====== Archive eFLP 2011: Prolog assignment 1 ====== 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 [[http://pastebin.com/u/radek | pastebin.com/u/radek]] useful. ===== 1. Introduction ===== Familiarize yourself with the royal family of the British Monarchy: [[http://en.wikipedia.org/wiki/British_Royal_Family|wikipedia:British_Royal_Family]] ===== 2. Database ===== 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** ===== 3. Basic definitions ===== * Define the predicate ''husband(Man,Woman)'' as to be derivable from the database. Do not list all husbands of all wives as ground facts. * Similarly define ''person(P)'' to be either a //male// or a //female//. * Define ''mother(Mother,Child)'' and ''father(Father,Child)''. Be careful not to define a son or a daughter! **1 point** ===== 4. Negation by failure ===== Using the course literature or Google, study the “negation as failure ''\+''” technique or “non-unifiability predicate ''\=''”. * Define the ''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! * Using a similar technique, find a way of detecting children, whose parents are not married: define ''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** ===== 5. Recursion and search strategy ===== * Define ''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. * Define ''ancestor(Predecesor,Succesor)'' if there is a bloodline from person ''Predecesor'' to ''Succesor''. E.g. ''ancestor(george,william)'' must succeed. **2 points** ====== Submission ====== Submit the file to [[http://cw.felk.cvut.cz/upload/|cw.felk.cvut.cz/upload]] on the **14.4.2011 23:59 CEST** the latest. The deadline is strict.