diff -r c09598a97436 -r d8d85a8172b5 src/HOL/Set.thy --- a/src/HOL/Set.thy Sat Jul 18 21:44:18 2015 +0200 +++ b/src/HOL/Set.thy Sat Jul 18 22:58:50 2015 +0200 @@ -1,12 +1,12 @@ (* Author: Tobias Nipkow, Lawrence C Paulson and Markus Wenzel *) -section {* Set theory for higher-order logic *} +section \Set theory for higher-order logic\ theory Set imports Lattices begin -subsection {* Sets as predicates *} +subsection \Sets as predicates\ typedecl 'a set @@ -40,7 +40,7 @@ not_member ("(_/ \ _)" [51, 51] 50) -text {* Set comprehensions *} +text \Set comprehensions\ syntax "_Coll" :: "pttrn => bool => 'a set" ("(1{_./ _})") @@ -63,12 +63,12 @@ lemma Collect_cong: "(\x. P x = Q x) ==> {x. P x} = {x. Q x}" by simp -text {* +text \ Simproc for pulling @{text "x=t"} in @{text "{x. \ & x=t & \}"} to the front (and similarly for @{text "t=x"}): -*} - -simproc_setup defined_Collect ("{x. P x & Q x}") = {* +\ + +simproc_setup defined_Collect ("{x. P x & Q x}") = \ fn _ => Quantifier1.rearrange_Collect (fn ctxt => resolve_tac ctxt @{thms Collect_cong} 1 THEN @@ -76,7 +76,7 @@ ALLGOALS (EVERY' [REPEAT_DETERM o eresolve_tac ctxt @{thms conjE}, DEPTH_SOLVE_1 o (assume_tac ctxt ORELSE' resolve_tac ctxt @{thms conjI})])) -*} +\ lemmas CollectE = CollectD [elim_format] @@ -92,7 +92,7 @@ "A = B \ (\x. x \ A \ x \ B)" by (auto intro:set_eqI) -text {* Lifting of predicate class instances *} +text \Lifting of predicate class instances\ instantiation set :: (type) boolean_algebra begin @@ -130,7 +130,7 @@ end -text {* Set enumerations *} +text \Set enumerations\ abbreviation empty :: "'a set" ("{}") where "{} \ bot" @@ -145,7 +145,7 @@ "{x}" == "CONST insert x {}" -subsection {* Subsets and bounded quantifiers *} +subsection \Subsets and bounded quantifiers\ abbreviation subset :: "'a set \ 'a set \ bool" where @@ -256,7 +256,7 @@ "\A\B. P" => "EX A. A \ B & P" "\!A\B. P" => "EX! A. A \ B & P" -print_translation {* +print_translation \ let val All_binder = Mixfix.binder_name @{const_syntax All}; val Ex_binder = Mixfix.binder_name @{const_syntax Ex}; @@ -287,19 +287,19 @@ in [tr' All_binder, tr' Ex_binder] end -*} - - -text {* +\ + + +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)"}. -*} +\ syntax "_Setcompr" :: "'a => idts => bool => 'a set" ("(1{_ |/_./ _})") -parse_translation {* +parse_translation \ let val ex_tr = snd (Syntax_Trans.mk_binder_tr ("EX ", @{const_syntax Ex})); @@ -314,14 +314,14 @@ in Syntax.const @{const_syntax Collect} $ absdummy dummyT exP end; in [(@{syntax_const "_Setcompr"}, setcompr_tr)] end; -*} - -print_translation {* +\ + +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 *} - -print_translation {* +\ -- \to avoid eta-contraction of body\ + +print_translation \ let val ex_tr' = snd (Syntax_Trans.mk_binder_tr' (@{const_syntax Ex}, "DUMMY")); @@ -353,21 +353,21 @@ end end; in [(@{const_syntax Collect}, setcompr_tr')] end; -*} - -simproc_setup defined_Bex ("EX x:A. P x & Q x") = {* +\ + +simproc_setup defined_Bex ("EX x:A. P x & Q x") = \ fn _ => Quantifier1.rearrange_bex (fn ctxt => unfold_tac ctxt @{thms Bex_def} THEN Quantifier1.prove_one_point_ex_tac ctxt) -*} - -simproc_setup defined_All ("ALL x:A. P x --> Q x") = {* +\ + +simproc_setup defined_All ("ALL x:A. P x --> Q x") = \ fn _ => Quantifier1.rearrange_ball (fn ctxt => unfold_tac ctxt @{thms Ball_def} THEN Quantifier1.prove_one_point_all_tac ctxt) -*} +\ lemma ballI [intro!]: "(!!x. x:A ==> P x) ==> ALL x:A. P x" by (simp add: Ball_def) @@ -377,16 +377,16 @@ lemma bspec [dest?]: "ALL x:A. P x ==> x:A ==> P x" by (simp add: Ball_def) -text {* +text \ Gives better instantiation for bound: -*} - -setup {* +\ + +setup \ map_theory_claset (fn ctxt => ctxt addbefore ("bspec", fn ctxt' => dresolve_tac ctxt' @{thms bspec} THEN' assume_tac ctxt')) -*} - -ML {* +\ + +ML \ structure Simpdata = struct @@ -397,22 +397,22 @@ end; open Simpdata; -*} - -declaration {* fn _ => +\ + +declaration \fn _ => Simplifier.map_ss (Simplifier.set_mksimps (mksimps mksimps_pairs)) -*} +\ lemma ballE [elim]: "ALL x:A. P x ==> (P x ==> Q) ==> (x ~: A ==> Q) ==> Q" 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 - choice of @{prop "x:A"}. *} + -- \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" @@ -422,11 +422,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)" @@ -456,7 +456,7 @@ by blast -text {* Congruence rules *} +text \Congruence rules\ lemma ball_cong: "A = B ==> (!!x. x:B ==> P x = Q x) ==> @@ -481,34 +481,34 @@ lemma bex1_def: "(\!x\X. P x) \ (\x\X. P x) \ (\x\X. \y\X. P x \ P y \ x = y)" by auto -subsection {* Basic operations *} - -subsubsection {* Subsets *} +subsection \Basic operations\ + +subsubsection \Subsets\ lemma subsetI [intro!]: "(\x. x \ A \ x \ B) \ A \ B" by (simp add: less_eq_set_def le_fun_def) -text {* +text \ \medskip Map the type @{text "'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 @{text erule} -- + cf @{text rev_mp}.\ by (rule subsetD) -text {* +text \ \medskip Converts @{prop "A \ B"} to @{prop "x \ A ==> x \ B"}. -*} +\ 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 @@ -539,16 +539,16 @@ order_trans_rules set_rev_mp set_mp eq_mem_trans -subsubsection {* Equality *} +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 {* +text \ \medskip Equality rules from ZF set theory -- are they appropriate here? -*} +\ lemma equalityD1: "A = B ==> A \ B" by simp @@ -556,11 +556,11 @@ lemma equalityD2: "A = B ==> B \ A" by simp -text {* +text \ \medskip Be careful when adding this to the claset as @{text subset_empty} is in the simpset: @{prop "A = {}"} goes to @{prop "{} \ A"} and @{prop "A \ {}"} and then back to @{prop "A = {}"}! -*} +\ lemma equalityE: "A = B ==> (A \ B ==> B \ A ==> P) ==> P" by simp @@ -576,7 +576,7 @@ by simp -subsubsection {* The empty set *} +subsubsection \The empty set\ lemma empty_def: "{} = {x. False}" @@ -589,14 +589,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: @{text "A Int B = {}"}\ by blast lemma ball_empty [simp]: "Ball {} P = True" @@ -606,7 +606,7 @@ by (simp add: Bex_def) -subsubsection {* The universal set -- UNIV *} +subsubsection \The universal set -- UNIV\ abbreviation UNIV :: "'a set" where "UNIV \ top" @@ -618,7 +618,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 @@ -626,11 +626,11 @@ lemma subset_UNIV: "A \ UNIV" by (fact top_greatest) (* already simp *) -text {* +text \ \medskip Eta-contracting these two rules (to remove @{text P}) causes them to be ignored because of their interaction with congruence rules. -*} +\ lemma ball_UNIV [simp]: "Ball UNIV P = All P" by (simp add: Ball_def) @@ -647,7 +647,7 @@ lemma empty_not_UNIV[simp]: "{} \ UNIV" by blast -subsubsection {* The Powerset operator -- Pow *} +subsubsection \The Powerset operator -- Pow\ definition Pow :: "'a set => 'a set set" where Pow_def: "Pow A = {B. B \ A}" @@ -671,7 +671,7 @@ using Pow_top by blast -subsubsection {* Set complement *} +subsubsection \Set complement\ lemma Compl_iff [simp]: "(c \ -A) = (c \ A)" by (simp add: fun_Compl_def uminus_set_def) @@ -679,10 +679,10 @@ lemma ComplI [intro!]: "(c \ A ==> False) ==> c \ -A" by (simp add: fun_Compl_def uminus_set_def) blast -text {* +text \ \medskip This form, with negated conclusion, works well with the Classical prover. Negated assumptions behave like formulae on the - right side of the notional turnstile ... *} + right side of the notional turnstile ...\ lemma ComplD [dest!]: "c : -A ==> c~:A" by simp @@ -693,7 +693,7 @@ by blast -subsubsection {* Binary intersection *} +subsubsection \Binary intersection\ abbreviation inter :: "'a set \ 'a set \ 'a set" (infixl "Int" 70) where "op Int \ inf" @@ -727,7 +727,7 @@ by (fact mono_inf) -subsubsection {* Binary union *} +subsubsection \Binary union\ abbreviation union :: "'a set \ 'a set \ 'a set" (infixl "Un" 65) where "union \ sup" @@ -751,10 +751,10 @@ lemma UnI2 [elim?]: "c:B ==> c : A Un B" by simp -text {* +text \ \medskip Classical introduction rule: no commitment to @{prop A} vs @{prop B}. -*} +\ lemma UnCI [intro!]: "(c~:B ==> c:A) ==> c : A Un B" by auto @@ -769,7 +769,7 @@ by (fact mono_sup) -subsubsection {* Set difference *} +subsubsection \Set difference\ lemma Diff_iff [simp]: "(c : A - B) = (c:A & c~:B)" by (simp add: minus_set_def fun_diff_def) @@ -792,7 +792,7 @@ by blast -subsubsection {* Augmenting a set -- @{const insert} *} +subsubsection \Augmenting a set -- @{const insert}\ lemma insert_iff [simp]: "(a : insert b A) = (a = b | a:A)" by (unfold insert_def) blast @@ -807,7 +807,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)" @@ -833,13 +833,13 @@ assume ?L show ?R proof cases - assume "a=b" with assms `?L` show ?R by (simp add: insert_ident) + assume "a=b" with assms \?L\ show ?R by (simp add: insert_ident) next assume "a\b" let ?C = "A - {b}" have "A = insert b ?C \ b \ ?C \ B = insert a ?C \ a \ ?C" - using assms `?L` `a\b` by auto - thus ?R using `a\b` by auto + using assms \?L\ \a\b\ by auto + thus ?R using \a\b\ by auto qed next assume ?R thus ?L by (auto split: if_splits) @@ -848,10 +848,10 @@ lemma insert_UNIV: "insert x UNIV = UNIV" by auto -subsubsection {* Singletons, using insert *} +subsubsection \Singletons, using insert\ lemma singletonI [intro!]: "a : {a}" - -- {* Redundant? But unlike @{text insertCI}, it proves the subgoal immediately! *} + -- \Redundant? But unlike @{text insertCI}, it proves the subgoal immediately!\ by (rule insertI1) lemma singletonD [dest!]: "b : {a} ==> b = a" @@ -897,11 +897,11 @@ by auto -subsubsection {* Image of a set under a function *} - -text {* +subsubsection \Image of a set under a function\ + +text \ Frequently @{term b} does not have the syntactic form of @{term "f x"}. -*} +\ definition image :: "('a \ 'b) \ 'a set \ 'b set" (infixr "`" 90) where @@ -917,12 +917,12 @@ lemma rev_image_eqI: "x \ A \ b = f x \ b \ f ` A" - -- {* This version's more effective when we already have the - required @{term x}. *} + -- \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 @@ -940,13 +940,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 @{text subsetI}, @{text imageE}, + @{text 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: @@ -1000,9 +1000,9 @@ 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. *} + equational properties than does the RHS.\ by blast lemma if_image_distrib [simp]: @@ -1036,9 +1036,9 @@ using assms by auto -text {* +text \ \medskip Range of a function -- just a translation for image! -*} +\ abbreviation range :: "('a \ 'b) \ 'b set" where -- "of function" @@ -1065,9 +1065,9 @@ by auto -subsubsection {* Some rules with @{text "if"} *} - -text{* Elimination of @{text"{x. \ & x=t & \}"}. *} +subsubsection \Some rules with @{text "if"}\ + +text\Elimination of @{text"{x. \ & x=t & \}"}.\ lemma Collect_conv_if: "{x. x=a & P x} = (if P a then {a} else {})" by auto @@ -1075,10 +1075,10 @@ lemma Collect_conv_if2: "{x. a=x & P x} = (if P a then {a} else {})" by auto -text {* +text \ Rewrite rules for boolean case-splitting: faster than @{text "split_if [split]"}. -*} +\ lemma split_if_eq1: "((if Q then x else y) = b) = ((Q --> x = b) & (~ Q --> y = b))" by (rule split_if) @@ -1086,10 +1086,10 @@ lemma split_if_eq2: "(a = (if Q then x else y)) = ((Q --> a = x) & (~ Q --> a = y))" by (rule split_if) -text {* +text \ Split ifs on either side of the membership relation. Not for @{text "[simp]"} -- can cause goals to blow up! -*} +\ lemma split_if_mem1: "((if Q then x else y) : b) = ((Q --> x : b) & (~ Q --> y : b))" by (rule split_if) @@ -1109,9 +1109,9 @@ *) -subsection {* Further operations and lemmas *} - -subsubsection {* The ``proper subset'' relation *} +subsection \Further operations and lemmas\ + +subsubsection \The ``proper subset'' relation\ lemma psubsetI [intro!]: "A \ B ==> A \ B ==> A \ B" by (unfold less_le) blast @@ -1167,9 +1167,9 @@ using assms by (blast elim: subset_imageE) -subsubsection {* Derived rules involving subsets. *} - -text {* @{text insert}. *} +subsubsection \Derived rules involving subsets.\ + +text \@{text insert}.\ lemma subset_insertI: "B \ insert a B" by (rule subsetI) (erule insertI2) @@ -1181,7 +1181,7 @@ by blast -text {* \medskip Finite Union -- the least upper bound of two sets. *} +text \\medskip Finite Union -- the least upper bound of two sets.\ lemma Un_upper1: "A \ A \ B" by (fact sup_ge1) @@ -1193,7 +1193,7 @@ by (fact sup_least) -text {* \medskip Finite Intersection -- the greatest lower bound of two sets. *} +text \\medskip Finite Intersection -- the greatest lower bound of two sets.\ lemma Int_lower1: "A \ B \ A" by (fact inf_le1) @@ -1205,7 +1205,7 @@ by (fact inf_greatest) -text {* \medskip Set difference. *} +text \\medskip Set difference.\ lemma Diff_subset: "A - B \ A" by blast @@ -1214,12 +1214,12 @@ by blast -subsubsection {* Equalities involving union, intersection, inclusion, etc. *} - -text {* @{text "{}"}. *} +subsubsection \Equalities involving union, intersection, inclusion, etc.\ + +text \@{text "{}"}.\ lemma Collect_const [simp]: "{s. P} = (if P then UNIV else {})" - -- {* supersedes @{text "Collect_False_empty"} *} + -- \supersedes @{text "Collect_False_empty"}\ by auto lemma subset_empty [simp]: "(A \ {}) = (A = {})" @@ -1250,10 +1250,10 @@ by blast -text {* \medskip @{text insert}. *} +text \\medskip @{text 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 @{text "{a} == insert a {}"}\ by blast lemma insert_not_empty [simp]: "insert a A \ {}" @@ -1263,8 +1263,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 *} + -- \@{text "[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" @@ -1277,7 +1277,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 @{text B} rather than @{text "A - {a}"} to avoid infinite unfolding\ apply (rule_tac x = "A - {a}" in exI, blast) done @@ -1298,7 +1298,7 @@ by auto -text {* \medskip @{text Int} *} +text \\medskip @{text Int}\ lemma Int_absorb: "A \ A = A" by (fact inf_idem) (* already simp *) @@ -1316,7 +1316,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) @@ -1358,7 +1358,7 @@ by blast -text {* \medskip @{text Un}. *} +text \\medskip @{text Un}.\ lemma Un_absorb: "A \ A = A" by (fact sup_idem) (* already simp *) @@ -1376,7 +1376,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) @@ -1452,7 +1452,7 @@ by blast -text {* \medskip Set complement *} +text \\medskip Set complement\ lemma Compl_disjoint [simp]: "A \ -A = {}" by (fact inf_compl_bot) @@ -1479,7 +1479,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 = {}" @@ -1497,10 +1497,10 @@ lemma Compl_insert: "- insert x A = (-A) - {x}" by blast -text {* \medskip Bounded quantifiers. +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 @{text Int}.\ lemma ball_Un: "(\x \ A \ B. P x) = ((\x\A. P x) & (\x\B. P x))" by blast @@ -1509,7 +1509,7 @@ by blast -text {* \medskip Set difference. *} +text \\medskip Set difference.\ lemma Diff_eq: "A - B = A \ (-B)" by blast @@ -1539,11 +1539,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 @{text "{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 @{text "{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))" @@ -1601,7 +1601,7 @@ by blast -text {* \medskip Quantification over type @{typ bool}. *} +text \\medskip Quantification over type @{typ bool}.\ lemma bool_induct: "P True \ P False \ P x" by (cases x) auto @@ -1618,7 +1618,7 @@ lemma UNIV_bool: "UNIV = {False, True}" by (auto intro: bool_induct) -text {* \medskip @{text Pow} *} +text \\medskip @{text Pow}\ lemma Pow_empty [simp]: "Pow {} = {{}}" by (auto simp add: Pow_def) @@ -1642,7 +1642,7 @@ by blast -text {* \medskip Miscellany. *} +text \\medskip Miscellany.\ lemma set_eq_subset: "(A = B) = (A \ B & B \ A)" by blast @@ -1684,7 +1684,7 @@ by auto -subsubsection {* Monotonicity of various operations *} +subsubsection \Monotonicity of various operations\ lemma image_mono: "A \ B ==> f`A \ f`B" by blast @@ -1707,7 +1707,7 @@ lemma Compl_anti_mono: "A \ B ==> -B \ -A" by (fact compl_mono) -text {* \medskip Monotonicity of implications. *} +text \\medskip Monotonicity of implications.\ lemma in_mono: "A \ B ==> x \ A --> x \ B" apply (rule impI) @@ -1749,7 +1749,7 @@ by iprover -subsubsection {* Inverse image of a function *} +subsubsection \Inverse image of a function\ definition vimage :: "('a => 'b) => 'b set => 'a set" (infixr "-`" 90) where "f -` B == {x. f x : B}" @@ -1791,7 +1791,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)" @@ -1801,7 +1801,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}" @@ -1832,7 +1832,7 @@ by blast -subsubsection {* Getting the Contents of a Singleton Set *} +subsubsection \Getting the Contents of a Singleton Set\ definition the_elem :: "'a set \ 'a" where "the_elem X = (THE x. X = {x})" @@ -1845,20 +1845,20 @@ assumes *: "\y. y \ A \ f y = f x" shows "the_elem (f ` A) = f x" unfolding the_elem_def proof (rule the1_equality) - from `A \ {}` obtain y where "y \ A" by auto + from \A \ {}\ obtain y where "y \ A" by auto with * have "f x = f y" by simp - with `y \ A` have "f x \ f ` A" by blast + with \y \ A\ have "f x \ f ` A" by blast with * show "f ` A = {f x}" by auto then show "\!x. f ` A = {x}" by auto qed -subsubsection {* Least value operator *} +subsubsection \Least value operator\ 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) @@ -1866,7 +1866,7 @@ done -subsubsection {* Monad operation *} +subsubsection \Monad operation\ definition bind :: "'a set \ ('a \ 'b set) \ 'b set" where "bind A f = {x. \B \ f`A. x \ B}" @@ -1892,7 +1892,7 @@ lemma bind_singleton_conv_image: "Set.bind A (\x. {f x}) = f ` A" by(auto simp add: bind_def) -subsubsection {* Operations for execution *} +subsubsection \Operations for execution\ definition is_empty :: "'a set \ bool" where [code_abbrev]: "is_empty A \ A = {}" @@ -1929,13 +1929,13 @@ end -text {* Misc *} +text \Misc\ hide_const (open) member not_member lemmas equalityI = subset_antisym -ML {* +ML \ val Ball_def = @{thm Ball_def} val Bex_def = @{thm Bex_def} val CollectD = @{thm CollectD} @@ -1988,7 +1988,7 @@ val vimage_Collect = @{thm vimage_Collect} val vimage_Int = @{thm vimage_Int} val vimage_Un = @{thm vimage_Un} -*} +\ end