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 -> |
36 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 |
|
40 val check: theory -> xstring * Position.T -> string |
39 val check: theory -> xstring * Position.T -> string |
41 val extern: theory -> string -> xstring |
40 val extern: theory -> string -> xstring |
|
41 val markup_name: Proof.context -> string -> string |
42 val pretty_name: Proof.context -> string -> Pretty.T |
42 val pretty_name: Proof.context -> string -> Pretty.T |
43 val defined: theory -> string -> bool |
43 val defined: theory -> string -> bool |
44 val params_of: theory -> string -> ((string * typ) * mixfix) list |
44 val params_of: theory -> string -> ((string * typ) * mixfix) list |
45 val intros_of: theory -> string -> thm option * thm option |
45 val intros_of: theory -> string -> thm option * thm option |
46 val axioms_of: theory -> string -> thm list |
46 val axioms_of: theory -> string -> thm list |
157 val empty : T = Name_Space.empty_table "locale"; |
157 val empty : T = Name_Space.empty_table "locale"; |
158 val extend = I; |
158 val extend = I; |
159 val merge = Name_Space.join_tables (K merge_locale); |
159 val merge = Name_Space.join_tables (K merge_locale); |
160 ); |
160 ); |
161 |
161 |
162 val intern = Name_Space.intern o #1 o Locales.get; |
|
163 fun check thy = #1 o Name_Space.check (Context.Theory thy) (Locales.get thy); |
162 fun check thy = #1 o Name_Space.check (Context.Theory thy) (Locales.get thy); |
|
163 |
164 fun extern thy = Name_Space.extern (Proof_Context.init_global thy) (#1 (Locales.get thy)); |
164 fun extern thy = Name_Space.extern (Proof_Context.init_global thy) (#1 (Locales.get thy)); |
165 |
165 |
166 fun pretty_name ctxt name = |
166 fun markup_extern ctxt = |
167 Pretty.mark_str |
167 Name_Space.markup_extern ctxt (#1 (Locales.get (Proof_Context.theory_of ctxt))); |
168 (Name_Space.markup_extern ctxt (#1 (Locales.get (Proof_Context.theory_of ctxt))) name); |
168 |
|
169 fun markup_name ctxt name = markup_extern ctxt name |-> Markup.markup; |
|
170 fun pretty_name ctxt name = markup_extern ctxt name |> Pretty.mark_str; |
169 |
171 |
170 val get_locale = Symtab.lookup o #2 o Locales.get; |
172 val get_locale = Symtab.lookup o #2 o Locales.get; |
171 val defined = Symtab.defined o #2 o Locales.get; |
173 val defined = Symtab.defined o #2 o Locales.get; |
172 |
174 |
173 fun the_locale thy name = |
175 fun the_locale thy name = |
205 #dependencies; |
207 #dependencies; |
206 |
208 |
207 fun mixins_of thy name serial = the_locale thy name |> |
209 fun mixins_of thy name serial = the_locale thy name |> |
208 #mixins |> lookup_mixins serial; |
210 #mixins |> lookup_mixins serial; |
209 |
211 |
210 (* FIXME unused *) |
212 (* FIXME unused!? *) |
211 fun identity_on thy name morph = |
213 fun identity_on thy name morph = |
212 let val mk_instance = instance_of thy name |
214 let val mk_instance = instance_of thy name |
213 in ListPair.all Term.aconv_untyped (mk_instance Morphism.identity, mk_instance morph) end; |
215 in ListPair.all Term.aconv_untyped (mk_instance Morphism.identity, mk_instance morph) end; |
214 |
216 |
215 (* Print instance and qualifiers *) |
217 (* Print instance and qualifiers *) |
460 (*** Add and extend registrations ***) |
462 (*** Add and extend registrations ***) |
461 |
463 |
462 fun amend_registration (name, morph) mixin export context = |
464 fun amend_registration (name, morph) mixin export context = |
463 let |
465 let |
464 val thy = Context.theory_of context; |
466 val thy = Context.theory_of context; |
|
467 val ctxt = Context.proof_of context; |
|
468 |
465 val regs = Registrations.get context |> fst; |
469 val regs = Registrations.get context |> fst; |
466 val base = instance_of thy name (morph $> export); |
470 val base = instance_of thy name (morph $> export); |
467 val serial' = case Idtab.lookup regs (name, base) of |
471 val serial' = |
|
472 (case Idtab.lookup regs (name, base) of |
468 NONE => |
473 NONE => |
469 error ("No interpretation of locale " ^ |
474 error ("No interpretation of locale " ^ quote (markup_name ctxt name) ^ |
470 quote (extern thy name) ^ " with\nparameter instantiation " ^ |
475 " with\nparameter instantiation " ^ |
471 space_implode " " (map (quote o Syntax.string_of_term_global thy) base) ^ |
476 space_implode " " (map (quote o Syntax.string_of_term_global thy) base) ^ |
472 " available") |
477 " available") |
473 | SOME (_, serial') => serial'; |
478 | SOME (_, serial') => serial'); |
474 in |
479 in |
475 add_mixin serial' mixin context |
480 add_mixin serial' mixin context |
476 end; |
481 end; |
477 |
482 |
478 (* Note that a registration that would be subsumed by an existing one will not be |
483 (* Note that a registration that would be subsumed by an existing one will not be |
500 end; |
505 end; |
501 |
506 |
502 |
507 |
503 (*** Dependencies ***) |
508 (*** Dependencies ***) |
504 |
509 |
505 (* |
510 (* FIXME dead code!? |
506 fun amend_dependency loc (name, morph) mixin export thy = |
511 fun amend_dependency loc (name, morph) mixin export thy = |
507 let |
512 let |
508 val deps = dependencies_of thy loc; |
513 val deps = dependencies_of thy loc; |
509 in |
514 in |
510 case AList.lookup (fn ((name, morph), ((name', (morph', _)), _)) => |
515 case AList.lookup (fn ((name, morph), ((name', (morph', _)), _)) => |