Options
Options
The settings of cas, cega and #cas: the budget of a call, what a report shows, and the trace classes.
set_option name value in commandset_option name valueset_option trace.class true in commandSymLean works within budgets, because I’d rather have an expensive call stop and say so than hang. When a call would need more work than its budget allows, it stops, and the message names the budget. A box query that is too big is refused before the kernel starts, so it fails at once instead of stalling a build. Two more options choose what a report shows, and the trace classes print the steps of a route.
Examples (13)#
Basic Examples (3)
cas.suggest turns a report into an example to paste in place of the command:
set_option cas.suggest true in #cas [derive x] (tan x)
1/cos(x)^2- Conditions
Checked by Lean’s kernel: Derivative of the input
∀ (x : ℝ), Real.cos x ≠ 0 → HasDerivAt (fun x ↦ Real.tan x) (1 / Real.cos x ^ 2) x
from CAS.Command.hasDerivAt_of_displayRoute
The certificate: 5 checked steps
Derivative of the input
∀ (x : ℝ), Real.cos x ≠ 0 → HasDerivAt (fun x ↦ Real.tan x) (1 / Real.cos x ^ 2) x
Partial derivative in x: indexed rules compute Expr.diff
(CAS.Verified.Expr.DiffDerivation.build 0 (𝕏[0].sin.div 𝕏[0].cos)).rawDerivative = CAS.Verified.Expr.diff 0 (𝕏[0].sin.div 𝕏[0].cos)
Partial derivative in x: normalization preserves evaluation
∀ (ρ : Fin 1 → ℝ), CAS.Verified.Expr.eval ρ (CAS.Verified.Expr.DiffDerivation.build 0 (𝕏[0].sin.div 𝕏[0].cos)).simplifiedDerivative = CAS.Verified.Expr.eval ρ (CAS.Verified.Expr.DiffDerivation.build 0 (𝕏[0].sin.div 𝕏[0].cos)).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].sin.div 𝕏[0].cos))).nonzero → CAS.Verified.Expr.eval ρ (CAS.Command.displayDerivativeRoute (CAS.Verified.Expr.DiffDerivation.build 0 (𝕏[0].sin.div 𝕏[0].cos))).rhs = CAS.Verified.Expr.eval ρ (CAS.Verified.Expr.DiffDerivation.build 0 (𝕏[0].sin.div 𝕏[0].cos)).simplifiedDerivative
Partial derivative in x: analytic semantics of the displayed result
∀ (x : ℝ^1), CAS.Verified.Expr.ValidAt x.ofLp (𝕏[0].sin.div 𝕏[0].cos) → CAS.Verified.Expr.Alg.SideHolds x.ofLp (CAS.Command.displayDerivativeRoute (CAS.Verified.Expr.DiffDerivation.build 0 (𝕏[0].sin.div 𝕏[0].cos))).nonzero → (fderiv ℝ (fun y ↦ CAS.Verified.Expr.eval y.ofLp (𝕏[0].sin.div 𝕏[0].cos)) x) (EuclideanSpace.single 0 1) = CAS.Verified.Expr.eval x.ofLp (CAS.Command.displayDerivativeRoute (CAS.Verified.Expr.DiffDerivation.build 0 (𝕏[0].sin.div 𝕏[0].cos))).rhs
The computation
Variables: x
Analytic domain conditions
Raw checked nonzero requirements: cos(x) Raw checked positivity requirements: (none)
Partial derivative in x
1. Apply symbolic differentiation rules
raw result: (cos(x)*1*cos(x) - sin(x)*-sin(x)*1)/cos(x)^2
2. Normalize the symbolic derivative unconditionally
normalized result: 1/cos(x)^2
3. Apply checked side-conditioned cleanup
displayed result: 1/cos(x)^2 additional nonzero requirements: (none)
Try this
example (x : ℝ) (h : Real.cos x ≠ 0) : HasDerivAt (fun x ↦ Real.tan x) (1 / Real.cos x ^ 2) x := by cas
The suggestion, pasted:
example (x : ℝ) (h : Real.cos x ≠ 0) : HasDerivAt (fun x ↦ Real.tan x) (1 / Real.cos x ^ 2) x := by cas
Lean accepts the proof.
trace.cega.stated shows the bound that the kernel checked:
set_option trace.cega.stated true in example (x : ℝ) (h0 : 0 ≤ x) (h1 : x ≤ 1) : x * (1 - x) ≤ 1 / 4 := by cega
[cega.stated] bound query, stated bound ≤ 1/4: checked by the kernel
Scope (3)
trace.cega.integration shows the quadrature behind a bound on an integral:
set_option trace.cega.integration true in example : |(∫ x in (0 : ℝ)..1, x ^ 2) - 1 / 3| ≤ 1 / 100 := by cega
[cega.integration] 1 Simpson panels at the precision (16, 6, 12) put the integral in [0.33, 0.34]
cega.arithmetic sets the arithmetic of the cega calls after it. The trace names the format of the check:
set_option cega.arithmetic "binary64" in set_option trace.cega.stated true in example (x : ℝ) (h0 : 0 ≤ x) (h1 : x ≤ 1) : Real.exp x ≤ 2.72 := by cega
Lean accepts the proof.
cas.verbose shows the full report under a suggestion:
set_option cas.verbose true in example (x : ℝ) (h0 : 0 ≤ x) (h1 : x ≤ 1) : x * (1 - x) ≤ 1 / 4 := by cega?
Try this
cega [enclose x in [0, 1]] (x * (1 - x)) [CAS.explanation] Proof evidence [CAS.explanation.checkedEvidence] Checked proof steps [CAS.explanation.checkedStep] final proof assigned to the original goal Proposition: x * (1 - x) ≤ 1 / 4 Validation: completed proof checked by the elaborator; kernel check occurs when the declaration is accepted [CAS.explanation.plannerMetadata] Planner metadata (not proof) [CAS.explanation.plannerStep] CEGA route: checked box enclosure of an ordinary inequality: selected [CAS.explanation.plannerStep] arithmetic: exact rationals: selected
Options (1)
Without in, an option holds to the end of the section:
section set_option cas.suggest true #cas [simplify] (x + x) end
2*xChecked by Lean’s kernel: Identity with the simplified form
∀ (x : ℝ), x + x = 2 * x
from CAS.Command.eq_of_simplifyFinDisplayRoute
The certificate: 2 checked steps
Identity with the simplified form
∀ (x : ℝ), x + x = 2 * x
Simplification under generated rewrite assumptions
∀ (ρ : Fin 1 → ℝ), CAS.Verified.Expr.Alg.SideHolds ρ (𝕏[0].add 𝕏[0]).simplifyFinDisplayRoute.nonzero → CAS.Verified.Expr.eval ρ (𝕏[0].add 𝕏[0]).simplifyFinDisplayRoute.rhs = CAS.Verified.Expr.eval ρ (𝕏[0].add 𝕏[0]).simplifyFinDisplayRoute.lhs
The computation
Variables: x
Checked symbolic computation
Raw checked nonzero requirements: (none) Guarantee: these assumptions justify conditional rewrites and preserve real evaluation
Try this
example (x : ℝ) : x + x = 2 * x := by cas
Applications (1)
Five bounds in one conjunction, each proved by cega. The trace shows the kind of query and the bound that each check proved:
set_option trace.cega.stated true in example (x : ℝ) (h0 : 0 ≤ x) (h1 : x ≤ 1) : x * (1 - x) < 1 / 3 ∧ 0 ≤ x * (1 - x) ∧ x * (1 - x) > -1 / 2 ∧ |x - 1 / 2| < 1 ∧ 3 / 10 ≥ x * (1 - x) := ⟨by cega, by cega, by cega, by cega, by cega⟩
Lean accepts the proof.
Properties and Relations (1)
The options in parentheses belong to one call, where set_option holds for a whole command. Here the digits of findRoot:
#cas (digits := 30) [findRoot x in [1, 2]] (x^2 - 2)
certified simple root
x = 1.414213562373095048801688724210 ± 10^-30- Domain
x ∈ [1, 2]
Checked by Lean’s kernel: Unique root in the interval
∃! x, x ∈ Set.Icc (1414213562373095048801688724209 / 10 ^ 30) (1414213562373095048801688724211 / 10 ^ 30) ∧ x ^ 2 - 2 = 0
The certificate: 1 checked step
Unique root in the interval
∃! x, x ∈ Set.Icc (1414213562373095048801688724209 / 10 ^ 30) (1414213562373095048801688724211 / 10 ^ 30) ∧ x ^ 2 - 2 = 0
The computation
Certified root
Sign change found by interval sampling and bisection (not proof) Unique root in [1.414213562373095048801688724209, 1.414213562373095048801688724211], within 10^-30 of 1.414213562373095048801688724210: endpoint signs and a derivative of one sign, checked by the kernel
Possible Issues (3)
A fallback that runs out of its budget says so. Here grind gets a thousand heartbeats:
set_option cas.grindHeartbeats 1 in example (x : ℝ) (h₁ : x - 1 ≠ 0) (h₂ : x + 1 ≠ 0) : (x ^ 3 - 1) / (x ^ 2 - 1) = (x ^ 2 + x + 1) / (x + 1) := by cas
Error
cas could not close this ordinary arithmetic goal. This goal contains branch-sensitive operations and may need nonzero denominator hypotheses. Put those facts in the local context; pass one explicit fact as `cas using h` when needed. The corresponding `#cas [simplify]` report shows the exact generated conditions. Detected candidate conditions: x ^ 2 - 1 ≠ 0, x + 1 ≠ 0.
The rest of the message
Polynomial equation route:
`grind` failed
case grind
x : ℝ
h₁ : x - 1 ≠ 0
h₂ : x + 1 ≠ 0
h : ¬(x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ = x * (x + 1) + 1
⊢ False
[grind] Goal diagnostics
[facts] Asserted facts
[prop] ¬x - 1 = 0
[prop] ¬x + 1 = 0
[prop] ¬(x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ = x * (x + 1) + 1
[prop] if x ^ 2 - 1 = 0 then (x ^ 2 - 1)⁻¹ = 0 else (x ^ 2 - 1) * (x ^ 2 - 1)⁻¹ = 1
[eqc] True propositions
[prop] if x ^ 2 - 1 = 0 then (x ^ 2 - 1)⁻¹ = 0 else (x ^ 2 - 1) * (x ^ 2 - 1)⁻¹ = 1
[eqc] False propositions
[prop] x + 1 = 0
[prop] (x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ = x * (x + 1) + 1
[prop] x - 1 = 0
[eqc] Equivalence classes
[eqc] {1,
(x + 1) * (x + 1)⁻¹,
(x - 1) * (x - 1)⁻¹,
((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1)) *
((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹}
[ematch] E-matching patterns
[thm] Nat.pow_pos: [@HPow.hPow `[ℕ] `[ℕ] `[ℕ] `[instHPow] #2 #1]
[thm] Nat.div_pow_of_pos: [@HPow.hPow `[ℕ] `[ℕ] `[ℕ] `[instHPow] #2 #1]
[ring] Ring `ℝ`
[basis] Basis
[_] 2 * (x ^ 2 * (x ^ 2 - 1)⁻¹ * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹) +
2 * (x * (x ^ 2 - 1)⁻¹ * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹) +
-3 * ((x - 1)⁻¹ * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹) +
(x + 1)⁻¹ * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹ +
2 * ((x ^ 2 - 1)⁻¹ * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹) +
-1 * (x - 1)⁻¹ +
(x + 1)⁻¹ +
-2 * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹ =
0
[_] 6 * ((x - 1)⁻¹ ^ 2 * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹) +
-4 * (x * (x ^ 2 - 1)⁻¹ * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹) +
-12 *
((x - 1)⁻¹ * (x ^ 2 - 1)⁻¹ *
((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹) +
2 * (x - 1)⁻¹ ^ 2 +
3 * ((x - 1)⁻¹ * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹) +
(x + 1)⁻¹ * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹ +
-8 * ((x ^ 2 - 1)⁻¹ * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹) +
-1 * (x - 1)⁻¹ +
(x + 1)⁻¹ =
0
[_] 2 * ((x + 1)⁻¹ ^ 2 * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹) +
4 * (x * (x ^ 2 - 1)⁻¹ * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹) +
4 *
((x + 1)⁻¹ * (x ^ 2 - 1)⁻¹ *
((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹) +
2 * (x + 1)⁻¹ ^ 2 +
-3 * ((x - 1)⁻¹ * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹) +
-1 * ((x + 1)⁻¹ * ((x ^ 3 - 1) * (x + 1) * (x ^ 2 - 1)⁻¹ - (x * (x + 1) + 1))⁻¹) +
-1 * (x - 1)⁻¹ +
(x + 1)⁻¹ =
0
[_] x * (x - 1)⁻¹ + -1 * (x - 1)⁻¹ + -1 = 0
[_] x * (x + 1)⁻¹ + (x + 1)⁻¹ + -1 = 0
[_] 2 * ((x - 1)⁻¹ * (x + 1)⁻¹) + -1 * (x - 1)⁻¹ + (x + 1)⁻¹ = 0
[limits] Thresholds reached
[limit] maximum number of E-matching rounds has been reached, threshold: `(ematch := 0)`
[limit] maximum number of case-splits has been reached, threshold: `(splits := 0)`
Checked identity route:
cas could not prove the real analytic domain conditions.
A denominator or logarithm argument may need to be nonzero, a square-root argument may need to be positive, or an inverse-trigonometric argument may need to avoid a branch endpoint. Supply the relevant ordinary hypothesis with `cas using h`.
Unproved conditions:
x * x + ↑(-1) ≠ 0
Grind fallback:
grind did not finish within its budget of 1 thousand heartbeats (option `cas.grindHeartbeats`)A box with nine coordinates is over cega.maxDimension. FloatLib’s interval, which cega tries next, has no such limit, and it proves on . The bound below is sharp at , and interval evaluation does not reach it:
example (x0 x1 x2 x3 x4 x5 x6 x7 x8 : ℝ) (h0 : x0 ∈ Set.Icc (0 : ℝ) 1) (h1 : x1 ∈ Set.Icc (0 : ℝ) 1) (h2 : x2 ∈ Set.Icc (0 : ℝ) 1) (h3 : x3 ∈ Set.Icc (0 : ℝ) 1) (h4 : x4 ∈ Set.Icc (0 : ℝ) 1) (h5 : x5 ∈ Set.Icc (0 : ℝ) 1) (h6 : x6 ∈ Set.Icc (0 : ℝ) 1) (h7 : x7 ∈ Set.Icc (0 : ℝ) 1) (h8 : x8 ∈ Set.Icc (0 : ℝ) 1) : x0 * (1 - x0) + x1 * (1 - x1) + x2 * (1 - x2) + x3 * (1 - x3) + x4 * (1 - x4) + x5 * (1 - x5) + x6 * (1 - x6) + x7 * (1 - x7) + x8 * (1 - x8) ≤ 9 / 4 := by cega
Error
CEGA box query with 9 coordinates exceeds cega.maxDimension (8); bound fewer variables at once, or explicitly increase that resource budget
The rest of the message
Other routes:
carrier search:
cega found no registered checked carrier or direct certificate matching the target
interval route:
interval could not certify: the enclosure of (((((((((x0 * (1 - x0) + (x1 * (1 - x1))) + (x2 * (1 - x2))) + (x3 * (1 - x3))) + (x4 * (1 - …))) + …) + …) + …) + …) - …) is [-9/4, 11/4]; its upper endpoint does not establish ≤ 0.
Box: x0 in [0, 1/2], x1 in [0, 1/2], x2 in [0, 1/2], x3 in [0, 1/2], x4 in [0, 1/2], x5 in [0, 1/2], … (3 more coordinates). Subdivision depth 8 exhausted after 8 splits on this branch.
Try tighter input bounds or more subdivision depth.
Bare `cega` proves an ordinary real inequality (`f x ≤ c`, `f x < c`, `c ≤ f x`, `c < f x` (also with `≥` and `>`), `|f x| ≤ c`, `|f x| < c`, `a ≤ f x ∧ f x ≤ b` (also with `<`), `f x ∈ Set.Icc a b` (also `Set.Ioo`, `Set.Ico`, `Set.Ioc`), `f x ≤ g x`, `f x < g x`, and conjunctions of these, with `c`, `a`, `b` closed and every real variable bounded by hypotheses `a ≤ x` and `x ≤ b`, `x ∈ Set.Icc a b`, or `|x| ≤ r` with rational literal endpoints), a bound on an interval integral `∫ x in a..b, f x` with rational limits, a certificate goal (`EnclosedOn f s lo hi`, `BoundOn f s c`, `ApproxOn f g s ε`, `ResidualBound r s ε`) on a coordinate box or from a checked carrier in the local context or the goal, a closed decidable statement about floats, which `float_decide` decides, a real inequality that FloatLib's `interval` proves, on finite sums and norms too, and a closed goal that interval evaluation proves.Twenty thousand digits of are over cas.maxDigits:
example : (3 : ℝ) ≤ Real.pi ∧ Real.pi ≤ 4 := by cega (digits := 20000) [enclose] Real.pi
Error
CEGA query with 20000 digits exceeds cas.maxDigits (2000); request fewer digits or explicitly increase that resource budget
Neat Examples (1)
A sum of six terms on , at most 6, with equality at . FloatLib’s check, which runs first, does not reach a sharp bound like this one. Each term increases in its coordinate, so the box query could reduce every coordinate by monotonicity, and cega.maxFaceReductions refuses it at once:
example (x0 x1 x2 x3 x4 x5 : ℝ) (h0 : x0 ∈ Set.Icc (0 : ℝ) 1) (h1 : x1 ∈ Set.Icc (0 : ℝ) 1) (h2 : x2 ∈ Set.Icc (0 : ℝ) 1) (h3 : x3 ∈ Set.Icc (0 : ℝ) 1) (h4 : x4 ∈ Set.Icc (0 : ℝ) 1) (h5 : x5 ∈ Set.Icc (0 : ℝ) 1) : x0 * (2 - x0) + x1 * (2 - x1) + x2 * (2 - x2) + x3 * (2 - x3) + x4 * (2 - x4) + x5 * (2 - x5) ≤ 6 := by cega
Error
CEGA box query could reduce 6 coordinates by monotonicity, which exceeds cega.maxFaceReductions (5). Each reduction reruns the planner on two faces, so its kernel work doubles with each one (a sum of six squares on a six-dimensional box took minutes and tens of gigabytes); bound fewer variables at once, or explicitly increase that resource budget
The rest of the message
Other routes:
carrier search:
cega found no registered checked carrier or direct certificate matching the target
interval route:
interval could not certify: the enclosure of ((((((x0 * (2 - x0) + (x1 * (2 - x1))) + (x2 * (2 - x2))) + (x3 * (2 - x3))) + (x4 * (2 - x4))) + (x5 * …)) - …) is [-19/4, 1/4]; its upper endpoint does not establish ≤ 0.
Box: x0 in [1/4, 1/2], x1 in [1/4, 1/2], x2 in [0, 1/2], x3 in [0, 1/2], x4 in [0, 1/2], x5 in [1/2, 1]. Subdivision depth 8 exhausted after 8 splits on this branch.
Try tighter input bounds or more subdivision depth.
Bare `cega` proves an ordinary real inequality (`f x ≤ c`, `f x < c`, `c ≤ f x`, `c < f x` (also with `≥` and `>`), `|f x| ≤ c`, `|f x| < c`, `a ≤ f x ∧ f x ≤ b` (also with `<`), `f x ∈ Set.Icc a b` (also `Set.Ioo`, `Set.Ico`, `Set.Ioc`), `f x ≤ g x`, `f x < g x`, and conjunctions of these, with `c`, `a`, `b` closed and every real variable bounded by hypotheses `a ≤ x` and `x ≤ b`, `x ∈ Set.Icc a b`, or `|x| ≤ r` with rational literal endpoints), a bound on an interval integral `∫ x in a..b, f x` with rational limits, a certificate goal (`EnclosedOn f s lo hi`, `BoundOn f s c`, `ApproxOn f g s ε`, `ResidualBound r s ε`) on a coordinate box or from a checked carrier in the local context or the goal, a closed decidable statement about floats, which `float_decide` decides, a real inequality that FloatLib's `interval` proves, on finite sums and norms too, and a closed goal that interval evaluation proves.