| author | wenzelm | 
| Tue, 10 Jun 2008 19:15:21 +0200 | |
| changeset 27128 | d2374ba6c02e | 
| parent 26814 | b3e8d5ec721d | 
| child 27368 | 9f90ac19e32b | 
| permissions | -rwxr-xr-x | 
| 16932 | 1  | 
(* Title: HOL/Library/BigO.thy  | 
2  | 
ID: $Id$  | 
|
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
3  | 
Authors: Jeremy Avigad and Kevin Donnelly  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
4  | 
*)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
5  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
6  | 
header {* Big O notation *}
 | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
7  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
8  | 
theory BigO  | 
| 25592 | 9  | 
imports Main SetsAndFunctions  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
10  | 
begin  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
11  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
12  | 
text {*
 | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
13  | 
This library is designed to support asymptotic ``big O'' calculations,  | 
| 
17199
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
14  | 
i.e.~reasoning with expressions of the form $f = O(g)$ and $f = g +  | 
| 
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
15  | 
O(h)$. An earlier version of this library is described in detail in  | 
| 
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
16  | 
\cite{Avigad-Donnelly}.
 | 
| 
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
17  | 
|
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
18  | 
The main changes in this version are as follows:  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
19  | 
\begin{itemize}
 | 
| 
17199
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
20  | 
\item We have eliminated the @{text O} operator on sets. (Most uses of this seem
 | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
21  | 
to be inessential.)  | 
| 
17199
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
22  | 
\item We no longer use @{text "+"} as output syntax for @{text "+o"}
 | 
| 
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
23  | 
\item Lemmas involving @{text "sumr"} have been replaced by more general lemmas 
 | 
| 
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
24  | 
  involving `@{text "setsum"}.
 | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
25  | 
\item The library has been expanded, with e.g.~support for expressions of  | 
| 
17199
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
26  | 
  the form @{text "f < g + O(h)"}.
 | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
27  | 
\end{itemize}
 | 
| 
17199
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
28  | 
|
| 
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
29  | 
See \verb,Complex/ex/BigO_Complex.thy, for additional lemmas that  | 
| 
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
30  | 
require the \verb,HOL-Complex, logic image.  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
31  | 
|
| 
17199
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
32  | 
Note also since the Big O library includes rules that demonstrate set  | 
| 
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
33  | 
inclusion, to use the automated reasoners effectively with the library  | 
| 
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
34  | 
one should redeclare the theorem @{text "subsetI"} as an intro rule,
 | 
| 
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
35  | 
rather than as an @{text "intro!"} rule, for example, using
 | 
| 
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
36  | 
\isa{\isakeyword{declare}}~@{text "subsetI [del, intro]"}.
 | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
37  | 
*}  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
38  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
39  | 
subsection {* Definitions *}
 | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
40  | 
|
| 19736 | 41  | 
definition  | 
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19736 
diff
changeset
 | 
42  | 
  bigo :: "('a => 'b::ordered_idom) => ('a => 'b) set"  ("(1O'(_'))") where
 | 
| 19736 | 43  | 
  "O(f::('a => 'b)) =
 | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
44  | 
      {h. EX c. ALL x. abs (h x) <= c * abs (f x)}"
 | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
45  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
46  | 
lemma bigo_pos_const: "(EX (c::'a::ordered_idom).  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
47  | 
ALL x. (abs (h x)) <= (c * (abs (f x))))  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
48  | 
= (EX c. 0 < c & (ALL x. (abs(h x)) <= (c * (abs (f x)))))"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
49  | 
apply auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
50  | 
apply (case_tac "c = 0")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
51  | 
apply simp  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
52  | 
apply (rule_tac x = "1" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
53  | 
apply simp  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
54  | 
apply (rule_tac x = "abs c" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
55  | 
apply auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
56  | 
apply (subgoal_tac "c * abs(f x) <= abs c * abs (f x)")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
57  | 
apply (erule_tac x = x in allE)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
58  | 
apply force  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
59  | 
apply (rule mult_right_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
60  | 
apply (rule abs_ge_self)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
61  | 
apply (rule abs_ge_zero)  | 
| 22665 | 62  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
63  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
64  | 
lemma bigo_alt_def: "O(f) =  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
65  | 
    {h. EX c. (0 < c & (ALL x. abs (h x) <= c * abs (f x)))}"
 | 
| 22665 | 66  | 
by (auto simp add: bigo_def bigo_pos_const)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
67  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
68  | 
lemma bigo_elt_subset [intro]: "f : O(g) ==> O(f) <= O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
69  | 
apply (auto simp add: bigo_alt_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
70  | 
apply (rule_tac x = "ca * c" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
71  | 
apply (rule conjI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
72  | 
apply (rule mult_pos_pos)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
73  | 
apply (assumption)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
74  | 
apply (rule allI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
75  | 
apply (drule_tac x = "xa" in spec)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
76  | 
apply (subgoal_tac "ca * abs(f xa) <= ca * (c * abs(g xa))")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
77  | 
apply (erule order_trans)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
78  | 
apply (simp add: mult_ac)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
79  | 
apply (rule mult_left_mono, assumption)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
80  | 
apply (rule order_less_imp_le, assumption)  | 
| 22665 | 81  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
82  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
83  | 
lemma bigo_refl [intro]: "f : O(f)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
84  | 
apply(auto simp add: bigo_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
85  | 
apply(rule_tac x = 1 in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
86  | 
apply simp  | 
| 22665 | 87  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
88  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
89  | 
lemma bigo_zero: "0 : O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
90  | 
apply (auto simp add: bigo_def func_zero)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
91  | 
apply (rule_tac x = 0 in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
92  | 
apply auto  | 
| 22665 | 93  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
94  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
95  | 
lemma bigo_zero2: "O(%x.0) = {%x.0}"
 | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
96  | 
apply (auto simp add: bigo_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
97  | 
apply (rule ext)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
98  | 
apply auto  | 
| 22665 | 99  | 
done  | 
| 
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 bigo_plus_self_subset [intro]:  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
102  | 
"O(f) \<oplus> O(f) <= O(f)"  | 
| 
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
103  | 
apply (auto simp add: bigo_alt_def set_plus_def)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
104  | 
apply (rule_tac x = "c + ca" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
105  | 
apply auto  | 
| 
23477
 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 
nipkow 
parents: 
23413 
diff
changeset
 | 
106  | 
apply (simp add: ring_distribs func_plus)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
107  | 
apply (rule order_trans)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
108  | 
apply (rule abs_triangle_ineq)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
109  | 
apply (rule add_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
110  | 
apply force  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
111  | 
apply force  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
112  | 
done  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
113  | 
|
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
114  | 
lemma bigo_plus_idemp [simp]: "O(f) \<oplus> O(f) = O(f)"  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
115  | 
apply (rule equalityI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
116  | 
apply (rule bigo_plus_self_subset)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
117  | 
apply (rule set_zero_plus2)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
118  | 
apply (rule bigo_zero)  | 
| 22665 | 119  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
120  | 
|
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
121  | 
lemma bigo_plus_subset [intro]: "O(f + g) <= O(f) \<oplus> O(g)"  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
122  | 
apply (rule subsetI)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
123  | 
apply (auto simp add: bigo_def bigo_pos_const func_plus set_plus_def)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
124  | 
apply (subst bigo_pos_const [symmetric])+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
125  | 
apply (rule_tac x =  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
126  | 
"%n. if abs (g n) <= (abs (f n)) then x n else 0" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
127  | 
apply (rule conjI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
128  | 
apply (rule_tac x = "c + c" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
129  | 
apply (clarsimp)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
130  | 
apply (auto)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
131  | 
apply (subgoal_tac "c * abs (f xa + g xa) <= (c + c) * abs (f xa)")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
132  | 
apply (erule_tac x = xa in allE)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
133  | 
apply (erule order_trans)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
134  | 
apply (simp)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
135  | 
apply (subgoal_tac "c * abs (f xa + g xa) <= c * (abs (f xa) + abs (g xa))")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
136  | 
apply (erule order_trans)  | 
| 
23477
 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 
nipkow 
parents: 
23413 
diff
changeset
 | 
137  | 
apply (simp add: ring_distribs)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
138  | 
apply (rule mult_left_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
139  | 
apply assumption  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
140  | 
apply (simp add: order_less_le)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
141  | 
apply (rule mult_left_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
142  | 
apply (simp add: abs_triangle_ineq)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
143  | 
apply (simp add: order_less_le)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
144  | 
apply (rule mult_nonneg_nonneg)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
145  | 
apply (rule add_nonneg_nonneg)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
146  | 
apply auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
147  | 
apply (rule_tac x = "%n. if (abs (f n)) < abs (g n) then x n else 0"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
148  | 
in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
149  | 
apply (rule conjI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
150  | 
apply (rule_tac x = "c + c" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
151  | 
apply auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
152  | 
apply (subgoal_tac "c * abs (f xa + g xa) <= (c + c) * abs (g xa)")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
153  | 
apply (erule_tac x = xa in allE)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
154  | 
apply (erule order_trans)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
155  | 
apply (simp)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
156  | 
apply (subgoal_tac "c * abs (f xa + g xa) <= c * (abs (f xa) + abs (g xa))")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
157  | 
apply (erule order_trans)  | 
| 
23477
 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 
nipkow 
parents: 
23413 
diff
changeset
 | 
158  | 
apply (simp add: ring_distribs)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
159  | 
apply (rule mult_left_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
160  | 
apply (simp add: order_less_le)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
161  | 
apply (simp add: order_less_le)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
162  | 
apply (rule mult_left_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
163  | 
apply (rule abs_triangle_ineq)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
164  | 
apply (simp add: order_less_le)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
165  | 
apply (rule mult_nonneg_nonneg)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
166  | 
apply (rule add_nonneg_nonneg)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
167  | 
apply (erule order_less_imp_le)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
168  | 
apply simp  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
169  | 
apply (rule ext)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
170  | 
apply (auto simp add: if_splits linorder_not_le)  | 
| 22665 | 171  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
172  | 
|
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
173  | 
lemma bigo_plus_subset2 [intro]: "A <= O(f) ==> B <= O(f) ==> A \<oplus> B <= O(f)"  | 
| 
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
174  | 
apply (subgoal_tac "A \<oplus> B <= O(f) \<oplus> O(f)")  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
175  | 
apply (erule order_trans)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
176  | 
apply simp  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
177  | 
apply (auto del: subsetI simp del: bigo_plus_idemp)  | 
| 22665 | 178  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
179  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
180  | 
lemma bigo_plus_eq: "ALL x. 0 <= f x ==> ALL x. 0 <= g x ==>  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
181  | 
O(f + g) = O(f) \<oplus> O(g)"  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
182  | 
apply (rule equalityI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
183  | 
apply (rule bigo_plus_subset)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
184  | 
apply (simp add: bigo_alt_def set_plus_def func_plus)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
185  | 
apply clarify  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
186  | 
apply (rule_tac x = "max c ca" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
187  | 
apply (rule conjI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
188  | 
apply (subgoal_tac "c <= max c ca")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
189  | 
apply (erule order_less_le_trans)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
190  | 
apply assumption  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
191  | 
apply (rule le_maxI1)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
192  | 
apply clarify  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
193  | 
apply (drule_tac x = "xa" in spec)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
194  | 
apply (subgoal_tac "0 <= f xa + g xa")  | 
| 
23477
 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 
nipkow 
parents: 
23413 
diff
changeset
 | 
195  | 
apply (simp add: ring_distribs)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
196  | 
apply (subgoal_tac "abs(a xa + b xa) <= abs(a xa) + abs(b xa)")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
197  | 
apply (subgoal_tac "abs(a xa) + abs(b xa) <=  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
198  | 
max c ca * f xa + max c ca * g xa")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
199  | 
apply (force)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
200  | 
apply (rule add_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
201  | 
apply (subgoal_tac "c * f xa <= max c ca * f xa")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
202  | 
apply (force)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
203  | 
apply (rule mult_right_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
204  | 
apply (rule le_maxI1)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
205  | 
apply assumption  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
206  | 
apply (subgoal_tac "ca * g xa <= max c ca * g xa")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
207  | 
apply (force)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
208  | 
apply (rule mult_right_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
209  | 
apply (rule le_maxI2)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
210  | 
apply assumption  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
211  | 
apply (rule abs_triangle_ineq)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
212  | 
apply (rule add_nonneg_nonneg)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
213  | 
apply assumption+  | 
| 22665 | 214  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
215  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
216  | 
lemma bigo_bounded_alt: "ALL x. 0 <= f x ==> ALL x. f x <= c * g x ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
217  | 
f : O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
218  | 
apply (auto simp add: bigo_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
219  | 
apply (rule_tac x = "abs c" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
220  | 
apply auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
221  | 
apply (drule_tac x = x in spec)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
222  | 
apply (simp add: abs_mult [symmetric])  | 
| 22665 | 223  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
224  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
225  | 
lemma bigo_bounded: "ALL x. 0 <= f x ==> ALL x. f x <= g x ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
226  | 
f : O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
227  | 
apply (erule bigo_bounded_alt [of f 1 g])  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
228  | 
apply simp  | 
| 22665 | 229  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
230  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
231  | 
lemma bigo_bounded2: "ALL x. lb x <= f x ==> ALL x. f x <= lb x + g x ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
232  | 
f : lb +o O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
233  | 
apply (rule set_minus_imp_plus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
234  | 
apply (rule bigo_bounded)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
235  | 
apply (auto simp add: diff_minus fun_Compl_def func_plus)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
236  | 
apply (drule_tac x = x in spec)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
237  | 
apply force  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
238  | 
apply (drule_tac x = x in spec)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
239  | 
apply force  | 
| 22665 | 240  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
241  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
242  | 
lemma bigo_abs: "(%x. abs(f x)) =o O(f)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
243  | 
apply (unfold bigo_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
244  | 
apply auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
245  | 
apply (rule_tac x = 1 in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
246  | 
apply auto  | 
| 22665 | 247  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
248  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
249  | 
lemma bigo_abs2: "f =o O(%x. abs(f x))"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
250  | 
apply (unfold bigo_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
251  | 
apply auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
252  | 
apply (rule_tac x = 1 in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
253  | 
apply auto  | 
| 22665 | 254  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
255  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
256  | 
lemma bigo_abs3: "O(f) = O(%x. abs(f x))"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
257  | 
apply (rule equalityI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
258  | 
apply (rule bigo_elt_subset)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
259  | 
apply (rule bigo_abs2)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
260  | 
apply (rule bigo_elt_subset)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
261  | 
apply (rule bigo_abs)  | 
| 22665 | 262  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
263  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
264  | 
lemma bigo_abs4: "f =o g +o O(h) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
265  | 
(%x. abs (f x)) =o (%x. abs (g x)) +o O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
266  | 
apply (drule set_plus_imp_minus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
267  | 
apply (rule set_minus_imp_plus)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
268  | 
apply (subst fun_diff_def)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
269  | 
proof -  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
270  | 
assume a: "f - g : O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
271  | 
have "(%x. abs (f x) - abs (g x)) =o O(%x. abs(abs (f x) - abs (g x)))"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
272  | 
by (rule bigo_abs2)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
273  | 
also have "... <= O(%x. abs (f x - g x))"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
274  | 
apply (rule bigo_elt_subset)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
275  | 
apply (rule bigo_bounded)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
276  | 
apply force  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
277  | 
apply (rule allI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
278  | 
apply (rule abs_triangle_ineq3)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
279  | 
done  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
280  | 
also have "... <= O(f - g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
281  | 
apply (rule bigo_elt_subset)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
282  | 
apply (subst fun_diff_def)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
283  | 
apply (rule bigo_abs)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
284  | 
done  | 
| 23373 | 285  | 
also from a have "... <= O(h)"  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
286  | 
by (rule bigo_elt_subset)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
287  | 
finally show "(%x. abs (f x) - abs (g x)) : O(h)".  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
288  | 
qed  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
289  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
290  | 
lemma bigo_abs5: "f =o O(g) ==> (%x. abs(f x)) =o O(g)"  | 
| 22665 | 291  | 
by (unfold bigo_def, auto)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
292  | 
|
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
293  | 
lemma bigo_elt_subset2 [intro]: "f : g +o O(h) ==> O(f) <= O(g) \<oplus> O(h)"  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
294  | 
proof -  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
295  | 
assume "f : g +o O(h)"  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
296  | 
also have "... <= O(g) \<oplus> O(h)"  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
297  | 
by (auto del: subsetI)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
298  | 
also have "... = O(%x. abs(g x)) \<oplus> O(%x. abs(h x))"  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
299  | 
apply (subst bigo_abs3 [symmetric])+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
300  | 
apply (rule refl)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
301  | 
done  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
302  | 
also have "... = O((%x. abs(g x)) + (%x. abs(h x)))"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
303  | 
by (rule bigo_plus_eq [symmetric], auto)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
304  | 
finally have "f : ...".  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
305  | 
then have "O(f) <= ..."  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
306  | 
by (elim bigo_elt_subset)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
307  | 
also have "... = O(%x. abs(g x)) \<oplus> O(%x. abs(h x))"  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
308  | 
by (rule bigo_plus_eq, auto)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
309  | 
finally show ?thesis  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
310  | 
by (simp add: bigo_abs3 [symmetric])  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
311  | 
qed  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
312  | 
|
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
313  | 
lemma bigo_mult [intro]: "O(f)\<otimes>O(g) <= O(f * g)"  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
314  | 
apply (rule subsetI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
315  | 
apply (subst bigo_def)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
316  | 
apply (auto simp add: bigo_alt_def set_times_def func_times)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
317  | 
apply (rule_tac x = "c * ca" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
318  | 
apply(rule allI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
319  | 
apply(erule_tac x = x in allE)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
320  | 
apply(subgoal_tac "c * ca * abs(f x * g x) =  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
321  | 
(c * abs(f x)) * (ca * abs(g x))")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
322  | 
apply(erule ssubst)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
323  | 
apply (subst abs_mult)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
324  | 
apply (rule mult_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
325  | 
apply assumption+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
326  | 
apply (rule mult_nonneg_nonneg)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
327  | 
apply auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
328  | 
apply (simp add: mult_ac abs_mult)  | 
| 22665 | 329  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
330  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
331  | 
lemma bigo_mult2 [intro]: "f *o O(g) <= O(f * g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
332  | 
apply (auto simp add: bigo_def elt_set_times_def func_times abs_mult)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
333  | 
apply (rule_tac x = c in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
334  | 
apply auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
335  | 
apply (drule_tac x = x in spec)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
336  | 
apply (subgoal_tac "abs(f x) * abs(b x) <= abs(f x) * (c * abs(g x))")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
337  | 
apply (force simp add: mult_ac)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
338  | 
apply (rule mult_left_mono, assumption)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
339  | 
apply (rule abs_ge_zero)  | 
| 22665 | 340  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
341  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
342  | 
lemma bigo_mult3: "f : O(h) ==> g : O(j) ==> f * g : O(h * j)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
343  | 
apply (rule subsetD)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
344  | 
apply (rule bigo_mult)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
345  | 
apply (erule set_times_intro, assumption)  | 
| 22665 | 346  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
347  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
348  | 
lemma bigo_mult4 [intro]:"f : k +o O(h) ==> g * f : (g * k) +o O(g * h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
349  | 
apply (drule set_plus_imp_minus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
350  | 
apply (rule set_minus_imp_plus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
351  | 
apply (drule bigo_mult3 [where g = g and j = g])  | 
| 
23477
 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 
nipkow 
parents: 
23413 
diff
changeset
 | 
352  | 
apply (auto simp add: ring_simps)  | 
| 22665 | 353  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
354  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
355  | 
lemma bigo_mult5: "ALL x. f x ~= 0 ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
356  | 
    O(f * g) <= (f::'a => ('b::ordered_field)) *o O(g)"
 | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
357  | 
proof -  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
358  | 
assume "ALL x. f x ~= 0"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
359  | 
show "O(f * g) <= f *o O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
360  | 
proof  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
361  | 
fix h  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
362  | 
assume "h : O(f * g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
363  | 
then have "(%x. 1 / (f x)) * h : (%x. 1 / f x) *o O(f * g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
364  | 
by auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
365  | 
also have "... <= O((%x. 1 / f x) * (f * g))"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
366  | 
by (rule bigo_mult2)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
367  | 
also have "(%x. 1 / f x) * (f * g) = g"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
368  | 
apply (simp add: func_times)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
369  | 
apply (rule ext)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
370  | 
apply (simp add: prems nonzero_divide_eq_eq mult_ac)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
371  | 
done  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
372  | 
finally have "(%x. (1::'b) / f x) * h : O(g)".  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
373  | 
then have "f * ((%x. (1::'b) / f x) * h) : f *o O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
374  | 
by auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
375  | 
also have "f * ((%x. (1::'b) / f x) * h) = h"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
376  | 
apply (simp add: func_times)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
377  | 
apply (rule ext)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
378  | 
apply (simp add: prems nonzero_divide_eq_eq mult_ac)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
379  | 
done  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
380  | 
finally show "h : f *o O(g)".  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
381  | 
qed  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
382  | 
qed  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
383  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
384  | 
lemma bigo_mult6: "ALL x. f x ~= 0 ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
385  | 
    O(f * g) = (f::'a => ('b::ordered_field)) *o O(g)"
 | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
386  | 
apply (rule equalityI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
387  | 
apply (erule bigo_mult5)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
388  | 
apply (rule bigo_mult2)  | 
| 22665 | 389  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
390  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
391  | 
lemma bigo_mult7: "ALL x. f x ~= 0 ==>  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
392  | 
    O(f * g) <= O(f::'a => ('b::ordered_field)) \<otimes> O(g)"
 | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
393  | 
apply (subst bigo_mult6)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
394  | 
apply assumption  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
395  | 
apply (rule set_times_mono3)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
396  | 
apply (rule bigo_refl)  | 
| 22665 | 397  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
398  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
399  | 
lemma bigo_mult8: "ALL x. f x ~= 0 ==>  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
400  | 
    O(f * g) = O(f::'a => ('b::ordered_field)) \<otimes> O(g)"
 | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
401  | 
apply (rule equalityI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
402  | 
apply (erule bigo_mult7)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
403  | 
apply (rule bigo_mult)  | 
| 22665 | 404  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
405  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
406  | 
lemma bigo_minus [intro]: "f : O(g) ==> - f : O(g)"  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
407  | 
by (auto simp add: bigo_def fun_Compl_def)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
408  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
409  | 
lemma bigo_minus2: "f : g +o O(h) ==> -f : -g +o O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
410  | 
apply (rule set_minus_imp_plus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
411  | 
apply (drule set_plus_imp_minus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
412  | 
apply (drule bigo_minus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
413  | 
apply (simp add: diff_minus)  | 
| 22665 | 414  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
415  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
416  | 
lemma bigo_minus3: "O(-f) = O(f)"  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
417  | 
by (auto simp add: bigo_def fun_Compl_def abs_minus_cancel)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
418  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
419  | 
lemma bigo_plus_absorb_lemma1: "f : O(g) ==> f +o O(g) <= O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
420  | 
proof -  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
421  | 
assume a: "f : O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
422  | 
show "f +o O(g) <= O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
423  | 
proof -  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
424  | 
have "f : O(f)" by auto  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
425  | 
then have "f +o O(g) <= O(f) \<oplus> O(g)"  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
426  | 
by (auto del: subsetI)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
427  | 
also have "... <= O(g) \<oplus> O(g)"  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
428  | 
proof -  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
429  | 
from a have "O(f) <= O(g)" by (auto del: subsetI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
430  | 
thus ?thesis by (auto del: subsetI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
431  | 
qed  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
432  | 
also have "... <= O(g)" by (simp add: bigo_plus_idemp)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
433  | 
finally show ?thesis .  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
434  | 
qed  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
435  | 
qed  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
436  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
437  | 
lemma bigo_plus_absorb_lemma2: "f : O(g) ==> O(g) <= f +o O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
438  | 
proof -  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
439  | 
assume a: "f : O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
440  | 
show "O(g) <= f +o O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
441  | 
proof -  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
442  | 
from a have "-f : O(g)" by auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
443  | 
then have "-f +o O(g) <= O(g)" by (elim bigo_plus_absorb_lemma1)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
444  | 
then have "f +o (-f +o O(g)) <= f +o O(g)" by auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
445  | 
also have "f +o (-f +o O(g)) = O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
446  | 
by (simp add: set_plus_rearranges)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
447  | 
finally show ?thesis .  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
448  | 
qed  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
449  | 
qed  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
450  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
451  | 
lemma bigo_plus_absorb [simp]: "f : O(g) ==> f +o O(g) = O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
452  | 
apply (rule equalityI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
453  | 
apply (erule bigo_plus_absorb_lemma1)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
454  | 
apply (erule bigo_plus_absorb_lemma2)  | 
| 22665 | 455  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
456  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
457  | 
lemma bigo_plus_absorb2 [intro]: "f : O(g) ==> A <= O(g) ==> f +o A <= O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
458  | 
apply (subgoal_tac "f +o A <= f +o O(g)")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
459  | 
apply force+  | 
| 22665 | 460  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
461  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
462  | 
lemma bigo_add_commute_imp: "f : g +o O(h) ==> g : f +o O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
463  | 
apply (subst set_minus_plus [symmetric])  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
464  | 
apply (subgoal_tac "g - f = - (f - g)")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
465  | 
apply (erule ssubst)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
466  | 
apply (rule bigo_minus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
467  | 
apply (subst set_minus_plus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
468  | 
apply assumption  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
469  | 
apply (simp add: diff_minus add_ac)  | 
| 22665 | 470  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
471  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
472  | 
lemma bigo_add_commute: "(f : g +o O(h)) = (g : f +o O(h))"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
473  | 
apply (rule iffI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
474  | 
apply (erule bigo_add_commute_imp)+  | 
| 22665 | 475  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
476  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
477  | 
lemma bigo_const1: "(%x. c) : O(%x. 1)"  | 
| 22665 | 478  | 
by (auto simp add: bigo_def mult_ac)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
479  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
480  | 
lemma bigo_const2 [intro]: "O(%x. c) <= O(%x. 1)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
481  | 
apply (rule bigo_elt_subset)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
482  | 
apply (rule bigo_const1)  | 
| 22665 | 483  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
484  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
485  | 
lemma bigo_const3: "(c::'a::ordered_field) ~= 0 ==> (%x. 1) : O(%x. c)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
486  | 
apply (simp add: bigo_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
487  | 
apply (rule_tac x = "abs(inverse c)" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
488  | 
apply (simp add: abs_mult [symmetric])  | 
| 22665 | 489  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
490  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
491  | 
lemma bigo_const4: "(c::'a::ordered_field) ~= 0 ==> O(%x. 1) <= O(%x. c)"  | 
| 22665 | 492  | 
by (rule bigo_elt_subset, rule bigo_const3, assumption)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
493  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
494  | 
lemma bigo_const [simp]: "(c::'a::ordered_field) ~= 0 ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
495  | 
O(%x. c) = O(%x. 1)"  | 
| 22665 | 496  | 
by (rule equalityI, rule bigo_const2, rule bigo_const4, assumption)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
497  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
498  | 
lemma bigo_const_mult1: "(%x. c * f x) : O(f)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
499  | 
apply (simp add: bigo_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
500  | 
apply (rule_tac x = "abs(c)" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
501  | 
apply (auto simp add: abs_mult [symmetric])  | 
| 22665 | 502  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
503  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
504  | 
lemma bigo_const_mult2: "O(%x. c * f x) <= O(f)"  | 
| 22665 | 505  | 
by (rule bigo_elt_subset, rule bigo_const_mult1)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
506  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
507  | 
lemma bigo_const_mult3: "(c::'a::ordered_field) ~= 0 ==> f : O(%x. c * f x)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
508  | 
apply (simp add: bigo_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
509  | 
apply (rule_tac x = "abs(inverse c)" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
510  | 
apply (simp add: abs_mult [symmetric] mult_assoc [symmetric])  | 
| 22665 | 511  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
512  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
513  | 
lemma bigo_const_mult4: "(c::'a::ordered_field) ~= 0 ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
514  | 
O(f) <= O(%x. c * f x)"  | 
| 22665 | 515  | 
by (rule bigo_elt_subset, rule bigo_const_mult3, assumption)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
516  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
517  | 
lemma bigo_const_mult [simp]: "(c::'a::ordered_field) ~= 0 ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
518  | 
O(%x. c * f x) = O(f)"  | 
| 22665 | 519  | 
by (rule equalityI, rule bigo_const_mult2, erule bigo_const_mult4)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
520  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
521  | 
lemma bigo_const_mult5 [simp]: "(c::'a::ordered_field) ~= 0 ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
522  | 
(%x. c) *o O(f) = O(f)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
523  | 
apply (auto del: subsetI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
524  | 
apply (rule order_trans)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
525  | 
apply (rule bigo_mult2)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
526  | 
apply (simp add: func_times)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
527  | 
apply (auto intro!: subsetI simp add: bigo_def elt_set_times_def func_times)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
528  | 
apply (rule_tac x = "%y. inverse c * x y" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
529  | 
apply (simp add: mult_assoc [symmetric] abs_mult)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
530  | 
apply (rule_tac x = "abs (inverse c) * ca" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
531  | 
apply (rule allI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
532  | 
apply (subst mult_assoc)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
533  | 
apply (rule mult_left_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
534  | 
apply (erule spec)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
535  | 
apply force  | 
| 22665 | 536  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
537  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
538  | 
lemma bigo_const_mult6 [intro]: "(%x. c) *o O(f) <= O(f)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
539  | 
apply (auto intro!: subsetI  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
540  | 
simp add: bigo_def elt_set_times_def func_times)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
541  | 
apply (rule_tac x = "ca * (abs c)" in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
542  | 
apply (rule allI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
543  | 
apply (subgoal_tac "ca * abs(c) * abs(f x) = abs(c) * (ca * abs(f x))")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
544  | 
apply (erule ssubst)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
545  | 
apply (subst abs_mult)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
546  | 
apply (rule mult_left_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
547  | 
apply (erule spec)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
548  | 
apply simp  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
549  | 
apply(simp add: mult_ac)  | 
| 22665 | 550  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
551  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
552  | 
lemma bigo_const_mult7 [intro]: "f =o O(g) ==> (%x. c * f x) =o O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
553  | 
proof -  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
554  | 
assume "f =o O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
555  | 
then have "(%x. c) * f =o (%x. c) *o O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
556  | 
by auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
557  | 
also have "(%x. c) * f = (%x. c * f x)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
558  | 
by (simp add: func_times)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
559  | 
also have "(%x. c) *o O(g) <= O(g)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
560  | 
by (auto del: subsetI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
561  | 
finally show ?thesis .  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
562  | 
qed  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
563  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
564  | 
lemma bigo_compose1: "f =o O(g) ==> (%x. f(k x)) =o O(%x. g(k x))"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
565  | 
by (unfold bigo_def, auto)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
566  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
567  | 
lemma bigo_compose2: "f =o g +o O(h) ==> (%x. f(k x)) =o (%x. g(k x)) +o  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
568  | 
O(%x. h(k x))"  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
569  | 
apply (simp only: set_minus_plus [symmetric] diff_minus fun_Compl_def  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
570  | 
func_plus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
571  | 
apply (erule bigo_compose1)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
572  | 
done  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
573  | 
|
| 22665 | 574  | 
|
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
575  | 
subsection {* Setsum *}
 | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
576  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
577  | 
lemma bigo_setsum_main: "ALL x. ALL y : A x. 0 <= h x y ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
578  | 
EX c. ALL x. ALL y : A x. abs(f x y) <= c * (h x y) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
579  | 
(%x. SUM y : A x. f x y) =o O(%x. SUM y : A x. h x y)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
580  | 
apply (auto simp add: bigo_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
581  | 
apply (rule_tac x = "abs c" in exI)  | 
| 
17199
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
582  | 
apply (subst abs_of_nonneg) back back  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
583  | 
apply (rule setsum_nonneg)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
584  | 
apply force  | 
| 19279 | 585  | 
apply (subst setsum_right_distrib)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
586  | 
apply (rule allI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
587  | 
apply (rule order_trans)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
588  | 
apply (rule setsum_abs)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
589  | 
apply (rule setsum_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
590  | 
apply (rule order_trans)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
591  | 
apply (drule spec)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
592  | 
apply (drule bspec)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
593  | 
apply assumption+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
594  | 
apply (drule bspec)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
595  | 
apply assumption+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
596  | 
apply (rule mult_right_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
597  | 
apply (rule abs_ge_self)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
598  | 
apply force  | 
| 22665 | 599  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
600  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
601  | 
lemma bigo_setsum1: "ALL x y. 0 <= h x y ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
602  | 
EX c. ALL x y. abs(f x y) <= c * (h x y) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
603  | 
(%x. SUM y : A x. f x y) =o O(%x. SUM y : A x. h x y)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
604  | 
apply (rule bigo_setsum_main)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
605  | 
apply force  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
606  | 
apply clarsimp  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
607  | 
apply (rule_tac x = c in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
608  | 
apply force  | 
| 22665 | 609  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
610  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
611  | 
lemma bigo_setsum2: "ALL y. 0 <= h y ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
612  | 
EX c. ALL y. abs(f y) <= c * (h y) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
613  | 
(%x. SUM y : A x. f y) =o O(%x. SUM y : A x. h y)"  | 
| 22665 | 614  | 
by (rule bigo_setsum1, auto)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
615  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
616  | 
lemma bigo_setsum3: "f =o O(h) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
617  | 
(%x. SUM y : A x. (l x y) * f(k x y)) =o  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
618  | 
O(%x. SUM y : A x. abs(l x y * h(k x y)))"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
619  | 
apply (rule bigo_setsum1)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
620  | 
apply (rule allI)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
621  | 
apply (rule abs_ge_zero)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
622  | 
apply (unfold bigo_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
623  | 
apply auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
624  | 
apply (rule_tac x = c in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
625  | 
apply (rule allI)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
626  | 
apply (subst abs_mult)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
627  | 
apply (subst mult_left_commute)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
628  | 
apply (rule mult_left_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
629  | 
apply (erule spec)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
630  | 
apply (rule abs_ge_zero)  | 
| 22665 | 631  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
632  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
633  | 
lemma bigo_setsum4: "f =o g +o O(h) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
634  | 
(%x. SUM y : A x. l x y * f(k x y)) =o  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
635  | 
(%x. SUM y : A x. l x y * g(k x y)) +o  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
636  | 
O(%x. SUM y : A x. abs(l x y * h(k x y)))"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
637  | 
apply (rule set_minus_imp_plus)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
638  | 
apply (subst fun_diff_def)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
639  | 
apply (subst setsum_subtractf [symmetric])  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
640  | 
apply (subst right_diff_distrib [symmetric])  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
641  | 
apply (rule bigo_setsum3)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
642  | 
apply (subst fun_diff_def [symmetric])  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
643  | 
apply (erule set_plus_imp_minus)  | 
| 22665 | 644  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
645  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
646  | 
lemma bigo_setsum5: "f =o O(h) ==> ALL x y. 0 <= l x y ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
647  | 
ALL x. 0 <= h x ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
648  | 
(%x. SUM y : A x. (l x y) * f(k x y)) =o  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
649  | 
O(%x. SUM y : A x. (l x y) * h(k x y))"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
650  | 
apply (subgoal_tac "(%x. SUM y : A x. (l x y) * h(k x y)) =  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
651  | 
(%x. SUM y : A x. abs((l x y) * h(k x y)))")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
652  | 
apply (erule ssubst)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
653  | 
apply (erule bigo_setsum3)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
654  | 
apply (rule ext)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
655  | 
apply (rule setsum_cong2)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
656  | 
apply (subst abs_of_nonneg)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
657  | 
apply (rule mult_nonneg_nonneg)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
658  | 
apply auto  | 
| 22665 | 659  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
660  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
661  | 
lemma bigo_setsum6: "f =o g +o O(h) ==> ALL x y. 0 <= l x y ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
662  | 
ALL x. 0 <= h x ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
663  | 
(%x. SUM y : A x. (l x y) * f(k x y)) =o  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
664  | 
(%x. SUM y : A x. (l x y) * g(k x y)) +o  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
665  | 
O(%x. SUM y : A x. (l x y) * h(k x y))"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
666  | 
apply (rule set_minus_imp_plus)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
667  | 
apply (subst fun_diff_def)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
668  | 
apply (subst setsum_subtractf [symmetric])  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
669  | 
apply (subst right_diff_distrib [symmetric])  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
670  | 
apply (rule bigo_setsum5)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
671  | 
apply (subst fun_diff_def [symmetric])  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
672  | 
apply (drule set_plus_imp_minus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
673  | 
apply auto  | 
| 22665 | 674  | 
done  | 
675  | 
||
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
676  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
677  | 
subsection {* Misc useful stuff *}
 | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
678  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
679  | 
lemma bigo_useful_intro: "A <= O(f) ==> B <= O(f) ==>  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
680  | 
A \<oplus> B <= O(f)"  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
681  | 
apply (subst bigo_plus_idemp [symmetric])  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
682  | 
apply (rule set_plus_mono2)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
683  | 
apply assumption+  | 
| 22665 | 684  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
685  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
686  | 
lemma bigo_useful_add: "f =o O(h) ==> g =o O(h) ==> f + g =o O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
687  | 
apply (subst bigo_plus_idemp [symmetric])  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
688  | 
apply (rule set_plus_intro)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
689  | 
apply assumption+  | 
| 22665 | 690  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
691  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
692  | 
lemma bigo_useful_const_mult: "(c::'a::ordered_field) ~= 0 ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
693  | 
(%x. c) * f =o O(h) ==> f =o O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
694  | 
apply (rule subsetD)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
695  | 
apply (subgoal_tac "(%x. 1 / c) *o O(h) <= O(h)")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
696  | 
apply assumption  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
697  | 
apply (rule bigo_const_mult6)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
698  | 
apply (subgoal_tac "f = (%x. 1 / c) * ((%x. c) * f)")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
699  | 
apply (erule ssubst)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
700  | 
apply (erule set_times_intro2)  | 
| 
23413
 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 
nipkow 
parents: 
23373 
diff
changeset
 | 
701  | 
apply (simp add: func_times)  | 
| 22665 | 702  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
703  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
704  | 
lemma bigo_fix: "(%x. f ((x::nat) + 1)) =o O(%x. h(x + 1)) ==> f 0 = 0 ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
705  | 
f =o O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
706  | 
apply (simp add: bigo_alt_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
707  | 
apply auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
708  | 
apply (rule_tac x = c in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
709  | 
apply auto  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
710  | 
apply (case_tac "x = 0")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
711  | 
apply simp  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
712  | 
apply (rule mult_nonneg_nonneg)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
713  | 
apply force  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
714  | 
apply force  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
715  | 
apply (subgoal_tac "x = Suc (x - 1)")  | 
| 
17199
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
716  | 
apply (erule ssubst) back  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
717  | 
apply (erule spec)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
718  | 
apply simp  | 
| 22665 | 719  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
720  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
721  | 
lemma bigo_fix2:  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
722  | 
"(%x. f ((x::nat) + 1)) =o (%x. g(x + 1)) +o O(%x. h(x + 1)) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
723  | 
f 0 = g 0 ==> f =o g +o O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
724  | 
apply (rule set_minus_imp_plus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
725  | 
apply (rule bigo_fix)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
726  | 
apply (subst fun_diff_def)  | 
| 
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
727  | 
apply (subst fun_diff_def [symmetric])  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
728  | 
apply (rule set_plus_imp_minus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
729  | 
apply simp  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
730  | 
apply (simp add: fun_diff_def)  | 
| 22665 | 731  | 
done  | 
732  | 
||
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
733  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
734  | 
subsection {* Less than or equal to *}
 | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
735  | 
|
| 19736 | 736  | 
definition  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
737  | 
  lesso :: "('a => 'b::ordered_idom) => ('a => 'b) => ('a => 'b)"
 | 
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19736 
diff
changeset
 | 
738  | 
(infixl "<o" 70) where  | 
| 19736 | 739  | 
"f <o g = (%x. max (f x - g x) 0)"  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
740  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
741  | 
lemma bigo_lesseq1: "f =o O(h) ==> ALL x. abs (g x) <= abs (f x) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
742  | 
g =o O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
743  | 
apply (unfold bigo_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
744  | 
apply clarsimp  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
745  | 
apply (rule_tac x = c in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
746  | 
apply (rule allI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
747  | 
apply (rule order_trans)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
748  | 
apply (erule spec)+  | 
| 22665 | 749  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
750  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
751  | 
lemma bigo_lesseq2: "f =o O(h) ==> ALL x. abs (g x) <= f x ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
752  | 
g =o O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
753  | 
apply (erule bigo_lesseq1)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
754  | 
apply (rule allI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
755  | 
apply (drule_tac x = x in spec)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
756  | 
apply (rule order_trans)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
757  | 
apply assumption  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
758  | 
apply (rule abs_ge_self)  | 
| 22665 | 759  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
760  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
761  | 
lemma bigo_lesseq3: "f =o O(h) ==> ALL x. 0 <= g x ==> ALL x. g x <= f x ==>  | 
| 22665 | 762  | 
g =o O(h)"  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
763  | 
apply (erule bigo_lesseq2)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
764  | 
apply (rule allI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
765  | 
apply (subst abs_of_nonneg)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
766  | 
apply (erule spec)+  | 
| 22665 | 767  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
768  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
769  | 
lemma bigo_lesseq4: "f =o O(h) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
770  | 
ALL x. 0 <= g x ==> ALL x. g x <= abs (f x) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
771  | 
g =o O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
772  | 
apply (erule bigo_lesseq1)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
773  | 
apply (rule allI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
774  | 
apply (subst abs_of_nonneg)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
775  | 
apply (erule spec)+  | 
| 22665 | 776  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
777  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
778  | 
lemma bigo_lesso1: "ALL x. f x <= g x ==> f <o g =o O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
779  | 
apply (unfold lesso_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
780  | 
apply (subgoal_tac "(%x. max (f x - g x) 0) = 0")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
781  | 
apply (erule ssubst)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
782  | 
apply (rule bigo_zero)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
783  | 
apply (unfold func_zero)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
784  | 
apply (rule ext)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
785  | 
apply (simp split: split_max)  | 
| 22665 | 786  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
787  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
788  | 
lemma bigo_lesso2: "f =o g +o O(h) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
789  | 
ALL x. 0 <= k x ==> ALL x. k x <= f x ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
790  | 
k <o g =o O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
791  | 
apply (unfold lesso_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
792  | 
apply (rule bigo_lesseq4)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
793  | 
apply (erule set_plus_imp_minus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
794  | 
apply (rule allI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
795  | 
apply (rule le_maxI2)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
796  | 
apply (rule allI)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
797  | 
apply (subst fun_diff_def)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
798  | 
apply (case_tac "0 <= k x - g x")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
799  | 
apply simp  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
800  | 
apply (subst abs_of_nonneg)  | 
| 
17199
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
801  | 
apply (drule_tac x = x in spec) back  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
802  | 
apply (simp add: compare_rls)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
803  | 
apply (subst diff_minus)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
804  | 
apply (rule add_right_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
805  | 
apply (erule spec)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
806  | 
apply (rule order_trans)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
807  | 
prefer 2  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
808  | 
apply (rule abs_ge_zero)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
809  | 
apply (simp add: compare_rls)  | 
| 22665 | 810  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
811  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
812  | 
lemma bigo_lesso3: "f =o g +o O(h) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
813  | 
ALL x. 0 <= k x ==> ALL x. g x <= k x ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
814  | 
f <o k =o O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
815  | 
apply (unfold lesso_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
816  | 
apply (rule bigo_lesseq4)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
817  | 
apply (erule set_plus_imp_minus)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
818  | 
apply (rule allI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
819  | 
apply (rule le_maxI2)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
820  | 
apply (rule allI)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
821  | 
apply (subst fun_diff_def)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
822  | 
apply (case_tac "0 <= f x - k x")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
823  | 
apply simp  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
824  | 
apply (subst abs_of_nonneg)  | 
| 
17199
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
825  | 
apply (drule_tac x = x in spec) back  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
826  | 
apply (simp add: compare_rls)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
827  | 
apply (subst diff_minus)+  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
828  | 
apply (rule add_left_mono)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
829  | 
apply (rule le_imp_neg_le)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
830  | 
apply (erule spec)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
831  | 
apply (rule order_trans)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
832  | 
prefer 2  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
833  | 
apply (rule abs_ge_zero)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
834  | 
apply (simp add: compare_rls)  | 
| 22665 | 835  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
836  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
837  | 
lemma bigo_lesso4: "f <o g =o O(k::'a=>'b::ordered_field) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
838  | 
g =o h +o O(k) ==> f <o h =o O(k)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
839  | 
apply (unfold lesso_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
840  | 
apply (drule set_plus_imp_minus)  | 
| 
17199
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
841  | 
apply (drule bigo_abs5) back  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
842  | 
apply (simp add: fun_diff_def)  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
843  | 
apply (drule bigo_useful_add)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
844  | 
apply assumption  | 
| 
17199
 
59c1bfc81d91
moved lemmas that require the HOL-Complex logic image to Complex/ex/BigO_Complex.thy;
 
wenzelm 
parents: 
16961 
diff
changeset
 | 
845  | 
apply (erule bigo_lesseq2) back  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
846  | 
apply (rule allI)  | 
| 
26814
 
b3e8d5ec721d
Replaced + and * on sets by \<oplus> and \<otimes>, to avoid clash with
 
berghofe 
parents: 
25592 
diff
changeset
 | 
847  | 
apply (auto simp add: func_plus fun_diff_def compare_rls  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
848  | 
split: split_max abs_split)  | 
| 22665 | 849  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
850  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
851  | 
lemma bigo_lesso5: "f <o g =o O(h) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
852  | 
EX C. ALL x. f x <= g x + C * abs(h x)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
853  | 
apply (simp only: lesso_def bigo_alt_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
854  | 
apply clarsimp  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
855  | 
apply (rule_tac x = c in exI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
856  | 
apply (rule allI)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
857  | 
apply (drule_tac x = x in spec)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
858  | 
apply (subgoal_tac "abs(max (f x - g x) 0) = max (f x - g x) 0")  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
859  | 
apply (clarsimp simp add: compare_rls add_ac)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
860  | 
apply (rule abs_of_nonneg)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
861  | 
apply (rule le_maxI2)  | 
| 22665 | 862  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
863  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
864  | 
lemma lesso_add: "f <o g =o O(h) ==>  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
865  | 
k <o l =o O(h) ==> (f + k) <o (g + l) =o O(h)"  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
866  | 
apply (unfold lesso_def)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
867  | 
apply (rule bigo_lesseq3)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
868  | 
apply (erule bigo_useful_add)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
869  | 
apply assumption  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
870  | 
apply (force split: split_max)  | 
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
871  | 
apply (auto split: split_max simp add: func_plus)  | 
| 22665 | 872  | 
done  | 
| 
16908
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
873  | 
|
| 
 
d374530bfaaa
Added two new theories to HOL/Library: SetsAndFunctions.thy and BigO.thy
 
avigad 
parents:  
diff
changeset
 | 
874  | 
end  |