Struct Frame

Source
pub struct Frame {
    pub stype: StatementType,
    pub valid: GlobalRange,
    pub label_atom: Atom,
    pub const_pool: Box<[u8]>,
    pub hypotheses: Box<[Hyp]>,
    pub target: VerifyExpr,
    pub stub_expr: Box<[u8]>,
    pub var_list: Box<[Atom]>,
    pub mandatory_count: usize,
    pub mandatory_dv: Box<[(VarIndex, VarIndex)]>,
    pub optional_dv: Box<[Bitset]>,
}
Expand description

Frames represent the logical content of the database, and are the main work product of the scope check pass.

Every $a and $p statement in the database is associated with a “frame” and an “extended frame” as defined in the Metamath spec. The frame consists of the math string of the statement, the strings of all hypotheses, and any disjoint variable hypotheses which are required to hold when using the statement in a later proof; the extended frame additionally contains types and disjointness conditions for variables that may be used in the proof, but are not mentioned in the hypotheses and thus need not be respected by users.

In the spec, the extended frame includes all $f statements which are in scope. We do not actually track optional $f statements directly in the frame; instead, when you encounter a use of a $f statement in a proof, you need to look it up and check the valid range to see if it can be used in the current proof. $f statements are tracked using the same Frame data type, although they do not strictly speaking have associated frames.

Since the primary user of frames currently is the verifier, the format is heavily tuned for what the verifier requires. From the verifier’s perspective, the main use of a frame is to match the top several entries in a proof stack and perform substitutions; the frame may be considered a kind of program, and optimizations are taken for the execution of steps.

Support for non-verifier users of frame data is expected to be quite weak at the present time.

Variable names are replaced with small integers so that the substitution being built can be maintained as an array.

Fields§

§stype: StatementType

Type of this statement, will be StatementType::Axiom, StatementType::Floating, or StatementType::Provable.

§valid: GlobalRange

Valid range of this statement.

Use this to ensure that $f pseudo-frames are used only where they are in scope, and that $a $p frames are not used before they are defined.

§label_atom: Atom

Atom representation of this statement’s label (valid only if incremental).

§const_pool: Box<[u8]>

Backing array for all literal fragments in the hypotheses and target expression.

§hypotheses: Box<[Hyp]>

Ordered list of hypotheses required by this frame.

The last entry corresponds to the top of the stack at application time. If you process hypotheses in the order of this list, then you will never need to subsitute a variable before it has been set; this is a consequence of Metamath rules requiring $f to be in scope for an $e to be valid.

§target: VerifyExpr

Expression which is subsituted and pushed on the stack after validating hypotheses.

§stub_expr: Box<[u8]>

Compressed representation of the variable name, used only for $f pseudo-frames.

§var_list: Box<[Atom]>

Mapping from variable indices to the variable names.

§mandatory_count: usize

Length of the prefix of var_list representing mandatory variables; the number of slots in the subsitution for this frame.

§mandatory_dv: Box<[(VarIndex, VarIndex)]>

List of pairs of variables in simple mandatory disjoint variable constraints for this frame.

§optional_dv: Box<[Bitset]>

Two-dimensional bit array of pairs of variables which can be treated as disjoint in proofs of this frame.

Implementations§

Source§

impl Frame

Source

pub const fn as_ref<'a>(&'a self, db: &'a Database) -> FrameRef<'a>

Augment a frame with a database reference, to produce a FrameRef.

Source

pub fn mandatory_vars(&self) -> &[Atom]

The list of mandatory variables in the frame.

Source

pub fn mandatory_hyps(&self) -> &[Hyp]

The list of mandatory hypotheses in the frame. Every Hyp in this list will be Hyp::Floating.

Source§

impl Frame

Source

pub fn floating(&self) -> impl Iterator<Item = StatementAddress> + '_

Iterates over the floating hypotheses for this frame.

Trait Implementations§

Source§

impl Clone for Frame

Source§

fn clone(&self) -> Frame

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 Frame

Source§

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

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

impl Default for Frame

Source§

fn default() -> Frame

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Frame

§

impl RefUnwindSafe for Frame

§

impl Send for Frame

§

impl Sync for Frame

§

impl Unpin for Frame

§

impl UnwindSafe for Frame

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.