10328
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
|
3 |
\def\isabellecontext{Axioms}%
|
11866
|
4 |
\isamarkupfalse%
|
10328
|
5 |
%
|
10397
|
6 |
\isamarkupsubsection{Axioms%
|
|
7 |
}
|
11866
|
8 |
\isamarkuptrue%
|
10328
|
9 |
%
|
|
10 |
\begin{isamarkuptext}%
|
11494
|
11 |
Attaching axioms to our classes lets us reason on the
|
|
12 |
level of classes. The results will be applicable to all types in a class,
|
|
13 |
just as in axiomatic mathematics. These ideas are demonstrated by means of
|
|
14 |
our ordering relations.%
|
10328
|
15 |
\end{isamarkuptext}%
|
11866
|
16 |
\isamarkuptrue%
|
10328
|
17 |
%
|
10878
|
18 |
\isamarkupsubsubsection{Partial Orders%
|
10397
|
19 |
}
|
11866
|
20 |
\isamarkuptrue%
|
10328
|
21 |
%
|
|
22 |
\begin{isamarkuptext}%
|
|
23 |
A \emph{partial order} is a subclass of \isa{ordrel}
|
|
24 |
where certain axioms need to hold:%
|
|
25 |
\end{isamarkuptext}%
|
11866
|
26 |
\isamarkuptrue%
|
10328
|
27 |
\isacommand{axclass}\ parord\ {\isacharless}\ ordrel\isanewline
|
|
28 |
refl{\isacharcolon}\ \ \ \ {\isachardoublequote}x\ {\isacharless}{\isacharless}{\isacharequal}\ x{\isachardoublequote}\isanewline
|
|
29 |
trans{\isacharcolon}\ \ \ {\isachardoublequote}{\isasymlbrakk}\ x\ {\isacharless}{\isacharless}{\isacharequal}\ y{\isacharsemicolon}\ y\ {\isacharless}{\isacharless}{\isacharequal}\ z\ {\isasymrbrakk}\ {\isasymLongrightarrow}\ x\ {\isacharless}{\isacharless}{\isacharequal}\ z{\isachardoublequote}\isanewline
|
|
30 |
antisym{\isacharcolon}\ {\isachardoublequote}{\isasymlbrakk}\ x\ {\isacharless}{\isacharless}{\isacharequal}\ y{\isacharsemicolon}\ y\ {\isacharless}{\isacharless}{\isacharequal}\ x\ {\isasymrbrakk}\ {\isasymLongrightarrow}\ x\ {\isacharequal}\ y{\isachardoublequote}\isanewline
|
11866
|
31 |
less{\isacharunderscore}le{\isacharcolon}\ {\isachardoublequote}x\ {\isacharless}{\isacharless}\ y\ {\isacharequal}\ {\isacharparenleft}x\ {\isacharless}{\isacharless}{\isacharequal}\ y\ {\isasymand}\ x\ {\isasymnoteq}\ y{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
|
|
32 |
%
|
10328
|
33 |
\begin{isamarkuptext}%
|
|
34 |
\noindent
|
|
35 |
The first three axioms are the familiar ones, and the final one
|
|
36 |
requires that \isa{{\isacharless}{\isacharless}} and \isa{{\isacharless}{\isacharless}{\isacharequal}} are related as expected.
|
|
37 |
Note that behind the scenes, Isabelle has restricted the axioms to class
|
11494
|
38 |
\isa{parord}. For example, the axiom \isa{refl} really is
|
10878
|
39 |
\isa{{\isacharparenleft}{\isacharquery}x{\isasymColon}{\isacharquery}{\isacharprime}a{\isasymColon}parord{\isacharparenright}\ {\isacharless}{\isacharless}{\isacharequal}\ {\isacharquery}x}.
|
10328
|
40 |
|
10420
|
41 |
We have not made \isa{less{\isacharunderscore}le} a global definition because it would
|
11196
|
42 |
fix once and for all that \isa{{\isacharless}{\isacharless}} is defined in terms of \isa{{\isacharless}{\isacharless}{\isacharequal}} and
|
|
43 |
never the other way around. Below you will see why we want to avoid this
|
11494
|
44 |
asymmetry. The drawback of our choice is that
|
10420
|
45 |
we need to define both \isa{{\isacharless}{\isacharless}{\isacharequal}} and \isa{{\isacharless}{\isacharless}} for each instance.
|
|
46 |
|
10328
|
47 |
We can now prove simple theorems in this abstract setting, for example
|
|
48 |
that \isa{{\isacharless}{\isacharless}} is not symmetric:%
|
|
49 |
\end{isamarkuptext}%
|
11866
|
50 |
\isamarkuptrue%
|
|
51 |
\isacommand{lemma}\ {\isacharbrackleft}simp{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x{\isacharcolon}{\isacharcolon}{\isacharprime}a{\isacharcolon}{\isacharcolon}parord{\isacharparenright}\ {\isacharless}{\isacharless}\ y\ {\isasymLongrightarrow}\ {\isacharparenleft}{\isasymnot}\ y\ {\isacharless}{\isacharless}\ x{\isacharparenright}\ {\isacharequal}\ True{\isachardoublequote}\isamarkupfalse%
|
|
52 |
%
|
10328
|
53 |
\begin{isamarkuptxt}%
|
|
54 |
\noindent
|
11494
|
55 |
The conclusion is not just \isa{{\isasymnot}\ y\ {\isacharless}{\isacharless}\ x} because the
|
|
56 |
simplifier's preprocessor (see \S\ref{sec:simp-preprocessor})
|
|
57 |
would turn it into \isa{{\isacharparenleft}y\ {\isacharless}{\isacharless}\ x{\isacharparenright}\ {\isacharequal}\ False}, yielding
|
|
58 |
a nonterminating rewrite rule.
|
|
59 |
(It would be used to try to prove its own precondition \emph{ad
|
|
60 |
infinitum}.)
|
|
61 |
In the form above, the rule is useful.
|
10328
|
62 |
The type constraint is necessary because otherwise Isabelle would only assume
|
11494
|
63 |
\isa{{\isacharprime}a{\isacharcolon}{\isacharcolon}ordrel} (as required in the type of \isa{{\isacharless}{\isacharless}}),
|
|
64 |
when the proposition is not a theorem. The proof is easy:%
|
10328
|
65 |
\end{isamarkuptxt}%
|
11866
|
66 |
\isamarkuptrue%
|
|
67 |
\isacommand{by}{\isacharparenleft}simp\ add{\isacharcolon}less{\isacharunderscore}le\ antisym{\isacharparenright}\isamarkupfalse%
|
|
68 |
%
|
10328
|
69 |
\begin{isamarkuptext}%
|
|
70 |
We could now continue in this vein and develop a whole theory of
|
|
71 |
results about partial orders. Eventually we will want to apply these results
|
|
72 |
to concrete types, namely the instances of the class. Thus we first need to
|
|
73 |
prove that the types in question, for example \isa{bool}, are indeed
|
|
74 |
instances of \isa{parord}:%
|
|
75 |
\end{isamarkuptext}%
|
11866
|
76 |
\isamarkuptrue%
|
10328
|
77 |
\isacommand{instance}\ bool\ {\isacharcolon}{\isacharcolon}\ parord\isanewline
|
11866
|
78 |
\isamarkupfalse%
|
|
79 |
\isacommand{apply}\ intro{\isacharunderscore}classes\isamarkupfalse%
|
|
80 |
%
|
10328
|
81 |
\begin{isamarkuptxt}%
|
|
82 |
\noindent
|
|
83 |
This time \isa{intro{\isacharunderscore}classes} leaves us with the four axioms,
|
|
84 |
specialized to type \isa{bool}, as subgoals:
|
|
85 |
\begin{isabelle}%
|
|
86 |
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x{\isasymColon}bool{\isachardot}\ x\ {\isacharless}{\isacharless}{\isacharequal}\ x\isanewline
|
10696
|
87 |
\ {\isadigit{2}}{\isachardot}\ {\isasymAnd}{\isacharparenleft}x{\isasymColon}bool{\isacharparenright}\ {\isacharparenleft}y{\isasymColon}bool{\isacharparenright}\ z{\isasymColon}bool{\isachardot}\ {\isasymlbrakk}x\ {\isacharless}{\isacharless}{\isacharequal}\ y{\isacharsemicolon}\ y\ {\isacharless}{\isacharless}{\isacharequal}\ z{\isasymrbrakk}\ {\isasymLongrightarrow}\ x\ {\isacharless}{\isacharless}{\isacharequal}\ z\isanewline
|
|
88 |
\ {\isadigit{3}}{\isachardot}\ {\isasymAnd}{\isacharparenleft}x{\isasymColon}bool{\isacharparenright}\ y{\isasymColon}bool{\isachardot}\ {\isasymlbrakk}x\ {\isacharless}{\isacharless}{\isacharequal}\ y{\isacharsemicolon}\ y\ {\isacharless}{\isacharless}{\isacharequal}\ x{\isasymrbrakk}\ {\isasymLongrightarrow}\ x\ {\isacharequal}\ y\isanewline
|
10328
|
89 |
\ {\isadigit{4}}{\isachardot}\ {\isasymAnd}{\isacharparenleft}x{\isasymColon}bool{\isacharparenright}\ y{\isasymColon}bool{\isachardot}\ {\isacharparenleft}x\ {\isacharless}{\isacharless}\ y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}x\ {\isacharless}{\isacharless}{\isacharequal}\ y\ {\isasymand}\ x\ {\isasymnoteq}\ y{\isacharparenright}%
|
|
90 |
\end{isabelle}
|
11494
|
91 |
Fortunately, the proof is easy for \isa{blast}
|
|
92 |
once we have unfolded the definitions
|
|
93 |
of \isa{{\isacharless}{\isacharless}} and \isa{{\isacharless}{\isacharless}{\isacharequal}} at type \isa{bool}:%
|
10328
|
94 |
\end{isamarkuptxt}%
|
11866
|
95 |
\isamarkuptrue%
|
10328
|
96 |
\isacommand{apply}{\isacharparenleft}simp{\isacharunderscore}all\ {\isacharparenleft}no{\isacharunderscore}asm{\isacharunderscore}use{\isacharparenright}\ only{\isacharcolon}\ le{\isacharunderscore}bool{\isacharunderscore}def\ less{\isacharunderscore}bool{\isacharunderscore}def{\isacharparenright}\isanewline
|
11866
|
97 |
\isamarkupfalse%
|
|
98 |
\isacommand{by}{\isacharparenleft}blast{\isacharcomma}\ blast{\isacharcomma}\ blast{\isacharcomma}\ blast{\isacharparenright}\isamarkupfalse%
|
|
99 |
%
|
10328
|
100 |
\begin{isamarkuptext}%
|
|
101 |
\noindent
|
|
102 |
Can you figure out why we have to include \isa{{\isacharparenleft}no{\isacharunderscore}asm{\isacharunderscore}use{\isacharparenright}}?
|
|
103 |
|
|
104 |
We can now apply our single lemma above in the context of booleans:%
|
|
105 |
\end{isamarkuptext}%
|
11866
|
106 |
\isamarkuptrue%
|
10328
|
107 |
\isacommand{lemma}\ {\isachardoublequote}{\isacharparenleft}P{\isacharcolon}{\isacharcolon}bool{\isacharparenright}\ {\isacharless}{\isacharless}\ Q\ {\isasymLongrightarrow}\ {\isasymnot}{\isacharparenleft}Q\ {\isacharless}{\isacharless}\ P{\isacharparenright}{\isachardoublequote}\isanewline
|
11866
|
108 |
\isamarkupfalse%
|
|
109 |
\isacommand{by}\ simp\isamarkupfalse%
|
|
110 |
%
|
10328
|
111 |
\begin{isamarkuptext}%
|
|
112 |
\noindent
|
10878
|
113 |
The effect is not stunning, but it demonstrates the principle. It also shows
|
11494
|
114 |
that tools like the simplifier can deal with generic rules.
|
|
115 |
The main advantage of the axiomatic method is that
|
|
116 |
theorems can be proved in the abstract and freely reused for each instance.%
|
10328
|
117 |
\end{isamarkuptext}%
|
11866
|
118 |
\isamarkuptrue%
|
10328
|
119 |
%
|
10878
|
120 |
\isamarkupsubsubsection{Linear Orders%
|
10397
|
121 |
}
|
11866
|
122 |
\isamarkuptrue%
|
10328
|
123 |
%
|
|
124 |
\begin{isamarkuptext}%
|
|
125 |
If any two elements of a partial order are comparable it is a
|
11494
|
126 |
\textbf{linear} or \textbf{total} order:%
|
10328
|
127 |
\end{isamarkuptext}%
|
11866
|
128 |
\isamarkuptrue%
|
10328
|
129 |
\isacommand{axclass}\ linord\ {\isacharless}\ parord\isanewline
|
11866
|
130 |
linear{\isacharcolon}\ {\isachardoublequote}x\ {\isacharless}{\isacharless}{\isacharequal}\ y\ {\isasymor}\ y\ {\isacharless}{\isacharless}{\isacharequal}\ x{\isachardoublequote}\isamarkupfalse%
|
|
131 |
%
|
10328
|
132 |
\begin{isamarkuptext}%
|
|
133 |
\noindent
|
|
134 |
By construction, \isa{linord} inherits all axioms from \isa{parord}.
|
11196
|
135 |
Therefore we can show that linearity can be expressed in terms of \isa{{\isacharless}{\isacharless}}
|
10328
|
136 |
as follows:%
|
|
137 |
\end{isamarkuptext}%
|
11866
|
138 |
\isamarkuptrue%
|
11196
|
139 |
\isacommand{lemma}\ {\isachardoublequote}{\isasymAnd}x{\isacharcolon}{\isacharcolon}{\isacharprime}a{\isacharcolon}{\isacharcolon}linord{\isachardot}\ x\ {\isacharless}{\isacharless}\ y\ {\isasymor}\ x\ {\isacharequal}\ y\ {\isasymor}\ y\ {\isacharless}{\isacharless}\ x{\isachardoublequote}\isanewline
|
11866
|
140 |
\isamarkupfalse%
|
10328
|
141 |
\isacommand{apply}{\isacharparenleft}simp\ add{\isacharcolon}\ less{\isacharunderscore}le{\isacharparenright}\isanewline
|
11866
|
142 |
\isamarkupfalse%
|
11196
|
143 |
\isacommand{apply}{\isacharparenleft}insert\ linear{\isacharparenright}\isanewline
|
11866
|
144 |
\isamarkupfalse%
|
10328
|
145 |
\isacommand{apply}\ blast\isanewline
|
11866
|
146 |
\isamarkupfalse%
|
|
147 |
\isacommand{done}\isamarkupfalse%
|
|
148 |
%
|
10328
|
149 |
\begin{isamarkuptext}%
|
11494
|
150 |
Linear orders are an example of subclassing\index{subclasses}
|
|
151 |
by construction, which is the most
|
|
152 |
common case. Subclass relationships can also be proved.
|
|
153 |
This is the topic of the following
|
10654
|
154 |
paragraph.%
|
10328
|
155 |
\end{isamarkuptext}%
|
11866
|
156 |
\isamarkuptrue%
|
10328
|
157 |
%
|
10878
|
158 |
\isamarkupsubsubsection{Strict Orders%
|
10397
|
159 |
}
|
11866
|
160 |
\isamarkuptrue%
|
10328
|
161 |
%
|
|
162 |
\begin{isamarkuptext}%
|
|
163 |
An alternative axiomatization of partial orders takes \isa{{\isacharless}{\isacharless}} rather than
|
11494
|
164 |
\isa{{\isacharless}{\isacharless}{\isacharequal}} as the primary concept. The result is a \textbf{strict} order:%
|
10328
|
165 |
\end{isamarkuptext}%
|
11866
|
166 |
\isamarkuptrue%
|
10328
|
167 |
\isacommand{axclass}\ strord\ {\isacharless}\ ordrel\isanewline
|
|
168 |
irrefl{\isacharcolon}\ \ \ \ \ {\isachardoublequote}{\isasymnot}\ x\ {\isacharless}{\isacharless}\ x{\isachardoublequote}\isanewline
|
|
169 |
less{\isacharunderscore}trans{\isacharcolon}\ {\isachardoublequote}{\isasymlbrakk}\ x\ {\isacharless}{\isacharless}\ y{\isacharsemicolon}\ y\ {\isacharless}{\isacharless}\ z\ {\isasymrbrakk}\ {\isasymLongrightarrow}\ x\ {\isacharless}{\isacharless}\ z{\isachardoublequote}\isanewline
|
11866
|
170 |
le{\isacharunderscore}less{\isacharcolon}\ \ \ \ {\isachardoublequote}x\ {\isacharless}{\isacharless}{\isacharequal}\ y\ {\isacharequal}\ {\isacharparenleft}x\ {\isacharless}{\isacharless}\ y\ {\isasymor}\ x\ {\isacharequal}\ y{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
|
|
171 |
%
|
10328
|
172 |
\begin{isamarkuptext}%
|
|
173 |
\noindent
|
|
174 |
It is well known that partial orders are the same as strict orders. Let us
|
|
175 |
prove one direction, namely that partial orders are a subclass of strict
|
11196
|
176 |
orders.%
|
10328
|
177 |
\end{isamarkuptext}%
|
11866
|
178 |
\isamarkuptrue%
|
10328
|
179 |
\isacommand{instance}\ parord\ {\isacharless}\ strord\isanewline
|
11866
|
180 |
\isamarkupfalse%
|
|
181 |
\isacommand{apply}\ intro{\isacharunderscore}classes\isamarkupfalse%
|
|
182 |
%
|
11196
|
183 |
\begin{isamarkuptxt}%
|
|
184 |
\noindent
|
|
185 |
\begin{isabelle}%
|
|
186 |
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x{\isasymColon}{\isacharprime}a{\isachardot}\ {\isasymnot}\ x\ {\isacharless}{\isacharless}\ x\isanewline
|
|
187 |
\ {\isadigit{2}}{\isachardot}\ {\isasymAnd}{\isacharparenleft}x{\isasymColon}{\isacharprime}a{\isacharparenright}\ {\isacharparenleft}y{\isasymColon}{\isacharprime}a{\isacharparenright}\ z{\isasymColon}{\isacharprime}a{\isachardot}\ {\isasymlbrakk}x\ {\isacharless}{\isacharless}\ y{\isacharsemicolon}\ y\ {\isacharless}{\isacharless}\ z{\isasymrbrakk}\ {\isasymLongrightarrow}\ x\ {\isacharless}{\isacharless}\ z\isanewline
|
|
188 |
\ {\isadigit{3}}{\isachardot}\ {\isasymAnd}{\isacharparenleft}x{\isasymColon}{\isacharprime}a{\isacharparenright}\ y{\isasymColon}{\isacharprime}a{\isachardot}\ {\isacharparenleft}x\ {\isacharless}{\isacharless}{\isacharequal}\ y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}x\ {\isacharless}{\isacharless}\ y\ {\isasymor}\ x\ {\isacharequal}\ y{\isacharparenright}\isanewline
|
|
189 |
type\ variables{\isacharcolon}\isanewline
|
|
190 |
\isaindent{\ \ }{\isacharprime}a\ {\isacharcolon}{\isacharcolon}\ parord%
|
|
191 |
\end{isabelle}
|
|
192 |
Assuming \isa{{\isacharprime}a\ {\isacharcolon}{\isacharcolon}\ parord}, the three axioms of class \isa{strord}
|
|
193 |
are easily proved:%
|
|
194 |
\end{isamarkuptxt}%
|
11866
|
195 |
\ \ \isamarkuptrue%
|
|
196 |
\isacommand{apply}{\isacharparenleft}simp{\isacharunderscore}all\ {\isacharparenleft}no{\isacharunderscore}asm{\isacharunderscore}use{\isacharparenright}\ add{\isacharcolon}less{\isacharunderscore}le{\isacharparenright}\isanewline
|
|
197 |
\ \isamarkupfalse%
|
|
198 |
\isacommand{apply}{\isacharparenleft}blast\ intro{\isacharcolon}\ trans\ antisym{\isacharparenright}\isanewline
|
|
199 |
\isamarkupfalse%
|
11196
|
200 |
\isacommand{apply}{\isacharparenleft}blast\ intro{\isacharcolon}\ refl{\isacharparenright}\isanewline
|
11866
|
201 |
\isamarkupfalse%
|
|
202 |
\isacommand{done}\isamarkupfalse%
|
|
203 |
%
|
10328
|
204 |
\begin{isamarkuptext}%
|
10396
|
205 |
The subclass relation must always be acyclic. Therefore Isabelle will
|
|
206 |
complain if you also prove the relationship \isa{strord\ {\isacharless}\ parord}.%
|
|
207 |
\end{isamarkuptext}%
|
11866
|
208 |
\isamarkuptrue%
|
10396
|
209 |
%
|
10878
|
210 |
\isamarkupsubsubsection{Multiple Inheritance and Sorts%
|
10397
|
211 |
}
|
11866
|
212 |
\isamarkuptrue%
|
10396
|
213 |
%
|
|
214 |
\begin{isamarkuptext}%
|
|
215 |
A class may inherit from more than one direct superclass. This is called
|
11494
|
216 |
\bfindex{multiple inheritance}. For example, we could define
|
10396
|
217 |
the classes of well-founded orderings and well-orderings:%
|
|
218 |
\end{isamarkuptext}%
|
11866
|
219 |
\isamarkuptrue%
|
10396
|
220 |
\isacommand{axclass}\ wford\ {\isacharless}\ parord\isanewline
|
|
221 |
wford{\isacharcolon}\ {\isachardoublequote}wf\ {\isacharbraceleft}{\isacharparenleft}y{\isacharcomma}x{\isacharparenright}{\isachardot}\ y\ {\isacharless}{\isacharless}\ x{\isacharbraceright}{\isachardoublequote}\isanewline
|
|
222 |
\isanewline
|
11866
|
223 |
\isamarkupfalse%
|
|
224 |
\isacommand{axclass}\ wellord\ {\isacharless}\ linord{\isacharcomma}\ wford\isamarkupfalse%
|
|
225 |
%
|
10396
|
226 |
\begin{isamarkuptext}%
|
10328
|
227 |
\noindent
|
10396
|
228 |
The last line expresses the usual definition: a well-ordering is a linear
|
|
229 |
well-founded ordering. The result is the subclass diagram in
|
|
230 |
Figure~\ref{fig:subclass}.
|
|
231 |
|
|
232 |
\begin{figure}[htbp]
|
10328
|
233 |
\[
|
10396
|
234 |
\begin{array}{r@ {}r@ {}c@ {}l@ {}l}
|
|
235 |
& & \isa{term}\\
|
|
236 |
& & |\\
|
|
237 |
& & \isa{ordrel}\\
|
|
238 |
& & |\\
|
|
239 |
& & \isa{strord}\\
|
|
240 |
& & |\\
|
|
241 |
& & \isa{parord} \\
|
|
242 |
& / & & \backslash \\
|
|
243 |
\isa{linord} & & & & \isa{wford} \\
|
|
244 |
& \backslash & & / \\
|
|
245 |
& & \isa{wellord}
|
10328
|
246 |
\end{array}
|
|
247 |
\]
|
10878
|
248 |
\caption{Subclass Diagram}
|
10396
|
249 |
\label{fig:subclass}
|
|
250 |
\end{figure}
|
10328
|
251 |
|
10396
|
252 |
Since class \isa{wellord} does not introduce any new axioms, it can simply
|
|
253 |
be viewed as the intersection of the two classes \isa{linord} and \isa{wford}. Such intersections need not be given a new name but can be created on
|
|
254 |
the fly: the expression $\{C@1,\dots,C@n\}$, where the $C@i$ are classes,
|
|
255 |
represents the intersection of the $C@i$. Such an expression is called a
|
11428
|
256 |
\textbf{sort},\index{sorts} and sorts can appear in most places where we have only shown
|
10396
|
257 |
classes so far, for example in type constraints: \isa{{\isacharprime}a{\isacharcolon}{\isacharcolon}{\isacharbraceleft}linord{\isacharcomma}wford{\isacharbraceright}}.
|
11196
|
258 |
In fact, \isa{{\isacharprime}a{\isacharcolon}{\isacharcolon}C} is short for \isa{{\isacharprime}a{\isacharcolon}{\isacharcolon}{\isacharbraceleft}C{\isacharbraceright}}.
|
10396
|
259 |
However, we do not pursue this rarefied concept further.
|
10328
|
260 |
|
10396
|
261 |
This concludes our demonstration of type classes based on orderings. We
|
|
262 |
remind our readers that \isa{Main} contains a theory of
|
10328
|
263 |
orderings phrased in terms of the usual \isa{{\isasymle}} and \isa{{\isacharless}}.
|
11494
|
264 |
If possible, base your own ordering relations on this theory.%
|
10328
|
265 |
\end{isamarkuptext}%
|
11866
|
266 |
\isamarkuptrue%
|
10328
|
267 |
%
|
10397
|
268 |
\isamarkupsubsubsection{Inconsistencies%
|
|
269 |
}
|
11866
|
270 |
\isamarkuptrue%
|
10328
|
271 |
%
|
|
272 |
\begin{isamarkuptext}%
|
11494
|
273 |
The reader may be wondering what happens if we
|
10328
|
274 |
attach an inconsistent set of axioms to a class. So far we have always
|
|
275 |
avoided to add new axioms to HOL for fear of inconsistencies and suddenly it
|
|
276 |
seems that we are throwing all caution to the wind. So why is there no
|
|
277 |
problem?
|
|
278 |
|
|
279 |
The point is that by construction, all type variables in the axioms of an
|
|
280 |
\isacommand{axclass} are automatically constrained with the class being
|
|
281 |
defined (as shown for axiom \isa{refl} above). These constraints are
|
|
282 |
always carried around and Isabelle takes care that they are never lost,
|
|
283 |
unless the type variable is instantiated with a type that has been shown to
|
|
284 |
belong to that class. Thus you may be able to prove \isa{False}
|
|
285 |
from your axioms, but Isabelle will remind you that this
|
12332
|
286 |
theorem has the hidden hypothesis that the class is non-empty.
|
|
287 |
|
|
288 |
Even if each individual class is consistent, intersections of (unrelated)
|
|
289 |
classes readily become inconsistent in practice. Now we know this need not
|
|
290 |
worry us.%
|
10328
|
291 |
\end{isamarkuptext}%
|
11866
|
292 |
\isamarkuptrue%
|
|
293 |
\isamarkupfalse%
|
10328
|
294 |
\end{isabellebody}%
|
|
295 |
%%% Local Variables:
|
|
296 |
%%% mode: latex
|
|
297 |
%%% TeX-master: "root"
|
|
298 |
%%% End:
|