Skip to main content

EnvBuilder

Struct EnvBuilder 

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

A thin wrapper around Environment providing convenience methods for registering axioms and definitions during standard library initialisation.

Implementations§

Source§

impl EnvBuilder

Source

pub fn new(env: Environment) -> Self

Create a new builder from an existing environment.

Source

pub fn fresh() -> Self

Create a builder around a fresh Environment::new().

Source

pub fn add_axiom(&mut self, name: Name, ty: Expr)

Add an axiom with the given name and type.

Source

pub fn axiom(&mut self, name: &str, ty: Expr) -> &mut Self

Add an axiom using a &str name.

Source

pub fn add_definition(&mut self, name: Name, ty: Expr, value: Expr)

Add a definition with the given name, type, and value.

Source

pub fn def(&mut self, name: &str, ty: Expr, value: Expr) -> &mut Self

Add a definition using a &str name (builder-style).

Source

pub fn theorem(&mut self, name: &str, ty: Expr, proof: Expr) -> &mut Self

Add a theorem (opaque definition) using a &str name.

Source

pub fn sorry(&mut self, name: &str, ty: Expr) -> &mut Self

Add a Sorry opaque axiom — useful for placeholder proofs.

Source

pub fn finish(self) -> Result<Environment, String>

Finish building and return the environment, or an error string.

Source

pub fn finish_or_panic(self) -> Environment

Finish building, panicking on any error. Useful in tests.

Source

pub fn env(&self) -> &Environment

Get a reference to the underlying environment.

Source

pub fn is_ok(&self) -> bool

true if no errors have been accumulated.

Source

pub fn errors(&self) -> &[String]

Return the accumulated error messages.

Source

pub fn contains(&self, name: &str) -> bool

Check whether name has been registered.

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.