-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ac_nf and add test cases for BitVec
ac_nf is a counterpart to ac_rfl, which normalizes bitvector expressions with respect to associativity and commutativity.
- Loading branch information
1 parent
4cd4bcc
commit 70386a1
Showing
3 changed files
with
129 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/- arithmetic | commutativity -/ | ||
|
||
example (a b c d : BitVec w) : | ||
a * b * c * d = d * c * b * a := by | ||
ac_nf | ||
rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a * b * c * d = d * c * b * a := by | ||
ac_rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a + b + c + d = d + c + b + a := by | ||
ac_nf | ||
rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a + b + c + d = d + c + b + a := by | ||
ac_rfl | ||
|
||
/- arithmetic | associativity -/ | ||
|
||
example (a b c d : BitVec w) : | ||
a * (b * (c * d)) = ((a * b) * c) * d := by | ||
ac_nf | ||
rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a * (b * (c * d)) = ((a * b) * c) * d := by | ||
ac_rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a + (b + (c + d)) = ((a + b) + c) + d := by | ||
ac_nf | ||
rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a + (b + (c + d)) = ((a + b) + c) + d := by | ||
ac_rfl | ||
|
||
/- bitwise operations | commutativity -/ | ||
|
||
example (a b c d : BitVec w) : | ||
a ^^^ b ^^^ c ^^^ d = d ^^^ c ^^^ b ^^^ a := by | ||
ac_nf | ||
rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a ^^^ b ^^^ c ^^^ d = d ^^^ c ^^^ b ^^^ a := by | ||
ac_rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a &&& b &&& c &&& d = d &&& c &&& b &&& a := by | ||
ac_nf | ||
rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a &&& b &&& c &&& d = d &&& c &&& b &&& a := by | ||
ac_rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a ||| b ||| c ||| d = d ||| c ||| b ||| a := by | ||
ac_nf | ||
rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a ||| b ||| c ||| d = d ||| c ||| b ||| a := by | ||
ac_rfl | ||
|
||
/- bitwise operations | associativity -/ | ||
|
||
example (a b c d : BitVec w) : | ||
a &&& (b &&& (c &&& d)) = ((a &&& b) &&& c) &&& d := by | ||
ac_nf | ||
rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a &&& (b &&& (c &&& d)) = ((a &&& b) &&& c) &&& d := by | ||
ac_rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a ||| (b ||| (c ||| d)) = ((a ||| b) ||| c) ||| d := by | ||
ac_nf | ||
rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a ||| (b ||| (c ||| d)) = ((a ||| b) ||| c) ||| d := by | ||
ac_rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a ^^^ (b ^^^ (c ^^^ d)) = ((a ^^^ b) ^^^ c) ^^^ d := by | ||
ac_nf | ||
rfl | ||
|
||
example (a b c d : BitVec w) : | ||
a ^^^ (b ^^^ (c ^^^ d)) = ((a ^^^ b) ^^^ c) ^^^ d := by | ||
ac_rfl |