AFTD Auto-Formalizing Theoretical Domains

craig_shell_size_k_one

theoremverifiedformalization

For any prime p, the number of shortest nonzero vectors of Euclidean norm √2 in Craig's lattice A_{p-1}^1 is p * (p - 1).

Statement

theorem craig_shell_size_k_one (p : ℕ) (hp : Nat.Prime p) : craig_shell_size p 1 = p * (p - 1)
Formalizes
arXiv:2611.22441 Eq. (7)
Verified
20 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
  • craig_shell_sizeFor natural numbers p and k, craig_shell_size p k is the number of pairs of disjoint k-element subsets of Fin p whose elements have…

Read back from the Lean

For every natural number $p$, if $p$ is prime, then craig_shell_size p 1 equals $p(p - 1)$.

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 definition `craig_shell_size p 1` counts pairs of disjoint subsets (S1, S2) of Fin p of size 1 satisfying a power-sum condition for indices 1 ≤ r < 1. Because the condition on r is vacuous, this simply counts pairs of disjoint singletons ({x}, {y}). The proof constructs an explicit bijection between such pairs and the off-diagonal pairs (x, y) with x ≠ y in Fin p × Fin p, whose cardinality is calculated algebraically as p * (p - 1).

  1. The off-diagonal of `Finset.univ : Finset (Fin p)` has cardinality p * (p - 1).

    By `Finset.offDiag_card`, the number of distinct pairs in a finite set s is |s| * |s| - |s|. Since `Fin p` has p elements (by `Finset.card_univ` and `Fintype.card_fin`), this simplifies to p * p - p * 1 = p * (p - 1) using left distributivity (`Nat.mul_sub_left_distrib`) and `mul_one`. The primality hypothesis `hp` is noted on line 3 but not used in the calculation.

    lines 3–5

    uses Finset.offDiag_card, Finset.card_univ, Fintype.card_fin, Nat.mul_sub_left_distrib, mul_one

      have _ := hp
      have h_card : (Finset.offDiag (Finset.univ : Finset (Fin p))).card = p * (p - 1) := by
        rw [Finset.offDiag_card, Finset.card_univ, Fintype.card_fin, Nat.mul_sub_left_distrib, mul_one]
  2. It suffices to exhibit a bijection (x, y) ↦ ({x}, {y}) between the off-diagonal of `Fin p` and the set of pairs defining `craig_shell_size p 1`.

    We rewrite p * (p - 1) as the cardinality of the off-diagonal via `h_card`, unfold the definition of `craig_shell_size p 1`, and swap the equality. By `Finset.card_bij`, two finite sets have the same size if there is a well-defined, injective, and surjective map between them; we choose the map sending each pair of distinct indices (x, y) to the pair of singletons ({x}, {y}).

    lines 6–9

    uses Finset.card_bij

      rw [← h_card]
      dsimp [craig_shell_size]
      symm
      apply Finset.card_bij (fun ⟨x, y⟩ _ => ({x}, {y}))
  3. The map (x, y) ↦ ({x}, {y}) sends every off-diagonal pair into the target set.

    For any pair (x, y) with x ≠ y from `Finset.mem_offDiag`, the singletons {x} and {y} are subsets of the universe and each has cardinality 1 (by `Finset.card_singleton`). They are disjoint because x ≠ y (using `Finset.disjoint_singleton_left` and `Finset.mem_singleton`). The required power-sum condition for 1 ≤ r < 1 is vacuously satisfied, as closed by linear arithmetic (`omega`) because no natural number satisfies 1 ≤ r and r < 1.

    lines 10–17

    uses Finset.mem_offDiag, Finset.mem_filter, Finset.mem_product, Finset.mem_powerset, Finset.subset_univ, and_true, Finset.card_singleton, true_and, Finset.disjoint_singleton_left, Finset.mem_singleton

      · intro ⟨x, y⟩ hxy
        rw [Finset.mem_offDiag] at hxy
        dsimp at hxy
        simp only [Finset.mem_filter, Finset.mem_product, Finset.mem_powerset, Finset.subset_univ, and_true,
          Finset.card_singleton, true_and]
        refine ⟨?_, fun r hr1 hr2 => by omega⟩
        rw [Finset.disjoint_singleton_left, Finset.mem_singleton]
        exact hxy.2.2
  4. The map (x, y) ↦ ({x}, {y}) is injective.

    If ({x1}, {y1}) = ({x2}, {y2}), then {x1} = {x2} and {y1} = {y2}. Since singletons are equal if and only if their elements are equal (`Finset.singleton_inj`), it follows that x1 = x2 and y1 = y2, meaning (x1, y1) = (x2, y2).

    lines 18–21

    uses Finset.singleton_inj

      · intro ⟨x1, y1⟩ _ ⟨x2, y2⟩ _ h
        injection h with h1 h2
        rw [Finset.singleton_inj] at h1 h2
        rw [h1, h2]
  5. The map (x, y) ↦ ({x}, {y}) is surjective onto the target set.

    Every element in the target set is a pair of subsets (S1, S2) of `Fin p` where |S1| = 1, |S2| = 1, and S1 and S2 are disjoint. By `Finset.card_eq_one`, S1 = {x} and S2 = {y} for some x, y ∈ `Fin p`. Because {x} and {y} are disjoint, x cannot equal y (otherwise {x} being disjoint from {x} implies x ∉ {x}, a contradiction). Hence (x, y) is in the off-diagonal and maps directly to (S1, S2).

    lines 22–35

    uses Finset.mem_filter, Finset.mem_product, Finset.mem_powerset, Finset.card_eq_one, Finset.mem_offDiag, Finset.mem_univ, Finset.disjoint_singleton_left, Finset.mem_singleton

      · rintro ⟨S1, S2⟩ hS
        simp only [Finset.mem_filter, Finset.mem_product, Finset.mem_powerset] at hS
        rcases hS with ⟨-, h1, h2, hdisj, -⟩
        rw [Finset.card_eq_one] at h1 h2
        rcases h1 with ⟨x, rfl⟩
        rcases h2 with ⟨y, rfl⟩
        refine ⟨⟨x, y⟩, ?_, rfl⟩
        rw [Finset.mem_offDiag]
        dsimp
        refine ⟨Finset.mem_univ _, Finset.mem_univ _, ?_⟩
        intro hxy
        subst hxy
        simp only [Finset.disjoint_singleton_left, Finset.mem_singleton] at hdisj
        exact hdisj trivial
