author  krauss 
Thu, 12 Apr 2012 19:58:59 +0200  
changeset 47443  aeff49a3369b 
parent 44890  22f665a2e91c 
child 47444  d21c95af2df7 
permissions  rwrr 
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:
44890
diff
changeset

17 
instantiation set :: (plus) plus 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

18 
begin 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

19 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
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:
44890
diff
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:
44890
diff
changeset

22 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

23 
instance .. 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

24 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

25 
end 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

26 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

27 
instantiation set :: (times) times 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

28 
begin 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

29 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
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:
44890
diff
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:
44890
diff
changeset

32 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

33 
instance .. 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

34 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

35 
end 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

36 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

37 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

38 
text {* Legacy syntax: *} 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

39 

47443
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

40 
abbreviation (input) set_plus :: "'a::plus set \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixl "\<oplus>" 65) where 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

41 
"A \<oplus> B \<equiv> A + B" 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

42 
abbreviation (input) set_times :: "'a::times set \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixl "\<otimes>" 70) where 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

43 
"A \<otimes> B \<equiv> A * B" 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

44 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

45 
instantiation set :: (zero) zero 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

46 
begin 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

47 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

48 
definition 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

49 
set_zero[simp]: "0::('a::zero)set == {0}" 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

50 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

51 
instance .. 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

52 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

53 
end 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

54 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

55 
instantiation set :: (one) one 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

56 
begin 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

57 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

58 
definition 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

59 
set_one[simp]: "1::('a::one)set == {1}" 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

60 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

61 
instance .. 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

62 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

63 
end 
25594  64 

38622  65 
definition elt_set_plus :: "'a::plus \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixl "+o" 70) where 
66 
"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

67 

38622  68 
definition elt_set_times :: "'a::times \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixl "*o" 80) where 
69 
"a *o B = {c. \<exists>b\<in>B. c = a * b}" 

25594  70 

38622  71 
abbreviation (input) elt_set_eq :: "'a \<Rightarrow> 'a set \<Rightarrow> bool" (infix "=o" 50) where 
72 
"x =o A \<equiv> x \<in> A" 

25594  73 

47443
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

74 
instance set :: (semigroup_add) semigroup_add 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

75 
by default (force simp add: set_plus_def add.assoc) 
25594  76 

47443
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

77 
instance set :: (ab_semigroup_add) ab_semigroup_add 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

78 
by default (force simp add: set_plus_def add.commute) 
25594  79 

47443
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

80 
instance set :: (monoid_add) monoid_add 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

81 
by default (simp_all add: set_plus_def) 
25594  82 

47443
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

83 
instance set :: (comm_monoid_add) comm_monoid_add 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

84 
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

85 

47443
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

86 
instance set :: (semigroup_mult) semigroup_mult 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

87 
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

88 

47443
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

89 
instance set :: (ab_semigroup_mult) ab_semigroup_mult 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

90 
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

91 

47443
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

92 
instance set :: (monoid_mult) monoid_mult 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

93 
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

94 

47443
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

95 
instance set :: (comm_monoid_mult) comm_monoid_mult 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

96 
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

97 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

98 
lemma set_plus_intro [intro]: "a : C ==> b : D ==> a + b : C \<oplus> D" 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

99 
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

100 

d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

101 
lemma set_plus_intro2 [intro]: "b : C ==> a + b : a +o C" 
19736  102 
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

103 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

104 
lemma set_plus_rearrange: "((a::'a::comm_monoid_add) +o C) \<oplus> 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

105 
(b +o D) = (a + b) +o (C \<oplus> D)" 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

106 
apply (auto simp add: elt_set_plus_def set_plus_def add_ac) 
19736  107 
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

108 
apply (auto simp add: add_ac) 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

109 
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

110 
apply (auto simp add: add_ac) 
19736  111 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

112 

19736  113 
lemma set_plus_rearrange2: "(a::'a::semigroup_add) +o (b +o C) = 
114 
(a + b) +o C" 

115 
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

116 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

117 
lemma set_plus_rearrange3: "((a::'a::semigroup_add) +o B) \<oplus> C = 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

118 
a +o (B \<oplus> C)" 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

119 
apply (auto simp add: elt_set_plus_def set_plus_def) 
19736  120 
apply (blast intro: add_ac) 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

121 
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

122 
apply (rule conjI) 
19736  123 
apply (rule_tac x = "aa" in bexI) 
124 
apply auto 

16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

125 
apply (rule_tac x = "ba" in bexI) 
19736  126 
apply (auto simp add: add_ac) 
127 
done 

16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

128 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

129 
theorem set_plus_rearrange4: "C \<oplus> ((a::'a::comm_monoid_add) +o D) = 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

130 
a +o (C \<oplus> D)" 
44142  131 
apply (auto simp add: elt_set_plus_def set_plus_def add_ac) 
19736  132 
apply (rule_tac x = "aa + ba" in exI) 
133 
apply (auto simp add: add_ac) 

134 
done 

16908
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 
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

137 
set_plus_rearrange3 set_plus_rearrange4 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

138 

d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

139 
lemma set_plus_mono [intro!]: "C <= D ==> a +o C <= a +o D" 
19736  140 
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

141 

19736  142 
lemma set_plus_mono2 [intro]: "(C::('a::plus) set) <= D ==> E <= F ==> 
26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

143 
C \<oplus> E <= D \<oplus> F" 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

144 
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

145 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

146 
lemma set_plus_mono3 [intro]: "a : C ==> a +o D <= C \<oplus> D" 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

147 
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

148 

19736  149 
lemma set_plus_mono4 [intro]: "(a::'a::comm_monoid_add) : C ==> 
26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

150 
a +o D <= D \<oplus> C" 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

151 
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

152 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

153 
lemma set_plus_mono5: "a:C ==> B <= D ==> a +o B <= C \<oplus> D" 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

154 
apply (subgoal_tac "a +o B <= a +o D") 
19736  155 
apply (erule order_trans) 
156 
apply (erule set_plus_mono3) 

16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

157 
apply (erule set_plus_mono) 
19736  158 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

159 

19736  160 
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

161 
==> x : a +o D" 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

162 
apply (frule set_plus_mono) 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

163 
apply auto 
19736  164 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

165 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

166 
lemma set_plus_mono2_b: "C <= D ==> E <= F ==> x : C \<oplus> E ==> 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

167 
x : D \<oplus> F" 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

168 
apply (frule set_plus_mono2) 
19736  169 
prefer 2 
170 
apply force 

16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

171 
apply assumption 
19736  172 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

173 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

174 
lemma set_plus_mono3_b: "a : C ==> x : a +o D ==> x : C \<oplus> D" 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

175 
apply (frule set_plus_mono3) 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

176 
apply auto 
19736  177 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

178 

19736  179 
lemma set_plus_mono4_b: "(a::'a::comm_monoid_add) : C ==> 
26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

180 
x : a +o D ==> x : D \<oplus> C" 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

181 
apply (frule set_plus_mono4) 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

182 
apply auto 
19736  183 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

184 

d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

185 
lemma set_zero_plus [simp]: "(0::'a::comm_monoid_add) +o C = C" 
19736  186 
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

187 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

188 
lemma set_zero_plus2: "(0::'a::comm_monoid_add) : A ==> B <= A \<oplus> B" 
44142  189 
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

190 
apply (rule_tac x = 0 in bexI) 
19736  191 
apply (rule_tac x = x in bexI) 
192 
apply (auto simp add: add_ac) 

193 
done 

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_plus_imp_minus: "(a::'a::ab_group_add) : b +o C ==> (a  b) : C" 
19736  196 
by (auto simp add: elt_set_plus_def add_ac diff_minus) 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

197 

d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

198 
lemma set_minus_imp_plus: "(a::'a::ab_group_add)  b : C ==> a : b +o C" 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

199 
apply (auto simp add: elt_set_plus_def add_ac diff_minus) 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

200 
apply (subgoal_tac "a = (a +  b) + b") 
19736  201 
apply (rule bexI, assumption, assumption) 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

202 
apply (auto simp add: add_ac) 
19736  203 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

204 

d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

205 
lemma set_minus_plus: "((a::'a::ab_group_add)  b : C) = (a : b +o C)" 
19736  206 
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

207 
assumption) 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

208 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

209 
lemma set_times_intro [intro]: "a : C ==> b : D ==> a * b : C \<otimes> D" 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

210 
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

211 

d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

212 
lemma set_times_intro2 [intro!]: "b : C ==> a * b : a *o C" 
19736  213 
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

214 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

215 
lemma set_times_rearrange: "((a::'a::comm_monoid_mult) *o C) \<otimes> 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

216 
(b *o D) = (a * b) *o (C \<otimes> D)" 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

217 
apply (auto simp add: elt_set_times_def set_times_def) 
19736  218 
apply (rule_tac x = "ba * bb" in exI) 
219 
apply (auto simp add: mult_ac) 

16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

220 
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

221 
apply (auto simp add: mult_ac) 
19736  222 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

223 

19736  224 
lemma set_times_rearrange2: "(a::'a::semigroup_mult) *o (b *o C) = 
225 
(a * b) *o C" 

226 
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

227 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

228 
lemma set_times_rearrange3: "((a::'a::semigroup_mult) *o B) \<otimes> C = 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

229 
a *o (B \<otimes> C)" 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

230 
apply (auto simp add: elt_set_times_def set_times_def) 
19736  231 
apply (blast intro: mult_ac) 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

232 
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

233 
apply (rule conjI) 
19736  234 
apply (rule_tac x = "aa" in bexI) 
235 
apply auto 

16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

236 
apply (rule_tac x = "ba" in bexI) 
19736  237 
apply (auto simp add: mult_ac) 
238 
done 

16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

239 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

240 
theorem set_times_rearrange4: "C \<otimes> ((a::'a::comm_monoid_mult) *o D) = 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

241 
a *o (C \<otimes> D)" 
44142  242 
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

243 
mult_ac) 
19736  244 
apply (rule_tac x = "aa * ba" in exI) 
245 
apply (auto simp add: mult_ac) 

246 
done 

16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

247 

d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

248 
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

249 
set_times_rearrange3 set_times_rearrange4 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

250 

d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

251 
lemma set_times_mono [intro]: "C <= D ==> a *o C <= a *o D" 
19736  252 
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

253 

19736  254 
lemma set_times_mono2 [intro]: "(C::('a::times) set) <= D ==> E <= F ==> 
26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

255 
C \<otimes> E <= D \<otimes> F" 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

256 
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

257 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

258 
lemma set_times_mono3 [intro]: "a : C ==> a *o D <= C \<otimes> D" 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

259 
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

260 

19736  261 
lemma set_times_mono4 [intro]: "(a::'a::comm_monoid_mult) : C ==> 
26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

262 
a *o D <= D \<otimes> C" 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

263 
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

264 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

265 
lemma set_times_mono5: "a:C ==> B <= D ==> a *o B <= C \<otimes> D" 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

266 
apply (subgoal_tac "a *o B <= a *o D") 
19736  267 
apply (erule order_trans) 
268 
apply (erule set_times_mono3) 

16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

269 
apply (erule set_times_mono) 
19736  270 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

271 

19736  272 
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

273 
==> x : a *o D" 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

274 
apply (frule set_times_mono) 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

275 
apply auto 
19736  276 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

277 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

278 
lemma set_times_mono2_b: "C <= D ==> E <= F ==> x : C \<otimes> E ==> 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

279 
x : D \<otimes> F" 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

280 
apply (frule set_times_mono2) 
19736  281 
prefer 2 
282 
apply force 

16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

283 
apply assumption 
19736  284 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

285 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

286 
lemma set_times_mono3_b: "a : C ==> x : a *o D ==> x : C \<otimes> D" 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

287 
apply (frule set_times_mono3) 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

288 
apply auto 
19736  289 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

290 

19736  291 
lemma set_times_mono4_b: "(a::'a::comm_monoid_mult) : C ==> 
26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

292 
x : a *o D ==> x : D \<otimes> C" 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

293 
apply (frule set_times_mono4) 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

294 
apply auto 
19736  295 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

296 

d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

297 
lemma set_one_times [simp]: "(1::'a::comm_monoid_mult) *o C = C" 
19736  298 
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

299 

19736  300 
lemma set_times_plus_distrib: "(a::'a::semiring) *o (b +o C)= 
301 
(a * b) +o (a *o C)" 

23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
21404
diff
changeset

302 
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

303 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

304 
lemma set_times_plus_distrib2: "(a::'a::semiring) *o (B \<oplus> C) = 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

305 
(a *o B) \<oplus> (a *o C)" 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

306 
apply (auto simp add: set_plus_def elt_set_times_def ring_distribs) 
19736  307 
apply blast 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

308 
apply (rule_tac x = "b + bb" in exI) 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
21404
diff
changeset

309 
apply (auto simp add: ring_distribs) 
19736  310 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

311 

26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

312 
lemma set_times_plus_distrib3: "((a::'a::semiring) +o C) \<otimes> D <= 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

313 
a *o D \<oplus> C \<otimes> D" 
44142  314 
apply (auto simp add: 
26814
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
berghofe
parents:
25764
diff
changeset

315 
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:
25764
diff
changeset

316 
set_plus_def ring_distribs) 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

317 
apply auto 
19736  318 
done 
16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

319 

19380  320 
theorems set_times_plus_distribs = 
321 
set_times_plus_distrib 

16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

322 
set_times_plus_distrib2 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

323 

19736  324 
lemma set_neg_intro: "(a::'a::ring_1) : ( 1) *o C ==> 
325 
 a : C" 

326 
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

327 

d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

328 
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

329 
 a : ( 1) *o C" 
19736  330 
by (auto simp add: elt_set_times_def) 
331 

40887
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

332 
lemma set_plus_image: 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

333 
fixes S T :: "'n::semigroup_add set" shows "S \<oplus> T = (\<lambda>(x, y). x + y) ` (S \<times> T)" 
44890
22f665a2e91c
new fastforce replacing fastsimp  less confusing name
nipkow
parents:
44142
diff
changeset

334 
unfolding set_plus_def by (fastforce simp: image_iff) 
40887
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

335 

47443
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

336 
text {* Legacy syntax: *} 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

337 

aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

338 
abbreviation (input) setsum_set :: "('b \<Rightarrow> ('a::comm_monoid_add) set) \<Rightarrow> 'b set \<Rightarrow> 'a set" where 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

339 
"setsum_set == setsum" 
aeff49a3369b
backported Set_Algebras to use type classes (basically reverting b3e8d5ec721d from 2008)
krauss
parents:
44890
diff
changeset

340 

40887
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

341 
lemma set_setsum_alt: 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

342 
assumes fin: "finite I" 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

343 
shows "setsum_set S I = {setsum s I s. \<forall>i\<in>I. s i \<in> S i}" 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

344 
(is "_ = ?setsum I") 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

345 
using fin proof induct 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

346 
case (insert x F) 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

347 
have "setsum_set S (insert x F) = S x \<oplus> ?setsum F" 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

348 
using insert.hyps by auto 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

349 
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:
39302
diff
changeset

350 
unfolding set_plus_def 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

351 
proof safe 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

352 
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:
39302
diff
changeset

353 
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:
39302
diff
changeset

354 
using insert.hyps 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

355 
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:
39302
diff
changeset

356 
qed auto 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

357 
finally show ?case 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

358 
using insert.hyps by auto 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

359 
qed auto 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

360 

ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

361 
lemma setsum_set_cond_linear: 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

362 
fixes f :: "('a::comm_monoid_add) set \<Rightarrow> ('b::comm_monoid_add) set" 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

363 
assumes [intro!]: "\<And>A B. P A \<Longrightarrow> P B \<Longrightarrow> P (A \<oplus> B)" "P {0}" 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

364 
and f: "\<And>A B. P A \<Longrightarrow> P B \<Longrightarrow> f (A \<oplus> B) = f A \<oplus> f B" "f {0} = {0}" 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

365 
assumes all: "\<And>i. i \<in> I \<Longrightarrow> P (S i)" 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

366 
shows "f (setsum_set S I) = setsum_set (f \<circ> S) I" 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

367 
proof cases 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

368 
assume "finite I" from this all show ?thesis 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

369 
proof induct 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

370 
case (insert x F) 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

371 
from `finite F` `\<And>i. i \<in> insert x F \<Longrightarrow> P (S i)` have "P (setsum_set S F)" 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

372 
by induct auto 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

373 
with insert show ?case 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

374 
by (simp, subst f) auto 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

375 
qed (auto intro!: f) 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

376 
qed (auto intro!: f) 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

377 

ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

378 
lemma setsum_set_linear: 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

379 
fixes f :: "('a::comm_monoid_add) set => ('b::comm_monoid_add) set" 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

380 
assumes "\<And>A B. f(A) \<oplus> f(B) = f(A \<oplus> B)" "f {0} = {0}" 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

381 
shows "f (setsum_set S I) = setsum_set (f \<circ> S) I" 
ee8d0548c148
Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents:
39302
diff
changeset

382 
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:
39302
diff
changeset

383 

16908
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
avigad
parents:
diff
changeset

384 
end 