changeset 39974 b525988432e9
parent 36452 d37c6eed8117
child 39986 38677db30cad
--- a/src/HOLCF/ex/Domain_Proofs.thy	Tue Oct 05 17:53:00 2010 -0700
+++ b/src/HOLCF/ex/Domain_Proofs.thy	Wed Oct 06 10:49:27 2010 -0700
@@ -8,7 +8,7 @@
 imports HOLCF
-default_sort rep
+default_sort sfp
@@ -28,50 +28,50 @@
 text {* Start with the one-step non-recursive version *}
-  foo_bar_baz_deflF ::
-    "TypeRep \<rightarrow> TypeRep \<times> TypeRep \<times> TypeRep \<rightarrow> TypeRep \<times> TypeRep \<times> TypeRep"
+  foo_bar_baz_sfpF ::
+    "sfp \<rightarrow> sfp \<times> sfp \<times> sfp \<rightarrow> sfp \<times> sfp \<times> sfp"
-  "foo_bar_baz_deflF = (\<Lambda> a. Abs_CFun (\<lambda>(t1, t2, t3). 
-    ( ssum_defl\<cdot>REP(one)\<cdot>(sprod_defl\<cdot>(u_defl\<cdot>a)\<cdot>(u_defl\<cdot>t2))
-    , u_defl\<cdot>(cfun_defl\<cdot>t3\<cdot>REP(tr))
-    , u_defl\<cdot>(cfun_defl\<cdot>(convex_defl\<cdot>t1)\<cdot>REP(tr)))))"
+  "foo_bar_baz_sfpF = (\<Lambda> a. Abs_CFun (\<lambda>(t1, t2, t3). 
+    ( ssum_sfp\<cdot>SFP(one)\<cdot>(sprod_sfp\<cdot>(u_sfp\<cdot>a)\<cdot>(u_sfp\<cdot>t2))
+    , u_sfp\<cdot>(cfun_sfp\<cdot>t3\<cdot>SFP(tr))
+    , u_sfp\<cdot>(cfun_sfp\<cdot>(convex_sfp\<cdot>t1)\<cdot>SFP(tr)))))"
-lemma foo_bar_baz_deflF_beta:
-  "foo_bar_baz_deflF\<cdot>a\<cdot>t =
-    ( ssum_defl\<cdot>REP(one)\<cdot>(sprod_defl\<cdot>(u_defl\<cdot>a)\<cdot>(u_defl\<cdot>(fst (snd t))))
-    , u_defl\<cdot>(cfun_defl\<cdot>(snd (snd t))\<cdot>REP(tr))
-    , u_defl\<cdot>(cfun_defl\<cdot>(convex_defl\<cdot>(fst t))\<cdot>REP(tr)))"
-unfolding foo_bar_baz_deflF_def
+lemma foo_bar_baz_sfpF_beta:
+  "foo_bar_baz_sfpF\<cdot>a\<cdot>t =
+    ( ssum_sfp\<cdot>SFP(one)\<cdot>(sprod_sfp\<cdot>(u_sfp\<cdot>a)\<cdot>(u_sfp\<cdot>(fst (snd t))))
+    , u_sfp\<cdot>(cfun_sfp\<cdot>(snd (snd t))\<cdot>SFP(tr))
+    , u_sfp\<cdot>(cfun_sfp\<cdot>(convex_sfp\<cdot>(fst t))\<cdot>SFP(tr)))"
+unfolding foo_bar_baz_sfpF_def
 by (simp add: split_def)
 text {* Individual type combinators are projected from the fixed point. *}
-definition foo_defl :: "TypeRep \<rightarrow> TypeRep"
-where "foo_defl = (\<Lambda> a. fst (fix\<cdot>(foo_bar_baz_deflF\<cdot>a)))"
+definition foo_sfp :: "sfp \<rightarrow> sfp"
+where "foo_sfp = (\<Lambda> a. fst (fix\<cdot>(foo_bar_baz_sfpF\<cdot>a)))"
-definition bar_defl :: "TypeRep \<rightarrow> TypeRep"
-where "bar_defl = (\<Lambda> a. fst (snd (fix\<cdot>(foo_bar_baz_deflF\<cdot>a))))"
+definition bar_sfp :: "sfp \<rightarrow> sfp"
+where "bar_sfp = (\<Lambda> a. fst (snd (fix\<cdot>(foo_bar_baz_sfpF\<cdot>a))))"
-definition baz_defl :: "TypeRep \<rightarrow> TypeRep"
-where "baz_defl = (\<Lambda> a. snd (snd (fix\<cdot>(foo_bar_baz_deflF\<cdot>a))))"
+definition baz_sfp :: "sfp \<rightarrow> sfp"
+where "baz_sfp = (\<Lambda> a. snd (snd (fix\<cdot>(foo_bar_baz_sfpF\<cdot>a))))"
 lemma defl_apply_thms:
