src/HOL/ex/Function_Growth.thy
changeset 69597 ff784d5a5bfb
parent 66936 cf8d8fc23891
child 69815 56d5bb8c102e
equal deleted inserted replaced
69596:c8a2755bf220 69597:ff784d5a5bfb
    78   "f \<cong> g \<longleftrightarrow>
    78   "f \<cong> g \<longleftrightarrow>
    79     (\<exists>c\<^sub>1>0. \<exists>c\<^sub>2>0. \<exists>n. \<forall>m>n. f m \<le> c\<^sub>1 * g m \<and> g m \<le> c\<^sub>2 * f m)"
    79     (\<exists>c\<^sub>1>0. \<exists>c\<^sub>2>0. \<exists>n. \<forall>m>n. f m \<le> c\<^sub>1 * g m \<and> g m \<le> c\<^sub>2 * f m)"
    80 
    80 
    81 text \<open>
    81 text \<open>
    82   This yields \<open>f \<cong> g \<longleftrightarrow> f \<in> \<Theta>(g)\<close>.  Concerning \<open>c\<^sub>1\<close> and \<open>c\<^sub>2\<close>
    82   This yields \<open>f \<cong> g \<longleftrightarrow> f \<in> \<Theta>(g)\<close>.  Concerning \<open>c\<^sub>1\<close> and \<open>c\<^sub>2\<close>
    83   restricted to @{typ nat}, see note above on \<open>(\<lesssim>)\<close>.
    83   restricted to \<^typ>\<open>nat\<close>, see note above on \<open>(\<lesssim>)\<close>.
    84 \<close>
    84 \<close>
    85 
    85 
    86 lemma equiv_funI:
    86 lemma equiv_funI:
    87   assumes "\<exists>c\<^sub>1>0. \<exists>c\<^sub>2>0. \<exists>n. \<forall>m>n. f m \<le> c\<^sub>1 * g m \<and> g m \<le> c\<^sub>2 * f m"
    87   assumes "\<exists>c\<^sub>1>0. \<exists>c\<^sub>2>0. \<exists>n. \<forall>m>n. f m \<le> c\<^sub>1 * g m \<and> g m \<le> c\<^sub>2 * f m"
    88   shows "f \<cong> g"
    88   shows "f \<cong> g"
   160   Something still has to be said about the coefficient \<open>c\<close> in
   160   Something still has to be said about the coefficient \<open>c\<close> in
   161   the definition of \<open>(\<prec>)\<close>.  In the typical definition of \<open>o\<close>,
   161   the definition of \<open>(\<prec>)\<close>.  In the typical definition of \<open>o\<close>,
   162   it occurs on the \emph{right} hand side of the \<open>(>)\<close>.  The reason
   162   it occurs on the \emph{right} hand side of the \<open>(>)\<close>.  The reason
   163   is that the situation is dual to the definition of \<open>O\<close>: the definition
   163   is that the situation is dual to the definition of \<open>O\<close>: the definition
   164   works since \<open>c\<close> may become arbitrary small.  Since this is not possible
   164   works since \<open>c\<close> may become arbitrary small.  Since this is not possible
   165   within @{term \<nat>}, we push the coefficient to the left hand side instead such
   165   within \<^term>\<open>\<nat>\<close>, we push the coefficient to the left hand side instead such
   166   that it may become arbitrary big instead.
   166   that it may become arbitrary big instead.
   167 \<close>
   167 \<close>
   168 
   168 
   169 lemma less_fun_strongI:
   169 lemma less_fun_strongI:
   170   assumes "\<And>c. c > 0 \<Longrightarrow> \<exists>n. \<forall>m>n. c * f m < g m"
   170   assumes "\<And>c. c > 0 \<Longrightarrow> \<exists>n. \<forall>m>n. c * f m < g m"
   289   preconditions to the functions may be necessary.  The list here is by no means to be
   289   preconditions to the functions may be necessary.  The list here is by no means to be
   290   intended as complete construction set for typical functions, here surely something
   290   intended as complete construction set for typical functions, here surely something
   291   has to be added yet.
   291   has to be added yet.
   292 \<close>
   292 \<close>
   293 
   293 
   294 text \<open>@{prop "(\<lambda>n. f n + k) \<cong> f"}\<close>
   294 text \<open>\<^prop>\<open>(\<lambda>n. f n + k) \<cong> f\<close>\<close>
   295 
   295 
   296 lemma equiv_fun_mono_const:
   296 lemma equiv_fun_mono_const:
   297   assumes "mono f" and "\<exists>n. f n > 0"
   297   assumes "mono f" and "\<exists>n. f n > 0"
   298   shows "(\<lambda>n. f n + k) \<cong> f"
   298   shows "(\<lambda>n. f n + k) \<cong> f"
   299 proof (cases "k = 0")
   299 proof (cases "k = 0")
   382 qed
   382 qed
   383 
   383 
   384 (*lemma
   384 (*lemma
   385   "Discrete.log \<prec> Discrete.sqrt"
   385   "Discrete.log \<prec> Discrete.sqrt"
   386 proof (rule less_fun_strongI)*)
   386 proof (rule less_fun_strongI)*)
   387 text \<open>@{prop "Discrete.log \<prec> Discrete.sqrt"}\<close>
   387 text \<open>\<^prop>\<open>Discrete.log \<prec> Discrete.sqrt\<close>\<close>
   388 
   388 
   389 lemma
   389 lemma
   390   "Discrete.sqrt \<prec> id"
   390   "Discrete.sqrt \<prec> id"
   391 proof (rule less_fun_strongI)
   391 proof (rule less_fun_strongI)
   392   fix c :: nat
   392   fix c :: nat
   416   by (rule less_fun_strongI) auto
   416   by (rule less_fun_strongI) auto
   417 
   417 
   418 (*lemma 
   418 (*lemma 
   419   "(\<lambda>n. n ^ k) \<prec> (\<lambda>n. 2 ^ n)"
   419   "(\<lambda>n. n ^ k) \<prec> (\<lambda>n. 2 ^ n)"
   420 proof (rule less_fun_strongI)*)
   420 proof (rule less_fun_strongI)*)
   421 text \<open>@{prop "(\<lambda>n. n ^ k) \<prec> (\<lambda>n. 2 ^ n)"}\<close>
   421 text \<open>\<^prop>\<open>(\<lambda>n. n ^ k) \<prec> (\<lambda>n. 2 ^ n)\<close>\<close>
   422 
   422 
   423 end
   423 end