%% A grammar for a VERY small subset of English: %% sentence -> noun_phrase verb_phrase %% nounPhrase -> proper_noun %% nounPhrase -> article adjective noun %% nounPhrase -> article noun %% verbPhrase -> intransitive_verb %% verbPhrase -> transitive_verb noun_phrase %% article -> list of articles %% adjective -> list of adjectives %% properNoun -> list of proper nouns %% noun -> list of nouns %% intransitiveVerb -> list of intransitive verbs %% transitiveVerb -> list of transitive verbs variable(sentence). variable(nounPhrase). variable(verbPhrase). variable(article). variable(adjective). variable(properNoun). variable(noun). variable(intransitiveVerb). variable(transitiveVerb). terminal(X) :- article(X) ; adjective(X) ; properNoun(X) ; noun(X); intransitiveVerb(X); transitiveVerb(X). rule(sentence, [nounPhrase, verbPhrase]). rule(nounPhrase, [properNoun]). rule(nounPhrase, [article, adjective, noun]). rule(nounPhrase, [article, noun]). rule(nounPhrase, [adjective, noun]). rule(verbPhrase, [intransitiveVerb]). rule(verbPhrase, [transitiveVerb, nounPhrase]). rule(article, [A]) :- article(A). rule(adjective, [A]) :- adjective(A). rule(properNoun, [PN]) :- properNoun(PN). rule(noun, [N]) :- noun(N). rule(intransitiveVerb, [IV]) :- intransitiveVerb(IV). rule(transitiveVerb, [TV]) :- transitiveVerb(TV). article(a). article(an). article(the). adjective(lazy). adjective(excited). adjective(trinocular). adjective(rans). properNoun(zach). properNoun(ran). properNoun(turing). noun(spam). noun(spampede). noun(alien). noun(donut). noun(tofu). noun(chinchilla). intransitiveVerb(sleeps). intransitiveVerb(runs). intransitiveVerb(ran). transitiveVerb(defeats). transitiveVerb(eats). transitiveVerb(overwhelms).