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] e
gives the product of e for k from the natural number a to the variable n in closed form, and proves it for every n≥a−1 by induction.

product looks for a closed form of a finite product with a symbolic upper bound, and proves it for every n≥a−1 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 k+s with integer shifts s. When the exponents add up to zero, the product telescopes to a rational function of n, and when every shift is nonnegative, it is a product of factorials.

Details and Options

  • For the printed closed form P, the theorem is ∀ n : ℕ, ∏ k ∈ Finset.Icc a n, e = P, and ∀ n : ℕ, a - 1 ≤ n → ∏ k ∈ Finset.Icc a n, e = P when a≥2. The product over an empty range is 1.
  • e is a rational function of k. Its linear factors must be written in the input, so (k - 1) * (k + 1) / k ^ 2 has a closed form and 1 - 1 / k ^ 2 is refused.
  • A factor that vanishes in the range is refused, and so are a rational shift such as 2*k - 1 and an irreducible factor of degree 2 or more: the factor must be a constant times powers of linear factors k+s with an integer s.
  • The upper bound must be a variable. There are no options.
  • In a proof, cas proves the closed form for every n.

Examples (14)#

Basic Examples (2)

A telescoping product, with the theorem for every n:

In[1]:=
#cas [product k 1 n] ((k + 1) / k)
Out[1]=

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
  1. Closed form for every upper bound

    ∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, (↑k + 1) / ↑k = ↑n + 1

    Checked by Lean’s kernel


The product of the first n integers:

In[2]:=
#cas [product k 1 n] (k)
Out[2]=

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
  1. Closed form for every upper bound

    ∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, ↑k = ↑n.factorial

    Checked by Lean’s kernel

Scope (6)

A constant times a linear factor:

In[3]:=
#cas [product k 1 n] (2*k)
Out[3]=

closed form

2nn!
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
  1. Closed form for every upper bound

    ∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, 2 * ↑k = 2 ^ n * ↑n.factorial

    Checked by Lean’s kernel


Two linear factors give two factorials:

In[4]:=
#cas [product k 1 n] (k * (k + 1))
Out[4]=

closed form

n!(n+1)!
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
  1. Closed form for every upper bound

    ∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, ↑k * (↑k + 1) = ↑n.factorial * ↑(n + 1).factorial

    Checked by Lean’s kernel


With a shift of 2, the telescoping product leaves two factors:

In[5]:=
#cas [product k 1 n] ((k + 2) / k)
Out[5]=

closed form

(n+1)(n+2)2
(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
  1. Closed form for every upper bound

    ∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, (↑k + 2) / ↑k = (↑n + 1) * (↑n + 2) / 2

    Checked by Lean’s kernel


A product from 2, the partial products of ∏k≥2(1−1/k2) with the linear factors written out. The theorem holds for n≥1:

In[6]:=
#cas [product k 2 n] ((k - 1)*(k + 1)/k^2)
Out[6]=

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
  1. 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)

    Checked by Lean’s kernel


A constant factor. From 0 to n there are n+1 of them:

In[7]:=
#cas [product k 0 n] (3)
Out[7]=

closed form

3·3n
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
  1. Closed form for every upper bound

    ∀ (n : ℕ), ∏ k ∈ Finset.Icc 0 n, 3 = 3 * 3 ^ n

    Checked by Lean’s kernel


Negative and fractional constants:

In[8]:=
#cas [product k 1 n] (-2)
Out[8]=

closed form

(−2)n
(-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
  1. Closed form for every upper bound

    ∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, -2 = (-2) ^ n

    Checked by Lean’s kernel

In[9]:=
#cas [product k 1 n] (2/3)
Out[9]=

closed form

(23)n
(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
  1. Closed form for every upper bound

    ∀ (n : ℕ), ∏ k ∈ Finset.Icc 1 n, 2 / 3 = (2 / 3) ^ n

    Checked by Lean’s kernel

Applications (1)

The closed form in a proof. cas proves it by induction, and only the three standard axioms are used:

In[10]:=
theorem product_telescoping : ∀ n : ℕ, ∏ k ∈ Finset.Icc 1 n, ((k : ℝ) + 1) / k = n + 1 := by
  cas

#print axioms product_telescoping
Out[10]=

product_telescoping depends on the axioms propext, Classical.choice, Quot.sound.

Properties and Relations (1)

The closed form n! at n=10 is the value of the call factorial:

In[11]:=
#cas (factorial 10)
Out[11]=

factorial

3628800
Domain
ℕ
Input (natural numbers)
10

Checked by Lean’s kernel: factorial

Nat.factorial 10 = 3628800
The certificate: 1 checked step
  1. factorial

    Nat.factorial 10 = 3628800

    Checked by Lean’s kernel

Possible Issues (4)

A rational shift is refused, here 2k−1=2(k−1/2), since the shifts must be integers:

In[12]:=
#cas [product k 1 n] (2*k - 1)
Out[12]=

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 k at k=0:

In[13]:=
#cas [product k 0 n] (1 / k)
Out[13]=

Error

product: the factor k vanishes in the range of the product

The upper bound must be a variable. For the value 5!, the call factorial is the one to use:

In[14]:=
#cas [product k 1 5] (k)
Out[14]=

Error

product: the upper bound must be a variable

Only rational functions of k:

In[15]:=
#cas [product k 1 n] (sin k)
Out[15]=

Error

product: the expression is not a rational function: it has a function other than the field operations and natural powers

See Also

sum · rsolve · factorial · factor · gamma