AFTD Auto-Formalizing Theoretical Domains

op309_triple_star_forest_degrees

theoremverified

On Fin n with 3 dividing n, if every pair inside a consecutive triple that contains its first element 3t is an edge, then in the forest R of these edges each vertex 3t meets exactly two R-edges and every other vertex exactly one.

Statement

theorem op309_triple_star_forest_degrees (n : ℕ) (h3 : 3 ∣ n)
    (G : SimpleGraph (Fin n)) [DecidableRel G.Adj]
    (hstar : ∀ a b : Fin n, a ≠ b → a.val / 3 = b.val / 3 →
      (a.val % 3 = 0 ∨ b.val % 3 = 0) → G.Adj a b)
    (R : Finset G.edgeSet)
    (hR : ∀ e : G.edgeSet, e ∈ R ↔ ∃ a b : Fin n, e.1 = s(a,b) ∧ a ≠ b ∧
      a.val / 3 = b.val / 3 ∧ (a.val % 3 = 0 ∨ b.val % 3 = 0)) (v : Fin n) :
    (R.filter fun e => v ∈ e.1).card = if v.val % 3 = 0 then 2 else 1
Source
OP-309 girth-nine block-ring construction: helper for op309_girth9_acyclic_source_unbounded_switch_cost (the P3 degrees used by the port-graph validity and the switch-cost bound).
Verified
28 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
Used by 3

The proof, explained

