You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+62-46Lines changed: 62 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,10 @@
3
3
Popper is an [inductive logic programming](https://arxiv.org/pdf/2008.07912.pdf) (ILP) system.
4
4
Popper is still a **major** work-in-progress, so please notify us of bugs or usability issues.
5
5
6
-
If you use Popper for research, please cite the paper: Andrew Cropper and Rolf Morel. [Learning programs by learning from failures](https://arxiv.org/abs/2005.02259). Mach. Learn. 110(4): 801-856 (2021)
6
+
If you use Popper, please cite the paper: Andrew Cropper and Rolf Morel. [Learning programs by learning from failures](https://arxiv.org/abs/2005.02259). Mach. Learn. 110(4): 801-856 (2021)
7
7
8
+
## Installation
9
+
```pip install popper-ilp```
8
10
9
11
## Requirements
10
12
@@ -15,9 +17,9 @@ If you use Popper for research, please cite the paper: Andrew Cropper and Rolf M
15
17
[pyswip](https://pypi.org/project/pyswip/)
16
18
17
19
18
-
# Usage
20
+
# Command line usage
19
21
20
-
You can run Popper with the command `python popper.py <input dir>`
22
+
You can run Popper with the command `python popper.py <input dir>`.
21
23
For instance, running the command `python popper.py examples/dropk` produces the output:
An examples file simply contains positive and negative examples of the relation you wish to learn:
59
+
An examples file contains positive and negative examples of the relation you want to learn:
49
60
50
61
```prolog
51
62
pos(grandparent(ann,amelia)).
@@ -56,7 +67,7 @@ pos(grandparent(linda,amelia)).
56
67
neg(grandparent(amy,amelia)).
57
68
```
58
69
59
-
Likewise, a BK file contains helpful information about the relation you are trying to learn:
70
+
A BK file contains other information about the problem:
60
71
61
72
```prolog
62
73
mother(ann,amy).
@@ -69,26 +80,25 @@ father(gavin,amelia).
69
80
father(andy,spongebob).
70
81
```
71
82
72
-
The bias file contains all the information necessary to restrict the search space of Popper.
73
-
74
-
There two main things to add to this file are predicate declarations. These simply inform Popper whether it can use a predicate symbol in the head or body of a rule in a solution, such as:
83
+
A bias file contains information necessary to restrict the search space of Popper.
84
+
The first key thing thing to add to this file are *predicate declarations*.
85
+
These tell Popper which predicate symbols it can use in the head or body of a rule, such as:
75
86
76
87
```prolog
77
88
head_pred(grandparent,2).
78
89
body_pred(mother,2).
79
90
body_pred(father,2).
80
91
```
81
92
82
-
In other words, the above says each role in a program must have the symbol grandparent with arity two in the head and mother and/or father in the body, also with arity two.
83
-
84
-
Popper needs three parameters to restrict the search space:
93
+
These declarations say that each rule in a program must have the symbol *grandparent* with arity two in the head and *mother* and/or *father* in the body, also with arity two.
85
94
86
-
-`max_vars(N).` sets the maximum number of variables allowed in a rule to be `N`
87
-
-`max_body(N).` sets the maximum number of body literals in a rule to be `N`
88
-
-`max_clauses(N).` sets the maximum number of rules/clause to be `N`
95
+
Popper also needs three parameters to restrict the search space:
89
96
90
-
These parameters are important as they greatly influence the search space. If they are way too high then Popper will likely take a long time to learn a solution. If the settings are way too low then the search space might be too small to contain a good solution. We are currently working on techniques to automatically deduce these settings. But in the meantime finding the correct values can often be process of trial and error.
97
+
-`max_vars(N).` sets the maximum number of variables in a rule to `N`
98
+
-`max_body(N).` sets the maximum number of body literals in a rule to `N`
99
+
-`max_clauses(N).` sets the maximum number of rules/clauses to `N`
91
100
101
+
These parameters are very important as they greatly influence the search space. If the values are too high then Popper will might struggle to learn a solution. If the settings are too low then the search space might be too small to contain a good solution. We are currently working on method to automatically set these settings, but in the meantime finding the correct values can often be a process of trial and error.
92
102
93
103
In our running example, we will add these three lines to our bias file:
94
104
```prolog
@@ -97,7 +107,7 @@ max_vars(4).
97
107
max_body(3).
98
108
```
99
109
100
-
If we call Popper with these three files, then it will produce the output:
110
+
If we call Popper with these three files it will produce the output:
Popper supports [automatic predicate invention](https://arxiv.org/pdf/2104.14426.pdf) (PI). To enable PI, add the setting `enable_pi.` to the bias file.
113
-
With PI enabled, Popper (`python popper.py examples/kinship-pi`) learns the following program:
<!-- Popper can invent multiple levels of predicates. For instance, running `python popper.py examples/robots-pi` produces the output:
123
-
124
-
```prolog
125
-
126
-
``` -->
127
-
128
-
Predicate invention is currently very expensive so it is best to avoid it if possible.
129
-
130
-
# Anytime
131
-
132
-
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:
122
+
Popper is an anytime algorithm. To see intermediate solutions use the `--info` flag (or `settings.info = True`). For instance, running the command `python popper.py examples/trains2 --info` produces the output:
To enable recursion add `enable_recursion.` to the bias file.
166
-
This allows Popper to learn programs where a predicate symbol appears both in the head and body of a rule, such as to find a duplicate element (`python popper.py examples/find-dupl`) in a list:
156
+
This flag allows Popper to learn programs where a predicate symbol appears in both the head and body of a rule, such as to find a duplicate element (`python popper.py examples/find-dupl`) in a list:
Popper supports [automatic predicate invention](https://arxiv.org/pdf/2104.14426.pdf) (PI). To enable PI, add the setting `enable_pi.` to the bias file.
216
+
With PI enabled, Popper (`python popper.py examples/kinship-pi`) learns the following program:
0 commit comments