Documentation

CslibFrontier.Algorithms.Lean.OnlineMatching.AdWords

Online budgeted ad allocation (AdWords): Greedy and MSVV #

This module formalizes the online budgeted ad allocation (AdWords) problem from Lahaie, Pennock, Saberi, and Vohra, Sponsored Search Auctions, §28.4.1 (pp. 707–711 and Exercise 28.6, p. 716):

Model #

An advertiser set ι ([Fintype ι] [LinearOrder ι]) has budgets budget : ι → ℝ (assumed strictly positive in the competitive-ratio theorems). A keyword LP LP κ ι records bids bid : κ → ι → ℝ, budgets budget : ι → ℝ, and keyword demands demand : κ → ℝ. Given a finite query arrival sequence b : Fin T → ι → ℝ, the deterministic online algorithms maintain cumulative spending spent : ι → ℝ via a shared step-runner (spentAt) and tie-break maximal scores toward the smallest advertiser in ι using argmaxOver.

Because the online problem here deals with real-valued revenue maximization against a fractional LP relaxation weighted by Real.exp, it is kept separate from Cslib.DataStructure.Online.Problem, which models integer (ℕ-valued) step-cost minimization.

Source mapping and discrepancies verified on the page images #

Every locator below was verified on rendered page images of [LPSV07]:

Open work and limitations #

Main definitions #

Main results #

References #

Offline fractional LP relaxation (NRTV Eq. 28.11) #

structure Cslib.Algorithms.Lean.OnlineMatching.AdWords.LP (κ : Type u_1) (ι : Type u_2) :
Type (max u_1 u_2)

The offline fractional linear program for the online budgeted ad allocation problem ([LPSV07], §28.4.1, Eq. (28.11), p. 708): keywords κ with arrival frequencies demand, advertisers ι with budgets budget, and bid matrix bid.

  • bid : κ → ι → ℝ

    Advertiser bids: bid i j is advertiser j's bid for one query of keyword i.

  • budget : ι → ℝ

    Advertiser budgets B_j.

  • demand : κ → ℝ

    Keyword frequencies (number of queries) r_i.

structure Cslib.Algorithms.Lean.OnlineMatching.AdWords.LP.IsPrimalFeasible {κ : Type u_1} {ι : Type u_2} [Fintype κ] [Fintype ι] (lp : LP κ ι) (x : κ → ι → ℝ) :

Primal feasibility for the fractional allocation x : κ → ι → ℝ in [LPSV07], Eq. (28.11), p. 708.

  • nonneg (i : κ) (j : ι) : 0 ≤ x i j

    Nonnegativity: x i j ≥ 0.

  • demand_le (i : κ) : ∑ j : ι, x i j ≤ lp.demand i

    Demand cap: total allocation of keyword i is at most demand i.

  • budget_le (j : ι) : ∑ i : κ, lp.bid i j * x i j ≤ lp.budget j

    Budget cap: total charge to advertiser j is at most budget j.

structure Cslib.Algorithms.Lean.OnlineMatching.AdWords.LP.IsDualFeasible {κ : Type u_1} {ι : Type u_2} (lp : LP κ ι) (α : κ → ℝ) (β : ι → ℝ) :

Dual feasibility for (α, β) in the dual of [LPSV07], Eq. (28.11), p. 708.

  • alpha_nonneg (i : κ) : 0 ≤ α i

    Nonnegativity of keyword shadow prices α i ≥ 0.

  • beta_nonneg (j : ι) : 0 ≤ β j

    Nonnegativity of budget shadow prices β j ≥ 0.

  • bid_le (i : κ) (j : ι) : lp.bid i j ≤ α i + lp.bid i j * β j

    Dual covering constraint: α i + bid i j * β j ≥ bid i j.

def Cslib.Algorithms.Lean.OnlineMatching.AdWords.LP.primalObj {κ : Type u_1} {ι : Type u_2} [Fintype κ] [Fintype ι] (lp : LP κ ι) (x : κ → ι → ℝ) :

Primal objective ∑ i, ∑ j, bid i j * x i j of Eq. (28.11).

def Cslib.Algorithms.Lean.OnlineMatching.AdWords.LP.dualObj {κ : Type u_1} {ι : Type u_2} [Fintype κ] [Fintype ι] (lp : LP κ ι) (α : κ → ℝ) (β : ι → ℝ) :

