Skip to main content

ConstantInfo

Enum ConstantInfo 

Source
pub enum ConstantInfo {
    Axiom(AxiomVal),
    Definition(DefinitionVal),
    Theorem(TheoremVal),
    Opaque(OpaqueVal),
    Inductive(InductiveVal),
    Constructor(ConstructorVal),
    Recursor(RecursorVal),
    Quotient(QuotVal),
}
Expand description

Unified constant info enum (mirrors LEAN 4’s constant_info).

Every declaration in the environment is stored as a ConstantInfo. The type checker dispatches on this enum to determine reduction behavior.

Variants§

§

Axiom(AxiomVal)

Axiom declaration.

§

Definition(DefinitionVal)

Definition with body.

§

Theorem(TheoremVal)

Theorem with proof.

§

Opaque(OpaqueVal)

Opaque definition.

§

Inductive(InductiveVal)

Inductive type.

§

Constructor(ConstructorVal)

Constructor of inductive type.

§

Recursor(RecursorVal)

Recursor (eliminator).

§

Quotient(QuotVal)

Quotient type component.

Implementations§

Source§

impl ConstantInfo

Source

pub fn name(&self) -> &Name

Get the name of this constant.

Source

pub fn ty(&self) -> &Expr

Get the type of this constant.

Source

pub fn level_params(&self) -> &[Name]

Get the universe level parameters.

Source

pub fn common(&self) -> &ConstantVal

Get the common constant value.

Source

pub fn is_axiom(&self) -> bool

Check if this is an axiom.

Source

pub fn is_definition(&self) -> bool

Check if this is a definition.

Source

pub fn is_theorem(&self) -> bool

Check if this is a theorem.

Source

pub fn is_opaque(&self) -> bool

Check if this is opaque.

Source

pub fn is_inductive(&self) -> bool

Check if this is an inductive type.

Source

pub fn is_constructor(&self) -> bool

Check if this is a constructor.

Source

pub fn is_recursor(&self) -> bool

Check if this is a recursor.

Source

pub fn is_quotient(&self) -> bool

Check if this is a quotient component.

Source

pub fn to_definition_val(&self) -> Option<&DefinitionVal>

Get the definition value if this is a Definition.

Source

pub fn to_inductive_val(&self) -> Option<&InductiveVal>

Get the inductive value if this is an Inductive.

Source

pub fn to_constructor_val(&self) -> Option<&ConstructorVal>

Get the constructor value if this is a Constructor.

Source

pub fn to_recursor_val(&self) -> Option<&RecursorVal>

Get the recursor value if this is a Recursor.

Source

pub fn to_quotient_val(&self) -> Option<&QuotVal>

Get the quotient value if this is a Quotient.

Source

pub fn to_axiom_val(&self) -> Option<&AxiomVal>

Get the axiom value if this is an Axiom.

Source

pub fn to_theorem_val(&self) -> Option<&TheoremVal>

Get the theorem value if this is a Theorem.

Source

pub fn to_opaque_val(&self) -> Option<&OpaqueVal>

Get the opaque value if this is an Opaque.

Source

pub fn has_value(&self, allow_opaque: bool) -> bool

Check if this constant has a computable value.

allow_opaque controls whether opaque definitions are considered.

Source

pub fn value(&self) -> Option<&Expr>

Get the value (body/proof) if available.

Source

pub fn reducibility_hint(&self) -> ReducibilityHint

Get the reducibility hint.

Source

pub fn is_unsafe(&self) -> bool

Check if this declaration is unsafe.

Source

pub fn is_structure_like(&self) -> bool

Check if this is a structure-like inductive (single constructor, not recursive).

Source§

impl ConstantInfo

Source

pub fn kind(&self) -> ConstantKind

Return the kind of this constant.

Source

pub fn summarize(&self) -> ConstantSummary

Build a summary of this constant.

Source

pub fn num_level_params(&self) -> usize

Return the number of universe-level parameters.

Source

pub fn is_polymorphic(&self) -> bool

Whether this constant is universe-polymorphic.

Source

pub fn parent_inductive(&self) -> Option<&Name>

For constructors, return the parent inductive name.

Source

pub fn inductive_num_params(&self) -> Option<usize>

For inductives, return the number of parameters.

Source

pub fn inductive_num_indices(&self) -> Option<usize>

For inductives, return the number of indices.

Source

pub fn inductive_constructors(&self) -> Option<&[Name]>

For inductives, return the list of constructor names.

Source

pub fn ctor_num_fields(&self) -> Option<usize>

For constructors, return the number of fields.

Source

pub fn recursor_rules(&self) -> Option<&[RecursorRule]>

For recursors, return the recursor rules.

Source

pub fn display_string(&self) -> String

Return a display string for this constant.

Trait Implementations§

Source§

impl Clone for ConstantInfo

Source§

fn clone(&self) -> ConstantInfo

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 ConstantInfo

Source§

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

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

impl PartialEq for ConstantInfo

Source§

fn eq(&self, other: &ConstantInfo) -> 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 StructuralPartialEq for ConstantInfo

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> 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, 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.