-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Operations for bit representation of Nat
and BitVec
.
#366
Conversation
5e1c285
to
e6c22fb
Compare
8b340c3
to
2fd27f9
Compare
2fd27f9
to
8fe48e0
Compare
Nat
and BitVec
.
Nat
and BitVec
.Nat
and BitVec
.
Co-authored-by: Scott Morrison <[email protected]>
Co-authored-by: Scott Morrison <[email protected]>
Co-authored-by: Scott Morrison <[email protected]>
Co-authored-by: Scott Morrison <[email protected]>
30b8c79
to
d61e9e7
Compare
@semorrison I think I've done all the changes you suggested. |
theorem testBit_bitwise | ||
(false_false_axiom : f false false = false) (x y i : Nat) | ||
: (bitwise f x y).testBit i = f (x.testBit i) (y.testBit i) := by | ||
induction i using Nat.strongInductionOn generalizing x y with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This formatting looks pretty weird to me
theorem toNat_eq (x y : BitVec n) : x = y ↔ x.toNat = y.toNat := | ||
Iff.intro (congrArg BitVec.toNat) eq_of_toNat_eq |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mathlib has this lemma, but calls it toNat_inj
and states it in reverse.
revert . fix a bit blech one more comment out broken and unused results chore: bump Std remove redundant simp lemmas cleanup fix: make `Nat.testBit_bitwise` a simp-lemma again. This fixes the Int.testbit_bitwise proofs fix `castNum_testBit` fix `testBit_eq_inth` fixes golf golf Apply suggestions from code review Co-authored-by: Eric Wieser <[email protected]> fix whitespace fix name conflict more efficient restore lemma feat: Mapping extreme points under continuous maps (#8574) Prove that extreme points are preserved under affine equivalences, and the less trivial statement that a continuous affine map sends extreme points of a compact set to a superset of the extreme points of the image of that set. Also fix a few name and tweak the API a bit. Co-authored-by: Yury G. Kudryashov <[email protected]> chore(Profinite): allow more universe flexibility in Profinite/CofilteredLimit (#8613) We allow the indexing category for the cofiltered limit in the result `Profinite.exists_locallyConstant` to live in a smaller universe than our profinite sets. feat(CategoryTheory): `Preregular` and `FinitaryPreExtensive` implies `Precoherent` (#8643) We prove some results about effective epimorphisms which allow us to deduce that a category which is `FinitaryPreExtensive` and `Preregular` is also `Precoherent`. feat(Analysis/Seminorm): add more `*ball_smul_*ball` (#8724) We had `ball_smul_ball` and `closedBall_smul_closedBall`. Add versions with mixed `ball` and `closedBall`. Also move this lemmas below and golf the proofs. feat: the annihilator of the kernel of the trace form of a Lie module is contained in the span of its weights (#8739) fix breakage in BitVec lemmas
revert . fix a bit blech one more comment out broken and unused results chore: bump Std remove redundant simp lemmas cleanup fix: make `Nat.testBit_bitwise` a simp-lemma again. This fixes the Int.testbit_bitwise proofs fix `castNum_testBit` fix `testBit_eq_inth` fixes golf golf Apply suggestions from code review Co-authored-by: Eric Wieser <[email protected]> fix whitespace fix name conflict more efficient restore lemma feat: Mapping extreme points under continuous maps (#8574) Prove that extreme points are preserved under affine equivalences, and the less trivial statement that a continuous affine map sends extreme points of a compact set to a superset of the extreme points of the image of that set. Also fix a few name and tweak the API a bit. Co-authored-by: Yury G. Kudryashov <[email protected]> chore(Profinite): allow more universe flexibility in Profinite/CofilteredLimit (#8613) We allow the indexing category for the cofiltered limit in the result `Profinite.exists_locallyConstant` to live in a smaller universe than our profinite sets. feat(CategoryTheory): `Preregular` and `FinitaryPreExtensive` implies `Precoherent` (#8643) We prove some results about effective epimorphisms which allow us to deduce that a category which is `FinitaryPreExtensive` and `Preregular` is also `Precoherent`. feat(Analysis/Seminorm): add more `*ball_smul_*ball` (#8724) We had `ball_smul_ball` and `closedBall_smul_closedBall`. Add versions with mixed `ball` and `closedBall`. Also move this lemmas below and golf the proofs. feat: the annihilator of the kernel of the trace form of a Lie module is contained in the span of its weights (#8739) fix breakage in BitVec lemmas
else | ||
simp [h] | ||
|
||
theorem toNat_append (x : BitVec m) (y : BitVec n) : (x ++ y).toNat = x.toNat <<< n ||| y.toNat := |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In mathlib this had arguments msbs
and lsbs
for clarity; it feels like a regression to rename them back to x
and y
.
Notably leanprover-community/batteries#366 changed the definition of `testBit` (to something equivalent) when upstreaming it, which broke a handful of proofs. Other conflicting changes in Std, resolved for now by priming the mathlib name: * `Std.BitVec.adc`: the type was changed from `BitVec (n + 1)` to `Bool × BitVec w` * `Nat.mul_add_mod`: the type was changed from `(a * b + c) % b = c % b` to `(b * a + c) % b = c % b` [Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/348111-std4/topic/Mathlib.20bump.20for.20.22Operations.20for.20bit.20representation.20of.20.2E.2E.2E.22/near/404801443) Co-authored-by: Scott Morrison <[email protected]> Co-authored-by: Alex Keizer <[email protected]> Co-authored-by: Eric Wieser <[email protected]>
Notably leanprover-community/batteries#366 changed the definition of `testBit` (to something equivalent) when upstreaming it, which broke a handful of proofs. Other conflicting changes in Std, resolved for now by priming the mathlib name: * `Std.BitVec.adc`: the type was changed from `BitVec (n + 1)` to `Bool × BitVec w` * `Nat.mul_add_mod`: the type was changed from `(a * b + c) % b = c % b` to `(b * a + c) % b = c % b` [Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/348111-std4/topic/Mathlib.20bump.20for.20.22Operations.20for.20bit.20representation.20of.20.2E.2E.2E.22/near/404801443) Co-authored-by: Scott Morrison <[email protected]> Co-authored-by: Alex Keizer <[email protected]> Co-authored-by: Eric Wieser <[email protected]>
This is a large PR that has operations for working with Nat and BitVec as functions from indices to Bool. In particular it builds upon work in #314 and #358