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.shiftLeft_shiftLeft, BitVec.shiftRight_shiftRight #4148

Merged
merged 3 commits into from
May 13, 2024

Conversation

bollu
Copy link
Contributor

@bollu bollu commented May 13, 2024

@bollu bollu requested a review from semorrison as a code owner May 13, 2024 10:22
@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 May 13, 2024
@leanprover-community-mathlib4-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 799923d145960c6f2515b510111df2c170b34ca3 --onto 7db8e6482e1dc46fd1070b3bf549112f02a4c05e. (2024-05-13 10:44:04)

@bollu bollu changed the title feat: BitVec.shiftLeft_shiftLeft, BitVec.shiftRight_shiftRight. feat: BitVec.shiftLeft_shiftLeft, BitVec.shiftRight_shiftRight May 13, 2024
Comment on lines 615 to 616
-- omega claims that the system cannot be proven, so we case bash.
-- The entire proof below should be redundant once omega is complete.
Copy link
Collaborator

Choose a reason for hiding this comment

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

decide statements are out of scope for omega!

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you want to case bash and then hand off to omega, use:

theorem BitVec.shiftLeft_shiftLeft (w : Nat) (x : BitVec w) (n m : Nat) :
    (x <<< n) <<< m = x <<< (n + m) := by
  ext i
  simp only [getLsb_shiftLeft, Fin.is_lt, decide_True, Bool.true_and]
  rw [show i - (n + m) = (i - m - n) by omega]
  cases h₂ : decide (i < m) <;> cases h₃ : decide (i - m < w) <;> cases h₄ : decide (i - m < n) <;> cases h₅ : decide (i < n + m) <;>
    simp at * <;> omega

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sweet, thanks for the tutorial! rw [show _ by omega] is a neat one, I'm going to remember this golf trick :)

@semorrison semorrison added the awaiting-author Waiting for PR author to address issues label May 13, 2024
bollu and others added 2 commits May 13, 2024 13:10
@semorrison semorrison added this pull request to the merge queue May 13, 2024
Merged via the queue into leanprover:master with commit a17c3f4 May 13, 2024
11 checks passed
github-merge-queue bot pushed a commit that referenced this pull request May 14, 2024
Fixes double namespace introduced in #4148
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-author Waiting for PR author to address issues 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.

None yet

3 participants