Documentation

CslibFrontier.GameTheory.PredictionMarket.BooleanAggregation

Distributed computation through Boolean prediction markets #

This module formalizes the synchronous Shapley–Shubik Boolean prediction market model and its information-aggregation characterization from [PennockSami2007, §26.5, pp. 665–669].

Model and conventions #

There are n agents (i : Fin n, with 0 < n), each holding a private bit x i : Bool of the true state x : Fin n → Bool, and a Boolean security f : (Fin n → Bool) → Bool paying $1 if f x = true and $0 otherwise, evaluated under a common prior P : (Fin n → Bool) → ℝ (IsMixedStrategy P).

Main definitions #

Main results #

References #

Boolean Market Model (§26.5.1–26.5.4) #

noncomputable def Cslib.GameTheory.PredictionMarket.priorSupport {n : ℕ} (P : (Fin n → Bool) → ℝ) :
Finset (Fin n → Bool)

The set of positive-probability states {y | 0 < P y} under prior P.

@[simp]
theorem Cslib.GameTheory.PredictionMarket.mem_priorSupport {n : ℕ} {P : (Fin n → Bool) → ℝ} {y : Fin n → Bool} :
y ∈ priorSupport P ↔ 0 < P y
def Cslib.GameTheory.PredictionMarket.agentKnowledge {n : ℕ} (S : Finset (Fin n → Bool)) (i : Fin n) (y : Fin n → Bool) :
Finset (Fin n → Bool)

Agent i's knowledge set {z ∈ S | z i = y i} at state y given common knowledge S [PennockSami2007, §26.5.4, p. 668].

@[simp]
theorem Cslib.GameTheory.PredictionMarket.mem_agentKnowledge {n : ℕ} {S : Finset (Fin n → Bool)} {i : Fin n} {y z : Fin n → Bool} :
z ∈ agentKnowledge S i y ↔ z ∈ S ∧ z i = y i
noncomputable def Cslib.GameTheory.PredictionMarket.condExpect {n : ℕ} (f : (Fin n → Bool) → Bool) (P : (Fin n → Bool) → ℝ) (A : Finset (Fin n → Bool)) :

Conditional expectation P(f(z) = 1 | z ∈ A) of the Boolean security f over A.

@[simp]
theorem Cslib.GameTheory.PredictionMarket.condExpect_apply {n : ℕ} (f : (Fin n → Bool) → Bool) (P : (Fin n → Bool) → ℝ) (A : Finset (Fin n → Bool)) :
condExpect f P A = (∑ z ∈ A, if f z = true then P z else 0) / ∑ z ∈ A, P z
noncomputable def Cslib.GameTheory.PredictionMarket.agentBid {n : ℕ} (f : (Fin n → Bool) → Bool) (P : (Fin n → Bool) → ℝ) (S : Finset (Fin n → Bool)) (i : Fin n) (y : Fin n → Bool) :

Myopic truthful bid of agent i at state y given common knowledge S: b_i(y) = P(f(z) = 1 | z ∈ S_i(y)) [PennockSami2007, §26.5.3–26.5.4, pp. 667–668].

@[simp]
theorem Cslib.GameTheory.PredictionMarket.agentBid_apply {n : ℕ} (f : (Fin n → Bool) → Bool) (P : (Fin n → Bool) → ℝ) (S : Finset (Fin n → Bool)) (i : Fin n) (y : Fin n → Bool) :
agentBid f P S i y = condExpect f P (agentKnowledge S i y)
noncomputable def Cslib.GameTheory.PredictionMarket.roundPrice {n : ℕ} (f : (Fin n → Bool) → Bool) (P : (Fin n → Bool) → ℝ) (S : Finset (Fin n → Bool)) (y : Fin n → Bool) :

Unit-quantity (q_i = 1) Shapley–Shubik market clearing price p(y) = (∑ i, agentBid f P S i y) / n [PennockSami2007, §26.5.2, p. 666].

@[simp]
theorem Cslib.GameTheory.PredictionMarket.roundPrice_apply {n : ℕ} (f : (Fin n → Bool) → Bool) (P : (Fin n → Bool) → ℝ) (S : Finset (Fin n → Bool)) (y : Fin n → Bool) :
roundPrice f P S y = (∑ i : Fin n, agentBid f P S i y) / ↑n
noncomputable def Cslib.GameTheory.PredictionMarket.commonKnowledge {n : ℕ} (f : (Fin n → Bool) → Bool) (P : (Fin n → Bool) → ℝ) (x : Fin n → Bool) :
ℕ → Finset (Fin n → Bool)

Common-knowledge possibility set Sʳ after r rounds of trading when the true state is x, initialized at S⁰ = priorSupport P [PennockSami2007, §26.5.4, p. 668].

@[simp]
theorem Cslib.GameTheory.PredictionMarket.commonKnowledge_zero {n : ℕ} (f : (Fin n → Bool) → Bool) (P : (Fin n → Bool) → ℝ) (x : Fin n → Bool) :
theorem Cslib.GameTheory.PredictionMarket.mem_commonKnowledge_succ {n : ℕ} {f : (Fin n → Bool) → Bool} {P : (Fin n → Bool) → ℝ} {x y : Fin n → Bool} {r : ℕ} :
y ∈ commonKnowledge f P x (r + 1) ↔ y ∈ commonKnowledge f P x r ∧ roundPrice f P (commonKnowledge f P x r) y = roundPrice f P (commonKnowledge f P x r) x
theorem Cslib.GameTheory.PredictionMarket.commonKnowledge_succ_subset {n : ℕ} (f : (Fin n → Bool) → Bool) (P : (Fin n → Bool) → ℝ) (x : Fin n → Bool) (r : ℕ) :
commonKnowledge f P x (r + 1) ⊆ commonKnowledge f P x r
theorem Cslib.GameTheory.PredictionMarket.commonKnowledge_antitone {n : ℕ} (f : (Fin n → Bool) → Bool) (P : (Fin n → Bool) → ℝ) (x : Fin n → Bool) :
theorem Cslib.GameTheory.PredictionMarket.commonKnowledge_subset_priorSupport {n : ℕ} (f : (Fin n → Bool) → Bool) (P : (Fin n → Bool) → ℝ) (x : Fin n → Bool) (r : ℕ) :
theorem Cslib.GameTheory.PredictionMarket.mem_commonKnowledge_self {n : ℕ} {f : (Fin n → Bool) → Bool} {P : (Fin n → Bool) → ℝ} {x : Fin n → Bool} (hx : 0 < P x) (r : ℕ) :
theorem Cslib.GameTheory.PredictionMarket.commonKnowledge_eq_of_eq_succ {n : ℕ} {f : (Fin n → Bool) → Bool} {P : (Fin n → Bool) → ℝ} {x : Fin n → Bool} {r : ℕ} (hstab : commonKnowledge f P x (r + 1) = commonKnowledge f P x r) (k : ℕ) :
r ≤ k → commonKnowledge f P x k = commonKnowledge f P x r

Once Sʳ⁺¹ = Sʳ, common knowledge remains constant for all later rounds k ≥ r.

Private helper lemmas for sums and affine dimension #

theorem Cslib.GameTheory.PredictionMarket.commonKnowledge_succ_eq_self_at_n {n : ℕ} {f : (Fin n → Bool) → Bool} {P : (Fin n → Bool) → ℝ} {x : Fin n → Bool} (hx : 0 < P x) :
commonKnowledge f P x (n + 1) = commonKnowledge f P x n

Affine-dimension stabilization bound (generalizes [PennockSami2007, Theorem 26.14, p. 669] to every Boolean function f): for any f, P, and state x with 0 < P x, the common-knowledge set stabilizes after at most n rounds (Sⁿ⁺¹ = Sⁿ).

noncomputable def Cslib.GameTheory.PredictionMarket.eqSet {n : ℕ} (f : (Fin n → Bool) → Bool) (P : (Fin n → Bool) → ℝ) (x : Fin n → Bool) :
Finset (Fin n → Bool)

The equilibrium common-knowledge set S^∞ for true state x, equal to commonKnowledge f P x n since the market stabilizes in at most n rounds (commonKnowledge_succ_eq_self_at_n).

noncomputable def Cslib.GameTheory.PredictionMarket.eqPrice {n : ℕ} (f : (Fin n → Bool) → Bool) (P : (Fin n → Bool) → ℝ) (x : Fin n → Bool) :

The equilibrium clearing price p^∞ = roundPrice f P (eqSet f P x) x [PennockSami2007, §26.5.4, p. 668].