The edges of R partition the vertices into disjoint triples of the form {3t, 3t+1, 3t+2}, where each triple forms a star graph centered at 3t with leaves 3t+1 and 3t+2. We split into two cases according to whether v is a center vertex (v % 3 = 0) or a leaf (v % 3 ≠ 0). When v % 3 = 0, we identify its incident edges as exactly s(v, v+1) and s(v, v+2), proving its degree in R is 2. When v % 3 ≠ 0, canonical edge representation and uniqueness lemmas show that the only incident edge in R is s(v, 3 * (v / 3)), proving its degree in R is 1.

  1. There exists m such that n = 3m, and the vertex index satisfies v < n.

    We unpack the divisibility hypothesis 3 ∣ n into n = 3m and record that v < n by the definition of Fin n.

    lines 9–10

      obtain ⟨m, hm⟩ := h3
      have hv := v.isLt
  2. Any distinct pair a, b in Fin n in the same block of 3 with at least one vertex divisible by 3 forms an edge in R.

    We construct a helper lemma mkE: whenever a ≠ b have the same quotient upon division by 3 and at least one has remainder 0 modulo 3, the graph condition hstar ensures adjacency in G, and hR guarantees the resulting edge belongs to R.

    lines 11–15

    uses congrArg, Fin.val

      have mkE : ∀ a b : Fin n, a.val ≠ b.val → a.val / 3 = b.val / 3 →
          (a.val % 3 = 0 ∨ b.val % 3 = 0) → ∃ e ∈ R, e.1 = s(a,b) := by
        intro a b hne h3 h0
        have hne' : a ≠ b := fun h => hne (congrArg Fin.val h)
        exact ⟨⟨s(a,b), hstar a b hne' h3 h0⟩, (hR _).2 ⟨a, b, rfl, hne', h3, h0⟩, rfl⟩
  3. It suffices to consider the cases v % 3 = 0 and v % 3 ≠ 0 separately.

    We split on the if-then-else condition v.val % 3 = 0 in the degree formula.

    line 16

      split_ifs with h0
  4. When v % 3 = 0, the edges E₁ = s(v, v+1) and E₂ = s(v, v+2) exist in R.

    Since v is a multiple of 3 and v < n with 3 ∣ n, the values v + 1 and v + 2 are strictly less than n. Applying the constructor mkE to v with v + 1 and v + 2 produces the edges E₁ and E₂ in R.

    lines 17–20

    uses Or.inl

      · have b1 : v.val + 1 < n := by omega
        have b2 : v.val + 2 < n := by omega
        obtain ⟨E1, hE1, hE11⟩ := mkE v ⟨v.val + 1, b1⟩ (by simp) (by simp; omega) (Or.inl h0)
        obtain ⟨E2, hE2, hE21⟩ := mkE v ⟨v.val + 2, b2⟩ (by simp) (by simp; omega) (Or.inl h0)
  5. The edges E₁ and E₂ are distinct.

    If E₁ = E₂, then the unordered pairs s(v, v+1) and s(v, v+2) would be equal. By Sym2.eq_iff.1, this implies either v + 1 = v + 2 or v + 1 = v, both of which are contradictions.

    lines 21–26

    uses congrArg, Subtype.val, Sym2.eq_iff.1, Fin.val

        have hne : E1 ≠ E2 := by
          intro h
          have h' := hE11.symm.trans ((congrArg Subtype.val h).trans hE21)
          rcases Sym2.eq_iff.1 h' with ⟨_, h2⟩ | ⟨h1, _⟩
          · have := congrArg Fin.val h2; simp at this
          · have := congrArg Fin.val h1; simp at this
  6. The set of edges in R incident to v is exactly {E₁, E₂}.

    We prove set equality by extensionality. Any edge f ∈ R incident to v can be written via in1267_rep as s(x, c) where x % 3 ≠ 0 and c = 3 * (x / 3). Since v ∈ f, either v = x or v = c. The option v = x contradicts v % 3 = 0, so v = c = 3 * (x / 3). The non-center vertex x has either remainder 1 (so x = v + 1 and f = E₁) or remainder 2 (so x = v + 2 and f = E₂). Conversely, both E₁ and E₂ clearly belong to R and contain v.

    lines 27–48

    uses Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton, in1267_rep, Sym2.mem_iff.1, Fin.ext, Subtype.ext, Eq.trans, Sym2.eq_swap, Sym2.mem_mk_left

        have heq : (R.filter fun e => v ∈ e.1) = {E1, E2} := by
          ext f
          simp only [Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton]
          constructor
          · rintro ⟨hf, hvf⟩
            obtain ⟨x, c, hx, hc, hxc⟩ := in1267_rep hR hf
            rw [hxc] at hvf
            rcases Sym2.mem_iff.1 hvf with rfl | rfl
            · omega
            · have e1 : v = ⟨3 * (x.val / 3), by omega⟩ := Fin.ext hc
              by_cases h1 : x.val % 3 = 1
              · left
                refine Subtype.ext (hxc.trans (Eq.trans ?_ hE11.symm))
                have e2 : x = ⟨v.val + 1, b1⟩ := Fin.ext (by show x.val = v.val + 1; omega)
                rw [e2, Sym2.eq_swap]
              · right
                refine Subtype.ext (hxc.trans (Eq.trans ?_ hE21.symm))
                have e2 : x = ⟨v.val + 2, b2⟩ := Fin.ext (by show x.val = v.val + 2; omega)
                rw [e2, Sym2.eq_swap]
          · rintro (rfl | rfl)
            · exact ⟨hE1, by rw [hE11]; exact Sym2.mem_mk_left _ _⟩
            · exact ⟨hE2, by rw [hE21]; exact Sym2.mem_mk_left _ _⟩
  7. The degree of v in R is 2 when v % 3 = 0.

    Since the incident edge set equals {E₁, E₂} and E₁ ≠ E₂, its cardinality is 2 by Finset.card_pair.

    line 49

    uses Finset.card_pair

        rw [heq, Finset.card_pair hne]
  8. When v % 3 ≠ 0, the edge E = s(v, 3 * (v / 3)) exists in R.

    The block center 3 * (v / 3) is strictly less than n. Applying mkE to v and 3 * (v / 3) produces the edge E in R.

    lines 50–52

    uses Or.inr

      · have b0 : 3 * (v.val / 3) < n := by omega
        obtain ⟨E, hE, hE1⟩ := mkE v ⟨3 * (v.val / 3), b0⟩ (by simp; omega) (by simp)
          (Or.inr (by simp))
  9. The degree of v in R is 1 when v % 3 ≠ 0.

    By Finset.card_eq_one, it suffices to show that the incident edges form the singleton {E}. Any edge f ∈ R incident to v is of the form s(x, c) with x % 3 ≠ 0 and c = 3 * (x / 3). Since v % 3 ≠ 0, v cannot equal c, so v = x. Hence f connects v to 3 * (v / 3), and in1267_uniq shows f = E. The reverse inclusion is immediate as E contains v and lies in R.

    lines 53–65

    uses Finset.card_eq_one, Finset.mem_filter, Finset.mem_singleton, in1267_rep, Sym2.mem_iff.1, in1267_uniq, Sym2.mem_mk_left

        rw [Finset.card_eq_one]
        refine ⟨E, ?_⟩
        ext f
        simp only [Finset.mem_filter, Finset.mem_singleton]
        constructor
        · rintro ⟨hf, hvf⟩
          obtain ⟨x, c, hx, hc, hxc⟩ := in1267_rep hR hf
          rw [hxc] at hvf
          rcases Sym2.mem_iff.1 hvf with rfl | rfl
          · exact in1267_uniq hc rfl hxc hE1
          · omega
        · rintro rfl
          exact ⟨hE, by rw [hE1]; exact Sym2.mem_mk_left _ _⟩
