mathlib3 documentation

mathlib-archive / wiedijk_100_theorems.ballot_problem

Ballot problem #

THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.

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

counted_sequence 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

An alternative definition of counted_sequence that uses list.perm.

theorem ballot.mem_of_mem_counted_sequence {p q : } {l : list } (hl : l ballot.counted_sequence p q) {x : } (hx : x l) :
x = 1 x = -1
theorem ballot.counted_eq_nil_iff {p q : } {l : list } (hl : l ballot.counted_sequence p q) :
l = list.nil p = 0 q = 0
theorem ballot.counted_ne_nil_left {p q : } (hp : p 0) {l : list } (hl : l ballot.counted_sequence p q) :
theorem ballot.counted_ne_nil_right {p q : } (hq : q 0) {l : list } (hl : l ballot.counted_sequence p q) :
theorem ballot.head_mem_of_nonempty {α : Type u_1} [inhabited α] {l : list α} (hl : l list.nil) :
l.head l