Dual objective ∑ j, budget j * β j + ∑ i, demand i * α i of the dual of Eq. (28.11).

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.LP.primalObj_le_dualObj {κ : Type u_1} {ι : Type u_2} [Fintype κ] [Fintype ι] {lp : LP κ ι} {x : κ → ι → ℝ} {α : κ → ℝ} {β : ι → ℝ} (hx : lp.IsPrimalFeasible x) (hd : lp.IsDualFeasible α β) :
lp.primalObj x ≤ lp.dualObj α β

Weak duality for the AdWords LP relaxation Eq. (28.11) ([LPSV07], §28.4.1, p. 708).

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.LP.complementarySlackness {κ : Type u_1} {ι : Type u_2} [Fintype κ] [Fintype ι] {lp : LP κ ι} {x : κ → ι → ℝ} {α : κ → ℝ} {β : ι → ℝ} (hx : lp.IsPrimalFeasible x) (hd : lp.IsDualFeasible α β) (heq : lp.primalObj x = lp.dualObj α β) {i : κ} {j : ι} (hxpos : 0 < x i j) :
(1 - β j) * lp.bid i j = α i ∧ ∀ (k : ι), (1 - β k) * lp.bid i k ≤ (1 - β j) * lp.bid i j

Complementary slackness for Eq. (28.11) ([LPSV07], §28.4.1, p. 708): at primal–dual equality primalObj x = dualObj α β, every pair (i, j) with x i j > 0 satisfies (1 - β j) * bid i j = α i and maximizes (1 - β k) * bid i k over all advertisers k.

def Cslib.Algorithms.Lean.OnlineMatching.AdWords.LP.unit {T : ℕ} {ι : Type u_1} (bid : Fin T → ι → ℝ) (budget : ι → ℝ) :
LP (Fin T) ι

The unit-demand LP instance for a stream of T arriving queries with per-query bids bid : Fin T → ι → ℝ (demand t = 1 for every t : Fin T).

def Cslib.Algorithms.Lean.OnlineMatching.AdWords.LP.countLP {T : ℕ} {κ : Type u_1} {ι : Type u_2} [DecidableEq κ] (bid : κ → ι → ℝ) (budget : ι → ℝ) (queries : Fin T → κ) :
LP κ ι

The keyword-frequency LP relaxation Eq. (28.11) induced by a sequence queries : Fin T → κ of arriving keywords: demand i is the number of arrivals t : Fin T with queries t = i.

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.LP.exists_unitPrimal_of_countLP {T : ℕ} {κ : Type u_1} {ι : Type u_2} [Fintype κ] [DecidableEq κ] [Fintype ι] {bid : κ → ι → ℝ} {budget : ι → ℝ} (queries : Fin T → κ) {x : κ → ι → ℝ} (hx : (countLP bid budget queries).IsPrimalFeasible x) :
∃ (y : Fin T → ι → ℝ), (unit (fun (t : Fin T) (j : ι) => bid (queries t) j) budget).IsPrimalFeasible y ∧ (unit (fun (t : Fin T) (j : ι) => bid (queries t) j) budget).primalObj y = (countLP bid budget queries).primalObj x

Every feasible fractional solution x to the keyword-frequency LP countLP spreads evenly across matching arrival steps into a feasible solution y of the unit-demand LP unit with the exact same primal objective value ([LPSV07], §28.4.1, p. 708).

Shared deterministic online allocation runner #

noncomputable def Cslib.Algorithms.Lean.OnlineMatching.AdWords.argmaxOver {ι : Type u_1} [LinearOrder ι] (S : Finset ι) (score : ι → ℝ) :

The deterministic argmax of score : ι → ℝ over a finite set S : Finset ι, breaking ties toward the smallest advertiser in [LinearOrder ι], or none if S is empty.

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.argmaxOver_eq_some_iff {ι : Type u_1} [LinearOrder ι] {S : Finset ι} {score : ι → ℝ} {j : ι} :
argmaxOver S score = some j ↔ j ∈ S ∧ (∀ k ∈ S, score k ≤ score j) ∧ ∀ k ∈ S, k < j → score k < score j