congrArg
If a₁ = a₂, then f(a₁) = f(a₂) for any function f.
Eq.trans
Equality is transitive: if a = b and b = c, then a = c.
Fin.ext
Two elements of Fin n are equal if and only if their underlying natural values are equal.
Fin.val
The canonical projection mapping an element of Fin n to its underlying natural number.
Finset.card_eq_one
A finite set has cardinality 1 if and only if it is a singleton {a}.
Finset.card_pair
A finite set {a, b} with a ≠ b has cardinality 2.
Finset.mem_filter
An element belongs to a filtered set {x ∈ s | P(x)} if and only if it belongs to s and satisfies P.
Finset.mem_insert
An element belongs to insert b s if and only if it equals b or belongs to s.
Finset.mem_singleton
An element belongs to the singleton {a} if and only if it equals a.
in1267_rep
Any edge in R can be canonically represented as an unordered pair s(x, c) where x % 3 ≠ 0 and c = 3 * (x / 3).
in1267_uniq
If two edges in R both connect x to c and c' respectively with c = c' = 3 * (x / 3), then the edges are identical.
Or.inl
From a proof of A, infer A ∨ B.
Or.inr
From a proof of B, infer A ∨ B.
Subtype.ext
Two subtype elements are equal if their underlying values are equal.
Subtype.val
The projection extracting the underlying value from an element of a subtype.
Sym2.eq_iff.1
If two unordered pairs s(a, b) and s(c, d) are equal, then either (a = c and b = d) or (a = d and b = c).
Sym2.eq_swap
Unordered pairs are symmetric: s(a, b) = s(b, a).
Sym2.mem_iff.1
If an element belongs to the unordered pair s(a, b), then it equals a or it equals b.
Sym2.mem_mk_left
The first element of an unordered pair belongs to the pair: x ∈ s(x, y).

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

