"Attach" a proof P x
that holds for the element of o
, if present,
to produce a new option with the same element but in the type {x // P x}
.
Instances For
"Attach" the proof that the element of xs
, if present, is in xs
to produce a new option with the same elements but in the type {x // x ∈ xs}
.
Equations
- xs.attach = xs.attachWith (Membership.mem xs) ⋯
Instances For
unattach #
Option.unattach
is the (one-sided) inverse of Option.attach
. It is a synonym for Option.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 : Option { 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 an 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 [Option.unattach, -Option.map_subtype]
to unfold.
Equations
- o.unattach = Option.map (fun (x : { x : α // p x }) => x.val) o
Instances For
Recognizing higher order functions on subtypes using a function that only depends on the value. #
This lemma identifies maps over lists of subtypes, where the function only depends on the value, not the proposition, and simplifies these to the function directly taking the value.