doc-src/Logics/Old_HOL.tex
author lcp
Mon, 21 Mar 1994 11:41:41 +0100
changeset 287 6b62a6ddbe15
parent 154 f8c3715457b8
child 306 eee166d4a532
permissions -rw-r--r--
first draft of Springer book
lcp@104
     1
%% $Id$
lcp@287
     2
\chapter{Higher-Order logic}
lcp@287
     3
The directory~\ttindexbold{HOL} contains a theory for higher-order logic.
lcp@287
     4
It is based on Gordon's~{\sc hol} system~\cite{mgordon88a}, which itself is
lcp@287
     5
based on Church~\cite{church40}.  Andrews~\cite{andrews86} is a full
lcp@287
     6
description of higher-order logic.  Gordon's work has demonstrated that
lcp@287
     7
higher-order logic is useful for hardware verification; beyond this, it is
lcp@287
     8
widely applicable in many areas of mathematics.  It is weaker than {\ZF}
lcp@287
     9
set theory but for most applications this does not matter.  If you prefer
lcp@287
    10
{\ML} to Lisp, you will probably prefer {\HOL} to~{\ZF}.
lcp@104
    11
lcp@104
    12
Previous releases of Isabelle included a completely different version
lcp@104
    13
of~{\HOL}, with explicit type inference rules~\cite{paulson-COLOG}.  This
lcp@104
    14
version no longer exists, but \ttindex{ZF} supports a similar style of
lcp@104
    15
reasoning.
lcp@104
    16
lcp@104
    17
{\HOL} has a distinct feel, compared with {\ZF} and {\CTT}.  It
lcp@104
    18
identifies object-level types with meta-level types, taking advantage of
lcp@104
    19
Isabelle's built-in type checker.  It identifies object-level functions
lcp@104
    20
with meta-level functions, so it uses Isabelle's operations for abstraction
lcp@104
    21
and application.  There is no ``apply'' operator: function applications are
lcp@104
    22
