492 interpretation}. Interpretation is possible in locales @{command |
492 interpretation}. Interpretation is possible in locales @{command |
493 "sublocale"}, theories (command @{command "interpretation"}) and |
493 "sublocale"}, theories (command @{command "interpretation"}) and |
494 also within a proof body (command @{command "interpret"}). |
494 also within a proof body (command @{command "interpret"}). |
495 |
495 |
496 \begin{matharray}{rcl} |
496 \begin{matharray}{rcl} |
497 @{command_def "sublocale"} & : & @{text "theory \<rightarrow> proof(prove)"} \\ |
|
498 @{command_def "interpretation"} & : & @{text "theory \<rightarrow> proof(prove)"} \\ |
497 @{command_def "interpretation"} & : & @{text "theory \<rightarrow> proof(prove)"} \\ |
499 @{command_def "interpret"} & : & @{text "proof(state) | proof(chain) \<rightarrow> proof(prove)"} \\ |
498 @{command_def "interpret"} & : & @{text "proof(state) | proof(chain) \<rightarrow> proof(prove)"} \\ |
|
499 @{command_def "sublocale"} & : & @{text "theory \<rightarrow> proof(prove)"} \\ |
500 @{command_def "print_interps"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
500 @{command_def "print_interps"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\ |
501 \end{matharray} |
501 \end{matharray} |
502 |
502 |
503 \indexouternonterm{interp} |
503 \indexouternonterm{interp} |
504 \begin{rail} |
504 \begin{rail} |
505 'sublocale' nameref ('<' | subseteq) localeexpr |
505 'interpretation' localeexpr equations? |
506 ; |
|
507 'interpretation' localeepxr equations? |
|
508 ; |
506 ; |
509 'interpret' localeexpr equations? |
507 'interpret' localeexpr equations? |
510 ; |
508 ; |
|
509 'sublocale' nameref ('<' | subseteq) localeexpr equations? |
|
510 ; |
|
511 equations: 'where' (thmdecl? prop + 'and') |
|
512 ; |
511 'print_interps' nameref |
513 'print_interps' nameref |
512 ; |
514 ; |
513 equations: 'where' (thmdecl? prop + 'and') |
515 \end{rail} |
514 ; |
516 |
515 \end{rail} |
517 \begin{description} |
516 |
|
517 \begin{description} |
|
518 |
|
519 \item @{command "sublocale"}~@{text "name \<subseteq> expr"} |
|
520 interprets @{text expr} in the locale @{text name}. A proof that |
|
521 the specification of @{text name} implies the specification of |
|
522 @{text expr} is required. As in the localized version of the |
|
523 theorem command, the proof is in the context of @{text name}. After |
|
524 the proof obligation has been dischared, the facts of @{text expr} |
|
525 become part of locale @{text name} as \emph{derived} context |
|
526 elements and are available when the context @{text name} is |
|
527 subsequently entered. Note that, like import, this is dynamic: |
|
528 facts added to a locale part of @{text expr} after interpretation |
|
529 become also available in @{text name}. |
|
530 |
|
531 Only specification fragments of @{text expr} that are not already |
|
532 part of @{text name} (be it imported, derived or a derived fragment |
|
533 of the import) are considered in this process. This enables |
|
534 circular interpretations to the extent that no infinite chains are |
|
535 generated in the locale hierarchy. |
|
536 |
|
537 If interpretations of @{text name} exist in the current theory, the |
|
538 command adds interpretations for @{text expr} as well, with the same |
|
539 qualifier, although only for fragments of @{text expr} that are not |
|
540 interpreted in the theory already. |
|
541 |
518 |
542 \item @{command "interpretation"}~@{text "expr \<WHERE> eqns"} |
519 \item @{command "interpretation"}~@{text "expr \<WHERE> eqns"} |
543 interprets @{text expr} in the theory. The command generates proof |
520 interprets @{text expr} in the theory. The command generates proof |
544 obligations for the instantiated specifications (assumes and defines |
521 obligations for the instantiated specifications (assumes and defines |
545 elements). Once these are discharged by the user, instantiated |
522 elements). Once these are discharged by the user, instantiated |
546 facts are added to the theory in a post-processing phase. |
523 facts are added to the theory in a post-processing phase. |
547 |
524 |
548 Additional equations, which are unfolded during |
525 Additional equations, which are unfolded during |
549 post-processing, may be given after the keyword @{keyword "where"}. |
526 post-processing, may be given after the keyword @{keyword "where"}. |
550 This is useful for interpreting concepts introduced through |
527 This is useful for interpreting concepts introduced through |
551 definition specification elements. The equations must be proved. |
528 definitions. The equations must be proved. |
552 |
529 |
553 The command is aware of interpretations already active in the |
530 The command is aware of interpretations already active in the |
554 theory, but does not simplify the goal automatically. In order to |
531 theory, but does not simplify the goal automatically. In order to |
555 simplify the proof obligations use methods @{method intro_locales} |
532 simplify the proof obligations use methods @{method intro_locales} |
556 or @{method unfold_locales}. Post-processing is not applied to |
533 or @{method unfold_locales}. Post-processing is not applied to |
559 case of a locale with import, parts of the interpretation may |
536 case of a locale with import, parts of the interpretation may |
560 already be active. The command will only process facts for new |
537 already be active. The command will only process facts for new |
561 parts. |
538 parts. |
562 |
539 |
563 Adding facts to locales has the effect of adding interpreted facts |
540 Adding facts to locales has the effect of adding interpreted facts |
564 to the theory for all active interpretations also. That is, |
541 to the theory for all interpretations as well. That is, |
565 interpretations dynamically participate in any facts added to |
542 interpretations dynamically participate in any facts added to |
566 locales. |
543 locales. Note that if a theory inherits additional facts for a |
|
544 locale through one parent and an interpretation of that locale |
|
545 through another parent, the additional facts will not be |
|
546 interpreted. |
567 |
547 |
568 \item @{command "interpret"}~@{text "expr \<WHERE> eqns"} interprets |
548 \item @{command "interpret"}~@{text "expr \<WHERE> eqns"} interprets |
569 @{text expr} in the proof context and is otherwise similar to |
549 @{text expr} in the proof context and is otherwise similar to |
570 interpretation in theories. Note that rewrite rules given to |
550 interpretation in theories. Note that rewrite rules given to |
571 @{command "interpret"} should be explicitly universally quantified. |
551 @{command "interpret"} after the @{keyword "where"} keyword should be |
|
552 explicitly universally quantified. |
|
553 |
|
554 \item @{command "sublocale"}~@{text "name \<subseteq> expr \<WHERE> |
|
555 eqns"} |
|
556 interprets @{text expr} in the locale @{text name}. A proof that |
|
557 the specification of @{text name} implies the specification of |
|
558 @{text expr} is required. As in the localized version of the |
|
559 theorem command, the proof is in the context of @{text name}. After |
|
560 the proof obligation has been discharged, the facts of @{text expr} |
|
561 become part of locale @{text name} as \emph{derived} context |
|
562 elements and are available when the context @{text name} is |
|
563 subsequently entered. Note that, like import, this is dynamic: |
|
564 facts added to a locale part of @{text expr} after interpretation |
|
565 become also available in @{text name}. |
|
566 |
|
567 Only specification fragments of @{text expr} that are not already |
|
568 part of @{text name} (be it imported, derived or a derived fragment |
|
569 of the import) are considered in this process. This enables |
|
570 circular interpretations provided that no infinite chains are |
|
571 generated in the locale hierarchy. |
|
572 |
|
573 If interpretations of @{text name} exist in the current theory, the |
|
574 command adds interpretations for @{text expr} as well, with the same |
|
575 qualifier, although only for fragments of @{text expr} that are not |
|
576 interpreted in the theory already. |
|
577 |
|
578 Equations given after @{keyword "where"} amend the morphism through |
|
579 which @{text expr} is interpreted. This enables to map definitions |
|
580 from the interpreted locales to entities of @{text name}. This |
|
581 feature is experimental. |
572 |
582 |
573 \item @{command "print_interps"}~@{text "locale"} lists all |
583 \item @{command "print_interps"}~@{text "locale"} lists all |
574 interpretations of @{text "locale"} in the current theory or proof |
584 interpretations of @{text "locale"} in the current theory or proof |
575 context, including those due to a combination of a @{command |
585 context, including those due to a combination of a @{command |
576 "interpretation"} or @{command "interpret"} and one or several |
586 "interpretation"} or @{command "interpret"} and one or several |