I am currently working through SICP's section on Logic Programming, but I got stuck in the examples regarding logical deductions, especially the append-to-form rules. How do they work? What I don't quite understand is how the second rule cdr-downs the first list. For example, given:
(rule (append-to-form () ?y ?y))
(rule (append-to-form (?u . ?v) ?y (?u . ?z)) (append-to-form ?v ?y ?z))
a) How do we reach from:
;;; Query input:
(append-to-form (a b) (c d) ?z)
to
;;; Query results:
(append-to-form (a b) (c d) (a b c d))
b) And what bout this one:
;;; Query input:
(append-to-form (a b) ?y (a b c d))
to
;;; Query results:
(append-to-form (a b) (c d) (a b c d))
c) And lastly:
;;; Query input:
(append-to-form ?x ?y (a b c d))
to
;;; Query results:
(append-to-form () (a b c d) (a b c d))
(append-to-form (a) (b c d) (a b c d))
(append-to-form (a b) (c d) (a b c d))
(append-to-form (a b c) (d) (a b c d))
(append-to-form (a b c d) () (a b c d))
I would be interested in the specific mental steps required to carry out the rule matching.
Thank you in advance.