| author | wenzelm | 
| Mon, 04 Dec 2023 12:10:39 +0100 | |
| changeset 79120 | 45b2171e9e03 | 
| parent 75669 | 43f5dfb7fa35 | 
| child 80630 | 362d750f5788 | 
| permissions | -rw-r--r-- | 
| 23465 | 1 | (* Title: HOL/Presburger.thy | 
| 2 | Author: Amine Chaieb, TU Muenchen | |
| 3 | *) | |
| 4 | ||
| 60758 | 5 | section \<open>Decision Procedure for Presburger Arithmetic\<close> | 
| 23472 | 6 | |
| 23465 | 7 | theory Presburger | 
| 63962 
83a625d06e91
use argo as additional SAT solver with models but no proofs, since the proof trace formats are not easily translatable
 boehmes parents: 
63961diff
changeset | 8 | imports Groebner_Basis Set_Interval | 
| 58925 | 9 | keywords "try0" :: diag | 
| 23465 | 10 | begin | 
| 11 | ||
| 69605 | 12 | ML_file \<open>Tools/Qelim/qelim.ML\<close> | 
| 13 | ML_file \<open>Tools/Qelim/cooper_procedure.ML\<close> | |
| 48891 | 14 | |
| 61799 | 15 | subsection\<open>The \<open>-\<infinity>\<close> and \<open>+\<infinity>\<close> Properties\<close> | 
| 23465 | 16 | |
| 17 | lemma minf: | |
| 18 | "\<lbrakk>\<exists>(z ::'a::linorder).\<forall>x<z. P x = P' x; \<exists>z.\<forall>x<z. Q x = Q' x\<rbrakk> | |
| 19 | \<Longrightarrow> \<exists>z.\<forall>x<z. (P x \<and> Q x) = (P' x \<and> Q' x)" | |
| 20 | "\<lbrakk>\<exists>(z ::'a::linorder).\<forall>x<z. P x = P' x; \<exists>z.\<forall>x<z. Q x = Q' x\<rbrakk> | |
| 21 | \<Longrightarrow> \<exists>z.\<forall>x<z. (P x \<or> Q x) = (P' x \<or> Q' x)" | |
| 22 |   "\<exists>(z ::'a::{linorder}).\<forall>x<z.(x = t) = False"
 | |
| 23 |   "\<exists>(z ::'a::{linorder}).\<forall>x<z.(x \<noteq> t) = True"
 | |
| 24 |   "\<exists>(z ::'a::{linorder}).\<forall>x<z.(x < t) = True"
 | |
| 25 |   "\<exists>(z ::'a::{linorder}).\<forall>x<z.(x \<le> t) = True"
 | |
| 26 |   "\<exists>(z ::'a::{linorder}).\<forall>x<z.(x > t) = False"
 | |
| 27 |   "\<exists>(z ::'a::{linorder}).\<forall>x<z.(x \<ge> t) = False"
 | |
| 45425 | 28 |   "\<exists>z.\<forall>(x::'b::{linorder,plus,Rings.dvd})<z. (d dvd x + s) = (d dvd x + s)"
 | 
| 29 |   "\<exists>z.\<forall>(x::'b::{linorder,plus,Rings.dvd})<z. (\<not> d dvd x + s) = (\<not> d dvd x + s)"
 | |
| 23465 | 30 | "\<exists>z.\<forall>x<z. F = F" | 
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 31 | proof safe | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 32 | fix z1 z2 | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 33 | assume "\<forall>x<z1. P x = P' x" and "\<forall>x<z2. Q x = Q' x" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 34 | then have "\<forall>x < min z1 z2. (P x \<and> Q x) = (P' x \<and> Q' x)" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 35 | by simp | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 36 | then show "\<exists>z. \<forall>x<z. (P x \<and> Q x) = (P' x \<and> Q' x)" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 37 | by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 38 | next | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 39 | fix z1 z2 | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 40 | assume "\<forall>x<z1. P x = P' x" and "\<forall>x<z2. Q x = Q' x" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 41 | then have "\<forall>x < min z1 z2. (P x \<or> Q x) = (P' x \<or> Q' x)" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 42 | by simp | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 43 | then show "\<exists>z. \<forall>x<z. (P x \<or> Q x) = (P' x \<or> Q' x)" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 44 | by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 45 | next | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 46 | have "\<forall>x<t. x \<le> t" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 47 | by fastforce | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 48 | then show "\<exists>z. \<forall>x<z. (x \<le> t) = True" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 49 | by auto | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 50 | next | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 51 | have "\<forall>x<t. \<not> t < x" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 52 | by fastforce | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 53 | then show "\<exists>z. \<forall>x<z. (t < x) = False" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 54 | by auto | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 55 | next | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 56 | have "\<forall>x<t. \<not> t \<le> x" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 57 | by fastforce | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 58 | then show "\<exists>z. \<forall>x<z. (t \<le> x) = False" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 59 | by auto | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 60 | qed auto | 
| 23465 | 61 | |
| 62 | lemma pinf: | |
| 63 | "\<lbrakk>\<exists>(z ::'a::linorder).\<forall>x>z. P x = P' x; \<exists>z.\<forall>x>z. Q x = Q' x\<rbrakk> | |
| 64 | \<Longrightarrow> \<exists>z.\<forall>x>z. (P x \<and> Q x) = (P' x \<and> Q' x)" | |
| 65 | "\<lbrakk>\<exists>(z ::'a::linorder).\<forall>x>z. P x = P' x; \<exists>z.\<forall>x>z. Q x = Q' x\<rbrakk> | |
| 66 | \<Longrightarrow> \<exists>z.\<forall>x>z. (P x \<or> Q x) = (P' x \<or> Q' x)" | |
| 67 |   "\<exists>(z ::'a::{linorder}).\<forall>x>z.(x = t) = False"
 | |
