AFTD Auto-Formalizing Theoretical Domains

good_slopes_prime5_three_good_lines

theoremverified

A set of five points in the plane over the field with five elements is a line if at least three finite directions are injective on it.

Statement

theorem good_slopes_prime5_three_good_lines
    (S : Finset (ZMod 5 × ZMod 5)) (G : Finset (ZMod 5))
    (hcard : S.card = 5) (hgood : 3 ≤ G.card)
    (hinj : ∀ a ∈ G, Set.InjOn (fun p : ZMod 5 × ZMod 5 => p.2 + a*p.1) S) :
    (∃ x : ZMod 5, ∀ p ∈ S, p.1 = x) ∨
      (∃ a t : ZMod 5, ∀ p ∈ S, p.2 + a*p.1 = t)
Source
Finite five-point direction classification for OP-1027, derived from the checked anchored certificate.
Verified
19 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 5
Used by 1

The proof, explained

The theorem is proved by contradiction: suppose a 5-point subset S ⊆ (ℤ/5ℤ)² with at least three injective directions is not contained in any line. We choose three non-collinear points in S as an affine basis to send S to a set S' containing (0,0), (1,0), and (0,1). The three injective directions transform into three injective directions on S' whose slopes form a set T ⊆ ℤ/5ℤ; since directions 0 and 1 are ruled out by the basis points, T must be exactly {2, 3, 4}. Applying the reflection τ(x, y) = (1 - x, -y) produces a 5-point set S'' containing (0,0), (1,4), and (1,0), still having 2, 3, and 4 as injective directions. By a prior classification of sets anchored at (0,0) and (1,4), all points in S'' must lie on the line y + x = 0, which contradicts (1,0) ∈ S''.

  1. In ℤ/5ℤ, the subset {2, 3, 4} has 3 elements, contains all elements other than 0 and 1, and -1 = 4. automation

    These elementary arithmetic and set-theoretic facts about the finite field ℤ/5ℤ are verified by exhaustive case-checking (`decide`).

    lines 3–7

    private theorem in962_prime5_card : ({2,3,4} : Finset (ZMod 5)).card = 3 := by decide
    private theorem in962_prime5_rem (a : ZMod 5) : a ≠ 0 → a ≠ 1 → a ∈ ({2,3,4} : Finset (ZMod 5)) := by
      revert a
      decide
    private theorem in962_prime5_negone : (-1 : ZMod 5) = 4 := by decide
  2. The affine coordinate transformation associated with three non-collinear points is injective.

    Given two points x, y with identical affine coordinates φ(x) = φ(y), their projections along any direction a, given by z ↦ z.2 + a * z.1, are expressed in terms of affine coordinates via `good_slopes_affine_coordinates_form`. Since φ(x) = φ(y), their projections agree for all a: x.2 + a * x.1 = y.2 + a * y.1. Specializing to a = 0 yields x.2 = y.2, and specializing to a = 1 yields x.2 + x.1 = y.2 + y.1. Subtracting the two gives x.1 = y.1, so x = y by `Prod.ext` using `congrArg`.

    lines 12–22

    uses good_slopes_affine_coordinates_form, congrArg, Prod.ext

      intro x y h
      have h1 := congrArg Prod.fst h
      have h2 := congrArg Prod.snd h
      have hf (a : K) : x.2+a*x.1 = y.2+a*y.1 := by
        rw [good_slopes_affine_coordinates_form u v w x a hd,
          good_slopes_affine_coordinates_form u v w y a hd, h1, h2]
      have h0 := hf 0
      have h1' := hf 1
      apply Prod.ext
      · linear_combination h1' - h0
      · simpa using h0
  3. For any two distinct points u, v in S, if all points of S were collinear with them, the line uv cannot be vertical.

    Since |S| > 1, there exist two distinct points u, v ∈ S by `Finset.one_lt_card.mp`. Assume for contradiction that every point w ∈ S is collinear with u and v. If v.1 - u.1 = 0, then v.2 - u.2 ≠ 0 because u ≠ v (`Prod.ext`, `sub_eq_zero.mp`). The collinearity relation then forces (w.1 - u.1) * (v.2 - u.2) = 0. Since v.2 - u.2 ≠ 0, we must have w.1 = u.1 for all w ∈ S (`mul_eq_zero.mp`), meaning S is contained in a vertical line, contradicting the hypothesis that S is not vertical.

    lines 30–44

    uses Finset.one_lt_card.mp, Prod.ext, sub_eq_zero.mp, mul_eq_zero.mp

      classical
      obtain ⟨u,hu,v,hv,huv⟩ := Finset.one_lt_card.mp hcard
      by_contra hex
      push Not at hex
      by_cases hx : v.1-u.1 = 0
      · have hy : v.2-u.2 ≠ 0 := by
          intro h
          apply huv
          exact Prod.ext (sub_eq_zero.mp hx).symm (sub_eq_zero.mp h).symm
        apply hnotv
        refine ⟨u.1, ?_⟩
        intro w hw
        have hw0 := hex u hu v hv w hw
        have hwx : (w.1-u.1)*(v.2-u.2) = 0 := by linear_combination -hw0 + (w.2-u.2)*hx
        exact sub_eq_zero.mp ((mul_eq_zero.mp hwx).resolve_right hy)
  4. Any set of at least two points not contained in any line contains three non-collinear points.

    In the remaining case where v.1 - u.1 ≠ 0, the line uv is non-vertical with slope -(v.2 - u.2)/(v.1 - u.1). The collinearity condition simplifies using `mul_right_inj'` to show that every w ∈ S satisfies the equation of this line. This contradicts the hypothesis that S is not contained in any non-vertical line. Thus, three non-collinear points u, v, w ∈ S must exist.

    lines 45–51

    uses mul_right_inj'

      · apply hnotl
        refine ⟨-(v.2-u.2)/(v.1-u.1), u.2 + (-(v.2-u.2)/(v.1-u.1))*u.1, ?_⟩
        intro w hw
        have hw0 := hex u hu v hv w hw
        apply (mul_right_inj' hx).mp
        field_simp
        linear_combination hw0
  5. Assuming S is not contained in any line, an affine coordinate change maps S to a 5-point set S' containing (0,0), (1,0), and (0,1).

    Assuming for contradiction that S is not contained in any line, `in9625_noncollinear` yields three non-collinear points u, v, w ∈ S. The affine coordinate map φ based on u, v, w is injective (`in9625_coords_injective`), so the transformed set S' = φ(S) has 5 points (`Finset.card_image_of_injective`). By `good_slopes_affine_coordinates_anchors`, φ maps u, v, w to (0,0), (1,0), (0,1) ∈ S' via `Finset.mem_image.mpr`. Moreover, non-collinearity ensures u ≠ v and u ≠ w.

    lines 59–82

    uses in9625_noncollinear, in9625_coords_injective, Finset.card_image_of_injective, good_slopes_affine_coordinates_anchors, Finset.mem_image.mpr

      classical
      haveI : Fact (Nat.Prime 5) := ⟨by decide⟩
      by_contra hnot
      have hnotv : ¬ ∃ x : ZMod 5, ∀ p ∈ S, p.1 = x := fun h => hnot (Or.inl h)
      have hnotl : ¬ ∃ a t : ZMod 5, ∀ p ∈ S, p.2+a*p.1 = t := fun h => hnot (Or.inr h)
      obtain ⟨u,hu,v,hv,w,hw,hd⟩ := in9625_noncollinear S (by omega) hnotv hnotl
      let φ := good_slopes_affine_coordinates u v w
      have hφ : Function.Injective φ := in9625_coords_injective u v w hd
      let S' := S.image φ
      have hS' : S'.card = 5 := by
        dsimp [S']
        rw [Finset.card_image_of_injective _ hφ, hcard]
      obtain ⟨h0,h1,h2⟩ := good_slopes_affine_coordinates_anchors u v w hd
      have hu' : ((0 : ZMod 5), 0) ∈ S' := Finset.mem_image.mpr ⟨u,hu,h0⟩
      have hv' : ((1 : ZMod 5), 0) ∈ S' := Finset.mem_image.mpr ⟨v,hv,h1⟩
      have hw' : ((0 : ZMod 5), 1) ∈ S' := Finset.mem_image.mpr ⟨w,hw,h2⟩
      have huv : u ≠ v := by
        intro he
        subst v
        simp at hd
      have huw : u ≠ w := by
        intro he
        subst w
        simp at hd
  6. The slope transformation ψ(a) = α(a) / β(a) is injective on G, yielding a set T ⊆ ℤ/5ℤ of at least three transformed slopes.

    For each a, define α(a) = v.2 - u.2 + a * (v.1 - u.1) and β(a) = w.2 - u.2 + a * (w.1 - u.1). For a ∈ G, both α(a) and β(a) are non-zero, since if either were zero, injectivity of p ↦ p.2 + a * p.1 on S would force u = v or u = w. The slope mapping ψ(a) = α(a) / β(a) is injective on G by `good_slopes_affine_slope_fractional_injective`. Its image T = ψ(G) therefore has |T| = |G| ≥ 3 by `Finset.card_image_of_injOn`.

    lines 83–107

    uses good_slopes_affine_slope_fractional_injective, Finset.card_image_of_injOn

      let α (a : ZMod 5) := v.2-u.2+a*(v.1-u.1)
      let β (a : ZMod 5) := w.2-u.2+a*(w.1-u.1)
      have hα (a : ZMod 5) (ha : a ∈ G) : α a ≠ 0 := by
        intro hz
        apply huv
        apply hinj a ha hu hv
        dsimp [α] at hz
        linear_combination -hz
      have hβ (a : ZMod 5) (ha : a ∈ G) : β a ≠ 0 := by
        intro hz
        apply huw
        apply hinj a ha hu hw
        dsimp [β] at hz
        linear_combination -hz
      let ψ (a : ZMod 5) := α a / β a
      have hψ : Set.InjOn ψ G := by
        intro a ha b hb heq
        exact good_slopes_affine_slope_fractional_injective
          (v.1-u.1) (v.2-u.2) (w.1-u.1) (w.2-u.2) a b hd
          (hβ a ha) (hβ b hb) heq
      let T : Finset (ZMod 5) := G.image ψ
      have hTcard : 3 ≤ T.card := by
        dsimp [T]
        rw [Finset.card_image_of_injOn hψ]
        exact hgood
  7. Every transformed slope in T is non-zero, and the corresponding direction is injective on S'.

    If 0 ∈ T, then ψ(b) = 0 for some b ∈ G, which by `div_eq_zero_iff` implies α(b) = 0, contradiction; thus 0 ∉ T. Furthermore, for any a = ψ(b) ∈ T and points x', y' ∈ S' coming from x, y ∈ S via `Finset.mem_image.mp`, the condition x'.2 + a * x'.1 = y'.2 + a * y'.1 rescales by β(b) using `good_slopes_affine_coordinates_form`, `mul_add`, and `mul_assoc` to x.2 + b * x.1 = y.2 + b * y.1. Injectivity of slope b on S gives x = y, which via `congrArg` implies x' = y'.

    lines 108–128

    uses Finset.mem_image.mp, div_eq_zero_iff, congrArg, good_slopes_affine_coordinates_form, mul_add, mul_assoc

      have hTzero : (0 : ZMod 5) ∉ T := by
        intro hz
        obtain ⟨a,ha,heq⟩ := Finset.mem_image.mp hz
        have := (div_eq_zero_iff).mp (by simpa [ψ] using heq)
        exact hα a ha (this.resolve_right (hβ a ha))
      have hTin : ∀ a ∈ T, Set.InjOn (fun p : ZMod 5 × ZMod 5 => p.2 + a*p.1) S' := by
        intro a ha x hx y hy heq
        obtain ⟨b,hb,rfl⟩ := Finset.mem_image.mp ha
        obtain ⟨x,hx0,rfl⟩ := Finset.mem_image.mp hx
        obtain ⟨y,hy0,rfl⟩ := Finset.mem_image.mp hy
        apply congrArg φ
        apply hinj b hb hx0 hy0
        have hxform := good_slopes_affine_coordinates_form u v w x b hd
        have hyform := good_slopes_affine_coordinates_form u v w y b hd
        change x.2+b*x.1 = u.2+b*u.1 + α b*(φ x).1 + β b*(φ x).2 at hxform
        change y.2+b*y.1 = u.2+b*u.1 + α b*(φ y).1 + β b*(φ y).2 at hyform
        change (φ x).2 + (α b / β b)*(φ x).1 = (φ y).2 + (α b / β b)*(φ y).1 at heq
        have hs := congrArg (fun z : ZMod 5 => β b * z) heq
        have hcancel : β b * (α b / β b) = α b := by field_simp [hβ b hb]
        simp only [mul_add, ← mul_assoc, hcancel] at hs
        linear_combination hxform - hyform + hs
  8. The slope 1 is not in T, forcing T = {2, 3, 4}.

    If 1 were in T, then (x, y) ↦ y + x would be injective on S'. However, both (1,0) and (0,1) belong to S' and evaluate to 1 under this map, which would force (1,0) = (0,1), an immediate contradiction on the first coordinate via `congrArg`. Since 0 ∉ T and 1 ∉ T, every element of T belongs to {2, 3, 4} by `in962_prime5_rem`. As |T| ≥ 3 and |{2, 3, 4}| = 3 (`in962_prime5_card`), we conclude T = {2, 3, 4} by `Finset.eq_of_subset_of_card_le`.

    lines 129–142

    uses congrArg, in962_prime5_rem, in962_prime5_card, Finset.eq_of_subset_of_card_le

      have hTone : (1 : ZMod 5) ∉ T := by
        intro h
        have he : (((1 : ZMod 5),0) : ZMod 5 × ZMod 5) = (0,1) := hTin 1 h hv' hw' (by norm_num)
        have hh := congrArg Prod.fst he
        norm_num at hh
      have hTsub : T ⊆ ({2,3,4} : Finset (ZMod 5)) := by
        intro a ha
        have ha0 : a ≠ 0 := by intro h; apply hTzero; simpa [h] using ha
        have ha1 : a ≠ 1 := by intro h; apply hTone; simpa [h] using ha
        exact in962_prime5_rem a ha0 ha1
      have hTcard3 : ({2,3,4} : Finset (ZMod 5)).card = 3 := in962_prime5_card
      have hTeq : T = ({2,3,4} : Finset (ZMod 5)) := by
        apply Finset.eq_of_subset_of_card_le hTsub
        omega
  9. The affine transformation τ(x, y) = (1 - x, -y) maps S' to a 5-point set S'' containing (0,0), (1,4), and (1,0).

    The map τ(z) = (1 - z.1, -z.2) is injective (`Prod.ext`, `congrArg`), so S'' = τ(S') has 5 points by `Finset.card_image_of_injective`. Applying τ to the known points of S' via `Finset.mem_image.mpr`: (1,0) ↦ (0,0) ∈ S'', (0,1) ↦ (1,-1) = (1,4) ∈ S'' because -1 = 4 in ℤ/5ℤ (`in962_prime5_negone`), and (0,0) ↦ (1,0) ∈ S''.

    lines 143–167

    uses congrArg, Prod.ext, Finset.card_image_of_injective, Finset.mem_image.mpr, in962_prime5_negone

      let τ (z : ZMod 5 × ZMod 5) : ZMod 5 × ZMod 5 := (1-z.1,-z.2)
      have hτ : Function.Injective τ := by
        intro x y h
        have hx := congrArg Prod.fst h
        have hy := congrArg Prod.snd h
        dsimp [τ] at hx hy
        apply Prod.ext
        · linear_combination -hx
        · linear_combination -hy
      let S'' := S'.image τ
      have hS'' : S''.card = 5 := by
        dsimp [S'']
        rw [Finset.card_image_of_injective _ hτ, hS']
      have h0'' : ((0 : ZMod 5),0) ∈ S'' := by
        apply Finset.mem_image.mpr
        refine ⟨((1 : ZMod 5),0),hv', ?_⟩
        simp [τ, in962_prime5_negone]
      have h1'' : ((1 : ZMod 5),4) ∈ S'' := by
        apply Finset.mem_image.mpr
        refine ⟨((0 : ZMod 5),1),hw', ?_⟩
        simp [τ, in962_prime5_negone]
      have hu'' : ((1 : ZMod 5),0) ∈ S'' := by
        apply Finset.mem_image.mpr
        refine ⟨((0 : ZMod 5),0),hu', ?_⟩
        norm_num [τ]
  10. Directions 2, 3, 4 are injective on S'', forcing all points of S'' to satisfy p.2 + p.1 = 0, which contradicts (1,0) ∈ S''.

    For each c ∈ T, the projection z ↦ z.2 + c * z.1 on S'' pulls back under τ to a linear transformation of y ↦ y.2 + c * y.1 on S', hence is injective (`Finset.mem_image.mp`, `congrArg`). Since T = {2, 3, 4}, directions 2, 3, and 4 are injective on S''. By `good_slopes_prime5_anchored_line`, any 5-point set containing (0,0) and (1,4) with injective directions 2, 3, 4 must lie entirely on the line p.2 + p.1 = 0. Evaluating this condition at (1,0) ∈ S'' gives 0 + 1 = 0, a contradiction.

    lines 168–181

    uses Finset.mem_image.mp, congrArg, good_slopes_prime5_anchored_line

      have hg'' (c : ZMod 5) (hc : c ∈ T) : Set.InjOn (fun z : ZMod 5 × ZMod 5 => z.2+c*z.1) S'' := by
        intro x hx y hy he
        obtain ⟨x,hx0,rfl⟩ := Finset.mem_image.mp hx
        obtain ⟨y,hy0,rfl⟩ := Finset.mem_image.mp hy
        apply congrArg τ
        apply hTin c hc hx0 hy0
        dsimp [τ] at he
        linear_combination -he
      have ht2 : (2 : ZMod 5) ∈ T := by rw [hTeq]; norm_num
      have ht3 : (3 : ZMod 5) ∈ T := by rw [hTeq]; norm_num
      have ht4 : (4 : ZMod 5) ∈ T := by rw [hTeq]; norm_num
      have hline := good_slopes_prime5_anchored_line S'' hS'' h0'' h1'' (hg'' 2 ht2) (hg'' 3 ht3) (hg'' 4 ht4)
      have habs := hline ((1 : ZMod 5),0) hu''
      norm_num at habs
in962_prime5_card
The set {2, 3, 4} in ℤ/5ℤ has cardinality 3.
in962_prime5_rem
Any element of ℤ/5ℤ other than 0 and 1 belongs to {2, 3, 4}.
in962_prime5_negone
In ℤ/5ℤ, -1 equals 4.
good_slopes_affine_coordinates_form
For non-collinear u, v, w, the functional z ↦ z.2 + a * z.1 expands in affine coordinates as u.2 + a * u.1 + α(a) * φ(z).1 + β(a) * φ(z).2.
congrArg
Applying a function to equal arguments produces equal results: x = y implies f x = f y.
Prod.ext
Two pairs are equal if and only if their first components are equal and their second components are equal.
Finset.one_lt_card.mp
A finite set with cardinality strictly greater than 1 contains at least two distinct elements.
sub_eq_zero.mp
If a - b = 0, then a = b.
mul_eq_zero.mp
If a * b = 0 in a domain, then a = 0 or b = 0.
mul_right_inj'
In a structure where non-zero multiplication cancels, multiplying on the right by a non-zero element is injective: if a ≠ 0, then b * a = c * a implies b = c.
in9625_noncollinear
Any finite set of at least two points in a plane not contained in any vertical line nor any non-vertical line contains three non-collinear points.
in9625_coords_injective
For three non-collinear points, the affine coordinate map is injective.
Finset.card_image_of_injective
The image of a finite set under an injective function has the same cardinality as the domain set.
good_slopes_affine_coordinates_anchors
The affine coordinate map based at u, v, w sends u to (0,0), v to (1,0), and w to (0,1).
Finset.mem_image.mpr
If a ∈ S and f a = b, then b is in the image of S under f.
good_slopes_affine_slope_fractional_injective
For non-collinear points, the fractional linear slope transformation ψ(a) = (dyv + a * dxv) / (dyw + a * dxw) is injective on all slopes where the denominator is non-zero.
Finset.card_image_of_injOn
If a function is injective on a finite set S, the cardinality of its image equals the cardinality of S.
Finset.mem_image.mp
If b is in the image of S under f, there exists a ∈ S such that f a = b.
div_eq_zero_iff
In a field or group with zero, a / b = 0 if and only if a = 0 or b = 0.
mul_add
Multiplication distributes over addition on the left: a * (b + c) = a * b + a * c.
mul_assoc
Multiplication is associative: (a * b) * c = a * (b * c).
Finset.eq_of_subset_of_card_le
If S ⊆ T between finite sets and |T| ≤ |S|, then S = T.
good_slopes_prime5_anchored_line
Any 5-point subset of (ℤ/5ℤ)² containing (0,0) and (1,4) on which the directions 2, 3, and 4 are injective satisfies p.2 + p.1 = 0 for all its points.

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_prime5_card : ({2,3,4} : Finset (ZMod 5)).card = 3 := by decideprivate theorem in962_prime5_rem (a : ZMod 5) : a ≠ 0 → a ≠ 1 → a ∈ ({2,3,4} : Finset (ZMod 5)) := by  revert a  decideprivate theorem in962_prime5_negone : (-1 : ZMod 5) = 4 := by decideprivate theorem in9625_coords_injective {K : Type*} [Field K] (u v w : K × K)    (hd : (v.1-u.1)*(w.2-u.2)-(w.1-u.1)*(v.2-u.2) ≠ 0) :    Function.Injective (good_slopes_affine_coordinates u v w) := by  intro x y h  have h1 := congrArg Prod.fst h  have h2 := congrArg Prod.snd h  have hf (a : K) : x.2+a*x.1 = y.2+a*y.1 := by    rw [good_slopes_affine_coordinates_form u v w x a hd,      good_slopes_affine_coordinates_form u v w y a hd, h1, h2]  have h0 := hf 0  have h1' := hf 1  apply Prod.ext  · linear_combination h1' - h0  · simpa using h0private theorem in9625_noncollinear {K : Type*} [Field K] [DecidableEq K]    (S : Finset (K × K)) (hcard : 1 < S.card)    (hnotv : ¬ ∃ x : K, ∀ p ∈ S, p.1 = x)    (hnotl : ¬ ∃ a t : K, ∀ p ∈ S, p.2 + a*p.1 = t) :    ∃ u ∈ S, ∃ v ∈ S, ∃ w ∈ S,      (v.1-u.1)*(w.2-u.2)-(w.1-u.1)*(v.2-u.2) ≠ 0 := by  classical  obtain ⟨u,hu,v,hv,huv⟩ := Finset.one_lt_card.mp hcard  by_contra hex  push Not at hex  by_cases hx : v.1-u.1 = 0  · have hy : v.2-u.2 ≠ 0 := by      intro h      apply huv      exact Prod.ext (sub_eq_zero.mp hx).symm (sub_eq_zero.mp h).symm    apply hnotv    refine ⟨u.1, ?_⟩    intro w hw    have hw0 := hex u hu v hv w hw    have hwx : (w.1-u.1)*(v.2-u.2) = 0 := by linear_combination -hw0 + (w.2-u.2)*hx    exact sub_eq_zero.mp ((mul_eq_zero.mp hwx).resolve_right hy)  · apply hnotl    refine ⟨-(v.2-u.2)/(v.1-u.1), u.2 + (-(v.2-u.2)/(v.1-u.1))*u.1, ?_⟩    intro w hw    have hw0 := hex u hu v hv w hw    apply (mul_right_inj' hx).mp    field_simp    linear_combination hw0theorem good_slopes_prime5_three_good_lines    (S : Finset (ZMod 5 × ZMod 5)) (G : Finset (ZMod 5))    (hcard : S.card = 5) (hgood : 3 ≤ G.card)    (hinj : ∀ a ∈ G, Set.InjOn (fun p : ZMod 5 × ZMod 5 => p.2 + a*p.1) S) :    (∃ x : ZMod 5, ∀ p ∈ S, p.1 = x) ∨      (∃ a t : ZMod 5, ∀ p ∈ S, p.2 + a*p.1 = t) := by  classical  haveI : Fact (Nat.Prime 5) := ⟨by decide⟩  by_contra hnot  have hnotv : ¬ ∃ x : ZMod 5, ∀ p ∈ S, p.1 = x := fun h => hnot (Or.inl h)  have hnotl : ¬ ∃ a t : ZMod 5, ∀ p ∈ S, p.2+a*p.1 = t := fun h => hnot (Or.inr h)  obtain ⟨u,hu,v,hv,w,hw,hd⟩ := in9625_noncollinear S (by omega) hnotv hnotl  let φ := good_slopes_affine_coordinates u v w  have hφ : Function.Injective φ := in9625_coords_injective u v w hd  let S' := S.image φ  have hS' : S'.card = 5 := by    dsimp [S']    rw [Finset.card_image_of_injective _ hφ, hcard]  obtain ⟨h0,h1,h2⟩ := good_slopes_affine_coordinates_anchors u v w hd  have hu' : ((0 : ZMod 5), 0) ∈ S' := Finset.mem_image.mpr ⟨u,hu,h0⟩  have hv' : ((1 : ZMod 5), 0) ∈ S' := Finset.mem_image.mpr ⟨v,hv,h1⟩  have hw' : ((0 : ZMod 5), 1) ∈ S' := Finset.mem_image.mpr ⟨w,hw,h2⟩  have huv : u ≠ v := by    intro he    subst v    simp at hd  have huw : u ≠ w := by    intro he    subst w    simp at hd  let α (a : ZMod 5) := v.2-u.2+a*(v.1-u.1)  let β (a : ZMod 5) := w.2-u.2+a*(w.1-u.1)  have hα (a : ZMod 5) (ha : a ∈ G) : α a ≠ 0 := by    intro hz    apply huv    apply hinj a ha hu hv    dsimp [α] at hz    linear_combination -hz  have hβ (a : ZMod 5) (ha : a ∈ G) : β a ≠ 0 := by    intro hz    apply huw    apply hinj a ha hu hw    dsimp [β] at hz    linear_combination -hz  let ψ (a : ZMod 5) := α a / β a  have hψ : Set.InjOn ψ G := by    intro a ha b hb heq    exact good_slopes_affine_slope_fractional_injective      (v.1-u.1) (v.2-u.2) (w.1-u.1) (w.2-u.2) a b hd      (hβ a ha) (hβ b hb) heq  let T : Finset (ZMod 5) := G.image ψ  have hTcard : 3 ≤ T.card := by    dsimp [T]    rw [Finset.card_image_of_injOn hψ]    exact hgood  have hTzero : (0 : ZMod 5) ∉ T := by    intro hz    obtain ⟨a,ha,heq⟩ := Finset.mem_image.mp hz    have := (div_eq_zero_iff).mp (by simpa [ψ] using heq)    exact hα a ha (this.resolve_right (hβ a ha))  have hTin : ∀ a ∈ T, Set.InjOn (fun p : ZMod 5 × ZMod 5 => p.2 + a*p.1) S' := by    intro a ha x hx y hy heq    obtain ⟨b,hb,rfl⟩ := Finset.mem_image.mp ha    obtain ⟨x,hx0,rfl⟩ := Finset.mem_image.mp hx    obtain ⟨y,hy0,rfl⟩ := Finset.mem_image.mp hy    apply congrArg φ    apply hinj b hb hx0 hy0    have hxform := good_slopes_affine_coordinates_form u v w x b hd    have hyform := good_slopes_affine_coordinates_form u v w y b hd    change x.2+b*x.1 = u.2+b*u.1 + α b*(φ x).1 + β b*(φ x).2 at hxform    change y.2+b*y.1 = u.2+b*u.1 + α b*(φ y).1 + β b*(φ y).2 at hyform    change (φ x).2 + (α b / β b)*(φ x).1 = (φ y).2 + (α b / β b)*(φ y).1 at heq    have hs := congrArg (fun z : ZMod 5 => β b * z) heq    have hcancel : β b * (α b / β b) = α b := by field_simp [hβ b hb]    simp only [mul_add, ← mul_assoc, hcancel] at hs    linear_combination hxform - hyform + hs  have hTone : (1 : ZMod 5) ∉ T := by    intro h    have he : (((1 : ZMod 5),0) : ZMod 5 × ZMod 5) = (0,1) := hTin 1 h hv' hw' (by norm_num)    have hh := congrArg Prod.fst he    norm_num at hh  have hTsub : T ⊆ ({2,3,4} : Finset (ZMod 5)) := by    intro a ha    have ha0 : a ≠ 0 := by intro h; apply hTzero; simpa [h] using ha    have ha1 : a ≠ 1 := by intro h; apply hTone; simpa [h] using ha    exact in962_prime5_rem a ha0 ha1  have hTcard3 : ({2,3,4} : Finset (ZMod 5)).card = 3 := in962_prime5_card  have hTeq : T = ({2,3,4} : Finset (ZMod 5)) := by    apply Finset.eq_of_subset_of_card_le hTsub    omega  let τ (z : ZMod 5 × ZMod 5) : ZMod 5 × ZMod 5 := (1-z.1,-z.2)  have hτ : Function.Injective τ := by    intro x y h    have hx := congrArg Prod.fst h    have hy := congrArg Prod.snd h    dsimp [τ] at hx hy    apply Prod.ext    · linear_combination -hx    · linear_combination -hy  let S'' := S'.image τ  have hS'' : S''.card = 5 := by    dsimp [S'']    rw [Finset.card_image_of_injective _ hτ, hS']  have h0'' : ((0 : ZMod 5),0) ∈ S'' := by    apply Finset.mem_image.mpr    refine ⟨((1 : ZMod 5),0),hv', ?_⟩    simp [τ, in962_prime5_negone]  have h1'' : ((1 : ZMod 5),4) ∈ S'' := by    apply Finset.mem_image.mpr    refine ⟨((0 : ZMod 5),1),hw', ?_⟩    simp [τ, in962_prime5_negone]  have hu'' : ((1 : ZMod 5),0) ∈ S'' := by    apply Finset.mem_image.mpr    refine ⟨((0 : ZMod 5),0),hu', ?_⟩    norm_num [τ]  have hg'' (c : ZMod 5) (hc : c ∈ T) : Set.InjOn (fun z : ZMod 5 × ZMod 5 => z.2+c*z.1) S'' := by    intro x hx y hy he    obtain ⟨x,hx0,rfl⟩ := Finset.mem_image.mp hx    obtain ⟨y,hy0,rfl⟩ := Finset.mem_image.mp hy    apply congrArg τ    apply hTin c hc hx0 hy0    dsimp [τ] at he    linear_combination -he  have ht2 : (2 : ZMod 5) ∈ T := by rw [hTeq]; norm_num  have ht3 : (3 : ZMod 5) ∈ T := by rw [hTeq]; norm_num  have ht4 : (4 : ZMod 5) ∈ T := by rw [hTeq]; norm_num  have hline := good_slopes_prime5_anchored_line S'' hS'' h0'' h1'' (hg'' 2 ht2) (hg'' 3 ht3) (hg'' 4 ht4)  have habs := hline ((1 : ZMod 5),0) hu''  norm_num at habs
See it in the graphDiscuss this resultChallenge it