Finset.offDiag_card
The number of pairs of distinct elements in a finite set s is |s| * |s| - |s|.
Finset.card_univ
The universal finset `Finset.univ` of a finite type has cardinality equal to the cardinality of the type.
Fintype.card_fin
The finite type `Fin n` has cardinality n.
Nat.mul_sub_left_distrib
Multiplication of natural numbers distributes over subtraction on the left: n * (m - k) = n * m - n * k.
mul_one
Multiplying by 1 on the right leaves an element unchanged: a * 1 = a.
Finset.card_bij
Two finite sets have equal cardinality if there exists a well-defined map between them that is injective and surjective.
Finset.mem_offDiag
An ordered pair (x, y) belongs to the off-diagonal of s if and only if x ∈ s, y ∈ s, and x ≠ y.
Finset.mem_filter
An element belongs to a filtered finset if and only if it belongs to the base set and satisfies the filtering predicate.
Finset.mem_product
An ordered pair belongs to the Cartesian product s × t if and only if its first element is in s and its second is in t.
Finset.mem_powerset
A finset belongs to the powerset of s if and only if it is a subset of s.
Finset.subset_univ
Every finset of elements of a finite type is a subset of the universal finset `Finset.univ`.
and_true
Conjoining any proposition with `True` is equivalent to the proposition itself: (p ∧ True) = p.
Finset.card_singleton
The cardinality of any singleton finset {a} is 1.
true_and
Conjoining `True` with any proposition is equivalent to the proposition itself: (True ∧ p) = p.
Finset.disjoint_singleton_left
The singleton finset {a} is disjoint from a finset s if and only if a ∉ s.
Finset.mem_singleton
An element b belongs to the singleton finset {a} if and only if b = a.
Finset.singleton_inj
Two singleton finsets {a} and {b} are equal if and only if a = b.
Finset.card_eq_one
A finset has cardinality 1 if and only if it is a singleton {a} for some element a.
Finset.mem_univ
Every element of a finite type belongs to the universal finset `Finset.univ`.

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

/-- For any prime p, the shortest vector shell size of Craig's lattice for k = 1 is p * (p - 1). -/theorem craig_shell_size_k_one (p : ℕ) (hp : Nat.Prime p) : craig_shell_size p 1 = p * (p - 1) := by  have _ := hp  have h_card : (Finset.offDiag (Finset.univ : Finset (Fin p))).card = p * (p - 1) := by    rw [Finset.offDiag_card, Finset.card_univ, Fintype.card_fin, Nat.mul_sub_left_distrib, mul_one]  rw [← h_card]  dsimp [craig_shell_size]  symm  apply Finset.card_bij (fun ⟨x, y⟩ _ => ({x}, {y}))  · intro ⟨x, y⟩ hxy    rw [Finset.mem_offDiag] at hxy    dsimp at hxy    simp only [Finset.mem_filter, Finset.mem_product, Finset.mem_powerset, Finset.subset_univ, and_true,      Finset.card_singleton, true_and]    refine ⟨?_, fun r hr1 hr2 => by omega⟩    rw [Finset.disjoint_singleton_left, Finset.mem_singleton]    exact hxy.2.2  · intro ⟨x1, y1⟩ _ ⟨x2, y2⟩ _ h    injection h with h1 h2    rw [Finset.singleton_inj] at h1 h2    rw [h1, h2]  · rintro ⟨S1, S2⟩ hS    simp only [Finset.mem_filter, Finset.mem_product, Finset.mem_powerset] at hS    rcases hS with ⟨-, h1, h2, hdisj, -⟩    rw [Finset.card_eq_one] at h1 h2    rcases h1 with ⟨x, rfl⟩    rcases h2 with ⟨y, rfl⟩    refine ⟨⟨x, y⟩, ?_, rfl⟩    rw [Finset.mem_offDiag]    dsimp    refine ⟨Finset.mem_univ _, Finset.mem_univ _, ?_⟩    intro hxy    subst hxy    simp only [Finset.disjoint_singleton_left, Finset.mem_singleton] at hdisj    exact hdisj trivial
See it in the graphDiscuss this resultChallenge it