| 68 |   "\<exists>(z ::'a::{linorder}).\<forall>x>z.(x \<noteq> t) = True"
 | |
| 69 |   "\<exists>(z ::'a::{linorder}).\<forall>x>z.(x < t) = False"
 | |
| 70 |   "\<exists>(z ::'a::{linorder}).\<forall>x>z.(x \<le> t) = False"
 | |
| 71 |   "\<exists>(z ::'a::{linorder}).\<forall>x>z.(x > t) = True"
 | |
| 72 |   "\<exists>(z ::'a::{linorder}).\<forall>x>z.(x \<ge> t) = True"
 | |
| 45425 | 73 |   "\<exists>z.\<forall>(x::'b::{linorder,plus,Rings.dvd})>z. (d dvd x + s) = (d dvd x + s)"
 | 
| 74 |   "\<exists>z.\<forall>(x::'b::{linorder,plus,Rings.dvd})>z. (\<not> d dvd x + s) = (\<not> d dvd x + s)"
 | |
| 23465 | 75 | "\<exists>z.\<forall>x>z. F = F" | 
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 76 | proof safe | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 77 | fix z1 z2 | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 78 | assume "\<forall>x>z1. P x = P' x" and "\<forall>x>z2. Q x = Q' x" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 79 | then have "\<forall>x > max z1 z2. (P x \<and> Q x) = (P' x \<and> Q' x)" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 80 | by simp | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 81 | then show "\<exists>z. \<forall>x>z. (P x \<and> Q x) = (P' x \<and> Q' x)" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 82 | by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 83 | next | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 84 | fix z1 z2 | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 85 | assume "\<forall>x>z1. P x = P' x" and "\<forall>x>z2. Q x = Q' x" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 86 | then have "\<forall>x > max z1 z2. (P x \<or> Q x) = (P' x \<or> Q' x)" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 87 | by simp | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 88 | then show "\<exists>z. \<forall>x>z. (P x \<or> Q x) = (P' x \<or> Q' x)" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 89 | by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 90 | next | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 91 | have "\<forall>x>t. \<not> x < t" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 92 | by fastforce | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 93 | then show "\<exists>z. \<forall>x>z. x < t = False" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 94 | by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 95 | next | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 96 | have "\<forall>x>t. \<not> x \<le> t" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 97 | by fastforce | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 98 | then show "\<exists>z. \<forall>x>z. x \<le> t = False" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 99 | by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 100 | next | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 101 | have "\<forall>x>t. t \<le> x" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 102 | by fastforce | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 103 | then show "\<exists>z. \<forall>x>z. t \<le> x = True" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 104 | by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 105 | qed auto | 
| 23465 | 106 | |
| 107 | lemma inf_period: | |
| 108 | "\<lbrakk>\<forall>x k. P x = P (x - k*D); \<forall>x k. Q x = Q (x - k*D)\<rbrakk> | |
| 109 | \<Longrightarrow> \<forall>x k. (P x \<and> Q x) = (P (x - k*D) \<and> Q (x - k*D))" | |
| 110 | "\<lbrakk>\<forall>x k. P x = P (x - k*D); \<forall>x k. Q x = Q (x - k*D)\<rbrakk> | |
| 111 | \<Longrightarrow> \<forall>x k. (P x \<or> Q x) = (P (x - k*D) \<or> Q (x - k*D))" | |
| 35050 
9f841f20dca6
renamed OrderedGroup to Groups; split theory Ring_and_Field into Rings Fields
 haftmann parents: 
33318diff
changeset | 112 |   "(d::'a::{comm_ring,Rings.dvd}) dvd D \<Longrightarrow> \<forall>x k. (d dvd x + t) = (d dvd (x - k*D) + t)"
 | 
| 
9f841f20dca6
renamed OrderedGroup to Groups; split theory Ring_and_Field into Rings Fields
 haftmann parents: 
33318diff
changeset | 113 |   "(d::'a::{comm_ring,Rings.dvd}) dvd D \<Longrightarrow> \<forall>x k. (\<not>d dvd x + t) = (\<not>d dvd (x - k*D) + t)"
 | 
| 23465 | 114 | "\<forall>x k. F = F" | 
| 29667 | 115 | apply (auto elim!: dvdE simp add: algebra_simps) | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
56850diff
changeset | 116 | unfolding mult.assoc [symmetric] distrib_right [symmetric] left_diff_distrib [symmetric] | 
| 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
56850diff
changeset | 117 | unfolding dvd_def mult.commute [of d] | 
| 27668 | 118 | by auto | 
| 23465 | 119 | |
| 60758 | 120 | subsection\<open>The A and B sets\<close> | 
| 23465 | 121 | lemma bset: | 
| 122 |   "\<lbrakk>\<forall>x.(\<forall>j \<in> {1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> P x \<longrightarrow> P(x - D) ;
 | |
| 123 |      \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> Q x \<longrightarrow> Q(x - D)\<rbrakk> \<Longrightarrow> 
 | |
| 124 |   \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j) \<longrightarrow> (P x \<and> Q x) \<longrightarrow> (P(x - D) \<and> Q (x - D))"
 | |
| 125 |   "\<lbrakk>\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> P x \<longrightarrow> P(x - D) ;
 | |
| 126 |      \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> Q x \<longrightarrow> Q(x - D)\<rbrakk> \<Longrightarrow> 
 | |
| 127 |   \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (P x \<or> Q x) \<longrightarrow> (P(x - D) \<or> Q (x - D))"
 | |
| 128 |   "\<lbrakk>D>0; t - 1\<in> B\<rbrakk> \<Longrightarrow> (\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x = t) \<longrightarrow> (x - D = t))"
 | |
| 129 |   "\<lbrakk>D>0 ; t \<in> B\<rbrakk> \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x \<noteq> t) \<longrightarrow> (x - D \<noteq> t))"
 | |
