src/HOLCF/Ssum.thy
author wenzelm
Tue Mar 02 23:59:54 2010 +0100 (2010-03-02)
changeset 35427 ad039d29e01c
parent 33808 31169fdc5ae7
child 35547 991a6af75978
permissions -rw-r--r--
proper (type_)notation;
huffman@15600
     1
(*  Title:      HOLCF/Ssum.thy
huffman@16060
     2
    Author:     Franz Regensburger and Brian Huffman
huffman@15576
     3
*)
huffman@15576
     4
huffman@15576
     5
header {* The type of strict sums *}
huffman@15576
     6
huffman@15577
     7
theory Ssum
huffman@31115
     8
imports Tr
huffman@15577
     9
begin
huffman@15576
    10
huffman@16083
    11
defaultsort pcpo
huffman@16083
    12
huffman@15593
    13
subsection {* Definition of strict sum type *}
huffman@15593
    14
huffman@17817
    15
pcpodef (Ssum)  ('a, 'b) "++" (infixr "++" 10) = 
huffman@25740
    16
  "{p :: tr \<times> ('a \<times> 'b).
huffman@31115
    17
    (fst p \<sqsubseteq> TT \<longleftrightarrow> snd (snd p) = \<bottom>) \<and>
huffman@31115
    18
    (fst p \<sqsubseteq> FF \<longleftrightarrow> fst (snd p) = \<bottom>)}"
wenzelm@29063
    19
by simp_all
huffman@15576
    20
huffman@25827
    21
instance "++" :: ("{finite_po,pcpo}", "{finite_po,pcpo}") finite_po
huffman@25827
    22
by (rule typedef_finite_po [OF type_definition_Ssum])
huffman@25827
    23
huffman@25827
    24
instance "++" :: ("{chfin,pcpo}", "{chfin,pcpo}") chfin
huffman@31076
    25
by (rule typedef_chfin [OF type_definition_Ssum below_Ssum_def])
huffman@25827
    26
wenzelm@35427
    27
type_notation (xsymbols)
wenzelm@35427
    28
  "++"  ("(_ \<oplus>/ _)" [21, 20] 20)
wenzelm@35427
    29
type_notation (HTML output)
wenzelm@35427
    30
  "++"  ("(_ \<oplus>/ _)" [21, 20] 20)
huffman@15576
    31
huffman@16060
    32
subsection {* Definitions of constructors *}
huffman@15576
    33
wenzelm@25131
    34
definition
wenzelm@25131
    35
  sinl :: "'a \<rightarrow> ('a ++ 'b)" where
huffman@31115
    36
  "sinl = (\<Lambda> a. Abs_Ssum (strictify\<cdot>(\<Lambda> _. TT)\<cdot>a, a, \<bottom>))"
huffman@16060
    37
wenzelm@25131
    38
definition
wenzelm@25131
    39
  sinr :: "'b \<rightarrow> ('a ++ 'b)" where
huffman@31115
    40
  "sinr = (\<Lambda> b. Abs_Ssum (strictify\<cdot>(\<Lambda> _. FF)\<cdot>b, \<bottom>, b))"
huffman@25740
    41
huffman@31115
    42
lemma sinl_Ssum: "(strictify\<cdot>(\<Lambda> _. TT)\<cdot>a, a, \<bottom>) \<in> Ssum"
huffman@25740
    43
by (simp add: Ssum_def strictify_conv_if)
huffman@25740
    44
huffman@31115
    45
lemma sinr_Ssum: "(strictify\<cdot>(\<Lambda> _. FF)\<cdot>b, \<bottom>, b) \<in> Ssum"
huffman@25740
    46
by (simp add: Ssum_def strictify_conv_if)
huffman@25740
    47
huffman@31115
    48
lemma sinl_Abs_Ssum: "sinl\<cdot>a = Abs_Ssum (strictify\<cdot>(\<Lambda> _. TT)\<cdot>a, a, \<bottom>)"
huffman@25740
    49
by (unfold sinl_def, simp add: cont_Abs_Ssum sinl_Ssum)
huffman@25740
    50
