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

Lean: Fixing Lean style and wrong definition in Sail.lean #891

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion lib/vector.sail
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ val truncateLSB = pure {
interpreter: "vector_truncateLSB",
lem: "vector_truncateLSB",
coq: "vector_truncateLSB",
lean: "Sail.BitVec.truncateLSB",
lean: "Sail.BitVec.truncateLsb",
_: "sail_truncateLSB"
} : forall 'm 'n, 'm >= 0 & 'm <= 'n. (bits('n), int('m)) -> bits('m)

Expand Down
12 changes: 6 additions & 6 deletions src/sail_lean_backend/Sail/Sail.lean
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
namespace Sail
namespace BitVec

def length {w: Nat} (_: BitVec w): Nat := w
def length {w : Nat} (_ : BitVec w) : Nat := w

def signExtend {w: Nat} (x: BitVec w) (w': Nat) : BitVec w' :=
def signExtend {w : Nat} (x : BitVec w) (w' : Nat) : BitVec w' :=
x.signExtend w'

def zeroExtend {w: Nat} (x: BitVec w) (w': Nat) : BitVec w' :=
def zeroExtend {w : Nat} (x : BitVec w) (w' : Nat) : BitVec w' :=
x.zeroExtend w'

def truncate {w: Nat} (x: BitVec w) (w': Nat) : BitVec w' :=
def truncate {w : Nat} (x : BitVec w) (w' : Nat) : BitVec w' :=
x.truncate w'

def truncateLSB {w: Nat} (x: BitVec w) (w': Nat) : BitVec w' :=
x.extractLsb' 0 w'
def truncateLsb {w : Nat} (x : BitVec w) (w' : Nat) : BitVec w' :=
x.extractLsb' (w - w') w'

end BitVec
end Sail
2 changes: 1 addition & 1 deletion test/lean/bitvec_operation.expected.lean
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def bitvector_truncate (x : BitVec 32) : BitVec 16 :=
(Sail.BitVec.truncate x 16)

def bitvector_truncateLSB (x : BitVec 32) : BitVec 16 :=
(Sail.BitVec.truncateLSB x 16)
(Sail.BitVec.truncateLsb x 16)

def bitvector_append (x : BitVec 16) (y : BitVec 16) : BitVec 32 :=
(BitVec.append x y)
Expand Down
Loading