| author | blanchet | 
| Wed, 18 Jun 2014 14:19:42 +0200 | |
| changeset 57273 | 01b68f625550 | 
| parent 55966 | 972f0aa7091b | 
| child 57698 | afef6616cbae | 
| permissions | -rw-r--r-- | 
| 55059 | 1  | 
(* Title: HOL/BNF_GFP.thy  | 
| 
48975
 
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
 
blanchet 
parents:  
diff
changeset
 | 
2  | 
Author: Dmitriy Traytel, TU Muenchen  | 
| 55059 | 3  | 
Author: Lorenz Panny, TU Muenchen  | 
4  | 
Author: Jasmin Blanchette, TU Muenchen  | 
|
5  | 
Copyright 2012, 2013  | 
|
| 
48975
 
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
 
blanchet 
parents:  
diff
changeset
 | 
6  | 
|
| 
 
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
 
blanchet 
parents:  
diff
changeset
 | 
7  | 
Greatest fixed point operation on bounded natural functors.  | 
| 
 
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
 
blanchet 
parents:  
diff
changeset
 | 
8  | 
*)  | 
| 
 
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
 
blanchet 
parents:  
diff
changeset
 | 
9  | 
|
| 
 
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
 
blanchet 
parents:  
diff
changeset
 | 
10  | 
header {* Greatest Fixed Point Operation on Bounded Natural Functors *}
 | 
| 
 
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
 
blanchet 
parents:  
diff
changeset
 | 
11  | 
|
| 
 
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
 
blanchet 
parents:  
diff
changeset
 | 
12  | 
theory BNF_GFP  | 
| 55578 | 13  | 
imports BNF_FP_Base String  | 
| 
48975
 
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
 
blanchet 
parents:  
diff
changeset
 | 
14  | 
keywords  | 
| 53310 | 15  | 
"codatatype" :: thy_decl and  | 
| 53822 | 16  | 
"primcorecursive" :: thy_goal and  | 
17  | 
"primcorec" :: thy_decl  | 
|
| 
48975
 
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
 
blanchet 
parents:  
diff
changeset
 | 
18  | 
begin  | 
| 
 
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
 
blanchet 
parents:  
diff
changeset
 | 
19  | 
|
| 55024 | 20  | 
setup {*
 | 
21  | 
Sign.const_alias @{binding proj} @{const_name Equiv_Relations.proj}
 | 
|
22  | 
*}  | 
|
23  | 
||
| 55966 | 24  | 
lemma one_pointE: "\<lbrakk>\<And>x. s = x \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"  | 
25  | 
by simp  | 
|
26  | 
||
27  | 
lemma obj_sumE: "\<lbrakk>\<forall>x. s = Inl x \<longrightarrow> P; \<forall>x. s = Inr x \<longrightarrow> P\<rbrakk> \<Longrightarrow> P"  | 
|
28  | 
by (cases s) auto  | 
|
29  | 
||
| 54485 | 30  | 
lemma not_TrueE: "\<not> True \<Longrightarrow> P"  | 
31  | 
by (erule notE, rule TrueI)  | 
|
32  | 
||
33  | 
lemma neq_eq_eq_contradict: "\<lbrakk>t \<noteq> u; s = t; s = u\<rbrakk> \<Longrightarrow> P"  | 
|
34  | 
by fast  | 
|
35  | 
||
| 
55414
 
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
 
blanchet 
parents: 
55413 
diff
changeset
 | 
36  | 
lemma case_sum_expand_Inr: "f o Inl = g \<Longrightarrow> f x = case_sum g (f o Inr) x"  | 
| 49312 | 37  | 
by (auto split: sum.splits)  | 
38  | 
||
| 
55414
 
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
 
blanchet 
parents: 
55413 
diff
changeset
 | 
39  | 
lemma case_sum_expand_Inr': "f o Inl = g \<Longrightarrow> h = f o Inr \<longleftrightarrow> case_sum g h = f"  | 
| 54488 | 40  | 
apply rule  | 
41  | 
apply (rule ext, force split: sum.split)  | 
|
| 
55414
 
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
 
blanchet 
parents: 
55413 
diff
changeset
 | 
42  | 
by (rule ext, metis case_sum_o_inj(2))  | 
| 
51739
 
3514b90d0a8b
(co)rec is (just as the (un)fold) the unique morphism;
 
