src/HOLCF/Sprod.thy
author wenzelm
Wed May 25 09:44:34 2005 +0200 (2005-05-25)
changeset 16070 4a83dd540b88
parent 16059 dab0d004732f
child 16082 ebb53ebfd4e2
permissions -rw-r--r--
removed LICENCE note -- everything is subject to Isabelle licence as
stated in COPYRIGHT file;
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@15591
    14
subsection {* Definition of strict product type *}
huffman@15591
    15
huffman@16059
    16
typedef (Sprod)  ('a, 'b) "**" (infixr 20) =
huffman@16059
    17
        "{p::'a \<times> 'b. p = \<bottom> \<or> (cfst\<cdot>p \<noteq> \<bottom> \<and> csnd\<cdot>p \<noteq> \<bottom>)}"
huffman@16059
    18
by (auto simp add: inst_cprod_pcpo)
huffman@15576
    19
huffman@15576
    20
syntax (xsymbols)
huffman@15576
    21
  "**"		:: "[type, type] => type"	 ("(_ \<otimes>/ _)" [21,20] 20)
huffman@15576
    22
syntax (HTML output)
huffman@15576
    23
  "**"		:: "[type, type] => type"	 ("(_ \<otimes>/ _)" [21,20] 20)
huffman@15576
    24
huffman@16059
    25
subsection {* Class instances *}
huffman@15576
    26
huffman@16059
    27
instance "**" :: (pcpo, pcpo) sq_ord ..
huffman@16059
    28
defs (overloaded)
huffman@16059
    29
  less_sprod_def: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep_Sprod x \<sqsubseteq> Rep_Sprod y"
huffman@15576
    30
huffman@16059
    31
lemma adm_Sprod: "adm (\<lambda>x. x \<in> Sprod)"
huffman@16059
    32
by (simp add: Sprod_def)
huffman@15576
    33
huffman@16059
    34
lemma UU_Sprod: "\<bottom> \<in> Sprod"
huffman@16059
    35
by (simp add: Sprod_def)
huffman@15576
    36
huffman@16059
    37
instance "**" :: (pcpo, pcpo) po
huffman@16059
    38
by (rule typedef_po [OF type_definition_Sprod less_sprod_def])
huffman@15576
    39
huffman@16059
    40
instance "**" :: (pcpo, pcpo) cpo
huffman@16059
    41
by (rule typedef_cpo [OF type_definition_Sprod less_sprod_def adm_Sprod])
huffman@15576
    42
huffman@16059
    43
instance "**" :: (pcpo, pcpo) pcpo
huffman@16059
    44
by (rule typedef_pcpo_UU [OF type_definition_Sprod less_sprod_def UU_Sprod])
huffman@15576
    45
huffman@16059
    46
lemmas cont_Rep_Sprod =
huffman@16059
    47
  typedef_cont_Rep [OF type_definition_Sprod less_sprod_def adm_Sprod]
huffman@15576
    48
huffman@16059
    49
lemmas cont_Abs_Sprod = 
huffman@16059
    50
  typedef_cont_Abs [OF type_definition_Sprod less_sprod_def adm_Sprod]
huffman@15576
    51
huffman@16059
    52
lemmas strict_Rep_Sprod =
huffman@16059
    53
  typedef_strict_Rep [OF type_definition_Sprod less_sprod_def UU_Sprod]
huffman@15576
    54
huffman@16059
    55
lemmas strict_Abs_Sprod =
huffman@16059
    56
  typedef_strict_Abs [OF type_definition_Sprod less_sprod_def UU_Sprod]
huffman@15576
    57
huffman@16059
    58
lemma UU_Abs_Sprod: "\<bottom> = Abs_Sprod <\<bottom>, \<bottom>>"
huffman@16059
    59
by (simp add: strict_Abs_Sprod inst_cprod_pcpo2 [symmetric])
huffman@15576
    60
huffman@16059
    61
lemma spair_lemma:
huffman@16059
    62
  "<strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a> \<in> Sprod"
huffman@16059
    63
apply (simp add: Sprod_def inst_cprod_pcpo2)
huffman@16059
    64
apply (case_tac "a = \<bottom>", case_tac [!] "b = \<bottom>", simp_all)
huffman@15576
    65
done
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@16059
   102
apply (simp add: strict_Abs_Sprod)
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@16059
   116
lemma strict_spair1 [simp]: "(:\<bottom>, b:) = \<bottom>"
huffman@16059
   117
apply (simp add: spair_Abs_Sprod UU_Abs_Sprod)
huffman@16059
   118
apply (case_tac "b = \<bottom>", simp_all)
huffman@15576
   119
done
huffman@15576
   120
huffman@16059
   121
lemma strict_spair2 [simp]: "(:a, \<bottom>:) = \<bottom>"
huffman@16059
   122
apply (simp add: spair_Abs_Sprod UU_Abs_Sprod)
huffman@16059
   123