| 130 |   "D>0 \<Longrightarrow> (\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x < t) \<longrightarrow> (x - D < t))"
 | |
| 131 |   "D>0 \<Longrightarrow> (\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x \<le> t) \<longrightarrow> (x - D \<le> t))"
 | |
| 132 |   "\<lbrakk>D>0 ; t \<in> B\<rbrakk> \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x > t) \<longrightarrow> (x - D > t))"
 | |
| 133 |   "\<lbrakk>D>0 ; t - 1 \<in> B\<rbrakk> \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x \<ge> t) \<longrightarrow> (x - D \<ge> t))"
 | |
| 134 |   "d dvd D \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (d dvd x+t) \<longrightarrow> (d dvd (x - D) + t))"
 | |
| 135 |   "d dvd D \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (\<not>d dvd x+t) \<longrightarrow> (\<not> d dvd (x - D) + t))"
 | |
| 136 |   "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j) \<longrightarrow> F \<longrightarrow> F"
 | |
| 137 | proof (blast, blast) | |
| 138 | assume dp: "D > 0" and tB: "t - 1\<in> B" | |
| 139 |   show "(\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x = t) \<longrightarrow> (x - D = t))" 
 | |
| 27668 | 140 | apply (rule allI, rule impI,erule ballE[where x="1"],erule ballE[where x="t - 1"]) | 
| 141 | apply algebra using dp tB by simp_all | |
| 23465 | 142 | next | 
| 143 | assume dp: "D > 0" and tB: "t \<in> B" | |
| 144 |   show "(\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x \<noteq> t) \<longrightarrow> (x - D \<noteq> t))" 
 | |
| 145 | apply (rule allI, rule impI,erule ballE[where x="D"],erule ballE[where x="t"]) | |
| 27668 | 146 | apply algebra | 
| 23465 | 147 | using dp tB by simp_all | 
| 148 | next | |
| 149 |   assume dp: "D > 0" thus "(\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x < t) \<longrightarrow> (x - D < t))" by arith
 | |
| 150 | next | |
| 151 |   assume dp: "D > 0" thus "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x \<le> t) \<longrightarrow> (x - D \<le> t)" by arith
 | |
| 152 | next | |
| 153 | assume dp: "D > 0" and tB:"t \<in> B" | |
| 154 |   {fix x assume nob: "\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j" and g: "x > t" and ng: "\<not> (x - D) > t"
 | |
| 155 | hence "x -t \<le> D" and "1 \<le> x - t" by simp+ | |
| 156 |       hence "\<exists>j \<in> {1 .. D}. x - t = j" by auto
 | |
| 29667 | 157 |       hence "\<exists>j \<in> {1 .. D}. x = t + j" by (simp add: algebra_simps)
 | 
| 23465 | 158 | with nob tB have "False" by simp} | 
| 159 |   thus "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x > t) \<longrightarrow> (x - D > t)" by blast
 | |
| 160 | next | |
| 161 | assume dp: "D > 0" and tB:"t - 1\<in> B" | |
| 162 |   {fix x assume nob: "\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j" and g: "x \<ge> t" and ng: "\<not> (x - D) \<ge> t"
 | |
| 163 | hence "x - (t - 1) \<le> D" and "1 \<le> x - (t - 1)" by simp+ | |
| 164 |       hence "\<exists>j \<in> {1 .. D}. x - (t - 1) = j" by auto
 | |
| 29667 | 165 |       hence "\<exists>j \<in> {1 .. D}. x = (t - 1) + j" by (simp add: algebra_simps)
 | 
| 23465 | 166 | with nob tB have "False" by simp} | 
| 167 |   thus "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x \<ge> t) \<longrightarrow> (x - D \<ge> t)" by blast
 | |
| 168 | next | |
| 169 | assume d: "d dvd D" | |
| 27668 | 170 |   {fix x assume H: "d dvd x + t" with d have "d dvd (x - D) + t" by algebra}
 | 
| 23465 | 171 |   thus "\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (d dvd x+t) \<longrightarrow> (d dvd (x - D) + t)" by simp
 | 
| 172 | next | |
| 173 | assume d: "d dvd D" | |
| 27651 
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
 haftmann parents: 
27540diff
changeset | 174 |   {fix x assume H: "\<not>(d dvd x + t)" with d have "\<not> d dvd (x - D) + t"
 | 
| 29667 | 175 | by (clarsimp simp add: dvd_def,erule_tac x= "ka + k" in allE,simp add: algebra_simps)} | 
| 23465 | 176 |   thus "\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (\<not>d dvd x+t) \<longrightarrow> (\<not>d dvd (x - D) + t)" by auto
 | 
| 177 | qed blast | |
| 178 | ||
| 179 | lemma aset: | |
| 180 |   "\<lbrakk>\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> P x \<longrightarrow> P(x + D) ;
 | |
| 181 |      \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> Q x \<longrightarrow> Q(x + D)\<rbrakk> \<Longrightarrow> 
 | |
| 182 |   \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j) \<longrightarrow> (P x \<and> Q x) \<longrightarrow> (P(x + D) \<and> Q (x + D))"
 | |
| 183 |   "\<lbrakk>\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> P x \<longrightarrow> P(x + D) ;
 | |
| 184 |      \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> Q x \<longrightarrow> Q(x + D)\<rbrakk> \<Longrightarrow> 
 | |
| 185 |   \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (P x \<or> Q x) \<longrightarrow> (P(x + D) \<or> Q (x + D))"
 | |
| 186 |   "\<lbrakk>D>0; t + 1\<in> A\<rbrakk> \<Longrightarrow> (\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x = t) \<longrightarrow> (x + D = t))"
 | |
| 187 |   "\<lbrakk>D>0 ; t \<in> A\<rbrakk> \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x \<noteq> t) \<longrightarrow> (x + D \<noteq> t))"
 | |
