Skip to content

Commit

Permalink
Lean: Fixing Lean style and wrong definition in Sail.lean (#891)
Browse files Browse the repository at this point in the history
  • Loading branch information
lfrenot authored Jan 16, 2025
1 parent 9addae9 commit bf921f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
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

0 comments on commit bf921f9

Please sign in to comment.