src/HOL/Presburger.thy
author paulson
Mon, 12 Jan 2004 16:51:45 +0100
changeset 14353 79f9fbef9106
parent 14271 8ed6989228bb
child 14378 69c4d5997669
permissions -rw-r--r--
Added lemmas to Ring_and_Field with slightly modified simplification rules Deleted some little-used integer theorems, replacing them by the generic ones in Ring_and_Field Consolidated integer powers
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
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   211
(*This is the first direction of cooper's theorem*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   212
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
   213
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   214
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   215
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   216
(*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
   217
too, it relies exclusively on prediacte calculus.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   218
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
   219
--> (EX x::int. P x ) --> R) ==> (EX x::int. P x) = R|Q "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   220
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   221
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   222
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   223
(*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
   224
are trivial.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   225
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   226
lemma  fm_eq_minf: "EX z::int. ALL x. x < z --> (P = P) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   227
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   228
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   229
lemma  fm_modd_minf: "ALL (x::int). ALL (k::int). (P = P)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   230
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   231
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   232
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
   233
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   234
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   235
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   236
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   237
lemma  fm_eq_pinf: "EX z::int. ALL x. z < x --> (P = P) "
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   238
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   239
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   240
(* The next 2 thms are the same as the minusinf version*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   241
lemma  fm_modd_pinf: "ALL (x::int). ALL (k::int). (P = P)"
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
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
   245
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   246
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   247
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   248
(* Theorems to be deleted from simpset when proving simplified formulaes*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   249
lemma P_eqtrue: "(P=True) = P"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   250
  by rules
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   251
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   252
lemma P_eqfalse: "(P=False) = (~P)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   253
  by rules
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   254
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 for the generation of the bachwards direction of cooper's theorem*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   258
(*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
   259
properties of B-set ant the arithmetic and contradiction proofs*)
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 not_bst_p_lt: "0 < (d::int) ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   262
 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
   263
by arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   264
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   265
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
   266
 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
   267
apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   268
apply(rule ccontr)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   269
apply(drule_tac x = "x+a" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   270
apply(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   271
apply(drule_tac x = "-a" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   272
apply assumption
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   273
apply(simp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   274
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   275
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   276
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
   277
 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
   278
apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   279
apply(subgoal_tac "x = -a")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   280
 prefer 2 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   281
apply(drule_tac x = "1" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   282
apply(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   283
apply(drule_tac x = "-a- 1" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   284
apply assumption
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   285
apply(simp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   286
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   287
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   288
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   289
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
   290
 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
   291
apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   292
apply(subgoal_tac "x = -a+d")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   293
 prefer 2 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   294
apply(drule_tac x = "d" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   295
apply(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   296
apply(drule_tac x = "-a" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   297
apply assumption
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   298
apply(simp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   299
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   300
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   301
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   302
lemma not_bst_p_dvd: "(d1::int) dvd d ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   303
 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
   304
apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   305
apply(rename_tac m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   306
apply(rule_tac x = "m - k" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   307
apply(simp add:int_distrib)
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
lemma not_bst_p_ndvd: "(d1::int) dvd d ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   311
 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
   312
apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   313
apply(rename_tac m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   314
apply(erule_tac x = "m + k" in allE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   315
apply(simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   316
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   317
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   318
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   319
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   320
(*Theorems for the generation of the bachwards direction of cooper's theorem*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   321
(*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
   322
properties of A-set ant the arithmetic and contradiction proofs*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   323
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   324
lemma not_ast_p_gt: "0 < (d::int) ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   325
 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
   326
by arith
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
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
   330
 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
   331
  apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   332
  apply (rule ccontr)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   333
  apply (drule_tac x = "t-x" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   334
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   335
  apply (drule_tac x = "t" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   336
  apply assumption
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   337
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   338
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   339
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   340
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
   341
 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
   342
  apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   343
  apply (drule_tac x="1" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   344
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   345
  apply (drule_tac x="- t + 1" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   346
  apply assumption
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   347
  apply(subgoal_tac "x = -t")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   348
  prefer 2 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   349
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   350
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   351
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   352
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
   353
 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
   354
  apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   355
  apply (subgoal_tac "x = -t-d")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   356
  prefer 2 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   357
  apply (drule_tac x = "d" in bspec)
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
  apply (drule_tac x = "-t" in bspec)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   360
  apply assumption
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   361
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   362
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   363
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   364
lemma not_ast_p_dvd: "(d1::int) dvd d ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   365
 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
   366
  apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   367
  apply(rename_tac m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   368
  apply(rule_tac x = "m + k" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   369
  apply(simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   370
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   371
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   372
lemma not_ast_p_ndvd: "(d1::int) dvd d ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   373
 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
   374
  apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   375
  apply(rename_tac m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   376
  apply(erule_tac x = "m - k" in allE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   377
  apply(simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   378
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   379
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   380
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   381
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   382
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   383
(*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
   384
plusinfinity*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   385
(*They are fully based on arithmetics*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   386
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   387
lemma  dvd_modd_pinf: "((d::int) dvd d1) ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   388
 (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
   389
  apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   390
  apply(rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   391
  apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   392
  apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   393
  apply(rule_tac x = "m + n*k" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   394
  apply(simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   395
  apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   396
  apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   397
  apply(rule_tac x = "m - n*k" in exI)
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   398
  apply(simp add:int_distrib mult_ac)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   399
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   400
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   401
lemma  not_dvd_modd_pinf: "((d::int) dvd d1) ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   402
 (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
   403
  apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   404
  apply(rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   405
  apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   406
  apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   407
  apply(erule_tac x = "m - n*k" in allE)
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   408
  apply(simp add:int_distrib mult_ac)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   409
  apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   410
  apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   411
  apply(erule_tac x = "m + n*k" in allE)
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   412
  apply(simp add:int_distrib mult_ac)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   413
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   414
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   415
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   416
(*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
   417
plusinfinity for integers x greather than some integer z.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   418
(*They are fully based on arithmetics*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   419
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   420
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
   421
  apply(rule_tac x = "-t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   422
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   423
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   424
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   425
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
   426
  apply(rule_tac x = "-t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   427
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   428
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   429
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   430
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
   431
  apply(rule_tac x = "-t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   432
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   433
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   434
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   435
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
   436
  apply(rule_tac x = "t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   437
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   438
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   439
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   440
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
   441
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   442
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   443
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
   444
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   445
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   446
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   447
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   448
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   449
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   450
(*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
   451
minusinfinity*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   452
(*They are fully based on arithmetics*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   453
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   454
lemma  dvd_modd_minf: "((d::int) dvd d1) ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   455
 (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
   456
apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   457
apply(rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   458
apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   459
apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   460
apply(rule_tac x = "m - n*k" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   461
apply(simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   462
apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   463
apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   464
apply(rule_tac x = "m + n*k" in exI)
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   465
apply(simp add:int_distrib mult_ac)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   466
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   467
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   468
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   469
lemma  not_dvd_modd_minf: "((d::int) dvd d1) ==>
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   470
 (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
   471
apply(clarsimp simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   472
apply(rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   473
apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   474
apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   475
apply(erule_tac x = "m + n*k" in allE)
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   476
apply(simp add:int_distrib mult_ac)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   477
apply(clarsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   478
apply(rename_tac n m)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   479
apply(erule_tac x = "m - n*k" in allE)
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   480
apply(simp add:int_distrib mult_ac)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   481
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   482
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   483
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   484
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   485
(*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
   486
minusinfinity for integers x less than some integer z.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   487
(*They are fully based on arithmetics*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   488
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   489
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
   490
apply(rule_tac x = "-t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   491
apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   492
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   493
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   494
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
   495
apply(rule_tac x = "-t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   496
apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   497
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   498
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   499
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
   500
apply(rule_tac x = "-t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   501
apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   502
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   503
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   504
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   505
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
   506
apply(rule_tac x = "t" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   507
apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   508
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   509
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   510
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
   511
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   512
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   513
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
   514
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   515
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   516
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   517
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   518
(*This Theorem combines whithnesses about P minusinfinity to schow one component of the
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   519
equivalence proof for cooper's theorem*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   520
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   521
(* FIXME: remove once they are part of the distribution *)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   522
theorem int_ge_induct[consumes 1,case_names base step]:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   523
  assumes ge: "k \<le> (i::int)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   524
        base: "P(k)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   525
        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
   526
  shows "P i"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   527
proof -
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   528
  { 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
   529
    proof (induct n)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   530
      case 0
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   531
      hence "i = k" by arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   532
      thus "P i" using base by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   533
    next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   534
      case (Suc n)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   535
      hence "n = nat((i - 1) - k)" by arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   536
      moreover
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   537
      have ki1: "k \<le> i - 1" using Suc.prems by arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   538
      ultimately
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   539
      have "P(i - 1)" by(rule Suc.hyps)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   540
      from step[OF ki1 this] show ?case by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   541
    qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   542
  }
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   543
  from this ge show ?thesis by fast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   544
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   545
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   546
theorem int_gr_induct[consumes 1,case_names base step]:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   547
  assumes gr: "k < (i::int)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   548
        base: "P(k+1)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   549
        step: "\<And>i. \<lbrakk>k < i; P i\<rbrakk> \<Longrightarrow> P(i+1)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   550
  shows "P i"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   551
apply(rule int_ge_induct[of "k + 1"])
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   552
  using gr apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   553
 apply(rule base)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   554
apply(rule step)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   555
 apply simp+
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   556
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   557
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   558
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
   559
apply(induct rule: int_gr_induct)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   560
 apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   561
 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   562
apply (simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   563
apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   564
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   565
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   566
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
   567
apply(induct rule: int_gr_induct)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   568
 apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   569
 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   570
apply (simp add:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   571
apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   572
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   573
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   574
lemma  minusinfinity:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   575
  assumes "0 < d" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   576
    P1eqP1: "ALL x k. P1 x = P1(x - k*d)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   577
    ePeqP1: "EX z::int. ALL x. x < z \<longrightarrow> (P x = P1 x)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   578
  shows "(EX x. P1 x) \<longrightarrow> (EX x. P x)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   579
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   580
  assume eP1: "EX x. P1 x"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   581
  then obtain x where P1: "P1 x" ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   582
  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
   583
  let ?w = "x - (abs(x-z)+1) * d"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   584
  show "EX x. P x"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   585
  proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   586
    have w: "?w < z" by(rule decr_lemma)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   587
    have "P1 x = P1 ?w" using P1eqP1 by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   588
    also have "\<dots> = P(?w)" using w P1eqP by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   589
    finally show "P ?w" using P1 by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   590
  qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   591
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   592
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   593
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   594
(*This Theorem combines whithnesses about P minusinfinity to schow one component of the
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   595
equivalence proof for cooper's theorem*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   596
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   597
lemma plusinfinity:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   598
  assumes "0 < d" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   599
    P1eqP1: "ALL (x::int) (k::int). P1 x = P1 (x + k * d)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   600
    ePeqP1: "EX z::int. ALL x. z < x  --> (P x = P1 x)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   601
  shows "(EX x::int. P1 x) --> (EX x::int. P x)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   602
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   603
  assume eP1: "EX x. P1 x"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   604
  then obtain x where P1: "P1 x" ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   605
  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
   606
  let ?w = "x + (abs(x-z)+1) * d"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   607
  show "EX x. P x"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   608
  proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   609
    have w: "z < ?w" by(rule incr_lemma)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   610
    have "P1 x = P1 ?w" using P1eqP1 by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   611
    also have "\<dots> = P(?w)" using w P1eqP by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   612
    finally show "P ?w" using P1 by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   613
  qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   614
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   615
 
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   616
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   617
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   618
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   619
(*Theorem for periodic function on discrete sets*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   620
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   621
lemma minf_vee:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   622
  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
   623
  shows "(EX x. P x) = (EX j : {1..d}. P j)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   624
  (is "?LHS = ?RHS")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   625
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   626
  assume ?LHS
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   627
  then obtain x where P: "P x" ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   628
  have "x mod d = x - (x div d)*d"
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   629
    by(simp add:zmod_zdiv_equality mult_ac eq_diff_eq)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   630
  hence Pmod: "P x = P(x mod d)" using modd by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   631
  show ?RHS
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   632
  proof (cases)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   633
    assume "x mod d = 0"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   634
    hence "P 0" using P Pmod by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   635
    moreover have "P 0 = P(0 - (-1)*d)" using modd by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   636
    ultimately have "P d" by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   637
    moreover have "d : {1..d}" using dpos by(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   638
    ultimately show ?RHS ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   639
  next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   640
    assume not0: "x mod d \<noteq> 0"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   641
    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
   642
    moreover have "x mod d : {1..d}"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   643
    proof -
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   644
      have "0 \<le> x mod d" by(rule pos_mod_sign)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   645
      moreover have "x mod d < d" by(rule pos_mod_bound)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   646
      ultimately show ?thesis using not0 by(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   647
    qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   648
    ultimately show ?RHS ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   649
  qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   650
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   651
  assume ?RHS thus ?LHS by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   652
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   653
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   654
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   655
(*Theorem for periodic function on discrete sets*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   656
lemma pinf_vee:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   657
  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
   658
  shows "(EX x::int. P x) = (EX (j::int) : {1..d} . P j)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   659
  (is "?LHS = ?RHS")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   660
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   661
  assume ?LHS
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   662
  then obtain x where P: "P x" ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   663
  have "x mod d = x + (-(x div d))*d"
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   664
    by(simp add:zmod_zdiv_equality mult_ac eq_diff_eq)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   665
  hence Pmod: "P x = P(x mod d)" using modd by (simp only:)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   666
  show ?RHS
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   667
  proof (cases)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   668
    assume "x mod d = 0"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   669
    hence "P 0" using P Pmod by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   670
    moreover have "P 0 = P(0 + 1*d)" using modd by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   671
    ultimately have "P d" by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   672
    moreover have "d : {1..d}" using dpos by(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   673
    ultimately show ?RHS ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   674
  next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   675
    assume not0: "x mod d \<noteq> 0"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   676
    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
   677
    moreover have "x mod d : {1..d}"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   678
    proof -
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   679
      have "0 \<le> x mod d" by(rule pos_mod_sign)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   680
      moreover have "x mod d < d" by(rule pos_mod_bound)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   681
      ultimately show ?thesis using not0 by(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   682
    qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   683
    ultimately show ?RHS ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   684
  qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   685
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   686
  assume ?RHS thus ?LHS by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   687
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   688
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   689
lemma decr_mult_lemma:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   690
  assumes dpos: "(0::int) < d" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   691
          minus: "ALL x::int. P x \<longrightarrow> P(x - d)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   692
          knneg: "0 <= k"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   693
  shows "ALL x. P x \<longrightarrow> P(x - k*d)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   694
using knneg
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   695
proof (induct rule:int_ge_induct)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   696
  case base thus ?case by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   697
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   698
  case (step i)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   699
  show ?case
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   700
  proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   701
    fix x
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   702
    have "P x \<longrightarrow> P (x - i * d)" using step.hyps by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   703
    also have "\<dots> \<longrightarrow> P(x - (i + 1) * d)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   704
      using minus[THEN spec, of "x - i * d"]
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   705
      by (simp add:int_distrib Ring_and_Field.diff_diff_eq[symmetric])
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   706
    ultimately show "P x \<longrightarrow> P(x - (i + 1) * d)" by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   707
  qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   708
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   709
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   710
lemma incr_mult_lemma:
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   711
  assumes dpos: "(0::int) < d" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   712
          plus: "ALL x::int. P x \<longrightarrow> P(x + d)" and
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   713
          knneg: "0 <= k"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   714
  shows "ALL x. P x \<longrightarrow> P(x + k*d)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   715
using knneg
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   716
proof (induct rule:int_ge_induct)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   717
  case base thus ?case by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   718
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   719
  case (step i)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   720
  show ?case
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   721
  proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   722
    fix x
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   723
    have "P x \<longrightarrow> P (x + i * d)" using step.hyps by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   724
    also have "\<dots> \<longrightarrow> P(x + (i + 1) * d)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   725
      using plus[THEN spec, of "x + i * d"]
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   726
      by (simp add:int_distrib zadd_ac)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   727
    ultimately show "P x \<longrightarrow> P(x + (i + 1) * d)" by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   728
  qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   729
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   730
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   731
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
   732
==> 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
   733
==> (ALL (x::int). ALL (k::int). ((P1 x)= (P1 (x-k*D))))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   734
==> (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
   735
apply(rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   736
prefer 2
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   737
apply(drule minusinfinity)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   738
apply assumption+
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   739
apply(fastsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   740
apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   741
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
   742
apply(frule_tac x = x and z=z in decr_lemma)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   743
apply(subgoal_tac "P1(x - (\<bar>x - z\<bar> + 1) * D)")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   744
prefer 2
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   745
apply(subgoal_tac "0 <= (\<bar>x - z\<bar> + 1)")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   746
prefer 2 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   747
 apply fastsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   748
apply(drule (1) minf_vee)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   749
apply blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   750
apply(blast dest:decr_mult_lemma)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   751
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   752
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   753
(* Cooper Thm `, plus infinity version*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   754
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
   755
==> 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
   756
==> (ALL (x::int). ALL (k::int). ((P1 x)= (P1 (x+k*D))))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   757
==> (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
   758
  apply(rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   759
  prefer 2
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   760
  apply(drule plusinfinity)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   761
  apply assumption+
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   762
  apply(fastsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   763
  apply clarsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   764
  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
   765
  apply(frule_tac x = x and z=z in incr_lemma)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   766
  apply(subgoal_tac "P1(x + (\<bar>x - z\<bar> + 1) * D)")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   767
  prefer 2
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   768
  apply(subgoal_tac "0 <= (\<bar>x - z\<bar> + 1)")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   769
  prefer 2 apply arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   770
  apply fastsimp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   771
  apply(drule (1) pinf_vee)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   772
  apply blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   773
  apply(blast dest:incr_mult_lemma)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   774
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   775
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   776
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   777
(*=============================================================================*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   778
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   779
(*Theorems for the quantifier elminination Functions.*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   780
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   781
lemma qe_ex_conj: "(EX (x::int). A x) = R
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   782
		==> (EX (x::int). P x) = (Q & (EX x::int. A x))
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   783
		==> (EX (x::int). P x) = (Q & R)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   784
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   785
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   786
lemma qe_ex_nconj: "(EX (x::int). P x) = (True & Q)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   787
		==> (EX (x::int). P x) = Q"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   788
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   789
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   790
lemma qe_conjI: "P1 = P2 ==> Q1 = Q2 ==> (P1 & Q1) = (P2 & Q2)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   791
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   792
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   793
lemma qe_disjI: "P1 = P2 ==> Q1 = Q2 ==> (P1 | Q1) = (P2 | Q2)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   794
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   795
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   796
lemma qe_impI: "P1 = P2 ==> Q1 = Q2 ==> (P1 --> Q1) = (P2 --> Q2)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   797
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   798
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   799
lemma qe_eqI: "P1 = P2 ==> Q1 = Q2 ==> (P1 = Q1) = (P2 = Q2)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   800
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   801
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   802
lemma qe_Not: "P = Q ==> (~P) = (~Q)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   803
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   804
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   805
lemma qe_ALL: "(EX x. ~P x) = R ==> (ALL x. P x) = (~R)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   806
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   807
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   808
(* Theorems for proving NNF *)
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 nnf_im: "((~P) = P1) ==> (Q=Q1) ==> ((P --> Q) = (P1 | Q1))"
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 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
   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 nnf_nn: "(P = Q) ==> ((~~P) = Q)"
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
lemma nnf_ncj: "((~P) = P1) ==> ((~Q) = Q1) ==> ((~(P & Q)) = (P1 | Q1))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   819
by blast
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_ndj: "((~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
lemma nnf_nim: "(P = P1) ==> ((~Q) = Q1) ==> ((~(P --> Q)) = (P1 & Q1))"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   824
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   825
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
   826
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   827
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
   828
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   829
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   830
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   831
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
   832
  by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   833
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   834
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
   835
  by rules
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   836
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   837
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
   838
  by rules
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   839
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   840
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
   841
==>(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
   842
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   843
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   844
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
   845
==>(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
   846
by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   847
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   848
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   849
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
   850
apply(simp add:atLeastAtMost_def atLeast_def atMost_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   851
apply(fastsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   852
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   853
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   854
(* Theorems required for the adjustcoeffitienteq*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   855
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   856
lemma ac_dvd_eq: assumes not0: "0 ~= (k::int)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   857
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
   858
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   859
  assume ?P
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   860
  thus ?Q
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   861
    apply(simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   862
    apply clarify
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   863
    apply(rename_tac d)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   864
    apply(drule_tac f = "op * k" in arg_cong)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   865
    apply(simp only:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   866
    apply(rule_tac x = "d" in exI)
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   867
    apply(simp only:mult_ac)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   868
    done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   869
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   870
  assume ?Q
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   871
  then obtain d where "k * c * n + k * t = (k*m)*d" by(fastsimp simp:dvd_def)
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   872
  hence "(c * n + t) * k = (m*d) * k" by(simp add:int_distrib mult_ac)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   873
  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
   874
  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
   875
  thus ?P by(simp add:dvd_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   876
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   877
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   878
lemma ac_lt_eq: assumes gr0: "0 < (k::int)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   879
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
   880
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   881
  assume P: ?P
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   882
  show ?Q using zmult_zless_mono2[OF P gr0] by(simp add: int_distrib mult_ac)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   883
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   884
  assume ?Q
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   885
  hence "0 < k*(c*n + t - m)" by(simp add: int_distrib mult_ac)
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 14271
diff changeset
   886
  with gr0 have "0 < (c*n + t - m)" by(simp add: zero_less_mult_iff)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   887
  thus ?P by(simp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   888
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   889
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   890
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
   891
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   892
  assume ?P
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   893
  thus ?Q
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   894
    apply(drule_tac f = "op * k" in arg_cong)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   895
    apply(simp only:int_distrib)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   896
    done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   897
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   898
  assume ?Q
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   899
  hence "m * k = (c*n + t) * k" by(simp add:int_distrib mult_ac)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   900
  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
   901
  thus ?P by(simp add: zdiv_zmult_self1[OF not0[symmetric]])
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   902
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   903
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   904
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
   905
proof -
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   906
  have "(~ (0::int) < (c*n + t)) = (0<1-(c*n + t))" by arith
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   907
  also have  "(1-(c*n + t)) = (-1*c)*n + (-t+1)" by(simp add: int_distrib mult_ac)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   908
  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])
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   909
  also have "(k*(-1*c)*n) + (k*(-t+1)) = ((-k)*c)*n + ((-k)*t + k)" by(simp add: int_distrib mult_ac)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   910
  finally show ?thesis .
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   911
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   912
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   913
lemma binminus_uminus_conv: "(a::int) - b = a + (-b)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   914
by arith
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   915
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   916
lemma  linearize_dvd: "(t::int) = t1 ==> (d dvd t) = (d dvd t1)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   917
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   918
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   919
lemma lf_lt: "(l::int) = ll ==> (r::int) = lr ==> (l < r) =(ll < lr)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   920
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   921
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   922
lemma lf_eq: "(l::int) = ll ==> (r::int) = lr ==> (l = r) =(ll = lr)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   923
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   924
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   925
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
   926
by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   927
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   928
(* Theorems for transforming predicates on nat to predicates on int*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   929
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   930
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
   931
  by (simp split add: split_nat)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   932
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   933
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
   934
  apply (simp split add: split_nat)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   935
  apply (rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   936
  apply (erule exE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   937
  apply (rule_tac x = "int x" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   938
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   939
  apply (erule exE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   940
  apply (rule_tac x = "nat x" in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   941
  apply (erule conjE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   942
  apply (erule_tac x = "nat x" in allE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   943
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   944
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   945
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   946
theorem zdiff_int_split: "P (int (x - y)) =
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   947
  ((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
   948
  apply (case_tac "y \<le> x")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   949
  apply (simp_all add: zdiff_int)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   950
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   951
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   952
theorem zdvd_int: "(x dvd y) = (int x dvd int y)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   953
  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
   954
    nat_0_le cong add: conj_cong)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   955
  apply (rule iffI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   956
  apply rules
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   957
  apply (erule exE)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   958
  apply (case_tac "x=0")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   959
  apply (rule_tac x=0 in exI)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   960
  apply simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   961
  apply (case_tac "0 \<le> k")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   962
  apply rules
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   963
  apply (simp add: linorder_not_le)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   964
  apply (drule zmult_zless_mono2_neg [OF iffD2 [OF zero_less_int_conv]])
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   965
  apply assumption
14271
8ed6989228bb Simplification of the development of Integers
paulson
parents: 14139
diff changeset
   966
  apply (simp add: mult_ac)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   967
  done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   968
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   969
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
   970
  by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   971
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   972
theorem number_of2: "(0::int) <= number_of bin.Pls" by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   973
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   974
theorem Suc_plus1: "Suc n = n + 1" by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   975
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   976
(* specific instances of congruence rules, to prevent simplifier from looping *)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   977
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   978
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
   979
  by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   980
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   981
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
   982
  by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   983
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   984
use "cooper_dec.ML"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   985
use "cooper_proof.ML"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   986
use "qelim.ML"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   987
use "presburger.ML"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   988
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   989
setup "Presburger.setup"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   990
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   991
end