theorem Cslib.GameTheory.PredictionMarket.commonKnowledge_eq_eqSet_of_le {n : ℕ} {f : (Fin n → Bool) → Bool} {P : (Fin n → Bool) → ℝ} {x : Fin n → Bool} (hx : 0 < P x) {r : ℕ} (hr : n ≤ r) :
commonKnowledge f P x r = eqSet f P x
theorem Cslib.GameTheory.PredictionMarket.commonKnowledge_eq_eqSet_of_eq_succ {n : ℕ} {f : (Fin n → Bool) → Bool} {P : (Fin n → Bool) → ℝ} {x : Fin n → Bool} (hx : 0 < P x) {r : ℕ} (hstab : commonKnowledge f P x (r + 1) = commonKnowledge f P x r) :
commonKnowledge f P x r = eqSet f P x
theorem Cslib.GameTheory.PredictionMarket.roundPrice_eq_eqPrice_of_mem_eqSet {n : ℕ} {f : (Fin n → Bool) → Bool} {P : (Fin n → Bool) → ℝ} {x y : Fin n → Bool} (hx : 0 < P x) (hy : y ∈ eqSet f P x) :
roundPrice f P (eqSet f P x) y = eqPrice f P x

Theorem 26.9: Common Knowledge of Aggregates at Equilibrium (§26.5.4, p. 668) #

theorem Cslib.GameTheory.PredictionMarket.eq_condExpect_and_agentBid_of_roundPrice_const {n : ℕ} (hn : 0 < n) {f : (Fin n → Bool) → Bool} {P : (Fin n → Bool) → ℝ} {S : Finset (Fin n → Bool)} (hS : S ⊆ priorSupport P) (hne : S.Nonempty) {p : ℝ} (hconst : ∀ y ∈ S, roundPrice f P S y = p) :
condExpect f P S = p ∧ ∀ (i : Fin n), ∀ y ∈ S, agentBid f P S i y = p

Common knowledge of aggregates at any fixed-point set ([PennockSami2007, Theorem 26.9, Eqs. (26.1)–(26.2), p. 668]): if 0 < n, S ⊆ priorSupport P is nonempty, and the clearing price roundPrice f P S y takes a constant value p on S, then:

  1. condExpect f P S = p (Eq. 26.1), and
  2. agentBid f P S i y = p for every agent i and every state y ∈ S (Eq. 26.2).
theorem Cslib.GameTheory.PredictionMarket.equilibrium_commonKnowledge_of_aggregates {n : ℕ} (hn : 0 < n) {f : (Fin n → Bool) → Bool} {P : (Fin n → Bool) → ℝ} {x : Fin n → Bool} (hx : 0 < P x) :
condExpect f P (eqSet f P x) = eqPrice f P x ∧ ∀ (i : Fin n), ∀ y ∈ eqSet f P x, agentBid f P (eqSet f P x) i y = eqPrice f P x

Theorem 26.9 ([PennockSami2007, p. 668, Eqs. (26.1)–(26.2)]): at equilibrium (eqSet f P x, eqPrice f P x) for any 0 < n and any prior P with 0 < P x, the common-knowledge expectation and every agent's conditional expectation equal the equilibrium price p^∞.

Definition 26.11 and Theorems 26.12–26.13: Weighted Threshold Characterization #

A Boolean function f : (Fin n → Bool) → Bool is a weighted threshold function iff there exist real constants w₀, w₁, …, wₙ such that f x = true ↔ 1 ≤ w₀ + ∑ i, w i * x_i [PennockSami2007, Definition 26.11, p. 669].

This is equivalent to Cslib.Circuits.Boolean.WeightedThreshold.IsLTF via θ = 1 - w₀; it is defined directly here to match Definition 26.11 without importing the depth-two threshold-circuit complexity stack.

theorem Cslib.GameTheory.PredictionMarket.isWeightedThreshold_iff {n : ℕ} {f : (Fin n → Bool) → Bool} :
IsWeightedThreshold f ↔ ∃ (w₀ : ℝ) (w : Fin n → ℝ), ∀ (x : Fin n → Bool), f x = true ↔ 1 ≤ w₀ + ∑ i : Fin n, w i * if x i = true then 1 else 0
theorem Cslib.GameTheory.PredictionMarket.eq_of_mem_eqSet_of_isWeightedThreshold {n : ℕ} (hn : 0 < n) {f : (Fin n → Bool) → Bool} (hf : IsWeightedThreshold f) {P : (Fin n → Bool) → ℝ} {x : Fin n → Bool} (hx : 0 < P x) (y : Fin n → Bool) :
y ∈ eqSet f P x → f y = f x

At equilibrium for a weighted threshold function f, common knowledge eqSet f P x already determines f x: every state y ∈ eqSet f P x satisfies f y = f x.

