Mode of #cas
minimize
The minimum of a polynomial on the real line or on an interval, exact or enclosed, with a theorem.
#cas [minimize x] p#cas [minimize x in [a, b]] p#cas (digits := d) [minimize x] pminimize looks for the smallest value of a polynomial and proves that nothing goes below it. When a rational point attains the minimum, the answer is exact, and the theorem says for every real , and .
Often the minimizer is irrational, as for , whose minimizer is . Then the answer is an enclosure of the minimum, and the theorem says for every , and at a rational point near the minimizer. What it bounds is the value of the minimum, not the position of the minimizer.
Examples (18)#
Basic Examples (3)
A quadratic, with an exact minimum at a rational point:
#cas [minimize x] (x^2 - 2*x + 4)
exact global minimum
min = 3 at x = 1- Input (polynomial)
(x^2 - 2*x + 4)
Checked by Lean’s kernel: Global bound attained at the point
(∀ (x : ℝ), 3 ≤ x ^ 2 - 2 * x + 4) ∧ (fun x ↦ x ^ 2 - 2 * x + 4) 1 = 3
The certificate: 1 checked step
Global bound attained at the point
(∀ (x : ℝ), 3 ≤ x ^ 2 - 2 * x + 4) ∧ (fun x ↦ x ^ 2 - 2 * x + 4) 1 = 3
The computation
Critical points
Real roots of the derivative from the root list (not proof): 1
The minimizer of is , so the minimum is enclosed:
#cas [minimize x] (x^4 - x)
certified enclosure of the global minimum
min ∈ [-0.473, -0.472] near x = 0.62996- Input (polynomial)
(x^4 - x)
Checked by Lean’s kernel: Global bound and a nearby value
(∀ (x : ℝ), -473 / 10 ^ 3 ≤ x ^ 4 - x) ∧ (fun x ↦ x ^ 4 - x) (62996 / 10 ^ 5) ≤ -472 / 10 ^ 3
The certificate: 1 checked step
Global bound and a nearby value
(∀ (x : ℝ), -473 / 10 ^ 3 ≤ x ^ 4 - x) ∧ (fun x ↦ x ^ 4 - x) (62996 / 10 ^ 5) ≤ -472 / 10 ^ 3
The computation
Critical points
Real roots of the derivative from the root list (not proof): 1
The minimum on an interval:
#cas [minimize x in [0, 2]] (x^2 - 2*x)
exact minimum on the interval
min = -1 at x = 1- Domain
x ∈ [0, 2]- Input (polynomial)
(x^2 - 2*x)
Checked by Lean’s kernel: Bound on the interval attained at the point
(∀ x ∈ Set.Icc 0 2, -1 ≤ x ^ 2 - 2 * x) ∧ 1 ∈ Set.Icc 0 2 ∧ (fun x ↦ x ^ 2 - 2 * x) 1 = -1
The certificate: 1 checked step
Bound on the interval attained at the point
(∀ x ∈ Set.Icc 0 2, -1 ≤ x ^ 2 - 2 * x) ∧ 1 ∈ Set.Icc 0 2 ∧ (fun x ↦ x ^ 2 - 2 * x) 1 = -1
The computation
Candidates
Endpoints and real roots of the derivative in the interval (not proof): 3
Scope (5)
A quartic with a rational minimizer and a rational minimum:
#cas [minimize x] (x^4 - x^3)
exact global minimum
min = -27/256 at x = 3/4- Input (polynomial)
(x^4 - x^3)
Checked by Lean’s kernel: Global bound attained at the point
(∀ (x : ℝ), -(27 / 256) ≤ x ^ 4 - x ^ 3) ∧ (fun x ↦ x ^ 4 - x ^ 3) (3 / 4) = -(27 / 256)
The certificate: 1 checked step
Global bound attained at the point
(∀ (x : ℝ), -(27 / 256) ≤ x ^ 4 - x ^ 3) ∧ (fun x ↦ x ^ 4 - x ^ 3) (3 / 4) = -(27 / 256)
The computation
Critical points
Real roots of the derivative from the root list (not proof): 2
A quartic with two local minima. The global one is at an irrational point:
#cas [minimize x] (x^4 - 3*x^2 + x)
certified enclosure of the global minimum
min ∈ [-3.514, -3.513] near x = -1.30084- Input (polynomial)
(x^4 - 3*x^2 + x)
Checked by Lean’s kernel: Global bound and a nearby value
(∀ (x : ℝ), -3514 / 10 ^ 3 ≤ x ^ 4 - 3 * x ^ 2 + x) ∧ (fun x ↦ x ^ 4 - 3 * x ^ 2 + x) (-130084 / 10 ^ 5) ≤ -3513 / 10 ^ 3
The certificate: 1 checked step
Global bound and a nearby value
(∀ (x : ℝ), -3514 / 10 ^ 3 ≤ x ^ 4 - 3 * x ^ 2 + x) ∧ (fun x ↦ x ^ 4 - 3 * x ^ 2 + x) (-130084 / 10 ^ 5) ≤ -3513 / 10 ^ 3
The computation
Critical points
Real roots of the derivative from the root list (not proof): 3
On an interval, the candidates are the critical points inside and the two endpoints:
#cas [minimize x in [-1, 2]] (x^3 - 3*x)
exact minimum on the interval
min = -2 at x = 1- Domain
x ∈ [-1, 2]- Input (polynomial)
(x^3 - 3*x)
Checked by Lean’s kernel: Bound on the interval attained at the point
(∀ x ∈ Set.Icc (-1) 2, -2 ≤ x ^ 3 - 3 * x) ∧ 1 ∈ Set.Icc (-1) 2 ∧ (fun x ↦ x ^ 3 - 3 * x) 1 = -2
The certificate: 1 checked step
Bound on the interval attained at the point
(∀ x ∈ Set.Icc (-1) 2, -2 ≤ x ^ 3 - 3 * x) ∧ 1 ∈ Set.Icc (-1) 2 ∧ (fun x ↦ x ^ 3 - 3 * x) 1 = -2
The computation
Candidates
Endpoints and real roots of the derivative in the interval (not proof): 4
#cas [minimize x in [1, 2]] (x)
exact minimum on the interval
min = 1 at x = 1- Domain
x ∈ [1, 2]- Input (polynomial)
(x)
Checked by Lean’s kernel: Bound on the interval attained at the point
(∀ x ∈ Set.Icc 1 2, 1 ≤ x) ∧ 1 ∈ Set.Icc 1 2 ∧ (fun x ↦ x) 1 = 1
The certificate: 1 checked step
Bound on the interval attained at the point
(∀ x ∈ Set.Icc 1 2, 1 ≤ x) ∧ 1 ∈ Set.Icc 1 2 ∧ (fun x ↦ x) 1 = 1
The computation
Candidates
Endpoints and real roots of the derivative in the interval (not proof): 2
A polynomial of odd degree has a minimum on a closed interval, here at :
#cas [minimize x in [0, 2]] (x^3 - 2*x)
certified enclosure of the minimum on the interval
min ∈ [-1.089, -1.088], witness x = 0.8165 with value ≤ -1.088- Domain
x ∈ [0, 2]- Input (polynomial)
(x^3 - 2*x)
Checked by Lean’s kernel: Bound on the interval and a witness value
(∀ x ∈ Set.Icc 0 2, -1089 / 10 ^ 3 ≤ x ^ 3 - 2 * x) ∧ 8165 / 10 ^ 4 ∈ Set.Icc 0 2 ∧ (fun x ↦ x ^ 3 - 2 * x) (8165 / 10 ^ 4) ≤ -1088 / 10 ^ 3
The certificate: 1 checked step
Bound on the interval and a witness value
(∀ x ∈ Set.Icc 0 2, -1089 / 10 ^ 3 ≤ x ^ 3 - 2 * x) ∧ 8165 / 10 ^ 4 ∈ Set.Icc 0 2 ∧ (fun x ↦ x ^ 3 - 2 * x) (8165 / 10 ^ 4) ≤ -1088 / 10 ^ 3
The computation
Candidates
Endpoints and real roots of the derivative in the interval (not proof): 3
Rational endpoints:
#cas [minimize x in [1/2, 3/2]] (x^5 - 5*x)
exact minimum on the interval
min = -4 at x = 1- Domain
x ∈ [1/2, 3/2]- Input (polynomial)
(x^5 - 5*x)
Checked by Lean’s kernel: Bound on the interval attained at the point
(∀ x ∈ Set.Icc (1 / 2) (3 / 2), -4 ≤ x ^ 5 - 5 * x) ∧ 1 ∈ Set.Icc (1 / 2) (3 / 2) ∧ (fun x ↦ x ^ 5 - 5 * x) 1 = -4
The certificate: 1 checked step
Bound on the interval attained at the point
(∀ x ∈ Set.Icc (1 / 2) (3 / 2), -4 ≤ x ^ 5 - 5 * x) ∧ 1 ∈ Set.Icc (1 / 2) (3 / 2) ∧ (fun x ↦ x ^ 5 - 5 * x) 1 = -4
The computation
Candidates
Endpoints and real roots of the derivative in the interval (not proof): 3
Options (1)
(digits := 4) makes the enclosure at most wide:
#cas (digits := 4) [minimize x] (x^4 - x)
certified enclosure of the global minimum
min ∈ [-0.4725, -0.4724] near x = 0.629961- Input (polynomial)
(x^4 - x)
Checked by Lean’s kernel: Global bound and a nearby value
(∀ (x : ℝ), -4725 / 10 ^ 4 ≤ x ^ 4 - x) ∧ (fun x ↦ x ^ 4 - x) (629961 / 10 ^ 6) ≤ -4724 / 10 ^ 4
The certificate: 1 checked step
Global bound and a nearby value
(∀ (x : ℝ), -4725 / 10 ^ 4 ≤ x ^ 4 - x) ∧ (fun x ↦ x ^ 4 - x) (629961 / 10 ^ 6) ≤ -4724 / 10 ^ 4
The computation
Critical points
Real roots of the derivative from the root list (not proof): 1
Applications (2)
The bound in a proof. cas proves it, and only the three standard axioms are used:
theorem minimize_quadratic : ∀ x : ℝ, 3 ≤ x ^ 2 - 2 * x + 4 := by cas #print axioms minimize_quadratic
minimize_quadratic depends on the axioms propext, Classical.choice, Quot.sound.
The exact minimum of is a sharp bound:
example : ∀ x : ℝ, (-27 : ℝ) / 256 ≤ x ^ 4 - x ^ 3 := by cas
Lean accepts the proof.
Properties and Relations (2)
The minimizer is a root of the derivative:
#cas [derive x] (x^4 - x^3)
4*x^3 - 3*x^2Checked by Lean’s kernel: Derivative of the input
∀ (x : ℝ), HasDerivAt (fun x ↦ x ^ 4 - x ^ 3) (4 * x ^ 3 - 3 * x ^ 2) x
from CAS.Command.hasDerivAt_of_displayRoute
The certificate: 5 checked steps
Derivative of the input
∀ (x : ℝ), HasDerivAt (fun x ↦ x ^ 4 - x ^ 3) (4 * x ^ 3 - 3 * x ^ 2) x
Partial derivative in x: indexed rules compute Expr.diff
(CAS.Verified.Expr.DiffDerivation.build 0 ((𝕏[0].pow 4).sub (𝕏[0].pow 3))).rawDerivative = CAS.Verified.Expr.diff 0 ((𝕏[0].pow 4).sub (𝕏[0].pow 3))
Partial derivative in x: normalization preserves evaluation
∀ (ρ : Fin 1 → ℝ), CAS.Verified.Expr.eval ρ (CAS.Verified.Expr.DiffDerivation.build 0 ((𝕏[0].pow 4).sub (𝕏[0].pow 3))).simplifiedDerivative = CAS.Verified.Expr.eval ρ (CAS.Verified.Expr.DiffDerivation.build 0 ((𝕏[0].pow 4).sub (𝕏[0].pow 3))).rawDerivative
Partial derivative in x: side-conditioned display normalization
∀ (ρ : Fin 1 → ℝ), CAS.Verified.Expr.Alg.SideHolds ρ (CAS.Command.displayDerivativeRoute (CAS.Verified.Expr.DiffDerivation.build 0 ((𝕏[0].pow 4).sub (𝕏[0].pow 3)))).nonzero → CAS.Verified.Expr.eval ρ (CAS.Command.displayDerivativeRoute (CAS.Verified.Expr.DiffDerivation.build 0 ((𝕏[0].pow 4).sub (𝕏[0].pow 3)))).rhs = CAS.Verified.Expr.eval ρ (CAS.Verified.Expr.DiffDerivation.build 0 ((𝕏[0].pow 4).sub (𝕏[0].pow 3))).simplifiedDerivative
Partial derivative in x: analytic semantics of the displayed result
∀ (x : ℝ^1), CAS.Verified.Expr.ValidAt x.ofLp ((𝕏[0].pow 4).sub (𝕏[0].pow 3)) → CAS.Verified.Expr.Alg.SideHolds x.ofLp (CAS.Command.displayDerivativeRoute (CAS.Verified.Expr.DiffDerivation.build 0 ((𝕏[0].pow 4).sub (𝕏[0].pow 3)))).nonzero → (fderiv ℝ (fun y ↦ CAS.Verified.Expr.eval y.ofLp ((𝕏[0].pow 4).sub (𝕏[0].pow 3))) x) (EuclideanSpace.single 0 1) = CAS.Verified.Expr.eval x.ofLp (CAS.Command.displayDerivativeRoute (CAS.Verified.Expr.DiffDerivation.build 0 ((𝕏[0].pow 4).sub (𝕏[0].pow 3)))).rhs
The computation
Variables: x
Analytic domain conditions
Raw checked nonzero requirements: (none) Raw checked positivity requirements: (none)
Partial derivative in x
1. Apply symbolic differentiation rules
raw result: 4*x^3*1 - 3*x^2*1
2. Normalize the symbolic derivative unconditionally
normalized result: 4*x^3 - 3*x^2
3. Apply checked side-conditioned cleanup
displayed result: 4*x^3 - 3*x^2 additional nonzero requirements: (none)
maximize of gives the same point:
#cas [maximize x] (x^3 - x^4)
exact global maximum
max = 27/256 at x = 3/4- Input (polynomial)
(x^3 - x^4)
Checked by Lean’s kernel: Global bound attained at the point
(∀ (x : ℝ), x ^ 3 - x ^ 4 ≤ 27 / 256) ∧ (fun x ↦ x ^ 3 - x ^ 4) (3 / 4) = 27 / 256
The certificate: 1 checked step
Global bound attained at the point
(∀ (x : ℝ), x ^ 3 - x ^ 4 ≤ 27 / 256) ∧ (fun x ↦ x ^ 3 - x ^ 4) (3 / 4) = 27 / 256
The computation
Critical points
Real roots of the derivative from the root list (not proof): 2
Possible Issues (4)
A polynomial of odd degree has no global minimum:
#cas [minimize x] (x^3 - x)
Error
minimize: the polynomial is unbounded below (degree 3, leading coefficient 1), so it has no minimum
On a closed interval it has one:
#cas [minimize x in [-1, 1]] (x^3 - x)
certified enclosure of the minimum on the interval
min ∈ [-0.385, -0.384], witness x = 0.57735 with value ≤ -0.384- Domain
x ∈ [-1, 1]- Input (polynomial)
(x^3 - x)
Checked by Lean’s kernel: Bound on the interval and a witness value
(∀ x ∈ Set.Icc (-1) 1, -385 / 10 ^ 3 ≤ x ^ 3 - x) ∧ 57735 / 10 ^ 5 ∈ Set.Icc (-1) 1 ∧ (fun x ↦ x ^ 3 - x) (57735 / 10 ^ 5) ≤ -384 / 10 ^ 3
The certificate: 1 checked step
Bound on the interval and a witness value
(∀ x ∈ Set.Icc (-1) 1, -385 / 10 ^ 3 ≤ x ^ 3 - x) ∧ 57735 / 10 ^ 5 ∈ Set.Icc (-1) 1 ∧ (fun x ↦ x ^ 3 - x) (57735 / 10 ^ 5) ≤ -384 / 10 ^ 3
The computation
Candidates
Endpoints and real roots of the derivative in the interval (not proof): 4
Only polynomials. For other functions on an interval, cega proves bounds:
#cas [minimize x] (sin x)
Error
minimize needs a polynomial in x with rational coefficients
The smaller endpoint comes first:
#cas [minimize x in [1, 0]] (x)
Error
minimize needs rational endpoints a < b
At most 6 digits:
#cas (digits := 7) [minimize x] (x^4 - x)
Error
minimize accepts between 1 and 6 digits
Neat Examples (1)
On the minimum of is the global one, with a witness in the interval:
#cas [minimize x in [-2, 2]] (x^4 - 3*x^2 + x)
certified enclosure of the minimum on the interval
min ∈ [-3.514, -3.513], witness x = -1.30084 with value ≤ -3.513- Domain
x ∈ [-2, 2]- Input (polynomial)
(x^4 - 3*x^2 + x)
Checked by Lean’s kernel: Bound on the interval and a witness value
(∀ x ∈ Set.Icc (-2) 2, -3514 / 10 ^ 3 ≤ x ^ 4 - 3 * x ^ 2 + x) ∧ -130084 / 10 ^ 5 ∈ Set.Icc (-2) 2 ∧ (fun x ↦ x ^ 4 - 3 * x ^ 2 + x) (-130084 / 10 ^ 5) ≤ -3513 / 10 ^ 3
The certificate: 1 checked step
Bound on the interval and a witness value
(∀ x ∈ Set.Icc (-2) 2, -3514 / 10 ^ 3 ≤ x ^ 4 - 3 * x ^ 2 + x) ∧ -130084 / 10 ^ 5 ∈ Set.Icc (-2) 2 ∧ (fun x ↦ x ^ 4 - 3 * x ^ 2 + x) (-130084 / 10 ^ 5) ≤ -3513 / 10 ^ 3
The computation
Candidates
Endpoints and real roots of the derivative in the interval (not proof): 5
