src/HOLCF/Sprod.thy
author huffman
Thu Jan 10 05:37:18 2008 +0100 (2008-01-10)
changeset 25881 d80bd899ea95
parent 25827 c2adeb1bae5c
child 25914 ff835e25ae87
permissions -rw-r--r--
Compactness subsection with new lemmas
huffman@15600
     1
(*  Title:      HOLCF/Sprod.thy
huffman@15576
     2
    ID:         $Id$
huffman@16059
     3
    Author:     Franz Regensburger and Brian Huffman
huffman@15576
     4
huffman@15576
     5
Strict product with typedef.
huffman@15576
     6
*)
huffman@15576
     7
huffman@15576
     8
header {* The type of strict products *}
huffman@15576
     9
huffman@15577
    10
theory Sprod
huffman@16699
    11
imports Cprod
huffman@15577
    12
begin
huffman@15576
    13
huffman@16082
    14
defaultsort pcpo
huffman@16082
    15
huffman@15591
    16
subsection {* Definition of strict product type *}
huffman@15591
    17
huffman@17817
    18
pcpodef (Sprod)  ('a, 'b) "**" (infixr "**" 20) =
huffman@16059
    19
        "{p::'a \<times> 'b. p = \<bottom> \<or> (cfst\<cdot>p \<noteq> \<bottom> \<and> csnd\<cdot>p \<noteq> \<bottom>)}"
huffman@16699
    20
by simp
huffman@15576
    21
huffman@25827
    22
instance "**" :: ("{finite_po,pcpo}", "{finite_po,pcpo}") finite_po
huffman@25827
    23
by (rule typedef_finite_po [OF type_definition_Sprod])
huffman@25827
    24
huffman@25827
    25
instance "**" :: ("{chfin,pcpo}", "{chfin,pcpo}") chfin
huffman@25827
    26
by (rule typedef_chfin [OF type_definition_Sprod less_Sprod_def])
huffman@25827
    27
huffman@15576
    28
syntax (xsymbols)
huffman@15576
    29
  "**"		:: "[type, type] => type"	 ("(_ \<otimes>/ _)" [21,20] 20)
huffman@15576
    30
syntax (HTML output)
huffman@15576
    31
  "**"		:: "[type, type] => type"	 ("(_ \<otimes>/ _)" [21,20] 20)
huffman@15576
    32
huffman@16059
    33
lemma spair_lemma:
huffman@16059
    34
  "<strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a> \<in> Sprod"
huffman@16212
    35
by (simp add: Sprod_def strictify_conv_if cpair_strict)
huffman@15576
    36
huffman@16059
    37
subsection {* Definitions of constants *}
huffman@15576
    38
wenzelm@25135
    39
definition
wenzelm@25135
    40
  sfst :: "('a ** 'b) \<rightarrow> 'a" where
wenzelm@25135
    41
  "sfst = (\<Lambda> p. cfst\<cdot>(Rep_Sprod p))"
wenzelm@25135
    42
wenzelm@25135
    43
definition
wenzelm@25135
    44
  ssnd :: "('a ** 'b) \<rightarrow> 'b" where
wenzelm@25135
    45
  "ssnd = (\<Lambda> p. csnd\<cdot>(Rep_Sprod p))"
huffman@15576
    46
wenzelm@25135
    47
definition
wenzelm@25135
    48
  spair :: "'a \<rightarrow> 'b \<rightarrow> ('a ** 'b)" where
wenzelm@25135
    49
  "spair = (\<Lambda> a b. Abs_Sprod
wenzelm@25135
    50
             <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>)"
huffman@15576
    51
wenzelm@25135
    52
definition
wenzelm@25135
    53
  ssplit :: "('a \<rightarrow> 'b \<rightarrow> 'c) \<rightarrow> ('a ** 'b) \<rightarrow> 'c" where
wenzelm@25135
    54
  "ssplit = (\<Lambda> f. strictify\<cdot>(\<Lambda> p. f\<cdot>(sfst\<cdot>p)\<cdot>(ssnd\<cdot>p)))"
wenzelm@25135
    55