huffman@31115
    51
lemma sinr_Abs_Ssum: "sinr\<cdot>b = Abs_Ssum (strictify\<cdot>(\<Lambda> _. FF)\<cdot>b, \<bottom>, b)"
huffman@25740
    52
by (unfold sinr_def, simp add: cont_Abs_Ssum sinr_Ssum)
huffman@25740
    53
huffman@31115
    54
lemma Rep_Ssum_sinl: "Rep_Ssum (sinl\<cdot>a) = (strictify\<cdot>(\<Lambda> _. TT)\<cdot>a, a, \<bottom>)"
huffman@25740
    55
by (simp add: sinl_Abs_Ssum Abs_Ssum_inverse sinl_Ssum)
huffman@25740
    56
huffman@31115
    57
lemma Rep_Ssum_sinr: "Rep_Ssum (sinr\<cdot>b) = (strictify\<cdot>(\<Lambda> _. FF)\<cdot>b, \<bottom>, b)"
huffman@25740
    58
by (simp add: sinr_Abs_Ssum Abs_Ssum_inverse sinr_Ssum)
huffman@16060
    59
huffman@16060
    60
subsection {* Properties of @{term sinl} and @{term sinr} *}
huffman@16060
    61
huffman@25740
    62
text {* Ordering *}
huffman@25740
    63
huffman@31076
    64
lemma sinl_below [simp]: "(sinl\<cdot>x \<sqsubseteq> sinl\<cdot>y) = (x \<sqsubseteq> y)"
huffman@31076
    65
by (simp add: below_Ssum_def Rep_Ssum_sinl strictify_conv_if)
huffman@25740
    66
huffman@31076
    67
lemma sinr_below [simp]: "(sinr\<cdot>x \<sqsubseteq> sinr\<cdot>y) = (x \<sqsubseteq> y)"
huffman@31076
    68
by (simp add: below_Ssum_def Rep_Ssum_sinr strictify_conv_if)
huffman@25740
    69
huffman@31076
    70
lemma sinl_below_sinr [simp]: "(sinl\<cdot>x \<sqsubseteq> sinr\<cdot>y) = (x = \<bottom>)"
huffman@31076
    71
by (simp add: below_Ssum_def Rep_Ssum_sinl Rep_Ssum_sinr strictify_conv_if)
huffman@25740
    72
huffman@31076
    73
lemma sinr_below_sinl [simp]: "(sinr\<cdot>x \<sqsubseteq> sinl\<cdot>y) = (x = \<bottom>)"
huffman@31076
    74
by (simp add: below_Ssum_def Rep_Ssum_sinl Rep_Ssum_sinr strictify_conv_if)
huffman@25740
    75
huffman@25740
    76
text {* Equality *}
huffman@25740
    77
huffman@25740
    78
lemma sinl_eq [simp]: "(sinl\<cdot>x = sinl\<cdot>y) = (x = y)"
huffman@25740
    79
by (simp add: po_eq_conv)
huffman@25740
    80
huffman@25740
    81
lemma sinr_eq [simp]: "(sinr\<cdot>x = sinr\<cdot>y) = (x = y)"
huffman@25740
    82
by (simp add: po_eq_conv)
huffman@25740
    83
huffman@25740
    84
lemma sinl_eq_sinr [simp]: "(sinl\<cdot>x = sinr\<cdot>y) = (x = \<bottom> \<and> y = \<bottom>)"
huffman@25740
    85
by (subst po_eq_conv, simp)
huffman@25740
    86
huffman@25740
    87
lemma sinr_eq_sinl [simp]: "(sinr\<cdot>x = sinl\<cdot>y) = (x = \<bottom> \<and> y = \<bottom>)"
huffman@25740
    88
by (subst po_eq_conv, simp)
huffman@25740
    89
huffman@25740
    90
lemma sinl_inject: "sinl\<cdot>x = sinl\<cdot>y \<Longrightarrow> x = y"
huffman@25740
    91
by (rule sinl_eq [THEN iffD1])
huffman@25740
    92
huffman@25740
    93
