| author | wenzelm | 
| Thu, 17 Dec 2009 15:09:07 +0100 | |
| changeset 34096 | e438a5875c16 | 
| parent 32960 | 69916a850301 | 
| child 35068 | 544867142ea4 | 
| permissions | -rw-r--r-- | 
| 615 | 1 | (* Title: ZF/ZF.thy | 
| 0 | 2 | Author: Lawrence C Paulson and Martin D Coen, CU Computer Laboratory | 
| 3 | Copyright 1993 University of Cambridge | |
| 14076 | 4 | *) | 
| 0 | 5 | |
| 14076 | 6 | header{*Zermelo-Fraenkel Set Theory*}
 | 
| 0 | 7 | |
| 16417 | 8 | theory ZF imports FOL begin | 
| 0 | 9 | |
| 32740 | 10 | ML {* Unsynchronized.reset eta_contract *}
 | 
| 23168 | 11 | |
| 3906 | 12 | global | 
| 13 | ||
| 14076 | 14 | typedecl i | 
| 15 | arities i :: "term" | |
| 0 | 16 | |
| 17 | consts | |
| 18 | ||
| 14076 | 19 |   "0"         :: "i"                  ("0")   --{*the empty set*}
 | 
| 20 |   Pow         :: "i => i"                     --{*power sets*}
 | |
| 21 |   Inf         :: "i"                          --{*infinite set*}
 | |
| 0 | 22 | |
| 14076 | 23 | text {*Bounded Quantifiers *}
 | 
| 24 | consts | |
| 13780 | 25 | Ball :: "[i, i => o] => o" | 
| 26 | Bex :: "[i, i => o] => o" | |
| 0 | 27 | |
| 14076 | 28 | text {*General Union and Intersection *}
 | 
| 29 | consts | |
| 13780 | 30 | Union :: "i => i" | 
| 31 | Inter :: "i => i" | |
| 0 | 32 | |
| 14076 | 33 | text {*Variations on Replacement *}
 | 
| 34 | consts | |
| 13144 | 35 | PrimReplace :: "[i, [i, i] => o] => i" | 
| 36 | Replace :: "[i, [i, i] => o] => i" | |
| 37 | RepFun :: "[i, i => i] => i" | |
| 38 | Collect :: "[i, i => o] => i" | |
| 0 | 39 | |
| 14883 | 40 | text{*Definite descriptions -- via Replace over the set "1"*}
 | 
| 14076 | 41 | consts | 
| 13780 | 42 | The :: "(i => o) => i" (binder "THE " 10) | 
| 13144 | 43 |   If          :: "[o, i, i] => i"     ("(if (_)/ then (_)/ else (_))" [10] 10)
 | 
| 6068 | 44 | |
| 24826 | 45 | abbreviation (input) | 
| 46 |   old_if      :: "[o, i, i] => i"   ("if '(_,_,_')") where
 | |
| 47 | "if(P,a,b) == If(P,a,b)" | |
| 6068 | 48 | |
| 49 | ||
| 14076 | 50 | text {*Finite Sets *}
 | 
| 6068 | 51 | consts | 
| 13780 | 52 | Upair :: "[i, i] => i" | 
| 53 | cons :: "[i, i] => i" | |
| 54 | succ :: "i => i" | |
| 0 | 55 | |
| 14076 | 56 | text {*Ordered Pairing *}
 | 
| 57 | consts | |
| 13780 | 58 | Pair :: "[i, i] => i" | 
| 59 | fst :: "i => i" | |
| 60 | snd :: "i => i" | |
| 14854 | 61 |   split :: "[[i, i] => 'a, i] => 'a::{}"  --{*for pattern-matching*}
 | 
| 0 | 62 | |
| 14076 | 63 | text {*Sigma and Pi Operators *}
 | 
| 64 | consts | |
| 13780 | 65 | Sigma :: "[i, i => i] => i" | 
| 66 | Pi :: "[i, i => i] => i" | |
| 0 | 67 | |
| 14076 | 68 | text {*Relations and Functions *}
 | 
| 69 | consts | |
| 70 | "domain" :: "i => i" | |
| 13144 | 71 | range :: "i => i" | 
| 72 | field :: "i => i" | |
| 73 | converse :: "i => i" | |
| 14076 | 74 |   relation    :: "i => o"        --{*recognizes sets of pairs*}
 | 
| 24826 | 75 |   "function"  :: "i => o"        --{*recognizes functions; can have non-pairs*}
 | 
| 13144 | 76 | Lambda :: "[i, i => i] => i" | 
| 77 | restrict :: "[i, i] => i" | |
| 0 | 78 | |
| 14076 | 79 | text {*Infixes in order of decreasing precedence *}
 | 
| 80 | consts | |
| 0 | 81 | |
| 24826 | 82 |   Image       :: "[i, i] => i"    (infixl "``" 90) --{*image*}
 | 
| 83 |   vimage      :: "[i, i] => i"    (infixl "-``" 90) --{*inverse image*}
 | |
| 84 |   "apply"     :: "[i, i] => i"    (infixl "`" 90) --{*function application*}
 | |
| 85 |   "Int"       :: "[i, i] => i"    (infixl "Int" 70) --{*binary intersection*}
 | |
| 86 |   "Un"        :: "[i, i] => i"    (infixl "Un" 65) --{*binary union*}
 | |
| 87 |   Diff        :: "[i, i] => i"    (infixl "-" 65) --{*set difference*}
 | |
| 88 |   Subset      :: "[i, i] => o"    (infixl "<=" 50) --{*subset relation*}
 | |
| 89 |   mem         :: "[i, i] => o"    (infixl ":" 50) --{*membership relation*}
 | |
| 90 | ||
| 91 | abbreviation | |
| 92 |   not_mem :: "[i, i] => o"  (infixl "~:" 50)  --{*negated membership relation*}
 | |
| 93 | where "x ~: y == ~ (x : y)" | |
| 94 | ||
| 95 | abbreviation | |
| 96 |   cart_prod :: "[i, i] => i"    (infixr "*" 80) --{*Cartesian product*}
 | |
