src/Doc/Locales/Examples.thy
author wenzelm
Wed, 26 Dec 2018 16:25:20 +0100
changeset 69505 cc2d676d5395
parent 67398 5eb932e604a2
child 69597 ff784d5a5bfb
permissions -rw-r--r--
isabelle update_cartouches -t;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
     1
theory Examples
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
     2
imports Main
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
     3
begin
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
     4
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
     5
(*
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
     6
text {* The following presentation will use notation of
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
     7
  Isabelle's meta logic, hence a few sentences to explain this.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
     8
  The logical
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
     9
  primitives are universal quantification (@{text "\<And>"}), entailment
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    10
  (@{text "\<Longrightarrow>"}) and equality (@{text "\<equiv>"}).  Variables (not bound
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    11
  variables) are sometimes preceded by a question mark.  The logic is
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    12
  typed.  Type variables are denoted by~@{text "'a"},~@{text "'b"}
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    13
  etc., and~@{text "\<Rightarrow>"} is the function type.  Double brackets~@{text
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    14
  "\<lbrakk>"} and~@{text "\<rbrakk>"} are used to abbreviate nested entailment.
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    15
*}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    16
*)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    17
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
    18
section \<open>Introduction\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    19
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
    20
text \<open>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    21
  Locales are based on contexts.  A \emph{context} can be seen as a
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    22
  formula schema
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    23
\[
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
    24
  \<open>\<And>x\<^sub>1\<dots>x\<^sub>n. \<lbrakk> A\<^sub>1; \<dots> ;A\<^sub>m \<rbrakk> \<Longrightarrow> \<dots>\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    25
\]
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
    26
  where the variables~\<open>x\<^sub>1\<close>, \ldots,~\<open>x\<^sub>n\<close> are called
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
    27
  \emph{parameters} and the premises $\<open>A\<^sub>1\<close>, \ldots,~\<open>A\<^sub>m\<close>$ \emph{assumptions}.  A formula~\<open>C\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    28
  is a \emph{theorem} in the context if it is a conclusion
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    29
\[
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
    30
  \<open>\<And>x\<^sub>1\<dots>x\<^sub>n. \<lbrakk> A\<^sub>1; \<dots> ;A\<^sub>m \<rbrakk> \<Longrightarrow> C\<close>.
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    31
\]
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    32
  Isabelle/Isar's notion of context goes beyond this logical view.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    33
  Its contexts record, in a consecutive order, proved
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    34
  conclusions along with \emph{attributes}, which can provide context
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    35
  specific configuration information for proof procedures and concrete
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    36
  syntax.  From a logical perspective, locales are just contexts that
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    37
  have been made persistent.  To the user, though, they provide
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    38
  powerful means for declaring and combining contexts, and for the
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    39
  reuse of theorems proved in these contexts.
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
    40
\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    41
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
    42
section \<open>Simple Locales\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    43
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
    44
text \<open>
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    45
  In its simplest form, a
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    46
  \emph{locale declaration} consists of a sequence of context elements
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    47
  declaring parameters (keyword \isakeyword{fixes}) and assumptions
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    48
  (keyword \isakeyword{assumes}).  The following is the specification of
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
    49
  partial orders, as locale \<open>partial_order\<close>.
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
    50
\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    51
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    52
  locale partial_order =
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    53
    fixes le :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infixl "\<sqsubseteq>" 50)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    54
    assumes refl [intro, simp]: "x \<sqsubseteq> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    55
      and anti_sym [intro]: "\<lbrakk> x \<sqsubseteq> y; y \<sqsubseteq> x \<rbrakk> \<Longrightarrow> x = y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    56
      and trans [trans]: "\<lbrakk> x \<sqsubseteq> y; y \<sqsubseteq> z \<rbrakk> \<Longrightarrow> x \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    57
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
    58
text (in partial_order) \<open>The parameter of this locale is~\<open>le\<close>,
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
    59
  which is a binary predicate with infix syntax~\<open>\<sqsubseteq>\<close>.  The
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    60
  parameter syntax is available in the subsequent
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    61
  assumptions, which are the familiar partial order axioms.
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    62
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    63
  Isabelle recognises unbound names as free variables.  In locale
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    64
  assumptions, these are implicitly universally quantified.  That is,
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    65
  @{term "\<lbrakk> x \<sqsubseteq> y; y \<sqsubseteq> z \<rbrakk> \<Longrightarrow> x \<sqsubseteq> z"} in fact means
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    66
  @{term "\<And>x y z. \<lbrakk> x \<sqsubseteq> y; y \<sqsubseteq> z \<rbrakk> \<Longrightarrow> x \<sqsubseteq> z"}.
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    67
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    68
  Two commands are provided to inspect locales:
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    69
  \isakeyword{print\_locales} lists the names of all locales of the
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    70
  current theory; \isakeyword{print\_locale}~$n$ prints the parameters
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    71
  and assumptions of locale $n$; the variation \isakeyword{print\_locale!}~$n$
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    72
  additionally outputs the conclusions that are stored in the locale.
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    73
  We may inspect the new locale
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    74
  by issuing \isakeyword{print\_locale!} @{term partial_order}.  The output
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    75
  is the following list of context elements.
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    76
\begin{small}
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    77
\begin{alltt}
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    78
  \isakeyword{fixes} le :: "'a \(\Rightarrow\) 'a \(\Rightarrow\)  bool" (\isakeyword{infixl} "\(\sqsubseteq\)" 50)
67398
5eb932e604a2 Manual updates towards conversion of "op" syntax
nipkow
parents: 63724
diff changeset
    79
  \isakeyword{assumes} "partial_order (\(\sqsubseteq\))"
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    80
  \isakeyword{notes} assumption
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    81
    refl [intro, simp] = `?x \(\sqsubseteq\) ?x`
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    82
    \isakeyword{and}
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    83
    anti_sym [intro] = `\(\isasymlbrakk\)?x \(\sqsubseteq\) ?y; ?y \(\sqsubseteq\) ?x\(\isasymrbrakk\) \(\Longrightarrow\) ?x = ?y`
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    84
    \isakeyword{and}
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    85
    trans [trans] = `\(\isasymlbrakk\)?x \(\sqsubseteq\) ?y; ?y \(\sqsubseteq\) ?z\(\isasymrbrakk\) \(\Longrightarrow\) ?x \(\sqsubseteq\) ?z`
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
    86
\end{alltt}
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    87
\end{small}
51799
8fcf6e32544e Clarified confusing sentence in locales tutorial.
ballarin
parents: 48985
diff changeset
    88
8fcf6e32544e Clarified confusing sentence in locales tutorial.
ballarin
parents: 48985
diff changeset
    89
  This differs from the declaration.  The assumptions have turned into
8fcf6e32544e Clarified confusing sentence in locales tutorial.
ballarin
parents: 48985
diff changeset
    90
  conclusions, denoted by the keyword \isakeyword{notes}.  Also,
8fcf6e32544e Clarified confusing sentence in locales tutorial.
ballarin
parents: 48985
diff changeset
    91
  there is only one assumption, namely @{term "partial_order le"}.
8fcf6e32544e Clarified confusing sentence in locales tutorial.
ballarin
parents: 48985
diff changeset
    92
  The locale declaration has introduced the predicate @{term
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    93
  partial_order} to the theory.  This predicate is the
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    94
  \emph{locale predicate}.  Its definition may be inspected by
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    95
  issuing \isakeyword{thm} @{thm [source] partial_order_def}.
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    96
  @{thm [display, indent=2] partial_order_def}
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    97
  In our example, this is a unary predicate over the parameter of the
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    98
  locale.  It is equivalent to the original assumptions, which have
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
    99
  been turned into conclusions and are
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   100
  available as theorems in the context of the locale.  The names and
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   101
  attributes from the locale declaration are associated to these
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   102
  theorems and are effective in the context of the locale.
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   103
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   104
  Each conclusion has a \emph{foundational theorem} as counterpart
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   105
  in the theory.  Technically, this is simply the theorem composed
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   106
  of context and conclusion.  For the transitivity theorem, this is
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   107
  @{thm [source] partial_order.trans}:
37206
7f2a6f3143ad Typo in locales tutorial.
ballarin
parents: 37094
diff changeset
   108
  @{thm [display, indent=2] partial_order.trans}
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   109
\<close>
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   110
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   111
subsection \<open>Targets: Extending Locales\<close>
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   112
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   113
text \<open>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   114
  The specification of a locale is fixed, but its list of conclusions
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   115
  may be extended through Isar commands that take a \emph{target} argument.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   116
  In the following, \isakeyword{definition} and 
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   117
  \isakeyword{theorem} are illustrated.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   118
  Table~\ref{tab:commands-with-target} lists Isar commands that accept
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   119
  a target.  Isar provides various ways of specifying the target.  A
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   120
  target for a single command may be indicated with keyword
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   121
  \isakeyword{in} in the following way:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   122
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   123
\begin{table}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   124
\hrule
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   125
\vspace{2ex}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   126
\begin{center}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   127
\begin{tabular}{ll}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   128
  \isakeyword{definition} & definition through an equation \\
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   129
  \isakeyword{inductive} & inductive definition \\
30826
a53f4872400e Improvements to the text.
ballarin
parents: 30780
diff changeset
   130
  \isakeyword{primrec} & primitive recursion \\
a53f4872400e Improvements to the text.
ballarin
parents: 30780
diff changeset
   131
  \isakeyword{fun}, \isakeyword{function} & general recursion \\
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   132
  \isakeyword{abbreviation} & syntactic abbreviation \\
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   133
  \isakeyword{theorem}, etc.\ & theorem statement with proof \\
30826
a53f4872400e Improvements to the text.
ballarin
parents: 30780
diff changeset
   134
  \isakeyword{theorems}, etc.\ & redeclaration of theorems \\
a53f4872400e Improvements to the text.
ballarin
parents: 30780
diff changeset
   135
  \isakeyword{text}, etc.\ & document markup
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   136
\end{tabular}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   137
\end{center}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   138
\hrule
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   139
\caption{Isar commands that accept a target.}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   140
\label{tab:commands-with-target}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   141
\end{table}
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   142
\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   143
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   144
  definition (in partial_order)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   145
    less :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infixl "\<sqsubset>" 50)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   146
    where "(x \<sqsubset> y) = (x \<sqsubseteq> y \<and> x \<noteq> y)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   147
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   148
text (in partial_order) \<open>The strict order \<open>less\<close> with infix
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   149
  syntax~\<open>\<sqsubset>\<close> is
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   150
  defined in terms of the locale parameter~\<open>le\<close> and the general
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   151
  equality of the object logic we work in.  The definition generates a
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   152
  \emph{foundational constant}
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   153
  @{term partial_order.less} with definition @{thm [source]
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   154
  partial_order.less_def}:
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   155
  @{thm [display, indent=2] partial_order.less_def}
30826
a53f4872400e Improvements to the text.
ballarin
parents: 30780
diff changeset
   156
  At the same time, the locale is extended by syntax transformations
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   157
  hiding this construction in the context of the locale.  Here, the
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   158
  abbreviation \<open>less\<close> is available for
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   159
  \<open>partial_order.less le\<close>, and it is printed
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   160
  and parsed as infix~\<open>\<sqsubset>\<close>.  Finally, the conclusion @{thm [source]
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   161
  less_def} is added to the locale:
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   162
  @{thm [display, indent=2] less_def}
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   163
\<close>
30393
aa6f42252bf6 replaced old locale option by proper "text (in locale)";
wenzelm
parents: 29567
diff changeset
   164
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   165
text \<open>The treatment of theorem statements is more straightforward.
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   166
  As an example, here is the derivation of a transitivity law for the
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   167
  strict order relation.\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   168
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   169
  lemma (in partial_order) less_le_trans [trans]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   170
    "\<lbrakk> x \<sqsubset> y; y \<sqsubseteq> z \<rbrakk> \<Longrightarrow> x \<sqsubset> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   171
    unfolding %visible less_def by %visible (blast intro: trans)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   172
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   173
text \<open>In the context of the proof, conclusions of the
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   174
  locale may be used like theorems.  Attributes are effective: \<open>anti_sym\<close> was
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   175
  declared as introduction rule, hence it is in the context's set of
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   176
  rules used by the classical reasoner by default.\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   177
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   178
subsection \<open>Context Blocks\<close>
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   179
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   180
text \<open>When working with locales, sequences of commands with the same
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   181
  target are frequent.  A block of commands, delimited by
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   182
  \isakeyword{begin} and \isakeyword{end}, makes a theory-like style
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   183
  of working possible.  All commands inside the block refer to the
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   184
  same target.  A block may immediately follow a locale
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   185
  declaration, which makes that locale the target.  Alternatively the
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   186
  target for a block may be given with the \isakeyword{context}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   187
  command.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   188
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   189
  This style of working is illustrated in the block below, where
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   190
  notions of infimum and supremum for partial orders are introduced,
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   191
  together with theorems about their uniqueness.\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   192
46855
f72a2bedd7a9 more precise alignment of begin/end, proof/qed;
wenzelm
parents: 37206
diff changeset
   193
  context partial_order
