Subject: RE: UNDERSTANDING LISTS

From: andrew <[email-masked]>
Date: Wed, 3 May 2000 15:05:13 +0300

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