doc-src/Locales/Locales/Examples.thy
author ballarin
Tue, 31 Mar 2009 21:25:08 +0200
changeset 30826 a53f4872400e
parent 30780 c3f1e8a9e0b5
child 32960 69916a850301
child 32981 0114e04a0d64
permissions -rw-r--r--
Improvements to the text.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
     1
theory Examples
27375
8d2c3d61c502 adjusted import
haftmann
parents: 27081
diff changeset
     2
imports Main GCD
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
     3
begin
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
     4
27081
6d2a458be1b6 replaced (*<*)(*>*) by invisibility tags;
wenzelm
parents: 27063
diff changeset
     5
hide %invisible const Lattices.lattice
6d2a458be1b6 replaced (*<*)(*>*) by invisibility tags;
wenzelm
parents: 27063
diff changeset
     6
pretty_setmargin %invisible 65
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
     7
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
     8
(*
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
     9
text {* The following presentation will use notation of
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    10
  Isabelle's meta logic, hence a few sentences to explain this.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    11
  The logical
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    12
  primitives are universal quantification (@{text "\<And>"}), entailment
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    13
  (@{text "\<Longrightarrow>"}) and equality (@{text "\<equiv>"}).  Variables (not bound
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    14
  variables) are sometimes preceded by a question mark.  The logic is
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    15
  typed.  Type variables are denoted by @{text "'a"}, @{text "'b"}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    16
  etc., and @{text "\<Rightarrow>"} is the function type.  Double brackets @{text
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    17
  "\<lbrakk>"} and @{text "\<rbrakk>"} are used to abbreviate nested entailment.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    18
*}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    19
*)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    20
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    21
section {* Introduction *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    22
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    23
text {*
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    24
  Locales are based on contexts.  A \emph{context} can be seen as a
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    25
  formula schema
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    26
\[
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    27
  @{text "\<And>x\<^sub>1\<dots>x\<^sub>n. \<lbrakk> A\<^sub>1; \<dots> ;A\<^sub>m \<rbrakk> \<Longrightarrow> \<dots>"}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    28
\]
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    29
  where variables @{text "x\<^sub>1"}, \ldots, @{text "x\<^sub>n"} are called
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    30
  \emph{parameters} and the premises $@{text "A\<^sub>1"}, \ldots,
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    31
  @{text "A\<^sub>m"}$ \emph{assumptions}.  A formula @{text "C"}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    32
  is a \emph{theorem} in the context if it is a conclusion
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    33
\[
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    34
%\label{eq-fact-in-context}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    35
  @{text "\<And>x\<^sub>1\<dots>x\<^sub>n. \<lbrakk> A\<^sub>1; \<dots> ;A\<^sub>m \<rbrakk> \<Longrightarrow> C"}.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    36
\]
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    37
  Isabelle/Isar's notion of context goes beyond this logical view.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    38
  Its contexts record, in a consecutive order, proved
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    39
  conclusions along with attributes, which
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    40
  may control proof procedures.  Contexts also contain syntax information
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    41
  for parameters and for terms depending on them.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    42
  *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    43
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    44
section {* Simple Locales *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    45
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    46
text {*
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    47
  Locales can be seen as persistent contexts.  In its simplest form, a
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    48
  \emph{locale declaration} consists of a sequence of context elements
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    49
  declaring parameters (keyword \isakeyword{fixes}) and assumptions
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    50
  (keyword \isakeyword{assumes}).  The following is the specification of
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    51
  partial orders, as locale @{text partial_order}.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    52
  *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    53
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    54
  locale partial_order =
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    55
    fixes le :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infixl "\<sqsubseteq>" 50)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    56
    assumes refl [intro, simp]: "x \<sqsubseteq> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    57
      and anti_sym [intro]: "\<lbrakk> x \<sqsubseteq> y; y \<sqsubseteq> x \<rbrakk> \<Longrightarrow> x = y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    58
      and trans [trans]: "\<lbrakk> x \<sqsubseteq> y; y \<sqsubseteq> z \<rbrakk> \<Longrightarrow> x \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    59
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    60
text {* The parameter of this locale is @{term le}, with infix syntax
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    61
  @{text \<sqsubseteq>}.  There is an implicit type parameter @{typ "'a"}.  It
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    62
  is not necessary to declare parameter types: most general types will
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    63
  be inferred from the context elements for all parameters.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    64
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    65
  The above declaration not only introduces the locale, it also
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    66
  defines the \emph{locale predicate} @{term partial_order} with
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    67
  definition @{thm [source] partial_order_def}:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    68
  @{thm [display, indent=2] partial_order_def}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    69
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    70
  The specification of a locale is fixed, but its list of conclusions
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    71
  may be extended through Isar commands that take a \emph{target} argument.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    72
  In the following, \isakeyword{definition} and 
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    73
  \isakeyword{theorem} are illustrated.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    74
  Table~\ref{tab:commands-with-target} lists Isar commands that accept
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    75
  a target.  There are various ways of specifying the target.  A
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    76
  target for a single command may be indicated with keyword
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    77
  \isakeyword{in} in the following way:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    78
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    79
\begin{table}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    80
\hrule
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    81
\vspace{2ex}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    82
\begin{center}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    83
\begin{tabular}{ll}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    84
  \isakeyword{definition} & definition through an equation \\
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    85
  \isakeyword{inductive} & inductive definition \\
30826
a53f4872400e Improvements to the text.
ballarin
parents: 30780
diff changeset
    86
  \isakeyword{primrec} & primitive recursion \\
a53f4872400e Improvements to the text.
ballarin
parents: 30780
diff changeset
    87
  \isakeyword{fun}, \isakeyword{function} & general recursion \\
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    88
  \isakeyword{abbreviation} & syntactic abbreviation \\
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    89
  \isakeyword{theorem}, etc.\ & theorem statement with proof \\
30826
a53f4872400e Improvements to the text.
ballarin
parents: 30780
diff changeset
    90
  \isakeyword{theorems}, etc.\ & redeclaration of theorems \\
a53f4872400e Improvements to the text.
ballarin
parents: 30780
diff changeset
    91
  \isakeyword{text}, etc.\ & document markup
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    92
\end{tabular}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    93
\end{center}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    94
\hrule
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    95
\caption{Isar commands that accept a target.}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    96
\label{tab:commands-with-target}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    97
\end{table}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    98
  *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    99
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   100
  definition (in partial_order)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   101
    less :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infixl "\<sqsubset>" 50)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   102
    where "(x \<sqsubset> y) = (x \<sqsubseteq> y \<and> x \<noteq> y)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   103
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   104
text {* A definition in a locale depends on the locale parameters.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   105
  Here, a global constant @{term partial_order.less} is declared, which is lifted over the
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   106
  locale parameter @{term le}.  Its definition is the global theorem
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   107
  @{thm [source] partial_order.less_def}:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   108
  @{thm [display, indent=2] partial_order.less_def}
30826
a53f4872400e Improvements to the text.
ballarin
parents: 30780
diff changeset
   109
  At the same time, the locale is extended by syntax transformations
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   110
  hiding this construction in the context of the locale.  That is,
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   111
  @{term "partial_order.less le"} is printed and parsed as infix
30393
aa6f42252bf6 replaced old locale option by proper "text (in locale)";
wenzelm
parents: 29567
diff changeset
   112
  @{text \<sqsubset>}. *}
aa6f42252bf6 replaced old locale option by proper "text (in locale)";
wenzelm
parents: 29567
diff changeset
   113
aa6f42252bf6 replaced old locale option by proper "text (in locale)";
wenzelm
parents: 29567
diff changeset
   114
text (in partial_order) {* Finally, the conclusion of the definition
aa6f42252bf6 replaced old locale option by proper "text (in locale)";
wenzelm
parents: 29567
diff changeset
   115
  is added to the locale, @{thm [source] less_def}:
aa6f42252bf6 replaced old locale option by proper "text (in locale)";
wenzelm
parents: 29567
diff changeset
   116
  @{thm [display, indent=2] less_def}
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   117
  *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   118
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   119
text {* As an example of a theorem statement in the locale, here is the
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   120
  derivation of a transitivity law. *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   121
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   122
  lemma (in partial_order) less_le_trans [trans]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   123
    "\<lbrakk> x \<sqsubset> y; y \<sqsubseteq> z \<rbrakk> \<Longrightarrow> x \<sqsubset> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   124
    unfolding %visible less_def by %visible (blast intro: trans)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   125
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   126
text {* In the context of the proof, assumptions and theorems of the
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   127
  locale may be used.  Attributes are effective: @{text anti_sym} was
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   128
  declared as introduction rule, hence it is in the context's set of
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   129
  rules used by the classical reasoner by default.  *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   130
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   131
text {* When working with locales, sequences of commands with the same
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   132
  target are frequent.  A block of commands, delimited by
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   133
  \isakeyword{begin} and \isakeyword{end}, makes a theory-like style
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   134
  of working possible.  All commands inside the block refer to the
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   135
  same target.  A block may immediately follow a locale
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   136
  declaration, which makes that locale the target.  Alternatively the
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   137
  target for a block may be given with the \isakeyword{context}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   138
  command.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   139
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   140
  This style of working is illustrated in the block below, where
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   141
  notions of infimum and supremum for partial orders are introduced,
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   142
  together with theorems.  *}
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   143
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   144
  context partial_order begin
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   145
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   146
  definition
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   147
    is_inf where "is_inf x y i =
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   148
      (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
   149
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   150
  definition
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   151
    is_sup where "is_sup x y s =
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   152
      (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
   153
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   154
  lemma %invisible is_infI [intro?]: "i \<sqsubseteq> x \<Longrightarrow> i \<sqsubseteq> y \<Longrightarrow>
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   155
      (\<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
   156
    by (unfold is_inf_def) blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   157
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   158
  lemma %invisible is_inf_lower [elim?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   159
    "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
   160
    by (unfold is_inf_def) blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   161
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   162
  lemma %invisible is_inf_greatest [elim?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   163
      "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
   164
    by (unfold is_inf_def) blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   165
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   166
  theorem is_inf_uniq: "\<lbrakk>is_inf x y i; is_inf x y i'\<rbrakk> \<Longrightarrow> i = i'"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   167
  proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   168
    assume inf: "is_inf x y i"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   169
    assume inf': "is_inf x y i'"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   170
    show ?thesis
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   171
    proof (rule anti_sym)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   172
      from inf' show "i \<sqsubseteq> i'"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   173
      proof (rule is_inf_greatest)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   174
	from inf show "i \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   175
	from inf show "i \<sqsubseteq> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   176
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   177
      from inf show "i' \<sqsubseteq> i"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   178
      proof (rule is_inf_greatest)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   179
	from inf' show "i' \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   180
	from inf' show "i' \<sqsubseteq> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   181
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   182
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   183
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   184
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   185
  theorem %invisible is_inf_related [elim?]: "x \<sqsubseteq> y \<Longrightarrow> is_inf x y x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   186
  proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   187
    assume "x \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   188
    show ?thesis
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   189
    proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   190
      show "x \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   191
      show "x \<sqsubseteq> y" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   192
      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
   193
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   194
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   195
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   196
  lemma %invisible is_supI [intro?]: "x \<sqsubseteq> s \<Longrightarrow> y \<sqsubseteq> s \<Longrightarrow>
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   197
      (\<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
   198
    by (unfold is_sup_def) blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   199
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   200
  lemma %invisible is_sup_least [elim?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   201
      "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
   202
    by (unfold is_sup_def) blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   203
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   204
  lemma %invisible is_sup_upper [elim?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   205
      "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
   206
    by (unfold is_sup_def) blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   207
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   208
  theorem is_sup_uniq: "\<lbrakk>is_sup x y s; is_sup x y s'\<rbrakk> \<Longrightarrow> s = s'"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   209
  proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   210
    assume sup: "is_sup x y s"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   211
    assume sup': "is_sup x y s'"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   212
    show ?thesis
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   213
    proof (rule anti_sym)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   214
      from sup show "s \<sqsubseteq> s'"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   215
      proof (rule is_sup_least)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   216
	from sup' show "x \<sqsubseteq> s'" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   217
	from sup' show "y \<sqsubseteq> s'" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   218
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   219
      from sup' show "s' \<sqsubseteq> s"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   220
      proof (rule is_sup_least)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   221
	from sup show "x \<sqsubseteq> s" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   222
	from sup show "y \<sqsubseteq> s" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   223
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   224
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   225
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   226
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   227
  theorem %invisible is_sup_related [elim?]: "x \<sqsubseteq> y \<Longrightarrow> is_sup x y y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   228
  proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   229
    assume "x \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   230
    show ?thesis
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   231
    proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   232
      show "x \<sqsubseteq> y" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   233
      show "y \<sqsubseteq> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   234
      fix z assume "x \<sqsubseteq> z" and "y \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   235
      show "y \<sqsubseteq> z" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   236
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   237
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   238
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   239
  end
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   240
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   241
text {* Two commands are provided to inspect locales:
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   242
  \isakeyword{print\_locales} lists the names of all locales of the
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   243
  current theory; \isakeyword{print\_locale}~$n$ prints the parameters
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   244
  and assumptions of locale $n$; \isakeyword{print\_locale!}~$n$
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   245
  additionally outputs the conclusions.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   246
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   247
  The syntax of the locale commands discussed in this tutorial is
30780
c3f1e8a9e0b5 Default mode of qualifiers in locale commands.
ballarin
parents: 30580
diff changeset
   248
  shown in Table~\ref{tab:commands}.  The grammer is complete with the
c3f1e8a9e0b5 Default mode of qualifiers in locale commands.
ballarin
parents: 30580
diff changeset
   249
  exception of additional context elements not discussed here.  See the
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   250
  Isabelle/Isar Reference Manual~\cite{IsarRef}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   251
  for full documentation.  *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   252
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   253
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   254
section {* Import \label{sec:import} *}
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   255
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   256
text {* 
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   257
  Algebraic structures are commonly defined by adding operations and
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   258
  properties to existing structures.  For example, partial orders
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   259
  are extended to lattices and total orders.  Lattices are extended to
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   260
  distributive lattices.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   261
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   262
  With locales, this inheritance is achieved through \emph{import} of a
30826
a53f4872400e Improvements to the text.
ballarin
parents: 30780
diff changeset
   263
  locale.  Import is a separate entity in the locale declaration.  If
a53f4872400e Improvements to the text.
ballarin
parents: 30780
diff changeset
   264
  present, it precedes the context elements.
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   265
  *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   266
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   267
  locale lattice = partial_order +
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   268
    assumes ex_inf: "\<exists>inf. is_inf x y inf"
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   269
      and ex_sup: "\<exists>sup. is_sup x y sup"
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   270
  begin
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   271
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   272
text {* These assumptions refer to the predicates for infimum
30826
a53f4872400e Improvements to the text.
ballarin
parents: 30780
diff changeset
   273
  and supremum defined in @{text partial_order}.  We may now introduce
a53f4872400e Improvements to the text.
ballarin
parents: 30780
diff changeset
   274
  the notions of meet and join.  *}
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   275
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   276
  definition
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   277
    meet (infixl "\<sqinter>" 70) where "x \<sqinter> y = (THE inf. is_inf x y inf)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   278
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   279
  definition
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   280
    join (infixl "\<squnion>" 65) where "x \<squnion> y = (THE sup. is_sup x y sup)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   281
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   282
  lemma %invisible meet_equality [elim?]: "is_inf x y i \<Longrightarrow> x \<sqinter> y = i"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   283
  proof (unfold meet_def)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   284
    assume "is_inf x y i"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   285
    then show "(THE i. is_inf x y i) = i"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   286
      by (rule the_equality) (rule is_inf_uniq [OF _ `is_inf x y i`])
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
  lemma %invisible meetI [intro?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   290
      "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
   291
    by (rule meet_equality, rule is_infI) blast+
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   292
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   293
  lemma %invisible is_inf_meet [intro?]: "is_inf x y (x \<sqinter> y)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   294
  proof (unfold meet_def)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   295
    from ex_inf obtain i where "is_inf x y i" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   296
    then show "is_inf x y (THE i. is_inf x y i)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   297
      by (rule theI) (rule is_inf_uniq [OF _ `is_inf x y i`])
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   298
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   299
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   300
  lemma %invisible meet_left [intro?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   301
    "x \<sqinter> y \<sqsubseteq> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   302
    by (rule is_inf_lower) (rule is_inf_meet)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   303
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   304
  lemma %invisible meet_right [intro?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   305
    "x \<sqinter> y \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   306
    by (rule is_inf_lower) (rule is_inf_meet)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   307
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   308
  lemma %invisible meet_le [intro?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   309
    "\<lbrakk> z \<sqsubseteq> x; z \<sqsubseteq> y \<rbrakk> \<Longrightarrow> z \<sqsubseteq> x \<sqinter> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   310
    by (rule is_inf_greatest) (rule is_inf_meet)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   311
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   312
  lemma %invisible join_equality [elim?]: "is_sup x y s \<Longrightarrow> x \<squnion> y = s"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   313
  proof (unfold join_def)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   314
    assume "is_sup x y s"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   315
    then show "(THE s. is_sup x y s) = s"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   316
      by (rule the_equality) (rule is_sup_uniq [OF _ `is_sup x y s`])
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   317
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   318
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   319
  lemma %invisible joinI [intro?]: "x \<sqsubseteq> s \<Longrightarrow> y \<sqsubseteq> s \<Longrightarrow>
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   320
      (\<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
   321
    by (rule join_equality, rule is_supI) blast+
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   322
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   323
  lemma %invisible is_sup_join [intro?]: "is_sup x y (x \<squnion> y)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   324
  proof (unfold join_def)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   325
    from ex_sup obtain s where "is_sup x y s" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   326
    then show "is_sup x y (THE s. is_sup x y s)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   327
      by (rule theI) (rule is_sup_uniq [OF _ `is_sup x y s`])
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   328
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   329
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   330
  lemma %invisible join_left [intro?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   331
    "x \<sqsubseteq> x \<squnion> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   332
    by (rule is_sup_upper) (rule is_sup_join)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   333
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   334
  lemma %invisible join_right [intro?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   335
    "y \<sqsubseteq> x \<squnion> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   336
    by (rule is_sup_upper) (rule is_sup_join)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   337
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   338
  lemma %invisible join_le [intro?]:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   339
    "\<lbrakk> x \<sqsubseteq> z; y \<sqsubseteq> z \<rbrakk> \<Longrightarrow> x \<squnion> y \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   340
    by (rule is_sup_least) (rule is_sup_join)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   341
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   342
  theorem %invisible meet_assoc: "(x \<sqinter> y) \<sqinter> z = x \<sqinter> (y \<sqinter> z)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   343
  proof (rule meetI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   344
    show "x \<sqinter> (y \<sqinter> z) \<sqsubseteq> x \<sqinter> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   345
    proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   346
      show "x \<sqinter> (y \<sqinter> z) \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   347
      show "x \<sqinter> (y \<sqinter> z) \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   348
      proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   349
	have "x \<sqinter> (y \<sqinter> z) \<sqsubseteq> y \<sqinter> z" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   350
	also have "\<dots> \<sqsubseteq> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   351
	finally show ?thesis .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   352
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   353
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   354
    show "x \<sqinter> (y \<sqinter> z) \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   355
    proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   356
      have "x \<sqinter> (y \<sqinter> z) \<sqsubseteq> y \<sqinter> z" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   357
      also have "\<dots> \<sqsubseteq> z" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   358
      finally show ?thesis .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   359
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   360
    fix w assume "w \<sqsubseteq> x \<sqinter> y" and "w \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   361
    show "w \<sqsubseteq> x \<sqinter> (y \<sqinter> z)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   362
    proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   363
      show "w \<sqsubseteq> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   364
      proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   365
	have "w \<sqsubseteq> x \<sqinter> y" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   366
	also have "\<dots> \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   367
	finally show ?thesis .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   368
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   369
      show "w \<sqsubseteq> y \<sqinter> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   370
      proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   371
	show "w \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   372
	proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   373
	  have "w \<sqsubseteq> x \<sqinter> y" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   374
	  also have "\<dots> \<sqsubseteq> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   375
	  finally show ?thesis .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   376
	qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   377
	show "w \<sqsubseteq> z" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   378
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   379
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   380
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   381
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   382
  theorem %invisible meet_commute: "x \<sqinter> y = y \<sqinter> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   383
  proof (rule meetI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   384
    show "y \<sqinter> x \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   385
    show "y \<sqinter> x \<sqsubseteq> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   386
    fix z assume "z \<sqsubseteq> y" and "z \<sqsubseteq> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   387
    then show "z \<sqsubseteq> y \<sqinter> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   388
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   389
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   390
  theorem %invisible meet_join_absorb: "x \<sqinter> (x \<squnion> y) = x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   391
  proof (rule meetI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   392
    show "x \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   393
    show "x \<sqsubseteq> x \<squnion> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   394
    fix z assume "z \<sqsubseteq> x" and "z \<sqsubseteq> x \<squnion> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   395
    show "z \<sqsubseteq> x" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   396
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   397
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   398
  theorem %invisible join_assoc: "(x \<squnion> y) \<squnion> z = x \<squnion> (y \<squnion> z)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   399
  proof (rule joinI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   400
    show "x \<squnion> y \<sqsubseteq> x \<squnion> (y \<squnion> z)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   401
    proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   402
      show "x \<sqsubseteq> x \<squnion> (y \<squnion> z)" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   403
      show "y \<sqsubseteq> x \<squnion> (y \<squnion> z)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   404
      proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   405
	have "y \<sqsubseteq> y \<squnion> z" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   406
	also have "... \<sqsubseteq> x \<squnion> (y \<squnion> z)" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   407
	finally show ?thesis .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   408
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   409
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   410
    show "z \<sqsubseteq> x \<squnion> (y \<squnion> z)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   411
    proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   412
      have "z \<sqsubseteq> y \<squnion> z"  ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   413
      also have "... \<sqsubseteq> x \<squnion> (y \<squnion> z)" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   414
      finally show ?thesis .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   415
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   416
    fix w assume "x \<squnion> y \<sqsubseteq> w" and "z \<sqsubseteq> w"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   417
    show "x \<squnion> (y \<squnion> z) \<sqsubseteq> w"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   418
    proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   419
      show "x \<sqsubseteq> w"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   420
      proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   421
	have "x \<sqsubseteq> x \<squnion> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   422
	also have "\<dots> \<sqsubseteq> w" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   423
	finally show ?thesis .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   424
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   425
      show "y \<squnion> z \<sqsubseteq> w"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   426
      proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   427
	show "y \<sqsubseteq> w"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   428
	proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   429
	  have "y \<sqsubseteq> x \<squnion> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   430
	  also have "... \<sqsubseteq> w" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   431
	  finally show ?thesis .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   432
	qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   433
	show "z \<sqsubseteq> w" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   434
      qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   435
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   436
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   437
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   438
  theorem %invisible join_commute: "x \<squnion> y = y \<squnion> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   439
  proof (rule joinI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   440
    show "x \<sqsubseteq> y \<squnion> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   441
    show "y \<sqsubseteq> y \<squnion> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   442
    fix z assume "y \<sqsubseteq> z" and "x \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   443
    then show "y \<squnion> x \<sqsubseteq> z" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   444
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   445
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   446
  theorem %invisible join_meet_absorb: "x \<squnion> (x \<sqinter> y) = x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   447
  proof (rule joinI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   448
    show "x \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   449
    show "x \<sqinter> y \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   450
    fix z assume "x \<sqsubseteq> z" and "x \<sqinter> y \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   451
    show "x \<sqsubseteq> z" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   452
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   453
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   454
  theorem %invisible meet_idem: "x \<sqinter> x = x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   455
  proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   456
    have "x \<sqinter> (x \<squnion> (x \<sqinter> x)) = x" by (rule meet_join_absorb)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   457
    also have "x \<squnion> (x \<sqinter> x) = x" by (rule join_meet_absorb)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   458
    finally show ?thesis .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   459
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   460
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   461
  theorem %invisible meet_related [elim?]: "x \<sqsubseteq> y \<Longrightarrow> x \<sqinter> y = x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   462
  proof (rule meetI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   463
    assume "x \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   464
    show "x \<sqsubseteq> x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   465
    show "x \<sqsubseteq> y" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   466
    fix z assume "z \<sqsubseteq> x" and "z \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   467
    show "z \<sqsubseteq> x" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   468
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   469
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   470
  theorem %invisible meet_related2 [elim?]: "y \<sqsubseteq> x \<Longrightarrow> x \<sqinter> y = y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   471
    by (drule meet_related) (simp add: meet_commute)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   472
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   473
  theorem %invisible join_related [elim?]: "x \<sqsubseteq> y \<Longrightarrow> x \<squnion> y = y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   474
  proof (rule joinI)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   475
    assume "x \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   476
    show "y \<sqsubseteq> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   477
    show "x \<sqsubseteq> y" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   478
    fix z assume "x \<sqsubseteq> z" and "y \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   479
    show "y \<sqsubseteq> z" by fact
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   480
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   481
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   482
  theorem %invisible join_related2 [elim?]: "y \<sqsubseteq> x \<Longrightarrow> x \<squnion> y = x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   483
    by (drule join_related) (simp add: join_commute)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   484
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   485
  theorem %invisible meet_connection: "(x \<sqsubseteq> y) = (x \<sqinter> y = x)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   486
  proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   487
    assume "x \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   488
    then have "is_inf x y x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   489
    then show "x \<sqinter> y = x" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   490
  next
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   491
    have "x \<sqinter> y \<sqsubseteq> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   492
    also assume "x \<sqinter> y = x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   493
    finally show "x \<sqsubseteq> y" .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   494
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   495
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   496
  theorem %invisible join_connection: "(x \<sqsubseteq> y) = (x \<squnion> y = y)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   497
  proof
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   498
    assume "x \<sqsubseteq> y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   499
    then have "is_sup x y y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   500
    then show "x \<squnion> y = y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   501
  next
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   502
    have "x \<sqsubseteq> x \<squnion> y" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   503
    also assume "x \<squnion> y = y"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   504
    finally show "x \<sqsubseteq> y" .
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_connection2: "(x \<sqsubseteq> y) = (y \<sqinter> x = x)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   508
    using meet_commute meet_connection by simp
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   509
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   510
  theorem %invisible join_connection2: "(x \<sqsubseteq> y) = (x \<squnion> y = y)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   511
    using join_commute join_connection by simp
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   512
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   513
  text %invisible {* Naming according to Jacobson I, p.\ 459. *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   514
  lemmas %invisible L1 = join_commute meet_commute
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   515
  lemmas %invisible L2 = join_assoc meet_assoc
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   516
  (* lemmas L3 = join_idem meet_idem *)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   517
  lemmas %invisible L4 = join_meet_absorb meet_join_absorb
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   518
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   519
  end
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   520
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   521
text {* Locales for total orders and distributive lattices follow.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   522
  Each comes with an example theorem. *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   523
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   524
  locale total_order = partial_order +
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   525
    assumes total: "x \<sqsubseteq> y \<or> y \<sqsubseteq> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   526
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   527
  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
   528
    using total
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   529
    by (unfold less_def) blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   530
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   531
  locale distrib_lattice = lattice +
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   532
    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
   533
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   534
  lemma (in distrib_lattice) join_distr:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   535
    "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
   536
    proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   537
    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
   538
    also have "... = x \<squnion> ((x \<sqinter> z) \<squnion> (y \<sqinter> z))" by (simp add: L2)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   539
    also have "... = x \<squnion> ((x \<squnion> y) \<sqinter> z)" by (simp add: L1 meet_distr)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   540
    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
   541
    also have "... = (x \<squnion> y) \<sqinter> (x \<squnion> z)" by (simp add: meet_distr)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   542
    finally show ?thesis .
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   543
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   544
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   545
text {*
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   546
  The locale hierachy obtained through these declarations is shown in Figure~\ref{fig:lattices}(a).
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   547
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   548
\begin{figure}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   549
\hrule \vspace{2ex}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   550
\begin{center}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   551
\subfigure[Declared hierachy]{
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   552
\begin{tikzpicture}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   553
  \node (po) at (0,0) {@{text partial_order}};
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   554
  \node (lat) at (-1.5,-1) {@{text lattice}};
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   555
  \node (dlat) at (-1.5,-2) {@{text distrib_lattice}};
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   556
  \node (to) at (1.5,-1) {@{text total_order}};
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   557
  \draw (po) -- (lat);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   558
  \draw (lat) -- (dlat);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   559
  \draw (po) -- (to);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   560
%  \draw[->, dashed] (lat) -- (to);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   561
\end{tikzpicture}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   562
} \\
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   563
\subfigure[Total orders are lattices]{
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   564
\begin{tikzpicture}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   565
  \node (po) at (0,0) {@{text partial_order}};
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   566
  \node (lat) at (0,-1) {@{text lattice}};
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   567
  \node (dlat) at (-1.5,-2) {@{text distrib_lattice}};
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   568
  \node (to) at (1.5,-2) {@{text total_order}};
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   569
  \draw (po) -- (lat);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   570
  \draw (lat) -- (dlat);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   571
  \draw (lat) -- (to);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   572
%  \draw[->, dashed] (dlat) -- (to);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   573
\end{tikzpicture}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   574
} \quad
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   575
\subfigure[Total orders are distributive lattices]{
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   576
\begin{tikzpicture}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   577
  \node (po) at (0,0) {@{text partial_order}};
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   578
  \node (lat) at (0,-1) {@{text lattice}};
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   579
  \node (dlat) at (0,-2) {@{text distrib_lattice}};
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   580
  \node (to) at (0,-3) {@{text total_order}};
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   581
  \draw (po) -- (lat);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   582
  \draw (lat) -- (dlat);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   583
  \draw (dlat) -- (to);
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   584
\end{tikzpicture}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   585
}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   586
\end{center}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   587
\hrule
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   588
\caption{Hierarchy of Lattice Locales.}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   589
\label{fig:lattices}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   590
\end{figure}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   591
  *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   592
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   593
section {* Changing the Locale Hierarchy
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 30393
diff changeset
   594
  \label{sec:changing-the-hierarchy} *}
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   595
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   596
text {*
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   597
  Total orders are lattices.  Hence, by deriving the lattice
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   598
  axioms for total orders, the hierarchy may be changed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   599
  and @{text lattice} be placed between @{text partial_order}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   600
  and @{text total_order}, as shown in Figure~\ref{fig:lattices}(b).
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   601
  Changes to the locale hierarchy may be declared
29566
937baa077df2 Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents: 27375
diff changeset
   602
  with the \isakeyword{sublocale} command. *}
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   603
29566
937baa077df2 Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents: 27375
diff changeset
   604
  sublocale %visible total_order \<subseteq> lattice
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   605
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   606
txt {* This enters the context of locale @{text total_order}, in
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   607
  which the goal @{subgoals [display]} must be shown.  First, the
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   608
  locale predicate needs to be unfolded --- for example using its
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   609
  definition or by introduction rules
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   610
  provided by the locale package.  The methods @{text intro_locales}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   611
  and @{text unfold_locales} automate this.  They are aware of the
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   612
  current context and dependencies between locales and automatically
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   613
  discharge goals implied by these.  While @{text unfold_locales}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   614
  always unfolds locale predicates to assumptions, @{text
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   615
  intro_locales} only unfolds definitions along the locale
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   616
  hierarchy, leaving a goal consisting of predicates defined by the
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   617
  locale package.  Occasionally the latter is of advantage since the goal
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   618
  is smaller.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   619
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   620
  For the current goal, we would like to get hold of
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   621
  the assumptions of @{text lattice}, hence @{text unfold_locales}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   622
  is appropriate. *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   623
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   624
  proof unfold_locales
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   625
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   626
txt {* Since both @{text lattice} and @{text total_order}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   627
  inherit @{text partial_order}, the assumptions of the latter are
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   628
  discharged, and the only subgoals that remain are the assumptions
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   629
  introduced in @{text lattice} @{subgoals [display]}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   630
  The proof for the first subgoal is *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   631
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   632
    fix x y
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   633
    from total have "is_inf x y (if x \<sqsubseteq> y then x else y)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   634
      by (auto simp: is_inf_def)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   635
    then show "\<exists>inf. is_inf x y inf" ..
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   636
txt {* The proof for the second subgoal is analogous and not
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   637
  reproduced here. *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   638
  next %invisible
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   639
    fix x y
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   640
    from total have "is_sup x y (if x \<sqsubseteq> y then y else x)"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   641
      by (auto simp: is_sup_def)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   642
    then show "\<exists>sup. is_sup x y sup" .. qed %visible
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   643
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   644
text {* Similarly, total orders are distributive lattices. *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   645
29566
937baa077df2 Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents: 27375
diff changeset
   646
  sublocale total_order \<subseteq> distrib_lattice
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   647
  proof unfold_locales
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   648
    fix %"proof" x y z
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   649
    show "x \<sqinter> (y \<squnion> z) = x \<sqinter> y \<squnion> x \<sqinter> z" (is "?l = ?r")
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   650
      txt {* Jacobson I, p.\ 462 *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   651
    proof -
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   652
      { assume c: "y \<sqsubseteq> x" "z \<sqsubseteq> x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   653
	from c have "?l = y \<squnion> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   654
	  by (metis c join_connection2 join_related2 meet_related2 total)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   655
	also from c have "... = ?r" by (metis meet_related2)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   656
	finally have "?l = ?r" . }
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   657
      moreover
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   658
      { assume c: "x \<sqsubseteq> y \<or> x \<sqsubseteq> z"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   659
	from c have "?l = x"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   660
	  by (metis join_connection2 join_related2 meet_connection total trans)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   661
	also from c have "... = ?r"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   662
	  by (metis join_commute join_related2 meet_connection meet_related2 total)
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   663
	finally have "?l = ?r" . }
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   664
      moreover note total
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   665
      ultimately show ?thesis by blast
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   666
    qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   667
  qed
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   668
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   669
text {* The locale hierarchy is now as shown in Figure~\ref{fig:lattices}(c). *}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   670
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   671
end