Challenge 1: Building seen/1 at Runtime With assertz — Possible Solution ==================================================================== seen_demo.pl: :- dynamic(seen/1). Queries: ?- assertz(seen(apple)). true. ?- assertz(seen(banana)). true. ?- assertz(seen(cherry)). true. ?- seen(X). X = apple ; X = banana ; X = cherry. Explanation: seen/1 starts with no clauses at all -- only the :- dynamic(seen/1). directive, which tells Prolog in advance that assertz/retract are allowed to target it even though it has no facts yet. Each assertz call adds one more fact to the end of the database, in the order the calls were made. Querying seen(X) afterward behaves exactly like any ordinary predicate defined in the source file -- backtracking via ; walks through all three facts in the order they were asserted, even though none of them existed when the program first loaded. WHY THIS WORKS AS AN ANSWER ------------------------------ This confirms that a predicate declared dynamic with zero starting clauses behaves identically to a normal predicate once facts have been asserted into it, and that assertz preserves insertion order across repeated calls, matching the chapter's own description of assertz adding to the end of the database.