src/Pure/Isar/locale.ML
changeset 30755 7ef503d216c2
parent 30754 c896167de3d5
child 30761 ac7570d80c3d
equal deleted inserted replaced
30754:c896167de3d5 30755:7ef503d216c2
    28 
    28 
    29 signature LOCALE =
    29 signature LOCALE =
    30 sig
    30 sig
    31   (* Locale specification *)
    31   (* Locale specification *)
    32   val register_locale: binding ->
    32   val register_locale: binding ->
    33     (string * sort) list * (binding * typ option * mixfix) list ->
    33     (string * sort) list * ((string * typ) * mixfix) list ->
    34     term option * term list ->
    34     term option * term list ->
    35     thm option * thm option -> thm list ->
    35     thm option * thm option -> thm list ->
    36     declaration list * declaration list ->
    36     declaration list * declaration list ->
    37     (string * (Attrib.binding * (thm list * Attrib.src list) list) list) list ->
    37     (string * (Attrib.binding * (thm list * Attrib.src list) list) list) list ->
    38     (string * morphism) list -> theory -> theory
    38     (string * morphism) list -> theory -> theory
    39   val intern: theory -> xstring -> string
    39   val intern: theory -> xstring -> string
    40   val extern: theory -> string -> xstring
    40   val extern: theory -> string -> xstring
    41   val defined: theory -> string -> bool
    41   val defined: theory -> string -> bool
    42   val params_of: theory -> string -> (binding * typ option * mixfix) list
    42   val params_of: theory -> string -> ((string * typ) * mixfix) list
    43   val intros_of: theory -> string -> thm option * thm option
    43   val intros_of: theory -> string -> thm option * thm option
    44   val axioms_of: theory -> string -> thm list
    44   val axioms_of: theory -> string -> thm list
    45   val instance_of: theory -> string -> morphism -> term list
    45   val instance_of: theory -> string -> morphism -> term list
    46   val specification_of: theory -> string -> term option * term list
    46   val specification_of: theory -> string -> term option * term list
    47   val declarations_of: theory -> string -> declaration list * declaration list
    47   val declarations_of: theory -> string -> declaration list * declaration list
    89 
    89 
    90 (*** Theory data ***)
    90 (*** Theory data ***)
    91 
    91 
    92 datatype locale = Loc of {
    92 datatype locale = Loc of {
    93   (** static part **)
    93   (** static part **)
    94   parameters: (string * sort) list * (binding * typ option * mixfix) list,
    94   parameters: (string * sort) list * ((string * typ) * mixfix) list,
    95     (* type and term parameters *)
    95     (* type and term parameters *)
    96   spec: term option * term list,
    96   spec: term option * term list,
    97     (* assumptions (as a single predicate expression) and defines *)
    97     (* assumptions (as a single predicate expression) and defines *)
    98   intros: thm option * thm option,
    98   intros: thm option * thm option,
    99   axioms: thm list,
    99   axioms: thm list,
   163 fun intros_of thy = #intros o the_locale thy;
   163 fun intros_of thy = #intros o the_locale thy;
   164 
   164 
   165 fun axioms_of thy = #axioms o the_locale thy;
   165 fun axioms_of thy = #axioms o the_locale thy;
   166 
   166 
   167 fun instance_of thy name morph = params_of thy name |>
   167 fun instance_of thy name morph = params_of thy name |>
   168   map (fn (b, T, _) => Morphism.term morph (Free (Name.of_binding b, the T)));
   168   map (Morphism.term morph o Free o #1);
   169 
   169 
   170 fun specification_of thy = #spec o the_locale thy;
   170 fun specification_of thy = #spec o the_locale thy;
   171 
   171 
   172 fun declarations_of thy name = the_locale thy name |>
   172 fun declarations_of thy name = the_locale thy name |>
   173   #decls |> pairself (map fst);
   173   #decls |> pairself (map fst);
   283   let
   283   let
   284     val {parameters = (_, params), spec = (asm, defs), ...} =
   284     val {parameters = (_, params), spec = (asm, defs), ...} =
   285       the_locale thy name;
   285       the_locale thy name;
   286   in
   286   in
   287     input |>
   287     input |>
   288       (if not (null params) then activ_elem (Fixes params) else I) |>
   288       (not (null params) ?
       
   289         activ_elem (Fixes (map (fn ((x, T), mx) => (Binding.name x, SOME T, mx)) params))) |>
   289       (* FIXME type parameters *)
   290       (* FIXME type parameters *)
   290       (if is_some asm then activ_elem (Assumes [(Attrib.empty_binding, [(the asm, [])])]) else I) |>
   291       (if is_some asm then activ_elem (Assumes [(Attrib.empty_binding, [(the asm, [])])]) else I) |>
   291       (if not (null defs)
   292       (if not (null defs)
   292         then activ_elem (Defines (map (fn def => (Attrib.empty_binding, (def, []))) defs))
   293         then activ_elem (Defines (map (fn def => (Attrib.empty_binding, (def, []))) defs))
   293         else I) |>
   294         else I) |>