traytel 
parents: 
51447 
diff
changeset
 | 
43  | 
|
| 49312 | 44  | 
lemma converse_Times: "(A \<times> B) ^-1 = B \<times> A"  | 
| 54488 | 45  | 
by fast  | 
| 49312 | 46  | 
|
47  | 
lemma equiv_proj:  | 
|
48  | 
assumes e: "equiv A R" and "z \<in> R"  | 
|
49  | 
shows "(proj R o fst) z = (proj R o snd) z"  | 
|
50  | 
proof -  | 
|
51  | 
from assms(2) have z: "(fst z, snd z) \<in> R" by auto  | 
|
| 53695 | 52  | 
with e have "\<And>x. (fst z, x) \<in> R \<Longrightarrow> (snd z, x) \<in> R" "\<And>x. (snd z, x) \<in> R \<Longrightarrow> (fst z, x) \<in> R"  | 
53  | 
unfolding equiv_def sym_def trans_def by blast+  | 
|
54  | 
then show ?thesis unfolding proj_def[abs_def] by auto  | 
|
| 49312 | 55  | 
qed  | 
56  | 
||
57  | 
(* Operators: *)  | 
|
58  | 
definition image2 where "image2 A f g = {(f a, g a) | a. a \<in> A}"
 | 
|
59  | 
||
| 51447 | 60  | 
lemma Id_on_Gr: "Id_on A = Gr A id"  | 
61  | 
unfolding Id_on_def Gr_def by auto  | 
|
| 49312 | 62  | 
|
63  | 
lemma image2_eqI: "\<lbrakk>b = f x; c = g x; x \<in> A\<rbrakk> \<Longrightarrow> (b, c) \<in> image2 A f g"  | 
|
64  | 
unfolding image2_def by auto  | 
|
65  | 
||
66  | 
lemma IdD: "(a, b) \<in> Id \<Longrightarrow> a = b"  | 
|
67  | 
by auto  | 
|
68  | 
||
69  | 
lemma image2_Gr: "image2 A f g = (Gr A f)^-1 O (Gr A g)"  | 
|
70  | 
unfolding image2_def Gr_def by auto  | 
|
71  | 
||
72  | 
lemma GrD1: "(x, fx) \<in> Gr A f \<Longrightarrow> x \<in> A"  | 
|
73  | 
unfolding Gr_def by simp  | 
|
74  | 
||
75  | 
lemma GrD2: "(x, fx) \<in> Gr A f \<Longrightarrow> f x = fx"  | 
|
76  | 
unfolding Gr_def by simp  | 
|
77  | 
||
78  | 
lemma Gr_incl: "Gr A f \<subseteq> A <*> B \<longleftrightarrow> f ` A \<subseteq> B"  | 
|
79  | 
unfolding Gr_def by auto  | 
|
80  | 
||
| 54485 | 81  | 
lemma subset_Collect_iff: "B \<subseteq> A \<Longrightarrow> (B \<subseteq> {x \<in> A. P x}) = (\<forall>x \<in> B. P x)"
 | 
82  | 
by blast  | 
|
83  | 
||
84  | 
lemma subset_CollectI: "B \<subseteq> A \<Longrightarrow> (\<And>x. x \<in> B \<Longrightarrow> Q x \<Longrightarrow> P x) \<Longrightarrow> ({x \<in> B. Q x} \<subseteq> {x \<in> A. P x})"
 | 
|
85  | 
by blast  | 
|
86  | 
||
| 
51893
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
87  | 
lemma in_rel_Collect_split_eq: "in_rel (Collect (split X)) = X"  | 
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
88  | 
unfolding fun_eq_iff by auto  | 
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
89  | 
|
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
90  | 
lemma Collect_split_in_rel_leI: "X \<subseteq> Y \<Longrightarrow> X \<subseteq> Collect (split (in_rel Y))"  | 
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
91  | 
by auto  | 
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
92  | 
|
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
93  | 
lemma Collect_split_in_rel_leE: "X \<subseteq> Collect (split (in_rel Y)) \<Longrightarrow> (X \<subseteq> Y \<Longrightarrow> R) \<Longrightarrow> R"  | 
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
94  | 
by force  | 
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
95  | 
|
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
96  | 
lemma conversep_in_rel: "(in_rel R)\<inverse>\<inverse> = in_rel (R\<inverse>)"  | 
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
97  | 
unfolding fun_eq_iff by auto  | 
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
98  | 
|
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
99  | 
lemma relcompp_in_rel: "in_rel R OO in_rel S = in_rel (R O S)"  | 
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
100  | 
unfolding fun_eq_iff by auto  | 
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
101  | 
|
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
102  | 
lemma in_rel_Gr: "in_rel (Gr A f) = Grp A f"  | 
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
103  | 
unfolding Gr_def Grp_def fun_eq_iff by auto  | 
| 
 
