# Which rules should I define for the predicate "not_to_far" of the exercise 1.1 of the book "Simply Logical: Intelligent Reasoning by Example"?

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)

• Does it say how nearby is different from connected? Where do the different lines come from? Dec 24 '16 at 18:52
• 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 Dec 25 '16 at 14:09

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