From arunm@genumerix.com  Mon Dec  6 23:41:11 1999
Received: from field.videotron.net (field.videotron.net [205.151.222.108])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id XAA27593
	for <prolog@swi.psy.uva.nl>; Mon, 6 Dec 1999 23:41:10 +0100 (MET)
Received: from arun ([24.200.86.113]) by field.videotron.net (Sun Internet Mail Server sims.3.5.1999.07.30.00.05.p8)
 with SMTP id <0FMC002RAC3W6B@field.videotron.net> for prolog@swi.psy.uva.nl; Mon,  6 Dec 1999 17:35:57 -0500 (EST)
Date: Mon, 06 Dec 1999 17:43:38 -0500
From: "Arun Majumdar (Genumerix)" <arunm@genumerix.com>
Subject: Fw: How to write join(X,Y)?
To: prolog@swi.psy.uva.nl
Reply-to: "Arun Majumdar (Genumerix)" <arunm@genumerix.com>
Message-id: <008701bf403b$56abefe0$7156c818@videotron.ca>
MIME-version: 1.0
X-Mailer: Microsoft Outlook Express 5.00.2314.1300
Content-type: text/plain; charset=utf-7
Content-transfer-encoding: 7bit
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
X-Priority: 3


----- Original Message -----
From: Arun Majumdar (Genumerix) +ADw-arunm+AEA-genumerix.com+AD4-
To: alexandra romantseva +ADw-afromant+AEA-midway.uchicago.edu+AD4-
Sent: Monday, December 06, 1999 11:16 AM
Subject: Re: How to write join(X,Y)?


