author | wenzelm |
Wed, 01 Sep 2010 17:59:06 +0200 | |
changeset 38975 | ef13a2cc97be |
parent 38558 | 32ad17fe2b9c |
child 39159 | 0dec18004e75 |
permissions | -rw-r--r-- |
30439 | 1 |
(* Title: HOL/Decision_Procs/mir_tac.ML |
23858 | 2 |
Author: Amine Chaieb, TU Muenchen |
3 |
*) |
|
4 |
||
31240 | 5 |
signature MIR_TAC = |
6 |
sig |
|
32740 | 7 |
val trace: bool Unsynchronized.ref |
31240 | 8 |
val mir_tac: Proof.context -> bool -> int -> tactic |
9 |
val setup: theory -> theory |
|
10 |
end |
|
11 |
||
29788 | 12 |
structure Mir_Tac = |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
13 |
struct |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
14 |
|
32740 | 15 |
val trace = Unsynchronized.ref false; |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
16 |
fun trace_msg s = if !trace then tracing s else (); |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
17 |
|
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
18 |
val mir_ss = |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
19 |
let val ths = map thm ["real_of_int_inject", "real_of_int_less_iff", "real_of_int_le_iff"] |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
20 |
in @{simpset} delsimps ths addsimps (map (fn th => th RS sym) ths) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
21 |
end; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
22 |
|
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
23 |
val nT = HOLogic.natT; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
24 |
val nat_arith = map thm ["add_nat_number_of", "diff_nat_number_of", |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
25 |
"mult_nat_number_of", "eq_nat_number_of", "less_nat_number_of"]; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
26 |
|
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
27 |
val comp_arith = (map thm ["Let_def", "if_False", "if_True", "add_0", |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
28 |
"add_Suc", "add_number_of_left", "mult_number_of_left", |
31790 | 29 |
"Suc_eq_plus1"])@ |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
30 |
(map (fn s => thm s RS sym) ["numeral_1_eq_1", "numeral_0_eq_0"]) |
25481 | 31 |
@ @{thms arith_simps} @ nat_arith @ @{thms rel_simps} |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
32 |
val ths = [@{thm "mult_numeral_1"}, @{thm "mult_numeral_1_right"}, |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
33 |
@{thm "real_of_nat_number_of"}, |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
34 |
@{thm "real_of_nat_Suc"}, @{thm "real_of_nat_one"}, @{thm "real_of_one"}, |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
35 |
@{thm "real_of_int_zero"}, @{thm "real_of_nat_zero"}, |
36308 | 36 |
@{thm "divide_zero"}, |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
37 |
@{thm "divide_divide_eq_left"}, @{thm "times_divide_eq_right"}, |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
38 |
@{thm "times_divide_eq_left"}, @{thm "divide_divide_eq_right"}, |
37887 | 39 |
@{thm "diff_minus"}, @{thm "minus_divide_left"}] |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
40 |
val comp_ths = ths @ comp_arith @ simp_thms |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
41 |
|
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
42 |
|
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
43 |
val zdvd_int = @{thm "zdvd_int"}; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
44 |
val zdiff_int_split = @{thm "zdiff_int_split"}; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
45 |
val all_nat = @{thm "all_nat"}; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
46 |
val ex_nat = @{thm "ex_nat"}; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
47 |
val number_of1 = @{thm "number_of1"}; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
48 |
val number_of2 = @{thm "number_of2"}; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
49 |
val split_zdiv = @{thm "split_zdiv"}; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
50 |
val split_zmod = @{thm "split_zmod"}; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
51 |
val mod_div_equality' = @{thm "mod_div_equality'"}; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
52 |
val split_div' = @{thm "split_div'"}; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
53 |
val imp_le_cong = @{thm "imp_le_cong"}; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
54 |
val conj_le_cong = @{thm "conj_le_cong"}; |
30224 | 55 |
val mod_add_eq = @{thm "mod_add_eq"} RS sym; |
30034 | 56 |
val mod_add_left_eq = @{thm "mod_add_left_eq"} RS sym; |
57 |
val mod_add_right_eq = @{thm "mod_add_right_eq"} RS sym; |
|
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
58 |
val nat_div_add_eq = @{thm "div_add1_eq"} RS sym; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
59 |
val int_div_add_eq = @{thm "zdiv_zadd1_eq"} RS sym; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
60 |
val ZDIVISION_BY_ZERO_MOD = @{thm "DIVISION_BY_ZERO"} RS conjunct2; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
61 |
val ZDIVISION_BY_ZERO_DIV = @{thm "DIVISION_BY_ZERO"} RS conjunct1; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
62 |
|
27456 | 63 |
fun prepare_for_mir thy q fm = |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
64 |
let |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
65 |
val ps = Logic.strip_params fm |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
66 |
val hs = map HOLogic.dest_Trueprop (Logic.strip_assums_hyp fm) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
67 |
val c = HOLogic.dest_Trueprop (Logic.strip_assums_concl fm) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
68 |
fun mk_all ((s, T), (P,n)) = |
36692
54b64d4ad524
farewell to old-style mem infixes -- type inference in situations with mem_int and mem_string should provide enough information to resolve the type of (op =)
haftmann
parents:
36308
diff
changeset
|
69 |
if member (op =) (loose_bnos P) 0 then |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
70 |
(HOLogic.all_const T $ Abs (s, T, P), n) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
71 |
else (incr_boundvars ~1 P, n-1) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
72 |
fun mk_all2 (v, t) = HOLogic.all_const (fastype_of v) $ lambda v t; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
73 |
val rhs = hs |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
74 |
(* val (rhs,irhs) = List.partition (relevant (rev ps)) hs *) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
75 |
val np = length ps |
33004
715566791eb0
always qualify NJ's old List.foldl/foldr in Isabelle/ML;
wenzelm
parents:
32740
diff
changeset
|
76 |
val (fm',np) = List.foldr (fn ((x, T), (fm,n)) => mk_all ((x, T), (fm,n))) |
715566791eb0
always qualify NJ's old List.foldl/foldr in Isabelle/ML;
wenzelm
parents:
32740
diff
changeset
|
77 |
(List.foldr HOLogic.mk_imp c rhs, np) ps |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
78 |
val (vs, _) = List.partition (fn t => q orelse (type_of t) = nT) |
29265
5b4247055bd7
moved old add_term_vars, add_term_frees etc. to structure OldTerm;
wenzelm
parents:
28952
diff
changeset
|
79 |
(OldTerm.term_frees fm' @ OldTerm.term_vars fm'); |
33004
715566791eb0
always qualify NJ's old List.foldl/foldr in Isabelle/ML;
wenzelm
parents:
32740
diff
changeset
|
80 |
val fm2 = List.foldr mk_all2 fm' vs |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
81 |
in (fm2, np + length vs, length rhs) end; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
82 |
|
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
83 |
(*Object quantifier to meta --*) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
84 |
fun spec_step n th = if (n=0) then th else (spec_step (n-1) th) RS spec ; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
85 |
|
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
86 |
(* object implication to meta---*) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
87 |
fun mp_step n th = if (n=0) then th else (mp_step (n-1) th) RS mp; |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
88 |
|
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
89 |
|
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
90 |
fun mir_tac ctxt q i = |
35625 | 91 |
Object_Logic.atomize_prems_tac i |
31240 | 92 |
THEN simp_tac (HOL_basic_ss addsimps [@{thm "abs_ge_zero"}] addsimps simp_thms) i |
93 |
THEN REPEAT_DETERM (split_tac [@{thm "split_min"}, @{thm "split_max"}, @{thm "abs_split"}] i) |
|
28290 | 94 |
THEN (fn st => |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
95 |
let |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
96 |
val g = List.nth (prems_of st, i - 1) |
27456 | 97 |
val thy = ProofContext.theory_of ctxt |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
98 |
(* Transform the term*) |
27456 | 99 |
val (t,np,nh) = prepare_for_mir thy q g |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
100 |
(* Some simpsets for dealing with mod div abs and nat*) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
101 |
val mod_div_simpset = HOL_basic_ss |
30224 | 102 |
addsimps [refl, mod_add_eq, |
28290 | 103 |
@{thm "mod_self"}, @{thm "zmod_self"}, |
104 |
@{thm "zdiv_zero"},@{thm "zmod_zero"},@{thm "div_0"}, @{thm "mod_0"}, |
|
30031 | 105 |
@{thm "div_by_1"}, @{thm "mod_by_1"}, @{thm "div_1"}, @{thm "mod_1"}, |
31790 | 106 |
@{thm "Suc_eq_plus1"}] |
28290 | 107 |
addsimps @{thms add_ac} |
30939 | 108 |
addsimprocs [cancel_div_mod_nat_proc, cancel_div_mod_int_proc] |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
109 |
val simpset0 = HOL_basic_ss |
31790 | 110 |
addsimps [mod_div_equality', @{thm Suc_eq_plus1}] |
23318 | 111 |
addsimps comp_ths |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
112 |
addsplits [@{thm "split_zdiv"}, @{thm "split_zmod"}, @{thm "split_div'"}, @{thm "split_min"}, @{thm "split_max"}] |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
113 |
(* Simp rules for changing (n::int) to int n *) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
114 |
val simpset1 = HOL_basic_ss |
23381 | 115 |
addsimps [@{thm "nat_number_of_def"}, @{thm "zdvd_int"}] @ map (fn r => r RS sym) |
116 |
[@{thm "int_int_eq"}, @{thm "zle_int"}, @{thm "zless_int"}, @{thm "zadd_int"}, |
|
117 |
@{thm "zmult_int"}] |
|
118 |
addsplits [@{thm "zdiff_int_split"}] |
|
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
119 |
(*simp rules for elimination of int n*) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
120 |
|
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
121 |
val simpset2 = HOL_basic_ss |
23381 | 122 |
addsimps [@{thm "nat_0_le"}, @{thm "all_nat"}, @{thm "ex_nat"}, @{thm "number_of1"}, |
123 |
@{thm "number_of2"}, @{thm "int_0"}, @{thm "int_1"}] |
|
124 |
addcongs [@{thm "conj_le_cong"}, @{thm "imp_le_cong"}] |
|
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
125 |
(* simp rules for elimination of abs *) |
27456 | 126 |
val ct = cterm_of thy (HOLogic.mk_Trueprop t) |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
127 |
(* Theorem for the nat --> int transformation *) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
128 |
val pre_thm = Seq.hd (EVERY |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
129 |
[simp_tac mod_div_simpset 1, simp_tac simpset0 1, |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
130 |
TRY (simp_tac simpset1 1), TRY (simp_tac simpset2 1), TRY (simp_tac mir_ss 1)] |
36945 | 131 |
(Thm.trivial ct)) |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
132 |
fun assm_tac i = REPEAT_DETERM_N nh (assume_tac i) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
133 |
(* The result of the quantifier elimination *) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
134 |
val (th, tac) = case (prop_of pre_thm) of |
38558 | 135 |
Const ("==>", _) $ (Const (@{const_name Trueprop}, _) $ t1) $ _ => |
28290 | 136 |
let val pth = |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
137 |
(* If quick_and_dirty then run without proof generation as oracle*) |
28290 | 138 |
if !quick_and_dirty |
139 |
then mirfr_oracle (false, cterm_of thy (Pattern.eta_long [] t1)) |
|
140 |
else mirfr_oracle (true, cterm_of thy (Pattern.eta_long [] t1)) |
|
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
141 |
in |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
142 |
(trace_msg ("calling procedure with term:\n" ^ |
26939
1035c89b4c02
moved global pretty/string_of functions from Sign to Syntax;
wenzelm
parents:
25481
diff
changeset
|
143 |
Syntax.string_of_term ctxt t1); |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
144 |
((pth RS iffD2) RS pre_thm, |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
145 |
assm_tac (i + 1) THEN (if q then I else TRY) (rtac TrueI i))) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
146 |
end |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
147 |
| _ => (pre_thm, assm_tac i) |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
148 |
in (rtac (((mp_step nh) o (spec_step np)) th) i |
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
149 |
THEN tac) st |
27456 | 150 |
end handle Subscript => no_tac st); |
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
151 |
|
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
152 |
val setup = |
31240 | 153 |
Method.setup @{binding mir} |
154 |
let |
|
155 |
val parse_flag = Args.$$$ "no_quantify" >> K (K false) |
|
156 |
in |
|
157 |
Scan.lift (Scan.optional (Args.$$$ "(" |-- Scan.repeat1 parse_flag --| Args.$$$ ")") [] >> |
|
158 |
curry (Library.foldl op |>) true) >> |
|
159 |
(fn q => fn ctxt => SIMPLE_METHOD' (mir_tac ctxt q)) |
|
160 |
end |
|
161 |
"decision procedure for MIR arithmetic"; |
|
23264
324622260d29
Added twe Examples for Quantifier elimination ofer linear real arithmetic and over the mixed theory of linear real artihmetic with integers
chaieb
parents:
diff
changeset
|
162 |
|
23590
ad95084a5c63
renamed ObjectLogic.atomize_tac to ObjectLogic.atomize_prems_tac;
wenzelm
parents:
23381
diff
changeset
|
163 |
end |