AFTD Auto-Formalizing Theoretical Domains

good_slopes_gap_three_primes_conditional

theoremverified

For primes 5≤p and q≥2p−1 with 3(p+1)<2q, the conjectured gap for a nonextremal permutation modulo 3pq follows from the two finite-field direction classifications and the unit-cover normalization.

Statement

theorem good_slopes_gap_three_primes_conditional (p q : ℕ)
    [Fact (Nat.Prime p)] [Fact (Nat.Prime q)] (hp : 5 ≤ p) (hsep : 2*p-1 ≤ q)
    (hsize : (p+1)*3 < 2*q) (hdirP : (∀ T : Finset (ZMod p × ZMod p), T.card = p →
      (∃ G : Finset (ZMod p), (p+1)/2 ≤ G.card ∧ ∀ a ∈ G, Set.InjOn (fun z : ZMod p × ZMod p => z.2 + a*z.1) T) →
      (∃ x : ZMod p, ∀ z ∈ T, z.1 = x) ∨ (∃ a t : ZMod p, ∀ z ∈ T, z.2 + a*z.1 = t))) (hdirQ : (∀ T : Finset (ZMod q × ZMod q), T.card = q →
      (∃ G : Finset (ZMod q), (q+1)/2 ≤ G.card ∧ ∀ a ∈ G, Set.InjOn (fun z : ZMod q × ZMod q => z.2 + a*z.1) T) →
      (∃ x : ZMod q, ∀ z ∈ T, z.1 = x) ∨ (∃ a t : ZMod q, ∀ z ∈ T, z.2 + a*z.1 = t)))
    (f : Equiv.Perm (ZMod (3*(p*q)))) (hf : ¬ is_extremal_perm (3*(p*q)) f)
    (hcover : ∃ c : ZMod (3*(p*q)), ∀ m ∈ good_slopes (3*(p*q)) f, IsUnit (m+c)) :
    (good_slopes (3*(p*q)) f).card ≤ 2*(p-1)*(q-2)
Source
Conditional general reduction for OP-1027. Compare the already-covered large-q range in arXiv:2611.04551 Theorem 9.3.
Verified
19 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 8
Used by 1

The proof, explained

