More Simply Logical lab exercises chapter 3

The Prolog file to be used for these lab exercises is

  1. The well-known 8-puzzle consists of 8 tiles and an empty space, organised in a square. A move consists in sliding a tile to the empty space. The objective is to reach the following position:
       1 2 3
       8   4
       7 6 5
    Such a position will be represented by a list
    with the first pair denoting the coordinates of the empty space, X1/Y1 denoting the coordinates of tile 1, and so on. Coordinates 1/1 refer to the lower left square. The position above is thus represented by the list

  2. The predicate prove_e(Goal,Explanation) returns an explanation with the answer to a query:
    | ?- prove_e(student_of(S,T),Explanation).
    S = paul,
    T = peter,
    Explanation = student_of(paul,peter)because(follows(paul,computer_science)because given)and(teaches(peter,computer_science)because given) ? ;
    S = paul,
    T = adrian,
    Explanation = student_of(paul,adrian)because(follows(paul,expert_systems)because given)and(teaches(adrian,expert_systems)because given) ? ;
    S = maria,
    T = peter,
    Explanation = student_of(maria,peter)because(follows(maria,ai_techniques)because given)and(teaches(peter,ai_techniques)because given) ? ;
    Notice that because and and are declared as infix functors. Also notice that any predicate on which we use clause(Head,Body) should be declared as dynamic.

Back / Peter Flach