History dependent semi_lex_compare/3

The representation based comparison does this feat. Only I originally
based it on term_factorized/3, which gave me a stack overflow, so I
couldn’t complete my testing. But when I use my custom factorize/3,

even the version of the predicate that doesn’t minimize, I easily get:

?- aggregate_all(count, (between(1,1000000,_), random_cyclic(A),
random_cyclic(B), random_cyclic(C), rep_less(A,B),
    rep_less(B,C), \+ rep_less(A,C)), F).
F = 0.

The source code is here:

rep2.p.log (2,2 KB)