Parenthesized reductions #
ReductionTree records a nonempty reduction without choosing an arithmetic implementation.
Unlike mathlib's BinaryTree, values occur at leaves, not internal nodes. An empty reduction
needs a separately chosen identity and is deliberately not represented here.
A nonempty collection of inputs together with a binary evaluation schedule.
- leaf {α : Type u_1} (value : α) : ReductionTree α
- node {α : Type u_1} (left right : ReductionTree α) : ReductionTree α
Instances For
Instances For
Instances For
Input occurrences in left-to-right order, including repetitions.
Instances For
Evaluate the chosen schedule; the combining operation need not be associative.
Instances For
Change leaf values without changing the evaluation schedule.
Instances For
Mapping preserves the order and multiplicity of leaf occurrences.
Number of combining operations in the schedule.
Instances For
A full binary reduction performs one fewer addition than it has inputs.
A permutation of inputs cannot change the number of combining operations.
A predicate on the two evaluated operands holds at every internal node of this tree.
Instances For
Interpretation commutes with evaluation when it preserves the actual operations used.
Reordering leaves or changing parentheses preserves an exact commutative sum.