Arena

Struct Arena 

Source
pub struct Arena { /* private fields */ }
Expand description

Arena for interning terms with hash-consing

Implementations§

Source§

impl Arena

Source

pub fn new() -> Self

Create a new term arena

Source

pub fn intern(&mut self, kind: TermKind) -> TermId

Intern a term and return its ID

Source

pub fn get(&self, id: TermId) -> Option<&Term>

Get a term by its ID

Source

pub fn get_term(&self, id: TermId) -> Option<&Term>

Get a term by its ID (alias for compatibility)

Source

pub fn kind(&self, id: TermId) -> Option<&TermKind>

Get the kind of a term by its ID

Source

pub fn terms(&self) -> usize

Get the number of terms in the arena

Source

pub fn stats(&self) -> &ArenaStats

Get arena statistics

Source

pub fn cache_hit_rate(&self) -> f64

Get cache efficiency (hit rate)

Source

pub fn clear_stats(&mut self)

Clear all statistics

Source

pub fn mk_sort(&mut self, level: LevelId) -> TermId

Create a sort term

Source

pub fn mk_const(&mut self, name: SymbolId, levels: Vec<LevelId>) -> TermId

Create a constant term

Source

pub fn mk_var(&mut self, index: u32) -> TermId

Create a variable term

Source

pub fn mk_app(&mut self, func: TermId, arg: TermId) -> TermId

Create an application term

Source

pub fn mk_lam(&mut self, binder: Binder, body: TermId) -> TermId

Create a lambda term

Source

pub fn mk_pi(&mut self, binder: Binder, body: TermId) -> TermId

Create a Pi term

Source

pub fn mk_let(&mut self, binder: Binder, value: TermId, body: TermId) -> TermId

Create a let term

Source

pub fn mk_mvar(&mut self, id: MetaVarId) -> TermId

Create a metavariable term

Source

pub fn mk_nat(&mut self, n: u64) -> TermId

Create a natural number literal

Source

pub fn mk_app_spine(&mut self, func: TermId, args: &[TermId]) -> TermId

Create a spine of applications (f x y z)

Source

pub fn mk_level_zero(&mut self) -> LevelId

Create a zero universe level

Trait Implementations§

Source§

impl Default for Arena

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Arena

§

impl RefUnwindSafe for Arena

§

impl Send for Arena

§

impl Sync for Arena

§

impl Unpin for Arena

§

impl UnwindSafe for Arena

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.