O(1)
. "Attach" a proof P x
that holds for all the elements of xs
to produce a new array
with the same elements but in the type {x // P x}
.
Equations
- xs.attachWith P H = { toList := xs.toList.attachWith P ⋯ }
Instances For
O(1)
. "Attach" the proof that the elements of xs
are in xs
to produce a new array
with the same elements but in the type {x // x ∈ xs}
.
Equations
- xs.attach = xs.attachWith (Membership.mem xs) ⋯
Instances For
unattach #
Array.unattach
is the (one-sided) inverse of Array.attach
. It is a synonym for Array.map Subtype.val
.
We use it by providing a simp lemma l.attach.unattach = l
, and simp lemmas which recognize higher order
functions applied to l : Array { x // p x }
which only depend on the value, not the predicate, and rewrite these
in terms of a simpler function applied to l.unattach
.
Further, we provide simp lemmas that push unattach
inwards.
A synonym for l.map (·.val)
. Mostly this should not be needed by users.
It is introduced as in intermediate step by lemmas such as map_subtype
,
and is ideally subsequently simplified away by unattach_attach
.
If not, usually the right approach is simp [Array.unattach, -Array.map_subtype]
to unfold.
Instances For
Recognizing higher order functions using a function that only depends on the value. #
This lemma identifies folds over arrays of subtypes, where the function only depends on the value, not the proposition, and simplifies these to the function directly taking the value.
Variant of foldl_subtype
with side condition to check stop = l.size
.
This lemma identifies folds over arrays of subtypes, where the function only depends on the value, not the proposition, and simplifies these to the function directly taking the value.
Variant of foldr_subtype
with side condition to check stop = l.size
.
This lemma identifies maps over arrays of subtypes, where the function only depends on the value, not the proposition, and simplifies these to the function directly taking the value.