@@ -3,8 +3,9 @@ Copyright (c) 2026 Nelson Spence. All rights reserved.
33Released under Apache 2.0 license as described in the file LICENSE.
44Authors: Nelson Spence
55-/
6- import FdFormal.FlowerGraph
7- import Mathlib.Tactic
6+ import Mathlib.Tactic.Zify
7+ import Mathlib.Tactic.Linarith
8+ import Mathlib.Data.Real.Basic
89
910set_option relaxedAutoImplicit false
1011set_option autoImplicit false
@@ -23,28 +24,121 @@ each edge is replaced by two parallel paths of lengths `u` and `v`,
2324contributing `(u - 1) + (v - 1) = w - 2` new internal vertices per
2425edge and multiplying the edge count by `w`.
2526
27+ The counting formulas are pure arithmetic recurrences and do not
28+ depend on the graph representation.
29+
30+ ## Main definitions
31+
32+ - `flowerEdgeCount` — number of edges at generation `g`
33+ - `flowerVertCount` — number of vertices at generation `g`
34+ - `flowerVertCountReal` — vertex count cast to `ℝ`
35+
2636 ## Main statements
2737
28- - `flower_edge_count` — `E_g = w^g`
29- - `flower_vertex_count` — `(w - 1) * N_g = (w - 2) * w^g + w`
38+ - `flowerEdgeCount_eq_pow` — `E_g = w^g`
39+ - `flowerVertCount_eq` — `(w - 1) * N_g = (w - 2) * w^g + w`
40+ - `flowerVertCount_lower` — `(w - 2) * w^g ≤ (w - 1) * N_g`
41+ - `flowerVertCount_upper` — `(w - 1) * N_g ≤ 2 * (w - 1) * w^g`
42+ - `flowerVertCount_pos` — `0 < N_g`
3043
3144 ## References
3245
3346- [ Rozenfeld2007 ] §2, construction and counting formulas.
47+
48+ ## Tags
49+
50+ flower graph, fractal, edge count, vertex count
3451-/
3552
36- -- TODO: State and prove edge_count and vertex_count once FlowerGraph
37- -- construction is defined.
38- --
39- -- The edge count E_g = w^g follows directly: each edge produces w
40- -- new edges (u edges on the short path + v edges on the long path).
41- --
42- -- The vertex count uses the recurrence:
43- -- N_{g+1} = N_g + (w - 2) * E_g
44- -- = N_g + (w - 2) * w^g
45- -- with N_0 = 2 (two hub vertices connected by a single edge).
46- -- Solving: (w-1) * N_g = (w-2) * w^g + w.
47- --
48- -- Real-valued wrappers for the headline theorem:
49- -- def V_count_real (u v g : ℕ) : ℝ := (N_g : ℝ)
50- -- Cast early, prove positivity lemmas here.
53+ /-- Number of edges in the (u,v)-flower at generation `g`. -/
54+ def flowerEdgeCount (u v : ℕ) : ℕ → ℕ
55+ | 0 => 1
56+ | g + 1 => (u + v) * flowerEdgeCount u v g
57+
58+ @[simp]
59+ theorem flowerEdgeCount_zero (u v : ℕ) : flowerEdgeCount u v 0 = 1 := rfl
60+
61+ @[simp]
62+ theorem flowerEdgeCount_succ (u v g : ℕ) :
63+ flowerEdgeCount u v (g + 1 ) = (u + v) * flowerEdgeCount u v g := rfl
64+
65+ /-- Number of vertices in the (u,v)-flower at generation `g`. -/
66+ def flowerVertCount (u v : ℕ) : ℕ → ℕ
67+ | 0 => 2
68+ | g + 1 => flowerVertCount u v g + (u + v - 2 ) * flowerEdgeCount u v g
69+
70+ @[simp]
71+ theorem flowerVertCount_zero (u v : ℕ) : flowerVertCount u v 0 = 2 := rfl
72+
73+ @[simp]
74+ theorem flowerVertCount_succ (u v g : ℕ) :
75+ flowerVertCount u v (g + 1 ) =
76+ flowerVertCount u v g + (u + v - 2 ) * flowerEdgeCount u v g := rfl
77+
78+ /-! ### Edge count -/
79+
80+ /-- The edge count of the (u,v)-flower at generation `g` is `(u + v) ^ g`. -/
81+ theorem flowerEdgeCount_eq_pow (u v g : ℕ) :
82+ flowerEdgeCount u v g = (u + v) ^ g := by
83+ induction g with
84+ | zero => simp
85+ | succ g ih => rw [flowerEdgeCount_succ, ih, pow_succ, mul_comm]
86+
87+ /-! ### Vertex count -/
88+
89+ /-- The vertex count satisfies `(w - 1) * N_g = (w - 2) * w^g + w`
90+ where `w = u + v`. Multiplicative form avoids ℕ division. -/
91+ theorem flowerVertCount_eq (u v g : ℕ) (hu : 1 < u) (huv : u ≤ v) :
92+ (u + v - 1 ) * flowerVertCount u v g =
93+ (u + v - 2 ) * (u + v) ^ g + (u + v) := by
94+ induction g with
95+ | zero =>
96+ simp
97+ omega
98+ | succ g ih =>
99+ simp only [flowerVertCount_succ, flowerEdgeCount_eq_pow, pow_succ]
100+ have h1 : 1 ≤ u + v := by omega
101+ have h2 : 2 ≤ u + v := by omega
102+ zify [h1, h2] at ih ⊢
103+ nlinarith [ih]
104+
105+ /-- The vertex count is always positive (holds for all `u`, `v`). -/
106+ theorem flowerVertCount_pos (u v g : ℕ) :
107+ 0 < flowerVertCount u v g := by
108+ induction g with
109+ | zero => simp
110+ | succ g ih =>
111+ simp only [flowerVertCount_succ]
112+ omega
113+
114+ /-! ### Two-sided bounds for squeeze -/
115+
116+ /-- Lower bound: `(w - 2) * w^g ≤ (w - 1) * N_g`. -/
117+ theorem flowerVertCount_lower (u v g : ℕ) (hu : 1 < u) (huv : u ≤ v) :
118+ (u + v - 2 ) * (u + v) ^ g ≤
119+ (u + v - 1 ) * flowerVertCount u v g := by
120+ rw [flowerVertCount_eq u v g hu huv]
121+ exact le_add_of_nonneg_right (Nat.zero_le _)
122+
123+ /-- Upper bound: `(w - 1) * N_g ≤ 2 * (w - 1) * w^g`. -/
124+ theorem flowerVertCount_upper (u v g : ℕ) (hu : 1 < u) (huv : u ≤ v) :
125+ (u + v - 1 ) * flowerVertCount u v g ≤
126+ 2 * (u + v - 1 ) * (u + v) ^ g := by
127+ rw [flowerVertCount_eq u v g hu huv]
128+ have h1 : 1 ≤ u + v := by omega
129+ have h2 : 2 ≤ u + v := by omega
130+ have h_pow : 1 ≤ (u + v) ^ g := Nat.one_le_pow _ _ (by omega)
131+ zify [h1, h2] at h_pow ⊢
132+ nlinarith [h_pow]
133+
134+ /-! ### Real-valued wrappers -/
135+
136+ /-- Vertex count cast to `ℝ`. -/
137+ noncomputable def flowerVertCountReal (u v : ℕ) (g : ℕ) : ℝ :=
138+ (flowerVertCount u v g : ℝ)
139+
140+ /-- The real-valued vertex count is positive. -/
141+ theorem flowerVertCountReal_pos (u v g : ℕ) :
142+ 0 < flowerVertCountReal u v g := by
143+ simp only [flowerVertCountReal]
144+ exact Nat.cast_pos.mpr (flowerVertCount_pos u v g)
0 commit comments