238 Fixrec.add_matchers |
238 Fixrec.add_matchers |
239 [ (@{const_name Inl}, @{const_name match_Inl}), |
239 [ (@{const_name Inl}, @{const_name match_Inl}), |
240 (@{const_name Inr}, @{const_name match_Inr}) ] |
240 (@{const_name Inr}, @{const_name match_Inr}) ] |
241 *} |
241 *} |
242 |
242 |
|
243 subsection {* Disjoint sum is a predomain *} |
|
244 |
|
245 definition |
|
246 "encode_sum_u = |
|
247 (\<Lambda>(up\<cdot>x). case x of Inl a \<Rightarrow> sinl\<cdot>(up\<cdot>a) | Inr b \<Rightarrow> sinr\<cdot>(up\<cdot>b))" |
|
248 |
|
249 definition |
|
250 "decode_sum_u = sscase\<cdot>(\<Lambda>(up\<cdot>a). up\<cdot>(Inl a))\<cdot>(\<Lambda>(up\<cdot>b). up\<cdot>(Inr b))" |
|
251 |
|
252 lemma decode_encode_sum_u [simp]: "decode_sum_u\<cdot>(encode_sum_u\<cdot>x) = x" |
|
253 unfolding decode_sum_u_def encode_sum_u_def |
|
254 by (case_tac x, simp, rename_tac y, case_tac y, simp_all) |
|
255 |
|
256 lemma encode_decode_sum_u [simp]: "encode_sum_u\<cdot>(decode_sum_u\<cdot>x) = x" |
|
257 unfolding decode_sum_u_def encode_sum_u_def |
|
258 apply (case_tac x, simp) |
|
259 apply (rename_tac a, case_tac a, simp, simp) |
|
260 apply (rename_tac b, case_tac b, simp, simp) |
|
261 done |
|
262 |
|
263 instantiation sum :: (predomain, predomain) predomain |
|
264 begin |
|
265 |
|
266 definition |
|
267 "liftemb = (udom_emb ssum_approx oo ssum_map\<cdot>emb\<cdot>emb) oo encode_sum_u" |
|
268 |
|
269 definition |
|
270 "liftprj = |
|
271 decode_sum_u oo (ssum_map\<cdot>prj\<cdot>prj oo udom_prj ssum_approx)" |
|
272 |
|
273 definition |
|
274 "liftdefl (t::('a + 'b) itself) = ssum_defl\<cdot>DEFL('a u)\<cdot>DEFL('b u)" |
|
275 |
|
276 instance proof |
|
277 show "ep_pair liftemb (liftprj :: udom \<rightarrow> ('a + 'b) u)" |
|
278 unfolding liftemb_sum_def liftprj_sum_def |
|
279 apply (rule ep_pair_comp) |
|
280 apply (rule ep_pair.intro, simp, simp) |
|
281 apply (rule ep_pair_comp) |
|
282 apply (intro ep_pair_ssum_map ep_pair_emb_prj) |
|
283 apply (rule ep_pair_udom [OF ssum_approx]) |
|
284 done |
|
285 show "cast\<cdot>LIFTDEFL('a + 'b) = liftemb oo (liftprj :: udom \<rightarrow> ('a + 'b) u)" |
|
286 unfolding liftemb_sum_def liftprj_sum_def liftdefl_sum_def |
|
287 by (simp add: cast_ssum_defl cast_DEFL cfcomp1 ssum_map_map) |
|
288 qed |
|
289 |
243 end |
290 end |
|
291 |
|
292 end |