EmbedderState

Struct EmbedderState 

Source
pub struct EmbedderState<'a> {
    pub model_spaces: HashMap<TypeId, EmbeddingSpace<'a>>,
    pub ctxt: &'a Context,
}
Expand description

An EmbedderState keeps track of the embeddings of function terms (TermModels) which come from some InterpreterState, and also the learned Elaborators for every function type.

Fields§

§model_spaces: HashMap<TypeId, EmbeddingSpace<'a>>§ctxt: &'a Context

Implementations§

Source§

impl<'a> EmbedderState<'a>

Source

pub fn sample(&self, rng: &mut ThreadRng) -> SampledEmbedderState<'a>

Draws a sample from the distribution over TermModels represented in this EmbedderState, yielding a SampledEmbedderState.

Source

pub fn new( model_prior_specification: &'a dyn PriorSpecification, elaborator_prior_specification: &'a dyn PriorSpecification, ctxt: &'a Context, ) -> EmbedderState<'a>

Creates a new EmbedderState, initially populated with default embeddings for primitive terms in the passed Context.

Source

pub fn init_embeddings_for_new_terms( &mut self, newly_evaluated_terms: &NewlyEvaluatedTerms, )

Initializes default embeddings for the passed collection of terms in a NewlyEvaluatedTerms.

Source

pub fn bayesian_update_step( &mut self, interpreter_state: &InterpreterState<'_>, newly_evaluated_terms: &NewlyEvaluatedTerms, )

Given an InterpreterState and a collection of NewlyEvaluatedTerms, performs a bottom-up (data) update followed by a top-down (prior) update recursively on all modified terms. This method may be used to keep the TermModels in this EmbedderState up-to-date with new information.

Source

pub fn has_embedding(&self, term_ptr: TermPointer) -> bool

Determines whether/not there is a stored TermModel for the given TermPointer.

Source

pub fn get_embedding(&self, term_ptr: TermPointer) -> &TermModel<'_>

Given a TermPointer pointing to a TermModel tracked by this EmbedderState, yields a reference to the TermModel. Panics if there is no such entry stored.

Source

pub fn get_mut_embedding(&mut self, term_ptr: TermPointer) -> &mut TermModel<'a>

Like EmbedderState, but yields a mutable reference to the TermModel given a TermPointer pointing to it.

Auto Trait Implementations§

§

impl<'a> Freeze for EmbedderState<'a>

§

impl<'a> !RefUnwindSafe for EmbedderState<'a>

§

impl<'a> !Send for EmbedderState<'a>

§

impl<'a> !Sync for EmbedderState<'a>

§

impl<'a> Unpin for EmbedderState<'a>

§

impl<'a> !UnwindSafe for EmbedderState<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V