Expert and AI systems require the ability to store a representation of knowledge, and be able to deduce and explain things with that stored knowledge. One example might be a medical diagnosis program, while another might be a visual imaging and reco
gnition program.
You will be given sentences with 'has' relationships, and sentences with queries related to those sentences. You must store the knowledge and be able to deduce and explain chains of knowledge.
Each input line will be of the following format (or a blank line):
a/an noun1 has a/an noun2. or Why has a/an noun1 a/an noun2? ( each word may be separated by 1 or more spaces/tabs ) ( the line may begin with any number of spaces/tabs ) ( the '.' or '?' may or may not have any number of spaces/tabs before it )
The four possible outputs are given in the Sample Output section. If a sentence is in the incorrect form then it outputs I don't understand "...". If a question is answered by one of the other sentences then it outputs "..." because you told me so. If there is a chain of things to explain, it explains the chain with the format in the sample output. If a question is asked when insufficient knowledge is available then it outputs I don't know that .... Do not assume that all queries come last in the input file, they may be mixed in with the knowledge sentences. The input file will be named explain.in, and the output file will be named explain.out.
Sample Input:
A lion has a head. A lion has a leg . A leg has a paw. A lion is an animal. A paw has a claw. Why has a lion a head? A leg has a knee. Why has a lion a claw? Why has a tiger a leg?Sample Output:
I don't understand "A lion is an animal.". A lion has a head because you told me so. A lion has a claw because a lion has a leg, a leg has a paw, and a paw has a claw. I don't know that a tiger has a leg.