10305
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
|
3 |
\def\isabellecontext{Overloading{\isadigit{1}}}%
|
|
4 |
%
|
|
5 |
\isamarkupsubsubsection{Controlled overloading with type classes}
|
|
6 |
%
|
|
7 |
\begin{isamarkuptext}%
|
|
8 |
We now start with the theory of ordering relations, which we want to phrase
|
|
9 |
in terms of the two binary symbols \isa{{\isacharless}{\isacharless}} and \isa{{\isacharless}{\isacharless}{\isacharequal}}: they have
|
|
10 |
been chosen to avoid clashes with \isa{{\isasymle}} and \isa{{\isacharless}} in theory \isa{Main}. To restrict the application of \isa{{\isacharless}{\isacharless}} and \isa{{\isacharless}{\isacharless}{\isacharequal}} we
|
|
11 |
introduce the class \isa{ordrel}:%
|
|
12 |
\end{isamarkuptext}%
|
|
13 |
\isacommand{axclass}\ ordrel\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}%
|
|
14 |
\begin{isamarkuptext}%
|
|
15 |
\noindent
|
|
16 |
This is a degenerate form of axiomatic type class without any axioms.
|
|
17 |
Its sole purpose is to restrict the use of overloaded constants to meaningful
|
|
18 |
instances:%
|
|
19 |
\end{isamarkuptext}%
|
|
20 |
\isacommand{consts}\isanewline
|
|
21 |
\ \ {\isachardoublequote}{\isacharless}{\isacharless}{\isachardoublequote}\ \ \ \ \ \ \ \ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}{\isacharprime}a{\isacharcolon}{\isacharcolon}ordrel{\isacharparenright}\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\isanewline
|
|
22 |
\ \ {\isachardoublequote}{\isacharless}{\isacharless}{\isacharequal}{\isachardoublequote}\ \ \ \ \ \ \ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}{\isacharprime}a{\isacharcolon}{\isacharcolon}ordrel{\isacharparenright}\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\isanewline
|
|
23 |
\isanewline
|
|
24 |
\isacommand{instance}\ bool\ {\isacharcolon}{\isacharcolon}\ ordrel\isanewline
|
|
25 |
\isacommand{by}\ intro{\isacharunderscore}classes\isanewline
|
|
26 |
\isanewline
|
|
27 |
\isacommand{defs}\ {\isacharparenleft}\isakeyword{overloaded}{\isacharparenright}\isanewline
|
|
28 |
le{\isacharunderscore}bool{\isacharunderscore}def{\isacharcolon}\ \ {\isachardoublequote}P\ {\isacharless}{\isacharless}{\isacharequal}\ Q\ {\isasymequiv}\ P\ {\isasymlongrightarrow}\ Q{\isachardoublequote}\isanewline
|
|
29 |
less{\isacharunderscore}bool{\isacharunderscore}def{\isacharcolon}\ {\isachardoublequote}P\ {\isacharless}{\isacharless}\ Q\ {\isasymequiv}\ {\isasymnot}P\ {\isasymand}\ Q{\isachardoublequote}%
|
|
30 |
\begin{isamarkuptext}%
|
|
31 |
Now \isa{False\ {\isacharless}{\isacharless}{\isacharequal}\ False} is provable%
|
|
32 |
\end{isamarkuptext}%
|
|
33 |
\isacommand{lemma}\ {\isachardoublequote}False\ {\isacharless}{\isacharless}{\isacharequal}\ False{\isachardoublequote}\isanewline
|
|
34 |
\isacommand{by}{\isacharparenleft}simp\ add{\isacharcolon}\ le{\isacharunderscore}bool{\isacharunderscore}def{\isacharparenright}%
|
|
35 |
\begin{isamarkuptext}%
|
|
36 |
\noindent
|
|
37 |
whereas \isa{{\isacharbrackleft}{\isacharbrackright}\ {\isacharless}{\isacharless}{\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}} is not even welltyped. In order to make it welltyped
|
|
38 |
we need to make lists a type of class \isa{ordrel}:%
|
|
39 |
\end{isamarkuptext}%
|
|
40 |
\end{isabellebody}%
|
|
41 |
%%% Local Variables:
|
|
42 |
%%% mode: latex
|
|
43 |
%%% TeX-master: "root"
|
|
44 |
%%% End:
|