The proof establishes the conjectured gap for good slopes modulo 3pq by reducing the problem to fiber bounds modulo pq and invoking the finite-field direction classifications over ℤ/pℤ and ℤ/qℤ. Using the master lifting theorem good_slopes_gap_three_coprime_from_fiber_bounds with parameters k = pq, L = (p - 1)(q - 1), and d = p - 1, the required uncolored and 3-colored direction bounds on fibers are provided by the CRT product theorems good_slopes_uncolored_product_gap_crt_conditional and good_slopes_colored_product_gap_crt_conditional. This bounds the number of good slopes by 2(p - 1)(q - 1) - 2(p - 1), which simplifies via elementary algebra to 2(p - 1)(q - 2).

  1. For any positive integer n, the number of units in ℤ/nℤ equals Euler's totient φ(n).

    Euler's totient is identified with the cardinality of the unit group (ℤ/nℤ)ˣ via ZMod.card_units_eq_totient. By ZMod.unitsEquivCoprime, the unit group is equivalent to elements whose representative is coprime to n, which by ZMod.isUnit_iff_coprime and ZMod.natCast_zmod_val matches the subtype of units. Transporting cardinality along this equivalence using Fintype.card_congr and converting the subtype cardinality to the size of the filtered finset with Fintype.card_subtype establishes the identity.

    lines 5–14

    uses ZMod.card_units_eq_totient, ZMod.unitsEquivCoprime, Equiv.subtypeEquivRight, ZMod.isUnit_iff_coprime, ZMod.natCast_zmod_val, Fintype.card_congr, Fintype.card_subtype

      classical
      rw [← ZMod.card_units_eq_totient]
      have e1 := ZMod.unitsEquivCoprime (n := n)
      have e2 : { x : ZMod n // Nat.Coprime x.val n } ≃ { x : ZMod n // IsUnit x } := by
        refine Equiv.subtypeEquivRight (fun x => ?_)
        have h := ZMod.isUnit_iff_coprime x.val n
        rw [ZMod.natCast_zmod_val] at h
        exact h.symm
      rw [Fintype.card_congr (e1.trans e2)]
      exact (Fintype.card_subtype (fun b : ZMod n => IsUnit b)).symm
  2. The primes p and q satisfy p < q, are both odd, and are coprime to each other and to 3, so gcd(3, pq) = 1.

    From 5 ≤ p and 2p - 1 ≤ q, linear arithmetic yields p < q. Since p and q are prime (Fact.out) and p ≥ 5, neither prime is 2, so both are odd. Because they are distinct primes, Nat.coprime_primes shows they are coprime. Since 3 is prime and distinct from both p and q, 3 is coprime to p and to q, and therefore coprime to their product pq.

    lines 26–35

    uses Fact.out, Nat.coprime_primes

      classical
      have hppr : Nat.Prime p := Fact.out
      have hqpr : Nat.Prime q := Fact.out
      have hpq : p < q := by omega
      have hpodd : p % 2 = 1 := hppr.eq_two_or_odd.resolve_left (by omega)
      have hqodd : q % 2 = 1 := hqpr.eq_two_or_odd.resolve_left (by omega)
      have hcop : Nat.Coprime p q := (Nat.coprime_primes hppr hqpr).mpr (by omega)
      have hcop3p : Nat.Coprime 3 p := (Nat.coprime_primes (by decide) hppr).mpr (by omega)
      have hcop3q : Nat.Coprime 3 q := (Nat.coprime_primes (by decide) hqpr).mpr (by omega)
      have hcop3 : Nat.Coprime 3 (p*q) := hcop3p.mul_right hcop3q
  3. The number of units in the ring ℤ/pqℤ is (p - 1)(q - 1).

    By the helper lemma in962_units_totient, the unit count in ℤ/pqℤ is φ(pq). Since p and q are coprime, Nat.totient_mul gives φ(pq) = φ(p)φ(q), and Nat.totient_prime computes this as (p - 1)(q - 1).

    lines 36–37

    uses in962_units_totient, Nat.totient_mul, Nat.totient_prime

      have hL : ((Finset.univ : Finset (ZMod (p*q))).filter fun b => IsUnit b).card = (p-1)*(q-1) := by
        rw [in962_units_totient,Nat.totient_mul hcop,Nat.totient_prime hppr,Nat.totient_prime hqpr]
  4. The defect parameter d = p - 1 is strictly positive and satisfies 2(p - 1) < (p - 1)(q - 1).

    Since 5 ≤ p and q ≥ 2p - 1 ≥ 9, we have p - 1 > 0 and q - 1 > 2. Multiplying 2 < q - 1 by p - 1 > 0 using Nat.mul_lt_mul_of_pos_left shows that 2(p - 1) < (p - 1)(q - 1).

    lines 38–42

    uses Nat.mul_lt_mul_of_pos_left

      have hp1 : 0 < p-1 := by omega
      have hq3 : 2 < q-1 := by omega
      have hLd : 2*(p-1) < (p-1)*(q-1) := by
        have h := Nat.mul_lt_mul_of_pos_left hq3 hp1
        omega
  5. The number of good slopes of f in ℤ/3pqℤ is at most 2(p - 1)(q - 1) - 2(p - 1).

    The master lifting theorem good_slopes_gap_three_coprime_from_fiber_bounds bounds the number of good slopes by 2L - 2d with k = pq, L = (p - 1)(q - 1), and d = p - 1. Its two fiber hypotheses on directions in (ℤ/pqℤ)² are discharged: the uncolored bound is supplied by good_slopes_uncolored_product_gap_crt_conditional (using the direction classification hdirQ), and the 3-colored bound is supplied by good_slopes_colored_product_gap_crt_conditional (using both hdirP and hdirQ).

    lines 43–49

    uses good_slopes_gap_three_coprime_from_fiber_bounds, good_slopes_uncolored_product_gap_crt_conditional, good_slopes_colored_product_gap_crt_conditional

      have h := good_slopes_gap_three_coprime_from_fiber_bounds (p*q) ((p-1)*(q-1)) (p-1) hcop3 f hf hcover hL hp1 hLd
        (by
          intro S hs hb
          exact good_slopes_uncolored_product_gap_crt_conditional p q hcop hp hpodd hqodd hsep hdirQ S hs hb)
        (by
          intro S color hs hx hc hb
          exact good_slopes_colored_product_gap_crt_conditional p q hcop hp hpodd hqodd hsep hsize hdirP hdirQ S color hs hx hc hb)
  6. The upper bound 2(p - 1)(q - 1) - 2(p - 1) simplifies to 2(p - 1)(q - 2), completing the proof.

    Writing q - 1 = (q - 2) + 1, the product (p - 1)(q - 1) expands to (p - 1)(q - 2) + (p - 1). Doubling and subtracting 2(p - 1) algebraically simplifies 2(p - 1)(q - 1) - 2(p - 1) to 2(p - 1)(q - 2). Rewriting the bound on good slopes with this identity completes the proof.

    lines 50–60

      have hqsub : q-1=(q-2)+1 := by omega
      have hmul : (p-1)*(q-1) = (p-1)*(q-2)+(p-1) := by
        calc
          _ = (p-1)*((q-2)+1) := by rw [hqsub]
          _ = _ := by ring
      have heq : 2*((p-1)*(q-1))-2*(p-1) = 2*(p-1)*(q-2) := by
        have hr : 2*((p-1)*(q-1)) = 2*((p-1)*(q-2))+2*(p-1) := by rw [hmul]; ring
        have hright : 2*((p-1)*(q-2)) = 2*(p-1)*(q-2) := by ring
        omega
      rw [heq] at h
      exact h
ZMod.card_units_eq_totient
The number of units in the ring ℤ/nℤ equals Euler's totient φ(n).
ZMod.unitsEquivCoprime
The unit group (ℤ/nℤ)ˣ is equivalent to the subtype of elements whose canonical integer representative is coprime to n.
Equiv.subtypeEquivRight
Two subtypes of the same type are equivalent if their defining predicates are logically equivalent for every element.
ZMod.isUnit_iff_coprime
The reduction of a natural number m modulo n is a unit in ℤ/nℤ if and only if m and n are coprime.
ZMod.natCast_zmod_val
Casting the integer value of an element of ℤ/nℤ back into ℤ/nℤ yields the original element.
Fintype.card_congr
Equivalent finite types have the same cardinality.
Fintype.card_subtype
The cardinality of a subtype equals the number of elements of the ambient finite type satisfying the predicate.
Fact.out
Extracts the underlying fact from a Fact typeclass instance.
Nat.coprime_primes
Two prime numbers are coprime if and only if they are distinct.
in962_units_totient
The number of units in the finite ring ℤ/nℤ equals Euler's totient φ(n).
Nat.totient_mul
Euler's totient function is multiplicative on coprime integers: φ(m * n) = φ(m) * φ(n).
Nat.totient_prime
For any prime p, Euler's totient is φ(p) = p - 1.
Nat.mul_lt_mul_of_pos_left
Multiplying a strict inequality n < m by a strictly positive integer k preserves the strict inequality: k * n < k * m.
good_slopes_gap_three_coprime_from_fiber_bounds
For a permutation on ℤ/3kℤ with gcd(3, k) = 1 whose good slopes admit a unit cover and which is non-extremal, if uncolored point directions in (ℤ/kℤ)² achieve at most L - d slopes and 3-colored point directions achieve at most L - 2d slopes, then the permutation has at most 2L - 2d good slopes.
good_slopes_uncolored_product_gap_crt_conditional
Under the direction classification over ℤ/qℤ, any set of size pq in (ℤ/pqℤ)² missing at least one unit direction achieves at most (p-1)*(q-1) - (p-1) point directions.
good_slopes_colored_product_gap_crt_conditional
Under the direction classifications over ℤ/pℤ and ℤ/qℤ, any 3-colored set of size pq in (ℤ/pqℤ)² satisfying color-separated injectivity and missing at least one unit direction achieves at most (p-1)*(q-1) - 2*(p-1) 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 lemma in962_units_totient (n : ℕ) [NeZero n] :    ((Finset.univ : Finset (ZMod n)).filter fun b => IsUnit b).card = Nat.totient n := by  classical  rw [← ZMod.card_units_eq_totient]  have e1 := ZMod.unitsEquivCoprime (n := n)  have e2 : { x : ZMod n // Nat.Coprime x.val n } ≃ { x : ZMod n // IsUnit x } := by    refine Equiv.subtypeEquivRight (fun x => ?_)    have h := ZMod.isUnit_iff_coprime x.val n    rw [ZMod.natCast_zmod_val] at h    exact h.symm  rw [Fintype.card_congr (e1.trans e2)]  exact (Fintype.card_subtype (fun b : ZMod n => IsUnit b)).symmtheorem good_slopes_gap_three_primes_conditional (p q : ℕ)    [Fact (Nat.Prime p)] [Fact (Nat.Prime q)] (hp : 5 ≤ p) (hsep : 2*p-1 ≤ q)    (hsize : (p+1)*3 < 2*q) (hdirP : (∀ T : Finset (ZMod p × ZMod p), T.card = p →      (∃ G : Finset (ZMod p), (p+1)/2 ≤ G.card ∧ ∀ a ∈ G, Set.InjOn (fun z : ZMod p × ZMod p => z.2 + a*z.1) T) →      (∃ x : ZMod p, ∀ z ∈ T, z.1 = x) ∨ (∃ a t : ZMod p, ∀ z ∈ T, z.2 + a*z.1 = t))) (hdirQ : (∀ T : Finset (ZMod q × ZMod q), T.card = q →      (∃ G : Finset (ZMod q), (q+1)/2 ≤ G.card ∧ ∀ a ∈ G, Set.InjOn (fun z : ZMod q × ZMod q => z.2 + a*z.1) T) →      (∃ x : ZMod q, ∀ z ∈ T, z.1 = x) ∨ (∃ a t : ZMod q, ∀ z ∈ T, z.2 + a*z.1 = t)))    (f : Equiv.Perm (ZMod (3*(p*q)))) (hf : ¬ is_extremal_perm (3*(p*q)) f)    (hcover : ∃ c : ZMod (3*(p*q)), ∀ m ∈ good_slopes (3*(p*q)) f, IsUnit (m+c)) :    (good_slopes (3*(p*q)) f).card ≤ 2*(p-1)*(q-2) := by  classical  have hppr : Nat.Prime p := Fact.out  have hqpr : Nat.Prime q := Fact.out  have hpq : p < q := by omega  have hpodd : p % 2 = 1 := hppr.eq_two_or_odd.resolve_left (by omega)  have hqodd : q % 2 = 1 := hqpr.eq_two_or_odd.resolve_left (by omega)  have hcop : Nat.Coprime p q := (Nat.coprime_primes hppr hqpr).mpr (by omega)  have hcop3p : Nat.Coprime 3 p := (Nat.coprime_primes (by decide) hppr).mpr (by omega)  have hcop3q : Nat.Coprime 3 q := (Nat.coprime_primes (by decide) hqpr).mpr (by omega)  have hcop3 : Nat.Coprime 3 (p*q) := hcop3p.mul_right hcop3q  have hL : ((Finset.univ : Finset (ZMod (p*q))).filter fun b => IsUnit b).card = (p-1)*(q-1) := by    rw [in962_units_totient,Nat.totient_mul hcop,Nat.totient_prime hppr,Nat.totient_prime hqpr]  have hp1 : 0 < p-1 := by omega  have hq3 : 2 < q-1 := by omega  have hLd : 2*(p-1) < (p-1)*(q-1) := by    have h := Nat.mul_lt_mul_of_pos_left hq3 hp1    omega  have h := good_slopes_gap_three_coprime_from_fiber_bounds (p*q) ((p-1)*(q-1)) (p-1) hcop3 f hf hcover hL hp1 hLd    (by      intro S hs hb      exact good_slopes_uncolored_product_gap_crt_conditional p q hcop hp hpodd hqodd hsep hdirQ S hs hb)    (by      intro S color hs hx hc hb      exact good_slopes_colored_product_gap_crt_conditional p q hcop hp hpodd hqodd hsep hsize hdirP hdirQ S color hs hx hc hb)  have hqsub : q-1=(q-2)+1 := by omega  have hmul : (p-1)*(q-1) = (p-1)*(q-2)+(p-1) := by    calc      _ = (p-1)*((q-2)+1) := by rw [hqsub]      _ = _ := by ring  have heq : 2*((p-1)*(q-1))-2*(p-1) = 2*(p-1)*(q-2) := by    have hr : 2*((p-1)*(q-1)) = 2*((p-1)*(q-2))+2*(p-1) := by rw [hmul]; ring    have hright : 2*((p-1)*(q-2)) = 2*(p-1)*(q-2) := by ring    omega  rw [heq] at h  exact h
See it in the graphDiscuss this resultChallenge it