% File: ECMI01.AI2_VISITING % Author: Peter Ross % Purpose: a simple database example % % This contains a baby database: % visiting(A,B) meaning A is currently visiting B % at(A,Place) meaning A is at Place % phone(Place, Number) meaning the phone at Place is Number % There is a predicate 'ring' which finds out which number to ring % to get hold of a particular person, or vice-versa. % ---- phone numbers ----- phone(place_a, 667-5770). phone(place_b, 339-5390). phone(place_c, 229-8901). phone(place_d, 229-6031). phone(place_e, 667-1011-2551). % ---- some 'at' details ---- at(bundy, place_a). at(howe, place_b). at(ritchie, place_c). at(ross, place_d). at(ai_dept, place_e). % ---- some 'visiting' details ---- visiting(johnson, ai_dept). visiting(reagan, thatcher). visiting(thatcher, howe). visiting(andropov, castro). visiting(castro, jaruzelski). visiting(jaruzelski, ai_dept). % The predicate 'location' finds out where a person is. % Either: the person is known to be 'at' a place, % or: the person is known to be 'visiting' someone, and % 'location' is used to find out where that someone is. location(Person, Place) :- at(Person, Place). location(Person, Place) :- visiting(Person, Someone), location(Someone, Place). % The predicate 'ring' tells you what number to ring to contact % someone, or tells you who you can contact at a given number. ring(Person, Number) :- location(Person, Place), phone(Place, Number).