+AD4- Hi,
+AD4-
+AD4- I read your previous email, and this one.  Peter is right, others such as
+AD4- myself are unclear.  Perhaps these comments will help you.
+AD4-
+AD4- Firstly, when I look at your prolog code and what you've written, ex: two
+AD4- lists of X and Y because they refer to two identical sets of unnamed
+AD4- variables, presumably generated by join, then you would not get no for an
+AD4- answer, because two +ACI-empty+ACI- or anonymouse sets would always be equivalent:
+AD4- ie, they are equivalent in not knowing anything. This I gather by your
+AD4- trivequiv(0, +AFsAXQ-) predicate: the answer given is that empty set is +ACI-zero+ACI-
not
+AD4- +ACI-fail+ACI-, so empty sets are equivalents to zero...therefore, two empty sets
+AD4- are equivalent. Here I assume you want to use the word +ACI-set+ACI- in place of
+AD4- using the word +ACI-list+ACI- which properly defines the data structure you are
+AD4- using for your representation.
+AD4-
+AD4- Second, the idea you are asking of equivalence relations is not what you
+AD4- have written in the actual code. What you have is a selective numeric
+AD4- mapping relation defined on set elements of integers. Your mapping
relation,
+AD4- therefore, can be more efficiently written without all the other clauses.
+AD4- Try to use a top-down approach in writing your prolog code, then put in
all
+AD4- the other clauses. Example of top-down (here you can define all the
clauses
+AD4- such as listlength, or, better still, refer to the ISO standard
+AD4- predicates...)
+AD4-
+AD4- join(X, Y) :-
+AD4-                    islist(X), islist(Y),        +ACU-remember to comment your
+AD4- code, check if we have lists
+AD4-                    listlength(X,FirstListLength),
+AD4-                    listlength(Y,SecondListLength),    +ACU-get list lengths
+AD4-                    ifequal(FirstListlength, SecondListLength), +ACU-if lengths
+AD4- are equal, then continue, else fail,
+AD4-                    if+AF8-elements+AF8-of+AF8-list+AF8-equiv( X, Y, ResultList),
+ACU-recursive
+AD4- and keep your conditions here
+AD4-                    write(ResultList), +ACU-Here is where you are +ACI-returning+ACI-
the
+AD4- result
+AD4-                     nl.            +ACU-new line
+AD4-
+AD4- So, that's a top-down view, with your conditions that the lengths of lists
+AD4- must be equal. An excellent book to look at that will help you code is
+AD4- called +ACI-Clause and Effect+ACI- by Clocksin.  You will learn all about these
+AD4- types of mappings in that book.
+AD4-
+AD4- Also, try to get rid of the idea of using the word +ACI-returns+ACI- a result
+AD4- because prolog does not work as, for example, C language where results are
+AD4- returned by a function call: results are always instantiated into the
+AD4- variables that act as named places for your results. The intrinsic idea of
+AD4- returning results may impede your prolog style. Therefore, more properly,
we
+AD4- could write join(X, Y, ResultList) as a better predicate definition than
+AD4- just join(X,Y).
+AD4-
+AD4- I suggest that for +ACI-homework+ACI- type stuff, as this looks like homework to
me,
+AD4- that you try to draw a small SLD for say, two or three element lists. I
also
+AD4- suggest that you comment your code at a high-level, in a top-down
approach:
+AD4- your definition of join, becomes evident through the top-down view of the
+AD4- code, which prolog as as a language was designed for.
+AD4-
+AD4- Also, strictly speaking, your use of the terms +ACI-equivalence relation+ACI- is
+AD4- what is confusing: a relation is a complex data structure and an
equivalence
+AD4- relation between two such complex structures is a bisimilarity: one
+AD4- structure seen as another structure by some mapping that you define, that
+AD4- makes them appear equivalent to you.  If this is what you mean, then what
+AD4- you have written is not that at all.
+AD4-
+AD4- In SWI prolog, you can use the apropos(X) to get information on an ISO
+AD4- predicate, or you can call on +ACI-help.+ACI-  to launch the XPCE based help
system.
+AD4- There is a lot of valuable information in the defintion of predicates and
I
+AD4- suggest that for predicates like max, min etc.. that you look them up
under
+AD4- SWI prolog's very complete online help system --- then, in your comments,
+AD4- you can just put a reference to SWI defintions...it makes it easier for
the
+AD4- rest of us because otherwise it looks as if your are
+AD4- re-defining a system predicate.
+AD4-
+AD4- I hope that my comments will help you resolve the issue without giving you
+AD4- the answer directly, tempting as it is to just write you an answer.
+AD4- Remember this proverb:
+AD4-
+AD4- +ADwAPA- Tell me and I will forget, Show me and I may remember, Involve me and I
+AD4- will Understand +AD4APg-
+AD4-
+AD4- Cheers,
+AD4-
+AD4- Arun Majumdar,
+AD4- CEO, Genumerix Inc,
+AD4- www.genumerix.com
+AD4-
+AD4-
+AD4-
+AD4- ----- Original Message -----
+AD4- From: alexandra romantseva +ADw-afromant+AEA-midway.uchicago.edu+AD4-
+AD4- To: Peter Mott +ADw-pmott+AEA-scs.leeds.ac.uk+AD4AOw- +ADw-prolog+AEA-swi.psy.uva.nl+AD4-
+AD4- Sent: Monday, December 06, 1999 7:36 AM
+AD4- Subject: Re: How to write join(X,Y)?
+AD4-
+AD4-
+AD4- +AD4- join(X,Y)
+AD4- +AD4-
+AD4- +AD4- combines the two equivalence relations X and Y (which must work on the
+AD4- same
+AD4- +AD4- number of things for this to make good sense)
+AD4- +AD4- things equivalent in X remain equivalent,
+AD4- +AD4- things that are equivalent in Y remain equivalent
+AD4- +AD4- and some things become equivalent because of the combination of X and Y.
+AD4- +AD4-
+AD4- +AD4- and the following is supposed to happen :
+AD4- +AD4-
+AD4- +AD4- +AHw- ?- unitequiv(5,2,4,X), unitequiv(5,2,3,Y), join(X,Y).
+AD4- +AD4- X +AD0- +AFs-A,B,B,B,C+AF0-
+AD4- +AD4- Y +AD0- +AFs-A,B,B,B,C+AF0- ?
+AD4- +AD4- no
+AD4- +AD4-
+AD4- +AD4- Sorry for bein unclear.  Hope this is helpful.
+AD4- +AD4-
+AD4- +AD4-
+AD4- +AD4-
+AD4- +AD4- Sasha
+AD4- +AD4-
+AD4- +AD4-
+AD4- +AD4-
+AD4- +AD4- +AD4-Sasha,
+AD4- +AD4- +AD4-
+AD4- +AD4- +AD4-I don't understand the operation join(X,Y). What is its formal
+AD4- definition?
+AD4- +AD4- +AD4-Maybe other people had this problem too :-).
+AD4- +AD4- +AD4-
+AD4- +AD4- +AD4-Peter
+AD4- +AD4- +AD4APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQ-
+AD4- +AD4- +AD4-Peter Mott                             Tel:  (0)113 233 5323
+AD4- +AD4- +AD4-School Of Computer Studies                     Fax:  (0)113 233 5468
+AD4- +AD4- +AD4-University of Leeds, Leeds LS2 9JT             Office:  (0)113 233 5430
+AD4- +AD4- +AD4-URL http://csis1.leeds.ac.uk/pmott.htm
+AD4- +AD4- +AD4-
+AD4- +AD4- -----------------------------------------------------
+AD4- +AD4- Click here for Free Video+ACEAIQ-
+AD4- +AD4- http://www.gohip.com/freevideo/
+AD4- +AD4-
+AD4- +AD4-
+AD4- +AD4- ----------------
+AD4- +AD4- +ACo- To UNSUBSCRIBE, please use the HTML form at
+AD4- +AD4-
+AD4- +AD4-     http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html+ACM-mailinglist
+AD4- +AD4-
+AD4- +AD4- or send mail to prolog-request+AEA-swi.psy.uva.nl using the Subject:
+AD4- +ACI-unsubscribe+ACI-
+AD4- +AD4- (without the quotes) and +ACo-no+ACo- message body.
+AD4- +AD4-
+AD4- +AD4- +ACoAKg- An ARCHIVE of this list is maintained at
+AD4- +AD4-
+AD4- +AD4-     http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/
+AD4-