| 188 |   "\<lbrakk>D>0; t\<in> A\<rbrakk> \<Longrightarrow>(\<forall>(x::int). (\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x < t) \<longrightarrow> (x + D < t))"
 | |
| 189 |   "\<lbrakk>D>0; t + 1 \<in> A\<rbrakk> \<Longrightarrow> (\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x \<le> t) \<longrightarrow> (x + D \<le> t))"
 | |
| 190 |   "D>0 \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x > t) \<longrightarrow> (x + D > t))"
 | |
| 191 |   "D>0 \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x \<ge> t) \<longrightarrow> (x + D \<ge> t))"
 | |
| 192 |   "d dvd D \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (d dvd x+t) \<longrightarrow> (d dvd (x + D) + t))"
 | |
| 193 |   "d dvd D \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (\<not>d dvd x+t) \<longrightarrow> (\<not> d dvd (x + D) + t))"
 | |
| 194 |   "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j) \<longrightarrow> F \<longrightarrow> F"
 | |
| 195 | proof (blast, blast) | |
| 196 | assume dp: "D > 0" and tA: "t + 1 \<in> A" | |
| 197 |   show "(\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x = t) \<longrightarrow> (x + D = t))" 
 | |
| 198 | apply (rule allI, rule impI,erule ballE[where x="1"],erule ballE[where x="t + 1"]) | |
| 199 | using dp tA by simp_all | |
| 200 | next | |
| 201 | assume dp: "D > 0" and tA: "t \<in> A" | |
| 202 |   show "(\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x \<noteq> t) \<longrightarrow> (x + D \<noteq> t))" 
 | |
| 203 | apply (rule allI, rule impI,erule ballE[where x="D"],erule ballE[where x="t"]) | |
| 204 | using dp tA by simp_all | |
| 205 | next | |
| 206 |   assume dp: "D > 0" thus "(\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x > t) \<longrightarrow> (x + D > t))" by arith
 | |
| 207 | next | |
| 208 |   assume dp: "D > 0" thus "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x \<ge> t) \<longrightarrow> (x + D \<ge> t)" by arith
 | |
| 209 | next | |
| 210 | assume dp: "D > 0" and tA:"t \<in> A" | |
| 211 |   {fix x assume nob: "\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j" and g: "x < t" and ng: "\<not> (x + D) < t"
 | |
| 212 | hence "t - x \<le> D" and "1 \<le> t - x" by simp+ | |
| 213 |       hence "\<exists>j \<in> {1 .. D}. t - x = j" by auto
 | |
| 29667 | 214 |       hence "\<exists>j \<in> {1 .. D}. x = t - j" by (auto simp add: algebra_simps) 
 | 
| 23465 | 215 | with nob tA have "False" by simp} | 
| 216 |   thus "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x < t) \<longrightarrow> (x + D < t)" by blast
 | |
| 217 | next | |
| 218 | assume dp: "D > 0" and tA:"t + 1\<in> A" | |
| 219 |   {fix x assume nob: "\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j" and g: "x \<le> t" and ng: "\<not> (x + D) \<le> t"
 | |
| 29667 | 220 | hence "(t + 1) - x \<le> D" and "1 \<le> (t + 1) - x" by (simp_all add: algebra_simps) | 
| 23465 | 221 |       hence "\<exists>j \<in> {1 .. D}. (t + 1) - x = j" by auto
 | 
| 29667 | 222 |       hence "\<exists>j \<in> {1 .. D}. x = (t + 1) - j" by (auto simp add: algebra_simps)
 | 
| 23465 | 223 | with nob tA have "False" by simp} | 
| 224 |   thus "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x \<le> t) \<longrightarrow> (x + D \<le> t)" by blast
 | |
| 225 | next | |
| 226 | assume d: "d dvd D" | |
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 227 | have "\<And>x. d dvd x + t \<Longrightarrow> d dvd x + D + t" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 228 | proof - | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 229 | fix x | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 230 | assume H: "d dvd x + t" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 231 | then obtain ka where "x + t = d * ka" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 232 | unfolding dvd_def by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 233 | moreover from d obtain k where *:"D = d * k" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 234 | unfolding dvd_def by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 235 | ultimately have "x + d * k + t = d * (ka + k)" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 236 | by (simp add: algebra_simps) | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 237 | then show "d dvd (x + D) + t" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 238 | using * unfolding dvd_def by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 239 | qed | 
| 23465 | 240 |   thus "\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (d dvd x+t) \<longrightarrow> (d dvd (x + D) + t)" by simp
 | 
| 241 | next | |
| 242 | assume d: "d dvd D" | |
| 243 |   {fix x assume H: "\<not>(d dvd x + t)" with d have "\<not>d dvd (x + D) + t"
 | |
| 29667 | 244 | by (clarsimp simp add: dvd_def,erule_tac x= "ka - k" in allE,simp add: algebra_simps)} | 
| 23465 | 245 |   thus "\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (\<not>d dvd x+t) \<longrightarrow> (\<not>d dvd (x + D) + t)" by auto
 | 
| 246 | qed blast | |
| 247 | ||
| 61799 | 248 | subsection\<open>Cooper's Theorem \<open>-\<infinity>\<close> and \<open>+\<infinity>\<close> Version\<close> | 
| 23465 | 249 | |
| 60758 | 250 | subsubsection\<open>First some trivial facts about periodic sets or predicates\<close> | 
| 23465 | 251 | lemma periodic_finite_ex: | 
| 67091 | 252 | assumes dpos: "(0::int) < d" and modd: "\<forall>x k. P x = P(x - k*d)" | 
| 253 |   shows "(\<exists>x. P x) = (\<exists>j \<in> {1..d}. P j)"
 | |