596baae88a88
got rid of the set based relator---use (binary) predicate based relator instead
 
traytel 
parents: 
51850 
diff
changeset
 | 
104  | 
|
| 49312 | 105  | 
definition relImage where  | 
106  | 
"relImage R f \<equiv> {(f a1, f a2) | a1 a2. (a1,a2) \<in> R}"
 | 
|
107  | 
||
108  | 
definition relInvImage where  | 
|
109  | 
"relInvImage A R f \<equiv> {(a1, a2) | a1 a2. a1 \<in> A \<and> a2 \<in> A \<and> (f a1, f a2) \<in> R}"
 | 
|
110  | 
||
111  | 
lemma relImage_Gr:  | 
|
112  | 
"\<lbrakk>R \<subseteq> A \<times> A\<rbrakk> \<Longrightarrow> relImage R f = (Gr A f)^-1 O R O Gr A f"  | 
|
113  | 
unfolding relImage_def Gr_def relcomp_def by auto  | 
|
114  | 
||
115  | 
lemma relInvImage_Gr: "\<lbrakk>R \<subseteq> B \<times> B\<rbrakk> \<Longrightarrow> relInvImage A R f = Gr A f O R O (Gr A f)^-1"  | 
|
116  | 
unfolding Gr_def relcomp_def image_def relInvImage_def by auto  | 
|
117  | 
||
118  | 
lemma relImage_mono:  | 
|
119  | 
"R1 \<subseteq> R2 \<Longrightarrow> relImage R1 f \<subseteq> relImage R2 f"  | 
|
120  | 
unfolding relImage_def by auto  | 
|
121  | 
||
122  | 
lemma relInvImage_mono:  | 
|
123  | 
"R1 \<subseteq> R2 \<Longrightarrow> relInvImage A R1 f \<subseteq> relInvImage A R2 f"  | 
|
124  | 
unfolding relInvImage_def by auto  | 
|
125  | 
||
| 51447 | 126  | 
lemma relInvImage_Id_on:  | 
127  | 
"(\<And>a1 a2. f a1 = f a2 \<longleftrightarrow> a1 = a2) \<Longrightarrow> relInvImage A (Id_on B) f \<subseteq> Id"  | 
|
128  | 
unfolding relInvImage_def Id_on_def by auto  | 
|
| 49312 | 129  | 
|
130  | 
lemma relInvImage_UNIV_relImage:  | 
|
131  | 
"R \<subseteq> relInvImage UNIV (relImage R f) f"  | 
|
132  | 
unfolding relInvImage_def relImage_def by auto  | 
|
133  | 
||
134  | 
lemma relImage_proj:  | 
|
135  | 
assumes "equiv A R"  | 
|
| 51447 | 136  | 
shows "relImage R (proj R) \<subseteq> Id_on (A//R)"  | 
137  | 
unfolding relImage_def Id_on_def  | 
|
138  | 
using proj_iff[OF assms] equiv_class_eq_iff[OF assms]  | 
|
139  | 
by (auto simp: proj_preserves)  | 
|
| 49312 | 140  | 
|
141  | 
lemma relImage_relInvImage:  | 
|
142  | 
assumes "R \<subseteq> f ` A <*> f ` A"  | 
|
143  | 
shows "relImage (relInvImage A R f) f = R"  | 
|
| 54488 | 144  | 
using assms unfolding relImage_def relInvImage_def by fast  | 
| 49312 | 145  | 
|
146  | 
lemma subst_Pair: "P x y \<Longrightarrow> a = (x, y) \<Longrightarrow> P (fst a) (snd a)"  | 
|
147  | 
by simp  | 
|
148  | 
||
| 55644 | 149  | 
lemma fst_diag_id: "(fst \<circ> (%x. (x, x))) z = id z" by simp  | 
150  | 
lemma snd_diag_id: "(snd \<circ> (%x. (x, x))) z = id z" by simp  | 
|
| 49312 | 151  | 
|
| 55644 | 152  | 
lemma fst_diag_fst: "fst o ((\<lambda>x. (x, x)) o fst) = fst" by auto  | 
153  | 
lemma snd_diag_fst: "snd o ((\<lambda>x. (x, x)) o fst) = fst" by auto  | 
|
154  | 
lemma fst_diag_snd: "fst o ((\<lambda>x. (x, x)) o snd) = snd" by auto  | 
|
155  | 
lemma snd_diag_snd: "snd o ((\<lambda>x. (x, x)) o snd) = snd" by auto  | 
|
| 49312 | 156  | 
|
157  | 
definition Succ where "Succ Kl kl = {k . kl @ [k] \<in> Kl}"
 | 