lemma sinr_inject: "sinr\<cdot>x = sinr\<cdot>y \<Longrightarrow> x = y"
huffman@25740
    94
by (rule sinr_eq [THEN iffD1])
huffman@25740
    95
huffman@25740
    96
text {* Strictness *}
huffman@17837
    97
huffman@16211
    98
lemma sinl_strict [simp]: "sinl\<cdot>\<bottom> = \<bottom>"
huffman@25915
    99
by (simp add: sinl_Abs_Ssum Abs_Ssum_strict)
huffman@15576
   100
huffman@16211
   101
lemma sinr_strict [simp]: "sinr\<cdot>\<bottom> = \<bottom>"
huffman@25915
   102
by (simp add: sinr_Abs_Ssum Abs_Ssum_strict)
huffman@16060
   103
huffman@16752
   104
lemma sinl_defined_iff [simp]: "(sinl\<cdot>x = \<bottom>) = (x = \<bottom>)"
huffman@17837
   105
by (cut_tac sinl_eq [of "x" "\<bottom>"], simp)
huffman@15576
   106
huffman@16752
   107
lemma sinr_defined_iff [simp]: "(sinr\<cdot>x = \<bottom>) = (x = \<bottom>)"
huffman@17837
   108
by (cut_tac sinr_eq [of "x" "\<bottom>"], simp)
huffman@15576
   109
huffman@16752
   110
lemma sinl_defined [intro!]: "x \<noteq> \<bottom> \<Longrightarrow> sinl\<cdot>x \<noteq> \<bottom>"
huffman@16752
   111
by simp
huffman@16752
   112
huffman@16752
   113
lemma sinr_defined [intro!]: "x \<noteq> \<bottom> \<Longrightarrow> sinr\<cdot>x \<noteq> \<bottom>"
huffman@16752
   114
by simp
huffman@16752
   115
huffman@25882
   116
text {* Compactness *}
huffman@25882
   117
huffman@25882
   118
lemma compact_sinl: "compact x \<Longrightarrow> compact (sinl\<cdot>x)"
huffman@25882
   119
by (rule compact_Ssum, simp add: Rep_Ssum_sinl strictify_conv_if)
huffman@25882
   120
huffman@25882
   121
lemma compact_sinr: "compact x \<Longrightarrow> compact (sinr\<cdot>x)"
huffman@25882
   122
by (rule compact_Ssum, simp add: Rep_Ssum_sinr strictify_conv_if)
huffman@25882
   123
huffman@25882
   124
lemma compact_sinlD: "compact (sinl\<cdot>x) \<Longrightarrow> compact x"
huffman@25882
   125
unfolding compact_def
huffman@25882
   126
by (drule adm_subst [OF cont_Rep_CFun2 [where f=sinl]], simp)
huffman@25882
   127
huffman@25882
   128
lemma compact_sinrD: "compact (sinr\<cdot>x) \<Longrightarrow> compact x"
huffman@25882
   129
unfolding compact_def
huffman@25882
   130
by (drule adm_subst [OF cont_Rep_CFun2 [where f=sinr]], simp)
huffman@25882
   131
huffman@25882
   132
lemma compact_sinl_iff [simp]: "compact (sinl\<cdot>x) = compact x"
huffman@25882
   133
by (safe elim!: compact_sinl compact_sinlD)
huffman@25882
   134
huffman@25882
   135
lemma compact_sinr_iff [simp]: "compact (sinr\<cdot>x) = compact x"
huffman@25882
   136
by (safe elim!: compact_sinr compact_sinrD)
huffman@25882
   137
huffman@16060
   138
subsection {* Case analysis *}
huffman@16060
   139
huffman@16921
   140
lemma Exh_Ssum: 
huffman@16060
   141
  "z = \<bottom> \<or> (\<exists>a. z = sinl\<cdot>a \<and> a \<noteq> \<bottom>) \<or> (\<exists>b. z = sinr\<cdot>b \<and> b \<noteq> \<bottom>)"
huffman@31115
   142
apply (induct z rule: Abs_Ssum_induct)
huffman@31115
   143
