src/ZF/ZF.thy
author wenzelm
Mon Oct 11 12:35:00 1993 +0100 (1993-10-11 ago)
changeset 49 c78503b345c4
parent 37 cebe01deba80
child 80 0d10b8a501d5
permissions -rw-r--r--
"The" now a binder, removed translation;
improved encoding and translations of tuples;
added parse rules for -> and *, removed ndependent_tr;
clasohm@0
     1
(*  Title:      ZF/zf.thy
clasohm@0
     2
    ID:         $Id$
clasohm@0
     3
    Author:     Lawrence C Paulson and Martin D Coen, CU Computer Laboratory
clasohm@0
     4
    Copyright   1993  University of Cambridge
clasohm@0
     5
clasohm@0
     6
Zermelo-Fraenkel Set Theory
clasohm@0
     7
*)
clasohm@0
     8
clasohm@0
     9
ZF = FOL +
clasohm@0
    10
clasohm@0
    11
types
wenzelm@49
    12
  i, is 0
clasohm@0
    13
clasohm@0
    14
arities
clasohm@0
    15
  i :: term
clasohm@0
    16
clasohm@0
    17
clasohm@0
    18
consts
clasohm@0
    19
clasohm@0
    20
  "0"          :: "i"                          ("0") (*the empty set*)
clasohm@0
    21
  Pow          :: "i => i"                                 (*power sets*)
clasohm@0
    22
  Inf          :: "i"                                      (*infinite set*)
clasohm@0
    23
clasohm@0
    24
  (* Bounded Quantifiers *)
clasohm@0
    25
clasohm@0
    26
  "@Ball"      :: "[idt, i, o] => o"           ("(3ALL _:_./ _)" 10)
clasohm@0
    27
  "@Bex"       :: "[idt, i, o] => o"           ("(3EX _:_./ _)" 10)
clasohm@0
    28
  Ball         :: "[i, i => o] => o"
clasohm@0
    29
  Bex          :: "[i, i => o] => o"
clasohm@0
    30
clasohm@0
    31
  (* General Union and Intersection *)
clasohm@0
    32
clasohm@0
    33
  "@INTER"     :: "[idt, i, i] => i"           ("(3INT _:_./ _)" 10)
clasohm@0
    34
  "@UNION"     :: "[idt, i, i] => i"           ("(3UN _:_./ _)" 10)
clasohm@0
    35
  Union, Inter :: "i => i"
clasohm@0
    36
clasohm@0
    37
  (* Variations on Replacement *)
clasohm@0
    38
clasohm@0
    39
  "@Replace"   :: "[idt, idt, i, o] => i"      ("(1{_ ./ _: _, _})")
clasohm@0
    40
  "@RepFun"    :: "[i, idt, i] => i"           ("(1{_ ./ _: _})")
clasohm@0
    41
  "@Collect"   :: "[idt, i, o] => i"           ("(1{_: _ ./ _})")
clasohm@0
    42
  PrimReplace  :: "[i, [i, i] => o] => i"
clasohm@0
    43
  Replace      :: "[i, [i, i] => o] => i"
clasohm@0
    44
  RepFun       :: "[i, i => i] => i"
clasohm@0
    45
  Collect      :: "[i, i => o] => i"
clasohm@0
    46
clasohm@0
    47
  (* Descriptions *)
clasohm@0
    48
wenzelm@49
    49
  The          :: "(i => o) => i"              (binder "THE " 10)
clasohm@0
    50
  if           :: "[o, i, i] => i"
clasohm@0
    51
clasohm@0
    52
  (* Enumerations of type i *)
clasohm@0
    53
clasohm@0
    54
  ""           :: "i => is"                    ("_")
clasohm@0
    55
  "@Enum"      :: "[i, is] => is"              ("_,/ _")
clasohm@0
    56
clasohm@0
    57
  (* Finite Sets *)
clasohm@0
    58
clasohm@0
    59
  "@Finset"    :: "is => i"                    ("{(_)}")
