Following is a demo of the blocks.pl program, Task 3.
?- solve(Steps) | . Steps = [putOn(b3, b1), putOn(b2, b3), putOn(b5, b6), putOn(b4, b5), putOn(b7, b4), putOn(b8, b7)] ; Steps = [putOn(b3, b1), putOn(b2, b3), putOn(b5, b6), putOn(b4, b5), putOn(b7, b4), putOn(b8, b7)] ; false.