# HG changeset patch # User haftmann # Date 1291816343 -3600 # Node ID 294956ff285b5556755512b1e3a9a845ccbc1f1f # Parent a0d9258e2091c9ca331ac113a7a52d9b7eed1427 nice syntax for lattice INFI, SUPR; various *_apply rules for lattice operations on fun; more default simplification rules diff -r a0d9258e2091 -r 294956ff285b 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 14:52:23 2010 +0100 @@ -44,14 +44,22 @@ lemma Sup_Inf: "\A = \{b. \a \ A. a \ b}" by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least) -lemma Inf_empty: +lemma Inf_empty [simp]: "\{} = \" by (auto intro: antisym Inf_greatest) -lemma Sup_empty: +lemma Sup_empty [simp]: "\{} = \" by (auto intro: antisym Sup_least) +lemma Inf_UNIV [simp]: + "\UNIV = \" + by (simp add: Sup_Inf Sup_empty [symmetric]) + +lemma Sup_UNIV [simp]: + "\UNIV = \" + by (simp add: Inf_Sup Inf_empty [symmetric]) + lemma Inf_insert: "\insert a A = a \ \A" by (auto intro: le_infI le_infI1 le_infI2 antisym Inf_greatest Inf_lower) @@ -74,14 +82,6 @@ "\{a, b} = a \ b" by (simp add: Sup_empty Sup_insert) -lemma Inf_UNIV: - "\UNIV = bot" - by (simp add: Sup_Inf Sup_empty [symmetric]) - -lemma Sup_UNIV: - "\UNIV = top" - by (simp add: Inf_Sup Inf_empty [symmetric]) - lemma Sup_le_iff: "Sup A \ b \ (\a\A. a \ b)" by (auto intro: Sup_least dest: Sup_upper) @@ -117,10 +117,16 @@ end syntax - "_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) + "_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) + "_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 "SUP x y. B" == "SUP x. SUP y. B" @@ -212,25 +218,17 @@ begin definition - Inf_bool_def: "\A \ (\x\A. x)" + "\A \ (\x\A. x)" definition - Sup_bool_def: "\A \ (\x\A. x)" + "\A \ (\x\A. x)" instance proof qed (auto simp add: Inf_bool_def Sup_bool_def le_bool_def) end -lemma Inf_empty_bool [simp]: - "\{}" - unfolding Inf_bool_def by auto - -lemma not_Sup_empty_bool [simp]: - "\ \{}" - unfolding Sup_bool_def by auto - -lemma INFI_bool_eq: +lemma INFI_bool_eq [simp]: "INFI = Ball" proof (rule ext)+ fix A :: "'a set" @@ -239,7 +237,7 @@ by (auto simp add: Ball_def INFI_def Inf_bool_def) qed -lemma SUPR_bool_eq: +lemma SUPR_bool_eq [simp]: "SUPR = Bex" proof (rule ext)+ fix A :: "'a set" @@ -252,36 +250,32 @@ begin definition - Inf_fun_def: "\A = (\x. \{y. \f\A. y = f x})" + "\A = (\x. \{y. \f\A. y = f x})" + +lemma Inf_apply: + "(\A) x = \{y. \f\A. y = f x}" + by (simp add: Inf_fun_def) definition - Sup_fun_def: "\A = (\x. \{y. \f\A. y = f x})" + "\A = (\x. \{y. \f\A. y = f x})" + +lemma Sup_apply: + "(\A) x = \{y. \f\A. y = f x}" + by (simp add: Sup_fun_def) instance proof -qed (auto simp add: Inf_fun_def Sup_fun_def le_fun_def +qed (auto simp add: le_fun_def Inf_apply Sup_apply intro: Inf_lower Sup_upper Inf_greatest Sup_least) end -lemma SUPR_fun_expand: - fixes f :: "'a \ 'b \ 'c\{complete_lattice}" - shows "(SUP y:A. f y) = (\x. SUP y:A. f y x)" - by (auto intro!: arg_cong[where f=Sup] ext[where 'a='b] - simp: SUPR_def Sup_fun_def) +lemma INFI_apply: + "(\y\A. f y) x = (\y\A. f y x)" + by (auto intro: arg_cong [of _ _ Inf] simp add: INFI_def Inf_apply) -lemma INFI_fun_expand: - fixes f :: "'a \ 'b \ 'c\{complete_lattice}" - shows "(INF y:A. f y) x = (INF y:A. f y x)" - by (auto intro!: arg_cong[where f=Inf] ext[where 'a='b] - simp: INFI_def Inf_fun_def) - -lemma Inf_empty_fun: - "\{} = (\_. \{})" - by (simp add: Inf_fun_def) - -lemma Sup_empty_fun: - "\{} = (\_. \{})" - by (simp add: Sup_fun_def) +lemma SUPR_apply: + "(\y\A. f y) x = (\y\A. f y x)" + by (auto intro: arg_cong [of _ _ Sup] simp add: SUPR_def Sup_apply) subsection {* Union *} @@ -572,7 +566,7 @@ by blast lemma Inter_empty [simp]: "\{} = UNIV" - by blast + by (fact Inf_empty) lemma Inter_UNIV [simp]: "\UNIV = {}" by blast @@ -871,6 +865,12 @@ top ("\") and bot ("\") +no_syntax (xsymbols) + "_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 mem_Collect_eq UN_iff Union_iff INT_iff Inter_iff diff -r a0d9258e2091 -r 294956ff285b 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 14:52:23 2010 +0100 @@ -587,34 +587,33 @@ begin definition - bool_Compl_def: "uminus = Not" + bool_Compl_def [simp]: "uminus = Not" definition - bool_diff_def: "A - B \ A \ \ B" + bool_diff_def [simp]: "A - B \ A \ \ B" definition - inf_bool_def: "P \ Q \ P \ Q" + [simp]: "P \ Q \ P \ Q" definition - sup_bool_def: "P \ Q \ P \ Q" + [simp]: "P \ Q \ P \ Q" instance proof -qed (simp_all add: inf_bool_def sup_bool_def le_bool_def - bot_bool_def top_bool_def bool_Compl_def bool_diff_def, auto) +qed auto end lemma sup_boolI1: "P \ P \ Q" - by (simp add: sup_bool_def) + by simp lemma sup_boolI2: "Q \ P \ Q" - by (simp add: sup_bool_def) + by simp lemma sup_boolE: "P \ Q \ (P \ R) \ (Q \ R) \ R" - by (auto simp add: sup_bool_def) + by auto subsection {* Fun as lattice *} @@ -623,19 +622,26 @@ begin definition - inf_fun_def: "f \ g = (\x. f x \ g x)" + "f \ g = (\x. f x \ g x)" + +lemma inf_apply: + "(f \ g) x = f x \ g x" + by (simp add: inf_fun_def) definition - sup_fun_def: "f \ g = (\x. f x \ g x)" + "f \ g = (\x. f x \ g x)" + +lemma sup_apply: + "(f \ g) x = f x \ g x" + by (simp add: sup_fun_def) instance proof -qed (simp_all add: le_fun_def inf_fun_def sup_fun_def) +qed (simp_all add: le_fun_def inf_apply sup_apply) end -instance "fun" :: (type, distrib_lattice) distrib_lattice -proof -qed (simp_all add: inf_fun_def sup_fun_def sup_inf_distrib1) +instance "fun" :: (type, distrib_lattice) distrib_lattice proof +qed (rule ext, simp add: sup_inf_distrib1 inf_apply sup_apply) instance "fun" :: (type, bounded_lattice) bounded_lattice .. @@ -645,6 +651,10 @@ definition fun_Compl_def: "- A = (\x. - A x)" +lemma uminus_apply: + "(- A) x = - (A x)" + by (simp add: fun_Compl_def) + instance .. end @@ -655,15 +665,16 @@ definition fun_diff_def: "A - B = (\x. A x - B x)" +lemma minus_apply: + "(A - B) x = A x - B x" + by (simp add: fun_diff_def) + instance .. end -instance "fun" :: (type, boolean_algebra) boolean_algebra -proof -qed (simp_all add: inf_fun_def sup_fun_def bot_fun_def top_fun_def fun_Compl_def fun_diff_def - inf_compl_bot sup_compl_top diff_eq) - +instance "fun" :: (type, boolean_algebra) boolean_algebra proof +qed (rule ext, simp_all add: inf_apply sup_apply bot_apply top_apply uminus_apply minus_apply inf_compl_bot sup_compl_top diff_eq)+ no_notation less_eq (infix "\" 50) and diff -r a0d9258e2091 -r 294956ff285b 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 14:52:23 2010 +0100 @@ -14,4 +14,10 @@ Inf ("\_" [900] 900) and Sup ("\_" [900] 900) +syntax (xsymbols) + "_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 a0d9258e2091 -r 294956ff285b 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 14:52:23 2010 +0100 @@ -1208,46 +1208,46 @@ begin definition - le_bool_def: "P \ Q \ P \ Q" + le_bool_def [simp]: "P \ Q \ P \ Q" definition - less_bool_def: "(P\bool) < Q \ \ P \ Q" + [simp]: "(P\bool) < Q \ \ P \ Q" definition - top_bool_def: "top = True" + [simp]: "top \ True" definition - bot_bool_def: "bot = False" + [simp]: "bot \ False" instance proof -qed (auto simp add: bot_bool_def top_bool_def less_bool_def, auto simp add: le_bool_def) +qed auto end lemma le_boolI: "(P \ Q) \ P \ Q" - by (simp add: le_bool_def) + by simp lemma le_boolI': "P \ Q \ P \ Q" - by (simp add: le_bool_def) + by simp lemma le_boolE: "P \ Q \ P \ (Q \ R) \ R" - by (simp add: le_bool_def) + by simp lemma le_boolD: "P \ Q \ P \ Q" - by (simp add: le_bool_def) + by simp lemma bot_boolE: "bot \ P" - by (simp add: bot_bool_def) + by simp lemma top_boolI: top - by (simp add: top_bool_def) + by simp lemma [code]: "False \ b \ True" "True \ b \ b" "False < b \ b" "True < b \ False" - unfolding le_bool_def less_bool_def by simp_all + by simp_all subsection {* Order on functions *} @@ -1259,7 +1259,7 @@ le_fun_def: "f \ g \ (\x. f x \ g x)" definition - less_fun_def: "(f\'a \ 'b) < g \ f \ g \ \ (g \ f)" + "(f\'a \ 'b) < g \ f \ g \ \ (g \ f)" instance .. @@ -1276,11 +1276,15 @@ begin definition - top_fun_def [no_atp]: "top = (\x. top)" + [no_atp]: "top = (\x. top)" declare top_fun_def_raw [no_atp] +lemma top_apply: + "top x = top" + by (simp add: top_fun_def) + instance proof -qed (simp add: top_fun_def le_fun_def) +qed (simp add: le_fun_def top_apply) end @@ -1288,10 +1292,14 @@ begin definition - bot_fun_def: "bot = (\x. bot)" + "bot = (\x. bot)" + +lemma bot_apply: + "bot x = bot" + by (simp add: bot_fun_def) instance proof -qed (simp add: bot_fun_def le_fun_def) +qed (simp add: le_fun_def bot_apply) end diff -r a0d9258e2091 -r 294956ff285b 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 14:52:23 2010 +0100 @@ -16,6 +16,12 @@ top ("\") and bot ("\") +syntax (xsymbols) + "_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 *} @@ -179,61 +185,61 @@ subsubsection {* Unions of families *} lemma SUP1_iff: "(SUP x:A. B x) b = (EX x:A. B x b)" - by (simp add: SUPR_def Sup_fun_def Sup_bool_def) blast + 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_def Sup_fun_def Sup_bool_def) blast + by (simp add: SUPR_apply) lemma SUP1_I [intro]: "a : A ==> B a b ==> (SUP x:A. B x) b" - by (auto simp add: SUP1_iff) + 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: SUP2_iff) + 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: SUP1_iff) + 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: SUP2_iff) + 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: SUP1_iff fun_eq_iff) + 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: SUP2_iff fun_eq_iff) + 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)" - by (simp add: INFI_def Inf_fun_def Inf_bool_def) blast + by (simp add: INFI_apply) lemma INF2_iff: "(INF x:A. B x) b c = (ALL x:A. B x b c)" - by (simp add: INFI_def Inf_fun_def Inf_bool_def) blast + by (simp add: INFI_apply) lemma INF1_I [intro!]: "(!!x. x : A ==> B x b) ==> (INF x:A. B x) b" - by (auto simp add: INF1_iff) + by (auto simp add: INFI_apply) lemma INF2_I [intro!]: "(!!x. x : A ==> B x b c) ==> (INF x:A. B x) b c" - by (auto simp add: INF2_iff) + by (auto simp add: INFI_apply) lemma INF1_D [elim]: "(INF x:A. B x) b ==> a : A ==> B a b" - by (auto simp add: INF1_iff) + by (auto simp add: INFI_apply) lemma INF2_D [elim]: "(INF x:A. B x) b c ==> a : A ==> B a b c" - by (auto simp add: INF2_iff) + by (auto simp add: INFI_apply) lemma INF1_E [elim]: "(INF x:A. B x) b ==> (B a b ==> R) ==> (a ~: A ==> R) ==> R" - by (auto simp add: INF1_iff) + by (auto simp add: INFI_apply) lemma INF2_E [elim]: "(INF x:A. B x) b c ==> (B a b c ==> R) ==> (a ~: A ==> R) ==> R" - by (auto simp add: INF2_iff) + by (auto simp add: INFI_apply) lemma INF_INT_eq: "(INF i. (\x. x \ r i)) = (\x. x \ (INT i. r i))" - by (simp add: INF1_iff fun_eq_iff) + by (simp add: INFI_apply fun_eq_iff) lemma INF_INT_eq2: "(INF i. (\x y. (x, y) \ r i)) = (\x y. (x, y) \ (INT i. r i))" - by (simp add: INF2_iff fun_eq_iff) + by (simp add: INFI_apply fun_eq_iff) subsection {* Predicates as relations *} @@ -493,8 +499,7 @@ by (simp add: minus_pred_def) instance proof -qed (auto intro!: pred_eqI simp add: less_eq_pred_def less_pred_def - fun_Compl_def fun_diff_def bool_Compl_def bool_diff_def) +qed (auto intro!: pred_eqI simp add: less_eq_pred_def less_pred_def uminus_apply minus_apply) end @@ -514,10 +519,10 @@ by (simp add: single_def) definition bind :: "'a pred \ ('a \ 'b pred) \ 'b pred" (infixl "\=" 70) where - "P \= f = (SUPR {x. Predicate.eval P x} f)" + "P \= f = (SUPR {x. eval P x} f)" lemma eval_bind [simp]: - "eval (P \= f) = Predicate.eval (SUPR {x. Predicate.eval P x} f)" + "eval (P \= f) = eval (SUPR {x. eval P x} f)" by (simp add: bind_def) lemma bind_bind: @@ -822,7 +827,7 @@ "single x = Seq (\u. Insert x \)" unfolding Seq_def by simp -primrec "apply" :: "('a \ 'b Predicate.pred) \ 'a seq \ 'b seq" where +primrec "apply" :: "('a \ 'b pred) \ 'a seq \ 'b seq" where "apply f Empty = Empty" | "apply f (Insert x P) = Join (f x) (Join (P \= f) Empty)" | "apply f (Join P xq) = Join (P \= f) (apply f xq)" @@ -972,7 +977,7 @@ "the A = (THE x. eval A x)" lemma the_eqI: - "(THE x. Predicate.eval P x) = x \ Predicate.the P = x" + "(THE x. eval P x) = x \ the P = x" by (simp add: the_def) lemma the_eq [code]: "the A = singleton (\x. not_unique A) A" @@ -1030,6 +1035,12 @@ bot ("\") and bind (infixl "\=" 70) +no_syntax (xsymbols) + "_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 Empty Insert Join Seq member pred_of_seq "apply" adjunct null the_only eq map not_unique the diff -r a0d9258e2091 -r 294956ff285b src/HOL/Probability/Borel_Space.thy --- a/src/HOL/Probability/Borel_Space.thy Wed Dec 08 14:52:23 2010 +0100 +++ b/src/HOL/Probability/Borel_Space.thy Wed Dec 08 14:52:23 2010 +0100 @@ -1391,7 +1391,7 @@ proof safe fix a have "{x\space M. a < ?sup x} = (\i\A. {x\space M. a < f i x})" - by (auto simp: less_Sup_iff SUPR_def[where 'a=pextreal] SUPR_fun_expand[where 'c=pextreal]) + by (auto simp: less_Sup_iff SUPR_def[where 'a=pextreal] SUPR_apply[where 'c=pextreal]) then show "{x\space M. a < ?sup x} \ sets M" using assms by auto qed @@ -1404,7 +1404,7 @@ proof safe fix a have "{x\space M. ?inf x < a} = (\i\A. {x\space M. f i x < a})" - by (auto simp: Inf_less_iff INFI_def[where 'a=pextreal] INFI_fun_expand) + by (auto simp: Inf_less_iff INFI_def[where 'a=pextreal] INFI_apply) then show "{x\space M. ?inf x < a} \ sets M" using assms by auto qed @@ -1427,7 +1427,7 @@ assumes "\i. f i \ borel_measurable M" shows "(\x. (\\<^isub>\ i. f i x)) \ borel_measurable M" using assms unfolding psuminf_def - by (auto intro!: borel_measurable_SUP[unfolded SUPR_fun_expand]) + by (auto intro!: borel_measurable_SUP[unfolded SUPR_apply]) section "LIMSEQ is borel measurable" @@ -1456,7 +1456,7 @@ with eq[THEN measurable_cong, of M "\x. x" borel] have "(\x. Real (u' x)) \ borel_measurable M" "(\x. Real (- u' x)) \ borel_measurable M" - unfolding SUPR_fun_expand INFI_fun_expand by auto + unfolding SUPR_apply INFI_apply by auto note this[THEN borel_measurable_real] from borel_measurable_diff[OF this] show ?thesis unfolding * .