Issue with a tutorial

18 views
Skip to first unread message

digamma F

unread,
Oct 15, 2018, 1:19:18 PM10/15/18
to SWI-Prolog
Hi.
I'm a total beginner in Prolog, and I'm following a tutorial. It says that :

Prolog file :


sunny.


Interactive session :

 ?- sunny.
true

 ?- snowy.
false

However, when I try it, given the same Prolog file :

 ?- sunny.
true

 ?- snowy.
ERROR: Undefined procedure: snowy/0 (DWIM could not correct goal)

Why ?

Boris Vassilev

unread,
Oct 15, 2018, 2:01:05 PM10/15/18
to digam...@gmail.com, SWI-Prolog
It must be a very outdated tutorial. As the old joke goes:

> 1972 - Alain Colmerauer designs the logic language Prolog. His goal is to create a language with the intelligence of a two year old. He proves he has reached his goal by showing a Prolog session that says "No." to every query.

Modern Prolog correctly throws an exception when a rule is not found at all.

You can implement "Negation as failure" like this:

Prolog file:

weather(sunny).

Now:

?- weather(sunny).
true.

?- weather(snowy).
false.



--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
Visit this group at https://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.

digamma F

unread,
Oct 15, 2018, 2:12:51 PM10/15/18
to SWI-Prolog
Thanks a lot !
Reply all
Reply to author
Forward
0 new messages