author | wenzelm |
Mon, 02 Dec 1996 10:22:41 +0100 | |
changeset 2286 | c2f76a5bad65 |
parent 1478 | 2b8c2a7547ab |
child 2469 | b50b8c0eec01 |
permissions | -rw-r--r-- |
615 | 1 |
(* Title: ZF/ZF.thy |
0 | 2 |
ID: $Id$ |
3 |
Author: Lawrence C Paulson and Martin D Coen, CU Computer Laboratory |
|
4 |
Copyright 1993 University of Cambridge |
|
5 |
||
6 |
Zermelo-Fraenkel Set Theory |
|
7 |
*) |
|
8 |
||
1106
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
9 |
ZF = FOL + Let + |
0 | 10 |
|
11 |
types |
|
615 | 12 |
i |
0 | 13 |
|
14 |
arities |
|
15 |
i :: term |
|
16 |
||
17 |
consts |
|
18 |
||
1401 | 19 |
"0" :: i ("0") (*the empty set*) |
20 |
Pow :: i => i (*power sets*) |
|
21 |
Inf :: i (*infinite set*) |
|
0 | 22 |
|
23 |
(* Bounded Quantifiers *) |
|
24 |
||
1401 | 25 |
Ball, Bex :: [i, i => o] => o |
0 | 26 |
|
27 |
(* General Union and Intersection *) |
|
28 |
||
1401 | 29 |
Union,Inter :: i => i |
0 | 30 |
|
31 |
(* Variations on Replacement *) |
|
32 |
||
1401 | 33 |
PrimReplace :: [i, [i, i] => o] => i |
34 |
Replace :: [i, [i, i] => o] => i |
|
35 |
RepFun :: [i, i => i] => i |
|
36 |
Collect :: [i, i => o] => i |
|
0 | 37 |
|
38 |
(* Descriptions *) |
|
39 |
||
1401 | 40 |
The :: (i => o) => i (binder "THE " 10) |
41 |
if :: [o, i, i] => i |
|
0 | 42 |
|
43 |
(* Finite Sets *) |
|
44 |
||
1401 | 45 |
Upair, cons :: [i, i] => i |
46 |
succ :: i => i |
|
0 | 47 |
|
615 | 48 |
(* Ordered Pairing *) |
0 | 49 |
|
1401 | 50 |
Pair :: [i, i] => i |
51 |
fst, snd :: i => i |
|
52 |
split :: [[i, i] => 'a, i] => 'a::logic (*for pattern-matching*) |
|
0 | 53 |
|
54 |
(* Sigma and Pi Operators *) |
|
55 |
||
1401 | 56 |
Sigma, Pi :: [i, i => i] => i |
0 | 57 |
|
58 |
(* Relations and Functions *) |
|
59 |
||
1401 | 60 |
domain :: i => i |
61 |
range :: i => i |
|
62 |
field :: i => i |
|
63 |
converse :: i => i |
|
1478 | 64 |
function :: i => o (*is a relation a function?*) |
1401 | 65 |
Lambda :: [i, i => i] => i |
66 |
restrict :: [i, i] => i |
|
0 | 67 |
|
68 |
(* Infixes in order of decreasing precedence *) |
|
69 |
||
1401 | 70 |
"``" :: [i, i] => i (infixl 90) (*image*) |
71 |
"-``" :: [i, i] => i (infixl 90) (*inverse image*) |
|
72 |
"`" :: [i, i] => i (infixl 90) (*function application*) |
|
73 |
(*"*" :: [i, i] => i (infixr 80) (*Cartesian product*)*) |
|
74 |
"Int" :: [i, i] => i (infixl 70) (*binary intersection*) |
|
75 |
"Un" :: [i, i] => i (infixl 65) (*binary union*) |
|
76 |
"-" :: [i, i] => i (infixl 65) (*set difference*) |
|
77 |
(*"->" :: [i, i] => i (infixr 60) (*function space*)*) |
|
78 |
"<=" :: [i, i] => o (infixl 50) (*subset relation*) |
|
79 |
":" :: [i, i] => o (infixl 50) (*membership relation*) |
|
80 |
(*"~:" :: [i, i] => o (infixl 50) (*negated membership relation*)*) |
|
0 | 81 |
|
82 |
||
615 | 83 |
types |
84 |
is |
|
1106
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
85 |
pttrns |
615 | 86 |
|
87 |
syntax |
|
1401 | 88 |
"" :: i => is ("_") |
89 |
"@Enum" :: [i, is] => is ("_,/ _") |
|
90 |
"~:" :: [i, i] => o (infixl 50) |
|
91 |
"@Finset" :: is => i ("{(_)}") |
|
92 |
"@Tuple" :: [i, is] => i ("<(_,/ _)>") |
|
93 |
"@Collect" :: [pttrn, i, o] => i ("(1{_: _ ./ _})") |
|
94 |
"@Replace" :: [pttrn, pttrn, i, o] => i ("(1{_ ./ _: _, _})") |
|
95 |
"@RepFun" :: [i, pttrn, i] => i ("(1{_ ./ _: _})" [51,0,51]) |
|
96 |
"@INTER" :: [pttrn, i, i] => i ("(3INT _:_./ _)" 10) |
|
97 |
"@UNION" :: [pttrn, i, i] => i ("(3UN _:_./ _)" 10) |
|
98 |
"@PROD" :: [pttrn, i, i] => i ("(3PROD _:_./ _)" 10) |
|
99 |
"@SUM" :: [pttrn, i, i] => i ("(3SUM _:_./ _)" 10) |
|
100 |
"->" :: [i, i] => i (infixr 60) |
|
101 |
"*" :: [i, i] => i (infixr 80) |
|
102 |
"@lam" :: [pttrn, i, i] => i ("(3lam _:_./ _)" 10) |
|
103 |
"@Ball" :: [pttrn, i, o] => o ("(3ALL _:_./ _)" 10) |
|
104 |
"@Bex" :: [pttrn, i, o] => o ("(3EX _:_./ _)" 10) |
|
1106
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
105 |
|
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
106 |
(** Patterns -- extends pre-defined type "pttrn" used in abstractions **) |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
107 |
|
1401 | 108 |
"@pttrn" :: pttrns => pttrn ("<_>") |
109 |
"" :: pttrn => pttrns ("_") |
|
110 |
"@pttrns" :: [pttrn,pttrns] => pttrns ("_,/_") |
|
615 | 111 |
|
0 | 112 |
translations |
615 | 113 |
"x ~: y" == "~ (x : y)" |
0 | 114 |
"{x, xs}" == "cons(x, {xs})" |
115 |
"{x}" == "cons(x, 0)" |
|
116 |
"{x:A. P}" == "Collect(A, %x. P)" |
|
117 |
"{y. x:A, Q}" == "Replace(A, %x y. Q)" |
|
615 | 118 |
"{b. x:A}" == "RepFun(A, %x. b)" |
0 | 119 |
"INT x:A. B" == "Inter({B. x:A})" |
120 |
"UN x:A. B" == "Union({B. x:A})" |
|
121 |
"PROD x:A. B" => "Pi(A, %x. B)" |
|
122 |
"SUM x:A. B" => "Sigma(A, %x. B)" |
|
49 | 123 |
"A -> B" => "Pi(A, _K(B))" |
124 |
"A * B" => "Sigma(A, _K(B))" |
|
0 | 125 |
"lam x:A. f" == "Lambda(A, %x. f)" |
126 |
"ALL x:A. P" == "Ball(A, %x. P)" |
|
127 |
"EX x:A. P" == "Bex(A, %x. P)" |
|
37 | 128 |
|
1106
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
129 |
"<x, y, z>" == "<x, <y, z>>" |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
130 |
"<x, y>" == "Pair(x, y)" |
2286 | 131 |
"%<x,y,zs>.b" == "split(%x <y,zs>.b)" |
132 |
"%<x,y>.b" == "split(%x y.b)" |
|
133 |
||
0 | 134 |
|
690 | 135 |
defs |
0 | 136 |
|
615 | 137 |
(* Bounded Quantifiers *) |
138 |
Ball_def "Ball(A, P) == ALL x. x:A --> P(x)" |
|
139 |
Bex_def "Bex(A, P) == EX x. x:A & P(x)" |
|
690 | 140 |
|
615 | 141 |
subset_def "A <= B == ALL x:A. x:B" |
690 | 142 |
succ_def "succ(i) == cons(i, i)" |
143 |
||
144 |
rules |
|
0 | 145 |
|
615 | 146 |
(* ZF axioms -- see Suppes p.238 |
147 |
Axioms for Union, Pow and Replace state existence only, |
|
148 |
uniqueness is derivable using extensionality. *) |
|
0 | 149 |
|
615 | 150 |
extension "A = B <-> A <= B & B <= A" |
151 |
Union_iff "A : Union(C) <-> (EX B:C. A:B)" |
|
152 |
Pow_iff "A : Pow(B) <-> A <= B" |
|
0 | 153 |
|
615 | 154 |
(*We may name this set, though it is not uniquely defined.*) |
155 |
infinity "0:Inf & (ALL y:Inf. succ(y): Inf)" |
|
0 | 156 |
|
615 | 157 |
(*This formulation facilitates case analysis on A.*) |
158 |
foundation "A=0 | (EX x:A. ALL y:x. y~:A)" |
|
0 | 159 |
|
615 | 160 |
(*Schema axiom since predicate P is a higher-order variable*) |
1155 | 161 |
replacement "(ALL x:A. ALL y z. P(x,y) & P(x,z) --> y=z) ==> |
162 |
b : PrimReplace(A,P) <-> (EX x:A. P(x,b))" |
|
615 | 163 |
|
690 | 164 |
defs |
165 |
||
615 | 166 |
(* Derived form of replacement, restricting P to its functional part. |
167 |
The resulting set (for functional P) is the same as with |
|
168 |
PrimReplace, but the rules are simpler. *) |
|
0 | 169 |
|
615 | 170 |
Replace_def "Replace(A,P) == PrimReplace(A, %x y. (EX!z.P(x,z)) & P(x,y))" |
171 |
||
172 |
(* Functional form of replacement -- analgous to ML's map functional *) |
|
0 | 173 |
|
615 | 174 |
RepFun_def "RepFun(A,f) == {y . x:A, y=f(x)}" |
0 | 175 |
|
615 | 176 |
(* Separation and Pairing can be derived from the Replacement |
177 |
and Powerset Axioms using the following definitions. *) |
|
0 | 178 |
|
615 | 179 |
Collect_def "Collect(A,P) == {y . x:A, x=y & P(x)}" |
0 | 180 |
|
615 | 181 |
(*Unordered pairs (Upair) express binary union/intersection and cons; |
182 |
set enumerations translate as {a,...,z} = cons(a,...,cons(z,0)...)*) |
|
0 | 183 |
|
615 | 184 |
Upair_def "Upair(a,b) == {y. x:Pow(Pow(0)), (x=0 & y=a) | (x=Pow(0) & y=b)}" |
185 |
cons_def "cons(a,A) == Upair(a,a) Un A" |
|
186 |
||
187 |
(* Difference, general intersection, binary union and small intersection *) |
|
0 | 188 |
|
615 | 189 |
Diff_def "A - B == { x:A . ~(x:B) }" |
190 |
Inter_def "Inter(A) == { x:Union(A) . ALL y:A. x:y}" |
|
191 |
Un_def "A Un B == Union(Upair(A,B))" |
|
192 |
Int_def "A Int B == Inter(Upair(A,B))" |
|
0 | 193 |
|
615 | 194 |
(* Definite descriptions -- via Replace over the set "1" *) |
0 | 195 |
|
615 | 196 |
the_def "The(P) == Union({y . x:{0}, P(y)})" |
197 |
if_def "if(P,a,b) == THE z. P & z=a | ~P & z=b" |
|
0 | 198 |
|
615 | 199 |
(* Ordered pairs and disjoint union of a family of sets *) |
0 | 200 |
|
615 | 201 |
(* this "symmetric" definition works better than {{a}, {a,b}} *) |
202 |
Pair_def "<a,b> == {{a,a}, {a,b}}" |
|
1106
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
203 |
fst_def "fst(p) == THE a. EX b. p=<a,b>" |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
204 |
snd_def "snd(p) == THE b. EX a. p=<a,b>" |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
205 |
split_def "split(c,p) == c(fst(p), snd(p))" |
615 | 206 |
Sigma_def "Sigma(A,B) == UN x:A. UN y:B(x). {<x,y>}" |
0 | 207 |
|
615 | 208 |
(* Operations on relations *) |
0 | 209 |
|
615 | 210 |
(*converse of relation r, inverse of function*) |
211 |
converse_def "converse(r) == {z. w:r, EX x y. w=<x,y> & z=<y,x>}" |
|
0 | 212 |
|
615 | 213 |
domain_def "domain(r) == {x. w:r, EX y. w=<x,y>}" |
214 |
range_def "range(r) == domain(converse(r))" |
|
215 |
field_def "field(r) == domain(r) Un range(r)" |
|
1478 | 216 |
function_def "function(r) == ALL x y. <x,y>:r --> |
217 |
(ALL y'. <x,y'>:r --> y=y')" |
|
615 | 218 |
image_def "r `` A == {y : range(r) . EX x:A. <x,y> : r}" |
219 |
vimage_def "r -`` A == converse(r)``A" |
|
0 | 220 |
|
615 | 221 |
(* Abstraction, application and Cartesian product of a family of sets *) |
0 | 222 |
|
615 | 223 |
lam_def "Lambda(A,b) == {<x,b(x)> . x:A}" |
224 |
apply_def "f`a == THE y. <a,y> : f" |
|
690 | 225 |
Pi_def "Pi(A,B) == {f: Pow(Sigma(A,B)). A<=domain(f) & function(f)}" |
0 | 226 |
|
227 |
(* Restrict the function f to the domain A *) |
|
615 | 228 |
restrict_def "restrict(f,A) == lam x:A.f`x" |
0 | 229 |
|
230 |
end |
|
231 |
||
232 |
||
233 |
ML |
|
234 |
||
1106
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
235 |
(* Pattern-matching and 'Dependent' type operators *) |
1116 | 236 |
(* |
1106
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
237 |
local open Syntax |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
238 |
|
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
239 |
fun pttrn s = const"@pttrn" $ s; |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
240 |
fun pttrns s t = const"@pttrns" $ s $ t; |
0 | 241 |
|
1106
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
242 |
fun split2(Abs(x,T,t)) = |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
243 |
let val (pats,u) = split1 t |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
244 |
in (pttrns (Free(x,T)) pats, subst_bounds([free x],u)) end |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
245 |
| split2(Const("split",_) $ r) = |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
246 |
let val (pats,s) = split2(r) |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
247 |
val (pats2,t) = split1(s) |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
248 |
in (pttrns (pttrn pats) pats2, t) end |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
249 |
and split1(Abs(x,T,t)) = (Free(x,T), subst_bounds([free x],t)) |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
250 |
| split1(Const("split",_)$t) = split2(t); |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
251 |
|
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
252 |
fun split_tr'(t::args) = |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
253 |
let val (pats,ft) = split2(t) |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
254 |
in list_comb(const"_lambda" $ pttrn pats $ ft, args) end; |
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
255 |
|
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
256 |
in |
1116 | 257 |
*) |
1106
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
258 |
val print_translation = |
1116 | 259 |
[(*("split", split_tr'),*) |
1106
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
260 |
("Pi", dependent_tr' ("@PROD", "op ->")), |
632 | 261 |
("Sigma", dependent_tr' ("@SUM", "op *"))]; |
1116 | 262 |
(* |
1106
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy. Changed
lcp
parents:
690
diff
changeset
|
263 |
end; |
1116 | 264 |
*) |