src/HOLCF/Sprod.thy
author wenzelm
Sun Oct 21 16:27:42 2007 +0200 (2007-10-21)
changeset 25135 4f8176c940cf
parent 25131 2c8caac48ade
child 25757 5957e3d72fec
permissions -rw-r--r--
modernized specifications ('definition', 'axiomatization');
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@15576
    22
syntax (xsymbols)
huffman@15576
    23
  "**"		:: "[type, type] => type"	 ("(_ \<otimes>/ _)" [21,20] 20)
huffman@15576
    24
syntax (HTML output)
huffman@15576
    25
  "**"		:: "[type, type] => type"	 ("(_ \<otimes>/ _)" [21,20] 20)
huffman@15576
    26
huffman@16059
    27
lemma spair_lemma:
huffman@16059
    28
  "<strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a> \<in> Sprod"
huffman@16212
    29
by (simp add: Sprod_def strictify_conv_if cpair_strict)
huffman@15576
    30
huffman@16059
    31
subsection {* Definitions of constants *}
huffman@15576
    32
wenzelm@25135
    33
definition
wenzelm@25135
    34
  sfst :: "('a ** 'b) \<rightarrow> 'a" where
wenzelm@25135
    35
  "sfst = (\<Lambda> p. cfst\<cdot>(Rep_Sprod p))"
wenzelm@25135
    36
wenzelm@25135
    37
definition
wenzelm@25135
    38
  ssnd :: "('a ** 'b) \<rightarrow> 'b" where
wenzelm@25135
    39
  "ssnd = (\<Lambda> p. csnd\<cdot>(Rep_Sprod p))"
huffman@15576
    40
wenzelm@25135
    41
definition
wenzelm@25135
    42
  spair :: "'a \<rightarrow> 'b \<rightarrow> ('a ** 'b)" where
wenzelm@25135
    43
  "spair = (\<Lambda> a b. Abs_Sprod
wenzelm@25135
    44
             <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>)"
huffman@15576
    45
wenzelm@25135
    46
definition
wenzelm@25135
    47
  ssplit :: "('a \<rightarrow> 'b \<rightarrow> 'c) \<rightarrow> ('a ** 'b) \<rightarrow> 'c" where
wenzelm@25135
    48
  "ssplit = (\<Lambda> f. strictify\<cdot>(\<Lambda> p. f\<cdot>(sfst\<cdot>p)\<cdot>(ssnd\<cdot>p)))"
wenzelm@25135
    49
wenzelm@25135
    50
syntax
huffman@18078
    51
  "@stuple" :: "['a, args] => 'a ** 'b"  ("(1'(:_,/ _:'))")
huffman@15576
    52
translations
huffman@18078
    53
  "(:x, y, z:)" == "(:x, (:y, z:):)"
wenzelm@25131
    54
  "(:x, y:)"    == "CONST spair\<cdot>x\<cdot>y"
huffman@18078
    55
huffman@18078
    56
translations
wenzelm@25131
    57
  "\<Lambda>(CONST spair\<cdot>x\<cdot>y). t" == "CONST ssplit\<cdot>(\<Lambda> x y. t)"
huffman@15576
    58
wenzelm@25135
    59
huffman@16059
    60
subsection {* Case analysis *}
huffman@15576
    61
huffman@16059
    62
lemma spair_Abs_Sprod:
huffman@16059
    63
  "(:a, b:) = Abs_Sprod <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
huffman@16059
    64
apply (unfold spair_def)
huffman@16059
    65
apply (simp add: cont_Abs_Sprod spair_lemma)
huffman@15576
    66
done
huffman@15576
    67
huffman@16059
    68
lemma Exh_Sprod2:
huffman@16059
    69
  "z = \<bottom> \<or> (\<exists>a b. z = (:a, b:) \<and> a \<noteq> \<bottom> \<and> b \<noteq> \<bottom>)"
huffman@16059
    70
apply (rule_tac x=z in Abs_Sprod_cases)
huffman@16059
    71
apply (simp add: Sprod_def)
huffman@16059
    72
apply (erule disjE)
huffman@16212
    73
