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

From: alexandra romantseva <[email-masked]>
Date: Sun, 05 Dec 1999 22:41:43 -0500

Hello!

I was wondering if anyone can PLEASE help me write a definition for
join(X,Y). 
I need join(X,Y) join the two equivalence relations X and Y, so that
positions equivalent 
whenever either of X or Y become then equivalent.  
For example join(X,Y) where X is [1,2,1,3,4,5,6] and Y is [1,2,2,3,4,5,6]
should return [1,1,1,2,3,4,5].

I have the following definitions:

max(X, Y, X) :- X >= Y.
max(X, Y, Y) :- Y >= X.
min(X, Y, X) :- Y >= X.
min(X, Y, Y) :- X >= Y.

instequivclassesn([], M, N).

instequivclassesn([M | R], M, N) :-
   M > 0, P is M+1, max(P,N,Q), instequivclassesn(R, Q, Q).

instequivclassesn([X | R], M, N) :-
   M > 1, P is M-1, instequivclassesn([X | R], P, N).

instequivclasses(X) :- instequivclassesn(X, 1, 1).

trivequiv(0, []).

trivequiv(N, [X | R]) :- N > 0, P is N-1, min(P,N,Q), trivequiv(Q, R).

insert(1, X, Y, [X | Y]).

insert(I, X, [Y | R], [Y | Z]) :- P is I-1, min(P,I,Q), insert(Q,X,R,Z).

unitequiv(N, I, J, X) :-

	N > 1, I =\= J, P=N-1, min(P,N,Q), trivequiv(Q,Z), 
	insert(J,I,Z,X).

join(. . . ).

	Thank You, 
	Alexandra
-----------------------------------------------------
Click here for Free Video!!
http://www.gohip.com/freevideo/