# HG changeset patch # User wenzelm # Date 1452554323 -3600 # Node ID a02b79ef23390c3c525b1f6af63188297cb4b5c0 # Parent e410c628710374e0e8af623048e4f2fc44175f5c clarified axiomatization versus definitions; eliminated old defs; more symbols; diff -r e410c6287103 -r a02b79ef2339 src/ZF/ZF.thy --- a/src/ZF/ZF.thy Mon Jan 11 22:34:20 2016 +0100 +++ b/src/ZF/ZF.thy Tue Jan 12 00:18:43 2016 +0100 @@ -3,147 +3,262 @@ Copyright 1993 University of Cambridge *) -section\Zermelo-Fraenkel Set Theory\ +section \Zermelo-Fraenkel Set Theory\ theory ZF imports "~~/src/FOL/FOL" begin +subsection \Signature\ + declare [[eta_contract = false]] typedecl i instance i :: "term" .. -axiomatization - zero :: "i" ("0") \\the empty set\ and - Pow :: "i => i" \\power sets\ and - Inf :: "i" \\infinite set\ +axiomatization mem :: "[i, i] \ o" (infixl "\" 50) \ \membership relation\ + and zero :: "i" ("0") \ \the empty set\ + and Pow :: "i \ i" \ \power sets\ + and Inf :: "i" \ \infinite set\ + and Union :: "i \ i" ("\_" [90] 90) + and PrimReplace :: "[i, [i, i] \ o] \ i" + +abbreviation not_mem :: "[i, i] \ o" (infixl "\" 50) \ \negated membership relation\ + where "x \ y \ \ (x \ y)" + + +subsection \Bounded Quantifiers\ + +definition Ball :: "[i, i \ o] \ o" + where "Ball(A, P) \ \x. x\A \ P(x)" -text \Bounded Quantifiers\ -consts - Ball :: "[i, i => o] => o" - Bex :: "[i, i => o] => o" +definition Bex :: "[i, i \ o] \ o" + where "Bex(A, P) \ \x. x\A \ P(x)" -text \General Union and Intersection\ -axiomatization Union :: "i => i" ("\_" [90] 90) -consts Inter :: "i => i" ("\_" [90] 90) +syntax + "_Ball" :: "[pttrn, i, o] \ o" ("(3\_\_./ _)" 10) + "_Bex" :: "[pttrn, i, o] \ o" ("(3\_\_./ _)" 10) +translations + "\x\A. P" \ "CONST Ball(A, \x. P)" + "\x\A. P" \ "CONST Bex(A, \x. P)" + + +subsection \Variations on Replacement\ + +(* Derived form of replacement, restricting P to its functional part. + The resulting set (for functional P) is the same as with + PrimReplace, but the rules are simpler. *) +definition Replace :: "[i, [i, i] \ o] \ i" + where "Replace(A,P) == PrimReplace(A, %x y. (EX!z. P(x,z)) & P(x,y))" -text \Variations on Replacement\ -axiomatization PrimReplace :: "[i, [i, i] => o] => i" -consts - Replace :: "[i, [i, i] => o] => i" - RepFun :: "[i, i => i] => i" - Collect :: "[i, i => o] => i" +syntax + "_Replace" :: "[pttrn, pttrn, i, o] => i" ("(1{_ ./ _ \ _, _})") +translations + "{y. x\A, Q}" \ "CONST Replace(A, \x y. Q)" + + +(* Functional form of replacement -- analgous to ML's map functional *) + +definition RepFun :: "[i, i \ i] \ i" + where "RepFun(A,f) == {y . x\A, y=f(x)}" + +syntax + "_RepFun" :: "[i, pttrn, i] => i" ("(1{_ ./ _ \ _})" [51,0,51]) +translations + "{b. x\A}" \ "CONST RepFun(A, \x. b)" + -text\Definite descriptions -- via Replace over the set "1"\ -consts - The :: "(i => o) => i" (binder "THE " 10) - If :: "[o, i, i] => i" ("(if (_)/ then (_)/ else (_))" [10] 10) +(* Separation and Pairing can be derived from the Replacement + and Powerset Axioms using the following definitions. *) +definition Collect :: "[i, i \ o] \ i" + where "Collect(A,P) == {y . x\A, x=y & P(x)}" + +syntax + "_Collect" :: "[pttrn, i, o] \ i" ("(1{_ \ _ ./ _})") +translations + "{x\A. P}" \ "CONST Collect(A, \x. P)" + -abbreviation (input) - old_if :: "[o, i, i] => i" ("if '(_,_,_')") where - "if(P,a,b) == If(P,a,b)" +subsection \General union and intersection\ + +definition Inter :: "i => i" ("\_" [90] 90) + where "\(A) == { x\\(A) . \y\A. x\y}" + +syntax + "_UNION" :: "[pttrn, i, i] => i" ("(3\_\_./ _)" 10) + "_INTER" :: "[pttrn, i, i] => i" ("(3\_\_./ _)" 10) +translations + "\x\A. B" == "CONST Union({B. x\A})" + "\x\A. B" == "CONST Inter({B. x\A})" -text \Finite Sets\ -consts - Upair :: "[i, i] => i" - cons :: "[i, i] => i" - succ :: "i => i" +subsection \Finite sets and binary operations\ + +(*Unordered pairs (Upair) express binary union/intersection and cons; + set enumerations translate as {a,...,z} = cons(a,...,cons(z,0)...)*) + +definition Upair :: "[i, i] => i" + where "Upair(a,b) == {y. x\Pow(Pow(0)), (x=0 & y=a) | (x=Pow(0) & y=b)}" -text \Ordered Pairing\ -consts - Pair :: "[i, i] => i" - fst :: "i => i" - snd :: "i => i" - split :: "[[i, i] => 'a, i] => 'a::{}" \\for pattern-matching\ +definition Subset :: "[i, i] \ o" (infixl "\" 50) \ \subset relation\ + where subset_def: "A \ B \ \x\A. x\B" + +definition Diff :: "[i, i] \ i" (infixl "-" 65) \ \set difference\ + where "A - B == { x\A . ~(x\B) }" -text \Sigma and Pi Operators\ -consts - Sigma :: "[i, i => i] => i" - Pi :: "[i, i => i] => i" +definition Un :: "[i, i] \ i" (infixl "\" 65) \ \binary union\ + where "A \ B == \(Upair(A,B))" + +definition Int :: "[i, i] \ i" (infixl "\" 70) \ \binary intersection\ + where "A \ B == \(Upair(A,B))" -text \Relations and Functions\ -consts - "domain" :: "i => i" - range :: "i => i" - field :: "i => i" - converse :: "i => i" - relation :: "i => o" \\recognizes sets of pairs\ - "function" :: "i => o" \\recognizes functions; can have non-pairs\ - Lambda :: "[i, i => i] => i" - restrict :: "[i, i] => i" +definition cons :: "[i, i] => i" + where "cons(a,A) == Upair(a,a) \ A" + +definition succ :: "i => i" + where "succ(i) == cons(i, i)" -text \Infixes in order of decreasing precedence\ -consts - Image :: "[i, i] => i" (infixl "``" 90) \\image\ - vimage :: "[i, i] => i" (infixl "-``" 90) \\inverse image\ - "apply" :: "[i, i] => i" (infixl "`" 90) \\function application\ - "Int" :: "[i, i] => i" (infixl "\" 70) \\binary intersection\ - "Un" :: "[i, i] => i" (infixl "\" 65) \\binary union\ - Diff :: "[i, i] => i" (infixl "-" 65) \\set difference\ - Subset :: "[i, i] => o" (infixl "\" 50) \\subset relation\ +nonterminal "is" +syntax + "" :: "i \ is" ("_") + "_Enum" :: "[i, is] \ is" ("_,/ _") + "_Finset" :: "is \ i" ("{(_)}") +translations + "{x, xs}" == "CONST cons(x, {xs})" + "{x}" == "CONST cons(x, 0)" + + +subsection \Axioms\ + +(* ZF axioms -- see Suppes p.238 + Axioms for Union, Pow and Replace state existence only, + uniqueness is derivable using extensionality. *) axiomatization - mem :: "[i, i] => o" (infixl "\" 50) \\membership relation\ - -abbreviation - not_mem :: "[i, i] => o" (infixl "\" 50) \\negated membership relation\ - where "x \ y \ \ (x \ y)" +where + extension: "A = B \ A \ B \ B \ A" and + Union_iff: "A \ \(C) \ (\B\C. A\B)" and + Pow_iff: "A \ Pow(B) \ A \ B" and -abbreviation - cart_prod :: "[i, i] => i" (infixr "\" 80) \\Cartesian product\ - where "A \ B \ Sigma(A, \_. B)" + (*We may name this set, though it is not uniquely defined.*) + infinity: "0 \ Inf \ (\y\Inf. succ(y) \ Inf)" and -abbreviation - function_space :: "[i, i] => i" (infixr "->" 60) \\function space\ - where "A -> B \ Pi(A, \_. B)" + (*This formulation facilitates case analysis on A.*) + foundation: "A = 0 \ (\x\A. \y\x. y\A)" and + + (*Schema axiom since predicate P is a higher-order variable*) + replacement: "(\x\A. \y z. P(x,y) \ P(x,z) \ y = z) \ + b \ PrimReplace(A,P) \ (\x\A. P(x,b))" -nonterminal "is" and patterns +subsection \Definite descriptions -- via Replace over the set "1"\ + +definition The :: "(i \ o) \ i" (binder "THE " 10) + where the_def: "The(P) == \({y . x \ {0}, P(y)})" -syntax - "" :: "i => is" ("_") - "_Enum" :: "[i, is] => is" ("_,/ _") +definition If :: "[o, i, i] \ i" ("(if (_)/ then (_)/ else (_))" [10] 10) + where if_def: "if P then a else b == THE z. P & z=a | ~P & z=b" + +abbreviation (input) + old_if :: "[o, i, i] => i" ("if '(_,_,_')") + where "if(P,a,b) == If(P,a,b)" + + +subsection \Ordered Pairing\ - "_Finset" :: "is => i" ("{(_)}") - "_Tuple" :: "[i, is] => i" ("\(_,/ _)\") - "_Collect" :: "[pttrn, i, o] => i" ("(1{_ \ _ ./ _})") - "_Replace" :: "[pttrn, pttrn, i, o] => i" ("(1{_ ./ _ \ _, _})") - "_RepFun" :: "[i, pttrn, i] => i" ("(1{_ ./ _ \ _})" [51,0,51]) - "_UNION" :: "[pttrn, i, i] => i" ("(3\_\_./ _)" 10) - "_INTER" :: "[pttrn, i, i] => i" ("(3\_\_./ _)" 10) - "_PROD" :: "[pttrn, i, i] => i" ("(3\_\_./ _)" 10) - "_SUM" :: "[pttrn, i, i] => i" ("(3\_\_./ _)" 10) - "_lam" :: "[pttrn, i, i] => i" ("(3\_\_./ _)" 10) - "_Ball" :: "[pttrn, i, o] => o" ("(3\_\_./ _)" 10) - "_Bex" :: "[pttrn, i, o] => o" ("(3\_\_./ _)" 10) +(* this "symmetric" definition works better than {{a}, {a,b}} *) +definition Pair :: "[i, i] => i" + where "Pair(a,b) == {{a,a}, {a,b}}" + +definition fst :: "i \ i" + where "fst(p) == THE a. \b. p = Pair(a, b)" - (** Patterns -- extends pre-defined type "pttrn" used in abstractions **) +definition snd :: "i \ i" + where "snd(p) == THE b. \a. p = Pair(a, b)" +definition split :: "[[i, i] \ 'a, i] \ 'a::{}" \ \for pattern-matching\ + where "split(c) == \p. c(fst(p), snd(p))" + +(* Patterns -- extends pre-defined type "pttrn" used in abstractions *) +nonterminal patterns +syntax "_pattern" :: "patterns => pttrn" ("\_\") "" :: "pttrn => patterns" ("_") "_patterns" :: "[pttrn, patterns] => patterns" ("_,/_") - + "_Tuple" :: "[i, is] => i" ("\(_,/ _)\") translations - "{x, xs}" == "CONST cons(x, {xs})" - "{x}" == "CONST cons(x, 0)" - "{x\A. P}" == "CONST Collect(A, \x. P)" - "{y. x\A, Q}" == "CONST Replace(A, \x y. Q)" - "{b. x\A}" == "CONST RepFun(A, \x. b)" - "\x\A. B" == "CONST Inter({B. x\A})" - "\x\A. B" == "CONST Union({B. x\A})" - "\x\A. B" == "CONST Pi(A, \x. B)" - "\x\A. B" == "CONST Sigma(A, \x. B)" - "\x\A. f" == "CONST Lambda(A, \x. f)" - "\x\A. P" == "CONST Ball(A, \x. P)" - "\x\A. P" == "CONST Bex(A, \x. P)" - "\x, y, z\" == "\x, \y, z\\" "\x, y\" == "CONST Pair(x, y)" "\\x,y,zs\.b" == "CONST split(\x \y,zs\.b)" "\\x,y\.b" == "CONST split(\x y. b)" +definition Sigma :: "[i, i \ i] \ i" + where "Sigma(A,B) == \x\A. \y\B(x). {\x,y\}" + +abbreviation cart_prod :: "[i, i] => i" (infixr "\" 80) \ \Cartesian product\ + where "A \ B \ Sigma(A, \_. B)" + + +subsection \Relations and Functions\ + +(*converse of relation r, inverse of function*) +definition converse :: "i \ i" + where "converse(r) == {z. w\r, \x y. w=\x,y\ \ z=\y,x\}" + +definition domain :: "i \ i" + where "domain(r) == {x. w\r, \y. w=\x,y\}" + +definition range :: "i \ i" + where "range(r) == domain(converse(r))" + +definition field :: "i \ i" + where "field(r) == domain(r) \ range(r)" + +definition relation :: "i \ o" \ \recognizes sets of pairs\ + where "relation(r) == \z\r. \x y. z = \x,y\" + +definition function :: "i \ o" \ \recognizes functions; can have non-pairs\ + where "function(r) == \x y. \x,y\ \ r \ (\y'. \x,y'\ \ r \ y = y')" + +definition Image :: "[i, i] \ i" (infixl "``" 90) \ \image\ + where image_def: "r `` A == {y \ range(r). \x\A. \x,y\ \ r}" + +definition vimage :: "[i, i] \ i" (infixl "-``" 90) \ \inverse image\ + where vimage_def: "r -`` A == converse(r)``A" + +(* Restrict the relation r to the domain A *) +definition restrict :: "[i, i] \ i" + where "restrict(r,A) == {z \ r. \x\A. \y. z = \x,y\}" + + +(* Abstraction, application and Cartesian product of a family of sets *) + +definition Lambda :: "[i, i \ i] \ i" + where lam_def: "Lambda(A,b) == {\x,b(x)\. x\A}" + +definition "apply" :: "[i, i] \ i" (infixl "`" 90) \ \function application\ + where "f`a == \(f``{a})" + +definition Pi :: "[i, i \ i] \ i" + where "Pi(A,B) == {f\Pow(Sigma(A,B)). A\domain(f) & function(f)}" + +abbreviation function_space :: "[i, i] \ i" (infixr "->" 60) \ \function space\ + where "A -> B \ Pi(A, \_. B)" + + +(* binder syntax *) + +syntax + "_PROD" :: "[pttrn, i, i] => i" ("(3\_\_./ _)" 10) + "_SUM" :: "[pttrn, i, i] => i" ("(3\_\_./ _)" 10) + "_lam" :: "[pttrn, i, i] => i" ("(3\_\_./ _)" 10) +translations + "\x\A. B" == "CONST Pi(A, \x. B)" + "\x\A. B" == "CONST Sigma(A, \x. B)" + "\x\A. f" == "CONST Lambda(A, \x. f)" + + +subsection \ASCII syntax\ notation (ASCII) cart_prod (infixr "*" 80) and @@ -155,6 +270,8 @@ not_mem (infixl "~:" 50) syntax (ASCII) + "_Ball" :: "[pttrn, i, o] => o" ("(3ALL _:_./ _)" 10) + "_Bex" :: "[pttrn, i, o] => o" ("(3EX _:_./ _)" 10) "_Collect" :: "[pttrn, i, o] => i" ("(1{_: _ ./ _})") "_Replace" :: "[pttrn, pttrn, i, o] => i" ("(1{_ ./ _: _, _})") "_RepFun" :: "[i, pttrn, i] => i" ("(1{_ ./ _: _})" [51,0,51]) @@ -163,104 +280,9 @@ "_PROD" :: "[pttrn, i, i] => i" ("(3PROD _:_./ _)" 10) "_SUM" :: "[pttrn, i, i] => i" ("(3SUM _:_./ _)" 10) "_lam" :: "[pttrn, i, i] => i" ("(3lam _:_./ _)" 10) - "_Ball" :: "[pttrn, i, o] => o" ("(3ALL _:_./ _)" 10) - "_Bex" :: "[pttrn, i, o] => o" ("(3EX _:_./ _)" 10) "_Tuple" :: "[i, is] => i" ("<(_,/ _)>") "_pattern" :: "patterns => pttrn" ("<_>") -defs (* Bounded Quantifiers *) - Ball_def: "Ball(A, P) == \x. x\A \ P(x)" - Bex_def: "Bex(A, P) == \x. x\A & P(x)" - - subset_def: "A \ B == \x\A. x\B" - - -axiomatization where - - (* ZF axioms -- see Suppes p.238 - Axioms for Union, Pow and Replace state existence only, - uniqueness is derivable using extensionality. *) - - extension: "A = B <-> A \ B & B \ A" and - Union_iff: "A \ \(C) <-> (\B\C. A\B)" and - Pow_iff: "A \ Pow(B) <-> A \ B" and - - (*We may name this set, though it is not uniquely defined.*) - infinity: "0\Inf & (\y\Inf. succ(y): Inf)" and - - (*This formulation facilitates case analysis on A.*) - foundation: "A=0 | (\x\A. \y\x. y\A)" and - - (*Schema axiom since predicate P is a higher-order variable*) - replacement: "(\x\A. \y z. P(x,y) & P(x,z) \ y=z) ==> - b \ PrimReplace(A,P) <-> (\x\A. P(x,b))" - - -defs - - (* Derived form of replacement, restricting P to its functional part. - The resulting set (for functional P) is the same as with - PrimReplace, but the rules are simpler. *) - - Replace_def: "Replace(A,P) == PrimReplace(A, %x y. (EX!z. P(x,z)) & P(x,y))" - - (* Functional form of replacement -- analgous to ML's map functional *) - - RepFun_def: "RepFun(A,f) == {y . x\A, y=f(x)}" - - (* Separation and Pairing can be derived from the Replacement - and Powerset Axioms using the following definitions. *) - - Collect_def: "Collect(A,P) == {y . x\A, x=y & P(x)}" - - (*Unordered pairs (Upair) express binary union/intersection and cons; - set enumerations translate as {a,...,z} = cons(a,...,cons(z,0)...)*) - - Upair_def: "Upair(a,b) == {y. x\Pow(Pow(0)), (x=0 & y=a) | (x=Pow(0) & y=b)}" - cons_def: "cons(a,A) == Upair(a,a) \ A" - succ_def: "succ(i) == cons(i, i)" - - (* Difference, general intersection, binary union and small intersection *) - - Diff_def: "A - B == { x\A . ~(x\B) }" - Inter_def: "\(A) == { x\\(A) . \y\A. x\y}" - Un_def: "A \ B == \(Upair(A,B))" - Int_def: "A \ B == \(Upair(A,B))" - - (* definite descriptions *) - the_def: "The(P) == \({y . x \ {0}, P(y)})" - if_def: "if(P,a,b) == THE z. P & z=a | ~P & z=b" - - (* this "symmetric" definition works better than {{a}, {a,b}} *) - Pair_def: " == {{a,a}, {a,b}}" - fst_def: "fst(p) == THE a. \b. p=" - snd_def: "snd(p) == THE b. \a. p=" - split_def: "split(c) == %p. c(fst(p), snd(p))" - Sigma_def: "Sigma(A,B) == \x\A. \y\B(x). {}" - - (* Operations on relations *) - - (*converse of relation r, inverse of function*) - converse_def: "converse(r) == {z. w\r, \x y. w= & z=}" - - domain_def: "domain(r) == {x. w\r, \y. w=}" - range_def: "range(r) == domain(converse(r))" - field_def: "field(r) == domain(r) \ range(r)" - relation_def: "relation(r) == \z\r. \x y. z = " - function_def: "function(r) == - \x y. :r \ (\y'. :r \ y=y')" - image_def: "r `` A == {y \ range(r) . \x\A. \ r}" - vimage_def: "r -`` A == converse(r)``A" - - (* Abstraction, application and Cartesian product of a family of sets *) - - lam_def: "Lambda(A,b) == { . x\A}" - apply_def: "f`a == \(f``{a})" - Pi_def: "Pi(A,B) == {f\Pow(Sigma(A,B)). A<=domain(f) & function(f)}" - - (* Restrict the relation r to the domain A *) - restrict_def: "restrict(r,A) == {z \ r. \x\A. \y. z = }" - subsection \Substitution\