src/Pure/Isar/local_defs.ML
changeset 21684 e8c135b166b3
parent 21591 5e0f2340caa7
child 21687 f689f729afab
equal deleted inserted replaced
21683:b90fa6c8e062 21684:e8c135b166b3
     8 signature LOCAL_DEFS =
     8 signature LOCAL_DEFS =
     9 sig
     9 sig
    10   val cert_def: Proof.context -> term -> (string * typ) * term
    10   val cert_def: Proof.context -> term -> (string * typ) * term
    11   val abs_def: term -> (string * typ) * term
    11   val abs_def: term -> (string * typ) * term
    12   val mk_def: Proof.context -> (string * term) list -> term list
    12   val mk_def: Proof.context -> (string * term) list -> term list
       
    13   val expand: cterm list -> thm -> thm
    13   val def_export: Assumption.export
    14   val def_export: Assumption.export
    14   val add_defs: ((string * mixfix) * ((bstring * attribute list) * term)) list -> Proof.context ->
    15   val add_defs: ((string * mixfix) * ((bstring * attribute list) * term)) list -> Proof.context ->
    15     (term * (bstring * thm)) list * Proof.context
    16     (term * (bstring * thm)) list * Proof.context
    16   val export: Proof.context -> Proof.context -> thm -> thm list * thm
    17   val export: Proof.context -> Proof.context -> thm -> thm list * thm
    17   val print_rules: Proof.context -> unit
    18   val print_rules: Proof.context -> unit
    66        :
    67        :
    67       B x
    68       B x
    68   -----------
    69   -----------
    69       B a
    70       B a
    70 *)
    71 *)
    71 fun def_export _ defs thm =
    72 fun expand defs =
    72   thm
    73   Drule.implies_intr_list defs
    73   |> Drule.implies_intr_list defs
    74   #> Drule.generalize ([], map (head_of_def o Thm.term_of) defs)
    74   |> Drule.generalize ([], map (head_of_def o Thm.term_of) defs)
    75   #> funpow (length defs) (fn th => Drule.reflexive_thm RS th);
    75   |> funpow (length defs) (fn th => Drule.reflexive_thm RS th);
    76 
       
    77 fun expand_term [] = I
       
    78   | expand_term defs = Pattern.rewrite_term
       
    79       (Theory.merge_list (map Thm.theory_of_cterm defs))
       
    80       (map (Logic.dest_equals o Thm.prop_of o Assumption.assume) defs) [];
       
    81 
       
    82 fun def_export _ defs = (expand defs, expand_term defs);
    76 
    83 
    77 
    84 
    78 (* add defs *)
    85 (* add defs *)
    79 
    86 
    80 fun add_defs defs ctxt =
    87 fun add_defs defs ctxt =
    92       (map2 (fn a => fn eq => (a, [(eq, [])])) (names' ~~ atts) eqs)
    99       (map2 (fn a => fn eq => (a, [(eq, [])])) (names' ~~ atts) eqs)
    93     |>> map2 (fn lhs => fn (name, [th]) => (lhs, (name, th))) lhss
   100     |>> map2 (fn lhs => fn (name, [th]) => (lhs, (name, th))) lhss
    94   end;
   101   end;
    95 
   102 
    96 
   103 
    97 (* export -- result based on educated guessing *)
   104 (* specific export -- result based on educated guessing *)
    98 
   105 
    99 fun export inner outer th =
   106 fun export inner outer th =
   100   let
   107   let
   101     val th' = Assumption.export false inner outer th;
   108     val th' = Assumption.export false inner outer th;
   102     val still_fixed = map #1 (Drule.fold_terms Term.add_frees th' []);
   109     val still_fixed = map #1 (Drule.fold_terms Term.add_frees th' []);