src/HOLCF/Ssum.thy
changeset 25882 c58e380d9f7d
parent 25827 c2adeb1bae5c
child 25915 f1bce5261dec
equal deleted inserted replaced
25881:d80bd899ea95 25882:c58e380d9f7d
    30 syntax (xsymbols)
    30 syntax (xsymbols)
    31   "++"		:: "[type, type] => type"	("(_ \<oplus>/ _)" [21, 20] 20)
    31   "++"		:: "[type, type] => type"	("(_ \<oplus>/ _)" [21, 20] 20)
    32 syntax (HTML output)
    32 syntax (HTML output)
    33   "++"		:: "[type, type] => type"	("(_ \<oplus>/ _)" [21, 20] 20)
    33   "++"		:: "[type, type] => type"	("(_ \<oplus>/ _)" [21, 20] 20)
    34 
    34 
    35 
       
    36 subsection {* Definitions of constructors *}
    35 subsection {* Definitions of constructors *}
    37 
    36 
    38 definition
    37 definition
    39   sinl :: "'a \<rightarrow> ('a ++ 'b)" where
    38   sinl :: "'a \<rightarrow> ('a ++ 'b)" where
    40   "sinl = (\<Lambda> a. Abs_Ssum <strictify\<cdot>(\<Lambda> _. TT)\<cdot>a, a, \<bottom>>)"
    39   "sinl = (\<Lambda> a. Abs_Ssum <strictify\<cdot>(\<Lambda> _. TT)\<cdot>a, a, \<bottom>>)"
    61 lemma Rep_Ssum_sinr: "Rep_Ssum (sinr\<cdot>b) = <strictify\<cdot>(\<Lambda> _. FF)\<cdot>b, \<bottom>, b>"
    60 lemma Rep_Ssum_sinr: "Rep_Ssum (sinr\<cdot>b) = <strictify\<cdot>(\<Lambda> _. FF)\<cdot>b, \<bottom>, b>"
    62 by (simp add: sinr_Abs_Ssum Abs_Ssum_inverse sinr_Ssum)
    61 by (simp add: sinr_Abs_Ssum Abs_Ssum_inverse sinr_Ssum)
    63 
    62 
    64 subsection {* Properties of @{term sinl} and @{term sinr} *}
    63 subsection {* Properties of @{term sinl} and @{term sinr} *}
    65 
    64 
    66 text {* Compactness *}
       
    67 
       
    68 lemma compact_sinl [simp]: "compact x \<Longrightarrow> compact (sinl\<cdot>x)"
       
    69 by (rule compact_Ssum, simp add: Rep_Ssum_sinl strictify_conv_if)
       
    70 
       
    71 lemma compact_sinr [simp]: "compact x \<Longrightarrow> compact (sinr\<cdot>x)"
       
    72 by (rule compact_Ssum, simp add: Rep_Ssum_sinr strictify_conv_if)
       
    73 
       
    74 text {* Ordering *}
    65 text {* Ordering *}
    75 
    66 
    76 lemma sinl_less [simp]: "(sinl\<cdot>x \<sqsubseteq> sinl\<cdot>y) = (x \<sqsubseteq> y)"
    67 lemma sinl_less [simp]: "(sinl\<cdot>x \<sqsubseteq> sinl\<cdot>y) = (x \<sqsubseteq> y)"
    77 by (simp add: less_Ssum_def Rep_Ssum_sinl strictify_conv_if)
    68 by (simp add: less_Ssum_def Rep_Ssum_sinl strictify_conv_if)
    78 
    69 
   122 lemma sinl_defined [intro!]: "x \<noteq> \<bottom> \<Longrightarrow> sinl\<cdot>x \<noteq> \<bottom>"
   113 lemma sinl_defined [intro!]: "x \<noteq> \<bottom> \<Longrightarrow> sinl\<cdot>x \<noteq> \<bottom>"
   123 by simp
   114 by simp
   124 
   115 
   125 lemma sinr_defined [intro!]: "x \<noteq> \<bottom> \<Longrightarrow> sinr\<cdot>x \<noteq> \<bottom>"
   116 lemma sinr_defined [intro!]: "x \<noteq> \<bottom> \<Longrightarrow> sinr\<cdot>x \<noteq> \<bottom>"
   126 by simp
   117 by simp
       
   118 
       
   119 text {* Compactness *}
       
   120 
       
   121 lemma compact_sinl: "compact x \<Longrightarrow> compact (sinl\<cdot>x)"
       
   122 by (rule compact_Ssum, simp add: Rep_Ssum_sinl strictify_conv_if)
       
   123 
       
   124 lemma compact_sinr: "compact x \<Longrightarrow> compact (sinr\<cdot>x)"
       
   125 by (rule compact_Ssum, simp add: Rep_Ssum_sinr strictify_conv_if)
       
   126 
       
   127 lemma compact_sinlD: "compact (sinl\<cdot>x) \<Longrightarrow> compact x"
       
   128 unfolding compact_def
       
   129 by (drule adm_subst [OF cont_Rep_CFun2 [where f=sinl]], simp)
       
   130 
       
   131 lemma compact_sinrD: "compact (sinr\<cdot>x) \<Longrightarrow> compact x"
       
   132 unfolding compact_def
       
   133 by (drule adm_subst [OF cont_Rep_CFun2 [where f=sinr]], simp)
       
   134 
       
   135 lemma compact_sinl_iff [simp]: "compact (sinl\<cdot>x) = compact x"
       
   136 by (safe elim!: compact_sinl compact_sinlD)
       
   137 
       
   138 lemma compact_sinr_iff [simp]: "compact (sinr\<cdot>x) = compact x"
       
   139 by (safe elim!: compact_sinr compact_sinrD)
   127 
   140 
   128 subsection {* Case analysis *}
   141 subsection {* Case analysis *}
   129 
   142 
   130 lemma Exh_Ssum: 
   143 lemma Exh_Ssum: 
   131   "z = \<bottom> \<or> (\<exists>a. z = sinl\<cdot>a \<and> a \<noteq> \<bottom>) \<or> (\<exists>b. z = sinr\<cdot>b \<and> b \<noteq> \<bottom>)"
   144   "z = \<bottom> \<or> (\<exists>a. z = sinl\<cdot>a \<and> a \<noteq> \<bottom>) \<or> (\<exists>b. z = sinr\<cdot>b \<and> b \<noteq> \<bottom>)"
   192 lemma sscase4 [simp]: "sscase\<cdot>sinl\<cdot>sinr\<cdot>z = z"
   205 lemma sscase4 [simp]: "sscase\<cdot>sinl\<cdot>sinr\<cdot>z = z"
   193 by (cases z, simp_all)
   206 by (cases z, simp_all)
   194 
   207 
   195 subsection {* Strict sum preserves flatness *}
   208 subsection {* Strict sum preserves flatness *}
   196 
   209 
   197 lemma flat_less_iff:
       
   198   fixes x y :: "'a::flat"
       
   199   shows "(x \<sqsubseteq> y) = (x = \<bottom> \<or> x = y)"
       
   200 by (safe dest!: ax_flat [rule_format])
       
   201 
       
   202 instance "++" :: (flat, flat) flat
   210 instance "++" :: (flat, flat) flat
   203 apply (intro_classes, clarify)
   211 apply (intro_classes, clarify)
   204 apply (rule_tac p=x in ssumE, simp)
   212 apply (rule_tac p=x in ssumE, simp)
   205 apply (rule_tac p=y in ssumE, simp_all add: flat_less_iff)
   213 apply (rule_tac p=y in ssumE, simp_all add: flat_less_iff)
   206 apply (rule_tac p=y in ssumE, simp_all add: flat_less_iff)
   214 apply (rule_tac p=y in ssumE, simp_all add: flat_less_iff)