src/Pure/Isar/isar_thy.ML
changeset 16372 8618d334840b
parent 16169 b59202511b8a
child 16425 2427be27cc60
equal deleted inserted replaced
16371:d30742f22121 16372:8618d334840b
     5 Pure/Isar derived theory operations.
     5 Pure/Isar derived theory operations.
     6 *)
     6 *)
     7 
     7 
     8 signature ISAR_THY =
     8 signature ISAR_THY =
     9 sig
     9 sig
    10   val hide_space: string * xstring list -> theory -> theory
    10   val hide_names: string * xstring list -> theory -> theory
    11   val hide_space_i: string * string list -> theory -> theory
    11   val hide_names_i: string * string list -> theory -> theory
    12   val add_axioms: ((bstring * string) * Attrib.src list) list -> theory -> theory
    12   val add_axioms: ((bstring * string) * Attrib.src list) list -> theory -> theory
    13   val add_axioms_i: ((bstring * term) * theory attribute list) list -> theory -> theory
    13   val add_axioms_i: ((bstring * term) * theory attribute list) list -> theory -> theory
    14   val add_defs: bool * ((bstring * string) * Attrib.src list) list -> theory -> theory
    14   val add_defs: bool * ((bstring * string) * Attrib.src list) list -> theory -> theory
    15   val add_defs_i: bool * ((bstring * term) * theory attribute list) list -> theory -> theory
    15   val add_defs_i: bool * ((bstring * term) * theory attribute list) list -> theory -> theory
    16   val theorems: string ->
    16   val theorems: string ->
   176 (* name spaces *)
   176 (* name spaces *)
   177 
   177 
   178 local
   178 local
   179 
   179 
   180 val kinds =
   180 val kinds =
   181  [(Sign.classK, can o Sign.certify_class),
   181  [("class", (Sign.intern_class, can o Sign.certify_class, Theory.hide_classes_i)),
   182   (Sign.typeK, Sign.declared_tyname),
   182   ("type", (Sign.intern_type, Sign.declared_tyname, Theory.hide_types_i)),
   183   (Sign.constK, Sign.declared_const)];
   183   ("const", (Sign.intern_const, Sign.declared_const, Theory.hide_consts_i))];
   184 
   184 
   185 fun gen_hide intern (kind, xnames) thy =
   185 fun gen_hide int (kind, xnames) thy =
   186   (case assoc (kinds, kind) of
   186   (case assoc_string (kinds, kind) of
   187     SOME check =>
   187     SOME (intern, check, hide) =>
   188       let
   188       let
   189         val sg = Theory.sign_of thy;
   189         val sg = Theory.sign_of thy;
   190         val names = map (intern sg kind) xnames;
   190         val names = if int then map (intern sg) xnames else xnames;
   191         val bads = filter_out (check sg) names;
   191         val bads = filter_out (check sg) names;
   192       in
   192       in
   193         if null bads then Theory.hide_space_i true (kind, names) thy
   193         if null bads then hide true names thy
   194         else error ("Attempt to hide undeclared item(s): " ^ commas_quote bads)
   194         else error ("Attempt to hide undeclared item(s): " ^ commas_quote bads)
   195       end
   195       end
   196   | NONE => error ("Bad name space specification: " ^ quote kind));
   196   | NONE => error ("Bad name space specification: " ^ quote kind));
   197 
   197 
   198 in
   198 in
   199 
   199 
   200 fun hide_space x = gen_hide Sign.intern x;
   200 val hide_names = gen_hide true;
   201 fun hide_space_i x = gen_hide (K (K I)) x;
   201 val hide_names_i = gen_hide false;
   202 
   202 
   203 end;
   203 end;
   204 
   204 
   205 
   205 
   206 (* axioms and defs *)
   206 (* axioms and defs *)