7 \isamarkuptrue% |
7 \isamarkuptrue% |
8 \isacommand{theory}\ Product\ {\isacharequal}\ Main{\isacharcolon}\isamarkupfalse% |
8 \isacommand{theory}\ Product\ {\isacharequal}\ Main{\isacharcolon}\isamarkupfalse% |
9 % |
9 % |
10 \begin{isamarkuptext}% |
10 \begin{isamarkuptext}% |
11 \medskip\noindent There is still a feature of Isabelle's type system |
11 \medskip\noindent There is still a feature of Isabelle's type system |
12 left that we have not yet discussed. When declaring polymorphic |
12 left that we have not yet discussed. When declaring polymorphic |
13 constants \isa{c\ {\isasymColon}\ {\isasymsigma}}, the type variables occurring in \isa{{\isasymsigma}} |
13 constants \isa{c\ {\isasymColon}\ {\isasymsigma}}, the type variables occurring in \isa{{\isasymsigma}} |
14 may be constrained by type classes (or even general sorts) in an |
14 may be constrained by type classes (or even general sorts) in an |
15 arbitrary way. Note that by default, in Isabelle/HOL the declaration |
15 arbitrary way. Note that by default, in Isabelle/HOL the |
16 \isa{{\isasymodot}\ {\isasymColon}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} is actually an abbreviation for \isa{{\isasymodot}\ {\isasymColon}\ {\isacharprime}a{\isasymColon}term\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} Since class \isa{term} is the universal |
16 declaration \isa{{\isasymodot}\ {\isasymColon}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} is actually an abbreviation |
17 class of HOL, this is not really a constraint at all. |
17 for \isa{{\isasymodot}\ {\isasymColon}\ {\isacharprime}a{\isasymColon}type\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} Since class \isa{type} is the |
|
18 universal class of HOL, this is not really a constraint at all. |
18 |
19 |
19 The \isa{product} class below provides a less degenerate example of |
20 The \isa{product} class below provides a less degenerate example of |
20 syntactic type classes.% |
21 syntactic type classes.% |
21 \end{isamarkuptext}% |
22 \end{isamarkuptext}% |
22 \isamarkuptrue% |
23 \isamarkuptrue% |
23 \isacommand{axclass}\isanewline |
24 \isacommand{axclass}\isanewline |
24 \ \ product\ {\isasymsubseteq}\ {\isachardoublequote}term{\isachardoublequote}\isanewline |
25 \ \ product\ {\isasymsubseteq}\ type\isanewline |
25 \isamarkupfalse% |
26 \isamarkupfalse% |
26 \isacommand{consts}\isanewline |
27 \isacommand{consts}\isanewline |
27 \ \ product\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a{\isasymColon}product\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymodot}{\isachardoublequote}\ {\isadigit{7}}{\isadigit{0}}{\isacharparenright}\isamarkupfalse% |
28 \ \ product\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a{\isasymColon}product\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isasymodot}{\isachardoublequote}\ {\isadigit{7}}{\isadigit{0}}{\isacharparenright}\isamarkupfalse% |
28 % |
29 % |
29 \begin{isamarkuptext}% |
30 \begin{isamarkuptext}% |
30 Here class \isa{product} is defined as subclass of \isa{term} |
31 Here class \isa{product} is defined as subclass of \isa{type} |
31 without any additional axioms. This effects in logical equivalence |
32 without any additional axioms. This effects in logical equivalence |
32 of \isa{product} and \isa{term}, as is reflected by the trivial |
33 of \isa{product} and \isa{type}, as is reflected by the trivial |
33 introduction rule generated for this definition. |
34 introduction rule generated for this definition. |
34 |
35 |
35 \medskip So what is the difference of declaring \isa{{\isasymodot}\ {\isasymColon}\ {\isacharprime}a{\isasymColon}product\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} vs.\ declaring \isa{{\isasymodot}\ {\isasymColon}\ {\isacharprime}a{\isasymColon}term\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} |
36 \medskip So what is the difference of declaring \isa{{\isasymodot}\ {\isasymColon}\ {\isacharprime}a{\isasymColon}product\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} vs.\ declaring \isa{{\isasymodot}\ {\isasymColon}\ {\isacharprime}a{\isasymColon}type\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} anyway? In this particular case where \isa{product\ {\isasymequiv}\ type}, it should be obvious that both declarations are the same |
36 anyway? In this particular case where \isa{product\ {\isasymequiv}\ term}, it |
37 from the logic's point of view. It even makes the most sense to |
37 should be obvious that both declarations are the same from the |
38 remove sort constraints from constant declarations, as far as the |
38 logic's point of view. It even makes the most sense to remove sort |
39 purely logical meaning is concerned \cite{Wenzel:1997:TPHOL}. |
39 constraints from constant declarations, as far as the purely logical |
|
40 meaning is concerned \cite{Wenzel:1997:TPHOL}. |
|
41 |
40 |
42 On the other hand there are syntactic differences, of course. |
41 On the other hand there are syntactic differences, of course. |
43 Constants \isa{{\isasymodot}} on some type \isa{{\isasymtau}} are rejected by the |
42 Constants \isa{{\isasymodot}} on some type \isa{{\isasymtau}} are rejected by the |
44 type-checker, unless the arity \isa{{\isasymtau}\ {\isasymColon}\ product} is part of the |
43 type-checker, unless the arity \isa{{\isasymtau}\ {\isasymColon}\ product} is part of the |
45 type signature. In our example, this arity may be always added when |
44 type signature. In our example, this arity may be always added when |
46 required by means of an $\INSTANCE$ with the default proof $\DDOT$. |
45 required by means of an $\INSTANCE$ with the default proof $\DDOT$. |
47 |
46 |
48 \medskip Thus, we may observe the following discipline of using |
47 \medskip Thus, we may observe the following discipline of using |
49 syntactic classes. Overloaded polymorphic constants have their type |
48 syntactic classes. Overloaded polymorphic constants have their type |
50 arguments restricted to an associated (logically trivial) class |
49 arguments restricted to an associated (logically trivial) class |
51 \isa{c}. Only immediately before \emph{specifying} these constants |
50 \isa{c}. Only immediately before \emph{specifying} these |
52 on a certain type \isa{{\isasymtau}} do we instantiate \isa{{\isasymtau}\ {\isasymColon}\ c}. |
51 constants on a certain type \isa{{\isasymtau}} do we instantiate \isa{{\isasymtau}\ {\isasymColon}\ c}. |
53 |
52 |
54 This is done for class \isa{product} and type \isa{bool} as |
53 This is done for class \isa{product} and type \isa{bool} as |
55 follows.% |
54 follows.% |
56 \end{isamarkuptext}% |
55 \end{isamarkuptext}% |
57 \isamarkuptrue% |
56 \isamarkuptrue% |
58 \isacommand{instance}\ bool\ {\isacharcolon}{\isacharcolon}\ product\ \isamarkupfalse% |
57 \isacommand{instance}\ bool\ {\isacharcolon}{\isacharcolon}\ product\ \isamarkupfalse% |
59 \isacommand{{\isachardot}{\isachardot}}\isanewline |
58 \isacommand{{\isachardot}{\isachardot}}\isanewline |
60 \isamarkupfalse% |
59 \isamarkupfalse% |