author | wenzelm |
Wed, 05 Nov 1997 11:43:37 +0100 | |
changeset 4148 | e0e5a2820ac1 |
parent 3490 | 823a6defdf0c |
child 4877 | 7a046198610e |
permissions | -rw-r--r-- |
104 | 1 |
%% $Id$ |
287 | 2 |
\chapter{Zermelo-Fraenkel Set Theory} |
317 | 3 |
\index{set theory|(} |
4 |
||
5 |
The theory~\thydx{ZF} implements Zermelo-Fraenkel set |
|
3490 | 6 |
theory~\cite{halmos60,suppes72} as an extension of~\texttt{FOL}, classical |
104 | 7 |
first-order logic. The theory includes a collection of derived natural |
317 | 8 |
deduction rules, for use with Isabelle's classical reasoner. Much |
9 |
of it is based on the work of No\"el~\cite{noel}. |
|
104 | 10 |
|
11 |
A tremendous amount of set theory has been formally developed, including |
|
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
12 |
the basic properties of relations, functions, ordinals and cardinals. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
13 |
Significant results have been proved, such as the Schr\"oder-Bernstein |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
14 |
Theorem, the Wellordering Theorem and a version of Ramsey's Theorem. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
15 |
General methods have been developed for solving recursion equations over |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
16 |
monotonic functors; these have been applied to yield constructions of |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
17 |
lists, trees, infinite lists, etc. The Recursion Theorem has been proved, |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
18 |
admitting recursive definitions of functions over well-founded relations. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
19 |
Thus, we may even regard set theory as a computational logic, loosely |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
20 |
inspired by Martin-L\"of's Type Theory. |
104 | 21 |
|
3149 | 22 |
Because {\ZF} is an extension of {\FOL}, it provides the same |
3490 | 23 |
packages, namely \texttt{hyp_subst_tac}, the simplifier, and the |
3149 | 24 |
classical reasoner. The default simpset and claset are usually |
25 |
satisfactory. Named simpsets include \ttindexbold{ZF_ss} (basic set |
|
26 |
theory rules) and \ttindexbold{rank_ss} (for proving termination of |
|
27 |
well-founded recursion). Named clasets include \ttindexbold{ZF_cs} |
|
28 |
(basic set theory) and \ttindexbold{le_cs} (useful for reasoning about |
|
29 |
the relations $<$ and $\le$). |
|
104 | 30 |
|
3490 | 31 |
\texttt{ZF} has a flexible package for handling inductive definitions, |
111 | 32 |
such as inference systems, and datatype definitions, such as lists and |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
33 |
trees. Moreover it handles coinductive definitions, such as |
3140 | 34 |
bisimulation relations, and codatatype definitions, such as streams. |
35 |
There is a paper \cite{paulson-CADE} describing the package, but its |
|
36 |
examples use an obsolete declaration syntax. Please consult the |
|
37 |
version of the paper distributed with Isabelle. |
|
111 | 38 |
|
3490 | 39 |
Recent reports~\cite{paulson-set-I,paulson-set-II} describe \texttt{ZF} less |
317 | 40 |
formally than this chapter. Isabelle employs a novel treatment of |
343 | 41 |
non-well-founded data structures within the standard {\sc zf} axioms including |
317 | 42 |
the Axiom of Foundation~\cite{paulson-final}. |
111 | 43 |
|
104 | 44 |
|
45 |
\section{Which version of axiomatic set theory?} |
|
317 | 46 |
The two main axiom systems for set theory are Bernays-G\"odel~({\sc bg}) |
47 |
and Zermelo-Fraenkel~({\sc zf}). Resolution theorem provers can use {\sc |
|
48 |
bg} because it is finite~\cite{boyer86,quaife92}. {\sc zf} does not |
|
49 |
have a finite axiom system because of its Axiom Scheme of Replacement. |
|
50 |
This makes it awkward to use with many theorem provers, since instances |
|
51 |
of the axiom scheme have to be invoked explicitly. Since Isabelle has no |
|
52 |
difficulty with axiom schemes, we may adopt either axiom system. |
|
104 | 53 |
|
54 |
These two theories differ in their treatment of {\bf classes}, which are |
|
317 | 55 |
collections that are `too big' to be sets. The class of all sets,~$V$, |
56 |
cannot be a set without admitting Russell's Paradox. In {\sc bg}, both |
|
57 |
classes and sets are individuals; $x\in V$ expresses that $x$ is a set. In |
|
58 |
{\sc zf}, all variables denote sets; classes are identified with unary |
|
59 |
predicates. The two systems define essentially the same sets and classes, |
|
60 |
with similar properties. In particular, a class cannot belong to another |
|
61 |
class (let alone a set). |
|
104 | 62 |
|
317 | 63 |
Modern set theorists tend to prefer {\sc zf} because they are mainly concerned |
64 |
with sets, rather than classes. {\sc bg} requires tiresome proofs that various |
|
104 | 65 |
collections are sets; for instance, showing $x\in\{x\}$ requires showing that |
317 | 66 |
$x$ is a set. |
104 | 67 |
|
68 |
||
3133 | 69 |
\begin{figure} \small |
104 | 70 |
\begin{center} |
71 |
\begin{tabular}{rrr} |
|
111 | 72 |
\it name &\it meta-type & \it description \\ |
1449 | 73 |
\cdx{Let} & $[\alpha,\alpha\To\beta]\To\beta$ & let binder\\ |
317 | 74 |
\cdx{0} & $i$ & empty set\\ |
75 |
\cdx{cons} & $[i,i]\To i$ & finite set constructor\\ |
|
76 |
\cdx{Upair} & $[i,i]\To i$ & unordered pairing\\ |
|
77 |
\cdx{Pair} & $[i,i]\To i$ & ordered pairing\\ |
|
78 |
\cdx{Inf} & $i$ & infinite set\\ |
|
79 |
\cdx{Pow} & $i\To i$ & powerset\\ |
|
80 |
\cdx{Union} \cdx{Inter} & $i\To i$ & set union/intersection \\ |
|
81 |
\cdx{split} & $[[i,i]\To i, i] \To i$ & generalized projection\\ |
|
82 |
\cdx{fst} \cdx{snd} & $i\To i$ & projections\\ |
|
83 |
\cdx{converse}& $i\To i$ & converse of a relation\\ |
|
84 |
\cdx{succ} & $i\To i$ & successor\\ |
|
85 |
\cdx{Collect} & $[i,i\To o]\To i$ & separation\\ |
|
86 |
\cdx{Replace} & $[i, [i,i]\To o] \To i$ & replacement\\ |
|
87 |
\cdx{PrimReplace} & $[i, [i,i]\To o] \To i$ & primitive replacement\\ |
|
88 |
\cdx{RepFun} & $[i, i\To i] \To i$ & functional replacement\\ |
|
89 |
\cdx{Pi} \cdx{Sigma} & $[i,i\To i]\To i$ & general product/sum\\ |
|
90 |
\cdx{domain} & $i\To i$ & domain of a relation\\ |
|
91 |
\cdx{range} & $i\To i$ & range of a relation\\ |
|
92 |
\cdx{field} & $i\To i$ & field of a relation\\ |
|
93 |
\cdx{Lambda} & $[i, i\To i]\To i$ & $\lambda$-abstraction\\ |
|
94 |
\cdx{restrict}& $[i, i] \To i$ & restriction of a function\\ |
|
95 |
\cdx{The} & $[i\To o]\To i$ & definite description\\ |
|
96 |
\cdx{if} & $[o,i,i]\To i$ & conditional\\ |
|
97 |
\cdx{Ball} \cdx{Bex} & $[i, i\To o]\To o$ & bounded quantifiers |
|
104 | 98 |
\end{tabular} |
99 |
\end{center} |
|
100 |
\subcaption{Constants} |
|
101 |
||
102 |
\begin{center} |
|
317 | 103 |
\index{*"`"` symbol} |
104 |
\index{*"-"`"` symbol} |
|
105 |
\index{*"` symbol}\index{function applications!in \ZF} |
|
106 |
\index{*"- symbol} |
|
107 |
\index{*": symbol} |
|
108 |
\index{*"<"= symbol} |
|
104 | 109 |
\begin{tabular}{rrrr} |
317 | 110 |
\it symbol & \it meta-type & \it priority & \it description \\ |
111 | 111 |
\tt `` & $[i,i]\To i$ & Left 90 & image \\ |
112 |
\tt -`` & $[i,i]\To i$ & Left 90 & inverse image \\ |
|
113 |
\tt ` & $[i,i]\To i$ & Left 90 & application \\ |
|
3149 | 114 |
\sdx{Int} & $[i,i]\To i$ & Left 70 & intersection ($\int$) \\ |
115 |
\sdx{Un} & $[i,i]\To i$ & Left 65 & union ($\un$) \\ |
|
111 | 116 |
\tt - & $[i,i]\To i$ & Left 65 & set difference ($-$) \\[1ex] |
117 |
\tt: & $[i,i]\To o$ & Left 50 & membership ($\in$) \\ |
|
118 |
\tt <= & $[i,i]\To o$ & Left 50 & subset ($\subseteq$) |
|
104 | 119 |
\end{tabular} |
120 |
\end{center} |
|
121 |
\subcaption{Infixes} |
|
317 | 122 |
\caption{Constants of {\ZF}} \label{zf-constants} |
104 | 123 |
\end{figure} |
124 |
||
125 |
||
126 |
\section{The syntax of set theory} |
|
127 |
The language of set theory, as studied by logicians, has no constants. The |
|
128 |
traditional axioms merely assert the existence of empty sets, unions, |
|
129 |
powersets, etc.; this would be intolerable for practical reasoning. The |
|
130 |
Isabelle theory declares constants for primitive sets. It also extends |
|
3490 | 131 |
\texttt{FOL} with additional syntax for finite sets, ordered pairs, |
104 | 132 |
comprehension, general union/intersection, general sums/products, and |
133 |
bounded quantifiers. In most other respects, Isabelle implements precisely |
|
134 |
Zermelo-Fraenkel set theory. |
|
135 |
||
498 | 136 |
Figure~\ref{zf-constants} lists the constants and infixes of~\ZF, while |
317 | 137 |
Figure~\ref{zf-trans} presents the syntax translations. Finally, |
138 |
Figure~\ref{zf-syntax} presents the full grammar for set theory, including |
|
104 | 139 |
the constructs of \FOL. |
140 |
||
3490 | 141 |
Local abbreviations can be introduced by a \texttt{let} construct whose |
1449 | 142 |
syntax appears in Fig.\ts\ref{zf-syntax}. Internally it is translated into |
143 |
the constant~\cdx{Let}. It can be expanded by rewriting with its |
|
144 |
definition, \tdx{Let_def}. |
|
145 |
||
3490 | 146 |
Apart from \texttt{let}, set theory does not use polymorphism. All terms in |
1449 | 147 |
{\ZF} have type~\tydx{i}, which is the type of individuals and has class~{\tt |
3490 | 148 |
term}. The type of first-order formulae, remember, is~\textit{o}. |
104 | 149 |
|
3149 | 150 |
Infix operators include binary union and intersection ($A\un B$ and |
151 |
$A\int B$), set difference ($A-B$), and the subset and membership |
|
317 | 152 |
relations. Note that $a$\verb|~:|$b$ is translated to $\neg(a\in b)$. The |
153 |
union and intersection operators ($\bigcup A$ and $\bigcap A$) form the |
|
154 |
union or intersection of a set of sets; $\bigcup A$ means the same as |
|
155 |
$\bigcup@{x\in A}x$. Of these operators, only $\bigcup A$ is primitive. |
|
104 | 156 |
|
317 | 157 |
The constant \cdx{Upair} constructs unordered pairs; thus {\tt |
3490 | 158 |
Upair($A$,$B$)} denotes the set~$\{A,B\}$ and \texttt{Upair($A$,$A$)} |
317 | 159 |
denotes the singleton~$\{A\}$. General union is used to define binary |
160 |
union. The Isabelle version goes on to define the constant |
|
161 |
\cdx{cons}: |
|
104 | 162 |
\begin{eqnarray*} |
3490 | 163 |
A\cup B & \equiv & \bigcup(\texttt{Upair}(A,B)) \\ |
164 |
\texttt{cons}(a,B) & \equiv & \texttt{Upair}(a,a) \un B |
|
104 | 165 |
\end{eqnarray*} |
3149 | 166 |
The $\{a@1, \ldots\}$ notation abbreviates finite sets constructed in the |
3490 | 167 |
obvious manner using~\texttt{cons} and~$\emptyset$ (the empty set): |
104 | 168 |
\begin{eqnarray*} |
3490 | 169 |
\{a,b,c\} & \equiv & \texttt{cons}(a,\texttt{cons}(b,\texttt{cons}(c,\emptyset))) |
104 | 170 |
\end{eqnarray*} |
171 |
||
317 | 172 |
The constant \cdx{Pair} constructs ordered pairs, as in {\tt |
104 | 173 |
Pair($a$,$b$)}. Ordered pairs may also be written within angle brackets, |
111 | 174 |
as {\tt<$a$,$b$>}. The $n$-tuple {\tt<$a@1$,\ldots,$a@{n-1}$,$a@n$>} |
317 | 175 |
abbreviates the nest of pairs\par\nobreak |
3490 | 176 |
\centerline\texttt{Pair($a@1$,\ldots,Pair($a@{n-1}$,$a@n$)\ldots).} |
104 | 177 |
|
178 |
In {\ZF}, a function is a set of pairs. A {\ZF} function~$f$ is simply an |
|
179 |
individual as far as Isabelle is concerned: its Isabelle type is~$i$, not |
|
180 |
say $i\To i$. The infix operator~{\tt`} denotes the application of a |
|
181 |
function set to its argument; we must write~$f{\tt`}x$, not~$f(x)$. The |
|
182 |
syntax for image is~$f{\tt``}A$ and that for inverse image is~$f{\tt-``}A$. |
|
183 |
||
184 |
||
185 |
\begin{figure} |
|
317 | 186 |
\index{lambda abs@$\lambda$-abstractions!in \ZF} |
187 |
\index{*"-"> symbol} |
|
188 |
\index{*"* symbol} |
|
287 | 189 |
\begin{center} \footnotesize\tt\frenchspacing |
104 | 190 |
\begin{tabular}{rrr} |
111 | 191 |
\it external & \it internal & \it description \\ |
104 | 192 |
$a$ \ttilde: $b$ & \ttilde($a$ : $b$) & \rm negated membership\\ |
3149 | 193 |
\ttlbrace$a@1$, $\ldots$, $a@n$\ttrbrace & cons($a@1$,$\ldots$,cons($a@n$,0)) & |
104 | 194 |
\rm finite set \\ |
111 | 195 |
<$a@1$, $\ldots$, $a@{n-1}$, $a@n$> & |
196 |
Pair($a@1$,\ldots,Pair($a@{n-1}$,$a@n$)\ldots) & |
|
197 |
\rm ordered $n$-tuple \\ |
|
3140 | 198 |
\ttlbrace$x$:$A . P[x]$\ttrbrace & Collect($A$,$\lambda x.P[x]$) & |
104 | 199 |
\rm separation \\ |
3140 | 200 |
\ttlbrace$y . x$:$A$, $Q[x,y]$\ttrbrace & Replace($A$,$\lambda x\,y.Q[x,y]$) & |
104 | 201 |
\rm replacement \\ |
3140 | 202 |
\ttlbrace$b[x] . x$:$A$\ttrbrace & RepFun($A$,$\lambda x.b[x]$) & |
104 | 203 |
\rm functional replacement \\ |
3140 | 204 |
\sdx{INT} $x$:$A . B[x]$ & Inter(\ttlbrace$B[x] . x$:$A$\ttrbrace) & |
111 | 205 |
\rm general intersection \\ |
3140 | 206 |
\sdx{UN} $x$:$A . B[x]$ & Union(\ttlbrace$B[x] . x$:$A$\ttrbrace) & |
111 | 207 |
\rm general union \\ |
317 | 208 |
\sdx{PROD} $x$:$A . B[x]$ & Pi($A$,$\lambda x.B[x]$) & |
111 | 209 |
\rm general product \\ |
317 | 210 |
\sdx{SUM} $x$:$A . B[x]$ & Sigma($A$,$\lambda x.B[x]$) & |
111 | 211 |
\rm general sum \\ |
212 |
$A$ -> $B$ & Pi($A$,$\lambda x.B$) & |
|
213 |
\rm function space \\ |
|
214 |
$A$ * $B$ & Sigma($A$,$\lambda x.B$) & |
|
215 |
\rm binary product \\ |
|
317 | 216 |
\sdx{THE} $x . P[x]$ & The($\lambda x.P[x]$) & |
111 | 217 |
\rm definite description \\ |
317 | 218 |
\sdx{lam} $x$:$A . b[x]$ & Lambda($A$,$\lambda x.b[x]$) & |
111 | 219 |
\rm $\lambda$-abstraction\\[1ex] |
317 | 220 |
\sdx{ALL} $x$:$A . P[x]$ & Ball($A$,$\lambda x.P[x]$) & |
111 | 221 |
\rm bounded $\forall$ \\ |
317 | 222 |
\sdx{EX} $x$:$A . P[x]$ & Bex($A$,$\lambda x.P[x]$) & |
111 | 223 |
\rm bounded $\exists$ |
104 | 224 |
\end{tabular} |
225 |
\end{center} |
|
317 | 226 |
\caption{Translations for {\ZF}} \label{zf-trans} |
104 | 227 |
\end{figure} |
228 |
||
229 |
||
230 |
\begin{figure} |
|
1449 | 231 |
\index{*let symbol} |
232 |
\index{*in symbol} |
|
104 | 233 |
\dquotes |
234 |
\[\begin{array}{rcl} |
|
235 |
term & = & \hbox{expression of type~$i$} \\ |
|
1449 | 236 |
& | & "let"~id~"="~term";"\dots";"~id~"="~term~"in"~term \\ |
3140 | 237 |
& | & "{\ttlbrace} " term\; ("," term)^* " {\ttrbrace}" \\ |
317 | 238 |
& | & "< " term\; ("," term)^* " >" \\ |
3140 | 239 |
& | & "{\ttlbrace} " id ":" term " . " formula " {\ttrbrace}" \\ |
240 |
& | & "{\ttlbrace} " id " . " id ":" term ", " formula " {\ttrbrace}" \\ |
|
241 |
& | & "{\ttlbrace} " term " . " id ":" term " {\ttrbrace}" \\ |
|
111 | 242 |
& | & term " `` " term \\ |
243 |
& | & term " -`` " term \\ |
|
244 |
& | & term " ` " term \\ |
|
245 |
& | & term " * " term \\ |
|
246 |
& | & term " Int " term \\ |
|
247 |
& | & term " Un " term \\ |
|
248 |
& | & term " - " term \\ |
|
249 |
& | & term " -> " term \\ |
|
250 |
& | & "THE~~" id " . " formula\\ |
|
251 |
& | & "lam~~" id ":" term " . " term \\ |
|
252 |
& | & "INT~~" id ":" term " . " term \\ |
|
253 |
& | & "UN~~~" id ":" term " . " term \\ |
|
254 |
& | & "PROD~" id ":" term " . " term \\ |
|
255 |
& | & "SUM~~" id ":" term " . " term \\[2ex] |
|
104 | 256 |
formula & = & \hbox{expression of type~$o$} \\ |
111 | 257 |
& | & term " : " term \\ |
317 | 258 |
& | & term " \ttilde: " term \\ |
111 | 259 |
& | & term " <= " term \\ |
260 |
& | & term " = " term \\ |
|
317 | 261 |
& | & term " \ttilde= " term \\ |
111 | 262 |
& | & "\ttilde\ " formula \\ |
263 |
& | & formula " \& " formula \\ |
|
264 |
& | & formula " | " formula \\ |
|
265 |
& | & formula " --> " formula \\ |
|
266 |
& | & formula " <-> " formula \\ |
|
267 |
& | & "ALL " id ":" term " . " formula \\ |
|
268 |
& | & "EX~~" id ":" term " . " formula \\ |
|
269 |
& | & "ALL~" id~id^* " . " formula \\ |
|
270 |
& | & "EX~~" id~id^* " . " formula \\ |
|
271 |
& | & "EX!~" id~id^* " . " formula |
|
104 | 272 |
\end{array} |
273 |
\] |
|
317 | 274 |
\caption{Full grammar for {\ZF}} \label{zf-syntax} |
104 | 275 |
\end{figure} |
276 |
||
277 |
||
278 |
\section{Binding operators} |
|
317 | 279 |
The constant \cdx{Collect} constructs sets by the principle of {\bf |
3140 | 280 |
separation}. The syntax for separation is |
281 |
\hbox{\tt\ttlbrace$x$:$A$.$P[x]$\ttrbrace}, where $P[x]$ is a formula |
|
282 |
that may contain free occurrences of~$x$. It abbreviates the set {\tt |
|
283 |
Collect($A$,$\lambda x.P[x]$)}, which consists of all $x\in A$ that |
|
3490 | 284 |
satisfy~$P[x]$. Note that \texttt{Collect} is an unfortunate choice of |
3140 | 285 |
name: some set theories adopt a set-formation principle, related to |
286 |
replacement, called collection. |
|
104 | 287 |
|
317 | 288 |
The constant \cdx{Replace} constructs sets by the principle of {\bf |
3140 | 289 |
replacement}. The syntax |
290 |
\hbox{\tt\ttlbrace$y$.$x$:$A$,$Q[x,y]$\ttrbrace} denotes the set {\tt |
|
291 |
Replace($A$,$\lambda x\,y.Q[x,y]$)}, which consists of all~$y$ such |
|
292 |
that there exists $x\in A$ satisfying~$Q[x,y]$. The Replacement Axiom |
|
293 |
has the condition that $Q$ must be single-valued over~$A$: for |
|
294 |
all~$x\in A$ there exists at most one $y$ satisfying~$Q[x,y]$. A |
|
295 |
single-valued binary predicate is also called a {\bf class function}. |
|
104 | 296 |
|
317 | 297 |
The constant \cdx{RepFun} expresses a special case of replacement, |
104 | 298 |
where $Q[x,y]$ has the form $y=b[x]$. Such a $Q$ is trivially |
299 |
single-valued, since it is just the graph of the meta-level |
|
287 | 300 |
function~$\lambda x.b[x]$. The resulting set consists of all $b[x]$ |
3490 | 301 |
for~$x\in A$. This is analogous to the \ML{} functional \texttt{map}, |
3140 | 302 |
since it applies a function to every element of a set. The syntax is |
303 |
\hbox{\tt\ttlbrace$b[x]$.$x$:$A$\ttrbrace}, which expands to {\tt |
|
304 |
RepFun($A$,$\lambda x.b[x]$)}. |
|
104 | 305 |
|
317 | 306 |
\index{*INT symbol}\index{*UN symbol} |
287 | 307 |
General unions and intersections of indexed |
308 |
families of sets, namely $\bigcup@{x\in A}B[x]$ and $\bigcap@{x\in A}B[x]$, |
|
309 |
are written \hbox{\tt UN $x$:$A$.$B[x]$} and \hbox{\tt INT $x$:$A$.$B[x]$}. |
|
3490 | 310 |
Their meaning is expressed using \texttt{RepFun} as |
3140 | 311 |
\[ |
312 |
\bigcup(\{B[x]. x\in A\}) \qquad\hbox{and}\qquad |
|
313 |
\bigcap(\{B[x]. x\in A\}). |
|
104 | 314 |
\] |
315 |
General sums $\sum@{x\in A}B[x]$ and products $\prod@{x\in A}B[x]$ can be |
|
316 |
constructed in set theory, where $B[x]$ is a family of sets over~$A$. They |
|
317 |
have as special cases $A\times B$ and $A\to B$, where $B$ is simply a set. |
|
318 |
This is similar to the situation in Constructive Type Theory (set theory |
|
317 | 319 |
has `dependent sets') and calls for similar syntactic conventions. The |
320 |
constants~\cdx{Sigma} and~\cdx{Pi} construct general sums and |
|
3490 | 321 |
products. Instead of \texttt{Sigma($A$,$B$)} and \texttt{Pi($A$,$B$)} we may write |
104 | 322 |
\hbox{\tt SUM $x$:$A$.$B[x]$} and \hbox{\tt PROD $x$:$A$.$B[x]$}. |
317 | 323 |
\index{*SUM symbol}\index{*PROD symbol}% |
104 | 324 |
The special cases as \hbox{\tt$A$*$B$} and \hbox{\tt$A$->$B$} abbreviate |
325 |
general sums and products over a constant family.\footnote{Unlike normal |
|
326 |
infix operators, {\tt*} and {\tt->} merely define abbreviations; there are |
|
327 |
no constants~{\tt op~*} and~\hbox{\tt op~->}.} Isabelle accepts these |
|
328 |
abbreviations in parsing and uses them whenever possible for printing. |
|
329 |
||
317 | 330 |
\index{*THE symbol} |
104 | 331 |
As mentioned above, whenever the axioms assert the existence and uniqueness |
332 |
of a set, Isabelle's set theory declares a constant for that set. These |
|
333 |
constants can express the {\bf definite description} operator~$\iota |
|
334 |
x.P[x]$, which stands for the unique~$a$ satisfying~$P[a]$, if such exists. |
|
335 |
Since all terms in {\ZF} denote something, a description is always |
|
336 |
meaningful, but we do not know its value unless $P[x]$ defines it uniquely. |
|
317 | 337 |
Using the constant~\cdx{The}, we may write descriptions as {\tt |
104 | 338 |
The($\lambda x.P[x]$)} or use the syntax \hbox{\tt THE $x$.$P[x]$}. |
339 |
||
317 | 340 |
\index{*lam symbol} |
104 | 341 |
Function sets may be written in $\lambda$-notation; $\lambda x\in A.b[x]$ |
342 |
stands for the set of all pairs $\pair{x,b[x]}$ for $x\in A$. In order for |
|
343 |
this to be a set, the function's domain~$A$ must be given. Using the |
|
317 | 344 |
constant~\cdx{Lambda}, we may express function sets as {\tt |
104 | 345 |
Lambda($A$,$\lambda x.b[x]$)} or use the syntax \hbox{\tt lam $x$:$A$.$b[x]$}. |
346 |
||
347 |
Isabelle's set theory defines two {\bf bounded quantifiers}: |
|
348 |
\begin{eqnarray*} |
|
317 | 349 |
\forall x\in A.P[x] &\hbox{abbreviates}& \forall x. x\in A\imp P[x] \\ |
350 |
\exists x\in A.P[x] &\hbox{abbreviates}& \exists x. x\in A\conj P[x] |
|
104 | 351 |
\end{eqnarray*} |
317 | 352 |
The constants~\cdx{Ball} and~\cdx{Bex} are defined |
3490 | 353 |
accordingly. Instead of \texttt{Ball($A$,$P$)} and \texttt{Bex($A$,$P$)} we may |
104 | 354 |
write |
355 |
\hbox{\tt ALL $x$:$A$.$P[x]$} and \hbox{\tt EX $x$:$A$.$P[x]$}. |
|
356 |
||
357 |
||
343 | 358 |
%%%% ZF.thy |
104 | 359 |
|
360 |
\begin{figure} |
|
361 |
\begin{ttbox} |
|
1449 | 362 |
\tdx{Let_def} Let(s, f) == f(s) |
363 |
||
317 | 364 |
\tdx{Ball_def} Ball(A,P) == ALL x. x:A --> P(x) |
365 |
\tdx{Bex_def} Bex(A,P) == EX x. x:A & P(x) |
|
104 | 366 |
|
317 | 367 |
\tdx{subset_def} A <= B == ALL x:A. x:B |
368 |
\tdx{extension} A = B <-> A <= B & B <= A |
|
104 | 369 |
|
498 | 370 |
\tdx{Union_iff} A : Union(C) <-> (EX B:C. A:B) |
371 |
\tdx{Pow_iff} A : Pow(B) <-> A <= B |
|
317 | 372 |
\tdx{foundation} A=0 | (EX x:A. ALL y:x. ~ y:A) |
104 | 373 |
|
317 | 374 |
\tdx{replacement} (ALL x:A. ALL y z. P(x,y) & P(x,z) --> y=z) ==> |
104 | 375 |
b : PrimReplace(A,P) <-> (EX x:A. P(x,b)) |
376 |
\subcaption{The Zermelo-Fraenkel Axioms} |
|
377 |
||
317 | 378 |
\tdx{Replace_def} Replace(A,P) == |
287 | 379 |
PrimReplace(A, \%x y. (EX!z.P(x,z)) & P(x,y)) |
3140 | 380 |
\tdx{RepFun_def} RepFun(A,f) == {\ttlbrace}y . x:A, y=f(x)\ttrbrace |
381 |
\tdx{the_def} The(P) == Union({\ttlbrace}y . x:{\ttlbrace}0{\ttrbrace}, P(y){\ttrbrace}) |
|
317 | 382 |
\tdx{if_def} if(P,a,b) == THE z. P & z=a | ~P & z=b |
3140 | 383 |
\tdx{Collect_def} Collect(A,P) == {\ttlbrace}y . x:A, x=y & P(x){\ttrbrace} |
317 | 384 |
\tdx{Upair_def} Upair(a,b) == |
3140 | 385 |
{\ttlbrace}y. x:Pow(Pow(0)), (x=0 & y=a) | (x=Pow(0) & y=b){\ttrbrace} |
104 | 386 |
\subcaption{Consequences of replacement} |
387 |
||
3140 | 388 |
\tdx{Inter_def} Inter(A) == {\ttlbrace}x:Union(A) . ALL y:A. x:y{\ttrbrace} |
317 | 389 |
\tdx{Un_def} A Un B == Union(Upair(A,B)) |
390 |
\tdx{Int_def} A Int B == Inter(Upair(A,B)) |
|
3140 | 391 |
\tdx{Diff_def} A - B == {\ttlbrace}x:A . x~:B{\ttrbrace} |
104 | 392 |
\subcaption{Union, intersection, difference} |
393 |
\end{ttbox} |
|
317 | 394 |
\caption{Rules and axioms of {\ZF}} \label{zf-rules} |
104 | 395 |
\end{figure} |
396 |
||
397 |
||
398 |
\begin{figure} |
|
399 |
\begin{ttbox} |
|
317 | 400 |
\tdx{cons_def} cons(a,A) == Upair(a,a) Un A |
401 |
\tdx{succ_def} succ(i) == cons(i,i) |
|
402 |
\tdx{infinity} 0:Inf & (ALL y:Inf. succ(y): Inf) |
|
111 | 403 |
\subcaption{Finite and infinite sets} |
404 |
||
3140 | 405 |
\tdx{Pair_def} <a,b> == {\ttlbrace}{\ttlbrace}a,a{\ttrbrace}, {\ttlbrace}a,b{\ttrbrace}{\ttrbrace} |
317 | 406 |
\tdx{split_def} split(c,p) == THE y. EX a b. p=<a,b> & y=c(a,b) |
407 |
\tdx{fst_def} fst(A) == split(\%x y.x, p) |
|
408 |
\tdx{snd_def} snd(A) == split(\%x y.y, p) |
|
3140 | 409 |
\tdx{Sigma_def} Sigma(A,B) == UN x:A. UN y:B(x). {\ttlbrace}<x,y>{\ttrbrace} |
104 | 410 |
\subcaption{Ordered pairs and Cartesian products} |
411 |
||
3140 | 412 |
\tdx{converse_def} converse(r) == {\ttlbrace}z. w:r, EX x y. w=<x,y> & z=<y,x>{\ttrbrace} |
413 |
\tdx{domain_def} domain(r) == {\ttlbrace}x. w:r, EX y. w=<x,y>{\ttrbrace} |
|
317 | 414 |
\tdx{range_def} range(r) == domain(converse(r)) |
415 |
\tdx{field_def} field(r) == domain(r) Un range(r) |
|
3140 | 416 |
\tdx{image_def} r `` A == {\ttlbrace}y : range(r) . EX x:A. <x,y> : r{\ttrbrace} |
317 | 417 |
\tdx{vimage_def} r -`` A == converse(r)``A |
104 | 418 |
\subcaption{Operations on relations} |
419 |
||
3140 | 420 |
\tdx{lam_def} Lambda(A,b) == {\ttlbrace}<x,b(x)> . x:A{\ttrbrace} |
317 | 421 |
\tdx{apply_def} f`a == THE y. <a,y> : f |
3140 | 422 |
\tdx{Pi_def} Pi(A,B) == {\ttlbrace}f: Pow(Sigma(A,B)). ALL x:A. EX! y. <x,y>: f{\ttrbrace} |
317 | 423 |
\tdx{restrict_def} restrict(f,A) == lam x:A.f`x |
104 | 424 |
\subcaption{Functions and general product} |
425 |
\end{ttbox} |
|
317 | 426 |
\caption{Further definitions of {\ZF}} \label{zf-defs} |
104 | 427 |
\end{figure} |
428 |
||
429 |
||
430 |
||
431 |
\section{The Zermelo-Fraenkel axioms} |
|
317 | 432 |
The axioms appear in Fig.\ts \ref{zf-rules}. They resemble those |
104 | 433 |
presented by Suppes~\cite{suppes72}. Most of the theory consists of |
434 |
definitions. In particular, bounded quantifiers and the subset relation |
|
435 |
appear in other axioms. Object-level quantifiers and implications have |
|
436 |
been replaced by meta-level ones wherever possible, to simplify use of the |
|
3490 | 437 |
axioms. See the file \texttt{ZF/ZF.thy} for details. |
104 | 438 |
|
439 |
The traditional replacement axiom asserts |
|
3490 | 440 |
\[ y \in \texttt{PrimReplace}(A,P) \bimp (\exists x\in A. P(x,y)) \] |
104 | 441 |
subject to the condition that $P(x,y)$ is single-valued for all~$x\in A$. |
317 | 442 |
The Isabelle theory defines \cdx{Replace} to apply |
443 |
\cdx{PrimReplace} to the single-valued part of~$P$, namely |
|
104 | 444 |
\[ (\exists!z.P(x,z)) \conj P(x,y). \] |
3490 | 445 |
Thus $y\in \texttt{Replace}(A,P)$ if and only if there is some~$x$ such that |
104 | 446 |
$P(x,-)$ holds uniquely for~$y$. Because the equivalence is unconditional, |
3490 | 447 |
\texttt{Replace} is much easier to use than \texttt{PrimReplace}; it defines the |
104 | 448 |
same set, if $P(x,y)$ is single-valued. The nice syntax for replacement |
3490 | 449 |
expands to \texttt{Replace}. |
104 | 450 |
|
451 |
Other consequences of replacement include functional replacement |
|
317 | 452 |
(\cdx{RepFun}) and definite descriptions (\cdx{The}). |
453 |
Axioms for separation (\cdx{Collect}) and unordered pairs |
|
454 |
(\cdx{Upair}) are traditionally assumed, but they actually follow |
|
104 | 455 |
from replacement~\cite[pages 237--8]{suppes72}. |
456 |
||
457 |
The definitions of general intersection, etc., are straightforward. Note |
|
3490 | 458 |
the definition of \texttt{cons}, which underlies the finite set notation. |
104 | 459 |
The axiom of infinity gives us a set that contains~0 and is closed under |
317 | 460 |
successor (\cdx{succ}). Although this set is not uniquely defined, |
461 |
the theory names it (\cdx{Inf}) in order to simplify the |
|
104 | 462 |
construction of the natural numbers. |
111 | 463 |
|
317 | 464 |
Further definitions appear in Fig.\ts\ref{zf-defs}. Ordered pairs are |
104 | 465 |
defined in the standard way, $\pair{a,b}\equiv\{\{a\},\{a,b\}\}$. Recall |
317 | 466 |
that \cdx{Sigma}$(A,B)$ generalizes the Cartesian product of two |
104 | 467 |
sets. It is defined to be the union of all singleton sets |
468 |
$\{\pair{x,y}\}$, for $x\in A$ and $y\in B(x)$. This is a typical usage of |
|
469 |
general union. |
|
470 |
||
317 | 471 |
The projections \cdx{fst} and~\cdx{snd} are defined in terms of the |
472 |
generalized projection \cdx{split}. The latter has been borrowed from |
|
473 |
Martin-L\"of's Type Theory, and is often easier to use than \cdx{fst} |
|
474 |
and~\cdx{snd}. |
|
475 |
||
104 | 476 |
Operations on relations include converse, domain, range, and image. The |
477 |
set ${\tt Pi}(A,B)$ generalizes the space of functions between two sets. |
|
478 |
Note the simple definitions of $\lambda$-abstraction (using |
|
317 | 479 |
\cdx{RepFun}) and application (using a definite description). The |
480 |
function \cdx{restrict}$(f,A)$ has the same values as~$f$, but only |
|
104 | 481 |
over the domain~$A$. |
482 |
||
317 | 483 |
|
484 |
%%%% zf.ML |
|
485 |
||
486 |
\begin{figure} |
|
487 |
\begin{ttbox} |
|
488 |
\tdx{ballI} [| !!x. x:A ==> P(x) |] ==> ALL x:A. P(x) |
|
489 |
\tdx{bspec} [| ALL x:A. P(x); x: A |] ==> P(x) |
|
490 |
\tdx{ballE} [| ALL x:A. P(x); P(x) ==> Q; ~ x:A ==> Q |] ==> Q |
|
491 |
||
492 |
\tdx{ball_cong} [| A=A'; !!x. x:A' ==> P(x) <-> P'(x) |] ==> |
|
493 |
(ALL x:A. P(x)) <-> (ALL x:A'. P'(x)) |
|
494 |
||
495 |
\tdx{bexI} [| P(x); x: A |] ==> EX x:A. P(x) |
|
496 |
\tdx{bexCI} [| ALL x:A. ~P(x) ==> P(a); a: A |] ==> EX x:A.P(x) |
|
497 |
\tdx{bexE} [| EX x:A. P(x); !!x. [| x:A; P(x) |] ==> Q |] ==> Q |
|
498 |
||
499 |
\tdx{bex_cong} [| A=A'; !!x. x:A' ==> P(x) <-> P'(x) |] ==> |
|
500 |
(EX x:A. P(x)) <-> (EX x:A'. P'(x)) |
|
501 |
\subcaption{Bounded quantifiers} |
|
502 |
||
503 |
\tdx{subsetI} (!!x.x:A ==> x:B) ==> A <= B |
|
504 |
\tdx{subsetD} [| A <= B; c:A |] ==> c:B |
|
505 |
\tdx{subsetCE} [| A <= B; ~(c:A) ==> P; c:B ==> P |] ==> P |
|
506 |
\tdx{subset_refl} A <= A |
|
507 |
\tdx{subset_trans} [| A<=B; B<=C |] ==> A<=C |
|
508 |
||
509 |
\tdx{equalityI} [| A <= B; B <= A |] ==> A = B |
|
510 |
\tdx{equalityD1} A = B ==> A<=B |
|
511 |
\tdx{equalityD2} A = B ==> B<=A |
|
512 |
\tdx{equalityE} [| A = B; [| A<=B; B<=A |] ==> P |] ==> P |
|
513 |
\subcaption{Subsets and extensionality} |
|
514 |
||
515 |
\tdx{emptyE} a:0 ==> P |
|
516 |
\tdx{empty_subsetI} 0 <= A |
|
517 |
\tdx{equals0I} [| !!y. y:A ==> False |] ==> A=0 |
|
518 |
\tdx{equals0D} [| A=0; a:A |] ==> P |
|
519 |
||
520 |
\tdx{PowI} A <= B ==> A : Pow(B) |
|
521 |
\tdx{PowD} A : Pow(B) ==> A<=B |
|
522 |
\subcaption{The empty set; power sets} |
|
523 |
\end{ttbox} |
|
524 |
\caption{Basic derived rules for {\ZF}} \label{zf-lemmas1} |
|
525 |
\end{figure} |
|
104 | 526 |
|
527 |
||
528 |
\section{From basic lemmas to function spaces} |
|
529 |
Faced with so many definitions, it is essential to prove lemmas. Even |
|
3149 | 530 |
trivial theorems like $A \int B = B \int A$ would be difficult to |
531 |
prove from the definitions alone. Isabelle's set theory derives many |
|
532 |
rules using a natural deduction style. Ideally, a natural deduction |
|
533 |
rule should introduce or eliminate just one operator, but this is not |
|
534 |
always practical. For most operators, we may forget its definition |
|
535 |
and use its derived rules instead. |
|
104 | 536 |
|
537 |
\subsection{Fundamental lemmas} |
|
317 | 538 |
Figure~\ref{zf-lemmas1} presents the derived rules for the most basic |
104 | 539 |
operators. The rules for the bounded quantifiers resemble those for the |
343 | 540 |
ordinary quantifiers, but note that \tdx{ballE} uses a negated assumption |
541 |
in the style of Isabelle's classical reasoner. The \rmindex{congruence |
|
542 |
rules} \tdx{ball_cong} and \tdx{bex_cong} are required by Isabelle's |
|
104 | 543 |
simplifier, but have few other uses. Congruence rules must be specially |
544 |
derived for all binding operators, and henceforth will not be shown. |
|
545 |
||
317 | 546 |
Figure~\ref{zf-lemmas1} also shows rules for the subset and equality |
104 | 547 |
relations (proof by extensionality), and rules about the empty set and the |
548 |
power set operator. |
|
549 |
||
317 | 550 |
Figure~\ref{zf-lemmas2} presents rules for replacement and separation. |
551 |
The rules for \cdx{Replace} and \cdx{RepFun} are much simpler than |
|
3490 | 552 |
comparable rules for \texttt{PrimReplace} would be. The principle of |
104 | 553 |
separation is proved explicitly, although most proofs should use the |
3490 | 554 |
natural deduction rules for \texttt{Collect}. The elimination rule |
317 | 555 |
\tdx{CollectE} is equivalent to the two destruction rules |
556 |
\tdx{CollectD1} and \tdx{CollectD2}, but each rule is suited to |
|
104 | 557 |
particular circumstances. Although too many rules can be confusing, there |
558 |
is no reason to aim for a minimal set of rules. See the file |
|
3490 | 559 |
\texttt{ZF/ZF.ML} for a complete listing. |
104 | 560 |
|
317 | 561 |
Figure~\ref{zf-lemmas3} presents rules for general union and intersection. |
104 | 562 |
The empty intersection should be undefined. We cannot have |
563 |
$\bigcap(\emptyset)=V$ because $V$, the universal class, is not a set. All |
|
564 |
expressions denote something in {\ZF} set theory; the definition of |
|
565 |
intersection implies $\bigcap(\emptyset)=\emptyset$, but this value is |
|
317 | 566 |
arbitrary. The rule \tdx{InterI} must have a premise to exclude |
104 | 567 |
the empty intersection. Some of the laws governing intersections require |
568 |
similar premises. |
|
569 |
||
570 |
||
317 | 571 |
%the [p] gives better page breaking for the book |
572 |
\begin{figure}[p] |
|
573 |
\begin{ttbox} |
|
574 |
\tdx{ReplaceI} [| x: A; P(x,b); !!y. P(x,y) ==> y=b |] ==> |
|
3140 | 575 |
b : {\ttlbrace}y. x:A, P(x,y){\ttrbrace} |
317 | 576 |
|
3140 | 577 |
\tdx{ReplaceE} [| b : {\ttlbrace}y. x:A, P(x,y){\ttrbrace}; |
317 | 578 |
!!x. [| x: A; P(x,b); ALL y. P(x,y)-->y=b |] ==> R |
579 |
|] ==> R |
|
580 |
||
3140 | 581 |
\tdx{RepFunI} [| a : A |] ==> f(a) : {\ttlbrace}f(x). x:A{\ttrbrace} |
582 |
\tdx{RepFunE} [| b : {\ttlbrace}f(x). x:A{\ttrbrace}; |
|
317 | 583 |
!!x.[| x:A; b=f(x) |] ==> P |] ==> P |
584 |
||
3140 | 585 |
\tdx{separation} a : {\ttlbrace}x:A. P(x){\ttrbrace} <-> a:A & P(a) |
586 |
\tdx{CollectI} [| a:A; P(a) |] ==> a : {\ttlbrace}x:A. P(x){\ttrbrace} |
|
587 |
\tdx{CollectE} [| a : {\ttlbrace}x:A. P(x){\ttrbrace}; [| a:A; P(a) |] ==> R |] ==> R |
|
588 |
\tdx{CollectD1} a : {\ttlbrace}x:A. P(x){\ttrbrace} ==> a:A |
|
589 |
\tdx{CollectD2} a : {\ttlbrace}x:A. P(x){\ttrbrace} ==> P(a) |
|
317 | 590 |
\end{ttbox} |
591 |
\caption{Replacement and separation} \label{zf-lemmas2} |
|
592 |
\end{figure} |
|
593 |
||
594 |
||
595 |
\begin{figure} |
|
596 |
\begin{ttbox} |
|
597 |
\tdx{UnionI} [| B: C; A: B |] ==> A: Union(C) |
|
598 |
\tdx{UnionE} [| A : Union(C); !!B.[| A: B; B: C |] ==> R |] ==> R |
|
599 |
||
600 |
\tdx{InterI} [| !!x. x: C ==> A: x; c:C |] ==> A : Inter(C) |
|
601 |
\tdx{InterD} [| A : Inter(C); B : C |] ==> A : B |
|
602 |
\tdx{InterE} [| A : Inter(C); A:B ==> R; ~ B:C ==> R |] ==> R |
|
603 |
||
604 |
\tdx{UN_I} [| a: A; b: B(a) |] ==> b: (UN x:A. B(x)) |
|
605 |
\tdx{UN_E} [| b : (UN x:A. B(x)); !!x.[| x: A; b: B(x) |] ==> R |
|
606 |
|] ==> R |
|
607 |
||
608 |
\tdx{INT_I} [| !!x. x: A ==> b: B(x); a: A |] ==> b: (INT x:A. B(x)) |
|
609 |
\tdx{INT_E} [| b : (INT x:A. B(x)); a: A |] ==> b : B(a) |
|
610 |
\end{ttbox} |
|
611 |
\caption{General union and intersection} \label{zf-lemmas3} |
|
612 |
\end{figure} |
|
613 |
||
614 |
||
104 | 615 |
%%% upair.ML |
616 |
||
617 |
\begin{figure} |
|
618 |
\begin{ttbox} |
|
317 | 619 |
\tdx{pairing} a:Upair(b,c) <-> (a=b | a=c) |
620 |
\tdx{UpairI1} a : Upair(a,b) |
|
621 |
\tdx{UpairI2} b : Upair(a,b) |
|
622 |
\tdx{UpairE} [| a : Upair(b,c); a = b ==> P; a = c ==> P |] ==> P |
|
623 |
\end{ttbox} |
|
624 |
\caption{Unordered pairs} \label{zf-upair1} |
|
625 |
\end{figure} |
|
626 |
||
104 | 627 |
|
317 | 628 |
\begin{figure} |
629 |
\begin{ttbox} |
|
630 |
\tdx{UnI1} c : A ==> c : A Un B |
|
631 |
\tdx{UnI2} c : B ==> c : A Un B |
|
632 |
\tdx{UnCI} (~c : B ==> c : A) ==> c : A Un B |
|
633 |
\tdx{UnE} [| c : A Un B; c:A ==> P; c:B ==> P |] ==> P |
|
634 |
||
635 |
\tdx{IntI} [| c : A; c : B |] ==> c : A Int B |
|
636 |
\tdx{IntD1} c : A Int B ==> c : A |
|
637 |
\tdx{IntD2} c : A Int B ==> c : B |
|
638 |
\tdx{IntE} [| c : A Int B; [| c:A; c:B |] ==> P |] ==> P |
|
104 | 639 |
|
317 | 640 |
\tdx{DiffI} [| c : A; ~ c : B |] ==> c : A - B |
641 |
\tdx{DiffD1} c : A - B ==> c : A |
|
498 | 642 |
\tdx{DiffD2} c : A - B ==> c ~: B |
317 | 643 |
\tdx{DiffE} [| c : A - B; [| c:A; ~ c:B |] ==> P |] ==> P |
644 |
\end{ttbox} |
|
645 |
\caption{Union, intersection, difference} \label{zf-Un} |
|
646 |
\end{figure} |
|
647 |
||
104 | 648 |
|
317 | 649 |
\begin{figure} |
650 |
\begin{ttbox} |
|
651 |
\tdx{consI1} a : cons(a,B) |
|
652 |
\tdx{consI2} a : B ==> a : cons(b,B) |
|
653 |
\tdx{consCI} (~ a:B ==> a=b) ==> a: cons(b,B) |
|
654 |
\tdx{consE} [| a : cons(b,A); a=b ==> P; a:A ==> P |] ==> P |
|
655 |
||
3140 | 656 |
\tdx{singletonI} a : {\ttlbrace}a{\ttrbrace} |
657 |
\tdx{singletonE} [| a : {\ttlbrace}b{\ttrbrace}; a=b ==> P |] ==> P |
|
104 | 658 |
\end{ttbox} |
317 | 659 |
\caption{Finite and singleton sets} \label{zf-upair2} |
104 | 660 |
\end{figure} |
661 |
||
662 |
||
663 |
\begin{figure} |
|
664 |
\begin{ttbox} |
|
317 | 665 |
\tdx{succI1} i : succ(i) |
666 |
\tdx{succI2} i : j ==> i : succ(j) |
|
667 |
\tdx{succCI} (~ i:j ==> i=j) ==> i: succ(j) |
|
668 |
\tdx{succE} [| i : succ(j); i=j ==> P; i:j ==> P |] ==> P |
|
669 |
\tdx{succ_neq_0} [| succ(n)=0 |] ==> P |
|
670 |
\tdx{succ_inject} succ(m) = succ(n) ==> m=n |
|
671 |
\end{ttbox} |
|
672 |
\caption{The successor function} \label{zf-succ} |
|
673 |
\end{figure} |
|
104 | 674 |
|
675 |
||
317 | 676 |
\begin{figure} |
677 |
\begin{ttbox} |
|
678 |
\tdx{the_equality} [| P(a); !!x. P(x) ==> x=a |] ==> (THE x. P(x)) = a |
|
679 |
\tdx{theI} EX! x. P(x) ==> P(THE x. P(x)) |
|
104 | 680 |
|
461 | 681 |
\tdx{if_P} P ==> if(P,a,b) = a |
682 |
\tdx{if_not_P} ~P ==> if(P,a,b) = b |
|
104 | 683 |
|
461 | 684 |
\tdx{mem_asym} [| a:b; b:a |] ==> P |
685 |
\tdx{mem_irrefl} a:a ==> P |
|
104 | 686 |
\end{ttbox} |
317 | 687 |
\caption{Descriptions; non-circularity} \label{zf-the} |
104 | 688 |
\end{figure} |
689 |
||
690 |
||
691 |
\subsection{Unordered pairs and finite sets} |
|
317 | 692 |
Figure~\ref{zf-upair1} presents the principle of unordered pairing, along |
104 | 693 |
with its derived rules. Binary union and intersection are defined in terms |
317 | 694 |
of ordered pairs (Fig.\ts\ref{zf-Un}). Set difference is also included. The |
695 |
rule \tdx{UnCI} is useful for classical reasoning about unions, |
|
3490 | 696 |
like \texttt{disjCI}\@; it supersedes \tdx{UnI1} and |
317 | 697 |
\tdx{UnI2}, but these rules are often easier to work with. For |
104 | 698 |
intersection and difference we have both elimination and destruction rules. |
699 |
Again, there is no reason to provide a minimal rule set. |
|
700 |
||
317 | 701 |
Figure~\ref{zf-upair2} is concerned with finite sets: it presents rules |
3490 | 702 |
for~\texttt{cons}, the finite set constructor, and rules for singleton |
317 | 703 |
sets. Figure~\ref{zf-succ} presents derived rules for the successor |
3490 | 704 |
function, which is defined in terms of~\texttt{cons}. The proof that {\tt |
317 | 705 |
succ} is injective appears to require the Axiom of Foundation. |
104 | 706 |
|
317 | 707 |
Definite descriptions (\sdx{THE}) are defined in terms of the singleton |
708 |
set~$\{0\}$, but their derived rules fortunately hide this |
|
709 |
(Fig.\ts\ref{zf-the}). The rule~\tdx{theI} is difficult to apply |
|
710 |
because of the two occurrences of~$\Var{P}$. However, |
|
711 |
\tdx{the_equality} does not have this problem and the files contain |
|
712 |
many examples of its use. |
|
104 | 713 |
|
714 |
Finally, the impossibility of having both $a\in b$ and $b\in a$ |
|
461 | 715 |
(\tdx{mem_asym}) is proved by applying the Axiom of Foundation to |
104 | 716 |
the set $\{a,b\}$. The impossibility of $a\in a$ is a trivial consequence. |
717 |
||
3490 | 718 |
See the file \texttt{ZF/upair.ML} for full proofs of the rules discussed in |
317 | 719 |
this section. |
104 | 720 |
|
721 |
||
722 |
%%% subset.ML |
|
723 |
||
724 |
\begin{figure} |
|
725 |
\begin{ttbox} |
|
317 | 726 |
\tdx{Union_upper} B:A ==> B <= Union(A) |
727 |
\tdx{Union_least} [| !!x. x:A ==> x<=C |] ==> Union(A) <= C |
|
104 | 728 |
|
317 | 729 |
\tdx{Inter_lower} B:A ==> Inter(A) <= B |
730 |
\tdx{Inter_greatest} [| a:A; !!x. x:A ==> C<=x |] ==> C <= Inter(A) |
|
104 | 731 |
|
317 | 732 |
\tdx{Un_upper1} A <= A Un B |
733 |
\tdx{Un_upper2} B <= A Un B |
|
734 |
\tdx{Un_least} [| A<=C; B<=C |] ==> A Un B <= C |
|
104 | 735 |
|
317 | 736 |
\tdx{Int_lower1} A Int B <= A |
737 |
\tdx{Int_lower2} A Int B <= B |
|
738 |
\tdx{Int_greatest} [| C<=A; C<=B |] ==> C <= A Int B |
|
104 | 739 |
|
317 | 740 |
\tdx{Diff_subset} A-B <= A |
741 |
\tdx{Diff_contains} [| C<=A; C Int B = 0 |] ==> C <= A-B |
|
104 | 742 |
|
317 | 743 |
\tdx{Collect_subset} Collect(A,P) <= A |
104 | 744 |
\end{ttbox} |
317 | 745 |
\caption{Subset and lattice properties} \label{zf-subset} |
104 | 746 |
\end{figure} |
747 |
||
748 |
||
749 |
\subsection{Subset and lattice properties} |
|
317 | 750 |
The subset relation is a complete lattice. Unions form least upper bounds; |
751 |
non-empty intersections form greatest lower bounds. Figure~\ref{zf-subset} |
|
752 |
shows the corresponding rules. A few other laws involving subsets are |
|
3490 | 753 |
included. Proofs are in the file \texttt{ZF/subset.ML}. |
317 | 754 |
|
755 |
Reasoning directly about subsets often yields clearer proofs than |
|
756 |
reasoning about the membership relation. Section~\ref{sec:ZF-pow-example} |
|
757 |
below presents an example of this, proving the equation ${{\tt Pow}(A)\cap |
|
758 |
{\tt Pow}(B)}= {\tt Pow}(A\cap B)$. |
|
104 | 759 |
|
760 |
%%% pair.ML |
|
761 |
||
762 |
\begin{figure} |
|
763 |
\begin{ttbox} |
|
317 | 764 |
\tdx{Pair_inject1} <a,b> = <c,d> ==> a=c |
765 |
\tdx{Pair_inject2} <a,b> = <c,d> ==> b=d |
|
766 |
\tdx{Pair_inject} [| <a,b> = <c,d>; [| a=c; b=d |] ==> P |] ==> P |
|
767 |
\tdx{Pair_neq_0} <a,b>=0 ==> P |
|
104 | 768 |
|
349 | 769 |
\tdx{fst_conv} fst(<a,b>) = a |
770 |
\tdx{snd_conv} snd(<a,b>) = b |
|
317 | 771 |
\tdx{split} split(\%x y.c(x,y), <a,b>) = c(a,b) |
104 | 772 |
|
317 | 773 |
\tdx{SigmaI} [| a:A; b:B(a) |] ==> <a,b> : Sigma(A,B) |
104 | 774 |
|
317 | 775 |
\tdx{SigmaE} [| c: Sigma(A,B); |
776 |
!!x y.[| x:A; y:B(x); c=<x,y> |] ==> P |] ==> P |
|
104 | 777 |
|
317 | 778 |
\tdx{SigmaE2} [| <a,b> : Sigma(A,B); |
779 |
[| a:A; b:B(a) |] ==> P |] ==> P |
|
104 | 780 |
\end{ttbox} |
317 | 781 |
\caption{Ordered pairs; projections; general sums} \label{zf-pair} |
104 | 782 |
\end{figure} |
783 |
||
784 |
||
785 |
\subsection{Ordered pairs} |
|
317 | 786 |
Figure~\ref{zf-pair} presents the rules governing ordered pairs, |
3490 | 787 |
projections and general sums. File \texttt{ZF/pair.ML} contains the |
104 | 788 |
full (and tedious) proof that $\{\{a\},\{a,b\}\}$ functions as an ordered |
789 |
pair. This property is expressed as two destruction rules, |
|
317 | 790 |
\tdx{Pair_inject1} and \tdx{Pair_inject2}, and equivalently |
791 |
as the elimination rule \tdx{Pair_inject}. |
|
104 | 792 |
|
317 | 793 |
The rule \tdx{Pair_neq_0} asserts $\pair{a,b}\neq\emptyset$. This |
114 | 794 |
is a property of $\{\{a\},\{a,b\}\}$, and need not hold for other |
343 | 795 |
encodings of ordered pairs. The non-standard ordered pairs mentioned below |
114 | 796 |
satisfy $\pair{\emptyset;\emptyset}=\emptyset$. |
104 | 797 |
|
317 | 798 |
The natural deduction rules \tdx{SigmaI} and \tdx{SigmaE} |
799 |
assert that \cdx{Sigma}$(A,B)$ consists of all pairs of the form |
|
800 |
$\pair{x,y}$, for $x\in A$ and $y\in B(x)$. The rule \tdx{SigmaE2} |
|
3490 | 801 |
merely states that $\pair{a,b}\in \texttt{Sigma}(A,B)$ implies $a\in A$ and |
104 | 802 |
$b\in B(a)$. |
803 |
||
1449 | 804 |
In addition, it is possible to use tuples as patterns in abstractions: |
805 |
\begin{center} |
|
3490 | 806 |
{\tt\%<$x$,$y$>.$t$} \quad stands for\quad \texttt{split(\%$x$ $y$.$t$)} |
1449 | 807 |
\end{center} |
808 |
Nested patterns are translated recursively: |
|
809 |
{\tt\%<$x$,$y$,$z$>.$t$} $\leadsto$ {\tt\%<$x$,<$y$,$z$>>.$t$} $\leadsto$ |
|
3490 | 810 |
\texttt{split(\%$x$.\%<$y$,$z$>.$t$)} $\leadsto$ \texttt{split(\%$x$.split(\%$y$ |
3486
10cf84e5d2c2
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3149
diff
changeset
|
811 |
$z$.$t$))}. The reverse translation is performed upon printing. |
1449 | 812 |
\begin{warn} |
3490 | 813 |
The translation between patterns and \texttt{split} is performed automatically |
1449 | 814 |
by the parser and printer. Thus the internal and external form of a term |
3149 | 815 |
may differ, which affects proofs. For example the term {\tt |
3490 | 816 |
(\%<x,y>.<y,x>)<a,b>} requires the theorem \texttt{split} to rewrite to |
1449 | 817 |
{\tt<b,a>}. |
818 |
\end{warn} |
|
819 |
In addition to explicit $\lambda$-abstractions, patterns can be used in any |
|
820 |
variable binding construct which is internally described by a |
|
3486
10cf84e5d2c2
Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents:
3149
diff
changeset
|
821 |
$\lambda$-abstraction. Some important examples are |
1449 | 822 |
\begin{description} |
3490 | 823 |
\item[Let:] \texttt{let {\it pattern} = $t$ in $u$} |
824 |
\item[Choice:] \texttt{THE~{\it pattern}~.~$P$} |
|
825 |
\item[Set operations:] \texttt{UN~{\it pattern}:$A$.~$B$} |
|
826 |
\item[Comprehension:] \texttt{{\ttlbrace}~{\it pattern}:$A$~.~$P$~{\ttrbrace}} |
|
1449 | 827 |
\end{description} |
828 |
||
104 | 829 |
|
830 |
%%% domrange.ML |
|
831 |
||
832 |
\begin{figure} |
|
833 |
\begin{ttbox} |
|
317 | 834 |
\tdx{domainI} <a,b>: r ==> a : domain(r) |
835 |
\tdx{domainE} [| a : domain(r); !!y. <a,y>: r ==> P |] ==> P |
|
836 |
\tdx{domain_subset} domain(Sigma(A,B)) <= A |
|
104 | 837 |
|
317 | 838 |
\tdx{rangeI} <a,b>: r ==> b : range(r) |
839 |
\tdx{rangeE} [| b : range(r); !!x. <x,b>: r ==> P |] ==> P |
|
840 |
\tdx{range_subset} range(A*B) <= B |
|
104 | 841 |
|
317 | 842 |
\tdx{fieldI1} <a,b>: r ==> a : field(r) |
843 |
\tdx{fieldI2} <a,b>: r ==> b : field(r) |
|
844 |
\tdx{fieldCI} (~ <c,a>:r ==> <a,b>: r) ==> a : field(r) |
|
104 | 845 |
|
317 | 846 |
\tdx{fieldE} [| a : field(r); |
104 | 847 |
!!x. <a,x>: r ==> P; |
848 |
!!x. <x,a>: r ==> P |
|
849 |
|] ==> P |
|
850 |
||
317 | 851 |
\tdx{field_subset} field(A*A) <= A |
852 |
\end{ttbox} |
|
853 |
\caption{Domain, range and field of a relation} \label{zf-domrange} |
|
854 |
\end{figure} |
|
104 | 855 |
|
317 | 856 |
\begin{figure} |
857 |
\begin{ttbox} |
|
858 |
\tdx{imageI} [| <a,b>: r; a:A |] ==> b : r``A |
|
859 |
\tdx{imageE} [| b: r``A; !!x.[| <x,b>: r; x:A |] ==> P |] ==> P |
|
860 |
||
861 |
\tdx{vimageI} [| <a,b>: r; b:B |] ==> a : r-``B |
|
862 |
\tdx{vimageE} [| a: r-``B; !!x.[| <a,x>: r; x:B |] ==> P |] ==> P |
|
104 | 863 |
\end{ttbox} |
317 | 864 |
\caption{Image and inverse image} \label{zf-domrange2} |
104 | 865 |
\end{figure} |
866 |
||
867 |
||
868 |
\subsection{Relations} |
|
317 | 869 |
Figure~\ref{zf-domrange} presents rules involving relations, which are sets |
104 | 870 |
of ordered pairs. The converse of a relation~$r$ is the set of all pairs |
871 |
$\pair{y,x}$ such that $\pair{x,y}\in r$; if $r$ is a function, then |
|
317 | 872 |
{\cdx{converse}$(r)$} is its inverse. The rules for the domain |
343 | 873 |
operation, namely \tdx{domainI} and~\tdx{domainE}, assert that |
874 |
\cdx{domain}$(r)$ consists of all~$x$ such that $r$ contains |
|
104 | 875 |
some pair of the form~$\pair{x,y}$. The range operation is similar, and |
317 | 876 |
the field of a relation is merely the union of its domain and range. |
877 |
||
878 |
Figure~\ref{zf-domrange2} presents rules for images and inverse images. |
|
343 | 879 |
Note that these operations are generalisations of range and domain, |
3490 | 880 |
respectively. See the file \texttt{ZF/domrange.ML} for derivations of the |
317 | 881 |
rules. |
104 | 882 |
|
883 |
||
884 |
%%% func.ML |
|
885 |
||
886 |
\begin{figure} |
|
887 |
\begin{ttbox} |
|
317 | 888 |
\tdx{fun_is_rel} f: Pi(A,B) ==> f <= Sigma(A,B) |
104 | 889 |
|
317 | 890 |
\tdx{apply_equality} [| <a,b>: f; f: Pi(A,B) |] ==> f`a = b |
891 |
\tdx{apply_equality2} [| <a,b>: f; <a,c>: f; f: Pi(A,B) |] ==> b=c |
|
104 | 892 |
|
317 | 893 |
\tdx{apply_type} [| f: Pi(A,B); a:A |] ==> f`a : B(a) |
894 |
\tdx{apply_Pair} [| f: Pi(A,B); a:A |] ==> <a,f`a>: f |
|
895 |
\tdx{apply_iff} f: Pi(A,B) ==> <a,b>: f <-> a:A & f`a = b |
|
104 | 896 |
|
317 | 897 |
\tdx{fun_extension} [| f : Pi(A,B); g: Pi(A,D); |
104 | 898 |
!!x. x:A ==> f`x = g`x |] ==> f=g |
899 |
||
317 | 900 |
\tdx{domain_type} [| <a,b> : f; f: Pi(A,B) |] ==> a : A |
901 |
\tdx{range_type} [| <a,b> : f; f: Pi(A,B) |] ==> b : B(a) |
|
104 | 902 |
|
317 | 903 |
\tdx{Pi_type} [| f: A->C; !!x. x:A ==> f`x: B(x) |] ==> f: Pi(A,B) |
904 |
\tdx{domain_of_fun} f: Pi(A,B) ==> domain(f)=A |
|
905 |
\tdx{range_of_fun} f: Pi(A,B) ==> f: A->range(f) |
|
104 | 906 |
|
317 | 907 |
\tdx{restrict} a : A ==> restrict(f,A) ` a = f`a |
908 |
\tdx{restrict_type} [| !!x. x:A ==> f`x: B(x) |] ==> |
|
909 |
restrict(f,A) : Pi(A,B) |
|
104 | 910 |
\end{ttbox} |
317 | 911 |
\caption{Functions} \label{zf-func1} |
104 | 912 |
\end{figure} |
913 |
||
914 |
||
915 |
\begin{figure} |
|
916 |
\begin{ttbox} |
|
317 | 917 |
\tdx{lamI} a:A ==> <a,b(a)> : (lam x:A. b(x)) |
918 |
\tdx{lamE} [| p: (lam x:A. b(x)); !!x.[| x:A; p=<x,b(x)> |] ==> P |
|
919 |
|] ==> P |
|
920 |
||
921 |
\tdx{lam_type} [| !!x. x:A ==> b(x): B(x) |] ==> (lam x:A.b(x)) : Pi(A,B) |
|
104 | 922 |
|
317 | 923 |
\tdx{beta} a : A ==> (lam x:A.b(x)) ` a = b(a) |
924 |
\tdx{eta} f : Pi(A,B) ==> (lam x:A. f`x) = f |
|
925 |
\end{ttbox} |
|
926 |
\caption{$\lambda$-abstraction} \label{zf-lam} |
|
927 |
\end{figure} |
|
928 |
||
929 |
||
930 |
\begin{figure} |
|
931 |
\begin{ttbox} |
|
932 |
\tdx{fun_empty} 0: 0->0 |
|
3140 | 933 |
\tdx{fun_single} {\ttlbrace}<a,b>{\ttrbrace} : {\ttlbrace}a{\ttrbrace} -> {\ttlbrace}b{\ttrbrace} |
317 | 934 |
|
935 |
\tdx{fun_disjoint_Un} [| f: A->B; g: C->D; A Int C = 0 |] ==> |
|
104 | 936 |
(f Un g) : (A Un C) -> (B Un D) |
937 |
||
317 | 938 |
\tdx{fun_disjoint_apply1} [| a:A; f: A->B; g: C->D; A Int C = 0 |] ==> |
104 | 939 |
(f Un g)`a = f`a |
940 |
||
317 | 941 |
\tdx{fun_disjoint_apply2} [| c:C; f: A->B; g: C->D; A Int C = 0 |] ==> |
104 | 942 |
(f Un g)`c = g`c |
943 |
\end{ttbox} |
|
317 | 944 |
\caption{Constructing functions from smaller sets} \label{zf-func2} |
104 | 945 |
\end{figure} |
946 |
||
947 |
||
948 |
\subsection{Functions} |
|
949 |
Functions, represented by graphs, are notoriously difficult to reason |
|
3490 | 950 |
about. The file \texttt{ZF/func.ML} derives many rules, which overlap more |
317 | 951 |
than they ought. This section presents the more important rules. |
104 | 952 |
|
317 | 953 |
Figure~\ref{zf-func1} presents the basic properties of \cdx{Pi}$(A,B)$, |
104 | 954 |
the generalized function space. For example, if $f$ is a function and |
317 | 955 |
$\pair{a,b}\in f$, then $f`a=b$ (\tdx{apply_equality}). Two functions |
104 | 956 |
are equal provided they have equal domains and deliver equals results |
317 | 957 |
(\tdx{fun_extension}). |
104 | 958 |
|
317 | 959 |
By \tdx{Pi_type}, a function typing of the form $f\in A\to C$ can be |
104 | 960 |
refined to the dependent typing $f\in\prod@{x\in A}B(x)$, given a suitable |
317 | 961 |
family of sets $\{B(x)\}@{x\in A}$. Conversely, by \tdx{range_of_fun}, |
104 | 962 |
any dependent typing can be flattened to yield a function type of the form |
963 |
$A\to C$; here, $C={\tt range}(f)$. |
|
964 |
||
317 | 965 |
Among the laws for $\lambda$-abstraction, \tdx{lamI} and \tdx{lamE} |
966 |
describe the graph of the generated function, while \tdx{beta} and |
|
967 |
\tdx{eta} are the standard conversions. We essentially have a |
|
968 |
dependently-typed $\lambda$-calculus (Fig.\ts\ref{zf-lam}). |
|
104 | 969 |
|
317 | 970 |
Figure~\ref{zf-func2} presents some rules that can be used to construct |
104 | 971 |
functions explicitly. We start with functions consisting of at most one |
972 |
pair, and may form the union of two functions provided their domains are |
|
973 |
disjoint. |
|
974 |
||
975 |
||
976 |
\begin{figure} |
|
977 |
\begin{ttbox} |
|
317 | 978 |
\tdx{Int_absorb} A Int A = A |
979 |
\tdx{Int_commute} A Int B = B Int A |
|
980 |
\tdx{Int_assoc} (A Int B) Int C = A Int (B Int C) |
|
981 |
\tdx{Int_Un_distrib} (A Un B) Int C = (A Int C) Un (B Int C) |
|
104 | 982 |
|
317 | 983 |
\tdx{Un_absorb} A Un A = A |
984 |
\tdx{Un_commute} A Un B = B Un A |
|
985 |
\tdx{Un_assoc} (A Un B) Un C = A Un (B Un C) |
|
986 |
\tdx{Un_Int_distrib} (A Int B) Un C = (A Un C) Int (B Un C) |
|
104 | 987 |
|
317 | 988 |
\tdx{Diff_cancel} A-A = 0 |
989 |
\tdx{Diff_disjoint} A Int (B-A) = 0 |
|
990 |
\tdx{Diff_partition} A<=B ==> A Un (B-A) = B |
|
991 |
\tdx{double_complement} [| A<=B; B<= C |] ==> (B - (C-A)) = A |
|
992 |
\tdx{Diff_Un} A - (B Un C) = (A-B) Int (A-C) |
|
993 |
\tdx{Diff_Int} A - (B Int C) = (A-B) Un (A-C) |
|
104 | 994 |
|
317 | 995 |
\tdx{Union_Un_distrib} Union(A Un B) = Union(A) Un Union(B) |
996 |
\tdx{Inter_Un_distrib} [| a:A; b:B |] ==> |
|
104 | 997 |
Inter(A Un B) = Inter(A) Int Inter(B) |
998 |
||
317 | 999 |
\tdx{Int_Union_RepFun} A Int Union(B) = (UN C:B. A Int C) |
104 | 1000 |
|
317 | 1001 |
\tdx{Un_Inter_RepFun} b:B ==> |
104 | 1002 |
A Un Inter(B) = (INT C:B. A Un C) |
1003 |
||
317 | 1004 |
\tdx{SUM_Un_distrib1} (SUM x:A Un B. C(x)) = |
104 | 1005 |
(SUM x:A. C(x)) Un (SUM x:B. C(x)) |
1006 |
||
317 | 1007 |
\tdx{SUM_Un_distrib2} (SUM x:C. A(x) Un B(x)) = |
104 | 1008 |
(SUM x:C. A(x)) Un (SUM x:C. B(x)) |
1009 |
||
317 | 1010 |
\tdx{SUM_Int_distrib1} (SUM x:A Int B. C(x)) = |
104 | 1011 |
(SUM x:A. C(x)) Int (SUM x:B. C(x)) |
1012 |
||
317 | 1013 |
\tdx{SUM_Int_distrib2} (SUM x:C. A(x) Int B(x)) = |
104 | 1014 |
(SUM x:C. A(x)) Int (SUM x:C. B(x)) |
1015 |
\end{ttbox} |
|
1016 |
\caption{Equalities} \label{zf-equalities} |
|
1017 |
\end{figure} |
|
1018 |
||
111 | 1019 |
|
1020 |
\begin{figure} |
|
317 | 1021 |
%\begin{constants} |
1022 |
% \cdx{1} & $i$ & & $\{\emptyset\}$ \\ |
|
1023 |
% \cdx{bool} & $i$ & & the set $\{\emptyset,1\}$ \\ |
|
3490 | 1024 |
% \cdx{cond} & $[i,i,i]\To i$ & & conditional for \texttt{bool} \\ |
1025 |
% \cdx{not} & $i\To i$ & & negation for \texttt{bool} \\ |
|
1026 |
% \sdx{and} & $[i,i]\To i$ & Left 70 & conjunction for \texttt{bool} \\ |
|
1027 |
% \sdx{or} & $[i,i]\To i$ & Left 65 & disjunction for \texttt{bool} \\ |
|
1028 |
% \sdx{xor} & $[i,i]\To i$ & Left 65 & exclusive-or for \texttt{bool} |
|
317 | 1029 |
%\end{constants} |
1030 |
% |
|
111 | 1031 |
\begin{ttbox} |
3140 | 1032 |
\tdx{bool_def} bool == {\ttlbrace}0,1{\ttrbrace} |
317 | 1033 |
\tdx{cond_def} cond(b,c,d) == if(b=1,c,d) |
1034 |
\tdx{not_def} not(b) == cond(b,0,1) |
|
1035 |
\tdx{and_def} a and b == cond(a,b,0) |
|
1036 |
\tdx{or_def} a or b == cond(a,1,b) |
|
1037 |
\tdx{xor_def} a xor b == cond(a,not(b),b) |
|
1038 |
||
1039 |
\tdx{bool_1I} 1 : bool |
|
1040 |
\tdx{bool_0I} 0 : bool |
|
1041 |
\tdx{boolE} [| c: bool; c=1 ==> P; c=0 ==> P |] ==> P |
|
1042 |
\tdx{cond_1} cond(1,c,d) = c |
|
1043 |
\tdx{cond_0} cond(0,c,d) = d |
|
1044 |
\end{ttbox} |
|
1045 |
\caption{The booleans} \label{zf-bool} |
|
1046 |
\end{figure} |
|
1047 |
||
1048 |
||
1049 |
\section{Further developments} |
|
1050 |
The next group of developments is complex and extensive, and only |
|
1051 |
highlights can be covered here. It involves many theories and ML files of |
|
1052 |
proofs. |
|
1053 |
||
1054 |
Figure~\ref{zf-equalities} presents commutative, associative, distributive, |
|
1055 |
and idempotency laws of union and intersection, along with other equations. |
|
3490 | 1056 |
See file \texttt{ZF/equalities.ML}. |
317 | 1057 |
|
3490 | 1058 |
Theory \thydx{Bool} defines $\{0,1\}$ as a set of booleans, with the usual |
1059 |
operators including a conditional (Fig.\ts\ref{zf-bool}). Although {\ZF} is a |
|
1060 |
first-order theory, you can obtain the effect of higher-order logic using |
|
1061 |
\texttt{bool}-valued functions, for example. The constant~\texttt{1} is |
|
1062 |
translated to \texttt{succ(0)}. |
|
317 | 1063 |
|
1064 |
\begin{figure} |
|
1065 |
\index{*"+ symbol} |
|
1066 |
\begin{constants} |
|
343 | 1067 |
\it symbol & \it meta-type & \it priority & \it description \\ |
317 | 1068 |
\tt + & $[i,i]\To i$ & Right 65 & disjoint union operator\\ |
1069 |
\cdx{Inl}~~\cdx{Inr} & $i\To i$ & & injections\\ |
|
1070 |
\cdx{case} & $[i\To i,i\To i, i]\To i$ & & conditional for $A+B$ |
|
1071 |
\end{constants} |
|
1072 |
\begin{ttbox} |
|
3140 | 1073 |
\tdx{sum_def} A+B == {\ttlbrace}0{\ttrbrace}*A Un {\ttlbrace}1{\ttrbrace}*B |
317 | 1074 |
\tdx{Inl_def} Inl(a) == <0,a> |
1075 |
\tdx{Inr_def} Inr(b) == <1,b> |
|
1076 |
\tdx{case_def} case(c,d,u) == split(\%y z. cond(y, d(z), c(z)), u) |
|
1077 |
||
1078 |
\tdx{sum_InlI} a : A ==> Inl(a) : A+B |
|
1079 |
\tdx{sum_InrI} b : B ==> Inr(b) : A+B |
|
1080 |
||
1081 |
\tdx{Inl_inject} Inl(a)=Inl(b) ==> a=b |
|
1082 |
\tdx{Inr_inject} Inr(a)=Inr(b) ==> a=b |
|
1083 |
\tdx{Inl_neq_Inr} Inl(a)=Inr(b) ==> P |
|
1084 |
||
1085 |
\tdx{sumE2} u: A+B ==> (EX x. x:A & u=Inl(x)) | (EX y. y:B & u=Inr(y)) |
|
1086 |
||
1087 |
\tdx{case_Inl} case(c,d,Inl(a)) = c(a) |
|
1088 |
\tdx{case_Inr} case(c,d,Inr(b)) = d(b) |
|
1089 |
\end{ttbox} |
|
1090 |
\caption{Disjoint unions} \label{zf-sum} |
|
1091 |
\end{figure} |
|
1092 |
||
1093 |
||
1094 |
Theory \thydx{Sum} defines the disjoint union of two sets, with |
|
1095 |
injections and a case analysis operator (Fig.\ts\ref{zf-sum}). Disjoint |
|
1096 |
unions play a role in datatype definitions, particularly when there is |
|
1097 |
mutual recursion~\cite{paulson-set-II}. |
|
1098 |
||
1099 |
\begin{figure} |
|
1100 |
\begin{ttbox} |
|
1101 |
\tdx{QPair_def} <a;b> == a+b |
|
1102 |
\tdx{qsplit_def} qsplit(c,p) == THE y. EX a b. p=<a;b> & y=c(a,b) |
|
1103 |
\tdx{qfsplit_def} qfsplit(R,z) == EX x y. z=<x;y> & R(x,y) |
|
3140 | 1104 |
\tdx{qconverse_def} qconverse(r) == {\ttlbrace}z. w:r, EX x y. w=<x;y> & z=<y;x>{\ttrbrace} |
1105 |
\tdx{QSigma_def} QSigma(A,B) == UN x:A. UN y:B(x). {\ttlbrace}<x;y>{\ttrbrace} |
|
317 | 1106 |
|
3140 | 1107 |
\tdx{qsum_def} A <+> B == ({\ttlbrace}0{\ttrbrace} <*> A) Un ({\ttlbrace}1{\ttrbrace} <*> B) |
317 | 1108 |
\tdx{QInl_def} QInl(a) == <0;a> |
1109 |
\tdx{QInr_def} QInr(b) == <1;b> |
|
1110 |
\tdx{qcase_def} qcase(c,d) == qsplit(\%y z. cond(y, d(z), c(z))) |
|
1111 |
\end{ttbox} |
|
1112 |
\caption{Non-standard pairs, products and sums} \label{zf-qpair} |
|
1113 |
\end{figure} |
|
1114 |
||
1115 |
Theory \thydx{QPair} defines a notion of ordered pair that admits |
|
1116 |
non-well-founded tupling (Fig.\ts\ref{zf-qpair}). Such pairs are written |
|
1117 |
{\tt<$a$;$b$>}. It also defines the eliminator \cdx{qsplit}, the |
|
1118 |
converse operator \cdx{qconverse}, and the summation operator |
|
1119 |
\cdx{QSigma}. These are completely analogous to the corresponding |
|
1120 |
versions for standard ordered pairs. The theory goes on to define a |
|
1121 |
non-standard notion of disjoint sum using non-standard pairs. All of these |
|
1122 |
concepts satisfy the same properties as their standard counterparts; in |
|
1123 |
addition, {\tt<$a$;$b$>} is continuous. The theory supports coinductive |
|
1124 |
definitions, for example of infinite lists~\cite{paulson-final}. |
|
1125 |
||
1126 |
\begin{figure} |
|
1127 |
\begin{ttbox} |
|
1128 |
\tdx{bnd_mono_def} bnd_mono(D,h) == |
|
111 | 1129 |
h(D)<=D & (ALL W X. W<=X --> X<=D --> h(W) <= h(X)) |
1130 |
||
3140 | 1131 |
\tdx{lfp_def} lfp(D,h) == Inter({\ttlbrace}X: Pow(D). h(X) <= X{\ttrbrace}) |
1132 |
\tdx{gfp_def} gfp(D,h) == Union({\ttlbrace}X: Pow(D). X <= h(X){\ttrbrace}) |
|
317 | 1133 |
|
111 | 1134 |
|
317 | 1135 |
\tdx{lfp_lowerbound} [| h(A) <= A; A<=D |] ==> lfp(D,h) <= A |
111 | 1136 |
|
317 | 1137 |
\tdx{lfp_subset} lfp(D,h) <= D |
111 | 1138 |
|
317 | 1139 |
\tdx{lfp_greatest} [| bnd_mono(D,h); |
111 | 1140 |
!!X. [| h(X) <= X; X<=D |] ==> A<=X |
1141 |
|] ==> A <= lfp(D,h) |
|
1142 |
||
317 | 1143 |
\tdx{lfp_Tarski} bnd_mono(D,h) ==> lfp(D,h) = h(lfp(D,h)) |
111 | 1144 |
|
317 | 1145 |
\tdx{induct} [| a : lfp(D,h); bnd_mono(D,h); |
111 | 1146 |
!!x. x : h(Collect(lfp(D,h),P)) ==> P(x) |
1147 |
|] ==> P(a) |
|
1148 |
||
317 | 1149 |
\tdx{lfp_mono} [| bnd_mono(D,h); bnd_mono(E,i); |
111 | 1150 |
!!X. X<=D ==> h(X) <= i(X) |
1151 |
|] ==> lfp(D,h) <= lfp(E,i) |
|
1152 |
||
317 | 1153 |
\tdx{gfp_upperbound} [| A <= h(A); A<=D |] ==> A <= gfp(D,h) |
111 | 1154 |
|
317 | 1155 |
\tdx{gfp_subset} gfp(D,h) <= D |
111 | 1156 |
|
317 | 1157 |
\tdx{gfp_least} [| bnd_mono(D,h); |
111 | 1158 |
!!X. [| X <= h(X); X<=D |] ==> X<=A |
1159 |
|] ==> gfp(D,h) <= A |
|
1160 |
||
317 | 1161 |
\tdx{gfp_Tarski} bnd_mono(D,h) ==> gfp(D,h) = h(gfp(D,h)) |
111 | 1162 |
|
317 | 1163 |
\tdx{coinduct} [| bnd_mono(D,h); a: X; X <= h(X Un gfp(D,h)); X <= D |
111 | 1164 |
|] ==> a : gfp(D,h) |
1165 |
||
317 | 1166 |
\tdx{gfp_mono} [| bnd_mono(D,h); D <= E; |
111 | 1167 |
!!X. X<=D ==> h(X) <= i(X) |
1168 |
|] ==> gfp(D,h) <= gfp(E,i) |
|
1169 |
\end{ttbox} |
|
1170 |
\caption{Least and greatest fixedpoints} \label{zf-fixedpt} |
|
1171 |
\end{figure} |
|
1172 |
||
317 | 1173 |
The Knaster-Tarski Theorem states that every monotone function over a |
1174 |
complete lattice has a fixedpoint. Theory \thydx{Fixedpt} proves the |
|
1175 |
Theorem only for a particular lattice, namely the lattice of subsets of a |
|
1176 |
set (Fig.\ts\ref{zf-fixedpt}). The theory defines least and greatest |
|
1177 |
fixedpoint operators with corresponding induction and coinduction rules. |
|
1178 |
These are essential to many definitions that follow, including the natural |
|
1179 |
numbers and the transitive closure operator. The (co)inductive definition |
|
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1180 |
package also uses the fixedpoint operators~\cite{paulson-CADE}. See |
317 | 1181 |
Davey and Priestley~\cite{davey&priestley} for more on the Knaster-Tarski |
1182 |
Theorem and my paper~\cite{paulson-set-II} for discussion of the Isabelle |
|
1183 |
proofs. |
|
1184 |
||
1185 |
Monotonicity properties are proved for most of the set-forming operations: |
|
1186 |
union, intersection, Cartesian product, image, domain, range, etc. These |
|
1187 |
are useful for applying the Knaster-Tarski Fixedpoint Theorem. The proofs |
|
1188 |
themselves are trivial applications of Isabelle's classical reasoner. See |
|
3490 | 1189 |
file \texttt{ZF/mono.ML}. |
317 | 1190 |
|
111 | 1191 |
|
104 | 1192 |
\begin{figure} |
317 | 1193 |
\begin{constants} |
1194 |
\it symbol & \it meta-type & \it priority & \it description \\ |
|
1195 |
\sdx{O} & $[i,i]\To i$ & Right 60 & composition ($\circ$) \\ |
|
349 | 1196 |
\cdx{id} & $i\To i$ & & identity function \\ |
317 | 1197 |
\cdx{inj} & $[i,i]\To i$ & & injective function space\\ |
1198 |
\cdx{surj} & $[i,i]\To i$ & & surjective function space\\ |
|
1199 |
\cdx{bij} & $[i,i]\To i$ & & bijective function space |
|
1200 |
\end{constants} |
|
1201 |
||
104 | 1202 |
\begin{ttbox} |
3140 | 1203 |
\tdx{comp_def} r O s == {\ttlbrace}xz : domain(s)*range(r) . |
1204 |
EX x y z. xz=<x,z> & <x,y>:s & <y,z>:r{\ttrbrace} |
|
317 | 1205 |
\tdx{id_def} id(A) == (lam x:A. x) |
3140 | 1206 |
\tdx{inj_def} inj(A,B) == {\ttlbrace} f: A->B. ALL w:A. ALL x:A. f`w=f`x --> w=x {\ttrbrace} |
1207 |
\tdx{surj_def} surj(A,B) == {\ttlbrace} f: A->B . ALL y:B. EX x:A. f`x=y {\ttrbrace} |
|
317 | 1208 |
\tdx{bij_def} bij(A,B) == inj(A,B) Int surj(A,B) |
104 | 1209 |
|
317 | 1210 |
|
1211 |
\tdx{left_inverse} [| f: inj(A,B); a: A |] ==> converse(f)`(f`a) = a |
|
1212 |
\tdx{right_inverse} [| f: inj(A,B); b: range(f) |] ==> |
|
104 | 1213 |
f`(converse(f)`b) = b |
1214 |
||
317 | 1215 |
\tdx{inj_converse_inj} f: inj(A,B) ==> converse(f): inj(range(f), A) |
1216 |
\tdx{bij_converse_bij} f: bij(A,B) ==> converse(f): bij(B,A) |
|
104 | 1217 |
|
317 | 1218 |
\tdx{comp_type} [| s<=A*B; r<=B*C |] ==> (r O s) <= A*C |
1219 |
\tdx{comp_assoc} (r O s) O t = r O (s O t) |
|
104 | 1220 |
|
317 | 1221 |
\tdx{left_comp_id} r<=A*B ==> id(B) O r = r |
1222 |
\tdx{right_comp_id} r<=A*B ==> r O id(A) = r |
|
104 | 1223 |
|
317 | 1224 |
\tdx{comp_func} [| g:A->B; f:B->C |] ==> (f O g):A->C |
1225 |
\tdx{comp_func_apply} [| g:A->B; f:B->C; a:A |] ==> (f O g)`a = f`(g`a) |
|
104 | 1226 |
|
317 | 1227 |
\tdx{comp_inj} [| g:inj(A,B); f:inj(B,C) |] ==> (f O g):inj(A,C) |
1228 |
\tdx{comp_surj} [| g:surj(A,B); f:surj(B,C) |] ==> (f O g):surj(A,C) |
|
1229 |
\tdx{comp_bij} [| g:bij(A,B); f:bij(B,C) |] ==> (f O g):bij(A,C) |
|
104 | 1230 |
|
317 | 1231 |
\tdx{left_comp_inverse} f: inj(A,B) ==> converse(f) O f = id(A) |
1232 |
\tdx{right_comp_inverse} f: surj(A,B) ==> f O converse(f) = id(B) |
|
104 | 1233 |
|
317 | 1234 |
\tdx{bij_disjoint_Un} |
104 | 1235 |
[| f: bij(A,B); g: bij(C,D); A Int C = 0; B Int D = 0 |] ==> |
1236 |
(f Un g) : bij(A Un C, B Un D) |
|
1237 |
||
317 | 1238 |
\tdx{restrict_bij} [| f:inj(A,B); C<=A |] ==> restrict(f,C): bij(C, f``C) |
104 | 1239 |
\end{ttbox} |
1240 |
\caption{Permutations} \label{zf-perm} |
|
1241 |
\end{figure} |
|
1242 |
||
317 | 1243 |
The theory \thydx{Perm} is concerned with permutations (bijections) and |
1244 |
related concepts. These include composition of relations, the identity |
|
1245 |
relation, and three specialized function spaces: injective, surjective and |
|
1246 |
bijective. Figure~\ref{zf-perm} displays many of their properties that |
|
1247 |
have been proved. These results are fundamental to a treatment of |
|
1248 |
equipollence and cardinality. |
|
104 | 1249 |
|
3133 | 1250 |
\begin{figure}\small |
317 | 1251 |
\index{#*@{\tt\#*} symbol} |
1252 |
\index{*div symbol} |
|
1253 |
\index{*mod symbol} |
|
1254 |
\index{#+@{\tt\#+} symbol} |
|
1255 |
\index{#-@{\tt\#-} symbol} |
|
1256 |
\begin{constants} |
|
1257 |
\it symbol & \it meta-type & \it priority & \it description \\ |
|
1258 |
\cdx{nat} & $i$ & & set of natural numbers \\ |
|
1259 |
\cdx{nat_case}& $[i,i\To i,i]\To i$ & & conditional for $nat$\\ |
|
1260 |
\cdx{rec} & $[i,i,[i,i]\To i]\To i$ & & recursor for $nat$\\ |
|
1261 |
\tt \#* & $[i,i]\To i$ & Left 70 & multiplication \\ |
|
1262 |
\tt div & $[i,i]\To i$ & Left 70 & division\\ |
|
1263 |
\tt mod & $[i,i]\To i$ & Left 70 & modulus\\ |
|
1264 |
\tt \#+ & $[i,i]\To i$ & Left 65 & addition\\ |
|
1265 |
\tt \#- & $[i,i]\To i$ & Left 65 & subtraction |
|
1266 |
\end{constants} |
|
111 | 1267 |
|
317 | 1268 |
\begin{ttbox} |
3140 | 1269 |
\tdx{nat_def} nat == lfp(lam r: Pow(Inf). {\ttlbrace}0{\ttrbrace} Un {\ttlbrace}succ(x). x:r{\ttrbrace} |
317 | 1270 |
|
1271 |
\tdx{nat_case_def} nat_case(a,b,k) == |
|
1272 |
THE y. k=0 & y=a | (EX x. k=succ(x) & y=b(x)) |
|
1273 |
||
1274 |
\tdx{rec_def} rec(k,a,b) == |
|
1275 |
transrec(k, \%n f. nat_case(a, \%m. b(m, f`m), n)) |
|
1276 |
||
1277 |
\tdx{add_def} m#+n == rec(m, n, \%u v.succ(v)) |
|
1278 |
\tdx{diff_def} m#-n == rec(n, m, \%u v. rec(v, 0, \%x y.x)) |
|
1279 |
\tdx{mult_def} m#*n == rec(m, 0, \%u v. n #+ v) |
|
1280 |
\tdx{mod_def} m mod n == transrec(m, \%j f. if(j:n, j, f`(j#-n))) |
|
1281 |
\tdx{div_def} m div n == transrec(m, \%j f. if(j:n, 0, succ(f`(j#-n)))) |
|
111 | 1282 |
|
1283 |
||
317 | 1284 |
\tdx{nat_0I} 0 : nat |
1285 |
\tdx{nat_succI} n : nat ==> succ(n) : nat |
|
104 | 1286 |
|
317 | 1287 |
\tdx{nat_induct} |
104 | 1288 |
[| n: nat; P(0); !!x. [| x: nat; P(x) |] ==> P(succ(x)) |
1289 |
|] ==> P(n) |
|
1290 |
||
317 | 1291 |
\tdx{nat_case_0} nat_case(a,b,0) = a |
1292 |
\tdx{nat_case_succ} nat_case(a,b,succ(m)) = b(m) |
|
104 | 1293 |
|
317 | 1294 |
\tdx{rec_0} rec(0,a,b) = a |
1295 |
\tdx{rec_succ} rec(succ(m),a,b) = b(m, rec(m,a,b)) |
|
104 | 1296 |
|
317 | 1297 |
\tdx{mult_type} [| m:nat; n:nat |] ==> m #* n : nat |
1298 |
\tdx{mult_0} 0 #* n = 0 |
|
1299 |
\tdx{mult_succ} succ(m) #* n = n #+ (m #* n) |
|
3133 | 1300 |
\tdx{mult_commute} [| m:nat; n:nat |] ==> m #* n = n #* m |
3140 | 1301 |
\tdx{add_mult_dist} [| m:nat; k:nat |] ==> (m #+ n) #* k = (m #* k){\thinspace}#+{\thinspace}(n #* k) |
317 | 1302 |
\tdx{mult_assoc} |
104 | 1303 |
[| m:nat; n:nat; k:nat |] ==> (m #* n) #* k = m #* (n #* k) |
317 | 1304 |
\tdx{mod_quo_equality} |
104 | 1305 |
[| 0:n; m:nat; n:nat |] ==> (m div n)#*n #+ m mod n = m |
1306 |
\end{ttbox} |
|
1307 |
\caption{The natural numbers} \label{zf-nat} |
|
1308 |
\end{figure} |
|
1309 |
||
317 | 1310 |
Theory \thydx{Nat} defines the natural numbers and mathematical |
1311 |
induction, along with a case analysis operator. The set of natural |
|
3490 | 1312 |
numbers, here called \texttt{nat}, is known in set theory as the ordinal~$\omega$. |
317 | 1313 |
|
1314 |
Theory \thydx{Arith} defines primitive recursion and goes on to develop |
|
1315 |
arithmetic on the natural numbers (Fig.\ts\ref{zf-nat}). It defines |
|
1316 |
addition, multiplication, subtraction, division, and remainder. Many of |
|
1317 |
their properties are proved: commutative, associative and distributive |
|
1318 |
laws, identity and cancellation laws, etc. The most interesting result is |
|
1319 |
perhaps the theorem $a \bmod b + (a/b)\times b = a$. Division and |
|
1320 |
remainder are defined by repeated subtraction, which requires well-founded |
|
1321 |
rather than primitive recursion; the termination argument relies on the |
|
1322 |
divisor's being non-zero. |
|
1323 |
||
3490 | 1324 |
Theory \thydx{Univ} defines a `universe' $\texttt{univ}(A)$, for |
317 | 1325 |
constructing datatypes such as trees. This set contains $A$ and the |
1326 |
natural numbers. Vitally, it is closed under finite products: ${\tt |
|
1327 |
univ}(A)\times{\tt univ}(A)\subseteq{\tt univ}(A)$. This theory also |
|
1328 |
defines the cumulative hierarchy of axiomatic set theory, which |
|
1329 |
traditionally is written $V@\alpha$ for an ordinal~$\alpha$. The |
|
1330 |
`universe' is a simple generalization of~$V@\omega$. |
|
1331 |
||
1332 |
Theory \thydx{QUniv} defines a `universe' ${\tt quniv}(A)$, for |
|
1333 |
constructing codatatypes such as streams. It is analogous to ${\tt |
|
1334 |
univ}(A)$ (and is defined in terms of it) but is closed under the |
|
1335 |
non-standard product and sum. |
|
1336 |
||
3490 | 1337 |
Theory \texttt{Finite} (Figure~\ref{zf-fin}) defines the finite set operator; |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1338 |
${\tt Fin}(A)$ is the set of all finite sets over~$A$. The theory employs |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1339 |
Isabelle's inductive definition package, which proves various rules |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1340 |
automatically. The induction rule shown is stronger than the one proved by |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1341 |
the package. The theory also defines the set of all finite functions |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1342 |
between two given sets. |
317 | 1343 |
|
111 | 1344 |
\begin{figure} |
1345 |
\begin{ttbox} |
|
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1346 |
\tdx{Fin.emptyI} 0 : Fin(A) |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1347 |
\tdx{Fin.consI} [| a: A; b: Fin(A) |] ==> cons(a,b) : Fin(A) |
111 | 1348 |
|
317 | 1349 |
\tdx{Fin_induct} |
111 | 1350 |
[| b: Fin(A); |
1351 |
P(0); |
|
1352 |
!!x y. [| x: A; y: Fin(A); x~:y; P(y) |] ==> P(cons(x,y)) |
|
1353 |
|] ==> P(b) |
|
1354 |
||
317 | 1355 |
\tdx{Fin_mono} A<=B ==> Fin(A) <= Fin(B) |
1356 |
\tdx{Fin_UnI} [| b: Fin(A); c: Fin(A) |] ==> b Un c : Fin(A) |
|
1357 |
\tdx{Fin_UnionI} C : Fin(Fin(A)) ==> Union(C) : Fin(A) |
|
1358 |
\tdx{Fin_subset} [| c<=b; b: Fin(A) |] ==> c: Fin(A) |
|
111 | 1359 |
\end{ttbox} |
1360 |
\caption{The finite set operator} \label{zf-fin} |
|
1361 |
\end{figure} |
|
1362 |
||
317 | 1363 |
\begin{figure} |
1364 |
\begin{constants} |
|
1365 |
\cdx{list} & $i\To i$ && lists over some set\\ |
|
1366 |
\cdx{list_case} & $[i, [i,i]\To i, i] \To i$ && conditional for $list(A)$ \\ |
|
1367 |
\cdx{list_rec} & $[i, i, [i,i,i]\To i] \To i$ && recursor for $list(A)$ \\ |
|
1368 |
\cdx{map} & $[i\To i, i] \To i$ & & mapping functional\\ |
|
1369 |
\cdx{length} & $i\To i$ & & length of a list\\ |
|
1370 |
\cdx{rev} & $i\To i$ & & reverse of a list\\ |
|
1371 |
\tt \at & $[i,i]\To i$ & Right 60 & append for lists\\ |
|
1372 |
\cdx{flat} & $i\To i$ & & append of list of lists |
|
1373 |
\end{constants} |
|
1374 |
||
1375 |
\underscoreon %%because @ is used here |
|
104 | 1376 |
\begin{ttbox} |
317 | 1377 |
\tdx{list_rec_def} list_rec(l,c,h) == |
287 | 1378 |
Vrec(l, \%l g.list_case(c, \%x xs. h(x, xs, g`xs), l)) |
104 | 1379 |
|
317 | 1380 |
\tdx{map_def} map(f,l) == list_rec(l, 0, \%x xs r. <f(x), r>) |
1381 |
\tdx{length_def} length(l) == list_rec(l, 0, \%x xs r. succ(r)) |
|
1382 |
\tdx{app_def} xs@ys == list_rec(xs, ys, \%x xs r. <x,r>) |
|
1383 |
\tdx{rev_def} rev(l) == list_rec(l, 0, \%x xs r. r @ <x,0>) |
|
1384 |
\tdx{flat_def} flat(ls) == list_rec(ls, 0, \%l ls r. l @ r) |
|
104 | 1385 |
|
1386 |
||
317 | 1387 |
\tdx{NilI} Nil : list(A) |
1388 |
\tdx{ConsI} [| a: A; l: list(A) |] ==> Cons(a,l) : list(A) |
|
1389 |
||
1390 |
\tdx{List.induct} |
|
104 | 1391 |
[| l: list(A); |
111 | 1392 |
P(Nil); |
1393 |
!!x y. [| x: A; y: list(A); P(y) |] ==> P(Cons(x,y)) |
|
104 | 1394 |
|] ==> P(l) |
1395 |
||
317 | 1396 |
\tdx{Cons_iff} Cons(a,l)=Cons(a',l') <-> a=a' & l=l' |
1397 |
\tdx{Nil_Cons_iff} ~ Nil=Cons(a,l) |
|
104 | 1398 |
|
317 | 1399 |
\tdx{list_mono} A<=B ==> list(A) <= list(B) |
111 | 1400 |
|
317 | 1401 |
\tdx{list_rec_Nil} list_rec(Nil,c,h) = c |
1402 |
\tdx{list_rec_Cons} list_rec(Cons(a,l), c, h) = h(a, l, list_rec(l,c,h)) |
|
104 | 1403 |
|
317 | 1404 |
\tdx{map_ident} l: list(A) ==> map(\%u.u, l) = l |
1405 |
\tdx{map_compose} l: list(A) ==> map(h, map(j,l)) = map(\%u.h(j(u)), l) |
|
1406 |
\tdx{map_app_distrib} xs: list(A) ==> map(h, xs@ys) = map(h,xs) @ map(h,ys) |
|
1407 |
\tdx{map_type} |
|
104 | 1408 |
[| l: list(A); !!x. x: A ==> h(x): B |] ==> map(h,l) : list(B) |
317 | 1409 |
\tdx{map_flat} |
104 | 1410 |
ls: list(list(A)) ==> map(h, flat(ls)) = flat(map(map(h),ls)) |
1411 |
\end{ttbox} |
|
1412 |
\caption{Lists} \label{zf-list} |
|
1413 |
\end{figure} |
|
1414 |
||
111 | 1415 |
|
1416 |
Figure~\ref{zf-list} presents the set of lists over~$A$, ${\tt list}(A)$. |
|
1417 |
The definition employs Isabelle's datatype package, which defines the |
|
1418 |
introduction and induction rules automatically, as well as the constructors |
|
3490 | 1419 |
and case operator (\verb|list_case|). See file \texttt{ZF/List.ML}. |
1420 |
The file \texttt{ZF/ListFn.thy} proceeds to define structural |
|
111 | 1421 |
recursion and the usual list functions. |
104 | 1422 |
|
1423 |
The constructions of the natural numbers and lists make use of a suite of |
|
317 | 1424 |
operators for handling recursive function definitions. I have described |
1425 |
the developments in detail elsewhere~\cite{paulson-set-II}. Here is a brief |
|
1426 |
summary: |
|
1427 |
\begin{itemize} |
|
3490 | 1428 |
\item Theory \texttt{Trancl} defines the transitive closure of a relation |
317 | 1429 |
(as a least fixedpoint). |
104 | 1430 |
|
3490 | 1431 |
\item Theory \texttt{WF} proves the Well-Founded Recursion Theorem, using an |
317 | 1432 |
elegant approach of Tobias Nipkow. This theorem permits general |
1433 |
recursive definitions within set theory. |
|
1434 |
||
3490 | 1435 |
\item Theory \texttt{Ord} defines the notions of transitive set and ordinal |
317 | 1436 |
number. It derives transfinite induction. A key definition is {\bf |
1437 |
less than}: $i<j$ if and only if $i$ and $j$ are both ordinals and |
|
1438 |
$i\in j$. As a special case, it includes less than on the natural |
|
1439 |
numbers. |
|
3140 | 1440 |
|
3490 | 1441 |
\item Theory \texttt{Epsilon} derives $\varepsilon$-induction and |
3140 | 1442 |
$\varepsilon$-recursion, which are generalisations of transfinite |
1443 |
induction and recursion. It also defines \cdx{rank}$(x)$, which |
|
1444 |
is the least ordinal $\alpha$ such that $x$ is constructed at |
|
1445 |
stage $\alpha$ of the cumulative hierarchy (thus $x\in |
|
1446 |
V@{\alpha+1}$). |
|
317 | 1447 |
\end{itemize} |
1448 |
||
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1449 |
Other important theories lead to a theory of cardinal numbers. They have |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1450 |
not yet been written up anywhere. Here is a summary: |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1451 |
\begin{itemize} |
3490 | 1452 |
\item Theory \texttt{Rel} defines the basic properties of relations, such as |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1453 |
(ir)reflexivity, (a)symmetry, and transitivity. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1454 |
|
3490 | 1455 |
\item Theory \texttt{EquivClass} develops a theory of equivalence |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1456 |
classes, not using the Axiom of Choice. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1457 |
|
3490 | 1458 |
\item Theory \texttt{Order} defines partial orderings, total orderings and |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1459 |
wellorderings. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1460 |
|
3490 | 1461 |
\item Theory \texttt{OrderArith} defines orderings on sum and product sets. |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1462 |
These can be used to define ordinal arithmetic and have applications to |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1463 |
cardinal arithmetic. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1464 |
|
3490 | 1465 |
\item Theory \texttt{OrderType} defines order types. Every wellordering is |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1466 |
equivalent to a unique ordinal, which is its order type. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1467 |
|
3490 | 1468 |
\item Theory \texttt{Cardinal} defines equipollence and cardinal numbers. |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1469 |
|
3490 | 1470 |
\item Theory \texttt{CardinalArith} defines cardinal addition and |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1471 |
multiplication, and proves their elementary laws. It proves that there |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1472 |
is no greatest cardinal. It also proves a deep result, namely |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1473 |
$\kappa\otimes\kappa=\kappa$ for every infinite cardinal~$\kappa$; see |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1474 |
Kunen~\cite[page 29]{kunen80}. None of these results assume the Axiom of |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1475 |
Choice, which complicates their proofs considerably. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1476 |
\end{itemize} |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1477 |
|
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1478 |
The following developments involve the Axiom of Choice (AC): |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1479 |
\begin{itemize} |
3490 | 1480 |
\item Theory \texttt{AC} asserts the Axiom of Choice and proves some simple |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1481 |
equivalent forms. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1482 |
|
3490 | 1483 |
\item Theory \texttt{Zorn} proves Hausdorff's Maximal Principle, Zorn's Lemma |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1484 |
and the Wellordering Theorem, following Abrial and |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1485 |
Laffitte~\cite{abrial93}. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1486 |
|
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1487 |
\item Theory \verb|Cardinal_AC| uses AC to prove simplified theorems about |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1488 |
the cardinals. It also proves a theorem needed to justify |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1489 |
infinitely branching datatype declarations: if $\kappa$ is an infinite |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1490 |
cardinal and $|X(\alpha)| \le \kappa$ for all $\alpha<\kappa$ then |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1491 |
$|\union\sb{\alpha<\kappa} X(\alpha)| \le \kappa$. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1492 |
|
3490 | 1493 |
\item Theory \texttt{InfDatatype} proves theorems to justify infinitely |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1494 |
branching datatypes. Arbitrary index sets are allowed, provided their |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1495 |
cardinalities have an upper bound. The theory also justifies some |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1496 |
unusual cases of finite branching, involving the finite powerset operator |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1497 |
and the finite function space operator. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1498 |
\end{itemize} |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1499 |
|
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1500 |
|
104 | 1501 |
|
317 | 1502 |
\section{Simplification rules} |
1503 |
{\ZF} does not merely inherit simplification from \FOL, but modifies it |
|
3490 | 1504 |
extensively. File \texttt{ZF/simpdata.ML} contains the details. |
317 | 1505 |
|
1506 |
The extraction of rewrite rules takes set theory primitives into account. |
|
1507 |
It can strip bounded universal quantifiers from a formula; for example, |
|
1508 |
${\forall x\in A.f(x)=g(x)}$ yields the conditional rewrite rule $x\in A \Imp |
|
1509 |
f(x)=g(x)$. Given $a\in\{x\in A.P(x)\}$ it extracts rewrite rules from |
|
1510 |
$a\in A$ and~$P(a)$. It can also break down $a\in A\int B$ and $a\in A-B$. |
|
1511 |
||
2495 | 1512 |
The default simplification set contains congruence rules for |
317 | 1513 |
all the binding operators of {\ZF}\@. It contains all the conversion |
3490 | 1514 |
rules, such as \texttt{fst} and \texttt{snd}, as well as the rewrites |
2495 | 1515 |
shown in Fig.\ts\ref{zf-simpdata}. See the file |
3490 | 1516 |
\texttt{ZF/simpdata.ML} for a fuller list. |
104 | 1517 |
|
1518 |
\begin{figure} |
|
1519 |
\begin{eqnarray*} |
|
111 | 1520 |
a\in \emptyset & \bimp & \bot\\ |
3149 | 1521 |
a \in A \un B & \bimp & a\in A \disj a\in B\\ |
1522 |
a \in A \int B & \bimp & a\in A \conj a\in B\\ |
|
111 | 1523 |
a \in A-B & \bimp & a\in A \conj \neg (a\in B)\\ |
104 | 1524 |
\pair{a,b}\in {\tt Sigma}(A,B) |
111 | 1525 |
& \bimp & a\in A \conj b\in B(a)\\ |
1526 |
a \in {\tt Collect}(A,P) & \bimp & a\in A \conj P(a)\\ |
|
343 | 1527 |
(\forall x \in \emptyset. P(x)) & \bimp & \top\\ |
111 | 1528 |
(\forall x \in A. \top) & \bimp & \top |
104 | 1529 |
\end{eqnarray*} |
2495 | 1530 |
\caption{Some rewrite rules for set theory} \label{zf-simpdata} |
104 | 1531 |
\end{figure} |
1532 |
||
1533 |
||
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1534 |
\section{The examples directories} |
3490 | 1535 |
Directory \texttt{HOL/IMP} contains a mechanised version of a semantic |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1536 |
equivalence proof taken from Winskel~\cite{winskel93}. It formalises the |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1537 |
denotational and operational semantics of a simple while-language, then |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1538 |
proves the two equivalent. It contains several datatype and inductive |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1539 |
definitions, and demonstrates their use. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1540 |
|
3490 | 1541 |
The directory \texttt{ZF/ex} contains further developments in {\ZF} set |
317 | 1542 |
theory. Here is an overview; see the files themselves for more details. I |
1543 |
describe much of this material in other |
|
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1544 |
publications~\cite{paulson-set-I,paulson-set-II,paulson-CADE}. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1545 |
\begin{itemize} |
3490 | 1546 |
\item File \texttt{misc.ML} contains miscellaneous examples such as |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1547 |
Cantor's Theorem, the Schr\"oder-Bernstein Theorem and the `Composition |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1548 |
of homomorphisms' challenge~\cite{boyer86}. |
104 | 1549 |
|
3490 | 1550 |
\item Theory \texttt{Ramsey} proves the finite exponent 2 version of |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1551 |
Ramsey's Theorem, following Basin and Kaufmann's |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1552 |
presentation~\cite{basin91}. |
114 | 1553 |
|
3490 | 1554 |
\item Theory \texttt{Integ} develops a theory of the integers as |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1555 |
equivalence classes of pairs of natural numbers. |
114 | 1556 |
|
3490 | 1557 |
\item Theory \texttt{Primrec} develops some computation theory. It |
1558 |
inductively defines the set of primitive recursive functions and presents a |
|
1559 |
proof that Ackermann's function is not primitive recursive. |
|
1560 |
||
1561 |
\item Theory \texttt{Primes} defines the Greatest Common Divisor of two |
|
1562 |
natural numbers and and the ``divides'' relation. |
|
1563 |
||
1564 |
\item Theory \texttt{Bin} defines a datatype for two's complement binary |
|
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1565 |
integers, then proves rewrite rules to perform binary arithmetic. For |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1566 |
instance, $1359\times {-}2468 = {-}3354012$ takes under 14 seconds. |
104 | 1567 |
|
3490 | 1568 |
\item Theory \texttt{BT} defines the recursive data structure ${\tt |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1569 |
bt}(A)$, labelled binary trees. |
104 | 1570 |
|
3490 | 1571 |
\item Theory \texttt{Term} defines a recursive data structure for terms |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1572 |
and term lists. These are simply finite branching trees. |
104 | 1573 |
|
3490 | 1574 |
\item Theory \texttt{TF} defines primitives for solving mutually |
114 | 1575 |
recursive equations over sets. It constructs sets of trees and forests |
1576 |
as an example, including induction and recursion rules that handle the |
|
1577 |
mutual recursion. |
|
1578 |
||
3490 | 1579 |
\item Theory \texttt{Prop} proves soundness and completeness of |
343 | 1580 |
propositional logic~\cite{paulson-set-II}. This illustrates datatype |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1581 |
definitions, inductive definitions, structural induction and rule |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1582 |
induction. |
114 | 1583 |
|
3490 | 1584 |
\item Theory \texttt{ListN} inductively defines the lists of $n$ |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1585 |
elements~\cite{paulin92}. |
104 | 1586 |
|
3490 | 1587 |
\item Theory \texttt{Acc} inductively defines the accessible part of a |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1588 |
relation~\cite{paulin92}. |
114 | 1589 |
|
3490 | 1590 |
\item Theory \texttt{Comb} defines the datatype of combinators and |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1591 |
inductively defines contraction and parallel contraction. It goes on to |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1592 |
prove the Church-Rosser Theorem. This case study follows Camilleri and |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1593 |
Melham~\cite{camilleri92}. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1594 |
|
3490 | 1595 |
\item Theory \texttt{LList} defines lazy lists and a coinduction |
595
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1596 |
principle for proving equations between them. |
96c87d5bb015
Added mention of directory IMP; tidied the section on examples.
lcp
parents:
498
diff
changeset
|
1597 |
\end{itemize} |
104 | 1598 |
|
1599 |
||
317 | 1600 |
\section{A proof about powersets}\label{sec:ZF-pow-example} |
114 | 1601 |
To demonstrate high-level reasoning about subsets, let us prove the |
1602 |
equation ${{\tt Pow}(A)\cap {\tt Pow}(B)}= {\tt Pow}(A\cap B)$. Compared |
|
1603 |
with first-order logic, set theory involves a maze of rules, and theorems |
|
1604 |
have many different proofs. Attempting other proofs of the theorem might |
|
1605 |
be instructive. This proof exploits the lattice properties of |
|
1606 |
intersection. It also uses the monotonicity of the powerset operation, |
|
3490 | 1607 |
from \texttt{ZF/mono.ML}: |
104 | 1608 |
\begin{ttbox} |
317 | 1609 |
\tdx{Pow_mono} A<=B ==> Pow(A) <= Pow(B) |
104 | 1610 |
\end{ttbox} |
1611 |
We enter the goal and make the first step, which breaks the equation into |
|
317 | 1612 |
two inclusions by extensionality:\index{*equalityI theorem} |
104 | 1613 |
\begin{ttbox} |
2495 | 1614 |
goal thy "Pow(A Int B) = Pow(A) Int Pow(B)"; |
104 | 1615 |
{\out Level 0} |
1616 |
{\out Pow(A Int B) = Pow(A) Int Pow(B)} |
|
1617 |
{\out 1. Pow(A Int B) = Pow(A) Int Pow(B)} |
|
287 | 1618 |
\ttbreak |
104 | 1619 |
by (resolve_tac [equalityI] 1); |
1620 |
{\out Level 1} |
|
1621 |
{\out Pow(A Int B) = Pow(A) Int Pow(B)} |
|
1622 |
{\out 1. Pow(A Int B) <= Pow(A) Int Pow(B)} |
|
1623 |
{\out 2. Pow(A) Int Pow(B) <= Pow(A Int B)} |
|
1624 |
\end{ttbox} |
|
3490 | 1625 |
Both inclusions could be tackled straightforwardly using \texttt{subsetI}. |
104 | 1626 |
A shorter proof results from noting that intersection forms the greatest |
317 | 1627 |
lower bound:\index{*Int_greatest theorem} |
104 | 1628 |
\begin{ttbox} |
1629 |
by (resolve_tac [Int_greatest] 1); |
|
1630 |
{\out Level 2} |
|
1631 |
{\out Pow(A Int B) = Pow(A) Int Pow(B)} |
|
1632 |
{\out 1. Pow(A Int B) <= Pow(A)} |
|
1633 |
{\out 2. Pow(A Int B) <= Pow(B)} |
|
1634 |
{\out 3. Pow(A) Int Pow(B) <= Pow(A Int B)} |
|
1635 |
\end{ttbox} |
|
3490 | 1636 |
Subgoal~1 follows by applying the monotonicity of \texttt{Pow} to $A\int |
104 | 1637 |
B\subseteq A$; subgoal~2 follows similarly: |
317 | 1638 |
\index{*Int_lower1 theorem}\index{*Int_lower2 theorem} |
104 | 1639 |
\begin{ttbox} |
1640 |
by (resolve_tac [Int_lower1 RS Pow_mono] 1); |
|
1641 |
{\out Level 3} |
|
1642 |
{\out Pow(A Int B) = Pow(A) Int Pow(B)} |
|
1643 |
{\out 1. Pow(A Int B) <= Pow(B)} |
|
1644 |
{\out 2. Pow(A) Int Pow(B) <= Pow(A Int B)} |
|
287 | 1645 |
\ttbreak |
104 | 1646 |
by (resolve_tac [Int_lower2 RS Pow_mono] 1); |
1647 |
{\out Level 4} |
|
1648 |
{\out Pow(A Int B) = Pow(A) Int Pow(B)} |
|
1649 |
{\out 1. Pow(A) Int Pow(B) <= Pow(A Int B)} |
|
1650 |
\end{ttbox} |
|
1651 |
We are left with the opposite inclusion, which we tackle in the |
|
317 | 1652 |
straightforward way:\index{*subsetI theorem} |
104 | 1653 |
\begin{ttbox} |
1654 |
by (resolve_tac [subsetI] 1); |
|
1655 |
{\out Level 5} |
|
1656 |
{\out Pow(A Int B) = Pow(A) Int Pow(B)} |
|
1657 |
{\out 1. !!x. x : Pow(A) Int Pow(B) ==> x : Pow(A Int B)} |
|
1658 |
\end{ttbox} |
|
1659 |
The subgoal is to show $x\in {\tt Pow}(A\cap B)$ assuming $x\in{\tt |
|
287 | 1660 |
Pow}(A)\cap {\tt Pow}(B)$; eliminating this assumption produces two |
317 | 1661 |
subgoals. The rule \tdx{IntE} treats the intersection like a conjunction |
287 | 1662 |
instead of unfolding its definition. |
104 | 1663 |
\begin{ttbox} |
1664 |
by (eresolve_tac [IntE] 1); |
|
1665 |
{\out Level 6} |
|
1666 |
{\out Pow(A Int B) = Pow(A) Int Pow(B)} |
|
1667 |
{\out 1. !!x. [| x : Pow(A); x : Pow(B) |] ==> x : Pow(A Int B)} |
|
1668 |
\end{ttbox} |
|
3490 | 1669 |
The next step replaces the \texttt{Pow} by the subset |
317 | 1670 |
relation~($\subseteq$).\index{*PowI theorem} |
104 | 1671 |
\begin{ttbox} |
1672 |
by (resolve_tac [PowI] 1); |
|
1673 |
{\out Level 7} |
|
1674 |
{\out Pow(A Int B) = Pow(A) Int Pow(B)} |
|
1675 |
{\out 1. !!x. [| x : Pow(A); x : Pow(B) |] ==> x <= A Int B} |
|
1676 |
\end{ttbox} |
|
287 | 1677 |
We perform the same replacement in the assumptions. This is a good |
317 | 1678 |
demonstration of the tactic \ttindex{dresolve_tac}:\index{*PowD theorem} |
104 | 1679 |
\begin{ttbox} |
1680 |
by (REPEAT (dresolve_tac [PowD] 1)); |
|
1681 |
{\out Level 8} |
|
1682 |
{\out Pow(A Int B) = Pow(A) Int Pow(B)} |
|
1683 |
{\out 1. !!x. [| x <= A; x <= B |] ==> x <= A Int B} |
|
1684 |
\end{ttbox} |
|
287 | 1685 |
The assumptions are that $x$ is a lower bound of both $A$ and~$B$, but |
3149 | 1686 |
$A\int B$ is the greatest lower bound:\index{*Int_greatest theorem} |
104 | 1687 |
\begin{ttbox} |
1688 |
by (resolve_tac [Int_greatest] 1); |
|
1689 |
{\out Level 9} |
|
1690 |
{\out Pow(A Int B) = Pow(A) Int Pow(B)} |
|
1691 |
{\out 1. !!x. [| x <= A; x <= B |] ==> x <= A} |
|
1692 |
{\out 2. !!x. [| x <= A; x <= B |] ==> x <= B} |
|
287 | 1693 |
\end{ttbox} |
1694 |
To conclude the proof, we clear up the trivial subgoals: |
|
1695 |
\begin{ttbox} |
|
104 | 1696 |
by (REPEAT (assume_tac 1)); |
1697 |
{\out Level 10} |
|
1698 |
{\out Pow(A Int B) = Pow(A) Int Pow(B)} |
|
1699 |
{\out No subgoals!} |
|
1700 |
\end{ttbox} |
|
287 | 1701 |
\medskip |
104 | 1702 |
We could have performed this proof in one step by applying |
3133 | 1703 |
\ttindex{Blast_tac}. Let us |
287 | 1704 |
go back to the start: |
104 | 1705 |
\begin{ttbox} |
1706 |
choplev 0; |
|
1707 |
{\out Level 0} |
|
1708 |
{\out Pow(A Int B) = Pow(A) Int Pow(B)} |
|
1709 |
{\out 1. Pow(A Int B) = Pow(A) Int Pow(B)} |
|
3133 | 1710 |
by (Blast_tac 1); |
1711 |
{\out Depth = 0} |
|
1712 |
{\out Depth = 1} |
|
1713 |
{\out Depth = 2} |
|
1714 |
{\out Depth = 3} |
|
104 | 1715 |
{\out Level 1} |
1716 |
{\out Pow(A Int B) = Pow(A) Int Pow(B)} |
|
1717 |
{\out No subgoals!} |
|
1718 |
\end{ttbox} |
|
3133 | 1719 |
Past researchers regarded this as a difficult proof, as indeed it is if all |
287 | 1720 |
the symbols are replaced by their definitions. |
1721 |
\goodbreak |
|
104 | 1722 |
|
1723 |
\section{Monotonicity of the union operator} |
|
1724 |
For another example, we prove that general union is monotonic: |
|
1725 |
${C\subseteq D}$ implies $\bigcup(C)\subseteq \bigcup(D)$. To begin, we |
|
317 | 1726 |
tackle the inclusion using \tdx{subsetI}: |
104 | 1727 |
\begin{ttbox} |
2495 | 1728 |
val [prem] = goal thy "C<=D ==> Union(C) <= Union(D)"; |
104 | 1729 |
{\out Level 0} |
1730 |
{\out Union(C) <= Union(D)} |
|
1731 |
{\out 1. Union(C) <= Union(D)} |
|
114 | 1732 |
{\out val prem = "C <= D [C <= D]" : thm} |
1733 |
\ttbreak |
|
104 | 1734 |
by (resolve_tac [subsetI] 1); |
1735 |
{\out Level 1} |
|
1736 |
{\out Union(C) <= Union(D)} |
|
1737 |
{\out 1. !!x. x : Union(C) ==> x : Union(D)} |
|
1738 |
\end{ttbox} |
|
1739 |
Big union is like an existential quantifier --- the occurrence in the |
|
1740 |
assumptions must be eliminated early, since it creates parameters. |
|
317 | 1741 |
\index{*UnionE theorem} |
104 | 1742 |
\begin{ttbox} |
1743 |
by (eresolve_tac [UnionE] 1); |
|
1744 |
{\out Level 2} |
|
1745 |
{\out Union(C) <= Union(D)} |
|
1746 |
{\out 1. !!x B. [| x : B; B : C |] ==> x : Union(D)} |
|
1747 |
\end{ttbox} |
|
317 | 1748 |
Now we may apply \tdx{UnionI}, which creates an unknown involving the |
104 | 1749 |
parameters. To show $x\in \bigcup(D)$ it suffices to show that $x$ belongs |
1750 |
to some element, say~$\Var{B2}(x,B)$, of~$D$. |
|
1751 |
\begin{ttbox} |
|
1752 |
by (resolve_tac [UnionI] 1); |
|
1753 |
{\out Level 3} |
|
1754 |
{\out Union(C) <= Union(D)} |
|
1755 |
{\out 1. !!x B. [| x : B; B : C |] ==> ?B2(x,B) : D} |
|
1756 |
{\out 2. !!x B. [| x : B; B : C |] ==> x : ?B2(x,B)} |
|
1757 |
\end{ttbox} |
|
317 | 1758 |
Combining \tdx{subsetD} with the premise $C\subseteq D$ yields |
104 | 1759 |
$\Var{a}\in C \Imp \Var{a}\in D$, which reduces subgoal~1: |
1760 |
\begin{ttbox} |
|
1761 |
by (resolve_tac [prem RS subsetD] 1); |
|
1762 |
{\out Level 4} |
|
1763 |
{\out Union(C) <= Union(D)} |
|
1764 |
{\out 1. !!x B. [| x : B; B : C |] ==> ?B2(x,B) : C} |
|
1765 |
{\out 2. !!x B. [| x : B; B : C |] ==> x : ?B2(x,B)} |
|
1766 |
\end{ttbox} |
|
1767 |
The rest is routine. Note how~$\Var{B2}(x,B)$ is instantiated. |
|
1768 |
\begin{ttbox} |
|
1769 |
by (assume_tac 1); |
|
1770 |
{\out Level 5} |
|
1771 |
{\out Union(C) <= Union(D)} |
|
1772 |
{\out 1. !!x B. [| x : B; B : C |] ==> x : B} |
|
1773 |
by (assume_tac 1); |
|
1774 |
{\out Level 6} |
|
1775 |
{\out Union(C) <= Union(D)} |
|
1776 |
{\out No subgoals!} |
|
1777 |
\end{ttbox} |
|
3133 | 1778 |
Again, \ttindex{Blast_tac} can prove the theorem in one |
3490 | 1779 |
step, provided we somehow supply it with~\texttt{prem}. We can add |
3133 | 1780 |
\hbox{\tt prem RS subsetD} to the claset as an introduction rule: |
1781 |
\begin{ttbox} |
|
1782 |
by (blast_tac (!claset addIs [prem RS subsetD]) 1); |
|
1783 |
{\out Depth = 0} |
|
1784 |
{\out Depth = 1} |
|
1785 |
{\out Depth = 2} |
|
1786 |
{\out Level 1} |
|
1787 |
{\out Union(C) <= Union(D)} |
|
1788 |
{\out No subgoals!} |
|
1789 |
\end{ttbox} |
|
1790 |
As an alternative, we could add premise to the assumptions, either using |
|
1791 |
\ttindex{cut_facts_tac} or by stating the original goal using~\texttt{!!}: |
|
1792 |
\begin{ttbox} |
|
1793 |
goal thy "!!C D. C<=D ==> Union(C) <= Union(D)"; |
|
1794 |
{\out Level 0} |
|
1795 |
{\out Union(C) <= Union(D)} |
|
1796 |
{\out 1. !!C D. C <= D ==> Union(C) <= Union(D)} |
|
1797 |
by (Blast_tac 1); |
|
1798 |
\end{ttbox} |
|
104 | 1799 |
|
3490 | 1800 |
The file \texttt{ZF/equalities.ML} has many similar proofs. Reasoning about |
343 | 1801 |
general intersection can be difficult because of its anomalous behaviour on |
3133 | 1802 |
the empty set. However, \ttindex{Blast_tac} copes well with these. Here is |
317 | 1803 |
a typical example, borrowed from Devlin~\cite[page 12]{devlin79}: |
104 | 1804 |
\begin{ttbox} |
1805 |
a:C ==> (INT x:C. A(x) Int B(x)) = (INT x:C.A(x)) Int (INT x:C.B(x)) |
|
1806 |
\end{ttbox} |
|
1807 |
In traditional notation this is |
|
317 | 1808 |
\[ a\in C \,\Imp\, \inter@{x\in C} \Bigl(A(x) \int B(x)\Bigr) = |
1809 |
\Bigl(\inter@{x\in C} A(x)\Bigr) \int |
|
1810 |
\Bigl(\inter@{x\in C} B(x)\Bigr) \] |
|
104 | 1811 |
|
1812 |
\section{Low-level reasoning about functions} |
|
3490 | 1813 |
The derived rules \texttt{lamI}, \texttt{lamE}, \texttt{lam_type}, \texttt{beta} |
1814 |
and \texttt{eta} support reasoning about functions in a |
|
104 | 1815 |
$\lambda$-calculus style. This is generally easier than regarding |
1816 |
functions as sets of ordered pairs. But sometimes we must look at the |
|
1817 |
underlying representation, as in the following proof |
|
317 | 1818 |
of~\tdx{fun_disjoint_apply1}. This states that if $f$ and~$g$ are |
104 | 1819 |
functions with disjoint domains~$A$ and~$C$, and if $a\in A$, then |
287 | 1820 |
$(f\un g)`a = f`a$: |
104 | 1821 |
\begin{ttbox} |
2495 | 1822 |
val prems = goal thy |
104 | 1823 |
"[| a:A; f: A->B; g: C->D; A Int C = 0 |] ==> \ttback |
1824 |
\ttback (f Un g)`a = f`a"; |
|
1825 |
{\out Level 0} |
|
1826 |
{\out (f Un g) ` a = f ` a} |
|
1827 |
{\out 1. (f Un g) ` a = f ` a} |
|
287 | 1828 |
\end{ttbox} |
1829 |
Isabelle has produced the output above; the \ML{} top-level now echoes the |
|
3490 | 1830 |
binding of \texttt{prems}. |
287 | 1831 |
\begin{ttbox} |
114 | 1832 |
{\out val prems = ["a : A [a : A]",} |
1833 |
{\out "f : A -> B [f : A -> B]",} |
|
1834 |
{\out "g : C -> D [g : C -> D]",} |
|
1835 |
{\out "A Int C = 0 [A Int C = 0]"] : thm list} |
|
104 | 1836 |
\end{ttbox} |
317 | 1837 |
Using \tdx{apply_equality}, we reduce the equality to reasoning about |
287 | 1838 |
ordered pairs. The second subgoal is to verify that $f\un g$ is a function. |
104 | 1839 |
\begin{ttbox} |
1840 |
by (resolve_tac [apply_equality] 1); |
|
1841 |
{\out Level 1} |
|
1842 |
{\out (f Un g) ` a = f ` a} |
|
1843 |
{\out 1. <a,f ` a> : f Un g} |
|
1844 |
{\out 2. f Un g : (PROD x:?A. ?B(x))} |
|
1845 |
\end{ttbox} |
|
317 | 1846 |
We must show that the pair belongs to~$f$ or~$g$; by~\tdx{UnI1} we |
104 | 1847 |
choose~$f$: |
1848 |
\begin{ttbox} |
|
1849 |
by (resolve_tac [UnI1] 1); |
|
1850 |
{\out Level 2} |
|
1851 |
{\out (f Un g) ` a = f ` a} |
|
1852 |
{\out 1. <a,f ` a> : f} |
|
1853 |
{\out 2. f Un g : (PROD x:?A. ?B(x))} |
|
1854 |
\end{ttbox} |
|
317 | 1855 |
To show $\pair{a,f`a}\in f$ we use \tdx{apply_Pair}, which is |
1856 |
essentially the converse of \tdx{apply_equality}: |
|
104 | 1857 |
\begin{ttbox} |
1858 |
by (resolve_tac [apply_Pair] 1); |
|
1859 |
{\out Level 3} |
|
1860 |
{\out (f Un g) ` a = f ` a} |
|
1861 |
{\out 1. f : (PROD x:?A2. ?B2(x))} |
|
1862 |
{\out 2. a : ?A2} |
|
1863 |
{\out 3. f Un g : (PROD x:?A. ?B(x))} |
|
1864 |
\end{ttbox} |
|
1865 |
Using the premises $f\in A\to B$ and $a\in A$, we solve the two subgoals |
|
317 | 1866 |
from \tdx{apply_Pair}. Recall that a $\Pi$-set is merely a generalized |
3490 | 1867 |
function space, and observe that~{\tt?A2} is instantiated to~\texttt{A}. |
104 | 1868 |
\begin{ttbox} |
1869 |
by (resolve_tac prems 1); |
|
1870 |
{\out Level 4} |
|
1871 |
{\out (f Un g) ` a = f ` a} |
|
1872 |
{\out 1. a : A} |
|
1873 |
{\out 2. f Un g : (PROD x:?A. ?B(x))} |
|
1874 |
by (resolve_tac prems 1); |
|
1875 |
{\out Level 5} |
|
1876 |
{\out (f Un g) ` a = f ` a} |
|
1877 |
{\out 1. f Un g : (PROD x:?A. ?B(x))} |
|
1878 |
\end{ttbox} |
|
3149 | 1879 |
To construct functions of the form $f\un g$, we apply |
317 | 1880 |
\tdx{fun_disjoint_Un}: |
104 | 1881 |
\begin{ttbox} |
1882 |
by (resolve_tac [fun_disjoint_Un] 1); |
|
1883 |
{\out Level 6} |
|
1884 |
{\out (f Un g) ` a = f ` a} |
|
1885 |
{\out 1. f : ?A3 -> ?B3} |
|
1886 |
{\out 2. g : ?C3 -> ?D3} |
|
1887 |
{\out 3. ?A3 Int ?C3 = 0} |
|
1888 |
\end{ttbox} |
|
1889 |
The remaining subgoals are instances of the premises. Again, observe how |
|
1890 |
unknowns are instantiated: |
|
1891 |
\begin{ttbox} |
|
1892 |
by (resolve_tac prems 1); |
|
1893 |
{\out Level 7} |
|
1894 |
{\out (f Un g) ` a = f ` a} |
|
1895 |
{\out 1. g : ?C3 -> ?D3} |
|
1896 |
{\out 2. A Int ?C3 = 0} |
|
1897 |
by (resolve_tac prems 1); |
|
1898 |
{\out Level 8} |
|
1899 |
{\out (f Un g) ` a = f ` a} |
|
1900 |
{\out 1. A Int C = 0} |
|
1901 |
by (resolve_tac prems 1); |
|
1902 |
{\out Level 9} |
|
1903 |
{\out (f Un g) ` a = f ` a} |
|
1904 |
{\out No subgoals!} |
|
1905 |
\end{ttbox} |
|
3490 | 1906 |
See the files \texttt{ZF/func.ML} and \texttt{ZF/WF.ML} for more |
104 | 1907 |
examples of reasoning about functions. |
317 | 1908 |
|
1909 |
\index{set theory|)} |