Is there a way to formalize election methods as code?

In other words, a way to specify the rules of the method mathematically so that its criterion compliance properties etc. could be derived automatically?

I think this is the sort of work you are looking for

@psephomancy, that’s exactly what I tried to do when I created Electowidget back in 2005. The code is old, but as Joel Spolsky famously put it, old code doesn’t rust. The caveat he made:

Old code has been used . It has been tested . Lots of bugs have been found, and they’ve been fixed .

Well, he didn’t phrase it like a caveat, but it’s still important. Electowidget didn’t get used very much. I wasn’t very good about unit tests (it was 2005 after all… testing is for sissies!). That code is written in PHP4, not in PHP5 or in Python or in Rust (see what I did there? Get it? Get it??? :smiley: … ok, forget I made that joke…). I think my software design wasn’t too embarrassing, but it does have a lot of object-oriented inheritance going on. The design is pretty dated, and the code didn’t take the world by storm. Electowidget didn’t have all of the real-world usage that Spolsky was talking about when he complained about Netscape abandoning the old Netscape Navigator code. Electowidget might be worth porting to a modern programming language (like PHP7 or Hack), but now may not be the time to resurrect zombie Electowidget.

Wayyyyyy back in the day, I was a member of the W3C QA group, when it was just getting started. One of the things that I found really exciting was the idea of having conformance suites for all of the recommendations we were writing. But when I was involved in the W3C QA group, I wasn’t managing a QA team anymore, so I kinda drifted away. Still, I had my first experience with “test driven development” (TDD) was when I wrote svg2swf as a hobby project in 2001. I suspect the W3C’s SVG test suite is a big reason for SVG’s success today. I’d bee more optimistic about a codebase that has had more recent use.

I think a good test suite for testing election methods implementations would be a huge step forward. I might be willing to work on something like that. We should start a page up on Electowiki about (e.g. I may create if someone doesn’t beat me to the punch).

Is it? That page says it’s for “conducting Internet polls and elections” which is definitely not what I mean. I mean something like a …

This is kind of a loose analogy, I guess, but on OEIS, many entries have a “PROG” section, in which there are concise programs that can generate the sequence, like a(n)=if(n<1, 0, sumdiv(n, d, !isprime(d)*d)) for

So I’m thinking of some way like this to specify the rules of a voting method such that it is unambiguously fully-defined, and a computer program can take that representation as input and then tell you automatically if it’s Condorcet compliant, etc. Maybe related to

Maybe this doesn’t even make sense. I don’t know.

I’m sort of thinking of this for things like automatic infobox generation for Electowiki, but also things like “automatically generate many different voting rules and train AIs to vote strategically using them and see which ones have the highest Social Utility Efficiency while resisting strategy” and other crazy stuff like that.

@psephomancy wrote: “That page says it’s for “conducting Internet polls and elections” which is definitely not what I mean.”

You may be reading the marketing material for my 0.1 version of Electowidget too literally. My personal goal with Electowidget was to create something that participants of the election-methods-list could use to debate election methods. I tried to make it really general to implement as many election systems as I could. Unfortunately, I fear that I over-architected the silly thing, and I marketed it to the wrong audience.

It was intended to be a replacement for my 1996 “” perl script, which was (in relative terms) a thing of beautiful simplicity. It was my first significant object-oriented program, but I didn’t know enough about OO programming to shoot too many toes off my foot (so to speak).

Anyway, my original script was a huge success (I think it’s the foundation of the script that the Debian project uses for their leader elections). More later…

1 Like

Sounds like a pretty high level of AI, maybe beyond what has been achieved to date. Sure you can code up voting systems so they can be executed against example data, but analysis is harder than mere execution.

FWIW, I have some code as web pages: irvtest.htm has links to a multi-winner page on the lower right and to Approval, Score, and STAR in lower center. Cntl/U on many browsers displays the source code.

1 Like

A possible social benefit of describing electoral regimes using code in addition to describing them in natural language would be that code is less ambiguous. Sometimes in this discussion forum, one person tries to describe/prescribe an electoral regime and another person responds by saying “I don’t understand what you wrote”. Code would disambiguate.

1 Like