src/HOL/HOLCF/Sprod.thy
author kuncar
Fri Dec 09 18:07:04 2011 +0100 (2011-12-09)
changeset 45802 b16f976db515
parent 45695 b108b3d7c49e
child 49759 ecf1d5d87e5e
permissions -rw-r--r--
Quotient_Info stores only relation maps
     1 (*  Title:      HOL/HOLCF/Sprod.thy
     2     Author:     Franz Regensburger
     3     Author:     Brian Huffman
     4 *)
     5 
     6 header {* The type of strict products *}
     7 
     8 theory Sprod
     9 imports Cfun
    10 begin
    11 
    12 default_sort pcpo
    13 
    14 subsection {* Definition of strict product type *}
    15 
    16 definition "sprod = {p::'a \<times> 'b. p = \<bottom> \<or> (fst p \<noteq> \<bottom> \<and> snd p \<noteq> \<bottom>)}"
    17 
    18 pcpodef (open) ('a, 'b) sprod (infixr "**" 20) = "sprod :: ('a \<times> 'b) set"
    19   unfolding sprod_def by simp_all
    20 
    21 instance sprod :: ("{chfin,pcpo}", "{chfin,pcpo}") chfin
    22 by (rule typedef_chfin [OF type_definition_sprod below_sprod_def])
    23 
    24 type_notation (xsymbols)
    25   sprod  ("(_ \<otimes>/ _)" [21,20] 20)
    26 type_notation (HTML output)
    27   sprod  ("(_ \<otimes>/ _)" [21,20] 20)
    28 
    29 subsection {* Definitions of constants *}
    30 
    31 definition
    32   sfst :: "('a ** 'b) \<rightarrow> 'a" where
    33   "sfst = (\<Lambda> p. fst (Rep_sprod p))"
    34 
    35 definition
    36   ssnd :: "('a ** 'b) \<rightarrow> 'b" where
    37   "ssnd = (\<Lambda> p. snd (Rep_sprod p))"
    38 
    39 definition
    40   spair :: "'a \<rightarrow> 'b \<rightarrow> ('a ** 'b)" where
    41   "spair = (\<Lambda> a b. Abs_sprod (seq\<cdot>b\<cdot>a, seq\<cdot>a\<cdot>b))"
    42 
    43 definition
    44   ssplit :: "('a \<rightarrow> 'b \<rightarrow> 'c) \<rightarrow> ('a ** 'b) \<rightarrow> 'c" where
    45   "ssplit = (\<Lambda> f p. seq\<cdot>p\<cdot>(f\<cdot>(sfst\<cdot>p)\<cdot>(ssnd\<cdot>p)))"
    46 
    47 syntax
    48   "_stuple" :: "[logic, args] \<Rightarrow> logic"  ("(1'(:_,/ _:'))")
    49 
    50 translations
    51   "(:x, y, z:)" == "(:x, (:y, z:):)"
    52   "(:x, y:)"    == "CONST spair\<cdot>x\<cdot>y"
    53 
    54 translations
    55   "\<Lambda>(CONST spair\<cdot>x\<cdot>y). t" == "CONST ssplit\<cdot>(\<Lambda> x y. t)"
    56 
    57 subsection {* Case analysis *}
    58 
    59 lemma spair_sprod: "(seq\<cdot>b\<cdot>a, seq\<cdot>a\<cdot>b) \<in> sprod"
    60 by (simp add: sprod_def seq_conv_if)
    61 
    62 lemma Rep_sprod_spair: "Rep_sprod (:a, b:) = (seq\<cdot>b\<cdot>a, seq\<cdot>a\<cdot>b)"
    63 by (simp add: spair_def cont_Abs_sprod Abs_sprod_inverse spair_sprod)
    64 
    65 lemmas Rep_sprod_simps =
    66   Rep_sprod_inject [symmetric] below_sprod_def
    67   prod_eq_iff below_prod_def
    68   Rep_sprod_strict Rep_sprod_spair
    69 
    70 lemma sprodE [case_names bottom spair, cases type: sprod]:
    71   obtains "p = \<bottom>" | x y where "p = (:x, y:)" and "x \<noteq> \<bottom>" and "y \<noteq> \<bottom>"
    72 using Rep_sprod [of p] by (auto simp add: sprod_def Rep_sprod_simps)
    73 
    74 lemma sprod_induct [case_names bottom spair, induct type: sprod]:
    75   "\<lbrakk>P \<bottom>; \<And>x y. \<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> P (:x, y:)\<rbrakk> \<Longrightarrow> P x"
    76 by (cases x, simp_all)
    77 
    78 subsection {* Properties of \emph{spair} *}
    79 
    80 lemma spair_strict1 [simp]: "(:\<bottom>, y:) = \<bottom>"
    81 by (simp add: Rep_sprod_simps)
    82 
    83 lemma spair_strict2 [simp]: "(:x, \<bottom>:) = \<bottom>"
    84 by (simp add: Rep_sprod_simps)
    85 
    86 lemma spair_bottom_iff [simp]: "((:x, y:) = \<bottom>) = (x = \<bottom> \<or> y = \<bottom>)"
    87 by (simp add: Rep_sprod_simps seq_conv_if)
    88 
    89 lemma spair_below_iff:
    90   "((:a, b:) \<sqsubseteq> (:c, d:)) = (a = \<bottom> \<or> b = \<bottom> \<or> (a \<sqsubseteq> c \<and> b \<sqsubseteq> d))"
    91 by (simp add: Rep_sprod_simps seq_conv_if)
    92 
    93 lemma spair_eq_iff:
    94   "((:a, b:) = (:c, d:)) =
    95     (a = c \<and> b = d \<or> (a = \<bottom> \<or> b = \<bottom>) \<and> (c = \<bottom> \<or> d = \<bottom>))"
    96 by (simp add: Rep_sprod_simps seq_conv_if)
    97 
    98 lemma spair_strict: "x = \<bottom> \<or> y = \<bottom> \<Longrightarrow> (:x, y:) = \<bottom>"
    99 by simp
   100 
   101 lemma spair_strict_rev: "(:x, y:) \<noteq> \<bottom> \<Longrightarrow> x \<noteq> \<bottom> \<and> y \<noteq> \<bottom>"
   102 by simp
   103 
   104 lemma spair_defined: "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<noteq> \<bottom>"
   105 by simp
   106 
   107 lemma spair_defined_rev: "(:x, y:) = \<bottom> \<Longrightarrow> x = \<bottom> \<or> y = \<bottom>"
   108 by simp
   109 
   110 lemma spair_below:
   111   "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<sqsubseteq> (:a, b:) = (x \<sqsubseteq> a \<and> y \<sqsubseteq> b)"
   112 by (simp add: spair_below_iff)
   113 
   114 lemma spair_eq:
   115   "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> ((:x, y:) = (:a, b:)) = (x = a \<and> y = b)"
   116 by (simp add: spair_eq_iff)
   117 
   118 lemma spair_inject:
   119   "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>; (:x, y:) = (:a, b:)\<rbrakk> \<Longrightarrow> x = a \<and> y = b"
   120 by (rule spair_eq [THEN iffD1])
   121 
   122 lemma inst_sprod_pcpo2: "\<bottom> = (:\<bottom>, \<bottom>:)"
   123 by simp
   124 
   125 lemma sprodE2: "(\<And>x y. p = (:x, y:) \<Longrightarrow> Q) \<Longrightarrow> Q"
   126 by (cases p, simp only: inst_sprod_pcpo2, simp)
   127 
   128 subsection {* Properties of \emph{sfst} and \emph{ssnd} *}
   129 
   130 lemma sfst_strict [simp]: "sfst\<cdot>\<bottom> = \<bottom>"
   131 by (simp add: sfst_def cont_Rep_sprod Rep_sprod_strict)
   132 
   133 lemma ssnd_strict [simp]: "ssnd\<cdot>\<bottom> = \<bottom>"
   134 by (simp add: ssnd_def cont_Rep_sprod Rep_sprod_strict)
   135 
   136 lemma sfst_spair [simp]: "y \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>(:x, y:) = x"
   137 by (simp add: sfst_def cont_Rep_sprod Rep_sprod_spair)
   138 
   139 lemma ssnd_spair [simp]: "x \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>(:x, y:) = y"
   140 by (simp add: ssnd_def cont_Rep_sprod Rep_sprod_spair)
   141 
   142 lemma sfst_bottom_iff [simp]: "(sfst\<cdot>p = \<bottom>) = (p = \<bottom>)"
   143 by (cases p, simp_all)
   144 
   145 lemma ssnd_bottom_iff [simp]: "(ssnd\<cdot>p = \<bottom>) = (p = \<bottom>)"
   146 by (cases p, simp_all)
   147 
   148 lemma sfst_defined: "p \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>p \<noteq> \<bottom>"
   149 by simp
   150 
   151 lemma ssnd_defined: "p \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>p \<noteq> \<bottom>"
   152 by simp
   153 
   154 lemma spair_sfst_ssnd: "(:sfst\<cdot>p, ssnd\<cdot>p:) = p"
   155 by (cases p, simp_all)
   156 
   157 lemma below_sprod: "(x \<sqsubseteq> y) = (sfst\<cdot>x \<sqsubseteq> sfst\<cdot>y \<and> ssnd\<cdot>x \<sqsubseteq> ssnd\<cdot>y)"
   158 by (simp add: Rep_sprod_simps sfst_def ssnd_def cont_Rep_sprod)
   159 
   160 lemma eq_sprod: "(x = y) = (sfst\<cdot>x = sfst\<cdot>y \<and> ssnd\<cdot>x = ssnd\<cdot>y)"
   161 by (auto simp add: po_eq_conv below_sprod)
   162 
   163 lemma sfst_below_iff: "sfst\<cdot>x \<sqsubseteq> y \<longleftrightarrow> x \<sqsubseteq> (:y, ssnd\<cdot>x:)"
   164 apply (cases "x = \<bottom>", simp, cases "y = \<bottom>", simp)
   165 apply (simp add: below_sprod)
   166 done
   167 
   168 lemma ssnd_below_iff: "ssnd\<cdot>x \<sqsubseteq> y \<longleftrightarrow> x \<sqsubseteq> (:sfst\<cdot>x, y:)"
   169 apply (cases "x = \<bottom>", simp, cases "y = \<bottom>", simp)
   170 apply (simp add: below_sprod)
   171 done
   172 
   173 subsection {* Compactness *}
   174 
   175 lemma compact_sfst: "compact x \<Longrightarrow> compact (sfst\<cdot>x)"
   176 by (rule compactI, simp add: sfst_below_iff)
   177 
   178 lemma compact_ssnd: "compact x \<Longrightarrow> compact (ssnd\<cdot>x)"
   179 by (rule compactI, simp add: ssnd_below_iff)
   180 
   181 lemma compact_spair: "\<lbrakk>compact x; compact y\<rbrakk> \<Longrightarrow> compact (:x, y:)"
   182 by (rule compact_sprod, simp add: Rep_sprod_spair seq_conv_if)
   183 
   184 lemma compact_spair_iff:
   185   "compact (:x, y:) = (x = \<bottom> \<or> y = \<bottom> \<or> (compact x \<and> compact y))"
   186 apply (safe elim!: compact_spair)
   187 apply (drule compact_sfst, simp)
   188 apply (drule compact_ssnd, simp)
   189 apply simp
   190 apply simp
   191 done
   192 
   193 subsection {* Properties of \emph{ssplit} *}
   194 
   195 lemma ssplit1 [simp]: "ssplit\<cdot>f\<cdot>\<bottom> = \<bottom>"
   196 by (simp add: ssplit_def)
   197 
   198 lemma ssplit2 [simp]: "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> ssplit\<cdot>f\<cdot>(:x, y:) = f\<cdot>x\<cdot>y"
   199 by (simp add: ssplit_def)
   200 
   201 lemma ssplit3 [simp]: "ssplit\<cdot>spair\<cdot>z = z"
   202 by (cases z, simp_all)
   203 
   204 subsection {* Strict product preserves flatness *}
   205 
   206 instance sprod :: (flat, flat) flat
   207 proof
   208   fix x y :: "'a \<otimes> 'b"
   209   assume "x \<sqsubseteq> y" thus "x = \<bottom> \<or> x = y"
   210     apply (induct x, simp)
   211     apply (induct y, simp)
   212     apply (simp add: spair_below_iff flat_below_iff)
   213     done
   214 qed
   215 
   216 end