Tactic
cas?
Proves the goal as cas does, and suggests the call to keep in the proof.
cas?cas does, and suggests the call to keep in the proof.cas? using h, cas? using [h₁, h₂], cas? [l₁, l₂]cas, with the same arguments.cas? [integrate primitive := F]using h inside the brackets.I write cas? while a proof is still taking shape. It closes the goal as cas would, then tells me which route did it and what to write instead. When the box query proved a bound, the suggestion names the box and the expression, so the finished proof says what it checks. When FloatLib’s check proved it, the suggestion is bare cega, which runs that check again.
Examples (14)#
Basic Examples (3)
A polynomial identity. The suggestion is plain cas, and the line under it names the route:
example (x : ℝ) : (x + 1) ^ 2 = x ^ 2 + 2 * x + 1 := by cas?
Try this
cas
Lean checked the suggested replacement against the original goal. Selected route: CAS route: ordinary Lean simplification/arithmetic.A bound on a box. The route was the box route of cega, and FloatLib’s check proved the bound, so the suggestion is bare cega:
example (x : ℝ) (h₀ : 0 ≤ x) (h₁ : x ≤ 1) : Real.exp x ≤ 3 := by cas?
Try this
cega
Lean checked the suggested replacement against the original goal. Selected route: CAS route: checked CEGA box enclosure of an ordinary inequality.A definite integral, by a search for an antiderivative:
example : (∫ x in (0 : ℝ)..1, x * Real.exp x) = 1 := by cas?
Try this
cas
Lean checked the suggested replacement against the original goal. Selected route: CAS route: checked integration, bounded antiderivative search.Scope (4)
Evidence for a domain condition, as in cas using:
example (x : ℝ) (hx : 0 < x) : deriv (fun t : ℝ ↦ t ^ (3 / 2 : ℝ)) x = (3 / 2 : ℝ) * x ^ (1 / 2 : ℝ) := by cas? using hx
Try this
cas using hx Lean checked the suggested replacement against the original goal. Selected route: CAS route: checked symbolic derivative.
Equation hypotheses as facts:
example (x y : ℝ) (h₁ : x + y = 3) (h₂ : x - y = 1) : x = 2 := by cas? using [h₁, h₂]
Try this
cas using [h₁, h₂] Lean checked the suggested replacement against the original goal. Selected route: CAS route: polynomial consequences of equation hypotheses.
A definition to unfold:
def square (x : ℝ) : ℝ := x * x example (x : ℝ) : square (x + 1) = x ^ 2 + 2 * x + 1 := by cas? [square]
Try this
cas [square]
Lean checked the suggested replacement against the original goal. Selected route: CAS route: ordinary Lean simplification/arithmetic.A supplied primitive, with and without domain evidence:
example : (∫ x in (0 : ℝ)..1, 2 * x) = 1 := by cas? [integrate primitive := fun x ↦ x ^ 2]
Try this
cas [integrate primitive := fun x ↦ x ^ 2] Lean checked the suggested replacement against the original goal. Selected route: CAS route: checked integration, explicit primitive verification.
example (a b : ℝ) (h : ∀ t ∈ Set.uIcc a b, t ≠ 0) : (∫ t in a..b, Real.log t / t) = Real.log b ^ 2 / 2 - Real.log a ^ 2 / 2 := by cas? [integrate primitive := fun t ↦ Real.log t ^ 2 / 2 using h]
Try this
cas [integrate primitive := fun t ↦ Real.log t ^ 2 / 2 using h] Lean checked the suggested replacement against the original goal. Selected route: CAS route: checked integration, explicit primitive verification.
Options (1)
set_option cas.verbose true shows the full report under the suggestion:
set_option cas.verbose true in example (x : ℝ) : Real.sin x ^ 2 + Real.cos x ^ 2 = 1 := by cas?
Try this
cas [CAS.explanation] Proof evidence [CAS.explanation.checkedEvidence] Checked proof steps [CAS.explanation.checkedStep] final proof assigned to the original goal Proposition: Real.sin x ^ 2 + Real.cos x ^ 2 = 1 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] CAS route: ordinary Lean simplification/arithmetic: selected
Applications (1)
The suggested call replaces cas?, and the theorem keeps it. Only the three standard axioms are used:
theorem exp_le_three (x : ℝ) (h₀ : 0 ≤ x) (h₁ : x ≤ 1) : Real.exp x ≤ 3 := by cega #print axioms exp_le_three
exp_le_three depends on the axioms propext, Classical.choice, Quot.sound.
Properties and Relations (2)
example (x : ℝ) (h₀ : 0 ≤ x) (h₁ : x ≤ 1) : Real.sin x ≤ 0.85 := by cega?
Try this
cega Lean checked the suggested replacement against the original goal. Selected route: CEGA route: checked box enclosure of an ordinary inequality, arithmetic: exact rationals.
A limit, written with Mathlib’s filters. The statement is one that limit prints:
open Filter Topology in example : Tendsto (fun x : ℝ ↦ Real.sin x / x) (𝓝[≠] 0) (𝓝 1) := by cas?
Try this
cas Lean checked the suggested replacement against the original goal. Selected route: CAS route: theorem of a #cas command.
Possible Issues (2)
cas? fails where cas fails, with the message of cas:
example (x : ℝ) : Real.sin x ^ 2 + Real.cos x ^ 2 = 2 := by cas?
Error
cas could not prove this arithmetic relation. The statement may be false, or it may lie outside the supported normalization and arithmetic fragment
The rest of the message
Polynomial equation route:
`grind` failed
case grind
x : ℝ
h : ¬Real.sin x ^ 2 + Real.cos x ^ 2 = 2
⊢ False
[grind] Goal diagnostics
[facts] Asserted facts
[prop] ¬Real.sin x ^ 2 + Real.cos x ^ 2 = 2
[eqc] False propositions
[prop] Real.sin x ^ 2 + Real.cos x ^ 2 = 2
[eqc] Equivalence classes
[eqc] {1, (Real.sin x ^ 2 + Real.cos x ^ 2 - 2) * (Real.sin x ^ 2 + Real.cos x ^ 2 - 2)⁻¹}
[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
[_] Real.sin x ^ 2 * (Real.sin x ^ 2 + Real.cos x ^ 2 - 2)⁻¹ +
Real.cos x ^ 2 * (Real.sin x ^ 2 + Real.cos x ^ 2 - 2)⁻¹ +
-2 * (Real.sin x ^ 2 + Real.cos x ^ 2 - 2)⁻¹ +
-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 identify the two sides: the checked normalizer does not reduce their difference to zero.
Normalized difference:
CAS.Verified.Expr.int (-1)
canonical form route: the canonical rational form of the difference is not zero.
Canonical difference:
((𝕏[0].sin.pow 2).add (𝕏[0].cos.pow 2)).sub (CAS.Verified.Expr.nat 2)
Elementary rewrite route:
no elementary rewrite applies
Grind fallback:
`grind` failed (`set_option trace.cas.fallback true` shows its diagnostics)A resource limit is not a refutation. The message names a larger setting to try:
example (x : ℝ) : x + 1 = 1 + x := by set_option maxRecDepth 12 in cas?
Error
cas exceeded Lean's maximum recursion depth (the option maxRecDepth is 12; some routes run with a higher limit of their own). This is a resource limit, not a refutation of the goal. A larger setting may help: write `set_option maxRecDepth 48 in` before the tactic; or make the goal smaller.
Neat Examples (1)
An integral whose right side is for , with the condition on the interval. The suggestion is cas using h:
theorem log_div_integral_of_goal (a b : ℝ) (h : ∀ t ∈ Set.uIcc a b, t ≠ 0) : (∫ t in a..b, Real.log t / t) = Real.log b ^ 2 / 2 - Real.log a ^ 2 / 2 := by cas? using h
Try this
cas using h Lean checked the suggested replacement against the original goal. Selected route: CAS route: checked integration, direct interval calculus.
See Also
cas · cega? · cas using · cas [integrate primitive := F] · cega · Options
