Folding over Fin
#
This file defines the prime versions of Fin.(d)fold{l/r}
which has better definitional equalities
(i.e. automatically unfold for 0
and for n.succ
). We then show equivalences between the prime
and non-prime versions, so that when compiling, the non-prime versions (which are more efficient)
are used.
We also prove that the existing mathlib function finSumFinEquiv : ∑ i, Fin (n i) ≃ Fin (∑ i, n i)
is equivalent to a version defined via Fin.dfoldl'
.
Heterogeneous left fold over Fin n
in a monad, prime version with better defeq.
Automatically unfolds for 0
and n.succ
.
Equations
Instances For
Heterogeneous right fold over Fin n
in a monad, prime version with better defeq.
Automatically unfolds for 0
and n.succ
.
Equations
Instances For
Congruence for dfoldl
Congruence for dfoldl
whose type vectors are indexed by ι
and have a DCast
instance
Note that we put cast
(instead of dcast
) in the theorem statement for easier matching,
but dcast
inside the hypotheses for downstream proving.