Module programinduction::trs
source · Expand description
(representation) Polymorphically-typed term rewriting system.
An evaluatable first-order Term Rewriting System (TRS) with a Hindley-Milner type system.
Example
use polytype::{ptp, tp, Context as TypeContext};
use programinduction::trs::{TRS, Lexicon};
use term_rewriting::{Signature, parse_rule};
let mut sig = Signature::default();
let mut ops = vec![];
sig.new_op(2, Some("PLUS".to_string()));
ops.push(ptp![@arrow[tp!(int), tp!(int), tp!(int)]]);
sig.new_op(1, Some("SUCC".to_string()));
ops.push(ptp![@arrow[tp!(int), tp!(int)]]);
sig.new_op(0, Some("ZERO".to_string()));
ops.push(ptp![int]);
let rules = vec![
parse_rule(&mut sig, "PLUS(x_ ZERO) = x_").expect("parsed rule"),
parse_rule(&mut sig, "PLUS(x_ SUCC(y_)) = SUCC(PLUS(x_ y_))").expect("parsed rule"),
];
let vars = vec![
ptp![int],
ptp![int],
ptp![int],
];
let lexicon = Lexicon::from_signature(sig, ops, vars, vec![], vec![], false, TypeContext::default());
let trs = TRS::new(&lexicon, rules, &lexicon.context());
Re-exports
pub use self::parser::parse_context;
pub use self::parser::parse_lexicon;
pub use self::parser::parse_rule;
pub use self::parser::parse_rulecontext;
pub use self::parser::parse_templates;
pub use self::parser::parse_trs;
Modules
Structs
- (representation) Manages the syntax of a term rewriting system.
- Parameters for a TRS-based probabilistic model.
- Manages the semantics of a term rewriting system.
Enums
- The error type for sampling operations.
- The error type for type inference.