7
$\begingroup$

I've just started reading a book about AI. The book is Simply Logical: Intelligent Reasoning by Example. There is a very basic exercise (on page 19 of the pdf, page 5 of the book), but I can't figure it out.

The exercise is

Exercise 1.1. Two stations are 'not too far' if they are on the same or a different line, with at most one station in between. Define rules for the predicate not_too_far.

The only rules I've seen are nearby and connected and don't know how to use this. What I've done so far is this:

not_too_far(X,Y) :- nearby(X,Y)

$\endgroup$
2
  • 1
    $\begingroup$ Does it say how nearby is different from connected? Where do the different lines come from? $\endgroup$ Dec 24, 2016 at 18:52
  • 1
    $\begingroup$ Let’s define two stations to be nearby if they are on the same line, with at most one station in between. And the are connected if are on the same line, and don't have any station in between. pag 18 you have the source image $\endgroup$
    – ihavenokia
    Dec 25, 2016 at 14:09

1 Answer 1

3
$\begingroup$

Your intuition is good. Because "nearby" is only defined with "connected", there could only be 1 station between them. However, it says that the stations are "not_too_far" if at most one station is between them. What about if no stations are between them? If 2 stations are "connected" they should be "not_too_far" as well.

So it should be:

not_too_far(X,Y) :- connected(X,Y) ; nearby(X,Y).

Where ; denotes OR.

$\endgroup$
2
  • 1
    $\begingroup$ the ";" is OR? thanks $\endgroup$
    – ihavenokia
    Dec 27, 2016 at 19:28
  • 1
    $\begingroup$ Yep, look at page 18 (32 of the pdf) $\endgroup$ Dec 27, 2016 at 19:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .