src/HOLCF/Sprod.thy
author huffman
Wed Jun 08 00:18:26 2005 +0200 (2005-06-08)
changeset 16317 868eddbcaf6e
parent 16212 422f836f6b39
child 16553 aa36d41e4263
permissions -rw-r--r--
added theorems less_sprod, spair_less, spair_eq, spair_inject
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@16059
    11
imports Cprod TypedefPcpo
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@16059
    18
typedef (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@16059
    20
by (auto simp add: inst_cprod_pcpo)
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
subsection {* Class instances *}
huffman@15576
    28
huffman@16059
    29
instance "**" :: (pcpo, pcpo) sq_ord ..
huffman@16059
    30
defs (overloaded)
huffman@16059
    31
  less_sprod_def: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep_Sprod x \<sqsubseteq> Rep_Sprod y"
huffman@15576
    32
huffman@16059
    33
lemma adm_Sprod: "adm (\<lambda>x. x \<in> Sprod)"
huffman@16059
    34
by (simp add: Sprod_def)
huffman@15576
    35
huffman@16059
    36
lemma UU_Sprod: "\<bottom> \<in> Sprod"
huffman@16059
    37
by (simp add: Sprod_def)
huffman@15576
    38
huffman@16059
    39
instance "**" :: (pcpo, pcpo) po
huffman@16059
    40
by (rule typedef_po [OF type_definition_Sprod less_sprod_def])
huffman@15576
    41
huffman@16059
    42
instance "**" :: (pcpo, pcpo) cpo
huffman@16059
    43
by (rule typedef_cpo [OF type_definition_Sprod less_sprod_def adm_Sprod])
huffman@15576
    44
huffman@16059
    45
instance "**" :: (pcpo, pcpo) pcpo
huffman@16059
    46
by (rule typedef_pcpo_UU [OF type_definition_Sprod less_sprod_def UU_Sprod])
huffman@15576
    47
huffman@16059
    48
lemmas cont_Rep_Sprod =
huffman@16059
    49
  typedef_cont_Rep [OF type_definition_Sprod less_sprod_def adm_Sprod]
huffman@15576
    50
huffman@16059
    51
lemmas cont_Abs_Sprod = 
huffman@16059
    52
  typedef_cont_Abs [OF type_definition_Sprod less_sprod_def adm_Sprod]
huffman@15576
    53
huffman@16212
    54
lemmas Rep_Sprod_strict =
huffman@16212
    55
  typedef_Rep_strict [OF type_definition_Sprod less_sprod_def UU_Sprod]
huffman@15576
    56
huffman@16212
    57
lemmas Abs_Sprod_strict =
huffman@16212
    58
  typedef_Abs_strict [OF type_definition_Sprod less_sprod_def UU_Sprod]
huffman@15576
    59
huffman@16059
    60
lemma UU_Abs_Sprod: "\<bottom> = Abs_Sprod <\<bottom>, \<bottom>>"
huffman@16212
    61
by (simp add: Abs_Sprod_strict inst_cprod_pcpo2 [symmetric])
huffman@15576
    62
huffman@16059
    63
lemma spair_lemma:
huffman@16059
    64
  "<strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a> \<in> Sprod"
huffman@16212
    65
by (simp add: Sprod_def strictify_conv_if cpair_strict)
huffman@15576
    66
huffman@16059
    67
subsection {* Definitions of constants *}
huffman@15576
    68
huffman@16059
    69
consts
huffman@16059
    70
  sfst :: "('a ** 'b) \<rightarrow> 'a"
huffman@16059
    71
  ssnd :: "('a ** 'b) \<rightarrow> 'b"
huffman@16059
    72
  spair :: "'a \<rightarrow> 'b \<rightarrow> ('a ** 'b)"
huffman@16059
    73
  ssplit :: "('a \<rightarrow> 'b \<rightarrow> 'c) \<rightarrow> ('a ** 'b) \<rightarrow> 'c"
huffman@15576
    74
huffman@16059
    75
defs
huffman@16059
    76
  sfst_def: "sfst \<equiv> \<Lambda> p. cfst\<cdot>(Rep_Sprod p)"
huffman@16059
    77
  ssnd_def: "ssnd \<equiv> \<Lambda> p. csnd\<cdot>(Rep_Sprod p)"
huffman@16059
    78
  spair_def: "spair \<equiv> \<Lambda> a b. Abs_Sprod
huffman@16059
    79
                <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
huffman@16059
    80
  ssplit_def: "ssplit \<equiv> \<Lambda> f. strictify\<cdot>(\<Lambda> p. f\<cdot>(sfst\<cdot>p)\<cdot>(ssnd\<cdot>p))"
huffman@15576
    81
huffman@15576
    82
syntax  
huffman@15576
    83
  "@stuple"	:: "['a, args] => 'a ** 'b"	("(1'(:_,/ _:'))")
huffman@15576
    84
huffman@15576
    85
translations
huffman@15576
    86
        "(:x, y, z:)"   == "(:x, (:y, z:):)"
huffman@15576
    87
        "(:x, y:)"      == "spair$x$y"
huffman@15576
    88
huffman@16059
    89
subsection {* Case analysis *}
huffman@15576
    90
huffman@16059
    91
lemma spair_Abs_Sprod:
huffman@16059
    92
  "(:a, b:) = Abs_Sprod <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
huffman@16059
    93
apply (unfold spair_def)
huffman@16059
    94
apply (simp add: cont_Abs_Sprod spair_lemma)
huffman@15576
    95
done
huffman@15576
    96
huffman@16059
    97
lemma Exh_Sprod2:
huffman@16059
    98
  "z = \<bottom> \<or> (\<exists>a b. z = (:a, b:) \<and> a \<noteq> \<bottom> \<and> b \<noteq> \<bottom>)"
huffman@16059
    99
apply (rule_tac x=z in Abs_Sprod_cases)
huffman@16059
   100
apply (simp add: Sprod_def)
huffman@16059
   101
apply (erule disjE)
huffman@16212
   102
apply (simp add: Abs_Sprod_strict)
huffman@16059
   103
apply (rule disjI2)
huffman@16059
   104
apply (rule_tac x="cfst\<cdot>y" in exI)
huffman@16059
   105
apply (rule_tac x="csnd\<cdot>y" in exI)
huffman@16059
   106
apply (simp add: spair_Abs_Sprod Abs_Sprod_inject spair_lemma)
huffman@16059
   107
apply (simp add: surjective_pairing_Cprod2)
huffman@15576
   108
done
huffman@15576
   109
huffman@16059
   110
lemma sprodE:
huffman@16059
   111
  "\<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
   112
by (cut_tac z=p in Exh_Sprod2, auto)
huffman@16059
   113
huffman@16059
   114
subsection {* Properties of @{term spair} *}
huffman@16059
   115
huffman@16317
   116
lemma spair_strict1 [simp]: "(:\<bottom>, y:) = \<bottom>"
huffman@16212
   117
by (simp add: spair_Abs_Sprod UU_Abs_Sprod strictify_conv_if)
huffman@15576
   118
huffman@16317
   119
lemma spair_strict2 [simp]: "(:x, \<bottom>:) = \<bottom>"
huffman@16212
   120
by (simp add: spair_Abs_Sprod UU_Abs_Sprod strictify_conv_if)
huffman@15576
   121
huffman@16317
   122
lemma spair_strict: "x = \<bottom> \<or> y = \<bottom> \<Longrightarrow> (:x, y:) = \<bottom>"
huffman@16059
   123
by auto
huffman@16059
   124
huffman@16212
   125
lemma spair_strict_rev: "(:x, y:) \<noteq> \<bottom> \<Longrightarrow> x \<noteq> \<bottom> \<and> y \<noteq> \<bottom>"
huffman@16059
   126
by (erule contrapos_np, auto)
huffman@16059
   127
huffman@16212
   128
lemma spair_defined [simp]: 
huffman@16317
   129
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<noteq> \<bottom>"
huffman@16059
   130
apply (simp add: spair_Abs_Sprod UU_Abs_Sprod)
huffman@16059
   131
apply (subst Abs_Sprod_inject)
huffman@16059
   132
apply (simp add: Sprod_def)
huffman@16059
   133
apply (simp add: Sprod_def inst_cprod_pcpo2)
huffman@16059
   134
apply simp
huffman@15576
   135
done
huffman@15576
   136
huffman@16317
   137
lemma spair_defined_rev: "(:x, y:) = \<bottom> \<Longrightarrow> x = \<bottom> \<or> y = \<bottom>"
huffman@16059
   138
by (erule contrapos_pp, simp)
huffman@15576
   139
huffman@16317
   140
lemma spair_eq:
huffman@16317
   141
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> ((:x, y:) = (:a, b:)) = (x = a \<and> y = b)"
huffman@16317
   142
apply (simp add: spair_Abs_Sprod)
huffman@16317
   143
apply (simp add: Abs_Sprod_inject [OF _ spair_lemma] Sprod_def)
huffman@16317
   144
apply (simp add: strictify_conv_if)
huffman@16317
   145
done
huffman@16317
   146
huffman@16212
   147
lemma spair_inject:
huffman@16317
   148
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>; (:x, y:) = (:a, b:)\<rbrakk> \<Longrightarrow> x = a \<and> y = b"
huffman@16317
   149
by (rule spair_eq [THEN iffD1])
huffman@15576
   150
huffman@15576
   151
lemma inst_sprod_pcpo2: "UU = (:UU,UU:)"
huffman@16059
   152
by simp
huffman@15576
   153
huffman@16059
   154
subsection {* Properties of @{term sfst} and @{term ssnd} *}
huffman@15576
   155
huffman@16212
   156
lemma sfst_strict [simp]: "sfst\<cdot>\<bottom> = \<bottom>"
huffman@16212
   157
by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_strict)
huffman@15576
   158
