Use Brzozowski algebraic method

Up until now I was using a dubious homegrown algorithm
(http://qntm.org/algo) to turn FSMs into regexes. This algorithm was
technically simply (1) reversing the FSM and then (2) using the
Brzozowski algebraic method. This commit replaces this unintentionally
obfuscated procedure with something which is recognisably Brzozowski's.
Some of the regexes falling out of this new implementation are a little
different but at least they read better forwards and they are certainly
technically equivalent. The new code is also a lot shorter and more
elegant, although it was a little tricky to construct at first. The
"lego" module's regex combination operators make all of this
unbelievably straightforward.