src/HOL/Presburger.thy
changeset 61944 5d06ecfdb472
parent 61799 4cf66f21b764
child 62348 9a5f43dac883
equal deleted inserted replaced
61943:7fba644ed827 61944:5d06ecfdb472
   209   qed
   209   qed
   210 qed auto
   210 qed auto
   211 
   211 
   212 subsubsection\<open>The \<open>-\<infinity>\<close> 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 - (\<bar>x - z\<bar> + 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 + (\<bar>x - z\<bar> + 1) * d"
   218 by(induct rule: int_gr_induct, simp_all add:int_distrib)
   218   by (induct rule: int_gr_induct) (simp_all add: int_distrib)
   219 
   219 
   220 lemma decr_mult_lemma:
   220 lemma decr_mult_lemma:
   221   assumes dpos: "(0::int) < d" and minus: "\<forall>x. P x \<longrightarrow> P(x - d)" and knneg: "0 <= k"
   221   assumes dpos: "(0::int) < d" and minus: "\<forall>x. P x \<longrightarrow> P(x - d)" and knneg: "0 <= k"
   222   shows "ALL x. P x \<longrightarrow> P(x - k*d)"
   222   shows "ALL x. P x \<longrightarrow> P(x - k*d)"
   223 using knneg
   223 using knneg
   239   shows "(EX x. P1 x) \<longrightarrow> (EX x. P x)"
   239   shows "(EX x. P1 x) \<longrightarrow> (EX x. P x)"
   240 proof
   240 proof
   241   assume eP1: "EX x. P1 x"
   241   assume eP1: "EX x. P1 x"
   242   then obtain x where P1: "P1 x" ..
   242   then obtain x where P1: "P1 x" ..
   243   from ePeqP1 obtain z where P1eqP: "ALL x. x < z \<longrightarrow> (P x = P1 x)" ..
   243   from ePeqP1 obtain z where P1eqP: "ALL x. x < z \<longrightarrow> (P x = P1 x)" ..
   244   let ?w = "x - (abs(x-z)+1) * d"
   244   let ?w = "x - (\<bar>x - z\<bar> + 1) * d"
   245   from dpos have w: "?w < z" by(rule decr_lemma)
   245   from dpos have w: "?w < z" by(rule decr_lemma)
   246   have "P1 x = P1 ?w" using P1eqP1 by blast
   246   have "P1 x = P1 ?w" using P1eqP1 by blast
   247   also have "\<dots> = P(?w)" using w P1eqP by blast
   247   also have "\<dots> = P(?w)" using w P1eqP by blast
   248   finally have "P ?w" using P1 by blast
   248   finally have "P ?w" using P1 by blast
   249   thus "EX x. P x" ..
   249   thus "EX 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)"
   286 proof
   286 proof
   287   assume eP1: "EX x. P' x"
   287   assume eP1: "EX x. P' x"
   288   then obtain x where P1: "P' x" ..
   288   then obtain x where P1: "P' x" ..
   289   from ePeqP1 obtain z where P1eqP: "\<forall>x>z. P x = P' x" ..
   289   from ePeqP1 obtain z where P1eqP: "\<forall>x>z. P x = P' x" ..
   290   let ?w' = "x + (abs(x-z)+1) * d"
   290   let ?w' = "x + (\<bar>x - z\<bar> + 1) * d"
   291   let ?w = "x - (-(abs(x-z) + 1))*d"
   291   let ?w = "x - (- (\<bar>x - z\<bar> + 1)) * d"
   292   have ww'[simp]: "?w = ?w'" by (simp add: algebra_simps)
   292   have ww'[simp]: "?w = ?w'" by (simp add: algebra_simps)
   293   from dpos have w: "?w > z" by(simp only: ww' incr_lemma)
   293   from dpos have w: "?w > z" by(simp only: ww' incr_lemma)
   294   hence "P' x = P' ?w" using P1eqP1 by blast
   294   hence "P' x = P' ?w" using P1eqP1 by blast
   295   also have "\<dots> = P(?w)" using w P1eqP by blast
   295   also have "\<dots> = P(?w)" using w P1eqP by blast
   296   finally have "P ?w" using P1 by blast
   296   finally have "P ?w" using P1 by blast