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: complete BitVec.[getMsbD|getLsbD|msb] for shifts #5604

Merged
merged 33 commits into from
Oct 13, 2024
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6d69881
added (add, sub, mul)_eq_xor
luisacicolini Oct 1, 2024
6793410
Update src/Init/Data/BitVec/Lemmas.lean
luisacicolini Oct 1, 2024
8395eb6
Update src/Init/Data/BitVec/Lemmas.lean
luisacicolini Oct 1, 2024
9a81414
Update src/Init/Data/BitVec/Lemmas.lean
luisacicolini Oct 1, 2024
0dcd369
Update src/Init/Data/BitVec/Lemmas.lean
luisacicolini Oct 1, 2024
99f88c9
Update src/Init/Data/BitVec/Lemmas.lean
luisacicolini Oct 1, 2024
bee8960
Update src/Init/Data/BitVec/Lemmas.lean
luisacicolini Oct 1, 2024
413d92b
Update src/Init/Data/BitVec/Lemmas.lean
luisacicolini Oct 1, 2024
3898e69
fix parentheses
luisacicolini Oct 1, 2024
1727d6f
msb, lsb, shift
luisacicolini Oct 3, 2024
e29e653
fixed deprecation
luisacicolini Oct 3, 2024
12c2a38
second attempt to fix ci
luisacicolini Oct 3, 2024
d7d1c2e
Update src/Init/Data/BitVec/Lemmas.lean
luisacicolini Oct 3, 2024
b919cd4
removed unrelated theorems and fixed comments
luisacicolini Oct 3, 2024
cedbbd8
fixed deprecated
luisacicolini Oct 3, 2024
e86986e
fixed non-term simp
luisacicolini Oct 3, 2024
914d316
let's start again
luisacicolini Oct 3, 2024
42a58ef
refactored and expanded proofs
luisacicolini Oct 3, 2024
2ae42e5
third expanded version of said thms
luisacicolini Oct 3, 2024
2c1223d
completed proof (a lot of space for improvement)
luisacicolini Oct 3, 2024
eef65a1
polished getMsbD_sshiftRight
luisacicolini Oct 5, 2024
e18ab37
better now
luisacicolini Oct 5, 2024
b509af4
last nit
luisacicolini Oct 5, 2024
dcedcad
Merge branch 'master' into shift-msb-lsb
luisacicolini Oct 5, 2024
f553f1e
more sensible name
luisacicolini Oct 5, 2024
dcc7d91
Update src/Init/Data/BitVec/Lemmas.lean
luisacicolini Oct 5, 2024
33292d9
getMsbD_ushiftRight is now a swan
luisacicolini Oct 5, 2024
f9d3e73
polished sshiftRight
luisacicolini Oct 5, 2024
1891a64
nit
luisacicolini Oct 5, 2024
70ab993
updated getMsbD_sshiftRight'
luisacicolini Oct 5, 2024
91108ad
Merge branch 'master' into shift-msb-lsb
luisacicolini Oct 7, 2024
8b410b2
fixed simp-related issues
luisacicolini Oct 7, 2024
71ade77
fixed normal form in msb_ushiftRight
luisacicolini Oct 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Init/Data/BitVec/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ theorem sshiftRight_or_distrib (x y : BitVec w) (n : Nat) :
<;> simp [*]

/-- The msb after arithmetic shifting right equals the original msb. -/
theorem sshiftRight_msb_eq_msb {n : Nat} {x : BitVec w} :
theorem msb_sshiftRight {n : Nat} {x : BitVec w} :
(x.sshiftRight n).msb = x.msb := by
rw [msb_eq_getLsbD_last, getLsbD_sshiftRight, msb_eq_getLsbD_last]
by_cases hw₀ : w = 0
Expand All @@ -1322,7 +1322,7 @@ theorem sshiftRight_add {x : BitVec w} {m n : Nat} :
by_cases h₃ : m + (n + ↑i) < w
· simp [h₃]
omega
· simp [h₃, sshiftRight_msb_eq_msb]
· simp [h₃, msb_sshiftRight]

theorem not_sshiftRight {b : BitVec w} :
~~~b.sshiftRight n = (~~~b).sshiftRight n := by
Expand Down Expand Up @@ -1376,7 +1376,7 @@ theorem getMsbD_sshiftRight' {x y: BitVec w} {i : Nat} :

theorem msb_sshiftRight' {x y: BitVec w} :
(x.sshiftRight' y).msb = x.msb := by
simp [BitVec.sshiftRight', BitVec.sshiftRight_msb_eq_msb]
simp [BitVec.sshiftRight', BitVec.msb_sshiftRight]

/-! ### udiv -/

Expand Down Expand Up @@ -2914,7 +2914,7 @@ abbrev zeroExtend_truncate_succ_eq_zeroExtend_truncate_or_twoPow_of_getLsbD_true
@[deprecated and_one_eq_setWidth_ofBool_getLsbD (since := "2024-09-18")]
abbrev and_one_eq_zeroExtend_ofBool_getLsbD := @and_one_eq_setWidth_ofBool_getLsbD

@[deprecated sshiftRight_msb_eq_msb (since := "2024-10-03")]
abbrev msb_sshiftRight := @sshiftRight_msb_eq_msb
@[deprecated msb_sshiftRight (since := "2024-10-03")]
luisacicolini marked this conversation as resolved.
Show resolved Hide resolved
abbrev sshiftRight_msb_eq_msb := @msb_sshiftRight

end BitVec
Loading