Möbius Inversion

lean4-proofnumber-theoryvisualization
f(n)=dnμ(d)g ⁣(nd)f(n) = \sum_{d \mid n} \mu(d)\, g\!\left(\frac{n}{d}\right)

Statement

The Möbius function μ:N{1,0,1}\mu : \mathbb{N} \to \{-1, 0, 1\} is defined by

μ(n)={1if n=1(1)kif n=p1p2pk is squarefree with k distinct primes0if n has a squared prime factor.\mu(n) = \begin{cases} 1 & \text{if } n = 1 \\ (-1)^k & \text{if } n = p_1 p_2 \cdots p_k \text{ is squarefree with } k \text{ distinct primes} \\ 0 & \text{if } n \text{ has a squared prime factor.} \end{cases}

Möbius Inversion Formula: If g(n)=dnf(d)g(n) = \sum_{d \mid n} f(d) for all nn, then

f(n)=dnμ(d)g ⁣(nd).f(n) = \sum_{d \mid n} \mu(d)\, g\!\left(\frac{n}{d}\right).

This is the statement that μ\mu is the Dirichlet-convolution inverse of the constant function 1\mathbf{1}:

μ1=ε,where ε(n)=[n=1].\mu * \mathbf{1} = \varepsilon, \qquad \text{where } \varepsilon(n) = [n = 1].

Visualization

Values of μ(n)\mu(n) for small nn:

n   Factorization     μ(n)
----+----------------+------
1   1                 1
2   2                -1
3   3                -1
4   2²                0   ← squared factor
5   5                -1
6   2·3               1   ← 2 prime factors, squarefree
7   7                -1
8   2³                0
9   3²                0
10  2·5               1
11  11               -1
12  2²·3              0
30  2·3·5            -1   ← 3 prime factors, squarefree

Inversion in action: Take f(n)=ϕ(n)f(n) = \phi(n) (Euler's totient). Then g(n)=dnϕ(d)=ng(n) = \sum_{d\mid n} \phi(d) = n (a classical identity). Möbius inversion recovers ϕ(n)=dnμ(d)(n/d)=npn(11/p)\phi(n) = \sum_{d \mid n} \mu(d) \cdot (n/d) = n \prod_{p \mid n}(1 - 1/p).

Proof Sketch

  1. Key identity: Show dnμ(d)=[n=1]\sum_{d \mid n} \mu(d) = [n = 1]. For n=1n = 1 this is trivial. For n>1n > 1, write n=p1a1pkakn = p_1^{a_1} \cdots p_k^{a_k}. The sum over divisors dd of nn with μ(d)0\mu(d) \neq 0 is just the sum over squarefree divisors, which equals j=0k(kj)(1)j=(11)k=0\sum_{j=0}^{k} \binom{k}{j}(-1)^j = (1-1)^k = 0.

  2. Substitution: Expand dnμ(d)g(n/d)=dnμ(d)e(n/d)f(e)\sum_{d \mid n} \mu(d)\, g(n/d) = \sum_{d \mid n} \mu(d) \sum_{e \mid (n/d)} f(e).

  3. Reindex: Switch the order: for each divisor ee of nn, collect all dd dividing n/en/e:

=enf(e)d(n/e)μ(d)=enf(e)[n/e=1]=f(n).= \sum_{e \mid n} f(e) \sum_{d \mid (n/e)} \mu(d) = \sum_{e \mid n} f(e) \cdot [n/e = 1] = f(n).
  1. Dirichlet series view: The generating Dirichlet series for 1\mathbf{1} is ζ(s)\zeta(s) and for μ\mu is 1/ζ(s)1/\zeta(s), so their product is 11, which is the Dirichlet series for ε\varepsilon.

Connections

Möbius inversion is the cornerstone of analytic and algebraic number theory. It immediately yields the formula for Euler's Totient ϕ(n)=npn(11/p)\phi(n) = n \prod_{p \mid n}(1 - 1/p). It underpins the Riemann zeta function and prime-counting via Λ(n)=dnμ(d)logd\Lambda(n) = -\sum_{d \mid n} \mu(d) \log d. The formula generalises to any locally finite partially ordered set (Rota's generalisation). The Möbius function is itself a multiplicative functionMultiplicative Functionsgcd(m,n)=1f(mn)=f(m)f(n)\gcd(m,n)=1 \Rightarrow f(mn)=f(m)f(n)Arithmetic functions that split over coprime inputs: f(mn) = f(m)f(n) when gcd(m,n) = 1Read more →, and the inversion formula preserves multiplicativity. See also Fundamental Theorem of ArithmeticFundamental Theorem of Arithmeticn=p1a1p2a2pkakn = p_1^{a_1} \cdot p_2^{a_2} \cdots p_k^{a_k}Every integer greater than 1 has a unique prime factorizationRead more → for the squarefree factorization structure.

Lean4 Proof

open ArithmeticFunction in
/-- The Möbius function is the Dirichlet-convolution inverse of the constant-1
    arithmetic function (the zeta function). In Mathlib this is stated as
    `moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1`. -/
theorem moebius_zeta_inverse :
    (ArithmeticFunction.moebius * ArithmeticFunction.zeta : ArithmeticFunction ) = 1 :=
  ArithmeticFunction.moebius_mul_coe_zeta