% Example DCG's from the lecture

  sent --> np, vp.
  np --> [the], n.
  vp --> [runs].
  n  --> [engine].
  n  --> [rabbit].

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

sent(s(X,Y)) --> np(X, N), vp(Y, N).
np(john, singular(3)) --> [john].
np(they,plural(3)) --> [they].
vp(run,plural(X)) --> [run].
vp(runs,singular(3)) --> [runs].

/*  Example query
| ?- phrase(sent(X), A, B).
A = [john,runs|B],
X = s(john,runs) ? ;
A = [they,run|B],
X = s(they,run) ? ;
no
*/

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

abc --> a(N), b(N), c(N), {even(N)}.

a(0) --> [].
a(s(N)) --> [a], a(N).

b(0) --> [].
b(s(N)) --> [b], b(N).

c(0) --> [].
c(s(N)) --> [c], c(N).

even(0).
even(s(s(X))) :- even(X).
