src/HOL/ex/Reflected_Presburger.thy
changeset 23515 3e7f62e68fe4
parent 23477 f4b83f03cac9
child 23689 0410269099dc
equal deleted inserted replaced
23514:25e69e56355d 23515:3e7f62e68fe4
     1 theory Reflected_Presburger
     1 theory Reflected_Presburger
     2 imports GCD Main EfficientNat
     2 imports GCD EfficientNat
     3 uses ("coopereif.ML") ("coopertac.ML")
     3 uses ("coopereif.ML") ("coopertac.ML")
     4 begin
     4 begin
     5 
     5 
     6 lemma allpairs_set: "set (allpairs Pair xs ys) = {(x,y). x\<in> set xs \<and> y \<in> set ys}"
     6 lemma allpairs_set: "set (allpairs Pair xs ys) = {(x,y). x\<in> set xs \<and> y \<in> set ys}"
     7 by (induct xs) auto
     7 by (induct xs) auto
  1900 constdefs pa:: "fm \<Rightarrow> fm"
  1900 constdefs pa:: "fm \<Rightarrow> fm"
  1901   "pa \<equiv> (\<lambda> p. qelim (prep p) cooper)"
  1901   "pa \<equiv> (\<lambda> p. qelim (prep p) cooper)"
  1902 
  1902 
  1903 theorem mirqe: "(Ifm bbs bs (pa p) = Ifm bbs bs p) \<and> qfree (pa p)"
  1903 theorem mirqe: "(Ifm bbs bs (pa p) = Ifm bbs bs p) \<and> qfree (pa p)"
  1904   using qelim_ci cooper prep by (auto simp add: pa_def)
  1904   using qelim_ci cooper prep by (auto simp add: pa_def)
  1905 declare zdvd_iff_zmod_eq_0 [code]
  1905 
  1906 
  1906 definition
  1907 code_module GeneratedCooper
  1907   cooper_test :: "unit \<Rightarrow> fm"
  1908 file "generated_cooper.ML"
  1908 where
  1909 contains pa = "pa"
  1909   "cooper_test u = pa (E (A (Imp (Ge (Sub (Bound 0) (Bound 1)))
  1910 test = "%x . pa (E(A(Imp (Ge (Sub (Bound 0) (Bound 1))) (E(E(Eq(Sub(Add(Mul 3 (Bound 1)) (Mul 5 (Bound 0))) (Bound 2))))))))"
  1910     (E (E (Eq (Sub (Add (Mul 3 (Bound 1)) (Mul 5 (Bound 0)))
  1911 
  1911       (Bound 2))))))))"
  1912 ML{* use "generated_cooper.ML"; 
  1912 
  1913      GeneratedCooper.test (); *}
  1913 code_gen pa cooper_test in SML
       
  1914 
       
  1915 ML {* structure GeneratedCooper = struct open ROOT end *}
       
  1916 ML {* GeneratedCooper.Reflected_Presburger.cooper_test () *}
  1914 use "coopereif.ML"
  1917 use "coopereif.ML"
  1915 oracle linzqe_oracle ("term") = Coopereif.cooper_oracle
  1918 oracle linzqe_oracle ("term") = Coopereif.cooper_oracle
  1916 use"coopertac.ML"
  1919 use "coopertac.ML"
  1917 setup "LinZTac.setup"
  1920 setup "LinZTac.setup"
  1918 
  1921 
  1919   (* Tests *)
  1922   (* Tests *)
  1920 lemma "\<exists> (j::int). \<forall> x\<ge>j. (\<exists> a b. x = 3*a+5*b)"
  1923 lemma "\<exists> (j::int). \<forall> x\<ge>j. (\<exists> a b. x = 3*a+5*b)"
  1921 by cooper
  1924 by cooper