| 97 | where "A * B == Sigma(A, %_. B)" | |
| 98 | ||
| 99 | abbreviation | |
| 100 |   function_space :: "[i, i] => i"  (infixr "->" 60) --{*function space*}
 | |
| 101 | where "A -> B == Pi(A, %_. B)" | |
| 0 | 102 | |
| 103 | ||
| 13780 | 104 | nonterminals "is" patterns | 
| 615 | 105 | |
| 106 | syntax | |
| 13144 | 107 |   ""          :: "i => is"                   ("_")
 | 
| 108 |   "@Enum"     :: "[i, is] => is"             ("_,/ _")
 | |
| 24826 | 109 | |
| 13144 | 110 |   "@Finset"   :: "is => i"                   ("{(_)}")
 | 
| 111 |   "@Tuple"    :: "[i, is] => i"              ("<(_,/ _)>")
 | |
| 112 |   "@Collect"  :: "[pttrn, i, o] => i"        ("(1{_: _ ./ _})")
 | |
| 113 |   "@Replace"  :: "[pttrn, pttrn, i, o] => i" ("(1{_ ./ _: _, _})")
 | |
| 114 |   "@RepFun"   :: "[i, pttrn, i] => i"        ("(1{_ ./ _: _})" [51,0,51])
 | |
| 115 |   "@INTER"    :: "[pttrn, i, i] => i"        ("(3INT _:_./ _)" 10)
 | |
| 116 |   "@UNION"    :: "[pttrn, i, i] => i"        ("(3UN _:_./ _)" 10)
 | |
| 117 |   "@PROD"     :: "[pttrn, i, i] => i"        ("(3PROD _:_./ _)" 10)
 | |
| 118 |   "@SUM"      :: "[pttrn, i, i] => i"        ("(3SUM _:_./ _)" 10)
 | |
| 119 |   "@lam"      :: "[pttrn, i, i] => i"        ("(3lam _:_./ _)" 10)
 | |
| 120 |   "@Ball"     :: "[pttrn, i, o] => o"        ("(3ALL _:_./ _)" 10)
 | |
| 121 |   "@Bex"      :: "[pttrn, i, o] => o"        ("(3EX _:_./ _)" 10)
 | |
| 1106 
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy.  Changed
 lcp parents: 
690diff
changeset | 122 | |
| 
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy.  Changed
 lcp parents: 
690diff
changeset | 123 | (** Patterns -- extends pre-defined type "pttrn" used in abstractions **) | 
| 
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy.  Changed
 lcp parents: 
690diff
changeset | 124 | |
| 13144 | 125 |   "@pattern"  :: "patterns => pttrn"         ("<_>")
 | 
| 126 |   ""          :: "pttrn => patterns"         ("_")
 | |
| 127 |   "@patterns" :: "[pttrn, patterns] => patterns"  ("_,/_")
 | |
| 615 | 128 | |
| 0 | 129 | translations | 
| 130 |   "{x, xs}"     == "cons(x, {xs})"
 | |
| 131 |   "{x}"         == "cons(x, 0)"
 | |
| 132 |   "{x:A. P}"    == "Collect(A, %x. P)"
 | |
| 133 |   "{y. x:A, Q}" == "Replace(A, %x y. Q)"
 | |
| 615 | 134 |   "{b. x:A}"    == "RepFun(A, %x. b)"
 | 
| 0 | 135 |   "INT x:A. B"  == "Inter({B. x:A})"
 | 
| 136 |   "UN x:A. B"   == "Union({B. x:A})"
 | |
| 24826 | 137 | "PROD x:A. B" == "Pi(A, %x. B)" | 
| 138 | "SUM x:A. B" == "Sigma(A, %x. B)" | |
| 0 | 139 | "lam x:A. f" == "Lambda(A, %x. f)" | 
| 140 | "ALL x:A. P" == "Ball(A, %x. P)" | |
| 141 | "EX x:A. P" == "Bex(A, %x. P)" | |
| 37 | 142 | |
| 1106 
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy.  Changed
 lcp parents: 
690diff
changeset | 143 | "<x, y, z>" == "<x, <y, z>>" | 
| 
62bdb9e5722b
Added pattern-matching code from CHOL/Prod.thy.  Changed
 lcp parents: 
690diff
changeset | 144 | "<x, y>" == "Pair(x, y)" | 
| 2286 | 145 | "%<x,y,zs>.b" == "split(%x <y,zs>.b)" | 
| 3840 | 146 | "%<x,y>.b" == "split(%x y. b)" | 
| 2286 | 147 | |
| 0 | 148 | |
| 24826 | 149 | notation (xsymbols) | 
| 150 | cart_prod (infixr "\<times>" 80) and | |
| 151 | Int (infixl "\<inter>" 70) and | |
| 152 | Un (infixl "\<union>" 65) and | |
| 153 | function_space (infixr "\<rightarrow>" 60) and | |
| 154 | Subset (infixl "\<subseteq>" 50) and | |
| 155 | mem (infixl "\<in>" 50) and | |
| 156 | not_mem (infixl "\<notin>" 50) and | |
| 157 |   Union           ("\<Union>_" [90] 90) and
 | |
| 158 |   Inter           ("\<Inter>_" [90] 90)
 | |
| 159 | ||
| 12114 
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
 wenzelm parents: 
11322diff
changeset | 160 | syntax (xsymbols) | 
| 13780 | 161 |   "@Collect"  :: "[pttrn, i, o] => i"        ("(1{_ \<in> _ ./ _})")
 | 
| 162 |   "@Replace"  :: "[pttrn, pttrn, i, o] => i" ("(1{_ ./ _ \<in> _, _})")
 | |
| 163 |   "@RepFun"   :: "[i, pttrn, i] => i"        ("(1{_ ./ _ \<in> _})" [51,0,51])
 | |
| 164 |   "@UNION"    :: "[pttrn, i, i] => i"        ("(3\<Union>_\<in>_./ _)" 10)
 | |
