src/HOLCF/Sprod.thy
author huffman
Fri Jan 04 00:01:02 2008 +0100 (2008-01-04)
changeset 25827 c2adeb1bae5c
parent 25757 5957e3d72fec
child 25881 d80bd899ea95
permissions -rw-r--r--
new instance proofs for classes finite_po, chfin, flat
     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 instance "**" :: ("{finite_po,pcpo}", "{finite_po,pcpo}") finite_po
    23 by (rule typedef_finite_po [OF type_definition_Sprod])
    24 
    25 instance "**" :: ("{chfin,pcpo}", "{chfin,pcpo}") chfin
    26 by (rule typedef_chfin [OF type_definition_Sprod less_Sprod_def])
    27 
    28 syntax (xsymbols)
    29   "**"		:: "[type, type] => type"	 ("(_ \<otimes>/ _)" [21,20] 20)
    30 syntax (HTML output)
    31   "**"		:: "[type, type] => type"	 ("(_ \<otimes>/ _)" [21,20] 20)
    32 
    33 lemma spair_lemma:
    34   "<strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a> \<in> Sprod"
    35 by (simp add: Sprod_def strictify_conv_if cpair_strict)
    36 
    37 subsection {* Definitions of constants *}
    38 
    39 definition
    40   sfst :: "('a ** 'b) \<rightarrow> 'a" where
    41   "sfst = (\<Lambda> p. cfst\<cdot>(Rep_Sprod p))"
    42 
    43 definition
    44   ssnd :: "('a ** 'b) \<rightarrow> 'b" where
    45   "ssnd = (\<Lambda> p. csnd\<cdot>(Rep_Sprod p))"
    46 
    47 definition
    48   spair :: "'a \<rightarrow> 'b \<rightarrow> ('a ** 'b)" where
    49   "spair = (\<Lambda> a b. Abs_Sprod
    50              <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>)"
    51 
    52 definition
    53   ssplit :: "('a \<rightarrow> 'b \<rightarrow> 'c) \<rightarrow> ('a ** 'b) \<rightarrow> 'c" where
    54   "ssplit = (\<Lambda> f. strictify\<cdot>(\<Lambda> p. f\<cdot>(sfst\<cdot>p)\<cdot>(ssnd\<cdot>p)))"
    55 
    56 syntax
    57   "@stuple" :: "['a, args] => 'a ** 'b"  ("(1'(:_,/ _:'))")
    58 translations
    59   "(:x, y, z:)" == "(:x, (:y, z:):)"
    60   "(:x, y:)"    == "CONST spair\<cdot>x\<cdot>y"
    61 
    62 translations
    63   "\<Lambda>(CONST spair\<cdot>x\<cdot>y). t" == "CONST ssplit\<cdot>(\<Lambda> x y. t)"
    64 
    65 
    66 subsection {* Case analysis *}
    67 
    68 lemma spair_Abs_Sprod:
    69   "(:a, b:) = Abs_Sprod <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
    70 apply (unfold spair_def)
    71 apply (simp add: cont_Abs_Sprod spair_lemma)
    72 done
    73 
    74 lemma Exh_Sprod2:
    75   "z = \<bottom> \<or> (\<exists>a b. z = (:a, b:) \<and> a \<noteq> \<bottom> \<and> b \<noteq> \<bottom>)"
    76 apply (cases z rule: Abs_Sprod_cases)
    77 apply (simp add: Sprod_def)
    78 apply (erule disjE)
    79 apply (simp add: Abs_Sprod_strict)
    80 apply (rule disjI2)
    81 apply (rule_tac x="cfst\<cdot>y" in exI)
    82 apply (rule_tac x="csnd\<cdot>y" in exI)
    83 apply (simp add: spair_Abs_Sprod Abs_Sprod_inject spair_lemma)
    84 apply (simp add: surjective_pairing_Cprod2)
    85 done
    86 
    87 lemma sprodE [cases type: **]:
    88   "\<lbrakk>p = \<bottom> \<Longrightarrow> Q; \<And>x y. \<lbrakk>p = (:x, y:); x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
    89 by (cut_tac z=p in Exh_Sprod2, auto)
    90 
    91 lemma sprod_induct [induct type: **]:
    92   "\<lbrakk>P \<bottom>; \<And>x y. \<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> P (:x, y:)\<rbrakk> \<Longrightarrow> P x"
    93 by (cases x, simp_all)
    94 
    95 subsection {* Properties of @{term spair} *}
    96 
    97 lemma spair_strict1 [simp]: "(:\<bottom>, y:) = \<bottom>"
    98 by (simp add: spair_Abs_Sprod strictify_conv_if cpair_strict Abs_Sprod_strict)
    99 
   100 lemma spair_strict2 [simp]: "(:x, \<bottom>:) = \<bottom>"
   101 by (simp add: spair_Abs_Sprod strictify_conv_if cpair_strict Abs_Sprod_strict)
   102 
   103 lemma spair_strict: "x = \<bottom> \<or> y = \<bottom> \<Longrightarrow> (:x, y:) = \<bottom>"
   104 by auto
   105 
   106 lemma spair_strict_rev: "(:x, y:) \<noteq> \<bottom> \<Longrightarrow> x \<noteq> \<bottom> \<and> y \<noteq> \<bottom>"
   107 by (erule contrapos_np, auto)
   108 
   109 lemma spair_defined [simp]:
   110   "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<noteq> \<bottom>"
   111 by (simp add: spair_Abs_Sprod Abs_Sprod_defined Sprod_def)
   112 
   113 lemma spair_defined_rev: "(:x, y:) = \<bottom> \<Longrightarrow> x = \<bottom> \<or> y = \<bottom>"
   114 by (erule contrapos_pp, simp)
   115 
   116 lemma spair_eq:
   117   "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> ((:x, y:) = (:a, b:)) = (x = a \<and> y = b)"
   118 apply (simp add: spair_Abs_Sprod)
   119 apply (simp add: Abs_Sprod_inject [OF _ spair_lemma] Sprod_def)
   120 apply (simp add: strictify_conv_if)
   121 done
   122 
   123 lemma spair_inject:
   124   "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>; (:x, y:) = (:a, b:)\<rbrakk> \<Longrightarrow> x = a \<and> y = b"
   125 by (rule spair_eq [THEN iffD1])
   126 
   127 lemma inst_sprod_pcpo2: "UU = (:UU,UU:)"
   128 by simp
   129 
   130 lemma Rep_Sprod_spair:
   131   "Rep_Sprod (:a, b:) = <strictify\<cdot>(\<Lambda> b. a)\<cdot>b, strictify\<cdot>(\<Lambda> a. b)\<cdot>a>"
   132 apply (unfold spair_def)
   133 apply (simp add: cont_Abs_Sprod Abs_Sprod_inverse spair_lemma)
   134 done
   135 
   136 lemma compact_spair: "\<lbrakk>compact x; compact y\<rbrakk> \<Longrightarrow> compact (:x, y:)"
   137 by (rule compact_Sprod, simp add: Rep_Sprod_spair strictify_conv_if)
   138 
   139 subsection {* Properties of @{term sfst} and @{term ssnd} *}
   140 
   141 lemma sfst_strict [simp]: "sfst\<cdot>\<bottom> = \<bottom>"
   142 by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_strict)
   143 
   144 lemma ssnd_strict [simp]: "ssnd\<cdot>\<bottom> = \<bottom>"
   145 by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_strict)
   146 
   147 lemma sfst_spair [simp]: "y \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>(:x, y:) = x"
   148 by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_spair)
   149 
   150 lemma ssnd_spair [simp]: "x \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>(:x, y:) = y"
   151 by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_spair)
   152 
   153 lemma sfst_defined_iff [simp]: "(sfst\<cdot>p = \<bottom>) = (p = \<bottom>)"
   154 by (cases p, simp_all)
   155 
   156 lemma ssnd_defined_iff [simp]: "(ssnd\<cdot>p = \<bottom>) = (p = \<bottom>)"
   157 by (cases p, simp_all)
   158 
   159 lemma sfst_defined: "p \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>p \<noteq> \<bottom>"
   160 by simp
   161 
   162 lemma ssnd_defined: "p \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>p \<noteq> \<bottom>"
   163 by simp
   164 
   165 lemma surjective_pairing_Sprod2: "(:sfst\<cdot>p, ssnd\<cdot>p:) = p"
   166 by (cases p, simp_all)
   167 
   168 lemma less_sprod: "x \<sqsubseteq> y = (sfst\<cdot>x \<sqsubseteq> sfst\<cdot>y \<and> ssnd\<cdot>x \<sqsubseteq> ssnd\<cdot>y)"
   169 apply (simp add: less_Sprod_def sfst_def ssnd_def cont_Rep_Sprod)
   170 apply (rule less_cprod)
   171 done
   172 
   173 lemma eq_sprod: "(x = y) = (sfst\<cdot>x = sfst\<cdot>y \<and> ssnd\<cdot>x = ssnd\<cdot>y)"
   174 by (auto simp add: po_eq_conv less_sprod)
   175 
   176 lemma spair_less:
   177   "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<sqsubseteq> (:a, b:) = (x \<sqsubseteq> a \<and> y \<sqsubseteq> b)"
   178 apply (cases "a = \<bottom>", simp)
   179 apply (cases "b = \<bottom>", simp)
   180 apply (simp add: less_sprod)
   181 done
   182 
   183 subsection {* Properties of @{term ssplit} *}
   184 
   185 lemma ssplit1 [simp]: "ssplit\<cdot>f\<cdot>\<bottom> = \<bottom>"
   186 by (simp add: ssplit_def)
   187 
   188 lemma ssplit2 [simp]: "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> ssplit\<cdot>f\<cdot>(:x, y:) = f\<cdot>x\<cdot>y"
   189 by (simp add: ssplit_def)
   190 
   191 lemma ssplit3 [simp]: "ssplit\<cdot>spair\<cdot>z = z"
   192 by (cases z, simp_all)
   193 
   194 subsection {* Strict product preserves flatness *}
   195 
   196 instance "**" :: (flat, flat) flat
   197 apply (intro_classes, clarify)
   198 apply (rule_tac p=x in sprodE, simp)
   199 apply (rule_tac p=y in sprodE, simp)
   200 apply (simp add: flat_less_iff spair_less)
   201 done
   202 
   203 end