clasohm@0
    60
  Upair, cons  :: "[i, i] => i"
clasohm@0
    61
  succ         :: "i => i"
clasohm@0
    62
clasohm@0
    63
  (* Ordered Pairing and n-Tuples *)
clasohm@0
    64
clasohm@0
    65
  "@Tuple"     :: "[i, is] => i"               ("<(_,/ _)>")
clasohm@0
    66
  Pair         :: "[i, i] => i"
clasohm@0
    67
  fst, snd     :: "i => i"
clasohm@0
    68
  split        :: "[[i,i] => i, i] => i"
clasohm@0
    69
  fsplit       :: "[[i,i] => o, i] => o"
clasohm@0
    70
clasohm@0
    71
  (* Sigma and Pi Operators *)
clasohm@0
    72
clasohm@0
    73
  "@PROD"      :: "[idt, i, i] => i"           ("(3PROD _:_./ _)" 10)
clasohm@0
    74
  "@SUM"       :: "[idt, i, i] => i"           ("(3SUM _:_./ _)" 10)
clasohm@0
    75
  "@lam"       :: "[idt, i, i] => i"           ("(3lam _:_./ _)" 10)
clasohm@0
    76
  Pi, Sigma    :: "[i, i => i] => i"
clasohm@0
    77
clasohm@0
    78
  (* Relations and Functions *)
clasohm@0
    79
clasohm@0
    80
  domain       :: "i => i"
clasohm@0
    81
  range        :: "i => i"
clasohm@0
    82
  field        :: "i => i"
clasohm@0
    83
  converse     :: "i => i"
clasohm@0
    84
  Lambda       :: "[i, i => i] => i"
clasohm@0
    85
  restrict     :: "[i, i] => i"
clasohm@0
    86
clasohm@0
    87
  (* Infixes in order of decreasing precedence *)
clasohm@0
    88
clasohm@0
    89
  "``"  :: "[i, i] => i"         (infixl 90) (*image*)
clasohm@0
    90
  "-``" :: "[i, i] => i"         (infixl 90) (*inverse image*)
clasohm@0
    91
  "`"   :: "[i, i] => i"         (infixl 90) (*function application*)
clasohm@0
    92
clasohm@0
    93
  (*Except for their translations, * and -> are right-associating infixes*)
clasohm@0
    94
  " *"  :: "[i, i] => i"         ("(_ */ _)" [81, 80] 80) (*Cartesian product*)
clasohm@0
    95
  "Int" :: "[i, i] => i"         (infixl 70) (*binary intersection*)
clasohm@0
    96
  "Un"  :: "[i, i] => i"         (infixl 65) (*binary union*)
clasohm@0
    97
  "-"   :: "[i, i] => i"         (infixl 65) (*set difference*)
clasohm@0
    98
  " ->" :: "[i, i] => i"         ("(_ ->/ _)" [61, 60] 60) (*function space*)
clasohm@0
    99
  "<="  :: "[i, i] => o"         (infixl 50) (*subset relation*)
clasohm@0
   100
  ":"   :: "[i, i] => o"         (infixl 50) (*membership relation*)
wenzelm@49
   101
  "~:"  :: "[i, i] => o"         (infixl 50) (*negated membership relation*)
clasohm@0
   102
clasohm@0
   103
clasohm@0
   104
translations
clasohm@0
   105
  "{x, xs}"     == "cons(x, {xs})"
clasohm@0
   106
  "{x}"         == "cons(x, 0)"
wenzelm@49
   107
  "<x, y, z>"   == "<x, <y, z>>"
wenzelm@49
   108
  "<x, y>"      == "Pair(x, y)"
clasohm@0
   109
  "{x:A. P}"    == "Collect(A, %x. P)"
clasohm@0
   110
  "{y. x:A, Q}" == "Replace(A, %x y. Q)"
clasohm@0
   111
  "{f. x:A}"    == "RepFun(A, %x. f)"
