Documentation

Archive.Wiedijk100Theorems.BallotProblem

Ballot problem #

This file proves Theorem 30 from the 100 Theorems List.

The ballot problem asks, if in an election, candidate A receives p votes whereas candidate B receives q votes where p > q, what is the probability that candidate A is strictly ahead throughout the count. The probability of this is (p - q) / (p + q).

Main definitions #

Main result #

The set of nonempty lists of integers which suffix has positive sum.

Equations
Instances For
    theorem Ballot.staysPositive_suffix {l₁ l₂ : List ℤ} (hl₂ : l₂ ∈ staysPositive) (h : l₁ <:+ l₂) :

    countedSequence p q is the set of lists of integers for which every element is +1 or -1, there are p lots of +1 and q lots of -1.

    This represents vote sequences where candidate +1 receives p votes and candidate -1 receives q votes.

    Equations
    Instances For

      An alternative definition of countedSequence that uses List.Perm.

      theorem Ballot.mem_of_mem_countedSequence {p q : ℕ} {l : List ℤ} (hl : l ∈ countedSequence p q) {x : ℤ} (hx : x ∈ l) :
      x = 1 ∨ x = -1
      theorem Ballot.counted_eq_nil_iff {p q : ℕ} {l : List ℤ} (hl : l ∈ countedSequence p q) :
      l = [] ↔ p = 0 ∧ q = 0
      theorem Ballot.counted_ne_nil_left {p q : ℕ} (hp : p ≠ 0) {l : List ℤ} (hl : l ∈ countedSequence p q) :
      theorem Ballot.counted_ne_nil_right {p q : ℕ} (hq : q ≠ 0) {l : List ℤ} (hl : l ∈ countedSequence p q) :
      theorem Ballot.sum_of_mem_countedSequence {p q : ℕ} {l : List ℤ} (hl : l ∈ countedSequence p q) :
      l.sum = ↑p - ↑q
      theorem Ballot.first_vote_pos (p q : ℕ) :
      0 < p + q → (ProbabilityTheory.uniformOn (countedSequence p q)) {l : List ℤ | l.headI = 1} = ↑p / (↑p + ↑q)
      theorem Ballot.headI_mem_of_nonempty {α : Type u_1} [Inhabited α] {l : List α} :
      l ≠ [] → l.headI ∈ l
      theorem Ballot.first_vote_neg (p q : ℕ) (h : 0 < p + q) :
      theorem Ballot.ballot_problem' (q p : ℕ) :
      q < p → ((ProbabilityTheory.uniformOn (countedSequence p q)) staysPositive).toReal = (↑p - ↑q) / (↑p + ↑q)
      theorem Ballot.ballot_problem (q p : ℕ) :
      q < p → (ProbabilityTheory.uniformOn (countedSequence p q)) staysPositive = (↑p - ↑q) / (↑p + ↑q)

      The ballot problem.