wenzelm@25135
    56
syntax
huffman@18078
    57
  "@stuple" :: "['a, args] => 'a ** 'b"  ("(1'(:_,/ _:'))")
huffman@15576
    58
translations
huffman@18078
    59
  "(:x, y, z:)" == "(:x, (:y, z:):)"
wenzelm@25131
    60
  "(:x, y:)"    == "CONST spair\<cdot>x\<cdot>y"
huffman@18078
    61
huffman@18078
    62
translations
wenzelm@25131
    63
  "\<Lambda>(CONST spair\<cdot>x\<cdot>y). t" == "CONST ssplit\<cdot>(\<Lambda> x y. t)"
huffman@15576
    64
huffman@16059
    65
subsection {* Case analysis *}
huffman@15576
    66
huffman@16059
    67
lemma spair_Abs_Sprod:
huffman@16059
    68
  "(:a, b:) = Abs_Sprod <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
huffman@16059
    69
apply (unfold spair_def)
huffman@16059
    70
apply (simp add: cont_Abs_Sprod spair_lemma)
huffman@15576
    71
done
huffman@15576
    72
huffman@16059
    73
lemma Exh_Sprod2:
huffman@16059
    74
  "z = \<bottom> \<or> (\<exists>a b. z = (:a, b:) \<and> a \<noteq> \<bottom> \<and> b \<noteq> \<bottom>)"
huffman@25757
    75
apply (cases z rule: Abs_Sprod_cases)
huffman@16059
    76
apply (simp add: Sprod_def)
huffman@16059
    77
apply (erule disjE)
huffman@16212
    78
apply (simp add: Abs_Sprod_strict)
huffman@16059
    79
apply (rule disjI2)
huffman@16059
    80
apply (rule_tac x="cfst\<cdot>y" in exI)
huffman@16059
    81
apply (rule_tac x="csnd\<cdot>y" in exI)
huffman@16059
    82
apply (simp add: spair_Abs_Sprod Abs_Sprod_inject spair_lemma)
huffman@16059
    83
apply (simp add: surjective_pairing_Cprod2)
huffman@15576
    84
done
huffman@15576
    85
huffman@25757
    86
lemma sprodE [cases type: **]:
huffman@16059
    87
  "\<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@16059
    88
by (cut_tac z=p in Exh_Sprod2, auto)
huffman@16059
    89
huffman@25757
    90
lemma sprod_induct [induct type: **]:
huffman@25757
    91
  "\<lbrakk>P \<bottom>; \<And>x y. \<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> P (:x, y:)\<rbrakk> \<Longrightarrow> P x"
huffman@25757
    92
by (cases x, simp_all)
huffman@25757
    93
huffman@16059
    94
subsection {* Properties of @{term spair} *}
huffman@16059
    95
huffman@16317
    96
lemma spair_strict1 [simp]: "(:\<bottom>, y:) = \<bottom>"
huffman@16920
    97
by (simp add: spair_Abs_Sprod strictify_conv_if cpair_strict Abs_Sprod_strict)
huffman@15576
    98
huffman@16317
    99
lemma spair_strict2 [simp]: "(:x, \<bottom>:) = \<bottom>"
huffman@16920
   100
by (simp add: spair_Abs_Sprod strictify_conv_if cpair_strict Abs_Sprod_strict)
huffman@15576
   101
huffman@16317
   102
lemma spair_strict: "x = \<bottom> \<or> y = \<bottom> \<Longrightarrow> (:x, y:) = \<bottom>"
huffman@16059
   103
by auto
huffman@16059
   104
huffman@16212
   105
lemma spair_strict_rev: "(:x, y:) \<noteq> \<bottom> \<Longrightarrow> x \<noteq> \<bottom> \<and> y \<noteq> \<bottom>"
huffman@16059
   106
by (erule contrapos_np, auto)
huffman@16059
   107
wenzelm@25135
   108
lemma spair_defined [simp]:
huffman@16317
   109
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<noteq> \<bottom>"
huffman@18078
   110
by (simp add: spair_Abs_Sprod Abs_Sprod_defined Sprod_def)
huffman@15576
   111
