pub fn unify_pattern(
lhs: &ProofExpr,
rhs: &ProofExpr,
) -> ProofResult<ExprSubstitution>Expand description
Attempt higher-order pattern unification (Miller patterns).
Given lhs and rhs, if lhs is of the form Hole(h)(args...) where
args are distinct BoundVarRefs, solves: h = λargs. rhs.
§Miller Patterns
A Miller pattern is a meta-variable applied to distinct bound variables:
?P(x)is a valid pattern?F(x, y)is a valid pattern (x ≠ y)?G(x, x)is NOT valid (duplicate variable)?H(f(x))is NOT valid (non-variable argument)
§Why This Matters
Higher-order pattern unification is decidable and has unique most general solutions, unlike full higher-order unification. This restriction enables automatic motive inference for structural induction.
§Returns
Ok(subst)- AnExprSubstitutionmapping hole names to lambdasErr(PatternNotDistinct)- If pattern has duplicate variablesErr(NotAPattern)- If arguments aren’t bound variable referencesErr(ScopeViolation)- If RHS uses variables not in pattern scope
§Example
unify_pattern(?P(x), Even(x))
→ { "P" ↦ λx. Even(x) }§See Also
ExprSubstitution- The result type for hole solutionsProofError::PatternNotDistinct- Duplicate variable error