所以我有一组事实和一个用 ASP 编写的要在 DLV 上运行的查询,
%Q1 : Find the implicit "is_a" relationship between terms
%ex: if term A is is_a term B, term B is_a term C, then term A is_a term C
%is_a One level
triple1(TermA, "go:is_a", TermB):- triple(TermA, "go:is_a", TermB), TermA != TermB.
%is_a MultiLevel
triple1(TermA, "go:is_a", TermC) :-
triple(TermA, "go:is_a", TermB),
triple(TermB, "go:is_a", TermC),
TermA != TermC.
triple1(TermA, "go:is_a", TermC) :-
triple1(TermA, "go:is_a", TermB),
triple1(TermB, "go:is_a", TermC),
TermA != TermC.
然后我想计算我的答案集中有多少triple1
三元组不包括事实。然后我做了这种聚合#count查询:
triple1nr(X) :- #count{TermA : triple1(TermA,"go:is_a",TermC)} = X.
但我得到的只是变量的数量TermA
作为我的结果出现。当我将查询更改为这样时:
triple1nr(X) :- #count{triple1(TermA,"go:is_a",TermC)} = X.
它给了我错误。我该怎么做这个查询?