apply (simp add: Abs_Sprod_strict)
huffman@16059
    74
apply (rule disjI2)
huffman@16059
    75
apply (rule_tac x="cfst\<cdot>y" in exI)
huffman@16059
    76
apply (rule_tac x="csnd\<cdot>y" in exI)
huffman@16059
    77
apply (simp add: spair_Abs_Sprod Abs_Sprod_inject spair_lemma)
huffman@16059
    78
apply (simp add: surjective_pairing_Cprod2)
huffman@15576
    79
done
huffman@15576
    80
huffman@16059
    81
lemma sprodE:
huffman@16059
    82
  "\<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
    83
by (cut_tac z=p in Exh_Sprod2, auto)
huffman@16059
    84
huffman@16059
    85
subsection {* Properties of @{term spair} *}
huffman@16059
    86
huffman@16317
    87
lemma spair_strict1 [simp]: "(:\<bottom>, y:) = \<bottom>"
huffman@16920
    88
by (simp add: spair_Abs_Sprod strictify_conv_if cpair_strict Abs_Sprod_strict)
huffman@15576
    89
huffman@16317
    90
lemma spair_strict2 [simp]: "(:x, \<bottom>:) = \<bottom>"
huffman@16920
    91
by (simp add: spair_Abs_Sprod strictify_conv_if cpair_strict Abs_Sprod_strict)
huffman@15576
    92
huffman@16317
    93
lemma spair_strict: "x = \<bottom> \<or> y = \<bottom> \<Longrightarrow> (:x, y:) = \<bottom>"
huffman@16059
    94
by auto
huffman@16059
    95
huffman@16212
    96
lemma spair_strict_rev: "(:x, y:) \<noteq> \<bottom> \<Longrightarrow> x \<noteq> \<bottom> \<and> y \<noteq> \<bottom>"
huffman@16059
    97
by (erule contrapos_np, auto)
huffman@16059
    98
wenzelm@25135
    99
lemma spair_defined [simp]:
huffman@16317
   100
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<noteq> \<bottom>"
huffman@18078
   101
by (simp add: spair_Abs_Sprod Abs_Sprod_defined Sprod_def)
huffman@15576
   102
huffman@16317
   103
lemma spair_defined_rev: "(:x, y:) = \<bottom> \<Longrightarrow> x = \<bottom> \<or> y = \<bottom>"
huffman@16059
   104
by (erule contrapos_pp, simp)
huffman@15576
   105
huffman@16317
   106
lemma spair_eq:
huffman@16317
   107
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> ((:x, y:) = (:a, b:)) = (x = a \<and> y = b)"
huffman@16317
   108
apply (simp add: spair_Abs_Sprod)
huffman@16317
   109
apply (simp add: Abs_Sprod_inject [OF _ spair_lemma] Sprod_def)
huffman@16317
   110
apply (simp add: strictify_conv_if)
huffman@16317
   111
done
huffman@16317
   112
huffman@16212
   113
lemma spair_inject:
huffman@16317
   114
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>; (:x, y:) = (:a, b:)\<rbrakk> \<Longrightarrow> x = a \<and> y = b"
huffman@16317
   115
by (rule spair_eq [THEN iffD1])
huffman@15576
   116
huffman@15576
   117
lemma inst_sprod_pcpo2: "UU = (:UU,UU:)"
huffman@16059
   118
by simp
huffman@15576
   119
huffman@17837
   120
lemma Rep_Sprod_spair:
huffman@17837
   121
  "Rep_Sprod (:a, b:) = <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
huffman@17837
   122
apply (unfold spair_def)
huffman@17837
   123
apply (simp add: cont_Abs_Sprod Abs_Sprod_inverse spair_lemma)
huffman@17837
   124
done
huffman@17837
   125
huffman@17837
   126
lemma compact_spair: "\<lbrakk>compact x; compact y\<rbrakk> \<Longrightarrow> compact (:x, y:)"
huffman@17837
   127
by (rule compact_Sprod, simp add: Rep_Sprod_spair strictify_conv_if)
huffman@17837
   128
