我是prolog的新手,已经做了一个简单的prolog程序,我不断得到这些错误,还有更多,但我并不认为所有这些都是必需的,因为它们都是一样的:
Clauses of door/2 are not together in the source-file
Warning: c:/users/hani cassidy/desktop/test/test.pl:27:
Clauses of room/1 are not together in the source-file
Warning: c:/users/hani cassidy/desktop/test/test.pl:28:
Clauses of door/2 are not together in the source-file
Warning: c:/users/hani cassidy/desktop/test/test.pl:34:
Clauses of location/2 are not together in the source-file
Warning: c:/users/hani cassidy/desktop/test/test.pl:36:
Clauses of location/3 are not together in the source-file
Warning: c:/users/hani cassidy/desktop/test/test.pl:37:
Clauses of location/2 are not together in the source-file
Warning: c:/users/hani cassidy/desktop/test/test.pl:38:
Clauses of location/3 are not together in the source-file
Warning: c:/users/hani cassidy/desktop/test/test.pl:40:
Clauses of location/2 are not together in the source-file
Warning: c:/users/hani cassidy/desktop/test/test.pl:42:
Clauses of location/3 are not together in the source-file
Warning: c:/users/hani cassidy/desktop/test/test.pl:49:
Clauses of location/2 are not together in the source-file
Warning: c:/users/hani cassidy/desktop/test/test.pl:51:
Singleton variables: [North,Table]
Warning: c:/users/hani cassidy/desktop/test/test.pl:51:
Clauses of location/3 are not together in the source-file
Warning: c:/users/hani cassidy/desktop/test/test.pl:52:
Singleton variables: [East,Table]
Warning: c:/users/hani cassidy/desktop/test/test.pl:53:
Singleton variables: [South,Table]
Warning: c:/users/hani cassidy/desktop/test/test.pl:54:
Singleton variables: [Table]
Warning: c:/users/hani cassidy/desktop/test/test.pl:55:
Singleton variables: [Centre,Table]
ERROR: c:/users/hani cassidy/desktop/test/test.pl:59:20: Syntax error: Operator expected
Warning: c:/users/hani cassidy/desktop/test/test.pl:67:
我注意到它们都是一样的,所以我知道每个人都会犯同样的错误但是我不能解决我是什么,因为我是prolog的新手,我的代码部分如下: 门(大厅,卧室A)。 门(大厅,卧室B)。 门(hall,sittingroomkitchen)。
%Bedroom B – Hall
room(bedroomB).
door(bedroomB, hall).
%Sitting room / Kitchen – Hall, Bathroom
room(sittingroomkitchen).
door(sittingroomkitchen, hall).
door(sittingroomkitchen, bathroom).
%Bathroom – Sitting room/Kitchen
room(bathroom).
door(bathroom, sittingroomkitchen).
%Each Bedroom = Desk, Bed, Pillow, Duvet, Wardrobe
location(bed, bedroomA).
location(pillow, bed, bedroomA).
location(duvet, bed, bedroomA).
location(wardrobe, bedroomA).
location(desk, bedroomA).
location(phone, underPillow, bedroomA).
location(bed, bedroomB).
location(pillow, bed, bedroomB).
如果我需要提供更多内容,这只是一个片段。
答案 0 :(得分:1)
关于" ......的条款不在源文件中#34;警告,大多数(如果不是全部)Prolog系统期望同一谓词的子句在源文件中一起存在。解决方案是为其子句分散在源文件中的谓词添加discontiguous/1
指令,或将所有子句一起移动。对于第一个解决方案,在这些谓词的任何子句之前写入:
:- discontiguous([
room/1, door/2, location/2, location/3
]).
不连续的谓词有时是由于代码中的拼写错误(例如,意外忘记了子句中的参数)而且永远不应该被忽略。