AngouriMath

Navigation

RewriteRecording


← Back to list of classes

Description

Summary

Collects the rewrites that fire while it is open, so that an answer can be asked how
it was reached rather than only what it is.

Remarks

Off unless asked for, and off is free: with no recording open, applying a rule set
costs one ambient read more than it did before — per rule set, not per node — and
allocates nothing. That is the condition
#746 puts on
every layer above the tree, and it is why this is a scope rather than a setting that
something might leave on.
Per flow, like Settings: the recording belongs to the call rather
than to the thread running it. It survives an await, and work
started under it — including on another thread — reports to it. A recording opened
inside a task is invisible to that task's siblings and to whatever started it.
Order is not guaranteed once work is parallel. Steps from one flow keep the
order they fired in, but two flows recording into the same open recording interleave
however they happen to run. The single-threaded case — which is what
Simplify(System.Int32) is — is unaffected.
What this is not. It records rewrites — which is what
#28 asks for —
and not everything Simplify(System.Int32) does. Simplification also
expands, factorises, divides polynomials, minimises boolean expressions and then
*chooses* among the candidates by a complexity metric; the steps below are the
rewrites, in the order they fired, across every candidate that was generated,
including the ones that lost. Reading them as a route from the input to the returned
answer would be reading in something that is not there.

Example

using AngouriMath;
using AngouriMath.Core.Transformations;
            
using var recording = RewriteRecording.Start();
var simplified = ((Entity)"a / (b / c)").Simplify();
foreach (var step in recording.Steps)
    Console.WriteLine(step);

Members

























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