In the first assignment you are going to revise basic syntax of Prolog, its search strategy and recursion. You are asked to save your work in a file called family.pl and to submit it via the upload system.
You may find the code from the first prolog tutorial pastebin.com/u/radek useful.
Familiarize yourself with the royal family of the British Monarchy: wikipedia:British_Royal_Family
Consider the following people:
william: Prince William of Wales
harry: Prince Henry of Wales
charles: The Prince Charles, Prince of Wales
diana: Diana, Princess of Wales
camilla: Camilla, Duchess of Cornwall
george: George VI of the United Kingdom
elizabeth: Elizabeth II, HM The Queen
philip: Prince Philip, Duke of Edinburgh
edward: The Prince Edward, Earl of Wessex
sophie: Sophie, Countess of Wessex
louise: Princess Louise of Wessex
james: Prince James of Wessex
and their relationships:
male(X) means that X is a man.
female(X) if X is a woman.
parent(P,C) if P is the parent of C. E.g. P can be Lady Diana and C Prince William. Not the other way round!
wife(W,H) if W is (or was) the wife of H.
Your task is to encode the genealogy graph about the listed people using the listed relations into Prolog as ground facts.
1 point
husband(Man,Woman) as to be derivable from the database. Do not list all husbands of all wives as ground facts.
person(P) to be either a male or a female.
mother(Mother,Child) and father(Father,Child). Be careful not to define a son or a daughter!
1 point
Using the course literature or Google, study the “negation as failure \+” technique or “non-unifiability predicate \=”.
sibling(Sibling1,Sibling2,Parent) predicate: Sibling1 is the sibling of Sibling2 and Parent is their shared parent. Be careful, the person is not its own sibling, therefore sibling(william,william,P) must be false!
misbegotten(Child). You are strongly encouraged to use previously defined predicates! In the royal family, there are no such children – for testing purposes you can delete information about Lady Diana being the wife of Prince Charles (make sure to put the information back before submitting the assignment).
2 points
brother(Brother,Person) and explain (in words) why all results to the query ?- brother(X,Y) are listed twice. Please include your explanation as a comment in the source code.
ancestor(Predecesor,Succesor) if there is a bloodline from person Predecesor to Succesor. E.g. ancestor(george,william) must succeed.
2 points
Submit the file to cw.felk.cvut.cz/upload on the 14.4.2011 23:59 CEST the latest. The deadline is strict.