src/Pure/tactic.ML
changeset 11974 f76c3e1ab352
parent 11970 e7eedbd2c8ca
child 12139 d51d50636332
equal deleted inserted replaced
11973:bd0111191d71 11974:f76c3e1ab352
   616   let
   616   let
   617     val statement = Logic.list_implies (asms, prop);
   617     val statement = Logic.list_implies (asms, prop);
   618     val frees = map Term.dest_Free (Term.term_frees statement);
   618     val frees = map Term.dest_Free (Term.term_frees statement);
   619     val fixed_frees = filter_out (fn (x, _) => x mem_string xs) frees;
   619     val fixed_frees = filter_out (fn (x, _) => x mem_string xs) frees;
   620     val fixed_tfrees = foldr Term.add_typ_tfree_names (map #2 fixed_frees, []);
   620     val fixed_tfrees = foldr Term.add_typ_tfree_names (map #2 fixed_frees, []);
   621 
       
   622     val params = mapfilter (fn x => apsome (pair x) (assoc_string (frees, x))) xs;
   621     val params = mapfilter (fn x => apsome (pair x) (assoc_string (frees, x))) xs;
   623 
   622 
   624     fun err msg = error (msg ^ "\nThe error(s) above occurred for the goal statement:\n" ^
   623     fun err msg = error (msg ^ "\nThe error(s) above occurred for the goal statement:\n" ^
   625       Sign.string_of_term sign (Term.list_all_free (params, statement)));
   624       Sign.string_of_term sign (Term.list_all_free (params, statement)));
   626 
   625 
   627     fun cert_safe t = Thm.cterm_of sign t
   626     fun cert_safe t = Thm.cterm_of sign t
   628       handle TERM (msg, _) => err msg | TYPE (msg, _, _) => err msg;
   627       handle TERM (msg, _) => err msg | TYPE (msg, _, _) => err msg;
   629 
   628 
   630     val _ = cert_safe statement;
   629     val _ = cert_safe statement;
   631     val _ = Term.no_dummy_patterns statement handle TERM (msg, _) => error msg;
   630     val _ = Term.no_dummy_patterns statement handle TERM (msg, _) => err msg;
   632 
   631 
       
   632     val cparams = map (cert_safe o Free) params;
   633     val casms = map cert_safe asms;
   633     val casms = map cert_safe asms;
   634     val prems = map (norm_hhf o Thm.assume) casms;
   634     val prems = map (norm_hhf o Thm.assume) casms;
   635     val goal = Drule.mk_triv_goal (cert_safe prop);
   635     val goal = Drule.mk_triv_goal (cert_safe prop);
   636 
   636 
   637     val goal' =
   637     val goal' =
   646     else if not (Pattern.matches (Sign.tsig_of sign) (prop, prop')) then
   646     else if not (Pattern.matches (Sign.tsig_of sign) (prop, prop')) then
   647       err ("Proved a different theorem: " ^ Sign.string_of_term sign prop')
   647       err ("Proved a different theorem: " ^ Sign.string_of_term sign prop')
   648     else
   648     else
   649       raw_result
   649       raw_result
   650       |> Drule.implies_intr_list casms
   650       |> Drule.implies_intr_list casms
   651       |> Drule.forall_intr_list (map (cert_safe o Free) params)
   651       |> Drule.forall_intr_list cparams
   652       |> norm_hhf
   652       |> norm_hhf
   653       |> Thm.varifyT' fixed_tfrees
   653       |> Thm.varifyT' fixed_tfrees
   654       |> Drule.zero_var_indexes
   654       |> Drule.zero_var_indexes
   655   end;
   655   end;
   656 
   656