Skip to main content

Proven

Struct Proven 

Source
pub struct Proven<P, T> { /* private fields */ }
Expand description

A value of type T accompanied by a compile-time witness that property P holds for T.

Construction is deliberately restricted: safe constructors require the relevant trait bound (e.g., from_semigroup requires T: Semigroup). The trait implementation is the proof.

For properties verified externally (proptest, SMT solver, inspection), use the unsafe Proven::axiom constructor.

Implementations§

Source§

impl<P, T> Proven<P, T>

Source

pub unsafe fn axiom(value: T) -> Proven<P, T>

Create a witness without checking.

§Safety

Caller asserts that property P genuinely holds for type T.

Source

pub fn value(&self) -> &T

Access the inner value by reference.

Source

pub fn into_inner(self) -> T

Unwrap the witness, discarding the proof.

Source

pub fn derive<Q>(self) -> Proven<Q, T>
where P: Implies<Q>,

If property P implies property Q, derive a new witness.

Source

pub fn and<Q>(self, _other: Proven<Q, T>) -> Proven<And<P, Q>, T>

Combine two independent proofs into a conjunction.

Source§

impl<P, Q, T> Proven<And<P, Q>, T>

Source

pub fn derive_second(self) -> Proven<Q, T>

Extract the second component from a conjunction proof.

(The first component is available via .derive() since And<P, Q>: Implies<P>.)

Source§

impl<T> Proven<IsAssociative, T>
where T: Semigroup,

Source

pub fn from_semigroup(value: T) -> Proven<IsAssociative, T>

Witness associativity from a Semigroup implementation.

Source§

impl<T> Proven<IsMonoid, T>
where T: Monoid,

Source

pub fn from_monoid(value: T) -> Proven<IsMonoid, T>

Witness monoid laws from a Monoid implementation.

Source§

impl<T> Proven<IsGroup, T>
where T: Group,

Source

pub fn from_group(value: T) -> Proven<IsGroup, T>

Witness group laws from a Group implementation.

Source§

impl<T> Proven<IsAbelianGroup, T>
where T: AbelianGroup,

Source

pub fn from_abelian(value: T) -> Proven<IsAbelianGroup, T>

Witness abelian group from an AbelianGroup implementation.

Source§

impl<T> Proven<IsSemiring, T>
where T: Semiring,

Source

pub fn from_semiring(value: T) -> Proven<IsSemiring, T>

Source§

impl<T> Proven<IsRing, T>
where T: Ring,

Source

pub fn from_ring(value: T) -> Proven<IsRing, T>

Source§

impl<T> Proven<IsField, T>
where T: Field,

Source

pub fn from_field(value: T) -> Proven<IsField, T>

Source§

impl<T> Proven<IsLattice, T>
where T: Lattice,

Source

pub fn from_lattice(value: T) -> Proven<IsLattice, T>

Source§

impl<T> Proven<IsBoundedLattice, T>
where T: BoundedLattice,

Trait Implementations§

Source§

impl<P, T> AbelianGroup for Proven<P, T>
where T: AbelianGroup,

Source§

impl<P, T> BoundedLattice for Proven<P, T>
where T: BoundedLattice,

Source§

fn top() -> Proven<P, T>

Source§

fn bottom() -> Proven<P, T>

Source§

impl<P, T> Clone for Proven<P, T>
where T: Clone,

Source§

fn clone(&self) -> Proven<P, T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<P, T> Copy for Proven<P, T>
where T: Copy,

Source§

impl<P, T> Debug for Proven<P, T>
where T: Debug,

Source§

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

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

impl<P, T> Eq for Proven<P, T>
where T: Eq,

Source§

impl<P, T> Field for Proven<P, T>
where T: Field,

Source§

fn reciprocal(self) -> Proven<P, T>

Source§

fn div(self, other: Self) -> Self
where Self: Sized,

Source§

impl<P, T> Group for Proven<P, T>
where T: Group,

Source§

fn invert(self) -> Proven<P, T>

Source§

fn combine_inverse(self, other: Self) -> Self
where Self: Sized,

Source§

impl<P, T> Hash for Proven<P, T>
where T: Hash,

Source§

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

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<P, T> Lattice for Proven<P, T>
where T: Lattice,

Source§

fn meet(self, other: Proven<P, T>) -> Proven<P, T>

Source§

fn join(self, other: Proven<P, T>) -> Proven<P, T>

Source§

impl<P, R, T> Module<R> for Proven<P, T>
where R: Ring, T: Module<R>,

Source§

fn scale(self, scalar: R) -> Proven<P, T>

Source§

impl<P, T> Monoid for Proven<P, T>
where T: Monoid,

Source§

fn empty() -> Proven<P, T>

Source§

impl<P, T> Ord for Proven<P, T>
where T: Ord,

Source§

fn cmp(&self, other: &Proven<P, T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<P, T> PartialEq for Proven<P, T>
where T: PartialEq,

Source§

fn eq(&self, other: &Proven<P, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<P, T> PartialOrd for Proven<P, T>
where T: PartialOrd,

Source§

fn partial_cmp(&self, other: &Proven<P, T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<P, T> Ring for Proven<P, T>
where T: Ring,

Source§

fn negate(self) -> Proven<P, T>

Source§

fn sub(self, other: Self) -> Self
where Self: Sized,

Source§

impl<P, T> Semigroup for Proven<P, T>
where T: Semigroup,

Source§

fn combine(self, other: Proven<P, T>) -> Proven<P, T>

Source§

impl<P, T> Semiring for Proven<P, T>
where T: Semiring,

Source§

fn add(self, other: Proven<P, T>) -> Proven<P, T>

Source§

fn mul(self, other: Proven<P, T>) -> Proven<P, T>

Source§

fn zero() -> Proven<P, T>

Source§

fn one() -> Proven<P, T>

Source§

impl<P, F, T> VectorSpace<F> for Proven<P, T>
where F: Field, T: VectorSpace<F>,

Auto Trait Implementations§

§

impl<P, T> Freeze for Proven<P, T>
where T: Freeze,

§

impl<P, T> RefUnwindSafe for Proven<P, T>

§

impl<P, T> Send for Proven<P, T>
where T: Send, P: Send,

§

impl<P, T> Sync for Proven<P, T>
where T: Sync, P: Sync,

§

impl<P, T> Unpin for Proven<P, T>
where T: Unpin, P: Unpin,

§

impl<P, T> UnsafeUnpin for Proven<P, T>
where T: UnsafeUnpin,

§

impl<P, T> UnwindSafe for Proven<P, T>
where T: UnwindSafe, P: UnwindSafe,

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.