huffman@16317
   112
lemma spair_defined_rev: "(:x, y:) = \<bottom> \<Longrightarrow> x = \<bottom> \<or> y = \<bottom>"
huffman@16059
   113
by (erule contrapos_pp, simp)
huffman@15576
   114
huffman@16317
   115
lemma spair_eq:
huffman@16317
   116
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> ((:x, y:) = (:a, b:)) = (x = a \<and> y = b)"
huffman@16317
   117
apply (simp add: spair_Abs_Sprod)
huffman@16317
   118
apply (simp add: Abs_Sprod_inject [OF _ spair_lemma] Sprod_def)
huffman@16317
   119
apply (simp add: strictify_conv_if)
huffman@16317
   120
done
huffman@16317
   121
huffman@16212
   122
lemma spair_inject:
huffman@16317
   123
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>; (:x, y:) = (:a, b:)\<rbrakk> \<Longrightarrow> x = a \<and> y = b"
huffman@16317
   124
by (rule spair_eq [THEN iffD1])
huffman@15576
   125
huffman@15576
   126
lemma inst_sprod_pcpo2: "UU = (:UU,UU:)"
huffman@16059
   127
by simp
huffman@15576
   128
huffman@17837
   129
lemma Rep_Sprod_spair:
huffman@17837
   130
  "Rep_Sprod (:a, b:) = <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
huffman@17837
   131
apply (unfold spair_def)
huffman@17837
   132
apply (simp add: cont_Abs_Sprod Abs_Sprod_inverse spair_lemma)
huffman@17837
   133
done
huffman@17837
   134
huffman@16059
   135
subsection {* Properties of @{term sfst} and @{term ssnd} *}
huffman@15576
   136
huffman@16212
   137
lemma sfst_strict [simp]: "sfst\<cdot>\<bottom> = \<bottom>"
huffman@16212
   138
by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_strict)
huffman@15576
   139
huffman@16212
   140
lemma ssnd_strict [simp]: "ssnd\<cdot>\<bottom> = \<bottom>"
huffman@16212
   141
by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_strict)
huffman@15576
   142
huffman@16212
   143
lemma sfst_spair [simp]: "y \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>(:x, y:) = x"
huffman@16059
   144
by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_spair)
huffman@15576
   145
huffman@16212
   146
lemma ssnd_spair [simp]: "x \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>(:x, y:) = y"
huffman@16059
   147
by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_spair)
huffman@15576
   148
huffman@16777
   149
lemma sfst_defined_iff [simp]: "(sfst\<cdot>p = \<bottom>) = (p = \<bottom>)"
huffman@25757
   150
by (cases p, simp_all)
huffman@16777
   151
huffman@16777
   152
lemma ssnd_defined_iff [simp]: "(ssnd\<cdot>p = \<bottom>) = (p = \<bottom>)"
huffman@25757
   153
by (cases p, simp_all)
huffman@16317
   154
huffman@16777
   155
lemma sfst_defined: "p \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>p \<noteq> \<bottom>"
huffman@16777
   156
by simp
huffman@16777
   157
huffman@16777
   158
lemma ssnd_defined: "p \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>p \<noteq> \<bottom>"
huffman@16777
   159
by simp
huffman@16777
   160
huffman@16059
   161
lemma surjective_pairing_Sprod2: "(:sfst\<cdot>p, ssnd\<cdot>p:) = p"
huffman@25757
   162
by (cases p, simp_all)
huffman@15576
   163
huffman@16751
   164
lemma less_sprod: "x \<sqsubseteq> y = (sfst\<cdot>x \<sqsubseteq> sfst\<cdot>y \<and> ssnd\<cdot>x \<sqsubseteq> ssnd\<cdot>y)"
huffman@16699
   165
apply (simp add: less_Sprod_def sfst_def ssnd_def cont_Rep_Sprod)
huffman@16317
   166
apply (rule less_cprod)
huffman@16317
   167
done
huffman@16317
   168
huffman@16751
   169
lemma eq_sprod: "(x = y) = (sfst\<cdot>x = sfst\<cdot>y \<and> ssnd\<cdot>x = ssnd\<cdot>y)"
huffman@16751
   170
by (auto simp add: po_eq_conv less_sprod)
huffman@16751
   171
huffman@16317
   172
lemma spair_less:
huffman@16317
   173
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<sqsubseteq> (:a, b:) = (x \<sqsubseteq> a \<and> y \<sqsubseteq> b)"
huffman@25757
   174
apply (cases "a = \<bottom>", simp)
huffman@25757
   175
apply (cases "b = \<bottom>", simp)
huffman@16317
   176
apply (simp add: less_sprod)
huffman@16317
   177
done
huffman@16317
   178
huffman@25881
   179
lemma sfst_less_iff: "sfst\<cdot>x \<sqsubseteq> y = x \<sqsubseteq> (:y, ssnd\<cdot>x:)"
huffman@25881
   180
apply (cases "x = \<bottom>", simp, cases "y = \<bottom>", simp)
huffman@25881
   181
apply (simp add: less_sprod)
huffman@25881
   182
done
huffman@25881
   183
huffman@25881
   184
lemma ssnd_less_iff: "ssnd\<cdot>x \<sqsubseteq> y = x \<sqsubseteq> (:sfst\<cdot>x, y:)"
huffman@25881
   185
apply (cases "x = \<bottom>", simp, cases "y = \<bottom>", simp)
huffman@25881
   186
apply (simp add: less_sprod)
huffman@25881
   187
done
huffman@25881
   188
huffman@25881
   189
subsection {* Compactness *}
huffman@25881
   190
huffman@25881
   191
lemma compact_sfst: "compact x \<Longrightarrow> compact (sfst\<cdot>x)"
huffman@25881
   192
by (rule compactI, simp add: sfst_less_iff)
huffman@25881
   193
huffman@25881
   194
lemma compact_ssnd: "compact x \<Longrightarrow> compact (ssnd\<cdot>x)"
huffman@25881
   195
by (rule compactI, simp add: ssnd_less_iff)
huffman@25881
   196
huffman@25881
   197
lemma compact_spair: "\<lbrakk>compact x; compact y\<rbrakk> \<Longrightarrow> compact (:x, y:)"
huffman@25881
   198
by (rule compact_Sprod, simp add: Rep_Sprod_spair strictify_conv_if)
huffman@25881
   199
huffman@25881
   200
lemma compact_spair_iff:
huffman@25881
   201
  "compact (:x, y:) = (x = \<bottom> \<or> y = \<bottom> \<or> (compact x \<and> compact y))"
huffman@25881
   202
apply (safe elim!: compact_spair)
huffman@25881
   203
apply (drule compact_sfst, simp)
huffman@25881
   204
apply (drule compact_ssnd, simp)
huffman@25881
   205
apply simp
huffman@25881
   206
apply simp
huffman@25881
   207
done
huffman@25881
   208
huffman@16059
   209
subsection {* Properties of @{term ssplit} *}
huffman@15576
   210
huffman@16059
   211
lemma ssplit1 [simp]: "ssplit\<cdot>f\<cdot>\<bottom> = \<bottom>"
huffman@15591
   212
by (simp add: ssplit_def)
huffman@15591
   213
huffman@16920
   214
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
   215
by (simp add: ssplit_def)
huffman@15591
   216
huffman@16553
   217
lemma ssplit3 [simp]: "ssplit\<cdot>spair\<cdot>z = z"
huffman@25757
   218
by (cases z, simp_all)
huffman@15576
   219
huffman@25827
   220
subsection {* Strict product preserves flatness *}
huffman@25827
   221
huffman@25827
   222
instance "**" :: (flat, flat) flat
huffman@25827
   223
apply (intro_classes, clarify)
huffman@25827
   224
apply (rule_tac p=x in sprodE, simp)
huffman@25827
   225
apply (rule_tac p=y in sprodE, simp)
huffman@25827
   226
apply (simp add: flat_less_iff spair_less)
huffman@25827
   227
done
huffman@25827
   228
huffman@15576
   229
end