| author | blanchet | 
| Fri, 18 Nov 2011 11:47:12 +0100 | |
| changeset 45572 | 08970468f99b | 
| parent 44011 | f67c93f52d13 | 
| child 45694 | 4a8743618257 | 
| permissions | -rw-r--r-- | 
| 19203 | 1  | 
(* Title: HOL/ZF/Zet.thy  | 
2  | 
Author: Steven Obua  | 
|
3  | 
||
4  | 
Introduces a type 'a zet of ZF representable sets.  | 
|
5  | 
See "Partizan Games in Isabelle/HOLZF", available from http://www4.in.tum.de/~obua/partizan  | 
|
6  | 
*)  | 
|
7  | 
||
8  | 
theory Zet  | 
|
9  | 
imports HOLZF  | 
|
10  | 
begin  | 
|
11  | 
||
12  | 
typedef 'a zet = "{A :: 'a set | A f z. inj_on f A \<and> f ` A \<subseteq> explode z}"
 | 
|
13  | 
by blast  | 
|
14  | 
||
| 
35416
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
33057 
diff
changeset
 | 
15  | 
definition zin :: "'a \<Rightarrow> 'a zet \<Rightarrow> bool" where  | 
| 19203 | 16  | 
"zin x A == x \<in> (Rep_zet A)"  | 
17  | 
||
18  | 
lemma zet_ext_eq: "(A = B) = (! x. zin x A = zin x B)"  | 
|
19  | 
by (auto simp add: Rep_zet_inject[symmetric] zin_def)  | 
|
20  | 
||
| 
35416
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
33057 
diff
changeset
 | 
21  | 
definition zimage :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a zet \<Rightarrow> 'b zet" where
 | 
| 19203 | 22  | 
"zimage f A == Abs_zet (image f (Rep_zet A))"  | 
23  | 
||
24  | 
lemma zet_def': "zet = {A :: 'a set | A f z. inj_on f A \<and> f ` A = explode z}"
 | 
|
| 
39302
 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 
nipkow 
parents: 
35502 
diff
changeset
 | 
