
%Database interrogation program: frontend_bu.pl
% Version which uses the bottom-up shift-reduce
% parser
linguistic_analyser(String) :-
   setof(parse(Matrix, Store),
         parse(String, s(Matrix, Store-[])), %shift reduce parser
        Parses), !,
   findall(reading(ScopedTrans),
           (member(parse(Mx, St), Parses),
           scope(Mx, St, ScopedTrans)),
               Readings), !,
        answer(Readings).


linguistic_analyser(_) :-
	write('Linguistic analyser: unable to process'), nl.
	
answer(Readings):-
	member(reading(ScopedTrans), Readings),
	message(ScopedTrans),
	fail.
answer(_).


message(Formula):-
	write(Formula), nl,
	( call(Formula)->  
	write('That''s right.'), nl
	;
	write('I don''t think so.')
	)
	, nl.


~P :- \+ P.

(P & Q):-
	call(P),
	call(Q).

for_all(_X, P => Q):-
	\+ (call(P),
	       \+ call(Q)).

exists(_X, P):-
	call(P).

witch1(w1).
witch1(w2).
witch1(w3).
witch1(w4).

died1(X):-
	killed1(_, X).

soldier1(s1).
soldier1(s2).
soldier1(s3).
soldier1(s4).


killed1(m, d).
killed1(m, w1).

killed1(s1, w1).
killed1(s2, w2).
killed1(s3, w3).
killed1(s4, w4).





