A solution for this problem can be found here.
You have been given the job of writing a simple symbolic AI processor, which will be told some facts, and asked some questions. The AI processor must then try its hardest to answer the questions.
Fortunately, these facts and questions relate only to specific individuals, who are in groups (collective nouns) which perform actions (verbs) on other groups.
The grammar used is very simple: there are two types of statements and one type of question, and all nouns are made plural through the expedient of adding an s.
Lines are up to 80 characters long. Words are up to 40 characters long and may consist of upper and lower case letters, although all searching is done case-insensitively. There may be more than one space between words, but there are never any spaces between words and the punctuation marks at the end of each sentence. Allow for up to 100 facts in the input.
Yes.if the preceding input implies that the question is true, and
No.otherwise.
Dogs chase cats. Sheeps ignore glasss. Fido is a dog. Fluffles is a cat. Does Fido chase Fluffles? Does Fluffles chase Fido? #
Yes. No.