Specification characterizing the exact tie-breaking choice argmaxOver S score = some j: j ∈ S, score j maximizes score on S, and every strictly smaller k ∈ S has strictly smaller score.

One-step outcome produced by an online allocation rule on a single arriving query.

  • choice : Option ι

    Advertiser selected to receive the query, or none if the query is left unallocated.

  • payment : ℝ

    Payment charged to choice (0 when choice = none).

def Cslib.Algorithms.Lean.OnlineMatching.AdWords.applyStep {ι : Type u_1} [DecidableEq ι] (spent : ι → ℝ) (res : StepResult ι) :
ι → ℝ

Update the cumulative spend vector spent with a single StepResult.

@[reducible, inline]

Type alias for a deterministic online allocation rule: given current cumulative spending spent : ι → ℝ and the arriving query's bid vector q : ι → ℝ, return a StepResult ι.

def Cslib.Algorithms.Lean.OnlineMatching.AdWords.spentAt {T : ℕ} {ι : Type u_1} [DecidableEq ι] (rule : AllocationRule ι) (b : Fin T → ι → ℝ) (t : Fin (T + 1)) :
ι → ℝ

Cumulative spending vector after processing the first t.val queries (t : Fin (T + 1)).

def Cslib.Algorithms.Lean.OnlineMatching.AdWords.finalSpent {T : ℕ} {ι : Type u_1} [DecidableEq ι] (rule : AllocationRule ι) (b : Fin T → ι → ℝ) :
ι → ℝ

Cumulative spending vector after processing all T queries.

def Cslib.Algorithms.Lean.OnlineMatching.AdWords.revenue {T : ℕ} {ι : Type u_1} [Fintype ι] [DecidableEq ι] (rule : AllocationRule ι) (b : Fin T → ι → ℝ) :

Total online revenue collected after processing all T queries: ∑ j, finalSpent rule b j.

def Cslib.Algorithms.Lean.OnlineMatching.AdWords.choiceAt {T : ℕ} {ι : Type u_1} [DecidableEq ι] (rule : AllocationRule ι) (b : Fin T → ι → ℝ) (t : Fin T) :

Chosen advertiser at query arrival step t : Fin T.

def Cslib.Algorithms.Lean.OnlineMatching.AdWords.paymentAt {T : ℕ} {ι : Type u_1} [DecidableEq ι] (rule : AllocationRule ι) (b : Fin T → ι → ℝ) (t : Fin T) :

Payment collected at query arrival step t : Fin T.

@[simp]
theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.spentAt_zero {T : ℕ} {ι : Type u_1} [DecidableEq ι] (rule : AllocationRule ι) (b : Fin T → ι → ℝ) :
spentAt rule b 0 = 0

Initial spending vector before any queries arrive is identically zero.

@[simp]
theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.spentAt_succ {T : ℕ} {ι : Type u_1} [DecidableEq ι] (rule : AllocationRule ι) (b : Fin T → ι → ℝ) (t : Fin T) :
spentAt rule b t.succ = applyStep (spentAt rule b t.castSucc) (rule (spentAt rule b t.castSucc) (b t))

One-step recurrence updating cumulative spending after processing query t.

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.revenue_eq_sum_paymentAt {T : ℕ} {ι : Type u_1} [Fintype ι] [DecidableEq ι] {rule : AllocationRule ι} {b : Fin T → ι → ℝ} (hnone : ∀ (t : Fin T), choiceAt rule b t = none → paymentAt rule b t = 0) :
revenue rule b = ∑ t : Fin T, paymentAt rule b t

When an unallocated query always charges 0, revenue equals the sum of per-step payments.

The four online allocation rules #

The MSVV trade-off function φ(x) = 1 - exp (x - 1) ([LPSV07], §28.4.1, p. 709).

The MSVV trade-off weight φ(x) = 1 - exp (x - 1) is nonnegative for x ≤ 1.

The MSVV trade-off weight φ(x) = 1 - exp (x - 1) is antitone (nonincreasing).

noncomputable def Cslib.Algorithms.Lean.OnlineMatching.AdWords.greedyTruncRule {ι : Type u_1} [Fintype ι] [LinearOrder ι] (budget : ι → ℝ) :

