Re: equivalence class implementation
"baoru" <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
thanks for your reply, let's say predicate(a) is person(a) (could be anything really does not really matter), your rule resorting to the representative predicates makes sense but I am not sure if I understand the point you brought up on doing this dynamically or statically? What's the drawback of doing it dynamically? Assuming the two person is equal if they have the same name as you asked me if I know what to count as equivalent. ------------------ Original ------------------ From: "Richard A. O'Keefe"<[email protected]>; Date: Fri, Aug 9, 2013 08:56 AM To: "keowang"<[email protected]>; Cc: "swi-prolog"<[email protected]>; Subject: Re: [SWIPL] equivalence class implementation 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. -------------- next part -------------- HTML attachment scrubbed and removed