| 165 |   "@INTER"    :: "[pttrn, i, i] => i"        ("(3\<Inter>_\<in>_./ _)" 10)
 | |
| 166 |   "@PROD"     :: "[pttrn, i, i] => i"        ("(3\<Pi>_\<in>_./ _)" 10)
 | |
| 167 |   "@SUM"      :: "[pttrn, i, i] => i"        ("(3\<Sigma>_\<in>_./ _)" 10)
 | |
| 168 |   "@lam"      :: "[pttrn, i, i] => i"        ("(3\<lambda>_\<in>_./ _)" 10)
 | |
| 169 |   "@Ball"     :: "[pttrn, i, o] => o"        ("(3\<forall>_\<in>_./ _)" 10)
 | |
| 170 |   "@Bex"      :: "[pttrn, i, o] => o"        ("(3\<exists>_\<in>_./ _)" 10)
 | |
| 171 |   "@Tuple"    :: "[i, is] => i"              ("\<langle>(_,/ _)\<rangle>")
 | |
| 172 |   "@pattern"  :: "patterns => pttrn"         ("\<langle>_\<rangle>")
 | |
| 2540 | 173 | |
| 24826 | 174 | notation (HTML output) | 
| 175 | cart_prod (infixr "\<times>" 80) and | |
| 176 | Int (infixl "\<inter>" 70) and | |
| 177 | Un (infixl "\<union>" 65) and | |
| 178 | Subset (infixl "\<subseteq>" 50) and | |
| 179 | mem (infixl "\<in>" 50) and | |
| 180 | not_mem (infixl "\<notin>" 50) and | |
| 181 |   Union           ("\<Union>_" [90] 90) and
 | |
| 182 |   Inter           ("\<Inter>_" [90] 90)
 | |
| 183 | ||
| 6340 | 184 | syntax (HTML output) | 
| 14565 | 185 |   "@Collect"  :: "[pttrn, i, o] => i"        ("(1{_ \<in> _ ./ _})")
 | 
| 186 |   "@Replace"  :: "[pttrn, pttrn, i, o] => i" ("(1{_ ./ _ \<in> _, _})")
 | |
| 187 |   "@RepFun"   :: "[i, pttrn, i] => i"        ("(1{_ ./ _ \<in> _})" [51,0,51])
 | |
| 188 |   "@UNION"    :: "[pttrn, i, i] => i"        ("(3\<Union>_\<in>_./ _)" 10)
 | |
| 189 |   "@INTER"    :: "[pttrn, i, i] => i"        ("(3\<Inter>_\<in>_./ _)" 10)
 | |
| 190 |   "@PROD"     :: "[pttrn, i, i] => i"        ("(3\<Pi>_\<in>_./ _)" 10)
 | |
| 191 |   "@SUM"      :: "[pttrn, i, i] => i"        ("(3\<Sigma>_\<in>_./ _)" 10)
 | |
| 192 |   "@lam"      :: "[pttrn, i, i] => i"        ("(3\<lambda>_\<in>_./ _)" 10)
 | |
| 193 |   "@Ball"     :: "[pttrn, i, o] => o"        ("(3\<forall>_\<in>_./ _)" 10)
 | |
| 194 |   "@Bex"      :: "[pttrn, i, o] => o"        ("(3\<exists>_\<in>_./ _)" 10)
 | |
| 195 |   "@Tuple"    :: "[i, is] => i"              ("\<langle>(_,/ _)\<rangle>")
 | |
| 196 |   "@pattern"  :: "patterns => pttrn"         ("\<langle>_\<rangle>")
 | |
