logic-and-learning-lab / Popper

An inductive logic programming system
MIT License
206 stars 36 forks source link

What does max_clauses(N) do exactly? #48

Closed youssefmahmoud89 closed 1 year ago

youssefmahmoud89 commented 2 years ago

I am trying to learn a program that does addition by succession, and I am trying to limit the number of rules generated (which is supposedly what max_clauses(N) is for) to 2 clauses. I have added 'max_clauses(2).' to my bias file, but I am still getting programs that are more than 2 rules. Is there a way to limit this? or am I misusing the max_clauses(N) parameter?

ex prog generated:

y_plus(A,B,C):- y_succ(A,C),y_prec(B,C). y_plus(A,B,C):- y_succ(B,C),y_prec(A,C). y_plus(A,B,C):- y_prec(B,D),y_succ(D,C),y_prec(A,D). y_plus(A,B,C):- y_prec(B,D),y_succ(D,B),y_succ(A,C). y_plus(A,B,C):- y_prec(B,D),y_succ(D,C),y_succ(A,D). y_plus(A,B,C):- y_succ(B,D),y_plus(D,A,C). y_plus(A,B,C):- y_succ(A,D),y_plus(B,D,C).

my bias file is as follows:

max_clauses(2). max_vars(5). max_body(3). enable_recursion.

head_pred(y_plus,3). body_pred(y_plus,3). body_pred(y_succ,2). body_pred(y_prec,2).

direction(y_plus,(in,in,out)). direction(y_succ,(in,out)). direction(y_prec,(in,out)).

type(y_plus,(integer,integer,integer)). type(y_succ,(integer,integer)). type(y_prec,(integer,integer)).

celinehocquette commented 2 years ago

Yes, max_clauses/1 has changed meaning in the new version (#45) and does not work as you intended anymore.

JeanChristopheRohner commented 2 years ago

I'm also a bit confused by the max_clauses/1 setting. I have recursion enabled but i get more than the number of intended clauses (6 instead of 5). Still really cool though that Popper can do this :-)

The program i get is:

********** SOLUTION **********
Precision:1.00 Recall:1.00 TP:24 FN:0 TN:26 FP:0 Size:15
anchestor(A,B):- mother(A,B).
anchestor(A,B):- admother(A,B).
anchestor(A,B):- father(A,B).
anchestor(A,B):- mother(A,C),father(C,B).
anchestor(A,B):- father(A,C),anchestor(C,B).
anchestor(A,B):- mother(A,C),anchestor(C,B).

My bias.pl

enable_pi.
enable_recursion.

max_vars(3).
max_body(2).
max_clauses(5).

head_pred(anchestor,2).
body_pred(father,2).
body_pred(mother,2).
body_pred(admother,2).

direction(anchestor,(in,out)).
direction(mother,(in,out)).
direction(admother,(in,out)).
direction(father,(in,out)).

My bk.pl

father(orville, abe).
father(abe, homer).
father(homer, lisa).
father(homer, bart).
father(clancy, marge).
father(clancy, selma).

mother(mrsolsen, mona).
mother(mona, homer).
mother(marge, bart).
mother(marge, lisa).

admother(selma, ling).

My exs.pl

pos(anchestor(orville,abe)).
pos(anchestor(abe,homer)).
pos(anchestor(homer,lisa)).
pos(anchestor(homer,bart)).
pos(anchestor(clancy,marge)).
pos(anchestor(clancy,selma)).
pos(anchestor(mona,homer)).
pos(anchestor(marge,bart)).
pos(anchestor(marge,lisa)).
pos(anchestor(orville,homer)).
pos(anchestor(orville,lisa)).
pos(anchestor(orville,bart)).
pos(anchestor(abe,lisa)).
pos(anchestor(abe,bart)).
pos(anchestor(clancy,bart)).
pos(anchestor(clancy,lisa)).
pos(anchestor(mona,lisa)).
pos(anchestor(mona,bart)).
pos(anchestor(mrsolsen,mona)).
pos(anchestor(mrsolsen,homer)).
pos(anchestor(mrsolsen,lisa)).
pos(anchestor(mrsolsen,bart)).
pos(anchestor(clancy, ling)).
pos(anchestor(selma, ling)).

neg(anchestor(abe,orville)).
neg(anchestor(homer,abe)).
neg(anchestor(lisa,homer)).
neg(anchestor(bart,homer)).
neg(anchestor(marge,clancy)).
neg(anchestor(homer,mona)).
neg(anchestor(bart,marge)).
neg(anchestor(lisa,marge)).
neg(anchestor(homer,orville)).
neg(anchestor(lisa,orville)).
neg(anchestor(bart,orville)).
neg(anchestor(lisa,abe)).
neg(anchestor(bart,abe)).
neg(anchestor(bart,clancy)).
neg(anchestor(lisa,clancy)).
neg(anchestor(lisa,mona)).
neg(anchestor(bart,mona)).
neg(anchestor(bart, lisa)).
neg(anchestor(marge, homer)).
neg(anchestor(abe, clancy)).
neg(anchestor(mona,mrsolsen)).
neg(anchestor(homer,mrsolsen)).
neg(anchestor(lisa,mrsolsen)).
neg(anchestor(bart, mrsolsen)).
neg(anchestor(ling, clancy)).
neg(anchestor(ling, selma)).
andrewcropper commented 2 years ago

As @celinehocquette said, the meaning of max_clauses has changed with the latest version.

I will make a note of this confusion and will push a fix in the next 1-3 weeks so that max_clauses defines the maximum number of rules/clauses allowed in a theory.