op2130_mc_step_agrees_general
For any list of n discrepancies and any valid path edge j,j+1, the list-state greedy update agrees coordinatewise with the existing finite-vertex carpool step.
Statement
theorem op2130_mc_step_agrees_general (n : ℕ) (d : List ℤ) (hd : d.length = n) (j : ℕ) (hj : j+1 < n) (c : Bool) (v : Fin n) : let D : Fin n → ℤ := fun i => d.getD i.val 0 let a : Fin n := ⟨j, by omega⟩ let b : Fin n := ⟨j+1, hj⟩ (op2130_mc_step d j c).getD v.val 0 = carpool_step n D (a,b) (if D a < D b then true else if D b < D a then false else c) v
- Source
- OP-2130, list-state and finite-path greedy update
- Verified
- 24 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 2
- op2130_interval_marginal_recursive_counterexampleFor an explicit 33-request six-vertex path schedule, the recursively enumerated fair-coin greedy process in the list-state representation…
- carpool_stepIn online carpooling on n vertices, given an edge e joining two distinct vertices and an orientation bit b, the discrepancy vector d…
- Used by 1
- op2130_setup_replay_matches_carpoolFor every valid list of path-edge indices and coin bits, replaying the list-state greedy updates from zero agrees with the repository…
The proof, explained
The proof establishes that the list-based greedy update `op2130_mc_step` agrees coordinatewise with `carpool_step` on edge (j, j+1) by case analysis on whether the vertex v equals j, equals j+1, or lies outside the edge. For each endpoint (v = j and v = j+1), unfolding the definitions and simplifying list lookups reveals that both operations select the same step direction from the discrepancies and tie-breaking coin, updating the two endpoints with opposite signs. For any other vertex, list-update lemmas show that neither operation modifies the entry at v. In each case, simplifying and integer arithmetic (`omega`) close all resulting branches.
The edge endpoints j and j+1 are strictly less than n and lie within the bounds of the discrepancy list d.
From the hypothesis j + 1 < n and d.length = n, linear arithmetic (`omega`) proves j < n (making a = ⟨j, ·⟩ a well-defined element of Fin n) as well as j < d.length (h0) and j + 1 < d.length (h1).
let a : Fin n := ⟨j, by omega⟩ let b : Fin n := ⟨j+1, hj⟩ (op2130_mc_step d j c).getD v.val 0 = carpool_step n D (a,b) (if D a < D b then true else if D b < D a then false else c) v := by have h0 : j < d.length := by omega have h1 : j+1 < d.length := by omega
When v = j, the list update and the carpool step produce identical values at v.
Assuming v.val = j (hv0), it follows by linear arithmetic that v.val ≠ j + 1 (hv1). Unfolding the definitions of `op2130_mc_step` and `carpool_step` and simplifying list indexing at position j reduces the claim to verifying that both definitions add 1 when d[j] < d[j+1] or when d[j] = d[j+1] with c = true, and subtract 1 otherwise. Case-splitting on these conditions (`split_ifs`) leaves subgoals that are either trivial equalities closed by `simp_all` or contradictory inequality systems closed by `omega`.
uses
op2130_mc_step,carpool_step,List.getD_eq_getElem?_getD,List.getElem?_set,Fin.ext_iffby_cases hv0 : v.val = j · have hv1 : v.val ≠ j+1 := by omega simp [op2130_mc_step, carpool_step, List.getD_eq_getElem?_getD, List.getElem?_set, Fin.ext_iff, hv0, hv1, h0, h1] <;> split_ifs <;> simp_all <;> omega
When v = j+1, the list update and the carpool step produce identical values at v.
Given v.val ≠ j from the preceding case, we assume v.val = j + 1 (hv1). Unfolding the definitions and rewriting the list lookup at j+1 shows that both operations subtract 1 when d[j] < d[j+1] (or on a tie with c = true) and add 1 otherwise. As in the previous case, splitting on the if-then-else conditions (`split_ifs`) reduces all branches to basic identities or contradictions solved by `simp_all` and `omega`.
uses
op2130_mc_step,carpool_step,List.getD_eq_getElem?_getD,List.getElem?_set,Fin.ext_iff· by_cases hv1 : v.val = j+1 · simp [op2130_mc_step, carpool_step, List.getD_eq_getElem?_getD, List.getElem?_set, Fin.ext_iff, hv0, hv1, h0, h1] <;> split_ifs <;> simp_all <;> omega
When v ≠ j and v ≠ j+1, both operations leave the value at v unchanged.
When v is neither endpoint of the edge, `List.getElem?_set` shows that updating the list at j and j+1 does not affect the entry at index v. In `carpool_step`, neither indicator condition (v = a or v = b) holds, so both add zero. The simplifier (`simp`) evaluates both sides directly to d[v] and closes the goal.
uses
op2130_mc_step,carpool_step,List.getD_eq_getElem?_getD,List.getElem?_set,Fin.ext_iff,Ne.symm· simp [op2130_mc_step, carpool_step, List.getD_eq_getElem?_getD, List.getElem?_set, Fin.ext_iff, hv0, hv1, Ne.symm hv0, Ne.symm hv1, h0, h1]
carpool_step- The carpool discrepancy step on a finite vertex set: given edge (a, b) and boolean direction c, it increments discrepancy at a by +1 (if c is true) or -1 (if false), applies the opposite update at b, and leaves other vertices unchanged.
Fin.ext_iff- Two elements of Fin n are equal if and only if their underlying natural numbers are equal.
List.getD_eq_getElem?_getD- Looking up an element with a default value, l.getD i a, is equivalent to taking the optional lookup l[i]? with default a.
List.getElem?_set- Accessing index j of a list updated at index i yields the new element if i = j (provided i is within bounds), and the original element l[j]? otherwise.
Ne.symm- Inequality is symmetric: if a ≠ b then b ≠ a.
op2130_mc_step- The greedy transition step on a list of discrepancies: it compares the values at indices j and j+1 to choose an increment in {1, -1} (using the boolean coin c as a tie-breaker), incrementing index j and decrementing index j+1.
- On paper, list indexing and functions on finite sets are identified informally, whereas Lean requires explicit bridging between 0-based list updates (`List.set`, `List.getD`) and `Fin n` values via lemmas such as `List.getElem?_set` and `Fin.ext_iff`.
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.
set_option maxHeartbeats 2000000theorem op2130_mc_step_agrees_general (n : ℕ) (d : List ℤ) (hd : d.length = n) (j : ℕ) (hj : j+1 < n) (c : Bool) (v : Fin n) : let D : Fin n → ℤ := fun i => d.getD i.val 0 let a : Fin n := ⟨j, by omega⟩ let b : Fin n := ⟨j+1, hj⟩ (op2130_mc_step d j c).getD v.val 0 = carpool_step n D (a,b) (if D a < D b then true else if D b < D a then false else c) v := by have h0 : j < d.length := by omega have h1 : j+1 < d.length := by omega by_cases hv0 : v.val = j · have hv1 : v.val ≠ j+1 := by omega simp [op2130_mc_step, carpool_step, List.getD_eq_getElem?_getD, List.getElem?_set, Fin.ext_iff, hv0, hv1, h0, h1] <;> split_ifs <;> simp_all <;> omega · by_cases hv1 : v.val = j+1 · simp [op2130_mc_step, carpool_step, List.getD_eq_getElem?_getD, List.getElem?_set, Fin.ext_iff, hv0, hv1, h0, h1] <;> split_ifs <;> simp_all <;> omega · simp [op2130_mc_step, carpool_step, List.getD_eq_getElem?_getD, List.getElem?_set, Fin.ext_iff, hv0, hv1, Ne.symm hv0, Ne.symm hv1, h0, h1]