The areas / V01. The language of Mathlib
Mathlib.Data.PFun
129 declarations. Mathlib docs · Source
Partial functions
This file defines partial functions. Partial functions are like functions, except they can also be
"undefined" on some inputs. We define them as functions α → Part β.
Definitions
PFun α β: Type of partial functions fromαtoβ. Defined asα → Part βand denotedα →. β.PFun.Dom: Domain of a partial function. Set of values on which it is defined. Not to be confused with the domain of a functionα → β, which is a type (αpresently).PFun.fn: Evaluation of a partial function. Takes in an element and a proof it belongs to the partial function'sDom.PFun.asSubtype: Returns a partial function as a function from itsDom.PFun.toSubtype: Restricts the codomain of a function to a subtype.PFun.evalOpt: Returns a partial function with a decidableDomas a functiona → Option β.PFun.lift: Turns a function into a partial function.PFun.id: The identity as a partial function.PFun.comp: Composition of partial functions.PFun.restrict: Restriction of a partial function to a smallerDom.PFun.res: Turns a function into a partial function with a prescribed domain.PFun.fix: First return map of a partial functionf : α →. β ⊕ α.PFun.fixInduction: A recursion principle forPFun.fix.
Partial functions as relations
Partial functions can be considered as relations, so we specialize some Rel definitions to PFun:
PFun.image: Image of a set under a partial function.PFun.ran: Range of a partial function.PFun.preimage: Preimage of a set under a partial function.PFun.core: Core of a set under a partial function.PFun.graph: Graph of a partial functiona →. βas aSet (α × β).PFun.graph': Graph of a partial functiona →. βas aRel α β.
PFun α as a monad
Monad operations:
PFun.pure: The monadpurefunction, the constantxfunction.PFun.bind: The monadbindfunction, pointwisePart.bindPFun.map: The monadmapfunction, pointwisePart.map.
theorem PFun.fn.congr_simp E1 #
∀ {α : Type u_1} {β : Type u_2} (f f_1 : α →. β) (e_f : f = f_1) (a a_1 : α) (e_a : a = a_1) (a_2 : a ∈ f.Dom),
f.fn a a_2 = f_1.fn a_1 ⋯
theorem PFun.fixInduction.congr_simp E1 #
∀ {α : Type u_1} {β : Type u_2} {C : α → Sort u_7} {f : α →. β ⊕ α} {b : β} {a : α} (h : b ∈ f.fix a)
(H H_1 : (a' : α) → b ∈ f.fix a' → ((a'' : α) → Sum.inr a'' ∈ f a' → C a'') → C a'),
H = H_1 → PFun.fixInduction h H = PFun.fixInduction h H_1
theorem Part.restrict.congr_simp E1 #
∀ {α : Type u_1} (p p_1 : Prop) (e_p : p = p_1) (o o_1 : Part α) (e_o : o = o_1) (H : p → o.Dom),
Part.restrict p o H = Part.restrict p_1 o_1 ⋯
theorem WellFounded.fixF.congr_simp E1 #
∀ {α : Sort u} {r : α → α → Prop} {C : α → Sort v} (F F_1 : (x : α) → ((y : α) → r y x → C y) → C x),
F = F_1 → ∀ (x : α) (a : Acc r x), WellFounded.fixF F x a = WellFounded.fixF F_1 x a
theorem PFun.fix.match_1.congr_eq_1 E1 #
∀ {α : Type u_2} {β : Type u_1} (motive : β ⊕ α → Sort u_3) (x : β ⊕ α)
(h_1 : (b : β) → x = Sum.inl b → motive (Sum.inl b)) (h_2 : (a' : α) → x = Sum.inr a' → motive (Sum.inr a')) (b : β)
(heq_1 : x = Sum.inl b),
(match e : x with
| Sum.inl b => h_1 b e
| Sum.inr a' => h_2 a' e) ≍
h_1 b heq_1
theorem PFun.restrict.congr_simp E1 #
∀ {α : Type u_1} {β : Type u_2} (f f_1 : α →. β) (e_f : f = f_1) {p p_1 : Set α} (e_p : p = p_1) (H : p ⊆ f.Dom)
(a a_1 : α), a = a_1 → f.restrict H a = f_1.restrict ⋯ a_1
theorem PFun.fix.match_1.congr_eq_2 E1 #
∀ {α : Type u_2} {β : Type u_1} (motive : β ⊕ α → Sort u_3) (x : β ⊕ α)
(h_1 : (b : β) → x = Sum.inl b → motive (Sum.inl b)) (h_2 : (a' : α) → x = Sum.inr a' → motive (Sum.inr a')) (a' : α)
(heq_1 : x = Sum.inr a'),
(match e : x with
| Sum.inl b => h_1 b e
| Sum.inr a' => h_2 a' e) ≍
h_2 a' heq_1
def PFun E1 #
Type u_1 → Type u_2 → Type (max u_1 u_2)
PFun α β, or α →. β, is the type of partial functions from
α to β. It is defined as α → Part β.
def «term_→._» E1 #
Lean.TrailingParserDescr
α →. β is notation for the type PFun α β of partial functions from α to β.
instance PFun.inhabited E0 #
{α : Type u_1} → {β : Type u_2} → Inhabited (α →. β)
def PFun.Dom E1 #
{α : Type u_1} → {β : Type u_2} → (α →. β) → Set α
The domain of a partial function
theorem PFun.mem_dom E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (x : α), x ∈ f.Dom ↔ ∃ y, y ∈ f x
theorem PFun.dom_mk E0 #
∀ {α : Type u_1} {β : Type u_2} (p : α → Prop) (f : (a : α) → p a → β),
(PFun.Dom fun x ↦ { Dom := p x, get := f x }) = {x | p x}
theorem PFun.dom_eq E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β), f.Dom = {x | ∃ y, y ∈ f x}
def PFun.fn E1 #
{α : Type u_1} → {β : Type u_2} → (f : α →. β) → (a : α) → a ∈ f.Dom → β
Evaluate a partial function
theorem PFun.fn_apply E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (a : α), f.fn a = (f a).get
def PFun.evalOpt E1 #
{α : Type u_1} → {β : Type u_2} → (f : α →. β) → [D : DecidablePred fun x ↦ x ∈ f.Dom] → α → Option β
Evaluate a partial function to return an Option
theorem PFun.ext' E1 #
∀ {α : Type u_1} {β : Type u_2} {f g : α →. β},
(∀ (a : α), a ∈ f.Dom ↔ a ∈ g.Dom) → (∀ (a : α) (p : a ∈ f.Dom) (q : a ∈ g.Dom), f.fn a p = g.fn a q) → f = g
Partial function extensionality
theorem PFun.ext E1 #
∀ {α : Type u_1} {β : Type u_2} {f g : α →. β}, (∀ (a : α) (b : β), b ∈ f a ↔ b ∈ g a) → f = g
theorem PFun.ext_iff E0 #
∀ {α : Type u_1} {β : Type u_2} {f g : α →. β}, f = g ↔ ∀ (a : α) (b : β), b ∈ f a ↔ b ∈ g a
def PFun.asSubtype E1 #
{α : Type u_1} → {β : Type u_2} → (f : α →. β) → ↑f.Dom → β
Turns a partial function into a function out of its domain.
def PFun.equivSubtype E1 #
{α : Type u_1} → {β : Type u_2} → (α →. β) ≃ (p : α → Prop) × (Subtype p → β)
The type of partial functions α →. β is equivalent to
the type of pairs (p : α → Prop, f : Subtype p → β).
theorem PFun.asSubtype_eq_of_mem E1 #
∀ {α : Type u_1} {β : Type u_2} {f : α →. β} {x : α} {y : β}, y ∈ f x → ∀ (domx : x ∈ f.Dom), f.asSubtype ⟨x, domx⟩ = y
def PFun.lift E1 #
{α : Type u_1} → {β : Type u_2} → (α → β) → α →. β
Turn a total function into a partial function.
instance PFun.coe E0 #
{α : Type u_1} → {β : Type u_2} → Coe (α → β) (α →. β)
theorem PFun.coe_val E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α → β) (a : α), ↑f a = Part.some (f a)
theorem PFun.dom_coe E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α → β), (↑f).Dom = Set.univ
theorem PFun.lift_injective E1 #
∀ {α : Type u_1} {β : Type u_2}, Function.Injective PFun.lift
def PFun.graph E1 #
{α : Type u_1} → {β : Type u_2} → (α →. β) → Set (α × β)
Graph of a partial function f as the set of pairs (x, f x) where x is in the domain of
f.
def PFun.graph' E1 #
{α : Type u_1} → {β : Type u_2} → (α →. β) → SetRel α β
Graph of a partial function as a relation. x and y are related iff f x is defined and
"equals" y.
def PFun.ran E1 #
{α : Type u_1} → {β : Type u_2} → (α →. β) → Set β
The range of a partial function is the set of values
f x where x is in the domain of f.
theorem PFun.ran_coe E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α → β), (↑f).ran = Set.range f
theorem PFun.ran_eq_empty_iff_dom_eq_empty E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β), f.ran = ∅ ↔ f.Dom = ∅
def PFun.restrict E1 #
{α : Type u_1} → {β : Type u_2} → (f : α →. β) → {p : Set α} → p ⊆ f.Dom → α →. β
Restrict a partial function to a smaller domain.
theorem PFun.mem_restrict E0 #
∀ {α : Type u_1} {β : Type u_2} {f : α →. β} {s : Set α} (h : s ⊆ f.Dom) (a : α) (b : β),
b ∈ f.restrict h a ↔ a ∈ s ∧ b ∈ f a
theorem PFun.dom_restrict E0 #
∀ {α : Type u_1} {β : Type u_2} {f : α →. β} {S : Set α} (hS : S ⊆ f.Dom), (f.restrict hS).Dom = S
theorem PFun.restrict_restrict E0 #
∀ {α : Type u_1} {β : Type u_2} {f : α →. β} {S T : Set α} (hS : S ⊆ f.Dom) (hT : T ⊆ (f.restrict hS).Dom),
(f.restrict hS).restrict hT = f.restrict ⋯
def PFun.res E1 #
{α : Type u_1} → {β : Type u_2} → (α → β) → Set α → α →. β
Turns a function into a partial function with a prescribed domain.
theorem PFun.mem_res E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α → β) (s : Set α) (a : α) (b : β), b ∈ PFun.res f s a ↔ a ∈ s ∧ f a = b
theorem PFun.res_univ E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α → β), PFun.res f Set.univ = ↑f
theorem PFun.dom_iff_graph E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (x : α), x ∈ f.Dom ↔ ∃ y, (x, y) ∈ f.graph
theorem PFun.lift_graph E1 #
∀ {α : Type u_1} {β : Type u_2} {f : α → β} {a : α} {b : β}, (a, b) ∈ (↑f).graph ↔ f a = b
def PFun.pure E1 #
{α : Type u_1} → {β : Type u_2} → β → α →. β
The monad pure function, the total constant x function
def PFun.bind E1 #
{α : Type u_1} → {β : Type u_2} → {γ : Type u_3} → (α →. β) → (β → α →. γ) → α →. γ
The monad bind function, pointwise Part.bind
theorem PFun.bind_apply E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : α →. β) (g : β → α →. γ) (a : α),
f.bind g a = (f a).bind fun b ↦ g b a
def PFun.map E1 #
{α : Type u_1} → {β : Type u_2} → {γ : Type u_3} → (β → γ) → (α →. β) → α →. γ
The monad map function, pointwise Part.map
theorem PFun.dom_map E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (g : β → γ) (f : α →. β), (PFun.map g f).Dom = f.Dom
theorem PFun.mem_map E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (g : β → γ) (f : α →. β) (a : α) (c : γ),
c ∈ PFun.map g f a ↔ ∃ b ∈ f a, g b = c
theorem PFun.ran_map E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (g : β → γ) (f : α →. β), (PFun.map g f).ran = g '' f.ran
instance PFun.monad E0 #
{α : Type u_1} → Monad (PFun α)
instance PFun.lawfulMonad E0 #
∀ {α : Type u_1}, LawfulMonad (PFun α)
theorem PFun.pure_defined E1 #
∀ {α : Type u_1} {β : Type u_2} (p : Set α) (x : β), p ⊆ (PFun.pure x).Dom
theorem PFun.bind_defined E1 #
∀ {α : Type u_7} {β γ : Type u_8} (p : Set α) {f : α →. β} {g : β → α →. γ},
p ⊆ f.Dom → (∀ (x : β), p ⊆ (g x).Dom) → p ⊆ (f >>= g).Dom
def PFun.fix E1 #
{α : Type u_1} → {β : Type u_2} → (α →. β ⊕ α) → α →. β
First return map. Transforms a partial function f : α →. β ⊕ α into the partial function
α →. β which sends a : α to the first value in β it hits by iterating f, if such a value
exists. By abusing notation to illustrate, either f a is in the β part of β ⊕ α (in which
case f.fix a returns f a), or it is undefined (in which case f.fix a is undefined as well), or
it is in the α part of β ⊕ α (in which case we repeat the procedure, so f.fix a will return
f.fix (f a)).
theorem PFun.dom_of_mem_fix E1 #
∀ {α : Type u_1} {β : Type u_2} {f : α →. β ⊕ α} {a : α} {b : β}, b ∈ f.fix a → (f a).Dom
theorem PFun.mem_fix_iff E0 #
∀ {α : Type u_1} {β : Type u_2} {f : α →. β ⊕ α} {a : α} {b : β},
b ∈ f.fix a ↔ Sum.inl b ∈ f a ∨ ∃ a', Sum.inr a' ∈ f a ∧ b ∈ f.fix a'
theorem PFun.fix_stop E1 #
∀ {α : Type u_1} {β : Type u_2} {f : α →. β ⊕ α} {b : β} {a : α}, Sum.inl b ∈ f a → b ∈ f.fix a
If advancing one step from a leads to b : β, then f.fix a = b
theorem PFun.fix_fwd_eq E0 #
∀ {α : Type u_1} {β : Type u_2} {f : α →. β ⊕ α} {a a' : α}, Sum.inr a' ∈ f a → f.fix a = f.fix a'
If advancing one step from a on f leads to a' : α, then f.fix a = f.fix a'
theorem PFun.fix_fwd E1 #
∀ {α : Type u_1} {β : Type u_2} {f : α →. β ⊕ α} {b : β} {a a' : α}, b ∈ f.fix a → Sum.inr a' ∈ f a → b ∈ f.fix a'
def PFun.fixInduction E1 #
{α : Type u_1} →
{β : Type u_2} →
{C : α → Sort u_7} →
{f : α →. β ⊕ α} →
{b : β} →
{a : α} → b ∈ f.fix a → ((a' : α) → b ∈ f.fix a' → ((a'' : α) → Sum.inr a'' ∈ f a' → C a'') → C a') → C a
A recursion principle for PFun.fix.
theorem PFun.fixInduction_spec E1 #
∀ {α : Type u_1} {β : Type u_2} {C : α → Sort u_7} {f : α →. β ⊕ α} {b : β} {a : α} (h : b ∈ f.fix a)
(H : (a' : α) → b ∈ f.fix a' → ((a'' : α) → Sum.inr a'' ∈ f a' → C a'') → C a'),
PFun.fixInduction h H = H a h fun x h' ↦ PFun.fixInduction ⋯ H
def PFun.fixInduction' E1 #
{α : Type u_1} →
{β : Type u_2} →
{C : α → Sort u_7} →
{f : α →. β ⊕ α} →
{b : β} →
{a : α} →
b ∈ f.fix a →
((a_final : α) → Sum.inl b ∈ f a_final → C a_final) →
((a₀ a₁ : α) → b ∈ f.fix a₁ → Sum.inr a₁ ∈ f a₀ → C a₁ → C a₀) → C a
Another induction lemma for b ∈ f.fix a which allows one to prove a predicate P holds for
a given that f a inherits P from a and P holds for preimages of b.
theorem PFun.fixInduction'_stop E1 #
∀ {α : Type u_1} {β : Type u_2} {C : α → Sort u_7} {f : α →. β ⊕ α} {b : β} {a : α} (h : b ∈ f.fix a)
(fa : Sum.inl b ∈ f a) (hbase : (a_final : α) → Sum.inl b ∈ f a_final → C a_final)
(hind : (a₀ a₁ : α) → b ∈ f.fix a₁ → Sum.inr a₁ ∈ f a₀ → C a₁ → C a₀), PFun.fixInduction' h hbase hind = hbase a fa
theorem PFun.fixInduction'_fwd E1 #
∀ {α : Type u_1} {β : Type u_2} {C : α → Sort u_7} {f : α →. β ⊕ α} {b : β} {a a' : α} (h : b ∈ f.fix a)
(h' : b ∈ f.fix a') (fa : Sum.inr a' ∈ f a) (hbase : (a_final : α) → Sum.inl b ∈ f a_final → C a_final)
(hind : (a₀ a₁ : α) → b ∈ f.fix a₁ → Sum.inr a₁ ∈ f a₀ → C a₁ → C a₀),
PFun.fixInduction' h hbase hind = hind a a' h' fa (PFun.fixInduction' h' hbase hind)
def PFun.image E1 #
{α : Type u_1} → {β : Type u_2} → (α →. β) → Set α → Set β
Image of a set under a partial function.
theorem PFun.image_def E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s : Set α), f.image s = {y | ∃ x ∈ s, y ∈ f x}
theorem PFun.mem_image E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (y : β) (s : Set α), y ∈ f.image s ↔ ∃ x ∈ s, y ∈ f x
theorem PFun.image_mono E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) {s t : Set α}, s ⊆ t → f.image s ⊆ f.image t
theorem PFun.image_inter E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s t : Set α), f.image (s ∩ t) ⊆ f.image s ∩ f.image t
theorem PFun.image_union E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s t : Set α), f.image (s ∪ t) = f.image s ∪ f.image t
theorem PFun.image_subset_ran E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) {S : Set α}, f.image S ⊆ f.ran
theorem PFun.ran_restrict E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) {S : Set α} (hS : S ⊆ f.Dom), (f.restrict hS).ran = f.image S
theorem PFun.image_map E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (g : β → γ) (f : α →. β) (S : Set α),
(PFun.map g f).image S = g '' f.image S
def PFun.preimage E1 #
{α : Type u_1} → {β : Type u_2} → (α →. β) → Set β → Set α
Preimage of a set under a partial function.
theorem PFun.Preimage_def E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s : Set β), f.preimage s = {x | ∃ y ∈ s, y ∈ f x}
theorem PFun.mem_preimage E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s : Set β) (x : α), x ∈ f.preimage s ↔ ∃ y ∈ s, y ∈ f x
theorem PFun.preimage_subset_dom E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s : Set β), f.preimage s ⊆ f.Dom
theorem PFun.preimage_mono E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) {s t : Set β}, s ⊆ t → f.preimage s ⊆ f.preimage t
theorem PFun.preimage_inter E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s t : Set β), f.preimage (s ∩ t) = f.preimage s ∩ f.preimage t
theorem PFun.preimage_union E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s t : Set β), f.preimage (s ∪ t) = f.preimage s ∪ f.preimage t
theorem PFun.preimage_univ E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β), f.preimage Set.univ = f.Dom
theorem PFun.coe_preimage E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α → β) (s : Set β), (↑f).preimage s = f ⁻¹' s
theorem PFun.preimage_empty E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β), f.preimage ∅ = ∅
theorem PFun.disjoint_preimage_of_disjoint E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) {s t : Set β}, Disjoint s t → Disjoint (f.preimage s) (f.preimage t)
theorem PFun.preimage_restrict E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) {S : Set α} {T : Set β} (hS : S ⊆ f.Dom),
(f.restrict hS).preimage T = f.preimage T ∩ S
theorem PFun.preimage_map E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : α →. β) (g : β → γ) (S : Set γ),
(PFun.map g f).preimage S = f.preimage (g ⁻¹' S)
def PFun.core E1 #
{α : Type u_1} → {β : Type u_2} → (α →. β) → Set β → Set α
Core of a set s : Set β with respect to a partial function f : α →. β. Set of all a : α
such that f a ∈ s, if f a is defined.
theorem PFun.core_def E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s : Set β), f.core s = {x | ∀ y ∈ f x, y ∈ s}
theorem PFun.mem_core E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (x : α) (s : Set β), x ∈ f.core s ↔ ∀ y ∈ f x, y ∈ s
theorem PFun.compl_dom_subset_core E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s : Set β), f.Domᶜ ⊆ f.core s
theorem PFun.core_mono E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) {s t : Set β}, s ⊆ t → f.core s ⊆ f.core t
theorem PFun.core_inter E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s t : Set β), f.core (s ∩ t) = f.core s ∩ f.core t
theorem PFun.mem_core_res E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α → β) (s : Set α) (t : Set β) (x : α), x ∈ (PFun.res f s).core t ↔ x ∈ s → f x ∈ t
theorem PFun.core_res E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α → β) (s : Set α) (t : Set β), (PFun.res f s).core t = sᶜ ∪ f ⁻¹' t
theorem PFun.core_restrict E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α → β) (s : Set β), (↑f).core s = f ⁻¹' s
theorem PFun.preimage_subset_core E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s : Set β), f.preimage s ⊆ f.core s
theorem PFun.preimage_eq E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s : Set β), f.preimage s = f.core s ∩ f.Dom
theorem PFun.core_eq E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s : Set β), f.core s = f.preimage s ∪ f.Domᶜ
theorem PFun.preimage_asSubtype E1 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β) (s : Set β), f.asSubtype ⁻¹' s = Subtype.val ⁻¹' f.preimage s
def PFun.toSubtype E1 #
{α : Type u_1} → {β : Type u_2} → (p : β → Prop) → (α → β) → α →. Subtype p
Turns a function into a partial function to a subtype.
theorem PFun.dom_toSubtype E0 #
∀ {α : Type u_1} {β : Type u_2} (p : β → Prop) (f : α → β), (PFun.toSubtype p f).Dom = {a | p (f a)}
theorem PFun.toSubtype_apply E0 #
∀ {α : Type u_1} {β : Type u_2} (p : β → Prop) (f : α → β) (a : α),
PFun.toSubtype p f a = { Dom := p (f a), get := Subtype.mk (f a) }
theorem PFun.dom_toSubtype_apply_iff E0 #
∀ {α : Type u_1} {β : Type u_2} {p : β → Prop} {f : α → β} {a : α}, (PFun.toSubtype p f a).Dom ↔ p (f a)
theorem PFun.mem_toSubtype_iff E0 #
∀ {α : Type u_1} {β : Type u_2} {p : β → Prop} {f : α → β} {a : α} {b : Subtype p}, b ∈ PFun.toSubtype p f a ↔ ↑b = f a
def PFun.id E1 #
(α : Type u_7) → α →. α
The identity as a partial function
theorem PFun.coe_id E0 #
∀ (α : Type u_7), ↑id = PFun.id α
theorem PFun.id_apply E0 #
∀ {α : Type u_1} (a : α), PFun.id α a = Part.some a
def PFun.comp E1 #
{α : Type u_1} → {β : Type u_2} → {γ : Type u_3} → (β →. γ) → (α →. β) → α →. γ
Composition of partial functions as a partial function.
theorem PFun.comp_apply E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : β →. γ) (g : α →. β) (a : α), f.comp g a = (g a).bind f
theorem PFun.id_comp E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β), (PFun.id β).comp f = f
theorem PFun.comp_id E0 #
∀ {α : Type u_1} {β : Type u_2} (f : α →. β), f.comp (PFun.id α) = f
theorem PFun.dom_comp E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : β →. γ) (g : α →. β), (f.comp g).Dom = g.preimage f.Dom
theorem PFun.preimage_comp E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : β →. γ) (g : α →. β) (s : Set γ),
(f.comp g).preimage s = g.preimage (f.preimage s)
theorem PFun.Part.bind_comp E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : β →. γ) (g : α →. β) (a : Part α),
a.bind (f.comp g) = (a.bind g).bind f
theorem PFun.comp_assoc E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} (f : γ →. δ) (g : β →. γ) (h : α →. β),
(f.comp g).comp h = f.comp (g.comp h)
theorem PFun.coe_comp E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (g : β → γ) (f : α → β), ↑(g ∘ f) = (↑g).comp ↑f
def PFun.prodLift E1 #
{α : Type u_1} → {β : Type u_2} → {γ : Type u_3} → (α →. β) → (α →. γ) → α →. β × γ
Product of partial functions.
theorem PFun.dom_prodLift E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : α →. β) (g : α →. γ),
(f.prodLift g).Dom = {x | (f x).Dom ∧ (g x).Dom}
theorem PFun.get_prodLift E1 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : α →. β) (g : α →. γ) (x : α) (h : (f.prodLift g x).Dom),
(f.prodLift g x).get h = ((f x).get ⋯, (g x).get ⋯)
theorem PFun.prodLift_apply E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : α →. β) (g : α →. γ) (x : α),
f.prodLift g x = { Dom := (f x).Dom ∧ (g x).Dom, get := fun h ↦ ((f x).get ⋯, (g x).get ⋯) }
theorem PFun.mem_prodLift E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {f : α →. β} {g : α →. γ} {x : α} {y : β × γ},
y ∈ f.prodLift g x ↔ y.1 ∈ f x ∧ y.2 ∈ g x
def PFun.prodMap E1 #
{α : Type u_1} → {β : Type u_2} → {γ : Type u_3} → {δ : Type u_4} → (α →. γ) → (β →. δ) → α × β →. γ × δ
Product of partial functions.
theorem PFun.dom_prodMap E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} (f : α →. γ) (g : β →. δ),
(f.prodMap g).Dom = {x | (f x.1).Dom ∧ (g x.2).Dom}
theorem PFun.get_prodMap E1 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} (f : α →. γ) (g : β →. δ) (x : α × β)
(h : (f.prodMap g x).Dom), (f.prodMap g x).get h = ((f x.1).get ⋯, (g x.2).get ⋯)
theorem PFun.prodMap_apply E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} (f : α →. γ) (g : β →. δ) (x : α × β),
f.prodMap g x = { Dom := (f x.1).Dom ∧ (g x.2).Dom, get := fun h ↦ ((f x.1).get ⋯, (g x.2).get ⋯) }
theorem PFun.mem_prodMap E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} {f : α →. γ} {g : β →. δ} {x : α × β} {y : γ × δ},
y ∈ f.prodMap g x ↔ y.1 ∈ f x.1 ∧ y.2 ∈ g x.2
theorem PFun.prodLift_fst_comp_snd_comp E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} (f : α →. γ) (g : β →. δ),
(f.comp ↑Prod.fst).prodLift (g.comp ↑Prod.snd) = f.prodMap g
theorem PFun.prodMap_id_id E0 #
∀ {α : Type u_1} {β : Type u_2}, (PFun.id α).prodMap (PFun.id β) = PFun.id (α × β)
theorem PFun.prodMap_comp_comp E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} {ε : Type u_5} {ι : Type u_6} (f₁ : α →. β) (f₂ : β →. γ)
(g₁ : δ →. ε) (g₂ : ε →. ι), (f₂.comp f₁).prodMap (g₂.comp g₁) = (f₂.prodMap g₂).comp (f₁.prodMap g₁)