AngouriMath

Navigation

DerivationPath


← Back to list of classes

Description

Summary

How an expression became an answer: an ordered chain of whole expressions, each one the
result of the step before it, from the input to the value that was actually returned.

Remarks

This is what Steps and Derivation are not. Those are the rewrites that fired, across every candidate
Simplify(System.Int32) generated including the ones it discarded, each on the
subexpression it matched. Reading them in order does not walk from the input to the answer.
This does: Steps[i].After == Steps[i + 1].Before holds for every i,
Steps[0].Before is the Input, and the last step lands on the
Result. Compared as expressions, not as printed forms.
The losing candidates are not here. The simplifier explores far more expressions than
it keeps — ExpressionsExplored says how many — and a route through a discarded
candidate is not a route to the answer. They are excluded rather than labelled because a
derivation is read forwards: a reader following the chain from the input needs every entry
to be a step towards the answer, and a marked dead end is something to skip, which is the
same as not being there while costing the reader the skip. What was explored but not taken
is a fact about the search, and it is reported as a count for that reason.
Every step really happened. Each one is an edge the engine actually traversed, with
the expression it started from and the one it produced. Where several recorded routes reach
the answer, the shortest is taken, and ties are settled by the order the engine recorded
them in — so the same input gives the same path.

Example

using AngouriMath;
using AngouriMath.Core.Transformations;
            
foreach (var step in DerivationPath.OfSimplifying("x ^ (-1) / (y / z)")!.Steps)
    Console.WriteLine(step);

Members

























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