AngouriMath

Navigation

← Back to list of members

IsDeterministic

 Property

Summary

Whether this pattern can match an expression in at most one way, so that a
caller wanting a solution needs no enumeration and no backtracking.

Remarks

True for everything except Commutative``1(AngouriMath.Core.Transformations.Matching.MatchPattern,AngouriMath.Core.Transformations.Matching.MatchPattern) and Gathered``1(System.String,AngouriMath.Core.Transformations.Matching.MatchPattern[]),
and false for any node containing one of those, since a choice anywhere below makes
the whole pattern a search.
This is worth distinguishing because most rules are in the deterministic subset and enumeration is pure overhead for them: MatchCore(AngouriMath.Entity,AngouriMath.Core.Transformations.Matching.Bindings) is an iterator, so
a state machine is allocated for every node of the pattern at every attempt, and a
rewrite pass makes an attempt at every node of the tree. Measured on one rule set over
one tree, that was ten times the time and seven times the allocation of the
switch the set mirrors.

























Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 4378 pages online