written as simply~$f(a)$ rather than $f{\tt`}a$.
lcp@104
    23
lcp@104
    24
These identifications allow Isabelle to support {\HOL} particularly nicely,
lcp@104
    25
but they also mean that {\HOL} requires more sophistication from the user
lcp@104
    26
--- in particular, an understanding of Isabelle's type system.  Beginners
lcp@104
    27
should gain experience by working in first-order logic, before attempting
lcp@104
    28
to use higher-order logic.  This chapter assumes familiarity with~{\FOL{}}.
lcp@104
    29
lcp@104
    30
lcp@104
    31
\begin{figure} 
lcp@104
    32
\begin{center}
lcp@104
    33
\begin{tabular}{rrr} 
lcp@111
    34
  \it name      &\it meta-type  & \it description \\ 
lcp@111
    35
  \idx{Trueprop}& $bool\To prop$                & coercion to $prop$\\
lcp@111
    36
  \idx{not}     & $bool\To bool$                & negation ($\neg$) \\
lcp@111
    37
  \idx{True}    & $bool$                        & tautology ($\top$) \\
lcp@111
    38
  \idx{False}   & $bool$                        & absurdity ($\bot$) \\
lcp@111
    39
  \idx{if}      & $[bool,\alpha,\alpha]\To\alpha::term$ & conditional \\
lcp@111
    40
  \idx{Inv}     & $(\alpha\To\beta)\To(\beta\To\alpha)$ & function inversion
lcp@104
    41
\end{tabular}
lcp@104
    42
\end{center}
lcp@104
    43
\subcaption{Constants}
lcp@104
    44
lcp@104
    45
\index{"@@{\tt\at}}
lcp@104
    46
\begin{center}
lcp@104
    47
\begin{tabular}{llrrr} 
lcp@111
    48
  \it symbol &\it name     &\it meta-type & \it prec & \it description \\
lcp@104
    49
  \tt\at   & \idx{Eps}  & $(\alpha\To bool)\To\alpha::term$ & 10 & 
lcp@111
    50
        Hilbert description ($\epsilon$) \\
lcp@104
    51
  \idx{!}  & \idx{All}  & $(\alpha::term\To bool)\To bool$ & 10 & 
lcp@111
    52
        universal quantifier ($\forall$) \\
lcp@104
    53
  \idx{?}  & \idx{Ex}   & $(\alpha::term\To bool)\To bool$ & 10 & 
lcp@111
    54
        existential quantifier ($\exists$) \\
lcp@104
    55
  \idx{?!} & \idx{Ex1}  & $(\alpha::term\To bool)\To bool$ & 10 & 
lcp@111
    56
        unique existence ($\exists!$)
lcp@104
    57
\end{tabular}
lcp@104
    58
\end{center}
lcp@104
    59
\subcaption{Binders} 
lcp@104
    60
lcp@104
    61
\begin{center}
lcp@104
    62
\begin{tabular}{llrrr} 
lcp@111
    63
  \it symbol &\it name     &\it meta-type & \it prec & \it description \\
lcp@104
    64
  \idx{ALL}  & \idx{All}  & $(\alpha::term\To bool)\To bool$ & 10 & 
lcp@111
    65
        universal quantifier ($\forall$) \\
lcp@104
    66
  \idx{EX}   & \idx{Ex}   & $(\alpha::term\To bool)\To bool$ & 10 & 
lcp@111
    67
        existential quantifier ($\exists$) \\
lcp@104
    68
  \idx{EX!}  & \idx{Ex1}  & $(\alpha::term\To bool)\To bool$ & 10 & 
lcp@111
    69
        unique existence ($\exists!$)
lcp@104
    70
\end{tabular}
lcp@104
    71
\end{center}
lcp@104
    72
\subcaption{Alternative quantifiers} 
lcp@104
    73
lcp@104
    74
\begin{center}
lcp@104
    75
\indexbold{*"=}
lcp@104
    76
\indexbold{&@{\tt\&}}
lcp@104
    77
\indexbold{*"|}
lcp@104
    78
\indexbold{*"-"-">}
lcp@104
    79
\begin{tabular}{rrrr} 
lcp@111
    80
  \it symbol    & \it meta-type & \it precedence & \it description \\ 
lcp@111
    81
  \idx{o}       & $[\beta\To\gamma,\alpha\To\beta]\To (\alpha\To\gamma)$ & 
lcp@111
    82
        Right 50 & composition ($\circ$) \\
lcp@111
    83
  \tt =         & $[\alpha::term,\alpha]\To bool$ & Left 50 & equality ($=$) \\
lcp@111
    84
  \tt \&        & $[bool,bool]\To bool$ & Right 35 & conjunction ($\conj$) \\
lcp@111
    85
  \tt |         & $[bool,bool]\To bool$ & Right 30 & disjunction ($\disj$) \\
lcp@111
    86
  \tt -->       & $[bool,bool]\To bool$ & Right 25 & implication ($\imp$) \\
lcp@111
    87
  \tt <         & $[\alpha::ord,\alpha]\To bool$ & Left 50 & less than ($<$) \\
lcp@111
    88
  \tt <=        & $[\alpha::ord,\alpha]\To bool$ & Left 50 & 
lcp@111
    89
                less than or equals ($\leq$)
lcp@104
    90
\end{tabular}
lcp@104
    91
\end{center}
lcp@104
    92
\subcaption{Infixes}
lcp@104
    93
\caption{Syntax of {\tt HOL}} \label{hol-constants}
lcp@104
    94
\end{figure}
lcp@104
    95
lcp@104
    96
lcp@104
    97
\begin{figure} 
lcp@104
    98
\dquotes
lcp@104
    99
\[\begin{array}{rcl}
lcp@104
   100
    term & = & \hbox{expression of class~$term$} \\
lcp@111
   101
         & | & "\at~~" id~id^* " . " formula \\[2ex]
lcp@104
   102
 formula & = & \hbox{expression of type~$bool$} \\
lcp@111
   103
         & | & term " = " term \\
lcp@111
   104
         & | & term " \ttilde= " term \\
lcp@111
   105
         & | & term " < " term \\
lcp@111
   106
         & | & term " <= " term \\
lcp@111
   107
         & | & "\ttilde\ " formula \\
lcp@111
   108
         & | & formula " \& " formula \\
lcp@111
   109
         & | & formula " | " formula \\
lcp@111
   110
         & | & formula " --> " formula \\
lcp@111
   111
         & | & "!~~~" id~id^* " . " formula \\
lcp@111
   112
         & | & "?~~~" id~id^* " . " formula \\
lcp@111
   113
         & | & "?!~~" id~id^* " . " formula \\
lcp@111
   114
         & | & "ALL~" id~id^* " . " formula \\
lcp@111
   115
         & | & "EX~~" id~id^* " . " formula \\
lcp@111
   116
         & | & "EX!~" id~id^* " . " formula
lcp@104
   117
  \end{array}
lcp@104
   118
\]
lcp@104
   119
\subcaption{Grammar}
lcp@104
   120
\caption{Full grammar for {\HOL}} \label{hol-grammar}
lcp@104
   121
\end{figure} 
lcp@104
   122
lcp@104
   123
lcp@104
   124
\section{Syntax}
lcp@104
   125
Type inference is automatic, exploiting Isabelle's type classes.  The class
lcp@104
   126
of higher-order terms is called {\it term\/}; type variables range over
lcp@104
   127
this class by default.  The equality symbol and quantifiers are polymorphic
lcp@104
   128
over class {\it term}.  
lcp@104
   129
lcp@104
   130
Class {\it ord\/} consists of all ordered types; the relations $<$ and
lcp@104
   131
$\leq$ are polymorphic over this class, as are the functions
lcp@104
   132
\ttindex{mono}, \ttindex{min} and \ttindex{max}.  Three other
lcp@104
   133
type classes --- {\it plus}, {\it minus\/} and {\it times} --- permit
lcp@104
   134
overloading of the operators {\tt+}, {\tt-} and {\tt*}.  In particular,
lcp@104
   135
{\tt-} is overloaded for set difference and subtraction.
lcp@104
   136
\index{*"+}\index{-@{\tt-}}\index{*@{\tt*}}
lcp@104
   137
lcp@104
   138
Figure~\ref{hol-constants} lists the constants (including infixes and
lcp@287
   139
binders), while Fig.\ts \ref{hol-grammar} presents the grammar of
lcp@287
   140
higher-order logic.  Note that $a$\verb|~=|$b$ is translated to
lcp@287
   141
\verb|~(|$a$=$b$\verb|)|.
lcp@104
   142
lcp@287
   143
\subsection{Types}\label{HOL-types}
lcp@104
   144
The type of formulae, {\it bool} belongs to class {\it term}; thus,
lcp@104
   145
formulae are terms.  The built-in type~$fun$, which constructs function
lcp@104
   146
types, is overloaded such that $\sigma\To\tau$ belongs to class~$term$ if
lcp@104
   147
$\sigma$ and~$\tau$ do; this allows quantification over functions.  Types
lcp@287
   148
in {\HOL} must be non-empty; otherwise the quantifier rules would be
lcp@287
   149
unsound~\cite[\S7]{paulson-COLOG}.
lcp@104
   150
lcp@104
   151
Gordon's {\sc hol} system supports {\bf type definitions}.  A type is
lcp@104
   152
defined by exhibiting an existing type~$\sigma$, a predicate~$P::\sigma\To
lcp@104
   153
bool$, and a theorem of the form $\exists x::\sigma.P(x)$.  Thus~$P$
lcp@104
   154
specifies a non-empty subset of~$\sigma$, and the new type denotes this
lcp@104
   155
subset.  New function constants are generated to establish an isomorphism
lcp@104
   156
between the new type and the subset.  If type~$\sigma$ involves type
lcp@104
   157
variables $\alpha@1$, \ldots, $\alpha@n$, then the type definition creates
lcp@104
   158
a type constructor $(\alpha@1,\ldots,\alpha@n)ty$ rather than a particular
lcp@104
   159
type.
lcp@104
   160
lcp@104
   161
Isabelle does not support type definitions at present.  Instead, they are
lcp@104
   162
mimicked by explicit definitions of isomorphism functions.  These should be
lcp@104
   163
accompanied by theorems of the form $\exists x::\sigma.P(x)$, but this is
lcp@104
   164
not checked.
lcp@104
   165
lcp@104
   166
lcp@104
   167
\subsection{Binders}
lcp@104
   168
Hilbert's {\bf description} operator~$\epsilon x.P[x]$ stands for some~$a$
lcp@104
   169
satisfying~$P[a]$, if such exists.  Since all terms in {\HOL} denote
lcp@104
   170
something, a description is always meaningful, but we do not know its value
lcp@104
   171
unless $P[x]$ defines it uniquely.  We may write descriptions as
lcp@104
   172
\ttindexbold{Eps}($P$) or use the syntax
lcp@104
   173
\hbox{\tt \at $x$.$P[x]$}.  Existential quantification is defined
lcp@104
   174
by
lcp@104
   175
\[ \exists x.P(x) \equiv P(\epsilon x.P(x)) \]
lcp@104
   176
The unique existence quantifier, $\exists!x.P[x]$, is defined in terms
lcp@104
   177
of~$\exists$ and~$\forall$.  An Isabelle binder, it admits nested
lcp@104
   178
quantifications.  For instance, $\exists!x y.P(x,y)$ abbreviates
lcp@104
   179
$\exists!x. \exists!y.P(x,y)$; note that this does not mean that there
lcp@104
   180
exists a unique pair $(x,y)$ satisfying~$P(x,y)$.
lcp@104
   181
lcp@104
   182
\index{*"!}\index{*"?}
lcp@104
   183
Quantifiers have two notations.  As in Gordon's {\sc hol} system, {\HOL}
lcp@104
   184
uses~{\tt!}\ and~{\tt?}\ to stand for $\forall$ and $\exists$.  The
lcp@104
   185
existential quantifier must be followed by a space; thus {\tt?x} is an
lcp@104
   186
unknown, while \verb'? x.f(x)=y' is a quantification.  Isabelle's usual
lcp@104
   187
notation for quantifiers, \ttindex{ALL} and \ttindex{EX}, is also
lcp@104
   188
available.  Both notations are accepted for input.  The {\ML} reference
lcp@104
   189
\ttindexbold{HOL_quantifiers} governs the output notation.  If set to {\tt
lcp@104
   190
true}, then~{\tt!}\ and~{\tt?}\ are displayed; this is the default.  If set
lcp@104
   191
to {\tt false}, then~{\tt ALL} and~{\tt EX} are displayed.
lcp@104
   192
lcp@104
   193
\begin{warn}
lcp@104
   194
Although the description operator does not usually allow iteration of the
lcp@104
   195
form \hbox{\tt \at $x@1 \dots x@n$.$P[x@1,\dots,x@n]$}, there are cases where
lcp@104
   196
this is legal.  If \hbox{\tt \at $y$.$P[x,y]$} is of type~{\it bool},
lcp@104
   197
then \hbox{\tt \at $x\,y$.$P[x,y]$} is legal.  The pretty printer will
lcp@104
   198
display \hbox{\tt \at $x$.\at $y$.$P[x,y]$} as
lcp@104
   199
\hbox{\tt \at $x\,y$.$P[x,y]$}.
lcp@104
   200
\end{warn}
lcp@104
   201
lcp@287
   202
\begin{figure} 
lcp@287
   203
\begin{ttbox}\makeatother
lcp@104
   204
\idx{refl}           t = t::'a
lcp@104
   205
\idx{subst}          [| s=t; P(s) |] ==> P(t::'a)
lcp@287
   206
\idx{ext}            (!!x::'a. f(x)::'b = g(x)) ==> (\%x.f(x)) = (\%x.g(x))
lcp@104
   207
\idx{impI}           (P ==> Q) ==> P-->Q
lcp@104
   208
\idx{mp}             [| P-->Q;  P |] ==> Q
lcp@104
   209
\idx{iff}            (P-->Q) --> (Q-->P) --> (P=Q)
lcp@104
   210
\idx{selectI}        P(x::'a) ==> P(@x.P(x))
lcp@104
   211
\idx{True_or_False}  (P=True) | (P=False)
lcp@104
   212
\subcaption{basic rules}
lcp@104
   213
lcp@287
   214
\idx{True_def}       True  = ((\%x.x)=(\%x.x))
lcp@287
   215
\idx{All_def}        All   = (\%P. P = (\%x.True))
lcp@287
   216
\idx{Ex_def}         Ex    = (\%P. P(@x.P(x)))
lcp@104
   217
\idx{False_def}      False = (!P.P)
lcp@287
   218
\idx{not_def}        not   = (\%P. P-->False)
lcp@287
   219
\idx{and_def}        op &  = (\%P Q. !R. (P-->Q-->R) --> R)
lcp@287
   220
\idx{or_def}         op |  = (\%P Q. !R. (P-->R) --> (Q-->R) --> R)
lcp@287
   221
\idx{Ex1_def}        Ex1   = (\%P. ? x. P(x) & (! y. P(y) --> y=x))
lcp@104
   222
\subcaption{Definitions of the logical constants}
lcp@104
   223
lcp@287
   224
\idx{Inv_def}   Inv  = (\%(f::'a=>'b) y. @x. f(x)=y)
lcp@287
   225
\idx{o_def}     op o = (\%(f::'b=>'c) g (x::'a). f(g(x)))
lcp@287
   226
\idx{if_def}    if   = (\%P x y.@z::'a.(P=True --> z=x) & (P=False --> z=y))
lcp@104
   227
\subcaption{Further definitions}
lcp@104
   228
\end{ttbox}
lcp@104
   229
\caption{Rules of {\tt HOL}} \label{hol-rules}
lcp@104
   230
\end{figure}
lcp@104
   231
lcp@104
   232
lcp@287
   233
\begin{figure}
lcp@104
   234
\begin{ttbox}
lcp@104
   235
\idx{sym}         s=t ==> t=s
lcp@104
   236
\idx{trans}       [| r=s; s=t |] ==> r=t
lcp@104
   237
\idx{ssubst}      [| t=s; P(s) |] ==> P(t::'a)
lcp@104
   238
\idx{box_equals}  [| a=b;  a=c;  b=d |] ==> c=d  
lcp@104
   239
\idx{arg_cong}    s=t ==> f(s)=f(t)
lcp@104
   240
\idx{fun_cong}    s::'a=>'b = t ==> s(x)=t(x)
lcp@104
   241
\subcaption{Equality}
lcp@104
   242
lcp@104
   243
\idx{TrueI}       True 
lcp@104
   244
\idx{FalseE}      False ==> P
lcp@104
   245
lcp@104
   246
\idx{conjI}       [| P; Q |] ==> P&Q
lcp@104
   247
\idx{conjunct1}   [| P&Q |] ==> P
lcp@104
   248
\idx{conjunct2}   [| P&Q |] ==> Q 
lcp@104
   249
\idx{conjE}       [| P&Q;  [| P; Q |] ==> R |] ==> R
lcp@104
   250
lcp@104
   251
\idx{disjI1}      P ==> P|Q
lcp@104
   252
\idx{disjI2}      Q ==> P|Q
lcp@104
   253
\idx{disjE}       [| P | Q; P ==> R; Q ==> R |] ==> R
lcp@104
   254
lcp@104
   255
\idx{notI}        (P ==> False) ==> ~ P
lcp@104
   256
\idx{notE}        [| ~ P;  P |] ==> R
lcp@104
   257
\idx{impE}        [| P-->Q;  P;  Q ==> R |] ==> R
lcp@104
   258
\subcaption{Propositional logic}
lcp@104
   259
lcp@104
   260
\idx{iffI}        [| P ==> Q;  Q ==> P |] ==> P=Q
lcp@104
   261
\idx{iffD1}       [| P=Q; P |] ==> Q
lcp@104
   262
\idx{iffD2}       [| P=Q; Q |] ==> P
lcp@104
   263
\idx{iffE}        [| P=Q; [| P --> Q; Q --> P |] ==> R |] ==> R
lcp@104
   264
lcp@104
   265
\idx{eqTrueI}     P ==> P=True 
lcp@104
   266
\idx{eqTrueE}     P=True ==> P 
lcp@104
   267
\subcaption{Logical equivalence}
lcp@104
   268
lcp@104
   269
\end{ttbox}
lcp@104
   270
\caption{Derived rules for {\HOL}} \label{hol-lemmas1}
lcp@104
   271
\end{figure}
lcp@104
   272
lcp@104
   273
lcp@287
   274
\begin{figure}
lcp@287
   275
\begin{ttbox}\makeatother
lcp@104
   276
\idx{allI}      (!!x::'a. P(x)) ==> !x. P(x)
lcp@104
   277
\idx{spec}      !x::'a.P(x) ==> P(x)
lcp@104
   278
\idx{allE}      [| !x.P(x);  P(x) ==> R |] ==> R
lcp@104
   279
\idx{all_dupE}  [| !x.P(x);  [| P(x); !x.P(x) |] ==> R |] ==> R
lcp@104
   280
lcp@104
   281
\idx{exI}       P(x) ==> ? x::'a.P(x)
lcp@104
   282
\idx{exE}       [| ? x::'a.P(x); !!x. P(x) ==> Q |] ==> Q
lcp@104
   283
lcp@104
   284
\idx{ex1I}      [| P(a);  !!x. P(x) ==> x=a |] ==> ?! x. P(x)
lcp@104
   285
\idx{ex1E}      [| ?! x.P(x);  !!x. [| P(x);  ! y. P(y) --> y=x |] ==> R 
lcp@104
   286
          |] ==> R
lcp@104
   287
lcp@104
   288
\idx{select_equality}  [| P(a);  !!x. P(x) ==> x=a |] ==> (@x.P(x)) = a
lcp@104
   289
\subcaption{Quantifiers and descriptions}
lcp@104
   290
lcp@104
   291
\idx{ccontr}             (~P ==> False) ==> P
lcp@104
   292
\idx{classical}          (~P ==> P) ==> P
lcp@104
   293
\idx{excluded_middle}    ~P | P
lcp@104
   294
lcp@104
   295
\idx{disjCI}    (~Q ==> P) ==> P|Q
lcp@104
   296
\idx{exCI}      (! x. ~ P(x) ==> P(a)) ==> ? x.P(x)
lcp@104
   297
\idx{impCE}     [| P-->Q; ~ P ==> R; Q ==> R |] ==> R
lcp@287
   298
\idx{iffCE}     [| P=Q;  [| P; Q |] ==> R;  [| ~P; ~Q |] ==> R |] ==> R
lcp@104
   299
\idx{notnotD}   ~~P ==> P
lcp@104
   300
\idx{swap}      ~P ==> (~Q ==> P) ==> Q
lcp@104
   301
\subcaption{Classical logic}
lcp@104
   302
lcp@104
   303
\idx{if_True}    if(True,x,y) = x
lcp@104
   304
\idx{if_False}   if(False,x,y) = y
lcp@104
   305
\idx{if_P}       P ==> if(P,x,y) = x
lcp@104
   306
\idx{if_not_P}   ~ P ==> if(P,x,y) = y
lcp@104
   307
\idx{expand_if}  P(if(Q,x,y)) = ((Q --> P(x)) & (~Q --> P(y)))
lcp@104
   308
\subcaption{Conditionals}
lcp@104
   309
\end{ttbox}
lcp@104
   310
\caption{More derived rules} \label{hol-lemmas2}
lcp@104
   311
\end{figure}
lcp@104
   312
lcp@104
   313
lcp@104
   314
\section{Rules of inference}
lcp@104
   315
The basic theory has the {\ML} identifier \ttindexbold{HOL.thy}.  However,
lcp@104
   316
many further theories are defined, introducing product and sum types, the
lcp@104
   317
natural numbers, etc.
lcp@104
   318
lcp@104
   319
Figure~\ref{hol-rules} shows the inference rules with their~{\ML} names.
lcp@104
   320
They follow standard practice in higher-order logic: only a few connectives
lcp@104
   321
are taken as primitive, with the remainder defined obscurely.  
lcp@104
   322
lcp@287
   323
Unusually, the definitions are expressed using object-equality~({\tt=})
lcp@287
   324
rather than meta-equality~({\tt==}).  This is possible because equality in
lcp@287
   325
higher-order logic may equate formulae and even functions over formulae.
lcp@287
   326
On the other hand, meta-equality is Isabelle's usual symbol for making
lcp@287
   327
definitions.  Take care to note which form of equality is used before
lcp@287
   328
attempting a proof.
lcp@104
   329
lcp@104
   330
Some of the rules mention type variables; for example, {\tt refl} mentions
lcp@104
   331
the type variable~{\tt'a}.  This facilitates explicit instantiation of the
lcp@104
   332
type variables.  By default, such variables range over class {\it term}.  
lcp@104
   333
lcp@104
   334
\begin{warn}
lcp@104
   335
Where function types are involved, Isabelle's unification code does not
lcp@104
   336
guarantee to find instantiations for type variables automatically.  If
lcp@104
   337
resolution fails for no obvious reason, try setting \ttindex{show_types} to
lcp@104
   338
{\tt true}, causing Isabelle to display types of terms.  (Possibly, set
lcp@104
   339
\ttindex{show_sorts} to {\tt true} also, causing Isabelle to display sorts.)
lcp@104
   340
Be prepared to use \ttindex{res_inst_tac} instead of {\tt resolve_tac}.
lcp@104
   341
Setting \ttindex{Unify.trace_types} to {\tt true} causes Isabelle to
lcp@104
   342
report omitted search paths during unification.
lcp@104
   343
\end{warn}
lcp@104
   344
lcp@104
   345
Here are further comments on the rules:
lcp@104
   346
\begin{description}
lcp@104
   347
\item[\ttindexbold{ext}] 
lcp@104
   348
expresses extensionality of functions.
lcp@104
   349
\item[\ttindexbold{iff}] 
lcp@104
   350
asserts that logically equivalent formulae are equal.
lcp@104
   351
\item[\ttindexbold{selectI}] 
lcp@104
   352
gives the defining property of the Hilbert $\epsilon$-operator.  The
lcp@104
   353
derived rule \ttindexbold{select_equality} (see below) is often easier to use.
lcp@104
   354
\item[\ttindexbold{True_or_False}] 
lcp@104
   355
makes the logic classical.\footnote{In fact, the $\epsilon$-operator
lcp@104
   356
already makes the logic classical, as shown by Diaconescu;
lcp@104
   357
see Paulson~\cite{paulson-COLOG} for details.}
lcp@104
   358
\end{description}
lcp@104
   359
lcp@104
   360
\begin{warn}
lcp@104
   361
{\HOL} has no if-and-only-if connective; logical equivalence is expressed
lcp@104
   362
using equality.  But equality has a high precedence, as befitting a
lcp@104
   363
relation, while if-and-only-if typically has the lowest precedence.  Thus,
lcp@104
   364
$\neg\neg P=P$ abbreviates $\neg\neg (P=P)$ and not $(\neg\neg P)=P$.  When
lcp@104
   365
using $=$ to mean logical equivalence, enclose both operands in
lcp@104
   366
parentheses.
lcp@104
   367
\end{warn}
lcp@104
   368
lcp@104
   369
Some derived rules are shown in Figures~\ref{hol-lemmas1}
lcp@104
   370
and~\ref{hol-lemmas2}, with their {\ML} names.  These include natural rules
lcp@104
   371
for the logical connectives, as well as sequent-style elimination rules for
lcp@104
   372
conjunctions, implications, and universal quantifiers.  
lcp@104
   373
lcp@104
   374
Note the equality rules: \ttindexbold{ssubst} performs substitution in
lcp@104
   375
backward proofs, while \ttindexbold{box_equals} supports reasoning by
lcp@104
   376
simplifying both sides of an equation.
lcp@104
   377
lcp@287
   378
See the files {\tt HOL/hol.thy} and
lcp@287
   379
{\tt HOL/hol.ML} for complete listings of the rules and
lcp@104
   380
derived rules.
lcp@104
   381
lcp@104
   382
lcp@104
   383
\section{Generic packages}
lcp@104
   384
{\HOL} instantiates most of Isabelle's generic packages;
lcp@287
   385
see {\tt HOL/ROOT.ML} for details.
lcp@104
   386
\begin{itemize}
lcp@104
   387
\item 
lcp@104
   388
Because it includes a general substitution rule, {\HOL} instantiates the
lcp@104
   389
tactic \ttindex{hyp_subst_tac}, which substitutes for an equality
lcp@104
   390
throughout a subgoal and its hypotheses.
lcp@104
   391
\item 
lcp@104
   392
It instantiates the simplifier, defining~\ttindexbold{HOL_ss} as the
lcp@104
   393
simplification set for higher-order logic.  Equality~($=$), which also
lcp@104
   394
expresses logical equivalence, may be used for rewriting.  See the file
lcp@287
   395
{\tt HOL/simpdata.ML} for a complete listing of the simplification
lcp@104
   396
rules. 
lcp@104
   397
\item 
lcp@104
   398
It instantiates the classical reasoning module.  See~\S\ref{hol-cla-prover}
lcp@104
   399
for details. 
lcp@104
   400
\end{itemize}
lcp@104
   401
lcp@104
   402
lcp@104
   403
\begin{figure} 
lcp@104
   404
\begin{center}
lcp@104
   405
\begin{tabular}{rrr} 
lcp@111
   406
  \it name      &\it meta-type  & \it description \\ 
lcp@104
   407
\index{"{"}@{\tt\{\}}}
lcp@111
   408
  {\tt\{\}}     & $\alpha\,set$         & the empty set \\
lcp@111
   409
  \idx{insert}  & $[\alpha,\alpha\,set]\To \alpha\,set$
lcp@111
   410
        & insertion of element \\
lcp@111
   411
  \idx{Collect} & $(\alpha\To bool)\To\alpha\,set$
lcp@111
   412
        & comprehension \\
lcp@111
   413
  \idx{Compl}   & $(\alpha\,set)\To\alpha\,set$
lcp@111
   414
        & complement \\
lcp@104
   415
  \idx{INTER} & $[\alpha\,set,\alpha\To\beta\,set]\To\beta\,set$
lcp@111
   416
        & intersection over a set\\
lcp@104
   417
  \idx{UNION} & $[\alpha\,set,\alpha\To\beta\,set]\To\beta\,set$
lcp@111
   418
        & union over a set\\
lcp@104
   419
  \idx{Inter} & $((\alpha\,set)set)\To\alpha\,set$
lcp@111
   420
        &set of sets intersection \\
lcp@104
   421
  \idx{Union} & $((\alpha\,set)set)\To\alpha\,set$
lcp@111
   422
        &set of sets union \\
lcp@111
   423
  \idx{range}   & $(\alpha\To\beta )\To\beta\,set$
lcp@111
   424
        & range of a function \\[1ex]
lcp@111
   425
  \idx{Ball}~~\idx{Bex} & $[\alpha\,set,\alpha\To bool]\To bool$
lcp@111
   426
        & bounded quantifiers \\
lcp@111
   427
  \idx{mono}    & $(\alpha\,set\To\beta\,set)\To bool$
lcp@111
   428
        & monotonicity \\
lcp@104
   429
  \idx{inj}~~\idx{surj}& $(\alpha\To\beta )\To bool$
lcp@111
   430
        & injective/surjective \\
lcp@111
   431
  \idx{inj_onto}        & $[\alpha\To\beta ,\alpha\,set]\To bool$
lcp@111
   432
        & injective over subset
lcp@104
   433
\end{tabular}
lcp@104
   434
\end{center}
lcp@104
   435
\subcaption{Constants}
lcp@104
   436
lcp@104
   437
\begin{center}
lcp@104
   438
\begin{tabular}{llrrr} 
lcp@111
   439
  \it symbol &\it name     &\it meta-type & \it prec & \it description \\
lcp@104
   440
  \idx{INT}  & \idx{INTER1}  & $(\alpha\To\beta\,set)\To\beta\,set$ & 10 & 
lcp@111
   441
        intersection over a type\\
lcp@104
   442
  \idx{UN}  & \idx{UNION1}  & $(\alpha\To\beta\,set)\To\beta\,set$ & 10 & 
lcp@111
   443
        union over a type
lcp@104
   444
\end{tabular}
lcp@104
   445
\end{center}
lcp@104
   446
\subcaption{Binders} 
lcp@104
   447
lcp@104
   448
\begin{center}
lcp@104
   449
\indexbold{*"`"`}
lcp@104
   450
\indexbold{*":}
lcp@104
   451
\indexbold{*"<"=}
lcp@104
   452
\begin{tabular}{rrrr} 
lcp@111
   453
  \it symbol    & \it meta-type & \it precedence & \it description \\ 
lcp@111
   454
  \tt ``        & $[\alpha\To\beta ,\alpha\,set]\To  (\beta\,set)$
lcp@111
   455
        & Left 90 & image \\
lcp@111
   456
  \idx{Int}     & $[\alpha\,set,\alpha\,set]\To\alpha\,set$
lcp@111
   457
        & Left 70 & intersection ($\inter$) \\
lcp@111
   458
  \idx{Un}      & $[\alpha\,set,\alpha\,set]\To\alpha\,set$
lcp@111
   459
        & Left 65 & union ($\union$) \\
lcp@111
   460
  \tt:          & $[\alpha ,\alpha\,set]\To bool$       
lcp@111
   461
        & Left 50 & membership ($\in$) \\
lcp@111
   462
  \tt <=        & $[\alpha\,set,\alpha\,set]\To bool$
lcp@111
   463
        & Left 50 & subset ($\subseteq$) 
lcp@104
   464
\end{tabular}
lcp@104
   465
\end{center}
lcp@104
   466
\subcaption{Infixes}
lcp@104
   467
\caption{Syntax of {\HOL}'s set theory} \label{hol-set-syntax}
lcp@104
   468
\end{figure} 
lcp@104
   469
lcp@104
   470
lcp@104
   471
\begin{figure} 
lcp@104
   472
\begin{center} \tt\frenchspacing
lcp@104
   473
\begin{tabular}{rrr} 
lcp@111
   474
  \it external          & \it internal  & \it description \\ 
lcp@104
   475
  $a$ \ttilde: $b$      & \ttilde($a$ : $b$)    & \rm negated membership\\
wenzelm@154
   476
  \{$a@1$, $\ldots$, $a@n$\}  &  insert($a@1$,$\cdots$,insert($a@n$,\{\})) &
lcp@104
   477
        \rm finite set \\
lcp@111
   478
  \{$x$.$P[x]$\}        &  Collect($\lambda x.P[x]$) &
lcp@104
   479
        \rm comprehension \\
lcp@111
   480
  \idx{INT} $x$:$A$.$B[x]$      & INTER($A$,$\lambda x.B[x]$) &
lcp@111
   481
        \rm intersection over a set \\
lcp@111
   482
  \idx{UN}  $x$:$A$.$B[x]$      & UNION($A$,$\lambda x.B[x]$) &
lcp@111
   483
        \rm union over a set \\
lcp@111
   484
  \idx{!} $x$:$A$.$P[x]$        & Ball($A$,$\lambda x.P[x]$) & 
lcp@111
   485
        \rm bounded $\forall$ \\
lcp@111
   486
  \idx{?} $x$:$A$.$P[x]$        & Bex($A$,$\lambda x.P[x]$) & 
lcp@111
   487
        \rm bounded $\exists$ \\[1ex]
lcp@111
   488
  \idx{ALL} $x$:$A$.$P[x]$      & Ball($A$,$\lambda x.P[x]$) & 
lcp@111
   489
        \rm bounded $\forall$ \\
lcp@111
   490
  \idx{EX} $x$:$A$.$P[x]$       & Bex($A$,$\lambda x.P[x]$) & 
lcp@111
   491
        \rm bounded $\exists$
lcp@104
   492
\end{tabular}
lcp@104
   493
\end{center}
lcp@104
   494
\subcaption{Translations}
lcp@104
   495
lcp@104
   496
\dquotes
lcp@104
   497
\[\begin{array}{rcl}
lcp@104
   498
    term & = & \hbox{other terms\ldots} \\
lcp@111
   499
         & | & "\{\}" \\
lcp@111
   500
         & | & "\{ " term\; ("," term)^* " \}" \\
lcp@111
   501
         & | & "\{ " id " . " formula " \}" \\
lcp@111
   502
         & | & term " `` " term \\
lcp@111
   503
         & | & term " Int " term \\
lcp@111
   504
         & | & term " Un " term \\
lcp@111
   505
         & | & "INT~~"  id ":" term " . " term \\
lcp@111
   506
         & | & "UN~~~"  id ":" term " . " term \\
lcp@111
   507
         & | & "INT~~"  id~id^* " . " term \\
lcp@111
   508
         & | & "UN~~~"  id~id^* " . " term \\[2ex]
lcp@104
   509
 formula & = & \hbox{other formulae\ldots} \\
lcp@111
   510
         & | & term " : " term \\
lcp@111
   511
         & | & term " \ttilde: " term \\
lcp@111
   512
         & | & term " <= " term \\
lcp@111
   513
         & | & "!~~~" id ":" term " . " formula \\
lcp@111
   514
         & | & "?~~~" id ":" term " . " formula \\
lcp@111
   515
         & | & "ALL " id ":" term " . " formula \\
lcp@111
   516
         & | & "EX~~" id ":" term " . " formula
lcp@104
   517
  \end{array}
lcp@104
   518
\]
lcp@104
   519
\subcaption{Full Grammar}
lcp@104
   520
\caption{Syntax of {\HOL}'s set theory (continued)} \label{hol-set-syntax2}
lcp@104
   521
\end{figure} 
lcp@104
   522
lcp@104
   523
lcp@287
   524
\begin{figure} \underscoreon
lcp@104
   525
\begin{ttbox}
lcp@104
   526
\idx{mem_Collect_eq}    (a : \{x.P(x)\}) = P(a)
lcp@104
   527
\idx{Collect_mem_eq}    \{x.x:A\} = A
lcp@104
   528
\subcaption{Isomorphisms between predicates and sets}
lcp@104
   529
wenzelm@154
   530
\idx{empty_def}         \{\}          == \{x.x=False\}
lcp@104
   531
\idx{insert_def}        insert(a,B) == \{x.x=a\} Un B
lcp@104
   532
\idx{Ball_def}          Ball(A,P)   == ! x. x:A --> P(x)
lcp@104
   533
\idx{Bex_def}           Bex(A,P)    == ? x. x:A & P(x)
lcp@104
   534
\idx{subset_def}        A <= B      == ! x:A. x:B
lcp@104
   535
\idx{Un_def}            A Un B      == \{x.x:A | x:B\}
lcp@104
   536
\idx{Int_def}           A Int B     == \{x.x:A & x:B\}
lcp@104
   537
\idx{set_diff_def}      A - B       == \{x.x:A & x~:B\}
lcp@104
   538
\idx{Compl_def}         Compl(A)    == \{x. ~ x:A\}
lcp@104
   539
\idx{INTER_def}         INTER(A,B)  == \{y. ! x:A. y: B(x)\}
lcp@104
   540
\idx{UNION_def}         UNION(A,B)  == \{y. ? x:A. y: B(x)\}
lcp@104
   541
\idx{INTER1_def}        INTER1(B)   == INTER(\{x.True\}, B)
lcp@104
   542
\idx{UNION1_def}        UNION1(B)   == UNION(\{x.True\}, B)
lcp@104
   543
\idx{Inter_def}         Inter(S)    == (INT x:S. x)
lcp@104
   544
\idx{Union_def}         Union(S)    ==  (UN x:S. x)
lcp@104
   545
\idx{image_def}         f``A        == \{y. ? x:A. y=f(x)\}
lcp@104
   546
\idx{range_def}         range(f)    == \{y. ? x. y=f(x)\}
lcp@104
   547
\idx{mono_def}          mono(f)     == !A B. A <= B --> f(A) <= f(B)
lcp@104
   548
\idx{inj_def}           inj(f)      == ! x y. f(x)=f(y) --> x=y
lcp@104
   549
\idx{surj_def}          surj(f)     == ! y. ? x. y=f(x)
lcp@104
   550
\idx{inj_onto_def}      inj_onto(f,A) == !x:A. !y:A. f(x)=f(y) --> x=y
lcp@104
   551
\subcaption{Definitions}
lcp@104
   552
\end{ttbox}
lcp@104
   553
\caption{Rules of {\HOL}'s set theory} \label{hol-set-rules}
lcp@104
   554
\end{figure}
lcp@104
   555
lcp@104
   556
lcp@287
   557
\begin{figure} \underscoreon
lcp@104
   558
\begin{ttbox}
lcp@104
   559
\idx{CollectI}      [| P(a) |] ==> a : \{x.P(x)\}
lcp@104
   560
\idx{CollectD}      [| a : \{x.P(x)\} |] ==> P(a)
lcp@104
   561
\idx{CollectE}      [| a : \{x.P(x)\};  P(a) ==> W |] ==> W
lcp@104
   562
\idx{Collect_cong}  [| !!x. P(x)=Q(x) |] ==> \{x. P(x)\} = \{x. Q(x)\}
lcp@104
   563
\subcaption{Comprehension}
lcp@104
   564
lcp@104
   565
\idx{ballI}         [| !!x. x:A ==> P(x) |] ==> ! x:A. P(x)
lcp@104
   566
\idx{bspec}         [| ! x:A. P(x);  x:A |] ==> P(x)
lcp@104
   567
\idx{ballE}         [| ! x:A. P(x);  P(x) ==> Q;  ~ x:A ==> Q |] ==> Q
lcp@104
   568
\idx{ball_cong}     [| A=A';  !!x. x:A' ==> P(x) = P'(x) |] ==>
lcp@104
   569
              (! x:A. P(x)) = (! x:A'. P'(x))
lcp@104
   570
lcp@104
   571
\idx{bexI}          [| P(x);  x:A |] ==> ? x:A. P(x)
lcp@104
   572
\idx{bexCI}         [| ! x:A. ~ P(x) ==> P(a);  a:A |] ==> ? x:A.P(x)
lcp@104
   573
\idx{bexE}          [| ? x:A. P(x);  !!x. [| x:A; P(x) |] ==> Q  |] ==> Q
lcp@104
   574
\subcaption{Bounded quantifiers}
lcp@104
   575
lcp@104
   576
\idx{subsetI}         (!!x.x:A ==> x:B) ==> A <= B
lcp@104
   577
\idx{subsetD}         [| A <= B;  c:A |] ==> c:B
lcp@104
   578
\idx{subsetCE}        [| A <= B;  ~ (c:A) ==> P;  c:B ==> P |] ==> P
lcp@104
   579
lcp@104
   580
\idx{subset_refl}     A <= A
lcp@104
   581
\idx{subset_antisym}  [| A <= B;  B <= A |] ==> A = B
lcp@104
   582
\idx{subset_trans}    [| A<=B;  B<=C |] ==> A<=C
lcp@104
   583
lcp@104
   584
\idx{set_ext}         [| !!x. (x:A) = (x:B) |] ==> A = B
lcp@104
   585
\idx{equalityD1}      A = B ==> A<=B
lcp@104
   586
\idx{equalityD2}      A = B ==> B<=A
lcp@104
   587
\idx{equalityE}       [| A = B;  [| A<=B; B<=A |] ==> P |]  ==>  P
lcp@104
   588
lcp@104
   589
\idx{equalityCE}      [| A = B;  [| c:A; c:B |] ==> P;  
lcp@104
   590
                           [| ~ c:A; ~ c:B |] ==> P 
lcp@104
   591
                |]  ==>  P
lcp@104
   592
\subcaption{The subset and equality relations}
lcp@104
   593
\end{ttbox}
lcp@104
   594
\caption{Derived rules for set theory} \label{hol-set1}
lcp@104
   595
\end{figure}
lcp@104
   596
lcp@104
   597
lcp@287
   598
\begin{figure} \underscoreon
lcp@104
   599
\begin{ttbox}
lcp@104
   600
\idx{emptyE}   a : \{\} ==> P
lcp@104
   601
lcp@104
   602
\idx{insertI1} a : insert(a,B)
lcp@104
   603
\idx{insertI2} a : B ==> a : insert(b,B)
lcp@114
   604
\idx{insertE}  [| a : insert(b,A);  a=b ==> P;  a:A ==> P |] ==> P
lcp@104
   605
lcp@104
   606
\idx{ComplI}   [| c:A ==> False |] ==> c : Compl(A)
lcp@104
   607
\idx{ComplD}   [| c : Compl(A) |] ==> ~ c:A
lcp@104
   608
lcp@104
   609
\idx{UnI1}     c:A ==> c : A Un B
lcp@104
   610
\idx{UnI2}     c:B ==> c : A Un B
lcp@104
   611
\idx{UnCI}     (~c:B ==> c:A) ==> c : A Un B
lcp@104
   612
\idx{UnE}      [| c : A Un B;  c:A ==> P;  c:B ==> P |] ==> P
lcp@104
   613
lcp@104
   614
\idx{IntI}     [| c:A;  c:B |] ==> c : A Int B
lcp@104
   615
\idx{IntD1}    c : A Int B ==> c:A
lcp@104
   616
\idx{IntD2}    c : A Int B ==> c:B
lcp@104
   617
\idx{IntE}     [| c : A Int B;  [| c:A; c:B |] ==> P |] ==> P
lcp@104
   618
lcp@104
   619
\idx{UN_I}     [| a:A;  b: B(a) |] ==> b: (UN x:A. B(x))
lcp@104
   620
\idx{UN_E}     [| b: (UN x:A. B(x));  !!x.[| x:A;  b:B(x) |] ==> R |] ==> R
lcp@104
   621
lcp@104
   622
\idx{INT_I}    (!!x. x:A ==> b: B(x)) ==> b : (INT x:A. B(x))
lcp@104
   623
\idx{INT_D}    [| b: (INT x:A. B(x));  a:A |] ==> b: B(a)
lcp@104
   624
\idx{INT_E}    [| b: (INT x:A. B(x));  b: B(a) ==> R;  ~ a:A ==> R |] ==> R
lcp@104
   625
lcp@104
   626
\idx{UnionI}   [| X:C;  A:X |] ==> A : Union(C)
lcp@104
   627
\idx{UnionE}   [| A : Union(C);  !!X.[| A:X;  X:C |] ==> R |] ==> R
lcp@104
   628
lcp@104
   629
\idx{InterI}   [| !!X. X:C ==> A:X |] ==> A : Inter(C)
lcp@104
   630
\idx{InterD}   [| A : Inter(C);  X:C |] ==> A:X
lcp@104
   631
\idx{InterE}   [| A : Inter(C);  A:X ==> R;  ~ X:C ==> R |] ==> R
lcp@104
   632
\end{ttbox}
lcp@104
   633
\caption{Further derived rules for set theory} \label{hol-set2}
lcp@104
   634
\end{figure}
lcp@104
   635
lcp@104
   636
lcp@104
   637
\section{A formulation of set theory}
lcp@104
   638
Historically, higher-order logic gives a foundation for Russell and
lcp@104
   639
Whitehead's theory of classes.  Let us use modern terminology and call them
lcp@104
   640
{\bf sets}, but note that these sets are distinct from those of {\ZF} set
lcp@104
   641
theory, and behave more like {\ZF} classes.
lcp@104
   642
\begin{itemize}
lcp@104
   643
\item
lcp@104
   644
Sets are given by predicates over some type~$\sigma$.  Types serve to
lcp@104
   645
define universes for sets, but type checking is still significant.
lcp@104
   646
\item
lcp@104
   647
There is a universal set (for each type).  Thus, sets have complements, and
lcp@104
   648
may be defined by absolute comprehension.
lcp@104
   649
\item
lcp@104
   650
Although sets may contain other sets as elements, the containing set must
lcp@104
   651
have a more complex type.
lcp@104
   652
\end{itemize}
lcp@104
   653
Finite unions and intersections have the same behaviour in {\HOL} as they
lcp@104
   654
do in~{\ZF}.  In {\HOL} the intersection of the empty set is well-defined,
lcp@104
   655
denoting the universal set for the given type.
lcp@104
   656
lcp@104
   657
\subsection{Syntax of set theory}
lcp@287
   658
The type $\alpha\,set$ is essentially the same as $\alpha\To bool$.  The
lcp@287
   659
new type is defined for clarity and to avoid complications involving
lcp@287
   660
function types in unification.  Since Isabelle does not support type
lcp@287
   661
definitions (as mentioned in \S\ref{HOL-types}), the isomorphisms between
lcp@287
   662
the two types are declared explicitly.  Here they are natural: {\tt
lcp@287
   663
  Collect} maps $\alpha\To bool$ to $\alpha\,set$, while \hbox{\tt op :}
lcp@287
   664
maps in the other direction (ignoring argument order).
lcp@104
   665
lcp@104
   666
Figure~\ref{hol-set-syntax} lists the constants, infixes, and syntax
lcp@104
   667
translations.  Figure~\ref{hol-set-syntax2} presents the grammar of the new
lcp@104
   668
constructs.  Infix operators include union and intersection ($A\union B$
lcp@104
   669
and $A\inter B$), the subset and membership relations, and the image
lcp@104
   670
operator~{\tt``}.  Note that $a$\verb|~:|$b$ is translated to
lcp@104
   671
\verb|~(|$a$:$b$\verb|)|.  The {\tt\{\ldots\}} notation abbreviates finite
lcp@104
   672
sets constructed in the obvious manner using~{\tt insert} and~$\{\}$ (the
lcp@104
   673
empty set):
lcp@104
   674
\begin{eqnarray*}
wenzelm@154
   675
 \{a,b,c\} & \equiv & {\tt insert}(a,{\tt insert}(b,{\tt insert}(c,\{\})))
lcp@104
   676
\end{eqnarray*}
lcp@104
   677
lcp@104
   678
The set \hbox{\tt\{$x$.$P[x]$\}} consists of all $x$ (of suitable type)
lcp@104
   679
that satisfy~$P[x]$, where $P[x]$ is a formula that may contain free
lcp@104
   680
occurrences of~$x$.  This syntax expands to \ttindexbold{Collect}$(\lambda
lcp@104
   681
x.P[x])$. 
lcp@104
   682
lcp@104
   683
The set theory defines two {\bf bounded quantifiers}:
lcp@104
   684
\begin{eqnarray*}
lcp@104
   685
   \forall x\in A.P[x] &\hbox{which abbreviates}& \forall x. x\in A\imp P[x] \\
lcp@104
   686
   \exists x\in A.P[x] &\hbox{which abbreviates}& \exists x. x\in A\conj P[x]
lcp@104
   687
\end{eqnarray*}
lcp@104
   688
The constants~\ttindexbold{Ball} and~\ttindexbold{Bex} are defined
lcp@104
   689
accordingly.  Instead of {\tt Ball($A$,$P$)} and {\tt Bex($A$,$P$)} we may
lcp@104
   690
write\index{*"!}\index{*"?}\index{*ALL}\index{*EX}
lcp@104
   691
\hbox{\tt !~$x$:$A$.$P[x]$} and \hbox{\tt ?~$x$:$A$.$P[x]$}. 
lcp@104
   692
Isabelle's usual notation, \ttindex{ALL} and \ttindex{EX}, is also
lcp@104
   693
available.  As with
lcp@104
   694
ordinary quantifiers, the contents of \ttindexbold{HOL_quantifiers} specifies
lcp@104
   695
which notation should be used for output.
lcp@104
   696
lcp@104
   697
Unions and intersections over sets, namely $\bigcup@{x\in A}B[x]$ and
lcp@104
   698
$\bigcap@{x\in A}B[x]$, are written 
lcp@104
   699
\ttindexbold{UN}~\hbox{\tt$x$:$A$.$B[x]$} and
lcp@104
   700
\ttindexbold{INT}~\hbox{\tt$x$:$A$.$B[x]$}.  
lcp@104
   701
Unions and intersections over types, namely $\bigcup@x B[x]$ and
lcp@104
   702
$\bigcap@x B[x]$, are written 
lcp@104
   703
\ttindexbold{UN}~\hbox{\tt$x$.$B[x]$} and
lcp@104
   704
\ttindexbold{INT}~\hbox{\tt$x$.$B[x]$}; they are equivalent to the previous
lcp@104
   705
union/intersection operators when $A$ is the universal set.
lcp@104
   706
The set of set union and intersection operators ($\bigcup A$ and $\bigcap
lcp@104
   707
A$) are not binders, but equals $\bigcup@{x\in A}x$ and $\bigcap@{x\in
lcp@104
   708
  A}x$, respectively.
lcp@104
   709
lcp@104
   710
\subsection{Axioms and rules of set theory}
lcp@104
   711
The axioms \ttindexbold{mem_Collect_eq} and
lcp@104
   712
\ttindexbold{Collect_mem_eq} assert that the functions {\tt Collect} and
lcp@104
   713
\hbox{\tt op :} are isomorphisms. 
lcp@287
   714
All the other axioms are definitions; see Fig.\ts \ref{hol-set-rules}.
lcp@104
   715
These include straightforward properties of functions: image~({\tt``}) and
lcp@104
   716
{\tt range}, and predicates concerning monotonicity, injectiveness, etc.
lcp@104
   717
lcp@104
   718
{\HOL}'s set theory has the {\ML} identifier \ttindexbold{Set.thy}.
lcp@104
   719
lcp@287
   720
\begin{figure} \underscoreon
lcp@104
   721
\begin{ttbox}
lcp@104
   722
\idx{imageI}     [| x:A |] ==> f(x) : f``A
lcp@104
   723
\idx{imageE}     [| b : f``A;  !!x.[| b=f(x);  x:A |] ==> P |] ==> P
lcp@104
   724
lcp@104
   725
\idx{rangeI}     f(x) : range(f)
lcp@104
   726
\idx{rangeE}     [| b : range(f);  !!x.[| b=f(x) |] ==> P |] ==> P
lcp@104
   727
lcp@104
   728
\idx{monoI}      [| !!A B. A <= B ==> f(A) <= f(B) |] ==> mono(f)
lcp@104
   729
\idx{monoD}      [| mono(f);  A <= B |] ==> f(A) <= f(B)
lcp@104
   730
lcp@104
   731
\idx{injI}       [| !! x y. f(x) = f(y) ==> x=y |] ==> inj(f)
lcp@104
   732
\idx{inj_inverseI}              (!!x. g(f(x)) = x) ==> inj(f)
lcp@104
   733
\idx{injD}       [| inj(f); f(x) = f(y) |] ==> x=y
lcp@104
   734
lcp@104
   735
\idx{Inv_f_f}    inj(f) ==> Inv(f,f(x)) = x
lcp@104
   736
\idx{f_Inv_f}    y : range(f) ==> f(Inv(f,y)) = y
lcp@104
   737
lcp@104
   738
\idx{Inv_injective}
lcp@104
   739
    [| Inv(f,x)=Inv(f,y); x: range(f);  y: range(f) |] ==> x=y
lcp@104
   740
lcp@104
   741
\idx{inj_ontoI}
lcp@104
   742
    (!! x y. [| f(x) = f(y); x:A; y:A |] ==> x=y) ==> inj_onto(f,A)
lcp@104
   743
lcp@104
   744
\idx{inj_onto_inverseI}
lcp@104
   745
    (!!x. x:A ==> g(f(x)) = x) ==> inj_onto(f,A)
lcp@104
   746
lcp@104
   747
\idx{inj_ontoD}
lcp@104
   748
    [| inj_onto(f,A);  f(x)=f(y);  x:A;  y:A |] ==> x=y
lcp@104
   749
lcp@104
   750
\idx{inj_onto_contraD}
lcp@104
   751
    [| inj_onto(f,A);  x~=y;  x:A;  y:A |] ==> ~ f(x)=f(y)
lcp@104
   752
\end{ttbox}
lcp@104
   753
\caption{Derived rules involving functions} \label{hol-fun}
lcp@104
   754
\end{figure}
lcp@104
   755
lcp@104
   756
lcp@287
   757
\begin{figure} \underscoreon
lcp@104
   758
\begin{ttbox}
lcp@104
   759
\idx{Union_upper}     B:A ==> B <= Union(A)
lcp@104
   760
\idx{Union_least}     [| !!X. X:A ==> X<=C |] ==> Union(A) <= C
lcp@104
   761
lcp@104
   762
\idx{Inter_lower}     B:A ==> Inter(A) <= B
lcp@104
   763
\idx{Inter_greatest}  [| !!X. X:A ==> C<=X |] ==> C <= Inter(A)
lcp@104
   764
lcp@104
   765
\idx{Un_upper1}       A <= A Un B
lcp@104
   766
\idx{Un_upper2}       B <= A Un B
lcp@104
   767
\idx{Un_least}        [| A<=C;  B<=C |] ==> A Un B <= C
lcp@104
   768
lcp@104
   769
\idx{Int_lower1}      A Int B <= A
lcp@104
   770
\idx{Int_lower2}      A Int B <= B
lcp@104
   771
\idx{Int_greatest}    [| C<=A;  C<=B |] ==> C <= A Int B
lcp@104
   772
\end{ttbox}
lcp@104
   773
\caption{Derived rules involving subsets} \label{hol-subset}
lcp@104
   774
\end{figure}
lcp@104
   775
lcp@104
   776
lcp@287
   777
\begin{figure} \underscoreon
lcp@104
   778
\begin{ttbox}
lcp@104
   779
\idx{Int_absorb}         A Int A = A
lcp@104
   780
\idx{Int_commute}        A Int B = B Int A
lcp@104
   781
\idx{Int_assoc}          (A Int B) Int C  =  A Int (B Int C)
lcp@104
   782
\idx{Int_Un_distrib}     (A Un B)  Int C  =  (A Int C) Un (B Int C)
lcp@104
   783
lcp@104
   784
\idx{Un_absorb}          A Un A = A
lcp@104
   785
\idx{Un_commute}         A Un B = B Un A
lcp@104
   786
\idx{Un_assoc}           (A Un B)  Un C  =  A Un (B Un C)
lcp@104
   787
\idx{Un_Int_distrib}     (A Int B) Un C  =  (A Un C) Int (B Un C)
lcp@104
   788
lcp@104
   789
\idx{Compl_disjoint}     A Int Compl(A) = \{x.False\} 
lcp@104
   790
\idx{Compl_partition}    A Un  Compl(A) = \{x.True\}
lcp@104
   791
\idx{double_complement}  Compl(Compl(A)) = A
lcp@104
   792
\idx{Compl_Un}           Compl(A Un B)  = Compl(A) Int Compl(B)
lcp@104
   793
\idx{Compl_Int}          Compl(A Int B) = Compl(A) Un Compl(B)
lcp@104
   794
lcp@104
   795
\idx{Union_Un_distrib}   Union(A Un B) = Union(A) Un Union(B)
lcp@287
   796
\idx{Int_Union}          A Int Union(B) = (UN C:B. A Int C)
lcp@104
   797
\idx{Un_Union_image} 
lcp@104
   798
    (UN x:C. A(x) Un B(x)) = Union(A``C)  Un  Union(B``C)
lcp@104
   799
lcp@104
   800
\idx{Inter_Un_distrib}   Inter(A Un B) = Inter(A) Int Inter(B)
lcp@287
   801
\idx{Un_Inter}           A Un Inter(B) = (INT C:B. A Un C)
lcp@104
   802
\idx{Int_Inter_image}
lcp@104
   803
   (INT x:C. A(x) Int B(x)) = Inter(A``C) Int Inter(B``C)
lcp@104
   804
\end{ttbox}
lcp@104
   805
\caption{Set equalities} \label{hol-equalities}
lcp@104
   806
\end{figure}
lcp@104
   807
lcp@104
   808
lcp@104
   809
\subsection{Derived rules for sets}
lcp@104
   810
Figures~\ref{hol-set1} and~\ref{hol-set2} present derived rules.  Most
lcp@104
   811
are obvious and resemble rules of Isabelle's {\ZF} set theory.  The
lcp@104
   812
rules named $XXX${\tt_cong} break down equalities.  Certain rules, such as
lcp@104
   813
\ttindexbold{subsetCE}, \ttindexbold{bexCI} and \ttindexbold{UnCI}, are
lcp@104
   814
designed for classical reasoning; the more natural rules \ttindexbold{subsetD},
lcp@104
   815
\ttindexbold{bexI}, \ttindexbold{Un1} and~\ttindexbold{Un2} are not
lcp@104
   816
strictly necessary.  Similarly, \ttindexbold{equalityCE} supports classical
lcp@104
   817
reasoning about extensionality, after the fashion of \ttindex{iffCE}.  See
lcp@287
   818
the file {\tt HOL/set.ML} for proofs pertaining to set theory.
lcp@104
   819
lcp@287
   820
Figure~\ref{hol-fun} presents derived inference rules involving functions.  See
lcp@287
   821
the file {\tt HOL/fun.ML} for a complete listing.
lcp@104
   822
lcp@104
   823
Figure~\ref{hol-subset} presents lattice properties of the subset relation.
lcp@287
   824
See the file {\tt HOL/subset.ML}.
lcp@104
   825
lcp@104
   826
Figure~\ref{hol-equalities} presents set equalities.  See
lcp@287
   827
{\tt HOL/equalities.ML}.
lcp@104
   828
lcp@104
   829
lcp@287
   830
\begin{figure}
lcp@104
   831
\begin{center}
lcp@104
   832
\begin{tabular}{rrr} 
lcp@111
   833
  \it name      &\it meta-type  & \it description \\ 
lcp@111
   834
  \idx{Pair}    & $[\alpha,\beta]\To \alpha\times\beta$
lcp@111
   835
        & ordered pairs $\langle a,b\rangle$ \\
lcp@287
   836
  \idx{fst}     & $\alpha\times\beta \To \alpha$        & first projection\\
lcp@111
   837
  \idx{snd}     & $\alpha\times\beta \To \beta$         & second projection\\
lcp@111
   838
  \idx{split}   & $[\alpha\times\beta, [\alpha,\beta]\To\gamma] \To \gamma$ 
lcp@287
   839
        & generalized projection\\
lcp@287
   840
  \idx{Sigma}  & 
lcp@287
   841
        $[\alpha\,set, \alpha\To\beta\,set]\To(\alpha\times\beta)set$ &
lcp@287
   842
        general sum of sets
lcp@104
   843
\end{tabular}
lcp@104
   844
\end{center}
lcp@104
   845
\subcaption{Constants}
lcp@104
   846
lcp@287
   847
\begin{ttbox}\makeatletter
lcp@104
   848
\idx{fst_def}      fst(p)     == @a. ? b. p = <a,b>
lcp@104
   849
\idx{snd_def}      snd(p)     == @b. ? a. p = <a,b>
lcp@104
   850
\idx{split_def}    split(p,c) == c(fst(p),snd(p))
lcp@287
   851
\idx{Sigma_def}    Sigma(A,B) == UN x:A. UN y:B(x). \{<x,y>\}
lcp@104
   852
\subcaption{Definitions}
lcp@104
   853
lcp@104
   854
\idx{Pair_inject}  [| <a, b> = <a',b'>;  [| a=a';  b=b' |] ==> R |] ==> R
lcp@104
   855
lcp@104
   856
\idx{fst}          fst(<a,b>) = a
lcp@104
   857
\idx{snd}          snd(<a,b>) = b
lcp@104
   858
\idx{split}        split(<a,b>, c) = c(a,b)
lcp@104
   859
lcp@104
   860
\idx{surjective_pairing}  p = <fst(p),snd(p)>
lcp@287
   861
lcp@287
   862
\idx{SigmaI}       [| a:A;  b:B(a) |] ==> <a,b> : Sigma(A,B)
lcp@287
   863
lcp@287
   864
\idx{SigmaE}       [| c: Sigma(A,B);  
lcp@287
   865
                !!x y.[| x:A; y:B(x); c=<x,y> |] ==> P |] ==> P
lcp@104
   866
\subcaption{Derived rules}
lcp@104
   867
\end{ttbox}
lcp@104
   868
\caption{Type $\alpha\times\beta$} 
lcp@104
   869
\label{hol-prod}
lcp@104
   870
\end{figure} 
lcp@104
   871
lcp@104
   872
lcp@287
   873
\begin{figure}
lcp@104
   874
\begin{center}
lcp@104
   875
\begin{tabular}{rrr} 
lcp@111
   876
  \it name      &\it meta-type  & \it description \\ 
lcp@111
   877
  \idx{Inl}     & $\alpha \To \alpha+\beta$                     & first injection\\
lcp@111
   878
  \idx{Inr}     & $\beta \To \alpha+\beta$                      & second injection\\
lcp@111
   879
  \idx{case}    & $[\alpha+\beta, \alpha\To\gamma, \beta\To\gamma] \To\gamma$
lcp@111
   880
        & conditional
lcp@104
   881
\end{tabular}
lcp@104
   882
\end{center}
lcp@104
   883
\subcaption{Constants}
lcp@104
   884
lcp@287
   885
\begin{ttbox}\makeatletter
lcp@287
   886
\idx{case_def}     case == (\%p f g. @z. (!x. p=Inl(x) --> z=f(x)) &
lcp@104
   887
                                  (!y. p=Inr(y) --> z=g(y)))
lcp@104
   888
\subcaption{Definition}
lcp@104
   889
lcp@104
   890
\idx{Inl_not_Inr}    ~ Inl(a)=Inr(b)
lcp@104
   891
lcp@104
   892
\idx{inj_Inl}        inj(Inl)
lcp@104
   893
\idx{inj_Inr}        inj(Inr)
lcp@104
   894
lcp@104
   895
\idx{sumE}           [| !!x::'a. P(Inl(x));  !!y::'b. P(Inr(y)) |] ==> P(s)
lcp@104
   896
lcp@104
   897
\idx{case_Inl}       case(Inl(x), f, g) = f(x)
lcp@104
   898
\idx{case_Inr}       case(Inr(x), f, g) = g(x)
lcp@104
   899
lcp@104
   900
\idx{surjective_sum} case(s, %x::'a. f(Inl(x)), %y::'b. f(Inr(y))) = f(s)
lcp@104
   901
\subcaption{Derived rules}
lcp@104
   902
\end{ttbox}
lcp@104
   903
\caption{Rules for type $\alpha+\beta$} 
lcp@104
   904
\label{hol-sum}
lcp@104
   905
\end{figure}
lcp@104
   906
lcp@104
   907
lcp@104
   908
\section{Types}
lcp@104
   909
The basic higher-order logic is augmented with a tremendous amount of
lcp@104
   910
material, including support for recursive function and type definitions.
lcp@104
   911
Space does not permit a detailed discussion.  The present section describes
lcp@104
   912
product, sum, natural number and list types.
lcp@104
   913
lcp@104
   914
\subsection{Product and sum types}
lcp@104
   915
{\HOL} defines the product type $\alpha\times\beta$ and the sum type
lcp@104
   916
$\alpha+\beta$, with the ordered pair syntax {\tt<$a$,$b$>}, using fairly
lcp@287
   917
standard constructions (Figs.~\ref{hol-prod} and~\ref{hol-sum}).  Because
lcp@287
   918
Isabelle does not support abstract type definitions, the isomorphisms
lcp@287
   919
between these types and their representations are made explicitly.
lcp@104
   920
lcp@104
   921
Most of the definitions are suppressed, but observe that the projections
lcp@104
   922
and conditionals are defined as descriptions.  Their properties are easily
lcp@287
   923
proved using \ttindex{select_equality}.  See {\tt HOL/prod.thy} and
lcp@287
   924
{\tt HOL/sum.thy} for details.
lcp@104
   925
lcp@287
   926
\begin{figure} 
lcp@104
   927
\indexbold{*"<}
lcp@104
   928
\begin{center}
lcp@104
   929
\begin{tabular}{rrr} 
lcp@111
   930
  \it symbol    & \it meta-type & \it description \\ 
lcp@111
   931
  \idx{0}       & $nat$         & zero \\
lcp@111
   932
  \idx{Suc}     & $nat \To nat$ & successor function\\
lcp@104
   933
  \idx{nat_case} & $[nat, \alpha, nat\To\alpha] \To\alpha$
lcp@111
   934
        & conditional\\
lcp@104
   935
  \idx{nat_rec} & $[nat, \alpha, [nat, \alpha]\To\alpha] \To \alpha$
lcp@111
   936
        & primitive recursor\\
lcp@104
   937
  \idx{pred_nat} & $(nat\times nat) set$ & predecessor relation
lcp@104
   938
\end{tabular}
lcp@104
   939
\end{center}
lcp@104
   940
lcp@104
   941
\begin{center}
lcp@104
   942
\indexbold{*"+}
lcp@104
   943
\index{*@{\tt*}|bold}
lcp@104
   944
\index{/@{\tt/}|bold}
lcp@104
   945
\index{//@{\tt//}|bold}
lcp@104
   946
\index{+@{\tt+}|bold}
lcp@104
   947
\index{-@{\tt-}|bold}
lcp@104
   948
\begin{tabular}{rrrr} 
lcp@111
   949
  \it symbol    & \it meta-type & \it precedence & \it description \\ 
lcp@111
   950
  \tt *         & $[nat,nat]\To nat$    &  Left 70      & multiplication \\
lcp@111
   951
  \tt /         & $[nat,nat]\To nat$    &  Left 70      & division\\
lcp@111
   952
  \tt //        & $[nat,nat]\To nat$    &  Left 70      & modulus\\
lcp@111
   953
  \tt +         & $[nat,nat]\To nat$    &  Left 65      & addition\\
lcp@111
   954
  \tt -         & $[nat,nat]\To nat$    &  Left 65      & subtraction
lcp@104
   955
\end{tabular}
lcp@104
   956
\end{center}
lcp@104
   957
\subcaption{Constants and infixes}
lcp@104
   958
lcp@287
   959
\begin{ttbox}\makeatother
lcp@287
   960
\idx{nat_case_def}  nat_case == (\%n a f. @z. (n=0 --> z=a) & 
lcp@104
   961
                                        (!x. n=Suc(x) --> z=f(x)))
lcp@104
   962
\idx{pred_nat_def}  pred_nat == \{p. ? n. p = <n, Suc(n)>\} 
lcp@104
   963
\idx{less_def}      m<n      == <m,n>:pred_nat^+
lcp@104
   964
\idx{nat_rec_def}   nat_rec(n,c,d) == 
lcp@287
   965
               wfrec(pred_nat, n, \%l g.nat_case(l, c, \%m.d(m,g(m))))
lcp@104
   966
lcp@287
   967
\idx{add_def}   m+n  == nat_rec(m, n, \%u v.Suc(v))
lcp@287
   968
\idx{diff_def}  m-n  == nat_rec(n, m, \%u v. nat_rec(v, 0, \%x y.x))
lcp@287
   969
\idx{mult_def}  m*n  == nat_rec(m, 0, \%u v. n + v)
lcp@287
   970
\idx{mod_def}   m//n == wfrec(trancl(pred_nat), m, \%j f. if(j<n,j,f(j-n)))
lcp@104
   971
\idx{quo_def}   m/n  == wfrec(trancl(pred_nat), 
lcp@287
   972
                        m, \%j f. if(j<n,0,Suc(f(j-n))))
lcp@104
   973
\subcaption{Definitions}
lcp@104
   974
\end{ttbox}
lcp@104
   975
\caption{Defining $nat$, the type of natural numbers} \label{hol-nat1}
lcp@104
   976
\end{figure}
lcp@104
   977
lcp@104
   978
lcp@287
   979
\begin{figure} \underscoreon
lcp@104
   980
\begin{ttbox}
lcp@104
   981
\idx{nat_induct}     [| P(0); !!k. [| P(k) |] ==> P(Suc(k)) |]  ==> P(n)
lcp@104
   982
lcp@104
   983
\idx{Suc_not_Zero}   Suc(m) ~= 0
lcp@104
   984
\idx{inj_Suc}        inj(Suc)
lcp@104
   985
\idx{n_not_Suc_n}    n~=Suc(n)
lcp@104
   986
\subcaption{Basic properties}
lcp@104
   987
lcp@104
   988
\idx{pred_natI}      <n, Suc(n)> : pred_nat
lcp@104
   989
\idx{pred_natE}
lcp@104
   990
    [| p : pred_nat;  !!x n. [| p = <n, Suc(n)> |] ==> R |] ==> R
lcp@104
   991
lcp@104
   992
\idx{nat_case_0}     nat_case(0, a, f) = a
lcp@104
   993
\idx{nat_case_Suc}   nat_case(Suc(k), a, f) = f(k)
lcp@104
   994
lcp@104
   995
\idx{wf_pred_nat}    wf(pred_nat)
lcp@104
   996
\idx{nat_rec_0}      nat_rec(0,c,h) = c
lcp@104
   997
\idx{nat_rec_Suc}    nat_rec(Suc(n), c, h) = h(n, nat_rec(n,c,h))
lcp@104
   998
\subcaption{Case analysis and primitive recursion}
lcp@104
   999
lcp@104
  1000
\idx{less_trans}     [| i<j;  j<k |] ==> i<k
lcp@104
  1001
\idx{lessI}          n < Suc(n)
lcp@104
  1002
\idx{zero_less_Suc}  0 < Suc(n)
lcp@104
  1003
lcp@104
  1004
\idx{less_not_sym}   n<m --> ~ m<n 
lcp@104
  1005
\idx{less_not_refl}  ~ n<n
lcp@104
  1006
\idx{not_less0}      ~ n<0
lcp@104
  1007
lcp@104
  1008
\idx{Suc_less_eq}    (Suc(m) < Suc(n)) = (m<n)
lcp@104
  1009
\idx{less_induct}    [| !!n. [| ! m. m<n --> P(m) |] ==> P(n) |]  ==>  P(n)
lcp@104
  1010
lcp@104
  1011
\idx{less_linear}    m<n | m=n | n<m
lcp@104
  1012
\subcaption{The less-than relation}
lcp@104
  1013
\end{ttbox}
lcp@104
  1014
\caption{Derived rules for~$nat$} \label{hol-nat2}
lcp@104
  1015
\end{figure}
lcp@104
  1016
lcp@104
  1017
lcp@104
  1018
\subsection{The type of natural numbers, $nat$}
lcp@104
  1019
{\HOL} defines the natural numbers in a roundabout but traditional way.
lcp@104
  1020
The axiom of infinity postulates an type~$ind$ of individuals, which is
lcp@104
  1021
non-empty and closed under an injective operation.  The natural numbers are
lcp@104
  1022
inductively generated by choosing an arbitrary individual for~0 and using
lcp@104
  1023
the injective operation to take successors.  As usual, the isomorphisms
lcp@104
  1024
between~$nat$ and its representation are made explicitly.
lcp@104
  1025
lcp@104
  1026
The definition makes use of a least fixed point operator \ttindex{lfp},
lcp@104
  1027
defined using the Knaster-Tarski theorem.  This in turn defines an operator
lcp@104
  1028
\ttindex{trancl} for taking the transitive closure of a relation.  See
lcp@287
  1029
files {\tt HOL/lfp.thy} and {\tt HOL/trancl.thy} for
lcp@287
  1030
details.  The definition of~$nat$ resides on {\tt HOL/nat.thy}.  
lcp@104
  1031
lcp@104
  1032
Type $nat$ is postulated to belong to class~$ord$, which overloads $<$ and
lcp@104
  1033
$\leq$ on the natural numbers.  As of this writing, Isabelle provides no
lcp@104
  1034
means of verifying that such overloading is sensible.  On the other hand,
lcp@104
  1035
the {\HOL} theory includes no polymorphic axioms stating general properties
lcp@104
  1036
of $<$ and $\leq$.
lcp@104
  1037
lcp@287
  1038
File {\tt HOL/arith.ML} develops arithmetic on the natural numbers.
lcp@104
  1039
It defines addition, multiplication, subtraction, division, and remainder,
lcp@104
  1040
proving the theorem $a \bmod b + (a/b)\times b = a$.  Division and
lcp@104
  1041
remainder are defined by repeated subtraction, which requires well-founded
lcp@104
  1042
rather than primitive recursion.
lcp@104
  1043
lcp@104
  1044
Primitive recursion makes use of \ttindex{wfrec}, an operator for recursion
lcp@287
  1045
along arbitrary well-founded relations; see {\tt HOL/wf.ML} for the
lcp@104
  1046
development.  The predecessor relation, \ttindexbold{pred_nat}, is shown to
lcp@104
  1047
be well-founded; recursion along this relation is primitive recursion,
lcp@104
  1048
while its transitive closure is~$<$.
lcp@104
  1049
lcp@104
  1050
lcp@287
  1051
\begin{figure}
lcp@104
  1052
\begin{center}
lcp@104
  1053
\begin{tabular}{rrr} 
lcp@111
  1054
  \it symbol    & \it meta-type & \it description \\ 
lcp@111
  1055
  \idx{Nil}     & $\alpha list$ & the empty list\\
lcp@111
  1056
  \idx{Cons}    & $[\alpha, \alpha list] \To \alpha list$
lcp@111
  1057
        & list constructor\\
lcp@111
  1058
  \idx{list_rec}        & $[\alpha list, \beta, [\alpha ,\alpha list,
lcp@104
  1059
\beta]\To\beta] \To \beta$
lcp@111
  1060
        & list recursor\\
lcp@111
  1061
  \idx{map}     & $(\alpha\To\beta) \To (\alpha list \To \beta list)$
lcp@111
  1062
        & mapping functional
lcp@104
  1063
\end{tabular}
lcp@104
  1064
\end{center}
lcp@104
  1065
\subcaption{Constants}
lcp@104
  1066
lcp@104
  1067
\begin{ttbox}
lcp@287
  1068
\idx{map_def}     map(f,xs) == list_rec(xs, Nil, \%x l r. Cons(f(x), r))
lcp@104
  1069
\subcaption{Definition}
lcp@104
  1070
lcp@104
  1071
\idx{list_induct}
lcp@104
  1072
    [| P(Nil);  !!x xs. [| P(xs) |] ==> P(Cons(x,xs)) |]  ==> P(l)
lcp@104
  1073
lcp@104
  1074
\idx{Cons_not_Nil}   ~ Cons(x,xs) = Nil
lcp@104
  1075
\idx{Cons_Cons_eq}   (Cons(x,xs)=Cons(y,ys)) = (x=y & xs=ys)
lcp@104
  1076
lcp@104
  1077
\idx{list_rec_Nil}   list_rec(Nil,c,h) = c
lcp@104
  1078
\idx{list_rec_Cons}  list_rec(Cons(a,l), c, h) = h(a, l, list_rec(l,c,h))
lcp@104
  1079
lcp@104
  1080
\idx{map_Nil}        map(f,Nil) = Nil
lcp@104
  1081
\idx{map_Cons}       map(f, Cons(x,xs)) = Cons(f(x), map(f,xs))
lcp@104
  1082
\end{ttbox}
lcp@104
  1083
\caption{The type of lists and its operations} \label{hol-list}
lcp@104
  1084
\end{figure}
lcp@104
  1085
lcp@104
  1086
lcp@104
  1087
\subsection{The type constructor for lists, $\alpha\,list$}
lcp@104
  1088
{\HOL}'s definition of lists is an example of an experimental method for
lcp@104
  1089
handling recursive data types.  The details need not concern us here; see
lcp@287
  1090
the file {\tt HOL/list.ML}.  Figure~\ref{hol-list} presents the
lcp@104
  1091
basic list operations, with their types and properties.  In particular,
lcp@104
  1092
\ttindexbold{list_rec} is a primitive recursion operator for lists, in the
lcp@104
  1093
style of Martin-L\"of type theory.  It is derived from well-founded
lcp@104
  1094
recursion, a general principle that can express arbitrary total recursive
lcp@104
  1095
functions. 
lcp@104
  1096
lcp@104
  1097
lcp@104
  1098
\subsection{The type constructor for lazy lists, $\alpha\,llist$}
lcp@104
  1099
The definition of lazy lists demonstrates methods for handling infinite
lcp@104
  1100
data structures and co-induction in higher-order logic.  It defines an
lcp@104
  1101
operator for co-recursion on lazy lists, which is used to define a few
lcp@104
  1102
simple functions such as map and append.  Co-recursion cannot easily define
lcp@104
  1103
operations such as filter, which can compute indefinitely before yielding
lcp@104
  1104
the next element (if any!) of the lazy list.  A co-induction principle is
lcp@104
  1105
defined for proving equations on lazy lists.  See the files
lcp@287
  1106
{\tt HOL/llist.thy} and {\tt HOL/llist.ML} for the formal
lcp@104
  1107
derivations.  I have written a report discussing the treatment of lazy
lcp@104
  1108
lists, and finite lists also~\cite{paulson-coind}.
lcp@104
  1109
lcp@104
  1110
lcp@104
  1111
\section{Classical proof procedures} \label{hol-cla-prover}
lcp@104
  1112
{\HOL} derives classical introduction rules for $\disj$ and~$\exists$, as
lcp@104
  1113
well as classical elimination rules for~$\imp$ and~$\bimp$, and the swap
lcp@287
  1114
rule (Fig.~\ref{hol-lemmas2}).
lcp@104
  1115
lcp@104
  1116
The classical reasoning module is set up for \HOL, as the structure 
lcp@104
  1117
\ttindexbold{Classical}.  This structure is open, so {\ML} identifiers such
lcp@104
  1118
as {\tt step_tac}, {\tt fast_tac}, {\tt best_tac}, etc., refer to it.
lcp@104
  1119
lcp@104
  1120
{\HOL} defines the following classical rule sets:
lcp@104
  1121
\begin{ttbox} 
lcp@104
  1122
prop_cs    : claset
lcp@104
  1123
HOL_cs     : claset
lcp@104
  1124
HOL_dup_cs : claset
lcp@104
  1125
set_cs     : claset
lcp@104
  1126
\end{ttbox}
lcp@104
  1127
\begin{description}
lcp@104
  1128
\item[\ttindexbold{prop_cs}] contains the propositional rules, namely
lcp@104
  1129
those for~$\top$, $\bot$, $\conj$, $\disj$, $\neg$, $\imp$ and~$\bimp$,
lcp@104
  1130
along with the rule~\ttindex{refl}.
lcp@104
  1131
lcp@104
  1132
\item[\ttindexbold{HOL_cs}] 
lcp@104
  1133
extends {\tt prop_cs} with the safe rules \ttindex{allI} and~\ttindex{exE}
lcp@104
  1134
and the unsafe rules \ttindex{allE} and~\ttindex{exI}, as well as rules for
lcp@104
  1135
unique existence.  Search using this is incomplete since quantified
lcp@104
  1136
formulae are used at most once.
lcp@104
  1137
lcp@104
  1138
\item[\ttindexbold{HOL_dup_cs}] 
lcp@104
  1139
extends {\tt prop_cs} with the safe rules \ttindex{allI} and~\ttindex{exE}
lcp@104
  1140
and the unsafe rules \ttindex{all_dupE} and~\ttindex{exCI}, as well as
lcp@104
  1141
rules for unique existence.  Search using this is complete --- quantified
lcp@104
  1142
formulae may be duplicated --- but frequently fails to terminate.  It is
lcp@104
  1143
generally unsuitable for depth-first search.
lcp@104
  1144
lcp@104
  1145
\item[\ttindexbold{set_cs}] 
lcp@104
  1146
extends {\tt HOL_cs} with rules for the bounded quantifiers, subsets,
lcp@104
  1147
comprehensions, unions/intersections, complements, finite setes, images and
lcp@104
  1148
ranges.
lcp@104
  1149
\end{description}
lcp@104
  1150
\noindent
lcp@104
  1151
See the {\em Reference Manual} for more discussion of classical proof
lcp@104
  1152
methods.
lcp@104
  1153
lcp@104
  1154
lcp@111
  1155
\section{The examples directories}
lcp@111
  1156
Directory {\tt Subst} contains Martin Coen's mechanization of a theory of
lcp@111
  1157
substitutions and unifiers.  It is based on Paulson's previous
lcp@114
  1158
mechanization in {\LCF}~\cite{paulson85} of Manna and Waldinger's
lcp@111
  1159
theory~\cite{mw81}. 
lcp@111
  1160
lcp@111
  1161
Directory {\tt ex} contains other examples and experimental proofs in
lcp@111
  1162
{\HOL}.  Here is an overview of the more interesting files.
lcp@104
  1163
\begin{description}
lcp@287
  1164
\item[{\tt HOL/ex/meson.ML}]
lcp@104
  1165
contains an experimental implementation of the MESON proof procedure,
lcp@104
  1166
inspired by Plaisted~\cite{plaisted90}.  It is much more powerful than
lcp@104
  1167
Isabelle's classical module.  
lcp@104
  1168
lcp@287
  1169
\item[{\tt HOL/ex/mesontest.ML}]
lcp@104
  1170
contains test data for the MESON proof procedure.
lcp@104
  1171
lcp@287
  1172
\item[{\tt HOL/ex/set.ML}] 
lcp@287
  1173
  proves Cantor's Theorem, which is presented below, and the
lcp@287
  1174
  Schr\"oder-Bernstein Theorem.
lcp@104
  1175
lcp@287
  1176
\item[{\tt HOL/ex/pl.ML}]
lcp@104
  1177
proves the soundness and completeness of classical propositional logic,
lcp@104
  1178
given a truth table semantics.  The only connective is $\imp$.  A
lcp@104
  1179
Hilbert-style axiom system is specified, and its set of theorems defined
lcp@104
  1180
inductively.
lcp@104
  1181
lcp@287
  1182
\item[{\tt HOL/ex/term.ML}] 
lcp@111
  1183
  contains proofs about an experimental recursive type definition;
lcp@111
  1184
  the recursion goes through the type constructor~$list$.
lcp@104
  1185
lcp@287
  1186
\item[{\tt HOL/ex/simult.ML}]
lcp@104
  1187
defines primitives for solving mutually recursive equations over sets.
lcp@104
  1188
It constructs sets of trees and forests as an example, including induction
lcp@104
  1189
and recursion rules that handle the mutual recursion.
lcp@111
  1190
lcp@287
  1191
\item[{\tt HOL/ex/mt.ML}]
lcp@111
  1192
contains Jacob Frost's formalization~\cite{frost93} of a co-induction
lcp@111
  1193
example by Milner and Tofte~\cite{milner-coind}.
lcp@104
  1194
\end{description}
lcp@104
  1195
lcp@104
  1196
lcp@104
  1197
\section{Example: deriving the conjunction rules}
lcp@104
  1198
{\HOL} comes with a body of derived rules, ranging from simple properties
lcp@104
  1199
of the logical constants and set theory to well-founded recursion.  Many of
lcp@104
  1200
them are worth studying.
lcp@104
  1201
lcp@104
  1202
Deriving natural deduction rules for the logical constants from their
lcp@104
  1203
definitions is an archetypal example of higher-order reasoning.  Let us
lcp@104
  1204
verify two conjunction rules:
lcp@104
  1205
\[ \infer[({\conj}I)]{P\conj Q}{P & Q} \qquad\qquad
lcp@104
  1206
   \infer[({\conj}E1)]{P}{P\conj Q}  
lcp@104
  1207
\]
lcp@104
  1208
lcp@104
  1209
\subsection{The introduction rule}
lcp@104
  1210
We begin by stating the rule as the goal.  The list of premises $[P,Q]$ is
lcp@104
  1211
bound to the {\ML} variable~{\tt prems}.
lcp@104
  1212
\begin{ttbox}
lcp@104
  1213
val prems = goal HOL.thy "[| P; Q |] ==> P&Q";
lcp@104
  1214
{\out Level 0}
lcp@104
  1215
{\out P & Q}
lcp@104
  1216
{\out  1. P & Q}
lcp@111
  1217
{\out val prems = ["P [P]",  "Q [Q]"] : thm list}
lcp@104
  1218
\end{ttbox}
lcp@104
  1219
The next step is to unfold the definition of conjunction.  But
lcp@104
  1220
\ttindex{and_def} uses {\HOL}'s internal equality, so
lcp@104
  1221
\ttindex{rewrite_goals_tac} is unsuitable.
lcp@104
  1222
Instead, we perform substitution using the rule \ttindex{ssubst}:
lcp@104
  1223
\begin{ttbox}
lcp@104
  1224
by (resolve_tac [and_def RS ssubst] 1);
lcp@104
  1225
{\out Level 1}
lcp@104
  1226
{\out P & Q}
lcp@104
  1227
{\out  1. ! R. (P --> Q --> R) --> R}
lcp@104
  1228
\end{ttbox}
lcp@104
  1229
We now apply $(\forall I)$ and $({\imp}I)$:
lcp@104
  1230
\begin{ttbox}
lcp@104
  1231
by (resolve_tac [allI] 1);
lcp@104
  1232
{\out Level 2}
lcp@104
  1233
{\out P & Q}
lcp@104
  1234
{\out  1. !!R. (P --> Q --> R) --> R}
lcp@287
  1235
\ttbreak
lcp@104
  1236
by (resolve_tac [impI] 1);
lcp@104
  1237
{\out Level 3}
lcp@104
  1238
{\out P & Q}
lcp@104
  1239
{\out  1. !!R. P --> Q --> R ==> R}
lcp@104
  1240
\end{ttbox}
lcp@104
  1241
The assumption is a nested implication, which may be eliminated
lcp@104
  1242
using~\ttindex{mp} resolved with itself.  Elim-resolution, here, performs
lcp@104
  1243
backwards chaining.  More straightforward would be to use~\ttindex{impE}
lcp@104
  1244
twice.
lcp@104
  1245
\index{*RS}
lcp@104
  1246
\begin{ttbox}
lcp@104
  1247
by (eresolve_tac [mp RS mp] 1);
lcp@104
  1248
{\out Level 4}
lcp@104
  1249
{\out P & Q}
lcp@104
  1250
{\out  1. !!R. P}
lcp@104
  1251
{\out  2. !!R. Q}
lcp@104
  1252
\end{ttbox}
lcp@104
  1253
These two subgoals are simply the premises:
lcp@104
  1254
\begin{ttbox}
lcp@104
  1255
by (REPEAT (resolve_tac prems 1));
lcp@104
  1256
{\out Level 5}
lcp@104
  1257
{\out P & Q}
lcp@104
  1258
{\out No subgoals!}
lcp@104
  1259
\end{ttbox}
lcp@104
  1260
lcp@104
  1261
lcp@104
  1262
\subsection{The elimination rule}
lcp@104
  1263
Again, we bind the list of premises (in this case $[P\conj Q]$)
lcp@104
  1264
to~{\tt prems}.
lcp@104
  1265
\begin{ttbox}
lcp@104
  1266
val prems = goal HOL.thy "[| P & Q |] ==> P";
lcp@104
  1267
{\out Level 0}
lcp@104
  1268
{\out P}
lcp@104
  1269
{\out  1. P}
lcp@111
  1270
{\out val prems = ["P & Q  [P & Q]"] : thm list}
lcp@104
  1271
\end{ttbox}
lcp@104
  1272
Working with premises that involve defined constants can be tricky.  We
lcp@104
  1273
must expand the definition of conjunction in the meta-assumption $P\conj
lcp@104
  1274
Q$.  The rule \ttindex{subst} performs substitution in forward proofs.
lcp@287
  1275
We get {\it two\/} resolvents since the vacuous substitution is valid:
lcp@104
  1276
\begin{ttbox}
lcp@104
  1277
prems RL [and_def RS subst];
lcp@104
  1278
{\out val it = ["! R. (P --> Q --> R) --> R  [P & Q]",}
lcp@104
  1279
{\out           "P & Q  [P & Q]"] : thm list}
lcp@104
  1280
\end{ttbox}
lcp@104
  1281
By applying $(\forall E)$ and $({\imp}E)$ to the resolvents, we dispose of
lcp@287
  1282
the vacuous one and put the other into a convenient form:\footnote {Why use
lcp@287
  1283
  {\tt [spec] RL [mp]} instead of {\tt [spec RS mp]} to join the rules?  In
lcp@287
  1284
  higher-order logic, {\tt spec RS mp} fails because the resolution yields
lcp@287
  1285
  two results, namely ${\List{\forall x.x; P}\Imp Q}$ and ${\List{\forall
lcp@287
  1286
      x.P(x)\imp Q(x); P(x)}\Imp Q(x)}$.  In first-order logic, the
lcp@287
  1287
  resolution yields only the latter result because $\forall x.x$ is not a
lcp@287
  1288
  first-order formula; in fact, it is equivalent to falsity.} \index{*RL}
lcp@104
  1289
\begin{ttbox}
lcp@104
  1290
prems RL [and_def RS subst] RL [spec] RL [mp];
lcp@104
  1291
{\out val it = ["P --> Q --> ?Q ==> ?Q  [P & Q]"] : thm list}
lcp@104
  1292
\end{ttbox}
lcp@104
  1293
This is a list containing a single rule, which is directly applicable to
lcp@104
  1294
our goal:
lcp@104
  1295
\begin{ttbox}
lcp@104
  1296
by (resolve_tac it 1);
lcp@104
  1297
{\out Level 1}
lcp@104
  1298
{\out P}
lcp@104
  1299
{\out  1. P --> Q --> P}
lcp@104
  1300
\end{ttbox}
lcp@104
  1301
The subgoal is a trivial implication.  Recall that \ttindex{ares_tac} is a
lcp@104
  1302
combination of \ttindex{assume_tac} and \ttindex{resolve_tac}.
lcp@104
  1303
\begin{ttbox}
lcp@104
  1304
by (REPEAT (ares_tac [impI] 1));
lcp@104
  1305
{\out Level 2}
lcp@104
  1306
{\out P}
lcp@104
  1307
{\out No subgoals!}
lcp@104
  1308
\end{ttbox}
lcp@104
  1309
lcp@104
  1310
lcp@104
  1311
\section{Example: Cantor's Theorem}
lcp@104
  1312
Cantor's Theorem states that every set has more subsets than it has
lcp@104
  1313
elements.  It has become a favourite example in higher-order logic since
lcp@104
  1314
it is so easily expressed:
lcp@104
  1315
\[  \forall f::[\alpha,\alpha]\To bool. \exists S::\alpha\To bool.
lcp@104
  1316
    \forall x::\alpha. f(x) \not= S 
lcp@104
  1317
\] 
lcp@104
  1318
Viewing types as sets, $\alpha\To bool$ represents the powerset
lcp@104
  1319
of~$\alpha$.  This version states that for every function from $\alpha$ to
lcp@104
  1320
its powerset, some subset is outside its range.
lcp@104
  1321
The Isabelle proof uses {\HOL}'s set theory, with the type $\alpha\,set$ and
lcp@104
  1322
the operator \ttindex{range}.  Since it avoids quantification, we may
lcp@104
  1323
inspect the subset found by the proof.
lcp@104
  1324
\begin{ttbox}
lcp@104
  1325
goal Set.thy "~ ?S : range(f :: 'a=>'a set)";
lcp@104
  1326
{\out Level 0}
lcp@104
  1327
{\out ~ ?S : range(f)}
lcp@104
  1328
{\out  1. ~ ?S : range(f)}
lcp@104
  1329
\end{ttbox}
lcp@104
  1330
The first two steps are routine.  The rule \ttindex{rangeE} reasons that,
lcp@104
  1331
since $\Var{S}\in range(f)$, we have $\Var{S}=f(x)$ for some~$x$.
lcp@104
  1332
\begin{ttbox}
lcp@104
  1333
by (resolve_tac [notI] 1);
lcp@104
  1334
{\out Level 1}
lcp@104
  1335
{\out ~ ?S : range(f)}
lcp@104
  1336
{\out  1. ?S : range(f) ==> False}
lcp@287
  1337
\ttbreak
lcp@104
  1338
by (eresolve_tac [rangeE] 1);
lcp@104
  1339
{\out Level 2}
lcp@104
  1340
{\out ~ ?S : range(f)}
lcp@104
  1341
{\out  1. !!x. ?S = f(x) ==> False}
lcp@104
  1342
\end{ttbox}
lcp@104
  1343
Next, we apply \ttindex{equalityCE}, reasoning that since $\Var{S}=f(x)$,
lcp@104
  1344
we have $\Var{c}\in \Var{S}$ if and only if $\Var{c}\in f(x)$ for
lcp@104
  1345
any~$\Var{c}$.
lcp@104
  1346
\begin{ttbox}
lcp@104
  1347
by (eresolve_tac [equalityCE] 1);
lcp@104
  1348
{\out Level 3}
lcp@104
  1349
{\out ~ ?S : range(f)}
lcp@104
  1350
{\out  1. !!x. [| ?c3(x) : ?S; ?c3(x) : f(x) |] ==> False}
lcp@104
  1351
{\out  2. !!x. [| ~ ?c3(x) : ?S; ~ ?c3(x) : f(x) |] ==> False}
lcp@104
  1352
\end{ttbox}
lcp@104
  1353
Now we use a bit of creativity.  Suppose that $\Var{S}$ has the form of a
lcp@104
  1354
comprehension.  Then $\Var{c}\in\{x.\Var{P}(x)\}$ implies
lcp@104
  1355
$\Var{P}(\Var{c})\}$.\index{*CollectD}
lcp@104
  1356
\begin{ttbox}
lcp@104
  1357
by (dresolve_tac [CollectD] 1);
lcp@104
  1358
{\out Level 4}
lcp@104
  1359
{\out ~ \{x. ?P7(x)\} : range(f)}
lcp@104
  1360
{\out  1. !!x. [| ?c3(x) : f(x); ?P7(?c3(x)) |] ==> False}
lcp@104
  1361
{\out  2. !!x. [| ~ ?c3(x) : \{x. ?P7(x)\}; ~ ?c3(x) : f(x) |] ==> False}
lcp@104
  1362
\end{ttbox}
lcp@104
  1363
Forcing a contradiction between the two assumptions of subgoal~1 completes
lcp@287
  1364
the instantiation of~$S$.  It is now the set $\{x. x\not\in f(x)\}$, the
lcp@287
  1365
standard diagonal construction.
lcp@104
  1366
\begin{ttbox}
lcp@104
  1367
by (contr_tac 1);
lcp@104
  1368
{\out Level 5}
lcp@104
  1369
{\out ~ \{x. ~ x : f(x)\} : range(f)}
lcp@104
  1370
{\out  1. !!x. [| ~ x : \{x. ~ x : f(x)\}; ~ x : f(x) |] ==> False}
lcp@104
  1371
\end{ttbox}
lcp@104
  1372
The rest should be easy.  To apply \ttindex{CollectI} to the negated
lcp@104
  1373
assumption, we employ \ttindex{swap_res_tac}:
lcp@104
  1374
\begin{ttbox}
lcp@104
  1375
by (swap_res_tac [CollectI] 1);
lcp@104
  1376
{\out Level 6}
lcp@104
  1377
{\out ~ \{x. ~ x : f(x)\} : range(f)}
lcp@104
  1378
{\out  1. !!x. [| ~ x : f(x); ~ False |] ==> ~ x : f(x)}
lcp@287
  1379
\ttbreak
lcp@104
  1380
by (assume_tac 1);
lcp@104
  1381
{\out Level 7}
lcp@104
  1382
{\out ~ \{x. ~ x : f(x)\} : range(f)}
lcp@104
  1383
{\out No subgoals!}
lcp@104
  1384
\end{ttbox}
lcp@104
  1385
How much creativity is required?  As it happens, Isabelle can prove this
lcp@104
  1386
theorem automatically.  The classical set \ttindex{set_cs} contains rules
lcp@104
  1387
for most of the constructs of {\HOL}'s set theory.  We augment it with
lcp@104
  1388
\ttindex{equalityCE} --- set equalities are not broken up by default ---
lcp@104
  1389
and apply best-first search.  Depth-first search would diverge, but
lcp@104
  1390
best-first search successfully navigates through the large search space.
lcp@104
  1391
\begin{ttbox}
lcp@104
  1392
choplev 0;
lcp@104
  1393
{\out Level 0}
lcp@104
  1394
{\out ~ ?S : range(f)}
lcp@104
  1395
{\out  1. ~ ?S : range(f)}
lcp@287
  1396
\ttbreak
lcp@104
  1397
by (best_tac (set_cs addSEs [equalityCE]) 1);
lcp@104
  1398
{\out Level 1}
lcp@104
  1399
{\out ~ \{x. ~ x : f(x)\} : range(f)}
lcp@104
  1400
{\out No subgoals!}
lcp@104
  1401
\end{ttbox}