AFTD Auto-Formalizing Theoretical Domains

ssss_weak_duality

theoremverified

For any edge set E : Finset (V × V), edge costs c : V × V → ℝ, distinct terminals s ≠ t in V, and integer k : ℕ, if x : V × V → ℝ is feasible for the primal LP (SSSS-P) with k paths and (a, y) is feasible for the dual LP (SSSS-D), then the dual objective value ssss_dual_obj s t k a y is at most the primal objective value ssss_primal_obj E c x.

Statement

theorem ssss_weak_duality {V : Type*} [Fintype V] [DecidableEq V]
    (E : Finset (V × V)) (c : V × V → ℝ) (s t : V) (hst : s ≠ t) (k : ℕ)
    (x : V × V → ℝ) (hx : ssss_primal_feasible E s t k x)
    (a : V → ℝ) (y : Finset V → ℝ) (hy : ssss_dual_feasible E c s t a y) :
    ssss_dual_obj s t k a y ≤ ssss_primal_obj E c x
Source
arXiv:2611.26188, Section 3
Verified
22 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 5
  • ssss_primal_feasibleFor a finite vertex set V with decidable equality, a set of directed edges E : Finset (V × V), terminals s, t ∈ V, and an integer k : ℕ, a…
  • ssss_dual_feasibleA node potential vector a : V → ℝ and cut dual vector y : Finset V → ℝ are feasible for the dual LP relaxation (SSSS-D) on edge set E :…
  • ssss_primal_objFor a finite vertex type V with decidable equality, a set of directed edges E : Finset (V × V), and edge cost and flow functions c, x : V…
  • ssss_dual_objThe objective value of a dual solution (a, y) for k paths is k * (a(t) - a(s)) plus twice the sum of y_U over all non-empty subsets U of V…
  • ssss_cutsFor a finite vertex set V and vertices s, t ∈ V, ssss_cuts s t is the set of all non-empty subsets of V \ {s, t}.

Read back from the Lean

For any finite type $V$ with decidable equality, let $E \subseteq V \times V$ be a finite set of directed edges, $c : V \times V \to \mathbb{R}$ an edge cost function, $s, t \in V$ two distinct vertices ($s \ne t$), and $k \in \mathbb{N}$. If $x : V \times V \to \mathbb{R}$ is primal feasible for $(E, s, t, k)$, meaning: 1. $x(e) \ge 0$ for all $e \in E$; 2. For every vertex $v \in V$, the net inflow minus outflow satisfies: $$\sum_{e \in E, e.2 = v} x(e) - \sum_{e \in E, e.1 = v} x(e) = \begin{cases} -k & \text{if } v = s \\ k & \text{if } v = t \\ 0 & \text{otherwise} \end{cases}$$ 3. For every non-empty subset $U \subseteq V \setminus \{s, t\}$, the total flow on edges of $E$ crossing $U$ (i.e., with one endpoint in $U$ and the other not in $U$) is at least 2; and if $a : V \to \mathbb{R}$ and $y : \text{Finset } V \to \mathbb{R}$ are dual feasible for $(E, c, s, t)$, meaning: 1. $y(U) \ge 0$ for every non-empty subset $U \subseteq V \setminus \{s, t\}$; 2. For every edge $e \in E$, $$a(e.2) - a(e.1) + \sum_{\substack{U \subseteq V \setminus \{s, t\}, U \ne \emptyset \\ (e.1 \in U \land e.2 \notin U) \lor (e.1 \notin U \land e.2 \in U)}} y(U) \le c(e);$$ then the dual objective value is at most the primal objective value: $$k(a(t) - a(s)) + \sum_{\substack{U \subseteq V \setminus \{s, t\} \\ U \ne \emptyset}} 2 y(U) \le \sum_{e \in E} c(e) x(e).$$

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

