author | boehmes |
Wed, 12 May 2010 23:54:04 +0200 | |
changeset 36899 | bcd6fce5bf06 |
parent 36898 | 8e55aa1306c5 |
child 36936 | c52d1c130898 |
permissions | -rw-r--r-- |
36898 | 1 |
(* Title: HOL/Tools/SMT/z3_proof_tools.ML |
2 |
Author: Sascha Boehme, TU Muenchen |
|
3 |
||
4 |
Helper functions required for Z3 proof reconstruction. |
|
5 |
*) |
|
6 |
||
7 |
signature Z3_PROOF_TOOLS = |
|
8 |
sig |
|
9 |
(* accessing and modifying terms *) |
|
10 |
val term_of: cterm -> term |
|
11 |
val prop_of: thm -> term |
|
12 |
val mk_prop: cterm -> cterm |
|
13 |
val as_meta_eq: cterm -> cterm |
|
14 |
||
15 |
(* theorem nets *) |
|
16 |
val thm_net_of: thm list -> thm Net.net |
|
17 |
val net_instance: thm Net.net -> cterm -> thm option |
|
18 |
||
19 |
(* proof combinators *) |
|
20 |
val under_assumption: (thm -> thm) -> cterm -> thm |
|
21 |
val with_conv: conv -> (cterm -> thm) -> cterm -> thm |
|
22 |
val discharge: thm -> thm -> thm |
|
23 |
val varify: string list -> thm -> thm |
|
24 |
val unfold_eqs: Proof.context -> thm list -> conv |
|
25 |
val match_instantiate: (cterm -> cterm) -> cterm -> thm -> thm |
|
26 |
val by_tac: (int -> tactic) -> cterm -> thm |
|
27 |
val make_hyp_def: thm -> Proof.context -> thm * Proof.context |
|
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
28 |
val by_abstraction: bool * bool -> Proof.context -> thm list -> |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
29 |
(Proof.context -> cterm -> thm) -> cterm -> thm |
36898 | 30 |
|
31 |
(* a faster COMP *) |
|
32 |
type compose_data |
|
33 |
val precompose: (cterm -> cterm list) -> thm -> compose_data |
|
34 |
val precompose2: (cterm -> cterm * cterm) -> thm -> compose_data |
|
35 |
val compose: compose_data -> thm -> thm |
|
36 |
||
37 |
(* unfolding of 'distinct' *) |
|
38 |
val unfold_distinct_conv: conv |
|
39 |
||
40 |
(* simpset *) |
|
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
41 |
val add_simproc: Simplifier.simproc -> Context.generic -> Context.generic |
36898 | 42 |
val make_simpset: Proof.context -> thm list -> simpset |
43 |
end |
|
44 |
||
45 |
structure Z3_Proof_Tools: Z3_PROOF_TOOLS = |
|
46 |
struct |
|
47 |
||
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
48 |
structure I = Z3_Interface |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
49 |
|
36898 | 50 |
|
51 |
||
52 |
(* accessing terms *) |
|
53 |
||
54 |
val dest_prop = (fn @{term Trueprop} $ t => t | t => t) |
|
55 |
||
56 |
fun term_of ct = dest_prop (Thm.term_of ct) |
|
57 |
fun prop_of thm = dest_prop (Thm.prop_of thm) |
|
58 |
||
59 |
val mk_prop = Thm.capply @{cterm Trueprop} |
|
60 |
||
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
61 |
val eq = I.mk_inst_pair I.destT1 @{cpat "op =="} |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
62 |
fun mk_meta_eq_cterm ct cu = Thm.mk_binop (I.instT' ct eq) ct cu |
36898 | 63 |
|
64 |
fun as_meta_eq ct = uncurry mk_meta_eq_cterm (Thm.dest_binop (Thm.dest_arg ct)) |
|
65 |
||
66 |
||
67 |
||
68 |
(* theorem nets *) |
|
69 |
||
70 |
fun thm_net_of thms = |
|
71 |
let fun insert thm = Net.insert_term (K false) (Thm.prop_of thm, thm) |
|
72 |
in fold insert thms Net.empty end |
|
73 |
||
74 |
fun maybe_instantiate ct thm = |
|
75 |
try Thm.first_order_match (Thm.cprop_of thm, ct) |
|
76 |
|> Option.map (fn inst => Thm.instantiate inst thm) |
|
77 |
||
78 |
fun first_of thms ct = get_first (maybe_instantiate ct) thms |
|
79 |
fun net_instance net ct = first_of (Net.match_term net (Thm.term_of ct)) ct |
|
80 |
||
81 |
||
82 |
||
83 |
(* proof combinators *) |
|
84 |
||
85 |
fun under_assumption f ct = |
|
86 |
let val ct' = mk_prop ct |
|
87 |
in Thm.implies_intr ct' (f (Thm.assume ct')) end |
|
88 |
||
89 |
fun with_conv conv prove ct = |
|
90 |
let val eq = Thm.symmetric (conv ct) |
|
91 |
in Thm.equal_elim eq (prove (Thm.lhs_of eq)) end |
|
92 |
||
93 |
fun discharge p pq = Thm.implies_elim pq p |
|
94 |
||
95 |
fun varify vars = Drule.generalize ([], vars) |
|
96 |
||
97 |
fun unfold_eqs _ [] = Conv.all_conv |
|
98 |
| unfold_eqs ctxt eqs = |
|
99 |
More_Conv.top_sweep_conv (K (More_Conv.rewrs_conv eqs)) ctxt |
|
100 |
||
101 |
fun match_instantiate f ct thm = |
|
102 |
Thm.instantiate (Thm.match (f (Thm.cprop_of thm), ct)) thm |
|
103 |
||
104 |
fun by_tac tac ct = Goal.norm_result (Goal.prove_internal [] ct (K (tac 1))) |
|
105 |
||
106 |
(* |- c x == t x ==> P (c x) ~~> c == t |- P (c x) *) |
|
107 |
fun make_hyp_def thm ctxt = |
|
108 |
let |
|
109 |
val (lhs, rhs) = Thm.dest_binop (Thm.cprem_of thm 1) |
|
110 |
val (cf, cvs) = Drule.strip_comb lhs |
|
111 |
val eq = mk_meta_eq_cterm cf (fold_rev Thm.cabs cvs rhs) |
|
112 |
fun apply cv th = |
|
113 |
Thm.combination th (Thm.reflexive cv) |
|
114 |
|> Conv.fconv_rule (Conv.arg_conv (Thm.beta_conversion false)) |
|
115 |
in |
|
116 |
yield_singleton Assumption.add_assumes eq ctxt |
|
117 |
|>> Thm.implies_elim thm o fold apply cvs |
|
118 |
end |
|
119 |
||
120 |
||
121 |
||
122 |
(* abstraction *) |
|
123 |
||
124 |
local |
|
125 |
||
126 |
fun typ_of ct = #T (Thm.rep_cterm ct) |
|
127 |
fun certify ctxt = Thm.cterm_of (ProofContext.theory_of ctxt) |
|
128 |
||
129 |
fun abs_context ctxt = (ctxt, Termtab.empty, 1, false) |
|
130 |
||
131 |
fun context_of (ctxt, _, _, _) = ctxt |
|
132 |
||
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
133 |
fun replace (_, (cv, ct)) = Thm.forall_elim ct o Thm.forall_intr cv |
36898 | 134 |
|
135 |
fun abs_instantiate (_, tab, _, beta_norm) = |
|
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
136 |
fold replace (Termtab.dest tab) #> |
36898 | 137 |
beta_norm ? Conv.fconv_rule (Thm.beta_conversion true) |
138 |
||
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
139 |
fun lambda_abstract cvs t = |
36898 | 140 |
let |
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
141 |
val frees = map Free (Term.add_frees t []) |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
142 |
val cvs' = filter (fn cv => member (op aconv) frees (Thm.term_of cv)) cvs |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
143 |
val vs = map (Term.dest_Free o Thm.term_of) cvs' |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
144 |
in (Term.list_abs_free (vs, t), cvs') end |
36898 | 145 |
|
146 |
fun fresh_abstraction cvs ct (cx as (ctxt, tab, idx, beta_norm)) = |
|
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
147 |
let val (t, cvs') = lambda_abstract cvs (Thm.term_of ct) |
36898 | 148 |
in |
149 |
(case Termtab.lookup tab t of |
|
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
150 |
SOME (cv, _) => (Drule.list_comb (cv, cvs'), cx) |
36898 | 151 |
| NONE => |
152 |
let |
|
153 |
val (n, ctxt') = yield_singleton Variable.variant_fixes "x" ctxt |
|
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
154 |
val cv = certify ctxt' (Free (n, map typ_of cvs' ---> typ_of ct)) |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
155 |
val cu = Drule.list_comb (cv, cvs') |
36898 | 156 |
val e = (t, (cv, fold_rev Thm.cabs cvs' ct)) |
157 |
val beta_norm' = beta_norm orelse not (null cvs') |
|
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
158 |
in (cu, (ctxt', Termtab.update e tab, idx + 1, beta_norm')) end) |
36898 | 159 |
end |
160 |
||
161 |
fun abs_comb f g cvs ct = |
|
162 |
let val (cf, cu) = Thm.dest_comb ct |
|
163 |
in f cvs cf ##>> g cvs cu #>> uncurry Thm.capply end |
|
164 |
||
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
165 |
fun abs_arg f = abs_comb (K pair) f |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
166 |
|
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
167 |
fun abs_args f cvs ct = |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
168 |
(case Thm.term_of ct of |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
169 |
_ $ _ => abs_comb (abs_args f) f cvs ct |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
170 |
| _ => pair ct) |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
171 |
|
36898 | 172 |
fun abs_list f g cvs ct = |
173 |
(case Thm.term_of ct of |
|
174 |
Const (@{const_name Nil}, _) => pair ct |
|
175 |
| Const (@{const_name Cons}, _) $ _ $ _ => |
|
176 |
abs_comb (abs_arg f) (abs_list f g) cvs ct |
|
177 |
| _ => g cvs ct) |
|
178 |
||
179 |
fun abs_abs f cvs ct = |
|
180 |
let val (cv, cu) = Thm.dest_abs NONE ct |
|
181 |
in f (cv :: cvs) cu #>> Thm.cabs cv end |
|
182 |
||
183 |
val is_atomic = (fn _ $ _ => false | Abs _ => false | _ => true) |
|
184 |
||
185 |
fun abstract (ext_logic, with_theories) = |
|
186 |
let |
|
187 |
fun abstr1 cvs ct = abs_arg abstr cvs ct |
|
188 |
and abstr2 cvs ct = abs_comb abstr1 abstr cvs ct |
|
189 |
and abstr3 cvs ct = abs_comb abstr2 abstr cvs ct |
|
190 |
and abstr_abs cvs ct = abs_arg (abs_abs abstr) cvs ct |
|
191 |
||
192 |
and abstr cvs ct = |
|
193 |
(case Thm.term_of ct of |
|
194 |
@{term Trueprop} $ _ => abstr1 cvs ct |
|
195 |
| @{term "op ==>"} $ _ $ _ => abstr2 cvs ct |
|
196 |
| @{term True} => pair ct |
|
197 |
| @{term False} => pair ct |
|
198 |
| @{term Not} $ _ => abstr1 cvs ct |
|
199 |
| @{term "op &"} $ _ $ _ => abstr2 cvs ct |
|
200 |
| @{term "op |"} $ _ $ _ => abstr2 cvs ct |
|
201 |
| @{term "op -->"} $ _ $ _ => abstr2 cvs ct |
|
202 |
| Const (@{const_name "op ="}, _) $ _ $ _ => abstr2 cvs ct |
|
203 |
| Const (@{const_name distinct}, _) $ _ => |
|
204 |
if ext_logic then abs_arg (abs_list abstr fresh_abstraction) cvs ct |
|
205 |
else fresh_abstraction cvs ct |
|
206 |
| Const (@{const_name If}, _) $ _ $ _ $ _ => |
|
207 |
if ext_logic then abstr3 cvs ct else fresh_abstraction cvs ct |
|
208 |
| Const (@{const_name All}, _) $ _ => |
|
209 |
if ext_logic then abstr_abs cvs ct else fresh_abstraction cvs ct |
|
210 |
| Const (@{const_name Ex}, _) $ _ => |
|
211 |
if ext_logic then abstr_abs cvs ct else fresh_abstraction cvs ct |
|
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
212 |
| t => (fn cx => |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
213 |
if is_atomic t orelse can HOLogic.dest_number t then (ct, cx) |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
214 |
else if with_theories andalso |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
215 |
I.is_builtin_theory_term (context_of cx) t |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
216 |
then abs_args abstr cvs ct cx |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
217 |
else fresh_abstraction cvs ct cx)) |
36898 | 218 |
in abstr [] end |
219 |
||
220 |
fun with_prems thms f ct = |
|
221 |
fold_rev (Thm.mk_binop @{cterm "op ==>"} o Thm.cprop_of) thms ct |
|
222 |
|> f |
|
223 |
|> fold (fn prem => fn th => Thm.implies_elim th prem) thms |
|
224 |
||
225 |
in |
|
226 |
||
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
227 |
fun by_abstraction mode ctxt thms prove = with_prems thms (fn ct => |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
228 |
let val (cu, cx) = abstract mode ct (abs_context ctxt) |
36898 | 229 |
in abs_instantiate cx (prove (context_of cx) cu) end) |
230 |
||
231 |
end |
|
232 |
||
233 |
||
234 |
||
235 |
(* a faster COMP *) |
|
236 |
||
237 |
type compose_data = cterm list * (cterm -> cterm list) * thm |
|
238 |
||
239 |
fun list2 (x, y) = [x, y] |
|
240 |
||
241 |
fun precompose f rule = (f (Thm.cprem_of rule 1), f, rule) |
|
242 |
fun precompose2 f rule = precompose (list2 o f) rule |
|
243 |
||
244 |
fun compose (cvs, f, rule) thm = |
|
245 |
discharge thm (Thm.instantiate ([], cvs ~~ f (Thm.cprop_of thm)) rule) |
|
246 |
||
247 |
||
248 |
||
249 |
(* unfolding of 'distinct' *) |
|
250 |
||
251 |
local |
|
252 |
val set1 = @{lemma "x ~: set [] == ~False" by simp} |
|
253 |
val set2 = @{lemma "x ~: set [x] == False" by simp} |
|
254 |
val set3 = @{lemma "x ~: set [y] == x ~= y" by simp} |
|
255 |
val set4 = @{lemma "x ~: set (x # ys) == False" by simp} |
|
256 |
val set5 = @{lemma "x ~: set (y # ys) == x ~= y & x ~: set ys" by simp} |
|
257 |
||
258 |
fun set_conv ct = |
|
259 |
(More_Conv.rewrs_conv [set1, set2, set3, set4] else_conv |
|
260 |
(Conv.rewr_conv set5 then_conv Conv.arg_conv set_conv)) ct |
|
261 |
||
262 |
val dist1 = @{lemma "distinct [] == ~False" by simp} |
|
263 |
val dist2 = @{lemma "distinct [x] == ~False" by simp} |
|
264 |
val dist3 = @{lemma "distinct (x # xs) == x ~: set xs & distinct xs" |
|
265 |
by simp} |
|
266 |
||
267 |
fun binop_conv cv1 cv2 = Conv.combination_conv (Conv.arg_conv cv1) cv2 |
|
268 |
in |
|
269 |
fun unfold_distinct_conv ct = |
|
270 |
(More_Conv.rewrs_conv [dist1, dist2] else_conv |
|
271 |
(Conv.rewr_conv dist3 then_conv binop_conv set_conv unfold_distinct_conv)) ct |
|
272 |
end |
|
273 |
||
274 |
||
275 |
||
276 |
(* simpset *) |
|
277 |
||
278 |
local |
|
279 |
val antisym_le1 = mk_meta_eq @{thm order_class.antisym_conv} |
|
280 |
val antisym_le2 = mk_meta_eq @{thm linorder_class.antisym_conv2} |
|
281 |
val antisym_less1 = mk_meta_eq @{thm linorder_class.antisym_conv1} |
|
282 |
val antisym_less2 = mk_meta_eq @{thm linorder_class.antisym_conv3} |
|
283 |
||
284 |
fun eq_prop t thm = HOLogic.mk_Trueprop t aconv Thm.prop_of thm |
|
285 |
fun dest_binop ((c as Const _) $ t $ u) = (c, t, u) |
|
286 |
| dest_binop t = raise TERM ("dest_binop", [t]) |
|
287 |
||
288 |
fun prove_antisym_le ss t = |
|
289 |
let |
|
290 |
val (le, r, s) = dest_binop t |
|
291 |
val less = Const (@{const_name less}, Term.fastype_of le) |
|
292 |
val prems = Simplifier.prems_of_ss ss |
|
293 |
in |
|
294 |
(case find_first (eq_prop (le $ s $ r)) prems of |
|
295 |
NONE => |
|
296 |
find_first (eq_prop (HOLogic.mk_not (less $ r $ s))) prems |
|
297 |
|> Option.map (fn thm => thm RS antisym_less1) |
|
298 |
| SOME thm => SOME (thm RS antisym_le1)) |
|
299 |
end |
|
300 |
handle THM _ => NONE |
|
301 |
||
302 |
fun prove_antisym_less ss t = |
|
303 |
let |
|
304 |
val (less, r, s) = dest_binop (HOLogic.dest_not t) |
|
305 |
val le = Const (@{const_name less_eq}, Term.fastype_of less) |
|
306 |
val prems = prems_of_ss ss |
|
307 |
in |
|
308 |
(case find_first (eq_prop (le $ r $ s)) prems of |
|
309 |
NONE => |
|
310 |
find_first (eq_prop (HOLogic.mk_not (less $ s $ r))) prems |
|
311 |
|> Option.map (fn thm => thm RS antisym_less2) |
|
312 |
| SOME thm => SOME (thm RS antisym_le2)) |
|
313 |
end |
|
314 |
handle THM _ => NONE |
|
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
315 |
|
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
316 |
val basic_simpset = HOL_ss addsimps @{thms field_simps} |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
317 |
addsimps [@{thm times_divide_eq_right}, @{thm times_divide_eq_left}] |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
318 |
addsimps @{thms arith_special} addsimps @{thms less_bin_simps} |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
319 |
addsimps @{thms le_bin_simps} addsimps @{thms eq_bin_simps} |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
320 |
addsimps @{thms add_bin_simps} addsimps @{thms succ_bin_simps} |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
321 |
addsimps @{thms minus_bin_simps} addsimps @{thms pred_bin_simps} |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
322 |
addsimps @{thms mult_bin_simps} addsimps @{thms iszero_simps} |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
323 |
addsimps @{thms array_rules} |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
324 |
addsimprocs [ |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
325 |
Simplifier.simproc @{theory} "fast_int_arith" [ |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
326 |
"(m::int) < n", "(m::int) <= n", "(m::int) = n"] (K Lin_Arith.simproc), |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
327 |
Simplifier.simproc @{theory} "antisym_le" ["(x::'a::order) <= y"] |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
328 |
(K prove_antisym_le), |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
329 |
Simplifier.simproc @{theory} "antisym_less" ["~ (x::'a::linorder) < y"] |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
330 |
(K prove_antisym_less)] |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
331 |
|
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
332 |
structure Simpset = Generic_Data |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
333 |
( |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
334 |
type T = simpset |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
335 |
val empty = basic_simpset |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
336 |
val extend = I |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
337 |
val merge = Simplifier.merge_ss |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
338 |
) |
36898 | 339 |
in |
340 |
||
36899
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
341 |
fun add_simproc simproc = Simpset.map (fn ss => ss addsimprocs [simproc]) |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
342 |
|
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
343 |
fun make_simpset ctxt rules = |
bcd6fce5bf06
layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents:
36898
diff
changeset
|
344 |
Simplifier.context ctxt (Simpset.get (Context.Proof ctxt)) addsimps rules |
36898 | 345 |
|
346 |
end |
|
347 |
||
348 |
end |