Search code examples
prologswi-prologaleph-ilpinductive-logic-programming

Not getting a theory in Aleph for SWI Prolog


I'm trying to get Aleph to work and induce a simple theory: grandparent(X,Z):- father(X, Y), father(Y, Z). However i get back an atom (e.g. grandparent(john,johnJuniorJunior)). Hope somebody can help. Note that Aleph for SWI uses a single file as input. Cheers/JC

My program:

:- use_module(library(aleph)).
:- aleph.

:- modeh(*,grandparent(+person,-person)).
:- modeb(*,father(+person,-person)).

:-begin_bg.
person(john).
person(johnJunior).
person(johnJuniorJunior).
person(jack).
person(jackJunior).
person(jackJuniorJunior).
father(johnJunior, john).
father(johnJuniorJunior, johnJunior).
father(jackJunior, jack).
father(jackJuniorJunior, jackJunior).

:-determination(grandparent/2,father/2).

:-end_bg.

:-begin_in_pos.
grandparent(john, johnJuniorJunior).
grandparent(jack, jackJuniorJunior).
:-end_in_pos.

:-begin_in_neg.
grandparent(jack, john).
:-end_in_neg.

:-aleph_read_all.

My output:

[theory]

[Rule 1] [Pos cover = 1 Neg cover = 0]
grandparent(john,johnJuniorJunior).

[Rule 2] [Pos cover = 1 Neg cover = 0]
grandparent(jack,jackJuniorJunior).

[time taken] [0.0]
[total clauses constructed] [2]
true.

Solution

  • Changing

    :- modeh(*,grandparent(+person,-person)).
    :- modeb(*,father(+person,-person)).
    

    To

    :- modeh(*,grandparent(+person,+person)).
    :- modeb(*,father(-person,-person)).
    

    Solved my issue. Thanks Fabrizio!