Capped-bid truncated Greedy allocation rule: among advertisers with unexhausted budget s j < B j, pick the one maximizing the effective payment min (q j) (B j - s j) (ties broken toward the smallest advertiser), and charge that amount. Coincides with raw-bid Greedy whenever the winning bid fits in remaining budget.

All-or-nothing Greedy allocation rule: among advertisers whose remaining budget fits the full bid (s j + q j ≤ B j), pick the one maximizing q j (ties broken toward the smallest advertiser), and charge q j.

noncomputable def Cslib.Algorithms.Lean.OnlineMatching.AdWords.msvvTruncRule {ι : Type u_1} [Fintype ι] [LinearOrder ι] (budget : ι → ℝ) :

MSVV Algorithm 1 ([LPSV07], §28.4.1, p. 709) with truncated spend: among advertisers with unexhausted budget s j < B j, pick the one maximizing q j * msvvWeight (s j / B j) (ties broken toward the smallest advertiser), and charge min (q j) (B j - s j).

MSVV Algorithm 1 ([LPSV07], §28.4.1, p. 709) with all-or-nothing spend: among advertisers with remaining budget s j + q j ≤ B j, pick the one maximizing q j * msvvWeight (s j / B j) (ties broken toward the smallest advertiser), and charge q j.

Budget-safety invariants #

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.greedyTrunc_spent_mem {T : ℕ} {ι : Type u_1} [Fintype ι] [LinearOrder ι] {b : Fin T → ι → ℝ} {budget : ι → ℝ} (hB : ∀ (j : ι), 0 ≤ budget j) (hb : ∀ (t : Fin T) (j : ι), 0 ≤ b t j) (t : Fin (T + 1)) (j : ι) :
0 ≤ spentAt (greedyTruncRule budget) b t j ∧ spentAt (greedyTruncRule budget) b t j ≤ budget j

greedyTruncRule keeps every advertiser's cumulative spending inside [0, budget j].

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.greedyAllOrNothing_spent_mem {T : ℕ} {ι : Type u_1} [Fintype ι] [LinearOrder ι] {b : Fin T → ι → ℝ} {budget : ι → ℝ} (hB : ∀ (j : ι), 0 ≤ budget j) (hb : ∀ (t : Fin T) (j : ι), 0 ≤ b t j) (t : Fin (T + 1)) (j : ι) :
0 ≤ spentAt (greedyAllOrNothingRule budget) b t j ∧ spentAt (greedyAllOrNothingRule budget) b t j ≤ budget j

greedyAllOrNothingRule keeps every advertiser's cumulative spending inside [0, budget j].

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.msvvTrunc_spent_mem {T : ℕ} {ι : Type u_1} [Fintype ι] [LinearOrder ι] {b : Fin T → ι → ℝ} {budget : ι → ℝ} (hB : ∀ (j : ι), 0 ≤ budget j) (hb : ∀ (t : Fin T) (j : ι), 0 ≤ b t j) (t : Fin (T + 1)) (j : ι) :
0 ≤ spentAt (msvvTruncRule budget) b t j ∧ spentAt (msvvTruncRule budget) b t j ≤ budget j

msvvTruncRule keeps every advertiser's cumulative spending inside [0, budget j].

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.msvvAllOrNothing_spent_mem {T : ℕ} {ι : Type u_1} [Fintype ι] [LinearOrder ι] {b : Fin T → ι → ℝ} {budget : ι → ℝ} (hB : ∀ (j : ι), 0 ≤ budget j) (hb : ∀ (t : Fin T) (j : ι), 0 ≤ b t j) (t : Fin (T + 1)) (j : ι) :
0 ≤ spentAt (msvvAllOrNothingRule budget) b t j ∧ spentAt (msvvAllOrNothingRule budget) b t j ≤ budget j

msvvAllOrNothingRule keeps every advertiser's cumulative spending inside [0, budget j].

