Module programinduction::lambda [−][src]
(representation) Polymorphically-typed lambda calculus.
Examples
use programinduction::lambda::{task_by_evaluation, Language, SimpleEvaluator}; fn evaluate(name: &str, inps: &[i32]) -> Result<i32, ()> { match name { "0" => Ok(0), "1" => Ok(1), "+" => Ok(inps[0] + inps[1]), _ => unreachable!(), } } let dsl = Language::uniform(vec![ ("0", ptp!(int)), ("1", ptp!(int)), ("+", ptp!(@arrow[tp!(int), tp!(int), tp!(int)])), ]); // task: sum 1 with two numbers let tp = ptp!(@arrow[tp!(int), tp!(int), tp!(int)]); let examples = vec![(vec![2, 5], 8), (vec![1, 2], 4)]; let task = task_by_evaluation(SimpleEvaluator::of(evaluate), tp, &examples); // solution: let expr = dsl.parse("(λ (+ (+ 1 $0)))").unwrap(); assert!((task.oracle)(&dsl, &expr).is_finite())
Structs
CompressionParams |
Parameters for grammar induction. |
Language |
(representation) A Language is a registry for primitive and invented expressions in a polymorphically-typed lambda calculus with corresponding production log-probabilities. |
LiftedFunction |
A function object for evaluation in domains with first-class functions. |
LiftedLazyFunction |
Like |
ParseError | |
SimpleEvaluator |
An |
Enums
Expression |
Expressions of lambda calculus, which only make sense with an accompanying |
InferenceError |
Traits
Evaluator |
A specification for evaluating lambda calculus expressions in a domain. |
LazyEvaluator |
Like |
Functions
task_by_evaluation |
Create a task based on evaluating lambda calculus expressions on test input/output pairs. |
task_by_lazy_evaluation |
Liky |