f72a2bedd7a9 more precise alignment of begin/end, proof/qed;
wenzelm
parents: 37206
diff changeset
   194
  begin
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   195
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   196
  definition
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   197
    is_inf where "is_inf x y i =
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   198
      (i \<sqsubseteq> x \<and> i \<sqsubseteq> y \<and> (\<forall>z. z \<sqsubseteq> x \<and> z \<sqsubseteq> y \<longrightarrow> z \<sqsubseteq> i))"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   199
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   200
  definition
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   201
    is_sup where "is_sup x y s =
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   202
      (x \<sqsubseteq> s \<and> y \<sqsubseteq> s \<and> (\<forall>z. x \<sqsubseteq> z \<and> y \<sqsubseteq> z \<longrightarrow> s \<sqsubseteq> z))"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   203
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   204
  lemma %invisible is_infI [intro?]: "i \<sqsubseteq> x \<Longrightarrow> i \<sqsubseteq> y \<Longrightarrow>
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   205
      (\<And>z. z \<sqsubseteq> x \<Longrightarrow> z \<sqsubseteq> y \<Longrightarrow> z \<sqsubseteq> i) \<Longrightarrow> is_inf x y i"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   206
    by (unfold is_inf_def) blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   207
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   208
  lemma %invisible is_inf_lower [elim?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   209
    "is_inf x y i \<Longrightarrow> (i \<sqsubseteq> x \<Longrightarrow> i \<sqsubseteq> y \<Longrightarrow> C) \<Longrightarrow> C"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   210
    by (unfold is_inf_def) blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   211
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   212
  lemma %invisible is_inf_greatest [elim?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   213
      "is_inf x y i \<Longrightarrow> z \<sqsubseteq> x \<Longrightarrow> z \<sqsubseteq> y \<Longrightarrow> z \<sqsubseteq> i"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   214
    by (unfold is_inf_def) blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   215
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   216
  theorem is_inf_uniq: "\<lbrakk>is_inf x y i; is_inf x y i'\<rbrakk> \<Longrightarrow> i = i'"
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   217
    proof -
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   218
    assume inf: "is_inf x y i"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   219
    assume inf': "is_inf x y i'"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   220
    show ?thesis
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   221
    proof (rule anti_sym)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   222
      from inf' show "i \<sqsubseteq> i'"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   223
      proof (rule is_inf_greatest)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   224
        from inf show "i \<sqsubseteq> x" ..
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   225
        from inf show "i \<sqsubseteq> y" ..
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   226
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   227
      from inf show "i' \<sqsubseteq> i"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   228
      proof (rule is_inf_greatest)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   229
        from inf' show "i' \<sqsubseteq> x" ..
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   230
        from inf' show "i' \<sqsubseteq> y" ..
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   231
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   232
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   233
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   234
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   235
  theorem %invisible is_inf_related [elim?]: "x \<sqsubseteq> y \<Longrightarrow> is_inf x y x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   236
  proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   237
    assume "x \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   238
    show ?thesis
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   239
    proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   240
      show "x \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   241
      show "x \<sqsubseteq> y" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   242
      fix z assume "z \<sqsubseteq> x" and "z \<sqsubseteq> y" show "z \<sqsubseteq> x" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   243
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   244
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   245
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   246
  lemma %invisible is_supI [intro?]: "x \<sqsubseteq> s \<Longrightarrow> y \<sqsubseteq> s \<Longrightarrow>
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   247
      (\<And>z. x \<sqsubseteq> z \<Longrightarrow> y \<sqsubseteq> z \<Longrightarrow> s \<sqsubseteq> z) \<Longrightarrow> is_sup x y s"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   248
    by (unfold is_sup_def) blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   249
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   250
  lemma %invisible is_sup_least [elim?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   251
      "is_sup x y s \<Longrightarrow> x \<sqsubseteq> z \<Longrightarrow> y \<sqsubseteq> z \<Longrightarrow> s \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   252
    by (unfold is_sup_def) blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   253
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   254
  lemma %invisible is_sup_upper [elim?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   255
      "is_sup x y s \<Longrightarrow> (x \<sqsubseteq> s \<Longrightarrow> y \<sqsubseteq> s \<Longrightarrow> C) \<Longrightarrow> C"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   256
    by (unfold is_sup_def) blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   257
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   258
  theorem is_sup_uniq: "\<lbrakk>is_sup x y s; is_sup x y s'\<rbrakk> \<Longrightarrow> s = s'"
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   259
    proof -
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   260
    assume sup: "is_sup x y s"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   261
    assume sup': "is_sup x y s'"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   262
    show ?thesis
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   263
    proof (rule anti_sym)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   264
      from sup show "s \<sqsubseteq> s'"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   265
      proof (rule is_sup_least)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   266
        from sup' show "x \<sqsubseteq> s'" ..
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   267
        from sup' show "y \<sqsubseteq> s'" ..
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   268
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   269
      from sup' show "s' \<sqsubseteq> s"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   270
      proof (rule is_sup_least)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   271
        from sup show "x \<sqsubseteq> s" ..
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   272
        from sup show "y \<sqsubseteq> s" ..
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   273
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   274
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   275
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   276
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   277
  theorem %invisible is_sup_related [elim?]: "x \<sqsubseteq> y \<Longrightarrow> is_sup x y y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   278
  proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   279
    assume "x \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   280
    show ?thesis
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   281
    proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   282
      show "x \<sqsubseteq> y" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   283
      show "y \<sqsubseteq> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   284
      fix z assume "x \<sqsubseteq> z" and "y \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   285
      show "y \<sqsubseteq> z" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   286
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   287
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   288
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   289
  end
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   290
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   291
text \<open>The syntax of the locale commands discussed in this tutorial is
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   292
  shown in Table~\ref{tab:commands}.  The grammar is complete with the
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   293
  exception of the context elements \isakeyword{constrains} and
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   294
  \isakeyword{defines}, which are provided for backward
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   295
  compatibility.  See the Isabelle/Isar Reference
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   296
  Manual @{cite IsarRef} for full documentation.\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   297
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   298
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   299
section \<open>Import \label{sec:import}\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   300
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   301
text \<open>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   302
  Algebraic structures are commonly defined by adding operations and
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   303
  properties to existing structures.  For example, partial orders
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   304
  are extended to lattices and total orders.  Lattices are extended to
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   305
  distributive lattices.\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   306
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   307
text \<open>
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   308
  With locales, this kind of inheritance is achieved through
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   309
  \emph{import} of locales.  The import part of a locale declaration,
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   310
  if present, precedes the context elements.  Here is an example,
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   311
  where partial orders are extended to lattices.
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   312
\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   313
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   314
  locale lattice = partial_order +
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   315
    assumes ex_inf: "\<exists>inf. is_inf x y inf"
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   316
      and ex_sup: "\<exists>sup. is_sup x y sup"
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   317
  begin
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   318
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   319
text \<open>These assumptions refer to the predicates for infimum
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   320
  and supremum defined for \<open>partial_order\<close> in the previous
63724
e7df93d4d9b8 Back to original example theorem.
ballarin
parents: 61419
diff changeset
   321
  section.  We now introduce the notions of meet and join,
e7df93d4d9b8 Back to original example theorem.
ballarin
parents: 61419
diff changeset
   322
  together with an example theorem.\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   323
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   324
  definition
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   325
    meet (infixl "\<sqinter>" 70) where "x \<sqinter> y = (THE inf. is_inf x y inf)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   326
  definition
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   327
    join (infixl "\<squnion>" 65) where "x \<squnion> y = (THE sup. is_sup x y sup)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   328
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   329
  lemma %invisible meet_equality [elim?]: "is_inf x y i \<Longrightarrow> x \<sqinter> y = i"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   330
  proof (unfold meet_def)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   331
    assume "is_inf x y i"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   332
    then show "(THE i. is_inf x y i) = i"
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   333
      by (rule the_equality) (rule is_inf_uniq [OF _ \<open>is_inf x y i\<close>])
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   334
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   335
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   336
  lemma %invisible meetI [intro?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   337
      "i \<sqsubseteq> x \<Longrightarrow> i \<sqsubseteq> y \<Longrightarrow> (\<And>z. z \<sqsubseteq> x \<Longrightarrow> z \<sqsubseteq> y \<Longrightarrow> z \<sqsubseteq> i) \<Longrightarrow> x \<sqinter> y = i"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   338
    by (rule meet_equality, rule is_infI) blast+
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   339
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   340
  lemma %invisible is_inf_meet [intro?]: "is_inf x y (x \<sqinter> y)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   341
  proof (unfold meet_def)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   342
    from ex_inf obtain i where "is_inf x y i" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   343
    then show "is_inf x y (THE i. is_inf x y i)"
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   344
      by (rule theI) (rule is_inf_uniq [OF _ \<open>is_inf x y i\<close>])
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   345
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   346
63724
e7df93d4d9b8 Back to original example theorem.
ballarin
parents: 61419
diff changeset
   347
  lemma meet_left(*<*)[intro?](*>*): "x \<sqinter> y \<sqsubseteq> x"
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   348
    by (rule is_inf_lower) (rule is_inf_meet)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   349
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   350
  lemma %invisible meet_right [intro?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   351
    "x \<sqinter> y \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   352
    by (rule is_inf_lower) (rule is_inf_meet)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   353
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   354
  lemma %invisible meet_le [intro?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   355
    "\<lbrakk> z \<sqsubseteq> x; z \<sqsubseteq> y \<rbrakk> \<Longrightarrow> z \<sqsubseteq> x \<sqinter> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   356
    by (rule is_inf_greatest) (rule is_inf_meet)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   357
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   358
  lemma %invisible join_equality [elim?]: "is_sup x y s \<Longrightarrow> x \<squnion> y = s"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   359
  proof (unfold join_def)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   360
    assume "is_sup x y s"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   361
    then show "(THE s. is_sup x y s) = s"
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   362
      by (rule the_equality) (rule is_sup_uniq [OF _ \<open>is_sup x y s\<close>])
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   363
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   364
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   365
  lemma %invisible joinI [intro?]: "x \<sqsubseteq> s \<Longrightarrow> y \<sqsubseteq> s \<Longrightarrow>
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   366
      (\<And>z. x \<sqsubseteq> z \<Longrightarrow> y \<sqsubseteq> z \<Longrightarrow> s \<sqsubseteq> z) \<Longrightarrow> x \<squnion> y = s"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   367
    by (rule join_equality, rule is_supI) blast+
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   368
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   369
  lemma %invisible is_sup_join [intro?]: "is_sup x y (x \<squnion> y)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   370
  proof (unfold join_def)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   371
    from ex_sup obtain s where "is_sup x y s" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   372
    then show "is_sup x y (THE s. is_sup x y s)"
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   373
      by (rule theI) (rule is_sup_uniq [OF _ \<open>is_sup x y s\<close>])
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   374
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   375
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   376
  lemma %invisible join_left [intro?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   377
    "x \<sqsubseteq> x \<squnion> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   378
    by (rule is_sup_upper) (rule is_sup_join)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   379
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   380
  lemma %invisible join_right [intro?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   381
    "y \<sqsubseteq> x \<squnion> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   382
    by (rule is_sup_upper) (rule is_sup_join)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   383
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   384
  lemma %invisible join_le [intro?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   385
    "\<lbrakk> x \<sqsubseteq> z; y \<sqsubseteq> z \<rbrakk> \<Longrightarrow> x \<squnion> y \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   386
    by (rule is_sup_least) (rule is_sup_join)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   387
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   388
  theorem %invisible meet_assoc: "(x \<sqinter> y) \<sqinter> z = x \<sqinter> (y \<sqinter> z)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   389
  proof (rule meetI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   390
    show "x \<sqinter> (y \<sqinter> z) \<sqsubseteq> x \<sqinter> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   391
    proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   392
      show "x \<sqinter> (y \<sqinter> z) \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   393
      show "x \<sqinter> (y \<sqinter> z) \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   394
      proof -
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   395
        have "x \<sqinter> (y \<sqinter> z) \<sqsubseteq> y \<sqinter> z" ..
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   396
        also have "\<dots> \<sqsubseteq> y" ..
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   397
        finally show ?thesis .
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   398
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   399
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   400
    show "x \<sqinter> (y \<sqinter> z) \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   401
    proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   402
      have "x \<sqinter> (y \<sqinter> z) \<sqsubseteq> y \<sqinter> z" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   403
      also have "\<dots> \<sqsubseteq> z" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   404
      finally show ?thesis .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   405
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   406
    fix w assume "w \<sqsubseteq> x \<sqinter> y" and "w \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   407
    show "w \<sqsubseteq> x \<sqinter> (y \<sqinter> z)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   408
    proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   409
      show "w \<sqsubseteq> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   410
      proof -
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   411
        have "w \<sqsubseteq> x \<sqinter> y" by fact
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   412
        also have "\<dots> \<sqsubseteq> x" ..
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   413
        finally show ?thesis .
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   414
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   415
      show "w \<sqsubseteq> y \<sqinter> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   416
      proof
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   417
        show "w \<sqsubseteq> y"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   418
        proof -
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   419
          have "w \<sqsubseteq> x \<sqinter> y" by fact
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   420
          also have "\<dots> \<sqsubseteq> y" ..
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   421
          finally show ?thesis .
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   422
        qed
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   423
        show "w \<sqsubseteq> z" by fact
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   424
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   425
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   426
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   427
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   428
  theorem %invisible meet_commute: "x \<sqinter> y = y \<sqinter> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   429
  proof (rule meetI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   430
    show "y \<sqinter> x \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   431
    show "y \<sqinter> x \<sqsubseteq> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   432
    fix z assume "z \<sqsubseteq> y" and "z \<sqsubseteq> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   433
    then show "z \<sqsubseteq> y \<sqinter> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   434
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   435
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   436
  theorem %invisible meet_join_absorb: "x \<sqinter> (x \<squnion> y) = x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   437
  proof (rule meetI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   438
    show "x \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   439
    show "x \<sqsubseteq> x \<squnion> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   440
    fix z assume "z \<sqsubseteq> x" and "z \<sqsubseteq> x \<squnion> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   441
    show "z \<sqsubseteq> x" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   442
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   443
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   444
  theorem %invisible join_assoc: "(x \<squnion> y) \<squnion> z = x \<squnion> (y \<squnion> z)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   445
  proof (rule joinI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   446
    show "x \<squnion> y \<sqsubseteq> x \<squnion> (y \<squnion> z)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   447
    proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   448
      show "x \<sqsubseteq> x \<squnion> (y \<squnion> z)" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   449
      show "y \<sqsubseteq> x \<squnion> (y \<squnion> z)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   450
      proof -
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   451
        have "y \<sqsubseteq> y \<squnion> z" ..
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   452
        also have "... \<sqsubseteq> x \<squnion> (y \<squnion> z)" ..
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   453
        finally show ?thesis .
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   454
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   455
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   456
    show "z \<sqsubseteq> x \<squnion> (y \<squnion> z)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   457
    proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   458
      have "z \<sqsubseteq> y \<squnion> z"  ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   459
      also have "... \<sqsubseteq> x \<squnion> (y \<squnion> z)" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   460
      finally show ?thesis .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   461
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   462
    fix w assume "x \<squnion> y \<sqsubseteq> w" and "z \<sqsubseteq> w"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   463
    show "x \<squnion> (y \<squnion> z) \<sqsubseteq> w"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   464
    proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   465
      show "x \<sqsubseteq> w"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   466
      proof -
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   467
        have "x \<sqsubseteq> x \<squnion> y" ..
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   468
        also have "\<dots> \<sqsubseteq> w" by fact
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   469
        finally show ?thesis .
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   470
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   471
      show "y \<squnion> z \<sqsubseteq> w"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   472
      proof
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   473
        show "y \<sqsubseteq> w"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   474
        proof -
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   475
          have "y \<sqsubseteq> x \<squnion> y" ..
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   476
          also have "... \<sqsubseteq> w" by fact
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   477
          finally show ?thesis .
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   478
        qed
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   479
        show "z \<sqsubseteq> w" by fact
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   480
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   481
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   482
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   483
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   484
  theorem %invisible join_commute: "x \<squnion> y = y \<squnion> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   485
  proof (rule joinI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   486
    show "x \<sqsubseteq> y \<squnion> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   487
    show "y \<sqsubseteq> y \<squnion> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   488
    fix z assume "y \<sqsubseteq> z" and "x \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   489
    then show "y \<squnion> x \<sqsubseteq> z" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   490
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   491
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   492
  theorem %invisible join_meet_absorb: "x \<squnion> (x \<sqinter> y) = x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   493
  proof (rule joinI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   494
    show "x \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   495
    show "x \<sqinter> y \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   496
    fix z assume "x \<sqsubseteq> z" and "x \<sqinter> y \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   497
    show "x \<sqsubseteq> z" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   498
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   499
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   500
  theorem %invisible meet_idem: "x \<sqinter> x = x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   501
  proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   502
    have "x \<sqinter> (x \<squnion> (x \<sqinter> x)) = x" by (rule meet_join_absorb)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   503
    also have "x \<squnion> (x \<sqinter> x) = x" by (rule join_meet_absorb)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   504
    finally show ?thesis .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   505
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   506
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   507
  theorem %invisible meet_related [elim?]: "x \<sqsubseteq> y \<Longrightarrow> x \<sqinter> y = x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   508
  proof (rule meetI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   509
    assume "x \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   510
    show "x \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   511
    show "x \<sqsubseteq> y" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   512
    fix z assume "z \<sqsubseteq> x" and "z \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   513
    show "z \<sqsubseteq> x" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   514
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   515
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   516
  theorem %invisible meet_related2 [elim?]: "y \<sqsubseteq> x \<Longrightarrow> x \<sqinter> y = y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   517
    by (drule meet_related) (simp add: meet_commute)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   518
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   519
  theorem %invisible join_related [elim?]: "x \<sqsubseteq> y \<Longrightarrow> x \<squnion> y = y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   520
  proof (rule joinI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   521
    assume "x \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   522
    show "y \<sqsubseteq> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   523
    show "x \<sqsubseteq> y" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   524
    fix z assume "x \<sqsubseteq> z" and "y \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   525
    show "y \<sqsubseteq> z" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   526
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   527
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   528
  theorem %invisible join_related2 [elim?]: "y \<sqsubseteq> x \<Longrightarrow> x \<squnion> y = x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   529
    by (drule join_related) (simp add: join_commute)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   530
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   531
  theorem %invisible meet_connection: "(x \<sqsubseteq> y) = (x \<sqinter> y = x)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   532
  proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   533
    assume "x \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   534
    then have "is_inf x y x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   535
    then show "x \<sqinter> y = x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   536
  next
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   537
    have "x \<sqinter> y \<sqsubseteq> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   538
    also assume "x \<sqinter> y = x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   539
    finally show "x \<sqsubseteq> y" .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   540
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   541
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   542
  theorem %invisible join_connection: "(x \<sqsubseteq> y) = (x \<squnion> y = y)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   543
  proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   544
    assume "x \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   545
    then have "is_sup x y y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   546
    then show "x \<squnion> y = y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   547
  next
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   548
    have "x \<sqsubseteq> x \<squnion> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   549
    also assume "x \<squnion> y = y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   550
    finally show "x \<sqsubseteq> y" .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   551
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   552
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   553
  theorem %invisible meet_connection2: "(x \<sqsubseteq> y) = (y \<sqinter> x = x)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   554
    using meet_commute meet_connection by simp
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   555
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   556
  theorem %invisible join_connection2: "(x \<sqsubseteq> y) = (x \<squnion> y = y)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   557
    using join_commute join_connection by simp
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   558
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   559
  text %invisible \<open>Naming according to Jacobson I, p.\ 459.\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   560
  lemmas %invisible L1 = join_commute meet_commute
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   561
  lemmas %invisible L2 = join_assoc meet_assoc
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   562
  (* lemmas L3 = join_idem meet_idem *)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   563
  lemmas %invisible L4 = join_meet_absorb meet_join_absorb
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   564
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   565
  end
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   566
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   567
text \<open>Locales for total orders and distributive lattices follow to
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   568
  establish a sufficiently rich landscape of locales for
63724
e7df93d4d9b8 Back to original example theorem.
ballarin
parents: 61419
diff changeset
   569
  further examples in this tutorial.\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   570
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   571
  locale total_order = partial_order +
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   572
    assumes total: "x \<sqsubseteq> y \<or> y \<sqsubseteq> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   573
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   574
  lemma (in total_order) less_total: "x \<sqsubset> y \<or> x = y \<or> y \<sqsubset> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   575
    using total
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   576
    by (unfold less_def) blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   577
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   578
  locale distrib_lattice = lattice +
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   579
    assumes meet_distr: "x \<sqinter> (y \<squnion> z) = x \<sqinter> y \<squnion> x \<sqinter> z"
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   580
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   581
  lemma (in distrib_lattice) join_distr:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   582
    "x \<squnion> (y \<sqinter> z) = (x \<squnion> y) \<sqinter> (x \<squnion> z)"  (* txt {* Jacobson I, p.\ 462 *} *)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   583
    proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   584
    have "x \<squnion> (y \<sqinter> z) = (x \<squnion> (x \<sqinter> z)) \<squnion> (y \<sqinter> z)" by (simp add: L4)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   585
    also have "... = x \<squnion> ((x \<sqinter> z) \<squnion> (y \<sqinter> z))" by (simp add: L2)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   586
    also have "... = x \<squnion> ((x \<squnion> y) \<sqinter> z)" by (simp add: L1 meet_distr)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   587
    also have "... = ((x \<squnion> y) \<sqinter> x) \<squnion> ((x \<squnion> y) \<sqinter> z)" by (simp add: L1 L4)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   588
    also have "... = (x \<squnion> y) \<sqinter> (x \<squnion> z)" by (simp add: meet_distr)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   589
    finally show ?thesis .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   590
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   591
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   592
text \<open>
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   593
  The locale hierarchy obtained through these declarations is shown in
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   594
  Figure~\ref{fig:lattices}(a).
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   595
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   596
\begin{figure}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   597
\hrule \vspace{2ex}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   598
\begin{center}
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   599
\subfigure[Declared hierarchy]{
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   600
\begin{tikzpicture}
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   601
  \node (po) at (0,0) {\<open>partial_order\<close>};
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   602
  \node (lat) at (-1.5,-1) {\<open>lattice\<close>};
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   603
  \node (dlat) at (-1.5,-2) {\<open>distrib_lattice\<close>};
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   604
  \node (to) at (1.5,-1) {\<open>total_order\<close>};
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   605
  \draw (po) -- (lat);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   606
  \draw (lat) -- (dlat);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   607
  \draw (po) -- (to);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   608
%  \draw[->, dashed] (lat) -- (to);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   609
\end{tikzpicture}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   610
} \\
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   611
\subfigure[Total orders are lattices]{
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   612
\begin{tikzpicture}
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   613
  \node (po) at (0,0) {\<open>partial_order\<close>};
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   614
  \node (lat) at (0,-1) {\<open>lattice\<close>};
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   615
  \node (dlat) at (-1.5,-2) {\<open>distrib_lattice\<close>};
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   616
  \node (to) at (1.5,-2) {\<open>total_order\<close>};
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   617
  \draw (po) -- (lat);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   618
  \draw (lat) -- (dlat);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   619
  \draw (lat) -- (to);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   620
%  \draw[->, dashed] (dlat) -- (to);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   621
\end{tikzpicture}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   622
} \quad
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   623
\subfigure[Total orders are distributive lattices]{
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   624
\begin{tikzpicture}
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   625
  \node (po) at (0,0) {\<open>partial_order\<close>};
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   626
  \node (lat) at (0,-1) {\<open>lattice\<close>};
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   627
  \node (dlat) at (0,-2) {\<open>distrib_lattice\<close>};
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   628
  \node (to) at (0,-3) {\<open>total_order\<close>};
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   629
  \draw (po) -- (lat);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   630
  \draw (lat) -- (dlat);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   631
  \draw (dlat) -- (to);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   632
\end{tikzpicture}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   633
}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   634
\end{center}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   635
\hrule
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   636
\caption{Hierarchy of Lattice Locales.}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   637
\label{fig:lattices}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   638
\end{figure}
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   639
\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   640
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   641
section \<open>Changing the Locale Hierarchy
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   642
  \label{sec:changing-the-hierarchy}\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   643
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   644
text \<open>
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   645
  Locales enable to prove theorems abstractly, relative to
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   646
  sets of assumptions.  These theorems can then be used in other
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   647
  contexts where the assumptions themselves, or
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   648
  instances of the assumptions, are theorems.  This form of theorem
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   649
  reuse is called \emph{interpretation}.  Locales generalise
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   650
  interpretation from theorems to conclusions, enabling the reuse of
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   651
  definitions and other constructs that are not part of the
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   652
  specifications of the locales.
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   653
37094
2e93e29a809a Typo fixed.
webertj
parents: 36691
diff changeset
   654
  The first form of interpretation we will consider in this tutorial
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   655
  is provided by the \isakeyword{sublocale} command.  It enables to
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   656
  modify the import hierarchy to reflect the \emph{logical} relation
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   657
  between locales.
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   658
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   659
  Consider the locale hierarchy from Figure~\ref{fig:lattices}(a).
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   660
  Total orders are lattices, although this is not reflected here, and
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   661
  definitions, theorems and other conclusions
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   662
  from @{term lattice} are not available in @{term total_order}.  To
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   663
  obtain the situation in Figure~\ref{fig:lattices}(b), it is
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   664
  sufficient to add the conclusions of the latter locale to the former.
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   665
  The \isakeyword{sublocale} command does exactly this.
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   666
  The declaration \isakeyword{sublocale} $l_1
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   667
  \subseteq l_2$ causes locale $l_2$ to be \emph{interpreted} in the
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   668
  context of $l_1$.  This means that all conclusions of $l_2$ are made
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   669
  available in $l_1$.
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   670
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   671
  Of course, the change of hierarchy must be supported by a theorem
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   672
  that reflects, in our example, that total orders are indeed
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   673
  lattices.  Therefore the \isakeyword{sublocale} command generates a
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   674
  goal, which must be discharged by the user.  This is illustrated in
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   675
  the following paragraphs.  First the sublocale relation is stated.
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   676
\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   677
29566
937baa077df2 Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents: 27375
diff changeset
   678
  sublocale %visible total_order \<subseteq> lattice
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   679
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   680
txt \<open>\normalsize
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   681
  This enters the context of locale \<open>total_order\<close>, in
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   682
  which the goal @{subgoals [display]} must be shown.
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   683
  Now the
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   684
  locale predicate needs to be unfolded --- for example, using its
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   685
  definition or by introduction rules
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   686
  provided by the locale package.  For automation, the locale package
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   687
  provides the methods \<open>intro_locales\<close> and \<open>unfold_locales\<close>.  They are aware of the
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   688
  current context and dependencies between locales and automatically
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   689
  discharge goals implied by these.  While \<open>unfold_locales\<close>
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   690
  always unfolds locale predicates to assumptions, \<open>intro_locales\<close> only unfolds definitions along the locale
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   691
  hierarchy, leaving a goal consisting of predicates defined by the
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   692
  locale package.  Occasionally the latter is of advantage since the goal
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   693
  is smaller.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   694
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   695
  For the current goal, we would like to get hold of
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   696
  the assumptions of \<open>lattice\<close>, which need to be shown, hence
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   697
  \<open>unfold_locales\<close> is appropriate.\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   698
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   699
  proof unfold_locales
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   700
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   701
txt \<open>\normalsize
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   702
  Since the fact that both lattices and total orders are partial
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   703
  orders is already reflected in the locale hierarchy, the assumptions
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   704
  of \<open>partial_order\<close> are discharged automatically, and only the
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67398
diff changeset
   705
  assumptions introduced in \<open>lattice\<close> remain as subgoals
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   706
  @{subgoals [display]}
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   707
  The proof for the first subgoal is obtained by constructing an
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   708
  infimum, whose existence is implied by totality.\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   709
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   710
    fix x y
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   711
    from total have "is_inf x y (if x \<sqsubseteq> y then x else y)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   712
      by (auto simp: is_inf_def)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   713
    then show "\<exists>inf. is_inf x y inf" ..
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   714
txt \<open>\normalsize
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   715
   The proof for the second subgoal is analogous and not
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   716
  reproduced here.\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   717
  next %invisible
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   718
    fix x y
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   719
    from total have "is_sup x y (if x \<sqsubseteq> y then y else x)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   720
      by (auto simp: is_sup_def)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   721
    then show "\<exists>sup. is_sup x y sup" .. qed %visible
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   722
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   723
text \<open>Similarly, we may establish that total orders are distributive
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   724
  lattices with a second \isakeyword{sublocale} statement.\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   725
29566
937baa077df2 Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents: 27375
diff changeset
   726
  sublocale total_order \<subseteq> distrib_lattice
32983
a6914429005b Finished revisions of locales tutorial.
ballarin
parents: 32981
diff changeset
   727
    proof unfold_locales
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   728
    fix %"proof" x y z
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   729
    show "x \<sqinter> (y \<squnion> z) = x \<sqinter> y \<squnion> x \<sqinter> z" (is "?l = ?r")
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   730
      txt \<open>Jacobson I, p.\ 462\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   731
    proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   732
      { assume c: "y \<sqsubseteq> x" "z \<sqsubseteq> x"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   733
        from c have "?l = y \<squnion> z"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   734
          by (metis c join_connection2 join_related2 meet_related2 total)
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   735
        also from c have "... = ?r" by (metis meet_related2)
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   736
        finally have "?l = ?r" . }
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   737
      moreover
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   738
      { assume c: "x \<sqsubseteq> y \<or> x \<sqsubseteq> z"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   739
        from c have "?l = x"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   740
          by (metis join_connection2 join_related2 meet_connection total trans)
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   741
        also from c have "... = ?r"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   742
          by (metis join_commute join_related2 meet_connection meet_related2 total)
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30826
diff changeset
   743
        finally have "?l = ?r" . }
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   744
      moreover note total
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   745
      ultimately show ?thesis by blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   746
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   747
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   748
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   749
text \<open>The locale hierarchy is now as shown in
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   750
  Figure~\ref{fig:lattices}(c).\<close>
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   751
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   752
text \<open>
32981
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   753
  Locale interpretation is \emph{dynamic}.  The statement
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   754
  \isakeyword{sublocale} $l_1 \subseteq l_2$ will not just add the
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   755
  current conclusions of $l_2$ to $l_1$.  Rather the dependency is
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   756
  stored, and conclusions that will be
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   757
  added to $l_2$ in future are automatically propagated to $l_1$.
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   758
  The sublocale relation is transitive --- that is, propagation takes
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   759
  effect along chains of sublocales.  Even cycles in the sublocale relation are
0114e04a0d64 Save current state of locales tutorial.
ballarin
parents: 30826
diff changeset
   760
  supported, as long as these cycles do not lead to infinite chains.
58620
7435b6a3f72e more antiquotations;
wenzelm
parents: 51799
diff changeset
   761
  Details are discussed in the technical report @{cite Ballarin2006a}.
61419
3c3f8b182e4b isabelle update_cartouches;
wenzelm
parents: 58620
diff changeset
   762
  See also Section~\ref{sec:infinite-chains} of this tutorial.\<close>
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   763
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   764
end