Mode of #cas
together
Writes a rational expression as one fraction in lowest terms, with the conditions under which they agree.
#cas [together] etogether puts a sum of fractions over one denominator, the way you would by hand. The answer comes with a theorem, and the conditions of the theorem come from the divisors of the input.
On paper we rarely write those conditions down, but Lean needs them, because its division is total: . At the sum is in Lean, while is . So the identity needs and , and the theorem has them as hypotheses.
Examples (13)#
Basic Examples (2)
Two reciprocals:
#cas [together] (1/x + 1/y)
common denominator
(x + y)/(x*y)- Input (rational function)
(1/x + 1/y)- Conditions
- ,
Checked by Lean’s kernel: Identity with the common-denominator form
∀ (x y : ℝ), x ≠ 0 → y ≠ 0 → 1 / x + 1 / y = (x + y) / (x * y)
The certificate: 1 checked step
Identity with the common-denominator form
∀ (x y : ℝ), x ≠ 0 → y ≠ 0 → 1 / x + 1 / y = (x + y) / (x * y)
The denominator stays factored as the input factors it, and each divisor gives a condition:
#cas [together] (1/(x^2-1) + 1/(x-1))
common denominator
(x + 2)/((x - 1)*(x + 1))- Input (rational function)
(1/(x^2-1) + 1/(x-1))- Conditions
- ,
Checked by Lean’s kernel: Identity with the common-denominator form
∀ (x : ℝ), x ^ 2 - 1 ≠ 0 → x - 1 ≠ 0 → 1 / (x ^ 2 - 1) + 1 / (x - 1) = (x + 2) / ((x - 1) * (x + 1))
The certificate: 1 checked step
Identity with the common-denominator form
∀ (x : ℝ), x ^ 2 - 1 ≠ 0 → x - 1 ≠ 0 → 1 / (x ^ 2 - 1) + 1 / (x - 1) = (x + 2) / ((x - 1) * (x + 1))
Scope (2)
Numbers as divisors need no condition:
#cas [together] (x/2 + y/3)
common denominator
(3*x + 2*y)/6- Input (rational function)
(x/2 + y/3)
Checked by Lean’s kernel: Identity with the common-denominator form
∀ (x y : ℝ), x / 2 + y / 3 = (3 * x + 2 * y) / 6
The certificate: 1 checked step
Identity with the common-denominator form
∀ (x y : ℝ), x / 2 + y / 3 = (3 * x + 2 * y) / 6
The fraction is in lowest terms. Here the common factor cancels, and the condition is still the divisor of the input:
#cas [together] ((x^3 - y^3)/(x^2 - y^2))
common denominator
(x^2 + x*y + y^2)/(x + y)- Input (rational function)
((x^3 - y^3)/(x^2 - y^2))- Conditions
Checked by Lean’s kernel: Identity with the common-denominator form
∀ (x y : ℝ), x ^ 2 - y ^ 2 ≠ 0 → (x ^ 3 - y ^ 3) / (x ^ 2 - y ^ 2) = (x ^ 2 + x * y + y ^ 2) / (x + y)
The certificate: 1 checked step
Identity with the common-denominator form
∀ (x y : ℝ), x ^ 2 - y ^ 2 ≠ 0 → (x ^ 3 - y ^ 3) / (x ^ 2 - y ^ 2) = (x ^ 2 + x * y + y ^ 2) / (x + y)
Applications (2)
The first example as a theorem, with the conditions as hypotheses. Only the three standard axioms are used:
theorem reciprocals_together (x y : ℝ) (hx : x ≠ 0) (hy : y ≠ 0) : 1 / x + 1 / y = (x + y) / (x * y) := by cas #print axioms reciprocals_together
reciprocals_together depends on the axioms propext, Classical.choice, Quot.sound.
Without the conditions the identity is false in Lean. At and the left side is and the right side is :
example : ¬ ∀ x y : ℝ, 1 / x + 1 / y = (x + y) / (x * y) := by intro h have := h 0 1 norm_num at this
Lean accepts the proof.
Properties and Relations (4)
numerator gives the numerator of the first example:
#cas [numerator] (1/x + 1/y)
numerator
x + y- Input (rational function)
(1/x + 1/y)- Conditions
- ,
Checked by Lean’s kernel: Identity with the common-denominator form
∀ (x y : ℝ), x ≠ 0 → y ≠ 0 → 1 / x + 1 / y = (x + y) / (x * y)
The certificate: 1 checked step
Identity with the common-denominator form
∀ (x y : ℝ), x ≠ 0 → y ≠ 0 → 1 / x + 1 / y = (x + y) / (x * y)
denominator gives the of :
#cas [denominator] (x/2 + y/3)
denominator
6- Input (rational function)
(x/2 + y/3)
Checked by Lean’s kernel: Identity with the common-denominator form
∀ (x y : ℝ), x / 2 + y / 3 = (3 * x + 2 * y) / 6
The certificate: 1 checked step
Identity with the common-denominator form
∀ (x y : ℝ), x / 2 + y / 3 = (3 * x + 2 * y) / 6
cancel cancels inside each summand and keeps the sum:
#cas [cancel] ((x^2-1)/(x-1) + 1/x)
cancelled
x + 1 + 1/x- Input (rational function)
((x^2-1)/(x-1) + 1/x)- Conditions
- ,
Checked by Lean’s kernel: Identity with the cancelled form
∀ (x : ℝ), x - 1 ≠ 0 → x ≠ 0 → (x ^ 2 - 1) / (x - 1) + 1 / x = x + 1 + 1 / x
The certificate: 1 checked step
Identity with the cancelled form
∀ (x : ℝ), x - 1 ≠ 0 → x ≠ 0 → (x ^ 2 - 1) / (x - 1) + 1 / x = x + 1 + 1 / x
apart splits one fraction into partial fractions:
#cas [apart] (1/((x - 1)*(x + 1)))
partial fractions
1/(2*(x - 1)) - 1/(2*(x + 1))- Input (rational function)
(1/((x - 1)*(x + 1)))- Conditions
Checked by Lean’s kernel: Identity with the partial fraction decomposition
∀ (x : ℝ), (x - 1) * (x + 1) ≠ 0 → 1 / ((x - 1) * (x + 1)) = 1 / (2 * (x - 1)) - 1 / (2 * (x + 1))
The certificate: 1 checked step
Identity with the partial fraction decomposition
∀ (x : ℝ), (x - 1) * (x + 1) ≠ 0 → 1 / ((x - 1) * (x + 1)) = 1 / (2 * (x - 1)) - 1 / (2 * (x + 1))
Possible Issues (3)
The conditions are the divisors as written. Here is , and the condition keeps the form of the input:
#cas [together] (1/((x*y + x - x)^2) + 1)
common denominator
(x^2*y^2 + 1)/(x^2*y^2)- Input (rational function)
(1/((x*y + x - x)^2) + 1)- Conditions
Checked by Lean’s kernel: Identity with the common-denominator form
∀ (x y : ℝ), (x * y + x - x) ^ 2 ≠ 0 → 1 / (x * y + x - x) ^ 2 + 1 = (x ^ 2 * y ^ 2 + 1) / (x ^ 2 * y ^ 2)
The certificate: 1 checked step
Identity with the common-denominator form
∀ (x y : ℝ), (x * y + x - x) ^ 2 ≠ 0 → 1 / (x * y + x - x) ^ 2 + 1 = (x ^ 2 * y ^ 2 + 1) / (x ^ 2 * y ^ 2)
A divisor must be a polynomial. Multiply the inner fraction out first. For the expression is :
#cas [together] (1/(1 + 1/x))
Error
together: a divisor is itself a quotient; write the expression with polynomial divisors
Functions other than the field operations are refused. simplify and fullSimplify accept them:
#cas [together] (sin x / x)
Error
together: the expression is not a rational function: it has a function other than the field operations and natural powers
See Also
cancel · numerator · denominator · apart · simplify
