src/HOL/HOLCF/Representable.thy
changeset 41436 480978f80eae
parent 41297 01b2de947cff
child 41437 5bc117c382ec
equal deleted inserted replaced
41435:12585dfb86fe 41436:480978f80eae
    32   assumes cast_liftdefl: "cast\<cdot>(liftdefl TYPE('a)) = liftemb oo liftprj"
    32   assumes cast_liftdefl: "cast\<cdot>(liftdefl TYPE('a)) = liftemb oo liftprj"
    33 
    33 
    34 syntax "_LIFTDEFL" :: "type \<Rightarrow> logic"  ("(1LIFTDEFL/(1'(_')))")
    34 syntax "_LIFTDEFL" :: "type \<Rightarrow> logic"  ("(1LIFTDEFL/(1'(_')))")
    35 translations "LIFTDEFL('t)" \<rightleftharpoons> "CONST liftdefl TYPE('t)"
    35 translations "LIFTDEFL('t)" \<rightleftharpoons> "CONST liftdefl TYPE('t)"
    36 
    36 
    37 definition pdefl :: "udom defl \<rightarrow> udom u defl"
    37 definition liftdefl_of :: "udom defl \<rightarrow> udom u defl"
    38   where "pdefl = defl_fun1 ID ID u_map"
    38   where "liftdefl_of = defl_fun1 ID ID u_map"
    39 
    39 
    40 lemma cast_pdefl: "cast\<cdot>(pdefl\<cdot>t) = u_map\<cdot>(cast\<cdot>t)"
    40 lemma cast_liftdefl_of: "cast\<cdot>(liftdefl_of\<cdot>t) = u_map\<cdot>(cast\<cdot>t)"
    41 by (simp add: pdefl_def cast_defl_fun1 ep_pair_def finite_deflation_u_map)
    41 by (simp add: liftdefl_of_def cast_defl_fun1 ep_pair_def finite_deflation_u_map)
    42 
    42 
    43 class "domain" = predomain_syn + pcpo +
    43 class "domain" = predomain_syn + pcpo +
    44   fixes emb :: "'a \<rightarrow> udom"
    44   fixes emb :: "'a \<rightarrow> udom"
    45   fixes prj :: "udom \<rightarrow> 'a"
    45   fixes prj :: "udom \<rightarrow> 'a"
    46   fixes defl :: "'a itself \<Rightarrow> udom defl"
    46   fixes defl :: "'a itself \<Rightarrow> udom defl"
    47   assumes ep_pair_emb_prj: "ep_pair emb prj"
    47   assumes ep_pair_emb_prj: "ep_pair emb prj"
    48   assumes cast_DEFL: "cast\<cdot>(defl TYPE('a)) = emb oo prj"
    48   assumes cast_DEFL: "cast\<cdot>(defl TYPE('a)) = emb oo prj"
    49   assumes liftemb_eq: "liftemb = u_map\<cdot>emb"
    49   assumes liftemb_eq: "liftemb = u_map\<cdot>emb"
    50   assumes liftprj_eq: "liftprj = u_map\<cdot>prj"
    50   assumes liftprj_eq: "liftprj = u_map\<cdot>prj"
    51   assumes liftdefl_eq: "liftdefl TYPE('a) = pdefl\<cdot>(defl TYPE('a))"
    51   assumes liftdefl_eq: "liftdefl TYPE('a) = liftdefl_of\<cdot>(defl TYPE('a))"
    52 
    52 
    53 syntax "_DEFL" :: "type \<Rightarrow> logic"  ("(1DEFL/(1'(_')))")
    53 syntax "_DEFL" :: "type \<Rightarrow> logic"  ("(1DEFL/(1'(_')))")
    54 translations "DEFL('t)" \<rightleftharpoons> "CONST defl TYPE('t)"
    54 translations "DEFL('t)" \<rightleftharpoons> "CONST defl TYPE('t)"
    55 
    55 
    56 instance "domain" \<subseteq> predomain
    56 instance "domain" \<subseteq> predomain
    58   show "ep_pair liftemb (liftprj::udom\<^sub>\<bottom> \<rightarrow> 'a\<^sub>\<bottom>)"
    58   show "ep_pair liftemb (liftprj::udom\<^sub>\<bottom> \<rightarrow> 'a\<^sub>\<bottom>)"
    59     unfolding liftemb_eq liftprj_eq
    59     unfolding liftemb_eq liftprj_eq
    60     by (intro ep_pair_u_map ep_pair_emb_prj)
    60     by (intro ep_pair_u_map ep_pair_emb_prj)
    61   show "cast\<cdot>LIFTDEFL('a) = liftemb oo (liftprj::udom\<^sub>\<bottom> \<rightarrow> 'a\<^sub>\<bottom>)"
    61   show "cast\<cdot>LIFTDEFL('a) = liftemb oo (liftprj::udom\<^sub>\<bottom> \<rightarrow> 'a\<^sub>\<bottom>)"
    62     unfolding liftemb_eq liftprj_eq liftdefl_eq
    62     unfolding liftemb_eq liftprj_eq liftdefl_eq
    63     by (simp add: cast_pdefl cast_DEFL u_map_oo)
    63     by (simp add: cast_liftdefl_of cast_DEFL u_map_oo)
    64 qed
    64 qed
    65 
    65 
    66 text {*
    66 text {*
    67   Constants @{const liftemb} and @{const liftprj} imply class predomain.
    67   Constants @{const liftemb} and @{const liftprj} imply class predomain.
    68 *}
    68 *}
   227 
   227 
   228 definition
   228 definition
   229   "(liftprj :: udom u \<rightarrow> udom u) = u_map\<cdot>prj"
   229   "(liftprj :: udom u \<rightarrow> udom u) = u_map\<cdot>prj"
   230 
   230 
   231 definition
   231 definition
   232   "liftdefl (t::udom itself) = pdefl\<cdot>DEFL(udom)"
   232   "liftdefl (t::udom itself) = liftdefl_of\<cdot>DEFL(udom)"
   233 
   233 
   234 instance proof
   234 instance proof
   235   show "ep_pair emb (prj :: udom \<rightarrow> udom)"
   235   show "ep_pair emb (prj :: udom \<rightarrow> udom)"
   236     by (simp add: ep_pair.intro)
   236     by (simp add: ep_pair.intro)
   237   show "cast\<cdot>DEFL(udom) = emb oo (prj :: udom \<rightarrow> udom)"
   237   show "cast\<cdot>DEFL(udom) = emb oo (prj :: udom \<rightarrow> udom)"
   269 
   269 
   270 definition
   270 definition
   271   "(liftprj :: udom u \<rightarrow> 'a u u) = u_map\<cdot>prj"
   271   "(liftprj :: udom u \<rightarrow> 'a u u) = u_map\<cdot>prj"
   272 
   272 
   273 definition
   273 definition
   274   "liftdefl (t::'a u itself) = pdefl\<cdot>DEFL('a u)"
   274   "liftdefl (t::'a u itself) = liftdefl_of\<cdot>DEFL('a u)"
   275 
   275 
   276 instance proof
   276 instance proof
   277   show "ep_pair emb (prj :: udom \<rightarrow> 'a u)"
   277   show "ep_pair emb (prj :: udom \<rightarrow> 'a u)"
   278     unfolding emb_u_def prj_u_def
   278     unfolding emb_u_def prj_u_def
   279     by (intro ep_pair_comp ep_pair_u predomain_ep)
   279     by (intro ep_pair_comp ep_pair_u predomain_ep)
   306 
   306 
   307 definition
   307 definition
   308   "(liftprj :: udom u \<rightarrow> ('a \<rightarrow>! 'b) u) = u_map\<cdot>prj"
   308   "(liftprj :: udom u \<rightarrow> ('a \<rightarrow>! 'b) u) = u_map\<cdot>prj"
   309 
   309 
   310 definition
   310 definition
   311   "liftdefl (t::('a \<rightarrow>! 'b) itself) = pdefl\<cdot>DEFL('a \<rightarrow>! 'b)"
   311   "liftdefl (t::('a \<rightarrow>! 'b) itself) = liftdefl_of\<cdot>DEFL('a \<rightarrow>! 'b)"
   312 
   312 
   313 instance proof
   313 instance proof
   314   show "ep_pair emb (prj :: udom \<rightarrow> 'a \<rightarrow>! 'b)"
   314   show "ep_pair emb (prj :: udom \<rightarrow> 'a \<rightarrow>! 'b)"
   315     unfolding emb_sfun_def prj_sfun_def
   315     unfolding emb_sfun_def prj_sfun_def
   316     by (intro ep_pair_comp ep_pair_sfun ep_pair_sfun_map ep_pair_emb_prj)
   316     by (intro ep_pair_comp ep_pair_sfun ep_pair_sfun_map ep_pair_emb_prj)
   344 
   344 
   345 definition
   345 definition
   346   "(liftprj :: udom u \<rightarrow> ('a \<rightarrow> 'b) u) = u_map\<cdot>prj"
   346   "(liftprj :: udom u \<rightarrow> ('a \<rightarrow> 'b) u) = u_map\<cdot>prj"
   347 
   347 
   348 definition
   348 definition
   349   "liftdefl (t::('a \<rightarrow> 'b) itself) = pdefl\<cdot>DEFL('a \<rightarrow> 'b)"
   349   "liftdefl (t::('a \<rightarrow> 'b) itself) = liftdefl_of\<cdot>DEFL('a \<rightarrow> 'b)"
   350 
   350 
   351 instance proof
   351 instance proof
   352   have "ep_pair encode_cfun decode_cfun"
   352   have "ep_pair encode_cfun decode_cfun"
   353     by (rule ep_pair.intro, simp_all)
   353     by (rule ep_pair.intro, simp_all)
   354   thus "ep_pair emb (prj :: udom \<rightarrow> 'a \<rightarrow> 'b)"
   354   thus "ep_pair emb (prj :: udom \<rightarrow> 'a \<rightarrow> 'b)"
   384 
   384 
   385 definition
   385 definition
   386   "(liftprj :: udom u \<rightarrow> ('a \<otimes> 'b) u) = u_map\<cdot>prj"
   386   "(liftprj :: udom u \<rightarrow> ('a \<otimes> 'b) u) = u_map\<cdot>prj"
   387 
   387 
   388 definition
   388 definition
   389   "liftdefl (t::('a \<otimes> 'b) itself) = pdefl\<cdot>DEFL('a \<otimes> 'b)"
   389   "liftdefl (t::('a \<otimes> 'b) itself) = liftdefl_of\<cdot>DEFL('a \<otimes> 'b)"
   390 
   390 
   391 instance proof
   391 instance proof
   392   show "ep_pair emb (prj :: udom \<rightarrow> 'a \<otimes> 'b)"
   392   show "ep_pair emb (prj :: udom \<rightarrow> 'a \<otimes> 'b)"
   393     unfolding emb_sprod_def prj_sprod_def
   393     unfolding emb_sprod_def prj_sprod_def
   394     by (intro ep_pair_comp ep_pair_sprod ep_pair_sprod_map ep_pair_emb_prj)
   394     by (intro ep_pair_comp ep_pair_sprod ep_pair_sprod_map ep_pair_emb_prj)
   473     unfolding prj_prod_def liftprj_prod_def liftprj_eq
   473     unfolding prj_prod_def liftprj_prod_def liftprj_eq
   474     unfolding encode_prod_u_def decode_prod_u_def
   474     unfolding encode_prod_u_def decode_prod_u_def
   475     apply (rule cfun_eqI, case_tac x, simp)
   475     apply (rule cfun_eqI, case_tac x, simp)
   476     apply (rename_tac y, case_tac "prod_prj\<cdot>y", simp)
   476     apply (rename_tac y, case_tac "prod_prj\<cdot>y", simp)
   477     done
   477     done
   478   show 5: "LIFTDEFL('a \<times> 'b) = pdefl\<cdot>DEFL('a \<times> 'b)"
   478   show 5: "LIFTDEFL('a \<times> 'b) = liftdefl_of\<cdot>DEFL('a \<times> 'b)"
   479     by (rule cast_eq_imp_eq)
   479     by (rule cast_eq_imp_eq)
   480       (simp add: cast_liftdefl cast_pdefl cast_DEFL 2 3 4 u_map_oo)
   480       (simp add: cast_liftdefl cast_liftdefl_of cast_DEFL 2 3 4 u_map_oo)
   481 qed
   481 qed
   482 
   482 
   483 end
   483 end
   484 
   484 
   485 lemma DEFL_prod:
   485 lemma DEFL_prod:
   510 
   510 
   511 definition
   511 definition
   512   "(liftprj :: udom u \<rightarrow> unit u) = u_map\<cdot>prj"
   512   "(liftprj :: udom u \<rightarrow> unit u) = u_map\<cdot>prj"
   513 
   513 
   514 definition
   514 definition
   515   "liftdefl (t::unit itself) = pdefl\<cdot>DEFL(unit)"
   515   "liftdefl (t::unit itself) = liftdefl_of\<cdot>DEFL(unit)"
   516 
   516 
   517 instance proof
   517 instance proof
   518   show "ep_pair emb (prj :: udom \<rightarrow> unit)"
   518   show "ep_pair emb (prj :: udom \<rightarrow> unit)"
   519     unfolding emb_unit_def prj_unit_def
   519     unfolding emb_unit_def prj_unit_def
   520     by (simp add: ep_pair.intro)
   520     by (simp add: ep_pair.intro)
   588 
   588 
   589 definition
   589 definition
   590   "(liftprj :: udom u \<rightarrow> ('a \<oplus> 'b) u) = u_map\<cdot>prj"
   590   "(liftprj :: udom u \<rightarrow> ('a \<oplus> 'b) u) = u_map\<cdot>prj"
   591 
   591 
   592 definition
   592 definition
   593   "liftdefl (t::('a \<oplus> 'b) itself) = pdefl\<cdot>DEFL('a \<oplus> 'b)"
   593   "liftdefl (t::('a \<oplus> 'b) itself) = liftdefl_of\<cdot>DEFL('a \<oplus> 'b)"
   594 
   594 
   595 instance proof
   595 instance proof
   596   show "ep_pair emb (prj :: udom \<rightarrow> 'a \<oplus> 'b)"
   596   show "ep_pair emb (prj :: udom \<rightarrow> 'a \<oplus> 'b)"
   597     unfolding emb_ssum_def prj_ssum_def
   597     unfolding emb_ssum_def prj_ssum_def
   598     by (intro ep_pair_comp ep_pair_ssum ep_pair_ssum_map ep_pair_emb_prj)
   598     by (intro ep_pair_comp ep_pair_ssum ep_pair_ssum_map ep_pair_emb_prj)
   626 
   626 
   627 definition
   627 definition
   628   "(liftprj :: udom u \<rightarrow> 'a lift u) = u_map\<cdot>prj"
   628   "(liftprj :: udom u \<rightarrow> 'a lift u) = u_map\<cdot>prj"
   629 
   629 
   630 definition
   630 definition
   631   "liftdefl (t::'a lift itself) = pdefl\<cdot>DEFL('a lift)"
   631   "liftdefl (t::'a lift itself) = liftdefl_of\<cdot>DEFL('a lift)"
   632 
   632 
   633 instance proof
   633 instance proof
   634   note [simp] = cont_Rep_lift cont_Abs_lift Rep_lift_inverse Abs_lift_inverse
   634   note [simp] = cont_Rep_lift cont_Abs_lift Rep_lift_inverse Abs_lift_inverse
   635   have "ep_pair (\<Lambda>(x::'a lift). Rep_lift x) (\<Lambda> y. Abs_lift y)"
   635   have "ep_pair (\<Lambda>(x::'a lift). Rep_lift x) (\<Lambda> y. Abs_lift y)"
   636     by (simp add: ep_pair_def)
   636     by (simp add: ep_pair_def)