apply (case_tac y, rename_tac t a b)
huffman@31115
   144
apply (case_tac t rule: trE)
huffman@25740
   145
apply (rule disjI1)
huffman@31115
   146
apply (simp add: Ssum_def Abs_Ssum_strict)
huffman@25740
   147
apply (rule disjI2, rule disjI1, rule_tac x=a in exI)
huffman@25740
   148
apply (simp add: sinl_Abs_Ssum Ssum_def)
huffman@25740
   149
apply (rule disjI2, rule disjI2, rule_tac x=b in exI)
huffman@25740
   150
apply (simp add: sinr_Abs_Ssum Ssum_def)
huffman@15576
   151
done
huffman@15576
   152
huffman@25740
   153
lemma ssumE [cases type: ++]:
huffman@16060
   154
  "\<lbrakk>p = \<bottom> \<Longrightarrow> Q;
huffman@16060
   155
   \<And>x. \<lbrakk>p = sinl\<cdot>x; x \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> Q;
huffman@16060
   156
   \<And>y. \<lbrakk>p = sinr\<cdot>y; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
huffman@16921
   157
by (cut_tac z=p in Exh_Ssum, auto)
huffman@15576
   158
huffman@25756
   159
lemma ssum_induct [induct type: ++]:
huffman@25756
   160
  "\<lbrakk>P \<bottom>;
huffman@25756
   161
   \<And>x. x \<noteq> \<bottom> \<Longrightarrow> P (sinl\<cdot>x);
huffman@25756
   162
   \<And>y. y \<noteq> \<bottom> \<Longrightarrow> P (sinr\<cdot>y)\<rbrakk> \<Longrightarrow> P x"
huffman@25756
   163
by (cases x, simp_all)
huffman@25756
   164
huffman@15576
   165
lemma ssumE2:
huffman@16060
   166
  "\<lbrakk>\<And>x. p = sinl\<cdot>x \<Longrightarrow> Q; \<And>y. p = sinr\<cdot>y \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
huffman@25740
   167
by (cases p, simp only: sinl_strict [symmetric], simp, simp)
huffman@16060
   168
huffman@31076
   169
lemma below_sinlD: "p \<sqsubseteq> sinl\<cdot>x \<Longrightarrow> \<exists>y. p = sinl\<cdot>y \<and> y \<sqsubseteq> x"
huffman@25740
   170
by (cases p, rule_tac x="\<bottom>" in exI, simp_all)
huffman@15576
   171
huffman@31076
   172
lemma below_sinrD: "p \<sqsubseteq> sinr\<cdot>x \<Longrightarrow> \<exists>y. p = sinr\<cdot>y \<and> y \<sqsubseteq> x"
huffman@25740
   173
by (cases p, rule_tac x="\<bottom>" in exI, simp_all)
huffman@16060
   174
huffman@25740
   175
subsection {* Case analysis combinator *}
huffman@16060
   176
wenzelm@25131
   177
definition
wenzelm@25131
   178
  sscase :: "('a \<rightarrow> 'c) \<rightarrow> ('b \<rightarrow> 'c) \<rightarrow> ('a ++ 'b) \<rightarrow> 'c" where
huffman@31115
   179
  "sscase = (\<Lambda> f g s. (\<lambda>(t, x, y). If t then f\<cdot>x else g\<cdot>y fi) (Rep_Ssum s))"
huffman@16060
   180
huffman@16060
   181
translations
huffman@26046
   182
  "case s of XCONST sinl\<cdot>x \<Rightarrow> t1 | XCONST sinr\<cdot>y \<Rightarrow> t2" == "CONST sscase\<cdot>(\<Lambda> x. t1)\<cdot>(\<Lambda> y. t2)\<cdot>s"
huffman@18078
   183
huffman@18078
   184
translations
huffman@26046
   185
  "\<Lambda>(XCONST sinl\<cdot>x). t" == "CONST sscase\<cdot>(\<Lambda> x. t)\<cdot>\<bottom>"
