AFTD Auto-Formalizing Theoretical Domains

factorization_mobius_simple_prime

theoremverifiedformalization

Theorem 1 of arXiv:2611.18194. Let n = mq where q is a prime not dividing m, and let x be a factorization of n (a multiset of integers greater than 1 with product n) with k factors. Let c_1, ..., c_s be the multiplicities in x of the distinct factors of x that are not divisible by q. Then μ(x, n) = (-1)^{k-1} (k-1)!/(c_1! ⋯ c_s!), the right side computed as a rational number, where μ(x, n) = factorizationMobiusToTop n x is the Möbius function of the poset of factorizations of n ordered by refinement (x ≤ y when y is a coarsening of x, IsFactorizationCoarsening x y), between x and the top element.

Statement

theorem factorization_mobius_simple_prime
    (m q : ℕ) (hq : q.Prime) (hqm : ¬ q ∣ m) (x : Multiset ℕ)
    (hx : IsNatFactorization (m * q) x) :
    (factorizationMobiusToTop (m * q) x : ℚ) =
      ((-1 : ℚ) ^ (x.card - 1) * ((x.card - 1).factorial : ℚ) /
        ∏ a ∈ (x.filter (fun a => ¬ q ∣ a)).toFinset,
          (((x.filter (fun a => ¬ q ∣ a)).count a).factorial : ℚ))
Formalizes
arXiv:2611.18194 (The Möbius function of factorizations with a simple prime factor), Theorem 1 (first formula)
Verified
17 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 9
Used by 1

Read back from the Lean

