Enum mm0b_parser::UnifyCmd[][src]

pub enum UnifyCmd {
    Term {
        tid: TermId,
        save: bool,
    },
    Ref(u32),
    Dummy(SortId),
    Hyp,
}
Expand description

Unify commands appear in the header data for a def or axiom/theorem. They are executed by the ProofCmd::Thm command in order to perform substitutions. The state of the unify stack machine is:

  • MS: Stack<StackEl>: The main stack, called S in the ProofCmd documentation. Since a unification is called as a subroutine during a proof command, the main stack is available, but most operations don’t use it.
  • S: Stack<Expr>: The unify stack, which contains expressions from the target context that are being destructured.
  • H: Vec<Expr>: The unify heap, also known as the substitution. This is initialized with the expressions that the target context would like to substitute for the variable names in the theorem being applied, but it can be extended in order to support substitutions with sharing as well as dummy variables.

Variants

Term
UTerm t: S, (t e1 ... en) --> S, en, ..., e1
USave: H; S, e --> H, e; S, e
UTermSave t = USave; UTerm t:
  H; S, (t e1 ... en) --> H, (t e1 ... en); S, en, ..., e1

Pop an element from the stack, ensure that the head is t, then push the n arguments to the term (in reverse order, so that they are dealt with in the correct order in the command stream). UTermSave does the same thing but saves the term to the unify heap before the destructuring.

Fields of Term

tid: TermId

The term that should be at the head

save: bool

True if we want to recall this substitution for later

Ref(u32)
URef i: H; S, Hi --> H; S

Get the i-th element from the unify heap (the substitution), and match it against the head of the unify stack.

Tuple Fields of Ref

0: u32
Dummy(SortId)
UDummy s: H; S, x --> H, x; S   (where x:s)

Pop a variable from the unify stack (ensure that it is a name of the appropriate sort) and push it to the heap (ensure that it is distinct from everything else in the substitution).

Tuple Fields of Dummy

0: SortId
Hyp
UHyp (UThm mode):  MS, |- e; S --> MS; S, e
UHyp (UThmEnd mode):  HS, e; S --> HS; S, e

UHyp is a command that is used in theorem declarations to indicate that we are about to read a hypothesis. There are two contexts where we read this, when we are first declaring the theorem and check the statement (UThmEnd mode), and later when we are applying the theorem and have to apply a substitution (UThm mode). When we are applying the theorem, we have |- e on the main stack, and we pop that and load the expression onto the unify stack. When we are checking a theorem, we have been pushing hypotheses onto the hypothesis stack, so we pop it from there instead.

Implementations

Serialize a UnifyCmd to the given writer. Uses the UNIFY_* commands in mmb::export::cmd.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.