fact
stringlengths
6
3.84k
type
stringclasses
11 values
library
stringclasses
32 values
imports
listlengths
1
14
filename
stringlengths
20
95
symbolic_name
stringlengths
1
90
docstring
stringlengths
7
20k
single_trans_of_mem (a : α) {b : β} {c : γ} {f : β ≃. γ} (h : c ∈ f b) : (single a b).trans f = single a c := by ext dsimp [single, PEquiv.trans] split_ifs <;> simp_all
theorem
Data
[ "Mathlib.Data.Option.Basic", "Batteries.Tactic.Congr", "Mathlib.Data.Set.Basic", "Mathlib.Tactic.Contrapose" ]
Mathlib/Data/PEquiv.lean
single_trans_of_mem
null
trans_single_of_mem {a : α} {b : β} (c : γ) {f : α ≃. β} (h : b ∈ f a) : f.trans (single b c) = single a c := symm_injective <| single_trans_of_mem _ ((mem_iff_mem f).2 h) @[simp]
theorem
Data
[ "Mathlib.Data.Option.Basic", "Batteries.Tactic.Congr", "Mathlib.Data.Set.Basic", "Mathlib.Tactic.Contrapose" ]
Mathlib/Data/PEquiv.lean
trans_single_of_mem
null
single_trans_single (a : α) (b : β) (c : γ) : (single a b).trans (single b c) = single a c := single_trans_of_mem _ (mem_single _ _) @[simp]
theorem
Data
[ "Mathlib.Data.Option.Basic", "Batteries.Tactic.Congr", "Mathlib.Data.Set.Basic", "Mathlib.Tactic.Contrapose" ]
Mathlib/Data/PEquiv.lean
single_trans_single
null
single_subsingleton_eq_refl [Subsingleton α] (a b : α) : single a b = PEquiv.refl α := by ext i j dsimp [single] rw [if_pos (Subsingleton.elim i a), Subsingleton.elim i j, Subsingleton.elim b j]
theorem
Data
[ "Mathlib.Data.Option.Basic", "Batteries.Tactic.Congr", "Mathlib.Data.Set.Basic", "Mathlib.Tactic.Contrapose" ]
Mathlib/Data/PEquiv.lean
single_subsingleton_eq_refl
null
trans_single_of_eq_none {b : β} (c : γ) {f : δ ≃. β} (h : f.symm b = none) : f.trans (single b c) = ⊥ := by ext simp only [eq_none_iff_forall_not_mem, Option.mem_def, f.eq_some_iff] at h dsimp [PEquiv.trans, single] simp only [bind_eq_some_iff, iff_false, not_exists, not_and, reduceCtorEq] intros split_ifs <;> simp_all
theorem
Data
[ "Mathlib.Data.Option.Basic", "Batteries.Tactic.Congr", "Mathlib.Data.Set.Basic", "Mathlib.Tactic.Contrapose" ]
Mathlib/Data/PEquiv.lean
trans_single_of_eq_none
null
single_trans_of_eq_none (a : α) {b : β} {f : β ≃. δ} (h : f b = none) : (single a b).trans f = ⊥ := symm_injective <| trans_single_of_eq_none _ h
theorem
Data
[ "Mathlib.Data.Option.Basic", "Batteries.Tactic.Congr", "Mathlib.Data.Set.Basic", "Mathlib.Tactic.Contrapose" ]
Mathlib/Data/PEquiv.lean
single_trans_of_eq_none
null
single_trans_single_of_ne {b₁ b₂ : β} (h : b₁ ≠ b₂) (a : α) (c : γ) : (single a b₁).trans (single b₂ c) = ⊥ := single_trans_of_eq_none _ (single_apply_of_ne h.symm _)
theorem
Data
[ "Mathlib.Data.Option.Basic", "Batteries.Tactic.Congr", "Mathlib.Data.Set.Basic", "Mathlib.Tactic.Contrapose" ]
Mathlib/Data/PEquiv.lean
single_trans_single_of_ne
null
instPartialOrderPEquiv : PartialOrder (α ≃. β) where le f g := ∀ (a : α) (b : β), b ∈ f a → b ∈ g a le_refl _ _ _ := id le_trans _ _ _ fg gh a b := gh a b ∘ fg a b le_antisymm f g fg gf := ext (by intro a rcases h : g a with _ | b · exact eq_none_iff_forall_not_mem.2 fun b hb => Option.not_mem_none b <| h ▸ fg a b hb · exact gf _ _ h)
instance
Data
[ "Mathlib.Data.Option.Basic", "Batteries.Tactic.Congr", "Mathlib.Data.Set.Basic", "Mathlib.Tactic.Contrapose" ]
Mathlib/Data/PEquiv.lean
instPartialOrderPEquiv
null
le_def {f g : α ≃. β} : f ≤ g ↔ ∀ (a : α) (b : β), b ∈ f a → b ∈ g a := Iff.rfl
theorem
Data
[ "Mathlib.Data.Option.Basic", "Batteries.Tactic.Congr", "Mathlib.Data.Set.Basic", "Mathlib.Tactic.Contrapose" ]
Mathlib/Data/PEquiv.lean
le_def
null
toPEquiv (f : α ≃ β) : α ≃. β where toFun := some ∘ f invFun := some ∘ f.symm inv := by simp [Equiv.eq_symm_apply, eq_comm] @[simp]
def
Data
[ "Mathlib.Data.Option.Basic", "Batteries.Tactic.Congr", "Mathlib.Data.Set.Basic", "Mathlib.Tactic.Contrapose" ]
Mathlib/Data/PEquiv.lean
toPEquiv
Turns an `Equiv` into a `PEquiv` of the whole type.
toPEquiv_refl : (Equiv.refl α).toPEquiv = PEquiv.refl α := rfl
theorem
Data
[ "Mathlib.Data.Option.Basic", "Batteries.Tactic.Congr", "Mathlib.Data.Set.Basic", "Mathlib.Tactic.Contrapose" ]
Mathlib/Data/PEquiv.lean
toPEquiv_refl
null
toPEquiv_trans (f : α ≃ β) (g : β ≃ γ) : (f.trans g).toPEquiv = f.toPEquiv.trans g.toPEquiv := rfl
theorem
Data
[ "Mathlib.Data.Option.Basic", "Batteries.Tactic.Congr", "Mathlib.Data.Set.Basic", "Mathlib.Tactic.Contrapose" ]
Mathlib/Data/PEquiv.lean
toPEquiv_trans
null
toPEquiv_symm (f : α ≃ β) : f.symm.toPEquiv = f.toPEquiv.symm := rfl @[simp]
theorem
Data
[ "Mathlib.Data.Option.Basic", "Batteries.Tactic.Congr", "Mathlib.Data.Set.Basic", "Mathlib.Tactic.Contrapose" ]
Mathlib/Data/PEquiv.lean
toPEquiv_symm
null
toPEquiv_apply (f : α ≃ β) (x : α) : f.toPEquiv x = some (f x) := rfl
theorem
Data
[ "Mathlib.Data.Option.Basic", "Batteries.Tactic.Congr", "Mathlib.Data.Set.Basic", "Mathlib.Tactic.Contrapose" ]
Mathlib/Data/PEquiv.lean
toPEquiv_apply
null
PFun (α β : Type*) := α → Part β
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
PFun
`PFun α β`, or `α →. β`, is the type of partial functions from `α` to `β`. It is defined as `α → Part β`.
Dom (f : α →. β) : Set α := { a | (f a).Dom } @[simp]
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
Dom
`α →. β` is notation for the type `PFun α β` of partial functions from `α` to `β`. -/ infixr:25 " →. " => PFun namespace PFun variable {α β γ δ ε ι : Type*} instance inhabited : Inhabited (α →. β) := ⟨fun _ => Part.none⟩ /-- The domain of a partial function
mem_dom (f : α →. β) (x : α) : x ∈ Dom f ↔ ∃ y, y ∈ f x := by simp [Dom, Part.dom_iff_mem] @[simp]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
mem_dom
null
dom_mk (p : α → Prop) (f : ∀ a, p a → β) : (PFun.Dom fun x => ⟨p x, f x⟩) = { x | p x } := rfl
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
dom_mk
null
dom_eq (f : α →. β) : Dom f = { x | ∃ y, y ∈ f x } := Set.ext (mem_dom f)
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
dom_eq
null
fn (f : α →. β) (a : α) : Dom f a → β := (f a).get @[simp]
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
fn
Evaluate a partial function
fn_apply (f : α →. β) (a : α) : f.fn a = (f a).get := rfl
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
fn_apply
null
evalOpt (f : α →. β) [D : DecidablePred (· ∈ Dom f)] (x : α) : Option β := @Part.toOption _ _ (D x)
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
evalOpt
Evaluate a partial function to return an `Option`
ext' {f g : α →. β} (H1 : ∀ a, a ∈ Dom f ↔ a ∈ Dom g) (H2 : ∀ a p q, f.fn a p = g.fn a q) : f = g := funext fun a => Part.ext' (H1 a) (H2 a) @[ext]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
ext'
Partial function extensionality
ext {f g : α →. β} (H : ∀ a b, b ∈ f a ↔ b ∈ g a) : f = g := funext fun a => Part.ext (H a)
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
ext
null
asSubtype (f : α →. β) (s : f.Dom) : β := f.fn s s.2
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
asSubtype
Turns a partial function into a function out of its domain.
equivSubtype : (α →. β) ≃ Σ p : α → Prop, Subtype p → β := ⟨fun f => ⟨fun a => (f a).Dom, asSubtype f⟩, fun f x => ⟨f.1 x, fun h => f.2 ⟨x, h⟩⟩, fun _ => funext fun _ => Part.eta _, fun ⟨p, f⟩ => by dsimp; congr⟩
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
equivSubtype
The type of partial functions `α →. β` is equivalent to the type of pairs `(p : α → Prop, f : Subtype p → β)`.
asSubtype_eq_of_mem {f : α →. β} {x : α} {y : β} (fxy : y ∈ f x) (domx : x ∈ f.Dom) : f.asSubtype ⟨x, domx⟩ = y := Part.mem_unique (Part.get_mem _) fxy
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
asSubtype_eq_of_mem
null
@[coe] protected lift (f : α → β) : α →. β := fun a => Part.some (f a)
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
lift
Turn a total function into a partial function.
coe : Coe (α → β) (α →. β) := ⟨PFun.lift⟩ @[simp]
instance
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
coe
null
coe_val (f : α → β) (a : α) : (f : α →. β) a = Part.some (f a) := rfl @[simp]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
coe_val
null
dom_coe (f : α → β) : (f : α →. β).Dom = Set.univ := rfl
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
dom_coe
null
lift_injective : Injective (PFun.lift : (α → β) → α →. β) := fun _ _ h => funext fun a => Part.some_injective <| congr_fun h a
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
lift_injective
null
graph (f : α →. β) : Set (α × β) := { p | p.2 ∈ f p.1 }
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
graph
Graph of a partial function `f` as the set of pairs `(x, f x)` where `x` is in the domain of `f`.
graph' (f : α →. β) : SetRel α β := {(x, y) : α × β | y ∈ f x}
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
graph'
Graph of a partial function as a relation. `x` and `y` are related iff `f x` is defined and "equals" `y`.
ran (f : α →. β) : Set β := { b | ∃ a, b ∈ f a }
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
ran
The range of a partial function is the set of values `f x` where `x` is in the domain of `f`.
restrict (f : α →. β) {p : Set α} (H : p ⊆ f.Dom) : α →. β := fun x => (f x).restrict (x ∈ p) (@H x) @[simp]
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
restrict
Restrict a partial function to a smaller domain.
mem_restrict {f : α →. β} {s : Set α} (h : s ⊆ f.Dom) (a : α) (b : β) : b ∈ f.restrict h a ↔ a ∈ s ∧ b ∈ f a := by simp [restrict]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
mem_restrict
null
res (f : α → β) (s : Set α) : α →. β := (PFun.lift f).restrict s.subset_univ
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
res
Turns a function into a partial function with a prescribed domain.
mem_res (f : α → β) (s : Set α) (a : α) (b : β) : b ∈ res f s a ↔ a ∈ s ∧ f a = b := by simp [res, @eq_comm _ b]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
mem_res
null
res_univ (f : α → β) : PFun.res f Set.univ = f := rfl
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
res_univ
null
dom_iff_graph (f : α →. β) (x : α) : x ∈ f.Dom ↔ ∃ y, (x, y) ∈ f.graph := Part.dom_iff_mem
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
dom_iff_graph
null
lift_graph {f : α → β} {a b} : (a, b) ∈ (f : α →. β).graph ↔ f a = b := show (∃ _ : True, f a = b) ↔ f a = b by simp
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
lift_graph
null
protected pure (x : β) : α →. β := fun _ => Part.some x
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
pure
The monad `pure` function, the total constant `x` function
bind (f : α →. β) (g : β → α →. γ) : α →. γ := fun a => (f a).bind fun b => g b a @[simp]
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
bind
The monad `bind` function, pointwise `Part.bind`
bind_apply (f : α →. β) (g : β → α →. γ) (a : α) : f.bind g a = (f a).bind fun b => g b a := rfl
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
bind_apply
null
map (f : β → γ) (g : α →. β) : α →. γ := fun a => (g a).map f
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
map
The monad `map` function, pointwise `Part.map`
monad : Monad (PFun α) where pure := PFun.pure bind := PFun.bind map := PFun.map
instance
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
monad
null
lawfulMonad : LawfulMonad (PFun α) := LawfulMonad.mk' (bind_pure_comp := fun _ _ => funext fun _ => Part.bind_some_eq_map _ _) (id_map := fun f => by funext a; dsimp [Functor.map, PFun.map]; cases f a; rfl) (pure_bind := fun x f => funext fun _ => Part.bind_some _ (f x)) (bind_assoc := fun f g k => funext fun a => (f a).bind_assoc (fun b => g b a) fun b => k b a)
instance
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
lawfulMonad
null
pure_defined (p : Set α) (x : β) : p ⊆ (@PFun.pure α _ x).Dom := p.subset_univ
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
pure_defined
null
bind_defined {α β γ} (p : Set α) {f : α →. β} {g : β → α →. γ} (H1 : p ⊆ f.Dom) (H2 : ∀ x, p ⊆ (g x).Dom) : p ⊆ (f >>= g).Dom := fun a ha => (⟨H1 ha, H2 _ ha⟩ : (f >>= g).Dom a)
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
bind_defined
null
fix (f : α →. β ⊕ α) : α →. β := fun a => Part.assert (Acc (fun x y => Sum.inr x ∈ f y) a) fun h => WellFounded.fixF (fun a IH => Part.assert (f a).Dom fun hf => match e : (f a).get hf with | Sum.inl b => Part.some b | Sum.inr a' => IH a' ⟨hf, e⟩) a h
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
fix
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)`).
dom_of_mem_fix {f : α →. β ⊕ α} {a : α} {b : β} (h : b ∈ f.fix a) : (f a).Dom := by let ⟨h₁, h₂⟩ := Part.mem_assert_iff.1 h rw [WellFounded.fixF_eq] at h₂; exact h₂.fst.fst
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
dom_of_mem_fix
null
mem_fix_iff {f : α →. β ⊕ α} {a : α} {b : β} : b ∈ f.fix a ↔ Sum.inl b ∈ f a ∨ ∃ a', Sum.inr a' ∈ f a ∧ b ∈ f.fix a' := ⟨fun h => by let ⟨h₁, h₂⟩ := Part.mem_assert_iff.1 h rw [WellFounded.fixF_eq] at h₂ simp only [Part.mem_assert_iff] at h₂ obtain ⟨h₂, h₃⟩ := h₂ split at h₃ next e => simp only [Part.mem_some_iff] at h₃; subst b; exact Or.inl ⟨h₂, e⟩ next e => exact Or.inr ⟨_, ⟨_, e⟩, Part.mem_assert _ h₃⟩, fun h => by simp only [fix, Part.mem_assert_iff] rcases h with (⟨h₁, h₂⟩ | ⟨a', h, h₃⟩) · refine ⟨⟨_, fun y h' => ?_⟩, ?_⟩ · injection Part.mem_unique ⟨h₁, h₂⟩ h' · rw [WellFounded.fixF_eq] apply Part.mem_assert h₁ split next e => injection h₂.symm.trans e with h; simp [h] next e => injection h₂.symm.trans e · simp only [fix, Part.mem_assert_iff] at h₃ obtain ⟨h₃, h₄⟩ := h₃ refine ⟨⟨_, fun y h' => ?_⟩, ?_⟩ · injection Part.mem_unique h h' with e exact e ▸ h₃ · obtain ⟨h₁, h₂⟩ := h rw [WellFounded.fixF_eq] apply Part.mem_assert h₁ split next e => injection h₂.symm.trans e next e => injection h₂.symm.trans e; subst a'; exact h₄⟩
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
mem_fix_iff
null
fix_stop {f : α →. β ⊕ α} {b : β} {a : α} (hb : Sum.inl b ∈ f a) : b ∈ f.fix a := by rw [PFun.mem_fix_iff] exact Or.inl hb
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
fix_stop
If advancing one step from `a` leads to `b : β`, then `f.fix a = b`
fix_fwd_eq {f : α →. β ⊕ α} {a a' : α} (ha' : Sum.inr a' ∈ f a) : f.fix a = f.fix a' := by ext b; constructor · intro h obtain h' | ⟨a, h', e'⟩ := mem_fix_iff.1 h <;> cases Part.mem_unique ha' h' exact e' · intro h rw [PFun.mem_fix_iff] exact Or.inr ⟨a', ha', h⟩
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
fix_fwd_eq
If advancing one step from `a` on `f` leads to `a' : α`, then `f.fix a = f.fix a'`
fix_fwd {f : α →. β ⊕ α} {b : β} {a a' : α} (hb : b ∈ f.fix a) (ha' : Sum.inr a' ∈ f a) : b ∈ f.fix a' := by rwa [← fix_fwd_eq ha']
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
fix_fwd
null
@[elab_as_elim] fixInduction {C : α → Sort*} {f : α →. β ⊕ α} {b : β} {a : α} (h : b ∈ f.fix a) (H : ∀ a', b ∈ f.fix a' → (∀ a'', Sum.inr a'' ∈ f a' → C a'') → C a') : C a := by have h₂ := (Part.mem_assert_iff.1 h).snd generalize_proofs at h₂ clear h induction ‹Acc _ _› with | intro a ha IH => _ have h : b ∈ f.fix a := Part.mem_assert_iff.2 ⟨⟨a, ha⟩, h₂⟩ exact H a h fun a' fa' => IH a' fa' (Part.mem_assert_iff.1 (fix_fwd h fa')).snd
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
fixInduction
A recursion principle for `PFun.fix`.
fixInduction_spec {C : α → Sort*} {f : α →. β ⊕ α} {b : β} {a : α} (h : b ∈ f.fix a) (H : ∀ a', b ∈ f.fix a' → (∀ a'', Sum.inr a'' ∈ f a' → C a'') → C a') : @fixInduction _ _ C _ _ _ h H = H a h fun _ h' => fixInduction (fix_fwd h h') H := by unfold fixInduction generalize_proofs induction ‹Acc _ _› rfl
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
fixInduction_spec
null
@[elab_as_elim] fixInduction' {C : α → Sort*} {f : α →. β ⊕ α} {b : β} {a : α} (h : b ∈ f.fix 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₀) : C a := by refine fixInduction h fun a' h ih => ?_ rcases e : (f a').get (dom_of_mem_fix h) with b' | a'' <;> replace e : _ ∈ f a' := ⟨_, e⟩ · apply hbase convert e exact Part.mem_unique h (fix_stop e) · exact hind _ _ (fix_fwd h e) e (ih _ e)
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
fixInduction'
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`.
fixInduction'_stop {C : α → Sort*} {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₀) : @fixInduction' _ _ C _ _ _ h hbase hind = hbase a fa := by unfold fixInduction' rw [fixInduction_spec] refine Eq.rec (motive := fun x e ↦ Sum.casesOn x ?_ ?_ (Eq.trans (Part.get_eq_of_mem fa (dom_of_mem_fix h)) e) = hbase a fa) ?_ (Part.get_eq_of_mem fa (dom_of_mem_fix h)).symm simp
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
fixInduction'_stop
null
fixInduction'_fwd {C : α → Sort*} {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₀) : @fixInduction' _ _ C _ _ _ h hbase hind = hind a a' h' fa (fixInduction' h' hbase hind) := by unfold fixInduction' rw [fixInduction_spec] refine Eq.rec (motive := fun x e => Sum.casesOn (motive := fun y => (f a).get (dom_of_mem_fix h) = y → C a) x ?_ ?_ (Eq.trans (Part.get_eq_of_mem fa (dom_of_mem_fix h)) e) = _) ?_ (Part.get_eq_of_mem fa (dom_of_mem_fix h)).symm simp variable (f : α →. β)
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
fixInduction'_fwd
null
image (s : Set α) : Set β := f.graph'.image s
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
image
Image of a set under a partial function.
image_def (s : Set α) : f.image s = { y | ∃ x ∈ s, y ∈ f x } := rfl
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
image_def
null
mem_image (y : β) (s : Set α) : y ∈ f.image s ↔ ∃ x ∈ s, y ∈ f x := Iff.rfl
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
mem_image
null
image_mono {s t : Set α} (h : s ⊆ t) : f.image s ⊆ f.image t := SetRel.image_mono h
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
image_mono
null
image_inter (s t : Set α) : f.image (s ∩ t) ⊆ f.image s ∩ f.image t := SetRel.image_inter_subset _
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
image_inter
null
image_union (s t : Set α) : f.image (s ∪ t) = f.image s ∪ f.image t := SetRel.image_union _ s t
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
image_union
null
preimage (s : Set β) : Set α := f.graph'.preimage s
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
preimage
Preimage of a set under a partial function.
Preimage_def (s : Set β) : f.preimage s = { x | ∃ y ∈ s, y ∈ f x } := rfl @[simp]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
Preimage_def
null
mem_preimage (s : Set β) (x : α) : x ∈ f.preimage s ↔ ∃ y ∈ s, y ∈ f x := Iff.rfl
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
mem_preimage
null
preimage_subset_dom (s : Set β) : f.preimage s ⊆ f.Dom := fun _ ⟨y, _, fxy⟩ => Part.dom_iff_mem.mpr ⟨y, fxy⟩
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
preimage_subset_dom
null
preimage_mono {s t : Set β} (h : s ⊆ t) : f.preimage s ⊆ f.preimage t := SetRel.preimage_mono h
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
preimage_mono
null
preimage_inter (s t : Set β) : f.preimage (s ∩ t) ⊆ f.preimage s ∩ f.preimage t := SetRel.preimage_inter_subset _
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
preimage_inter
null
preimage_union (s t : Set β) : f.preimage (s ∪ t) = f.preimage s ∪ f.preimage t := SetRel.preimage_union _ s t
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
preimage_union
null
preimage_univ : f.preimage Set.univ = f.Dom := by ext; simp [mem_preimage, mem_dom]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
preimage_univ
null
coe_preimage (f : α → β) (s : Set β) : (f : α →. β).preimage s = f ⁻¹' s := by ext; simp
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
coe_preimage
null
core (s : Set β) : Set α := f.graph'.core s
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
core
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.
core_def (s : Set β) : f.core s = { x | ∀ y, y ∈ f x → y ∈ s } := rfl @[simp]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
core_def
null
mem_core (x : α) (s : Set β) : x ∈ f.core s ↔ ∀ y, y ∈ f x → y ∈ s := Iff.rfl
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
mem_core
null
compl_dom_subset_core (s : Set β) : f.Domᶜ ⊆ f.core s := fun x hx y fxy => absurd ((mem_dom f x).mpr ⟨y, fxy⟩) hx
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
compl_dom_subset_core
null
core_mono {s t : Set β} (h : s ⊆ t) : f.core s ⊆ f.core t := SetRel.core_mono h
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
core_mono
null
core_inter (s t : Set β) : f.core (s ∩ t) = f.core s ∩ f.core t := SetRel.core_inter _ s t
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
core_inter
null
mem_core_res (f : α → β) (s : Set α) (t : Set β) (x : α) : x ∈ (res f s).core t ↔ x ∈ s → f x ∈ t := by simp [mem_core, mem_res]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
mem_core_res
null
core_res (f : α → β) (s : Set α) (t : Set β) : (res f s).core t = sᶜ ∪ f ⁻¹' t := by ext x rw [mem_core_res] by_cases h : x ∈ s <;> simp [h]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
core_res
null
core_restrict (f : α → β) (s : Set β) : (f : α →. β).core s = s.preimage f := by ext x; simp [core_def]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
core_restrict
null
preimage_subset_core (f : α →. β) (s : Set β) : f.preimage s ⊆ f.core s := fun _ ⟨y, ys, fxy⟩ y' fxy' => have : y = y' := Part.mem_unique fxy fxy' this ▸ ys
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
preimage_subset_core
null
preimage_eq (f : α →. β) (s : Set β) : f.preimage s = f.core s ∩ f.Dom := Set.eq_of_subset_of_subset (Set.subset_inter (f.preimage_subset_core s) (f.preimage_subset_dom s)) fun x ⟨xcore, xdom⟩ => let y := (f x).get xdom have ys : y ∈ s := xcore (Part.get_mem _) show x ∈ f.preimage s from ⟨(f x).get xdom, ys, Part.get_mem _⟩
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
preimage_eq
null
core_eq (f : α →. β) (s : Set β) : f.core s = f.preimage s ∪ f.Domᶜ := by rw [preimage_eq, Set.inter_union_distrib_right, Set.union_comm (Dom f), Set.compl_union_self, Set.inter_univ, Set.union_eq_self_of_subset_right (f.compl_dom_subset_core s)]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
core_eq
null
preimage_asSubtype (f : α →. β) (s : Set β) : f.asSubtype ⁻¹' s = Subtype.val ⁻¹' f.preimage s := by ext x simp only [Set.mem_preimage, PFun.asSubtype, PFun.mem_preimage] show f.fn x.val _ ∈ s ↔ ∃ y ∈ s, y ∈ f x.val exact Iff.intro (fun h => ⟨_, h, Part.get_mem _⟩) fun ⟨y, ys, fxy⟩ => have : f.fn x.val x.property ∈ f x.val := Part.get_mem _ Part.mem_unique fxy this ▸ ys
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
preimage_asSubtype
null
toSubtype (p : β → Prop) (f : α → β) : α →. Subtype p := fun a => ⟨p (f a), Subtype.mk _⟩ @[simp]
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
toSubtype
Turns a function into a partial function to a subtype.
dom_toSubtype (p : β → Prop) (f : α → β) : (toSubtype p f).Dom = { a | p (f a) } := rfl @[simp]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
dom_toSubtype
null
toSubtype_apply (p : β → Prop) (f : α → β) (a : α) : toSubtype p f a = ⟨p (f a), Subtype.mk _⟩ := rfl
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
toSubtype_apply
null
dom_toSubtype_apply_iff {p : β → Prop} {f : α → β} {a : α} : (toSubtype p f a).Dom ↔ p (f a) := Iff.rfl
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
dom_toSubtype_apply_iff
null
mem_toSubtype_iff {p : β → Prop} {f : α → β} {a : α} {b : Subtype p} : b ∈ toSubtype p f a ↔ ↑b = f a := by rw [toSubtype_apply, Part.mem_mk_iff, exists_subtype_mk_eq_iff, eq_comm]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
mem_toSubtype_iff
null
protected id (α : Type*) : α →. α := Part.some @[simp, norm_cast]
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
id
The identity as a partial function
coe_id (α : Type*) : ((id : α → α) : α →. α) = PFun.id α := rfl @[simp]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
coe_id
null
id_apply (a : α) : PFun.id α a = Part.some a := rfl
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
id_apply
null
comp (f : β →. γ) (g : α →. β) : α →. γ := fun a => (g a).bind f @[simp]
def
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
comp
Composition of partial functions as a partial function.
comp_apply (f : β →. γ) (g : α →. β) (a : α) : f.comp g a = (g a).bind f := rfl @[simp]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
comp_apply
null
id_comp (f : α →. β) : (PFun.id β).comp f = f := ext fun _ _ => by simp @[simp]
theorem
Data
[ "Batteries.WF", "Mathlib.Data.Part", "Mathlib.Data.Rel", "Mathlib.Tactic.GeneralizeProofs" ]
Mathlib/Data/PFun.lean
id_comp
null