prolog,logical-purity,prolog-coroutining

It would be nice if when/2 would support a condition list/1. In the meantime, consider: list_ltruth(L, Bool) :- freeze(L, nvlist_ltruth(L, Bool)). nvlist_ltruth(Xs0, Bool) :- ( Xs0 == [] -> Bool = true ; Xs0 = [_|Xs1] -> freeze(Xs1, nvist_ltruth(Xs1, Bool)) ; Bool = false ). when_list(L, Goal_0) :- nvlist_ltruth(L, Bool),...

prolog,logic-programming,logical-purity

Is the above predicate plus/3 really pure? It has some odd behavior: Sometimes it accepts arithmetic expressions, and sometimes not ; and this although all arguments are evaluated: ?- plus(3,5-3,5). true ... ?- plus(3,2,3+2). false. ?- plus(3,2,3+b). ERROR: </2: Arithmetic: `b/0' is not a function ?- plus(3,2,3+Z). ERROR: </2:...

Logical purity of when/2 and ground/1 Note that there is the ISO built-in ground/1 which is just as impure as nonvar/1. But it seems you are rather talking about the conditions for when/2. In fact, any accepted condition for when/2 is as pure as it can get. So this...