代码如下:
DOMAINS
name = valentin; leonid; valery; andrew; michael
faculty = physics; history; biology; geography
instrument = sax; piano; bass; drums
student = student(name, instrument, faculty)
PREDICATES
nondeterm student(name, instrument, faculty)
CLAUSES
student(michael, sax, _).
student(_, piano, physics).
student(_, drums, _) :- student(leonid, _, _); student(michael, _, _); student(valentin, _, _); student(andrew, _, _).
student(_, _, geography) :- student(michael, _, _); student(valentin, _, _); student(valery, _, _); student(andrew, _, _).
student(michael, _, _) :- student(_, _, physics); student(_, _, geography); student(_, _, biology).
student(andrew, _, _) :- student(_, _, physics); student(_, _, history); student(_, _, geography).
student(andrew, _, _) :- student(_, sax, _); student(_, bass, _); student(_, drums, _).
student(valery, _, _) :- student(_, _, geography); student(_, _, biology); student(_, _, history).
student(_, drums, _) :- student(_, _, physics); student(_, _, geography); student(_, _, biology).
student(leonid, _, _) :- student(_, sax, _); student(_, piano, _); student(_, drums, _).
GOAL
student(valentin, Instrument, Faculty).
我使用Visual Prolog 5。 这段代码编译,但编译器说有未绑定的变量: _行中的变量:
student(michael, sax, _).
student(_, piano, physics).
和第二个_变量在地理位置原子之前的行:
student(_, _, geography) :- student(michael, _, _); student(valentin, _, _); student(valery, _, _); student(andrew, _, _).
是否可以使此代码有效?