|
| 1 | +/- |
| 2 | +Copyright (c) 2026 Thomas Browning. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Thomas Browning |
| 5 | +-/ |
| 6 | +module |
| 7 | + |
| 8 | +public import Mathlib.NumberTheory.ArithmeticFunction.Moebius |
| 9 | +public import Mathlib.RingTheory.UniqueFactorizationDomain.Basic |
| 10 | + |
| 11 | +/-! |
| 12 | +# The Moebius function on a unique factorization monoid |
| 13 | +
|
| 14 | +We define the Moebius function on a unique factorization monoid. |
| 15 | +
|
| 16 | +## Main definitions |
| 17 | +
|
| 18 | +* `UniqueFactorizationMonoid.moebius`: The Moebius function on a unique factorization monoid, |
| 19 | + defined to be `((-1) ^ (factors a).card)` if `a` is squarefree and `0` otherwise. |
| 20 | +
|
| 21 | +## Main statements |
| 22 | +
|
| 23 | +* `IsRelPrime.moebius_mul`: The Moebius function is a multiplicative function. |
| 24 | +-/ |
| 25 | + |
| 26 | +@[expose] public section |
| 27 | + |
| 28 | +namespace UniqueFactorizationMonoid |
| 29 | + |
| 30 | +variable {α : Type*} [CommMonoidWithZero α] [UniqueFactorizationMonoid α] {a b : α} |
| 31 | + |
| 32 | +/-- The Moebius function on a unique factorization monoid, defined to be |
| 33 | + `((-1) ^ (factors a).card)` if `a` is squarefree and `0` otherwise. -/ |
| 34 | +noncomputable def moebius (a : α) : ℤ := |
| 35 | + open Classical in |
| 36 | + if Squarefree a then ((-1) ^ (factors a).card) else 0 |
| 37 | + |
| 38 | +-- Todo: prove `Int.moebius_eq` as well. |
| 39 | +theorem _root_.Nat.moebius_eq (n : ℕ) : moebius n = ArithmeticFunction.moebius n := by |
| 40 | + rw [moebius] |
| 41 | + congr |
| 42 | + simp [Nat.factors_eq, ArithmeticFunction.cardFactors_apply] |
| 43 | + |
| 44 | +@[simp] |
| 45 | +theorem _root_.Squarefree.moebius_eq (ha : Squarefree a) : moebius a = (-1) ^ (factors a).card := |
| 46 | + if_pos ha |
| 47 | + |
| 48 | +@[simp] |
| 49 | +theorem moebius_of_not_squarefree (ha : ¬ Squarefree a) : moebius a = 0 := |
| 50 | + if_neg ha |
| 51 | + |
| 52 | +theorem moebius_zero [Nontrivial α] : moebius (0 : α) = 0 := by |
| 53 | + simp |
| 54 | + |
| 55 | +theorem moebius_one : moebius (1 : α) = 1 := by |
| 56 | + simp |
| 57 | + |
| 58 | +theorem _root_.Associated.moebius_eq (h : Associated a b) : moebius a = moebius b := by |
| 59 | + rw [moebius, moebius, h.squarefree_iff, h.card_factors_eq] |
| 60 | + |
| 61 | +theorem _root_.IsUnit.moebius_eq (ha : IsUnit a) : moebius a = 1 := by |
| 62 | + rw [(associated_one_iff_isUnit.mpr ha).moebius_eq, moebius_one] |
| 63 | + |
| 64 | +theorem _root_.Irreducible.moebius_eq (ha : Irreducible a) : moebius a = -1 := by |
| 65 | + rw [ha.squarefree.moebius_eq, card_factors_of_irreducible ha, pow_one] |
| 66 | + |
| 67 | +theorem _root_.IsRelPrime.moebius_mul (h : IsRelPrime a b) : |
| 68 | + moebius (a * b) = moebius a * moebius b := by |
| 69 | + rcases subsingleton_or_nontrivial α |
| 70 | + · rw [Subsingleton.elim a 1, moebius_one, one_mul, one_mul] |
| 71 | + by_cases ha : Squarefree a; swap |
| 72 | + · simp [ha, mt Squarefree.of_mul_left ha] |
| 73 | + by_cases hb : Squarefree b; swap |
| 74 | + · simp [hb, mt Squarefree.of_mul_right hb] |
| 75 | + have hab : Squarefree (a * b) := squarefree_mul_iff.mpr ⟨h, ha, hb⟩ |
| 76 | + rw [hab.moebius_eq, Multiset.card_eq_card_of_rel (factors_mul ha.ne_zero hb.ne_zero), |
| 77 | + Multiset.card_add, pow_add, ha.moebius_eq, hb.moebius_eq] |
| 78 | + |
| 79 | +end UniqueFactorizationMonoid |
0 commit comments