doc-src/Logics/ZF.tex
changeset 287 6b62a6ddbe15
parent 131 bb0caac13eff
child 317 8a96a64e0b35
equal deleted inserted replaced
286:e7efbf03562b 287:6b62a6ddbe15
     1 %% $Id$
     1 %% $Id$
     2 %%%See grant/bra/Lib/ZF.tex for lfp figure
     2 %%%See grant/bra/Lib/ZF.tex for lfp figure
     3 \chapter{Zermelo-Fraenkel set theory}
     3 \chapter{Zermelo-Fraenkel Set Theory}
     4 The directory~\ttindexbold{ZF} implements Zermelo-Fraenkel set
     4 The directory~\ttindexbold{ZF} implements Zermelo-Fraenkel set
     5 theory~\cite{halmos60,suppes72} as an extension of~\ttindex{FOL}, classical
     5 theory~\cite{halmos60,suppes72} as an extension of~\ttindex{FOL}, classical
     6 first-order logic.  The theory includes a collection of derived natural
     6 first-order logic.  The theory includes a collection of derived natural
     7 deduction rules, for use with Isabelle's classical reasoning module.  Much
     7 deduction rules, for use with Isabelle's classical reasoning module.  Much
     8 of it is based on the work of No\"el~\cite{noel}.  The theory has the {\ML}
     8 of it is based on the work of No\"el~\cite{noel}.  The theory has the {\ML}
   160 \end{eqnarray*}
   160 \end{eqnarray*}
   161 
   161 
   162 The constant \ttindexbold{Pair} constructs ordered pairs, as in {\tt
   162 The constant \ttindexbold{Pair} constructs ordered pairs, as in {\tt
   163 Pair($a$,$b$)}.  Ordered pairs may also be written within angle brackets,
   163 Pair($a$,$b$)}.  Ordered pairs may also be written within angle brackets,
   164 as {\tt<$a$,$b$>}.  The $n$-tuple {\tt<$a@1$,\ldots,$a@{n-1}$,$a@n$>}
   164 as {\tt<$a$,$b$>}.  The $n$-tuple {\tt<$a@1$,\ldots,$a@{n-1}$,$a@n$>}
   165 abbreviates the nest of pairs {\tt
   165 abbreviates the nest of pairs 
   166   Pair($a@1$,\ldots,Pair($a@{n-1}$,$a@n$)\ldots)}. 
   166 \begin{quote}
       
   167   \tt Pair($a@1$,\ldots,Pair($a@{n-1}$,$a@n$)\ldots).
       
   168 \end{quote}
   167 
   169 
   168 In {\ZF}, a function is a set of pairs.  A {\ZF} function~$f$ is simply an
   170 In {\ZF}, a function is a set of pairs.  A {\ZF} function~$f$ is simply an
   169 individual as far as Isabelle is concerned: its Isabelle type is~$i$, not
   171 individual as far as Isabelle is concerned: its Isabelle type is~$i$, not
   170 say $i\To i$.  The infix operator~{\tt`} denotes the application of a
   172 say $i\To i$.  The infix operator~{\tt`} denotes the application of a
   171 function set to its argument; we must write~$f{\tt`}x$, not~$f(x)$.  The
   173 function set to its argument; we must write~$f{\tt`}x$, not~$f(x)$.  The
   173 
   175 
   174 
   176 
   175 \begin{figure} 
   177 \begin{figure} 
   176 \indexbold{*"-">}
   178 \indexbold{*"-">}
   177 \indexbold{*"*}
   179 \indexbold{*"*}
   178 \begin{center} \tt\frenchspacing
   180 \begin{center} \footnotesize\tt\frenchspacing
   179 \begin{tabular}{rrr} 
   181 \begin{tabular}{rrr} 
   180   \it external          & \it internal  & \it description \\ 
   182   \it external          & \it internal  & \it description \\ 
   181   $a$ \ttilde: $b$      & \ttilde($a$ : $b$)    & \rm negated membership\\
   183   $a$ \ttilde: $b$      & \ttilde($a$ : $b$)    & \rm negated membership\\
   182   \{$a@1$, $\ldots$, $a@n$\}  &  cons($a@1$,$\cdots$,cons($a@n$,0)) &
   184   \{$a@1$, $\ldots$, $a@n$\}  &  cons($a@1$,$\cdots$,cons($a@n$,0)) &
   183         \rm finite set \\
   185         \rm finite set \\
   278 predicate is also called a {\bf class function}.
   280 predicate is also called a {\bf class function}.
   279 
   281 
   280 The constant \ttindexbold{RepFun} expresses a special case of replacement,
   282 The constant \ttindexbold{RepFun} expresses a special case of replacement,
   281 where $Q[x,y]$ has the form $y=b[x]$.  Such a $Q$ is trivially
   283 where $Q[x,y]$ has the form $y=b[x]$.  Such a $Q$ is trivially
   282 single-valued, since it is just the graph of the meta-level
   284 single-valued, since it is just the graph of the meta-level
   283 function~$\lambda x.b[x]$.  The syntax is \hbox{\tt\{$b[x]$.$x$:$A$\}},
   285 function~$\lambda x.b[x]$.  The resulting set consists of all $b[x]$
   284 denoting set {\tt RepFun($A$,$\lambda x.b[x]$)} of all $b[x]$ for~$x\in A$.
   286 for~$x\in A$.  This is analogous to the \ML{} functional {\tt map}, since
   285 This is analogous to the \ML{} functional {\tt map}, since it applies a
   287 it applies a function to every element of a set.  The syntax is
   286 function to every element of a set.
   288 \hbox{\tt\{$b[x]$.$x$:$A$\}}, which expands to {\tt RepFun($A$,$\lambda
   287 
   289   x.b[x]$)}.
   288 \indexbold{*INT}\indexbold{*UN}
   290 
   289 General unions and intersections of families, namely $\bigcup@{x\in A}B[x]$ and
   291 
   290 $\bigcap@{x\in A}B[x]$, are written \hbox{\tt UN $x$:$A$.$B[x]$} and
   292 \indexbold{*INT}\indexbold{*UN} 
   291 \hbox{\tt INT $x$:$A$.$B[x]$}.  Their meaning is expressed using {\tt
   293 General unions and intersections of indexed
   292 RepFun} as
   294 families of sets, namely $\bigcup@{x\in A}B[x]$ and $\bigcap@{x\in A}B[x]$,
       
   295 are written \hbox{\tt UN $x$:$A$.$B[x]$} and \hbox{\tt INT $x$:$A$.$B[x]$}.
       
   296 Their meaning is expressed using {\tt RepFun} as
   293 \[ \bigcup(\{B[x]. x\in A\}) \qquad\hbox{and}\qquad 
   297 \[ \bigcup(\{B[x]. x\in A\}) \qquad\hbox{and}\qquad 
   294    \bigcap(\{B[x]. x\in A\}). 
   298    \bigcap(\{B[x]. x\in A\}). 
   295 \]
   299 \]
   296 General sums $\sum@{x\in A}B[x]$ and products $\prod@{x\in A}B[x]$ can be
   300 General sums $\sum@{x\in A}B[x]$ and products $\prod@{x\in A}B[x]$ can be
   297 constructed in set theory, where $B[x]$ is a family of sets over~$A$.  They
   301 constructed in set theory, where $B[x]$ is a family of sets over~$A$.  They
   353 \idx{replacement}        (ALL x:A. ALL y z. P(x,y) & P(x,z) --> y=z) ==>
   357 \idx{replacement}        (ALL x:A. ALL y z. P(x,y) & P(x,z) --> y=z) ==>
   354                    b : PrimReplace(A,P) <-> (EX x:A. P(x,b))
   358                    b : PrimReplace(A,P) <-> (EX x:A. P(x,b))
   355 \subcaption{The Zermelo-Fraenkel Axioms}
   359 \subcaption{The Zermelo-Fraenkel Axioms}
   356 
   360 
   357 \idx{Replace_def}  Replace(A,P) == 
   361 \idx{Replace_def}  Replace(A,P) == 
   358                    PrimReplace(A, %x y. (EX!z.P(x,z)) & P(x,y))
   362                    PrimReplace(A, \%x y. (EX!z.P(x,z)) & P(x,y))
   359 \idx{RepFun_def}   RepFun(A,f)  == \{y . x:A, y=f(x)\}
   363 \idx{RepFun_def}   RepFun(A,f)  == \{y . x:A, y=f(x)\}
   360 \idx{the_def}      The(P)       == Union(\{y . x:\{0\}, P(y)\})
   364 \idx{the_def}      The(P)       == Union(\{y . x:\{0\}, P(y)\})
   361 \idx{if_def}       if(P,a,b)    == THE z. P & z=a | ~P & z=b
   365 \idx{if_def}       if(P,a,b)    == THE z. P & z=a | ~P & z=b
   362 \idx{Collect_def}  Collect(A,P) == \{y . x:A, x=y & P(x)\}
   366 \idx{Collect_def}  Collect(A,P) == \{y . x:A, x=y & P(x)\}
   363 \idx{Upair_def}    Upair(a,b)   == 
   367 \idx{Upair_def}    Upair(a,b)   == 
   381 \idx{infinity}     0:Inf & (ALL y:Inf. succ(y): Inf)
   385 \idx{infinity}     0:Inf & (ALL y:Inf. succ(y): Inf)
   382 \subcaption{Finite and infinite sets}
   386 \subcaption{Finite and infinite sets}
   383 
   387 
   384 \idx{Pair_def}       <a,b>      == \{\{a,a\}, \{a,b\}\}
   388 \idx{Pair_def}       <a,b>      == \{\{a,a\}, \{a,b\}\}
   385 \idx{split_def}      split(c,p) == THE y. EX a b. p=<a,b> & y=c(a,b)
   389 \idx{split_def}      split(c,p) == THE y. EX a b. p=<a,b> & y=c(a,b)
   386 \idx{fst_def}        fst(A)     == split(%x y.x, p)
   390 \idx{fst_def}        fst(A)     == split(\%x y.x, p)
   387 \idx{snd_def}        snd(A)     == split(%x y.y, p)
   391 \idx{snd_def}        snd(A)     == split(\%x y.y, p)
   388 \idx{Sigma_def}      Sigma(A,B) == UN x:A. UN y:B(x). \{<x,y>\}
   392 \idx{Sigma_def}      Sigma(A,B) == UN x:A. UN y:B(x). \{<x,y>\}
   389 \subcaption{Ordered pairs and Cartesian products}
   393 \subcaption{Ordered pairs and Cartesian products}
   390 
   394 
   391 \idx{converse_def}   converse(r) == \{z. w:r, EX x y. w=<x,y> & z=<y,x>\}
   395 \idx{converse_def}   converse(r) == \{z. w:r, EX x y. w=<x,y> & z=<y,x>\}
   392 \idx{domain_def}     domain(r)   == \{x. w:r, EX y. w=<x,y>\}
   396 \idx{domain_def}     domain(r)   == \{x. w:r, EX y. w=<x,y>\}
   493 \caption{General Union and Intersection} \label{ZF-lemmas3}
   497 \caption{General Union and Intersection} \label{ZF-lemmas3}
   494 \end{figure}
   498 \end{figure}
   495 
   499 
   496 
   500 
   497 \section{The Zermelo-Fraenkel axioms}
   501 \section{The Zermelo-Fraenkel axioms}
   498 The axioms appear in Figure~\ref{ZF-rules}.  They resemble those
   502 The axioms appear in Fig.\ts \ref{ZF-rules}.  They resemble those
   499 presented by Suppes~\cite{suppes72}.  Most of the theory consists of
   503 presented by Suppes~\cite{suppes72}.  Most of the theory consists of
   500 definitions.  In particular, bounded quantifiers and the subset relation
   504 definitions.  In particular, bounded quantifiers and the subset relation
   501 appear in other axioms.  Object-level quantifiers and implications have
   505 appear in other axioms.  Object-level quantifiers and implications have
   502 been replaced by meta-level ones wherever possible, to simplify use of the
   506 been replaced by meta-level ones wherever possible, to simplify use of the
   503 axioms.  See the file \ttindexbold{ZF/zf.thy} for details.
   507 axioms.  See the file {\tt ZF/zf.thy} for details.
   504 
   508 
   505 The traditional replacement axiom asserts
   509 The traditional replacement axiom asserts
   506 \[ y \in {\tt PrimReplace}(A,P) \bimp (\exists x\in A. P(x,y)) \]
   510 \[ y \in {\tt PrimReplace}(A,P) \bimp (\exists x\in A. P(x,y)) \]
   507 subject to the condition that $P(x,y)$ is single-valued for all~$x\in A$.
   511 subject to the condition that $P(x,y)$ is single-valued for all~$x\in A$.
   508 The Isabelle theory defines \ttindex{Replace} to apply
   512 The Isabelle theory defines \ttindex{Replace} to apply
   525 The axiom of infinity gives us a set that contains~0 and is closed under
   529 The axiom of infinity gives us a set that contains~0 and is closed under
   526 successor (\ttindexbold{succ}).  Although this set is not uniquely defined,
   530 successor (\ttindexbold{succ}).  Although this set is not uniquely defined,
   527 the theory names it (\ttindexbold{Inf}) in order to simplify the
   531 the theory names it (\ttindexbold{Inf}) in order to simplify the
   528 construction of the natural numbers.
   532 construction of the natural numbers.
   529                                              
   533                                              
   530 Further definitions appear in Figure~\ref{ZF-defs}.  Ordered pairs are
   534 Further definitions appear in Fig.\ts\ref{ZF-defs}.  Ordered pairs are
   531 defined in the standard way, $\pair{a,b}\equiv\{\{a\},\{a,b\}\}$.  Recall
   535 defined in the standard way, $\pair{a,b}\equiv\{\{a\},\{a,b\}\}$.  Recall
   532 that \ttindexbold{Sigma}$(A,B)$ generalizes the Cartesian product of two
   536 that \ttindexbold{Sigma}$(A,B)$ generalizes the Cartesian product of two
   533 sets.  It is defined to be the union of all singleton sets
   537 sets.  It is defined to be the union of all singleton sets
   534 $\{\pair{x,y}\}$, for $x\in A$ and $y\in B(x)$.  This is a typical usage of
   538 $\{\pair{x,y}\}$, for $x\in A$ and $y\in B(x)$.  This is a typical usage of
   535 general union.
   539 general union.
   582 natural deduction rules for \ttindex{Collect}.  The elimination rule
   586 natural deduction rules for \ttindex{Collect}.  The elimination rule
   583 \ttindex{CollectE} is equivalent to the two destruction rules
   587 \ttindex{CollectE} is equivalent to the two destruction rules
   584 \ttindex{CollectD1} and \ttindex{CollectD2}, but each rule is suited to
   588 \ttindex{CollectD1} and \ttindex{CollectD2}, but each rule is suited to
   585 particular circumstances.  Although too many rules can be confusing, there
   589 particular circumstances.  Although too many rules can be confusing, there
   586 is no reason to aim for a minimal set of rules.  See the file
   590 is no reason to aim for a minimal set of rules.  See the file
   587 \ttindexbold{ZF/zf.ML} for a complete listing.
   591 {\tt ZF/zf.ML} for a complete listing.
   588 
   592 
   589 Figure~\ref{ZF-lemmas3} presents rules for general union and intersection.
   593 Figure~\ref{ZF-lemmas3} presents rules for general union and intersection.
   590 The empty intersection should be undefined.  We cannot have
   594 The empty intersection should be undefined.  We cannot have
   591 $\bigcap(\emptyset)=V$ because $V$, the universal class, is not a set.  All
   595 $\bigcap(\emptyset)=V$ because $V$, the universal class, is not a set.  All
   592 expressions denote something in {\ZF} set theory; the definition of
   596 expressions denote something in {\ZF} set theory; the definition of
   682 
   686 
   683 Finally, the impossibility of having both $a\in b$ and $b\in a$
   687 Finally, the impossibility of having both $a\in b$ and $b\in a$
   684 (\ttindex{mem_anti_sym}) is proved by applying the axiom of foundation to
   688 (\ttindex{mem_anti_sym}) is proved by applying the axiom of foundation to
   685 the set $\{a,b\}$.  The impossibility of $a\in a$ is a trivial consequence.
   689 the set $\{a,b\}$.  The impossibility of $a\in a$ is a trivial consequence.
   686 
   690 
   687 See the file \ttindexbold{ZF/upair.ML} for full details.
   691 See the file {\tt ZF/upair.ML} for full details.
   688 
   692 
   689 
   693 
   690 %%% subset.ML
   694 %%% subset.ML
   691 
   695 
   692 \begin{figure}
   696 \begin{figure}
   716 
   720 
   717 \subsection{Subset and lattice properties}
   721 \subsection{Subset and lattice properties}
   718 Figure~\ref{ZF-subset} shows that the subset relation is a complete
   722 Figure~\ref{ZF-subset} shows that the subset relation is a complete
   719 lattice.  Unions form least upper bounds; non-empty intersections form
   723 lattice.  Unions form least upper bounds; non-empty intersections form
   720 greatest lower bounds.  A few other laws involving subsets are included.
   724 greatest lower bounds.  A few other laws involving subsets are included.
   721 See the file \ttindexbold{ZF/subset.ML}.
   725 See the file {\tt ZF/subset.ML}.
   722 
   726 
   723 %%% pair.ML
   727 %%% pair.ML
   724 
   728 
   725 \begin{figure}
   729 \begin{figure}
   726 \begin{ttbox}
   730 \begin{ttbox}
   729 \idx{Pair_inject}     [| <a,b> = <c,d>;  [| a=c; b=d |] ==> P |] ==> P
   733 \idx{Pair_inject}     [| <a,b> = <c,d>;  [| a=c; b=d |] ==> P |] ==> P
   730 \idx{Pair_neq_0}      <a,b>=0 ==> P
   734 \idx{Pair_neq_0}      <a,b>=0 ==> P
   731 
   735 
   732 \idx{fst}       fst(<a,b>) = a
   736 \idx{fst}       fst(<a,b>) = a
   733 \idx{snd}       snd(<a,b>) = b
   737 \idx{snd}       snd(<a,b>) = b
   734 \idx{split}     split(%x y.c(x,y), <a,b>) = c(a,b)
   738 \idx{split}     split(\%x y.c(x,y), <a,b>) = c(a,b)
   735 
   739 
   736 \idx{SigmaI}    [| a:A;  b:B(a) |] ==> <a,b> : Sigma(A,B)
   740 \idx{SigmaI}    [| a:A;  b:B(a) |] ==> <a,b> : Sigma(A,B)
   737 
   741 
   738 \idx{SigmaE}    [| c: Sigma(A,B);  
   742 \idx{SigmaE}    [| c: Sigma(A,B);  
   739              !!x y.[| x:A; y:B(x); c=<x,y> |] ==> P |] ==> P
   743              !!x y.[| x:A; y:B(x); c=<x,y> |] ==> P |] ==> P
   745 \end{figure}
   749 \end{figure}
   746 
   750 
   747 
   751 
   748 \subsection{Ordered pairs}
   752 \subsection{Ordered pairs}
   749 Figure~\ref{ZF-pair} presents the rules governing ordered pairs,
   753 Figure~\ref{ZF-pair} presents the rules governing ordered pairs,
   750 projections and general sums.  File \ttindexbold{ZF/pair.ML} contains the
   754 projections and general sums.  File {\tt ZF/pair.ML} contains the
   751 full (and tedious) proof that $\{\{a\},\{a,b\}\}$ functions as an ordered
   755 full (and tedious) proof that $\{\{a\},\{a,b\}\}$ functions as an ordered
   752 pair.  This property is expressed as two destruction rules,
   756 pair.  This property is expressed as two destruction rules,
   753 \ttindexbold{Pair_inject1} and \ttindexbold{Pair_inject2}, and equivalently
   757 \ttindexbold{Pair_inject1} and \ttindexbold{Pair_inject2}, and equivalently
   754 as the elimination rule \ttindexbold{Pair_inject}.
   758 as the elimination rule \ttindexbold{Pair_inject}.
   755 
   759 
   809 \ttindex{domain}$(r)$ consists of every element~$a$ such that $r$ contains
   813 \ttindex{domain}$(r)$ consists of every element~$a$ such that $r$ contains
   810 some pair of the form~$\pair{x,y}$.  The range operation is similar, and
   814 some pair of the form~$\pair{x,y}$.  The range operation is similar, and
   811 the field of a relation is merely the union of its domain and range.  Note
   815 the field of a relation is merely the union of its domain and range.  Note
   812 that image and inverse image are generalizations of range and domain,
   816 that image and inverse image are generalizations of range and domain,
   813 respectively.  See the file
   817 respectively.  See the file
   814 \ttindexbold{ZF/domrange.ML} for derivations of the rules.
   818 {\tt ZF/domrange.ML} for derivations of the rules.
   815 
   819 
   816 
   820 
   817 %%% func.ML
   821 %%% func.ML
   818 
   822 
   819 \begin{figure}
   823 \begin{figure}
   874 \end{figure}
   878 \end{figure}
   875 
   879 
   876 
   880 
   877 \subsection{Functions}
   881 \subsection{Functions}
   878 Functions, represented by graphs, are notoriously difficult to reason
   882 Functions, represented by graphs, are notoriously difficult to reason
   879 about.  The file \ttindexbold{ZF/func.ML} derives many rules, which overlap
   883 about.  The file {\tt ZF/func.ML} derives many rules, which overlap
   880 more than they ought.  One day these rules will be tidied up; this section
   884 more than they ought.  One day these rules will be tidied up; this section
   881 presents only the more important ones.
   885 presents only the more important ones.
   882 
   886 
   883 Figure~\ref{ZF-func1} presents the basic properties of \ttindex{Pi}$(A,B)$,
   887 Figure~\ref{ZF-func1} presents the basic properties of \ttindex{Pi}$(A,B)$,
   884 the generalized function space.  For example, if $f$ is a function and
   888 the generalized function space.  For example, if $f$ is a function and
   905 
   909 
   906 \begin{figure} 
   910 \begin{figure} 
   907 \begin{center}
   911 \begin{center}
   908 \begin{tabular}{rrr} 
   912 \begin{tabular}{rrr} 
   909   \it name      &\it meta-type  & \it description \\ 
   913   \it name      &\it meta-type  & \it description \\ 
   910   \idx{id}      & $i$           & identity function \\
   914   \idx{id}      & $\To i$       & identity function \\
   911   \idx{inj}     & $[i,i]\To i$  & injective function space\\
   915   \idx{inj}     & $[i,i]\To i$  & injective function space\\
   912   \idx{surj}    & $[i,i]\To i$  & surjective function space\\
   916   \idx{surj}    & $[i,i]\To i$  & surjective function space\\
   913   \idx{bij}     & $[i,i]\To i$  & bijective function space
   917   \idx{bij}     & $[i,i]\To i$  & bijective function space
   914         \\[1ex]
   918         \\[1ex]
   915   \idx{1}       & $i$           & $\{\emptyset\}$       \\
   919   \idx{1}       & $i$           & $\{\emptyset\}$       \\
  1102 \idx{xor_def}        a xor b == cond(a,not(b),b)
  1106 \idx{xor_def}        a xor b == cond(a,not(b),b)
  1103 
  1107 
  1104 \idx{sum_def}        A+B == \{0\}*A Un \{1\}*B
  1108 \idx{sum_def}        A+B == \{0\}*A Un \{1\}*B
  1105 \idx{Inl_def}        Inl(a) == <0,a>
  1109 \idx{Inl_def}        Inl(a) == <0,a>
  1106 \idx{Inr_def}        Inr(b) == <1,b>
  1110 \idx{Inr_def}        Inr(b) == <1,b>
  1107 \idx{case_def}       case(c,d,u) == split(%y z. cond(y, d(z), c(z)), u)
  1111 \idx{case_def}       case(c,d,u) == split(\%y z. cond(y, d(z), c(z)), u)
  1108 \subcaption{Definitions}
  1112 \subcaption{Definitions}
  1109 
  1113 
  1110 \idx{bool_1I}        1 : bool
  1114 \idx{bool_1I}        1 : bool
  1111 \idx{bool_0I}        0 : bool
  1115 \idx{bool_0I}        0 : bool
  1112 
  1116 
  1138 \idx{QSigma_def}      QSigma(A,B)  ==  UN x:A. UN y:B(x). {<x;y>}
  1142 \idx{QSigma_def}      QSigma(A,B)  ==  UN x:A. UN y:B(x). {<x;y>}
  1139 
  1143 
  1140 \idx{qsum_def}        A <+> B      == (\{0\} <*> A) Un (\{1\} <*> B)
  1144 \idx{qsum_def}        A <+> B      == (\{0\} <*> A) Un (\{1\} <*> B)
  1141 \idx{QInl_def}        QInl(a)      == <0;a>
  1145 \idx{QInl_def}        QInl(a)      == <0;a>
  1142 \idx{QInr_def}        QInr(b)      == <1;b>
  1146 \idx{QInr_def}        QInr(b)      == <1;b>
  1143 \idx{qcase_def}       qcase(c,d)   == qsplit(%y z. cond(y, d(z), c(z)))
  1147 \idx{qcase_def}       qcase(c,d)   == qsplit(\%y z. cond(y, d(z), c(z)))
  1144 \end{ttbox}
  1148 \end{ttbox}
  1145 \caption{Non-standard pairs, products and sums} \label{zf-qpair}
  1149 \caption{Non-standard pairs, products and sums} \label{zf-qpair}
  1146 \end{figure}
  1150 \end{figure}
  1147 
  1151 
  1148 
  1152 
  1152 
  1156 
  1153 \idx{nat_case_def}  nat_case(a,b,k) == 
  1157 \idx{nat_case_def}  nat_case(a,b,k) == 
  1154               THE y. k=0 & y=a | (EX x. k=succ(x) & y=b(x))
  1158               THE y. k=0 & y=a | (EX x. k=succ(x) & y=b(x))
  1155 
  1159 
  1156 \idx{rec_def}       rec(k,a,b) ==  
  1160 \idx{rec_def}       rec(k,a,b) ==  
  1157               transrec(k, %n f. nat_case(a, %m. b(m, f`m), n))
  1161               transrec(k, \%n f. nat_case(a, \%m. b(m, f`m), n))
  1158 
  1162 
  1159 \idx{add_def}       m#+n == rec(m, n, %u v.succ(v))
  1163 \idx{add_def}       m#+n == rec(m, n, \%u v.succ(v))
  1160 \idx{diff_def}      m#-n == rec(n, m, %u v. rec(v, 0, %x y.x))
  1164 \idx{diff_def}      m#-n == rec(n, m, \%u v. rec(v, 0, \%x y.x))
  1161 \idx{mult_def}      m#*n == rec(m, 0, %u v. n #+ v)
  1165 \idx{mult_def}      m#*n == rec(m, 0, \%u v. n #+ v)
  1162 \idx{mod_def}       m mod n == transrec(m, %j f. if(j:n, j, f`(j#-n)))
  1166 \idx{mod_def}       m mod n == transrec(m, \%j f. if(j:n, j, f`(j#-n)))
  1163 \idx{div_def}       m div n == transrec(m, %j f. if(j:n, 0, succ(f`(j#-n))))
  1167 \idx{div_def}       m div n == transrec(m, \%j f. if(j:n, 0, succ(f`(j#-n))))
  1164 \subcaption{Definitions}
  1168 \subcaption{Definitions}
  1165 
  1169 
  1166 \idx{nat_0I}        0 : nat
  1170 \idx{nat_0I}        0 : nat
  1167 \idx{nat_succI}     n : nat ==> succ(n) : nat
  1171 \idx{nat_succI}     n : nat ==> succ(n) : nat
  1168 
  1172 
  1211 \end{figure}
  1215 \end{figure}
  1212 
  1216 
  1213 \begin{figure}\underscoreon %%because @ is used here
  1217 \begin{figure}\underscoreon %%because @ is used here
  1214 \begin{ttbox}
  1218 \begin{ttbox}
  1215 \idx{list_rec_def}    list_rec(l,c,h) == 
  1219 \idx{list_rec_def}    list_rec(l,c,h) == 
  1216                 Vrec(l, %l g.list_case(c, %x xs. h(x, xs, g`xs), l))
  1220                 Vrec(l, \%l g.list_case(c, \%x xs. h(x, xs, g`xs), l))
  1217 
  1221 
  1218 \idx{map_def}         map(f,l)  == list_rec(l,  0,  %x xs r. <f(x), r>)
  1222 \idx{map_def}         map(f,l)  == list_rec(l,  0,  \%x xs r. <f(x), r>)
  1219 \idx{length_def}      length(l) == list_rec(l,  0,  %x xs r. succ(r))
  1223 \idx{length_def}      length(l) == list_rec(l,  0,  \%x xs r. succ(r))
  1220 \idx{app_def}         xs@ys     == list_rec(xs, ys, %x xs r. <x,r>)
  1224 \idx{app_def}         xs@ys     == list_rec(xs, ys, \%x xs r. <x,r>)
  1221 \idx{rev_def}         rev(l)    == list_rec(l,  0,  %x xs r. r @ <x,0>)
  1225 \idx{rev_def}         rev(l)    == list_rec(l,  0,  \%x xs r. r @ <x,0>)
  1222 \idx{flat_def}        flat(ls)  == list_rec(ls, 0,  %l ls r. l @ r)
  1226 \idx{flat_def}        flat(ls)  == list_rec(ls, 0,  \%l ls r. l @ r)
  1223 \subcaption{Definitions}
  1227 \subcaption{Definitions}
  1224 
  1228 
  1225 \idx{NilI}            Nil : list(A)
  1229 \idx{NilI}            Nil : list(A)
  1226 \idx{ConsI}           [| a: A;  l: list(A) |] ==> Cons(a,l) : list(A)
  1230 \idx{ConsI}           [| a: A;  l: list(A) |] ==> Cons(a,l) : list(A)
  1227 
  1231 
  1237 \idx{list_mono}       A<=B ==> list(A) <= list(B)
  1241 \idx{list_mono}       A<=B ==> list(A) <= list(B)
  1238 
  1242 
  1239 \idx{list_rec_Nil}    list_rec(Nil,c,h) = c
  1243 \idx{list_rec_Nil}    list_rec(Nil,c,h) = c
  1240 \idx{list_rec_Cons}   list_rec(Cons(a,l), c, h) = h(a, l, list_rec(l,c,h))
  1244 \idx{list_rec_Cons}   list_rec(Cons(a,l), c, h) = h(a, l, list_rec(l,c,h))
  1241 
  1245 
  1242 \idx{map_ident}       l: list(A) ==> map(%u.u, l) = l
  1246 \idx{map_ident}       l: list(A) ==> map(\%u.u, l) = l
  1243 \idx{map_compose}     l: list(A) ==> map(h, map(j,l)) = map(%u.h(j(u)), l)
  1247 \idx{map_compose}     l: list(A) ==> map(h, map(j,l)) = map(\%u.h(j(u)), l)
  1244 \idx{map_app_distrib} xs: list(A) ==> map(h, xs@ys) = map(h,xs) @ map(h,ys)
  1248 \idx{map_app_distrib} xs: list(A) ==> map(h, xs@ys) = map(h,xs) @ map(h,ys)
  1245 \idx{map_type}
  1249 \idx{map_type}
  1246     [| l: list(A);  !!x. x: A ==> h(x): B |] ==> map(h,l) : list(B)
  1250     [| l: list(A);  !!x. x: A ==> h(x): B |] ==> map(h,l) : list(B)
  1247 \idx{map_flat}
  1251 \idx{map_flat}
  1248     ls: list(list(A)) ==> map(h, flat(ls)) = flat(map(map(h),ls))
  1252     ls: list(list(A)) ==> map(h, flat(ls)) = flat(map(map(h),ls))
  1256 some of the further constants and infixes that are declared in the various
  1260 some of the further constants and infixes that are declared in the various
  1257 theory extensions.
  1261 theory extensions.
  1258 
  1262 
  1259 Figure~\ref{zf-equalities} presents commutative, associative, distributive,
  1263 Figure~\ref{zf-equalities} presents commutative, associative, distributive,
  1260 and idempotency laws of union and intersection, along with other equations.
  1264 and idempotency laws of union and intersection, along with other equations.
  1261 See file \ttindexbold{ZF/equalities.ML}.
  1265 See file {\tt ZF/equalities.ML}.
  1262 
  1266 
  1263 Figure~\ref{zf-sum} defines $\{0,1\}$ as a set of booleans, with the usual
  1267 Figure~\ref{zf-sum} defines $\{0,1\}$ as a set of booleans, with the usual
  1264 operators including a conditional.  It also defines the disjoint union of
  1268 operators including a conditional.  It also defines the disjoint union of
  1265 two sets, with injections and a case analysis operator.  See files
  1269 two sets, with injections and a case analysis operator.  See files
  1266 \ttindexbold{ZF/bool.ML} and \ttindexbold{ZF/sum.ML}.
  1270 {\tt ZF/bool.ML} and {\tt ZF/sum.ML}.
  1267 
  1271 
  1268 Figure~\ref{zf-qpair} defines a notion of ordered pair that admits
  1272 Figure~\ref{zf-qpair} defines a notion of ordered pair that admits
  1269 non-well-founded tupling.  Such pairs are written {\tt<$a$;$b$>}.  It also
  1273 non-well-founded tupling.  Such pairs are written {\tt<$a$;$b$>}.  It also
  1270 defines the eliminator \ttindexbold{qsplit}, the converse operator
  1274 defines the eliminator \ttindexbold{qsplit}, the converse operator
  1271 \ttindexbold{qconverse}, and the summation operator \ttindexbold{QSigma}.
  1275 \ttindexbold{qconverse}, and the summation operator \ttindexbold{QSigma}.
  1274 disjoint sum using non-standard pairs.  This will support co-inductive
  1278 disjoint sum using non-standard pairs.  This will support co-inductive
  1275 definitions, for example of infinite lists.  See file \ttindexbold{qpair.thy}.
  1279 definitions, for example of infinite lists.  See file \ttindexbold{qpair.thy}.
  1276 
  1280 
  1277 Monotonicity properties of most of the set-forming operations are proved.
  1281 Monotonicity properties of most of the set-forming operations are proved.
  1278 These are useful for applying the Knaster-Tarski Fixedpoint Theorem.
  1282 These are useful for applying the Knaster-Tarski Fixedpoint Theorem.
  1279 See file \ttindexbold{ZF/mono.ML}.
  1283 See file {\tt ZF/mono.ML}.
  1280 
  1284 
  1281 Figure~\ref{zf-fixedpt} presents the Knaster-Tarski Fixedpoint Theorem, proved
  1285 Figure~\ref{zf-fixedpt} presents the Knaster-Tarski Fixedpoint Theorem, proved
  1282 for the lattice of subsets of a set.  The theory defines least and greatest
  1286 for the lattice of subsets of a set.  The theory defines least and greatest
  1283 fixedpoint operators with corresponding induction and co-induction rules.
  1287 fixedpoint operators with corresponding induction and co-induction rules.
  1284 Later definitions use these, such as the natural numbers and
  1288 Later definitions use these, such as the natural numbers and
  1285 the transitive closure operator.  The (co-)inductive definition
  1289 the transitive closure operator.  The (co-)inductive definition
  1286 package also uses them.    See file \ttindexbold{ZF/fixedpt.ML}.
  1290 package also uses them.    See file {\tt ZF/fixedpt.ML}.
  1287 
  1291 
  1288 Figure~\ref{zf-perm} defines composition and injective, surjective and
  1292 Figure~\ref{zf-perm} defines composition and injective, surjective and
  1289 bijective function spaces, with proofs of many of their properties.
  1293 bijective function spaces, with proofs of many of their properties.
  1290 See file \ttindexbold{ZF/perm.ML}.
  1294 See file {\tt ZF/perm.ML}.
  1291 
  1295 
  1292 Figure~\ref{zf-nat} presents the natural numbers, with induction and a
  1296 Figure~\ref{zf-nat} presents the natural numbers, with induction and a
  1293 primitive recursion operator.  See file \ttindexbold{ZF/nat.ML}.  File
  1297 primitive recursion operator.  See file {\tt ZF/nat.ML}.  File
  1294 \ttindexbold{ZF/arith.ML} develops arithmetic on the natural numbers.  It
  1298 {\tt ZF/arith.ML} develops arithmetic on the natural numbers.  It
  1295 defines addition, multiplication, subtraction, division, and remainder,
  1299 defines addition, multiplication, subtraction, division, and remainder,
  1296 proving the theorem $a \bmod b + (a/b)\times b = a$.  Division and
  1300 proving the theorem $a \bmod b + (a/b)\times b = a$.  Division and
  1297 remainder are defined by repeated subtraction, which requires well-founded
  1301 remainder are defined by repeated subtraction, which requires well-founded
  1298 rather than primitive recursion.
  1302 rather than primitive recursion.
  1299 
  1303 
  1300 The file \ttindexbold{ZF/univ.ML} defines a ``universe'' ${\tt univ}(A)$,
  1304 The file {\tt ZF/univ.ML} defines a ``universe'' ${\tt univ}(A)$,
  1301 for constructing datatypes such as trees.  This set contains $A$ and the
  1305 for constructing datatypes such as trees.  This set contains $A$ and the
  1302 natural numbers.  Vitally, it is closed under finite products: ${\tt
  1306 natural numbers.  Vitally, it is closed under finite products: ${\tt
  1303   univ}(A)\times{\tt univ}(A)\subseteq{\tt univ}(A)$.  This file also
  1307   univ}(A)\times{\tt univ}(A)\subseteq{\tt univ}(A)$.  This file also
  1304 defines set theory's cumulative hierarchy, traditionally written $V@\alpha$
  1308 defines set theory's cumulative hierarchy, traditionally written $V@\alpha$
  1305 where $\alpha$ is any ordinal.
  1309 where $\alpha$ is any ordinal.
  1306 
  1310 
  1307 The file \ttindexbold{ZF/quniv.ML} defines a ``universe'' ${\tt quniv}(A)$,
  1311 The file {\tt ZF/quniv.ML} defines a ``universe'' ${\tt quniv}(A)$,
  1308 for constructing co-datatypes such as streams.  It is analogous to ${\tt
  1312 for constructing co-datatypes such as streams.  It is analogous to ${\tt
  1309   univ}(A)$ but is closed under the non-standard product and sum.
  1313   univ}(A)$ but is closed under the non-standard product and sum.
  1310 
  1314 
  1311 Figure~\ref{zf-fin} presents the finite set operator; ${\tt Fin}(A)$ is the
  1315 Figure~\ref{zf-fin} presents the finite set operator; ${\tt Fin}(A)$ is the
  1312 set of all finite sets over~$A$.  The definition employs Isabelle's
  1316 set of all finite sets over~$A$.  The definition employs Isabelle's
  1313 inductive definition package, which proves the introduction rules
  1317 inductive definition package, which proves the introduction rules
  1314 automatically.  The induction rule shown is stronger than the one proved by
  1318 automatically.  The induction rule shown is stronger than the one proved by
  1315 the package.  See file \ttindexbold{ZF/fin.ML}.
  1319 the package.  See file {\tt ZF/fin.ML}.
  1316 
  1320 
  1317 Figure~\ref{zf-list} presents the set of lists over~$A$, ${\tt list}(A)$.
  1321 Figure~\ref{zf-list} presents the set of lists over~$A$, ${\tt list}(A)$.
  1318 The definition employs Isabelle's datatype package, which defines the
  1322 The definition employs Isabelle's datatype package, which defines the
  1319 introduction and induction rules automatically, as well as the constructors
  1323 introduction and induction rules automatically, as well as the constructors
  1320 and case operator (\verb|list_case|).  See file \ttindexbold{ZF/list.ML}.
  1324 and case operator (\verb|list_case|).  See file {\tt ZF/list.ML}.
  1321 The file \ttindexbold{ZF/listfn.thy} proceeds to define structural
  1325 The file {\tt ZF/listfn.thy} proceeds to define structural
  1322 recursion and the usual list functions.
  1326 recursion and the usual list functions.
  1323 
  1327 
  1324 The constructions of the natural numbers and lists make use of a suite of
  1328 The constructions of the natural numbers and lists make use of a suite of
  1325 operators for handling recursive function definitions.  The developments are
  1329 operators for handling recursive function definitions.  The developments are
  1326 summarized below:
  1330 summarized below:
  1327 \begin{description}
  1331 \begin{description}
  1328 \item[\ttindexbold{ZF/trancl.ML}]
  1332 \item[{\tt ZF/trancl.ML}]
  1329 defines the transitive closure of a relation (as a least fixedpoint).
  1333 defines the transitive closure of a relation (as a least fixedpoint).
  1330 
  1334 
  1331 \item[\ttindexbold{ZF/wf.ML}]
  1335 \item[{\tt ZF/wf.ML}]
  1332 proves the Well-Founded Recursion Theorem, using an elegant
  1336 proves the Well-Founded Recursion Theorem, using an elegant
  1333 approach of Tobias Nipkow.  This theorem permits general recursive
  1337 approach of Tobias Nipkow.  This theorem permits general recursive
  1334 definitions within set theory.
  1338 definitions within set theory.
  1335 
  1339 
  1336 \item[\ttindexbold{ZF/ord.ML}] defines the notions of transitive set and
  1340 \item[{\tt ZF/ord.ML}] defines the notions of transitive set and
  1337   ordinal number.  It derives transfinite induction.  A key definition is
  1341   ordinal number.  It derives transfinite induction.  A key definition is
  1338   {\bf less than}: $i<j$ if and only if $i$ and $j$ are both ordinals and
  1342   {\bf less than}: $i<j$ if and only if $i$ and $j$ are both ordinals and
  1339   $i\in j$.  As a special case, it includes less than on the natural
  1343   $i\in j$.  As a special case, it includes less than on the natural
  1340   numbers.
  1344   numbers.
  1341 
  1345 
  1342 \item[\ttindexbold{ZF/epsilon.ML}]
  1346 \item[{\tt ZF/epsilon.ML}]
  1343 derives $\epsilon$-induction and $\epsilon$-recursion, which are
  1347 derives $\epsilon$-induction and $\epsilon$-recursion, which are
  1344 generalizations of transfinite induction.  It also defines
  1348 generalizations of transfinite induction.  It also defines
  1345 \ttindexbold{rank}$(x)$, which is the least ordinal $\alpha$ such that $x$
  1349 \ttindexbold{rank}$(x)$, which is the least ordinal $\alpha$ such that $x$
  1346 is constructed at stage $\alpha$ of the cumulative hierarchy (thus $x\in
  1350 is constructed at stage $\alpha$ of the cumulative hierarchy (thus $x\in
  1347 V@{\alpha+1}$).
  1351 V@{\alpha+1}$).
  1365 \end{figure}
  1369 \end{figure}
  1366 
  1370 
  1367 
  1371 
  1368 \section{Simplification rules}
  1372 \section{Simplification rules}
  1369 {\ZF} does not merely inherit simplification from \FOL, but instantiates
  1373 {\ZF} does not merely inherit simplification from \FOL, but instantiates
  1370 the rewriting package new.  File \ttindexbold{ZF/simpdata.ML} contains the
  1374 the rewriting package new.  File {\tt ZF/simpdata.ML} contains the
  1371 details; here is a summary of the key differences:
  1375 details; here is a summary of the key differences:
  1372 \begin{itemize}
  1376 \begin{itemize}
  1373 \item 
  1377 \item 
  1374 \ttindexbold{mk_rew_rules} is given as a function that can
  1378 \ttindexbold{mk_rew_rules} is given as a function that can
  1375 strip bounded universal quantifiers from a formula.  For example, $\forall
  1379 strip bounded universal quantifiers from a formula.  For example, $\forall
  1377 f(x)=g(x)$.
  1381 f(x)=g(x)$.
  1378 \item
  1382 \item
  1379 \ttindexbold{ZF_ss} contains congruence rules for all the operators of
  1383 \ttindexbold{ZF_ss} contains congruence rules for all the operators of
  1380 {\ZF}, including the binding operators.  It contains all the conversion
  1384 {\ZF}, including the binding operators.  It contains all the conversion
  1381 rules, such as \ttindex{fst} and \ttindex{snd}, as well as the
  1385 rules, such as \ttindex{fst} and \ttindex{snd}, as well as the
  1382 rewrites shown in Figure~\ref{ZF-simpdata}.
  1386 rewrites shown in Fig.\ts\ref{ZF-simpdata}.
  1383 \item
  1387 \item
  1384 \ttindexbold{FOL_ss} is redeclared with the same {\FOL} rules as the
  1388 \ttindexbold{FOL_ss} is redeclared with the same {\FOL} rules as the
  1385 previous version, so that it may still be used.  
  1389 previous version, so that it may still be used.  
  1386 \end{itemize}
  1390 \end{itemize}
  1387 
  1391 
  1388 
  1392 
  1389 \section{The examples directory}
  1393 \section{The examples directory}
  1390 This directory contains further developments in {\ZF} set theory.  Here is
  1394 This directory contains further developments in {\ZF} set theory.  Here is
  1391 an overview; see the files themselves for more details.
  1395 an overview; see the files themselves for more details.
  1392 \begin{description}
  1396 \begin{description}
  1393 \item[\ttindexbold{ZF/ex/misc.ML}] contains miscellaneous examples such as
  1397 \item[{\tt ZF/ex/misc.ML}] contains miscellaneous examples such as
  1394   Cantor's Theorem, the Schr\"oder-Bernstein Theorem.  and the
  1398   Cantor's Theorem, the Schr\"oder-Bernstein Theorem.  and the
  1395   ``Composition of homomorphisms'' challenge~\cite{boyer86}.
  1399   ``Composition of homomorphisms'' challenge~\cite{boyer86}.
  1396 
  1400 
  1397 \item[\ttindexbold{ZF/ex/ramsey.ML}]
  1401 \item[{\tt ZF/ex/ramsey.ML}]
  1398 proves the finite exponent 2 version of Ramsey's Theorem, following Basin
  1402 proves the finite exponent 2 version of Ramsey's Theorem, following Basin
  1399 and Kaufmann's presentation~\cite{basin91}.
  1403 and Kaufmann's presentation~\cite{basin91}.
  1400 
  1404 
  1401 \item[\ttindexbold{ZF/ex/equiv.ML}]
  1405 \item[{\tt ZF/ex/equiv.ML}]
  1402 develops a ZF theory of equivalence classes, not using the Axiom of Choice.
  1406 develops a ZF theory of equivalence classes, not using the Axiom of Choice.
  1403 
  1407 
  1404 \item[\ttindexbold{ZF/ex/integ.ML}]
  1408 \item[{\tt ZF/ex/integ.ML}]
  1405 develops a theory of the integers as equivalence classes of pairs of
  1409 develops a theory of the integers as equivalence classes of pairs of
  1406 natural numbers.
  1410 natural numbers.
  1407 
  1411 
  1408 \item[\ttindexbold{ZF/ex/bin.ML}]
  1412 \item[{\tt ZF/ex/bin.ML}]
  1409 defines a datatype for two's complement binary integers.  File
  1413 defines a datatype for two's complement binary integers.  File
  1410 \ttindexbold{ZF/ex/binfn.ML} then develops rewrite rules for binary
  1414 {\tt binfn.ML} then develops rewrite rules for binary
  1411 arithmetic.  For instance, $1359\times {-}2468 = {-}3354012$ takes under
  1415 arithmetic.  For instance, $1359\times {-}2468 = {-}3354012$ takes under
  1412 14 seconds.
  1416 14 seconds.
  1413 
  1417 
  1414 \item[\ttindexbold{ZF/ex/bt.ML}]
  1418 \item[{\tt ZF/ex/bt.ML}]
  1415 defines the recursive data structure ${\tt bt}(A)$, labelled binary trees.
  1419 defines the recursive data structure ${\tt bt}(A)$, labelled binary trees.
  1416 
  1420 
  1417 \item[\ttindexbold{ZF/ex/term.ML}] 
  1421 \item[{\tt ZF/ex/term.ML}] 
  1418   and \ttindexbold{ZF/ex/termfn.ML} define a recursive data structure for
  1422   and {\tt termfn.ML} define a recursive data structure for
  1419   terms and term lists.  These are simply finite branching trees.
  1423   terms and term lists.  These are simply finite branching trees.
  1420 
  1424 
  1421 \item[\ttindexbold{ZF/ex/tf.ML}]
  1425 \item[{\tt ZF/ex/tf.ML}]
  1422   and \ttindexbold{ZF/ex/tf_fn.ML} define primitives for solving mutually
  1426   and {\tt tf_fn.ML} define primitives for solving mutually
  1423   recursive equations over sets.  It constructs sets of trees and forests
  1427   recursive equations over sets.  It constructs sets of trees and forests
  1424   as an example, including induction and recursion rules that handle the
  1428   as an example, including induction and recursion rules that handle the
  1425   mutual recursion.
  1429   mutual recursion.
  1426 
  1430 
  1427 \item[\ttindexbold{ZF/ex/prop.ML}]
  1431 \item[{\tt ZF/ex/prop.ML}]
  1428   and \ttindexbold{ZF/ex/proplog.ML} proves soundness and completeness of
  1432   and {\tt proplog.ML} proves soundness and completeness of
  1429   propositional logic.  This illustrates datatype definitions, inductive
  1433   propositional logic.  This illustrates datatype definitions, inductive
  1430   definitions, structural induction and rule induction.
  1434   definitions, structural induction and rule induction.
  1431 
  1435 
  1432 \item[\ttindexbold{ZF/ex/listn.ML}]
  1436 \item[{\tt ZF/ex/listn.ML}]
  1433 presents the inductive definition of the lists of $n$ elements~\cite{paulin92}.
  1437 presents the inductive definition of the lists of $n$ elements~\cite{paulin92}.
  1434 
  1438 
  1435 \item[\ttindexbold{ZF/ex/acc.ML}]
  1439 \item[{\tt ZF/ex/acc.ML}]
  1436 presents the inductive definition of the accessible part of a
  1440 presents the inductive definition of the accessible part of a
  1437 relation~\cite{paulin92}. 
  1441 relation~\cite{paulin92}. 
  1438 
  1442 
  1439 \item[\ttindexbold{ZF/ex/comb.ML}]
  1443 \item[{\tt ZF/ex/comb.ML}]
  1440   presents the datatype definition of combinators.  File
  1444   presents the datatype definition of combinators.  The file
  1441   \ttindexbold{ZF/ex/contract0.ML} defines contraction, while file
  1445   {\tt contract0.ML} defines contraction, while file
  1442   \ttindexbold{ZF/ex/parcontract.ML} defines parallel contraction and
  1446   {\tt parcontract.ML} defines parallel contraction and
  1443   proves the Church-Rosser Theorem.  This case study follows Camilleri and
  1447   proves the Church-Rosser Theorem.  This case study follows Camilleri and
  1444   Melham~\cite{camilleri92}. 
  1448   Melham~\cite{camilleri92}. 
  1445 
  1449 
  1446 \item[\ttindexbold{ZF/ex/llist.ML}]
  1450 \item[{\tt ZF/ex/llist.ML}]
  1447   and \ttindexbold{ZF/ex/llist_eq.ML} develop lazy lists in ZF and a notion
  1451   and {\tt llist_eq.ML} develop lazy lists in ZF and a notion
  1448   of co-induction for proving equations between them.
  1452   of co-induction for proving equations between them.
  1449 \end{description}
  1453 \end{description}
  1450 
  1454 
  1451 
  1455 
  1452 \section{A proof about powersets}
  1456 \section{A proof about powersets}
  1465 \begin{ttbox}
  1469 \begin{ttbox}
  1466 goal ZF.thy "Pow(A Int B) = Pow(A) Int Pow(B)";
  1470 goal ZF.thy "Pow(A Int B) = Pow(A) Int Pow(B)";
  1467 {\out Level 0}
  1471 {\out Level 0}
  1468 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1472 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1469 {\out  1. Pow(A Int B) = Pow(A) Int Pow(B)}
  1473 {\out  1. Pow(A Int B) = Pow(A) Int Pow(B)}
       
  1474 \ttbreak
  1470 by (resolve_tac [equalityI] 1);
  1475 by (resolve_tac [equalityI] 1);
  1471 {\out Level 1}
  1476 {\out Level 1}
  1472 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1477 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1473 {\out  1. Pow(A Int B) <= Pow(A) Int Pow(B)}
  1478 {\out  1. Pow(A Int B) <= Pow(A) Int Pow(B)}
  1474 {\out  2. Pow(A) Int Pow(B) <= Pow(A Int B)}
  1479 {\out  2. Pow(A) Int Pow(B) <= Pow(A Int B)}
  1491 by (resolve_tac [Int_lower1 RS Pow_mono] 1);
  1496 by (resolve_tac [Int_lower1 RS Pow_mono] 1);
  1492 {\out Level 3}
  1497 {\out Level 3}
  1493 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1498 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1494 {\out  1. Pow(A Int B) <= Pow(B)}
  1499 {\out  1. Pow(A Int B) <= Pow(B)}
  1495 {\out  2. Pow(A) Int Pow(B) <= Pow(A Int B)}
  1500 {\out  2. Pow(A) Int Pow(B) <= Pow(A Int B)}
       
  1501 \ttbreak
  1496 by (resolve_tac [Int_lower2 RS Pow_mono] 1);
  1502 by (resolve_tac [Int_lower2 RS Pow_mono] 1);
  1497 {\out Level 4}
  1503 {\out Level 4}
  1498 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1504 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1499 {\out  1. Pow(A) Int Pow(B) <= Pow(A Int B)}
  1505 {\out  1. Pow(A) Int Pow(B) <= Pow(A Int B)}
  1500 \end{ttbox}
  1506 \end{ttbox}
  1505 {\out Level 5}
  1511 {\out Level 5}
  1506 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1512 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1507 {\out  1. !!x. x : Pow(A) Int Pow(B) ==> x : Pow(A Int B)}
  1513 {\out  1. !!x. x : Pow(A) Int Pow(B) ==> x : Pow(A Int B)}
  1508 \end{ttbox}
  1514 \end{ttbox}
  1509 The subgoal is to show $x\in {\tt Pow}(A\cap B)$ assuming $x\in{\tt
  1515 The subgoal is to show $x\in {\tt Pow}(A\cap B)$ assuming $x\in{\tt
  1510 Pow}(A)\cap {\tt Pow}(B)$.  Eliminating this assumption produces two
  1516 Pow}(A)\cap {\tt Pow}(B)$; eliminating this assumption produces two
  1511 subgoals, since intersection is like conjunction.\index{*IntE}
  1517 subgoals.  The rule \ttindex{IntE} treats the intersection like a conjunction
       
  1518 instead of unfolding its definition.
  1512 \begin{ttbox}
  1519 \begin{ttbox}
  1513 by (eresolve_tac [IntE] 1);
  1520 by (eresolve_tac [IntE] 1);
  1514 {\out Level 6}
  1521 {\out Level 6}
  1515 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1522 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1516 {\out  1. !!x. [| x : Pow(A); x : Pow(B) |] ==> x : Pow(A Int B)}
  1523 {\out  1. !!x. [| x : Pow(A); x : Pow(B) |] ==> x : Pow(A Int B)}
  1521 by (resolve_tac [PowI] 1);
  1528 by (resolve_tac [PowI] 1);
  1522 {\out Level 7}
  1529 {\out Level 7}
  1523 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1530 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1524 {\out  1. !!x. [| x : Pow(A); x : Pow(B) |] ==> x <= A Int B}
  1531 {\out  1. !!x. [| x : Pow(A); x : Pow(B) |] ==> x <= A Int B}
  1525 \end{ttbox}
  1532 \end{ttbox}
  1526 We perform the same replacement in the assumptions:\index{*PowD}
  1533 We perform the same replacement in the assumptions.  This is a good
       
  1534 demonstration of the tactic \ttindex{dresolve_tac}:\index{*PowD}
  1527 \begin{ttbox}
  1535 \begin{ttbox}
  1528 by (REPEAT (dresolve_tac [PowD] 1));
  1536 by (REPEAT (dresolve_tac [PowD] 1));
  1529 {\out Level 8}
  1537 {\out Level 8}
  1530 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1538 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1531 {\out  1. !!x. [| x <= A; x <= B |] ==> x <= A Int B}
  1539 {\out  1. !!x. [| x <= A; x <= B |] ==> x <= A Int B}
  1532 \end{ttbox}
  1540 \end{ttbox}
  1533 Here, $x$ is a lower bound of $A$ and~$B$, but $A\inter B$ is the greatest
  1541 The assumptions are that $x$ is a lower bound of both $A$ and~$B$, but
  1534 lower bound:\index{*Int_greatest}
  1542 $A\inter B$ is the greatest lower bound:\index{*Int_greatest}
  1535 \begin{ttbox}
  1543 \begin{ttbox}
  1536 by (resolve_tac [Int_greatest] 1);
  1544 by (resolve_tac [Int_greatest] 1);
  1537 {\out Level 9}
  1545 {\out Level 9}
  1538 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1546 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1539 {\out  1. !!x. [| x <= A; x <= B |] ==> x <= A}
  1547 {\out  1. !!x. [| x <= A; x <= B |] ==> x <= A}
  1540 {\out  2. !!x. [| x <= A; x <= B |] ==> x <= B}
  1548 {\out  2. !!x. [| x <= A; x <= B |] ==> x <= B}
       
  1549 \end{ttbox}
       
  1550 To conclude the proof, we clear up the trivial subgoals:
       
  1551 \begin{ttbox}
  1541 by (REPEAT (assume_tac 1));
  1552 by (REPEAT (assume_tac 1));
  1542 {\out Level 10}
  1553 {\out Level 10}
  1543 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1554 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1544 {\out No subgoals!}
  1555 {\out No subgoals!}
  1545 \end{ttbox}
  1556 \end{ttbox}
       
  1557 \medskip
  1546 We could have performed this proof in one step by applying
  1558 We could have performed this proof in one step by applying
  1547 \ttindex{fast_tac} with the classical rule set \ttindex{ZF_cs}.  But we
  1559 \ttindex{fast_tac} with the classical rule set \ttindex{ZF_cs}.  Let us
  1548 must add \ttindex{equalityI} as an introduction rule, since extensionality
  1560 go back to the start:
  1549 is not used by default:
       
  1550 \begin{ttbox}
  1561 \begin{ttbox}
  1551 choplev 0;
  1562 choplev 0;
  1552 {\out Level 0}
  1563 {\out Level 0}
  1553 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1564 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1554 {\out  1. Pow(A Int B) = Pow(A) Int Pow(B)}
  1565 {\out  1. Pow(A Int B) = Pow(A) Int Pow(B)}
       
  1566 \end{ttbox}
       
  1567 We must add \ttindex{equalityI} to {\tt ZF_cs} as an introduction rule.
       
  1568 Extensionality is not used by default because many equalities can be proved
       
  1569 by rewriting.
       
  1570 \begin{ttbox}
  1555 by (fast_tac (ZF_cs addIs [equalityI]) 1);
  1571 by (fast_tac (ZF_cs addIs [equalityI]) 1);
  1556 {\out Level 1}
  1572 {\out Level 1}
  1557 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1573 {\out Pow(A Int B) = Pow(A) Int Pow(B)}
  1558 {\out No subgoals!}
  1574 {\out No subgoals!}
  1559 \end{ttbox}
  1575 \end{ttbox}
  1560 
  1576 In the past this was regarded as a difficult proof, as indeed it is if all
       
  1577 the symbols are replaced by their definitions.
       
  1578 \goodbreak
  1561 
  1579 
  1562 \section{Monotonicity of the union operator}
  1580 \section{Monotonicity of the union operator}
  1563 For another example, we prove that general union is monotonic:
  1581 For another example, we prove that general union is monotonic:
  1564 ${C\subseteq D}$ implies $\bigcup(C)\subseteq \bigcup(D)$.  To begin, we
  1582 ${C\subseteq D}$ implies $\bigcup(C)\subseteq \bigcup(D)$.  To begin, we
  1565 tackle the inclusion using \ttindex{subsetI}:
  1583 tackle the inclusion using \ttindex{subsetI}:
  1617 Again, \ttindex{fast_tac} with \ttindex{ZF_cs} can do this proof in one
  1635 Again, \ttindex{fast_tac} with \ttindex{ZF_cs} can do this proof in one
  1618 step, provided we somehow supply it with~{\tt prem}.  We can either add
  1636 step, provided we somehow supply it with~{\tt prem}.  We can either add
  1619 this premise to the assumptions using \ttindex{cut_facts_tac}, or add
  1637 this premise to the assumptions using \ttindex{cut_facts_tac}, or add
  1620 \hbox{\tt prem RS subsetD} to \ttindex{ZF_cs} as an introduction rule.
  1638 \hbox{\tt prem RS subsetD} to \ttindex{ZF_cs} as an introduction rule.
  1621 
  1639 
  1622 The file \ttindex{ZF/equalities.ML} has many similar proofs.
  1640 The file {\tt ZF/equalities.ML} has many similar proofs.
  1623 Reasoning about general intersection can be difficult because of its anomalous
  1641 Reasoning about general intersection can be difficult because of its anomalous
  1624 behavior on the empty set.  However, \ttindex{fast_tac} copes well with
  1642 behavior on the empty set.  However, \ttindex{fast_tac} copes well with
  1625 these.  Here is a typical example:
  1643 these.  Here is a typical example, borrowed from Devlin[page 12]{devlin79}:
  1626 \begin{ttbox}
  1644 \begin{ttbox}
  1627 a:C ==> (INT x:C. A(x) Int B(x)) = (INT x:C.A(x)) Int (INT x:C.B(x))
  1645 a:C ==> (INT x:C. A(x) Int B(x)) = (INT x:C.A(x)) Int (INT x:C.B(x))
  1628 \end{ttbox}
  1646 \end{ttbox}
  1629 In traditional notation this is
  1647 In traditional notation this is
  1630 \[ a\in C \,\Imp\, \bigcap@{x\in C} \Bigl(A(x) \inter B(x)\Bigr) =        
  1648 \[ a\in C \,\Imp\, \bigcap@{x\in C} \Bigl(A(x) \inter B(x)\Bigr) =        
  1637 $\lambda$-calculus style.  This is generally easier than regarding
  1655 $\lambda$-calculus style.  This is generally easier than regarding
  1638 functions as sets of ordered pairs.  But sometimes we must look at the
  1656 functions as sets of ordered pairs.  But sometimes we must look at the
  1639 underlying representation, as in the following proof
  1657 underlying representation, as in the following proof
  1640 of~\ttindex{fun_disjoint_apply1}.  This states that if $f$ and~$g$ are
  1658 of~\ttindex{fun_disjoint_apply1}.  This states that if $f$ and~$g$ are
  1641 functions with disjoint domains~$A$ and~$C$, and if $a\in A$, then
  1659 functions with disjoint domains~$A$ and~$C$, and if $a\in A$, then
  1642 $(f\union g)`a = f`a$:
  1660 $(f\un g)`a = f`a$:
  1643 \begin{ttbox}
  1661 \begin{ttbox}
  1644 val prems = goal ZF.thy
  1662 val prems = goal ZF.thy
  1645     "[| a:A;  f: A->B;  g: C->D;  A Int C = 0 |] ==>  \ttback
  1663     "[| a:A;  f: A->B;  g: C->D;  A Int C = 0 |] ==>  \ttback
  1646 \ttback    (f Un g)`a = f`a";
  1664 \ttback    (f Un g)`a = f`a";
  1647 {\out Level 0}
  1665 {\out Level 0}
  1648 {\out (f Un g) ` a = f ` a}
  1666 {\out (f Un g) ` a = f ` a}
  1649 {\out  1. (f Un g) ` a = f ` a}
  1667 {\out  1. (f Un g) ` a = f ` a}
  1650 \ttbreak
  1668 \end{ttbox}
       
  1669 Isabelle has produced the output above; the \ML{} top-level now echoes the
       
  1670 binding of {\tt prems}.
       
  1671 \begin{ttbox}
  1651 {\out val prems = ["a : A  [a : A]",}
  1672 {\out val prems = ["a : A  [a : A]",}
  1652 {\out              "f : A -> B  [f : A -> B]",}
  1673 {\out              "f : A -> B  [f : A -> B]",}
  1653 {\out              "g : C -> D  [g : C -> D]",}
  1674 {\out              "g : C -> D  [g : C -> D]",}
  1654 {\out              "A Int C = 0  [A Int C = 0]"] : thm list}
  1675 {\out              "A Int C = 0  [A Int C = 0]"] : thm list}
  1655 \end{ttbox}
  1676 \end{ttbox}
  1656 Using \ttindex{apply_equality}, we reduce the equality to reasoning about
  1677 Using \ttindex{apply_equality}, we reduce the equality to reasoning about
  1657 ordered pairs.
  1678 ordered pairs.  The second subgoal is to verify that $f\un g$ is a function.
  1658 \begin{ttbox}
  1679 \begin{ttbox}
  1659 by (resolve_tac [apply_equality] 1);
  1680 by (resolve_tac [apply_equality] 1);
  1660 {\out Level 1}
  1681 {\out Level 1}
  1661 {\out (f Un g) ` a = f ` a}
  1682 {\out (f Un g) ` a = f ` a}
  1662 {\out  1. <a,f ` a> : f Un g}
  1683 {\out  1. <a,f ` a> : f Un g}
  1720 by (resolve_tac prems 1);
  1741 by (resolve_tac prems 1);
  1721 {\out Level 9}
  1742 {\out Level 9}
  1722 {\out (f Un g) ` a = f ` a}
  1743 {\out (f Un g) ` a = f ` a}
  1723 {\out No subgoals!}
  1744 {\out No subgoals!}
  1724 \end{ttbox}
  1745 \end{ttbox}
  1725 See the files \ttindex{ZF/func.ML} and \ttindex{ZF/wf.ML} for more
  1746 See the files {\tt ZF/func.ML} and {\tt ZF/wf.ML} for more
  1726 examples of reasoning about functions.
  1747 examples of reasoning about functions.