doc-src/AxClass/Nat/document/NatClass.tex
changeset 17175 1eced27ee0e1
parent 17128 bb09ba3e5b2f
child 17181 5f42dd5e6570
equal deleted inserted replaced
17174:11aa41ed306d 17175:1eced27ee0e1
     1 %
     1 %
     2 \begin{isabellebody}%
     2 \begin{isabellebody}%
     3 \def\isabellecontext{NatClass}%
     3 \def\isabellecontext{NatClass}%
     4 \isamarkuptrue%
       
     5 %
     4 %
     6 \isamarkupheader{Defining natural numbers in FOL \label{sec:ex-natclass}%
     5 \isamarkupheader{Defining natural numbers in FOL \label{sec:ex-natclass}%
     7 }
     6 }
       
     7 \isamarkuptrue%
     8 %
     8 %
     9 \isadelimtheory
     9 \isadelimtheory
    10 %
    10 %
    11 \endisadelimtheory
    11 \endisadelimtheory
    12 %
    12 %
    13 \isatagtheory
    13 \isatagtheory
    14 \isamarkupfalse%
    14 \isacommand{theory}\isamarkupfalse%
    15 \isacommand{theory}\ NatClass\ \isakeyword{imports}\ FOL\ \isakeyword{begin}%
    15 \ NatClass\ \isakeyword{imports}\ FOL\ \isakeyword{begin}%
    16 \endisatagtheory
    16 \endisatagtheory
    17 {\isafoldtheory}%
    17 {\isafoldtheory}%
    18 %
    18 %
    19 \isadelimtheory
    19 \isadelimtheory
    20 %
    20 %
    21 \endisadelimtheory
    21 \endisadelimtheory
    22 \isamarkuptrue%
       
    23 %
    22 %
    24 \begin{isamarkuptext}%
    23 \begin{isamarkuptext}%
    25 \medskip\noindent Axiomatic type classes abstract over exactly one
    24 \medskip\noindent Axiomatic type classes abstract over exactly one
    26  type argument. Thus, any \emph{axiomatic} theory extension where each
    25  type argument. Thus, any \emph{axiomatic} theory extension where each
    27  axiom refers to at most one type variable, may be trivially turned
    26  axiom refers to at most one type variable, may be trivially turned
    29 
    28 
    30  We illustrate this with the natural numbers in
    29  We illustrate this with the natural numbers in
    31  Isabelle/FOL.\footnote{See also
    30  Isabelle/FOL.\footnote{See also
    32  \url{http://isabelle.in.tum.de/library/FOL/ex/NatClass.html}}%
    31  \url{http://isabelle.in.tum.de/library/FOL/ex/NatClass.html}}%
    33 \end{isamarkuptext}%
    32 \end{isamarkuptext}%
    34 \isamarkupfalse%
    33 \isamarkuptrue%
    35 \isacommand{consts}\isanewline
    34 \isacommand{consts}\isamarkupfalse%
    36 \ \ zero\ {\isacharcolon}{\isacharcolon}\ {\isacharprime}a\ \ \ \ {\isacharparenleft}{\isachardoublequote}{\isasymzero}{\isachardoublequote}{\isacharparenright}\isanewline
       
    37 \ \ Suc\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\isanewline
       
    38 \ \ 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
       
    39 \isanewline
    35 \isanewline
    40 \isamarkupfalse%
    36 \ \ zero\ {\isacharcolon}{\isacharcolon}\ {\isacharprime}a\ \ \ \ {\isacharparenleft}{\isachardoublequoteopen}{\isasymzero}{\isachardoublequoteclose}{\isacharparenright}\isanewline
    41 \isacommand{axclass}\ nat\ {\isasymsubseteq}\ {\isachardoublequote}term{\isachardoublequote}\isanewline
    37 \ \ Suc\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequoteclose}\isanewline
    42 \ \ 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
    38 \ \ rec\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharparenleft}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isacharparenright}\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequoteclose}\isanewline
    43 \ \ Suc{\isacharunderscore}inject{\isacharcolon}\ {\isachardoublequote}Suc{\isacharparenleft}m{\isacharparenright}\ {\isacharequal}\ Suc{\isacharparenleft}n{\isacharparenright}\ {\isasymLongrightarrow}\ m\ {\isacharequal}\ n{\isachardoublequote}\isanewline
       
    44 \ \ Suc{\isacharunderscore}neq{\isacharunderscore}{\isadigit{0}}{\isacharcolon}\ {\isachardoublequote}Suc{\isacharparenleft}m{\isacharparenright}\ {\isacharequal}\ {\isasymzero}\ {\isasymLongrightarrow}\ R{\isachardoublequote}\isanewline
       
    45 \ \ rec{\isacharunderscore}{\isadigit{0}}{\isacharcolon}\ {\isachardoublequote}rec{\isacharparenleft}{\isasymzero}{\isacharcomma}\ a{\isacharcomma}\ f{\isacharparenright}\ {\isacharequal}\ a{\isachardoublequote}\isanewline
       
    46 \ \ 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
       
    47 \isanewline
    39 \isanewline
    48 \isamarkupfalse%
    40 \isacommand{axclass}\isamarkupfalse%
    49 \isacommand{constdefs}\isanewline
    41 \ nat\ {\isasymsubseteq}\ {\isachardoublequoteopen}term{\isachardoublequoteclose}\isanewline
    50 \ \ 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
    42 \ \ induct{\isacharcolon}\ {\isachardoublequoteopen}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}{\isachardoublequoteclose}\isanewline
    51 \ \ {\isachardoublequote}m\ {\isacharplus}\ n\ {\isasymequiv}\ rec{\isacharparenleft}m{\isacharcomma}\ n{\isacharcomma}\ {\isasymlambda}x\ y{\isachardot}\ Suc{\isacharparenleft}y{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isamarkuptrue%
    43 \ \ Suc{\isacharunderscore}inject{\isacharcolon}\ {\isachardoublequoteopen}Suc{\isacharparenleft}m{\isacharparenright}\ {\isacharequal}\ Suc{\isacharparenleft}n{\isacharparenright}\ {\isasymLongrightarrow}\ m\ {\isacharequal}\ n{\isachardoublequoteclose}\isanewline
    52 %
    44 \ \ Suc{\isacharunderscore}neq{\isacharunderscore}{\isadigit{0}}{\isacharcolon}\ {\isachardoublequoteopen}Suc{\isacharparenleft}m{\isacharparenright}\ {\isacharequal}\ {\isasymzero}\ {\isasymLongrightarrow}\ R{\isachardoublequoteclose}\isanewline
       
    45 \ \ rec{\isacharunderscore}{\isadigit{0}}{\isacharcolon}\ {\isachardoublequoteopen}rec{\isacharparenleft}{\isasymzero}{\isacharcomma}\ a{\isacharcomma}\ f{\isacharparenright}\ {\isacharequal}\ a{\isachardoublequoteclose}\isanewline
       
    46 \ \ rec{\isacharunderscore}Suc{\isacharcolon}\ {\isachardoublequoteopen}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}{\isachardoublequoteclose}\isanewline
       
    47 \isanewline
       
    48 \isacommand{constdefs}\isamarkupfalse%
       
    49 \isanewline
       
    50 \ \ add\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}a{\isacharcolon}{\isacharcolon}nat\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequoteclose}\ \ \ \ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequoteopen}{\isacharplus}{\isachardoublequoteclose}\ {\isadigit{6}}{\isadigit{0}}{\isacharparenright}\isanewline
       
    51 \ \ {\isachardoublequoteopen}m\ {\isacharplus}\ n\ {\isasymequiv}\ rec{\isacharparenleft}m{\isacharcomma}\ n{\isacharcomma}\ {\isasymlambda}x\ y{\isachardot}\ Suc{\isacharparenleft}y{\isacharparenright}{\isacharparenright}{\isachardoublequoteclose}%
    53 \begin{isamarkuptext}%
    52 \begin{isamarkuptext}%
    54 This is an abstract version of the plain \isa{Nat} theory in
    53 This is an abstract version of the plain \isa{Nat} theory in
    55  FOL.\footnote{See
    54  FOL.\footnote{See
    56  \url{http://isabelle.in.tum.de/library/FOL/ex/Nat.html}} Basically,
    55  \url{http://isabelle.in.tum.de/library/FOL/ex/Nat.html}} Basically,
    57  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}.
    56  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}.
    73  Theorems of the abstract natural numbers may be derived in the same
    72  Theorems of the abstract natural numbers may be derived in the same
    74  way as for the concrete version.  The original proof scripts may be
    73  way as for the concrete version.  The original proof scripts may be
    75  re-used with some trivial changes only (mostly adding some type
    74  re-used with some trivial changes only (mostly adding some type
    76  constraints).%
    75  constraints).%
    77 \end{isamarkuptext}%
    76 \end{isamarkuptext}%
       
    77 \isamarkuptrue%
    78 %
    78 %
    79 \isadelimtheory
    79 \isadelimtheory
    80 %
    80 %
    81 \endisadelimtheory
    81 \endisadelimtheory
    82 %
    82 %
    83 \isatagtheory
    83 \isatagtheory
    84 \isamarkupfalse%
    84 \isacommand{end}\isamarkupfalse%
    85 \isacommand{end}%
    85 %
    86 \endisatagtheory
    86 \endisatagtheory
    87 {\isafoldtheory}%
    87 {\isafoldtheory}%
    88 %
    88 %
    89 \isadelimtheory
    89 \isadelimtheory
    90 %
    90 %