Comments on previous versions: N218 2010-04-01, N218 2010-07-18, N232 2012-07-13, N238 2012-11-20. N249 2013-08-20. While there is some progress compared to N249, there are still many open issues, and the previous comments must still be taken into account.
SemiContext
by Semicontext. It is one word like semigroup.
nt(S0, [word|S]) :- S0 = S.
should read nt(S0,S) :- S = [word|S0]. or
introduce further equations.
Since, there has not been any attempt to define when constructs are well defined and when they are implementation dependent, maybe the best would be to define this formally only.
->//2 - if-then-else. This is an if-then,
not an if-then else. If-then-else is (;)//2. The remarks make
this somewhat clear, but the present form is unsuited for a
definition.
( a -> b | c) needs to be implementation
dependent.
Goal is expanded to phrase//1 and
respectively phrase/3.
(\+)//1: It seems the entire construct
is rather disputed: At least it should be left as a dummy that
must not be used otherwise.
[] --> [a]. \+ a --> []. a --> [_|_]. a --> (b --> c). a, b --> c. ! --> [].Must be left implementation dependent. But where is this defined?
dcg_cbody(\+ GRBody, S0, S, ( \+ phrase(GRBody,S0,_), S0 = S )).Implementations still may translate things more efficiently, however, the observable semantics, particularly with respect to cuts and errors must be retained. As an example, consider the query
phrase(([a],\+1),[]) which
always should fail and not produce an error.
LHS --> RHS.
meaning "a possible form for LHS is RHS".