src/Pure/tctical.ML
changeset 6390 5d58c100ca3f
parent 6041 684ec6a1d802
child 7686 4731f10af2e6
equal deleted inserted replaced
6389:da9c26906f3f 6390:5d58c100ca3f
   355   DOES NOT work if tactic affects the main goal other than by instantiation.*)
   355   DOES NOT work if tactic affects the main goal other than by instantiation.*)
   356 
   356 
   357 (*SELECT_GOAL optimization: replace the conclusion by a variable X,
   357 (*SELECT_GOAL optimization: replace the conclusion by a variable X,
   358   to avoid copying.  Proof states have X==concl as an assuption.*)
   358   to avoid copying.  Proof states have X==concl as an assuption.*)
   359 
   359 
   360 val prop_equals = cterm_of (sign_of ProtoPure.thy) 
   360 val prop_equals = cterm_of (Theory.sign_of ProtoPure.thy) 
   361                     (Const("==", propT-->propT-->propT));
   361                     (Const("==", propT-->propT-->propT));
   362 
   362 
   363 fun mk_prop_equals(t,u) = capply (capply prop_equals t) u;
   363 fun mk_prop_equals(t,u) = capply (capply prop_equals t) u;
   364 
   364 
   365 (*Like trivial but returns [ct==X] ct==>X instead of ct==>ct, if possible.
   365 (*Like trivial but returns [ct==X] ct==>X instead of ct==>ct, if possible.
   366   It is paired with a function to undo the transformation.  If ct contains
   366   It is paired with a function to undo the transformation.  If ct contains
   367   Vars then it returns ct==>ct.*)
   367   Vars then it returns ct==>ct.*)
   368 
   368 
   369 fun eq_trivial ct =
   369 fun eq_trivial ct =
   370   let val xfree = cterm_of (sign_of ProtoPure.thy)
   370   let val xfree = cterm_of (Theory.sign_of ProtoPure.thy)
   371                            (Free (gensym"EQ_TRIVIAL_", propT))
   371                            (Free (gensym"EQ_TRIVIAL_", propT))
   372       val ct_eq_x = mk_prop_equals (ct, xfree)
   372       val ct_eq_x = mk_prop_equals (ct, xfree)
   373       and refl_ct = reflexive ct
   373       and refl_ct = reflexive ct
   374       fun restore th = 
   374       fun restore th = 
   375           implies_elim 
   375           implies_elim 
   389 	  eq_trivial (adjust_maxidx (List.nth(cprems_of st, i-1)))
   389 	  eq_trivial (adjust_maxidx (List.nth(cprems_of st, i-1)))
   390       fun next st' = 
   390       fun next st' = 
   391 	  let val np' = nprems_of st'
   391 	  let val np' = nprems_of st'
   392               (*rename the ?A in rev_triv_goal*)
   392               (*rename the ?A in rev_triv_goal*)
   393 	      val {maxidx,...} = rep_thm st'
   393 	      val {maxidx,...} = rep_thm st'
   394               val ct = cterm_of (sign_of ProtoPure.thy)
   394               val ct = cterm_of (Theory.sign_of ProtoPure.thy)
   395 		                (Var(("A",maxidx+1), propT))
   395 		                (Var(("A",maxidx+1), propT))
   396 	      val rev_triv_goal' = instantiate' [] [Some ct] Drule.rev_triv_goal
   396 	      val rev_triv_goal' = instantiate' [] [Some ct] Drule.rev_triv_goal
   397               fun bic th = bicompose false (false, th, np')
   397               fun bic th = bicompose false (false, th, np')
   398           in  bic (Seq.hd (bic (restore st') 1 rev_triv_goal')) i st  end 
   398           in  bic (Seq.hd (bic (restore st') 1 rev_triv_goal')) i st  end 
   399   in  Seq.flat (Seq.map next (tac eq_cprem))
   399   in  Seq.flat (Seq.map next (tac eq_cprem))