From afromant@midway.uchicago.edu  Mon Dec  6 05:40:23 1999
Received: from midway.uchicago.edu (midway.uchicago.edu [128.135.12.12])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id FAA27140
	for <prolog@swi.psy.uva.nl>; Mon, 6 Dec 1999 05:40:23 +0100 (MET)
Received: from harper.uchicago.edu (root@harper.uchicago.edu [128.135.12.7])
	by midway.uchicago.edu (8.9.3/8.9.3) with ESMTP id WAA26486
	for <prolog@swi.psy.uva.nl>; Sun, 5 Dec 1999 22:40:23 -0600 (CST)
Received: from equality-7-2524 (pierce-175-003.rh.uchicago.edu [128.135.175.3])
	by harper.uchicago.edu (8.9.3/8.9.3) with SMTP id WAA13027
	for <prolog@swi.psy.uva.nl>; Sun, 5 Dec 1999 22:40:21 -0600 (CST)
Message-Id: <199912060440.WAA13027@harper.uchicago.edu>
X-Sender: afromant@nsit-popmail.uchicago.edu
X-Mailer: QUALCOMM Windows Eudora Pro Version 4.0.1 
Date: Sun, 05 Dec 1999 22:41:43 -0500
To: <prolog@swi.psy.uva.nl>
From: alexandra romantseva <afromant@midway.uchicago.edu>
Subject: How to write join(X,Y)??
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"

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/

