src/Pure/facts.ML
changeset 56158 c2c6d560e7b2
parent 56140 ed92ce2ac88e
child 57887 44354c99d754
equal deleted inserted replaced
56157:7cfe7b6d501a 56158:c2c6d560e7b2
    29   val markup_extern: Proof.context -> T -> string -> Markup.T * xstring
    29   val markup_extern: Proof.context -> T -> string -> Markup.T * xstring
    30   val lookup: Context.generic -> T -> string -> (bool * thm list) option
    30   val lookup: Context.generic -> T -> string -> (bool * thm list) option
    31   val retrieve: Context.generic -> T -> xstring * Position.T -> string * thm list
    31   val retrieve: Context.generic -> T -> xstring * Position.T -> string * thm list
    32   val defined: T -> string -> bool
    32   val defined: T -> string -> bool
    33   val fold_static: (string * thm list -> 'a -> 'a) -> T -> 'a -> 'a
    33   val fold_static: (string * thm list -> 'a -> 'a) -> T -> 'a -> 'a
    34   val dest_static: T list -> T -> (string * thm list) list
    34   val dest_static: bool -> T list -> T -> (string * thm list) list
    35   val extern_static: Proof.context -> T list -> T -> (xstring * thm list) list
       
    36   val props: T -> thm list
    35   val props: T -> thm list
    37   val could_unify: T -> term -> thm list
    36   val could_unify: T -> term -> thm list
    38   val merge: T * T -> T
    37   val merge: T * T -> T
    39   val add_static: Context.generic -> {strict: bool, index: bool} ->
    38   val add_static: Context.generic -> {strict: bool, index: bool} ->
    40     binding * thm list -> T -> string * T
    39     binding * thm list -> T -> string * T
   157 
   156 
   158 val intern = Name_Space.intern o space_of;
   157 val intern = Name_Space.intern o space_of;
   159 fun extern ctxt = Name_Space.extern ctxt o space_of;
   158 fun extern ctxt = Name_Space.extern ctxt o space_of;
   160 fun markup_extern ctxt = Name_Space.markup_extern ctxt o space_of
   159 fun markup_extern ctxt = Name_Space.markup_extern ctxt o space_of
   161 
   160 
       
   161 
       
   162 (* retrieve *)
       
   163 
   162 val defined = is_some oo (Name_Space.lookup_key o facts_of);
   164 val defined = is_some oo (Name_Space.lookup_key o facts_of);
   163 
   165 
   164 fun lookup context facts name =
   166 fun lookup context facts name =
   165   (case Name_Space.lookup_key (facts_of facts) name of
   167   (case Name_Space.lookup_key (facts_of facts) name of
   166     NONE => NONE
   168     NONE => NONE
   177            else Context_Position.report_generic context pos (Markup.dynamic_fact name);
   179            else Context_Position.report_generic context pos (Markup.dynamic_fact name);
   178            thms)
   180            thms)
   179       | NONE => error ("Unknown fact " ^ quote name ^ Position.here pos));
   181       | NONE => error ("Unknown fact " ^ quote name ^ Position.here pos));
   180   in (name, map (Thm.transfer (Context.theory_of context)) thms) end;
   182   in (name, map (Thm.transfer (Context.theory_of context)) thms) end;
   181 
   183 
       
   184 
       
   185 (* static content *)
       
   186 
   182 fun fold_static f =
   187 fun fold_static f =
   183   Name_Space.fold_table (fn (name, Static ths) => f (name, ths) | _ => I) o facts_of;
   188   Name_Space.fold_table (fn (name, Static ths) => f (name, ths) | _ => I) o facts_of;
   184 
   189 
   185 
   190 fun dest_static verbose prev_facts facts =
   186 (* content difference *)
       
   187 
       
   188 fun diff_table prev_facts facts =
       
   189   fold_static (fn (name, ths) =>
   191   fold_static (fn (name, ths) =>
   190     if exists (fn prev => defined prev name) prev_facts then I
   192     if exists (fn prev => defined prev name) prev_facts orelse
   191     else cons (name, ths)) facts [];
   193       not verbose andalso is_concealed facts name then I
   192 
   194     else cons (name, ths)) facts []
   193 fun dest_static prev_facts facts =
   195   |> sort_wrt #1;
   194   sort_wrt #1 (diff_table prev_facts facts);
       
   195 
       
   196 fun extern_static ctxt prev_facts facts =
       
   197   sort_wrt #1 (diff_table prev_facts facts |> map (apfst (extern ctxt facts)));
       
   198 
   196 
   199 
   197 
   200 (* indexed props *)
   198 (* indexed props *)
   201 
   199 
   202 val prop_ord = Term_Ord.term_ord o pairself Thm.full_prop_of;
   200 val prop_ord = Term_Ord.term_ord o pairself Thm.full_prop_of;