Tactic
cas using
Proves the goal as cas does, with your hypotheses as evidence for the conditions that the routes need.
cas using hcas does, with h as evidence for the conditions that the routes need, such as for .cas using [h₁, h₂]Many statements about real functions are true only where the functions are defined. The derivative of is for , but at Lean’s deriv is , while the right side is , since Mathlib sets . cas never assumes a condition like that. You give it one with using, and the proof uses exactly what you gave.
Examples (19)#
Basic Examples (3)
A derivative that needs :
example (x : ℝ) (hx : x ≠ 0) : deriv (fun t : ℝ ↦ t * Real.log t) x = Real.log x + 1 := by cas using hx
Lean accepts the proof.
An integral that needs the integrand to be defined on the whole interval:
example (a b : ℝ) (hpositive : ∀ t ∈ Set.uIcc a b, 0 < t) : (∫ t in a..b, 1 / t) = Real.log b - Real.log a := by cas using hpositive
Lean accepts the proof.
Two equations as facts, over any commutative ring:
theorem mul_minor_eq_zero {R : Type*} [CommRing R] (a b c d e f : R) (h₁ : a * d = b * c) (h₂ : c * f = e * d) : c * (a * f - b * e) = 0 := by cas using [h₁, h₂]
Lean accepts the proof.
Scope (6)
One-sided evidence settles the sign inside an absolute value:
example (x : ℝ) (hpositive : 0 < 2 * x + 1) : deriv (fun t : ℝ ↦ |2 * t + 1|) x = 2 := by cas using hpositive
Lean accepts the proof.
An inverse function, inside its domain:
example (x : ℝ) (hinside : 0 < 1 - x ^ 2) : HasDerivAt Real.arcsin (1 / Real.sqrt (1 - x ^ 2)) x := by cas using hinside
Lean accepts the proof.
Negative powers, and a nested derivative:
example (x : ℝ) (hx : x ≠ 0) : deriv (fun t : ℝ ↦ t ^ (-2 : ℤ)) x = -2 / x ^ 3 := by cas using hx
Lean accepts the proof.
example (x : ℝ) (hx : x ≠ 0) : deriv (deriv (fun t : ℝ ↦ Real.log (2 * t))) x = -(x ^ 2)⁻¹ := by cas using hx
Lean accepts the proof.
Positivity evidence covers a nonzero condition, here :
example (s : ℝ) (h : 0 < 4 * Real.pi * s) : deriv (fun t : ℝ ↦ Real.log (4 * Real.pi * t)) s = 1 / s := by cas using h
Lean accepts the proof.
A real power with a symbolic exponent. The interval may contain , since :
example (r a b : ℝ) (hr : -1 < r) : (∫ t : ℝ in a..b, t ^ r) = (b ^ (r + 1) - a ^ (r + 1)) / (r + 1) := by cas using hr
Lean accepts the proof.
An equation with a quotient as the hypothesis. Its denominators are cleared, with from the context:
example (p q : ℝ) (hq : q ≠ 0) (h : p / q = p - 1) : p = q * (p - 1) := by cas using h
Lean accepts the proof.
Options (3)
Evidence proved in place. Here is what I know, and the route wants :
example (r a b : ℝ) (hr : 0 < r + 1) : (∫ t : ℝ in a..b, t ^ r) = (b ^ (r + 1) - a ^ (r + 1)) / (r + 1) := by cas using (show -1 < r from by linarith)
Lean accepts the proof.
Two conditions at once, with And.intro:
example (r a b : ℝ) (hr : r ≠ -1) (hab : (0 : ℝ) ∉ Set.uIcc a b) : (∫ t : ℝ in a..b, t ^ r) = (b ^ (r + 1) - a ^ (r + 1)) / (r + 1) := by cas using And.intro hr hab
Lean accepts the proof.
Applied hypotheses, in a list and alone:
example (x : ℝ) (hlower : ∀ t : ℝ, t = x → 1 ≤ t) (hupper : ∀ t : ℝ, t = x → t ≤ 2) : x ^ 2 ≤ 4 := by cas using [hlower x rfl, hupper x rfl]
Lean accepts the proof.
example (f : ℝ → ℝ) (h : ∀ t, (1 : ℝ) ≤ f t) : 0 ≤ f 0 := by cas using (h 0)
Lean accepts the proof.
Applications (1)
An integral with two parameters. The only condition is that and are not both zero, and only the three standard axioms are used:
theorem exp_mul_sin_over_unit (a b : ℝ) (h : a ^ 2 + b ^ 2 ≠ 0) : ∫ x in (0 : ℝ)..1, Real.exp (a * x) * Real.sin (b * x) = (Real.exp a * (a * Real.sin b - b * Real.cos b) + b) / (a ^ 2 + b ^ 2) := by cas using h #print axioms exp_mul_sin_over_unit
exp_mul_sin_over_unit depends on the axioms propext, Classical.choice, Quot.sound.
Properties and Relations (2)
derive prints the same derivative together with the condition it needs:
#cas [derive x] (x * log x)
log(x) + 1- Conditions
Checked by Lean’s kernel: Derivative of the input
∀ (x : ℝ), x ≠ 0 → HasDerivAt (fun x ↦ x * Real.log x) (Real.log x + 1) x
from CAS.Command.hasDerivAt_of_displayRoute
The certificate: 5 checked steps
Derivative of the input
∀ (x : ℝ), x ≠ 0 → HasDerivAt (fun x ↦ x * Real.log x) (Real.log x + 1) x
Partial derivative in x: indexed rules compute Expr.diff
(CAS.Verified.Expr.DiffDerivation.build 0 (𝕏[0].mul 𝕏[0].log)).rawDerivative = CAS.Verified.Expr.diff 0 (𝕏[0].mul 𝕏[0].log)
Partial derivative in x: normalization preserves evaluation
∀ (ρ : Fin 1 → ℝ), CAS.Verified.Expr.eval ρ (CAS.Verified.Expr.DiffDerivation.build 0 (𝕏[0].mul 𝕏[0].log)).simplifiedDerivative = CAS.Verified.Expr.eval ρ (CAS.Verified.Expr.DiffDerivation.build 0 (𝕏[0].mul 𝕏[0].log)).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].mul 𝕏[0].log))).nonzero → CAS.Verified.Expr.eval ρ (CAS.Command.displayDerivativeRoute (CAS.Verified.Expr.DiffDerivation.build 0 (𝕏[0].mul 𝕏[0].log))).rhs = CAS.Verified.Expr.eval ρ (CAS.Verified.Expr.DiffDerivation.build 0 (𝕏[0].mul 𝕏[0].log)).simplifiedDerivative
Partial derivative in x: analytic semantics of the displayed result
∀ (x : ℝ^1), CAS.Verified.Expr.ValidAt x.ofLp (𝕏[0].mul 𝕏[0].log) → CAS.Verified.Expr.Alg.SideHolds x.ofLp (CAS.Command.displayDerivativeRoute (CAS.Verified.Expr.DiffDerivation.build 0 (𝕏[0].mul 𝕏[0].log))).nonzero → (fderiv ℝ (fun y ↦ CAS.Verified.Expr.eval y.ofLp (𝕏[0].mul 𝕏[0].log)) x) (EuclideanSpace.single 0 1) = CAS.Verified.Expr.eval x.ofLp (CAS.Command.displayDerivativeRoute (CAS.Verified.Expr.DiffDerivation.build 0 (𝕏[0].mul 𝕏[0].log))).rhs
The computation
Variables: x
Analytic domain conditions
Raw checked nonzero requirements: x, x Raw checked positivity requirements: (none)
Partial derivative in x
1. Apply symbolic differentiation rules
raw result: 1*log(x) + x*1/x
2. Normalize the symbolic derivative unconditionally
normalized result: log(x) + x/x
3. Apply checked side-conditioned cleanup
displayed result: log(x) + 1 additional nonzero requirements: x
cas? accepts the same evidence and suggests the call to keep:
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.
Possible Issues (2)
Without the condition, cas refuses. At this statement is false in Lean:
example (x : ℝ) : deriv (fun t : ℝ ↦ t * Real.log t) x = Real.log x + 1 := by cas
Error
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 ≠ 0
Evidence that is too weak is refused in the same way. still allows :
example (x : ℝ) (hx : 0 ≤ x) : deriv (fun t : ℝ ↦ t * Real.log t) x = Real.log x + 1 := by cas using hx
Error
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 ≠ 0
Neat Examples (2)
The second derivative of is at every :
theorem deriv_deriv_abs (x : ℝ) (hx : x ≠ 0) : deriv (deriv (fun t : ℝ ↦ |t|)) x = 0 := by cas using hx
Lean accepts the proof.
Conjugate exponents. From it follows that :
example (p q : ℝ) (hp : p ≠ 0) (hq : q ≠ 0) (h : p / q = p - 1) : 1 / q = 1 - 1 / p := by cas using h
Lean accepts the proof.