clasohm@0
   112
  "INT x:A. B"  == "Inter({B. x:A})"
clasohm@0
   113
  "UN x:A. B"   == "Union({B. x:A})"
clasohm@0
   114
  "PROD x:A. B" => "Pi(A, %x. B)"
clasohm@0
   115
  "SUM x:A. B"  => "Sigma(A, %x. B)"
wenzelm@49
   116
  "A -> B"      => "Pi(A, _K(B))"
wenzelm@49
   117
  "A * B"       => "Sigma(A, _K(B))"
clasohm@0
   118
  "lam x:A. f"  == "Lambda(A, %x. f)"
clasohm@0
   119
  "ALL x:A. P"  == "Ball(A, %x. P)"
clasohm@0
   120
  "EX x:A. P"   == "Bex(A, %x. P)"
lcp@37
   121
  "x ~: y"      == "~ (x:y)"
lcp@37
   122
clasohm@0
   123
clasohm@0
   124
rules
clasohm@0
   125
clasohm@0
   126
 (* Bounded Quantifiers *)
clasohm@0
   127
Ball_def        "Ball(A,P) == ALL x. x:A --> P(x)"
clasohm@0
   128
Bex_def         "Bex(A,P) == EX x. x:A & P(x)"
clasohm@0
   129
subset_def      "A <= B == ALL x:A. x:B"
clasohm@0
   130
clasohm@0
   131
 (* ZF axioms -- see Suppes p.238
clasohm@0
   132
    Axioms for Union, Pow and Replace state existence only,
clasohm@0
   133
        uniqueness is derivable using extensionality.  *)
clasohm@0
   134
clasohm@0
   135
extension       "A = B <-> A <= B & B <= A"
clasohm@0
   136
union_iff       "A : Union(C) <-> (EX B:C. A:B)"
clasohm@0
   137
power_set       "A : Pow(B) <-> A <= B"
clasohm@0
   138
succ_def        "succ(i) == cons(i,i)"
clasohm@0
   139
clasohm@0
   140
 (*We may name this set, though it is not uniquely defined. *)
clasohm@0
   141
infinity        "0:Inf & (ALL y:Inf. succ(y): Inf)"
clasohm@0
   142
clasohm@0
   143
 (*This formulation facilitates case analysis on A. *)
lcp@37
   144
foundation      "A=0 | (EX x:A. ALL y:x. y~:A)"
clasohm@0
   145
clasohm@0
   146
 (* Schema axiom since predicate P is a higher-order variable *)
clasohm@0
   147
replacement     "(ALL x:A. ALL y z. P(x,y) & P(x,z) --> y=z) ==> \
clasohm@0
   148
\                        b : PrimReplace(A,P) <-> (EX x:A. P(x,b))"
clasohm@0
   149
clasohm@0
   150
 (* Derived form of replacement, restricting P to its functional part.
clasohm@0
   151
    The resulting set (for functional P) is the same as with
clasohm@0
   152
    PrimReplace, but the rules are simpler. *)
clasohm@0
   153
Replace_def     "Replace(A,P) == PrimReplace(A, %x y. (EX!z.P(x,z)) & P(x,y))"
clasohm@0
   154
