AngouriMath

Navigation

EntityOrder


← Back to list of classes

Description

Summary

A total order on expressions, for choosing the representative of a set of equal
ones rather than a nice one.

Remarks

Why this is not a CostModel. A cost model answers "which of these is
nicer" with a Double, and two expressions it cannot separate therefore tie —
which CostModel's own remarks say is common enough to design the models
against. A tie is settled by whichever candidate was reached first, and that is an accident
of traversal rather than a form anybody chose. A canonical form cannot be built on an
accident: it needs exactly one least member, and the same one every run. No
Double can carry a total order on trees, so this is a comparison instead.
Why this is not Entity.SortHash. That key orders the operands within a
commutative chain, which is what RewriteRules.CanonicalOrder and its two siblings
sort by. Choosing between whole expressions that are equal is a different question — the
operands are not siblings, they are rival writings of one value — and a key built to answer
the first is not thereby an answer to the second. The two do not compete: a canonical
extraction under this order still wants its operands sorted by that one.

Members

























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