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: BitVec.toInt_neg_eq_ite #6153

Closed
wants to merge 1 commit into from

Conversation

bollu
Copy link
Contributor

@bollu bollu commented Nov 21, 2024

This PR adds a theorem that describes (-x).toInt as a case-split:

  • If x = intMin w, then (-x) overflows and is equal to intMin w = x = -x. and thus (-x).toInt = x.toInt.
  • otherwise, (-x).toInt = - (x.toInt).

This better matches the semantics one might expect of such an operation, since, in particular, it explicitly describes what happens when x = intMin, and it combines two existing lemmas on the two sides of the case split: neg_intMin , toInt_neg_of_ne_intMin

This PR adds a theorem that describes `(-x).toInt` as a case-split:
- If `x = intMin w`, then `(-x)` overflows and is equal to `intMin w = x = -x`.
  and thus `(-x).toInt = x.toInt`.
- otherwise, `(-x).toInt = - (x.toInt)`.

This is a building block to prove `BitVec.toInt_abs`,
from leanprover#5787
@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 Nov 21, 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 799b2b662825e646609963921f2c68489b2e664a --onto 72e952eadc6a171310f1d8e9d6e78acf98421494. (2024-11-21 12:32:59)

@bollu bollu mentioned this pull request Nov 21, 2024
@bollu bollu changed the title feat: BitVec.toInt_neg_eq_ite feat: BitVec.toInt_neg_eq_ite [1/2] Nov 21, 2024
@bollu bollu changed the title feat: BitVec.toInt_neg_eq_ite [1/2] feat: BitVec.toInt_neg_eq_ite Nov 21, 2024
@bollu
Copy link
Contributor Author

bollu commented Nov 21, 2024

changelog-library

@github-actions github-actions bot added the changelog-library Library label Nov 21, 2024
@kim-em
Copy link
Collaborator

kim-em commented Nov 21, 2024

This is already in #6154, right?

@kim-em kim-em closed this Nov 21, 2024
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