Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions FormalConjectures/ForMathlib/Analysis/Asymptotics/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,46 @@ limitations under the License.

import Mathlib.Analysis.Asymptotics.Defs
import Mathlib.Order.Filter.AtTopBot.Defs
import Mathlib.Analysis.SpecialFunctions.Log.Basic

open Filter

notation f " ≫ " g => Asymptotics.IsBigO Filter.atTop g f
notation g " ≪ " f => Asymptotics.IsBigO Filter.atTop g f

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be better to include this code in a file ../Asymptotics/ElementaryGrowth.lean since I suspect more content will be added to it after! It would also be useful to add a module docstring to the file documenting what you've added, and the intended use (perhaps with some examples!).

/-- The type of common functions used to estimate growth rate. -/
inductive ElementaryGrowth : Type
| const : ℝ → ElementaryGrowth
| id : ElementaryGrowth
| log : ElementaryGrowth
| exp : ElementaryGrowth
| atTop : (f : ℝ → ℝ) → (Tendsto f atTop atTop) → ElementaryGrowth
| add : ElementaryGrowth → ElementaryGrowth → ElementaryGrowth
| mul : ElementaryGrowth → ElementaryGrowth → ElementaryGrowth
| comp : ElementaryGrowth → ElementaryGrowth → ElementaryGrowth

namespace ElementaryGrowth

def neg : ElementaryGrowth → ElementaryGrowth := fun f => mul (const (-1)) f

def sub : ElementaryGrowth → ElementaryGrowth → ElementaryGrowth := fun f g => add f (neg g)

def pow : ElementaryGrowth → ElementaryGrowth → ElementaryGrowth :=
fun f g => comp exp (mul g (comp log f))

def inv : ElementaryGrowth → ElementaryGrowth := fun f => pow f (const (-1))

def div : ElementaryGrowth → ElementaryGrowth → ElementaryGrowth := fun f g => mul f (inv g)

/-- The evaluation map of the type of common growth functions. -/
noncomputable def Real.eval : ElementaryGrowth → ℝ → ℝ
| const c => fun _ => c
| id => fun x => x
| log => fun x => x.log
| exp => fun x => x.exp
| atTop f _ => f
| add f g => fun x => eval f x + eval g x
| mul f g => fun x => eval f x * eval g x
| comp f g => eval f ∘ eval g

end ElementaryGrowth
Loading