src/HOLCF/Sprod.thy
author huffman
Tue Dec 16 21:31:55 2008 -0800 (2008-12-16)
changeset 29138 661a8db7e647
parent 29063 7619f0561cd7
child 31076 99fe356cbbc2
permissions -rw-r--r--
remove cvs Id tags
huffman@15600
     1
(*  Title:      HOLCF/Sprod.thy
huffman@16059
     2
    Author:     Franz Regensburger and Brian Huffman
huffman@15576
     3
*)
huffman@15576
     4
huffman@15576
     5
header {* The type of strict products *}
huffman@15576
     6
huffman@15577
     7
theory Sprod
huffman@16699
     8
imports Cprod
huffman@15577
     9
begin
huffman@15576
    10
huffman@16082
    11
defaultsort pcpo
huffman@16082
    12
huffman@15591
    13
subsection {* Definition of strict product type *}
huffman@15591
    14
huffman@17817
    15
pcpodef (Sprod)  ('a, 'b) "**" (infixr "**" 20) =
huffman@16059
    16
        "{p::'a \<times> 'b. p = \<bottom> \<or> (cfst\<cdot>p \<noteq> \<bottom> \<and> csnd\<cdot>p \<noteq> \<bottom>)}"
wenzelm@29063
    17
by simp_all
huffman@15576
    18
huffman@25827
    19
instance "**" :: ("{finite_po,pcpo}", "{finite_po,pcpo}") finite_po
huffman@25827
    20
by (rule typedef_finite_po [OF type_definition_Sprod])
huffman@25827
    21
huffman@25827
    22
instance "**" :: ("{chfin,pcpo}", "{chfin,pcpo}") chfin
huffman@25827
    23
by (rule typedef_chfin [OF type_definition_Sprod less_Sprod_def])
huffman@25827
    24
huffman@15576
    25
syntax (xsymbols)
huffman@15576
    26
  "**"		:: "[type, type] => type"	 ("(_ \<otimes>/ _)" [21,20] 20)
huffman@15576
    27
syntax (HTML output)
huffman@15576
    28
  "**"		:: "[type, type] => type"	 ("(_ \<otimes>/ _)" [21,20] 20)
huffman@15576
    29
huffman@16059
    30
lemma spair_lemma:
huffman@16059
    31
  "<strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a> \<in> Sprod"
huffman@25914
    32
by (simp add: Sprod_def strictify_conv_if)
huffman@15576
    33
huffman@16059
    34
subsection {* Definitions of constants *}
huffman@15576
    35
wenzelm@25135
    36
definition
wenzelm@25135
    37
  sfst :: "('a ** 'b) \<rightarrow> 'a" where
wenzelm@25135
    38
  "sfst = (\<Lambda> p. cfst\<cdot>(Rep_Sprod p))"
wenzelm@25135
    39
wenzelm@25135
    40
definition
wenzelm@25135
    41
  ssnd :: "('a ** 'b) \<rightarrow> 'b" where
wenzelm@25135
    42
  "ssnd = (\<Lambda> p. csnd\<cdot>(Rep_Sprod p))"
huffman@15576
    43
wenzelm@25135
    44
definition
wenzelm@25135
    45
  spair :: "'a \<rightarrow> 'b \<rightarrow> ('a ** 'b)" where
wenzelm@25135
    46
  "spair = (\<Lambda> a b. Abs_Sprod
wenzelm@25135
    47
             <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>)"
huffman@15576
    48
wenzelm@25135
    49
definition
wenzelm@25135
    50
  ssplit :: "('a \<rightarrow> 'b \<rightarrow> 'c) \<rightarrow> ('a ** 'b) \<rightarrow> 'c" where
wenzelm@25135
    51
  "ssplit = (\<Lambda> f. strictify\<cdot>(\<Lambda> p. f\<cdot>(sfst\<cdot>p)\<cdot>(ssnd\<cdot>p)))"
wenzelm@25135
    52
wenzelm@25135
    53
syntax
huffman@18078
    54
  "@stuple" :: "['a, args] => 'a ** 'b"  ("(1'(:_,/ _:'))")
huffman@15576
    55
translations
huffman@18078
    56
  "(:x, y, z:)" == "(:x, (:y, z:):)"
wenzelm@25131
    57
  "(:x, y:)"    == "CONST spair\<cdot>x\<cdot>y"
huffman@18078
    58
huffman@18078
    59
translations
wenzelm@25131
    60
  "\<Lambda>(CONST spair\<cdot>x\<cdot>y). t" == "CONST ssplit\<cdot>(\<Lambda> x y. t)"
huffman@15576
    61
huffman@16059
    62
subsection {* Case analysis *}
huffman@15576
    63
huffman@25914
    64
lemma Rep_Sprod_spair:
huffman@25914
    65
  "Rep_Sprod (:a, b:) = <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
huffman@25914
    66
unfolding spair_def
huffman@25914
    67
by (simp add: cont_Abs_Sprod Abs_Sprod_inverse spair_lemma)
huffman@25914
    68
huffman@25914
    69
lemmas Rep_Sprod_simps =
huffman@25914
    70
  Rep_Sprod_inject [symmetric] less_Sprod_def
huffman@25914
    71
  Rep_Sprod_strict Rep_Sprod_spair
huffman@15576
    72
huffman@27310
    73
lemma Exh_Sprod:
huffman@16059
    74
  "z = \<bottom> \<or> (\<exists>a b. z = (:a, b:) \<and> a \<noteq> \<bottom> \<and> b \<noteq> \<bottom>)"
huffman@25914
    75
apply (insert Rep_Sprod [of z])
huffman@25914
    76
apply (simp add: Rep_Sprod_simps eq_cprod)
huffman@16059
    77
apply (simp add: Sprod_def)
huffman@25914
    78
apply (erule disjE, simp)
huffman@25914
    79
apply (simp add: strictify_conv_if)
huffman@25914
    80
apply fast
huffman@15576
    81
done
huffman@15576
    82
huffman@25757
    83
lemma sprodE [cases type: **]:
huffman@16059
    84
  "\<lbrakk>p = \<bottom> \<Longrightarrow> Q; \<And>x y. \<lbrakk>p = (:x, y:); x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
huffman@27310
    85
by (cut_tac z=p in Exh_Sprod, auto)
huffman@16059
    86
huffman@25757
    87
lemma sprod_induct [induct type: **]:
huffman@25757
    88
  "\<lbrakk>P \<bottom>; \<And>x y. \<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> P (:x, y:)\<rbrakk> \<Longrightarrow> P x"
huffman@25757
    89
by (cases x, simp_all)
huffman@25757
    90
huffman@16059
    91
subsection {* Properties of @{term spair} *}
huffman@16059
    92
huffman@16317
    93
lemma spair_strict1 [simp]: "(:\<bottom>, y:) = \<bottom>"
huffman@25914
    94
by (simp add: Rep_Sprod_simps strictify_conv_if)
huffman@15576
    95
huffman@16317
    96
lemma spair_strict2 [simp]: "(:x, \<bottom>:) = \<bottom>"
huffman@25914
    97
by (simp add: Rep_Sprod_simps strictify_conv_if)
huffman@25914
    98
huffman@25914
    99
lemma spair_strict_iff [simp]: "((:x, y:) = \<bottom>) = (x = \<bottom> \<or> y = \<bottom>)"
huffman@25914
   100
by (simp add: Rep_Sprod_simps strictify_conv_if)
huffman@25914
   101
huffman@25914
   102
lemma spair_less_iff:
huffman@25914
   103
  "((:a, b:) \<sqsubseteq> (:c, d:)) = (a = \<bottom> \<or> b = \<bottom> \<or> (a \<sqsubseteq> c \<and> b \<sqsubseteq> d))"
huffman@25914
   104
