code example from and problem solutions for the book "The Art of Prolog"