Challenge 1: All Color/Size Combinations via Backtracking — Possible Solution ==================================================================== facts.pl: color(red). color(green). color(blue). size(small). size(medium). size(large). Query: ?- color(X), size(Y). X = red, Y = small ; X = red, Y = medium ; X = red, Y = large ; X = green, Y = small ; X = green, Y = medium ; X = green, Y = large ; X = blue, Y = small ; X = blue, Y = medium ; X = blue, Y = large. Explanation: color(X) has three possible answers (red, green, blue) and size(Y) has three possible answers (small, medium, large) -- combined in a single conjunction, Prolog generates all nine combinations by backtracking: it fixes X = red, exhausts every Y value, THEN backtracks into color(X) for the next value (green), exhausting every Y again, and so on. Pressing ; after each answer requests exactly this next combination, with no explicit nested loop written anywhere in the code. WHY THIS WORKS AS AN ANSWER ------------------------------ This reproduces the chapter's own member/2 combination example using two independent sets of facts, confirming backtracking generates every combination of the two automatically.