huffman@16212
   159
lemma ssnd_strict [simp]: "ssnd\<cdot>\<bottom> = \<bottom>"
huffman@16212
   160
by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_strict)
huffman@15576
   161
huffman@16059
   162
lemma Rep_Sprod_spair:
huffman@16059
   163
  "Rep_Sprod (:a, b:) = <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
huffman@15576
   164
apply (unfold spair_def)
huffman@16059
   165
apply (simp add: cont_Abs_Sprod Abs_Sprod_inverse spair_lemma)
huffman@15576
   166
done
huffman@15591
   167
huffman@16212
   168
lemma sfst_spair [simp]: "y \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>(:x, y:) = x"
huffman@16059
   169
by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_spair)
huffman@15576
   170
huffman@16212
   171
lemma ssnd_spair [simp]: "x \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>(:x, y:) = y"
huffman@16059
   172
by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_spair)
huffman@15576
   173
huffman@16212
   174
lemma sfstssnd_defined: "p \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>p \<noteq> \<bottom> \<and> ssnd\<cdot>p \<noteq> \<bottom>"
huffman@16059
   175
by (rule_tac p=p in sprodE, simp_all)
huffman@16317
   176
huffman@16059
   177
lemma surjective_pairing_Sprod2: "(:sfst\<cdot>p, ssnd\<cdot>p:) = p"
huffman@16059
   178
