3 \index{higher-order logic|(} |
3 \index{higher-order logic|(} |
4 \index{HOL system@{\sc hol} system} |
4 \index{HOL system@{\sc hol} system} |
5 |
5 |
6 The theory~\thydx{HOL} implements higher-order logic. It is based on |
6 The theory~\thydx{HOL} implements higher-order logic. It is based on |
7 Gordon's~{\sc hol} system~\cite{mgordon-hol}, which itself is based on |
7 Gordon's~{\sc hol} system~\cite{mgordon-hol}, which itself is based on |
8 Church's original paper~\cite{church40}. Andrews's |
8 Church's original paper~\cite{church40}. Andrews's book~\cite{andrews86} is a |
9 book~\cite{andrews86} is a full description of the original |
9 full description of the original Church-style higher-order logic. Experience |
10 Church-style higher-order logic. Experience with the {\sc hol} system |
10 with the {\sc hol} system has demonstrated that higher-order logic is widely |
11 has demonstrated that higher-order logic is widely applicable in many |
11 applicable in many areas of mathematics and computer science, not just |
12 areas of mathematics and computer science, not just hardware |
12 hardware verification, {\sc hol}'s original \textit{raison d'{\^e}tre\/}. It |
13 verification, {\sc hol}'s original \textit{raison d'{\^e}tre\/}. It is |
13 is weaker than ZF set theory but for most applications this does not matter. |
14 weaker than {\ZF} set theory but for most applications this does not |
14 If you prefer {\ML} to Lisp, you will probably prefer HOL to~ZF. |
15 matter. If you prefer {\ML} to Lisp, you will probably prefer \HOL\ |
15 |
16 to~{\ZF}. |
16 The syntax of HOL\footnote{Earlier versions of Isabelle's HOL used a different |
17 |
17 syntax. Ancient releases of Isabelle included still another version of~HOL, |
18 The syntax of \HOL\footnote{Earlier versions of Isabelle's \HOL\ used a |
18 with explicit type inference rules~\cite{paulson-COLOG}. This version no |
19 different syntax. Ancient releases of Isabelle included still another version |
19 longer exists, but \thydx{ZF} supports a similar style of reasoning.} |
20 of~\HOL, with explicit type inference rules~\cite{paulson-COLOG}. This |
20 follows $\lambda$-calculus and functional programming. Function application |
21 version no longer exists, but \thydx{ZF} supports a similar style of |
21 is curried. To apply the function~$f$ of type $\tau@1\To\tau@2\To\tau@3$ to |
22 reasoning.} follows $\lambda$-calculus and functional programming. Function |
22 the arguments~$a$ and~$b$ in HOL, you simply write $f\,a\,b$. There is no |
23 application is curried. To apply the function~$f$ of type |
23 `apply' operator as in \thydx{ZF}. Note that $f(a,b)$ means ``$f$ applied to |
24 $\tau@1\To\tau@2\To\tau@3$ to the arguments~$a$ and~$b$ in \HOL, you simply |
24 the pair $(a,b)$'' in HOL. We write ordered pairs as $(a,b)$, not $\langle |
25 write $f\,a\,b$. There is no `apply' operator as in \thydx{ZF}. Note that |
25 a,b\rangle$ as in ZF. |
26 $f(a,b)$ means ``$f$ applied to the pair $(a,b)$'' in \HOL. We write ordered |
26 |
27 pairs as $(a,b)$, not $\langle a,b\rangle$ as in {\ZF}. |
27 HOL has a distinct feel, compared with ZF and CTT. It identifies object-level |
28 |
28 types with meta-level types, taking advantage of Isabelle's built-in |
29 \HOL\ has a distinct feel, compared with {\ZF} and {\CTT}. It |
29 type-checker. It identifies object-level functions with meta-level functions, |
30 identifies object-level types with meta-level types, taking advantage of |
30 so it uses Isabelle's operations for abstraction and application. |
31 Isabelle's built-in type-checker. It identifies object-level functions |
31 |
32 with meta-level functions, so it uses Isabelle's operations for abstraction |
32 These identifications allow Isabelle to support HOL particularly nicely, but |
33 and application. |
33 they also mean that HOL requires more sophistication from the user --- in |
34 |
34 particular, an understanding of Isabelle's type system. Beginners should work |
35 These identifications allow Isabelle to support \HOL\ particularly |
35 with \texttt{show_types} (or even \texttt{show_sorts}) set to \texttt{true}. |
36 nicely, but they also mean that \HOL\ requires more sophistication |
|
37 from the user --- in particular, an understanding of Isabelle's type |
|
38 system. Beginners should work with \texttt{show_types} (or even |
|
39 \texttt{show_sorts}) set to \texttt{true}. |
|
40 % Gain experience by |
|
41 %working in first-order logic before attempting to use higher-order logic. |
|
42 %This chapter assumes familiarity with~{\FOL{}}. |
|
43 |
36 |
44 |
37 |
45 \begin{figure} |
38 \begin{figure} |
46 \begin{constants} |
39 \begin{constants} |
47 \it name &\it meta-type & \it description \\ |
40 \it name &\it meta-type & \it description \\ |
133 binders), while Fig.\ts\ref{hol-grammar} presents the grammar of |
126 binders), while Fig.\ts\ref{hol-grammar} presents the grammar of |
134 higher-order logic. Note that $a$\verb|~=|$b$ is translated to |
127 higher-order logic. Note that $a$\verb|~=|$b$ is translated to |
135 $\lnot(a=b)$. |
128 $\lnot(a=b)$. |
136 |
129 |
137 \begin{warn} |
130 \begin{warn} |
138 \HOL\ has no if-and-only-if connective; logical equivalence is expressed |
131 HOL has no if-and-only-if connective; logical equivalence is expressed using |
139 using equality. But equality has a high priority, as befitting a |
132 equality. But equality has a high priority, as befitting a relation, while |
140 relation, while if-and-only-if typically has the lowest priority. Thus, |
133 if-and-only-if typically has the lowest priority. Thus, $\lnot\lnot P=P$ |
141 $\lnot\lnot P=P$ abbreviates $\lnot\lnot (P=P)$ and not $(\lnot\lnot P)=P$. |
134 abbreviates $\lnot\lnot (P=P)$ and not $(\lnot\lnot P)=P$. When using $=$ |
142 When using $=$ to mean logical equivalence, enclose both operands in |
135 to mean logical equivalence, enclose both operands in parentheses. |
143 parentheses. |
|
144 \end{warn} |
136 \end{warn} |
145 |
137 |
146 \subsection{Types and overloading} |
138 \subsection{Types and overloading} |
147 The universal type class of higher-order terms is called~\cldx{term}. |
139 The universal type class of higher-order terms is called~\cldx{term}. |
148 By default, explicit type variables have class \cldx{term}. In |
140 By default, explicit type variables have class \cldx{term}. In |
154 function types, is overloaded with arity {\tt(term,\thinspace |
146 function types, is overloaded with arity {\tt(term,\thinspace |
155 term)\thinspace term}. Thus, $\sigma\To\tau$ belongs to class~{\tt |
147 term)\thinspace term}. Thus, $\sigma\To\tau$ belongs to class~{\tt |
156 term} if $\sigma$ and~$\tau$ do, allowing quantification over |
148 term} if $\sigma$ and~$\tau$ do, allowing quantification over |
157 functions. |
149 functions. |
158 |
150 |
159 \HOL\ allows new types to be declared as subsets of existing types; |
151 HOL allows new types to be declared as subsets of existing types; |
160 see~{\S}\ref{sec:HOL:Types}. ML-like datatypes can also be declared; see |
152 see~{\S}\ref{sec:HOL:Types}. ML-like datatypes can also be declared; see |
161 ~{\S}\ref{sec:HOL:datatype}. |
153 ~{\S}\ref{sec:HOL:datatype}. |
162 |
154 |
163 Several syntactic type classes --- \cldx{plus}, \cldx{minus}, |
155 Several syntactic type classes --- \cldx{plus}, \cldx{minus}, |
164 \cldx{times} and |
156 \cldx{times} and |
216 \end{warn} |
208 \end{warn} |
217 |
209 |
218 |
210 |
219 \subsection{Binders} |
211 \subsection{Binders} |
220 |
212 |
221 Hilbert's {\bf description} operator~$\varepsilon x. P[x]$ stands for |
213 Hilbert's {\bf description} operator~$\varepsilon x. P[x]$ stands for some~$x$ |
222 some~$x$ satisfying~$P$, if such exists. Since all terms in \HOL\ |
214 satisfying~$P$, if such exists. Since all terms in HOL denote something, a |
223 denote something, a description is always meaningful, but we do not |
215 description is always meaningful, but we do not know its value unless $P$ |
224 know its value unless $P$ defines it uniquely. We may write |
216 defines it uniquely. We may write descriptions as \cdx{Eps}($\lambda x. |
225 descriptions as \cdx{Eps}($\lambda x. P[x]$) or use the syntax |
217 P[x]$) or use the syntax \hbox{\tt SOME~$x$.~$P[x]$}. |
226 \hbox{\tt SOME~$x$.~$P[x]$}. |
|
227 |
218 |
228 Existential quantification is defined by |
219 Existential quantification is defined by |
229 \[ \exists x. P~x \;\equiv\; P(\varepsilon x. P~x). \] |
220 \[ \exists x. P~x \;\equiv\; P(\varepsilon x. P~x). \] |
230 The unique existence quantifier, $\exists!x. P$, is defined in terms |
221 The unique existence quantifier, $\exists!x. P$, is defined in terms |
231 of~$\exists$ and~$\forall$. An Isabelle binder, it admits nested |
222 of~$\exists$ and~$\forall$. An Isabelle binder, it admits nested |
270 Local abbreviations can be introduced by a \texttt{let} construct whose |
261 Local abbreviations can be introduced by a \texttt{let} construct whose |
271 syntax appears in Fig.\ts\ref{hol-grammar}. Internally it is translated into |
262 syntax appears in Fig.\ts\ref{hol-grammar}. Internally it is translated into |
272 the constant~\cdx{Let}. It can be expanded by rewriting with its |
263 the constant~\cdx{Let}. It can be expanded by rewriting with its |
273 definition, \tdx{Let_def}. |
264 definition, \tdx{Let_def}. |
274 |
265 |
275 \HOL\ also defines the basic syntax |
266 HOL also defines the basic syntax |
276 \[\dquotes"case"~e~"of"~c@1~"=>"~e@1~"|" \dots "|"~c@n~"=>"~e@n\] |
267 \[\dquotes"case"~e~"of"~c@1~"=>"~e@1~"|" \dots "|"~c@n~"=>"~e@n\] |
277 as a uniform means of expressing \texttt{case} constructs. Therefore \texttt{case} |
268 as a uniform means of expressing \texttt{case} constructs. Therefore \texttt{case} |
278 and \sdx{of} are reserved words. Initially, this is mere syntax and has no |
269 and \sdx{of} are reserved words. Initially, this is mere syntax and has no |
279 logical meaning. By declaring translations, you can cause instances of the |
270 logical meaning. By declaring translations, you can cause instances of the |
280 \texttt{case} construct to denote applications of particular case operators. |
271 \texttt{case} construct to denote applications of particular case operators. |
303 \tdx{True_or_False} (P=True) | (P=False) |
294 \tdx{True_or_False} (P=True) | (P=False) |
304 \end{ttbox} |
295 \end{ttbox} |
305 \caption{The \texttt{HOL} rules} \label{hol-rules} |
296 \caption{The \texttt{HOL} rules} \label{hol-rules} |
306 \end{figure} |
297 \end{figure} |
307 |
298 |
308 Figure~\ref{hol-rules} shows the primitive inference rules of~\HOL{}, |
299 Figure~\ref{hol-rules} shows the primitive inference rules of~HOL, with |
309 with their~{\ML} names. Some of the rules deserve additional |
300 their~{\ML} names. Some of the rules deserve additional comments: |
310 comments: |
|
311 \begin{ttdescription} |
301 \begin{ttdescription} |
312 \item[\tdx{ext}] expresses extensionality of functions. |
302 \item[\tdx{ext}] expresses extensionality of functions. |
313 \item[\tdx{iff}] asserts that logically equivalent formulae are |
303 \item[\tdx{iff}] asserts that logically equivalent formulae are |
314 equal. |
304 equal. |
315 \item[\tdx{selectI}] gives the defining property of the Hilbert |
305 \item[\tdx{selectI}] gives the defining property of the Hilbert |
340 \end{ttbox} |
330 \end{ttbox} |
341 \caption{The \texttt{HOL} definitions} \label{hol-defs} |
331 \caption{The \texttt{HOL} definitions} \label{hol-defs} |
342 \end{figure} |
332 \end{figure} |
343 |
333 |
344 |
334 |
345 \HOL{} follows standard practice in higher-order logic: only a few |
335 HOL follows standard practice in higher-order logic: only a few connectives |
346 connectives are taken as primitive, with the remainder defined obscurely |
336 are taken as primitive, with the remainder defined obscurely |
347 (Fig.\ts\ref{hol-defs}). Gordon's {\sc hol} system expresses the |
337 (Fig.\ts\ref{hol-defs}). Gordon's {\sc hol} system expresses the |
348 corresponding definitions \cite[page~270]{mgordon-hol} using |
338 corresponding definitions \cite[page~270]{mgordon-hol} using |
349 object-equality~({\tt=}), which is possible because equality in |
339 object-equality~({\tt=}), which is possible because equality in higher-order |
350 higher-order logic may equate formulae and even functions over formulae. |
340 logic may equate formulae and even functions over formulae. But theory~HOL, |
351 But theory~\HOL{}, like all other Isabelle theories, uses |
341 like all other Isabelle theories, uses meta-equality~({\tt==}) for |
352 meta-equality~({\tt==}) for definitions. |
342 definitions. |
353 \begin{warn} |
343 \begin{warn} |
354 The definitions above should never be expanded and are shown for completeness |
344 The definitions above should never be expanded and are shown for completeness |
355 only. Instead users should reason in terms of the derived rules shown below |
345 only. Instead users should reason in terms of the derived rules shown below |
356 or, better still, using high-level tactics |
346 or, better still, using high-level tactics |
357 (see~{\S}\ref{sec:HOL:generic-packages}). |
347 (see~{\S}\ref{sec:HOL:generic-packages}). |
582 |
572 |
583 |
573 |
584 \section{A formulation of set theory} |
574 \section{A formulation of set theory} |
585 Historically, higher-order logic gives a foundation for Russell and |
575 Historically, higher-order logic gives a foundation for Russell and |
586 Whitehead's theory of classes. Let us use modern terminology and call them |
576 Whitehead's theory of classes. Let us use modern terminology and call them |
587 {\bf sets}, but note that these sets are distinct from those of {\ZF} set |
577 {\bf sets}, but note that these sets are distinct from those of ZF set theory, |
588 theory, and behave more like {\ZF} classes. |
578 and behave more like ZF classes. |
589 \begin{itemize} |
579 \begin{itemize} |
590 \item |
580 \item |
591 Sets are given by predicates over some type~$\sigma$. Types serve to |
581 Sets are given by predicates over some type~$\sigma$. Types serve to |
592 define universes for sets, but type-checking is still significant. |
582 define universes for sets, but type-checking is still significant. |
593 \item |
583 \item |
595 may be defined by absolute comprehension. |
585 may be defined by absolute comprehension. |
596 \item |
586 \item |
597 Although sets may contain other sets as elements, the containing set must |
587 Although sets may contain other sets as elements, the containing set must |
598 have a more complex type. |
588 have a more complex type. |
599 \end{itemize} |
589 \end{itemize} |
600 Finite unions and intersections have the same behaviour in \HOL\ as they |
590 Finite unions and intersections have the same behaviour in HOL as they do |
601 do in~{\ZF}. In \HOL\ the intersection of the empty set is well-defined, |
591 in~ZF. In HOL the intersection of the empty set is well-defined, denoting the |
602 denoting the universal set for the given type. |
592 universal set for the given type. |
603 |
593 |
604 \subsection{Syntax of set theory}\index{*set type} |
594 \subsection{Syntax of set theory}\index{*set type} |
605 \HOL's set theory is called \thydx{Set}. The type $\alpha\,set$ is |
595 HOL's set theory is called \thydx{Set}. The type $\alpha\,set$ is essentially |
606 essentially the same as $\alpha\To bool$. The new type is defined for |
596 the same as $\alpha\To bool$. The new type is defined for clarity and to |
607 clarity and to avoid complications involving function types in unification. |
597 avoid complications involving function types in unification. The isomorphisms |
608 The isomorphisms between the two types are declared explicitly. They are |
598 between the two types are declared explicitly. They are very natural: |
609 very natural: \texttt{Collect} maps $\alpha\To bool$ to $\alpha\,set$, while |
599 \texttt{Collect} maps $\alpha\To bool$ to $\alpha\,set$, while \hbox{\tt op :} |
610 \hbox{\tt op :} maps in the other direction (ignoring argument order). |
600 maps in the other direction (ignoring argument order). |
611 |
601 |
612 Figure~\ref{hol-set-syntax} lists the constants, infixes, and syntax |
602 Figure~\ref{hol-set-syntax} lists the constants, infixes, and syntax |
613 translations. Figure~\ref{hol-set-syntax2} presents the grammar of the new |
603 translations. Figure~\ref{hol-set-syntax2} presents the grammar of the new |
614 constructs. Infix operators include union and intersection ($A\un B$ |
604 constructs. Infix operators include union and intersection ($A\un B$ |
615 and $A\int B$), the subset and membership relations, and the image |
605 and $A\int B$), the subset and membership relations, and the image |
621 \begin{eqnarray*} |
611 \begin{eqnarray*} |
622 \{a, b, c\} & \equiv & |
612 \{a, b, c\} & \equiv & |
623 \texttt{insert} \, a \, ({\tt insert} \, b \, ({\tt insert} \, c \, \{\})) |
613 \texttt{insert} \, a \, ({\tt insert} \, b \, ({\tt insert} \, c \, \{\})) |
624 \end{eqnarray*} |
614 \end{eqnarray*} |
625 |
615 |
626 The set \hbox{\tt{\ttlbrace}$x$.\ $P[x]${\ttrbrace}} consists of all $x$ (of suitable type) |
616 The set \hbox{\tt{\ttlbrace}$x$.\ $P[x]${\ttrbrace}} consists of all $x$ (of |
627 that satisfy~$P[x]$, where $P[x]$ is a formula that may contain free |
617 suitable type) that satisfy~$P[x]$, where $P[x]$ is a formula that may contain |
628 occurrences of~$x$. This syntax expands to \cdx{Collect}$(\lambda |
618 free occurrences of~$x$. This syntax expands to \cdx{Collect}$(\lambda x. |
629 x. P[x])$. It defines sets by absolute comprehension, which is impossible |
619 P[x])$. It defines sets by absolute comprehension, which is impossible in~ZF; |
630 in~{\ZF}; the type of~$x$ implicitly restricts the comprehension. |
620 the type of~$x$ implicitly restricts the comprehension. |
631 |
621 |
632 The set theory defines two {\bf bounded quantifiers}: |
622 The set theory defines two {\bf bounded quantifiers}: |
633 \begin{eqnarray*} |
623 \begin{eqnarray*} |
634 \forall x\in A. P[x] &\hbox{abbreviates}& \forall x. x\in A\imp P[x] \\ |
624 \forall x\in A. P[x] &\hbox{abbreviates}& \forall x. x\in A\imp P[x] \\ |
635 \exists x\in A. P[x] &\hbox{abbreviates}& \exists x. x\in A\conj P[x] |
625 \exists x\in A. P[x] &\hbox{abbreviates}& \exists x. x\in A\conj P[x] |
865 \caption{Set equalities} \label{hol-equalities} |
855 \caption{Set equalities} \label{hol-equalities} |
866 \end{figure} |
856 \end{figure} |
867 |
857 |
868 |
858 |
869 Figures~\ref{hol-set1} and~\ref{hol-set2} present derived rules. Most are |
859 Figures~\ref{hol-set1} and~\ref{hol-set2} present derived rules. Most are |
870 obvious and resemble rules of Isabelle's {\ZF} set theory. Certain rules, |
860 obvious and resemble rules of Isabelle's ZF set theory. Certain rules, such |
871 such as \tdx{subsetCE}, \tdx{bexCI} and \tdx{UnCI}, |
861 as \tdx{subsetCE}, \tdx{bexCI} and \tdx{UnCI}, are designed for classical |
872 are designed for classical reasoning; the rules \tdx{subsetD}, |
862 reasoning; the rules \tdx{subsetD}, \tdx{bexI}, \tdx{Un1} and~\tdx{Un2} are |
873 \tdx{bexI}, \tdx{Un1} and~\tdx{Un2} are not |
863 not strictly necessary but yield more natural proofs. Similarly, |
874 strictly necessary but yield more natural proofs. Similarly, |
864 \tdx{equalityCE} supports classical reasoning about extensionality, after the |
875 \tdx{equalityCE} supports classical reasoning about extensionality, |
865 fashion of \tdx{iffCE}. See the file \texttt{HOL/Set.ML} for proofs |
876 after the fashion of \tdx{iffCE}. See the file \texttt{HOL/Set.ML} for |
866 pertaining to set theory. |
877 proofs pertaining to set theory. |
|
878 |
867 |
879 Figure~\ref{hol-subset} presents lattice properties of the subset relation. |
868 Figure~\ref{hol-subset} presents lattice properties of the subset relation. |
880 Unions form least upper bounds; non-empty intersections form greatest lower |
869 Unions form least upper bounds; non-empty intersections form greatest lower |
881 bounds. Reasoning directly about subsets often yields clearer proofs than |
870 bounds. Reasoning directly about subsets often yields clearer proofs than |
882 reasoning about the membership relation. See the file \texttt{HOL/subset.ML}. |
871 reasoning about the membership relation. See the file \texttt{HOL/subset.ML}. |
970 |
959 |
971 If $thm$ is a conditional equality, the instantiated condition becomes an |
960 If $thm$ is a conditional equality, the instantiated condition becomes an |
972 additional (first) subgoal. |
961 additional (first) subgoal. |
973 \end{ttdescription} |
962 \end{ttdescription} |
974 |
963 |
975 \HOL{} provides the tactic \ttindex{hyp_subst_tac}, which substitutes |
964 HOL provides the tactic \ttindex{hyp_subst_tac}, which substitutes for an |
976 for an equality throughout a subgoal and its hypotheses. This tactic uses |
965 equality throughout a subgoal and its hypotheses. This tactic uses HOL's |
977 \HOL's general substitution rule. |
966 general substitution rule. |
978 |
967 |
979 \subsubsection{Case splitting} |
968 \subsubsection{Case splitting} |
980 \label{subsec:HOL:case:splitting} |
969 \label{subsec:HOL:case:splitting} |
981 |
970 |
982 \HOL{} also provides convenient means for case splitting during |
971 HOL also provides convenient means for case splitting during rewriting. Goals |
983 rewriting. Goals containing a subterm of the form \texttt{if}~$b$~{\tt |
972 containing a subterm of the form \texttt{if}~$b$~{\tt then\dots else\dots} |
984 then\dots else\dots} often require a case distinction on $b$. This is |
973 often require a case distinction on $b$. This is expressed by the theorem |
985 expressed by the theorem \tdx{split_if}: |
974 \tdx{split_if}: |
986 $$ |
975 $$ |
987 \Var{P}(\mbox{\tt if}~\Var{b}~{\tt then}~\Var{x}~\mbox{\tt else}~\Var{y})~=~ |
976 \Var{P}(\mbox{\tt if}~\Var{b}~{\tt then}~\Var{x}~\mbox{\tt else}~\Var{y})~=~ |
988 ((\Var{b} \to \Var{P}(\Var{x})) \land (\lnot \Var{b} \to \Var{P}(\Var{y}))) |
977 ((\Var{b} \to \Var{P}(\Var{x})) \land (\lnot \Var{b} \to \Var{P}(\Var{y}))) |
989 \eqno{(*)} |
978 \eqno{(*)} |
990 $$ |
979 $$ |
1033 \end{ttbox} |
1022 \end{ttbox} |
1034 for adding splitting rules to, and deleting them from the current simpset. |
1023 for adding splitting rules to, and deleting them from the current simpset. |
1035 |
1024 |
1036 \subsection{Classical reasoning} |
1025 \subsection{Classical reasoning} |
1037 |
1026 |
1038 \HOL\ derives classical introduction rules for $\disj$ and~$\exists$, as |
1027 HOL derives classical introduction rules for $\disj$ and~$\exists$, as well as |
1039 well as classical elimination rules for~$\imp$ and~$\bimp$, and the swap |
1028 classical elimination rules for~$\imp$ and~$\bimp$, and the swap rule; recall |
1040 rule; recall Fig.\ts\ref{hol-lemmas2} above. |
1029 Fig.\ts\ref{hol-lemmas2} above. |
1041 |
1030 |
1042 The classical reasoner is installed. Tactics such as \texttt{Blast_tac} and |
1031 The classical reasoner is installed. Tactics such as \texttt{Blast_tac} and |
1043 {\tt Best_tac} refer to the default claset (\texttt{claset()}), which works |
1032 {\tt Best_tac} refer to the default claset (\texttt{claset()}), which works |
1044 for most purposes. Named clasets include \ttindexbold{prop_cs}, which |
1033 for most purposes. Named clasets include \ttindexbold{prop_cs}, which |
1045 includes the propositional rules, and \ttindexbold{HOL_cs}, which also |
1034 includes the propositional rules, and \ttindexbold{HOL_cs}, which also |
1141 |
1130 |
1142 |
1131 |
1143 |
1132 |
1144 |
1133 |
1145 \section{Types}\label{sec:HOL:Types} |
1134 \section{Types}\label{sec:HOL:Types} |
1146 This section describes \HOL's basic predefined types ($\alpha \times |
1135 This section describes HOL's basic predefined types ($\alpha \times \beta$, |
1147 \beta$, $\alpha + \beta$, $nat$ and $\alpha \; list$) and ways for |
1136 $\alpha + \beta$, $nat$ and $\alpha \; list$) and ways for introducing new |
1148 introducing new types in general. The most important type |
1137 types in general. The most important type construction, the |
1149 construction, the \texttt{datatype}, is treated separately in |
1138 \texttt{datatype}, is treated separately in {\S}\ref{sec:HOL:datatype}. |
1150 {\S}\ref{sec:HOL:datatype}. |
|
1151 |
1139 |
1152 |
1140 |
1153 \subsection{Product and sum types}\index{*"* type}\index{*"+ type} |
1141 \subsection{Product and sum types}\index{*"* type}\index{*"+ type} |
1154 \label{subsec:prod-sum} |
1142 \label{subsec:prod-sum} |
1155 |
1143 |
1405 \end{ttbox} |
1393 \end{ttbox} |
1406 |
1394 |
1407 |
1395 |
1408 \subsection{Numerical types and numerical reasoning} |
1396 \subsection{Numerical types and numerical reasoning} |
1409 |
1397 |
1410 The integers (type \tdx{int}) are also available in \HOL, and the reals (type |
1398 The integers (type \tdx{int}) are also available in HOL, and the reals (type |
1411 \tdx{real}) are available in the logic image \texttt{HOL-Real}. They support |
1399 \tdx{real}) are available in the logic image \texttt{HOL-Real}. They support |
1412 the expected operations of addition (\texttt{+}), subtraction (\texttt{-}) and |
1400 the expected operations of addition (\texttt{+}), subtraction (\texttt{-}) and |
1413 multiplication (\texttt{*}), and much else. Type \tdx{int} provides the |
1401 multiplication (\texttt{*}), and much else. Type \tdx{int} provides the |
1414 \texttt{div} and \texttt{mod} operators, while type \tdx{real} provides real |
1402 \texttt{div} and \texttt{mod} operators, while type \tdx{real} provides real |
1415 division and other operations. Both types belong to class \cldx{linorder}, so |
1403 division and other operations. Both types belong to class \cldx{linorder}, so |
1606 \index{list@{\textit{list}} type|)} |
1594 \index{list@{\textit{list}} type|)} |
1607 |
1595 |
1608 |
1596 |
1609 \subsection{Introducing new types} \label{sec:typedef} |
1597 \subsection{Introducing new types} \label{sec:typedef} |
1610 |
1598 |
1611 The \HOL-methodology dictates that all extensions to a theory should |
1599 The HOL-methodology dictates that all extensions to a theory should be |
1612 be \textbf{definitional}. The type definition mechanism that |
1600 \textbf{definitional}. The type definition mechanism that meets this |
1613 meets this criterion is \ttindex{typedef}. Note that \emph{type synonyms}, |
1601 criterion is \ttindex{typedef}. Note that \emph{type synonyms}, which are |
1614 which are inherited from {\Pure} and described elsewhere, are just |
1602 inherited from Pure and described elsewhere, are just syntactic abbreviations |
1615 syntactic abbreviations that have no logical meaning. |
1603 that have no logical meaning. |
1616 |
1604 |
1617 \begin{warn} |
1605 \begin{warn} |
1618 Types in \HOL\ must be non-empty; otherwise the quantifier rules would be |
1606 Types in HOL must be non-empty; otherwise the quantifier rules would be |
1619 unsound, because $\exists x. x=x$ is a theorem \cite[{\S}7]{paulson-COLOG}. |
1607 unsound, because $\exists x. x=x$ is a theorem \cite[{\S}7]{paulson-COLOG}. |
1620 \end{warn} |
1608 \end{warn} |
1621 A \bfindex{type definition} identifies the new type with a subset of |
1609 A \bfindex{type definition} identifies the new type with a subset of |
1622 an existing type. More precisely, the new type is defined by |
1610 an existing type. More precisely, the new type is defined by |
1623 exhibiting an existing type~$\tau$, a set~$A::\tau\,set$, and a |
1611 exhibiting an existing type~$\tau$, a set~$A::\tau\,set$, and a |
2850 |
2838 |
2851 Each (co)inductive definition adds definitions to the theory and also |
2839 Each (co)inductive definition adds definitions to the theory and also |
2852 proves some theorems. Each definition creates an \ML\ structure, which is a |
2840 proves some theorems. Each definition creates an \ML\ structure, which is a |
2853 substructure of the main theory structure. |
2841 substructure of the main theory structure. |
2854 |
2842 |
2855 This package is related to the \ZF\ one, described in a separate |
2843 This package is related to the ZF one, described in a separate |
2856 paper,% |
2844 paper,% |
2857 \footnote{It appeared in CADE~\cite{paulson-CADE}; a longer version is |
2845 \footnote{It appeared in CADE~\cite{paulson-CADE}; a longer version is |
2858 distributed with Isabelle.} % |
2846 distributed with Isabelle.} % |
2859 which you should refer to in case of difficulties. The package is simpler |
2847 which you should refer to in case of difficulties. The package is simpler |
2860 than \ZF's thanks to \HOL's extra-logical automatic type-checking. The types |
2848 than ZF's thanks to HOL's extra-logical automatic type-checking. The types of |
2861 of the (co)inductive sets determine the domain of the fixedpoint definition, |
2849 the (co)inductive sets determine the domain of the fixedpoint definition, and |
2862 and the package does not have to use inference rules for type-checking. |
2850 the package does not have to use inference rules for type-checking. |
2863 |
2851 |
2864 |
2852 |
2865 \subsection{The result structure} |
2853 \subsection{The result structure} |
2866 Many of the result structure's components have been discussed in the paper; |
2854 Many of the result structure's components have been discussed in the paper; |
2867 others are self-explanatory. |
2855 others are self-explanatory. |
2988 The resulting theory structure contains a substructure, called~\texttt{Fin}. |
2976 The resulting theory structure contains a substructure, called~\texttt{Fin}. |
2989 It contains the \texttt{Fin}$~A$ introduction rules as the list \texttt{Fin.intrs}, |
2977 It contains the \texttt{Fin}$~A$ introduction rules as the list \texttt{Fin.intrs}, |
2990 and also individually as \texttt{Fin.emptyI} and \texttt{Fin.consI}. The induction |
2978 and also individually as \texttt{Fin.emptyI} and \texttt{Fin.consI}. The induction |
2991 rule is \texttt{Fin.induct}. |
2979 rule is \texttt{Fin.induct}. |
2992 |
2980 |
2993 For another example, here is a theory file defining the accessible |
2981 For another example, here is a theory file defining the accessible part of a |
2994 part of a relation. The paper |
2982 relation. The paper \cite{paulson-CADE} discusses a ZF version of this |
2995 \cite{paulson-CADE} discusses a \ZF\ version of this example in more |
2983 example in more detail. |
2996 detail. |
|
2997 \begin{ttbox} |
2984 \begin{ttbox} |
2998 Acc = WF + Inductive + |
2985 Acc = WF + Inductive + |
2999 |
2986 |
3000 consts acc :: "('a * 'a)set => 'a set" (* accessible part *) |
2987 consts acc :: "('a * 'a)set => 'a set" (* accessible part *) |
3001 |
2988 |
3039 |
3026 |
3040 Directory \texttt{HOL/Lambda} contains a formalization of untyped |
3027 Directory \texttt{HOL/Lambda} contains a formalization of untyped |
3041 $\lambda$-calculus in de~Bruijn notation and Church-Rosser proofs for $\beta$ |
3028 $\lambda$-calculus in de~Bruijn notation and Church-Rosser proofs for $\beta$ |
3042 and $\eta$ reduction~\cite{Nipkow-CR}. |
3029 and $\eta$ reduction~\cite{Nipkow-CR}. |
3043 |
3030 |
3044 Directory \texttt{HOL/Subst} contains Martin Coen's mechanization of a theory of |
3031 Directory \texttt{HOL/Subst} contains Martin Coen's mechanization of a theory |
3045 substitutions and unifiers. It is based on Paulson's previous |
3032 of substitutions and unifiers. It is based on Paulson's previous |
3046 mechanisation in {\LCF}~\cite{paulson85} of Manna and Waldinger's |
3033 mechanisation in LCF~\cite{paulson85} of Manna and Waldinger's |
3047 theory~\cite{mw81}. It demonstrates a complicated use of \texttt{recdef}, |
3034 theory~\cite{mw81}. It demonstrates a complicated use of \texttt{recdef}, |
3048 with nested recursion. |
3035 with nested recursion. |
3049 |
3036 |
3050 Directory \texttt{HOL/Induct} presents simple examples of (co)inductive |
3037 Directory \texttt{HOL/Induct} presents simple examples of (co)inductive |
3051 definitions and datatypes. |
3038 definitions and datatypes. |
3052 \begin{itemize} |
3039 \begin{itemize} |
3053 \item Theory \texttt{PropLog} proves the soundness and completeness of |
3040 \item Theory \texttt{PropLog} proves the soundness and completeness of |
3054 classical propositional logic, given a truth table semantics. The only |
3041 classical propositional logic, given a truth table semantics. The only |
3055 connective is $\imp$. A Hilbert-style axiom system is specified, and its |
3042 connective is $\imp$. A Hilbert-style axiom system is specified, and its |
3056 set of theorems defined inductively. A similar proof in \ZF{} is |
3043 set of theorems defined inductively. A similar proof in ZF is described |
3057 described elsewhere~\cite{paulson-set-II}. |
3044 elsewhere~\cite{paulson-set-II}. |
3058 |
3045 |
3059 \item Theory \texttt{Term} defines the datatype \texttt{term}. |
3046 \item Theory \texttt{Term} defines the datatype \texttt{term}. |
3060 |
3047 |
3061 \item Theory \texttt{ABexp} defines arithmetic and boolean expressions |
3048 \item Theory \texttt{ABexp} defines arithmetic and boolean expressions |
3062 as mutually recursive datatypes. |
3049 as mutually recursive datatypes. |
3203 {\out Level 7} |
3190 {\out Level 7} |
3204 {\out {\ttlbrace}x. x ~: f x{\ttrbrace} ~: range f} |
3191 {\out {\ttlbrace}x. x ~: f x{\ttrbrace} ~: range f} |
3205 {\out No subgoals!} |
3192 {\out No subgoals!} |
3206 \end{ttbox} |
3193 \end{ttbox} |
3207 How much creativity is required? As it happens, Isabelle can prove this |
3194 How much creativity is required? As it happens, Isabelle can prove this |
3208 theorem automatically. The default classical set \texttt{claset()} contains rules |
3195 theorem automatically. The default classical set \texttt{claset()} contains |
3209 for most of the constructs of \HOL's set theory. We must augment it with |
3196 rules for most of the constructs of HOL's set theory. We must augment it with |
3210 \tdx{equalityCE} to break up set equalities, and then apply best-first |
3197 \tdx{equalityCE} to break up set equalities, and then apply best-first search. |
3211 search. Depth-first search would diverge, but best-first search |
3198 Depth-first search would diverge, but best-first search successfully navigates |
3212 successfully navigates through the large search space. |
3199 through the large search space. \index{search!best-first} |
3213 \index{search!best-first} |
|
3214 \begin{ttbox} |
3200 \begin{ttbox} |
3215 choplev 0; |
3201 choplev 0; |
3216 {\out Level 0} |
3202 {\out Level 0} |
3217 {\out ?S ~: range f} |
3203 {\out ?S ~: range f} |
3218 {\out 1. ?S ~: range f} |
3204 {\out 1. ?S ~: range f} |