English
Define decode₂(α) [Encodable α] (n) as decode(n) bound by guard (encode a = n). It returns the preimage if it matches, otherwise none.
Русский
Определение decode₂(α) [Encodable α](n) как связанное с decode(n) и guard (encode a = n); возвращает предобраз, если совпадает, иначе none.
LaTeX
$$$\decode_2(\alpha) [Encodable α] (n) := (\decode n).bind (\text{Option.guard }(\lambda a,\ encode a = n))$$$
Lean4
instance (priority := 100) _root_.IsEmpty.toEncodable [IsEmpty α] : Encodable α :=
⟨isEmptyElim, fun _ => none, isEmptyElim⟩