src/HOLCF/Sprod.thy
author huffman
Thu May 26 02:24:08 2005 +0200 (2005-05-26)
changeset 16082 ebb53ebfd4e2
parent 16070 4a83dd540b88
child 16212 422f836f6b39
permissions -rw-r--r--
added defaultsort declaration
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@16059
    54
lemmas strict_Rep_Sprod =
huffman@16059
    55
  typedef_strict_Rep [OF type_definition_Sprod less_sprod_def UU_Sprod]
huffman@15576
    56
huffman@16059
    57
lemmas strict_Abs_Sprod =
huffman@16059
    58
  typedef_strict_Abs [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@16059
    61
by (simp add: strict_Abs_Sprod 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@16059
    65
apply (simp add: Sprod_def inst_cprod_pcpo2)
huffman@16059
    66
apply (case_tac "a = \<bottom>", case_tac [!] "b = \<bottom>", simp_all)
huffman@15576
    67
done
huffman@15576
    68
huffman@16059
    69
subsection {* Definitions of constants *}
huffman@15576
    70
huffman@16059
    71
consts
huffman@16059
    72
  sfst :: "('a ** 'b) \<rightarrow> 'a"
huffman@16059
    73
  ssnd :: "('a ** 'b) \<rightarrow> 'b"
huffman@16059
    74
  spair :: "'a \<rightarrow> 'b \<rightarrow> ('a ** 'b)"
huffman@16059
    75
  ssplit :: "('a \<rightarrow> 'b \<rightarrow> 'c) \<rightarrow> ('a ** 'b) \<rightarrow> 'c"
huffman@15576
    76
huffman@16059
    77
defs
huffman@16059
    78
  sfst_def: "sfst \<equiv> \<Lambda> p. cfst\<cdot>(Rep_Sprod p)"
huffman@16059
    79
  ssnd_def: "ssnd \<equiv> \<Lambda> p. csnd\<cdot>(Rep_Sprod p)"
huffman@16059
    80
  spair_def: "spair \<equiv> \<Lambda> a b. Abs_Sprod
huffman@16059
    81
                <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
huffman@16059
    82
  ssplit_def: "ssplit \<equiv> \<Lambda> f. strictify\<cdot>(\<Lambda> p. f\<cdot>(sfst\<cdot>p)\<cdot>(ssnd\<cdot>p))"
huffman@15576
    83
huffman@15576
    84
syntax  
huffman@15576
    85
  "@stuple"	:: "['a, args] => 'a ** 'b"	("(1'(:_,/ _:'))")
huffman@15576
    86
huffman@15576
    87
translations
huffman@15576
    88
        "(:x, y, z:)"   == "(:x, (:y, z:):)"
huffman@15576
    89
        "(:x, y:)"      == "spair$x$y"
huffman@15576
    90
huffman@16059
    91
subsection {* Case analysis *}
huffman@15576
    92
huffman@16059
    93
lemma spair_Abs_Sprod:
huffman@16059
    94
  "(:a, b:) = Abs_Sprod <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
huffman@16059
    95
apply (unfold spair_def)
huffman@16059
    96
apply (simp add: cont_Abs_Sprod spair_lemma)
huffman@15576
    97
done
huffman@15576
    98
huffman@16059
    99
lemma Exh_Sprod2:
huffman@16059
   100
  "z = \<bottom> \<or> (\<exists>a b. z = (:a, b:) \<and> a \<noteq> \<bottom> \<and> b \<noteq> \<bottom>)"
huffman@16059
   101
apply (rule_tac x=z in Abs_Sprod_cases)
huffman@16059
   102
apply (simp add: Sprod_def)
huffman@16059
   103
apply (erule disjE)
huffman@16059
   104
apply (simp add: strict_Abs_Sprod)
huffman@16059
   105
apply (rule disjI2)
huffman@16059
   106
apply (rule_tac x="cfst\<cdot>y" in exI)
huffman@16059
   107
apply (rule_tac x="csnd\<cdot>y" in exI)
huffman@16059
   108
apply (simp add: spair_Abs_Sprod Abs_Sprod_inject spair_lemma)
huffman@16059
   109
apply (simp add: surjective_pairing_Cprod2)
huffman@15576
   110
done
huffman@15576
   111
huffman@16059
   112
lemma sprodE:
huffman@16059
   113
  "\<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
   114
by (cut_tac z=p in Exh_Sprod2, auto)
huffman@16059
   115
huffman@16059
   116
subsection {* Properties of @{term spair} *}
huffman@16059
   117
huffman@16059
   118
lemma strict_spair1 [simp]: "(:\<bottom>, b:) = \<bottom>"
huffman@16059
   119
apply (simp add: spair_Abs_Sprod UU_Abs_Sprod)
huffman@16059
   120
apply (case_tac "b = \<bottom>", simp_all)
huffman@15576
   121
done
huffman@15576
   122
huffman@16059
   123
lemma strict_spair2 [simp]: "(:a, \<bottom>:) = \<bottom>"
huffman@16059
   124
apply (simp add: spair_Abs_Sprod UU_Abs_Sprod)
huffman@16059
   125
apply (case_tac "a = \<bottom>", simp_all)
huffman@15576
   126
done
huffman@15576
   127
huffman@16059
   128
lemma strict_spair: "a = \<bottom> \<or> b = \<bottom> \<Longrightarrow> (:a, b:) = \<bottom>"
huffman@16059
   129
by auto
huffman@16059
   130
huffman@16059
   131
lemma strict_spair_rev: "(:x, y:) \<noteq> \<bottom> \<Longrightarrow> x \<noteq> \<bottom> \<and> y \<noteq> \<bottom>"
huffman@16059
   132
by (erule contrapos_np, auto)
huffman@16059
   133
huffman@16059
   134
lemma defined_spair [simp]: 
huffman@16059
   135
  "\<lbrakk>a \<noteq> \<bottom>; b \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:a, b:) \<noteq> \<bottom>"
huffman@16059
   136
apply (simp add: spair_Abs_Sprod UU_Abs_Sprod)
huffman@16059
   137
apply (subst Abs_Sprod_inject)
huffman@16059
   138
apply (simp add: Sprod_def)
huffman@16059
   139
apply (simp add: Sprod_def inst_cprod_pcpo2)
huffman@16059
   140
apply simp
huffman@15576
   141
done
huffman@15576
   142
huffman@16059
   143
lemma defined_spair_rev: "(:a, b:) = \<bottom> \<Longrightarrow> a = \<bottom> \<or> b = \<bottom>"
huffman@16059
   144
by (erule contrapos_pp, simp)
huffman@15576
   145
huffman@15576
   146
lemma inject_spair: 
huffman@16059
   147
  "\<lbrakk>aa \<noteq> \<bottom>; ba \<noteq> \<bottom>; (:a,b:) = (:aa,ba:)\<rbrakk> \<Longrightarrow> a = aa \<and> b = ba"
huffman@16059
   148
apply (simp add: spair_Abs_Sprod)
huffman@16059
   149
apply (simp add: Abs_Sprod_inject [OF spair_lemma] Sprod_def)
huffman@16059
   150
apply (case_tac "a = \<bottom>", simp_all)
huffman@16059
   151
apply (case_tac "b = \<bottom>", simp_all)
huffman@15576
   152
done
huffman@15576
   153
huffman@15576
   154
lemma inst_sprod_pcpo2: "UU = (:UU,UU:)"
huffman@16059
   155
by simp
huffman@15576
   156
huffman@16059
   157
subsection {* Properties of @{term sfst} and @{term ssnd} *}
huffman@15576
   158
huffman@16059
   159
lemma strict_sfst [simp]: "sfst\<cdot>\<bottom> = \<bottom>"
huffman@16059
   160
by (simp add: sfst_def cont_Rep_Sprod strict_Rep_Sprod)
huffman@15576
   161
huffman@16059
   162
lemma strict_ssnd [simp]: "ssnd\<cdot>\<bottom> = \<bottom>"
huffman@16059
   163
by (simp add: ssnd_def cont_Rep_Sprod strict_Rep_Sprod)
huffman@15576
   164
huffman@16059
   165
lemma Rep_Sprod_spair:
huffman@16059
   166
  "Rep_Sprod (:a, b:) = <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
huffman@15576
   167
apply (unfold spair_def)
huffman@16059
   168
apply (simp add: cont_Abs_Sprod Abs_Sprod_inverse spair_lemma)
huffman@15576
   169
done
huffman@15591
   170
huffman@16059
   171
lemma sfst2 [simp]: "y \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>(:x, y:) = x"
huffman@16059
   172
by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_spair)
huffman@15576
   173
huffman@16059
   174
lemma ssnd2 [simp]: "x \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>(:x, y:) = y"
huffman@16059
   175
by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_spair)
huffman@15576
   176
huffman@16059
   177
lemma defined_sfstssnd: "p \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>p \<noteq> \<bottom> \<and> ssnd\<cdot>p \<noteq> \<bottom>"
huffman@16059
   178
by (rule_tac p=p in sprodE, simp_all)
huffman@15576
   179
 
huffman@16059
   180
lemma surjective_pairing_Sprod2: "(:sfst\<cdot>p, ssnd\<cdot>p:) = p"
huffman@16059
   181
by (rule_tac p=p in sprodE, simp_all)
huffman@15576
   182
huffman@16059
   183
subsection {* Properties of @{term ssplit} *}
huffman@15576
   184
huffman@16059
   185
lemma ssplit1 [simp]: "ssplit\<cdot>f\<cdot>\<bottom> = \<bottom>"
huffman@15591
   186
by (simp add: ssplit_def)
huffman@15591
   187
huffman@16059
   188
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
   189
by (simp add: ssplit_def)
huffman@15591
   190
huffman@16059
   191
lemma ssplit3: "ssplit\<cdot>spair\<cdot>z = z"
huffman@16059
   192
by (rule_tac p=z in sprodE, simp_all)
huffman@15576
   193
huffman@15576
   194
end