| 6340 | 197 | |
| 2540 | 198 | |
| 14227 | 199 | finalconsts | 
| 24826 | 200 | 0 Pow Inf Union PrimReplace mem | 
| 14227 | 201 | |
| 13780 | 202 | defs | 
| 203 | (*don't try to use constdefs: the declaration order is tightly constrained*) | |
| 0 | 204 | |
| 615 | 205 | (* Bounded Quantifiers *) | 
| 14227 | 206 | Ball_def: "Ball(A, P) == \<forall>x. x\<in>A --> P(x)" | 
| 207 | Bex_def: "Bex(A, P) == \<exists>x. x\<in>A & P(x)" | |
| 690 | 208 | |
| 14227 | 209 | subset_def: "A <= B == \<forall>x\<in>A. x\<in>B" | 
| 690 | 210 | |
| 3906 | 211 | |
| 3940 | 212 | local | 
| 3906 | 213 | |
| 13780 | 214 | axioms | 
| 0 | 215 | |
| 615 | 216 | (* ZF axioms -- see Suppes p.238 | 
| 217 | Axioms for Union, Pow and Replace state existence only, | |
| 218 | uniqueness is derivable using extensionality. *) | |
| 0 | 219 | |
| 13780 | 220 | extension: "A = B <-> A <= B & B <= A" | 
| 14227 | 221 | Union_iff: "A \<in> Union(C) <-> (\<exists>B\<in>C. A\<in>B)" | 
| 222 | Pow_iff: "A \<in> Pow(B) <-> A <= B" | |
| 0 | 223 | |
| 615 | 224 | (*We may name this set, though it is not uniquely defined.*) | 
| 14227 | 225 | infinity: "0\<in>Inf & (\<forall>y\<in>Inf. succ(y): Inf)" | 
| 0 | 226 | |
| 615 | 227 | (*This formulation facilitates case analysis on A.*) | 
| 14227 | 228 | foundation: "A=0 | (\<exists>x\<in>A. \<forall>y\<in>x. y~:A)" | 
| 0 | 229 | |
| 615 | 230 | (*Schema axiom since predicate P is a higher-order variable*) | 
| 14227 | 231 | replacement: "(\<forall>x\<in>A. \<forall>y z. P(x,y) & P(x,z) --> y=z) ==> | 
| 232 | b \<in> PrimReplace(A,P) <-> (\<exists>x\<in>A. P(x,b))" | |
| 615 | 233 | |
| 14883 | 234 | |
| 690 | 235 | defs | 
| 236 | ||
| 615 | 237 | (* Derived form of replacement, restricting P to its functional part. | 
| 238 | The resulting set (for functional P) is the same as with | |
| 239 | PrimReplace, but the rules are simpler. *) | |
| 0 | 240 | |
| 13780 | 241 | Replace_def: "Replace(A,P) == PrimReplace(A, %x y. (EX!z. P(x,z)) & P(x,y))" | 
| 615 | 242 | |
| 243 | (* Functional form of replacement -- analgous to ML's map functional *) | |
| 0 | 244 | |
| 14227 | 245 |   RepFun_def:   "RepFun(A,f) == {y . x\<in>A, y=f(x)}"
 | 
| 0 | 246 | |
| 615 | 247 | (* Separation and Pairing can be derived from the Replacement | 
| 248 | and Powerset Axioms using the following definitions. *) | |
| 0 | 249 | |
| 14227 | 250 |   Collect_def:  "Collect(A,P) == {y . x\<in>A, x=y & P(x)}"
 | 
| 0 | 251 | |
| 615 | 252 | (*Unordered pairs (Upair) express binary union/intersection and cons; | 
| 253 |     set enumerations translate as {a,...,z} = cons(a,...,cons(z,0)...)*)
 | |
| 0 | 254 | |
| 14227 | 255 |   Upair_def: "Upair(a,b) == {y. x\<in>Pow(Pow(0)), (x=0 & y=a) | (x=Pow(0) & y=b)}"
 | 
| 13780 | 256 | cons_def: "cons(a,A) == Upair(a,a) Un A" | 
| 257 | succ_def: "succ(i) == cons(i, i)" | |
| 615 | 258 | |
| 2872 
ac81a17f86f8
Moved definitions (binary intersection, etc.) from upair.thy back to ZF.thy
 paulson parents: 
2540diff
changeset | 259 | (* Difference, general intersection, binary union and small intersection *) | 
| 
ac81a17f86f8
Moved definitions (binary intersection, etc.) from upair.thy back to ZF.thy
 paulson parents: 
2540diff
changeset | 260 | |
| 14227 | 261 |   Diff_def:      "A - B    == { x\<in>A . ~(x\<in>B) }"
 | 
| 262 |   Inter_def:     "Inter(A) == { x\<in>Union(A) . \<forall>y\<in>A. x\<in>y}"
 | |
| 13780 | 263 | Un_def: "A Un B == Union(Upair(A,B))" | 
| 264 | Int_def: "A Int B == Inter(Upair(A,B))" | |
| 2872 
ac81a17f86f8
Moved definitions (binary intersection, etc.) from upair.thy back to ZF.thy
 paulson parents: 
2540diff
changeset | 265 | |
| 14883 | 266 | (* definite descriptions *) | 
| 14227 | 267 |   the_def:      "The(P)    == Union({y . x \<in> {0}, P(y)})"
 | 
| 13780 | 268 | if_def: "if(P,a,b) == THE z. P & z=a | ~P & z=b" | 
| 0 | 269 | |
| 615 | 270 |   (* this "symmetric" definition works better than {{a}, {a,b}} *)
 | 
| 13780 | 271 |   Pair_def:     "<a,b>  == {{a,a}, {a,b}}"
 | 
| 14227 | 272 | fst_def: "fst(p) == THE a. \<exists>b. p=<a,b>" | 
| 273 | snd_def: "snd(p) == THE b. \<exists>a. p=<a,b>" | |
| 13780 | 274 | split_def: "split(c) == %p. c(fst(p), snd(p))" | 
| 14227 | 275 |   Sigma_def:    "Sigma(A,B) == \<Union>x\<in>A. \<Union>y\<in>B(x). {<x,y>}"
 | 
| 0 | 276 | |
| 615 | 277 | (* Operations on relations *) | 
| 0 | 278 | |
| 615 | 279 | (*converse of relation r, inverse of function*) | 
| 14227 | 280 |   converse_def: "converse(r) == {z. w\<in>r, \<exists>x y. w=<x,y> & z=<y,x>}"
 | 
| 0 | 281 | |
| 14227 | 282 |   domain_def:   "domain(r) == {x. w\<in>r, \<exists>y. w=<x,y>}"
 | 
| 13780 | 283 | range_def: "range(r) == domain(converse(r))" | 
| 284 | field_def: "field(r) == domain(r) Un range(r)" | |
| 14227 | 285 | relation_def: "relation(r) == \<forall>z\<in>r. \<exists>x y. z = <x,y>" | 
| 13780 | 286 | function_def: "function(r) == | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32740diff
changeset | 287 | \<forall>x y. <x,y>:r --> (\<forall>y'. <x,y'>:r --> y=y')" | 
| 14227 | 288 |   image_def:    "r `` A  == {y : range(r) . \<exists>x\<in>A. <x,y> : r}"
 | 
| 13780 | 289 | vimage_def: "r -`` A == converse(r)``A" | 
| 0 | 290 | |
| 615 | 291 | (* Abstraction, application and Cartesian product of a family of sets *) | 
| 0 | 292 | |
| 14227 | 293 |   lam_def:      "Lambda(A,b) == {<x,b(x)> . x\<in>A}"
 | 
| 13780 | 294 |   apply_def:    "f`a == Union(f``{a})"
 | 
| 14227 | 295 |   Pi_def:       "Pi(A,B)  == {f\<in>Pow(Sigma(A,B)). A<=domain(f) & function(f)}"
 | 
| 0 | 296 | |
| 12891 | 297 | (* Restrict the relation r to the domain A *) | 
| 14227 | 298 |   restrict_def: "restrict(r,A) == {z : r. \<exists>x\<in>A. \<exists>y. z = <x,y>}"
 | 
| 13780 | 299 | |
| 300 | ||
| 301 | subsection {* Substitution*}
 | |
| 302 | ||
| 303 | (*Useful examples: singletonI RS subst_elem, subst_elem RSN (2,IntI) *) | |
| 14227 | 304 | lemma subst_elem: "[| b\<in>A; a=b |] ==> a\<in>A" | 
| 13780 | 305 | by (erule ssubst, assumption) | 
| 306 | ||
| 307 | ||
| 308 | subsection{*Bounded universal quantifier*}
 | |
| 309 | ||
| 14227 | 310 | lemma ballI [intro!]: "[| !!x. x\<in>A ==> P(x) |] ==> \<forall>x\<in>A. P(x)" | 
| 13780 | 311 | by (simp add: Ball_def) | 
| 312 | ||
| 15481 | 313 | lemmas strip = impI allI ballI | 
| 314 | ||
| 14227 | 315 | lemma bspec [dest?]: "[| \<forall>x\<in>A. P(x); x: A |] ==> P(x)" | 
| 13780 | 316 | by (simp add: Ball_def) | 
| 317 | ||
| 318 | (*Instantiates x first: better for automatic theorem proving?*) | |
| 319 | lemma rev_ballE [elim]: | |
| 14227 | 320 | "[| \<forall>x\<in>A. P(x); x~:A ==> Q; P(x) ==> Q |] ==> Q" | 
| 13780 | 321 | by (simp add: Ball_def, blast) | 
| 322 | ||
| 14227 | 323 | lemma ballE: "[| \<forall>x\<in>A. P(x); P(x) ==> Q; x~:A ==> Q |] ==> Q" | 
| 13780 | 324 | by blast | 
| 325 | ||
| 326 | (*Used in the datatype package*) | |
| 14227 | 327 | lemma rev_bspec: "[| x: A; \<forall>x\<in>A. P(x) |] ==> P(x)" | 
| 13780 | 328 | by (simp add: Ball_def) | 
| 329 | ||
| 14227 | 330 | (*Trival rewrite rule; (\<forall>x\<in>A.P)<->P holds only if A is nonempty!*) | 
| 331 | lemma ball_triv [simp]: "(\<forall>x\<in>A. P) <-> ((\<exists>x. x\<in>A) --> P)" | |
| 13780 | 332 | by (simp add: Ball_def) | 
| 333 | ||
| 334 | (*Congruence rule for rewriting*) | |
| 335 | lemma ball_cong [cong]: | |
| 14227 | 336 | "[| A=A'; !!x. x\<in>A' ==> P(x) <-> P'(x) |] ==> (\<forall>x\<in>A. P(x)) <-> (\<forall>x\<in>A'. P'(x))" | 
| 13780 | 337 | by (simp add: Ball_def) | 
| 338 | ||
| 18845 | 339 | lemma atomize_ball: | 
| 340 | "(!!x. x \<in> A ==> P(x)) == Trueprop (\<forall>x\<in>A. P(x))" | |
| 341 | by (simp only: Ball_def atomize_all atomize_imp) | |
| 342 | ||
| 343 | lemmas [symmetric, rulify] = atomize_ball | |
| 344 | and [symmetric, defn] = atomize_ball | |
| 345 | ||
| 13780 | 346 | |
| 347 | subsection{*Bounded existential quantifier*}
 | |
| 348 | ||
| 14227 | 349 | lemma bexI [intro]: "[| P(x); x: A |] ==> \<exists>x\<in>A. P(x)" | 
| 13780 | 350 | by (simp add: Bex_def, blast) | 
| 351 | ||
| 14227 | 352 | (*The best argument order when there is only one x\<in>A*) | 
| 353 | lemma rev_bexI: "[| x\<in>A; P(x) |] ==> \<exists>x\<in>A. P(x)" | |
| 13780 | 354 | by blast | 
| 355 | ||
| 14227 | 356 | (*Not of the general form for such rules; ~\<exists>has become ALL~ *) | 
| 357 | lemma bexCI: "[| \<forall>x\<in>A. ~P(x) ==> P(a); a: A |] ==> \<exists>x\<in>A. P(x)" | |
| 13780 | 358 | by blast | 
| 359 | ||
| 14227 | 360 | lemma bexE [elim!]: "[| \<exists>x\<in>A. P(x); !!x. [| x\<in>A; P(x) |] ==> Q |] ==> Q" | 
| 13780 | 361 | by (simp add: Bex_def, blast) | 
| 362 | ||
| 14227 | 363 | (*We do not even have (\<exists>x\<in>A. True) <-> True unless A is nonempty!!*) | 
| 364 | lemma bex_triv [simp]: "(\<exists>x\<in>A. P) <-> ((\<exists>x. x\<in>A) & P)" | |
| 13780 | 365 | by (simp add: Bex_def) | 
| 366 | ||
| 367 | lemma bex_cong [cong]: | |
| 14227 | 368 | "[| A=A'; !!x. x\<in>A' ==> P(x) <-> P'(x) |] | 
| 369 | ==> (\<exists>x\<in>A. P(x)) <-> (\<exists>x\<in>A'. P'(x))" | |
| 13780 | 370 | by (simp add: Bex_def cong: conj_cong) | 
| 371 | ||
| 372 | ||
| 373 | ||
| 374 | subsection{*Rules for subsets*}
 | |
| 375 | ||
| 376 | lemma subsetI [intro!]: | |
| 14227 | 377 | "(!!x. x\<in>A ==> x\<in>B) ==> A <= B" | 
| 13780 | 378 | by (simp add: subset_def) | 
| 379 | ||
| 380 | (*Rule in Modus Ponens style [was called subsetE] *) | |
| 14227 | 381 | lemma subsetD [elim]: "[| A <= B; c\<in>A |] ==> c\<in>B" | 
| 13780 | 382 | apply (unfold subset_def) | 
| 383 | apply (erule bspec, assumption) | |
| 384 | done | |
| 385 | ||
| 386 | (*Classical elimination rule*) | |
| 387 | lemma subsetCE [elim]: | |
| 14227 | 388 | "[| A <= B; c~:A ==> P; c\<in>B ==> P |] ==> P" | 
| 13780 | 389 | by (simp add: subset_def, blast) | 
| 390 | ||
| 391 | (*Sometimes useful with premises in this order*) | |
| 14227 | 392 | lemma rev_subsetD: "[| c\<in>A; A<=B |] ==> c\<in>B" | 
| 13780 | 393 | by blast | 
| 394 | ||
| 395 | lemma contra_subsetD: "[| A <= B; c ~: B |] ==> c ~: A" | |
| 396 | by blast | |
| 397 | ||
| 398 | lemma rev_contra_subsetD: "[| c ~: B; A <= B |] ==> c ~: A" | |
| 399 | by blast | |
| 400 | ||
| 401 | lemma subset_refl [simp]: "A <= A" | |
| 402 | by blast | |
| 403 | ||
| 404 | lemma subset_trans: "[| A<=B; B<=C |] ==> A<=C" | |
| 405 | by blast | |
| 406 | ||
| 407 | (*Useful for proving A<=B by rewriting in some cases*) | |
| 408 | lemma subset_iff: | |
| 14227 | 409 | "A<=B <-> (\<forall>x. x\<in>A --> x\<in>B)" | 
| 13780 | 410 | apply (unfold subset_def Ball_def) | 
| 411 | apply (rule iff_refl) | |
| 412 | done | |
| 413 | ||
| 414 | ||
| 415 | subsection{*Rules for equality*}
 | |
| 416 | ||
| 417 | (*Anti-symmetry of the subset relation*) | |
| 418 | lemma equalityI [intro]: "[| A <= B; B <= A |] ==> A = B" | |
| 419 | by (rule extension [THEN iffD2], rule conjI) | |
| 420 | ||
| 421 | ||
| 14227 | 422 | lemma equality_iffI: "(!!x. x\<in>A <-> x\<in>B) ==> A = B" | 
| 13780 | 423 | by (rule equalityI, blast+) | 
| 424 | ||
| 425 | lemmas equalityD1 = extension [THEN iffD1, THEN conjunct1, standard] | |
| 426 | lemmas equalityD2 = extension [THEN iffD1, THEN conjunct2, standard] | |
| 427 | ||
| 428 | lemma equalityE: "[| A = B; [| A<=B; B<=A |] ==> P |] ==> P" | |
| 429 | by (blast dest: equalityD1 equalityD2) | |
| 430 | ||
| 431 | lemma equalityCE: | |
| 14227 | 432 | "[| A = B; [| c\<in>A; c\<in>B |] ==> P; [| c~:A; c~:B |] ==> P |] ==> P" | 
| 13780 | 433 | by (erule equalityE, blast) | 
| 434 | ||
| 27702 | 435 | lemma equality_iffD: | 
| 436 | "A = B ==> (!!x. x : A <-> x : B)" | |
| 437 | by auto | |
| 438 | ||
| 13780 | 439 | |
| 440 | subsection{*Rules for Replace -- the derived form of replacement*}
 | |
| 441 | ||
| 442 | lemma Replace_iff: | |
| 14227 | 443 |     "b : {y. x\<in>A, P(x,y)}  <->  (\<exists>x\<in>A. P(x,b) & (\<forall>y. P(x,y) --> y=b))"
 | 
| 13780 | 444 | apply (unfold Replace_def) | 
| 445 | apply (rule replacement [THEN iff_trans], blast+) | |
| 446 | done | |
| 447 | ||
| 448 | (*Introduction; there must be a unique y such that P(x,y), namely y=b. *) | |
| 449 | lemma ReplaceI [intro]: | |
| 450 | "[| P(x,b); x: A; !!y. P(x,y) ==> y=b |] ==> | |
| 14227 | 451 |      b : {y. x\<in>A, P(x,y)}"
 | 
| 13780 | 452 | by (rule Replace_iff [THEN iffD2], blast) | 
| 453 | ||
| 454 | (*Elimination; may asssume there is a unique y such that P(x,y), namely y=b. *) | |
| 455 | lemma ReplaceE: | |
| 14227 | 456 |     "[| b : {y. x\<in>A, P(x,y)};   
 | 
| 457 | !!x. [| x: A; P(x,b); \<forall>y. P(x,y)-->y=b |] ==> R | |
| 13780 | 458 | |] ==> R" | 
| 459 | by (rule Replace_iff [THEN iffD1, THEN bexE], simp+) | |
| 460 | ||
| 461 | (*As above but without the (generally useless) 3rd assumption*) | |
| 462 | lemma ReplaceE2 [elim!]: | |
| 14227 | 463 |     "[| b : {y. x\<in>A, P(x,y)};   
 | 
| 13780 | 464 | !!x. [| x: A; P(x,b) |] ==> R | 
| 465 | |] ==> R" | |
| 466 | by (erule ReplaceE, blast) | |
| 467 | ||
| 468 | lemma Replace_cong [cong]: | |
| 14227 | 469 | "[| A=B; !!x y. x\<in>B ==> P(x,y) <-> Q(x,y) |] ==> | 
| 13780 | 470 | Replace(A,P) = Replace(B,Q)" | 
| 471 | apply (rule equality_iffI) | |
| 472 | apply (simp add: Replace_iff) | |
| 473 | done | |
| 474 | ||
| 475 | ||
| 476 | subsection{*Rules for RepFun*}
 | |
| 477 | ||
| 14227 | 478 | lemma RepFunI: "a \<in> A ==> f(a) : {f(x). x\<in>A}"
 | 
| 13780 | 479 | by (simp add: RepFun_def Replace_iff, blast) | 
| 480 | ||
| 481 | (*Useful for coinduction proofs*) | |
| 14227 | 482 | lemma RepFun_eqI [intro]: "[| b=f(a);  a \<in> A |] ==> b : {f(x). x\<in>A}"
 | 
| 13780 | 483 | apply (erule ssubst) | 
| 484 | apply (erule RepFunI) | |
| 485 | done | |
| 486 | ||
| 487 | lemma RepFunE [elim!]: | |
| 14227 | 488 |     "[| b : {f(x). x\<in>A};   
 | 
| 489 | !!x.[| x\<in>A; b=f(x) |] ==> P |] ==> | |
| 13780 | 490 | P" | 
| 491 | by (simp add: RepFun_def Replace_iff, blast) | |
| 492 | ||
| 493 | lemma RepFun_cong [cong]: | |
| 14227 | 494 | "[| A=B; !!x. x\<in>B ==> f(x)=g(x) |] ==> RepFun(A,f) = RepFun(B,g)" | 
| 13780 | 495 | by (simp add: RepFun_def) | 
| 496 | ||
| 14227 | 497 | lemma RepFun_iff [simp]: "b : {f(x). x\<in>A} <-> (\<exists>x\<in>A. b=f(x))"
 | 
