Skip to content

Commit

Permalink
feat: add UInt32.{lt, le} (#6591)
Browse files Browse the repository at this point in the history
This PR adds less-than and less-than-or-equal-to relations to `UInt32`,
consistent with the other `UIntN` types.
  • Loading branch information
david-christiansen authored Jan 9, 2025
1 parent dd64455 commit 1b42728
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Init/Data/UInt/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ def UInt32.xor (a b : UInt32) : UInt32 := ⟨a.toBitVec ^^^ b.toBitVec⟩
def UInt32.shiftLeft (a b : UInt32) : UInt32 := ⟨a.toBitVec <<< (mod b 32).toBitVec⟩
@[extern "lean_uint32_shift_right"]
def UInt32.shiftRight (a b : UInt32) : UInt32 := ⟨a.toBitVec >>> (mod b 32).toBitVec⟩
def UInt32.lt (a b : UInt32) : Prop := a.toBitVec < b.toBitVec
def UInt32.le (a b : UInt32) : Prop := a.toBitVec ≤ b.toBitVec

instance : Add UInt32 := ⟨UInt32.add⟩
instance : Sub UInt32 := ⟨UInt32.sub⟩
Expand All @@ -169,6 +171,8 @@ set_option linter.deprecated false in
instance : HMod UInt32 Nat UInt32 := ⟨UInt32.modn⟩

instance : Div UInt32 := ⟨UInt32.div⟩
instance : LT UInt32 := ⟨UInt32.lt⟩
instance : LE UInt32 := ⟨UInt32.le⟩

@[extern "lean_uint32_complement"]
def UInt32.complement (a : UInt32) : UInt32 := ⟨~~~a.toBitVec⟩
Expand Down

0 comments on commit 1b42728

Please sign in to comment.