Zulip Chat Archive
Stream: Is there code for X?
Topic: Pairs of bitvectors
Jakob von Raumer (Mar 28 2025 at 16:55):
Is there code in any repo about intrepreting pairs/vectors/lists of bitvectors as a big bitvector by appending? With lemmas saying that the "high" bitvector is 0 if the value is low enough etc.
Jakob von Raumer (Mar 28 2025 at 16:55):
@Tobias Grosser @Henrik Böving
Kim Morrison (Mar 28 2025 at 21:55):
Certainly appending pairs of BitVectors is supported, just as v ++ w
, and there is a fairly complete set of lemmas about this.
I have an abandoned PR at lean#3727 that defined
protected def flattenList {n : Nat} (xs : List (BitVec n)) : BitVec (n * xs.length) :=
but it needed work.
I would suggest just starting over on this, and:
- Now that the
Vector
API is fairly complete, just do it forVector n (BitVec m)
directly. - Writing the function with signature
Vector.flatMapBitVec (v : Vector n \a) (f : \a \to BitVec m) : BitVec (n * m)
first is probably best, and then definingVector.flattenBitVec
in terms of that. - Probably it is best to define variants for both little-endian and big-endian conventions.
Jakob von Raumer (Mar 29 2025 at 10:27):
I'll take up on this, including some analysis of the .toNat
of flattened vectors and about carries of multiplication etc
Jakob von Raumer (Apr 01 2025 at 09:13):
@Kim Morrison Any comment on lean#7754? Will add the BE versions of the type equivalence if the approach seems reasonable. I think with the lemmas about getElem
we don't even need specific lemmas for the arithmetic operations
Siddharth Bhat (Apr 01 2025 at 09:29):
@Jakob von Raumer I left another round of review on the new APIs!
Last updated: May 02 2025 at 03:31 UTC