huffman@26046
   186
  "\<Lambda>(XCONST sinr\<cdot>y). t" == "CONST sscase\<cdot>\<bottom>\<cdot>(\<Lambda> y. t)"
huffman@16060
   187
huffman@25740
   188
lemma beta_sscase:
huffman@31115
   189
  "sscase\<cdot>f\<cdot>g\<cdot>s = (\<lambda>(t, x, y). If t then f\<cdot>x else g\<cdot>y fi) (Rep_Ssum s)"
huffman@31115
   190
unfolding sscase_def by (simp add: cont_Rep_Ssum [THEN cont_compose])
huffman@16060
   191
huffman@16060
   192
lemma sscase1 [simp]: "sscase\<cdot>f\<cdot>g\<cdot>\<bottom> = \<bottom>"
huffman@25740
   193
unfolding beta_sscase by (simp add: Rep_Ssum_strict)
huffman@15576
   194
huffman@16060
   195
lemma sscase2 [simp]: "x \<noteq> \<bottom> \<Longrightarrow> sscase\<cdot>f\<cdot>g\<cdot>(sinl\<cdot>x) = f\<cdot>x"
huffman@25740
   196
unfolding beta_sscase by (simp add: Rep_Ssum_sinl)
huffman@15576
   197
huffman@16060
   198
lemma sscase3 [simp]: "y \<noteq> \<bottom> \<Longrightarrow> sscase\<cdot>f\<cdot>g\<cdot>(sinr\<cdot>y) = g\<cdot>y"
huffman@25740
   199
unfolding beta_sscase by (simp add: Rep_Ssum_sinr)
huffman@15593
   200
huffman@16060
   201
lemma sscase4 [simp]: "sscase\<cdot>sinl\<cdot>sinr\<cdot>z = z"
huffman@25756
   202
by (cases z, simp_all)
huffman@15593
   203
huffman@25827
   204
subsection {* Strict sum preserves flatness *}
huffman@25827
   205
huffman@25827
   206
instance "++" :: (flat, flat) flat
huffman@25827
   207
apply (intro_classes, clarify)
huffman@31115
   208
apply (case_tac x, simp)
huffman@31115
   209
apply (case_tac y, simp_all add: flat_below_iff)
huffman@31115
   210
apply (case_tac y, simp_all add: flat_below_iff)
huffman@25827
   211
done
huffman@25827
   212
huffman@33504
   213
subsection {* Map function for strict sums *}
huffman@33504
   214
huffman@33504
   215
definition
huffman@33504
   216
  ssum_map :: "('a \<rightarrow> 'b) \<rightarrow> ('c \<rightarrow> 'd) \<rightarrow> 'a \<oplus> 'c \<rightarrow> 'b \<oplus> 'd"
huffman@33504
   217
where
huffman@33504
   218
  "ssum_map = (\<Lambda> f g. sscase\<cdot>(sinl oo f)\<cdot>(sinr oo g))"
huffman@33504
   219
huffman@33504
   220
lemma ssum_map_strict [simp]: "ssum_map\<cdot>f\<cdot>g\<cdot>\<bottom> = \<bottom>"
huffman@33504
   221
unfolding ssum_map_def by simp
huffman@33504
   222
huffman@33504
   223
lemma ssum_map_sinl [simp]: "x \<noteq> \<bottom> \<Longrightarrow> ssum_map\<cdot>f\<cdot>g\<cdot>(sinl\<cdot>x) = sinl\<cdot>(f\<cdot>x)"
huffman@33504
   224
unfolding ssum_map_def by simp
huffman@33504
   225
huffman@33504
   226
lemma ssum_map_sinr [simp]: "x \<noteq> \<bottom> \<Longrightarrow> ssum_map\<cdot>f\<cdot>g\<cdot>(sinr\<cdot>x) = sinr\<cdot>(g\<cdot>x)"
huffman@33504
   227
unfolding ssum_map_def by simp
huffman@33504
   228
huffman@33808
   229
lemma ssum_map_ID: "ssum_map\<cdot>ID\<cdot>ID = ID"
huffman@33808
   230
