Prolog脚本未正确加载

Prolog脚本未正确加载,prolog,Prolog,我试图将hw4.pl加载到swipl中,但它似乎不起作用。我试过了 swipl -s hw4.pl 在序言中 [hw4]. ['hw4']. consult('hw4.pl'). 它会说“是”,但我看不到“符合”这一行 当我尝试查询时: ?- user(@anna). ERROR: toplevel: Undefined procedure: user/1 (DWIM could not correct goal) 我的hw4.pl: assert(user(@anna)). asser

我试图将hw4.pl加载到swipl中,但它似乎不起作用。我试过了

swipl -s hw4.pl
在序言中

[hw4]. 
['hw4'].
consult('hw4.pl').
它会说“是”,但我看不到“符合”这一行

当我尝试查询时:

?- user(@anna).
ERROR: toplevel: Undefined procedure: user/1 (DWIM could not correct goal)
我的hw4.pl:

assert(user(@anna)).
assert(user(@tom)).
assert(user(@jeremy)).
assert(user(@lawrence)).

知道为什么吗?提前谢谢

以下是我尝试加载您的文件时得到的结果:

ERROR: hw4.pl:1:13: Syntax error: Operator expected
ERROR: hw4.pl:2:13: Syntax error: Operator expected
ERROR: hw4.pl:3:13: Syntax error: Operator expected
ERROR: hw4.pl:4:13: Syntax error: Operator expected
我很确定
@
是无效的语法。将文件更改为

assert(user(anna)).
assert(user(tom)).
assert(user(jeremy)).
assert(user(lawrence)).

你应该很好。

如果我真的想要“@”字符,我可以做一些类似assert(user(“@anna”)的事情吗?@Nevvea是的,如果你用单引号括住原子名称,它可以包含任意字符;如果你想要一个单引号,你可以用反斜杠转义:
'atom with\'in it'