DEPARTMENT OF ARTIFICIAL INTELLIGENCE Prolog exercises - for week beginning 6 Dec 1982 1. The normal method of getting a program into the interpreter, and modifying it, is fairly cumbersome for beginners. Devise a better method. You could restrict yourself to clauses such as fred eats haggis ian hates chips and other such clauses of the form "Object Relation Object". Your program should give you a prompt and allow you to add facts (use built-in predicate 'assertz(Term)') and ask questions - say of the form is it true that fred eats haggis Points to remember: (a) in ECMI25.UTIL_READIN there is a program for 'read_in(List)' such that the goal 'read_in(L)' will give a prompt and wait for you to type. If you type fred eats haggis then L will be instantiated to the list [fred,eats,haggis]. Experiment with it a bit to get the feel of it. (b) there is a built-in operator '=..' such that the goal 'T =.. [eats,fred,haggis]' will instantiate T to 'eats(fred,haggis)' which you can then add (by 'assertz(T)'). Experiment with it a bit to get the feel of it. (c) You can represent facts in any way you want e.g. as 'fact(fred,eats,haggis)' rather than the way suggested by (b) above. 2. Embellish your answer in any way you like; try to make it useful for people who have seen very little Prolog before. For example, you could try to cope with something of the form X eats haggis by treating it as a question and printing out one (or maybe all) X for which it's true. You could add checks so that if someone tries to add the fact fred eats haggis twice then your program says "I already know that!" at the second go. You could try coping with compound constructs such as fred eats haggis and fred likes beer and even rules such as fred likes beer if beer is cheap (again, just restrict yourself to things of the form "Object Relation Object if Object Relation Object" or whatever you feel you can cope with). Add anything you like, such as the power to cope with fred likes beer and hates vodka - the question is really meant to be an open-ended exercise, and enjoyable. If you have trouble with the Prolog for implementing your ideas, bring the ideas along so that your tutor and the rest of his group can have a go!