| 13780 | 498 | by (unfold Bex_def, blast) | 
| 499 | ||
| 14227 | 500 | lemma triv_RepFun [simp]: "{x. x\<in>A} = A"
 | 
| 13780 | 501 | by blast | 
| 502 | ||
| 503 | ||
| 504 | subsection{*Rules for Collect -- forming a subset by separation*}
 | |
| 505 | ||
| 506 | (*Separation is derivable from Replacement*) | |
| 14227 | 507 | lemma separation [simp]: "a : {x\<in>A. P(x)} <-> a\<in>A & P(a)"
 | 
| 13780 | 508 | by (unfold Collect_def, blast) | 
| 509 | ||
| 14227 | 510 | lemma CollectI [intro!]: "[| a\<in>A;  P(a) |] ==> a : {x\<in>A. P(x)}"
 | 
| 13780 | 511 | by simp | 
| 512 | ||
| 14227 | 513 | lemma CollectE [elim!]: "[| a : {x\<in>A. P(x)};  [| a\<in>A; P(a) |] ==> R |] ==> R"
 | 
| 13780 | 514 | by simp | 
| 515 | ||
| 14227 | 516 | lemma CollectD1: "a : {x\<in>A. P(x)} ==> a\<in>A"
 | 
| 13780 | 517 | by (erule CollectE, assumption) | 
| 518 | ||
| 14227 | 519 | lemma CollectD2: "a : {x\<in>A. P(x)} ==> P(a)"
 | 