clasohm@0
   155
 (* Functional form of replacement -- analgous to ML's map functional *)
clasohm@0
   156
RepFun_def      "RepFun(A,f) == {y . x:A, y=f(x)}"
clasohm@0
   157
clasohm@0
   158
 (* Separation and Pairing can be derived from the Replacement
clasohm@0
   159
    and Powerset Axioms using the following definitions.  *)
clasohm@0
   160
clasohm@0
   161
Collect_def     "Collect(A,P) == {y . x:A, x=y & P(x)}"
clasohm@0
   162
clasohm@0
   163
 (*Unordered pairs (Upair) express binary union/intersection and cons;
clasohm@0
   164
   set enumerations translate as {a,...,z} = cons(a,...,cons(z,0)...)  *)
clasohm@0
   165
Upair_def   "Upair(a,b) == {y. x:Pow(Pow(0)), (x=0 & y=a) | (x=Pow(0) & y=b)}"
clasohm@0
   166
cons_def    "cons(a,A) == Upair(a,a) Un A"
clasohm@0
   167
clasohm@0
   168
 (* Difference, general intersection, binary union and small intersection *)
clasohm@0
   169
clasohm@0
   170
Diff_def        "A - B    == { x:A . ~(x:B) }"
clasohm@0
   171
Inter_def       "Inter(A) == { x:Union(A) . ALL y:A. x:y}"
clasohm@0
   172
Un_def          "A Un  B  == Union(Upair(A,B))"
clasohm@0
   173
Int_def         "A Int B  == Inter(Upair(A,B))"
clasohm@0
   174
clasohm@0
   175
 (* Definite descriptions -- via Replace over the set "1" *)
clasohm@0
   176
clasohm@0
   177
the_def         "The(P)    == Union({y . x:{0}, P(y)})"
clasohm@0
   178
if_def          "if(P,a,b) == THE z. P & z=a | ~P & z=b"
clasohm@0
   179
clasohm@0
   180
 (* Ordered pairs and disjoint union of a family of sets *)
clasohm@0
   181
clasohm@0
   182
 (* this "symmetric" definition works better than {{a}, {a,b}} *)
clasohm@0
   183
Pair_def        "<a,b>  == {{a,a}, {a,b}}"
clasohm@0
   184
fst_def         "fst == split(%x y.x)"
clasohm@0
   185
snd_def         "snd == split(%x y.y)"
clasohm@0
   186
split_def       "split(c,p) == THE y. EX a b. p=<a,b> & y=c(a,b)"
clasohm@0
   187
fsplit_def      "fsplit(R,z) == EX x y. z=<x,y> & R(x,y)"
clasohm@0
   188
Sigma_def       "Sigma(A,B) == UN x:A. UN y:B(x). {<x,y>}"
clasohm@0
   189
clasohm@0
   190
 (* Operations on relations *)
clasohm@0
   191
clasohm@0
   192
(*converse of relation r, inverse of function*)
clasohm@0
   193
converse_def    "converse(r) == {z. w:r, EX x y. w=<x,y> & z=<y,x>}"
clasohm@0
   194
clasohm@0
   195
domain_def      "domain(r) == {x. w:r, EX y. w=<x,y>}"
clasohm@0
   196
range_def       "range(r) == domain(converse(r))"
clasohm@0
   197
field_def       "field(r) == domain(r) Un range(r)"
clasohm@0
   198
image_def       "r `` A  == {y : range(r) . EX x:A. <x,y> : r}"
clasohm@0
   199
vimage_def      "r -`` A == converse(r)``A"
clasohm@0
   200
clasohm@0
   201
 (* Abstraction, application and Cartesian product of a family of sets *)
clasohm@0
   202
clasohm@0
   203
lam_def         "Lambda(A,b) == {<x,b(x)> . x:A}"
clasohm@0
   204
apply_def       "f`a == THE y. <a,y> : f"
clasohm@0
   205
Pi_def          "Pi(A,B)  == {f: Pow(Sigma(A,B)). ALL x:A. EX! y. <x,y>: f}"
clasohm@0
   206
clasohm@0
   207
  (* Restrict the function f to the domain A *)
clasohm@0
   208
restrict_def    "restrict(f,A) == lam x:A.f`x"
clasohm@0
   209
clasohm@0
   210
end
clasohm@0
   211
clasohm@0
   212
clasohm@0
   213
ML
clasohm@0
   214
clasohm@0
   215
(* 'Dependent' type operators *)
clasohm@0
   216
clasohm@0
   217
val print_translation =
clasohm@0
   218
  [("Pi", dependent_tr' ("@PROD", " ->")),
clasohm@0
   219
   ("Sigma", dependent_tr' ("@SUM", " *"))];
wenzelm@49
   220