-  "foo_defl\<cdot>a = fst (fix\<cdot>(foo_bar_baz_deflF\<cdot>a))"
-  "bar_defl\<cdot>a = fst (snd (fix\<cdot>(foo_bar_baz_deflF\<cdot>a)))"
-  "baz_defl\<cdot>a = snd (snd (fix\<cdot>(foo_bar_baz_deflF\<cdot>a)))"
-unfolding foo_defl_def bar_defl_def baz_defl_def by simp_all
+  "foo_sfp\<cdot>a = fst (fix\<cdot>(foo_bar_baz_sfpF\<cdot>a))"
+  "bar_sfp\<cdot>a = fst (snd (fix\<cdot>(foo_bar_baz_sfpF\<cdot>a)))"
+  "baz_sfp\<cdot>a = snd (snd (fix\<cdot>(foo_bar_baz_sfpF\<cdot>a)))"
+unfolding foo_sfp_def bar_sfp_def baz_sfp_def by simp_all
 text {* Unfold rules for each combinator. *}
-lemma foo_defl_unfold:
-  "foo_defl\<cdot>a = ssum_defl\<cdot>REP(one)\<cdot>(sprod_defl\<cdot>(u_defl\<cdot>a)\<cdot>(u_defl\<cdot>(bar_defl\<cdot>a)))"
-unfolding defl_apply_thms by (subst fix_eq, simp add: foo_bar_baz_deflF_beta)
+lemma foo_sfp_unfold:
+  "foo_sfp\<cdot>a = ssum_sfp\<cdot>SFP(one)\<cdot>(sprod_sfp\<cdot>(u_sfp\<cdot>a)\<cdot>(u_sfp\<cdot>(bar_sfp\<cdot>a)))"
+unfolding defl_apply_thms by (subst fix_eq, simp add: foo_bar_baz_sfpF_beta)
-lemma bar_defl_unfold: "bar_defl\<cdot>a = u_defl\<cdot>(cfun_defl\<cdot>(baz_defl\<cdot>a)\<cdot>REP(tr))"
-unfolding defl_apply_thms by (subst fix_eq, simp add: foo_bar_baz_deflF_beta)
+lemma bar_sfp_unfold: "bar_sfp\<cdot>a = u_sfp\<cdot>(cfun_sfp\<cdot>(baz_sfp\<cdot>a)\<cdot>SFP(tr))"
+unfolding defl_apply_thms by (subst fix_eq, simp add: foo_bar_baz_sfpF_beta)
-lemma baz_defl_unfold: "baz_defl\<cdot>a = u_defl\<cdot>(cfun_defl\<cdot>(convex_defl\<cdot>(foo_defl\<cdot>a))\<cdot>REP(tr))"
-unfolding defl_apply_thms by (subst fix_eq, simp add: foo_bar_baz_deflF_beta)
+lemma baz_sfp_unfold: "baz_sfp\<cdot>a = u_sfp\<cdot>(cfun_sfp\<cdot>(convex_sfp\<cdot>(foo_sfp\<cdot>a))\<cdot>SFP(tr))"
+unfolding defl_apply_thms by (subst fix_eq, simp add: foo_bar_baz_sfpF_beta)
 text "The automation for the previous steps will be quite similar to
 how the fixrec package works."
@@ -82,28 +82,28 @@
 text {* Use @{text pcpodef} with the appropriate type combinator. *}
-pcpodef (open) 'a foo = "{x. x ::: foo_defl\<cdot>REP('a)}"
-by (simp_all add: adm_in_deflation)
+pcpodef (open) 'a foo = "{x. x ::: foo_sfp\<cdot>SFP('a)}"
+by (simp_all add: adm_in_sfp)
-pcpodef (open) 'a bar = "{x. x ::: bar_defl\<cdot>REP('a)}"
-by (simp_all add: adm_in_deflation)
+pcpodef (open) 'a bar = "{x. x ::: bar_sfp\<cdot>SFP('a)}"
+by (simp_all add: adm_in_sfp)
-pcpodef (open) 'a baz = "{x. x ::: baz_defl\<cdot>REP('a)}"
-by (simp_all add: adm_in_deflation)
+pcpodef (open) 'a baz = "{x. x ::: baz_sfp\<cdot>SFP('a)}"
+by (simp_all add: adm_in_sfp)
 text {* Prove rep instance using lemma @{text typedef_rep_class}. *}