Greedy competitive ratios (NRTV §28.4.1, p. 709) #

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.greedyTrunc_competitive {T : ℕ} {ι : Type u_1} [Fintype ι] [LinearOrder ι] {b : Fin T → ι → ℝ} {budget : ι → ℝ} {x : Fin T → ι → ℝ} (hB : ∀ (j : ι), 0 < budget j) (hb0 : ∀ (t : Fin T) (j : ι), 0 ≤ b t j) (hbB : ∀ (t : Fin T) (j : ι), b t j ≤ budget j) (hx : (LP.unit b budget).IsPrimalFeasible x) :
(LP.unit b budget).primalObj x ≤ 2 * revenue (greedyTruncRule budget) b

Exact 1 / 2-competitive ratio for capped-bid truncated Greedy against the offline fractional LP relaxation (28.11) ([LPSV07], §28.4.1, p. 709). Requires only 0 ≤ b t j ≤ budget j (no small-bid assumption and no assumption that OPT exhausts budgets).

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.greedyAllOrNothing_competitive {T : ℕ} {ι : Type u_1} [Fintype ι] [LinearOrder ι] {b : Fin T → ι → ℝ} {budget : ι → ℝ} {x : Fin T → ι → ℝ} {R : ℝ} (hB : ∀ (j : ι), 0 < budget j) (hR0 : 0 ≤ R) (hR1 : R ≤ 1) (hb0 : ∀ (t : Fin T) (j : ι), 0 ≤ b t j) (hbR : ∀ (t : Fin T) (j : ι), b t j ≤ R * budget j) (hx : (LP.unit b budget).IsPrimalFeasible x) :
(1 - R) * (LP.unit b budget).primalObj x ≤ (2 - R) * revenue (greedyAllOrNothingRule budget) b

Exact (1 - R) / (2 - R)-competitive ratio for all-or-nothing Greedy against the offline fractional LP relaxation (28.11) ([LPSV07], §28.4.1, p. 709) when all bids satisfy b t j ≤ R * budget j (0 ≤ R ≤ 1). Because 2 - R ≤ 2, this is strictly tighter than the standard (1 - R) / 2 bound for non-zero R, and its factor tends to 1 / 2 as R → 0 (tendsto_greedyAllOrNothing_factor).

As the bid-to-budget ratio R → 0, the all-or-nothing Greedy factor (1 - R) / (2 - R) converges to 1 / 2.

Tight two-bidder worst-case example for Greedy (NRTV p. 709) #

The bid matrix for the two-bidder Greedy lower-bound example ([LPSV07], §28.4.1, p. 709): b 0 = ![2, 2 - ε], b 1 = ![2, ε].

Equal advertiser budgets B = ![2, 2] for the two-bidder example.

The off-diagonal integral allocation x 0 = ![0, 1], x 1 = ![1, 0] assigning query 1 to bidder 2 and query 2 to bidder 1.

Tightness of the 1/2 ratio for Greedy ([LPSV07], §28.4.1, p. 709): for 0 < ε < 2 with B = ![2, 2], b₁₁ = 2, b₁₂ = 2 - ε, b₂₁ = 2, b₂₂ = ε:

  1. Both greedyTruncRule and greedyAllOrNothingRule earn 2 + ε.
  2. twoBidderOptAlloc is LP-feasible and attains revenue 4 - ε (correcting the printed 4 on NRTV p. 709).
  3. For 0 < ε ≤ 1, 4 - ε is exact LP-optimal (every feasible fractional LP solution x has primalObj x ≤ 4 - ε, certified by the dual witness α = ![2 - ε, ε], β = ![1 - ε / 2, 0]).

The ratio (2 + ε) / (4 - ε) of the two-bidder greedy revenue to its true optimum 4 - ε converges to 1 / 2 as ε → 0.

Exponential inequalities for the primal-dual MSVV proof #

Continuous trade-off inequality (analogue of NRTV Lemma 28.4) and Theorem 28.3 #

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.msvvTrunc_tradeoff {T : ℕ} {ι : Type u_1} [Fintype ι] [LinearOrder ι] {b : Fin T → ι → ℝ} {budget : ι → ℝ} {x : Fin T → ι → ℝ} (hB : ∀ (j : ι), 0 < budget j) (hb0 : ∀ (t : Fin T) (j : ι), 0 ≤ b t j) (hx : (LP.unit b budget).IsPrimalFeasible x) :
∑ j : ι, msvvWeight (finalSpent (msvvTruncRule budget) b j / budget j) * ∑ t : Fin T, b t j * x t j ≤ ∑ t : Fin T, match choiceAt (msvvTruncRule budget) b t with | none => 0 | some j => msvvWeight (spentAt (msvvTruncRule budget) b t.castSucc j / budget j) * b t j