huffman@16059
   129
subsection {* Properties of @{term sfst} and @{term ssnd} *}
huffman@15576
   130
huffman@16212
   131
lemma sfst_strict [simp]: "sfst\<cdot>\<bottom> = \<bottom>"
huffman@16212
   132
by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_strict)
huffman@15576
   133
huffman@16212
   134
lemma ssnd_strict [simp]: "ssnd\<cdot>\<bottom> = \<bottom>"
huffman@16212
   135
by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_strict)
huffman@15576
   136
huffman@16212
   137
lemma sfst_spair [simp]: "y \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>(:x, y:) = x"
huffman@16059
   138
by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_spair)
huffman@15576
   139
huffman@16212
   140
lemma ssnd_spair [simp]: "x \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>(:x, y:) = y"
huffman@16059
   141
by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_spair)
huffman@15576
   142
huffman@16777
   143
lemma sfst_defined_iff [simp]: "(sfst\<cdot>p = \<bottom>) = (p = \<bottom>)"
huffman@16777
   144
by (rule_tac p=p in sprodE, simp_all)
huffman@16777
   145
huffman@16777
   146
lemma ssnd_defined_iff [simp]: "(ssnd\<cdot>p = \<bottom>) = (p = \<bottom>)"
huffman@16059
   147
by (rule_tac p=p in sprodE, simp_all)
huffman@16317
   148
huffman@16777
   149
lemma sfst_defined: "p \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>p \<noteq> \<bottom>"
huffman@16777
   150
by simp
huffman@16777
   151
huffman@16777
   152
lemma ssnd_defined: "p \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>p \<noteq> \<bottom>"
huffman@16777
   153
by simp
huffman@16777
   154
huffman@16059
   155
lemma surjective_pairing_Sprod2: "(:sfst\<cdot>p, ssnd\<cdot>p:) = p"
huffman@16059
   156
by (rule_tac p=p in sprodE, simp_all)
huffman@15576
   157
huffman@16751
   158
lemma less_sprod: "x \<sqsubseteq> y = (sfst\<cdot>x \<sqsubseteq> sfst\<cdot>y \<and> ssnd\<cdot>x \<sqsubseteq> ssnd\<cdot>y)"
huffman@16699
   159
apply (simp add: less_Sprod_def sfst_def ssnd_def cont_Rep_Sprod)
huffman@16317
   160
apply (rule less_cprod)
huffman@16317
   161
done
huffman@16317
   162
huffman@16751
   163
lemma eq_sprod: "(x = y) = (sfst\<cdot>x = sfst\<cdot>y \<and> ssnd\<cdot>x = ssnd\<cdot>y)"
huffman@16751
   164
by (auto simp add: po_eq_conv less_sprod)
huffman@16751
   165
huffman@16317
   166
lemma spair_less:
huffman@16317
   167
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<sqsubseteq> (:a, b:) = (x \<sqsubseteq> a \<and> y \<sqsubseteq> b)"
huffman@16317
   168
apply (case_tac "a = \<bottom>")
huffman@16317
   169
apply (simp add: eq_UU_iff [symmetric])
huffman@16317
   170
apply (case_tac "b = \<bottom>")
huffman@16317
   171
apply (simp add: eq_UU_iff [symmetric])
huffman@16317
   172
apply (simp add: less_sprod)
huffman@16317
   173
done
huffman@16317
   174
huffman@16317
   175
huffman@16059
   176
subsection {* Properties of @{term ssplit} *}
huffman@15576
   177
huffman@16059
   178
lemma ssplit1 [simp]: "ssplit\<cdot>f\<cdot>\<bottom> = \<bottom>"
huffman@15591
   179
by (simp add: ssplit_def)
huffman@15591
   180
huffman@16920
   181
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
   182
by (simp add: ssplit_def)
huffman@15591
   183
huffman@16553
   184
lemma ssplit3 [simp]: "ssplit\<cdot>spair\<cdot>z = z"
huffman@16059
   185
by (rule_tac p=z in sprodE, simp_all)
huffman@15576
   186
huffman@15576
   187
end