AFTD Auto-Formalizing Theoretical Domains

op_2130_greedy_discrepancies_embedding

theoremverified

After injectively relabeling the vertices of a greedy carpool instance, restricting every prefix discrepancy vector to the original vertices recovers the original trajectory.

Statement

theorem op_2130_greedy_discrepancies_embedding (n m : ℕ) (f : Fin n ↪ Fin m) (edges : List (Fin n × Fin n)) (coins : List Bool) : (carpool_discrepancies m (edges.map (fun e => (f e.1, f e.2))) (carpool_greedy_orientations m (edges.map (fun e => (f e.1, f e.2))) coins)).map (fun d => fun v => d (f v)) = carpool_discrepancies n edges (carpool_greedy_orientations n edges coins)
Source
Independent-path-block construction for refuting op_2130_path_greedy_fixed_time_tail
Verified
22 Nov 2026
Axioms
Quot.soundpropext
Built on 4
  • op_2130_greedy_orientations_embeddingInjectively relabeling the vertices of a greedy carpool instance leaves its sequence of orientations unchanged for the same tie-breaking…
  • carpool_discrepanciesThe sequence of discrepancy vectors (d₀, ..., d_T) starting from the zero vector, where each d_t is updated from d_{t-1} using the t-th…
  • carpool_greedy_orientationsGiven a list of edges and a list of tie-breaking coins, randomized greedy carpooling orients each edge toward the endpoint with smaller…
  • 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 in three stages: single-step compatibility, full trajectory scan compatibility, and application to the greedy algorithm. First, an injective vertex embedding preserves each single carpool step because endpoint equality tests are invariant under injection. Second, by induction on the edge list, the prefix discrepancy vectors produced by scanning along embedded edges commute with restriction to the original vertices. Finally, combining this scan invariance with the fact that greedy edge orientations are invariant under vertex relabeling (`op_2130_greedy_orientations_embedding`), the full trajectory of greedy discrepancy vectors restricts to the original trajectory.

  1. A single carpool step commutes with restricting discrepancy vectors along an injective vertex embedding.

    Fix a vertex v. Because the embedding f is injective, f v = f e.1 is equivalent to v = e.1, and f v = f e.2 is equivalent to v = e.2. Unfolding `carpool_step`, the discrepancy update at f v adds the same conditional deltas as the update at v, and the base discrepancies match by the hypothesis hd v, so simplifying with these equivalences proves the claim.

    lines 5–8

    uses f.injective.eq_iff

      intro v
      have h1 : (f v = f e.1) ↔ v = e.1 := f.injective.eq_iff
      have h2 : (f v = f e.2) ↔ v = e.2 := f.injective.eq_iff
      simp [carpool_step, hd v, h1, h2]
  2. Discrepancy trajectories commute with restriction along the embedding whenever either the edge list or the sign list is empty.

    We induct on `edges`, generalizing `signs`, `d`, and `d'`. When `edges` is empty, zipping with `signs` gives the empty list, so `scanl` returns only the initial discrepancy vector [d'] on the embedded graph and [d] on the original graph. By function extensionality (`funext hd`), d' restricted to the embedded vertices is d. In the inductive step with edges `e :: es`, if `signs` is empty, the zipped list is again empty and the same reasoning closes the goal.

    lines 15–20

    uses funext

      induction edges generalizing signs d d' with
      | nil => simp [List.scanl, funext hd]
      | cons e es ih =>
        cases signs with
        | nil => simp [List.scanl, funext hd]
        | cons b bs =>
  3. Discrepancy trajectories commute with restriction along the embedding for non-empty edge and sign lists.

    When both an edge `e` and a sign `b` are available, `scanl` produces a list whose head is the initial discrepancy vector and whose tail is the scan over the remaining edges and signs starting from the updated discrepancy vector. Function extensionality (`funext hd`) identifies the heads. Removing the head via `congr 1`, the remaining tails match by the induction hypothesis on `bs`, where the updated discrepancy vectors satisfy the required agreement condition by `op2130_scan_step_embedding`.

    lines 21–25

    uses List.map_cons, List.zip_cons_cons, List.scanl_cons, funext, op2130_scan_step_embedding

          simp only [List.map_cons, List.zip_cons_cons, List.scanl_cons]
          have heq : (fun v => d' (f v)) = d := funext hd
          rw [heq]
          congr 1
          exact ih bs _ _ (op2130_scan_step_embedding n m f d d' e b hd)
  4. Restricting the greedy discrepancy vectors of the embedded instance to the original vertices recovers the original discrepancy trajectory.

    We unfold `carpool_discrepancies` into a `scanl` over the greedy orientation signs starting from the zero function. Rewriting with `op_2130_greedy_orientations_embedding` replaces the greedy orientations of the embedded graph with the original greedy orientations. Finally, applying `scan_embedding` with initial discrepancy vectors that are identically zero (which trivially agree everywhere) concludes the proof.

    lines 28–30

    uses op_2130_greedy_orientations_embedding, scan_embedding

      unfold carpool_discrepancies
      rw [op_2130_greedy_orientations_embedding]
      exact scan_embedding n m f edges _ _ _ (by intro; rfl)
f.injective.eq_iff
An injective function maps two arguments to the same value if and only if the arguments are equal.
funext
Two functions are equal if they evaluate to the same value on every argument (function extensionality).
List.map_cons
Mapping a function over a non-empty list applies the function to the head and maps over the tail.
List.zip_cons_cons
Zipping two non-empty lists pairs their first elements and zips the remaining tails.
List.scanl_cons
A left scan of a non-empty list begins with the initial accumulator, followed by the scan of the tail using the updated accumulator.
op2130_scan_step_embedding
Restricting the discrepancy vector after one carpool step on embedded vertices matches the one-step discrepancy update on the original vertices.
op_2130_greedy_orientations_embedding
The list of greedy carpool orientations is invariant under an injective relabeling of vertices.
scan_embedding
Scanning discrepancy updates along embedded edges produces prefix discrepancy vectors that, when restricted to the embedded vertices, match the prefix discrepancies scanned along the original edges.

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

private lemma op2130_scan_step_embedding (n m : ℕ) (f : Fin n ↪ Fin m)    (d : Fin n → ℤ) (d' : Fin m → ℤ) (e : Fin n × Fin n) (b : Bool)    (hd : ∀ v, d' (f v) = d v) :    ∀ v, carpool_step m d' (f e.1, f e.2) b (f v) = carpool_step n d e b v := by  intro v  have h1 : (f v = f e.1) ↔ v = e.1 := f.injective.eq_iff  have h2 : (f v = f e.2) ↔ v = e.2 := f.injective.eq_iff  simp [carpool_step, hd v, h1, h2]private lemma scan_embedding (n m : ℕ) (f : Fin n ↪ Fin m)    (edges : List (Fin n × Fin n)) (signs : List Bool)    (d : Fin n → ℤ) (d' : Fin m → ℤ) (hd : ∀ v, d' (f v) = d v) :    (((edges.map (fun e => (f e.1, f e.2))).zip signs).scanl (fun (d : Fin m → ℤ) (p : (Fin m × Fin m) × Bool) => carpool_step m d p.1 p.2) d').map (fun d => fun v => d (f v)) =      (edges.zip signs).scanl (fun (d : Fin n → ℤ) (p : (Fin n × Fin n) × Bool) => carpool_step n d p.1 p.2) d := by  induction edges generalizing signs d d' with  | nil => simp [List.scanl, funext hd]  | cons e es ih =>    cases signs with    | nil => simp [List.scanl, funext hd]    | cons b bs =>      simp only [List.map_cons, List.zip_cons_cons, List.scanl_cons]      have heq : (fun v => d' (f v)) = d := funext hd      rw [heq]      congr 1      exact ih bs _ _ (op2130_scan_step_embedding n m f d d' e b hd)theorem op_2130_greedy_discrepancies_embedding (n m : ℕ) (f : Fin n ↪ Fin m) (edges : List (Fin n × Fin n)) (coins : List Bool) : (carpool_discrepancies m (edges.map (fun e => (f e.1, f e.2))) (carpool_greedy_orientations m (edges.map (fun e => (f e.1, f e.2))) coins)).map (fun d => fun v => d (f v)) = carpool_discrepancies n edges (carpool_greedy_orientations n edges coins) := by  unfold carpool_discrepancies  rw [op_2130_greedy_orientations_embedding]  exact scan_embedding n m f edges _ _ _ (by intro; rfl)
See it in the graphDiscuss this resultChallenge it