Documentation

CslibFrontier.GameTheory.Market.DPSVAlgorithm

The DPSV primal-dual algorithm for linear Fisher markets #

This module formalizes the main primal-dual algorithm of Devanur–Papadimitriou–Saberi–Vazirani ([Vaz07], Chapter 5, Sections 5.8 and 5.10, pp. 115–121) for computing exact market equilibria in linear Fisher markets, building on the equality-network, balanced-flow, tight-set, and rationality infrastructure of CslibFrontier.GameTheory.Market.BalancedFlow.

Main definitions #

Main results #

Source notes #

Four minor slips in the printed text of [Vaz07], Sections 5.8 and 5.10 are addressed explicitly in this formalization:

  1. Section 5.8 (p. 116) states that equilibrium is reached when the Section 5.7.1 balanced-flow subroutine terminates in Case 1; in fact Case 1 with positive uniform shift X > 0 can occur far from equilibrium, and the actual halting condition is that all buyer surpluses vanish (∀ i, M.surplus f i = 0, matching Section 5.5, p. 110 and Section 5.6, p. 111).
  2. Section 5.8 (p. 116) claims that for all x > 1, buyers in B \ H immediately lose all equality edges to J; this fails for zero-spending buyers in B \ H whose equality edges all lie in J. Running Event 1 on (J, H) still preserves the Invariant and the full potential drop δ_{k-1} ^ 2 at Event 1 unconditionally, and once total surplus falls below 1 (hence below every integral budget e i ≥ 1), every buyer spends positively so no such buyer exists and Event 1 yields a genuine tight set in N(p').
  3. Section 5.10, Lemma 5.13 (p. 119) prints q ≤ Δ and r ≤ Δ for fractions p/q and r/s, where s ≤ Δ is meant.
  4. Section 5.10, Lemma 5.21 and Theorem 5.22 (p. 121) write n for both |A| and |B| (despite Section 5.2, p. 105 writing |A| = n and |B| = n'). All bounds here track m = Fintype.card I and n = Fintype.card G explicitly.

References #

Auxiliary bang-per-buck and equilibrium helpers #

Section 5.10: Lemmas 5.13, 5.15, and 5.16 #

theorem Cslib.GameTheory.Market.LinearFisherMarket.price_sub_ge_inv_sq_of_isTightSet {I : Type u_1} {G : Type u_2} [Fintype I] [Fintype G] [DecidableEq I] [DecidableEq G] {M : LinearFisherMarket I G} (hsup : ∀ (g : G), M.supply g = 1) {u : I → G → ℕ} (hu : ∀ (i : I) (g : G), M.utility i g = ↑(u i g)) {U : ℕ} (hU : ∀ (i : I) (g : G), u i g ≤ U) {e : I → ℕ} (he : ∀ (i : I), M.budget i = ↑(e i)) (hbuyer : ∀ (i : I), ∃ (g : G), 0 < M.utility i g) {p₁ p₂ : G → ℝ} (hp₁ : ∀ (g : G), 0 < p₁ g) (hp₂ : ∀ (g : G), 0 < p₂ g) (hinv₁ : M.SatisfiesInvariant p₁) (hinv₂ : M.SatisfiesInvariant p₂) {S₁ S₂ : Finset G} (hS₁ : M.IsTightSet p₁ S₁) (hS₂ : M.IsTightSet p₂ S₂) {g : G} (hg₁ : g ∈ S₁) (hg₂ : g ∈ S₂) (hlt : p₁ g < p₂ g) :
1 / ↑(Fintype.card G * U ^ Fintype.card G) ^ 2 ≤ p₂ g - p₁ g

Lemma 5.13 ([Vaz07], Section 5.10, p. 119): in a unit-supply linear Fisher market with integer utilities u i g ≤ U and integer budgets e i, if good g belongs to tight sets at two positive Invariant-preserving price vectors p₁ and p₂ with p₁ g < p₂ g, then p₂ g - p₁ g ≥ 1 / Δ ^ 2, where Δ = Fintype.card G * U ^ Fintype.card G.

Note: [Vaz07], p. 119 prints q ≤ Δ and r ≤ Δ for fractions p/q and r/s, where s ≤ Δ is intended.

theorem Cslib.GameTheory.Market.LinearFisherMarket.sum_sq_drop_of_transfer {ι : Type u_3} {s : Finset ι} {a δ : ℝ} {b δ_vec : ι → ℝ} (ha : 0 ≤ a) (hb : ∀ j ∈ s, 0 ≤ b j ∧ b j ≤ a) (hδ : ∀ j ∈ s, 0 ≤ δ_vec j) (hsum : ∑ j ∈ s, δ_vec j ≤ δ) :
a ^ 2 + ∑ j ∈ s, b j ^ 2 ≤ (a + δ) ^ 2 + ∑ j ∈ s, (b j - δ_vec j) ^ 2 - δ ^ 2

Lemma 5.16 ([Vaz07], Section 5.10, p. 120): elementary quadratic potential-drop inequality for shifting δ ≥ ∑ j ∈ s, δ_vec j from a + δ onto b j - δ_vec j with 0 ≤ b j ≤ a and 0 ≤ δ_vec j.

theorem Cslib.GameTheory.Market.LinearFisherMarket.surplusSqNorm_le_sub_sq_of_isBalancedFlow {I : Type u_1} {G : Type u_2} [Fintype I] [Fintype G] {M : LinearFisherMarket I G} {p : G → ℝ} {f fStar : G → I → ℝ} (hf : M.IsEqualityFlow p f) (hbal : M.IsBalancedFlow p fStar) (i : I) :
M.surplusSqNorm fStar ≤ M.surplusSqNorm f - (M.surplus f i - M.surplus fStar i) ^ 2

Lemma 5.15 ([Vaz07], Section 5.10, p. 119): for any feasible equality flow f and balanced flow fStar in N(p) and any buyer i, the squared ℓ₂ surplus norm drops by at least (M.surplus f i - M.surplus fStar i) ^ 2.

Proved directly via convexity of the feasible flow polytope: first-order optimality of fStar gives ∑ j, γ*_j * (γ_j - γ*_j) ≥ 0, hence ‖γ‖² - ‖γ*‖² ≥ ‖γ - γ*‖² ≥ (γ_i - γ*_i)².

Section 5.8: Price initialization and the Invariant #

noncomputable def Cslib.GameTheory.Market.LinearFisherMarket.dpsvInitPrice {I : Type u_1} {G : Type u_2} [Fintype I] [Fintype G] (M : LinearFisherMarket I G) (g : G) :

DPSV initial price vector ([Vaz07], Section 5.8, p. 115): starting from uniform prices p₀ g = 1 / n with bang-per-buck α i = max_g (u i g / p₀ g), sets p g = max_i (u i g / α i). Goods that already have an incident equality edge at p₀ keep price 1 / n, while goods with no incident equality edge are lowered to max_i (u i g / α i) < 1 / n.

theorem Cslib.GameTheory.Market.LinearFisherMarket.dpsvInitPrice_spec {I : Type u_1} {G : Type u_2} [Fintype I] [Fintype G] [DecidableEq I] [DecidableEq G] {M : LinearFisherMarket I G} (hnd : M.IsNonDegenerate) (hsup : ∀ (g : G), M.supply g = 1) (hbud : ∀ (i : I), 1 ≤ M.budget i) :
(∀ (g : G), 0 < M.dpsvInitPrice g) ∧ (∀ (g : G), M.dpsvInitPrice g ≤ 1 / ↑(Fintype.card G)) ∧ (∀ (g : G), (∃ (i : I), M.IsEqualityEdge (fun (x : G) => 1 / ↑(Fintype.card G)) i g) → M.dpsvInitPrice g = 1 / ↑(Fintype.card G)) ∧ (∀ (g : G), ∃ (i : I), M.IsEqualityEdge M.dpsvInitPrice i g) ∧ M.SatisfiesInvariant M.dpsvInitPrice

Initialization correctness ([Vaz07], Section 5.8, p. 115): in a non-degenerate unit-supply market where every buyer has budget at least 1, M.dpsvInitPrice is strictly positive, bounded above by 1 / n, keeps price 1 / n on every good already having an incident equality edge at uniform prices 1 / n, gives every good an incident equality edge, and satisfies M.SatisfiesInvariant.

Section 5.8 & 5.10: Active subgraph, Event 1 / Event 2, and Lemmas 5.17–5.20 #

Scale prices of goods in J by x while leaving goods outside J unchanged ([Vaz07], Section 5.8, p. 116).

noncomputable def Cslib.GameTheory.Market.LinearFisherMarket.activeGoods {I G : Type u} [Fintype G] (M : LinearFisherMarket I G) (p : G → ℝ) (H : Finset I) :

Active goods J = {g | ∃ i ∈ H, M.IsEqualityEdge p i g} desired by buyers in H ([Vaz07], Section 5.8, p. 116).

theorem Cslib.GameTheory.Market.LinearFisherMarket.mem_activeGoods {I G : Type u} [Fintype G] {M : LinearFisherMarket I G} {p : G → ℝ} {H : Finset I} {g : G} :
g ∈ M.activeGoods p H ↔ ∃ i ∈ H, M.IsEqualityEdge p i g

Membership in M.activeGoods p H: good g is active iff some buyer i ∈ H has an equality edge to g at prices p.

noncomputable def Cslib.GameTheory.Market.LinearFisherMarket.event2Ratio {I G : Type u} [Fintype G] [DecidableEq G] (M : LinearFisherMarket I G) (p : G → ℝ) (H : Finset I) (J : Finset G) :

Event-2 scale ratio ([Vaz07], Section 5.8, p. 116): the smallest x > 1 at which an active buyer i ∈ H gains a new equality edge to an inactive good g ∉ J, or none when no buyer in H derives positive utility from any good outside J.

theorem Cslib.GameTheory.Market.LinearFisherMarket.event2Ratio_eq_none_iff {I G : Type u} [Fintype G] [DecidableEq G] {M : LinearFisherMarket I G} {p : G → ℝ} {H : Finset I} {J : Finset G} :
M.event2Ratio p H J = none ↔ ∀ i ∈ H, ∀ g ∉ J, M.utility i g = 0

M.event2Ratio p H J = none iff no buyer i ∈ H derives positive utility from any good g ∉ J.

theorem Cslib.GameTheory.Market.LinearFisherMarket.one_lt_event2Ratio {I G : Type u} [Fintype G] [DecidableEq G] {M : LinearFisherMarket I G} {p : G → ℝ} (hp : ∀ (g : G), 0 < p g) {H : Finset I} {x2 : ℝ} (hx2 : M.event2Ratio p H (M.activeGoods p H) = some x2) :
1 < x2

At positive prices p, every Event-2 scale ratio r returned by M.event2Ratio p H (M.activeGoods p H) satisfies 1 < r.

theorem Cslib.GameTheory.Market.LinearFisherMarket.le_event2Ratio_iff {I G : Type u} [Fintype G] [DecidableEq G] {M : LinearFisherMarket I G} {p : G → ℝ} (hp : ∀ (g : G), 0 < p g) {H : Finset I} {J : Finset G} {x : ℝ} :
(∀ (r : ℝ), M.event2Ratio p H J = some r → x ≤ r) ↔ ∀ i ∈ H, ∀ g ∉ J, 0 < M.utility i g → ∃ (g' : G), x * M.bangPerBuck p i g ≤ M.bangPerBuck p i g'

Characterization of upper bounds on M.event2Ratio p H J at positive prices p: x does not exceed the Event-2 ratio (vacuously when M.event2Ratio p H J = none) iff for every active buyer i ∈ H and inactive good g ∉ J with 0 < M.utility i g, there exists a good g' such that x * M.bangPerBuck p i g ≤ M.bangPerBuck p i g'.

theorem Cslib.GameTheory.Market.LinearFisherMarket.isEqualityFlow_scaleActivePrices {I G : Type u} [Fintype I] [Fintype G] [DecidableEq G] {M : LinearFisherMarket I G} {p : G → ℝ} (hp : ∀ (g : G), 0 < p g) (hbuyer : ∀ (i : I), ∃ (g : G), 0 < M.utility i g) {f : G → I → ℝ} (hf : M.IsEqualityFlow p f) {H : Finset I} (hclosed : ∀ (u v : I), M.ResidualReachable p f u v → v ∈ H → u ∈ H) {x : ℝ} (hx1 : 1 ≤ x) (hx_le : ∀ (r : ℝ), M.event2Ratio p H (M.activeGoods p H) = some r → x ≤ r) :

Lemma 5.17 ([Vaz07], Section 5.10, p. 120): if f is a feasible equality flow in N(p) and H is closed under incoming residual paths in R(p, f) - {s, t}, then f remains a feasible equality flow in N(scaleActivePrices p J x) for every x ≥ 1 not exceeding event2Ratio (where J = M.activeGoods p H).

theorem Cslib.GameTheory.Market.LinearFisherMarket.surplusSqNorm_scaleActivePrices_le {I G : Type u} [Fintype I] [Fintype G] [DecidableEq G] {M : LinearFisherMarket I G} {p : G → ℝ} (hp : ∀ (g : G), 0 < p g) (hbuyer : ∀ (i : I), ∃ (g : G), 0 < M.utility i g) {f f' : G → I → ℝ} (hf : M.IsEqualityFlow p f) {H : Finset I} (hclosed : ∀ (u v : I), M.ResidualReachable p f u v → v ∈ H → u ∈ H) {x : ℝ} (hx1 : 1 ≤ x) (hx_le : ∀ (r : ℝ), M.event2Ratio p H (M.activeGoods p H) = some r → x ≤ r) (hbal' : M.IsBalancedFlow (scaleActivePrices p (M.activeGoods p H) x) f') :

Corollary 5.18 ([Vaz07], Section 5.10, p. 120): the squared ℓ₂ surplus norm is monotonically nonincreasing across active price-scaling iterations.

theorem Cslib.GameTheory.Market.LinearFisherMarket.exists_surplus_drop_of_residual_expand {I G : Type u} [Fintype I] [Fintype G] {M : LinearFisherMarket I G} {p' : G → ℝ} (hp' : ∀ (g : G), 0 ≤ p' g) {f f' : G → I → ℝ} (hbal' : M.IsBalancedFlow p' f') {H : Finset I} (hH : H.Nonempty) :
let H' := {u : I | ∃ v ∈ H, M.ResidualReachable p' f' u v}; have hH' := ⋯; ∃ i ∈ H, H.inf' hH (M.surplus f) - H'.inf' hH' (M.surplus f') ≤ M.surplus f i - M.surplus f' i

Lemma 5.19 ([Vaz07], Section 5.10, p. 120): when H' = {u | ∃ v ∈ H, M.ResidualReachable p' f' u v} expands H in the residual graph of a balanced flow f' in N(p'), the minimum surplus over H' is achieved by some buyer i ∈ H. Consequently, if δ' < δ where δ = min_{i ∈ H} M.surplus f i and δ' = min_{u ∈ H'} M.surplus f' u, then there exists i ∈ H with M.surplus f i - M.surplus f' i ≥ δ - δ'.

theorem Cslib.GameTheory.Market.LinearFisherMarket.surplusSqNorm_drop_of_minSurplus_lt {I G : Type u} [Fintype I] [Fintype G] [DecidableEq G] {M : LinearFisherMarket I G} {p : G → ℝ} (hp : ∀ (g : G), 0 < p g) (hbuyer : ∀ (i : I), ∃ (g : G), 0 < M.utility i g) {f f' : G → I → ℝ} (hf : M.IsEqualityFlow p f) {H : Finset I} (hH : H.Nonempty) (hclosed : ∀ (u v : I), M.ResidualReachable p f u v → v ∈ H → u ∈ H) {x : ℝ} (hx1 : 1 ≤ x) (hx_le : ∀ (r : ℝ), M.event2Ratio p H (M.activeGoods p H) = some r → x ≤ r) (hbal' : M.IsBalancedFlow (scaleActivePrices p (M.activeGoods p H) x) f') :
let p' := scaleActivePrices p (M.activeGoods p H) x; let H' := {u : I | ∃ v ∈ H, M.ResidualReachable p' f' u v}; have hH' := ⋯; H'.inf' hH' (M.surplus f') < H.inf' hH (M.surplus f) → M.surplusSqNorm f' ≤ M.surplusSqNorm f - (H.inf' hH (M.surplus f) - H'.inf' hH' (M.surplus f')) ^ 2

Lemma 5.20 ([Vaz07], Section 5.10, p. 120): if the minimum active surplus strictly drops from δ to δ' across an iteration, the squared ℓ₂ surplus norm drops by at least (δ - δ') ^ 2.

Phase execution, Event 1 / Event 2 invariants, and Lemmas 5.14 & 5.21 #

Output of one phase of the DPSV algorithm ([Vaz07], Section 5.8, p. 116).

  • price : G → ℝ

    Price vector at the end of the phase.

  • flow : G → I → ℝ

    Balanced equality flow in N(price).

  • tightSet : Finset G

    Active subset S₁ ⊆ J achieving Event 1 at the end of the phase.

  • iters : ℕ

    Number of Event-1 / Event-2 iterations executed in the phase.

noncomputable def Cslib.GameTheory.Market.LinearFisherMarket.dpsvPhaseProgram {I G : Type u} [Fintype I] [Fintype G] [DecidableEq I] [DecidableEq G] (M : LinearFisherMarket I G) (p : G → ℝ) (f : G → I → ℝ) :

One full phase of the DPSV algorithm ([Vaz07], Section 5.8, p. 116): given current prices p and balanced flow f, returns immediately when all buyer surpluses vanish, and otherwise initializes H₀ = {i | M.surplus f i = max_j M.surplus f j} and runs dpsvPhaseLoop for at most Fintype.card G iterations.

theorem Cslib.GameTheory.Market.LinearFisherMarket.dpsvPhaseProgram_spec {I G : Type u} [Fintype I] [Fintype G] [DecidableEq I] [DecidableEq G] {M : LinearFisherMarket I G} (hsup_pos : ∀ (g : G), 0 < M.supply g) (hbud_pos : ∀ (i : I), 0 < M.budget i) (hbuyer : ∀ (i : I), ∃ (g : G), 0 < M.utility i g) {p : G → ℝ} (hp : ∀ (g : G), 0 < p g) (hinv : M.SatisfiesInvariant p) {f : G → I → ℝ} (hbal : M.IsBalancedFlow p f) (hnot_eq : ∃ (i : I), 0 < M.surplus f i) {oracle : {ι : Type u} → MaxFlowQuery I G ι → ι} (horacle : IsValidMaxFlowOracle fun {ι : Type u} => oracle) :
have m := Fintype.card I; have n := Fintype.card G; have prog := M.dpsvPhaseProgram p f; have res := FreeM.eval (fun {ι : Type u} => oracle) prog; (∀ (g : G), 0 < res.price g) ∧ (∀ (g : G), p g ≤ res.price g) ∧ M.SatisfiesInvariant res.price ∧ M.IsBalancedFlow res.price res.flow ∧ 1 ≤ res.iters ∧ res.iters ≤ n ∧ FreeM.countQueries (fun {ι : Type u} => oracle) prog ≤ 2 * n * res.iters ∧ M.surplusSqNorm res.flow ≤ (1 - 1 / (↑m * ↑n)) * M.surplusSqNorm f ∧ res.tightSet.Nonempty ∧ (∀ g ∈ res.tightSet, p g < res.price g) ∧ ((∀ (i : I), ∑ j : I, M.surplus f j < M.budget i) → M.IsTightSet res.price res.tightSet)

Lemmas 5.14 and 5.21 ([Vaz07], Section 5.10, pp. 119, 121): when N(p) satisfies the Invariant at positive prices p and balanced flow f has at least one buyer with positive surplus, M.dpsvPhaseProgram p f executes between 1 and n = Fintype.card G iterations using at most 2 * n * iters ≤ 2 * n ^ 2 max-flow oracle calls, preserves positivity and the Invariant, never decreases prices, strictly raises prices on a nonempty set res.tightSet (which is a genuine tight set in N(res.price) whenever total surplus is strictly smaller than every buyer's budget), and reduces M.surplusSqNorm by at least δ ^ 2 / n and by a factor of 1 - 1 / (m * n) (specializing to 1 - 1 / n ^ 2 when m = Fintype.card I ≤ n).

Section 5.10: Full DPSV algorithm and Theorem 5.22 #

Output of the full DPSV primal-dual algorithm ([Vaz07], Sections 5.8 and 5.10).

  • alloc : I → G → ℝ

    Market equilibrium allocation alloc i g = f g i / price g.

  • price : G → ℝ

    Market equilibrium price vector.

  • phases : ℕ

    Number of phases executed before reaching equilibrium.

Upper bound T_max(m, n, U, M_tot) on the number of DPSV phases for a market with m buyers, n goods, integer utilities ≤ U, and total integer budget M_tot.

The DPSV primal-dual algorithm ([Vaz07], Sections 5.8 and 5.10, pp. 115–121) in Cslib.FreeM (MaxFlowQuery I G): initializes prices via M.dpsvInitPrice, computes an initial balanced flow via M.balancedFlowProgram, and executes DPSV phases until all buyer surpluses vanish (at most dpsvPhaseBound phases using the market's own maximum utility and total budget).

theorem Cslib.GameTheory.Market.LinearFisherMarket.dpsvProgram_spec {I G : Type u} [Fintype I] [Fintype G] [DecidableEq I] [DecidableEq G] {M : LinearFisherMarket I G} (hnd : M.IsNonDegenerate) (hsup : ∀ (g : G), M.supply g = 1) {u : I → G → ℕ} (hu : ∀ (i : I) (g : G), M.utility i g = ↑(u i g)) {U : ℕ} (hU : ∀ (i : I) (g : G), u i g ≤ U) {e : I → ℕ} (he : ∀ (i : I), M.budget i = ↑(e i)) {oracle : {ι : Type u} → MaxFlowQuery I G ι → ι} (horacle : IsValidMaxFlowOracle fun {ι : Type u} => oracle) :
have m := Fintype.card I; have n := Fintype.card G; have M_tot := ∑ i : I, e i; have res := FreeM.eval (fun {ι : Type u} => oracle) M.dpsvProgram; M.IsEquilibrium res.alloc res.price ∧ res.phases ≤ dpsvPhaseBound m n U M_tot ∧ FreeM.countQueries (fun {ι : Type u} => oracle) M.dpsvProgram ≤ n + 2 * n ^ 2 * res.phases

Theorem 5.22 ([Vaz07], Section 5.10, p. 121): for every non-degenerate unit-supply linear Fisher market with integer utilities u i g ≤ U and integer budgets e i (M_tot = ∑ i, e i, m = Fintype.card I, n = Fintype.card G, Δ = n * U ^ n), the DPSV primal-dual algorithm M.dpsvProgram evaluated with any valid max-flow oracle computes an exact market equilibrium (res.alloc, res.price) in at most dpsvPhaseBound m n U M_tot = m * n * (Nat.log 2 (m * Δ ^ 4 * M_tot ^ 2) + 1) + n phases and at most n + 2 * n ^ 2 * res.phases max-flow oracle calls — yielding O(m * n ^ 3 * (log m + log n + n log U + log M_tot)) max-flow computations (and O(n ^ 4 * (log n + n log U + log M_tot)) when m ≤ n).

Note: this states the max-flow oracle query complexity in Cslib.FreeM, matching [Vaz07], Theorem 5.22's count of max-flow computations rather than a machine-level bit-complexity runtime.