doc-src/AxClass/generated/NatClass.tex
author wenzelm
Fri, 03 Nov 2000 21:33:53 +0100
changeset 10387 9dac2cad5500
parent 10207 c7c64cd26fc9
child 10395 7ef380745743
permissions -rw-r--r--
adapted "obtain" proofs;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9767
dc2ee9b2e065 updated;
wenzelm
parents: 9672
diff changeset
     1
%
dc2ee9b2e065 updated;
wenzelm
parents: 9672
diff changeset
     2
\begin{isabellebody}%
9921
7acefd99e748 updated;
wenzelm
parents: 9767
diff changeset
     3
\def\isabellecontext{NatClass}%
8906
wenzelm
parents: 8903
diff changeset
     4
%
wenzelm
parents: 8903
diff changeset
     5
\isamarkupheader{Defining natural numbers in FOL \label{sec:ex-natclass}}
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
     6
\isacommand{theory}\ NatClass\ {\isacharequal}\ FOL{\isacharcolon}%
8906
wenzelm
parents: 8903
diff changeset
     7
\begin{isamarkuptext}%
wenzelm
parents: 8903
diff changeset
     8
\medskip\noindent Axiomatic type classes abstract over exactly one
wenzelm
parents: 8903
diff changeset
     9
 type argument. Thus, any \emph{axiomatic} theory extension where each
wenzelm
parents: 8903
diff changeset
    10
 axiom refers to at most one type variable, may be trivially turned
wenzelm
parents: 8903
diff changeset
    11
 into a \emph{definitional} one.
wenzelm
parents: 8903
diff changeset
    12
wenzelm
parents: 8903
diff changeset
    13
 We illustrate this with the natural numbers in
wenzelm
parents: 8903
diff changeset
    14
 Isabelle/FOL.\footnote{See also
wenzelm
parents: 8903
diff changeset
    15
 \url{http://isabelle.in.tum.de/library/FOL/ex/NatClass.html}}%
wenzelm
parents: 8903
diff changeset
    16
\end{isamarkuptext}%
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    17
\isacommand{consts}\isanewline
10140
ba9297b71897 major cleanup -- improved typesetting;
wenzelm
parents: 9921
diff changeset
    18
\ \ zero\ {\isacharcolon}{\isacharcolon}\ {\isacharprime}a\ \ \ \ {\isacharparenleft}{\isachardoublequote}{\isasymzero}{\isachardoublequote}{\isacharparenright}\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    19
\ \ Suc\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\isanewline
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    20
\ \ rec\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharparenleft}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isacharparenright}\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\isanewline
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    21
\isanewline
10140
ba9297b71897 major cleanup -- improved typesetting;
wenzelm
parents: 9921
diff changeset
    22
\isacommand{axclass}\ nat\ {\isacharless}\ {\isachardoublequote}term{\isachardoublequote}\isanewline
ba9297b71897 major cleanup -- improved typesetting;
wenzelm
parents: 9921
diff changeset
    23
\ \ induct{\isacharcolon}\ {\isachardoublequote}P{\isacharparenleft}{\isasymzero}{\isacharparenright}\ {\isasymLongrightarrow}\ {\isacharparenleft}{\isasymAnd}x{\isachardot}\ P{\isacharparenleft}x{\isacharparenright}\ {\isasymLongrightarrow}\ P{\isacharparenleft}Suc{\isacharparenleft}x{\isacharparenright}{\isacharparenright}{\isacharparenright}\ {\isasymLongrightarrow}\ P{\isacharparenleft}n{\isacharparenright}{\isachardoublequote}\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    24
\ \ Suc{\isacharunderscore}inject{\isacharcolon}\ {\isachardoublequote}Suc{\isacharparenleft}m{\isacharparenright}\ {\isacharequal}\ Suc{\isacharparenleft}n{\isacharparenright}\ {\isasymLongrightarrow}\ m\ {\isacharequal}\ n{\isachardoublequote}\isanewline
10207
c7c64cd26fc9 updated;
wenzelm
parents: 10140
diff changeset
    25
\ \ Suc{\isacharunderscore}neq{\isacharunderscore}{\isadigit{0}}{\isacharcolon}\ {\isachardoublequote}Suc{\isacharparenleft}m{\isacharparenright}\ {\isacharequal}\ {\isasymzero}\ {\isasymLongrightarrow}\ R{\isachardoublequote}\isanewline
c7c64cd26fc9 updated;
wenzelm
parents: 10140
diff changeset
    26
\ \ rec{\isacharunderscore}{\isadigit{0}}{\isacharcolon}\ {\isachardoublequote}rec{\isacharparenleft}{\isasymzero}{\isacharcomma}\ a{\isacharcomma}\ f{\isacharparenright}\ {\isacharequal}\ a{\isachardoublequote}\isanewline
10140
ba9297b71897 major cleanup -- improved typesetting;
wenzelm
parents: 9921
diff changeset
    27
