op2130_path_height_step_bridge
For a left-to-right path request, the cumulative discrepancy profile after the greedy update is exactly the local height update at the crossing index.
Statement
theorem op2130_path_height_step_bridge {n : ℕ} (d : Fin n → ℤ) (e : Fin n × Fin n) (he : e.2.val = e.1.val + 1) (c : Bool) (k : ℕ) : op_2130_path_prefix_discrepancies_coin_monotone_pfx (carpool_step n d e (if d e.1 < d e.2 then true else if d e.2 < d e.1 then false else c)) k = op2130_height_step (op_2130_path_prefix_discrepancies_coin_monotone_pfx d) (e.1.val + 1) c k
- Source
- OP-2130, correspondence of path heights and greedy discrepancies
- Verified
- 24 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 3
- op2130_height_stepOne greedy update of a path cumulative-height profile at an interior site, using the supplied coin for a tie.
- op_2130_path_prefix_discrepancies_coin_monotoneFor path requests written left to right, increasing any subset of the tie coins cannot decrease any prefix sum of the discrepancy vector…
- carpool_stepIn online carpooling on n vertices, given an edge e joining two distinct vertices and an orientation bit b, the discrepancy vector d…
The proof, explained
The proof proceeds by case analysis on the prefix index k relative to the adjacent edge e = (e₁, e₁ + 1). When k = e₁ + 1, the greedy choice comparing discrepancies at e₁ and e₂ is rewritten to match the discrete curvature condition of the height profile, showing the discrepancy update coincides with the height step at the crossing index. When k ≠ e₁ + 1 (either k ≤ e₁ or k ≥ e₁ + 2), the carpool step leaves the prefix discrepancy unaffected, matching the height step which modifies the profile solely at index e₁ + 1.
When k = e₁.val + 1, the prefix discrepancy after the greedy carpool step equals the height profile value updated at e₁.val + 1.
We first consider the case where the prefix index k is the boundary index e₁.val + 1 between the two endpoints of edge e. Substituting k = e₁.val + 1, lemma `op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_mid` rewrites the updated prefix discrepancy into the old prefix discrepancy plus an increment of +1 or -1 according to the boolean decision. Next, lemma `op_2130_path_prefix_discrepancies_coin_monotone_greedy_step_inc` translates the greedy edge decision comparing d(e₁) and d(e₂) into the discrete curvature condition on the height profile at e₁.val + 1. Finally, unfolding `op2130_height_step`, evaluating the updated function at the modified index via `Function.update_self`, simplifying (e₁.val + 1) - 1 = e₁.val using `Nat.add_sub_cancel`, and arithmetic for (e₁.val + 1) + 1 = e₁.val + 2 shows that both sides are identical.
uses
op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_mid,op_2130_path_prefix_discrepancies_coin_monotone_greedy_step_inc,Function.update_self,Nat.add_sub_cancelby_cases hk : k = e.1.val + 1 · subst k rw [op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_mid d e _ he, op_2130_path_prefix_discrepancies_coin_monotone_greedy_step_inc d e c he] simp only [op2130_height_step, Function.update_self, Nat.add_sub_cancel, show e.1.val + 1 + 1 = e.1.val + 2 by omega]
When k ≤ e₁.val, both the prefix discrepancy and the height profile remain unchanged from their values before the step.
Assuming k ≠ e₁.val + 1, we consider the subcase k ≤ e₁.val. Lemma `op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_low` establishes that the carpool step on edge e does not alter prefix discrepancies at indices k ≤ e₁.val. On the right-hand side, since k ≠ e₁.val + 1, `Function.update_of_ne` verifies that the height profile at index k is untouched by the height step at e₁.val + 1.
uses
op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_low,Function.update_of_ne· have hne : k ≠ e.1.val+1 := hk by_cases hlo : k ≤ e.1.val · rw [op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_low d e _ k he hlo] simp only [op2130_height_step, Function.update_of_ne hne]
When k ≥ e₁.val + 2, the prefix discrepancy and the height profile also both remain unchanged.
In the remaining subcase where k > e₁.val and k ≠ e₁.val + 1, linear arithmetic gives e₁.val + 2 ≤ k. For prefix sums that encompass both endpoints of the edge, the +1 and -1 adjustments to e₁ and e₂ cancel out, so `op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_high` shows the prefix discrepancy at k is unchanged. Since k ≠ e₁.val + 1, `Function.update_of_ne` again confirms that the height step does not modify the value at k.
uses
op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_high,Function.update_of_ne· have hhi : e.1.val+2 ≤ k := by omega rw [op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_high d e _ k he hhi] simp only [op2130_height_step, Function.update_of_ne hne]
op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_mid- For an adjacent edge e = (e₁, e₁ + 1), a carpool step on e changes the prefix discrepancy at the midpoint e₁ + 1 by +1 if the step decision is true and by -1 if false.
op_2130_path_prefix_discrepancies_coin_monotone_greedy_step_inc- For an adjacent edge e = (e₁, e₁ + 1), the ±1 change chosen by the greedy carpool rule (comparing d(e₁) and d(e₂) with tie-breaker c) equals the ±1 change determined by comparing 2h(e₁ + 1) with h(e₁) + h(e₁ + 2).
Function.update_self- Evaluating an updated function `Function.update f a v` at the modified argument a returns the new value v.
Nat.add_sub_cancel- For any natural numbers n and m, (n + m) - m = n.
op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_low- For an adjacent edge e = (e₁, e₁ + 1), a carpool step on e leaves prefix discrepancies unchanged at any index k ≤ e₁.
Function.update_of_ne- Evaluating an updated function `Function.update f a' v` at an argument a ≠ a' returns the original value f(a).
op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_high- For an adjacent edge e = (e₁, e₁ + 1), a carpool step on e leaves prefix discrepancies unchanged at any index k ≥ e₁ + 2.
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 op2130_path_height_step_bridge {n : ℕ} (d : Fin n → ℤ) (e : Fin n × Fin n) (he : e.2.val = e.1.val + 1) (c : Bool) (k : ℕ) : op_2130_path_prefix_discrepancies_coin_monotone_pfx (carpool_step n d e (if d e.1 < d e.2 then true else if d e.2 < d e.1 then false else c)) k = op2130_height_step (op_2130_path_prefix_discrepancies_coin_monotone_pfx d) (e.1.val + 1) c k := by by_cases hk : k = e.1.val + 1 · subst k rw [op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_mid d e _ he, op_2130_path_prefix_discrepancies_coin_monotone_greedy_step_inc d e c he] simp only [op2130_height_step, Function.update_self, Nat.add_sub_cancel, show e.1.val + 1 + 1 = e.1.val + 2 by omega] · have hne : k ≠ e.1.val+1 := hk by_cases hlo : k ≤ e.1.val · rw [op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_low d e _ k he hlo] simp only [op2130_height_step, Function.update_of_ne hne] · have hhi : e.1.val+2 ≤ k := by omega rw [op_2130_path_prefix_discrepancies_coin_monotone_pfx_step_high d e _ k he hhi] simp only [op2130_height_step, Function.update_of_ne hne]