# HG changeset patch # User haftmann # Date 1291817146 -3600 # Node ID 9ff94e7cc3b3c3c478e186849350c44416637d2a # Parent fb1e5377143d4ed1c80e6fb4d208f5470d4f7b19 bot comes before top, inf before sup etc. diff -r fb1e5377143d -r 9ff94e7cc3b3 src/HOL/Complete_Lattice.thy --- a/src/HOL/Complete_Lattice.thy Wed Dec 08 14:52:23 2010 +0100 +++ b/src/HOL/Complete_Lattice.thy Wed Dec 08 15:05:46 2010 +0100 @@ -82,21 +82,11 @@ "\{a, b} = a \ b" by (simp add: Sup_empty Sup_insert) -lemma Sup_le_iff: "Sup A \ b \ (\a\A. a \ b)" - by (auto intro: Sup_least dest: Sup_upper) - lemma le_Inf_iff: "b \ Inf A \ (\a\A. b \ a)" by (auto intro: Inf_greatest dest: Inf_lower) -lemma Sup_mono: - assumes "\a. a \ A \ \b\B. a \ b" - shows "Sup A \ Sup B" -proof (rule Sup_least) - fix a assume "a \ A" - with assms obtain b where "b \ B" and "a \ b" by blast - from `b \ B` have "b \ Sup B" by (rule Sup_upper) - with `a \ b` show "a \ Sup B" by auto -qed +lemma Sup_le_iff: "Sup A \ b \ (\a\A. a \ b)" + by (auto intro: Sup_least dest: Sup_upper) lemma Inf_mono: assumes "\b. b \ B \ \a\A. a \ b" @@ -108,39 +98,49 @@ with `a \ b` show "Inf A \ b" by auto qed -definition SUPR :: "'b set \ ('b \ 'a) \ 'a" where - "SUPR A f = \ (f ` A)" +lemma Sup_mono: + assumes "\a. a \ A \ \b\B. a \ b" + shows "Sup A \ Sup B" +proof (rule Sup_least) + fix a assume "a \ A" + with assms obtain b where "b \ B" and "a \ b" by blast + from `b \ B` have "b \ Sup B" by (rule Sup_upper) + with `a \ b` show "a \ Sup B" by auto +qed definition INFI :: "'b set \ ('b \ 'a) \ 'a" where "INFI A f = \ (f ` A)" +definition SUPR :: "'b set \ ('b \ 'a) \ 'a" where + "SUPR A f = \ (f ` A)" + end syntax + "_INF1" :: "pttrns \ 'b \ 'b" ("(3INF _./ _)" [0, 10] 10) + "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3INF _:_./ _)" [0, 0, 10] 10) "_SUP1" :: "pttrns \ 'b \ 'b" ("(3SUP _./ _)" [0, 10] 10) "_SUP" :: "pttrn \ 'a set \ 'b \ 'b" ("(3SUP _:_./ _)" [0, 0, 10] 10) - "_INF1" :: "pttrns \ 'b \ 'b" ("(3INF _./ _)" [0, 10] 10) - "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3INF _:_./ _)" [0, 0, 10] 10) syntax (xsymbols) + "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) + "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) "_SUP1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) "_SUP" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) - "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) - "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) translations + "INF x y. B" == "INF x. INF y. B" + "INF x. B" == "CONST INFI CONST UNIV (%x. B)" + "INF x. B" == "INF x:CONST UNIV. B" + "INF x:A. B" == "CONST INFI A (%x. B)" "SUP x y. B" == "SUP x. SUP y. B" "SUP x. B" == "CONST SUPR CONST UNIV (%x. B)" "SUP x. B" == "SUP x:CONST UNIV. B" "SUP x:A. B" == "CONST SUPR A (%x. B)" - "INF x y. B" == "INF x. INF y. B" - "INF x. B" == "CONST INFI CONST UNIV (%x. B)" - "INF x. B" == "INF x:CONST UNIV. B" - "INF x:A. B" == "CONST INFI A (%x. B)" print_translation {* - [Syntax.preserve_binder_abs2_tr' @{const_syntax SUPR} @{syntax_const "_SUP"}, - Syntax.preserve_binder_abs2_tr' @{const_syntax INFI} @{syntax_const "_INF"}] + [Syntax.preserve_binder_abs2_tr' @{const_syntax INFI} @{syntax_const "_INF"}, + Syntax.preserve_binder_abs2_tr' @{const_syntax SUPR} @{syntax_const "_SUP"}] *} -- {* to avoid eta-contraction of body *} context complete_lattice @@ -164,54 +164,54 @@ lemma le_INF_iff: "u \ (INF i:A. M i) \ (\i \ A. u \ M i)" unfolding INFI_def by (auto simp add: le_Inf_iff) -lemma SUP_const[simp]: "A \ {} \ (SUP i:A. M) = M" - by (auto intro: antisym SUP_leI le_SUPI) - lemma INF_const[simp]: "A \ {} \ (INF i:A. M) = M" by (auto intro: antisym INF_leI le_INFI) -lemma SUP_mono: - "(\n. n \ A \ \m\B. f n \ g m) \ (SUP n:A. f n) \ (SUP n:B. g n)" - by (force intro!: Sup_mono simp: SUPR_def) +lemma SUP_const[simp]: "A \ {} \ (SUP i:A. M) = M" + by (auto intro: antisym SUP_leI le_SUPI) lemma INF_mono: "(\m. m \ B \ \n\A. f n \ g m) \ (INF n:A. f n) \ (INF n:B. g n)" by (force intro!: Inf_mono simp: INFI_def) -lemma SUP_subset: "A \ B \ SUPR A f \ SUPR B f" - by (intro SUP_mono) auto +lemma SUP_mono: + "(\n. n \ A \ \m\B. f n \ g m) \ (SUP n:A. f n) \ (SUP n:B. g n)" + by (force intro!: Sup_mono simp: SUPR_def) lemma INF_subset: "A \ B \ INFI B f \ INFI A f" by (intro INF_mono) auto -lemma SUP_commute: "(SUP i:A. SUP j:B. f i j) = (SUP j:B. SUP i:A. f i j)" - by (iprover intro: SUP_leI le_SUPI order_trans antisym) +lemma SUP_subset: "A \ B \ SUPR A f \ SUPR B f" + by (intro SUP_mono) auto lemma INF_commute: "(INF i:A. INF j:B. f i j) = (INF j:B. INF i:A. f i j)" by (iprover intro: INF_leI le_INFI order_trans antisym) +lemma SUP_commute: "(SUP i:A. SUP j:B. f i j) = (SUP j:B. SUP i:A. f i j)" + by (iprover intro: SUP_leI le_SUPI order_trans antisym) + end +lemma Inf_less_iff: + fixes a :: "'a\{complete_lattice,linorder}" + shows "Inf S < a \ (\x\S. x < a)" + unfolding not_le[symmetric] le_Inf_iff by auto + lemma less_Sup_iff: fixes a :: "'a\{complete_lattice,linorder}" shows "a < Sup S \ (\x\S. a < x)" unfolding not_le[symmetric] Sup_le_iff by auto -lemma Inf_less_iff: - fixes a :: "'a\{complete_lattice,linorder}" - shows "Inf S < a \ (\x\S. x < a)" - unfolding not_le[symmetric] le_Inf_iff by auto +lemma INF_less_iff: + fixes a :: "'a::{complete_lattice,linorder}" + shows "(INF i:A. f i) < a \ (\x\A. f x < a)" + unfolding INFI_def Inf_less_iff by auto lemma less_SUP_iff: fixes a :: "'a::{complete_lattice,linorder}" shows "a < (SUP i:A. f i) \ (\x\A. a < f x)" unfolding SUPR_def less_Sup_iff by auto -lemma INF_less_iff: - fixes a :: "'a::{complete_lattice,linorder}" - shows "(INF i:A. f i) < a \ (\x\A. f x < a)" - unfolding INFI_def Inf_less_iff by auto - subsection {* @{typ bool} and @{typ "_ \ _"} as complete lattice *} instantiation bool :: complete_lattice @@ -278,6 +278,200 @@ by (auto intro: arg_cong [of _ _ Sup] simp add: SUPR_def Sup_apply) +subsection {* Inter *} + +abbreviation Inter :: "'a set set \ 'a set" where + "Inter S \ \S" + +notation (xsymbols) + Inter ("\_" [90] 90) + +lemma Inter_eq: + "\A = {x. \B \ A. x \ B}" +proof (rule set_eqI) + fix x + have "(\Q\{P. \B\A. P \ x \ B}. Q) \ (\B\A. x \ B)" + by auto + then show "x \ \A \ x \ {x. \B \ A. x \ B}" + by (simp add: Inf_fun_def Inf_bool_def) (simp add: mem_def) +qed + +lemma Inter_iff [simp,no_atp]: "(A : Inter C) = (ALL X:C. A:X)" + by (unfold Inter_eq) blast + +lemma InterI [intro!]: "(!!X. X:C ==> A:X) ==> A : Inter C" + by (simp add: Inter_eq) + +text {* + \medskip A ``destruct'' rule -- every @{term X} in @{term C} + contains @{term A} as an element, but @{prop "A:X"} can hold when + @{prop "X:C"} does not! This rule is analogous to @{text spec}. +*} + +lemma InterD [elim, Pure.elim]: "A : Inter C ==> X:C ==> A:X" + by auto + +lemma InterE [elim]: "A : Inter C ==> (X~:C ==> R) ==> (A:X ==> R) ==> R" + -- {* ``Classical'' elimination rule -- does not require proving + @{prop "X:C"}. *} + by (unfold Inter_eq) blast + +lemma Inter_lower: "B \ A ==> Inter A \ B" + by blast + +lemma Inter_subset: + "[| !!X. X \ A ==> X \ B; A ~= {} |] ==> \A \ B" + by blast + +lemma Inter_greatest: "(!!X. X \ A ==> C \ X) ==> C \ Inter A" + by (iprover intro: InterI subsetI dest: subsetD) + +lemma Int_eq_Inter: "A \ B = \{A, B}" + by blast + +lemma Inter_empty [simp]: "\{} = UNIV" + by (fact Inf_empty) + +lemma Inter_UNIV [simp]: "\UNIV = {}" + by blast + +lemma Inter_insert [simp]: "\(insert a B) = a \ \B" + by blast + +lemma Inter_Un_subset: "\A \ \B \ \(A \ B)" + by blast + +lemma Inter_Un_distrib: "\(A \ B) = \A \ \B" + by blast + +lemma Inter_UNIV_conv [simp,no_atp]: + "(\A = UNIV) = (\x\A. x = UNIV)" + "(UNIV = \A) = (\x\A. x = UNIV)" + by blast+ + +lemma Inter_anti_mono: "B \ A ==> \A \ \B" + by blast + + +subsection {* Intersections of families *} + +abbreviation INTER :: "'a set \ ('a \ 'b set) \ 'b set" where + "INTER \ INFI" + +syntax + "_INTER1" :: "pttrns => 'b set => 'b set" ("(3INT _./ _)" [0, 10] 10) + "_INTER" :: "pttrn => 'a set => 'b set => 'b set" ("(3INT _:_./ _)" [0, 0, 10] 10) + +syntax (xsymbols) + "_INTER1" :: "pttrns => 'b set => 'b set" ("(3\_./ _)" [0, 10] 10) + "_INTER" :: "pttrn => 'a set => 'b set => 'b set" ("(3\_\_./ _)" [0, 0, 10] 10) + +syntax (latex output) + "_INTER1" :: "pttrns => 'b set => 'b set" ("(3\(00\<^bsub>_\<^esub>)/ _)" [0, 10] 10) + "_INTER" :: "pttrn => 'a set => 'b set => 'b set" ("(3\(00\<^bsub>_\_\<^esub>)/ _)" [0, 0, 10] 10) + +translations + "INT x y. B" == "INT x. INT y. B" + "INT x. B" == "CONST INTER CONST UNIV (%x. B)" + "INT x. B" == "INT x:CONST UNIV. B" + "INT x:A. B" == "CONST INTER A (%x. B)" + +print_translation {* + [Syntax.preserve_binder_abs2_tr' @{const_syntax INTER} @{syntax_const "_INTER"}] +*} -- {* to avoid eta-contraction of body *} + +lemma INTER_eq_Inter_image: + "(\x\A. B x) = \(B`A)" + by (fact INFI_def) + +lemma Inter_def: + "\S = (\x\S. x)" + by (simp add: INTER_eq_Inter_image image_def) + +lemma INTER_def: + "(\x\A. B x) = {y. \x\A. y \ B x}" + by (auto simp add: INTER_eq_Inter_image Inter_eq) + +lemma Inter_image_eq [simp]: + "\(B`A) = (\x\A. B x)" + by (rule sym) (fact INTER_eq_Inter_image) + +lemma INT_iff [simp]: "(b: (INT x:A. B x)) = (ALL x:A. b: B x)" + by (unfold INTER_def) blast + +lemma INT_I [intro!]: "(!!x. x:A ==> b: B x) ==> b : (INT x:A. B x)" + by (unfold INTER_def) blast + +lemma INT_D [elim, Pure.elim]: "b : (INT x:A. B x) ==> a:A ==> b: B a" + by auto + +lemma INT_E [elim]: "b : (INT x:A. B x) ==> (b: B a ==> R) ==> (a~:A ==> R) ==> R" + -- {* "Classical" elimination -- by the Excluded Middle on @{prop "a:A"}. *} + by (unfold INTER_def) blast + +lemma INT_cong [cong]: + "A = B ==> (!!x. x:B ==> C x = D x) ==> (INT x:A. C x) = (INT x:B. D x)" + by (simp add: INTER_def) + +lemma Collect_ball_eq: "{x. \y\A. P x y} = (\y\A. {x. P x y})" + by blast + +lemma Collect_all_eq: "{x. \y. P x y} = (\y. {x. P x y})" + by blast + +lemma INT_lower: "a \ A ==> (\x\A. B x) \ B a" + by (fact INF_leI) + +lemma INT_greatest: "(!!x. x \ A ==> C \ B x) ==> C \ (\x\A. B x)" + by (fact le_INFI) + +lemma INT_empty [simp]: "(\x\{}. B x) = UNIV" + by blast + +lemma INT_absorb: "k \ I ==> A k \ (\i\I. A i) = (\i\I. A i)" + by blast + +lemma INT_subset_iff: "(B \ (\i\I. A i)) = (\i\I. B \ A i)" + by (fact le_INF_iff) + +lemma INT_insert [simp]: "(\x \ insert a A. B x) = B a \ INTER A B" + by blast + +lemma INT_Un: "(\i \ A \ B. M i) = (\i \ A. M i) \ (\i\B. M i)" + by blast + +lemma INT_insert_distrib: + "u \ A ==> (\x\A. insert a (B x)) = insert a (\x\A. B x)" + by blast + +lemma INT_constant [simp]: "(\y\A. c) = (if A = {} then UNIV else c)" + by auto + +lemma INT_eq: "(\x\A. B x) = \({Y. \x\A. Y = B x})" + -- {* Look: it has an \emph{existential} quantifier *} + by blast + +lemma INTER_UNIV_conv[simp]: + "(UNIV = (INT x:A. B x)) = (\x\A. B x = UNIV)" + "((INT x:A. B x) = UNIV) = (\x\A. B x = UNIV)" +by blast+ + +lemma INT_bool_eq: "(\b::bool. A b) = (A True \ A False)" + by (auto intro: bool_induct) + +lemma Pow_INT_eq: "Pow (\x\A. B x) = (\x\A. Pow (B x))" + by blast + +lemma INT_anti_mono: + "B \ A ==> (!!x. x \ A ==> f x \ g x) ==> + (\x\A. f x) \ (\x\A. g x)" + -- {* The last inclusion is POSITIVE! *} + by (blast dest: subsetD) + +lemma vimage_INT: "f-`(INT x:A. B x) = (INT x:A. f -` B x)" + by blast + + subsection {* Union *} abbreviation Union :: "'a set set \ 'a set" where @@ -514,200 +708,6 @@ by blast -subsection {* Inter *} - -abbreviation Inter :: "'a set set \ 'a set" where - "Inter S \ \S" - -notation (xsymbols) - Inter ("\_" [90] 90) - -lemma Inter_eq: - "\A = {x. \B \ A. x \ B}" -proof (rule set_eqI) - fix x - have "(\Q\{P. \B\A. P \ x \ B}. Q) \ (\B\A. x \ B)" - by auto - then show "x \ \A \ x \ {x. \B \ A. x \ B}" - by (simp add: Inf_fun_def Inf_bool_def) (simp add: mem_def) -qed - -lemma Inter_iff [simp,no_atp]: "(A : Inter C) = (ALL X:C. A:X)" - by (unfold Inter_eq) blast - -lemma InterI [intro!]: "(!!X. X:C ==> A:X) ==> A : Inter C" - by (simp add: Inter_eq) - -text {* - \medskip A ``destruct'' rule -- every @{term X} in @{term C} - contains @{term A} as an element, but @{prop "A:X"} can hold when - @{prop "X:C"} does not! This rule is analogous to @{text spec}. -*} - -lemma InterD [elim, Pure.elim]: "A : Inter C ==> X:C ==> A:X" - by auto - -lemma InterE [elim]: "A : Inter C ==> (X~:C ==> R) ==> (A:X ==> R) ==> R" - -- {* ``Classical'' elimination rule -- does not require proving - @{prop "X:C"}. *} - by (unfold Inter_eq) blast - -lemma Inter_lower: "B \ A ==> Inter A \ B" - by blast - -lemma Inter_subset: - "[| !!X. X \ A ==> X \ B; A ~= {} |] ==> \A \ B" - by blast - -lemma Inter_greatest: "(!!X. X \ A ==> C \ X) ==> C \ Inter A" - by (iprover intro: InterI subsetI dest: subsetD) - -lemma Int_eq_Inter: "A \ B = \{A, B}" - by blast - -lemma Inter_empty [simp]: "\{} = UNIV" - by (fact Inf_empty) - -lemma Inter_UNIV [simp]: "\UNIV = {}" - by blast - -lemma Inter_insert [simp]: "\(insert a B) = a \ \B" - by blast - -lemma Inter_Un_subset: "\A \ \B \ \(A \ B)" - by blast - -lemma Inter_Un_distrib: "\(A \ B) = \A \ \B" - by blast - -lemma Inter_UNIV_conv [simp,no_atp]: - "(\A = UNIV) = (\x\A. x = UNIV)" - "(UNIV = \A) = (\x\A. x = UNIV)" - by blast+ - -lemma Inter_anti_mono: "B \ A ==> \A \ \B" - by blast - - -subsection {* Intersections of families *} - -abbreviation INTER :: "'a set \ ('a \ 'b set) \ 'b set" where - "INTER \ INFI" - -syntax - "_INTER1" :: "pttrns => 'b set => 'b set" ("(3INT _./ _)" [0, 10] 10) - "_INTER" :: "pttrn => 'a set => 'b set => 'b set" ("(3INT _:_./ _)" [0, 0, 10] 10) - -syntax (xsymbols) - "_INTER1" :: "pttrns => 'b set => 'b set" ("(3\_./ _)" [0, 10] 10) - "_INTER" :: "pttrn => 'a set => 'b set => 'b set" ("(3\_\_./ _)" [0, 0, 10] 10) - -syntax (latex output) - "_INTER1" :: "pttrns => 'b set => 'b set" ("(3\(00\<^bsub>_\<^esub>)/ _)" [0, 10] 10) - "_INTER" :: "pttrn => 'a set => 'b set => 'b set" ("(3\(00\<^bsub>_\_\<^esub>)/ _)" [0, 0, 10] 10) - -translations - "INT x y. B" == "INT x. INT y. B" - "INT x. B" == "CONST INTER CONST UNIV (%x. B)" - "INT x. B" == "INT x:CONST UNIV. B" - "INT x:A. B" == "CONST INTER A (%x. B)" - -print_translation {* - [Syntax.preserve_binder_abs2_tr' @{const_syntax INTER} @{syntax_const "_INTER"}] -*} -- {* to avoid eta-contraction of body *} - -lemma INTER_eq_Inter_image: - "(\x\A. B x) = \(B`A)" - by (fact INFI_def) - -lemma Inter_def: - "\S = (\x\S. x)" - by (simp add: INTER_eq_Inter_image image_def) - -lemma INTER_def: - "(\x\A. B x) = {y. \x\A. y \ B x}" - by (auto simp add: INTER_eq_Inter_image Inter_eq) - -lemma Inter_image_eq [simp]: - "\(B`A) = (\x\A. B x)" - by (rule sym) (fact INTER_eq_Inter_image) - -lemma INT_iff [simp]: "(b: (INT x:A. B x)) = (ALL x:A. b: B x)" - by (unfold INTER_def) blast - -lemma INT_I [intro!]: "(!!x. x:A ==> b: B x) ==> b : (INT x:A. B x)" - by (unfold INTER_def) blast - -lemma INT_D [elim, Pure.elim]: "b : (INT x:A. B x) ==> a:A ==> b: B a" - by auto - -lemma INT_E [elim]: "b : (INT x:A. B x) ==> (b: B a ==> R) ==> (a~:A ==> R) ==> R" - -- {* "Classical" elimination -- by the Excluded Middle on @{prop "a:A"}. *} - by (unfold INTER_def) blast - -lemma INT_cong [cong]: - "A = B ==> (!!x. x:B ==> C x = D x) ==> (INT x:A. C x) = (INT x:B. D x)" - by (simp add: INTER_def) - -lemma Collect_ball_eq: "{x. \y\A. P x y} = (\y\A. {x. P x y})" - by blast - -lemma Collect_all_eq: "{x. \y. P x y} = (\y. {x. P x y})" - by blast - -lemma INT_lower: "a \ A ==> (\x\A. B x) \ B a" - by (fact INF_leI) - -lemma INT_greatest: "(!!x. x \ A ==> C \ B x) ==> C \ (\x\A. B x)" - by (fact le_INFI) - -lemma INT_empty [simp]: "(\x\{}. B x) = UNIV" - by blast - -lemma INT_absorb: "k \ I ==> A k \ (\i\I. A i) = (\i\I. A i)" - by blast - -lemma INT_subset_iff: "(B \ (\i\I. A i)) = (\i\I. B \ A i)" - by (fact le_INF_iff) - -lemma INT_insert [simp]: "(\x \ insert a A. B x) = B a \ INTER A B" - by blast - -lemma INT_Un: "(\i \ A \ B. M i) = (\i \ A. M i) \ (\i\B. M i)" - by blast - -lemma INT_insert_distrib: - "u \ A ==> (\x\A. insert a (B x)) = insert a (\x\A. B x)" - by blast - -lemma INT_constant [simp]: "(\y\A. c) = (if A = {} then UNIV else c)" - by auto - -lemma INT_eq: "(\x\A. B x) = \({Y. \x\A. Y = B x})" - -- {* Look: it has an \emph{existential} quantifier *} - by blast - -lemma INTER_UNIV_conv[simp]: - "(UNIV = (INT x:A. B x)) = (\x\A. B x = UNIV)" - "((INT x:A. B x) = UNIV) = (\x\A. B x = UNIV)" -by blast+ - -lemma INT_bool_eq: "(\b::bool. A b) = (A True \ A False)" - by (auto intro: bool_induct) - -lemma Pow_INT_eq: "Pow (\x\A. B x) = (\x\A. Pow (B x))" - by blast - -lemma INT_anti_mono: - "B \ A ==> (!!x. x \ A ==> f x \ g x) ==> - (\x\A. f x) \ (\x\A. g x)" - -- {* The last inclusion is POSITIVE! *} - by (blast dest: subsetD) - -lemma vimage_INT: "f-`(INT x:A. B x) = (INT x:A. f -` B x)" - by blast - - subsection {* Distributive laws *} lemma Int_Union: "A \ \B = (\C\B. A \ C)" @@ -858,18 +858,18 @@ no_notation less_eq (infix "\" 50) and less (infix "\" 50) and + bot ("\") and + top ("\") and inf (infixl "\" 70) and sup (infixl "\" 65) and Inf ("\_" [900] 900) and - Sup ("\_" [900] 900) and - top ("\") and - bot ("\") + Sup ("\_" [900] 900) no_syntax (xsymbols) + "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) + "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) "_SUP1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) "_SUP" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) - "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) - "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) lemmas mem_simps = insert_iff empty_iff Un_iff Int_iff Compl_iff Diff_iff diff -r fb1e5377143d -r 9ff94e7cc3b3 src/HOL/Lattices.thy --- a/src/HOL/Lattices.thy Wed Dec 08 14:52:23 2010 +0100 +++ b/src/HOL/Lattices.thy Wed Dec 08 15:05:46 2010 +0100 @@ -48,8 +48,9 @@ notation less_eq (infix "\" 50) and less (infix "\" 50) and - top ("\") and - bot ("\") + bot ("\") and + top ("\") + class semilattice_inf = order + fixes inf :: "'a \ 'a \ 'a" (infixl "\" 70) diff -r fb1e5377143d -r 9ff94e7cc3b3 src/HOL/Library/Lattice_Syntax.thy --- a/src/HOL/Library/Lattice_Syntax.thy Wed Dec 08 14:52:23 2010 +0100 +++ b/src/HOL/Library/Lattice_Syntax.thy Wed Dec 08 15:05:46 2010 +0100 @@ -7,17 +7,17 @@ begin notation + bot ("\") and top ("\") and - bot ("\") and inf (infixl "\" 70) and sup (infixl "\" 65) and Inf ("\_" [900] 900) and Sup ("\_" [900] 900) syntax (xsymbols) + "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) + "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) "_SUP1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) "_SUP" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) - "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) - "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) end diff -r fb1e5377143d -r 9ff94e7cc3b3 src/HOL/Orderings.thy --- a/src/HOL/Orderings.thy Wed Dec 08 14:52:23 2010 +0100 +++ b/src/HOL/Orderings.thy Wed Dec 08 15:05:46 2010 +0100 @@ -1082,14 +1082,14 @@ subsection {* Top and bottom elements *} +class bot = preorder + + fixes bot :: 'a + assumes bot_least [simp]: "bot \ x" + class top = preorder + fixes top :: 'a assumes top_greatest [simp]: "x \ top" -class bot = preorder + - fixes bot :: 'a - assumes bot_least [simp]: "bot \ x" - subsection {* Dense orders *} @@ -1204,7 +1204,7 @@ subsection {* Order on bool *} -instantiation bool :: "{order, top, bot}" +instantiation bool :: "{order, bot, top}" begin definition @@ -1214,10 +1214,10 @@ [simp]: "(P\bool) < Q \ \ P \ Q" definition - [simp]: "top \ True" + [simp]: "bot \ False" definition - [simp]: "bot \ False" + [simp]: "top \ True" instance proof qed auto @@ -1272,6 +1272,21 @@ instance "fun" :: (type, order) order proof qed (auto simp add: le_fun_def intro: antisym ext) +instantiation "fun" :: (type, bot) bot +begin + +definition + "bot = (\x. bot)" + +lemma bot_apply: + "bot x = bot" + by (simp add: bot_fun_def) + +instance proof +qed (simp add: le_fun_def bot_apply) + +end + instantiation "fun" :: (type, top) top begin @@ -1288,21 +1303,6 @@ end -instantiation "fun" :: (type, bot) bot -begin - -definition - "bot = (\x. bot)" - -lemma bot_apply: - "bot x = bot" - by (simp add: bot_fun_def) - -instance proof -qed (simp add: le_fun_def bot_apply) - -end - lemma le_funI: "(\x. f x \ g x) \ f \ g" unfolding le_fun_def by simp diff -r fb1e5377143d -r 9ff94e7cc3b3 src/HOL/Predicate.thy --- a/src/HOL/Predicate.thy Wed Dec 08 14:52:23 2010 +0100 +++ b/src/HOL/Predicate.thy Wed Dec 08 15:05:46 2010 +0100 @@ -9,18 +9,18 @@ begin notation + bot ("\") and + top ("\") and inf (infixl "\" 70) and sup (infixl "\" 65) and Inf ("\_" [900] 900) and - Sup ("\_" [900] 900) and - top ("\") and - bot ("\") + Sup ("\_" [900] 900) syntax (xsymbols) + "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) + "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) "_SUP1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) "_SUP" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) - "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) - "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) subsection {* Predicates as (complete) lattices *} @@ -92,12 +92,6 @@ subsubsection {* Top and bottom elements *} -lemma top1I [intro!]: "top x" - by (simp add: top_fun_def top_bool_def) - -lemma top2I [intro!]: "top x y" - by (simp add: top_fun_def top_bool_def) - lemma bot1E [no_atp, elim!]: "bot x \ P" by (simp add: bot_fun_def bot_bool_def) @@ -110,6 +104,45 @@ lemma bot_empty_eq2: "bot = (\x y. (x, y) \ {})" by (auto simp add: fun_eq_iff) +lemma top1I [intro!]: "top x" + by (simp add: top_fun_def top_bool_def) + +lemma top2I [intro!]: "top x y" + by (simp add: top_fun_def top_bool_def) + + +subsubsection {* Binary intersection *} + +lemma inf1I [intro!]: "A x ==> B x ==> inf A B x" + by (simp add: inf_fun_def inf_bool_def) + +lemma inf2I [intro!]: "A x y ==> B x y ==> inf A B x y" + by (simp add: inf_fun_def inf_bool_def) + +lemma inf1E [elim!]: "inf A B x ==> (A x ==> B x ==> P) ==> P" + by (simp add: inf_fun_def inf_bool_def) + +lemma inf2E [elim!]: "inf A B x y ==> (A x y ==> B x y ==> P) ==> P" + by (simp add: inf_fun_def inf_bool_def) + +lemma inf1D1: "inf A B x ==> A x" + by (simp add: inf_fun_def inf_bool_def) + +lemma inf2D1: "inf A B x y ==> A x y" + by (simp add: inf_fun_def inf_bool_def) + +lemma inf1D2: "inf A B x ==> B x" + by (simp add: inf_fun_def inf_bool_def) + +lemma inf2D2: "inf A B x y ==> B x y" + by (simp add: inf_fun_def inf_bool_def) + +lemma inf_Int_eq: "inf (\x. x \ R) (\x. x \ S) = (\x. x \ R \ S)" + by (simp add: inf_fun_def inf_bool_def mem_def) + +lemma inf_Int_eq2 [pred_set_conv]: "inf (\x y. (x, y) \ R) (\x y. (x, y) \ S) = (\x y. (x, y) \ R \ S)" + by (simp add: inf_fun_def inf_bool_def mem_def) + subsubsection {* Binary union *} @@ -149,66 +182,6 @@ by (simp add: sup_fun_def sup_bool_def mem_def) -subsubsection {* Binary intersection *} - -lemma inf1I [intro!]: "A x ==> B x ==> inf A B x" - by (simp add: inf_fun_def inf_bool_def) - -lemma inf2I [intro!]: "A x y ==> B x y ==> inf A B x y" - by (simp add: inf_fun_def inf_bool_def) - -lemma inf1E [elim!]: "inf A B x ==> (A x ==> B x ==> P) ==> P" - by (simp add: inf_fun_def inf_bool_def) - -lemma inf2E [elim!]: "inf A B x y ==> (A x y ==> B x y ==> P) ==> P" - by (simp add: inf_fun_def inf_bool_def) - -lemma inf1D1: "inf A B x ==> A x" - by (simp add: inf_fun_def inf_bool_def) - -lemma inf2D1: "inf A B x y ==> A x y" - by (simp add: inf_fun_def inf_bool_def) - -lemma inf1D2: "inf A B x ==> B x" - by (simp add: inf_fun_def inf_bool_def) - -lemma inf2D2: "inf A B x y ==> B x y" - by (simp add: inf_fun_def inf_bool_def) - -lemma inf_Int_eq: "inf (\x. x \ R) (\x. x \ S) = (\x. x \ R \ S)" - by (simp add: inf_fun_def inf_bool_def mem_def) - -lemma inf_Int_eq2 [pred_set_conv]: "inf (\x y. (x, y) \ R) (\x y. (x, y) \ S) = (\x y. (x, y) \ R \ S)" - by (simp add: inf_fun_def inf_bool_def mem_def) - - -subsubsection {* Unions of families *} - -lemma SUP1_iff: "(SUP x:A. B x) b = (EX x:A. B x b)" - by (simp add: SUPR_apply) - -lemma SUP2_iff: "(SUP x:A. B x) b c = (EX x:A. B x b c)" - by (simp add: SUPR_apply) - -lemma SUP1_I [intro]: "a : A ==> B a b ==> (SUP x:A. B x) b" - by (auto simp add: SUPR_apply) - -lemma SUP2_I [intro]: "a : A ==> B a b c ==> (SUP x:A. B x) b c" - by (auto simp add: SUPR_apply) - -lemma SUP1_E [elim!]: "(SUP x:A. B x) b ==> (!!x. x : A ==> B x b ==> R) ==> R" - by (auto simp add: SUPR_apply) - -lemma SUP2_E [elim!]: "(SUP x:A. B x) b c ==> (!!x. x : A ==> B x b c ==> R) ==> R" - by (auto simp add: SUPR_apply) - -lemma SUP_UN_eq: "(SUP i. (\x. x \ r i)) = (\x. x \ (UN i. r i))" - by (simp add: SUPR_apply fun_eq_iff) - -lemma SUP_UN_eq2: "(SUP i. (\x y. (x, y) \ r i)) = (\x y. (x, y) \ (UN i. r i))" - by (simp add: SUPR_apply fun_eq_iff) - - subsubsection {* Intersections of families *} lemma INF1_iff: "(INF x:A. B x) b = (ALL x:A. B x b)" @@ -242,6 +215,33 @@ by (simp add: INFI_apply fun_eq_iff) +subsubsection {* Unions of families *} + +lemma SUP1_iff: "(SUP x:A. B x) b = (EX x:A. B x b)" + by (simp add: SUPR_apply) + +lemma SUP2_iff: "(SUP x:A. B x) b c = (EX x:A. B x b c)" + by (simp add: SUPR_apply) + +lemma SUP1_I [intro]: "a : A ==> B a b ==> (SUP x:A. B x) b" + by (auto simp add: SUPR_apply) + +lemma SUP2_I [intro]: "a : A ==> B a b c ==> (SUP x:A. B x) b c" + by (auto simp add: SUPR_apply) + +lemma SUP1_E [elim!]: "(SUP x:A. B x) b ==> (!!x. x : A ==> B x b ==> R) ==> R" + by (auto simp add: SUPR_apply) + +lemma SUP2_E [elim!]: "(SUP x:A. B x) b c ==> (!!x. x : A ==> B x b c ==> R) ==> R" + by (auto simp add: SUPR_apply) + +lemma SUP_UN_eq: "(SUP i. (\x. x \ r i)) = (\x. x \ (UN i. r i))" + by (simp add: SUPR_apply fun_eq_iff) + +lemma SUP_UN_eq2: "(SUP i. (\x y. (x, y) \ r i)) = (\x y. (x, y) \ (UN i. r i))" + by (simp add: SUPR_apply fun_eq_iff) + + subsection {* Predicates as relations *} subsubsection {* Composition *} @@ -1027,19 +1027,19 @@ *} no_notation + bot ("\") and + top ("\") and inf (infixl "\" 70) and sup (infixl "\" 65) and Inf ("\_" [900] 900) and Sup ("\_" [900] 900) and - top ("\") and - bot ("\") and bind (infixl "\=" 70) no_syntax (xsymbols) + "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) + "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) "_SUP1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) "_SUP" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) - "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) - "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) hide_type (open) pred seq hide_const (open) Pred eval single bind is_empty singleton if_pred not_pred holds diff -r fb1e5377143d -r 9ff94e7cc3b3 src/HOL/Set.thy --- a/src/HOL/Set.thy Wed Dec 08 14:52:23 2010 +0100 +++ b/src/HOL/Set.thy Wed Dec 08 15:05:46 2010 +0100 @@ -533,6 +533,36 @@ by simp +subsubsection {* The empty set *} + +lemma empty_def: + "{} = {x. False}" + by (simp add: bot_fun_def bot_bool_def Collect_def) + +lemma empty_iff [simp]: "(c : {}) = False" + by (simp add: empty_def) + +lemma emptyE [elim!]: "a : {} ==> P" + by simp + +lemma empty_subsetI [iff]: "{} \ A" + -- {* One effect is to delete the ASSUMPTION @{prop "{} <= A"} *} + by blast + +lemma equals0I: "(!!y. y \ A ==> False) ==> A = {}" + by blast + +lemma equals0D: "A = {} ==> a \ A" + -- {* Use for reasoning about disjointness: @{text "A Int B = {}"} *} + by blast + +lemma ball_empty [simp]: "Ball {} P = True" + by (simp add: Ball_def) + +lemma bex_empty [simp]: "Bex {} P = False" + by (simp add: Bex_def) + + subsubsection {* The universal set -- UNIV *} abbreviation UNIV :: "'a set" where @@ -568,36 +598,6 @@ lemma UNIV_eq_I: "(\x. x \ A) \ UNIV = A" by auto - -subsubsection {* The empty set *} - -lemma empty_def: - "{} = {x. False}" - by (simp add: bot_fun_def bot_bool_def Collect_def) - -lemma empty_iff [simp]: "(c : {}) = False" - by (simp add: empty_def) - -lemma emptyE [elim!]: "a : {} ==> P" - by simp - -lemma empty_subsetI [iff]: "{} \ A" - -- {* One effect is to delete the ASSUMPTION @{prop "{} <= A"} *} - by blast - -lemma equals0I: "(!!y. y \ A ==> False) ==> A = {}" - by blast - -lemma equals0D: "A = {} ==> a \ A" - -- {* Use for reasoning about disjointness: @{text "A Int B = {}"} *} - by blast - -lemma ball_empty [simp]: "Ball {} P = True" - by (simp add: Ball_def) - -lemma bex_empty [simp]: "Bex {} P = False" - by (simp add: Bex_def) - lemma UNIV_not_empty [iff]: "UNIV ~= {}" by (blast elim: equalityE) @@ -647,7 +647,41 @@ lemma Compl_eq: "- A = {x. ~ x : A}" by blast -subsubsection {* Binary union -- Un *} +subsubsection {* Binary intersection *} + +abbreviation inter :: "'a set \ 'a set \ 'a set" (infixl "Int" 70) where + "op Int \ inf" + +notation (xsymbols) + inter (infixl "\" 70) + +notation (HTML output) + inter (infixl "\" 70) + +lemma Int_def: + "A \ B = {x. x \ A \ x \ B}" + by (simp add: inf_fun_def inf_bool_def Collect_def mem_def) + +lemma Int_iff [simp]: "(c : A Int B) = (c:A & c:B)" + by (unfold Int_def) blast + +lemma IntI [intro!]: "c:A ==> c:B ==> c : A Int B" + by simp + +lemma IntD1: "c : A Int B ==> c:A" + by simp + +lemma IntD2: "c : A Int B ==> c:B" + by simp + +lemma IntE [elim!]: "c : A Int B ==> (c:A ==> c:B ==> P) ==> P" + by simp + +lemma mono_Int: "mono f \ f (A \ B) \ f A \ f B" + by (fact mono_inf) + + +subsubsection {* Binary union *} abbreviation union :: "'a set \ 'a set \ 'a set" (infixl "Un" 65) where "union \ sup" @@ -689,40 +723,6 @@ by (fact mono_sup) -subsubsection {* Binary intersection -- Int *} - -abbreviation inter :: "'a set \ 'a set \ 'a set" (infixl "Int" 70) where - "op Int \ inf" - -notation (xsymbols) - inter (infixl "\" 70) - -notation (HTML output) - inter (infixl "\" 70) - -lemma Int_def: - "A \ B = {x. x \ A \ x \ B}" - by (simp add: inf_fun_def inf_bool_def Collect_def mem_def) - -lemma Int_iff [simp]: "(c : A Int B) = (c:A & c:B)" - by (unfold Int_def) blast - -lemma IntI [intro!]: "c:A ==> c:B ==> c : A Int B" - by simp - -lemma IntD1: "c : A Int B ==> c:A" - by simp - -lemma IntD2: "c : A Int B ==> c:B" - by simp - -lemma IntE [elim!]: "c : A Int B ==> (c:A ==> c:B ==> P) ==> P" - by simp - -lemma mono_Int: "mono f \ f (A \ B) \ f A \ f B" - by (fact mono_inf) - - subsubsection {* Set difference *} lemma Diff_iff [simp]: "(c : A - B) = (c:A & c~:B)"