card_le_moore_bound
Every finite connected simple graph with maximum degree at most d and diameter at most k has at most m(d, k) vertices.
Statement
theorem card_le_moore_bound (d k : ℕ) (V : Type) [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) (hdiam : G.diam ≤ k) (hdeg : G.maxDegree ≤ d) : Fintype.card V ≤ moore_bound d k
- Formalizes
- arXiv:2611.26037 Sec. 1
- Verified
- 22 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 1
- moore_boundThe Moore bound m(d, k) is defined as 1 + d * ∑_{i=0}^{k-1} (d-1)^i, representing the maximum possible number of vertices in a graph of…
- Used by 1
- degree_diameter_three_defect_sublinear_of_deviation_boundReduction of the diameter-3 defect bound to the deviation theorem: for d ≥ 3, if every finite nonempty d-regular graph satisfies d < (√8 r…
Read back from the Lean
For any natural numbers $d$ and $k$, any finite type $V$, and any simple graph $G$ on $V$ with decidable adjacency: if $G$ is connected, the diameter of $G$ is at most $k$, and the maximum degree of $G$ is at most $d$, then the cardinality of $V$ is at most moore_bound d k.
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 Moore bound is proved by choosing an arbitrary root vertex v0 and partitioning the graph into distance layers L(i) of vertices at distance i from v0, up to the diameter bound k. A parent map is constructed by picking an adjacent predecessor along a shortest path to v0 for each vertex at positive distance. The root has at most d children, while every vertex in a higher layer has at most d - 1 children (its neighbor set minus its own parent), which yields the layer bound |L(i+1)| ≤ d(d-1)^i by induction. Summing over all layers gives |V| = 1 + ∑_{i=0}^{k-1} |L(i+1)| ≤ 1 + d ∑_{i=0}^{k-1} (d-1)^i = moore_bound(d, k).
Choose a root vertex v0, and observe that every vertex has distance at most k from v0.
Since G is connected, V is nonempty; let v0 ∈ V be any vertex. In a connected graph, the distance from v0 to any vertex v is bounded by the diameter G.diam, which by assumption is at most k.
uses
card_le_moore_bound_dist_le_diamclassical obtain ⟨v0⟩ := hconn.2 have hdist_le : ∀ v : V, G.dist v0 v ≤ k := fun v => (@card_le_moore_bound_dist_le_diam V _ ⟨v0⟩ G hconn v0 v).trans hdiam
Every vertex w at distance at least 1 from v0 has an adjacent predecessor u with dist(v0, u) = dist(v0, w) - 1.
Let p be a shortest path from v0 to w, so p has length dist(v0, w) ≥ 1. The vertex u at index dist(v0, w) - 1 along p is adjacent to w by construction. Furthermore, the prefix of p up to u is a subwalk of a shortest path, so its length dist(v0, w) - 1 equals the distance dist(v0, u).
uses
Nat.sub_add_cancel,SimpleGraph.length_eq_dist_of_subwalk,SimpleGraph.Walk.take_length,min_eq_lefthave hex : ∀ w : V, 1 ≤ G.dist v0 w → ∃ u : V, G.Adj u w ∧ G.dist v0 u = G.dist v0 w - 1 := by intro w hw obtain ⟨p, -, hp_len⟩ := hconn.exists_path_of_dist v0 w refine ⟨p.getVert (G.dist v0 w - 1), ?_, ?_⟩ · have h1 : G.dist v0 w - 1 < p.length := by omega have hadj := p.adj_getVert_succ h1 have h2 : p.getVert (G.dist v0 w - 1 + 1) = w := by rw [Nat.sub_add_cancel hw, ← hp_len, p.getVert_length] rwa [h2] at hadj · have h2 : (p.take (G.dist v0 w - 1)).length = G.dist v0 (p.getVert (G.dist v0 w - 1)) := SimpleGraph.length_eq_dist_of_subwalk hp_len (p.isSubwalk_take _) rw [← h2, SimpleGraph.Walk.take_length, hp_len, min_eq_left (by omega)]
There exists a parent function par : V → V that sends each vertex w with dist(v0, w) ≥ 1 to an adjacent predecessor at distance dist(v0, w) - 1.
We define par(w) by choosing via Classical.choose an adjacent predecessor when one exists, and defaulting to w otherwise. By the previous step, such a predecessor exists whenever dist(v0, w) ≥ 1, and Classical.choose_spec guarantees it satisfies the adjacency and distance conditions.
uses
Classical.choose,dif_pos,Classical.choose_speclet par : V → V := fun w => if h : ∃ u : V, G.Adj u w ∧ G.dist v0 u = G.dist v0 w - 1 then Classical.choose h else w have par_spec : ∀ w : V, 1 ≤ G.dist v0 w → G.Adj (par w) w ∧ G.dist v0 (par w) = G.dist v0 w - 1 := by intro w hw have h := hex w hw have hpar : par w = Classical.choose h := by simp only [par, dif_pos h] rw [hpar] exact Classical.choose_spec h
Define the distance layers L(i) = {v ∈ V | dist(v0, v) = i}; then L(0) = {v0}.
The distance layers L(i) collect vertices at distance i from v0. Since dist(v0, v) = 0 if and only if v = v0 in a connected graph, L(0) is the singleton {v0}.
uses
SimpleGraph.Connected.dist_eq_zero_iffset L : ℕ → Finset V := fun i => Finset.univ.filter (fun v => G.dist v0 v = i) with hL have memL : ∀ (i : ℕ) (v : V), v ∈ L i ↔ G.dist v0 v = i := by intro i v; rw [hL]; simp have hL0 : L 0 = {v0} := by ext v; rw [memL]; simp [SimpleGraph.Connected.dist_eq_zero_iff hconn, eq_comm]
The parent map sends layer L(j+1) into layer L(j).
For every a ∈ L(j+1), dist(v0, a) = j + 1 ≥ 1, so dist(v0, par(a)) = (j + 1) - 1 = j, meaning par(a) ∈ L(j).
uses
Finset.mem_imagehave himage : ∀ j : ℕ, (Finset.image par (L (j+1))) ⊆ L j := by intro j b hb rw [Finset.mem_image] at hb obtain ⟨a, ha, rfl⟩ := hb rw [memL] at ha ⊢ have hpos : 1 ≤ G.dist v0 a := by omega have := (par_spec a hpos).2 omega
The fiber of any vertex in L(0) under par restricted to L(1) has size at most d.
Every vertex a ∈ L(1) with par(a) = b is a neighbor of b. Hence the fiber {a ∈ L(1) | par(a) = b} is a subset of the neighbor set of b, whose size is degree(b) ≤ maxDegree(G) ≤ d.
uses
Finset.mem_filter,SimpleGraph.mem_neighborFinset,Finset.card_le_card,SimpleGraph.card_neighborFinset_eq_degree,SimpleGraph.degree_le_maxDegreehave hfib0 : ∀ b : V, b ∈ L 0 → (Finset.filter (fun a => par a = b) (L 1)).card ≤ d := by intro b hb have hsub : Finset.filter (fun a => par a = b) (L 1) ⊆ G.neighborFinset b := by intro a ha rw [Finset.mem_filter] at ha obtain ⟨ha1, ha2⟩ := ha rw [SimpleGraph.mem_neighborFinset] rw [memL] at ha1 have hpos : 1 ≤ G.dist v0 a := by omega have := (par_spec a hpos).1 rwa [ha2] at this calc (Finset.filter (fun a => par a = b) (L 1)).card ≤ (G.neighborFinset b).card := Finset.card_le_card hsub _ = G.degree b := SimpleGraph.card_neighborFinset_eq_degree G b _ ≤ G.maxDegree := SimpleGraph.degree_le_maxDegree G b _ ≤ d := hdeg
For j ≥ 1, the fiber of any vertex b ∈ L(j) under par restricted to L(j+1) has size at most d - 1.
Each child a ∈ L(j+1) with par(a) = b is adjacent to b, but a cannot equal par(b) because dist(v0, a) = j + 1 while dist(v0, par(b)) = j - 1. Thus the fiber is contained in the neighbor set of b with par(b) removed. Since par(b) is a neighbor of b, removing it leaves at most degree(b) - 1 ≤ d - 1 elements.
uses
Finset.mem_filter,Finset.mem_erase,SimpleGraph.mem_neighborFinset,Finset.card_le_card,Finset.card_erase_of_mem,SimpleGraph.card_neighborFinset_eq_degree,SimpleGraph.degree_le_maxDegreehave hfib : ∀ (j : ℕ), 1 ≤ j → ∀ b : V, b ∈ L j → (Finset.filter (fun a => par a = b) (L (j+1))).card ≤ d - 1 := by intro j hj b hb have hbdist : G.dist v0 b = j := (memL j b).mp hb obtain ⟨hadj, hdist⟩ := par_spec b (by omega) have hsub : Finset.filter (fun a => par a = b) (L (j+1)) ⊆ (G.neighborFinset b).erase (par b) := by intro a ha rw [Finset.mem_filter] at ha obtain ⟨halayer, hapar⟩ := ha rw [memL] at halayer have hpos : 1 ≤ G.dist v0 a := by omega have hadja : G.Adj (par a) a := (par_spec a hpos).1 rw [Finset.mem_erase] refine ⟨?_, ?_⟩ · intro hEq have h1 : G.dist v0 a = G.dist v0 b - 1 := by rw [hEq]; exact hdist omega · rw [SimpleGraph.mem_neighborFinset] rwa [hapar] at hadja calc (Finset.filter (fun a => par a = b) (L (j+1))).card ≤ ((G.neighborFinset b).erase (par b)).card := Finset.card_le_card hsub _ = (G.neighborFinset b).card - 1 := Finset.card_erase_of_mem (by rw [SimpleGraph.mem_neighborFinset]; exact hadj.symm) _ = G.degree b - 1 := by rw [SimpleGraph.card_neighborFinset_eq_degree] _ ≤ d - 1 := by have h1 := SimpleGraph.degree_le_maxDegree G b omega
For each j ≥ 1, the size of layer L(j+1) is at most (d - 1) * |L(j)|.
By bounding a set by the maximum fiber size times the image size, |L(j+1)| ≤ (d - 1) * |par(L(j+1))|. Since par(L(j+1)) ⊆ L(j), this is at most (d - 1) * |L(j)|.
uses
le_trans,Finset.card_le_mul_card_image,Nat.mul_le_mul_left,Finset.card_le_cardhave hstep : ∀ (j : ℕ), 1 ≤ j → (L (j+1)).card ≤ (d - 1) * (L j).card := by intro j hj refine le_trans (Finset.card_le_mul_card_image (f := par) (L (j+1)) (d - 1) ?_) ?_ · intro b hb exact hfib j hj b (himage j hb) · exact Nat.mul_le_mul_left _ (Finset.card_le_card (himage j))
For all i ≥ 0, |L(i+1)| ≤ d * (d - 1)^i.
By induction on i. For i = 0, |L(1)| ≤ d * |L(0)| = d * 1 = d * (d - 1)^0 using the fiber bound for L(0) and L(0) = {v0}. For the induction step, |L(i+2)| ≤ (d - 1) * |L(i+1)| ≤ (d - 1) * (d * (d - 1)^i) = d * (d - 1)^(i+1).
uses
Finset.card_le_mul_card_image,Finset.card_le_card,Nat.mul_le_mul_left,pow_succhave hlayer : ∀ i : ℕ, (L (i+1)).card ≤ d * (d - 1)^i := by intro i induction i with | zero => have h1 : (L 1).card ≤ d * (Finset.image par (L 1)).card := Finset.card_le_mul_card_image (f := par) (L 1) d (fun b hb => hfib0 b (himage 0 hb)) have h2 : (Finset.image par (L 1)).card ≤ 1 := by calc (Finset.image par (L 1)).card ≤ (L 0).card := Finset.card_le_card (himage 0) _ = 1 := by rw [hL0]; simp calc (L (0+1)).card = (L 1).card := rfl _ ≤ d * (Finset.image par (L 1)).card := h1 _ ≤ d * 1 := Nat.mul_le_mul_left _ h2 _ = d * (d - 1)^0 := by simp | succ i ih => calc (L (i+1+1)).card ≤ (d - 1) * (L (i+1)).card := hstep (i+1) (by omega) _ ≤ (d - 1) * (d * (d - 1)^i) := Nat.mul_le_mul_left _ ih _ = d * (d - 1)^(i+1) := by rw [pow_succ]; ring
The sum of the sizes of layers L(1) through L(k) is at most d * ∑_{i=0}^{k-1} (d - 1)^i.
Summing the inequality |L(i+1)| ≤ d * (d - 1)^i over i ∈ {0, ..., k-1} and factoring out d yields the desired bound.
uses
Finset.mul_sum,Finset.sum_le_sumhave hsum_le : ∑ i ∈ Finset.range k, (L (i+1)).card ≤ d * ∑ i ∈ Finset.range k, (d - 1)^i := by rw [Finset.mul_sum] exact Finset.sum_le_sum (fun i _ => hlayer i)
The total number of vertices |V| equals the sum of the layer sizes ∑_{i=0}^k |L(i)|.
Since every vertex v satisfies dist(v0, v) ≤ k, the distance to v0 maps V into {0, ..., k}. Summing the sizes of the fibers of this map gives |V| = ∑_{i=0}^k |L(i)|.
uses
Nat.lt_succ_of_le,Finset.card_eq_sum_card_fiberwisehave hcover : ∀ v ∈ (Finset.univ : Finset V), G.dist v0 v ∈ Finset.range (k+1) := fun v _ => Finset.mem_range.mpr (Nat.lt_succ_of_le (hdist_le v)) have hcard : Fintype.card V = ∑ i ∈ Finset.range (k+1), (L i).card := by have h := Finset.card_eq_sum_card_fiberwise (s := (Finset.univ : Finset V)) (t := Finset.range (k+1)) (f := fun v : V => G.dist v0 v) hcover simpa [hL] using h
The total number of vertices is at most moore_bound(d, k).
Splitting off L(0) gives |V| = |L(0)| + ∑_{i=0}^{k-1} |L(i+1)|. Since |L(0)| = 1 and the sum of the remaining layers is at most d * ∑_{i=0}^{k-1} (d - 1)^i, |V| ≤ 1 + d * ∑_{i=0}^{k-1} (d - 1)^i, which is the definition of moore_bound(d, k).
uses
Finset.sum_range_succ',Finset.card_singleton,Nat.add_le_add_right,Nat.add_commrw [hcard, Finset.sum_range_succ'] calc (∑ i ∈ Finset.range k, (L (i + 1)).card) + (L 0).card ≤ d * (∑ i ∈ Finset.range k, (d - 1)^i) + 1 := by rw [hL0, Finset.card_singleton] exact Nat.add_le_add_right hsum_le 1 _ = moore_bound d k := by rw [moore_bound, Nat.add_comm]
card_le_moore_bound_dist_le_diam- In a nonempty connected graph, the distance between any two vertices is at most the diameter of the graph.
Nat.sub_add_cancel- For natural numbers m ≤ n, (n - m) + m = n.
SimpleGraph.length_eq_dist_of_subwalk- If a walk has length equal to the distance between its endpoints, any of its subwalks also has length equal to the distance between its endpoints.
SimpleGraph.Walk.take_length- The length of the prefix of length n of a walk p is min(n, length(p)).
min_eq_left- If a ≤ b, then min(a, b) = a.
Classical.choose- Given an existential statement ∃ x, P(x), returns a witness x satisfying P(x).
dif_pos- If a decidable proposition c is true, the dependent if-then-else dite c t e simplifies to t c.
Classical.choose_spec- The witness selected by Classical.choose on ∃ x, P(x) satisfies P.
SimpleGraph.Connected.dist_eq_zero_iff- In a connected graph, the distance between two vertices is zero if and only if they are equal.
Finset.mem_image- An element b belongs to the image f(s) of a finite set s if and only if b = f(a) for some a ∈ s.
Finset.mem_filter- An element a belongs to the filtered set {x ∈ s | P(x)} if and only if a ∈ s and P(a) holds.
SimpleGraph.mem_neighborFinset- A vertex w belongs to the neighbor finset of v if and only if v and w are adjacent in G.
Finset.card_le_card- If s ⊆ t for finite sets s and t, then |s| ≤ |t|.
SimpleGraph.card_neighborFinset_eq_degree- The cardinality of the neighbor finset of a vertex v equals the degree of v.
SimpleGraph.degree_le_maxDegree- The degree of any vertex in a finite graph is at most the maximum degree of the graph.
Finset.mem_erase- An element a belongs to s \ {b} if and only if a ≠ b and a ∈ s.
Finset.card_erase_of_mem- If a belongs to a finite set s, then |s \ {a}| = |s| - 1.
le_trans- If a ≤ b and b ≤ c, then a ≤ c.
Finset.card_le_mul_card_image- If every fiber of a function f on a finite set s has size at most n, then |s| ≤ n * |f(s)|.
Nat.mul_le_mul_left- If n ≤ m, then k * n ≤ k * m for any natural number k.
pow_succ- For any power, a^(n + 1) = a^n * a.
Finset.mul_sum- Multiplication distributes over finite sums: a * ∑ i ∈ s, f(i) = ∑ i ∈ s, a * f(i).
Finset.sum_le_sum- If f(i) ≤ g(i) for all i ∈ s, then ∑ i ∈ s, f(i) ≤ ∑ i ∈ s, g(i).
Nat.lt_succ_of_le- If n ≤ m, then n < m + 1.
Finset.card_eq_sum_card_fiberwise- The cardinality of a finite set s equals the sum over b ∈ t of the fiber sizes |{a ∈ s | f(a) = b}|, provided f maps s into t.
Finset.sum_range_succ'- Splitting off the first term of a range sum: ∑_{k=0}^n f(k) = (∑_{k=0}^{n-1} f(k+1)) + f(0).
Finset.card_singleton- The cardinality of a singleton set {a} is 1.
Nat.add_le_add_right- If n ≤ m, then n + k ≤ m + k for any natural number k.
Nat.add_comm- Addition of natural numbers is commutative: n + m = m + n.
- The parent map `par` is extended to all vertices of V via `Classical.choose` with a dummy fallback `par(v0) = v0`, as its predecessor properties are only invoked for vertices at distance at least 1.
- The bound `dist v0 v ≤ diam` is supplied by a private helper lemma `card_le_moore_bound_dist_le_diam` proved immediately preceding the theorem.
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
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
private lemma card_le_moore_bound_dist_le_diam (V : Type) [Fintype V] [Nonempty V] (G : SimpleGraph V) (hconn : G.Connected) (u v : V) : G.dist u v ≤ G.diam := SimpleGraph.dist_le_diam (SimpleGraph.connected_iff_ediam_ne_top.mp hconn)/-- The classical Moore bound: every finite connected simple graph of maximum degree at most d and diameter at most k has at most m(d, k) vertices. -/theorem card_le_moore_bound (d k : ℕ) (V : Type) [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] (hconn : G.Connected) (hdiam : G.diam ≤ k) (hdeg : G.maxDegree ≤ d) : Fintype.card V ≤ moore_bound d k := by classical obtain ⟨v0⟩ := hconn.2 have hdist_le : ∀ v : V, G.dist v0 v ≤ k := fun v => (@card_le_moore_bound_dist_le_diam V _ ⟨v0⟩ G hconn v0 v).trans hdiam have hex : ∀ w : V, 1 ≤ G.dist v0 w → ∃ u : V, G.Adj u w ∧ G.dist v0 u = G.dist v0 w - 1 := by intro w hw obtain ⟨p, -, hp_len⟩ := hconn.exists_path_of_dist v0 w refine ⟨p.getVert (G.dist v0 w - 1), ?_, ?_⟩ · have h1 : G.dist v0 w - 1 < p.length := by omega have hadj := p.adj_getVert_succ h1 have h2 : p.getVert (G.dist v0 w - 1 + 1) = w := by rw [Nat.sub_add_cancel hw, ← hp_len, p.getVert_length] rwa [h2] at hadj · have h2 : (p.take (G.dist v0 w - 1)).length = G.dist v0 (p.getVert (G.dist v0 w - 1)) := SimpleGraph.length_eq_dist_of_subwalk hp_len (p.isSubwalk_take _) rw [← h2, SimpleGraph.Walk.take_length, hp_len, min_eq_left (by omega)] let par : V → V := fun w => if h : ∃ u : V, G.Adj u w ∧ G.dist v0 u = G.dist v0 w - 1 then Classical.choose h else w have par_spec : ∀ w : V, 1 ≤ G.dist v0 w → G.Adj (par w) w ∧ G.dist v0 (par w) = G.dist v0 w - 1 := by intro w hw have h := hex w hw have hpar : par w = Classical.choose h := by simp only [par, dif_pos h] rw [hpar] exact Classical.choose_spec h set L : ℕ → Finset V := fun i => Finset.univ.filter (fun v => G.dist v0 v = i) with hL have memL : ∀ (i : ℕ) (v : V), v ∈ L i ↔ G.dist v0 v = i := by intro i v; rw [hL]; simp have hL0 : L 0 = {v0} := by ext v; rw [memL]; simp [SimpleGraph.Connected.dist_eq_zero_iff hconn, eq_comm] have himage : ∀ j : ℕ, (Finset.image par (L (j+1))) ⊆ L j := by intro j b hb rw [Finset.mem_image] at hb obtain ⟨a, ha, rfl⟩ := hb rw [memL] at ha ⊢ have hpos : 1 ≤ G.dist v0 a := by omega have := (par_spec a hpos).2 omega have hfib0 : ∀ b : V, b ∈ L 0 → (Finset.filter (fun a => par a = b) (L 1)).card ≤ d := by intro b hb have hsub : Finset.filter (fun a => par a = b) (L 1) ⊆ G.neighborFinset b := by intro a ha rw [Finset.mem_filter] at ha obtain ⟨ha1, ha2⟩ := ha rw [SimpleGraph.mem_neighborFinset] rw [memL] at ha1 have hpos : 1 ≤ G.dist v0 a := by omega have := (par_spec a hpos).1 rwa [ha2] at this calc (Finset.filter (fun a => par a = b) (L 1)).card ≤ (G.neighborFinset b).card := Finset.card_le_card hsub _ = G.degree b := SimpleGraph.card_neighborFinset_eq_degree G b _ ≤ G.maxDegree := SimpleGraph.degree_le_maxDegree G b _ ≤ d := hdeg have hfib : ∀ (j : ℕ), 1 ≤ j → ∀ b : V, b ∈ L j → (Finset.filter (fun a => par a = b) (L (j+1))).card ≤ d - 1 := by intro j hj b hb have hbdist : G.dist v0 b = j := (memL j b).mp hb obtain ⟨hadj, hdist⟩ := par_spec b (by omega) have hsub : Finset.filter (fun a => par a = b) (L (j+1)) ⊆ (G.neighborFinset b).erase (par b) := by intro a ha rw [Finset.mem_filter] at ha obtain ⟨halayer, hapar⟩ := ha rw [memL] at halayer have hpos : 1 ≤ G.dist v0 a := by omega have hadja : G.Adj (par a) a := (par_spec a hpos).1 rw [Finset.mem_erase] refine ⟨?_, ?_⟩ · intro hEq have h1 : G.dist v0 a = G.dist v0 b - 1 := by rw [hEq]; exact hdist omega · rw [SimpleGraph.mem_neighborFinset] rwa [hapar] at hadja calc (Finset.filter (fun a => par a = b) (L (j+1))).card ≤ ((G.neighborFinset b).erase (par b)).card := Finset.card_le_card hsub _ = (G.neighborFinset b).card - 1 := Finset.card_erase_of_mem (by rw [SimpleGraph.mem_neighborFinset]; exact hadj.symm) _ = G.degree b - 1 := by rw [SimpleGraph.card_neighborFinset_eq_degree] _ ≤ d - 1 := by have h1 := SimpleGraph.degree_le_maxDegree G b omega have hstep : ∀ (j : ℕ), 1 ≤ j → (L (j+1)).card ≤ (d - 1) * (L j).card := by intro j hj refine le_trans (Finset.card_le_mul_card_image (f := par) (L (j+1)) (d - 1) ?_) ?_ · intro b hb exact hfib j hj b (himage j hb) · exact Nat.mul_le_mul_left _ (Finset.card_le_card (himage j)) have hlayer : ∀ i : ℕ, (L (i+1)).card ≤ d * (d - 1)^i := by intro i induction i with | zero => have h1 : (L 1).card ≤ d * (Finset.image par (L 1)).card := Finset.card_le_mul_card_image (f := par) (L 1) d (fun b hb => hfib0 b (himage 0 hb)) have h2 : (Finset.image par (L 1)).card ≤ 1 := by calc (Finset.image par (L 1)).card ≤ (L 0).card := Finset.card_le_card (himage 0) _ = 1 := by rw [hL0]; simp calc (L (0+1)).card = (L 1).card := rfl _ ≤ d * (Finset.image par (L 1)).card := h1 _ ≤ d * 1 := Nat.mul_le_mul_left _ h2 _ = d * (d - 1)^0 := by simp | succ i ih => calc (L (i+1+1)).card ≤ (d - 1) * (L (i+1)).card := hstep (i+1) (by omega) _ ≤ (d - 1) * (d * (d - 1)^i) := Nat.mul_le_mul_left _ ih _ = d * (d - 1)^(i+1) := by rw [pow_succ]; ring have hsum_le : ∑ i ∈ Finset.range k, (L (i+1)).card ≤ d * ∑ i ∈ Finset.range k, (d - 1)^i := by rw [Finset.mul_sum] exact Finset.sum_le_sum (fun i _ => hlayer i) have hcover : ∀ v ∈ (Finset.univ : Finset V), G.dist v0 v ∈ Finset.range (k+1) := fun v _ => Finset.mem_range.mpr (Nat.lt_succ_of_le (hdist_le v)) have hcard : Fintype.card V = ∑ i ∈ Finset.range (k+1), (L i).card := by have h := Finset.card_eq_sum_card_fiberwise (s := (Finset.univ : Finset V)) (t := Finset.range (k+1)) (f := fun v : V => G.dist v0 v) hcover simpa [hL] using h rw [hcard, Finset.sum_range_succ'] calc (∑ i ∈ Finset.range k, (L (i + 1)).card) + (L 0).card ≤ d * (∑ i ∈ Finset.range k, (d - 1)^i) + 1 := by rw [hL0, Finset.card_singleton] exact Nat.add_le_add_right hsum_le 1 _ = moore_bound d k := by rw [moore_bound, Nat.add_comm]