First-order substitution is a method of inserting expressions into expressions, perhaps changing binding variables to avoid capture. For example according to the definition
Def {i...j} == {k:| ik & kj }
the expression
Generally, one specifies a first order substitution by giving the "matrix", i.e. the expression into which one substitutes, and one gives a list of "target" variables to be replaced, and for each target one gives its "replacement expression". If we consider the replacement expressions as arguments, then the matrix and target variables together specify a "first-order
Second-order substitution is a method for inserting instances of a "pattern" into an expression, again changing binding variables as need be to avoid capture, where the pattern is itself simply instantiated by first order substitution. Consider the definition of symmetry for a relation.
Def Sym x,y:T. E(x;y) == a,b:T. E(a;b) E(b;a)
According to this definition,
A second-order
Generally, one specifies a second-order substitution by giving the matrix, a list of target variables which may now include second-order as well as first-order variables, and for each target variable, if it is a first-order variable then one gives its replacement expression, but if it is a second-order variable then one gives its "replacement function" which is a first-order substitution function (see above) with as many places as the second-order variable takes.
It is easy to see where the replacement functions for second order variables come from when expanding an operator instance according to an
As a last example illustrating more complex substitution consider this definition:
Def Weird(x; u,v. F(u;v)) == F(F(x;0);x)
Weird(3; u,v. vv-u) expands to33-(00-3)
Weird(3; v,u. vv-u) expands to(33-0)(33-0)-3
Weird(3; u,v. u) andWeird(3; v,u. u) both expand to3
Finally, observe that first-order variables can be construed simply as
About: