Re: equivalence class implementation
"Richard A. O'Keefe" <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 8/08/2013, at 1:49 PM, baoRu wrote:
> Hi All:
>
>
> I am trying to work around transitive equivalence definition in my reasoning engine meaning suppose I have two following facts
> equal(predicate(a),predicate(b)).
> equal(predicate(a),predicate(c)).
It's really not very clear what you mean here; the word 'predicate'
is rather worrying since it suggests that you may be intending to
state connections between Prolog predicates. (Which could be a nice
idea, indeed the MECHO project at Edinburgh did something very like
this in their inference engine, but it applied to the object language,
not to Prolog -- which was their metalanguage.)
Do not state general equivalences, but map terms to *representatives*
of their equivalence classes, so that two terms are to be regarded as
equivalent when and only when they have the same representative.
equivalent(T1, T2) :-
representative(T1, Rep),
representative(T2, Rep).
If you _must_ do this dynamically, see any good data structures and
algorithms book for 'Union/Find' (or see The Craft of Prolog...).
The key question is whether you must do this dynamically or can do
it statically, and that is not about Prolog, but about when you *know*
what to count as equivalent.