Skip to content
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

feat: add Bitvec.(toInt, toFin)_twoPow #7225

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

luisacicolini
Copy link
Contributor

This PR contains BitVec.(toInt, toFin)_twoPow theorems, completing the API for BitVec.*_twoPow.

@luisacicolini luisacicolini changed the title chore: add theorems feat: add Bitvec.(toInt, toFin)_twoPow Feb 25, 2025
@luisacicolini
Copy link
Contributor Author

changelog-library

@github-actions github-actions bot added the changelog-library Library label Feb 25, 2025
Comment on lines +3743 to +3744
have hy : (2 ^ i % 2 ^ (w + 1)) = 2 ^ i := by rw [Nat.mod_eq_of_lt (by rw [Nat.pow_lt_pow_iff_right (by omega)]; omega)]
have hj : 2 * 2 ^ i = 2 ^ (i + 1) := by rw [Nat.pow_add, Nat.mul_comm]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
have hy : (2 ^ i % 2 ^ (w + 1)) = 2 ^ i := by rw [Nat.mod_eq_of_lt (by rw [Nat.pow_lt_pow_iff_right (by omega)]; omega)]
have hj : 2 * 2 ^ i = 2 ^ (i + 1) := by rw [Nat.pow_add, Nat.mul_comm]
have hy : 2 ^ i % 2 ^ (w + 1) = 2 ^ i := by rw [Nat.mod_eq_of_lt (by rw [Nat.pow_lt_pow_iff_right (by omega)]; omega)]
have hj : 2 * 2 ^ i = 2 ^ (i + 1) := by rw [Nat.pow_add, Nat.mul_comm]

I wonder if these two lemma above should not be named simp lemmas.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, the entire second half of the proof would be a lot nicer, if we can make avoid the casts in the middle and just make this all simp away. I am wondering if there is a set of simp lemmas which could help here?

Comment on lines +3747 to +3748
by_cases i + 1 = (w + 1)
· simp [show i = w by omega]; omega
Copy link
Contributor

@tobiasgrosser tobiasgrosser Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
by_cases i + 1 = (w + 1)
· simp [show i = w by omega]; omega
by_cases i + 1 = w + 1
· simp [show i = w by omega]; omega

@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Feb 25, 2025
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 2377f3542622e24dd1ad1ee49a20ea14e34f34d3 --onto 5cbeb22564c6caa0603612edfdabda4bdb34b780. (2025-02-25 13:43:44)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-library Library toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants