src/HOL/Library/BigO.thy
changeset 26814 b3e8d5ec721d
parent 25592 e8ddaf6bf5df
child 27368 9f90ac19e32b
     1.1 --- a/src/HOL/Library/BigO.thy	Wed May 07 10:59:23 2008 +0200
     1.2 +++ b/src/HOL/Library/BigO.thy	Wed May 07 10:59:24 2008 +0200
     1.3 @@ -99,8 +99,8 @@
     1.4    done
     1.5  
     1.6  lemma bigo_plus_self_subset [intro]: 
     1.7 -  "O(f) + O(f) <= O(f)"
     1.8 -  apply (auto simp add: bigo_alt_def set_plus)
     1.9 +  "O(f) \<oplus> O(f) <= O(f)"
    1.10 +  apply (auto simp add: bigo_alt_def set_plus_def)
    1.11    apply (rule_tac x = "c + ca" in exI)
    1.12    apply auto
    1.13    apply (simp add: ring_distribs func_plus)
    1.14 @@ -111,16 +111,16 @@
    1.15    apply force
    1.16  done
    1.17  
    1.18 -lemma bigo_plus_idemp [simp]: "O(f) + O(f) = O(f)"
    1.19 +lemma bigo_plus_idemp [simp]: "O(f) \<oplus> O(f) = O(f)"
    1.20    apply (rule equalityI)
    1.21    apply (rule bigo_plus_self_subset)
    1.22    apply (rule set_zero_plus2) 
    1.23    apply (rule bigo_zero)
    1.24    done
    1.25  
    1.26 -lemma bigo_plus_subset [intro]: "O(f + g) <= O(f) + O(g)"
    1.27 +lemma bigo_plus_subset [intro]: "O(f + g) <= O(f) \<oplus> O(g)"
    1.28    apply (rule subsetI)
    1.29 -  apply (auto simp add: bigo_def bigo_pos_const func_plus set_plus)
    1.30 +  apply (auto simp add: bigo_def bigo_pos_const func_plus set_plus_def)
    1.31    apply (subst bigo_pos_const [symmetric])+
    1.32    apply (rule_tac x = 
    1.33      "%n. if abs (g n) <= (abs (f n)) then x n else 0" in exI)
    1.34 @@ -170,18 +170,18 @@
    1.35    apply (auto simp add: if_splits linorder_not_le)
    1.36    done
    1.37  
    1.38 -lemma bigo_plus_subset2 [intro]: "A <= O(f) ==> B <= O(f) ==> A + B <= O(f)"
    1.39 -  apply (subgoal_tac "A + B <= O(f) + O(f)")
    1.40 +lemma bigo_plus_subset2 [intro]: "A <= O(f) ==> B <= O(f) ==> A \<oplus> B <= O(f)"
    1.41 +  apply (subgoal_tac "A \<oplus> B <= O(f) \<oplus> O(f)")
    1.42    apply (erule order_trans)
    1.43    apply simp
    1.44    apply (auto del: subsetI simp del: bigo_plus_idemp)
    1.45    done
    1.46  
    1.47  lemma bigo_plus_eq: "ALL x. 0 <= f x ==> ALL x. 0 <= g x ==> 
    1.48 -    O(f + g) = O(f) + O(g)"
    1.49 +    O(f + g) = O(f) \<oplus> O(g)"
    1.50    apply (rule equalityI)
    1.51    apply (rule bigo_plus_subset)
    1.52 -  apply (simp add: bigo_alt_def set_plus func_plus)
    1.53 +  apply (simp add: bigo_alt_def set_plus_def func_plus)
    1.54    apply clarify
    1.55    apply (rule_tac x = "max c ca" in exI)
    1.56    apply (rule conjI)
    1.57 @@ -232,7 +232,7 @@
    1.58      f : lb +o O(g)"
    1.59    apply (rule set_minus_imp_plus)
    1.60    apply (rule bigo_bounded)
    1.61 -  apply (auto simp add: diff_minus func_minus func_plus)
    1.62 +  apply (auto simp add: diff_minus fun_Compl_def func_plus)
    1.63    apply (drule_tac x = x in spec)+
    1.64    apply force
    1.65    apply (drule_tac x = x in spec)+
    1.66 @@ -265,7 +265,7 @@
    1.67      (%x. abs (f x)) =o (%x. abs (g x)) +o O(h)"
    1.68    apply (drule set_plus_imp_minus)
    1.69    apply (rule set_minus_imp_plus)
    1.70 -  apply (subst func_diff)
    1.71 +  apply (subst fun_diff_def)
    1.72  proof -
    1.73    assume a: "f - g : O(h)"
    1.74    have "(%x. abs (f x) - abs (g x)) =o O(%x. abs(abs (f x) - abs (g x)))"
    1.75 @@ -279,7 +279,7 @@
    1.76      done
    1.77    also have "... <= O(f - g)"
    1.78      apply (rule bigo_elt_subset)
    1.79 -    apply (subst func_diff)
    1.80 +    apply (subst fun_diff_def)
    1.81      apply (rule bigo_abs)
    1.82      done
    1.83    also from a have "... <= O(h)"
    1.84 @@ -290,12 +290,12 @@
    1.85  lemma bigo_abs5: "f =o O(g) ==> (%x. abs(f x)) =o O(g)" 
    1.86    by (unfold bigo_def, auto)
    1.87  
    1.88 -lemma bigo_elt_subset2 [intro]: "f : g +o O(h) ==> O(f) <= O(g) + O(h)"
    1.89 +lemma bigo_elt_subset2 [intro]: "f : g +o O(h) ==> O(f) <= O(g) \<oplus> O(h)"
    1.90  proof -
    1.91    assume "f : g +o O(h)"
    1.92 -  also have "... <= O(g) + O(h)"
    1.93 +  also have "... <= O(g) \<oplus> O(h)"
    1.94      by (auto del: subsetI)
    1.95 -  also have "... = O(%x. abs(g x)) + O(%x. abs(h x))"
    1.96 +  also have "... = O(%x. abs(g x)) \<oplus> O(%x. abs(h x))"
    1.97      apply (subst bigo_abs3 [symmetric])+
    1.98      apply (rule refl)
    1.99      done
   1.100 @@ -304,16 +304,16 @@
   1.101    finally have "f : ...".
   1.102    then have "O(f) <= ..."
   1.103      by (elim bigo_elt_subset)
   1.104 -  also have "... = O(%x. abs(g x)) + O(%x. abs(h x))"
   1.105 +  also have "... = O(%x. abs(g x)) \<oplus> O(%x. abs(h x))"
   1.106      by (rule bigo_plus_eq, auto)
   1.107    finally show ?thesis
   1.108      by (simp add: bigo_abs3 [symmetric])
   1.109  qed
   1.110  
   1.111 -lemma bigo_mult [intro]: "O(f)*O(g) <= O(f * g)"
   1.112 +lemma bigo_mult [intro]: "O(f)\<otimes>O(g) <= O(f * g)"
   1.113    apply (rule subsetI)
   1.114    apply (subst bigo_def)
   1.115 -  apply (auto simp add: bigo_alt_def set_times func_times)
   1.116 +  apply (auto simp add: bigo_alt_def set_times_def func_times)
   1.117    apply (rule_tac x = "c * ca" in exI)
   1.118    apply(rule allI)
   1.119    apply(erule_tac x = x in allE)+
   1.120 @@ -389,7 +389,7 @@
   1.121    done
   1.122  
   1.123  lemma bigo_mult7: "ALL x. f x ~= 0 ==>
   1.124 -    O(f * g) <= O(f::'a => ('b::ordered_field)) * O(g)"
   1.125 +    O(f * g) <= O(f::'a => ('b::ordered_field)) \<otimes> O(g)"
   1.126    apply (subst bigo_mult6)
   1.127    apply assumption
   1.128    apply (rule set_times_mono3)
   1.129 @@ -397,14 +397,14 @@
   1.130    done
   1.131  
   1.132  lemma bigo_mult8: "ALL x. f x ~= 0 ==>
   1.133 -    O(f * g) = O(f::'a => ('b::ordered_field)) * O(g)"
   1.134 +    O(f * g) = O(f::'a => ('b::ordered_field)) \<otimes> O(g)"
   1.135    apply (rule equalityI)
   1.136    apply (erule bigo_mult7)
   1.137    apply (rule bigo_mult)
   1.138    done
   1.139  
   1.140  lemma bigo_minus [intro]: "f : O(g) ==> - f : O(g)"
   1.141 -  by (auto simp add: bigo_def func_minus)
   1.142 +  by (auto simp add: bigo_def fun_Compl_def)
   1.143  
   1.144  lemma bigo_minus2: "f : g +o O(h) ==> -f : -g +o O(h)"
   1.145    apply (rule set_minus_imp_plus)
   1.146 @@ -414,7 +414,7 @@
   1.147    done
   1.148  
   1.149  lemma bigo_minus3: "O(-f) = O(f)"
   1.150 -  by (auto simp add: bigo_def func_minus abs_minus_cancel)
   1.151 +  by (auto simp add: bigo_def fun_Compl_def abs_minus_cancel)
   1.152  
   1.153  lemma bigo_plus_absorb_lemma1: "f : O(g) ==> f +o O(g) <= O(g)"
   1.154  proof -
   1.155 @@ -422,9 +422,9 @@
   1.156    show "f +o O(g) <= O(g)"
   1.157    proof -
   1.158      have "f : O(f)" by auto
   1.159 -    then have "f +o O(g) <= O(f) + O(g)"
   1.160 +    then have "f +o O(g) <= O(f) \<oplus> O(g)"
   1.161        by (auto del: subsetI)
   1.162 -    also have "... <= O(g) + O(g)"
   1.163 +    also have "... <= O(g) \<oplus> O(g)"
   1.164      proof -
   1.165        from a have "O(f) <= O(g)" by (auto del: subsetI)
   1.166        thus ?thesis by (auto del: subsetI)
   1.167 @@ -566,7 +566,7 @@
   1.168  
   1.169  lemma bigo_compose2: "f =o g +o O(h) ==> (%x. f(k x)) =o (%x. g(k x)) +o 
   1.170      O(%x. h(k x))"
   1.171 -  apply (simp only: set_minus_plus [symmetric] diff_minus func_minus
   1.172 +  apply (simp only: set_minus_plus [symmetric] diff_minus fun_Compl_def
   1.173        func_plus)
   1.174    apply (erule bigo_compose1)
   1.175  done
   1.176 @@ -635,11 +635,11 @@
   1.177        (%x. SUM y : A x. l x y * g(k x y)) +o
   1.178          O(%x. SUM y : A x. abs(l x y * h(k x y)))"
   1.179    apply (rule set_minus_imp_plus)
   1.180 -  apply (subst func_diff)
   1.181 +  apply (subst fun_diff_def)
   1.182    apply (subst setsum_subtractf [symmetric])
   1.183    apply (subst right_diff_distrib [symmetric])
   1.184    apply (rule bigo_setsum3)
   1.185 -  apply (subst func_diff [symmetric])
   1.186 +  apply (subst fun_diff_def [symmetric])
   1.187    apply (erule set_plus_imp_minus)
   1.188    done
   1.189  
   1.190 @@ -664,11 +664,11 @@
   1.191          (%x. SUM y : A x. (l x y) * g(k x y)) +o
   1.192            O(%x. SUM y : A x. (l x y) * h(k x y))" 
   1.193    apply (rule set_minus_imp_plus)
   1.194 -  apply (subst func_diff)
   1.195 +  apply (subst fun_diff_def)
   1.196    apply (subst setsum_subtractf [symmetric])
   1.197    apply (subst right_diff_distrib [symmetric])
   1.198    apply (rule bigo_setsum5)
   1.199 -  apply (subst func_diff [symmetric])
   1.200 +  apply (subst fun_diff_def [symmetric])
   1.201    apply (drule set_plus_imp_minus)
   1.202    apply auto
   1.203    done
   1.204 @@ -677,7 +677,7 @@
   1.205  subsection {* Misc useful stuff *}
   1.206  
   1.207  lemma bigo_useful_intro: "A <= O(f) ==> B <= O(f) ==>
   1.208 -  A + B <= O(f)"
   1.209 +  A \<oplus> B <= O(f)"
   1.210    apply (subst bigo_plus_idemp [symmetric])
   1.211    apply (rule set_plus_mono2)
   1.212    apply assumption+
   1.213 @@ -723,11 +723,11 @@
   1.214         f 0 = g 0 ==> f =o g +o O(h)"
   1.215    apply (rule set_minus_imp_plus)
   1.216    apply (rule bigo_fix)
   1.217 -  apply (subst func_diff)
   1.218 -  apply (subst func_diff [symmetric])
   1.219 +  apply (subst fun_diff_def)
   1.220 +  apply (subst fun_diff_def [symmetric])
   1.221    apply (rule set_plus_imp_minus)
   1.222    apply simp
   1.223 -  apply (simp add: func_diff)
   1.224 +  apply (simp add: fun_diff_def)
   1.225    done
   1.226  
   1.227  
   1.228 @@ -794,7 +794,7 @@
   1.229    apply (rule allI)
   1.230    apply (rule le_maxI2)
   1.231    apply (rule allI)
   1.232 -  apply (subst func_diff)
   1.233 +  apply (subst fun_diff_def)
   1.234    apply (case_tac "0 <= k x - g x")
   1.235    apply simp
   1.236    apply (subst abs_of_nonneg)
   1.237 @@ -818,7 +818,7 @@
   1.238    apply (rule allI)
   1.239    apply (rule le_maxI2)
   1.240    apply (rule allI)
   1.241 -  apply (subst func_diff)
   1.242 +  apply (subst fun_diff_def)
   1.243    apply (case_tac "0 <= f x - k x")
   1.244    apply simp
   1.245    apply (subst abs_of_nonneg)
   1.246 @@ -839,12 +839,12 @@
   1.247    apply (unfold lesso_def)
   1.248    apply (drule set_plus_imp_minus)
   1.249    apply (drule bigo_abs5) back
   1.250 -  apply (simp add: func_diff)
   1.251 +  apply (simp add: fun_diff_def)
   1.252    apply (drule bigo_useful_add)
   1.253    apply assumption
   1.254    apply (erule bigo_lesseq2) back
   1.255    apply (rule allI)
   1.256 -  apply (auto simp add: func_plus func_diff compare_rls 
   1.257 +  apply (auto simp add: func_plus fun_diff_def compare_rls 
   1.258      split: split_max abs_split)
   1.259    done
   1.260