| 23465 | 254 | (is "?LHS = ?RHS") | 
| 255 | proof | |
| 256 | assume ?LHS | |
| 257 | then obtain x where P: "P x" .. | |
| 64246 | 258 | have "x mod d = x - (x div d)*d" by(simp add:mult_div_mod_eq [symmetric] ac_simps eq_diff_eq) | 
| 23465 | 259 | hence Pmod: "P x = P(x mod d)" using modd by simp | 
| 260 | show ?RHS | |
| 261 | proof (cases) | |
| 262 | assume "x mod d = 0" | |
| 263 | hence "P 0" using P Pmod by simp | |
| 264 | moreover have "P 0 = P(0 - (-1)*d)" using modd by blast | |
| 265 | ultimately have "P d" by simp | |
| 67613 | 266 |     moreover have "d \<in> {1..d}" using dpos by simp
 | 
| 23465 | 267 | ultimately show ?RHS .. | 
| 268 | next | |
| 269 | assume not0: "x mod d \<noteq> 0" | |
| 35216 | 270 | have "P(x mod d)" using dpos P Pmod by simp | 
| 67613 | 271 |     moreover have "x mod d \<in> {1..d}"
 | 
| 23465 | 272 | proof - | 
| 273 | from dpos have "0 \<le> x mod d" by(rule pos_mod_sign) | |
| 274 | moreover from dpos have "x mod d < d" by(rule pos_mod_bound) | |
| 35216 | 275 | ultimately show ?thesis using not0 by simp | 
| 23465 | 276 | qed | 
| 277 | ultimately show ?RHS .. | |
| 278 | qed | |
| 279 | qed auto | |
| 280 | ||
| 61799 | 281 | subsubsection\<open>The \<open>-\<infinity>\<close> Version\<close> | 
| 23465 | 282 | |
| 61944 | 283 | lemma decr_lemma: "0 < (d::int) \<Longrightarrow> x - (\<bar>x - z\<bar> + 1) * d < z" | 
| 284 | by (induct rule: int_gr_induct) (simp_all add: int_distrib) | |
| 23465 | 285 | |
| 61944 | 286 | lemma incr_lemma: "0 < (d::int) \<Longrightarrow> z < x + (\<bar>x - z\<bar> + 1) * d" | 
| 287 | by (induct rule: int_gr_induct) (simp_all add: int_distrib) | |
| 23465 | 288 | |
| 289 | lemma decr_mult_lemma: | |
| 290 | assumes dpos: "(0::int) < d" and minus: "\<forall>x. P x \<longrightarrow> P(x - d)" and knneg: "0 <= k" | |
| 67091 | 291 | shows "\<forall>x. P x \<longrightarrow> P(x - k*d)" | 
| 23465 | 292 | using knneg | 
| 293 | proof (induct rule:int_ge_induct) | |
| 294 | case base thus ?case by simp | |
| 295 | next | |
| 296 | case (step i) | |
| 297 |   {fix x
 | |
| 298 | have "P x \<longrightarrow> P (x - i * d)" using step.hyps by blast | |
| 299 | also have "\<dots> \<longrightarrow> P(x - (i + 1) * d)" using minus[THEN spec, of "x - i * d"] | |
| 35050 
9f841f20dca6
renamed OrderedGroup to Groups; split theory Ring_and_Field into Rings Fields
 haftmann parents: 
33318diff
changeset | 300 | by (simp add: algebra_simps) | 
| 23465 | 301 | ultimately have "P x \<longrightarrow> P(x - (i + 1) * d)" by blast} | 
| 302 | thus ?case .. | |
| 303 | qed | |
| 304 | ||
| 305 | lemma minusinfinity: | |
| 306 | assumes dpos: "0 < d" and | |
| 67091 | 307 | P1eqP1: "\<forall>x k. P1 x = P1(x - k*d)" and ePeqP1: "\<exists>z::int. \<forall>x. x < z \<longrightarrow> (P x = P1 x)" | 
| 308 | shows "(\<exists>x. P1 x) \<longrightarrow> (\<exists>x. P x)" | |
| 23465 | 309 | proof | 
| 67091 | 310 | assume eP1: "\<exists>x. P1 x" | 
| 23465 | 311 | then obtain x where P1: "P1 x" .. | 
| 67091 | 312 | from ePeqP1 obtain z where P1eqP: "\<forall>x. x < z \<longrightarrow> (P x = P1 x)" .. | 
| 61944 | 313 | let ?w = "x - (\<bar>x - z\<bar> + 1) * d" | 
| 23465 | 314 | from dpos have w: "?w < z" by(rule decr_lemma) | 
| 315 | have "P1 x = P1 ?w" using P1eqP1 by blast | |
| 316 | also have "\<dots> = P(?w)" using w P1eqP by blast | |
| 317 | finally have "P ?w" using P1 by blast | |
| 67091 | 318 | thus "\<exists>x. P x" .. | 
| 23465 | 319 | qed | 
| 320 | ||
| 321 | lemma cpmi: | |
| 322 | assumes dp: "0 < D" and p1:"\<exists>z. \<forall> x< z. P x = P' x" | |
| 67091 | 323 |   and nb:"\<forall>x.(\<forall> j\<in> {1..D}. \<forall>(b::int) \<in> B. x \<noteq> b+j) \<longrightarrow> P (x) \<longrightarrow> P (x - D)"
 | 
| 23465 | 324 | and pd: "\<forall> x k. P' x = P' (x-k*D)" | 
| 67091 | 325 |   shows "(\<exists>x. P x) = ((\<exists>j \<in> {1..D} . P' j) \<or> (\<exists>j \<in> {1..D}. \<exists> b \<in> B. P (b+j)))"
 | 
| 23465 | 326 | (is "?L = (?R1 \<or> ?R2)") | 
| 327 | proof- | |
| 328 |  {assume "?R2" hence "?L"  by blast}
 | |
| 329 | moreover | |
| 330 |  {assume H:"?R1" hence "?L" using minusinfinity[OF dp pd p1] periodic_finite_ex[OF dp pd] by simp}
 | |
