Lemmas about Array.findSome?
, Array.find?
. #
findSome? #
@[simp]
theorem
Array.findSomeRev?_push_of_isSome
{α : Type u_1}
{α✝ : Type u_2}
{f : α → Option α✝}
{a : α}
(l : Array α)
(h : (f a).isSome = true)
:
findSomeRev? f (l.push a) = f a
@[simp]
theorem
Array.findSomeRev?_push_of_isNone
{α : Type u_1}
{α✝ : Type u_2}
{f : α → Option α✝}
{a : α}
(l : Array α)
(h : (f a).isNone = true)
:
findSomeRev? f (l.push a) = findSomeRev? f l
@[simp]
theorem
Array.back?_filterMap
{α : Type u_1}
{β : Type u_2}
(f : α → Option β)
(l : Array α)
:
(filterMap f l).back? = findSomeRev? f l
@[simp]
theorem
Array.map_findSome?
{α : Type u_1}
{β : Type u_2}
{γ : Type u_3}
(f : α → Option β)
(g : β → γ)
(l : Array α)
:
Option.map g (findSome? f l) = findSome? (Option.map g ∘ f) l
theorem
Array.back?_flatten
{α : Type u_1}
{L : Array (Array α)}
:
L.flatten.back? = findSomeRev? (fun (l : Array α) => l.back?) L
find? #
If find? p
returns some a
from xs.flatten
, then p a
holds, and
some array in xs
contains a
, and no earlier element of that array satisfies p
.
Moreover, no earlier array in xs
has an element satisfying p
.