theorem Cslib.GameTheory.PredictionMarket.eqPrice_eq_of_isWeightedThreshold {n : ℕ} (hn : 0 < n) {f : (Fin n → Bool) → Bool} (hf : IsWeightedThreshold f) {P : (Fin n → Bool) → ℝ} {x : Fin n → Bool} (hx : 0 < P x) :
eqPrice f P x = if f x = true then 1 else 0

Theorem 26.12 ([PennockSami2007, p. 669]): if f : (Fin n → Bool) → Bool (0 < n) is a weighted threshold function, then for every prior P and every state x with 0 < P x, the equilibrium price equals f x (1 if f x = true, 0 if f x = false).

theorem Cslib.GameTheory.PredictionMarket.exists_prior_eqPrice_eq_half_of_not_isWeightedThreshold {n : ℕ} {f : (Fin n → Bool) → Bool} (hf : ¬IsWeightedThreshold f) :
∃ (P : (Fin n → Bool) → ℝ), IsMixedStrategy P ∧ ∀ (x : Fin n → Bool), 0 < P x → eqPrice f P x = 1 / 2

Theorem 26.13 ([PennockSami2007, p. 669]): if f : (Fin n → Bool) → Bool is not a weighted threshold function, then there exists a prior distribution P (IsMixedStrategy P) for which the market immediately stabilizes at equilibrium price p^∞ = 1 / 2 on every positive-probability state (and therefore never reveals f x ∈ {0, 1}).

theorem Cslib.GameTheory.PredictionMarket.isWeightedThreshold_iff_forall_eqPrice_eq {n : ℕ} (hn : 0 < n) (f : (Fin n → Bool) → Bool) :
IsWeightedThreshold f ↔ ∀ (P : (Fin n → Bool) → ℝ), IsMixedStrategy P → ∀ (x : Fin n → Bool), 0 < P x → eqPrice f P x = if f x = true then 1 else 0

Weighted threshold characterization of market-computable Boolean functions ([PennockSami2007, §26.5.5, Theorems 26.12–26.13, p. 669]): for 0 < n, f : (Fin n → Bool) → Bool is a weighted threshold function iff the equilibrium price equals f x for every common prior P and every positive-probability state x.

Examples 26.8 (OR) and 26.10 (XOR) #

theorem Cslib.GameTheory.PredictionMarket.orMarket_bids_and_eqPrice :
have f := fun (y : Fin 2 → Bool) => y 0 || y 1; have P := fun (x : Fin 2 → Bool) => 1 / 4; have x := ![false, true]; agentBid f P (priorSupport P) 0 x = 1 / 2 ∧ agentBid f P (priorSupport P) 1 x = 1 ∧ roundPrice f P (priorSupport P) x = 3 / 4 ∧ eqPrice f P x = 1

Example 26.8 ([PennockSami2007, p. 667]): two-agent OR market f(x₁, x₂) = x₁ ∨ x₂ under the uniform prior on {0, 1}² at true state x = (false, true). In round 1, agent 1 bids 1/2, agent 2 bids 1, and the clearing price is 3/4; at equilibrium, p^∞ = 1 = f x.

theorem Cslib.GameTheory.PredictionMarket.xorMarket_bids_and_eqPrice :
have f := fun (y : Fin 2 → Bool) => y 0 ^^ y 1; have P := fun (x : Fin 2 → Bool) => 1 / 4; (∀ (x : Fin 2 → Bool) (i : Fin 2), agentBid f P (priorSupport P) i x = 1 / 2) ∧ (∀ (x : Fin 2 → Bool), roundPrice f P (priorSupport P) x = 1 / 2) ∧ ∀ (x : Fin 2 → Bool), eqPrice f P x = 1 / 2 ∧ eqPrice f P x ≠ if f x = true then 1 else 0

Example 26.10 ([PennockSami2007, pp. 668–669]): two-agent XOR market f(x₁, x₂) = x₁ ⊕ x₂ under the uniform prior on {0, 1}². In round 1, every agent bids 1/2 on every state, the clearing price is 1/2, and the market immediately reaches equilibrium at p^∞ = 1/2 ≠ f x.

Two-bit XOR is not a weighted threshold function (immediate from xorMarket_bids_and_eqPrice and Theorem 26.12).

Theorem 26.14: Convergence in at Most n Rounds (§26.5.6, p. 669) #

