/* ========== updated and defined version at 12/7/96 ============ */ /* initialization */ start:- backinit, set, generic_class, int, roles_soc, people, objects, places, events, states, processes, charge_sentences. /* definition of sets */ set :- own_names := aset([john, mary]),         masfem := aset([male, female]),         pol := '..'(0 , 1),        special := aset([(in), (on), (under), (near)]). /* definition of general class */ generic_class:- general :< anything.          /* temporary interface definition */ int:- time :< general, tloc :< time.     /* definition of social roles */ roles_soc:- social_roles :< general. /* definition and personal stages */ people:- man :< general, has_name :< domain(man) and range(own_names),           sex :< domain(man) and range(masfem),           waiter :< man and all(works_in, restaurant).                /* definition and objectives */ objects:- thing :< general,           table :< thing and all(location, location), corner :< thing and all(spec, special) and all(location, place), book :< thing and all(location, location).                                /* definition and places stations */ places:- place :< general,            restaurant :< place.            /* definition and event stands */ events:- ev :< general and all(time, time) and all(polarities, poles),   begin :< ev and all(agent, man) and all(prop, pr),             go :< ev and all(agent, man) and all(location, location). /* definition and state stations */ states:- st :< general and all(time, time), there_be :< st and all(theme_nonaff, thing),            have :< st and all(agent, man) and all(theme_aff, thing), there_in :< st and all(location, place) and all(goal, general). /* definition and process stations */ processes:- pr :< general and all(time, time) , read :< pr and all(agent, man) and all(theme_aff, thing), take_order :< pr and all(agent, waiter) and all(goal, man).           /* definition of the reading cycle */ charge_phrases:- done, fail. charge_phrases. /* ================================================== */ done:- fact(_, inst_of, [ind:Y, class:man], 1, _, _), Y::man. done:- fact(_, inst_of, [ind:Y, class:thing], 1, _, _), Y::thing. done:- fact(_, inst_of, [ind:Y, class:social_roles], 1, _, _), Y::waiter. /* ================================================== */ done:- fact(_, name, [X, Y], 1, _, _),Y::ha_name:X. done:- fact(_, roles, [waiter, X, Y], 1, _, _), Y::works_in:X. /* ================================================== */ done:- fact(_, isa, [ind:X, class:Y], 1, A, Z), X::Y and time:A and location:Z. done:- fact(_, isa, [arg:X, arg:ev], 1, A, B), X::ev and time:A and location:B. done:- fact(_, isa, [arg:X, arg:pr], 1, A, _), X::pr and time:A. done:- fact(_, isa, [arg:X, arg:tloc], 1, _, _), X::time. done:- fact(_, isa, [arg:X, arg:st], 1, A, _), X::st and time:A. done:- fact(_, isa, [arg:X, arg:Y], 1, A, B), X::Y and time:A and location:B. /* ================================================== */ done:- fact(X, go, [agent:Z, locat:A], 1, B, _), X::go and agent:Z and location:A and time:B. done:- fact(X, there_be, [theme nonaff:Z], 1, B, _), X::there_be and theme_nonaff:Z and time:B. done:- fact(X, take_order, [actor:Z, goal:A], 1, B, _), X::take_order and agent:Z and goal:A and time:B. done:- fact(X, read, [agent:Z, topic_aff:A], 1, B, _), X::read and agent:Z and theme_aff:A and time:B. done:- fact(X, start, [agent:Z, prop:A], 1, B, _), X::begin and agent:Z and prop:A and time:B. done:- fact(_, X, [arg:Y, poss:Z], 1, B, _), X::have and agent:Z and theme_aff:Y and time:B. done:- fact(_, X, [arg:Y, renting:Z], 1, A, B), Y::thing and spec:X and locaz:Z and time:A and location:B. /* Lista completa degli identificativi */ /* id2 = restaurant id3 = john id4 = go id5 = tloc id6 = table id7 = corner id8 = there_be id9 = tloc id10 = waiter id12 = take_order id13 = tloc id14 = tloc id18 = book id19 = read id20 = tloc id21 = begin id22 = tloc infon27 = there_in infon77 = have */ /* queries========================================== */ who(X):- backretrieve(getall(X)). who(X, Y):- backretrieve(X = getall(Y)). look_for(X):- backretrieve(getall(man and ha_name:X)). /* ================================================== */ describe(X):- backretrieve(describe X). /* example: | ?- describe(id3). >>> id3   describe:                           man           and has_name:john           and inv(agent):( poss and id19 and id21 and id4)           and inv(goal):id12           and oneof([id3]) yes | ?- describe(id4). >>> id4   describe:                           go           and location:id2           and time:tes(f5_r01)           and agent:id3           and oneof([id4]) yes */ /* ================================================== */   /* there was a table, there was a book .... */ c_era(X):- backretrieve(getall(X and lease:id2)). /* example: | ?- c_era(book). [id18] yes | ?- c_era(table). [id6] yes */ /* ================================================== */ /* what was in the restaurant */ what_wax(Z):- backretrieve(X = getall(Z)), member([Y], X), backretrieve(A = getall(thing and location:Y)), write(A), nl. /* example: |?- what_wax(restaurant). [[id7], [id6], [id18]] yes */ /* ================================================== */ /* who was in the restaurant */ who_wax(Z):- backretrieve(X = getall(Z)), member([Y], X), backretrieve(A = getall(man and location:Y)), write(A), nl. /* example: |- who_wax(restaurant). [[id10]] yes */ /* ================================================== */ /* who ordered */   who_has_ordered:- backretrieve(X = getall(take_order)), X = [[Y]], backretrieve(Z = getall(man and inv(goal):Y)), nl, write('take_order ='), write(Y), nl, write('goal ='), write(Z), nl. /* example: | ?- who_has_ordered. take_order = id12 goal = [[id3]] yes */ /* ================================================ */ /* who took the order-> syntax:who_has_taken_order */ who_has_taken_order:- backretrieve(X = getall(take_order)), X = [[Y]], backretrieve(Z = getall(man and inv(agent):Y)), nl, write('take_order ='), write(Y), nl, write('agent ='), write(Z), nl. /* example: |?- who_has_taken_order. take_order = id12 agent = [[id10]] yes */ /* ================================================== */ /* where is the waiter, john, the table etc ... */ where_and(Z):- backretrieve(X = getall(Z)), X = [[Y]], backretrieve(A = getall(anything and inv(lease):Y)), nl, write('lease ='), write(A), nl. /* example: |?- and(waiter). lease = [[id2]]   yes |?- where(book). lease = [[id2]]   yes | ?- where(table). lease = [[id2]]   yes */