| Did you know ... | Search Documentation: |
| Pack anti_unify -- README.md |
Relational anti-unification for SWI-Prolog
anti_unify/3 is intended as a relational drop-in replacement for term_subsumer/3. It can handle cyclic data, as well as cases where cyclic data would be induced.
?- anti_unify(X, Y, f(P, Q)). X = f(_XP, _XQ), Y = f(_YP, _YQ), anti_unify(_XP, _YP, P), maplist(subsumes(P), [_XP, _YP]), anti_unify(_XQ, _YQ, Q), maplist(subsumes(Q), [_XQ, _YQ]). ?- anti_unify(X, Y, Z), Z = f(Y). % Example with induced cyclic data. X = Y, Y = Z, Z = f(Z). ?- anti_unify(X, Y, Z), Z = g(_). X = g(_A), Y = g(_B), Z = g(_C), anti_unify(_A, _B, _C), maplist(subsumes(_C), [_A, _B]).
See the unit tests in [test/anti_unify.plt](test/anti_unify.plt) for more examples.
?- pack_install(anti_unify).
Executing the following goal from the top-level anti_unify directory should run all the tests:
?- consult("test/*.plt"), run_tests.
(Note to self) To publish a new version:
pack.pl
swipl -g "make_directory(temp), pack_install(anti_unify, [url('https://github.com/GeoffChurch/anti_unify/archive/0.5.zip'), pack_directory(temp), interactive(false)]), delete_directory_and_contents(temp)" -t halt