Mode of #cas
limit
A limit at a rational point, from one side, or at ±∞, with a theorem about Mathlib’s Filter.Tendsto.
#cas [limit x → a] e𝓝 a, or 𝓝[≠] a when e is a quotient whose denominator vanishes at a.#cas [limit x → a from above] e𝓝[>] a. With from below it gives the limit from the left, with 𝓝[<] a.#cas [limit x → ∞] eatTop.#cas [limit x → -∞] eatBot.limit computes a limit and proves it as a Filter.Tendsto statement, which is how Mathlib states limits. A statement Tendsto f l (𝓝 L) says that tends to along the filter l, which is 𝓝 a for , 𝓝[≠] a for with , 𝓝[>] a and 𝓝[<] a from the right and from the left, and atTop and atBot for and . Where the expression is defined, the answer is simple: the limit is its value. The interesting case is a quotient whose denominator vanishes. There SymLean does what you would do by hand with l’Hôpital’s rule. It takes the first derivatives of the numerator and the denominator that don’t vanish, and their values have to be exact rational numbers.
At the expression is rewritten in and expanded at . Expressions with exp, log, sqrt, atan, π or e first go through a comparison of growth rates, and when that comparison proves the limit, the label of the answer says “limit from the dominant term”.
Examples (20)#
Basic Examples (3)
The classical one, with the theorem on the punctured neighborhood of 0:
#cas [limit x → 0] (sin x / x)
exact limit
1- Domain
x → 0, x ≠ 0
Checked by Lean’s kernel: Limit from the leading terms of order 1
Filter.Tendsto (fun x ↦ Real.sin x / x) (nhdsWithin 0 {0}ᶜ) (nhds 1)
The certificate: 1 checked step
Limit from the leading terms of order 1
Filter.Tendsto (fun x ↦ Real.sin x / x) (nhdsWithin 0 {0}ᶜ) (nhds 1)
The computation
Leading terms
Numerator 1 (x - a)^1, denominator 1 (x - a)^1 (not proof)
A rational function at . The terms of order 0 in give the limit:
#cas [limit x → ∞] ((x^2 + 1) / (2*x^2 - 3))
exact limit from the terms of order 0
1/2- Domain
x → ∞
Checked by Lean’s kernel: Limit
Filter.Tendsto (fun x ↦ (x ^ 2 + 1) / (2 * x ^ 2 - 3)) Filter.atTop (nhds (1 / 2))
The certificate: 1 checked step
Limit
Filter.Tendsto (fun x ↦ (x ^ 2 + 1) / (2 * x ^ 2 - 3)) Filter.atTop (nhds (1 / 2))
A one-sided infinite limit:
#cas [limit x → 0 from above] (1 / x)
infinite limit at a pole of order 1
∞- Domain
x → 0⁺
Checked by Lean’s kernel: Limit
Filter.Tendsto (fun x ↦ 1 / x) (nhdsWithin 0 (Set.Ioi 0)) Filter.atTop
The certificate: 1 checked step
Limit
Filter.Tendsto (fun x ↦ 1 / x) (nhdsWithin 0 (Set.Ioi 0)) Filter.atTop
Scope (7)
A quotient whose denominator vanishes. The first derivatives that do not vanish give the limit. They have order 1 in the first example and order 2 in the second:
#cas [limit x → 1] ((x^2 - 1) / (x - 1))
exact limit
2- Domain
x → 1, x ≠ 1
Checked by Lean’s kernel: Limit from the leading terms of order 1
Filter.Tendsto (fun x ↦ (x ^ 2 - 1) / (x - 1)) (nhdsWithin 1 {1}ᶜ) (nhds 2)
The certificate: 1 checked step
Limit from the leading terms of order 1
Filter.Tendsto (fun x ↦ (x ^ 2 - 1) / (x - 1)) (nhdsWithin 1 {1}ᶜ) (nhds 2)
The computation
Leading terms
Numerator 2 (x - a)^1, denominator 1 (x - a)^1 (not proof)
#cas [limit x → 0] ((1 - cos x) / x^2)
exact limit
1/2- Domain
x → 0, x ≠ 0
Checked by Lean’s kernel: Limit from the leading terms of order 2
Filter.Tendsto (fun x ↦ (1 - Real.cos x) / x ^ 2) (nhdsWithin 0 {0}ᶜ) (nhds (1 / 2))
The certificate: 1 checked step
Limit from the leading terms of order 2
Filter.Tendsto (fun x ↦ (1 - Real.cos x) / x ^ 2) (nhdsWithin 0 {0}ᶜ) (nhds (1 / 2))
The computation
Leading terms
Numerator 1/2 (x - a)^2, denominator 1 (x - a)^2 (not proof)
Where the expression is defined, the limit is its value. Here the point is close to the edge of the domain of the square root:
#cas [limit x → 1/10000] (sqrt x)
limit, the value at the point
1/100- Domain
x → 1/10000
Checked by Lean’s kernel: Continuity at a point of validity
Filter.Tendsto (fun x ↦ √x) (nhds (1 / 10000)) (nhds √(1 / 10000))
The certificate: 1 checked step
Continuity at a point of validity
Filter.Tendsto (fun x ↦ √x) (nhds (1 / 10000)) (nhds √(1 / 10000))
At , is in :
#cas [limit x → ∞] (x * sin (1 / x))
exact limit from the terms of order 1
1- Domain
x → ∞
Checked by Lean’s kernel: Limit
Filter.Tendsto (fun x ↦ x * Real.sin (1 / x)) Filter.atTop (nhds 1)
The certificate: 1 checked step
Limit
Filter.Tendsto (fun x ↦ x * Real.sin (1 / x)) Filter.atTop (nhds 1)
An infinite limit at . In the expression has a pole of order 2:
#cas [limit x → ∞] (x^3 / (x + 1))
infinite limit at a pole of order 2
∞- Domain
x → ∞
Checked by Lean’s kernel: Limit
Filter.Tendsto (fun x ↦ x ^ 3 / (x + 1)) Filter.atTop Filter.atTop
The certificate: 1 checked step
Limit
Filter.Tendsto (fun x ↦ x ^ 3 / (x + 1)) Filter.atTop Filter.atTop
Exponentials and arctangents at , by the dominant term:
#cas [limit x → ∞] (x^2 * exp (-x))
limit from the dominant term
0- Domain
x → ∞
Checked by Lean’s kernel: Limit by asymptotic comparison
Filter.Tendsto (fun x ↦ x ^ 2 * Real.exp (-x)) Filter.atTop (nhds 0)
The certificate: 1 checked step
Limit by asymptotic comparison
Filter.Tendsto (fun x ↦ x ^ 2 * Real.exp (-x)) Filter.atTop (nhds 0)
The computation
Asymptotic equivalent
f ~ c x^2 e^(-1 x) (log x)^0
#cas [limit x → ∞] (atan x)
limit from the dominant term
pi/2- Domain
x → ∞
Checked by Lean’s kernel: Limit by asymptotic comparison
Filter.Tendsto (fun x ↦ Real.arctan x) Filter.atTop (nhds (Real.pi / 2))
The certificate: 1 checked step
Limit by asymptotic comparison
Filter.Tendsto (fun x ↦ Real.arctan x) Filter.atTop (nhds (Real.pi / 2))
The computation
Asymptotic equivalent
f ~ c x^0 e^(0 x) (log x)^0
#cas [limit x → -∞] (x * exp x)
limit from the dominant term
0- Domain
x → -∞
Checked by Lean’s kernel: Limit by asymptotic comparison
Filter.Tendsto (fun x ↦ x * Real.exp x) Filter.atBot (nhds 0)
The certificate: 1 checked step
Limit by asymptotic comparison
Filter.Tendsto (fun x ↦ x * Real.exp x) Filter.atBot (nhds 0)
The computation
Asymptotic equivalent
f ~ c x^1 e^(-1 x) (log x)^0 in t = -x
A difference of two terms that both grow:
#cas [limit x → ∞] (sqrt (x^2 + 1) - x)
limit from the dominant term
0- Domain
x → ∞
Checked by Lean’s kernel: Limit by asymptotic comparison
Filter.Tendsto (fun x ↦ √(x ^ 2 + 1) - x) Filter.atTop (nhds 0)
The certificate: 1 checked step
Limit by asymptotic comparison
Filter.Tendsto (fun x ↦ √(x ^ 2 + 1) - x) Filter.atTop (nhds 0)
The computation
Asymptotic equivalent
f ~ c x^-1 e^(0 x) (log x)^0
At a pole of even order both sides agree. At a pole of odd order they differ, and the answer gives both:
#cas [limit x → 0] (1 / x^2)
infinite limit at a pole of order 2
∞- Domain
x → 0, x ≠ 0
Checked by Lean’s kernel: Limit
Filter.Tendsto (fun x ↦ 1 / x ^ 2) (nhdsWithin 0 {0}ᶜ) Filter.atTop
The certificate: 1 checked step
Limit
Filter.Tendsto (fun x ↦ 1 / x ^ 2) (nhdsWithin 0 {0}ᶜ) Filter.atTop
#cas [limit x → 0] (1 / x)
no two-sided limit: a pole of order 1
Indeterminate (∞ from above, -∞ from below)- Domain
x → 0, x ≠ 0
Checked by Lean’s kernel: Limit
Filter.Tendsto (fun x ↦ 1 / x) (nhdsWithin 0 (Set.Ioi 0)) Filter.atTop ∧ Filter.Tendsto (fun x ↦ 1 / x) (nhdsWithin 0 (Set.Iio 0)) Filter.atBot
The certificate: 1 checked step
Limit
Filter.Tendsto (fun x ↦ 1 / x) (nhdsWithin 0 (Set.Ioi 0)) Filter.atTop ∧ Filter.Tendsto (fun x ↦ 1 / x) (nhdsWithin 0 (Set.Iio 0)) Filter.atBot
Applications (2)
A limit in a proof. cas proves it, and only the three standard axioms are used:
open Filter Topology in theorem limit_sinc : Tendsto (fun x : ℝ ↦ Real.sin x / x) (𝓝[≠] 0) (𝓝 1) := by cas #print axioms limit_sinc
limit_sinc depends on the axioms propext, Classical.choice, Quot.sound.
A one-sided infinite limit as a goal:
open Filter Topology in example : Tendsto (fun x : ℝ ↦ 1 / x) (𝓝[>] 0) atTop := by cas
Lean accepts the proof.
Properties and Relations (1)
The limit of at 0 is the coefficient of in the series of :
#cas [series x 0 6] (exp x)
Taylor polynomial with exact coefficients
1 + x + 1/2*x^2 + 1/6*x^3 + 1/24*x^4 + 1/120*x^5 + 1/720*x^6 + o(x^6)- Domain
x → 0
Checked by Lean’s kernel: Taylor expansion with a little-o remainder
(fun x ↦ Real.exp x - (1 + x + 1 / 2 * x ^ 2 + 1 / 6 * x ^ 3 + 1 / 24 * x ^ 4 + 1 / 120 * x ^ 5 + 1 / 720 * x ^ 6)) =o[nhds 0] fun x ↦ x ^ 6
The certificate: 1 checked step
Taylor expansion with a little-o remainder
(fun x ↦ Real.exp x - (1 + x + 1 / 2 * x ^ 2 + 1 / 6 * x ^ 3 + 1 / 24 * x ^ 4 + 1 / 120 * x ^ 5 + 1 / 720 * x ^ 6)) =o[nhds 0] fun x ↦ x ^ 6
The computation
Checked coefficients
Coefficients of (x - 0)^0, …, ^6: [1, 1, 1/2, 1/6, 1/24, 1/120, 1/720]
#cas [limit x → 0] ((exp x - 1 - x) / x^2)
exact limit
1/2- Domain
x → 0, x ≠ 0
Checked by Lean’s kernel: Limit from the leading terms of order 2
Filter.Tendsto (fun x ↦ (Real.exp x - 1 - x) / x ^ 2) (nhdsWithin 0 {0}ᶜ) (nhds (1 / 2))
The certificate: 1 checked step
Limit from the leading terms of order 2
Filter.Tendsto (fun x ↦ (Real.exp x - 1 - x) / x ^ 2) (nhdsWithin 0 {0}ᶜ) (nhds (1 / 2))
The computation
Leading terms
Numerator 1/2 (x - a)^2, denominator 1 (x - a)^2 (not proof)
Possible Issues (4)
The point must be a rational number, or :
#cas [limit x → π] (sin x)
Error
limit: expected a rational number
is not defined at 0, and it has no limit there. For a quotient whose denominator vanishes, the message asks for a single quotient g / h:
#cas [limit x → 0] (sin (1 / x))
Error
limit: the domain checker did not certify that the expression is defined at 0; for a quotient whose denominator vanishes at 0, write it as a single quotient
Away from 0, is , but x / x is not valid at 0, so the domain checker refuses the denominator:
#cas [limit x → 0] (1 / (x + x / x))
Error
limit: the domain checker did not certify that the denominator and its derivatives through order 1 are defined at 0
Some limits at are out of reach of both routes, and the message lists why each one stopped:
#cas [limit x → ∞] (log (exp x + 1) - x)
Error
limit: no route proved the limit at ∞. Asymptotic comparison: limit: log of an argument that is not equivalent to a positive power Substitution x = 1 / t: limit: the expression is not built from x by field operations and functions of arguments with a finite limit
Neat Examples (3)
Two terms that grow like , and a difference of :
#cas [limit x → ∞] (sqrt (x^2 + 3 * x) - x)
limit from the dominant term
3/2- Domain
x → ∞
Checked by Lean’s kernel: Limit by asymptotic comparison
Filter.Tendsto (fun x ↦ √(x ^ 2 + 3 * x) - x) Filter.atTop (nhds (3 / 2))
The certificate: 1 checked step
Limit by asymptotic comparison
Filter.Tendsto (fun x ↦ √(x ^ 2 + 3 * x) - x) Filter.atTop (nhds (3 / 2))
The computation
Asymptotic equivalent
f ~ c x^0 e^(0 x) (log x)^0
The exponential dominates both the numerator and the denominator:
#cas [limit x → ∞] ((x^2 + exp x) / (exp x + 1))
limit from the dominant term
1- Domain
x → ∞
Checked by Lean’s kernel: Limit by asymptotic comparison
Filter.Tendsto (fun x ↦ (x ^ 2 + Real.exp x) / (Real.exp x + 1)) Filter.atTop (nhds 1)
The certificate: 1 checked step
Limit by asymptotic comparison
Filter.Tendsto (fun x ↦ (x ^ 2 + Real.exp x) / (Real.exp x + 1)) Filter.atTop (nhds 1)
The computation
Asymptotic equivalent
f ~ c x^0 e^(0 x) (log x)^0
A quotient of logarithms:
#cas [limit x → ∞] (log (x^2 + 1) / log x)
limit from the dominant term
2- Domain
x → ∞
Checked by Lean’s kernel: Limit by asymptotic comparison
Filter.Tendsto (fun x ↦ Real.log (x ^ 2 + 1) / Real.log x) Filter.atTop (nhds 2)
The certificate: 1 checked step
Limit by asymptotic comparison
Filter.Tendsto (fun x ↦ Real.log (x ^ 2 + 1) / Real.log x) Filter.atTop (nhds 2)
The computation
Asymptotic equivalent
f ~ c x^0 e^(0 x) (log x)^0
