在序言中建立专家系统的问题

Problem with building an expert system in prolog

在 prolog 中编译此代码时,我不断遇到语法错误。我是编程新手,所以我不太明白。有人可以帮我调试我哪里出错了吗?专家系统旨在将动物分为脊椎动物和无脊椎动物。这是我目前拥有的代码:

:-dynamic known/3
top_goal(X):-animal(X).

%Animals and their classifications
animal(lion):-
    type(vertebrate),
    color(brown).

animal(bee):-
    type(invertebrate),
    color(yellow).

animal(crickets):-
    type(invertebrate),
    color(green).

%background information about vertebrates and invertebrates.

animal(vertebrate):-
    vertebral_column(present),
    nerve_cord(dorsal_and_hollow),
    skeleton(internal),
    heart(located_on_right_side),
    haemoglobin(present_in_red_blood_cells).

animal(invertebrate):-
    vertebral_column(absent),
    skeleton(external),
    heart(located_on_dorsal_side),
    haemoglobin(dissolved_in_plasma).

%Ask rules
animal(X):-ask(type,X).
animal(X):-ask(color,X).
animal(X):-ask(sound,X).

ask(A,V):-
    write(A:V),%ask user
    write('?:'),
    read(Y),%get the answer
    asserta(known(Y,A,V),%remember it
    Y==yes.%succeed or fail

solve:-
    retractall(known(_,_,)),
    top_goal(X),
    write('The animal is '),write(X),nl.

solve:-
    write('This animal is unknown '),nl.

你有一些错别字。

ask(A,V):-
    write(A:V),%ask user
    write('?:'),
    read(Y),%get the answer
    asserta(known(Y,A,V)), %remember it ***missing ')'
    Y==yes.%succeed or fail

这里

solve:-
    retractall(known(_,_,_)), % *** missing _
    top_goal(X),
    write('The animal is '),write(X),nl.

然后缺少一些代码:color/1、haemoglobin/1、heart/1、 nerve_cord/1, skeleton/1, top_goal/1, type/1, vertebral_column/1.