/****************************************************************
A small DCG for very simple English sentences

This version: 11/08/04 albu,stwa
****************************************************************/

:- [comsemOperators].
:- [users:comsemOperators].
:- [users:betaConversion].

:- use_module(comsemLib,[compose/3]).
:- use_module(signature,[vars2atoms/1]).


s(NP@VP) --> np(NP),vp(VP).
np(DET@N) --> det(DET),n(N).
np(PN) --> pn(PN).
vp(TV@NP) --> tv(TV),np(NP).
vp(IV) --> iv(IV).


det(lambda(P, lambda(Q, exists(X, ((P@X) & (Q@X)))))) --> [a], {vars2atoms(P), vars2atoms(Q),vars2atoms(X)}.
det(lambda(P, lambda(Q, forall(X, ((P@X) > (Q@X)))))) --> [every], {vars2atoms(P), vars2atoms(Q),vars2atoms(X)}.

n(lambda(X, witch(X))) --> [witch], {vars2atoms(X)}.
n(lambda(X, wizard(X))) --> [wizard], {vars2atoms(X)}.
n(lambda(X, broomstick(X))) --> [broomstick], {vars2atoms(X)}.
n(lambda(X, man(X))) --> [man], {vars2atoms(X)}.
n(lambda(X, woman(X))) --> [woman], {vars2atoms(X)}.

pn(lambda(P, P@harry)) --> [harry], {vars2atoms(P)}.
pn(lambda(P, P@john)) --> [john], {vars2atoms(P)}.
pn(lambda(P, P@mary)) --> [mary], {vars2atoms(P)}.

iv(lambda(X, fly(X))) --> [flies], {vars2atoms(X)}.

tv(lambda(X, lambda(Y, X@lambda(Z, curse(Y,Z))))) --> [curses], {vars2atoms(X), vars2atoms(Y), vars2atoms(Z)}.
tv(lambda(X, lambda(Y, X@lambda(Z, love(Y,Z))))) --> [loves], {vars2atoms(X), vars2atoms(Y), vars2atoms(Z)}.
