op874_distance_partial_bits
If each nonroot vertex descends in distance to an allowed successor and both specified successors have odd distance, parity gives the needed partial bits.
Statement
theorem op874_distance_partial_bits {X : Type*} [DecidableEq X] (p q : X → X) (S : Finset X) (r x : X) (d : X → ℕ) (hr : r ∈ S) (hx : x ∈ S) (hp : p x ∈ S) (hq : q x ∈ S) (hfix : p x ≠ x ∧ q x ≠ x) (hodd : d (p x) % 2 = 1 ∧ d (q x) % 2 = 1) (hdesc : ∀ y ∈ S, y ≠ r → y ≠ x → (p y ∈ S ∧ p y ≠ x ∧ d y = d (p y) + 1) ∨ (q y ∈ S ∧ q y ≠ x ∧ d y = d (q y) + 1)) : ∃ b : X → Bool, (∀ y ∈ S, y ≠ r → (p y ∈ S ∧ b y ≠ b (p y)) ∨ (q y ∈ S ∧ b y ≠ b (q y))) ∧ b x ≠ b (p x) ∧ b x ≠ b (q x)
- Source
- A descending-distance certificate yields the required partial bit assignment.
- Verified
- 22 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 1
- op874_distance_parity_succ_neConsecutive natural numbers have opposite parity.
The proof, explained
The theorem constructs an explicit boolean labeling b on X by assigning b(x) = true and setting b(y) to the parity of d(y) (whether d(y) is even) for every y ≠ x. Since both p(x) and q(x) differ from x and have odd distance, b evaluates to false at both points, immediately ensuring that b flips along both transitions from x. For any other vertex y ∈ S distinct from the root r and from x, the descent hypothesis provides a successor avoiding x whose distance is d(y) - 1; because consecutive natural numbers have opposite parity, the bit flips along that transition.
Define a candidate boolean labeling b on X and verify that b x differs from both b (p x) and b (q x).
We define b(y) to be true if y = x, and otherwise the boolean value of d(y) % 2 = 0 (whether d(y) is even). Since p x ≠ x and q x ≠ x by assumption, evaluating b on p x and q x falls into the else-branch. Because both d(p x) and d(q x) are odd, those evaluations yield false, which is distinct from b(x) = true.
let b : X → Bool := fun y => if y = x then true else decide (d y % 2 = 0) have hpx : b x ≠ b (p x) := by simp [b, hfix.1, hodd.1] have hqx : b x ≠ b (q x) := by simp [b, hfix.2, hodd.2]
It suffices to show that every non-root vertex y ∈ S with y ≠ r has an allowed successor in S that flips the bit under b.
We instantiate the existential quantifier with b, providing the inequalities b x ≠ b (p x) and b x ≠ b (q x) already established. This leaves only the condition for all non-root vertices y ∈ S.
refine ⟨b, ?_, hpx, hqx⟩The required successor condition holds when y = x.
We fix a vertex y ∈ S with y ≠ r and split into cases on whether y = x. When y = x, we choose the left alternative p(x): the assumption hp gives p x ∈ S, and the inequality b x ≠ b (p x) was already established, so Or.inl completes this case.
uses
Or.inlintro y hy hyr by_cases hyx : y = x · subst y exact Or.inl ⟨hp, hpx⟩
When y ≠ x and the descending successor is given by p, the condition holds.
When y ≠ x, the descent hypothesis hdesc provides a successor of distance d(y) - 1 avoiding x. In the first case, p y ∈ S, p y ≠ x, and d y = d (p y) + 1. Since neither y nor p y equals x, the definition of b simplifies by if_neg to parity tests on d(y) and d(p y). Rewriting d y with d (p y) + 1, op874_distance_parity_succ_ne ensures that the parities of consecutive natural numbers differ.
uses
if_neg,op874_distance_parity_succ_ne· rcases hdesc y hy hyr hyx with ⟨hys, hyx', hd⟩ | ⟨hys, hyx', hd⟩ · left refine ⟨hys, ?_⟩ simp only [b, if_neg hyx, if_neg hyx'] rw [hd] exact op874_distance_parity_succ_ne _
When y ≠ x and the descending successor is given by q, the condition holds.
In the second case of the descent hypothesis, q y ∈ S, q y ≠ x, and d y = d (q y) + 1. Symmetrically, since neither y nor q y equals x, their bit values simplify by if_neg to parity checks on d(y) and d(q y). Rewriting d y as d (q y) + 1, op874_distance_parity_succ_ne confirms that b y ≠ b (q y).
uses
if_neg,op874_distance_parity_succ_ne· right refine ⟨hys, ?_⟩ simp only [b, if_neg hyx, if_neg hyx'] rw [hd] exact op874_distance_parity_succ_ne _
Or.inl- Given a proof of the proposition a, produces a proof of the disjunction a ∨ b.
if_neg- An if-then-else expression evaluates to its else-branch when the condition is false.
op874_distance_parity_succ_ne- The boolean indicator that a natural number is even takes different values for n + 1 and n.
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_distance_partial_bits {X : Type*} [DecidableEq X] (p q : X → X) (S : Finset X) (r x : X) (d : X → ℕ) (hr : r ∈ S) (hx : x ∈ S) (hp : p x ∈ S) (hq : q x ∈ S) (hfix : p x ≠ x ∧ q x ≠ x) (hodd : d (p x) % 2 = 1 ∧ d (q x) % 2 = 1) (hdesc : ∀ y ∈ S, y ≠ r → y ≠ x → (p y ∈ S ∧ p y ≠ x ∧ d y = d (p y) + 1) ∨ (q y ∈ S ∧ q y ≠ x ∧ d y = d (q y) + 1)) : ∃ b : X → Bool, (∀ y ∈ S, y ≠ r → (p y ∈ S ∧ b y ≠ b (p y)) ∨ (q y ∈ S ∧ b y ≠ b (q y))) ∧ b x ≠ b (p x) ∧ b x ≠ b (q x) := by let b : X → Bool := fun y => if y = x then true else decide (d y % 2 = 0) have hpx : b x ≠ b (p x) := by simp [b, hfix.1, hodd.1] have hqx : b x ≠ b (q x) := by simp [b, hfix.2, hodd.2] refine ⟨b, ?_, hpx, hqx⟩ intro y hy hyr by_cases hyx : y = x · subst y exact Or.inl ⟨hp, hpx⟩ · rcases hdesc y hy hyr hyx with ⟨hys, hyx', hd⟩ | ⟨hys, hyx', hd⟩ · left refine ⟨hys, ?_⟩ simp only [b, if_neg hyx, if_neg hyx'] rw [hd] exact op874_distance_parity_succ_ne _ · right refine ⟨hys, ?_⟩ simp only [b, if_neg hyx, if_neg hyx'] rw [hd] exact op874_distance_parity_succ_ne _