332 DOES NOT work if tactic affects the main goal other than by instantiation.*) |
332 DOES NOT work if tactic affects the main goal other than by instantiation.*) |
333 |
333 |
334 (*SELECT_GOAL optimization: replace the conclusion by a variable X, |
334 (*SELECT_GOAL optimization: replace the conclusion by a variable X, |
335 to avoid copying. Proof states have X==concl as an assuption.*) |
335 to avoid copying. Proof states have X==concl as an assuption.*) |
336 |
336 |
337 val prop_equals = cterm_of Sign.proto_pure |
337 val prop_equals = cterm_of (sign_of ProtoPure.thy) |
338 (Const("==", propT-->propT-->propT)); |
338 (Const("==", propT-->propT-->propT)); |
339 |
339 |
340 fun mk_prop_equals(t,u) = capply (capply prop_equals t) u; |
340 fun mk_prop_equals(t,u) = capply (capply prop_equals t) u; |
341 |
341 |
342 (*Like trivial but returns [ct==X] ct==>X instead of ct==>ct, if possible. |
342 (*Like trivial but returns [ct==X] ct==>X instead of ct==>ct, if possible. |
343 It is paired with a function to undo the transformation. If ct contains |
343 It is paired with a function to undo the transformation. If ct contains |
344 Vars then it returns ct==>ct.*) |
344 Vars then it returns ct==>ct.*) |
345 fun eq_trivial ct = |
345 fun eq_trivial ct = |
346 let val xfree = cterm_of Sign.proto_pure (Free (gensym"EQ_TRIVIAL_", propT)) |
346 let val xfree = cterm_of (sign_of ProtoPure.thy) (Free (gensym"EQ_TRIVIAL_", propT)) |
347 val ct_eq_x = mk_prop_equals (ct, xfree) |
347 val ct_eq_x = mk_prop_equals (ct, xfree) |
348 and refl_ct = reflexive ct |
348 and refl_ct = reflexive ct |
349 fun restore th = |
349 fun restore th = |
350 implies_elim |
350 implies_elim |
351 (forall_elim ct (forall_intr xfree (implies_intr ct_eq_x th))) |
351 (forall_elim ct (forall_intr xfree (implies_intr ct_eq_x th))) |
365 in Sequence.flats (Sequence.maps next (tac eq_cprem)) |
365 in Sequence.flats (Sequence.maps next (tac eq_cprem)) |
366 end; |
366 end; |
367 |
367 |
368 (* (!!selct. PROP ?V) ==> PROP ?V ; contains NO TYPE VARIABLES.*) |
368 (* (!!selct. PROP ?V) ==> PROP ?V ; contains NO TYPE VARIABLES.*) |
369 val dummy_quant_rl = |
369 val dummy_quant_rl = |
370 read_cterm Sign.proto_pure ("!!selct::prop. PROP V",propT) |> |
370 read_cterm (sign_of ProtoPure.thy) ("!!selct::prop. PROP V",propT) |> |
371 assume |> forall_elim_var 0 |> standard; |
371 assume |> forall_elim_var 0 |> standard; |
372 |
372 |
373 (* Prevent the subgoal's assumptions from becoming additional subgoals in the |
373 (* Prevent the subgoal's assumptions from becoming additional subgoals in the |
374 new proof state by enclosing them by a universal quantification *) |
374 new proof state by enclosing them by a universal quantification *) |
375 fun protect_subgoal st i = |
375 fun protect_subgoal st i = |