| 331 | moreover | |
| 332 |  { fix x
 | |
| 333 | assume P: "P x" and H: "\<not> ?R2" | |
| 334 |    {fix y assume "\<not> (\<exists>j\<in>{1..D}. \<exists>b\<in>B. P (b + j))" and P: "P y"
 | |
| 67091 | 335 |      hence "\<not>(\<exists>(j::int) \<in> {1..D}. \<exists>(b::int) \<in> B. y = b+j)" by auto
 | 
| 23465 | 336 | with nb P have "P (y - D)" by auto } | 
| 67091 | 337 |    hence "\<forall>x. \<not>(\<exists>(j::int) \<in> {1..D}. \<exists>(b::int) \<in> B. P(b+j)) \<longrightarrow> P (x) \<longrightarrow> P (x - D)" by blast
 | 
| 23465 | 338 | with H P have th: " \<forall>x. P x \<longrightarrow> P (x - D)" by auto | 
| 67091 | 339 | from p1 obtain z where z: "\<forall>x. x < z \<longrightarrow> (P x = P' x)" by blast | 
| 23465 | 340 | let ?y = "x - (\<bar>x - z\<bar> + 1)*D" | 
| 341 | have zp: "0 <= (\<bar>x - z\<bar> + 1)" by arith | |
| 342 | from dp have yz: "?y < z" using decr_lemma[OF dp] by simp | |
| 343 | from z[rule_format, OF yz] decr_mult_lemma[OF dp th zp, rule_format, OF P] have th2: " P' ?y" by auto | |
| 344 | with periodic_finite_ex[OF dp pd] | |
| 345 | have "?R1" by blast} | |
| 346 | ultimately show ?thesis by blast | |
| 347 | qed | |
| 348 | ||
| 61799 | 349 | subsubsection \<open>The \<open>+\<infinity>\<close> Version\<close> | 
| 23465 | 350 | |
| 351 | lemma plusinfinity: | |
| 352 | assumes dpos: "(0::int) < d" and | |
| 353 | P1eqP1: "\<forall>x k. P' x = P'(x - k*d)" and ePeqP1: "\<exists> z. \<forall> x>z. P x = P' x" | |
| 354 | shows "(\<exists> x. P' x) \<longrightarrow> (\<exists> x. P x)" | |
| 355 | proof | |
| 67091 | 356 | assume eP1: "\<exists>x. P' x" | 
| 23465 | 357 | then obtain x where P1: "P' x" .. | 
| 358 | from ePeqP1 obtain z where P1eqP: "\<forall>x>z. P x = P' x" .. | |
| 61944 | 359 | let ?w' = "x + (\<bar>x - z\<bar> + 1) * d" | 
| 360 | let ?w = "x - (- (\<bar>x - z\<bar> + 1)) * d" | |
| 29667 | 361 | have ww'[simp]: "?w = ?w'" by (simp add: algebra_simps) | 
| 23465 | 362 | from dpos have w: "?w > z" by(simp only: ww' incr_lemma) | 
| 363 | hence "P' x = P' ?w" using P1eqP1 by blast | |
| 364 | also have "\<dots> = P(?w)" using w P1eqP by blast | |
| 365 | finally have "P ?w" using P1 by blast | |
| 67091 | 366 | thus "\<exists>x. P x" .. | 
| 23465 | 367 | qed | 
| 368 | ||
| 369 | lemma incr_mult_lemma: | |
| 67091 | 370 | assumes dpos: "(0::int) < d" and plus: "\<forall>x::int. P x \<longrightarrow> P(x + d)" and knneg: "0 <= k" | 
| 371 | shows "\<forall>x. P x \<longrightarrow> P(x + k*d)" | |
| 23465 | 372 | using knneg | 
| 373 | proof (induct rule:int_ge_induct) | |
| 374 | case base thus ?case by simp | |
| 375 | next | |
| 376 | case (step i) | |
| 377 |   {fix x
 | |
| 378 | have "P x \<longrightarrow> P (x + i * d)" using step.hyps by blast | |
| 379 | also have "\<dots> \<longrightarrow> P(x + (i + 1) * d)" using plus[THEN spec, of "x + i * d"] | |
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 380 | by (simp add:int_distrib ac_simps) | 
| 23465 | 381 | ultimately have "P x \<longrightarrow> P(x + (i + 1) * d)" by blast} | 
| 382 | thus ?case .. | |
| 383 | qed | |
| 384 | ||
| 385 | lemma cppi: | |
| 386 | assumes dp: "0 < D" and p1:"\<exists>z. \<forall> x> z. P x = P' x" | |
| 67091 | 387 |   and nb:"\<forall>x.(\<forall> j\<in> {1..D}. \<forall>(b::int) \<in> A. x \<noteq> b - j) \<longrightarrow> P (x) \<longrightarrow> P (x + D)"
 | 
| 23465 | 388 | and pd: "\<forall> x k. P' x= P' (x-k*D)" | 
| 67091 | 389 |   shows "(\<exists>x. P x) = ((\<exists>j \<in> {1..D} . P' j) \<or> (\<exists> j \<in> {1..D}. \<exists> b\<in> A. P (b - j)))" (is "?L = (?R1 \<or> ?R2)")
 | 
| 23465 | 390 | proof- | 
| 391 |  {assume "?R2" hence "?L"  by blast}
 | |
| 392 | moreover | |
| 393 |  {assume H:"?R1" hence "?L" using plusinfinity[OF dp pd p1] periodic_finite_ex[OF dp pd] by simp}
 | |
| 394 | moreover | |
| 395 |  { fix x
 | |
| 396 | assume P: "P x" and H: "\<not> ?R2" | |
| 397 |    {fix y assume "\<not> (\<exists>j\<in>{1..D}. \<exists>b\<in>A. P (b - j))" and P: "P y"
 | |
| 67091 | 398 |      hence "\<not>(\<exists>(j::int) \<in> {1..D}. \<exists>(b::int) \<in> A. y = b - j)" by auto
 | 
| 23465 | 399 | with nb P have "P (y + D)" by auto } | 
| 67091 | 400 |    hence "\<forall>x. \<not>(\<exists>(j::int) \<in> {1..D}. \<exists>(b::int) \<in> A. P(b-j)) \<longrightarrow> P (x) \<longrightarrow> P (x + D)" by blast
 | 
| 23465 | 401 | with H P have th: " \<forall>x. P x \<longrightarrow> P (x + D)" by auto | 
| 67091 | 402 | from p1 obtain z where z: "\<forall>x. x > z \<longrightarrow> (P x = P' x)" by blast | 
| 23465 | 403 | let ?y = "x + (\<bar>x - z\<bar> + 1)*D" | 
| 404 | have zp: "0 <= (\<bar>x - z\<bar> + 1)" by arith | |
| 405 | from dp have yz: "?y > z" using incr_lemma[OF dp] by simp | |
| 406 | from z[rule_format, OF yz] incr_mult_lemma[OF dp th zp, rule_format, OF P] have th2: " P' ?y" by auto | |
| 407 | with periodic_finite_ex[OF dp pd] | |
| 408 | have "?R1" by blast} | |
| 409 | ultimately show ?thesis by blast | |
| 410 | qed | |
| 411 | ||
| 412 | lemma simp_from_to: "{i..j::int} = (if j < i then {} else insert i {i+1..j})"
 | |
| 413 | apply(simp add:atLeastAtMost_def atLeast_def atMost_def) | |
| 44890 
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
 nipkow parents: 
44766diff
changeset | 414 | apply(fastforce) | 
| 23465 | 415 | done | 
| 416 | ||
| 35050 
9f841f20dca6
renamed OrderedGroup to Groups; split theory Ring_and_Field into Rings Fields
 haftmann parents: 
33318diff
changeset | 417 | theorem unity_coeff_ex: "(\<exists>(x::'a::{semiring_0,Rings.dvd}). P (l * x)) \<equiv> (\<exists>x. l dvd (x + 0) \<and> P x)"
 | 
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70341diff
changeset | 418 | unfolding dvd_def by (rule eq_reflection, rule iffI) auto | 
| 23465 | 419 | |
| 54227 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 420 | lemma zdvd_mono: | 
| 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 421 | fixes k m t :: int | 
| 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 422 | assumes "k \<noteq> 0" | 
| 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 423 | shows "m dvd t \<equiv> k * m dvd k * t" | 
| 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 424 | using assms by simp | 
| 23465 | 425 | |
| 54227 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 426 | lemma uminus_dvd_conv: | 
| 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 427 | fixes d t :: int | 
| 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 428 | shows "d dvd t \<equiv> - d dvd t" and "d dvd t \<equiv> d dvd - t" | 
| 23465 | 429 | by simp_all | 
| 32553 | 430 | |
| 61799 | 431 | text \<open>\bigskip Theorems for transforming predicates on nat to predicates on \<open>int\<close>\<close> | 
| 32553 | 432 | |
| 23465 | 433 | lemma zdiff_int_split: "P (int (x - y)) = | 
| 434 | ((y \<le> x \<longrightarrow> P (int x - int y)) \<and> (x < y \<longrightarrow> P 0))" | |
| 62348 | 435 | by (cases "y \<le> x") (simp_all add: of_nat_diff) | 
| 23465 | 436 | |
| 60758 | 437 | text \<open> | 
| 23465 | 438 | \medskip Specific instances of congruence rules, to prevent | 
| 60758 | 439 | simplifier from looping.\<close> | 
| 23465 | 440 | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
45425diff
changeset | 441 | theorem imp_le_cong: | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
45425diff
changeset | 442 | "\<lbrakk>x = x'; 0 \<le> x' \<Longrightarrow> P = P'\<rbrakk> \<Longrightarrow> (0 \<le> (x::int) \<longrightarrow> P) = (0 \<le> x' \<longrightarrow> P')" | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
45425diff
changeset | 443 | by simp | 
| 23465 | 444 | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
45425diff
changeset | 445 | theorem conj_le_cong: | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
45425diff
changeset | 446 | "\<lbrakk>x = x'; 0 \<le> x' \<Longrightarrow> P = P'\<rbrakk> \<Longrightarrow> (0 \<le> (x::int) \<and> P) = (0 \<le> x' \<and> P')" | 
| 23465 | 447 | by (simp cong: conj_cong) | 
| 36799 | 448 | |
| 69605 | 449 | ML_file \<open>Tools/Qelim/cooper.ML\<close> | 
| 23465 | 450 | |
| 60758 | 451 | method_setup presburger = \<open> | 
| 47432 | 452 | let | 
| 453 | fun keyword k = Scan.lift (Args.$$$ k -- Args.colon) >> K () | |
| 454 | fun simple_keyword k = Scan.lift (Args.$$$ k) >> K () | |
| 455 | val addN = "add" | |
| 456 | val delN = "del" | |
| 457 | val elimN = "elim" | |
| 458 | val any_keyword = keyword addN || keyword delN || simple_keyword elimN | |
| 61476 | 459 | val thms = Scan.repeats (Scan.unless any_keyword Attrib.multi_thm) | 
| 47432 | 460 | in | 
| 461 | Scan.optional (simple_keyword elimN >> K false) true -- | |
| 462 | Scan.optional (keyword addN |-- thms) [] -- | |
| 463 | Scan.optional (keyword delN |-- thms) [] >> | |
| 464 | (fn ((elim, add_ths), del_ths) => fn ctxt => | |
| 465 | SIMPLE_METHOD' (Cooper.tac elim add_ths del_ths ctxt)) | |
| 466 | end | |
| 60758 | 467 | \<close> "Cooper's algorithm for Presburger arithmetic" | 
| 23465 | 468 | |
| 64247 | 469 | declare mod_eq_0_iff_dvd [presburger] | 
| 64244 | 470 | declare mod_by_Suc_0 [presburger] | 
| 54227 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 471 | declare mod_0 [presburger] | 
| 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 472 | declare mod_by_1 [presburger] | 
| 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 473 | declare mod_self [presburger] | 
| 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 474 | declare div_by_0 [presburger] | 
| 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 475 | declare mod_by_0 [presburger] | 
| 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 476 | declare mod_div_trivial [presburger] | 
| 64242 
93c6f0da5c70
more standardized theorem names for facts involving the div and mod identity
 haftmann parents: 
63962diff
changeset | 477 | declare mult_div_mod_eq [presburger] | 
| 
93c6f0da5c70
more standardized theorem names for facts involving the div and mod identity
 haftmann parents: 
63962diff
changeset | 478 | declare div_mult_mod_eq [presburger] | 
| 54227 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 479 | declare mod_mult_self1 [presburger] | 
| 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 480 | declare mod_mult_self2 [presburger] | 
| 64247 | 481 | declare mod2_Suc_Suc [presburger] | 
| 54227 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 482 | declare not_mod_2_eq_0_eq_1 [presburger] | 
| 
63b441f49645
moving generic lemmas out of theory parity, disregarding some unused auxiliary lemmas;
 haftmann parents: 
49962diff
changeset | 483 | declare nat_zero_less_power_iff [presburger] | 
| 36798 | 484 | |
| 27668 | 485 | lemma [presburger, algebra]: "m mod 2 = (1::nat) \<longleftrightarrow> \<not> 2 dvd m " by presburger | 
| 486 | lemma [presburger, algebra]: "m mod 2 = Suc 0 \<longleftrightarrow> \<not> 2 dvd m " by presburger | |
| 487 | lemma [presburger, algebra]: "m mod (Suc (Suc 0)) = (1::nat) \<longleftrightarrow> \<not> 2 dvd m " by presburger | |
| 488 | lemma [presburger, algebra]: "m mod (Suc (Suc 0)) = Suc 0 \<longleftrightarrow> \<not> 2 dvd m " by presburger | |
| 489 | lemma [presburger, algebra]: "m mod 2 = (1::int) \<longleftrightarrow> \<not> 2 dvd m " by presburger | |
| 23465 | 490 | |
| 70341 
972c0c744e7c
generalized type classes for parity to cover word types also, which contain zero divisors
 haftmann parents: 
70340diff
changeset | 491 | context semiring_parity | 
| 58777 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 492 | begin | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 493 | |
| 68100 | 494 | declare even_mult_iff [presburger] | 
| 58777 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 495 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 496 | declare even_power [presburger] | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 497 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 498 | lemma [presburger]: | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 499 | "even (a + b) \<longleftrightarrow> even a \<and> even b \<or> odd a \<and> odd b" | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 500 | by auto | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 501 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 502 | end | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 503 | |
| 70341 
972c0c744e7c
generalized type classes for parity to cover word types also, which contain zero divisors
 haftmann parents: 
70340diff
changeset | 504 | context ring_parity | 
| 58777 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 505 | begin | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 506 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 507 | declare even_minus [presburger] | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 508 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 509 | end | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 510 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 511 | context linordered_idom | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 512 | begin | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 513 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 514 | declare zero_le_power_eq [presburger] | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 515 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 516 | declare zero_less_power_eq [presburger] | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 517 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 518 | declare power_less_zero_eq [presburger] | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 519 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 520 | declare power_le_zero_eq [presburger] | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 521 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 522 | end | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 523 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 524 | declare even_Suc [presburger] | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 525 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 526 | lemma [presburger]: | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 527 | "Suc n div Suc (Suc 0) = n div Suc (Suc 0) \<longleftrightarrow> even n" | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 528 | by presburger | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 529 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 530 | declare even_diff_nat [presburger] | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 531 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 532 | lemma [presburger]: | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 533 | fixes k :: int | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 534 | shows "(k + 1) div 2 = k div 2 \<longleftrightarrow> even k" | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 535 | by presburger | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 536 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 537 | lemma [presburger]: | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 538 | fixes k :: int | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 539 | shows "(k + 1) div 2 = k div 2 + 1 \<longleftrightarrow> odd k" | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 540 | by presburger | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 541 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 542 | lemma [presburger]: | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 543 | "even n \<longleftrightarrow> even (int n)" | 
| 66630 | 544 | by simp | 
| 58777 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 545 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 546 | |
| 69593 | 547 | subsection \<open>Nice facts about division by \<^term>\<open>4\<close>\<close> | 
| 58777 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 548 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 549 | lemma even_even_mod_4_iff: | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 550 | "even (n::nat) \<longleftrightarrow> even (n mod 4)" | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 551 | by presburger | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 552 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 553 | lemma odd_mod_4_div_2: | 
| 68157 | 554 | "n mod 4 = (3::nat) \<Longrightarrow> odd ((n - Suc 0) div 2)" | 
| 58777 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 555 | by presburger | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 556 | |
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 557 | lemma even_mod_4_div_2: | 
| 68157 | 558 | "n mod 4 = Suc 0 \<Longrightarrow> even ((n - Suc 0) div 2)" | 
| 58777 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 559 | by presburger | 
| 
6ba2f1fa243b
further downshift of theory Parity in the hierarchy
 haftmann parents: 
57514diff
changeset | 560 | |
| 56850 | 561 | |
| 60758 | 562 | subsection \<open>Try0\<close> | 
| 56850 | 563 | |
| 69605 | 564 | ML_file \<open>Tools/try0.ML\<close> | 
| 56850 | 565 | |
| 23465 | 566 | end |