| 13780 | 520 | by (erule CollectE, assumption) | 
| 521 | ||
| 522 | lemma Collect_cong [cong]: | |
| 14227 | 523 | "[| A=B; !!x. x\<in>B ==> P(x) <-> Q(x) |] | 
| 13780 | 524 | ==> Collect(A, %x. P(x)) = Collect(B, %x. Q(x))" | 
| 525 | by (simp add: Collect_def) | |
| 526 | ||
| 527 | ||
| 528 | subsection{*Rules for Unions*}
 | |
| 529 | ||
| 530 | declare Union_iff [simp] | |
| 531 | ||
| 532 | (*The order of the premises presupposes that C is rigid; A may be flexible*) | |
| 533 | lemma UnionI [intro]: "[| B: C; A: B |] ==> A: Union(C)" | |
| 534 | by (simp, blast) | |
| 535 | ||
| 14227 | 536 | lemma UnionE [elim!]: "[| A \<in> Union(C); !!B.[| A: B; B: C |] ==> R |] ==> R" | 
| 13780 | 537 | by (simp, blast) | 
| 538 | ||
| 539 | ||
| 540 | subsection{*Rules for Unions of families*}
 | |
| 14227 | 541 | (* \<Union>x\<in>A. B(x) abbreviates Union({B(x). x\<in>A}) *)
 | 
