Mode of #cas
trigExpand
Expands sines and cosines of sums, differences and double angles, with a theorem about Mathlib’s sine and cosine.
#cas [trigExpand] etrigExpand applies the angle-addition formulas to sines and cosines, so that their products can be expanded and simplified. The theorem is an identity about Real.sin and Real.cos for all real values of the variables, so it needs no conditions.
It applies six formulas and nothing else, which keeps it predictable: you can tell from the input what the output will be. For identities that need more, such as or a triple angle, I use fullSimplify or the tactic cas.
Examples (11)#
Basic Examples (2)
The sine of a sum:
#cas [trigExpand] (sin (x + y))
sin(x)*cos(y) + cos(x)*sin(y)Checked by Lean’s kernel: Identity with the trigonometric expansion
∀ (x y : ℝ), Real.sin (x + y) = Real.sin x * Real.cos y + Real.cos x * Real.sin yThe certificate: 1 checked step
Identity with the trigonometric expansion
∀ (x y : ℝ), Real.sin (x + y) = Real.sin x * Real.cos y + Real.cos x * Real.sin y
The computation
Ranked candidates (proposals, not proof)
trigonometric expansion: sin(x)*cos(y) + cos(x)*sin(y) [leafCount 11, conditions 0] input: sin(x + y) [leafCount 4, conditions 0]
The cosine of a double angle:
#cas [trigExpand] (cos (2*x))
cos(x)^2 - sin(x)^2Checked by Lean’s kernel: Identity with the trigonometric expansion
∀ (x : ℝ), Real.cos (2 * x) = Real.cos x ^ 2 - Real.sin x ^ 2
The certificate: 1 checked step
Identity with the trigonometric expansion
∀ (x : ℝ), Real.cos (2 * x) = Real.cos x ^ 2 - Real.sin x ^ 2
The computation
Ranked candidates (proposals, not proof)
trigonometric expansion: cos(x)^2 - sin(x)^2 [leafCount 9, conditions 0] input: cos(2*x) [leafCount 4, conditions 0]
Scope (1)
A difference and a double angle in one product. Each factor is expanded:
#cas [trigExpand] (cos (x - y) * sin (2 * y))
(cos(x)*cos(y) + sin(x)*sin(y))*(2*sin(y)*cos(y))Checked by Lean’s kernel: Identity with the trigonometric expansion
∀ (x y : ℝ), Real.cos (x - y) * Real.sin (2 * y) = (Real.cos x * Real.cos y + Real.sin x * Real.sin y) * (2 * Real.sin y * Real.cos y)
The certificate: 1 checked step
Identity with the trigonometric expansion
∀ (x y : ℝ), Real.cos (x - y) * Real.sin (2 * y) = (Real.cos x * Real.cos y + Real.sin x * Real.sin y) * (2 * Real.sin y * Real.cos y)
The computation
Ranked candidates (proposals, not proof)
trigonometric expansion: (cos(x)*cos(y) + sin(x)*sin(y))*(2*sin(y)*cos(y)) [leafCount 19, conditions 0] input: cos(x - y)*sin(2*y) [leafCount 9, conditions 0]
Applications (3)
The addition formula as a theorem, for all real x and y. Only the three standard axioms are used:
theorem sin_add_expanded (x y : ℝ) : Real.sin (x + y) = Real.sin x * Real.cos y + Real.cos x * Real.sin y := by cas #print axioms sin_add_expanded
sin_add_expanded depends on the axioms propext, Classical.choice, Quot.sound.
The tactic cas proves the other forms of the double-angle formula, which also need :
example (x : ℝ) : Real.cos (2 * x) = 1 - 2 * Real.sin x ^ 2 := by cas
Lean accepts the proof.
A product of a sum and a difference:
example (x y : ℝ) : Real.sin (x + y) * Real.sin (x - y) = Real.sin x ^ 2 - Real.sin y ^ 2 := by cas
Lean accepts the proof.
Properties and Relations (2)
expand leaves the argument of a function alone:
#cas [expand] (sin (x + y))
sin(x + y)Checked by Lean’s kernel: Identity with the input
∀ (x y : ℝ), Real.sin (x + y) = Real.sin (x + y)The certificate: 1 checked step
Identity with the input
∀ (x y : ℝ), Real.sin (x + y) = Real.sin (x + y)
The computation
Ranked candidates (proposals, not proof)
input: sin(x + y) [leafCount 4, conditions 0]
fullSimplify tries the trigonometric expansion with the other candidates, so it finds identities that reduce to :
#cas [fullSimplify] (sin (2*x) - 2*sin x*cos x)
0Checked by Lean’s kernel: Identity with the trigonometric expansion and simplification
∀ (x : ℝ), Real.sin (2 * x) - 2 * Real.sin x * Real.cos x = 0
The certificate: 1 checked step
Identity with the trigonometric expansion and simplification
∀ (x : ℝ), Real.sin (2 * x) - 2 * Real.sin x * Real.cos x = 0
The computation
Ranked candidates (proposals, not proof)
trigonometric expansion and simplification: 0 [leafCount 1, conditions 0] input: sin(2*x) - 2*sin(x)*cos(x) [leafCount 12, conditions 0] configured simplification: sin(2*x) - 2*(sin(x)*cos(x)) [leafCount 12, conditions 0] trigonometric expansion: 2*sin(x)*cos(x) - 2*sin(x)*cos(x) [leafCount 15, conditions 0]
#cas [fullSimplify] (cos x ^ 2 - sin x ^ 2 - cos (2*x))
0Checked by Lean’s kernel: Identity with the trigonometric expansion and simplification
∀ (x : ℝ), Real.cos x ^ 2 - Real.sin x ^ 2 - Real.cos (2 * x) = 0
The certificate: 1 checked step
Identity with the trigonometric expansion and simplification
∀ (x : ℝ), Real.cos x ^ 2 - Real.sin x ^ 2 - Real.cos (2 * x) = 0
The computation
Ranked candidates (proposals, not proof)
trigonometric expansion and simplification: 0 [leafCount 1, conditions 0] configured simplification: 1 + -2*sin(x)^2 - cos(2*x) [leafCount 13, conditions 0] input: cos(x)^2 - sin(x)^2 - cos(2*x) [leafCount 14, conditions 0] exact passes: cos(x)^2 + -sin(x)^2 - cos(2*x) [leafCount 16, conditions 0] trigonometric expansion: cos(x)^2 - sin(x)^2 - (cos(x)^2 - sin(x)^2) [leafCount 19, conditions 0]
Possible Issues (3)
A multiple angle other than a double angle is not expanded, and the report proves the trivial identity :
#cas [trigExpand] (sin (3*x))
sin(3*x)Checked by Lean’s kernel: Identity with the input
∀ (x : ℝ), Real.sin (3 * x) = Real.sin (3 * x)
The certificate: 1 checked step
Identity with the input
∀ (x : ℝ), Real.sin (3 * x) = Real.sin (3 * x)
The computation
Ranked candidates (proposals, not proof)
input: sin(3*x) [leafCount 4, conditions 0]
The tactic cas proves the triple-angle formula:
example (x : ℝ) : Real.cos (3 * x) = 4 * Real.cos x ^ 3 - 3 * Real.cos x := by cas
Lean accepts the proof.
A false identity is refused. Here fails at , where the left side is and the right side is . The refusal proves nothing: the message says that the statement may be false or outside what cas supports:
example (x : ℝ) : Real.sin (2 * x) = 2 * Real.sin x := 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 (2 * x) = 2 * Real.sin x
⊢ False
[grind] Goal diagnostics
[facts] Asserted facts
[prop] ¬Real.sin (2 * x) = 2 * Real.sin x
[eqc] False propositions
[prop] Real.sin (2 * x) = 2 * Real.sin x
[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.nat 2).mul 𝕏[0]).sin.add ((CAS.Verified.Expr.int (-2)).mul 𝕏[0].sin)
canonical form route: the canonical rational form of the difference is not zero.
Canonical difference:
((CAS.Verified.Expr.int (-2)).mul 𝕏[0].sin).add ((CAS.Verified.Expr.nat 2).mul 𝕏[0]).sin
Elementary rewrite route:
after the elementary rewrites, neither the arithmetic script nor polynomial reasoning modulo sin² + cos² = 1 proved the goal:
linarith failed to find a contradiction
case h1
x : ℝ
a✝ : 2 * Real.sin x * Real.cos x < 2 * Real.sin x
⊢ False
failed
`grind` failed
case grind
x : ℝ
hcasPolynomialEquation : Real.sin x ^ 2 + Real.cos x ^ 2 = 1
h : ¬Real.sin x * Real.cos x = Real.sin x
⊢ False
[grind] Goal diagnostics
[facts] Asserted facts
[prop] Real.sin x ^ 2 + Real.cos x ^ 2 = 1
[prop] ¬Real.sin x * Real.cos x = Real.sin x
[eqc] False propositions
[prop] Real.sin x * Real.cos x = Real.sin x
[eqc] Equivalence classes
[eqc] {1,
Real.sin x ^ 2 + Real.cos x ^ 2,
(Real.sin x * Real.cos x - Real.sin x) * (Real.sin x * Real.cos x - Real.sin x)⁻¹}
[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.cos x ^ 3 * (Real.sin x * Real.cos x - Real.sin x)⁻¹ +
-1 * (Real.cos x ^ 2 * (Real.sin x * Real.cos x - Real.sin x)⁻¹) +
-1 * (Real.cos x * (Real.sin x * Real.cos x - Real.sin x)⁻¹) +
Real.sin x +
(Real.sin x * Real.cos x - Real.sin x)⁻¹ =
0
[_] Real.sin x * Real.cos x * (Real.sin x * Real.cos x - Real.sin x)⁻¹ +
-1 * (Real.sin x * (Real.sin x * Real.cos x - Real.sin x)⁻¹) +
-1 =
0
[_] Real.sin x ^ 2 + Real.cos x ^ 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)`
Grind fallback:
`grind` failed (`set_option trace.cas.fallback true` shows its diagnostics)See Also
expand · fullSimplify · simplify · cas
