AFTD Auto-Formalizing Theoretical Domains

good_slopes_fiber55_unit_gap

theoremverified

For 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.

Statement

theorem good_slopes_fiber55_unit_gap (S : Finset (ZMod 55 × ZMod 55)) (hcard : S.card = 55) (hbad : ∃ a : ZMod 55, IsUnit a ∧ a ∉ good_slopes_point_directions 55 S) : (good_slopes_point_directions 55 S).card ≤ 36
Source
Uncolored 55-point fiber estimate for OP-1027, from the normalized neighbor obstruction and CRT.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 3
Used by 2

The proof, explained

The theorem is proved by contradiction, assuming that more than 36 of the 40 unit directions in ℤ/55ℤ are injective on the 55-point set S. This assumption implies that at most 3 unit directions can fail to be injective. From an assumed bad unit direction a₀, we obtain two colliding points p, q ∈ S with coordinate difference (d₁, d₂). If the horizontal difference d₁ is not a unit, an auxiliary gap theorem immediately bounds the good directions by 36. If d₁ is a unit, an affine transformation normalizes the configuration to contain (0,0) and (1,54); a structural result on such anchored sets then shows that among a specific set of 12 directions, every triple must contain an injective direction, since otherwise transferring non-injective directions back to S would produce 4 bad unit directions, contradicting the bound of at most 3.

  1. Precompute arithmetic facts in ℤ/55ℤ: the 40-element unit set U₅₅, a 12-element subset of units, that 1 is not in that subset, and that -1 = 54. automation

    The units of ℤ/55ℤ are characterized by the existence of inverses via `isUnit_iff_exists_inv` and verified to coincide with the explicit 40-element finset U₅₅ by exhaustive checking with `decide`. Similarly, by computational evaluation (`decide`), the 12-element set {6,12,16,21,23,26,31,34,36,41,46,51} is verified to be a subset of U₅₅, 1 is shown not to belong to this set, and -1 is computed to equal 54.

    lines 1–16

    uses isUnit_iff_exists_inv

    set_option maxRecDepth 10000
    set_option maxHeartbeats 3000000
    namespace Gs55Gap
    
    def U55 : Finset (ZMod 55) := {1,2,3,4,6,7,8,9,12,13,14,16,17,18,19,21,23,24,26,27,28,29,31,32,34,36,37,38,39,41,42,43,46,47,48,49,51,52,53,54}
    
    theorem isUnit_iff_U (x : ZMod 55) : IsUnit x ↔ x ∈ U55 := by
      rw [isUnit_iff_exists_inv]; revert x; decide
    
    theorem eight_sub : ({6,12,16,21,23,26,31,34,36,41,46,51} : Finset (ZMod 55)) ⊆ U55 := by decide
    
    theorem one_not_eight : (1 : ZMod 55) ∉ ({6,12,16,21,23,26,31,34,36,41,46,51} : Finset (ZMod 55)) := by decide
    
    theorem neg_one_eq : (-1 : ZMod 55) = 54 := by decide
    
    end Gs55Gap
  2. Assume for contradiction that more than 36 unit directions are injective on S, obtain a non-injective unit direction a₀, and characterize good directions as units whose projection map is injective on S.

    We begin a proof by contradiction: suppose the cardinality of the set of good directions on S is strictly greater than 36. From the hypothesis that at least one unit direction is bad, we choose such a unit direction a₀. Unfolding the definition of good directions, an element a is good if and only if a is a unit and the projection map (x, y) ↦ y + ax is injective on S.

    lines 18–25

    theorem good_slopes_fiber55_unit_gap (S : Finset (ZMod 55 × ZMod 55)) (hcard : S.card = 55) (hbad : ∃ a : ZMod 55, IsUnit a ∧ a ∉ good_slopes_point_directions 55 S) : (good_slopes_point_directions 55 S).card ≤ 36 := by
      classical
      by_contra hlt
      push Not at hlt
      obtain ⟨a0, ha0u, ha0⟩ := hbad
      have hmem : ∀ a, a ∈ good_slopes_point_directions 55 S ↔
          IsUnit a ∧ Set.InjOn (fun p : ZMod 55 × ZMod 55 => p.2 + a * p.1) S := by
        intro a; unfold good_slopes_point_directions; simp
  3. Any set B of non-injective unit directions on S has cardinality at most 3. automation

    There are exactly 40 units in ℤ/55ℤ, forming the explicit set U₅₅. Any good direction is an injective unit direction, so it cannot belong to B. Thus the good directions form a subset of U₅₅ \ B, which implies that their number is at most 40 - |B|. Since by assumption there are more than 36 good directions, linear arithmetic forces |B| ≤ 3.

    lines 26–39

    uses Gs55Gap.isUnit_iff_U, Finset.mem_sdiff, Finset.card_le_card, Finset.card_sdiff_of_subset

      -- four bad unit directions are impossible
      have key : ∀ B : Finset (ZMod 55),
          (∀ b ∈ B, IsUnit b ∧ ¬ Set.InjOn (fun p : ZMod 55 × ZMod 55 => p.2 + b * p.1) S) → B.card ≤ 3 := by
        intro B hB
        have hBU : B ⊆ Gs55Gap.U55 := fun b hb => (Gs55Gap.isUnit_iff_U b).1 (hB b hb).1
        have hsub : good_slopes_point_directions 55 S ⊆ Gs55Gap.U55 \ B := by
          intro a ha
          rw [hmem] at ha
          rw [Finset.mem_sdiff]
          exact ⟨(Gs55Gap.isUnit_iff_U a).1 ha.1, fun hb => (hB a hb).2 ha.2⟩
        have h1 := Finset.card_le_card hsub
        rw [Finset.card_sdiff_of_subset hBU] at h1
        have : Gs55Gap.U55.card = 40 := by decide
        omega
  4. There exist distinct points p, q ∈ S that collide under projection in direction a₀, and any direction b satisfying (q₂ - p₂) + b(q₁ - p₁) = 0 is also non-injective on S.

    Because a₀ is a non-injective direction, the projection map fails to be injective on S, giving distinct points p, q ∈ S with p₂ + a₀ p₁ = q₂ + a₀ q₁. Setting d₁ = q₁ - p₁ and d₂ = q₂ - p₂, this collision means d₂ = -a₀ d₁. Any direction b satisfying d₂ + b d₁ = 0 produces the same value on p as on q, and hence is also non-injective on S.

    lines 40–51

    uses not_forall

      have hni : ¬ Set.InjOn (fun p : ZMod 55 × ZMod 55 => p.2 + a0 * p.1) S := by
        intro h; exact ha0 ((hmem a0).2 ⟨ha0u, h⟩)
      obtain ⟨p, hp, q, hq, hpq, hne⟩ : ∃ p ∈ S, ∃ q ∈ S, p.2 + a0 * p.1 = q.2 + a0 * q.1 ∧ p ≠ q := by
        simp only [Set.InjOn, not_forall] at hni
        obtain ⟨p, hp, q, hq, h, hne⟩ := hni
        exact ⟨p, hp, q, hq, h, hne⟩
      set d1 := q.1 - p.1 with hd1
      set d2 := q.2 - p.2 with hd2
      have hd : d2 = -(a0 * d1) := by rw [hd1, hd2]; linear_combination -hpq
      have bad_of : ∀ b, d2 + b * d1 = 0 → ¬ Set.InjOn (fun p : ZMod 55 × ZMod 55 => p.2 + b * p.1) S := by
        intro b hb hinj
        exact hne (hinj hp hq (by simp only; rw [hd1, hd2] at hb; linear_combination -hb))
  5. If the horizontal difference d₁ is a unit, an affine coordinate transformation φ maps S to a set S' of 55 points containing (0,0) and (1,54).

    When d₁ is a unit, d₂ = -a₀ d₁ is also a unit since a₀ is a unit. Setting s = d₁⁻¹ and r = -d₂⁻¹, we obtain s d₁ = 1 and r d₂ = -1 ≡ 54 (mod 55). The coordinate transformation φ(u) = (s(u₁ - p₁), r(u₂ - p₂)) is an injective affine map, so the transformed set S' = φ(S) still has 55 points, with p mapping to (0,0) and q mapping to (1,54).

    lines 52–77

    uses ZMod.mul_inv_of_unit, isUnit_iff_exists_inv, neg_mul, mul_neg, neg_neg, mul_comm, Prod.mk.injEq, Prod.ext, Finset.card_image_of_injective, Finset.mem_image, Gs55Gap.neg_one_eq

      by_cases hu1 : IsUnit d1
      · -- normalise the collision to (0,0), (1,34)
        have hd2u : IsUnit d2 := by rw [hd]; exact (ha0u.mul hu1).neg
        set s := d1⁻¹ with hs
        set r := -d2⁻¹ with hr
        have hsd : s * d1 = 1 := by rw [hs, mul_comm]; exact ZMod.mul_inv_of_unit d1 hu1
        have hrd : r * d2 = -1 := by rw [hr, neg_mul, mul_comm, ZMod.mul_inv_of_unit d2 hd2u]
        have hsu : IsUnit s := isUnit_iff_exists_inv.2 ⟨d1, hsd⟩
        have hru : IsUnit r := isUnit_iff_exists_inv.2 ⟨-d2, by rw [mul_neg, hrd, neg_neg]⟩
        let φ : ZMod 55 × ZMod 55 → ZMod 55 × ZMod 55 := fun u => (s * (u.1 - p.1), r * (u.2 - p.2))
        have hφ : Function.Injective φ := by
          intro u v h
          simp only [φ, Prod.mk.injEq] at h
          have e1 := hsu.mul_left_cancel h.1
          have e2 := hru.mul_left_cancel h.2
          exact Prod.ext (by linear_combination e1) (by linear_combination e2)
        set S' := S.image φ with hS'
        have hcard' : S'.card = 55 := by rw [hS', Finset.card_image_of_injective _ hφ, hcard]
        have h0 : ((0 : ZMod 55), (0 : ZMod 55)) ∈ S' :=
          Finset.mem_image.2 ⟨p, hp, by simp [φ]⟩
        have h1 : ((1 : ZMod 55), (54 : ZMod 55)) ∈ S' :=
          Finset.mem_image.2 ⟨q, hq, by
            simp only [φ, Prod.mk.injEq]
            refine ⟨?_, ?_⟩
            · rw [← hd1]; exact hsd
            · rw [← hd2, hrd, Gs55Gap.neg_one_eq]⟩
  6. A direction b that is non-injective on the normalized set S' transfers to a non-injective direction a₀ b on the original set S.

    Because r a₀ d₁ = -d₂⁻¹ a₀ d₁ = d₂⁻¹ d₂ = 1 = s d₁, canceling the unit d₁ gives the identity r a₀ = s. Expanding the projection of transformed points shows that (φ(w))₂ + b(φ(w))₁ = r(w₂ + (a₀ b)w₁) - (r p₂ + b s p₁). Since r is invertible, injectivity in direction a₀ b on S is equivalent to injectivity in direction b on S'. Contrapositively, if b is non-injective on S', then a₀ b is non-injective on S.

    lines 78–97

    uses Finset.mem_image, mul_assoc, neg_neg, mul_neg

        -- a direction b bad on S' gives the direction a0 * b bad on S
        have transfer : ∀ b, ¬ Set.InjOn (fun p : ZMod 55 × ZMod 55 => p.2 + b * p.1) S' →
            ¬ Set.InjOn (fun p : ZMod 55 × ZMod 55 => p.2 + (a0 * b) * p.1) S := by
          intro b hb hinj
          apply hb
          intro u' hu' v' hv' huv
          obtain ⟨u, hu, rfl⟩ := Finset.mem_image.1 hu'
          obtain ⟨v, hv, rfl⟩ := Finset.mem_image.1 hv'
          have hrel : ∀ w : ZMod 55 × ZMod 55, (φ w).2 + b * (φ w).1 =
              r * (w.2 + (a0 * b) * w.1) - (r * p.2 + b * s * p.1) := by
            intro w
            simp only [φ]
            have hrs : r * a0 = s := by
              have : r * a0 * d1 = s * d1 := by
                rw [hsd, mul_assoc, ← neg_neg (a0 * d1), ← hd, mul_neg, hrd, neg_neg]
              exact hu1.mul_right_cancel this
            linear_combination (-(b * w.1)) * hrs
          have e : r * (u.2 + (a0 * b) * u.1) = r * (v.2 + (a0 * b) * v.1) := by
            have := huv; simp only at this; rw [hrel u, hrel v] at this; linear_combination this
          rw [hinj hu hv (hru.mul_left_cancel e)]
  7. Applying the anchored neighbors theorem to S' leads to a contradiction, because any three non-injective directions in E would generate 4 non-injective unit directions on S. automation

    We invoke the structural theorem good_slopes_fiber55_anchored_neighbors on S' with the 12-element direction set E = {6,12,16,21,23,26,31,34,36,41,46,51}. The first two conditions (injectivity and surjectivity onto ℤ/55ℤ by pigeonhole) are verified directly. If the third condition failed, there would exist three distinct directions a, b, c ∈ E all non-injective on S'. Since 1 ∉ E, the set T = {1, a, b, c} has 4 elements, all of which are units. Multiplying T by a₀ gives a set B = a₀ · T of 4 distinct units that are all non-injective on S (since a₀ · 1 = a₀ is bad on S and each a₀ y is bad on S by the transfer lemma). This contradicts the earlier bound |B| ≤ 3, so good_slopes_fiber55_anchored_neighbors applies and derives False.

    lines 98–136

    uses good_slopes_fiber55_anchored_neighbors, Finset.eq_univ_of_card, Finset.card_image_of_injOn, ZMod.card, Finset.mem_univ, Finset.mem_image, Finset.card_insert_of_notMem, Finset.card_eq_three, Finset.mem_insert, Finset.mem_singleton, Gs55Gap.one_not_eight, isUnit_one, Gs55Gap.isUnit_iff_U, Gs55Gap.eight_sub, Finset.card_image_of_injective

        apply good_slopes_fiber55_anchored_neighbors S'
          (fun a => Set.InjOn (fun p : ZMod 55 × ZMod 55 => p.2 + a * p.1) S') h0 h1
        · intro a _ ha; exact ha
        · intro a _ ha t
          have himg : S'.image (fun p : ZMod 55 × ZMod 55 => p.2 + a * p.1) = Finset.univ := by
            apply Finset.eq_univ_of_card
            rw [Finset.card_image_of_injOn ha, hcard', ZMod.card]
          have ht : t ∈ S'.image (fun p : ZMod 55 × ZMod 55 => p.2 + a * p.1) := by
            rw [himg]; exact Finset.mem_univ t
          obtain ⟨x, hx, hxt⟩ := Finset.mem_image.1 ht
          exact ⟨x, hx, hxt⟩
        · intro a b c ha hb hc hab hac hbc
          by_contra hall
          push Not at hall
          obtain ⟨hga, hgb, hgc⟩ := hall
          have hT : (insert (1 : ZMod 55) ({a, b, c} : Finset (ZMod 55))).card = 4 := by
            rw [Finset.card_insert_of_notMem, Finset.card_eq_three.2 ⟨a, b, c, hab, hac, hbc, rfl⟩]
            intro h1m
            simp only [Finset.mem_insert, Finset.mem_singleton] at h1m
            rcases h1m with h | h | h <;> [exact Gs55Gap.one_not_eight (h ▸ ha); exact Gs55Gap.one_not_eight (h ▸ hb);
              exact Gs55Gap.one_not_eight (h ▸ hc)]
          have hB := key ((insert (1 : ZMod 55) ({a, b, c} : Finset (ZMod 55))).image (a0 * ·)) (by
            intro x hx
            obtain ⟨y, hy, rfl⟩ := Finset.mem_image.1 hx
            simp only [Finset.mem_insert, Finset.mem_singleton] at hy
            have hyu : IsUnit y := by
              rcases hy with rfl | rfl | rfl | rfl
              · exact isUnit_one
              · exact (Gs55Gap.isUnit_iff_U _).2 (Gs55Gap.eight_sub ha)
              · exact (Gs55Gap.isUnit_iff_U _).2 (Gs55Gap.eight_sub hb)
              · exact (Gs55Gap.isUnit_iff_U _).2 (Gs55Gap.eight_sub hc)
            refine ⟨ha0u.mul hyu, ?_⟩
            rcases hy with rfl | rfl | rfl | rfl
            · simpa using hni
            · exact transfer _ hga
            · exact transfer _ hgb
            · exact transfer _ hgc)
          rw [Finset.card_image_of_injective _ ha0u.mul_right_injective, hT] at hB
          omega
  8. When the horizontal difference d₁ is not a unit, good_slopes_fiber55_nonunit_collision_gap bounds the number of good directions by at most 36, completing the contradiction. automation

    In the remaining case where d₁ = q₁ - p₁ is not invertible, the previously proved theorem good_slopes_fiber55_nonunit_collision_gap applies directly to the collision pair p, q under a₀, proving that the number of good directions is at most 36. This contradicts our assumption that there are more than 36 good directions.

    lines 137–138

    uses good_slopes_fiber55_nonunit_collision_gap

      · have hle := good_slopes_fiber55_nonunit_collision_gap S a0 ha0u p q hp hq hne hpq (by simpa [hd1] using hu1)
        omega
Gs55Gap.eight_sub
The set {6,12,16,21,23,26,31,34,36,41,46,51} is a subset of the unit set U₅₅ in ℤ/55ℤ.
Gs55Gap.isUnit_iff_U
An element of ℤ/55ℤ is a unit if and only if it belongs to the explicit 40-element set U₅₅.
Gs55Gap.one_not_eight
In ℤ/55ℤ, 1 is not in the set {6,12,16,21,23,26,31,34,36,41,46,51}.
Gs55Gap.neg_one_eq
In ℤ/55ℤ, -1 = 54.
Finset.card_eq_three
A finite set has cardinality 3 if and only if it consists of three pairwise distinct elements.
Finset.card_image_of_injective
The image of a finite set under an injective function has the same cardinality as the original set.
Finset.card_image_of_injOn
If a function is injective on a finite set s, the cardinality of its image on s equals the cardinality of s.
Finset.card_insert_of_notMem
Inserting an element not already in a finite set increases its cardinality by 1.
Finset.card_le_card
If a finite set is a subset of another, its cardinality is at most the cardinality of the larger set.
Finset.card_sdiff_of_subset
If s ⊆ t for finite sets, the cardinality of t \ s equals the cardinality of t minus the cardinality of s.
Finset.eq_univ_of_card
A subset of a finite type whose cardinality equals the cardinality of the entire type is the universal set.
Finset.mem_image
An element belongs to the image of a finite set under a function if and only if it is the image of some element of that set.
Finset.mem_insert
An element is in the insertion of an element a into a set s if and only if it equals a or belongs to s.
Finset.mem_sdiff
An element belongs to s \ t if and only if it belongs to s and does not belong to t.
Finset.mem_singleton
An element belongs to the singleton {a} if and only if it equals a.
Finset.mem_univ
Every element of a finite type belongs to the universal finite set univ.
good_slopes_fiber55_anchored_neighbors
Any 55-element set in (ℤ/55ℤ)² containing (0,0) and (1,54) cannot satisfy that every three directions in {6,12,16,21,23,26,31,34,36,41,46,51} contain at least one injective direction.
good_slopes_fiber55_nonunit_collision_gap
For any 55-point set S in (ℤ/55ℤ)², if a unit direction causes a collision whose horizontal coordinate difference is not a unit, then S has at most 36 good directions.
isUnit_one
The identity element 1 is a unit in any monoid.
isUnit_iff_exists_inv
An element in a Dedekind-finite monoid is a unit if and only if it has a multiplicative inverse.
mul_assoc
Multiplication is associative: (a * b) * c = a * (b * c).
mul_comm
Multiplication is commutative: a * b = b * a.
mul_neg
For any elements a and b, a * (-b) = -(a * b).
neg_mul
For any elements a and b, (-a) * b = -(a * b).
neg_neg
Double negation cancels: -(-a) = a.
not_forall
A universal statement is false if and only if there exists a counterexample.
Prod.mk.injEq
Two ordered pairs are equal if and only if their respective first and second components are equal.
Prod.ext
Two ordered pairs are equal if their first coordinates agree and their second coordinates agree.
ZMod.card
The cardinality of ℤ/nℤ is n.
ZMod.mul_inv_of_unit
Multiplying a unit in ℤ/nℤ by its modular inverse yields 1.

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 3000000namespace Gs55Gapdef U55 : Finset (ZMod 55) := {1,2,3,4,6,7,8,9,12,13,14,16,17,18,19,21,23,24,26,27,28,29,31,32,34,36,37,38,39,41,42,43,46,47,48,49,51,52,53,54}theorem isUnit_iff_U (x : ZMod 55) : IsUnit x ↔ x ∈ U55 := by  rw [isUnit_iff_exists_inv]; revert x; decidetheorem eight_sub : ({6,12,16,21,23,26,31,34,36,41,46,51} : Finset (ZMod 55)) ⊆ U55 := by decidetheorem one_not_eight : (1 : ZMod 55) ∉ ({6,12,16,21,23,26,31,34,36,41,46,51} : Finset (ZMod 55)) := by decidetheorem neg_one_eq : (-1 : ZMod 55) = 54 := by decideend Gs55Gaptheorem good_slopes_fiber55_unit_gap (S : Finset (ZMod 55 × ZMod 55)) (hcard : S.card = 55) (hbad : ∃ a : ZMod 55, IsUnit a ∧ a ∉ good_slopes_point_directions 55 S) : (good_slopes_point_directions 55 S).card ≤ 36 := by  classical  by_contra hlt  push Not at hlt  obtain ⟨a0, ha0u, ha0⟩ := hbad  have hmem : ∀ a, a ∈ good_slopes_point_directions 55 S ↔      IsUnit a ∧ Set.InjOn (fun p : ZMod 55 × ZMod 55 => p.2 + a * p.1) S := by    intro a; unfold good_slopes_point_directions; simp  -- four bad unit directions are impossible  have key : ∀ B : Finset (ZMod 55),      (∀ b ∈ B, IsUnit b ∧ ¬ Set.InjOn (fun p : ZMod 55 × ZMod 55 => p.2 + b * p.1) S) → B.card ≤ 3 := by    intro B hB    have hBU : B ⊆ Gs55Gap.U55 := fun b hb => (Gs55Gap.isUnit_iff_U b).1 (hB b hb).1    have hsub : good_slopes_point_directions 55 S ⊆ Gs55Gap.U55 \ B := by      intro a ha      rw [hmem] at ha      rw [Finset.mem_sdiff]      exact ⟨(Gs55Gap.isUnit_iff_U a).1 ha.1, fun hb => (hB a hb).2 ha.2⟩    have h1 := Finset.card_le_card hsub    rw [Finset.card_sdiff_of_subset hBU] at h1    have : Gs55Gap.U55.card = 40 := by decide    omega  have hni : ¬ Set.InjOn (fun p : ZMod 55 × ZMod 55 => p.2 + a0 * p.1) S := by    intro h; exact ha0 ((hmem a0).2 ⟨ha0u, h⟩)  obtain ⟨p, hp, q, hq, hpq, hne⟩ : ∃ p ∈ S, ∃ q ∈ S, p.2 + a0 * p.1 = q.2 + a0 * q.1 ∧ p ≠ q := by    simp only [Set.InjOn, not_forall] at hni    obtain ⟨p, hp, q, hq, h, hne⟩ := hni    exact ⟨p, hp, q, hq, h, hne⟩  set d1 := q.1 - p.1 with hd1  set d2 := q.2 - p.2 with hd2  have hd : d2 = -(a0 * d1) := by rw [hd1, hd2]; linear_combination -hpq  have bad_of : ∀ b, d2 + b * d1 = 0 → ¬ Set.InjOn (fun p : ZMod 55 × ZMod 55 => p.2 + b * p.1) S := by    intro b hb hinj    exact hne (hinj hp hq (by simp only; rw [hd1, hd2] at hb; linear_combination -hb))  by_cases hu1 : IsUnit d1  · -- normalise the collision to (0,0), (1,34)    have hd2u : IsUnit d2 := by rw [hd]; exact (ha0u.mul hu1).neg    set s := d1⁻¹ with hs    set r := -d2⁻¹ with hr    have hsd : s * d1 = 1 := by rw [hs, mul_comm]; exact ZMod.mul_inv_of_unit d1 hu1    have hrd : r * d2 = -1 := by rw [hr, neg_mul, mul_comm, ZMod.mul_inv_of_unit d2 hd2u]    have hsu : IsUnit s := isUnit_iff_exists_inv.2 ⟨d1, hsd⟩    have hru : IsUnit r := isUnit_iff_exists_inv.2 ⟨-d2, by rw [mul_neg, hrd, neg_neg]⟩    let φ : ZMod 55 × ZMod 55 → ZMod 55 × ZMod 55 := fun u => (s * (u.1 - p.1), r * (u.2 - p.2))    have hφ : Function.Injective φ := by      intro u v h      simp only [φ, Prod.mk.injEq] at h      have e1 := hsu.mul_left_cancel h.1      have e2 := hru.mul_left_cancel h.2      exact Prod.ext (by linear_combination e1) (by linear_combination e2)    set S' := S.image φ with hS'    have hcard' : S'.card = 55 := by rw [hS', Finset.card_image_of_injective _ hφ, hcard]    have h0 : ((0 : ZMod 55), (0 : ZMod 55)) ∈ S' :=      Finset.mem_image.2 ⟨p, hp, by simp [φ]⟩    have h1 : ((1 : ZMod 55), (54 : ZMod 55)) ∈ S' :=      Finset.mem_image.2 ⟨q, hq, by        simp only [φ, Prod.mk.injEq]        refine ⟨?_, ?_⟩        · rw [← hd1]; exact hsd        · rw [← hd2, hrd, Gs55Gap.neg_one_eq]⟩    -- a direction b bad on S' gives the direction a0 * b bad on S    have transfer : ∀ b, ¬ Set.InjOn (fun p : ZMod 55 × ZMod 55 => p.2 + b * p.1) S' →        ¬ Set.InjOn (fun p : ZMod 55 × ZMod 55 => p.2 + (a0 * b) * p.1) S := by      intro b hb hinj      apply hb      intro u' hu' v' hv' huv      obtain ⟨u, hu, rfl⟩ := Finset.mem_image.1 hu'      obtain ⟨v, hv, rfl⟩ := Finset.mem_image.1 hv'      have hrel : ∀ w : ZMod 55 × ZMod 55, (φ w).2 + b * (φ w).1 =          r * (w.2 + (a0 * b) * w.1) - (r * p.2 + b * s * p.1) := by        intro w        simp only [φ]        have hrs : r * a0 = s := by          have : r * a0 * d1 = s * d1 := by            rw [hsd, mul_assoc, ← neg_neg (a0 * d1), ← hd, mul_neg, hrd, neg_neg]          exact hu1.mul_right_cancel this        linear_combination (-(b * w.1)) * hrs      have e : r * (u.2 + (a0 * b) * u.1) = r * (v.2 + (a0 * b) * v.1) := by        have := huv; simp only at this; rw [hrel u, hrel v] at this; linear_combination this      rw [hinj hu hv (hru.mul_left_cancel e)]    apply good_slopes_fiber55_anchored_neighbors S'      (fun a => Set.InjOn (fun p : ZMod 55 × ZMod 55 => p.2 + a * p.1) S') h0 h1    · intro a _ ha; exact ha    · intro a _ ha t      have himg : S'.image (fun p : ZMod 55 × ZMod 55 => p.2 + a * p.1) = Finset.univ := by        apply Finset.eq_univ_of_card        rw [Finset.card_image_of_injOn ha, hcard', ZMod.card]      have ht : t ∈ S'.image (fun p : ZMod 55 × ZMod 55 => p.2 + a * p.1) := by        rw [himg]; exact Finset.mem_univ t      obtain ⟨x, hx, hxt⟩ := Finset.mem_image.1 ht      exact ⟨x, hx, hxt⟩    · intro a b c ha hb hc hab hac hbc      by_contra hall      push Not at hall      obtain ⟨hga, hgb, hgc⟩ := hall      have hT : (insert (1 : ZMod 55) ({a, b, c} : Finset (ZMod 55))).card = 4 := by        rw [Finset.card_insert_of_notMem, Finset.card_eq_three.2 ⟨a, b, c, hab, hac, hbc, rfl⟩]        intro h1m        simp only [Finset.mem_insert, Finset.mem_singleton] at h1m        rcases h1m with h | h | h <;> [exact Gs55Gap.one_not_eight (h ▸ ha); exact Gs55Gap.one_not_eight (h ▸ hb);          exact Gs55Gap.one_not_eight (h ▸ hc)]      have hB := key ((insert (1 : ZMod 55) ({a, b, c} : Finset (ZMod 55))).image (a0 * ·)) (by        intro x hx        obtain ⟨y, hy, rfl⟩ := Finset.mem_image.1 hx        simp only [Finset.mem_insert, Finset.mem_singleton] at hy        have hyu : IsUnit y := by          rcases hy with rfl | rfl | rfl | rfl          · exact isUnit_one          · exact (Gs55Gap.isUnit_iff_U _).2 (Gs55Gap.eight_sub ha)          · exact (Gs55Gap.isUnit_iff_U _).2 (Gs55Gap.eight_sub hb)          · exact (Gs55Gap.isUnit_iff_U _).2 (Gs55Gap.eight_sub hc)        refine ⟨ha0u.mul hyu, ?_⟩        rcases hy with rfl | rfl | rfl | rfl        · simpa using hni        · exact transfer _ hga        · exact transfer _ hgb        · exact transfer _ hgc)      rw [Finset.card_image_of_injective _ ha0u.mul_right_injective, hT] at hB      omega  · have hle := good_slopes_fiber55_nonunit_collision_gap S a0 ha0u p q hp hq hne hpq (by simpa [hd1] using hu1)    omega
See it in the graphDiscuss this resultChallenge it