Mode of #cas
product
A finite product in closed form, telescoped or in factorials, with a theorem for every upper bound.
#cas [product k a n] eproduct looks for a closed form of a finite product with a symbolic upper bound, and proves it for every by induction. The theorem is about Mathlib’s ∏ k ∈ Finset.Icc a n, and the factorials in the answer are Nat.factorial.
The factors it takes are a constant times powers of linear factors with integer shifts . When the exponents add up to zero, the product telescopes to a rational function of , and when every shift is nonnegative, it is a product of factorials.
Examples (14)#
Basic Examples (2)
A telescoping product, with the theorem for every :
#cas [product k 1 n] ((k + 1) / k)
closed form
(n + 1)- Domain
k ∈ [1, n]- Input (factor)
((k + 1) / k)
Checked by Lean’s kernel: Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, (↑k + 1) / ↑k = ↑n + 1
The certificate: 1 checked step
Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, (↑k + 1) / ↑k = ↑n + 1
The product of the first integers:
#cas [product k 1 n] (k)
closed form
n!- Domain
k ∈ [1, n]- Input (factor)
(k)
Checked by Lean’s kernel: Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, ↑k = ↑n.factorial
The certificate: 1 checked step
Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, ↑k = ↑n.factorial
Scope (6)
A constant times a linear factor:
#cas [product k 1 n] (2*k)
closed form
2^n*n!- Domain
k ∈ [1, n]- Input (factor)
(2*k)
Checked by Lean’s kernel: Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, 2 * ↑k = 2 ^ n * ↑n.factorial
The certificate: 1 checked step
Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, 2 * ↑k = 2 ^ n * ↑n.factorial
Two linear factors give two factorials:
#cas [product k 1 n] (k * (k + 1))
closed form
n!*(n + 1)!- Domain
k ∈ [1, n]- Input (factor)
(k * (k + 1))
Checked by Lean’s kernel: Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, ↑k * (↑k + 1) = ↑n.factorial * ↑(n + 1).factorial
The certificate: 1 checked step
Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, ↑k * (↑k + 1) = ↑n.factorial * ↑(n + 1).factorial
With a shift of 2, the telescoping product leaves two factors:
#cas [product k 1 n] ((k + 2) / k)
closed form
(n + 1)*(n + 2)/2- Domain
k ∈ [1, n]- Input (factor)
((k + 2) / k)
Checked by Lean’s kernel: Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, (↑k + 2) / ↑k = (↑n + 1) * (↑n + 2) / 2
The certificate: 1 checked step
Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, (↑k + 2) / ↑k = (↑n + 1) * (↑n + 2) / 2
A product from 2, the partial products of with the linear factors written out. The theorem holds for :
#cas [product k 2 n] ((k - 1)*(k + 1)/k^2)
closed form
(n + 1)/(2*n) for n ≥ 1- Domain
k ∈ [2, n]- Input (factor)
((k - 1)*(k + 1)/k^2)
Checked by Lean’s kernel: Closed form for every upper bound n ≥ 1
∀ (n : ℕ), 1 ≤ n → ∏ k ∈ Finset.Icc 2 n, (↑k - 1) * (↑k + 1) / ↑k ^ 2 = (↑n + 1) / (2 * ↑n)
The certificate: 1 checked step
Closed form for every upper bound n ≥ 1
∀ (n : ℕ), 1 ≤ n → ∏ k ∈ Finset.Icc 2 n, (↑k - 1) * (↑k + 1) / ↑k ^ 2 = (↑n + 1) / (2 * ↑n)
A constant factor. From 0 to there are of them:
#cas [product k 0 n] (3)
closed form
3*3^n- Domain
k ∈ [0, n]- Input (factor)
(3)
Checked by Lean’s kernel: Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 0 n, 3 = 3 * 3 ^ n
The certificate: 1 checked step
Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 0 n, 3 = 3 * 3 ^ n
Negative and fractional constants:
#cas [product k 1 n] (-2)
closed form
(-2)^n- Domain
k ∈ [1, n]- Input (factor)
(-2)
Checked by Lean’s kernel: Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, -2 = (-2) ^ n
The certificate: 1 checked step
Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, -2 = (-2) ^ n
#cas [product k 1 n] (2/3)
closed form
(2/3)^n- Domain
k ∈ [1, n]- Input (factor)
(2/3)
Checked by Lean’s kernel: Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, 2 / 3 = (2 / 3) ^ n
The certificate: 1 checked step
Closed form for every upper bound
∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, 2 / 3 = (2 / 3) ^ n
Applications (1)
The closed form in a proof. cas proves it by induction, and only the three standard axioms are used:
theorem product_telescoping : ∀ n : ℕ, ∏ k ∈ Finset.Icc 1 n, ((k : ℝ) + 1) / k = n + 1 := by cas #print axioms product_telescoping
product_telescoping depends on the axioms propext, Classical.choice, Quot.sound.
Properties and Relations (1)
Possible Issues (4)
A rational shift is refused, here , since the shifts must be integers:
#cas [product k 1 n] (2*k - 1)
Error
product: the factor is not a constant times powers of linear factors k + s with integer s; its product needs Gamma functions or Pochhammer symbols
A factor that vanishes in the range is refused, here the denominator at :
#cas [product k 0 n] (1 / k)
Error
product: the factor k vanishes in the range of the product
The upper bound must be a variable. For the value , the call factorial is the one to use:
#cas [product k 1 5] (k)
Error
product: the upper bound must be a variable
Only rational functions of :
#cas [product k 1 n] (sin k)
Error
product: the expression is not a rational function: it has a function other than the field operations and natural powers