\ \ rec{\isacharunderscore}Suc{\isacharcolon}\ {\isachardoublequote}rec{\isacharparenleft}Suc{\isacharparenleft}m{\isacharparenright}{\isacharcomma}\ a{\isacharcomma}\ f{\isacharparenright}\ {\isacharequal}\ f{\isacharparenleft}m{\isacharcomma}\ rec{\isacharparenleft}m{\isacharcomma}\ a{\isacharcomma}\ f{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isanewline
8890
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    28
\isanewline
9a44d8d98731 snapshot of new Isar'ized version;
wenzelm
parents:
diff changeset
    29
\isacommand{constdefs}\isanewline
10207
c7c64cd26fc9 updated;
wenzelm
parents: 10140
diff changeset
    30
\ \ add\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a{\isacharcolon}{\isacharcolon}nat\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequote}{\isacharplus}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{0}}{\isacharparenright}\isanewline
9672
2c208c98f541 updated;
wenzelm
parents: 9665
diff changeset
    31
\ \ {\isachardoublequote}m\ {\isacharplus}\ n\ {\isasymequiv}\ rec{\isacharparenleft}m{\isacharcomma}\ n{\isacharcomma}\ {\isasymlambda}x\ y{\isachardot}\ Suc{\isacharparenleft}y{\isacharparenright}{\isacharparenright}{\isachardoublequote}%
8906
wenzelm
parents: 8903
diff changeset
    32
\begin{isamarkuptext}%
10140
ba9297b71897 major cleanup -- improved typesetting;
wenzelm
parents: 9921
diff changeset
    33
This is an abstract version of the plain \isa{Nat} theory in
8906
wenzelm
parents: 8903
diff changeset
    34
 FOL.\footnote{See
8907
wenzelm
parents: 8906
diff changeset
    35
 \url{http://isabelle.in.tum.de/library/FOL/ex/Nat.html}} Basically,
10140
ba9297b71897 major cleanup -- improved typesetting;
wenzelm
parents: 9921
diff changeset
    36
 we have just replaced all occurrences of type \isa{nat} by \isa{{\isacharprime}a} and used the natural number axioms to define class \isa{nat}.
ba9297b71897 major cleanup -- improved typesetting;
wenzelm
parents: 9921
diff changeset
    37
 There is only a minor snag, that the original recursion operator
ba9297b71897 major cleanup -- improved typesetting;
wenzelm
parents: 9921
diff changeset
    38
 \isa{rec} had to be made monomorphic.
8906
wenzelm
parents: 8903
diff changeset
    39
10140
ba9297b71897 major cleanup -- improved typesetting;
wenzelm
parents: 9921
diff changeset
    40
 Thus class \isa{nat} contains exactly those types \isa{{\isasymtau}} that
ba9297b71897 major cleanup -- improved typesetting;
wenzelm
parents: 9921
diff changeset
    41
 are isomorphic to ``the'' natural numbers (with signature \isa{{\isasymzero}}, \isa{Suc}, \isa{rec}).
8906
wenzelm
parents: 8903
diff changeset
    42
wenzelm
parents: 8903
diff changeset
    43
 \medskip What we have done here can be also viewed as \emph{type
wenzelm
parents: 8903
diff changeset
    44
 specification}.  Of course, it still remains open if there is some
wenzelm
parents: 8903
diff changeset
    45
 type at all that meets the class axioms.  Now a very nice property of
8907
wenzelm
parents: 8906
diff changeset
    46
 axiomatic type classes is that abstract reasoning is always possible
8906
wenzelm
parents: 8903
diff changeset
    47
 --- independent of satisfiability.  The meta-logic won't break, even
8907
wenzelm
parents: 8906
diff changeset
    48
 if some classes (or general sorts) turns out to be empty later ---
wenzelm
parents: 8906
diff changeset
    49
 ``inconsistent'' class definitions may be useless, but do not cause
wenzelm
parents: 8906
diff changeset
    50
 any harm.
8906
wenzelm
parents: 8903
diff changeset
    51
wenzelm
parents: 8903
diff changeset
    52
 Theorems of the abstract natural numbers may be derived in the same
wenzelm
parents: 8903
diff changeset
    53
 way as for the concrete version.  The original proof scripts may be
8907
wenzelm
parents: 8906
diff changeset
    54
 re-used with some trivial changes only (mostly adding some type
8906
wenzelm
parents: 8903
diff changeset
    55
 constraints).%
wenzelm
parents: 8903
diff changeset
    56
\end{isamarkuptext}%
9767
dc2ee9b2e065 updated;
wenzelm
parents: 9672
diff changeset
    57
\isacommand{end}\end{isabellebody}%
9145
9f7b8de5bfaf updated;
wenzelm
parents: 8907
diff changeset
    58
%%% Local Variables:
9f7b8de5bfaf updated;
wenzelm
parents: 8907
diff changeset
    59
%%% mode: latex
9f7b8de5bfaf updated;
wenzelm
parents: 8907
diff changeset
    60
%%% TeX-master: "root"
9f7b8de5bfaf updated;
wenzelm
parents: 8907
diff changeset
    61
%%% End: