AngouriMath
Canonicalize
Method (no overloads)
Summary
A canonical form for the commutative structure: two expressions differing only in
how their sums, products, conjunctions, disjunctions and set operations are
arranged or nested come out as the identical tree.
how their sums, products, conjunctions, disjunctions and set operations are
arranged or nested come out as the identical tree.
Remarks
expression comparable, not shorter, and it may well make it longer. What it
buys is that
the two are the same expression, where comparing simplified forms is not.
all. There is no canonical form for the whole language — deciding whether an
expression is zero is undecidable once
functions and
the arrangement of commutative operators. For rational functions over
a complete canonical form does exist, use
CanonicalizeAsRationalFunction.
library is from it.
Example
using AngouriMath;
using static System.Console;
WriteLine("x + y".ToEntity().Canonicalize() == "y + x".ToEntity().Canonicalize());
WriteLine("(x + y) + a".ToEntity().Canonicalize() == "x + (y + a)".ToEntity().Canonicalize());Prints
True
TrueAngouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 4378 pages online