op874_finite_parent_root_has_leaf
A nonempty finite set with a root outside the parent map has a member with no child in the set.
Statement
theorem op874_finite_parent_root_has_leaf {X : Type*} [DecidableEq X] (S : Finset X) (root : X) (parent : X → Option X) (hroot : root ∈ S) (hrootp : parent root = none) : ∃ a ∈ S, ∀ b ∈ S, parent b ≠ some a
- Source
- Finite parent-map counting lemma for the maximum-cut exchange tree.
- Verified
- 22 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext
The proof, explained
The proof proceeds by contradiction. If no element in the finite set S is childless, every element has a child in S, which defines a child-selection map f : S → S. Because each node has at most one parent, f is injective, and since S is finite, f must also be surjective. Surjectivity implies that the root is the child of some element in S, contradicting the hypothesis that the root has no parent.
Suppose, for contradiction, that every element of S has a child in S.
We argue by contradiction. Negating the existence of a childless element in S and pushing the negation past the quantifiers yields the assumption that for every element a ∈ S, there exists some b ∈ S whose parent is a (parent b = some a).
classical by_contra hn push_neg at hn
There is a function f : S → S selecting a child for each element of S.
By classical choice applied to the negated hypothesis, every a ∈ S can be associated with a chosen child f(a) ∈ S such that parent(f(a)) = some a.
uses
Classical.choose,Classical.choose_speclet f : {a // a ∈ S} → {a // a ∈ S} := fun a => ⟨Classical.choose (hn a a.property), (Classical.choose_spec (hn a a.property)).1⟩ have hf (a : {a // a ∈ S}) : parent (f a) = some a := (Classical.choose_spec (hn a a.property)).2
The child-selection map f is injective.
Suppose f(a) = f(b) for two elements a, b ∈ S. Applying the parent map gives some a = parent(f(a)) = parent(f(b)) = some b. Since the constructor some is injective, the underlying values of a and b are equal, which implies a = b as elements of the subtype S.
uses
congrArg,Subtype.ext,Option.some.injhave hinj : Function.Injective f := by intro a b hab have h : some a.val = some b.val := (hf a).symm.trans (congrArg parent (congrArg Subtype.val hab) |>.trans (hf b)) apply Subtype.ext exact Option.some.inj h
The function f is surjective.
Because S is finite, any injective map from S to itself is also surjective by the pigeonhole principle.
uses
Finite.injective_iff_surjective.mphave hsurj : Function.Surjective f := Finite.injective_iff_surjective.mp hinjA contradiction is derived from the fact that root has no parent.
By surjectivity of f, the element root ∈ S has a preimage a ∈ S such that f(a) = root. Evaluating the parent map yields parent(root) = parent(f(a)) = some a. However, root is assumed to have no parent (parent root = none), giving none = some a, which is an immediate contradiction between distinct constructors of Option.
uses
congrArgobtain ⟨a, ha⟩ := hsurj ⟨root, hroot⟩ have hp := hf a have : (f a).val = root := congrArg Subtype.val ha rw [this, hrootp] at hp cases hp
Classical.choose- Given an existential statement ∃ x, p x, returns a witness x.
Classical.choose_spec- The witness produced by Classical.choose satisfies the property p.
congrArg- Applying a function to equal arguments yields equal values: if a₁ = a₂, then f a₁ = f a₂.
Subtype.ext- Two terms of a subtype are equal if their underlying values are equal.
Option.some.inj- The some constructor of Option is injective: if some x = some y, then x = y.
Finite.injective_iff_surjective.mp- An injective function from a finite type to itself is surjective.
- The finite set S is represented formally as the subtype {a // a ∈ S} so that library results for endofunctions on finite types (specifically Finite.injective_iff_surjective) can be applied.
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.
theorem op874_finite_parent_root_has_leaf {X : Type*} [DecidableEq X] (S : Finset X) (root : X) (parent : X → Option X) (hroot : root ∈ S) (hrootp : parent root = none) : ∃ a ∈ S, ∀ b ∈ S, parent b ≠ some a := by classical by_contra hn push_neg at hn let f : {a // a ∈ S} → {a // a ∈ S} := fun a => ⟨Classical.choose (hn a a.property), (Classical.choose_spec (hn a a.property)).1⟩ have hf (a : {a // a ∈ S}) : parent (f a) = some a := (Classical.choose_spec (hn a a.property)).2 have hinj : Function.Injective f := by intro a b hab have h : some a.val = some b.val := (hf a).symm.trans (congrArg parent (congrArg Subtype.val hab) |>.trans (hf b)) apply Subtype.ext exact Option.some.inj h have hsurj : Function.Surjective f := Finite.injective_iff_surjective.mp hinj obtain ⟨a, ha⟩ := hsurj ⟨root, hroot⟩ have hp := hf a have : (f a).val = root := congrArg Subtype.val ha rw [this, hrootp] at hp cases hp