AFTD Auto-Formalizing Theoretical Domains

op_2130_carpool_fold_avoids_vertex

theoremverified

A sequence of carpool updates whose requested edges all avoid a vertex leaves that vertex’s discrepancy unchanged.

Statement

theorem op_2130_carpool_fold_avoids_vertex (n : ℕ) (edges : List (Fin n × Fin n)) (signs : List Bool) (d : Fin n → ℤ) (v : Fin n) (h : ∀ e ∈ edges, v ≠ e.1 ∧ v ≠ e.2) : ((edges.zip signs).foldl (fun d (e, b) => carpool_step n d e b) d) v = d v
Source
Independent-path-block construction for refuting op_2130_path_greedy_fixed_time_tail
Verified
22 Nov 2026
Axioms
propext
Built on 1
  • 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 induction on the list of edges, generalizing over the sequence of signs and the initial discrepancy function. If either the edge list or the sign list is empty, the zipped list is empty, so no updates occur and the discrepancy at v is trivially unchanged. In the inductive step with a non-empty sign list, we peel off the first edge-sign pair: by the induction hypothesis, the remaining edges preserve the discrepancy at v. This reduces the problem to the single step on the first edge, which leaves the discrepancy at v invariant because v is not an endpoint of that edge.

  1. The theorem holds when the edge list is empty.

    We argue by induction on edges, generalizing over the sign list signs and discrepancy function d. In the base case where edges is the empty list [], zipping it with any signs yields the empty list. A fold over an empty list returns the initial discrepancy d unchanged, so d v = d v holds immediately.

    lines 2–3

      induction edges generalizing signs d with
      | nil => simp
  2. The inductive step holds when the sign list is empty.

    For the inductive step with edges = e :: es, we case-split on signs. If signs is empty, zipping e :: es with [] is again empty, so no carpool steps are applied and the discrepancy remains d v.

    lines 4–6

      | cons e es ih =>
        cases signs with
        | nil => simp
  3. The head edge e avoids vertex v, and every edge in the tail es also avoids v.

    When signs = b :: bs, both lists are non-empty. Since e is the head of e :: es (by List.mem_cons_self), the hypothesis h implies that neither endpoint of e equals v (he). Likewise, any edge in the tail es belongs to e :: es (by List.mem_cons_of_mem), so h implies that all edges in es also avoid v (ht).

    lines 7–9

    uses List.mem_cons_self, List.mem_cons_of_mem

        | cons b bs =>
          have he := h e (List.mem_cons_self ..)
          have ht : ∀ e ∈ es, v ≠ e.1 ∧ v ≠ e.2 := fun e he => h e (List.mem_cons_of_mem _ he)
  4. The full sequence of updates leaves v with the same discrepancy as after the first step alone.

    Rewriting with List.zip_cons_cons and List.foldl_cons decomposes the fold into a single update carpool_step n d e b on the head pair, followed by folding the remaining pairs es.zip bs. Because all edges in es avoid v (ht), the induction hypothesis ih applies to the tail, simplifying the entire fold evaluated at v to just carpool_step n d e b v.

    lines 10–11

    uses List.zip_cons_cons, List.foldl_cons

          simp only [List.zip_cons_cons, List.foldl_cons]
          rw [ih bs (carpool_step n d e b) ht]
  5. The first update leaves the discrepancy at vertex v unchanged.

    By definition, carpool_step n d e b modifies the discrepancy function only at the two endpoints e.1 and e.2 of the edge e. Since v is distinct from both endpoints by he, the conditional adjustment terms are zero, leaving the discrepancy at v equal to d v.

    line 12

          simp [carpool_step, he.1, he.2]
List.mem_cons_self
An element belongs to any list formed by prepending it to a tail (a ∈ a :: l).
List.mem_cons_of_mem
An element that belongs to a list also belongs to that list with any element prepended (a ∈ l → a ∈ y :: l).
List.zip_cons_cons
Zipping two non-empty lists pairs their heads and prepends this pair to the zip of their tails: (a :: as).zip (b :: bs) = (a, b) :: as.zip bs.
List.foldl_cons
Left-folding an accumulator over a non-empty list is equivalent to folding over the tail starting from the accumulator updated by the head: List.foldl f b (a :: l) = List.foldl f (f b a) l.

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

theorem op_2130_carpool_fold_avoids_vertex (n : ℕ) (edges : List (Fin n × Fin n)) (signs : List Bool) (d : Fin n → ℤ) (v : Fin n) (h : ∀ e ∈ edges, v ≠ e.1 ∧ v ≠ e.2) : ((edges.zip signs).foldl (fun d (e, b) => carpool_step n d e b) d) v = d v := by  induction edges generalizing signs d with  | nil => simp  | cons e es ih =>    cases signs with    | nil => simp    | cons b bs =>      have he := h e (List.mem_cons_self ..)      have ht : ∀ e ∈ es, v ≠ e.1 ∧ v ≠ e.2 := fun e he => h e (List.mem_cons_of_mem _ he)      simp only [List.zip_cons_cons, List.foldl_cons]      rw [ih bs (carpool_step n d e b) ht]      simp [carpool_step, he.1, he.2]
See it in the graphDiscuss this resultChallenge it