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