The proof establishes weak duality for the LP relaxation of the Single-Source Single-Sink Multi-Path problem by relating the dual objective terms to edge costs through flow conservation and cut constraints. First, the dual potential term k * (a t - a s) is shown to equal the sum of edge potential differences ∑_{e ∈ E} (a e.2 - a e.1) * x e by weighting flow conservation at each vertex by its potential. Second, the dual cut term ∑_U 2 * y U is bounded above by the cut-dual edge sum ∑_{e ∈ E} (∑_{U: e ∈ δ(U)} y U) * x e by swapping summation order and using primal cut feasibility and dual nonnegativity. Finally, adding these two bounds and applying dual feasibility (a e.2 - a e.1) + ∑_{U: e ∈ δ(U)} y U ≤ c e together with primal nonnegativity x e ≥ 0 demonstrates that the dual objective is at most the primal objective ∑_{e ∈ E} c e * x e.

  1. For every vertex v, the potential weighted by the divergence demand decomposes into two separate indicator terms for s and t.

    We perform case analysis on whether v = s and v = t. Since s ≠ t, if v = s the expression simplifies to -k * a s; if v = t it simplifies to k * a t; and if v is neither terminal both sides are zero.

    lines 5–18

    uses if_pos, if_neg

      have h1 : ∀ v : V, a v * (if v = s then -↑k else if v = t then ↑k else 0) =
          (if v = s then -(↑k * a s) else 0) + (if v = t then ↑k * a t else 0) := by
        intro v
        by_cases hvs : v = s
        · subst hvs
          rw [if_pos rfl, if_pos rfl, if_neg hst]
          ring
        · rw [if_neg hvs, if_neg hvs]
          by_cases hvt : v = t
          · subst hvt
            rw [if_pos rfl, if_pos rfl]
            ring
          · rw [if_neg hvt, if_neg hvt]
            ring
  2. Summing vertex potentials against the divergence demand over all vertices yields k * (a t - a s).

    We rewrite each summand into the sum of the two indicators and split the sum into two. Each sum over the universe of vertices has exactly one non-zero term (at s and t respectively), which simplifies to -k * a s + k * a t = k * (a t - a s).

    lines 19–22

    uses Finset.sum_add_distrib, Finset.sum_ite_eq', Finset.univ, Finset.mem_univ, if_true

      simp_rw [h1, Finset.sum_add_distrib]
      rw [Finset.sum_ite_eq' Finset.univ s, Finset.sum_ite_eq' Finset.univ t]
      · simp only [Finset.mem_univ, if_true]
        ring
  3. Summing vertex potentials against incoming flows equals summing target potentials against edge flows: ∑ v, a v * ∑_{e.2=v} x e = ∑_{e ∈ E} a e.2 * x e.

    We distribute a v into each inner sum, replace a v with a e.2 since e.2 = v on the incoming fiber, and recombine the fibers over all target vertices into a single sum over E using fiberwise summation.

    lines 28–37

    uses Finset.mul_sum, Finset.sum_congr, Finset.mem_filter.mp, Finset.sum_fiberwise, Prod.snd

      have h_in : (∑ v : V, a v * ∑ e ∈ E with e.2 = v, x e) = ∑ e ∈ E, a e.2 * x e := by
        simp_rw [Finset.mul_sum]
        have h1 : ∀ v : V, (∑ e ∈ E with e.2 = v, a v * x e) = ∑ e ∈ E with e.2 = v, a e.2 * x e := by
          intro v
          apply Finset.sum_congr rfl
          intro e he
          have he2 : e.2 = v := (Finset.mem_filter.mp he).2
          rw [he2]
        simp_rw [h1]
        exact Finset.sum_fiberwise E Prod.snd (fun e => a e.2 * x e)
  4. Summing vertex potentials against outgoing flows equals summing source potentials against edge flows: ∑ v, a v * ∑_{e.1=v} x e = ∑_{e ∈ E} a e.1 * x e.

    Similarly, we distribute a v into each inner sum, replace a v with a e.1 on each outgoing fiber, and recombine the fibers over all source vertices into a single sum over E using fiberwise summation.

    lines 38–47

    uses Finset.mul_sum, Finset.sum_congr, Finset.mem_filter.mp, Finset.sum_fiberwise, Prod.fst

      have h_out : (∑ v : V, a v * ∑ e ∈ E with e.1 = v, x e) = ∑ e ∈ E, a e.1 * x e := by
        simp_rw [Finset.mul_sum]
        have h1 : ∀ v : V, (∑ e ∈ E with e.1 = v, a v * x e) = ∑ e ∈ E with e.1 = v, a e.1 * x e := by
          intro v
          apply Finset.sum_congr rfl
          intro e he
          have he1 : e.1 = v := (Finset.mem_filter.mp he).2
          rw [he1]
        simp_rw [h1]
        exact Finset.sum_fiberwise E Prod.fst (fun e => a e.1 * x e)
  5. The net potential flow sum satisfies ∑ v, a v * (∑_{e.2=v} x e - ∑_{e.1=v} x e) = ∑_{e ∈ E} (a e.2 - a e.1) * x e.

    We distribute multiplication across the difference between incoming and outgoing flows and split the sum into two. Substituting the incoming and outgoing edge formulas and factoring out x e yields the result.

    lines 48–52

    uses mul_sub, Finset.sum_sub_distrib, sub_mul

      have h_sub : (∑ v : V, a v * (∑ e ∈ E with e.2 = v, x e - ∑ e ∈ E with e.1 = v, x e)) =
          (∑ v : V, a v * ∑ e ∈ E with e.2 = v, x e) - (∑ v : V, a v * ∑ e ∈ E with e.1 = v, x e) := by
        simp_rw [mul_sub, Finset.sum_sub_distrib]
      rw [h_sub, h_in, h_out]
      simp_rw [sub_mul, Finset.sum_sub_distrib]
  6. The scalar factors y U and x e can be distributed into the inner sums of the cut-crossing expressions.

    We push y U inside the inner sum over cut-crossing edges and x e inside the inner sum over cuts separating the endpoints of edge e.

    lines 58–68

    uses Finset.sum_congr, Finset.mul_sum, Finset.sum_mul

      have h1 : (∑ U ∈ ssss_cuts s t, y U * (∑ e ∈ E with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, x e)) =
          ∑ U ∈ ssss_cuts s t, ∑ e ∈ E with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U * x e := by
        apply Finset.sum_congr rfl
        intro U _
        rw [Finset.mul_sum]
      have h2 : (∑ e ∈ E, (∑ U ∈ ssss_cuts s t with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U) * x e) =
          ∑ e ∈ E, ∑ U ∈ ssss_cuts s t with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U * x e := by
        apply Finset.sum_congr rfl
        intro e _
        rw [Finset.sum_mul]
      rw [h1, h2]
  7. The double sum of cut duals against cut flows equals the double sum of edge flows against cut duals.

    We rewrite each filtered sum as a full sum with an indicator condition testing whether edge e crosses cut U. The two double sums then become identical sums over all cuts and all edges with the order of summation interchanged.

    lines 69–80

    uses Finset.sum_congr, Finset.sum_filter, Finset.sum_comm

      let P := fun (e : V × V) (U : Finset V) => e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U
      have h3 : (∑ U ∈ ssss_cuts s t, ∑ e ∈ E with P e U, y U * x e) =
          ∑ U ∈ ssss_cuts s t, ∑ e ∈ E, if P e U then y U * x e else 0 := by
        apply Finset.sum_congr rfl
        intro U _
        exact Finset.sum_filter (fun e => P e U) (fun e => y U * x e)
      have h4 : (∑ e ∈ E, ∑ U ∈ ssss_cuts s t with P e U, y U * x e) =
          ∑ e ∈ E, ∑ U ∈ ssss_cuts s t, if P e U then y U * x e else 0 := by
        apply Finset.sum_congr rfl
        intro e _
        exact Finset.sum_filter (fun U => P e U) (fun U => y U * x e)
      rw [h3, h4, Finset.sum_comm]
  8. Unpack primal feasibility, dual feasibility, and definitions of primal and dual objectives.

    We unpack the hypotheses: primal nonnegativity x ≥ 0, flow conservation with divergence demands -k at s and k at t, cut lower bounds ≥ 2, dual nonnegativity y ≥ 0, and dual edge cost constraints. We also unfold the definitions of the primal and dual objectives.

    lines 88–90

      rcases hx with ⟨hx_nonneg, hx_flow, hx_cut⟩
      rcases hy with ⟨hy_nonneg, hy_cost⟩
      dsimp [ssss_dual_obj, ssss_primal_obj]
  9. The dual potential term equals the potential difference weighted by edge flows: k * (a t - a s) = ∑_{e ∈ E} (a e.2 - a e.1) * x e.

    We multiply flow conservation at each vertex v by a v and sum over all vertices. By ssss_weak_duality_sum_flow_potentials, the right-hand side is k * (a t - a s). By ssss_weak_duality_sum_potentials_flow, the left-hand side is ∑_{e ∈ E} (a e.2 - a e.1) * x e.

    lines 91–99

    uses Finset.sum_congr, ssss_weak_duality_sum_flow_potentials, ssss_weak_duality_sum_potentials_flow

      have h_flow_eq : ↑k * (a t - a s) = ∑ e ∈ E, (a e.2 - a e.1) * x e := by
        have h1 : ∑ v : V, a v * (∑ e ∈ E with e.2 = v, x e - ∑ e ∈ E with e.1 = v, x e) =
            ∑ v : V, a v * (if v = s then -↑k else if v = t then ↑k else 0) := by
          apply Finset.sum_congr rfl
          intro v _
          rw [hx_flow v]
        rw [ssss_weak_duality_sum_flow_potentials s t hst k a] at h1
        rw [ssss_weak_duality_sum_potentials_flow E x a] at h1
        exact h1.symm
  10. The dual cut term is bounded by the cut-dual edge sum: ∑_U 2 * y U ≤ ∑_{e ∈ E} (∑_{U: e ∈ δ(U)} y U) * x e.

    Swapping the summation via ssss_weak_duality_cuts_sum_swap rewrites the right-hand side as ∑_U y U * (∑_{e ∈ δ(U)} x e). For each cut U, primal cut feasibility gives 2 ≤ ∑_{e ∈ δ(U)} x e and dual nonnegativity gives y U ≥ 0, so 2 * y U ≤ y U * ∑_{e ∈ δ(U)} x e. Summing over all cuts gives the inequality.

    lines 100–107

    uses ssss_weak_duality_cuts_sum_swap, Finset.sum_le_sum

      have h_cut_le : (∑ U ∈ ssss_cuts s t, 2 * y U) ≤
          ∑ e ∈ E, (∑ U ∈ ssss_cuts s t with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U) * x e := by
        rw [← ssss_weak_duality_cuts_sum_swap]
        apply Finset.sum_le_sum
        intro U hU
        have hU_flow := hx_cut U hU
        have hU_nonneg := hy_nonneg U hU
        nlinarith
  11. The combined edge sum of potential differences and cut duals is bounded by the primal objective: ∑_{e ∈ E} (a e.2 - a e.1) * x e + ∑_{e ∈ E} (∑_{U: e ∈ δ(U)} y U) * x e ≤ ∑_{e ∈ E} c e * x e.

    We combine the two sums over E into a single sum. For each edge e ∈ E, dual feasibility asserts (a e.2 - a e.1) + ∑_{U: e ∈ δ(U)} y U ≤ c e. Multiplying by primal nonnegativity x e ≥ 0 preserves the inequality, and summing over all edges yields the bound.

    lines 108–118

    uses Finset.sum_add_distrib, Finset.sum_le_sum

      have h_sum_le : (∑ e ∈ E, (a e.2 - a e.1) * x e) +
          ∑ e ∈ E, (∑ U ∈ ssss_cuts s t with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U) * x e ≤
          ∑ e ∈ E, c e * x e := by
        rw [← Finset.sum_add_distrib]
        apply Finset.sum_le_sum
        intro e he
        have he_cost := hy_cost e he
        have he_nonneg := hx_nonneg e he
        calc (a e.2 - a e.1) * x e + (∑ U ∈ ssss_cuts s t with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U) * x e
          _ = ((a e.2 - a e.1) + ∑ U ∈ ssss_cuts s t with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U) * x e := by ring
          _ ≤ c e * x e := by nlinarith
  12. The dual objective value is at most the primal objective value: ssss_dual_obj s t k a y ≤ ssss_primal_obj E c x. automation

    Linear arithmetic combines the potential difference equality, the cut inequality, and the edge cost bound to conclude that dual_obj ≤ primal_obj.

    line 119

      linarith
