Function of #cas

divisorSigma

The sum σk(n) of the k-th powers of the divisors of n, with a theorem about Mathlib’s ArithmeticFunction.sigma.

#cas (divisorSigma k n)
gives the sum σk(n) of the k-th powers of the divisors of the positive natural number n and proves ArithmeticFunction.sigma k n = s.

divisorSigma computes the divisor functions: σ0(n) counts the divisors of n, and σ1(n) adds them up. The theorem is about Mathlib’s ArithmeticFunction.sigma. What I like about the proof is that the kernel checks the divisors with a counting certificate and no factorization at all, so how hard n is to factor never comes into it.

Details and Options

  • k and n are natural numbers, literals or closed integer expressions, with 1≤n<1012 and k<232, the exponents for which the kernel evaluates the powers dk of the certificate.
  • The theorem is ArithmeticFunction.sigma k n = s, by CAS.NumberTheory.sigma_eq_of_cert. The kernel checks the list of divisors of n with a counting certificate, ⌊n⌋ divisions and no factorization, and sums their k-th powers.
  • The value has at most 10000 digits, the most that a call computes.
  • divisors prints the list of divisors with the same certificate.
  • The call is evaluated when it is the whole input of #cas.
  • There are no options.

Examples (7)#

Basic Examples (1)

The sum of the divisors of 360. σ1 is multiplicative, and σ1(pe)=1+p+⋯+pe on a prime power, so the sum is σ1(23)σ1(32)σ1(5)=15·13·6=1170:

In[1]:=
#cas (divisorSigma 1 360)
Out[1]=

divisorSigma 1

1170
Domain
ℕ
Input (natural numbers)
360

Checked by Lean’s kernel: divisorSigma 1

(ArithmeticFunction.sigma 1) 360 = 1170
The certificate: 1 checked step
  1. divisorSigma 1

    (ArithmeticFunction.sigma 1) 360 = 1170

    Checked by Lean’s kernel

Scope (2)

With k=0 the call counts the divisors. 360=23·32·5 has 4·3·2=24 of them:

In[2]:=
#cas (divisorSigma 0 360)
Out[2]=

divisorSigma 0

24
Domain
ℕ
Input (natural numbers)
360

Checked by Lean’s kernel: divisorSigma 0

(ArithmeticFunction.sigma 0) 360 = 24
The certificate: 1 checked step
  1. divisorSigma 0

    (ArithmeticFunction.sigma 0) 360 = 24

    Checked by Lean’s kernel


The sum of the squares of the divisors of 12:

In[3]:=
#cas (divisorSigma 2 12)
Out[3]=

divisorSigma 2

210
Domain
ℕ
Input (natural numbers)
12

Checked by Lean’s kernel: divisorSigma 2

(ArithmeticFunction.sigma 2) 12 = 210
The certificate: 1 checked step
  1. divisorSigma 2

    (ArithmeticFunction.sigma 2) 12 = 210

    Checked by Lean’s kernel

Applications (1)

In a proof, cas proves the equation. Only the three standard axioms are used:

In[4]:=
theorem sigma_two_twelve : ArithmeticFunction.sigma 2 12 = 210 := by
  cas

#print axioms sigma_two_twelve
Out[4]=

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

Properties and Relations (1)

divisors lists the divisors of 12, and the sum of their squares is 1+4+9+16+36+144=210:

In[5]:=
#cas [divisors] 12
Out[5]=

divisors

[1, 2, 3, 4, 6, 12]
[1, 2, 3, 4, 6, 12]
Domain
ℕ
Input (natural numbers)
12

Checked by Lean’s kernel: divisors

Nat.divisors 12 = {1, 2, 3, 4, 6, 12}
The certificate: 1 checked step
  1. divisors

    Nat.divisors 12 = {1, 2, 3, 4, 6, 12}

    Checked by Lean’s kernel

Possible Issues (2)

Every natural number divides 0, and Mathlib sets ArithmeticFunction.sigma k 0 = 0. The call takes positive n only:

In[6]:=
#cas (divisorSigma 1 0)
Out[6]=

Error

divisorSigma: expected a positive natural number

The value has at most 10000 digits. The prime 999999937 has σ4000=1+9999999374000, with 36000 digits:

In[7]:=
#cas (divisorSigma 4000 999999937)
Out[7]=

Error

divisorSigma: the value has more than 10000 digits, the most that a call computes

See Also

divisors · eulerPhi · moebiusMu · factorInteger