CLRS-compatible wrappers for mathlib's filter-based asymptotics on ℕ → ℝ.
Proves equivalence between the CLRS discrete definition and the filter
definition, plus standard algebraic properties.
havehOwith:IsBigOWithcatTopfg:=isBigOWith_iff.mprhevent'exact⟨c,hOwith⟩theoremisLittleO_iff(fg:ℕ→ℝ):isLittleOfg↔∀(c:ℝ),c>0→∃(n₀:ℕ),∀n,n≥n₀→|fn|≤c*|gn|:=byunfoldisLittleOrw[isLittleO_iff_forall_isBigOWith]constructor·introhchc_poshavehOwith:IsBigOWithcatTopfg:=hhc_poshavehevent:=(isBigOWith_iff.mphOwith)havehevent':∀ᶠninatTop,|fn|≤c*|gn|:=bysimpa[Real.norm_eq_abs]usingheventrw[Filter.eventually_atTop]athevent'rcaseshevent'with⟨n₀,hn₀⟩exact⟨n₀,hn₀⟩·introhchc_posrcaseshchc_poswith⟨n₀,hn₀⟩havehevent:∀ᶠninatTop,|fn|≤c*|gn|:=byrw[Filter.eventually_atTop]exact⟨n₀,hn₀⟩havehevent':∀ᶠninatTop,‖fn‖≤c*‖gn‖:=bysimpa[Real.norm_eq_abs]usingheventexactisBigOWith_iff.mprhevent'theoremisBigOmega_iff(fg:ℕ→ℝ):isBigOmegafg↔∃(c:ℝ),c>0∧∃(n₀:ℕ),∀n,n≥n₀→c*|gn|≤|fn|:=by-- isBigOmega f g = isBigO g f, and isBigO_iff g f gives-- isBigO g f ↔ ∃ c>0, n₀, ∀ n≥n₀, |g n| ≤ c * |f n|-- We prove this RHS is equivalent to-- ∃ c>0, n₀, ∀ n≥n₀, c * |g n| ≤ |f n|-- by exchanging c ↔ c⁻¹.haveh_base:=isBigO_iffgf-- isBigOmega f g = isBigO g f definitionally-- Now the goal is: isBigO g f ↔ ∃ c>0, n₀, ∀ n≥n₀, c * |g n| ≤ |f n|-- But h_base says: isBigO g f ↔ ∃ c>0, n₀, ∀ n≥n₀, |g n| ≤ c * |f n|-- So it suffices to show the two RHSs are equivalent.constructor·-- From isBigO g f, get ∃ c>0, n₀, ∀ n≥n₀, |g n| ≤ c * |f n|-- Transform to ∃ c'>0, n₀, ∀ n≥n₀, c' * |g n| ≤ |f n| via c' = c⁻¹introh_isOrcasesh_base.mph_isOwith⟨c,hc_pos,n₀,hn₀⟩havehc_ne_zero:c≠0:=bylinarithrefine⟨c⁻¹,inv_pos.mprhc_pos,n₀,λnhn=>?_⟩havehineq:=hn₀nhncalcc⁻¹*|gn|≤c⁻¹*(c*|fn|):=bygcongr_=(c⁻¹*c)*|fn|:=byring_=1*|fn|:=byfield_simp[hc_ne_zero]_=|fn|:=bysimp·introh_omegarcasesh_omegawith⟨c,hc_pos,n₀,hn₀⟩havehc_ne_zero:c≠0:=bylinarith-- Need to show isBigO g f, i.e. ∃ c'>0, n₀, ∀ n≥n₀, |g n| ≤ c' * |f n|-- Using c' = c⁻¹applyh_base.mprrefine⟨c⁻¹,inv_pos.mprhc_pos,n₀,λnhn=>?_⟩havehineq:=hn₀nhncalc|gn|=(c⁻¹*c)*|gn|:=byfield_simp[hc_ne_zero]_=c⁻¹*(c*|gn|):=byring_≤c⁻¹*|fn|:=bygcongrtheoremisLittleOmega_iff(fg:ℕ→ℝ):isLittleOmegafg↔∀(c:ℝ),c>0→∃(n₀:ℕ),∀n,n≥n₀→c*|gn|≤|fn|:=by-- isLittleOmega f g = isLittleO g f-- isLittleO_iff g f says: isLittleO g f ↔ ∀ c>0, ∃ n₀, |g n| ≤ c * |f n|-- We need to show the RHS is equivalent to ∀ c>0, c * |g n| ≤ |f n|-- via exchanging c ↔ c⁻¹.haveh_base:=isLittleO_iffgf-- isLittleOmega f g = isLittleO g f definitionallyconstructor·introh_ochchavehc_inv_pos:c⁻¹>0:=inv_pos.mprhcrcases(h_base.mph_o)c⁻¹hc_inv_poswith⟨n₀,hn₀⟩havehc_ne_zero:c≠0:=bylinarithrefine⟨n₀,λnhn=>?_⟩havehineq:=hn₀nhncalcc*|gn|≤c*(c⁻¹*|fn|):=bygcongr_=(c*c⁻¹)*|fn|:=byring_=1*|fn|:=byfield_simp[hc_ne_zero]_=|fn|:=bysimp·introh_forallapplyh_base.mprintroc'hc'_poshavehc_inv_pos:c'⁻¹>0:=inv_pos.mprhc'_posrcasesh_forallc'⁻¹hc_inv_poswith⟨n₀,hn₀⟩havehc_ne_zero:c'≠0:=bylinarithrefine⟨n₀,λnhn=>?_⟩havehineq:=hn₀nhncalc|gn|=c'*(c'⁻¹*|gn|):=byfield_simp[hc_ne_zero]_≤c'*|fn|:=bygcongr