patmatch1.spad line 410 [edit on github]
This package provides tools for the pattern matcher.
patternMatch(lsubj, lpat, op, res, match) matches the list of patterns lpat to the list of subjects lsubj, allowing for commutativity; op is the operator such that op(lpat) should match op(lsubj) at the end, r contains the previous matches, and match is a pattern-matching function on P.
patternMatchTimes(lsubj, lpat, res, match) matches the product of patterns reduce(*, lpat) to the product of subjects reduce(*, lsubj); r contains the previous matches and match is a pattern-matching function on P.