rule(s,  [np, vp]).
rule(np, [det, nb]).
rule(nb, [n]).
rule(nb, [n, rel]).
rule(rel,[wh, vp]).
rule(vp, [iv]).
rule(vp, [tv, np]).
rule(vp, [dv, np, pp]).
rule(vp, [sv, s]).
rule(pp, [p, np]).

word(np,kim).
word(np,sandy).
word(np,lee).
word(np,bread).
word(det,a).
word(det,the).
word(det,her).
word(n,consumer).
word(n,duck).
word(n,man).
word(n,woman).
word(wh,who).
word(wh,that).
word(p,to).
word(iv,died).
word(iv,ate).
word(tv,ate).
word(tv,saw).
word(tv,gave).
word(dv,gave).
word(dv,handed).
word(sv,knew).


initial(s).		% the start category 

% A set of test examples - predicate 'test' must be defined for parser

test1 :-
	test([kim,died]).
test2 :-
	test([sandy,saw,a,duck]).
test3 :-
	test([kim,knew,sandy,knew,lee,died]).
test4 :-
	test([the,woman,gave,a,duck,to,her,man]).
test5 :-
	test([lee,handed,a,duck,that,died,to,the,woman]).

teste1 :-
  test(['Maria',lacks,a,house]).
teste2 :-
  test(['Mayumi',sees,a,table]).
teste3 :-
  test(['Mayumi',sees,that,'Maria',sees,that,'Mayumi',lacks,a,house]).
teste4 :-
  test([the,woman,who,sees,'Maria',sings]).
teste5 :-
  test(['Maria',hits,a,house,that,lacks,a,table]).

testf1 :-
  test([kim,was,happy]).

testf2 :-
  test([lee,is,a,consumer,and,often,very,very,stupid]).

testf3 :-
  test([sandy,was,sometimes,a,stupid,man,and,kim,is,always,the,happy,woman]).
