% type definitions for PR counting system % candidates :- type candidate = atom. % posInt/string? :- type candidates = list(candidate). % ballot paper % has list of candidates - head = 1st preference :- type ballot = list(candidate). % wrap functor around ? :- type ballots = list(ballot). % parcel of ballot papers % Value of each ballot, number of ballots (redundent) % plus list of ballots :- type parcel ---> parcel(nonNeg, nonNeg, list(ballot)). :- type parcels = list(parcel). % "stack" of votes for a candidate (or exhausted) % Total value (redundent) % plus list of parcels (head = most recent) :- type stack ---> stack(candidate, nonNeg, list(parcel)). :- type stacks = list(stack). % stage of whole count % Event, % List of stacks for continuing candidates, % Stack for exhausted, % List of elected candidates' stacks not yet dealt with, % List of parcels from excluded candidate % List of candidates declared elected?? (not included) :- type stage ---> stage(event, list(stack), stack, list(stack), parcels). % list(candidate)). :- type stages = list(stage). % Events in count: % Initial stage: list of all candidates, % quota calculation (#ballots, #vacancies, quota) + % distribution of first preferences + election of candidates; % Distribution of surplus preferences for elected candidate % + election of candidates; % Exclusion of a candidate; % Distribution of preferences for excluded candidate % (done one parcel at a time) + election of candidates; % Electing remaining candidates :- type event ---> init(candidates, posInt, posInt, posInt, candidates) ; dist_surplus(candidate, candidates) ; exclusion(candidate) ; dist_excluded(candidates) ; elect_all. :- type events = list(event). % used temporarily