equal
deleted
inserted
replaced
1 (* A formalization of quantifier elimination for Presburger arithmetic*) |
1 (* Title: HOL/ex/PresburgerEx.thy |
2 (* based on a generic quantifier elimination algorithm and |
2 ID: $Id$ |
3 cooper's methos to eliminate on \<exists> *) |
3 Author: Amine Chaieb, TU Muenchen |
|
4 |
|
5 A formalization of quantifier elimination for Presburger arithmetic |
|
6 based on a generic quantifier elimination algorithm and Cooper's |
|
7 methos to eliminate on \<exists>. *) |
|
8 |
|
9 header {* Quantifier elimination for Presburger arithmetic *} |
4 |
10 |
5 theory Reflected_Presburger |
11 theory Reflected_Presburger |
6 imports Main |
12 imports Main |
7 (* uses ("rcooper.ML") ("rpresbtac.ML") *) |
|
8 begin |
13 begin |
9 |
14 |
10 (* Shadow syntax for integer terms *) |
15 (* Shadow syntax for integer terms *) |
11 datatype intterm = |
16 datatype intterm = |
12 Cst int |
17 Cst int |
2049 assumes lpos: "(0::int) < l" |
2054 assumes lpos: "(0::int) < l" |
2050 and inz: "i \<noteq> 0" |
2055 and inz: "i \<noteq> 0" |
2051 and dvd: "i dvd l" |
2056 and dvd: "i dvd l" |
2052 shows "(i*x + r = 0) = (l*x + ((l div i)*r) = 0)" |
2057 shows "(i*x + r = 0) = (l*x + ((l div i)*r) = 0)" |
2053 proof- |
2058 proof- |
2054 thm dvd_div_pos[OF lpos inz dvd] |
|
2055 have ldvdii: "(l div i)*i = l" by (rule dvd_div_pos[OF lpos inz dvd]) |
2059 have ldvdii: "(l div i)*i = l" by (rule dvd_div_pos[OF lpos inz dvd]) |
2056 have ldivinz: "l div i \<noteq> 0" using inz ldvdii lpos by auto |
2060 have ldivinz: "l div i \<noteq> 0" using inz ldvdii lpos by auto |
2057 have "(i*x + r = 0) = ((l div i)*(i*x + r) = (l div i)*0)" |
2061 have "(i*x + r = 0) = ((l div i)*(i*x + r) = (l div i)*0)" |
2058 using ldivinz by arith |
2062 using ldivinz by arith |
2059 also have "\<dots> = (((l div i)*i)*x + (l div i)*r = 0)" |
2063 also have "\<dots> = (((l div i)*i)*x + (l div i)*r = 0)" |
2222 moreover |
2226 moreover |
2223 { |
2227 { |
2224 assume nz: "n=0" |
2228 assume nz: "n=0" |
2225 from prems have inz: "i \<noteq> 0" by auto |
2229 from prems have inz: "i \<noteq> 0" by auto |
2226 from prems nz have idvdl: "i dvd l" by simp |
2230 from prems nz have idvdl: "i dvd l" by simp |
2227 thm adjustcoeff_eq_corr[OF lpos inz idvdl] |
|
2228 have "(i * a + (i' * (a # ats) ! n' + I_intterm (a # ats) r) = 0) = |
2231 have "(i * a + (i' * (a # ats) ! n' + I_intterm (a # ats) r) = 0) = |
2229 (l * a + l div i * (i' * (a # ats) ! n' + I_intterm (a # ats) r) = 0)" |
2232 (l * a + l div i * (i' * (a # ats) ! n' + I_intterm (a # ats) r) = 0)" |
2230 by (rule adjustcoeff_eq_corr[OF lpos inz idvdl]) |
2233 by (rule adjustcoeff_eq_corr[OF lpos inz idvdl]) |
2231 then |
2234 then |
2232 have ?thesis using prems linr linr2 |
2235 have ?thesis using prems linr linr2 |
2698 (* divlcm is correct *) |
2701 (* divlcm is correct *) |
2699 lemma divlcm_corr: |
2702 lemma divlcm_corr: |
2700 assumes |
2703 assumes |
2701 linp: "islinform p" |
2704 linp: "islinform p" |
2702 shows "alldivide (divlcm p,p)" |
2705 shows "alldivide (divlcm p,p)" |
2703 thm nz_le[OF divlcm_pos[OF linp]] |
|
2704 using linp divlcm_pos |
2706 using linp divlcm_pos |
2705 proof (induct p rule: divlcm.induct,simp_all add: zdvd_refl_abs,clarsimp simp add: Nat.gr0_conv_Suc) |
2707 proof (induct p rule: divlcm.induct,simp_all add: zdvd_refl_abs,clarsimp simp add: Nat.gr0_conv_Suc) |
2706 case (goal1 f) |
2708 case (goal1 f) |
2707 have "islinform f" using prems |
2709 have "islinform f" using prems |
2708 by (cases f, auto) (case_tac "intterm2", auto,case_tac "intterm1", auto) |
2710 by (cases f, auto) (case_tac "intterm2", auto,case_tac "intterm1", auto) |
5720 use "rcooper.ML" |
5722 use "rcooper.ML" |
5721 oracle rpresburger_oracle ("term") = RCooper.rpresburger_oracle |
5723 oracle rpresburger_oracle ("term") = RCooper.rpresburger_oracle |
5722 use "rpresbtac.ML" |
5724 use "rpresbtac.ML" |
5723 setup RPresburger.setup |
5725 setup RPresburger.setup |
5724 *) |
5726 *) |
|
5727 |
5725 end |
5728 end |