doc-src/Logics/Old_HOL.tex
changeset 287 6b62a6ddbe15
parent 154 f8c3715457b8
child 306 eee166d4a532
equal deleted inserted replaced
286:e7efbf03562b 287:6b62a6ddbe15
     1 %% $Id$
     1 %% $Id$
     2 \chapter{Higher-order logic}
     2 \chapter{Higher-Order logic}
     3 The directory~\ttindexbold{HOL} contains a theory for higher-order logic
     3 The directory~\ttindexbold{HOL} contains a theory for higher-order logic.
     4 based on Gordon's~{\sc hol} system~\cite{mgordon88a}, which itself is based on
     4 It is based on Gordon's~{\sc hol} system~\cite{mgordon88a}, which itself is
     5 Church~\cite{church40}.  Andrews~\cite{andrews86} is a full description of
     5 based on Church~\cite{church40}.  Andrews~\cite{andrews86} is a full
     6 higher-order logic.  Gordon's work has demonstrated that higher-order logic
     6 description of higher-order logic.  Gordon's work has demonstrated that
     7 is useful for hardware verification; beyond this, it is widely applicable
     7 higher-order logic is useful for hardware verification; beyond this, it is
     8 in many areas of mathematics.  It is weaker than {\ZF} set theory but for
     8 widely applicable in many areas of mathematics.  It is weaker than {\ZF}
     9 most applications this does not matter.  If you prefer {\ML} to Lisp, you
     9 set theory but for most applications this does not matter.  If you prefer
    10 will probably prefer {\HOL} to~{\ZF}.
    10 {\ML} to Lisp, you will probably prefer {\HOL} to~{\ZF}.
    11 
    11 
    12 Previous releases of Isabelle included a completely different version
    12 Previous releases of Isabelle included a completely different version
    13 of~{\HOL}, with explicit type inference rules~\cite{paulson-COLOG}.  This
    13 of~{\HOL}, with explicit type inference rules~\cite{paulson-COLOG}.  This
    14 version no longer exists, but \ttindex{ZF} supports a similar style of
    14 version no longer exists, but \ttindex{ZF} supports a similar style of
    15 reasoning.
    15 reasoning.
   134 overloading of the operators {\tt+}, {\tt-} and {\tt*}.  In particular,
   134 overloading of the operators {\tt+}, {\tt-} and {\tt*}.  In particular,
   135 {\tt-} is overloaded for set difference and subtraction.
   135 {\tt-} is overloaded for set difference and subtraction.
   136 \index{*"+}\index{-@{\tt-}}\index{*@{\tt*}}
   136 \index{*"+}\index{-@{\tt-}}\index{*@{\tt*}}
   137 
   137 
   138 Figure~\ref{hol-constants} lists the constants (including infixes and
   138 Figure~\ref{hol-constants} lists the constants (including infixes and
   139 binders), while Figure~\ref{hol-grammar} presents the grammar.  Note that
   139 binders), while Fig.\ts \ref{hol-grammar} presents the grammar of
   140 $a$\verb|~=|$b$ is translated to \verb|~(|$a$=$b$\verb|)|.
   140 higher-order logic.  Note that $a$\verb|~=|$b$ is translated to
   141 
   141 \verb|~(|$a$=$b$\verb|)|.
   142 \subsection{Types}
   142 
       
   143 \subsection{Types}\label{HOL-types}
   143 The type of formulae, {\it bool} belongs to class {\it term}; thus,
   144 The type of formulae, {\it bool} belongs to class {\it term}; thus,
   144 formulae are terms.  The built-in type~$fun$, which constructs function
   145 formulae are terms.  The built-in type~$fun$, which constructs function
   145 types, is overloaded such that $\sigma\To\tau$ belongs to class~$term$ if
   146 types, is overloaded such that $\sigma\To\tau$ belongs to class~$term$ if
   146 $\sigma$ and~$\tau$ do; this allows quantification over functions.  Types
   147 $\sigma$ and~$\tau$ do; this allows quantification over functions.  Types
   147 in {\HOL} must be non-empty because of the form of quantifier
   148 in {\HOL} must be non-empty; otherwise the quantifier rules would be
   148 rules~\cite[\S7]{paulson-COLOG}.
   149 unsound~\cite[\S7]{paulson-COLOG}.
   149 
   150 
   150 Gordon's {\sc hol} system supports {\bf type definitions}.  A type is
   151 Gordon's {\sc hol} system supports {\bf type definitions}.  A type is
   151 defined by exhibiting an existing type~$\sigma$, a predicate~$P::\sigma\To
   152 defined by exhibiting an existing type~$\sigma$, a predicate~$P::\sigma\To
   152 bool$, and a theorem of the form $\exists x::\sigma.P(x)$.  Thus~$P$
   153 bool$, and a theorem of the form $\exists x::\sigma.P(x)$.  Thus~$P$
   153 specifies a non-empty subset of~$\sigma$, and the new type denotes this
   154 specifies a non-empty subset of~$\sigma$, and the new type denotes this
   196 then \hbox{\tt \at $x\,y$.$P[x,y]$} is legal.  The pretty printer will
   197 then \hbox{\tt \at $x\,y$.$P[x,y]$} is legal.  The pretty printer will
   197 display \hbox{\tt \at $x$.\at $y$.$P[x,y]$} as
   198 display \hbox{\tt \at $x$.\at $y$.$P[x,y]$} as
   198 \hbox{\tt \at $x\,y$.$P[x,y]$}.
   199 \hbox{\tt \at $x\,y$.$P[x,y]$}.
   199 \end{warn}
   200 \end{warn}
   200 
   201 
   201 \begin{figure} \makeatother
   202 \begin{figure} 
   202 \begin{ttbox}
   203 \begin{ttbox}\makeatother
   203 \idx{refl}           t = t::'a
   204 \idx{refl}           t = t::'a
   204 \idx{subst}          [| s=t; P(s) |] ==> P(t::'a)
   205 \idx{subst}          [| s=t; P(s) |] ==> P(t::'a)
   205 \idx{ext}            (!!x::'a. f(x)::'b = g(x)) ==> (%x.f(x)) = (%x.g(x))
   206 \idx{ext}            (!!x::'a. f(x)::'b = g(x)) ==> (\%x.f(x)) = (\%x.g(x))
   206 \idx{impI}           (P ==> Q) ==> P-->Q
   207 \idx{impI}           (P ==> Q) ==> P-->Q
   207 \idx{mp}             [| P-->Q;  P |] ==> Q
   208 \idx{mp}             [| P-->Q;  P |] ==> Q
   208 \idx{iff}            (P-->Q) --> (Q-->P) --> (P=Q)
   209 \idx{iff}            (P-->Q) --> (Q-->P) --> (P=Q)
   209 \idx{selectI}        P(x::'a) ==> P(@x.P(x))
   210 \idx{selectI}        P(x::'a) ==> P(@x.P(x))
   210 \idx{True_or_False}  (P=True) | (P=False)
   211 \idx{True_or_False}  (P=True) | (P=False)
   211 \subcaption{basic rules}
   212 \subcaption{basic rules}
   212 
   213 
   213 \idx{True_def}       True  = ((%x.x)=(%x.x))
   214 \idx{True_def}       True  = ((\%x.x)=(\%x.x))
   214 \idx{All_def}        All   = (%P. P = (%x.True))
   215 \idx{All_def}        All   = (\%P. P = (\%x.True))
   215 \idx{Ex_def}         Ex    = (%P. P(@x.P(x)))
   216 \idx{Ex_def}         Ex    = (\%P. P(@x.P(x)))
   216 \idx{False_def}      False = (!P.P)
   217 \idx{False_def}      False = (!P.P)
   217 \idx{not_def}        not   = (%P. P-->False)
   218 \idx{not_def}        not   = (\%P. P-->False)
   218 \idx{and_def}        op &  = (%P Q. !R. (P-->Q-->R) --> R)
   219 \idx{and_def}        op &  = (\%P Q. !R. (P-->Q-->R) --> R)
   219 \idx{or_def}         op |  = (%P Q. !R. (P-->R) --> (Q-->R) --> R)
   220 \idx{or_def}         op |  = (\%P Q. !R. (P-->R) --> (Q-->R) --> R)
   220 \idx{Ex1_def}        Ex1   = (%P. ? x. P(x) & (! y. P(y) --> y=x))
   221 \idx{Ex1_def}        Ex1   = (\%P. ? x. P(x) & (! y. P(y) --> y=x))
   221 \subcaption{Definitions of the logical constants}
   222 \subcaption{Definitions of the logical constants}
   222 
   223 
   223 \idx{Inv_def}   Inv  = (%(f::'a=>'b) y. @x. f(x)=y)
   224 \idx{Inv_def}   Inv  = (\%(f::'a=>'b) y. @x. f(x)=y)
   224 \idx{o_def}     op o = (%(f::'b=>'c) g (x::'a). f(g(x)))
   225 \idx{o_def}     op o = (\%(f::'b=>'c) g (x::'a). f(g(x)))
   225 \idx{if_def}    if   = (%P x y.@z::'a.(P=True --> z=x) & (P=False --> z=y))
   226 \idx{if_def}    if   = (\%P x y.@z::'a.(P=True --> z=x) & (P=False --> z=y))
   226 \subcaption{Further definitions}
   227 \subcaption{Further definitions}
   227 \end{ttbox}
   228 \end{ttbox}
   228 \caption{Rules of {\tt HOL}} \label{hol-rules}
   229 \caption{Rules of {\tt HOL}} \label{hol-rules}
   229 \end{figure}
   230 \end{figure}
   230 
   231 
   231 
   232 
   232 \begin{figure} \makeatother
   233 \begin{figure}
   233 \begin{ttbox}
   234 \begin{ttbox}
   234 \idx{sym}         s=t ==> t=s
   235 \idx{sym}         s=t ==> t=s
   235 \idx{trans}       [| r=s; s=t |] ==> r=t
   236 \idx{trans}       [| r=s; s=t |] ==> r=t
   236 \idx{ssubst}      [| t=s; P(s) |] ==> P(t::'a)
   237 \idx{ssubst}      [| t=s; P(s) |] ==> P(t::'a)
   237 \idx{box_equals}  [| a=b;  a=c;  b=d |] ==> c=d  
   238 \idx{box_equals}  [| a=b;  a=c;  b=d |] ==> c=d  
   268 \end{ttbox}
   269 \end{ttbox}
   269 \caption{Derived rules for {\HOL}} \label{hol-lemmas1}
   270 \caption{Derived rules for {\HOL}} \label{hol-lemmas1}
   270 \end{figure}
   271 \end{figure}
   271 
   272 
   272 
   273 
   273 \begin{figure} \makeatother
   274 \begin{figure}
   274 \begin{ttbox}
   275 \begin{ttbox}\makeatother
   275 \idx{allI}      (!!x::'a. P(x)) ==> !x. P(x)
   276 \idx{allI}      (!!x::'a. P(x)) ==> !x. P(x)
   276 \idx{spec}      !x::'a.P(x) ==> P(x)
   277 \idx{spec}      !x::'a.P(x) ==> P(x)
   277 \idx{allE}      [| !x.P(x);  P(x) ==> R |] ==> R
   278 \idx{allE}      [| !x.P(x);  P(x) ==> R |] ==> R
   278 \idx{all_dupE}  [| !x.P(x);  [| P(x); !x.P(x) |] ==> R |] ==> R
   279 \idx{all_dupE}  [| !x.P(x);  [| P(x); !x.P(x) |] ==> R |] ==> R
   279 
   280 
   292 \idx{excluded_middle}    ~P | P
   293 \idx{excluded_middle}    ~P | P
   293 
   294 
   294 \idx{disjCI}    (~Q ==> P) ==> P|Q
   295 \idx{disjCI}    (~Q ==> P) ==> P|Q
   295 \idx{exCI}      (! x. ~ P(x) ==> P(a)) ==> ? x.P(x)
   296 \idx{exCI}      (! x. ~ P(x) ==> P(a)) ==> ? x.P(x)
   296 \idx{impCE}     [| P-->Q; ~ P ==> R; Q ==> R |] ==> R
   297 \idx{impCE}     [| P-->Q; ~ P ==> R; Q ==> R |] ==> R
   297 \idx{iffCE}     [| P<->Q;  [| P; Q |] ==> R;  [| ~P; ~Q |] ==> R |] ==> R
   298 \idx{iffCE}     [| P=Q;  [| P; Q |] ==> R;  [| ~P; ~Q |] ==> R |] ==> R
   298 \idx{notnotD}   ~~P ==> P
   299 \idx{notnotD}   ~~P ==> P
   299 \idx{swap}      ~P ==> (~Q ==> P) ==> Q
   300 \idx{swap}      ~P ==> (~Q ==> P) ==> Q
   300 \subcaption{Classical logic}
   301 \subcaption{Classical logic}
   301 
   302 
   302 \idx{if_True}    if(True,x,y) = x
   303 \idx{if_True}    if(True,x,y) = x
   317 
   318 
   318 Figure~\ref{hol-rules} shows the inference rules with their~{\ML} names.
   319 Figure~\ref{hol-rules} shows the inference rules with their~{\ML} names.
   319 They follow standard practice in higher-order logic: only a few connectives
   320 They follow standard practice in higher-order logic: only a few connectives
   320 are taken as primitive, with the remainder defined obscurely.  
   321 are taken as primitive, with the remainder defined obscurely.  
   321 
   322 
   322 Unusually, the definitions use object-equality~({\tt=}) rather than
   323 Unusually, the definitions are expressed using object-equality~({\tt=})
   323 meta-equality~({\tt==}).  This is possible because equality in higher-order
   324 rather than meta-equality~({\tt==}).  This is possible because equality in
   324 logic may equate formulae and even functions over formulae.  On the other
   325 higher-order logic may equate formulae and even functions over formulae.
   325 hand, meta-equality is Isabelle's usual symbol for making definitions.
   326 On the other hand, meta-equality is Isabelle's usual symbol for making
   326 Take care to note which form of equality is used before attempting a proof.
   327 definitions.  Take care to note which form of equality is used before
       
   328 attempting a proof.
   327 
   329 
   328 Some of the rules mention type variables; for example, {\tt refl} mentions
   330 Some of the rules mention type variables; for example, {\tt refl} mentions
   329 the type variable~{\tt'a}.  This facilitates explicit instantiation of the
   331 the type variable~{\tt'a}.  This facilitates explicit instantiation of the
   330 type variables.  By default, such variables range over class {\it term}.  
   332 type variables.  By default, such variables range over class {\it term}.  
   331 
   333 
   371 
   373 
   372 Note the equality rules: \ttindexbold{ssubst} performs substitution in
   374 Note the equality rules: \ttindexbold{ssubst} performs substitution in
   373 backward proofs, while \ttindexbold{box_equals} supports reasoning by
   375 backward proofs, while \ttindexbold{box_equals} supports reasoning by
   374 simplifying both sides of an equation.
   376 simplifying both sides of an equation.
   375 
   377 
   376 See the files \ttindexbold{HOL/hol.thy} and
   378 See the files {\tt HOL/hol.thy} and
   377 \ttindexbold{HOL/hol.ML} for complete listings of the rules and
   379 {\tt HOL/hol.ML} for complete listings of the rules and
   378 derived rules.
   380 derived rules.
   379 
   381 
   380 
   382 
   381 \section{Generic packages}
   383 \section{Generic packages}
   382 {\HOL} instantiates most of Isabelle's generic packages;
   384 {\HOL} instantiates most of Isabelle's generic packages;
   383 see \ttindexbold{HOL/ROOT.ML} for details.
   385 see {\tt HOL/ROOT.ML} for details.
   384 \begin{itemize}
   386 \begin{itemize}
   385 \item 
   387 \item 
   386 Because it includes a general substitution rule, {\HOL} instantiates the
   388 Because it includes a general substitution rule, {\HOL} instantiates the
   387 tactic \ttindex{hyp_subst_tac}, which substitutes for an equality
   389 tactic \ttindex{hyp_subst_tac}, which substitutes for an equality
   388 throughout a subgoal and its hypotheses.
   390 throughout a subgoal and its hypotheses.
   389 \item 
   391 \item 
   390 It instantiates the simplifier, defining~\ttindexbold{HOL_ss} as the
   392 It instantiates the simplifier, defining~\ttindexbold{HOL_ss} as the
   391 simplification set for higher-order logic.  Equality~($=$), which also
   393 simplification set for higher-order logic.  Equality~($=$), which also
   392 expresses logical equivalence, may be used for rewriting.  See the file
   394 expresses logical equivalence, may be used for rewriting.  See the file
   393 \ttindexbold{HOL/simpdata.ML} for a complete listing of the simplification
   395 {\tt HOL/simpdata.ML} for a complete listing of the simplification
   394 rules. 
   396 rules. 
   395 \item 
   397 \item 
   396 It instantiates the classical reasoning module.  See~\S\ref{hol-cla-prover}
   398 It instantiates the classical reasoning module.  See~\S\ref{hol-cla-prover}
   397 for details. 
   399 for details. 
   398 \end{itemize}
   400 \end{itemize}
   517 \subcaption{Full Grammar}
   519 \subcaption{Full Grammar}
   518 \caption{Syntax of {\HOL}'s set theory (continued)} \label{hol-set-syntax2}
   520 \caption{Syntax of {\HOL}'s set theory (continued)} \label{hol-set-syntax2}
   519 \end{figure} 
   521 \end{figure} 
   520 
   522 
   521 
   523 
   522 \begin{figure} \makeatother
   524 \begin{figure} \underscoreon
   523 \begin{ttbox}
   525 \begin{ttbox}
   524 \idx{mem_Collect_eq}    (a : \{x.P(x)\}) = P(a)
   526 \idx{mem_Collect_eq}    (a : \{x.P(x)\}) = P(a)
   525 \idx{Collect_mem_eq}    \{x.x:A\} = A
   527 \idx{Collect_mem_eq}    \{x.x:A\} = A
   526 \subcaption{Isomorphisms between predicates and sets}
   528 \subcaption{Isomorphisms between predicates and sets}
   527 
   529 
   550 \end{ttbox}
   552 \end{ttbox}
   551 \caption{Rules of {\HOL}'s set theory} \label{hol-set-rules}
   553 \caption{Rules of {\HOL}'s set theory} \label{hol-set-rules}
   552 \end{figure}
   554 \end{figure}
   553 
   555 
   554 
   556 
   555 \begin{figure} \makeatother
   557 \begin{figure} \underscoreon
   556 \begin{ttbox}
   558 \begin{ttbox}
   557 \idx{CollectI}      [| P(a) |] ==> a : \{x.P(x)\}
   559 \idx{CollectI}      [| P(a) |] ==> a : \{x.P(x)\}
   558 \idx{CollectD}      [| a : \{x.P(x)\} |] ==> P(a)
   560 \idx{CollectD}      [| a : \{x.P(x)\} |] ==> P(a)
   559 \idx{CollectE}      [| a : \{x.P(x)\};  P(a) ==> W |] ==> W
   561 \idx{CollectE}      [| a : \{x.P(x)\};  P(a) ==> W |] ==> W
   560 \idx{Collect_cong}  [| !!x. P(x)=Q(x) |] ==> \{x. P(x)\} = \{x. Q(x)\}
   562 \idx{Collect_cong}  [| !!x. P(x)=Q(x) |] ==> \{x. P(x)\} = \{x. Q(x)\}
   591 \end{ttbox}
   593 \end{ttbox}
   592 \caption{Derived rules for set theory} \label{hol-set1}
   594 \caption{Derived rules for set theory} \label{hol-set1}
   593 \end{figure}
   595 \end{figure}
   594 
   596 
   595 
   597 
   596 \begin{figure} \makeatother
   598 \begin{figure} \underscoreon
   597 \begin{ttbox}
   599 \begin{ttbox}
   598 \idx{emptyE}   a : \{\} ==> P
   600 \idx{emptyE}   a : \{\} ==> P
   599 
   601 
   600 \idx{insertI1} a : insert(a,B)
   602 \idx{insertI1} a : insert(a,B)
   601 \idx{insertI2} a : B ==> a : insert(b,B)
   603 \idx{insertI2} a : B ==> a : insert(b,B)
   651 Finite unions and intersections have the same behaviour in {\HOL} as they
   653 Finite unions and intersections have the same behaviour in {\HOL} as they
   652 do in~{\ZF}.  In {\HOL} the intersection of the empty set is well-defined,
   654 do in~{\ZF}.  In {\HOL} the intersection of the empty set is well-defined,
   653 denoting the universal set for the given type.
   655 denoting the universal set for the given type.
   654 
   656 
   655 \subsection{Syntax of set theory}
   657 \subsection{Syntax of set theory}
   656 The type $\alpha\,set$ is essentially the same as $\alpha\To bool$.  The new
   658 The type $\alpha\,set$ is essentially the same as $\alpha\To bool$.  The
   657 type is defined for clarity and to avoid complications involving function
   659 new type is defined for clarity and to avoid complications involving
   658 types in unification.  Since Isabelle does not support type definitions (as
   660 function types in unification.  Since Isabelle does not support type
   659 discussed above), the isomorphisms between the two types are declared
   661 definitions (as mentioned in \S\ref{HOL-types}), the isomorphisms between
   660 explicitly.  Here they are natural: {\tt Collect} maps $\alpha\To bool$ to
   662 the two types are declared explicitly.  Here they are natural: {\tt
   661 $\alpha\,set$, while \hbox{\tt op :} maps in the other direction (ignoring
   663   Collect} maps $\alpha\To bool$ to $\alpha\,set$, while \hbox{\tt op :}
   662 argument order).  
   664 maps in the other direction (ignoring argument order).
   663 
   665 
   664 Figure~\ref{hol-set-syntax} lists the constants, infixes, and syntax
   666 Figure~\ref{hol-set-syntax} lists the constants, infixes, and syntax
   665 translations.  Figure~\ref{hol-set-syntax2} presents the grammar of the new
   667 translations.  Figure~\ref{hol-set-syntax2} presents the grammar of the new
   666 constructs.  Infix operators include union and intersection ($A\union B$
   668 constructs.  Infix operators include union and intersection ($A\union B$
   667 and $A\inter B$), the subset and membership relations, and the image
   669 and $A\inter B$), the subset and membership relations, and the image
   707 
   709 
   708 \subsection{Axioms and rules of set theory}
   710 \subsection{Axioms and rules of set theory}
   709 The axioms \ttindexbold{mem_Collect_eq} and
   711 The axioms \ttindexbold{mem_Collect_eq} and
   710 \ttindexbold{Collect_mem_eq} assert that the functions {\tt Collect} and
   712 \ttindexbold{Collect_mem_eq} assert that the functions {\tt Collect} and
   711 \hbox{\tt op :} are isomorphisms. 
   713 \hbox{\tt op :} are isomorphisms. 
   712 All the other axioms are definitions; see Figure~\ref{hol-set-rules}.
   714 All the other axioms are definitions; see Fig.\ts \ref{hol-set-rules}.
   713 These include straightforward properties of functions: image~({\tt``}) and
   715 These include straightforward properties of functions: image~({\tt``}) and
   714 {\tt range}, and predicates concerning monotonicity, injectiveness, etc.
   716 {\tt range}, and predicates concerning monotonicity, injectiveness, etc.
   715 
   717 
   716 {\HOL}'s set theory has the {\ML} identifier \ttindexbold{Set.thy}.
   718 {\HOL}'s set theory has the {\ML} identifier \ttindexbold{Set.thy}.
   717 
   719 
   718 \begin{figure} \makeatother
   720 \begin{figure} \underscoreon
   719 \begin{ttbox}
   721 \begin{ttbox}
   720 \idx{imageI}     [| x:A |] ==> f(x) : f``A
   722 \idx{imageI}     [| x:A |] ==> f(x) : f``A
   721 \idx{imageE}     [| b : f``A;  !!x.[| b=f(x);  x:A |] ==> P |] ==> P
   723 \idx{imageE}     [| b : f``A;  !!x.[| b=f(x);  x:A |] ==> P |] ==> P
   722 
   724 
   723 \idx{rangeI}     f(x) : range(f)
   725 \idx{rangeI}     f(x) : range(f)
   750 \end{ttbox}
   752 \end{ttbox}
   751 \caption{Derived rules involving functions} \label{hol-fun}
   753 \caption{Derived rules involving functions} \label{hol-fun}
   752 \end{figure}
   754 \end{figure}
   753 
   755 
   754 
   756 
   755 \begin{figure} \makeatother
   757 \begin{figure} \underscoreon
   756 \begin{ttbox}
   758 \begin{ttbox}
   757 \idx{Union_upper}     B:A ==> B <= Union(A)
   759 \idx{Union_upper}     B:A ==> B <= Union(A)
   758 \idx{Union_least}     [| !!X. X:A ==> X<=C |] ==> Union(A) <= C
   760 \idx{Union_least}     [| !!X. X:A ==> X<=C |] ==> Union(A) <= C
   759 
   761 
   760 \idx{Inter_lower}     B:A ==> Inter(A) <= B
   762 \idx{Inter_lower}     B:A ==> Inter(A) <= B
   770 \end{ttbox}
   772 \end{ttbox}
   771 \caption{Derived rules involving subsets} \label{hol-subset}
   773 \caption{Derived rules involving subsets} \label{hol-subset}
   772 \end{figure}
   774 \end{figure}
   773 
   775 
   774 
   776 
   775 \begin{figure} \makeatother
   777 \begin{figure} \underscoreon
   776 \begin{ttbox}
   778 \begin{ttbox}
   777 \idx{Int_absorb}         A Int A = A
   779 \idx{Int_absorb}         A Int A = A
   778 \idx{Int_commute}        A Int B = B Int A
   780 \idx{Int_commute}        A Int B = B Int A
   779 \idx{Int_assoc}          (A Int B) Int C  =  A Int (B Int C)
   781 \idx{Int_assoc}          (A Int B) Int C  =  A Int (B Int C)
   780 \idx{Int_Un_distrib}     (A Un B)  Int C  =  (A Int C) Un (B Int C)
   782 \idx{Int_Un_distrib}     (A Un B)  Int C  =  (A Int C) Un (B Int C)
   789 \idx{double_complement}  Compl(Compl(A)) = A
   791 \idx{double_complement}  Compl(Compl(A)) = A
   790 \idx{Compl_Un}           Compl(A Un B)  = Compl(A) Int Compl(B)
   792 \idx{Compl_Un}           Compl(A Un B)  = Compl(A) Int Compl(B)
   791 \idx{Compl_Int}          Compl(A Int B) = Compl(A) Un Compl(B)
   793 \idx{Compl_Int}          Compl(A Int B) = Compl(A) Un Compl(B)
   792 
   794 
   793 \idx{Union_Un_distrib}   Union(A Un B) = Union(A) Un Union(B)
   795 \idx{Union_Un_distrib}   Union(A Un B) = Union(A) Un Union(B)
   794 \idx{Int_Union_image}    A Int Union(B) = (UN C:B. A Int C)
   796 \idx{Int_Union}          A Int Union(B) = (UN C:B. A Int C)
   795 \idx{Un_Union_image} 
   797 \idx{Un_Union_image} 
   796     (UN x:C. A(x) Un B(x)) = Union(A``C)  Un  Union(B``C)
   798     (UN x:C. A(x) Un B(x)) = Union(A``C)  Un  Union(B``C)
   797 
   799 
   798 \idx{Inter_Un_distrib}   Inter(A Un B) = Inter(A) Int Inter(B)
   800 \idx{Inter_Un_distrib}   Inter(A Un B) = Inter(A) Int Inter(B)
   799 \idx{Un_Inter_image}     A Un Inter(B) = (INT C:B. A Un C)
   801 \idx{Un_Inter}           A Un Inter(B) = (INT C:B. A Un C)
   800 \idx{Int_Inter_image}
   802 \idx{Int_Inter_image}
   801    (INT x:C. A(x) Int B(x)) = Inter(A``C) Int Inter(B``C)
   803    (INT x:C. A(x) Int B(x)) = Inter(A``C) Int Inter(B``C)
   802 \end{ttbox}
   804 \end{ttbox}
   803 \caption{Set equalities} \label{hol-equalities}
   805 \caption{Set equalities} \label{hol-equalities}
   804 \end{figure}
   806 \end{figure}
   811 \ttindexbold{subsetCE}, \ttindexbold{bexCI} and \ttindexbold{UnCI}, are
   813 \ttindexbold{subsetCE}, \ttindexbold{bexCI} and \ttindexbold{UnCI}, are
   812 designed for classical reasoning; the more natural rules \ttindexbold{subsetD},
   814 designed for classical reasoning; the more natural rules \ttindexbold{subsetD},
   813 \ttindexbold{bexI}, \ttindexbold{Un1} and~\ttindexbold{Un2} are not
   815 \ttindexbold{bexI}, \ttindexbold{Un1} and~\ttindexbold{Un2} are not
   814 strictly necessary.  Similarly, \ttindexbold{equalityCE} supports classical
   816 strictly necessary.  Similarly, \ttindexbold{equalityCE} supports classical
   815 reasoning about extensionality, after the fashion of \ttindex{iffCE}.  See
   817 reasoning about extensionality, after the fashion of \ttindex{iffCE}.  See
   816 the file \ttindexbold{HOL/set.ML} for proofs pertaining to set theory.
   818 the file {\tt HOL/set.ML} for proofs pertaining to set theory.
   817 
   819 
   818 Figure~\ref{hol-fun} presents derived rules involving functions.  See
   820 Figure~\ref{hol-fun} presents derived inference rules involving functions.  See
   819 the file \ttindexbold{HOL/fun.ML} for a complete listing.
   821 the file {\tt HOL/fun.ML} for a complete listing.
   820 
   822 
   821 Figure~\ref{hol-subset} presents lattice properties of the subset relation.
   823 Figure~\ref{hol-subset} presents lattice properties of the subset relation.
   822 See \ttindexbold{HOL/subset.ML}.
   824 See the file {\tt HOL/subset.ML}.
   823 
   825 
   824 Figure~\ref{hol-equalities} presents set equalities.  See
   826 Figure~\ref{hol-equalities} presents set equalities.  See
   825 \ttindexbold{HOL/equalities.ML}.
   827 {\tt HOL/equalities.ML}.
   826 
   828 
   827 
   829 
   828 \begin{figure} \makeatother
   830 \begin{figure}
   829 \begin{center}
   831 \begin{center}
   830 \begin{tabular}{rrr} 
   832 \begin{tabular}{rrr} 
   831   \it name      &\it meta-type  & \it description \\ 
   833   \it name      &\it meta-type  & \it description \\ 
   832   \idx{Pair}    & $[\alpha,\beta]\To \alpha\times\beta$
   834   \idx{Pair}    & $[\alpha,\beta]\To \alpha\times\beta$
   833         & ordered pairs $\langle a,b\rangle$ \\
   835         & ordered pairs $\langle a,b\rangle$ \\
   834   \idx{fst}     & $\alpha\times\beta \To \alpha$                & first projection\\
   836   \idx{fst}     & $\alpha\times\beta \To \alpha$        & first projection\\
   835   \idx{snd}     & $\alpha\times\beta \To \beta$         & second projection\\
   837   \idx{snd}     & $\alpha\times\beta \To \beta$         & second projection\\
   836   \idx{split}   & $[\alpha\times\beta, [\alpha,\beta]\To\gamma] \To \gamma$ 
   838   \idx{split}   & $[\alpha\times\beta, [\alpha,\beta]\To\gamma] \To \gamma$ 
   837         & generalized projection
   839         & generalized projection\\
       
   840   \idx{Sigma}  & 
       
   841         $[\alpha\,set, \alpha\To\beta\,set]\To(\alpha\times\beta)set$ &
       
   842         general sum of sets
   838 \end{tabular}
   843 \end{tabular}
   839 \end{center}
   844 \end{center}
   840 \subcaption{Constants}
   845 \subcaption{Constants}
   841 
   846 
   842 \begin{ttbox}
   847 \begin{ttbox}\makeatletter
   843 \idx{fst_def}      fst(p)     == @a. ? b. p = <a,b>
   848 \idx{fst_def}      fst(p)     == @a. ? b. p = <a,b>
   844 \idx{snd_def}      snd(p)     == @b. ? a. p = <a,b>
   849 \idx{snd_def}      snd(p)     == @b. ? a. p = <a,b>
   845 \idx{split_def}    split(p,c) == c(fst(p),snd(p))
   850 \idx{split_def}    split(p,c) == c(fst(p),snd(p))
       
   851 \idx{Sigma_def}    Sigma(A,B) == UN x:A. UN y:B(x). \{<x,y>\}
   846 \subcaption{Definitions}
   852 \subcaption{Definitions}
   847 
   853 
   848 \idx{Pair_inject}  [| <a, b> = <a',b'>;  [| a=a';  b=b' |] ==> R |] ==> R
   854 \idx{Pair_inject}  [| <a, b> = <a',b'>;  [| a=a';  b=b' |] ==> R |] ==> R
   849 
   855 
   850 \idx{fst}          fst(<a,b>) = a
   856 \idx{fst}          fst(<a,b>) = a
   851 \idx{snd}          snd(<a,b>) = b
   857 \idx{snd}          snd(<a,b>) = b
   852 \idx{split}        split(<a,b>, c) = c(a,b)
   858 \idx{split}        split(<a,b>, c) = c(a,b)
   853 
   859 
   854 \idx{surjective_pairing}  p = <fst(p),snd(p)>
   860 \idx{surjective_pairing}  p = <fst(p),snd(p)>
       
   861 
       
   862 \idx{SigmaI}       [| a:A;  b:B(a) |] ==> <a,b> : Sigma(A,B)
       
   863 
       
   864 \idx{SigmaE}       [| c: Sigma(A,B);  
       
   865                 !!x y.[| x:A; y:B(x); c=<x,y> |] ==> P |] ==> P
   855 \subcaption{Derived rules}
   866 \subcaption{Derived rules}
   856 \end{ttbox}
   867 \end{ttbox}
   857 \caption{Type $\alpha\times\beta$} 
   868 \caption{Type $\alpha\times\beta$} 
   858 \label{hol-prod}
   869 \label{hol-prod}
   859 \end{figure} 
   870 \end{figure} 
   860 
   871 
   861 
   872 
   862 \begin{figure} \makeatother
   873 \begin{figure}
   863 \begin{center}
   874 \begin{center}
   864 \begin{tabular}{rrr} 
   875 \begin{tabular}{rrr} 
   865   \it name      &\it meta-type  & \it description \\ 
   876   \it name      &\it meta-type  & \it description \\ 
   866   \idx{Inl}     & $\alpha \To \alpha+\beta$                     & first injection\\
   877   \idx{Inl}     & $\alpha \To \alpha+\beta$                     & first injection\\
   867   \idx{Inr}     & $\beta \To \alpha+\beta$                      & second injection\\
   878   \idx{Inr}     & $\beta \To \alpha+\beta$                      & second injection\\
   869         & conditional
   880         & conditional
   870 \end{tabular}
   881 \end{tabular}
   871 \end{center}
   882 \end{center}
   872 \subcaption{Constants}
   883 \subcaption{Constants}
   873 
   884 
   874 \begin{ttbox}
   885 \begin{ttbox}\makeatletter
   875 \idx{case_def}     case == (%p f g. @z. (!x. p=Inl(x) --> z=f(x)) &
   886 \idx{case_def}     case == (\%p f g. @z. (!x. p=Inl(x) --> z=f(x)) &
   876                                   (!y. p=Inr(y) --> z=g(y)))
   887                                   (!y. p=Inr(y) --> z=g(y)))
   877 \subcaption{Definition}
   888 \subcaption{Definition}
   878 
   889 
   879 \idx{Inl_not_Inr}    ~ Inl(a)=Inr(b)
   890 \idx{Inl_not_Inr}    ~ Inl(a)=Inr(b)
   880 
   891 
   901 product, sum, natural number and list types.
   912 product, sum, natural number and list types.
   902 
   913 
   903 \subsection{Product and sum types}
   914 \subsection{Product and sum types}
   904 {\HOL} defines the product type $\alpha\times\beta$ and the sum type
   915 {\HOL} defines the product type $\alpha\times\beta$ and the sum type
   905 $\alpha+\beta$, with the ordered pair syntax {\tt<$a$,$b$>}, using fairly
   916 $\alpha+\beta$, with the ordered pair syntax {\tt<$a$,$b$>}, using fairly
   906 standard constructions (Figures~\ref{hol-prod} and~\ref{hol-sum}).  Because
   917 standard constructions (Figs.~\ref{hol-prod} and~\ref{hol-sum}).  Because
   907 Isabelle does not support type definitions, the isomorphisms between these
   918 Isabelle does not support abstract type definitions, the isomorphisms
   908 types and their representations are made explicitly.
   919 between these types and their representations are made explicitly.
   909 
   920 
   910 Most of the definitions are suppressed, but observe that the projections
   921 Most of the definitions are suppressed, but observe that the projections
   911 and conditionals are defined as descriptions.  Their properties are easily
   922 and conditionals are defined as descriptions.  Their properties are easily
   912 proved using \ttindex{select_equality}.  See \ttindexbold{HOL/prod.thy} and
   923 proved using \ttindex{select_equality}.  See {\tt HOL/prod.thy} and
   913 \ttindexbold{HOL/sum.thy} for details.
   924 {\tt HOL/sum.thy} for details.
   914 
   925 
   915 \begin{figure} \makeatother
   926 \begin{figure} 
   916 \indexbold{*"<}
   927 \indexbold{*"<}
   917 \begin{center}
   928 \begin{center}
   918 \begin{tabular}{rrr} 
   929 \begin{tabular}{rrr} 
   919   \it symbol    & \it meta-type & \it description \\ 
   930   \it symbol    & \it meta-type & \it description \\ 
   920   \idx{0}       & $nat$         & zero \\
   931   \idx{0}       & $nat$         & zero \\
   943   \tt -         & $[nat,nat]\To nat$    &  Left 65      & subtraction
   954   \tt -         & $[nat,nat]\To nat$    &  Left 65      & subtraction
   944 \end{tabular}
   955 \end{tabular}
   945 \end{center}
   956 \end{center}
   946 \subcaption{Constants and infixes}
   957 \subcaption{Constants and infixes}
   947 
   958 
   948 \begin{ttbox}
   959 \begin{ttbox}\makeatother
   949 \idx{nat_case_def}  nat_case == (%n a f. @z. (n=0 --> z=a) & 
   960 \idx{nat_case_def}  nat_case == (\%n a f. @z. (n=0 --> z=a) & 
   950                                         (!x. n=Suc(x) --> z=f(x)))
   961                                         (!x. n=Suc(x) --> z=f(x)))
   951 \idx{pred_nat_def}  pred_nat == \{p. ? n. p = <n, Suc(n)>\} 
   962 \idx{pred_nat_def}  pred_nat == \{p. ? n. p = <n, Suc(n)>\} 
   952 \idx{less_def}      m<n      == <m,n>:pred_nat^+
   963 \idx{less_def}      m<n      == <m,n>:pred_nat^+
   953 \idx{nat_rec_def}   nat_rec(n,c,d) == 
   964 \idx{nat_rec_def}   nat_rec(n,c,d) == 
   954                wfrec(pred_nat, n, %l g.nat_case(l, c, %m.d(m,g(m))))
   965                wfrec(pred_nat, n, \%l g.nat_case(l, c, \%m.d(m,g(m))))
   955 
   966 
   956 \idx{add_def}   m+n  == nat_rec(m, n, %u v.Suc(v))
   967 \idx{add_def}   m+n  == nat_rec(m, n, \%u v.Suc(v))
   957 \idx{diff_def}  m-n  == nat_rec(n, m, %u v. nat_rec(v, 0, %x y.x))
   968 \idx{diff_def}  m-n  == nat_rec(n, m, \%u v. nat_rec(v, 0, \%x y.x))
   958 \idx{mult_def}  m*n  == nat_rec(m, 0, %u v. n + v)
   969 \idx{mult_def}  m*n  == nat_rec(m, 0, \%u v. n + v)
   959 \idx{mod_def}   m//n == wfrec(trancl(pred_nat), m, %j f. if(j<n,j,f(j-n)))
   970 \idx{mod_def}   m//n == wfrec(trancl(pred_nat), m, \%j f. if(j<n,j,f(j-n)))
   960 \idx{quo_def}   m/n  == wfrec(trancl(pred_nat), 
   971 \idx{quo_def}   m/n  == wfrec(trancl(pred_nat), 
   961                         m, %j f. if(j<n,0,Suc(f(j-n))))
   972                         m, \%j f. if(j<n,0,Suc(f(j-n))))
   962 \subcaption{Definitions}
   973 \subcaption{Definitions}
   963 \end{ttbox}
   974 \end{ttbox}
   964 \caption{Defining $nat$, the type of natural numbers} \label{hol-nat1}
   975 \caption{Defining $nat$, the type of natural numbers} \label{hol-nat1}
   965 \end{figure}
   976 \end{figure}
   966 
   977 
   967 
   978 
   968 \begin{figure} \makeatother
   979 \begin{figure} \underscoreon
   969 \begin{ttbox}
   980 \begin{ttbox}
   970 \idx{nat_induct}     [| P(0); !!k. [| P(k) |] ==> P(Suc(k)) |]  ==> P(n)
   981 \idx{nat_induct}     [| P(0); !!k. [| P(k) |] ==> P(Suc(k)) |]  ==> P(n)
   971 
   982 
   972 \idx{Suc_not_Zero}   Suc(m) ~= 0
   983 \idx{Suc_not_Zero}   Suc(m) ~= 0
   973 \idx{inj_Suc}        inj(Suc)
   984 \idx{inj_Suc}        inj(Suc)
  1013 between~$nat$ and its representation are made explicitly.
  1024 between~$nat$ and its representation are made explicitly.
  1014 
  1025 
  1015 The definition makes use of a least fixed point operator \ttindex{lfp},
  1026 The definition makes use of a least fixed point operator \ttindex{lfp},
  1016 defined using the Knaster-Tarski theorem.  This in turn defines an operator
  1027 defined using the Knaster-Tarski theorem.  This in turn defines an operator
  1017 \ttindex{trancl} for taking the transitive closure of a relation.  See
  1028 \ttindex{trancl} for taking the transitive closure of a relation.  See
  1018 files \ttindexbold{HOL/lfp.thy} and \ttindexbold{HOL/trancl.thy} for
  1029 files {\tt HOL/lfp.thy} and {\tt HOL/trancl.thy} for
  1019 details.  The definition of~$nat$ resides on \ttindexbold{HOL/nat.thy}.  
  1030 details.  The definition of~$nat$ resides on {\tt HOL/nat.thy}.  
  1020 
  1031 
  1021 Type $nat$ is postulated to belong to class~$ord$, which overloads $<$ and
  1032 Type $nat$ is postulated to belong to class~$ord$, which overloads $<$ and
  1022 $\leq$ on the natural numbers.  As of this writing, Isabelle provides no
  1033 $\leq$ on the natural numbers.  As of this writing, Isabelle provides no
  1023 means of verifying that such overloading is sensible.  On the other hand,
  1034 means of verifying that such overloading is sensible.  On the other hand,
  1024 the {\HOL} theory includes no polymorphic axioms stating general properties
  1035 the {\HOL} theory includes no polymorphic axioms stating general properties
  1025 of $<$ and $\leq$.
  1036 of $<$ and $\leq$.
  1026 
  1037 
  1027 File \ttindexbold{HOL/arith.ML} develops arithmetic on the natural numbers.
  1038 File {\tt HOL/arith.ML} develops arithmetic on the natural numbers.
  1028 It defines addition, multiplication, subtraction, division, and remainder,
  1039 It defines addition, multiplication, subtraction, division, and remainder,
  1029 proving the theorem $a \bmod b + (a/b)\times b = a$.  Division and
  1040 proving the theorem $a \bmod b + (a/b)\times b = a$.  Division and
  1030 remainder are defined by repeated subtraction, which requires well-founded
  1041 remainder are defined by repeated subtraction, which requires well-founded
  1031 rather than primitive recursion.
  1042 rather than primitive recursion.
  1032 
  1043 
  1033 Primitive recursion makes use of \ttindex{wfrec}, an operator for recursion
  1044 Primitive recursion makes use of \ttindex{wfrec}, an operator for recursion
  1034 along arbitrary well-founded relations; see \ttindexbold{HOL/wf.ML} for the
  1045 along arbitrary well-founded relations; see {\tt HOL/wf.ML} for the
  1035 development.  The predecessor relation, \ttindexbold{pred_nat}, is shown to
  1046 development.  The predecessor relation, \ttindexbold{pred_nat}, is shown to
  1036 be well-founded; recursion along this relation is primitive recursion,
  1047 be well-founded; recursion along this relation is primitive recursion,
  1037 while its transitive closure is~$<$.
  1048 while its transitive closure is~$<$.
  1038 
  1049 
  1039 
  1050 
  1040 \begin{figure} \makeatother
  1051 \begin{figure}
  1041 \begin{center}
  1052 \begin{center}
  1042 \begin{tabular}{rrr} 
  1053 \begin{tabular}{rrr} 
  1043   \it symbol    & \it meta-type & \it description \\ 
  1054   \it symbol    & \it meta-type & \it description \\ 
  1044   \idx{Nil}     & $\alpha list$ & the empty list\\
  1055   \idx{Nil}     & $\alpha list$ & the empty list\\
  1045   \idx{Cons}    & $[\alpha, \alpha list] \To \alpha list$
  1056   \idx{Cons}    & $[\alpha, \alpha list] \To \alpha list$
  1052 \end{tabular}
  1063 \end{tabular}
  1053 \end{center}
  1064 \end{center}
  1054 \subcaption{Constants}
  1065 \subcaption{Constants}
  1055 
  1066 
  1056 \begin{ttbox}
  1067 \begin{ttbox}
  1057 \idx{map_def}     map(f,xs) == list_rec(xs, Nil, %x l r. Cons(f(x), r))
  1068 \idx{map_def}     map(f,xs) == list_rec(xs, Nil, \%x l r. Cons(f(x), r))
  1058 \subcaption{Definition}
  1069 \subcaption{Definition}
  1059 
  1070 
  1060 \idx{list_induct}
  1071 \idx{list_induct}
  1061     [| P(Nil);  !!x xs. [| P(xs) |] ==> P(Cons(x,xs)) |]  ==> P(l)
  1072     [| P(Nil);  !!x xs. [| P(xs) |] ==> P(Cons(x,xs)) |]  ==> P(l)
  1062 
  1073 
  1074 
  1085 
  1075 
  1086 
  1076 \subsection{The type constructor for lists, $\alpha\,list$}
  1087 \subsection{The type constructor for lists, $\alpha\,list$}
  1077 {\HOL}'s definition of lists is an example of an experimental method for
  1088 {\HOL}'s definition of lists is an example of an experimental method for
  1078 handling recursive data types.  The details need not concern us here; see
  1089 handling recursive data types.  The details need not concern us here; see
  1079 the file \ttindexbold{HOL/list.ML}.  Figure~\ref{hol-list} presents the
  1090 the file {\tt HOL/list.ML}.  Figure~\ref{hol-list} presents the
  1080 basic list operations, with their types and properties.  In particular,
  1091 basic list operations, with their types and properties.  In particular,
  1081 \ttindexbold{list_rec} is a primitive recursion operator for lists, in the
  1092 \ttindexbold{list_rec} is a primitive recursion operator for lists, in the
  1082 style of Martin-L\"of type theory.  It is derived from well-founded
  1093 style of Martin-L\"of type theory.  It is derived from well-founded
  1083 recursion, a general principle that can express arbitrary total recursive
  1094 recursion, a general principle that can express arbitrary total recursive
  1084 functions. 
  1095 functions. 
  1090 operator for co-recursion on lazy lists, which is used to define a few
  1101 operator for co-recursion on lazy lists, which is used to define a few
  1091 simple functions such as map and append.  Co-recursion cannot easily define
  1102 simple functions such as map and append.  Co-recursion cannot easily define
  1092 operations such as filter, which can compute indefinitely before yielding
  1103 operations such as filter, which can compute indefinitely before yielding
  1093 the next element (if any!) of the lazy list.  A co-induction principle is
  1104 the next element (if any!) of the lazy list.  A co-induction principle is
  1094 defined for proving equations on lazy lists.  See the files
  1105 defined for proving equations on lazy lists.  See the files
  1095 \ttindexbold{HOL/llist.thy} and \ttindexbold{HOL/llist.ML} for the formal
  1106 {\tt HOL/llist.thy} and {\tt HOL/llist.ML} for the formal
  1096 derivations.  I have written a report discussing the treatment of lazy
  1107 derivations.  I have written a report discussing the treatment of lazy
  1097 lists, and finite lists also~\cite{paulson-coind}.
  1108 lists, and finite lists also~\cite{paulson-coind}.
  1098 
  1109 
  1099 
  1110 
  1100 \section{Classical proof procedures} \label{hol-cla-prover}
  1111 \section{Classical proof procedures} \label{hol-cla-prover}
  1101 {\HOL} derives classical introduction rules for $\disj$ and~$\exists$, as
  1112 {\HOL} derives classical introduction rules for $\disj$ and~$\exists$, as
  1102 well as classical elimination rules for~$\imp$ and~$\bimp$, and the swap
  1113 well as classical elimination rules for~$\imp$ and~$\bimp$, and the swap
  1103 rule (Figure~\ref{hol-lemmas2}).
  1114 rule (Fig.~\ref{hol-lemmas2}).
  1104 
  1115 
  1105 The classical reasoning module is set up for \HOL, as the structure 
  1116 The classical reasoning module is set up for \HOL, as the structure 
  1106 \ttindexbold{Classical}.  This structure is open, so {\ML} identifiers such
  1117 \ttindexbold{Classical}.  This structure is open, so {\ML} identifiers such
  1107 as {\tt step_tac}, {\tt fast_tac}, {\tt best_tac}, etc., refer to it.
  1118 as {\tt step_tac}, {\tt fast_tac}, {\tt best_tac}, etc., refer to it.
  1108 
  1119 
  1148 theory~\cite{mw81}. 
  1159 theory~\cite{mw81}. 
  1149 
  1160 
  1150 Directory {\tt ex} contains other examples and experimental proofs in
  1161 Directory {\tt ex} contains other examples and experimental proofs in
  1151 {\HOL}.  Here is an overview of the more interesting files.
  1162 {\HOL}.  Here is an overview of the more interesting files.
  1152 \begin{description}
  1163 \begin{description}
  1153 \item[\ttindexbold{HOL/ex/meson.ML}]
  1164 \item[{\tt HOL/ex/meson.ML}]
  1154 contains an experimental implementation of the MESON proof procedure,
  1165 contains an experimental implementation of the MESON proof procedure,
  1155 inspired by Plaisted~\cite{plaisted90}.  It is much more powerful than
  1166 inspired by Plaisted~\cite{plaisted90}.  It is much more powerful than
  1156 Isabelle's classical module.  
  1167 Isabelle's classical module.  
  1157 
  1168 
  1158 \item[\ttindexbold{HOL/ex/mesontest.ML}]
  1169 \item[{\tt HOL/ex/mesontest.ML}]
  1159 contains test data for the MESON proof procedure.
  1170 contains test data for the MESON proof procedure.
  1160 
  1171 
  1161 \item[\ttindexbold{HOL/ex/set.ML}]
  1172 \item[{\tt HOL/ex/set.ML}] 
  1162 proves Cantor's Theorem (see below) and the Schr\"oder-Bernstein Theorem.
  1173   proves Cantor's Theorem, which is presented below, and the
  1163 
  1174   Schr\"oder-Bernstein Theorem.
  1164 \item[\ttindexbold{HOL/ex/pl.ML}]
  1175 
       
  1176 \item[{\tt HOL/ex/pl.ML}]
  1165 proves the soundness and completeness of classical propositional logic,
  1177 proves the soundness and completeness of classical propositional logic,
  1166 given a truth table semantics.  The only connective is $\imp$.  A
  1178 given a truth table semantics.  The only connective is $\imp$.  A
  1167 Hilbert-style axiom system is specified, and its set of theorems defined
  1179 Hilbert-style axiom system is specified, and its set of theorems defined
  1168 inductively.
  1180 inductively.
  1169 
  1181 
  1170 \item[\ttindexbold{HOL/ex/term.ML}] 
  1182 \item[{\tt HOL/ex/term.ML}] 
  1171   contains proofs about an experimental recursive type definition;
  1183   contains proofs about an experimental recursive type definition;
  1172   the recursion goes through the type constructor~$list$.
  1184   the recursion goes through the type constructor~$list$.
  1173 
  1185 
  1174 \item[\ttindexbold{HOL/ex/simult.ML}]
  1186 \item[{\tt HOL/ex/simult.ML}]
  1175 defines primitives for solving mutually recursive equations over sets.
  1187 defines primitives for solving mutually recursive equations over sets.
  1176 It constructs sets of trees and forests as an example, including induction
  1188 It constructs sets of trees and forests as an example, including induction
  1177 and recursion rules that handle the mutual recursion.
  1189 and recursion rules that handle the mutual recursion.
  1178 
  1190 
  1179 \item[\ttindexbold{HOL/ex/mt.ML}]
  1191 \item[{\tt HOL/ex/mt.ML}]
  1180 contains Jacob Frost's formalization~\cite{frost93} of a co-induction
  1192 contains Jacob Frost's formalization~\cite{frost93} of a co-induction
  1181 example by Milner and Tofte~\cite{milner-coind}.
  1193 example by Milner and Tofte~\cite{milner-coind}.
  1182 \end{description}
  1194 \end{description}
  1183 
  1195 
  1184 
  1196 
  1218 \begin{ttbox}
  1230 \begin{ttbox}
  1219 by (resolve_tac [allI] 1);
  1231 by (resolve_tac [allI] 1);
  1220 {\out Level 2}
  1232 {\out Level 2}
  1221 {\out P & Q}
  1233 {\out P & Q}
  1222 {\out  1. !!R. (P --> Q --> R) --> R}
  1234 {\out  1. !!R. (P --> Q --> R) --> R}
       
  1235 \ttbreak
  1223 by (resolve_tac [impI] 1);
  1236 by (resolve_tac [impI] 1);
  1224 {\out Level 3}
  1237 {\out Level 3}
  1225 {\out P & Q}
  1238 {\out P & Q}
  1226 {\out  1. !!R. P --> Q --> R ==> R}
  1239 {\out  1. !!R. P --> Q --> R ==> R}
  1227 \end{ttbox}
  1240 \end{ttbox}
  1257 {\out val prems = ["P & Q  [P & Q]"] : thm list}
  1270 {\out val prems = ["P & Q  [P & Q]"] : thm list}
  1258 \end{ttbox}
  1271 \end{ttbox}
  1259 Working with premises that involve defined constants can be tricky.  We
  1272 Working with premises that involve defined constants can be tricky.  We
  1260 must expand the definition of conjunction in the meta-assumption $P\conj
  1273 must expand the definition of conjunction in the meta-assumption $P\conj
  1261 Q$.  The rule \ttindex{subst} performs substitution in forward proofs.
  1274 Q$.  The rule \ttindex{subst} performs substitution in forward proofs.
  1262 We get two resolvents, since the vacuous substitution is valid:
  1275 We get {\it two\/} resolvents since the vacuous substitution is valid:
  1263 \begin{ttbox}
  1276 \begin{ttbox}
  1264 prems RL [and_def RS subst];
  1277 prems RL [and_def RS subst];
  1265 {\out val it = ["! R. (P --> Q --> R) --> R  [P & Q]",}
  1278 {\out val it = ["! R. (P --> Q --> R) --> R  [P & Q]",}
  1266 {\out           "P & Q  [P & Q]"] : thm list}
  1279 {\out           "P & Q  [P & Q]"] : thm list}
  1267 \end{ttbox}
  1280 \end{ttbox}
  1268 By applying $(\forall E)$ and $({\imp}E)$ to the resolvents, we dispose of
  1281 By applying $(\forall E)$ and $({\imp}E)$ to the resolvents, we dispose of
  1269 the vacuous one and put the other into a convenient form:\footnote
  1282 the vacuous one and put the other into a convenient form:\footnote {Why use
  1270 {In higher-order logic, {\tt spec RS mp} fails because the resolution yields
  1283   {\tt [spec] RL [mp]} instead of {\tt [spec RS mp]} to join the rules?  In
  1271 two results, namely ${\List{\forall x.x; P}\Imp Q}$ and ${\List{\forall
  1284   higher-order logic, {\tt spec RS mp} fails because the resolution yields
  1272   x.P(x)\imp Q(x); P(x)}\Imp Q(x)}$.  In first-order logic, the resolution
  1285   two results, namely ${\List{\forall x.x; P}\Imp Q}$ and ${\List{\forall
  1273 yields only the latter result.}
  1286       x.P(x)\imp Q(x); P(x)}\Imp Q(x)}$.  In first-order logic, the
  1274 \index{*RL}
  1287   resolution yields only the latter result because $\forall x.x$ is not a
       
  1288   first-order formula; in fact, it is equivalent to falsity.} \index{*RL}
  1275 \begin{ttbox}
  1289 \begin{ttbox}
  1276 prems RL [and_def RS subst] RL [spec] RL [mp];
  1290 prems RL [and_def RS subst] RL [spec] RL [mp];
  1277 {\out val it = ["P --> Q --> ?Q ==> ?Q  [P & Q]"] : thm list}
  1291 {\out val it = ["P --> Q --> ?Q ==> ?Q  [P & Q]"] : thm list}
  1278 \end{ttbox}
  1292 \end{ttbox}
  1279 This is a list containing a single rule, which is directly applicable to
  1293 This is a list containing a single rule, which is directly applicable to
  1302     \forall x::\alpha. f(x) \not= S 
  1316     \forall x::\alpha. f(x) \not= S 
  1303 \] 
  1317 \] 
  1304 Viewing types as sets, $\alpha\To bool$ represents the powerset
  1318 Viewing types as sets, $\alpha\To bool$ represents the powerset
  1305 of~$\alpha$.  This version states that for every function from $\alpha$ to
  1319 of~$\alpha$.  This version states that for every function from $\alpha$ to
  1306 its powerset, some subset is outside its range.
  1320 its powerset, some subset is outside its range.
  1307 
       
  1308 The Isabelle proof uses {\HOL}'s set theory, with the type $\alpha\,set$ and
  1321 The Isabelle proof uses {\HOL}'s set theory, with the type $\alpha\,set$ and
  1309 the operator \ttindex{range}.  Since it avoids quantification, we may
  1322 the operator \ttindex{range}.  Since it avoids quantification, we may
  1310 inspect the subset found by the proof.
  1323 inspect the subset found by the proof.
  1311 \begin{ttbox}
  1324 \begin{ttbox}
  1312 goal Set.thy "~ ?S : range(f :: 'a=>'a set)";
  1325 goal Set.thy "~ ?S : range(f :: 'a=>'a set)";
  1319 \begin{ttbox}
  1332 \begin{ttbox}
  1320 by (resolve_tac [notI] 1);
  1333 by (resolve_tac [notI] 1);
  1321 {\out Level 1}
  1334 {\out Level 1}
  1322 {\out ~ ?S : range(f)}
  1335 {\out ~ ?S : range(f)}
  1323 {\out  1. ?S : range(f) ==> False}
  1336 {\out  1. ?S : range(f) ==> False}
       
  1337 \ttbreak
  1324 by (eresolve_tac [rangeE] 1);
  1338 by (eresolve_tac [rangeE] 1);
  1325 {\out Level 2}
  1339 {\out Level 2}
  1326 {\out ~ ?S : range(f)}
  1340 {\out ~ ?S : range(f)}
  1327 {\out  1. !!x. ?S = f(x) ==> False}
  1341 {\out  1. !!x. ?S = f(x) ==> False}
  1328 \end{ttbox}
  1342 \end{ttbox}
  1345 {\out ~ \{x. ?P7(x)\} : range(f)}
  1359 {\out ~ \{x. ?P7(x)\} : range(f)}
  1346 {\out  1. !!x. [| ?c3(x) : f(x); ?P7(?c3(x)) |] ==> False}
  1360 {\out  1. !!x. [| ?c3(x) : f(x); ?P7(?c3(x)) |] ==> False}
  1347 {\out  2. !!x. [| ~ ?c3(x) : \{x. ?P7(x)\}; ~ ?c3(x) : f(x) |] ==> False}
  1361 {\out  2. !!x. [| ~ ?c3(x) : \{x. ?P7(x)\}; ~ ?c3(x) : f(x) |] ==> False}
  1348 \end{ttbox}
  1362 \end{ttbox}
  1349 Forcing a contradiction between the two assumptions of subgoal~1 completes
  1363 Forcing a contradiction between the two assumptions of subgoal~1 completes
  1350 the instantiation of~$S$.  It is now $\{x. x\not\in f(x)\}$, the standard
  1364 the instantiation of~$S$.  It is now the set $\{x. x\not\in f(x)\}$, the
  1351 diagonal construction.
  1365 standard diagonal construction.
  1352 \begin{ttbox}
  1366 \begin{ttbox}
  1353 by (contr_tac 1);
  1367 by (contr_tac 1);
  1354 {\out Level 5}
  1368 {\out Level 5}
  1355 {\out ~ \{x. ~ x : f(x)\} : range(f)}
  1369 {\out ~ \{x. ~ x : f(x)\} : range(f)}
  1356 {\out  1. !!x. [| ~ x : \{x. ~ x : f(x)\}; ~ x : f(x) |] ==> False}
  1370 {\out  1. !!x. [| ~ x : \{x. ~ x : f(x)\}; ~ x : f(x) |] ==> False}
  1360 \begin{ttbox}
  1374 \begin{ttbox}
  1361 by (swap_res_tac [CollectI] 1);
  1375 by (swap_res_tac [CollectI] 1);
  1362 {\out Level 6}
  1376 {\out Level 6}
  1363 {\out ~ \{x. ~ x : f(x)\} : range(f)}
  1377 {\out ~ \{x. ~ x : f(x)\} : range(f)}
  1364 {\out  1. !!x. [| ~ x : f(x); ~ False |] ==> ~ x : f(x)}
  1378 {\out  1. !!x. [| ~ x : f(x); ~ False |] ==> ~ x : f(x)}
       
  1379 \ttbreak
  1365 by (assume_tac 1);
  1380 by (assume_tac 1);
  1366 {\out Level 7}
  1381 {\out Level 7}
  1367 {\out ~ \{x. ~ x : f(x)\} : range(f)}
  1382 {\out ~ \{x. ~ x : f(x)\} : range(f)}
  1368 {\out No subgoals!}
  1383 {\out No subgoals!}
  1369 \end{ttbox}
  1384 \end{ttbox}
  1376 \begin{ttbox}
  1391 \begin{ttbox}
  1377 choplev 0;
  1392 choplev 0;
  1378 {\out Level 0}
  1393 {\out Level 0}
  1379 {\out ~ ?S : range(f)}
  1394 {\out ~ ?S : range(f)}
  1380 {\out  1. ~ ?S : range(f)}
  1395 {\out  1. ~ ?S : range(f)}
       
  1396 \ttbreak
  1381 by (best_tac (set_cs addSEs [equalityCE]) 1);
  1397 by (best_tac (set_cs addSEs [equalityCE]) 1);
  1382 {\out Level 1}
  1398 {\out Level 1}
  1383 {\out ~ \{x. ~ x : f(x)\} : range(f)}
  1399 {\out ~ \{x. ~ x : f(x)\} : range(f)}
  1384 {\out No subgoals!}
  1400 {\out No subgoals!}
  1385 \end{ttbox}
  1401 \end{ttbox}