The instantiation error would be raised by P being unbound, not D. You can walk over variables with member/2.
In Swi-Prolog:
?- member(X, D).
D = [X|_3304] ;
D = [_3302, X|_3310] ;
D = [_3302, _3308, X|_3316] ;
D = [_3302, _3308, _3314, X|_3322] .
In Sicstus Prolog: | ?- member(X,D).
D = [X|_A] ? ;
D = [_A,X|_B] ? ;
D = [_A,_B,X|_C] ? ;
D = [_A,_B,_C,X|_D] ?
yes
The instantiation error, e.g. in Swi: ?- (member(X,D), \+ P).
ERROR: Arguments are not sufficiently instantiated
- is an implementation detail, not a feature of the language (although it's
probably in some standard). You could write your own version of \+/2 that
doesn't raise an error.>> SMT2 is perfectly happy with infinite domains. Yes, you can encounter undecidability (and obviously must in some cases), but it is not a given. You can absolutely prove theorems over infinite domains with it.
You can prove theorems in infinite domains with Prolog. For instance, given the program P, below, the query Q terminates:
P =
{ s(0),
s(s(N)):- s(N)
}
Q = { s(s(s(0))) }
Now that I think about it, member/2, append/2, etc list processing predicates also range over infinite domains. member(X,[X|T]).
member(X,[H|T]):-
member(X,T).
etc. True for lists of arbitrary length, restricted only by your computer's memory.