Skip to content

Commit 57e2391

Browse files
kim-emKha
authored andcommitted
fix: implementation of Array.anyMUnsafe
move test
1 parent 14e626a commit 57e2391

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Init/Data/Array/Basic.lean

+3-2
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,9 @@ unsafe def anyMUnsafe {α : Type u} {m : Type → Type w} [Monad m] (p : α →
328328
else
329329
any (i+1) stop
330330
if start < stop then
331-
if stop ≤ as.size then
332-
any (USize.ofNat start) (USize.ofNat stop)
331+
let stop' := min stop as.size
332+
if start < stop' then
333+
any (USize.ofNat start) (USize.ofNat stop')
333334
else
334335
pure false
335336
else

tests/lean/run/1921.lean

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@[simp] theorem Array.size_singleton : #[a].size = 1 := rfl
2+
@[simp] theorem USize.not_size_le_one : ¬ USize.size ≤ 1 := by cases usize_size_eq <;> simp_all
3+
4+
def f := #[true].any id 0 USize.size
5+
6+
-- `native_decide` used to prove `false` here, due to a bug in `Array.anyMUnsafe`.
7+
example : f = true := by native_decide
8+
9+
example : f = true := by simp [f, Array.any, Array.anyM]

0 commit comments

Comments
 (0)