equal
deleted
inserted
replaced
73 val intro_add: attribute |
73 val intro_add: attribute |
74 val unfold_add: attribute |
74 val unfold_add: attribute |
75 val intro_locales_tac: {strict: bool, eager: bool} -> Proof.context -> thm list -> tactic |
75 val intro_locales_tac: {strict: bool, eager: bool} -> Proof.context -> thm list -> tactic |
76 |
76 |
77 (* Registrations and dependencies *) |
77 (* Registrations and dependencies *) |
78 type registration = {dep: string * morphism, mixin: (morphism * bool) option, export: morphism} |
78 type registration = {inst: string * morphism, mixin: (morphism * bool) option, export: morphism} |
79 val amend_registration: registration -> Context.generic -> Context.generic |
79 val amend_registration: registration -> Context.generic -> Context.generic |
80 val add_registration: registration -> Context.generic -> Context.generic |
80 val add_registration: registration -> Context.generic -> Context.generic |
81 val add_registration_theory: registration -> theory -> theory |
81 val add_registration_theory: registration -> theory -> theory |
82 val add_registration_proof: registration -> Proof.context -> Proof.context |
82 val add_registration_proof: registration -> Proof.context -> Proof.context |
83 val add_registration_local_theory: registration -> local_theory -> local_theory |
83 val add_registration_local_theory: registration -> local_theory -> local_theory |
537 (*** Add and extend registrations ***) |
537 (*** Add and extend registrations ***) |
538 |
538 |
539 type registration = Locale.registration; |
539 type registration = Locale.registration; |
540 |
540 |
541 fun amend_registration {mixin = NONE, ...} context = context |
541 fun amend_registration {mixin = NONE, ...} context = context |
542 | amend_registration {dep = (name, morph), mixin = SOME mixin, export} context = |
542 | amend_registration {inst = (name, morph), mixin = SOME mixin, export} context = |
543 let |
543 let |
544 val thy = Context.theory_of context; |
544 val thy = Context.theory_of context; |
545 val ctxt = Context.proof_of context; |
545 val ctxt = Context.proof_of context; |
546 |
546 |
547 val regs = get_regs context; |
547 val regs = get_regs context; |
559 end; |
559 end; |
560 |
560 |
561 (* Note that a registration that would be subsumed by an existing one will not be |
561 (* Note that a registration that would be subsumed by an existing one will not be |
562 generated, and it will not be possible to amend it. *) |
562 generated, and it will not be possible to amend it. *) |
563 |
563 |
564 fun add_registration {dep = (name, base_morph), mixin, export} context = |
564 fun add_registration {inst = (name, base_morph), mixin, export} context = |
565 let |
565 let |
566 val thy = Context.theory_of context; |
566 val thy = Context.theory_of context; |
567 val pos_morph = Morphism.binding_morphism "position" (Binding.set_pos (Position.thread_data ())); |
567 val pos_morph = Morphism.binding_morphism "position" (Binding.set_pos (Position.thread_data ())); |
568 val mix_morph = (case mixin of NONE => base_morph | SOME (mix, _) => base_morph $> mix); |
568 val mix_morph = (case mixin of NONE => base_morph | SOME (mix, _) => base_morph $> mix); |
569 val inst = instance_of thy name mix_morph; |
569 val inst = instance_of thy name mix_morph; |
573 else |
573 else |
574 (idents, context) |
574 (idents, context) |
575 (* add new registrations with inherited mixins *) |
575 (* add new registrations with inherited mixins *) |
576 |> roundup thy (add_reg thy export) export (name, mix_morph) |> #2 |
576 |> roundup thy (add_reg thy export) export (name, mix_morph) |> #2 |
577 (* add mixin *) |
577 (* add mixin *) |
578 |> amend_registration {dep = (name, mix_morph), mixin = mixin, export = export} |
578 |> amend_registration {inst = (name, mix_morph), mixin = mixin, export = export} |
579 (* activate import hierarchy as far as not already active *) |
579 (* activate import hierarchy as far as not already active *) |
580 |> activate_facts (SOME export) (name, mix_morph $> pos_morph) |
580 |> activate_facts (SOME export) (name, mix_morph $> pos_morph) |
581 end; |
581 end; |
582 |
582 |
583 val add_registration_theory = Context.theory_map o add_registration; |
583 val add_registration_theory = Context.theory_map o add_registration; |
602 name = loc ? cons (name, morphisms)) (get_regs context) [] |
602 name = loc ? cons (name, morphisms)) (get_regs context) [] |
603 (*with inherited mixins*) |
603 (*with inherited mixins*) |
604 |> map (fn (name, (base, export)) => |
604 |> map (fn (name, (base, export)) => |
605 (name, base $> (collect_mixins context (name, base $> export)) $> export)); |
605 (name, base $> (collect_mixins context (name, base $> export)) $> export)); |
606 |
606 |
607 fun add_dependency loc {dep = (name, morph), mixin, export} thy = |
607 fun add_dependency loc {inst = (name, morph), mixin, export} thy = |
608 let |
608 let |
609 val serial' = serial (); |
609 val serial' = serial (); |
610 val thy' = thy |> |
610 val thy' = thy |> |
611 (change_locale loc o apsnd) |
611 (change_locale loc o apsnd) |
612 (apfst (cons ((name, (morph, export)), serial')) #> |
612 (apfst (cons ((name, (morph, export)), serial')) #> |
615 val (_, regs) = |
615 val (_, regs) = |
616 fold_rev (roundup thy' cons export) |
616 fold_rev (roundup thy' cons export) |
617 (registrations_of context' loc) (Idents.get context', []); |
617 (registrations_of context' loc) (Idents.get context', []); |
618 in |
618 in |
619 thy' |
619 thy' |
620 |> fold_rev (fn dep => add_registration_theory {dep = dep, mixin = NONE, export = export}) regs |
620 |> fold_rev (fn dep => add_registration_theory {inst = dep, mixin = NONE, export = export}) regs |
621 end; |
621 end; |
622 |
622 |
623 |
623 |
624 (*** Storing results ***) |
624 (*** Storing results ***) |
625 |
625 |