Continuous trade-off inequality for MSVV Algorithm 1 (truncated spend), the continuous analogue of [LPSV07], Lemma 28.4, Eq. (28.13), p. 710. Holds against every LP-feasible fractional solution x without assuming that OPT exhausts every budget.

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.msvvTrunc_competitive {T : ℕ} {ι : Type u_1} [Fintype ι] [LinearOrder ι] {b : Fin T → ι → ℝ} {budget : ι → ℝ} {x : Fin T → ι → ℝ} {R : ℝ} (hB : ∀ (j : ι), 0 < budget j) (hb0 : ∀ (t : Fin T) (j : ι), 0 ≤ b t j) (hbR : ∀ (t : Fin T) (j : ι), b t j ≤ R * budget j) (hx : (LP.unit b budget).IsPrimalFeasible x) :
(1 - Real.exp (-1)) * Real.exp (-R) * (LP.unit b budget).primalObj x ≤ revenue (msvvTruncRule budget) b

MSVV Algorithm 1 competitive-ratio upper bound (truncated spend) — the revenue lower bound half of [LPSV07], Theorem 28.3 (pp. 709–711) and Exercise 28.6 (p. 716).

For every finite bid ratio R ≥ 0 with b t j ≤ R * budget j, every positive budget profile budget, and every feasible fractional LP solution x to Eq. (28.11) (without assuming OPT exhausts budgets): (1 - exp (-1)) * exp (-R) * primalObj x ≤ revenue (msvvTruncRule budget) b.

The companion optimality lower bound ("no deterministic or randomized online algorithm beats 1 - 1/e") is not proved here and stays open under issue #7789. No running-time claim is made.

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.msvvTrunc_competitive_countLP {T : ℕ} {κ : Type u_1} {ι : Type u_2} [Fintype κ] [DecidableEq κ] [Fintype ι] [LinearOrder ι] {bid : κ → ι → ℝ} {budget : ι → ℝ} (queries : Fin T → κ) {x : κ → ι → ℝ} {R : ℝ} (hB : ∀ (j : ι), 0 < budget j) (hb0 : ∀ (i : κ) (j : ι), 0 ≤ bid i j) (hbR : ∀ (i : κ) (j : ι), bid i j ≤ R * budget j) (hx : (LP.countLP bid budget queries).IsPrimalFeasible x) :
(1 - Real.exp (-1)) * Real.exp (-R) * (LP.countLP bid budget queries).primalObj x ≤ revenue (msvvTruncRule budget) fun (t : Fin T) (j : ι) => bid (queries t) j

