AFTD Auto-Formalizing Theoretical Domains

good_slopes_gap_mod_165_le_76

theoremverifiedoriginal

Every non-extremal permutation of the integers modulo 165 has at most 76 good slopes.

Statement

theorem good_slopes_gap_mod_165_le_76 (f : Equiv.Perm (ZMod 165)) (hf : ¬ is_extremal_perm 165 f) : (good_slopes 165 f).card ≤ 76
Related work
The open gap question and modulus-165 case are in https://arxiv.org/abs/2611.04551, Question 10.2 and Table 3.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 7
  • good_slopesGiven a natural number n with n ≠ 0 (via [NeZero n]) and a permutation f of ℤ/nℤ, good_slopes n f is the finite set (Finset) of elements m…
  • is_extremal_permGiven n with [NeZero n], a permutation f of ℤ/nℤ is extremal if the number of its good slopes (the cardinality of good_slopes n f) equals…
  • good_slopes_gap_three_coprime_from_fiber_boundsLet k be a nonzero natural number coprime to 3 and let f be a non-extremal permutation modulo 3k. Suppose there are L units modulo k and 0…
  • good_slopes_fiber55_unit_gapFor any 55 points over Z/55Z, if at least one unit direction fails to be injective, then at most 36 of the 40 unit directions are injective.
  • good_slopes_unit_cover_squarefreeFor every nonzero squarefree modulus and permutation, some unit can be added to all its good slopes to make them units.
  • good_slopes_point_directionsThe unit directions a for which the linear form y + a x is injective on a finite set of points over the residues modulo n.
  • good_slopes_fiber55_nonunit_collision_gapLet S be any finite set of points over Z/55Z. If a unit direction has a collision between distinct points whose first-coordinate…

Read back from the Lean

For every permutation $f$ of $\mathbb{Z}/165\mathbb{Z}$, if $f$ is not an extremal permutation for $n = 165$ (meaning $\operatorname{card}(\text{good\_slopes } 165\ f) \ne \varphi(165)$), then the number of good slopes of $f$ in $\mathbb{Z}/165\mathbb{Z}$ is at most 76.

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 proof establishes that 165 is squarefree, which guarantees that all good slopes of f can be shifted into the unit group by some constant c. It then applies a coprime-factor gap theorem with modulus 165 = 3 * 55, using fiber direction bounds on ZMod 55 (where any fiber missing a unit direction has at most 36 directions) to conclude that f has at most 2 * 40 - 4 = 76 good slopes.

  1. The integer 165 is squarefree.

    The prime factorization of 165 is 3 * 5 * 11. Since 3, 5, and 11 are prime, they are squarefree. Because gcd(3, 5) = 1, their product 15 is squarefree, and because gcd(15, 11) = 1, the product 165 is squarefree by Nat.squarefree_mul.

    lines 3–11

    uses Nat.squarefree_mul

    private theorem in962_gap76_squarefree : Squarefree 165 := by
      have hp3 : Nat.Prime 3 := by norm_num
      have hp5 : Nat.Prime 5 := by norm_num
      have hp11 : Nat.Prime 11 := by norm_num
      have h : Squarefree ((3*5)*11 : ℕ) :=
        (Nat.squarefree_mul (by norm_num)).2
          ⟨(Nat.squarefree_mul (by norm_num)).2 ⟨hp3.squarefree, hp5.squarefree⟩,
           hp11.squarefree⟩
      exact h
  2. There exists an element c such that m + c is a unit modulo 165 for every good slope m of f.

    Since 165 is squarefree, good_slopes_unit_cover_squarefree applies to provide a shift c such that translating every good slope of f by c results in a unit modulo 165.

    line 14

    uses good_slopes_unit_cover_squarefree

      obtain ⟨c, _, hc⟩ := good_slopes_unit_cover_squarefree 165 in962_gap76_squarefree f
  3. The permutation f has at most 76 good slopes.

    We apply good_slopes_gap_three_coprime_from_fiber_bounds with k = 55, L = 40, and d = 2. The arithmetic conditions Nat.Coprime 3 55, 0 < 2, and 2 * 2 < 40 hold by computation. Modulo 55 there are L = 40 units by good_slopes_fiber55_nonunit_collision_gap_card_units. The uncolored and colored fiber conditions require that any 55-element subset missing a unit direction has at most 40 - 2 = 38 (respectively 40 - 4 = 36) point directions; both bounds follow from good_slopes_fiber55_unit_gap, which bounds the directions by 36. This yields at most 2 * 40 - 2 * 2 = 76 good slopes for f.

    lines 15–25

    uses good_slopes_gap_three_coprime_from_fiber_bounds, good_slopes_fiber55_nonunit_collision_gap_card_units, good_slopes_fiber55_unit_gap

      have h := good_slopes_gap_three_coprime_from_fiber_bounds 55 40 2 (by decide) f hf
        ⟨c,hc⟩ good_slopes_fiber55_nonunit_collision_gap_card_units (by decide) (by decide)
        (by
          intro S hs hb
          have hg := good_slopes_fiber55_unit_gap S hs hb
          omega)
        (by
          intro S color hs hx hc hb
          have hg := good_slopes_fiber55_unit_gap S hs hb
          omega)
      exact h
Nat.squarefree_mul
A product of coprime numbers is squarefree if and only if both factors are squarefree
good_slopes_unit_cover_squarefree
For a squarefree modulus, the good slopes of any permutation can be translated by some constant to all become units
good_slopes_gap_three_coprime_from_fiber_bounds
Reduces the gap bound for a modulus of the form 3*k to bounds on the point directions of subsets of size k
good_slopes_fiber55_nonunit_collision_gap_card_units
There are 40 units in ZMod 55
good_slopes_fiber55_unit_gap
A 55-element subset of (ZMod 55)^2 missing at least one unit direction has at most 36 good point directions

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

set_option maxRecDepth 10000set_option maxHeartbeats 5000000private theorem in962_gap76_squarefree : Squarefree 165 := by  have hp3 : Nat.Prime 3 := by norm_num  have hp5 : Nat.Prime 5 := by norm_num  have hp11 : Nat.Prime 11 := by norm_num  have h : Squarefree ((3*5)*11 : ℕ) :=    (Nat.squarefree_mul (by norm_num)).2      ⟨(Nat.squarefree_mul (by norm_num)).2 ⟨hp3.squarefree, hp5.squarefree⟩,       hp11.squarefree⟩  exact htheorem good_slopes_gap_mod_165_le_76 (f : Equiv.Perm (ZMod 165)) (hf : ¬ is_extremal_perm 165 f) : (good_slopes 165 f).card ≤ 76 := by  obtain ⟨c, _, hc⟩ := good_slopes_unit_cover_squarefree 165 in962_gap76_squarefree f  have h := good_slopes_gap_three_coprime_from_fiber_bounds 55 40 2 (by decide) f hf    ⟨c,hc⟩ good_slopes_fiber55_nonunit_collision_gap_card_units (by decide) (by decide)    (by      intro S hs hb      have hg := good_slopes_fiber55_unit_gap S hs hb      omega)    (by      intro S color hs hx hc hb      have hg := good_slopes_fiber55_unit_gap S hs hb      omega)  exact h
See it in the graphDiscuss this resultChallenge it