Did you know ... | Search Documentation: |
Packs (add-ons) for SWI-Prolog |
Title: | Anti-unification. anti_unify/3 is intended as a relational drop-in replacement for term_subsumer/3. |
---|---|
Rating: | Not rated. Create the first rating! |
Latest version: | 0.5 |
SHA1 sum: | 62af8f6fad21f18cac05933afb2e8bf10f7af9c3 |
Author: | Geoffrey Churchill <geoffrey.a.churchill@gmail.com> |
Home page: | https://github.com/GeoffChurch/anti_unify |
Requires: | subsumes |
No reviews. Create the first review!.
Version | SHA1 | #Downloads | URL |
---|---|---|---|
0.5 | 62af8f6fad21f18cac05933afb2e8bf10f7af9c3 | 10 | http://github.com/GeoffChurch/anti_unify/archive/0.5.zip |
0.4 | 8717f53f8cfbee33ed5eee0189d72b6760468ddc | 2 | http://github.com/GeoffChurch/anti_unify/archive/0.4.zip |
0.3 | 1280ab16d86ea1d77c135f993ddef82988d30a55 | 2 | http://github.com/GeoffChurch/anti_unify/archive/0.3.zip |
0.2 | f3423581fab2d33de679a905b96370e001cc1be3 | 2 | http://github.com/GeoffChurch/anti_unify/archive/0.2.zip |
0.1 | facac8abecc670647434c5a3f15263b2ed178be8 | 2 | http://github.com/GeoffChurch/anti_unify/archive/0.1.zip |
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.
Executing the following goal from the top-level subsumes
directory should run all the tests:
?- expand_file_name("test/**.plt", Tests), maplist(consult, Tests), run_tests.
TODO: make ISO-compatible.
(Note to self) To publish a new version:
pack.pl
?- make_directory(potato), pack_install(anti_unify, [url('http://github.com/GeoffChurch/anti_unify/archive/13.17.zip'), package_directory(potato)]).
Pack contains 5 files holding a total of 5.9K bytes.