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.[(getMsbD, msb)_extractLsb', (getLsbD, getMsbD, msb)_extractLsb] #6792

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

luisacicolini
Copy link
Contributor

This PR adds theorems BitVec.(getMsbD, msb)_(extractLsb', extractLsb), getMsbD_extractLsb'_eq_getLsbD.

@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 Jan 27, 2025
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Jan 27, 2025

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 56733b953eee491cbd1a95018bdb6a76506f5e61 --onto 69a73a18fbfa1fc045bfbf1c4cf93b155d4c9387. (2025-01-27 12:27:39)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 56733b953eee491cbd1a95018bdb6a76506f5e61 --onto 20c616503abe5ce4253c56dbcd7766a91c675ba0. (2025-01-29 13:33:45)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 56733b953eee491cbd1a95018bdb6a76506f5e61 --onto e922edfc218090ab2e54092336c67fe3b970dfc2. (2025-01-30 20:26:30)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 56733b953eee491cbd1a95018bdb6a76506f5e61 --onto d68c2ce28bc11ec0271a97aa7a7316905f15a484. (2025-02-03 09:05:10)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 56733b953eee491cbd1a95018bdb6a76506f5e61 --onto 832d7c500d709deb5e7f0a5a6fd0f01865d1a303. (2025-02-03 10:25:47)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 56733b953eee491cbd1a95018bdb6a76506f5e61 --onto 412389f71f8a24307e3adba69b38b4b685b04f72. (2025-02-05 09:53:54)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 56733b953eee491cbd1a95018bdb6a76506f5e61 --onto b01ca8ee237a1b3c299384e73ad79d424e216a84. (2025-02-07 17:52:57)

@luisacicolini
Copy link
Contributor Author

changelog-library

@github-actions github-actions bot added the changelog-library Library label Jan 28, 2025
Copy link
Contributor

@bollu bollu left a comment

Choose a reason for hiding this comment

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

Thanks for the API :) I request a couple of minor syntactic changes, and one simplification of a theorem statement.

src/Init/Data/BitVec/Lemmas.lean Outdated Show resolved Hide resolved
src/Init/Data/BitVec/Lemmas.lean Outdated Show resolved Hide resolved
src/Init/Data/BitVec/Lemmas.lean Outdated Show resolved Hide resolved
src/Init/Data/BitVec/Lemmas.lean Outdated Show resolved Hide resolved
luisacicolini and others added 3 commits January 29, 2025 11:38
@luisacicolini luisacicolini requested a review from bollu January 29, 2025 14:46
Copy link
Contributor

@alexkeizer alexkeizer left a comment

Choose a reason for hiding this comment

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

Some style comments

src/Init/Data/BitVec/Lemmas.lean Show resolved Hide resolved
src/Init/Data/BitVec/Lemmas.lean Outdated Show resolved Hide resolved
src/Init/Data/BitVec/Lemmas.lean Outdated Show resolved Hide resolved
src/Init/Data/BitVec/Lemmas.lean Outdated Show resolved Hide resolved
src/Init/Data/BitVec/Lemmas.lean Outdated Show resolved Hide resolved
src/Init/Data/BitVec/Lemmas.lean Outdated Show resolved Hide resolved
@luisacicolini
Copy link
Contributor Author

awaiting-review

@github-actions github-actions bot added the awaiting-review Waiting for someone to review the PR label Jan 30, 2025
@luisacicolini luisacicolini marked this pull request as ready for review January 30, 2025 22:52
@luisacicolini luisacicolini requested a review from kim-em as a code owner January 30, 2025 22:52
@kim-em kim-em added the awaiting-author Waiting for PR author to address issues label Feb 5, 2025
@luisacicolini luisacicolini requested a review from bollu February 5, 2025 15:37
@luisacicolini
Copy link
Contributor Author

awaiting-review

@github-actions github-actions bot added awaiting-review Waiting for someone to review the PR and removed awaiting-author Waiting for PR author to address issues labels Feb 6, 2025
@@ -789,6 +815,32 @@ protected theorem extractLsb_ofNat (x n : Nat) (hi lo : Nat) :
getLsbD (extractLsb hi lo x) i = (i ≤ (hi-lo) && getLsbD x (lo+i)) := by
simp [getLsbD, Nat.lt_succ]

@[boolToPropSimps] theorem and_eq_decide (a b : Bool) : (a && b) = decide (a = true ∧ b = true) := by simp [Bool.decide_and]
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this belong in this file?

@luisacicolini luisacicolini changed the title feat: add BitVec.(getMsbD, msb)_(extractLsb', extractLsb), getMsbD_extractLsb'_eq_getLsbD feat: add BitVec.[(getMsbD, msb)_extractLsb', (getLsbD, getMsbD, msb)_extractLsb] Feb 7, 2025
src/Init/Data/Bool.lean Outdated Show resolved Hide resolved
src/Init/Data/Bool.lean Outdated Show resolved Hide resolved
@luisacicolini
Copy link
Contributor Author

luisacicolini commented Feb 7, 2025

After reasoning about it, the solution I am adopting to balance the organization of theorems in the appropriate locations without breaking consists of:

  1. moving and_eq_decide_true to Data/Bool, removing the @[boolToPropSimps] which would otherwise break another theorem, adding Bool.and_eq_decide_true in the necessary simp (l. 829)
  2. adding decide_eq_true_iff to the simp directly, avoiding the attribute specification (l. 829)

This should ensure that we don't break existing theorems, while still maintaining a relatively nice proof for getMsbD_extractLsb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review Waiting for someone to review the PR changelog-library Library P-medium We may work on this issue if we find the time 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.

7 participants