Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news.harvard.edu!news2.near.net!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!EU.net!sun4nl!knowar!ocean.knoware.nl!snowlion
From: snowlion@knoware.nl (Maarten van den Dungen)
Subject: Re: Silly getting started question.
Sender: news@knoware.nl (News Account)
Message-ID: <snowlion.2.000E6C82@knoware.nl>
Date: Fri, 2 Sep 1994 19:25:20 GMT
Lines: 67
References:  <oneel.778454044@athena>
Nntp-Posting-Host: ocean.knoware.nl
Organization: Knoware Nederland
X-Newsreader: Trumpet for Windows [Version 1.0 Rev A]


>Hi,
>  I have a very silly getting started question.  I checked Clocksin
>and Mellish Programming in Prolog out of the library, FTP'd SWI-Prolog
>and built it on my sun.  Now I'm looking at C&M and am a bit lost.

>On page 7 there are a set of rules:

>likes(john,flowers).
>likes(john,mary).
>likes(paul,mary).

>?- likes(john,X).

>and prolog returns something like
>X=flowers

>Now, when I type the following into SWI-Prolog I get...

>Welcome to SWI-Prolog (Version 1.9.0 June 1994)
>Copyright (c) 1993,1994 University of Amsterdam.  All rights reserved.
> 
>1 ?- likes(john,flowers).
>[WARNING: Undefined predicate: `likes/2']
> 
>No
>2 ?- likes(john,X).
>[WARNING: Undefined predicate: `likes/2']
> 
>No
>3 ?- 

>Now, I suspect that part of the problem is the ?- at the beginnings of
>the lines.  I'm unclear how to proceed.  I did look at the documents
>which came with SWI-Prolog but I must have missed the critical bit.
>Most of the documents seemed to cover SWI-Prolog specifics.

>Thanks very much for any help!

>bruce
>--


Hi,

I don't know anything about SWI-prolog, but at start-up your prolog-engine is usually in 'query'-
mode, which means it expects a query into its database. So your quite right that the '?-' is the 
problem. At start-up your database is virtually empty, which means you can only question it on its 
build-in predicates and 'likes' is not a build-in. 
There are, however, several ways to learn your database knew things:
You can read in a term and 'assert' it to your database, e.g.:
?- read(T), assert(T). <ret> 
: likes(john, books). <ret>
and them make suitable queries like ?- likes(john, What). <ret> . 
(When you enter this, you will see the cursor change to ':' and back to '?-'. )
The other way is to consult either the 'user' (yourself) or an existing file, the latter option is most 
suited for larger programs. If you consult the user you'll have to type either 'end_of_file.' <ret> or 
cntrl-D to get back in query-mode.E.g.:
?- consult(user). <ret>
: likes(john, books). <ret.
: end_of_file. <ret>


Good luck.