unfolding ssum_map_def by (simp add: expand_cfun_eq eta_cfun)
huffman@33808
   231
huffman@33587
   232
lemma ssum_map_map:
huffman@33587
   233
  "\<lbrakk>f1\<cdot>\<bottom> = \<bottom>; g1\<cdot>\<bottom> = \<bottom>\<rbrakk> \<Longrightarrow>
huffman@33587
   234
    ssum_map\<cdot>f1\<cdot>g1\<cdot>(ssum_map\<cdot>f2\<cdot>g2\<cdot>p) =
huffman@33587
   235
     ssum_map\<cdot>(\<Lambda> x. f1\<cdot>(f2\<cdot>x))\<cdot>(\<Lambda> x. g1\<cdot>(g2\<cdot>x))\<cdot>p"
huffman@33587
   236
apply (induct p, simp)
huffman@33587
   237
apply (case_tac "f2\<cdot>x = \<bottom>", simp, simp)
huffman@33587
   238
apply (case_tac "g2\<cdot>y = \<bottom>", simp, simp)
huffman@33587
   239
done
huffman@33587
   240
huffman@33504
   241
lemma ep_pair_ssum_map:
huffman@33504
   242
  assumes "ep_pair e1 p1" and "ep_pair e2 p2"
huffman@33504
   243
  shows "ep_pair (ssum_map\<cdot>e1\<cdot>e2) (ssum_map\<cdot>p1\<cdot>p2)"
huffman@33504
   244
proof
huffman@33504
   245
  interpret e1p1: pcpo_ep_pair e1 p1 unfolding pcpo_ep_pair_def by fact
huffman@33504
   246
  interpret e2p2: pcpo_ep_pair e2 p2 unfolding pcpo_ep_pair_def by fact
huffman@33504
   247
  fix x show "ssum_map\<cdot>p1\<cdot>p2\<cdot>(ssum_map\<cdot>e1\<cdot>e2\<cdot>x) = x"
huffman@33504
   248
    by (induct x) simp_all
huffman@33504
   249
  fix y show "ssum_map\<cdot>e1\<cdot>e2\<cdot>(ssum_map\<cdot>p1\<cdot>p2\<cdot>y) \<sqsubseteq> y"
huffman@33504
   250
    apply (induct y, simp)
huffman@33504
   251
    apply (case_tac "p1\<cdot>x = \<bottom>", simp, simp add: e1p1.e_p_below)
huffman@33504
   252
    apply (case_tac "p2\<cdot>y = \<bottom>", simp, simp add: e2p2.e_p_below)
huffman@33504
   253
    done
huffman@33504
   254
qed
huffman@33504
   255
huffman@33504
   256
lemma deflation_ssum_map:
huffman@33504
   257
  assumes "deflation d1" and "deflation d2"
huffman@33504
   258
  shows "deflation (ssum_map\<cdot>d1\<cdot>d2)"
huffman@33504
   259
proof
huffman@33504
   260
  interpret d1: deflation d1 by fact
huffman@33504
   261
  interpret d2: deflation d2 by fact
huffman@33504
   262
  fix x
huffman@33504
   263
  show "ssum_map\<cdot>d1\<cdot>d2\<cdot>(ssum_map\<cdot>d1\<cdot>d2\<cdot>x) = ssum_map\<cdot>d1\<cdot>d2\<cdot>x"
huffman@33504
   264
    apply (induct x, simp)
huffman@33504
   265
    apply (case_tac "d1\<cdot>x = \<bottom>", simp, simp add: d1.idem)
huffman@33504
   266
    apply (case_tac "d2\<cdot>y = \<bottom>", simp, simp add: d2.idem)
huffman@33504
   267
    done
huffman@33504
   268
  show "ssum_map\<cdot>d1\<cdot>d2\<cdot>x \<sqsubseteq> x"
huffman@33504
   269
    apply (induct x, simp)
huffman@33504
   270
    apply (case_tac "d1\<cdot>x = \<bottom>", simp, simp add: d1.below)
