Skip to main content

LinearTypeChecker

Struct LinearTypeChecker 

Source
pub struct LinearTypeChecker;
Expand description

A simple linearity checker that tracks variable usage counts. In linear typing, each variable must be used exactly once.

Implementations§

Source§

impl LinearTypeChecker

Source

pub fn new() -> Self

Create a new linearity checker.

Source

pub fn count_uses(&self, term: &Term, depth: usize) -> UsageMap

Count free variable occurrences in term, relative to a context of depth variables. Returns a vector of length depth with usage counts for each variable.

Source

pub fn is_linear(&self, term: &Term, depth: usize) -> bool

Check if term is linear in the context of depth variables. Returns true iff every variable in the context is used exactly once.

Source

pub fn is_affine(&self, term: &Term, depth: usize) -> bool

Check if term is affine in the context of depth variables. Returns true iff every variable in the context is used at most once.

Source

pub fn is_relevant(&self, term: &Term, depth: usize) -> bool

Check if term is relevant in the context of depth variables. Returns true iff every variable in the context is used at least once.

Trait Implementations§

Source§

impl Default for LinearTypeChecker

Source§

fn default() -> Self

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

Auto Trait Implementations§

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.