AFTD Auto-Formalizing Theoretical Domains

ball_bearing_not_hamiltonian

theoremverifiedformalization

For any integer k ≥ 3, the Ball Bearing graph ballBearingGraph k contains no Hamiltonian cycle, that is, ¬ (ballBearingGraph k).IsHamiltonian.

Statement

theorem ball_bearing_not_hamiltonian {k : ℕ} (hk : 3 ≤ k) :
    ¬ (ballBearingGraph k).IsHamiltonian
Formalizes
arXiv:2611.17386 Lemma 2
Verified
23 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
  • ballBearingGraphFor any natural number k, the Ball Bearing graph ballBearingGraph k has vertex set Fin k × Fin 5. Two distinct vertices (j₁, v₁) and (j₂,…

Read back from the Lean

For every natural number $k$ such that $k \ge 3$, the graph ballBearingGraph k is not Hamiltonian.

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 proof proceeds by contradiction, assuming that the Ball Bearing graph BB(k) contains a Hamiltonian cycle p, which determines a 2-regular spanning subgraph H. Degree considerations in the ambient graph force both edges incident to each vertex (j, 4) to belong to H, which tightly constrains the connections among layers 3, 2, and 1: for each j, vertex (j, 1) is connected to layer 0 if and only if the edge (j, 2)-(j, 3) is present in H. Consequently, the set Z consisting of all layer 0 vertices together with those layer 1 vertices where (j, 2)-(j, 3) ∈ H is closed under taking neighbors in H. Because the cycle starts at (0, 0) ∈ Z, it can never leave Z and thus cannot visit (0, 2), contradicting Hamiltonicity.

  1. Assume for contradiction that the graph is Hamiltonian, and characterize the successor operation in Fin k.

    We assume for contradiction that the graph admits a Hamiltonian cycle. Since k ≥ 3, we have k > 0 and 1 < k, so 1 % k = 1. Consequently, adding 1 to a in Fin k produces the element with natural value (a.val + 1) % k, meaning a + 1 = b holds in Fin k if and only if (a.val + 1) % k = b.val.

    lines 4–13

    uses Nat.mod_eq_of_lt, Nat.mod_lt, Fin.val_add, Fin.val_one', Fin.ext_iff

      intro hHam
      haveI : NeZero k := ⟨by omega⟩
      have hmod1 : 1 % k = 1 := Nat.mod_eq_of_lt (by omega)
      have hadd1 : ∀ (a : Fin k), a + 1 = (⟨(a.val + 1) % k, Nat.mod_lt _ (by omega)⟩ : Fin k) := by
        intro a; ext
        rw [Fin.val_add]
        simp only [Fin.val_one', hmod1]
      have hnext : ∀ (a b : Fin k), (a + 1 = b) ↔ ((a.val + 1) % k = b.val) := by
        intro a b
        rw [hadd1 a, Fin.ext_iff]
  2. The adjacency condition of the Ball Bearing graph can be phrased using ring addition a + 1 in Fin k.

    Unfolding the definition of the Ball Bearing graph, adjacency between vertices (x₁, x₂) and (y₁, y₂) requires x ≠ y and either x₁ = y₁ with an internal edge in the 5-cycle gadget, or x₁ + 1 = y₁ or y₁ + 1 = x₁ along specified inter-gadget connections. We replace the modular arithmetic (x₁.val + 1) % k = y₁.val with the cleaner equivalence x₁ + 1 = y₁ in Fin k.

    lines 14–28

    uses Or.inl, Or.inr

      have hadj : ∀ x y : Fin k × Fin 5, (ballBearingGraph k).Adj x y ↔ x ≠ y ∧
          ((x.1 = y.1 ∧ (x.2 = 0 ∧ y.2 = 1 ∨ x.2 = 1 ∧ y.2 = 0 ∨ x.2 = 1 ∧ y.2 = 2 ∨ x.2 = 2 ∧ y.2 = 1 ∨ x.2 = 1 ∧ y.2 = 3 ∨ x.2 = 3 ∧ y.2 = 1 ∨ x.2 = 2 ∧ y.2 = 3 ∨ x.2 = 3 ∧ y.2 = 2 ∨ x.2 = 3 ∧ y.2 = 4 ∨ x.2 = 4 ∧ y.2 = 3)) ∨
          (x.1 + 1 = y.1 ∧ (x.2 = 0 ∧ y.2 = 0 ∨ x.2 = 1 ∧ y.2 = 0 ∨ x.2 = 4 ∧ y.2 = 2)) ∨
          (y.1 + 1 = x.1 ∧ (y.2 = 0 ∧ x.2 = 0 ∨ y.2 = 1 ∧ x.2 = 0 ∨ y.2 = 4 ∧ x.2 = 2))) := by
        intro x y
        simp only [ballBearingGraph]
        refine ⟨fun ⟨h, h'⟩ => ⟨h, ?_⟩, fun ⟨h, h'⟩ => ⟨h, ?_⟩⟩
        · rcases h' with h' | h' | h'
          · exact Or.inl h'
          · exact Or.inr (Or.inl ⟨(hnext x.1 y.1).mpr h'.1, h'.2⟩)
          · exact Or.inr (Or.inr ⟨(hnext y.1 x.1).mpr h'.1, h'.2⟩)
        · rcases h' with h' | h' | h'
          · exact Or.inl h'
          · exact Or.inr (Or.inl ⟨(hnext x.1 y.1).mp h'.1, h'.2⟩)
          · exact Or.inr (Or.inr ⟨(hnext y.1 x.1).mp h'.1, h'.2⟩)
  3. For every j ∈ Fin k, j + 1 ≠ j, so (j, 0) ≠ (j + 1, 0).

    If j + 1 = j in Fin k, then (j.val + 1) % k = j.val. Since j.val < k, either j.val + 1 < k (yielding j.val + 1 = j.val, impossible) or j.val + 1 = k (yielding 0 = j.val = k - 1 ≥ 2, also impossible). Comparing first coordinates shows that the vertices (j, 0) and (j + 1, 0) are distinct.

    lines 29–38

    uses Nat.lt_or_eq_of_le, Nat.mod_eq_of_lt, Nat.mod_self, congrArg, Prod.fst

      have hne_succ : ∀ j : Fin k, j + 1 ≠ j := by
        intro j h
        have h1 : (j.val + 1) % k = j.val := (hnext j j).mp h
        have h2 : j.val + 1 ≤ k := by have := j.isLt; omega
        rcases Nat.lt_or_eq_of_le h2 with h3 | h3
        · rw [Nat.mod_eq_of_lt h3] at h1; omega
        · rw [h3, Nat.mod_self] at h1; omega
      have hp01 : ∀ j : Fin k, ((j, (0:Fin 5)) : Fin k × Fin 5) ≠ (j + 1, 0) := by
        intro j h
        exact hne_succ j (congrArg Prod.fst h).symm
  4. A Hamiltonian cycle p starting at (0, 0) yields a 2-regular spanning subgraph H of the ambient graph.

    Since the vertex set is nontrivial, the Hamiltonicity hypothesis gives a Hamiltonian cycle p based at (0, 0). The subgraph H formed by the edges of p is contained in the Ball Bearing graph, and because p visits every vertex in the graph exactly once in a simple cycle, every vertex has degree exactly 2 in H.

    lines 39–45

      haveI : Nontrivial (Fin k × Fin 5) :=
        ⟨⟨((0:Fin k), (0:Fin 5)), ((0:Fin k), (1:Fin 5)), by simp⟩⟩
      obtain ⟨p, hp⟩ := hHam.exists_isHamiltonianCycle ((0:Fin k), (0:Fin 5))
      let H : (ballBearingGraph k).Subgraph := p.toSubgraph
      have hdeg : ∀ v : Fin k × Fin 5, (H.neighborSet v).ncard = 2 :=
        fun v => hp.toIsCycle.ncard_neighborSet_toSubgraph_eq_two (hp.mem_support v)
      have hsub : ∀ v w, H.Adj v w → (ballBearingGraph k).Adj v w := fun v w h => H.adj_sub h
  5. For each layer s ∈ {0, 1, 2, 3, 4}, the neighborhood in the ambient graph is bounded.

    By exhaustively checking the five possible values of the second coordinate and simplifying with the adjacency characterization hadj, we determine that vertex (j, 4) has exactly two neighbors in the graph, {(j, 3), (j + 1, 2)}, while the neighbors of (j, 3), (j, 2), (j, 1), and (j, 0) are restricted to the expected local subsets.

    lines 46–66

    uses SimpleGraph.mem_neighborSet, eq_comm, eq_sub_iff_add_eq

      have L4 : ∀ j : Fin k, (ballBearingGraph k).neighborSet (j, 4) = {(j, 3), (j + 1, 2)} := by
        intro j
        ext w
        obtain ⟨i, s⟩ := w
        fin_cases s <;> simp [hadj, SimpleGraph.mem_neighborSet, eq_comm]
      have L3 : ∀ j : Fin k, (ballBearingGraph k).neighborSet (j, 3) ⊆ {(j,1),(j,2),(j,4)} := by
        intro j w hw
        obtain ⟨i, s⟩ := w
        fin_cases s <;> simp [hadj, SimpleGraph.mem_neighborSet, eq_comm] at hw ⊢ <;> tauto
      have L2 : ∀ j : Fin k, (ballBearingGraph k).neighborSet (j, 2) ⊆ {(j,1),(j,3),(j-1,4)} := by
        intro j w hw
        obtain ⟨i, s⟩ := w
        fin_cases s <;> simp [hadj, SimpleGraph.mem_neighborSet, eq_comm, eq_sub_iff_add_eq] at hw ⊢ <;> tauto
      have L1 : ∀ j : Fin k, (ballBearingGraph k).neighborSet (j, 1) ⊆ {(j,0),(j,2),(j,3),(j+1,0)} := by
        intro j w hw
        obtain ⟨i, s⟩ := w
        fin_cases s <;> simp [hadj, SimpleGraph.mem_neighborSet, eq_comm] at hw ⊢ <;> tauto
      have L0 : ∀ j : Fin k, (ballBearingGraph k).neighborSet (j, 0) ⊆ {(j,1),(j+1,0),(j-1,0),(j-1,1)} := by
        intro j w hw
        obtain ⟨i, s⟩ := w
        fin_cases s <;> simp [hadj, SimpleGraph.mem_neighborSet, eq_comm, eq_sub_iff_add_eq] at hw ⊢ <;> tauto
  6. Any set of three pairwise distinct vertices has cardinality 3.

    Writing {a, b, c} as insert a (insert b {c}), each insertion adds a fresh element since the three vertices are assumed pairwise distinct, raising the cardinality from 1 to 2 to 3.

    lines 67–73

    uses Set.ncard_insert_of_notMem, Set.ncard_singleton

      have ncard3 : ∀ a b c : Fin k × Fin 5, a ≠ b → a ≠ c → b ≠ c →
          ({a, b, c} : Set (Fin k × Fin 5)).ncard = 3 := by
        intro a b c hab hac hbc
        have h1 : a ∉ ({b, c} : Set (Fin k × Fin 5)) := by simp [hab, hac]
        have h2 : b ∉ ({c} : Set (Fin k × Fin 5)) := by simp [hbc]
        rw [show ({a,b,c} : Set (Fin k × Fin 5)) = insert a (insert b {c}) from rfl,
          Set.ncard_insert_of_notMem h1, Set.ncard_insert_of_notMem h2, Set.ncard_singleton]
  7. In H, vertex (j, 4) must be adjacent to both (j, 3) and (j + 1, 2).

    In the ambient graph, (j, 4) has only two neighbors, {(j, 3), (j + 1, 2)}. Since H is a subgraph of degree 2 at (j, 4), its neighbor set in H is a 2-element subset of this 2-element set, forcing equality. Hence both incident edges are present in H.

    lines 74–86

    uses Set.eq_of_subset_of_ncard_le, Set.ncard_pair

      have hA4 : ∀ j : Fin k, H.Adj (j, 4) (j, 3) ∧ H.Adj (j, 4) (j + 1, 2) := by
        intro j
        have heq : H.neighborSet (j, 4) = ({(j, 3), (j + 1, 2)} : Set (Fin k × Fin 5)) := by
          refine Set.eq_of_subset_of_ncard_le ?_ ?_
          · intro w hw
            have hw' : w ∈ (ballBearingGraph k).neighborSet (j, 4) := hsub _ _ hw
            rwa [L4 j] at hw'
          · rw [Set.ncard_pair (by simp), hdeg]
        constructor
        · have h : (j, 3) ∈ H.neighborSet (j, 4) := by rw [heq]; simp
          exact h
        · have h : ((j + 1, 2) : Fin k × Fin 5) ∈ H.neighborSet (j, 4) := by rw [heq]; simp
          exact h
  8. For every j, exactly one of the edges (j, 3)-(j, 1) or (j, 3)-(j, 2) is in H.

    Vertex (j, 3) already has neighbor (j, 4) in H. If it were adjacent to both (j, 1) and (j, 2), it would have at least three neighbors in H, contradicting that its degree is 2. Conversely, all neighbors of (j, 3) in the graph lie in {(j, 1), (j, 2), (j, 4)}; if neither (j, 1) nor (j, 2) were adjacent to (j, 3) in H, its degree in H would be at most 1, also a contradiction.

    lines 87–117

    uses Set.mem_insert_iff, Set.mem_singleton_iff, Set.ncard_le_ncard, Set.ncard_singleton

      have hE3a : ∀ j : Fin k, ¬(H.Adj (j, 3) (j, 1) ∧ H.Adj (j, 3) (j, 2)) := by
        intro j hb
        have hsub' : ({(j, 1), (j, 2), (j, 4)} : Set (Fin k × Fin 5)) ⊆ H.neighborSet (j, 3) := by
          intro x hx
          simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hx
          rcases hx with rfl | rfl | rfl
          · exact hb.1
          · exact hb.2
          · exact (hA4 j).1.symm
        have h3 : ({(j, 1), (j, 2), (j, 4)} : Set (Fin k × Fin 5)).ncard = 3 :=
          ncard3 _ _ _ (by simp) (by simp) (by simp)
        have hle := Set.ncard_le_ncard hsub'
        rw [h3, hdeg] at hle
        omega
      have hE3b : ∀ j : Fin k, H.Adj (j, 3) (j, 1) ∨ H.Adj (j, 3) (j, 2) := by
        intro j
        by_contra hc
        push_neg at hc
        obtain ⟨hc1, hc2⟩ := hc
        have hsub' : H.neighborSet (j, 3) ⊆ ({(j, 4)} : Set (Fin k × Fin 5)) := by
          intro x hx
          have hxG : x ∈ (ballBearingGraph k).neighborSet (j, 3) := hsub _ _ hx
          have hxG' := L3 j hxG
          simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hxG' ⊢
          rcases hxG' with rfl | rfl | rfl
          · exact absurd hx hc1
          · exact absurd hx hc2
          · rfl
        have hle := Set.ncard_le_ncard hsub'
        rw [Set.ncard_singleton, hdeg] at hle
        omega
  9. For every j, vertex (j, 2) is adjacent to (j - 1, 4) in H, and exactly one of (j, 2)-(j, 1) or (j, 2)-(j, 3) is in H.

    Shifting indices in the edge (j - 1, 4)-(j, 2) established earlier shows that (j, 2) is always adjacent to (j - 1, 4) in H. Since all ambient neighbors of (j, 2) lie in {(j, 1), (j, 3), (j - 1, 4)}, the same degree-counting argument shows that (j, 2) cannot be adjacent to both (j, 1) and (j, 3) (which would give degree ≥ 3) nor to neither (which would give degree ≤ 1).

    lines 118–153

    uses sub_add_cancel, Set.mem_insert_iff, Set.mem_singleton_iff, Set.ncard_le_ncard, Set.ncard_singleton

      have hprev : ∀ j : Fin k, H.Adj (j, 2) ((j - 1, 4) : Fin k × Fin 5) := by
        intro j
        have h := (hA4 (j - 1)).2
        rw [sub_add_cancel] at h
        exact h.symm
      have hE2a : ∀ j : Fin k, ¬(H.Adj (j, 2) (j, 1) ∧ H.Adj (j, 2) (j, 3)) := by
        intro j hb
        have hsub' : ({(j, 1), (j, 3), (j - 1, 4)} : Set (Fin k × Fin 5)) ⊆ H.neighborSet (j, 2) := by
          intro x hx
          simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hx
          rcases hx with rfl | rfl | rfl
          · exact hb.1
          · exact hb.2
          · exact hprev j
        have h3 : ({(j, 1), (j, 3), (j - 1, 4)} : Set (Fin k × Fin 5)).ncard = 3 :=
          ncard3 _ _ _ (by simp) (by simp) (by simp)
        have hle := Set.ncard_le_ncard hsub'
        rw [h3, hdeg] at hle
        omega
      have hE2b : ∀ j : Fin k, H.Adj (j, 2) (j, 1) ∨ H.Adj (j, 2) (j, 3) := by
        intro j
        by_contra hc
        push_neg at hc
        obtain ⟨hc1, hc2⟩ := hc
        have hsub' : H.neighborSet (j, 2) ⊆ ({(j - 1, 4)} : Set (Fin k × Fin 5)) := by
          intro x hx
          have hxG : x ∈ (ballBearingGraph k).neighborSet (j, 2) := hsub _ _ hx
          have hxG' := L2 j hxG
          simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hxG' ⊢
          rcases hxG' with rfl | rfl | rfl
          · exact absurd hx hc1
          · exact absurd hx hc2
          · rfl
        have hle := Set.ncard_le_ncard hsub'
        rw [Set.ncard_singleton, hdeg] at hle
        omega
  10. The neighbors of (j, 1) in H are {(j, 0), (j + 1, 0)} if H contains (j, 2)-(j, 3), and {(j, 2), (j, 3)} otherwise.

    If (j, 2)-(j, 3) is an edge of H, then by the previous steps neither (j, 2) nor (j, 3) can connect to (j, 1). The only remaining ambient neighbors of (j, 1) are (j, 0) and (j + 1, 0); since (j, 1) has degree 2, these must be its two neighbors in H. Conversely, if (j, 2)-(j, 3) is absent from H, then (j, 1) must be adjacent to both (j, 2) and (j, 3), exhausting its degree of 2 and leaving no edges to layer 0.

    lines 154–189

    uses Set.eq_of_subset_of_ncard_le, Set.mem_insert_iff, Set.mem_singleton_iff, Set.ncard_pair

      have hb1 : ∀ j : Fin k, H.Adj (j, 2) (j, 3) →
          H.neighborSet (j, 1) = ({(j, 0), (j + 1, 0)} : Set (Fin k × Fin 5)) := by
        intro j hb
        have hn2 : ¬ H.Adj (j, 1) (j, 2) := fun h => (hE2a j) ⟨h.symm, hb⟩
        have hn3 : ¬ H.Adj (j, 1) (j, 3) := fun h => (hE3a j) ⟨h.symm, hb.symm⟩
        refine Set.eq_of_subset_of_ncard_le ?_ ?_
        · intro x hx
          have hxG : x ∈ (ballBearingGraph k).neighborSet (j, 1) := hsub _ _ hx
          have hxG' := L1 j hxG
          simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hxG' ⊢
          rcases hxG' with rfl | rfl | rfl | rfl
          · simp
          · exact absurd hx hn2
          · exact absurd hx hn3
          · simp
        · rw [Set.ncard_pair (hp01 j), hdeg]
      have hb2 : ∀ j : Fin k, ¬ H.Adj (j, 2) (j, 3) →
          H.neighborSet (j, 1) = ({(j, 2), (j, 3)} : Set (Fin k × Fin 5)) := by
        intro j hb
        have hp12 : H.Adj (j, 1) (j, 2) := by
          rcases hE2b j with h | h
          · exact h.symm
          · exact absurd h hb
        have hp13 : H.Adj (j, 1) (j, 3) := by
          rcases hE3b j with h | h
          · exact h.symm
          · exact absurd h.symm hb
        have h := Set.eq_of_subset_of_ncard_le
          (s := ({(j, 2), (j, 3)} : Set (Fin k × Fin 5))) (t := H.neighborSet (j, 1)) ?_ ?_
        · exact h.symm
        · intro x hx
          simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hx
          rcases hx with rfl | rfl
          · exact hp12
          · exact hp13
        · rw [Set.ncard_pair (by simp), hdeg]
  11. The set Z = {(j, 0) | j} ∪ {(j, 1) | H.Adj (j, 2) (j, 3)} contains (0, 0), excludes (0, 2), and is closed under H-adjacency.

    Clearly (0, 0) ∈ Z and (0, 2) ∉ Z. If v = (j, 0) ∈ Z, any neighbor w in H must be an ambient neighbor; if w has layer 0 it is in Z, and if w is (j, 1) or (j - 1, 1), its connection to layer 0 implies that its corresponding edge (2)-(3) must be in H, placing w in Z. If v = (j, 1) ∈ Z, the edge (j, 2)-(j, 3) is present, so the neighbors of v in H are (j, 0) and (j + 1, 0), both of which are in Z. Thus no edge of H can leave Z.

    lines 190–228

    uses Set.mem_insert_iff, Set.mem_singleton_iff, Or.inl

      let b : Fin k → Prop := fun j => H.Adj (j, 2) (j, 3)
      let Z : Set (Fin k × Fin 5) := {v | (∃ j, v = (j, (0:Fin 5))) ∨ (∃ j, v = (j, (1:Fin 5)) ∧ b j)}
      have hclos : ∀ v ∈ Z, ∀ w, H.Adj v w → w ∈ Z := by
        intro v hv w hw
        rcases hv with ⟨j, rfl⟩ | ⟨j, rfl, hj⟩
        · obtain ⟨i, s⟩ := w
          have hwG : ((i, s) : Fin k × Fin 5) ∈ (ballBearingGraph k).neighborSet (j, 0) := hsub _ _ hw
          have hwG' := L0 j hwG
          simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hwG'
          rcases hwG' with h1 | h1 | h1 | h1
          · rw [h1] at hw ⊢
            refine Or.inr ⟨j, rfl, ?_⟩
            by_contra hnb
            have h := hb2 j hnb
            have hmem : ((j, (0:Fin 5)) : Fin k × Fin 5) ∈ H.neighborSet (j, 1) := hw.symm
            rw [h] at hmem
            simp at hmem
          · rw [h1]; exact Or.inl ⟨j + 1, rfl⟩
          · rw [h1]; exact Or.inl ⟨j - 1, rfl⟩
          · rw [h1] at hw ⊢
            refine Or.inr ⟨j - 1, rfl, ?_⟩
            by_contra hnb
            have h := hb2 (j - 1) hnb
            have hmem : ((j, (0:Fin 5)) : Fin k × Fin 5) ∈ H.neighborSet (j - 1, 1) := hw.symm
            rw [h] at hmem
            simp at hmem
        · have h := hb1 j hj
          have hmem : w ∈ H.neighborSet (j, 1) := hw
          rw [h] at hmem
          simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hmem
          rcases hmem with h1 | h1
          · rw [h1]; exact Or.inl ⟨j, rfl⟩
          · rw [h1]; exact Or.inl ⟨j + 1, rfl⟩
      have h0Z : ((0:Fin k), (0:Fin 5)) ∈ Z := Or.inl ⟨0, rfl⟩
      have h2Z : ((0:Fin k), (2:Fin 5)) ∉ Z := by
        intro h
        rcases h with ⟨j, hj⟩ | ⟨j, hj, _⟩
        · simp at hj
        · simp at hj
  12. Every vertex on the cycle p lies in Z, contradicting the requirement that p visits (0, 2).

    Since p starts at (0, 0) ∈ Z and every step follows an edge of H, induction along the walk shows that every vertex visited by p belongs to Z. But p is a Hamiltonian cycle, so it must visit all vertices of the graph, including (0, 2). This forces (0, 2) ∈ Z, contradicting (0, 2) ∉ Z.

    lines 229–240

    uses SimpleGraph.Walk.getVert_zero, SimpleGraph.Walk.mem_support_iff_exists_getVert.mp

      have key : ∀ i : ℕ, i ≤ p.length → p.getVert i ∈ Z := by
        intro i
        induction i with
        | zero => intro _; rw [SimpleGraph.Walk.getVert_zero]; exact h0Z
        | succ n ih =>
          intro hn
          have hprev : n ≤ p.length := by omega
          have hnlt : n < p.length := by omega
          exact hclos _ (ih hprev) _ (p.toSubgraph_adj_getVert hnlt)
      obtain ⟨i, hi, hile⟩ :=
        SimpleGraph.Walk.mem_support_iff_exists_getVert.mp (hp.mem_support ((0:Fin k), (2:Fin 5)))
      exact h2Z (hi ▸ key i hile)
Nat.mod_eq_of_lt
If a < b for natural numbers, then a % b = a.
Nat.mod_lt
If 0 < y, then x % y < y.
Fin.val_add
The underlying natural value of a + b in Fin n is (a.val + b.val) % n.
Fin.val_one'
The underlying natural value of 1 in Fin n (with n > 0) is 1 % n.
Fin.ext_iff
Two elements of Fin n are equal if and only if their underlying natural values are equal.
Or.inl
From a proof of A, infer A ∨ B.
Or.inr
From a proof of B, infer A ∨ B.
Nat.lt_or_eq_of_le
If n ≤ m, then n < m or n = m.
Nat.mod_self
For any natural number n, n % n = 0.
congrArg
Functions preserve equality: if a = b, then f a = f b.
Prod.fst
The first coordinate projection of a pair (a, b) is a.
SimpleGraph.mem_neighborSet
A vertex w belongs to the neighbor set of v in graph G if and only if G.Adj v w.
eq_comm
Equality is symmetric: a = b is equivalent to b = a.
eq_sub_iff_add_eq
In an additive group, a = b - c if and only if a + c = b.
Set.ncard_insert_of_notMem
Inserting an element not in a finite set increases its cardinality by 1.
Set.ncard_singleton
A singleton set has cardinality 1.
Set.eq_of_subset_of_ncard_le
If s ⊆ t and |t| ≤ |s| for finite sets, then s = t.
Set.ncard_pair
A set of two distinct elements has cardinality 2.
Set.mem_insert_iff
An element x is in insert a s if and only if x = a or x ∈ s.
Set.mem_singleton_iff
An element a is in the singleton {b} if and only if a = b.
Set.ncard_le_ncard
If s ⊆ t for finite sets, then |s| ≤ |t|.
sub_add_cancel
In an additive group, (a - b) + b = a.
SimpleGraph.Walk.getVert_zero
The vertex at index 0 of a walk starting at u is u.
SimpleGraph.Walk.mem_support_iff_exists_getVert.mp
If a vertex belongs to the support of a walk, it is visited as getVert n for some index n ≤ length.

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 integer k ≥ 3, the Ball Bearing graph BB(k) contains no Hamiltonian cycle. -/theorem ball_bearing_not_hamiltonian {k : ℕ} (hk : 3 ≤ k) :    ¬ (ballBearingGraph k).IsHamiltonian := by  intro hHam  haveI : NeZero k := ⟨by omega⟩  have hmod1 : 1 % k = 1 := Nat.mod_eq_of_lt (by omega)  have hadd1 : ∀ (a : Fin k), a + 1 = (⟨(a.val + 1) % k, Nat.mod_lt _ (by omega)⟩ : Fin k) := by    intro a; ext    rw [Fin.val_add]    simp only [Fin.val_one', hmod1]  have hnext : ∀ (a b : Fin k), (a + 1 = b) ↔ ((a.val + 1) % k = b.val) := by    intro a b    rw [hadd1 a, Fin.ext_iff]  have hadj : ∀ x y : Fin k × Fin 5, (ballBearingGraph k).Adj x y ↔ x ≠ y ∧      ((x.1 = y.1 ∧ (x.2 = 0 ∧ y.2 = 1 ∨ x.2 = 1 ∧ y.2 = 0 ∨ x.2 = 1 ∧ y.2 = 2 ∨ x.2 = 2 ∧ y.2 = 1 ∨ x.2 = 1 ∧ y.2 = 3 ∨ x.2 = 3 ∧ y.2 = 1 ∨ x.2 = 2 ∧ y.2 = 3 ∨ x.2 = 3 ∧ y.2 = 2 ∨ x.2 = 3 ∧ y.2 = 4 ∨ x.2 = 4 ∧ y.2 = 3)) ∨      (x.1 + 1 = y.1 ∧ (x.2 = 0 ∧ y.2 = 0 ∨ x.2 = 1 ∧ y.2 = 0 ∨ x.2 = 4 ∧ y.2 = 2)) ∨      (y.1 + 1 = x.1 ∧ (y.2 = 0 ∧ x.2 = 0 ∨ y.2 = 1 ∧ x.2 = 0 ∨ y.2 = 4 ∧ x.2 = 2))) := by    intro x y    simp only [ballBearingGraph]    refine ⟨fun ⟨h, h'⟩ => ⟨h, ?_⟩, fun ⟨h, h'⟩ => ⟨h, ?_⟩⟩    · rcases h' with h' | h' | h'      · exact Or.inl h'      · exact Or.inr (Or.inl ⟨(hnext x.1 y.1).mpr h'.1, h'.2⟩)      · exact Or.inr (Or.inr ⟨(hnext y.1 x.1).mpr h'.1, h'.2⟩)    · rcases h' with h' | h' | h'      · exact Or.inl h'      · exact Or.inr (Or.inl ⟨(hnext x.1 y.1).mp h'.1, h'.2⟩)      · exact Or.inr (Or.inr ⟨(hnext y.1 x.1).mp h'.1, h'.2⟩)  have hne_succ : ∀ j : Fin k, j + 1 ≠ j := by    intro j h    have h1 : (j.val + 1) % k = j.val := (hnext j j).mp h    have h2 : j.val + 1 ≤ k := by have := j.isLt; omega    rcases Nat.lt_or_eq_of_le h2 with h3 | h3    · rw [Nat.mod_eq_of_lt h3] at h1; omega    · rw [h3, Nat.mod_self] at h1; omega  have hp01 : ∀ j : Fin k, ((j, (0:Fin 5)) : Fin k × Fin 5) ≠ (j + 1, 0) := by    intro j h    exact hne_succ j (congrArg Prod.fst h).symm  haveI : Nontrivial (Fin k × Fin 5) :=    ⟨⟨((0:Fin k), (0:Fin 5)), ((0:Fin k), (1:Fin 5)), by simp⟩⟩  obtain ⟨p, hp⟩ := hHam.exists_isHamiltonianCycle ((0:Fin k), (0:Fin 5))  let H : (ballBearingGraph k).Subgraph := p.toSubgraph  have hdeg : ∀ v : Fin k × Fin 5, (H.neighborSet v).ncard = 2 :=    fun v => hp.toIsCycle.ncard_neighborSet_toSubgraph_eq_two (hp.mem_support v)  have hsub : ∀ v w, H.Adj v w → (ballBearingGraph k).Adj v w := fun v w h => H.adj_sub h  have L4 : ∀ j : Fin k, (ballBearingGraph k).neighborSet (j, 4) = {(j, 3), (j + 1, 2)} := by    intro j    ext w    obtain ⟨i, s⟩ := w    fin_cases s <;> simp [hadj, SimpleGraph.mem_neighborSet, eq_comm]  have L3 : ∀ j : Fin k, (ballBearingGraph k).neighborSet (j, 3) ⊆ {(j,1),(j,2),(j,4)} := by    intro j w hw    obtain ⟨i, s⟩ := w    fin_cases s <;> simp [hadj, SimpleGraph.mem_neighborSet, eq_comm] at hw ⊢ <;> tauto  have L2 : ∀ j : Fin k, (ballBearingGraph k).neighborSet (j, 2) ⊆ {(j,1),(j,3),(j-1,4)} := by    intro j w hw    obtain ⟨i, s⟩ := w    fin_cases s <;> simp [hadj, SimpleGraph.mem_neighborSet, eq_comm, eq_sub_iff_add_eq] at hw ⊢ <;> tauto  have L1 : ∀ j : Fin k, (ballBearingGraph k).neighborSet (j, 1) ⊆ {(j,0),(j,2),(j,3),(j+1,0)} := by    intro j w hw    obtain ⟨i, s⟩ := w    fin_cases s <;> simp [hadj, SimpleGraph.mem_neighborSet, eq_comm] at hw ⊢ <;> tauto  have L0 : ∀ j : Fin k, (ballBearingGraph k).neighborSet (j, 0) ⊆ {(j,1),(j+1,0),(j-1,0),(j-1,1)} := by    intro j w hw    obtain ⟨i, s⟩ := w    fin_cases s <;> simp [hadj, SimpleGraph.mem_neighborSet, eq_comm, eq_sub_iff_add_eq] at hw ⊢ <;> tauto  have ncard3 : ∀ a b c : Fin k × Fin 5, a ≠ b → a ≠ c → b ≠ c →      ({a, b, c} : Set (Fin k × Fin 5)).ncard = 3 := by    intro a b c hab hac hbc    have h1 : a ∉ ({b, c} : Set (Fin k × Fin 5)) := by simp [hab, hac]    have h2 : b ∉ ({c} : Set (Fin k × Fin 5)) := by simp [hbc]    rw [show ({a,b,c} : Set (Fin k × Fin 5)) = insert a (insert b {c}) from rfl,      Set.ncard_insert_of_notMem h1, Set.ncard_insert_of_notMem h2, Set.ncard_singleton]  have hA4 : ∀ j : Fin k, H.Adj (j, 4) (j, 3) ∧ H.Adj (j, 4) (j + 1, 2) := by    intro j    have heq : H.neighborSet (j, 4) = ({(j, 3), (j + 1, 2)} : Set (Fin k × Fin 5)) := by      refine Set.eq_of_subset_of_ncard_le ?_ ?_      · intro w hw        have hw' : w ∈ (ballBearingGraph k).neighborSet (j, 4) := hsub _ _ hw        rwa [L4 j] at hw'      · rw [Set.ncard_pair (by simp), hdeg]    constructor    · have h : (j, 3) ∈ H.neighborSet (j, 4) := by rw [heq]; simp      exact h    · have h : ((j + 1, 2) : Fin k × Fin 5) ∈ H.neighborSet (j, 4) := by rw [heq]; simp      exact h  have hE3a : ∀ j : Fin k, ¬(H.Adj (j, 3) (j, 1) ∧ H.Adj (j, 3) (j, 2)) := by    intro j hb    have hsub' : ({(j, 1), (j, 2), (j, 4)} : Set (Fin k × Fin 5)) ⊆ H.neighborSet (j, 3) := by      intro x hx      simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hx      rcases hx with rfl | rfl | rfl      · exact hb.1      · exact hb.2      · exact (hA4 j).1.symm    have h3 : ({(j, 1), (j, 2), (j, 4)} : Set (Fin k × Fin 5)).ncard = 3 :=      ncard3 _ _ _ (by simp) (by simp) (by simp)    have hle := Set.ncard_le_ncard hsub'    rw [h3, hdeg] at hle    omega  have hE3b : ∀ j : Fin k, H.Adj (j, 3) (j, 1) ∨ H.Adj (j, 3) (j, 2) := by    intro j    by_contra hc    push_neg at hc    obtain ⟨hc1, hc2⟩ := hc    have hsub' : H.neighborSet (j, 3) ⊆ ({(j, 4)} : Set (Fin k × Fin 5)) := by      intro x hx      have hxG : x ∈ (ballBearingGraph k).neighborSet (j, 3) := hsub _ _ hx      have hxG' := L3 j hxG      simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hxG' ⊢      rcases hxG' with rfl | rfl | rfl      · exact absurd hx hc1      · exact absurd hx hc2      · rfl    have hle := Set.ncard_le_ncard hsub'    rw [Set.ncard_singleton, hdeg] at hle    omega  have hprev : ∀ j : Fin k, H.Adj (j, 2) ((j - 1, 4) : Fin k × Fin 5) := by    intro j    have h := (hA4 (j - 1)).2    rw [sub_add_cancel] at h    exact h.symm  have hE2a : ∀ j : Fin k, ¬(H.Adj (j, 2) (j, 1) ∧ H.Adj (j, 2) (j, 3)) := by    intro j hb    have hsub' : ({(j, 1), (j, 3), (j - 1, 4)} : Set (Fin k × Fin 5)) ⊆ H.neighborSet (j, 2) := by      intro x hx      simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hx      rcases hx with rfl | rfl | rfl      · exact hb.1      · exact hb.2      · exact hprev j    have h3 : ({(j, 1), (j, 3), (j - 1, 4)} : Set (Fin k × Fin 5)).ncard = 3 :=      ncard3 _ _ _ (by simp) (by simp) (by simp)    have hle := Set.ncard_le_ncard hsub'    rw [h3, hdeg] at hle    omega  have hE2b : ∀ j : Fin k, H.Adj (j, 2) (j, 1) ∨ H.Adj (j, 2) (j, 3) := by    intro j    by_contra hc    push_neg at hc    obtain ⟨hc1, hc2⟩ := hc    have hsub' : H.neighborSet (j, 2) ⊆ ({(j - 1, 4)} : Set (Fin k × Fin 5)) := by      intro x hx      have hxG : x ∈ (ballBearingGraph k).neighborSet (j, 2) := hsub _ _ hx      have hxG' := L2 j hxG      simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hxG' ⊢      rcases hxG' with rfl | rfl | rfl      · exact absurd hx hc1      · exact absurd hx hc2      · rfl    have hle := Set.ncard_le_ncard hsub'    rw [Set.ncard_singleton, hdeg] at hle    omega  have hb1 : ∀ j : Fin k, H.Adj (j, 2) (j, 3) →      H.neighborSet (j, 1) = ({(j, 0), (j + 1, 0)} : Set (Fin k × Fin 5)) := by    intro j hb    have hn2 : ¬ H.Adj (j, 1) (j, 2) := fun h => (hE2a j) ⟨h.symm, hb⟩    have hn3 : ¬ H.Adj (j, 1) (j, 3) := fun h => (hE3a j) ⟨h.symm, hb.symm⟩    refine Set.eq_of_subset_of_ncard_le ?_ ?_    · intro x hx      have hxG : x ∈ (ballBearingGraph k).neighborSet (j, 1) := hsub _ _ hx      have hxG' := L1 j hxG      simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hxG' ⊢      rcases hxG' with rfl | rfl | rfl | rfl      · simp      · exact absurd hx hn2      · exact absurd hx hn3      · simp    · rw [Set.ncard_pair (hp01 j), hdeg]  have hb2 : ∀ j : Fin k, ¬ H.Adj (j, 2) (j, 3) →      H.neighborSet (j, 1) = ({(j, 2), (j, 3)} : Set (Fin k × Fin 5)) := by    intro j hb    have hp12 : H.Adj (j, 1) (j, 2) := by      rcases hE2b j with h | h      · exact h.symm      · exact absurd h hb    have hp13 : H.Adj (j, 1) (j, 3) := by      rcases hE3b j with h | h      · exact h.symm      · exact absurd h.symm hb    have h := Set.eq_of_subset_of_ncard_le      (s := ({(j, 2), (j, 3)} : Set (Fin k × Fin 5))) (t := H.neighborSet (j, 1)) ?_ ?_    · exact h.symm    · intro x hx      simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hx      rcases hx with rfl | rfl      · exact hp12      · exact hp13    · rw [Set.ncard_pair (by simp), hdeg]  let b : Fin k → Prop := fun j => H.Adj (j, 2) (j, 3)  let Z : Set (Fin k × Fin 5) := {v | (∃ j, v = (j, (0:Fin 5))) ∨ (∃ j, v = (j, (1:Fin 5)) ∧ b j)}  have hclos : ∀ v ∈ Z, ∀ w, H.Adj v w → w ∈ Z := by    intro v hv w hw    rcases hv with ⟨j, rfl⟩ | ⟨j, rfl, hj⟩    · obtain ⟨i, s⟩ := w      have hwG : ((i, s) : Fin k × Fin 5) ∈ (ballBearingGraph k).neighborSet (j, 0) := hsub _ _ hw      have hwG' := L0 j hwG      simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hwG'      rcases hwG' with h1 | h1 | h1 | h1      · rw [h1] at hw ⊢        refine Or.inr ⟨j, rfl, ?_⟩        by_contra hnb        have h := hb2 j hnb        have hmem : ((j, (0:Fin 5)) : Fin k × Fin 5) ∈ H.neighborSet (j, 1) := hw.symm        rw [h] at hmem        simp at hmem      · rw [h1]; exact Or.inl ⟨j + 1, rfl⟩      · rw [h1]; exact Or.inl ⟨j - 1, rfl⟩      · rw [h1] at hw ⊢        refine Or.inr ⟨j - 1, rfl, ?_⟩        by_contra hnb        have h := hb2 (j - 1) hnb        have hmem : ((j, (0:Fin 5)) : Fin k × Fin 5) ∈ H.neighborSet (j - 1, 1) := hw.symm        rw [h] at hmem        simp at hmem    · have h := hb1 j hj      have hmem : w ∈ H.neighborSet (j, 1) := hw      rw [h] at hmem      simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hmem      rcases hmem with h1 | h1      · rw [h1]; exact Or.inl ⟨j, rfl⟩      · rw [h1]; exact Or.inl ⟨j + 1, rfl⟩  have h0Z : ((0:Fin k), (0:Fin 5)) ∈ Z := Or.inl ⟨0, rfl⟩  have h2Z : ((0:Fin k), (2:Fin 5)) ∉ Z := by    intro h    rcases h with ⟨j, hj⟩ | ⟨j, hj, _⟩    · simp at hj    · simp at hj  have key : ∀ i : ℕ, i ≤ p.length → p.getVert i ∈ Z := by    intro i    induction i with    | zero => intro _; rw [SimpleGraph.Walk.getVert_zero]; exact h0Z    | succ n ih =>      intro hn      have hprev : n ≤ p.length := by omega      have hnlt : n < p.length := by omega      exact hclos _ (ih hprev) _ (p.toSubgraph_adj_getVert hnlt)  obtain ⟨i, hi, hile⟩ :=    SimpleGraph.Walk.mem_support_iff_exists_getVert.mp (hp.mem_support ((0:Fin k), (2:Fin 5)))  exact h2Z (hi ▸ key i hile)
See it in the graphDiscuss this resultChallenge it