iunfoldr is an iterative operation that applies a function f
repeatedly.
It produces a sequence of state values [s_0, s_1 .. s_w]
and a bitvector
v
where f i s_i = (s_{i+1}, b_i)
and b_i
is bit i
th least-significant bit
in v
(e.g., getLsb v i = b_i
).
Theorems involving iunfoldr
can be eliminated using iunfoldr_replace
below.
Equations
- BitVec.iunfoldr f s = Fin.hIterate (fun (i : Nat) => α × BitVec i) (s, BitVec.nil) fun (i : Fin w) (q : α × BitVec ↑i) => (fun (p : α × Bool) => (p.fst, BitVec.cons p.snd q.snd)) (f i q.fst)