retained_line_expected_msf_two
For two vertices, the expected retained minimum spanning forest weight is q.
Statement
theorem retained_line_expected_msf_two (q : ℝ) : retained_line_expected_msf 2 q = q- Source
- Sanity check for the independent-edge distribution in OP-815.
- Verified
- 19 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 7
- retained_line_expected_msfThe expectation of the minimum spanning forest weight on n linearly arranged vertices when every possible edge is independently retained…
- retained_line_msf_weight_emptyThe minimum spanning forest of the empty graph on n line vertices has total weight zero.
- retained_line_msf_weightFor a graph on the first n nonnegative integers, the minimum total edge length among its spanning forests, one tree in each connected…
- OrderAn order of dimension d is a permutation of the attribute set {0, ..., d-1}, represented as a list without duplicates containing all…
- graph_costFor a finite vertex type V with [Fintype V], a pairwise distance function d : V → V → ℝ, and a simple graph T on V, graph_cost d T is…
- supportThe support $\mathrm{supp}(p) \subseteq \mathrm{Fin}\,n$ consists of coordinates where $p(i) \neq I$; the weight is…
- FThe prime field $\mathrm{GF}(p)$, realized as $\mathbb{Z}/p\mathbb{Z}$ via
ZMod.
The proof, explained
On two vertices {0, 1}, there are only two simple graphs: the empty graph ⊥ and the complete graph ⊤. The expected retained minimum spanning forest (MSF) weight is defined as a probability-weighted sum over all graphs on two vertices, where each graph G with e edges appears with probability q^e * (1-q)^(1-e). The empty graph has 0 edges and MSF weight 0, while the complete graph has 1 edge, is acyclic, and has MSF weight 1 (the distance between 0 and 1). Thus, the expectation reduces to a single non-zero term: q^1 * (1-q)^0 * 1 = q.
Any simple graph on two vertices is either the empty graph ⊥ or the complete graph ⊤
We perform a case split on whether vertices 0 and 1 are adjacent. If they are adjacent, then since a simple graph has no self-loops and adjacency is symmetric, the graph has an edge between 0 and 1 and between 1 and 0, which matches the complete graph ⊤ on Fin 2. If they are not adjacent, no pair of vertices is adjacent, which matches the empty graph ⊥.
uses
mtby_cases h : G.Adj 0 1 · right ext u v fin_cases u <;> fin_cases v · simp · simpa using h · simp [G.adj_symm h] · simp · left ext u v fin_cases u <;> fin_cases v · simp · simp [h] · simp [mt G.adj_symm h] · simp
The empty graph ⊥ and the complete graph ⊤ on two vertices are distinct (⊥ ≠ ⊤)
Assuming for contradiction that ⊥ = ⊤, their adjacency relations must be identical. Evaluating both relations on the pair (0, 1) implies that 0 and 1 are adjacent in ⊥ if and only if they are adjacent in ⊤. This simplifies to a contradiction because ⊥ has no edges while ⊤ connects 0 and 1.
uses
congr_fun₂,congr_argintro h have := congr_fun₂ (congr_arg SimpleGraph.Adj h) 0 1 simp at this
The universal set of simple graphs on two vertices is the two-element set {⊥, ⊤}
By extensionality, a graph G belongs to the universe if and only if it belongs to {⊥, ⊤}, which is equivalent to G = ⊥ ∨ G = ⊤. This holds directly from the two-vertex graph classification lemma.
uses
mem_univ,true_iff,mem_insert,mem_singleton,retained_line_expected_msf_two_simpleGraph_fin_twoext G simp only [mem_univ, true_iff, mem_insert, mem_singleton] exact retained_line_expected_msf_two_simpleGraph_fin_two G
The complete graph ⊤ on two vertices is acyclic
Suppose for contradiction that there exists a cycle c. Any simple cycle has length at least 3. On the other hand, the vertices in the tail of the cycle's support list are duplicate-free, so the tail's length cannot exceed the total number of vertices |Fin 2| = 2. Since the tail's length equals the cycle length, we have length ≤ 2, contradicting length ≥ 3.
uses
List.Nodup.length_le_card,List.length_tail,Nat.add_sub_cancelintro v c hc have h3 := hc.three_le_length have hle : c.support.tail.length ≤ 2 := List.Nodup.length_le_card hc.support_nodup have hlen : c.support.tail.length = c.length := by rw [List.length_tail, c.length_support, Nat.add_sub_cancel] omega
The retained minimum spanning forest weight of the complete graph ⊤ on two vertices is 1
By definition, the MSF weight is the infimum of the costs of maximal acyclic subgraphs. Since ⊤ is itself acyclic, any acyclic subgraph F ≤ ⊤ satisfies F ≤ ⊤, making ⊤ the unique maximal acyclic subgraph of itself. The line metric cost of ⊤ is (1/2) * (|0 - 1| + |1 - 0|) = 1. Therefore, the set of costs of maximal acyclic subgraphs is the singleton {1}, whose infimum is 1.
uses
Set.mem_ofPred_eq,Set.mem_singleton_iff,le_antisymm,le_top,retained_line_expected_msf_two_top_acyclic,le_rfl,Fin.sum_univ_two,csInf_singletonsimp only [retained_line_msf_weight] have h : {x : ℝ | ∃ F : SimpleGraph (Fin 2), Maximal (fun H : SimpleGraph (Fin 2) => H ≤ ⊤ ∧ H.IsAcyclic) F ∧ x = graph_cost (fun i j => |(i.val : ℝ) - (j.val : ℝ)|) F} = {1} := by ext x simp only [Set.mem_ofPred_eq, Set.mem_singleton_iff] constructor · rintro ⟨F, hF, rfl⟩ have hf : F = ⊤ := by apply le_antisymm le_top exact hF.2 ⟨le_rfl, retained_line_expected_msf_two_top_acyclic⟩ le_top subst F simp [graph_cost, Fin.sum_univ_two] ring · intro hx subst x refine ⟨⊤, ?_, ?_⟩ · refine ⟨⟨le_rfl, retained_line_expected_msf_two_top_acyclic⟩, ?_⟩ intro b hb _ exact hb.1 · simp [graph_cost, Fin.sum_univ_two] ring rw [h, csInf_singleton]
The complete graph ⊤ on two vertices has exactly 1 edge
The complete graph on n vertices has n choose 2 edges. For Fin 2, this is 2 choose 2 = 1. Lean shows that the cardinality under the classical decidability instance equals that under the canonical decidability instance for ⊤, where the library lemma card_edgeFinset_top_eq_card_choose_two directly applies.
uses
Set.toFinset_card,Fintype.card_congr,Equiv.refl,SimpleGraph.card_edgeFinset_top_eq_card_choose_twosimp only [SimpleGraph.edgeFinset, Set.toFinset_card] let inst1 := @SimpleGraph.fintypeEdgeSet (Fin 2) ⊤ Sym2.instFintype (fun a b => Classical.propDecidable (SimpleGraph.Adj ⊤ a b)) let inst2 := @SimpleGraph.fintypeEdgeSet (Fin 2) ⊤ Sym2.instFintype (fun a b => @SimpleGraph.Top.adjDecidable (Fin 2) _ a b) have h_eq : @Fintype.card (⊤ : SimpleGraph (Fin 2)).edgeSet inst1 = @Fintype.card (⊤ : SimpleGraph (Fin 2)).edgeSet inst2 := @Fintype.card_congr _ _ inst1 inst2 (Equiv.refl _) change @Fintype.card (⊤ : SimpleGraph (Fin 2)).edgeSet inst1 = 1 rw [h_eq] have h2 : @Fintype.card (⊤ : SimpleGraph (Fin 2)).edgeSet inst2 = 1 := by have h_choose := @SimpleGraph.card_edgeFinset_top_eq_card_choose_two (Fin 2) _ _ rw [← @Set.toFinset_card (Sym2 (Fin 2)) (⊤ : SimpleGraph (Fin 2)).edgeSet inst2] exact h_choose exact h2
The expected retained minimum spanning forest weight on two vertices is q
Unfolding the definition, the expected MSF weight is a sum over all graphs on two vertices, which the universe lemma reduces to the two-element set {⊥, ⊤}. Since ⊥ ≠ ⊤, the sum expands to two terms: the ⊥ term has MSF weight 0 and vanishes, while the ⊤ term has MSF weight 1 and 1 edge out of 2 choose 2 = 1 possible edges, contributing q^1 * (1 - q)^0 * 1 = q.
uses
retained_line_expected_msf_two_univ,Finset.sum_pair,retained_line_expected_msf_two_bot_ne_top,retained_line_msf_weight_empty,retained_line_expected_msf_two_msf_weight_top,mul_zero,zero_add,mul_one,retained_line_expected_msf_two_card_edgeFinset_topunfold retained_line_expected_msf rw [retained_line_expected_msf_two_univ] rw [Finset.sum_pair retained_line_expected_msf_two_bot_ne_top] rw [retained_line_msf_weight_empty, retained_line_expected_msf_two_msf_weight_top] simp only [mul_zero, zero_add, mul_one] rw [retained_line_expected_msf_two_card_edgeFinset_top] norm_num
mt- Modus tollens: if a implies b, then ¬b implies ¬a
congr_fun₂- Equal binary functions take equal values on any two inputs
congr_arg- Functions preserve equality of their inputs
mem_univ- Every element of a type belongs to Finset.univ
true_iff- (True ↔ p) simplifies to p
mem_insert- Membership in an inserted set: x ∈ insert a s ↔ x = a ∨ x ∈ s
mem_singleton- Membership in a singleton set: x ∈ {a} ↔ x = a
retained_line_expected_msf_two_simpleGraph_fin_two- Any simple graph on Fin 2 is either the empty graph ⊥ or the complete graph ⊤
List.Nodup.length_le_card- A list without duplicates in a finite type has length at most the cardinality of the type
List.length_tail- The length of the tail of a list is its length minus one
Nat.add_sub_cancel- For natural numbers n and m, (n + m) - m = n
Set.mem_ofPred_eq- Membership in a comprehension set {x | p x} is equivalent to p x
Set.mem_singleton_iff- Membership in a singleton set: x ∈ {a} ↔ x = a
le_antisymm- In a partial order, if a ≤ b and b ≤ a, then a = b
le_top- In an order with a top element ⊤, every element a satisfies a ≤ ⊤
retained_line_expected_msf_two_top_acyclic- The complete graph ⊤ on Fin 2 is acyclic
le_rfl- The ordering relation ≤ is reflexive: a ≤ a
Fin.sum_univ_two- A sum of a function over Fin 2 equals f 0 + f 1
csInf_singleton- The infimum of a singleton set {a} is a
Set.toFinset_card- The cardinality of s.toFinset equals the Fintype cardinality of s
Fintype.card_congr- An equivalence (bijection) between two types implies their finite cardinalities are equal
Equiv.refl- The identity equivalence from a type to itself
SimpleGraph.card_edgeFinset_top_eq_card_choose_two- The complete graph on a vertex set V has |V| choose 2 edges
retained_line_expected_msf_two_univ- The universal finset of simple graphs on Fin 2 is {⊥, ⊤}
Finset.sum_pair- If a ≠ b, the sum of a function over {a, b} equals f a + f b
retained_line_expected_msf_two_bot_ne_top- The empty graph ⊥ and the complete graph ⊤ on Fin 2 are distinct (⊥ ≠ ⊤)
retained_line_msf_weight_empty- The retained minimum spanning forest weight of the empty graph ⊥ is 0
retained_line_expected_msf_two_msf_weight_top- The retained minimum spanning forest weight of the complete graph ⊤ on Fin 2 is 1
mul_zero- Multiplying by zero yields zero: a * 0 = 0
zero_add- Adding zero yields the original element: 0 + a = a
mul_one- Multiplying by one yields the original element: a * 1 = a
retained_line_expected_msf_two_card_edgeFinset_top- The complete graph ⊤ on Fin 2 has exactly 1 edge
- In the proof of retained_line_expected_msf_two_card_edgeFinset_top (lines 70-84), Lean works with two different decidability instances for the edge set of ⊤ (classical decidability versus the canonical decidability for the complete graph) and uses Fintype.card_congr to transfer the cardinality between them before applying SimpleGraph.card_edgeFinset_top_eq_card_choose_two.
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.
open scoped Classicalopen Finsetlemma retained_line_expected_msf_two_simpleGraph_fin_two (G : SimpleGraph (Fin 2)) : G = ⊥ ∨ G = ⊤ := by by_cases h : G.Adj 0 1 · right ext u v fin_cases u <;> fin_cases v · simp · simpa using h · simp [G.adj_symm h] · simp · left ext u v fin_cases u <;> fin_cases v · simp · simp [h] · simp [mt G.adj_symm h] · simplemma retained_line_expected_msf_two_bot_ne_top : (⊥ : SimpleGraph (Fin 2)) ≠ ⊤ := by intro h have := congr_fun₂ (congr_arg SimpleGraph.Adj h) 0 1 simp at thislemma retained_line_expected_msf_two_univ : (Finset.univ : Finset (SimpleGraph (Fin 2))) = {⊥, ⊤} := by ext G simp only [mem_univ, true_iff, mem_insert, mem_singleton] exact retained_line_expected_msf_two_simpleGraph_fin_two Glemma retained_line_expected_msf_two_top_acyclic : (⊤ : SimpleGraph (Fin 2)).IsAcyclic := by intro v c hc have h3 := hc.three_le_length have hle : c.support.tail.length ≤ 2 := List.Nodup.length_le_card hc.support_nodup have hlen : c.support.tail.length = c.length := by rw [List.length_tail, c.length_support, Nat.add_sub_cancel] omegalemma retained_line_expected_msf_two_msf_weight_top : retained_line_msf_weight (⊤ : SimpleGraph (Fin 2)) = 1 := by simp only [retained_line_msf_weight] have h : {x : ℝ | ∃ F : SimpleGraph (Fin 2), Maximal (fun H : SimpleGraph (Fin 2) => H ≤ ⊤ ∧ H.IsAcyclic) F ∧ x = graph_cost (fun i j => |(i.val : ℝ) - (j.val : ℝ)|) F} = {1} := by ext x simp only [Set.mem_ofPred_eq, Set.mem_singleton_iff] constructor · rintro ⟨F, hF, rfl⟩ have hf : F = ⊤ := by apply le_antisymm le_top exact hF.2 ⟨le_rfl, retained_line_expected_msf_two_top_acyclic⟩ le_top subst F simp [graph_cost, Fin.sum_univ_two] ring · intro hx subst x refine ⟨⊤, ?_, ?_⟩ · refine ⟨⟨le_rfl, retained_line_expected_msf_two_top_acyclic⟩, ?_⟩ intro b hb _ exact hb.1 · simp [graph_cost, Fin.sum_univ_two] ring rw [h, csInf_singleton]lemma retained_line_expected_msf_two_card_edgeFinset_top : @Finset.card (Sym2 (Fin 2)) (@SimpleGraph.edgeFinset (Fin 2) ⊤ (@SimpleGraph.fintypeEdgeSet (Fin 2) ⊤ Sym2.instFintype fun a b => Classical.propDecidable (SimpleGraph.Adj ⊤ a b))) = 1 := by simp only [SimpleGraph.edgeFinset, Set.toFinset_card] let inst1 := @SimpleGraph.fintypeEdgeSet (Fin 2) ⊤ Sym2.instFintype (fun a b => Classical.propDecidable (SimpleGraph.Adj ⊤ a b)) let inst2 := @SimpleGraph.fintypeEdgeSet (Fin 2) ⊤ Sym2.instFintype (fun a b => @SimpleGraph.Top.adjDecidable (Fin 2) _ a b) have h_eq : @Fintype.card (⊤ : SimpleGraph (Fin 2)).edgeSet inst1 = @Fintype.card (⊤ : SimpleGraph (Fin 2)).edgeSet inst2 := @Fintype.card_congr _ _ inst1 inst2 (Equiv.refl _) change @Fintype.card (⊤ : SimpleGraph (Fin 2)).edgeSet inst1 = 1 rw [h_eq] have h2 : @Fintype.card (⊤ : SimpleGraph (Fin 2)).edgeSet inst2 = 1 := by have h_choose := @SimpleGraph.card_edgeFinset_top_eq_card_choose_two (Fin 2) _ _ rw [← @Set.toFinset_card (Sym2 (Fin 2)) (⊤ : SimpleGraph (Fin 2)).edgeSet inst2] exact h_choose exact h2theorem retained_line_expected_msf_two (q : ℝ) : retained_line_expected_msf 2 q = q := by unfold retained_line_expected_msf rw [retained_line_expected_msf_two_univ] rw [Finset.sum_pair retained_line_expected_msf_two_bot_ne_top] rw [retained_line_msf_weight_empty, retained_line_expected_msf_two_msf_weight_top] simp only [mul_zero, zero_add, mul_one] rw [retained_line_expected_msf_two_card_edgeFinset_top] norm_num