| 13780 | 542 | |
| 14227 | 543 | lemma UN_iff [simp]: "b : (\<Union>x\<in>A. B(x)) <-> (\<exists>x\<in>A. b \<in> B(x))" | 
| 13780 | 544 | by (simp add: Bex_def, blast) | 
| 545 | ||
| 546 | (*The order of the premises presupposes that A is rigid; b may be flexible*) | |
| 14227 | 547 | lemma UN_I: "[| a: A; b: B(a) |] ==> b: (\<Union>x\<in>A. B(x))" | 
| 13780 | 548 | by (simp, blast) | 
| 549 | ||
| 550 | ||
| 551 | lemma UN_E [elim!]: | |
| 14227 | 552 | "[| b : (\<Union>x\<in>A. B(x)); !!x.[| x: A; b: B(x) |] ==> R |] ==> R" | 
| 13780 | 553 | by blast | 
| 554 | ||
| 555 | lemma UN_cong: | |
| 14227 | 556 | "[| A=B; !!x. x\<in>B ==> C(x)=D(x) |] ==> (\<Union>x\<in>A. C(x)) = (\<Union>x\<in>B. D(x))" | 
| 13780 | 557 | by simp | 
| 558 | ||
| 559 | ||
| 14227 | 560 | (*No "Addcongs [UN_cong]" because \<Union>is a combination of constants*) | 
| 13780 | 561 | |
| 562 | (* UN_E appears before UnionE so that it is tried first, to avoid expensive | |
| 563 | calls to hyp_subst_tac. Cannot include UN_I as it is unsafe: would enlarge | |
| 564 | the search space.*) | |
| 565 | ||
| 566 | ||
| 567 | subsection{*Rules for the empty set*}
 | |
