src/HOL/ex/MIR.thy
changeset 29667 53103fc8ffa3
parent 29265 5b4247055bd7
equal deleted inserted replaced
29549:7187373c6cb1 29667:53103fc8ffa3
   707   from gp have gnz: "g \<noteq> 0" by simp
   707   from gp have gnz: "g \<noteq> 0" by simp
   708   from prems show ?case by (simp add: real_of_int_div[OF gnz gd])
   708   from prems show ?case by (simp add: real_of_int_div[OF gnz gd])
   709 next
   709 next
   710   case (2 n c t)  hence gd: "g dvd c" by simp
   710   case (2 n c t)  hence gd: "g dvd c" by simp
   711   from gp have gnz: "g \<noteq> 0" by simp
   711   from gp have gnz: "g \<noteq> 0" by simp
   712   from prems show ?case by (simp add: real_of_int_div[OF gnz gd] ring_simps)
   712   from prems show ?case by (simp add: real_of_int_div[OF gnz gd] algebra_simps)
   713 next
   713 next
   714   case (3 c s t)  hence gd: "g dvd c" by simp
   714   case (3 c s t)  hence gd: "g dvd c" by simp
   715   from gp have gnz: "g \<noteq> 0" by simp
   715   from gp have gnz: "g \<noteq> 0" by simp
   716   from prems show ?case by (simp add: real_of_int_div[OF gnz gd] ring_simps) 
   716   from prems show ?case by (simp add: real_of_int_div[OF gnz gd] algebra_simps) 
   717 qed (auto simp add: numgcd_def gp)
   717 qed (auto simp add: numgcd_def gp)
   718 consts ismaxcoeff:: "num \<Rightarrow> int \<Rightarrow> bool"
   718 consts ismaxcoeff:: "num \<Rightarrow> int \<Rightarrow> bool"
   719 recdef ismaxcoeff "measure size"
   719 recdef ismaxcoeff "measure size"
   720   "ismaxcoeff (C i) = (\<lambda> x. abs i \<le> x)"
   720   "ismaxcoeff (C i) = (\<lambda> x. abs i \<le> x)"
   721   "ismaxcoeff (CN n c t) = (\<lambda>x. abs c \<le> x \<and> (ismaxcoeff t x))"
   721   "ismaxcoeff (CN n c t) = (\<lambda>x. abs c \<le> x \<and> (ismaxcoeff t x))"
   848   "numadd (a,b) = Add a b"
   848   "numadd (a,b) = Add a b"
   849 
   849 
   850 lemma numadd[simp]: "Inum bs (numadd (t,s)) = Inum bs (Add t s)"
   850 lemma numadd[simp]: "Inum bs (numadd (t,s)) = Inum bs (Add t s)"
   851 apply (induct t s rule: numadd.induct, simp_all add: Let_def)
   851 apply (induct t s rule: numadd.induct, simp_all add: Let_def)
   852  apply (case_tac "c1+c2 = 0",case_tac "n1 \<le> n2", simp_all)
   852  apply (case_tac "c1+c2 = 0",case_tac "n1 \<le> n2", simp_all)
   853   apply (case_tac "n1 = n2", simp_all add: ring_simps)
   853   apply (case_tac "n1 = n2", simp_all add: algebra_simps)
   854   apply (simp only: left_distrib[symmetric])
   854   apply (simp only: left_distrib[symmetric])
   855  apply simp
   855  apply simp
   856 apply (case_tac "lex_bnd t1 t2", simp_all)
   856 apply (case_tac "lex_bnd t1 t2", simp_all)
   857  apply (case_tac "c1+c2 = 0")
   857  apply (case_tac "c1+c2 = 0")
   858   by (case_tac "t1 = t2", simp_all add: ring_simps left_distrib[symmetric] real_of_int_mult[symmetric] real_of_int_add[symmetric]del: real_of_int_mult real_of_int_add left_distrib)
   858   by (case_tac "t1 = t2", simp_all add: algebra_simps left_distrib[symmetric] real_of_int_mult[symmetric] real_of_int_add[symmetric]del: real_of_int_mult real_of_int_add left_distrib)
   859 
   859 
   860 lemma numadd_nb[simp]: "\<lbrakk> numbound0 t ; numbound0 s\<rbrakk> \<Longrightarrow> numbound0 (numadd (t,s))"
   860 lemma numadd_nb[simp]: "\<lbrakk> numbound0 t ; numbound0 s\<rbrakk> \<Longrightarrow> numbound0 (numadd (t,s))"
   861 by (induct t s rule: numadd.induct, auto simp add: Let_def)
   861 by (induct t s rule: numadd.induct, auto simp add: Let_def)
   862 
   862 
   863 recdef nummul "measure size"
   863 recdef nummul "measure size"
   866   "nummul (CF c t s) = (\<lambda> i. CF (c*i) t (nummul s i))"
   866   "nummul (CF c t s) = (\<lambda> i. CF (c*i) t (nummul s i))"
   867   "nummul (Mul c t) = (\<lambda> i. nummul t (i*c))"
   867   "nummul (Mul c t) = (\<lambda> i. nummul t (i*c))"
   868   "nummul t = (\<lambda> i. Mul i t)"
   868   "nummul t = (\<lambda> i. Mul i t)"
   869 
   869 
   870 lemma nummul[simp]: "\<And> i. Inum bs (nummul t i) = Inum bs (Mul i t)"
   870 lemma nummul[simp]: "\<And> i. Inum bs (nummul t i) = Inum bs (Mul i t)"
   871 by (induct t rule: nummul.induct, auto simp add: ring_simps)
   871 by (induct t rule: nummul.induct, auto simp add: algebra_simps)
   872 
   872 
   873 lemma nummul_nb[simp]: "\<And> i. numbound0 t \<Longrightarrow> numbound0 (nummul t i)"
   873 lemma nummul_nb[simp]: "\<And> i. numbound0 t \<Longrightarrow> numbound0 (nummul t i)"
   874 by (induct t rule: nummul.induct, auto)
   874 by (induct t rule: nummul.induct, auto)
   875 
   875 
   876 constdefs numneg :: "num \<Rightarrow> num"
   876 constdefs numneg :: "num \<Rightarrow> num"
   926   let ?bi = "snd (split_int b)"
   926   let ?bi = "snd (split_int b)"
   927   have "split_int b = (?bv,?bi)" by simp
   927   have "split_int b = (?bv,?bi)" by simp
   928   with prems(1) have b:"Inum bs (Add ?bv ?bi) = Inum bs b" and bii: "isint ?bi bs" by blast+
   928   with prems(1) have b:"Inum bs (Add ?bv ?bi) = Inum bs b" and bii: "isint ?bi bs" by blast+
   929   from prems(2) have tibi: "ti = CF c a ?bi" by (simp add: Let_def split_def)
   929   from prems(2) have tibi: "ti = CF c a ?bi" by (simp add: Let_def split_def)
   930   from prems(2) b[symmetric] bii show ?case by (auto simp add: Let_def split_def isint_Floor isint_add isint_Mul isint_CF)
   930   from prems(2) b[symmetric] bii show ?case by (auto simp add: Let_def split_def isint_Floor isint_add isint_Mul isint_CF)
   931 qed (auto simp add: Let_def isint_iff isint_Floor isint_add isint_Mul split_def ring_simps)
   931 qed (auto simp add: Let_def isint_iff isint_Floor isint_add isint_Mul split_def algebra_simps)
   932 
   932 
   933 lemma split_int_nb: "numbound0 t \<Longrightarrow> numbound0 (fst (split_int t)) \<and> numbound0 (snd (split_int t)) "
   933 lemma split_int_nb: "numbound0 t \<Longrightarrow> numbound0 (fst (split_int t)) \<and> numbound0 (snd (split_int t)) "
   934 by (induct t rule: split_int.induct, auto simp add: Let_def split_def)
   934 by (induct t rule: split_int.induct, auto simp add: Let_def split_def)
   935 
   935 
   936 definition
   936 definition
  1766   "(real (a::int) + b > 0) = (real a + real (floor b) > 0 \<or> (real a + real (floor b) = 0 \<and> real (floor b) - b < 0))"
  1766   "(real (a::int) + b > 0) = (real a + real (floor b) > 0 \<or> (real a + real (floor b) = 0 \<and> real (floor b) - b < 0))"
  1767 proof- 
  1767 proof- 
  1768   have th: "(real a + b >0) = (real (-a) + (-b)< 0)" by arith
  1768   have th: "(real a + b >0) = (real (-a) + (-b)< 0)" by arith
  1769   show ?thesis using myless[rule_format, where b="real (floor b)"] 
  1769   show ?thesis using myless[rule_format, where b="real (floor b)"] 
  1770     by (simp only:th split_int_less_real'[where a="-a" and b="-b"]) 
  1770     by (simp only:th split_int_less_real'[where a="-a" and b="-b"]) 
  1771     (simp add: ring_simps diff_def[symmetric],arith)
  1771     (simp add: algebra_simps diff_def[symmetric],arith)
  1772 qed
  1772 qed
  1773 
  1773 
  1774 lemma split_int_le_real: 
  1774 lemma split_int_le_real: 
  1775   "(real (a::int) \<le> b) = (a \<le> floor b \<or> (a = floor b \<and> real (floor b) < b))"
  1775   "(real (a::int) \<le> b) = (a \<le> floor b \<or> (a = floor b \<and> real (floor b) < b))"
  1776 proof( auto)
  1776 proof( auto)
  1793 lemma split_int_ge_real': 
  1793 lemma split_int_ge_real': 
  1794   "(real (a::int) + b \<ge> 0) = (real a + real (floor b) \<ge> 0 \<or> (real a + real (floor b) = 0 \<and> real (floor b) - b < 0))"
  1794   "(real (a::int) + b \<ge> 0) = (real a + real (floor b) \<ge> 0 \<or> (real a + real (floor b) = 0 \<and> real (floor b) - b < 0))"
  1795 proof- 
  1795 proof- 
  1796   have th: "(real a + b \<ge>0) = (real (-a) + (-b) \<le> 0)" by arith
  1796   have th: "(real a + b \<ge>0) = (real (-a) + (-b) \<le> 0)" by arith
  1797   show ?thesis by (simp only: th split_int_le_real'[where a="-a" and b="-b"])
  1797   show ?thesis by (simp only: th split_int_le_real'[where a="-a" and b="-b"])
  1798     (simp add: ring_simps diff_def[symmetric],arith)
  1798     (simp add: algebra_simps diff_def[symmetric],arith)
  1799 qed
  1799 qed
  1800 
  1800 
  1801 lemma split_int_eq_real: "(real (a::int) = b) = ( a = floor b \<and> b = real (floor b))" (is "?l = ?r")
  1801 lemma split_int_eq_real: "(real (a::int) = b) = ( a = floor b \<and> b = real (floor b))" (is "?l = ?r")
  1802 by auto
  1802 by auto
  1803 
  1803 
  2279       assume 
  2279       assume 
  2280 	"real i rdvd real c * real x - real c * (real k * real d) + Inum (real x # bs) e"
  2280 	"real i rdvd real c * real x - real c * (real k * real d) + Inum (real x # bs) e"
  2281       (is "?ri rdvd ?rc*?rx - ?rc*(?rk*?rd) + ?I x e" is "?ri rdvd ?rt")
  2281       (is "?ri rdvd ?rc*?rx - ?rc*(?rk*?rd) + ?I x e" is "?ri rdvd ?rt")
  2282       hence "\<exists> (l::int). ?rt = ?ri * (real l)" by (simp add: rdvd_def)
  2282       hence "\<exists> (l::int). ?rt = ?ri * (real l)" by (simp add: rdvd_def)
  2283       hence "\<exists> (l::int). ?rc*?rx+ ?I x e = ?ri*(real l)+?rc*(?rk * (real i) * (real di))" 
  2283       hence "\<exists> (l::int). ?rc*?rx+ ?I x e = ?ri*(real l)+?rc*(?rk * (real i) * (real di))" 
  2284 	by (simp add: ring_simps di_def)
  2284 	by (simp add: algebra_simps di_def)
  2285       hence "\<exists> (l::int). ?rc*?rx+ ?I x e = ?ri*(real (l + c*k*di))"
  2285       hence "\<exists> (l::int). ?rc*?rx+ ?I x e = ?ri*(real (l + c*k*di))"
  2286 	by (simp add: ring_simps)
  2286 	by (simp add: algebra_simps)
  2287       hence "\<exists> (l::int). ?rc*?rx+ ?I x e = ?ri* (real l)" by blast
  2287       hence "\<exists> (l::int). ?rc*?rx+ ?I x e = ?ri* (real l)" by blast
  2288       thus "real i rdvd real c * real x + Inum (real x # bs) e" using rdvd_def by simp
  2288       thus "real i rdvd real c * real x + Inum (real x # bs) e" using rdvd_def by simp
  2289     next
  2289     next
  2290       assume 
  2290       assume 
  2291 	"real i rdvd real c * real x + Inum (real x # bs) e" (is "?ri rdvd ?rc*?rx+?e")
  2291 	"real i rdvd real c * real x + Inum (real x # bs) e" (is "?ri rdvd ?rc*?rx+?e")
  2292       hence "\<exists> (l::int). ?rc*?rx+?e = ?ri * (real l)" by (simp add: rdvd_def)
  2292       hence "\<exists> (l::int). ?rc*?rx+?e = ?ri * (real l)" by (simp add: rdvd_def)
  2293       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real l) - real c * (real k * real d)" by simp
  2293       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real l) - real c * (real k * real d)" by simp
  2294       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real l) - real c * (real k * real i * real di)" by (simp add: di_def)
  2294       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real l) - real c * (real k * real i * real di)" by (simp add: di_def)
  2295       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real (l - c*k*di))" by (simp add: ring_simps)
  2295       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real (l - c*k*di))" by (simp add: algebra_simps)
  2296       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real l)"
  2296       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real l)"
  2297 	by blast
  2297 	by blast
  2298       thus "real i rdvd real c * real x - real c * (real k * real d) + Inum (real x # bs) e" using rdvd_def by simp
  2298       thus "real i rdvd real c * real x - real c * (real k * real d) + Inum (real x # bs) e" using rdvd_def by simp
  2299     qed
  2299     qed
  2300 next
  2300 next
  2306       assume 
  2306       assume 
  2307 	"real i rdvd real c * real x - real c * (real k * real d) + Inum (real x # bs) e"
  2307 	"real i rdvd real c * real x - real c * (real k * real d) + Inum (real x # bs) e"
  2308       (is "?ri rdvd ?rc*?rx - ?rc*(?rk*?rd) + ?I x e" is "?ri rdvd ?rt")
  2308       (is "?ri rdvd ?rc*?rx - ?rc*(?rk*?rd) + ?I x e" is "?ri rdvd ?rt")
  2309       hence "\<exists> (l::int). ?rt = ?ri * (real l)" by (simp add: rdvd_def)
  2309       hence "\<exists> (l::int). ?rt = ?ri * (real l)" by (simp add: rdvd_def)
  2310       hence "\<exists> (l::int). ?rc*?rx+ ?I x e = ?ri*(real l)+?rc*(?rk * (real i) * (real di))" 
  2310       hence "\<exists> (l::int). ?rc*?rx+ ?I x e = ?ri*(real l)+?rc*(?rk * (real i) * (real di))" 
  2311 	by (simp add: ring_simps di_def)
  2311 	by (simp add: algebra_simps di_def)
  2312       hence "\<exists> (l::int). ?rc*?rx+ ?I x e = ?ri*(real (l + c*k*di))"
  2312       hence "\<exists> (l::int). ?rc*?rx+ ?I x e = ?ri*(real (l + c*k*di))"
  2313 	by (simp add: ring_simps)
  2313 	by (simp add: algebra_simps)
  2314       hence "\<exists> (l::int). ?rc*?rx+ ?I x e = ?ri* (real l)" by blast
  2314       hence "\<exists> (l::int). ?rc*?rx+ ?I x e = ?ri* (real l)" by blast
  2315       thus "real i rdvd real c * real x + Inum (real x # bs) e" using rdvd_def by simp
  2315       thus "real i rdvd real c * real x + Inum (real x # bs) e" using rdvd_def by simp
  2316     next
  2316     next
  2317       assume 
  2317       assume 
  2318 	"real i rdvd real c * real x + Inum (real x # bs) e" (is "?ri rdvd ?rc*?rx+?e")
  2318 	"real i rdvd real c * real x + Inum (real x # bs) e" (is "?ri rdvd ?rc*?rx+?e")
  2319       hence "\<exists> (l::int). ?rc*?rx+?e = ?ri * (real l)" by (simp add: rdvd_def)
  2319       hence "\<exists> (l::int). ?rc*?rx+?e = ?ri * (real l)" by (simp add: rdvd_def)
  2320       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real l) - real c * (real k * real d)" by simp
  2320       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real l) - real c * (real k * real d)" by simp
  2321       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real l) - real c * (real k * real i * real di)" by (simp add: di_def)
  2321       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real l) - real c * (real k * real i * real di)" by (simp add: di_def)
  2322       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real (l - c*k*di))" by (simp add: ring_simps)
  2322       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real (l - c*k*di))" by (simp add: algebra_simps)
  2323       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real l)"
  2323       hence "\<exists> (l::int). ?rc*?rx - real c * (real k * real d) +?e = ?ri * (real l)"
  2324 	by blast
  2324 	by blast
  2325       thus "real i rdvd real c * real x - real c * (real k * real d) + Inum (real x # bs) e" using rdvd_def by simp
  2325       thus "real i rdvd real c * real x - real c * (real k * real d) + Inum (real x # bs) e" using rdvd_def by simp
  2326     qed
  2326     qed
  2327 qed (auto simp add: nth_pos2 numbound0_I[where bs="bs" and b="real(x - k*d)" and b'="real x"] simp del: real_of_int_mult real_of_int_diff)
  2327 qed (auto simp add: nth_pos2 numbound0_I[where bs="bs" and b="real(x - k*d)" and b'="real x"] simp del: real_of_int_mult real_of_int_diff)
  2448 proof(induct p rule: iszlfm.induct)
  2448 proof(induct p rule: iszlfm.induct)
  2449   case (9 j c e)
  2449   case (9 j c e)
  2450   have th: "(real j rdvd real c * real x - Inum (real x # bs) e) =
  2450   have th: "(real j rdvd real c * real x - Inum (real x # bs) e) =
  2451        (real j rdvd - (real c * real x - Inum (real x # bs) e))"
  2451        (real j rdvd - (real c * real x - Inum (real x # bs) e))"
  2452     by (simp only: rdvd_minus[symmetric])
  2452     by (simp only: rdvd_minus[symmetric])
  2453   from prems show  ?case
  2453   from prems th show  ?case
  2454     by (simp add: ring_simps th[simplified ring_simps]
  2454     by (simp add: algebra_simps
  2455       numbound0_I[where bs="bs" and b'="real x" and b="- real x"])
  2455       numbound0_I[where bs="bs" and b'="real x" and b="- real x"])
  2456 next
  2456 next
  2457     case (10 j c e)
  2457     case (10 j c e)
  2458   have th: "(real j rdvd real c * real x - Inum (real x # bs) e) =
  2458   have th: "(real j rdvd real c * real x - Inum (real x # bs) e) =
  2459        (real j rdvd - (real c * real x - Inum (real x # bs) e))"
  2459        (real j rdvd - (real c * real x - Inum (real x # bs) e))"
  2460     by (simp only: rdvd_minus[symmetric])
  2460     by (simp only: rdvd_minus[symmetric])
  2461   from prems show  ?case
  2461   from prems th show  ?case
  2462     by (simp add: ring_simps th[simplified ring_simps]
  2462     by (simp add: algebra_simps
  2463       numbound0_I[where bs="bs" and b'="real x" and b="- real x"])
  2463       numbound0_I[where bs="bs" and b'="real x" and b="- real x"])
  2464 qed (auto simp add: numbound0_I[where bs="bs" and b="real x" and b'="- real x"] nth_pos2)
  2464 qed (auto simp add: numbound0_I[where bs="bs" and b="real x" and b'="- real x"] nth_pos2)
  2465 
  2465 
  2466 lemma mirror_l: "iszlfm p (a#bs) \<Longrightarrow> iszlfm (mirror p) (a#bs)"
  2466 lemma mirror_l: "iszlfm p (a#bs) \<Longrightarrow> iszlfm (mirror p) (a#bs)"
  2467 by (induct p rule: mirror.induct, auto simp add: isint_neg)
  2467 by (induct p rule: mirror.induct, auto simp add: isint_neg)
  2539     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2539     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2540       by simp
  2540       by simp
  2541     hence "(real l * real x + real (l div c) * Inum (real x # bs) e < (0\<Colon>real)) =
  2541     hence "(real l * real x + real (l div c) * Inum (real x # bs) e < (0\<Colon>real)) =
  2542           (real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e < 0)"
  2542           (real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e < 0)"
  2543       by simp
  2543       by simp
  2544     also have "\<dots> = (real (l div c) * (real c * real x + Inum (real x # bs) e) < (real (l div c)) * 0)" by (simp add: ring_simps)
  2544     also have "\<dots> = (real (l div c) * (real c * real x + Inum (real x # bs) e) < (real (l div c)) * 0)" by (simp add: algebra_simps)
  2545     also have "\<dots> = (real c * real x + Inum (real x # bs) e < 0)"
  2545     also have "\<dots> = (real c * real x + Inum (real x # bs) e < 0)"
  2546     using mult_less_0_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e"] ldcp by simp
  2546     using mult_less_0_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e"] ldcp by simp
  2547   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"] be  isint_Mul[OF ei] by simp
  2547   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"] be  isint_Mul[OF ei] by simp
  2548 next
  2548 next
  2549   case (6 c e) hence cp: "c>0" and be: "numbound0 e" and ei:"isint e (a#bs)" and d': "c dvd l" by simp+
  2549   case (6 c e) hence cp: "c>0" and be: "numbound0 e" and ei:"isint e (a#bs)" and d': "c dvd l" by simp+
  2557     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2557     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2558       by simp
  2558       by simp
  2559     hence "(real l * real x + real (l div c) * Inum (real x # bs) e \<le> (0\<Colon>real)) =
  2559     hence "(real l * real x + real (l div c) * Inum (real x # bs) e \<le> (0\<Colon>real)) =
  2560           (real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e \<le> 0)"
  2560           (real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e \<le> 0)"
  2561       by simp
  2561       by simp
  2562     also have "\<dots> = (real (l div c) * (real c * real x + Inum (real x # bs) e) \<le> (real (l div c)) * 0)" by (simp add: ring_simps)
  2562     also have "\<dots> = (real (l div c) * (real c * real x + Inum (real x # bs) e) \<le> (real (l div c)) * 0)" by (simp add: algebra_simps)
  2563     also have "\<dots> = (real c * real x + Inum (real x # bs) e \<le> 0)"
  2563     also have "\<dots> = (real c * real x + Inum (real x # bs) e \<le> 0)"
  2564     using mult_le_0_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e"] ldcp by simp
  2564     using mult_le_0_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e"] ldcp by simp
  2565   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"]  be  isint_Mul[OF ei] by simp
  2565   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"]  be  isint_Mul[OF ei] by simp
  2566 next
  2566 next
  2567   case (7 c e) hence cp: "c>0" and be: "numbound0 e" and ei:"isint e (a#bs)" and d': "c dvd l" by simp+
  2567   case (7 c e) hence cp: "c>0" and be: "numbound0 e" and ei:"isint e (a#bs)" and d': "c dvd l" by simp+
  2575     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2575     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2576       by simp
  2576       by simp
  2577     hence "(real l * real x + real (l div c) * Inum (real x # bs) e > (0\<Colon>real)) =
  2577     hence "(real l * real x + real (l div c) * Inum (real x # bs) e > (0\<Colon>real)) =
  2578           (real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e > 0)"
  2578           (real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e > 0)"
  2579       by simp
  2579       by simp
  2580     also have "\<dots> = (real (l div c) * (real c * real x + Inum (real x # bs) e) > (real (l div c)) * 0)" by (simp add: ring_simps)
  2580     also have "\<dots> = (real (l div c) * (real c * real x + Inum (real x # bs) e) > (real (l div c)) * 0)" by (simp add: algebra_simps)
  2581     also have "\<dots> = (real c * real x + Inum (real x # bs) e > 0)"
  2581     also have "\<dots> = (real c * real x + Inum (real x # bs) e > 0)"
  2582     using zero_less_mult_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e"] ldcp by simp
  2582     using zero_less_mult_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e"] ldcp by simp
  2583   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"]  be  isint_Mul[OF ei] by simp
  2583   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"]  be  isint_Mul[OF ei] by simp
  2584 next
  2584 next
  2585   case (8 c e) hence cp: "c>0" and be: "numbound0 e"  and ei:"isint e (a#bs)" and d': "c dvd l" by simp+
  2585   case (8 c e) hence cp: "c>0" and be: "numbound0 e"  and ei:"isint e (a#bs)" and d': "c dvd l" by simp+
  2593     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2593     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2594       by simp
  2594       by simp
  2595     hence "(real l * real x + real (l div c) * Inum (real x # bs) e \<ge> (0\<Colon>real)) =
  2595     hence "(real l * real x + real (l div c) * Inum (real x # bs) e \<ge> (0\<Colon>real)) =
  2596           (real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e \<ge> 0)"
  2596           (real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e \<ge> 0)"
  2597       by simp
  2597       by simp
  2598     also have "\<dots> = (real (l div c) * (real c * real x + Inum (real x # bs) e) \<ge> (real (l div c)) * 0)" by (simp add: ring_simps)
  2598     also have "\<dots> = (real (l div c) * (real c * real x + Inum (real x # bs) e) \<ge> (real (l div c)) * 0)" by (simp add: algebra_simps)
  2599     also have "\<dots> = (real c * real x + Inum (real x # bs) e \<ge> 0)"
  2599     also have "\<dots> = (real c * real x + Inum (real x # bs) e \<ge> 0)"
  2600     using zero_le_mult_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e"] ldcp by simp
  2600     using zero_le_mult_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e"] ldcp by simp
  2601   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"]  be  isint_Mul[OF ei] by simp
  2601   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"]  be  isint_Mul[OF ei] by simp
  2602 next
  2602 next
  2603   case (3 c e) hence cp: "c>0" and be: "numbound0 e" and ei:"isint e (a#bs)" and d': "c dvd l" by simp+
  2603   case (3 c e) hence cp: "c>0" and be: "numbound0 e" and ei:"isint e (a#bs)" and d': "c dvd l" by simp+
  2611     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2611     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2612       by simp
  2612       by simp
  2613     hence "(real l * real x + real (l div c) * Inum (real x # bs) e = (0\<Colon>real)) =
  2613     hence "(real l * real x + real (l div c) * Inum (real x # bs) e = (0\<Colon>real)) =
  2614           (real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e = 0)"
  2614           (real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e = 0)"
  2615       by simp
  2615       by simp
  2616     also have "\<dots> = (real (l div c) * (real c * real x + Inum (real x # bs) e) = (real (l div c)) * 0)" by (simp add: ring_simps)
  2616     also have "\<dots> = (real (l div c) * (real c * real x + Inum (real x # bs) e) = (real (l div c)) * 0)" by (simp add: algebra_simps)
  2617     also have "\<dots> = (real c * real x + Inum (real x # bs) e = 0)"
  2617     also have "\<dots> = (real c * real x + Inum (real x # bs) e = 0)"
  2618     using mult_eq_0_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e"] ldcp by simp
  2618     using mult_eq_0_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e"] ldcp by simp
  2619   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"]  be  isint_Mul[OF ei] by simp
  2619   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"]  be  isint_Mul[OF ei] by simp
  2620 next
  2620 next
  2621   case (4 c e) hence cp: "c>0" and be: "numbound0 e" and ei:"isint e (a#bs)" and d': "c dvd l" by simp+
  2621   case (4 c e) hence cp: "c>0" and be: "numbound0 e" and ei:"isint e (a#bs)" and d': "c dvd l" by simp+
  2629     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2629     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2630       by simp
  2630       by simp
  2631     hence "(real l * real x + real (l div c) * Inum (real x # bs) e \<noteq> (0\<Colon>real)) =
  2631     hence "(real l * real x + real (l div c) * Inum (real x # bs) e \<noteq> (0\<Colon>real)) =
  2632           (real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e \<noteq> 0)"
  2632           (real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e \<noteq> 0)"
  2633       by simp
  2633       by simp
  2634     also have "\<dots> = (real (l div c) * (real c * real x + Inum (real x # bs) e) \<noteq> (real (l div c)) * 0)" by (simp add: ring_simps)
  2634     also have "\<dots> = (real (l div c) * (real c * real x + Inum (real x # bs) e) \<noteq> (real (l div c)) * 0)" by (simp add: algebra_simps)
  2635     also have "\<dots> = (real c * real x + Inum (real x # bs) e \<noteq> 0)"
  2635     also have "\<dots> = (real c * real x + Inum (real x # bs) e \<noteq> 0)"
  2636     using zero_le_mult_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e"] ldcp by simp
  2636     using zero_le_mult_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e"] ldcp by simp
  2637   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"]  be  isint_Mul[OF ei] by simp
  2637   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"]  be  isint_Mul[OF ei] by simp
  2638 next
  2638 next
  2639   case (9 j c e) hence cp: "c>0" and be: "numbound0 e" and ei:"isint e (a#bs)" and jp: "j > 0" and d': "c dvd l" by simp+
  2639   case (9 j c e) hence cp: "c>0" and be: "numbound0 e" and ei:"isint e (a#bs)" and jp: "j > 0" and d': "c dvd l" by simp+
  2645       by (simp add: zdiv_self[OF cnz])
  2645       by (simp add: zdiv_self[OF cnz])
  2646     have "c * (l div c) = c* (l div c) + l mod c" using d' zdvd_iff_zmod_eq_0[where m="c" and n="l"] by simp
  2646     have "c * (l div c) = c* (l div c) + l mod c" using d' zdvd_iff_zmod_eq_0[where m="c" and n="l"] by simp
  2647     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2647     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2648       by simp
  2648       by simp
  2649     hence "(\<exists> (k::int). real l * real x + real (l div c) * Inum (real x # bs) e = (real (l div c) * real j) * real k) = (\<exists> (k::int). real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e = (real (l div c) * real j) * real k)"  by simp
  2649     hence "(\<exists> (k::int). real l * real x + real (l div c) * Inum (real x # bs) e = (real (l div c) * real j) * real k) = (\<exists> (k::int). real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e = (real (l div c) * real j) * real k)"  by simp
  2650     also have "\<dots> = (\<exists> (k::int). real (l div c) * (real c * real x + Inum (real x # bs) e - real j * real k) = real (l div c)*0)" by (simp add: ring_simps)
  2650     also have "\<dots> = (\<exists> (k::int). real (l div c) * (real c * real x + Inum (real x # bs) e - real j * real k) = real (l div c)*0)" by (simp add: algebra_simps)
  2651     also fix k have "\<dots> = (\<exists> (k::int). real c * real x + Inum (real x # bs) e - real j * real k = 0)"
  2651     also fix k have "\<dots> = (\<exists> (k::int). real c * real x + Inum (real x # bs) e - real j * real k = 0)"
  2652     using zero_le_mult_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e - real j * real k"] ldcp by simp
  2652     using zero_le_mult_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e - real j * real k"] ldcp by simp
  2653   also have "\<dots> = (\<exists> (k::int). real c * real x + Inum (real x # bs) e = real j * real k)" by simp
  2653   also have "\<dots> = (\<exists> (k::int). real c * real x + Inum (real x # bs) e = real j * real k)" by simp
  2654   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"] rdvd_def  be  isint_Mul[OF ei] mult_strict_mono[OF ldcp jp ldcp ] by simp 
  2654   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"] rdvd_def  be  isint_Mul[OF ei] mult_strict_mono[OF ldcp jp ldcp ] by simp 
  2655 next
  2655 next
  2662       by (simp add: zdiv_self[OF cnz])
  2662       by (simp add: zdiv_self[OF cnz])
  2663     have "c * (l div c) = c* (l div c) + l mod c" using d' zdvd_iff_zmod_eq_0[where m="c" and n="l"] by simp
  2663     have "c * (l div c) = c* (l div c) + l mod c" using d' zdvd_iff_zmod_eq_0[where m="c" and n="l"] by simp
  2664     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2664     hence cl:"c * (l div c) =l" using zmod_zdiv_equality[where a="l" and b="c", symmetric] 
  2665       by simp
  2665       by simp
  2666     hence "(\<exists> (k::int). real l * real x + real (l div c) * Inum (real x # bs) e = (real (l div c) * real j) * real k) = (\<exists> (k::int). real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e = (real (l div c) * real j) * real k)"  by simp
  2666     hence "(\<exists> (k::int). real l * real x + real (l div c) * Inum (real x # bs) e = (real (l div c) * real j) * real k) = (\<exists> (k::int). real (c * (l div c)) * real x + real (l div c) * Inum (real x # bs) e = (real (l div c) * real j) * real k)"  by simp
  2667     also have "\<dots> = (\<exists> (k::int). real (l div c) * (real c * real x + Inum (real x # bs) e - real j * real k) = real (l div c)*0)" by (simp add: ring_simps)
  2667     also have "\<dots> = (\<exists> (k::int). real (l div c) * (real c * real x + Inum (real x # bs) e - real j * real k) = real (l div c)*0)" by (simp add: algebra_simps)
  2668     also fix k have "\<dots> = (\<exists> (k::int). real c * real x + Inum (real x # bs) e - real j * real k = 0)"
  2668     also fix k have "\<dots> = (\<exists> (k::int). real c * real x + Inum (real x # bs) e - real j * real k = 0)"
  2669     using zero_le_mult_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e - real j * real k"] ldcp by simp
  2669     using zero_le_mult_iff [where a="real (l div c)" and b="real c * real x + Inum (real x # bs) e - real j * real k"] ldcp by simp
  2670   also have "\<dots> = (\<exists> (k::int). real c * real x + Inum (real x # bs) e = real j * real k)" by simp
  2670   also have "\<dots> = (\<exists> (k::int). real c * real x + Inum (real x # bs) e = real j * real k)" by simp
  2671   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"] rdvd_def  be  isint_Mul[OF ei]  mult_strict_mono[OF ldcp jp ldcp ] by simp
  2671   finally show ?case using numbound0_I[OF be,where b="real (l * x)" and b'="real x" and bs="bs"] rdvd_def  be  isint_Mul[OF ei]  mult_strict_mono[OF ldcp jp ldcp ] by simp
  2672 qed (simp_all add: nth_pos2 numbound0_I[where bs="bs" and b="real (l * x)" and b'="real x"] isint_Mul del: real_of_int_mult)
  2672 qed (simp_all add: nth_pos2 numbound0_I[where bs="bs" and b="real (l * x)" and b'="real x"] isint_Mul del: real_of_int_mult)
  2717       hence "real (x + floor ?e) > real (0::int) \<and> real (x + floor ?e) \<le> real d"
  2717       hence "real (x + floor ?e) > real (0::int) \<and> real (x + floor ?e) \<le> real d"
  2718 	using ie by simp
  2718 	using ie by simp
  2719       hence "x + floor ?e \<ge> 1 \<and> x + floor ?e \<le> d"  by simp
  2719       hence "x + floor ?e \<ge> 1 \<and> x + floor ?e \<le> d"  by simp
  2720       hence "\<exists> (j::int) \<in> {1 .. d}. j = x + floor ?e" by simp
  2720       hence "\<exists> (j::int) \<in> {1 .. d}. j = x + floor ?e" by simp
  2721       hence "\<exists> (j::int) \<in> {1 .. d}. real x = real (- floor ?e + j)" 
  2721       hence "\<exists> (j::int) \<in> {1 .. d}. real x = real (- floor ?e + j)" 
  2722 	by (simp only: real_of_int_inject) (simp add: ring_simps)
  2722 	by (simp only: real_of_int_inject) (simp add: algebra_simps)
  2723       hence "\<exists> (j::int) \<in> {1 .. d}. real x = - ?e + real j" 
  2723       hence "\<exists> (j::int) \<in> {1 .. d}. real x = - ?e + real j" 
  2724 	by (simp add: ie[simplified isint_iff])
  2724 	by (simp add: ie[simplified isint_iff])
  2725       with nob have ?case by auto}
  2725       with nob have ?case by auto}
  2726     ultimately show ?case by blast
  2726     ultimately show ?case by blast
  2727 next
  2727 next
  2742       from H p have "real x + ?e \<ge> 0 \<and> real x + ?e < real d" by (simp add: c1)
  2742       from H p have "real x + ?e \<ge> 0 \<and> real x + ?e < real d" by (simp add: c1)
  2743       hence "real (x + floor ?e) \<ge> real (0::int) \<and> real (x + floor ?e) < real d"
  2743       hence "real (x + floor ?e) \<ge> real (0::int) \<and> real (x + floor ?e) < real d"
  2744 	using ie by simp
  2744 	using ie by simp
  2745       hence "x + floor ?e +1 \<ge> 1 \<and> x + floor ?e + 1 \<le> d"  by simp
  2745       hence "x + floor ?e +1 \<ge> 1 \<and> x + floor ?e + 1 \<le> d"  by simp
  2746       hence "\<exists> (j::int) \<in> {1 .. d}. j = x + floor ?e + 1" by simp
  2746       hence "\<exists> (j::int) \<in> {1 .. d}. j = x + floor ?e + 1" by simp
  2747       hence "\<exists> (j::int) \<in> {1 .. d}. x= - floor ?e - 1 + j" by (simp add: ring_simps)
  2747       hence "\<exists> (j::int) \<in> {1 .. d}. x= - floor ?e - 1 + j" by (simp add: algebra_simps)
  2748       hence "\<exists> (j::int) \<in> {1 .. d}. real x= real (- floor ?e - 1 + j)" 
  2748       hence "\<exists> (j::int) \<in> {1 .. d}. real x= real (- floor ?e - 1 + j)" 
  2749 	by (simp only: real_of_int_inject)
  2749 	by (simp only: real_of_int_inject)
  2750       hence "\<exists> (j::int) \<in> {1 .. d}. real x= - ?e - 1 + real j" 
  2750       hence "\<exists> (j::int) \<in> {1 .. d}. real x= - ?e - 1 + real j" 
  2751 	by (simp add: ie[simplified isint_iff])
  2751 	by (simp add: ie[simplified isint_iff])
  2752       with nob have ?case by simp }
  2752       with nob have ?case by simp }
  2757     let ?e = "Inum (real x # bs) e"
  2757     let ?e = "Inum (real x # bs) e"
  2758     let ?v="(Sub (C -1) e)"
  2758     let ?v="(Sub (C -1) e)"
  2759     have vb: "?v \<in> set (\<beta> (Eq (CN 0 c e)))" by simp
  2759     have vb: "?v \<in> set (\<beta> (Eq (CN 0 c e)))" by simp
  2760     from p have "real x= - ?e" by (simp add: c1) with prems(11) show ?case using dp
  2760     from p have "real x= - ?e" by (simp add: c1) with prems(11) show ?case using dp
  2761       by simp (erule ballE[where x="1"],
  2761       by simp (erule ballE[where x="1"],
  2762 	simp_all add:ring_simps numbound0_I[OF bn,where b="real x"and b'="a"and bs="bs"])
  2762 	simp_all add:algebra_simps numbound0_I[OF bn,where b="real x"and b'="a"and bs="bs"])
  2763 next
  2763 next
  2764   case (4 c e)hence p: "Ifm (real x #bs) (NEq (CN 0 c e))" (is "?p x") and c1: "c=1" 
  2764   case (4 c e)hence p: "Ifm (real x #bs) (NEq (CN 0 c e))" (is "?p x") and c1: "c=1" 
  2765     and bn:"numbound0 e" and ie1: "isint e (a #bs)" using dvd1_eq1[where x="c"] by simp+
  2765     and bn:"numbound0 e" and ie1: "isint e (a #bs)" using dvd1_eq1[where x="c"] by simp+
  2766     let ?e = "Inum (real x # bs) e"
  2766     let ?e = "Inum (real x # bs) e"
  2767     let ?v="Neg e"
  2767     let ?v="Neg e"
  2981       from kpos have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  2981       from kpos have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  2982       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  2982       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  2983       from prems have "?I (real x) (?s (Eq (CN 0 c e))) = ((real c * (?N (real x) t / real k) + ?N (real x) e)* real k = 0)"
  2983       from prems have "?I (real x) (?s (Eq (CN 0 c e))) = ((real c * (?N (real x) t / real k) + ?N (real x) e)* real k = 0)"
  2984 	using real_of_int_div[OF knz kdt]
  2984 	using real_of_int_div[OF knz kdt]
  2985 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  2985 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  2986 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti ring_simps)
  2986 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti algebra_simps)
  2987       also have "\<dots> = (?I ?tk (Eq (CN 0 c e)))" using nonzero_eq_divide_eq[OF knz', where a="real c * (?N (real x) t / real k) + ?N (real x) e" and b="0", symmetric] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  2987       also have "\<dots> = (?I ?tk (Eq (CN 0 c e)))" using nonzero_eq_divide_eq[OF knz', where a="real c * (?N (real x) t / real k) + ?N (real x) e" and b="0", symmetric] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  2988 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  2988 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  2989 	by (simp add: ti)
  2989 	by (simp add: ti)
  2990       finally have ?case . }
  2990       finally have ?case . }
  2991     ultimately show ?case by blast 
  2991     ultimately show ?case by blast 
  3003       from kpos have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3003       from kpos have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3004       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  3004       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  3005       from prems have "?I (real x) (?s (NEq (CN 0 c e))) = ((real c * (?N (real x) t / real k) + ?N (real x) e)* real k \<noteq> 0)"
  3005       from prems have "?I (real x) (?s (NEq (CN 0 c e))) = ((real c * (?N (real x) t / real k) + ?N (real x) e)* real k \<noteq> 0)"
  3006 	using real_of_int_div[OF knz kdt]
  3006 	using real_of_int_div[OF knz kdt]
  3007 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3007 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3008 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti ring_simps)
  3008 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti algebra_simps)
  3009       also have "\<dots> = (?I ?tk (NEq (CN 0 c e)))" using nonzero_eq_divide_eq[OF knz', where a="real c * (?N (real x) t / real k) + ?N (real x) e" and b="0", symmetric] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3009       also have "\<dots> = (?I ?tk (NEq (CN 0 c e)))" using nonzero_eq_divide_eq[OF knz', where a="real c * (?N (real x) t / real k) + ?N (real x) e" and b="0", symmetric] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3010 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  3010 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  3011 	by (simp add: ti)
  3011 	by (simp add: ti)
  3012       finally have ?case . }
  3012       finally have ?case . }
  3013     ultimately show ?case by blast 
  3013     ultimately show ?case by blast 
  3025       from kpos have knz: "k\<noteq>0" by simp
  3025       from kpos have knz: "k\<noteq>0" by simp
  3026       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  3026       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  3027       from prems have "?I (real x) (?s (Lt (CN 0 c e))) = ((real c * (?N (real x) t / real k) + ?N (real x) e)* real k < 0)"
  3027       from prems have "?I (real x) (?s (Lt (CN 0 c e))) = ((real c * (?N (real x) t / real k) + ?N (real x) e)* real k < 0)"
  3028 	using real_of_int_div[OF knz kdt]
  3028 	using real_of_int_div[OF knz kdt]
  3029 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3029 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3030 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti ring_simps)
  3030 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti algebra_simps)
  3031       also have "\<dots> = (?I ?tk (Lt (CN 0 c e)))" using pos_less_divide_eq[OF kpos, where a="real c * (?N (real x) t / real k) + ?N (real x) e" and b="0", symmetric] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3031       also have "\<dots> = (?I ?tk (Lt (CN 0 c e)))" using pos_less_divide_eq[OF kpos, where a="real c * (?N (real x) t / real k) + ?N (real x) e" and b="0", symmetric] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3032 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  3032 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  3033 	by (simp add: ti)
  3033 	by (simp add: ti)
  3034       finally have ?case . }
  3034       finally have ?case . }
  3035     ultimately show ?case by blast 
  3035     ultimately show ?case by blast 
  3047       from kpos have knz: "k\<noteq>0" by simp
  3047       from kpos have knz: "k\<noteq>0" by simp
  3048       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  3048       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  3049       from prems have "?I (real x) (?s (Le (CN 0 c e))) = ((real c * (?N (real x) t / real k) + ?N (real x) e)* real k \<le> 0)"
  3049       from prems have "?I (real x) (?s (Le (CN 0 c e))) = ((real c * (?N (real x) t / real k) + ?N (real x) e)* real k \<le> 0)"
  3050 	using real_of_int_div[OF knz kdt]
  3050 	using real_of_int_div[OF knz kdt]
  3051 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3051 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3052 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti ring_simps)
  3052 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti algebra_simps)
  3053       also have "\<dots> = (?I ?tk (Le (CN 0 c e)))" using pos_le_divide_eq[OF kpos, where a="real c * (?N (real x) t / real k) + ?N (real x) e" and b="0", symmetric] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3053       also have "\<dots> = (?I ?tk (Le (CN 0 c e)))" using pos_le_divide_eq[OF kpos, where a="real c * (?N (real x) t / real k) + ?N (real x) e" and b="0", symmetric] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3054 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  3054 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  3055 	by (simp add: ti)
  3055 	by (simp add: ti)
  3056       finally have ?case . }
  3056       finally have ?case . }
  3057     ultimately show ?case by blast 
  3057     ultimately show ?case by blast 
  3069       from kpos have knz: "k\<noteq>0" by simp
  3069       from kpos have knz: "k\<noteq>0" by simp
  3070       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  3070       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  3071       from prems have "?I (real x) (?s (Gt (CN 0 c e))) = ((real c * (?N (real x) t / real k) + ?N (real x) e)* real k > 0)"
  3071       from prems have "?I (real x) (?s (Gt (CN 0 c e))) = ((real c * (?N (real x) t / real k) + ?N (real x) e)* real k > 0)"
  3072 	using real_of_int_div[OF knz kdt]
  3072 	using real_of_int_div[OF knz kdt]
  3073 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3073 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3074 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti ring_simps)
  3074 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti algebra_simps)
  3075       also have "\<dots> = (?I ?tk (Gt (CN 0 c e)))" using pos_divide_less_eq[OF kpos, where a="real c * (?N (real x) t / real k) + ?N (real x) e" and b="0", symmetric] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3075       also have "\<dots> = (?I ?tk (Gt (CN 0 c e)))" using pos_divide_less_eq[OF kpos, where a="real c * (?N (real x) t / real k) + ?N (real x) e" and b="0", symmetric] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3076 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  3076 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  3077 	by (simp add: ti)
  3077 	by (simp add: ti)
  3078       finally have ?case . }
  3078       finally have ?case . }
  3079     ultimately show ?case by blast 
  3079     ultimately show ?case by blast 
  3091       from kpos have knz: "k\<noteq>0" by simp
  3091       from kpos have knz: "k\<noteq>0" by simp
  3092       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  3092       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  3093       from prems have "?I (real x) (?s (Ge (CN 0 c e))) = ((real c * (?N (real x) t / real k) + ?N (real x) e)* real k \<ge> 0)"
  3093       from prems have "?I (real x) (?s (Ge (CN 0 c e))) = ((real c * (?N (real x) t / real k) + ?N (real x) e)* real k \<ge> 0)"
  3094 	using real_of_int_div[OF knz kdt]
  3094 	using real_of_int_div[OF knz kdt]
  3095 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3095 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3096 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti ring_simps)
  3096 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti algebra_simps)
  3097       also have "\<dots> = (?I ?tk (Ge (CN 0 c e)))" using pos_divide_le_eq[OF kpos, where a="real c * (?N (real x) t / real k) + ?N (real x) e" and b="0", symmetric] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3097       also have "\<dots> = (?I ?tk (Ge (CN 0 c e)))" using pos_divide_le_eq[OF kpos, where a="real c * (?N (real x) t / real k) + ?N (real x) e" and b="0", symmetric] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3098 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  3098 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  3099 	by (simp add: ti)
  3099 	by (simp add: ti)
  3100       finally have ?case . }
  3100       finally have ?case . }
  3101     ultimately show ?case by blast 
  3101     ultimately show ?case by blast 
  3112       from kpos have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3112       from kpos have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3113       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  3113       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  3114       from prems have "?I (real x) (?s (Dvd i (CN 0 c e))) = (real i * real k rdvd (real c * (?N (real x) t / real k) + ?N (real x) e)* real k)"
  3114       from prems have "?I (real x) (?s (Dvd i (CN 0 c e))) = (real i * real k rdvd (real c * (?N (real x) t / real k) + ?N (real x) e)* real k)"
  3115 	using real_of_int_div[OF knz kdt]
  3115 	using real_of_int_div[OF knz kdt]
  3116 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3116 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3117 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti ring_simps)
  3117 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti algebra_simps)
  3118       also have "\<dots> = (?I ?tk (Dvd i (CN 0 c e)))" using rdvd_mult[OF knz, where n="i"] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3118       also have "\<dots> = (?I ?tk (Dvd i (CN 0 c e)))" using rdvd_mult[OF knz, where n="i"] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3119 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  3119 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  3120 	by (simp add: ti)
  3120 	by (simp add: ti)
  3121       finally have ?case . }
  3121       finally have ?case . }
  3122     ultimately show ?case by blast 
  3122     ultimately show ?case by blast 
  3133       from kpos have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3133       from kpos have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3134       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  3134       from tint have ti: "real (floor (?N (real x) t)) = ?N (real x) t" using isint_def by simp
  3135       from prems have "?I (real x) (?s (NDvd i (CN 0 c e))) = (\<not> (real i * real k rdvd (real c * (?N (real x) t / real k) + ?N (real x) e)* real k))"
  3135       from prems have "?I (real x) (?s (NDvd i (CN 0 c e))) = (\<not> (real i * real k rdvd (real c * (?N (real x) t / real k) + ?N (real x) e)* real k))"
  3136 	using real_of_int_div[OF knz kdt]
  3136 	using real_of_int_div[OF knz kdt]
  3137 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3137 	  numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3138 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti ring_simps)
  3138 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"] by (simp add: ti algebra_simps)
  3139       also have "\<dots> = (?I ?tk (NDvd i (CN 0 c e)))" using rdvd_mult[OF knz, where n="i"] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3139       also have "\<dots> = (?I ?tk (NDvd i (CN 0 c e)))" using rdvd_mult[OF knz, where n="i"] real_of_int_div[OF knz kdt] numbound0_I[OF tnb, where bs="bs" and b="b'" and b'="real x"]
  3140 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  3140 	  numbound0_I[OF nb, where bs="bs" and b="?tk" and b'="real x"]
  3141 	by (simp add: ti)
  3141 	by (simp add: ti)
  3142       finally have ?case . }
  3142       finally have ?case . }
  3143     ultimately show ?case by blast 
  3143     ultimately show ?case by blast 
  3152   case (3 c e)  
  3152   case (3 c e)  
  3153   from prems have cp: "c > 0" and nb: "numbound0 e" by auto
  3153   from prems have cp: "c > 0" and nb: "numbound0 e" by auto
  3154   from kp have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3154   from kp have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3155     {assume kdc: "k dvd c" from prems have  ?case using real_of_int_div[OF knz kdc] by simp } 
  3155     {assume kdc: "k dvd c" from prems have  ?case using real_of_int_div[OF knz kdc] by simp } 
  3156     moreover 
  3156     moreover 
  3157     {assume nkdc: "\<not> k dvd c" hence ?case using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] nonzero_eq_divide_eq[OF knz', where b="0" and a="real c * real x + Inum (real x # bs) e", symmetric] by (simp add: ring_simps)}
  3157     {assume nkdc: "\<not> k dvd c" hence ?case using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] nonzero_eq_divide_eq[OF knz', where b="0" and a="real c * real x + Inum (real x # bs) e", symmetric] by (simp add: algebra_simps)}
  3158     ultimately show ?case by blast 
  3158     ultimately show ?case by blast 
  3159 next
  3159 next
  3160   case (4 c e)   
  3160   case (4 c e)   
  3161   from prems have cp: "c > 0" and nb: "numbound0 e" by auto
  3161   from prems have cp: "c > 0" and nb: "numbound0 e" by auto
  3162   from kp have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3162   from kp have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3163     {assume kdc: "k dvd c" from prems have  ?case using real_of_int_div[OF knz kdc] by simp } 
  3163     {assume kdc: "k dvd c" from prems have  ?case using real_of_int_div[OF knz kdc] by simp } 
  3164     moreover 
  3164     moreover 
  3165     {assume nkdc: "\<not> k dvd c" hence ?case using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] nonzero_eq_divide_eq[OF knz', where b="0" and a="real c * real x + Inum (real x # bs) e", symmetric] by (simp add: ring_simps)}
  3165     {assume nkdc: "\<not> k dvd c" hence ?case using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] nonzero_eq_divide_eq[OF knz', where b="0" and a="real c * real x + Inum (real x # bs) e", symmetric] by (simp add: algebra_simps)}
  3166     ultimately show ?case by blast 
  3166     ultimately show ?case by blast 
  3167 next
  3167 next
  3168   case (5 c e)   
  3168   case (5 c e)   
  3169   from prems have cp: "c > 0" and nb: "numbound0 e" by auto
  3169   from prems have cp: "c > 0" and nb: "numbound0 e" by auto
  3170   from kp have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3170   from kp have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3171     {assume kdc: "k dvd c" from prems have  ?case using real_of_int_div[OF knz kdc] by simp } 
  3171     {assume kdc: "k dvd c" from prems have  ?case using real_of_int_div[OF knz kdc] by simp } 
  3172     moreover 
  3172     moreover 
  3173     {assume nkdc: "\<not> k dvd c" hence ?case using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] pos_less_divide_eq[OF kp, where b="0" and a="real c * real x + Inum (real x # bs) e", symmetric] by (simp add: ring_simps)}
  3173     {assume nkdc: "\<not> k dvd c" hence ?case using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] pos_less_divide_eq[OF kp, where b="0" and a="real c * real x + Inum (real x # bs) e", symmetric] by (simp add: algebra_simps)}
  3174     ultimately show ?case by blast 
  3174     ultimately show ?case by blast 
  3175 next
  3175 next
  3176   case (6 c e)    
  3176   case (6 c e)    
  3177   from prems have cp: "c > 0" and nb: "numbound0 e" by auto
  3177   from prems have cp: "c > 0" and nb: "numbound0 e" by auto
  3178   from kp have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3178   from kp have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3179     {assume kdc: "k dvd c" from prems have  ?case using real_of_int_div[OF knz kdc] by simp } 
  3179     {assume kdc: "k dvd c" from prems have  ?case using real_of_int_div[OF knz kdc] by simp } 
  3180     moreover 
  3180     moreover 
  3181     {assume nkdc: "\<not> k dvd c" hence ?case using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] pos_le_divide_eq[OF kp, where b="0" and a="real c * real x + Inum (real x # bs) e", symmetric] by (simp add: ring_simps)}
  3181     {assume nkdc: "\<not> k dvd c" hence ?case using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] pos_le_divide_eq[OF kp, where b="0" and a="real c * real x + Inum (real x # bs) e", symmetric] by (simp add: algebra_simps)}
  3182     ultimately show ?case by blast 
  3182     ultimately show ?case by blast 
  3183 next
  3183 next
  3184   case (7 c e)    
  3184   case (7 c e)    
  3185   from prems have cp: "c > 0" and nb: "numbound0 e" by auto
  3185   from prems have cp: "c > 0" and nb: "numbound0 e" by auto
  3186   from kp have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3186   from kp have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3187     {assume kdc: "k dvd c" from prems have  ?case using real_of_int_div[OF knz kdc] by simp } 
  3187     {assume kdc: "k dvd c" from prems have  ?case using real_of_int_div[OF knz kdc] by simp } 
  3188     moreover 
  3188     moreover 
  3189     {assume nkdc: "\<not> k dvd c" hence ?case using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] pos_divide_less_eq[OF kp, where b="0" and a="real c * real x + Inum (real x # bs) e", symmetric] by (simp add: ring_simps)}
  3189     {assume nkdc: "\<not> k dvd c" hence ?case using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] pos_divide_less_eq[OF kp, where b="0" and a="real c * real x + Inum (real x # bs) e", symmetric] by (simp add: algebra_simps)}
  3190     ultimately show ?case by blast 
  3190     ultimately show ?case by blast 
  3191 next
  3191 next
  3192   case (8 c e)    
  3192   case (8 c e)    
  3193   from prems have cp: "c > 0" and nb: "numbound0 e" by auto
  3193   from prems have cp: "c > 0" and nb: "numbound0 e" by auto
  3194   from kp have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3194   from kp have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3195     {assume kdc: "k dvd c" from prems have  ?case using real_of_int_div[OF knz kdc] by simp } 
  3195     {assume kdc: "k dvd c" from prems have  ?case using real_of_int_div[OF knz kdc] by simp } 
  3196     moreover 
  3196     moreover 
  3197     {assume nkdc: "\<not> k dvd c" hence ?case using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] pos_divide_le_eq[OF kp, where b="0" and a="real c * real x + Inum (real x # bs) e", symmetric] by (simp add: ring_simps)}
  3197     {assume nkdc: "\<not> k dvd c" hence ?case using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] pos_divide_le_eq[OF kp, where b="0" and a="real c * real x + Inum (real x # bs) e", symmetric] by (simp add: algebra_simps)}
  3198     ultimately show ?case by blast 
  3198     ultimately show ?case by blast 
  3199 next
  3199 next
  3200   case (9 i c e)
  3200   case (9 i c e)
  3201   from prems have cp: "c > 0" and nb: "numbound0 e" by auto
  3201   from prems have cp: "c > 0" and nb: "numbound0 e" by auto
  3202   from kp have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3202   from kp have knz: "k\<noteq>0" by simp hence knz': "real k \<noteq> 0" by simp
  3204   moreover 
  3204   moreover 
  3205   {assume "\<not> k dvd c"
  3205   {assume "\<not> k dvd c"
  3206     hence "Ifm (real (x*k)#bs) (a\<rho> (Dvd i (CN 0 c e)) k) = 
  3206     hence "Ifm (real (x*k)#bs) (a\<rho> (Dvd i (CN 0 c e)) k) = 
  3207       (real i * real k rdvd (real c * real x + Inum (real x#bs) e) * real k)" 
  3207       (real i * real k rdvd (real c * real x + Inum (real x#bs) e) * real k)" 
  3208       using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] 
  3208       using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] 
  3209       by (simp add: ring_simps)
  3209       by (simp add: algebra_simps)
  3210     also have "\<dots> = (Ifm (real x#bs) (Dvd i (CN 0 c e)))" by (simp add: rdvd_mult[OF knz, where n="i"])
  3210     also have "\<dots> = (Ifm (real x#bs) (Dvd i (CN 0 c e)))" by (simp add: rdvd_mult[OF knz, where n="i"])
  3211     finally have ?case . }
  3211     finally have ?case . }
  3212   ultimately show ?case by blast 
  3212   ultimately show ?case by blast 
  3213 next
  3213 next
  3214   case (10 i c e) 
  3214   case (10 i c e) 
  3218   moreover 
  3218   moreover 
  3219   {assume "\<not> k dvd c"
  3219   {assume "\<not> k dvd c"
  3220     hence "Ifm (real (x*k)#bs) (a\<rho> (NDvd i (CN 0 c e)) k) = 
  3220     hence "Ifm (real (x*k)#bs) (a\<rho> (NDvd i (CN 0 c e)) k) = 
  3221       (\<not> (real i * real k rdvd (real c * real x + Inum (real x#bs) e) * real k))" 
  3221       (\<not> (real i * real k rdvd (real c * real x + Inum (real x#bs) e) * real k))" 
  3222       using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] 
  3222       using numbound0_I[OF nb, where bs="bs" and b="real (x*k)" and b'="real x"] 
  3223       by (simp add: ring_simps)
  3223       by (simp add: algebra_simps)
  3224     also have "\<dots> = (Ifm (real x#bs) (NDvd i (CN 0 c e)))" by (simp add: rdvd_mult[OF knz, where n="i"])
  3224     also have "\<dots> = (Ifm (real x#bs) (NDvd i (CN 0 c e)))" by (simp add: rdvd_mult[OF knz, where n="i"])
  3225     finally have ?case . }
  3225     finally have ?case . }
  3226   ultimately show ?case by blast 
  3226   ultimately show ?case by blast 
  3227 qed (simp_all add: nth_pos2)
  3227 qed (simp_all add: nth_pos2)
  3228 
  3228 
  3231   shows "(\<exists> (x::int). real k rdvd real x \<and> Ifm (real x#bs) (a\<rho> p k)) = 
  3231   shows "(\<exists> (x::int). real k rdvd real x \<and> Ifm (real x#bs) (a\<rho> p k)) = 
  3232   (\<exists> (x::int). Ifm (real x#bs) p)" (is "(\<exists> x. ?D x \<and> ?P' x) = (\<exists> x. ?P x)")
  3232   (\<exists> (x::int). Ifm (real x#bs) p)" (is "(\<exists> x. ?D x \<and> ?P' x) = (\<exists> x. ?P x)")
  3233 proof-
  3233 proof-
  3234   have "(\<exists> x. ?D x \<and> ?P' x) = (\<exists> x. k dvd x \<and> ?P' x)" using int_rdvd_iff by simp
  3234   have "(\<exists> x. ?D x \<and> ?P' x) = (\<exists> x. k dvd x \<and> ?P' x)" using int_rdvd_iff by simp
  3235   also have "\<dots> = (\<exists>x. ?P' (x*k))" using unity_coeff_ex[where P="?P'" and l="k", simplified]
  3235   also have "\<dots> = (\<exists>x. ?P' (x*k))" using unity_coeff_ex[where P="?P'" and l="k", simplified]
  3236     by (simp add: ring_simps)
  3236     by (simp add: algebra_simps)
  3237   also have "\<dots> = (\<exists> x. ?P x)" using a\<rho> iszlfm_gen[OF lp] kp by auto
  3237   also have "\<dots> = (\<exists> x. ?P x)" using a\<rho> iszlfm_gen[OF lp] kp by auto
  3238   finally show ?thesis .
  3238   finally show ?thesis .
  3239 qed
  3239 qed
  3240 
  3240 
  3241 lemma \<sigma>\<rho>': assumes lp: "iszlfm p (real (x::int)#bs)" and kp: "k > 0" and nb: "numbound0 t"
  3241 lemma \<sigma>\<rho>': assumes lp: "iszlfm p (real (x::int)#bs)" and kp: "k > 0" and nb: "numbound0 t"
  3295   hence cp: "c >0" and nb: "numbound0 e" and ei: "isint e (real i#bs)"
  3295   hence cp: "c >0" and nb: "numbound0 e" and ei: "isint e (real i#bs)"
  3296     and nob: "\<forall> j\<in> {1 .. c*d}. real (c*i) \<noteq> - ?N i e + real j"
  3296     and nob: "\<forall> j\<in> {1 .. c*d}. real (c*i) \<noteq> - ?N i e + real j"
  3297     by simp+
  3297     by simp+
  3298   {assume "real (c*i) \<noteq> - ?N i e + real (c*d)"
  3298   {assume "real (c*i) \<noteq> - ?N i e + real (c*d)"
  3299     with numbound0_I[OF nb, where bs="bs" and b="real i - real d" and b'="real i"]
  3299     with numbound0_I[OF nb, where bs="bs" and b="real i - real d" and b'="real i"]
  3300     have ?case by (simp add: ring_simps)}
  3300     have ?case by (simp add: algebra_simps)}
  3301   moreover
  3301   moreover
  3302   {assume pi: "real (c*i) = - ?N i e + real (c*d)"
  3302   {assume pi: "real (c*i) = - ?N i e + real (c*d)"
  3303     from mult_strict_left_mono[OF dp cp] have d: "(c*d) \<in> {1 .. c*d}" by simp
  3303     from mult_strict_left_mono[OF dp cp] have d: "(c*d) \<in> {1 .. c*d}" by simp
  3304     from nob[rule_format, where j="c*d", OF d] pi have ?case by simp }
  3304     from nob[rule_format, where j="c*d", OF d] pi have ?case by simp }
  3305   ultimately show ?case by blast
  3305   ultimately show ?case by blast
  3307   case (5 c e) hence cp: "c > 0" by simp
  3307   case (5 c e) hence cp: "c > 0" by simp
  3308   from prems mult_strict_left_mono[OF dp cp, simplified real_of_int_less_iff[symmetric] 
  3308   from prems mult_strict_left_mono[OF dp cp, simplified real_of_int_less_iff[symmetric] 
  3309     real_of_int_mult]
  3309     real_of_int_mult]
  3310   show ?case using prems dp 
  3310   show ?case using prems dp 
  3311     by (simp add: add: numbound0_I[where bs="bs" and b="real i - real d" and b'="real i"] 
  3311     by (simp add: add: numbound0_I[where bs="bs" and b="real i - real d" and b'="real i"] 
  3312       ring_simps)
  3312       algebra_simps)
  3313 next
  3313 next
  3314   case (6 c e)  hence cp: "c > 0" by simp
  3314   case (6 c e)  hence cp: "c > 0" by simp
  3315   from prems mult_strict_left_mono[OF dp cp, simplified real_of_int_less_iff[symmetric] 
  3315   from prems mult_strict_left_mono[OF dp cp, simplified real_of_int_less_iff[symmetric] 
  3316     real_of_int_mult]
  3316     real_of_int_mult]
  3317   show ?case using prems dp 
  3317   show ?case using prems dp 
  3318     by (simp add: add: numbound0_I[where bs="bs" and b="real i - real d" and b'="real i"] 
  3318     by (simp add: add: numbound0_I[where bs="bs" and b="real i - real d" and b'="real i"] 
  3319       ring_simps)
  3319       algebra_simps)
  3320 next
  3320 next
  3321   case (7 c e) hence cp: "c >0" and nb: "numbound0 e" and ei: "isint e (real i#bs)"
  3321   case (7 c e) hence cp: "c >0" and nb: "numbound0 e" and ei: "isint e (real i#bs)"
  3322     and nob: "\<forall> j\<in> {1 .. c*d}. real (c*i) \<noteq> - ?N i e + real j"
  3322     and nob: "\<forall> j\<in> {1 .. c*d}. real (c*i) \<noteq> - ?N i e + real j"
  3323     and pi: "real (c*i) + ?N i e > 0" and cp': "real c >0"
  3323     and pi: "real (c*i) + ?N i e > 0" and cp': "real c >0"
  3324     by simp+
  3324     by simp+
  3325   let ?fe = "floor (?N i e)"
  3325   let ?fe = "floor (?N i e)"
  3326   from pi cp have th:"(real i +?N i e / real c)*real c > 0" by (simp add: ring_simps)
  3326   from pi cp have th:"(real i +?N i e / real c)*real c > 0" by (simp add: algebra_simps)
  3327   from pi ei[simplified isint_iff] have "real (c*i + ?fe) > real (0::int)" by simp
  3327   from pi ei[simplified isint_iff] have "real (c*i + ?fe) > real (0::int)" by simp
  3328   hence pi': "c*i + ?fe > 0" by (simp only: real_of_int_less_iff[symmetric])
  3328   hence pi': "c*i + ?fe > 0" by (simp only: real_of_int_less_iff[symmetric])
  3329   have "real (c*i) + ?N i e > real (c*d) \<or> real (c*i) + ?N i e \<le> real (c*d)" by auto
  3329   have "real (c*i) + ?N i e > real (c*d) \<or> real (c*i) + ?N i e \<le> real (c*d)" by auto
  3330   moreover
  3330   moreover
  3331   {assume "real (c*i) + ?N i e > real (c*d)" hence ?case
  3331   {assume "real (c*i) + ?N i e > real (c*d)" hence ?case
  3332       by (simp add: ring_simps 
  3332       by (simp add: algebra_simps 
  3333 	numbound0_I[OF nb,where bs="bs" and b="real i - real d" and b'="real i"])} 
  3333 	numbound0_I[OF nb,where bs="bs" and b="real i - real d" and b'="real i"])} 
  3334   moreover 
  3334   moreover 
  3335   {assume H:"real (c*i) + ?N i e \<le> real (c*d)"
  3335   {assume H:"real (c*i) + ?N i e \<le> real (c*d)"
  3336     with ei[simplified isint_iff] have "real (c*i + ?fe) \<le> real (c*d)" by simp
  3336     with ei[simplified isint_iff] have "real (c*i + ?fe) \<le> real (c*d)" by simp
  3337     hence pid: "c*i + ?fe \<le> c*d" by (simp only: real_of_int_le_iff)
  3337     hence pid: "c*i + ?fe \<le> c*d" by (simp only: real_of_int_le_iff)
  3338     with pi' have "\<exists> j1\<in> {1 .. c*d}. c*i + ?fe = j1" by auto
  3338     with pi' have "\<exists> j1\<in> {1 .. c*d}. c*i + ?fe = j1" by auto
  3339     hence "\<exists> j1\<in> {1 .. c*d}. real (c*i) = - ?N i e + real j1" 
  3339     hence "\<exists> j1\<in> {1 .. c*d}. real (c*i) = - ?N i e + real j1" 
  3340       by (simp only: diff_def[symmetric] real_of_int_mult real_of_int_add real_of_int_inject[symmetric] ei[simplified isint_iff] ring_simps)
  3340       by (simp only: diff_def[symmetric] real_of_int_mult real_of_int_add real_of_int_inject[symmetric] ei[simplified isint_iff] algebra_simps)
  3341     with nob  have ?case by blast }
  3341     with nob  have ?case by blast }
  3342   ultimately show ?case by blast
  3342   ultimately show ?case by blast
  3343 next
  3343 next
  3344   case (8 c e)  hence cp: "c >0" and nb: "numbound0 e" and ei: "isint e (real i#bs)"
  3344   case (8 c e)  hence cp: "c >0" and nb: "numbound0 e" and ei: "isint e (real i#bs)"
  3345     and nob: "\<forall> j\<in> {1 .. c*d}. real (c*i) \<noteq> - 1 - ?N i e + real j"
  3345     and nob: "\<forall> j\<in> {1 .. c*d}. real (c*i) \<noteq> - 1 - ?N i e + real j"
  3346     and pi: "real (c*i) + ?N i e \<ge> 0" and cp': "real c >0"
  3346     and pi: "real (c*i) + ?N i e \<ge> 0" and cp': "real c >0"
  3347     by simp+
  3347     by simp+
  3348   let ?fe = "floor (?N i e)"
  3348   let ?fe = "floor (?N i e)"
  3349   from pi cp have th:"(real i +?N i e / real c)*real c \<ge> 0" by (simp add: ring_simps)
  3349   from pi cp have th:"(real i +?N i e / real c)*real c \<ge> 0" by (simp add: algebra_simps)
  3350   from pi ei[simplified isint_iff] have "real (c*i + ?fe) \<ge> real (0::int)" by simp
  3350   from pi ei[simplified isint_iff] have "real (c*i + ?fe) \<ge> real (0::int)" by simp
  3351   hence pi': "c*i + 1 + ?fe \<ge> 1" by (simp only: real_of_int_le_iff[symmetric])
  3351   hence pi': "c*i + 1 + ?fe \<ge> 1" by (simp only: real_of_int_le_iff[symmetric])
  3352   have "real (c*i) + ?N i e \<ge> real (c*d) \<or> real (c*i) + ?N i e < real (c*d)" by auto
  3352   have "real (c*i) + ?N i e \<ge> real (c*d) \<or> real (c*i) + ?N i e < real (c*d)" by auto
  3353   moreover
  3353   moreover
  3354   {assume "real (c*i) + ?N i e \<ge> real (c*d)" hence ?case
  3354   {assume "real (c*i) + ?N i e \<ge> real (c*d)" hence ?case
  3355       by (simp add: ring_simps 
  3355       by (simp add: algebra_simps 
  3356 	numbound0_I[OF nb,where bs="bs" and b="real i - real d" and b'="real i"])} 
  3356 	numbound0_I[OF nb,where bs="bs" and b="real i - real d" and b'="real i"])} 
  3357   moreover 
  3357   moreover 
  3358   {assume H:"real (c*i) + ?N i e < real (c*d)"
  3358   {assume H:"real (c*i) + ?N i e < real (c*d)"
  3359     with ei[simplified isint_iff] have "real (c*i + ?fe) < real (c*d)" by simp
  3359     with ei[simplified isint_iff] have "real (c*i + ?fe) < real (c*d)" by simp
  3360     hence pid: "c*i + 1 + ?fe \<le> c*d" by (simp only: real_of_int_le_iff)
  3360     hence pid: "c*i + 1 + ?fe \<le> c*d" by (simp only: real_of_int_le_iff)
  3361     with pi' have "\<exists> j1\<in> {1 .. c*d}. c*i + 1+ ?fe = j1" by auto
  3361     with pi' have "\<exists> j1\<in> {1 .. c*d}. c*i + 1+ ?fe = j1" by auto
  3362     hence "\<exists> j1\<in> {1 .. c*d}. real (c*i) + 1= - ?N i e + real j1"
  3362     hence "\<exists> j1\<in> {1 .. c*d}. real (c*i) + 1= - ?N i e + real j1"
  3363       by (simp only: diff_def[symmetric] real_of_int_mult real_of_int_add real_of_int_inject[symmetric] ei[simplified isint_iff] ring_simps real_of_one) 
  3363       by (simp only: diff_def[symmetric] real_of_int_mult real_of_int_add real_of_int_inject[symmetric] ei[simplified isint_iff] algebra_simps real_of_one) 
  3364     hence "\<exists> j1\<in> {1 .. c*d}. real (c*i) = (- ?N i e + real j1) - 1"
  3364     hence "\<exists> j1\<in> {1 .. c*d}. real (c*i) = (- ?N i e + real j1) - 1"
  3365       by (simp only: ring_simps diff_def[symmetric])
  3365       by (simp only: algebra_simps diff_def[symmetric])
  3366         hence "\<exists> j1\<in> {1 .. c*d}. real (c*i) = - 1 - ?N i e + real j1"
  3366         hence "\<exists> j1\<in> {1 .. c*d}. real (c*i) = - 1 - ?N i e + real j1"
  3367 	  by (simp only: add_ac diff_def)
  3367 	  by (simp only: add_ac diff_def)
  3368     with nob  have ?case by blast }
  3368     with nob  have ?case by blast }
  3369   ultimately show ?case by blast
  3369   ultimately show ?case by blast
  3370 next
  3370 next
  3381       using dvd_period[OF id, where x="c*i" and c="-c" and t="floor ?e"] by simp
  3381       using dvd_period[OF id, where x="c*i" and c="-c" and t="floor ?e"] by simp
  3382     also have "\<dots> = (real j rdvd real (c*i - c*d + floor ?e))" 
  3382     also have "\<dots> = (real j rdvd real (c*i - c*d + floor ?e))" 
  3383       using int_rdvd_iff[where i="j" and t="(c*i - c*d + floor ?e)",symmetric, simplified]
  3383       using int_rdvd_iff[where i="j" and t="(c*i - c*d + floor ?e)",symmetric, simplified]
  3384       ie by simp
  3384       ie by simp
  3385     also have "\<dots> = (real j rdvd real (c*(i - d)) + ?e)" 
  3385     also have "\<dots> = (real j rdvd real (c*(i - d)) + ?e)" 
  3386       using ie by (simp add:ring_simps)
  3386       using ie by (simp add:algebra_simps)
  3387     finally show ?case 
  3387     finally show ?case 
  3388       using numbound0_I[OF bn,where b="real i - real d" and b'="real i" and bs="bs"] p 
  3388       using numbound0_I[OF bn,where b="real i - real d" and b'="real i" and bs="bs"] p 
  3389       by (simp add: ring_simps)
  3389       by (simp add: algebra_simps)
  3390 next
  3390 next
  3391   case (10 j c e)   hence p: "\<not> (real j rdvd real (c*i) + ?N i e)" (is "?p x") and cp: "c > 0" and bn:"numbound0 e"  by simp+
  3391   case (10 j c e)   hence p: "\<not> (real j rdvd real (c*i) + ?N i e)" (is "?p x") and cp: "c > 0" and bn:"numbound0 e"  by simp+
  3392     let ?e = "Inum (real i # bs) e"
  3392     let ?e = "Inum (real i # bs) e"
  3393     from prems have "isint e (real i #bs)"  by simp 
  3393     from prems have "isint e (real i #bs)"  by simp 
  3394     hence ie: "real (floor ?e) = ?e" using isint_iff[where n="e" and bs="(real i)#bs"] numbound0_I[OF bn,where b="real i" and b'="real i" and bs="bs"]
  3394     hence ie: "real (floor ?e) = ?e" using isint_iff[where n="e" and bs="(real i)#bs"] numbound0_I[OF bn,where b="real i" and b'="real i" and bs="bs"]
  3401       using dvd_period[OF id, where x="c*i" and c="-c" and t="floor ?e"] by simp
  3401       using dvd_period[OF id, where x="c*i" and c="-c" and t="floor ?e"] by simp
  3402     also have "\<dots> = Not (real j rdvd real (c*i - c*d + floor ?e))" 
  3402     also have "\<dots> = Not (real j rdvd real (c*i - c*d + floor ?e))" 
  3403       using int_rdvd_iff[where i="j" and t="(c*i - c*d + floor ?e)",symmetric, simplified]
  3403       using int_rdvd_iff[where i="j" and t="(c*i - c*d + floor ?e)",symmetric, simplified]
  3404       ie by simp
  3404       ie by simp
  3405     also have "\<dots> = Not (real j rdvd real (c*(i - d)) + ?e)" 
  3405     also have "\<dots> = Not (real j rdvd real (c*(i - d)) + ?e)" 
  3406       using ie by (simp add:ring_simps)
  3406       using ie by (simp add:algebra_simps)
  3407     finally show ?case 
  3407     finally show ?case 
  3408       using numbound0_I[OF bn,where b="real i - real d" and b'="real i" and bs="bs"] p 
  3408       using numbound0_I[OF bn,where b="real i - real d" and b'="real i" and bs="bs"] p 
  3409       by (simp add: ring_simps)
  3409       by (simp add: algebra_simps)
  3410 qed(auto simp add: numbound0_I[where bs="bs" and b="real i - real d" and b'="real i"] nth_pos2)
  3410 qed(auto simp add: numbound0_I[where bs="bs" and b="real i - real d" and b'="real i"] nth_pos2)
  3411 
  3411 
  3412 lemma \<sigma>_nb: assumes lp: "iszlfm p (a#bs)" and nb: "numbound0 t"
  3412 lemma \<sigma>_nb: assumes lp: "iszlfm p (a#bs)" and nb: "numbound0 t"
  3413   shows "bound0 (\<sigma> p k t)"
  3413   shows "bound0 (\<sigma> p k t)"
  3414   using \<sigma>\<rho>_nb[OF lp nb] nb by (simp add: \<sigma>_def)
  3414   using \<sigma>\<rho>_nb[OF lp nb] nb by (simp add: \<sigma>_def)
  3647 	let ?nxs = "CN 0 n' s'"
  3647 	let ?nxs = "CN 0 n' s'"
  3648 	let ?l = "floor (?N s') + j"
  3648 	let ?l = "floor (?N s') + j"
  3649 	from H 
  3649 	from H 
  3650 	have "?I (?p (p',n',s') j) \<longrightarrow> 
  3650 	have "?I (?p (p',n',s') j) \<longrightarrow> 
  3651 	  (((?N ?nxs \<ge> real ?l) \<and> (?N ?nxs < real (?l + 1))) \<and> (?N a = ?N ?nxs ))" 
  3651 	  (((?N ?nxs \<ge> real ?l) \<and> (?N ?nxs < real (?l + 1))) \<and> (?N a = ?N ?nxs ))" 
  3652 	  by (simp add: fp_def np ring_simps numsub numadd numfloor)
  3652 	  by (simp add: fp_def np algebra_simps numsub numadd numfloor)
  3653 	also have "\<dots> \<longrightarrow> ((floor (?N ?nxs) = ?l) \<and> (?N a = ?N ?nxs ))"
  3653 	also have "\<dots> \<longrightarrow> ((floor (?N ?nxs) = ?l) \<and> (?N a = ?N ?nxs ))"
  3654 	  using floor_int_eq[where x="?N ?nxs" and n="?l"] by simp
  3654 	  using floor_int_eq[where x="?N ?nxs" and n="?l"] by simp
  3655 	moreover
  3655 	moreover
  3656 	have "\<dots> \<longrightarrow> (?N (Floor a) = ?N ((Add (Floor s') (C j))))" by simp
  3656 	have "\<dots> \<longrightarrow> (?N (Floor a) = ?N ((Add (Floor s') (C j))))" by simp
  3657 	ultimately have "?I (?p (p',n',s') j) \<longrightarrow> (?N (Floor a) = ?N ((Add (Floor s') (C j))))"
  3657 	ultimately have "?I (?p (p',n',s') j) \<longrightarrow> (?N (Floor a) = ?N ((Add (Floor s') (C j))))"
  3673 	let ?nxs = "CN 0 n' s'"
  3673 	let ?nxs = "CN 0 n' s'"
  3674 	let ?l = "floor (?N s') + j"
  3674 	let ?l = "floor (?N s') + j"
  3675 	from H 
  3675 	from H 
  3676 	have "?I (?p (p',n',s') j) \<longrightarrow> 
  3676 	have "?I (?p (p',n',s') j) \<longrightarrow> 
  3677 	  (((?N ?nxs \<ge> real ?l) \<and> (?N ?nxs < real (?l + 1))) \<and> (?N a = ?N ?nxs ))" 
  3677 	  (((?N ?nxs \<ge> real ?l) \<and> (?N ?nxs < real (?l + 1))) \<and> (?N a = ?N ?nxs ))" 
  3678 	  by (simp add: np fp_def ring_simps numneg numfloor numadd numsub)
  3678 	  by (simp add: np fp_def algebra_simps numneg numfloor numadd numsub)
  3679 	also have "\<dots> \<longrightarrow> ((floor (?N ?nxs) = ?l) \<and> (?N a = ?N ?nxs ))"
  3679 	also have "\<dots> \<longrightarrow> ((floor (?N ?nxs) = ?l) \<and> (?N a = ?N ?nxs ))"
  3680 	  using floor_int_eq[where x="?N ?nxs" and n="?l"] by simp
  3680 	  using floor_int_eq[where x="?N ?nxs" and n="?l"] by simp
  3681 	moreover
  3681 	moreover
  3682 	have "\<dots> \<longrightarrow> (?N (Floor a) = ?N ((Add (Floor s') (C j))))"  by simp
  3682 	have "\<dots> \<longrightarrow> (?N (Floor a) = ?N ((Add (Floor s') (C j))))"  by simp
  3683 	ultimately have "?I (?p (p',n',s') j) \<longrightarrow> (?N (Floor a) = ?N ((Add (Floor s') (C j))))"
  3683 	ultimately have "?I (?p (p',n',s') j) \<longrightarrow> (?N (Floor a) = ?N ((Add (Floor s') (C j))))"
  3689   case (3 a b) then show ?case
  3689   case (3 a b) then show ?case
  3690   apply auto
  3690   apply auto
  3691   apply (erule_tac x = "(aa, aaa, ba)" in ballE) apply simp_all
  3691   apply (erule_tac x = "(aa, aaa, ba)" in ballE) apply simp_all
  3692   apply (erule_tac x = "(ab, ac, baa)" in ballE) apply simp_all
  3692   apply (erule_tac x = "(ab, ac, baa)" in ballE) apply simp_all
  3693   done
  3693   done
  3694 qed (auto simp add: Let_def split_def ring_simps conj_rl)
  3694 qed (auto simp add: Let_def split_def algebra_simps conj_rl)
  3695 
  3695 
  3696 lemma real_in_int_intervals: 
  3696 lemma real_in_int_intervals: 
  3697   assumes xb: "real m \<le> x \<and> x < real ((n::int) + 1)"
  3697   assumes xb: "real m \<le> x \<and> x < real ((n::int) + 1)"
  3698   shows "\<exists> j\<in> {m.. n}. real j \<le> x \<and> x < real (j+1)" (is "\<exists> j\<in> ?N. ?P j")
  3698   shows "\<exists> j\<in> {m.. n}. real j \<le> x \<and> x < real (j+1)" (is "\<exists> j\<in> ?N. ?P j")
  3699 by (rule bexI[where P="?P" and x="floor x" and A="?N"]) 
  3699 by (rule bexI[where P="?P" and x="floor x" and A="?N"]) 
  3793     from real_in_int_intervals th have  "\<exists> j\<in> {0 .. n}. real j \<le> real n *x + ?N s - ?N (Floor s)\<and> real n *x + ?N s - ?N (Floor s) < real (j+1)" by simp
  3793     from real_in_int_intervals th have  "\<exists> j\<in> {0 .. n}. real j \<le> real n *x + ?N s - ?N (Floor s)\<and> real n *x + ?N s - ?N (Floor s) < real (j+1)" by simp
  3794     
  3794     
  3795     hence "\<exists> j\<in> {0 .. n}. 0 \<le> real n *x + ?N s - ?N (Floor s) - real j \<and> real n *x + ?N s - ?N (Floor s) - real (j+1) < 0"
  3795     hence "\<exists> j\<in> {0 .. n}. 0 \<le> real n *x + ?N s - ?N (Floor s) - real j \<and> real n *x + ?N s - ?N (Floor s) - real (j+1) < 0"
  3796       by(simp only: myl[rule_format, where b="real n * x + Inum (x # bs) s - Inum (x # bs) (Floor s)"] less_iff_diff_less_0[where a="real n *x + ?N s - ?N (Floor s)"]) 
  3796       by(simp only: myl[rule_format, where b="real n * x + Inum (x # bs) s - Inum (x # bs) (Floor s)"] less_iff_diff_less_0[where a="real n *x + ?N s - ?N (Floor s)"]) 
  3797     hence "\<exists> j\<in> {0.. n}. ?I (?p (p,n,s) j)"
  3797     hence "\<exists> j\<in> {0.. n}. ?I (?p (p,n,s) j)"
  3798       using pns by (simp add: fp_def np ring_simps numsub numadd)
  3798       using pns by (simp add: fp_def np algebra_simps numsub numadd)
  3799     then obtain "j" where j_def: "j\<in> {0 .. n} \<and> ?I (?p (p,n,s) j)" by blast
  3799     then obtain "j" where j_def: "j\<in> {0 .. n} \<and> ?I (?p (p,n,s) j)" by blast
  3800     hence "\<exists>x \<in> {?p (p,n,s) j |j. 0\<le> j \<and> j \<le> n }. ?I x" by auto
  3800     hence "\<exists>x \<in> {?p (p,n,s) j |j. 0\<le> j \<and> j \<le> n }. ?I x" by auto
  3801     hence ?case using pns 
  3801     hence ?case using pns 
  3802       by (simp only: FS,simp add: bex_Un) 
  3802       by (simp only: FS,simp add: bex_Un) 
  3803     (rule disjI2, rule disjI1,rule exI [where x="p"],
  3803     (rule disjI2, rule disjI1,rule exI [where x="p"],
  3811     moreover
  3811     moreover
  3812     {from mult_strict_left_mono_neg[OF x1, where c="real n"] nn
  3812     {from mult_strict_left_mono_neg[OF x1, where c="real n"] nn
  3813       have "real n *x + ?N s \<ge> real n + ?N s" by simp 
  3813       have "real n *x + ?N s \<ge> real n + ?N s" by simp 
  3814       moreover from real_of_int_floor_le[where r="?N s"]  have "real n + ?N s \<ge> real n + ?N (Floor s)" by simp
  3814       moreover from real_of_int_floor_le[where r="?N s"]  have "real n + ?N s \<ge> real n + ?N (Floor s)" by simp
  3815       ultimately have "real n *x + ?N s \<ge> ?N (Floor s) + real n" 
  3815       ultimately have "real n *x + ?N s \<ge> ?N (Floor s) + real n" 
  3816 	by (simp only: ring_simps)}
  3816 	by (simp only: algebra_simps)}
  3817     ultimately have "?N (Floor s) + real n \<le> real n *x + ?N s\<and> real n *x + ?N s < ?N (Floor s) + real (1::int)" by simp
  3817     ultimately have "?N (Floor s) + real n \<le> real n *x + ?N s\<and> real n *x + ?N s < ?N (Floor s) + real (1::int)" by simp
  3818     hence th: "real n \<le> real n *x + ?N s - ?N (Floor s) \<and> real n *x + ?N s - ?N (Floor s) < real (1::int)" by simp
  3818     hence th: "real n \<le> real n *x + ?N s - ?N (Floor s) \<and> real n *x + ?N s - ?N (Floor s) < real (1::int)" by simp
  3819     have th1: "\<forall> (a::real). (- a > 0) = (a < 0)" by auto
  3819     have th1: "\<forall> (a::real). (- a > 0) = (a < 0)" by auto
  3820     have th2: "\<forall> (a::real). (0 \<ge> - a) = (a \<ge> 0)" by auto
  3820     have th2: "\<forall> (a::real). (0 \<ge> - a) = (a \<ge> 0)" by auto
  3821     from real_in_int_intervals th  have  "\<exists> j\<in> {n .. 0}. real j \<le> real n *x + ?N s - ?N (Floor s)\<and> real n *x + ?N s - ?N (Floor s) < real (j+1)" by simp
  3821     from real_in_int_intervals th  have  "\<exists> j\<in> {n .. 0}. real j \<le> real n *x + ?N s - ?N (Floor s)\<and> real n *x + ?N s - ?N (Floor s) < real (j+1)" by simp
  3917   (is "\<forall> a n s . ?N a = ?N (CN 0 n s) \<and> _\<longrightarrow> ?I (lt n s) = ?I (Lt a)")
  3917   (is "\<forall> a n s . ?N a = ?N (CN 0 n s) \<and> _\<longrightarrow> ?I (lt n s) = ?I (Lt a)")
  3918 proof(clarify)
  3918 proof(clarify)
  3919   fix a n s
  3919   fix a n s
  3920   assume H: "?N a = ?N (CN 0 n s)"
  3920   assume H: "?N a = ?N (CN 0 n s)"
  3921   show "?I (lt n s) = ?I (Lt a)" using H by (cases "n=0", (simp add: lt_def))
  3921   show "?I (lt n s) = ?I (Lt a)" using H by (cases "n=0", (simp add: lt_def))
  3922   (cases "n > 0", simp_all add: lt_def ring_simps myless[rule_format, where b="0"])
  3922   (cases "n > 0", simp_all add: lt_def algebra_simps myless[rule_format, where b="0"])
  3923 qed
  3923 qed
  3924 
  3924 
  3925 lemma lt_l: "isrlfm (rsplit lt a)"
  3925 lemma lt_l: "isrlfm (rsplit lt a)"
  3926   by (rule rsplit_l[where f="lt" and a="a"], auto simp add: lt_def,
  3926   by (rule rsplit_l[where f="lt" and a="a"], auto simp add: lt_def,
  3927     case_tac s, simp_all, case_tac "nat", simp_all)
  3927     case_tac s, simp_all, case_tac "nat", simp_all)
  3929 lemma le_mono: "\<forall> a n s. Inum (x#bs) a = Inum (x#bs) (CN 0 n s) \<and> numbound0 s \<longrightarrow> Ifm (x#bs) (le n s) = Ifm (x#bs) (Le a)" (is "\<forall> a n s. ?N a = ?N (CN 0 n s) \<and> _ \<longrightarrow> ?I (le n s) = ?I (Le a)")
  3929 lemma le_mono: "\<forall> a n s. Inum (x#bs) a = Inum (x#bs) (CN 0 n s) \<and> numbound0 s \<longrightarrow> Ifm (x#bs) (le n s) = Ifm (x#bs) (Le a)" (is "\<forall> a n s. ?N a = ?N (CN 0 n s) \<and> _ \<longrightarrow> ?I (le n s) = ?I (Le a)")
  3930 proof(clarify)
  3930 proof(clarify)
  3931   fix a n s
  3931   fix a n s
  3932   assume H: "?N a = ?N (CN 0 n s)"
  3932   assume H: "?N a = ?N (CN 0 n s)"
  3933   show "?I (le n s) = ?I (Le a)" using H by (cases "n=0", (simp add: le_def))
  3933   show "?I (le n s) = ?I (Le a)" using H by (cases "n=0", (simp add: le_def))
  3934   (cases "n > 0", simp_all add: le_def ring_simps myl[rule_format, where b="0"])
  3934   (cases "n > 0", simp_all add: le_def algebra_simps myl[rule_format, where b="0"])
  3935 qed
  3935 qed
  3936 
  3936 
  3937 lemma le_l: "isrlfm (rsplit le a)"
  3937 lemma le_l: "isrlfm (rsplit le a)"
  3938   by (rule rsplit_l[where f="le" and a="a"], auto simp add: le_def) 
  3938   by (rule rsplit_l[where f="le" and a="a"], auto simp add: le_def) 
  3939 (case_tac s, simp_all, case_tac "nat",simp_all)
  3939 (case_tac s, simp_all, case_tac "nat",simp_all)
  3941 lemma gt_mono: "\<forall> a n s. Inum (x#bs) a = Inum (x#bs) (CN 0 n s) \<and> numbound0 s \<longrightarrow> Ifm (x#bs) (gt n s) = Ifm (x#bs) (Gt a)" (is "\<forall> a n s. ?N a = ?N (CN 0 n s) \<and> _ \<longrightarrow> ?I (gt n s) = ?I (Gt a)")
  3941 lemma gt_mono: "\<forall> a n s. Inum (x#bs) a = Inum (x#bs) (CN 0 n s) \<and> numbound0 s \<longrightarrow> Ifm (x#bs) (gt n s) = Ifm (x#bs) (Gt a)" (is "\<forall> a n s. ?N a = ?N (CN 0 n s) \<and> _ \<longrightarrow> ?I (gt n s) = ?I (Gt a)")
  3942 proof(clarify)
  3942 proof(clarify)
  3943   fix a n s
  3943   fix a n s
  3944   assume H: "?N a = ?N (CN 0 n s)"
  3944   assume H: "?N a = ?N (CN 0 n s)"
  3945   show "?I (gt n s) = ?I (Gt a)" using H by (cases "n=0", (simp add: gt_def))
  3945   show "?I (gt n s) = ?I (Gt a)" using H by (cases "n=0", (simp add: gt_def))
  3946   (cases "n > 0", simp_all add: gt_def ring_simps myless[rule_format, where b="0"])
  3946   (cases "n > 0", simp_all add: gt_def algebra_simps myless[rule_format, where b="0"])
  3947 qed
  3947 qed
  3948 lemma gt_l: "isrlfm (rsplit gt a)"
  3948 lemma gt_l: "isrlfm (rsplit gt a)"
  3949   by (rule rsplit_l[where f="gt" and a="a"], auto simp add: gt_def) 
  3949   by (rule rsplit_l[where f="gt" and a="a"], auto simp add: gt_def) 
  3950 (case_tac s, simp_all, case_tac "nat", simp_all)
  3950 (case_tac s, simp_all, case_tac "nat", simp_all)
  3951 
  3951 
  3952 lemma ge_mono: "\<forall> a n s. Inum (x#bs) a = Inum (x#bs) (CN 0 n s) \<and> numbound0 s \<longrightarrow> Ifm (x#bs) (ge n s) = Ifm (x#bs) (Ge a)" (is "\<forall> a n s . ?N a = ?N (CN 0 n s) \<and> _ \<longrightarrow> ?I (ge n s) = ?I (Ge a)")
  3952 lemma ge_mono: "\<forall> a n s. Inum (x#bs) a = Inum (x#bs) (CN 0 n s) \<and> numbound0 s \<longrightarrow> Ifm (x#bs) (ge n s) = Ifm (x#bs) (Ge a)" (is "\<forall> a n s . ?N a = ?N (CN 0 n s) \<and> _ \<longrightarrow> ?I (ge n s) = ?I (Ge a)")
  3953 proof(clarify)
  3953 proof(clarify)
  3954   fix a n s 
  3954   fix a n s 
  3955   assume H: "?N a = ?N (CN 0 n s)"
  3955   assume H: "?N a = ?N (CN 0 n s)"
  3956   show "?I (ge n s) = ?I (Ge a)" using H by (cases "n=0", (simp add: ge_def))
  3956   show "?I (ge n s) = ?I (Ge a)" using H by (cases "n=0", (simp add: ge_def))
  3957   (cases "n > 0", simp_all add: ge_def ring_simps myl[rule_format, where b="0"])
  3957   (cases "n > 0", simp_all add: ge_def algebra_simps myl[rule_format, where b="0"])
  3958 qed
  3958 qed
  3959 lemma ge_l: "isrlfm (rsplit ge a)"
  3959 lemma ge_l: "isrlfm (rsplit ge a)"
  3960   by (rule rsplit_l[where f="ge" and a="a"], auto simp add: ge_def) 
  3960   by (rule rsplit_l[where f="ge" and a="a"], auto simp add: ge_def) 
  3961 (case_tac s, simp_all, case_tac "nat", simp_all)
  3961 (case_tac s, simp_all, case_tac "nat", simp_all)
  3962 
  3962 
  3963 lemma eq_mono: "\<forall> a n s. Inum (x#bs) a = Inum (x#bs) (CN 0 n s) \<and> numbound0 s \<longrightarrow> Ifm (x#bs) (eq n s) = Ifm (x#bs) (Eq a)" (is "\<forall> a n s. ?N a = ?N (CN 0 n s) \<and> _ \<longrightarrow> ?I (eq n s) = ?I (Eq a)")
  3963 lemma eq_mono: "\<forall> a n s. Inum (x#bs) a = Inum (x#bs) (CN 0 n s) \<and> numbound0 s \<longrightarrow> Ifm (x#bs) (eq n s) = Ifm (x#bs) (Eq a)" (is "\<forall> a n s. ?N a = ?N (CN 0 n s) \<and> _ \<longrightarrow> ?I (eq n s) = ?I (Eq a)")
  3964 proof(clarify)
  3964 proof(clarify)
  3965   fix a n s 
  3965   fix a n s 
  3966   assume H: "?N a = ?N (CN 0 n s)"
  3966   assume H: "?N a = ?N (CN 0 n s)"
  3967   show "?I (eq n s) = ?I (Eq a)" using H by (auto simp add: eq_def ring_simps)
  3967   show "?I (eq n s) = ?I (Eq a)" using H by (auto simp add: eq_def algebra_simps)
  3968 qed
  3968 qed
  3969 lemma eq_l: "isrlfm (rsplit eq a)"
  3969 lemma eq_l: "isrlfm (rsplit eq a)"
  3970   by (rule rsplit_l[where f="eq" and a="a"], auto simp add: eq_def) 
  3970   by (rule rsplit_l[where f="eq" and a="a"], auto simp add: eq_def) 
  3971 (case_tac s, simp_all, case_tac"nat", simp_all)
  3971 (case_tac s, simp_all, case_tac"nat", simp_all)
  3972 
  3972 
  3973 lemma neq_mono: "\<forall> a n s. Inum (x#bs) a = Inum (x#bs) (CN 0 n s) \<and> numbound0 s \<longrightarrow> Ifm (x#bs) (neq n s) = Ifm (x#bs) (NEq a)" (is "\<forall> a n s. ?N a = ?N (CN 0 n s) \<and> _ \<longrightarrow> ?I (neq n s) = ?I (NEq a)")
  3973 lemma neq_mono: "\<forall> a n s. Inum (x#bs) a = Inum (x#bs) (CN 0 n s) \<and> numbound0 s \<longrightarrow> Ifm (x#bs) (neq n s) = Ifm (x#bs) (NEq a)" (is "\<forall> a n s. ?N a = ?N (CN 0 n s) \<and> _ \<longrightarrow> ?I (neq n s) = ?I (NEq a)")
  3974 proof(clarify)
  3974 proof(clarify)
  3975   fix a n s bs
  3975   fix a n s bs
  3976   assume H: "?N a = ?N (CN 0 n s)"
  3976   assume H: "?N a = ?N (CN 0 n s)"
  3977   show "?I (neq n s) = ?I (NEq a)" using H by (auto simp add: neq_def ring_simps)
  3977   show "?I (neq n s) = ?I (NEq a)" using H by (auto simp add: neq_def algebra_simps)
  3978 qed
  3978 qed
  3979 
  3979 
  3980 lemma neq_l: "isrlfm (rsplit neq a)"
  3980 lemma neq_l: "isrlfm (rsplit neq a)"
  3981   by (rule rsplit_l[where f="neq" and a="a"], auto simp add: neq_def) 
  3981   by (rule rsplit_l[where f="neq" and a="a"], auto simp add: neq_def) 
  3982 (case_tac s, simp_all, case_tac"nat", simp_all)
  3982 (case_tac s, simp_all, case_tac"nat", simp_all)
  4010     \<and> real(floor (real n * u - s) + floor s)< real n - ?ss)" (is "_=(?DE \<and>real ?a \<ge> _ \<and> real ?a < _)")
  4010     \<and> real(floor (real n * u - s) + floor s)< real n - ?ss)" (is "_=(?DE \<and>real ?a \<ge> _ \<and> real ?a < _)")
  4011     using nu0 nun  by auto
  4011     using nu0 nun  by auto
  4012   also have "\<dots> = (?DE \<and> ?a \<ge> 0 \<and> ?a < n)" by(simp only: small_le[OF ss0 ss1] small_lt[OF ss0 ss1])
  4012   also have "\<dots> = (?DE \<and> ?a \<ge> 0 \<and> ?a < n)" by(simp only: small_le[OF ss0 ss1] small_lt[OF ss0 ss1])
  4013   also have "\<dots> = (?DE \<and> (\<exists> j\<in> {0 .. (n - 1)}. ?a = j))" by simp
  4013   also have "\<dots> = (?DE \<and> (\<exists> j\<in> {0 .. (n - 1)}. ?a = j))" by simp
  4014   also have "\<dots> = (?DE \<and> (\<exists> j\<in> {0 .. (n - 1)}. real (\<lfloor>real n * u - s\<rfloor>) = real j - real \<lfloor>s\<rfloor> ))"
  4014   also have "\<dots> = (?DE \<and> (\<exists> j\<in> {0 .. (n - 1)}. real (\<lfloor>real n * u - s\<rfloor>) = real j - real \<lfloor>s\<rfloor> ))"
  4015     by (simp only: ring_simps real_of_int_diff[symmetric] real_of_int_inject del: real_of_int_diff)
  4015     by (simp only: algebra_simps real_of_int_diff[symmetric] real_of_int_inject del: real_of_int_diff)
  4016   also have "\<dots> = ((\<exists> j\<in> {0 .. (n - 1)}. real n * u - s = real j - real \<lfloor>s\<rfloor> \<and> real i rdvd real n * u - s))" using int_rdvd_iff[where i="i" and t="\<lfloor>real n * u - s\<rfloor>"]
  4016   also have "\<dots> = ((\<exists> j\<in> {0 .. (n - 1)}. real n * u - s = real j - real \<lfloor>s\<rfloor> \<and> real i rdvd real n * u - s))" using int_rdvd_iff[where i="i" and t="\<lfloor>real n * u - s\<rfloor>"]
  4017     by (auto cong: conj_cong)
  4017     by (auto cong: conj_cong)
  4018   also have "\<dots> = ?rhs" by(simp cong: conj_cong) (simp add: ring_simps )
  4018   also have "\<dots> = ?rhs" by(simp cong: conj_cong) (simp add: algebra_simps )
  4019   finally show ?thesis .
  4019   finally show ?thesis .
  4020 qed
  4020 qed
  4021 
  4021 
  4022 definition
  4022 definition
  4023   DVDJ:: "int \<Rightarrow> int \<Rightarrow> num \<Rightarrow> fm"
  4023   DVDJ:: "int \<Rightarrow> int \<Rightarrow> num \<Rightarrow> fm"
  4036   let ?f = "\<lambda> j. conj (Eq(CN 0 n (Add s (Sub(Floor (Neg s)) (C j))))) (Dvd i (Sub (C j) (Floor (Neg s))))"
  4036   let ?f = "\<lambda> j. conj (Eq(CN 0 n (Add s (Sub(Floor (Neg s)) (C j))))) (Dvd i (Sub (C j) (Floor (Neg s))))"
  4037   let ?s= "Inum (x#bs) s"
  4037   let ?s= "Inum (x#bs) s"
  4038   from foldr_disj_map[where xs="iupt(0,n - 1)" and bs="x#bs" and f="?f"]
  4038   from foldr_disj_map[where xs="iupt(0,n - 1)" and bs="x#bs" and f="?f"]
  4039   have "Ifm (x#bs) (DVDJ i n s) = (\<exists> j\<in> {0 .. (n - 1)}. Ifm (x#bs) (?f j))" 
  4039   have "Ifm (x#bs) (DVDJ i n s) = (\<exists> j\<in> {0 .. (n - 1)}. Ifm (x#bs) (?f j))" 
  4040     by (simp add: iupt_set np DVDJ_def del: iupt.simps)
  4040     by (simp add: iupt_set np DVDJ_def del: iupt.simps)
  4041   also have "\<dots> = (\<exists> j\<in> {0 .. (n - 1)}. real n * x = (- ?s) - real (floor (- ?s)) + real j \<and> real i rdvd real (j - floor (- ?s)))" by (simp add: ring_simps diff_def[symmetric])
  4041   also have "\<dots> = (\<exists> j\<in> {0 .. (n - 1)}. real n * x = (- ?s) - real (floor (- ?s)) + real j \<and> real i rdvd real (j - floor (- ?s)))" by (simp add: algebra_simps diff_def[symmetric])
  4042   also from rdvd01_cs[OF xp x1 np, where i="i" and s="-?s"] 
  4042   also from rdvd01_cs[OF xp x1 np, where i="i" and s="-?s"] 
  4043   have "\<dots> = (real i rdvd real n * x - (-?s))" by simp
  4043   have "\<dots> = (real i rdvd real n * x - (-?s))" by simp
  4044   finally show ?thesis by simp
  4044   finally show ?thesis by simp
  4045 qed
  4045 qed
  4046 
  4046 
  4051   let ?f = "\<lambda> j. disj(NEq(CN 0 n (Add s (Sub (Floor (Neg s)) (C j))))) (NDvd i (Sub (C j) (Floor(Neg s))))"
  4051   let ?f = "\<lambda> j. disj(NEq(CN 0 n (Add s (Sub (Floor (Neg s)) (C j))))) (NDvd i (Sub (C j) (Floor(Neg s))))"
  4052   let ?s= "Inum (x#bs) s"
  4052   let ?s= "Inum (x#bs) s"
  4053   from foldr_conj_map[where xs="iupt(0,n - 1)" and bs="x#bs" and f="?f"]
  4053   from foldr_conj_map[where xs="iupt(0,n - 1)" and bs="x#bs" and f="?f"]
  4054   have "Ifm (x#bs) (NDVDJ i n s) = (\<forall> j\<in> {0 .. (n - 1)}. Ifm (x#bs) (?f j))" 
  4054   have "Ifm (x#bs) (NDVDJ i n s) = (\<forall> j\<in> {0 .. (n - 1)}. Ifm (x#bs) (?f j))" 
  4055     by (simp add: iupt_set np NDVDJ_def del: iupt.simps)
  4055     by (simp add: iupt_set np NDVDJ_def del: iupt.simps)
  4056   also have "\<dots> = (\<not> (\<exists> j\<in> {0 .. (n - 1)}. real n * x = (- ?s) - real (floor (- ?s)) + real j \<and> real i rdvd real (j - floor (- ?s))))" by (simp add: ring_simps diff_def[symmetric])
  4056   also have "\<dots> = (\<not> (\<exists> j\<in> {0 .. (n - 1)}. real n * x = (- ?s) - real (floor (- ?s)) + real j \<and> real i rdvd real (j - floor (- ?s))))" by (simp add: algebra_simps diff_def[symmetric])
  4057   also from rdvd01_cs[OF xp x1 np, where i="i" and s="-?s"] 
  4057   also from rdvd01_cs[OF xp x1 np, where i="i" and s="-?s"] 
  4058   have "\<dots> = (\<not> (real i rdvd real n * x - (-?s)))" by simp
  4058   have "\<dots> = (\<not> (real i rdvd real n * x - (-?s)))" by simp
  4059   finally show ?thesis by simp
  4059   finally show ?thesis by simp
  4060 qed  
  4060 qed  
  4061 
  4061 
  4650   case (5 c e) from prems have cp: "c >0" and nb: "numbound0 e" by simp+
  4650   case (5 c e) from prems have cp: "c >0" and nb: "numbound0 e" by simp+
  4651   have "?I ?u (Lt (CN 0 c e)) = (real c *(?t/?n) + (?N x e) < 0)"
  4651   have "?I ?u (Lt (CN 0 c e)) = (real c *(?t/?n) + (?N x e) < 0)"
  4652     using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp
  4652     using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp
  4653   also have "\<dots> = (?n*(real c *(?t/?n)) + ?n*(?N x e) < 0)"
  4653   also have "\<dots> = (?n*(real c *(?t/?n)) + ?n*(?N x e) < 0)"
  4654     by (simp only: pos_less_divide_eq[OF np, where a="real c *(?t/?n) + (?N x e)" 
  4654     by (simp only: pos_less_divide_eq[OF np, where a="real c *(?t/?n) + (?N x e)" 
  4655       and b="0", simplified divide_zero_left]) (simp only: ring_simps)
  4655       and b="0", simplified divide_zero_left]) (simp only: algebra_simps)
  4656   also have "\<dots> = (real c *?t + ?n* (?N x e) < 0)"
  4656   also have "\<dots> = (real c *?t + ?n* (?N x e) < 0)"
  4657     using np by simp 
  4657     using np by simp 
  4658   finally show ?case using nbt nb by (simp add: ring_simps)
  4658   finally show ?case using nbt nb by (simp add: algebra_simps)
  4659 next
  4659 next
  4660   case (6 c e) from prems have cp: "c >0" and nb: "numbound0 e" by simp+
  4660   case (6 c e) from prems have cp: "c >0" and nb: "numbound0 e" by simp+
  4661   have "?I ?u (Le (CN 0 c e)) = (real c *(?t/?n) + (?N x e) \<le> 0)"
  4661   have "?I ?u (Le (CN 0 c e)) = (real c *(?t/?n) + (?N x e) \<le> 0)"
  4662     using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp
  4662     using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp
  4663   also have "\<dots> = (?n*(real c *(?t/?n)) + ?n*(?N x e) \<le> 0)"
  4663   also have "\<dots> = (?n*(real c *(?t/?n)) + ?n*(?N x e) \<le> 0)"
  4664     by (simp only: pos_le_divide_eq[OF np, where a="real c *(?t/?n) + (?N x e)" 
  4664     by (simp only: pos_le_divide_eq[OF np, where a="real c *(?t/?n) + (?N x e)" 
  4665       and b="0", simplified divide_zero_left]) (simp only: ring_simps)
  4665       and b="0", simplified divide_zero_left]) (simp only: algebra_simps)
  4666   also have "\<dots> = (real c *?t + ?n* (?N x e) \<le> 0)"
  4666   also have "\<dots> = (real c *?t + ?n* (?N x e) \<le> 0)"
  4667     using np by simp 
  4667     using np by simp 
  4668   finally show ?case using nbt nb by (simp add: ring_simps)
  4668   finally show ?case using nbt nb by (simp add: algebra_simps)
  4669 next
  4669 next
  4670   case (7 c e) from prems have cp: "c >0" and nb: "numbound0 e" by simp+
  4670   case (7 c e) from prems have cp: "c >0" and nb: "numbound0 e" by simp+
  4671   have "?I ?u (Gt (CN 0 c e)) = (real c *(?t/?n) + (?N x e) > 0)"
  4671   have "?I ?u (Gt (CN 0 c e)) = (real c *(?t/?n) + (?N x e) > 0)"
  4672     using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp
  4672     using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp
  4673   also have "\<dots> = (?n*(real c *(?t/?n)) + ?n*(?N x e) > 0)"
  4673   also have "\<dots> = (?n*(real c *(?t/?n)) + ?n*(?N x e) > 0)"
  4674     by (simp only: pos_divide_less_eq[OF np, where a="real c *(?t/?n) + (?N x e)" 
  4674     by (simp only: pos_divide_less_eq[OF np, where a="real c *(?t/?n) + (?N x e)" 
  4675       and b="0", simplified divide_zero_left]) (simp only: ring_simps)
  4675       and b="0", simplified divide_zero_left]) (simp only: algebra_simps)
  4676   also have "\<dots> = (real c *?t + ?n* (?N x e) > 0)"
  4676   also have "\<dots> = (real c *?t + ?n* (?N x e) > 0)"
  4677     using np by simp 
  4677     using np by simp 
  4678   finally show ?case using nbt nb by (simp add: ring_simps)
  4678   finally show ?case using nbt nb by (simp add: algebra_simps)
  4679 next
  4679 next
  4680   case (8 c e) from prems have cp: "c >0" and nb: "numbound0 e" by simp+
  4680   case (8 c e) from prems have cp: "c >0" and nb: "numbound0 e" by simp+
  4681   have "?I ?u (Ge (CN 0 c e)) = (real c *(?t/?n) + (?N x e) \<ge> 0)"
  4681   have "?I ?u (Ge (CN 0 c e)) = (real c *(?t/?n) + (?N x e) \<ge> 0)"
  4682     using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp
  4682     using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp
  4683   also have "\<dots> = (?n*(real c *(?t/?n)) + ?n*(?N x e) \<ge> 0)"
  4683   also have "\<dots> = (?n*(real c *(?t/?n)) + ?n*(?N x e) \<ge> 0)"
  4684     by (simp only: pos_divide_le_eq[OF np, where a="real c *(?t/?n) + (?N x e)" 
  4684     by (simp only: pos_divide_le_eq[OF np, where a="real c *(?t/?n) + (?N x e)" 
  4685       and b="0", simplified divide_zero_left]) (simp only: ring_simps)
  4685       and b="0", simplified divide_zero_left]) (simp only: algebra_simps)
  4686   also have "\<dots> = (real c *?t + ?n* (?N x e) \<ge> 0)"
  4686   also have "\<dots> = (real c *?t + ?n* (?N x e) \<ge> 0)"
  4687     using np by simp 
  4687     using np by simp 
  4688   finally show ?case using nbt nb by (simp add: ring_simps)
  4688   finally show ?case using nbt nb by (simp add: algebra_simps)
  4689 next
  4689 next
  4690   case (3 c e) from prems have cp: "c >0" and nb: "numbound0 e" by simp+
  4690   case (3 c e) from prems have cp: "c >0" and nb: "numbound0 e" by simp+
  4691   from np have np: "real n \<noteq> 0" by simp
  4691   from np have np: "real n \<noteq> 0" by simp
  4692   have "?I ?u (Eq (CN 0 c e)) = (real c *(?t/?n) + (?N x e) = 0)"
  4692   have "?I ?u (Eq (CN 0 c e)) = (real c *(?t/?n) + (?N x e) = 0)"
  4693     using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp
  4693     using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp
  4694   also have "\<dots> = (?n*(real c *(?t/?n)) + ?n*(?N x e) = 0)"
  4694   also have "\<dots> = (?n*(real c *(?t/?n)) + ?n*(?N x e) = 0)"
  4695     by (simp only: nonzero_eq_divide_eq[OF np, where a="real c *(?t/?n) + (?N x e)" 
  4695     by (simp only: nonzero_eq_divide_eq[OF np, where a="real c *(?t/?n) + (?N x e)" 
  4696       and b="0", simplified divide_zero_left]) (simp only: ring_simps)
  4696       and b="0", simplified divide_zero_left]) (simp only: algebra_simps)
  4697   also have "\<dots> = (real c *?t + ?n* (?N x e) = 0)"
  4697   also have "\<dots> = (real c *?t + ?n* (?N x e) = 0)"
  4698     using np by simp 
  4698     using np by simp 
  4699   finally show ?case using nbt nb by (simp add: ring_simps)
  4699   finally show ?case using nbt nb by (simp add: algebra_simps)
  4700 next
  4700 next
  4701   case (4 c e) from prems have cp: "c >0" and nb: "numbound0 e" by simp+
  4701   case (4 c e) from prems have cp: "c >0" and nb: "numbound0 e" by simp+
  4702   from np have np: "real n \<noteq> 0" by simp
  4702   from np have np: "real n \<noteq> 0" by simp
  4703   have "?I ?u (NEq (CN 0 c e)) = (real c *(?t/?n) + (?N x e) \<noteq> 0)"
  4703   have "?I ?u (NEq (CN 0 c e)) = (real c *(?t/?n) + (?N x e) \<noteq> 0)"
  4704     using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp
  4704     using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp
  4705   also have "\<dots> = (?n*(real c *(?t/?n)) + ?n*(?N x e) \<noteq> 0)"
  4705   also have "\<dots> = (?n*(real c *(?t/?n)) + ?n*(?N x e) \<noteq> 0)"
  4706     by (simp only: nonzero_eq_divide_eq[OF np, where a="real c *(?t/?n) + (?N x e)" 
  4706     by (simp only: nonzero_eq_divide_eq[OF np, where a="real c *(?t/?n) + (?N x e)" 
  4707       and b="0", simplified divide_zero_left]) (simp only: ring_simps)
  4707       and b="0", simplified divide_zero_left]) (simp only: algebra_simps)
  4708   also have "\<dots> = (real c *?t + ?n* (?N x e) \<noteq> 0)"
  4708   also have "\<dots> = (real c *?t + ?n* (?N x e) \<noteq> 0)"
  4709     using np by simp 
  4709     using np by simp 
  4710   finally show ?case using nbt nb by (simp add: ring_simps)
  4710   finally show ?case using nbt nb by (simp add: algebra_simps)
  4711 qed(simp_all add: nbt numbound0_I[where bs ="bs" and b="(Inum (x#bs) t)/ real n" and b'="x"] nth_pos2)
  4711 qed(simp_all add: nbt numbound0_I[where bs ="bs" and b="(Inum (x#bs) t)/ real n" and b'="x"] nth_pos2)
  4712 
  4712 
  4713 lemma \<Upsilon>_l:
  4713 lemma \<Upsilon>_l:
  4714   assumes lp: "isrlfm p"
  4714   assumes lp: "isrlfm p"
  4715   shows "\<forall> (t,k) \<in> set (\<Upsilon> p). numbound0 t \<and> k >0"
  4715   shows "\<forall> (t,k) \<in> set (\<Upsilon> p). numbound0 t \<and> k >0"
  4756   and ly: "l < y" and yu: "y < u"
  4756   and ly: "l < y" and yu: "y < u"
  4757   shows "Ifm (y#bs) p"
  4757   shows "Ifm (y#bs) p"
  4758 using lp px noS
  4758 using lp px noS
  4759 proof (induct p rule: isrlfm.induct)
  4759 proof (induct p rule: isrlfm.induct)
  4760   case (5 c e) hence cp: "real c > 0" and nb: "numbound0 e" by simp+
  4760   case (5 c e) hence cp: "real c > 0" and nb: "numbound0 e" by simp+
  4761     from prems have "x * real c + ?N x e < 0" by (simp add: ring_simps)
  4761     from prems have "x * real c + ?N x e < 0" by (simp add: algebra_simps)
  4762     hence pxc: "x < (- ?N x e) / real c" 
  4762     hence pxc: "x < (- ?N x e) / real c" 
  4763       by (simp only: pos_less_divide_eq[OF cp, where a="x" and b="-?N x e"])
  4763       by (simp only: pos_less_divide_eq[OF cp, where a="x" and b="-?N x e"])
  4764     from prems have noSc:"\<forall> t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real c" by auto
  4764     from prems have noSc:"\<forall> t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real c" by auto
  4765     with ly yu have yne: "y \<noteq> - ?N x e / real c" by auto
  4765     with ly yu have yne: "y \<noteq> - ?N x e / real c" by auto
  4766     hence "y < (- ?N x e) / real c \<or> y > (-?N x e) / real c" by auto
  4766     hence "y < (- ?N x e) / real c \<or> y > (-?N x e) / real c" by auto
  4767     moreover {assume y: "y < (-?N x e)/ real c"
  4767     moreover {assume y: "y < (-?N x e)/ real c"
  4768       hence "y * real c < - ?N x e"
  4768       hence "y * real c < - ?N x e"
  4769 	by (simp add: pos_less_divide_eq[OF cp, where a="y" and b="-?N x e", symmetric])
  4769 	by (simp add: pos_less_divide_eq[OF cp, where a="y" and b="-?N x e", symmetric])
  4770       hence "real c * y + ?N x e < 0" by (simp add: ring_simps)
  4770       hence "real c * y + ?N x e < 0" by (simp add: algebra_simps)
  4771       hence ?case using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] by simp}
  4771       hence ?case using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] by simp}
  4772     moreover {assume y: "y > (- ?N x e) / real c" 
  4772     moreover {assume y: "y > (- ?N x e) / real c" 
  4773       with yu have eu: "u > (- ?N x e) / real c" by auto
  4773       with yu have eu: "u > (- ?N x e) / real c" by auto
  4774       with noSc ly yu have "(- ?N x e) / real c \<le> l" by (cases "(- ?N x e) / real c > l", auto)
  4774       with noSc ly yu have "(- ?N x e) / real c \<le> l" by (cases "(- ?N x e) / real c > l", auto)
  4775       with lx pxc have "False" by auto
  4775       with lx pxc have "False" by auto
  4776       hence ?case by simp }
  4776       hence ?case by simp }
  4777     ultimately show ?case by blast
  4777     ultimately show ?case by blast
  4778 next
  4778 next
  4779   case (6 c e) hence cp: "real c > 0" and nb: "numbound0 e" by simp +
  4779   case (6 c e) hence cp: "real c > 0" and nb: "numbound0 e" by simp +
  4780     from prems have "x * real c + ?N x e \<le> 0" by (simp add: ring_simps)
  4780     from prems have "x * real c + ?N x e \<le> 0" by (simp add: algebra_simps)
  4781     hence pxc: "x \<le> (- ?N x e) / real c" 
  4781     hence pxc: "x \<le> (- ?N x e) / real c" 
  4782       by (simp only: pos_le_divide_eq[OF cp, where a="x" and b="-?N x e"])
  4782       by (simp only: pos_le_divide_eq[OF cp, where a="x" and b="-?N x e"])
  4783     from prems have noSc:"\<forall> t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real c" by auto
  4783     from prems have noSc:"\<forall> t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real c" by auto
  4784     with ly yu have yne: "y \<noteq> - ?N x e / real c" by auto
  4784     with ly yu have yne: "y \<noteq> - ?N x e / real c" by auto
  4785     hence "y < (- ?N x e) / real c \<or> y > (-?N x e) / real c" by auto
  4785     hence "y < (- ?N x e) / real c \<or> y > (-?N x e) / real c" by auto
  4786     moreover {assume y: "y < (-?N x e)/ real c"
  4786     moreover {assume y: "y < (-?N x e)/ real c"
  4787       hence "y * real c < - ?N x e"
  4787       hence "y * real c < - ?N x e"
  4788 	by (simp add: pos_less_divide_eq[OF cp, where a="y" and b="-?N x e", symmetric])
  4788 	by (simp add: pos_less_divide_eq[OF cp, where a="y" and b="-?N x e", symmetric])
  4789       hence "real c * y + ?N x e < 0" by (simp add: ring_simps)
  4789       hence "real c * y + ?N x e < 0" by (simp add: algebra_simps)
  4790       hence ?case using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] by simp}
  4790       hence ?case using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] by simp}
  4791     moreover {assume y: "y > (- ?N x e) / real c" 
  4791     moreover {assume y: "y > (- ?N x e) / real c" 
  4792       with yu have eu: "u > (- ?N x e) / real c" by auto
  4792       with yu have eu: "u > (- ?N x e) / real c" by auto
  4793       with noSc ly yu have "(- ?N x e) / real c \<le> l" by (cases "(- ?N x e) / real c > l", auto)
  4793       with noSc ly yu have "(- ?N x e) / real c \<le> l" by (cases "(- ?N x e) / real c > l", auto)
  4794       with lx pxc have "False" by auto
  4794       with lx pxc have "False" by auto
  4795       hence ?case by simp }
  4795       hence ?case by simp }
  4796     ultimately show ?case by blast
  4796     ultimately show ?case by blast
  4797 next
  4797 next
  4798   case (7 c e) hence cp: "real c > 0" and nb: "numbound0 e" by simp+
  4798   case (7 c e) hence cp: "real c > 0" and nb: "numbound0 e" by simp+
  4799     from prems have "x * real c + ?N x e > 0" by (simp add: ring_simps)
  4799     from prems have "x * real c + ?N x e > 0" by (simp add: algebra_simps)
  4800     hence pxc: "x > (- ?N x e) / real c" 
  4800     hence pxc: "x > (- ?N x e) / real c" 
  4801       by (simp only: pos_divide_less_eq[OF cp, where a="x" and b="-?N x e"])
  4801       by (simp only: pos_divide_less_eq[OF cp, where a="x" and b="-?N x e"])
  4802     from prems have noSc:"\<forall> t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real c" by auto
  4802     from prems have noSc:"\<forall> t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real c" by auto
  4803     with ly yu have yne: "y \<noteq> - ?N x e / real c" by auto
  4803     with ly yu have yne: "y \<noteq> - ?N x e / real c" by auto
  4804     hence "y < (- ?N x e) / real c \<or> y > (-?N x e) / real c" by auto
  4804     hence "y < (- ?N x e) / real c \<or> y > (-?N x e) / real c" by auto
  4805     moreover {assume y: "y > (-?N x e)/ real c"
  4805     moreover {assume y: "y > (-?N x e)/ real c"
  4806       hence "y * real c > - ?N x e"
  4806       hence "y * real c > - ?N x e"
  4807 	by (simp add: pos_divide_less_eq[OF cp, where a="y" and b="-?N x e", symmetric])
  4807 	by (simp add: pos_divide_less_eq[OF cp, where a="y" and b="-?N x e", symmetric])
  4808       hence "real c * y + ?N x e > 0" by (simp add: ring_simps)
  4808       hence "real c * y + ?N x e > 0" by (simp add: algebra_simps)
  4809       hence ?case using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] by simp}
  4809       hence ?case using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] by simp}
  4810     moreover {assume y: "y < (- ?N x e) / real c" 
  4810     moreover {assume y: "y < (- ?N x e) / real c" 
  4811       with ly have eu: "l < (- ?N x e) / real c" by auto
  4811       with ly have eu: "l < (- ?N x e) / real c" by auto
  4812       with noSc ly yu have "(- ?N x e) / real c \<ge> u" by (cases "(- ?N x e) / real c > l", auto)
  4812       with noSc ly yu have "(- ?N x e) / real c \<ge> u" by (cases "(- ?N x e) / real c > l", auto)
  4813       with xu pxc have "False" by auto
  4813       with xu pxc have "False" by auto
  4814       hence ?case by simp }
  4814       hence ?case by simp }
  4815     ultimately show ?case by blast
  4815     ultimately show ?case by blast
  4816 next
  4816 next
  4817   case (8 c e) hence cp: "real c > 0" and nb: "numbound0 e" by simp+
  4817   case (8 c e) hence cp: "real c > 0" and nb: "numbound0 e" by simp+
  4818     from prems have "x * real c + ?N x e \<ge> 0" by (simp add: ring_simps)
  4818     from prems have "x * real c + ?N x e \<ge> 0" by (simp add: algebra_simps)
  4819     hence pxc: "x \<ge> (- ?N x e) / real c" 
  4819     hence pxc: "x \<ge> (- ?N x e) / real c" 
  4820       by (simp only: pos_divide_le_eq[OF cp, where a="x" and b="-?N x e"])
  4820       by (simp only: pos_divide_le_eq[OF cp, where a="x" and b="-?N x e"])
  4821     from prems have noSc:"\<forall> t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real c" by auto
  4821     from prems have noSc:"\<forall> t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real c" by auto
  4822     with ly yu have yne: "y \<noteq> - ?N x e / real c" by auto
  4822     with ly yu have yne: "y \<noteq> - ?N x e / real c" by auto
  4823     hence "y < (- ?N x e) / real c \<or> y > (-?N x e) / real c" by auto
  4823     hence "y < (- ?N x e) / real c \<or> y > (-?N x e) / real c" by auto
  4824     moreover {assume y: "y > (-?N x e)/ real c"
  4824     moreover {assume y: "y > (-?N x e)/ real c"
  4825       hence "y * real c > - ?N x e"
  4825       hence "y * real c > - ?N x e"
  4826 	by (simp add: pos_divide_less_eq[OF cp, where a="y" and b="-?N x e", symmetric])
  4826 	by (simp add: pos_divide_less_eq[OF cp, where a="y" and b="-?N x e", symmetric])
  4827       hence "real c * y + ?N x e > 0" by (simp add: ring_simps)
  4827       hence "real c * y + ?N x e > 0" by (simp add: algebra_simps)
  4828       hence ?case using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] by simp}
  4828       hence ?case using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] by simp}
  4829     moreover {assume y: "y < (- ?N x e) / real c" 
  4829     moreover {assume y: "y < (- ?N x e) / real c" 
  4830       with ly have eu: "l < (- ?N x e) / real c" by auto
  4830       with ly have eu: "l < (- ?N x e) / real c" by auto
  4831       with noSc ly yu have "(- ?N x e) / real c \<ge> u" by (cases "(- ?N x e) / real c > l", auto)
  4831       with noSc ly yu have "(- ?N x e) / real c \<ge> u" by (cases "(- ?N x e) / real c > l", auto)
  4832       with xu pxc have "False" by auto
  4832       with xu pxc have "False" by auto
  4833       hence ?case by simp }
  4833       hence ?case by simp }
  4834     ultimately show ?case by blast
  4834     ultimately show ?case by blast
  4835 next
  4835 next
  4836   case (3 c e) hence cp: "real c > 0" and nb: "numbound0 e" by simp+
  4836   case (3 c e) hence cp: "real c > 0" and nb: "numbound0 e" by simp+
  4837     from cp have cnz: "real c \<noteq> 0" by simp
  4837     from cp have cnz: "real c \<noteq> 0" by simp
  4838     from prems have "x * real c + ?N x e = 0" by (simp add: ring_simps)
  4838     from prems have "x * real c + ?N x e = 0" by (simp add: algebra_simps)
  4839     hence pxc: "x = (- ?N x e) / real c" 
  4839     hence pxc: "x = (- ?N x e) / real c" 
  4840       by (simp only: nonzero_eq_divide_eq[OF cnz, where a="x" and b="-?N x e"])
  4840       by (simp only: nonzero_eq_divide_eq[OF cnz, where a="x" and b="-?N x e"])
  4841     from prems have noSc:"\<forall> t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real c" by auto
  4841     from prems have noSc:"\<forall> t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real c" by auto
  4842     with lx xu have yne: "x \<noteq> - ?N x e / real c" by auto
  4842     with lx xu have yne: "x \<noteq> - ?N x e / real c" by auto
  4843     with pxc show ?case by simp
  4843     with pxc show ?case by simp
  4846     from cp have cnz: "real c \<noteq> 0" by simp
  4846     from cp have cnz: "real c \<noteq> 0" by simp
  4847     from prems have noSc:"\<forall> t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real c" by auto
  4847     from prems have noSc:"\<forall> t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real c" by auto
  4848     with ly yu have yne: "y \<noteq> - ?N x e / real c" by auto
  4848     with ly yu have yne: "y \<noteq> - ?N x e / real c" by auto
  4849     hence "y* real c \<noteq> -?N x e"      
  4849     hence "y* real c \<noteq> -?N x e"      
  4850       by (simp only: nonzero_eq_divide_eq[OF cnz, where a="y" and b="-?N x e"]) simp
  4850       by (simp only: nonzero_eq_divide_eq[OF cnz, where a="y" and b="-?N x e"]) simp
  4851     hence "y* real c + ?N x e \<noteq> 0" by (simp add: ring_simps)
  4851     hence "y* real c + ?N x e \<noteq> 0" by (simp add: algebra_simps)
  4852     thus ?case using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] 
  4852     thus ?case using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] 
  4853       by (simp add: ring_simps)
  4853       by (simp add: algebra_simps)
  4854 qed (auto simp add: nth_pos2 numbound0_I[where bs="bs" and b="y" and b'="x"])
  4854 qed (auto simp add: nth_pos2 numbound0_I[where bs="bs" and b="y" and b'="x"])
  4855 
  4855 
  4856 lemma finite_set_intervals:
  4856 lemma finite_set_intervals:
  4857   assumes px: "P (x::real)" 
  4857   assumes px: "P (x::real)" 
  4858   and lx: "l \<le> x" and xu: "x \<le> u"
  4858   and lx: "l \<le> x" and xu: "x \<le> u"
  5011       let ?st = "Add (Mul m t) (Mul n s)"
  5011       let ?st = "Add (Mul m t) (Mul n s)"
  5012       from mult_pos_pos[OF np mp] have mnp: "real (2*n*m) > 0" 
  5012       from mult_pos_pos[OF np mp] have mnp: "real (2*n*m) > 0" 
  5013 	by (simp add: mult_commute)
  5013 	by (simp add: mult_commute)
  5014       from tnb snb have st_nb: "numbound0 ?st" by simp
  5014       from tnb snb have st_nb: "numbound0 ?st" by simp
  5015       have st: "(?N t / real n + ?N s / real m)/2 = ?N ?st / real (2*n*m)"
  5015       have st: "(?N t / real n + ?N s / real m)/2 = ?N ?st / real (2*n*m)"
  5016 	using mnp mp np by (simp add: ring_simps add_divide_distrib)
  5016 	using mnp mp np by (simp add: algebra_simps add_divide_distrib)
  5017       from \<upsilon>_I[OF lp mnp st_nb, where x="x" and bs="bs"] 
  5017       from \<upsilon>_I[OF lp mnp st_nb, where x="x" and bs="bs"] 
  5018       have "?I x (\<upsilon> p (?st,2*n*m)) = ?I ((?N t / real n + ?N s / real m) /2) p" by (simp only: st[symmetric])}
  5018       have "?I x (\<upsilon> p (?st,2*n*m)) = ?I ((?N t / real n + ?N s / real m) /2) p" by (simp only: st[symmetric])}
  5019     with rinf_\<Upsilon>[OF lp nmi npi px] have "?F" by blast hence "?D" by blast}
  5019     with rinf_\<Upsilon>[OF lp nmi npi px] have "?F" by blast hence "?D" by blast}
  5020   ultimately show "?D" by blast
  5020   ultimately show "?D" by blast
  5021 next
  5021 next
  5080   "exsplit (NOT p) = NOT (exsplit p)"
  5080   "exsplit (NOT p) = NOT (exsplit p)"
  5081   "exsplit p = p"
  5081   "exsplit p = p"
  5082 
  5082 
  5083 lemma exsplitnum: 
  5083 lemma exsplitnum: 
  5084   "Inum (x#y#bs) (exsplitnum t) = Inum ((x+y) #bs) t"
  5084   "Inum (x#y#bs) (exsplitnum t) = Inum ((x+y) #bs) t"
  5085   by(induct t rule: exsplitnum.induct) (simp_all add: ring_simps)
  5085   by(induct t rule: exsplitnum.induct) (simp_all add: algebra_simps)
  5086 
  5086 
  5087 lemma exsplit: 
  5087 lemma exsplit: 
  5088   assumes qfp: "qfree p"
  5088   assumes qfp: "qfree p"
  5089   shows "Ifm (x#y#bs) (exsplit p) = Ifm ((x+y)#bs) p"
  5089   shows "Ifm (x#y#bs) (exsplit p) = Ifm ((x+y)#bs) p"
  5090 using qfp exsplitnum[where x="x" and y="y" and bs="bs"]
  5090 using qfp exsplitnum[where x="x" and y="y" and bs="bs"]
  5171   let ?N = "\<lambda> t. Inum (x#bs) t"
  5171   let ?N = "\<lambda> t. Inum (x#bs) t"
  5172   let ?st= "Add (Mul m t) (Mul n s)"
  5172   let ?st= "Add (Mul m t) (Mul n s)"
  5173   from Ul th have mnz: "m \<noteq> 0" by auto
  5173   from Ul th have mnz: "m \<noteq> 0" by auto
  5174   from Ul th have  nnz: "n \<noteq> 0" by auto  
  5174   from Ul th have  nnz: "n \<noteq> 0" by auto  
  5175   have st: "(?N t / real n + ?N s / real m)/2 = ?N ?st / real (2*n*m)"
  5175   have st: "(?N t / real n + ?N s / real m)/2 = ?N ?st / real (2*n*m)"
  5176    using mnz nnz by (simp add: ring_simps add_divide_distrib)
  5176    using mnz nnz by (simp add: algebra_simps add_divide_distrib)
  5177  
  5177  
  5178   thus "(real m *  Inum (x # bs) t + real n * Inum (x # bs) s) /
  5178   thus "(real m *  Inum (x # bs) t + real n * Inum (x # bs) s) /
  5179        (2 * real n * real m)
  5179        (2 * real n * real m)
  5180        \<in> (\<lambda>((t, n), s, m).
  5180        \<in> (\<lambda>((t, n), s, m).
  5181              (Inum (x # bs) t / real n + Inum (x # bs) s / real m) / 2) `
  5181              (Inum (x # bs) t / real n + Inum (x # bs) s / real m) / 2) `
  5182          (set U \<times> set U)"using mnz nnz th  
  5182          (set U \<times> set U)"using mnz nnz th  
  5183     apply (auto simp add: th add_divide_distrib ring_simps split_def image_def)
  5183     apply (auto simp add: th add_divide_distrib algebra_simps split_def image_def)
  5184     by (rule_tac x="(s,m)" in bexI,simp_all) 
  5184     by (rule_tac x="(s,m)" in bexI,simp_all) 
  5185   (rule_tac x="(t,n)" in bexI,simp_all)
  5185   (rule_tac x="(t,n)" in bexI,simp_all)
  5186 next
  5186 next
  5187   fix t n s m
  5187   fix t n s m
  5188   assume tnU: "(t,n) \<in> set U" and smU:"(s,m) \<in> set U" 
  5188   assume tnU: "(t,n) \<in> set U" and smU:"(s,m) \<in> set U" 
  5189   let ?N = "\<lambda> t. Inum (x#bs) t"
  5189   let ?N = "\<lambda> t. Inum (x#bs) t"
  5190   let ?st= "Add (Mul m t) (Mul n s)"
  5190   let ?st= "Add (Mul m t) (Mul n s)"
  5191   from Ul smU have mnz: "m \<noteq> 0" by auto
  5191   from Ul smU have mnz: "m \<noteq> 0" by auto
  5192   from Ul tnU have  nnz: "n \<noteq> 0" by auto  
  5192   from Ul tnU have  nnz: "n \<noteq> 0" by auto  
  5193   have st: "(?N t / real n + ?N s / real m)/2 = ?N ?st / real (2*n*m)"
  5193   have st: "(?N t / real n + ?N s / real m)/2 = ?N ?st / real (2*n*m)"
  5194    using mnz nnz by (simp add: ring_simps add_divide_distrib)
  5194    using mnz nnz by (simp add: algebra_simps add_divide_distrib)
  5195  let ?P = "\<lambda> (t',n') (s',m'). (Inum (x # bs) t / real n + Inum (x # bs) s / real m)/2 = (Inum (x # bs) t' / real n' + Inum (x # bs) s' / real m')/2"
  5195  let ?P = "\<lambda> (t',n') (s',m'). (Inum (x # bs) t / real n + Inum (x # bs) s / real m)/2 = (Inum (x # bs) t' / real n' + Inum (x # bs) s' / real m')/2"
  5196  have Pc:"\<forall> a b. ?P a b = ?P b a"
  5196  have Pc:"\<forall> a b. ?P a b = ?P b a"
  5197    by auto
  5197    by auto
  5198  from Ul alluopairs_set1 have Up:"\<forall> ((t,n),(s,m)) \<in> set (alluopairs U). n \<noteq> 0 \<and> m \<noteq> 0" by blast
  5198  from Ul alluopairs_set1 have Up:"\<forall> ((t,n),(s,m)) \<in> set (alluopairs U). n \<noteq> 0 \<and> m \<noteq> 0" by blast
  5199  from alluopairs_ex[OF Pc, where xs="U"] tnU smU
  5199  from alluopairs_ex[OF Pc, where xs="U"] tnU smU
  5202  then obtain t' n' s' m' where ts'_U: "((t',n'),(s',m')) \<in> set (alluopairs U)" 
  5202  then obtain t' n' s' m' where ts'_U: "((t',n'),(s',m')) \<in> set (alluopairs U)" 
  5203    and Pts': "?P (t',n') (s',m')" by blast
  5203    and Pts': "?P (t',n') (s',m')" by blast
  5204  from ts'_U Up have mnz': "m' \<noteq> 0" and nnz': "n'\<noteq> 0" by auto
  5204  from ts'_U Up have mnz': "m' \<noteq> 0" and nnz': "n'\<noteq> 0" by auto
  5205  let ?st' = "Add (Mul m' t') (Mul n' s')"
  5205  let ?st' = "Add (Mul m' t') (Mul n' s')"
  5206    have st': "(?N t' / real n' + ?N s' / real m')/2 = ?N ?st' / real (2*n'*m')"
  5206    have st': "(?N t' / real n' + ?N s' / real m')/2 = ?N ?st' / real (2*n'*m')"
  5207    using mnz' nnz' by (simp add: ring_simps add_divide_distrib)
  5207    using mnz' nnz' by (simp add: algebra_simps add_divide_distrib)
  5208  from Pts' have 
  5208  from Pts' have 
  5209    "(Inum (x # bs) t / real n + Inum (x # bs) s / real m)/2 = (Inum (x # bs) t' / real n' + Inum (x # bs) s' / real m')/2" by simp
  5209    "(Inum (x # bs) t / real n + Inum (x # bs) s / real m)/2 = (Inum (x # bs) t' / real n' + Inum (x # bs) s' / real m')/2" by simp
  5210  also have "\<dots> = ((\<lambda>(t, n). Inum (x # bs) t / real n) ((\<lambda>((t, n), s, m). (Add (Mul m t) (Mul n s), 2 * n * m)) ((t',n'),(s',m'))))" by (simp add: st')
  5210  also have "\<dots> = ((\<lambda>(t, n). Inum (x # bs) t / real n) ((\<lambda>((t, n), s, m). (Add (Mul m t) (Mul n s), 2 * n * m)) ((t',n'),(s',m'))))" by (simp add: st')
  5211  finally show "(Inum (x # bs) t / real n + Inum (x # bs) s / real m) / 2
  5211  finally show "(Inum (x # bs) t / real n + Inum (x # bs) s / real m) / 2
  5212           \<in> (\<lambda>(t, n). Inum (x # bs) t / real n) `
  5212           \<in> (\<lambda>(t, n). Inum (x # bs) t / real n) `
  5232   let ?st= "Add (Mul m t) (Mul n s)"
  5232   let ?st= "Add (Mul m t) (Mul n s)"
  5233   from mult_pos_pos[OF np mp] have mnp: "real (2*n*m) > 0" 
  5233   from mult_pos_pos[OF np mp] have mnp: "real (2*n*m) > 0" 
  5234       by (simp add: mult_commute real_of_int_mult[symmetric] del: real_of_int_mult)
  5234       by (simp add: mult_commute real_of_int_mult[symmetric] del: real_of_int_mult)
  5235     from tnb snb have stnb: "numbound0 ?st" by simp
  5235     from tnb snb have stnb: "numbound0 ?st" by simp
  5236   have st: "(?N t / real n + ?N s / real m)/2 = ?N ?st / real (2*n*m)"
  5236   have st: "(?N t / real n + ?N s / real m)/2 = ?N ?st / real (2*n*m)"
  5237    using mp np by (simp add: ring_simps add_divide_distrib)
  5237    using mp np by (simp add: algebra_simps add_divide_distrib)
  5238   from tnU smU UU' have "?g ((t,n),(s,m)) \<in> ?f ` U'" by blast
  5238   from tnU smU UU' have "?g ((t,n),(s,m)) \<in> ?f ` U'" by blast
  5239   hence "\<exists> (t',n') \<in> U'. ?g ((t,n),(s,m)) = ?f (t',n')"
  5239   hence "\<exists> (t',n') \<in> U'. ?g ((t,n),(s,m)) = ?f (t',n')"
  5240     by auto (rule_tac x="(a,b)" in bexI, auto)
  5240     by auto (rule_tac x="(a,b)" in bexI, auto)
  5241   then obtain t' n' where tnU': "(t',n') \<in> U'" and th: "?g ((t,n),(s,m)) = ?f (t',n')" by blast
  5241   then obtain t' n' where tnU': "(t',n') \<in> U'" and th: "?g ((t,n),(s,m)) = ?f (t',n')" by blast
  5242   from U' tnU' have tnb': "numbound0 t'" and np': "real n' > 0" by auto
  5242   from U' tnU' have tnb': "numbound0 t'" and np': "real n' > 0" by auto
  5260   let ?st= "Add (Mul m t) (Mul n s)"
  5260   let ?st= "Add (Mul m t) (Mul n s)"
  5261   from mult_pos_pos[OF np mp] have mnp: "real (2*n*m) > 0" 
  5261   from mult_pos_pos[OF np mp] have mnp: "real (2*n*m) > 0" 
  5262       by (simp add: mult_commute real_of_int_mult[symmetric] del: real_of_int_mult)
  5262       by (simp add: mult_commute real_of_int_mult[symmetric] del: real_of_int_mult)
  5263     from tnb snb have stnb: "numbound0 ?st" by simp
  5263     from tnb snb have stnb: "numbound0 ?st" by simp
  5264   have st: "(?N t / real n + ?N s / real m)/2 = ?N ?st / real (2*n*m)"
  5264   have st: "(?N t / real n + ?N s / real m)/2 = ?N ?st / real (2*n*m)"
  5265    using mp np by (simp add: ring_simps add_divide_distrib)
  5265    using mp np by (simp add: algebra_simps add_divide_distrib)
  5266   from U' tnU' have tnb': "numbound0 t'" and np': "real n' > 0" by auto
  5266   from U' tnU' have tnb': "numbound0 t'" and np': "real n' > 0" by auto
  5267   from \<upsilon>_I[OF lp np' tnb', where bs="bs" and x="x",simplified th[simplified split_def fst_conv snd_conv] st] Pt'
  5267   from \<upsilon>_I[OF lp np' tnb', where bs="bs" and x="x",simplified th[simplified split_def fst_conv snd_conv] st] Pt'
  5268   have Pst2: "Ifm (Inum (x # bs) (Add (Mul m t) (Mul n s)) / real (2 * n * m) # bs) p" by simp
  5268   have Pst2: "Ifm (Inum (x # bs) (Add (Mul m t) (Mul n s)) / real (2 * n * m) # bs) p" by simp
  5269   with \<upsilon>_I[OF lp mnp stnb, where x="x" and bs="bs"] tnU smU show ?lhs by blast
  5269   with \<upsilon>_I[OF lp mnp stnb, where x="x" and bs="bs"] tnU smU show ?lhs by blast
  5270 qed
  5270 qed