if_pos
If a condition c is true, the conditional expression (if c then t else e) equals t.
if_neg
If a condition c is false, the conditional expression (if c then t else e) equals e.
Finset.sum_add_distrib
A finite sum of sums equals the sum of the finite sums.
Finset.sum_ite_eq'
Summing an indicator that is nonzero only when x = a over a finset s evaluates to b a if a ∈ s, and 0 otherwise.
Finset.univ
The universal finset containing every element of a finite type.
Finset.mem_univ
Every element of a finite type belongs to the universal finset.
if_true
A conditional expression with condition True simplifies to the then-branch.
Finset.mul_sum
Left multiplication by a scalar distributes over a finite sum.
Finset.sum_congr
Two finite sums over equal index sets are equal if their summands agree at every element.
Finset.mem_filter.mp
If an element belongs to a filtered finset, it satisfies the filter condition.
Finset.sum_fiberwise
Summing over the fibers of a function on a finite domain reconstructs the total sum over the domain.
Prod.snd
The second projection of an ordered pair, giving the target vertex of a directed edge.
Prod.fst
The first projection of an ordered pair, giving the source vertex of a directed edge.
mul_sub
Multiplication distributes over subtraction from the left: a * (b - c) = a * b - a * c.
Finset.sum_sub_distrib
A finite sum of differences equals the difference of the finite sums.
sub_mul
Multiplication distributes over subtraction from the right: (a - b) * c = a * c - b * c.
Finset.sum_mul
Right multiplication by a scalar distributes over a finite sum.
Finset.sum_filter
A sum over a filtered finset equals the sum over the entire set with an indicator function.
Finset.sum_comm
The order of two finite summations can be interchanged.
ssss_weak_duality_sum_flow_potentials
Summing vertex potentials against net divergence demand (-k at s, k at t, 0 elsewhere) yields k * (a t - a s).
ssss_weak_duality_sum_potentials_flow
Summing vertex potentials against net inflows across all vertices equals summing edge potential differences against edge flows.
ssss_weak_duality_cuts_sum_swap
The double sum of cut dual variables and cut flows can be rearranged by swapping summation between cuts and edges.
Finset.sum_le_sum
If one function is pointwise bounded by another on a finite set, its finite sum is bounded by the other finite sum.

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 ssss_weak_duality_sum_flow_potentials {V : Type*} [Fintype V] [DecidableEq V]    (s t : V) (hst : s ≠ t) (k : ℕ) (a : V → ℝ) :    ∑ v : V, a v * (if v = s then -↑k else if v = t then ↑k else 0) =    ↑k * (a t - a s) := by  have h1 : ∀ v : V, a v * (if v = s then -↑k else if v = t then ↑k else 0) =      (if v = s then -(↑k * a s) else 0) + (if v = t then ↑k * a t else 0) := by    intro v    by_cases hvs : v = s    · subst hvs      rw [if_pos rfl, if_pos rfl, if_neg hst]      ring    · rw [if_neg hvs, if_neg hvs]      by_cases hvt : v = t      · subst hvt        rw [if_pos rfl, if_pos rfl]        ring      · rw [if_neg hvt, if_neg hvt]        ring  simp_rw [h1, Finset.sum_add_distrib]  rw [Finset.sum_ite_eq' Finset.univ s, Finset.sum_ite_eq' Finset.univ t]  · simp only [Finset.mem_univ, if_true]    ringtheorem ssss_weak_duality_sum_potentials_flow {V : Type*} [Fintype V] [DecidableEq V]    (E : Finset (V × V)) (x : V × V → ℝ) (a : V → ℝ) :    ∑ v : V, a v * (∑ e ∈ E with e.2 = v, x e - ∑ e ∈ E with e.1 = v, x e) =    ∑ e ∈ E, (a e.2 - a e.1) * x e := by  have h_in : (∑ v : V, a v * ∑ e ∈ E with e.2 = v, x e) = ∑ e ∈ E, a e.2 * x e := by    simp_rw [Finset.mul_sum]    have h1 : ∀ v : V, (∑ e ∈ E with e.2 = v, a v * x e) = ∑ e ∈ E with e.2 = v, a e.2 * x e := by      intro v      apply Finset.sum_congr rfl      intro e he      have he2 : e.2 = v := (Finset.mem_filter.mp he).2      rw [he2]    simp_rw [h1]    exact Finset.sum_fiberwise E Prod.snd (fun e => a e.2 * x e)  have h_out : (∑ v : V, a v * ∑ e ∈ E with e.1 = v, x e) = ∑ e ∈ E, a e.1 * x e := by    simp_rw [Finset.mul_sum]    have h1 : ∀ v : V, (∑ e ∈ E with e.1 = v, a v * x e) = ∑ e ∈ E with e.1 = v, a e.1 * x e := by      intro v      apply Finset.sum_congr rfl      intro e he      have he1 : e.1 = v := (Finset.mem_filter.mp he).2      rw [he1]    simp_rw [h1]    exact Finset.sum_fiberwise E Prod.fst (fun e => a e.1 * x e)  have h_sub : (∑ v : V, a v * (∑ e ∈ E with e.2 = v, x e - ∑ e ∈ E with e.1 = v, x e)) =      (∑ v : V, a v * ∑ e ∈ E with e.2 = v, x e) - (∑ v : V, a v * ∑ e ∈ E with e.1 = v, x e) := by    simp_rw [mul_sub, Finset.sum_sub_distrib]  rw [h_sub, h_in, h_out]  simp_rw [sub_mul, Finset.sum_sub_distrib]theorem ssss_weak_duality_cuts_sum_swap {V : Type*} [Fintype V] [DecidableEq V]    (E : Finset (V × V)) (s t : V) (x : V × V → ℝ) (y : Finset V → ℝ) :    ∑ U ∈ ssss_cuts s t, y U * (∑ e ∈ E with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, x e) =    ∑ e ∈ E, (∑ U ∈ ssss_cuts s t with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U) * x e := by  have h1 : (∑ U ∈ ssss_cuts s t, y U * (∑ e ∈ E with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, x e)) =      ∑ U ∈ ssss_cuts s t, ∑ e ∈ E with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U * x e := by    apply Finset.sum_congr rfl    intro U _    rw [Finset.mul_sum]  have h2 : (∑ e ∈ E, (∑ U ∈ ssss_cuts s t with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U) * x e) =      ∑ e ∈ E, ∑ U ∈ ssss_cuts s t with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U * x e := by    apply Finset.sum_congr rfl    intro e _    rw [Finset.sum_mul]  rw [h1, h2]  let P := fun (e : V × V) (U : Finset V) => e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U  have h3 : (∑ U ∈ ssss_cuts s t, ∑ e ∈ E with P e U, y U * x e) =      ∑ U ∈ ssss_cuts s t, ∑ e ∈ E, if P e U then y U * x e else 0 := by    apply Finset.sum_congr rfl    intro U _    exact Finset.sum_filter (fun e => P e U) (fun e => y U * x e)  have h4 : (∑ e ∈ E, ∑ U ∈ ssss_cuts s t with P e U, y U * x e) =      ∑ e ∈ E, ∑ U ∈ ssss_cuts s t, if P e U then y U * x e else 0 := by    apply Finset.sum_congr rfl    intro e _    exact Finset.sum_filter (fun U => P e U) (fun U => y U * x e)  rw [h3, h4, Finset.sum_comm]/-- Weak duality for the Single-Source Single-Sink Multi-Path LP relaxation. -/theorem ssss_weak_duality {V : Type*} [Fintype V] [DecidableEq V]    (E : Finset (V × V)) (c : V × V → ℝ) (s t : V) (hst : s ≠ t) (k : ℕ)    (x : V × V → ℝ) (hx : ssss_primal_feasible E s t k x)    (a : V → ℝ) (y : Finset V → ℝ) (hy : ssss_dual_feasible E c s t a y) :    ssss_dual_obj s t k a y ≤ ssss_primal_obj E c x := by  rcases hx with ⟨hx_nonneg, hx_flow, hx_cut⟩  rcases hy with ⟨hy_nonneg, hy_cost⟩  dsimp [ssss_dual_obj, ssss_primal_obj]  have h_flow_eq : ↑k * (a t - a s) = ∑ e ∈ E, (a e.2 - a e.1) * x e := by    have h1 : ∑ v : V, a v * (∑ e ∈ E with e.2 = v, x e - ∑ e ∈ E with e.1 = v, x e) =        ∑ v : V, a v * (if v = s then -↑k else if v = t then ↑k else 0) := by      apply Finset.sum_congr rfl      intro v _      rw [hx_flow v]    rw [ssss_weak_duality_sum_flow_potentials s t hst k a] at h1    rw [ssss_weak_duality_sum_potentials_flow E x a] at h1    exact h1.symm  have h_cut_le : (∑ U ∈ ssss_cuts s t, 2 * y U) ≤      ∑ e ∈ E, (∑ U ∈ ssss_cuts s t with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U) * x e := by    rw [← ssss_weak_duality_cuts_sum_swap]    apply Finset.sum_le_sum    intro U hU    have hU_flow := hx_cut U hU    have hU_nonneg := hy_nonneg U hU    nlinarith  have h_sum_le : (∑ e ∈ E, (a e.2 - a e.1) * x e) +      ∑ e ∈ E, (∑ U ∈ ssss_cuts s t with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U) * x e ≤      ∑ e ∈ E, c e * x e := by    rw [← Finset.sum_add_distrib]    apply Finset.sum_le_sum    intro e he    have he_cost := hy_cost e he    have he_nonneg := hx_nonneg e he    calc (a e.2 - a e.1) * x e + (∑ U ∈ ssss_cuts s t with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U) * x e      _ = ((a e.2 - a e.1) + ∑ U ∈ ssss_cuts s t with e.1 ∈ U ∧ e.2 ∉ U ∨ e.1 ∉ U ∧ e.2 ∈ U, y U) * x e := by ring      _ ≤ c e * x e := by nlinarith  linarith
See it in the graphDiscuss this resultChallenge it