Skip to main content

RefinementInfo

Struct RefinementInfo 

Source
pub struct RefinementInfo<'a> {
    pub carrier_type: &'a str,
    pub carrier_field: &'a str,
    pub param_name: &'a str,
    pub constructor_fn: &'a str,
    pub predicate: &'a Spanned<Expr>,
}
Expand description

A “refinement record” is the canonical refinement-via-opaque pattern: a single-field record X { carrier: T } paired with a validating smart constructor fn fromX(p: T) -> Result<X, _> body = match <pred-in-p> with true -> Result.Ok(X(carrier = p)) false -> Result.Err("...")

Detecting this shape lets backends emit the type as a true dependent / subset type (def X := { n : T // P n } in Lean, type X = n: T | P n in Dafny) instead of a flat product, which in turn collapses universal-law proofs into one-liners (rw [Int.add_comm]) by carrying the invariant inside the type rather than threading it through ad-hoc tactic plumbing.

Fields§

§carrier_type: &'a str

Carrier-type annotation as written in the record field ("Int", "Float", …). Backends emit this as the subset’s underlying type.

§carrier_field: &'a str

Carrier-field name (e.g. "value"). Lean projects through .val on a Subtype, so users of the carrier field have to rewrite n.value → n.val when the host type is refined.

§param_name: &'a str

Name of the smart constructor’s input parameter ("n" in fromInt(n: Int) → Result<X, _>). Used when substituting the law’s quantified variable into the predicate.

§constructor_fn: &'a str

Source-level name of the smart constructor itself ("fromInt"). The interval analysis gates its transparent-wrapper peel on this name so only the real smart constructor — never an arbitrary one-arg helper — is treated as identity over its argument.

§predicate: &'a Spanned<Expr>

AST node for the bool predicate the smart constructor branches on — the body’s Match { subject = <here>, ... }.

Trait Implementations§

Source§

impl<'a> Clone for RefinementInfo<'a>

Source§

fn clone(&self) -> RefinementInfo<'a>

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<'a> Debug for RefinementInfo<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for RefinementInfo<'a>

§

impl<'a> RefUnwindSafe for RefinementInfo<'a>

§

impl<'a> Send for RefinementInfo<'a>

§

impl<'a> Sync for RefinementInfo<'a>

§

impl<'a> Unpin for RefinementInfo<'a>

§

impl<'a> UnsafeUnpin for RefinementInfo<'a>

§

impl<'a> UnwindSafe for RefinementInfo<'a>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V