This file establishes a set of normalization lemmas for map
/mapAccumr
operations on vectors
Fold nested mapAccumr
s into one #
Bisimulations #
We can prove two applications of mapAccumr
equal by providing a bisimulation relation that relates
the initial states.
That is, by providing a relation R : σ₁ → σ₁ → Prop
such that R s₁ s₂
implies that R
also
relates any pair of states reachable by applying f₁
to s₁
and f₂
to s₂
, with any possible
input values.
Redundant state optimization #
The following section are collection of rewrites to simplify, or even get rid, redundant accumulation state
If there is a set of states that is closed under f
, and such that f
produces that same output
for all states in this set, then the state is not actually needed.
Hence, then we can rewrite mapAccumr
into just map
If there is a set of states that is closed under f
, and such that f
produces that same output
for all states in this set, then the state is not actually needed.
Hence, then we can rewrite mapAccumr₂
into just map₂
If an accumulation function f
, given an initial state s
, produces s
as its output state
for all possible input bits, then the state is redundant and can be optimized out
If an accumulation function f
, given an initial state s
, produces s
as its output state
for all possible input bits, then the state is redundant and can be optimized out
If an accumulation function f
, produces the same output bits regardless of accumulation state,
then the state is redundant and can be optimized out
If an accumulation function f
, produces the same output bits regardless of accumulation state,
then the state is redundant and can be optimized out
If f
takes a pair of states, but always returns the same value for both elements of the
pair, then we can simplify to just a single element of state
If f
takes a pair of states, but always returns the same value for both elements of the
pair, then we can simplify to just a single element of state
Unused input optimizations #
If f
returns the same output and next state for every value of it's first argument, then
xs : Vector
is ignored, and we can rewrite mapAccumr₂
into map
If f
returns the same output and next state for every value of it's second argument, then
ys : Vector
is ignored, and we can rewrite mapAccumr₂
into map