SWI-Prolog Did You Know Did you know? You can train markov chains with BIMS Search Documentation:
Predicate pairs_keys_values/3