src/HOLCF/Sprod.thy
author huffman
Wed Jul 06 00:07:34 2005 +0200 (2005-07-06)
changeset 16699 24b494ff8f0f
parent 16553 aa36d41e4263
child 16751 7af6723ad741
permissions -rw-r--r--
use new pcpodef package
     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 UU_Abs_Sprod: "\<bottom> = Abs_Sprod <\<bottom>, \<bottom>>"
    28 by (simp add: Abs_Sprod_strict inst_cprod_pcpo2 [symmetric])
    29 
    30 lemma spair_lemma:
    31   "<strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a> \<in> Sprod"
    32 by (simp add: Sprod_def strictify_conv_if cpair_strict)
    33 
    34 subsection {* Definitions of constants *}
    35 
    36 consts
    37   sfst :: "('a ** 'b) \<rightarrow> 'a"
    38   ssnd :: "('a ** 'b) \<rightarrow> 'b"
    39   spair :: "'a \<rightarrow> 'b \<rightarrow> ('a ** 'b)"
    40   ssplit :: "('a \<rightarrow> 'b \<rightarrow> 'c) \<rightarrow> ('a ** 'b) \<rightarrow> 'c"
    41 
    42 defs
    43   sfst_def: "sfst \<equiv> \<Lambda> p. cfst\<cdot>(Rep_Sprod p)"
    44   ssnd_def: "ssnd \<equiv> \<Lambda> p. csnd\<cdot>(Rep_Sprod p)"
    45   spair_def: "spair \<equiv> \<Lambda> a b. Abs_Sprod
    46                 <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
    47   ssplit_def: "ssplit \<equiv> \<Lambda> f. strictify\<cdot>(\<Lambda> p. f\<cdot>(sfst\<cdot>p)\<cdot>(ssnd\<cdot>p))"
    48 
    49 syntax  
    50   "@stuple"	:: "['a, args] => 'a ** 'b"	("(1'(:_,/ _:'))")
    51 
    52 translations
    53         "(:x, y, z:)"   == "(:x, (:y, z:):)"
    54         "(:x, y:)"      == "spair$x$y"
    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 UU_Abs_Sprod strictify_conv_if)
    85 
    86 lemma spair_strict2 [simp]: "(:x, \<bottom>:) = \<bottom>"
    87 by (simp add: spair_Abs_Sprod UU_Abs_Sprod strictify_conv_if)
    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 apply (simp add: spair_Abs_Sprod UU_Abs_Sprod)
    98 apply (subst Abs_Sprod_inject)
    99 apply (simp add: Sprod_def)
   100 apply (simp add: Sprod_def inst_cprod_pcpo2)
   101 apply simp
   102 done
   103 
   104 lemma spair_defined_rev: "(:x, y:) = \<bottom> \<Longrightarrow> x = \<bottom> \<or> y = \<bottom>"
   105 by (erule contrapos_pp, simp)
   106 
   107 lemma spair_eq:
   108   "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> ((:x, y:) = (:a, b:)) = (x = a \<and> y = b)"
   109 apply (simp add: spair_Abs_Sprod)
   110 apply (simp add: Abs_Sprod_inject [OF _ spair_lemma] Sprod_def)
   111 apply (simp add: strictify_conv_if)
   112 done
   113 
   114 lemma spair_inject:
   115   "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>; (:x, y:) = (:a, b:)\<rbrakk> \<Longrightarrow> x = a \<and> y = b"
   116 by (rule spair_eq [THEN iffD1])
   117 
   118 lemma inst_sprod_pcpo2: "UU = (:UU,UU:)"
   119 by simp
   120 
   121 subsection {* Properties of @{term sfst} and @{term ssnd} *}
   122 
   123 lemma sfst_strict [simp]: "sfst\<cdot>\<bottom> = \<bottom>"
   124 by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_strict)
   125 
   126 lemma ssnd_strict [simp]: "ssnd\<cdot>\<bottom> = \<bottom>"
   127 by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_strict)
   128 
   129 lemma Rep_Sprod_spair:
   130   "Rep_Sprod (:a, b:) = <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
   131 apply (unfold spair_def)
   132 apply (simp add: cont_Abs_Sprod Abs_Sprod_inverse spair_lemma)
   133 done
   134 
   135 lemma sfst_spair [simp]: "y \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>(:x, y:) = x"
   136 by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_spair)
   137 
   138 lemma ssnd_spair [simp]: "x \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>(:x, y:) = y"
   139 by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_spair)
   140 
   141 lemma sfstssnd_defined: "p \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>p \<noteq> \<bottom> \<and> ssnd\<cdot>p \<noteq> \<bottom>"
   142 by (rule_tac p=p in sprodE, simp_all)
   143 
   144 lemma surjective_pairing_Sprod2: "(:sfst\<cdot>p, ssnd\<cdot>p:) = p"
   145 by (rule_tac p=p in sprodE, simp_all)
   146 
   147 lemma less_sprod: "p1 \<sqsubseteq> p2 = (sfst\<cdot>p1 \<sqsubseteq> sfst\<cdot>p2 \<and> ssnd\<cdot>p1 \<sqsubseteq> ssnd\<cdot>p2)"
   148 apply (simp add: less_Sprod_def sfst_def ssnd_def cont_Rep_Sprod)
   149 apply (rule less_cprod)
   150 done
   151 
   152 lemma spair_less:
   153   "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<sqsubseteq> (:a, b:) = (x \<sqsubseteq> a \<and> y \<sqsubseteq> b)"
   154 apply (case_tac "a = \<bottom>")
   155 apply (simp add: eq_UU_iff [symmetric])
   156 apply (case_tac "b = \<bottom>")
   157 apply (simp add: eq_UU_iff [symmetric])
   158 apply (simp add: less_sprod)
   159 done
   160 
   161 
   162 subsection {* Properties of @{term ssplit} *}
   163 
   164 lemma ssplit1 [simp]: "ssplit\<cdot>f\<cdot>\<bottom> = \<bottom>"
   165 by (simp add: ssplit_def)
   166 
   167 lemma ssplit2 [simp]: "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> ssplit\<cdot>f\<cdot>(:x, y:)= f\<cdot>x\<cdot>y"
   168 by (simp add: ssplit_def)
   169 
   170 lemma ssplit3 [simp]: "ssplit\<cdot>spair\<cdot>z = z"
   171 by (rule_tac p=z in sprodE, simp_all)
   172 
   173 end