A term of the rewriting fragment: no Subst node anywhere. Rule sides live here.
Equations
- MeTTaIL.SubstFree (MeTTaIL.AST.var path) = True
- MeTTaIL.SubstFree (MeTTaIL.AST.sexp label args) = MeTTaIL.SubstFreeList args
- MeTTaIL.SubstFree (body.subst repl v) = False
Instances For
Equations
Instances For
Well-sorted terms are subst-free. The sort discipline (WellSorted has only var and sexp cases,
no Subst rule) rejects every Subst node, so a Subst term is never well-sorted. Hence the
subst-free fragment on which matcher correctness and the critical-pair confluence are stated coincides
with the well-sorted-TERM fragment.
Scope, stated honestly: this does NOT by itself cover rules whose right-hand side is a Subst (for
example the rho-calculus COMM rule in MeTTaILTests/Rholang.lean, whose RHS is .subst ...). Such a
rule's RHS is not well-sorted as written, and its reduct becomes subst-free only after inst resolves
the Subst. Subject reduction THROUGH that explicit-substitution resolution is a separate obligation
(the binder fragment), not discharged by this lemma. So this closes the first-order rewriting fragment,
not the binder fragment.
Structural instantiation: like AST.inst but it does NOT resolve a Subst node, rebuilding it
structurally with its bound variable kept literally. This is exactly the reconstruction the matcher
inverts: the matcher is purely structural and matches a Subst pattern's bound variable by syntactic
equality, so matcher correctness is stated against instStruct for the FULL pattern language. On the
subst-free fragment instStruct agrees with inst (instStruct_eq_inst_substFree), so the inst
theorems are recovered as corollaries.
Equations
- One or more equations did not get rendered due to their size.
- MeTTaIL.AST.instStruct bnds (MeTTaIL.AST.var p) = MeTTaIL.AST.var p
- MeTTaIL.AST.instStruct bnds (MeTTaIL.AST.sexp l args) = MeTTaIL.AST.sexp l (MeTTaIL.AST.instStructList bnds args)
- MeTTaIL.AST.instStruct bnds (b.subst r w) = (MeTTaIL.AST.instStruct bnds b).subst (MeTTaIL.AST.instStruct bnds r) w
Instances For
Structural instantiation through an argument list.
Equations
- MeTTaIL.AST.instStructList bnds [] = []
- MeTTaIL.AST.instStructList bnds (a :: as) = MeTTaIL.AST.instStruct bnds a :: MeTTaIL.AST.instStructList bnds as
Instances For
Extend a typing context along a path: a base name y binds y : c; a qualified path binds nothing
(no well-sorted variable can equal a qualified path), so the context is unchanged.
Equations
- Γ.extendPath (MeTTaIL.DottedPath.base y) c = (y, c) :: Γ
- Γ.extendPath q c = Γ
Instances For
The substitution lemma along an arbitrary path (the general subst1 half), the binder-fragment
counterpart of inst_wellSorted: substituting a term well-sorted at c for the path q in a term
well-sorted at d in the path-extended context yields a term well-sorted at d. For q = .base y
this is the binder substitution lemma; for a qualified path it holds vacuously (no well-sorted
variable matches a qualified path, so the term is unchanged and the extended context is Γ). This is
the key lemma for subject reduction of rules whose right-hand side is a Subst (explicit
substitution), such as the rho-calculus COMM rule (MeTTaILTests/Rholang.lean), whose reduct is
inst-resolved through subst1, INCLUDING the captured-bound-variable (alpha) case where the match
remaps the bound variable to another runtime variable. Kept here rather than in Semantics because it
needs LawfulBEq DottedPath from DecEq.
The binder substitution lemma for a base variable y: the q = .base y instance of
subst1_wellSorted_path (the original first-order/binder substitution lemma).
The substitution target that AST.inst computes for a Subst node's bound variable w: a base name
bound by the match to a runtime variable .var p is remapped to p (the capture-avoiding rename);
otherwise w itself. Mirrors the let w' := ... inside AST.inst's .subst case.
Equations
- One or more equations did not get rendered due to their size.
- MeTTaIL.AST.instSubstTarget bnds x✝ = x✝
Instances For
AST.inst on a Subst node resolves it to a subst1 along the remapped target.
Subject reduction for a Subst right-hand side (the binder fragment), in FULL generality including the
captured-bound-variable (alpha) case: the inst-resolved reduct of a rule whose RHS is subst b r w is
well-sorted. inst resolves the explicit substitution to a subst1 along the remapped target
instSubstTarget bnds w (the bound variable w, or the runtime variable it was matched to), so the
reduct is well-sorted when the instantiated body inst bnds b is well-sorted at d in the context
extended by that target and the instantiated inst bnds r is well-sorted at the target's sort. This
covers the rho-calculus COMM rule's reduction, INCLUDING when its bound variable is captured/remapped by
the match (the alpha case the earlier freshness-restricted version excluded).
Instantiation depends only on the pattern's variables #
The argument-list version.
instStruct leaves an unbound base variable alone (defeq to the inst version).
instStruct and inst coincide on a base variable (they have identical defining clauses there).
Two substitutions agreeing on a term's variables instantiate it the same way, for the FULL language
(the instStruct counterpart of inst_agree, with no subst-free restriction).
The argument-list version.
A successful Subst-headed match forces a Subst subject with the same (syntactic) bound variable, and
splits into a match of the body and a match of the replacement.
Matching a variable reconstructs the matched term #
A successful match of a qualified-path variable forces the term to be that variable and leaves the bindings unchanged (it is a structural-equality match).
Matching a base variable binds it to the matched term: instantiation gives the term back. The
repeated-variable case uses the matcher's consistency test t' == t, the equality re-check that MORK's
VarRefRecheck/BindingEnv Verus proofs validate.
Matching only extends the bindings, and binds every pattern variable #
BindingEnv in MORK's Verus proofs: a re-match is a no-op and a fresh bind only adds.
Subst-free corollary of matchPat_mono_all (the original matchPat_mono).
Subst-free corollary of matchPatList_mono_all (the original matchPatList_mono).
Subst-free corollary of matchPat_cover_all (the original matchPat_cover_sf).
Subst-free corollary of matchPatList_cover_all (the original matchPatList_cover_sf).
Matcher correctness: a successful match reconstructs the matched term #
A successful match produces a substitution that STRUCTURALLY instantiates the pattern back to the
matched term, for the FULL pattern language including Subst (the matcher inverts instStruct).
The argument-list version.
Subst-free corollary: a successful match inst-reconstructs the term (the original matchPat_inst_eq).
On the subst-free fragment inst = instStruct.
The argument-list version (the original matchPatList_inst_eq).
The runtime step is a genuine rule application #
The matcher correctness certifies the runtime: when applyBaseRewrite fires a (subst-free) base rule on a
term, the result really is the rule's right side instantiated at a substitution whose action on the left
side gives back the original term. So t ~> t' genuinely instances lhs ~> rhs.
A successful base rewrite is a genuine rule application: there is a substitution bnds with
t = lhs·bnds and t' = rhs·bnds.
Matcher completeness: the matcher finds every instance #
The dual of matchPat_inst_eq: the matcher never misses a match. This mirrors the completeness half of
MORK's VarRefRecheck (the re-check is sound and, under the right groundness, complete). Here completeness
is unconditional, because a substitution is a function, so a pattern's instance has equal subterms at a
repeated variable's positions and the consistency test always passes.
bnds agrees with a substitution σ: it binds each variable exactly as σ instantiates it.
Equations
- MeTTaIL.CompatS σ bnds = ∀ (v : String) (ty : MeTTaIL.AST), MeTTaIL.bndLookup bnds v = some ty → ty = MeTTaIL.AST.inst σ (MeTTaIL.AST.var (MeTTaIL.DottedPath.base v))
Instances For
The argument-list version (the original matchPatList_complete).
Matcher correctness, both directions, for the FULL pattern language (including Subst): a pattern
matches a term exactly when the term is a STRUCTURAL instance of the pattern.
Matcher correctness, both directions: a (subst-free) pattern matches a term exactly when the term is an
inst-instance of the pattern. The subst-free corollary of matchPat_iff_instStruct.