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