src/HOL/Presburger.thy
changeset 61799 4cf66f21b764
parent 61476 1884c40f1539
child 61944 5d06ecfdb472
equal deleted inserted replaced
61798:27f3c10b0b50 61799:4cf66f21b764
    10 begin
    10 begin
    11 
    11 
    12 ML_file "Tools/Qelim/qelim.ML"
    12 ML_file "Tools/Qelim/qelim.ML"
    13 ML_file "Tools/Qelim/cooper_procedure.ML"
    13 ML_file "Tools/Qelim/cooper_procedure.ML"
    14 
    14 
    15 subsection\<open>The @{text "-\<infinity>"} and @{text "+\<infinity>"} Properties\<close>
    15 subsection\<open>The \<open>-\<infinity>\<close> and \<open>+\<infinity>\<close> Properties\<close>
    16 
    16 
    17 lemma minf:
    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> 
    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)"
    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> 
    20   "\<lbrakk>\<exists>(z ::'a::linorder).\<forall>x<z. P x = P' x; \<exists>z.\<forall>x<z. Q x = Q' x\<rbrakk> 
   174   {fix x assume H: "\<not>(d dvd x + t)" with d have "\<not>d dvd (x + D) + t"
   174   {fix x assume H: "\<not>(d dvd x + t)" with d have "\<not>d dvd (x + D) + t"
   175       by (clarsimp simp add: dvd_def,erule_tac x= "ka - k" in allE,simp add: algebra_simps)}
   175       by (clarsimp simp add: dvd_def,erule_tac x= "ka - k" in allE,simp add: algebra_simps)}
   176   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
   176   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
   177 qed blast
   177 qed blast
   178 
   178 
   179 subsection\<open>Cooper's Theorem @{text "-\<infinity>"} and @{text "+\<infinity>"} Version\<close>
   179 subsection\<open>Cooper's Theorem \<open>-\<infinity>\<close> and \<open>+\<infinity>\<close> Version\<close>
   180 
   180 
   181 subsubsection\<open>First some trivial facts about periodic sets or predicates\<close>
   181 subsubsection\<open>First some trivial facts about periodic sets or predicates\<close>
   182 lemma periodic_finite_ex:
   182 lemma periodic_finite_ex:
   183   assumes dpos: "(0::int) < d" and modd: "ALL x k. P x = P(x - k*d)"
   183   assumes dpos: "(0::int) < d" and modd: "ALL x k. P x = P(x - k*d)"
   184   shows "(EX x. P x) = (EX j : {1..d}. P j)"
   184   shows "(EX x. P x) = (EX j : {1..d}. P j)"
   207     qed
   207     qed
   208     ultimately show ?RHS ..
   208     ultimately show ?RHS ..
   209   qed
   209   qed
   210 qed auto
   210 qed auto
   211 
   211 
   212 subsubsection\<open>The @{text "-\<infinity>"} Version\<close>
   212 subsubsection\<open>The \<open>-\<infinity>\<close> Version\<close>
   213 
   213 
   214 lemma decr_lemma: "0 < (d::int) \<Longrightarrow> x - (abs(x-z)+1) * d < z"
   214 lemma decr_lemma: "0 < (d::int) \<Longrightarrow> x - (abs(x-z)+1) * d < z"
   215 by(induct rule: int_gr_induct,simp_all add:int_distrib)
   215 by(induct rule: int_gr_induct,simp_all add:int_distrib)
   216 
   216 
   217 lemma incr_lemma: "0 < (d::int) \<Longrightarrow> z < x + (abs(x-z)+1) * d"
   217 lemma incr_lemma: "0 < (d::int) \<Longrightarrow> z < x + (abs(x-z)+1) * d"
   275    with periodic_finite_ex[OF dp pd]
   275    with periodic_finite_ex[OF dp pd]
   276    have "?R1" by blast}
   276    have "?R1" by blast}
   277  ultimately show ?thesis by blast
   277  ultimately show ?thesis by blast
   278 qed
   278 qed
   279 
   279 
   280 subsubsection \<open>The @{text "+\<infinity>"} Version\<close>
   280 subsubsection \<open>The \<open>+\<infinity>\<close> Version\<close>
   281 
   281 
   282 lemma  plusinfinity:
   282 lemma  plusinfinity:
   283   assumes dpos: "(0::int) < d" and
   283   assumes dpos: "(0::int) < d" and
   284     P1eqP1: "\<forall>x k. P' x = P'(x - k*d)" and ePeqP1: "\<exists> z. \<forall> x>z. P x = P' x"
   284     P1eqP1: "\<forall>x k. P' x = P'(x - k*d)" and ePeqP1: "\<exists> z. \<forall> x>z. P x = P' x"
   285   shows "(\<exists> x. P' x) \<longrightarrow> (\<exists> x. P x)"
   285   shows "(\<exists> x. P' x) \<longrightarrow> (\<exists> x. P x)"
   370 lemma uminus_dvd_conv:
   370 lemma uminus_dvd_conv:
   371   fixes d t :: int
   371   fixes d t :: int
   372   shows "d dvd t \<equiv> - d dvd t" and "d dvd t \<equiv> d dvd - t"
   372   shows "d dvd t \<equiv> - d dvd t" and "d dvd t \<equiv> d dvd - t"
   373   by simp_all
   373   by simp_all
   374 
   374 
   375 text \<open>\bigskip Theorems for transforming predicates on nat to predicates on @{text int}\<close>
   375 text \<open>\bigskip Theorems for transforming predicates on nat to predicates on \<open>int\<close>\<close>
   376 
   376 
   377 lemma zdiff_int_split: "P (int (x - y)) =
   377 lemma zdiff_int_split: "P (int (x - y)) =
   378   ((y \<le> x \<longrightarrow> P (int x - int y)) \<and> (x < y \<longrightarrow> P 0))"
   378   ((y \<le> x \<longrightarrow> P (int x - int y)) \<and> (x < y \<longrightarrow> P 0))"
   379   by (cases "y \<le> x") (simp_all add: zdiff_int)
   379   by (cases "y \<le> x") (simp_all add: zdiff_int)
   380 
   380