For all natural numbers $m$ and $q$ such that $q$ is prime and $q$ does not divide $m$, and for every multiset of natural numbers $x$ such that $x$ is a natural factorization of $m \cdot q$ (IsNatFactorization (m * q) x), the value of factorizationMobiusToTop (m * q) x (coerced to $\mathbb{Q}$) equals: $$\frac{(-1)^{|x| - 1} (|x| - 1)!}{\prod_{a \in S} ((\operatorname{count}(a, x'))!)},$$ where $x'$ is the submultiset of elements in $x$ not divisible by $q$ (i.e., x.filter (fun a => ¬ q ∣ a)), $S$ is the finset of distinct elements in $x'$ (x'.toFinset), and the factorials and powers are evaluated in $\mathbb{Q}$.

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

The theorem is proved by strong induction on the number of factors k = |x| of the factorization x. When k = 1, x is the trivial factorization {mq}, for which both the Möbius function and the formula evaluate to 1. For k ≥ 2, the Möbius function is defined recursively as the negative sum of itself over all strictly coarser factorizations y (which have |y| < |x|), allowing the induction hypothesis to replace each term with the candidate weight fw(q, y). The proof then hinges on the identity `factorization_coarsening_signed_orderings_sum_zero`, which establishes that the sum of fw(q, y) over all coarsenings y of x (including x itself) is zero, so fw(q, x) equals the negative sum over the proper coarsenings and thus matches the Möbius value.

  1. The product of any non-empty multiset of integers strictly greater than 1 is strictly greater than 1.

    We argue by induction on the multiset g. The base case g = ∅ is ruled out by the hypothesis g ≠ 0. In the inductive step g = a :: g', the prepended element a satisfies a > 1 and every element of g' is at least 2, so the product of g' is strictly positive. Since a > 1 and ∏ g' > 0, nonlinear arithmetic shows that a * ∏ g' > 1.

    lines 9–16

    uses Multiset.induction_on, Multiset.prod_cons, Multiset.mem_cons_self, Multiset.prod_pos, Multiset.mem_cons_of_mem

      induction g using Multiset.induction_on with
      | empty => exact absurd rfl hg
      | cons a g ih =>
        rw [Multiset.prod_cons]
        have ha := h a (Multiset.mem_cons_self a g)
        have hp : 0 < g.prod := Multiset.prod_pos (fun b hb => by
          have := h b (Multiset.mem_cons_of_mem hb); omega)
        nlinarith
  2. Any coarsening of a valid factorization of n into integers strictly greater than 1 is also a valid factorization of n.

    By definition, a coarsening y of x is obtained by partitioning x into a multiset G of non-empty sub-multisets and replacing each block g ∈ G by its product. Since every element of each block g belongs to x and is therefore > 1, the lemma `one_lt_prod_of` ensures that each block product is > 1. Furthermore, the product of the block products equals the product of all elements in the joined partition, which is x.prod = n.

    lines 20–27

    uses Multiset.mem_map, one_lt_prod_of, Multiset.prod_join

      obtain ⟨G, hG0, hJ, hM⟩ := h
      refine ⟨?_, ?_⟩
      · intro b hb
        rw [← hM, Multiset.mem_map] at hb
        obtain ⟨g, hg, rfl⟩ := hb
        refine one_lt_prod_of (hG0 g hg) (fun a ha => hx.1 a ?_)
        rw [← hJ]; exact Multiset.mem_join.2 ⟨g, hg, ha⟩
      · rw [← hM, ← Multiset.prod_join, hJ]; exact hx.2
  3. To prove the formula for the Möbius function, it suffices to proceed by strong induction on the number of factors k = |x| and branch on whether |x| ≤ 1.

    We induct strongly on the cardinality k = |x|. Unfolding the recursive definition of `factorizationMobiusToTop`, we split cases on whether |x| ≤ 1. When |x| ≤ 1, the Möbius function is defined to be 1; when |x| > 1, it is defined as the negative sum of the Möbius function over all proper coarsenings y of x.

    lines 32–35

    uses Nat.strong_induction_on, factorizationMobiusToTop

      induction hk : x.card using Nat.strong_induction_on generalizing x with
      | _ k ih =>
      rw [factorizationMobiusToTop]
      split_ifs with h1
  4. In the base case |x| ≤ 1, x must be the single-factor multiset {mq}, and both the Möbius function and the formula fw(q, x) evaluate to 1.

    The factorization x cannot be empty because its product is mq ≥ 2 (since q is prime), whereas the empty product is 1. Thus |x| = 1, so x = {a} for some integer a, which must equal mq to have product mq. By definition, factorizationMobiusToTop evaluates to 1 on any factorization of length 1. In fw(q, {mq}), the numerator is (-1)^0 * 0! = 1. Since q divides mq, the filter keeping factors not divisible by q is empty, so the denominator is an empty product, which is 1. Thus fw(q, {mq}) = 1.

    lines 36–49

    uses Multiset.prod_zero, Nat.eq_one_of_mul_eq_one_left, Multiset.filter_singleton, dvd_mul_left

      · have hx0 : x ≠ 0 := by
          rintro rfl
          have h2 := hx.2
          simp only [Multiset.prod_zero] at h2
          have := hq.two_le
          have : m * q ≠ 1 := by
            intro h; have := Nat.eq_one_of_mul_eq_one_left h; omega
          exact this h2.symm
        obtain ⟨a, rfl⟩ : ∃ a, x = {a} :=
          Multiset.card_eq_one.1 (by have := Multiset.card_pos.2 hx0; omega)
        have ha : a = m * q := by simpa using hx.2
        subst ha
        unfold fw
        simp [Multiset.filter_singleton, dvd_mul_left]
  5. For |x| ≥ 2, q^2 does not divide x.prod = mq, the set of coarsenings of x is finite, and the sum of fw(q, y) over all coarsenings y of x vanishes.

    Because x has product mq and q does not divide m, q^2 cannot divide mq (cancelling q would imply q divides m). Since any coarsening of x is a valid factorization of mq by `coars_fact`, and the set of all natural factorizations of mq is finite by `setOf_isNatFactorization_finite`, the set of coarsenings of x is finite. Applying the theorem `factorization_coarsening_signed_orderings_sum_zero` with prime q, factors > 1, q ∣ mq, q^2 ∤ mq, and |x| ≥ 2 yields that the sum of fw(q, y) over all coarsenings y of x is 0. We convert this sum to a sum over the finite set of coarsenings.

    lines 50–62

    uses pow_two, Nat.dvd_of_mul_dvd_mul_right, setOf_isNatFactorization_finite, coars_fact, factorization_coarsening_signed_orderings_sum_zero, dvd_mul_left, finsum_mem_eq_finite_toFinset_sum

      · have hsq : ¬ q ^ 2 ∣ x.prod := by
          rw [hx.2, pow_two]
          intro h
          exact hqm (Nat.dvd_of_mul_dvd_mul_right hq.pos h)
        have hfinS : {y : Multiset ℕ | IsNatFactorization (m * q) y ∧ IsFactorizationCoarsening x y ∧
            y.card < x.card}.Finite :=
          (setOf_isNatFactorization_finite _).subset (fun y hy => hy.1)
        have hfinC : {y : Multiset ℕ | IsFactorizationCoarsening x y}.Finite :=
          (setOf_isNatFactorization_finite (m * q)).subset (fun y hy => coars_fact hx hy)
        have h5 := factorization_coarsening_signed_orderings_sum_zero q hq x hx.1
          (by rw [hx.2]; exact dvd_mul_left q m) hsq (by omega)
        change ∑ᶠ y ∈ {y : Multiset ℕ | IsFactorizationCoarsening x y}, fw q y = 0 at h5
        rw [finsum_mem_eq_finite_toFinset_sum _ hfinC] at h5
  6. The set of all coarsenings of x partitions into {x} and the proper coarsenings y (those with |y| < |x|), yielding fw(q, x) + ∑_{|y| < |x|} fw(q, y) = 0.

    Every coarsening y of x is either equal to x or different from x. By `isFactorizationCoarsening_card_lt_iff_ne`, a coarsening satisfies y ≠ x if and only if |y| < |x|. Since |x| < |x| is impossible by irreflexivity of <, x itself is not among the proper coarsenings. Decomposing the finset of all coarsenings into x and the proper coarsenings, `Finset.sum_insert` splits the vanishing sum into fw(q, x) plus the sum over all proper coarsenings.

    lines 63–77

    uses Set.Finite.mem_toFinset, Finset.mem_insert, Set.mem_ofPred_eq, Or.inl, Or.inr, coars_fact, isFactorizationCoarsening_card_lt_iff_ne, isFactorizationCoarsening_refl, lt_irrefl, Finset.sum_insert

        have hC : hfinC.toFinset = insert x hfinS.toFinset := by
          ext y
          simp only [Set.Finite.mem_toFinset, Finset.mem_insert, Set.mem_ofPred_eq]
          constructor
          · intro hy
            by_cases hyx : y = x
            · exact Or.inl hyx
            · exact Or.inr ⟨coars_fact hx hy, hy, (isFactorizationCoarsening_card_lt_iff_ne hy).2 hyx⟩
          · rintro (rfl | hy)
            · exact isFactorizationCoarsening_refl _
            · exact hy.2.1
        have hxS : x ∉ hfinS.toFinset := by
          simp only [Set.Finite.mem_toFinset, Set.mem_ofPred_eq]
          intro h; exact lt_irrefl _ h.2.2
        rw [hC, Finset.sum_insert hxS] at h5
  7. Applying the induction hypothesis to all proper coarsenings shows that factorizationMobiusToTop(mq, x) = fw(q, x).

    By definition, when |x| ≥ 2, the Möbius function is the negative sum of factorizationMobiusToTop(mq, y) over all proper coarsenings y with |y| < |x|. For each such proper coarsening y, the induction hypothesis applies because |y| < |x|, giving factorizationMobiusToTop(mq, y) = fw(q, y). Substituting this equality into the sum and combining it with the identity fw(q, x) + ∑_{|y| < |x|} fw(q, y) = 0, linear arithmetic over ℚ concludes that factorizationMobiusToTop(mq, x) = fw(q, x).

    lines 78–85

    uses finsum_mem_eq_finite_toFinset_sum, Finset.sum_congr, Set.Finite.mem_toFinset

        change ((-∑ᶠ y ∈ {y : Multiset ℕ | IsNatFactorization (m * q) y ∧ IsFactorizationCoarsening x y ∧
            y.card < x.card}, factorizationMobiusToTop (m * q) y : ℤ) : ℚ) = fw q x
        rw [finsum_mem_eq_finite_toFinset_sum _ hfinS]
        push_cast
        rw [Finset.sum_congr rfl (fun y hy => by
          have hy' := (Set.Finite.mem_toFinset _).1 hy
          exact ih y.card (hk ▸ hy'.2.2) y hy'.1 rfl)]
        linarith
  8. Theorem 1 (factorization_mobius_simple_prime) holds for any natural factorization x of mq.

    The statement of `factorization_mobius_simple_prime` is identical to `FactMobT1.thm1` with the definition of `fw` expanded; invoking `FactMobT1.thm1` completes the proof.

    line 96

    uses FactMobT1.thm1

      exact FactMobT1.thm1 m q hq hqm x hx
Multiset.induction_on
Multiset induction: to prove a property for all multisets, it suffices to prove it for the empty multiset and show that it is preserved upon prepending an element.
Multiset.prod_cons
The product of a multiset with an element prepended is that element times the product of the multiset.
Multiset.mem_cons_self
An element belongs to the multiset obtained by prepending it to any multiset.
Multiset.prod_pos
If every element in a multiset is strictly positive, then their product is strictly positive.
Multiset.mem_cons_of_mem
An element belonging to a multiset also belongs to the multiset with an additional element prepended.
Multiset.mem_map
An element belongs to the multiset image under a function if and only if it is the image of some element in the domain multiset.
one_lt_prod_of
The product of any non-empty multiset of natural numbers strictly greater than 1 is strictly greater than 1.
Multiset.prod_join
The product of the joined (flattened) multiset of multisets equals the product of the products of each constituent multiset.
Nat.strong_induction_on
Strong mathematical induction on natural numbers: if a property holding for all strictly smaller numbers implies it holds for n, then it holds for all n.
factorizationMobiusToTop
The Möbius function between a factorization and the top element of the coarsening poset, defined recursively as 1 for factorizations of length at most 1, and as the negative sum over all strictly coarser factorizations otherwise.
Multiset.prod_zero
The product of the empty multiset is 1.
Nat.eq_one_of_mul_eq_one_left
If the product of two natural numbers is 1, then the right factor is 1.
Multiset.filter_singleton
Filtering a singleton multiset by a predicate yields the singleton if the element satisfies the predicate, and the empty multiset otherwise.
dvd_mul_left
A number divides any product in which it appears as a factor.
pow_two
The square of an element equals the element multiplied by itself.
Nat.dvd_of_mul_dvd_mul_right
If mk divides nk for positive k, then m divides n.
setOf_isNatFactorization_finite
The set of all natural factorizations of a fixed integer n into factors strictly greater than 1 is finite.
coars_fact
Any coarsening of a natural factorization of n into factors strictly greater than 1 is also a natural factorization of n.
factorization_coarsening_signed_orderings_sum_zero
If q is a prime dividing the product of a multiset W of integers strictly greater than 1, q^2 does not divide the product, and W has at least 2 elements, then the sum of fw(q, y) over all coarsenings y of W is zero.
finsum_mem_eq_finite_toFinset_sum
A sum over a finite set defined using `finsum` is equal to the finite sum over its corresponding `Finset`.
Set.Finite.mem_toFinset
An element belongs to the Finset of a finite set if and only if it belongs to the set.
Finset.mem_insert
An element belongs to the insertion of b into a finite set s if and only if it equals b or belongs to s.
Set.mem_ofPred_eq
Membership of x in a set comprehension {y | p y} is equivalent to p x.
Or.inl
Left disjunction introduction: if a holds, then a ∨ b holds.
Or.inr
Right disjunction introduction: if b holds, then a ∨ b holds.
isFactorizationCoarsening_card_lt_iff_ne
A coarsening of a factorization has strictly fewer factors if and only if it is not equal to the original factorization.
isFactorizationCoarsening_refl
Coarsening of factorizations is reflexive: every factorization is a coarsening of itself.
lt_irrefl
Strict inequality on a preorder is irreflexive: no element is strictly less than itself.
Finset.sum_insert
If an element is not in a finite set, summing over inserting it equals the value at that element plus the sum over the original set.
Finset.sum_congr
Two finite sums are equal if their index sets are equal and their summands agree on every element of the index set.
FactMobT1.thm1
For n = mq with q prime and q not dividing m, the Möbius function to the top element for any factorization x of n equals fw(q, x).

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

namespace FactMobT1noncomputable def fw (q : ℕ) (y : Multiset ℕ) : ℚ :=  (-1 : ℚ) ^ (y.card - 1) * ((y.card - 1).factorial : ℚ) /    ∏ a ∈ (y.filter (fun a => ¬ q ∣ a)).toFinset,      (((y.filter (fun a => ¬ q ∣ a)).count a).factorial : ℚ)lemma one_lt_prod_of {g : Multiset ℕ} (hg : g ≠ 0) (h : ∀ a ∈ g, 1 < a) : 1 < g.prod := by  induction g using Multiset.induction_on with  | empty => exact absurd rfl hg  | cons a g ih =>    rw [Multiset.prod_cons]    have ha := h a (Multiset.mem_cons_self a g)    have hp : 0 < g.prod := Multiset.prod_pos (fun b hb => by      have := h b (Multiset.mem_cons_of_mem hb); omega)    nlinarithlemma coars_fact {n : ℕ} {x y : Multiset ℕ} (hx : IsNatFactorization n x)    (h : IsFactorizationCoarsening x y) : IsNatFactorization n y := by  obtain ⟨G, hG0, hJ, hM⟩ := h  refine ⟨?_, ?_⟩  · intro b hb    rw [← hM, Multiset.mem_map] at hb    obtain ⟨g, hg, rfl⟩ := hb    refine one_lt_prod_of (hG0 g hg) (fun a ha => hx.1 a ?_)    rw [← hJ]; exact Multiset.mem_join.2 ⟨g, hg, ha⟩  · rw [← hM, ← Multiset.prod_join, hJ]; exact hx.2theorem thm1 (m q : ℕ) (hq : q.Prime) (hqm : ¬ q ∣ m) (x : Multiset ℕ)    (hx : IsNatFactorization (m * q) x) :    (factorizationMobiusToTop (m * q) x : ℚ) = fw q x := by  induction hk : x.card using Nat.strong_induction_on generalizing x with  | _ k ih =>  rw [factorizationMobiusToTop]  split_ifs with h1  · have hx0 : x ≠ 0 := by      rintro rfl      have h2 := hx.2      simp only [Multiset.prod_zero] at h2      have := hq.two_le      have : m * q ≠ 1 := by        intro h; have := Nat.eq_one_of_mul_eq_one_left h; omega      exact this h2.symm    obtain ⟨a, rfl⟩ : ∃ a, x = {a} :=      Multiset.card_eq_one.1 (by have := Multiset.card_pos.2 hx0; omega)    have ha : a = m * q := by simpa using hx.2    subst ha    unfold fw    simp [Multiset.filter_singleton, dvd_mul_left]  · have hsq : ¬ q ^ 2 ∣ x.prod := by      rw [hx.2, pow_two]      intro h      exact hqm (Nat.dvd_of_mul_dvd_mul_right hq.pos h)    have hfinS : {y : Multiset ℕ | IsNatFactorization (m * q) y ∧ IsFactorizationCoarsening x y ∧        y.card < x.card}.Finite :=      (setOf_isNatFactorization_finite _).subset (fun y hy => hy.1)    have hfinC : {y : Multiset ℕ | IsFactorizationCoarsening x y}.Finite :=      (setOf_isNatFactorization_finite (m * q)).subset (fun y hy => coars_fact hx hy)    have h5 := factorization_coarsening_signed_orderings_sum_zero q hq x hx.1      (by rw [hx.2]; exact dvd_mul_left q m) hsq (by omega)    change ∑ᶠ y ∈ {y : Multiset ℕ | IsFactorizationCoarsening x y}, fw q y = 0 at h5    rw [finsum_mem_eq_finite_toFinset_sum _ hfinC] at h5    have hC : hfinC.toFinset = insert x hfinS.toFinset := by      ext y      simp only [Set.Finite.mem_toFinset, Finset.mem_insert, Set.mem_ofPred_eq]      constructor      · intro hy        by_cases hyx : y = x        · exact Or.inl hyx        · exact Or.inr ⟨coars_fact hx hy, hy, (isFactorizationCoarsening_card_lt_iff_ne hy).2 hyx⟩      · rintro (rfl | hy)        · exact isFactorizationCoarsening_refl _        · exact hy.2.1    have hxS : x ∉ hfinS.toFinset := by      simp only [Set.Finite.mem_toFinset, Set.mem_ofPred_eq]      intro h; exact lt_irrefl _ h.2.2    rw [hC, Finset.sum_insert hxS] at h5    change ((-∑ᶠ y ∈ {y : Multiset ℕ | IsNatFactorization (m * q) y ∧ IsFactorizationCoarsening x y ∧        y.card < x.card}, factorizationMobiusToTop (m * q) y : ℤ) : ℚ) = fw q x    rw [finsum_mem_eq_finite_toFinset_sum _ hfinS]    push_cast    rw [Finset.sum_congr rfl (fun y hy => by      have hy' := (Set.Finite.mem_toFinset _).1 hy      exact ih y.card (hk ▸ hy'.2.2) y hy'.1 rfl)]    linarithend FactMobT1theorem factorization_mobius_simple_prime    (m q : ℕ) (hq : q.Prime) (hqm : ¬ q ∣ m) (x : Multiset ℕ)    (hx : IsNatFactorization (m * q) x) :    (factorizationMobiusToTop (m * q) x : ℚ) =      ((-1 : ℚ) ^ (x.card - 1) * ((x.card - 1).factorial : ℚ) /        ∏ a ∈ (x.filter (fun a => ¬ q ∣ a)).toFinset,          (((x.filter (fun a => ¬ q ∣ a)).count a).factorial : ℚ)) := by  exact FactMobT1.thm1 m q hq hqm x hx
See it in the graphDiscuss this resultChallenge it