|
158  | 
definition Shift where "Shift Kl k = {kl. k # kl \<in> Kl}"
 | 
|
159  | 
definition shift where "shift lab k = (\<lambda>kl. lab (k # kl))"  | 
|
160  | 
||
161  | 
lemma empty_Shift: "\<lbrakk>[] \<in> Kl; k \<in> Succ Kl []\<rbrakk> \<Longrightarrow> [] \<in> Shift Kl k"  | 
|
162  | 
unfolding Shift_def Succ_def by simp  | 
|
163  | 
||
164  | 
lemma SuccD: "k \<in> Succ Kl kl \<Longrightarrow> kl @ [k] \<in> Kl"  | 
|
165  | 
unfolding Succ_def by simp  | 
|
166  | 
||
167  | 
lemmas SuccE = SuccD[elim_format]  | 
|
168  | 
||
169  | 
lemma SuccI: "kl @ [k] \<in> Kl \<Longrightarrow> k \<in> Succ Kl kl"  | 
|
170  | 
unfolding Succ_def by simp  | 
|
171  | 
||
172  | 
lemma ShiftD: "kl \<in> Shift Kl k \<Longrightarrow> k # kl \<in> Kl"  | 
|
173  | 
unfolding Shift_def by simp  | 
|
174  | 
||
175  | 
lemma Succ_Shift: "Succ (Shift Kl k) kl = Succ Kl (k # kl)"  | 
|
176  | 
unfolding Succ_def Shift_def by auto  | 
|
177  | 
||
178  | 
lemma length_Cons: "length (x # xs) = Suc (length xs)"  | 
|
179  | 
by simp  | 
|
180  | 
||
181  | 
lemma length_append_singleton: "length (xs @ [x]) = Suc (length xs)"  | 
|
182  | 
by simp  | 
|
183  | 
||
184  | 
(*injection into the field of a cardinal*)  | 
|
185  | 
definition "toCard_pred A r f \<equiv> inj_on f A \<and> f ` A \<subseteq> Field r \<and> Card_order r"  | 
|
186  | 
definition "toCard A r \<equiv> SOME f. toCard_pred A r f"  | 
|
187  | 
||
188  | 
lemma ex_toCard_pred:  | 
|
189  | 
"\<lbrakk>|A| \<le>o r; Card_order r\<rbrakk> \<Longrightarrow> \<exists> f. toCard_pred A r f"  | 
|
190  | 
unfolding toCard_pred_def  | 
|
191  | 
using card_of_ordLeq[of A "Field r"]  | 
|
192  | 
ordLeq_ordIso_trans[OF _ card_of_unique[of "Field r" r], of "|A|"]  | 
|
193  | 
by blast  | 
|
194  | 
||
195  | 
lemma toCard_pred_toCard:  | 
|
196  | 
"\<lbrakk>|A| \<le>o r; Card_order r\<rbrakk> \<Longrightarrow> toCard_pred A r (toCard A r)"  | 
|
197  | 
unfolding toCard_def using someI_ex[OF ex_toCard_pred] .  | 
|
198  | 
||
199  | 
lemma toCard_inj: "\<lbrakk>|A| \<le>o r; Card_order r; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow>  | 
|
200  | 
toCard A r x = toCard A r y \<longleftrightarrow> x = y"  | 
|
201  | 
using toCard_pred_toCard unfolding inj_on_def toCard_pred_def by blast  | 
|
202  | 
||
203  | 
definition "fromCard A r k \<equiv> SOME b. b \<in> A \<and> toCard A r b = k"  | 
|
204  | 
||
205  | 
lemma fromCard_toCard:  | 
|
206  | 
"\<lbrakk>|A| \<le>o r; Card_order r; b \<in> A\<rbrakk> \<Longrightarrow> fromCard A r (toCard A r b) = b"  | 
|
207  | 
unfolding fromCard_def by (rule some_equality) (auto simp add: toCard_inj)  | 
|
208  | 
||
209  | 
lemma Inl_Field_csum: "a \<in> Field r \<Longrightarrow> Inl a \<in> Field (r +c s)"  | 
|
210  | 
unfolding Field_card_of csum_def by auto  | 
|
211  | 
||
212  | 
lemma Inr_Field_csum: "a \<in> Field s \<Longrightarrow> Inr a \<in> Field (r +c s)"  | 
|
213  | 
unfolding Field_card_of csum_def by auto  | 
|
214  | 
||
| 55415 | 215  | 
lemma rec_nat_0_imp: "f = rec_nat f1 (%n rec. f2 n rec) \<Longrightarrow> f 0 = f1"  | 
| 49312 | 216  | 
by auto  | 
217  | 
||
| 55415 | 218  | 
lemma rec_nat_Suc_imp: "f = rec_nat f1 (%n rec. f2 n rec) \<Longrightarrow> f (Suc n) = f2 n (f n)"  | 
| 49312 | 219  | 
by auto  | 
220  | 
||
| 
55413
 
