Skip to main content

Sem

Struct Sem 

Source
pub struct Sem<'a> {
    pub k: &'a mut Kernel,
    pub st: &'a mut State,
}
Expand description

The engine: the kernel (environment, stores, well-known names) and the session state.

Fields§

§k: &'a mut Kernel§st: &'a mut State

Implementations§

Source§

impl Sem<'_>

Source

pub fn is_def_eq(&mut self, t: V, s: V) -> KResult<bool>

t ≡ s.

Source

pub fn is_def_eq_within( &mut self, t: V, s: V, steps: u32, ) -> KResult<Option<bool>>

t ≡ s, if it is decided within steps conversion steps and the checker’s resources; None if not. An attempt is speculation: running out — of steps, or of recursion depth, which a step does not bound — leaves it undecided, never declined, and nothing is learned from it but what it proved along the way.

Source

pub fn proof_positions(&mut self, ty: V) -> KResult<u64>

The positions of a Π telescope whose binder types are propositions.

Source§

impl Sem<'_>

Source

pub fn const_type(&mut self, n: NameId, ls: LevelsId) -> KResult<V>

The type of constant n at universe levels ls.

Source

pub fn eval(&mut self, env: EnvId, e: ExprId) -> KResult<V>

Evaluates e in env.

Source

pub fn apply(&mut self, f: V, a: V) -> KResult<V>

f a.

Source

pub fn instantiate(&mut self, clo: V, x: V) -> KResult<V>

The body of a closure applied to x: a lambda’s body, a Π’s codomain.

Source§

impl Sem<'_>

Source

pub fn infer( &mut self, env: EnvId, ctx: CtxId, e: ExprId, check: bool, ) -> KResult<V>

The type of e, whose bound variables have the values env and the types ctx (an empty context means “the types of the values”).

Source§

impl Sem<'_>

Source

pub fn type_of(&mut self, v: V) -> KResult<V>

The type of v.

Source

pub fn is_prop(&mut self, ty: V) -> KResult<bool>

Whether the type ty lives in Prop.

Source

pub fn signature( &mut self, c: NameId, ls: LevelsId, ) -> KResult<Option<Signature>>

The Signature of c.{ls}, computed once per settled constant and instantiation and shared by every later declaration; None for a constant only provisionally in the environment, or one given the wrong number of universes, whose applications’ types must be inferred.

Source§

impl Sem<'_>

Source

pub fn whnf_core(&mut self, v: V, cheap_proj: bool) -> KResult<V>

Weak-head normal form without δ. With cheap_proj, a projection’s structure is only brought to whnf_core (not unfolded), as Lean’s whnfCore does inside conversion.

Source

pub fn unfold(&mut self, v: V) -> KResult<Option<V>>

One δ-step: the definition at the head of v unfolded and applied to the arguments.

Source

pub fn whnf(&mut self, v: V) -> KResult<V>

Full weak-head normal form.

Source§

impl<'a> Sem<'a>

Source

pub fn new(k: &'a mut Kernel, st: &'a mut State) -> Sem<'a>

Source

pub fn under<T>( &mut self, ty: V, f: impl FnOnce(&mut Self, V) -> KResult<T>, ) -> KResult<T>

Runs f under a fresh variable of type ty.

Source

pub fn check_type(&mut self, ty: ExprId) -> KResult<LevelId>

Checks that the closed term ty is a type; its universe level.

Source

pub fn check_value(&mut self, value: ExprId, ty: ExprId) -> KResult<()>

Checks the closed term value against the closed, already checked type ty.

Source

pub fn show(&mut self, v: V) -> String

A one-line description of a value, for diagnostics.

Auto Trait Implementations§

§

impl<'a> Freeze for Sem<'a>

§

impl<'a> RefUnwindSafe for Sem<'a>

§

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

§

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

§

impl<'a> Unpin for Sem<'a>

§

impl<'a> UnsafeUnpin for Sem<'a>

§

impl<'a> !UnwindSafe for Sem<'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.