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 #
counted_sequence: given natural numberspandq,counted_sequence p qis the set of all lists containingpof1s andqof-1s representing the votes of candidate A and B respectively.stays_positive: is the set of lists of integers which suffix has positive sum. In particular, the intersection of this set withcounted_sequenceis the set of lists where candidate A is strictly ahead.
Main result #
ballot: the ballot problem.
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.
An alternative definition of counted_sequence that uses list.perm.
The ballot problem.