% Here is the grammar shown in class

sentence --> np, vp.

np --> article, noun.

vp --> verb, np.

verb --> [eat].

verb --> [eats].

article --> [a].

article --> [an].

article --> [the].

noun --> [apple].

noun --> [man].

test :- sentence([the, man, eats, the, apple], []).

%try the query ?- test.

%Same grammar extended with parse-trees

sentence(fsent(N,V)) --> np(N), vp(V).

np(fnp(A,N)) --> article(A), noun(N).

vp(fvp(V,N)) --> verb(V), np(N).

verb(fverb(eat)) --> [eat].

verb(fverb(eats)) --> [eats].

article(farticle(a)) --> [a].

article(farticle(an)) --> [an].

article(farticle(the)) --> [the].

noun(fnoun(apple)) --> [apple].

noun(fnoun(man)) --> [man].

test(P) :- sentence(P, [the, man, eats, the, apple], []).

%try the query ?- test(P).