a ∈ o
means that o
is defined and equal to a
Equations
- roption.mem a o = ∃ (h : o.dom), o.get h = a
@[instance]
Equations
- roption.has_mem = {mem := roption.mem α}
@[instance]
Equations
@[simp]
theorem
roption.get_some
{α : Type u_1}
{a : α}
(ha : (roption.some a).dom) :
(roption.some a).get ha = a
theorem
roption.ne_none_iff
{α : Type u_1}
{o : roption α} :
o ≠ roption.none ↔ ∃ (x : α), o = roption.some x
@[simp]
@[simp]
theorem
roption.get_eq_iff_eq_some
{α : Type u_1}
{a : roption α}
{ha : a.dom}
{b : α} :
a.get ha = b ↔ a = roption.some b
@[instance]
Equations
@[instance]
Equations
@[simp]
@[simp]
@[simp]
theorem
roption.mem_of_option
{α : Type u_1}
{a : α}
{o : option α} :
a ∈ roption.of_option o ↔ a ∈ o
@[simp]
theorem
roption.of_option_dom
{α : Type u_1}
(o : option α) :
(roption.of_option o).dom ↔ ↥(o.is_some)
theorem
roption.of_option_eq_get
{α : Type u_1}
(o : option α) :
roption.of_option o = {dom := ↥(o.is_some), get := option.get o}
@[instance]
Equations
theorem
roption.induction_on
{α : Type u_1}
{P : roption α → Prop}
(a : roption α) :
P roption.none → (∀ (a : α), P (roption.some a)) → P a
@[instance]
@[simp]
@[simp]
Equations
- roption.equiv_option = {to_fun := λ (o : roption α), o.to_option, inv_fun := roption.of_option α, left_inv := _, right_inv := _}
assert p f
is a bind-like operation which appends an additional condition
p
to the domain and uses f
to produce the value.
theorem
roption.mem_map
{α : Type u_1}
{β : Type u_2}
(f : α → β)
{o : roption α}
{a : α} :
a ∈ o → f a ∈ roption.map f o
@[simp]
theorem
roption.mem_map_iff
{α : Type u_1}
{β : Type u_2}
(f : α → β)
{o : roption α}
{b : β} :
b ∈ roption.map f o ↔ ∃ (a : α) (H : a ∈ o), f a = b
@[simp]
@[simp]
theorem
roption.map_some
{α : Type u_1}
{β : Type u_2}
(f : α → β)
(a : α) :
roption.map f (roption.some a) = roption.some (f a)
theorem
roption.mem_assert
{α : Type u_1}
{p : Prop}
{f : p → roption α}
{a : α}
(h : p) :
a ∈ f h → a ∈ roption.assert p f
@[simp]
theorem
roption.mem_assert_iff
{α : Type u_1}
{p : Prop}
{f : p → roption α}
{a : α} :
a ∈ roption.assert p f ↔ ∃ (h : p), a ∈ f h
@[simp]
@[simp]
theorem
roption.bind_some
{α : Type u_1}
{β : Type u_2}
(a : α)
(f : α → roption β) :
(roption.some a).bind f = f a
theorem
roption.bind_some_eq_map
{α : Type u_1}
{β : Type u_2}
(f : α → β)
(x : roption α) :
x.bind (roption.some ∘ f) = roption.map f x
@[simp]
theorem
roption.bind_map
{α : Type u_1}
{β : Type u_2}
{γ : Type u_3}
(f : α → β)
(x : roption α)
(g : β → roption γ) :
(roption.map f x).bind g = x.bind (λ (y : α), g (f y))
@[simp]
theorem
roption.map_bind
{α : Type u_1}
{β : Type u_2}
{γ : Type u_3}
(f : α → roption β)
(x : roption α)
(g : β → γ) :
roption.map g (x.bind f) = x.bind (λ (y : α), roption.map g (f y))
theorem
roption.map_map
{α : Type u_1}
{β : Type u_2}
{γ : Type u_3}
(g : β → γ)
(f : α → β)
(o : roption α) :
roption.map g (roption.map f o) = roption.map (g ∘ f) o
@[instance]
Equations
theorem
roption.map_id'
{α : Type u_1}
{f : α → α}
(H : ∀ (x : α), f x = x)
(o : roption α) :
roption.map f o = o
@[simp]
@[simp]
@[simp]
theorem
roption.map_eq_map
{α β : Type u_1}
(f : α → β)
(o : roption α) :
f <$> o = roption.map f o
@[instance]
Equations
- roption.monad_fail = {fail := λ (_x : Type u_1) (_x_1 : string), roption.none}
@[simp]
theorem
roption.mem_restrict
{α : Type u_1}
(p : Prop)
(o : roption α)
(h : p → o.dom)
(a : α) :
a ∈ roption.restrict p o h ↔ p ∧ a ∈ o
unwrap o
gets the value at o
, ignoring the condition.
(This function is unsound.)
theorem
roption.assert_defined
{α : Type u_1}
{p : Prop}
{f : p → roption α}
(h : p) :
(f h).dom → (roption.assert p f).dom
@[instance]
Equations
- pfun.inhabited = {default := λ (a : α), roption.none}
def
pfun.eval_opt
{α : Type u_1}
{β : Type u_2}
(f : α →. β)
[D : decidable_pred f.dom] :
α → option β
Evaluate a partial function to return an option
Turn a partial function into a function out of a subtype
Equations
- f.as_subtype s = f.fn ↑s _
The set of partial functions α →. β
is equivalent to
the set of pairs (p : α → Prop, f : subtype p → β)
.
theorem
pfun.as_subtype_eq_of_mem
{α : Type u_1}
{β : Type u_2}
{f : α →. β}
{x : α}
{y : β}
(fxy : y ∈ f x)
(domx : x ∈ f.dom) :
f.as_subtype ⟨x, domx⟩ = y
Turn a total function into a partial function
Equations
- pfun.lift f = λ (a : α), roption.some (f a)
@[instance]
Equations
- pfun.has_coe = {coe := pfun.lift β}
@[simp]
@[simp]
Restrict a partial function to a smaller domain.
Equations
- f.restrict H = λ (x : α), roption.restrict (p x) (f x) H
The monad pure
function, the total constant x
function
Equations
- pfun.pure x = λ (_x : α), roption.some x
The monad bind
function, pointwise roption.bind
The monad map
function, pointwise roption.map
Equations
- pfun.map f g = λ (a : α), roption.map f (g a)
@[instance]
Equations
Equations
- f.fix = λ (a : α), roption.assert (acc (λ (x y : α), sum.inr x ∈ f y) a) (λ (h : acc (λ (x y : α), sum.inr x ∈ f y) a), well_founded.fix_F (λ (a : α) (IH : Π (y : α), (λ (x y : α), sum.inr x ∈ f y) y a → roption β), roption.assert (f a).dom (λ (hf : (f a).dom), (λ (_x : β ⊕ α) (e : (f a).get hf = _x), _x.cases_on (λ (b : β) (e : (f a).get hf = sum.inl b), roption.some b) (λ (a' : α) (e : (f a).get hf = sum.inr a'), IH a' _) e) ((f a).get hf) _)) a h)
def
pfun.fix_induction
{α : Type u_1}
{β : Type u_2}
{f : α →. β ⊕ α}
{b : β}
{C : α → Sort u_3}
{a : α} :
Equations
- pfun.fix_induction h H = acc.drec (λ (a : α) (ha : ∀ (y : α), (λ (x y : α), sum.inr x ∈ f y) y a → acc (λ (x y : α), sum.inr x ∈ f y) y) (IH : Π (y : α) (a : (λ (x y : α), sum.inr x ∈ f y) y a), (λ {a : α} (_x : acc (λ (x y : α), sum.inr x ∈ f y) a), (∃ (h : acc (λ (x y : α), sum.inr x ∈ f y) a), b ∈ well_founded.fix_F (λ (a : α) (IH : Π (y : α), (λ (x y : α), sum.inr x ∈ f y) y a → roption β), roption.assert (f a).dom (λ (hf : (f a).dom), (λ (_x : β ⊕ α) (e : (f a).get hf = _x), _x.cases_on (λ (b : β) (e : (f a).get hf = sum.inl b), roption.some b) (λ (a' : α) (e : (f a).get hf = sum.inr a'), IH a' _) e) ((f a).get hf) _)) a h) → b ∈ well_founded.fix_F (λ (a : α) (IH : Π (y : α), (λ (x y : α), sum.inr x ∈ f y) y a → roption β), roption.assert (f a).dom (λ (hf : (f a).dom), (λ (_x : β ⊕ α) (e : (f a).get hf = _x), _x.cases_on (λ (b : β) (e : (f a).get hf = sum.inl b), roption.some b) (λ (a' : α) (e : (f a).get hf = sum.inr a'), IH a' _) e) ((f a).get hf) _)) a _x → C a) _) (h : ∃ (h : acc (λ (x y : α), sum.inr x ∈ f y) a), b ∈ well_founded.fix_F (λ (a : α) (IH : Π (y : α), (λ (x y : α), sum.inr x ∈ f y) y a → roption β), roption.assert (f a).dom (λ (hf : (f a).dom), (λ (_x : β ⊕ α) (e : (f a).get hf = _x), _x.cases_on (λ (b : β) (e : (f a).get hf = sum.inl b), roption.some b) (λ (a' : α) (e : (f a).get hf = sum.inr a'), IH a' _) e) ((f a).get hf) _)) a h) (h₂ : b ∈ well_founded.fix_F (λ (a : α) (IH : Π (y : α), (λ (x y : α), sum.inr x ∈ f y) y a → roption β), roption.assert (f a).dom (λ (hf : (f a).dom), (λ (_x : β ⊕ α) (e : (f a).get hf = _x), _x.cases_on (λ (b : β) (e : (f a).get hf = sum.inl b), roption.some b) (λ (a' : α) (e : (f a).get hf = sum.inr a'), IH a' _) e) ((f a).get hf) _)) a _), H a _ (λ (a' : α) (ha' : b ∈ f.fix a') (fa' : sum.inr a' ∈ f a), IH a' fa' _ _)) _ _ _
Equations
- f.preimage s = rel.preimage (λ (x : α) (y : β), y ∈ f x) s
theorem
pfun.preimage_as_subtype
{α : Type u_1}
{β : Type u_2}
(f : α →. β)
(s : set β) :
f.as_subtype ⁻¹' s = subtype.val ⁻¹' f.preimage s