Zulip Chat Archive
Stream: lean4
Topic: BitVec: popcount and parity?
François G. Dorais (Jan 19 2025 at 16:26):
Just wondering if there are plans to support popcount and/or parity for BitVec. They are not essential but they are common enough to even get hardware support on some architectures.
Henrik Böving (Jan 19 2025 at 16:30):
Currently the BitVec
API is modelled almost 1:1 after what is found in SMTLIB (which does notably not have a popcount/parity notion afaik). That being said I believe having an RFC that proposes the inclusion of these functions would be sensible, here are a bunch of things to consider:
- should they be defined in terms of other
BitVec
operations or, like most other current functionality, in terms of thetoNat
/toInt
semantics? - what about signed/unsigned versions? Does the distinction exists practically or does everyone just assume unsigned?
- should we pull them through to
UIntX
/IntX
? Potentially along with an efficient C implementation? -
We need to support them in
bv_decide
, this can mean two things:- providing lemmas that reduce them to already exists
BitVec
operations - providing lemmas that describe efficient circuits that we can implement in
bv_decide
In particular we can of course also go two steps here, first providing unfolding lemmas and then at a later point integrate with more optimized circuits intobv_decide
.
- providing lemmas that reduce them to already exists
-
How do they interact with the rest of the
BitVec
API? Do we want e.g. lemmas about what happens when you|||
when you&&&
when you+
?
François G. Dorais (Jan 19 2025 at 17:03):
Thanks! Before I'm ready to PR to core, I'll incubate in Batteries and answer these questions there.
Last updated: May 02 2025 at 03:31 UTC