Challenge 2: Deriving a Domain Before Labeling — Possible Solution ==================================================================== derive_demo.pl: :- use_module(library(clpfd)). Query: ?- Y in 3..8, X #= Y * 2. X in 6..16, Y in 3..8. -- Why would the equivalent is/2 version raise an error here? -- -- -- X is Y * 2 demands that its right-hand side, Y * 2, already be -- fully ground arithmetic at the moment is/2 runs -- Y has to -- already be bound to a specific number, or Prolog cannot evaluate -- Y * 2 at all and raises an "Arguments are not sufficiently -- instantiated" error. Here, Y is only a domain variable ranging -- over 3..8, with no single value chosen yet -- is/2 has no way to -- multiply an entire RANGE by 2. #=, in contrast, doesn't need -- either side to be a concrete number -- it works directly over -- domains, propagating the multiplication across Y's whole 3..8 -- range to derive X's own domain, 6..16, immediately, with neither -- variable committed to any specific value yet. This is exactly the -- bidirectional, domain-level behavior the chapter names as #='s -- real difference from is/2. WHY THIS WORKS AS AN ANSWER ------------------------------ This uses a fresh multiplication example (rather than reusing the chapter's own X #= Y + 1) to show domain propagation happening before either variable is labeled, then explicitly ties the failure of the is/2 equivalent back to is/2's requirement for already-ground arithmetic, matching the chapter's own stated distinction.