theorem op309_triple_star_forest_degrees (n : ℕ) (h3 : 3 ∣ n)    (G : SimpleGraph (Fin n)) [DecidableRel G.Adj]    (hstar : ∀ a b : Fin n, a ≠ b → a.val / 3 = b.val / 3 →      (a.val % 3 = 0 ∨ b.val % 3 = 0) → G.Adj a b)    (R : Finset G.edgeSet)    (hR : ∀ e : G.edgeSet, e ∈ R ↔ ∃ a b : Fin n, e.1 = s(a,b) ∧ a ≠ b ∧      a.val / 3 = b.val / 3 ∧ (a.val % 3 = 0 ∨ b.val % 3 = 0)) (v : Fin n) :    (R.filter fun e => v ∈ e.1).card = if v.val % 3 = 0 then 2 else 1 := by  obtain ⟨m, hm⟩ := h3  have hv := v.isLt  have mkE : ∀ a b : Fin n, a.val ≠ b.val → a.val / 3 = b.val / 3 →      (a.val % 3 = 0 ∨ b.val % 3 = 0) → ∃ e ∈ R, e.1 = s(a,b) := by    intro a b hne h3 h0    have hne' : a ≠ b := fun h => hne (congrArg Fin.val h)    exact ⟨⟨s(a,b), hstar a b hne' h3 h0⟩, (hR _).2 ⟨a, b, rfl, hne', h3, h0⟩, rfl⟩  split_ifs with h0  · have b1 : v.val + 1 < n := by omega    have b2 : v.val + 2 < n := by omega    obtain ⟨E1, hE1, hE11⟩ := mkE v ⟨v.val + 1, b1⟩ (by simp) (by simp; omega) (Or.inl h0)    obtain ⟨E2, hE2, hE21⟩ := mkE v ⟨v.val + 2, b2⟩ (by simp) (by simp; omega) (Or.inl h0)    have hne : E1 ≠ E2 := by      intro h      have h' := hE11.symm.trans ((congrArg Subtype.val h).trans hE21)      rcases Sym2.eq_iff.1 h' with ⟨_, h2⟩ | ⟨h1, _⟩      · have := congrArg Fin.val h2; simp at this      · have := congrArg Fin.val h1; simp at this    have heq : (R.filter fun e => v ∈ e.1) = {E1, E2} := by      ext f      simp only [Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton]      constructor      · rintro ⟨hf, hvf⟩        obtain ⟨x, c, hx, hc, hxc⟩ := in1267_rep hR hf        rw [hxc] at hvf        rcases Sym2.mem_iff.1 hvf with rfl | rfl        · omega        · have e1 : v = ⟨3 * (x.val / 3), by omega⟩ := Fin.ext hc          by_cases h1 : x.val % 3 = 1          · left            refine Subtype.ext (hxc.trans (Eq.trans ?_ hE11.symm))            have e2 : x = ⟨v.val + 1, b1⟩ := Fin.ext (by show x.val = v.val + 1; omega)            rw [e2, Sym2.eq_swap]          · right            refine Subtype.ext (hxc.trans (Eq.trans ?_ hE21.symm))            have e2 : x = ⟨v.val + 2, b2⟩ := Fin.ext (by show x.val = v.val + 2; omega)            rw [e2, Sym2.eq_swap]      · rintro (rfl | rfl)        · exact ⟨hE1, by rw [hE11]; exact Sym2.mem_mk_left _ _⟩        · exact ⟨hE2, by rw [hE21]; exact Sym2.mem_mk_left _ _⟩    rw [heq, Finset.card_pair hne]  · have b0 : 3 * (v.val / 3) < n := by omega    obtain ⟨E, hE, hE1⟩ := mkE v ⟨3 * (v.val / 3), b0⟩ (by simp; omega) (by simp)      (Or.inr (by simp))    rw [Finset.card_eq_one]    refine ⟨E, ?_⟩    ext f    simp only [Finset.mem_filter, Finset.mem_singleton]    constructor    · rintro ⟨hf, hvf⟩      obtain ⟨x, c, hx, hc, hxc⟩ := in1267_rep hR hf      rw [hxc] at hvf      rcases Sym2.mem_iff.1 hvf with rfl | rfl      · exact in1267_uniq hc rfl hxc hE1      · omega    · rintro rfl      exact ⟨hE, by rw [hE1]; exact Sym2.mem_mk_left _ _⟩
See it in the graphDiscuss this resultChallenge it