author | paulson |
Mon, 16 Jul 2007 19:18:23 +0200 | |
changeset 23816 | 3879cb3d0ba7 |
parent 23519 | a4ffa756d8eb |
child 24545 | f406a5744756 |
permissions | -rw-r--r-- |
23449 | 1 |
(* Title: HOL/MetisExamples/BigO.thy |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
||
5 |
Testing the metis method |
|
6 |
*) |
|
7 |
||
8 |
header {* Big O notation *} |
|
9 |
||
10 |
theory BigO |
|
11 |
imports SetsAndFunctions |
|
12 |
begin |
|
13 |
||
14 |
subsection {* Definitions *} |
|
15 |
||
16 |
constdefs |
|
17 |
||
18 |
bigo :: "('a => 'b::ordered_idom) => ('a => 'b) set" ("(1O'(_'))") |
|
19 |
"O(f::('a => 'b)) == {h. EX c. ALL x. abs (h x) <= c * abs (f x)}" |
|
20 |
||
21 |
ML{*ResAtp.problem_name := "BigO__bigo_pos_const"*} |
|
22 |
lemma bigo_pos_const: "(EX (c::'a::ordered_idom). |
|
23 |
ALL x. (abs (h x)) <= (c * (abs (f x)))) |
|
24 |
= (EX c. 0 < c & (ALL x. (abs(h x)) <= (c * (abs (f x)))))" |
|
25 |
apply auto |
|
26 |
apply (case_tac "c = 0", simp) |
|
27 |
apply (rule_tac x = "1" in exI, simp) |
|
28 |
apply (rule_tac x = "abs c" in exI, auto); |
|
29 |
txt{*Version 1: one-shot proof. MUCH SLOWER with types: 24 versus 6.7 seconds*} |
|
30 |
apply (metis abs_ge_minus_self abs_ge_zero abs_minus_cancel abs_of_nonneg equation_minus_iff Orderings.xt1(6) abs_le_mult) |
|
31 |
done |
|
32 |
||
33 |
(*** Now various verions with an increasing modulus ***) |
|
34 |
||
35 |
ML{*ResReconstruct.modulus := 1*} |
|
36 |
||
37 |
lemma bigo_pos_const: "(EX (c::'a::ordered_idom). |
|
38 |
ALL x. (abs (h x)) <= (c * (abs (f x)))) |
|
39 |
= (EX c. 0 < c & (ALL x. (abs(h x)) <= (c * (abs (f x)))))" |
|
40 |
apply auto |
|
41 |
apply (case_tac "c = 0", simp) |
|
42 |
apply (rule_tac x = "1" in exI, simp) |
|
43 |
apply (rule_tac x = "abs c" in exI, auto) |
|
44 |
(*hand-modified to give 'a sort ordered_idom and X3 type 'a*) |
|
45 |
proof (neg_clausify) |
|
46 |
fix c x |
|
47 |
assume 0: "\<And>A. \<bar>h A\<bar> \<le> c * \<bar>f A\<bar>" |
|
48 |
assume 1: "c \<noteq> (0\<Colon>'a::ordered_idom)" |
|
49 |
assume 2: "\<not> \<bar>h x\<bar> \<le> \<bar>c\<bar> * \<bar>f x\<bar>" |
|
50 |
have 3: "\<And>X1 X3. \<bar>h X3\<bar> < X1 \<or> \<not> c * \<bar>f X3\<bar> < X1" |
|
51 |
by (metis order_le_less_trans 0) |
|
52 |
have 4: "\<And>X3. (1\<Colon>'a) * X3 \<le> X3 \<or> \<not> (1\<Colon>'a) \<le> (1\<Colon>'a)" |
|
53 |
by (metis mult_le_cancel_right2 order_refl) |
|
54 |
have 5: "\<And>X3. (1\<Colon>'a) * X3 \<le> X3" |
|
55 |
by (metis 4 order_refl) |
|
56 |
have 6: "\<And>X3. \<bar>0\<Colon>'a\<bar> = \<bar>X3\<bar> * (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> (0\<Colon>'a)" |
|
57 |
by (metis abs_mult_pos mult_cancel_right1) |
|
58 |
have 7: "\<bar>0\<Colon>'a\<bar> = (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> (0\<Colon>'a)" |
|
59 |
by (metis 6 mult_cancel_right1) |
|
60 |
have 8: "\<bar>0\<Colon>'a\<bar> = (0\<Colon>'a)" |
|
61 |
by (metis 7 order_refl) |
|
62 |
have 9: "\<not> (0\<Colon>'a) < (0\<Colon>'a)" |
|
63 |
by (metis abs_not_less_zero 8) |
|
64 |
have 10: "\<bar>(1\<Colon>'a) * (0\<Colon>'a)\<bar> = - ((1\<Colon>'a) * (0\<Colon>'a))" |
|
65 |
by (metis abs_of_nonpos 5) |
|
66 |
have 11: "(0\<Colon>'a) = - ((1\<Colon>'a) * (0\<Colon>'a))" |
|
67 |
by (metis 10 mult_cancel_right1 8) |
|
68 |
have 12: "(0\<Colon>'a) = - (0\<Colon>'a)" |
|
69 |
by (metis 11 mult_cancel_right1) |
|
70 |
have 13: "\<And>X3. \<bar>X3\<bar> = X3 \<or> X3 \<le> (0\<Colon>'a)" |
|
71 |
by (metis abs_of_nonneg linorder_linear) |
|
72 |
have 14: "c \<le> (0\<Colon>'a) \<or> \<not> \<bar>h x\<bar> \<le> c * \<bar>f x\<bar>" |
|
73 |
by (metis 2 13) |
|
74 |
have 15: "c \<le> (0\<Colon>'a)" |
|
75 |
by (metis 14 0) |
|
76 |
have 16: "c = (0\<Colon>'a) \<or> c < (0\<Colon>'a)" |
|
77 |
by (metis linorder_antisym_conv2 15) |
|
78 |
have 17: "\<bar>c\<bar> = - c" |
|
79 |
by (metis abs_of_nonpos 15) |
|
80 |
have 18: "c < (0\<Colon>'a)" |
|
81 |
by (metis 16 1) |
|
82 |
have 19: "\<not> \<bar>h x\<bar> \<le> - c * \<bar>f x\<bar>" |
|
83 |
by (metis 2 17) |
|
84 |
have 20: "\<And>X3. X3 * (1\<Colon>'a) = X3" |
|
85 |
by (metis mult_cancel_right1 AC_mult.f.commute) |
|
86 |
have 21: "\<And>X3. (0\<Colon>'a) \<le> X3 * X3" |
|
87 |
by (metis zero_le_square AC_mult.f.commute) |
|
88 |
have 22: "(0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
89 |
by (metis 21 mult_cancel_left1) |
|
90 |
have 23: "\<And>X3. (0\<Colon>'a) = X3 \<or> (0\<Colon>'a) \<noteq> - X3" |
|
91 |
by (metis neg_equal_iff_equal 12) |
|
92 |
have 24: "\<And>X3. (0\<Colon>'a) = - X3 \<or> X3 \<noteq> (0\<Colon>'a)" |
|
93 |
by (metis 23 minus_equation_iff) |
|
94 |
have 25: "\<And>X3. \<bar>0\<Colon>'a\<bar> = \<bar>X3\<bar> \<or> X3 \<noteq> (0\<Colon>'a)" |
|
95 |
by (metis abs_minus_cancel 24) |
|
96 |
have 26: "\<And>X3. (0\<Colon>'a) = \<bar>X3\<bar> \<or> X3 \<noteq> (0\<Colon>'a)" |
|
97 |
by (metis 25 8) |
|
98 |
have 27: "\<And>X1 X3. (0\<Colon>'a) * \<bar>X1\<bar> = \<bar>X3 * X1\<bar> \<or> X3 \<noteq> (0\<Colon>'a)" |
|
99 |
by (metis abs_mult 26) |
|
100 |
have 28: "\<And>X1 X3. (0\<Colon>'a) = \<bar>X3 * X1\<bar> \<or> X3 \<noteq> (0\<Colon>'a)" |
|
101 |
by (metis 27 mult_cancel_left1) |
|
102 |
have 29: "\<And>X1 X3. (0\<Colon>'a) = X3 * X1 \<or> (0\<Colon>'a) < (0\<Colon>'a) \<or> X3 \<noteq> (0\<Colon>'a)" |
|
103 |
by (metis zero_less_abs_iff 28) |
|
104 |
have 30: "\<And>X1 X3. X3 * X1 = (0\<Colon>'a) \<or> X3 \<noteq> (0\<Colon>'a)" |
|
105 |
by (metis 29 9) |
|
106 |
have 31: "\<And>X1 X3. (0\<Colon>'a) = X1 * X3 \<or> X3 \<noteq> (0\<Colon>'a)" |
|
107 |
by (metis AC_mult.f.commute 30) |
|
108 |
have 32: "\<And>X1 X3. (0\<Colon>'a) = \<bar>X3 * X1\<bar> \<or> \<bar>X1\<bar> \<noteq> (0\<Colon>'a)" |
|
109 |
by (metis abs_mult 31) |
|
110 |
have 33: "\<And>X3::'a. \<bar>X3 * X3\<bar> = X3 * X3" |
|
111 |
by (metis abs_mult_self abs_mult AC_mult.f.commute) |
|
112 |
have 34: "\<And>X3. (0\<Colon>'a) \<le> \<bar>X3\<bar> \<or> \<not> (0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
113 |
by (metis abs_ge_zero abs_mult_pos 20) |
|
114 |
have 35: "\<And>X3. (0\<Colon>'a) \<le> \<bar>X3\<bar>" |
|
115 |
by (metis 34 22) |
|
116 |
have 36: "\<And>X3. X3 * (1\<Colon>'a) = (0\<Colon>'a) \<or> \<bar>X3\<bar> \<noteq> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
117 |
by (metis abs_eq_0 abs_mult_pos 20) |
|
118 |
have 37: "\<And>X3. X3 = (0\<Colon>'a) \<or> \<bar>X3\<bar> \<noteq> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
119 |
by (metis 36 20) |
|
120 |
have 38: "\<And>X3. X3 = (0\<Colon>'a) \<or> \<bar>X3\<bar> \<noteq> (0\<Colon>'a)" |
|
121 |
by (metis 37 22) |
|
122 |
have 39: "\<And>X1 X3. X3 * X1 = (0\<Colon>'a) \<or> \<bar>X1\<bar> \<noteq> (0\<Colon>'a)" |
|
123 |
by (metis 38 32) |
|
124 |
have 40: "\<And>X3::'a. \<bar>\<bar>X3\<bar>\<bar> = \<bar>X3\<bar> \<or> \<not> (0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
125 |
by (metis abs_idempotent abs_mult_pos 20) |
|
126 |
have 41: "\<And>X3::'a. \<bar>\<bar>X3\<bar>\<bar> = \<bar>X3\<bar>" |
|
127 |
by (metis 40 22) |
|
128 |
have 42: "\<And>X3. \<not> \<bar>X3\<bar> < (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
129 |
by (metis abs_not_less_zero abs_mult_pos 20) |
|
130 |
have 43: "\<And>X3. \<not> \<bar>X3\<bar> < (0\<Colon>'a)" |
|
131 |
by (metis 42 22) |
|
132 |
have 44: "\<And>X3. X3 * (1\<Colon>'a) = (0\<Colon>'a) \<or> \<not> \<bar>X3\<bar> \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
133 |
by (metis abs_le_zero_iff abs_mult_pos 20) |
|
134 |
have 45: "\<And>X3. X3 = (0\<Colon>'a) \<or> \<not> \<bar>X3\<bar> \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
135 |
by (metis 44 20) |
|
136 |
have 46: "\<And>X3. X3 = (0\<Colon>'a) \<or> \<not> \<bar>X3\<bar> \<le> (0\<Colon>'a)" |
|
137 |
by (metis 45 22) |
|
138 |
have 47: "\<And>X3. X3 * X3 = (0\<Colon>'a) \<or> \<not> X3 * X3 \<le> (0\<Colon>'a)" |
|
139 |
by (metis 46 33) |
|
140 |
have 48: "\<And>X3. X3 * X3 = (0\<Colon>'a) \<or> \<not> X3 \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> X3" |
|
141 |
by (metis 47 mult_le_0_iff) |
|
142 |
have 49: "\<And>X3. \<bar>X3\<bar> = (0\<Colon>'a) \<or> \<not> X3 \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> X3" |
|
143 |
by (metis mult_eq_0_iff abs_mult_self 48) |
|
144 |
have 50: "\<And>X1 X3. |
|
145 |
(0\<Colon>'a) * \<bar>X1\<bar> = \<bar>\<bar>X3 * X1\<bar>\<bar> \<or> |
|
146 |
\<not> (0\<Colon>'a) \<le> \<bar>X1\<bar> \<or> \<not> \<bar>X3\<bar> \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> \<bar>X3\<bar>" |
|
147 |
by (metis abs_mult_pos abs_mult 49) |
|
148 |
have 51: "\<And>X1 X3. X3 * X1 = (0\<Colon>'a) \<or> \<not> X1 \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> X1" |
|
149 |
by (metis 39 49) |
|
150 |
have 52: "\<And>X1 X3. |
|
151 |
(0\<Colon>'a) = \<bar>\<bar>X3 * X1\<bar>\<bar> \<or> |
|
152 |
\<not> (0\<Colon>'a) \<le> \<bar>X1\<bar> \<or> \<not> \<bar>X3\<bar> \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> \<bar>X3\<bar>" |
|
153 |
by (metis 50 mult_cancel_left1) |
|
154 |
have 53: "\<And>X1 X3. |
|
155 |
(0\<Colon>'a) = \<bar>X3 * X1\<bar> \<or> \<not> (0\<Colon>'a) \<le> \<bar>X1\<bar> \<or> \<not> \<bar>X3\<bar> \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> \<bar>X3\<bar>" |
|
156 |
by (metis 52 41) |
|
157 |
have 54: "\<And>X1 X3. (0\<Colon>'a) = \<bar>X3 * X1\<bar> \<or> \<not> \<bar>X3\<bar> \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> \<bar>X3\<bar>" |
|
158 |
by (metis 53 35) |
|
159 |
have 55: "\<And>X1 X3. (0\<Colon>'a) = \<bar>X3 * X1\<bar> \<or> \<not> \<bar>X3\<bar> \<le> (0\<Colon>'a)" |
|
160 |
by (metis 54 35) |
|
161 |
have 56: "\<And>X1 X3. \<bar>X1 * X3\<bar> = (0\<Colon>'a) \<or> \<not> \<bar>X3\<bar> \<le> (0\<Colon>'a)" |
|
162 |
by (metis 55 AC_mult.f.commute) |
|
163 |
have 57: "\<And>X1 X3. X3 * X1 = (0\<Colon>'a) \<or> \<not> \<bar>X1\<bar> \<le> (0\<Colon>'a)" |
|
164 |
by (metis 38 56) |
|
165 |
have 58: "\<And>X3. \<bar>h X3\<bar> \<le> (0\<Colon>'a) \<or> \<not> \<bar>f X3\<bar> \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> \<bar>f X3\<bar>" |
|
166 |
by (metis 0 51) |
|
167 |
have 59: "\<And>X3. \<bar>h X3\<bar> \<le> (0\<Colon>'a) \<or> \<not> \<bar>f X3\<bar> \<le> (0\<Colon>'a)" |
|
168 |
by (metis 58 35) |
|
169 |
have 60: "\<And>X3. \<bar>h X3\<bar> \<le> (0\<Colon>'a) \<or> (0\<Colon>'a) < \<bar>f X3\<bar>" |
|
170 |
by (metis 59 linorder_not_le) |
|
171 |
have 61: "\<And>X1 X3. X3 * X1 = (0\<Colon>'a) \<or> (0\<Colon>'a) < \<bar>X1\<bar>" |
|
172 |
by (metis 57 linorder_not_le) |
|
173 |
have 62: "(0\<Colon>'a) < \<bar>\<bar>f x\<bar>\<bar> \<or> \<not> \<bar>h x\<bar> \<le> (0\<Colon>'a)" |
|
174 |
by (metis 19 61) |
|
175 |
have 63: "(0\<Colon>'a) < \<bar>f x\<bar> \<or> \<not> \<bar>h x\<bar> \<le> (0\<Colon>'a)" |
|
176 |
by (metis 62 41) |
|
177 |
have 64: "(0\<Colon>'a) < \<bar>f x\<bar>" |
|
178 |
by (metis 63 60) |
|
179 |
have 65: "\<And>X3. \<bar>h X3\<bar> < (0\<Colon>'a) \<or> \<not> c < (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) < \<bar>f X3\<bar>" |
|
180 |
by (metis 3 mult_less_0_iff) |
|
181 |
have 66: "\<And>X3. \<bar>h X3\<bar> < (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) < \<bar>f X3\<bar>" |
|
182 |
by (metis 65 18) |
|
183 |
have 67: "\<And>X3. \<not> (0\<Colon>'a) < \<bar>f X3\<bar>" |
|
184 |
by (metis 66 43) |
|
185 |
show "False" |
|
186 |
by (metis 67 64) |
|
187 |
qed |
|
188 |
||
189 |
lemma (*bigo_pos_const:*) "(EX (c::'a::ordered_idom). |
|
190 |
ALL x. (abs (h x)) <= (c * (abs (f x)))) |
|
191 |
= (EX c. 0 < c & (ALL x. (abs(h x)) <= (c * (abs (f x)))))" |
|
192 |
apply auto |
|
193 |
apply (case_tac "c = 0", simp) |
|
194 |
apply (rule_tac x = "1" in exI, simp) |
|
195 |
apply (rule_tac x = "abs c" in exI, auto); |
|
196 |
ML{*ResReconstruct.modulus:=2*} |
|
197 |
proof (neg_clausify) |
|
198 |
fix c x |
|
199 |
assume 0: "\<And>A. \<bar>h A\<bar> \<le> c * \<bar>f A\<bar>" |
|
200 |
assume 1: "c \<noteq> (0\<Colon>'a::ordered_idom)" |
|
201 |
assume 2: "\<not> \<bar>h x\<bar> \<le> \<bar>c\<bar> * \<bar>f x\<bar>" |
|
202 |
have 3: "\<And>X3. (1\<Colon>'a) * X3 \<le> X3" |
|
203 |
by (metis mult_le_cancel_right2 order_refl order_refl) |
|
204 |
have 4: "\<bar>0\<Colon>'a\<bar> = (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> (0\<Colon>'a)" |
|
205 |
by (metis abs_mult_pos mult_cancel_right1 mult_cancel_right1) |
|
206 |
have 5: "\<not> (0\<Colon>'a) < (0\<Colon>'a)" |
|
207 |
by (metis abs_not_less_zero 4 order_refl) |
|
208 |
have 6: "(0\<Colon>'a) = - ((1\<Colon>'a) * (0\<Colon>'a))" |
|
209 |
by (metis abs_of_nonpos 3 mult_cancel_right1 4 order_refl) |
|
210 |
have 7: "\<And>X3. \<bar>X3\<bar> = X3 \<or> X3 \<le> (0\<Colon>'a)" |
|
211 |
by (metis abs_of_nonneg linorder_linear) |
|
212 |
have 8: "c \<le> (0\<Colon>'a)" |
|
213 |
by (metis 2 7 0) |
|
214 |
have 9: "\<bar>c\<bar> = - c" |
|
215 |
by (metis abs_of_nonpos 8) |
|
216 |
have 10: "\<not> \<bar>h x\<bar> \<le> - c * \<bar>f x\<bar>" |
|
217 |
by (metis 2 9) |
|
218 |
have 11: "\<And>X3. X3 * (1\<Colon>'a) = X3" |
|
219 |
by (metis mult_cancel_right1 AC_mult.f.commute) |
|
220 |
have 12: "(0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
221 |
by (metis zero_le_square AC_mult.f.commute mult_cancel_left1) |
|
222 |
have 13: "\<And>X3. (0\<Colon>'a) = - X3 \<or> X3 \<noteq> (0\<Colon>'a)" |
|
223 |
by (metis neg_equal_iff_equal 6 mult_cancel_right1 minus_equation_iff) |
|
224 |
have 14: "\<And>X3. (0\<Colon>'a) = \<bar>X3\<bar> \<or> X3 \<noteq> (0\<Colon>'a)" |
|
225 |
by (metis abs_minus_cancel 13 4 order_refl) |
|
226 |
have 15: "\<And>X1 X3. (0\<Colon>'a) = \<bar>X3 * X1\<bar> \<or> X3 \<noteq> (0\<Colon>'a)" |
|
227 |
by (metis abs_mult 14 mult_cancel_left1) |
|
228 |
have 16: "\<And>X1 X3. X3 * X1 = (0\<Colon>'a) \<or> X3 \<noteq> (0\<Colon>'a)" |
|
229 |
by (metis zero_less_abs_iff 15 5) |
|
230 |
have 17: "\<And>X1 X3. (0\<Colon>'a) = \<bar>X3 * X1\<bar> \<or> \<bar>X1\<bar> \<noteq> (0\<Colon>'a)" |
|
231 |
by (metis abs_mult AC_mult.f.commute 16) |
|
232 |
have 18: "\<And>X3. (0\<Colon>'a) \<le> \<bar>X3\<bar>" |
|
233 |
by (metis abs_ge_zero abs_mult_pos 11 12) |
|
234 |
have 19: "\<And>X3. X3 * (1\<Colon>'a) = (0\<Colon>'a) \<or> \<bar>X3\<bar> \<noteq> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
235 |
by (metis abs_eq_0 abs_mult_pos 11) |
|
236 |
have 20: "\<And>X3. X3 = (0\<Colon>'a) \<or> \<bar>X3\<bar> \<noteq> (0\<Colon>'a)" |
|
237 |
by (metis 19 11 12) |
|
238 |
have 21: "\<And>X3::'a. \<bar>\<bar>X3\<bar>\<bar> = \<bar>X3\<bar> \<or> \<not> (0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
239 |
by (metis abs_idempotent abs_mult_pos 11) |
|
240 |
have 22: "\<And>X3. \<not> \<bar>X3\<bar> < (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
241 |
by (metis abs_not_less_zero abs_mult_pos 11) |
|
242 |
have 23: "\<And>X3. X3 = (0\<Colon>'a) \<or> \<not> \<bar>X3\<bar> \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
243 |
by (metis abs_le_zero_iff abs_mult_pos 11 11) |
|
244 |
have 24: "\<And>X3. X3 * X3 = (0\<Colon>'a) \<or> \<not> X3 * X3 \<le> (0\<Colon>'a)" |
|
245 |
by (metis 23 12 abs_mult_self abs_mult AC_mult.f.commute) |
|
246 |
have 25: "\<And>X3. \<bar>X3\<bar> = (0\<Colon>'a) \<or> \<not> X3 \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> X3" |
|
247 |
by (metis mult_eq_0_iff abs_mult_self 24 mult_le_0_iff) |
|
248 |
have 26: "\<And>X1 X3. X3 * X1 = (0\<Colon>'a) \<or> \<not> X1 \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> X1" |
|
249 |
by (metis 20 17 25) |
|
250 |
have 27: "\<And>X1 X3. |
|
251 |
(0\<Colon>'a) = \<bar>X3 * X1\<bar> \<or> \<not> (0\<Colon>'a) \<le> \<bar>X1\<bar> \<or> \<not> \<bar>X3\<bar> \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> \<bar>X3\<bar>" |
|
252 |
by (metis abs_mult_pos abs_mult 25 mult_cancel_left1 21 12) |
|
253 |
have 28: "\<And>X1 X3. (0\<Colon>'a) = \<bar>X3 * X1\<bar> \<or> \<not> \<bar>X3\<bar> \<le> (0\<Colon>'a)" |
|
254 |
by (metis 27 18 18) |
|
255 |
have 29: "\<And>X1 X3. X3 * X1 = (0\<Colon>'a) \<or> \<not> \<bar>X1\<bar> \<le> (0\<Colon>'a)" |
|
256 |
by (metis 20 28 AC_mult.f.commute) |
|
257 |
have 30: "\<And>X3. \<bar>h X3\<bar> \<le> (0\<Colon>'a) \<or> \<not> \<bar>f X3\<bar> \<le> (0\<Colon>'a)" |
|
258 |
by (metis 0 26 18) |
|
259 |
have 31: "\<And>X1 X3. X3 * X1 = (0\<Colon>'a) \<or> (0\<Colon>'a) < \<bar>X1\<bar>" |
|
260 |
by (metis 29 linorder_not_le) |
|
261 |
have 32: "(0\<Colon>'a) < \<bar>f x\<bar> \<or> \<not> \<bar>h x\<bar> \<le> (0\<Colon>'a)" |
|
262 |
by (metis 10 31 21 12) |
|
263 |
have 33: "\<And>X3. \<bar>h X3\<bar> < (0\<Colon>'a) \<or> \<not> c < (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) < \<bar>f X3\<bar>" |
|
264 |
by (metis order_le_less_trans 0 mult_less_0_iff) |
|
265 |
have 34: "\<And>X3. \<not> (0\<Colon>'a) < \<bar>f X3\<bar>" |
|
266 |
by (metis 33 linorder_antisym_conv2 8 1 22 12) |
|
267 |
show "False" |
|
268 |
by (metis 34 32 30 linorder_not_le) |
|
269 |
qed |
|
270 |
||
271 |
lemma (*bigo_pos_const:*) "(EX (c::'a::ordered_idom). |
|
272 |
ALL x. (abs (h x)) <= (c * (abs (f x)))) |
|
273 |
= (EX c. 0 < c & (ALL x. (abs(h x)) <= (c * (abs (f x)))))" |
|
274 |
apply auto |
|
275 |
apply (case_tac "c = 0", simp) |
|
276 |
apply (rule_tac x = "1" in exI, simp) |
|
277 |
apply (rule_tac x = "abs c" in exI, auto); |
|
278 |
ML{*ResReconstruct.modulus:=3*} |
|
279 |
proof (neg_clausify) |
|
280 |
fix c x |
|
281 |
assume 0: "\<And>A\<Colon>'b\<Colon>type. |
|
282 |
\<bar>(h\<Colon>'b\<Colon>type \<Rightarrow> 'a\<Colon>ordered_idom) A\<bar> |
|
283 |
\<le> (c\<Colon>'a\<Colon>ordered_idom) * \<bar>(f\<Colon>'b\<Colon>type \<Rightarrow> 'a\<Colon>ordered_idom) A\<bar>" |
|
284 |
assume 1: "(c\<Colon>'a\<Colon>ordered_idom) \<noteq> (0\<Colon>'a\<Colon>ordered_idom)" |
|
285 |
assume 2: "\<not> \<bar>(h\<Colon>'b\<Colon>type \<Rightarrow> 'a\<Colon>ordered_idom) (x\<Colon>'b\<Colon>type)\<bar> |
|
286 |
\<le> \<bar>c\<Colon>'a\<Colon>ordered_idom\<bar> * \<bar>(f\<Colon>'b\<Colon>type \<Rightarrow> 'a\<Colon>ordered_idom) x\<bar>" |
|
287 |
have 3: "\<And>X3\<Colon>'a\<Colon>ordered_idom. (1\<Colon>'a\<Colon>ordered_idom) * X3 \<le> X3" |
|
288 |
by (metis mult_le_cancel_right2 order_refl order_refl) |
|
289 |
have 4: "\<bar>0\<Colon>'a\<Colon>ordered_idom\<bar> = (0\<Colon>'a\<Colon>ordered_idom)" |
|
290 |
by (metis abs_mult_pos mult_cancel_right1 mult_cancel_right1 order_refl) |
|
291 |
have 5: "(0\<Colon>'a\<Colon>ordered_idom) = - ((1\<Colon>'a\<Colon>ordered_idom) * (0\<Colon>'a\<Colon>ordered_idom))" |
|
292 |
by (metis abs_of_nonpos 3 mult_cancel_right1 4) |
|
293 |
have 6: "(c\<Colon>'a\<Colon>ordered_idom) \<le> (0\<Colon>'a\<Colon>ordered_idom)" |
|
294 |
by (metis 2 abs_of_nonneg linorder_linear 0) |
|
295 |
have 7: "(c\<Colon>'a\<Colon>ordered_idom) < (0\<Colon>'a\<Colon>ordered_idom)" |
|
296 |
by (metis linorder_antisym_conv2 6 1) |
|
297 |
have 8: "\<And>X3\<Colon>'a\<Colon>ordered_idom. X3 * (1\<Colon>'a\<Colon>ordered_idom) = X3" |
|
298 |
by (metis mult_cancel_right1 AC_mult.f.commute) |
|
299 |
have 9: "\<And>X3\<Colon>'a\<Colon>ordered_idom. (0\<Colon>'a\<Colon>ordered_idom) = X3 \<or> (0\<Colon>'a\<Colon>ordered_idom) \<noteq> - X3" |
|
300 |
by (metis neg_equal_iff_equal 5 mult_cancel_right1) |
|
301 |
have 10: "\<And>X3\<Colon>'a\<Colon>ordered_idom. (0\<Colon>'a\<Colon>ordered_idom) = \<bar>X3\<bar> \<or> X3 \<noteq> (0\<Colon>'a\<Colon>ordered_idom)" |
|
302 |
by (metis abs_minus_cancel 9 minus_equation_iff 4) |
|
303 |
have 11: "\<And>(X1\<Colon>'a\<Colon>ordered_idom) X3\<Colon>'a\<Colon>ordered_idom. |
|
304 |
(0\<Colon>'a\<Colon>ordered_idom) * \<bar>X1\<bar> = \<bar>X3 * X1\<bar> \<or> X3 \<noteq> (0\<Colon>'a\<Colon>ordered_idom)" |
|
305 |
by (metis abs_mult 10) |
|
306 |
have 12: "\<And>(X1\<Colon>'a\<Colon>ordered_idom) X3\<Colon>'a\<Colon>ordered_idom. |
|
307 |
X3 * X1 = (0\<Colon>'a\<Colon>ordered_idom) \<or> X3 \<noteq> (0\<Colon>'a\<Colon>ordered_idom)" |
|
308 |
by (metis zero_less_abs_iff 11 mult_cancel_left1 abs_not_less_zero 4) |
|
309 |
have 13: "\<And>X3\<Colon>'a\<Colon>ordered_idom. \<bar>X3 * X3\<bar> = X3 * X3" |
|
310 |
by (metis abs_mult_self abs_mult AC_mult.f.commute) |
|
311 |
have 14: "\<And>X3\<Colon>'a\<Colon>ordered_idom. (0\<Colon>'a\<Colon>ordered_idom) \<le> \<bar>X3\<bar>" |
|
312 |
by (metis abs_ge_zero abs_mult_pos 8 zero_le_square AC_mult.f.commute mult_cancel_left1) |
|
313 |
have 15: "\<And>X3\<Colon>'a\<Colon>ordered_idom. |
|
314 |
X3 = (0\<Colon>'a\<Colon>ordered_idom) \<or> |
|
315 |
\<bar>X3\<bar> \<noteq> (0\<Colon>'a\<Colon>ordered_idom) \<or> \<not> (0\<Colon>'a\<Colon>ordered_idom) \<le> (1\<Colon>'a\<Colon>ordered_idom)" |
|
316 |
by (metis abs_eq_0 abs_mult_pos 8 8) |
|
317 |
have 16: "\<And>X3\<Colon>'a\<Colon>ordered_idom. |
|
318 |
\<bar>\<bar>X3\<bar>\<bar> = \<bar>X3\<bar> \<or> \<not> (0\<Colon>'a\<Colon>ordered_idom) \<le> (1\<Colon>'a\<Colon>ordered_idom)" |
|
319 |
by (metis abs_idempotent abs_mult_pos 8) |
|
320 |
have 17: "\<And>X3\<Colon>'a\<Colon>ordered_idom. \<not> \<bar>X3\<bar> < (0\<Colon>'a\<Colon>ordered_idom)" |
|
321 |
by (metis abs_not_less_zero abs_mult_pos 8 zero_le_square AC_mult.f.commute mult_cancel_left1) |
|
322 |
have 18: "\<And>X3\<Colon>'a\<Colon>ordered_idom. |
|
323 |
X3 = (0\<Colon>'a\<Colon>ordered_idom) \<or> |
|
324 |
\<not> \<bar>X3\<bar> \<le> (0\<Colon>'a\<Colon>ordered_idom) \<or> |
|
325 |
\<not> (0\<Colon>'a\<Colon>ordered_idom) \<le> (1\<Colon>'a\<Colon>ordered_idom)" |
|
326 |
by (metis abs_le_zero_iff abs_mult_pos 8 8) |
|
327 |
have 19: "\<And>X3\<Colon>'a\<Colon>ordered_idom. |
|
328 |
X3 * X3 = (0\<Colon>'a\<Colon>ordered_idom) \<or> |
|
329 |
\<not> X3 \<le> (0\<Colon>'a\<Colon>ordered_idom) \<or> \<not> (0\<Colon>'a\<Colon>ordered_idom) \<le> X3" |
|
330 |
by (metis 18 zero_le_square AC_mult.f.commute mult_cancel_left1 13 mult_le_0_iff) |
|
331 |
have 20: "\<And>(X1\<Colon>'a\<Colon>ordered_idom) X3\<Colon>'a\<Colon>ordered_idom. |
|
332 |
X3 * X1 = (0\<Colon>'a\<Colon>ordered_idom) \<or> |
|
333 |
\<not> X1 \<le> (0\<Colon>'a\<Colon>ordered_idom) \<or> \<not> (0\<Colon>'a\<Colon>ordered_idom) \<le> X1" |
|
334 |
by (metis 15 zero_le_square AC_mult.f.commute mult_cancel_left1 abs_mult AC_mult.f.commute 12 mult_eq_0_iff abs_mult_self 19) |
|
335 |
have 21: "\<And>(X1\<Colon>'a\<Colon>ordered_idom) X3\<Colon>'a\<Colon>ordered_idom. |
|
336 |
(0\<Colon>'a\<Colon>ordered_idom) = \<bar>X3 * X1\<bar> \<or> |
|
337 |
\<not> \<bar>X3\<bar> \<le> (0\<Colon>'a\<Colon>ordered_idom) \<or> \<not> (0\<Colon>'a\<Colon>ordered_idom) \<le> \<bar>X3\<bar>" |
|
338 |
by (metis abs_mult_pos abs_mult mult_eq_0_iff abs_mult_self 19 mult_cancel_left1 16 zero_le_square AC_mult.f.commute mult_cancel_left1 14) |
|
339 |
have 22: "\<And>(X1\<Colon>'a\<Colon>ordered_idom) X3\<Colon>'a\<Colon>ordered_idom. |
|
340 |
X3 * X1 = (0\<Colon>'a\<Colon>ordered_idom) \<or> \<not> \<bar>X1\<bar> \<le> (0\<Colon>'a\<Colon>ordered_idom)" |
|
341 |
by (metis 15 zero_le_square AC_mult.f.commute mult_cancel_left1 21 14 AC_mult.f.commute) |
|
342 |
have 23: "\<And>X3\<Colon>'b\<Colon>type. |
|
343 |
\<bar>(h\<Colon>'b\<Colon>type \<Rightarrow> 'a\<Colon>ordered_idom) X3\<bar> \<le> (0\<Colon>'a\<Colon>ordered_idom) \<or> |
|
344 |
(0\<Colon>'a\<Colon>ordered_idom) < \<bar>(f\<Colon>'b\<Colon>type \<Rightarrow> 'a\<Colon>ordered_idom) X3\<bar>" |
|
345 |
by (metis 0 20 14 linorder_not_le) |
|
346 |
have 24: "(0\<Colon>'a\<Colon>ordered_idom) < \<bar>(f\<Colon>'b\<Colon>type \<Rightarrow> 'a\<Colon>ordered_idom) (x\<Colon>'b\<Colon>type)\<bar> \<or> |
|
347 |
\<not> \<bar>(h\<Colon>'b\<Colon>type \<Rightarrow> 'a\<Colon>ordered_idom) x\<bar> \<le> (0\<Colon>'a\<Colon>ordered_idom)" |
|
348 |
by (metis 2 abs_of_nonpos 6 22 linorder_not_le 16 zero_le_square AC_mult.f.commute mult_cancel_left1) |
|
349 |
have 25: "\<And>X3\<Colon>'b\<Colon>type. |
|
350 |
\<bar>(h\<Colon>'b\<Colon>type \<Rightarrow> 'a\<Colon>ordered_idom) X3\<bar> < (0\<Colon>'a\<Colon>ordered_idom) \<or> |
|
351 |
\<not> (0\<Colon>'a\<Colon>ordered_idom) < \<bar>(f\<Colon>'b\<Colon>type \<Rightarrow> 'a\<Colon>ordered_idom) X3\<bar>" |
|
352 |
by (metis order_le_less_trans 0 mult_less_0_iff 7) |
|
353 |
show "False" |
|
354 |
by (metis 25 17 24 23) |
|
355 |
qed |
|
356 |
||
357 |
lemma (*bigo_pos_const:*) "(EX (c::'a::ordered_idom). |
|
358 |
ALL x. (abs (h x)) <= (c * (abs (f x)))) |
|
359 |
= (EX c. 0 < c & (ALL x. (abs(h x)) <= (c * (abs (f x)))))" |
|
360 |
apply auto |
|
361 |
apply (case_tac "c = 0", simp) |
|
362 |
apply (rule_tac x = "1" in exI, simp) |
|
363 |
apply (rule_tac x = "abs c" in exI, auto); |
|
364 |
ML{*ResReconstruct.modulus:=4*} |
|
365 |
ML{*ResReconstruct.recon_sorts:=false*} |
|
366 |
proof (neg_clausify) |
|
367 |
fix c x |
|
368 |
assume 0: "\<And>A. \<bar>h A\<bar> \<le> c * \<bar>f A\<bar>" |
|
369 |
assume 1: "c \<noteq> (0\<Colon>'a)" |
|
370 |
assume 2: "\<not> \<bar>h x\<bar> \<le> \<bar>c\<bar> * \<bar>f x\<bar>" |
|
371 |
have 3: "\<And>X3. (1\<Colon>'a) * X3 \<le> X3" |
|
372 |
by (metis mult_le_cancel_right2 order_refl order_refl) |
|
373 |
have 4: "\<not> (0\<Colon>'a) < (0\<Colon>'a)" |
|
374 |
by (metis abs_not_less_zero abs_mult_pos mult_cancel_right1 mult_cancel_right1 order_refl) |
|
375 |
have 5: "c \<le> (0\<Colon>'a)" |
|
376 |
by (metis 2 abs_of_nonneg linorder_linear 0) |
|
377 |
have 6: "\<not> \<bar>h x\<bar> \<le> - c * \<bar>f x\<bar>" |
|
378 |
by (metis 2 abs_of_nonpos 5) |
|
379 |
have 7: "(0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
380 |
by (metis zero_le_square AC_mult.f.commute mult_cancel_left1) |
|
381 |
have 8: "\<And>X3. (0\<Colon>'a) = \<bar>X3\<bar> \<or> X3 \<noteq> (0\<Colon>'a)" |
|
382 |
by (metis abs_minus_cancel neg_equal_iff_equal abs_of_nonpos 3 mult_cancel_right1 abs_mult_pos mult_cancel_right1 mult_cancel_right1 order_refl mult_cancel_right1 minus_equation_iff abs_mult_pos mult_cancel_right1 mult_cancel_right1 order_refl) |
|
383 |
have 9: "\<And>X1 X3. (0\<Colon>'a) = \<bar>X3 * X1\<bar> \<or> X3 \<noteq> (0\<Colon>'a)" |
|
384 |
by (metis abs_mult 8 mult_cancel_left1) |
|
385 |
have 10: "\<And>X1 X3. (0\<Colon>'a) = \<bar>X3 * X1\<bar> \<or> \<bar>X1\<bar> \<noteq> (0\<Colon>'a)" |
|
386 |
by (metis abs_mult AC_mult.f.commute zero_less_abs_iff 9 4) |
|
387 |
have 11: "\<And>X3. (0\<Colon>'a) \<le> \<bar>X3\<bar>" |
|
388 |
by (metis abs_ge_zero abs_mult_pos mult_cancel_right1 AC_mult.f.commute 7) |
|
389 |
have 12: "\<And>X3. X3 = (0\<Colon>'a) \<or> \<bar>X3\<bar> \<noteq> (0\<Colon>'a)" |
|
390 |
by (metis abs_eq_0 abs_mult_pos mult_cancel_right1 AC_mult.f.commute mult_cancel_right1 AC_mult.f.commute 7) |
|
391 |
have 13: "\<And>X3. \<not> \<bar>X3\<bar> < (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
392 |
by (metis abs_not_less_zero abs_mult_pos mult_cancel_right1 AC_mult.f.commute) |
|
393 |
have 14: "\<And>X3. X3 = (0\<Colon>'a) \<or> \<not> \<bar>X3\<bar> \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> (1\<Colon>'a)" |
|
394 |
by (metis abs_le_zero_iff abs_mult_pos mult_cancel_right1 AC_mult.f.commute mult_cancel_right1 AC_mult.f.commute) |
|
395 |
have 15: "\<And>X3. \<bar>X3\<bar> = (0\<Colon>'a) \<or> \<not> X3 \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> X3" |
|
396 |
by (metis mult_eq_0_iff abs_mult_self 14 7 abs_mult_self abs_mult AC_mult.f.commute mult_le_0_iff) |
|
397 |
have 16: "\<And>X1 X3. |
|
398 |
(0\<Colon>'a) = \<bar>X3 * X1\<bar> \<or> \<not> (0\<Colon>'a) \<le> \<bar>X1\<bar> \<or> \<not> \<bar>X3\<bar> \<le> (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) \<le> \<bar>X3\<bar>" |
|
399 |
by (metis abs_mult_pos abs_mult 15 mult_cancel_left1 abs_idempotent abs_mult_pos mult_cancel_right1 AC_mult.f.commute 7) |
|
400 |
have 17: "\<And>X1 X3. X3 * X1 = (0\<Colon>'a) \<or> \<not> \<bar>X1\<bar> \<le> (0\<Colon>'a)" |
|
401 |
by (metis 12 16 11 11 AC_mult.f.commute) |
|
402 |
have 18: "\<And>X1 X3. X3 * X1 = (0\<Colon>'a) \<or> (0\<Colon>'a) < \<bar>X1\<bar>" |
|
403 |
by (metis 17 linorder_not_le) |
|
404 |
have 19: "\<And>X3. \<bar>h X3\<bar> < (0\<Colon>'a) \<or> \<not> c < (0\<Colon>'a) \<or> \<not> (0\<Colon>'a) < \<bar>f X3\<bar>" |
|
405 |
by (metis order_le_less_trans 0 mult_less_0_iff) |
|
406 |
show "False" |
|
407 |
by (metis 19 linorder_antisym_conv2 5 1 13 7 6 18 abs_idempotent abs_mult_pos mult_cancel_right1 AC_mult.f.commute 7 0 12 10 15 11 linorder_not_le) |
|
408 |
qed |
|
409 |
||
410 |
||
411 |
ML{*ResReconstruct.modulus:=1*} |
|
412 |
ML{*ResReconstruct.recon_sorts:=true*} |
|
413 |
||
414 |
lemma bigo_alt_def: "O(f) = |
|
415 |
{h. EX c. (0 < c & (ALL x. abs (h x) <= c * abs (f x)))}" |
|
416 |
by (auto simp add: bigo_def bigo_pos_const) |
|
417 |
||
418 |
ML{*ResAtp.problem_name := "BigO__bigo_elt_subset"*} |
|
419 |
lemma bigo_elt_subset [intro]: "f : O(g) ==> O(f) <= O(g)" |
|
420 |
apply (auto simp add: bigo_alt_def) |
|
421 |
apply (rule_tac x = "ca * c" in exI) |
|
422 |
apply (rule conjI) |
|
423 |
apply (rule mult_pos_pos) |
|
424 |
apply (assumption)+ |
|
425 |
(*sledgehammer*); |
|
426 |
apply (rule allI) |
|
427 |
apply (drule_tac x = "xa" in spec)+ |
|
428 |
apply (subgoal_tac "ca * abs(f xa) <= ca * (c * abs(g xa))"); |
|
429 |
apply (erule order_trans) |
|
430 |
apply (simp add: mult_ac) |
|
431 |
apply (rule mult_left_mono, assumption) |
|
432 |
apply (rule order_less_imp_le, assumption); |
|
433 |
done |
|
434 |
||
435 |
||
436 |
ML{*ResAtp.problem_name := "BigO__bigo_refl"*} |
|
437 |
lemma bigo_refl [intro]: "f : O(f)" |
|
438 |
apply(auto simp add: bigo_def) |
|
439 |
proof (neg_clausify) |
|
440 |
fix x |
|
441 |
assume 0: "\<And>mes_pSG\<Colon>'b\<Colon>ordered_idom. |
|
442 |
\<not> \<bar>(f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) ((x\<Colon>'b\<Colon>ordered_idom \<Rightarrow> 'a) mes_pSG)\<bar> |
|
443 |
\<le> mes_pSG * \<bar>f (x mes_pSG)\<bar>" |
|
444 |
have 1: "\<And>X3\<Colon>'b. X3 \<le> (1\<Colon>'b) * X3 \<or> \<not> (1\<Colon>'b) \<le> (1\<Colon>'b)" |
|
445 |
by (metis Ring_and_Field.mult_le_cancel_right1 order_refl) |
|
446 |
have 2: "\<And>X3\<Colon>'b. X3 \<le> (1\<Colon>'b) * X3" |
|
447 |
by (metis 1 order_refl) |
|
448 |
show 3: "False" |
|
449 |
by (metis 0 2) |
|
450 |
qed |
|
451 |
||
452 |
ML{*ResAtp.problem_name := "BigO__bigo_zero"*} |
|
453 |
lemma bigo_zero: "0 : O(g)" |
|
454 |
apply (auto simp add: bigo_def func_zero) |
|
455 |
proof (neg_clausify) |
|
456 |
fix x |
|
457 |
assume 0: "\<And>mes_mVM\<Colon>'b\<Colon>ordered_idom. |
|
458 |
\<not> (0\<Colon>'b\<Colon>ordered_idom) |
|
459 |
\<le> mes_mVM * |
|
460 |
\<bar>(g\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) |
|
461 |
((x\<Colon>'b\<Colon>ordered_idom \<Rightarrow> 'a) mes_mVM)\<bar>" |
|
462 |
have 1: "(0\<Colon>'b\<Colon>ordered_idom) < (0\<Colon>'b\<Colon>ordered_idom)" |
|
463 |
by (metis 0 Ring_and_Field.mult_le_cancel_left1) |
|
464 |
show 2: "False" |
|
465 |
by (metis Orderings.linorder_class.neq_iff 1) |
|
466 |
qed |
|
467 |
||
468 |
lemma bigo_zero2: "O(%x.0) = {%x.0}" |
|
469 |
apply (auto simp add: bigo_def) |
|
470 |
apply (rule ext) |
|
471 |
apply auto |
|
472 |
done |
|
473 |
||
474 |
lemma bigo_plus_self_subset [intro]: |
|
475 |
"O(f) + O(f) <= O(f)" |
|
476 |
apply (auto simp add: bigo_alt_def set_plus) |
|
477 |
apply (rule_tac x = "c + ca" in exI) |
|
478 |
apply auto |
|
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23464
diff
changeset
|
479 |
apply (simp add: ring_distribs func_plus) |
23449 | 480 |
apply (blast intro:order_trans abs_triangle_ineq add_mono elim:) |
481 |
done |
|
482 |
||
483 |
lemma bigo_plus_idemp [simp]: "O(f) + O(f) = O(f)" |
|
484 |
apply (rule equalityI) |
|
485 |
apply (rule bigo_plus_self_subset) |
|
486 |
apply (rule set_zero_plus2) |
|
487 |
apply (rule bigo_zero) |
|
488 |
done |
|
489 |
||
490 |
lemma bigo_plus_subset [intro]: "O(f + g) <= O(f) + O(g)" |
|
491 |
apply (rule subsetI) |
|
492 |
apply (auto simp add: bigo_def bigo_pos_const func_plus set_plus) |
|
493 |
apply (subst bigo_pos_const [symmetric])+ |
|
494 |
apply (rule_tac x = |
|
495 |
"%n. if abs (g n) <= (abs (f n)) then x n else 0" in exI) |
|
496 |
apply (rule conjI) |
|
497 |
apply (rule_tac x = "c + c" in exI) |
|
498 |
apply (clarsimp) |
|
499 |
apply (auto) |
|
500 |
apply (subgoal_tac "c * abs (f xa + g xa) <= (c + c) * abs (f xa)") |
|
501 |
apply (erule_tac x = xa in allE) |
|
502 |
apply (erule order_trans) |
|
503 |
apply (simp) |
|
504 |
apply (subgoal_tac "c * abs (f xa + g xa) <= c * (abs (f xa) + abs (g xa))") |
|
505 |
apply (erule order_trans) |
|
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23464
diff
changeset
|
506 |
apply (simp add: ring_distribs) |
23449 | 507 |
apply (rule mult_left_mono) |
508 |
apply assumption |
|
509 |
apply (simp add: order_less_le) |
|
510 |
apply (rule mult_left_mono) |
|
511 |
apply (simp add: abs_triangle_ineq) |
|
512 |
apply (simp add: order_less_le) |
|
513 |
apply (rule mult_nonneg_nonneg) |
|
514 |
apply (rule add_nonneg_nonneg) |
|
515 |
apply auto |
|
516 |
apply (rule_tac x = "%n. if (abs (f n)) < abs (g n) then x n else 0" |
|
517 |
in exI) |
|
518 |
apply (rule conjI) |
|
519 |
apply (rule_tac x = "c + c" in exI) |
|
520 |
apply auto |
|
521 |
apply (subgoal_tac "c * abs (f xa + g xa) <= (c + c) * abs (g xa)") |
|
522 |
apply (erule_tac x = xa in allE) |
|
523 |
apply (erule order_trans) |
|
524 |
apply (simp) |
|
525 |
apply (subgoal_tac "c * abs (f xa + g xa) <= c * (abs (f xa) + abs (g xa))") |
|
526 |
apply (erule order_trans) |
|
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23464
diff
changeset
|
527 |
apply (simp add: ring_distribs) |
23449 | 528 |
apply (rule mult_left_mono) |
529 |
apply (simp add: order_less_le) |
|
530 |
apply (simp add: order_less_le) |
|
531 |
apply (rule mult_left_mono) |
|
532 |
apply (rule abs_triangle_ineq) |
|
533 |
apply (simp add: order_less_le) |
|
534 |
apply (rule mult_nonneg_nonneg) |
|
535 |
apply (rule add_nonneg_nonneg) |
|
536 |
apply (erule order_less_imp_le)+ |
|
537 |
apply simp |
|
538 |
apply (rule ext) |
|
539 |
apply (auto simp add: if_splits linorder_not_le) |
|
540 |
done |
|
541 |
||
542 |
lemma bigo_plus_subset2 [intro]: "A <= O(f) ==> B <= O(f) ==> A + B <= O(f)" |
|
543 |
apply (subgoal_tac "A + B <= O(f) + O(f)") |
|
544 |
apply (erule order_trans) |
|
545 |
apply simp |
|
546 |
apply (auto del: subsetI simp del: bigo_plus_idemp) |
|
547 |
done |
|
548 |
||
549 |
ML{*ResAtp.problem_name := "BigO__bigo_plus_eq"*} |
|
550 |
lemma bigo_plus_eq: "ALL x. 0 <= f x ==> ALL x. 0 <= g x ==> |
|
551 |
O(f + g) = O(f) + O(g)" |
|
552 |
apply (rule equalityI) |
|
553 |
apply (rule bigo_plus_subset) |
|
554 |
apply (simp add: bigo_alt_def set_plus func_plus) |
|
555 |
apply clarify |
|
556 |
(*sledgehammer*); |
|
557 |
apply (rule_tac x = "max c ca" in exI) |
|
558 |
apply (rule conjI) |
|
559 |
apply (subgoal_tac "c <= max c ca") |
|
560 |
apply (erule order_less_le_trans) |
|
561 |
apply assumption |
|
562 |
apply (rule le_maxI1) |
|
563 |
apply clarify |
|
564 |
apply (drule_tac x = "xa" in spec)+ |
|
565 |
apply (subgoal_tac "0 <= f xa + g xa") |
|
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23464
diff
changeset
|
566 |
apply (simp add: ring_distribs) |
23449 | 567 |
apply (subgoal_tac "abs(a xa + b xa) <= abs(a xa) + abs(b xa)") |
568 |
apply (subgoal_tac "abs(a xa) + abs(b xa) <= |
|
569 |
max c ca * f xa + max c ca * g xa") |
|
570 |
apply (blast intro: order_trans) |
|
571 |
defer 1 |
|
572 |
apply (rule abs_triangle_ineq) |
|
573 |
apply (rule add_nonneg_nonneg) |
|
574 |
apply assumption+ |
|
575 |
apply (rule add_mono) |
|
576 |
ML{*ResAtp.problem_name := "BigO__bigo_plus_eq_simpler"*} |
|
577 |
(*sledgehammer...fails*); |
|
578 |
apply (subgoal_tac "c * f xa <= max c ca * f xa") |
|
579 |
apply (blast intro: order_trans) |
|
580 |
apply (rule mult_right_mono) |
|
581 |
apply (rule le_maxI1) |
|
582 |
apply assumption |
|
583 |
apply (subgoal_tac "ca * g xa <= max c ca * g xa") |
|
584 |
apply (blast intro: order_trans) |
|
585 |
apply (rule mult_right_mono) |
|
586 |
apply (rule le_maxI2) |
|
587 |
apply assumption |
|
588 |
done |
|
589 |
||
590 |
ML{*ResAtp.problem_name := "BigO__bigo_bounded_alt"*} |
|
591 |
lemma bigo_bounded_alt: "ALL x. 0 <= f x ==> ALL x. f x <= c * g x ==> |
|
592 |
f : O(g)" |
|
593 |
apply (auto simp add: bigo_def) |
|
594 |
(*Version 1: one-shot proof*) |
|
595 |
apply (metis OrderedGroup.abs_ge_self OrderedGroup.abs_le_D1 OrderedGroup.abs_of_nonneg Orderings.linorder_class.not_less order_less_le Orderings.xt1(12) Ring_and_Field.abs_mult) |
|
596 |
done |
|
597 |
||
598 |
lemma bigo_bounded_alt: "ALL x. 0 <= f x ==> ALL x. f x <= c * g x ==> |
|
599 |
f : O(g)" |
|
600 |
apply (auto simp add: bigo_def) |
|
601 |
(*Version 2: single-step proof*) |
|
602 |
proof (neg_clausify) |
|
603 |
fix x |
|
604 |
assume 0: "\<And>mes_mbt\<Colon>'a. |
|
605 |
(f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) mes_mbt |
|
606 |
\<le> (c\<Colon>'b\<Colon>ordered_idom) * (g\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) mes_mbt" |
|
607 |
assume 1: "\<And>mes_mbs\<Colon>'b\<Colon>ordered_idom. |
|
608 |
\<not> (f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) ((x\<Colon>'b\<Colon>ordered_idom \<Rightarrow> 'a) mes_mbs) |
|
609 |
\<le> mes_mbs * \<bar>(g\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) (x mes_mbs)\<bar>" |
|
610 |
have 2: "\<And>X3\<Colon>'a. |
|
611 |
(c\<Colon>'b\<Colon>ordered_idom) * (g\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) X3 = |
|
612 |
(f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) X3 \<or> |
|
613 |
\<not> c * g X3 \<le> f X3" |
|
614 |
by (metis Lattices.min_max.less_eq_less_inf.antisym_intro 0) |
|
615 |
have 3: "\<And>X3\<Colon>'b\<Colon>ordered_idom. |
|
616 |
\<not> (f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) ((x\<Colon>'b\<Colon>ordered_idom \<Rightarrow> 'a) \<bar>X3\<bar>) |
|
617 |
\<le> \<bar>X3 * (g\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) (x \<bar>X3\<bar>)\<bar>" |
|
618 |
by (metis 1 Ring_and_Field.abs_mult) |
|
619 |
have 4: "\<And>X3\<Colon>'b\<Colon>ordered_idom. (1\<Colon>'b\<Colon>ordered_idom) * X3 = X3" |
|
620 |
by (metis Ring_and_Field.mult_cancel_left2 Finite_Set.AC_mult.f.commute) |
|
621 |
have 5: "\<And>X3\<Colon>'b\<Colon>ordered_idom. X3 * (1\<Colon>'b\<Colon>ordered_idom) = X3" |
|
622 |
by (metis Ring_and_Field.mult_cancel_right2 Finite_Set.AC_mult.f.commute) |
|
623 |
have 6: "\<And>X3\<Colon>'b\<Colon>ordered_idom. \<bar>X3\<bar> * \<bar>X3\<bar> = X3 * X3" |
|
624 |
by (metis Ring_and_Field.abs_mult_self Finite_Set.AC_mult.f.commute) |
|
625 |
have 7: "\<And>X3\<Colon>'b\<Colon>ordered_idom. (0\<Colon>'b\<Colon>ordered_idom) \<le> X3 * X3" |
|
626 |
by (metis Ring_and_Field.zero_le_square Finite_Set.AC_mult.f.commute) |
|
627 |
have 8: "(0\<Colon>'b\<Colon>ordered_idom) \<le> (1\<Colon>'b\<Colon>ordered_idom)" |
|
628 |
by (metis 7 Ring_and_Field.mult_cancel_left2) |
|
629 |
have 9: "\<And>X3\<Colon>'b\<Colon>ordered_idom. X3 * X3 = \<bar>X3 * X3\<bar>" |
|
630 |
by (metis Ring_and_Field.abs_mult 6) |
|
631 |
have 10: "\<bar>1\<Colon>'b\<Colon>ordered_idom\<bar> = (1\<Colon>'b\<Colon>ordered_idom)" |
|
632 |
by (metis 9 4) |
|
633 |
have 11: "\<And>X3\<Colon>'b\<Colon>ordered_idom. \<bar>\<bar>X3\<bar>\<bar> = \<bar>X3\<bar> * \<bar>1\<Colon>'b\<Colon>ordered_idom\<bar>" |
|
634 |
by (metis Ring_and_Field.abs_mult OrderedGroup.abs_idempotent 5) |
|
635 |
have 12: "\<And>X3\<Colon>'b\<Colon>ordered_idom. \<bar>\<bar>X3\<bar>\<bar> = \<bar>X3\<bar>" |
|
636 |
by (metis 11 10 5) |
|
637 |
have 13: "\<And>(X1\<Colon>'b\<Colon>ordered_idom) X3\<Colon>'b\<Colon>ordered_idom. |
|
638 |
X3 * (1\<Colon>'b\<Colon>ordered_idom) \<le> X1 \<or> |
|
639 |
\<not> \<bar>X3\<bar> \<le> X1 \<or> \<not> (0\<Colon>'b\<Colon>ordered_idom) \<le> (1\<Colon>'b\<Colon>ordered_idom)" |
|
640 |
by (metis OrderedGroup.abs_le_D1 Ring_and_Field.abs_mult_pos 5) |
|
641 |
have 14: "\<And>(X1\<Colon>'b\<Colon>ordered_idom) X3\<Colon>'b\<Colon>ordered_idom. |
|
642 |
X3 \<le> X1 \<or> \<not> \<bar>X3\<bar> \<le> X1 \<or> \<not> (0\<Colon>'b\<Colon>ordered_idom) \<le> (1\<Colon>'b\<Colon>ordered_idom)" |
|
643 |
by (metis 13 5) |
|
644 |
have 15: "\<And>(X1\<Colon>'b\<Colon>ordered_idom) X3\<Colon>'b\<Colon>ordered_idom. X3 \<le> X1 \<or> \<not> \<bar>X3\<bar> \<le> X1" |
|
645 |
by (metis 14 8) |
|
646 |
have 16: "\<And>(X1\<Colon>'b\<Colon>ordered_idom) X3\<Colon>'b\<Colon>ordered_idom. X3 \<le> X1 \<or> X1 \<le> \<bar>X3\<bar>" |
|
647 |
by (metis 15 Orderings.linorder_class.less_eq_less.linear) |
|
648 |
have 17: "\<And>X3\<Colon>'b\<Colon>ordered_idom. |
|
649 |
X3 * (g\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) ((x\<Colon>'b\<Colon>ordered_idom \<Rightarrow> 'a) \<bar>X3\<bar>) |
|
650 |
\<le> (f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) (x \<bar>X3\<bar>)" |
|
651 |
by (metis 3 16) |
|
652 |
have 18: "(c\<Colon>'b\<Colon>ordered_idom) * |
|
653 |
(g\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) ((x\<Colon>'b\<Colon>ordered_idom \<Rightarrow> 'a) \<bar>c\<bar>) = |
|
654 |
(f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) (x \<bar>c\<bar>)" |
|
655 |
by (metis 2 17) |
|
656 |
have 19: "\<And>(X1\<Colon>'b\<Colon>ordered_idom) X3\<Colon>'b\<Colon>ordered_idom. \<bar>X3 * X1\<bar> \<le> \<bar>\<bar>X3\<bar>\<bar> * \<bar>\<bar>X1\<bar>\<bar>" |
|
657 |
by (metis 15 Ring_and_Field.abs_le_mult Ring_and_Field.abs_mult) |
|
658 |
have 20: "\<And>(X1\<Colon>'b\<Colon>ordered_idom) X3\<Colon>'b\<Colon>ordered_idom. \<bar>X3 * X1\<bar> \<le> \<bar>X3\<bar> * \<bar>X1\<bar>" |
|
659 |
by (metis 19 12 12) |
|
660 |
have 21: "\<And>(X1\<Colon>'b\<Colon>ordered_idom) X3\<Colon>'b\<Colon>ordered_idom. X3 * X1 \<le> \<bar>X3\<bar> * \<bar>X1\<bar>" |
|
661 |
by (metis 15 20) |
|
662 |
have 22: "(f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) |
|
663 |
((x\<Colon>'b\<Colon>ordered_idom \<Rightarrow> 'a) \<bar>c\<Colon>'b\<Colon>ordered_idom\<bar>) |
|
664 |
\<le> \<bar>c\<bar> * \<bar>(g\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) (x \<bar>c\<bar>)\<bar>" |
|
665 |
by (metis 21 18) |
|
666 |
show 23: "False" |
|
667 |
by (metis 22 1) |
|
668 |
qed |
|
669 |
||
670 |
||
671 |
text{*So here is the easier (and more natural) problem using transitivity*} |
|
672 |
ML{*ResAtp.problem_name := "BigO__bigo_bounded_alt_trans"*} |
|
673 |
lemma "ALL x. 0 <= f x ==> ALL x. f x <= c * g x ==> f : O(g)" |
|
674 |
apply (auto simp add: bigo_def) |
|
675 |
(*Version 1: one-shot proof*) |
|
676 |
apply (metis Orderings.leD Orderings.leI abs_ge_self abs_le_D1 abs_mult abs_of_nonneg order_le_less xt1(12)); |
|
677 |
done |
|
678 |
||
679 |
text{*So here is the easier (and more natural) problem using transitivity*} |
|
680 |
ML{*ResAtp.problem_name := "BigO__bigo_bounded_alt_trans"*} |
|
681 |
lemma "ALL x. 0 <= f x ==> ALL x. f x <= c * g x ==> f : O(g)" |
|
682 |
apply (auto simp add: bigo_def) |
|
683 |
(*Version 2: single-step proof*) |
|
684 |
proof (neg_clausify) |
|
685 |
fix x |
|
23519 | 686 |
assume 0: "\<And>A\<Colon>'a\<Colon>type. |
687 |
(f\<Colon>'a\<Colon>type \<Rightarrow> 'b\<Colon>ordered_idom) A |
|
688 |
\<le> (c\<Colon>'b\<Colon>ordered_idom) * (g\<Colon>'a\<Colon>type \<Rightarrow> 'b\<Colon>ordered_idom) A" |
|
689 |
assume 1: "\<And>A\<Colon>'b\<Colon>ordered_idom. |
|
690 |
\<not> (f\<Colon>'a\<Colon>type \<Rightarrow> 'b\<Colon>ordered_idom) ((x\<Colon>'b\<Colon>ordered_idom \<Rightarrow> 'a\<Colon>type) A) |
|
691 |
\<le> A * \<bar>(g\<Colon>'a\<Colon>type \<Rightarrow> 'b\<Colon>ordered_idom) (x A)\<bar>" |
|
692 |
have 2: "\<And>X2\<Colon>'a\<Colon>type. |
|
693 |
\<not> (c\<Colon>'b\<Colon>ordered_idom) * (g\<Colon>'a\<Colon>type \<Rightarrow> 'b\<Colon>ordered_idom) X2 |
|
694 |
< (f\<Colon>'a\<Colon>type \<Rightarrow> 'b\<Colon>ordered_idom) X2" |
|
695 |
by (metis 0 linorder_not_le) |
|
696 |
have 3: "\<And>X2\<Colon>'b\<Colon>ordered_idom. |
|
697 |
\<not> (f\<Colon>'a\<Colon>type \<Rightarrow> 'b\<Colon>ordered_idom) ((x\<Colon>'b\<Colon>ordered_idom \<Rightarrow> 'a\<Colon>type) \<bar>X2\<bar>) |
|
698 |
\<le> \<bar>X2 * (g\<Colon>'a\<Colon>type \<Rightarrow> 'b\<Colon>ordered_idom) (x \<bar>X2\<bar>)\<bar>" |
|
699 |
by (metis abs_mult 1) |
|
700 |
have 4: "\<And>X2\<Colon>'b\<Colon>ordered_idom. |
|
701 |
\<bar>X2 * (g\<Colon>'a\<Colon>type \<Rightarrow> 'b\<Colon>ordered_idom) ((x\<Colon>'b\<Colon>ordered_idom \<Rightarrow> 'a\<Colon>type) \<bar>X2\<bar>)\<bar> |
|
702 |
< (f\<Colon>'a\<Colon>type \<Rightarrow> 'b\<Colon>ordered_idom) (x \<bar>X2\<bar>)" |
|
703 |
by (metis 3 linorder_not_less) |
|
704 |
have 5: "\<And>X2\<Colon>'b\<Colon>ordered_idom. |
|
705 |
X2 * (g\<Colon>'a\<Colon>type \<Rightarrow> 'b\<Colon>ordered_idom) ((x\<Colon>'b\<Colon>ordered_idom \<Rightarrow> 'a\<Colon>type) \<bar>X2\<bar>) |
|
706 |
< (f\<Colon>'a\<Colon>type \<Rightarrow> 'b\<Colon>ordered_idom) (x \<bar>X2\<bar>)" |
|
707 |
by (metis abs_less_iff 4) |
|
708 |
show "False" |
|
709 |
by (metis 2 5) |
|
23449 | 710 |
qed |
711 |
||
712 |
||
713 |
lemma bigo_bounded: "ALL x. 0 <= f x ==> ALL x. f x <= g x ==> |
|
714 |
f : O(g)" |
|
715 |
apply (erule bigo_bounded_alt [of f 1 g]) |
|
716 |
apply simp |
|
717 |
done |
|
718 |
||
719 |
ML{*ResAtp.problem_name := "BigO__bigo_bounded2"*} |
|
720 |
lemma bigo_bounded2: "ALL x. lb x <= f x ==> ALL x. f x <= lb x + g x ==> |
|
721 |
f : lb +o O(g)" |
|
722 |
apply (rule set_minus_imp_plus) |
|
723 |
apply (rule bigo_bounded) |
|
724 |
apply (auto simp add: diff_minus func_minus func_plus) |
|
725 |
prefer 2 |
|
726 |
apply (drule_tac x = x in spec)+ |
|
727 |
apply arith (*not clear that it's provable otherwise*) |
|
728 |
proof (neg_clausify) |
|
729 |
fix x |
|
730 |
assume 0: "\<And>y. lb y \<le> f y" |
|
731 |
assume 1: "\<not> (0\<Colon>'b) \<le> f x + - lb x" |
|
732 |
have 2: "\<And>X3. (0\<Colon>'b) + X3 = X3" |
|
733 |
by (metis diff_eq_eq right_minus_eq) |
|
734 |
have 3: "\<not> (0\<Colon>'b) \<le> f x - lb x" |
|
735 |
by (metis 1 compare_rls(1)) |
|
736 |
have 4: "\<not> (0\<Colon>'b) + lb x \<le> f x" |
|
737 |
by (metis 3 le_diff_eq) |
|
738 |
show "False" |
|
739 |
by (metis 4 2 0) |
|
740 |
qed |
|
741 |
||
742 |
ML{*ResAtp.problem_name := "BigO__bigo_abs"*} |
|
743 |
lemma bigo_abs: "(%x. abs(f x)) =o O(f)" |
|
744 |
apply (unfold bigo_def) |
|
745 |
apply auto |
|
746 |
proof (neg_clausify) |
|
747 |
fix x |
|
748 |
assume 0: "!!mes_o43::'b::ordered_idom. |
|
749 |
~ abs ((f::'a::type => 'b::ordered_idom) |
|
750 |
((x::'b::ordered_idom => 'a::type) mes_o43)) |
|
751 |
<= mes_o43 * abs (f (x mes_o43))" |
|
752 |
have 1: "!!X3::'b::ordered_idom. |
|
753 |
X3 <= (1::'b::ordered_idom) * X3 | |
|
754 |
~ (1::'b::ordered_idom) <= (1::'b::ordered_idom)" |
|
755 |
by (metis mult_le_cancel_right1 order_refl) |
|
756 |
have 2: "!!X3::'b::ordered_idom. X3 <= (1::'b::ordered_idom) * X3" |
|
757 |
by (metis 1 order_refl) |
|
758 |
show "False" |
|
759 |
by (metis 0 2) |
|
760 |
qed |
|
761 |
||
762 |
ML{*ResAtp.problem_name := "BigO__bigo_abs2"*} |
|
763 |
lemma bigo_abs2: "f =o O(%x. abs(f x))" |
|
764 |
apply (unfold bigo_def) |
|
765 |
apply auto |
|
766 |
proof (neg_clausify) |
|
767 |
fix x |
|
768 |
assume 0: "\<And>mes_o4C\<Colon>'b\<Colon>ordered_idom. |
|
769 |
\<not> \<bar>(f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) ((x\<Colon>'b\<Colon>ordered_idom \<Rightarrow> 'a) mes_o4C)\<bar> |
|
770 |
\<le> mes_o4C * \<bar>f (x mes_o4C)\<bar>" |
|
771 |
have 1: "\<And>X3\<Colon>'b\<Colon>ordered_idom. |
|
772 |
X3 \<le> (1\<Colon>'b\<Colon>ordered_idom) * X3 \<or> |
|
773 |
\<not> (1\<Colon>'b\<Colon>ordered_idom) \<le> (1\<Colon>'b\<Colon>ordered_idom)" |
|
774 |
by (metis mult_le_cancel_right1 order_refl) |
|
775 |
have 2: "\<And>X3\<Colon>'b\<Colon>ordered_idom. X3 \<le> (1\<Colon>'b\<Colon>ordered_idom) * X3" |
|
776 |
by (metis 1 order_refl) |
|
777 |
show "False" |
|
778 |
by (metis 0 2) |
|
779 |
qed |
|
780 |
||
781 |
lemma bigo_abs3: "O(f) = O(%x. abs(f x))" |
|
782 |
apply (rule equalityI) |
|
783 |
apply (rule bigo_elt_subset) |
|
784 |
apply (rule bigo_abs2) |
|
785 |
apply (rule bigo_elt_subset) |
|
786 |
apply (rule bigo_abs) |
|
787 |
done |
|
788 |
||
789 |
lemma bigo_abs4: "f =o g +o O(h) ==> |
|
790 |
(%x. abs (f x)) =o (%x. abs (g x)) +o O(h)" |
|
791 |
apply (drule set_plus_imp_minus) |
|
792 |
apply (rule set_minus_imp_plus) |
|
793 |
apply (subst func_diff) |
|
794 |
proof - |
|
795 |
assume a: "f - g : O(h)" |
|
796 |
have "(%x. abs (f x) - abs (g x)) =o O(%x. abs(abs (f x) - abs (g x)))" |
|
797 |
by (rule bigo_abs2) |
|
798 |
also have "... <= O(%x. abs (f x - g x))" |
|
799 |
apply (rule bigo_elt_subset) |
|
800 |
apply (rule bigo_bounded) |
|
801 |
apply force |
|
802 |
apply (rule allI) |
|
803 |
apply (rule abs_triangle_ineq3) |
|
804 |
done |
|
805 |
also have "... <= O(f - g)" |
|
806 |
apply (rule bigo_elt_subset) |
|
807 |
apply (subst func_diff) |
|
808 |
apply (rule bigo_abs) |
|
809 |
done |
|
810 |
also have "... <= O(h)" |
|
23464 | 811 |
using a by (rule bigo_elt_subset) |
23449 | 812 |
finally show "(%x. abs (f x) - abs (g x)) : O(h)". |
813 |
qed |
|
814 |
||
815 |
lemma bigo_abs5: "f =o O(g) ==> (%x. abs(f x)) =o O(g)" |
|
816 |
by (unfold bigo_def, auto) |
|
817 |
||
818 |
lemma bigo_elt_subset2 [intro]: "f : g +o O(h) ==> O(f) <= O(g) + O(h)" |
|
819 |
proof - |
|
820 |
assume "f : g +o O(h)" |
|
821 |
also have "... <= O(g) + O(h)" |
|
822 |
by (auto del: subsetI) |
|
823 |
also have "... = O(%x. abs(g x)) + O(%x. abs(h x))" |
|
824 |
apply (subst bigo_abs3 [symmetric])+ |
|
825 |
apply (rule refl) |
|
826 |
done |
|
827 |
also have "... = O((%x. abs(g x)) + (%x. abs(h x)))" |
|
828 |
by (rule bigo_plus_eq [symmetric], auto) |
|
829 |
finally have "f : ...". |
|
830 |
then have "O(f) <= ..." |
|
831 |
by (elim bigo_elt_subset) |
|
832 |
also have "... = O(%x. abs(g x)) + O(%x. abs(h x))" |
|
833 |
by (rule bigo_plus_eq, auto) |
|
834 |
finally show ?thesis |
|
835 |
by (simp add: bigo_abs3 [symmetric]) |
|
836 |
qed |
|
837 |
||
838 |
ML{*ResAtp.problem_name := "BigO__bigo_mult"*} |
|
839 |
lemma bigo_mult [intro]: "O(f)*O(g) <= O(f * g)" |
|
840 |
apply (rule subsetI) |
|
841 |
apply (subst bigo_def) |
|
842 |
apply (auto simp del: abs_mult mult_ac |
|
843 |
simp add: bigo_alt_def set_times func_times) |
|
844 |
(*sledgehammer*); |
|
845 |
apply (rule_tac x = "c * ca" in exI) |
|
846 |
apply(rule allI) |
|
847 |
apply(erule_tac x = x in allE)+ |
|
848 |
apply(subgoal_tac "c * ca * abs(f x * g x) = |
|
849 |
(c * abs(f x)) * (ca * abs(g x))") |
|
850 |
ML{*ResAtp.problem_name := "BigO__bigo_mult_simpler"*} |
|
851 |
prefer 2 |
|
852 |
apply (metis Finite_Set.AC_mult.f.assoc Finite_Set.AC_mult.f.left_commute OrderedGroup.abs_of_pos OrderedGroup.mult_left_commute Ring_and_Field.abs_mult Ring_and_Field.mult_pos_pos) |
|
853 |
apply(erule ssubst) |
|
854 |
apply (subst abs_mult) |
|
855 |
(*not qute BigO__bigo_mult_simpler_1 (a hard problem!) as abs_mult has |
|
856 |
just been done*) |
|
857 |
proof (neg_clausify) |
|
858 |
fix a c b ca x |
|
859 |
assume 0: "(0\<Colon>'b\<Colon>ordered_idom) < (c\<Colon>'b\<Colon>ordered_idom)" |
|
860 |
assume 1: "\<bar>(a\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) (x\<Colon>'a)\<bar> |
|
861 |
\<le> (c\<Colon>'b\<Colon>ordered_idom) * \<bar>(f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar>" |
|
862 |
assume 2: "\<bar>(b\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) (x\<Colon>'a)\<bar> |
|
863 |
\<le> (ca\<Colon>'b\<Colon>ordered_idom) * \<bar>(g\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar>" |
|
864 |
assume 3: "\<not> \<bar>(a\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) (x\<Colon>'a)\<bar> * |
|
865 |
\<bar>(b\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar> |
|
866 |
\<le> (c\<Colon>'b\<Colon>ordered_idom) * \<bar>(f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar> * |
|
867 |
((ca\<Colon>'b\<Colon>ordered_idom) * \<bar>(g\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar>)" |
|
868 |
have 4: "\<bar>c\<Colon>'b\<Colon>ordered_idom\<bar> = c" |
|
869 |
by (metis OrderedGroup.abs_of_pos 0) |
|
870 |
have 5: "\<And>X1\<Colon>'b\<Colon>ordered_idom. (c\<Colon>'b\<Colon>ordered_idom) * \<bar>X1\<bar> = \<bar>c * X1\<bar>" |
|
871 |
by (metis Ring_and_Field.abs_mult 4) |
|
872 |
have 6: "(0\<Colon>'b\<Colon>ordered_idom) = (1\<Colon>'b\<Colon>ordered_idom) \<or> |
|
873 |
(0\<Colon>'b\<Colon>ordered_idom) < (1\<Colon>'b\<Colon>ordered_idom)" |
|
874 |
by (metis OrderedGroup.abs_not_less_zero Ring_and_Field.abs_one Ring_and_Field.linorder_neqE_ordered_idom) |
|
875 |
have 7: "(0\<Colon>'b\<Colon>ordered_idom) < (1\<Colon>'b\<Colon>ordered_idom)" |
|
876 |
by (metis 6 Ring_and_Field.one_neq_zero) |
|
877 |
have 8: "\<bar>1\<Colon>'b\<Colon>ordered_idom\<bar> = (1\<Colon>'b\<Colon>ordered_idom)" |
|
878 |
by (metis OrderedGroup.abs_of_pos 7) |
|
879 |
have 9: "\<And>X1\<Colon>'b\<Colon>ordered_idom. (0\<Colon>'b\<Colon>ordered_idom) \<le> (c\<Colon>'b\<Colon>ordered_idom) * \<bar>X1\<bar>" |
|
880 |
by (metis OrderedGroup.abs_ge_zero 5) |
|
881 |
have 10: "\<And>X1\<Colon>'b\<Colon>ordered_idom. X1 * (1\<Colon>'b\<Colon>ordered_idom) = X1" |
|
882 |
by (metis Ring_and_Field.mult_cancel_right2 Finite_Set.AC_mult.f.commute) |
|
883 |
have 11: "\<And>X1\<Colon>'b\<Colon>ordered_idom. \<bar>\<bar>X1\<bar>\<bar> = \<bar>X1\<bar> * \<bar>1\<Colon>'b\<Colon>ordered_idom\<bar>" |
|
884 |
by (metis Ring_and_Field.abs_mult OrderedGroup.abs_idempotent 10) |
|
885 |
have 12: "\<And>X1\<Colon>'b\<Colon>ordered_idom. \<bar>\<bar>X1\<bar>\<bar> = \<bar>X1\<bar>" |
|
886 |
by (metis 11 8 10) |
|
887 |
have 13: "\<And>X1\<Colon>'b\<Colon>ordered_idom. (0\<Colon>'b\<Colon>ordered_idom) \<le> \<bar>X1\<bar>" |
|
888 |
by (metis OrderedGroup.abs_ge_zero 12) |
|
889 |
have 14: "\<not> (0\<Colon>'b\<Colon>ordered_idom) |
|
890 |
\<le> (c\<Colon>'b\<Colon>ordered_idom) * \<bar>(f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) (x\<Colon>'a)\<bar> \<or> |
|
891 |
\<not> (0\<Colon>'b\<Colon>ordered_idom) \<le> \<bar>(b\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar> \<or> |
|
892 |
\<not> \<bar>b x\<bar> \<le> (ca\<Colon>'b\<Colon>ordered_idom) * \<bar>(g\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar> \<or> |
|
893 |
\<not> \<bar>(a\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar> \<le> c * \<bar>f x\<bar>" |
|
894 |
by (metis 3 Ring_and_Field.mult_mono) |
|
895 |
have 15: "\<not> (0\<Colon>'b\<Colon>ordered_idom) \<le> \<bar>(b\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) (x\<Colon>'a)\<bar> \<or> |
|
896 |
\<not> \<bar>b x\<bar> \<le> (ca\<Colon>'b\<Colon>ordered_idom) * \<bar>(g\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar> \<or> |
|
897 |
\<not> \<bar>(a\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar> |
|
898 |
\<le> (c\<Colon>'b\<Colon>ordered_idom) * \<bar>(f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar>" |
|
899 |
by (metis 14 9) |
|
900 |
have 16: "\<not> \<bar>(b\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) (x\<Colon>'a)\<bar> |
|
901 |
\<le> (ca\<Colon>'b\<Colon>ordered_idom) * \<bar>(g\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar> \<or> |
|
902 |
\<not> \<bar>(a\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar> |
|
903 |
\<le> (c\<Colon>'b\<Colon>ordered_idom) * \<bar>(f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar>" |
|
904 |
by (metis 15 13) |
|
905 |
have 17: "\<not> \<bar>(a\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) (x\<Colon>'a)\<bar> |
|
906 |
\<le> (c\<Colon>'b\<Colon>ordered_idom) * \<bar>(f\<Colon>'a \<Rightarrow> 'b\<Colon>ordered_idom) x\<bar>" |
|
907 |
by (metis 16 2) |
|
908 |
show 18: "False" |
|
909 |
by (metis 17 1) |
|
910 |
qed |
|
911 |
||
912 |
||
913 |
ML{*ResAtp.problem_name := "BigO__bigo_mult2"*} |
|
914 |
lemma bigo_mult2 [intro]: "f *o O(g) <= O(f * g)" |
|
915 |
apply (auto simp add: bigo_def elt_set_times_def func_times abs_mult) |
|
916 |
(*sledgehammer*); |
|
917 |
apply (rule_tac x = c in exI) |
|
918 |
apply clarify |
|
919 |
apply (drule_tac x = x in spec) |
|
920 |
ML{*ResAtp.problem_name := "BigO__bigo_mult2_simpler"*} |
|
921 |
(*sledgehammer*); |
|
922 |
apply (subgoal_tac "abs(f x) * abs(b x) <= abs(f x) * (c * abs(g x))") |
|
923 |
apply (simp add: mult_ac) |
|
924 |
apply (rule mult_left_mono, assumption) |
|
925 |
apply (rule abs_ge_zero) |
|
926 |
done |
|
927 |
||
928 |
ML{*ResAtp.problem_name:="BigO__bigo_mult3"*} |
|
929 |
lemma bigo_mult3: "f : O(h) ==> g : O(j) ==> f * g : O(h * j)" |
|
930 |
by (metis bigo_mult set_times_intro subset_iff) |
|
931 |
||
932 |
ML{*ResAtp.problem_name:="BigO__bigo_mult4"*} |
|
933 |
lemma bigo_mult4 [intro]:"f : k +o O(h) ==> g * f : (g * k) +o O(g * h)" |
|
934 |
by (metis bigo_mult2 set_plus_mono_b set_times_intro2 set_times_plus_distrib) |
|
935 |
||
936 |
||
937 |
lemma bigo_mult5: "ALL x. f x ~= 0 ==> |
|
938 |
O(f * g) <= (f::'a => ('b::ordered_field)) *o O(g)" |
|
939 |
proof - |
|
940 |
assume "ALL x. f x ~= 0" |
|
941 |
show "O(f * g) <= f *o O(g)" |
|
942 |
proof |
|
943 |
fix h |
|
944 |
assume "h : O(f * g)" |
|
945 |
then have "(%x. 1 / (f x)) * h : (%x. 1 / f x) *o O(f * g)" |
|
946 |
by auto |
|
947 |
also have "... <= O((%x. 1 / f x) * (f * g))" |
|
948 |
by (rule bigo_mult2) |
|
949 |
also have "(%x. 1 / f x) * (f * g) = g" |
|
950 |
apply (simp add: func_times) |
|
951 |
apply (rule ext) |
|
952 |
apply (simp add: prems nonzero_divide_eq_eq mult_ac) |
|
953 |
done |
|
954 |
finally have "(%x. (1::'b) / f x) * h : O(g)". |
|
955 |
then have "f * ((%x. (1::'b) / f x) * h) : f *o O(g)" |
|
956 |
by auto |
|
957 |
also have "f * ((%x. (1::'b) / f x) * h) = h" |
|
958 |
apply (simp add: func_times) |
|
959 |
apply (rule ext) |
|
960 |
apply (simp add: prems nonzero_divide_eq_eq mult_ac) |
|
961 |
done |
|
962 |
finally show "h : f *o O(g)". |
|
963 |
qed |
|
964 |
qed |
|
965 |
||
966 |
ML{*ResAtp.problem_name := "BigO__bigo_mult6"*} |
|
967 |
lemma bigo_mult6: "ALL x. f x ~= 0 ==> |
|
968 |
O(f * g) = (f::'a => ('b::ordered_field)) *o O(g)" |
|
969 |
by (metis bigo_mult2 bigo_mult5 order_antisym) |
|
970 |
||
971 |
(*proof requires relaxing relevance: 2007-01-25*) |
|
972 |
ML{*ResAtp.problem_name := "BigO__bigo_mult7"*} |
|
973 |
declare bigo_mult6 [simp] |
|
974 |
lemma bigo_mult7: "ALL x. f x ~= 0 ==> |
|
975 |
O(f * g) <= O(f::'a => ('b::ordered_field)) * O(g)" |
|
976 |
(*sledgehammer*) |
|
977 |
apply (subst bigo_mult6) |
|
978 |
apply assumption |
|
979 |
apply (rule set_times_mono3) |
|
980 |
apply (rule bigo_refl) |
|
981 |
done |
|
982 |
declare bigo_mult6 [simp del] |
|
983 |
||
984 |
ML{*ResAtp.problem_name := "BigO__bigo_mult8"*} |
|
985 |
declare bigo_mult7[intro!] |
|
986 |
lemma bigo_mult8: "ALL x. f x ~= 0 ==> |
|
987 |
O(f * g) = O(f::'a => ('b::ordered_field)) * O(g)" |
|
988 |
by (metis bigo_mult bigo_mult7 order_antisym_conv) |
|
989 |
||
990 |
lemma bigo_minus [intro]: "f : O(g) ==> - f : O(g)" |
|
991 |
by (auto simp add: bigo_def func_minus) |
|
992 |
||
993 |
lemma bigo_minus2: "f : g +o O(h) ==> -f : -g +o O(h)" |
|
994 |
apply (rule set_minus_imp_plus) |
|
995 |
apply (drule set_plus_imp_minus) |
|
996 |
apply (drule bigo_minus) |
|
997 |
apply (simp add: diff_minus) |
|
998 |
done |
|
999 |
||
1000 |
lemma bigo_minus3: "O(-f) = O(f)" |
|
1001 |
by (auto simp add: bigo_def func_minus abs_minus_cancel) |
|
1002 |
||
1003 |
lemma bigo_plus_absorb_lemma1: "f : O(g) ==> f +o O(g) <= O(g)" |
|
1004 |
proof - |
|
1005 |
assume a: "f : O(g)" |
|
1006 |
show "f +o O(g) <= O(g)" |
|
1007 |
proof - |
|
1008 |
have "f : O(f)" by auto |
|
1009 |
then have "f +o O(g) <= O(f) + O(g)" |
|
1010 |
by (auto del: subsetI) |
|
1011 |
also have "... <= O(g) + O(g)" |
|
1012 |
proof - |
|
1013 |
from a have "O(f) <= O(g)" by (auto del: subsetI) |
|
1014 |
thus ?thesis by (auto del: subsetI) |
|
1015 |
qed |
|
1016 |
also have "... <= O(g)" by (simp add: bigo_plus_idemp) |
|
1017 |
finally show ?thesis . |
|
1018 |
qed |
|
1019 |
qed |
|
1020 |
||
1021 |
lemma bigo_plus_absorb_lemma2: "f : O(g) ==> O(g) <= f +o O(g)" |
|
1022 |
proof - |
|
1023 |
assume a: "f : O(g)" |
|
1024 |
show "O(g) <= f +o O(g)" |
|
1025 |
proof - |
|
1026 |
from a have "-f : O(g)" by auto |
|
1027 |
then have "-f +o O(g) <= O(g)" by (elim bigo_plus_absorb_lemma1) |
|
1028 |
then have "f +o (-f +o O(g)) <= f +o O(g)" by auto |
|
1029 |
also have "f +o (-f +o O(g)) = O(g)" |
|
1030 |
by (simp add: set_plus_rearranges) |
|
1031 |
finally show ?thesis . |
|
1032 |
qed |
|
1033 |
qed |
|
1034 |
||
1035 |
ML{*ResAtp.problem_name:="BigO__bigo_plus_absorb"*} |
|
1036 |
lemma bigo_plus_absorb [simp]: "f : O(g) ==> f +o O(g) = O(g)" |
|
1037 |
by (metis bigo_plus_absorb_lemma1 bigo_plus_absorb_lemma2 order_eq_iff); |
|
1038 |
||
1039 |
lemma bigo_plus_absorb2 [intro]: "f : O(g) ==> A <= O(g) ==> f +o A <= O(g)" |
|
1040 |
apply (subgoal_tac "f +o A <= f +o O(g)") |
|
1041 |
apply force+ |
|
1042 |
done |
|
1043 |
||
1044 |
lemma bigo_add_commute_imp: "f : g +o O(h) ==> g : f +o O(h)" |
|
1045 |
apply (subst set_minus_plus [symmetric]) |
|
1046 |
apply (subgoal_tac "g - f = - (f - g)") |
|
1047 |
apply (erule ssubst) |
|
1048 |
apply (rule bigo_minus) |
|
1049 |
apply (subst set_minus_plus) |
|
1050 |
apply assumption |
|
1051 |
apply (simp add: diff_minus add_ac) |
|
1052 |
done |
|
1053 |
||
1054 |
lemma bigo_add_commute: "(f : g +o O(h)) = (g : f +o O(h))" |
|
1055 |
apply (rule iffI) |
|
1056 |
apply (erule bigo_add_commute_imp)+ |
|
1057 |
done |
|
1058 |
||
1059 |
lemma bigo_const1: "(%x. c) : O(%x. 1)" |
|
1060 |
by (auto simp add: bigo_def mult_ac) |
|
1061 |
||
1062 |
declare bigo_const1 [skolem] |
|
1063 |
||
1064 |
ML{*ResAtp.problem_name:="BigO__bigo_const2"*} |
|
1065 |
lemma (*bigo_const2 [intro]:*) "O(%x. c) <= O(%x. 1)" |
|
1066 |
by (metis bigo_const1 bigo_elt_subset); |
|
1067 |
||
1068 |
lemma bigo_const2 [intro]: "O(%x. c) <= O(%x. 1)"; |
|
1069 |
(*??FAILS because the two occurrences of COMBK have different polymorphic types |
|
1070 |
proof (neg_clausify) |
|
1071 |
assume 0: "\<not> O(COMBK (c\<Colon>'b\<Colon>ordered_idom)) \<subseteq> O(COMBK (1\<Colon>'b\<Colon>ordered_idom))" |
|
1072 |
have 1: "COMBK (c\<Colon>'b\<Colon>ordered_idom) \<notin> O(COMBK (1\<Colon>'b\<Colon>ordered_idom))" |
|
1073 |
apply (rule notI) |
|
1074 |
apply (rule 0 [THEN notE]) |
|
1075 |
apply (rule bigo_elt_subset) |
|
1076 |
apply assumption; |
|
1077 |
sorry |
|
1078 |
by (metis 0 bigo_elt_subset) loops?? |
|
1079 |
show "False" |
|
1080 |
by (metis 1 bigo_const1) |
|
1081 |
qed |
|
1082 |
*) |
|
1083 |
apply (rule bigo_elt_subset) |
|
1084 |
apply (rule bigo_const1) |
|
1085 |
done |
|
1086 |
||
1087 |
declare bigo_const2 [skolem] |
|
1088 |
||
1089 |
ML{*ResAtp.problem_name := "BigO__bigo_const3"*} |
|
1090 |
lemma bigo_const3: "(c::'a::ordered_field) ~= 0 ==> (%x. 1) : O(%x. c)" |
|
1091 |
apply (simp add: bigo_def) |
|
1092 |
proof (neg_clausify) |
|
1093 |
assume 0: "(c\<Colon>'a\<Colon>ordered_field) \<noteq> (0\<Colon>'a\<Colon>ordered_field)" |
|
23519 | 1094 |
assume 1: "\<And>A\<Colon>'a\<Colon>ordered_field. \<not> (1\<Colon>'a\<Colon>ordered_field) \<le> A * \<bar>c\<Colon>'a\<Colon>ordered_field\<bar>" |
23449 | 1095 |
have 2: "(0\<Colon>'a\<Colon>ordered_field) = \<bar>c\<Colon>'a\<Colon>ordered_field\<bar> \<or> |
1096 |
\<not> (1\<Colon>'a\<Colon>ordered_field) \<le> (1\<Colon>'a\<Colon>ordered_field)" |
|
1097 |
by (metis 1 field_inverse) |
|
1098 |
have 3: "\<bar>c\<Colon>'a\<Colon>ordered_field\<bar> = (0\<Colon>'a\<Colon>ordered_field)" |
|
23519 | 1099 |
by (metis linorder_neq_iff linorder_antisym_conv1 2) |
23449 | 1100 |
have 4: "(0\<Colon>'a\<Colon>ordered_field) = (c\<Colon>'a\<Colon>ordered_field)" |
23519 | 1101 |
by (metis 3 abs_eq_0) |
1102 |
show "False" |
|
1103 |
by (metis 0 4) |
|
23449 | 1104 |
qed |
1105 |
||
1106 |
lemma bigo_const4: "(c::'a::ordered_field) ~= 0 ==> O(%x. 1) <= O(%x. c)" |
|
1107 |
by (rule bigo_elt_subset, rule bigo_const3, assumption) |
|
1108 |
||
1109 |
lemma bigo_const [simp]: "(c::'a::ordered_field) ~= 0 ==> |
|
1110 |
O(%x. c) = O(%x. 1)" |
|
1111 |
by (rule equalityI, rule bigo_const2, rule bigo_const4, assumption) |
|
1112 |
||
1113 |
ML{*ResAtp.problem_name := "BigO__bigo_const_mult1"*} |
|
1114 |
lemma bigo_const_mult1: "(%x. c * f x) : O(f)" |
|
1115 |
apply (simp add: bigo_def abs_mult) |
|
1116 |
proof (neg_clausify) |
|
1117 |
fix x |
|
1118 |
assume 0: "\<And>mes_vAL\<Colon>'b. |
|
1119 |
\<not> \<bar>c\<Colon>'b\<bar> * |
|
1120 |
\<bar>(f\<Colon>'a \<Rightarrow> 'b) ((x\<Colon>'b \<Rightarrow> 'a) mes_vAL)\<bar> |
|
1121 |
\<le> mes_vAL * \<bar>f (x mes_vAL)\<bar>" |
|
1122 |
have 1: "\<And>Y\<Colon>'b. Y \<le> Y" |
|
1123 |
by (metis order_refl) |
|
1124 |
show 2: "False" |
|
1125 |
by (metis 0 1) |
|
1126 |
qed |
|
1127 |
||
1128 |
lemma bigo_const_mult2: "O(%x. c * f x) <= O(f)" |
|
1129 |
by (rule bigo_elt_subset, rule bigo_const_mult1) |
|
1130 |
||
1131 |
ML{*ResAtp.problem_name := "BigO__bigo_const_mult3"*} |
|
1132 |
lemma bigo_const_mult3: "(c::'a::ordered_field) ~= 0 ==> f : O(%x. c * f x)" |
|
1133 |
apply (simp add: bigo_def) |
|
1134 |
(*sledgehammer*); |
|
1135 |
apply (rule_tac x = "abs(inverse c)" in exI) |
|
1136 |
apply (simp only: abs_mult [symmetric] mult_assoc [symmetric]) |
|
1137 |
apply (subst left_inverse) |
|
1138 |
apply (auto ); |
|
1139 |
done |
|
1140 |
||
1141 |
lemma bigo_const_mult4: "(c::'a::ordered_field) ~= 0 ==> |
|
1142 |
O(f) <= O(%x. c * f x)" |
|
1143 |
by (rule bigo_elt_subset, rule bigo_const_mult3, assumption) |
|
1144 |
||
1145 |
lemma bigo_const_mult [simp]: "(c::'a::ordered_field) ~= 0 ==> |
|
1146 |
O(%x. c * f x) = O(f)" |
|
1147 |
by (rule equalityI, rule bigo_const_mult2, erule bigo_const_mult4) |
|
1148 |
||
1149 |
ML{*ResAtp.problem_name := "BigO__bigo_const_mult5"*} |
|
1150 |
lemma bigo_const_mult5 [simp]: "(c::'a::ordered_field) ~= 0 ==> |
|
1151 |
(%x. c) *o O(f) = O(f)" |
|
1152 |
apply (auto del: subsetI) |
|
1153 |
apply (rule order_trans) |
|
1154 |
apply (rule bigo_mult2) |
|
1155 |
apply (simp add: func_times) |
|
1156 |
apply (auto intro!: subsetI simp add: bigo_def elt_set_times_def func_times) |
|
1157 |
apply (rule_tac x = "%y. inverse c * x y" in exI) |
|
1158 |
apply (rename_tac g d) |
|
1159 |
apply safe; |
|
1160 |
apply (rule_tac [2] ext) |
|
1161 |
(*sledgehammer*); |
|
1162 |
apply (simp_all del: mult_assoc add: mult_assoc [symmetric] abs_mult) |
|
1163 |
apply (rule_tac x = "abs (inverse c) * d" in exI) |
|
1164 |
apply (rule allI) |
|
1165 |
apply (subst mult_assoc) |
|
1166 |
apply (rule mult_left_mono) |
|
1167 |
apply (erule spec) |
|
1168 |
apply (simp add: ); |
|
1169 |
done |
|
1170 |
||
1171 |
||
1172 |
ML{*ResAtp.problem_name := "BigO__bigo_const_mult6"*} |
|
1173 |
lemma bigo_const_mult6 [intro]: "(%x. c) *o O(f) <= O(f)" |
|
1174 |
apply (auto intro!: subsetI |
|
1175 |
simp add: bigo_def elt_set_times_def func_times |
|
1176 |
simp del: abs_mult mult_ac) |
|
1177 |
(*sledgehammer*); |
|
1178 |
apply (rule_tac x = "ca * (abs c)" in exI) |
|
1179 |
apply (rule allI) |
|
1180 |
apply (subgoal_tac "ca * abs(c) * abs(f x) = abs(c) * (ca * abs(f x))") |
|
1181 |
apply (erule ssubst) |
|
1182 |
apply (subst abs_mult) |
|
1183 |
apply (rule mult_left_mono) |
|
1184 |
apply (erule spec) |
|
1185 |
apply simp |
|
1186 |
apply(simp add: mult_ac) |
|
1187 |
done |
|
1188 |
||
1189 |
lemma bigo_const_mult7 [intro]: "f =o O(g) ==> (%x. c * f x) =o O(g)" |
|
1190 |
proof - |
|
1191 |
assume "f =o O(g)" |
|
1192 |
then have "(%x. c) * f =o (%x. c) *o O(g)" |
|
1193 |
by auto |
|
1194 |
also have "(%x. c) * f = (%x. c * f x)" |
|
1195 |
by (simp add: func_times) |
|
1196 |
also have "(%x. c) *o O(g) <= O(g)" |
|
1197 |
by (auto del: subsetI) |
|
1198 |
finally show ?thesis . |
|
1199 |
qed |
|
1200 |
||
1201 |
lemma bigo_compose1: "f =o O(g) ==> (%x. f(k x)) =o O(%x. g(k x))" |
|
1202 |
by (unfold bigo_def, auto) |
|
1203 |
||
1204 |
lemma bigo_compose2: "f =o g +o O(h) ==> (%x. f(k x)) =o (%x. g(k x)) +o |
|
1205 |
O(%x. h(k x))" |
|
1206 |
apply (simp only: set_minus_plus [symmetric] diff_minus func_minus |
|
1207 |
func_plus) |
|
1208 |
apply (erule bigo_compose1) |
|
1209 |
done |
|
1210 |
||
1211 |
subsection {* Setsum *} |
|
1212 |
||
1213 |
lemma bigo_setsum_main: "ALL x. ALL y : A x. 0 <= h x y ==> |
|
1214 |
EX c. ALL x. ALL y : A x. abs(f x y) <= c * (h x y) ==> |
|
1215 |
(%x. SUM y : A x. f x y) =o O(%x. SUM y : A x. h x y)" |
|
1216 |
apply (auto simp add: bigo_def) |
|
1217 |
apply (rule_tac x = "abs c" in exI) |
|
1218 |
apply (subst abs_of_nonneg) back back |
|
1219 |
apply (rule setsum_nonneg) |
|
1220 |
apply force |
|
1221 |
apply (subst setsum_right_distrib) |
|
1222 |
apply (rule allI) |
|
1223 |
apply (rule order_trans) |
|
1224 |
apply (rule setsum_abs) |
|
1225 |
apply (rule setsum_mono) |
|
1226 |
apply (blast intro: order_trans mult_right_mono abs_ge_self) |
|
1227 |
done |
|
1228 |
||
1229 |
ML{*ResAtp.problem_name := "BigO__bigo_setsum1"*} |
|
1230 |
lemma bigo_setsum1: "ALL x y. 0 <= h x y ==> |
|
1231 |
EX c. ALL x y. abs(f x y) <= c * (h x y) ==> |
|
1232 |
(%x. SUM y : A x. f x y) =o O(%x. SUM y : A x. h x y)" |
|
1233 |
apply (rule bigo_setsum_main) |
|
1234 |
(*sledgehammer*); |
|
1235 |
apply force |
|
1236 |
apply clarsimp |
|
1237 |
apply (rule_tac x = c in exI) |
|
1238 |
apply force |
|
1239 |
done |
|
1240 |
||
1241 |
lemma bigo_setsum2: "ALL y. 0 <= h y ==> |
|
1242 |
EX c. ALL y. abs(f y) <= c * (h y) ==> |
|
1243 |
(%x. SUM y : A x. f y) =o O(%x. SUM y : A x. h y)" |
|
1244 |
by (rule bigo_setsum1, auto) |
|
1245 |
||
1246 |
ML{*ResAtp.problem_name := "BigO__bigo_setsum3"*} |
|
1247 |
lemma bigo_setsum3: "f =o O(h) ==> |
|
1248 |
(%x. SUM y : A x. (l x y) * f(k x y)) =o |
|
1249 |
O(%x. SUM y : A x. abs(l x y * h(k x y)))" |
|
1250 |
apply (rule bigo_setsum1) |
|
1251 |
apply (rule allI)+ |
|
1252 |
apply (rule abs_ge_zero) |
|
1253 |
apply (unfold bigo_def) |
|
1254 |
apply (auto simp add: abs_mult); |
|
1255 |
(*sledgehammer*); |
|
1256 |
apply (rule_tac x = c in exI) |
|
1257 |
apply (rule allI)+ |
|
1258 |
apply (subst mult_left_commute) |
|
1259 |
apply (rule mult_left_mono) |
|
1260 |
apply (erule spec) |
|
1261 |
apply (rule abs_ge_zero) |
|
1262 |
done |
|
1263 |
||
1264 |
lemma bigo_setsum4: "f =o g +o O(h) ==> |
|
1265 |
(%x. SUM y : A x. l x y * f(k x y)) =o |
|
1266 |
(%x. SUM y : A x. l x y * g(k x y)) +o |
|
1267 |
O(%x. SUM y : A x. abs(l x y * h(k x y)))" |
|
1268 |
apply (rule set_minus_imp_plus) |
|
1269 |
apply (subst func_diff) |
|
1270 |
apply (subst setsum_subtractf [symmetric]) |
|
1271 |
apply (subst right_diff_distrib [symmetric]) |
|
1272 |
apply (rule bigo_setsum3) |
|
1273 |
apply (subst func_diff [symmetric]) |
|
1274 |
apply (erule set_plus_imp_minus) |
|
1275 |
done |
|
1276 |
||
1277 |
ML{*ResAtp.problem_name := "BigO__bigo_setsum5"*} |
|
1278 |
lemma bigo_setsum5: "f =o O(h) ==> ALL x y. 0 <= l x y ==> |
|
1279 |
ALL x. 0 <= h x ==> |
|
1280 |
(%x. SUM y : A x. (l x y) * f(k x y)) =o |
|
1281 |
O(%x. SUM y : A x. (l x y) * h(k x y))" |
|
1282 |
apply (subgoal_tac "(%x. SUM y : A x. (l x y) * h(k x y)) = |
|
1283 |
(%x. SUM y : A x. abs((l x y) * h(k x y)))") |
|
1284 |
apply (erule ssubst) |
|
1285 |
apply (erule bigo_setsum3) |
|
1286 |
apply (rule ext) |
|
1287 |
apply (rule setsum_cong2) |
|
1288 |
apply (thin_tac "f \<in> O(h)") |
|
1289 |
(*sledgehammer*); |
|
1290 |
apply (subst abs_of_nonneg) |
|
1291 |
apply (rule mult_nonneg_nonneg) |
|
1292 |
apply auto |
|
1293 |
done |
|
1294 |
||
1295 |
lemma bigo_setsum6: "f =o g +o O(h) ==> ALL x y. 0 <= l x y ==> |
|
1296 |
ALL x. 0 <= h x ==> |
|
1297 |
(%x. SUM y : A x. (l x y) * f(k x y)) =o |
|
1298 |
(%x. SUM y : A x. (l x y) * g(k x y)) +o |
|
1299 |
O(%x. SUM y : A x. (l x y) * h(k x y))" |
|
1300 |
apply (rule set_minus_imp_plus) |
|
1301 |
apply (subst func_diff) |
|
1302 |
apply (subst setsum_subtractf [symmetric]) |
|
1303 |
apply (subst right_diff_distrib [symmetric]) |
|
1304 |
apply (rule bigo_setsum5) |
|
1305 |
apply (subst func_diff [symmetric]) |
|
1306 |
apply (drule set_plus_imp_minus) |
|
1307 |
apply auto |
|
1308 |
done |
|
1309 |
||
1310 |
subsection {* Misc useful stuff *} |
|
1311 |
||
1312 |
lemma bigo_useful_intro: "A <= O(f) ==> B <= O(f) ==> |
|
1313 |
A + B <= O(f)" |
|
1314 |
apply (subst bigo_plus_idemp [symmetric]) |
|
1315 |
apply (rule set_plus_mono2) |
|
1316 |
apply assumption+ |
|
1317 |
done |
|
1318 |
||
1319 |
lemma bigo_useful_add: "f =o O(h) ==> g =o O(h) ==> f + g =o O(h)" |
|
1320 |
apply (subst bigo_plus_idemp [symmetric]) |
|
1321 |
apply (rule set_plus_intro) |
|
1322 |
apply assumption+ |
|
1323 |
done |
|
1324 |
||
1325 |
lemma bigo_useful_const_mult: "(c::'a::ordered_field) ~= 0 ==> |
|
1326 |
(%x. c) * f =o O(h) ==> f =o O(h)" |
|
1327 |
apply (rule subsetD) |
|
1328 |
apply (subgoal_tac "(%x. 1 / c) *o O(h) <= O(h)") |
|
1329 |
apply assumption |
|
1330 |
apply (rule bigo_const_mult6) |
|
1331 |
apply (subgoal_tac "f = (%x. 1 / c) * ((%x. c) * f)") |
|
1332 |
apply (erule ssubst) |
|
1333 |
apply (erule set_times_intro2) |
|
1334 |
apply (simp add: func_times) |
|
1335 |
done |
|
1336 |
||
1337 |
ML{*ResAtp.problem_name := "BigO__bigo_fix"*} |
|
1338 |
lemma bigo_fix: "(%x. f ((x::nat) + 1)) =o O(%x. h(x + 1)) ==> f 0 = 0 ==> |
|
1339 |
f =o O(h)" |
|
1340 |
apply (simp add: bigo_alt_def) |
|
1341 |
(*sledgehammer*); |
|
1342 |
apply clarify |
|
1343 |
apply (rule_tac x = c in exI) |
|
1344 |
apply safe |
|
1345 |
apply (case_tac "x = 0") |
|
23816 | 1346 |
apply (metis OrderedGroup.abs_ge_zero OrderedGroup.abs_zero order_less_le Ring_and_Field.split_mult_pos_le) |
23449 | 1347 |
apply (subgoal_tac "x = Suc (x - 1)") |
23816 | 1348 |
apply metis |
23449 | 1349 |
apply simp |
1350 |
done |
|
1351 |
||
1352 |
||
1353 |
lemma bigo_fix2: |
|
1354 |
"(%x. f ((x::nat) + 1)) =o (%x. g(x + 1)) +o O(%x. h(x + 1)) ==> |
|
1355 |
f 0 = g 0 ==> f =o g +o O(h)" |
|
1356 |
apply (rule set_minus_imp_plus) |
|
1357 |
apply (rule bigo_fix) |
|
1358 |
apply (subst func_diff) |
|
1359 |
apply (subst func_diff [symmetric]) |
|
1360 |
apply (rule set_plus_imp_minus) |
|
1361 |
apply simp |
|
1362 |
apply (simp add: func_diff) |
|
1363 |
done |
|
1364 |
||
1365 |
subsection {* Less than or equal to *} |
|
1366 |
||
1367 |
constdefs |
|
1368 |
lesso :: "('a => 'b::ordered_idom) => ('a => 'b) => ('a => 'b)" |
|
1369 |
(infixl "<o" 70) |
|
1370 |
"f <o g == (%x. max (f x - g x) 0)" |
|
1371 |
||
1372 |
lemma bigo_lesseq1: "f =o O(h) ==> ALL x. abs (g x) <= abs (f x) ==> |
|
1373 |
g =o O(h)" |
|
1374 |
apply (unfold bigo_def) |
|
1375 |
apply clarsimp |
|
1376 |
apply (blast intro: order_trans) |
|
1377 |
done |
|
1378 |
||
1379 |
lemma bigo_lesseq2: "f =o O(h) ==> ALL x. abs (g x) <= f x ==> |
|
1380 |
g =o O(h)" |
|
1381 |
apply (erule bigo_lesseq1) |
|
1382 |
apply (blast intro: abs_ge_self order_trans) |
|
1383 |
done |
|
1384 |
||
1385 |
lemma bigo_lesseq3: "f =o O(h) ==> ALL x. 0 <= g x ==> ALL x. g x <= f x ==> |
|
1386 |
g =o O(h)" |
|
1387 |
apply (erule bigo_lesseq2) |
|
1388 |
apply (rule allI) |
|
1389 |
apply (subst abs_of_nonneg) |
|
1390 |
apply (erule spec)+ |
|
1391 |
done |
|
1392 |
||
1393 |
lemma bigo_lesseq4: "f =o O(h) ==> |
|
1394 |
ALL x. 0 <= g x ==> ALL x. g x <= abs (f x) ==> |
|
1395 |
g =o O(h)" |
|
1396 |
apply (erule bigo_lesseq1) |
|
1397 |
apply (rule allI) |
|
1398 |
apply (subst abs_of_nonneg) |
|
1399 |
apply (erule spec)+ |
|
1400 |
done |
|
1401 |
||
1402 |
ML{*ResAtp.problem_name:="BigO__bigo_lesso1"*} |
|
1403 |
lemma bigo_lesso1: "ALL x. f x <= g x ==> f <o g =o O(h)" |
|
1404 |
apply (unfold lesso_def) |
|
1405 |
apply (subgoal_tac "(%x. max (f x - g x) 0) = 0") |
|
1406 |
(* |
|
1407 |
?? abstractions don't work: abstraction function gets the wrong type? |
|
1408 |
proof (neg_clausify) |
|
1409 |
assume 0: "llabs_subgoal_1 f g = 0" |
|
1410 |
assume 1: "llabs_subgoal_1 f g \<notin> O(h)" |
|
1411 |
show "False" |
|
1412 |
by (metis 1 0 bigo_zero) |
|
1413 |
*) |
|
1414 |
apply (erule ssubst) |
|
1415 |
apply (rule bigo_zero) |
|
1416 |
apply (unfold func_zero) |
|
1417 |
apply (rule ext) |
|
1418 |
apply (simp split: split_max) |
|
1419 |
done |
|
1420 |
||
1421 |
||
1422 |
ML{*ResAtp.problem_name := "BigO__bigo_lesso2"*} |
|
1423 |
lemma bigo_lesso2: "f =o g +o O(h) ==> |
|
1424 |
ALL x. 0 <= k x ==> ALL x. k x <= f x ==> |
|
1425 |
k <o g =o O(h)" |
|
1426 |
apply (unfold lesso_def) |
|
1427 |
apply (rule bigo_lesseq4) |
|
1428 |
apply (erule set_plus_imp_minus) |
|
1429 |
apply (rule allI) |
|
1430 |
apply (rule le_maxI2) |
|
1431 |
apply (rule allI) |
|
1432 |
apply (subst func_diff) |
|
1433 |
apply (erule thin_rl) |
|
1434 |
(*sledgehammer*); |
|
1435 |
apply (case_tac "0 <= k x - g x") |
|
1436 |
apply (simp del: compare_rls diff_minus); |
|
1437 |
apply (subst abs_of_nonneg) |
|
1438 |
apply (drule_tac x = x in spec) back |
|
1439 |
ML{*ResAtp.problem_name := "BigO__bigo_lesso2_simpler"*} |
|
1440 |
(*sledgehammer*); |
|
1441 |
apply (simp add: compare_rls del: diff_minus) |
|
1442 |
apply (subst diff_minus)+ |
|
1443 |
apply (rule add_right_mono) |
|
1444 |
apply (erule spec) |
|
1445 |
apply (rule order_trans) |
|
1446 |
prefer 2 |
|
1447 |
apply (rule abs_ge_zero) |
|
1448 |
(* |
|
1449 |
apply (simp only: compare_rls min_max.below_sup.above_sup_conv |
|
1450 |
linorder_not_le order_less_imp_le) |
|
1451 |
*) |
|
1452 |
apply (simp add: compare_rls del: diff_minus) |
|
1453 |
done |
|
1454 |
||
1455 |
||
1456 |
||
1457 |
ML{*ResAtp.problem_name := "BigO__bigo_lesso3"*} |
|
1458 |
lemma bigo_lesso3: "f =o g +o O(h) ==> |
|
1459 |
ALL x. 0 <= k x ==> ALL x. g x <= k x ==> |
|
1460 |
f <o k =o O(h)" |
|
1461 |
apply (unfold lesso_def) |
|
1462 |
apply (rule bigo_lesseq4) |
|
1463 |
apply (erule set_plus_imp_minus) |
|
1464 |
apply (rule allI) |
|
1465 |
apply (rule le_maxI2) |
|
1466 |
apply (rule allI) |
|
1467 |
apply (subst func_diff) |
|
1468 |
apply (erule thin_rl) |
|
1469 |
(*sledgehammer*); |
|
1470 |
apply (case_tac "0 <= f x - k x") |
|
1471 |
apply (simp del: compare_rls diff_minus); |
|
1472 |
apply (subst abs_of_nonneg) |
|
1473 |
apply (drule_tac x = x in spec) back |
|
1474 |
ML{*ResAtp.problem_name := "BigO__bigo_lesso3_simpler"*} |
|
1475 |
(*sledgehammer*); |
|
1476 |
apply (simp del: diff_minus) |
|
1477 |
apply (subst diff_minus)+ |
|
1478 |
apply (rule add_left_mono) |
|
1479 |
apply (rule le_imp_neg_le) |
|
1480 |
apply (erule spec) |
|
1481 |
apply (rule order_trans) |
|
1482 |
prefer 2 |
|
1483 |
apply (rule abs_ge_zero) |
|
1484 |
apply (simp del: diff_minus) |
|
1485 |
done |
|
1486 |
||
1487 |
lemma bigo_lesso4: "f <o g =o O(k::'a=>'b::ordered_field) ==> |
|
1488 |
g =o h +o O(k) ==> f <o h =o O(k)" |
|
1489 |
apply (unfold lesso_def) |
|
1490 |
apply (drule set_plus_imp_minus) |
|
1491 |
apply (drule bigo_abs5) back |
|
1492 |
apply (simp add: func_diff) |
|
1493 |
apply (drule bigo_useful_add) |
|
1494 |
apply assumption |
|
1495 |
apply (erule bigo_lesseq2) back |
|
1496 |
apply (rule allI) |
|
1497 |
apply (auto simp add: func_plus func_diff compare_rls |
|
1498 |
split: split_max abs_split) |
|
1499 |
done |
|
1500 |
||
1501 |
ML{*ResAtp.problem_name := "BigO__bigo_lesso5"*} |
|
1502 |
lemma bigo_lesso5: "f <o g =o O(h) ==> |
|
1503 |
EX C. ALL x. f x <= g x + C * abs(h x)" |
|
1504 |
apply (simp only: lesso_def bigo_alt_def) |
|
1505 |
apply clarsimp |
|
1506 |
(*sledgehammer*); |
|
1507 |
apply (auto simp add: compare_rls add_ac) |
|
1508 |
done |
|
1509 |
||
1510 |
end |