$40
This programming assignment has two main learning goals. First, the assignment will provide you with an example of an automated reasoning inference procedure for first-order logic implemented in Python. You will be able to explore the use of such an inference procedure by populating the knowledge base with various sentences. Second, and more prominently, this assignment will give you practice translating English sentences into first-order logic definite clauses. You will produce a knowledge base of facts and rules that communicate some general knowledge that has been provided to you, and you will provide these sentences in a form that they may be directly used by the provided Python inference engine.
Activities
Domain
You are to provide a Python script file that defines the global variable monstersentences and initializes it to a list of strings, with each string being a first-order logic sentence. These sentences are to capture the domain knowledge provided below.
The domain of this knowledge base is a fictional murder that took place in the cemetery last night. Somebody has been killed, and the possible villians include vampires, werewolves, and witches. You will be writing first-order logic sentences that reflect general knowledge about these monsters and the terrible things that they do to their victims. To test your knowledge base, the details of a specific homicide will be encoded as additional logical sentences, and the inference engine will be asked if the identity of the murderer (or murderers) can be deduced from the provided knowledge. If you translate the given English sentences correctly, the culprit will be caught (at least in some cases).
Knowledge
You are to translate the following statements into first-order logic definite clauses:
• Celene is a vampire.
• Mario is a werewolf.
• Mildred is a witch.
• Bob, Lin, and Maurice are people.
• A person who is dead is a victim.
• All vampires, werewolves, and witches are monsters.
• Any monster present at the crime scene is a suspect.
• If a vampire is suspected and the victim was bitten, then the vampire killed the victim.
• If a werewolf is suspected and the victim was eaten, then the werewolf killed the victim.
• If a witch is suspected and the victim was poisoned, then the witch killed the victim.
• If a victim is drained of blood but has an intact body, then the victim was bitten.
• If a victim is drained of blood and has body pieces missing (i.e., is incomplete), then the victim was eaten.
• If a victim’s body is intact, and the victim’s skin complexion is green, blue, or purple, or if it is pale with boils, then the victim was poisoned.
• If a victim’s skin complexion is pale and the body is either cold or punctured, then the victim is drained of blood.
• If a victim’s body is complete (i.e., not incomplete), then the victim is not dismembered or disemboweled.
These English sentences contain all of the knowledge to be encoded in the knowledge base. No additional knowledge should appear in your list of logical sentences.
Ontology
The first-order logic sentences to be produced must use only the following ontology of constants and predicate symbols:
• Bob, Celene, Lin, Mario, Maurice, Mildred : constant symbols referring to individuals
• Pale, Blue, Green, Purple : constant symbols for skin complexion colors
• Bitten(x) : true iff x has been bitten
• Boils(x) : true iff the skin of x has boils
• Cold(x) : true iff the body of x is cold to the touch
• Complexion(x, y) : true iff the skin of x has the complexion color y
• Dead(x) : true iff x is dead
• Disemboweled(x) : true iff the body of x is missing internal organs
• Dismembered(x) : true iff the body of x is missing limbs
• Drained(x) : true iff the body of x has been drained of blood
• Eaten(x) : true iff x has been eaten
• Incomplete(x) : true iff the body of x is missing parts
• Intact(x) : true iff the body of x is relatively whole and intact
• Killed(x, y) : true iff x murdered y
• Monster(x) : true iff x is a monster
• Person(x) : true iff x is a person
• Poisoned(x) : true iff x has been poisoned
• Present(x) : true iff x was present at the crime scene
• Punctured(x) : true iff the body of x has puncture wounds
• Suspect(x) : true iff x is a murder suspect
• Vampire(x) : true iff x is a vampire
• Victim(x) : true iff x was the victim of a murder
• Werewolf(x) : true iff x is a werewolf
• Witch(x) : true iff x is a witch
In the descriptions of these predicates, “iff” is shorthand for “if and only if”. Note that capitalization matters. Constants and predicate symbols must start with a capital letter. Variables are all lowercase. You should not introduce any other constants or predicates (or function symbols) beyond those explicitly listed in this ontology.
Translation
The knowledge provided as English sentences is to be translated into a list of first-order logic sentences. These will be gathered, along with sentences describing the specific murder case, in order to produce a Python object of the class FolKB (first-order logic knowledge base).
Note that every sentence must be a definite clause. The inference engine that you are given implements a backward chaining algorithm that only works on knowledge bases consisting of definite clauses. Other kinds of first-order logic sentences are not allowed.
Also note that the number of first-order logic sentences needed to encode the provided knowledge need not be the same as the number of presented English sentences. In particular, it is not unusual for a single English sentence to be translated into multiple first-order logic definite clauses.
A template of the “knowledge.py” file is provided for you. Your only task is to set the value of the monstersentences variable to a list of your definite clauses, with each sentence given as a string. In these strings, the conjunction operator is the ampersand (“&”), and the disjunction operator is the vertical bar (“|”). The implication operator is two equal signs followed by a greaterthan sign (“==>”). Example sentences appear in the template script file