Closed seddiqbenterki closed 1 year ago
Hi Seddiq,
It seems there is an issue with your bk. Should the last line of subtract1/3 be instead the following?
nonvar(X),nonvar(Result)-> Y is X-Result.
@seddiqbenterki did Céline's comment help?
@andrewcropper Yes it's very helpful thank you @celinehocquette
I initially used Prolog to establish an expected relation for calculating speed through division and subtraction. Following this successful validation, I turned to Popper to automate the learning process. However, when I tasked Popper with learning the program, it encountered an error. the description contains all the information I have used to learn.
expected result fact(A,B,C,D,E):- subtract1(A,B,F),subtract1(D,C,G),integer_divide(F,G,E). %error 18:09:20 Searching programs of size: 3 18:09:21 Searching programs of size: 4 Traceback (most recent call last): File "/home/seddiq/Desktop/Popper/popper.py", line 8, in
prog, score, stats = learn_solution(settings)
File "/home/seddiq/Desktop/Popper/popper/loop.py", line 414, in learn_solution
timeout(settings, popper, (settings,), timeout_duration=int(settings.timeout),)
File "/home/seddiq/Desktop/Popper/popper/util.py", line 54, in timeout
result = func(*args, kwargs)
File "/home/seddiq/Desktop/Popper/popper/loop.py", line 214, in popper
pruned_sub_incomplete = explain_incomplete(settings, generator, explainer, prog, directions, new_cons, all_handles, bad_handles, new_ground_cons)
File "/home/seddiq/Desktop/Popper/popper/loop.py", line 23, in explain_incomplete
for subprog, unsat_body in explainer.explain_totally_incomplete(prog, directions):
File "/home/seddiq/Desktop/Popper/popper/explain.py", line 141, in explain_totally_incomplete_aux
xs = list(self.explain_totally_incomplete_aux(subprog, directions, depth+1, sat, unsat))
File "/home/seddiq/Desktop/Popper/popper/explain.py", line 136, in explain_totally_incomplete_aux
if self.tester.is_sat(test_prog):
File "/home/seddiq/Desktop/Popper/popper/tester.py", line 150, in is_sat
return self.bool_query(x)
File "/home/seddiq/Desktop/Popper/popper/tester.py", line 24, in bool_query
return len(list(self.prolog.query(query))) > 0
File "/home/seddiq/.local/lib/python3.10/site-packages/pyswip/prolog.py", line 128, in call
raise PrologError("".join(["Caused by: '", query, "'. ",
pyswip.prolog.PrologError: Caused by: 'posindex(,fact(A,B,C,D,E)), subtract1(C,F,A),!'. Returned: 'error(existence_error(procedure, /(-, 2)), context(:(system, /(, 1)), _1198))'
example
pos(fact(1,76,1,4,25)).
Bk**
integer_divide(Dividend, Divisor, Quotient) :-
((nonvar(Dividend),nonvar(Divisor));(nonvar(Dividend),nonvar(Quotient));(nonvar(Quotient),nonvar(Divisor))),
%fail-> (var(Dividend),var(Divisor)),
nonvar(Divisor),nonvar(Dividend),Divisor =\= 0-> Quotient is Dividend // Divisor; nonvar(Quotient),nonvar(Divisor),Dividend=\= 0->Dividend is Quotient * Divisor; nonvar(Dividend),nonvar(Quotient),Quotient =\= 0->Divisor is Dividend //Quotient. %Quotient is 0. tail([|T],T). head([H|],H). subtract1(X, Y, Result) :- ((nonvar(X),nonvar(Y));(nonvar(X),nonvar(Result));(nonvar(Result),nonvar(Y))), %(nonvar(X),nonvar(Y)), nonvar(X),nonvar(Y)-> Result is X - Y; nonvar(Result),nonvar(Y)->X is Result + Y; nonvar(X),nonvar(Result)->X-Result. %Quotient is 0. %bias %% speed up example
max_vars(7). max_body(5). max_clauses(2).
bias
head_pred(fact,5). body_pred(integer_divide,3). %body_pred(tail,2). %body_pred(head,2). body_pred(subtract1,3). direction(fact,(in,in,in,in,out)). direction(integer_divide,(in,in,out)). direction(tail,(in,out)). direction(head,(in,out)). direction(substract1,(in,in,out)). type(fact,(integer,integer,integer,integer,integer)). type(integer_divide,(integer,integer,integer)).type(tail,(list,list)). type(head,(list,integer)). type(substract1,(integer,integer,integer)).