by (rule_tac p=p in sprodE, simp_all)
huffman@15576
   179
huffman@16317
   180
lemma less_sprod: "p1 \<sqsubseteq> p2 = (sfst\<cdot>p1 \<sqsubseteq> sfst\<cdot>p2 \<and> ssnd\<cdot>p1 \<sqsubseteq> ssnd\<cdot>p2)"
huffman@16317
   181
apply (simp add: less_sprod_def sfst_def ssnd_def cont_Rep_Sprod)
huffman@16317
   182
apply (rule less_cprod)
huffman@16317
   183
done
huffman@16317
   184
huffman@16317
   185
lemma spair_less:
huffman@16317
   186
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<sqsubseteq> (:a, b:) = (x \<sqsubseteq> a \<and> y \<sqsubseteq> b)"
huffman@16317
   187
apply (case_tac "a = \<bottom>")
huffman@16317
   188
apply (simp add: eq_UU_iff [symmetric])
huffman@16317
   189
apply (case_tac "b = \<bottom>")
huffman@16317
   190
apply (simp add: eq_UU_iff [symmetric])
huffman@16317
   191
apply (simp add: less_sprod)
huffman@16317
   192
done
huffman@16317
   193
huffman@16317
   194
huffman@16059
   195
subsection {* Properties of @{term ssplit} *}
huffman@15576
   196
huffman@16059
   197
lemma ssplit1 [simp]: "ssplit\<cdot>f\<cdot>\<bottom> = \<bottom>"
huffman@15591
   198
by (simp add: ssplit_def)
huffman@15591
   199
huffman@16059
   200
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
   201
by (simp add: ssplit_def)
huffman@15591
   202
huffman@16059
   203
lemma ssplit3: "ssplit\<cdot>spair\<cdot>z = z"
huffman@16059
   204
by (rule_tac p=z in sprodE, simp_all)
huffman@15576
   205
huffman@15576
   206
end