pub struct SimpRule {
pub name: String,
pub binders: Vec<(String, Term)>,
pub lhs: Term,
pub rhs: Term,
pub head: String,
}Expand description
The @[simp] registry’s compiled rule — Context::simp_rules/simp_rules_for hand these to
whatever does the rewriting, already destructured into ∀x̄. lhs ⟶ rhs.
A @[simp] lemma COMPILED to the form a rewriter applies: ∀x̄. lhs ⟶ rhs.
The binders are the lemma’s universally quantified variables in order; lhs and rhs
mention them as Term::Var. head is lhs’s head symbol and is the registry’s dispatch
key — see Context::simp_rules_for.
Fields§
§name: StringThe lemma’s name, so a rewrite can say which lemma fired.
binders: Vec<(String, Term)>Universally quantified variables, outermost first, with their types.
lhs: TermThe pattern to match.
rhs: TermWhat to replace a match with.
head: Stringlhs’s head symbol — the dispatch key.
Implementations§
Source§impl SimpRule
impl SimpRule
Sourcepub fn compile(name: &str, stmt: &Term) -> KernelResult<SimpRule>
pub fn compile(name: &str, stmt: &Term) -> KernelResult<SimpRule>
Compile a declared statement Π(x̄). Eq A lhs rhs into a rule, or say why it is not one.
Sourcepub fn rewrite(&self, term: &Term) -> Option<Term>
pub fn rewrite(&self, term: &Term) -> Option<Term>
Try to rewrite term with this rule AT THE TOP LEVEL — first-order matching of lhs
against term, then rhs under the resulting substitution. None means the rule does
not apply; the caller descends into subterms itself.
This lives with the rule rather than with the rewriter for one reason: matching has to
agree with what SimpRule::compile refused. A rewriter that wrote its own matcher could
bind a pattern variable twice to two different terms, or substitute a variable the rule
never bound — and both are silent wrong answers rather than failures.