a8e96847523c
adapted theories to '{case,rec}_{list,option}' names
 
blanchet 
parents: 
55079 
diff
changeset
 | 
221  | 
lemma rec_list_Nil_imp: "f = rec_list f1 (%x xs rec. f2 x xs rec) \<Longrightarrow> f [] = f1"  | 
| 49312 | 222  | 
by auto  | 
223  | 
||
| 
55413
 
a8e96847523c
adapted theories to '{case,rec}_{list,option}' names
 
blanchet 
parents: 
55079 
diff
changeset
 | 
224  | 
lemma rec_list_Cons_imp: "f = rec_list f1 (%x xs rec. f2 x xs rec) \<Longrightarrow> f (x # xs) = f2 x xs (f xs)"  | 
| 49312 | 225  | 
by auto  | 
226  | 
||
227  | 
lemma not_arg_cong_Inr: "x \<noteq> y \<Longrightarrow> Inr x \<noteq> Inr y"  | 
|
228  | 
by simp  | 
|
229  | 
||
| 51925 | 230  | 
lemma Collect_splitD: "x \<in> Collect (split A) \<Longrightarrow> A (fst x) (snd x)"  | 
231  | 
by auto  | 
|
232  | 
||
| 52731 | 233  | 
definition image2p where  | 
234  | 
"image2p f g R = (\<lambda>x y. \<exists>x' y'. R x' y' \<and> f x' = x \<and> g y' = y)"  | 
|
235  | 
||
| 
55463
 
942c2153b5b4
register 'Spec_Rules' for new-style (co)datatypes
 
blanchet 
parents: 
55415 
diff
changeset
 | 
236  | 
lemma image2pI: "R x y \<Longrightarrow> image2p f g R (f x) (g y)"  | 
| 52731 | 237  | 
unfolding image2p_def by blast  | 
238  | 
||
| 
55463
 
942c2153b5b4
register 'Spec_Rules' for new-style (co)datatypes
 
blanchet 
parents: 
55415 
diff
changeset
 | 