by (simp add: Rep_Sprod_simps strictify_conv_if)
huffman@25914
   105
huffman@25914
   106
lemma spair_eq_iff:
huffman@25914
   107
  "((:a, b:) = (:c, d:)) =
huffman@25914
   108
    (a = c \<and> b = d \<or> (a = \<bottom> \<or> b = \<bottom>) \<and> (c = \<bottom> \<or> d = \<bottom>))"
huffman@25914
   109
by (simp add: Rep_Sprod_simps strictify_conv_if)
huffman@15576
   110
huffman@16317
   111
lemma spair_strict: "x = \<bottom> \<or> y = \<bottom> \<Longrightarrow> (:x, y:) = \<bottom>"
huffman@25914
   112
by simp
huffman@16059
   113
huffman@16212
   114
lemma spair_strict_rev: "(:x, y:) \<noteq> \<bottom> \<Longrightarrow> x \<noteq> \<bottom> \<and> y \<noteq> \<bottom>"
huffman@25914
   115
by simp
huffman@16059
   116
huffman@25914
   117
lemma spair_defined: "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<noteq> \<bottom>"
huffman@25914
   118
by simp
huffman@15576
   119
huffman@16317
   120
lemma spair_defined_rev: "(:x, y:) = \<bottom> \<Longrightarrow> x = \<bottom> \<or> y = \<bottom>"
huffman@25914
   121
by simp
huffman@15576
   122
huffman@16317
   123
lemma spair_eq:
huffman@16317
   124
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> ((:x, y:) = (:a, b:)) = (x = a \<and> y = b)"
huffman@25914
   125
by (simp add: spair_eq_iff)
huffman@16317
   126
huffman@16212
   127
lemma spair_inject:
huffman@16317
   128
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>; (:x, y:) = (:a, b:)\<rbrakk> \<Longrightarrow> x = a \<and> y = b"
huffman@16317
   129
by (rule spair_eq [THEN iffD1])
huffman@15576
   130
huffman@15576
   131
lemma inst_sprod_pcpo2: "UU = (:UU,UU:)"
huffman@16059
   132
by simp
huffman@15576
   133
huffman@16059
   134
subsection {* Properties of @{term sfst} and @{term ssnd} *}
huffman@15576
   135
huffman@16212
   136
lemma sfst_strict [simp]: "sfst\<cdot>\<bottom> = \<bottom>"
huffman@16212
   137
by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_strict)
huffman@15576
   138
huffman@16212
   139
lemma ssnd_strict [simp]: "ssnd\<cdot>\<bottom> = \<bottom>"
huffman@16212
   140
by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_strict)
huffman@15576
   141
huffman@16212
   142
lemma sfst_spair [simp]: "y \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>(:x, y:) = x"
huffman@16059
   143
by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_spair)
huffman@15576
   144
huffman@16212
   145
lemma ssnd_spair [simp]: "x \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>(:x, y:) = y"
huffman@16059
   146
by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_spair)
huffman@15576
   147
huffman@16777
   148
lemma sfst_defined_iff [simp]: "(sfst\<cdot>p = \<bottom>) = (p = \<bottom>)"
huffman@25757
   149
by (cases p, simp_all)
huffman@16777
   150
huffman@16777
   151
lemma ssnd_defined_iff [simp]: "(ssnd\<cdot>p = \<bottom>) = (p = \<bottom>)"
huffman@25757
   152
by (cases p, simp_all)
huffman@16317
   153
huffman@16777
   154
lemma sfst_defined: "p \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>p \<noteq> \<bottom>"
huffman@16777
   155
by simp
huffman@16777
   156
huffman@16777
   157
lemma ssnd_defined: "p \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>p \<noteq> \<bottom>"
huffman@16777
   158
by simp
huffman@16777
   159
huffman@16059
   160
lemma surjective_pairing_Sprod2: "(:sfst\<cdot>p, ssnd\<cdot>p:) = p"
huffman@25757
   161
