src/Pure/global_theory.ML
changeset 80299 a397fd0c451a
parent 80295 8a9588ffc133
child 80306 c2537860ccf8
equal deleted inserted replaced
80298:f3bfec3b02f0 80299:a397fd0c451a
    12   val intern_fact: theory -> xstring -> string
    12   val intern_fact: theory -> xstring -> string
    13   val defined_fact: theory -> string -> bool
    13   val defined_fact: theory -> string -> bool
    14   val alias_fact: binding -> string -> theory -> theory
    14   val alias_fact: binding -> string -> theory -> theory
    15   val hide_fact: bool -> string -> theory -> theory
    15   val hide_fact: bool -> string -> theory -> theory
    16   val dest_thms: bool -> theory list -> theory -> (Thm_Name.T * thm) list
    16   val dest_thms: bool -> theory list -> theory -> (Thm_Name.T * thm) list
       
    17   val pretty_thm_name: theory -> Thm_Name.T -> Pretty.T
       
    18   val print_thm_name: theory -> Thm_Name.T -> string
    17   val get_thm_names: theory -> Thm_Name.T Inttab.table
    19   val get_thm_names: theory -> Thm_Name.T Inttab.table
    18   val dest_thm_names: theory -> (Proofterm.thm_id * Thm_Name.T) list
    20   val dest_thm_names: theory -> (Proofterm.thm_id * Thm_Name.T) list
    19   val lookup_thm_id: theory -> Proofterm.thm_id -> Thm_Name.T option
    21   val lookup_thm_id: theory -> Proofterm.thm_id -> Thm_Name.T option
    20   val lookup_thm: theory -> thm -> (Proofterm.thm_id * Thm_Name.T) option
    22   val lookup_thm: theory -> thm -> (Proofterm.thm_id * Thm_Name.T) option
    21   val get_thms: theory -> xstring -> thm list
    23   val get_thms: theory -> xstring -> thm list
    65   val empty: T = (Facts.empty, NONE);
    67   val empty: T = (Facts.empty, NONE);
    66   fun merge ((facts1, _), (facts2, _)) = (Facts.merge (facts1, facts2), NONE);
    68   fun merge ((facts1, _), (facts2, _)) = (Facts.merge (facts1, facts2), NONE);
    67 );
    69 );
    68 
    70 
    69 
    71 
    70 (* facts *)
    72 (* global facts *)
    71 
    73 
    72 val facts_of = #1 o Data.get;
    74 val facts_of = #1 o Data.get;
    73 val map_facts = Data.map o apfst;
    75 val map_facts = Data.map o apfst;
    74 
    76 
    75 val fact_space = Facts.space_of o facts_of;
    77 val fact_space = Facts.space_of o facts_of;
    83 fun hide_fact fully name = map_facts (Facts.hide fully name);
    85 fun hide_fact fully name = map_facts (Facts.hide fully name);
    84 
    86 
    85 fun dest_thms verbose prev_thys thy =
    87 fun dest_thms verbose prev_thys thy =
    86   Facts.dest_static verbose (map facts_of prev_thys) (facts_of thy)
    88   Facts.dest_static verbose (map facts_of prev_thys) (facts_of thy)
    87   |> maps (fn (name, thms) => Thm_Name.list (name, Position.none) thms |> map (apfst fst));
    89   |> maps (fn (name, thms) => Thm_Name.list (name, Position.none) thms |> map (apfst fst));
       
    90 
       
    91 fun pretty_thm_name thy = Facts.pretty_thm_name (Context.Theory thy) (facts_of thy);
       
    92 val print_thm_name = Pretty.string_of oo pretty_thm_name;
    88 
    93 
    89 
    94 
    90 (* thm_name vs. derivation_id *)
    95 (* thm_name vs. derivation_id *)
    91 
    96 
    92 val thm_names_of = #2 o Data.get;
    97 val thm_names_of = #2 o Data.get;
   102           raise THM ("Bad theory name for derivation", 0, [thm])
   107           raise THM ("Bad theory name for derivation", 0, [thm])
   103         else
   108         else
   104           (case Inttab.lookup thm_names serial of
   109           (case Inttab.lookup thm_names serial of
   105             SOME thm_name' =>
   110             SOME thm_name' =>
   106               raise THM ("Duplicate use of derivation identity for " ^
   111               raise THM ("Duplicate use of derivation identity for " ^
   107                 Thm_Name.print thm_name ^ " vs. " ^
   112                 print_thm_name thy thm_name ^ " vs. " ^
   108                 Thm_Name.print thm_name', 0, [thm])
   113                 print_thm_name thy thm_name', 0, [thm])
   109           | NONE => Inttab.update (serial, thm_name) thm_names)));
   114           | NONE => Inttab.update (serial, thm_name) thm_names)));
   110 
   115 
   111 fun lazy_thm_names thy =
   116 fun lazy_thm_names thy =
   112   (case thm_names_of thy of
   117   (case thm_names_of thy of
   113     NONE => Lazy.lazy (fn () => make_thm_names thy)
   118     NONE => Lazy.lazy (fn () => make_thm_names thy)