Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/tests/nofib/real/prolog/prolog.stdout

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Mini Prolog Version 1.5 (stack based)

Reading stdlib........done
> ??
append(nil,X,X).
append(cons(X,Y),Z,cons(X,W)):==append(Y,Z,W).

equals(X,X).

not(X):==X,!,false.
not(X).

or(X,Y):==X.
or(X,Y):==Y.

true.
> ?- append(cons(1,nil),cons(2,nil),X)
X = cons(1,cons(2,nil)) ;
no.
> 
> ?- append(X,Y,cons(1,cons(2,nil)))
X = nil
Y = cons(1,cons(2,nil)) ;
X = cons(1,nil)
Y = cons(2,nil) ;
X = cons(1,cons(2,nil))
Y = nil ;
no.
> 
> ?- append(cons(1,nil),cons(2,nil),cons(1,cons(2,nil)))
yes.
> ?- append(cons(1,nil),cons(2,nil),cons(1,cons(3,nil)))
no.
> parent(Child,Parent):==father(Child,Parent).
> parent(Child,Parent):==mother(Child,Parent).
> grandparent(GChild,Gparent):==parent(GChild,Parent),parent(Parent,Gparent).
> father(charles,princePhilip).
> mother(charles,theQueen).
> father(anne,princePhilip).
> mother(anne,theQueen).
> father(andrew,princePhilip).
> mother(andrew,theQueen).
> father(edward,princePhilip).
> mother(edward,theQueen).
> mother(theQueen,theQueenMother).
> father(william,charles).
> mother(william,diana).
> father(harry,charles).
> mother(harry,diana).
> ?- grandparent(X,theQueenMother)
X = charles ;
X = anne ;
X = andrew ;
X = edward ;
no.
> 
> ?- grandparent(harry,Who)
Who = princePhilip ;
Who = theQueen ;
no.
> 
> sibling(One,Tother) :== parent(One,X),parent(Tother,X).
> ?- sibling(harry,Who)
Who = william ;
Who = harry ;
Who = william ;
Who = harry ;
no.
> 
> newsib(One,Tother) :== parent(One,X),!,parent(Tother,X).
> ?- newsib(harry,Who)
Who = william ;
Who = harry ;
no.
> 
> newsib1(O,T):==parent(O,X),!,parent(T,X),not(equals(O,T)).
> ?- newsib1(harry,Who)
Who = william ;
no.
> 
> bye
Thank you and goodbye

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.