-instantiation foo :: (rep) rep
+instantiation foo :: (sfp) sfp
 definition emb_foo :: "'a foo \<rightarrow> udom"
 where "emb_foo \<equiv> (\<Lambda> x. Rep_foo x)"
 definition prj_foo :: "udom \<rightarrow> 'a foo"
-where "prj_foo \<equiv> (\<Lambda> y. Abs_foo (cast\<cdot>(foo_defl\<cdot>REP('a))\<cdot>y))"
+where "prj_foo \<equiv> (\<Lambda> y. Abs_foo (cast\<cdot>(foo_sfp\<cdot>SFP('a))\<cdot>y))"
-definition approx_foo :: "nat \<Rightarrow> 'a foo \<rightarrow> 'a foo"
-where "approx_foo \<equiv> repdef_approx Rep_foo Abs_foo (foo_defl\<cdot>REP('a))"
+definition sfp_foo :: "'a foo itself \<Rightarrow> sfp"
+where "sfp_foo \<equiv> \<lambda>a. foo_sfp\<cdot>SFP('a)"
 apply (rule typedef_rep_class)
@@ -111,22 +111,22 @@
 apply (rule below_foo_def)
 apply (rule emb_foo_def)
 apply (rule prj_foo_def)
-apply (rule approx_foo_def)
+apply (rule sfp_foo_def)
-instantiation bar :: (rep) rep
+instantiation bar :: (sfp) sfp
 definition emb_bar :: "'a bar \<rightarrow> udom"
 where "emb_bar \<equiv> (\<Lambda> x. Rep_bar x)"
 definition prj_bar :: "udom \<rightarrow> 'a bar"
-where "prj_bar \<equiv> (\<Lambda> y. Abs_bar (cast\<cdot>(bar_defl\<cdot>REP('a))\<cdot>y))"
+where "prj_bar \<equiv> (\<Lambda> y. Abs_bar (cast\<cdot>(bar_sfp\<cdot>SFP('a))\<cdot>y))"
-definition approx_bar :: "nat \<Rightarrow> 'a bar \<rightarrow> 'a bar"
-where "approx_bar \<equiv> repdef_approx Rep_bar Abs_bar (bar_defl\<cdot>REP('a))"
+definition sfp_bar :: "'a bar itself \<Rightarrow> sfp"
+where "sfp_bar \<equiv> \<lambda>a. bar_sfp\<cdot>SFP('a)"
 apply (rule typedef_rep_class)
@@ -134,22 +134,22 @@
 apply (rule below_bar_def)
 apply (rule emb_bar_def)
 apply (rule prj_bar_def)
-apply (rule approx_bar_def)
+apply (rule sfp_bar_def)
-instantiation baz :: (rep) rep
+instantiation baz :: (sfp) sfp
 definition emb_baz :: "'a baz \<rightarrow> udom"
 where "emb_baz \<equiv> (\<Lambda> x. Rep_baz x)"
 definition prj_baz :: "udom \<rightarrow> 'a baz"
-where "prj_baz \<equiv> (\<Lambda> y. Abs_baz (cast\<cdot>(baz_defl\<cdot>REP('a))\<cdot>y))"
+where "prj_baz \<equiv> (\<Lambda> y. Abs_baz (cast\<cdot>(baz_sfp\<cdot>SFP('a))\<cdot>y))"
-definition approx_baz :: "nat \<Rightarrow> 'a baz \<rightarrow> 'a baz"
-where "approx_baz \<equiv> repdef_approx Rep_baz Abs_baz (baz_defl\<cdot>REP('a))"
+definition sfp_baz :: "'a baz itself \<Rightarrow> sfp"
+where "sfp_baz \<equiv> \<lambda>a. baz_sfp\<cdot>SFP('a)"
 apply (rule typedef_rep_class)
@@ -157,50 +157,44 @@
 apply (rule below_baz_def)
 apply (rule emb_baz_def)
 apply (rule prj_baz_def)