25  | 
apply (rule set_eqI)  | 
| 19203 | 26  | 
apply (auto simp add: zet_def)  | 
27  | 
apply (rule_tac x=f in exI)  | 
|
28  | 
apply auto  | 
|
29  | 
apply (rule_tac x="Sep z (\<lambda> y. y \<in> (f ` x))" in exI)  | 
|
30  | 
apply (auto simp add: explode_def Sep)  | 
|
31  | 
done  | 
|
32  | 
||
33  | 
lemma image_zet_rep: "A \<in> zet \<Longrightarrow> ? z . g ` A = explode z"  | 
|
34  | 
apply (auto simp add: zet_def')  | 
|
| 33057 | 35  | 
apply (rule_tac x="Repl z (g o (inv_into A f))" in exI)  | 
| 19203 | 36  | 
apply (simp add: explode_Repl_eq)  | 
37  | 
apply (subgoal_tac "explode z = f ` A")  | 
|
| 35502 | 38  | 
apply (simp_all add: image_compose)  | 
| 19203 | 39  | 
done  | 
40  | 
||
41  | 
lemma zet_image_mem:  | 
|
42  | 
assumes Azet: "A \<in> zet"  | 
|
43  | 
shows "g ` A \<in> zet"  | 
|
44  | 
proof -  | 
|
45  | 
from Azet have "? (f :: _ \<Rightarrow> ZF). inj_on f A"  | 
|
46  | 
by (auto simp add: zet_def')  | 
|
47  | 
then obtain f where injf: "inj_on (f :: _ \<Rightarrow> ZF) A"  | 
|
48  | 
by auto  | 
|
| 33057 | 49  | 
let ?w = "f o (inv_into A g)"  | 
50  | 
have subset: "(inv_into A g) ` (g ` A) \<subseteq> A"  | 
|
51  | 
by (auto simp add: inv_into_into)  | 
|
52  | 
have "inj_on (inv_into A g) (g ` A)" by (simp add: inj_on_inv_into)  | 
|
| 19203 | 53  | 
then have injw: "inj_on ?w (g ` A)"  | 
54  | 
apply (rule comp_inj_on)  | 
|
55  | 
apply (rule subset_inj_on[where B=A])  | 
|
56  | 
apply (auto simp add: subset injf)  | 
|
57  | 
done  | 
|
58  | 
show ?thesis  | 
|
| 35502 | 59  | 
apply (simp add: zet_def' image_compose[symmetric])  | 
| 19203 | 60  | 
apply (rule exI[where x="?w"])  | 
61  | 
apply (simp add: injw image_zet_rep Azet)  | 
|
62  | 
done  | 
|
63  | 
qed  | 
|
64  | 
||
65  | 
lemma Rep_zimage_eq: "Rep_zet (zimage f A) = image f (Rep_zet A)"  | 
|
66  | 
apply (simp add: zimage_def)  | 
|
67  | 
apply (subst Abs_zet_inverse)  | 
|
68  | 
apply (simp_all add: Rep_zet zet_image_mem)  | 
|
69  | 
done  | 
|
70  | 
||
71  | 
lemma zimage_iff: "zin y (zimage f A) = (? x. zin x A & y = f x)"  | 
|
72  | 
by (auto simp add: zin_def Rep_zimage_eq)  | 
|
73  | 
||
| 
35416
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
33057 
diff
changeset
 | 
74  | 
definition zimplode :: "ZF zet \<Rightarrow> ZF" where  | 
| 19203 | 75  | 
"zimplode A == implode (Rep_zet A)"  | 
| 
35416
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
33057 
diff
changeset
 | 
76  | 
|
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
33057 
diff
changeset
 | 
77  | 
definition zexplode :: "ZF \<Rightarrow> ZF zet" where  | 
| 19203 | 78  | 
"zexplode z == Abs_zet (explode z)"  | 
79  | 
||
80  | 
lemma Rep_zet_eq_explode: "? z. Rep_zet A = explode z"  | 
|
81  | 
by (rule image_zet_rep[where g="\<lambda> x. x",OF Rep_zet, simplified])  | 
|
82  | 
||
83  | 
lemma zexplode_zimplode: "zexplode (zimplode A) = A"  | 
|
84  | 
apply (simp add: zimplode_def zexplode_def)  | 
|
85  | 
apply (simp add: implode_def)  | 
|
| 33057 | 86  | 
apply (subst f_inv_into_f[where y="Rep_zet A"])  | 
| 19203 | 87  | 
apply (auto simp add: Rep_zet_inverse Rep_zet_eq_explode image_def)  | 
88  | 
done  | 
|
89  | 
||
90  | 
lemma explode_mem_zet: "explode z \<in> zet"  | 
|
91  | 
apply (simp add: zet_def')  | 
|
92  | 
apply (rule_tac x="% x. x" in exI)  | 
|
93  | 
apply (auto simp add: inj_on_def)  | 
|
94  | 
done  | 
|
95  | 
||
96  | 
lemma zimplode_zexplode: "zimplode (zexplode z) = z"  | 
|
97  | 
apply (simp add: zimplode_def zexplode_def)  | 
|
98  | 
apply (subst Abs_zet_inverse)  | 
|
99  | 
apply (auto simp add: explode_mem_zet implode_explode)  | 
|
100  | 
done  | 
|
101  | 
||
102  | 
lemma zin_zexplode_eq: "zin x (zexplode A) = Elem x A"  | 
|
103  | 
apply (simp add: zin_def zexplode_def)  | 
|
104  | 
apply (subst Abs_zet_inverse)  | 
|
105  | 
apply (simp_all add: explode_Elem explode_mem_zet)  | 
|
106  | 
done  | 
|
107  | 
||
108  | 
lemma comp_zimage_eq: "zimage g (zimage f A) = zimage (g o f) A"  | 
|
109  | 
apply (simp add: zimage_def)  | 
|
110  | 
apply (subst Abs_zet_inverse)  | 
|
| 35502 | 111  | 
apply (simp_all add: image_compose zet_image_mem Rep_zet)  | 
| 19203 | 112  | 
done  | 
113  | 
||
| 
35416
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
33057 
diff
changeset
 | 
114  | 
definition zunion :: "'a zet \<Rightarrow> 'a zet \<Rightarrow> 'a zet" where  | 
| 19203 | 115  | 
"zunion a b \<equiv> Abs_zet ((Rep_zet a) \<union> (Rep_zet b))"  | 
| 
35416
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
33057 
diff
changeset
 | 
116  | 
|
| 
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
33057 
diff
changeset
 | 
117  | 
definition zsubset :: "'a zet \<Rightarrow> 'a zet \<Rightarrow> bool" where  | 
| 19203 | 118  | 
"zsubset a b \<equiv> ! x. zin x a \<longrightarrow> zin x b"  | 
119  | 
||
120  | 
lemma explode_union: "explode (union a b) = (explode a) \<union> (explode b)"  | 
|
| 
39302
 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 
nipkow 
parents: 
35502 
diff
changeset
 | 
121  | 
apply (rule set_eqI)  | 
| 19203 | 122  | 
apply (simp add: explode_def union)  | 
123  | 
done  | 
|
124  | 
||
125  | 
lemma Rep_zet_zunion: "Rep_zet (zunion a b) = (Rep_zet a) \<union> (Rep_zet b)"  | 
|
126  | 
proof -  | 
|
127  | 
from Rep_zet[of a] have "? f z. inj_on f (Rep_zet a) \<and> f ` (Rep_zet a) = explode z"  | 
|
128  | 
by (auto simp add: zet_def')  | 
|
129  | 
then obtain fa za where a:"inj_on fa (Rep_zet a) \<and> fa ` (Rep_zet a) = explode za"  | 
|
130  | 
by blast  | 
|
131  | 
from a have fa: "inj_on fa (Rep_zet a)" by blast  | 
|
132  | 
from a have za: "fa ` (Rep_zet a) = explode za" by blast  | 
|
133  | 
from Rep_zet[of b] have "? f z. inj_on f (Rep_zet b) \<and> f ` (Rep_zet b) = explode z"  | 
|
134  | 
by (auto simp add: zet_def')  | 
|
135  | 
then obtain fb zb where b:"inj_on fb (Rep_zet b) \<and> fb ` (Rep_zet b) = explode zb"  | 
|
136  | 
by blast  | 
|
137  | 
from b have fb: "inj_on fb (Rep_zet b)" by blast  | 
|
138  | 
from b have zb: "fb ` (Rep_zet b) = explode zb" by blast  | 
|
139  | 
let ?f = "(\<lambda> x. if x \<in> (Rep_zet a) then Opair (fa x) (Empty) else Opair (fb x) (Singleton Empty))"  | 
|
140  | 
let ?z = "CartProd (union za zb) (Upair Empty (Singleton Empty))"  | 
|
141  | 
have se: "Singleton Empty \<noteq> Empty"  | 
|
142  | 
apply (auto simp add: Ext Singleton)  | 
|
143  | 
apply (rule exI[where x=Empty])  | 
|
144  | 
apply (simp add: Empty)  | 
|
145  | 
done  | 
|
146  | 
show ?thesis  | 
|
147  | 
apply (simp add: zunion_def)  | 
|
148  | 
apply (subst Abs_zet_inverse)  | 
|
149  | 
apply (auto simp add: zet_def)  | 
|
150  | 
apply (rule exI[where x = ?f])  | 
|
151  | 
apply (rule conjI)  | 
|
152  | 
apply (auto simp add: inj_on_def Opair inj_onD[OF fa] inj_onD[OF fb] se se[symmetric])  | 
|
153  | 
apply (rule exI[where x = ?z])  | 
|
154  | 
apply (insert za zb)  | 
|
155  | 
apply (auto simp add: explode_def CartProd union Upair Opair)  | 
|
156  | 
done  | 
|
157  | 
qed  | 
|
158  | 
||
159  | 
lemma zunion: "zin x (zunion a b) = ((zin x a) \<or> (zin x b))"  | 
|
160  | 
by (auto simp add: zin_def Rep_zet_zunion)  | 
|
161  | 
||
162  | 
lemma zimage_zexplode_eq: "zimage f (zexplode z) = zexplode (Repl z f)"  | 
|
163  | 
by (simp add: zet_ext_eq zin_zexplode_eq Repl zimage_iff)  | 
|
164  | 
||
165  | 
lemma range_explode_eq_zet: "range explode = zet"  | 
|
| 
39302
 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 
nipkow 
parents: 
35502 
diff
changeset
 | 
166  | 
apply (rule set_eqI)  | 
| 19203 | 167  | 
apply (auto simp add: explode_mem_zet)  | 
168  | 
apply (drule image_zet_rep)  | 
|
169  | 
apply (simp add: image_def)  | 
|
170  | 
apply auto  | 
|
171  | 
apply (rule_tac x=z in exI)  | 
|
172  | 
apply auto  | 
|
173  | 
done  | 
|
174  | 
||
175  | 
lemma Elem_zimplode: "(Elem x (zimplode z)) = (zin x z)"  | 
|
176  | 
apply (simp add: zimplode_def)  | 
|
177  | 
apply (subst Elem_implode)  | 
|
178  | 
apply (simp_all add: zin_def Rep_zet range_explode_eq_zet)  | 
|
179  | 
done  | 
|
180  | 
||
| 
35416
 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 
haftmann 
parents: 
33057 
diff
changeset
 | 
181  | 
definition zempty :: "'a zet" where  | 
| 19203 | 182  | 
  "zempty \<equiv> Abs_zet {}"
 | 
183  | 
||
184  | 
lemma zempty[simp]: "\<not> (zin x zempty)"  | 
|
185  | 
by (auto simp add: zin_def zempty_def Abs_zet_inverse zet_def)  | 
|
186  | 
||
187  | 
lemma zimage_zempty[simp]: "zimage f zempty = zempty"  | 
|
188  | 
by (auto simp add: zet_ext_eq zimage_iff)  | 
|
189  | 
||
190  | 
lemma zunion_zempty_left[simp]: "zunion zempty a = a"  | 
|
191  | 
by (simp add: zet_ext_eq zunion)  | 
|
192  | 
||
193  | 
lemma zunion_zempty_right[simp]: "zunion a zempty = a"  | 
|
194  | 
by (simp add: zet_ext_eq zunion)  | 
|
195  | 
||
196  | 
lemma zimage_id[simp]: "zimage id A = A"  | 
|
197  | 
by (simp add: zet_ext_eq zimage_iff)  | 
|
198  | 
||
| 
44011
 
f67c93f52d13
eliminated obsolete recdef/wfrec related declarations
 
krauss 
parents: 
39302 
diff
changeset
 | 
199  | 
lemma zimage_cong[fundef_cong]: "\<lbrakk> M = N; !! x. zin x N \<Longrightarrow> f x = g x \<rbrakk> \<Longrightarrow> zimage f M = zimage g N"  | 
| 19203 | 200  | 
by (auto simp add: zet_ext_eq zimage_iff)  | 
201  | 
||
202  | 
end  |