program-induction
A library for program induction and learning representations.
Implements Bayesian program learning and genetic programming.
Installation
Install rust. In a new or existing project, add the
following to your Cargo.toml
:
[]
= "0.2"
# many examples also depend on polytype for the tp! and arrow! macros:
= "1.2"
The documentation requires a custom HTML header to include KaTeX for math
support. This isn't supported by cargo doc
, so to build the documentation
you may use:
Usage
Specify a probabilistic context-free grammar (PCFG; see pcfg::Grammar
) and
induce a sentence that matches an example:
extern crate polytype;
extern crate programinduction;
use ;
use ;
The Exploration-Compression (EC) algorithm iteratively learns a better
representation by finding common structure in induced programs. We can run
the EC algorithm with a polymorphically-typed lambda calculus representation
lambda::Language
in a Boolean circuit domain:
extern crate polytype;
extern crate programinduction;
use ;
You may have noted the above use of domains::circuits
. Some domains are
already implemented for you. Currently, this only consists of circuits and
strings. The strings domain uses a rich set of primitives and thus
depends on lambda::LispEvaluator
. If you find this evaluator to be slow,
you may install racket and enable the racket
feature in your Cargo.toml
:
[]
= "0.2"
= ["racket"]
See the documentation for more details.
TODO
(you could be the one who does one of these!)
[ ] PCFG compression is currently only estimating parameters, not actually
learning pieces of programs. An adaptor
grammar
approach seems like a good direction to go, perhaps minus the Bayesian
non-parametrics.
[ ] impl GP for pcfg::Grammar
is not yet complete.
[ ] Add more representations
[ ] Add more domains
[ ] Add task generation function in domains::strings