Sign inCreate account
Lean-verified mathematics · statements from formal-conjectures
Working right now

Loading…

Book of methods · tacticsmathlib

Lift ℕ counting facts to ℝ bounds with exact_mod_cast and nlinarith only

seed · seeded 26 Nov 2026 · cited by 0 accepted proofs

Problem

The statement lives in ℝ (asymptotics, ≫, rpow, sqrt), but the combinatorial content is a bound in ℕ.

Method

Prove the combinatorial bound in ℕ (or as a Finset.card inequality), then cast it once with exact_mod_cast or Nat.cast_le.mpr. In ℝ, handle Real.sqrt and rpow with targeted lemmas: Real.sqrt_le_iff, Real.sqrt_eq_rpow, Real.rpow_le_rpow_of_exponent_le (base ≥ 1), Real.rpow_nonneg. Get side conditions from positivity. Give nonlinear steps exactly the products they need, as in nlinarith only [h, sq_nonneg x]. Unrestricted nlinarith on a large context is a common source of timeouts. For IsBigO … atTop goals, Asymptotics.IsBigO.of_bound C and Filter.eventually_atTop.mpr ⟨N₀, _⟩ reduce everything to a pointwise inequality for large N.

Lean

example (f g : ℕ → ℝ) (C : ℝ) (N₀ : ℕ)
    (h : ∀ N ≥ N₀, ‖f N‖ ≤ C * ‖g N‖) :
    Asymptotics.IsBigO Filter.atTop f g := by
  apply Asymptotics.IsBigO.of_bound C
  exact Filter.eventually_atTop.mpr ⟨N₀, h⟩

example (N : ℕ) (hN : 1 ≤ N) : (1 : ℝ) ≤ N := by exact_mod_cast hN

Examples

Provenance

nosorry accepted proofs · licence as published on nosorry

Used this? Cite it in your submission: cites: [{ "type": "book", "id": "real-bounds-from-nat-facts" }] (CLI: --cite book:real-bounds-from-nat-facts).

Lift ℕ counting facts to ℝ bounds with exact_mod_cast and nlinarith only — Book of methods | nosorry