src/HOL/Presburger.thy
author berghofe
Fri, 11 Jul 2003 14:55:17 +0200
changeset 14102 8af7334af4b3
parent 13876 68f4ed8311ac
child 14139 ca3dd7ed5ac5
permissions -rw-r--r--
- Installed specific code generator for equality enforcing that arguments do not have function types, which would result in an error message during compilation. - Added test case generators for basic types.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
     1
(*  Title:      HOL/Integ/Presburger.thy
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
     2
    ID:         $Id$
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
     3
    Author:     Amine Chaieb, Tobias Nipkow and Stefan Berghofer, TU Muenchen
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
     5
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
     6
File containing necessary theorems for the proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
     7
generation for Cooper Algorithm  
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
     8
*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
     9
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    10
theory Presburger = NatSimprocs
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    11
files
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    12
  ("cooper_dec.ML")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    13
  ("cooper_proof.ML")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    14
  ("qelim.ML")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    15
  ("presburger.ML"):
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    16
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    17
(* Theorem for unitifying the coeffitients of x in an existential formula*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    18
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    19
theorem unity_coeff_ex: "(\<exists>x::int. P (l * x)) = (\<exists>x. l dvd (1*x+0) \<and> P x)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    20
  apply (rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    21
  apply (erule exE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    22
  apply (rule_tac x = "l * x" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    23
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    24
  apply (erule exE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    25
  apply (erule conjE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    26
  apply (erule dvdE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    27
  apply (rule_tac x = k in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    28
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    29
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    30
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    31
lemma uminus_dvd_conv: "(d dvd (t::int)) = (-d dvd t)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    32
apply(unfold dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    33
apply(rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    34
apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    35
apply(rename_tac k)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    36
apply(rule_tac x = "-k" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    37
apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    38
apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    39
apply(rename_tac k)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    40
apply(rule_tac x = "-k" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    41
apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    42
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    43
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    44
lemma uminus_dvd_conv': "(d dvd (t::int)) = (d dvd -t)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    45
apply(unfold dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    46
apply(rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    47
apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    48
apply(rule_tac x = "-k" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    49
apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    50
apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    51
apply(rule_tac x = "-k" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    52
apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    53
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    54
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    55
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    56
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    57
(*Theorems for the combination of proofs of the equality of P and P_m for integers x less than some integer z.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    58
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    59
theorem eq_minf_conjI: "\<exists>z1::int. \<forall>x. x < z1 \<longrightarrow> (A1 x = A2 x) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    60
  \<exists>z2::int. \<forall>x. x < z2 \<longrightarrow> (B1 x = B2 x) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    61
  \<exists>z::int. \<forall>x. x < z \<longrightarrow> ((A1 x \<and> B1 x) = (A2 x \<and> B2 x))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    62
  apply (erule exE)+
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    63
  apply (rule_tac x = "min z1 z2" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    64
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    65
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    66
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    67
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    68
theorem eq_minf_disjI: "\<exists>z1::int. \<forall>x. x < z1 \<longrightarrow> (A1 x = A2 x) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    69
  \<exists>z2::int. \<forall>x. x < z2 \<longrightarrow> (B1 x = B2 x) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    70
  \<exists>z::int. \<forall>x. x < z \<longrightarrow> ((A1 x \<or> B1 x) = (A2 x \<or> B2 x))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    71
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    72
  apply (erule exE)+
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    73
  apply (rule_tac x = "min z1 z2" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    74
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    75
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    76
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    77
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    78
(*Theorems for the combination of proofs of the equality of P and P_m for integers x greather than some integer z.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    79
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    80
theorem eq_pinf_conjI: "\<exists>z1::int. \<forall>x. z1 < x \<longrightarrow> (A1 x = A2 x) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    81
  \<exists>z2::int. \<forall>x. z2 < x \<longrightarrow> (B1 x = B2 x) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    82
  \<exists>z::int. \<forall>x. z < x \<longrightarrow> ((A1 x \<and> B1 x) = (A2 x \<and> B2 x))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    83
  apply (erule exE)+
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    84
  apply (rule_tac x = "max z1 z2" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    85
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    86
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    87
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    88
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    89
theorem eq_pinf_disjI: "\<exists>z1::int. \<forall>x. z1 < x \<longrightarrow> (A1 x = A2 x) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    90
  \<exists>z2::int. \<forall>x. z2 < x \<longrightarrow> (B1 x = B2 x) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    91
  \<exists>z::int. \<forall>x. z < x  \<longrightarrow> ((A1 x \<or> B1 x) = (A2 x \<or> B2 x))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    92
  apply (erule exE)+
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    93
  apply (rule_tac x = "max z1 z2" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    94
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    95
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    96
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    97
(*Theorems for the combination of proofs of the modulo D property for P
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    98
pluusinfinity*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    99
(* FIXME : This is THE SAME theorem as for the minusinf version, but with +k.. instead of -k.. In the future replace these both with only one*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   100
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   101
theorem modd_pinf_conjI: "\<forall>(x::int) k. A x = A (x+k*d) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   102
  \<forall>(x::int) k. B x = B (x+k*d) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   103
  \<forall>(x::int) (k::int). (A x \<and> B x) = (A (x+k*d) \<and> B (x+k*d))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   104
  by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   105
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   106
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   107
theorem modd_pinf_disjI: "\<forall>(x::int) k. A x = A (x+k*d) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   108
  \<forall>(x::int) k. B x = B (x+k*d) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   109
  \<forall>(x::int) (k::int). (A x \<or> B x) = (A (x+k*d) \<or> B (x+k*d))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   110
  by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   111
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   112
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   113
(*This is one of the cases where the simplifed formula is prooved to habe some property
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   114
(in relation to P_m) but we need to proove the property for the original formula (P_m)*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   115
(*FIXME : This is exaclty the same thm as for minusinf.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   116
lemma pinf_simp_eq: "ALL x. P(x) = Q(x) ==> (EX (x::int). P(x)) --> (EX (x::int). F(x))  ==> (EX (x::int). Q(x)) --> (EX (x::int). F(x)) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   117
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   118
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   119
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   120
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   121
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   122
(*Theorems for the combination of proofs of the modulo D property for P
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   123
minusinfinity*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   124
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   125
theorem modd_minf_conjI: "\<forall>(x::int) k. A x = A (x-k*d) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   126
  \<forall>(x::int) k. B x = B (x-k*d) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   127
  \<forall>(x::int) (k::int). (A x \<and> B x) = (A (x-k*d) \<and> B (x-k*d))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   128
  by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   129
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   130
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   131
theorem modd_minf_disjI: "\<forall>(x::int) k. A x = A (x-k*d) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   132
  \<forall>(x::int) k. B x = B (x-k*d) \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   133
  \<forall>(x::int) (k::int). (A x \<or> B x) = (A (x-k*d) \<or> B (x-k*d))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   134
  by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   135
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   136
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   137
(*This is one of the cases where the simplifed formula is prooved to habe some property
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   138
(in relation to P_m) but we need to proove the property for the original formula (P_m)*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   139
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   140
lemma minf_simp_eq: "ALL x. P(x) = Q(x) ==> (EX (x::int). P(x)) --> (EX (x::int). F(x))  ==> (EX (x::int). Q(x)) --> (EX (x::int). F(x)) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   141
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   142
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   143
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   144
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   145
(*theorem needed for prooving at runtime divide properties using the arithmetic tatic
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   146
(who knows only about modulo = 0)*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   147
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   148
lemma zdvd_iff_zmod_eq_0: "(m dvd n) = (n mod m = (0::int))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   149
by(simp add:dvd_def zmod_eq_0_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   150
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   151
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   152
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   153
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   154
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   155
(*Theorems used for the combination of proof for the backwards direction of cooper's
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   156
theorem. they rely exclusively on Predicate calculus.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   157
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   158
lemma not_ast_p_disjI: "(ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (a::int) : A. Q(a - j)) --> P1(x) --> P1(x + d))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   159
==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   160
(ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (a::int) : A. Q(a - j)) --> P2(x) --> P2(x + d))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   161
==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   162
(ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (a::int) : A. Q(a - j)) -->(P1(x) \<or> P2(x)) --> (P1(x + d) \<or> P2(x + d))) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   163
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   164
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   165
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   166
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   167
lemma not_ast_p_conjI: "(ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (a::int) : A. Q(a- j)) --> P1(x) --> P1(x + d))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   168
==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   169
(ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (a::int) : A. Q(a - j)) --> P2(x) --> P2(x + d))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   170
==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   171
(ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (a::int) : A. Q(a - j)) -->(P1(x) \<and> P2(x)) --> (P1(x + d)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   172
\<and> P2(x + d))) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   173
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   174
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   175
lemma not_ast_p_Q_elim: "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   176
(ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (a::int) : A. Q(a - j)) -->P(x) --> P(x + d))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   177
==> ( P = Q )
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   178
==> (ALL x. ~(EX (j::int) : {1..d}. EX (a::int) : A. P(a - j)) -->P(x) --> P(x + d))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   179
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   180
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   181
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   182
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   183
(*Theorems used for the combination of proof for the backwards direction of cooper's
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   184
theorem. they rely exclusively on Predicate calculus.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   185
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   186
lemma not_bst_p_disjI: "(ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (b::int) : B. Q(b+j)) --> P1(x) --> P1(x - d))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   187
==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   188
(ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (b::int) : B. Q(b+j)) --> P2(x) --> P2(x - d))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   189
==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   190
(ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (b::int) : B. Q(b+j)) -->(P1(x) \<or> P2(x)) --> (P1(x - d)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   191
\<or> P2(x-d))) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   192
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   193
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   194
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   195
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   196
lemma not_bst_p_conjI: "(ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (b::int) : B. Q(b+j)) --> P1(x) --> P1(x - d))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   197
==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   198
(ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (b::int) : B. Q(b+j)) --> P2(x) --> P2(x - d))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   199
==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   200
(ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (b::int) : B. Q(b+j)) -->(P1(x) \<and> P2(x)) --> (P1(x - d)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   201
\<and> P2(x-d))) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   202
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   203
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   204
lemma not_bst_p_Q_elim: "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   205
(ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (b::int) : B. Q(b+j)) -->P(x) --> P(x - d)) 
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   206
==> ( P = Q )
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   207
==> (ALL x. ~(EX (j::int) : {1..d}. EX (b::int) : B. P(b+j)) -->P(x) --> P(x - d))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   208
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   209
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   210
(*The Theorem for the second proof step- about bset. it is trivial too. *)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   211
lemma bst_thm: " (EX (j::int) : {1..d}. EX (b::int) : B. P (b+j) )--> (EX x::int. P (x)) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   212
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   213
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   214
(*The Theorem for the second proof step- about aset. it is trivial too. *)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   215
lemma ast_thm: " (EX (j::int) : {1..d}. EX (a::int) : A. P (a - j) )--> (EX x::int. P (x)) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   216
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   217
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   218
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   219
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   220
(*This is the first direction of cooper's theorem*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   221
lemma cooper_thm: "(R --> (EX x::int. P x))  ==> (Q -->(EX x::int.  P x )) ==> ((R|Q) --> (EX x::int. P x )) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   222
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   223
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   224
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   225
(*The full cooper's theoorem in its equivalence Form- Given the premisses it is trivial
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   226
too, it relies exclusively on prediacte calculus.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   227
lemma cooper_eq_thm: "(R --> (EX x::int. P x))  ==> (Q -->(EX x::int.  P x )) ==> ((~Q)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   228
--> (EX x::int. P x ) --> R) ==> (EX x::int. P x) = R|Q "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   229
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   230
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   231
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   232
(*Some of the atomic theorems generated each time the atom does not depend on x, they
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   233
are trivial.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   234
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   235
lemma  fm_eq_minf: "EX z::int. ALL x. x < z --> (P = P) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   236
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   237
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   238
lemma  fm_modd_minf: "ALL (x::int). ALL (k::int). (P = P)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   239
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   240
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   241
lemma not_bst_p_fm: "ALL (x::int). Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (b::int) : B. Q(b+j)) --> fm --> fm"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   242
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   243
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   244
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   245
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   246
lemma  fm_eq_pinf: "EX z::int. ALL x. z < x --> (P = P) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   247
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   248
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   249
(* The next 2 thms are the same as the minusinf version*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   250
lemma  fm_modd_pinf: "ALL (x::int). ALL (k::int). (P = P)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   251
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   252
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   253
lemma not_ast_p_fm: "ALL (x::int). Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (a::int) : A. Q(a - j)) --> fm --> fm"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   254
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   255
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   256
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   257
(* Theorems to be deleted from simpset when proving simplified formulaes*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   258
lemma P_eqtrue: "(P=True) = P"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   259
  by rules
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   260
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   261
lemma P_eqfalse: "(P=False) = (~P)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   262
  by rules
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   263
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   264
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   265
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   266
(*Theorems for the generation of the bachwards direction of cooper's theorem*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   267
(*These are the 6 interesting atomic cases which have to be proved relying on the
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   268
properties of B-set ant the arithmetic and contradiction proofs*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   269
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   270
lemma not_bst_p_lt: "0 < (d::int) ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   271
 ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (b::int) : B. Q(b+j)) --> ( 0 < -x + a) --> (0 < -(x - d) + a )"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   272
by arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   273
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   274
lemma not_bst_p_gt: "\<lbrakk> (g::int) \<in> B; g = -a \<rbrakk> \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   275
 ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (b::int) : B. Q(b+j)) --> (0 < (x) + a) --> ( 0 < (x - d) + a)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   276
apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   277
apply(rule ccontr)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   278
apply(drule_tac x = "x+a" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   279
apply(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   280
apply(drule_tac x = "-a" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   281
apply assumption
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   282
apply(simp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   283
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   284
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   285
lemma not_bst_p_eq: "\<lbrakk> 0 < d; (g::int) \<in> B; g = -a - 1 \<rbrakk> \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   286
 ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (b::int) : B. Q(b+j)) --> (0 = x + a) --> (0 = (x - d) + a )"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   287
apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   288
apply(subgoal_tac "x = -a")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   289
 prefer 2 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   290
apply(drule_tac x = "1" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   291
apply(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   292
apply(drule_tac x = "-a- 1" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   293
apply assumption
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   294
apply(simp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   295
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   296
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   297
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   298
lemma not_bst_p_ne: "\<lbrakk> 0 < d; (g::int) \<in> B; g = -a \<rbrakk> \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   299
 ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (b::int) : B. Q(b+j)) --> ~(0 = x + a) --> ~(0 = (x - d) + a)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   300
apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   301
apply(subgoal_tac "x = -a+d")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   302
 prefer 2 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   303
apply(drule_tac x = "d" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   304
apply(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   305
apply(drule_tac x = "-a" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   306
apply assumption
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   307
apply(simp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   308
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   309
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   310
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   311
lemma not_bst_p_dvd: "(d1::int) dvd d ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   312
 ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (b::int) : B. Q(b+j)) --> d1 dvd (x + a) --> d1 dvd ((x - d) + a )"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   313
apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   314
apply(rename_tac m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   315
apply(rule_tac x = "m - k" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   316
apply(simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   317
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   318
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   319
lemma not_bst_p_ndvd: "(d1::int) dvd d ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   320
 ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (b::int) : B. Q(b+j)) --> ~(d1 dvd (x + a)) --> ~(d1 dvd ((x - d) + a ))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   321
apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   322
apply(rename_tac m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   323
apply(erule_tac x = "m + k" in allE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   324
apply(simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   325
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   326
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   327
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   328
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   329
(*Theorems for the generation of the bachwards direction of cooper's theorem*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   330
(*These are the 6 interesting atomic cases which have to be proved relying on the
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   331
properties of A-set ant the arithmetic and contradiction proofs*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   332
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   333
lemma not_ast_p_gt: "0 < (d::int) ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   334
 ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (a::int) : A. Q(a - j)) --> ( 0 < x + t) --> (0 < (x + d) + t )"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   335
by arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   336
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   337
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   338
lemma not_ast_p_lt: "\<lbrakk>0 < d ;(t::int) \<in> A \<rbrakk> \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   339
 ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (a::int) : A. Q(a - j)) --> (0 < -x + t) --> ( 0 < -(x + d) + t)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   340
  apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   341
  apply (rule ccontr)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   342
  apply (drule_tac x = "t-x" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   343
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   344
  apply (drule_tac x = "t" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   345
  apply assumption
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   346
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   347
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   348
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   349
lemma not_ast_p_eq: "\<lbrakk> 0 < d; (g::int) \<in> A; g = -t + 1 \<rbrakk> \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   350
 ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (a::int) : A. Q(a - j)) --> (0 = x + t) --> (0 = (x + d) + t )"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   351
  apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   352
  apply (drule_tac x="1" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   353
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   354
  apply (drule_tac x="- t + 1" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   355
  apply assumption
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   356
  apply(subgoal_tac "x = -t")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   357
  prefer 2 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   358
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   359
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   360
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   361
lemma not_ast_p_ne: "\<lbrakk> 0 < d; (g::int) \<in> A; g = -t \<rbrakk> \<Longrightarrow>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   362
 ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (a::int) : A. Q(a - j)) --> ~(0 = x + t) --> ~(0 = (x + d) + t)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   363
  apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   364
  apply (subgoal_tac "x = -t-d")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   365
  prefer 2 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   366
  apply (drule_tac x = "d" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   367
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   368
  apply (drule_tac x = "-t" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   369
  apply assumption
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   370
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   371
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   372
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   373
lemma not_ast_p_dvd: "(d1::int) dvd d ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   374
 ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (a::int) : A. Q(a - j)) --> d1 dvd (x + t) --> d1 dvd ((x + d) + t )"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   375
  apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   376
  apply(rename_tac m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   377
  apply(rule_tac x = "m + k" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   378
  apply(simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   379
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   380
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   381
lemma not_ast_p_ndvd: "(d1::int) dvd d ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   382
 ALL x. Q(x::int) \<and> ~(EX (j::int) : {1..d}. EX (a::int) : A. Q(a - j)) --> ~(d1 dvd (x + t)) --> ~(d1 dvd ((x + d) + t ))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   383
  apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   384
  apply(rename_tac m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   385
  apply(erule_tac x = "m - k" in allE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   386
  apply(simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   387
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   388
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   389
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   390
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   391
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   392
(*These are the atomic cases for the proof generation for the modulo D property for P
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   393
plusinfinity*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   394
(*They are fully based on arithmetics*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   395
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   396
lemma  dvd_modd_pinf: "((d::int) dvd d1) ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   397
 (ALL (x::int). ALL (k::int). (((d::int) dvd (x + t)) = (d dvd (x+k*d1 + t))))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   398
  apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   399
  apply(rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   400
  apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   401
  apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   402
  apply(rule_tac x = "m + n*k" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   403
  apply(simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   404
  apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   405
  apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   406
  apply(rule_tac x = "m - n*k" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   407
  apply(simp add:int_distrib zmult_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   408
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   409
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   410
lemma  not_dvd_modd_pinf: "((d::int) dvd d1) ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   411
 (ALL (x::int). ALL k. (~((d::int) dvd (x + t))) = (~(d dvd (x+k*d1 + t))))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   412
  apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   413
  apply(rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   414
  apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   415
  apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   416
  apply(erule_tac x = "m - n*k" in allE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   417
  apply(simp add:int_distrib zmult_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   418
  apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   419
  apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   420
  apply(erule_tac x = "m + n*k" in allE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   421
  apply(simp add:int_distrib zmult_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   422
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   423
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   424
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   425
(*These are the atomic cases for the proof generation for the equivalence of P and P
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   426
plusinfinity for integers x greather than some integer z.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   427
(*They are fully based on arithmetics*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   428
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   429
lemma  eq_eq_pinf: "EX z::int. ALL x. z < x --> (( 0 = x +t ) = False )"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   430
  apply(rule_tac x = "-t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   431
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   432
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   433
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   434
lemma  neq_eq_pinf: "EX z::int. ALL x.  z < x --> ((~( 0 = x +t )) = True )"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   435
  apply(rule_tac x = "-t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   436
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   437
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   438
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   439
lemma  le_eq_pinf: "EX z::int. ALL x.  z < x --> ( 0 < x +t  = True )"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   440
  apply(rule_tac x = "-t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   441
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   442
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   443
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   444
lemma  len_eq_pinf: "EX z::int. ALL x. z < x  --> (0 < -x +t  = False )"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   445
  apply(rule_tac x = "t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   446
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   447
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   448
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   449
lemma  dvd_eq_pinf: "EX z::int. ALL x.  z < x --> ((d dvd (x + t)) = (d dvd (x + t))) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   450
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   451
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   452
lemma  not_dvd_eq_pinf: "EX z::int. ALL x. z < x  --> ((~(d dvd (x + t))) = (~(d dvd (x + t)))) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   453
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   454
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   455
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   456
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   457
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   458
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   459
(*These are the atomic cases for the proof generation for the modulo D property for P
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   460
minusinfinity*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   461
(*They are fully based on arithmetics*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   462
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   463
lemma  dvd_modd_minf: "((d::int) dvd d1) ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   464
 (ALL (x::int). ALL (k::int). (((d::int) dvd (x + t)) = (d dvd (x-k*d1 + t))))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   465
apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   466
apply(rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   467
apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   468
apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   469
apply(rule_tac x = "m - n*k" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   470
apply(simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   471
apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   472
apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   473
apply(rule_tac x = "m + n*k" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   474
apply(simp add:int_distrib zmult_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   475
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   476
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   477
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   478
lemma  not_dvd_modd_minf: "((d::int) dvd d1) ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   479
 (ALL (x::int). ALL k. (~((d::int) dvd (x + t))) = (~(d dvd (x-k*d1 + t))))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   480
apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   481
apply(rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   482
apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   483
apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   484
apply(erule_tac x = "m + n*k" in allE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   485
apply(simp add:int_distrib zmult_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   486
apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   487
apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   488
apply(erule_tac x = "m - n*k" in allE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   489
apply(simp add:int_distrib zmult_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   490
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   491
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   492
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   493
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   494
(*These are the atomic cases for the proof generation for the equivalence of P and P
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   495
minusinfinity for integers x less than some integer z.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   496
(*They are fully based on arithmetics*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   497
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   498
lemma  eq_eq_minf: "EX z::int. ALL x. x < z --> (( 0 = x +t ) = False )"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   499
apply(rule_tac x = "-t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   500
apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   501
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   502
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   503
lemma  neq_eq_minf: "EX z::int. ALL x. x < z --> ((~( 0 = x +t )) = True )"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   504
apply(rule_tac x = "-t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   505
apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   506
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   507
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   508
lemma  le_eq_minf: "EX z::int. ALL x. x < z --> ( 0 < x +t  = False )"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   509
apply(rule_tac x = "-t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   510
apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   511
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   512
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   513
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   514
lemma  len_eq_minf: "EX z::int. ALL x. x < z --> (0 < -x +t  = True )"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   515
apply(rule_tac x = "t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   516
apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   517
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   518
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   519
lemma  dvd_eq_minf: "EX z::int. ALL x. x < z --> ((d dvd (x + t)) = (d dvd (x + t))) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   520
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   521
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   522
lemma  not_dvd_eq_minf: "EX z::int. ALL x. x < z --> ((~(d dvd (x + t))) = (~(d dvd (x + t)))) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   523
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   524
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   525
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   526
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   527
(*This Theorem combines whithnesses about P minusinfinity to schow one component of the
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   528
equivalence proof for cooper's theorem*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   529
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   530
(* FIXME: remove once they are part of the distribution *)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   531
theorem int_ge_induct[consumes 1,case_names base step]:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   532
  assumes ge: "k \<le> (i::int)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   533
        base: "P(k)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   534
        step: "\<And>i. \<lbrakk>k \<le> i; P i\<rbrakk> \<Longrightarrow> P(i+1)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   535
  shows "P i"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   536
proof -
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   537
  { fix n have "\<And>i::int. n = nat(i-k) \<Longrightarrow> k <= i \<Longrightarrow> P i"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   538
    proof (induct n)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   539
      case 0
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   540
      hence "i = k" by arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   541
      thus "P i" using base by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   542
    next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   543
      case (Suc n)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   544
      hence "n = nat((i - 1) - k)" by arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   545
      moreover
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   546
      have ki1: "k \<le> i - 1" using Suc.prems by arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   547
      ultimately
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   548
      have "P(i - 1)" by(rule Suc.hyps)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   549
      from step[OF ki1 this] show ?case by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   550
    qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   551
  }
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   552
  from this ge show ?thesis by fast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   553
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   554
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   555
theorem int_gr_induct[consumes 1,case_names base step]:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   556
  assumes gr: "k < (i::int)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   557
        base: "P(k+1)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   558
        step: "\<And>i. \<lbrakk>k < i; P i\<rbrakk> \<Longrightarrow> P(i+1)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   559
  shows "P i"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   560
apply(rule int_ge_induct[of "k + 1"])
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   561
  using gr apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   562
 apply(rule base)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   563
apply(rule step)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   564
 apply simp+
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   565
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   566
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   567
lemma decr_lemma: "0 < (d::int) \<Longrightarrow> x - (abs(x-z)+1) * d < z"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   568
apply(induct rule: int_gr_induct)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   569
 apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   570
 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   571
apply (simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   572
apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   573
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   574
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   575
lemma incr_lemma: "0 < (d::int) \<Longrightarrow> z < x + (abs(x-z)+1) * d"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   576
apply(induct rule: int_gr_induct)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   577
 apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   578
 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   579
apply (simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   580
apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   581
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   582
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   583
lemma  minusinfinity:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   584
  assumes "0 < d" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   585
    P1eqP1: "ALL x k. P1 x = P1(x - k*d)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   586
    ePeqP1: "EX z::int. ALL x. x < z \<longrightarrow> (P x = P1 x)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   587
  shows "(EX x. P1 x) \<longrightarrow> (EX x. P x)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   588
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   589
  assume eP1: "EX x. P1 x"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   590
  then obtain x where P1: "P1 x" ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   591
  from ePeqP1 obtain z where P1eqP: "ALL x. x < z \<longrightarrow> (P x = P1 x)" ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   592
  let ?w = "x - (abs(x-z)+1) * d"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   593
  show "EX x. P x"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   594
  proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   595
    have w: "?w < z" by(rule decr_lemma)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   596
    have "P1 x = P1 ?w" using P1eqP1 by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   597
    also have "\<dots> = P(?w)" using w P1eqP by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   598
    finally show "P ?w" using P1 by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   599
  qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   600
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   601
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   602
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   603
(*This Theorem combines whithnesses about P minusinfinity to schow one component of the
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   604
equivalence proof for cooper's theorem*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   605
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   606
lemma plusinfinity:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   607
  assumes "0 < d" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   608
    P1eqP1: "ALL (x::int) (k::int). P1 x = P1 (x + k * d)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   609
    ePeqP1: "EX z::int. ALL x. z < x  --> (P x = P1 x)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   610
  shows "(EX x::int. P1 x) --> (EX x::int. P x)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   611
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   612
  assume eP1: "EX x. P1 x"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   613
  then obtain x where P1: "P1 x" ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   614
  from ePeqP1 obtain z where P1eqP: "ALL x. z < x \<longrightarrow> (P x = P1 x)" ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   615
  let ?w = "x + (abs(x-z)+1) * d"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   616
  show "EX x. P x"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   617
  proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   618
    have w: "z < ?w" by(rule incr_lemma)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   619
    have "P1 x = P1 ?w" using P1eqP1 by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   620
    also have "\<dots> = P(?w)" using w P1eqP by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   621
    finally show "P ?w" using P1 by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   622
  qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   623
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   624
 
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   625
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   626
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   627
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   628
(*Theorem for periodic function on discrete sets*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   629
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   630
lemma minf_vee:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   631
  assumes dpos: "(0::int) < d" and modd: "ALL x k. P x = P(x - k*d)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   632
  shows "(EX x. P x) = (EX j : {1..d}. P j)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   633
  (is "?LHS = ?RHS")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   634
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   635
  assume ?LHS
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   636
  then obtain x where P: "P x" ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   637
  have "x mod d = x - (x div d)*d"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   638
    by(simp add:zmod_zdiv_equality zmult_ac eq_zdiff_eq)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   639
  hence Pmod: "P x = P(x mod d)" using modd by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   640
  show ?RHS
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   641
  proof (cases)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   642
    assume "x mod d = 0"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   643
    hence "P 0" using P Pmod by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   644
    moreover have "P 0 = P(0 - (-1)*d)" using modd by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   645
    ultimately have "P d" by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   646
    moreover have "d : {1..d}" using dpos by(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   647
    ultimately show ?RHS ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   648
  next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   649
    assume not0: "x mod d \<noteq> 0"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   650
    have "P(x mod d)" using dpos P Pmod by(simp add:pos_mod_sign pos_mod_bound)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   651
    moreover have "x mod d : {1..d}"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   652
    proof -
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   653
      have "0 \<le> x mod d" by(rule pos_mod_sign)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   654
      moreover have "x mod d < d" by(rule pos_mod_bound)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   655
      ultimately show ?thesis using not0 by(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   656
    qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   657
    ultimately show ?RHS ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   658
  qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   659
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   660
  assume ?RHS thus ?LHS by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   661
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   662
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   663
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   664
(*Theorem for periodic function on discrete sets*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   665
lemma pinf_vee:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   666
  assumes dpos: "0 < (d::int)" and modd: "ALL (x::int) (k::int). P x = P (x+k*d)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   667
  shows "(EX x::int. P x) = (EX (j::int) : {1..d} . P j)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   668
  (is "?LHS = ?RHS")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   669
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   670
  assume ?LHS
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   671
  then obtain x where P: "P x" ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   672
  have "x mod d = x + (-(x div d))*d"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   673
    by(simp add:zmod_zdiv_equality zmult_ac eq_zdiff_eq)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   674
  hence Pmod: "P x = P(x mod d)" using modd by (simp only:)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   675
  show ?RHS
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   676
  proof (cases)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   677
    assume "x mod d = 0"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   678
    hence "P 0" using P Pmod by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   679
    moreover have "P 0 = P(0 + 1*d)" using modd by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   680
    ultimately have "P d" by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   681
    moreover have "d : {1..d}" using dpos by(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   682
    ultimately show ?RHS ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   683
  next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   684
    assume not0: "x mod d \<noteq> 0"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   685
    have "P(x mod d)" using dpos P Pmod by(simp add:pos_mod_sign pos_mod_bound)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   686
    moreover have "x mod d : {1..d}"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   687
    proof -
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   688
      have "0 \<le> x mod d" by(rule pos_mod_sign)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   689
      moreover have "x mod d < d" by(rule pos_mod_bound)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   690
      ultimately show ?thesis using not0 by(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   691
    qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   692
    ultimately show ?RHS ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   693
  qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   694
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   695
  assume ?RHS thus ?LHS by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   696
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   697
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   698
lemma decr_mult_lemma:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   699
  assumes dpos: "(0::int) < d" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   700
          minus: "ALL x::int. P x \<longrightarrow> P(x - d)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   701
          knneg: "0 <= k"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   702
  shows "ALL x. P x \<longrightarrow> P(x - k*d)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   703
using knneg
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   704
proof (induct rule:int_ge_induct)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   705
  case base thus ?case by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   706
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   707
  case (step i)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   708
  show ?case
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   709
  proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   710
    fix x
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   711
    have "P x \<longrightarrow> P (x - i * d)" using step.hyps by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   712
    also have "\<dots> \<longrightarrow> P(x - (i + 1) * d)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   713
      using minus[THEN spec, of "x - i * d"]
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   714
      by (simp add:int_distrib zdiff_zdiff_eq[symmetric])
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   715
    ultimately show "P x \<longrightarrow> P(x - (i + 1) * d)" by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   716
  qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   717
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   718
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   719
lemma incr_mult_lemma:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   720
  assumes dpos: "(0::int) < d" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   721
          plus: "ALL x::int. P x \<longrightarrow> P(x + d)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   722
          knneg: "0 <= k"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   723
  shows "ALL x. P x \<longrightarrow> P(x + k*d)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   724
using knneg
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   725
proof (induct rule:int_ge_induct)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   726
  case base thus ?case by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   727
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   728
  case (step i)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   729
  show ?case
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   730
  proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   731
    fix x
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   732
    have "P x \<longrightarrow> P (x + i * d)" using step.hyps by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   733
    also have "\<dots> \<longrightarrow> P(x + (i + 1) * d)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   734
      using plus[THEN spec, of "x + i * d"]
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   735
      by (simp add:int_distrib zadd_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   736
    ultimately show "P x \<longrightarrow> P(x + (i + 1) * d)" by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   737
  qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   738
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   739
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   740
lemma cpmi_eq: "0 < D \<Longrightarrow> (EX z::int. ALL x. x < z --> (P x = P1 x))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   741
==> (EX (j::int) : {1..D}. EX (b::int) : B. P (b+j)) --> (EX (x::int). P x) 
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   742
==> ALL x.~(EX (j::int) : {1..D}. EX (b::int) : B. P(b+j)) --> P (x) --> P (x - D) 
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   743
==> (ALL (x::int). ALL (k::int). ((P1 x)= (P1 (x-k*D))))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   744
==> (EX (x::int). P(x)) = ((EX (j::int) : {1..D} . (P1(j))) | (EX (j::int) : {1..D}. EX (b::int) : B. P (b+j)))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   745
apply(rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   746
prefer 2
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   747
apply(drule minusinfinity)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   748
apply assumption+
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   749
apply(fastsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   750
apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   751
apply(subgoal_tac "!!k. 0<=k \<Longrightarrow> !x. P x \<longrightarrow> P (x - k*D)")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   752
apply(frule_tac x = x and z=z in decr_lemma)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   753
apply(subgoal_tac "P1(x - (\<bar>x - z\<bar> + 1) * D)")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   754
prefer 2
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   755
apply(subgoal_tac "0 <= (\<bar>x - z\<bar> + 1)")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   756
prefer 2 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   757
 apply fastsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   758
apply(drule (1) minf_vee)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   759
apply blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   760
apply(blast dest:decr_mult_lemma)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   761
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   762
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   763
(* Cooper Thm `, plus infinity version*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   764
lemma cppi_eq: "0 < D \<Longrightarrow> (EX z::int. ALL x. z < x --> (P x = P1 x))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   765
==> (EX (j::int) : {1..D}. EX (a::int) : A. P (a - j)) --> (EX (x::int). P x) 
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   766
==> ALL x.~(EX (j::int) : {1..D}. EX (a::int) : A. P(a - j)) --> P (x) --> P (x + D) 
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   767
==> (ALL (x::int). ALL (k::int). ((P1 x)= (P1 (x+k*D))))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   768
==> (EX (x::int). P(x)) = ((EX (j::int) : {1..D} . (P1(j))) | (EX (j::int) : {1..D}. EX (a::int) : A. P (a - j)))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   769
  apply(rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   770
  prefer 2
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   771
  apply(drule plusinfinity)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   772
  apply assumption+
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   773
  apply(fastsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   774
  apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   775
  apply(subgoal_tac "!!k. 0<=k \<Longrightarrow> !x. P x \<longrightarrow> P (x + k*D)")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   776
  apply(frule_tac x = x and z=z in incr_lemma)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   777
  apply(subgoal_tac "P1(x + (\<bar>x - z\<bar> + 1) * D)")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   778
  prefer 2
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   779
  apply(subgoal_tac "0 <= (\<bar>x - z\<bar> + 1)")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   780
  prefer 2 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   781
  apply fastsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   782
  apply(drule (1) pinf_vee)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   783
  apply blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   784
  apply(blast dest:incr_mult_lemma)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   785
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   786
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   787
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   788
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   789
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   790
(*Theorems for the quantifier elminination Functions.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   791
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   792
lemma qe_ex_conj: "(EX (x::int). A x) = R
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   793
		==> (EX (x::int). P x) = (Q & (EX x::int. A x))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   794
		==> (EX (x::int). P x) = (Q & R)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   795
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   796
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   797
lemma qe_ex_nconj: "(EX (x::int). P x) = (True & Q)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   798
		==> (EX (x::int). P x) = Q"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   799
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   800
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   801
lemma qe_conjI: "P1 = P2 ==> Q1 = Q2 ==> (P1 & Q1) = (P2 & Q2)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   802
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   803
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   804
lemma qe_disjI: "P1 = P2 ==> Q1 = Q2 ==> (P1 | Q1) = (P2 | Q2)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   805
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   806
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   807
lemma qe_impI: "P1 = P2 ==> Q1 = Q2 ==> (P1 --> Q1) = (P2 --> Q2)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   808
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   809
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   810
lemma qe_eqI: "P1 = P2 ==> Q1 = Q2 ==> (P1 = Q1) = (P2 = Q2)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   811
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   812
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   813
lemma qe_Not: "P = Q ==> (~P) = (~Q)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   814
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   815
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   816
lemma qe_ALL: "(EX x. ~P x) = R ==> (ALL x. P x) = (~R)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   817
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   818
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   819
(* Theorems for proving NNF *)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   820
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   821
lemma nnf_im: "((~P) = P1) ==> (Q=Q1) ==> ((P --> Q) = (P1 | Q1))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   822
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   823
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   824
lemma nnf_eq: "((P & Q) = (P1 & Q1)) ==> (((~P) & (~Q)) = (P2 & Q2)) ==> ((P = Q) = ((P1 & Q1)|(P2 & Q2)))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   825
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   826
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   827
lemma nnf_nn: "(P = Q) ==> ((~~P) = Q)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   828
  by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   829
lemma nnf_ncj: "((~P) = P1) ==> ((~Q) = Q1) ==> ((~(P & Q)) = (P1 | Q1))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   830
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   831
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   832
lemma nnf_ndj: "((~P) = P1) ==> ((~Q) = Q1) ==> ((~(P | Q)) = (P1 & Q1))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   833
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   834
lemma nnf_nim: "(P = P1) ==> ((~Q) = Q1) ==> ((~(P --> Q)) = (P1 & Q1))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   835
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   836
lemma nnf_neq: "((P & (~Q)) = (P1 & Q1)) ==> (((~P) & Q) = (P2 & Q2)) ==> ((~(P = Q)) = ((P1 & Q1)|(P2 & Q2)))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   837
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   838
lemma nnf_sdj: "((A & (~B)) = (A1 & B1)) ==> ((C & (~D)) = (C1 & D1)) ==> (A = (~C)) ==> ((~((A & B) | (C & D))) = ((A1 & B1) | (C1 & D1)))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   839
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   840
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   841
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   842
lemma qe_exI2: "A = B ==> (EX (x::int). A(x)) = (EX (x::int). B(x))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   843
  by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   844
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   845
lemma qe_exI: "(!!x::int. A x = B x) ==> (EX (x::int). A(x)) = (EX (x::int). B(x))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   846
  by rules
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   847
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   848
lemma qe_ALLI: "(!!x::int. A x = B x) ==> (ALL (x::int). A(x)) = (ALL (x::int). B(x))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   849
  by rules
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   850
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   851
lemma cp_expand: "(EX (x::int). P (x)) = (EX (j::int) : {1..d}. EX (b::int) : B. (P1 (j) | P(b+j)))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   852
==>(EX (x::int). P (x)) = (EX (j::int) : {1..d}. EX (b::int) : B. (P1 (j) | P(b+j))) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   853
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   854
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   855
lemma cppi_expand: "(EX (x::int). P (x)) = (EX (j::int) : {1..d}. EX (a::int) : A. (P1 (j) | P(a - j)))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   856
==>(EX (x::int). P (x)) = (EX (j::int) : {1..d}. EX (a::int) : A. (P1 (j) | P(a - j))) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   857
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   858
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   859
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   860
lemma simp_from_to: "{i..j::int} = (if j < i then {} else insert i {i+1..j})"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   861
apply(simp add:atLeastAtMost_def atLeast_def atMost_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   862
apply(fastsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   863
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   864
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   865
(* Theorems required for the adjustcoeffitienteq*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   866
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   867
lemma ac_dvd_eq: assumes not0: "0 ~= (k::int)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   868
shows "((m::int) dvd (c*n+t)) = (k*m dvd ((k*c)*n+(k*t)))" (is "?P = ?Q")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   869
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   870
  assume ?P
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   871
  thus ?Q
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   872
    apply(simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   873
    apply clarify
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   874
    apply(rename_tac d)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   875
    apply(drule_tac f = "op * k" in arg_cong)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   876
    apply(simp only:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   877
    apply(rule_tac x = "d" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   878
    apply(simp only:zmult_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   879
    done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   880
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   881
  assume ?Q
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   882
  then obtain d where "k * c * n + k * t = (k*m)*d" by(fastsimp simp:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   883
  hence "(c * n + t) * k = (m*d) * k" by(simp add:int_distrib zmult_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   884
  hence "((c * n + t) * k) div k = ((m*d) * k) div k" by(rule arg_cong[of _ _ "%t. t div k"])
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   885
  hence "c*n+t = m*d" by(simp add: zdiv_zmult_self1[OF not0[symmetric]])
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   886
  thus ?P by(simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   887
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   888
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   889
lemma ac_lt_eq: assumes gr0: "0 < (k::int)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   890
shows "((m::int) < (c*n+t)) = (k*m <((k*c)*n+(k*t)))" (is "?P = ?Q")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   891
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   892
  assume P: ?P
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   893
  show ?Q using zmult_zless_mono2[OF P gr0] by(simp add: int_distrib zmult_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   894
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   895
  assume ?Q
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   896
  hence "0 < k*(c*n + t - m)" by(simp add: int_distrib zmult_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   897
  with gr0 have "0 < (c*n + t - m)" by(simp add:int_0_less_mult_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   898
  thus ?P by(simp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   899
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   900
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   901
lemma ac_eq_eq : assumes not0: "0 ~= (k::int)" shows "((m::int) = (c*n+t)) = (k*m =((k*c)*n+(k*t)) )" (is "?P = ?Q")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   902
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   903
  assume ?P
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   904
  thus ?Q
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   905
    apply(drule_tac f = "op * k" in arg_cong)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   906
    apply(simp only:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   907
    done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   908
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   909
  assume ?Q
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   910
  hence "m * k = (c*n + t) * k" by(simp add:int_distrib zmult_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   911
  hence "((m) * k) div k = ((c*n + t) * k) div k" by(rule arg_cong[of _ _ "%t. t div k"])
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   912
  thus ?P by(simp add: zdiv_zmult_self1[OF not0[symmetric]])
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   913
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   914
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   915
lemma ac_pi_eq: assumes gr0: "0 < (k::int)" shows "(~((0::int) < (c*n + t))) = (0 < ((-k)*c)*n + ((-k)*t + k))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   916
proof -
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   917
  have "(~ (0::int) < (c*n + t)) = (0<1-(c*n + t))" by arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   918
  also have  "(1-(c*n + t)) = (-1*c)*n + (-t+1)" by(simp add: int_distrib zmult_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   919
  also have "0<(-1*c)*n + (-t+1) = (0 < (k*(-1*c)*n) + (k*(-t+1)))" by(rule ac_lt_eq[of _ 0,OF gr0,simplified])
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   920
  also have "(k*(-1*c)*n) + (k*(-t+1)) = ((-k)*c)*n + ((-k)*t + k)" by(simp add: int_distrib zmult_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   921
  finally show ?thesis .
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   922
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   923
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   924
lemma binminus_uminus_conv: "(a::int) - b = a + (-b)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   925
by arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   926
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   927
lemma  linearize_dvd: "(t::int) = t1 ==> (d dvd t) = (d dvd t1)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   928
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   929
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   930
lemma lf_lt: "(l::int) = ll ==> (r::int) = lr ==> (l < r) =(ll < lr)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   931
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   932
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   933
lemma lf_eq: "(l::int) = ll ==> (r::int) = lr ==> (l = r) =(ll = lr)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   934
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   935
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   936
lemma lf_dvd: "(l::int) = ll ==> (r::int) = lr ==> (l dvd r) =(ll dvd lr)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   937
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   938
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   939
(* Theorems for transforming predicates on nat to predicates on int*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   940
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   941
theorem all_nat: "(\<forall>x::nat. P x) = (\<forall>x::int. 0 <= x \<longrightarrow> P (nat x))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   942
  by (simp split add: split_nat)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   943
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   944
theorem ex_nat: "(\<exists>x::nat. P x) = (\<exists>x::int. 0 <= x \<and> P (nat x))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   945
  apply (simp split add: split_nat)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   946
  apply (rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   947
  apply (erule exE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   948
  apply (rule_tac x = "int x" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   949
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   950
  apply (erule exE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   951
  apply (rule_tac x = "nat x" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   952
  apply (erule conjE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   953
  apply (erule_tac x = "nat x" in allE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   954
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   955
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   956
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   957
theorem zdiff_int_split: "P (int (x - y)) =
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   958
  ((y \<le> x \<longrightarrow> P (int x - int y)) \<and> (x < y \<longrightarrow> P 0))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   959
  apply (case_tac "y \<le> x")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   960
  apply (simp_all add: zdiff_int)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   961
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   962
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   963
theorem zdvd_int: "(x dvd y) = (int x dvd int y)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   964
  apply (simp only: dvd_def ex_nat int_int_eq [symmetric] zmult_int [symmetric]
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   965
    nat_0_le cong add: conj_cong)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   966
  apply (rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   967
  apply rules
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   968
  apply (erule exE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   969
  apply (case_tac "x=0")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   970
  apply (rule_tac x=0 in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   971
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   972
  apply (case_tac "0 \<le> k")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   973
  apply rules
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   974
  apply (simp add: linorder_not_le)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   975
  apply (drule zmult_zless_mono2_neg [OF iffD2 [OF zero_less_int_conv]])
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   976
  apply assumption
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   977
  apply (simp add: zmult_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   978
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   979
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   980
theorem number_of1: "(0::int) <= number_of n \<Longrightarrow> (0::int) <= number_of (n BIT b)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   981
  by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   982
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   983
theorem number_of2: "(0::int) <= number_of bin.Pls" by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   984
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   985
theorem Suc_plus1: "Suc n = n + 1" by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   986
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   987
(* specific instances of congruence rules, to prevent simplifier from looping *)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   988
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   989
theorem imp_le_cong: "(0 <= x \<Longrightarrow> P = P') \<Longrightarrow> (0 <= (x::nat) \<longrightarrow> P) = (0 <= x \<longrightarrow> P')"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   990
  by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   991
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   992
theorem conj_le_cong: "(0 <= x \<Longrightarrow> P = P') \<Longrightarrow> (0 <= (x::nat) \<and> P) = (0 <= x \<and> P')"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   993
  by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   994
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   995
use "cooper_dec.ML"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   996
use "cooper_proof.ML"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   997
use "qelim.ML"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   998
use "presburger.ML"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   999
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
  1000
setup "Presburger.setup"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
  1001
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
  1002
end