src/Pure/Isar/proof_context.ML
changeset 13415 63462ccc6fac
parent 13399 c136276dc847
child 13425 119ae829ad9b
equal deleted inserted replaced
13414:15597d502035 13415:63462ccc6fac
    46   val declare_terms: term list -> context -> context
    46   val declare_terms: term list -> context -> context
    47   val warn_extra_tfrees: context -> context -> context
    47   val warn_extra_tfrees: context -> context -> context
    48   val generalize: context -> context -> term list -> term list
    48   val generalize: context -> context -> term list -> term list
    49   val find_free: term -> string -> term option
    49   val find_free: term -> string -> term option
    50   val export: bool -> context -> context -> thm -> thm Seq.seq
    50   val export: bool -> context -> context -> thm -> thm Seq.seq
    51   val export_standard: cterm option -> context -> context -> thm -> thm
    51   val export_standard: cterm list -> context -> context -> thm -> thm
    52   val drop_schematic: indexname * term option -> indexname * term option
    52   val drop_schematic: indexname * term option -> indexname * term option
    53   val add_binds: (indexname * string option) list -> context -> context
    53   val add_binds: (indexname * string option) list -> context -> context
    54   val add_binds_i: (indexname * term option) list -> context -> context
    54   val add_binds_i: (indexname * term option) list -> context -> context
    55   val auto_bind_goal: term list -> context -> context
    55   val auto_bind_goal: term list -> context -> context
    56   val auto_bind_facts: term list -> context -> context
    56   val auto_bind_facts: term list -> context -> context
   729 fun get_free x (None, t as Free (y, _)) = if x = y then Some t else None
   729 fun get_free x (None, t as Free (y, _)) = if x = y then Some t else None
   730   | get_free _ (opt, _) = opt;
   730   | get_free _ (opt, _) = opt;
   731 
   731 
   732 fun find_free t x = foldl_aterms (get_free x) (None, t);
   732 fun find_free t x = foldl_aterms (get_free x) (None, t);
   733 
   733 
   734 fun export0 view is_goal inner outer =
   734 fun export_view view is_goal inner outer =
   735   let
   735   let
   736     val gen = generalize_tfrees inner outer;
   736     val gen = generalize_tfrees inner outer;
   737     val fixes = fixed_names_of inner \\ fixed_names_of outer;
   737     val fixes = fixed_names_of inner \\ fixed_names_of outer;
   738     val asms = Library.drop (length (assumptions_of outer), assumptions_of inner);
   738     val asms = Library.drop (length (assumptions_of outer), assumptions_of inner);
   739     val exp_asms = map (fn (cprops, exp) => exp is_goal cprops) asms;
   739     val exp_asms = map (fn (cprops, exp) => exp is_goal cprops) asms;
   740   in fn thm => thm
   740   in fn thm => thm
   741     |> Tactic.norm_hhf_rule
   741     |> Tactic.norm_hhf_rule
   742     |> Seq.EVERY (rev exp_asms)
   742     |> Seq.EVERY (rev exp_asms)
   743     |> Seq.map (case view of None => I | Some A => Thm.implies_intr A)
   743     |> Seq.map (Drule.implies_intr_list view)
   744     |> Seq.map (fn rule =>
   744     |> Seq.map (fn rule =>
   745       let
   745       let
   746         val {sign, prop, ...} = Thm.rep_thm rule;
   746         val {sign, prop, ...} = Thm.rep_thm rule;
   747         val frees = map (Thm.cterm_of sign) (mapfilter (find_free prop) fixes);
   747         val frees = map (Thm.cterm_of sign) (mapfilter (find_free prop) fixes);
   748         val tfrees = gen (Term.add_term_tfree_names (prop, []));
   748         val tfrees = gen (Term.add_term_tfree_names (prop, []));
   752         |> Tactic.norm_hhf_rule
   752         |> Tactic.norm_hhf_rule
   753         |> (#1 o Drule.tvars_intr_list tfrees)
   753         |> (#1 o Drule.tvars_intr_list tfrees)
   754       end)
   754       end)
   755   end;
   755   end;
   756 
   756 
   757 val export = export0 None;
   757 val export = export_view [];
   758 
   758 
   759 fun export_standard view inner outer =
   759 fun export_standard view inner outer =
   760   let val exp = export0 view false inner outer in
   760   let val exp = export_view view false inner outer in
   761     fn th =>
   761     fn th =>
   762       (case Seq.pull (exp th) of
   762       (case Seq.pull (exp th) of
   763         Some (th', _) => th' |> Drule.local_standard
   763         Some (th', _) => th' |> Drule.local_standard
   764       | None => raise CONTEXT ("Internal failure while exporting theorem", inner))
   764       | None => raise CONTEXT ("Internal failure while exporting theorem", inner))
   765   end;
   765   end;