| author | sultana | 
| Wed, 19 Feb 2014 15:57:02 +0000 | |
| changeset 55586 | c94f1a72d9c5 | 
| parent 54230 | b1d955791529 | 
| child 56899 | 9b9f4abaaa7e | 
| permissions | -rw-r--r-- | 
| 38622 | 1 | (* Title: HOL/Library/Set_Algebras.thy | 
| 2 | Author: Jeremy Avigad and Kevin Donnelly; Florian Haftmann, TUM | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 3 | *) | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 4 | |
| 38622 | 5 | header {* Algebraic operations on sets *}
 | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 6 | |
| 38622 | 7 | theory Set_Algebras | 
| 30738 | 8 | imports Main | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 9 | begin | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 10 | |
| 19736 | 11 | text {*
 | 
| 38622 | 12 | This library lifts operations like addition and muliplication to | 
| 13 | sets. It was designed to support asymptotic calculations. See the | |
| 14 |   comments at the top of theory @{text BigO}.
 | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 15 | *} | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 16 | |
| 47443 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 17 | instantiation set :: (plus) plus | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 18 | begin | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 19 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 20 | definition plus_set :: "'a::plus set \<Rightarrow> 'a set \<Rightarrow> 'a set" where | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 21 |   set_plus_def: "A + B = {c. \<exists>a\<in>A. \<exists>b\<in>B. c = a + b}"
 | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 22 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 23 | instance .. | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 24 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 25 | end | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 26 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 27 | instantiation set :: (times) times | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 28 | begin | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 29 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 30 | definition times_set :: "'a::times set \<Rightarrow> 'a set \<Rightarrow> 'a set" where | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 31 |   set_times_def: "A * B = {c. \<exists>a\<in>A. \<exists>b\<in>B. c = a * b}"
 | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 32 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 33 | instance .. | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 34 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 35 | end | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 36 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 37 | instantiation set :: (zero) zero | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 38 | begin | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 39 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 40 | definition | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 41 |   set_zero[simp]: "0::('a::zero)set == {0}"
 | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 42 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 43 | instance .. | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 44 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 45 | end | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 46 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 47 | instantiation set :: (one) one | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 48 | begin | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 49 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 50 | definition | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 51 |   set_one[simp]: "1::('a::one)set == {1}"
 | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 52 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 53 | instance .. | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 54 | |
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 55 | end | 
| 25594 | 56 | |
| 38622 | 57 | definition elt_set_plus :: "'a::plus \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixl "+o" 70) where | 
| 58 |   "a +o B = {c. \<exists>b\<in>B. c = a + b}"
 | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 59 | |
| 38622 | 60 | definition elt_set_times :: "'a::times \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixl "*o" 80) where | 
| 61 |   "a *o B = {c. \<exists>b\<in>B. c = a * b}"
 | |
| 25594 | 62 | |
| 38622 | 63 | abbreviation (input) elt_set_eq :: "'a \<Rightarrow> 'a set \<Rightarrow> bool" (infix "=o" 50) where | 
| 64 | "x =o A \<equiv> x \<in> A" | |
| 25594 | 65 | |
| 47443 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 66 | instance set :: (semigroup_add) semigroup_add | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 67 | by default (force simp add: set_plus_def add.assoc) | 
| 25594 | 68 | |
| 47443 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 69 | instance set :: (ab_semigroup_add) ab_semigroup_add | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 70 | by default (force simp add: set_plus_def add.commute) | 
| 25594 | 71 | |
| 47443 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 72 | instance set :: (monoid_add) monoid_add | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 73 | by default (simp_all add: set_plus_def) | 
| 25594 | 74 | |
| 47443 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 75 | instance set :: (comm_monoid_add) comm_monoid_add | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 76 | by default (simp_all add: set_plus_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 77 | |
| 47443 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 78 | instance set :: (semigroup_mult) semigroup_mult | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 79 | by default (force simp add: set_times_def mult.assoc) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 80 | |
| 47443 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 81 | instance set :: (ab_semigroup_mult) ab_semigroup_mult | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 82 | by default (force simp add: set_times_def mult.commute) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 83 | |
| 47443 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 84 | instance set :: (monoid_mult) monoid_mult | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 85 | by default (simp_all add: set_times_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 86 | |
| 47443 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 87 | instance set :: (comm_monoid_mult) comm_monoid_mult | 
| 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
 krauss parents: 
44890diff
changeset | 88 | by default (simp_all add: set_times_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 89 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 90 | lemma set_plus_intro [intro]: "a : C ==> b : D ==> a + b : C + D" | 
| 26814 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 91 | by (auto simp add: set_plus_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 92 | |
| 53596 | 93 | lemma set_plus_elim: | 
| 94 | assumes "x \<in> A + B" | |
| 95 | obtains a b where "x = a + b" and "a \<in> A" and "b \<in> B" | |
| 96 | using assms unfolding set_plus_def by fast | |
| 97 | ||
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 98 | lemma set_plus_intro2 [intro]: "b : C ==> a + b : a +o C" | 
| 19736 | 99 | by (auto simp add: elt_set_plus_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 100 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 101 | lemma set_plus_rearrange: "((a::'a::comm_monoid_add) +o C) + | 
| 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 102 | (b +o D) = (a + b) +o (C + D)" | 
| 26814 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 103 | apply (auto simp add: elt_set_plus_def set_plus_def add_ac) | 
| 19736 | 104 | apply (rule_tac x = "ba + bb" in exI) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 105 | apply (auto simp add: add_ac) | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 106 | apply (rule_tac x = "aa + a" in exI) | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 107 | apply (auto simp add: add_ac) | 
| 19736 | 108 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 109 | |
| 19736 | 110 | lemma set_plus_rearrange2: "(a::'a::semigroup_add) +o (b +o C) = | 
| 111 | (a + b) +o C" | |
| 112 | by (auto simp add: elt_set_plus_def add_assoc) | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 113 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 114 | lemma set_plus_rearrange3: "((a::'a::semigroup_add) +o B) + C = | 
| 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 115 | a +o (B + C)" | 
| 26814 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 116 | apply (auto simp add: elt_set_plus_def set_plus_def) | 
| 19736 | 117 | apply (blast intro: add_ac) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 118 | apply (rule_tac x = "a + aa" in exI) | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 119 | apply (rule conjI) | 
| 19736 | 120 | apply (rule_tac x = "aa" in bexI) | 
| 121 | apply auto | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 122 | apply (rule_tac x = "ba" in bexI) | 
| 19736 | 123 | apply (auto simp add: add_ac) | 
| 124 | done | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 125 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 126 | theorem set_plus_rearrange4: "C + ((a::'a::comm_monoid_add) +o D) = | 
| 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 127 | a +o (C + D)" | 
| 44142 | 128 | apply (auto simp add: elt_set_plus_def set_plus_def add_ac) | 
| 19736 | 129 | apply (rule_tac x = "aa + ba" in exI) | 
| 130 | apply (auto simp add: add_ac) | |
| 131 | done | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 132 | |
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 133 | theorems set_plus_rearranges = set_plus_rearrange set_plus_rearrange2 | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 134 | set_plus_rearrange3 set_plus_rearrange4 | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 135 | |
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 136 | lemma set_plus_mono [intro!]: "C <= D ==> a +o C <= a +o D" | 
| 19736 | 137 | by (auto simp add: elt_set_plus_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 138 | |
| 19736 | 139 | lemma set_plus_mono2 [intro]: "(C::('a::plus) set) <= D ==> E <= F ==>
 | 
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 140 | C + E <= D + F" | 
| 26814 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 141 | by (auto simp add: set_plus_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 142 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 143 | lemma set_plus_mono3 [intro]: "a : C ==> a +o D <= C + D" | 
| 26814 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 144 | by (auto simp add: elt_set_plus_def set_plus_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 145 | |
| 19736 | 146 | lemma set_plus_mono4 [intro]: "(a::'a::comm_monoid_add) : C ==> | 
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 147 | a +o D <= D + C" | 
| 26814 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 148 | by (auto simp add: elt_set_plus_def set_plus_def add_ac) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 149 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 150 | lemma set_plus_mono5: "a:C ==> B <= D ==> a +o B <= C + D" | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 151 | apply (subgoal_tac "a +o B <= a +o D") | 
| 19736 | 152 | apply (erule order_trans) | 
| 153 | apply (erule set_plus_mono3) | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 154 | apply (erule set_plus_mono) | 
| 19736 | 155 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 156 | |
| 19736 | 157 | lemma set_plus_mono_b: "C <= D ==> x : a +o C | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 158 | ==> x : a +o D" | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 159 | apply (frule set_plus_mono) | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 160 | apply auto | 
| 19736 | 161 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 162 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 163 | lemma set_plus_mono2_b: "C <= D ==> E <= F ==> x : C + E ==> | 
| 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 164 | x : D + F" | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 165 | apply (frule set_plus_mono2) | 
| 19736 | 166 | prefer 2 | 
| 167 | apply force | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 168 | apply assumption | 
| 19736 | 169 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 170 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 171 | lemma set_plus_mono3_b: "a : C ==> x : a +o D ==> x : C + D" | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 172 | apply (frule set_plus_mono3) | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 173 | apply auto | 
| 19736 | 174 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 175 | |
| 19736 | 176 | lemma set_plus_mono4_b: "(a::'a::comm_monoid_add) : C ==> | 
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 177 | x : a +o D ==> x : D + C" | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 178 | apply (frule set_plus_mono4) | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 179 | apply auto | 
| 19736 | 180 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 181 | |
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 182 | lemma set_zero_plus [simp]: "(0::'a::comm_monoid_add) +o C = C" | 
| 19736 | 183 | by (auto simp add: elt_set_plus_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 184 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 185 | lemma set_zero_plus2: "(0::'a::comm_monoid_add) : A ==> B <= A + B" | 
| 44142 | 186 | apply (auto simp add: set_plus_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 187 | apply (rule_tac x = 0 in bexI) | 
| 19736 | 188 | apply (rule_tac x = x in bexI) | 
| 189 | apply (auto simp add: add_ac) | |
| 190 | done | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 191 | |
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 192 | lemma set_plus_imp_minus: "(a::'a::ab_group_add) : b +o C ==> (a - b) : C" | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53596diff
changeset | 193 | by (auto simp add: elt_set_plus_def add_ac) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 194 | |
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 195 | lemma set_minus_imp_plus: "(a::'a::ab_group_add) - b : C ==> a : b +o C" | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53596diff
changeset | 196 | apply (auto simp add: elt_set_plus_def add_ac) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 197 | apply (subgoal_tac "a = (a + - b) + b") | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53596diff
changeset | 198 | apply (rule bexI, assumption) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 199 | apply (auto simp add: add_ac) | 
| 19736 | 200 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 201 | |
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 202 | lemma set_minus_plus: "((a::'a::ab_group_add) - b : C) = (a : b +o C)" | 
| 19736 | 203 | by (rule iffI, rule set_minus_imp_plus, assumption, rule set_plus_imp_minus, | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 204 | assumption) | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 205 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 206 | lemma set_times_intro [intro]: "a : C ==> b : D ==> a * b : C * D" | 
| 26814 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 207 | by (auto simp add: set_times_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 208 | |
| 53596 | 209 | lemma set_times_elim: | 
| 210 | assumes "x \<in> A * B" | |
| 211 | obtains a b where "x = a * b" and "a \<in> A" and "b \<in> B" | |
| 212 | using assms unfolding set_times_def by fast | |
| 213 | ||
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 214 | lemma set_times_intro2 [intro!]: "b : C ==> a * b : a *o C" | 
| 19736 | 215 | by (auto simp add: elt_set_times_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 216 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 217 | lemma set_times_rearrange: "((a::'a::comm_monoid_mult) *o C) * | 
| 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 218 | (b *o D) = (a * b) *o (C * D)" | 
| 26814 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 219 | apply (auto simp add: elt_set_times_def set_times_def) | 
| 19736 | 220 | apply (rule_tac x = "ba * bb" in exI) | 
| 221 | apply (auto simp add: mult_ac) | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 222 | apply (rule_tac x = "aa * a" in exI) | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 223 | apply (auto simp add: mult_ac) | 
| 19736 | 224 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 225 | |
| 19736 | 226 | lemma set_times_rearrange2: "(a::'a::semigroup_mult) *o (b *o C) = | 
| 227 | (a * b) *o C" | |
| 228 | by (auto simp add: elt_set_times_def mult_assoc) | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 229 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 230 | lemma set_times_rearrange3: "((a::'a::semigroup_mult) *o B) * C = | 
| 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 231 | a *o (B * C)" | 
| 26814 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 232 | apply (auto simp add: elt_set_times_def set_times_def) | 
| 19736 | 233 | apply (blast intro: mult_ac) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 234 | apply (rule_tac x = "a * aa" in exI) | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 235 | apply (rule conjI) | 
| 19736 | 236 | apply (rule_tac x = "aa" in bexI) | 
| 237 | apply auto | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 238 | apply (rule_tac x = "ba" in bexI) | 
| 19736 | 239 | apply (auto simp add: mult_ac) | 
| 240 | done | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 241 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 242 | theorem set_times_rearrange4: "C * ((a::'a::comm_monoid_mult) *o D) = | 
| 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 243 | a *o (C * D)" | 
| 44142 | 244 | apply (auto simp add: elt_set_times_def set_times_def | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 245 | mult_ac) | 
| 19736 | 246 | apply (rule_tac x = "aa * ba" in exI) | 
| 247 | apply (auto simp add: mult_ac) | |
| 248 | done | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 249 | |
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 250 | theorems set_times_rearranges = set_times_rearrange set_times_rearrange2 | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 251 | set_times_rearrange3 set_times_rearrange4 | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 252 | |
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 253 | lemma set_times_mono [intro]: "C <= D ==> a *o C <= a *o D" | 
| 19736 | 254 | by (auto simp add: elt_set_times_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 255 | |
| 19736 | 256 | lemma set_times_mono2 [intro]: "(C::('a::times) set) <= D ==> E <= F ==>
 | 
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 257 | C * E <= D * F" | 
| 26814 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 258 | by (auto simp add: set_times_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 259 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 260 | lemma set_times_mono3 [intro]: "a : C ==> a *o D <= C * D" | 
| 26814 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 261 | by (auto simp add: elt_set_times_def set_times_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 262 | |
| 19736 | 263 | lemma set_times_mono4 [intro]: "(a::'a::comm_monoid_mult) : C ==> | 
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 264 | a *o D <= D * C" | 
| 26814 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 265 | by (auto simp add: elt_set_times_def set_times_def mult_ac) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 266 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 267 | lemma set_times_mono5: "a:C ==> B <= D ==> a *o B <= C * D" | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 268 | apply (subgoal_tac "a *o B <= a *o D") | 
| 19736 | 269 | apply (erule order_trans) | 
| 270 | apply (erule set_times_mono3) | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 271 | apply (erule set_times_mono) | 
| 19736 | 272 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 273 | |
| 19736 | 274 | lemma set_times_mono_b: "C <= D ==> x : a *o C | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 275 | ==> x : a *o D" | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 276 | apply (frule set_times_mono) | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 277 | apply auto | 
| 19736 | 278 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 279 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 280 | lemma set_times_mono2_b: "C <= D ==> E <= F ==> x : C * E ==> | 
| 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 281 | x : D * F" | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 282 | apply (frule set_times_mono2) | 
| 19736 | 283 | prefer 2 | 
| 284 | apply force | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 285 | apply assumption | 
| 19736 | 286 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 287 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 288 | lemma set_times_mono3_b: "a : C ==> x : a *o D ==> x : C * D" | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 289 | apply (frule set_times_mono3) | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 290 | apply auto | 
| 19736 | 291 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 292 | |
| 19736 | 293 | lemma set_times_mono4_b: "(a::'a::comm_monoid_mult) : C ==> | 
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 294 | x : a *o D ==> x : D * C" | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 295 | apply (frule set_times_mono4) | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 296 | apply auto | 
| 19736 | 297 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 298 | |
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 299 | lemma set_one_times [simp]: "(1::'a::comm_monoid_mult) *o C = C" | 
| 19736 | 300 | by (auto simp add: elt_set_times_def) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 301 | |
| 19736 | 302 | lemma set_times_plus_distrib: "(a::'a::semiring) *o (b +o C)= | 
| 303 | (a * b) +o (a *o C)" | |
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
21404diff
changeset | 304 | by (auto simp add: elt_set_plus_def elt_set_times_def ring_distribs) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 305 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 306 | lemma set_times_plus_distrib2: "(a::'a::semiring) *o (B + C) = | 
| 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 307 | (a *o B) + (a *o C)" | 
| 26814 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 308 | apply (auto simp add: set_plus_def elt_set_times_def ring_distribs) | 
| 19736 | 309 | apply blast | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 310 | apply (rule_tac x = "b + bb" in exI) | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
21404diff
changeset | 311 | apply (auto simp add: ring_distribs) | 
| 19736 | 312 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 313 | |
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 314 | lemma set_times_plus_distrib3: "((a::'a::semiring) +o C) * D <= | 
| 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 315 | a *o D + C * D" | 
| 44142 | 316 | apply (auto simp add: | 
| 26814 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 317 | elt_set_plus_def elt_set_times_def set_times_def | 
| 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 berghofe parents: 
25764diff
changeset | 318 | set_plus_def ring_distribs) | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 319 | apply auto | 
| 19736 | 320 | done | 
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 321 | |
| 19380 | 322 | theorems set_times_plus_distribs = | 
| 323 | set_times_plus_distrib | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 324 | set_times_plus_distrib2 | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 325 | |
| 19736 | 326 | lemma set_neg_intro: "(a::'a::ring_1) : (- 1) *o C ==> | 
| 327 | - a : C" | |
| 328 | by (auto simp add: elt_set_times_def) | |
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 329 | |
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 330 | lemma set_neg_intro2: "(a::'a::ring_1) : C ==> | 
| 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 331 | - a : (- 1) *o C" | 
| 19736 | 332 | by (auto simp add: elt_set_times_def) | 
| 333 | ||
| 53596 | 334 | lemma set_plus_image: "S + T = (\<lambda>(x, y). x + y) ` (S \<times> T)" | 
| 44890 
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
 nipkow parents: 
44142diff
changeset | 335 | unfolding set_plus_def by (fastforce simp: image_iff) | 
| 40887 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 336 | |
| 53596 | 337 | lemma set_times_image: "S * T = (\<lambda>(x, y). x * y) ` (S \<times> T)" | 
| 338 | unfolding set_times_def by (fastforce simp: image_iff) | |
| 339 | ||
| 340 | lemma finite_set_plus: | |
| 341 | assumes "finite s" and "finite t" shows "finite (s + t)" | |
| 342 | using assms unfolding set_plus_image by simp | |
| 343 | ||
| 344 | lemma finite_set_times: | |
| 345 | assumes "finite s" and "finite t" shows "finite (s * t)" | |
| 346 | using assms unfolding set_times_image by simp | |
| 347 | ||
| 40887 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 348 | lemma set_setsum_alt: | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 349 | assumes fin: "finite I" | 
| 47444 
d21c95af2df7
removed "setsum_set", now subsumed by generic setsum
 krauss parents: 
47443diff
changeset | 350 |   shows "setsum S I = {setsum s I |s. \<forall>i\<in>I. s i \<in> S i}"
 | 
| 40887 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 351 | (is "_ = ?setsum I") | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 352 | using fin proof induct | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 353 | case (insert x F) | 
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 354 | have "setsum S (insert x F) = S x + ?setsum F" | 
| 40887 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 355 | using insert.hyps by auto | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 356 |   also have "...= {s x + setsum s F |s. \<forall> i\<in>insert x F. s i \<in> S i}"
 | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 357 | unfolding set_plus_def | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 358 | proof safe | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 359 | fix y s assume "y \<in> S x" "\<forall>i\<in>F. s i \<in> S i" | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 360 | then show "\<exists>s'. y + setsum s F = s' x + setsum s' F \<and> (\<forall>i\<in>insert x F. s' i \<in> S i)" | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 361 | using insert.hyps | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 362 | by (intro exI[of _ "\<lambda>i. if i \<in> F then s i else y"]) (auto simp add: set_plus_def) | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 363 | qed auto | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 364 | finally show ?case | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 365 | using insert.hyps by auto | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 366 | qed auto | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 367 | |
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 368 | lemma setsum_set_cond_linear: | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 369 |   fixes f :: "('a::comm_monoid_add) set \<Rightarrow> ('b::comm_monoid_add) set"
 | 
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 370 |   assumes [intro!]: "\<And>A B. P A  \<Longrightarrow> P B  \<Longrightarrow> P (A + B)" "P {0}"
 | 
| 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 371 |     and f: "\<And>A B. P A  \<Longrightarrow> P B \<Longrightarrow> f (A + B) = f A + f B" "f {0} = {0}"
 | 
| 40887 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 372 | assumes all: "\<And>i. i \<in> I \<Longrightarrow> P (S i)" | 
| 47444 
d21c95af2df7
removed "setsum_set", now subsumed by generic setsum
 krauss parents: 
47443diff
changeset | 373 | shows "f (setsum S I) = setsum (f \<circ> S) I" | 
| 40887 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 374 | proof cases | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 375 | assume "finite I" from this all show ?thesis | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 376 | proof induct | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 377 | case (insert x F) | 
| 47444 
d21c95af2df7
removed "setsum_set", now subsumed by generic setsum
 krauss parents: 
47443diff
changeset | 378 | from `finite F` `\<And>i. i \<in> insert x F \<Longrightarrow> P (S i)` have "P (setsum S F)" | 
| 40887 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 379 | by induct auto | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 380 | with insert show ?case | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 381 | by (simp, subst f) auto | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 382 | qed (auto intro!: f) | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 383 | qed (auto intro!: f) | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 384 | |
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 385 | lemma setsum_set_linear: | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 386 |   fixes f :: "('a::comm_monoid_add) set => ('b::comm_monoid_add) set"
 | 
| 47445 
69e96e5500df
Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
 krauss parents: 
47444diff
changeset | 387 |   assumes "\<And>A B. f(A) + f(B) = f(A + B)" "f {0} = {0}"
 | 
| 47444 
d21c95af2df7
removed "setsum_set", now subsumed by generic setsum
 krauss parents: 
47443diff
changeset | 388 | shows "f (setsum S I) = setsum (f \<circ> S) I" | 
| 40887 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 389 | using setsum_set_cond_linear[of "\<lambda>x. True" f I S] assms by auto | 
| 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
 hoelzl parents: 
39302diff
changeset | 390 | |
| 47446 | 391 | lemma set_times_Un_distrib: | 
| 392 | "A * (B \<union> C) = A * B \<union> A * C" | |
| 393 | "(A \<union> B) * C = A * C \<union> B * C" | |
| 394 | by (auto simp: set_times_def) | |
| 395 | ||
| 396 | lemma set_times_UNION_distrib: | |
| 397 | "A * UNION I M = UNION I (%i. A * M i)" | |
| 398 | "UNION I M * A = UNION I (%i. M i * A)" | |
| 399 | by (auto simp: set_times_def) | |
| 400 | ||
| 16908 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 avigad parents: diff
changeset | 401 | end |