Skip to content

Commit 7f4ac7b

Browse files
committed
merged
2 parents 9942aca + c6406e4 commit 7f4ac7b

File tree

13 files changed

+29821
-122
lines changed

13 files changed

+29821
-122
lines changed

README.md

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# POPPER IS STILL A MAJOR WORK-IN-PROGRESS. BE PREPARED FOR BUGS, DEMONS, AND BACKWARDS-BREAKING CHANGES!
2-
31
# Popper
42

53
Popper is an inductive logic programming (ILP) system.
64
If you use Popper for research, please cite the paper [learning programs by learning from failures](https://arxiv.org/abs/2005.02259).
7-
5+
Popper is still a major work-in-progress, so please notify us of bugs or usability issues.
86

97
## Requirements
108

@@ -22,30 +20,50 @@ You can run Popper `python popper.py <input dir>`.
2220
For instance, running the command `python popper.py examples/dropk` produces the output:
2321

2422
```prolog
25-
BEST PROGRAM:
2623
f(A,B,C):-tail(A,C),one(B)
27-
f(A,B,C):-f(A,E,D),tail(D,C),decrement(B,E)
28-
TP: 10, FN: 0, TN: 0+, FP: 0+
24+
f(A,B,C):-decrement(B,E),f(A,E,D),tail(D,C)
25+
TP: 10, FN: 0, TN: 10, FP: 0
2926
```
3027

3128
Running the command `python popper.py examples/trains` produces the output:
3229

3330
```prolog
34-
BEST PROGRAM:
35-
f(A):-three_wheels(B),long(C),roof_closed(C),has_car(A,B),has_car(A,C)
36-
TP: 5, FN: 0, TN: 0+, FP: 0+
31+
f(A):-long(B),roof_closed(B),has_car(A,B),three_wheels(C),has_car(A,C)
32+
TP: 5, FN: 0, TN: 5, FP: 0
3733
```
3834

3935
Take a look at the examples folder for examples.
4036

41-
Note that in the above output, some of the outcomes are `N+`. The reason is that, by default, Popper does not test all the examples during the testing stage, and instead performs *minimal testing*. To test on all the examples, call Popper with the `--test-all` flag.
42-
43-
For instance, running the command `python popper.py examples/trains --test-all` produces the output:
37+
Popper is an anytime algorithm. To see the intermediate solutions use the `--info` flag. For instance, running the command `python popper.py examples/trains2 --info` produces the output:
4438

4539
```prolog
46-
BEST PROGRAM:
47-
f(A):-long(B),has_car(A,C),roof_closed(B),has_car(A,B),three_wheels(C)
48-
TP: 5, FN: 0, TN: 5, FP: 0
40+
NEW BEST PROG 1:
41+
f(A):-short(B),has_car(A,B)
42+
TP: 683, FN: 109, TN: 33, FP: 175
43+
44+
NEW BEST PROG 2:
45+
f(A):-roof_closed(B),has_car(A,B)
46+
TP: 745, FN: 47, TN: 36, FP: 172
47+
48+
NEW BEST PROG 3:
49+
f(A):-roof_open(B),has_car(A,B)
50+
TP: 731, FN: 61, TN: 172, FP: 36
51+
52+
NEW BEST PROG 95:
53+
f(A):-roof_closed(C),roof_open(B),has_car(A,C),has_car(A,B)
54+
f(A):-has_load(C,B),has_car(A,C),three_load(B),roof_open(C)
55+
TP: 721, FN: 71, TN: 208, FP: 0
56+
57+
NEW BEST PROG 382:
58+
f(A):-has_car(A,C),roof_closed(B),has_car(A,B),roof_open(C)
59+
f(A):-rectangle(D),has_load(C,B),has_car(A,C),has_load(E,D),triangle(B),has_car(A,E)
60+
TP: 761, FN: 31, TN: 208, FP: 0
61+
62+
BEST PROG 1271:
63+
f(A):-roof_closed(C),roof_open(B),has_car(A,C),has_car(A,B)
64+
f(A):-has_car(A,B),three_load(C),roof_open(B),has_load(B,C)
65+
f(A):-rectangle(D),has_car(A,B),has_load(B,C),triangle(C),has_load(E,D),has_car(A,E)
66+
TP: 792, FN: 0, TN: 208, FP: 0
4967
```
5068

5169
# Popper settings
@@ -67,3 +85,5 @@ To run with statistics use the flag `--stats`
6785
To run with a maximum learning time use the flag `--eval-timeout`.
6886

6987
To run in debug mode use the flag `--debug`
88+
89+
To run in information mode use the flag `--debug`

examples/iggp-minimal-decay/bias.pl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
%% SOLUTION:
2-
%% next_value(A,B):-does(A,C,D),c_pressButton(D),c5(B),c_player(C)
3-
%% next_value(A,B):-c_player(E),my_succ(B,C),my_true_value(A,C),does(A,E,D),c_noop(D)
4-
%% Total programs: 24104
1+
%% BEST PROGRAM:
2+
%% next_value(A,B):-c_player(C),c5(B),c_pressButton(D),does(A,C,D)
3+
%% next_value(A,B):-my_succ(B,D),my_true_value(A,D),c_player(C),c_noop(E),does(A,C,E)
4+
%% TP: 8, FN: 0, TN: 46, FP: 0
5+
6+
%% Total programs: 2604
57
%% Generate:
6-
%% Called: 24114 times Total: 29.08 Mean: 0.001 Max: 0.026
8+
%% Called: 2614 times Total: 2.31 Mean: 0.001 Max: 0.012
79
%% Test:
8-
%% Called: 24104 times Total: 18.17 Mean: 0.001 Max: 0.031
10+
%% Called: 2604 times Total: 1.45 Mean: 0.001 Max: 0.040
911
%% Build_Rules:
10-
%% Called: 24103 times Total: 4.01 Mean: 0.000 Max: 0.006
12+
%% Called: 2603 times Total: 1.37 Mean: 0.001 Max: 0.007
1113
%% Ground:
12-
%% Called: 24103 times Total: 0.84 Mean: 0.000 Max: 0.003
14+
%% Called: 2603 times Total: 0.20 Mean: 0.000 Max: 0.003
1315
%% Add:
14-
%% Called: 24103 times Total: 27.83 Mean: 0.001 Max: 0.006
15-
%% Total operation time: 79.93s
16-
%% Total execution time: 80.51s
16+
%% Called: 2603 times Total: 1.56 Mean: 0.001 Max: 0.002
17+
%% Test_Individual_Rules.Is_Totally_Incomplete:
18+
%% Called: 1989 times Total: 0.10 Mean: 0.000 Max: 0.000
19+
%% Total operation time: 7.00s
20+
%% Total execution time: 7.00s
1721

1822
max_clauses(2).
1923
max_vars(5).
@@ -26,10 +30,10 @@
2630
body_pred(c_pressButton,1).
2731
body_pred(c_noop,1).
2832
body_pred(c_player,1). % comment to make unsat
29-
body_pred(c1,1). % comment to make easier to solve
30-
body_pred(c2,1). % comment to make easier to solve
31-
body_pred(c3,1). % comment to make easier to solve
32-
body_pred(c4,1). % comment to make easier to solve
33+
body_pred(c1,1).
34+
body_pred(c2,1).
35+
body_pred(c3,1).
36+
body_pred(c4,1).
3337
body_pred(c5,1).
3438

3539
type(next_value,(ex,int)).
@@ -45,10 +49,6 @@
4549
type(c4,(int,)).
4650
type(c5,(int,)).
4751

48-
functional(my_succ,2).
49-
irreflexive(my_succ,2).
50-
functional(my_true_value,2).
51-
5252
%% HACK BECAUSE WE DO NOT LEARN FROM INTERPRETATIONS
5353
:-
5454
clause(C),

examples/iggp-rps/bias.pl

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1-
%% SOLUTION:
2-
%% next_score(A,B,C):-different(B,D),my_true_score(A,B,C),wins(A,D)
3-
%% next_score(A,B,C):-my_true_score(A,B,D),wins(A,B),my_succ(D,C)
4-
%% next_score(A,B,C):-does(A,B,D),different(E,B),my_true_score(A,B,C),does(A,E,D)
5-
%% Total programs: 8444
1+
%% BEST PROGRAM:
2+
%% next_score(A,B,C):-my_true_score(A,B,D),my_succ(D,C),wins(A,B)
3+
%% next_score(A,B,C):-wins(A,D),my_true_score(A,B,C),different(B,D)
4+
%% next_score(A,B,C):-does(A,D,E),my_true_score(A,B,C),different(B,D),does(A,B,E)
5+
%% TP: 108, FN: 0, TN: 356, FP: 0
6+
7+
%% Total programs: 1607
68
%% Generate:
7-
%% Called: 8456 times Total: 13.57 Mean: 0.002 Max: 0.246
9+
%% Called: 1619 times Total: 4.64 Mean: 0.003 Max: 0.041
810
%% Test:
9-
%% Called: 8444 times Total: 8.76 Mean: 0.001 Max: 0.032
11+
%% Called: 1607 times Total: 7.98 Mean: 0.005 Max: 0.048
1012
%% Build_Rules:
11-
%% Called: 8443 times Total: 1.37 Mean: 0.000 Max: 0.006
13+
%% Called: 1606 times Total: 3.20 Mean: 0.002 Max: 0.009
1214
%% Ground:
13-
%% Called: 8443 times Total: 0.67 Mean: 0.000 Max: 0.003
15+
%% Called: 1606 times Total: 0.26 Mean: 0.000 Max: 0.003
1416
%% Add:
15-
%% Called: 8443 times Total: 9.99 Mean: 0.001 Max: 0.005
16-
%% Total operation time: 34.38s
17-
%% Total execution time: 34.70s
17+
%% Called: 1606 times Total: 1.83 Mean: 0.001 Max: 0.004
18+
%% Test_Individual_Rules.Is_Totally_Incomplete:
19+
%% Called: 1539 times Total: 0.05 Mean: 0.000 Max: 0.001
20+
%% Total operation time: 17.96s
21+
%% Total execution time: 18.08s
1822

1923
max_clauses(4).
2024
max_vars(5).
2125
max_body(7).
2226

2327
head_pred(next_score,3).
24-
%% body_pred(draws,2).
2528
body_pred(wins,2).
26-
%% body_pred(loses,2).
2729
body_pred(my_true_score,3).
2830
body_pred(my_succ,2).
2931
body_pred(does,3).
3032
body_pred(beats,2).
31-
%% body_pred(player,1).
33+
body_pred(player,1).
3234
body_pred(different,2).
3335

3436
type(next_score,(ex,player,int)).
@@ -42,11 +44,6 @@
4244
type(player,(player,)).
4345
type(different,(player,player)).
4446

45-
functional(beats,2).
46-
functional(my_succ,2).
47-
irreflexive(my_succ,2).
48-
irreflexive(beats,2).
49-
5047
%% HACK BECAUSE WE DO NOT LEARN FROM INTERPRETATIONS
5148
:-
5249
clause(C),

examples/trains/bias.pl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
%% f(A) :- has_car(A,C),long(C),roof_closed(C),has_car(A,B),three_wheels(B).
33
%% 0.83s user 0.03s system 99% cpu 0.860 total
44

5-
max_clauses(4).
5+
max_clauses(3).
66
max_vars(5).
7-
max_body(5).
7+
max_body(6).
88

99
head_pred(f,1).
1010
body_pred(has_car,2).
@@ -18,6 +18,7 @@
1818
body_pred(zero_load,1).
1919
body_pred(one_load,1).
2020
body_pred(two_load,1).
21+
body_pred(three_load,1).
2122
body_pred(circle,1).
2223
body_pred(triangle,1).
2324
body_pred(rectangle,1).
@@ -31,9 +32,10 @@
3132
type(three_wheels,(car,)).
3233
type(roof_open,(car,)).
3334
type(roof_closed,(car,)).
34-
type(zero_load,(car,)).
35-
type(one_load,(car,)).
36-
type(two_load,(car,)).
35+
type(zero_load,(load,)).
36+
type(one_load,(load,)).
37+
type(two_load,(load,)).
38+
type(three_load,(load,)).
3739
type(circle,(load,)).
3840
type(triangle,(load,)).
3941
type(rectangle,(load,)).
@@ -50,6 +52,7 @@
5052
direction(zero_load,(in,)).
5153
direction(one_load,(in,)).
5254
direction(two_load,(in,)).
55+
direction(three_load,(in,)).
5356
direction(circle,(in,)).
5457
direction(triangle,(in,)).
5558
direction(rectangle,(in,)).

examples/trains2/bias.pl

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
%% BEST PROGRAM:
2+
%% f(A):-has_car(A,B),roof_open(C),roof_closed(B),has_car(A,C)
3+
%% f(A):-three_load(B),roof_open(C),has_car(A,C),has_load(C,B)
4+
%% f(A):-has_load(C,B),triangle(D),has_car(A,E),rectangle(B),has_load(E,D),has_car(A,C)
5+
%% TP: 792, FN: 0, TN: 208, FP: 0
6+
7+
%% Total programs: 1274
8+
%% Generate:
9+
%% Called: 1290 times Total: 11.54 Mean: 0.009 Max: 0.249
10+
%% Test:
11+
%% Called: 1274 times Total: 14.05 Mean: 0.011 Max: 0.053
12+
%% Build_Rules:
13+
%% Called: 1273 times Total: 2.29 Mean: 0.002 Max: 0.017
14+
%% Ground:
15+
%% Called: 1273 times Total: 0.69 Mean: 0.001 Max: 0.006
16+
%% Add:
17+
%% Called: 1273 times Total: 2.26 Mean: 0.002 Max: 0.004
18+
%% Test_Individual_Rules.Is_Totally_Incomplete:
19+
%% Called: 1259 times Total: 0.06 Mean: 0.000 Max: 0.002
20+
%% Total operation time: 30.89s
21+
%% Total execution time: 31.55s
22+
23+
24+
max_clauses(3).
25+
max_vars(5).
26+
max_body(6).
27+
28+
head_pred(f,1).
29+
body_pred(has_car,2).
30+
body_pred(has_load,2).
31+
body_pred(short,1).
32+
body_pred(long,1).
33+
body_pred(two_wheels,1).
34+
body_pred(three_wheels,1).
35+
body_pred(roof_open,1).
36+
body_pred(roof_closed,1).
37+
body_pred(zero_load,1).
38+
body_pred(one_load,1).
39+
body_pred(two_load,1).
40+
body_pred(three_load,1).
41+
body_pred(circle,1).
42+
body_pred(triangle,1).
43+
body_pred(rectangle,1).
44+
45+
type(f,(train,)).
46+
type(has_car,(train,car)).
47+
type(has_load,(car,load)).
48+
type(short,(car,)).
49+
type(long,(car,)).
50+
type(two_wheels,(car,)).
51+
type(three_wheels,(car,)).
52+
type(roof_open,(car,)).
53+
type(roof_closed,(car,)).
54+
type(zero_load,(load,)).
55+
type(one_load,(load,)).
56+
type(two_load,(load,)).
57+
type(three_load,(load,)).
58+
type(circle,(load,)).
59+
type(triangle,(load,)).
60+
type(rectangle,(load,)).
61+
62+
direction(f,(in,)).
63+
direction(has_car,(in,out)).
64+
direction(has_load,(in,out)).
65+
direction(short,(in,)).
66+
direction(long,(in,)).
67+
direction(two_wheels,(in,)).
68+
direction(three_wheels,(in,)).
69+
direction(roof_open,(in,)).
70+
direction(roof_closed,(in,)).
71+
direction(zero_load,(in,)).
72+
direction(one_load,(in,)).
73+
direction(two_load,(in,)).
74+
direction(three_load,(in,)).
75+
direction(circle,(in,)).
76+
direction(triangle,(in,)).
77+
direction(rectangle,(in,)).

0 commit comments

Comments
 (0)