Substitution on syntactic objects #
SyntacticObject.replace s target replacement substitutes every subterm of s equal to
target by replacement; it is UnorderedTree.replace closed under well-formedness, which holds
because substitution preserves the arity of every vertex. The copy-theory use is
s.replace mover trace, leaving a trace where a mover was. This is a structural operation:
the Merge-algebraic Internal Merge is the coproduct composition of Merge/Internal.lean, with
traces as cut remainders and chains held at the workspace level, and replace supports the
transformational view that study files are written in. It is noncomputable; concrete cases
reduce by replace_self, replace_merge_of_ne, and the leaf lemmas.
Main definitions #
Substitution preserves well-formedness.
Replace every subterm of s equal to target by replacement.
Instances For
At a node other than the target, substitution recurses into both daughters.