KRR Coursework II, Autumn 2021
Build a Knowledge Base
Brandon Bennett
This coursework counts for 15% of the total marks for this module.
This piece of coursework can be done either individually, or in a group of two or three students. The grading
will take into account the group size. Proportionally more substantial programming and report content are
expected in group submissions compared to individual submissions. The details given below explicitly give
some difference in requirements depending on group size.
If submitting as a group, ONLY ONE group member should make the submission on Grade-
scope. They will then see a button that enables them to add additional members to the group.
Do not make separate submissions of work coming from the same group.
Build Your Own Knowledge Base
For this part of the assignment you will create a Knowledge Base (KB) formulated as a Prolog program.
As a starting point, you are given the program brandons kb.pl, which contains an example knowledge base
(expressed as a set of facts and a set of inference rules) as well as a simple but quite powerful inference mechanism.
You can get to it via the following url:
https://swish.swi-prolog.org/p/bb_kb_2021.pl
You should examine the program and run it in SWISH (some other Prolog), before attempting the questions.
In order to modify the code you need to copy it using the fork option in the SWISH “Save new version” dialogue,
that you get to by choosing “Save …” on the drop down “File” menu. You should rename your version to
username kb.pl.
Initial Experimentation
Before attempting this question, you are advised to do some initial experimentation with the given database
and go through the following questions, which will help you think about how the system works:
1. Specify a rule which enforces the condition: “Cats hate all dogs except puppies”.
(Ensure that your rule gives the expected inferences.)
2. Specify a relational composition rule that will enable the implied fact
[rex, is grandfather of, champ] to be inferred from the KB.
3. A programmer is considering adding the following “genesis” rule to the KB:
rule( genesis, [[X, isa, dog]] ==> [[fatherof(X), isa, dog]] ).
Add this rule to the KB and run the inference mechanism, before answering these questions:
(a) What is the meaning/purpose of this rule?
(b) Explain what happens when the inference system is run with this rule present and why it could be
problematic.
4. Consider the function of the weak negation operator \+ that can be applied to premisses of a rule. A
weakly negated premiss takes the form \+[r, … ] and means that the rule can only be applied if the
fact [r, … ] is not in the database. This can be useful but can lead to unforseen behaviour of the
inference system when rule are reordered or further rules are added. Explain how this can happen.
1
https://swish.swi-prolog.org/p/bb_kb_2021.pl
Making your own Knowledge Base
To answer this question you must replace the simple example facts and rules with a more substantial KB of
your own devising (you will probably want to keep the ‘logic’ rules for subclass reasoning). Your answer to this
question should be submitted in the form of a PDF document. Your Prolog code should also be submitted as
a separate file on Gradescope. Grading will normally be done just by reading your PDF report, but we will
check the code file if we think the report may not give an accurate account of the results you obtained from
your code.
Preparation: You must chose a domain for your KB. This should be focused enough so that it has a
distinctive vocabulary of key concepts, relations and specific facts; but also substantial enough that moderately
complex inference rules are required to draw relevant and interesting conclusions. I suggest you do a bit of
experimentation with adding new information to the current KB before deciding on the domain your want to
work on.
Structure of your report
The mark allocation for your report will be divided up as follows:
1. Domain and Topic Description
Explain your topic in 50-100 words giving a clear description of the types of entities and relationships that
will be represented and the kinds of inference you expect to be able to make. [3 marks]
2. Presentation of your Knowledge Base
You should present your knowledge by just giving the exact code of the facts and rules of the KB that you
have created, but divided into separate sections. Use suitable spacing and brief comments so that your
knowledge base is easy to understand.
(a) Fact Statements. Your fact statements should involve all key properties and relations of the
domain. The relevant concept hierarchy should be specified via the subclass relation, so that all
subclass relations are either directly asserted or derivable by the inference mechanism. A selection
of significant and/or illustrative facts concerning specific entities should also be given. You should
group similar facts together in blocks, so that the coverage and range of different facts is easy to see.
[2 marks]
(b) Rule Statements. Within the restricted scope of your chosen domain and the limited time available,
you should aim to give inference rules that are as comprehensive as possible. Generally applicable
rules are preferable to those that are very specific. More credit will be given for diversity of rules
than for large numbers of very similar rules. Above each rule statements should be a comment giving
a brief explanation of the rule. [6 marks]
3. Evaluation
Give and assessment of how successful is your KB in capturing the essential knowledge for your chosen
domain. Discuss the power and limitations of the inference rules you have specified. You should write
about 100 words + 50 words per person in your group. [4 marks]
4. Interesting Inferences
Pick out up to 3 of what you consider to be the most interesting inferences that are generated by your
system. You must consider at least one inference for each member of the group. Choose cases
such that each illustrates a different aspect of your rule system. In each case give (a) the sequence of
single-step inferences leading from initial facts to the final conclusion; and (b) a written explanation (say
3 or 4 sentences) of the inference and how it is justified by the rules. [15 marks]
Note that the term ‘inference’ is a little ambiguous. It can refer to both the final fact deduced and also
the full sequence of inference steps leading from the assumptions to the conclusion. In answering this
question you need to give the full sequence. You will be able to find this by looking at the rules applied
and facts generated at each level up to the depth were the final inference is made.
The most interesting inferences will typically those that require a sequence of several inference steps
involving several different rules and facts. When answering the question you should give a clear account
of the steps involved in making the inference.
[30 marks total]
2