# HG changeset patch # User ballarin # Date 1607032823 -3600 # Node ID d7393c35aa5dc290b97cd341250c954295d4e3f2 # Parent 83c6d29a241250e67807cedc733a12af51002a4c Highlight that 'intro_locales' and 'trace_locales' are useful debug features, plus minor clarifications. diff -r 83c6d29a2412 -r d7393c35aa5d src/Doc/Isar_Ref/Spec.thy --- a/src/Doc/Isar_Ref/Spec.thy Wed Dec 02 10:30:59 2020 +0100 +++ b/src/Doc/Isar_Ref/Spec.thy Thu Dec 03 23:00:23 2020 +0100 @@ -512,15 +512,12 @@ subsection \Locale declarations\ text \ - \begin{tabular}{rcll} + \begin{tabular}{rcl} @{command_def "locale"} & : & \theory \ local_theory\ \\ @{command_def "experiment"} & : & \theory \ local_theory\ \\ @{command_def "print_locale"}\\<^sup>*\ & : & \context \\ \\ @{command_def "print_locales"}\\<^sup>*\ & : & \context \\ \\ @{command_def "locale_deps"}\\<^sup>*\ & : & \context \\ \\ - @{method_def intro_locales} & : & \method\ \\ - @{method_def unfold_locales} & : & \method\ \\ - @{attribute_def trace_locales} & : & \attribute\ & default \false\ \\ \end{tabular} \indexisarelem{fixes}\indexisarelem{constrains}\indexisarelem{assumes} @@ -546,11 +543,10 @@ @'notes' (@{syntax thmdef}? @{syntax thms} + @'and') \ - \<^descr> \<^theory_text>\locale loc = import bundles + body\ defines a new locale \loc\ as a context - consisting of a certain view of existing locales (\import\) plus some - additional elements (\body\); given \bundles\ take effect in the surface - context within both \import\ and \body\ and the potentially following - \<^theory_text>\begin\ / \<^theory_text>\end\ block. Each part is optional; the + \<^descr> \<^theory_text>\locale loc = import opening bundles + body\ defines a new locale \loc\ + as a context consisting of a certain view of existing locales (\import\) plus some + additional elements (\body\) with declaration \bundles\ enriching the context + of the command itself. All \import\, \bundles\ and \body\ are optional; the degenerate form \<^theory_text>\locale loc\ defines an empty locale, which may still be useful to collect declarations of facts later on. Type-inference on locale expressions automatically takes care of the most general typing that the @@ -565,7 +561,11 @@ and provides a notational convenience for the inheritance of parameters in locale declarations. - The \body\ consists of context elements. + Declarations from \bundles\, see \secref{sec:bundle}, are effective in the + entire command including a subsequent \<^theory_text>\begin\ / \<^theory_text>\end\ block, but they do + not contribute to the declarations stored in the locale. + + The \body\ consists of context elements: \<^descr> @{element "fixes"}~\x :: \ (mx)\ declares a local parameter of type \\\ and mixfix annotation \mx\ (both are optional). The special syntax @@ -619,7 +619,7 @@ Separate introduction rules \loc_axioms.intro\ and \loc.intro\ are provided as well. - \<^descr> \<^theory_text>\experiment exprs begin\ opens an anonymous locale context with private + \<^descr> \<^theory_text>\experiment body begin\ opens an anonymous locale context with private naming policy. Specifications in its body are inaccessible from outside. This is useful to perform experiments, without polluting the name space. @@ -632,20 +632,6 @@ \<^descr> \<^theory_text>\locale_deps\ visualizes all locales and their relations as a Hasse diagram. This includes locales defined as type classes (\secref{sec:class}). - - \<^descr> @{method intro_locales} and @{method unfold_locales} repeatedly expand all - introduction rules of locale predicates of the theory. While @{method - intro_locales} only applies the \loc.intro\ introduction rules and therefore - does not descend to assumptions, @{method unfold_locales} is more aggressive - and applies \loc_axioms.intro\ as well. Both methods are aware of locale - specifications entailed by the context, both from target statements, and - from interpretations (see below). New goals that are entailed by the current - context are discharged automatically. - - \<^descr> @{attribute trace_locales}, when set to - \true\, prints the locale instances activated during - roundup. Useful for understanding local theories created by complex - locale hierarchies. \ @@ -658,6 +644,9 @@ @{command_def "global_interpretation"} & : & \theory | local_theory \ proof(prove)\ \\ @{command_def "sublocale"} & : & \theory | local_theory \ proof(prove)\ \\ @{command_def "print_interps"}\\<^sup>*\ & : & \context \\ \\ + @{method_def intro_locales} & : & \method\ \\ + @{method_def unfold_locales} & : & \method\ \\ + @{attribute_def trace_locales} & : & \mbox{\attribute\ \quad default \false\} \\ \end{matharray} Locales may be instantiated, and the resulting instantiated declarations @@ -733,7 +722,7 @@ proof block. Note that for \<^theory_text>\interpret\ the \eqns\ should be explicitly universally quantified. - \<^descr> \<^theory_text>\global_interpretation defines defs\ interprets \expr\ + \<^descr> \<^theory_text>\global_interpretation expr defines defs\ interprets \expr\ into a global theory. When adding declarations to locales, interpreted versions of these @@ -775,6 +764,26 @@ \<^theory_text>\interpretation\ or \<^theory_text>\interpret\ and one or several \<^theory_text>\sublocale\ declarations. + \<^descr> @{method intro_locales} and @{method unfold_locales} repeatedly expand all + introduction rules of locale predicates of the theory. While @{method + intro_locales} only applies the \loc.intro\ introduction rules and therefore + does not descend to assumptions, @{method unfold_locales} is more aggressive + and applies \loc_axioms.intro\ as well. Both methods are aware of locale + specifications entailed by the context, both from target statements, and + from interpretations (see below). New goals that are entailed by the current + context are discharged automatically. + + While @{method unfold_locales} is part of the default method for \<^theory_text>\proof\ + and often invoked ``behind the scenes'', @{method intro_locales} helps + understand which proof obligations originated from which locale instances. + The latter method is useful while developing proofs but rare in finished + developments. + + \<^descr> @{attribute trace_locales}, when set to \true\, prints the locale + instances activated during roundup. Use this when locale commands yield + obscure errors or for understanding local theories created by complex locale + hierarchies. + \begin{warn} If a global theory inherits declarations (body elements) for a locale from one parent and an interpretation of that locale from another parent, the