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

chore: add bv_toNat tag for toNat_ofInt #5608

Merged
merged 2 commits into from
Oct 3, 2024

Conversation

bollu
Copy link
Contributor

@bollu bollu commented Oct 3, 2024

These were missing from the bv_toNat simp-set,
discovered when refactoring LNSym's simp-set:
leanprover/LNSym#208

These were missing from the `bv_toNat` simp-set,
discovered when refactoring LNSym's simp-set:
leanprover/LNSym#208
@hargoniX hargoniX enabled auto-merge October 3, 2024 15:57
@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 Oct 3, 2024
@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 5dea30f169b91cdda9a3903a7a9d125e0f075605 --onto a4fda010f3d44c02393d5afd5cf05509989daf63. (2024-10-03 16:21:51)

@bollu
Copy link
Contributor Author

bollu commented Oct 3, 2024

Aha, I see that BitVec.toNat_sub is intentionally not part of the bv_toNat simp-set:https://github.com/leanprover/lean4/blob/master/src/Init/Data/BitVec/Lemmas.lean#L1935-L1938

-- We prefer this lemma to `toNat_sub` for the `bv_toNat` simp set.
-- For reasons we don't yet understand, unfolding via `toNat_sub` sometimes
-- results in `omega` generating proof terms that are very slow in the kernel.
@[bv_toNat] theorem toNat_sub' {n} (x y : BitVec n) :
    (x - y).toNat = ((x.toNat + (2^n - y.toNat)) % 2^n) := by
  rw [toNat_sub, Nat.add_comm]

auto-merge was automatically disabled October 3, 2024 17:30

Head branch was pushed to by a user without write access

@bollu bollu changed the title chore: add bv_toNat tags for toNat_{ofInt, sub} chore: add bv_toNat tags for toNat_ofInt Oct 3, 2024
@bollu bollu changed the title chore: add bv_toNat tags for toNat_ofInt chore: add bv_toNat tag for toNat_ofInt Oct 3, 2024
@hargoniX hargoniX added this pull request to the merge queue Oct 3, 2024
Merged via the queue into leanprover:master with commit f9048c1 Oct 3, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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