% GRAMMAR RULES. % The only feature handled is AGR (number & person.) s(S) --> np(S), vp(S). np(s3) --> propernoun. np(S) --> pronoun(S). vp(S) --> verb(S). vp(S) --> verb(S),[and],verb(S). % TERMINAL SYMBOLS % proper nouns propernoun --> [janet]. % alternative I propernoun([N|S],S) :- member(N,[bill,steve]). % alternative II % verbs verb(s3,[cries|S],S). verb(P,[cry|S],S) :- agr(P), not(P=s3). verb(s3,[smiles|S],S). verb(P,[smile|S],S) :- agr(P), not(P=s3). % pronouns pronoun(N,[P|S],S) :- ispronoun(N,P). ispronoun(s1,i). ispronoun(s2,you). ispronoun(s3,he). ispronoun(s3,she). ispronoun(s3,it). ispronoun(p1,we). ispronoun(p2,you). ispronoun(p3,they). % AUXILIARY DEFINITIONS agr(s1). agr(s2). agr(s3). agr(p1). agr(p2). agr(p3). % AUXILIARY PREDICATES % negation as failure not(G) :- G, !, fail. % If goal G succeeds, commit to this clause, and fail. not(G). % Goal G did not succeed above, so not(G) succeeds. % Is A a member of the list? member(A,[A|_]). % Yes, if it is the head of the list, member(A,[_|L]) :- member(A,L). % or in the tail of the list.