theorem Cslib.GameTheory.PredictionMarket.convergence_in_n_rounds_of_isWeightedThreshold {n : ℕ} (hn : 0 < n) {f : (Fin n → Bool) → Bool} (hf : IsWeightedThreshold f) {P : (Fin n → Bool) → ℝ} {x : Fin n → Bool} (hx : 0 < P x) {r : ℕ} (hr : n ≤ r) :
commonKnowledge f P x r = eqSet f P x ∧ (roundPrice f P (commonKnowledge f P x r) x = if f x = true then 1 else 0) ∧ condExpect f P (commonKnowledge f P x r) = if f x = true then 1 else 0

Theorem 26.14 ([PennockSami2007, p. 669]): for any weighted threshold function f on n inputs (0 < n), any prior P, and any state x with 0 < P x, after at most n rounds of trading (r ≥ n), common knowledge Sʳ has reached equilibrium S^∞ and both the clearing price and the common-knowledge expectation equal f x.

Theorem 26.15: Worst-Case n-Round Lower Bound on 2n Inputs (§26.5.6, p. 669) #

The nested carry-chain Boolean function Cₙ : (Fin (2 * n) → Bool) → Bool [PennockSami2007, Theorem 26.15, p. 669]: C₀ = false, C_{n+1}(a, b, y) = (a ∧ b) ∨ ((a ∨ b) ∧ Cₙ(y)).

carryChain n is a weighted threshold function with exponentially decaying pair weights w(2j) = w(2j + 1) = 2^(n - 1 - j) and threshold 2^n.

noncomputable def Cslib.GameTheory.PredictionMarket.carryPrior (n : ℕ) (x : Fin (2 * n) → Bool) :

The explicit prior distribution Pₙ on {0, 1}^{2n} achieving the n-round worst-case lower bound for carryChain n [PennockSami2007, Theorem 26.15, p. 669].

carryPrior n is a valid probability distribution (IsMixedStrategy) on {0, 1}^{2n} for every n : ℕ.

Alternating 2n-bit input (true, false, true, false, …, true, false) on which carryChain n = false.

Worst-case 2n-bit input (true, false, …, true, false, true, true) on which carryChain n = true (for n > 0).

Explicit round-by-round convergence profile for (carryChain n, carryPrior n) (0 < n): for every r < n, the common-knowledge sets at carryInputFalse n (Cₙ = false) and carryInputTrue n (Cₙ = true) coincide with conditional expectation 1 / 2 and exact clearing prices 1 / 2 (for r + 1 < n) or (3n ∓ 1) / (6n) (at r = n - 1), all strictly in (0, 1); after n rounds, common knowledge reveals Cₙ and the clearing price equals Cₙ(x).

theorem Cslib.GameTheory.PredictionMarket.exists_n_round_lower_bound {n : ℕ} (hn : 0 < n) :
∃ (f : (Fin (2 * n) → Bool) → Bool) (P : (Fin (2 * n) → Bool) → ℝ) (x₀ : Fin (2 * n) → Bool) (x₁ : Fin (2 * n) → Bool), IsWeightedThreshold f ∧ IsMixedStrategy P ∧ 0 < P x₀ ∧ 0 < P x₁ ∧ f x₀ = false ∧ f x₁ = true ∧ (∀ r < n, commonKnowledge f P x₀ r = commonKnowledge f P x₁ r ∧ condExpect f P (commonKnowledge f P x₀ r) = 1 / 2 ∧ roundPrice f P (commonKnowledge f P x₀ r) x₀ ≠ 0 ∧ roundPrice f P (commonKnowledge f P x₁ r) x₁ ≠ 1) ∧ ((∀ y ∈ commonKnowledge f P x₀ n, f y = false) ∧ roundPrice f P (commonKnowledge f P x₀ n) x₀ = 0) ∧ (∀ y ∈ commonKnowledge f P x₁ n, f y = true) ∧ roundPrice f P (commonKnowledge f P x₁ n) x₁ = 1

Theorem 26.15 ([PennockSami2007, p. 669]): for every n > 0, there exist a weighted threshold function Cₙ : (Fin (2 * n) → Bool) → Bool, a prior distribution Pₙ (IsMixedStrategy Pₙ), and positive-probability states x₀, x₁ with Cₙ x₀ = false and Cₙ x₁ = true such that for every round r < n, the common-knowledge sets Sʳ(x₀) = Sʳ(x₁) do not distinguish Cₙ x₀ from Cₙ x₁ (with conditional expectation 1 / 2 and clearing prices strictly between 0 and 1), while after n rounds common knowledge reveals Cₙ and the clearing price reaches Cₙ(x).