161 datatype tree_choice = Left | Right |
161 datatype tree_choice = Left | Right |
162 type prover = tree_choice list -> |
162 type prover = tree_choice list -> |
163 (thm list * thm list * thm list -> positivstellensatz -> thm) -> |
163 (thm list * thm list * thm list -> positivstellensatz -> thm) -> |
164 thm list * thm list * thm list -> thm * pss_tree |
164 thm list * thm list * thm list -> thm * pss_tree |
165 type cert_conv = cterm -> thm * pss_tree |
165 type cert_conv = cterm -> thm * pss_tree |
166 |
|
167 val my_eqs = Unsynchronized.ref ([] : thm list); |
|
168 val my_les = Unsynchronized.ref ([] : thm list); |
|
169 val my_lts = Unsynchronized.ref ([] : thm list); |
|
170 val my_proof = Unsynchronized.ref (Axiom_eq 0); |
|
171 val my_context = Unsynchronized.ref @{context}; |
|
172 |
|
173 val my_mk_numeric = Unsynchronized.ref ((K @{cterm True}) :Rat.rat -> cterm); |
|
174 val my_numeric_eq_conv = Unsynchronized.ref no_conv; |
|
175 val my_numeric_ge_conv = Unsynchronized.ref no_conv; |
|
176 val my_numeric_gt_conv = Unsynchronized.ref no_conv; |
|
177 val my_poly_conv = Unsynchronized.ref no_conv; |
|
178 val my_poly_neg_conv = Unsynchronized.ref no_conv; |
|
179 val my_poly_add_conv = Unsynchronized.ref no_conv; |
|
180 val my_poly_mul_conv = Unsynchronized.ref no_conv; |
|
181 |
166 |
182 |
167 |
183 (* Some useful derived rules *) |
168 (* Some useful derived rules *) |
184 fun deduct_antisym_rule tha thb = |
169 fun deduct_antisym_rule tha thb = |
185 Thm.equal_intr (Thm.implies_intr (cprop_of thb) tha) |
170 Thm.equal_intr (Thm.implies_intr (cprop_of thb) tha) |
360 fun gen_gen_real_arith ctxt (mk_numeric, |
345 fun gen_gen_real_arith ctxt (mk_numeric, |
361 numeric_eq_conv,numeric_ge_conv,numeric_gt_conv, |
346 numeric_eq_conv,numeric_ge_conv,numeric_gt_conv, |
362 poly_conv,poly_neg_conv,poly_add_conv,poly_mul_conv, |
347 poly_conv,poly_neg_conv,poly_add_conv,poly_mul_conv, |
363 absconv1,absconv2,prover) = |
348 absconv1,absconv2,prover) = |
364 let |
349 let |
365 val _ = my_context := ctxt |
|
366 val _ = (my_mk_numeric := mk_numeric ; my_numeric_eq_conv := numeric_eq_conv ; |
|
367 my_numeric_ge_conv := numeric_ge_conv; my_numeric_gt_conv := numeric_gt_conv ; |
|
368 my_poly_conv := poly_conv; my_poly_neg_conv := poly_neg_conv; |
|
369 my_poly_add_conv := poly_add_conv; my_poly_mul_conv := poly_mul_conv) |
|
370 val pre_ss = HOL_basic_ss addsimps simp_thms@ ex_simps@ all_simps@[@{thm not_all},@{thm not_ex},ex_disj_distrib, all_conj_distrib, @{thm if_bool_eq_disj}] |
350 val pre_ss = HOL_basic_ss addsimps simp_thms@ ex_simps@ all_simps@[@{thm not_all},@{thm not_ex},ex_disj_distrib, all_conj_distrib, @{thm if_bool_eq_disj}] |
371 val prenex_ss = HOL_basic_ss addsimps prenex_simps |
351 val prenex_ss = HOL_basic_ss addsimps prenex_simps |
372 val skolemize_ss = HOL_basic_ss addsimps [choice_iff] |
352 val skolemize_ss = HOL_basic_ss addsimps [choice_iff] |
373 val presimp_conv = Simplifier.rewrite (Simplifier.context ctxt pre_ss) |
353 val presimp_conv = Simplifier.rewrite (Simplifier.context ctxt pre_ss) |
374 val prenex_conv = Simplifier.rewrite (Simplifier.context ctxt prenex_ss) |
354 val prenex_conv = Simplifier.rewrite (Simplifier.context ctxt prenex_ss) |
406 fun square_rule t = fconv_rule (arg_conv (oprconv poly_conv)) |
386 fun square_rule t = fconv_rule (arg_conv (oprconv poly_conv)) |
407 (instantiate' [] [SOME t] pth_square) |
387 (instantiate' [] [SOME t] pth_square) |
408 |
388 |
409 fun hol_of_positivstellensatz(eqs,les,lts) proof = |
389 fun hol_of_positivstellensatz(eqs,les,lts) proof = |
410 let |
390 let |
411 val _ = (my_eqs := eqs ; my_les := les ; my_lts := lts ; my_proof := proof) |
|
412 fun translate prf = case prf of |
391 fun translate prf = case prf of |
413 Axiom_eq n => nth eqs n |
392 Axiom_eq n => nth eqs n |
414 | Axiom_le n => nth les n |
393 | Axiom_le n => nth les n |
415 | Axiom_lt n => nth lts n |
394 | Axiom_lt n => nth lts n |
416 | Rational_eq x => eqT_elim(numeric_eq_conv(Thm.capply @{cterm Trueprop} |
395 | Rational_eq x => eqT_elim(numeric_eq_conv(Thm.capply @{cterm Trueprop} |