pub struct IrProgram {
pub clauses: Vec<IrClause>,
pub queries: Vec<IrQuery>,
pub tabled_predicates: HashSet<(String, usize)>,
pub diff_neural_predicates: HashSet<(String, usize, String)>,
pub neural_gen_predicates: HashSet<(String, usize)>,
pub neural_models: HashMap<String, String>,
pub actions: Vec<IrAction>,
pub neural_unify_threshold: f64,
pub type_hierarchy: Vec<(Vec<String>, Option<String>)>,
}Expand description
A complete IR program: a collection of clauses, queries, and planning actions.
Fields§
§clauses: Vec<IrClause>All clauses (facts and rules) in the program.
queries: Vec<IrQuery>All queries in the program.
tabled_predicates: HashSet<(String, usize)>Predicates declared with :- table functor/arity.
diff_neural_predicates: HashSet<(String, usize, String)>Predicates declared with :- differentiable neural functor/arity using "model".
neural_gen_predicates: HashSet<(String, usize)>Generative neural predicates declared with :- neural_gen functor/arity.
neural_models: HashMap<String, String>Mapping from neural predicate (name/arity) to a named model (from :- neural_model).
actions: Vec<IrAction>STRIPS-style planning actions registered in this program.
neural_unify_threshold: f64Cosine-similarity threshold used by the ~= (neural unification) operator.
Set via :- neural_unify threshold(<value>).; defaults to 0.85.
type_hierarchy: Vec<(Vec<String>, Option<String>)>PDDL type hierarchy: each entry is (child_types, parent).
Preserves the full type hierarchy from a PDDL domain so that
round-tripping through IR does not flatten the type tree.
For example, city location - object and truck car - vehicle
become [ (["city", "location"], Some("object")), (["truck", "car"], Some("vehicle")) ].
Union (either) types in parameter annotations are stored
with |-separated names (e.g. "brick|window").
Implementations§
Source§impl IrProgram
impl IrProgram
Sourcepub fn validate_actions(&self) -> Result<(), (usize, ActionValidationError)>
pub fn validate_actions(&self) -> Result<(), (usize, ActionValidationError)>
Validate all actions in the program, returning the index of the first
invalid action together with its ActionValidationError, or Ok(())
if all actions are well-formed.
This is a convenience wrapper around IrAction::validate that makes
it easy to gate the planning pipeline on structural correctness.
§Example
use gollum_ir::{IrAction, IrProgram, IrTerm};
let mut prog = IrProgram::new();
prog.actions.push(IrAction {
name: "move".into(),
parameters: vec!["X".into(), "Y".into()],
preconditions: vec![
IrTerm::Structure { name: "at".into(), args: vec![IrTerm::Var("X".into())] },
],
effects: vec![
IrTerm::Structure { name: "at".into(), args: vec![IrTerm::Var("Y".into())] },
],
metadata: None,
});
assert!(prog.validate_actions().is_ok());