MatchPy: Pattern Matching in Python

Manuel Krebber, Henrik Barthels · The Journal of Open Source Software · 2018

Pattern matching is a powerful tool for symbolic computations.Applications include symbolic integration, term rewriting systems, theorem proving and the manipulation of abstract syntax trees.Given a pattern and an expression, the goal of pattern matching is to find a substitution for all the variables in the pattern such that the pattern becomes the expression.As an example, consider the pattern f(x), where x is a variable, and the expression f(a).Then the substitution that replaces x with a is a match.In practice, functions can also be associative and/or commutative, which makes matching more complicated and can lead to multiple possible matches.

Read the paper · More papers on PaperTik