Subject: Re: How to write join(X,Y)?

From: "Richard A. O'Keefe" <[email-masked]>
Date: Tue, 7 Dec 1999 10:36:15 +1300 (NZDT)

join(X,Y)
	
	combines the two equivalence relations X and Y (which must work
	on the same number of things for this to make good sense) things
	equivalent in X remain equivalent, things that are equivalent in
	Y remain equivalent and some things become equivalent because of
	the combination of X and Y.

At first it sounded to me as though this meant

    "if X : Eqv(S) and Y: Eqv(S) then join(X,Y) : Eqv(S)
     is the least (finest) equivalence relation containing 
     both X and Y".

If that's the case, then programming it is quite straightforward
(join(X, Y) = (X + Y)*, using obvious notation) once you tell us
how the equivalence relations X and Y and the result are to be
represented.

But then came the example:

	and the following is supposed to happen :
	
	| ?- unitequiv(5,2,4,X), unitequiv(5,2,3,Y), join(X,Y).
	X = [A,B,B,B,C]
	Y = [A,B,B,B,C] ? 
	no
	
That left me _completely_ confused.  the list [A,B,B,B,C] doesn't
look like any equivalence relation representation that I can think
of (unless it is the partition {{1}, {2,3,4}, {5}}) and join is a
predicate, not a function, with no place that I can see to put the
result.

Here's a wild guess.  S is the integers 1..N for some N.
A list [X1,...,XN] represents the equivalence relation
(i equiv j if and only if Xi is the same variable as Xj).
join(X, Y) is to take two such representations and *convert*
them both to the representation of (X+Y)* by binding variables.

If that's the case, then
    unit_equiv(5, 2,4, X)	=> X = [X1,X2,X3,X2,X5]
    unit_equiv(5, 2,3, Y)	=> Y = [Y1,Y2,Y2,Y4,Y5]
and the definition
    join(X, X) :- true.
should work.  You'd get
    X1 = Y1
    X2 = Y2 = X3 = Y4
    X5 = Y5
or  X = Y = [A,B,B,B,C].

If it's not the case, I have no idea what's going on.