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 #
countedSequence: given natural numberspandq,countedSequence p qis the set of all lists containingpof1s andqof-1s representing the votes of candidate A and B respectively.staysPositive: is the set of lists of integers which suffix has positive sum. In particular, the intersection of this set withcountedSequenceis the set of lists where candidate A is strictly ahead.
Main result #
ballot_problem: the ballot problem.
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.
@[simp]
theorem Ballot.length_of_mem_countedSequence {p q : ℕ} {l : List ℤ} (hl : l ∈ countedSequence p q) :
theorem Ballot.counted_succ_succ (p q : ℕ) :
countedSequence (p + 1) (q + 1) = List.cons 1 '' countedSequence p (q + 1) ∪ List.cons (-1) '' countedSequence (p + 1) q
theorem Ballot.disjoint_bits (p q : ℕ) :
Disjoint (List.cons 1 '' countedSequence p (q + 1)) (List.cons (-1) '' countedSequence (p + 1) q)
@[instance_reducible]
Equations
Instances For
theorem Ballot.ballot_pos (p q : ℕ) :
(ProbabilityTheory.uniformOn (countedSequence (p + 1) (q + 1) ∩ {l : List ℤ | l.headI = 1})) staysPositive = (ProbabilityTheory.uniformOn (countedSequence p (q + 1))) staysPositive
theorem Ballot.ballot_neg (p q : ℕ) (qp : q < p) :
(ProbabilityTheory.uniformOn (countedSequence (p + 1) (q + 1) ∩ {l : List ℤ | l.headI = 1}ᶜ)) staysPositive = (ProbabilityTheory.uniformOn (countedSequence (p + 1) q)) staysPositive
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.