apply (case_tac "a = \<bottom>", simp_all)
huffman@15576
   124
done
huffman@15576
   125
huffman@16059
   126
lemma strict_spair: "a = \<bottom> \<or> b = \<bottom> \<Longrightarrow> (:a, b:) = \<bottom>"
huffman@16059
   127
by auto
huffman@16059
   128
huffman@16059
   129
lemma strict_spair_rev: "(:x, y:) \<noteq> \<bottom> \<Longrightarrow> x \<noteq> \<bottom> \<and> y \<noteq> \<bottom>"
huffman@16059
   130
by (erule contrapos_np, auto)
huffman@16059
   131
huffman@16059
   132
lemma defined_spair [simp]: 
huffman@16059
   133
  "\<lbrakk>a \<noteq> \<bottom>; b \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:a, b:) \<noteq> \<bottom>"
huffman@16059
   134
apply (simp add: spair_Abs_Sprod UU_Abs_Sprod)
huffman@16059
   135
apply (subst Abs_Sprod_inject)
huffman@16059
   136
apply (simp add: Sprod_def)
huffman@16059
   137
apply (simp add: Sprod_def inst_cprod_pcpo2)
huffman@16059
   138
apply simp
huffman@15576
   139
done
huffman@15576
   140
huffman@16059
   141
lemma defined_spair_rev: "(:a, b:) = \<bottom> \<Longrightarrow> a = \<bottom> \<or> b = \<bottom>"
huffman@16059
   142
by (erule contrapos_pp, simp)
huffman@15576
   143
huffman@15576
   144
lemma inject_spair: 
huffman@16059
   145
  "\<lbrakk>aa \<noteq> \<bottom>; ba \<noteq> \<bottom>; (:a,b:) = (:aa,ba:)\<rbrakk> \<Longrightarrow> a = aa \<and> b = ba"
huffman@16059
   146
apply (simp add: spair_Abs_Sprod)
huffman@16059
   147
apply (simp add: Abs_Sprod_inject [OF spair_lemma] Sprod_def)
huffman@16059
   148
apply (case_tac "a = \<bottom>", simp_all)
huffman@16059
   149
apply (case_tac "b = \<bottom>", simp_all)
huffman@15576
   150
done
huffman@15576
   151
huffman@15576
   152
lemma inst_sprod_pcpo2: "UU = (:UU,UU:)"
huffman@16059
   153
by simp
huffman@15576
   154
huffman@16059
   155
subsection {* Properties of @{term sfst} and @{term ssnd} *}
huffman@15576
   156
huffman@16059
   157
lemma strict_sfst [simp]: "sfst\<cdot>\<bottom> = \<bottom>"
huffman@16059
   158
by (simp add: sfst_def cont_Rep_Sprod strict_Rep_Sprod)
huffman@15576
   159
huffman@16059
   160
lemma strict_ssnd [simp]: "ssnd\<cdot>\<bottom> = \<bottom>"
huffman@16059
   161
by (simp add: ssnd_def cont_Rep_Sprod strict_Rep_Sprod)
huffman@15576
   162
huffman@16059
   163
lemma Rep_Sprod_spair:
huffman@16059
   164
  "Rep_Sprod (:a, b:) = <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
huffman@15576
   165
apply (unfold spair_def)
huffman@16059
   166
apply (simp add: cont_Abs_Sprod Abs_Sprod_inverse spair_lemma)
huffman@15576
   167
done
huffman@15591
   168
huffman@16059
   169
lemma sfst2 [simp]: "y \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>(:x, y:) = x"
huffman@16059
   170
by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_spair)
huffman@15576
   171
huffman@16059
   172
lemma ssnd2 [simp]: "x \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>(:x, y:) = y"
huffman@16059
   173
by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_spair)
huffman@15576
   174
huffman@16059
   175
lemma defined_sfstssnd: "p \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>p \<noteq> \<bottom> \<and> ssnd\<cdot>p \<noteq> \<bottom>"
huffman@16059
   176
by (rule_tac p=p in sprodE, simp_all)
huffman@15576
   177
 
huffman@16059
   178
lemma surjective_pairing_Sprod2: "(:sfst\<cdot>p, ssnd\<cdot>p:) = p"
huffman@16059
   179
by (rule_tac p=p in sprodE, simp_all)
huffman@15576
   180
huffman@16059
   181
subsection {* Properties of @{term ssplit} *}
huffman@15576
   182
huffman@16059
   183
lemma ssplit1 [simp]: "ssplit\<cdot>f\<cdot>\<bottom> = \<bottom>"
huffman@15591
   184
by (simp add: ssplit_def)
huffman@15591
   185
huffman@16059
   186
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
   187
by (simp add: ssplit_def)
huffman@15591
   188
huffman@16059
   189
lemma ssplit3: "ssplit\<cdot>spair\<cdot>z = z"
huffman@16059
   190
by (rule_tac p=z in sprodE, simp_all)
huffman@15576
   191
huffman@15576
   192
end