# HG changeset patch # User haftmann # Date 1248265232 -7200 # Node ID f645b51e8e5437a696952cfc879aa64c72754282 # Parent ee143615019c0e20ee26e539b483b5da46078eef set intersection and union now named inter and union; closer connection between set and lattice operations; factored out complete lattice diff -r ee143615019c -r f645b51e8e54 src/HOL/Set.thy --- a/src/HOL/Set.thy Wed Jul 22 14:20:32 2009 +0200 +++ b/src/HOL/Set.thy Wed Jul 22 14:20:32 2009 +0200 @@ -103,7 +103,7 @@ text {* Set enumerations *} definition empty :: "'a set" ("{}") where - "empty = {x. False}" + bot_set_eq [symmetric]: "{} = bot" definition insert :: "'a \ 'a set \ 'a set" where insert_compr: "insert a B = {x. x = a \ x \ B}" @@ -544,7 +544,11 @@ subsubsection {* The universal set -- UNIV *} definition UNIV :: "'a set" where + top_set_eq [symmetric]: "UNIV = top" + +lemma UNIV_def: "UNIV = {x. True}" + by (simp add: top_set_eq [symmetric] top_fun_eq top_bool_eq Collect_def) lemma UNIV_I [simp]: "x : UNIV" by (simp add: UNIV_def) @@ -557,9 +561,6 @@ lemma subset_UNIV [simp]: "A \ UNIV" by (rule subsetI) (rule UNIV_I) -lemma top_set_eq: "top = UNIV" - by (iprover intro!: subset_antisym subset_UNIV top_greatest) - text {* \medskip Eta-contracting these two rules (to remove @{text P}) causes them to be ignored because of their interaction with @@ -578,6 +579,10 @@ subsubsection {* The empty set *} +lemma empty_def: + "{} = {x. False}" + by (simp add: bot_set_eq [symmetric] bot_fun_eq bot_bool_eq Collect_def) + lemma empty_iff [simp]: "(c : {}) = False" by (simp add: empty_def) @@ -588,9 +593,6 @@ -- {* One effect is to delete the ASSUMPTION @{prop "{} <= A"} *} by blast -lemma bot_set_eq: "bot = {}" - by (iprover intro!: subset_antisym empty_subsetI bot_least) - lemma equals0I: "(!!y. y \ A ==> False) ==> A = {}" by blast @@ -652,17 +654,18 @@ subsubsection {* Binary union -- Un *} -definition Un :: "'a set \ 'a set \ 'a set" (infixl "Un" 65) where - "A Un B = {x. x \ A \ x \ B}" +definition union :: "'a set \ 'a set \ 'a set" (infixl "Un" 65) where + sup_set_eq [symmetric]: "A Un B = sup A B" notation (xsymbols) - "Un" (infixl "\" 65) + union (infixl "\" 65) notation (HTML output) - "Un" (infixl "\" 65) - -lemma sup_set_eq: "sup A B = A \ B" - by (simp add: sup_fun_eq sup_bool_eq Un_def Collect_def mem_def) + union (infixl "\" 65) + +lemma Un_def: + "A \ B = {x. x \ A \ x \ B}" + by (simp add: sup_fun_eq sup_bool_eq sup_set_eq [symmetric] Collect_def mem_def) lemma Un_iff [simp]: "(c : A Un B) = (c:A | c:B)" by (unfold Un_def) blast @@ -695,17 +698,18 @@ subsubsection {* Binary intersection -- Int *} -definition Int :: "'a set \ 'a set \ 'a set" (infixl "Int" 70) where - "A Int B = {x. x \ A \ x \ B}" +definition inter :: "'a set \ 'a set \ 'a set" (infixl "Int" 70) where + inf_set_eq [symmetric]: "A Int B = inf A B" notation (xsymbols) - "Int" (infixl "\" 70) + inter (infixl "\" 70) notation (HTML output) - "Int" (infixl "\" 70) - -lemma inf_set_eq: "inf A B = A \ B" - by (simp add: inf_fun_eq inf_bool_eq Int_def Collect_def mem_def) + inter (infixl "\" 70) + +lemma Int_def: + "A \ B = {x. x \ A \ x \ B}" + by (simp add: inf_fun_eq inf_bool_eq inf_set_eq [symmetric] Collect_def mem_def) lemma Int_iff [simp]: "(c : A Int B) = (c:A & c:B)" by (unfold Int_def) blast @@ -933,6 +937,803 @@ *) +subsection {* Further operations and lemmas *} + +subsubsection {* The ``proper subset'' relation *} + +lemma psubsetI [intro!,noatp]: "A \ B ==> A \ B ==> A \ B" + by (unfold less_le) blast + +lemma psubsetE [elim!,noatp]: + "[|A \ B; [|A \ B; ~ (B\A)|] ==> R|] ==> R" + by (unfold less_le) blast + +lemma psubset_insert_iff: + "(A \ insert x B) = (if x \ B then A \ B else if x \ A then A - {x} \ B else A \ B)" + by (auto simp add: less_le subset_insert_iff) + +lemma psubset_eq: "(A \ B) = (A \ B & A \ B)" + by (simp only: less_le) + +lemma psubset_imp_subset: "A \ B ==> A \ B" + by (simp add: psubset_eq) + +lemma psubset_trans: "[| A \ B; B \ C |] ==> A \ C" +apply (unfold less_le) +apply (auto dest: subset_antisym) +done + +lemma psubsetD: "[| A \ B; c \ A |] ==> c \ B" +apply (unfold less_le) +apply (auto dest: subsetD) +done + +lemma psubset_subset_trans: "A \ B ==> B \ C ==> A \ C" + by (auto simp add: psubset_eq) + +lemma subset_psubset_trans: "A \ B ==> B \ C ==> A \ C" + by (auto simp add: psubset_eq) + +lemma psubset_imp_ex_mem: "A \ B ==> \b. b \ (B - A)" + by (unfold less_le) blast + +lemma atomize_ball: + "(!!x. x \ A ==> P x) == Trueprop (\x\A. P x)" + by (simp only: Ball_def atomize_all atomize_imp) + +lemmas [symmetric, rulify] = atomize_ball + and [symmetric, defn] = atomize_ball + +subsubsection {* Derived rules involving subsets. *} + +text {* @{text insert}. *} + +lemma subset_insertI: "B \ insert a B" + by (rule subsetI) (erule insertI2) + +lemma subset_insertI2: "A \ B \ A \ insert b B" + by blast + +lemma subset_insert: "x \ A ==> (A \ insert x B) = (A \ B)" + by blast + + +text {* \medskip Finite Union -- the least upper bound of two sets. *} + +lemma Un_upper1: "A \ A \ B" + by blast + +lemma Un_upper2: "B \ A \ B" + by blast + +lemma Un_least: "A \ C ==> B \ C ==> A \ B \ C" + by blast + + +text {* \medskip Finite Intersection -- the greatest lower bound of two sets. *} + +lemma Int_lower1: "A \ B \ A" + by blast + +lemma Int_lower2: "A \ B \ B" + by blast + +lemma Int_greatest: "C \ A ==> C \ B ==> C \ A \ B" + by blast + + +text {* \medskip Set difference. *} + +lemma Diff_subset: "A - B \ A" + by blast + +lemma Diff_subset_conv: "(A - B \ C) = (A \ B \ C)" +by blast + + +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"} *} + by auto + +lemma subset_empty [simp]: "(A \ {}) = (A = {})" + by blast + +lemma not_psubset_empty [iff]: "\ (A < {})" + by (unfold less_le) blast + +lemma Collect_empty_eq [simp]: "(Collect P = {}) = (\x. \ P x)" +by blast + +lemma empty_Collect_eq [simp]: "({} = Collect P) = (\x. \ P x)" +by blast + +lemma Collect_neg_eq: "{x. \ P x} = - {x. P x}" + by blast + +lemma Collect_disj_eq: "{x. P x | Q x} = {x. P x} \ {x. Q x}" + by blast + +lemma Collect_imp_eq: "{x. P x --> Q x} = -{x. P x} \ {x. Q x}" + by blast + +lemma Collect_conj_eq: "{x. P x & Q x} = {x. P x} \ {x. Q x}" + by blast + + +text {* \medskip @{text insert}. *} + +lemma insert_is_Un: "insert a A = {a} Un A" + -- {* NOT SUITABLE FOR REWRITING since @{text "{a} == insert a {}"} *} + by blast + +lemma insert_not_empty [simp]: "insert a A \ {}" + by blast + +lemmas empty_not_insert = insert_not_empty [symmetric, standard] +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 *} + by blast + +lemma insert_absorb2 [simp]: "insert x (insert x A) = insert x A" + by blast + +lemma insert_commute: "insert x (insert y A) = insert y (insert x A)" + by blast + +lemma insert_subset [simp]: "(insert x A \ B) = (x \ B & A \ B)" + 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 *} + apply (rule_tac x = "A - {a}" in exI, blast) + done + +lemma insert_Collect: "insert a (Collect P) = {u. u \ a --> P u}" + by auto + +lemma insert_inter_insert[simp]: "insert a A \ insert a B = insert a (A \ B)" + by blast + +lemma insert_disjoint [simp,noatp]: + "(insert a A \ B = {}) = (a \ B \ A \ B = {})" + "({} = insert a A \ B) = (a \ B \ {} = A \ B)" + by auto + +lemma disjoint_insert [simp,noatp]: + "(B \ insert a A = {}) = (a \ B \ B \ A = {})" + "({} = A \ insert b B) = (b \ A \ {} = A \ B)" + by auto + +text {* \medskip @{text image}. *} + +lemma image_empty [simp]: "f`{} = {}" + by blast + +lemma image_insert [simp]: "f ` insert a B = insert (f a) (f`B)" + by blast + +lemma image_constant: "x \ A ==> (\x. c) ` A = {c}" + by auto + +lemma image_constant_conv: "(%x. c) ` A = (if A = {} then {} else {c})" +by auto + +lemma image_image: "f ` (g ` A) = (\x. f (g x)) ` A" +by blast + +lemma insert_image [simp]: "x \ A ==> insert (f x) (f`A) = f`A" +by blast + +lemma image_is_empty [iff]: "(f`A = {}) = (A = {})" +by blast + +lemma empty_is_image[iff]: "({} = f ` A) = (A = {})" +by blast + + +lemma image_Collect [noatp]: "f ` {x. P x} = {f x | x. P x}" + -- {* 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 + +lemma if_image_distrib [simp]: + "(\x. if P x then f x else g x) ` S + = (f ` (S \ {x. P x})) \ (g ` (S \ {x. \ P x}))" + by (auto simp add: image_def) + +lemma image_cong: "M = N ==> (!!x. x \ N ==> f x = g x) ==> f`M = g`N" + by (simp add: image_def) + + +text {* \medskip @{text range}. *} + +lemma full_SetCompr_eq [noatp]: "{u. \x. u = f x} = range f" + by auto + +lemma range_composition: "range (\x. f (g x)) = f`range g" +by (subst image_image, simp) + + +text {* \medskip @{text Int} *} + +lemma Int_absorb [simp]: "A \ A = A" + by blast + +lemma Int_left_absorb: "A \ (A \ B) = A \ B" + by blast + +lemma Int_commute: "A \ B = B \ A" + by blast + +lemma Int_left_commute: "A \ (B \ C) = B \ (A \ C)" + by blast + +lemma Int_assoc: "(A \ B) \ C = A \ (B \ C)" + by blast + +lemmas Int_ac = Int_assoc Int_left_absorb Int_commute Int_left_commute + -- {* Intersection is an AC-operator *} + +lemma Int_absorb1: "B \ A ==> A \ B = B" + by blast + +lemma Int_absorb2: "A \ B ==> A \ B = A" + by blast + +lemma Int_empty_left [simp]: "{} \ B = {}" + by blast + +lemma Int_empty_right [simp]: "A \ {} = {}" + by blast + +lemma disjoint_eq_subset_Compl: "(A \ B = {}) = (A \ -B)" + by blast + +lemma disjoint_iff_not_equal: "(A \ B = {}) = (\x\A. \y\B. x \ y)" + by blast + +lemma Int_UNIV_left [simp]: "UNIV \ B = B" + by blast + +lemma Int_UNIV_right [simp]: "A \ UNIV = A" + by blast + +lemma Int_Un_distrib: "A \ (B \ C) = (A \ B) \ (A \ C)" + by blast + +lemma Int_Un_distrib2: "(B \ C) \ A = (B \ A) \ (C \ A)" + by blast + +lemma Int_UNIV [simp,noatp]: "(A \ B = UNIV) = (A = UNIV & B = UNIV)" + by blast + +lemma Int_subset_iff [simp]: "(C \ A \ B) = (C \ A & C \ B)" + by blast + +lemma Int_Collect: "(x \ A \ {x. P x}) = (x \ A & P x)" + by blast + + +text {* \medskip @{text Un}. *} + +lemma Un_absorb [simp]: "A \ A = A" + by blast + +lemma Un_left_absorb: "A \ (A \ B) = A \ B" + by blast + +lemma Un_commute: "A \ B = B \ A" + by blast + +lemma Un_left_commute: "A \ (B \ C) = B \ (A \ C)" + by blast + +lemma Un_assoc: "(A \ B) \ C = A \ (B \ C)" + by blast + +lemmas Un_ac = Un_assoc Un_left_absorb Un_commute Un_left_commute + -- {* Union is an AC-operator *} + +lemma Un_absorb1: "A \ B ==> A \ B = B" + by blast + +lemma Un_absorb2: "B \ A ==> A \ B = A" + by blast + +lemma Un_empty_left [simp]: "{} \ B = B" + by blast + +lemma Un_empty_right [simp]: "A \ {} = A" + by blast + +lemma Un_UNIV_left [simp]: "UNIV \ B = UNIV" + by blast + +lemma Un_UNIV_right [simp]: "A \ UNIV = UNIV" + by blast + +lemma Un_insert_left [simp]: "(insert a B) \ C = insert a (B \ C)" + by blast + +lemma Un_insert_right [simp]: "A \ (insert a B) = insert a (A \ B)" + by blast + +lemma Int_insert_left: + "(insert a B) Int C = (if a \ C then insert a (B \ C) else B \ C)" + by auto + +lemma Int_insert_right: + "A \ (insert a B) = (if a \ A then insert a (A \ B) else A \ B)" + by auto + +lemma Un_Int_distrib: "A \ (B \ C) = (A \ B) \ (A \ C)" + by blast + +lemma Un_Int_distrib2: "(B \ C) \ A = (B \ A) \ (C \ A)" + by blast + +lemma Un_Int_crazy: + "(A \ B) \ (B \ C) \ (C \ A) = (A \ B) \ (B \ C) \ (C \ A)" + by blast + +lemma subset_Un_eq: "(A \ B) = (A \ B = B)" + by blast + +lemma Un_empty [iff]: "(A \ B = {}) = (A = {} & B = {})" + by blast + +lemma Un_subset_iff [simp]: "(A \ B \ C) = (A \ C & B \ C)" + by blast + +lemma Un_Diff_Int: "(A - B) \ (A \ B) = A" + by blast + +lemma Diff_Int2: "A \ C - B \ C = A \ C - B" + by blast + + +text {* \medskip Set complement *} + +lemma Compl_disjoint [simp]: "A \ -A = {}" + by blast + +lemma Compl_disjoint2 [simp]: "-A \ A = {}" + by blast + +lemma Compl_partition: "A \ -A = UNIV" + by blast + +lemma Compl_partition2: "-A \ A = UNIV" + by blast + +lemma double_complement [simp]: "- (-A) = (A::'a set)" + by blast + +lemma Compl_Un [simp]: "-(A \ B) = (-A) \ (-B)" + by blast + +lemma Compl_Int [simp]: "-(A \ B) = (-A) \ (-B)" + by blast + +lemma subset_Compl_self_eq: "(A \ -A) = (A = {})" + by blast + +lemma Un_Int_assoc_eq: "((A \ B) \ C = A \ (B \ C)) = (C \ A)" + -- {* Halmos, Naive Set Theory, page 16. *} + by blast + +lemma Compl_UNIV_eq [simp]: "-UNIV = {}" + by blast + +lemma Compl_empty_eq [simp]: "-{} = UNIV" + by blast + +lemma Compl_subset_Compl_iff [iff]: "(-A \ -B) = (B \ A)" + by blast + +lemma Compl_eq_Compl_iff [iff]: "(-A = -B) = (A = (B::'a set))" + by blast + +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}. *} + +lemma ball_Un: "(\x \ A \ B. P x) = ((\x\A. P x) & (\x\B. P x))" + by blast + +lemma bex_Un: "(\x \ A \ B. P x) = ((\x\A. P x) | (\x\B. P x))" + by blast + + +text {* \medskip Set difference. *} + +lemma Diff_eq: "A - B = A \ (-B)" + by blast + +lemma Diff_eq_empty_iff [simp,noatp]: "(A - B = {}) = (A \ B)" + by blast + +lemma Diff_cancel [simp]: "A - A = {}" + by blast + +lemma Diff_idemp [simp]: "(A - B) - B = A - (B::'a set)" +by blast + +lemma Diff_triv: "A \ B = {} ==> A - B = A" + by (blast elim: equalityE) + +lemma empty_Diff [simp]: "{} - A = {}" + by blast + +lemma Diff_empty [simp]: "A - {} = A" + by blast + +lemma Diff_UNIV [simp]: "A - UNIV = {}" + by blast + +lemma Diff_insert0 [simp,noatp]: "x \ A ==> A - insert x B = A - B" + by blast + +lemma Diff_insert: "A - insert a B = A - B - {a}" + -- {* 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"} *} + by blast + +lemma insert_Diff_if: "insert x A - B = (if x \ B then A - B else insert x (A - B))" + by auto + +lemma insert_Diff1 [simp]: "x \ B ==> insert x A - B = A - B" + by blast + +lemma insert_Diff_single[simp]: "insert a (A - {a}) = insert a A" +by blast + +lemma insert_Diff: "a \ A ==> insert a (A - {a}) = A" + by blast + +lemma Diff_insert_absorb: "x \ A ==> (insert x A) - {x} = A" + by auto + +lemma Diff_disjoint [simp]: "A \ (B - A) = {}" + by blast + +lemma Diff_partition: "A \ B ==> A \ (B - A) = B" + by blast + +lemma double_diff: "A \ B ==> B \ C ==> B - (C - A) = A" + by blast + +lemma Un_Diff_cancel [simp]: "A \ (B - A) = A \ B" + by blast + +lemma Un_Diff_cancel2 [simp]: "(B - A) \ A = B \ A" + by blast + +lemma Diff_Un: "A - (B \ C) = (A - B) \ (A - C)" + by blast + +lemma Diff_Int: "A - (B \ C) = (A - B) \ (A - C)" + by blast + +lemma Un_Diff: "(A \ B) - C = (A - C) \ (B - C)" + by blast + +lemma Int_Diff: "(A \ B) - C = A \ (B - C)" + by blast + +lemma Diff_Int_distrib: "C \ (A - B) = (C \ A) - (C \ B)" + by blast + +lemma Diff_Int_distrib2: "(A - B) \ C = (A \ C) - (B \ C)" + by blast + +lemma Diff_Compl [simp]: "A - (- B) = A \ B" + by auto + +lemma Compl_Diff_eq [simp]: "- (A - B) = -A \ B" + by blast + + +text {* \medskip Quantification over type @{typ bool}. *} + +lemma bool_induct: "P True \ P False \ P x" + by (cases x) auto + +lemma all_bool_eq: "(\b. P b) \ P True \ P False" + by (auto intro: bool_induct) + +lemma bool_contrapos: "P x \ \ P False \ P True" + by (cases x) auto + +lemma ex_bool_eq: "(\b. P b) \ P True \ P False" + by (auto intro: bool_contrapos) + +text {* \medskip @{text Pow} *} + +lemma Pow_empty [simp]: "Pow {} = {{}}" + by (auto simp add: Pow_def) + +lemma Pow_insert: "Pow (insert a A) = Pow A \ (insert a ` Pow A)" + by (blast intro: image_eqI [where ?x = "u - {a}", standard]) + +lemma Pow_Compl: "Pow (- A) = {-B | B. A \ Pow B}" + by (blast intro: exI [where ?x = "- u", standard]) + +lemma Pow_UNIV [simp]: "Pow UNIV = UNIV" + by blast + +lemma Un_Pow_subset: "Pow A \ Pow B \ Pow (A \ B)" + by blast + +lemma Pow_Int_eq [simp]: "Pow (A \ B) = Pow A \ Pow B" + by blast + + +text {* \medskip Miscellany. *} + +lemma set_eq_subset: "(A = B) = (A \ B & B \ A)" + by blast + +lemma subset_iff: "(A \ B) = (\t. t \ A --> t \ B)" + by blast + +lemma subset_iff_psubset_eq: "(A \ B) = ((A \ B) | (A = B))" + by (unfold less_le) blast + +lemma all_not_in_conv [simp]: "(\x. x \ A) = (A = {})" + by blast + +lemma ex_in_conv: "(\x. x \ A) = (A \ {})" + by blast + +lemma distinct_lemma: "f x \ f y ==> x \ y" + by iprover + + +subsubsection {* Monotonicity of various operations *} + +lemma image_mono: "A \ B ==> f`A \ f`B" + by blast + +lemma Pow_mono: "A \ B ==> Pow A \ Pow B" + by blast + +lemma insert_mono: "C \ D ==> insert a C \ insert a D" + by blast + +lemma Un_mono: "A \ C ==> B \ D ==> A \ B \ C \ D" + by blast + +lemma Int_mono: "A \ C ==> B \ D ==> A \ B \ C \ D" + by blast + +lemma Diff_mono: "A \ C ==> D \ B ==> A - B \ C - D" + by blast + +lemma Compl_anti_mono: "A \ B ==> -B \ -A" + by blast + +text {* \medskip Monotonicity of implications. *} + +lemma in_mono: "A \ B ==> x \ A --> x \ B" + apply (rule impI) + apply (erule subsetD, assumption) + done + +lemma conj_mono: "P1 --> Q1 ==> P2 --> Q2 ==> (P1 & P2) --> (Q1 & Q2)" + by iprover + +lemma disj_mono: "P1 --> Q1 ==> P2 --> Q2 ==> (P1 | P2) --> (Q1 | Q2)" + by iprover + +lemma imp_mono: "Q1 --> P1 ==> P2 --> Q2 ==> (P1 --> P2) --> (Q1 --> Q2)" + by iprover + +lemma imp_refl: "P --> P" .. + +lemma ex_mono: "(!!x. P x --> Q x) ==> (EX x. P x) --> (EX x. Q x)" + by iprover + +lemma all_mono: "(!!x. P x --> Q x) ==> (ALL x. P x) --> (ALL x. Q x)" + by iprover + +lemma Collect_mono: "(!!x. P x --> Q x) ==> Collect P \ Collect Q" + by blast + +lemma Int_Collect_mono: + "A \ B ==> (!!x. x \ A ==> P x --> Q x) ==> A \ Collect P \ B \ Collect Q" + by blast + +lemmas basic_monos = + subset_refl imp_refl disj_mono conj_mono + ex_mono Collect_mono in_mono + +lemma eq_to_mono: "a = b ==> c = d ==> b --> d ==> a --> c" + by iprover + +lemma eq_to_mono2: "a = b ==> c = d ==> ~ b --> ~ d ==> ~ a --> ~ c" + by iprover + + +subsubsection {* Inverse image of a function *} + +constdefs + vimage :: "('a => 'b) => 'b set => 'a set" (infixr "-`" 90) + [code del]: "f -` B == {x. f x : B}" + +lemma vimage_eq [simp]: "(a : f -` B) = (f a : B)" + by (unfold vimage_def) blast + +lemma vimage_singleton_eq: "(a : f -` {b}) = (f a = b)" + by simp + +lemma vimageI [intro]: "f a = b ==> b:B ==> a : f -` B" + by (unfold vimage_def) blast + +lemma vimageI2: "f a : A ==> a : f -` A" + by (unfold vimage_def) fast + +lemma vimageE [elim!]: "a: f -` B ==> (!!x. f a = x ==> x:B ==> P) ==> P" + by (unfold vimage_def) blast + +lemma vimageD: "a : f -` A ==> f a : A" + by (unfold vimage_def) fast + +lemma vimage_empty [simp]: "f -` {} = {}" + by blast + +lemma vimage_Compl: "f -` (-A) = -(f -` A)" + by blast + +lemma vimage_Un [simp]: "f -` (A Un B) = (f -` A) Un (f -` B)" + by blast + +lemma vimage_Int [simp]: "f -` (A Int B) = (f -` A) Int (f -` B)" + by fast + +lemma vimage_Collect_eq [simp]: "f -` Collect P = {y. P (f y)}" + by blast + +lemma vimage_Collect: "(!!x. P (f x) = Q x) ==> f -` (Collect P) = Collect Q" + 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}"}. *} + by blast + +lemma vimage_Diff: "f -` (A - B) = (f -` A) - (f -` B)" + by blast + +lemma vimage_UNIV [simp]: "f -` UNIV = UNIV" + by blast + +lemma vimage_mono: "A \ B ==> f -` A \ f -` B" + -- {* monotonicity *} + by blast + +lemma vimage_image_eq [noatp]: "f -` (f ` A) = {y. EX x:A. f x = f y}" +by (blast intro: sym) + +lemma image_vimage_subset: "f ` (f -` A) <= A" +by blast + +lemma image_vimage_eq [simp]: "f ` (f -` A) = A Int range f" +by blast + +lemma image_Int_subset: "f`(A Int B) <= f`A Int f`B" +by blast + +lemma image_diff_subset: "f`A - f`B <= f`(A - B)" +by blast + + +subsubsection {* Getting the Contents of a Singleton Set *} + +definition contents :: "'a set \ 'a" where + [code del]: "contents X = (THE x. X = {x})" + +lemma contents_eq [simp]: "contents {x} = x" + by (simp add: contents_def) + + +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 *} + apply clarify + apply (erule_tac P = "%x. x : S" in LeastI2_order, fast) + apply (rule LeastI2_order) + apply (auto elim: monoD intro!: order_antisym) + done + +subsection {* Misc *} + +text {* Rudimentary code generation *} + +lemma insert_code [code]: "insert y A x \ y = x \ A x" + by (auto simp add: insert_compr Collect_def mem_def) + +lemma vimage_code [code]: "(f -` A) x = A (f x)" + by (simp add: vimage_def Collect_def mem_def) + + +text {* Misc theorem and ML bindings *} + +lemmas equalityI = subset_antisym + +ML {* +val Ball_def = @{thm Ball_def} +val Bex_def = @{thm Bex_def} +val CollectD = @{thm CollectD} +val CollectE = @{thm CollectE} +val CollectI = @{thm CollectI} +val Collect_conj_eq = @{thm Collect_conj_eq} +val Collect_mem_eq = @{thm Collect_mem_eq} +val IntD1 = @{thm IntD1} +val IntD2 = @{thm IntD2} +val IntE = @{thm IntE} +val IntI = @{thm IntI} +val Int_Collect = @{thm Int_Collect} +val UNIV_I = @{thm UNIV_I} +val UNIV_witness = @{thm UNIV_witness} +val UnE = @{thm UnE} +val UnI1 = @{thm UnI1} +val UnI2 = @{thm UnI2} +val ballE = @{thm ballE} +val ballI = @{thm ballI} +val bexCI = @{thm bexCI} +val bexE = @{thm bexE} +val bexI = @{thm bexI} +val bex_triv = @{thm bex_triv} +val bspec = @{thm bspec} +val contra_subsetD = @{thm contra_subsetD} +val distinct_lemma = @{thm distinct_lemma} +val eq_to_mono = @{thm eq_to_mono} +val eq_to_mono2 = @{thm eq_to_mono2} +val equalityCE = @{thm equalityCE} +val equalityD1 = @{thm equalityD1} +val equalityD2 = @{thm equalityD2} +val equalityE = @{thm equalityE} +val equalityI = @{thm equalityI} +val imageE = @{thm imageE} +val imageI = @{thm imageI} +val image_Un = @{thm image_Un} +val image_insert = @{thm image_insert} +val insert_commute = @{thm insert_commute} +val insert_iff = @{thm insert_iff} +val mem_Collect_eq = @{thm mem_Collect_eq} +val rangeE = @{thm rangeE} +val rangeI = @{thm rangeI} +val range_eqI = @{thm range_eqI} +val subsetCE = @{thm subsetCE} +val subsetD = @{thm subsetD} +val subsetI = @{thm subsetI} +val subset_refl = @{thm subset_refl} +val subset_trans = @{thm subset_trans} +val vimageD = @{thm vimageD} +val vimageE = @{thm vimageE} +val vimageI = @{thm vimageI} +val vimageI2 = @{thm vimageI2} +val vimage_Collect = @{thm vimage_Collect} +val vimage_Int = @{thm vimage_Int} +val vimage_Un = @{thm vimage_Un} +*} + + subsection {* Complete lattices *} notation @@ -957,10 +1758,10 @@ by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least) lemma Inf_Univ: "\UNIV = \{}" - unfolding Sup_Inf by (auto simp add: UNIV_def) + unfolding Sup_Inf by auto lemma Sup_Univ: "\UNIV = \{}" - unfolding Inf_Sup by (auto simp add: UNIV_def) + unfolding Inf_Sup by auto lemma Inf_insert: "\insert a A = a \ \A" by (auto intro: le_infI le_infI1 le_infI2 antisym Inf_greatest Inf_lower) @@ -1120,29 +1921,29 @@ lemma Inf_empty_fun: "\{} = (\_. \{})" - by rule (simp add: Inf_fun_def, simp add: empty_def) + by (simp add: Inf_fun_def) lemma Sup_empty_fun: "\{} = (\_. \{})" - by rule (simp add: Sup_fun_def, simp add: empty_def) + by (simp add: Sup_fun_def) subsubsection {* Union *} definition Union :: "'a set set \ 'a set" where - Union_eq [code del]: "Union A = {x. \B \ A. x \ B}" + Sup_set_eq [symmetric]: "Union S = \S" notation (xsymbols) Union ("\_" [90] 90) -lemma Sup_set_eq: - "\S = \S" +lemma Union_eq: + "\A = {x. \B \ A. x \ B}" proof (rule set_ext) fix x - have "(\Q\{P. \A\S. P \ x \ A}. Q) \ (\A\S. x \ A)" + have "(\Q\{P. \B\A. P \ x \ B}. Q) \ (\B\A. x \ B)" by auto - then show "x \ \S \ x \ \S" - by (simp add: Sup_fun_def Sup_bool_def Union_eq) (simp add: mem_def) + then show "x \ \A \ x \ {x. \B\A. x \ B}" + by (simp add: Sup_set_eq [symmetric] Sup_fun_def Sup_bool_def) (simp add: mem_def) qed lemma Union_iff [simp, noatp]: @@ -1159,11 +1960,53 @@ "A \ \C \ (\X. A\X \ X\C \ R) \ R" by auto +lemma Union_upper: "B \ A ==> B \ Union A" + by (iprover intro: subsetI UnionI) + +lemma Union_least: "(!!X. X \ A ==> X \ C) ==> Union A \ C" + by (iprover intro: subsetI elim: UnionE dest: subsetD) + +lemma Un_eq_Union: "A \ B = \{A, B}" + by blast + +lemma Union_empty [simp]: "Union({}) = {}" + by blast + +lemma Union_UNIV [simp]: "Union UNIV = UNIV" + by blast + +lemma Union_insert [simp]: "Union (insert a B) = a \ \B" + by blast + +lemma Union_Un_distrib [simp]: "\(A Un B) = \A \ \B" + by blast + +lemma Union_Int_subset: "\(A \ B) \ \A \ \B" + by blast + +lemma Union_empty_conv [simp,noatp]: "(\A = {}) = (\x\A. x = {})" + by blast + +lemma empty_Union_conv [simp,noatp]: "({} = \A) = (\x\A. x = {})" + by blast + +lemma Union_disjoint: "(\C \ A = {}) = (\B\C. B \ A = {})" + by blast + +lemma subset_Pow_Union: "A \ Pow (\A)" + by blast + +lemma Union_Pow_eq [simp]: "\(Pow A) = A" + by blast + +lemma Union_mono: "A \ B ==> \A \ \B" + by blast + subsubsection {* Unions of families *} definition UNION :: "'a set \ ('a \ 'b set) \ 'b set" where - UNION_eq_Union_image: "UNION A B = \(B`A)" + SUPR_set_eq [symmetric]: "UNION S f = (SUP x:S. f x)" syntax "@UNION1" :: "pttrns => 'b set => 'b set" ("(3UN _./ _)" [0, 10] 10) @@ -1196,16 +2039,16 @@ Syntax.preserve_binder_abs2_tr' @{const_syntax UNION} "@UNION" ] *} -- {* to avoid eta-contraction of body *} -lemma SUPR_set_eq: - "(SUP x:S. f x) = (\x\S. f x)" - by (simp add: SUPR_def UNION_eq_Union_image Sup_set_eq) +lemma UNION_eq_Union_image: + "(\x\A. B x) = \(B`A)" + by (simp add: SUPR_def SUPR_set_eq [symmetric] Sup_set_eq) lemma Union_def: "\S = (\x\S. x)" by (simp add: UNION_eq_Union_image image_def) lemma UNION_def [noatp]: - "UNION A B = {y. \x\A. y \ B x}" + "(\x\A. B x) = {y. \x\A. y \ B x}" by (auto simp add: UNION_eq_Union_image Union_eq) lemma Union_image_eq [simp]: @@ -1234,23 +2077,109 @@ lemma image_eq_UN: "f`A = (UN x:A. {f x})" by blast +lemma UN_upper: "a \ A ==> B a \ (\x\A. B x)" + by blast + +lemma UN_least: "(!!x. x \ A ==> B x \ C) ==> (\x\A. B x) \ C" + by (iprover intro: subsetI elim: UN_E dest: subsetD) + +lemma Collect_bex_eq [noatp]: "{x. \y\A. P x y} = (\y\A. {x. P x y})" + by blast + +lemma UN_insert_distrib: "u \ A ==> (\x\A. insert a (B x)) = insert a (\x\A. B x)" + by blast + +lemma UN_empty [simp,noatp]: "(\x\{}. B x) = {}" + by blast + +lemma UN_empty2 [simp]: "(\x\A. {}) = {}" + by blast + +lemma UN_singleton [simp]: "(\x\A. {x}) = A" + by blast + +lemma UN_absorb: "k \ I ==> A k \ (\i\I. A i) = (\i\I. A i)" + by auto + +lemma UN_insert [simp]: "(\x\insert a A. B x) = B a \ UNION A B" + by blast + +lemma UN_Un[simp]: "(\i \ A \ B. M i) = (\i\A. M i) \ (\i\B. M i)" + by blast + +lemma UN_UN_flatten: "(\x \ (\y\A. B y). C x) = (\y\A. \x\B y. C x)" + by blast + +lemma UN_subset_iff: "((\i\I. A i) \ B) = (\i\I. A i \ B)" + by blast + +lemma image_Union: "f ` \S = (\x\S. f ` x)" + by blast + +lemma UN_constant [simp]: "(\y\A. c) = (if A = {} then {} else c)" + by auto + +lemma UN_eq: "(\x\A. B x) = \({Y. \x\A. Y = B x})" + by blast + +lemma UNION_empty_conv[simp]: + "({} = (UN x:A. B x)) = (\x\A. B x = {})" + "((UN x:A. B x) = {}) = (\x\A. B x = {})" +by blast+ + +lemma Collect_ex_eq [noatp]: "{x. \y. P x y} = (\y. {x. P x y})" + by blast + +lemma ball_UN: "(\z \ UNION A B. P z) = (\x\A. \z \ B x. P z)" + by blast + +lemma bex_UN: "(\z \ UNION A B. P z) = (\x\A. \z\B x. P z)" + by blast + +lemma Un_eq_UN: "A \ B = (\b. if b then A else B)" + by (auto simp add: split_if_mem2) + +lemma UN_bool_eq: "(\b::bool. A b) = (A True \ A False)" + by (auto intro: bool_contrapos) + +lemma UN_Pow_subset: "(\x\A. Pow (B x)) \ Pow (\x\A. B x)" + by blast + +lemma UN_mono: + "A \ B ==> (!!x. x \ A ==> f x \ g x) ==> + (\x\A. f x) \ (\x\B. g x)" + by (blast dest: subsetD) + +lemma vimage_Union: "f -` (Union A) = (UN X:A. f -` X)" + by blast + +lemma vimage_UN: "f-`(UN x:A. B x) = (UN x:A. f -` B x)" + by blast + +lemma vimage_eq_UN: "f-`B = (UN y: B. f-`{y})" + -- {* NOT suitable for rewriting *} + by blast + +lemma image_UN: "(f ` (UNION A B)) = (UN x:A.(f ` (B x)))" +by blast + subsubsection {* Inter *} definition Inter :: "'a set set \ 'a set" where - Inter_eq [code del]: "Inter A = {x. \B \ A. x \ B}" - + Inf_set_eq [symmetric]: "Inter S = \S" + notation (xsymbols) Inter ("\_" [90] 90) -lemma Inf_set_eq: - "\S = \S" +lemma Inter_eq [code del]: + "\A = {x. \B \ A. x \ B}" proof (rule set_ext) fix x - have "(\Q\{P. \A\S. P \ x \ A}. Q) \ (\A\S. x \ A)" + have "(\Q\{P. \B\A. P \ x \ B}. Q) \ (\B\A. x \ B)" by auto - then show "x \ \S \ x \ \S" - by (simp add: Inter_eq Inf_fun_def Inf_bool_def) (simp add: mem_def) + then show "x \ \A \ x \ {x. \B \ A. x \ B}" + by (simp add: Inf_fun_def Inf_bool_def Inf_set_eq [symmetric]) (simp add: mem_def) qed lemma Inter_iff [simp,noatp]: "(A : Inter C) = (ALL X:C. A:X)" @@ -1273,11 +2202,47 @@ @{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 blast + +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,noatp]: + "(\A = UNIV) = (\x\A. x = UNIV)" + "(UNIV = \A) = (\x\A. x = UNIV)" + by blast+ + +lemma Inter_anti_mono: "B \ A ==> \A \ \B" + by blast + subsubsection {* Intersections of families *} definition INTER :: "'a set \ ('a \ 'b set) \ 'b set" where - INTER_eq_Inter_image: "INTER A B = \(B`A)" + INFI_set_eq [symmetric]: "INTER S f = (INF x:S. f x)" syntax "@INTER1" :: "pttrns => 'b set => 'b set" ("(3INT _./ _)" [0, 10] 10) @@ -1301,16 +2266,16 @@ Syntax.preserve_binder_abs2_tr' @{const_syntax INTER} "@INTER" ] *} -- {* to avoid eta-contraction of body *} -lemma INFI_set_eq: - "(INF x:S. f x) = (\x\S. f x)" - by (simp add: INFI_def INTER_eq_Inter_image Inf_set_eq) - +lemma INTER_eq_Inter_image: + "(\x\A. B x) = \(B`A)" + by (simp add: INFI_def INFI_set_eq [symmetric] Inf_set_eq) + lemma Inter_def: - "Inter S = INTER S (\x. x)" + "\S = (\x\S. x)" by (simp add: INTER_eq_Inter_image image_def) lemma INTER_def: - "INTER A B = {y. \x\A. y \ B x}" + "(\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]: @@ -1334,571 +2299,24 @@ "A = B ==> (!!x. x:B ==> C x = D x) ==> (INT x:A. C x) = (INT x:B. D x)" by (simp add: INTER_def) - -no_notation - less_eq (infix "\" 50) and - less (infix "\" 50) and - inf (infixl "\" 70) and - sup (infixl "\" 65) and - Inf ("\_" [900] 900) and - Sup ("\_" [900] 900) - - -subsection {* Further operations and lemmas *} - -subsubsection {* The ``proper subset'' relation *} - -lemma psubsetI [intro!,noatp]: "A \ B ==> A \ B ==> A \ B" - by (unfold less_le) blast - -lemma psubsetE [elim!,noatp]: - "[|A \ B; [|A \ B; ~ (B\A)|] ==> R|] ==> R" - by (unfold less_le) blast - -lemma psubset_insert_iff: - "(A \ insert x B) = (if x \ B then A \ B else if x \ A then A - {x} \ B else A \ B)" - by (auto simp add: less_le subset_insert_iff) - -lemma psubset_eq: "(A \ B) = (A \ B & A \ B)" - by (simp only: less_le) - -lemma psubset_imp_subset: "A \ B ==> A \ B" - by (simp add: psubset_eq) - -lemma psubset_trans: "[| A \ B; B \ C |] ==> A \ C" -apply (unfold less_le) -apply (auto dest: subset_antisym) -done - -lemma psubsetD: "[| A \ B; c \ A |] ==> c \ B" -apply (unfold less_le) -apply (auto dest: subsetD) -done - -lemma psubset_subset_trans: "A \ B ==> B \ C ==> A \ C" - by (auto simp add: psubset_eq) - -lemma subset_psubset_trans: "A \ B ==> B \ C ==> A \ C" - by (auto simp add: psubset_eq) - -lemma psubset_imp_ex_mem: "A \ B ==> \b. b \ (B - A)" - by (unfold less_le) blast - -lemma atomize_ball: - "(!!x. x \ A ==> P x) == Trueprop (\x\A. P x)" - by (simp only: Ball_def atomize_all atomize_imp) - -lemmas [symmetric, rulify] = atomize_ball - and [symmetric, defn] = atomize_ball - -subsubsection {* Derived rules involving subsets. *} - -text {* @{text insert}. *} - -lemma subset_insertI: "B \ insert a B" - by (rule subsetI) (erule insertI2) - -lemma subset_insertI2: "A \ B \ A \ insert b B" +lemma Collect_ball_eq: "{x. \y\A. P x y} = (\y\A. {x. P x y})" by blast -lemma subset_insert: "x \ A ==> (A \ insert x B) = (A \ B)" - by blast - - -text {* \medskip Big Union -- least upper bound of a set. *} - -lemma Union_upper: "B \ A ==> B \ Union A" - by (iprover intro: subsetI UnionI) - -lemma Union_least: "(!!X. X \ A ==> X \ C) ==> Union A \ C" - by (iprover intro: subsetI elim: UnionE dest: subsetD) - - -text {* \medskip General union. *} - -lemma UN_upper: "a \ A ==> B a \ (\x\A. B x)" +lemma Collect_all_eq: "{x. \y. P x y} = (\y. {x. P x y})" by blast -lemma UN_least: "(!!x. x \ A ==> B x \ C) ==> (\x\A. B x) \ C" - by (iprover intro: subsetI elim: UN_E dest: subsetD) - - -text {* \medskip Big Intersection -- greatest lower bound of a set. *} - -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_lower: "a \ A ==> (\x\A. B x) \ B a" by blast lemma INT_greatest: "(!!x. x \ A ==> C \ B x) ==> C \ (\x\A. B x)" by (iprover intro: INT_I subsetI dest: subsetD) - -text {* \medskip Finite Union -- the least upper bound of two sets. *} - -lemma Un_upper1: "A \ A \ B" - by blast - -lemma Un_upper2: "B \ A \ B" - by blast - -lemma Un_least: "A \ C ==> B \ C ==> A \ B \ C" - by blast - - -text {* \medskip Finite Intersection -- the greatest lower bound of two sets. *} - -lemma Int_lower1: "A \ B \ A" - by blast - -lemma Int_lower2: "A \ B \ B" - by blast - -lemma Int_greatest: "C \ A ==> C \ B ==> C \ A \ B" - by blast - - -text {* \medskip Set difference. *} - -lemma Diff_subset: "A - B \ A" - by blast - -lemma Diff_subset_conv: "(A - B \ C) = (A \ B \ C)" -by blast - - -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"} *} - by auto - -lemma subset_empty [simp]: "(A \ {}) = (A = {})" - by blast - -lemma not_psubset_empty [iff]: "\ (A < {})" - by (unfold less_le) blast - -lemma Collect_empty_eq [simp]: "(Collect P = {}) = (\x. \ P x)" -by blast - -lemma empty_Collect_eq [simp]: "({} = Collect P) = (\x. \ P x)" -by blast - -lemma Collect_neg_eq: "{x. \ P x} = - {x. P x}" - by blast - -lemma Collect_disj_eq: "{x. P x | Q x} = {x. P x} \ {x. Q x}" - by blast - -lemma Collect_imp_eq: "{x. P x --> Q x} = -{x. P x} \ {x. Q x}" - by blast - -lemma Collect_conj_eq: "{x. P x & Q x} = {x. P x} \ {x. Q x}" - by blast - -lemma Collect_all_eq: "{x. \y. P x y} = (\y. {x. P x y})" - by blast - -lemma Collect_ball_eq: "{x. \y\A. P x y} = (\y\A. {x. P x y})" - by blast - -lemma Collect_ex_eq [noatp]: "{x. \y. P x y} = (\y. {x. P x y})" - by blast - -lemma Collect_bex_eq [noatp]: "{x. \y\A. P x y} = (\y\A. {x. P x y})" - by blast - - -text {* \medskip @{text insert}. *} - -lemma insert_is_Un: "insert a A = {a} Un A" - -- {* NOT SUITABLE FOR REWRITING since @{text "{a} == insert a {}"} *} - by blast - -lemma insert_not_empty [simp]: "insert a A \ {}" - by blast - -lemmas empty_not_insert = insert_not_empty [symmetric, standard] -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 *} - by blast - -lemma insert_absorb2 [simp]: "insert x (insert x A) = insert x A" - by blast - -lemma insert_commute: "insert x (insert y A) = insert y (insert x A)" - by blast - -lemma insert_subset [simp]: "(insert x A \ B) = (x \ B & A \ B)" - 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 *} - apply (rule_tac x = "A - {a}" in exI, blast) - done - -lemma insert_Collect: "insert a (Collect P) = {u. u \ a --> P u}" - by auto - -lemma UN_insert_distrib: "u \ A ==> (\x\A. insert a (B x)) = insert a (\x\A. B x)" - by blast - -lemma insert_inter_insert[simp]: "insert a A \ insert a B = insert a (A \ B)" - by blast - -lemma insert_disjoint [simp,noatp]: - "(insert a A \ B = {}) = (a \ B \ A \ B = {})" - "({} = insert a A \ B) = (a \ B \ {} = A \ B)" - by auto - -lemma disjoint_insert [simp,noatp]: - "(B \ insert a A = {}) = (a \ B \ B \ A = {})" - "({} = A \ insert b B) = (b \ A \ {} = A \ B)" - by auto - -text {* \medskip @{text image}. *} - -lemma image_empty [simp]: "f`{} = {}" - by blast - -lemma image_insert [simp]: "f ` insert a B = insert (f a) (f`B)" - by blast - -lemma image_constant: "x \ A ==> (\x. c) ` A = {c}" - by auto - -lemma image_constant_conv: "(%x. c) ` A = (if A = {} then {} else {c})" -by auto - -lemma image_image: "f ` (g ` A) = (\x. f (g x)) ` A" -by blast - -lemma insert_image [simp]: "x \ A ==> insert (f x) (f`A) = f`A" -by blast - -lemma image_is_empty [iff]: "(f`A = {}) = (A = {})" -by blast - -lemma empty_is_image[iff]: "({} = f ` A) = (A = {})" -by blast - - -lemma image_Collect [noatp]: "f ` {x. P x} = {f x | x. P x}" - -- {* 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 - -lemma if_image_distrib [simp]: - "(\x. if P x then f x else g x) ` S - = (f ` (S \ {x. P x})) \ (g ` (S \ {x. \ P x}))" - by (auto simp add: image_def) - -lemma image_cong: "M = N ==> (!!x. x \ N ==> f x = g x) ==> f`M = g`N" - by (simp add: image_def) - - -text {* \medskip @{text range}. *} - -lemma full_SetCompr_eq [noatp]: "{u. \x. u = f x} = range f" - by auto - -lemma range_composition: "range (\x. f (g x)) = f`range g" -by (subst image_image, simp) - - -text {* \medskip @{text Int} *} - -lemma Int_absorb [simp]: "A \ A = A" - by blast - -lemma Int_left_absorb: "A \ (A \ B) = A \ B" - by blast - -lemma Int_commute: "A \ B = B \ A" - by blast - -lemma Int_left_commute: "A \ (B \ C) = B \ (A \ C)" - by blast - -lemma Int_assoc: "(A \ B) \ C = A \ (B \ C)" - by blast - -lemmas Int_ac = Int_assoc Int_left_absorb Int_commute Int_left_commute - -- {* Intersection is an AC-operator *} - -lemma Int_absorb1: "B \ A ==> A \ B = B" - by blast - -lemma Int_absorb2: "A \ B ==> A \ B = A" - by blast - -lemma Int_empty_left [simp]: "{} \ B = {}" - by blast - -lemma Int_empty_right [simp]: "A \ {} = {}" - by blast - -lemma disjoint_eq_subset_Compl: "(A \ B = {}) = (A \ -B)" - by blast - -lemma disjoint_iff_not_equal: "(A \ B = {}) = (\x\A. \y\B. x \ y)" - by blast - -lemma Int_UNIV_left [simp]: "UNIV \ B = B" - by blast - -lemma Int_UNIV_right [simp]: "A \ UNIV = A" - by blast - -lemma Int_eq_Inter: "A \ B = \{A, B}" - by blast - -lemma Int_Un_distrib: "A \ (B \ C) = (A \ B) \ (A \ C)" - by blast - -lemma Int_Un_distrib2: "(B \ C) \ A = (B \ A) \ (C \ A)" - by blast - -lemma Int_UNIV [simp,noatp]: "(A \ B = UNIV) = (A = UNIV & B = UNIV)" - by blast - -lemma Int_subset_iff [simp]: "(C \ A \ B) = (C \ A & C \ B)" - by blast - -lemma Int_Collect: "(x \ A \ {x. P x}) = (x \ A & P x)" - by blast - - -text {* \medskip @{text Un}. *} - -lemma Un_absorb [simp]: "A \ A = A" - by blast - -lemma Un_left_absorb: "A \ (A \ B) = A \ B" - by blast - -lemma Un_commute: "A \ B = B \ A" - by blast - -lemma Un_left_commute: "A \ (B \ C) = B \ (A \ C)" - by blast - -lemma Un_assoc: "(A \ B) \ C = A \ (B \ C)" - by blast - -lemmas Un_ac = Un_assoc Un_left_absorb Un_commute Un_left_commute - -- {* Union is an AC-operator *} - -lemma Un_absorb1: "A \ B ==> A \ B = B" - by blast - -lemma Un_absorb2: "B \ A ==> A \ B = A" - by blast - -lemma Un_empty_left [simp]: "{} \ B = B" - by blast - -lemma Un_empty_right [simp]: "A \ {} = A" - by blast - -lemma Un_UNIV_left [simp]: "UNIV \ B = UNIV" - by blast - -lemma Un_UNIV_right [simp]: "A \ UNIV = UNIV" - by blast - -lemma Un_eq_Union: "A \ B = \{A, B}" - by blast - -lemma Un_insert_left [simp]: "(insert a B) \ C = insert a (B \ C)" - by blast - -lemma Un_insert_right [simp]: "A \ (insert a B) = insert a (A \ B)" - by blast - -lemma Int_insert_left: - "(insert a B) Int C = (if a \ C then insert a (B \ C) else B \ C)" - by auto - -lemma Int_insert_right: - "A \ (insert a B) = (if a \ A then insert a (A \ B) else A \ B)" - by auto - -lemma Un_Int_distrib: "A \ (B \ C) = (A \ B) \ (A \ C)" - by blast - -lemma Un_Int_distrib2: "(B \ C) \ A = (B \ A) \ (C \ A)" - by blast - -lemma Un_Int_crazy: - "(A \ B) \ (B \ C) \ (C \ A) = (A \ B) \ (B \ C) \ (C \ A)" - by blast - -lemma subset_Un_eq: "(A \ B) = (A \ B = B)" - by blast - -lemma Un_empty [iff]: "(A \ B = {}) = (A = {} & B = {})" - by blast - -lemma Un_subset_iff [simp]: "(A \ B \ C) = (A \ C & B \ C)" - by blast - -lemma Un_Diff_Int: "(A - B) \ (A \ B) = A" - by blast - -lemma Diff_Int2: "A \ C - B \ C = A \ C - B" - by blast - - -text {* \medskip Set complement *} - -lemma Compl_disjoint [simp]: "A \ -A = {}" - by blast - -lemma Compl_disjoint2 [simp]: "-A \ A = {}" - by blast - -lemma Compl_partition: "A \ -A = UNIV" - by blast - -lemma Compl_partition2: "-A \ A = UNIV" - by blast - -lemma double_complement [simp]: "- (-A) = (A::'a set)" - by blast - -lemma Compl_Un [simp]: "-(A \ B) = (-A) \ (-B)" - by blast - -lemma Compl_Int [simp]: "-(A \ B) = (-A) \ (-B)" - by blast - -lemma Compl_UN [simp]: "-(\x\A. B x) = (\x\A. -B x)" - by blast - -lemma Compl_INT [simp]: "-(\x\A. B x) = (\x\A. -B x)" - by blast - -lemma subset_Compl_self_eq: "(A \ -A) = (A = {})" - by blast - -lemma Un_Int_assoc_eq: "((A \ B) \ C = A \ (B \ C)) = (C \ A)" - -- {* Halmos, Naive Set Theory, page 16. *} - by blast - -lemma Compl_UNIV_eq [simp]: "-UNIV = {}" - by blast - -lemma Compl_empty_eq [simp]: "-{} = UNIV" - by blast - -lemma Compl_subset_Compl_iff [iff]: "(-A \ -B) = (B \ A)" - by blast - -lemma Compl_eq_Compl_iff [iff]: "(-A = -B) = (A = (B::'a set))" - by blast - - -text {* \medskip @{text Union}. *} - -lemma Union_empty [simp]: "Union({}) = {}" - by blast - -lemma Union_UNIV [simp]: "Union UNIV = UNIV" - by blast - -lemma Union_insert [simp]: "Union (insert a B) = a \ \B" - by blast - -lemma Union_Un_distrib [simp]: "\(A Un B) = \A \ \B" - by blast - -lemma Union_Int_subset: "\(A \ B) \ \A \ \B" - by blast - -lemma Union_empty_conv [simp,noatp]: "(\A = {}) = (\x\A. x = {})" - by blast - -lemma empty_Union_conv [simp,noatp]: "({} = \A) = (\x\A. x = {})" - by blast - -lemma Union_disjoint: "(\C \ A = {}) = (\B\C. B \ A = {})" - by blast - - -text {* \medskip @{text Inter}. *} - -lemma Inter_empty [simp]: "\{} = UNIV" - by blast - -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,noatp]: - "(\A = UNIV) = (\x\A. x = UNIV)" - "(UNIV = \A) = (\x\A. x = UNIV)" - by blast+ - - -text {* - \medskip @{text UN} and @{text INT}. - - Basic identities: *} - -lemma UN_empty [simp,noatp]: "(\x\{}. B x) = {}" - by blast - -lemma UN_empty2 [simp]: "(\x\A. {}) = {}" - by blast - -lemma UN_singleton [simp]: "(\x\A. {x}) = A" - by blast - -lemma UN_absorb: "k \ I ==> A k \ (\i\I. A i) = (\i\I. A i)" - by auto - 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 UN_insert [simp]: "(\x\insert a A. B x) = B a \ UNION A B" - by blast - -lemma UN_Un[simp]: "(\i \ A \ B. M i) = (\i\A. M i) \ (\i\B. M i)" - by blast - -lemma UN_UN_flatten: "(\x \ (\y\A. B y). C x) = (\y\A. \x\B y. C x)" - by blast - -lemma UN_subset_iff: "((\i\I. A i) \ B) = (\i\I. A i \ B)" - by blast - lemma INT_subset_iff: "(B \ (\i\I. A i)) = (\i\I. B \ A i)" by blast @@ -1912,34 +2330,35 @@ "u \ A ==> (\x\A. insert a (B x)) = insert a (\x\A. B x)" by blast -lemma image_Union: "f ` \S = (\x\S. f ` x)" - by blast - -lemma UN_constant [simp]: "(\y\A. c) = (if A = {} then {} else c)" - by auto - lemma INT_constant [simp]: "(\y\A. c) = (if A = {} then UNIV else c)" by auto -lemma UN_eq: "(\x\A. B x) = \({Y. \x\A. Y = B x})" - by blast - lemma INT_eq: "(\x\A. B x) = \({Y. \x\A. Y = B x})" -- {* Look: it has an \emph{existential} quantifier *} by blast -lemma UNION_empty_conv[simp]: - "({} = (UN x:A. B x)) = (\x\A. B x = {})" - "((UN x:A. B x) = {}) = (\x\A. B x = {})" -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+ - -text {* \medskip Distributive laws: *} +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 + + +subsubsection {* Distributive laws *} lemma Int_Union: "A \ \B = (\C\B. A \ C)" by blast @@ -1980,192 +2399,16 @@ by blast -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}. *} - -lemma ball_Un: "(\x \ A \ B. P x) = ((\x\A. P x) & (\x\B. P x))" - by blast - -lemma bex_Un: "(\x \ A \ B. P x) = ((\x\A. P x) | (\x\B. P x))" - by blast - -lemma ball_UN: "(\z \ UNION A B. P z) = (\x\A. \z \ B x. P z)" - by blast - -lemma bex_UN: "(\z \ UNION A B. P z) = (\x\A. \z\B x. P z)" - by blast - - -text {* \medskip Set difference. *} - -lemma Diff_eq: "A - B = A \ (-B)" - by blast - -lemma Diff_eq_empty_iff [simp,noatp]: "(A - B = {}) = (A \ B)" - by blast - -lemma Diff_cancel [simp]: "A - A = {}" - by blast - -lemma Diff_idemp [simp]: "(A - B) - B = A - (B::'a set)" -by blast - -lemma Diff_triv: "A \ B = {} ==> A - B = A" - by (blast elim: equalityE) - -lemma empty_Diff [simp]: "{} - A = {}" - by blast - -lemma Diff_empty [simp]: "A - {} = A" - by blast - -lemma Diff_UNIV [simp]: "A - UNIV = {}" - by blast - -lemma Diff_insert0 [simp,noatp]: "x \ A ==> A - insert x B = A - B" - by blast - -lemma Diff_insert: "A - insert a B = A - B - {a}" - -- {* 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"} *} - by blast - -lemma insert_Diff_if: "insert x A - B = (if x \ B then A - B else insert x (A - B))" - by auto - -lemma insert_Diff1 [simp]: "x \ B ==> insert x A - B = A - B" - by blast - -lemma insert_Diff_single[simp]: "insert a (A - {a}) = insert a A" -by blast - -lemma insert_Diff: "a \ A ==> insert a (A - {a}) = A" - by blast - -lemma Diff_insert_absorb: "x \ A ==> (insert x A) - {x} = A" - by auto - -lemma Diff_disjoint [simp]: "A \ (B - A) = {}" - by blast - -lemma Diff_partition: "A \ B ==> A \ (B - A) = B" - by blast - -lemma double_diff: "A \ B ==> B \ C ==> B - (C - A) = A" - by blast - -lemma Un_Diff_cancel [simp]: "A \ (B - A) = A \ B" - by blast - -lemma Un_Diff_cancel2 [simp]: "(B - A) \ A = B \ A" - by blast - -lemma Diff_Un: "A - (B \ C) = (A - B) \ (A - C)" - by blast - -lemma Diff_Int: "A - (B \ C) = (A - B) \ (A - C)" - by blast - -lemma Un_Diff: "(A \ B) - C = (A - C) \ (B - C)" +subsubsection {* Complement *} + +lemma Compl_UN [simp]: "-(\x\A. B x) = (\x\A. -B x)" by blast -lemma Int_Diff: "(A \ B) - C = A \ (B - C)" - by blast - -lemma Diff_Int_distrib: "C \ (A - B) = (C \ A) - (C \ B)" - by blast - -lemma Diff_Int_distrib2: "(A - B) \ C = (A \ C) - (B \ C)" - by blast - -lemma Diff_Compl [simp]: "A - (- B) = A \ B" - by auto - -lemma Compl_Diff_eq [simp]: "- (A - B) = -A \ B" +lemma Compl_INT [simp]: "-(\x\A. B x) = (\x\A. -B x)" by blast -text {* \medskip Quantification over type @{typ bool}. *} - -lemma bool_induct: "P True \ P False \ P x" - by (cases x) auto - -lemma all_bool_eq: "(\b. P b) \ P True \ P False" - by (auto intro: bool_induct) - -lemma bool_contrapos: "P x \ \ P False \ P True" - by (cases x) auto - -lemma ex_bool_eq: "(\b. P b) \ P True \ P False" - by (auto intro: bool_contrapos) - -lemma Un_eq_UN: "A \ B = (\b. if b then A else B)" - by (auto simp add: split_if_mem2) - -lemma UN_bool_eq: "(\b::bool. A b) = (A True \ A False)" - by (auto intro: bool_contrapos) - -lemma INT_bool_eq: "(\b::bool. A b) = (A True \ A False)" - by (auto intro: bool_induct) - -text {* \medskip @{text Pow} *} - -lemma Pow_empty [simp]: "Pow {} = {{}}" - by (auto simp add: Pow_def) - -lemma Pow_insert: "Pow (insert a A) = Pow A \ (insert a ` Pow A)" - by (blast intro: image_eqI [where ?x = "u - {a}", standard]) - -lemma Pow_Compl: "Pow (- A) = {-B | B. A \ Pow B}" - by (blast intro: exI [where ?x = "- u", standard]) - -lemma Pow_UNIV [simp]: "Pow UNIV = UNIV" - by blast - -lemma Un_Pow_subset: "Pow A \ Pow B \ Pow (A \ B)" - by blast - -lemma UN_Pow_subset: "(\x\A. Pow (B x)) \ Pow (\x\A. B x)" - by blast - -lemma subset_Pow_Union: "A \ Pow (\A)" - by blast - -lemma Union_Pow_eq [simp]: "\(Pow A) = A" - by blast - -lemma Pow_Int_eq [simp]: "Pow (A \ B) = Pow A \ Pow B" - by blast - -lemma Pow_INT_eq: "Pow (\x\A. B x) = (\x\A. Pow (B x))" - by blast - - -text {* \medskip Miscellany. *} - -lemma set_eq_subset: "(A = B) = (A \ B & B \ A)" - by blast - -lemma subset_iff: "(A \ B) = (\t. t \ A --> t \ B)" - by blast - -lemma subset_iff_psubset_eq: "(A \ B) = ((A \ B) | (A = B))" - by (unfold less_le) blast - -lemma all_not_in_conv [simp]: "(\x. x \ A) = (A = {})" - by blast - -lemma ex_in_conv: "(\x. x \ A) = (A \ {})" - by blast - -lemma distinct_lemma: "f x \ f y ==> x \ y" - by iprover - +subsubsection {* Miniscoping and maxiscoping *} text {* \medskip Miniscoping: pushing in quantifiers and big Unions and Intersections. *} @@ -2262,284 +2505,17 @@ by auto -subsubsection {* Monotonicity of various operations *} - -lemma image_mono: "A \ B ==> f`A \ f`B" - by blast - -lemma Pow_mono: "A \ B ==> Pow A \ Pow B" - by blast - -lemma Union_mono: "A \ B ==> \A \ \B" - by blast - -lemma Inter_anti_mono: "B \ A ==> \A \ \B" - by blast - -lemma UN_mono: - "A \ B ==> (!!x. x \ A ==> f x \ g x) ==> - (\x\A. f x) \ (\x\B. g x)" - by (blast dest: subsetD) - -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 insert_mono: "C \ D ==> insert a C \ insert a D" - by blast - -lemma Un_mono: "A \ C ==> B \ D ==> A \ B \ C \ D" - by blast - -lemma Int_mono: "A \ C ==> B \ D ==> A \ B \ C \ D" - by blast - -lemma Diff_mono: "A \ C ==> D \ B ==> A - B \ C - D" - by blast - -lemma Compl_anti_mono: "A \ B ==> -B \ -A" - by blast - -text {* \medskip Monotonicity of implications. *} - -lemma in_mono: "A \ B ==> x \ A --> x \ B" - apply (rule impI) - apply (erule subsetD, assumption) - done - -lemma conj_mono: "P1 --> Q1 ==> P2 --> Q2 ==> (P1 & P2) --> (Q1 & Q2)" - by iprover - -lemma disj_mono: "P1 --> Q1 ==> P2 --> Q2 ==> (P1 | P2) --> (Q1 | Q2)" - by iprover - -lemma imp_mono: "Q1 --> P1 ==> P2 --> Q2 ==> (P1 --> P2) --> (Q1 --> Q2)" - by iprover - -lemma imp_refl: "P --> P" .. - -lemma ex_mono: "(!!x. P x --> Q x) ==> (EX x. P x) --> (EX x. Q x)" - by iprover - -lemma all_mono: "(!!x. P x --> Q x) ==> (ALL x. P x) --> (ALL x. Q x)" - by iprover - -lemma Collect_mono: "(!!x. P x --> Q x) ==> Collect P \ Collect Q" - by blast - -lemma Int_Collect_mono: - "A \ B ==> (!!x. x \ A ==> P x --> Q x) ==> A \ Collect P \ B \ Collect Q" - by blast - -lemmas basic_monos = - subset_refl imp_refl disj_mono conj_mono - ex_mono Collect_mono in_mono - -lemma eq_to_mono: "a = b ==> c = d ==> b --> d ==> a --> c" - by iprover - -lemma eq_to_mono2: "a = b ==> c = d ==> ~ b --> ~ d ==> ~ a --> ~ c" - by iprover - - -subsubsection {* Inverse image of a function *} - -constdefs - vimage :: "('a => 'b) => 'b set => 'a set" (infixr "-`" 90) - [code del]: "f -` B == {x. f x : B}" - -lemma vimage_eq [simp]: "(a : f -` B) = (f a : B)" - by (unfold vimage_def) blast - -lemma vimage_singleton_eq: "(a : f -` {b}) = (f a = b)" - by simp - -lemma vimageI [intro]: "f a = b ==> b:B ==> a : f -` B" - by (unfold vimage_def) blast - -lemma vimageI2: "f a : A ==> a : f -` A" - by (unfold vimage_def) fast - -lemma vimageE [elim!]: "a: f -` B ==> (!!x. f a = x ==> x:B ==> P) ==> P" - by (unfold vimage_def) blast - -lemma vimageD: "a : f -` A ==> f a : A" - by (unfold vimage_def) fast - -lemma vimage_empty [simp]: "f -` {} = {}" - by blast - -lemma vimage_Compl: "f -` (-A) = -(f -` A)" - by blast - -lemma vimage_Un [simp]: "f -` (A Un B) = (f -` A) Un (f -` B)" - by blast - -lemma vimage_Int [simp]: "f -` (A Int B) = (f -` A) Int (f -` B)" - by fast - -lemma vimage_Union: "f -` (Union A) = (UN X:A. f -` X)" - by blast - -lemma vimage_UN: "f-`(UN x:A. B x) = (UN x:A. f -` B x)" - by blast - -lemma vimage_INT: "f-`(INT x:A. B x) = (INT x:A. f -` B x)" - by blast - -lemma vimage_Collect_eq [simp]: "f -` Collect P = {y. P (f y)}" - by blast - -lemma vimage_Collect: "(!!x. P (f x) = Q x) ==> f -` (Collect P) = Collect Q" - 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}"}. *} - by blast - -lemma vimage_Diff: "f -` (A - B) = (f -` A) - (f -` B)" - by blast - -lemma vimage_UNIV [simp]: "f -` UNIV = UNIV" - by blast - -lemma vimage_eq_UN: "f-`B = (UN y: B. f-`{y})" - -- {* NOT suitable for rewriting *} - by blast - -lemma vimage_mono: "A \ B ==> f -` A \ f -` B" - -- {* monotonicity *} - by blast - -lemma vimage_image_eq [noatp]: "f -` (f ` A) = {y. EX x:A. f x = f y}" -by (blast intro: sym) - -lemma image_vimage_subset: "f ` (f -` A) <= A" -by blast - -lemma image_vimage_eq [simp]: "f ` (f -` A) = A Int range f" -by blast - -lemma image_Int_subset: "f`(A Int B) <= f`A Int f`B" -by blast - -lemma image_diff_subset: "f`A - f`B <= f`(A - B)" -by blast - -lemma image_UN: "(f ` (UNION A B)) = (UN x:A.(f ` (B x)))" -by blast - - -subsubsection {* Getting the Contents of a Singleton Set *} - -definition contents :: "'a set \ 'a" where - [code del]: "contents X = (THE x. X = {x})" - -lemma contents_eq [simp]: "contents {x} = x" - by (simp add: contents_def) - - -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 *} - apply clarify - apply (erule_tac P = "%x. x : S" in LeastI2_order, fast) - apply (rule LeastI2_order) - apply (auto elim: monoD intro!: order_antisym) - done - -subsection {* Misc *} - -text {* Rudimentary code generation *} - -lemma [code]: "{} = bot" - by (rule sym) (fact bot_set_eq) - -lemma [code]: "UNIV = top" - by (rule sym) (fact top_set_eq) - -lemma [code]: "op \ = inf" - by (rule ext)+ (simp add: inf_set_eq) - -lemma [code]: "op \ = sup" - by (rule ext)+ (simp add: sup_set_eq) - -lemma insert_code [code]: "insert y A x \ y = x \ A x" - by (auto simp add: insert_compr Collect_def mem_def) - -lemma vimage_code [code]: "(f -` A) x = A (f x)" - by (simp add: vimage_def Collect_def mem_def) - - -text {* Misc theorem and ML bindings *} - -lemmas equalityI = subset_antisym +no_notation + less_eq (infix "\" 50) and + less (infix "\" 50) and + inf (infixl "\" 70) and + sup (infixl "\" 65) and + Inf ("\_" [900] 900) and + Sup ("\_" [900] 900) + 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 -- {* Each of these has ALREADY been added @{text "[simp]"} above. *} -ML {* -val Ball_def = @{thm Ball_def} -val Bex_def = @{thm Bex_def} -val CollectD = @{thm CollectD} -val CollectE = @{thm CollectE} -val CollectI = @{thm CollectI} -val Collect_conj_eq = @{thm Collect_conj_eq} -val Collect_mem_eq = @{thm Collect_mem_eq} -val IntD1 = @{thm IntD1} -val IntD2 = @{thm IntD2} -val IntE = @{thm IntE} -val IntI = @{thm IntI} -val Int_Collect = @{thm Int_Collect} -val UNIV_I = @{thm UNIV_I} -val UNIV_witness = @{thm UNIV_witness} -val UnE = @{thm UnE} -val UnI1 = @{thm UnI1} -val UnI2 = @{thm UnI2} -val ballE = @{thm ballE} -val ballI = @{thm ballI} -val bexCI = @{thm bexCI} -val bexE = @{thm bexE} -val bexI = @{thm bexI} -val bex_triv = @{thm bex_triv} -val bspec = @{thm bspec} -val contra_subsetD = @{thm contra_subsetD} -val distinct_lemma = @{thm distinct_lemma} -val eq_to_mono = @{thm eq_to_mono} -val eq_to_mono2 = @{thm eq_to_mono2} -val equalityCE = @{thm equalityCE} -val equalityD1 = @{thm equalityD1} -val equalityD2 = @{thm equalityD2} -val equalityE = @{thm equalityE} -val equalityI = @{thm equalityI} -val imageE = @{thm imageE} -val imageI = @{thm imageI} -val image_Un = @{thm image_Un} -val image_insert = @{thm image_insert} -val insert_commute = @{thm insert_commute} -val insert_iff = @{thm insert_iff} -val mem_Collect_eq = @{thm mem_Collect_eq} -val rangeE = @{thm rangeE} -val rangeI = @{thm rangeI} -val range_eqI = @{thm range_eqI} -val subsetCE = @{thm subsetCE} -val subsetD = @{thm subsetD} -val subsetI = @{thm subsetI} -val subset_refl = @{thm subset_refl} -val subset_trans = @{thm subset_trans} -val vimageD = @{thm vimageD} -val vimageE = @{thm vimageE} -val vimageI = @{thm vimageI} -val vimageI2 = @{thm vimageI2} -val vimage_Collect = @{thm vimage_Collect} -val vimage_Int = @{thm vimage_Int} -val vimage_Un = @{thm vimage_Un} -*} - end diff -r ee143615019c -r f645b51e8e54 src/HOL/Tools/Function/fundef_lib.ML --- a/src/HOL/Tools/Function/fundef_lib.ML Wed Jul 22 14:20:32 2009 +0200 +++ b/src/HOL/Tools/Function/fundef_lib.ML Wed Jul 22 14:20:32 2009 +0200 @@ -167,10 +167,10 @@ end (* instance for unions *) -fun regroup_union_conv t = regroup_conv @{const_name Set.empty} @{const_name Un} - (map (fn t => t RS eq_reflection) (@{thms "Un_ac"} @ - @{thms "Un_empty_right"} @ - @{thms "Un_empty_left"})) t +fun regroup_union_conv t = regroup_conv @{const_name Set.empty} @{const_name Set.union} + (map (fn t => t RS eq_reflection) (@{thms Un_ac} @ + @{thms Un_empty_right} @ + @{thms Un_empty_left})) t end diff -r ee143615019c -r f645b51e8e54 src/HOL/Tools/Function/termination.ML --- a/src/HOL/Tools/Function/termination.ML Wed Jul 22 14:20:32 2009 +0200 +++ b/src/HOL/Tools/Function/termination.ML Wed Jul 22 14:20:32 2009 +0200 @@ -145,7 +145,7 @@ fun mk_sum_skel rel = let - val cs = FundefLib.dest_binop_list @{const_name Un} rel + val cs = FundefLib.dest_binop_list @{const_name union} rel fun collect_pats (Const ("Collect", _) $ Abs (_, _, c)) = let val (Const ("op &", _) $ (Const ("op =", _) $ _ $ (Const ("Pair", _) $ r $ l)) $ Gam) @@ -233,7 +233,7 @@ fun CALLS tac i st = if Thm.no_prems st then all_tac st else case Thm.term_of (Thm.cprem_of st i) of - (_ $ (_ $ rel)) => tac (FundefLib.dest_binop_list @{const_name Un} rel, i) st + (_ $ (_ $ rel)) => tac (FundefLib.dest_binop_list @{const_name union} rel, i) st |_ => no_tac st type ttac = (data -> int -> tactic) -> (data -> int -> tactic) -> data -> int -> tactic @@ -293,7 +293,7 @@ if null ineqs then Const (@{const_name Set.empty}, fastype_of rel) else - foldr1 (HOLogic.mk_binop @{const_name Un}) (map mk_compr ineqs) + foldr1 (HOLogic.mk_binop @{const_name union}) (map mk_compr ineqs) fun solve_membership_tac i = (EVERY' (replicate (i - 2) (rtac @{thm UnI2})) (* pick the right component of the union *) diff -r ee143615019c -r f645b51e8e54 src/HOL/Tools/inductive_set.ML --- a/src/HOL/Tools/inductive_set.ML Wed Jul 22 14:20:32 2009 +0200 +++ b/src/HOL/Tools/inductive_set.ML Wed Jul 22 14:20:32 2009 +0200 @@ -73,8 +73,8 @@ in Drule.instantiate' [] (rev (map (SOME o cterm_of thy o Var) vs)) (p (fold (Logic.all o Var) vs t) f) end; - fun mkop "op &" T x = SOME (Const (@{const_name "Int"}, T --> T --> T), x) - | mkop "op |" T x = SOME (Const (@{const_name "Un"}, T --> T --> T), x) + fun mkop "op &" T x = SOME (Const (@{const_name inter}, T --> T --> T), x) + | mkop "op |" T x = SOME (Const (@{const_name union}, T --> T --> T), x) | mkop _ _ _ = NONE; fun mk_collect p T t = let val U = HOLogic.dest_setT T diff -r ee143615019c -r f645b51e8e54 src/HOL/Tools/res_clause.ML --- a/src/HOL/Tools/res_clause.ML Wed Jul 22 14:20:32 2009 +0200 +++ b/src/HOL/Tools/res_clause.ML Wed Jul 22 14:20:32 2009 +0200 @@ -110,8 +110,8 @@ (@{const_name "op -->"}, "implies"), (@{const_name Set.empty}, "emptyset"), (@{const_name "op :"}, "in"), - (@{const_name Un}, "union"), - (@{const_name Int}, "inter"), + (@{const_name union}, "union"), + (@{const_name inter}, "inter"), ("List.append", "append"), ("ATP_Linkup.fequal", "fequal"), ("ATP_Linkup.COMBI", "COMBI"), diff -r ee143615019c -r f645b51e8e54 src/HOL/ex/Meson_Test.thy --- a/src/HOL/ex/Meson_Test.thy Wed Jul 22 14:20:32 2009 +0200 +++ b/src/HOL/ex/Meson_Test.thy Wed Jul 22 14:20:32 2009 +0200 @@ -1,4 +1,3 @@ -(*ID: $Id$*) header {* Meson test cases *} @@ -11,7 +10,7 @@ below and constants declared in HOL! *} -hide const subset member quotient +hide (open) const subset member quotient union inter text {* Test data for the MESON proof procedure