Problem 1

Using the fact and rules from the backward chaining handout, example 1, trace Prolog inference for the goal ?- sister_in_law(jennifer,rachel).
G0 ?- sister_in_law(jennifer,rachel).   Resolve with Rule 1.
   G1 ?- sibling(jennifer,Z1), married(Z1,rachel), female(rachel)
                                                 Resolve with Rule 4
    G2: ?- parent(Y2,jennifer), parent(Y2,Z1), married(Z1,rachel), female(rachel).
                                         Fail. Return to G0. Resolve with Rule 2
   G3: ?- wife(jennifer,Z), sibling(Z,rachel).   Resolve with fact 12.
     G4: ?- sibling(bob,rachel).                 Resolve with Rule 4.
       G5: ?- parent(Y3,bob), parent(Y3,rachel). Resolve with Fact 7,
         G6: ?- parent(alice,rachel).  Fail.  Return to G5. Resolve with Fact 10.
         G7: ?- parent(pete,rachel).  Succeed.

Problem 2

The append relation for lists can be defined as follows:
R1: append(nil,L,L). 
R2: append(c(X,L),M,c(X,N)) :- append(L,M,N).
Trace Prolog inference for the goal "append(c(p,c(q,nil)),c(r,nil),Q)".
G0: ?- append(c(p,c(q,nil)),c(r,nil),Q).
           Resolve with R2: X1=p, L1=c(q,nil), M1=c(r,nil), Q=c(p,N1).
  G1: ?- append(c(q,nil), c(r,nil), N1).
            Resolve with R2: X2=q, L2=nil, M2=c(r,nil), N1=c(q,N2).
    G2: ?- append(nil,c(r,nil),N2).
            Resolve with R1: L=N2=c(r,nil). Succeed.
Return Q=c(p,N1) = c(p,c(q,N2)), = c(p,c(q,c(r,nil))).

Problem 3

In problem 2, trace Prolog inference for the goal "append(X,c(r,nil),c(q,c(r,nil)))".
G0: ?- append(X,c(r,nil),c(q,c(r,nil))).
            Resolve with R2:  X=c(q,L1), L1, M1=c(r,nil), X1=q, N1=c(r,nil).
  G1: ?- append(L1,c(r,nil),c(r,nil)).
            Resolve with R1, L1=nil.  Succeed.
Return X = c(q,L1) = c(q,nil).

Problem 4

In problem 1, give a forward chaning proof of sister_in_law(jennifer,rachel). You need only show the chain of inference that leads to the goal.
Resolve Fact 10 with rule 4 to get
   R16: sibling(bob,Z) :- parent(pete,Y).

Resolve Fact 9 with R16 to get
   F17: sibling(bob,rachel).

Resolve Fact 12 with Rule 2 to get
   R18: sister_in_law(jennifer,rachel) :- sibling(bob,rachel).

Resolve Fact F17 with R18 to get
   F19: sister_in_law(jennifer,rachel).