# HG changeset patch # User huffman # Date 1287628802 25200 # Node ID ba2e41c8b725abcb54c9c02e160e9e9d25672315 # Parent e0f372e18f3e1c9d9a6ae3faebad8336caf9f5b0 introduce function strict :: 'a -> 'b -> 'b, which works like Haskell's seq; use strict instead of strictify in various definitions diff -r e0f372e18f3e -r ba2e41c8b725 src/HOLCF/Cfun.thy --- a/src/HOLCF/Cfun.thy Wed Oct 20 17:25:22 2010 -0700 +++ b/src/HOLCF/Cfun.thy Wed Oct 20 19:40:02 2010 -0700 @@ -534,32 +534,28 @@ default_sort pcpo definition - strictify :: "('a \ 'b) \ 'a \ 'b" where - "strictify = (\ f x. if x = \ then \ else f\x)" + strict :: "'a \ 'b \ 'b" where + "strict = (\ x. if x = \ then \ else ID)" -text {* results about strictify *} +lemma cont_strict: "cont (\x. if x = \ then \ else y)" +unfolding cont_def is_lub_def is_ub_def ball_simps +by (simp add: lub_eq_bottom_iff) -lemma cont_strictify1: "cont (\f. if x = \ then \ else f\x)" -by simp +lemma strict_conv_if: "strict\x = (if x = \ then \ else ID)" +unfolding strict_def by (simp add: cont_strict) -lemma monofun_strictify2: "monofun (\x. if x = \ then \ else f\x)" -apply (rule monofunI) -apply (auto simp add: monofun_cfun_arg) -done +lemma strict1 [simp]: "strict\\ = \" +by (simp add: strict_conv_if) -lemma cont_strictify2: "cont (\x. if x = \ then \ else f\x)" -apply (rule contI2) -apply (rule monofun_strictify2) -apply (case_tac "(\i. Y i) = \", simp) -apply (simp add: contlub_cfun_arg del: if_image_distrib) -apply (drule chain_UU_I_inverse2, clarify, rename_tac j) -apply (rule lub_mono2, rule_tac x=j in exI, simp_all) -apply (auto dest!: chain_mono_less) -done +lemma strict2 [simp]: "x \ \ \ strict\x = ID" +by (simp add: strict_conv_if) + + definition + strictify :: "('a \ 'b) \ 'a \ 'b" where + "strictify = (\ f x. strict\x\(f\x))" lemma strictify_conv_if: "strictify\f\x = (if x = \ then \ else f\x)" - unfolding strictify_def - by (simp add: cont_strictify1 cont_strictify2 cont2cont_LAM) +unfolding strictify_def by simp lemma strictify1 [simp]: "strictify\f\\ = \" by (simp add: strictify_conv_if) diff -r e0f372e18f3e -r ba2e41c8b725 src/HOLCF/Fixrec.thy --- a/src/HOLCF/Fixrec.thy Wed Oct 20 17:25:22 2010 -0700 +++ b/src/HOLCF/Fixrec.thy Wed Oct 20 19:40:02 2010 -0700 @@ -115,7 +115,7 @@ definition match_UU :: "'a \ 'c match \ 'c match" where - "match_UU = strictify\(\ x k. fail)" + "match_UU = (\ x k. strict\x\fail)" definition match_Pair :: "'a::cpo \ 'b::cpo \ ('a \ 'b \ 'c match) \ 'c match" diff -r e0f372e18f3e -r ba2e41c8b725 src/HOLCF/One.thy --- a/src/HOLCF/One.thy Wed Oct 20 17:25:22 2010 -0700 +++ b/src/HOLCF/One.thy Wed Oct 20 19:40:02 2010 -0700 @@ -54,7 +54,7 @@ definition one_when :: "'a::pcpo \ one \ 'a" where - "one_when = (\ a. strictify\(\ _. a))" + "one_when = (\ a x. strict\x\a)" translations "case x of XCONST ONE \ t" == "CONST one_when\t\x" diff -r e0f372e18f3e -r ba2e41c8b725 src/HOLCF/Sprod.thy --- a/src/HOLCF/Sprod.thy Wed Oct 20 17:25:22 2010 -0700 +++ b/src/HOLCF/Sprod.thy Wed Oct 20 19:40:02 2010 -0700 @@ -27,9 +27,8 @@ type_notation (HTML output) sprod ("(_ \/ _)" [21,20] 20) -lemma spair_lemma: - "(strictify\(\ b. a)\b, strictify\(\ a. b)\a) \ Sprod" -by (simp add: Sprod_def strictify_conv_if) +lemma spair_lemma: "(strict\b\a, strict\a\b) \ Sprod" +by (simp add: Sprod_def strict_conv_if) subsection {* Definitions of constants *} @@ -43,12 +42,11 @@ definition spair :: "'a \ 'b \ ('a ** 'b)" where - "spair = (\ a b. Abs_Sprod - (strictify\(\ b. a)\b, strictify\(\ a. b)\a))" + "spair = (\ a b. Abs_Sprod (strict\b\a, strict\a\b))" definition ssplit :: "('a \ 'b \ 'c) \ ('a ** 'b) \ 'c" where - "ssplit = (\ f. strictify\(\ p. f\(sfst\p)\(ssnd\p)))" + "ssplit = (\ f p. strict\p\(f\(sfst\p)\(ssnd\p)))" syntax "_stuple" :: "['a, args] => 'a ** 'b" ("(1'(:_,/ _:'))") @@ -62,7 +60,7 @@ subsection {* Case analysis *} lemma Rep_Sprod_spair: - "Rep_Sprod (:a, b:) = (strictify\(\ b. a)\b, strictify\(\ a. b)\a)" + "Rep_Sprod (:a, b:) = (strict\b\a, strict\a\b)" unfolding spair_def by (simp add: cont_Abs_Sprod Abs_Sprod_inverse spair_lemma) @@ -76,7 +74,7 @@ apply (simp add: Rep_Sprod_simps Pair_fst_snd_eq) apply (simp add: Sprod_def) apply (erule disjE, simp) -apply (simp add: strictify_conv_if) +apply (simp add: strict_conv_if) apply fast done @@ -91,22 +89,22 @@ subsection {* Properties of \emph{spair} *} lemma spair_strict1 [simp]: "(:\, y:) = \" -by (simp add: Rep_Sprod_simps strictify_conv_if) +by (simp add: Rep_Sprod_simps strict_conv_if) lemma spair_strict2 [simp]: "(:x, \:) = \" -by (simp add: Rep_Sprod_simps strictify_conv_if) +by (simp add: Rep_Sprod_simps strict_conv_if) lemma spair_strict_iff [simp]: "((:x, y:) = \) = (x = \ \ y = \)" -by (simp add: Rep_Sprod_simps strictify_conv_if) +by (simp add: Rep_Sprod_simps strict_conv_if) lemma spair_below_iff: "((:a, b:) \ (:c, d:)) = (a = \ \ b = \ \ (a \ c \ b \ d))" -by (simp add: Rep_Sprod_simps strictify_conv_if) +by (simp add: Rep_Sprod_simps strict_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) +by (simp add: Rep_Sprod_simps strict_conv_if) lemma spair_strict: "x = \ \ y = \ \ (:x, y:) = \" by simp @@ -197,7 +195,7 @@ by (rule compactI, simp add: ssnd_below_iff) lemma compact_spair: "\compact x; compact y\ \ compact (:x, y:)" -by (rule compact_Sprod, simp add: Rep_Sprod_spair strictify_conv_if) +by (rule compact_Sprod, simp add: Rep_Sprod_spair strict_conv_if) lemma compact_spair_iff: "compact (:x, y:) = (x = \ \ y = \ \ (compact x \ compact y))" diff -r e0f372e18f3e -r ba2e41c8b725 src/HOLCF/Ssum.thy --- a/src/HOLCF/Ssum.thy Wed Oct 20 17:25:22 2010 -0700 +++ b/src/HOLCF/Ssum.thy Wed Oct 20 19:40:02 2010 -0700 @@ -34,28 +34,28 @@ definition sinl :: "'a \ ('a ++ 'b)" where - "sinl = (\ a. Abs_Ssum (strictify\(\ _. TT)\a, a, \))" + "sinl = (\ a. Abs_Ssum (strict\a\TT, a, \))" definition sinr :: "'b \ ('a ++ 'b)" where - "sinr = (\ b. Abs_Ssum (strictify\(\ _. FF)\b, \, b))" + "sinr = (\ b. Abs_Ssum (strict\b\FF, \, b))" -lemma sinl_Ssum: "(strictify\(\ _. TT)\a, a, \) \ Ssum" -by (simp add: Ssum_def strictify_conv_if) +lemma sinl_Ssum: "(strict\a\TT, a, \) \ Ssum" +by (simp add: Ssum_def strict_conv_if) -lemma sinr_Ssum: "(strictify\(\ _. FF)\b, \, b) \ Ssum" -by (simp add: Ssum_def strictify_conv_if) +lemma sinr_Ssum: "(strict\b\FF, \, b) \ Ssum" +by (simp add: Ssum_def strict_conv_if) -lemma sinl_Abs_Ssum: "sinl\a = Abs_Ssum (strictify\(\ _. TT)\a, a, \)" +lemma sinl_Abs_Ssum: "sinl\a = Abs_Ssum (strict\a\TT, a, \)" by (unfold sinl_def, simp add: cont_Abs_Ssum sinl_Ssum) -lemma sinr_Abs_Ssum: "sinr\b = Abs_Ssum (strictify\(\ _. FF)\b, \, b)" +lemma sinr_Abs_Ssum: "sinr\b = Abs_Ssum (strict\b\FF, \, b)" by (unfold sinr_def, simp add: cont_Abs_Ssum sinr_Ssum) -lemma Rep_Ssum_sinl: "Rep_Ssum (sinl\a) = (strictify\(\ _. TT)\a, a, \)" +lemma Rep_Ssum_sinl: "Rep_Ssum (sinl\a) = (strict\a\TT, a, \)" by (simp add: sinl_Abs_Ssum Abs_Ssum_inverse sinl_Ssum) -lemma Rep_Ssum_sinr: "Rep_Ssum (sinr\b) = (strictify\(\ _. FF)\b, \, b)" +lemma Rep_Ssum_sinr: "Rep_Ssum (sinr\b) = (strict\b\FF, \, b)" by (simp add: sinr_Abs_Ssum Abs_Ssum_inverse sinr_Ssum) subsection {* Properties of \emph{sinl} and \emph{sinr} *} @@ -63,16 +63,16 @@ text {* Ordering *} lemma sinl_below [simp]: "(sinl\x \ sinl\y) = (x \ y)" -by (simp add: below_Ssum_def Rep_Ssum_sinl strictify_conv_if) +by (simp add: below_Ssum_def Rep_Ssum_sinl strict_conv_if) lemma sinr_below [simp]: "(sinr\x \ sinr\y) = (x \ y)" -by (simp add: below_Ssum_def Rep_Ssum_sinr strictify_conv_if) +by (simp add: below_Ssum_def Rep_Ssum_sinr strict_conv_if) lemma sinl_below_sinr [simp]: "(sinl\x \ sinr\y) = (x = \)" -by (simp add: below_Ssum_def Rep_Ssum_sinl Rep_Ssum_sinr strictify_conv_if) +by (simp add: below_Ssum_def Rep_Ssum_sinl Rep_Ssum_sinr strict_conv_if) lemma sinr_below_sinl [simp]: "(sinr\x \ sinl\y) = (x = \)" -by (simp add: below_Ssum_def Rep_Ssum_sinl Rep_Ssum_sinr strictify_conv_if) +by (simp add: below_Ssum_def Rep_Ssum_sinl Rep_Ssum_sinr strict_conv_if) text {* Equality *} @@ -117,10 +117,10 @@ text {* Compactness *} lemma compact_sinl: "compact x \ compact (sinl\x)" -by (rule compact_Ssum, simp add: Rep_Ssum_sinl strictify_conv_if) +by (rule compact_Ssum, simp add: Rep_Ssum_sinl strict_conv_if) lemma compact_sinr: "compact x \ compact (sinr\x)" -by (rule compact_Ssum, simp add: Rep_Ssum_sinr strictify_conv_if) +by (rule compact_Ssum, simp add: Rep_Ssum_sinr strict_conv_if) lemma compact_sinlD: "compact (sinl\x) \ compact x" unfolding compact_def