Function of #cas
divisorSigma
The sum of the -th powers of the divisors of , with a theorem about Mathlib’s ArithmeticFunction.sigma.
#cas (divisorSigma k n)ArithmeticFunction.sigma k n = s.divisorSigma computes the divisor functions: counts the divisors of , and 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 is to factor never comes into it.
Examples (7)#
Basic Examples (1)
The sum of the divisors of 360. is multiplicative, and on a prime power, so the sum is :
#cas (divisorSigma 1 360)
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
divisorSigma 1
(ArithmeticFunction.sigma 1) 360 = 1170
Scope (2)
With the call counts the divisors. has of them:
#cas (divisorSigma 0 360)
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
divisorSigma 0
(ArithmeticFunction.sigma 0) 360 = 24
The sum of the squares of the divisors of 12:
#cas (divisorSigma 2 12)
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
divisorSigma 2
(ArithmeticFunction.sigma 2) 12 = 210
Applications (1)
Properties and Relations (1)
divisors lists the divisors of 12, and the sum of their squares is :
#cas [divisors] 12
divisors
[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
divisors
Nat.divisors 12 = {1, 2, 3, 4, 6, 12}
Possible Issues (2)
Every natural number divides 0, and Mathlib sets ArithmeticFunction.sigma k 0 = 0. The call takes positive only:
#cas (divisorSigma 1 0)
Error
divisorSigma: expected a positive natural number
The value has at most 10000 digits. The prime 999999937 has , with 36000 digits:
#cas (divisorSigma 4000 999999937)
Error
divisorSigma: the value has more than 10000 digits, the most that a call computes