MSVV Algorithm 1 competitive-ratio upper bound (truncated spend) lifted directly to the keyword-frequency LP relaxation (28.11) countLP (demand i = #{t | queries t = i}).

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.msvvAllOrNothing_competitive {T : ℕ} {ι : Type u_1} [Fintype ι] [LinearOrder ι] {b : Fin T → ι → ℝ} {budget : ι → ℝ} {x : Fin T → ι → ℝ} {R : ℝ} (hB : ∀ (j : ι), 0 < budget j) (hR0 : 0 ≤ R) (hR1 : R ≤ 1) (hb0 : ∀ (t : Fin T) (j : ι), 0 ≤ b t j) (hbR : ∀ (t : Fin T) (j : ι), b t j ≤ R * budget j) (hx : (LP.unit b budget).IsPrimalFeasible x) :
(1 - Real.exp (-1)) * (1 - R) * Real.exp (-R) * (LP.unit b budget).primalObj x ≤ revenue (msvvAllOrNothingRule budget) b

MSVV Algorithm 1 competitive-ratio upper bound (all-or-nothing spend) — the revenue lower bound half of [LPSV07], Theorem 28.3 (pp. 709–711) and Exercise 28.6 (p. 716), when a query is assigned to j only if s j + b t j ≤ budget j.

For every 0 ≤ R ≤ 1 with b t j ≤ R * budget j and every feasible fractional LP solution x to Eq. (28.11) (without assuming OPT exhausts budgets): (1 - exp (-1)) * (1 - R) * exp (-R) * primalObj x ≤ revenue (msvvAllOrNothingRule budget) b.

The matching optimality lower bound stays open under issue #7789. No running-time claim is made.

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.msvvAllOrNothing_competitive_countLP {T : ℕ} {κ : Type u_1} {ι : Type u_2} [Fintype κ] [DecidableEq κ] [Fintype ι] [LinearOrder ι] {bid : κ → ι → ℝ} {budget : ι → ℝ} (queries : Fin T → κ) {x : κ → ι → ℝ} {R : ℝ} (hB : ∀ (j : ι), 0 < budget j) (hR0 : 0 ≤ R) (hR1 : R ≤ 1) (hb0 : ∀ (i : κ) (j : ι), 0 ≤ bid i j) (hbR : ∀ (i : κ) (j : ι), bid i j ≤ R * budget j) (hx : (LP.countLP bid budget queries).IsPrimalFeasible x) :
(1 - Real.exp (-1)) * (1 - R) * Real.exp (-R) * (LP.countLP bid budget queries).primalObj x ≤ revenue (msvvAllOrNothingRule budget) fun (t : Fin T) (j : ι) => bid (queries t) j

MSVV Algorithm 1 competitive-ratio upper bound (all-or-nothing spend) lifted directly to the keyword-frequency LP relaxation (28.11) countLP (demand i = #{t | queries t = i}).

As the bid-to-budget ratio R → 0, the truncated-spend MSVV competitive factor converges to 1 - exp (-1) (1 - 1 / e).

As the bid-to-budget ratio R → 0, the all-or-nothing MSVV competitive factor converges to 1 - exp (-1) (1 - 1 / e).

Discrete k-bucket geometric series (NRTV displays 28.12–28.13, pp. 710–711) #

Discrete trade-off function Φ(s) = 1 - (1 - 1 / k) ^ (k - s) ([LPSV07], §28.4.1, display (28.12), p. 710).

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.discretePhi_tradeoff {k : ℕ} (hk : 0 < k) {s w : Fin (k + 1) → ℝ} (htrade : ∑ i : Fin (k + 1), discretePhi k ↑i * s i ≤ ∑ i : Fin (k + 1), discretePhi k ↑i * w i) (hw : ∀ (i : Fin (k + 1)), w i ≤ (∑ j : Fin (k + 1) with i ≤ j, s j) / ↑k) :
(1 - 1 / ↑k) * discretePhi k 0 * ∑ i : Fin (k + 1), s i ≤ ∑ i : Fin (k + 1), ↑↑i / ↑k * s i

The exact discrete geometric-series step proving NRTV p. 710–711 from display (28.13) (correcting the printed inner index typo ∑_{j=0}^i Φ(i) → ∑_{j=0}^i Φ(j) on p. 710). Given ∑ i, Φ(i) s_i ≤ ∑ i, Φ(i) w_i and w_i ≤ (∑_{j ≥ i} s_j) / k, yields (1 - 1 / k) * Φ(0) * ∑ s_i ≤ ∑ (i / k) * s_i.

theorem Cslib.Algorithms.Lean.OnlineMatching.AdWords.discretePhi_tradeoff_zero {k : ℕ} (hk : 0 < k) {s w : Fin (k + 1) → ℝ} (htrade : ∑ i : Fin (k + 1), discretePhi k ↑i * s i ≤ ∑ i : Fin (k + 1), discretePhi k ↑i * w i) (hw0 : w 0 = 0) (hw : ∀ (i : Fin (k + 1)), 0 < ↑i → w i ≤ (∑ j : Fin (k + 1) with i ≤ j, s j) / ↑k) :
discretePhi k 0 * ∑ i : Fin (k + 1), s i ≤ ∑ i : Fin (k + 1), ↑↑i / ↑k * s i

Exact error-free version of discretePhi_tradeoff when no budget is spent inside the empty zero-interval (-1/k, 0] (w 0 = 0): Φ(0) * ∑ s_i ≤ ∑ (i / k) * s_i.

As the discretization k → ∞, discretePhi k 0 = 1 - (1 - 1 / k) ^ k converges to 1 - exp (-1) ([LPSV07], §28.4.1, p. 711).