# IRV Prime

IRV Prime is a voting method variation of instant-runoff voting (classic IRV) developed by Marcos Boyington that selects a single winner using votes that express each voter's order of preference, like IRV. It is a generalization of Condorcet IRV that works when there is no Condorcet winner.

Classic IRV eliminates candidates which had a chance of winning the election while preserving candidates that will lose. IRV Prime finds every candidate which has a chance of winning (candidates in the Schwartz set) & eliminates candidates we know won't win (those losing in the final round).

## Procedure

1. Find the instant-runoff voting (IRV) winners using the classic/standard rounds, where the candidate with least votes is eliminated & their votes redistributed (call this set Winners)
2. Find the candidates which satisfy the Schwartz set
3. Re-run the IRV election once for each candidate in the Schwartz set, preserving that candidate as well as all candidates in Winners set; each candidate in the Schwartz set which defeats one of the Winners is added to the Winners-Prime set.
4. Re-run the IRV election preserving all Winners and all Winners-Prime, proceeding with normal elimination when they are all that remain

Note that using the Schwartz set is simply to reduce the number of rounds; the results are the same if the set of all candidates or the Smith set is used instead.

### Algorithm

``` GetWinner(NumWinners, PrefSchedule)
{
// Step 1: Classic IRV, find classic winners
RemainingCandidates = PrefSchedule
while (RemainingCandidates.Length > NumWinners) {
RemainingCandidates = RemainingCandidates.EliminateLeast()
}
Winners = RemainingCandidates.TopCandidates(NumWinners)

// Step 2: Build round where only candidates remaining are
// classic winners & schwartz set
PrefMatrix = getPreferenceMatrix(PrefSchedule)
SchwartzSet = getSchwartz(PrefMatrix)
Keepers = union(Winners, SchwartzSet)
PrimeRound = PrefSchedule.EliminateAllExcept(Keepers)

// Step 3: Find candidates who can win against classic winners
WinnersPrime = {}
for (S in SchwartzSet) {
Keepers = union(S, Winners)
PossibleWinner = PrimeRound.EliminateAllExcept(Keepers)
WinnersPrime = union(WinnersPrime, PossibleWinner.TopCandidates(1))
}

// Step 4: Run final round from prime round eliminating all who
// lose against classic winners
RemainingCandidates = PrimeRound.EliminateAllExcept(union(Winners, WinnersPrime))
while (RemainingCandidates.Length > NumWinners) {
RemainingCandidates = RemainingCandidates.EliminateLeast()
}

return RemainingCandidates.TopCandidates(NumWinners)
}
```

## Proof of failing later-no-harm

```102 A
101 B
100 C
5 A>B>C
5 B>C>A
5 C>A>B
```

A wins IRV (after C is eliminated) The Schwarz set is {ABC} A wins AB. C wins AC. So, WinnersPrime is {AC}. C wins {AC} Thus, C is overall winner.

....

Now, some C voters add a later preference:

```102 A
101 B
100 C>B
5 A>B>C
5 B>C>A
5 C>A>B
```

B wins IRV (after C is eliminated). The Schwarz set is B. So B wins overall. This violates later-no-harm.

## An example

Imagine the following vote preferences:

Vote Preference
L, CR 47
R, CR 39
R 5
CR, R 5

Resulting in the following preference matrix:

Preference Matrix
Candidate Preference R CR L
R over 39 45
CR over 52 44
L over 47 47

In instant-runoff voting, R is elected as CR is eliminated:

Last Round IRV
R 49
L 47

In RCV Prime, because L does not end up in Winners-Prime but CR does, the final round instead looks like:

Last Round IRV
CR 52
R 49

And CR wins with a larger majority than the candidate that would win with IRV

## Strategy

Voters are left with only a single honest rank strategy to best serve their favorite candidate while minimizing the possibility of getting a less preferred candidate:

``` 1-3) Favorite candidates
4) Favorite frontrunner (if not already covered in 1-3)
5) Least-hated who is a frontrunner with opposing views
```

This voting strategy guarantees that a voter's favorite candidate will win if they are preferred by the largest number of voters; it also guarantees that if those candidates cannot win (do not have the largest number of voters), that a preferred candidate will win as long as they have the largest number of voters.