author | huffman |
Mon, 01 Mar 2010 16:36:25 -0800 | |
changeset 35489 | dd02201d95b6 |
parent 35480 | 7a1f285cad25 |
child 35490 | 63f8121c6585 |
permissions | -rw-r--r-- |
33589 | 1 |
(* Title: HOLCF/Representable.thy |
2 |
Author: Brian Huffman |
|
3 |
*) |
|
4 |
||
33588 | 5 |
header {* Representable Types *} |
6 |
||
7 |
theory Representable |
|
35473 | 8 |
imports Algebraic Universal Ssum Sprod One Fixrec |
33794
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
9 |
uses |
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
10 |
("Tools/repdef.ML") |
35475
979019ab92eb
move common functions into new file holcf_library.ML
huffman
parents:
35473
diff
changeset
|
11 |
("Tools/holcf_library.ML") |
33794
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
12 |
("Tools/Domain/domain_isomorphism.ML") |
33588 | 13 |
begin |
14 |
||
15 |
subsection {* Class of representable types *} |
|
16 |
||
17 |
text "Overloaded embedding and projection functions between |
|
18 |
a representable type and the universal domain." |
|
19 |
||
20 |
class rep = bifinite + |
|
21 |
fixes emb :: "'a::pcpo \<rightarrow> udom" |
|
22 |
fixes prj :: "udom \<rightarrow> 'a::pcpo" |
|
23 |
assumes ep_pair_emb_prj: "ep_pair emb prj" |
|
24 |
||
25 |
interpretation rep!: |
|
26 |
pcpo_ep_pair |
|
27 |
"emb :: 'a::rep \<rightarrow> udom" |
|
28 |
"prj :: udom \<rightarrow> 'a::rep" |
|
29 |
unfolding pcpo_ep_pair_def |
|
30 |
by (rule ep_pair_emb_prj) |
|
31 |
||
32 |
lemmas emb_inverse = rep.e_inverse |
|
33 |
lemmas emb_prj_below = rep.e_p_below |
|
34 |
lemmas emb_eq_iff = rep.e_eq_iff |
|
35 |
lemmas emb_strict = rep.e_strict |
|
36 |
lemmas prj_strict = rep.p_strict |
|
37 |
||
38 |
||
39 |
subsection {* Making @{term rep} the default class *} |
|
40 |
||
41 |
text {* |
|
42 |
From now on, free type variables are assumed to be in class |
|
43 |
@{term rep}, unless specified otherwise. |
|
44 |
*} |
|
45 |
||
46 |
defaultsort rep |
|
47 |
||
48 |
subsection {* Representations of types *} |
|
49 |
||
50 |
text "A TypeRep is an algebraic deflation over the universe of values." |
|
51 |
||
52 |
types TypeRep = "udom alg_defl" |
|
53 |
translations "TypeRep" \<leftharpoondown> (type) "udom alg_defl" |
|
54 |
||
55 |
definition |
|
56 |
Rep_of :: "'a::rep itself \<Rightarrow> TypeRep" |
|
57 |
where |
|
58 |
"Rep_of TYPE('a::rep) = |
|
59 |
(\<Squnion>i. alg_defl_principal (Abs_fin_defl |
|
60 |
(emb oo (approx i :: 'a \<rightarrow> 'a) oo prj)))" |
|
61 |
||
62 |
syntax "_REP" :: "type \<Rightarrow> TypeRep" ("(1REP/(1'(_')))") |
|
63 |
translations "REP(t)" \<rightleftharpoons> "CONST Rep_of TYPE(t)" |
|
64 |
||
65 |
lemma cast_REP: |
|
66 |
"cast\<cdot>REP('a::rep) = (emb::'a \<rightarrow> udom) oo (prj::udom \<rightarrow> 'a)" |
|
67 |
proof - |
|
68 |
let ?a = "\<lambda>i. emb oo approx i oo (prj::udom \<rightarrow> 'a)" |
|
69 |
have a: "\<And>i. finite_deflation (?a i)" |
|
70 |
apply (rule rep.finite_deflation_e_d_p) |
|
71 |
apply (rule finite_deflation_approx) |
|
72 |
done |
|
73 |
show ?thesis |
|
74 |
unfolding Rep_of_def |
|
75 |
apply (subst contlub_cfun_arg) |
|
76 |
apply (rule chainI) |
|
77 |
apply (rule alg_defl.principal_mono) |
|
78 |
apply (rule Abs_fin_defl_mono [OF a a]) |
|
79 |
apply (rule chainE, simp) |
|
80 |
apply (subst cast_alg_defl_principal) |
|
81 |
apply (simp add: Abs_fin_defl_inverse a) |
|
82 |
apply (simp add: expand_cfun_eq lub_distribs) |
|
83 |
done |
|
84 |
qed |
|
85 |
||
86 |
lemma emb_prj: "emb\<cdot>((prj\<cdot>x)::'a::rep) = cast\<cdot>REP('a)\<cdot>x" |
|
87 |
by (simp add: cast_REP) |
|
88 |
||
89 |
lemma in_REP_iff: |
|
90 |
"x ::: REP('a::rep) \<longleftrightarrow> emb\<cdot>((prj\<cdot>x)::'a) = x" |
|
91 |
by (simp add: in_deflation_def cast_REP) |
|
92 |
||
93 |
lemma prj_inverse: |
|
94 |
"x ::: REP('a::rep) \<Longrightarrow> emb\<cdot>((prj\<cdot>x)::'a) = x" |
|
95 |
by (simp only: in_REP_iff) |
|
96 |
||
97 |
lemma emb_in_REP [simp]: |
|
98 |
"emb\<cdot>(x::'a::rep) ::: REP('a)" |
|
99 |
by (simp add: in_REP_iff) |
|
100 |
||
101 |
subsection {* Coerce operator *} |
|
102 |
||
103 |
definition coerce :: "'a \<rightarrow> 'b" |
|
104 |
where "coerce = prj oo emb" |
|
105 |
||
106 |
lemma beta_coerce: "coerce\<cdot>x = prj\<cdot>(emb\<cdot>x)" |
|
107 |
by (simp add: coerce_def) |
|
108 |
||
109 |
lemma prj_emb: "prj\<cdot>(emb\<cdot>x) = coerce\<cdot>x" |
|
110 |
by (simp add: coerce_def) |
|
111 |
||
112 |
lemma coerce_strict [simp]: "coerce\<cdot>\<bottom> = \<bottom>" |
|
113 |
by (simp add: coerce_def) |
|
114 |
||
115 |
lemma coerce_eq_ID [simp]: "(coerce :: 'a \<rightarrow> 'a) = ID" |
|
116 |
by (rule ext_cfun, simp add: beta_coerce) |
|
117 |
||
118 |
lemma emb_coerce: |
|
119 |
"REP('a) \<sqsubseteq> REP('b) |
|
120 |
\<Longrightarrow> emb\<cdot>((coerce::'a \<rightarrow> 'b)\<cdot>x) = emb\<cdot>x" |
|
121 |
apply (simp add: beta_coerce) |
|
122 |
apply (rule prj_inverse) |
|
123 |
apply (erule subdeflationD) |
|
124 |
apply (rule emb_in_REP) |
|
125 |
done |
|
126 |
||
127 |
lemma coerce_prj: |
|
128 |
"REP('a) \<sqsubseteq> REP('b) |
|
129 |
\<Longrightarrow> (coerce::'b \<rightarrow> 'a)\<cdot>(prj\<cdot>x) = prj\<cdot>x" |
|
130 |
apply (simp add: coerce_def) |
|
131 |
apply (rule emb_eq_iff [THEN iffD1]) |
|
132 |
apply (simp only: emb_prj) |
|
133 |
apply (rule deflation_below_comp1) |
|
134 |
apply (rule deflation_cast) |
|
135 |
apply (rule deflation_cast) |
|
136 |
apply (erule monofun_cfun_arg) |
|
137 |
done |
|
138 |
||
139 |
lemma coerce_coerce [simp]: |
|
140 |
"REP('a) \<sqsubseteq> REP('b) |
|
141 |
\<Longrightarrow> coerce\<cdot>((coerce::'a \<rightarrow> 'b)\<cdot>x) = coerce\<cdot>x" |
|
142 |
by (simp add: beta_coerce prj_inverse subdeflationD) |
|
143 |
||
144 |
lemma coerce_inverse: |
|
145 |
"emb\<cdot>(x::'a) ::: REP('b) \<Longrightarrow> coerce\<cdot>(coerce\<cdot>x :: 'b) = x" |
|
146 |
by (simp only: beta_coerce prj_inverse emb_inverse) |
|
147 |
||
148 |
lemma coerce_type: |
|
149 |
"REP('a) \<sqsubseteq> REP('b) |
|
150 |
\<Longrightarrow> emb\<cdot>((coerce::'a \<rightarrow> 'b)\<cdot>x) ::: REP('a)" |
|
151 |
by (simp add: beta_coerce prj_inverse subdeflationD) |
|
152 |
||
153 |
lemma ep_pair_coerce: |
|
154 |
"REP('a) \<sqsubseteq> REP('b) |
|
155 |
\<Longrightarrow> ep_pair (coerce::'a \<rightarrow> 'b) (coerce::'b \<rightarrow> 'a)" |
|
156 |
apply (rule ep_pair.intro) |
|
157 |
apply simp |
|
158 |
apply (simp only: beta_coerce) |
|
159 |
apply (rule below_trans) |
|
160 |
apply (rule monofun_cfun_arg) |
|
161 |
apply (rule emb_prj_below) |
|
162 |
apply simp |
|
163 |
done |
|
164 |
||
33779 | 165 |
text {* Isomorphism lemmas used internally by the domain package: *} |
166 |
||
167 |
lemma domain_abs_iso: |
|
168 |
fixes abs and rep |
|
169 |
assumes REP: "REP('b) = REP('a)" |
|
170 |
assumes abs_def: "abs \<equiv> (coerce :: 'a \<rightarrow> 'b)" |
|
171 |
assumes rep_def: "rep \<equiv> (coerce :: 'b \<rightarrow> 'a)" |
|
172 |
shows "rep\<cdot>(abs\<cdot>x) = x" |
|
173 |
unfolding abs_def rep_def by (simp add: REP) |
|
174 |
||
175 |
lemma domain_rep_iso: |
|
176 |
fixes abs and rep |
|
177 |
assumes REP: "REP('b) = REP('a)" |
|
178 |
assumes abs_def: "abs \<equiv> (coerce :: 'a \<rightarrow> 'b)" |
|
179 |
assumes rep_def: "rep \<equiv> (coerce :: 'b \<rightarrow> 'a)" |
|
180 |
shows "abs\<cdot>(rep\<cdot>x) = x" |
|
181 |
unfolding abs_def rep_def by (simp add: REP [symmetric]) |
|
182 |
||
35480
7a1f285cad25
domain_isomorphism package proves deflation rules for map functions
huffman
parents:
35479
diff
changeset
|
183 |
lemma deflation_abs_rep: |
7a1f285cad25
domain_isomorphism package proves deflation rules for map functions
huffman
parents:
35479
diff
changeset
|
184 |
fixes abs and rep and d |
35489 | 185 |
assumes abs_iso: "\<And>x. rep\<cdot>(abs\<cdot>x) = x" |
186 |
assumes rep_iso: "\<And>y. abs\<cdot>(rep\<cdot>y) = y" |
|
35480
7a1f285cad25
domain_isomorphism package proves deflation rules for map functions
huffman
parents:
35479
diff
changeset
|
187 |
shows "deflation d \<Longrightarrow> deflation (abs oo d oo rep)" |
35489 | 188 |
by (rule ep_pair.deflation_e_d_p) (simp add: ep_pair.intro assms) |
35480
7a1f285cad25
domain_isomorphism package proves deflation rules for map functions
huffman
parents:
35479
diff
changeset
|
189 |
|
33779 | 190 |
|
33588 | 191 |
subsection {* Proving a subtype is representable *} |
192 |
||
193 |
text {* |
|
194 |
Temporarily relax type constraints for @{term "approx"}, |
|
195 |
@{term emb}, and @{term prj}. |
|
196 |
*} |
|
197 |
||
198 |
setup {* Sign.add_const_constraint |
|
199 |
(@{const_name "approx"}, SOME @{typ "nat \<Rightarrow> 'a::cpo \<rightarrow> 'a"}) *} |
|
200 |
||
201 |
setup {* Sign.add_const_constraint |
|
202 |
(@{const_name emb}, SOME @{typ "'a::pcpo \<rightarrow> udom"}) *} |
|
203 |
||
204 |
setup {* Sign.add_const_constraint |
|
205 |
(@{const_name prj}, SOME @{typ "udom \<rightarrow> 'a::pcpo"}) *} |
|
206 |
||
33679
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
207 |
definition |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
208 |
repdef_approx :: |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
209 |
"('a::pcpo \<Rightarrow> udom) \<Rightarrow> (udom \<Rightarrow> 'a) \<Rightarrow> udom alg_defl \<Rightarrow> nat \<Rightarrow> 'a \<rightarrow> 'a" |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
210 |
where |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
211 |
"repdef_approx Rep Abs t = (\<lambda>i. \<Lambda> x. Abs (cast\<cdot>(approx i\<cdot>t)\<cdot>(Rep x)))" |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
212 |
|
33588 | 213 |
lemma typedef_rep_class: |
214 |
fixes Rep :: "'a::pcpo \<Rightarrow> udom" |
|
215 |
fixes Abs :: "udom \<Rightarrow> 'a::pcpo" |
|
216 |
fixes t :: TypeRep |
|
217 |
assumes type: "type_definition Rep Abs {x. x ::: t}" |
|
218 |
assumes below: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
33679
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
219 |
assumes emb: "emb \<equiv> (\<Lambda> x. Rep x)" |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
220 |
assumes prj: "prj \<equiv> (\<Lambda> x. Abs (cast\<cdot>t\<cdot>x))" |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
221 |
assumes approx: "(approx :: nat \<Rightarrow> 'a \<rightarrow> 'a) \<equiv> repdef_approx Rep Abs t" |
33588 | 222 |
shows "OFCLASS('a, rep_class)" |
223 |
proof |
|
224 |
have adm: "adm (\<lambda>x. x \<in> {x. x ::: t})" |
|
225 |
by (simp add: adm_in_deflation) |
|
226 |
have emb_beta: "\<And>x. emb\<cdot>x = Rep x" |
|
227 |
unfolding emb |
|
228 |
apply (rule beta_cfun) |
|
229 |
apply (rule typedef_cont_Rep [OF type below adm]) |
|
230 |
done |
|
231 |
have prj_beta: "\<And>y. prj\<cdot>y = Abs (cast\<cdot>t\<cdot>y)" |
|
232 |
unfolding prj |
|
233 |
apply (rule beta_cfun) |
|
234 |
apply (rule typedef_cont_Abs [OF type below adm]) |
|
235 |
apply simp_all |
|
236 |
done |
|
33679
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
237 |
have cast_cast_approx: |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
238 |
"\<And>i x. cast\<cdot>t\<cdot>(cast\<cdot>(approx i\<cdot>t)\<cdot>x) = cast\<cdot>(approx i\<cdot>t)\<cdot>x" |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
239 |
apply (rule cast_fixed) |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
240 |
apply (rule subdeflationD) |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
241 |
apply (rule approx.below) |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
242 |
apply (rule cast_in_deflation) |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
243 |
done |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
244 |
have approx': |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
245 |
"approx = (\<lambda>i. \<Lambda>(x::'a). prj\<cdot>(cast\<cdot>(approx i\<cdot>t)\<cdot>(emb\<cdot>x)))" |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
246 |
unfolding approx repdef_approx_def |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
247 |
apply (subst cast_cast_approx [symmetric]) |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
248 |
apply (simp add: prj_beta [symmetric] emb_beta [symmetric]) |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
249 |
done |
33588 | 250 |
have emb_in_deflation: "\<And>x::'a. emb\<cdot>x ::: t" |
251 |
using type_definition.Rep [OF type] |
|
252 |
by (simp add: emb_beta) |
|
253 |
have prj_emb: "\<And>x::'a. prj\<cdot>(emb\<cdot>x) = x" |
|
254 |
unfolding prj_beta |
|
255 |
apply (simp add: cast_fixed [OF emb_in_deflation]) |
|
256 |
apply (simp add: emb_beta type_definition.Rep_inverse [OF type]) |
|
257 |
done |
|
258 |
have emb_prj: "\<And>y. emb\<cdot>(prj\<cdot>y :: 'a) = cast\<cdot>t\<cdot>y" |
|
259 |
unfolding prj_beta emb_beta |
|
260 |
by (simp add: type_definition.Abs_inverse [OF type]) |
|
261 |
show "ep_pair (emb :: 'a \<rightarrow> udom) prj" |
|
262 |
apply default |
|
263 |
apply (simp add: prj_emb) |
|
264 |
apply (simp add: emb_prj cast.below) |
|
265 |
done |
|
266 |
show "chain (approx :: nat \<Rightarrow> 'a \<rightarrow> 'a)" |
|
33679
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
267 |
unfolding approx' by simp |
33588 | 268 |
show "\<And>x::'a. (\<Squnion>i. approx i\<cdot>x) = x" |
33679
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
269 |
unfolding approx' |
33588 | 270 |
apply (simp add: lub_distribs) |
271 |
apply (subst cast_fixed [OF emb_in_deflation]) |
|
272 |
apply (rule prj_emb) |
|
273 |
done |
|
274 |
show "\<And>(i::nat) (x::'a). approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x" |
|
33679
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
275 |
unfolding approx' |
33588 | 276 |
apply simp |
277 |
apply (simp add: emb_prj) |
|
278 |
apply (simp add: cast_cast_approx) |
|
279 |
done |
|
280 |
show "\<And>i::nat. finite {x::'a. approx i\<cdot>x = x}" |
|
281 |
apply (rule_tac B="(\<lambda>x. prj\<cdot>x) ` {x. cast\<cdot>(approx i\<cdot>t)\<cdot>x = x}" |
|
282 |
in finite_subset) |
|
33679
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
283 |
apply (clarsimp simp add: approx') |
33588 | 284 |
apply (drule_tac f="\<lambda>x. emb\<cdot>x" in arg_cong) |
285 |
apply (rule image_eqI) |
|
286 |
apply (rule prj_emb [symmetric]) |
|
287 |
apply (simp add: emb_prj) |
|
288 |
apply (simp add: cast_cast_approx) |
|
289 |
apply (rule finite_imageI) |
|
290 |
apply (simp add: cast_approx_fixed_iff) |
|
291 |
apply (simp add: Collect_conj_eq) |
|
292 |
apply (simp add: finite_fixes_approx) |
|
293 |
done |
|
294 |
qed |
|
295 |
||
296 |
text {* Restore original typing constraints *} |
|
297 |
||
298 |
setup {* Sign.add_const_constraint |
|
299 |
(@{const_name "approx"}, SOME @{typ "nat \<Rightarrow> 'a::profinite \<rightarrow> 'a"}) *} |
|
300 |
||
301 |
setup {* Sign.add_const_constraint |
|
302 |
(@{const_name emb}, SOME @{typ "'a::rep \<rightarrow> udom"}) *} |
|
303 |
||
304 |
setup {* Sign.add_const_constraint |
|
305 |
(@{const_name prj}, SOME @{typ "udom \<rightarrow> 'a::rep"}) *} |
|
306 |
||
307 |
lemma typedef_REP: |
|
308 |
fixes Rep :: "'a::rep \<Rightarrow> udom" |
|
309 |
fixes Abs :: "udom \<Rightarrow> 'a::rep" |
|
310 |
fixes t :: TypeRep |
|
311 |
assumes type: "type_definition Rep Abs {x. x ::: t}" |
|
312 |
assumes below: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
33679
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
313 |
assumes emb: "emb \<equiv> (\<Lambda> x. Rep x)" |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
314 |
assumes prj: "prj \<equiv> (\<Lambda> x. Abs (cast\<cdot>t\<cdot>x))" |
33588 | 315 |
shows "REP('a) = t" |
316 |
proof - |
|
317 |
have adm: "adm (\<lambda>x. x \<in> {x. x ::: t})" |
|
318 |
by (simp add: adm_in_deflation) |
|
319 |
have emb_beta: "\<And>x. emb\<cdot>x = Rep x" |
|
320 |
unfolding emb |
|
321 |
apply (rule beta_cfun) |
|
322 |
apply (rule typedef_cont_Rep [OF type below adm]) |
|
323 |
done |
|
324 |
have prj_beta: "\<And>y. prj\<cdot>y = Abs (cast\<cdot>t\<cdot>y)" |
|
325 |
unfolding prj |
|
326 |
apply (rule beta_cfun) |
|
327 |
apply (rule typedef_cont_Abs [OF type below adm]) |
|
328 |
apply simp_all |
|
329 |
done |
|
330 |
have emb_in_deflation: "\<And>x::'a. emb\<cdot>x ::: t" |
|
331 |
using type_definition.Rep [OF type] |
|
332 |
by (simp add: emb_beta) |
|
333 |
have prj_emb: "\<And>x::'a. prj\<cdot>(emb\<cdot>x) = x" |
|
334 |
unfolding prj_beta |
|
335 |
apply (simp add: cast_fixed [OF emb_in_deflation]) |
|
336 |
apply (simp add: emb_beta type_definition.Rep_inverse [OF type]) |
|
337 |
done |
|
338 |
have emb_prj: "\<And>y. emb\<cdot>(prj\<cdot>y :: 'a) = cast\<cdot>t\<cdot>y" |
|
339 |
unfolding prj_beta emb_beta |
|
340 |
by (simp add: type_definition.Abs_inverse [OF type]) |
|
341 |
show "REP('a) = t" |
|
342 |
apply (rule cast_eq_imp_eq, rule ext_cfun) |
|
343 |
apply (simp add: cast_REP emb_prj) |
|
344 |
done |
|
345 |
qed |
|
346 |
||
33679
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
347 |
lemma adm_mem_Collect_in_deflation: "adm (\<lambda>x. x \<in> {x. x ::: A})" |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
348 |
unfolding mem_Collect_eq by (rule adm_in_deflation) |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
349 |
|
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
350 |
use "Tools/repdef.ML" |
331712879666
automate definition of representable domains from algebraic deflations
huffman
parents:
33589
diff
changeset
|
351 |
|
33588 | 352 |
|
353 |
subsection {* Instances of class @{text rep} *} |
|
354 |
||
355 |
subsubsection {* Universal Domain *} |
|
356 |
||
357 |
text "The Universal Domain itself is trivially representable." |
|
358 |
||
359 |
instantiation udom :: rep |
|
360 |
begin |
|
361 |
||
362 |
definition emb_udom_def [simp]: "emb = (ID :: udom \<rightarrow> udom)" |
|
363 |
definition prj_udom_def [simp]: "prj = (ID :: udom \<rightarrow> udom)" |
|
364 |
||
365 |
instance |
|
366 |
apply (intro_classes) |
|
367 |
apply (simp_all add: ep_pair.intro) |
|
368 |
done |
|
369 |
||
370 |
end |
|
371 |
||
372 |
subsubsection {* Lifted types *} |
|
373 |
||
374 |
instantiation lift :: (countable) rep |
|
375 |
begin |
|
376 |
||
377 |
definition emb_lift_def: |
|
378 |
"emb = udom_emb oo (FLIFT x. Def (to_nat x))" |
|
379 |
||
380 |
definition prj_lift_def: |
|
381 |
"prj = (FLIFT n. if (\<exists>x::'a::countable. n = to_nat x) |
|
382 |
then Def (THE x::'a. n = to_nat x) else \<bottom>) oo udom_prj" |
|
383 |
||
384 |
instance |
|
385 |
apply (intro_classes, unfold emb_lift_def prj_lift_def) |
|
386 |
apply (rule ep_pair_comp [OF _ ep_pair_udom]) |
|
387 |
apply (rule ep_pair.intro) |
|
388 |
apply (case_tac x, simp, simp) |
|
389 |
apply (case_tac y, simp, clarsimp) |
|
390 |
done |
|
391 |
||
392 |
end |
|
393 |
||
394 |
subsubsection {* Representable type constructors *} |
|
395 |
||
396 |
text "Functions between representable types are representable." |
|
397 |
||
398 |
instantiation "->" :: (rep, rep) rep |
|
399 |
begin |
|
400 |
||
401 |
definition emb_cfun_def: "emb = udom_emb oo cfun_map\<cdot>prj\<cdot>emb" |
|
402 |
definition prj_cfun_def: "prj = cfun_map\<cdot>emb\<cdot>prj oo udom_prj" |
|
403 |
||
404 |
instance |
|
405 |
apply (intro_classes, unfold emb_cfun_def prj_cfun_def) |
|
406 |
apply (intro ep_pair_comp ep_pair_cfun_map ep_pair_emb_prj ep_pair_udom) |
|
407 |
done |
|
408 |
||
409 |
end |
|
410 |
||
411 |
text "Strict products of representable types are representable." |
|
412 |
||
413 |
instantiation "**" :: (rep, rep) rep |
|
414 |
begin |
|
415 |
||
416 |
definition emb_sprod_def: "emb = udom_emb oo sprod_map\<cdot>emb\<cdot>emb" |
|
417 |
definition prj_sprod_def: "prj = sprod_map\<cdot>prj\<cdot>prj oo udom_prj" |
|
418 |
||
419 |
instance |
|
420 |
apply (intro_classes, unfold emb_sprod_def prj_sprod_def) |
|
421 |
apply (intro ep_pair_comp ep_pair_sprod_map ep_pair_emb_prj ep_pair_udom) |
|
422 |
done |
|
423 |
||
424 |
end |
|
425 |
||
426 |
text "Strict sums of representable types are representable." |
|
427 |
||
428 |
instantiation "++" :: (rep, rep) rep |
|
429 |
begin |
|
430 |
||
431 |
definition emb_ssum_def: "emb = udom_emb oo ssum_map\<cdot>emb\<cdot>emb" |
|
432 |
definition prj_ssum_def: "prj = ssum_map\<cdot>prj\<cdot>prj oo udom_prj" |
|
433 |
||
434 |
instance |
|
435 |
apply (intro_classes, unfold emb_ssum_def prj_ssum_def) |
|
436 |
apply (intro ep_pair_comp ep_pair_ssum_map ep_pair_emb_prj ep_pair_udom) |
|
437 |
done |
|
438 |
||
439 |
end |
|
440 |
||
441 |
text "Up of a representable type is representable." |
|
442 |
||
443 |
instantiation "u" :: (rep) rep |
|
444 |
begin |
|
445 |
||
446 |
definition emb_u_def: "emb = udom_emb oo u_map\<cdot>emb" |
|
447 |
definition prj_u_def: "prj = u_map\<cdot>prj oo udom_prj" |
|
448 |
||
449 |
instance |
|
450 |
apply (intro_classes, unfold emb_u_def prj_u_def) |
|
451 |
apply (intro ep_pair_comp ep_pair_u_map ep_pair_emb_prj ep_pair_udom) |
|
452 |
done |
|
453 |
||
454 |
end |
|
455 |
||
456 |
text "Cartesian products of representable types are representable." |
|
457 |
||
458 |
instantiation "*" :: (rep, rep) rep |
|
459 |
begin |
|
460 |
||
461 |
definition emb_cprod_def: "emb = udom_emb oo cprod_map\<cdot>emb\<cdot>emb" |
|
462 |
definition prj_cprod_def: "prj = cprod_map\<cdot>prj\<cdot>prj oo udom_prj" |
|
463 |
||
464 |
instance |
|
465 |
apply (intro_classes, unfold emb_cprod_def prj_cprod_def) |
|
466 |
apply (intro ep_pair_comp ep_pair_cprod_map ep_pair_emb_prj ep_pair_udom) |
|
467 |
done |
|
468 |
||
469 |
end |
|
470 |
||
471 |
subsection {* Type combinators *} |
|
472 |
||
473 |
definition |
|
474 |
TypeRep_fun1 :: |
|
475 |
"((udom \<rightarrow> udom) \<rightarrow> ('a \<rightarrow> 'a)) |
|
476 |
\<Rightarrow> (TypeRep \<rightarrow> TypeRep)" |
|
477 |
where |
|
478 |
"TypeRep_fun1 f = |
|
479 |
alg_defl.basis_fun (\<lambda>a. |
|
480 |
alg_defl_principal ( |
|
481 |
Abs_fin_defl (udom_emb oo f\<cdot>(Rep_fin_defl a) oo udom_prj)))" |
|
482 |
||
483 |
definition |
|
484 |
TypeRep_fun2 :: |
|
485 |
"((udom \<rightarrow> udom) \<rightarrow> (udom \<rightarrow> udom) \<rightarrow> ('a \<rightarrow> 'a)) |
|
486 |
\<Rightarrow> (TypeRep \<rightarrow> TypeRep \<rightarrow> TypeRep)" |
|
487 |
where |
|
488 |
"TypeRep_fun2 f = |
|
489 |
alg_defl.basis_fun (\<lambda>a. |
|
490 |
alg_defl.basis_fun (\<lambda>b. |
|
491 |
alg_defl_principal ( |
|
492 |
Abs_fin_defl (udom_emb oo |
|
493 |
f\<cdot>(Rep_fin_defl a)\<cdot>(Rep_fin_defl b) oo udom_prj))))" |
|
494 |
||
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
495 |
definition "cfun_defl = TypeRep_fun2 cfun_map" |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
496 |
definition "ssum_defl = TypeRep_fun2 ssum_map" |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
497 |
definition "sprod_defl = TypeRep_fun2 sprod_map" |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
498 |
definition "cprod_defl = TypeRep_fun2 cprod_map" |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
499 |
definition "u_defl = TypeRep_fun1 u_map" |
33588 | 500 |
|
501 |
lemma Rep_fin_defl_mono: "a \<sqsubseteq> b \<Longrightarrow> Rep_fin_defl a \<sqsubseteq> Rep_fin_defl b" |
|
502 |
unfolding below_fin_defl_def . |
|
503 |
||
504 |
lemma cast_TypeRep_fun1: |
|
505 |
assumes f: "\<And>a. finite_deflation a \<Longrightarrow> finite_deflation (f\<cdot>a)" |
|
506 |
shows "cast\<cdot>(TypeRep_fun1 f\<cdot>A) = udom_emb oo f\<cdot>(cast\<cdot>A) oo udom_prj" |
|
507 |
proof - |
|
508 |
have 1: "\<And>a. finite_deflation (udom_emb oo f\<cdot>(Rep_fin_defl a) oo udom_prj)" |
|
509 |
apply (rule ep_pair.finite_deflation_e_d_p [OF ep_pair_udom]) |
|
510 |
apply (rule f, rule finite_deflation_Rep_fin_defl) |
|
511 |
done |
|
512 |
show ?thesis |
|
513 |
by (induct A rule: alg_defl.principal_induct, simp) |
|
514 |
(simp only: TypeRep_fun1_def |
|
515 |
alg_defl.basis_fun_principal |
|
516 |
alg_defl.basis_fun_mono |
|
517 |
alg_defl.principal_mono |
|
518 |
Abs_fin_defl_mono [OF 1 1] |
|
519 |
monofun_cfun below_refl |
|
520 |
Rep_fin_defl_mono |
|
521 |
cast_alg_defl_principal |
|
522 |
Abs_fin_defl_inverse [unfolded mem_Collect_eq, OF 1]) |
|
523 |
qed |
|
524 |
||
525 |
lemma cast_TypeRep_fun2: |
|
526 |
assumes f: "\<And>a b. finite_deflation a \<Longrightarrow> finite_deflation b \<Longrightarrow> |
|
527 |
finite_deflation (f\<cdot>a\<cdot>b)" |
|
528 |
shows "cast\<cdot>(TypeRep_fun2 f\<cdot>A\<cdot>B) = udom_emb oo f\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj" |
|
529 |
proof - |
|
530 |
have 1: "\<And>a b. finite_deflation |
|
531 |
(udom_emb oo f\<cdot>(Rep_fin_defl a)\<cdot>(Rep_fin_defl b) oo udom_prj)" |
|
532 |
apply (rule ep_pair.finite_deflation_e_d_p [OF ep_pair_udom]) |
|
533 |
apply (rule f, (rule finite_deflation_Rep_fin_defl)+) |
|
534 |
done |
|
535 |
show ?thesis |
|
536 |
by (induct A B rule: alg_defl.principal_induct2, simp, simp) |
|
537 |
(simp only: TypeRep_fun2_def |
|
538 |
alg_defl.basis_fun_principal |
|
539 |
alg_defl.basis_fun_mono |
|
540 |
alg_defl.principal_mono |
|
541 |
Abs_fin_defl_mono [OF 1 1] |
|
542 |
monofun_cfun below_refl |
|
543 |
Rep_fin_defl_mono |
|
544 |
cast_alg_defl_principal |
|
545 |
Abs_fin_defl_inverse [unfolded mem_Collect_eq, OF 1]) |
|
546 |
qed |
|
547 |
||
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
548 |
lemma cast_cfun_defl: |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
549 |
"cast\<cdot>(cfun_defl\<cdot>A\<cdot>B) = udom_emb oo cfun_map\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj" |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
550 |
unfolding cfun_defl_def |
33588 | 551 |
apply (rule cast_TypeRep_fun2) |
552 |
apply (erule (1) finite_deflation_cfun_map) |
|
553 |
done |
|
554 |
||
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
555 |
lemma cast_ssum_defl: |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
556 |
"cast\<cdot>(ssum_defl\<cdot>A\<cdot>B) = udom_emb oo ssum_map\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj" |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
557 |
unfolding ssum_defl_def |
33588 | 558 |
apply (rule cast_TypeRep_fun2) |
559 |
apply (erule (1) finite_deflation_ssum_map) |
|
560 |
done |
|
561 |
||
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
562 |
lemma cast_sprod_defl: |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
563 |
"cast\<cdot>(sprod_defl\<cdot>A\<cdot>B) = udom_emb oo sprod_map\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj" |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
564 |
unfolding sprod_defl_def |
33588 | 565 |
apply (rule cast_TypeRep_fun2) |
566 |
apply (erule (1) finite_deflation_sprod_map) |
|
567 |
done |
|
568 |
||
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
569 |
lemma cast_cprod_defl: |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
570 |
"cast\<cdot>(cprod_defl\<cdot>A\<cdot>B) = udom_emb oo cprod_map\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj" |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
571 |
unfolding cprod_defl_def |
33588 | 572 |
apply (rule cast_TypeRep_fun2) |
573 |
apply (erule (1) finite_deflation_cprod_map) |
|
574 |
done |
|
575 |
||
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
576 |
lemma cast_u_defl: |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
577 |
"cast\<cdot>(u_defl\<cdot>A) = udom_emb oo u_map\<cdot>(cast\<cdot>A) oo udom_prj" |
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
578 |
unfolding u_defl_def |
33588 | 579 |
apply (rule cast_TypeRep_fun1) |
580 |
apply (erule finite_deflation_u_map) |
|
581 |
done |
|
582 |
||
583 |
text {* REP of type constructor = type combinator *} |
|
584 |
||
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
585 |
lemma REP_cfun: "REP('a \<rightarrow> 'b) = cfun_defl\<cdot>REP('a)\<cdot>REP('b)" |
33588 | 586 |
apply (rule cast_eq_imp_eq, rule ext_cfun) |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
587 |
apply (simp add: cast_REP cast_cfun_defl) |
33588 | 588 |
apply (simp add: cfun_map_def) |
589 |
apply (simp only: prj_cfun_def emb_cfun_def) |
|
590 |
apply (simp add: expand_cfun_eq ep_pair.e_eq_iff [OF ep_pair_udom]) |
|
591 |
done |
|
592 |
||
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
593 |
lemma REP_ssum: "REP('a \<oplus> 'b) = ssum_defl\<cdot>REP('a)\<cdot>REP('b)" |
33588 | 594 |
apply (rule cast_eq_imp_eq, rule ext_cfun) |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
595 |
apply (simp add: cast_REP cast_ssum_defl) |
33588 | 596 |
apply (simp add: prj_ssum_def) |
597 |
apply (simp add: emb_ssum_def) |
|
598 |
apply (simp add: ssum_map_map cfcomp1) |
|
599 |
done |
|
600 |
||
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
601 |
lemma REP_sprod: "REP('a \<otimes> 'b) = sprod_defl\<cdot>REP('a)\<cdot>REP('b)" |
33588 | 602 |
apply (rule cast_eq_imp_eq, rule ext_cfun) |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
603 |
apply (simp add: cast_REP cast_sprod_defl) |
33588 | 604 |
apply (simp add: prj_sprod_def) |
605 |
apply (simp add: emb_sprod_def) |
|
606 |
apply (simp add: sprod_map_map cfcomp1) |
|
607 |
done |
|
608 |
||
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
609 |
lemma REP_cprod: "REP('a \<times> 'b) = cprod_defl\<cdot>REP('a)\<cdot>REP('b)" |
33588 | 610 |
apply (rule cast_eq_imp_eq, rule ext_cfun) |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
611 |
apply (simp add: cast_REP cast_cprod_defl) |
33588 | 612 |
apply (simp add: prj_cprod_def) |
613 |
apply (simp add: emb_cprod_def) |
|
614 |
apply (simp add: cprod_map_map cfcomp1) |
|
615 |
done |
|
616 |
||
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
617 |
lemma REP_up: "REP('a u) = u_defl\<cdot>REP('a)" |
33588 | 618 |
apply (rule cast_eq_imp_eq, rule ext_cfun) |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
619 |
apply (simp add: cast_REP cast_u_defl) |
33588 | 620 |
apply (simp add: prj_u_def) |
621 |
apply (simp add: emb_u_def) |
|
622 |
apply (simp add: u_map_map cfcomp1) |
|
623 |
done |
|
624 |
||
625 |
lemmas REP_simps = |
|
626 |
REP_cfun |
|
627 |
REP_ssum |
|
628 |
REP_sprod |
|
629 |
REP_cprod |
|
630 |
REP_up |
|
631 |
||
632 |
subsection {* Isomorphic deflations *} |
|
633 |
||
634 |
definition |
|
635 |
isodefl :: "('a::rep \<rightarrow> 'a) \<Rightarrow> udom alg_defl \<Rightarrow> bool" |
|
636 |
where |
|
637 |
"isodefl d t \<longleftrightarrow> cast\<cdot>t = emb oo d oo prj" |
|
638 |
||
639 |
lemma isodeflI: "(\<And>x. cast\<cdot>t\<cdot>x = emb\<cdot>(d\<cdot>(prj\<cdot>x))) \<Longrightarrow> isodefl d t" |
|
640 |
unfolding isodefl_def by (simp add: ext_cfun) |
|
641 |
||
642 |
lemma cast_isodefl: "isodefl d t \<Longrightarrow> cast\<cdot>t = (\<Lambda> x. emb\<cdot>(d\<cdot>(prj\<cdot>x)))" |
|
643 |
unfolding isodefl_def by (simp add: ext_cfun) |
|
644 |
||
645 |
lemma isodefl_strict: "isodefl d t \<Longrightarrow> d\<cdot>\<bottom> = \<bottom>" |
|
646 |
unfolding isodefl_def |
|
647 |
by (drule cfun_fun_cong [where x="\<bottom>"], simp) |
|
648 |
||
649 |
lemma isodefl_imp_deflation: |
|
650 |
fixes d :: "'a::rep \<rightarrow> 'a" |
|
651 |
assumes "isodefl d t" shows "deflation d" |
|
652 |
proof |
|
653 |
note prems [unfolded isodefl_def, simp] |
|
654 |
fix x :: 'a |
|
655 |
show "d\<cdot>(d\<cdot>x) = d\<cdot>x" |
|
656 |
using cast.idem [of t "emb\<cdot>x"] by simp |
|
657 |
show "d\<cdot>x \<sqsubseteq> x" |
|
658 |
using cast.below [of t "emb\<cdot>x"] by simp |
|
659 |
qed |
|
660 |
||
661 |
lemma isodefl_ID_REP: "isodefl (ID :: 'a \<rightarrow> 'a) REP('a)" |
|
662 |
unfolding isodefl_def by (simp add: cast_REP) |
|
663 |
||
664 |
lemma isodefl_REP_imp_ID: "isodefl (d :: 'a \<rightarrow> 'a) REP('a) \<Longrightarrow> d = ID" |
|
665 |
unfolding isodefl_def |
|
666 |
apply (simp add: cast_REP) |
|
667 |
apply (simp add: expand_cfun_eq) |
|
668 |
apply (rule allI) |
|
669 |
apply (drule_tac x="emb\<cdot>x" in spec) |
|
670 |
apply simp |
|
671 |
done |
|
672 |
||
673 |
lemma isodefl_bottom: "isodefl \<bottom> \<bottom>" |
|
674 |
unfolding isodefl_def by (simp add: expand_cfun_eq) |
|
675 |
||
676 |
lemma adm_isodefl: |
|
677 |
"cont f \<Longrightarrow> cont g \<Longrightarrow> adm (\<lambda>x. isodefl (f x) (g x))" |
|
678 |
unfolding isodefl_def by simp |
|
679 |
||
680 |
lemma isodefl_lub: |
|
681 |
assumes "chain d" and "chain t" |
|
682 |
assumes "\<And>i. isodefl (d i) (t i)" |
|
683 |
shows "isodefl (\<Squnion>i. d i) (\<Squnion>i. t i)" |
|
684 |
using prems unfolding isodefl_def |
|
685 |
by (simp add: contlub_cfun_arg contlub_cfun_fun) |
|
686 |
||
687 |
lemma isodefl_fix: |
|
688 |
assumes "\<And>d t. isodefl d t \<Longrightarrow> isodefl (f\<cdot>d) (g\<cdot>t)" |
|
689 |
shows "isodefl (fix\<cdot>f) (fix\<cdot>g)" |
|
690 |
unfolding fix_def2 |
|
691 |
apply (rule isodefl_lub, simp, simp) |
|
692 |
apply (induct_tac i) |
|
693 |
apply (simp add: isodefl_bottom) |
|
694 |
apply (simp add: prems) |
|
695 |
done |
|
696 |
||
697 |
lemma isodefl_coerce: |
|
698 |
fixes d :: "'a \<rightarrow> 'a" |
|
699 |
assumes REP: "REP('b) = REP('a)" |
|
700 |
shows "isodefl d t \<Longrightarrow> isodefl (coerce oo d oo coerce :: 'b \<rightarrow> 'b) t" |
|
701 |
unfolding isodefl_def |
|
702 |
apply (simp add: expand_cfun_eq) |
|
703 |
apply (simp add: emb_coerce coerce_prj REP) |
|
704 |
done |
|
705 |
||
33779 | 706 |
lemma isodefl_abs_rep: |
707 |
fixes abs and rep and d |
|
708 |
assumes REP: "REP('b) = REP('a)" |
|
709 |
assumes abs_def: "abs \<equiv> (coerce :: 'a \<rightarrow> 'b)" |
|
710 |
assumes rep_def: "rep \<equiv> (coerce :: 'b \<rightarrow> 'a)" |
|
711 |
shows "isodefl d t \<Longrightarrow> isodefl (abs oo d oo rep) t" |
|
712 |
unfolding abs_def rep_def using REP by (rule isodefl_coerce) |
|
713 |
||
33588 | 714 |
lemma isodefl_cfun: |
715 |
"isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow> |
|
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
716 |
isodefl (cfun_map\<cdot>d1\<cdot>d2) (cfun_defl\<cdot>t1\<cdot>t2)" |
33588 | 717 |
apply (rule isodeflI) |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
718 |
apply (simp add: cast_cfun_defl cast_isodefl) |
33588 | 719 |
apply (simp add: emb_cfun_def prj_cfun_def) |
720 |
apply (simp add: cfun_map_map cfcomp1) |
|
721 |
done |
|
722 |
||
723 |
lemma isodefl_ssum: |
|
724 |
"isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow> |
|
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
725 |
isodefl (ssum_map\<cdot>d1\<cdot>d2) (ssum_defl\<cdot>t1\<cdot>t2)" |
33588 | 726 |
apply (rule isodeflI) |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
727 |
apply (simp add: cast_ssum_defl cast_isodefl) |
33588 | 728 |
apply (simp add: emb_ssum_def prj_ssum_def) |
729 |
apply (simp add: ssum_map_map isodefl_strict) |
|
730 |
done |
|
731 |
||
732 |
lemma isodefl_sprod: |
|
733 |
"isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow> |
|
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
734 |
isodefl (sprod_map\<cdot>d1\<cdot>d2) (sprod_defl\<cdot>t1\<cdot>t2)" |
33588 | 735 |
apply (rule isodeflI) |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
736 |
apply (simp add: cast_sprod_defl cast_isodefl) |
33588 | 737 |
apply (simp add: emb_sprod_def prj_sprod_def) |
738 |
apply (simp add: sprod_map_map isodefl_strict) |
|
739 |
done |
|
740 |
||
33786 | 741 |
lemma isodefl_cprod: |
742 |
"isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow> |
|
743 |
isodefl (cprod_map\<cdot>d1\<cdot>d2) (cprod_defl\<cdot>t1\<cdot>t2)" |
|
744 |
apply (rule isodeflI) |
|
745 |
apply (simp add: cast_cprod_defl cast_isodefl) |
|
746 |
apply (simp add: emb_cprod_def prj_cprod_def) |
|
747 |
apply (simp add: cprod_map_map cfcomp1) |
|
748 |
done |
|
749 |
||
33588 | 750 |
lemma isodefl_u: |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
751 |
"isodefl d t \<Longrightarrow> isodefl (u_map\<cdot>d) (u_defl\<cdot>t)" |
33588 | 752 |
apply (rule isodeflI) |
33784
7e434813752f
change naming convention for deflation combinators
huffman
parents:
33779
diff
changeset
|
753 |
apply (simp add: cast_u_defl cast_isodefl) |
33588 | 754 |
apply (simp add: emb_u_def prj_u_def) |
755 |
apply (simp add: u_map_map) |
|
756 |
done |
|
757 |
||
33794
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
758 |
subsection {* Constructing Domain Isomorphisms *} |
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
759 |
|
35475
979019ab92eb
move common functions into new file holcf_library.ML
huffman
parents:
35473
diff
changeset
|
760 |
use "Tools/holcf_library.ML" |
33794
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
761 |
use "Tools/Domain/domain_isomorphism.ML" |
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
762 |
|
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
763 |
setup {* |
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
764 |
fold Domain_Isomorphism.add_type_constructor |
35479
dffffe36344a
store deflation thms for map functions in theory data
huffman
parents:
35475
diff
changeset
|
765 |
[(@{type_name "->"}, @{term cfun_defl}, @{const_name cfun_map}, @{thm REP_cfun}, |
dffffe36344a
store deflation thms for map functions in theory data
huffman
parents:
35475
diff
changeset
|
766 |
@{thm isodefl_cfun}, @{thm cfun_map_ID}, @{thm deflation_cfun_map}), |
33794
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
767 |
|
35479
dffffe36344a
store deflation thms for map functions in theory data
huffman
parents:
35475
diff
changeset
|
768 |
(@{type_name "++"}, @{term ssum_defl}, @{const_name ssum_map}, @{thm REP_ssum}, |
dffffe36344a
store deflation thms for map functions in theory data
huffman
parents:
35475
diff
changeset
|
769 |
@{thm isodefl_ssum}, @{thm ssum_map_ID}, @{thm deflation_ssum_map}), |
33794
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
770 |
|
35479
dffffe36344a
store deflation thms for map functions in theory data
huffman
parents:
35475
diff
changeset
|
771 |
(@{type_name "**"}, @{term sprod_defl}, @{const_name sprod_map}, @{thm REP_sprod}, |
dffffe36344a
store deflation thms for map functions in theory data
huffman
parents:
35475
diff
changeset
|
772 |
@{thm isodefl_sprod}, @{thm sprod_map_ID}, @{thm deflation_sprod_map}), |
33794
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
773 |
|
35479
dffffe36344a
store deflation thms for map functions in theory data
huffman
parents:
35475
diff
changeset
|
774 |
(@{type_name "*"}, @{term cprod_defl}, @{const_name cprod_map}, @{thm REP_cprod}, |
dffffe36344a
store deflation thms for map functions in theory data
huffman
parents:
35475
diff
changeset
|
775 |
@{thm isodefl_cprod}, @{thm cprod_map_ID}, @{thm deflation_cprod_map}), |
33794
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
776 |
|
35479
dffffe36344a
store deflation thms for map functions in theory data
huffman
parents:
35475
diff
changeset
|
777 |
(@{type_name "u"}, @{term u_defl}, @{const_name u_map}, @{thm REP_up}, |
dffffe36344a
store deflation thms for map functions in theory data
huffman
parents:
35475
diff
changeset
|
778 |
@{thm isodefl_u}, @{thm u_map_ID}, @{thm deflation_u_map})] |
33794
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
779 |
*} |
364bc92ba081
set up domain_isomorphism package in Representable.thy
huffman
parents:
33786
diff
changeset
|
780 |
|
33588 | 781 |
end |