596 |
596 |
597 subsection {* Locale interpretation *} |
597 subsection {* Locale interpretation *} |
598 |
598 |
599 text {* |
599 text {* |
600 \begin{matharray}{rcl} |
600 \begin{matharray}{rcl} |
601 @{command_def "interpretation"} & : & @{text "local_theory \<rightarrow> proof(prove)"} \\ |
601 @{command_def "interpretation"} & : & @{text "theory | local_theory \<rightarrow> proof(prove)"} \\ |
602 @{command_def "interpret"} & : & @{text "proof(state) | proof(chain) \<rightarrow> proof(prove)"} \\ |
602 @{command_def "interpret"} & : & @{text "proof(state) | proof(chain) \<rightarrow> proof(prove)"} \\ |
603 @{command_def "sublocale"} & : & @{text "theory \<rightarrow> proof(prove)"} \\ |
603 @{command_def "sublocale"} & : & @{text "theory | local_theory \<rightarrow> proof(prove)"} \\ |
604 @{command_def "sublocale"} & : & @{text "local_theory \<rightarrow> proof(prove)"} \\ |
|
605 @{command_def "print_dependencies"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
604 @{command_def "print_dependencies"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
606 @{command_def "print_interps"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
605 @{command_def "print_interps"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
607 \end{matharray} |
606 \end{matharray} |
608 |
607 |
609 Locale expressions may be instantiated, and the instantiated facts |
608 Locale expressions may be instantiated, and the instantiated facts |
610 added to the current context. This requires a proof of the |
609 added to the current context. This requires a proof of the |
611 instantiated specification and is called \emph{locale |
610 instantiated specification and is called \emph{locale |
612 interpretation}. Interpretation is possible in locales (command |
611 interpretation}. Interpretation is possible in locales (command |
613 @{command "sublocale"}), (local) theories (command @{command |
612 @{command "sublocale"}), theories and local theories (command @{command |
614 "interpretation"}) and also within proof bodies (command @{command |
613 "interpretation"}) and also within proof bodies (command @{command |
615 "interpret"}). |
614 "interpret"}). |
616 |
615 |
617 @{rail " |
616 @{rail " |
618 @@{command interpretation} @{syntax target}? @{syntax locale_expr} equations? |
617 @@{command interpretation} @{syntax locale_expr} equations? |
619 ; |
618 ; |
620 @@{command interpret} @{syntax locale_expr} equations? |
619 @@{command interpret} @{syntax locale_expr} equations? |
621 ; |
620 ; |
622 @@{command sublocale} @{syntax nameref} ('<' | '\<subseteq>') @{syntax locale_expr} \\ |
621 @@{command sublocale} (@{syntax nameref} ('<' | '\<subseteq>'))? @{syntax locale_expr} \\ |
623 equations? |
622 equations? |
624 ; |
623 ; |
625 @@{command sublocale} @{syntax target}? @{syntax locale_expr} equations? |
|
626 ; |
|
627 @@{command print_dependencies} '!'? @{syntax locale_expr} |
624 @@{command print_dependencies} '!'? @{syntax locale_expr} |
628 ; |
625 ; |
629 @@{command print_interps} @{syntax nameref} |
626 @@{command print_interps} @{syntax nameref} |
630 ; |
627 ; |
631 |
628 |
633 "} |
630 "} |
634 |
631 |
635 \begin{description} |
632 \begin{description} |
636 |
633 |
637 \item @{command "interpretation"}~@{text "expr \<WHERE> eqns"} |
634 \item @{command "interpretation"}~@{text "expr \<WHERE> eqns"} |
638 interprets @{text expr} in a local theory. The command generates proof |
635 interprets @{text expr} in a theory or local theory. The command |
639 obligations for the instantiated specifications (assumes and defines |
636 generates proof obligations for the instantiated specifications |
640 elements). Once these are discharged by the user, instantiated |
637 (assumes and defines elements). Once these are discharged by the |
641 facts are added to the local theory in a post-processing phase. |
638 user, instantiated facts are added to the theory in a |
|
639 post-processing phase. |
|
640 |
|
641 The command is aware of interpretations that are already active, but |
|
642 does not simplify the goal automatically. In order to simplify the |
|
643 proof obligations use methods @{method intro_locales} or @{method |
|
644 unfold_locales}. Post-processing is not applied to facts of |
|
645 interpretations that are already active. This avoids duplication of |
|
646 interpreted facts, in particular. Note that, in the case of a |
|
647 locale with import, parts of the interpretation may already be |
|
648 active. The command will only process facts for new parts. |
|
649 |
|
650 When adding facts to locales, interpreted versions of these facts |
|
651 are added to the global theory for all interpretations in the global |
|
652 theory as well. That is, interpretations in global theories |
|
653 dynamically participate in any facts added to locales. (Note that |
|
654 if a global theory inherits additional facts for a locale through |
|
655 one parent and an interpretation of that locale through another |
|
656 parent, the additional facts will not be interpreted.) In contrast, |
|
657 the lifetime of an interpretation in a local theory is limited to the |
|
658 current context block. At the closing @{command end} of the block |
|
659 the interpretation and its facts disappear. This enables local |
|
660 interpretations, which are useful for auxilliary contructions, |
|
661 without polluting the class or locale with interpreted facts. |
642 |
662 |
643 Free variables in the interpreted expression are allowed. They are |
663 Free variables in the interpreted expression are allowed. They are |
644 turned into schematic variables in the generated declarations. In |
664 turned into schematic variables in the generated declarations. In |
645 order to use a free variable whose name is already bound in the |
665 order to use a free variable whose name is already bound in the |
646 context --- for example, because a constant of that name exists --- |
666 context --- for example, because a constant of that name exists --- |
648 |
668 |
649 Additional equations, which are unfolded during |
669 Additional equations, which are unfolded during |
650 post-processing, may be given after the keyword @{keyword "where"}. |
670 post-processing, may be given after the keyword @{keyword "where"}. |
651 This is useful for interpreting concepts introduced through |
671 This is useful for interpreting concepts introduced through |
652 definitions. The equations must be proved. |
672 definitions. The equations must be proved. |
653 |
|
654 The command is aware of interpretations already active in the |
|
655 local theory, but does not simplify the goal automatically. In order to |
|
656 simplify the proof obligations use methods @{method intro_locales} |
|
657 or @{method unfold_locales}. Post-processing is not applied to |
|
658 facts of interpretations that are already active. This avoids |
|
659 duplication of interpreted facts, in particular. Note that, in the |
|
660 case of a locale with import, parts of the interpretation may |
|
661 already be active. The command will only process facts for new |
|
662 parts. |
|
663 |
|
664 If the local theory is a global theory target, the facts persist. |
|
665 Even more, adding facts to locales has the effect of adding interpreted facts |
|
666 to the global background theory for all interpretations as well. That is, |
|
667 interpretations into global theories dynamically participate in any facts added to |
|
668 locales. |
|
669 |
|
670 If the local theory is not a global theory, the facts disappear |
|
671 after the @{command end} confining the current context block |
|
672 opened by @{command context}, similar to @{command interpret}. |
|
673 |
|
674 Note that if a local theory inherits additional facts for a |
|
675 locale through one parent and an interpretation of that locale |
|
676 through another parent, the additional facts will not be |
|
677 interpreted. |
|
678 |
673 |
679 \item @{command "interpret"}~@{text "expr \<WHERE> eqns"} interprets |
674 \item @{command "interpret"}~@{text "expr \<WHERE> eqns"} interprets |
680 @{text expr} in the proof context and is otherwise similar to |
675 @{text expr} in the proof context and is otherwise similar to |
681 interpretation in local theories. Note that rewrite rules given to |
676 interpretation in local theories. Note that rewrite rules given to |
682 @{command "interpret"} after the @{keyword "where"} keyword should be |
677 @{command "interpret"} after the @{keyword "where"} keyword should be |
699 part of @{text name} (be it imported, derived or a derived fragment |
694 part of @{text name} (be it imported, derived or a derived fragment |
700 of the import) are considered in this process. This enables |
695 of the import) are considered in this process. This enables |
701 circular interpretations provided that no infinite chains are |
696 circular interpretations provided that no infinite chains are |
702 generated in the locale hierarchy. |
697 generated in the locale hierarchy. |
703 |
698 |
704 If interpretations of @{text name} exist in the current theory, the |
699 If interpretations of @{text name} exist in the current global |
705 command adds interpretations for @{text expr} as well, with the same |
700 theory, the command adds interpretations for @{text expr} as well, |
706 qualifier, although only for fragments of @{text expr} that are not |
701 with the same qualifier, although only for fragments of @{text expr} |
707 interpreted in the theory already. |
702 that are not interpreted in the theory already. |
708 |
703 |
709 Equations given after @{keyword "where"} amend the morphism through |
704 Equations given after @{keyword "where"} amend the morphism through |
710 which @{text expr} is interpreted. This enables to map definitions |
705 which @{text expr} is interpreted. This enables to map definitions |
711 from the interpreted locales to entities of @{text name}. This |
706 from the interpreted locales to entities of @{text name}. This |
712 feature is experimental. |
707 feature is experimental. |
713 |
708 |
714 \item @{command "sublocale"}~@{text "expr \<WHERE> eqns"} is a syntactic |
709 In a named context block the @{command sublocale} command may also |
715 variant of @{command "sublocale"} which must be used in |
710 be used, but the locale argument must be omitted. The command then |
716 the local theory context of a locale @{text name} only. Then it |
711 refers to the locale (or class) target of the context block. |
717 is equivalent to @{command "sublocale"}~@{text "name \<subseteq> expr \<WHERE> |
|
718 eqns"}. |
|
719 |
712 |
720 \item @{command "print_dependencies"}~@{text "expr"} is useful for |
713 \item @{command "print_dependencies"}~@{text "expr"} is useful for |
721 understanding the effect of an interpretation of @{text "expr"}. It |
714 understanding the effect of an interpretation of @{text "expr"}. It |
722 lists all locale instances for which interpretations would be added |
715 lists all locale instances for which interpretations would be added |
723 to the current context. Variant @{command |
716 to the current context. Variant @{command |