Skip to main content

Level

Enum Level 

Source
pub enum Level {
    Zero,
    Succ(Box<Level>),
    Max(Box<Level>, Box<Level>),
    IMax(Box<Level>, Box<Level>),
    Param(Name),
    MVar(LevelMVarId),
}
Expand description

A universe level.

Levels form expressions over zero, successor, max, imax, parameters, and metavariables.

Variants§

§

Zero

Level 0 (Prop).

§

Succ(Box<Level>)

Successor: u + 1.

§

Max(Box<Level>, Box<Level>)

Maximum of two levels: max(u, v).

§

IMax(Box<Level>, Box<Level>)

Impredicative maximum: imax(u, v).

Semantics: imax(u, v) = 0 if v = 0, else max(u, v). This ensures Prop -> Prop : Prop (impredicativity).

§

Param(Name)

Universe parameter (for polymorphism).

§

MVar(LevelMVarId)

Universe metavariable (for unification).

Implementations§

Source§

impl Level

Source

pub fn zero() -> Self

Create Zero level.

Source

pub fn succ(l: Level) -> Self

Create a successor level.

Source

pub fn max(l1: Level, l2: Level) -> Self

Create a max level.

Source

pub fn imax(l1: Level, l2: Level) -> Self

Create an imax level.

Source

pub fn param(name: Name) -> Self

Create a parameter level.

Source

pub fn mvar(id: LevelMVarId) -> Self

Create a level metavariable.

Source

pub fn is_zero(&self) -> bool

Check if this is Zero.

Source

pub fn is_param(&self) -> bool

Check if this is a parameter.

Source

pub fn is_mvar(&self) -> bool

Check if this is a metavariable.

Source

pub fn is_succ(&self) -> bool

Check if this is a successor.

Source

pub fn is_max(&self) -> bool

Check if this is a max.

Source

pub fn is_imax(&self) -> bool

Check if this is an imax.

Source

pub fn is_not_zero(&self) -> bool

Check if this level is definitely not zero.

Returns true if we can statically determine this is >= 1.

Source

pub fn has_mvar(&self) -> bool

Check if this level contains any metavariables.

Source

pub fn has_param(&self) -> bool

Check if this level contains any parameters.

Source

pub fn depth(&self) -> usize

Get the depth (nesting) of this level expression.

Source

pub fn from_nat(n: u32) -> Self

Create a numeric level succ^n(zero).

Source

pub fn to_nat(&self) -> Option<u32>

Try to convert to a numeric level.

Returns Some(n) if this is succ^n(zero), None otherwise.

Trait Implementations§

Source§

impl Clone for Level

Source§

fn clone(&self) -> Level

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Level

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Level

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Level

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Level

Source§

fn eq(&self, other: &Level) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Level

Source§

impl StructuralPartialEq for Level

Auto Trait Implementations§

§

impl Freeze for Level

§

impl RefUnwindSafe for Level

§

impl Send for Level

§

impl Sync for Level

§

impl Unpin for Level

§

impl UnsafeUnpin for Level

§

impl UnwindSafe for Level

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.