lean4-htt/tests/lean/simpArrayIdx.lean
Kim Morrison 4e885be96d
feat: rename Array.setD to setIfInBounds (#6195)
This PR renames `Array.setD` to `Array.setIfInBounds`.
2024-11-24 08:54:19 +00:00

26 lines
668 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

section
variable {α : Type _}
variable [Inhabited α]
variable (a : Array α)
variable (i j : Nat)
variable (v d : α)
variable (g : i < (a.set! i v).size)
variable (j_lt : j < (a.set! i v).size)
#check_simp (i + 0) ~> i
#check_simp (a.set! i v).get i g ~> v
#check_simp (a.set! i v).get! i ~> (a.setIfInBounds i v)[i]!
#check_simp (a.set! i v).getD i d ~> if i < a.size then v else d
#check_simp (a.set! i v)[i] ~> v
-- Checks with different index values.
#check_simp (a.set! i v)[j]'j_lt ~> (a.setIfInBounds i v)[j]'_
#check_simp (a.setIfInBounds i v)[j]'j_lt !~>
section
variable (p : i < a.size)
#check_tactic (a.set! i v)[i]? ~> .some v by simp[p]
end
end