src/HOL/Metis_Examples/Big_O.thy
changeset 45575 3a865fc42bbf
parent 45532 74b17a0881b3
child 45705 a25ff4283352
     1.1 --- a/src/HOL/Metis_Examples/Big_O.thy	Fri Nov 18 11:47:12 2011 +0100
     1.2 +++ b/src/HOL/Metis_Examples/Big_O.thy	Fri Nov 18 11:47:12 2011 +0100
     1.3 @@ -10,36 +10,31 @@
     1.4  theory Big_O
     1.5  imports
     1.6    "~~/src/HOL/Decision_Procs/Dense_Linear_Order"
     1.7 -  Main
     1.8    "~~/src/HOL/Library/Function_Algebras"
     1.9    "~~/src/HOL/Library/Set_Algebras"
    1.10  begin
    1.11  
    1.12 -declare [[metis_new_skolemizer]]
    1.13 -
    1.14  subsection {* Definitions *}
    1.15  
    1.16 -definition bigo :: "('a => 'b::{linordered_idom,number_ring}) => ('a => 'b) set"    ("(1O'(_'))") where
    1.17 -  "O(f::('a => 'b)) ==   {h. EX c. ALL x. abs (h x) <= c * abs (f x)}"
    1.18 +definition bigo :: "('a => 'b\<Colon>{linordered_idom,number_ring}) => ('a => 'b) set" ("(1O'(_'))") where
    1.19 +  "O(f\<Colon>('a => 'b)) == {h. \<exists>c. \<forall>x. abs (h x) <= c * abs (f x)}"
    1.20  
    1.21 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_pos_const" ]]
    1.22 -lemma bigo_pos_const: "(EX (c::'a::linordered_idom).
    1.23 -    ALL x. (abs (h x)) <= (c * (abs (f x))))
    1.24 -      = (EX c. 0 < c & (ALL x. (abs(h x)) <= (c * (abs (f x)))))"
    1.25 -  apply auto
    1.26 -  apply (case_tac "c = 0", simp)
    1.27 -  apply (rule_tac x = "1" in exI, simp)
    1.28 -  apply (rule_tac x = "abs c" in exI, auto)
    1.29 -  apply (metis abs_ge_zero abs_of_nonneg Orderings.xt1(6) abs_mult)
    1.30 -  done
    1.31 +lemma bigo_pos_const:
    1.32 +  "(\<exists>(c\<Colon>'a\<Colon>linordered_idom).
    1.33 +    \<forall>x. (abs (h x)) <= (c * (abs (f x))))
    1.34 +      = (\<exists>c. 0 < c & (\<forall>x. (abs(h x)) <= (c * (abs (f x)))))"
    1.35 +by (metis (hide_lams, no_types) abs_ge_zero
    1.36 +      comm_semiring_1_class.normalizing_semiring_rules(7) mult.comm_neutral
    1.37 +      mult_nonpos_nonneg not_leE order_trans zero_less_one)
    1.38  
    1.39  (*** Now various verions with an increasing shrink factor ***)
    1.40  
    1.41  sledgehammer_params [isar_proof, isar_shrink_factor = 1]
    1.42  
    1.43 -lemma (*bigo_pos_const:*) "(EX (c::'a::linordered_idom).
    1.44 -    ALL x. (abs (h x)) <= (c * (abs (f x))))
    1.45 -      = (EX c. 0 < c & (ALL x. (abs(h x)) <= (c * (abs (f x)))))"
    1.46 +lemma
    1.47 +  "(\<exists>(c\<Colon>'a\<Colon>linordered_idom).
    1.48 +    \<forall>x. (abs (h x)) <= (c * (abs (f x))))
    1.49 +      = (\<exists>c. 0 < c & (\<forall>x. (abs(h x)) <= (c * (abs (f x)))))"
    1.50    apply auto
    1.51    apply (case_tac "c = 0", simp)
    1.52    apply (rule_tac x = "1" in exI, simp)
    1.53 @@ -67,9 +62,10 @@
    1.54  
    1.55  sledgehammer_params [isar_proof, isar_shrink_factor = 2]
    1.56  
    1.57 -lemma (*bigo_pos_const:*) "(EX (c::'a::linordered_idom).
    1.58 -    ALL x. (abs (h x)) <= (c * (abs (f x))))
    1.59 -      = (EX c. 0 < c & (ALL x. (abs(h x)) <= (c * (abs (f x)))))"
    1.60 +lemma
    1.61 +  "(\<exists>(c\<Colon>'a\<Colon>linordered_idom).
    1.62 +    \<forall>x. (abs (h x)) <= (c * (abs (f x))))
    1.63 +      = (\<exists>c. 0 < c & (\<forall>x. (abs(h x)) <= (c * (abs (f x)))))"
    1.64    apply auto
    1.65    apply (case_tac "c = 0", simp)
    1.66    apply (rule_tac x = "1" in exI, simp)
    1.67 @@ -89,9 +85,10 @@
    1.68  
    1.69  sledgehammer_params [isar_proof, isar_shrink_factor = 3]
    1.70  
    1.71 -lemma (*bigo_pos_const:*) "(EX (c::'a::linordered_idom).
    1.72 -    ALL x. (abs (h x)) <= (c * (abs (f x))))
    1.73 -      = (EX c. 0 < c & (ALL x. (abs(h x)) <= (c * (abs (f x)))))"
    1.74 +lemma
    1.75 +  "(\<exists>(c\<Colon>'a\<Colon>linordered_idom).
    1.76 +    \<forall>x. (abs (h x)) <= (c * (abs (f x))))
    1.77 +      = (\<exists>c. 0 < c & (\<forall>x. (abs(h x)) <= (c * (abs (f x)))))"
    1.78    apply auto
    1.79    apply (case_tac "c = 0", simp)
    1.80    apply (rule_tac x = "1" in exI, simp)
    1.81 @@ -108,9 +105,10 @@
    1.82  
    1.83  sledgehammer_params [isar_proof, isar_shrink_factor = 4]
    1.84  
    1.85 -lemma (*bigo_pos_const:*) "(EX (c::'a::linordered_idom).
    1.86 -    ALL x. (abs (h x)) <= (c * (abs (f x))))
    1.87 -      = (EX c. 0 < c & (ALL x. (abs(h x)) <= (c * (abs (f x)))))"
    1.88 +lemma
    1.89 +  "(\<exists>(c\<Colon>'a\<Colon>linordered_idom).
    1.90 +    \<forall>x. (abs (h x)) <= (c * (abs (f x))))
    1.91 +      = (\<exists>c. 0 < c & (\<forall>x. (abs(h x)) <= (c * (abs (f x)))))"
    1.92    apply auto
    1.93    apply (case_tac "c = 0", simp)
    1.94    apply (rule_tac x = "1" in exI, simp)
    1.95 @@ -127,142 +125,109 @@
    1.96  
    1.97  sledgehammer_params [isar_proof, isar_shrink_factor = 1]
    1.98  
    1.99 -lemma bigo_alt_def: "O(f) =
   1.100 -    {h. EX c. (0 < c & (ALL x. abs (h x) <= c * abs (f x)))}"
   1.101 +lemma bigo_alt_def: "O(f) = {h. \<exists>c. (0 < c & (\<forall>x. abs (h x) <= c * abs (f x)))}"
   1.102  by (auto simp add: bigo_def bigo_pos_const)
   1.103  
   1.104 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_elt_subset" ]]
   1.105 -lemma bigo_elt_subset [intro]: "f : O(g) ==> O(f) <= O(g)"
   1.106 -  apply (auto simp add: bigo_alt_def)
   1.107 -  apply (rule_tac x = "ca * c" in exI)
   1.108 -  apply (rule conjI)
   1.109 -  apply (rule mult_pos_pos)
   1.110 +lemma bigo_elt_subset [intro]: "f : O(g) \<Longrightarrow> O(f) <= O(g)"
   1.111 +apply (auto simp add: bigo_alt_def)
   1.112 +apply (rule_tac x = "ca * c" in exI)
   1.113 +apply (rule conjI)
   1.114 + apply (rule mult_pos_pos)
   1.115    apply (assumption)+
   1.116 -(*sledgehammer*)
   1.117 -  apply (rule allI)
   1.118 -  apply (drule_tac x = "xa" in spec)+
   1.119 -  apply (subgoal_tac "ca * abs(f xa) <= ca * (c * abs(g xa))")
   1.120 -  apply (erule order_trans)
   1.121 -  apply (simp add: mult_ac)
   1.122 -  apply (rule mult_left_mono, assumption)
   1.123 -  apply (rule order_less_imp_le, assumption)
   1.124 -done
   1.125 +(* sledgehammer *)
   1.126 +apply (rule allI)
   1.127 +apply (drule_tac x = "xa" in spec)+
   1.128 +apply (subgoal_tac "ca * abs (f xa) <= ca * (c * abs (g xa))")
   1.129 + apply (metis comm_semiring_1_class.normalizing_semiring_rules(19)
   1.130 +          comm_semiring_1_class.normalizing_semiring_rules(7) order_trans)
   1.131 +by (metis mult_le_cancel_left_pos)
   1.132  
   1.133 -
   1.134 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_refl" ]]
   1.135  lemma bigo_refl [intro]: "f : O(f)"
   1.136  apply (auto simp add: bigo_def)
   1.137  by (metis mult_1 order_refl)
   1.138  
   1.139 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_zero" ]]
   1.140  lemma bigo_zero: "0 : O(g)"
   1.141  apply (auto simp add: bigo_def func_zero)
   1.142  by (metis mult_zero_left order_refl)
   1.143  
   1.144 -lemma bigo_zero2: "O(%x.0) = {%x.0}"
   1.145 -  by (auto simp add: bigo_def)
   1.146 +lemma bigo_zero2: "O(\<lambda>x. 0) = {\<lambda>x. 0}"
   1.147 +by (auto simp add: bigo_def)
   1.148  
   1.149  lemma bigo_plus_self_subset [intro]:
   1.150    "O(f) \<oplus> O(f) <= O(f)"
   1.151 -  apply (auto simp add: bigo_alt_def set_plus_def)
   1.152 -  apply (rule_tac x = "c + ca" in exI)
   1.153 -  apply auto
   1.154 -  apply (simp add: ring_distribs func_plus)
   1.155 -  apply (blast intro:order_trans abs_triangle_ineq add_mono elim:)
   1.156 -done
   1.157 +apply (auto simp add: bigo_alt_def set_plus_def)
   1.158 +apply (rule_tac x = "c + ca" in exI)
   1.159 +apply auto
   1.160 +apply (simp add: ring_distribs func_plus)
   1.161 +by (metis order_trans abs_triangle_ineq add_mono)
   1.162  
   1.163  lemma bigo_plus_idemp [simp]: "O(f) \<oplus> O(f) = O(f)"
   1.164 -  apply (rule equalityI)
   1.165 -  apply (rule bigo_plus_self_subset)
   1.166 -  apply (rule set_zero_plus2)
   1.167 -  apply (rule bigo_zero)
   1.168 -done
   1.169 +by (metis bigo_plus_self_subset bigo_zero set_eq_subset set_zero_plus2)
   1.170  
   1.171  lemma bigo_plus_subset [intro]: "O(f + g) <= O(f) \<oplus> O(g)"
   1.172 -  apply (rule subsetI)
   1.173 -  apply (auto simp add: bigo_def bigo_pos_const func_plus set_plus_def)
   1.174 -  apply (subst bigo_pos_const [symmetric])+
   1.175 -  apply (rule_tac x =
   1.176 -    "%n. if abs (g n) <= (abs (f n)) then x n else 0" in exI)
   1.177 -  apply (rule conjI)
   1.178 -  apply (rule_tac x = "c + c" in exI)
   1.179 -  apply (clarsimp)
   1.180 -  apply (auto)
   1.181 +apply (rule subsetI)
   1.182 +apply (auto simp add: bigo_def bigo_pos_const func_plus set_plus_def)
   1.183 +apply (subst bigo_pos_const [symmetric])+
   1.184 +apply (rule_tac x = "\<lambda>n. if abs (g n) <= (abs (f n)) then x n else 0" in exI)
   1.185 +apply (rule conjI)
   1.186 + apply (rule_tac x = "c + c" in exI)
   1.187 + apply clarsimp
   1.188 + apply auto
   1.189    apply (subgoal_tac "c * abs (f xa + g xa) <= (c + c) * abs (f xa)")
   1.190 -  apply (erule_tac x = xa in allE)
   1.191 -  apply (erule order_trans)
   1.192 -  apply (simp)
   1.193 +   apply (metis mult_2 order_trans)
   1.194    apply (subgoal_tac "c * abs (f xa + g xa) <= c * (abs (f xa) + abs (g xa))")
   1.195 -  apply (erule order_trans)
   1.196 -  apply (simp add: ring_distribs)
   1.197 +   apply (erule order_trans)
   1.198 +   apply (simp add: ring_distribs)
   1.199    apply (rule mult_left_mono)
   1.200 -  apply (simp add: abs_triangle_ineq)
   1.201 +   apply (simp add: abs_triangle_ineq)
   1.202    apply (simp add: order_less_le)
   1.203 -  apply (rule mult_nonneg_nonneg)
   1.204 + apply (rule mult_nonneg_nonneg)
   1.205    apply auto
   1.206 -  apply (rule_tac x = "%n. if (abs (f n)) <  abs (g n) then x n else 0"
   1.207 -     in exI)
   1.208 -  apply (rule conjI)
   1.209 -  apply (rule_tac x = "c + c" in exI)
   1.210 -  apply auto
   1.211 -  apply (subgoal_tac "c * abs (f xa + g xa) <= (c + c) * abs (g xa)")
   1.212 -  apply (erule_tac x = xa in allE)
   1.213 -  apply (erule order_trans)
   1.214 -  apply (simp)
   1.215 -  apply (subgoal_tac "c * abs (f xa + g xa) <= c * (abs (f xa) + abs (g xa))")
   1.216 +apply (rule_tac x = "\<lambda>n. if (abs (f n)) < abs (g n) then x n else 0" in exI)
   1.217 +apply (rule conjI)
   1.218 + apply (rule_tac x = "c + c" in exI)
   1.219 + apply auto
   1.220 + apply (subgoal_tac "c * abs (f xa + g xa) <= (c + c) * abs (g xa)")
   1.221 +  apply (metis order_trans semiring_mult_2)
   1.222 + apply (subgoal_tac "c * abs (f xa + g xa) <= c * (abs (f xa) + abs (g xa))")
   1.223    apply (erule order_trans)
   1.224    apply (simp add: ring_distribs)
   1.225 -  apply (rule mult_left_mono)
   1.226 -  apply (rule abs_triangle_ineq)
   1.227 -  apply (simp add: order_less_le)
   1.228 -apply (metis abs_not_less_zero even_less_0_iff less_not_permute linorder_not_less mult_less_0_iff)
   1.229 -done
   1.230 + apply (metis abs_triangle_ineq mult_le_cancel_left_pos)
   1.231 +by (metis abs_ge_zero abs_of_pos zero_le_mult_iff)
   1.232  
   1.233 -lemma bigo_plus_subset2 [intro]: "A <= O(f) ==> B <= O(f) ==> A \<oplus> B <= O(f)"
   1.234 -  apply (subgoal_tac "A \<oplus> B <= O(f) \<oplus> O(f)")
   1.235 -  apply (erule order_trans)
   1.236 -  apply simp
   1.237 -  apply (auto del: subsetI simp del: bigo_plus_idemp)
   1.238 -done
   1.239 +lemma bigo_plus_subset2 [intro]: "A <= O(f) \<Longrightarrow> B <= O(f) \<Longrightarrow> A \<oplus> B <= O(f)"
   1.240 +by (metis bigo_plus_idemp set_plus_mono2)
   1.241  
   1.242 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_plus_eq" ]]
   1.243 -lemma bigo_plus_eq: "ALL x. 0 <= f x ==> ALL x. 0 <= g x ==>
   1.244 -  O(f + g) = O(f) \<oplus> O(g)"
   1.245 -  apply (rule equalityI)
   1.246 -  apply (rule bigo_plus_subset)
   1.247 -  apply (simp add: bigo_alt_def set_plus_def func_plus)
   1.248 -  apply clarify
   1.249 -(*sledgehammer*)
   1.250 -  apply (rule_tac x = "max c ca" in exI)
   1.251 -  apply (rule conjI)
   1.252 -   apply (metis Orderings.less_max_iff_disj)
   1.253 -  apply clarify
   1.254 -  apply (drule_tac x = "xa" in spec)+
   1.255 -  apply (subgoal_tac "0 <= f xa + g xa")
   1.256 -  apply (simp add: ring_distribs)
   1.257 -  apply (subgoal_tac "abs(a xa + b xa) <= abs(a xa) + abs(b xa)")
   1.258 -  apply (subgoal_tac "abs(a xa) + abs(b xa) <=
   1.259 -      max c ca * f xa + max c ca * g xa")
   1.260 -  apply (blast intro: order_trans)
   1.261 +lemma bigo_plus_eq: "\<forall>x. 0 <= f x \<Longrightarrow> \<forall>x. 0 <= g x \<Longrightarrow> O(f + g) = O(f) \<oplus> O(g)"
   1.262 +apply (rule equalityI)
   1.263 +apply (rule bigo_plus_subset)
   1.264 +apply (simp add: bigo_alt_def set_plus_def func_plus)
   1.265 +apply clarify
   1.266 +(* sledgehammer *)
   1.267 +apply (rule_tac x = "max c ca" in exI)
   1.268 +apply (rule conjI)
   1.269 + apply (metis less_max_iff_disj)
   1.270 +apply clarify
   1.271 +apply (drule_tac x = "xa" in spec)+
   1.272 +apply (subgoal_tac "0 <= f xa + g xa")
   1.273 + apply (simp add: ring_distribs)
   1.274 + apply (subgoal_tac "abs (a xa + b xa) <= abs (a xa) + abs (b xa)")
   1.275 +  apply (subgoal_tac "abs (a xa) + abs (b xa) <=
   1.276 +           max c ca * f xa + max c ca * g xa")
   1.277 +   apply (metis order_trans)
   1.278    defer 1
   1.279 -  apply (rule abs_triangle_ineq)
   1.280 -  apply (metis add_nonneg_nonneg)
   1.281 -  apply (rule add_mono)
   1.282 -using [[ sledgehammer_problem_prefix = "BigO__bigo_plus_eq_simpler" ]]
   1.283 -  apply (metis le_maxI2 linorder_linear min_max.sup_absorb1 mult_right_mono xt1(6))
   1.284 -  apply (metis le_maxI2 linorder_not_le mult_le_cancel_right order_trans)
   1.285 -done
   1.286 +  apply (metis abs_triangle_ineq)
   1.287 + apply (metis add_nonneg_nonneg)
   1.288 +apply (rule add_mono)
   1.289 + apply (metis le_maxI2 linorder_linear min_max.sup_absorb1 mult_right_mono xt1(6))
   1.290 +by (metis le_maxI2 linorder_not_le mult_le_cancel_right order_trans)
   1.291  
   1.292 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_bounded_alt" ]]
   1.293 -lemma bigo_bounded_alt: "ALL x. 0 <= f x ==> ALL x. f x <= c * g x ==>
   1.294 -    f : O(g)"
   1.295 -  apply (auto simp add: bigo_def)
   1.296 +lemma bigo_bounded_alt: "\<forall>x. 0 <= f x \<Longrightarrow> \<forall>x. f x <= c * g x \<Longrightarrow> f : O(g)"
   1.297 +apply (auto simp add: bigo_def)
   1.298  (* Version 1: one-line proof *)
   1.299 -  apply (metis abs_le_D1 linorder_class.not_less  order_less_le  Orderings.xt1(12)  abs_mult)
   1.300 -  done
   1.301 +by (metis abs_le_D1 linorder_class.not_less order_less_le Orderings.xt1(12) abs_mult)
   1.302  
   1.303 -lemma (*bigo_bounded_alt:*) "ALL x. 0 <= f x ==> ALL x. f x <= c * g x ==>
   1.304 -    f : O(g)"
   1.305 +lemma "\<forall>x. 0 <= f x \<Longrightarrow> \<forall>x. f x <= c * g x \<Longrightarrow> f : O(g)"
   1.306  apply (auto simp add: bigo_def)
   1.307  (* Version 2: structured proof *)
   1.308  proof -
   1.309 @@ -270,32 +235,11 @@
   1.310    thus "\<exists>c. \<forall>x. f x \<le> c * \<bar>g x\<bar>" by (metis abs_mult abs_ge_self order_trans)
   1.311  qed
   1.312  
   1.313 -text{*So here is the easier (and more natural) problem using transitivity*}
   1.314 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_bounded_alt_trans" ]]
   1.315 -lemma "ALL x. 0 <= f x ==> ALL x. f x <= c * g x ==> f : O(g)"
   1.316 -apply (auto simp add: bigo_def)
   1.317 -(* Version 1: one-line proof *)
   1.318 -by (metis abs_ge_self abs_mult order_trans)
   1.319 +lemma bigo_bounded: "\<forall>x. 0 <= f x \<Longrightarrow> \<forall>x. f x <= g x \<Longrightarrow> f : O(g)"
   1.320 +apply (erule bigo_bounded_alt [of f 1 g])
   1.321 +by (metis mult_1)
   1.322  
   1.323 -text{*So here is the easier (and more natural) problem using transitivity*}
   1.324 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_bounded_alt_trans" ]]
   1.325 -lemma "ALL x. 0 <= f x ==> ALL x. f x <= c * g x ==> f : O(g)"
   1.326 -  apply (auto simp add: bigo_def)
   1.327 -(* Version 2: structured proof *)
   1.328 -proof -
   1.329 -  assume "\<forall>x. f x \<le> c * g x"
   1.330 -  thus "\<exists>c. \<forall>x. f x \<le> c * \<bar>g x\<bar>" by (metis abs_mult abs_ge_self order_trans)
   1.331 -qed
   1.332 -
   1.333 -lemma bigo_bounded: "ALL x. 0 <= f x ==> ALL x. f x <= g x ==>
   1.334 -    f : O(g)"
   1.335 -  apply (erule bigo_bounded_alt [of f 1 g])
   1.336 -  apply simp
   1.337 -done
   1.338 -
   1.339 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_bounded2" ]]
   1.340 -lemma bigo_bounded2: "ALL x. lb x <= f x ==> ALL x. f x <= lb x + g x ==>
   1.341 -    f : lb +o O(g)"
   1.342 +lemma bigo_bounded2: "\<forall>x. lb x <= f x \<Longrightarrow> \<forall>x. f x <= lb x + g x \<Longrightarrow> f : lb +o O(g)"
   1.343  apply (rule set_minus_imp_plus)
   1.344  apply (rule bigo_bounded)
   1.345   apply (auto simp add: diff_minus fun_Compl_def func_plus)
   1.346 @@ -308,19 +252,17 @@
   1.347    thus "(0\<Colon>'b) \<le> f x + - lb x" by (metis not_leE diff_minus less_iff_diff_less_0 less_le_not_le)
   1.348  qed
   1.349  
   1.350 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_abs" ]]
   1.351 -lemma bigo_abs: "(%x. abs(f x)) =o O(f)"
   1.352 +lemma bigo_abs: "(\<lambda>x. abs(f x)) =o O(f)"
   1.353  apply (unfold bigo_def)
   1.354  apply auto
   1.355  by (metis mult_1 order_refl)
   1.356  
   1.357 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_abs2" ]]
   1.358 -lemma bigo_abs2: "f =o O(%x. abs(f x))"
   1.359 +lemma bigo_abs2: "f =o O(\<lambda>x. abs(f x))"
   1.360  apply (unfold bigo_def)
   1.361  apply auto
   1.362  by (metis mult_1 order_refl)
   1.363  
   1.364 -lemma bigo_abs3: "O(f) = O(%x. abs(f x))"
   1.365 +lemma bigo_abs3: "O(f) = O(\<lambda>x. abs(f x))"
   1.366  proof -
   1.367    have F1: "\<forall>v u. u \<in> O(v) \<longrightarrow> O(u) \<subseteq> O(v)" by (metis bigo_elt_subset)
   1.368    have F2: "\<forall>u. (\<lambda>R. \<bar>u R\<bar>) \<in> O(u)" by (metis bigo_abs)
   1.369 @@ -328,16 +270,15 @@
   1.370    thus "O(f) = O(\<lambda>x. \<bar>f x\<bar>)" using F1 F2 by auto
   1.371  qed
   1.372  
   1.373 -lemma bigo_abs4: "f =o g +o O(h) ==>
   1.374 -    (%x. abs (f x)) =o (%x. abs (g x)) +o O(h)"
   1.375 +lemma bigo_abs4: "f =o g +o O(h) \<Longrightarrow> (\<lambda>x. abs (f x)) =o (\<lambda>x. abs (g x)) +o O(h)"
   1.376    apply (drule set_plus_imp_minus)
   1.377    apply (rule set_minus_imp_plus)
   1.378    apply (subst fun_diff_def)
   1.379  proof -
   1.380    assume a: "f - g : O(h)"
   1.381 -  have "(%x. abs (f x) - abs (g x)) =o O(%x. abs(abs (f x) - abs (g x)))"
   1.382 +  have "(\<lambda>x. abs (f x) - abs (g x)) =o O(\<lambda>x. abs(abs (f x) - abs (g x)))"
   1.383      by (rule bigo_abs2)
   1.384 -  also have "... <= O(%x. abs (f x - g x))"
   1.385 +  also have "... <= O(\<lambda>x. abs (f x - g x))"
   1.386      apply (rule bigo_elt_subset)
   1.387      apply (rule bigo_bounded)
   1.388      apply force
   1.389 @@ -351,45 +292,43 @@
   1.390      done
   1.391    also have "... <= O(h)"
   1.392      using a by (rule bigo_elt_subset)
   1.393 -  finally show "(%x. abs (f x) - abs (g x)) : O(h)".
   1.394 +  finally show "(\<lambda>x. abs (f x) - abs (g x)) : O(h)".
   1.395  qed
   1.396  
   1.397 -lemma bigo_abs5: "f =o O(g) ==> (%x. abs(f x)) =o O(g)"
   1.398 +lemma bigo_abs5: "f =o O(g) \<Longrightarrow> (\<lambda>x. abs(f x)) =o O(g)"
   1.399  by (unfold bigo_def, auto)
   1.400  
   1.401 -lemma bigo_elt_subset2 [intro]: "f : g +o O(h) ==> O(f) <= O(g) \<oplus> O(h)"
   1.402 +lemma bigo_elt_subset2 [intro]: "f : g +o O(h) \<Longrightarrow> O(f) <= O(g) \<oplus> O(h)"
   1.403  proof -
   1.404    assume "f : g +o O(h)"
   1.405    also have "... <= O(g) \<oplus> O(h)"
   1.406      by (auto del: subsetI)
   1.407 -  also have "... = O(%x. abs(g x)) \<oplus> O(%x. abs(h x))"
   1.408 +  also have "... = O(\<lambda>x. abs(g x)) \<oplus> O(\<lambda>x. abs(h x))"
   1.409      apply (subst bigo_abs3 [symmetric])+
   1.410      apply (rule refl)
   1.411      done
   1.412 -  also have "... = O((%x. abs(g x)) + (%x. abs(h x)))"
   1.413 +  also have "... = O((\<lambda>x. abs(g x)) + (\<lambda>x. abs(h x)))"
   1.414      by (rule bigo_plus_eq [symmetric], auto)
   1.415    finally have "f : ...".
   1.416    then have "O(f) <= ..."
   1.417      by (elim bigo_elt_subset)
   1.418 -  also have "... = O(%x. abs(g x)) \<oplus> O(%x. abs(h x))"
   1.419 +  also have "... = O(\<lambda>x. abs(g x)) \<oplus> O(\<lambda>x. abs(h x))"
   1.420      by (rule bigo_plus_eq, auto)
   1.421    finally show ?thesis
   1.422      by (simp add: bigo_abs3 [symmetric])
   1.423  qed
   1.424  
   1.425 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_mult" ]]
   1.426  lemma bigo_mult [intro]: "O(f)\<otimes>O(g) <= O(f * g)"
   1.427    apply (rule subsetI)
   1.428    apply (subst bigo_def)
   1.429    apply (auto simp del: abs_mult mult_ac
   1.430                simp add: bigo_alt_def set_times_def func_times)
   1.431 -(*sledgehammer*)
   1.432 +(* sledgehammer *)
   1.433    apply (rule_tac x = "c * ca" in exI)
   1.434    apply(rule allI)
   1.435    apply(erule_tac x = x in allE)+
   1.436    apply(subgoal_tac "c * ca * abs(f x * g x) =
   1.437        (c * abs(f x)) * (ca * abs(g x))")
   1.438 -using [[ sledgehammer_problem_prefix = "BigO__bigo_mult_simpler" ]]
   1.439  prefer 2
   1.440  apply (metis mult_assoc mult_left_commute
   1.441    abs_of_pos mult_left_commute
   1.442 @@ -400,14 +339,12 @@
   1.443     abs_mult has just been done *)
   1.444  by (metis abs_ge_zero mult_mono')
   1.445  
   1.446 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_mult2" ]]
   1.447  lemma bigo_mult2 [intro]: "f *o O(g) <= O(f * g)"
   1.448    apply (auto simp add: bigo_def elt_set_times_def func_times abs_mult)
   1.449 -(*sledgehammer*)
   1.450 +(* sledgehammer *)
   1.451    apply (rule_tac x = c in exI)
   1.452    apply clarify
   1.453    apply (drule_tac x = x in spec)
   1.454 -using [[ sledgehammer_problem_prefix = "BigO__bigo_mult2_simpler" ]]
   1.455  (*sledgehammer [no luck]*)
   1.456    apply (subgoal_tac "abs(f x) * abs(b x) <= abs(f x) * (c * abs(g x))")
   1.457    apply (simp add: mult_ac)
   1.458 @@ -415,36 +352,33 @@
   1.459    apply (rule abs_ge_zero)
   1.460  done
   1.461  
   1.462 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_mult3" ]]
   1.463 -lemma bigo_mult3: "f : O(h) ==> g : O(j) ==> f * g : O(h * j)"
   1.464 +lemma bigo_mult3: "f : O(h) \<Longrightarrow> g : O(j) \<Longrightarrow> f * g : O(h * j)"
   1.465  by (metis bigo_mult set_rev_mp set_times_intro)
   1.466  
   1.467 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_mult4" ]]
   1.468 -lemma bigo_mult4 [intro]:"f : k +o O(h) ==> g * f : (g * k) +o O(g * h)"
   1.469 +lemma bigo_mult4 [intro]:"f : k +o O(h) \<Longrightarrow> g * f : (g * k) +o O(g * h)"
   1.470  by (metis bigo_mult2 set_plus_mono_b set_times_intro2 set_times_plus_distrib)
   1.471  
   1.472 -
   1.473 -lemma bigo_mult5: "ALL x. f x ~= 0 ==>
   1.474 -    O(f * g) <= (f::'a => ('b::{linordered_field,number_ring})) *o O(g)"
   1.475 +lemma bigo_mult5: "\<forall>x. f x ~= 0 \<Longrightarrow>
   1.476 +    O(f * g) <= (f\<Colon>'a => ('b\<Colon>{linordered_field,number_ring})) *o O(g)"
   1.477  proof -
   1.478 -  assume a: "ALL x. f x ~= 0"
   1.479 +  assume a: "\<forall>x. f x ~= 0"
   1.480    show "O(f * g) <= f *o O(g)"
   1.481    proof
   1.482      fix h
   1.483      assume h: "h : O(f * g)"
   1.484 -    then have "(%x. 1 / (f x)) * h : (%x. 1 / f x) *o O(f * g)"
   1.485 +    then have "(\<lambda>x. 1 / (f x)) * h : (\<lambda>x. 1 / f x) *o O(f * g)"
   1.486        by auto
   1.487 -    also have "... <= O((%x. 1 / f x) * (f * g))"
   1.488 +    also have "... <= O((\<lambda>x. 1 / f x) * (f * g))"
   1.489        by (rule bigo_mult2)
   1.490 -    also have "(%x. 1 / f x) * (f * g) = g"
   1.491 +    also have "(\<lambda>x. 1 / f x) * (f * g) = g"
   1.492        apply (simp add: func_times)
   1.493        apply (rule ext)
   1.494        apply (simp add: a h nonzero_divide_eq_eq mult_ac)
   1.495        done
   1.496 -    finally have "(%x. (1::'b) / f x) * h : O(g)".
   1.497 -    then have "f * ((%x. (1::'b) / f x) * h) : f *o O(g)"
   1.498 +    finally have "(\<lambda>x. (1\<Colon>'b) / f x) * h : O(g)".
   1.499 +    then have "f * ((\<lambda>x. (1\<Colon>'b) / f x) * h) : f *o O(g)"
   1.500        by auto
   1.501 -    also have "f * ((%x. (1::'b) / f x) * h) = h"
   1.502 +    also have "f * ((\<lambda>x. (1\<Colon>'b) / f x) * h) = h"
   1.503        apply (simp add: func_times)
   1.504        apply (rule ext)
   1.505        apply (simp add: a h nonzero_divide_eq_eq mult_ac)
   1.506 @@ -453,34 +387,32 @@
   1.507    qed
   1.508  qed
   1.509  
   1.510 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_mult6" ]]
   1.511 -lemma bigo_mult6: "ALL x. f x ~= 0 ==>
   1.512 -    O(f * g) = (f::'a => ('b::{linordered_field,number_ring})) *o O(g)"
   1.513 +lemma bigo_mult6: "\<forall>x. f x ~= 0 \<Longrightarrow>
   1.514 +    O(f * g) = (f\<Colon>'a => ('b\<Colon>{linordered_field,number_ring})) *o O(g)"
   1.515  by (metis bigo_mult2 bigo_mult5 order_antisym)
   1.516  
   1.517  (*proof requires relaxing relevance: 2007-01-25*)
   1.518 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_mult7" ]]
   1.519    declare bigo_mult6 [simp]
   1.520 -lemma bigo_mult7: "ALL x. f x ~= 0 ==>
   1.521 -    O(f * g) <= O(f::'a => ('b::{linordered_field,number_ring})) \<otimes> O(g)"
   1.522 -(*sledgehammer*)
   1.523 +lemma bigo_mult7: "\<forall>x. f x ~= 0 \<Longrightarrow>
   1.524 +    O(f * g) <= O(f\<Colon>'a => ('b\<Colon>{linordered_field,number_ring})) \<otimes> O(g)"
   1.525 +(* sledgehammer *)
   1.526    apply (subst bigo_mult6)
   1.527    apply assumption
   1.528    apply (rule set_times_mono3)
   1.529    apply (rule bigo_refl)
   1.530  done
   1.531 -  declare bigo_mult6 [simp del]
   1.532  
   1.533 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_mult8" ]]
   1.534 -  declare bigo_mult7[intro!]
   1.535 -lemma bigo_mult8: "ALL x. f x ~= 0 ==>
   1.536 -    O(f * g) = O(f::'a => ('b::{linordered_field,number_ring})) \<otimes> O(g)"
   1.537 +declare bigo_mult6 [simp del]
   1.538 +declare bigo_mult7 [intro!]
   1.539 +
   1.540 +lemma bigo_mult8: "\<forall>x. f x ~= 0 \<Longrightarrow>
   1.541 +    O(f * g) = O(f\<Colon>'a => ('b\<Colon>{linordered_field,number_ring})) \<otimes> O(g)"
   1.542  by (metis bigo_mult bigo_mult7 order_antisym_conv)
   1.543  
   1.544 -lemma bigo_minus [intro]: "f : O(g) ==> - f : O(g)"
   1.545 +lemma bigo_minus [intro]: "f : O(g) \<Longrightarrow> - f : O(g)"
   1.546    by (auto simp add: bigo_def fun_Compl_def)
   1.547  
   1.548 -lemma bigo_minus2: "f : g +o O(h) ==> -f : -g +o O(h)"
   1.549 +lemma bigo_minus2: "f : g +o O(h) \<Longrightarrow> -f : -g +o O(h)"
   1.550    apply (rule set_minus_imp_plus)
   1.551    apply (drule set_plus_imp_minus)
   1.552    apply (drule bigo_minus)
   1.553 @@ -490,7 +422,7 @@
   1.554  lemma bigo_minus3: "O(-f) = O(f)"
   1.555    by (auto simp add: bigo_def fun_Compl_def abs_minus_cancel)
   1.556  
   1.557 -lemma bigo_plus_absorb_lemma1: "f : O(g) ==> f +o O(g) <= O(g)"
   1.558 +lemma bigo_plus_absorb_lemma1: "f : O(g) \<Longrightarrow> f +o O(g) <= O(g)"
   1.559  proof -
   1.560    assume a: "f : O(g)"
   1.561    show "f +o O(g) <= O(g)"
   1.562 @@ -508,7 +440,7 @@
   1.563    qed
   1.564  qed
   1.565  
   1.566 -lemma bigo_plus_absorb_lemma2: "f : O(g) ==> O(g) <= f +o O(g)"
   1.567 +lemma bigo_plus_absorb_lemma2: "f : O(g) \<Longrightarrow> O(g) <= f +o O(g)"
   1.568  proof -
   1.569    assume a: "f : O(g)"
   1.570    show "O(g) <= f +o O(g)"
   1.571 @@ -522,23 +454,22 @@
   1.572    qed
   1.573  qed
   1.574  
   1.575 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_plus_absorb" ]]
   1.576 -lemma bigo_plus_absorb [simp]: "f : O(g) ==> f +o O(g) = O(g)"
   1.577 +lemma bigo_plus_absorb [simp]: "f : O(g) \<Longrightarrow> f +o O(g) = O(g)"
   1.578  by (metis bigo_plus_absorb_lemma1 bigo_plus_absorb_lemma2 order_eq_iff)
   1.579  
   1.580 -lemma bigo_plus_absorb2 [intro]: "f : O(g) ==> A <= O(g) ==> f +o A <= O(g)"
   1.581 +lemma bigo_plus_absorb2 [intro]: "f : O(g) \<Longrightarrow> A <= O(g) \<Longrightarrow> f +o A <= O(g)"
   1.582    apply (subgoal_tac "f +o A <= f +o O(g)")
   1.583    apply force+
   1.584  done
   1.585  
   1.586 -lemma bigo_add_commute_imp: "f : g +o O(h) ==> g : f +o O(h)"
   1.587 +lemma bigo_add_commute_imp: "f : g +o O(h) \<Longrightarrow> g : f +o O(h)"
   1.588    apply (subst set_minus_plus [symmetric])
   1.589    apply (subgoal_tac "g - f = - (f - g)")
   1.590    apply (erule ssubst)
   1.591    apply (rule bigo_minus)
   1.592    apply (subst set_minus_plus)
   1.593    apply assumption
   1.594 -  apply  (simp add: diff_minus add_ac)
   1.595 +  apply (simp add: diff_minus add_ac)
   1.596  done
   1.597  
   1.598  lemma bigo_add_commute: "(f : g +o O(h)) = (g : f +o O(h))"
   1.599 @@ -546,67 +477,60 @@
   1.600    apply (erule bigo_add_commute_imp)+
   1.601  done
   1.602  
   1.603 -lemma bigo_const1: "(%x. c) : O(%x. 1)"
   1.604 +lemma bigo_const1: "(\<lambda>x. c) : O(\<lambda>x. 1)"
   1.605  by (auto simp add: bigo_def mult_ac)
   1.606  
   1.607 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_const2" ]]
   1.608 -lemma (*bigo_const2 [intro]:*) "O(%x. c) <= O(%x. 1)"
   1.609 +lemma (*bigo_const2 [intro]:*) "O(\<lambda>x. c) <= O(\<lambda>x. 1)"
   1.610  by (metis bigo_const1 bigo_elt_subset)
   1.611  
   1.612 -lemma bigo_const2 [intro]: "O(%x. c::'b::{linordered_idom,number_ring}) <= O(%x. 1)"
   1.613 -(* "thus" had to be replaced by "show" with an explicit reference to "F1" *)
   1.614 +lemma bigo_const2 [intro]: "O(\<lambda>x. c\<Colon>'b\<Colon>{linordered_idom,number_ring}) <= O(\<lambda>x. 1)"
   1.615  proof -
   1.616 -  have F1: "\<forall>u. (\<lambda>Q. u) \<in> O(\<lambda>Q. 1)" by (metis bigo_const1)
   1.617 -  show "O(\<lambda>x. c) \<subseteq> O(\<lambda>x. 1)" by (metis F1 bigo_elt_subset)
   1.618 +  have "\<forall>u. (\<lambda>Q. u) \<in> O(\<lambda>Q. 1)" by (metis bigo_const1)
   1.619 +  thus "O(\<lambda>x. c) \<subseteq> O(\<lambda>x. 1)" by (metis bigo_elt_subset)
   1.620  qed
   1.621  
   1.622 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_const3" ]]
   1.623 -lemma bigo_const3: "(c::'a::{linordered_field,number_ring}) ~= 0 ==> (%x. 1) : O(%x. c)"
   1.624 +lemma bigo_const3: "(c\<Colon>'a\<Colon>{linordered_field,number_ring}) ~= 0 \<Longrightarrow> (\<lambda>x. 1) : O(\<lambda>x. c)"
   1.625  apply (simp add: bigo_def)
   1.626  by (metis abs_eq_0 left_inverse order_refl)
   1.627  
   1.628 -lemma bigo_const4: "(c::'a::{linordered_field,number_ring}) ~= 0 ==> O(%x. 1) <= O(%x. c)"
   1.629 +lemma bigo_const4: "(c\<Colon>'a\<Colon>{linordered_field,number_ring}) ~= 0 \<Longrightarrow> O(\<lambda>x. 1) <= O(\<lambda>x. c)"
   1.630  by (rule bigo_elt_subset, rule bigo_const3, assumption)
   1.631  
   1.632 -lemma bigo_const [simp]: "(c::'a::{linordered_field,number_ring}) ~= 0 ==>
   1.633 -    O(%x. c) = O(%x. 1)"
   1.634 +lemma bigo_const [simp]: "(c\<Colon>'a\<Colon>{linordered_field,number_ring}) ~= 0 \<Longrightarrow>
   1.635 +    O(\<lambda>x. c) = O(\<lambda>x. 1)"
   1.636  by (rule equalityI, rule bigo_const2, rule bigo_const4, assumption)
   1.637  
   1.638 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_const_mult1" ]]
   1.639 -lemma bigo_const_mult1: "(%x. c * f x) : O(f)"
   1.640 +lemma bigo_const_mult1: "(\<lambda>x. c * f x) : O(f)"
   1.641    apply (simp add: bigo_def abs_mult)
   1.642  by (metis le_less)
   1.643  
   1.644 -lemma bigo_const_mult2: "O(%x. c * f x) <= O(f)"
   1.645 +lemma bigo_const_mult2: "O(\<lambda>x. c * f x) <= O(f)"
   1.646  by (rule bigo_elt_subset, rule bigo_const_mult1)
   1.647  
   1.648 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_const_mult3" ]]
   1.649 -lemma bigo_const_mult3: "(c::'a::{linordered_field,number_ring}) ~= 0 ==> f : O(%x. c * f x)"
   1.650 -  apply (simp add: bigo_def)
   1.651 -(*sledgehammer [no luck]*)
   1.652 -  apply (rule_tac x = "abs(inverse c)" in exI)
   1.653 -  apply (simp only: abs_mult [symmetric] mult_assoc [symmetric])
   1.654 +lemma bigo_const_mult3: "(c\<Colon>'a\<Colon>{linordered_field,number_ring}) ~= 0 \<Longrightarrow> f : O(\<lambda>x. c * f x)"
   1.655 +apply (simp add: bigo_def)
   1.656 +(* sledgehammer *)
   1.657 +apply (rule_tac x = "abs(inverse c)" in exI)
   1.658 +apply (simp only: abs_mult [symmetric] mult_assoc [symmetric])
   1.659  apply (subst left_inverse)
   1.660 -apply (auto )
   1.661 -done
   1.662 +by auto
   1.663  
   1.664 -lemma bigo_const_mult4: "(c::'a::{linordered_field,number_ring}) ~= 0 ==>
   1.665 -    O(f) <= O(%x. c * f x)"
   1.666 +lemma bigo_const_mult4: "(c\<Colon>'a\<Colon>{linordered_field,number_ring}) ~= 0 \<Longrightarrow>
   1.667 +    O(f) <= O(\<lambda>x. c * f x)"
   1.668  by (rule bigo_elt_subset, rule bigo_const_mult3, assumption)
   1.669  
   1.670 -lemma bigo_const_mult [simp]: "(c::'a::{linordered_field,number_ring}) ~= 0 ==>
   1.671 -    O(%x. c * f x) = O(f)"
   1.672 +lemma bigo_const_mult [simp]: "(c\<Colon>'a\<Colon>{linordered_field,number_ring}) ~= 0 \<Longrightarrow>
   1.673 +    O(\<lambda>x. c * f x) = O(f)"
   1.674  by (rule equalityI, rule bigo_const_mult2, erule bigo_const_mult4)
   1.675  
   1.676 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_const_mult5" ]]
   1.677 -lemma bigo_const_mult5 [simp]: "(c::'a::{linordered_field,number_ring}) ~= 0 ==>
   1.678 -    (%x. c) *o O(f) = O(f)"
   1.679 +lemma bigo_const_mult5 [simp]: "(c\<Colon>'a\<Colon>{linordered_field,number_ring}) ~= 0 \<Longrightarrow>
   1.680 +    (\<lambda>x. c) *o O(f) = O(f)"
   1.681    apply (auto del: subsetI)
   1.682    apply (rule order_trans)
   1.683    apply (rule bigo_mult2)
   1.684    apply (simp add: func_times)
   1.685    apply (auto intro!: subsetI simp add: bigo_def elt_set_times_def func_times)
   1.686 -  apply (rule_tac x = "%y. inverse c * x y" in exI)
   1.687 +  apply (rule_tac x = "\<lambda>y. inverse c * x y" in exI)
   1.688    apply (rename_tac g d)
   1.689    apply safe
   1.690    apply (rule_tac [2] ext)
   1.691 @@ -633,13 +557,11 @@
   1.692      using A2 F4 by (metis ab_semigroup_mult_class.mult_ac(1) comm_mult_left_mono)
   1.693  qed
   1.694  
   1.695 -
   1.696 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_const_mult6" ]]
   1.697 -lemma bigo_const_mult6 [intro]: "(%x. c) *o O(f) <= O(f)"
   1.698 +lemma bigo_const_mult6 [intro]: "(\<lambda>x. c) *o O(f) <= O(f)"
   1.699    apply (auto intro!: subsetI
   1.700      simp add: bigo_def elt_set_times_def func_times
   1.701      simp del: abs_mult mult_ac)
   1.702 -(*sledgehammer*)
   1.703 +(* sledgehammer *)
   1.704    apply (rule_tac x = "ca * (abs c)" in exI)
   1.705    apply (rule allI)
   1.706    apply (subgoal_tac "ca * abs(c) * abs(f x) = abs(c) * (ca * abs(f x))")
   1.707 @@ -651,23 +573,23 @@
   1.708    apply(simp add: mult_ac)
   1.709  done
   1.710  
   1.711 -lemma bigo_const_mult7 [intro]: "f =o O(g) ==> (%x. c * f x) =o O(g)"
   1.712 +lemma bigo_const_mult7 [intro]: "f =o O(g) \<Longrightarrow> (\<lambda>x. c * f x) =o O(g)"
   1.713  proof -
   1.714    assume "f =o O(g)"
   1.715 -  then have "(%x. c) * f =o (%x. c) *o O(g)"
   1.716 +  then have "(\<lambda>x. c) * f =o (\<lambda>x. c) *o O(g)"
   1.717      by auto
   1.718 -  also have "(%x. c) * f = (%x. c * f x)"
   1.719 +  also have "(\<lambda>x. c) * f = (\<lambda>x. c * f x)"
   1.720      by (simp add: func_times)
   1.721 -  also have "(%x. c) *o O(g) <= O(g)"
   1.722 +  also have "(\<lambda>x. c) *o O(g) <= O(g)"
   1.723      by (auto del: subsetI)
   1.724    finally show ?thesis .
   1.725  qed
   1.726  
   1.727 -lemma bigo_compose1: "f =o O(g) ==> (%x. f(k x)) =o O(%x. g(k x))"
   1.728 +lemma bigo_compose1: "f =o O(g) \<Longrightarrow> (\<lambda>x. f(k x)) =o O(\<lambda>x. g(k x))"
   1.729  by (unfold bigo_def, auto)
   1.730  
   1.731 -lemma bigo_compose2: "f =o g +o O(h) ==> (%x. f(k x)) =o (%x. g(k x)) +o
   1.732 -    O(%x. h(k x))"
   1.733 +lemma bigo_compose2: "f =o g +o O(h) \<Longrightarrow> (\<lambda>x. f(k x)) =o (\<lambda>x. g(k x)) +o
   1.734 +    O(\<lambda>x. h(k x))"
   1.735    apply (simp only: set_minus_plus [symmetric] diff_minus fun_Compl_def
   1.736        func_plus)
   1.737    apply (erule bigo_compose1)
   1.738 @@ -675,9 +597,9 @@
   1.739  
   1.740  subsection {* Setsum *}
   1.741  
   1.742 -lemma bigo_setsum_main: "ALL x. ALL y : A x. 0 <= h x y ==>
   1.743 -    EX c. ALL x. ALL y : A x. abs(f x y) <= c * (h x y) ==>
   1.744 -      (%x. SUM y : A x. f x y) =o O(%x. SUM y : A x. h x y)"
   1.745 +lemma bigo_setsum_main: "\<forall>x. \<forall>y \<in> A x. 0 <= h x y \<Longrightarrow>
   1.746 +    \<exists>c. \<forall>x. \<forall>y \<in> A x. abs (f x y) <= c * (h x y) \<Longrightarrow>
   1.747 +      (\<lambda>x. SUM y : A x. f x y) =o O(\<lambda>x. SUM y : A x. h x y)"
   1.748    apply (auto simp add: bigo_def)
   1.749    apply (rule_tac x = "abs c" in exI)
   1.750    apply (subst abs_of_nonneg) back back
   1.751 @@ -691,61 +613,50 @@
   1.752  apply (blast intro: order_trans mult_right_mono abs_ge_self)
   1.753  done
   1.754  
   1.755 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_setsum1" ]]
   1.756 -lemma bigo_setsum1: "ALL x y. 0 <= h x y ==>
   1.757 -    EX c. ALL x y. abs(f x y) <= c * (h x y) ==>
   1.758 -      (%x. SUM y : A x. f x y) =o O(%x. SUM y : A x. h x y)"
   1.759 -  apply (rule bigo_setsum_main)
   1.760 -(*sledgehammer*)
   1.761 -  apply force
   1.762 -  apply clarsimp
   1.763 -  apply (rule_tac x = c in exI)
   1.764 -  apply force
   1.765 -done
   1.766 +lemma bigo_setsum1: "\<forall>x y. 0 <= h x y \<Longrightarrow>
   1.767 +    \<exists>c. \<forall>x y. abs (f x y) <= c * (h x y) \<Longrightarrow>
   1.768 +      (\<lambda>x. SUM y : A x. f x y) =o O(\<lambda>x. SUM y : A x. h x y)"
   1.769 +by (metis (no_types) bigo_setsum_main)
   1.770  
   1.771 -lemma bigo_setsum2: "ALL y. 0 <= h y ==>
   1.772 -    EX c. ALL y. abs(f y) <= c * (h y) ==>
   1.773 -      (%x. SUM y : A x. f y) =o O(%x. SUM y : A x. h y)"
   1.774 +lemma bigo_setsum2: "\<forall>y. 0 <= h y \<Longrightarrow>
   1.775 +    \<exists>c. \<forall>y. abs(f y) <= c * (h y) \<Longrightarrow>
   1.776 +      (\<lambda>x. SUM y : A x. f y) =o O(\<lambda>x. SUM y : A x. h y)"
   1.777  by (rule bigo_setsum1, auto)
   1.778  
   1.779 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_setsum3" ]]
   1.780 -lemma bigo_setsum3: "f =o O(h) ==>
   1.781 -    (%x. SUM y : A x. (l x y) * f(k x y)) =o
   1.782 -      O(%x. SUM y : A x. abs(l x y * h(k x y)))"
   1.783 -  apply (rule bigo_setsum1)
   1.784 -  apply (rule allI)+
   1.785 -  apply (rule abs_ge_zero)
   1.786 -  apply (unfold bigo_def)
   1.787 -  apply (auto simp add: abs_mult)
   1.788 -(*sledgehammer*)
   1.789 -  apply (rule_tac x = c in exI)
   1.790 -  apply (rule allI)+
   1.791 -  apply (subst mult_left_commute)
   1.792 -  apply (rule mult_left_mono)
   1.793 -  apply (erule spec)
   1.794 -  apply (rule abs_ge_zero)
   1.795 -done
   1.796 +lemma bigo_setsum3: "f =o O(h) \<Longrightarrow>
   1.797 +    (\<lambda>x. SUM y : A x. (l x y) * f(k x y)) =o
   1.798 +      O(\<lambda>x. SUM y : A x. abs(l x y * h(k x y)))"
   1.799 +apply (rule bigo_setsum1)
   1.800 + apply (rule allI)+
   1.801 + apply (rule abs_ge_zero)
   1.802 +apply (unfold bigo_def)
   1.803 +apply (auto simp add: abs_mult)
   1.804 +(* sledgehammer *)
   1.805 +apply (rule_tac x = c in exI)
   1.806 +apply (rule allI)+
   1.807 +apply (subst mult_left_commute)
   1.808 +apply (rule mult_left_mono)
   1.809 + apply (erule spec)
   1.810 +by (rule abs_ge_zero)
   1.811  
   1.812 -lemma bigo_setsum4: "f =o g +o O(h) ==>
   1.813 -    (%x. SUM y : A x. l x y * f(k x y)) =o
   1.814 -      (%x. SUM y : A x. l x y * g(k x y)) +o
   1.815 -        O(%x. SUM y : A x. abs(l x y * h(k x y)))"
   1.816 -  apply (rule set_minus_imp_plus)
   1.817 -  apply (subst fun_diff_def)
   1.818 -  apply (subst setsum_subtractf [symmetric])
   1.819 -  apply (subst right_diff_distrib [symmetric])
   1.820 -  apply (rule bigo_setsum3)
   1.821 -  apply (subst fun_diff_def [symmetric])
   1.822 -  apply (erule set_plus_imp_minus)
   1.823 -done
   1.824 +lemma bigo_setsum4: "f =o g +o O(h) \<Longrightarrow>
   1.825 +    (\<lambda>x. SUM y : A x. l x y * f(k x y)) =o
   1.826 +      (\<lambda>x. SUM y : A x. l x y * g(k x y)) +o
   1.827 +        O(\<lambda>x. SUM y : A x. abs(l x y * h(k x y)))"
   1.828 +apply (rule set_minus_imp_plus)
   1.829 +apply (subst fun_diff_def)
   1.830 +apply (subst setsum_subtractf [symmetric])
   1.831 +apply (subst right_diff_distrib [symmetric])
   1.832 +apply (rule bigo_setsum3)
   1.833 +apply (subst fun_diff_def [symmetric])
   1.834 +by (erule set_plus_imp_minus)
   1.835  
   1.836 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_setsum5" ]]
   1.837 -lemma bigo_setsum5: "f =o O(h) ==> ALL x y. 0 <= l x y ==>
   1.838 -    ALL x. 0 <= h x ==>
   1.839 -      (%x. SUM y : A x. (l x y) * f(k x y)) =o
   1.840 -        O(%x. SUM y : A x. (l x y) * h(k x y))"
   1.841 -  apply (subgoal_tac "(%x. SUM y : A x. (l x y) * h(k x y)) =
   1.842 -      (%x. SUM y : A x. abs((l x y) * h(k x y)))")
   1.843 +lemma bigo_setsum5: "f =o O(h) \<Longrightarrow> \<forall>x y. 0 <= l x y \<Longrightarrow>
   1.844 +    \<forall>x. 0 <= h x \<Longrightarrow>
   1.845 +      (\<lambda>x. SUM y : A x. (l x y) * f(k x y)) =o
   1.846 +        O(\<lambda>x. SUM y : A x. (l x y) * h(k x y))"
   1.847 +  apply (subgoal_tac "(\<lambda>x. SUM y : A x. (l x y) * h(k x y)) =
   1.848 +      (\<lambda>x. SUM y : A x. abs((l x y) * h(k x y)))")
   1.849    apply (erule ssubst)
   1.850    apply (erule bigo_setsum3)
   1.851    apply (rule ext)
   1.852 @@ -754,11 +665,11 @@
   1.853  apply (metis abs_of_nonneg zero_le_mult_iff)
   1.854  done
   1.855  
   1.856 -lemma bigo_setsum6: "f =o g +o O(h) ==> ALL x y. 0 <= l x y ==>
   1.857 -    ALL x. 0 <= h x ==>
   1.858 -      (%x. SUM y : A x. (l x y) * f(k x y)) =o
   1.859 -        (%x. SUM y : A x. (l x y) * g(k x y)) +o
   1.860 -          O(%x. SUM y : A x. (l x y) * h(k x y))"
   1.861 +lemma bigo_setsum6: "f =o g +o O(h) \<Longrightarrow> \<forall>x y. 0 <= l x y \<Longrightarrow>
   1.862 +    \<forall>x. 0 <= h x \<Longrightarrow>
   1.863 +      (\<lambda>x. SUM y : A x. (l x y) * f(k x y)) =o
   1.864 +        (\<lambda>x. SUM y : A x. (l x y) * g(k x y)) +o
   1.865 +          O(\<lambda>x. SUM y : A x. (l x y) * h(k x y))"
   1.866    apply (rule set_minus_imp_plus)
   1.867    apply (subst fun_diff_def)
   1.868    apply (subst setsum_subtractf [symmetric])
   1.869 @@ -771,50 +682,39 @@
   1.870  
   1.871  subsection {* Misc useful stuff *}
   1.872  
   1.873 -lemma bigo_useful_intro: "A <= O(f) ==> B <= O(f) ==>
   1.874 +lemma bigo_useful_intro: "A <= O(f) \<Longrightarrow> B <= O(f) \<Longrightarrow>
   1.875    A \<oplus> B <= O(f)"
   1.876    apply (subst bigo_plus_idemp [symmetric])
   1.877    apply (rule set_plus_mono2)
   1.878    apply assumption+
   1.879  done
   1.880  
   1.881 -lemma bigo_useful_add: "f =o O(h) ==> g =o O(h) ==> f + g =o O(h)"
   1.882 +lemma bigo_useful_add: "f =o O(h) \<Longrightarrow> g =o O(h) \<Longrightarrow> f + g =o O(h)"
   1.883    apply (subst bigo_plus_idemp [symmetric])
   1.884    apply (rule set_plus_intro)
   1.885    apply assumption+
   1.886  done
   1.887  
   1.888 -lemma bigo_useful_const_mult: "(c::'a::{linordered_field,number_ring}) ~= 0 ==>
   1.889 -    (%x. c) * f =o O(h) ==> f =o O(h)"
   1.890 +lemma bigo_useful_const_mult: "(c\<Colon>'a\<Colon>{linordered_field,number_ring}) ~= 0 \<Longrightarrow>
   1.891 +    (\<lambda>x. c) * f =o O(h) \<Longrightarrow> f =o O(h)"
   1.892    apply (rule subsetD)
   1.893 -  apply (subgoal_tac "(%x. 1 / c) *o O(h) <= O(h)")
   1.894 +  apply (subgoal_tac "(\<lambda>x. 1 / c) *o O(h) <= O(h)")
   1.895    apply assumption
   1.896    apply (rule bigo_const_mult6)
   1.897 -  apply (subgoal_tac "f = (%x. 1 / c) * ((%x. c) * f)")
   1.898 +  apply (subgoal_tac "f = (\<lambda>x. 1 / c) * ((\<lambda>x. c) * f)")
   1.899    apply (erule ssubst)
   1.900    apply (erule set_times_intro2)
   1.901    apply (simp add: func_times)
   1.902  done
   1.903  
   1.904 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_fix" ]]
   1.905 -lemma bigo_fix: "(%x. f ((x::nat) + 1)) =o O(%x. h(x + 1)) ==> f 0 = 0 ==>
   1.906 +lemma bigo_fix: "(\<lambda>x. f ((x\<Colon>nat) + 1)) =o O(\<lambda>x. h(x + 1)) \<Longrightarrow> f 0 = 0 \<Longrightarrow>
   1.907      f =o O(h)"
   1.908 -  apply (simp add: bigo_alt_def)
   1.909 -(*sledgehammer*)
   1.910 -  apply clarify
   1.911 -  apply (rule_tac x = c in exI)
   1.912 -  apply safe
   1.913 -  apply (case_tac "x = 0")
   1.914 -apply (metis abs_ge_zero  abs_zero  order_less_le  split_mult_pos_le)
   1.915 -  apply (subgoal_tac "x = Suc (x - 1)")
   1.916 -  apply metis
   1.917 -  apply simp
   1.918 -  done
   1.919 -
   1.920 +apply (simp add: bigo_alt_def)
   1.921 +by (metis abs_ge_zero abs_mult abs_of_pos abs_zero not0_implies_Suc)
   1.922  
   1.923  lemma bigo_fix2:
   1.924 -    "(%x. f ((x::nat) + 1)) =o (%x. g(x + 1)) +o O(%x. h(x + 1)) ==>
   1.925 -       f 0 = g 0 ==> f =o g +o O(h)"
   1.926 +    "(\<lambda>x. f ((x\<Colon>nat) + 1)) =o (\<lambda>x. g(x + 1)) +o O(\<lambda>x. h(x + 1)) \<Longrightarrow>
   1.927 +       f 0 = g 0 \<Longrightarrow> f =o g +o O(h)"
   1.928    apply (rule set_minus_imp_plus)
   1.929    apply (rule bigo_fix)
   1.930    apply (subst fun_diff_def)
   1.931 @@ -826,23 +726,23 @@
   1.932  
   1.933  subsection {* Less than or equal to *}
   1.934  
   1.935 -definition lesso :: "('a => 'b::linordered_idom) => ('a => 'b) => ('a => 'b)" (infixl "<o" 70) where
   1.936 -  "f <o g == (%x. max (f x - g x) 0)"
   1.937 +definition lesso :: "('a => 'b\<Colon>linordered_idom) => ('a => 'b) => ('a => 'b)" (infixl "<o" 70) where
   1.938 +  "f <o g == (\<lambda>x. max (f x - g x) 0)"
   1.939  
   1.940 -lemma bigo_lesseq1: "f =o O(h) ==> ALL x. abs (g x) <= abs (f x) ==>
   1.941 +lemma bigo_lesseq1: "f =o O(h) \<Longrightarrow> \<forall>x. abs (g x) <= abs (f x) \<Longrightarrow>
   1.942      g =o O(h)"
   1.943    apply (unfold bigo_def)
   1.944    apply clarsimp
   1.945  apply (blast intro: order_trans)
   1.946  done
   1.947  
   1.948 -lemma bigo_lesseq2: "f =o O(h) ==> ALL x. abs (g x) <= f x ==>
   1.949 +lemma bigo_lesseq2: "f =o O(h) \<Longrightarrow> \<forall>x. abs (g x) <= f x \<Longrightarrow>
   1.950        g =o O(h)"
   1.951    apply (erule bigo_lesseq1)
   1.952  apply (blast intro: abs_ge_self order_trans)
   1.953  done
   1.954  
   1.955 -lemma bigo_lesseq3: "f =o O(h) ==> ALL x. 0 <= g x ==> ALL x. g x <= f x ==>
   1.956 +lemma bigo_lesseq3: "f =o O(h) \<Longrightarrow> \<forall>x. 0 <= g x \<Longrightarrow> \<forall>x. g x <= f x \<Longrightarrow>
   1.957        g =o O(h)"
   1.958    apply (erule bigo_lesseq2)
   1.959    apply (rule allI)
   1.960 @@ -850,8 +750,8 @@
   1.961    apply (erule spec)+
   1.962  done
   1.963  
   1.964 -lemma bigo_lesseq4: "f =o O(h) ==>
   1.965 -    ALL x. 0 <= g x ==> ALL x. g x <= abs (f x) ==>
   1.966 +lemma bigo_lesseq4: "f =o O(h) \<Longrightarrow>
   1.967 +    \<forall>x. 0 <= g x \<Longrightarrow> \<forall>x. g x <= abs (f x) \<Longrightarrow>
   1.968        g =o O(h)"
   1.969    apply (erule bigo_lesseq1)
   1.970    apply (rule allI)
   1.971 @@ -859,23 +759,15 @@
   1.972    apply (erule spec)+
   1.973  done
   1.974  
   1.975 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_lesso1" ]]
   1.976 -lemma bigo_lesso1: "ALL x. f x <= g x ==> f <o g =o O(h)"
   1.977 +lemma bigo_lesso1: "\<forall>x. f x <= g x \<Longrightarrow> f <o g =o O(h)"
   1.978  apply (unfold lesso_def)
   1.979 -apply (subgoal_tac "(%x. max (f x - g x) 0) = 0")
   1.980 -proof -
   1.981 -  assume "(\<lambda>x. max (f x - g x) 0) = 0"
   1.982 -  thus "(\<lambda>x. max (f x - g x) 0) \<in> O(h)" by (metis bigo_zero)
   1.983 -next
   1.984 -  show "\<forall>x\<Colon>'a. f x \<le> g x \<Longrightarrow> (\<lambda>x\<Colon>'a. max (f x - g x) (0\<Colon>'b)) = (0\<Colon>'a \<Rightarrow> 'b)"
   1.985 -  apply (unfold func_zero)
   1.986 -  apply (rule ext)
   1.987 -  by (simp split: split_max)
   1.988 -qed
   1.989 +apply (subgoal_tac "(\<lambda>x. max (f x - g x) 0) = 0")
   1.990 + apply (metis bigo_zero)
   1.991 +by (metis (lam_lifting, no_types) func_zero le_fun_def le_iff_diff_le_0
   1.992 +      min_max.sup_absorb2 order_eq_iff)
   1.993  
   1.994 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_lesso2" ]]
   1.995 -lemma bigo_lesso2: "f =o g +o O(h) ==>
   1.996 -    ALL x. 0 <= k x ==> ALL x. k x <= f x ==>
   1.997 +lemma bigo_lesso2: "f =o g +o O(h) \<Longrightarrow>
   1.998 +    \<forall>x. 0 <= k x \<Longrightarrow> \<forall>x. k x <= f x \<Longrightarrow>
   1.999        k <o g =o O(h)"
  1.1000    apply (unfold lesso_def)
  1.1001    apply (rule bigo_lesseq4)
  1.1002 @@ -885,33 +777,15 @@
  1.1003    apply (rule allI)
  1.1004    apply (subst fun_diff_def)
  1.1005  apply (erule thin_rl)
  1.1006 -(*sledgehammer*)
  1.1007 -  apply (case_tac "0 <= k x - g x")
  1.1008 -(* apply (metis abs_le_iff add_le_imp_le_right diff_minus le_less
  1.1009 -                le_max_iff_disj min_max.le_supE min_max.sup_absorb2
  1.1010 -                min_max.sup_commute) *)
  1.1011 -proof -
  1.1012 -  fix x :: 'a
  1.1013 -  assume "\<forall>x\<Colon>'a. k x \<le> f x"
  1.1014 -  hence F1: "\<forall>x\<^isub>1\<Colon>'a. max (k x\<^isub>1) (f x\<^isub>1) = f x\<^isub>1" by (metis min_max.sup_absorb2)
  1.1015 -  assume "(0\<Colon>'b) \<le> k x - g x"
  1.1016 -  hence F2: "max (0\<Colon>'b) (k x - g x) = k x - g x" by (metis min_max.sup_absorb2)
  1.1017 -  have F3: "\<forall>x\<^isub>1\<Colon>'b. x\<^isub>1 \<le> \<bar>x\<^isub>1\<bar>" by (metis abs_le_iff le_less)
  1.1018 -  have "\<forall>(x\<^isub>2\<Colon>'b) x\<^isub>1\<Colon>'b. max x\<^isub>1 x\<^isub>2 \<le> x\<^isub>2 \<or> max x\<^isub>1 x\<^isub>2 \<le> x\<^isub>1" by (metis le_less le_max_iff_disj)
  1.1019 -  hence "\<forall>(x\<^isub>3\<Colon>'b) (x\<^isub>2\<Colon>'b) x\<^isub>1\<Colon>'b. x\<^isub>1 - x\<^isub>2 \<le> x\<^isub>3 - x\<^isub>2 \<or> x\<^isub>3 \<le> x\<^isub>1" by (metis add_le_imp_le_right diff_minus min_max.le_supE)
  1.1020 -  hence "k x - g x \<le> f x - g x" by (metis F1 le_less min_max.sup_absorb2 min_max.sup_commute)
  1.1021 -  hence "k x - g x \<le> \<bar>f x - g x\<bar>" by (metis F3 le_max_iff_disj min_max.sup_absorb2)
  1.1022 -  thus "max (k x - g x) (0\<Colon>'b) \<le> \<bar>f x - g x\<bar>" by (metis F2 min_max.sup_commute)
  1.1023 -next
  1.1024 -  show "\<And>x\<Colon>'a.
  1.1025 -       \<lbrakk>\<forall>x\<Colon>'a. (0\<Colon>'b) \<le> k x; \<forall>x\<Colon>'a. k x \<le> f x; \<not> (0\<Colon>'b) \<le> k x - g x\<rbrakk>
  1.1026 -       \<Longrightarrow> max (k x - g x) (0\<Colon>'b) \<le> \<bar>f x - g x\<bar>"
  1.1027 -    by (metis abs_ge_zero le_cases min_max.sup_absorb2)
  1.1028 -qed
  1.1029 +(* sledgehammer *)
  1.1030 +apply (case_tac "0 <= k x - g x")
  1.1031 + apply (metis (hide_lams, no_types) abs_le_iff add_le_imp_le_right diff_minus le_less
  1.1032 +          le_max_iff_disj min_max.le_supE min_max.sup_absorb2
  1.1033 +          min_max.sup_commute)
  1.1034 +by (metis abs_ge_zero le_cases min_max.sup_absorb2)
  1.1035  
  1.1036 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_lesso3" ]]
  1.1037 -lemma bigo_lesso3: "f =o g +o O(h) ==>
  1.1038 -    ALL x. 0 <= k x ==> ALL x. g x <= k x ==>
  1.1039 +lemma bigo_lesso3: "f =o g +o O(h) \<Longrightarrow>
  1.1040 +    \<forall>x. 0 <= k x \<Longrightarrow> \<forall>x. g x <= k x \<Longrightarrow>
  1.1041        f <o k =o O(h)"
  1.1042    apply (unfold lesso_def)
  1.1043    apply (rule bigo_lesseq4)
  1.1044 @@ -920,20 +794,19 @@
  1.1045    apply (rule le_maxI2)
  1.1046    apply (rule allI)
  1.1047    apply (subst fun_diff_def)
  1.1048 -apply (erule thin_rl)
  1.1049 -(*sledgehammer*)
  1.1050 +  apply (erule thin_rl)
  1.1051 +  (* sledgehammer *)
  1.1052    apply (case_tac "0 <= f x - k x")
  1.1053 -  apply (simp)
  1.1054 +  apply simp
  1.1055    apply (subst abs_of_nonneg)
  1.1056    apply (drule_tac x = x in spec) back
  1.1057 -using [[ sledgehammer_problem_prefix = "BigO__bigo_lesso3_simpler" ]]
  1.1058 -apply (metis diff_less_0_iff_less linorder_not_le not_leE uminus_add_conv_diff xt1(12) xt1(6))
  1.1059 -apply (metis add_minus_cancel diff_le_eq le_diff_eq uminus_add_conv_diff)
  1.1060 +  apply (metis diff_less_0_iff_less linorder_not_le not_leE uminus_add_conv_diff xt1(12) xt1(6))
  1.1061 + apply (metis add_minus_cancel diff_le_eq le_diff_eq uminus_add_conv_diff)
  1.1062  apply (metis abs_ge_zero linorder_linear min_max.sup_absorb1 min_max.sup_commute)
  1.1063  done
  1.1064  
  1.1065 -lemma bigo_lesso4: "f <o g =o O(k::'a=>'b::{linordered_field,number_ring}) ==>
  1.1066 -    g =o h +o O(k) ==> f <o h =o O(k)"
  1.1067 +lemma bigo_lesso4: "f <o g =o O(k\<Colon>'a=>'b\<Colon>{linordered_field,number_ring}) \<Longrightarrow>
  1.1068 +    g =o h +o O(k) \<Longrightarrow> f <o h =o O(k)"
  1.1069    apply (unfold lesso_def)
  1.1070    apply (drule set_plus_imp_minus)
  1.1071    apply (drule bigo_abs5) back
  1.1072 @@ -946,9 +819,7 @@
  1.1073      split: split_max abs_split)
  1.1074  done
  1.1075  
  1.1076 -declare [[ sledgehammer_problem_prefix = "BigO__bigo_lesso5" ]]
  1.1077 -lemma bigo_lesso5: "f <o g =o O(h) ==>
  1.1078 -    EX C. ALL x. f x <= g x + C * abs(h x)"
  1.1079 +lemma bigo_lesso5: "f <o g =o O(h) \<Longrightarrow> \<exists>C. \<forall>x. f x <= g x + C * abs(h x)"
  1.1080    apply (simp only: lesso_def bigo_alt_def)
  1.1081    apply clarsimp
  1.1082    apply (metis abs_if abs_mult add_commute diff_le_eq less_not_permute)