【发布时间】:2014-02-04 21:42:24
【问题描述】:
只是对这个序言脚本有点困惑..
/*frame representation */
frame(name(bird), isa(animal), hasproperty([fly, feathers, sing])).
frame(name(canary),isa(bird), hasproperty([yellow, nervous, easily_frightened])).
frame(name(tweety), isa(canary), hasproperty([baby, my_pet])).
frame(name(barn_owl), isa(bird), hasproperty([nocturnal,large_eyes])).
frame(name(barny), isa(barn_owl), hasproperty([sick,forward_facing])).
/* inheritance -using recursion*/
inherit(Concept, Prop):- frame(name(Concept), _, hasproperty(Prop)).
inherit(Concept, Prop):-
frame(name(Concept), isa(Parent), _),
write(Parent), nl,
frame(name(Parent), _, hasproperty(PP)),
write(PP), nl,
inherit(Parent, NewProp).
我了解它检查概念是否具有特定属性的第一条规则,但是我不太了解第二条规则.. 我知道如果它继承的框架具有特定属性,它应该可以解决但我不确定它是如何检查的,特别是当属性名称从 PP 到 NewProp 不同时。如果有两个同名的规则,prolog 如何知道在这个脚本中执行哪个规则?为任何帮助干杯!
【问题讨论】:
-
在回答您的第二个问题时,Prolog 按给定顺序查询规则。将同一谓词的附加子句视为“或”。
-
对!知道了!谢谢!
-
代码实际上应该做什么?您发现了一个差异,即单例
NewProp变量。Prop变量也是单例的。所以逻辑可能有问题。
标签: inheritance recursion prolog artificial-intelligence frame