Context
stringlengths
57
6.04k
file_name
stringlengths
21
79
start
int64
14
1.49k
end
int64
18
1.5k
theorem
stringlengths
25
1.55k
proof
stringlengths
5
7.36k
rank
int64
0
2.4k
import Mathlib.Data.Nat.Defs import Mathlib.Tactic.GCongr.Core import Mathlib.Tactic.Common import Mathlib.Tactic.Monotonicity.Attr #align_import data.nat.factorial.basic from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105" namespace Nat def factorial : ℕ → ℕ | 0 => 1 | succ n => succ n * factorial n #align nat.factorial Nat.factorial scoped notation:10000 n "!" => Nat.factorial n section DescFactorial def descFactorial (n : ℕ) : ℕ → ℕ | 0 => 1 | k + 1 => (n - k) * descFactorial n k #align nat.desc_factorial Nat.descFactorial @[simp] theorem descFactorial_zero (n : ℕ) : n.descFactorial 0 = 1 := rfl #align nat.desc_factorial_zero Nat.descFactorial_zero @[simp] theorem descFactorial_succ (n k : ℕ) : n.descFactorial (k + 1) = (n - k) * n.descFactorial k := rfl #align nat.desc_factorial_succ Nat.descFactorial_succ theorem zero_descFactorial_succ (k : ℕ) : (0 : ℕ).descFactorial (k + 1) = 0 := by rw [descFactorial_succ, Nat.zero_sub, Nat.zero_mul] #align nat.zero_desc_factorial_succ Nat.zero_descFactorial_succ
Mathlib/Data/Nat/Factorial/Basic.lean
344
344
theorem descFactorial_one (n : ℕ) : n.descFactorial 1 = n := by
simp
675
import Mathlib.Data.List.Count import Mathlib.Data.List.Dedup import Mathlib.Data.List.InsertNth import Mathlib.Data.List.Lattice import Mathlib.Data.List.Permutation import Mathlib.Data.Nat.Factorial.Basic #align_import data.list.perm from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" -- Make sure we don't import algebra assert_not_exists Monoid open Nat namespace List variable {α β : Type*} {l l₁ l₂ : List α} {a : α} #align list.perm List.Perm instance : Trans (@List.Perm α) (@List.Perm α) List.Perm where trans := @List.Perm.trans α open Perm (swap) attribute [refl] Perm.refl #align list.perm.refl List.Perm.refl lemma perm_rfl : l ~ l := Perm.refl _ -- Porting note: used rec_on in mathlib3; lean4 eqn compiler still doesn't like it attribute [symm] Perm.symm #align list.perm.symm List.Perm.symm #align list.perm_comm List.perm_comm #align list.perm.swap' List.Perm.swap' attribute [trans] Perm.trans #align list.perm.eqv List.Perm.eqv #align list.is_setoid List.isSetoid #align list.perm.mem_iff List.Perm.mem_iff #align list.perm.subset List.Perm.subset theorem Perm.subset_congr_left {l₁ l₂ l₃ : List α} (h : l₁ ~ l₂) : l₁ ⊆ l₃ ↔ l₂ ⊆ l₃ := ⟨h.symm.subset.trans, h.subset.trans⟩ #align list.perm.subset_congr_left List.Perm.subset_congr_left theorem Perm.subset_congr_right {l₁ l₂ l₃ : List α} (h : l₁ ~ l₂) : l₃ ⊆ l₁ ↔ l₃ ⊆ l₂ := ⟨fun h' => h'.trans h.subset, fun h' => h'.trans h.symm.subset⟩ #align list.perm.subset_congr_right List.Perm.subset_congr_right #align list.perm.append_right List.Perm.append_right #align list.perm.append_left List.Perm.append_left #align list.perm.append List.Perm.append #align list.perm.append_cons List.Perm.append_cons #align list.perm_middle List.perm_middle #align list.perm_append_singleton List.perm_append_singleton #align list.perm_append_comm List.perm_append_comm #align list.concat_perm List.concat_perm #align list.perm.length_eq List.Perm.length_eq #align list.perm.eq_nil List.Perm.eq_nil #align list.perm.nil_eq List.Perm.nil_eq #align list.perm_nil List.perm_nil #align list.nil_perm List.nil_perm #align list.not_perm_nil_cons List.not_perm_nil_cons #align list.reverse_perm List.reverse_perm #align list.perm_cons_append_cons List.perm_cons_append_cons #align list.perm_replicate List.perm_replicate #align list.replicate_perm List.replicate_perm #align list.perm_singleton List.perm_singleton #align list.singleton_perm List.singleton_perm #align list.singleton_perm_singleton List.singleton_perm_singleton #align list.perm_cons_erase List.perm_cons_erase #align list.perm_induction_on List.Perm.recOnSwap' -- Porting note: used to be @[congr] #align list.perm.filter_map List.Perm.filterMap -- Porting note: used to be @[congr] #align list.perm.map List.Perm.map #align list.perm.pmap List.Perm.pmap #align list.perm.filter List.Perm.filter #align list.filter_append_perm List.filter_append_perm #align list.exists_perm_sublist List.exists_perm_sublist #align list.perm.sizeof_eq_sizeof List.Perm.sizeOf_eq_sizeOf section Rel open Relator variable {γ : Type*} {δ : Type*} {r : α → β → Prop} {p : γ → δ → Prop} local infixr:80 " ∘r " => Relation.Comp
Mathlib/Data/List/Perm.lean
142
146
theorem perm_comp_perm : (Perm ∘r Perm : List α → List α → Prop) = Perm := by
funext a c; apply propext constructor · exact fun ⟨b, hab, hba⟩ => Perm.trans hab hba · exact fun h => ⟨a, Perm.refl a, h⟩
676
import Mathlib.Data.List.Count import Mathlib.Data.List.Dedup import Mathlib.Data.List.InsertNth import Mathlib.Data.List.Lattice import Mathlib.Data.List.Permutation import Mathlib.Data.Nat.Factorial.Basic #align_import data.list.perm from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" -- Make sure we don't import algebra assert_not_exists Monoid open Nat namespace List variable {α β : Type*} {l l₁ l₂ : List α} {a : α} #align list.perm List.Perm instance : Trans (@List.Perm α) (@List.Perm α) List.Perm where trans := @List.Perm.trans α open Perm (swap) attribute [refl] Perm.refl #align list.perm.refl List.Perm.refl lemma perm_rfl : l ~ l := Perm.refl _ -- Porting note: used rec_on in mathlib3; lean4 eqn compiler still doesn't like it attribute [symm] Perm.symm #align list.perm.symm List.Perm.symm #align list.perm_comm List.perm_comm #align list.perm.swap' List.Perm.swap' attribute [trans] Perm.trans #align list.perm.eqv List.Perm.eqv #align list.is_setoid List.isSetoid #align list.perm.mem_iff List.Perm.mem_iff #align list.perm.subset List.Perm.subset theorem Perm.subset_congr_left {l₁ l₂ l₃ : List α} (h : l₁ ~ l₂) : l₁ ⊆ l₃ ↔ l₂ ⊆ l₃ := ⟨h.symm.subset.trans, h.subset.trans⟩ #align list.perm.subset_congr_left List.Perm.subset_congr_left theorem Perm.subset_congr_right {l₁ l₂ l₃ : List α} (h : l₁ ~ l₂) : l₃ ⊆ l₁ ↔ l₃ ⊆ l₂ := ⟨fun h' => h'.trans h.subset, fun h' => h'.trans h.symm.subset⟩ #align list.perm.subset_congr_right List.Perm.subset_congr_right #align list.perm.append_right List.Perm.append_right #align list.perm.append_left List.Perm.append_left #align list.perm.append List.Perm.append #align list.perm.append_cons List.Perm.append_cons #align list.perm_middle List.perm_middle #align list.perm_append_singleton List.perm_append_singleton #align list.perm_append_comm List.perm_append_comm #align list.concat_perm List.concat_perm #align list.perm.length_eq List.Perm.length_eq #align list.perm.eq_nil List.Perm.eq_nil #align list.perm.nil_eq List.Perm.nil_eq #align list.perm_nil List.perm_nil #align list.nil_perm List.nil_perm #align list.not_perm_nil_cons List.not_perm_nil_cons #align list.reverse_perm List.reverse_perm #align list.perm_cons_append_cons List.perm_cons_append_cons #align list.perm_replicate List.perm_replicate #align list.replicate_perm List.replicate_perm #align list.perm_singleton List.perm_singleton #align list.singleton_perm List.singleton_perm #align list.singleton_perm_singleton List.singleton_perm_singleton #align list.perm_cons_erase List.perm_cons_erase #align list.perm_induction_on List.Perm.recOnSwap' -- Porting note: used to be @[congr] #align list.perm.filter_map List.Perm.filterMap -- Porting note: used to be @[congr] #align list.perm.map List.Perm.map #align list.perm.pmap List.Perm.pmap #align list.perm.filter List.Perm.filter #align list.filter_append_perm List.filter_append_perm #align list.exists_perm_sublist List.exists_perm_sublist #align list.perm.sizeof_eq_sizeof List.Perm.sizeOf_eq_sizeOf section Rel open Relator variable {γ : Type*} {δ : Type*} {r : α → β → Prop} {p : γ → δ → Prop} local infixr:80 " ∘r " => Relation.Comp theorem perm_comp_perm : (Perm ∘r Perm : List α → List α → Prop) = Perm := by funext a c; apply propext constructor · exact fun ⟨b, hab, hba⟩ => Perm.trans hab hba · exact fun h => ⟨a, Perm.refl a, h⟩ #align list.perm_comp_perm List.perm_comp_perm
Mathlib/Data/List/Perm.lean
149
164
theorem perm_comp_forall₂ {l u v} (hlu : Perm l u) (huv : Forall₂ r u v) : (Forall₂ r ∘r Perm) l v := by
induction hlu generalizing v with | nil => cases huv; exact ⟨[], Forall₂.nil, Perm.nil⟩ | cons u _hlu ih => cases' huv with _ b _ v hab huv' rcases ih huv' with ⟨l₂, h₁₂, h₂₃⟩ exact ⟨b :: l₂, Forall₂.cons hab h₁₂, h₂₃.cons _⟩ | swap a₁ a₂ h₂₃ => cases' huv with _ b₁ _ l₂ h₁ hr₂₃ cases' hr₂₃ with _ b₂ _ l₂ h₂ h₁₂ exact ⟨b₂ :: b₁ :: l₂, Forall₂.cons h₂ (Forall₂.cons h₁ h₁₂), Perm.swap _ _ _⟩ | trans _ _ ih₁ ih₂ => rcases ih₂ huv with ⟨lb₂, hab₂, h₂₃⟩ rcases ih₁ hab₂ with ⟨lb₁, hab₁, h₁₂⟩ exact ⟨lb₁, hab₁, Perm.trans h₁₂ h₂₃⟩
676
import Mathlib.Data.List.Count import Mathlib.Data.List.Dedup import Mathlib.Data.List.InsertNth import Mathlib.Data.List.Lattice import Mathlib.Data.List.Permutation import Mathlib.Data.Nat.Factorial.Basic #align_import data.list.perm from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" -- Make sure we don't import algebra assert_not_exists Monoid open Nat namespace List variable {α β : Type*} {l l₁ l₂ : List α} {a : α} #align list.perm List.Perm instance : Trans (@List.Perm α) (@List.Perm α) List.Perm where trans := @List.Perm.trans α open Perm (swap) attribute [refl] Perm.refl #align list.perm.refl List.Perm.refl lemma perm_rfl : l ~ l := Perm.refl _ -- Porting note: used rec_on in mathlib3; lean4 eqn compiler still doesn't like it attribute [symm] Perm.symm #align list.perm.symm List.Perm.symm #align list.perm_comm List.perm_comm #align list.perm.swap' List.Perm.swap' attribute [trans] Perm.trans #align list.perm.eqv List.Perm.eqv #align list.is_setoid List.isSetoid #align list.perm.mem_iff List.Perm.mem_iff #align list.perm.subset List.Perm.subset theorem Perm.subset_congr_left {l₁ l₂ l₃ : List α} (h : l₁ ~ l₂) : l₁ ⊆ l₃ ↔ l₂ ⊆ l₃ := ⟨h.symm.subset.trans, h.subset.trans⟩ #align list.perm.subset_congr_left List.Perm.subset_congr_left theorem Perm.subset_congr_right {l₁ l₂ l₃ : List α} (h : l₁ ~ l₂) : l₃ ⊆ l₁ ↔ l₃ ⊆ l₂ := ⟨fun h' => h'.trans h.subset, fun h' => h'.trans h.symm.subset⟩ #align list.perm.subset_congr_right List.Perm.subset_congr_right #align list.perm.append_right List.Perm.append_right #align list.perm.append_left List.Perm.append_left #align list.perm.append List.Perm.append #align list.perm.append_cons List.Perm.append_cons #align list.perm_middle List.perm_middle #align list.perm_append_singleton List.perm_append_singleton #align list.perm_append_comm List.perm_append_comm #align list.concat_perm List.concat_perm #align list.perm.length_eq List.Perm.length_eq #align list.perm.eq_nil List.Perm.eq_nil #align list.perm.nil_eq List.Perm.nil_eq #align list.perm_nil List.perm_nil #align list.nil_perm List.nil_perm #align list.not_perm_nil_cons List.not_perm_nil_cons #align list.reverse_perm List.reverse_perm #align list.perm_cons_append_cons List.perm_cons_append_cons #align list.perm_replicate List.perm_replicate #align list.replicate_perm List.replicate_perm #align list.perm_singleton List.perm_singleton #align list.singleton_perm List.singleton_perm #align list.singleton_perm_singleton List.singleton_perm_singleton #align list.perm_cons_erase List.perm_cons_erase #align list.perm_induction_on List.Perm.recOnSwap' -- Porting note: used to be @[congr] #align list.perm.filter_map List.Perm.filterMap -- Porting note: used to be @[congr] #align list.perm.map List.Perm.map #align list.perm.pmap List.Perm.pmap #align list.perm.filter List.Perm.filter #align list.filter_append_perm List.filter_append_perm #align list.exists_perm_sublist List.exists_perm_sublist #align list.perm.sizeof_eq_sizeof List.Perm.sizeOf_eq_sizeOf section Rel open Relator variable {γ : Type*} {δ : Type*} {r : α → β → Prop} {p : γ → δ → Prop} local infixr:80 " ∘r " => Relation.Comp theorem perm_comp_perm : (Perm ∘r Perm : List α → List α → Prop) = Perm := by funext a c; apply propext constructor · exact fun ⟨b, hab, hba⟩ => Perm.trans hab hba · exact fun h => ⟨a, Perm.refl a, h⟩ #align list.perm_comp_perm List.perm_comp_perm theorem perm_comp_forall₂ {l u v} (hlu : Perm l u) (huv : Forall₂ r u v) : (Forall₂ r ∘r Perm) l v := by induction hlu generalizing v with | nil => cases huv; exact ⟨[], Forall₂.nil, Perm.nil⟩ | cons u _hlu ih => cases' huv with _ b _ v hab huv' rcases ih huv' with ⟨l₂, h₁₂, h₂₃⟩ exact ⟨b :: l₂, Forall₂.cons hab h₁₂, h₂₃.cons _⟩ | swap a₁ a₂ h₂₃ => cases' huv with _ b₁ _ l₂ h₁ hr₂₃ cases' hr₂₃ with _ b₂ _ l₂ h₂ h₁₂ exact ⟨b₂ :: b₁ :: l₂, Forall₂.cons h₂ (Forall₂.cons h₁ h₁₂), Perm.swap _ _ _⟩ | trans _ _ ih₁ ih₂ => rcases ih₂ huv with ⟨lb₂, hab₂, h₂₃⟩ rcases ih₁ hab₂ with ⟨lb₁, hab₁, h₁₂⟩ exact ⟨lb₁, hab₁, Perm.trans h₁₂ h₂₃⟩ #align list.perm_comp_forall₂ List.perm_comp_forall₂
Mathlib/Data/List/Perm.lean
167
175
theorem forall₂_comp_perm_eq_perm_comp_forall₂ : Forall₂ r ∘r Perm = Perm ∘r Forall₂ r := by
funext l₁ l₃; apply propext constructor · intro h rcases h with ⟨l₂, h₁₂, h₂₃⟩ have : Forall₂ (flip r) l₂ l₁ := h₁₂.flip rcases perm_comp_forall₂ h₂₃.symm this with ⟨l', h₁, h₂⟩ exact ⟨l', h₂.symm, h₁.flip⟩ · exact fun ⟨l₂, h₁₂, h₂₃⟩ => perm_comp_forall₂ h₁₂ h₂₃
676
import Mathlib.Algebra.Associated import Mathlib.Algebra.BigOperators.Group.List import Mathlib.Data.List.Perm #align_import data.list.prime from "leanprover-community/mathlib"@"ccad6d5093bd2f5c6ca621fc74674cce51355af6" open List section CommMonoidWithZero variable {M : Type*} [CommMonoidWithZero M]
Mathlib/Data/List/Prime.lean
27
38
theorem Prime.dvd_prod_iff {p : M} {L : List M} (pp : Prime p) : p ∣ L.prod ↔ ∃ a ∈ L, p ∣ a := by
constructor · intro h induction' L with L_hd L_tl L_ih · rw [prod_nil] at h exact absurd h pp.not_dvd_one · rw [prod_cons] at h cases' pp.dvd_or_dvd h with hd hd · exact ⟨L_hd, mem_cons_self L_hd L_tl, hd⟩ · obtain ⟨x, hx1, hx2⟩ := L_ih hd exact ⟨x, mem_cons_of_mem L_hd hx1, hx2⟩ · exact fun ⟨a, ha1, ha2⟩ => dvd_trans ha2 (dvd_prod ha1)
677
import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Data.Nat.Factorial.Basic import Mathlib.Tactic.Ring import Mathlib.Tactic.Positivity.Core #align_import data.nat.factorial.double_factorial from "leanprover-community/mathlib"@"7daeaf3072304c498b653628add84a88d0e78767" open Nat namespace Nat @[simp] def doubleFactorial : ℕ → ℕ | 0 => 1 | 1 => 1 | k + 2 => (k + 2) * doubleFactorial k #align nat.double_factorial Nat.doubleFactorial -- This notation is `\!!` not two !'s @[inherit_doc] scoped notation:10000 n "‼" => Nat.doubleFactorial n lemma doubleFactorial_pos : ∀ n, 0 < n‼ | 0 | 1 => zero_lt_one | _n + 2 => mul_pos (succ_pos _) (doubleFactorial_pos _) theorem doubleFactorial_add_two (n : ℕ) : (n + 2)‼ = (n + 2) * n‼ := rfl #align nat.double_factorial_add_two Nat.doubleFactorial_add_two
Mathlib/Data/Nat/Factorial/DoubleFactorial.lean
48
48
theorem doubleFactorial_add_one (n : ℕ) : (n + 1)‼ = (n + 1) * (n - 1)‼ := by
cases n <;> rfl
678
import Mathlib.Data.Nat.Factorial.Basic import Mathlib.Algebra.Order.BigOperators.Ring.Finset #align_import data.nat.factorial.big_operators from "leanprover-community/mathlib"@"1126441d6bccf98c81214a0780c73d499f6721fe" open Finset Nat namespace Nat lemma monotone_factorial : Monotone factorial := fun _ _ => factorial_le #align nat.monotone_factorial Nat.monotone_factorial variable {α : Type*} (s : Finset α) (f : α → ℕ)
Mathlib/Data/Nat/Factorial/BigOperators.lean
31
31
theorem prod_factorial_pos : 0 < ∏ i ∈ s, (f i)! := by
positivity
679
import Mathlib.Data.Nat.Factorial.Basic import Mathlib.Algebra.Order.BigOperators.Ring.Finset #align_import data.nat.factorial.big_operators from "leanprover-community/mathlib"@"1126441d6bccf98c81214a0780c73d499f6721fe" open Finset Nat namespace Nat lemma monotone_factorial : Monotone factorial := fun _ _ => factorial_le #align nat.monotone_factorial Nat.monotone_factorial variable {α : Type*} (s : Finset α) (f : α → ℕ) theorem prod_factorial_pos : 0 < ∏ i ∈ s, (f i)! := by positivity #align nat.prod_factorial_pos Nat.prod_factorial_pos
Mathlib/Data/Nat/Factorial/BigOperators.lean
34
38
theorem prod_factorial_dvd_factorial_sum : (∏ i ∈ s, (f i)!) ∣ (∑ i ∈ s, f i)! := by
induction' s using Finset.cons_induction_on with a s has ih · simp · rw [prod_cons, Finset.sum_cons] exact (mul_dvd_mul_left _ ih).trans (Nat.factorial_mul_factorial_dvd_factorial_add _ _)
679
import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Data.Nat.Factorial.BigOperators import Mathlib.Data.ZMod.Basic open Finset Nat namespace ZMod
Mathlib/Data/ZMod/Factorial.lean
31
42
theorem cast_descFactorial {n p : ℕ} (h : n ≤ p) : (descFactorial (p - 1) n : ZMod p) = (-1) ^ n * n ! := by
rw [descFactorial_eq_prod_range, ← prod_range_add_one_eq_factorial] simp only [cast_prod] nth_rw 2 [← card_range n] rw [pow_card_mul_prod] refine prod_congr rfl ?_ intro x hx rw [← tsub_add_eq_tsub_tsub_swap, Nat.cast_sub <| Nat.le_trans (Nat.add_one_le_iff.mpr (List.mem_range.mp hx)) h, CharP.cast_eq_zero, zero_sub, cast_succ, neg_add_rev, mul_add, neg_mul, one_mul, mul_one, add_comm]
680
import Mathlib.Data.Nat.Factorial.Basic import Mathlib.Order.Monotone.Basic #align_import data.nat.choose.basic from "leanprover-community/mathlib"@"2f3994e1b117b1e1da49bcfb67334f33460c3ce4" open Nat namespace Nat def choose : ℕ → ℕ → ℕ | _, 0 => 1 | 0, _ + 1 => 0 | n + 1, k + 1 => choose n k + choose n (k + 1) #align nat.choose Nat.choose @[simp]
Mathlib/Data/Nat/Choose/Basic.lean
54
54
theorem choose_zero_right (n : ℕ) : choose n 0 = 1 := by
cases n <;> rfl
681
import Mathlib.Data.Nat.Factorial.Basic import Mathlib.Order.Monotone.Basic #align_import data.nat.choose.basic from "leanprover-community/mathlib"@"2f3994e1b117b1e1da49bcfb67334f33460c3ce4" open Nat namespace Nat def choose : ℕ → ℕ → ℕ | _, 0 => 1 | 0, _ + 1 => 0 | n + 1, k + 1 => choose n k + choose n (k + 1) #align nat.choose Nat.choose @[simp] theorem choose_zero_right (n : ℕ) : choose n 0 = 1 := by cases n <;> rfl #align nat.choose_zero_right Nat.choose_zero_right @[simp] theorem choose_zero_succ (k : ℕ) : choose 0 (succ k) = 0 := rfl #align nat.choose_zero_succ Nat.choose_zero_succ theorem choose_succ_succ (n k : ℕ) : choose (succ n) (succ k) = choose n k + choose n (succ k) := rfl #align nat.choose_succ_succ Nat.choose_succ_succ theorem choose_succ_succ' (n k : ℕ) : choose (n + 1) (k + 1) = choose n k + choose n (k + 1) := rfl theorem choose_eq_zero_of_lt : ∀ {n k}, n < k → choose n k = 0 | _, 0, hk => absurd hk (Nat.not_lt_zero _) | 0, k + 1, _ => choose_zero_succ _ | n + 1, k + 1, hk => by have hnk : n < k := lt_of_succ_lt_succ hk have hnk1 : n < k + 1 := lt_of_succ_lt hk rw [choose_succ_succ, choose_eq_zero_of_lt hnk, choose_eq_zero_of_lt hnk1] #align nat.choose_eq_zero_of_lt Nat.choose_eq_zero_of_lt @[simp]
Mathlib/Data/Nat/Choose/Basic.lean
79
80
theorem choose_self (n : ℕ) : choose n n = 1 := by
induction n <;> simp [*, choose, choose_eq_zero_of_lt (lt_succ_self _)]
681
import Mathlib.Data.Nat.Factorial.Basic import Mathlib.Order.Monotone.Basic #align_import data.nat.choose.basic from "leanprover-community/mathlib"@"2f3994e1b117b1e1da49bcfb67334f33460c3ce4" open Nat namespace Nat def choose : ℕ → ℕ → ℕ | _, 0 => 1 | 0, _ + 1 => 0 | n + 1, k + 1 => choose n k + choose n (k + 1) #align nat.choose Nat.choose @[simp] theorem choose_zero_right (n : ℕ) : choose n 0 = 1 := by cases n <;> rfl #align nat.choose_zero_right Nat.choose_zero_right @[simp] theorem choose_zero_succ (k : ℕ) : choose 0 (succ k) = 0 := rfl #align nat.choose_zero_succ Nat.choose_zero_succ theorem choose_succ_succ (n k : ℕ) : choose (succ n) (succ k) = choose n k + choose n (succ k) := rfl #align nat.choose_succ_succ Nat.choose_succ_succ theorem choose_succ_succ' (n k : ℕ) : choose (n + 1) (k + 1) = choose n k + choose n (k + 1) := rfl theorem choose_eq_zero_of_lt : ∀ {n k}, n < k → choose n k = 0 | _, 0, hk => absurd hk (Nat.not_lt_zero _) | 0, k + 1, _ => choose_zero_succ _ | n + 1, k + 1, hk => by have hnk : n < k := lt_of_succ_lt_succ hk have hnk1 : n < k + 1 := lt_of_succ_lt hk rw [choose_succ_succ, choose_eq_zero_of_lt hnk, choose_eq_zero_of_lt hnk1] #align nat.choose_eq_zero_of_lt Nat.choose_eq_zero_of_lt @[simp] theorem choose_self (n : ℕ) : choose n n = 1 := by induction n <;> simp [*, choose, choose_eq_zero_of_lt (lt_succ_self _)] #align nat.choose_self Nat.choose_self @[simp] theorem choose_succ_self (n : ℕ) : choose n (succ n) = 0 := choose_eq_zero_of_lt (lt_succ_self _) #align nat.choose_succ_self Nat.choose_succ_self @[simp] lemma choose_one_right (n : ℕ) : choose n 1 = n := by induction n <;> simp [*, choose, Nat.add_comm] #align nat.choose_one_right Nat.choose_one_right -- The `n+1`-st triangle number is `n` more than the `n`-th triangle number
Mathlib/Data/Nat/Choose/Basic.lean
93
95
theorem triangle_succ (n : ℕ) : (n + 1) * (n + 1 - 1) / 2 = n * (n - 1) / 2 + n := by
rw [← add_mul_div_left, Nat.mul_comm 2 n, ← Nat.mul_add, Nat.add_sub_cancel, Nat.mul_comm] cases n <;> rfl; apply zero_lt_succ
681
import Mathlib.Data.Nat.Factorial.Basic import Mathlib.Order.Monotone.Basic #align_import data.nat.choose.basic from "leanprover-community/mathlib"@"2f3994e1b117b1e1da49bcfb67334f33460c3ce4" open Nat namespace Nat def choose : ℕ → ℕ → ℕ | _, 0 => 1 | 0, _ + 1 => 0 | n + 1, k + 1 => choose n k + choose n (k + 1) #align nat.choose Nat.choose @[simp] theorem choose_zero_right (n : ℕ) : choose n 0 = 1 := by cases n <;> rfl #align nat.choose_zero_right Nat.choose_zero_right @[simp] theorem choose_zero_succ (k : ℕ) : choose 0 (succ k) = 0 := rfl #align nat.choose_zero_succ Nat.choose_zero_succ theorem choose_succ_succ (n k : ℕ) : choose (succ n) (succ k) = choose n k + choose n (succ k) := rfl #align nat.choose_succ_succ Nat.choose_succ_succ theorem choose_succ_succ' (n k : ℕ) : choose (n + 1) (k + 1) = choose n k + choose n (k + 1) := rfl theorem choose_eq_zero_of_lt : ∀ {n k}, n < k → choose n k = 0 | _, 0, hk => absurd hk (Nat.not_lt_zero _) | 0, k + 1, _ => choose_zero_succ _ | n + 1, k + 1, hk => by have hnk : n < k := lt_of_succ_lt_succ hk have hnk1 : n < k + 1 := lt_of_succ_lt hk rw [choose_succ_succ, choose_eq_zero_of_lt hnk, choose_eq_zero_of_lt hnk1] #align nat.choose_eq_zero_of_lt Nat.choose_eq_zero_of_lt @[simp] theorem choose_self (n : ℕ) : choose n n = 1 := by induction n <;> simp [*, choose, choose_eq_zero_of_lt (lt_succ_self _)] #align nat.choose_self Nat.choose_self @[simp] theorem choose_succ_self (n : ℕ) : choose n (succ n) = 0 := choose_eq_zero_of_lt (lt_succ_self _) #align nat.choose_succ_self Nat.choose_succ_self @[simp] lemma choose_one_right (n : ℕ) : choose n 1 = n := by induction n <;> simp [*, choose, Nat.add_comm] #align nat.choose_one_right Nat.choose_one_right -- The `n+1`-st triangle number is `n` more than the `n`-th triangle number theorem triangle_succ (n : ℕ) : (n + 1) * (n + 1 - 1) / 2 = n * (n - 1) / 2 + n := by rw [← add_mul_div_left, Nat.mul_comm 2 n, ← Nat.mul_add, Nat.add_sub_cancel, Nat.mul_comm] cases n <;> rfl; apply zero_lt_succ #align nat.triangle_succ Nat.triangle_succ
Mathlib/Data/Nat/Choose/Basic.lean
99
103
theorem choose_two_right (n : ℕ) : choose n 2 = n * (n - 1) / 2 := by
induction' n with n ih · simp · rw [triangle_succ n, choose, ih] simp [Nat.add_comm]
681
import Mathlib.Data.Nat.Factorial.Basic import Mathlib.Order.Monotone.Basic #align_import data.nat.choose.basic from "leanprover-community/mathlib"@"2f3994e1b117b1e1da49bcfb67334f33460c3ce4" open Nat namespace Nat def choose : ℕ → ℕ → ℕ | _, 0 => 1 | 0, _ + 1 => 0 | n + 1, k + 1 => choose n k + choose n (k + 1) #align nat.choose Nat.choose @[simp] theorem choose_zero_right (n : ℕ) : choose n 0 = 1 := by cases n <;> rfl #align nat.choose_zero_right Nat.choose_zero_right @[simp] theorem choose_zero_succ (k : ℕ) : choose 0 (succ k) = 0 := rfl #align nat.choose_zero_succ Nat.choose_zero_succ theorem choose_succ_succ (n k : ℕ) : choose (succ n) (succ k) = choose n k + choose n (succ k) := rfl #align nat.choose_succ_succ Nat.choose_succ_succ theorem choose_succ_succ' (n k : ℕ) : choose (n + 1) (k + 1) = choose n k + choose n (k + 1) := rfl theorem choose_eq_zero_of_lt : ∀ {n k}, n < k → choose n k = 0 | _, 0, hk => absurd hk (Nat.not_lt_zero _) | 0, k + 1, _ => choose_zero_succ _ | n + 1, k + 1, hk => by have hnk : n < k := lt_of_succ_lt_succ hk have hnk1 : n < k + 1 := lt_of_succ_lt hk rw [choose_succ_succ, choose_eq_zero_of_lt hnk, choose_eq_zero_of_lt hnk1] #align nat.choose_eq_zero_of_lt Nat.choose_eq_zero_of_lt @[simp] theorem choose_self (n : ℕ) : choose n n = 1 := by induction n <;> simp [*, choose, choose_eq_zero_of_lt (lt_succ_self _)] #align nat.choose_self Nat.choose_self @[simp] theorem choose_succ_self (n : ℕ) : choose n (succ n) = 0 := choose_eq_zero_of_lt (lt_succ_self _) #align nat.choose_succ_self Nat.choose_succ_self @[simp] lemma choose_one_right (n : ℕ) : choose n 1 = n := by induction n <;> simp [*, choose, Nat.add_comm] #align nat.choose_one_right Nat.choose_one_right -- The `n+1`-st triangle number is `n` more than the `n`-th triangle number theorem triangle_succ (n : ℕ) : (n + 1) * (n + 1 - 1) / 2 = n * (n - 1) / 2 + n := by rw [← add_mul_div_left, Nat.mul_comm 2 n, ← Nat.mul_add, Nat.add_sub_cancel, Nat.mul_comm] cases n <;> rfl; apply zero_lt_succ #align nat.triangle_succ Nat.triangle_succ theorem choose_two_right (n : ℕ) : choose n 2 = n * (n - 1) / 2 := by induction' n with n ih · simp · rw [triangle_succ n, choose, ih] simp [Nat.add_comm] #align nat.choose_two_right Nat.choose_two_right theorem choose_pos : ∀ {n k}, k ≤ n → 0 < choose n k | 0, _, hk => by rw [Nat.eq_zero_of_le_zero hk]; decide | n + 1, 0, _ => by simp | n + 1, k + 1, hk => Nat.add_pos_left (choose_pos (le_of_succ_le_succ hk)) _ #align nat.choose_pos Nat.choose_pos theorem choose_eq_zero_iff {n k : ℕ} : n.choose k = 0 ↔ n < k := ⟨fun h => lt_of_not_ge (mt Nat.choose_pos h.symm.not_lt), Nat.choose_eq_zero_of_lt⟩ #align nat.choose_eq_zero_iff Nat.choose_eq_zero_iff theorem succ_mul_choose_eq : ∀ n k, succ n * choose n k = choose (succ n) (succ k) * succ k | 0, 0 => by decide | 0, k + 1 => by simp [choose] | n + 1, 0 => by simp [choose, mul_succ, succ_eq_add_one, Nat.add_comm] | n + 1, k + 1 => by rw [choose_succ_succ (succ n) (succ k), Nat.add_mul, ← succ_mul_choose_eq n, mul_succ, ← succ_mul_choose_eq n, Nat.add_right_comm, ← Nat.mul_add, ← choose_succ_succ, ← succ_mul] #align nat.succ_mul_choose_eq Nat.succ_mul_choose_eq
Mathlib/Data/Nat/Choose/Basic.lean
125
142
theorem choose_mul_factorial_mul_factorial : ∀ {n k}, k ≤ n → choose n k * k ! * (n - k)! = n ! | 0, _, hk => by simp [Nat.eq_zero_of_le_zero hk] | n + 1, 0, _ => by simp | n + 1, succ k, hk => by rcases lt_or_eq_of_le hk with hk₁ | hk₁ · have h : choose n k * k.succ ! * (n - k)! = (k + 1) * n ! := by
rw [← choose_mul_factorial_mul_factorial (le_of_succ_le_succ hk)] simp [factorial_succ, Nat.mul_comm, Nat.mul_left_comm, Nat.mul_assoc] have h₁ : (n - k)! = (n - k) * (n - k.succ)! := by rw [← succ_sub_succ, succ_sub (le_of_lt_succ hk₁), factorial_succ] have h₂ : choose n (succ k) * k.succ ! * ((n - k) * (n - k.succ)!) = (n - k) * n ! := by rw [← choose_mul_factorial_mul_factorial (le_of_lt_succ hk₁)] simp [factorial_succ, Nat.mul_comm, Nat.mul_left_comm, Nat.mul_assoc] have h₃ : k * n ! ≤ n * n ! := Nat.mul_le_mul_right _ (le_of_succ_le_succ hk) rw [choose_succ_succ, Nat.add_mul, Nat.add_mul, succ_sub_succ, h, h₁, h₂, Nat.add_mul, Nat.mul_sub_right_distrib, factorial_succ, ← Nat.add_sub_assoc h₃, Nat.add_assoc, ← Nat.add_mul, Nat.add_sub_cancel_left, Nat.add_comm] · rw [hk₁]; simp [hk₁, Nat.mul_comm, choose, Nat.sub_self]
681
import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.GCD.Basic import Mathlib.Tactic.Ring import Mathlib.Tactic.Linarith #align_import data.nat.choose.central from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977" namespace Nat def centralBinom (n : ℕ) := (2 * n).choose n #align nat.central_binom Nat.centralBinom theorem centralBinom_eq_two_mul_choose (n : ℕ) : centralBinom n = (2 * n).choose n := rfl #align nat.central_binom_eq_two_mul_choose Nat.centralBinom_eq_two_mul_choose theorem centralBinom_pos (n : ℕ) : 0 < centralBinom n := choose_pos (Nat.le_mul_of_pos_left _ zero_lt_two) #align nat.central_binom_pos Nat.centralBinom_pos theorem centralBinom_ne_zero (n : ℕ) : centralBinom n ≠ 0 := (centralBinom_pos n).ne' #align nat.central_binom_ne_zero Nat.centralBinom_ne_zero @[simp] theorem centralBinom_zero : centralBinom 0 = 1 := choose_zero_right _ #align nat.central_binom_zero Nat.centralBinom_zero
Mathlib/Data/Nat/Choose/Central.lean
57
60
theorem choose_le_centralBinom (r n : ℕ) : choose (2 * n) r ≤ centralBinom n := calc (2 * n).choose r ≤ (2 * n).choose (2 * n / 2) := choose_le_middle r (2 * n) _ = (2 * n).choose n := by
rw [Nat.mul_div_cancel_left n zero_lt_two]
682
import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.GCD.Basic import Mathlib.Tactic.Ring import Mathlib.Tactic.Linarith #align_import data.nat.choose.central from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977" namespace Nat def centralBinom (n : ℕ) := (2 * n).choose n #align nat.central_binom Nat.centralBinom theorem centralBinom_eq_two_mul_choose (n : ℕ) : centralBinom n = (2 * n).choose n := rfl #align nat.central_binom_eq_two_mul_choose Nat.centralBinom_eq_two_mul_choose theorem centralBinom_pos (n : ℕ) : 0 < centralBinom n := choose_pos (Nat.le_mul_of_pos_left _ zero_lt_two) #align nat.central_binom_pos Nat.centralBinom_pos theorem centralBinom_ne_zero (n : ℕ) : centralBinom n ≠ 0 := (centralBinom_pos n).ne' #align nat.central_binom_ne_zero Nat.centralBinom_ne_zero @[simp] theorem centralBinom_zero : centralBinom 0 = 1 := choose_zero_right _ #align nat.central_binom_zero Nat.centralBinom_zero theorem choose_le_centralBinom (r n : ℕ) : choose (2 * n) r ≤ centralBinom n := calc (2 * n).choose r ≤ (2 * n).choose (2 * n / 2) := choose_le_middle r (2 * n) _ = (2 * n).choose n := by rw [Nat.mul_div_cancel_left n zero_lt_two] #align nat.choose_le_central_binom Nat.choose_le_centralBinom theorem two_le_centralBinom (n : ℕ) (n_pos : 0 < n) : 2 ≤ centralBinom n := calc 2 ≤ 2 * n := Nat.le_mul_of_pos_right _ n_pos _ = (2 * n).choose 1 := (choose_one_right (2 * n)).symm _ ≤ centralBinom n := choose_le_centralBinom 1 n #align nat.two_le_central_binom Nat.two_le_centralBinom
Mathlib/Data/Nat/Choose/Central.lean
72
81
theorem succ_mul_centralBinom_succ (n : ℕ) : (n + 1) * centralBinom (n + 1) = 2 * (2 * n + 1) * centralBinom n := calc (n + 1) * (2 * (n + 1)).choose (n + 1) = (2 * n + 2).choose (n + 1) * (n + 1) := mul_comm _ _ _ = (2 * n + 1).choose n * (2 * n + 2) := by
rw [choose_succ_right_eq, choose_mul_succ_eq] _ = 2 * ((2 * n + 1).choose n * (n + 1)) := by ring _ = 2 * ((2 * n + 1).choose n * (2 * n + 1 - n)) := by rw [two_mul n, add_assoc, Nat.add_sub_cancel_left] _ = 2 * ((2 * n).choose n * (2 * n + 1)) := by rw [choose_mul_succ_eq] _ = 2 * (2 * n + 1) * (2 * n).choose n := by rw [mul_assoc, mul_comm (2 * n + 1)]
682
import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.GCD.Basic import Mathlib.Tactic.Ring import Mathlib.Tactic.Linarith #align_import data.nat.choose.central from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977" namespace Nat def centralBinom (n : ℕ) := (2 * n).choose n #align nat.central_binom Nat.centralBinom theorem centralBinom_eq_two_mul_choose (n : ℕ) : centralBinom n = (2 * n).choose n := rfl #align nat.central_binom_eq_two_mul_choose Nat.centralBinom_eq_two_mul_choose theorem centralBinom_pos (n : ℕ) : 0 < centralBinom n := choose_pos (Nat.le_mul_of_pos_left _ zero_lt_two) #align nat.central_binom_pos Nat.centralBinom_pos theorem centralBinom_ne_zero (n : ℕ) : centralBinom n ≠ 0 := (centralBinom_pos n).ne' #align nat.central_binom_ne_zero Nat.centralBinom_ne_zero @[simp] theorem centralBinom_zero : centralBinom 0 = 1 := choose_zero_right _ #align nat.central_binom_zero Nat.centralBinom_zero theorem choose_le_centralBinom (r n : ℕ) : choose (2 * n) r ≤ centralBinom n := calc (2 * n).choose r ≤ (2 * n).choose (2 * n / 2) := choose_le_middle r (2 * n) _ = (2 * n).choose n := by rw [Nat.mul_div_cancel_left n zero_lt_two] #align nat.choose_le_central_binom Nat.choose_le_centralBinom theorem two_le_centralBinom (n : ℕ) (n_pos : 0 < n) : 2 ≤ centralBinom n := calc 2 ≤ 2 * n := Nat.le_mul_of_pos_right _ n_pos _ = (2 * n).choose 1 := (choose_one_right (2 * n)).symm _ ≤ centralBinom n := choose_le_centralBinom 1 n #align nat.two_le_central_binom Nat.two_le_centralBinom theorem succ_mul_centralBinom_succ (n : ℕ) : (n + 1) * centralBinom (n + 1) = 2 * (2 * n + 1) * centralBinom n := calc (n + 1) * (2 * (n + 1)).choose (n + 1) = (2 * n + 2).choose (n + 1) * (n + 1) := mul_comm _ _ _ = (2 * n + 1).choose n * (2 * n + 2) := by rw [choose_succ_right_eq, choose_mul_succ_eq] _ = 2 * ((2 * n + 1).choose n * (n + 1)) := by ring _ = 2 * ((2 * n + 1).choose n * (2 * n + 1 - n)) := by rw [two_mul n, add_assoc, Nat.add_sub_cancel_left] _ = 2 * ((2 * n).choose n * (2 * n + 1)) := by rw [choose_mul_succ_eq] _ = 2 * (2 * n + 1) * (2 * n).choose n := by rw [mul_assoc, mul_comm (2 * n + 1)] #align nat.succ_mul_central_binom_succ Nat.succ_mul_centralBinom_succ
Mathlib/Data/Nat/Choose/Central.lean
88
98
theorem four_pow_lt_mul_centralBinom (n : ℕ) (n_big : 4 ≤ n) : 4 ^ n < n * centralBinom n := by
induction' n using Nat.strong_induction_on with n IH rcases lt_trichotomy n 4 with (hn | rfl | hn) · clear IH; exact False.elim ((not_lt.2 n_big) hn) · norm_num [centralBinom, choose] obtain ⟨n, rfl⟩ : ∃ m, n = m + 1 := Nat.exists_eq_succ_of_ne_zero (Nat.not_eq_zero_of_lt hn) calc 4 ^ (n + 1) < 4 * (n * centralBinom n) := lt_of_eq_of_lt pow_succ' <| (mul_lt_mul_left <| zero_lt_four' ℕ).mpr (IH n n.lt_succ_self (Nat.le_of_lt_succ hn)) _ ≤ 2 * (2 * n + 1) * centralBinom n := by rw [← mul_assoc]; linarith _ = (n + 1) * centralBinom (n + 1) := (succ_mul_centralBinom_succ n).symm
682
import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.GCD.Basic import Mathlib.Tactic.Ring import Mathlib.Tactic.Linarith #align_import data.nat.choose.central from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977" namespace Nat def centralBinom (n : ℕ) := (2 * n).choose n #align nat.central_binom Nat.centralBinom theorem centralBinom_eq_two_mul_choose (n : ℕ) : centralBinom n = (2 * n).choose n := rfl #align nat.central_binom_eq_two_mul_choose Nat.centralBinom_eq_two_mul_choose theorem centralBinom_pos (n : ℕ) : 0 < centralBinom n := choose_pos (Nat.le_mul_of_pos_left _ zero_lt_two) #align nat.central_binom_pos Nat.centralBinom_pos theorem centralBinom_ne_zero (n : ℕ) : centralBinom n ≠ 0 := (centralBinom_pos n).ne' #align nat.central_binom_ne_zero Nat.centralBinom_ne_zero @[simp] theorem centralBinom_zero : centralBinom 0 = 1 := choose_zero_right _ #align nat.central_binom_zero Nat.centralBinom_zero theorem choose_le_centralBinom (r n : ℕ) : choose (2 * n) r ≤ centralBinom n := calc (2 * n).choose r ≤ (2 * n).choose (2 * n / 2) := choose_le_middle r (2 * n) _ = (2 * n).choose n := by rw [Nat.mul_div_cancel_left n zero_lt_two] #align nat.choose_le_central_binom Nat.choose_le_centralBinom theorem two_le_centralBinom (n : ℕ) (n_pos : 0 < n) : 2 ≤ centralBinom n := calc 2 ≤ 2 * n := Nat.le_mul_of_pos_right _ n_pos _ = (2 * n).choose 1 := (choose_one_right (2 * n)).symm _ ≤ centralBinom n := choose_le_centralBinom 1 n #align nat.two_le_central_binom Nat.two_le_centralBinom theorem succ_mul_centralBinom_succ (n : ℕ) : (n + 1) * centralBinom (n + 1) = 2 * (2 * n + 1) * centralBinom n := calc (n + 1) * (2 * (n + 1)).choose (n + 1) = (2 * n + 2).choose (n + 1) * (n + 1) := mul_comm _ _ _ = (2 * n + 1).choose n * (2 * n + 2) := by rw [choose_succ_right_eq, choose_mul_succ_eq] _ = 2 * ((2 * n + 1).choose n * (n + 1)) := by ring _ = 2 * ((2 * n + 1).choose n * (2 * n + 1 - n)) := by rw [two_mul n, add_assoc, Nat.add_sub_cancel_left] _ = 2 * ((2 * n).choose n * (2 * n + 1)) := by rw [choose_mul_succ_eq] _ = 2 * (2 * n + 1) * (2 * n).choose n := by rw [mul_assoc, mul_comm (2 * n + 1)] #align nat.succ_mul_central_binom_succ Nat.succ_mul_centralBinom_succ theorem four_pow_lt_mul_centralBinom (n : ℕ) (n_big : 4 ≤ n) : 4 ^ n < n * centralBinom n := by induction' n using Nat.strong_induction_on with n IH rcases lt_trichotomy n 4 with (hn | rfl | hn) · clear IH; exact False.elim ((not_lt.2 n_big) hn) · norm_num [centralBinom, choose] obtain ⟨n, rfl⟩ : ∃ m, n = m + 1 := Nat.exists_eq_succ_of_ne_zero (Nat.not_eq_zero_of_lt hn) calc 4 ^ (n + 1) < 4 * (n * centralBinom n) := lt_of_eq_of_lt pow_succ' <| (mul_lt_mul_left <| zero_lt_four' ℕ).mpr (IH n n.lt_succ_self (Nat.le_of_lt_succ hn)) _ ≤ 2 * (2 * n + 1) * centralBinom n := by rw [← mul_assoc]; linarith _ = (n + 1) * centralBinom (n + 1) := (succ_mul_centralBinom_succ n).symm #align nat.four_pow_lt_mul_central_binom Nat.four_pow_lt_mul_centralBinom
Mathlib/Data/Nat/Choose/Central.lean
105
115
theorem four_pow_le_two_mul_self_mul_centralBinom : ∀ (n : ℕ) (_ : 0 < n), 4 ^ n ≤ 2 * n * centralBinom n | 0, pr => (Nat.not_lt_zero _ pr).elim | 1, _ => by norm_num [centralBinom, choose] | 2, _ => by norm_num [centralBinom, choose] | 3, _ => by norm_num [centralBinom, choose] | n + 4, _ => calc 4 ^ (n+4) ≤ (n+4) * centralBinom (n+4) := (four_pow_lt_mul_centralBinom _ le_add_self).le _ ≤ 2 * (n+4) * centralBinom (n+4) := by
rw [mul_assoc]; refine Nat.le_mul_of_pos_left _ zero_lt_two
682
import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.GCD.Basic import Mathlib.Tactic.Ring import Mathlib.Tactic.Linarith #align_import data.nat.choose.central from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977" namespace Nat def centralBinom (n : ℕ) := (2 * n).choose n #align nat.central_binom Nat.centralBinom theorem centralBinom_eq_two_mul_choose (n : ℕ) : centralBinom n = (2 * n).choose n := rfl #align nat.central_binom_eq_two_mul_choose Nat.centralBinom_eq_two_mul_choose theorem centralBinom_pos (n : ℕ) : 0 < centralBinom n := choose_pos (Nat.le_mul_of_pos_left _ zero_lt_two) #align nat.central_binom_pos Nat.centralBinom_pos theorem centralBinom_ne_zero (n : ℕ) : centralBinom n ≠ 0 := (centralBinom_pos n).ne' #align nat.central_binom_ne_zero Nat.centralBinom_ne_zero @[simp] theorem centralBinom_zero : centralBinom 0 = 1 := choose_zero_right _ #align nat.central_binom_zero Nat.centralBinom_zero theorem choose_le_centralBinom (r n : ℕ) : choose (2 * n) r ≤ centralBinom n := calc (2 * n).choose r ≤ (2 * n).choose (2 * n / 2) := choose_le_middle r (2 * n) _ = (2 * n).choose n := by rw [Nat.mul_div_cancel_left n zero_lt_two] #align nat.choose_le_central_binom Nat.choose_le_centralBinom theorem two_le_centralBinom (n : ℕ) (n_pos : 0 < n) : 2 ≤ centralBinom n := calc 2 ≤ 2 * n := Nat.le_mul_of_pos_right _ n_pos _ = (2 * n).choose 1 := (choose_one_right (2 * n)).symm _ ≤ centralBinom n := choose_le_centralBinom 1 n #align nat.two_le_central_binom Nat.two_le_centralBinom theorem succ_mul_centralBinom_succ (n : ℕ) : (n + 1) * centralBinom (n + 1) = 2 * (2 * n + 1) * centralBinom n := calc (n + 1) * (2 * (n + 1)).choose (n + 1) = (2 * n + 2).choose (n + 1) * (n + 1) := mul_comm _ _ _ = (2 * n + 1).choose n * (2 * n + 2) := by rw [choose_succ_right_eq, choose_mul_succ_eq] _ = 2 * ((2 * n + 1).choose n * (n + 1)) := by ring _ = 2 * ((2 * n + 1).choose n * (2 * n + 1 - n)) := by rw [two_mul n, add_assoc, Nat.add_sub_cancel_left] _ = 2 * ((2 * n).choose n * (2 * n + 1)) := by rw [choose_mul_succ_eq] _ = 2 * (2 * n + 1) * (2 * n).choose n := by rw [mul_assoc, mul_comm (2 * n + 1)] #align nat.succ_mul_central_binom_succ Nat.succ_mul_centralBinom_succ theorem four_pow_lt_mul_centralBinom (n : ℕ) (n_big : 4 ≤ n) : 4 ^ n < n * centralBinom n := by induction' n using Nat.strong_induction_on with n IH rcases lt_trichotomy n 4 with (hn | rfl | hn) · clear IH; exact False.elim ((not_lt.2 n_big) hn) · norm_num [centralBinom, choose] obtain ⟨n, rfl⟩ : ∃ m, n = m + 1 := Nat.exists_eq_succ_of_ne_zero (Nat.not_eq_zero_of_lt hn) calc 4 ^ (n + 1) < 4 * (n * centralBinom n) := lt_of_eq_of_lt pow_succ' <| (mul_lt_mul_left <| zero_lt_four' ℕ).mpr (IH n n.lt_succ_self (Nat.le_of_lt_succ hn)) _ ≤ 2 * (2 * n + 1) * centralBinom n := by rw [← mul_assoc]; linarith _ = (n + 1) * centralBinom (n + 1) := (succ_mul_centralBinom_succ n).symm #align nat.four_pow_lt_mul_central_binom Nat.four_pow_lt_mul_centralBinom theorem four_pow_le_two_mul_self_mul_centralBinom : ∀ (n : ℕ) (_ : 0 < n), 4 ^ n ≤ 2 * n * centralBinom n | 0, pr => (Nat.not_lt_zero _ pr).elim | 1, _ => by norm_num [centralBinom, choose] | 2, _ => by norm_num [centralBinom, choose] | 3, _ => by norm_num [centralBinom, choose] | n + 4, _ => calc 4 ^ (n+4) ≤ (n+4) * centralBinom (n+4) := (four_pow_lt_mul_centralBinom _ le_add_self).le _ ≤ 2 * (n+4) * centralBinom (n+4) := by rw [mul_assoc]; refine Nat.le_mul_of_pos_left _ zero_lt_two #align nat.four_pow_le_two_mul_self_mul_central_binom Nat.four_pow_le_two_mul_self_mul_centralBinom
Mathlib/Data/Nat/Choose/Central.lean
118
121
theorem two_dvd_centralBinom_succ (n : ℕ) : 2 ∣ centralBinom (n + 1) := by
use (n + 1 + n).choose n rw [centralBinom_eq_two_mul_choose, two_mul, ← add_assoc, choose_succ_succ' (n + 1 + n) n, choose_symm_add, ← two_mul]
682
import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.GCD.Basic import Mathlib.Tactic.Ring import Mathlib.Tactic.Linarith #align_import data.nat.choose.central from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977" namespace Nat def centralBinom (n : ℕ) := (2 * n).choose n #align nat.central_binom Nat.centralBinom theorem centralBinom_eq_two_mul_choose (n : ℕ) : centralBinom n = (2 * n).choose n := rfl #align nat.central_binom_eq_two_mul_choose Nat.centralBinom_eq_two_mul_choose theorem centralBinom_pos (n : ℕ) : 0 < centralBinom n := choose_pos (Nat.le_mul_of_pos_left _ zero_lt_two) #align nat.central_binom_pos Nat.centralBinom_pos theorem centralBinom_ne_zero (n : ℕ) : centralBinom n ≠ 0 := (centralBinom_pos n).ne' #align nat.central_binom_ne_zero Nat.centralBinom_ne_zero @[simp] theorem centralBinom_zero : centralBinom 0 = 1 := choose_zero_right _ #align nat.central_binom_zero Nat.centralBinom_zero theorem choose_le_centralBinom (r n : ℕ) : choose (2 * n) r ≤ centralBinom n := calc (2 * n).choose r ≤ (2 * n).choose (2 * n / 2) := choose_le_middle r (2 * n) _ = (2 * n).choose n := by rw [Nat.mul_div_cancel_left n zero_lt_two] #align nat.choose_le_central_binom Nat.choose_le_centralBinom theorem two_le_centralBinom (n : ℕ) (n_pos : 0 < n) : 2 ≤ centralBinom n := calc 2 ≤ 2 * n := Nat.le_mul_of_pos_right _ n_pos _ = (2 * n).choose 1 := (choose_one_right (2 * n)).symm _ ≤ centralBinom n := choose_le_centralBinom 1 n #align nat.two_le_central_binom Nat.two_le_centralBinom theorem succ_mul_centralBinom_succ (n : ℕ) : (n + 1) * centralBinom (n + 1) = 2 * (2 * n + 1) * centralBinom n := calc (n + 1) * (2 * (n + 1)).choose (n + 1) = (2 * n + 2).choose (n + 1) * (n + 1) := mul_comm _ _ _ = (2 * n + 1).choose n * (2 * n + 2) := by rw [choose_succ_right_eq, choose_mul_succ_eq] _ = 2 * ((2 * n + 1).choose n * (n + 1)) := by ring _ = 2 * ((2 * n + 1).choose n * (2 * n + 1 - n)) := by rw [two_mul n, add_assoc, Nat.add_sub_cancel_left] _ = 2 * ((2 * n).choose n * (2 * n + 1)) := by rw [choose_mul_succ_eq] _ = 2 * (2 * n + 1) * (2 * n).choose n := by rw [mul_assoc, mul_comm (2 * n + 1)] #align nat.succ_mul_central_binom_succ Nat.succ_mul_centralBinom_succ theorem four_pow_lt_mul_centralBinom (n : ℕ) (n_big : 4 ≤ n) : 4 ^ n < n * centralBinom n := by induction' n using Nat.strong_induction_on with n IH rcases lt_trichotomy n 4 with (hn | rfl | hn) · clear IH; exact False.elim ((not_lt.2 n_big) hn) · norm_num [centralBinom, choose] obtain ⟨n, rfl⟩ : ∃ m, n = m + 1 := Nat.exists_eq_succ_of_ne_zero (Nat.not_eq_zero_of_lt hn) calc 4 ^ (n + 1) < 4 * (n * centralBinom n) := lt_of_eq_of_lt pow_succ' <| (mul_lt_mul_left <| zero_lt_four' ℕ).mpr (IH n n.lt_succ_self (Nat.le_of_lt_succ hn)) _ ≤ 2 * (2 * n + 1) * centralBinom n := by rw [← mul_assoc]; linarith _ = (n + 1) * centralBinom (n + 1) := (succ_mul_centralBinom_succ n).symm #align nat.four_pow_lt_mul_central_binom Nat.four_pow_lt_mul_centralBinom theorem four_pow_le_two_mul_self_mul_centralBinom : ∀ (n : ℕ) (_ : 0 < n), 4 ^ n ≤ 2 * n * centralBinom n | 0, pr => (Nat.not_lt_zero _ pr).elim | 1, _ => by norm_num [centralBinom, choose] | 2, _ => by norm_num [centralBinom, choose] | 3, _ => by norm_num [centralBinom, choose] | n + 4, _ => calc 4 ^ (n+4) ≤ (n+4) * centralBinom (n+4) := (four_pow_lt_mul_centralBinom _ le_add_self).le _ ≤ 2 * (n+4) * centralBinom (n+4) := by rw [mul_assoc]; refine Nat.le_mul_of_pos_left _ zero_lt_two #align nat.four_pow_le_two_mul_self_mul_central_binom Nat.four_pow_le_two_mul_self_mul_centralBinom theorem two_dvd_centralBinom_succ (n : ℕ) : 2 ∣ centralBinom (n + 1) := by use (n + 1 + n).choose n rw [centralBinom_eq_two_mul_choose, two_mul, ← add_assoc, choose_succ_succ' (n + 1 + n) n, choose_symm_add, ← two_mul] #align nat.two_dvd_central_binom_succ Nat.two_dvd_centralBinom_succ
Mathlib/Data/Nat/Choose/Central.lean
124
126
theorem two_dvd_centralBinom_of_one_le {n : ℕ} (h : 0 < n) : 2 ∣ centralBinom n := by
rw [← Nat.succ_pred_eq_of_pos h] exact two_dvd_centralBinom_succ n.pred
682
import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.GCD.Basic import Mathlib.Tactic.Ring import Mathlib.Tactic.Linarith #align_import data.nat.choose.central from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977" namespace Nat def centralBinom (n : ℕ) := (2 * n).choose n #align nat.central_binom Nat.centralBinom theorem centralBinom_eq_two_mul_choose (n : ℕ) : centralBinom n = (2 * n).choose n := rfl #align nat.central_binom_eq_two_mul_choose Nat.centralBinom_eq_two_mul_choose theorem centralBinom_pos (n : ℕ) : 0 < centralBinom n := choose_pos (Nat.le_mul_of_pos_left _ zero_lt_two) #align nat.central_binom_pos Nat.centralBinom_pos theorem centralBinom_ne_zero (n : ℕ) : centralBinom n ≠ 0 := (centralBinom_pos n).ne' #align nat.central_binom_ne_zero Nat.centralBinom_ne_zero @[simp] theorem centralBinom_zero : centralBinom 0 = 1 := choose_zero_right _ #align nat.central_binom_zero Nat.centralBinom_zero theorem choose_le_centralBinom (r n : ℕ) : choose (2 * n) r ≤ centralBinom n := calc (2 * n).choose r ≤ (2 * n).choose (2 * n / 2) := choose_le_middle r (2 * n) _ = (2 * n).choose n := by rw [Nat.mul_div_cancel_left n zero_lt_two] #align nat.choose_le_central_binom Nat.choose_le_centralBinom theorem two_le_centralBinom (n : ℕ) (n_pos : 0 < n) : 2 ≤ centralBinom n := calc 2 ≤ 2 * n := Nat.le_mul_of_pos_right _ n_pos _ = (2 * n).choose 1 := (choose_one_right (2 * n)).symm _ ≤ centralBinom n := choose_le_centralBinom 1 n #align nat.two_le_central_binom Nat.two_le_centralBinom theorem succ_mul_centralBinom_succ (n : ℕ) : (n + 1) * centralBinom (n + 1) = 2 * (2 * n + 1) * centralBinom n := calc (n + 1) * (2 * (n + 1)).choose (n + 1) = (2 * n + 2).choose (n + 1) * (n + 1) := mul_comm _ _ _ = (2 * n + 1).choose n * (2 * n + 2) := by rw [choose_succ_right_eq, choose_mul_succ_eq] _ = 2 * ((2 * n + 1).choose n * (n + 1)) := by ring _ = 2 * ((2 * n + 1).choose n * (2 * n + 1 - n)) := by rw [two_mul n, add_assoc, Nat.add_sub_cancel_left] _ = 2 * ((2 * n).choose n * (2 * n + 1)) := by rw [choose_mul_succ_eq] _ = 2 * (2 * n + 1) * (2 * n).choose n := by rw [mul_assoc, mul_comm (2 * n + 1)] #align nat.succ_mul_central_binom_succ Nat.succ_mul_centralBinom_succ theorem four_pow_lt_mul_centralBinom (n : ℕ) (n_big : 4 ≤ n) : 4 ^ n < n * centralBinom n := by induction' n using Nat.strong_induction_on with n IH rcases lt_trichotomy n 4 with (hn | rfl | hn) · clear IH; exact False.elim ((not_lt.2 n_big) hn) · norm_num [centralBinom, choose] obtain ⟨n, rfl⟩ : ∃ m, n = m + 1 := Nat.exists_eq_succ_of_ne_zero (Nat.not_eq_zero_of_lt hn) calc 4 ^ (n + 1) < 4 * (n * centralBinom n) := lt_of_eq_of_lt pow_succ' <| (mul_lt_mul_left <| zero_lt_four' ℕ).mpr (IH n n.lt_succ_self (Nat.le_of_lt_succ hn)) _ ≤ 2 * (2 * n + 1) * centralBinom n := by rw [← mul_assoc]; linarith _ = (n + 1) * centralBinom (n + 1) := (succ_mul_centralBinom_succ n).symm #align nat.four_pow_lt_mul_central_binom Nat.four_pow_lt_mul_centralBinom theorem four_pow_le_two_mul_self_mul_centralBinom : ∀ (n : ℕ) (_ : 0 < n), 4 ^ n ≤ 2 * n * centralBinom n | 0, pr => (Nat.not_lt_zero _ pr).elim | 1, _ => by norm_num [centralBinom, choose] | 2, _ => by norm_num [centralBinom, choose] | 3, _ => by norm_num [centralBinom, choose] | n + 4, _ => calc 4 ^ (n+4) ≤ (n+4) * centralBinom (n+4) := (four_pow_lt_mul_centralBinom _ le_add_self).le _ ≤ 2 * (n+4) * centralBinom (n+4) := by rw [mul_assoc]; refine Nat.le_mul_of_pos_left _ zero_lt_two #align nat.four_pow_le_two_mul_self_mul_central_binom Nat.four_pow_le_two_mul_self_mul_centralBinom theorem two_dvd_centralBinom_succ (n : ℕ) : 2 ∣ centralBinom (n + 1) := by use (n + 1 + n).choose n rw [centralBinom_eq_two_mul_choose, two_mul, ← add_assoc, choose_succ_succ' (n + 1 + n) n, choose_symm_add, ← two_mul] #align nat.two_dvd_central_binom_succ Nat.two_dvd_centralBinom_succ theorem two_dvd_centralBinom_of_one_le {n : ℕ} (h : 0 < n) : 2 ∣ centralBinom n := by rw [← Nat.succ_pred_eq_of_pos h] exact two_dvd_centralBinom_succ n.pred #align nat.two_dvd_central_binom_of_one_le Nat.two_dvd_centralBinom_of_one_le
Mathlib/Data/Nat/Choose/Central.lean
131
138
theorem succ_dvd_centralBinom (n : ℕ) : n + 1 ∣ n.centralBinom := by
have h_s : (n + 1).Coprime (2 * n + 1) := by rw [two_mul, add_assoc, coprime_add_self_right, coprime_self_add_left] exact coprime_one_left n apply h_s.dvd_of_dvd_mul_left apply Nat.dvd_of_mul_dvd_mul_left zero_lt_two rw [← mul_assoc, ← succ_mul_centralBinom_succ, mul_comm] exact mul_dvd_mul_left _ (two_dvd_centralBinom_succ n)
682
import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.Factorial.Cast #align_import data.nat.choose.cast from "leanprover-community/mathlib"@"bb168510ef455e9280a152e7f31673cabd3d7496" open Nat variable (K : Type*) [DivisionRing K] [CharZero K] namespace Nat
Mathlib/Data/Nat/Choose/Cast.lean
25
28
theorem cast_choose {a b : ℕ} (h : a ≤ b) : (b.choose a : K) = b ! / (a ! * (b - a)!) := by
have : ∀ {n : ℕ}, (n ! : K) ≠ 0 := Nat.cast_ne_zero.2 (factorial_ne_zero _) rw [eq_div_iff_mul_eq (mul_ne_zero this this)] rw_mod_cast [← mul_assoc, choose_mul_factorial_mul_factorial h]
683
import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.Factorial.Cast #align_import data.nat.choose.cast from "leanprover-community/mathlib"@"bb168510ef455e9280a152e7f31673cabd3d7496" open Nat variable (K : Type*) [DivisionRing K] [CharZero K] namespace Nat theorem cast_choose {a b : ℕ} (h : a ≤ b) : (b.choose a : K) = b ! / (a ! * (b - a)!) := by have : ∀ {n : ℕ}, (n ! : K) ≠ 0 := Nat.cast_ne_zero.2 (factorial_ne_zero _) rw [eq_div_iff_mul_eq (mul_ne_zero this this)] rw_mod_cast [← mul_assoc, choose_mul_factorial_mul_factorial h] #align nat.cast_choose Nat.cast_choose
Mathlib/Data/Nat/Choose/Cast.lean
31
32
theorem cast_add_choose {a b : ℕ} : ((a + b).choose a : K) = (a + b)! / (a ! * b !) := by
rw [cast_choose K (_root_.le_add_right le_rfl), add_tsub_cancel_left]
683
import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.Factorial.Cast #align_import data.nat.choose.cast from "leanprover-community/mathlib"@"bb168510ef455e9280a152e7f31673cabd3d7496" open Nat variable (K : Type*) [DivisionRing K] [CharZero K] namespace Nat theorem cast_choose {a b : ℕ} (h : a ≤ b) : (b.choose a : K) = b ! / (a ! * (b - a)!) := by have : ∀ {n : ℕ}, (n ! : K) ≠ 0 := Nat.cast_ne_zero.2 (factorial_ne_zero _) rw [eq_div_iff_mul_eq (mul_ne_zero this this)] rw_mod_cast [← mul_assoc, choose_mul_factorial_mul_factorial h] #align nat.cast_choose Nat.cast_choose theorem cast_add_choose {a b : ℕ} : ((a + b).choose a : K) = (a + b)! / (a ! * b !) := by rw [cast_choose K (_root_.le_add_right le_rfl), add_tsub_cancel_left] #align nat.cast_add_choose Nat.cast_add_choose
Mathlib/Data/Nat/Choose/Cast.lean
35
38
theorem cast_choose_eq_ascPochhammer_div (a b : ℕ) : (a.choose b : K) = (ascPochhammer K b).eval ↑(a - (b - 1)) / b ! := by
rw [eq_div_iff_mul_eq (cast_ne_zero.2 b.factorial_ne_zero : (b ! : K) ≠ 0), ← cast_mul, mul_comm, ← descFactorial_eq_factorial_mul_choose, ← cast_descFactorial]
683
import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.Factorial.Cast #align_import data.nat.choose.cast from "leanprover-community/mathlib"@"bb168510ef455e9280a152e7f31673cabd3d7496" open Nat variable (K : Type*) [DivisionRing K] [CharZero K] namespace Nat theorem cast_choose {a b : ℕ} (h : a ≤ b) : (b.choose a : K) = b ! / (a ! * (b - a)!) := by have : ∀ {n : ℕ}, (n ! : K) ≠ 0 := Nat.cast_ne_zero.2 (factorial_ne_zero _) rw [eq_div_iff_mul_eq (mul_ne_zero this this)] rw_mod_cast [← mul_assoc, choose_mul_factorial_mul_factorial h] #align nat.cast_choose Nat.cast_choose theorem cast_add_choose {a b : ℕ} : ((a + b).choose a : K) = (a + b)! / (a ! * b !) := by rw [cast_choose K (_root_.le_add_right le_rfl), add_tsub_cancel_left] #align nat.cast_add_choose Nat.cast_add_choose theorem cast_choose_eq_ascPochhammer_div (a b : ℕ) : (a.choose b : K) = (ascPochhammer K b).eval ↑(a - (b - 1)) / b ! := by rw [eq_div_iff_mul_eq (cast_ne_zero.2 b.factorial_ne_zero : (b ! : K) ≠ 0), ← cast_mul, mul_comm, ← descFactorial_eq_factorial_mul_choose, ← cast_descFactorial] #align nat.cast_choose_eq_pochhammer_div Nat.cast_choose_eq_ascPochhammer_div
Mathlib/Data/Nat/Choose/Cast.lean
41
43
theorem cast_choose_two (a : ℕ) : (a.choose 2 : K) = a * (a - 1) / 2 := by
rw [← cast_descFactorial_two, descFactorial_eq_factorial_mul_choose, factorial_two, mul_comm, cast_mul, cast_two, eq_div_iff_mul_eq (two_ne_zero : (2 : K) ≠ 0)]
683
import Mathlib.CategoryTheory.NatIso import Mathlib.Logic.Equiv.Defs #align_import category_theory.functor.fully_faithful from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" -- declare the `v`'s first; see `CategoryTheory.Category` for an explanation universe v₁ v₂ v₃ u₁ u₂ u₃ namespace CategoryTheory variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] namespace Functor class Full (F : C ⥤ D) : Prop where map_surjective {X Y : C} : Function.Surjective (F.map (X := X) (Y := Y)) #align category_theory.full CategoryTheory.Functor.Full class Faithful (F : C ⥤ D) : Prop where map_injective : ∀ {X Y : C}, Function.Injective (F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)) := by aesop_cat #align category_theory.faithful CategoryTheory.Functor.Faithful #align category_theory.faithful.map_injective CategoryTheory.Functor.Faithful.map_injective variable {X Y : C} theorem map_injective (F : C ⥤ D) [Faithful F] : Function.Injective <| (F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)) := Faithful.map_injective #align category_theory.functor.map_injective CategoryTheory.Functor.map_injective lemma map_injective_iff (F : C ⥤ D) [Faithful F] {X Y : C} (f g : X ⟶ Y) : F.map f = F.map g ↔ f = g := ⟨fun h => F.map_injective h, fun h => by rw [h]⟩ theorem mapIso_injective (F : C ⥤ D) [Faithful F] : Function.Injective <| (F.mapIso : (X ≅ Y) → (F.obj X ≅ F.obj Y)) := fun _ _ h => Iso.ext (map_injective F (congr_arg Iso.hom h : _)) #align category_theory.functor.map_iso_injective CategoryTheory.Functor.mapIso_injective theorem map_surjective (F : C ⥤ D) [Full F] : Function.Surjective (F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)) := Full.map_surjective #align category_theory.functor.map_surjective CategoryTheory.Functor.map_surjective noncomputable def preimage (F : C ⥤ D) [Full F] (f : F.obj X ⟶ F.obj Y) : X ⟶ Y := (F.map_surjective f).choose #align category_theory.functor.preimage CategoryTheory.Functor.preimage @[simp] theorem map_preimage (F : C ⥤ D) [Full F] {X Y : C} (f : F.obj X ⟶ F.obj Y) : F.map (preimage F f) = f := (F.map_surjective f).choose_spec #align category_theory.functor.image_preimage CategoryTheory.Functor.map_preimage variable {F : C ⥤ D} [Full F] [F.Faithful] {X Y Z : C} @[simp] theorem preimage_id : F.preimage (𝟙 (F.obj X)) = 𝟙 X := F.map_injective (by simp) #align category_theory.preimage_id CategoryTheory.Functor.preimage_id @[simp] theorem preimage_comp (f : F.obj X ⟶ F.obj Y) (g : F.obj Y ⟶ F.obj Z) : F.preimage (f ≫ g) = F.preimage f ≫ F.preimage g := F.map_injective (by simp) #align category_theory.preimage_comp CategoryTheory.Functor.preimage_comp @[simp] theorem preimage_map (f : X ⟶ Y) : F.preimage (F.map f) = f := F.map_injective (by simp) #align category_theory.preimage_map CategoryTheory.Functor.preimage_map variable (F) @[simps] noncomputable def preimageIso (f : F.obj X ≅ F.obj Y) : X ≅ Y where hom := F.preimage f.hom inv := F.preimage f.inv hom_inv_id := F.map_injective (by simp) inv_hom_id := F.map_injective (by simp) #align category_theory.functor.preimage_iso CategoryTheory.Functor.preimageIso #align category_theory.functor.preimage_iso_inv CategoryTheory.Functor.preimageIso_inv #align category_theory.functor.preimage_iso_hom CategoryTheory.Functor.preimageIso_hom @[simp]
Mathlib/CategoryTheory/Functor/FullyFaithful.lean
125
127
theorem preimageIso_mapIso (f : X ≅ Y) : F.preimageIso (F.mapIso f) = f := by
ext simp
684
import Mathlib.CategoryTheory.EpiMono import Mathlib.CategoryTheory.Functor.FullyFaithful import Mathlib.Tactic.PPWithUniv import Mathlib.Data.Set.Defs #align_import category_theory.types from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded" namespace CategoryTheory -- morphism levels before object levels. See note [CategoryTheory universes]. universe v v' w u u' @[to_additive existing CategoryTheory.types] instance types : LargeCategory (Type u) where Hom a b := a → b id a := id comp f g := g ∘ f #align category_theory.types CategoryTheory.types theorem types_hom {α β : Type u} : (α ⟶ β) = (α → β) := rfl #align category_theory.types_hom CategoryTheory.types_hom -- porting note (#10688): this lemma was not here in Lean 3. Lean 3 `ext` would solve this goal -- because of its "if all else fails, apply all `ext` lemmas" policy, -- which apparently we want to move away from. @[ext] theorem types_ext {α β : Type u} (f g : α ⟶ β) (h : ∀ a : α, f a = g a) : f = g := by funext x exact h x theorem types_id (X : Type u) : 𝟙 X = id := rfl #align category_theory.types_id CategoryTheory.types_id theorem types_comp {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) : f ≫ g = g ∘ f := rfl #align category_theory.types_comp CategoryTheory.types_comp @[simp] theorem types_id_apply (X : Type u) (x : X) : (𝟙 X : X → X) x = x := rfl #align category_theory.types_id_apply CategoryTheory.types_id_apply @[simp] theorem types_comp_apply {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : (f ≫ g) x = g (f x) := rfl #align category_theory.types_comp_apply CategoryTheory.types_comp_apply @[simp] theorem hom_inv_id_apply {X Y : Type u} (f : X ≅ Y) (x : X) : f.inv (f.hom x) = x := congr_fun f.hom_inv_id x #align category_theory.hom_inv_id_apply CategoryTheory.hom_inv_id_apply @[simp] theorem inv_hom_id_apply {X Y : Type u} (f : X ≅ Y) (y : Y) : f.hom (f.inv y) = y := congr_fun f.inv_hom_id y #align category_theory.inv_hom_id_apply CategoryTheory.inv_hom_id_apply -- Unfortunately without this wrapper we can't use `CategoryTheory` idioms, such as `IsIso f`. abbrev asHom {α β : Type u} (f : α → β) : α ⟶ β := f #align category_theory.as_hom CategoryTheory.asHom @[inherit_doc] scoped notation "↾" f:200 => CategoryTheory.asHom f section -- We verify the expected type checking behaviour of `asHom` variable (α β γ : Type u) (f : α → β) (g : β → γ) example : α → γ := ↾f ≫ ↾g example [IsIso (↾f)] : Mono (↾f) := by infer_instance example [IsIso (↾f)] : ↾f ≫ inv (↾f) = 𝟙 α := by simp end namespace FunctorToTypes variable {C : Type u} [Category.{v} C] (F G H : C ⥤ Type w) {X Y Z : C} variable (σ : F ⟶ G) (τ : G ⟶ H) @[simp]
Mathlib/CategoryTheory/Types.lean
152
153
theorem map_comp_apply (f : X ⟶ Y) (g : Y ⟶ Z) (a : F.obj X) : (F.map (f ≫ g)) a = (F.map g) ((F.map f) a) := by
simp [types_comp]
685
import Mathlib.CategoryTheory.EpiMono import Mathlib.CategoryTheory.Functor.FullyFaithful import Mathlib.Tactic.PPWithUniv import Mathlib.Data.Set.Defs #align_import category_theory.types from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded" namespace CategoryTheory -- morphism levels before object levels. See note [CategoryTheory universes]. universe v v' w u u' @[to_additive existing CategoryTheory.types] instance types : LargeCategory (Type u) where Hom a b := a → b id a := id comp f g := g ∘ f #align category_theory.types CategoryTheory.types theorem types_hom {α β : Type u} : (α ⟶ β) = (α → β) := rfl #align category_theory.types_hom CategoryTheory.types_hom -- porting note (#10688): this lemma was not here in Lean 3. Lean 3 `ext` would solve this goal -- because of its "if all else fails, apply all `ext` lemmas" policy, -- which apparently we want to move away from. @[ext] theorem types_ext {α β : Type u} (f g : α ⟶ β) (h : ∀ a : α, f a = g a) : f = g := by funext x exact h x theorem types_id (X : Type u) : 𝟙 X = id := rfl #align category_theory.types_id CategoryTheory.types_id theorem types_comp {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) : f ≫ g = g ∘ f := rfl #align category_theory.types_comp CategoryTheory.types_comp @[simp] theorem types_id_apply (X : Type u) (x : X) : (𝟙 X : X → X) x = x := rfl #align category_theory.types_id_apply CategoryTheory.types_id_apply @[simp] theorem types_comp_apply {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : (f ≫ g) x = g (f x) := rfl #align category_theory.types_comp_apply CategoryTheory.types_comp_apply @[simp] theorem hom_inv_id_apply {X Y : Type u} (f : X ≅ Y) (x : X) : f.inv (f.hom x) = x := congr_fun f.hom_inv_id x #align category_theory.hom_inv_id_apply CategoryTheory.hom_inv_id_apply @[simp] theorem inv_hom_id_apply {X Y : Type u} (f : X ≅ Y) (y : Y) : f.hom (f.inv y) = y := congr_fun f.inv_hom_id y #align category_theory.inv_hom_id_apply CategoryTheory.inv_hom_id_apply -- Unfortunately without this wrapper we can't use `CategoryTheory` idioms, such as `IsIso f`. abbrev asHom {α β : Type u} (f : α → β) : α ⟶ β := f #align category_theory.as_hom CategoryTheory.asHom @[inherit_doc] scoped notation "↾" f:200 => CategoryTheory.asHom f section -- We verify the expected type checking behaviour of `asHom` variable (α β γ : Type u) (f : α → β) (g : β → γ) example : α → γ := ↾f ≫ ↾g example [IsIso (↾f)] : Mono (↾f) := by infer_instance example [IsIso (↾f)] : ↾f ≫ inv (↾f) = 𝟙 α := by simp end namespace FunctorToTypes variable {C : Type u} [Category.{v} C] (F G H : C ⥤ Type w) {X Y Z : C} variable (σ : F ⟶ G) (τ : G ⟶ H) @[simp] theorem map_comp_apply (f : X ⟶ Y) (g : Y ⟶ Z) (a : F.obj X) : (F.map (f ≫ g)) a = (F.map g) ((F.map f) a) := by simp [types_comp] #align category_theory.functor_to_types.map_comp_apply CategoryTheory.FunctorToTypes.map_comp_apply @[simp]
Mathlib/CategoryTheory/Types.lean
157
157
theorem map_id_apply (a : F.obj X) : (F.map (𝟙 X)) a = a := by
simp [types_id]
685
import Mathlib.CategoryTheory.EpiMono import Mathlib.CategoryTheory.Functor.FullyFaithful import Mathlib.Tactic.PPWithUniv import Mathlib.Data.Set.Defs #align_import category_theory.types from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded" namespace CategoryTheory -- morphism levels before object levels. See note [CategoryTheory universes]. universe v v' w u u' @[to_additive existing CategoryTheory.types] instance types : LargeCategory (Type u) where Hom a b := a → b id a := id comp f g := g ∘ f #align category_theory.types CategoryTheory.types theorem types_hom {α β : Type u} : (α ⟶ β) = (α → β) := rfl #align category_theory.types_hom CategoryTheory.types_hom -- porting note (#10688): this lemma was not here in Lean 3. Lean 3 `ext` would solve this goal -- because of its "if all else fails, apply all `ext` lemmas" policy, -- which apparently we want to move away from. @[ext] theorem types_ext {α β : Type u} (f g : α ⟶ β) (h : ∀ a : α, f a = g a) : f = g := by funext x exact h x theorem types_id (X : Type u) : 𝟙 X = id := rfl #align category_theory.types_id CategoryTheory.types_id theorem types_comp {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) : f ≫ g = g ∘ f := rfl #align category_theory.types_comp CategoryTheory.types_comp @[simp] theorem types_id_apply (X : Type u) (x : X) : (𝟙 X : X → X) x = x := rfl #align category_theory.types_id_apply CategoryTheory.types_id_apply @[simp] theorem types_comp_apply {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : (f ≫ g) x = g (f x) := rfl #align category_theory.types_comp_apply CategoryTheory.types_comp_apply @[simp] theorem hom_inv_id_apply {X Y : Type u} (f : X ≅ Y) (x : X) : f.inv (f.hom x) = x := congr_fun f.hom_inv_id x #align category_theory.hom_inv_id_apply CategoryTheory.hom_inv_id_apply @[simp] theorem inv_hom_id_apply {X Y : Type u} (f : X ≅ Y) (y : Y) : f.hom (f.inv y) = y := congr_fun f.inv_hom_id y #align category_theory.inv_hom_id_apply CategoryTheory.inv_hom_id_apply -- Unfortunately without this wrapper we can't use `CategoryTheory` idioms, such as `IsIso f`. abbrev asHom {α β : Type u} (f : α → β) : α ⟶ β := f #align category_theory.as_hom CategoryTheory.asHom @[inherit_doc] scoped notation "↾" f:200 => CategoryTheory.asHom f section -- We verify the expected type checking behaviour of `asHom` variable (α β γ : Type u) (f : α → β) (g : β → γ) example : α → γ := ↾f ≫ ↾g example [IsIso (↾f)] : Mono (↾f) := by infer_instance example [IsIso (↾f)] : ↾f ≫ inv (↾f) = 𝟙 α := by simp end namespace FunctorToTypes variable {C : Type u} [Category.{v} C] (F G H : C ⥤ Type w) {X Y Z : C} variable (σ : F ⟶ G) (τ : G ⟶ H) @[simp] theorem map_comp_apply (f : X ⟶ Y) (g : Y ⟶ Z) (a : F.obj X) : (F.map (f ≫ g)) a = (F.map g) ((F.map f) a) := by simp [types_comp] #align category_theory.functor_to_types.map_comp_apply CategoryTheory.FunctorToTypes.map_comp_apply @[simp] theorem map_id_apply (a : F.obj X) : (F.map (𝟙 X)) a = a := by simp [types_id] #align category_theory.functor_to_types.map_id_apply CategoryTheory.FunctorToTypes.map_id_apply theorem naturality (f : X ⟶ Y) (x : F.obj X) : σ.app Y ((F.map f) x) = (G.map f) (σ.app X x) := congr_fun (σ.naturality f) x #align category_theory.functor_to_types.naturality CategoryTheory.FunctorToTypes.naturality @[simp] theorem comp (x : F.obj X) : (σ ≫ τ).app X x = τ.app X (σ.app X x) := rfl #align category_theory.functor_to_types.comp CategoryTheory.FunctorToTypes.comp @[simp]
Mathlib/CategoryTheory/Types.lean
170
172
theorem eqToHom_map_comp_apply (p : X = Y) (q : Y = Z) (x : F.obj X) : F.map (eqToHom q) (F.map (eqToHom p) x) = F.map (eqToHom <| p.trans q) x := by
aesop_cat
685
import Mathlib.CategoryTheory.EpiMono import Mathlib.CategoryTheory.Functor.FullyFaithful import Mathlib.Tactic.PPWithUniv import Mathlib.Data.Set.Defs #align_import category_theory.types from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded" namespace CategoryTheory -- morphism levels before object levels. See note [CategoryTheory universes]. universe v v' w u u' @[to_additive existing CategoryTheory.types] instance types : LargeCategory (Type u) where Hom a b := a → b id a := id comp f g := g ∘ f #align category_theory.types CategoryTheory.types theorem types_hom {α β : Type u} : (α ⟶ β) = (α → β) := rfl #align category_theory.types_hom CategoryTheory.types_hom -- porting note (#10688): this lemma was not here in Lean 3. Lean 3 `ext` would solve this goal -- because of its "if all else fails, apply all `ext` lemmas" policy, -- which apparently we want to move away from. @[ext] theorem types_ext {α β : Type u} (f g : α ⟶ β) (h : ∀ a : α, f a = g a) : f = g := by funext x exact h x theorem types_id (X : Type u) : 𝟙 X = id := rfl #align category_theory.types_id CategoryTheory.types_id theorem types_comp {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) : f ≫ g = g ∘ f := rfl #align category_theory.types_comp CategoryTheory.types_comp @[simp] theorem types_id_apply (X : Type u) (x : X) : (𝟙 X : X → X) x = x := rfl #align category_theory.types_id_apply CategoryTheory.types_id_apply @[simp] theorem types_comp_apply {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : (f ≫ g) x = g (f x) := rfl #align category_theory.types_comp_apply CategoryTheory.types_comp_apply @[simp] theorem hom_inv_id_apply {X Y : Type u} (f : X ≅ Y) (x : X) : f.inv (f.hom x) = x := congr_fun f.hom_inv_id x #align category_theory.hom_inv_id_apply CategoryTheory.hom_inv_id_apply @[simp] theorem inv_hom_id_apply {X Y : Type u} (f : X ≅ Y) (y : Y) : f.hom (f.inv y) = y := congr_fun f.inv_hom_id y #align category_theory.inv_hom_id_apply CategoryTheory.inv_hom_id_apply -- Unfortunately without this wrapper we can't use `CategoryTheory` idioms, such as `IsIso f`. abbrev asHom {α β : Type u} (f : α → β) : α ⟶ β := f #align category_theory.as_hom CategoryTheory.asHom @[inherit_doc] scoped notation "↾" f:200 => CategoryTheory.asHom f section -- We verify the expected type checking behaviour of `asHom` variable (α β γ : Type u) (f : α → β) (g : β → γ) example : α → γ := ↾f ≫ ↾g example [IsIso (↾f)] : Mono (↾f) := by infer_instance example [IsIso (↾f)] : ↾f ≫ inv (↾f) = 𝟙 α := by simp end def uliftTrivial (V : Type u) : ULift.{u} V ≅ V where hom a := a.1 inv a := .up a #align category_theory.ulift_trivial CategoryTheory.uliftTrivial @[pp_with_univ] def uliftFunctor : Type u ⥤ Type max u v where obj X := ULift.{v} X map {X} {Y} f := fun x : ULift.{v} X => ULift.up (f x.down) #align category_theory.ulift_functor CategoryTheory.uliftFunctor @[simp] theorem uliftFunctor_map {X Y : Type u} (f : X ⟶ Y) (x : ULift.{v} X) : uliftFunctor.map f x = ULift.up (f x.down) := rfl #align category_theory.ulift_functor_map CategoryTheory.uliftFunctor_map instance uliftFunctor_full : Functor.Full.{u} uliftFunctor where map_surjective f := ⟨fun x => (f (ULift.up x)).down, rfl⟩ #align category_theory.ulift_functor_full CategoryTheory.uliftFunctor_full instance uliftFunctor_faithful : uliftFunctor.Faithful where map_injective {_X} {_Y} f g p := funext fun x => congr_arg ULift.down (congr_fun p (ULift.up x) : ULift.up (f x) = ULift.up (g x)) #align category_theory.ulift_functor_faithful CategoryTheory.uliftFunctor_faithful def uliftFunctorTrivial : uliftFunctor.{u, u} ≅ 𝟭 _ := NatIso.ofComponents uliftTrivial #align category_theory.ulift_functor_trivial CategoryTheory.uliftFunctorTrivial -- TODO We should connect this to a general story about concrete categories -- whose forgetful functor is representable. def homOfElement {X : Type u} (x : X) : PUnit ⟶ X := fun _ => x #align category_theory.hom_of_element CategoryTheory.homOfElement theorem homOfElement_eq_iff {X : Type u} (x y : X) : homOfElement x = homOfElement y ↔ x = y := ⟨fun H => congr_fun H PUnit.unit, by aesop⟩ #align category_theory.hom_of_element_eq_iff CategoryTheory.homOfElement_eq_iff
Mathlib/CategoryTheory/Types.lean
256
261
theorem mono_iff_injective {X Y : Type u} (f : X ⟶ Y) : Mono f ↔ Function.Injective f := by
constructor · intro H x x' h rw [← homOfElement_eq_iff] at h ⊢ exact (cancel_mono f).mp h · exact fun H => ⟨fun g g' h => H.comp_left h⟩
685
import Mathlib.CategoryTheory.EpiMono import Mathlib.CategoryTheory.Functor.FullyFaithful import Mathlib.Tactic.PPWithUniv import Mathlib.Data.Set.Defs #align_import category_theory.types from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded" namespace CategoryTheory -- morphism levels before object levels. See note [CategoryTheory universes]. universe v v' w u u' @[to_additive existing CategoryTheory.types] instance types : LargeCategory (Type u) where Hom a b := a → b id a := id comp f g := g ∘ f #align category_theory.types CategoryTheory.types theorem types_hom {α β : Type u} : (α ⟶ β) = (α → β) := rfl #align category_theory.types_hom CategoryTheory.types_hom -- porting note (#10688): this lemma was not here in Lean 3. Lean 3 `ext` would solve this goal -- because of its "if all else fails, apply all `ext` lemmas" policy, -- which apparently we want to move away from. @[ext] theorem types_ext {α β : Type u} (f g : α ⟶ β) (h : ∀ a : α, f a = g a) : f = g := by funext x exact h x theorem types_id (X : Type u) : 𝟙 X = id := rfl #align category_theory.types_id CategoryTheory.types_id theorem types_comp {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) : f ≫ g = g ∘ f := rfl #align category_theory.types_comp CategoryTheory.types_comp @[simp] theorem types_id_apply (X : Type u) (x : X) : (𝟙 X : X → X) x = x := rfl #align category_theory.types_id_apply CategoryTheory.types_id_apply @[simp] theorem types_comp_apply {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : (f ≫ g) x = g (f x) := rfl #align category_theory.types_comp_apply CategoryTheory.types_comp_apply @[simp] theorem hom_inv_id_apply {X Y : Type u} (f : X ≅ Y) (x : X) : f.inv (f.hom x) = x := congr_fun f.hom_inv_id x #align category_theory.hom_inv_id_apply CategoryTheory.hom_inv_id_apply @[simp] theorem inv_hom_id_apply {X Y : Type u} (f : X ≅ Y) (y : Y) : f.hom (f.inv y) = y := congr_fun f.inv_hom_id y #align category_theory.inv_hom_id_apply CategoryTheory.inv_hom_id_apply -- Unfortunately without this wrapper we can't use `CategoryTheory` idioms, such as `IsIso f`. abbrev asHom {α β : Type u} (f : α → β) : α ⟶ β := f #align category_theory.as_hom CategoryTheory.asHom @[inherit_doc] scoped notation "↾" f:200 => CategoryTheory.asHom f section -- We verify the expected type checking behaviour of `asHom` variable (α β γ : Type u) (f : α → β) (g : β → γ) example : α → γ := ↾f ≫ ↾g example [IsIso (↾f)] : Mono (↾f) := by infer_instance example [IsIso (↾f)] : ↾f ≫ inv (↾f) = 𝟙 α := by simp end def uliftTrivial (V : Type u) : ULift.{u} V ≅ V where hom a := a.1 inv a := .up a #align category_theory.ulift_trivial CategoryTheory.uliftTrivial @[pp_with_univ] def uliftFunctor : Type u ⥤ Type max u v where obj X := ULift.{v} X map {X} {Y} f := fun x : ULift.{v} X => ULift.up (f x.down) #align category_theory.ulift_functor CategoryTheory.uliftFunctor @[simp] theorem uliftFunctor_map {X Y : Type u} (f : X ⟶ Y) (x : ULift.{v} X) : uliftFunctor.map f x = ULift.up (f x.down) := rfl #align category_theory.ulift_functor_map CategoryTheory.uliftFunctor_map instance uliftFunctor_full : Functor.Full.{u} uliftFunctor where map_surjective f := ⟨fun x => (f (ULift.up x)).down, rfl⟩ #align category_theory.ulift_functor_full CategoryTheory.uliftFunctor_full instance uliftFunctor_faithful : uliftFunctor.Faithful where map_injective {_X} {_Y} f g p := funext fun x => congr_arg ULift.down (congr_fun p (ULift.up x) : ULift.up (f x) = ULift.up (g x)) #align category_theory.ulift_functor_faithful CategoryTheory.uliftFunctor_faithful def uliftFunctorTrivial : uliftFunctor.{u, u} ≅ 𝟭 _ := NatIso.ofComponents uliftTrivial #align category_theory.ulift_functor_trivial CategoryTheory.uliftFunctorTrivial -- TODO We should connect this to a general story about concrete categories -- whose forgetful functor is representable. def homOfElement {X : Type u} (x : X) : PUnit ⟶ X := fun _ => x #align category_theory.hom_of_element CategoryTheory.homOfElement theorem homOfElement_eq_iff {X : Type u} (x y : X) : homOfElement x = homOfElement y ↔ x = y := ⟨fun H => congr_fun H PUnit.unit, by aesop⟩ #align category_theory.hom_of_element_eq_iff CategoryTheory.homOfElement_eq_iff theorem mono_iff_injective {X Y : Type u} (f : X ⟶ Y) : Mono f ↔ Function.Injective f := by constructor · intro H x x' h rw [← homOfElement_eq_iff] at h ⊢ exact (cancel_mono f).mp h · exact fun H => ⟨fun g g' h => H.comp_left h⟩ #align category_theory.mono_iff_injective CategoryTheory.mono_iff_injective theorem injective_of_mono {X Y : Type u} (f : X ⟶ Y) [hf : Mono f] : Function.Injective f := (mono_iff_injective f).1 hf #align category_theory.injective_of_mono CategoryTheory.injective_of_mono
Mathlib/CategoryTheory/Types.lean
272
280
theorem epi_iff_surjective {X Y : Type u} (f : X ⟶ Y) : Epi f ↔ Function.Surjective f := by
constructor · rintro ⟨H⟩ refine Function.surjective_of_right_cancellable_Prop fun g₁ g₂ hg => ?_ rw [← Equiv.ulift.symm.injective.comp_left.eq_iff] apply H change ULift.up ∘ g₁ ∘ f = ULift.up ∘ g₂ ∘ f rw [hg] · exact fun H => ⟨fun g g' h => H.injective_comp_right h⟩
685
import Mathlib.CategoryTheory.Types import Mathlib.CategoryTheory.Functor.EpiMono import Mathlib.CategoryTheory.Limits.Constructions.EpiMono #align_import category_theory.concrete_category.basic from "leanprover-community/mathlib"@"311ef8c4b4ae2804ea76b8a611bc5ea1d9c16872" universe w w' v v' v'' u u' u'' namespace CategoryTheory open CategoryTheory.Limits class ConcreteCategory (C : Type u) [Category.{v} C] where protected forget : C ⥤ Type w [forget_faithful : forget.Faithful] #align category_theory.concrete_category CategoryTheory.ConcreteCategory #align category_theory.concrete_category.forget CategoryTheory.ConcreteCategory.forget attribute [reducible] ConcreteCategory.forget attribute [instance] ConcreteCategory.forget_faithful abbrev forget (C : Type u) [Category.{v} C] [ConcreteCategory.{w} C] : C ⥤ Type w := ConcreteCategory.forget #align category_theory.forget CategoryTheory.forget -- this is reducible because we want `forget (Type u)` to unfold to `𝟭 _` @[instance] abbrev ConcreteCategory.types : ConcreteCategory.{u, u, u+1} (Type u) where forget := 𝟭 _ #align category_theory.concrete_category.types CategoryTheory.ConcreteCategory.types def ConcreteCategory.hasCoeToSort (C : Type u) [Category.{v} C] [ConcreteCategory.{w} C] : CoeSort C (Type w) where coe := fun X => (forget C).obj X #align category_theory.concrete_category.has_coe_to_sort CategoryTheory.ConcreteCategory.hasCoeToSort section attribute [local instance] ConcreteCategory.hasCoeToSort variable {C : Type u} [Category.{v} C] [ConcreteCategory.{w} C] -- Porting note: forget_obj_eq_coe has become a syntactic tautology. #noalign category_theory.forget_obj_eq_coe abbrev ConcreteCategory.instFunLike {X Y : C} : FunLike (X ⟶ Y) X Y where coe f := (forget C).map f coe_injective' _ _ h := (forget C).map_injective h attribute [local instance] ConcreteCategory.instFunLike @[ext low] -- Porting note: lowered priority
Mathlib/CategoryTheory/ConcreteCategory/Basic.lean
106
110
theorem ConcreteCategory.hom_ext {X Y : C} (f g : X ⟶ Y) (w : ∀ x : X, f x = g x) : f = g := by
apply (forget C).map_injective dsimp [forget] funext x exact w x
686
import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.Util.AddRelatedDecl import Batteries.Tactic.Lint set_option autoImplicit true open Lean Meta Elab Tactic open Mathlib.Tactic namespace Tactic.Elementwise open CategoryTheory section theorems theorem forall_congr_forget_Type (α : Type u) (p : α → Prop) : (∀ (x : (forget (Type u)).obj α), p x) ↔ ∀ (x : α), p x := Iff.rfl attribute [local instance] ConcreteCategory.instFunLike ConcreteCategory.hasCoeToSort theorem forget_hom_Type (α β : Type u) (f : α ⟶ β) : DFunLike.coe f = f := rfl
Mathlib/Tactic/CategoryTheory/Elementwise.lean
52
53
theorem hom_elementwise [Category C] [ConcreteCategory C] {X Y : C} {f g : X ⟶ Y} (h : f = g) (x : X) : f x = g x := by
rw [h]
687
import Mathlib.CategoryTheory.Limits.ColimitLimit import Mathlib.CategoryTheory.Limits.Preserves.FunctorCategory import Mathlib.CategoryTheory.Limits.Preserves.Finite import Mathlib.CategoryTheory.Limits.Shapes.FiniteLimits import Mathlib.CategoryTheory.Limits.TypesFiltered import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.CategoryTheory.Products.Bifunctor import Mathlib.Data.Countable.Small #align_import category_theory.limits.filtered_colimit_commutes_finite_limit from "leanprover-community/mathlib"@"3f409bd9df181d26dd223170da7b6830ece18442" -- Various pieces of algebra that have previously been spuriously imported here: assert_not_exists map_ne_zero assert_not_exists Field -- TODO: We should morally be able to strengthen this to `assert_not_exists GroupWithZero`, but -- finiteness currently relies on more algebra than it needs. universe w v₁ v₂ v u₁ u₂ u open CategoryTheory CategoryTheory.Category CategoryTheory.Limits.Types CategoryTheory.Limits.Types.FilteredColimit namespace CategoryTheory.Limits section variable {J : Type u₁} {K : Type u₂} [Category.{v₁} J] [Category.{v₂} K] [Small.{v} K] @[ext] lemma comp_lim_obj_ext {j : J} {G : J ⥤ K ⥤ Type v} (x y : (G ⋙ lim).obj j) (w : ∀ (k : K), limit.π (G.obj j) k x = limit.π (G.obj j) k y) : x = y := limit_ext _ x y w variable (F : J × K ⥤ Type v) open CategoryTheory.Prod variable [IsFiltered K] section variable [Finite J]
Mathlib/CategoryTheory/Limits/FilteredColimitCommutesFiniteLimit.lean
72
142
theorem colimitLimitToLimitColimit_injective : Function.Injective (colimitLimitToLimitColimit F) := by
classical cases nonempty_fintype J -- Suppose we have two terms `x y` in the colimit (over `K`) of the limits (over `J`), -- and that these have the same image under `colimitLimitToLimitColimit F`. intro x y h -- These elements of the colimit have representatives somewhere: obtain ⟨kx, x, rfl⟩ := jointly_surjective' x obtain ⟨ky, y, rfl⟩ := jointly_surjective' y dsimp at x y -- Since the images of `x` and `y` are equal in a limit, they are equal componentwise -- (indexed by `j : J`), replace h := fun j => congr_arg (limit.π (curry.obj F ⋙ colim) j) h -- and they are equations in a filtered colimit, -- so for each `j` we have some place `k j` to the right of both `kx` and `ky` simp? [colimit_eq_iff] at h says simp only [Functor.comp_obj, colim_obj, ι_colimitLimitToLimitColimit_π_apply, colimit_eq_iff, curry_obj_obj_obj, curry_obj_obj_map] at h let k j := (h j).choose let f : ∀ j, kx ⟶ k j := fun j => (h j).choose_spec.choose let g : ∀ j, ky ⟶ k j := fun j => (h j).choose_spec.choose_spec.choose -- where the images of the components of the representatives become equal: have w : ∀ j, F.map ((𝟙 j, f j) : (j, kx) ⟶ (j, k j)) (limit.π ((curry.obj (swap K J ⋙ F)).obj kx) j x) = F.map ((𝟙 j, g j) : (j, ky) ⟶ (j, k j)) (limit.π ((curry.obj (swap K J ⋙ F)).obj ky) j y) := fun j => (h j).choose_spec.choose_spec.choose_spec -- We now use that `K` is filtered, picking some point to the right of all these -- morphisms `f j` and `g j`. let O : Finset K := Finset.univ.image k ∪ {kx, ky} have kxO : kx ∈ O := Finset.mem_union.mpr (Or.inr (by simp)) have kyO : ky ∈ O := Finset.mem_union.mpr (Or.inr (by simp)) have kjO : ∀ j, k j ∈ O := fun j => Finset.mem_union.mpr (Or.inl (by simp)) let H : Finset (Σ' (X Y : K) (_ : X ∈ O) (_ : Y ∈ O), X ⟶ Y) := (Finset.univ.image fun j : J => ⟨kx, k j, kxO, Finset.mem_union.mpr (Or.inl (by simp)), f j⟩) ∪ Finset.univ.image fun j : J => ⟨ky, k j, kyO, Finset.mem_union.mpr (Or.inl (by simp)), g j⟩ obtain ⟨S, T, W⟩ := IsFiltered.sup_exists O H have fH : ∀ j, (⟨kx, k j, kxO, kjO j, f j⟩ : Σ' (X Y : K) (_ : X ∈ O) (_ : Y ∈ O), X ⟶ Y) ∈ H := fun j => Finset.mem_union.mpr (Or.inl (by simp only [true_and_iff, Finset.mem_univ, eq_self_iff_true, exists_prop_of_true, Finset.mem_image, heq_iff_eq] refine ⟨j, ?_⟩ simp only [heq_iff_eq] )) have gH : ∀ j, (⟨ky, k j, kyO, kjO j, g j⟩ : Σ' (X Y : K) (_ : X ∈ O) (_ : Y ∈ O), X ⟶ Y) ∈ H := fun j => Finset.mem_union.mpr (Or.inr (by simp only [true_and_iff, Finset.mem_univ, eq_self_iff_true, exists_prop_of_true, Finset.mem_image, heq_iff_eq] refine ⟨j, ?_⟩ simp only [heq_iff_eq])) -- Our goal is now an equation between equivalence classes of representatives of a colimit, -- and so it suffices to show those representative become equal somewhere, in particular at `S`. apply colimit_sound' (T kxO) (T kyO) -- We can check if two elements of a limit (in `Type`) -- are equal by comparing them componentwise. ext j -- Now it's just a calculation using `W` and `w`. simp only [Functor.comp_map, Limit.map_π_apply, curry_obj_map_app, swap_map] rw [← W _ _ (fH j), ← W _ _ (gH j)] -- Porting note(#10745): had to add `Limit.map_π_apply` -- (which was un-tagged simp since "simp can prove it") simp [Limit.map_π_apply, w]
688
import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.CategoryTheory.Functor.ReflectsIso #align_import category_theory.concrete_category.reflects_isomorphisms from "leanprover-community/mathlib"@"73dd4b5411ec8fafb18a9d77c9c826907730af80" universe u namespace CategoryTheory instance : (forget (Type u)).ReflectsIsomorphisms where reflects _ _ _ {i} := i variable (C : Type (u + 1)) [Category C] [ConcreteCategory.{u} C] variable (D : Type (u + 1)) [Category D] [ConcreteCategory.{u} D] -- This should not be an instance, as it causes a typeclass loop -- with `CategoryTheory.hasForgetToType`.
Mathlib/CategoryTheory/ConcreteCategory/ReflectsIso.lean
31
38
theorem reflectsIsomorphisms_forget₂ [HasForget₂ C D] [(forget C).ReflectsIsomorphisms] : (forget₂ C D).ReflectsIsomorphisms := { reflects := fun X Y f {i} => by haveI i' : IsIso ((forget D).map ((forget₂ C D).map f)) := Functor.map_isIso (forget D) _ haveI : IsIso ((forget C).map f) := by
have := @HasForget₂.forget_comp C D rwa [← this] apply isIso_of_reflects_iso f (forget C) }
689
import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.CategoryTheory.Limits.Preserves.Shapes.BinaryProducts import Mathlib.CategoryTheory.Limits.Shapes.RegularMono import Mathlib.CategoryTheory.Limits.Shapes.ZeroMorphisms #align_import category_theory.limits.mono_coprod from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" noncomputable section open CategoryTheory CategoryTheory.Category CategoryTheory.Limits universe u namespace CategoryTheory namespace Limits variable (C : Type*) [Category C] class MonoCoprod : Prop where binaryCofan_inl : ∀ ⦃A B : C⦄ (c : BinaryCofan A B) (_ : IsColimit c), Mono c.inl #align category_theory.limits.mono_coprod CategoryTheory.Limits.MonoCoprod variable {C} instance (priority := 100) monoCoprodOfHasZeroMorphisms [HasZeroMorphisms C] : MonoCoprod C := ⟨fun A B c hc => by haveI : IsSplitMono c.inl := IsSplitMono.mk' (SplitMono.mk (hc.desc (BinaryCofan.mk (𝟙 A) 0)) (IsColimit.fac _ _ _)) infer_instance⟩ #align category_theory.limits.mono_coprod_of_has_zero_morphisms CategoryTheory.Limits.monoCoprodOfHasZeroMorphisms namespace MonoCoprod
Mathlib/CategoryTheory/Limits/MonoCoprod.lean
63
69
theorem binaryCofan_inr {A B : C} [MonoCoprod C] (c : BinaryCofan A B) (hc : IsColimit c) : Mono c.inr := by
haveI hc' : IsColimit (BinaryCofan.mk c.inr c.inl) := BinaryCofan.IsColimit.mk _ (fun f₁ f₂ => hc.desc (BinaryCofan.mk f₂ f₁)) (by aesop_cat) (by aesop_cat) (fun f₁ f₂ m h₁ h₂ => BinaryCofan.IsColimit.hom_ext hc (by aesop_cat) (by aesop_cat)) exact binaryCofan_inl _ hc'
690
import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.CategoryTheory.Limits.Preserves.Shapes.BinaryProducts import Mathlib.CategoryTheory.Limits.Shapes.RegularMono import Mathlib.CategoryTheory.Limits.Shapes.ZeroMorphisms #align_import category_theory.limits.mono_coprod from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" noncomputable section open CategoryTheory CategoryTheory.Category CategoryTheory.Limits universe u namespace CategoryTheory namespace Limits variable (C : Type*) [Category C] class MonoCoprod : Prop where binaryCofan_inl : ∀ ⦃A B : C⦄ (c : BinaryCofan A B) (_ : IsColimit c), Mono c.inl #align category_theory.limits.mono_coprod CategoryTheory.Limits.MonoCoprod variable {C} instance (priority := 100) monoCoprodOfHasZeroMorphisms [HasZeroMorphisms C] : MonoCoprod C := ⟨fun A B c hc => by haveI : IsSplitMono c.inl := IsSplitMono.mk' (SplitMono.mk (hc.desc (BinaryCofan.mk (𝟙 A) 0)) (IsColimit.fac _ _ _)) infer_instance⟩ #align category_theory.limits.mono_coprod_of_has_zero_morphisms CategoryTheory.Limits.monoCoprodOfHasZeroMorphisms namespace MonoCoprod theorem binaryCofan_inr {A B : C} [MonoCoprod C] (c : BinaryCofan A B) (hc : IsColimit c) : Mono c.inr := by haveI hc' : IsColimit (BinaryCofan.mk c.inr c.inl) := BinaryCofan.IsColimit.mk _ (fun f₁ f₂ => hc.desc (BinaryCofan.mk f₂ f₁)) (by aesop_cat) (by aesop_cat) (fun f₁ f₂ m h₁ h₂ => BinaryCofan.IsColimit.hom_ext hc (by aesop_cat) (by aesop_cat)) exact binaryCofan_inl _ hc' #align category_theory.limits.mono_coprod.binary_cofan_inr CategoryTheory.Limits.MonoCoprod.binaryCofan_inr instance {A B : C} [MonoCoprod C] [HasBinaryCoproduct A B] : Mono (coprod.inl : A ⟶ A ⨿ B) := binaryCofan_inl _ (colimit.isColimit _) instance {A B : C} [MonoCoprod C] [HasBinaryCoproduct A B] : Mono (coprod.inr : B ⟶ A ⨿ B) := binaryCofan_inr _ (colimit.isColimit _)
Mathlib/CategoryTheory/Limits/MonoCoprod.lean
78
87
theorem mono_inl_iff {A B : C} {c₁ c₂ : BinaryCofan A B} (hc₁ : IsColimit c₁) (hc₂ : IsColimit c₂) : Mono c₁.inl ↔ Mono c₂.inl := by
suffices ∀ (c₁ c₂ : BinaryCofan A B) (_ : IsColimit c₁) (_ : IsColimit c₂) (_ : Mono c₁.inl), Mono c₂.inl by exact ⟨fun h₁ => this _ _ hc₁ hc₂ h₁, fun h₂ => this _ _ hc₂ hc₁ h₂⟩ intro c₁ c₂ hc₁ hc₂ intro simpa only [IsColimit.comp_coconePointUniqueUpToIso_hom] using mono_comp c₁.inl (hc₁.coconePointUniqueUpToIso hc₂).hom
690
import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.CategoryTheory.Limits.Preserves.Basic import Mathlib.CategoryTheory.Limits.TypesFiltered import Mathlib.CategoryTheory.Limits.Yoneda import Mathlib.Tactic.ApplyFun #align_import category_theory.limits.concrete_category from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395" universe t w v u r open CategoryTheory namespace CategoryTheory.Limits attribute [local instance] ConcreteCategory.instFunLike ConcreteCategory.hasCoeToSort section Limits lemma Concrete.small_sections_of_hasLimit {C : Type u} [Category.{v} C] [ConcreteCategory.{v} C] [(forget C).Corepresentable] {J : Type w} [Category.{t} J] (G : J ⥤ C) [HasLimit G] : Small.{v} (G ⋙ forget C).sections := by rw [← Types.hasLimit_iff_small_sections] infer_instance variable {C : Type u} [Category.{v} C] [ConcreteCategory.{max w v} C] {J : Type w} [Category.{t} J] (F : J ⥤ C) [PreservesLimit F (forget C)]
Mathlib/CategoryTheory/Limits/ConcreteCategory.lean
41
54
theorem Concrete.to_product_injective_of_isLimit {D : Cone F} (hD : IsLimit D) : Function.Injective fun (x : D.pt) (j : J) => D.π.app j x := by
let E := (forget C).mapCone D let hE : IsLimit E := isLimitOfPreserves _ hD let G := Types.limitCone.{w, v} (F ⋙ forget C) let hG := Types.limitConeIsLimit.{w, v} (F ⋙ forget C) let T : E.pt ≅ G.pt := hE.conePointUniqueUpToIso hG change Function.Injective (T.hom ≫ fun x j => G.π.app j x) have h : Function.Injective T.hom := by intro a b h suffices T.inv (T.hom a) = T.inv (T.hom b) by simpa rw [h] suffices Function.Injective fun (x : G.pt) j => G.π.app j x by exact this.comp h apply Subtype.ext
691
import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.CategoryTheory.Limits.Preserves.Basic import Mathlib.CategoryTheory.Limits.TypesFiltered import Mathlib.CategoryTheory.Limits.Yoneda import Mathlib.Tactic.ApplyFun #align_import category_theory.limits.concrete_category from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395" universe t w v u r open CategoryTheory namespace CategoryTheory.Limits attribute [local instance] ConcreteCategory.instFunLike ConcreteCategory.hasCoeToSort section Colimits section variable {C : Type u} [Category.{v} C] [ConcreteCategory.{t} C] {J : Type w} [Category.{r} J] (F : J ⥤ C) [PreservesColimit F (forget C)]
Mathlib/CategoryTheory/Limits/ConcreteCategory.lean
76
83
theorem Concrete.from_union_surjective_of_isColimit {D : Cocone F} (hD : IsColimit D) : let ff : (Σj : J, F.obj j) → D.pt := fun a => D.ι.app a.1 a.2 Function.Surjective ff := by
intro ff x let E : Cocone (F ⋙ forget C) := (forget C).mapCocone D let hE : IsColimit E := isColimitOfPreserves (forget C) hD obtain ⟨j, y, hy⟩ := Types.jointly_surjective_of_isColimit hE x exact ⟨⟨j, y⟩, hy⟩
691
import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.CategoryTheory.Limits.Preserves.Basic import Mathlib.CategoryTheory.Limits.TypesFiltered import Mathlib.CategoryTheory.Limits.Yoneda import Mathlib.Tactic.ApplyFun #align_import category_theory.limits.concrete_category from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395" universe t w v u r open CategoryTheory namespace CategoryTheory.Limits attribute [local instance] ConcreteCategory.instFunLike ConcreteCategory.hasCoeToSort section Colimits section variable {C : Type u} [Category.{v} C] [ConcreteCategory.{t} C] {J : Type w} [Category.{r} J] (F : J ⥤ C) [PreservesColimit F (forget C)] theorem Concrete.from_union_surjective_of_isColimit {D : Cocone F} (hD : IsColimit D) : let ff : (Σj : J, F.obj j) → D.pt := fun a => D.ι.app a.1 a.2 Function.Surjective ff := by intro ff x let E : Cocone (F ⋙ forget C) := (forget C).mapCocone D let hE : IsColimit E := isColimitOfPreserves (forget C) hD obtain ⟨j, y, hy⟩ := Types.jointly_surjective_of_isColimit hE x exact ⟨⟨j, y⟩, hy⟩ #align category_theory.limits.concrete.from_union_surjective_of_is_colimit CategoryTheory.Limits.Concrete.from_union_surjective_of_isColimit
Mathlib/CategoryTheory/Limits/ConcreteCategory.lean
86
89
theorem Concrete.isColimit_exists_rep {D : Cocone F} (hD : IsColimit D) (x : D.pt) : ∃ (j : J) (y : F.obj j), D.ι.app j y = x := by
obtain ⟨a, rfl⟩ := Concrete.from_union_surjective_of_isColimit F hD x exact ⟨a.1, a.2, rfl⟩
691
import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.CategoryTheory.Limits.Preserves.Basic import Mathlib.CategoryTheory.Limits.TypesFiltered import Mathlib.CategoryTheory.Limits.Yoneda import Mathlib.Tactic.ApplyFun #align_import category_theory.limits.concrete_category from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395" universe t w v u r open CategoryTheory namespace CategoryTheory.Limits attribute [local instance] ConcreteCategory.instFunLike ConcreteCategory.hasCoeToSort section Colimits section variable {C : Type u} [Category.{v} C] [ConcreteCategory.{t} C] {J : Type w} [Category.{r} J] (F : J ⥤ C) [PreservesColimit F (forget C)] theorem Concrete.from_union_surjective_of_isColimit {D : Cocone F} (hD : IsColimit D) : let ff : (Σj : J, F.obj j) → D.pt := fun a => D.ι.app a.1 a.2 Function.Surjective ff := by intro ff x let E : Cocone (F ⋙ forget C) := (forget C).mapCocone D let hE : IsColimit E := isColimitOfPreserves (forget C) hD obtain ⟨j, y, hy⟩ := Types.jointly_surjective_of_isColimit hE x exact ⟨⟨j, y⟩, hy⟩ #align category_theory.limits.concrete.from_union_surjective_of_is_colimit CategoryTheory.Limits.Concrete.from_union_surjective_of_isColimit theorem Concrete.isColimit_exists_rep {D : Cocone F} (hD : IsColimit D) (x : D.pt) : ∃ (j : J) (y : F.obj j), D.ι.app j y = x := by obtain ⟨a, rfl⟩ := Concrete.from_union_surjective_of_isColimit F hD x exact ⟨a.1, a.2, rfl⟩ #align category_theory.limits.concrete.is_colimit_exists_rep CategoryTheory.Limits.Concrete.isColimit_exists_rep theorem Concrete.colimit_exists_rep [HasColimit F] (x : ↑(colimit F)) : ∃ (j : J) (y : F.obj j), colimit.ι F j y = x := Concrete.isColimit_exists_rep F (colimit.isColimit _) x #align category_theory.limits.concrete.colimit_exists_rep CategoryTheory.Limits.Concrete.colimit_exists_rep
Mathlib/CategoryTheory/Limits/ConcreteCategory.lean
97
106
theorem Concrete.isColimit_rep_eq_of_exists {D : Cocone F} {i j : J} (x : F.obj i) (y : F.obj j) (h : ∃ (k : _) (f : i ⟶ k) (g : j ⟶ k), F.map f x = F.map g y) : D.ι.app i x = D.ι.app j y := by
let E := (forget C).mapCocone D obtain ⟨k, f, g, (hfg : (F ⋙ forget C).map f x = F.map g y)⟩ := h let h1 : (F ⋙ forget C).map f ≫ E.ι.app k = E.ι.app i := E.ι.naturality f let h2 : (F ⋙ forget C).map g ≫ E.ι.app k = E.ι.app j := E.ι.naturality g show E.ι.app i x = E.ι.app j y rw [← h1, types_comp_apply, hfg] exact congrFun h2 y
691
import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.CategoryTheory.Limits.Preserves.Basic import Mathlib.CategoryTheory.Limits.TypesFiltered import Mathlib.CategoryTheory.Limits.Yoneda import Mathlib.Tactic.ApplyFun #align_import category_theory.limits.concrete_category from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395" universe t w v u r open CategoryTheory namespace CategoryTheory.Limits attribute [local instance] ConcreteCategory.instFunLike ConcreteCategory.hasCoeToSort section Colimits section variable {C : Type u} [Category.{v} C] [ConcreteCategory.{t} C] {J : Type w} [Category.{r} J] (F : J ⥤ C) [PreservesColimit F (forget C)] theorem Concrete.from_union_surjective_of_isColimit {D : Cocone F} (hD : IsColimit D) : let ff : (Σj : J, F.obj j) → D.pt := fun a => D.ι.app a.1 a.2 Function.Surjective ff := by intro ff x let E : Cocone (F ⋙ forget C) := (forget C).mapCocone D let hE : IsColimit E := isColimitOfPreserves (forget C) hD obtain ⟨j, y, hy⟩ := Types.jointly_surjective_of_isColimit hE x exact ⟨⟨j, y⟩, hy⟩ #align category_theory.limits.concrete.from_union_surjective_of_is_colimit CategoryTheory.Limits.Concrete.from_union_surjective_of_isColimit theorem Concrete.isColimit_exists_rep {D : Cocone F} (hD : IsColimit D) (x : D.pt) : ∃ (j : J) (y : F.obj j), D.ι.app j y = x := by obtain ⟨a, rfl⟩ := Concrete.from_union_surjective_of_isColimit F hD x exact ⟨a.1, a.2, rfl⟩ #align category_theory.limits.concrete.is_colimit_exists_rep CategoryTheory.Limits.Concrete.isColimit_exists_rep theorem Concrete.colimit_exists_rep [HasColimit F] (x : ↑(colimit F)) : ∃ (j : J) (y : F.obj j), colimit.ι F j y = x := Concrete.isColimit_exists_rep F (colimit.isColimit _) x #align category_theory.limits.concrete.colimit_exists_rep CategoryTheory.Limits.Concrete.colimit_exists_rep theorem Concrete.isColimit_rep_eq_of_exists {D : Cocone F} {i j : J} (x : F.obj i) (y : F.obj j) (h : ∃ (k : _) (f : i ⟶ k) (g : j ⟶ k), F.map f x = F.map g y) : D.ι.app i x = D.ι.app j y := by let E := (forget C).mapCocone D obtain ⟨k, f, g, (hfg : (F ⋙ forget C).map f x = F.map g y)⟩ := h let h1 : (F ⋙ forget C).map f ≫ E.ι.app k = E.ι.app i := E.ι.naturality f let h2 : (F ⋙ forget C).map g ≫ E.ι.app k = E.ι.app j := E.ι.naturality g show E.ι.app i x = E.ι.app j y rw [← h1, types_comp_apply, hfg] exact congrFun h2 y #align category_theory.limits.concrete.is_colimit_rep_eq_of_exists CategoryTheory.Limits.Concrete.isColimit_rep_eq_of_exists theorem Concrete.colimit_rep_eq_of_exists [HasColimit F] {i j : J} (x : F.obj i) (y : F.obj j) (h : ∃ (k : _) (f : i ⟶ k) (g : j ⟶ k), F.map f x = F.map g y) : colimit.ι F i x = colimit.ι F j y := Concrete.isColimit_rep_eq_of_exists F x y h #align category_theory.limits.concrete.colimit_rep_eq_of_exists CategoryTheory.Limits.Concrete.colimit_rep_eq_of_exists end section FilteredColimits variable {C : Type u} [Category.{v} C] [ConcreteCategory.{max t w} C] {J : Type w} [Category.{r} J] (F : J ⥤ C) [PreservesColimit F (forget C)] [IsFiltered J]
Mathlib/CategoryTheory/Limits/ConcreteCategory.lean
122
127
theorem Concrete.isColimit_exists_of_rep_eq {D : Cocone F} {i j : J} (hD : IsColimit D) (x : F.obj i) (y : F.obj j) (h : D.ι.app _ x = D.ι.app _ y) : ∃ (k : _) (f : i ⟶ k) (g : j ⟶ k), F.map f x = F.map g y := by
let E := (forget C).mapCocone D let hE : IsColimit E := isColimitOfPreserves _ hD exact (Types.FilteredColimit.isColimit_eq_iff (F ⋙ forget C) hE).mp h
691
import Mathlib.CategoryTheory.Subobject.MonoOver import Mathlib.CategoryTheory.Skeletal import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.Tactic.ApplyFun import Mathlib.Tactic.CategoryTheory.Elementwise #align_import category_theory.subobject.basic from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe v₁ v₂ u₁ u₂ noncomputable section namespace CategoryTheory open CategoryTheory CategoryTheory.Category CategoryTheory.Limits variable {C : Type u₁} [Category.{v₁} C] {X Y Z : C} variable {D : Type u₂} [Category.{v₂} D] def Subobject (X : C) := ThinSkeleton (MonoOver X) #align category_theory.subobject CategoryTheory.Subobject instance (X : C) : PartialOrder (Subobject X) := by dsimp only [Subobject] infer_instance namespace Subobject -- Porting note: made it a def rather than an abbreviation -- because Lean would make it too transparent def mk {X A : C} (f : A ⟶ X) [Mono f] : Subobject X := (toThinSkeleton _).obj (MonoOver.mk' f) #align category_theory.subobject.mk CategoryTheory.Subobject.mk section attribute [local ext] CategoryTheory.Comma protected theorem ind {X : C} (p : Subobject X → Prop) (h : ∀ ⦃A : C⦄ (f : A ⟶ X) [Mono f], p (Subobject.mk f)) (P : Subobject X) : p P := by apply Quotient.inductionOn' intro a exact h a.arrow #align category_theory.subobject.ind CategoryTheory.Subobject.ind protected theorem ind₂ {X : C} (p : Subobject X → Subobject X → Prop) (h : ∀ ⦃A B : C⦄ (f : A ⟶ X) (g : B ⟶ X) [Mono f] [Mono g], p (Subobject.mk f) (Subobject.mk g)) (P Q : Subobject X) : p P Q := by apply Quotient.inductionOn₂' intro a b exact h a.arrow b.arrow #align category_theory.subobject.ind₂ CategoryTheory.Subobject.ind₂ end protected def lift {α : Sort*} {X : C} (F : ∀ ⦃A : C⦄ (f : A ⟶ X) [Mono f], α) (h : ∀ ⦃A B : C⦄ (f : A ⟶ X) (g : B ⟶ X) [Mono f] [Mono g] (i : A ≅ B), i.hom ≫ g = f → F f = F g) : Subobject X → α := fun P => Quotient.liftOn' P (fun m => F m.arrow) fun m n ⟨i⟩ => h m.arrow n.arrow ((MonoOver.forget X ⋙ Over.forget X).mapIso i) (Over.w i.hom) #align category_theory.subobject.lift CategoryTheory.Subobject.lift @[simp] protected theorem lift_mk {α : Sort*} {X : C} (F : ∀ ⦃A : C⦄ (f : A ⟶ X) [Mono f], α) {h A} (f : A ⟶ X) [Mono f] : Subobject.lift F h (Subobject.mk f) = F f := rfl #align category_theory.subobject.lift_mk CategoryTheory.Subobject.lift_mk noncomputable def equivMonoOver (X : C) : Subobject X ≌ MonoOver X := ThinSkeleton.equivalence _ #align category_theory.subobject.equiv_mono_over CategoryTheory.Subobject.equivMonoOver noncomputable def representative {X : C} : Subobject X ⥤ MonoOver X := (equivMonoOver X).functor #align category_theory.subobject.representative CategoryTheory.Subobject.representative noncomputable def representativeIso {X : C} (A : MonoOver X) : representative.obj ((toThinSkeleton _).obj A) ≅ A := (equivMonoOver X).counitIso.app A #align category_theory.subobject.representative_iso CategoryTheory.Subobject.representativeIso noncomputable def underlying {X : C} : Subobject X ⥤ C := representative ⋙ MonoOver.forget _ ⋙ Over.forget _ #align category_theory.subobject.underlying CategoryTheory.Subobject.underlying instance : CoeOut (Subobject X) C where coe Y := underlying.obj Y -- Porting note: removed as it has become a syntactic tautology -- @[simp] -- theorem underlying_as_coe {X : C} (P : Subobject X) : underlying.obj P = P := -- rfl -- #align category_theory.subobject.underlying_as_coe CategoryTheory.Subobject.underlying_as_coe noncomputable def underlyingIso {X Y : C} (f : X ⟶ Y) [Mono f] : (Subobject.mk f : C) ≅ X := (MonoOver.forget _ ⋙ Over.forget _).mapIso (representativeIso (MonoOver.mk' f)) #align category_theory.subobject.underlying_iso CategoryTheory.Subobject.underlyingIso noncomputable def arrow {X : C} (Y : Subobject X) : (Y : C) ⟶ X := (representative.obj Y).obj.hom #align category_theory.subobject.arrow CategoryTheory.Subobject.arrow instance arrow_mono {X : C} (Y : Subobject X) : Mono Y.arrow := (representative.obj Y).property #align category_theory.subobject.arrow_mono CategoryTheory.Subobject.arrow_mono @[simp]
Mathlib/CategoryTheory/Subobject/Basic.lean
210
213
theorem arrow_congr {A : C} (X Y : Subobject A) (h : X = Y) : eqToHom (congr_arg (fun X : Subobject A => (X : C)) h) ≫ Y.arrow = X.arrow := by
induction h simp
692
import Mathlib.CategoryTheory.Subobject.MonoOver import Mathlib.CategoryTheory.Skeletal import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.Tactic.ApplyFun import Mathlib.Tactic.CategoryTheory.Elementwise #align_import category_theory.subobject.basic from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe v₁ v₂ u₁ u₂ noncomputable section namespace CategoryTheory open CategoryTheory CategoryTheory.Category CategoryTheory.Limits variable {C : Type u₁} [Category.{v₁} C] {X Y Z : C} variable {D : Type u₂} [Category.{v₂} D] def Subobject (X : C) := ThinSkeleton (MonoOver X) #align category_theory.subobject CategoryTheory.Subobject instance (X : C) : PartialOrder (Subobject X) := by dsimp only [Subobject] infer_instance open CategoryTheory.Limits namespace Subobject def lower {Y : D} (F : MonoOver X ⥤ MonoOver Y) : Subobject X ⥤ Subobject Y := ThinSkeleton.map F #align category_theory.subobject.lower CategoryTheory.Subobject.lower theorem lower_iso (F₁ F₂ : MonoOver X ⥤ MonoOver Y) (h : F₁ ≅ F₂) : lower F₁ = lower F₂ := ThinSkeleton.map_iso_eq h #align category_theory.subobject.lower_iso CategoryTheory.Subobject.lower_iso def lower₂ (F : MonoOver X ⥤ MonoOver Y ⥤ MonoOver Z) : Subobject X ⥤ Subobject Y ⥤ Subobject Z := ThinSkeleton.map₂ F #align category_theory.subobject.lower₂ CategoryTheory.Subobject.lower₂ @[simp] theorem lower_comm (F : MonoOver Y ⥤ MonoOver X) : toThinSkeleton _ ⋙ lower F = F ⋙ toThinSkeleton _ := rfl #align category_theory.subobject.lower_comm CategoryTheory.Subobject.lower_comm def lowerAdjunction {A : C} {B : D} {L : MonoOver A ⥤ MonoOver B} {R : MonoOver B ⥤ MonoOver A} (h : L ⊣ R) : lower L ⊣ lower R := ThinSkeleton.lowerAdjunction _ _ h #align category_theory.subobject.lower_adjunction CategoryTheory.Subobject.lowerAdjunction @[simps] def lowerEquivalence {A : C} {B : D} (e : MonoOver A ≌ MonoOver B) : Subobject A ≌ Subobject B where functor := lower e.functor inverse := lower e.inverse unitIso := by apply eqToIso convert ThinSkeleton.map_iso_eq e.unitIso · exact ThinSkeleton.map_id_eq.symm · exact (ThinSkeleton.map_comp_eq _ _).symm counitIso := by apply eqToIso convert ThinSkeleton.map_iso_eq e.counitIso · exact (ThinSkeleton.map_comp_eq _ _).symm · exact ThinSkeleton.map_id_eq.symm #align category_theory.subobject.lower_equivalence CategoryTheory.Subobject.lowerEquivalence section Pullback variable [HasPullbacks C] def pullback (f : X ⟶ Y) : Subobject Y ⥤ Subobject X := lower (MonoOver.pullback f) #align category_theory.subobject.pullback CategoryTheory.Subobject.pullback
Mathlib/CategoryTheory/Subobject/Basic.lean
556
558
theorem pullback_id (x : Subobject X) : (pullback (𝟙 X)).obj x = x := by
induction' x using Quotient.inductionOn' with f exact Quotient.sound ⟨MonoOver.pullbackId.app f⟩
692
import Mathlib.CategoryTheory.Subobject.MonoOver import Mathlib.CategoryTheory.Skeletal import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.Tactic.ApplyFun import Mathlib.Tactic.CategoryTheory.Elementwise #align_import category_theory.subobject.basic from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe v₁ v₂ u₁ u₂ noncomputable section namespace CategoryTheory open CategoryTheory CategoryTheory.Category CategoryTheory.Limits variable {C : Type u₁} [Category.{v₁} C] {X Y Z : C} variable {D : Type u₂} [Category.{v₂} D] def Subobject (X : C) := ThinSkeleton (MonoOver X) #align category_theory.subobject CategoryTheory.Subobject instance (X : C) : PartialOrder (Subobject X) := by dsimp only [Subobject] infer_instance open CategoryTheory.Limits namespace Subobject def lower {Y : D} (F : MonoOver X ⥤ MonoOver Y) : Subobject X ⥤ Subobject Y := ThinSkeleton.map F #align category_theory.subobject.lower CategoryTheory.Subobject.lower theorem lower_iso (F₁ F₂ : MonoOver X ⥤ MonoOver Y) (h : F₁ ≅ F₂) : lower F₁ = lower F₂ := ThinSkeleton.map_iso_eq h #align category_theory.subobject.lower_iso CategoryTheory.Subobject.lower_iso def lower₂ (F : MonoOver X ⥤ MonoOver Y ⥤ MonoOver Z) : Subobject X ⥤ Subobject Y ⥤ Subobject Z := ThinSkeleton.map₂ F #align category_theory.subobject.lower₂ CategoryTheory.Subobject.lower₂ @[simp] theorem lower_comm (F : MonoOver Y ⥤ MonoOver X) : toThinSkeleton _ ⋙ lower F = F ⋙ toThinSkeleton _ := rfl #align category_theory.subobject.lower_comm CategoryTheory.Subobject.lower_comm def lowerAdjunction {A : C} {B : D} {L : MonoOver A ⥤ MonoOver B} {R : MonoOver B ⥤ MonoOver A} (h : L ⊣ R) : lower L ⊣ lower R := ThinSkeleton.lowerAdjunction _ _ h #align category_theory.subobject.lower_adjunction CategoryTheory.Subobject.lowerAdjunction @[simps] def lowerEquivalence {A : C} {B : D} (e : MonoOver A ≌ MonoOver B) : Subobject A ≌ Subobject B where functor := lower e.functor inverse := lower e.inverse unitIso := by apply eqToIso convert ThinSkeleton.map_iso_eq e.unitIso · exact ThinSkeleton.map_id_eq.symm · exact (ThinSkeleton.map_comp_eq _ _).symm counitIso := by apply eqToIso convert ThinSkeleton.map_iso_eq e.counitIso · exact (ThinSkeleton.map_comp_eq _ _).symm · exact ThinSkeleton.map_id_eq.symm #align category_theory.subobject.lower_equivalence CategoryTheory.Subobject.lowerEquivalence section Pullback variable [HasPullbacks C] def pullback (f : X ⟶ Y) : Subobject Y ⥤ Subobject X := lower (MonoOver.pullback f) #align category_theory.subobject.pullback CategoryTheory.Subobject.pullback theorem pullback_id (x : Subobject X) : (pullback (𝟙 X)).obj x = x := by induction' x using Quotient.inductionOn' with f exact Quotient.sound ⟨MonoOver.pullbackId.app f⟩ #align category_theory.subobject.pullback_id CategoryTheory.Subobject.pullback_id
Mathlib/CategoryTheory/Subobject/Basic.lean
561
564
theorem pullback_comp (f : X ⟶ Y) (g : Y ⟶ Z) (x : Subobject Z) : (pullback (f ≫ g)).obj x = (pullback f).obj ((pullback g).obj x) := by
induction' x using Quotient.inductionOn' with t exact Quotient.sound ⟨(MonoOver.pullbackComp _ _).app t⟩
692
import Mathlib.CategoryTheory.Subobject.MonoOver import Mathlib.CategoryTheory.Skeletal import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.Tactic.ApplyFun import Mathlib.Tactic.CategoryTheory.Elementwise #align_import category_theory.subobject.basic from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe v₁ v₂ u₁ u₂ noncomputable section namespace CategoryTheory open CategoryTheory CategoryTheory.Category CategoryTheory.Limits variable {C : Type u₁} [Category.{v₁} C] {X Y Z : C} variable {D : Type u₂} [Category.{v₂} D] def Subobject (X : C) := ThinSkeleton (MonoOver X) #align category_theory.subobject CategoryTheory.Subobject instance (X : C) : PartialOrder (Subobject X) := by dsimp only [Subobject] infer_instance open CategoryTheory.Limits namespace Subobject def lower {Y : D} (F : MonoOver X ⥤ MonoOver Y) : Subobject X ⥤ Subobject Y := ThinSkeleton.map F #align category_theory.subobject.lower CategoryTheory.Subobject.lower theorem lower_iso (F₁ F₂ : MonoOver X ⥤ MonoOver Y) (h : F₁ ≅ F₂) : lower F₁ = lower F₂ := ThinSkeleton.map_iso_eq h #align category_theory.subobject.lower_iso CategoryTheory.Subobject.lower_iso def lower₂ (F : MonoOver X ⥤ MonoOver Y ⥤ MonoOver Z) : Subobject X ⥤ Subobject Y ⥤ Subobject Z := ThinSkeleton.map₂ F #align category_theory.subobject.lower₂ CategoryTheory.Subobject.lower₂ @[simp] theorem lower_comm (F : MonoOver Y ⥤ MonoOver X) : toThinSkeleton _ ⋙ lower F = F ⋙ toThinSkeleton _ := rfl #align category_theory.subobject.lower_comm CategoryTheory.Subobject.lower_comm def lowerAdjunction {A : C} {B : D} {L : MonoOver A ⥤ MonoOver B} {R : MonoOver B ⥤ MonoOver A} (h : L ⊣ R) : lower L ⊣ lower R := ThinSkeleton.lowerAdjunction _ _ h #align category_theory.subobject.lower_adjunction CategoryTheory.Subobject.lowerAdjunction @[simps] def lowerEquivalence {A : C} {B : D} (e : MonoOver A ≌ MonoOver B) : Subobject A ≌ Subobject B where functor := lower e.functor inverse := lower e.inverse unitIso := by apply eqToIso convert ThinSkeleton.map_iso_eq e.unitIso · exact ThinSkeleton.map_id_eq.symm · exact (ThinSkeleton.map_comp_eq _ _).symm counitIso := by apply eqToIso convert ThinSkeleton.map_iso_eq e.counitIso · exact (ThinSkeleton.map_comp_eq _ _).symm · exact ThinSkeleton.map_id_eq.symm #align category_theory.subobject.lower_equivalence CategoryTheory.Subobject.lowerEquivalence section Map def map (f : X ⟶ Y) [Mono f] : Subobject X ⥤ Subobject Y := lower (MonoOver.map f) #align category_theory.subobject.map CategoryTheory.Subobject.map
Mathlib/CategoryTheory/Subobject/Basic.lean
580
582
theorem map_id (x : Subobject X) : (map (𝟙 X)).obj x = x := by
induction' x using Quotient.inductionOn' with f exact Quotient.sound ⟨(MonoOver.mapId _).app f⟩
692
import Mathlib.CategoryTheory.Subobject.MonoOver import Mathlib.CategoryTheory.Skeletal import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.Tactic.ApplyFun import Mathlib.Tactic.CategoryTheory.Elementwise #align_import category_theory.subobject.basic from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe v₁ v₂ u₁ u₂ noncomputable section namespace CategoryTheory open CategoryTheory CategoryTheory.Category CategoryTheory.Limits variable {C : Type u₁} [Category.{v₁} C] {X Y Z : C} variable {D : Type u₂} [Category.{v₂} D] def Subobject (X : C) := ThinSkeleton (MonoOver X) #align category_theory.subobject CategoryTheory.Subobject instance (X : C) : PartialOrder (Subobject X) := by dsimp only [Subobject] infer_instance open CategoryTheory.Limits namespace Subobject def lower {Y : D} (F : MonoOver X ⥤ MonoOver Y) : Subobject X ⥤ Subobject Y := ThinSkeleton.map F #align category_theory.subobject.lower CategoryTheory.Subobject.lower theorem lower_iso (F₁ F₂ : MonoOver X ⥤ MonoOver Y) (h : F₁ ≅ F₂) : lower F₁ = lower F₂ := ThinSkeleton.map_iso_eq h #align category_theory.subobject.lower_iso CategoryTheory.Subobject.lower_iso def lower₂ (F : MonoOver X ⥤ MonoOver Y ⥤ MonoOver Z) : Subobject X ⥤ Subobject Y ⥤ Subobject Z := ThinSkeleton.map₂ F #align category_theory.subobject.lower₂ CategoryTheory.Subobject.lower₂ @[simp] theorem lower_comm (F : MonoOver Y ⥤ MonoOver X) : toThinSkeleton _ ⋙ lower F = F ⋙ toThinSkeleton _ := rfl #align category_theory.subobject.lower_comm CategoryTheory.Subobject.lower_comm def lowerAdjunction {A : C} {B : D} {L : MonoOver A ⥤ MonoOver B} {R : MonoOver B ⥤ MonoOver A} (h : L ⊣ R) : lower L ⊣ lower R := ThinSkeleton.lowerAdjunction _ _ h #align category_theory.subobject.lower_adjunction CategoryTheory.Subobject.lowerAdjunction @[simps] def lowerEquivalence {A : C} {B : D} (e : MonoOver A ≌ MonoOver B) : Subobject A ≌ Subobject B where functor := lower e.functor inverse := lower e.inverse unitIso := by apply eqToIso convert ThinSkeleton.map_iso_eq e.unitIso · exact ThinSkeleton.map_id_eq.symm · exact (ThinSkeleton.map_comp_eq _ _).symm counitIso := by apply eqToIso convert ThinSkeleton.map_iso_eq e.counitIso · exact (ThinSkeleton.map_comp_eq _ _).symm · exact ThinSkeleton.map_id_eq.symm #align category_theory.subobject.lower_equivalence CategoryTheory.Subobject.lowerEquivalence section Map def map (f : X ⟶ Y) [Mono f] : Subobject X ⥤ Subobject Y := lower (MonoOver.map f) #align category_theory.subobject.map CategoryTheory.Subobject.map theorem map_id (x : Subobject X) : (map (𝟙 X)).obj x = x := by induction' x using Quotient.inductionOn' with f exact Quotient.sound ⟨(MonoOver.mapId _).app f⟩ #align category_theory.subobject.map_id CategoryTheory.Subobject.map_id
Mathlib/CategoryTheory/Subobject/Basic.lean
585
588
theorem map_comp (f : X ⟶ Y) (g : Y ⟶ Z) [Mono f] [Mono g] (x : Subobject X) : (map (f ≫ g)).obj x = (map g).obj ((map f).obj x) := by
induction' x using Quotient.inductionOn' with t exact Quotient.sound ⟨(MonoOver.mapComp _ _).app t⟩
692
import Mathlib.Control.EquivFunctor import Mathlib.CategoryTheory.Groupoid import Mathlib.CategoryTheory.Whiskering import Mathlib.CategoryTheory.Types #align_import category_theory.core from "leanprover-community/mathlib"@"369525b73f229ccd76a6ec0e0e0bf2be57599768" namespace CategoryTheory universe v₁ v₂ u₁ u₂ -- morphism levels before object levels. See note [CategoryTheory universes]. -- Porting note(#5171): linter not yet ported -- @[nolint has_nonempty_instance] def Core (C : Type u₁) := C #align category_theory.core CategoryTheory.Core variable {C : Type u₁} [Category.{v₁} C] instance coreCategory : Groupoid.{v₁} (Core C) where Hom (X Y : C) := X ≅ Y id (X : C) := Iso.refl X comp f g := Iso.trans f g inv {X Y} f := Iso.symm f #align category_theory.core_category CategoryTheory.coreCategory namespace Core @[simp]
Mathlib/CategoryTheory/Core.lean
52
53
theorem id_hom (X : C) : Iso.hom (coreCategory.id X) = @CategoryStruct.id C _ X := by
rfl
693
import Mathlib.Algebra.Category.GroupCat.Basic import Mathlib.CategoryTheory.SingleObj import Mathlib.CategoryTheory.Limits.FunctorCategory import Mathlib.CategoryTheory.Limits.Preserves.Basic import Mathlib.CategoryTheory.Adjunction.Limits import Mathlib.CategoryTheory.Conj #align_import representation_theory.Action from "leanprover-community/mathlib"@"95a87616d63b3cb49d3fe678d416fbe9c4217bf4" universe u v open CategoryTheory Limits variable (V : Type (u + 1)) [LargeCategory V] -- Note: this is _not_ a categorical action of `G` on `V`. structure Action (G : MonCat.{u}) where V : V ρ : G ⟶ MonCat.of (End V) set_option linter.uppercaseLean3 false in #align Action Action namespace Action variable {V} @[simp 1100]
Mathlib/RepresentationTheory/Action/Basic.lean
50
50
theorem ρ_one {G : MonCat.{u}} (A : Action V G) : A.ρ 1 = 𝟙 A.V := by
rw [MonoidHom.map_one]; rfl
694
import Mathlib.CategoryTheory.NatIso import Mathlib.CategoryTheory.EqToHom #align_import category_theory.quotient from "leanprover-community/mathlib"@"740acc0e6f9adf4423f92a485d0456fc271482da" def HomRel (C) [Quiver C] := ∀ ⦃X Y : C⦄, (X ⟶ Y) → (X ⟶ Y) → Prop #align hom_rel HomRel -- Porting Note: `deriving Inhabited` was not able to deduce this typeclass instance (C) [Quiver C] : Inhabited (HomRel C) where default := fun _ _ _ _ ↦ PUnit namespace CategoryTheory variable {C : Type _} [Category C] (r : HomRel C) class Congruence : Prop where equivalence : ∀ {X Y}, _root_.Equivalence (@r X Y) compLeft : ∀ {X Y Z} (f : X ⟶ Y) {g g' : Y ⟶ Z}, r g g' → r (f ≫ g) (f ≫ g') compRight : ∀ {X Y Z} {f f' : X ⟶ Y} (g : Y ⟶ Z), r f f' → r (f ≫ g) (f' ≫ g) #align category_theory.congruence CategoryTheory.Congruence @[ext] structure Quotient (r : HomRel C) where as : C #align category_theory.quotient CategoryTheory.Quotient instance [Inhabited C] : Inhabited (Quotient r) := ⟨{ as := default }⟩ namespace Quotient inductive CompClosure (r : HomRel C) ⦃s t : C⦄ : (s ⟶ t) → (s ⟶ t) → Prop | intro {a b : C} (f : s ⟶ a) (m₁ m₂ : a ⟶ b) (g : b ⟶ t) (h : r m₁ m₂) : CompClosure r (f ≫ m₁ ≫ g) (f ≫ m₂ ≫ g) #align category_theory.quotient.comp_closure CategoryTheory.Quotient.CompClosure
Mathlib/CategoryTheory/Quotient.lean
65
66
theorem CompClosure.of {a b : C} (m₁ m₂ : a ⟶ b) (h : r m₁ m₂) : CompClosure r m₁ m₂ := by
simpa using CompClosure.intro (𝟙 _) m₁ m₂ (𝟙 _) h
695
import Mathlib.CategoryTheory.EqToHom import Mathlib.CategoryTheory.Quotient import Mathlib.Combinatorics.Quiver.Path #align_import category_theory.path_category from "leanprover-community/mathlib"@"c6dd521ebdce53bb372c527569dd7c25de53a08b" universe v₁ v₂ u₁ u₂ namespace CategoryTheory section def Paths (V : Type u₁) : Type u₁ := V #align category_theory.paths CategoryTheory.Paths instance (V : Type u₁) [Inhabited V] : Inhabited (Paths V) := ⟨(default : V)⟩ variable (V : Type u₁) [Quiver.{v₁ + 1} V] namespace Paths instance categoryPaths : Category.{max u₁ v₁} (Paths V) where Hom := fun X Y : V => Quiver.Path X Y id X := Quiver.Path.nil comp f g := Quiver.Path.comp f g #align category_theory.paths.category_paths CategoryTheory.Paths.categoryPaths variable {V} @[simps] def of : V ⥤q Paths V where obj X := X map f := f.toPath #align category_theory.paths.of CategoryTheory.Paths.of attribute [local ext] Functor.ext def lift {C} [Category C] (φ : V ⥤q C) : Paths V ⥤ C where obj := φ.obj map {X} {Y} f := @Quiver.Path.rec V _ X (fun Y _ => φ.obj X ⟶ φ.obj Y) (𝟙 <| φ.obj X) (fun _ f ihp => ihp ≫ φ.map f) Y f map_id X := rfl map_comp f g := by induction' g with _ _ g' p ih _ _ _ · rw [Category.comp_id] rfl · have : f ≫ Quiver.Path.cons g' p = (f ≫ g').cons p := by apply Quiver.Path.comp_cons rw [this] simp only at ih ⊢ rw [ih, Category.assoc] #align category_theory.paths.lift CategoryTheory.Paths.lift @[simp] theorem lift_nil {C} [Category C] (φ : V ⥤q C) (X : V) : (lift φ).map Quiver.Path.nil = 𝟙 (φ.obj X) := rfl #align category_theory.paths.lift_nil CategoryTheory.Paths.lift_nil @[simp] theorem lift_cons {C} [Category C] (φ : V ⥤q C) {X Y Z : V} (p : Quiver.Path X Y) (f : Y ⟶ Z) : (lift φ).map (p.cons f) = (lift φ).map p ≫ φ.map f := rfl #align category_theory.paths.lift_cons CategoryTheory.Paths.lift_cons @[simp]
Mathlib/CategoryTheory/PathCategory.lean
87
90
theorem lift_toPath {C} [Category C] (φ : V ⥤q C) {X Y : V} (f : X ⟶ Y) : (lift φ).map f.toPath = φ.map f := by
dsimp [Quiver.Hom.toPath, lift] simp
696
import Mathlib.CategoryTheory.EqToHom import Mathlib.CategoryTheory.Quotient import Mathlib.Combinatorics.Quiver.Path #align_import category_theory.path_category from "leanprover-community/mathlib"@"c6dd521ebdce53bb372c527569dd7c25de53a08b" universe v₁ v₂ u₁ u₂ namespace CategoryTheory section def Paths (V : Type u₁) : Type u₁ := V #align category_theory.paths CategoryTheory.Paths instance (V : Type u₁) [Inhabited V] : Inhabited (Paths V) := ⟨(default : V)⟩ variable (V : Type u₁) [Quiver.{v₁ + 1} V] namespace Paths instance categoryPaths : Category.{max u₁ v₁} (Paths V) where Hom := fun X Y : V => Quiver.Path X Y id X := Quiver.Path.nil comp f g := Quiver.Path.comp f g #align category_theory.paths.category_paths CategoryTheory.Paths.categoryPaths variable {V} @[simps] def of : V ⥤q Paths V where obj X := X map f := f.toPath #align category_theory.paths.of CategoryTheory.Paths.of attribute [local ext] Functor.ext def lift {C} [Category C] (φ : V ⥤q C) : Paths V ⥤ C where obj := φ.obj map {X} {Y} f := @Quiver.Path.rec V _ X (fun Y _ => φ.obj X ⟶ φ.obj Y) (𝟙 <| φ.obj X) (fun _ f ihp => ihp ≫ φ.map f) Y f map_id X := rfl map_comp f g := by induction' g with _ _ g' p ih _ _ _ · rw [Category.comp_id] rfl · have : f ≫ Quiver.Path.cons g' p = (f ≫ g').cons p := by apply Quiver.Path.comp_cons rw [this] simp only at ih ⊢ rw [ih, Category.assoc] #align category_theory.paths.lift CategoryTheory.Paths.lift @[simp] theorem lift_nil {C} [Category C] (φ : V ⥤q C) (X : V) : (lift φ).map Quiver.Path.nil = 𝟙 (φ.obj X) := rfl #align category_theory.paths.lift_nil CategoryTheory.Paths.lift_nil @[simp] theorem lift_cons {C} [Category C] (φ : V ⥤q C) {X Y Z : V} (p : Quiver.Path X Y) (f : Y ⟶ Z) : (lift φ).map (p.cons f) = (lift φ).map p ≫ φ.map f := rfl #align category_theory.paths.lift_cons CategoryTheory.Paths.lift_cons @[simp] theorem lift_toPath {C} [Category C] (φ : V ⥤q C) {X Y : V} (f : X ⟶ Y) : (lift φ).map f.toPath = φ.map f := by dsimp [Quiver.Hom.toPath, lift] simp #align category_theory.paths.lift_to_path CategoryTheory.Paths.lift_toPath
Mathlib/CategoryTheory/PathCategory.lean
93
100
theorem lift_spec {C} [Category C] (φ : V ⥤q C) : of ⋙q (lift φ).toPrefunctor = φ := by
fapply Prefunctor.ext · rintro X rfl · rintro X Y f rcases φ with ⟨φo, φm⟩ dsimp [lift, Quiver.Hom.toPath] simp only [Category.id_comp]
696
import Mathlib.CategoryTheory.EqToHom import Mathlib.CategoryTheory.Quotient import Mathlib.Combinatorics.Quiver.Path #align_import category_theory.path_category from "leanprover-community/mathlib"@"c6dd521ebdce53bb372c527569dd7c25de53a08b" universe v₁ v₂ u₁ u₂ namespace CategoryTheory section def Paths (V : Type u₁) : Type u₁ := V #align category_theory.paths CategoryTheory.Paths instance (V : Type u₁) [Inhabited V] : Inhabited (Paths V) := ⟨(default : V)⟩ variable (V : Type u₁) [Quiver.{v₁ + 1} V] namespace Paths instance categoryPaths : Category.{max u₁ v₁} (Paths V) where Hom := fun X Y : V => Quiver.Path X Y id X := Quiver.Path.nil comp f g := Quiver.Path.comp f g #align category_theory.paths.category_paths CategoryTheory.Paths.categoryPaths variable {V} @[simps] def of : V ⥤q Paths V where obj X := X map f := f.toPath #align category_theory.paths.of CategoryTheory.Paths.of attribute [local ext] Functor.ext def lift {C} [Category C] (φ : V ⥤q C) : Paths V ⥤ C where obj := φ.obj map {X} {Y} f := @Quiver.Path.rec V _ X (fun Y _ => φ.obj X ⟶ φ.obj Y) (𝟙 <| φ.obj X) (fun _ f ihp => ihp ≫ φ.map f) Y f map_id X := rfl map_comp f g := by induction' g with _ _ g' p ih _ _ _ · rw [Category.comp_id] rfl · have : f ≫ Quiver.Path.cons g' p = (f ≫ g').cons p := by apply Quiver.Path.comp_cons rw [this] simp only at ih ⊢ rw [ih, Category.assoc] #align category_theory.paths.lift CategoryTheory.Paths.lift @[simp] theorem lift_nil {C} [Category C] (φ : V ⥤q C) (X : V) : (lift φ).map Quiver.Path.nil = 𝟙 (φ.obj X) := rfl #align category_theory.paths.lift_nil CategoryTheory.Paths.lift_nil @[simp] theorem lift_cons {C} [Category C] (φ : V ⥤q C) {X Y Z : V} (p : Quiver.Path X Y) (f : Y ⟶ Z) : (lift φ).map (p.cons f) = (lift φ).map p ≫ φ.map f := rfl #align category_theory.paths.lift_cons CategoryTheory.Paths.lift_cons @[simp] theorem lift_toPath {C} [Category C] (φ : V ⥤q C) {X Y : V} (f : X ⟶ Y) : (lift φ).map f.toPath = φ.map f := by dsimp [Quiver.Hom.toPath, lift] simp #align category_theory.paths.lift_to_path CategoryTheory.Paths.lift_toPath theorem lift_spec {C} [Category C] (φ : V ⥤q C) : of ⋙q (lift φ).toPrefunctor = φ := by fapply Prefunctor.ext · rintro X rfl · rintro X Y f rcases φ with ⟨φo, φm⟩ dsimp [lift, Quiver.Hom.toPath] simp only [Category.id_comp] #align category_theory.paths.lift_spec CategoryTheory.Paths.lift_spec
Mathlib/CategoryTheory/PathCategory.lean
103
119
theorem lift_unique {C} [Category C] (φ : V ⥤q C) (Φ : Paths V ⥤ C) (hΦ : of ⋙q Φ.toPrefunctor = φ) : Φ = lift φ := by
subst_vars fapply Functor.ext · rintro X rfl · rintro X Y f dsimp [lift] induction' f with _ _ p f' ih · simp only [Category.comp_id] apply Functor.map_id · simp only [Category.comp_id, Category.id_comp] at ih ⊢ -- Porting note: Had to do substitute `p.cons f'` and `f'.toPath` by their fully qualified -- versions in this `have` clause (elsewhere too). have : Φ.map (Quiver.Path.cons p f') = Φ.map p ≫ Φ.map (Quiver.Hom.toPath f') := by convert Functor.map_comp Φ p (Quiver.Hom.toPath f') rw [this, ih]
696
import Mathlib.CategoryTheory.EqToHom import Mathlib.CategoryTheory.Quotient import Mathlib.Combinatorics.Quiver.Path #align_import category_theory.path_category from "leanprover-community/mathlib"@"c6dd521ebdce53bb372c527569dd7c25de53a08b" universe v₁ v₂ u₁ u₂ namespace CategoryTheory section def Paths (V : Type u₁) : Type u₁ := V #align category_theory.paths CategoryTheory.Paths instance (V : Type u₁) [Inhabited V] : Inhabited (Paths V) := ⟨(default : V)⟩ variable (V : Type u₁) [Quiver.{v₁ + 1} V] namespace Paths instance categoryPaths : Category.{max u₁ v₁} (Paths V) where Hom := fun X Y : V => Quiver.Path X Y id X := Quiver.Path.nil comp f g := Quiver.Path.comp f g #align category_theory.paths.category_paths CategoryTheory.Paths.categoryPaths variable {V} @[simps] def of : V ⥤q Paths V where obj X := X map f := f.toPath #align category_theory.paths.of CategoryTheory.Paths.of attribute [local ext] Functor.ext def lift {C} [Category C] (φ : V ⥤q C) : Paths V ⥤ C where obj := φ.obj map {X} {Y} f := @Quiver.Path.rec V _ X (fun Y _ => φ.obj X ⟶ φ.obj Y) (𝟙 <| φ.obj X) (fun _ f ihp => ihp ≫ φ.map f) Y f map_id X := rfl map_comp f g := by induction' g with _ _ g' p ih _ _ _ · rw [Category.comp_id] rfl · have : f ≫ Quiver.Path.cons g' p = (f ≫ g').cons p := by apply Quiver.Path.comp_cons rw [this] simp only at ih ⊢ rw [ih, Category.assoc] #align category_theory.paths.lift CategoryTheory.Paths.lift @[simp] theorem lift_nil {C} [Category C] (φ : V ⥤q C) (X : V) : (lift φ).map Quiver.Path.nil = 𝟙 (φ.obj X) := rfl #align category_theory.paths.lift_nil CategoryTheory.Paths.lift_nil @[simp] theorem lift_cons {C} [Category C] (φ : V ⥤q C) {X Y Z : V} (p : Quiver.Path X Y) (f : Y ⟶ Z) : (lift φ).map (p.cons f) = (lift φ).map p ≫ φ.map f := rfl #align category_theory.paths.lift_cons CategoryTheory.Paths.lift_cons @[simp] theorem lift_toPath {C} [Category C] (φ : V ⥤q C) {X Y : V} (f : X ⟶ Y) : (lift φ).map f.toPath = φ.map f := by dsimp [Quiver.Hom.toPath, lift] simp #align category_theory.paths.lift_to_path CategoryTheory.Paths.lift_toPath theorem lift_spec {C} [Category C] (φ : V ⥤q C) : of ⋙q (lift φ).toPrefunctor = φ := by fapply Prefunctor.ext · rintro X rfl · rintro X Y f rcases φ with ⟨φo, φm⟩ dsimp [lift, Quiver.Hom.toPath] simp only [Category.id_comp] #align category_theory.paths.lift_spec CategoryTheory.Paths.lift_spec theorem lift_unique {C} [Category C] (φ : V ⥤q C) (Φ : Paths V ⥤ C) (hΦ : of ⋙q Φ.toPrefunctor = φ) : Φ = lift φ := by subst_vars fapply Functor.ext · rintro X rfl · rintro X Y f dsimp [lift] induction' f with _ _ p f' ih · simp only [Category.comp_id] apply Functor.map_id · simp only [Category.comp_id, Category.id_comp] at ih ⊢ -- Porting note: Had to do substitute `p.cons f'` and `f'.toPath` by their fully qualified -- versions in this `have` clause (elsewhere too). have : Φ.map (Quiver.Path.cons p f') = Φ.map p ≫ Φ.map (Quiver.Hom.toPath f') := by convert Functor.map_comp Φ p (Quiver.Hom.toPath f') rw [this, ih] #align category_theory.paths.lift_unique CategoryTheory.Paths.lift_unique @[ext]
Mathlib/CategoryTheory/PathCategory.lean
124
135
theorem ext_functor {C} [Category C] {F G : Paths V ⥤ C} (h_obj : F.obj = G.obj) (h : ∀ (a b : V) (e : a ⟶ b), F.map e.toPath = eqToHom (congr_fun h_obj a) ≫ G.map e.toPath ≫ eqToHom (congr_fun h_obj.symm b)) : F = G := by
fapply Functor.ext · intro X rw [h_obj] · intro X Y f induction' f with Y' Z' g e ih · erw [F.map_id, G.map_id, Category.id_comp, eqToHom_trans, eqToHom_refl] · erw [F.map_comp g (Quiver.Hom.toPath e), G.map_comp g (Quiver.Hom.toPath e), ih, h] simp only [Category.id_comp, eqToHom_refl, eqToHom_trans_assoc, Category.assoc]
696
import Mathlib.CategoryTheory.Category.Basic import Mathlib.CategoryTheory.Functor.Basic import Mathlib.CategoryTheory.Groupoid import Mathlib.Tactic.NthRewrite import Mathlib.CategoryTheory.PathCategory import Mathlib.CategoryTheory.Quotient import Mathlib.Combinatorics.Quiver.Symmetric #align_import category_theory.groupoid.free_groupoid from "leanprover-community/mathlib"@"706d88f2b8fdfeb0b22796433d7a6c1a010af9f2" open Set Classical Function attribute [local instance] propDecidable namespace CategoryTheory namespace Groupoid namespace Free universe u v u' v' u'' v'' variable {V : Type u} [Quiver.{v + 1} V] abbrev _root_.Quiver.Hom.toPosPath {X Y : V} (f : X ⟶ Y) : (CategoryTheory.Paths.categoryPaths <| Quiver.Symmetrify V).Hom X Y := f.toPos.toPath #align category_theory.groupoid.free.quiver.hom.to_pos_path Quiver.Hom.toPosPath abbrev _root_.Quiver.Hom.toNegPath {X Y : V} (f : X ⟶ Y) : (CategoryTheory.Paths.categoryPaths <| Quiver.Symmetrify V).Hom Y X := f.toNeg.toPath #align category_theory.groupoid.free.quiver.hom.to_neg_path Quiver.Hom.toNegPath inductive redStep : HomRel (Paths (Quiver.Symmetrify V)) | step (X Z : Quiver.Symmetrify V) (f : X ⟶ Z) : redStep (𝟙 (Paths.of.obj X)) (f.toPath ≫ (Quiver.reverse f).toPath) #align category_theory.groupoid.free.red_step CategoryTheory.Groupoid.Free.redStep def _root_.CategoryTheory.FreeGroupoid (V) [Q : Quiver V] := Quotient (@redStep V Q) #align category_theory.free_groupoid CategoryTheory.FreeGroupoid instance {V} [Quiver V] [Nonempty V] : Nonempty (FreeGroupoid V) := by inhabit V; exact ⟨⟨@default V _⟩⟩
Mathlib/CategoryTheory/Groupoid/FreeGroupoid.lean
81
90
theorem congr_reverse {X Y : Paths <| Quiver.Symmetrify V} (p q : X ⟶ Y) : Quotient.CompClosure redStep p q → Quotient.CompClosure redStep p.reverse q.reverse := by
rintro ⟨XW, pp, qq, WY, _, Z, f⟩ have : Quotient.CompClosure redStep (WY.reverse ≫ 𝟙 _ ≫ XW.reverse) (WY.reverse ≫ (f.toPath ≫ (Quiver.reverse f).toPath) ≫ XW.reverse) := by constructor constructor simpa only [CategoryStruct.comp, CategoryStruct.id, Quiver.Path.reverse, Quiver.Path.nil_comp, Quiver.Path.reverse_comp, Quiver.reverse_reverse, Quiver.Path.reverse_toPath, Quiver.Path.comp_assoc] using this
697
import Mathlib.CategoryTheory.Category.Basic import Mathlib.CategoryTheory.Functor.Basic import Mathlib.CategoryTheory.Groupoid import Mathlib.Tactic.NthRewrite import Mathlib.CategoryTheory.PathCategory import Mathlib.CategoryTheory.Quotient import Mathlib.Combinatorics.Quiver.Symmetric #align_import category_theory.groupoid.free_groupoid from "leanprover-community/mathlib"@"706d88f2b8fdfeb0b22796433d7a6c1a010af9f2" open Set Classical Function attribute [local instance] propDecidable namespace CategoryTheory namespace Groupoid namespace Free universe u v u' v' u'' v'' variable {V : Type u} [Quiver.{v + 1} V] abbrev _root_.Quiver.Hom.toPosPath {X Y : V} (f : X ⟶ Y) : (CategoryTheory.Paths.categoryPaths <| Quiver.Symmetrify V).Hom X Y := f.toPos.toPath #align category_theory.groupoid.free.quiver.hom.to_pos_path Quiver.Hom.toPosPath abbrev _root_.Quiver.Hom.toNegPath {X Y : V} (f : X ⟶ Y) : (CategoryTheory.Paths.categoryPaths <| Quiver.Symmetrify V).Hom Y X := f.toNeg.toPath #align category_theory.groupoid.free.quiver.hom.to_neg_path Quiver.Hom.toNegPath inductive redStep : HomRel (Paths (Quiver.Symmetrify V)) | step (X Z : Quiver.Symmetrify V) (f : X ⟶ Z) : redStep (𝟙 (Paths.of.obj X)) (f.toPath ≫ (Quiver.reverse f).toPath) #align category_theory.groupoid.free.red_step CategoryTheory.Groupoid.Free.redStep def _root_.CategoryTheory.FreeGroupoid (V) [Q : Quiver V] := Quotient (@redStep V Q) #align category_theory.free_groupoid CategoryTheory.FreeGroupoid instance {V} [Quiver V] [Nonempty V] : Nonempty (FreeGroupoid V) := by inhabit V; exact ⟨⟨@default V _⟩⟩ theorem congr_reverse {X Y : Paths <| Quiver.Symmetrify V} (p q : X ⟶ Y) : Quotient.CompClosure redStep p q → Quotient.CompClosure redStep p.reverse q.reverse := by rintro ⟨XW, pp, qq, WY, _, Z, f⟩ have : Quotient.CompClosure redStep (WY.reverse ≫ 𝟙 _ ≫ XW.reverse) (WY.reverse ≫ (f.toPath ≫ (Quiver.reverse f).toPath) ≫ XW.reverse) := by constructor constructor simpa only [CategoryStruct.comp, CategoryStruct.id, Quiver.Path.reverse, Quiver.Path.nil_comp, Quiver.Path.reverse_comp, Quiver.reverse_reverse, Quiver.Path.reverse_toPath, Quiver.Path.comp_assoc] using this #align category_theory.groupoid.free.congr_reverse CategoryTheory.Groupoid.Free.congr_reverse
Mathlib/CategoryTheory/Groupoid/FreeGroupoid.lean
93
117
theorem congr_comp_reverse {X Y : Paths <| Quiver.Symmetrify V} (p : X ⟶ Y) : Quot.mk (@Quotient.CompClosure _ _ redStep _ _) (p ≫ p.reverse) = Quot.mk (@Quotient.CompClosure _ _ redStep _ _) (𝟙 X) := by
apply Quot.EqvGen_sound induction' p with a b q f ih · apply EqvGen.refl · simp only [Quiver.Path.reverse] fapply EqvGen.trans -- Porting note: `Quiver.Path.*` and `Quiver.Hom.*` notation not working · exact q ≫ Quiver.Path.reverse q · apply EqvGen.symm apply EqvGen.rel have : Quotient.CompClosure redStep (q ≫ 𝟙 _ ≫ Quiver.Path.reverse q) (q ≫ (Quiver.Hom.toPath f ≫ Quiver.Hom.toPath (Quiver.reverse f)) ≫ Quiver.Path.reverse q) := by apply Quotient.CompClosure.intro apply redStep.step simp only [Category.assoc, Category.id_comp] at this ⊢ -- Porting note: `simp` cannot see how `Quiver.Path.comp_assoc` is relevant, so change to -- category notation change Quotient.CompClosure redStep (q ≫ Quiver.Path.reverse q) (Quiver.Path.cons q f ≫ (Quiver.Hom.toPath (Quiver.reverse f)) ≫ (Quiver.Path.reverse q)) simp only [← Category.assoc] at this ⊢ exact this · exact ih
697
import Mathlib.CategoryTheory.Category.Basic import Mathlib.CategoryTheory.Functor.Basic import Mathlib.CategoryTheory.Groupoid import Mathlib.Tactic.NthRewrite import Mathlib.CategoryTheory.PathCategory import Mathlib.CategoryTheory.Quotient import Mathlib.Combinatorics.Quiver.Symmetric #align_import category_theory.groupoid.free_groupoid from "leanprover-community/mathlib"@"706d88f2b8fdfeb0b22796433d7a6c1a010af9f2" open Set Classical Function attribute [local instance] propDecidable namespace CategoryTheory namespace Groupoid namespace Free universe u v u' v' u'' v'' variable {V : Type u} [Quiver.{v + 1} V] abbrev _root_.Quiver.Hom.toPosPath {X Y : V} (f : X ⟶ Y) : (CategoryTheory.Paths.categoryPaths <| Quiver.Symmetrify V).Hom X Y := f.toPos.toPath #align category_theory.groupoid.free.quiver.hom.to_pos_path Quiver.Hom.toPosPath abbrev _root_.Quiver.Hom.toNegPath {X Y : V} (f : X ⟶ Y) : (CategoryTheory.Paths.categoryPaths <| Quiver.Symmetrify V).Hom Y X := f.toNeg.toPath #align category_theory.groupoid.free.quiver.hom.to_neg_path Quiver.Hom.toNegPath inductive redStep : HomRel (Paths (Quiver.Symmetrify V)) | step (X Z : Quiver.Symmetrify V) (f : X ⟶ Z) : redStep (𝟙 (Paths.of.obj X)) (f.toPath ≫ (Quiver.reverse f).toPath) #align category_theory.groupoid.free.red_step CategoryTheory.Groupoid.Free.redStep def _root_.CategoryTheory.FreeGroupoid (V) [Q : Quiver V] := Quotient (@redStep V Q) #align category_theory.free_groupoid CategoryTheory.FreeGroupoid instance {V} [Quiver V] [Nonempty V] : Nonempty (FreeGroupoid V) := by inhabit V; exact ⟨⟨@default V _⟩⟩ theorem congr_reverse {X Y : Paths <| Quiver.Symmetrify V} (p q : X ⟶ Y) : Quotient.CompClosure redStep p q → Quotient.CompClosure redStep p.reverse q.reverse := by rintro ⟨XW, pp, qq, WY, _, Z, f⟩ have : Quotient.CompClosure redStep (WY.reverse ≫ 𝟙 _ ≫ XW.reverse) (WY.reverse ≫ (f.toPath ≫ (Quiver.reverse f).toPath) ≫ XW.reverse) := by constructor constructor simpa only [CategoryStruct.comp, CategoryStruct.id, Quiver.Path.reverse, Quiver.Path.nil_comp, Quiver.Path.reverse_comp, Quiver.reverse_reverse, Quiver.Path.reverse_toPath, Quiver.Path.comp_assoc] using this #align category_theory.groupoid.free.congr_reverse CategoryTheory.Groupoid.Free.congr_reverse theorem congr_comp_reverse {X Y : Paths <| Quiver.Symmetrify V} (p : X ⟶ Y) : Quot.mk (@Quotient.CompClosure _ _ redStep _ _) (p ≫ p.reverse) = Quot.mk (@Quotient.CompClosure _ _ redStep _ _) (𝟙 X) := by apply Quot.EqvGen_sound induction' p with a b q f ih · apply EqvGen.refl · simp only [Quiver.Path.reverse] fapply EqvGen.trans -- Porting note: `Quiver.Path.*` and `Quiver.Hom.*` notation not working · exact q ≫ Quiver.Path.reverse q · apply EqvGen.symm apply EqvGen.rel have : Quotient.CompClosure redStep (q ≫ 𝟙 _ ≫ Quiver.Path.reverse q) (q ≫ (Quiver.Hom.toPath f ≫ Quiver.Hom.toPath (Quiver.reverse f)) ≫ Quiver.Path.reverse q) := by apply Quotient.CompClosure.intro apply redStep.step simp only [Category.assoc, Category.id_comp] at this ⊢ -- Porting note: `simp` cannot see how `Quiver.Path.comp_assoc` is relevant, so change to -- category notation change Quotient.CompClosure redStep (q ≫ Quiver.Path.reverse q) (Quiver.Path.cons q f ≫ (Quiver.Hom.toPath (Quiver.reverse f)) ≫ (Quiver.Path.reverse q)) simp only [← Category.assoc] at this ⊢ exact this · exact ih #align category_theory.groupoid.free.congr_comp_reverse CategoryTheory.Groupoid.Free.congr_comp_reverse
Mathlib/CategoryTheory/Groupoid/FreeGroupoid.lean
120
124
theorem congr_reverse_comp {X Y : Paths <| Quiver.Symmetrify V} (p : X ⟶ Y) : Quot.mk (@Quotient.CompClosure _ _ redStep _ _) (p.reverse ≫ p) = Quot.mk (@Quotient.CompClosure _ _ redStep _ _) (𝟙 Y) := by
nth_rw 2 [← Quiver.Path.reverse_reverse p] apply congr_comp_reverse
697
import Mathlib.CategoryTheory.PathCategory import Mathlib.CategoryTheory.Functor.FullyFaithful import Mathlib.CategoryTheory.Bicategory.Free import Mathlib.CategoryTheory.Bicategory.LocallyDiscrete #align_import category_theory.bicategory.coherence from "leanprover-community/mathlib"@"f187f1074fa1857c94589cc653c786cadc4c35ff" open Quiver (Path) open Quiver.Path namespace CategoryTheory open Bicategory Category universe v u namespace FreeBicategory variable {B : Type u} [Quiver.{v + 1} B] @[simp] def inclusionPathAux {a : B} : ∀ {b : B}, Path a b → Hom a b | _, nil => Hom.id a | _, cons p f => (inclusionPathAux p).comp (Hom.of f) #align category_theory.free_bicategory.inclusion_path_aux CategoryTheory.FreeBicategory.inclusionPathAux local instance homCategory' (a b : B) : Category (Hom a b) := homCategory a b def inclusionPath (a b : B) : Discrete (Path.{v + 1} a b) ⥤ Hom a b := Discrete.functor inclusionPathAux #align category_theory.free_bicategory.inclusion_path CategoryTheory.FreeBicategory.inclusionPath def preinclusion (B : Type u) [Quiver.{v + 1} B] : PrelaxFunctor (LocallyDiscrete (Paths B)) (FreeBicategory B) where obj a := a.as map := @fun a b f => (@inclusionPath B _ a.as b.as).obj f map₂ η := (inclusionPath _ _).map η #align category_theory.free_bicategory.preinclusion CategoryTheory.FreeBicategory.preinclusion @[simp] theorem preinclusion_obj (a : B) : (preinclusion B).obj ⟨a⟩ = a := rfl #align category_theory.free_bicategory.preinclusion_obj CategoryTheory.FreeBicategory.preinclusion_obj @[simp]
Mathlib/CategoryTheory/Bicategory/Coherence.lean
94
98
theorem preinclusion_map₂ {a b : B} (f g : Discrete (Path.{v + 1} a b)) (η : f ⟶ g) : (preinclusion B).map₂ η = eqToHom (congr_arg _ (Discrete.ext _ _ (Discrete.eq_of_hom η))) := by
rcases η with ⟨⟨⟩⟩ cases Discrete.ext _ _ (by assumption) convert (inclusionPath a b).map_id _
698
import Mathlib.CategoryTheory.PathCategory import Mathlib.CategoryTheory.Functor.FullyFaithful import Mathlib.CategoryTheory.Bicategory.Free import Mathlib.CategoryTheory.Bicategory.LocallyDiscrete #align_import category_theory.bicategory.coherence from "leanprover-community/mathlib"@"f187f1074fa1857c94589cc653c786cadc4c35ff" open Quiver (Path) open Quiver.Path namespace CategoryTheory open Bicategory Category universe v u namespace FreeBicategory variable {B : Type u} [Quiver.{v + 1} B] @[simp] def inclusionPathAux {a : B} : ∀ {b : B}, Path a b → Hom a b | _, nil => Hom.id a | _, cons p f => (inclusionPathAux p).comp (Hom.of f) #align category_theory.free_bicategory.inclusion_path_aux CategoryTheory.FreeBicategory.inclusionPathAux local instance homCategory' (a b : B) : Category (Hom a b) := homCategory a b def inclusionPath (a b : B) : Discrete (Path.{v + 1} a b) ⥤ Hom a b := Discrete.functor inclusionPathAux #align category_theory.free_bicategory.inclusion_path CategoryTheory.FreeBicategory.inclusionPath def preinclusion (B : Type u) [Quiver.{v + 1} B] : PrelaxFunctor (LocallyDiscrete (Paths B)) (FreeBicategory B) where obj a := a.as map := @fun a b f => (@inclusionPath B _ a.as b.as).obj f map₂ η := (inclusionPath _ _).map η #align category_theory.free_bicategory.preinclusion CategoryTheory.FreeBicategory.preinclusion @[simp] theorem preinclusion_obj (a : B) : (preinclusion B).obj ⟨a⟩ = a := rfl #align category_theory.free_bicategory.preinclusion_obj CategoryTheory.FreeBicategory.preinclusion_obj @[simp] theorem preinclusion_map₂ {a b : B} (f g : Discrete (Path.{v + 1} a b)) (η : f ⟶ g) : (preinclusion B).map₂ η = eqToHom (congr_arg _ (Discrete.ext _ _ (Discrete.eq_of_hom η))) := by rcases η with ⟨⟨⟩⟩ cases Discrete.ext _ _ (by assumption) convert (inclusionPath a b).map_id _ #align category_theory.free_bicategory.preinclusion_map₂ CategoryTheory.FreeBicategory.preinclusion_map₂ @[simp] def normalizeAux {a : B} : ∀ {b c : B}, Path a b → Hom b c → Path a c | _, _, p, Hom.of f => p.cons f | _, _, p, Hom.id _ => p | _, _, p, Hom.comp f g => normalizeAux (normalizeAux p f) g #align category_theory.free_bicategory.normalize_aux CategoryTheory.FreeBicategory.normalizeAux @[simp] def normalizeIso {a : B} : ∀ {b c : B} (p : Path a b) (f : Hom b c), (preinclusion B).map ⟨p⟩ ≫ f ≅ (preinclusion B).map ⟨normalizeAux p f⟩ | _, _, _, Hom.of _ => Iso.refl _ | _, _, _, Hom.id b => ρ_ _ | _, _, p, Hom.comp f g => (α_ _ _ _).symm ≪≫ whiskerRightIso (normalizeIso p f) g ≪≫ normalizeIso (normalizeAux p f) g #align category_theory.free_bicategory.normalize_iso CategoryTheory.FreeBicategory.normalizeIso
Mathlib/CategoryTheory/Bicategory/Coherence.lean
148
157
theorem normalizeAux_congr {a b c : B} (p : Path a b) {f g : Hom b c} (η : f ⟶ g) : normalizeAux p f = normalizeAux p g := by
rcases η with ⟨η'⟩ apply @congr_fun _ _ fun p => normalizeAux p f clear p η induction η' with | vcomp _ _ _ _ => apply Eq.trans <;> assumption | whisker_left _ _ ih => funext; apply congr_fun ih | whisker_right _ _ ih => funext; apply congr_arg₂ _ (congr_fun ih _) rfl | _ => funext; rfl
698
import Mathlib.CategoryTheory.PathCategory import Mathlib.CategoryTheory.Functor.FullyFaithful import Mathlib.CategoryTheory.Bicategory.Free import Mathlib.CategoryTheory.Bicategory.LocallyDiscrete #align_import category_theory.bicategory.coherence from "leanprover-community/mathlib"@"f187f1074fa1857c94589cc653c786cadc4c35ff" open Quiver (Path) open Quiver.Path namespace CategoryTheory open Bicategory Category universe v u namespace FreeBicategory variable {B : Type u} [Quiver.{v + 1} B] @[simp] def inclusionPathAux {a : B} : ∀ {b : B}, Path a b → Hom a b | _, nil => Hom.id a | _, cons p f => (inclusionPathAux p).comp (Hom.of f) #align category_theory.free_bicategory.inclusion_path_aux CategoryTheory.FreeBicategory.inclusionPathAux local instance homCategory' (a b : B) : Category (Hom a b) := homCategory a b def inclusionPath (a b : B) : Discrete (Path.{v + 1} a b) ⥤ Hom a b := Discrete.functor inclusionPathAux #align category_theory.free_bicategory.inclusion_path CategoryTheory.FreeBicategory.inclusionPath def preinclusion (B : Type u) [Quiver.{v + 1} B] : PrelaxFunctor (LocallyDiscrete (Paths B)) (FreeBicategory B) where obj a := a.as map := @fun a b f => (@inclusionPath B _ a.as b.as).obj f map₂ η := (inclusionPath _ _).map η #align category_theory.free_bicategory.preinclusion CategoryTheory.FreeBicategory.preinclusion @[simp] theorem preinclusion_obj (a : B) : (preinclusion B).obj ⟨a⟩ = a := rfl #align category_theory.free_bicategory.preinclusion_obj CategoryTheory.FreeBicategory.preinclusion_obj @[simp] theorem preinclusion_map₂ {a b : B} (f g : Discrete (Path.{v + 1} a b)) (η : f ⟶ g) : (preinclusion B).map₂ η = eqToHom (congr_arg _ (Discrete.ext _ _ (Discrete.eq_of_hom η))) := by rcases η with ⟨⟨⟩⟩ cases Discrete.ext _ _ (by assumption) convert (inclusionPath a b).map_id _ #align category_theory.free_bicategory.preinclusion_map₂ CategoryTheory.FreeBicategory.preinclusion_map₂ @[simp] def normalizeAux {a : B} : ∀ {b c : B}, Path a b → Hom b c → Path a c | _, _, p, Hom.of f => p.cons f | _, _, p, Hom.id _ => p | _, _, p, Hom.comp f g => normalizeAux (normalizeAux p f) g #align category_theory.free_bicategory.normalize_aux CategoryTheory.FreeBicategory.normalizeAux @[simp] def normalizeIso {a : B} : ∀ {b c : B} (p : Path a b) (f : Hom b c), (preinclusion B).map ⟨p⟩ ≫ f ≅ (preinclusion B).map ⟨normalizeAux p f⟩ | _, _, _, Hom.of _ => Iso.refl _ | _, _, _, Hom.id b => ρ_ _ | _, _, p, Hom.comp f g => (α_ _ _ _).symm ≪≫ whiskerRightIso (normalizeIso p f) g ≪≫ normalizeIso (normalizeAux p f) g #align category_theory.free_bicategory.normalize_iso CategoryTheory.FreeBicategory.normalizeIso theorem normalizeAux_congr {a b c : B} (p : Path a b) {f g : Hom b c} (η : f ⟶ g) : normalizeAux p f = normalizeAux p g := by rcases η with ⟨η'⟩ apply @congr_fun _ _ fun p => normalizeAux p f clear p η induction η' with | vcomp _ _ _ _ => apply Eq.trans <;> assumption | whisker_left _ _ ih => funext; apply congr_fun ih | whisker_right _ _ ih => funext; apply congr_arg₂ _ (congr_fun ih _) rfl | _ => funext; rfl #align category_theory.free_bicategory.normalize_aux_congr CategoryTheory.FreeBicategory.normalizeAux_congr
Mathlib/CategoryTheory/Bicategory/Coherence.lean
161
183
theorem normalize_naturality {a b c : B} (p : Path a b) {f g : Hom b c} (η : f ⟶ g) : (preinclusion B).map ⟨p⟩ ◁ η ≫ (normalizeIso p g).hom = (normalizeIso p f).hom ≫ (preinclusion B).map₂ (eqToHom (Discrete.ext _ _ (normalizeAux_congr p η))) := by
rcases η with ⟨η'⟩; clear η; induction η' with | id => simp | vcomp η θ ihf ihg => simp only [mk_vcomp, Bicategory.whiskerLeft_comp] slice_lhs 2 3 => rw [ihg] slice_lhs 1 2 => rw [ihf] simp -- p ≠ nil required! See the docstring of `normalizeAux`. | whisker_left _ _ ih => dsimp rw [associator_inv_naturality_right_assoc, whisker_exchange_assoc, ih] simp | whisker_right h η' ih => dsimp rw [associator_inv_naturality_middle_assoc, ← comp_whiskerRight_assoc, ih, comp_whiskerRight] have := dcongr_arg (fun x => (normalizeIso x h).hom) (normalizeAux_congr p (Quot.mk _ η')) dsimp at this; simp [this] | _ => simp
698
import Mathlib.CategoryTheory.PathCategory import Mathlib.CategoryTheory.Functor.FullyFaithful import Mathlib.CategoryTheory.Bicategory.Free import Mathlib.CategoryTheory.Bicategory.LocallyDiscrete #align_import category_theory.bicategory.coherence from "leanprover-community/mathlib"@"f187f1074fa1857c94589cc653c786cadc4c35ff" open Quiver (Path) open Quiver.Path namespace CategoryTheory open Bicategory Category universe v u namespace FreeBicategory variable {B : Type u} [Quiver.{v + 1} B] @[simp] def inclusionPathAux {a : B} : ∀ {b : B}, Path a b → Hom a b | _, nil => Hom.id a | _, cons p f => (inclusionPathAux p).comp (Hom.of f) #align category_theory.free_bicategory.inclusion_path_aux CategoryTheory.FreeBicategory.inclusionPathAux local instance homCategory' (a b : B) : Category (Hom a b) := homCategory a b def inclusionPath (a b : B) : Discrete (Path.{v + 1} a b) ⥤ Hom a b := Discrete.functor inclusionPathAux #align category_theory.free_bicategory.inclusion_path CategoryTheory.FreeBicategory.inclusionPath def preinclusion (B : Type u) [Quiver.{v + 1} B] : PrelaxFunctor (LocallyDiscrete (Paths B)) (FreeBicategory B) where obj a := a.as map := @fun a b f => (@inclusionPath B _ a.as b.as).obj f map₂ η := (inclusionPath _ _).map η #align category_theory.free_bicategory.preinclusion CategoryTheory.FreeBicategory.preinclusion @[simp] theorem preinclusion_obj (a : B) : (preinclusion B).obj ⟨a⟩ = a := rfl #align category_theory.free_bicategory.preinclusion_obj CategoryTheory.FreeBicategory.preinclusion_obj @[simp] theorem preinclusion_map₂ {a b : B} (f g : Discrete (Path.{v + 1} a b)) (η : f ⟶ g) : (preinclusion B).map₂ η = eqToHom (congr_arg _ (Discrete.ext _ _ (Discrete.eq_of_hom η))) := by rcases η with ⟨⟨⟩⟩ cases Discrete.ext _ _ (by assumption) convert (inclusionPath a b).map_id _ #align category_theory.free_bicategory.preinclusion_map₂ CategoryTheory.FreeBicategory.preinclusion_map₂ @[simp] def normalizeAux {a : B} : ∀ {b c : B}, Path a b → Hom b c → Path a c | _, _, p, Hom.of f => p.cons f | _, _, p, Hom.id _ => p | _, _, p, Hom.comp f g => normalizeAux (normalizeAux p f) g #align category_theory.free_bicategory.normalize_aux CategoryTheory.FreeBicategory.normalizeAux @[simp] def normalizeIso {a : B} : ∀ {b c : B} (p : Path a b) (f : Hom b c), (preinclusion B).map ⟨p⟩ ≫ f ≅ (preinclusion B).map ⟨normalizeAux p f⟩ | _, _, _, Hom.of _ => Iso.refl _ | _, _, _, Hom.id b => ρ_ _ | _, _, p, Hom.comp f g => (α_ _ _ _).symm ≪≫ whiskerRightIso (normalizeIso p f) g ≪≫ normalizeIso (normalizeAux p f) g #align category_theory.free_bicategory.normalize_iso CategoryTheory.FreeBicategory.normalizeIso theorem normalizeAux_congr {a b c : B} (p : Path a b) {f g : Hom b c} (η : f ⟶ g) : normalizeAux p f = normalizeAux p g := by rcases η with ⟨η'⟩ apply @congr_fun _ _ fun p => normalizeAux p f clear p η induction η' with | vcomp _ _ _ _ => apply Eq.trans <;> assumption | whisker_left _ _ ih => funext; apply congr_fun ih | whisker_right _ _ ih => funext; apply congr_arg₂ _ (congr_fun ih _) rfl | _ => funext; rfl #align category_theory.free_bicategory.normalize_aux_congr CategoryTheory.FreeBicategory.normalizeAux_congr theorem normalize_naturality {a b c : B} (p : Path a b) {f g : Hom b c} (η : f ⟶ g) : (preinclusion B).map ⟨p⟩ ◁ η ≫ (normalizeIso p g).hom = (normalizeIso p f).hom ≫ (preinclusion B).map₂ (eqToHom (Discrete.ext _ _ (normalizeAux_congr p η))) := by rcases η with ⟨η'⟩; clear η; induction η' with | id => simp | vcomp η θ ihf ihg => simp only [mk_vcomp, Bicategory.whiskerLeft_comp] slice_lhs 2 3 => rw [ihg] slice_lhs 1 2 => rw [ihf] simp -- p ≠ nil required! See the docstring of `normalizeAux`. | whisker_left _ _ ih => dsimp rw [associator_inv_naturality_right_assoc, whisker_exchange_assoc, ih] simp | whisker_right h η' ih => dsimp rw [associator_inv_naturality_middle_assoc, ← comp_whiskerRight_assoc, ih, comp_whiskerRight] have := dcongr_arg (fun x => (normalizeIso x h).hom) (normalizeAux_congr p (Quot.mk _ η')) dsimp at this; simp [this] | _ => simp #align category_theory.free_bicategory.normalize_naturality CategoryTheory.FreeBicategory.normalize_naturality -- Porting note: the left-hand side is not in simp-normal form. -- @[simp]
Mathlib/CategoryTheory/Bicategory/Coherence.lean
188
193
theorem normalizeAux_nil_comp {a b c : B} (f : Hom a b) (g : Hom b c) : normalizeAux nil (f.comp g) = (normalizeAux nil f).comp (normalizeAux nil g) := by
induction g generalizing a with | id => rfl | of => rfl | comp g _ ihf ihg => erw [ihg (f.comp g), ihf f, ihg g, comp_assoc]
698
import Mathlib.Tactic.CategoryTheory.Coherence import Mathlib.CategoryTheory.Bicategory.Coherence namespace CategoryTheory namespace Bicategory open Category open scoped Bicategory open Mathlib.Tactic.BicategoryCoherence (bicategoricalComp bicategoricalIsoComp) universe w v u variable {B : Type u} [Bicategory.{w, v} B] {a b c : B} {f : a ⟶ b} {g : b ⟶ a} def leftZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) := η ▷ f ⊗≫ f ◁ ε def rightZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) := g ◁ η ⊗≫ ε ▷ g
Mathlib/CategoryTheory/Bicategory/Adjunction.lean
79
91
theorem rightZigzag_idempotent_of_left_triangle (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) (h : leftZigzag η ε = (λ_ _).hom ≫ (ρ_ _).inv) : rightZigzag η ε ⊗≫ rightZigzag η ε = rightZigzag η ε := by
dsimp only [rightZigzag] calc _ = g ◁ η ⊗≫ ((ε ▷ g ▷ 𝟙 a) ≫ (𝟙 b ≫ g) ◁ η) ⊗≫ ε ▷ g := by simp [bicategoricalComp]; coherence _ = 𝟙 _ ⊗≫ g ◁ (η ▷ 𝟙 a ≫ (f ≫ g) ◁ η) ⊗≫ (ε ▷ (g ≫ f) ≫ 𝟙 b ◁ ε) ▷ g ⊗≫ 𝟙 _ := by rw [← whisker_exchange]; simp [bicategoricalComp]; coherence _ = g ◁ η ⊗≫ g ◁ leftZigzag η ε ▷ g ⊗≫ ε ▷ g := by rw [← whisker_exchange, ← whisker_exchange]; simp [leftZigzag, bicategoricalComp]; coherence _ = g ◁ η ⊗≫ ε ▷ g := by rw [h]; simp [bicategoricalComp]; coherence
699
import Mathlib.Tactic.CategoryTheory.Coherence import Mathlib.CategoryTheory.Bicategory.Coherence namespace CategoryTheory namespace Bicategory open Category open scoped Bicategory open Mathlib.Tactic.BicategoryCoherence (bicategoricalComp bicategoricalIsoComp) universe w v u variable {B : Type u} [Bicategory.{w, v} B] {a b c : B} {f : a ⟶ b} {g : b ⟶ a} def leftZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) := η ▷ f ⊗≫ f ◁ ε def rightZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) := g ◁ η ⊗≫ ε ▷ g theorem rightZigzag_idempotent_of_left_triangle (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) (h : leftZigzag η ε = (λ_ _).hom ≫ (ρ_ _).inv) : rightZigzag η ε ⊗≫ rightZigzag η ε = rightZigzag η ε := by dsimp only [rightZigzag] calc _ = g ◁ η ⊗≫ ((ε ▷ g ▷ 𝟙 a) ≫ (𝟙 b ≫ g) ◁ η) ⊗≫ ε ▷ g := by simp [bicategoricalComp]; coherence _ = 𝟙 _ ⊗≫ g ◁ (η ▷ 𝟙 a ≫ (f ≫ g) ◁ η) ⊗≫ (ε ▷ (g ≫ f) ≫ 𝟙 b ◁ ε) ▷ g ⊗≫ 𝟙 _ := by rw [← whisker_exchange]; simp [bicategoricalComp]; coherence _ = g ◁ η ⊗≫ g ◁ leftZigzag η ε ▷ g ⊗≫ ε ▷ g := by rw [← whisker_exchange, ← whisker_exchange]; simp [leftZigzag, bicategoricalComp]; coherence _ = g ◁ η ⊗≫ ε ▷ g := by rw [h]; simp [bicategoricalComp]; coherence structure Adjunction (f : a ⟶ b) (g : b ⟶ a) where unit : 𝟙 a ⟶ f ≫ g counit : g ≫ f ⟶ 𝟙 b left_triangle : leftZigzag unit counit = (λ_ _).hom ≫ (ρ_ _).inv := by aesop_cat right_triangle : rightZigzag unit counit = (ρ_ _).hom ≫ (λ_ _).inv := by aesop_cat @[inherit_doc] scoped infixr:15 " ⊣ " => Bicategory.Adjunction namespace Adjunction attribute [simp] left_triangle right_triangle attribute [local simp] leftZigzag rightZigzag def id (a : B) : 𝟙 a ⊣ 𝟙 a where unit := (ρ_ _).inv counit := (ρ_ _).hom left_triangle := by dsimp; coherence right_triangle := by dsimp; coherence instance : Inhabited (Adjunction (𝟙 a) (𝟙 a)) := ⟨id a⟩ section Composition variable {f₁ : a ⟶ b} {g₁ : b ⟶ a} {f₂ : b ⟶ c} {g₂ : c ⟶ b} @[simp] def compUnit (adj₁ : f₁ ⊣ g₁) (adj₂ : f₂ ⊣ g₂) : 𝟙 a ⟶ (f₁ ≫ f₂) ≫ g₂ ≫ g₁ := adj₁.unit ⊗≫ f₁ ◁ adj₂.unit ▷ g₁ ⊗≫ 𝟙 _ @[simp] def compCounit (adj₁ : f₁ ⊣ g₁) (adj₂ : f₂ ⊣ g₂) : (g₂ ≫ g₁) ≫ f₁ ≫ f₂ ⟶ 𝟙 c := 𝟙 _ ⊗≫ g₂ ◁ adj₁.counit ▷ f₂ ⊗≫ adj₂.counit
Mathlib/CategoryTheory/Bicategory/Adjunction.lean
136
149
theorem comp_left_triangle_aux (adj₁ : f₁ ⊣ g₁) (adj₂ : f₂ ⊣ g₂) : leftZigzag (compUnit adj₁ adj₂) (compCounit adj₁ adj₂) = (λ_ _).hom ≫ (ρ_ _).inv := by
calc _ = 𝟙 _ ⊗≫ adj₁.unit ▷ (f₁ ≫ f₂) ⊗≫ f₁ ◁ (adj₂.unit ▷ (g₁ ≫ f₁) ≫ (f₂ ≫ g₂) ◁ adj₁.counit) ▷ f₂ ⊗≫ (f₁ ≫ f₂) ◁ adj₂.counit ⊗≫ 𝟙 _ := by simp [bicategoricalComp]; coherence _ = 𝟙 _ ⊗≫ (leftZigzag adj₁.unit adj₁.counit) ▷ f₂ ⊗≫ f₁ ◁ (leftZigzag adj₂.unit adj₂.counit) ⊗≫ 𝟙 _ := by rw [← whisker_exchange]; simp [bicategoricalComp]; coherence _ = _ := by simp_rw [left_triangle]; simp [bicategoricalComp]
699
import Mathlib.Tactic.CategoryTheory.Coherence import Mathlib.CategoryTheory.Bicategory.Coherence namespace CategoryTheory namespace Bicategory open Category open scoped Bicategory open Mathlib.Tactic.BicategoryCoherence (bicategoricalComp bicategoricalIsoComp) universe w v u variable {B : Type u} [Bicategory.{w, v} B] {a b c : B} {f : a ⟶ b} {g : b ⟶ a} def leftZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) := η ▷ f ⊗≫ f ◁ ε def rightZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) := g ◁ η ⊗≫ ε ▷ g theorem rightZigzag_idempotent_of_left_triangle (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) (h : leftZigzag η ε = (λ_ _).hom ≫ (ρ_ _).inv) : rightZigzag η ε ⊗≫ rightZigzag η ε = rightZigzag η ε := by dsimp only [rightZigzag] calc _ = g ◁ η ⊗≫ ((ε ▷ g ▷ 𝟙 a) ≫ (𝟙 b ≫ g) ◁ η) ⊗≫ ε ▷ g := by simp [bicategoricalComp]; coherence _ = 𝟙 _ ⊗≫ g ◁ (η ▷ 𝟙 a ≫ (f ≫ g) ◁ η) ⊗≫ (ε ▷ (g ≫ f) ≫ 𝟙 b ◁ ε) ▷ g ⊗≫ 𝟙 _ := by rw [← whisker_exchange]; simp [bicategoricalComp]; coherence _ = g ◁ η ⊗≫ g ◁ leftZigzag η ε ▷ g ⊗≫ ε ▷ g := by rw [← whisker_exchange, ← whisker_exchange]; simp [leftZigzag, bicategoricalComp]; coherence _ = g ◁ η ⊗≫ ε ▷ g := by rw [h]; simp [bicategoricalComp]; coherence structure Adjunction (f : a ⟶ b) (g : b ⟶ a) where unit : 𝟙 a ⟶ f ≫ g counit : g ≫ f ⟶ 𝟙 b left_triangle : leftZigzag unit counit = (λ_ _).hom ≫ (ρ_ _).inv := by aesop_cat right_triangle : rightZigzag unit counit = (ρ_ _).hom ≫ (λ_ _).inv := by aesop_cat @[inherit_doc] scoped infixr:15 " ⊣ " => Bicategory.Adjunction namespace Adjunction attribute [simp] left_triangle right_triangle attribute [local simp] leftZigzag rightZigzag def id (a : B) : 𝟙 a ⊣ 𝟙 a where unit := (ρ_ _).inv counit := (ρ_ _).hom left_triangle := by dsimp; coherence right_triangle := by dsimp; coherence instance : Inhabited (Adjunction (𝟙 a) (𝟙 a)) := ⟨id a⟩ section Composition variable {f₁ : a ⟶ b} {g₁ : b ⟶ a} {f₂ : b ⟶ c} {g₂ : c ⟶ b} @[simp] def compUnit (adj₁ : f₁ ⊣ g₁) (adj₂ : f₂ ⊣ g₂) : 𝟙 a ⟶ (f₁ ≫ f₂) ≫ g₂ ≫ g₁ := adj₁.unit ⊗≫ f₁ ◁ adj₂.unit ▷ g₁ ⊗≫ 𝟙 _ @[simp] def compCounit (adj₁ : f₁ ⊣ g₁) (adj₂ : f₂ ⊣ g₂) : (g₂ ≫ g₁) ≫ f₁ ≫ f₂ ⟶ 𝟙 c := 𝟙 _ ⊗≫ g₂ ◁ adj₁.counit ▷ f₂ ⊗≫ adj₂.counit theorem comp_left_triangle_aux (adj₁ : f₁ ⊣ g₁) (adj₂ : f₂ ⊣ g₂) : leftZigzag (compUnit adj₁ adj₂) (compCounit adj₁ adj₂) = (λ_ _).hom ≫ (ρ_ _).inv := by calc _ = 𝟙 _ ⊗≫ adj₁.unit ▷ (f₁ ≫ f₂) ⊗≫ f₁ ◁ (adj₂.unit ▷ (g₁ ≫ f₁) ≫ (f₂ ≫ g₂) ◁ adj₁.counit) ▷ f₂ ⊗≫ (f₁ ≫ f₂) ◁ adj₂.counit ⊗≫ 𝟙 _ := by simp [bicategoricalComp]; coherence _ = 𝟙 _ ⊗≫ (leftZigzag adj₁.unit adj₁.counit) ▷ f₂ ⊗≫ f₁ ◁ (leftZigzag adj₂.unit adj₂.counit) ⊗≫ 𝟙 _ := by rw [← whisker_exchange]; simp [bicategoricalComp]; coherence _ = _ := by simp_rw [left_triangle]; simp [bicategoricalComp]
Mathlib/CategoryTheory/Bicategory/Adjunction.lean
151
164
theorem comp_right_triangle_aux (adj₁ : f₁ ⊣ g₁) (adj₂ : f₂ ⊣ g₂) : rightZigzag (compUnit adj₁ adj₂) (compCounit adj₁ adj₂) = (ρ_ _).hom ≫ (λ_ _).inv := by
calc _ = 𝟙 _ ⊗≫ (g₂ ≫ g₁) ◁ adj₁.unit ⊗≫ g₂ ◁ ((g₁ ≫ f₁) ◁ adj₂.unit ≫ adj₁.counit ▷ (f₂ ≫ g₂)) ▷ g₁ ⊗≫ adj₂.counit ▷ (g₂ ≫ g₁) ⊗≫ 𝟙 _ := by simp [bicategoricalComp]; coherence _ = 𝟙 _ ⊗≫ g₂ ◁ (rightZigzag adj₁.unit adj₁.counit) ⊗≫ (rightZigzag adj₂.unit adj₂.counit) ▷ g₁ ⊗≫ 𝟙 _ := by rw [whisker_exchange]; simp [bicategoricalComp]; coherence _ = _ := by simp_rw [right_triangle]; simp [bicategoricalComp]
699
import Mathlib.Tactic.CategoryTheory.Coherence import Mathlib.CategoryTheory.Bicategory.Coherence namespace CategoryTheory namespace Bicategory open Category open scoped Bicategory open Mathlib.Tactic.BicategoryCoherence (bicategoricalComp bicategoricalIsoComp) universe w v u variable {B : Type u} [Bicategory.{w, v} B] {a b c : B} {f : a ⟶ b} {g : b ⟶ a} def leftZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) := η ▷ f ⊗≫ f ◁ ε def rightZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) := g ◁ η ⊗≫ ε ▷ g theorem rightZigzag_idempotent_of_left_triangle (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) (h : leftZigzag η ε = (λ_ _).hom ≫ (ρ_ _).inv) : rightZigzag η ε ⊗≫ rightZigzag η ε = rightZigzag η ε := by dsimp only [rightZigzag] calc _ = g ◁ η ⊗≫ ((ε ▷ g ▷ 𝟙 a) ≫ (𝟙 b ≫ g) ◁ η) ⊗≫ ε ▷ g := by simp [bicategoricalComp]; coherence _ = 𝟙 _ ⊗≫ g ◁ (η ▷ 𝟙 a ≫ (f ≫ g) ◁ η) ⊗≫ (ε ▷ (g ≫ f) ≫ 𝟙 b ◁ ε) ▷ g ⊗≫ 𝟙 _ := by rw [← whisker_exchange]; simp [bicategoricalComp]; coherence _ = g ◁ η ⊗≫ g ◁ leftZigzag η ε ▷ g ⊗≫ ε ▷ g := by rw [← whisker_exchange, ← whisker_exchange]; simp [leftZigzag, bicategoricalComp]; coherence _ = g ◁ η ⊗≫ ε ▷ g := by rw [h]; simp [bicategoricalComp]; coherence structure Adjunction (f : a ⟶ b) (g : b ⟶ a) where unit : 𝟙 a ⟶ f ≫ g counit : g ≫ f ⟶ 𝟙 b left_triangle : leftZigzag unit counit = (λ_ _).hom ≫ (ρ_ _).inv := by aesop_cat right_triangle : rightZigzag unit counit = (ρ_ _).hom ≫ (λ_ _).inv := by aesop_cat @[inherit_doc] scoped infixr:15 " ⊣ " => Bicategory.Adjunction namespace Adjunction attribute [simp] left_triangle right_triangle attribute [local simp] leftZigzag rightZigzag def id (a : B) : 𝟙 a ⊣ 𝟙 a where unit := (ρ_ _).inv counit := (ρ_ _).hom left_triangle := by dsimp; coherence right_triangle := by dsimp; coherence instance : Inhabited (Adjunction (𝟙 a) (𝟙 a)) := ⟨id a⟩ noncomputable section variable (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) def leftZigzagIso (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) := whiskerRightIso η f ≪⊗≫ whiskerLeftIso f ε def rightZigzagIso (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) := whiskerLeftIso g η ≪⊗≫ whiskerRightIso ε g attribute [local simp] leftZigzagIso rightZigzagIso leftZigzag rightZigzag @[simp] theorem leftZigzagIso_hom : (leftZigzagIso η ε).hom = leftZigzag η.hom ε.hom := rfl @[simp] theorem rightZigzagIso_hom : (rightZigzagIso η ε).hom = rightZigzag η.hom ε.hom := rfl @[simp]
Mathlib/CategoryTheory/Bicategory/Adjunction.lean
201
202
theorem leftZigzagIso_inv : (leftZigzagIso η ε).inv = rightZigzag ε.inv η.inv := by
simp [bicategoricalComp, bicategoricalIsoComp]
699
import Mathlib.Tactic.CategoryTheory.Coherence import Mathlib.CategoryTheory.Bicategory.Coherence namespace CategoryTheory namespace Bicategory open Category open scoped Bicategory open Mathlib.Tactic.BicategoryCoherence (bicategoricalComp bicategoricalIsoComp) universe w v u variable {B : Type u} [Bicategory.{w, v} B] {a b c : B} {f : a ⟶ b} {g : b ⟶ a} def leftZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) := η ▷ f ⊗≫ f ◁ ε def rightZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) := g ◁ η ⊗≫ ε ▷ g theorem rightZigzag_idempotent_of_left_triangle (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) (h : leftZigzag η ε = (λ_ _).hom ≫ (ρ_ _).inv) : rightZigzag η ε ⊗≫ rightZigzag η ε = rightZigzag η ε := by dsimp only [rightZigzag] calc _ = g ◁ η ⊗≫ ((ε ▷ g ▷ 𝟙 a) ≫ (𝟙 b ≫ g) ◁ η) ⊗≫ ε ▷ g := by simp [bicategoricalComp]; coherence _ = 𝟙 _ ⊗≫ g ◁ (η ▷ 𝟙 a ≫ (f ≫ g) ◁ η) ⊗≫ (ε ▷ (g ≫ f) ≫ 𝟙 b ◁ ε) ▷ g ⊗≫ 𝟙 _ := by rw [← whisker_exchange]; simp [bicategoricalComp]; coherence _ = g ◁ η ⊗≫ g ◁ leftZigzag η ε ▷ g ⊗≫ ε ▷ g := by rw [← whisker_exchange, ← whisker_exchange]; simp [leftZigzag, bicategoricalComp]; coherence _ = g ◁ η ⊗≫ ε ▷ g := by rw [h]; simp [bicategoricalComp]; coherence structure Adjunction (f : a ⟶ b) (g : b ⟶ a) where unit : 𝟙 a ⟶ f ≫ g counit : g ≫ f ⟶ 𝟙 b left_triangle : leftZigzag unit counit = (λ_ _).hom ≫ (ρ_ _).inv := by aesop_cat right_triangle : rightZigzag unit counit = (ρ_ _).hom ≫ (λ_ _).inv := by aesop_cat @[inherit_doc] scoped infixr:15 " ⊣ " => Bicategory.Adjunction namespace Adjunction attribute [simp] left_triangle right_triangle attribute [local simp] leftZigzag rightZigzag def id (a : B) : 𝟙 a ⊣ 𝟙 a where unit := (ρ_ _).inv counit := (ρ_ _).hom left_triangle := by dsimp; coherence right_triangle := by dsimp; coherence instance : Inhabited (Adjunction (𝟙 a) (𝟙 a)) := ⟨id a⟩ noncomputable section variable (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) def leftZigzagIso (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) := whiskerRightIso η f ≪⊗≫ whiskerLeftIso f ε def rightZigzagIso (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) := whiskerLeftIso g η ≪⊗≫ whiskerRightIso ε g attribute [local simp] leftZigzagIso rightZigzagIso leftZigzag rightZigzag @[simp] theorem leftZigzagIso_hom : (leftZigzagIso η ε).hom = leftZigzag η.hom ε.hom := rfl @[simp] theorem rightZigzagIso_hom : (rightZigzagIso η ε).hom = rightZigzag η.hom ε.hom := rfl @[simp] theorem leftZigzagIso_inv : (leftZigzagIso η ε).inv = rightZigzag ε.inv η.inv := by simp [bicategoricalComp, bicategoricalIsoComp] @[simp]
Mathlib/CategoryTheory/Bicategory/Adjunction.lean
205
206
theorem rightZigzagIso_inv : (rightZigzagIso η ε).inv = leftZigzag ε.inv η.inv := by
simp [bicategoricalComp, bicategoricalIsoComp]
699
import Mathlib.Tactic.CategoryTheory.Coherence import Mathlib.CategoryTheory.Bicategory.Coherence namespace CategoryTheory namespace Bicategory open Category open scoped Bicategory open Mathlib.Tactic.BicategoryCoherence (bicategoricalComp bicategoricalIsoComp) universe w v u variable {B : Type u} [Bicategory.{w, v} B] {a b c : B} {f : a ⟶ b} {g : b ⟶ a} def leftZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) := η ▷ f ⊗≫ f ◁ ε def rightZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) := g ◁ η ⊗≫ ε ▷ g theorem rightZigzag_idempotent_of_left_triangle (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) (h : leftZigzag η ε = (λ_ _).hom ≫ (ρ_ _).inv) : rightZigzag η ε ⊗≫ rightZigzag η ε = rightZigzag η ε := by dsimp only [rightZigzag] calc _ = g ◁ η ⊗≫ ((ε ▷ g ▷ 𝟙 a) ≫ (𝟙 b ≫ g) ◁ η) ⊗≫ ε ▷ g := by simp [bicategoricalComp]; coherence _ = 𝟙 _ ⊗≫ g ◁ (η ▷ 𝟙 a ≫ (f ≫ g) ◁ η) ⊗≫ (ε ▷ (g ≫ f) ≫ 𝟙 b ◁ ε) ▷ g ⊗≫ 𝟙 _ := by rw [← whisker_exchange]; simp [bicategoricalComp]; coherence _ = g ◁ η ⊗≫ g ◁ leftZigzag η ε ▷ g ⊗≫ ε ▷ g := by rw [← whisker_exchange, ← whisker_exchange]; simp [leftZigzag, bicategoricalComp]; coherence _ = g ◁ η ⊗≫ ε ▷ g := by rw [h]; simp [bicategoricalComp]; coherence structure Adjunction (f : a ⟶ b) (g : b ⟶ a) where unit : 𝟙 a ⟶ f ≫ g counit : g ≫ f ⟶ 𝟙 b left_triangle : leftZigzag unit counit = (λ_ _).hom ≫ (ρ_ _).inv := by aesop_cat right_triangle : rightZigzag unit counit = (ρ_ _).hom ≫ (λ_ _).inv := by aesop_cat @[inherit_doc] scoped infixr:15 " ⊣ " => Bicategory.Adjunction namespace Adjunction attribute [simp] left_triangle right_triangle attribute [local simp] leftZigzag rightZigzag def id (a : B) : 𝟙 a ⊣ 𝟙 a where unit := (ρ_ _).inv counit := (ρ_ _).hom left_triangle := by dsimp; coherence right_triangle := by dsimp; coherence instance : Inhabited (Adjunction (𝟙 a) (𝟙 a)) := ⟨id a⟩ noncomputable section variable (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) def leftZigzagIso (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) := whiskerRightIso η f ≪⊗≫ whiskerLeftIso f ε def rightZigzagIso (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) := whiskerLeftIso g η ≪⊗≫ whiskerRightIso ε g attribute [local simp] leftZigzagIso rightZigzagIso leftZigzag rightZigzag @[simp] theorem leftZigzagIso_hom : (leftZigzagIso η ε).hom = leftZigzag η.hom ε.hom := rfl @[simp] theorem rightZigzagIso_hom : (rightZigzagIso η ε).hom = rightZigzag η.hom ε.hom := rfl @[simp] theorem leftZigzagIso_inv : (leftZigzagIso η ε).inv = rightZigzag ε.inv η.inv := by simp [bicategoricalComp, bicategoricalIsoComp] @[simp] theorem rightZigzagIso_inv : (rightZigzagIso η ε).inv = leftZigzag ε.inv η.inv := by simp [bicategoricalComp, bicategoricalIsoComp] @[simp] theorem leftZigzagIso_symm : (leftZigzagIso η ε).symm = rightZigzagIso ε.symm η.symm := Iso.ext (leftZigzagIso_inv η ε) @[simp] theorem rightZigzagIso_symm : (rightZigzagIso η ε).symm = leftZigzagIso ε.symm η.symm := Iso.ext (rightZigzagIso_inv η ε) instance : IsIso (leftZigzag η.hom ε.hom) := inferInstanceAs <| IsIso (leftZigzagIso η ε).hom instance : IsIso (rightZigzag η.hom ε.hom) := inferInstanceAs <| IsIso (rightZigzagIso η ε).hom
Mathlib/CategoryTheory/Bicategory/Adjunction.lean
220
226
theorem right_triangle_of_left_triangle (h : leftZigzag η.hom ε.hom = (λ_ f).hom ≫ (ρ_ f).inv) : rightZigzag η.hom ε.hom = (ρ_ g).hom ≫ (λ_ g).inv := by
rw [← cancel_epi (rightZigzag η.hom ε.hom ≫ (λ_ g).hom ≫ (ρ_ g).inv)] calc _ = rightZigzag η.hom ε.hom ⊗≫ rightZigzag η.hom ε.hom := by coherence _ = rightZigzag η.hom ε.hom := rightZigzag_idempotent_of_left_triangle _ _ h _ = _ := by simp
699
import Mathlib.Tactic.CategoryTheory.Coherence import Mathlib.CategoryTheory.Bicategory.Coherence namespace CategoryTheory namespace Bicategory open Category open scoped Bicategory open Mathlib.Tactic.BicategoryCoherence (bicategoricalComp bicategoricalIsoComp) universe w v u variable {B : Type u} [Bicategory.{w, v} B] {a b c : B} {f : a ⟶ b} {g : b ⟶ a} def leftZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) := η ▷ f ⊗≫ f ◁ ε def rightZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) := g ◁ η ⊗≫ ε ▷ g theorem rightZigzag_idempotent_of_left_triangle (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) (h : leftZigzag η ε = (λ_ _).hom ≫ (ρ_ _).inv) : rightZigzag η ε ⊗≫ rightZigzag η ε = rightZigzag η ε := by dsimp only [rightZigzag] calc _ = g ◁ η ⊗≫ ((ε ▷ g ▷ 𝟙 a) ≫ (𝟙 b ≫ g) ◁ η) ⊗≫ ε ▷ g := by simp [bicategoricalComp]; coherence _ = 𝟙 _ ⊗≫ g ◁ (η ▷ 𝟙 a ≫ (f ≫ g) ◁ η) ⊗≫ (ε ▷ (g ≫ f) ≫ 𝟙 b ◁ ε) ▷ g ⊗≫ 𝟙 _ := by rw [← whisker_exchange]; simp [bicategoricalComp]; coherence _ = g ◁ η ⊗≫ g ◁ leftZigzag η ε ▷ g ⊗≫ ε ▷ g := by rw [← whisker_exchange, ← whisker_exchange]; simp [leftZigzag, bicategoricalComp]; coherence _ = g ◁ η ⊗≫ ε ▷ g := by rw [h]; simp [bicategoricalComp]; coherence structure Adjunction (f : a ⟶ b) (g : b ⟶ a) where unit : 𝟙 a ⟶ f ≫ g counit : g ≫ f ⟶ 𝟙 b left_triangle : leftZigzag unit counit = (λ_ _).hom ≫ (ρ_ _).inv := by aesop_cat right_triangle : rightZigzag unit counit = (ρ_ _).hom ≫ (λ_ _).inv := by aesop_cat @[inherit_doc] scoped infixr:15 " ⊣ " => Bicategory.Adjunction namespace Adjunction attribute [simp] left_triangle right_triangle attribute [local simp] leftZigzag rightZigzag def id (a : B) : 𝟙 a ⊣ 𝟙 a where unit := (ρ_ _).inv counit := (ρ_ _).hom left_triangle := by dsimp; coherence right_triangle := by dsimp; coherence instance : Inhabited (Adjunction (𝟙 a) (𝟙 a)) := ⟨id a⟩ noncomputable section variable (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) def leftZigzagIso (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) := whiskerRightIso η f ≪⊗≫ whiskerLeftIso f ε def rightZigzagIso (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) := whiskerLeftIso g η ≪⊗≫ whiskerRightIso ε g attribute [local simp] leftZigzagIso rightZigzagIso leftZigzag rightZigzag @[simp] theorem leftZigzagIso_hom : (leftZigzagIso η ε).hom = leftZigzag η.hom ε.hom := rfl @[simp] theorem rightZigzagIso_hom : (rightZigzagIso η ε).hom = rightZigzag η.hom ε.hom := rfl @[simp] theorem leftZigzagIso_inv : (leftZigzagIso η ε).inv = rightZigzag ε.inv η.inv := by simp [bicategoricalComp, bicategoricalIsoComp] @[simp] theorem rightZigzagIso_inv : (rightZigzagIso η ε).inv = leftZigzag ε.inv η.inv := by simp [bicategoricalComp, bicategoricalIsoComp] @[simp] theorem leftZigzagIso_symm : (leftZigzagIso η ε).symm = rightZigzagIso ε.symm η.symm := Iso.ext (leftZigzagIso_inv η ε) @[simp] theorem rightZigzagIso_symm : (rightZigzagIso η ε).symm = leftZigzagIso ε.symm η.symm := Iso.ext (rightZigzagIso_inv η ε) instance : IsIso (leftZigzag η.hom ε.hom) := inferInstanceAs <| IsIso (leftZigzagIso η ε).hom instance : IsIso (rightZigzag η.hom ε.hom) := inferInstanceAs <| IsIso (rightZigzagIso η ε).hom theorem right_triangle_of_left_triangle (h : leftZigzag η.hom ε.hom = (λ_ f).hom ≫ (ρ_ f).inv) : rightZigzag η.hom ε.hom = (ρ_ g).hom ≫ (λ_ g).inv := by rw [← cancel_epi (rightZigzag η.hom ε.hom ≫ (λ_ g).hom ≫ (ρ_ g).inv)] calc _ = rightZigzag η.hom ε.hom ⊗≫ rightZigzag η.hom ε.hom := by coherence _ = rightZigzag η.hom ε.hom := rightZigzag_idempotent_of_left_triangle _ _ h _ = _ := by simp def adjointifyCounit (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) : g ≫ f ≅ 𝟙 b := whiskerLeftIso g ((ρ_ f).symm ≪≫ rightZigzagIso ε.symm η.symm ≪≫ λ_ f) ≪≫ ε
Mathlib/CategoryTheory/Bicategory/Adjunction.lean
232
247
theorem adjointifyCounit_left_triangle (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) : leftZigzagIso η (adjointifyCounit η ε) = λ_ f ≪≫ (ρ_ f).symm := by
apply Iso.ext dsimp [adjointifyCounit, bicategoricalIsoComp] calc _ = 𝟙 _ ⊗≫ (η.hom ▷ (f ≫ 𝟙 b) ≫ (f ≫ g) ◁ f ◁ ε.inv) ⊗≫ f ◁ g ◁ η.inv ▷ f ⊗≫ f ◁ ε.hom := by simp [bicategoricalComp]; coherence _ = 𝟙 _ ⊗≫ f ◁ ε.inv ⊗≫ (η.hom ▷ (f ≫ g) ≫ (f ≫ g) ◁ η.inv) ▷ f ⊗≫ f ◁ ε.hom := by rw [← whisker_exchange η.hom (f ◁ ε.inv)]; simp [bicategoricalComp]; coherence _ = 𝟙 _ ⊗≫ f ◁ ε.inv ⊗≫ (η.inv ≫ η.hom) ▷ f ⊗≫ f ◁ ε.hom := by rw [← whisker_exchange η.hom η.inv]; coherence _ = 𝟙 _ ⊗≫ f ◁ (ε.inv ≫ ε.hom) := by rw [Iso.inv_hom_id]; simp [bicategoricalComp] _ = _ := by rw [Iso.inv_hom_id]; simp [bicategoricalComp]
699
import Mathlib.SetTheory.Cardinal.ToNat import Mathlib.Data.Nat.PartENat #align_import set_theory.cardinal.basic from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8" universe u v open Function variable {α : Type u} namespace Cardinal noncomputable def toPartENat : Cardinal →+o PartENat := .comp { (PartENat.withTopAddEquiv.symm : ℕ∞ →+ PartENat), (PartENat.withTopOrderIso.symm : ℕ∞ →o PartENat) with } toENat #align cardinal.to_part_enat Cardinal.toPartENat @[simp] theorem partENatOfENat_toENat (c : Cardinal) : (toENat c : PartENat) = toPartENat c := rfl @[simp]
Mathlib/SetTheory/Cardinal/PartENat.lean
39
40
theorem toPartENat_natCast (n : ℕ) : toPartENat n = n := by
simp only [← partENatOfENat_toENat, toENat_nat, PartENat.ofENat_coe]
700
import Mathlib.SetTheory.Cardinal.ToNat import Mathlib.Data.Nat.PartENat #align_import set_theory.cardinal.basic from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8" universe u v open Function variable {α : Type u} namespace Cardinal noncomputable def toPartENat : Cardinal →+o PartENat := .comp { (PartENat.withTopAddEquiv.symm : ℕ∞ →+ PartENat), (PartENat.withTopOrderIso.symm : ℕ∞ →o PartENat) with } toENat #align cardinal.to_part_enat Cardinal.toPartENat @[simp] theorem partENatOfENat_toENat (c : Cardinal) : (toENat c : PartENat) = toPartENat c := rfl @[simp] theorem toPartENat_natCast (n : ℕ) : toPartENat n = n := by simp only [← partENatOfENat_toENat, toENat_nat, PartENat.ofENat_coe] #align cardinal.to_part_enat_cast Cardinal.toPartENat_natCast
Mathlib/SetTheory/Cardinal/PartENat.lean
43
44
theorem toPartENat_apply_of_lt_aleph0 {c : Cardinal} (h : c < ℵ₀) : toPartENat c = toNat c := by
lift c to ℕ using h; simp
700
import Mathlib.SetTheory.Cardinal.ToNat import Mathlib.Data.Nat.PartENat #align_import set_theory.cardinal.basic from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8" universe u v open Function variable {α : Type u} namespace Cardinal noncomputable def toPartENat : Cardinal →+o PartENat := .comp { (PartENat.withTopAddEquiv.symm : ℕ∞ →+ PartENat), (PartENat.withTopOrderIso.symm : ℕ∞ →o PartENat) with } toENat #align cardinal.to_part_enat Cardinal.toPartENat @[simp] theorem partENatOfENat_toENat (c : Cardinal) : (toENat c : PartENat) = toPartENat c := rfl @[simp] theorem toPartENat_natCast (n : ℕ) : toPartENat n = n := by simp only [← partENatOfENat_toENat, toENat_nat, PartENat.ofENat_coe] #align cardinal.to_part_enat_cast Cardinal.toPartENat_natCast theorem toPartENat_apply_of_lt_aleph0 {c : Cardinal} (h : c < ℵ₀) : toPartENat c = toNat c := by lift c to ℕ using h; simp #align cardinal.to_part_enat_apply_of_lt_aleph_0 Cardinal.toPartENat_apply_of_lt_aleph0
Mathlib/SetTheory/Cardinal/PartENat.lean
47
51
theorem toPartENat_eq_top {c : Cardinal} : toPartENat c = ⊤ ↔ ℵ₀ ≤ c := by
rw [← partENatOfENat_toENat, ← PartENat.withTopEquiv_symm_top, ← toENat_eq_top, ← PartENat.withTopEquiv.symm.injective.eq_iff] simp
700
import Mathlib.SetTheory.Cardinal.ToNat import Mathlib.Data.Nat.PartENat #align_import set_theory.cardinal.basic from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8" universe u v open Function variable {α : Type u} namespace Cardinal noncomputable def toPartENat : Cardinal →+o PartENat := .comp { (PartENat.withTopAddEquiv.symm : ℕ∞ →+ PartENat), (PartENat.withTopOrderIso.symm : ℕ∞ →o PartENat) with } toENat #align cardinal.to_part_enat Cardinal.toPartENat @[simp] theorem partENatOfENat_toENat (c : Cardinal) : (toENat c : PartENat) = toPartENat c := rfl @[simp] theorem toPartENat_natCast (n : ℕ) : toPartENat n = n := by simp only [← partENatOfENat_toENat, toENat_nat, PartENat.ofENat_coe] #align cardinal.to_part_enat_cast Cardinal.toPartENat_natCast theorem toPartENat_apply_of_lt_aleph0 {c : Cardinal} (h : c < ℵ₀) : toPartENat c = toNat c := by lift c to ℕ using h; simp #align cardinal.to_part_enat_apply_of_lt_aleph_0 Cardinal.toPartENat_apply_of_lt_aleph0 theorem toPartENat_eq_top {c : Cardinal} : toPartENat c = ⊤ ↔ ℵ₀ ≤ c := by rw [← partENatOfENat_toENat, ← PartENat.withTopEquiv_symm_top, ← toENat_eq_top, ← PartENat.withTopEquiv.symm.injective.eq_iff] simp #align to_part_enat_eq_top_iff_le_aleph_0 Cardinal.toPartENat_eq_top theorem toPartENat_apply_of_aleph0_le {c : Cardinal} (h : ℵ₀ ≤ c) : toPartENat c = ⊤ := congr_arg PartENat.ofENat (toENat_eq_top.2 h) #align cardinal.to_part_enat_apply_of_aleph_0_le Cardinal.toPartENat_apply_of_aleph0_le @[deprecated (since := "2024-02-15")] alias toPartENat_cast := toPartENat_natCast @[simp] theorem mk_toPartENat_of_infinite [h : Infinite α] : toPartENat #α = ⊤ := toPartENat_apply_of_aleph0_le (infinite_iff.1 h) #align cardinal.mk_to_part_enat_of_infinite Cardinal.mk_toPartENat_of_infinite @[simp] theorem aleph0_toPartENat : toPartENat ℵ₀ = ⊤ := toPartENat_apply_of_aleph0_le le_rfl #align cardinal.aleph_0_to_part_enat Cardinal.aleph0_toPartENat theorem toPartENat_surjective : Surjective toPartENat := fun x => PartENat.casesOn x ⟨ℵ₀, toPartENat_apply_of_aleph0_le le_rfl⟩ fun n => ⟨n, toPartENat_natCast n⟩ #align cardinal.to_part_enat_surjective Cardinal.toPartENat_surjective @[deprecated (since := "2024-02-15")] alias toPartENat_eq_top_iff_le_aleph0 := toPartENat_eq_top theorem toPartENat_strictMonoOn : StrictMonoOn toPartENat (Set.Iic ℵ₀) := PartENat.withTopOrderIso.symm.strictMono.comp_strictMonoOn toENat_strictMonoOn lemma toPartENat_le_iff_of_le_aleph0 {c c' : Cardinal} (h : c ≤ ℵ₀) : toPartENat c ≤ toPartENat c' ↔ c ≤ c' := by lift c to ℕ∞ using h simp_rw [← partENatOfENat_toENat, toENat_ofENat, enat_gc _, ← PartENat.withTopOrderIso.symm.le_iff_le, PartENat.ofENat_le, map_le_map_iff] #align to_part_enat_le_iff_le_of_le_aleph_0 Cardinal.toPartENat_le_iff_of_le_aleph0 lemma toPartENat_le_iff_of_lt_aleph0 {c c' : Cardinal} (hc' : c' < ℵ₀) : toPartENat c ≤ toPartENat c' ↔ c ≤ c' := by lift c' to ℕ using hc' simp_rw [← partENatOfENat_toENat, toENat_nat, ← toENat_le_nat, ← PartENat.withTopOrderIso.symm.le_iff_le, PartENat.ofENat_le, map_le_map_iff] #align to_part_enat_le_iff_le_of_lt_aleph_0 Cardinal.toPartENat_le_iff_of_lt_aleph0 lemma toPartENat_eq_iff_of_le_aleph0 {c c' : Cardinal} (hc : c ≤ ℵ₀) (hc' : c' ≤ ℵ₀) : toPartENat c = toPartENat c' ↔ c = c' := toPartENat_strictMonoOn.injOn.eq_iff hc hc' #align to_part_enat_eq_iff_eq_of_le_aleph_0 Cardinal.toPartENat_eq_iff_of_le_aleph0 theorem toPartENat_mono {c c' : Cardinal} (h : c ≤ c') : toPartENat c ≤ toPartENat c' := OrderHomClass.mono _ h #align cardinal.to_part_enat_mono Cardinal.toPartENat_mono
Mathlib/SetTheory/Cardinal/PartENat.lean
104
105
theorem toPartENat_lift (c : Cardinal.{v}) : toPartENat (lift.{u, v} c) = toPartENat c := by
simp only [← partENatOfENat_toENat, toENat_lift]
700
import Mathlib.SetTheory.Cardinal.ToNat import Mathlib.Data.Nat.PartENat #align_import set_theory.cardinal.basic from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8" universe u v open Function variable {α : Type u} namespace Cardinal noncomputable def toPartENat : Cardinal →+o PartENat := .comp { (PartENat.withTopAddEquiv.symm : ℕ∞ →+ PartENat), (PartENat.withTopOrderIso.symm : ℕ∞ →o PartENat) with } toENat #align cardinal.to_part_enat Cardinal.toPartENat @[simp] theorem partENatOfENat_toENat (c : Cardinal) : (toENat c : PartENat) = toPartENat c := rfl @[simp] theorem toPartENat_natCast (n : ℕ) : toPartENat n = n := by simp only [← partENatOfENat_toENat, toENat_nat, PartENat.ofENat_coe] #align cardinal.to_part_enat_cast Cardinal.toPartENat_natCast theorem toPartENat_apply_of_lt_aleph0 {c : Cardinal} (h : c < ℵ₀) : toPartENat c = toNat c := by lift c to ℕ using h; simp #align cardinal.to_part_enat_apply_of_lt_aleph_0 Cardinal.toPartENat_apply_of_lt_aleph0 theorem toPartENat_eq_top {c : Cardinal} : toPartENat c = ⊤ ↔ ℵ₀ ≤ c := by rw [← partENatOfENat_toENat, ← PartENat.withTopEquiv_symm_top, ← toENat_eq_top, ← PartENat.withTopEquiv.symm.injective.eq_iff] simp #align to_part_enat_eq_top_iff_le_aleph_0 Cardinal.toPartENat_eq_top theorem toPartENat_apply_of_aleph0_le {c : Cardinal} (h : ℵ₀ ≤ c) : toPartENat c = ⊤ := congr_arg PartENat.ofENat (toENat_eq_top.2 h) #align cardinal.to_part_enat_apply_of_aleph_0_le Cardinal.toPartENat_apply_of_aleph0_le @[deprecated (since := "2024-02-15")] alias toPartENat_cast := toPartENat_natCast @[simp] theorem mk_toPartENat_of_infinite [h : Infinite α] : toPartENat #α = ⊤ := toPartENat_apply_of_aleph0_le (infinite_iff.1 h) #align cardinal.mk_to_part_enat_of_infinite Cardinal.mk_toPartENat_of_infinite @[simp] theorem aleph0_toPartENat : toPartENat ℵ₀ = ⊤ := toPartENat_apply_of_aleph0_le le_rfl #align cardinal.aleph_0_to_part_enat Cardinal.aleph0_toPartENat theorem toPartENat_surjective : Surjective toPartENat := fun x => PartENat.casesOn x ⟨ℵ₀, toPartENat_apply_of_aleph0_le le_rfl⟩ fun n => ⟨n, toPartENat_natCast n⟩ #align cardinal.to_part_enat_surjective Cardinal.toPartENat_surjective @[deprecated (since := "2024-02-15")] alias toPartENat_eq_top_iff_le_aleph0 := toPartENat_eq_top theorem toPartENat_strictMonoOn : StrictMonoOn toPartENat (Set.Iic ℵ₀) := PartENat.withTopOrderIso.symm.strictMono.comp_strictMonoOn toENat_strictMonoOn lemma toPartENat_le_iff_of_le_aleph0 {c c' : Cardinal} (h : c ≤ ℵ₀) : toPartENat c ≤ toPartENat c' ↔ c ≤ c' := by lift c to ℕ∞ using h simp_rw [← partENatOfENat_toENat, toENat_ofENat, enat_gc _, ← PartENat.withTopOrderIso.symm.le_iff_le, PartENat.ofENat_le, map_le_map_iff] #align to_part_enat_le_iff_le_of_le_aleph_0 Cardinal.toPartENat_le_iff_of_le_aleph0 lemma toPartENat_le_iff_of_lt_aleph0 {c c' : Cardinal} (hc' : c' < ℵ₀) : toPartENat c ≤ toPartENat c' ↔ c ≤ c' := by lift c' to ℕ using hc' simp_rw [← partENatOfENat_toENat, toENat_nat, ← toENat_le_nat, ← PartENat.withTopOrderIso.symm.le_iff_le, PartENat.ofENat_le, map_le_map_iff] #align to_part_enat_le_iff_le_of_lt_aleph_0 Cardinal.toPartENat_le_iff_of_lt_aleph0 lemma toPartENat_eq_iff_of_le_aleph0 {c c' : Cardinal} (hc : c ≤ ℵ₀) (hc' : c' ≤ ℵ₀) : toPartENat c = toPartENat c' ↔ c = c' := toPartENat_strictMonoOn.injOn.eq_iff hc hc' #align to_part_enat_eq_iff_eq_of_le_aleph_0 Cardinal.toPartENat_eq_iff_of_le_aleph0 theorem toPartENat_mono {c c' : Cardinal} (h : c ≤ c') : toPartENat c ≤ toPartENat c' := OrderHomClass.mono _ h #align cardinal.to_part_enat_mono Cardinal.toPartENat_mono theorem toPartENat_lift (c : Cardinal.{v}) : toPartENat (lift.{u, v} c) = toPartENat c := by simp only [← partENatOfENat_toENat, toENat_lift] #align cardinal.to_part_enat_lift Cardinal.toPartENat_lift
Mathlib/SetTheory/Cardinal/PartENat.lean
108
109
theorem toPartENat_congr {β : Type v} (e : α ≃ β) : toPartENat #α = toPartENat #β := by
rw [← toPartENat_lift, lift_mk_eq.{_, _,v}.mpr ⟨e⟩, toPartENat_lift]
700
import Mathlib.SetTheory.Cardinal.ToNat import Mathlib.Data.Nat.PartENat #align_import set_theory.cardinal.basic from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8" universe u v open Function variable {α : Type u} namespace Cardinal noncomputable def toPartENat : Cardinal →+o PartENat := .comp { (PartENat.withTopAddEquiv.symm : ℕ∞ →+ PartENat), (PartENat.withTopOrderIso.symm : ℕ∞ →o PartENat) with } toENat #align cardinal.to_part_enat Cardinal.toPartENat @[simp] theorem partENatOfENat_toENat (c : Cardinal) : (toENat c : PartENat) = toPartENat c := rfl @[simp] theorem toPartENat_natCast (n : ℕ) : toPartENat n = n := by simp only [← partENatOfENat_toENat, toENat_nat, PartENat.ofENat_coe] #align cardinal.to_part_enat_cast Cardinal.toPartENat_natCast theorem toPartENat_apply_of_lt_aleph0 {c : Cardinal} (h : c < ℵ₀) : toPartENat c = toNat c := by lift c to ℕ using h; simp #align cardinal.to_part_enat_apply_of_lt_aleph_0 Cardinal.toPartENat_apply_of_lt_aleph0 theorem toPartENat_eq_top {c : Cardinal} : toPartENat c = ⊤ ↔ ℵ₀ ≤ c := by rw [← partENatOfENat_toENat, ← PartENat.withTopEquiv_symm_top, ← toENat_eq_top, ← PartENat.withTopEquiv.symm.injective.eq_iff] simp #align to_part_enat_eq_top_iff_le_aleph_0 Cardinal.toPartENat_eq_top theorem toPartENat_apply_of_aleph0_le {c : Cardinal} (h : ℵ₀ ≤ c) : toPartENat c = ⊤ := congr_arg PartENat.ofENat (toENat_eq_top.2 h) #align cardinal.to_part_enat_apply_of_aleph_0_le Cardinal.toPartENat_apply_of_aleph0_le @[deprecated (since := "2024-02-15")] alias toPartENat_cast := toPartENat_natCast @[simp] theorem mk_toPartENat_of_infinite [h : Infinite α] : toPartENat #α = ⊤ := toPartENat_apply_of_aleph0_le (infinite_iff.1 h) #align cardinal.mk_to_part_enat_of_infinite Cardinal.mk_toPartENat_of_infinite @[simp] theorem aleph0_toPartENat : toPartENat ℵ₀ = ⊤ := toPartENat_apply_of_aleph0_le le_rfl #align cardinal.aleph_0_to_part_enat Cardinal.aleph0_toPartENat theorem toPartENat_surjective : Surjective toPartENat := fun x => PartENat.casesOn x ⟨ℵ₀, toPartENat_apply_of_aleph0_le le_rfl⟩ fun n => ⟨n, toPartENat_natCast n⟩ #align cardinal.to_part_enat_surjective Cardinal.toPartENat_surjective @[deprecated (since := "2024-02-15")] alias toPartENat_eq_top_iff_le_aleph0 := toPartENat_eq_top theorem toPartENat_strictMonoOn : StrictMonoOn toPartENat (Set.Iic ℵ₀) := PartENat.withTopOrderIso.symm.strictMono.comp_strictMonoOn toENat_strictMonoOn lemma toPartENat_le_iff_of_le_aleph0 {c c' : Cardinal} (h : c ≤ ℵ₀) : toPartENat c ≤ toPartENat c' ↔ c ≤ c' := by lift c to ℕ∞ using h simp_rw [← partENatOfENat_toENat, toENat_ofENat, enat_gc _, ← PartENat.withTopOrderIso.symm.le_iff_le, PartENat.ofENat_le, map_le_map_iff] #align to_part_enat_le_iff_le_of_le_aleph_0 Cardinal.toPartENat_le_iff_of_le_aleph0 lemma toPartENat_le_iff_of_lt_aleph0 {c c' : Cardinal} (hc' : c' < ℵ₀) : toPartENat c ≤ toPartENat c' ↔ c ≤ c' := by lift c' to ℕ using hc' simp_rw [← partENatOfENat_toENat, toENat_nat, ← toENat_le_nat, ← PartENat.withTopOrderIso.symm.le_iff_le, PartENat.ofENat_le, map_le_map_iff] #align to_part_enat_le_iff_le_of_lt_aleph_0 Cardinal.toPartENat_le_iff_of_lt_aleph0 lemma toPartENat_eq_iff_of_le_aleph0 {c c' : Cardinal} (hc : c ≤ ℵ₀) (hc' : c' ≤ ℵ₀) : toPartENat c = toPartENat c' ↔ c = c' := toPartENat_strictMonoOn.injOn.eq_iff hc hc' #align to_part_enat_eq_iff_eq_of_le_aleph_0 Cardinal.toPartENat_eq_iff_of_le_aleph0 theorem toPartENat_mono {c c' : Cardinal} (h : c ≤ c') : toPartENat c ≤ toPartENat c' := OrderHomClass.mono _ h #align cardinal.to_part_enat_mono Cardinal.toPartENat_mono theorem toPartENat_lift (c : Cardinal.{v}) : toPartENat (lift.{u, v} c) = toPartENat c := by simp only [← partENatOfENat_toENat, toENat_lift] #align cardinal.to_part_enat_lift Cardinal.toPartENat_lift theorem toPartENat_congr {β : Type v} (e : α ≃ β) : toPartENat #α = toPartENat #β := by rw [← toPartENat_lift, lift_mk_eq.{_, _,v}.mpr ⟨e⟩, toPartENat_lift] #align cardinal.to_part_enat_congr Cardinal.toPartENat_congr
Mathlib/SetTheory/Cardinal/PartENat.lean
112
113
theorem mk_toPartENat_eq_coe_card [Fintype α] : toPartENat #α = Fintype.card α := by
simp
700
import Mathlib.Data.Set.Basic open Function universe u v namespace Set section Subsingleton variable {α : Type u} {a : α} {s t : Set α} protected def Subsingleton (s : Set α) : Prop := ∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s), x = y #align set.subsingleton Set.Subsingleton theorem Subsingleton.anti (ht : t.Subsingleton) (hst : s ⊆ t) : s.Subsingleton := fun _ hx _ hy => ht (hst hx) (hst hy) #align set.subsingleton.anti Set.Subsingleton.anti theorem Subsingleton.eq_singleton_of_mem (hs : s.Subsingleton) {x : α} (hx : x ∈ s) : s = {x} := ext fun _ => ⟨fun hy => hs hx hy ▸ mem_singleton _, fun hy => (eq_of_mem_singleton hy).symm ▸ hx⟩ #align set.subsingleton.eq_singleton_of_mem Set.Subsingleton.eq_singleton_of_mem @[simp] theorem subsingleton_empty : (∅ : Set α).Subsingleton := fun _ => False.elim #align set.subsingleton_empty Set.subsingleton_empty @[simp] theorem subsingleton_singleton {a} : ({a} : Set α).Subsingleton := fun _ hx _ hy => (eq_of_mem_singleton hx).symm ▸ (eq_of_mem_singleton hy).symm ▸ rfl #align set.subsingleton_singleton Set.subsingleton_singleton theorem subsingleton_of_subset_singleton (h : s ⊆ {a}) : s.Subsingleton := subsingleton_singleton.anti h #align set.subsingleton_of_subset_singleton Set.subsingleton_of_subset_singleton theorem subsingleton_of_forall_eq (a : α) (h : ∀ b ∈ s, b = a) : s.Subsingleton := fun _ hb _ hc => (h _ hb).trans (h _ hc).symm #align set.subsingleton_of_forall_eq Set.subsingleton_of_forall_eq theorem subsingleton_iff_singleton {x} (hx : x ∈ s) : s.Subsingleton ↔ s = {x} := ⟨fun h => h.eq_singleton_of_mem hx, fun h => h.symm ▸ subsingleton_singleton⟩ #align set.subsingleton_iff_singleton Set.subsingleton_iff_singleton theorem Subsingleton.eq_empty_or_singleton (hs : s.Subsingleton) : s = ∅ ∨ ∃ x, s = {x} := s.eq_empty_or_nonempty.elim Or.inl fun ⟨x, hx⟩ => Or.inr ⟨x, hs.eq_singleton_of_mem hx⟩ #align set.subsingleton.eq_empty_or_singleton Set.Subsingleton.eq_empty_or_singleton
Mathlib/Data/Set/Subsingleton.lean
68
71
theorem Subsingleton.induction_on {p : Set α → Prop} (hs : s.Subsingleton) (he : p ∅) (h₁ : ∀ x, p {x}) : p s := by
rcases hs.eq_empty_or_singleton with (rfl | ⟨x, rfl⟩) exacts [he, h₁ _]
701
import Mathlib.Data.Set.Basic open Function universe u v namespace Set section Subsingleton variable {α : Type u} {a : α} {s t : Set α} protected def Subsingleton (s : Set α) : Prop := ∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s), x = y #align set.subsingleton Set.Subsingleton theorem Subsingleton.anti (ht : t.Subsingleton) (hst : s ⊆ t) : s.Subsingleton := fun _ hx _ hy => ht (hst hx) (hst hy) #align set.subsingleton.anti Set.Subsingleton.anti theorem Subsingleton.eq_singleton_of_mem (hs : s.Subsingleton) {x : α} (hx : x ∈ s) : s = {x} := ext fun _ => ⟨fun hy => hs hx hy ▸ mem_singleton _, fun hy => (eq_of_mem_singleton hy).symm ▸ hx⟩ #align set.subsingleton.eq_singleton_of_mem Set.Subsingleton.eq_singleton_of_mem @[simp] theorem subsingleton_empty : (∅ : Set α).Subsingleton := fun _ => False.elim #align set.subsingleton_empty Set.subsingleton_empty @[simp] theorem subsingleton_singleton {a} : ({a} : Set α).Subsingleton := fun _ hx _ hy => (eq_of_mem_singleton hx).symm ▸ (eq_of_mem_singleton hy).symm ▸ rfl #align set.subsingleton_singleton Set.subsingleton_singleton theorem subsingleton_of_subset_singleton (h : s ⊆ {a}) : s.Subsingleton := subsingleton_singleton.anti h #align set.subsingleton_of_subset_singleton Set.subsingleton_of_subset_singleton theorem subsingleton_of_forall_eq (a : α) (h : ∀ b ∈ s, b = a) : s.Subsingleton := fun _ hb _ hc => (h _ hb).trans (h _ hc).symm #align set.subsingleton_of_forall_eq Set.subsingleton_of_forall_eq theorem subsingleton_iff_singleton {x} (hx : x ∈ s) : s.Subsingleton ↔ s = {x} := ⟨fun h => h.eq_singleton_of_mem hx, fun h => h.symm ▸ subsingleton_singleton⟩ #align set.subsingleton_iff_singleton Set.subsingleton_iff_singleton theorem Subsingleton.eq_empty_or_singleton (hs : s.Subsingleton) : s = ∅ ∨ ∃ x, s = {x} := s.eq_empty_or_nonempty.elim Or.inl fun ⟨x, hx⟩ => Or.inr ⟨x, hs.eq_singleton_of_mem hx⟩ #align set.subsingleton.eq_empty_or_singleton Set.Subsingleton.eq_empty_or_singleton theorem Subsingleton.induction_on {p : Set α → Prop} (hs : s.Subsingleton) (he : p ∅) (h₁ : ∀ x, p {x}) : p s := by rcases hs.eq_empty_or_singleton with (rfl | ⟨x, rfl⟩) exacts [he, h₁ _] #align set.subsingleton.induction_on Set.Subsingleton.induction_on theorem subsingleton_univ [Subsingleton α] : (univ : Set α).Subsingleton := fun x _ y _ => Subsingleton.elim x y #align set.subsingleton_univ Set.subsingleton_univ theorem subsingleton_of_univ_subsingleton (h : (univ : Set α).Subsingleton) : Subsingleton α := ⟨fun a b => h (mem_univ a) (mem_univ b)⟩ #align set.subsingleton_of_univ_subsingleton Set.subsingleton_of_univ_subsingleton @[simp] theorem subsingleton_univ_iff : (univ : Set α).Subsingleton ↔ Subsingleton α := ⟨subsingleton_of_univ_subsingleton, fun h => @subsingleton_univ _ h⟩ #align set.subsingleton_univ_iff Set.subsingleton_univ_iff theorem subsingleton_of_subsingleton [Subsingleton α] {s : Set α} : Set.Subsingleton s := subsingleton_univ.anti (subset_univ s) #align set.subsingleton_of_subsingleton Set.subsingleton_of_subsingleton theorem subsingleton_isTop (α : Type*) [PartialOrder α] : Set.Subsingleton { x : α | IsTop x } := fun x hx _ hy => hx.isMax.eq_of_le (hy x) #align set.subsingleton_is_top Set.subsingleton_isTop theorem subsingleton_isBot (α : Type*) [PartialOrder α] : Set.Subsingleton { x : α | IsBot x } := fun x hx _ hy => hx.isMin.eq_of_ge (hy x) #align set.subsingleton_is_bot Set.subsingleton_isBot
Mathlib/Data/Set/Subsingleton.lean
99
104
theorem exists_eq_singleton_iff_nonempty_subsingleton : (∃ a : α, s = {a}) ↔ s.Nonempty ∧ s.Subsingleton := by
refine ⟨?_, fun h => ?_⟩ · rintro ⟨a, rfl⟩ exact ⟨singleton_nonempty a, subsingleton_singleton⟩ · exact h.2.eq_empty_or_singleton.resolve_left h.1.ne_empty
701
import Mathlib.Data.Set.Basic open Function universe u v namespace Set section Subsingleton variable {α : Type u} {a : α} {s t : Set α} protected def Subsingleton (s : Set α) : Prop := ∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s), x = y #align set.subsingleton Set.Subsingleton theorem Subsingleton.anti (ht : t.Subsingleton) (hst : s ⊆ t) : s.Subsingleton := fun _ hx _ hy => ht (hst hx) (hst hy) #align set.subsingleton.anti Set.Subsingleton.anti theorem Subsingleton.eq_singleton_of_mem (hs : s.Subsingleton) {x : α} (hx : x ∈ s) : s = {x} := ext fun _ => ⟨fun hy => hs hx hy ▸ mem_singleton _, fun hy => (eq_of_mem_singleton hy).symm ▸ hx⟩ #align set.subsingleton.eq_singleton_of_mem Set.Subsingleton.eq_singleton_of_mem @[simp] theorem subsingleton_empty : (∅ : Set α).Subsingleton := fun _ => False.elim #align set.subsingleton_empty Set.subsingleton_empty @[simp] theorem subsingleton_singleton {a} : ({a} : Set α).Subsingleton := fun _ hx _ hy => (eq_of_mem_singleton hx).symm ▸ (eq_of_mem_singleton hy).symm ▸ rfl #align set.subsingleton_singleton Set.subsingleton_singleton theorem subsingleton_of_subset_singleton (h : s ⊆ {a}) : s.Subsingleton := subsingleton_singleton.anti h #align set.subsingleton_of_subset_singleton Set.subsingleton_of_subset_singleton theorem subsingleton_of_forall_eq (a : α) (h : ∀ b ∈ s, b = a) : s.Subsingleton := fun _ hb _ hc => (h _ hb).trans (h _ hc).symm #align set.subsingleton_of_forall_eq Set.subsingleton_of_forall_eq theorem subsingleton_iff_singleton {x} (hx : x ∈ s) : s.Subsingleton ↔ s = {x} := ⟨fun h => h.eq_singleton_of_mem hx, fun h => h.symm ▸ subsingleton_singleton⟩ #align set.subsingleton_iff_singleton Set.subsingleton_iff_singleton theorem Subsingleton.eq_empty_or_singleton (hs : s.Subsingleton) : s = ∅ ∨ ∃ x, s = {x} := s.eq_empty_or_nonempty.elim Or.inl fun ⟨x, hx⟩ => Or.inr ⟨x, hs.eq_singleton_of_mem hx⟩ #align set.subsingleton.eq_empty_or_singleton Set.Subsingleton.eq_empty_or_singleton theorem Subsingleton.induction_on {p : Set α → Prop} (hs : s.Subsingleton) (he : p ∅) (h₁ : ∀ x, p {x}) : p s := by rcases hs.eq_empty_or_singleton with (rfl | ⟨x, rfl⟩) exacts [he, h₁ _] #align set.subsingleton.induction_on Set.Subsingleton.induction_on theorem subsingleton_univ [Subsingleton α] : (univ : Set α).Subsingleton := fun x _ y _ => Subsingleton.elim x y #align set.subsingleton_univ Set.subsingleton_univ theorem subsingleton_of_univ_subsingleton (h : (univ : Set α).Subsingleton) : Subsingleton α := ⟨fun a b => h (mem_univ a) (mem_univ b)⟩ #align set.subsingleton_of_univ_subsingleton Set.subsingleton_of_univ_subsingleton @[simp] theorem subsingleton_univ_iff : (univ : Set α).Subsingleton ↔ Subsingleton α := ⟨subsingleton_of_univ_subsingleton, fun h => @subsingleton_univ _ h⟩ #align set.subsingleton_univ_iff Set.subsingleton_univ_iff theorem subsingleton_of_subsingleton [Subsingleton α] {s : Set α} : Set.Subsingleton s := subsingleton_univ.anti (subset_univ s) #align set.subsingleton_of_subsingleton Set.subsingleton_of_subsingleton theorem subsingleton_isTop (α : Type*) [PartialOrder α] : Set.Subsingleton { x : α | IsTop x } := fun x hx _ hy => hx.isMax.eq_of_le (hy x) #align set.subsingleton_is_top Set.subsingleton_isTop theorem subsingleton_isBot (α : Type*) [PartialOrder α] : Set.Subsingleton { x : α | IsBot x } := fun x hx _ hy => hx.isMin.eq_of_ge (hy x) #align set.subsingleton_is_bot Set.subsingleton_isBot theorem exists_eq_singleton_iff_nonempty_subsingleton : (∃ a : α, s = {a}) ↔ s.Nonempty ∧ s.Subsingleton := by refine ⟨?_, fun h => ?_⟩ · rintro ⟨a, rfl⟩ exact ⟨singleton_nonempty a, subsingleton_singleton⟩ · exact h.2.eq_empty_or_singleton.resolve_left h.1.ne_empty #align set.exists_eq_singleton_iff_nonempty_subsingleton Set.exists_eq_singleton_iff_nonempty_subsingleton @[simp, norm_cast]
Mathlib/Data/Set/Subsingleton.lean
109
113
theorem subsingleton_coe (s : Set α) : Subsingleton s ↔ s.Subsingleton := by
constructor · refine fun h => fun a ha b hb => ?_ exact SetCoe.ext_iff.2 (@Subsingleton.elim s h ⟨a, ha⟩ ⟨b, hb⟩) · exact fun h => Subsingleton.intro fun a b => SetCoe.ext (h a.property b.property)
701
import Mathlib.Data.Set.Basic open Function universe u v namespace Set section Nontrivial variable {α : Type u} {a : α} {s t : Set α} protected def Nontrivial (s : Set α) : Prop := ∃ x ∈ s, ∃ y ∈ s, x ≠ y #align set.nontrivial Set.Nontrivial theorem nontrivial_of_mem_mem_ne {x y} (hx : x ∈ s) (hy : y ∈ s) (hxy : x ≠ y) : s.Nontrivial := ⟨x, hx, y, hy, hxy⟩ #align set.nontrivial_of_mem_mem_ne Set.nontrivial_of_mem_mem_ne -- Porting note: following the pattern for `Exists`, we have renamed `some` to `choose`. protected noncomputable def Nontrivial.choose (hs : s.Nontrivial) : α × α := (Exists.choose hs, hs.choose_spec.right.choose) #align set.nontrivial.some Set.Nontrivial.choose protected theorem Nontrivial.choose_fst_mem (hs : s.Nontrivial) : hs.choose.fst ∈ s := hs.choose_spec.left #align set.nontrivial.some_fst_mem Set.Nontrivial.choose_fst_mem protected theorem Nontrivial.choose_snd_mem (hs : s.Nontrivial) : hs.choose.snd ∈ s := hs.choose_spec.right.choose_spec.left #align set.nontrivial.some_snd_mem Set.Nontrivial.choose_snd_mem protected theorem Nontrivial.choose_fst_ne_choose_snd (hs : s.Nontrivial) : hs.choose.fst ≠ hs.choose.snd := hs.choose_spec.right.choose_spec.right #align set.nontrivial.some_fst_ne_some_snd Set.Nontrivial.choose_fst_ne_choose_snd theorem Nontrivial.mono (hs : s.Nontrivial) (hst : s ⊆ t) : t.Nontrivial := let ⟨x, hx, y, hy, hxy⟩ := hs ⟨x, hst hx, y, hst hy, hxy⟩ #align set.nontrivial.mono Set.Nontrivial.mono theorem nontrivial_pair {x y} (hxy : x ≠ y) : ({x, y} : Set α).Nontrivial := ⟨x, mem_insert _ _, y, mem_insert_of_mem _ (mem_singleton _), hxy⟩ #align set.nontrivial_pair Set.nontrivial_pair theorem nontrivial_of_pair_subset {x y} (hxy : x ≠ y) (h : {x, y} ⊆ s) : s.Nontrivial := (nontrivial_pair hxy).mono h #align set.nontrivial_of_pair_subset Set.nontrivial_of_pair_subset theorem Nontrivial.pair_subset (hs : s.Nontrivial) : ∃ x y, x ≠ y ∧ {x, y} ⊆ s := let ⟨x, hx, y, hy, hxy⟩ := hs ⟨x, y, hxy, insert_subset hx <| singleton_subset_iff.2 hy⟩ #align set.nontrivial.pair_subset Set.Nontrivial.pair_subset theorem nontrivial_iff_pair_subset : s.Nontrivial ↔ ∃ x y, x ≠ y ∧ {x, y} ⊆ s := ⟨Nontrivial.pair_subset, fun H => let ⟨_, _, hxy, h⟩ := H nontrivial_of_pair_subset hxy h⟩ #align set.nontrivial_iff_pair_subset Set.nontrivial_iff_pair_subset theorem nontrivial_of_exists_ne {x} (hx : x ∈ s) (h : ∃ y ∈ s, y ≠ x) : s.Nontrivial := let ⟨y, hy, hyx⟩ := h ⟨y, hy, x, hx, hyx⟩ #align set.nontrivial_of_exists_ne Set.nontrivial_of_exists_ne
Mathlib/Data/Set/Subsingleton.lean
194
198
theorem Nontrivial.exists_ne (hs : s.Nontrivial) (z) : ∃ x ∈ s, x ≠ z := by
by_contra! H rcases hs with ⟨x, hx, y, hy, hxy⟩ rw [H x hx, H y hy] at hxy exact hxy rfl
701
import Mathlib.Computability.PartrecCode import Mathlib.Data.Set.Subsingleton #align_import computability.halting from "leanprover-community/mathlib"@"a50170a88a47570ed186b809ca754110590f9476" open Encodable Denumerable namespace Nat.Partrec open Computable Part
Mathlib/Computability/Halting.lean
28
60
theorem merge' {f g} (hf : Nat.Partrec f) (hg : Nat.Partrec g) : ∃ h, Nat.Partrec h ∧ ∀ a, (∀ x ∈ h a, x ∈ f a ∨ x ∈ g a) ∧ ((h a).Dom ↔ (f a).Dom ∨ (g a).Dom) := by
obtain ⟨cf, rfl⟩ := Code.exists_code.1 hf obtain ⟨cg, rfl⟩ := Code.exists_code.1 hg have : Nat.Partrec fun n => Nat.rfindOpt fun k => cf.evaln k n <|> cg.evaln k n := Partrec.nat_iff.1 (Partrec.rfindOpt <| Primrec.option_orElse.to_comp.comp (Code.evaln_prim.to_comp.comp <| (snd.pair (const cf)).pair fst) (Code.evaln_prim.to_comp.comp <| (snd.pair (const cg)).pair fst)) refine ⟨_, this, fun n => ?_⟩ have : ∀ x ∈ rfindOpt fun k ↦ HOrElse.hOrElse (Code.evaln k cf n) fun _x ↦ Code.evaln k cg n, x ∈ Code.eval cf n ∨ x ∈ Code.eval cg n := by intro x h obtain ⟨k, e⟩ := Nat.rfindOpt_spec h revert e simp only [Option.mem_def] cases' e' : cf.evaln k n with y <;> simp <;> intro e · exact Or.inr (Code.evaln_sound e) · subst y exact Or.inl (Code.evaln_sound e') refine ⟨this, ⟨fun h => (this _ ⟨h, rfl⟩).imp Exists.fst Exists.fst, ?_⟩⟩ intro h rw [Nat.rfindOpt_dom] simp only [dom_iff_mem, Code.evaln_complete, Option.mem_def] at h obtain ⟨x, k, e⟩ | ⟨x, k, e⟩ := h · refine ⟨k, x, ?_⟩ simp only [e, Option.some_orElse, Option.mem_def] · refine ⟨k, ?_⟩ cases' cf.evaln k n with y · exact ⟨x, by simp only [e, Option.mem_def, Option.none_orElse]⟩ · exact ⟨y, by simp only [Option.some_orElse, Option.mem_def]⟩
702
import Mathlib.Computability.Halting #align_import computability.reduce from "leanprover-community/mathlib"@"d13b3a4a392ea7273dfa4727dbd1892e26cfd518" universe u v w open Function def ManyOneReducible {α β} [Primcodable α] [Primcodable β] (p : α → Prop) (q : β → Prop) := ∃ f, Computable f ∧ ∀ a, p a ↔ q (f a) #align many_one_reducible ManyOneReducible @[inherit_doc ManyOneReducible] infixl:1000 " ≤₀ " => ManyOneReducible theorem ManyOneReducible.mk {α β} [Primcodable α] [Primcodable β] {f : α → β} (q : β → Prop) (h : Computable f) : (fun a => q (f a)) ≤₀ q := ⟨f, h, fun _ => Iff.rfl⟩ #align many_one_reducible.mk ManyOneReducible.mk @[refl] theorem manyOneReducible_refl {α} [Primcodable α] (p : α → Prop) : p ≤₀ p := ⟨id, Computable.id, by simp⟩ #align many_one_reducible_refl manyOneReducible_refl @[trans] theorem ManyOneReducible.trans {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} : p ≤₀ q → q ≤₀ r → p ≤₀ r | ⟨f, c₁, h₁⟩, ⟨g, c₂, h₂⟩ => ⟨g ∘ f, c₂.comp c₁, fun a => ⟨fun h => by erw [← h₂, ← h₁]; assumption, fun h => by rwa [h₁, h₂]⟩⟩ #align many_one_reducible.trans ManyOneReducible.trans theorem reflexive_manyOneReducible {α} [Primcodable α] : Reflexive (@ManyOneReducible α α _ _) := manyOneReducible_refl #align reflexive_many_one_reducible reflexive_manyOneReducible theorem transitive_manyOneReducible {α} [Primcodable α] : Transitive (@ManyOneReducible α α _ _) := fun _ _ _ => ManyOneReducible.trans #align transitive_many_one_reducible transitive_manyOneReducible def OneOneReducible {α β} [Primcodable α] [Primcodable β] (p : α → Prop) (q : β → Prop) := ∃ f, Computable f ∧ Injective f ∧ ∀ a, p a ↔ q (f a) #align one_one_reducible OneOneReducible @[inherit_doc OneOneReducible] infixl:1000 " ≤₁ " => OneOneReducible theorem OneOneReducible.mk {α β} [Primcodable α] [Primcodable β] {f : α → β} (q : β → Prop) (h : Computable f) (i : Injective f) : (fun a => q (f a)) ≤₁ q := ⟨f, h, i, fun _ => Iff.rfl⟩ #align one_one_reducible.mk OneOneReducible.mk @[refl] theorem oneOneReducible_refl {α} [Primcodable α] (p : α → Prop) : p ≤₁ p := ⟨id, Computable.id, injective_id, by simp⟩ #align one_one_reducible_refl oneOneReducible_refl @[trans] theorem OneOneReducible.trans {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} : p ≤₁ q → q ≤₁ r → p ≤₁ r | ⟨f, c₁, i₁, h₁⟩, ⟨g, c₂, i₂, h₂⟩ => ⟨g ∘ f, c₂.comp c₁, i₂.comp i₁, fun a => ⟨fun h => by erw [← h₂, ← h₁]; assumption, fun h => by rwa [h₁, h₂]⟩⟩ #align one_one_reducible.trans OneOneReducible.trans theorem OneOneReducible.to_many_one {α β} [Primcodable α] [Primcodable β] {p : α → Prop} {q : β → Prop} : p ≤₁ q → p ≤₀ q | ⟨f, c, _, h⟩ => ⟨f, c, h⟩ #align one_one_reducible.to_many_one OneOneReducible.to_many_one theorem OneOneReducible.of_equiv {α β} [Primcodable α] [Primcodable β] {e : α ≃ β} (q : β → Prop) (h : Computable e) : (q ∘ e) ≤₁ q := OneOneReducible.mk _ h e.injective #align one_one_reducible.of_equiv OneOneReducible.of_equiv
Mathlib/Computability/Reduce.lean
111
113
theorem OneOneReducible.of_equiv_symm {α β} [Primcodable α] [Primcodable β] {e : α ≃ β} (q : β → Prop) (h : Computable e.symm) : q ≤₁ (q ∘ e) := by
convert OneOneReducible.of_equiv _ h; funext; simp
703
import Mathlib.Computability.Halting #align_import computability.reduce from "leanprover-community/mathlib"@"d13b3a4a392ea7273dfa4727dbd1892e26cfd518" universe u v w open Function def ManyOneReducible {α β} [Primcodable α] [Primcodable β] (p : α → Prop) (q : β → Prop) := ∃ f, Computable f ∧ ∀ a, p a ↔ q (f a) #align many_one_reducible ManyOneReducible @[inherit_doc ManyOneReducible] infixl:1000 " ≤₀ " => ManyOneReducible theorem ManyOneReducible.mk {α β} [Primcodable α] [Primcodable β] {f : α → β} (q : β → Prop) (h : Computable f) : (fun a => q (f a)) ≤₀ q := ⟨f, h, fun _ => Iff.rfl⟩ #align many_one_reducible.mk ManyOneReducible.mk @[refl] theorem manyOneReducible_refl {α} [Primcodable α] (p : α → Prop) : p ≤₀ p := ⟨id, Computable.id, by simp⟩ #align many_one_reducible_refl manyOneReducible_refl @[trans] theorem ManyOneReducible.trans {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} : p ≤₀ q → q ≤₀ r → p ≤₀ r | ⟨f, c₁, h₁⟩, ⟨g, c₂, h₂⟩ => ⟨g ∘ f, c₂.comp c₁, fun a => ⟨fun h => by erw [← h₂, ← h₁]; assumption, fun h => by rwa [h₁, h₂]⟩⟩ #align many_one_reducible.trans ManyOneReducible.trans theorem reflexive_manyOneReducible {α} [Primcodable α] : Reflexive (@ManyOneReducible α α _ _) := manyOneReducible_refl #align reflexive_many_one_reducible reflexive_manyOneReducible theorem transitive_manyOneReducible {α} [Primcodable α] : Transitive (@ManyOneReducible α α _ _) := fun _ _ _ => ManyOneReducible.trans #align transitive_many_one_reducible transitive_manyOneReducible def OneOneReducible {α β} [Primcodable α] [Primcodable β] (p : α → Prop) (q : β → Prop) := ∃ f, Computable f ∧ Injective f ∧ ∀ a, p a ↔ q (f a) #align one_one_reducible OneOneReducible @[inherit_doc OneOneReducible] infixl:1000 " ≤₁ " => OneOneReducible theorem OneOneReducible.mk {α β} [Primcodable α] [Primcodable β] {f : α → β} (q : β → Prop) (h : Computable f) (i : Injective f) : (fun a => q (f a)) ≤₁ q := ⟨f, h, i, fun _ => Iff.rfl⟩ #align one_one_reducible.mk OneOneReducible.mk @[refl] theorem oneOneReducible_refl {α} [Primcodable α] (p : α → Prop) : p ≤₁ p := ⟨id, Computable.id, injective_id, by simp⟩ #align one_one_reducible_refl oneOneReducible_refl @[trans] theorem OneOneReducible.trans {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} : p ≤₁ q → q ≤₁ r → p ≤₁ r | ⟨f, c₁, i₁, h₁⟩, ⟨g, c₂, i₂, h₂⟩ => ⟨g ∘ f, c₂.comp c₁, i₂.comp i₁, fun a => ⟨fun h => by erw [← h₂, ← h₁]; assumption, fun h => by rwa [h₁, h₂]⟩⟩ #align one_one_reducible.trans OneOneReducible.trans theorem OneOneReducible.to_many_one {α β} [Primcodable α] [Primcodable β] {p : α → Prop} {q : β → Prop} : p ≤₁ q → p ≤₀ q | ⟨f, c, _, h⟩ => ⟨f, c, h⟩ #align one_one_reducible.to_many_one OneOneReducible.to_many_one theorem OneOneReducible.of_equiv {α β} [Primcodable α] [Primcodable β] {e : α ≃ β} (q : β → Prop) (h : Computable e) : (q ∘ e) ≤₁ q := OneOneReducible.mk _ h e.injective #align one_one_reducible.of_equiv OneOneReducible.of_equiv theorem OneOneReducible.of_equiv_symm {α β} [Primcodable α] [Primcodable β] {e : α ≃ β} (q : β → Prop) (h : Computable e.symm) : q ≤₁ (q ∘ e) := by convert OneOneReducible.of_equiv _ h; funext; simp #align one_one_reducible.of_equiv_symm OneOneReducible.of_equiv_symm theorem reflexive_oneOneReducible {α} [Primcodable α] : Reflexive (@OneOneReducible α α _ _) := oneOneReducible_refl #align reflexive_one_one_reducible reflexive_oneOneReducible theorem transitive_oneOneReducible {α} [Primcodable α] : Transitive (@OneOneReducible α α _ _) := fun _ _ _ => OneOneReducible.trans #align transitive_one_one_reducible transitive_oneOneReducible namespace ComputablePred variable {α : Type*} {β : Type*} {σ : Type*} variable [Primcodable α] [Primcodable β] [Primcodable σ] open Computable
Mathlib/Computability/Reduce.lean
131
136
theorem computable_of_manyOneReducible {p : α → Prop} {q : β → Prop} (h₁ : p ≤₀ q) (h₂ : ComputablePred q) : ComputablePred p := by
rcases h₁ with ⟨f, c, hf⟩ rw [show p = fun a => q (f a) from Set.ext hf] rcases computable_iff.1 h₂ with ⟨g, hg, rfl⟩ exact ⟨by infer_instance, by simpa using hg.comp c⟩
703
import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Data.Set.Subsingleton #align_import combinatorics.double_counting from "leanprover-community/mathlib"@"1126441d6bccf98c81214a0780c73d499f6721fe" open Finset Function Relator variable {α β : Type*} namespace Finset section Bipartite variable (r : α → β → Prop) (s : Finset α) (t : Finset β) (a a' : α) (b b' : β) [DecidablePred (r a)] [∀ a, Decidable (r a b)] {m n : ℕ} def bipartiteBelow : Finset α := s.filter fun a ↦ r a b #align finset.bipartite_below Finset.bipartiteBelow def bipartiteAbove : Finset β := t.filter (r a) #align finset.bipartite_above Finset.bipartiteAbove theorem bipartiteBelow_swap : t.bipartiteBelow (swap r) a = t.bipartiteAbove r a := rfl #align finset.bipartite_below_swap Finset.bipartiteBelow_swap theorem bipartiteAbove_swap : s.bipartiteAbove (swap r) b = s.bipartiteBelow r b := rfl #align finset.bipartite_above_swap Finset.bipartiteAbove_swap @[simp, norm_cast] theorem coe_bipartiteBelow : (s.bipartiteBelow r b : Set α) = { a ∈ s | r a b } := coe_filter _ _ #align finset.coe_bipartite_below Finset.coe_bipartiteBelow @[simp, norm_cast] theorem coe_bipartiteAbove : (t.bipartiteAbove r a : Set β) = { b ∈ t | r a b } := coe_filter _ _ #align finset.coe_bipartite_above Finset.coe_bipartiteAbove variable {s t a a' b b'} @[simp] theorem mem_bipartiteBelow {a : α} : a ∈ s.bipartiteBelow r b ↔ a ∈ s ∧ r a b := mem_filter #align finset.mem_bipartite_below Finset.mem_bipartiteBelow @[simp] theorem mem_bipartiteAbove {b : β} : b ∈ t.bipartiteAbove r a ↔ b ∈ t ∧ r a b := mem_filter #align finset.mem_bipartite_above Finset.mem_bipartiteAbove
Mathlib/Combinatorics/Enumerative/DoubleCounting.lean
79
82
theorem sum_card_bipartiteAbove_eq_sum_card_bipartiteBelow [∀ a b, Decidable (r a b)] : (∑ a ∈ s, (t.bipartiteAbove r a).card) = ∑ b ∈ t, (s.bipartiteBelow r b).card := by
simp_rw [card_eq_sum_ones, bipartiteAbove, bipartiteBelow, sum_filter] exact sum_comm
704
import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Data.Set.Subsingleton #align_import combinatorics.double_counting from "leanprover-community/mathlib"@"1126441d6bccf98c81214a0780c73d499f6721fe" open Finset Function Relator variable {α β : Type*} namespace Finset section Bipartite variable (r : α → β → Prop) (s : Finset α) (t : Finset β) (a a' : α) (b b' : β) [DecidablePred (r a)] [∀ a, Decidable (r a b)] {m n : ℕ} def bipartiteBelow : Finset α := s.filter fun a ↦ r a b #align finset.bipartite_below Finset.bipartiteBelow def bipartiteAbove : Finset β := t.filter (r a) #align finset.bipartite_above Finset.bipartiteAbove theorem bipartiteBelow_swap : t.bipartiteBelow (swap r) a = t.bipartiteAbove r a := rfl #align finset.bipartite_below_swap Finset.bipartiteBelow_swap theorem bipartiteAbove_swap : s.bipartiteAbove (swap r) b = s.bipartiteBelow r b := rfl #align finset.bipartite_above_swap Finset.bipartiteAbove_swap @[simp, norm_cast] theorem coe_bipartiteBelow : (s.bipartiteBelow r b : Set α) = { a ∈ s | r a b } := coe_filter _ _ #align finset.coe_bipartite_below Finset.coe_bipartiteBelow @[simp, norm_cast] theorem coe_bipartiteAbove : (t.bipartiteAbove r a : Set β) = { b ∈ t | r a b } := coe_filter _ _ #align finset.coe_bipartite_above Finset.coe_bipartiteAbove variable {s t a a' b b'} @[simp] theorem mem_bipartiteBelow {a : α} : a ∈ s.bipartiteBelow r b ↔ a ∈ s ∧ r a b := mem_filter #align finset.mem_bipartite_below Finset.mem_bipartiteBelow @[simp] theorem mem_bipartiteAbove {b : β} : b ∈ t.bipartiteAbove r a ↔ b ∈ t ∧ r a b := mem_filter #align finset.mem_bipartite_above Finset.mem_bipartiteAbove theorem sum_card_bipartiteAbove_eq_sum_card_bipartiteBelow [∀ a b, Decidable (r a b)] : (∑ a ∈ s, (t.bipartiteAbove r a).card) = ∑ b ∈ t, (s.bipartiteBelow r b).card := by simp_rw [card_eq_sum_ones, bipartiteAbove, bipartiteBelow, sum_filter] exact sum_comm #align finset.sum_card_bipartite_above_eq_sum_card_bipartite_below Finset.sum_card_bipartiteAbove_eq_sum_card_bipartiteBelow theorem card_mul_le_card_mul [∀ a b, Decidable (r a b)] (hm : ∀ a ∈ s, m ≤ (t.bipartiteAbove r a).card) (hn : ∀ b ∈ t, (s.bipartiteBelow r b).card ≤ n) : s.card * m ≤ t.card * n := calc _ ≤ ∑ a ∈ s, (t.bipartiteAbove r a).card := s.card_nsmul_le_sum _ _ hm _ = ∑ b ∈ t, (s.bipartiteBelow r b).card := sum_card_bipartiteAbove_eq_sum_card_bipartiteBelow _ _ ≤ _ := t.sum_le_card_nsmul _ _ hn #align finset.card_mul_le_card_mul Finset.card_mul_le_card_mul theorem card_mul_le_card_mul' [∀ a b, Decidable (r a b)] (hn : ∀ b ∈ t, n ≤ (s.bipartiteBelow r b).card) (hm : ∀ a ∈ s, (t.bipartiteAbove r a).card ≤ m) : t.card * n ≤ s.card * m := card_mul_le_card_mul (swap r) hn hm #align finset.card_mul_le_card_mul' Finset.card_mul_le_card_mul' theorem card_mul_eq_card_mul [∀ a b, Decidable (r a b)] (hm : ∀ a ∈ s, (t.bipartiteAbove r a).card = m) (hn : ∀ b ∈ t, (s.bipartiteBelow r b).card = n) : s.card * m = t.card * n := (card_mul_le_card_mul _ (fun a ha ↦ (hm a ha).ge) fun b hb ↦ (hn b hb).le).antisymm <| card_mul_le_card_mul' _ (fun a ha ↦ (hn a ha).ge) fun b hb ↦ (hm b hb).le #align finset.card_mul_eq_card_mul Finset.card_mul_eq_card_mul
Mathlib/Combinatorics/Enumerative/DoubleCounting.lean
110
120
theorem card_le_card_of_forall_subsingleton (hs : ∀ a ∈ s, ∃ b, b ∈ t ∧ r a b) (ht : ∀ b ∈ t, ({ a ∈ s | r a b } : Set α).Subsingleton) : s.card ≤ t.card := by
classical rw [← mul_one s.card, ← mul_one t.card] exact card_mul_le_card_mul r (fun a h ↦ card_pos.2 (by rw [← coe_nonempty, coe_bipartiteAbove] exact hs _ h : (t.bipartiteAbove r a).Nonempty)) (fun b h ↦ card_le_one.2 (by simp_rw [mem_bipartiteBelow] exact ht _ h))
704
import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Combinatorics.Enumerative.DoubleCounting import Mathlib.Data.Finset.Pointwise import Mathlib.Tactic.GCongr #align_import combinatorics.additive.pluennecke_ruzsa from "leanprover-community/mathlib"@"4aab2abced69a9e579b1e6dc2856ed3db48e2cbd" open Nat open NNRat Pointwise namespace Finset variable {α : Type*} [CommGroup α] [DecidableEq α] {A B C : Finset α} @[to_additive card_sub_mul_le_card_sub_mul_card_sub "**Ruzsa's triangle inequality**. Subtraction version."]
Mathlib/Combinatorics/Additive/PluenneckeRuzsa.lean
45
56
theorem card_div_mul_le_card_div_mul_card_div (A B C : Finset α) : (A / C).card * B.card ≤ (A / B).card * (B / C).card := by
rw [← card_product (A / B), ← mul_one ((A / B) ×ˢ (B / C)).card] refine card_mul_le_card_mul (fun b ac ↦ ac.1 * ac.2 = b) (fun x hx ↦ ?_) fun x _ ↦ card_le_one_iff.2 fun hu hv ↦ ((mem_bipartiteBelow _).1 hu).2.symm.trans ?_ obtain ⟨a, ha, c, hc, rfl⟩ := mem_div.1 hx refine card_le_card_of_inj_on (fun b ↦ (a / b, b / c)) (fun b hb ↦ ?_) fun b₁ _ b₂ _ h ↦ ?_ · rw [mem_bipartiteAbove] exact ⟨mk_mem_product (div_mem_div ha hb) (div_mem_div hb hc), div_mul_div_cancel' _ _ _⟩ · exact div_right_injective (Prod.ext_iff.1 h).1 · exact ((mem_bipartiteBelow _).1 hv).2
705
import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Combinatorics.Enumerative.DoubleCounting import Mathlib.Data.Finset.Pointwise import Mathlib.Tactic.GCongr #align_import combinatorics.additive.pluennecke_ruzsa from "leanprover-community/mathlib"@"4aab2abced69a9e579b1e6dc2856ed3db48e2cbd" open Nat open NNRat Pointwise namespace Finset variable {α : Type*} [CommGroup α] [DecidableEq α] {A B C : Finset α} @[to_additive card_sub_mul_le_card_sub_mul_card_sub "**Ruzsa's triangle inequality**. Subtraction version."] theorem card_div_mul_le_card_div_mul_card_div (A B C : Finset α) : (A / C).card * B.card ≤ (A / B).card * (B / C).card := by rw [← card_product (A / B), ← mul_one ((A / B) ×ˢ (B / C)).card] refine card_mul_le_card_mul (fun b ac ↦ ac.1 * ac.2 = b) (fun x hx ↦ ?_) fun x _ ↦ card_le_one_iff.2 fun hu hv ↦ ((mem_bipartiteBelow _).1 hu).2.symm.trans ?_ obtain ⟨a, ha, c, hc, rfl⟩ := mem_div.1 hx refine card_le_card_of_inj_on (fun b ↦ (a / b, b / c)) (fun b hb ↦ ?_) fun b₁ _ b₂ _ h ↦ ?_ · rw [mem_bipartiteAbove] exact ⟨mk_mem_product (div_mem_div ha hb) (div_mem_div hb hc), div_mul_div_cancel' _ _ _⟩ · exact div_right_injective (Prod.ext_iff.1 h).1 · exact ((mem_bipartiteBelow _).1 hv).2 #align finset.card_div_mul_le_card_div_mul_card_div Finset.card_div_mul_le_card_div_mul_card_div #align finset.card_sub_mul_le_card_sub_mul_card_sub Finset.card_sub_mul_le_card_sub_mul_card_sub @[to_additive card_sub_mul_le_card_add_mul_card_add "**Ruzsa's triangle inequality**. Sub-add-add version."]
Mathlib/Combinatorics/Additive/PluenneckeRuzsa.lean
63
66
theorem card_div_mul_le_card_mul_mul_card_mul (A B C : Finset α) : (A / C).card * B.card ≤ (A * B).card * (B * C).card := by
rw [← div_inv_eq_mul, ← card_inv B, ← card_inv (B * C), mul_inv, ← div_eq_mul_inv] exact card_div_mul_le_card_div_mul_card_div _ _ _
705
import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Combinatorics.Enumerative.DoubleCounting import Mathlib.Data.Finset.Pointwise import Mathlib.Tactic.GCongr #align_import combinatorics.additive.pluennecke_ruzsa from "leanprover-community/mathlib"@"4aab2abced69a9e579b1e6dc2856ed3db48e2cbd" open Nat open NNRat Pointwise namespace Finset variable {α : Type*} [CommGroup α] [DecidableEq α] {A B C : Finset α} @[to_additive card_sub_mul_le_card_sub_mul_card_sub "**Ruzsa's triangle inequality**. Subtraction version."] theorem card_div_mul_le_card_div_mul_card_div (A B C : Finset α) : (A / C).card * B.card ≤ (A / B).card * (B / C).card := by rw [← card_product (A / B), ← mul_one ((A / B) ×ˢ (B / C)).card] refine card_mul_le_card_mul (fun b ac ↦ ac.1 * ac.2 = b) (fun x hx ↦ ?_) fun x _ ↦ card_le_one_iff.2 fun hu hv ↦ ((mem_bipartiteBelow _).1 hu).2.symm.trans ?_ obtain ⟨a, ha, c, hc, rfl⟩ := mem_div.1 hx refine card_le_card_of_inj_on (fun b ↦ (a / b, b / c)) (fun b hb ↦ ?_) fun b₁ _ b₂ _ h ↦ ?_ · rw [mem_bipartiteAbove] exact ⟨mk_mem_product (div_mem_div ha hb) (div_mem_div hb hc), div_mul_div_cancel' _ _ _⟩ · exact div_right_injective (Prod.ext_iff.1 h).1 · exact ((mem_bipartiteBelow _).1 hv).2 #align finset.card_div_mul_le_card_div_mul_card_div Finset.card_div_mul_le_card_div_mul_card_div #align finset.card_sub_mul_le_card_sub_mul_card_sub Finset.card_sub_mul_le_card_sub_mul_card_sub @[to_additive card_sub_mul_le_card_add_mul_card_add "**Ruzsa's triangle inequality**. Sub-add-add version."] theorem card_div_mul_le_card_mul_mul_card_mul (A B C : Finset α) : (A / C).card * B.card ≤ (A * B).card * (B * C).card := by rw [← div_inv_eq_mul, ← card_inv B, ← card_inv (B * C), mul_inv, ← div_eq_mul_inv] exact card_div_mul_le_card_div_mul_card_div _ _ _ #align finset.card_div_mul_le_card_mul_mul_card_mul Finset.card_div_mul_le_card_mul_mul_card_mul #align finset.card_sub_mul_le_card_add_mul_card_add Finset.card_sub_mul_le_card_add_mul_card_add @[to_additive card_add_mul_le_card_sub_mul_card_add "**Ruzsa's triangle inequality**. Add-sub-sub version."]
Mathlib/Combinatorics/Additive/PluenneckeRuzsa.lean
73
76
theorem card_mul_mul_le_card_div_mul_card_mul (A B C : Finset α) : (A * C).card * B.card ≤ (A / B).card * (B * C).card := by
rw [← div_inv_eq_mul, ← div_inv_eq_mul B] exact card_div_mul_le_card_div_mul_card_div _ _ _
705
import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Combinatorics.Enumerative.DoubleCounting import Mathlib.Data.Finset.Pointwise import Mathlib.Tactic.GCongr #align_import combinatorics.additive.pluennecke_ruzsa from "leanprover-community/mathlib"@"4aab2abced69a9e579b1e6dc2856ed3db48e2cbd" open Nat open NNRat Pointwise namespace Finset variable {α : Type*} [CommGroup α] [DecidableEq α] {A B C : Finset α} @[to_additive card_sub_mul_le_card_sub_mul_card_sub "**Ruzsa's triangle inequality**. Subtraction version."] theorem card_div_mul_le_card_div_mul_card_div (A B C : Finset α) : (A / C).card * B.card ≤ (A / B).card * (B / C).card := by rw [← card_product (A / B), ← mul_one ((A / B) ×ˢ (B / C)).card] refine card_mul_le_card_mul (fun b ac ↦ ac.1 * ac.2 = b) (fun x hx ↦ ?_) fun x _ ↦ card_le_one_iff.2 fun hu hv ↦ ((mem_bipartiteBelow _).1 hu).2.symm.trans ?_ obtain ⟨a, ha, c, hc, rfl⟩ := mem_div.1 hx refine card_le_card_of_inj_on (fun b ↦ (a / b, b / c)) (fun b hb ↦ ?_) fun b₁ _ b₂ _ h ↦ ?_ · rw [mem_bipartiteAbove] exact ⟨mk_mem_product (div_mem_div ha hb) (div_mem_div hb hc), div_mul_div_cancel' _ _ _⟩ · exact div_right_injective (Prod.ext_iff.1 h).1 · exact ((mem_bipartiteBelow _).1 hv).2 #align finset.card_div_mul_le_card_div_mul_card_div Finset.card_div_mul_le_card_div_mul_card_div #align finset.card_sub_mul_le_card_sub_mul_card_sub Finset.card_sub_mul_le_card_sub_mul_card_sub @[to_additive card_sub_mul_le_card_add_mul_card_add "**Ruzsa's triangle inequality**. Sub-add-add version."] theorem card_div_mul_le_card_mul_mul_card_mul (A B C : Finset α) : (A / C).card * B.card ≤ (A * B).card * (B * C).card := by rw [← div_inv_eq_mul, ← card_inv B, ← card_inv (B * C), mul_inv, ← div_eq_mul_inv] exact card_div_mul_le_card_div_mul_card_div _ _ _ #align finset.card_div_mul_le_card_mul_mul_card_mul Finset.card_div_mul_le_card_mul_mul_card_mul #align finset.card_sub_mul_le_card_add_mul_card_add Finset.card_sub_mul_le_card_add_mul_card_add @[to_additive card_add_mul_le_card_sub_mul_card_add "**Ruzsa's triangle inequality**. Add-sub-sub version."] theorem card_mul_mul_le_card_div_mul_card_mul (A B C : Finset α) : (A * C).card * B.card ≤ (A / B).card * (B * C).card := by rw [← div_inv_eq_mul, ← div_inv_eq_mul B] exact card_div_mul_le_card_div_mul_card_div _ _ _ #align finset.card_mul_mul_le_card_div_mul_card_mul Finset.card_mul_mul_le_card_div_mul_card_mul #align finset.card_add_mul_le_card_sub_mul_card_add Finset.card_add_mul_le_card_sub_mul_card_add @[to_additive card_add_mul_le_card_add_mul_card_sub "**Ruzsa's triangle inequality**. Add-add-sub version."]
Mathlib/Combinatorics/Additive/PluenneckeRuzsa.lean
83
86
theorem card_mul_mul_le_card_mul_mul_card_div (A B C : Finset α) : (A * C).card * B.card ≤ (A * B).card * (B / C).card := by
rw [← div_inv_eq_mul, div_eq_mul_inv B] exact card_div_mul_le_card_mul_mul_card_mul _ _ _
705
import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Combinatorics.Enumerative.DoubleCounting import Mathlib.Data.Finset.Pointwise import Mathlib.Tactic.GCongr #align_import combinatorics.additive.pluennecke_ruzsa from "leanprover-community/mathlib"@"4aab2abced69a9e579b1e6dc2856ed3db48e2cbd" open Nat open NNRat Pointwise namespace Finset variable {α : Type*} [CommGroup α] [DecidableEq α] {A B C : Finset α} @[to_additive card_sub_mul_le_card_sub_mul_card_sub "**Ruzsa's triangle inequality**. Subtraction version."] theorem card_div_mul_le_card_div_mul_card_div (A B C : Finset α) : (A / C).card * B.card ≤ (A / B).card * (B / C).card := by rw [← card_product (A / B), ← mul_one ((A / B) ×ˢ (B / C)).card] refine card_mul_le_card_mul (fun b ac ↦ ac.1 * ac.2 = b) (fun x hx ↦ ?_) fun x _ ↦ card_le_one_iff.2 fun hu hv ↦ ((mem_bipartiteBelow _).1 hu).2.symm.trans ?_ obtain ⟨a, ha, c, hc, rfl⟩ := mem_div.1 hx refine card_le_card_of_inj_on (fun b ↦ (a / b, b / c)) (fun b hb ↦ ?_) fun b₁ _ b₂ _ h ↦ ?_ · rw [mem_bipartiteAbove] exact ⟨mk_mem_product (div_mem_div ha hb) (div_mem_div hb hc), div_mul_div_cancel' _ _ _⟩ · exact div_right_injective (Prod.ext_iff.1 h).1 · exact ((mem_bipartiteBelow _).1 hv).2 #align finset.card_div_mul_le_card_div_mul_card_div Finset.card_div_mul_le_card_div_mul_card_div #align finset.card_sub_mul_le_card_sub_mul_card_sub Finset.card_sub_mul_le_card_sub_mul_card_sub @[to_additive card_sub_mul_le_card_add_mul_card_add "**Ruzsa's triangle inequality**. Sub-add-add version."] theorem card_div_mul_le_card_mul_mul_card_mul (A B C : Finset α) : (A / C).card * B.card ≤ (A * B).card * (B * C).card := by rw [← div_inv_eq_mul, ← card_inv B, ← card_inv (B * C), mul_inv, ← div_eq_mul_inv] exact card_div_mul_le_card_div_mul_card_div _ _ _ #align finset.card_div_mul_le_card_mul_mul_card_mul Finset.card_div_mul_le_card_mul_mul_card_mul #align finset.card_sub_mul_le_card_add_mul_card_add Finset.card_sub_mul_le_card_add_mul_card_add @[to_additive card_add_mul_le_card_sub_mul_card_add "**Ruzsa's triangle inequality**. Add-sub-sub version."] theorem card_mul_mul_le_card_div_mul_card_mul (A B C : Finset α) : (A * C).card * B.card ≤ (A / B).card * (B * C).card := by rw [← div_inv_eq_mul, ← div_inv_eq_mul B] exact card_div_mul_le_card_div_mul_card_div _ _ _ #align finset.card_mul_mul_le_card_div_mul_card_mul Finset.card_mul_mul_le_card_div_mul_card_mul #align finset.card_add_mul_le_card_sub_mul_card_add Finset.card_add_mul_le_card_sub_mul_card_add @[to_additive card_add_mul_le_card_add_mul_card_sub "**Ruzsa's triangle inequality**. Add-add-sub version."] theorem card_mul_mul_le_card_mul_mul_card_div (A B C : Finset α) : (A * C).card * B.card ≤ (A * B).card * (B / C).card := by rw [← div_inv_eq_mul, div_eq_mul_inv B] exact card_div_mul_le_card_mul_mul_card_mul _ _ _ #align finset.card_mul_mul_le_card_mul_mul_card_div Finset.card_mul_mul_le_card_mul_mul_card_div #align finset.card_add_mul_le_card_add_mul_card_sub Finset.card_add_mul_le_card_add_mul_card_sub set_option backward.isDefEq.lazyWhnfCore false in -- See https://github.com/leanprover-community/mathlib4/issues/12534 @[to_additive]
Mathlib/Combinatorics/Additive/PluenneckeRuzsa.lean
92
118
theorem mul_pluennecke_petridis (C : Finset α) (hA : ∀ A' ⊆ A, (A * B).card * A'.card ≤ (A' * B).card * A.card) : (A * B * C).card * A.card ≤ (A * B).card * (A * C).card := by
induction' C using Finset.induction_on with x C _ ih · simp set A' := A ∩ (A * C / {x}) with hA' set C' := insert x C with hC' have h₀ : A' * {x} = A * {x} ∩ (A * C) := by rw [hA', inter_mul_singleton, (isUnit_singleton x).div_mul_cancel] have h₁ : A * B * C' = A * B * C ∪ (A * B * {x}) \ (A' * B * {x}) := by rw [hC', insert_eq, union_comm, mul_union] refine (sup_sdiff_eq_sup ?_).symm rw [mul_right_comm, mul_right_comm A, h₀] exact mul_subset_mul_right inter_subset_right have h₂ : A' * B * {x} ⊆ A * B * {x} := mul_subset_mul_right (mul_subset_mul_right inter_subset_left) have h₃ : (A * B * C').card ≤ (A * B * C).card + (A * B).card - (A' * B).card := by rw [h₁] refine (card_union_le _ _).trans_eq ?_ rw [card_sdiff h₂, ← add_tsub_assoc_of_le (card_le_card h₂), card_mul_singleton, card_mul_singleton] refine (mul_le_mul_right' h₃ _).trans ?_ rw [tsub_mul, add_mul] refine (tsub_le_tsub (add_le_add_right ih _) <| hA _ inter_subset_left).trans_eq ?_ rw [← mul_add, ← mul_tsub, ← hA', hC', insert_eq, mul_union, ← card_mul_singleton A x, ← card_mul_singleton A' x, add_comm (card _), h₀, eq_tsub_of_add_eq (card_union_add_card_inter _ _)]
705
import Mathlib.Logic.Encodable.Basic import Mathlib.Logic.Pairwise import Mathlib.Data.Set.Subsingleton #align_import logic.encodable.lattice from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" open Set namespace Encodable variable {α : Type*} {β : Type*} [Encodable β]
Mathlib/Logic/Encodable/Lattice.lean
30
33
theorem iSup_decode₂ [CompleteLattice α] (f : β → α) : ⨆ (i : ℕ) (b ∈ decode₂ β i), f b = (⨆ b, f b) := by
rw [iSup_comm] simp only [mem_decode₂, iSup_iSup_eq_right]
706
import Mathlib.Logic.Encodable.Basic import Mathlib.Logic.Pairwise import Mathlib.Data.Set.Subsingleton #align_import logic.encodable.lattice from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" open Set namespace Encodable variable {α : Type*} {β : Type*} [Encodable β] theorem iSup_decode₂ [CompleteLattice α] (f : β → α) : ⨆ (i : ℕ) (b ∈ decode₂ β i), f b = (⨆ b, f b) := by rw [iSup_comm] simp only [mem_decode₂, iSup_iSup_eq_right] #align encodable.supr_decode₂ Encodable.iSup_decode₂ theorem iUnion_decode₂ (f : β → Set α) : ⋃ (i : ℕ) (b ∈ decode₂ β i), f b = ⋃ b, f b := iSup_decode₂ f #align encodable.Union_decode₂ Encodable.iUnion_decode₂ --@[elab_as_elim] theorem iUnion_decode₂_cases {f : β → Set α} {C : Set α → Prop} (H0 : C ∅) (H1 : ∀ b, C (f b)) {n} : C (⋃ b ∈ decode₂ β n, f b) := match decode₂ β n with | none => by simp only [Option.mem_def, iUnion_of_empty, iUnion_empty] apply H0 | some b => by convert H1 b simp [ext_iff] #align encodable.Union_decode₂_cases Encodable.iUnion_decode₂_cases
Mathlib/Logic/Encodable/Lattice.lean
53
59
theorem iUnion_decode₂_disjoint_on {f : β → Set α} (hd : Pairwise (Disjoint on f)) : Pairwise (Disjoint on fun i => ⋃ b ∈ decode₂ β i, f b) := by
rintro i j ij refine disjoint_left.mpr fun x => ?_ suffices ∀ a, encode a = i → x ∈ f a → ∀ b, encode b = j → x ∉ f b by simpa [decode₂_eq_some] rintro a rfl ha b rfl hb exact (hd (mt (congr_arg encode) ij)).le_bot ⟨ha, hb⟩
706
import Mathlib.Logic.Encodable.Lattice import Mathlib.MeasureTheory.MeasurableSpace.Defs #align_import measure_theory.pi_system from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90" open MeasurableSpace Set open scoped Classical open MeasureTheory def IsPiSystem {α} (C : Set (Set α)) : Prop := ∀ᵉ (s ∈ C) (t ∈ C), (s ∩ t : Set α).Nonempty → s ∩ t ∈ C #align is_pi_system IsPiSystem
Mathlib/MeasureTheory/PiSystem.lean
79
82
theorem IsPiSystem.singleton {α} (S : Set α) : IsPiSystem ({S} : Set (Set α)) := by
intro s h_s t h_t _ rw [Set.mem_singleton_iff.1 h_s, Set.mem_singleton_iff.1 h_t, Set.inter_self, Set.mem_singleton_iff]
707
import Mathlib.Logic.Encodable.Lattice import Mathlib.MeasureTheory.MeasurableSpace.Defs #align_import measure_theory.pi_system from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90" open MeasurableSpace Set open scoped Classical open MeasureTheory def IsPiSystem {α} (C : Set (Set α)) : Prop := ∀ᵉ (s ∈ C) (t ∈ C), (s ∩ t : Set α).Nonempty → s ∩ t ∈ C #align is_pi_system IsPiSystem theorem IsPiSystem.singleton {α} (S : Set α) : IsPiSystem ({S} : Set (Set α)) := by intro s h_s t h_t _ rw [Set.mem_singleton_iff.1 h_s, Set.mem_singleton_iff.1 h_t, Set.inter_self, Set.mem_singleton_iff] #align is_pi_system.singleton IsPiSystem.singleton
Mathlib/MeasureTheory/PiSystem.lean
85
92
theorem IsPiSystem.insert_empty {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert ∅ S) := by
intro s hs t ht hst cases' hs with hs hs · simp [hs] · cases' ht with ht ht · simp [ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst)
707
import Mathlib.Logic.Encodable.Lattice import Mathlib.MeasureTheory.MeasurableSpace.Defs #align_import measure_theory.pi_system from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90" open MeasurableSpace Set open scoped Classical open MeasureTheory def IsPiSystem {α} (C : Set (Set α)) : Prop := ∀ᵉ (s ∈ C) (t ∈ C), (s ∩ t : Set α).Nonempty → s ∩ t ∈ C #align is_pi_system IsPiSystem theorem IsPiSystem.singleton {α} (S : Set α) : IsPiSystem ({S} : Set (Set α)) := by intro s h_s t h_t _ rw [Set.mem_singleton_iff.1 h_s, Set.mem_singleton_iff.1 h_t, Set.inter_self, Set.mem_singleton_iff] #align is_pi_system.singleton IsPiSystem.singleton theorem IsPiSystem.insert_empty {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert ∅ S) := by intro s hs t ht hst cases' hs with hs hs · simp [hs] · cases' ht with ht ht · simp [ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_empty IsPiSystem.insert_empty
Mathlib/MeasureTheory/PiSystem.lean
95
102
theorem IsPiSystem.insert_univ {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert Set.univ S) := by
intro s hs t ht hst cases' hs with hs hs · cases' ht with ht ht <;> simp [hs, ht] · cases' ht with ht ht · simp [hs, ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst)
707
import Mathlib.Logic.Encodable.Lattice import Mathlib.MeasureTheory.MeasurableSpace.Defs #align_import measure_theory.pi_system from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90" open MeasurableSpace Set open scoped Classical open MeasureTheory def IsPiSystem {α} (C : Set (Set α)) : Prop := ∀ᵉ (s ∈ C) (t ∈ C), (s ∩ t : Set α).Nonempty → s ∩ t ∈ C #align is_pi_system IsPiSystem theorem IsPiSystem.singleton {α} (S : Set α) : IsPiSystem ({S} : Set (Set α)) := by intro s h_s t h_t _ rw [Set.mem_singleton_iff.1 h_s, Set.mem_singleton_iff.1 h_t, Set.inter_self, Set.mem_singleton_iff] #align is_pi_system.singleton IsPiSystem.singleton theorem IsPiSystem.insert_empty {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert ∅ S) := by intro s hs t ht hst cases' hs with hs hs · simp [hs] · cases' ht with ht ht · simp [ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_empty IsPiSystem.insert_empty theorem IsPiSystem.insert_univ {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert Set.univ S) := by intro s hs t ht hst cases' hs with hs hs · cases' ht with ht ht <;> simp [hs, ht] · cases' ht with ht ht · simp [hs, ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_univ IsPiSystem.insert_univ
Mathlib/MeasureTheory/PiSystem.lean
105
109
theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) : IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by
rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst rw [← Set.preimage_inter] at hst ⊢ exact ⟨s ∩ t, h_pi s hs_mem t ht_mem (nonempty_of_nonempty_preimage hst), rfl⟩
707
import Mathlib.Logic.Encodable.Lattice import Mathlib.MeasureTheory.MeasurableSpace.Defs #align_import measure_theory.pi_system from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90" open MeasurableSpace Set open scoped Classical open MeasureTheory def IsPiSystem {α} (C : Set (Set α)) : Prop := ∀ᵉ (s ∈ C) (t ∈ C), (s ∩ t : Set α).Nonempty → s ∩ t ∈ C #align is_pi_system IsPiSystem theorem IsPiSystem.singleton {α} (S : Set α) : IsPiSystem ({S} : Set (Set α)) := by intro s h_s t h_t _ rw [Set.mem_singleton_iff.1 h_s, Set.mem_singleton_iff.1 h_t, Set.inter_self, Set.mem_singleton_iff] #align is_pi_system.singleton IsPiSystem.singleton theorem IsPiSystem.insert_empty {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert ∅ S) := by intro s hs t ht hst cases' hs with hs hs · simp [hs] · cases' ht with ht ht · simp [ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_empty IsPiSystem.insert_empty theorem IsPiSystem.insert_univ {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert Set.univ S) := by intro s hs t ht hst cases' hs with hs hs · cases' ht with ht ht <;> simp [hs, ht] · cases' ht with ht ht · simp [hs, ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_univ IsPiSystem.insert_univ theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) : IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst rw [← Set.preimage_inter] at hst ⊢ exact ⟨s ∩ t, h_pi s hs_mem t ht_mem (nonempty_of_nonempty_preimage hst), rfl⟩ #align is_pi_system.comap IsPiSystem.comap
Mathlib/MeasureTheory/PiSystem.lean
112
120
theorem isPiSystem_iUnion_of_directed_le {α ι} (p : ι → Set (Set α)) (hp_pi : ∀ n, IsPiSystem (p n)) (hp_directed : Directed (· ≤ ·) p) : IsPiSystem (⋃ n, p n) := by
intro t1 ht1 t2 ht2 h rw [Set.mem_iUnion] at ht1 ht2 ⊢ cases' ht1 with n ht1 cases' ht2 with m ht2 obtain ⟨k, hpnk, hpmk⟩ : ∃ k, p n ≤ p k ∧ p m ≤ p k := hp_directed n m exact ⟨k, hp_pi k t1 (hpnk ht1) t2 (hpmk ht2) h⟩
707
import Mathlib.Logic.Encodable.Lattice import Mathlib.MeasureTheory.MeasurableSpace.Defs #align_import measure_theory.pi_system from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90" open MeasurableSpace Set open scoped Classical open MeasureTheory def IsPiSystem {α} (C : Set (Set α)) : Prop := ∀ᵉ (s ∈ C) (t ∈ C), (s ∩ t : Set α).Nonempty → s ∩ t ∈ C #align is_pi_system IsPiSystem theorem IsPiSystem.singleton {α} (S : Set α) : IsPiSystem ({S} : Set (Set α)) := by intro s h_s t h_t _ rw [Set.mem_singleton_iff.1 h_s, Set.mem_singleton_iff.1 h_t, Set.inter_self, Set.mem_singleton_iff] #align is_pi_system.singleton IsPiSystem.singleton theorem IsPiSystem.insert_empty {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert ∅ S) := by intro s hs t ht hst cases' hs with hs hs · simp [hs] · cases' ht with ht ht · simp [ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_empty IsPiSystem.insert_empty theorem IsPiSystem.insert_univ {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert Set.univ S) := by intro s hs t ht hst cases' hs with hs hs · cases' ht with ht ht <;> simp [hs, ht] · cases' ht with ht ht · simp [hs, ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_univ IsPiSystem.insert_univ theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) : IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst rw [← Set.preimage_inter] at hst ⊢ exact ⟨s ∩ t, h_pi s hs_mem t ht_mem (nonempty_of_nonempty_preimage hst), rfl⟩ #align is_pi_system.comap IsPiSystem.comap theorem isPiSystem_iUnion_of_directed_le {α ι} (p : ι → Set (Set α)) (hp_pi : ∀ n, IsPiSystem (p n)) (hp_directed : Directed (· ≤ ·) p) : IsPiSystem (⋃ n, p n) := by intro t1 ht1 t2 ht2 h rw [Set.mem_iUnion] at ht1 ht2 ⊢ cases' ht1 with n ht1 cases' ht2 with m ht2 obtain ⟨k, hpnk, hpmk⟩ : ∃ k, p n ≤ p k ∧ p m ≤ p k := hp_directed n m exact ⟨k, hp_pi k t1 (hpnk ht1) t2 (hpmk ht2) h⟩ #align is_pi_system_Union_of_directed_le isPiSystem_iUnion_of_directed_le theorem isPiSystem_iUnion_of_monotone {α ι} [SemilatticeSup ι] (p : ι → Set (Set α)) (hp_pi : ∀ n, IsPiSystem (p n)) (hp_mono : Monotone p) : IsPiSystem (⋃ n, p n) := isPiSystem_iUnion_of_directed_le p hp_pi (Monotone.directed_le hp_mono) #align is_pi_system_Union_of_monotone isPiSystem_iUnion_of_monotone section Order variable {α : Type*} {ι ι' : Sort*} [LinearOrder α]
Mathlib/MeasureTheory/PiSystem.lean
132
134
theorem isPiSystem_image_Iio (s : Set α) : IsPiSystem (Iio '' s) := by
rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ - exact ⟨a ⊓ b, inf_ind a b ha hb, Iio_inter_Iio.symm⟩
707
import Mathlib.Logic.Encodable.Lattice import Mathlib.MeasureTheory.MeasurableSpace.Defs #align_import measure_theory.pi_system from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90" open MeasurableSpace Set open scoped Classical open MeasureTheory def IsPiSystem {α} (C : Set (Set α)) : Prop := ∀ᵉ (s ∈ C) (t ∈ C), (s ∩ t : Set α).Nonempty → s ∩ t ∈ C #align is_pi_system IsPiSystem theorem IsPiSystem.singleton {α} (S : Set α) : IsPiSystem ({S} : Set (Set α)) := by intro s h_s t h_t _ rw [Set.mem_singleton_iff.1 h_s, Set.mem_singleton_iff.1 h_t, Set.inter_self, Set.mem_singleton_iff] #align is_pi_system.singleton IsPiSystem.singleton theorem IsPiSystem.insert_empty {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert ∅ S) := by intro s hs t ht hst cases' hs with hs hs · simp [hs] · cases' ht with ht ht · simp [ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_empty IsPiSystem.insert_empty theorem IsPiSystem.insert_univ {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert Set.univ S) := by intro s hs t ht hst cases' hs with hs hs · cases' ht with ht ht <;> simp [hs, ht] · cases' ht with ht ht · simp [hs, ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_univ IsPiSystem.insert_univ theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) : IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst rw [← Set.preimage_inter] at hst ⊢ exact ⟨s ∩ t, h_pi s hs_mem t ht_mem (nonempty_of_nonempty_preimage hst), rfl⟩ #align is_pi_system.comap IsPiSystem.comap theorem isPiSystem_iUnion_of_directed_le {α ι} (p : ι → Set (Set α)) (hp_pi : ∀ n, IsPiSystem (p n)) (hp_directed : Directed (· ≤ ·) p) : IsPiSystem (⋃ n, p n) := by intro t1 ht1 t2 ht2 h rw [Set.mem_iUnion] at ht1 ht2 ⊢ cases' ht1 with n ht1 cases' ht2 with m ht2 obtain ⟨k, hpnk, hpmk⟩ : ∃ k, p n ≤ p k ∧ p m ≤ p k := hp_directed n m exact ⟨k, hp_pi k t1 (hpnk ht1) t2 (hpmk ht2) h⟩ #align is_pi_system_Union_of_directed_le isPiSystem_iUnion_of_directed_le theorem isPiSystem_iUnion_of_monotone {α ι} [SemilatticeSup ι] (p : ι → Set (Set α)) (hp_pi : ∀ n, IsPiSystem (p n)) (hp_mono : Monotone p) : IsPiSystem (⋃ n, p n) := isPiSystem_iUnion_of_directed_le p hp_pi (Monotone.directed_le hp_mono) #align is_pi_system_Union_of_monotone isPiSystem_iUnion_of_monotone section Order variable {α : Type*} {ι ι' : Sort*} [LinearOrder α] theorem isPiSystem_image_Iio (s : Set α) : IsPiSystem (Iio '' s) := by rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ - exact ⟨a ⊓ b, inf_ind a b ha hb, Iio_inter_Iio.symm⟩ #align is_pi_system_image_Iio isPiSystem_image_Iio theorem isPiSystem_Iio : IsPiSystem (range Iio : Set (Set α)) := @image_univ α _ Iio ▸ isPiSystem_image_Iio univ #align is_pi_system_Iio isPiSystem_Iio theorem isPiSystem_image_Ioi (s : Set α) : IsPiSystem (Ioi '' s) := @isPiSystem_image_Iio αᵒᵈ _ s #align is_pi_system_image_Ioi isPiSystem_image_Ioi theorem isPiSystem_Ioi : IsPiSystem (range Ioi : Set (Set α)) := @image_univ α _ Ioi ▸ isPiSystem_image_Ioi univ #align is_pi_system_Ioi isPiSystem_Ioi
Mathlib/MeasureTheory/PiSystem.lean
149
151
theorem isPiSystem_image_Iic (s : Set α) : IsPiSystem (Iic '' s) := by
rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ - exact ⟨a ⊓ b, inf_ind a b ha hb, Iic_inter_Iic.symm⟩
707
import Mathlib.Logic.Encodable.Lattice import Mathlib.MeasureTheory.MeasurableSpace.Defs #align_import measure_theory.pi_system from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90" open MeasurableSpace Set open scoped Classical open MeasureTheory def IsPiSystem {α} (C : Set (Set α)) : Prop := ∀ᵉ (s ∈ C) (t ∈ C), (s ∩ t : Set α).Nonempty → s ∩ t ∈ C #align is_pi_system IsPiSystem theorem IsPiSystem.singleton {α} (S : Set α) : IsPiSystem ({S} : Set (Set α)) := by intro s h_s t h_t _ rw [Set.mem_singleton_iff.1 h_s, Set.mem_singleton_iff.1 h_t, Set.inter_self, Set.mem_singleton_iff] #align is_pi_system.singleton IsPiSystem.singleton theorem IsPiSystem.insert_empty {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert ∅ S) := by intro s hs t ht hst cases' hs with hs hs · simp [hs] · cases' ht with ht ht · simp [ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_empty IsPiSystem.insert_empty theorem IsPiSystem.insert_univ {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert Set.univ S) := by intro s hs t ht hst cases' hs with hs hs · cases' ht with ht ht <;> simp [hs, ht] · cases' ht with ht ht · simp [hs, ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_univ IsPiSystem.insert_univ theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) : IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst rw [← Set.preimage_inter] at hst ⊢ exact ⟨s ∩ t, h_pi s hs_mem t ht_mem (nonempty_of_nonempty_preimage hst), rfl⟩ #align is_pi_system.comap IsPiSystem.comap theorem isPiSystem_iUnion_of_directed_le {α ι} (p : ι → Set (Set α)) (hp_pi : ∀ n, IsPiSystem (p n)) (hp_directed : Directed (· ≤ ·) p) : IsPiSystem (⋃ n, p n) := by intro t1 ht1 t2 ht2 h rw [Set.mem_iUnion] at ht1 ht2 ⊢ cases' ht1 with n ht1 cases' ht2 with m ht2 obtain ⟨k, hpnk, hpmk⟩ : ∃ k, p n ≤ p k ∧ p m ≤ p k := hp_directed n m exact ⟨k, hp_pi k t1 (hpnk ht1) t2 (hpmk ht2) h⟩ #align is_pi_system_Union_of_directed_le isPiSystem_iUnion_of_directed_le theorem isPiSystem_iUnion_of_monotone {α ι} [SemilatticeSup ι] (p : ι → Set (Set α)) (hp_pi : ∀ n, IsPiSystem (p n)) (hp_mono : Monotone p) : IsPiSystem (⋃ n, p n) := isPiSystem_iUnion_of_directed_le p hp_pi (Monotone.directed_le hp_mono) #align is_pi_system_Union_of_monotone isPiSystem_iUnion_of_monotone section Order variable {α : Type*} {ι ι' : Sort*} [LinearOrder α] theorem isPiSystem_image_Iio (s : Set α) : IsPiSystem (Iio '' s) := by rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ - exact ⟨a ⊓ b, inf_ind a b ha hb, Iio_inter_Iio.symm⟩ #align is_pi_system_image_Iio isPiSystem_image_Iio theorem isPiSystem_Iio : IsPiSystem (range Iio : Set (Set α)) := @image_univ α _ Iio ▸ isPiSystem_image_Iio univ #align is_pi_system_Iio isPiSystem_Iio theorem isPiSystem_image_Ioi (s : Set α) : IsPiSystem (Ioi '' s) := @isPiSystem_image_Iio αᵒᵈ _ s #align is_pi_system_image_Ioi isPiSystem_image_Ioi theorem isPiSystem_Ioi : IsPiSystem (range Ioi : Set (Set α)) := @image_univ α _ Ioi ▸ isPiSystem_image_Ioi univ #align is_pi_system_Ioi isPiSystem_Ioi theorem isPiSystem_image_Iic (s : Set α) : IsPiSystem (Iic '' s) := by rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ - exact ⟨a ⊓ b, inf_ind a b ha hb, Iic_inter_Iic.symm⟩ theorem isPiSystem_Iic : IsPiSystem (range Iic : Set (Set α)) := @image_univ α _ Iic ▸ isPiSystem_image_Iic univ #align is_pi_system_Iic isPiSystem_Iic theorem isPiSystem_image_Ici (s : Set α) : IsPiSystem (Ici '' s) := @isPiSystem_image_Iic αᵒᵈ _ s theorem isPiSystem_Ici : IsPiSystem (range Ici : Set (Set α)) := @image_univ α _ Ici ▸ isPiSystem_image_Ici univ #align is_pi_system_Ici isPiSystem_Ici
Mathlib/MeasureTheory/PiSystem.lean
164
170
theorem isPiSystem_Ixx_mem {Ixx : α → α → Set α} {p : α → α → Prop} (Hne : ∀ {a b}, (Ixx a b).Nonempty → p a b) (Hi : ∀ {a₁ b₁ a₂ b₂}, Ixx a₁ b₁ ∩ Ixx a₂ b₂ = Ixx (max a₁ a₂) (min b₁ b₂)) (s t : Set α) : IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), p l u ∧ Ixx l u = S } := by
rintro _ ⟨l₁, hls₁, u₁, hut₁, _, rfl⟩ _ ⟨l₂, hls₂, u₂, hut₂, _, rfl⟩ simp only [Hi] exact fun H => ⟨l₁ ⊔ l₂, sup_ind l₁ l₂ hls₁ hls₂, u₁ ⊓ u₂, inf_ind u₁ u₂ hut₁ hut₂, Hne H, rfl⟩
707
import Mathlib.Logic.Encodable.Lattice import Mathlib.MeasureTheory.MeasurableSpace.Defs #align_import measure_theory.pi_system from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90" open MeasurableSpace Set open scoped Classical open MeasureTheory def IsPiSystem {α} (C : Set (Set α)) : Prop := ∀ᵉ (s ∈ C) (t ∈ C), (s ∩ t : Set α).Nonempty → s ∩ t ∈ C #align is_pi_system IsPiSystem theorem IsPiSystem.singleton {α} (S : Set α) : IsPiSystem ({S} : Set (Set α)) := by intro s h_s t h_t _ rw [Set.mem_singleton_iff.1 h_s, Set.mem_singleton_iff.1 h_t, Set.inter_self, Set.mem_singleton_iff] #align is_pi_system.singleton IsPiSystem.singleton theorem IsPiSystem.insert_empty {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert ∅ S) := by intro s hs t ht hst cases' hs with hs hs · simp [hs] · cases' ht with ht ht · simp [ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_empty IsPiSystem.insert_empty theorem IsPiSystem.insert_univ {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert Set.univ S) := by intro s hs t ht hst cases' hs with hs hs · cases' ht with ht ht <;> simp [hs, ht] · cases' ht with ht ht · simp [hs, ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_univ IsPiSystem.insert_univ theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) : IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst rw [← Set.preimage_inter] at hst ⊢ exact ⟨s ∩ t, h_pi s hs_mem t ht_mem (nonempty_of_nonempty_preimage hst), rfl⟩ #align is_pi_system.comap IsPiSystem.comap theorem isPiSystem_iUnion_of_directed_le {α ι} (p : ι → Set (Set α)) (hp_pi : ∀ n, IsPiSystem (p n)) (hp_directed : Directed (· ≤ ·) p) : IsPiSystem (⋃ n, p n) := by intro t1 ht1 t2 ht2 h rw [Set.mem_iUnion] at ht1 ht2 ⊢ cases' ht1 with n ht1 cases' ht2 with m ht2 obtain ⟨k, hpnk, hpmk⟩ : ∃ k, p n ≤ p k ∧ p m ≤ p k := hp_directed n m exact ⟨k, hp_pi k t1 (hpnk ht1) t2 (hpmk ht2) h⟩ #align is_pi_system_Union_of_directed_le isPiSystem_iUnion_of_directed_le theorem isPiSystem_iUnion_of_monotone {α ι} [SemilatticeSup ι] (p : ι → Set (Set α)) (hp_pi : ∀ n, IsPiSystem (p n)) (hp_mono : Monotone p) : IsPiSystem (⋃ n, p n) := isPiSystem_iUnion_of_directed_le p hp_pi (Monotone.directed_le hp_mono) #align is_pi_system_Union_of_monotone isPiSystem_iUnion_of_monotone inductive generatePiSystem {α} (S : Set (Set α)) : Set (Set α) | base {s : Set α} (h_s : s ∈ S) : generatePiSystem S s | inter {s t : Set α} (h_s : generatePiSystem S s) (h_t : generatePiSystem S t) (h_nonempty : (s ∩ t).Nonempty) : generatePiSystem S (s ∩ t) #align generate_pi_system generatePiSystem theorem isPiSystem_generatePiSystem {α} (S : Set (Set α)) : IsPiSystem (generatePiSystem S) := fun _ h_s _ h_t h_nonempty => generatePiSystem.inter h_s h_t h_nonempty #align is_pi_system_generate_pi_system isPiSystem_generatePiSystem theorem subset_generatePiSystem_self {α} (S : Set (Set α)) : S ⊆ generatePiSystem S := fun _ => generatePiSystem.base #align subset_generate_pi_system_self subset_generatePiSystem_self theorem generatePiSystem_subset_self {α} {S : Set (Set α)} (h_S : IsPiSystem S) : generatePiSystem S ⊆ S := fun x h => by induction' h with _ h_s s u _ _ h_nonempty h_s h_u · exact h_s · exact h_S _ h_s _ h_u h_nonempty #align generate_pi_system_subset_self generatePiSystem_subset_self theorem generatePiSystem_eq {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : generatePiSystem S = S := Set.Subset.antisymm (generatePiSystem_subset_self h_pi) (subset_generatePiSystem_self S) #align generate_pi_system_eq generatePiSystem_eq theorem generatePiSystem_mono {α} {S T : Set (Set α)} (hST : S ⊆ T) : generatePiSystem S ⊆ generatePiSystem T := fun t ht => by induction' ht with s h_s s u _ _ h_nonempty h_s h_u · exact generatePiSystem.base (Set.mem_of_subset_of_mem hST h_s) · exact isPiSystem_generatePiSystem T _ h_s _ h_u h_nonempty #align generate_pi_system_mono generatePiSystem_mono
Mathlib/MeasureTheory/PiSystem.lean
256
261
theorem generatePiSystem_measurableSet {α} [M : MeasurableSpace α] {S : Set (Set α)} (h_meas_S : ∀ s ∈ S, MeasurableSet s) (t : Set α) (h_in_pi : t ∈ generatePiSystem S) : MeasurableSet t := by
induction' h_in_pi with s h_s s u _ _ _ h_s h_u · apply h_meas_S _ h_s · apply MeasurableSet.inter h_s h_u
707
import Mathlib.MeasureTheory.PiSystem import Mathlib.Order.OmegaCompletePartialOrder import Mathlib.Topology.Constructions import Mathlib.MeasureTheory.MeasurableSpace.Basic open Set namespace MeasureTheory variable {ι : Type _} {α : ι → Type _} section squareCylinders def squareCylinders (C : ∀ i, Set (Set (α i))) : Set (Set (∀ i, α i)) := {S | ∃ s : Finset ι, ∃ t ∈ univ.pi C, S = (s : Set ι).pi t}
Mathlib/MeasureTheory/Constructions/Cylinders.lean
57
61
theorem squareCylinders_eq_iUnion_image (C : ∀ i, Set (Set (α i))) : squareCylinders C = ⋃ s : Finset ι, (fun t ↦ (s : Set ι).pi t) '' univ.pi C := by
ext1 f simp only [squareCylinders, mem_iUnion, mem_image, mem_univ_pi, exists_prop, mem_setOf_eq, eq_comm (a := f)]
708