(* Title: HOLCF/Sprod.thy
ID: $Id: Sprod.thy,v 1.15 2005/07/26 16:27:16 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
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 cpair_strict)
subsection {* Definitions of constants *}
consts
sfst :: "('a ** 'b) -> 'a"
ssnd :: "('a ** 'b) -> 'b"
spair :: "'a -> 'b -> ('a ** 'b)"
ssplit :: "('a -> 'b -> 'c) -> ('a ** 'b) -> 'c"
defs
sfst_def: "sfst ≡ Λ p. cfst·(Rep_Sprod p)"
ssnd_def: "ssnd ≡ Λ p. csnd·(Rep_Sprod p)"
spair_def: "spair ≡ Λ a b. Abs_Sprod
<strictify·(Λ b. a)·b, strictify·(Λ a. b)·a>"
ssplit_def: "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:)" == "spair$x$y"
subsection {* Case analysis *}
lemma spair_Abs_Sprod:
"(:a, b:) = Abs_Sprod <strictify·(Λ b. a)·b, strictify·(Λ a. b)·a>"
apply (unfold spair_def)
apply (simp add: cont_Abs_Sprod spair_lemma)
done
lemma Exh_Sprod2:
"z = ⊥ ∨ (∃a b. z = (:a, b:) ∧ a ≠ ⊥ ∧ b ≠ ⊥)"
apply (rule_tac x=z in Abs_Sprod_cases)
apply (simp add: Sprod_def)
apply (erule disjE)
apply (simp add: Abs_Sprod_strict)
apply (rule disjI2)
apply (rule_tac x="cfst·y" in exI)
apply (rule_tac x="csnd·y" in exI)
apply (simp add: spair_Abs_Sprod Abs_Sprod_inject spair_lemma)
apply (simp add: surjective_pairing_Cprod2)
done
lemma sprodE:
"[|p = ⊥ ==> Q; !!x y. [|p = (:x, y:); x ≠ ⊥; y ≠ ⊥|] ==> Q|] ==> Q"
by (cut_tac z=p in Exh_Sprod2, auto)
subsection {* Properties of @{term spair} *}
lemma spair_strict1 [simp]: "(:⊥, y:) = ⊥"
by (simp add: spair_Abs_Sprod strictify_conv_if cpair_strict Abs_Sprod_strict)
lemma spair_strict2 [simp]: "(:x, ⊥:) = ⊥"
by (simp add: spair_Abs_Sprod strictify_conv_if cpair_strict Abs_Sprod_strict)
lemma spair_strict: "x = ⊥ ∨ y = ⊥ ==> (:x, y:) = ⊥"
by auto
lemma spair_strict_rev: "(:x, y:) ≠ ⊥ ==> x ≠ ⊥ ∧ y ≠ ⊥"
by (erule contrapos_np, auto)
lemma spair_defined [simp]:
"[|x ≠ ⊥; y ≠ ⊥|] ==> (:x, y:) ≠ ⊥"
by (simp add: spair_Abs_Sprod Abs_Sprod_defined cpair_defined_iff Sprod_def)
lemma spair_defined_rev: "(:x, y:) = ⊥ ==> x = ⊥ ∨ y = ⊥"
by (erule contrapos_pp, simp)
lemma spair_eq:
"[|x ≠ ⊥; y ≠ ⊥|] ==> ((:x, y:) = (:a, b:)) = (x = a ∧ y = b)"
apply (simp add: spair_Abs_Sprod)
apply (simp add: Abs_Sprod_inject [OF _ spair_lemma] Sprod_def)
apply (simp add: strictify_conv_if)
done
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 Rep_Sprod_spair:
"Rep_Sprod (:a, b:) = <strictify·(Λ b. a)·b, strictify·(Λ a. b)·a>"
apply (unfold spair_def)
apply (simp add: cont_Abs_Sprod Abs_Sprod_inverse spair_lemma)
done
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 (rule_tac p=p in sprodE, simp_all)
lemma ssnd_defined_iff [simp]: "(ssnd·p = ⊥) = (p = ⊥)"
by (rule_tac p=p in sprodE, 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 (rule_tac p=p in sprodE, 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 (case_tac "a = ⊥")
apply (simp add: eq_UU_iff [symmetric])
apply (case_tac "b = ⊥")
apply (simp add: eq_UU_iff [symmetric])
apply (simp add: less_sprod)
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 (rule_tac p=z in sprodE, simp_all)
end
lemma spair_lemma:
<strictify·(LAM b. a)·b, strictify·(LAM a. b)·a> ∈ Sprod
lemma spair_Abs_Sprod:
(:a, b:) = Abs_Sprod <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 spair_strict1:
(:UU, y:) = UU
lemma spair_strict2:
(:x, UU:) = 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 Rep_Sprod_spair:
Rep_Sprod (:a, b:) = <strictify·(LAM b. a)·b, strictify·(LAM a. b)·a>
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 ssplit1:
ssplit·f·UU = UU
lemma ssplit2:
[| x ≠ UU; y ≠ UU |] ==> ssplit·f·(:x, y:) = f·x·y
lemma ssplit3:
ssplit·spair·z = z