huffman@33504
   271
    apply (case_tac "d2\<cdot>y = \<bottom>", simp, simp add: d2.below)
huffman@33504
   272
    done
huffman@33504
   273
qed
huffman@33504
   274
huffman@33504
   275
lemma finite_deflation_ssum_map:
huffman@33504
   276
  assumes "finite_deflation d1" and "finite_deflation d2"
huffman@33504
   277
  shows "finite_deflation (ssum_map\<cdot>d1\<cdot>d2)"
huffman@33504
   278
proof (intro finite_deflation.intro finite_deflation_axioms.intro)
huffman@33504
   279
  interpret d1: finite_deflation d1 by fact
huffman@33504
   280
  interpret d2: finite_deflation d2 by fact
huffman@33504
   281
  have "deflation d1" and "deflation d2" by fact+
huffman@33504
   282
  thus "deflation (ssum_map\<cdot>d1\<cdot>d2)" by (rule deflation_ssum_map)
huffman@33504
   283
  have "{x. ssum_map\<cdot>d1\<cdot>d2\<cdot>x = x} \<subseteq>
huffman@33504
   284
        (\<lambda>x. sinl\<cdot>x) ` {x. d1\<cdot>x = x} \<union>
huffman@33504
   285
        (\<lambda>x. sinr\<cdot>x) ` {x. d2\<cdot>x = x} \<union> {\<bottom>}"
huffman@33504
   286
    by (rule subsetI, case_tac x, simp_all)
huffman@33504
   287
  thus "finite {x. ssum_map\<cdot>d1\<cdot>d2\<cdot>x = x}"
huffman@33504
   288
    by (rule finite_subset, simp add: d1.finite_fixes d2.finite_fixes)
huffman@33504
   289
qed
huffman@33504
   290
huffman@25915
   291
subsection {* Strict sum is a bifinite domain *}
huffman@25915
   292
huffman@26962
   293
instantiation "++" :: (bifinite, bifinite) bifinite
huffman@26962
   294
begin
huffman@25915
   295
huffman@26962
   296
definition
huffman@25915
   297
  approx_ssum_def:
huffman@33504
   298
    "approx = (\<lambda>n. ssum_map\<cdot>(approx n)\<cdot>(approx n))"
huffman@25915
   299
huffman@25915
   300
lemma approx_sinl [simp]: "approx i\<cdot>(sinl\<cdot>x) = sinl\<cdot>(approx i\<cdot>x)"
huffman@25915
   301
unfolding approx_ssum_def by (cases "x = \<bottom>") simp_all
huffman@25915
   302
huffman@25915
   303
lemma approx_sinr [simp]: "approx i\<cdot>(sinr\<cdot>x) = sinr\<cdot>(approx i\<cdot>x)"
huffman@25915
   304
unfolding approx_ssum_def by (cases "x = \<bottom>") simp_all
huffman@25915
   305
huffman@26962
   306
instance proof
huffman@25915
   307
  fix i :: nat and x :: "'a \<oplus> 'b"
huffman@27310
   308
  show "chain (approx :: nat \<Rightarrow> 'a \<oplus> 'b \<rightarrow> 'a \<oplus> 'b)"
huffman@25915
   309
    unfolding approx_ssum_def by simp
huffman@25915
   310
  show "(\<Squnion>i. approx i\<cdot>x) = x"
huffman@25915
   311
    unfolding approx_ssum_def
huffman@33504
   312
    by (cases x, simp_all add: lub_distribs)
huffman@25915
   313
  show "approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x"
huffman@25915
   314
    by (cases x, simp add: approx_ssum_def, simp, simp)
huffman@33504
   315
  show "finite {x::'a \<oplus> 'b. approx i\<cdot>x = x}"
huffman@33504
   316
    unfolding approx_ssum_def
huffman@33504
   317
    by (intro finite_deflation.finite_fixes
huffman@33504
   318
              finite_deflation_ssum_map
huffman@33504
   319
              finite_deflation_approx)
huffman@25915
   320
qed
huffman@25915
   321
huffman@15576
   322
end
huffman@26962
   323
huffman@26962
   324
end