General
Material
Lecture 1
Lecture 2
Lecture 3
Lecture 4
Lecture 5

Finding paths through a maze

Imagine that the following knowledge base describes a maze. The facts determine which points are connected, i.e., from which point you can get to which other point in one step. Furthermore, imagine that all paths are one-way streets, so that you can only walk them in one direction. So, you can get from point 1 to point 2, but not the other way round.

connected(1,2).
connected(3,4).
connected(5,6).
connected(7,8).
connected(9,10).
connected(12,13).
connected(13,14).
connected(15,16).
connected(17,18).
connected(19,20).
connected(4,1).
connected(6,3).
connected(4,7).
connected(6,11).
connected(14,9).
connected(11,15).
connected(16,12).
connected(14,17).
connected(16,19).
    
Download knowledge base here.

Write a predicate path/2 that tells you from which point in the maze you can get to which other point when chaining together connections given in the above knowledge base.
Hint

Now ask some queries. Can you get from point 5 to point 10? Which other point can you get to when starting in point 1? And which points can be reached from point 13?

Back to the practical session of day 2.