by (cases p, simp_all)
huffman@15576
   162
huffman@16751
   163
lemma less_sprod: "x \<sqsubseteq> y = (sfst\<cdot>x \<sqsubseteq> sfst\<cdot>y \<and> ssnd\<cdot>x \<sqsubseteq> ssnd\<cdot>y)"
huffman@16699
   164
apply (simp add: less_Sprod_def sfst_def ssnd_def cont_Rep_Sprod)
huffman@16317
   165
apply (rule less_cprod)
huffman@16317
   166
done
huffman@16317
   167
huffman@16751
   168
lemma eq_sprod: "(x = y) = (sfst\<cdot>x = sfst\<cdot>y \<and> ssnd\<cdot>x = ssnd\<cdot>y)"
huffman@16751
   169
by (auto simp add: po_eq_conv less_sprod)
huffman@16751
   170
huffman@16317
   171
lemma spair_less:
huffman@16317
   172
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<sqsubseteq> (:a, b:) = (x \<sqsubseteq> a \<and> y \<sqsubseteq> b)"
huffman@25757
   173
apply (cases "a = \<bottom>", simp)
huffman@25757
   174
apply (cases "b = \<bottom>", simp)
huffman@16317
   175
apply (simp add: less_sprod)
huffman@16317
   176
done
huffman@16317
   177
huffman@25881
   178
lemma sfst_less_iff: "sfst\<cdot>x \<sqsubseteq> y = x \<sqsubseteq> (:y, ssnd\<cdot>x:)"
huffman@25881
   179
apply (cases "x = \<bottom>", simp, cases "y = \<bottom>", simp)
huffman@25881
   180
apply (simp add: less_sprod)
huffman@25881
   181
done
huffman@25881
   182
huffman@25881
   183
lemma ssnd_less_iff: "ssnd\<cdot>x \<sqsubseteq> y = x \<sqsubseteq> (:sfst\<cdot>x, y:)"
huffman@25881
   184
apply (cases "x = \<bottom>", simp, cases "y = \<bottom>", simp)
huffman@25881
   185
apply (simp add: less_sprod)
huffman@25881
   186
done
huffman@25881
   187
huffman@25881
   188
subsection {* Compactness *}
huffman@25881
   189
huffman@25881
   190
lemma compact_sfst: "compact x \<Longrightarrow> compact (sfst\<cdot>x)"
huffman@25881
   191
by (rule compactI, simp add: sfst_less_iff)
huffman@25881
   192
huffman@25881
   193
lemma compact_ssnd: "compact x \<Longrightarrow> compact (ssnd\<cdot>x)"
huffman@25881
   194
by (rule compactI, simp add: ssnd_less_iff)
huffman@25881
   195
huffman@25881
   196
lemma compact_spair: "\<lbrakk>compact x; compact y\<rbrakk> \<Longrightarrow> compact (:x, y:)"
huffman@25881
   197
by (rule compact_Sprod, simp add: Rep_Sprod_spair strictify_conv_if)
huffman@25881
   198
huffman@25881
   199
lemma compact_spair_iff:
huffman@25881
   200
  "compact (:x, y:) = (x = \<bottom> \<or> y = \<bottom> \<or> (compact x \<and> compact y))"
huffman@25881
   201
apply (safe elim!: compact_spair)
huffman@25881
   202
apply (drule compact_sfst, simp)
huffman@25881
   203
apply (drule compact_ssnd, simp)
huffman@25881
   204
apply simp
huffman@25881
   205
apply simp
huffman@25881
   206
done
huffman@25881
   207
huffman@16059
   208
subsection {* Properties of @{term ssplit} *}
huffman@15576
   209
huffman@16059
   210
lemma ssplit1 [simp]: "ssplit\<cdot>f\<cdot>\<bottom> = \<bottom>"
huffman@15591
   211
by (simp add: ssplit_def)
huffman@15591
   212
huffman@16920
   213
lemma ssplit2 [simp]: "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> ssplit\<cdot>f\<cdot>(:x, y:) = f\<cdot>x\<cdot>y"
huffman@15591
   214
by (simp add: ssplit_def)
huffman@15591
   215
huffman@16553
   216
lemma ssplit3 [simp]: "ssplit\<cdot>spair\<cdot>z = z"
huffman@25757
   217
by (cases z, simp_all)
huffman@15576
   218
huffman@25827
   219
subsection {* Strict product preserves flatness *}
huffman@25827
   220
huffman@25827
   221
instance "**" :: (flat, flat) flat
huffman@27310
   222
proof
huffman@27310
   223
  fix x y :: "'a \<otimes> 'b"
huffman@27310
   224
  assume "x \<sqsubseteq> y" thus "x = \<bottom> \<or> x = y"
huffman@27310
   225
    apply (induct x, simp)
huffman@27310
   226
    apply (induct y, simp)
huffman@27310
   227
    apply (simp add: spair_less_iff flat_less_iff)
huffman@27310
   228
    done
huffman@27310
   229
qed
huffman@25827
   230
huffman@25914
   231
subsection {* Strict product is a bifinite domain *}
huffman@25914
   232
huffman@26962
   233
instantiation "**" :: (bifinite, bifinite) bifinite
huffman@26962
   234
begin
huffman@25914
   235
huffman@26962
   236
definition
huffman@25914
   237
  approx_sprod_def:
huffman@26962
   238
    "approx = (\<lambda>n. \<Lambda>(:x, y:). (:approx n\<cdot>x, approx n\<cdot>y:))"
huffman@25914
   239
huffman@26962
   240
instance proof
huffman@25914
   241
  fix i :: nat and x :: "'a \<otimes> 'b"
huffman@27310
   242
  show "chain (approx :: nat \<Rightarrow> 'a \<otimes> 'b \<rightarrow> 'a \<otimes> 'b)"
huffman@25914
   243
    unfolding approx_sprod_def by simp
huffman@25914
   244
  show "(\<Squnion>i. approx i\<cdot>x) = x"
huffman@25914
   245
    unfolding approx_sprod_def
huffman@25914
   246
    by (simp add: lub_distribs eta_cfun)
huffman@25914
   247
  show "approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x"
huffman@25914
   248
    unfolding approx_sprod_def
huffman@25914
   249
    by (simp add: ssplit_def strictify_conv_if)
huffman@25914
   250
  have "Rep_Sprod ` {x::'a \<otimes> 'b. approx i\<cdot>x = x} \<subseteq> {x. approx i\<cdot>x = x}"
huffman@25914
   251
    unfolding approx_sprod_def
huffman@27310
   252
    apply (clarify, case_tac x)
huffman@25914
   253
     apply (simp add: Rep_Sprod_strict)
huffman@25914
   254
    apply (simp add: Rep_Sprod_spair spair_eq_iff)
huffman@25914
   255
    done
huffman@25914
   256
  hence "finite (Rep_Sprod ` {x::'a \<otimes> 'b. approx i\<cdot>x = x})"
huffman@25914
   257
    using finite_fixes_approx by (rule finite_subset)
huffman@25914
   258
  thus "finite {x::'a \<otimes> 'b. approx i\<cdot>x = x}"
huffman@25914
   259
    by (rule finite_imageD, simp add: inj_on_def Rep_Sprod_inject)
huffman@25914
   260
qed
huffman@25914
   261
huffman@26962
   262
end
huffman@26962
   263
huffman@25914
   264
lemma approx_spair [simp]:
huffman@25914
   265
  "approx i\<cdot>(:x, y:) = (:approx i\<cdot>x, approx i\<cdot>y:)"
huffman@25914
   266
unfolding approx_sprod_def
huffman@25914
   267
by (simp add: ssplit_def strictify_conv_if)
huffman@25914
   268
huffman@15576
   269
end