From andrew@microspec.co.il  Wed May  3 14:05:17 2000
Received: from server.microspec.co.il ([192.114.86.34])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id OAA07054
	for <prolog@swi.psy.uva.nl>; Wed, 3 May 2000 14:05:15 +0200 (MET DST)
Received: by SERVER with Internet Mail Service (5.5.2650.21)
	id <KB899ZX4>; Wed, 3 May 2000 15:05:18 +0300
Message-ID: <E0BD9133A887D211A35E0020AFB694460F560B@SERVER>
From: andrew <andrew@microspec.co.il>
To: "'Richard A. O'Keefe'" <ok@atlas.otago.ac.nz>,
        andrew
	 <andrew@microspec.co.il>, ino-waiting@gmx.net
Cc: prolog@swi.psy.uva.nl
Subject: RE: UNDERSTANDING LISTS
Date: Wed, 3 May 2000 15:05:13 +0300 
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)
Content-Type: text/plain;
	charset="iso-8859-1"

Examples:

1) NL reasoning

	%Goal:
where is new york? in R..             	

	% Inference rules:
who is X? R :- X is R..
where is X? in R :- X is situated in R..     		            

	% Factual knowledge:
joe is son of maria and peter..
julia is daughter of maria and peter..                        
peter 2 is son of maria and peter 1..                         
jack 2 is son of julia and jack 1..                           
new york is situated in america..                             
st.petersburg is situated in russia..                         
a book is situated on a table..                               

	% Output:
where is new york? in america..






2) Logic Formula Transformation

	%Goal:
according to the rule R, the result of shifting quantifiers in formula 
( for-all x 0 ) [a ( x 0 , y )] or ( for-all x 0 ) [b ( x 0 , t )] 
is formula W..

	% Program. Main clause:
according to the rule 2a from chapter 5, the result of shifting quantifiers
in formula 
( Q X ) [F] or ( Q X ) [H] 
is formula ( Q X ) ( Q Z ) ( [F] or [G] ) :- 
	X is notation for variables ,, 
	Z is notation for variables ,, 
	formula F does not contain variable Z ,, 
	the result of replacing X by Z in formula [ H ] is formula [ G ] ..


	% Definition of the variables for this  logic calculus
x 0 is notation for variables ..
X 1 0 is notation for variables :- 
	X 0 is notation for variables ..


	% Strighforward explanation what is 
	% "does not contain" and "contains" :
formula F does not contain variable Z :- ~~word F contains word Z ..
word _ X _ contains word X ..


	% Definition of the algorithm for replacing variables 
	% in logic formulae:
the result of replacing X by Y in formula [ A X M ] is formula [ A Y N ] :- 
	the result of replacing X by Y in formula [ M ] is formula [ N ] ..

the result of replacing X by Y in formula [ A ] is formula [ A ] :-
	formula A does not contain variable X..

	% Output:
according to the rule 2a from chapter 5, 
the result of shifting quantifiers in formula 
( for-all x 0 ) [a ( x 0 , y )] or ( for-all x 0 ) [b ( x 0 , t )] 
is formula 
( for-all x 0 ) ( for-all x 1 0 ) ( [a ( x 0 , y )] or [b ( x 1 0 , t )] )






3) Logic formula transformation (another version of (2))

	% Goal (variable W stands for the resulting formula):
( for-all x 0 ) [a ( x 0 , y )] or ( for-all x 0 ) [b ( x 0 , t )]  --> W..


	% Program. 
( Q X ) [F] or ( Q X ) [H] --> ( Q X ) ( Q Z ) ( [F] or [G] ) :- 
	[X is variable] ,, 
	[Z is variable] ,, 
	~~[F contains Z] ,, 
	[ Z / X ] [ H ] = [ G ] .. 

[x 0 is variable] ..	
[X 1 0 is variable] :- [X 0 is variable] ..

[_ X _ contains X] ..

[ Y / X ] [ A X M ] = [ A Y N ] :- [ Y / X ] [ M ] = [ N ] ..	
[ Y / X ] [ A ] = [ A ] :- ~~[A contains X]..

	% Output:
( for-all x 0 ) [a ( x 0 , y )] or ( for-all x 0 ) [b ( x 0 , t )]  -->
( for-all x 0 ) ( for-all x 1 0 ) ( [a ( x 0 , y )] or [b ( x 1 0 , t )] )



(details see in http:\\sampletalk.8m.com ).



All 3 examples are working programs built from LISTS
(formed from real reasoning examples).

1) They are (to a reasonable extent) in Prolog style.
2) They contain THOROUGH definitions of the corresponding
algorithms (of parsing, inference, logic calculus etc) and data
3) Adding additional facts (in NL or other relevant form)
and new reasoning rules is very easy: just take an example,
generalize it, and include.

I guess that Prolog equivalents of such programs would be
at least 10 times longer: you can not define interaction 
of these objecs (here: lists) without numerous append/3's
or other tricks.

Moreover, I am not sure properties (2) and (3) can be implemented
-together- in ANY language without MATCHING LISTS