-apply (rule approx_baz_def)
+apply (rule sfp_baz_def)
-text {* Prove REP rules using lemma @{text typedef_REP}. *}
+text {* Prove SFP rules using lemma @{text typedef_SFP}. *}
-lemma REP_foo: "REP('a foo) = foo_defl\<cdot>REP('a)"
-apply (rule typedef_REP)
-apply (rule type_definition_foo)
-apply (rule below_foo_def)
-apply (rule emb_foo_def)
-apply (rule prj_foo_def)
+lemma SFP_foo: "SFP('a foo) = foo_sfp\<cdot>SFP('a)"
+apply (rule typedef_SFP)
+apply (rule sfp_foo_def)
-lemma REP_bar: "REP('a bar) = bar_defl\<cdot>REP('a)"
-apply (rule typedef_REP)
-apply (rule type_definition_bar)
-apply (rule below_bar_def)
-apply (rule emb_bar_def)
-apply (rule prj_bar_def)
+lemma SFP_bar: "SFP('a bar) = bar_sfp\<cdot>SFP('a)"
+apply (rule typedef_SFP)
+apply (rule sfp_bar_def)
+lemma SFP_baz: "SFP('a baz) = baz_sfp\<cdot>SFP('a)"
+apply (rule typedef_SFP)
+apply (rule sfp_baz_def)
-lemma REP_baz: "REP('a baz) = baz_defl\<cdot>REP('a)"
-apply (rule typedef_REP)
-apply (rule type_definition_baz)
-apply (rule below_baz_def)
-apply (rule emb_baz_def)
-apply (rule prj_baz_def)
+text {* Prove SFP equations using type combinator unfold lemmas. *}
-text {* Prove REP equations using type combinator unfold lemmas. *}
+lemmas SFP_simps =
+  SFP_ssum SFP_sprod SFP_u SFP_cfun
-lemma REP_foo': "REP('a foo) = REP(one \<oplus> 'a\<^sub>\<bottom> \<otimes> ('a bar)\<^sub>\<bottom>)"
-unfolding REP_foo REP_bar REP_baz REP_simps
-by (rule foo_defl_unfold)
+lemma SFP_foo': "SFP('a foo) = SFP(one \<oplus> 'a\<^sub>\<bottom> \<otimes> ('a bar)\<^sub>\<bottom>)"
+unfolding SFP_foo SFP_bar SFP_baz SFP_simps
+by (rule foo_sfp_unfold)
-lemma REP_bar': "REP('a bar) = REP(('a baz \<rightarrow> tr)\<^sub>\<bottom>)"
-unfolding REP_foo REP_bar REP_baz REP_simps
-by (rule bar_defl_unfold)
+lemma SFP_bar': "SFP('a bar) = SFP(('a baz \<rightarrow> tr)\<^sub>\<bottom>)"
+unfolding SFP_foo SFP_bar SFP_baz SFP_simps
+by (rule bar_sfp_unfold)
-lemma REP_baz': "REP('a baz) = REP(('a foo convex_pd \<rightarrow> tr)\<^sub>\<bottom>)"
-unfolding REP_foo REP_bar REP_baz REP_simps REP_convex
-by (rule baz_defl_unfold)
+lemma SFP_baz': "SFP('a baz) = SFP(('a foo convex_pd \<rightarrow> tr)\<^sub>\<bottom>)"
+unfolding SFP_foo SFP_bar SFP_baz SFP_simps SFP_convex
+by (rule baz_sfp_unfold)
@@ -229,36 +223,36 @@
 text {* Prove isomorphism rules. *}
 lemma foo_abs_iso: "foo_rep\<cdot>(foo_abs\<cdot>x) = x"
-by (rule domain_abs_iso [OF REP_foo' foo_abs_def foo_rep_def])
+by (rule domain_abs_iso [OF SFP_foo' foo_abs_def foo_rep_def])
 lemma foo_rep_iso: "foo_abs\<cdot>(foo_rep\<cdot>x) = x"
-by (rule domain_rep_iso [OF REP_foo' foo_abs_def foo_rep_def])
+by (rule domain_rep_iso [OF SFP_foo' foo_abs_def foo_rep_def])
 lemma bar_abs_iso: "bar_rep\<cdot>(bar_abs\<cdot>x) = x"
-by (rule domain_abs_iso [OF REP_bar' bar_abs_def bar_rep_def])
+by (rule domain_abs_iso [OF SFP_bar' bar_abs_def bar_rep_def])
 lemma bar_rep_iso: "bar_abs\<cdot>(bar_rep\<cdot>x) = x"
-by (rule domain_rep_iso [OF REP_bar' bar_abs_def bar_rep_def])
+by (rule domain_rep_iso [OF SFP_bar' bar_abs_def bar_rep_def])
 lemma baz_abs_iso: "baz_rep\<cdot>(baz_abs\<cdot>x) = x"
-by (rule domain_abs_iso [OF REP_baz' baz_abs_def baz_rep_def])
+by (rule domain_abs_iso [OF SFP_baz' baz_abs_def baz_rep_def])
 lemma baz_rep_iso: "baz_abs\<cdot>(baz_rep\<cdot>x) = x"
-by (rule domain_rep_iso [OF REP_baz' baz_abs_def baz_rep_def])
+by (rule domain_rep_iso [OF SFP_baz' baz_abs_def baz_rep_def])
 text {* Prove isodefl rules using @{text isodefl_coerce}. *}
 lemma isodefl_foo_abs:
   "isodefl d t \<Longrightarrow> isodefl (foo_abs oo d oo foo_rep) t"
-by (rule isodefl_abs_rep [OF REP_foo' foo_abs_def foo_rep_def])
+by (rule isodefl_abs_rep [OF SFP_foo' foo_abs_def foo_rep_def])
 lemma isodefl_bar_abs:
   "isodefl d t \<Longrightarrow> isodefl (bar_abs oo d oo bar_rep) t"
-by (rule isodefl_abs_rep [OF REP_bar' bar_abs_def bar_rep_def])
+by (rule isodefl_abs_rep [OF SFP_bar' bar_abs_def bar_rep_def])
 lemma isodefl_baz_abs:
   "isodefl d t \<Longrightarrow> isodefl (baz_abs oo d oo baz_rep) t"
-by (rule isodefl_abs_rep [OF REP_baz' baz_abs_def baz_rep_def])
+by (rule isodefl_abs_rep [OF SFP_baz' baz_abs_def baz_rep_def])
@@ -322,15 +316,15 @@
 lemma isodefl_foo_bar_baz:
   assumes isodefl_d: "isodefl d t"
-  "isodefl (foo_map\<cdot>d) (foo_defl\<cdot>t) \<and>
-  isodefl (bar_map\<cdot>d) (bar_defl\<cdot>t) \<and>
-  isodefl (baz_map\<cdot>d) (baz_defl\<cdot>t)"
+  "isodefl (foo_map\<cdot>d) (foo_sfp\<cdot>t) \<and>
+  isodefl (bar_map\<cdot>d) (bar_sfp\<cdot>t) \<and>
+  isodefl (baz_map\<cdot>d) (baz_sfp\<cdot>t)"
 unfolding map_apply_thms defl_apply_thms
  apply (rule parallel_fix_ind)
    apply (intro adm_conj adm_isodefl cont2cont_fst cont2cont_snd cont_id)
   apply (simp only: fst_strict snd_strict isodefl_bottom simp_thms)
  apply (simp only: foo_bar_baz_mapF_beta
-                   foo_bar_baz_deflF_beta
+                   foo_bar_baz_sfpF_beta
                    fst_conv snd_conv)
  apply (elim conjE)
  apply (intro
@@ -338,7 +332,7 @@
-  isodefl_ssum isodefl_sprod isodefl_ID_REP
+  isodefl_ssum isodefl_sprod isodefl_ID_SFP
   isodefl_u isodefl_convex isodefl_cfun
@@ -349,27 +343,27 @@
 lemmas isodefl_bar = isodefl_foo_bar_baz [THEN conjunct2, THEN conjunct1]
 lemmas isodefl_baz = isodefl_foo_bar_baz [THEN conjunct2, THEN conjunct2]
-text {* Prove map ID lemmas, using isodefl_REP_imp_ID *}
+text {* Prove map ID lemmas, using isodefl_SFP_imp_ID *}
 lemma foo_map_ID: "foo_map\<cdot>ID = ID"
-apply (rule isodefl_REP_imp_ID)
-apply (subst REP_foo)
+apply (rule isodefl_SFP_imp_ID)
+apply (subst SFP_foo)
 apply (rule isodefl_foo)
-apply (rule isodefl_ID_REP)
+apply (rule isodefl_ID_SFP)
 lemma bar_map_ID: "bar_map\<cdot>ID = ID"
-apply (rule isodefl_REP_imp_ID)
-apply (subst REP_bar)
+apply (rule isodefl_SFP_imp_ID)
+apply (subst SFP_bar)
 apply (rule isodefl_bar)
-apply (rule isodefl_ID_REP)
+apply (rule isodefl_ID_SFP)
 lemma baz_map_ID: "baz_map\<cdot>ID = ID"
-apply (rule isodefl_REP_imp_ID)
-apply (subst REP_baz)
+apply (rule isodefl_SFP_imp_ID)
+apply (subst SFP_baz)
 apply (rule isodefl_baz)
-apply (rule isodefl_ID_REP)
+apply (rule isodefl_ID_SFP)