pub struct EGraph { /* private fields */ }Expand description
The state associated with an egglog program.
Implementations§
Source§impl EGraph
 
impl EGraph
Sourcepub fn with_tracing() -> EGraph
 
pub fn with_tracing() -> EGraph
Create a new EGraph with tracing (aka ‘proofs’) enabled.
Execution of queries against a tracing-enabled EGraph will be slower, but will annotate the egraph with annotations that can explain how rows came to appear.
Sourcepub fn base_values_mut(&mut self) -> &mut BaseValues
 
pub fn base_values_mut(&mut self) -> &mut BaseValues
Get a mutable reference to the underlying table of base values for this
EGraph.
Sourcepub fn container_values_mut(&mut self) -> &mut ContainerValues
 
pub fn container_values_mut(&mut self) -> &mut ContainerValues
Get a mutable reference to the underlying table of containers for this
EGraph.
Sourcepub fn container_values(&self) -> &ContainerValues
 
pub fn container_values(&self) -> &ContainerValues
Get a reference to the underlying table of containers for this EGraph.
Sourcepub fn get_container_value<C: ContainerValue>(&mut self, val: C) -> Value
 
pub fn get_container_value<C: ContainerValue>(&mut self, val: C) -> Value
Intern the given container value into the EGraph.
Sourcepub fn register_container_ty<C: ContainerValue>(&mut self)
 
pub fn register_container_ty<C: ContainerValue>(&mut self)
Register the given ContainerValue type with this EGraph.
The given container will use the EGraph’s union-find to manage rebuilding and the merging of containers with a common id.
Sourcepub fn base_values(&self) -> &BaseValues
 
pub fn base_values(&self) -> &BaseValues
Get a reference to the underlying table of base values for this EGraph.
Sourcepub fn base_value_constant<T>(&self, x: T) -> QueryEntrywhere
    T: BaseValue,
 
pub fn base_value_constant<T>(&self, x: T) -> QueryEntrywhere
    T: BaseValue,