| 568 | ||
| 14227 | 569 | (*The set {x\<in>0. False} is empty; by foundation it equals 0 
 | 
| 13780 | 570 | See Suppes, page 21.*) | 
| 571 | lemma not_mem_empty [simp]: "a ~: 0" | |
| 572 | apply (cut_tac foundation) | |
| 573 | apply (best dest: equalityD2) | |
| 574 | done | |
| 575 | ||
| 576 | lemmas emptyE [elim!] = not_mem_empty [THEN notE, standard] | |
| 577 | ||
| 578 | ||
| 579 | lemma empty_subsetI [simp]: "0 <= A" | |
| 580 | by blast | |
| 581 | ||
| 14227 | 582 | lemma equals0I: "[| !!y. y\<in>A ==> False |] ==> A=0" | 
| 13780 | 583 | by blast | 
| 584 | ||
| 585 | lemma equals0D [dest]: "A=0 ==> a ~: A" | |
| 586 | by blast | |
| 587 | ||
| 588 | declare sym [THEN equals0D, dest] | |
| 589 | ||
| 14227 | 590 | lemma not_emptyI: "a\<in>A ==> A ~= 0" | 
| 13780 | 591 | by blast | 
| 592 | ||
| 14227 | 593 | lemma not_emptyE: "[| A ~= 0; !!x. x\<in>A ==> R |] ==> R" | 
| 13780 | 594 | by blast | 
| 595 | ||
| 596 | ||
| 14095 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 597 | subsection{*Rules for Inter*}
 | 
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 598 | |
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 599 | (*Not obviously useful for proving InterI, InterD, InterE*) | 
| 14227 | 600 | lemma Inter_iff: "A \<in> Inter(C) <-> (\<forall>x\<in>C. A: x) & C\<noteq>0" | 
| 14095 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 601 | by (simp add: Inter_def Ball_def, blast) | 
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 602 | |
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 603 | (* Intersection is well-behaved only if the family is non-empty! *) | 
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 604 | lemma InterI [intro!]: | 
| 14227 | 605 | "[| !!x. x: C ==> A: x; C\<noteq>0 |] ==> A \<in> Inter(C)" | 
| 14095 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 606 | by (simp add: Inter_iff) | 
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 607 | |
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 608 | (*A "destruct" rule -- every B in C contains A as an element, but | 
| 14227 | 609 | A\<in>B can hold when B\<in>C does not! This rule is analogous to "spec". *) | 
| 610 | lemma InterD [elim]: "[| A \<in> Inter(C); B \<in> C |] ==> A \<in> B" | |
| 14095 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 611 | by (unfold Inter_def, blast) | 
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 612 | |
| 14227 | 613 | (*"Classical" elimination rule -- does not require exhibiting B\<in>C *) | 
| 14095 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 614 | lemma InterE [elim]: | 
| 14227 | 615 | "[| A \<in> Inter(C); B~:C ==> R; A\<in>B ==> R |] ==> R" | 
| 14095 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 616 | by (simp add: Inter_def, blast) | 
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 617 | |
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 618 | |
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 619 | subsection{*Rules for Intersections of families*}
 | 
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 620 | |
| 14227 | 621 | (* \<Inter>x\<in>A. B(x) abbreviates Inter({B(x). x\<in>A}) *)
 | 
| 14095 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 622 | |
| 14227 | 623 | lemma INT_iff: "b : (\<Inter>x\<in>A. B(x)) <-> (\<forall>x\<in>A. b \<in> B(x)) & A\<noteq>0" | 
| 14095 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 624 | by (force simp add: Inter_def) | 
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 625 | |
| 14227 | 626 | lemma INT_I: "[| !!x. x: A ==> b: B(x); A\<noteq>0 |] ==> b: (\<Inter>x\<in>A. B(x))" | 
| 14095 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 627 | by blast | 
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 628 | |
| 14227 | 629 | lemma INT_E: "[| b : (\<Inter>x\<in>A. B(x)); a: A |] ==> b \<in> B(a)" | 
| 14095 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 630 | by blast | 
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 631 | |
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 632 | lemma INT_cong: | 
| 14227 | 633 | "[| A=B; !!x. x\<in>B ==> C(x)=D(x) |] ==> (\<Inter>x\<in>A. C(x)) = (\<Inter>x\<in>B. D(x))" | 
| 14095 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 634 | by simp | 
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 635 | |
| 14227 | 636 | (*No "Addcongs [INT_cong]" because \<Inter>is a combination of constants*) | 
| 14095 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 637 | |
| 
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
 paulson parents: 
14076diff
changeset | 638 | |
| 13780 | 639 | subsection{*Rules for Powersets*}
 | 
| 640 | ||
| 14227 | 641 | lemma PowI: "A <= B ==> A \<in> Pow(B)" | 
| 13780 | 642 | by (erule Pow_iff [THEN iffD2]) | 
| 643 | ||
| 14227 | 644 | lemma PowD: "A \<in> Pow(B) ==> A<=B" | 
| 13780 | 645 | by (erule Pow_iff [THEN iffD1]) | 
| 646 | ||
| 647 | declare Pow_iff [iff] | |
| 648 | ||
| 14227 | 649 | lemmas Pow_bottom = empty_subsetI [THEN PowI] (* 0 \<in> Pow(B) *) | 
| 650 | lemmas Pow_top = subset_refl [THEN PowI] (* A \<in> Pow(A) *) | |
| 13780 | 651 | |
| 652 | ||
| 653 | subsection{*Cantor's Theorem: There is no surjection from a set to its powerset.*}
 | |
| 654 | ||
| 655 | (*The search is undirected. Allowing redundant introduction rules may | |
| 656 | make it diverge. Variable b represents ANY map, such as | |
| 14227 | 657 | (lam x\<in>A.b(x)): A->Pow(A). *) | 
| 658 | lemma cantor: "\<exists>S \<in> Pow(A). \<forall>x\<in>A. b(x) ~= S" | |
| 13780 | 659 | by (best elim!: equalityCE del: ReplaceI RepFun_eqI) | 
| 660 | ||
| 661 | (*Functions for ML scripts*) | |
| 662 | ML | |
| 663 | {*
 | |
| 14227 | 664 | (*Converts A<=B to x\<in>A ==> x\<in>B*) | 
| 24893 | 665 | fun impOfSubs th = th RSN (2, @{thm rev_subsetD});
 | 
| 13780 | 666 | |
| 14227 | 667 | (*Takes assumptions \<forall>x\<in>A.P(x) and a\<in>A; creates assumption P(a)*) | 
| 24893 | 668 | val ball_tac = dtac @{thm bspec} THEN' assume_tac
 | 
| 13780 | 669 | *} | 
| 0 | 670 | |
| 671 | end | |
| 672 |