# HG changeset patch # User wenzelm # Date 1447968111 -3600 # Node ID a1510dfb9bfa10c0f139f05e1b50b658828c997c # Parent 546e6494049fa547e3175a9adbc97989cad6109c tuned whitespace; diff -r 546e6494049f -r a1510dfb9bfa src/Doc/Isar_Ref/Spec.thy --- a/src/Doc/Isar_Ref/Spec.thy Thu Nov 19 22:06:14 2015 +0100 +++ b/src/Doc/Isar_Ref/Spec.thy Thu Nov 19 22:21:51 2015 +0100 @@ -40,11 +40,11 @@ proof. The theory body may be sub-structured by means of \<^emph>\local theory targets\, - such as \<^theory_text>\locale\ and \<^theory_text>\class\. It is also possible to use - \<^theory_text>\context begin \ end\ blocks to delimited a local theory context: a \<^emph>\named - context\ to augment a locale or class specification, or an \<^emph>\unnamed - context\ to refer to local parameters and assumptions that are discharged - later. See \secref{sec:target} for more details. + such as \<^theory_text>\locale\ and \<^theory_text>\class\. It is also possible to use \<^theory_text>\context begin \ + end\ blocks to delimited a local theory context: a \<^emph>\named context\ to + augment a locale or class specification, or an \<^emph>\unnamed context\ to refer + to local parameters and assumptions that are discharged later. See + \secref{sec:target} for more details. \<^medskip> A theory is commenced by the \<^theory_text>\theory\ command, which indicates imports of @@ -616,17 +616,12 @@ Locales may be instantiated, and the resulting instantiated declarations added to the current context. This requires proof (of the instantiated - specification) and is called \<^emph>\locale interpretation\. - Interpretation is possible within - arbitrary local theories (\<^theory_text>\interpretation\), - within proof bodies (\<^theory_text>\interpret\), into global theories - (another variant of \<^theory_text>\interpretation\) - and into locales (\<^theory_text>\sublocale\). - As a generalization, interpretation into - arbitrary local theories is possible, although this is - only implemented by certain targets - (\<^theory_text>\permanent_interpretation\). - + specification) and is called \<^emph>\locale interpretation\. Interpretation is + possible within arbitrary local theories (\<^theory_text>\interpretation\), within proof + bodies (\<^theory_text>\interpret\), into global theories (another variant of + \<^theory_text>\interpretation\) and into locales (\<^theory_text>\sublocale\). As a generalization, + interpretation into arbitrary local theories is possible, although this is + only implemented by certain targets (\<^theory_text>\permanent_interpretation\). @{rail \ @@{command interpretation} @{syntax locale_expr} equations? @@ -652,49 +647,46 @@ equations: @'rewrites' (@{syntax thmdecl}? @{syntax prop} + @'and') \} - The core of each interpretation command is a locale expression - \expr\; the command generates proof obligations for the instantiated - specifications. Once these are discharged by the user, instantiated - declarations (in particular, facts) are added to the context in - a post-processing phase, in a manner specific to each command. + The core of each interpretation command is a locale expression \expr\; the + command generates proof obligations for the instantiated specifications. + Once these are discharged by the user, instantiated declarations (in + particular, facts) are added to the context in a post-processing phase, in a + manner specific to each command. - Interpretation commands are aware of interpretations that are already active: - post-processing is achieved through a variant of roundup that takes + Interpretation commands are aware of interpretations that are already + active: post-processing is achieved through a variant of roundup that takes interpretations of the current global or local theory into account. In order to simplify the proof obligations according to existing interpretations use methods @{method intro_locales} or @{method unfold_locales}. Given equations \eqns\ amend the morphism through which \expr\ is - interpreted, adding rewrite rules. This is particularly useful - for interpreting concepts introduced through definitions. The - equations must be proved the user. + interpreted, adding rewrite rules. This is particularly useful for + interpreting concepts introduced through definitions. The equations must be + proved the user. - Given definitions \defs\ produce corresponding definitions in - the local theory's underlying target \<^emph>\and\ amend the morphism - with the equations stemming from the symmetric of the - definitions. Hence they need not be proved explicitly the user. - Such rewrite definitions are a even more useful device for - interpreting concepts introduced through definitions, but they - are only supported for interpretation commands operating in - a local theory whose implementing target actually supports this. + Given definitions \defs\ produce corresponding definitions in the local + theory's underlying target \<^emph>\and\ amend the morphism with the equations + stemming from the symmetric of the definitions. Hence they need not be + proved explicitly the user. Such rewrite definitions are a even more useful + device for interpreting concepts introduced through definitions, but they + are only supported for interpretation commands operating in a local theory + whose implementing target actually supports this. - \<^descr> \<^theory_text>\interpretation expr rewrites eqns\ - interprets \expr\ into a local theory such that its lifetime is - limited to the current context block (e.g. a locale or unnamed context). - At the closing @{command end} - of the block the interpretation and its declarations disappear. - Hence facts based on interpretation can be established without - creating permanent links to the interpreted locale instances, as - would be the case with @{command sublocale}. + \<^descr> \<^theory_text>\interpretation expr rewrites eqns\ interprets \expr\ into a local theory + such that its lifetime is limited to the current context block (e.g. a + locale or unnamed context). At the closing @{command end} of the block the + interpretation and its declarations disappear. Hence facts based on + interpretation can be established without creating permanent links to the + interpreted locale instances, as would be the case with @{command + sublocale}. - \<^descr> \<^theory_text>\interpret expr rewrites eqns\ interprets - \expr\ into a proof context: the interpretation and its declarations - disappear when closing the current proof block. - Note that for \<^theory_text>\interpret\ the \eqns\ should be - explicitly universally quantified. + \<^descr> \<^theory_text>\interpret expr rewrites eqns\ interprets \expr\ into a proof context: + the interpretation and its declarations disappear when closing the current + proof block. Note that for \<^theory_text>\interpret\ the \eqns\ should be explicitly + universally quantified. - \<^descr> \<^theory_text>\interpretation expr rewrites eqns\ - interprets \expr\ into a global theory. + \<^descr> \<^theory_text>\interpretation expr rewrites eqns\ interprets \expr\ into a global + theory. When adding declarations to locales, interpreted versions of these declarations are added to the global theory for all interpretations in the @@ -706,46 +698,43 @@ free variable whose name is already bound in the context --- for example, because a constant of that name exists --- add it to the \<^theory_text>\for\ clause. - \<^descr> \<^theory_text>\sublocale name \ defines "defs" expr rewrites eqns\ interprets \expr\ into the locale - \name\. A proof that the specification of \name\ implies the specification - of \expr\ is required. As in the localized version of the theorem command, - the proof is in the context of \name\. After the proof obligation has been - discharged, the locale hierarchy is changed as if \name\ imported \expr\ - (hence the name \<^theory_text>\sublocale\). When the context of \name\ is subsequently - entered, traversing the locale hierarchy will involve the locale instances - of \expr\, and their declarations will be added to the context. This makes - \<^theory_text>\sublocale\ dynamic: extensions of a locale that is instantiated in \expr\ - may take place after the \<^theory_text>\sublocale\ declaration and still become available - in the context. Circular \<^theory_text>\sublocale\ declarations are allowed as long as - they do not lead to infinite chains. + \<^descr> \<^theory_text>\sublocale name \ defines "defs" expr rewrites eqns\ interprets \expr\ + into the locale \name\. A proof that the specification of \name\ implies the + specification of \expr\ is required. As in the localized version of the + theorem command, the proof is in the context of \name\. After the proof + obligation has been discharged, the locale hierarchy is changed as if \name\ + imported \expr\ (hence the name \<^theory_text>\sublocale\). When the context of \name\ is + subsequently entered, traversing the locale hierarchy will involve the + locale instances of \expr\, and their declarations will be added to the + context. This makes \<^theory_text>\sublocale\ dynamic: extensions of a locale that is + instantiated in \expr\ may take place after the \<^theory_text>\sublocale\ declaration and + still become available in the context. Circular \<^theory_text>\sublocale\ declarations + are allowed as long as they do not lead to infinite chains. If interpretations of \name\ exist in the current global theory, the command adds interpretations for \expr\ as well, with the same qualifier, although only for fragments of \expr\ that are not interpreted in the theory already. - Using equations \eqns\ or rewrite definitions \defs\ can - help break infinite chains induced by circular \<^theory_text>\sublocale\ - declarations. + Using equations \eqns\ or rewrite definitions \defs\ can help break infinite + chains induced by circular \<^theory_text>\sublocale\ declarations. In a named context block the \<^theory_text>\sublocale\ command may also be used, but the locale argument must be omitted. The command then refers to the locale (or class) target of the context block. - \<^descr> \<^theory_text>\permanent_interpretation defines "defs" rewrites eqns\ - interprets \expr\ into the target of the current local theory. - When adding declarations to locales, interpreted versions of these - declarations are added to any target for all interpretations - in that target as well. That is, permanent interpretations - dynamically participate in any declarations added to + \<^descr> \<^theory_text>\permanent_interpretation defines "defs" rewrites eqns\ interprets \expr\ + into the target of the current local theory. When adding declarations to + locales, interpreted versions of these declarations are added to any target + for all interpretations in that target as well. That is, permanent + interpretations dynamically participate in any declarations added to locales. - The local theory's underlying target must explicitly support - permanent interpretations. Prominent examples are global theories - (where \<^theory_text>\permanent_interpretation\ technically - corresponds to \<^theory_text>\interpretation\) and locales - (where \<^theory_text>\permanent_interpretation\ technically - corresponds to \<^theory_text>\sublocale\). Unnamed contexts - (see \secref{sec:target}) are not admissible. + The local theory's underlying target must explicitly support permanent + interpretations. Prominent examples are global theories (where + \<^theory_text>\permanent_interpretation\ technically corresponds to \<^theory_text>\interpretation\) + and locales (where \<^theory_text>\permanent_interpretation\ technically corresponds to + \<^theory_text>\sublocale\). Unnamed contexts (see \secref{sec:target}) are not + admissible. \<^descr> \<^theory_text>\print_dependencies expr\ is useful for understanding the effect of an interpretation of \expr\ in the current context. It lists all locale @@ -760,6 +749,7 @@ \<^theory_text>\interpretation\ or \<^theory_text>\interpret\ and one or several \<^theory_text>\sublocale\ declarations. + \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