semirings
viterbi with all its quirks