239  | 
lemma image2pE: "\<lbrakk>image2p f g R fx gy; (\<And>x y. fx = f x \<Longrightarrow> gy = g y \<Longrightarrow> R x y \<Longrightarrow> P)\<rbrakk> \<Longrightarrow> P"  | 
| 52731 | 240  | 
unfolding image2p_def by blast  | 
241  | 
||
| 55945 | 242  | 
lemma rel_fun_iff_geq_image2p: "rel_fun R S f g = (image2p f g R \<le> S)"  | 
243  | 
unfolding rel_fun_def image2p_def by auto  | 
|
| 52731 | 244  | 
|
| 55945 | 245  | 
lemma rel_fun_image2p: "rel_fun R (image2p f g R) f g"  | 
246  | 
unfolding rel_fun_def image2p_def by auto  | 
|
| 52731 | 247  | 
|
| 
55022
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
248  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
249  | 
subsection {* Equivalence relations, quotients, and Hilbert's choice *}
 | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
250  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
251  | 
lemma equiv_Eps_in:  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
252  | 
"\<lbrakk>equiv A r; X \<in> A//r\<rbrakk> \<Longrightarrow> Eps (%x. x \<in> X) \<in> X"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
253  | 
apply (rule someI2_ex)  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
254  | 
using in_quotient_imp_non_empty by blast  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
255  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
256  | 
lemma equiv_Eps_preserves:  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
257  | 
assumes ECH: "equiv A r" and X: "X \<in> A//r"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
258  | 
shows "Eps (%x. x \<in> X) \<in> A"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
259  | 
apply (rule in_mono[rule_format])  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
260  | 
using assms apply (rule in_quotient_imp_subset)  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
261  | 
by (rule equiv_Eps_in) (rule assms)+  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
262  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
263  | 
lemma proj_Eps:  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
264  | 
assumes "equiv A r" and "X \<in> A//r"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
265  | 
shows "proj r (Eps (%x. x \<in> X)) = X"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
266  | 
unfolding proj_def proof auto  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
267  | 
fix x assume x: "x \<in> X"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
268  | 
thus "(Eps (%x. x \<in> X), x) \<in> r" using assms equiv_Eps_in in_quotient_imp_in_rel by fast  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
269  | 
next  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
270  | 
fix x assume "(Eps (%x. x \<in> X),x) \<in> r"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
271  | 
thus "x \<in> X" using in_quotient_imp_closed[OF assms equiv_Eps_in[OF assms]] by fast  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
272  | 
qed  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
273  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
274  | 
definition univ where "univ f X == f (Eps (%x. x \<in> X))"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
275  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
276  | 
lemma univ_commute:  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
277  | 
assumes ECH: "equiv A r" and RES: "f respects r" and x: "x \<in> A"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
278  | 
shows "(univ f) (proj r x) = f x"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
279  | 
unfolding univ_def proof -  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
280  | 
have prj: "proj r x \<in> A//r" using x proj_preserves by fast  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
281  | 
hence "Eps (%y. y \<in> proj r x) \<in> A" using ECH equiv_Eps_preserves by fast  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
282  | 
moreover have "proj r (Eps (%y. y \<in> proj r x)) = proj r x" using ECH prj proj_Eps by fast  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
283  | 
ultimately have "(x, Eps (%y. y \<in> proj r x)) \<in> r" using x ECH proj_iff by fast  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
284  | 
thus "f (Eps (%y. y \<in> proj r x)) = f x" using RES unfolding congruent_def by fastforce  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
285  | 
qed  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
286  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
287  | 
lemma univ_preserves:  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
288  | 
assumes ECH: "equiv A r" and RES: "f respects r" and  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
289  | 
PRES: "\<forall> x \<in> A. f x \<in> B"  | 
| 
55463
 
942c2153b5b4
register 'Spec_Rules' for new-style (co)datatypes
 
blanchet 
parents: 
55415 
diff
changeset
 | 
290  | 
shows "\<forall>X \<in> A//r. univ f X \<in> B"  | 
| 
55022
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
291  | 
proof  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
292  | 
fix X assume "X \<in> A//r"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
293  | 
then obtain x where x: "x \<in> A" and X: "X = proj r x" using ECH proj_image[of r A] by blast  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
294  | 
hence "univ f X = f x" using assms univ_commute by fastforce  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
295  | 
thus "univ f X \<in> B" using x PRES by simp  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
296  | 
qed  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54841 
diff
changeset
 | 
297  | 
|
| 55062 | 298  | 
ML_file "Tools/BNF/bnf_gfp_util.ML"  | 
299  | 
ML_file "Tools/BNF/bnf_gfp_tactics.ML"  | 
|
300  | 
ML_file "Tools/BNF/bnf_gfp.ML"  | 
|
| 55538 | 301  | 
ML_file "Tools/BNF/bnf_gfp_rec_sugar_tactics.ML"  | 
302  | 
ML_file "Tools/BNF/bnf_gfp_rec_sugar.ML"  | 
|
| 
49309
 
f20b24214ac2
split basic BNFs into really basic ones and others, and added Andreas Lochbihler's "option" BNF
 
blanchet 
parents: 
49308 
diff
changeset
 | 
303  | 
|
| 
48975
 
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
 
blanchet 
parents:  
diff
changeset
 | 
304  | 
end  |