doc-src/TutorialI/Types/document/Axioms.tex
changeset 10396 5ab08609e6c8
parent 10395 7ef380745743
child 10397 e2d0dda41f2c
equal deleted inserted replaced
10395:7ef380745743 10396:5ab08609e6c8
     1 %
     1 %
     2 \begin{isabellebody}%
     2 \begin{isabellebody}%
     3 \def\isabellecontext{Axioms}%
     3 \def\isabellecontext{Axioms}%
     4 %
     4 %
     5 \isamarkupsubsection{Axioms%
     5 \isamarkupsubsection{Axioms}
     6 }
       
     7 %
     6 %
     8 \begin{isamarkuptext}%
     7 \begin{isamarkuptext}%
     9 Now we want to attach axioms to our classes. Then we can reason on the
     8 Now we want to attach axioms to our classes. Then we can reason on the
    10 level of classes and the results will be applicable to all types in a class,
     9 level of classes and the results will be applicable to all types in a class,
    11 just as in axiomatic mathematics. These ideas are demonstrated by means of
    10 just as in axiomatic mathematics. These ideas are demonstrated by means of
    12 our above ordering relations.%
    11 our above ordering relations.%
    13 \end{isamarkuptext}%
    12 \end{isamarkuptext}%
    14 %
    13 %
    15 \isamarkupsubsubsection{Partial orders%
    14 \isamarkupsubsubsection{Partial orders}
    16 }
       
    17 %
    15 %
    18 \begin{isamarkuptext}%
    16 \begin{isamarkuptext}%
    19 A \emph{partial order} is a subclass of \isa{ordrel}
    17 A \emph{partial order} is a subclass of \isa{ordrel}
    20 where certain axioms need to hold:%
    18 where certain axioms need to hold:%
    21 \end{isamarkuptext}%
    19 \end{isamarkuptext}%
    86 it should be clear that the main advantage of the axiomatic method is that
    84 it should be clear that the main advantage of the axiomatic method is that
    87 theorems can be proved in the abstract and one does not need to repeat the
    85 theorems can be proved in the abstract and one does not need to repeat the
    88 proof for each instance.%
    86 proof for each instance.%
    89 \end{isamarkuptext}%
    87 \end{isamarkuptext}%
    90 %
    88 %
    91 \isamarkupsubsubsection{Linear orders%
    89 \isamarkupsubsubsection{Linear orders}
    92 }
       
    93 %
    90 %
    94 \begin{isamarkuptext}%
    91 \begin{isamarkuptext}%
    95 If any two elements of a partial order are comparable it is a
    92 If any two elements of a partial order are comparable it is a
    96 \emph{linear} or \emph{total} order:%
    93 \emph{linear} or \emph{total} order:%
    97 \end{isamarkuptext}%
    94 \end{isamarkuptext}%
   113 common case. It is also possible to prove additional subclass relationships
   110 common case. It is also possible to prove additional subclass relationships
   114 later on, i.e.\ subclassing by proof. This is the topic of the following
   111 later on, i.e.\ subclassing by proof. This is the topic of the following
   115 section.%
   112 section.%
   116 \end{isamarkuptext}%
   113 \end{isamarkuptext}%
   117 %
   114 %
   118 \isamarkupsubsubsection{Strict orders%
   115 \isamarkupsubsubsection{Strict orders}
   119 }
       
   120 %
   116 %
   121 \begin{isamarkuptext}%
   117 \begin{isamarkuptext}%
   122 An alternative axiomatization of partial orders takes \isa{{\isacharless}{\isacharless}} rather than
   118 An alternative axiomatization of partial orders takes \isa{{\isacharless}{\isacharless}} rather than
   123 \isa{{\isacharless}{\isacharless}{\isacharequal}} as the primary concept. The result is a \emph{strict} order:%
   119 \isa{{\isacharless}{\isacharless}{\isacharequal}} as the primary concept. The result is a \emph{strict} order:%
   124 \end{isamarkuptext}%
   120 \end{isamarkuptext}%
   137 \isacommand{apply}{\isacharparenleft}simp{\isacharunderscore}all\ {\isacharparenleft}no{\isacharunderscore}asm{\isacharunderscore}use{\isacharparenright}\ add{\isacharcolon}less{\isacharunderscore}le{\isacharparenright}\isanewline
   133 \isacommand{apply}{\isacharparenleft}simp{\isacharunderscore}all\ {\isacharparenleft}no{\isacharunderscore}asm{\isacharunderscore}use{\isacharparenright}\ add{\isacharcolon}less{\isacharunderscore}le{\isacharparenright}\isanewline
   138 \ \ \isacommand{apply}{\isacharparenleft}blast\ intro{\isacharcolon}\ trans\ antisym{\isacharparenright}\isanewline
   134 \ \ \isacommand{apply}{\isacharparenleft}blast\ intro{\isacharcolon}\ trans\ antisym{\isacharparenright}\isanewline
   139 \ \isacommand{apply}{\isacharparenleft}blast\ intro{\isacharcolon}\ refl{\isacharparenright}\isanewline
   135 \ \isacommand{apply}{\isacharparenleft}blast\ intro{\isacharcolon}\ refl{\isacharparenright}\isanewline
   140 \isacommand{done}%
   136 \isacommand{done}%
   141 \begin{isamarkuptext}%
   137 \begin{isamarkuptext}%
   142 \noindent
   138 The subclass relation must always be acyclic. Therefore Isabelle will
   143 The result is the following subclass diagram:
   139 complain if you also prove the relationship \isa{strord\ {\isacharless}\ parord}.%
       
   140 \end{isamarkuptext}%
       
   141 %
       
   142 \isamarkupsubsubsection{Multiple inheritance and sorts}
       
   143 %
       
   144 \begin{isamarkuptext}%
       
   145 A class may inherit from more than one direct superclass. This is called
       
   146 multiple inheritance and is certainly permitted. For example we could define
       
   147 the classes of well-founded orderings and well-orderings:%
       
   148 \end{isamarkuptext}%
       
   149 \isacommand{axclass}\ wford\ {\isacharless}\ parord\isanewline
       
   150 wford{\isacharcolon}\ {\isachardoublequote}wf\ {\isacharbraceleft}{\isacharparenleft}y{\isacharcomma}x{\isacharparenright}{\isachardot}\ y\ {\isacharless}{\isacharless}\ x{\isacharbraceright}{\isachardoublequote}\isanewline
       
   151 \isanewline
       
   152 \isacommand{axclass}\ wellord\ {\isacharless}\ linord{\isacharcomma}\ wford%
       
   153 \begin{isamarkuptext}%
       
   154 \noindent
       
   155 The last line expresses the usual definition: a well-ordering is a linear
       
   156 well-founded ordering. The result is the subclass diagram in
       
   157 Figure~\ref{fig:subclass}.
       
   158 
       
   159 \begin{figure}[htbp]
   144 \[
   160 \[
   145 \begin{array}{c}
   161 \begin{array}{r@ {}r@ {}c@ {}l@ {}l}
   146 \isa{term}\\
   162 & & \isa{term}\\
   147 |\\
   163 & & |\\
   148 \isa{ordrel}\\
   164 & & \isa{ordrel}\\
   149 |\\
   165 & & |\\
   150 \isa{strord}\\
   166 & & \isa{strord}\\
   151 |\\
   167 & & |\\
   152 \isa{parord}
   168 & & \isa{parord} \\
       
   169 & / & & \backslash \\
       
   170 \isa{linord} & & & & \isa{wford} \\
       
   171 & \backslash & & / \\
       
   172 & & \isa{wellord}
   153 \end{array}
   173 \end{array}
   154 \]
   174 \]
   155 
   175 \caption{Subclass diagramm}
   156 In general, the subclass diagram must be acyclic. Therefore Isabelle will
   176 \label{fig:subclass}
   157 complain if you also prove the relationship \isa{strord\ {\isacharless}\ parord}.
   177 \end{figure}
   158 Multiple inheritance is however permitted.
   178 
   159 
   179 Since class \isa{wellord} does not introduce any new axioms, it can simply
   160 This finishes our demonstration of type classes based on orderings.  We
   180 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
   161 remind our readers that \isa{Main} contains a much more developed theory of
   181 the fly: the expression $\{C@1,\dots,C@n\}$, where the $C@i$ are classes,
       
   182 represents the intersection of the $C@i$. Such an expression is called a
       
   183 \bfindex{sort}, and sorts can appear in most places where we have only shown
       
   184 classes so far, for example in type constraints: \isa{{\isacharprime}a{\isacharcolon}{\isacharcolon}{\isacharbraceleft}linord{\isacharcomma}wford{\isacharbraceright}}.
       
   185 In fact, \isa{{\isacharprime}a{\isacharcolon}{\isacharcolon}ord} is short for \isa{{\isacharprime}a{\isacharcolon}{\isacharcolon}{\isacharbraceleft}ord{\isacharbraceright}}.
       
   186 However, we do not pursue this rarefied concept further.
       
   187 
       
   188 This concludes our demonstration of type classes based on orderings.  We
       
   189 remind our readers that \isa{Main} contains a theory of
   162 orderings phrased in terms of the usual \isa{{\isasymle}} and \isa{{\isacharless}}.
   190 orderings phrased in terms of the usual \isa{{\isasymle}} and \isa{{\isacharless}}.
   163 It is recommended that, if possible,
   191 It is recommended that, if possible,
   164 you base your own ordering relations on this theory.%
   192 you base your own ordering relations on this theory.%
   165 \end{isamarkuptext}%
   193 \end{isamarkuptext}%
   166 %
   194 %
   167 \isamarkupsubsubsection{Inconsistencies%
   195 \isamarkupsubsubsection{Inconsistencies}
   168 }
       
   169 %
   196 %
   170 \begin{isamarkuptext}%
   197 \begin{isamarkuptext}%
   171 The reader may be wondering what happens if we, maybe accidentally,
   198 The reader may be wondering what happens if we, maybe accidentally,
   172 attach an inconsistent set of axioms to a class. So far we have always
   199 attach an inconsistent set of axioms to a class. So far we have always
   173 avoided to add new axioms to HOL for fear of inconsistencies and suddenly it
   200 avoided to add new axioms to HOL for fear of inconsistencies and suddenly it