如何在SWI-Prolog中使用Aleph来获得理论



我正试图通过使用带有SWI-Prolog(SWI-PrologPack(的Aleph归纳逻辑编程系统来获得一个理论

我的代码是

:- use_module(library(aleph)).
:- if(current_predicate(use_rendering/1)).
:- use_rendering(prolog).
:- endif.
:- aleph.
:- modeh(*,publication_nbpages(-publication,+pubnbpages)).
:- modeb(*,book_chapters_nbPages(-book,+nbpages)).

:-determination(publication_nbpages/2,book_chapters_nbPages/2).

:-begin_bg.
:- dynamic publication_title/2.
:- dynamic book2publication/2.
:- dynamic book_title/2.
publication_title(P,A) :- book2publication(B,P), book_title(B,A).
:-end_bg.
:-begin_in_pos.
book2publication(book0,publication0).
book(book0).
booktitle(article).
book_title(book0,article).
chapters(chapter0).
chapters(chapter1).
book_chapters(book0,[chapter0,chapter1]).
nbpages(13).
nbpages(1).
book_chapters_nbPages(book0,[13,1]).
publication(publication0).
publicationtitle(article).
publication_title(publication0,article).
pubnbpages(14).
publication_nbpages(publication0,14).
:-end_in_pos.
:-begin_in_neg.
publication_nbpages(book0,1).
publication_nbpages(book0,13).
publication_nbpages(book0,article).
publication_nbpages(book0,publication0).
:-end_in_neg.
:-aleph_read_all.

我想要的是:

publication_nbpages(P,N) :- book2publication(B,P), book_chapters_nbPages(B,N).

然而,我得到的结果是:

[Rule 1] [Pos cover = 1 Neg cover = 0]
book2publication(book0,publication0).
[Rule 2] [Pos cover = 1 Neg cover = 0]
book(book0).
[Rule 3] [Pos cover = 1 Neg cover = 0]
booktitle(article).
[Rule 4] [Pos cover = 1 Neg cover = 0]
book_title(book0,article).
[Rule 5] [Pos cover = 1 Neg cover = 0]
chapters(chapter0).
[Rule 6] [Pos cover = 1 Neg cover = 0]
chapters(chapter1).
[Rule 7] [Pos cover = 1 Neg cover = 0]
book_chapters(book0,[chapter0,chapter1]).
[Rule 8] [Pos cover = 1 Neg cover = 0]
nbpages(13).
[Rule 9] [Pos cover = 1 Neg cover = 0]
nbpages(1).
[Rule 10] [Pos cover = 1 Neg cover = 0]
book_chapters_nbPages(book0,[13,1]).
[Rule 11] [Pos cover = 1 Neg cover = 0]
publication(publication0).
[Rule 12] [Pos cover = 1 Neg cover = 0]
publicationtitle(article).
[Rule 13] [Pos cover = 1 Neg cover = 0]
publication_title(publication0,article).
[Rule 14] [Pos cover = 1 Neg cover = 0]
pubnbpages(14).
[Rule 15] [Pos cover = 1 Neg cover = 0]
publication_nbpages(publication0,14).

这太奇怪了,我想要一个一般的理论,但SWI Prolog只是给了我所有的规则。

似乎缺少一个book2publication(B,P)的确定声明。也许添加这些会有所帮助。您还可以在模式声明中尝试使用不同的+/-/#。

干杯/JCR

相关内容

  • 没有找到相关文章

最新更新