diff -r 27f3c10b0b50 -r 4cf66f21b764 src/HOL/Set.thy --- a/src/HOL/Set.thy Mon Dec 07 10:23:50 2015 +0100 +++ b/src/HOL/Set.thy Mon Dec 07 10:38:04 2015 +0100 @@ -10,8 +10,8 @@ typedecl 'a set -axiomatization Collect :: "('a \ bool) \ 'a set" -- "comprehension" - and member :: "'a \ 'a set \ bool" -- "membership" +axiomatization Collect :: "('a \ bool) \ 'a set" \ "comprehension" + and member :: "'a \ 'a set \ bool" \ "membership" where mem_Collect_eq [iff, code_unfold]: "member a (Collect P) = P a" and Collect_mem_eq [simp]: "Collect (\x. member x A) = A" @@ -21,7 +21,7 @@ member ("(_/ : _)" [51, 51] 50) abbreviation not_member where - "not_member x A \ ~ (x : A)" -- "non-membership" + "not_member x A \ ~ (x : A)" \ "non-membership" notation not_member ("op ~:") and @@ -58,8 +58,8 @@ by simp text \ -Simproc for pulling @{text "x=t"} in @{text "{x. \ & x=t & \}"} -to the front (and similarly for @{text "t=x"}): +Simproc for pulling \x=t\ in \{x. \ & x=t & \}\ +to the front (and similarly for \t=x\): \ simproc_setup defined_Collect ("{x. P x & Q x}") = \ @@ -176,10 +176,10 @@ supset_eq ("(_/ \ _)" [51, 51] 50) definition Ball :: "'a set \ ('a \ bool) \ bool" where - "Ball A P \ (\x. x \ A \ P x)" -- "bounded universal quantifiers" + "Ball A P \ (\x. x \ A \ P x)" \ "bounded universal quantifiers" definition Bex :: "'a set \ ('a \ bool) \ bool" where - "Bex A P \ (\x. x \ A \ P x)" -- "bounded existential quantifiers" + "Bex A P \ (\x. x \ A \ P x)" \ "bounded existential quantifiers" syntax "_Ball" :: "pttrn => 'a set => bool => bool" ("(3ALL _:_./ _)" [0, 0, 10] 10) @@ -267,9 +267,8 @@ text \ - \medskip Translate between @{text "{e | x1...xn. P}"} and @{text - "{u. EX x1..xn. u = e & P}"}; @{text "{y. EX x1..xn. y = e & P}"} is - only translated if @{text "[0..n] subset bvs(e)"}. + \medskip Translate between \{e | x1...xn. P}\ and \{u. EX x1..xn. u = e & P}\; \{y. EX x1..xn. y = e & P}\ is + only translated if \[0..n] subset bvs(e)\. \ syntax @@ -295,7 +294,7 @@ print_translation \ [Syntax_Trans.preserve_binder_abs2_tr' @{const_syntax Ball} @{syntax_const "_Ball"}, Syntax_Trans.preserve_binder_abs2_tr' @{const_syntax Bex} @{syntax_const "_Bex"}] -\ -- \to avoid eta-contraction of body\ +\ \ \to avoid eta-contraction of body\ print_translation \ let @@ -383,12 +382,12 @@ by (unfold Ball_def) blast lemma bexI [intro]: "P x ==> x:A ==> EX x:A. P x" - -- \Normally the best argument order: @{prop "P x"} constrains the + \ \Normally the best argument order: @{prop "P x"} constrains the choice of @{prop "x:A"}.\ by (unfold Bex_def) blast lemma rev_bexI [intro?]: "x:A ==> P x ==> EX x:A. P x" - -- \The best argument order when there is only one @{prop "x:A"}.\ + \ \The best argument order when there is only one @{prop "x:A"}.\ by (unfold Bex_def) blast lemma bexCI: "(ALL x:A. ~P x ==> P a) ==> a:A ==> EX x:A. P x" @@ -398,11 +397,11 @@ by (unfold Bex_def) blast lemma ball_triv [simp]: "(ALL x:A. P) = ((EX x. x:A) --> P)" - -- \Trival rewrite rule.\ + \ \Trival rewrite rule.\ by (simp add: Ball_def) lemma bex_triv [simp]: "(EX x:A. P) = ((EX x. x:A) & P)" - -- \Dual form for existentials.\ + \ \Dual form for existentials.\ by (simp add: Bex_def) lemma bex_triv_one_point1 [simp]: "(EX x:A. x = a) = (a:A)" @@ -465,18 +464,18 @@ by (simp add: less_eq_set_def le_fun_def) text \ - \medskip Map the type @{text "'a set => anything"} to just @{typ + \medskip Map the type \'a set => anything\ to just @{typ 'a}; for overloading constants whose first argument has type @{typ "'a set"}. \ lemma subsetD [elim, intro?]: "A \ B ==> c \ A ==> c \ B" by (simp add: less_eq_set_def le_fun_def) - -- \Rule in Modus Ponens style.\ + \ \Rule in Modus Ponens style.\ lemma rev_subsetD [intro?]: "c \ A ==> A \ B ==> c \ B" - -- \The same, with reversed premises for use with @{text erule} -- - cf @{text rev_mp}.\ + \ \The same, with reversed premises for use with \erule\ -- + cf \rev_mp\.\ by (rule subsetD) text \ @@ -484,7 +483,7 @@ \ lemma subsetCE [elim]: "A \ B ==> (c \ A ==> P) ==> (c \ B ==> P) ==> P" - -- \Classical elimination rule.\ + \ \Classical elimination rule.\ by (auto simp add: less_eq_set_def le_fun_def) lemma subset_eq: "A \ B = (\x\A. x \ B)" by blast @@ -518,7 +517,7 @@ subsubsection \Equality\ lemma subset_antisym [intro!]: "A \ B ==> B \ A ==> A = B" - -- \Anti-symmetry of the subset relation.\ + \ \Anti-symmetry of the subset relation.\ by (iprover intro: set_eqI subsetD) text \ @@ -533,8 +532,7 @@ by simp text \ - \medskip Be careful when adding this to the claset as @{text - subset_empty} is in the simpset: @{prop "A = {}"} goes to @{prop "{} + \medskip Be careful when adding this to the claset as \subset_empty\ is in the simpset: @{prop "A = {}"} goes to @{prop "{} \ A"} and @{prop "A \ {}"} and then back to @{prop "A = {}"}! \ @@ -565,14 +563,14 @@ by simp lemma empty_subsetI [iff]: "{} \ A" - -- \One effect is to delete the ASSUMPTION @{prop "{} <= 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 = {}"}\ + \ \Use for reasoning about disjointness: \A Int B = {}\\ by blast lemma ball_empty [simp]: "Ball {} P = True" @@ -594,7 +592,7 @@ lemma UNIV_I [simp]: "x : UNIV" by (simp add: UNIV_def) -declare UNIV_I [intro] -- \unsafe makes it less likely to cause problems\ +declare UNIV_I [intro] \ \unsafe makes it less likely to cause problems\ lemma UNIV_witness [intro?]: "EX x. x : UNIV" by simp @@ -603,7 +601,7 @@ by (fact top_greatest) (* already simp *) text \ - \medskip Eta-contracting these two rules (to remove @{text P}) + \medskip Eta-contracting these two rules (to remove \P\) causes them to be ignored because of their interaction with congruence rules. \ @@ -777,7 +775,7 @@ by (unfold insert_def) blast lemma insertCI [intro!]: "(a~:B ==> a = b) ==> a: insert b B" - -- \Classical introduction rule.\ + \ \Classical introduction rule.\ by auto lemma subset_insert_iff: "(A \ insert x B) = (if x:A then A - {x} \ B else A \ B)" @@ -821,7 +819,7 @@ subsubsection \Singletons, using insert\ lemma singletonI [intro!]: "a : {a}" - -- \Redundant? But unlike @{text insertCI}, it proves the subgoal immediately!\ + \ \Redundant? But unlike \insertCI\, it proves the subgoal immediately!\ by (rule insertI1) lemma singletonD [dest!]: "b : {a} ==> b = a" @@ -887,12 +885,12 @@ lemma rev_image_eqI: "x \ A \ b = f x \ b \ f ` A" - -- \This version's more effective when we already have the + \ \This version's more effective when we already have the required @{term x}.\ by (rule image_eqI) lemma imageE [elim!]: - assumes "b \ (\x. f x) ` A" -- \The eta-expansion gives variable-name preservation.\ + assumes "b \ (\x. f x) ` A" \ \The eta-expansion gives variable-name preservation.\ obtains x where "b = f x" and "x \ A" using assms by (unfold image_def) blast @@ -910,13 +908,13 @@ lemma image_subsetI: "(\x. x \ A \ f x \ B) \ f ` A \ B" - -- \Replaces the three steps @{text subsetI}, @{text imageE}, - @{text hypsubst}, but breaks too many existing proofs.\ + \ \Replaces the three steps \subsetI\, \imageE\, + \hypsubst\, but breaks too many existing proofs.\ by blast lemma image_subset_iff: "f ` A \ B \ (\x\A. f x \ B)" - -- \This rewrite rule would confuse users if made default.\ + \ \This rewrite rule would confuse users if made default.\ by blast lemma subset_imageE: @@ -970,7 +968,7 @@ lemma image_Collect: "f ` {x. P x} = {f x | x. P x}" - -- \NOT suitable as a default simprule: the RHS isn't simpler than the LHS, + \ \NOT suitable as a default simprule: the RHS isn't simpler than the LHS, with its implicit quantifier and conjunction. Also image enjoys better equational properties than does the RHS.\ by blast @@ -1011,7 +1009,7 @@ \ abbreviation range :: "('a \ 'b) \ 'b set" -where -- "of function" +where \ "of function" "range f \ f ` UNIV" lemma range_eqI: @@ -1035,9 +1033,9 @@ by auto -subsubsection \Some rules with @{text "if"}\ - -text\Elimination of @{text"{x. \ & x=t & \}"}.\ +subsubsection \Some rules with \if\\ + +text\Elimination of \{x. \ & x=t & \}\.\ lemma Collect_conv_if: "{x. x=a & P x} = (if P a then {a} else {})" by auto @@ -1046,8 +1044,7 @@ by auto text \ - Rewrite rules for boolean case-splitting: faster than @{text - "split_if [split]"}. + Rewrite rules for boolean case-splitting: faster than \split_if [split]\. \ lemma split_if_eq1: "((if Q then x else y) = b) = ((Q --> x = b) & (~ Q --> y = b))" @@ -1057,8 +1054,7 @@ by (rule split_if) text \ - Split ifs on either side of the membership relation. Not for @{text - "[simp]"} -- can cause goals to blow up! + Split ifs on either side of the membership relation. Not for \[simp]\ -- can cause goals to blow up! \ lemma split_if_mem1: "((if Q then x else y) : b) = ((Q --> x : b) & (~ Q --> y : b))" @@ -1139,7 +1135,7 @@ subsubsection \Derived rules involving subsets.\ -text \@{text insert}.\ +text \\insert\.\ lemma subset_insertI: "B \ insert a B" by (rule subsetI) (erule insertI2) @@ -1186,10 +1182,10 @@ subsubsection \Equalities involving union, intersection, inclusion, etc.\ -text \@{text "{}"}.\ +text \\{}\.\ lemma Collect_const [simp]: "{s. P} = (if P then UNIV else {})" - -- \supersedes @{text "Collect_False_empty"}\ + \ \supersedes \Collect_False_empty\\ by auto lemma subset_empty [simp]: "(A \ {}) = (A = {})" @@ -1220,10 +1216,10 @@ by blast -text \\medskip @{text insert}.\ +text \\medskip \insert\.\ lemma insert_is_Un: "insert a A = {a} Un A" - -- \NOT SUITABLE FOR REWRITING since @{text "{a} == insert a {}"}\ + \ \NOT SUITABLE FOR REWRITING since \{a} == insert a {}\\ by blast lemma insert_not_empty [simp]: "insert a A \ {}" @@ -1233,8 +1229,8 @@ declare empty_not_insert [simp] lemma insert_absorb: "a \ A ==> insert a A = A" - -- \@{text "[simp]"} causes recursive calls when there are nested inserts\ - -- \with \emph{quadratic} running time\ + \ \\[simp]\ causes recursive calls when there are nested inserts\ + \ \with \emph{quadratic} running time\ by blast lemma insert_absorb2 [simp]: "insert x (insert x A) = insert x A" @@ -1247,7 +1243,7 @@ by blast lemma mk_disjoint_insert: "a \ A ==> \B. A = insert a B & a \ B" - -- \use new @{text B} rather than @{text "A - {a}"} to avoid infinite unfolding\ + \ \use new \B\ rather than \A - {a}\ to avoid infinite unfolding\ apply (rule_tac x = "A - {a}" in exI, blast) done @@ -1268,7 +1264,7 @@ by auto -text \\medskip @{text Int}\ +text \\medskip \Int\\ lemma Int_absorb: "A \ A = A" by (fact inf_idem) (* already simp *) @@ -1286,7 +1282,7 @@ by (fact inf_assoc) lemmas Int_ac = Int_assoc Int_left_absorb Int_commute Int_left_commute - -- \Intersection is an AC-operator\ + \ \Intersection is an AC-operator\ lemma Int_absorb1: "B \ A ==> A \ B = B" by (fact inf_absorb2) @@ -1328,7 +1324,7 @@ by blast -text \\medskip @{text Un}.\ +text \\medskip \Un\.\ lemma Un_absorb: "A \ A = A" by (fact sup_idem) (* already simp *) @@ -1346,7 +1342,7 @@ by (fact sup_assoc) lemmas Un_ac = Un_assoc Un_left_absorb Un_commute Un_left_commute - -- \Union is an AC-operator\ + \ \Union is an AC-operator\ lemma Un_absorb1: "A \ B ==> A \ B = B" by (fact sup_absorb2) @@ -1449,7 +1445,7 @@ by blast lemma Un_Int_assoc_eq: "((A \ B) \ C = A \ (B \ C)) = (C \ A)" - -- \Halmos, Naive Set Theory, page 16.\ + \ \Halmos, Naive Set Theory, page 16.\ by blast lemma Compl_UNIV_eq: "-UNIV = {}" @@ -1470,7 +1466,7 @@ text \\medskip Bounded quantifiers. The following are not added to the default simpset because - (a) they duplicate the body and (b) there are no similar rules for @{text Int}.\ + (a) they duplicate the body and (b) there are no similar rules for \Int\.\ lemma ball_Un: "(\x \ A \ B. P x) = ((\x\A. P x) & (\x\B. P x))" by blast @@ -1509,11 +1505,11 @@ by blast lemma Diff_insert: "A - insert a B = A - B - {a}" - -- \NOT SUITABLE FOR REWRITING since @{text "{a} == insert a 0"}\ + \ \NOT SUITABLE FOR REWRITING since \{a} == insert a 0\\ by blast lemma Diff_insert2: "A - insert a B = A - {a} - B" - -- \NOT SUITABLE FOR REWRITING since @{text "{a} == insert a 0"}\ + \ \NOT SUITABLE FOR REWRITING since \{a} == insert a 0\\ by blast lemma insert_Diff_if: "insert x A - B = (if x \ B then A - B else insert x (A - B))" @@ -1591,7 +1587,7 @@ lemma UNIV_bool: "UNIV = {False, True}" by (auto intro: bool_induct) -text \\medskip @{text Pow}\ +text \\medskip \Pow\\ lemma Pow_empty [simp]: "Pow {} = {{}}" by (auto simp add: Pow_def) @@ -1764,7 +1760,7 @@ by blast lemma vimage_insert: "f-`(insert a B) = (f-`{a}) Un (f-`B)" - -- \NOT suitable for rewriting because of the recurrence of @{term "{a}"}.\ + \ \NOT suitable for rewriting because of the recurrence of @{term "{a}"}.\ by blast lemma vimage_Diff: "f -` (A - B) = (f -` A) - (f -` B)" @@ -1774,7 +1770,7 @@ by blast lemma vimage_mono: "A \ B ==> f -` A \ f -` B" - -- \monotonicity\ + \ \monotonicity\ by blast lemma vimage_image_eq: "f -` (f ` A) = {y. EX x:A. f x = f y}" @@ -1831,7 +1827,7 @@ lemma Least_mono: "mono (f::'a::order => 'b::order) ==> EX x:S. ALL y:S. x <= y ==> (LEAST y. y : f ` S) = f (LEAST x. x : S)" - -- \Courtesy of Stephan Merz\ + \ \Courtesy of Stephan Merz\ apply clarify apply (erule_tac P = "%x. x : S" in LeastI2_order, fast) apply (rule LeastI2_order)