I am trying to write a program in Prolog that would recognize 'is a' statements and apply the transitive property in inquired. For example:
Input: Mary is a girl.
Output: ok.
Input: A girl is a human.
Output: ok.
Input: Is Mary a human?
Output: yes.
Here's my code:
begin :-
begin(Input).
begin(Input) :-
write('Begin.. '),
write('\n'),
readln(Input),
tokenize_atom(Atom, List),
rules(List).
begin.
rules(['A', Subj, is, a, What]) :-
asserta(a(Subj, What)),
write('ok'),
write('\n').
rules([Subj, is, a, What]) :-
asserta(is(Subj, What)),
write('ok'),
write('\n').
rules(['Is', Subj, a, What]) :-
(is(Subj, Z) ; a(Z, What)) -> (write('Yes.'), nl)
; (write('Unknown.'), nl).
It doesn't go into any of the cases, it will just say true and terminate when given a statement. What am I doing wrong?