(* Title: HOLCF/Sprod.thy ID: $Id: Sprod.thy,v 1.25 2008/05/19 21:49:21 huffman Exp $ Author: Franz Regensburger and Brian Huffman Strict product with typedef. *) header {* The type of strict products *} theory Sprod imports Cprod begin defaultsort pcpo subsection {* Definition of strict product type *} pcpodef (Sprod) ('a, 'b) "**" (infixr "**" 20) = "{p::'a × 'b. p = ⊥ ∨ (cfst·p ≠ ⊥ ∧ csnd·p ≠ ⊥)}" by simp instance "**" :: ("{finite_po,pcpo}", "{finite_po,pcpo}") finite_po by (rule typedef_finite_po [OF type_definition_Sprod]) instance "**" :: ("{chfin,pcpo}", "{chfin,pcpo}") chfin by (rule typedef_chfin [OF type_definition_Sprod less_Sprod_def]) syntax (xsymbols) "**" :: "[type, type] => type" ("(_ ⊗/ _)" [21,20] 20) syntax (HTML output) "**" :: "[type, type] => type" ("(_ ⊗/ _)" [21,20] 20) lemma spair_lemma: "<strictify·(Λ b. a)·b, strictify·(Λ a. b)·a> ∈ Sprod" by (simp add: Sprod_def strictify_conv_if) subsection {* Definitions of constants *} definition sfst :: "('a ** 'b) -> 'a" where "sfst = (Λ p. cfst·(Rep_Sprod p))" definition ssnd :: "('a ** 'b) -> 'b" where "ssnd = (Λ p. csnd·(Rep_Sprod p))" definition spair :: "'a -> 'b -> ('a ** 'b)" where "spair = (Λ a b. Abs_Sprod <strictify·(Λ b. a)·b, strictify·(Λ a. b)·a>)" definition ssplit :: "('a -> 'b -> 'c) -> ('a ** 'b) -> 'c" where "ssplit = (Λ f. strictify·(Λ p. f·(sfst·p)·(ssnd·p)))" syntax "@stuple" :: "['a, args] => 'a ** 'b" ("(1'(:_,/ _:'))") translations "(:x, y, z:)" == "(:x, (:y, z:):)" "(:x, y:)" == "CONST spair·x·y" translations "Λ(CONST spair·x·y). t" == "CONST ssplit·(Λ x y. t)" subsection {* Case analysis *} lemma Rep_Sprod_spair: "Rep_Sprod (:a, b:) = <strictify·(Λ b. a)·b, strictify·(Λ a. b)·a>" unfolding spair_def by (simp add: cont_Abs_Sprod Abs_Sprod_inverse spair_lemma) lemmas Rep_Sprod_simps = Rep_Sprod_inject [symmetric] less_Sprod_def Rep_Sprod_strict Rep_Sprod_spair lemma Exh_Sprod2: "z = ⊥ ∨ (∃a b. z = (:a, b:) ∧ a ≠ ⊥ ∧ b ≠ ⊥)" apply (insert Rep_Sprod [of z]) apply (simp add: Rep_Sprod_simps eq_cprod) apply (simp add: Sprod_def) apply (erule disjE, simp) apply (simp add: strictify_conv_if) apply fast done lemma sprodE [cases type: **]: "[|p = ⊥ ==> Q; !!x y. [|p = (:x, y:); x ≠ ⊥; y ≠ ⊥|] ==> Q|] ==> Q" by (cut_tac z=p in Exh_Sprod2, auto) lemma sprod_induct [induct type: **]: "[|P ⊥; !!x y. [|x ≠ ⊥; y ≠ ⊥|] ==> P (:x, y:)|] ==> P x" by (cases x, simp_all) subsection {* Properties of @{term spair} *} lemma spair_strict1 [simp]: "(:⊥, y:) = ⊥" by (simp add: Rep_Sprod_simps strictify_conv_if) lemma spair_strict2 [simp]: "(:x, ⊥:) = ⊥" by (simp add: Rep_Sprod_simps strictify_conv_if) lemma spair_strict_iff [simp]: "((:x, y:) = ⊥) = (x = ⊥ ∨ y = ⊥)" by (simp add: Rep_Sprod_simps strictify_conv_if) lemma spair_less_iff: "((:a, b:) \<sqsubseteq> (:c, d:)) = (a = ⊥ ∨ b = ⊥ ∨ (a \<sqsubseteq> c ∧ b \<sqsubseteq> d))" by (simp add: Rep_Sprod_simps strictify_conv_if) lemma spair_eq_iff: "((:a, b:) = (:c, d:)) = (a = c ∧ b = d ∨ (a = ⊥ ∨ b = ⊥) ∧ (c = ⊥ ∨ d = ⊥))" by (simp add: Rep_Sprod_simps strictify_conv_if) lemma spair_strict: "x = ⊥ ∨ y = ⊥ ==> (:x, y:) = ⊥" by simp lemma spair_strict_rev: "(:x, y:) ≠ ⊥ ==> x ≠ ⊥ ∧ y ≠ ⊥" by simp lemma spair_defined: "[|x ≠ ⊥; y ≠ ⊥|] ==> (:x, y:) ≠ ⊥" by simp lemma spair_defined_rev: "(:x, y:) = ⊥ ==> x = ⊥ ∨ y = ⊥" by simp lemma spair_eq: "[|x ≠ ⊥; y ≠ ⊥|] ==> ((:x, y:) = (:a, b:)) = (x = a ∧ y = b)" by (simp add: spair_eq_iff) lemma spair_inject: "[|x ≠ ⊥; y ≠ ⊥; (:x, y:) = (:a, b:)|] ==> x = a ∧ y = b" by (rule spair_eq [THEN iffD1]) lemma inst_sprod_pcpo2: "UU = (:UU,UU:)" by simp subsection {* Properties of @{term sfst} and @{term ssnd} *} lemma sfst_strict [simp]: "sfst·⊥ = ⊥" by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_strict) lemma ssnd_strict [simp]: "ssnd·⊥ = ⊥" by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_strict) lemma sfst_spair [simp]: "y ≠ ⊥ ==> sfst·(:x, y:) = x" by (simp add: sfst_def cont_Rep_Sprod Rep_Sprod_spair) lemma ssnd_spair [simp]: "x ≠ ⊥ ==> ssnd·(:x, y:) = y" by (simp add: ssnd_def cont_Rep_Sprod Rep_Sprod_spair) lemma sfst_defined_iff [simp]: "(sfst·p = ⊥) = (p = ⊥)" by (cases p, simp_all) lemma ssnd_defined_iff [simp]: "(ssnd·p = ⊥) = (p = ⊥)" by (cases p, simp_all) lemma sfst_defined: "p ≠ ⊥ ==> sfst·p ≠ ⊥" by simp lemma ssnd_defined: "p ≠ ⊥ ==> ssnd·p ≠ ⊥" by simp lemma surjective_pairing_Sprod2: "(:sfst·p, ssnd·p:) = p" by (cases p, simp_all) lemma less_sprod: "x \<sqsubseteq> y = (sfst·x \<sqsubseteq> sfst·y ∧ ssnd·x \<sqsubseteq> ssnd·y)" apply (simp add: less_Sprod_def sfst_def ssnd_def cont_Rep_Sprod) apply (rule less_cprod) done lemma eq_sprod: "(x = y) = (sfst·x = sfst·y ∧ ssnd·x = ssnd·y)" by (auto simp add: po_eq_conv less_sprod) lemma spair_less: "[|x ≠ ⊥; y ≠ ⊥|] ==> (:x, y:) \<sqsubseteq> (:a, b:) = (x \<sqsubseteq> a ∧ y \<sqsubseteq> b)" apply (cases "a = ⊥", simp) apply (cases "b = ⊥", simp) apply (simp add: less_sprod) done lemma sfst_less_iff: "sfst·x \<sqsubseteq> y = x \<sqsubseteq> (:y, ssnd·x:)" apply (cases "x = ⊥", simp, cases "y = ⊥", simp) apply (simp add: less_sprod) done lemma ssnd_less_iff: "ssnd·x \<sqsubseteq> y = x \<sqsubseteq> (:sfst·x, y:)" apply (cases "x = ⊥", simp, cases "y = ⊥", simp) apply (simp add: less_sprod) done subsection {* Compactness *} lemma compact_sfst: "compact x ==> compact (sfst·x)" by (rule compactI, simp add: sfst_less_iff) lemma compact_ssnd: "compact x ==> compact (ssnd·x)" by (rule compactI, simp add: ssnd_less_iff) lemma compact_spair: "[|compact x; compact y|] ==> compact (:x, y:)" by (rule compact_Sprod, simp add: Rep_Sprod_spair strictify_conv_if) lemma compact_spair_iff: "compact (:x, y:) = (x = ⊥ ∨ y = ⊥ ∨ (compact x ∧ compact y))" apply (safe elim!: compact_spair) apply (drule compact_sfst, simp) apply (drule compact_ssnd, simp) apply simp apply simp done subsection {* Properties of @{term ssplit} *} lemma ssplit1 [simp]: "ssplit·f·⊥ = ⊥" by (simp add: ssplit_def) lemma ssplit2 [simp]: "[|x ≠ ⊥; y ≠ ⊥|] ==> ssplit·f·(:x, y:) = f·x·y" by (simp add: ssplit_def) lemma ssplit3 [simp]: "ssplit·spair·z = z" by (cases z, simp_all) subsection {* Strict product preserves flatness *} instance "**" :: (flat, flat) flat apply (intro_classes, clarify) apply (rule_tac p=x in sprodE, simp) apply (rule_tac p=y in sprodE, simp) apply (simp add: flat_less_iff spair_less) done subsection {* Strict product is a bifinite domain *} instantiation "**" :: (bifinite, bifinite) bifinite begin definition approx_sprod_def: "approx = (λn. Λ(:x, y:). (:approx n·x, approx n·y:))" instance proof fix i :: nat and x :: "'a ⊗ 'b" show "chain (λi. approx i·x)" unfolding approx_sprod_def by simp show "(\<Squnion>i. approx i·x) = x" unfolding approx_sprod_def by (simp add: lub_distribs eta_cfun) show "approx i·(approx i·x) = approx i·x" unfolding approx_sprod_def by (simp add: ssplit_def strictify_conv_if) have "Rep_Sprod ` {x::'a ⊗ 'b. approx i·x = x} ⊆ {x. approx i·x = x}" unfolding approx_sprod_def apply (clarify, rule_tac p=x in sprodE) apply (simp add: Rep_Sprod_strict) apply (simp add: Rep_Sprod_spair spair_eq_iff) done hence "finite (Rep_Sprod ` {x::'a ⊗ 'b. approx i·x = x})" using finite_fixes_approx by (rule finite_subset) thus "finite {x::'a ⊗ 'b. approx i·x = x}" by (rule finite_imageD, simp add: inj_on_def Rep_Sprod_inject) qed end lemma approx_spair [simp]: "approx i·(:x, y:) = (:approx i·x, approx i·y:)" unfolding approx_sprod_def by (simp add: ssplit_def strictify_conv_if) end
lemma spair_lemma:
<strictify·(LAM b. a)·b, strictify·(LAM a. b)·a> ∈ Sprod
lemma Rep_Sprod_spair:
Rep_Sprod (:a, b:) = <strictify·(LAM b. a)·b, strictify·(LAM a. b)·a>
lemma Rep_Sprod_simps:
(x = y) = (Rep_Sprod x = Rep_Sprod y)
op << == λx y. Rep_Sprod x << Rep_Sprod y
Rep_Sprod UU = UU
Rep_Sprod (:a, b:) = <strictify·(LAM b. a)·b, strictify·(LAM a. b)·a>
lemma Exh_Sprod2:
z = UU ∨ (∃a b. z = (:a, b:) ∧ a ≠ UU ∧ b ≠ UU)
lemma sprodE:
[| p = UU ==> Q; !!x y. [| p = (:x, y:); x ≠ UU; y ≠ UU |] ==> Q |] ==> Q
lemma sprod_induct:
[| P UU; !!x y. [| x ≠ UU; y ≠ UU |] ==> P (:x, y:) |] ==> P x
lemma spair_strict1:
(:UU, y:) = UU
lemma spair_strict2:
(:x, UU:) = UU
lemma spair_strict_iff:
((:x, y:) = UU) = (x = UU ∨ y = UU)
lemma spair_less_iff:
(:a, b:) << (:c, d:) = (a = UU ∨ b = UU ∨ a << c ∧ b << d)
lemma spair_eq_iff:
((:a, b:) = (:c, d:)) = (a = c ∧ b = d ∨ (a = UU ∨ b = UU) ∧ (c = UU ∨ d = UU))
lemma spair_strict:
x = UU ∨ y = UU ==> (:x, y:) = UU
lemma spair_strict_rev:
(:x, y:) ≠ UU ==> x ≠ UU ∧ y ≠ UU
lemma spair_defined:
[| x ≠ UU; y ≠ UU |] ==> (:x, y:) ≠ UU
lemma spair_defined_rev:
(:x, y:) = UU ==> x = UU ∨ y = UU
lemma spair_eq:
[| x ≠ UU; y ≠ UU |] ==> ((:x, y:) = (:a, b:)) = (x = a ∧ y = b)
lemma spair_inject:
[| x ≠ UU; y ≠ UU; (:x, y:) = (:a, b:) |] ==> x = a ∧ y = b
lemma inst_sprod_pcpo2:
UU = (:UU, UU:)
lemma sfst_strict:
sfst·UU = UU
lemma ssnd_strict:
ssnd·UU = UU
lemma sfst_spair:
y ≠ UU ==> sfst·(:x, y:) = x
lemma ssnd_spair:
x ≠ UU ==> ssnd·(:x, y:) = y
lemma sfst_defined_iff:
(sfst·p = UU) = (p = UU)
lemma ssnd_defined_iff:
(ssnd·p = UU) = (p = UU)
lemma sfst_defined:
p ≠ UU ==> sfst·p ≠ UU
lemma ssnd_defined:
p ≠ UU ==> ssnd·p ≠ UU
lemma surjective_pairing_Sprod2:
(:sfst·p, ssnd·p:) = p
lemma less_sprod:
x << y = (sfst·x << sfst·y ∧ ssnd·x << ssnd·y)
lemma eq_sprod:
(x = y) = (sfst·x = sfst·y ∧ ssnd·x = ssnd·y)
lemma spair_less:
[| x ≠ UU; y ≠ UU |] ==> (:x, y:) << (:a, b:) = (x << a ∧ y << b)
lemma sfst_less_iff:
sfst·x << y = x << (:y, ssnd·x:)
lemma ssnd_less_iff:
ssnd·x << y = x << (:sfst·x, y:)
lemma compact_sfst:
compact x ==> compact (sfst·x)
lemma compact_ssnd:
compact x ==> compact (ssnd·x)
lemma compact_spair:
[| compact x; compact y |] ==> compact (:x, y:)
lemma compact_spair_iff:
compact (:x, y:) = (x = UU ∨ y = UU ∨ compact x ∧ compact y)
lemma ssplit1:
ssplit·f·UU = UU
lemma ssplit2:
[| x ≠ UU; y ≠ UU |] ==> ssplit·f·(:x, y:) = f·x·y
lemma ssplit3:
ssplit·spair·z = z
lemma approx_spair:
approx i·(:x, y:) = (:approx i·x, approx i·y:)