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

From: alexandra romantseva <[email-masked]>
Date: Mon, 06 Dec 1999 06:55:36 -0500

I'm still trying to compose a definition for join(X,Y).

here is an example of how join(X,Y) should work...

unitequiv(7,3,6,X), unitequiv(7,2,6,Y), join(X,Y), instequivclasses(X).

should have a first return of X = [1,2,2,3,4,2,5] and Y=[1,2,2,3,4,2,5]

where the following definitions apply: 
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).

	Sasha
-----------------------------------------------------
Click here for Free Video!!
http://www.gohip.com/freevideo/