AFTD Auto-Formalizing Theoretical Domains

card_affine_line

theoremverified

Let p be a prime. For any point P and nonzero direction vector v in (ZMod p)^3, the affine line through P in direction v has cardinality p.

Statement

theorem card_affine_line (p : ℕ) [Fact p.Prime] (P v : Fin 3 → ZMod p) (hv : v ≠ 0) :
    (affine_line P v).ncard = p
Source
arXiv:2611.12153 Section 2
Verified
11 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
  • affine_lineFor a natural number p, the affine line in (ZMod p)^3 through a point P in direction v is the set of points x such that x = P + t • v for…

Read back from the Lean

For every natural number $p$ such that $p$ is prime, and for all vectors $P, v : \mathrm{Fin}\ 3 \to \mathbb{Z}/p\mathbb{Z}$, if $v \neq 0$, then the set affine_line P v has cardinality (Set.ncard) equal to $p$.

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 affine line through P with direction v is expressed as the range of the parameterization t ↦ P + t • v for t in ℤ/pℤ. Because p is prime and v ≠ 0, scalar multiplication has no non-trivial zero divisors, which makes this parameterization injective. The cardinality of the line is therefore the cardinality of the domain ℤ/pℤ, which is p.

  1. The parameterization t ↦ P + t • v from ℤ/pℤ to (ℤ/pℤ)³ is injective.

    Suppose P + a • v = P + b • v for scalars a, b in ℤ/pℤ. Canceling P from both sides gives a • v = b • v, which subtracts to (a - b) • v = 0. Since p is prime, ℤ/pℤ is a field and (ℤ/pℤ)³ is a vector space, where scalar multiplication has no zero divisors: either a - b = 0 or v = 0. Because v is assumed to be nonzero, we have a - b = 0, which implies a = b.

    lines 4–12

    uses add_right_inj, sub_smul, sub_self, smul_eq_zero.mp, sub_eq_zero.mp

      have hinj : Function.Injective (fun t : ZMod p => P + t • v) := by
        intro a b hab
        simp only [add_right_inj] at hab
        have h : (a - b) • v = 0 := by rw [sub_smul, hab, sub_self]
        have hz : a - b = 0 := by
          rcases smul_eq_zero.mp h with h' | h'
          · exact h'
          · exact absurd h' hv
        exact sub_eq_zero.mp hz
  2. The affine line through P with direction v is the range of the map t ↦ P + t • v.

    By definition, the affine line consists of all points x of the form P + t • v for some t in ℤ/pℤ. Unfolding the definition of set range and using the symmetry of equality shows that this is identical to the range of t ↦ P + t • v.

    lines 13–15

    uses Set.mem_range, eq_comm

      have hset : affine_line P v = Set.range (fun t : ZMod p => P + t • v) := by
        ext x
        simp [affine_line, Set.mem_range, eq_comm]
  3. The cardinality of the affine line is p.

    Expressing the line as the range of the injective parameterization, its cardinality is equal to the cardinality of the domain ℤ/pℤ. Since ℤ/pℤ has p elements, the affine line has cardinality p.

    lines 16–17

    uses Set.ncard_range_of_injective, Nat.card_eq_fintype_card, ZMod.card

      rw [hset, Set.ncard_range_of_injective hinj, Nat.card_eq_fintype_card]
      exact ZMod.card p
add_right_inj
In an additive group, adding an element to both sides preserves equivalence: a + b = a + c ↔ b = c.
sub_smul
Scalar multiplication distributes over scalar subtraction: (r - s) • y = r • y - s • y.
sub_self
Subtracting an element from itself yields zero: a - a = 0.
smul_eq_zero.mp
In a module over a field, if a scalar multiple of a vector is zero, then either the scalar is zero or the vector is zero.
sub_eq_zero.mp
If the difference of two elements is zero, then they are equal: a - b = 0 → a = b.
Set.mem_range
An element belongs to the range of a function f if and only if it equals f(y) for some y.
eq_comm
Equality is symmetric: a = b ↔ b = a.
Set.ncard_range_of_injective
The cardinality of the range of an injective function equals the cardinality of its domain.
Nat.card_eq_fintype_card
For a finite type, its cardinality as a natural number (`Nat.card`) equals its cardinality as a `Fintype`.
ZMod.card
The finite type ℤ/nℤ has cardinality n.

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

/-- An affine line in (ZMod p)^3 with nonzero direction vector has cardinality p. -/theorem card_affine_line (p : ℕ) [Fact p.Prime] (P v : Fin 3 → ZMod p) (hv : v ≠ 0) :    (affine_line P v).ncard = p := by  have hinj : Function.Injective (fun t : ZMod p => P + t • v) := by    intro a b hab    simp only [add_right_inj] at hab    have h : (a - b) • v = 0 := by rw [sub_smul, hab, sub_self]    have hz : a - b = 0 := by      rcases smul_eq_zero.mp h with h' | h'      · exact h'      · exact absurd h' hv    exact sub_eq_zero.mp hz  have hset : affine_line P v = Set.range (fun t : ZMod p => P + t • v) := by    ext x    simp [affine_line, Set.mem_range, eq_comm]  rw [hset, Set.ncard_range_of_injective hinj, Nat.card_eq_fintype_card]  exact ZMod.card p
See it in the graphDiscuss this resultChallenge it