I don’t know whether its the same as backtracking? And
how about A \== B, is it anti-unification? Mc Cune used
inequality initiation / propagation rules in his heuristics.
Sometimes rewriting and backtracking is used in model finding.
Here is an example, first using a slow rewriter with a straight
forward dumb solving strategy resulting in ca. 7.5 seconds:
?- time(mccune([e*X=X,X^(-1)*X=e,X*(Y*Z)=(X*Y)*Z, c*d\=d*c], 6, _)).
% Zeit 7726.925 ms, GC 44.343 ms, Lips 13101 k
true
If desired I can post the full source code, its only 150
lines of Prolog. Or one can study the Mc Cune description
or sift the E-graph community for inspiration. Then using
a little faster rewriter and a unit heuristic down to ca. 150 ms:
?- time(mccune([e*X=X,X^(-1)*X=e,X*(Y*Z)=(X*Y)*Z, c*d\=d*c], 6, _)).
% Zeit 166.140 ms, GC 0.000 ms, Lips 18616 k
true
Mc Cune himself reported 0.010 seconds , so 10 ms. He has
some nice heuristics in stock, and it was implemented in
LADR Argonne. Do E-graphs have such an application
domain? In principle it is not necessary to do a full grounding,
although the result, as a model, is usually some operator tables,
which show quite some grounding. But it can also have
don’t cares, indicating model variation. With union find the
result might look differently, for example it could say 4*4-2*1
and 2*1-5 instead of 4*4-5 and 2*1-5.
The approach is different from CLP(FD), since we don’t
label variables , instead we label functions, i.e. operator tables.
So its already on the 2nd order MIL level.
P.S.: The problem input is something like:
The problem output is something lilke:
The 150 lines Prolog code produce a similar result:
?- mccune([e*X=X,X^(-1)*X=e,X*(Y*Z)=(X*Y)*Z, c*d\=d*c], 6, R).
R = [d-2, c-1, 5*2-3, 5*5-4, 4*3-2, 3*5-2, 3*2-5, 4*4-5, 2*4-3,
2*3-4, 3*4-1, 3*1-4, 5*3-1, 4*1-3, 1*5-3, 1*3-5, 2*1-5, 2*5-1,
5*1-2, 4*2-1, 1*4-2, 1*2-4, 5*0-5, 4*0-4, 4*5-0, 5^ -1-4, 5*4-0,
4^ -1-5, 3*0-3, 3*3-0, 3^ -1-3, 2*0-2, 2*2-0, 2^ -1-2, 1*0-1,
1*1-0, 1^ -1-1, 0^ -1-0, 0*5-5, 0*4-4, 0*3-3, 0*2-2,
0*1-1, 0*0-0, e-0]