Create a QueryEntry for a base value.
pub fn register_external_func( &mut self, func: impl ExternalFunction + 'static, ) -> ExternalFunctionId
pub fn free_external_func(&mut self, func: ExternalFunctionId)
Sourcepub fn get_canon_repr(&self, val: Value, ty: ColumnTy) -> Value
 
pub fn get_canon_repr(&self, val: Value, ty: ColumnTy) -> Value
Get the canonical representation for val based on type.
For ColumnTy::Id, it looks up the union find; otherwise,
it returns the value itself.
Sourcepub fn add_values(
    &mut self,
    values: impl IntoIterator<Item = (FunctionId, Vec<Value>)>,
)
 
pub fn add_values( &mut self, values: impl IntoIterator<Item = (FunctionId, Vec<Value>)>, )
Load the given values into the database.
§Panics
This method panics if the values do not match the arity of the function.
NB: this is not an efficient interface for bulk loading. We should add one that allows us to pass through a series of RowBuffers before incrementing the timestamp.
Sourcepub fn add_term(
    &mut self,
    func: FunctionId,
    inputs: &[Value],
    desc: &str,
) -> Value
 
pub fn add_term( &mut self, func: FunctionId, inputs: &[Value], desc: &str, ) -> Value
A term-oriented means of adding data to the database: hand back a “term
id” for the given function and keys for the function. Proofs for this
term will include desc.
§Panics
This method panics if the values do not match the arity of the function.
Sourcepub fn lookup_id(&self, func: FunctionId, key: &[Value]) -> Option<Value>
 
pub fn lookup_id(&self, func: FunctionId, key: &[Value]) -> Option<Value>
Lookup the id associated with a function func and the given arguments
(key).
Sourcepub fn add_values_with_desc(
    &mut self,
    desc: &str,
    values: impl IntoIterator<Item = (FunctionId, Vec<Value>)>,
)
 
pub fn add_values_with_desc( &mut self, desc: &str, values: impl IntoIterator<Item = (FunctionId, Vec<Value>)>, )
Load the given values into the database. If tracing is enabled, the proof rows will be tagged with “desc” as their proof.
§Panics
This method panics if the values do not match the arity of the function.
NB: this is not an efficient interface for bulk loading. We should add one that allows us to pass through a series of RowBuffers before incrementing the timestamp.
pub fn approx_table_size(&self, table: FunctionId) -> usize
pub fn table_size(&self, table: FunctionId) -> usize
Sourcepub fn explain_term(
    &mut self,
    id: Value,
    store: &mut ProofStore,
) -> Result<TermProofId>
 
pub fn explain_term( &mut self, id: Value, store: &mut ProofStore, ) -> Result<TermProofId>
Sourcepub fn explain_terms_equal(
    &mut self,
    id1: Value,
    id2: Value,
    store: &mut ProofStore,
) -> Result<EqProofId>
 
pub fn explain_terms_equal( &mut self, id1: Value, id2: Value, store: &mut ProofStore, ) -> Result<EqProofId>
Generate a proof explaining why the term corresponding to id1
is equal to that corresponding to id2.
§Errors
This method will return an error if tracing is not enabled, if the row is not in the database, or if the terms themselves are not equal.
Sourcepub fn for_each(&self, table: FunctionId, f: impl FnMut(FunctionRow<'_>))
 
pub fn for_each(&self, table: FunctionId, f: impl FnMut(FunctionRow<'_>))
Read the contents of the given function.
The callback f is called with each row and its subsumption status.
Sourcepub fn for_each_while(
    &self,
    table: FunctionId,
    f: impl FnMut(FunctionRow<'_>) -> bool,
)
 
pub fn for_each_while( &self, table: FunctionId, f: impl FnMut(FunctionRow<'_>) -> bool, )
Iterate over the rows of a function table, calling f on each row. If f returns false
the function returns early and stops reading rows from the table.
Sourcepub fn dump_debug_info(&self)
 
pub fn dump_debug_info(&self)
A basic method for dumping the state of the database to log::info!.
For large tables, this is unlikely to give particularly useful output.
Sourcepub fn add_table(&mut self, config: FunctionConfig) -> FunctionId
 
pub fn add_table(&mut self, config: FunctionConfig) -> FunctionId
Register a function in this EGraph.
Sourcepub fn run_rules(&mut self, rules: &[RuleId]) -> Result<IterationReport>
 
pub fn run_rules(&mut self, rules: &[RuleId]) -> Result<IterationReport>
Run the given rules, returning whether the database changed.
If the given rules are malformed, this method can return an error.
Sourcepub fn with_execution_state<R>(
    &self,
    f: impl FnOnce(&mut ExecutionState<'_>) -> R,
) -> R
 
pub fn with_execution_state<R>( &self, f: impl FnOnce(&mut ExecutionState<'_>) -> R, ) -> R
Gives the user a handle to the underlying ExecutionState. Useful for staging updates to the database.
The staged updates are not immediately reflected in the EGraph, so you may want to
manually flush the updates using EGraph::flush_updates.
Sourcepub fn flush_updates(&mut self) -> bool
 
pub fn flush_updates(&mut self) -> bool
Flush the pending update buffers to the EGraph.
Returns true if the database is updated.
Source§impl EGraph
 
impl EGraph
Sourcepub fn new_panic(&mut self, message: String) -> ExternalFunctionId
 
pub fn new_panic(&mut self, message: String) -> ExternalFunctionId
Create a new ExternalFunction that panics with the given message.
pub fn new_panic_lazy( &mut self, message: impl FnOnce() -> String + Send + 'static, ) -> ExternalFunctionId
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EGraph
impl !RefUnwindSafe for EGraph
impl Send for EGraph
impl Sync for EGraph
impl Unpin for EGraph
impl !UnwindSafe for EGraph
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
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more