@@ -19,8 +19,8 @@ def UInt8.mul (a b : UInt8) : UInt8 := ⟨a.toBitVec * b.toBitVec⟩
19
19
def UInt8.div (a b : UInt8) : UInt8 := ⟨BitVec.udiv a.toBitVec b.toBitVec⟩
20
20
@[extern "lean_uint8_mod"]
21
21
def UInt8.mod (a b : UInt8) : UInt8 := ⟨BitVec.umod a.toBitVec b.toBitVec⟩
22
- @[extern "lean_uint8_modn"]
23
- def UInt8.modn (a : UInt8) (n : @& Nat) : UInt8 := ⟨Fin.modn a.val n⟩ -- TODO
22
+ @[extern "lean_uint8_modn", deprecated UInt8.mod (since := "2024-09-23") ]
23
+ def UInt8.modn (a : UInt8) (n : @& Nat) : UInt8 := ⟨Fin.modn a.val n⟩
24
24
@[extern "lean_uint8_land"]
25
25
def UInt8.land (a b : UInt8) : UInt8 := ⟨a.toBitVec &&& b.toBitVec⟩
26
26
@[extern "lean_uint8_lor"]
@@ -38,7 +38,10 @@ instance : Add UInt8 := ⟨UInt8.add⟩
38
38
instance : Sub UInt8 := ⟨UInt8.sub⟩
39
39
instance : Mul UInt8 := ⟨UInt8.mul⟩
40
40
instance : Mod UInt8 := ⟨UInt8.mod⟩
41
+
42
+ set_option linter.deprecated false in
41
43
instance : HMod UInt8 Nat UInt8 := ⟨UInt8.modn⟩
44
+
42
45
instance : Div UInt8 := ⟨UInt8.div⟩
43
46
instance : LT UInt8 := ⟨UInt8.lt⟩
44
47
instance : LE UInt8 := ⟨UInt8.le⟩
@@ -76,7 +79,7 @@ def UInt16.mul (a b : UInt16) : UInt16 := ⟨a.toBitVec * b.toBitVec⟩
76
79
def UInt16.div (a b : UInt16) : UInt16 := ⟨BitVec.udiv a.toBitVec b.toBitVec⟩
77
80
@[extern "lean_uint16_mod"]
78
81
def UInt16.mod (a b : UInt16) : UInt16 := ⟨BitVec.umod a.toBitVec b.toBitVec⟩
79
- @[extern "lean_uint16_modn"]
82
+ @[extern "lean_uint16_modn", deprecated UInt16.mod (since := "2024-09-23") ]
80
83
def UInt16.modn (a : UInt16) (n : @& Nat) : UInt16 := ⟨Fin.modn a.val n⟩
81
84
@[extern "lean_uint16_land"]
82
85
def UInt16.land (a b : UInt16) : UInt16 := ⟨a.toBitVec &&& b.toBitVec⟩
@@ -95,7 +98,10 @@ instance : Add UInt16 := ⟨UInt16.add⟩
95
98
instance : Sub UInt16 := ⟨UInt16.sub⟩
96
99
instance : Mul UInt16 := ⟨UInt16.mul⟩
97
100
instance : Mod UInt16 := ⟨UInt16.mod⟩
101
+
102
+ set_option linter.deprecated false in
98
103
instance : HMod UInt16 Nat UInt16 := ⟨UInt16.modn⟩
104
+
99
105
instance : Div UInt16 := ⟨UInt16.div⟩
100
106
instance : LT UInt16 := ⟨UInt16.lt⟩
101
107
instance : LE UInt16 := ⟨UInt16.le⟩
@@ -135,7 +141,7 @@ def UInt32.mul (a b : UInt32) : UInt32 := ⟨a.toBitVec * b.toBitVec⟩
135
141
def UInt32.div (a b : UInt32) : UInt32 := ⟨BitVec.udiv a.toBitVec b.toBitVec⟩
136
142
@[extern "lean_uint32_mod"]
137
143
def UInt32.mod (a b : UInt32) : UInt32 := ⟨BitVec.umod a.toBitVec b.toBitVec⟩
138
- @[extern "lean_uint32_modn"]
144
+ @[extern "lean_uint32_modn", deprecated UInt32.mod (since := "2024-09-23") ]
139
145
def UInt32.modn (a : UInt32) (n : @& Nat) : UInt32 := ⟨Fin.modn a.val n⟩
140
146
@[extern "lean_uint32_land"]
141
147
def UInt32.land (a b : UInt32) : UInt32 := ⟨a.toBitVec &&& b.toBitVec⟩
@@ -152,7 +158,10 @@ instance : Add UInt32 := ⟨UInt32.add⟩
152
158
instance : Sub UInt32 := ⟨UInt32.sub⟩
153
159
instance : Mul UInt32 := ⟨UInt32.mul⟩
154
160
instance : Mod UInt32 := ⟨UInt32.mod⟩
161
+
162
+ set_option linter.deprecated false in
155
163
instance : HMod UInt32 Nat UInt32 := ⟨UInt32.modn⟩
164
+
156
165
instance : Div UInt32 := ⟨UInt32.div⟩
157
166
158
167
@[extern "lean_uint32_complement"]
@@ -175,7 +184,7 @@ def UInt64.mul (a b : UInt64) : UInt64 := ⟨a.toBitVec * b.toBitVec⟩
175
184
def UInt64.div (a b : UInt64) : UInt64 := ⟨BitVec.udiv a.toBitVec b.toBitVec⟩
176
185
@[extern "lean_uint64_mod"]
177
186
def UInt64.mod (a b : UInt64) : UInt64 := ⟨BitVec.umod a.toBitVec b.toBitVec⟩
178
- @[extern "lean_uint64_modn"]
187
+ @[extern "lean_uint64_modn", deprecated UInt64.mod (since := "2024-09-23") ]
179
188
def UInt64.modn (a : UInt64) (n : @& Nat) : UInt64 := ⟨Fin.modn a.val n⟩
180
189
@[extern "lean_uint64_land"]
181
190
def UInt64.land (a b : UInt64) : UInt64 := ⟨a.toBitVec &&& b.toBitVec⟩
@@ -194,7 +203,10 @@ instance : Add UInt64 := ⟨UInt64.add⟩
194
203
instance : Sub UInt64 := ⟨UInt64.sub⟩
195
204
instance : Mul UInt64 := ⟨UInt64.mul⟩
196
205
instance : Mod UInt64 := ⟨UInt64.mod⟩
206
+
207
+ set_option linter.deprecated false in
197
208
instance : HMod UInt64 Nat UInt64 := ⟨UInt64.modn⟩
209
+
198
210
instance : Div UInt64 := ⟨UInt64.div⟩
199
211
instance : LT UInt64 := ⟨UInt64.lt⟩
200
212
instance : LE UInt64 := ⟨UInt64.le⟩
@@ -231,7 +243,7 @@ def USize.mul (a b : USize) : USize := ⟨a.toBitVec * b.toBitVec⟩
231
243
def USize.div (a b : USize) : USize := ⟨a.toBitVec / b.toBitVec⟩
232
244
@[extern "lean_usize_mod"]
233
245
def USize.mod (a b : USize) : USize := ⟨a.toBitVec % b.toBitVec⟩
234
- @[extern "lean_usize_modn"]
246
+ @[extern "lean_usize_modn", deprecated USize.mod (since := "2024-09-23") ]
235
247
def USize.modn (a : USize) (n : @& Nat) : USize := ⟨Fin.modn a.val n⟩
236
248
@[extern "lean_usize_land"]
237
249
def USize.land (a b : USize) : USize := ⟨a.toBitVec &&& b.toBitVec⟩
@@ -240,13 +252,16 @@ def USize.lor (a b : USize) : USize := ⟨a.toBitVec ||| b.toBitVec⟩
240
252
@[extern "lean_usize_xor"]
241
253
def USize.xor (a b : USize) : USize := ⟨a.toBitVec ^^^ b.toBitVec⟩
242
254
@[extern "lean_usize_shift_left"]
243
- def USize.shiftLeft (a b : USize) : USize := ⟨a.toBitVec <<< (modn b System.Platform.numBits).toBitVec⟩
255
+ def USize.shiftLeft (a b : USize) : USize := ⟨a.toBitVec <<< (mod b (USize.ofNat System.Platform.numBits) ).toBitVec⟩
244
256
@[extern "lean_usize_shift_right"]
245
- def USize.shiftRight (a b : USize) : USize := ⟨a.toBitVec >>> (modn b System.Platform.numBits).toBitVec⟩
257
+ def USize.shiftRight (a b : USize) : USize := ⟨a.toBitVec >>> (mod b (USize.ofNat System.Platform.numBits) ).toBitVec⟩
246
258
247
259
instance : Mul USize := ⟨USize.mul⟩
248
260
instance : Mod USize := ⟨USize.mod⟩
261
+
262
+ set_option linter.deprecated false in
249
263
instance : HMod USize Nat USize := ⟨USize.modn⟩
264
+
250
265
instance : Div USize := ⟨USize.div⟩
251
266
252
267
@[extern "lean_usize_complement"]
0 commit comments