pub enum Spec {
Logic(String),
Examples(Vec<(Vec<String>, String)>),
Grammar(CFG),
Conjunction(Box<Spec>, Box<Spec>),
Disjunction(Box<Spec>, Box<Spec>),
}Expand description
A logical specification for a synthesis problem.
Specifications range from purely logical (pre/post conditions) to example-based (input/output pairs) to grammar-constrained.
Variants§
Logic(String)
A logical predicate P(x, y) relating inputs x to output y.
Examples(Vec<(Vec<String>, String)>)
A finite set of concrete input/output examples.
Grammar(CFG)
A context-free grammar restricting the syntactic form of solutions.
Conjunction(Box<Spec>, Box<Spec>)
Conjunction of multiple specifications.
Disjunction(Box<Spec>, Box<Spec>)
Disjunction: any one of the specs suffices.
Implementations§
Source§impl Spec
impl Spec
Sourcepub fn logic(pred: impl Into<String>) -> Self
pub fn logic(pred: impl Into<String>) -> Self
Build a logic spec from a predicate string.
use oxilean_std::program_synthesis::Spec;
let s = Spec::logic("output = input * 2");
assert!(matches!(s, Spec::Logic(_)));Sourcepub fn from_examples(ex: Vec<(Vec<String>, String)>) -> Self
pub fn from_examples(ex: Vec<(Vec<String>, String)>) -> Self
Build a spec from a list of (inputs, output) example pairs.
use oxilean_std::program_synthesis::Spec;
let s = Spec::from_examples(vec![(vec!["0".into()], "0".into()),
(vec!["1".into()], "2".into())]);
assert!(matches!(s, Spec::Examples(_)));Sourcepub fn constraint_count(&self) -> usize
pub fn constraint_count(&self) -> usize
Return the number of constraints (examples or logical clauses) in this spec.
Trait Implementations§
impl Eq for Spec
impl StructuralPartialEq for Spec
Auto Trait Implementations§
impl Freeze for Spec
impl RefUnwindSafe for Spec
impl Send for Spec
impl Sync for Spec
impl Unpin for Spec
impl UnsafeUnpin for Spec
impl UnwindSafe for Spec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more