Context
stringlengths
57
85k
file_name
stringlengths
21
79
start
int64
14
2.42k
end
int64
18
2.43k
theorem
stringlengths
25
2.71k
proof
stringlengths
5
10.6k
import Mathlib.Algebra.BigOperators.Group.List import Mathlib.Data.Vector.Defs import Mathlib.Data.List.Nodup import Mathlib.Data.List.OfFn import Mathlib.Data.List.InsertNth import Mathlib.Control.Applicative import Mathlib.Control.Traversable.Basic #align_import data.vector.basic from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" set_option autoImplicit true universe u variable {n : ℕ} namespace Vector variable {α : Type*} @[inherit_doc] infixr:67 " ::ᵥ " => Vector.cons attribute [simp] head_cons tail_cons instance [Inhabited α] : Inhabited (Vector α n) := ⟨ofFn default⟩ theorem toList_injective : Function.Injective (@toList α n) := Subtype.val_injective #align vector.to_list_injective Vector.toList_injective @[ext] theorem ext : ∀ {v w : Vector α n} (_ : ∀ m : Fin n, Vector.get v m = Vector.get w m), v = w | ⟨v, hv⟩, ⟨w, hw⟩, h => Subtype.eq (List.ext_get (by rw [hv, hw]) fun m hm _ => h ⟨m, hv ▸ hm⟩) #align vector.ext Vector.ext instance zero_subsingleton : Subsingleton (Vector α 0) := ⟨fun _ _ => Vector.ext fun m => Fin.elim0 m⟩ #align vector.zero_subsingleton Vector.zero_subsingleton @[simp] theorem cons_val (a : α) : ∀ v : Vector α n, (a ::ᵥ v).val = a :: v.val | ⟨_, _⟩ => rfl #align vector.cons_val Vector.cons_val #align vector.cons_head Vector.head_cons #align vector.cons_tail Vector.tail_cons theorem eq_cons_iff (a : α) (v : Vector α n.succ) (v' : Vector α n) : v = a ::ᵥ v' ↔ v.head = a ∧ v.tail = v' := ⟨fun h => h.symm ▸ ⟨head_cons a v', tail_cons a v'⟩, fun h => _root_.trans (cons_head_tail v).symm (by rw [h.1, h.2])⟩ #align vector.eq_cons_iff Vector.eq_cons_iff theorem ne_cons_iff (a : α) (v : Vector α n.succ) (v' : Vector α n) : v ≠ a ::ᵥ v' ↔ v.head ≠ a ∨ v.tail ≠ v' := by rw [Ne, eq_cons_iff a v v', not_and_or] #align vector.ne_cons_iff Vector.ne_cons_iff theorem exists_eq_cons (v : Vector α n.succ) : ∃ (a : α) (as : Vector α n), v = a ::ᵥ as := ⟨v.head, v.tail, (eq_cons_iff v.head v v.tail).2 ⟨rfl, rfl⟩⟩ #align vector.exists_eq_cons Vector.exists_eq_cons @[simp] theorem toList_ofFn : ∀ {n} (f : Fin n → α), toList (ofFn f) = List.ofFn f | 0, f => by rw [ofFn, List.ofFn_zero, toList, nil] | n + 1, f => by rw [ofFn, List.ofFn_succ, toList_cons, toList_ofFn] #align vector.to_list_of_fn Vector.toList_ofFn @[simp] theorem mk_toList : ∀ (v : Vector α n) (h), (⟨toList v, h⟩ : Vector α n) = v | ⟨_, _⟩, _ => rfl #align vector.mk_to_list Vector.mk_toList @[simp] theorem length_val (v : Vector α n) : v.val.length = n := v.2 -- Porting note: not used in mathlib and coercions done differently in Lean 4 -- @[simp] -- theorem length_coe (v : Vector α n) : -- ((coe : { l : List α // l.length = n } → List α) v).length = n := -- v.2 #noalign vector.length_coe @[simp] theorem toList_map {β : Type*} (v : Vector α n) (f : α → β) : (v.map f).toList = v.toList.map f := by cases v; rfl #align vector.to_list_map Vector.toList_map @[simp] theorem head_map {β : Type*} (v : Vector α (n + 1)) (f : α → β) : (v.map f).head = f v.head := by obtain ⟨a, v', h⟩ := Vector.exists_eq_cons v rw [h, map_cons, head_cons, head_cons] #align vector.head_map Vector.head_map @[simp] theorem tail_map {β : Type*} (v : Vector α (n + 1)) (f : α → β) : (v.map f).tail = v.tail.map f := by obtain ⟨a, v', h⟩ := Vector.exists_eq_cons v rw [h, map_cons, tail_cons, tail_cons] #align vector.tail_map Vector.tail_map theorem get_eq_get (v : Vector α n) (i : Fin n) : v.get i = v.toList.get (Fin.cast v.toList_length.symm i) := rfl #align vector.nth_eq_nth_le Vector.get_eq_getₓ @[simp] theorem get_replicate (a : α) (i : Fin n) : (Vector.replicate n a).get i = a := by apply List.get_replicate #align vector.nth_repeat Vector.get_replicate @[simp] theorem get_map {β : Type*} (v : Vector α n) (f : α → β) (i : Fin n) : (v.map f).get i = f (v.get i) := by cases v; simp [Vector.map, get_eq_get]; rfl #align vector.nth_map Vector.get_map @[simp] theorem map₂_nil (f : α → β → γ) : Vector.map₂ f nil nil = nil := rfl @[simp] theorem map₂_cons (hd₁ : α) (tl₁ : Vector α n) (hd₂ : β) (tl₂ : Vector β n) (f : α → β → γ) : Vector.map₂ f (hd₁ ::ᵥ tl₁) (hd₂ ::ᵥ tl₂) = f hd₁ hd₂ ::ᵥ (Vector.map₂ f tl₁ tl₂) := rfl @[simp] theorem get_ofFn {n} (f : Fin n → α) (i) : get (ofFn f) i = f i := by conv_rhs => erw [← List.get_ofFn f ⟨i, by simp⟩] simp only [get_eq_get] congr <;> simp [Fin.heq_ext_iff] #align vector.nth_of_fn Vector.get_ofFn @[simp] theorem ofFn_get (v : Vector α n) : ofFn (get v) = v := by rcases v with ⟨l, rfl⟩ apply toList_injective dsimp simpa only [toList_ofFn] using List.ofFn_get _ #align vector.of_fn_nth Vector.ofFn_get def _root_.Equiv.vectorEquivFin (α : Type*) (n : ℕ) : Vector α n ≃ (Fin n → α) := ⟨Vector.get, Vector.ofFn, Vector.ofFn_get, fun f => funext <| Vector.get_ofFn f⟩ #align equiv.vector_equiv_fin Equiv.vectorEquivFin theorem get_tail (x : Vector α n) (i) : x.tail.get i = x.get ⟨i.1 + 1, by omega⟩ := by cases' i with i ih; dsimp rcases x with ⟨_ | _, h⟩ <;> try rfl rw [List.length] at h rw [← h] at ih contradiction #align vector.nth_tail Vector.get_tail @[simp] theorem get_tail_succ : ∀ (v : Vector α n.succ) (i : Fin n), get (tail v) i = get v i.succ | ⟨a :: l, e⟩, ⟨i, h⟩ => by simp [get_eq_get]; rfl #align vector.nth_tail_succ Vector.get_tail_succ @[simp] theorem tail_val : ∀ v : Vector α n.succ, v.tail.val = v.val.tail | ⟨_ :: _, _⟩ => rfl #align vector.tail_val Vector.tail_val @[simp] theorem tail_nil : (@nil α).tail = nil := rfl #align vector.tail_nil Vector.tail_nil @[simp] theorem singleton_tail : ∀ (v : Vector α 1), v.tail = Vector.nil | ⟨[_], _⟩ => rfl #align vector.singleton_tail Vector.singleton_tail @[simp] theorem tail_ofFn {n : ℕ} (f : Fin n.succ → α) : tail (ofFn f) = ofFn fun i => f i.succ := (ofFn_get _).symm.trans <| by congr funext i rw [get_tail, get_ofFn] rfl #align vector.tail_of_fn Vector.tail_ofFn @[simp] theorem toList_empty (v : Vector α 0) : v.toList = [] := List.length_eq_zero.mp v.2 #align vector.to_list_empty Vector.toList_empty @[simp] theorem toList_singleton (v : Vector α 1) : v.toList = [v.head] := by rw [← v.cons_head_tail] simp only [toList_cons, toList_nil, head_cons, eq_self_iff_true, and_self_iff, singleton_tail] #align vector.to_list_singleton Vector.toList_singleton @[simp] theorem empty_toList_eq_ff (v : Vector α (n + 1)) : v.toList.isEmpty = false := match v with | ⟨_ :: _, _⟩ => rfl #align vector.empty_to_list_eq_ff Vector.empty_toList_eq_ff theorem not_empty_toList (v : Vector α (n + 1)) : ¬v.toList.isEmpty := by simp only [empty_toList_eq_ff, Bool.coe_sort_false, not_false_iff] #align vector.not_empty_to_list Vector.not_empty_toList @[simp] theorem map_id {n : ℕ} (v : Vector α n) : Vector.map id v = v := Vector.eq _ _ (by simp only [List.map_id, Vector.toList_map]) #align vector.map_id Vector.map_id theorem nodup_iff_injective_get {v : Vector α n} : v.toList.Nodup ↔ Function.Injective v.get := by cases' v with l hl subst hl exact List.nodup_iff_injective_get #align vector.nodup_iff_nth_inj Vector.nodup_iff_injective_get theorem head?_toList : ∀ v : Vector α n.succ, (toList v).head? = some (head v) | ⟨_ :: _, _⟩ => rfl #align vector.head'_to_list Vector.head?_toList def reverse (v : Vector α n) : Vector α n := ⟨v.toList.reverse, by simp⟩ #align vector.reverse Vector.reverse theorem toList_reverse {v : Vector α n} : v.reverse.toList = v.toList.reverse := rfl #align vector.to_list_reverse Vector.toList_reverse @[simp] theorem reverse_reverse {v : Vector α n} : v.reverse.reverse = v := by cases v simp [Vector.reverse] #align vector.reverse_reverse Vector.reverse_reverse @[simp] theorem get_zero : ∀ v : Vector α n.succ, get v 0 = head v | ⟨_ :: _, _⟩ => rfl #align vector.nth_zero Vector.get_zero @[simp] theorem head_ofFn {n : ℕ} (f : Fin n.succ → α) : head (ofFn f) = f 0 := by rw [← get_zero, get_ofFn] #align vector.head_of_fn Vector.head_ofFn --@[simp] Porting note (#10618): simp can prove it theorem get_cons_zero (a : α) (v : Vector α n) : get (a ::ᵥ v) 0 = a := by simp [get_zero] #align vector.nth_cons_zero Vector.get_cons_zero @[simp] theorem get_cons_nil : ∀ {ix : Fin 1} (x : α), get (x ::ᵥ nil) ix = x | ⟨0, _⟩, _ => rfl #align vector.nth_cons_nil Vector.get_cons_nil @[simp]
Mathlib/Data/Vector/Basic.lean
280
281
theorem get_cons_succ (a : α) (v : Vector α n) (i : Fin n) : get (a ::ᵥ v) i.succ = get v i := by
rw [← get_tail_succ, tail_cons]
import Mathlib.AlgebraicTopology.SimplexCategory import Mathlib.CategoryTheory.Comma.Arrow import Mathlib.CategoryTheory.Limits.FunctorCategory import Mathlib.CategoryTheory.Opposites #align_import algebraic_topology.simplicial_object from "leanprover-community/mathlib"@"5ed51dc37c6b891b79314ee11a50adc2b1df6fd6" open Opposite open CategoryTheory open CategoryTheory.Limits universe v u v' u' namespace CategoryTheory variable (C : Type u) [Category.{v} C] -- porting note (#5171): removed @[nolint has_nonempty_instance] def SimplicialObject := SimplexCategoryᵒᵖ ⥤ C #align category_theory.simplicial_object CategoryTheory.SimplicialObject @[simps!] instance : Category (SimplicialObject C) := by dsimp only [SimplicialObject] infer_instance namespace SimplicialObject set_option quotPrecheck false in scoped[Simplicial] notation3:1000 X " _[" n "]" => (X : CategoryTheory.SimplicialObject _).obj (Opposite.op (SimplexCategory.mk n)) open Simplicial instance {J : Type v} [SmallCategory J] [HasLimitsOfShape J C] : HasLimitsOfShape J (SimplicialObject C) := by dsimp [SimplicialObject] infer_instance instance [HasLimits C] : HasLimits (SimplicialObject C) := ⟨inferInstance⟩ instance {J : Type v} [SmallCategory J] [HasColimitsOfShape J C] : HasColimitsOfShape J (SimplicialObject C) := by dsimp [SimplicialObject] infer_instance instance [HasColimits C] : HasColimits (SimplicialObject C) := ⟨inferInstance⟩ variable {C} -- Porting note (#10688): added to ease automation @[ext] lemma hom_ext {X Y : SimplicialObject C} (f g : X ⟶ Y) (h : ∀ (n : SimplexCategoryᵒᵖ), f.app n = g.app n) : f = g := NatTrans.ext _ _ (by ext; apply h) variable (X : SimplicialObject C) def δ {n} (i : Fin (n + 2)) : X _[n + 1] ⟶ X _[n] := X.map (SimplexCategory.δ i).op #align category_theory.simplicial_object.δ CategoryTheory.SimplicialObject.δ def σ {n} (i : Fin (n + 1)) : X _[n] ⟶ X _[n + 1] := X.map (SimplexCategory.σ i).op #align category_theory.simplicial_object.σ CategoryTheory.SimplicialObject.σ def eqToIso {n m : ℕ} (h : n = m) : X _[n] ≅ X _[m] := X.mapIso (CategoryTheory.eqToIso (by congr)) #align category_theory.simplicial_object.eq_to_iso CategoryTheory.SimplicialObject.eqToIso @[simp] theorem eqToIso_refl {n : ℕ} (h : n = n) : X.eqToIso h = Iso.refl _ := by ext simp [eqToIso] #align category_theory.simplicial_object.eq_to_iso_refl CategoryTheory.SimplicialObject.eqToIso_refl @[reassoc] theorem δ_comp_δ {n} {i j : Fin (n + 2)} (H : i ≤ j) : X.δ j.succ ≫ X.δ i = X.δ (Fin.castSucc i) ≫ X.δ j := by dsimp [δ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ H] #align category_theory.simplicial_object.δ_comp_δ CategoryTheory.SimplicialObject.δ_comp_δ @[reassoc] theorem δ_comp_δ' {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : Fin.castSucc i < j) : X.δ j ≫ X.δ i = X.δ (Fin.castSucc i) ≫ X.δ (j.pred fun (hj : j = 0) => by simp [hj, Fin.not_lt_zero] at H) := by dsimp [δ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ' H] #align category_theory.simplicial_object.δ_comp_δ' CategoryTheory.SimplicialObject.δ_comp_δ' @[reassoc] theorem δ_comp_δ'' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : i ≤ Fin.castSucc j) : X.δ j.succ ≫ X.δ (i.castLT (Nat.lt_of_le_of_lt (Fin.le_iff_val_le_val.mp H) j.is_lt)) = X.δ i ≫ X.δ j := by dsimp [δ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ'' H] #align category_theory.simplicial_object.δ_comp_δ'' CategoryTheory.SimplicialObject.δ_comp_δ'' @[reassoc] theorem δ_comp_δ_self {n} {i : Fin (n + 2)} : X.δ (Fin.castSucc i) ≫ X.δ i = X.δ i.succ ≫ X.δ i := by dsimp [δ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ_self] #align category_theory.simplicial_object.δ_comp_δ_self CategoryTheory.SimplicialObject.δ_comp_δ_self @[reassoc] theorem δ_comp_δ_self' {n} {j : Fin (n + 3)} {i : Fin (n + 2)} (H : j = Fin.castSucc i) : X.δ j ≫ X.δ i = X.δ i.succ ≫ X.δ i := by subst H rw [δ_comp_δ_self] #align category_theory.simplicial_object.δ_comp_δ_self' CategoryTheory.SimplicialObject.δ_comp_δ_self' @[reassoc] theorem δ_comp_σ_of_le {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : i ≤ Fin.castSucc j) : X.σ j.succ ≫ X.δ (Fin.castSucc i) = X.δ i ≫ X.σ j := by dsimp [δ, σ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_of_le H] #align category_theory.simplicial_object.δ_comp_σ_of_le CategoryTheory.SimplicialObject.δ_comp_σ_of_le @[reassoc] theorem δ_comp_σ_self {n} {i : Fin (n + 1)} : X.σ i ≫ X.δ (Fin.castSucc i) = 𝟙 _ := by dsimp [δ, σ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_self, op_id, X.map_id] #align category_theory.simplicial_object.δ_comp_σ_self CategoryTheory.SimplicialObject.δ_comp_σ_self @[reassoc] theorem δ_comp_σ_self' {n} {j : Fin (n + 2)} {i : Fin (n + 1)} (H : j = Fin.castSucc i) : X.σ i ≫ X.δ j = 𝟙 _ := by subst H rw [δ_comp_σ_self] #align category_theory.simplicial_object.δ_comp_σ_self' CategoryTheory.SimplicialObject.δ_comp_σ_self' @[reassoc] theorem δ_comp_σ_succ {n} {i : Fin (n + 1)} : X.σ i ≫ X.δ i.succ = 𝟙 _ := by dsimp [δ, σ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_succ, op_id, X.map_id] #align category_theory.simplicial_object.δ_comp_σ_succ CategoryTheory.SimplicialObject.δ_comp_σ_succ @[reassoc] theorem δ_comp_σ_succ' {n} {j : Fin (n + 2)} {i : Fin (n + 1)} (H : j = i.succ) : X.σ i ≫ X.δ j = 𝟙 _ := by subst H rw [δ_comp_σ_succ] #align category_theory.simplicial_object.δ_comp_σ_succ' CategoryTheory.SimplicialObject.δ_comp_σ_succ' @[reassoc] theorem δ_comp_σ_of_gt {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : Fin.castSucc j < i) : X.σ (Fin.castSucc j) ≫ X.δ i.succ = X.δ i ≫ X.σ j := by dsimp [δ, σ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_of_gt H] #align category_theory.simplicial_object.δ_comp_σ_of_gt CategoryTheory.SimplicialObject.δ_comp_σ_of_gt @[reassoc] theorem δ_comp_σ_of_gt' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : j.succ < i) : X.σ j ≫ X.δ i = X.δ (i.pred fun (hi : i = 0) => by simp only [Fin.not_lt_zero, hi] at H) ≫ X.σ (j.castLT ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le H i.is_le))) := by dsimp [δ, σ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_of_gt' H] #align category_theory.simplicial_object.δ_comp_σ_of_gt' CategoryTheory.SimplicialObject.δ_comp_σ_of_gt' @[reassoc] theorem σ_comp_σ {n} {i j : Fin (n + 1)} (H : i ≤ j) : X.σ j ≫ X.σ (Fin.castSucc i) = X.σ i ≫ X.σ j.succ := by dsimp [δ, σ] simp only [← X.map_comp, ← op_comp, SimplexCategory.σ_comp_σ H] #align category_theory.simplicial_object.σ_comp_σ CategoryTheory.SimplicialObject.σ_comp_σ open Simplicial @[reassoc (attr := simp)] theorem δ_naturality {X' X : SimplicialObject C} (f : X ⟶ X') {n : ℕ} (i : Fin (n + 2)) : X.δ i ≫ f.app (op [n]) = f.app (op [n + 1]) ≫ X'.δ i := f.naturality _ #align category_theory.simplicial_object.δ_naturality CategoryTheory.SimplicialObject.δ_naturality @[reassoc (attr := simp)] theorem σ_naturality {X' X : SimplicialObject C} (f : X ⟶ X') {n : ℕ} (i : Fin (n + 1)) : X.σ i ≫ f.app (op [n + 1]) = f.app (op [n]) ≫ X'.σ i := f.naturality _ #align category_theory.simplicial_object.σ_naturality CategoryTheory.SimplicialObject.σ_naturality variable (C) @[simps!] def whiskering (D : Type*) [Category D] : (C ⥤ D) ⥤ SimplicialObject C ⥤ SimplicialObject D := whiskeringRight _ _ _ #align category_theory.simplicial_object.whiskering CategoryTheory.SimplicialObject.whiskering -- porting note (#5171): removed @[nolint has_nonempty_instance] def Truncated (n : ℕ) := (SimplexCategory.Truncated n)ᵒᵖ ⥤ C #align category_theory.simplicial_object.truncated CategoryTheory.SimplicialObject.Truncated instance {n : ℕ} : Category (Truncated C n) := by dsimp [Truncated] infer_instance variable {C} variable (C) abbrev const : C ⥤ SimplicialObject C := CategoryTheory.Functor.const _ #align category_theory.simplicial_object.const CategoryTheory.SimplicialObject.const -- porting note (#5171): removed @[nolint has_nonempty_instance] def Augmented := Comma (𝟭 (SimplicialObject C)) (const C) #align category_theory.simplicial_object.augmented CategoryTheory.SimplicialObject.Augmented @[simps!] instance : Category (Augmented C) := by dsimp only [Augmented] infer_instance variable {C} @[simps] def augment (X : SimplicialObject C) (X₀ : C) (f : X _[0] ⟶ X₀) (w : ∀ (i : SimplexCategory) (g₁ g₂ : ([0] : SimplexCategory) ⟶ i), X.map g₁.op ≫ f = X.map g₂.op ≫ f) : SimplicialObject.Augmented C where left := X right := X₀ hom := { app := fun i => X.map (SimplexCategory.const _ _ 0).op ≫ f naturality := by intro i j g dsimp rw [← g.op_unop] simpa only [← X.map_comp, ← Category.assoc, Category.comp_id, ← op_comp] using w _ _ _ } #align category_theory.simplicial_object.augment CategoryTheory.SimplicialObject.augment -- Porting note: removed @[simp] as the linter complains
Mathlib/AlgebraicTopology/SimplicialObject.lean
400
401
theorem augment_hom_zero (X : SimplicialObject C) (X₀ : C) (f : X _[0] ⟶ X₀) (w) : (X.augment X₀ f w).hom.app (op [0]) = f := by
simp
import Mathlib.LinearAlgebra.Matrix.Symmetric import Mathlib.LinearAlgebra.Matrix.Orthogonal import Mathlib.Data.Matrix.Kronecker #align_import linear_algebra.matrix.is_diag from "leanprover-community/mathlib"@"55e2dfde0cff928ce5c70926a3f2c7dee3e2dd99" namespace Matrix variable {α β R n m : Type*} open Function open Matrix Kronecker def IsDiag [Zero α] (A : Matrix n n α) : Prop := Pairwise fun i j => A i j = 0 #align matrix.is_diag Matrix.IsDiag @[simp] theorem isDiag_diagonal [Zero α] [DecidableEq n] (d : n → α) : (diagonal d).IsDiag := fun _ _ => Matrix.diagonal_apply_ne _ #align matrix.is_diag_diagonal Matrix.isDiag_diagonal theorem IsDiag.diagonal_diag [Zero α] [DecidableEq n] {A : Matrix n n α} (h : A.IsDiag) : diagonal (diag A) = A := ext fun i j => by obtain rfl | hij := Decidable.eq_or_ne i j · rw [diagonal_apply_eq, diag] · rw [diagonal_apply_ne _ hij, h hij] #align matrix.is_diag.diagonal_diag Matrix.IsDiag.diagonal_diag theorem isDiag_iff_diagonal_diag [Zero α] [DecidableEq n] (A : Matrix n n α) : A.IsDiag ↔ diagonal (diag A) = A := ⟨IsDiag.diagonal_diag, fun hd => hd ▸ isDiag_diagonal (diag A)⟩ #align matrix.is_diag_iff_diagonal_diag Matrix.isDiag_iff_diagonal_diag theorem isDiag_of_subsingleton [Zero α] [Subsingleton n] (A : Matrix n n α) : A.IsDiag := fun i j h => (h <| Subsingleton.elim i j).elim #align matrix.is_diag_of_subsingleton Matrix.isDiag_of_subsingleton @[simp] theorem isDiag_zero [Zero α] : (0 : Matrix n n α).IsDiag := fun _ _ _ => rfl #align matrix.is_diag_zero Matrix.isDiag_zero @[simp] theorem isDiag_one [DecidableEq n] [Zero α] [One α] : (1 : Matrix n n α).IsDiag := fun _ _ => one_apply_ne #align matrix.is_diag_one Matrix.isDiag_one theorem IsDiag.map [Zero α] [Zero β] {A : Matrix n n α} (ha : A.IsDiag) {f : α → β} (hf : f 0 = 0) : (A.map f).IsDiag := by intro i j h simp [ha h, hf] #align matrix.is_diag.map Matrix.IsDiag.map theorem IsDiag.neg [AddGroup α] {A : Matrix n n α} (ha : A.IsDiag) : (-A).IsDiag := by intro i j h simp [ha h] #align matrix.is_diag.neg Matrix.IsDiag.neg @[simp] theorem isDiag_neg_iff [AddGroup α] {A : Matrix n n α} : (-A).IsDiag ↔ A.IsDiag := ⟨fun ha _ _ h => neg_eq_zero.1 (ha h), IsDiag.neg⟩ #align matrix.is_diag_neg_iff Matrix.isDiag_neg_iff theorem IsDiag.add [AddZeroClass α] {A B : Matrix n n α} (ha : A.IsDiag) (hb : B.IsDiag) : (A + B).IsDiag := by intro i j h simp [ha h, hb h] #align matrix.is_diag.add Matrix.IsDiag.add theorem IsDiag.sub [AddGroup α] {A B : Matrix n n α} (ha : A.IsDiag) (hb : B.IsDiag) : (A - B).IsDiag := by intro i j h simp [ha h, hb h] #align matrix.is_diag.sub Matrix.IsDiag.sub theorem IsDiag.smul [Monoid R] [AddMonoid α] [DistribMulAction R α] (k : R) {A : Matrix n n α} (ha : A.IsDiag) : (k • A).IsDiag := by intro i j h simp [ha h] #align matrix.is_diag.smul Matrix.IsDiag.smul @[simp] theorem isDiag_smul_one (n) [Semiring α] [DecidableEq n] (k : α) : (k • (1 : Matrix n n α)).IsDiag := isDiag_one.smul k #align matrix.is_diag_smul_one Matrix.isDiag_smul_one theorem IsDiag.transpose [Zero α] {A : Matrix n n α} (ha : A.IsDiag) : Aᵀ.IsDiag := fun _ _ h => ha h.symm #align matrix.is_diag.transpose Matrix.IsDiag.transpose @[simp] theorem isDiag_transpose_iff [Zero α] {A : Matrix n n α} : Aᵀ.IsDiag ↔ A.IsDiag := ⟨IsDiag.transpose, IsDiag.transpose⟩ #align matrix.is_diag_transpose_iff Matrix.isDiag_transpose_iff theorem IsDiag.conjTranspose [Semiring α] [StarRing α] {A : Matrix n n α} (ha : A.IsDiag) : Aᴴ.IsDiag := ha.transpose.map (star_zero _) #align matrix.is_diag.conj_transpose Matrix.IsDiag.conjTranspose @[simp] theorem isDiag_conjTranspose_iff [Semiring α] [StarRing α] {A : Matrix n n α} : Aᴴ.IsDiag ↔ A.IsDiag := ⟨fun ha => by convert ha.conjTranspose simp, IsDiag.conjTranspose⟩ #align matrix.is_diag_conj_transpose_iff Matrix.isDiag_conjTranspose_iff theorem IsDiag.submatrix [Zero α] {A : Matrix n n α} (ha : A.IsDiag) {f : m → n} (hf : Injective f) : (A.submatrix f f).IsDiag := fun _ _ h => ha (hf.ne h) #align matrix.is_diag.submatrix Matrix.IsDiag.submatrix theorem IsDiag.kronecker [MulZeroClass α] {A : Matrix m m α} {B : Matrix n n α} (hA : A.IsDiag) (hB : B.IsDiag) : (A ⊗ₖ B).IsDiag := by rintro ⟨a, b⟩ ⟨c, d⟩ h simp only [Prod.mk.inj_iff, Ne, not_and_or] at h cases' h with hac hbd · simp [hA hac] · simp [hB hbd] #align matrix.is_diag.kronecker Matrix.IsDiag.kronecker theorem IsDiag.isSymm [Zero α] {A : Matrix n n α} (h : A.IsDiag) : A.IsSymm := by ext i j by_cases g : i = j; · rw [g, transpose_apply] simp [h g, h (Ne.symm g)] #align matrix.is_diag.is_symm Matrix.IsDiag.isSymm theorem IsDiag.fromBlocks [Zero α] {A : Matrix m m α} {D : Matrix n n α} (ha : A.IsDiag) (hd : D.IsDiag) : (A.fromBlocks 0 0 D).IsDiag := by rintro (i | i) (j | j) hij · exact ha (ne_of_apply_ne _ hij) · rfl · rfl · exact hd (ne_of_apply_ne _ hij) #align matrix.is_diag.from_blocks Matrix.IsDiag.fromBlocks theorem isDiag_fromBlocks_iff [Zero α] {A : Matrix m m α} {B : Matrix m n α} {C : Matrix n m α} {D : Matrix n n α} : (A.fromBlocks B C D).IsDiag ↔ A.IsDiag ∧ B = 0 ∧ C = 0 ∧ D.IsDiag := by constructor · intro h refine ⟨fun i j hij => ?_, ext fun i j => ?_, ext fun i j => ?_, fun i j hij => ?_⟩ · exact h (Sum.inl_injective.ne hij) · exact h Sum.inl_ne_inr · exact h Sum.inr_ne_inl · exact h (Sum.inr_injective.ne hij) · rintro ⟨ha, hb, hc, hd⟩ convert IsDiag.fromBlocks ha hd #align matrix.is_diag_from_blocks_iff Matrix.isDiag_fromBlocks_iff
Mathlib/LinearAlgebra/Matrix/IsDiag.lean
184
188
theorem IsDiag.fromBlocks_of_isSymm [Zero α] {A : Matrix m m α} {C : Matrix n m α} {D : Matrix n n α} (h : (A.fromBlocks 0 C D).IsSymm) (ha : A.IsDiag) (hd : D.IsDiag) : (A.fromBlocks 0 C D).IsDiag := by
rw [← (isSymm_fromBlocks_iff.1 h).2.1] exact ha.fromBlocks hd
import Mathlib.Data.Set.Function import Mathlib.Logic.Equiv.Defs import Mathlib.Tactic.Says #align_import logic.equiv.set from "leanprover-community/mathlib"@"aba57d4d3dae35460225919dcd82fe91355162f9" open Function Set universe u v w z variable {α : Sort u} {β : Sort v} {γ : Sort w} namespace Equiv @[simp] theorem range_eq_univ {α : Type*} {β : Type*} (e : α ≃ β) : range e = univ := eq_univ_of_forall e.surjective #align equiv.range_eq_univ Equiv.range_eq_univ protected theorem image_eq_preimage {α β} (e : α ≃ β) (s : Set α) : e '' s = e.symm ⁻¹' s := Set.ext fun _ => mem_image_iff_of_inverse e.left_inv e.right_inv #align equiv.image_eq_preimage Equiv.image_eq_preimage @[simp 1001] theorem _root_.Set.mem_image_equiv {α β} {S : Set α} {f : α ≃ β} {x : β} : x ∈ f '' S ↔ f.symm x ∈ S := Set.ext_iff.mp (f.image_eq_preimage S) x #align set.mem_image_equiv Set.mem_image_equiv theorem _root_.Set.image_equiv_eq_preimage_symm {α β} (S : Set α) (f : α ≃ β) : f '' S = f.symm ⁻¹' S := f.image_eq_preimage S #align set.image_equiv_eq_preimage_symm Set.image_equiv_eq_preimage_symm theorem _root_.Set.preimage_equiv_eq_image_symm {α β} (S : Set α) (f : β ≃ α) : f ⁻¹' S = f.symm '' S := (f.symm.image_eq_preimage S).symm #align set.preimage_equiv_eq_image_symm Set.preimage_equiv_eq_image_symm -- Porting note: increased priority so this fires before `image_subset_iff` @[simp high] protected theorem symm_image_subset {α β} (e : α ≃ β) (s : Set α) (t : Set β) : e.symm '' t ⊆ s ↔ t ⊆ e '' s := by rw [image_subset_iff, e.image_eq_preimage] #align equiv.subset_image Equiv.symm_image_subset @[deprecated (since := "2024-01-19")] alias subset_image := Equiv.symm_image_subset -- Porting note: increased priority so this fires before `image_subset_iff` @[simp high] protected theorem subset_symm_image {α β} (e : α ≃ β) (s : Set α) (t : Set β) : s ⊆ e.symm '' t ↔ e '' s ⊆ t := calc s ⊆ e.symm '' t ↔ e.symm.symm '' s ⊆ t := by rw [e.symm.symm_image_subset] _ ↔ e '' s ⊆ t := by rw [e.symm_symm] #align equiv.subset_image' Equiv.subset_symm_image @[deprecated (since := "2024-01-19")] alias subset_image' := Equiv.subset_symm_image @[simp] theorem symm_image_image {α β} (e : α ≃ β) (s : Set α) : e.symm '' (e '' s) = s := e.leftInverse_symm.image_image s #align equiv.symm_image_image Equiv.symm_image_image theorem eq_image_iff_symm_image_eq {α β} (e : α ≃ β) (s : Set α) (t : Set β) : t = e '' s ↔ e.symm '' t = s := (e.symm.injective.image_injective.eq_iff' (e.symm_image_image s)).symm #align equiv.eq_image_iff_symm_image_eq Equiv.eq_image_iff_symm_image_eq @[simp] theorem image_symm_image {α β} (e : α ≃ β) (s : Set β) : e '' (e.symm '' s) = s := e.symm.symm_image_image s #align equiv.image_symm_image Equiv.image_symm_image @[simp] theorem image_preimage {α β} (e : α ≃ β) (s : Set β) : e '' (e ⁻¹' s) = s := e.surjective.image_preimage s #align equiv.image_preimage Equiv.image_preimage @[simp] theorem preimage_image {α β} (e : α ≃ β) (s : Set α) : e ⁻¹' (e '' s) = s := e.injective.preimage_image s #align equiv.preimage_image Equiv.preimage_image protected theorem image_compl {α β} (f : Equiv α β) (s : Set α) : f '' sᶜ = (f '' s)ᶜ := image_compl_eq f.bijective #align equiv.image_compl Equiv.image_compl @[simp] theorem symm_preimage_preimage {α β} (e : α ≃ β) (s : Set β) : e.symm ⁻¹' (e ⁻¹' s) = s := e.rightInverse_symm.preimage_preimage s #align equiv.symm_preimage_preimage Equiv.symm_preimage_preimage @[simp] theorem preimage_symm_preimage {α β} (e : α ≃ β) (s : Set α) : e ⁻¹' (e.symm ⁻¹' s) = s := e.leftInverse_symm.preimage_preimage s #align equiv.preimage_symm_preimage Equiv.preimage_symm_preimage theorem preimage_subset {α β} (e : α ≃ β) (s t : Set β) : e ⁻¹' s ⊆ e ⁻¹' t ↔ s ⊆ t := e.surjective.preimage_subset_preimage_iff #align equiv.preimage_subset Equiv.preimage_subset -- Porting note (#10618): removed `simp` attribute. `simp` can prove it. theorem image_subset {α β} (e : α ≃ β) (s t : Set α) : e '' s ⊆ e '' t ↔ s ⊆ t := image_subset_image_iff e.injective #align equiv.image_subset Equiv.image_subset @[simp] theorem image_eq_iff_eq {α β} (e : α ≃ β) (s t : Set α) : e '' s = e '' t ↔ s = t := image_eq_image e.injective #align equiv.image_eq_iff_eq Equiv.image_eq_iff_eq theorem preimage_eq_iff_eq_image {α β} (e : α ≃ β) (s t) : e ⁻¹' s = t ↔ s = e '' t := Set.preimage_eq_iff_eq_image e.bijective #align equiv.preimage_eq_iff_eq_image Equiv.preimage_eq_iff_eq_image theorem eq_preimage_iff_image_eq {α β} (e : α ≃ β) (s t) : s = e ⁻¹' t ↔ e '' s = t := Set.eq_preimage_iff_image_eq e.bijective #align equiv.eq_preimage_iff_image_eq Equiv.eq_preimage_iff_image_eq lemma setOf_apply_symm_eq_image_setOf {α β} (e : α ≃ β) (p : α → Prop) : {b | p (e.symm b)} = e '' {a | p a} := by rw [Equiv.image_eq_preimage, preimage_setOf_eq] @[simp] theorem prod_assoc_preimage {α β γ} {s : Set α} {t : Set β} {u : Set γ} : Equiv.prodAssoc α β γ ⁻¹' s ×ˢ t ×ˢ u = (s ×ˢ t) ×ˢ u := by ext simp [and_assoc] #align equiv.prod_assoc_preimage Equiv.prod_assoc_preimage @[simp] theorem prod_assoc_symm_preimage {α β γ} {s : Set α} {t : Set β} {u : Set γ} : (Equiv.prodAssoc α β γ).symm ⁻¹' (s ×ˢ t) ×ˢ u = s ×ˢ t ×ˢ u := by ext simp [and_assoc] #align equiv.prod_assoc_symm_preimage Equiv.prod_assoc_symm_preimage -- `@[simp]` doesn't like these lemmas, as it uses `Set.image_congr'` to turn `Equiv.prodAssoc` -- into a lambda expression and then unfold it. theorem prod_assoc_image {α β γ} {s : Set α} {t : Set β} {u : Set γ} : Equiv.prodAssoc α β γ '' (s ×ˢ t) ×ˢ u = s ×ˢ t ×ˢ u := by simpa only [Equiv.image_eq_preimage] using prod_assoc_symm_preimage #align equiv.prod_assoc_image Equiv.prod_assoc_image theorem prod_assoc_symm_image {α β γ} {s : Set α} {t : Set β} {u : Set γ} : (Equiv.prodAssoc α β γ).symm '' s ×ˢ t ×ˢ u = (s ×ˢ t) ×ˢ u := by simpa only [Equiv.image_eq_preimage] using prod_assoc_preimage #align equiv.prod_assoc_symm_image Equiv.prod_assoc_symm_image def setProdEquivSigma {α β : Type*} (s : Set (α × β)) : s ≃ Σx : α, { y : β | (x, y) ∈ s } where toFun x := ⟨x.1.1, x.1.2, by simp⟩ invFun x := ⟨(x.1, x.2.1), x.2.2⟩ left_inv := fun ⟨⟨x, y⟩, h⟩ => rfl right_inv := fun ⟨x, y, h⟩ => rfl #align equiv.set_prod_equiv_sigma Equiv.setProdEquivSigma @[simps! apply] def setCongr {α : Type*} {s t : Set α} (h : s = t) : s ≃ t := subtypeEquivProp h #align equiv.set_congr Equiv.setCongr #align equiv.set_congr_apply Equiv.setCongr_apply -- We could construct this using `Equiv.Set.image e s e.injective`, -- but this definition provides an explicit inverse. @[simps] def image {α β : Type*} (e : α ≃ β) (s : Set α) : s ≃ e '' s where toFun x := ⟨e x.1, by simp⟩ invFun y := ⟨e.symm y.1, by rcases y with ⟨-, ⟨a, ⟨m, rfl⟩⟩⟩ simpa using m⟩ left_inv x := by simp right_inv y := by simp #align equiv.image Equiv.image #align equiv.image_symm_apply_coe Equiv.image_symm_apply_coe #align equiv.image_apply_coe Equiv.image_apply_coe @[simps] def ofLeftInverse {α β : Sort _} (f : α → β) (f_inv : Nonempty α → β → α) (hf : ∀ h : Nonempty α, LeftInverse (f_inv h) f) : α ≃ range f where toFun a := ⟨f a, a, rfl⟩ invFun b := f_inv (nonempty_of_exists b.2) b left_inv a := hf ⟨a⟩ a right_inv := fun ⟨b, a, ha⟩ => Subtype.eq <| show f (f_inv ⟨a⟩ b) = b from Eq.trans (congr_arg f <| ha ▸ hf _ a) ha #align equiv.of_left_inverse Equiv.ofLeftInverse #align equiv.of_left_inverse_apply_coe Equiv.ofLeftInverse_apply_coe #align equiv.of_left_inverse_symm_apply Equiv.ofLeftInverse_symm_apply abbrev ofLeftInverse' {α β : Sort _} (f : α → β) (f_inv : β → α) (hf : LeftInverse f_inv f) : α ≃ range f := ofLeftInverse f (fun _ => f_inv) fun _ => hf #align equiv.of_left_inverse' Equiv.ofLeftInverse' @[simps! apply] noncomputable def ofInjective {α β} (f : α → β) (hf : Injective f) : α ≃ range f := Equiv.ofLeftInverse f (fun _ => Function.invFun f) fun _ => Function.leftInverse_invFun hf #align equiv.of_injective Equiv.ofInjective #align equiv.of_injective_apply Equiv.ofInjective_apply theorem apply_ofInjective_symm {α β} {f : α → β} (hf : Injective f) (b : range f) : f ((ofInjective f hf).symm b) = b := Subtype.ext_iff.1 <| (ofInjective f hf).apply_symm_apply b #align equiv.apply_of_injective_symm Equiv.apply_ofInjective_symm @[simp] theorem ofInjective_symm_apply {α β} {f : α → β} (hf : Injective f) (a : α) : (ofInjective f hf).symm ⟨f a, ⟨a, rfl⟩⟩ = a := by apply (ofInjective f hf).injective simp [apply_ofInjective_symm hf] #align equiv.of_injective_symm_apply Equiv.ofInjective_symm_apply theorem coe_ofInjective_symm {α β} {f : α → β} (hf : Injective f) : ((ofInjective f hf).symm : range f → α) = rangeSplitting f := by ext ⟨y, x, rfl⟩ apply hf simp [apply_rangeSplitting f] #align equiv.coe_of_injective_symm Equiv.coe_ofInjective_symm @[simp] theorem self_comp_ofInjective_symm {α β} {f : α → β} (hf : Injective f) : f ∘ (ofInjective f hf).symm = Subtype.val := funext fun x => apply_ofInjective_symm hf x #align equiv.self_comp_of_injective_symm Equiv.self_comp_ofInjective_symm
Mathlib/Logic/Equiv/Set.lean
642
648
theorem ofLeftInverse_eq_ofInjective {α β : Type*} (f : α → β) (f_inv : Nonempty α → β → α) (hf : ∀ h : Nonempty α, LeftInverse (f_inv h) f) : ofLeftInverse f f_inv hf = ofInjective f ((isEmpty_or_nonempty α).elim (fun h _ _ _ => Subsingleton.elim _ _) (fun h => (hf h).injective)) := by
ext simp
import Mathlib.CategoryTheory.NatIso #align_import category_theory.bicategory.basic from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" namespace CategoryTheory universe w v u open Category Iso -- intended to be used with explicit universe parameters @[nolint checkUnivs] class Bicategory (B : Type u) extends CategoryStruct.{v} B where -- category structure on the collection of 1-morphisms: homCategory : ∀ a b : B, Category.{w} (a ⟶ b) := by infer_instance -- left whiskering: whiskerLeft {a b c : B} (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) : f ≫ g ⟶ f ≫ h -- right whiskering: whiskerRight {a b c : B} {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) : f ≫ h ⟶ g ≫ h -- associator: associator {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) : (f ≫ g) ≫ h ≅ f ≫ g ≫ h -- left unitor: leftUnitor {a b : B} (f : a ⟶ b) : 𝟙 a ≫ f ≅ f -- right unitor: rightUnitor {a b : B} (f : a ⟶ b) : f ≫ 𝟙 b ≅ f -- axioms for left whiskering: whiskerLeft_id : ∀ {a b c} (f : a ⟶ b) (g : b ⟶ c), whiskerLeft f (𝟙 g) = 𝟙 (f ≫ g) := by aesop_cat whiskerLeft_comp : ∀ {a b c} (f : a ⟶ b) {g h i : b ⟶ c} (η : g ⟶ h) (θ : h ⟶ i), whiskerLeft f (η ≫ θ) = whiskerLeft f η ≫ whiskerLeft f θ := by aesop_cat id_whiskerLeft : ∀ {a b} {f g : a ⟶ b} (η : f ⟶ g), whiskerLeft (𝟙 a) η = (leftUnitor f).hom ≫ η ≫ (leftUnitor g).inv := by aesop_cat comp_whiskerLeft : ∀ {a b c d} (f : a ⟶ b) (g : b ⟶ c) {h h' : c ⟶ d} (η : h ⟶ h'), whiskerLeft (f ≫ g) η = (associator f g h).hom ≫ whiskerLeft f (whiskerLeft g η) ≫ (associator f g h').inv := by aesop_cat -- axioms for right whiskering: id_whiskerRight : ∀ {a b c} (f : a ⟶ b) (g : b ⟶ c), whiskerRight (𝟙 f) g = 𝟙 (f ≫ g) := by aesop_cat comp_whiskerRight : ∀ {a b c} {f g h : a ⟶ b} (η : f ⟶ g) (θ : g ⟶ h) (i : b ⟶ c), whiskerRight (η ≫ θ) i = whiskerRight η i ≫ whiskerRight θ i := by aesop_cat whiskerRight_id : ∀ {a b} {f g : a ⟶ b} (η : f ⟶ g), whiskerRight η (𝟙 b) = (rightUnitor f).hom ≫ η ≫ (rightUnitor g).inv := by aesop_cat whiskerRight_comp : ∀ {a b c d} {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c) (h : c ⟶ d), whiskerRight η (g ≫ h) = (associator f g h).inv ≫ whiskerRight (whiskerRight η g) h ≫ (associator f' g h).hom := by aesop_cat -- associativity of whiskerings: whisker_assoc : ∀ {a b c d} (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g') (h : c ⟶ d), whiskerRight (whiskerLeft f η) h = (associator f g h).hom ≫ whiskerLeft f (whiskerRight η h) ≫ (associator f g' h).inv := by aesop_cat -- exchange law of left and right whiskerings: whisker_exchange : ∀ {a b c} {f g : a ⟶ b} {h i : b ⟶ c} (η : f ⟶ g) (θ : h ⟶ i), whiskerLeft f θ ≫ whiskerRight η i = whiskerRight η h ≫ whiskerLeft g θ := by aesop_cat -- pentagon identity: pentagon : ∀ {a b c d e} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e), whiskerRight (associator f g h).hom i ≫ (associator f (g ≫ h) i).hom ≫ whiskerLeft f (associator g h i).hom = (associator (f ≫ g) h i).hom ≫ (associator f g (h ≫ i)).hom := by aesop_cat -- triangle identity: triangle : ∀ {a b c} (f : a ⟶ b) (g : b ⟶ c), (associator f (𝟙 b) g).hom ≫ whiskerLeft f (leftUnitor g).hom = whiskerRight (rightUnitor f).hom g := by aesop_cat #align category_theory.bicategory CategoryTheory.Bicategory #align category_theory.bicategory.hom_category CategoryTheory.Bicategory.homCategory #align category_theory.bicategory.whisker_left CategoryTheory.Bicategory.whiskerLeft #align category_theory.bicategory.whisker_right CategoryTheory.Bicategory.whiskerRight #align category_theory.bicategory.left_unitor CategoryTheory.Bicategory.leftUnitor #align category_theory.bicategory.right_unitor CategoryTheory.Bicategory.rightUnitor #align category_theory.bicategory.whisker_left_id' CategoryTheory.Bicategory.whiskerLeft_id #align category_theory.bicategory.whisker_left_comp' CategoryTheory.Bicategory.whiskerLeft_comp #align category_theory.bicategory.id_whisker_left' CategoryTheory.Bicategory.id_whiskerLeft #align category_theory.bicategory.comp_whisker_left' CategoryTheory.Bicategory.comp_whiskerLeft #align category_theory.bicategory.id_whisker_right' CategoryTheory.Bicategory.id_whiskerRight #align category_theory.bicategory.comp_whisker_right' CategoryTheory.Bicategory.comp_whiskerRight #align category_theory.bicategory.whisker_right_id' CategoryTheory.Bicategory.whiskerRight_id #align category_theory.bicategory.whisker_right_comp' CategoryTheory.Bicategory.whiskerRight_comp #align category_theory.bicategory.whisker_assoc' CategoryTheory.Bicategory.whisker_assoc #align category_theory.bicategory.whisker_exchange' CategoryTheory.Bicategory.whisker_exchange #align category_theory.bicategory.pentagon' CategoryTheory.Bicategory.pentagon #align category_theory.bicategory.triangle' CategoryTheory.Bicategory.triangle namespace Bicategory scoped infixr:81 " ◁ " => Bicategory.whiskerLeft scoped infixl:81 " ▷ " => Bicategory.whiskerRight scoped notation "α_" => Bicategory.associator scoped notation "λ_" => Bicategory.leftUnitor scoped notation "ρ_" => Bicategory.rightUnitor attribute [instance] homCategory attribute [reassoc] whiskerLeft_comp id_whiskerLeft comp_whiskerLeft comp_whiskerRight whiskerRight_id whiskerRight_comp whisker_assoc whisker_exchange attribute [reassoc (attr := simp)] pentagon triangle attribute [simp] whiskerLeft_id whiskerLeft_comp id_whiskerLeft comp_whiskerLeft id_whiskerRight comp_whiskerRight whiskerRight_id whiskerRight_comp whisker_assoc variable {B : Type u} [Bicategory.{w, v} B] {a b c d e : B} @[reassoc (attr := simp)] theorem whiskerLeft_hom_inv (f : a ⟶ b) {g h : b ⟶ c} (η : g ≅ h) : f ◁ η.hom ≫ f ◁ η.inv = 𝟙 (f ≫ g) := by rw [← whiskerLeft_comp, hom_inv_id, whiskerLeft_id] #align category_theory.bicategory.hom_inv_whisker_left CategoryTheory.Bicategory.whiskerLeft_hom_inv @[reassoc (attr := simp)] theorem hom_inv_whiskerRight {f g : a ⟶ b} (η : f ≅ g) (h : b ⟶ c) : η.hom ▷ h ≫ η.inv ▷ h = 𝟙 (f ≫ h) := by rw [← comp_whiskerRight, hom_inv_id, id_whiskerRight] #align category_theory.bicategory.hom_inv_whisker_right CategoryTheory.Bicategory.hom_inv_whiskerRight @[reassoc (attr := simp)] theorem whiskerLeft_inv_hom (f : a ⟶ b) {g h : b ⟶ c} (η : g ≅ h) : f ◁ η.inv ≫ f ◁ η.hom = 𝟙 (f ≫ h) := by rw [← whiskerLeft_comp, inv_hom_id, whiskerLeft_id] #align category_theory.bicategory.inv_hom_whisker_left CategoryTheory.Bicategory.whiskerLeft_inv_hom @[reassoc (attr := simp)] theorem inv_hom_whiskerRight {f g : a ⟶ b} (η : f ≅ g) (h : b ⟶ c) : η.inv ▷ h ≫ η.hom ▷ h = 𝟙 (g ≫ h) := by rw [← comp_whiskerRight, inv_hom_id, id_whiskerRight] #align category_theory.bicategory.inv_hom_whisker_right CategoryTheory.Bicategory.inv_hom_whiskerRight @[simps] def whiskerLeftIso (f : a ⟶ b) {g h : b ⟶ c} (η : g ≅ h) : f ≫ g ≅ f ≫ h where hom := f ◁ η.hom inv := f ◁ η.inv #align category_theory.bicategory.whisker_left_iso CategoryTheory.Bicategory.whiskerLeftIso instance whiskerLeft_isIso (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) [IsIso η] : IsIso (f ◁ η) := (whiskerLeftIso f (asIso η)).isIso_hom #align category_theory.bicategory.whisker_left_is_iso CategoryTheory.Bicategory.whiskerLeft_isIso @[simp] theorem inv_whiskerLeft (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) [IsIso η] : inv (f ◁ η) = f ◁ inv η := by apply IsIso.inv_eq_of_hom_inv_id simp only [← whiskerLeft_comp, whiskerLeft_id, IsIso.hom_inv_id] #align category_theory.bicategory.inv_whisker_left CategoryTheory.Bicategory.inv_whiskerLeft @[simps!] def whiskerRightIso {f g : a ⟶ b} (η : f ≅ g) (h : b ⟶ c) : f ≫ h ≅ g ≫ h where hom := η.hom ▷ h inv := η.inv ▷ h #align category_theory.bicategory.whisker_right_iso CategoryTheory.Bicategory.whiskerRightIso instance whiskerRight_isIso {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) [IsIso η] : IsIso (η ▷ h) := (whiskerRightIso (asIso η) h).isIso_hom #align category_theory.bicategory.whisker_right_is_iso CategoryTheory.Bicategory.whiskerRight_isIso @[simp] theorem inv_whiskerRight {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) [IsIso η] : inv (η ▷ h) = inv η ▷ h := by apply IsIso.inv_eq_of_hom_inv_id simp only [← comp_whiskerRight, id_whiskerRight, IsIso.hom_inv_id] #align category_theory.bicategory.inv_whisker_right CategoryTheory.Bicategory.inv_whiskerRight @[reassoc (attr := simp)] theorem pentagon_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : f ◁ (α_ g h i).inv ≫ (α_ f (g ≫ h) i).inv ≫ (α_ f g h).inv ▷ i = (α_ f g (h ≫ i)).inv ≫ (α_ (f ≫ g) h i).inv := eq_of_inv_eq_inv (by simp) #align category_theory.bicategory.pentagon_inv CategoryTheory.Bicategory.pentagon_inv @[reassoc (attr := simp)] theorem pentagon_inv_inv_hom_hom_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : (α_ f (g ≫ h) i).inv ≫ (α_ f g h).inv ▷ i ≫ (α_ (f ≫ g) h i).hom = f ◁ (α_ g h i).hom ≫ (α_ f g (h ≫ i)).inv := by rw [← cancel_epi (f ◁ (α_ g h i).inv), ← cancel_mono (α_ (f ≫ g) h i).inv] simp #align category_theory.bicategory.pentagon_inv_inv_hom_hom_inv CategoryTheory.Bicategory.pentagon_inv_inv_hom_hom_inv @[reassoc (attr := simp)] theorem pentagon_inv_hom_hom_hom_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : (α_ (f ≫ g) h i).inv ≫ (α_ f g h).hom ▷ i ≫ (α_ f (g ≫ h) i).hom = (α_ f g (h ≫ i)).hom ≫ f ◁ (α_ g h i).inv := eq_of_inv_eq_inv (by simp) #align category_theory.bicategory.pentagon_inv_hom_hom_hom_inv CategoryTheory.Bicategory.pentagon_inv_hom_hom_hom_inv @[reassoc (attr := simp)] theorem pentagon_hom_inv_inv_inv_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : f ◁ (α_ g h i).hom ≫ (α_ f g (h ≫ i)).inv ≫ (α_ (f ≫ g) h i).inv = (α_ f (g ≫ h) i).inv ≫ (α_ f g h).inv ▷ i := by simp [← cancel_epi (f ◁ (α_ g h i).inv)] #align category_theory.bicategory.pentagon_hom_inv_inv_inv_inv CategoryTheory.Bicategory.pentagon_hom_inv_inv_inv_inv @[reassoc (attr := simp)] theorem pentagon_hom_hom_inv_hom_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : (α_ (f ≫ g) h i).hom ≫ (α_ f g (h ≫ i)).hom ≫ f ◁ (α_ g h i).inv = (α_ f g h).hom ▷ i ≫ (α_ f (g ≫ h) i).hom := eq_of_inv_eq_inv (by simp) #align category_theory.bicategory.pentagon_hom_hom_inv_hom_hom CategoryTheory.Bicategory.pentagon_hom_hom_inv_hom_hom @[reassoc (attr := simp)] theorem pentagon_hom_inv_inv_inv_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : (α_ f g (h ≫ i)).hom ≫ f ◁ (α_ g h i).inv ≫ (α_ f (g ≫ h) i).inv = (α_ (f ≫ g) h i).inv ≫ (α_ f g h).hom ▷ i := by rw [← cancel_epi (α_ f g (h ≫ i)).inv, ← cancel_mono ((α_ f g h).inv ▷ i)] simp #align category_theory.bicategory.pentagon_hom_inv_inv_inv_hom CategoryTheory.Bicategory.pentagon_hom_inv_inv_inv_hom @[reassoc (attr := simp)] theorem pentagon_hom_hom_inv_inv_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : (α_ f (g ≫ h) i).hom ≫ f ◁ (α_ g h i).hom ≫ (α_ f g (h ≫ i)).inv = (α_ f g h).inv ▷ i ≫ (α_ (f ≫ g) h i).hom := eq_of_inv_eq_inv (by simp) #align category_theory.bicategory.pentagon_hom_hom_inv_inv_hom CategoryTheory.Bicategory.pentagon_hom_hom_inv_inv_hom @[reassoc (attr := simp)] theorem pentagon_inv_hom_hom_hom_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : (α_ f g h).inv ▷ i ≫ (α_ (f ≫ g) h i).hom ≫ (α_ f g (h ≫ i)).hom = (α_ f (g ≫ h) i).hom ≫ f ◁ (α_ g h i).hom := by simp [← cancel_epi ((α_ f g h).hom ▷ i)] #align category_theory.bicategory.pentagon_inv_hom_hom_hom_hom CategoryTheory.Bicategory.pentagon_inv_hom_hom_hom_hom @[reassoc (attr := simp)] theorem pentagon_inv_inv_hom_inv_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) : (α_ f g (h ≫ i)).inv ≫ (α_ (f ≫ g) h i).inv ≫ (α_ f g h).hom ▷ i = f ◁ (α_ g h i).inv ≫ (α_ f (g ≫ h) i).inv := eq_of_inv_eq_inv (by simp) #align category_theory.bicategory.pentagon_inv_inv_hom_inv_inv CategoryTheory.Bicategory.pentagon_inv_inv_hom_inv_inv theorem triangle_assoc_comp_left (f : a ⟶ b) (g : b ⟶ c) : (α_ f (𝟙 b) g).hom ≫ f ◁ (λ_ g).hom = (ρ_ f).hom ▷ g := triangle f g #align category_theory.bicategory.triangle_assoc_comp_left CategoryTheory.Bicategory.triangle_assoc_comp_left @[reassoc (attr := simp)] theorem triangle_assoc_comp_right (f : a ⟶ b) (g : b ⟶ c) : (α_ f (𝟙 b) g).inv ≫ (ρ_ f).hom ▷ g = f ◁ (λ_ g).hom := by rw [← triangle, inv_hom_id_assoc] #align category_theory.bicategory.triangle_assoc_comp_right CategoryTheory.Bicategory.triangle_assoc_comp_right @[reassoc (attr := simp)] theorem triangle_assoc_comp_right_inv (f : a ⟶ b) (g : b ⟶ c) : (ρ_ f).inv ▷ g ≫ (α_ f (𝟙 b) g).hom = f ◁ (λ_ g).inv := by simp [← cancel_mono (f ◁ (λ_ g).hom)] #align category_theory.bicategory.triangle_assoc_comp_right_inv CategoryTheory.Bicategory.triangle_assoc_comp_right_inv @[reassoc (attr := simp)] theorem triangle_assoc_comp_left_inv (f : a ⟶ b) (g : b ⟶ c) : f ◁ (λ_ g).inv ≫ (α_ f (𝟙 b) g).inv = (ρ_ f).inv ▷ g := by simp [← cancel_mono ((ρ_ f).hom ▷ g)] #align category_theory.bicategory.triangle_assoc_comp_left_inv CategoryTheory.Bicategory.triangle_assoc_comp_left_inv @[reassoc] theorem associator_naturality_left {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c) (h : c ⟶ d) : η ▷ g ▷ h ≫ (α_ f' g h).hom = (α_ f g h).hom ≫ η ▷ (g ≫ h) := by simp #align category_theory.bicategory.associator_naturality_left CategoryTheory.Bicategory.associator_naturality_left @[reassoc] theorem associator_inv_naturality_left {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c) (h : c ⟶ d) : η ▷ (g ≫ h) ≫ (α_ f' g h).inv = (α_ f g h).inv ≫ η ▷ g ▷ h := by simp #align category_theory.bicategory.associator_inv_naturality_left CategoryTheory.Bicategory.associator_inv_naturality_left @[reassoc] theorem whiskerRight_comp_symm {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c) (h : c ⟶ d) : η ▷ g ▷ h = (α_ f g h).hom ≫ η ▷ (g ≫ h) ≫ (α_ f' g h).inv := by simp #align category_theory.bicategory.whisker_right_comp_symm CategoryTheory.Bicategory.whiskerRight_comp_symm @[reassoc] theorem associator_naturality_middle (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g') (h : c ⟶ d) : (f ◁ η) ▷ h ≫ (α_ f g' h).hom = (α_ f g h).hom ≫ f ◁ η ▷ h := by simp #align category_theory.bicategory.associator_naturality_middle CategoryTheory.Bicategory.associator_naturality_middle @[reassoc] theorem associator_inv_naturality_middle (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g') (h : c ⟶ d) : f ◁ η ▷ h ≫ (α_ f g' h).inv = (α_ f g h).inv ≫ (f ◁ η) ▷ h := by simp #align category_theory.bicategory.associator_inv_naturality_middle CategoryTheory.Bicategory.associator_inv_naturality_middle @[reassoc]
Mathlib/CategoryTheory/Bicategory/Basic.lean
364
365
theorem whisker_assoc_symm (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g') (h : c ⟶ d) : f ◁ η ▷ h = (α_ f g h).inv ≫ (f ◁ η) ▷ h ≫ (α_ f g' h).hom := by
simp
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 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] #align nat.choose_mul_factorial_mul_factorial Nat.choose_mul_factorial_mul_factorial theorem choose_mul {n k s : ℕ} (hkn : k ≤ n) (hsk : s ≤ k) : n.choose k * k.choose s = n.choose s * (n - s).choose (k - s) := have h : 0 < (n - k)! * (k - s)! * s ! := by apply_rules [factorial_pos, Nat.mul_pos] Nat.mul_right_cancel h <| calc n.choose k * k.choose s * ((n - k)! * (k - s)! * s !) = n.choose k * (k.choose s * s ! * (k - s)!) * (n - k)! := by rw [Nat.mul_assoc, Nat.mul_assoc, Nat.mul_assoc, Nat.mul_assoc _ s !, Nat.mul_assoc, Nat.mul_comm (n - k)!, Nat.mul_comm s !] _ = n ! := by rw [choose_mul_factorial_mul_factorial hsk, choose_mul_factorial_mul_factorial hkn] _ = n.choose s * s ! * ((n - s).choose (k - s) * (k - s)! * (n - s - (k - s))!) := by rw [choose_mul_factorial_mul_factorial (Nat.sub_le_sub_right hkn _), choose_mul_factorial_mul_factorial (hsk.trans hkn)] _ = n.choose s * (n - s).choose (k - s) * ((n - k)! * (k - s)! * s !) := by rw [Nat.sub_sub_sub_cancel_right hsk, Nat.mul_assoc, Nat.mul_left_comm s !, Nat.mul_assoc, Nat.mul_comm (k - s)!, Nat.mul_comm s !, Nat.mul_right_comm, ← Nat.mul_assoc] #align nat.choose_mul Nat.choose_mul theorem choose_eq_factorial_div_factorial {n k : ℕ} (hk : k ≤ n) : choose n k = n ! / (k ! * (n - k)!) := by rw [← choose_mul_factorial_mul_factorial hk, Nat.mul_assoc] exact (mul_div_left _ (Nat.mul_pos (factorial_pos _) (factorial_pos _))).symm #align nat.choose_eq_factorial_div_factorial Nat.choose_eq_factorial_div_factorial theorem add_choose (i j : ℕ) : (i + j).choose j = (i + j)! / (i ! * j !) := by rw [choose_eq_factorial_div_factorial (Nat.le_add_left j i), Nat.add_sub_cancel_right, Nat.mul_comm] #align nat.add_choose Nat.add_choose theorem add_choose_mul_factorial_mul_factorial (i j : ℕ) : (i + j).choose j * i ! * j ! = (i + j)! := by rw [← choose_mul_factorial_mul_factorial (Nat.le_add_left _ _), Nat.add_sub_cancel_right, Nat.mul_right_comm] #align nat.add_choose_mul_factorial_mul_factorial Nat.add_choose_mul_factorial_mul_factorial theorem factorial_mul_factorial_dvd_factorial {n k : ℕ} (hk : k ≤ n) : k ! * (n - k)! ∣ n ! := by rw [← choose_mul_factorial_mul_factorial hk, Nat.mul_assoc]; exact Nat.dvd_mul_left _ _ #align nat.factorial_mul_factorial_dvd_factorial Nat.factorial_mul_factorial_dvd_factorial theorem factorial_mul_factorial_dvd_factorial_add (i j : ℕ) : i ! * j ! ∣ (i + j)! := by suffices i ! * (i + j - i) ! ∣ (i + j)! by rwa [Nat.add_sub_cancel_left i j] at this exact factorial_mul_factorial_dvd_factorial (Nat.le_add_right _ _) #align nat.factorial_mul_factorial_dvd_factorial_add Nat.factorial_mul_factorial_dvd_factorial_add @[simp] theorem choose_symm {n k : ℕ} (hk : k ≤ n) : choose n (n - k) = choose n k := by rw [choose_eq_factorial_div_factorial hk, choose_eq_factorial_div_factorial (Nat.sub_le _ _), Nat.sub_sub_self hk, Nat.mul_comm] #align nat.choose_symm Nat.choose_symm theorem choose_symm_of_eq_add {n a b : ℕ} (h : n = a + b) : Nat.choose n a = Nat.choose n b := by suffices choose n (n - b) = choose n b by rw [h, Nat.add_sub_cancel_right] at this; rwa [h] exact choose_symm (h ▸ le_add_left _ _) #align nat.choose_symm_of_eq_add Nat.choose_symm_of_eq_add theorem choose_symm_add {a b : ℕ} : choose (a + b) a = choose (a + b) b := choose_symm_of_eq_add rfl #align nat.choose_symm_add Nat.choose_symm_add theorem choose_symm_half (m : ℕ) : choose (2 * m + 1) (m + 1) = choose (2 * m + 1) m := by apply choose_symm_of_eq_add rw [Nat.add_comm m 1, Nat.add_assoc 1 m m, Nat.add_comm (2 * m) 1, Nat.two_mul m] #align nat.choose_symm_half Nat.choose_symm_half theorem choose_succ_right_eq (n k : ℕ) : choose n (k + 1) * (k + 1) = choose n k * (n - k) := by have e : (n + 1) * choose n k = choose n (k + 1) * (k + 1) + choose n k * (k + 1) := by rw [← Nat.add_mul, Nat.add_comm (choose _ _), ← choose_succ_succ, succ_mul_choose_eq] rw [← Nat.sub_eq_of_eq_add e, Nat.mul_comm, ← Nat.mul_sub_left_distrib, Nat.add_sub_add_right] #align nat.choose_succ_right_eq Nat.choose_succ_right_eq @[simp] theorem choose_succ_self_right : ∀ n : ℕ, (n + 1).choose n = n + 1 | 0 => rfl | n + 1 => by rw [choose_succ_succ, choose_succ_self_right n, choose_self] #align nat.choose_succ_self_right Nat.choose_succ_self_right theorem choose_mul_succ_eq (n k : ℕ) : n.choose k * (n + 1) = (n + 1).choose k * (n + 1 - k) := by cases k with | zero => simp | succ k => obtain hk | hk := le_or_lt (k + 1) (n + 1) · rw [choose_succ_succ, Nat.add_mul, succ_sub_succ, ← choose_succ_right_eq, ← succ_sub_succ, Nat.mul_sub_left_distrib, Nat.add_sub_cancel' (Nat.mul_le_mul_left _ hk)] · rw [choose_eq_zero_of_lt hk, choose_eq_zero_of_lt (n.lt_succ_self.trans hk), Nat.zero_mul, Nat.zero_mul] #align nat.choose_mul_succ_eq Nat.choose_mul_succ_eq
Mathlib/Data/Nat/Choose/Basic.lean
235
240
theorem ascFactorial_eq_factorial_mul_choose (n k : ℕ) : (n + 1).ascFactorial k = k ! * (n + k).choose k := by
rw [Nat.mul_comm] apply Nat.mul_right_cancel (n + k - k).factorial_pos rw [choose_mul_factorial_mul_factorial <| Nat.le_add_left k n, Nat.add_sub_cancel_right, ← factorial_mul_ascFactorial, Nat.mul_comm]
import Mathlib.FieldTheory.RatFunc.AsPolynomial import Mathlib.RingTheory.EuclideanDomain import Mathlib.RingTheory.Localization.FractionRing import Mathlib.RingTheory.Polynomial.Content noncomputable section universe u variable {K : Type u} namespace RatFunc section IntDegree open Polynomial variable [Field K] def intDegree (x : RatFunc K) : ℤ := natDegree x.num - natDegree x.denom #align ratfunc.int_degree RatFunc.intDegree @[simp] theorem intDegree_zero : intDegree (0 : RatFunc K) = 0 := by rw [intDegree, num_zero, natDegree_zero, denom_zero, natDegree_one, sub_self] #align ratfunc.int_degree_zero RatFunc.intDegree_zero @[simp] theorem intDegree_one : intDegree (1 : RatFunc K) = 0 := by rw [intDegree, num_one, denom_one, sub_self] #align ratfunc.int_degree_one RatFunc.intDegree_one @[simp] theorem intDegree_C (k : K) : intDegree (C k) = 0 := by rw [intDegree, num_C, natDegree_C, denom_C, natDegree_one, sub_self] set_option linter.uppercaseLean3 false in #align ratfunc.int_degree_C RatFunc.intDegree_C @[simp] theorem intDegree_X : intDegree (X : RatFunc K) = 1 := by rw [intDegree, num_X, Polynomial.natDegree_X, denom_X, Polynomial.natDegree_one, Int.ofNat_one, Int.ofNat_zero, sub_zero] set_option linter.uppercaseLean3 false in #align ratfunc.int_degree_X RatFunc.intDegree_X @[simp]
Mathlib/FieldTheory/RatFunc/Degree.lean
65
68
theorem intDegree_polynomial {p : K[X]} : intDegree (algebraMap K[X] (RatFunc K) p) = natDegree p := by
rw [intDegree, RatFunc.num_algebraMap, RatFunc.denom_algebraMap, Polynomial.natDegree_one, Int.ofNat_zero, sub_zero]
import Mathlib.Algebra.BigOperators.Module import Mathlib.Algebra.Order.Field.Basic import Mathlib.Order.Filter.ModEq import Mathlib.Analysis.Asymptotics.Asymptotics import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Data.List.TFAE import Mathlib.Analysis.NormedSpace.Basic #align_import analysis.specific_limits.normed from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" noncomputable section open scoped Classical open Set Function Filter Finset Metric Asymptotics open scoped Classical open Topology Nat uniformity NNReal ENNReal variable {α : Type*} {β : Type*} {ι : Type*} theorem tendsto_norm_atTop_atTop : Tendsto (norm : ℝ → ℝ) atTop atTop := tendsto_abs_atTop_atTop #align tendsto_norm_at_top_at_top tendsto_norm_atTop_atTop theorem summable_of_absolute_convergence_real {f : ℕ → ℝ} : (∃ r, Tendsto (fun n ↦ ∑ i ∈ range n, |f i|) atTop (𝓝 r)) → Summable f | ⟨r, hr⟩ => by refine .of_norm ⟨r, (hasSum_iff_tendsto_nat_of_nonneg ?_ _).2 ?_⟩ · exact fun i ↦ norm_nonneg _ · simpa only using hr #align summable_of_absolute_convergence_real summable_of_absolute_convergence_real theorem tendsto_norm_zero' {𝕜 : Type*} [NormedAddCommGroup 𝕜] : Tendsto (norm : 𝕜 → ℝ) (𝓝[≠] 0) (𝓝[>] 0) := tendsto_norm_zero.inf <| tendsto_principal_principal.2 fun _ hx ↦ norm_pos_iff.2 hx #align tendsto_norm_zero' tendsto_norm_zero' theorem isLittleO_pow_pow_of_lt_left {r₁ r₂ : ℝ} (h₁ : 0 ≤ r₁) (h₂ : r₁ < r₂) : (fun n : ℕ ↦ r₁ ^ n) =o[atTop] fun n ↦ r₂ ^ n := have H : 0 < r₂ := h₁.trans_lt h₂ (isLittleO_of_tendsto fun _ hn ↦ False.elim <| H.ne' <| pow_eq_zero hn) <| (tendsto_pow_atTop_nhds_zero_of_lt_one (div_nonneg h₁ (h₁.trans h₂.le)) ((div_lt_one H).2 h₂)).congr fun _ ↦ div_pow _ _ _ #align is_o_pow_pow_of_lt_left isLittleO_pow_pow_of_lt_left theorem isBigO_pow_pow_of_le_left {r₁ r₂ : ℝ} (h₁ : 0 ≤ r₁) (h₂ : r₁ ≤ r₂) : (fun n : ℕ ↦ r₁ ^ n) =O[atTop] fun n ↦ r₂ ^ n := h₂.eq_or_lt.elim (fun h ↦ h ▸ isBigO_refl _ _) fun h ↦ (isLittleO_pow_pow_of_lt_left h₁ h).isBigO set_option linter.uppercaseLean3 false in #align is_O_pow_pow_of_le_left isBigO_pow_pow_of_le_left
Mathlib/Analysis/SpecificLimits/Normed.lean
111
114
theorem isLittleO_pow_pow_of_abs_lt_left {r₁ r₂ : ℝ} (h : |r₁| < |r₂|) : (fun n : ℕ ↦ r₁ ^ n) =o[atTop] fun n ↦ r₂ ^ n := by
refine (IsLittleO.of_norm_left ?_).of_norm_right exact (isLittleO_pow_pow_of_lt_left (abs_nonneg r₁) h).congr (pow_abs r₁) (pow_abs r₂)
import Mathlib.RingTheory.Ideal.Maps #align_import ring_theory.ideal.prod from "leanprover-community/mathlib"@"052f6013363326d50cb99c6939814a4b8eb7b301" universe u v variable {R : Type u} {S : Type v} [Semiring R] [Semiring S] (I I' : Ideal R) (J J' : Ideal S) namespace Ideal def prod : Ideal (R × S) where carrier := { x | x.fst ∈ I ∧ x.snd ∈ J } zero_mem' := by simp add_mem' := by rintro ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ⟨ha₁, ha₂⟩ ⟨hb₁, hb₂⟩ exact ⟨I.add_mem ha₁ hb₁, J.add_mem ha₂ hb₂⟩ smul_mem' := by rintro ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ⟨hb₁, hb₂⟩ exact ⟨I.mul_mem_left _ hb₁, J.mul_mem_left _ hb₂⟩ #align ideal.prod Ideal.prod @[simp] theorem mem_prod {r : R} {s : S} : (⟨r, s⟩ : R × S) ∈ prod I J ↔ r ∈ I ∧ s ∈ J := Iff.rfl #align ideal.mem_prod Ideal.mem_prod @[simp] theorem prod_top_top : prod (⊤ : Ideal R) (⊤ : Ideal S) = ⊤ := Ideal.ext <| by simp #align ideal.prod_top_top Ideal.prod_top_top theorem ideal_prod_eq (I : Ideal (R × S)) : I = Ideal.prod (map (RingHom.fst R S) I : Ideal R) (map (RingHom.snd R S) I) := by apply Ideal.ext rintro ⟨r, s⟩ rw [mem_prod, mem_map_iff_of_surjective (RingHom.fst R S) Prod.fst_surjective, mem_map_iff_of_surjective (RingHom.snd R S) Prod.snd_surjective] refine ⟨fun h => ⟨⟨_, ⟨h, rfl⟩⟩, ⟨_, ⟨h, rfl⟩⟩⟩, ?_⟩ rintro ⟨⟨⟨r, s'⟩, ⟨h₁, rfl⟩⟩, ⟨⟨r', s⟩, ⟨h₂, rfl⟩⟩⟩ simpa using I.add_mem (I.mul_mem_left (1, 0) h₁) (I.mul_mem_left (0, 1) h₂) #align ideal.ideal_prod_eq Ideal.ideal_prod_eq @[simp] theorem map_fst_prod (I : Ideal R) (J : Ideal S) : map (RingHom.fst R S) (prod I J) = I := by ext x rw [mem_map_iff_of_surjective (RingHom.fst R S) Prod.fst_surjective] exact ⟨by rintro ⟨x, ⟨h, rfl⟩⟩ exact h.1, fun h => ⟨⟨x, 0⟩, ⟨⟨h, Ideal.zero_mem _⟩, rfl⟩⟩⟩ #align ideal.map_fst_prod Ideal.map_fst_prod @[simp] theorem map_snd_prod (I : Ideal R) (J : Ideal S) : map (RingHom.snd R S) (prod I J) = J := by ext x rw [mem_map_iff_of_surjective (RingHom.snd R S) Prod.snd_surjective] exact ⟨by rintro ⟨x, ⟨h, rfl⟩⟩ exact h.2, fun h => ⟨⟨0, x⟩, ⟨⟨Ideal.zero_mem _, h⟩, rfl⟩⟩⟩ #align ideal.map_snd_prod Ideal.map_snd_prod @[simp] theorem map_prodComm_prod : map ((RingEquiv.prodComm : R × S ≃+* S × R) : R × S →+* S × R) (prod I J) = prod J I := by refine Trans.trans (ideal_prod_eq _) ?_ simp [map_map] #align ideal.map_prod_comm_prod Ideal.map_prodComm_prod def idealProdEquiv : Ideal (R × S) ≃ Ideal R × Ideal S where toFun I := ⟨map (RingHom.fst R S) I, map (RingHom.snd R S) I⟩ invFun I := prod I.1 I.2 left_inv I := (ideal_prod_eq I).symm right_inv := fun ⟨I, J⟩ => by simp #align ideal.ideal_prod_equiv Ideal.idealProdEquiv @[simp] theorem idealProdEquiv_symm_apply (I : Ideal R) (J : Ideal S) : idealProdEquiv.symm ⟨I, J⟩ = prod I J := rfl #align ideal.ideal_prod_equiv_symm_apply Ideal.idealProdEquiv_symm_apply theorem prod.ext_iff {I I' : Ideal R} {J J' : Ideal S} : prod I J = prod I' J' ↔ I = I' ∧ J = J' := by simp only [← idealProdEquiv_symm_apply, idealProdEquiv.symm.injective.eq_iff, Prod.mk.inj_iff] #align ideal.prod.ext_iff Ideal.prod.ext_iff theorem isPrime_of_isPrime_prod_top {I : Ideal R} (h : (Ideal.prod I (⊤ : Ideal S)).IsPrime) : I.IsPrime := by constructor · contrapose! h rw [h, prod_top_top, isPrime_iff] simp [isPrime_iff, h] · intro x y hxy have : (⟨x, 1⟩ : R × S) * ⟨y, 1⟩ ∈ prod I ⊤ := by rw [Prod.mk_mul_mk, mul_one, mem_prod] exact ⟨hxy, trivial⟩ simpa using h.mem_or_mem this #align ideal.is_prime_of_is_prime_prod_top Ideal.isPrime_of_isPrime_prod_top theorem isPrime_of_isPrime_prod_top' {I : Ideal S} (h : (Ideal.prod (⊤ : Ideal R) I).IsPrime) : I.IsPrime := by apply isPrime_of_isPrime_prod_top (S := R) rw [← map_prodComm_prod] -- Note: couldn't synthesize the right instances without the `R` and `S` hints exact map_isPrime_of_equiv (RingEquiv.prodComm (R := R) (S := S)) #align ideal.is_prime_of_is_prime_prod_top' Ideal.isPrime_of_isPrime_prod_top' theorem isPrime_ideal_prod_top {I : Ideal R} [h : I.IsPrime] : (prod I (⊤ : Ideal S)).IsPrime := by constructor · rcases h with ⟨h, -⟩ contrapose! h rw [← prod_top_top, prod.ext_iff] at h exact h.1 rintro ⟨r₁, s₁⟩ ⟨r₂, s₂⟩ ⟨h₁, _⟩ cases' h.mem_or_mem h₁ with h h · exact Or.inl ⟨h, trivial⟩ · exact Or.inr ⟨h, trivial⟩ #align ideal.is_prime_ideal_prod_top Ideal.isPrime_ideal_prod_top theorem isPrime_ideal_prod_top' {I : Ideal S} [h : I.IsPrime] : (prod (⊤ : Ideal R) I).IsPrime := by letI : IsPrime (prod I (⊤ : Ideal R)) := isPrime_ideal_prod_top rw [← map_prodComm_prod] -- Note: couldn't synthesize the right instances without the `R` and `S` hints exact map_isPrime_of_equiv (RingEquiv.prodComm (R := S) (S := R)) #align ideal.is_prime_ideal_prod_top' Ideal.isPrime_ideal_prod_top' theorem ideal_prod_prime_aux {I : Ideal R} {J : Ideal S} : (Ideal.prod I J).IsPrime → I = ⊤ ∨ J = ⊤ := by contrapose! simp only [ne_top_iff_one, isPrime_iff, not_and, not_forall, not_or] exact fun ⟨hI, hJ⟩ _ => ⟨⟨0, 1⟩, ⟨1, 0⟩, by simp, by simp [hJ], by simp [hI]⟩ #align ideal.ideal_prod_prime_aux Ideal.ideal_prod_prime_aux
Mathlib/RingTheory/Ideal/Prod.lean
157
173
theorem ideal_prod_prime (I : Ideal (R × S)) : I.IsPrime ↔ (∃ p : Ideal R, p.IsPrime ∧ I = Ideal.prod p ⊤) ∨ ∃ p : Ideal S, p.IsPrime ∧ I = Ideal.prod ⊤ p := by
constructor · rw [ideal_prod_eq I] intro hI rcases ideal_prod_prime_aux hI with (h | h) · right rw [h] at hI ⊢ exact ⟨_, ⟨isPrime_of_isPrime_prod_top' hI, rfl⟩⟩ · left rw [h] at hI ⊢ exact ⟨_, ⟨isPrime_of_isPrime_prod_top hI, rfl⟩⟩ · rintro (⟨p, ⟨h, rfl⟩⟩ | ⟨p, ⟨h, rfl⟩⟩) · exact isPrime_ideal_prod_top · exact isPrime_ideal_prod_top'
import Mathlib.Analysis.SpecialFunctions.Pow.Complex import Qq #align_import analysis.special_functions.pow.real from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" noncomputable section open scoped Classical open Real ComplexConjugate open Finset Set namespace Real variable {x y z : ℝ} noncomputable def rpow (x y : ℝ) := ((x : ℂ) ^ (y : ℂ)).re #align real.rpow Real.rpow noncomputable instance : Pow ℝ ℝ := ⟨rpow⟩ @[simp] theorem rpow_eq_pow (x y : ℝ) : rpow x y = x ^ y := rfl #align real.rpow_eq_pow Real.rpow_eq_pow theorem rpow_def (x y : ℝ) : x ^ y = ((x : ℂ) ^ (y : ℂ)).re := rfl #align real.rpow_def Real.rpow_def theorem rpow_def_of_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) := by simp only [rpow_def, Complex.cpow_def]; split_ifs <;> simp_all [(Complex.ofReal_log hx).symm, -Complex.ofReal_mul, -RCLike.ofReal_mul, (Complex.ofReal_mul _ _).symm, Complex.exp_ofReal_re, Complex.ofReal_eq_zero] #align real.rpow_def_of_nonneg Real.rpow_def_of_nonneg theorem rpow_def_of_pos {x : ℝ} (hx : 0 < x) (y : ℝ) : x ^ y = exp (log x * y) := by rw [rpow_def_of_nonneg (le_of_lt hx), if_neg (ne_of_gt hx)] #align real.rpow_def_of_pos Real.rpow_def_of_pos theorem exp_mul (x y : ℝ) : exp (x * y) = exp x ^ y := by rw [rpow_def_of_pos (exp_pos _), log_exp] #align real.exp_mul Real.exp_mul @[simp, norm_cast] theorem rpow_intCast (x : ℝ) (n : ℤ) : x ^ (n : ℝ) = x ^ n := by simp only [rpow_def, ← Complex.ofReal_zpow, Complex.cpow_intCast, Complex.ofReal_intCast, Complex.ofReal_re] #align real.rpow_int_cast Real.rpow_intCast @[deprecated (since := "2024-04-17")] alias rpow_int_cast := rpow_intCast @[simp, norm_cast] theorem rpow_natCast (x : ℝ) (n : ℕ) : x ^ (n : ℝ) = x ^ n := by simpa using rpow_intCast x n #align real.rpow_nat_cast Real.rpow_natCast @[deprecated (since := "2024-04-17")] alias rpow_nat_cast := rpow_natCast @[simp] theorem exp_one_rpow (x : ℝ) : exp 1 ^ x = exp x := by rw [← exp_mul, one_mul] #align real.exp_one_rpow Real.exp_one_rpow @[simp] lemma exp_one_pow (n : ℕ) : exp 1 ^ n = exp n := by rw [← rpow_natCast, exp_one_rpow] theorem rpow_eq_zero_iff_of_nonneg (hx : 0 ≤ x) : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by simp only [rpow_def_of_nonneg hx] split_ifs <;> simp [*, exp_ne_zero] #align real.rpow_eq_zero_iff_of_nonneg Real.rpow_eq_zero_iff_of_nonneg @[simp] lemma rpow_eq_zero (hx : 0 ≤ x) (hy : y ≠ 0) : x ^ y = 0 ↔ x = 0 := by simp [rpow_eq_zero_iff_of_nonneg, *] @[simp] lemma rpow_ne_zero (hx : 0 ≤ x) (hy : y ≠ 0) : x ^ y ≠ 0 ↔ x ≠ 0 := Real.rpow_eq_zero hx hy |>.not open Real
Mathlib/Analysis/SpecialFunctions/Pow/Real.lean
100
112
theorem rpow_def_of_neg {x : ℝ} (hx : x < 0) (y : ℝ) : x ^ y = exp (log x * y) * cos (y * π) := by
rw [rpow_def, Complex.cpow_def, if_neg] · have : Complex.log x * y = ↑(log (-x) * y) + ↑(y * π) * Complex.I := by simp only [Complex.log, abs_of_neg hx, Complex.arg_ofReal_of_neg hx, Complex.abs_ofReal, Complex.ofReal_mul] ring rw [this, Complex.exp_add_mul_I, ← Complex.ofReal_exp, ← Complex.ofReal_cos, ← Complex.ofReal_sin, mul_add, ← Complex.ofReal_mul, ← mul_assoc, ← Complex.ofReal_mul, Complex.add_re, Complex.ofReal_re, Complex.mul_re, Complex.I_re, Complex.ofReal_im, Real.log_neg_eq_log] ring · rw [Complex.ofReal_eq_zero] exact ne_of_lt hx
import Mathlib.Algebra.BigOperators.Fin import Mathlib.LinearAlgebra.Finsupp import Mathlib.LinearAlgebra.Prod import Mathlib.SetTheory.Cardinal.Basic import Mathlib.Tactic.FinCases import Mathlib.Tactic.LinearCombination import Mathlib.Lean.Expr.ExtraRecognizers import Mathlib.Data.Set.Subsingleton #align_import linear_algebra.linear_independent from "leanprover-community/mathlib"@"9d684a893c52e1d6692a504a118bfccbae04feeb" noncomputable section open Function Set Submodule open Cardinal universe u' u variable {ι : Type u'} {ι' : Type*} {R : Type*} {K : Type*} variable {M : Type*} {M' M'' : Type*} {V : Type u} {V' : Type*} section Module variable {v : ι → M} variable [Semiring R] [AddCommMonoid M] [AddCommMonoid M'] [AddCommMonoid M''] variable [Module R M] [Module R M'] [Module R M''] variable {a b : R} {x y : M} variable (R) (v) def LinearIndependent : Prop := LinearMap.ker (Finsupp.total ι M R v) = ⊥ #align linear_independent LinearIndependent open Lean PrettyPrinter.Delaborator SubExpr in @[delab app.LinearIndependent] def delabLinearIndependent : Delab := whenPPOption getPPNotation <| whenNotPPOption getPPAnalysisSkip <| withOptionAtCurrPos `pp.analysis.skip true do let e ← getExpr guard <| e.isAppOfArity ``LinearIndependent 7 let some _ := (e.getArg! 0).coeTypeSet? | failure let optionsPerPos ← if (e.getArg! 3).isLambda then withNaryArg 3 do return (← read).optionsPerPos.setBool (← getPos) pp.funBinderTypes.name true else withNaryArg 0 do return (← read).optionsPerPos.setBool (← getPos) `pp.analysis.namedArg true withTheReader Context ({· with optionsPerPos}) delab variable {R} {v} theorem linearIndependent_iff : LinearIndependent R v ↔ ∀ l, Finsupp.total ι M R v l = 0 → l = 0 := by simp [LinearIndependent, LinearMap.ker_eq_bot'] #align linear_independent_iff linearIndependent_iff theorem linearIndependent_iff' : LinearIndependent R v ↔ ∀ s : Finset ι, ∀ g : ι → R, ∑ i ∈ s, g i • v i = 0 → ∀ i ∈ s, g i = 0 := linearIndependent_iff.trans ⟨fun hf s g hg i his => have h := hf (∑ i ∈ s, Finsupp.single i (g i)) <| by simpa only [map_sum, Finsupp.total_single] using hg calc g i = (Finsupp.lapply i : (ι →₀ R) →ₗ[R] R) (Finsupp.single i (g i)) := by { rw [Finsupp.lapply_apply, Finsupp.single_eq_same] } _ = ∑ j ∈ s, (Finsupp.lapply i : (ι →₀ R) →ₗ[R] R) (Finsupp.single j (g j)) := Eq.symm <| Finset.sum_eq_single i (fun j _hjs hji => by rw [Finsupp.lapply_apply, Finsupp.single_eq_of_ne hji]) fun hnis => hnis.elim his _ = (∑ j ∈ s, Finsupp.single j (g j)) i := (map_sum ..).symm _ = 0 := DFunLike.ext_iff.1 h i, fun hf l hl => Finsupp.ext fun i => _root_.by_contradiction fun hni => hni <| hf _ _ hl _ <| Finsupp.mem_support_iff.2 hni⟩ #align linear_independent_iff' linearIndependent_iff' theorem linearIndependent_iff'' : LinearIndependent R v ↔ ∀ (s : Finset ι) (g : ι → R), (∀ i ∉ s, g i = 0) → ∑ i ∈ s, g i • v i = 0 → ∀ i, g i = 0 := by classical exact linearIndependent_iff'.trans ⟨fun H s g hg hv i => if his : i ∈ s then H s g hv i his else hg i his, fun H s g hg i hi => by convert H s (fun j => if j ∈ s then g j else 0) (fun j hj => if_neg hj) (by simp_rw [ite_smul, zero_smul, Finset.sum_extend_by_zero, hg]) i exact (if_pos hi).symm⟩ #align linear_independent_iff'' linearIndependent_iff'' theorem not_linearIndependent_iff : ¬LinearIndependent R v ↔ ∃ s : Finset ι, ∃ g : ι → R, ∑ i ∈ s, g i • v i = 0 ∧ ∃ i ∈ s, g i ≠ 0 := by rw [linearIndependent_iff'] simp only [exists_prop, not_forall] #align not_linear_independent_iff not_linearIndependent_iff theorem Fintype.linearIndependent_iff [Fintype ι] : LinearIndependent R v ↔ ∀ g : ι → R, ∑ i, g i • v i = 0 → ∀ i, g i = 0 := by refine ⟨fun H g => by simpa using linearIndependent_iff'.1 H Finset.univ g, fun H => linearIndependent_iff''.2 fun s g hg hs i => H _ ?_ _⟩ rw [← hs] refine (Finset.sum_subset (Finset.subset_univ _) fun i _ hi => ?_).symm rw [hg i hi, zero_smul] #align fintype.linear_independent_iff Fintype.linearIndependent_iff theorem Fintype.linearIndependent_iff' [Fintype ι] [DecidableEq ι] : LinearIndependent R v ↔ LinearMap.ker (LinearMap.lsum R (fun _ ↦ R) ℕ fun i ↦ LinearMap.id.smulRight (v i)) = ⊥ := by simp [Fintype.linearIndependent_iff, LinearMap.ker_eq_bot', funext_iff] #align fintype.linear_independent_iff' Fintype.linearIndependent_iff' theorem Fintype.not_linearIndependent_iff [Fintype ι] : ¬LinearIndependent R v ↔ ∃ g : ι → R, ∑ i, g i • v i = 0 ∧ ∃ i, g i ≠ 0 := by simpa using not_iff_not.2 Fintype.linearIndependent_iff #align fintype.not_linear_independent_iff Fintype.not_linearIndependent_iff theorem linearIndependent_empty_type [IsEmpty ι] : LinearIndependent R v := linearIndependent_iff.mpr fun v _hv => Subsingleton.elim v 0 #align linear_independent_empty_type linearIndependent_empty_type theorem LinearIndependent.ne_zero [Nontrivial R] (i : ι) (hv : LinearIndependent R v) : v i ≠ 0 := fun h => zero_ne_one' R <| Eq.symm (by suffices (Finsupp.single i 1 : ι →₀ R) i = 0 by simpa rw [linearIndependent_iff.1 hv (Finsupp.single i 1)] · simp · simp [h]) #align linear_independent.ne_zero LinearIndependent.ne_zero lemma LinearIndependent.eq_zero_of_pair {x y : M} (h : LinearIndependent R ![x, y]) {s t : R} (h' : s • x + t • y = 0) : s = 0 ∧ t = 0 := by have := linearIndependent_iff'.1 h Finset.univ ![s, t] simp only [Fin.sum_univ_two, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.head_cons, h', Finset.mem_univ, forall_true_left] at this exact ⟨this 0, this 1⟩ lemma LinearIndependent.pair_iff {x y : M} : LinearIndependent R ![x, y] ↔ ∀ (s t : R), s • x + t • y = 0 → s = 0 ∧ t = 0 := by refine ⟨fun h s t hst ↦ h.eq_zero_of_pair hst, fun h ↦ ?_⟩ apply Fintype.linearIndependent_iff.2 intro g hg simp only [Fin.sum_univ_two, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.head_cons] at hg intro i fin_cases i exacts [(h _ _ hg).1, (h _ _ hg).2] theorem LinearIndependent.comp (h : LinearIndependent R v) (f : ι' → ι) (hf : Injective f) : LinearIndependent R (v ∘ f) := by rw [linearIndependent_iff, Finsupp.total_comp] intro l hl have h_map_domain : ∀ x, (Finsupp.mapDomain f l) (f x) = 0 := by rw [linearIndependent_iff.1 h (Finsupp.mapDomain f l) hl]; simp ext x convert h_map_domain x rw [Finsupp.mapDomain_apply hf] #align linear_independent.comp LinearIndependent.comp theorem linearIndependent_iff_finset_linearIndependent : LinearIndependent R v ↔ ∀ (s : Finset ι), LinearIndependent R (v ∘ (Subtype.val : s → ι)) := ⟨fun H _ ↦ H.comp _ Subtype.val_injective, fun H ↦ linearIndependent_iff'.2 fun s g hg i hi ↦ Fintype.linearIndependent_iff.1 (H s) (g ∘ Subtype.val) (hg ▸ Finset.sum_attach s fun j ↦ g j • v j) ⟨i, hi⟩⟩ theorem LinearIndependent.coe_range (i : LinearIndependent R v) : LinearIndependent R ((↑) : range v → M) := by simpa using i.comp _ (rangeSplitting_injective v) #align linear_independent.coe_range LinearIndependent.coe_range theorem LinearIndependent.map (hv : LinearIndependent R v) {f : M →ₗ[R] M'} (hf_inj : Disjoint (span R (range v)) (LinearMap.ker f)) : LinearIndependent R (f ∘ v) := by rw [disjoint_iff_inf_le, ← Set.image_univ, Finsupp.span_image_eq_map_total, map_inf_eq_map_inf_comap, map_le_iff_le_comap, comap_bot, Finsupp.supported_univ, top_inf_eq] at hf_inj unfold LinearIndependent at hv ⊢ rw [hv, le_bot_iff] at hf_inj haveI : Inhabited M := ⟨0⟩ rw [Finsupp.total_comp, Finsupp.lmapDomain_total _ _ f, LinearMap.ker_comp, hf_inj] exact fun _ => rfl #align linear_independent.map LinearIndependent.map theorem Submodule.range_ker_disjoint {f : M →ₗ[R] M'} (hv : LinearIndependent R (f ∘ v)) : Disjoint (span R (range v)) (LinearMap.ker f) := by rw [LinearIndependent, Finsupp.total_comp, Finsupp.lmapDomain_total R _ f (fun _ ↦ rfl), LinearMap.ker_comp] at hv rw [disjoint_iff_inf_le, ← Set.image_univ, Finsupp.span_image_eq_map_total, map_inf_eq_map_inf_comap, hv, inf_bot_eq, map_bot] theorem LinearIndependent.map' (hv : LinearIndependent R v) (f : M →ₗ[R] M') (hf_inj : LinearMap.ker f = ⊥) : LinearIndependent R (f ∘ v) := hv.map <| by simp [hf_inj] #align linear_independent.map' LinearIndependent.map' theorem LinearIndependent.map_of_injective_injective {R' : Type*} {M' : Type*} [Semiring R'] [AddCommMonoid M'] [Module R' M'] (hv : LinearIndependent R v) (i : R' → R) (j : M →+ M') (hi : ∀ r, i r = 0 → r = 0) (hj : ∀ m, j m = 0 → m = 0) (hc : ∀ (r : R') (m : M), j (i r • m) = r • j m) : LinearIndependent R' (j ∘ v) := by rw [linearIndependent_iff'] at hv ⊢ intro S r' H s hs simp_rw [comp_apply, ← hc, ← map_sum] at H exact hi _ <| hv _ _ (hj _ H) s hs theorem LinearIndependent.map_of_surjective_injective {R' : Type*} {M' : Type*} [Semiring R'] [AddCommMonoid M'] [Module R' M'] (hv : LinearIndependent R v) (i : ZeroHom R R') (j : M →+ M') (hi : Surjective i) (hj : ∀ m, j m = 0 → m = 0) (hc : ∀ (r : R) (m : M), j (r • m) = i r • j m) : LinearIndependent R' (j ∘ v) := by obtain ⟨i', hi'⟩ := hi.hasRightInverse refine hv.map_of_injective_injective i' j (fun _ h ↦ ?_) hj fun r m ↦ ?_ · apply_fun i at h rwa [hi', i.map_zero] at h rw [hc (i' r) m, hi']
Mathlib/LinearAlgebra/LinearIndependent.lean
319
324
theorem LinearIndependent.of_comp (f : M →ₗ[R] M') (hfv : LinearIndependent R (f ∘ v)) : LinearIndependent R v := linearIndependent_iff'.2 fun s g hg i his => have : (∑ i ∈ s, g i • f (v i)) = 0 := by
simp_rw [← map_smul, ← map_sum, hg, f.map_zero] linearIndependent_iff'.1 hfv s g this i his
import Mathlib.Data.List.Basic #align_import data.list.lattice from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734" open Nat namespace List variable {α : Type*} {l l₁ l₂ : List α} {p : α → Prop} {a : α} variable [DecidableEq α] section BagInter @[simp] theorem nil_bagInter (l : List α) : [].bagInter l = [] := by cases l <;> rfl #align list.nil_bag_inter List.nil_bagInter @[simp] theorem bagInter_nil (l : List α) : l.bagInter [] = [] := by cases l <;> rfl #align list.bag_inter_nil List.bagInter_nil @[simp] theorem cons_bagInter_of_pos (l₁ : List α) (h : a ∈ l₂) : (a :: l₁).bagInter l₂ = a :: l₁.bagInter (l₂.erase a) := by cases l₂ · exact if_pos h · simp only [List.bagInter, if_pos (elem_eq_true_of_mem h)] #align list.cons_bag_inter_of_pos List.cons_bagInter_of_pos @[simp]
Mathlib/Data/List/Lattice.lean
211
214
theorem cons_bagInter_of_neg (l₁ : List α) (h : a ∉ l₂) : (a :: l₁).bagInter l₂ = l₁.bagInter l₂ := by
cases l₂; · simp only [bagInter_nil] simp only [erase_of_not_mem h, List.bagInter, if_neg (mt mem_of_elem_eq_true h)]
import Mathlib.Algebra.GroupWithZero.Divisibility import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Tactic.NthRewrite #align_import data.nat.gcd.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" namespace Nat theorem gcd_greatest {a b d : ℕ} (hda : d ∣ a) (hdb : d ∣ b) (hd : ∀ e : ℕ, e ∣ a → e ∣ b → e ∣ d) : d = a.gcd b := (dvd_antisymm (hd _ (gcd_dvd_left a b) (gcd_dvd_right a b)) (dvd_gcd hda hdb)).symm #align nat.gcd_greatest Nat.gcd_greatest @[simp] theorem gcd_add_mul_right_right (m n k : ℕ) : gcd m (n + k * m) = gcd m n := by simp [gcd_rec m (n + k * m), gcd_rec m n] #align nat.gcd_add_mul_right_right Nat.gcd_add_mul_right_right @[simp] theorem gcd_add_mul_left_right (m n k : ℕ) : gcd m (n + m * k) = gcd m n := by simp [gcd_rec m (n + m * k), gcd_rec m n] #align nat.gcd_add_mul_left_right Nat.gcd_add_mul_left_right @[simp] theorem gcd_mul_right_add_right (m n k : ℕ) : gcd m (k * m + n) = gcd m n := by simp [add_comm _ n] #align nat.gcd_mul_right_add_right Nat.gcd_mul_right_add_right @[simp] theorem gcd_mul_left_add_right (m n k : ℕ) : gcd m (m * k + n) = gcd m n := by simp [add_comm _ n] #align nat.gcd_mul_left_add_right Nat.gcd_mul_left_add_right @[simp] theorem gcd_add_mul_right_left (m n k : ℕ) : gcd (m + k * n) n = gcd m n := by rw [gcd_comm, gcd_add_mul_right_right, gcd_comm] #align nat.gcd_add_mul_right_left Nat.gcd_add_mul_right_left @[simp] theorem gcd_add_mul_left_left (m n k : ℕ) : gcd (m + n * k) n = gcd m n := by rw [gcd_comm, gcd_add_mul_left_right, gcd_comm] #align nat.gcd_add_mul_left_left Nat.gcd_add_mul_left_left @[simp] theorem gcd_mul_right_add_left (m n k : ℕ) : gcd (k * n + m) n = gcd m n := by rw [gcd_comm, gcd_mul_right_add_right, gcd_comm] #align nat.gcd_mul_right_add_left Nat.gcd_mul_right_add_left @[simp]
Mathlib/Data/Nat/GCD/Basic.lean
68
69
theorem gcd_mul_left_add_left (m n k : ℕ) : gcd (n * k + m) n = gcd m n := by
rw [gcd_comm, gcd_mul_left_add_right, gcd_comm]
import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Algebra.Group.Int import Mathlib.Data.Nat.Dist import Mathlib.Data.Ordmap.Ordnode import Mathlib.Tactic.Abel import Mathlib.Tactic.Linarith #align_import data.ordmap.ordset from "leanprover-community/mathlib"@"47b51515e69f59bca5cf34ef456e6000fe205a69" variable {α : Type*} namespace Ordnode theorem not_le_delta {s} (H : 1 ≤ s) : ¬s ≤ delta * 0 := not_le_of_gt H #align ordnode.not_le_delta Ordnode.not_le_delta theorem delta_lt_false {a b : ℕ} (h₁ : delta * a < b) (h₂ : delta * b < a) : False := not_le_of_lt (lt_trans ((mul_lt_mul_left (by decide)).2 h₁) h₂) <| by simpa [mul_assoc] using Nat.mul_le_mul_right a (by decide : 1 ≤ delta * delta) #align ordnode.delta_lt_false Ordnode.delta_lt_false def realSize : Ordnode α → ℕ | nil => 0 | node _ l _ r => realSize l + realSize r + 1 #align ordnode.real_size Ordnode.realSize def Sized : Ordnode α → Prop | nil => True | node s l _ r => s = size l + size r + 1 ∧ Sized l ∧ Sized r #align ordnode.sized Ordnode.Sized theorem Sized.node' {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (node' l x r) := ⟨rfl, hl, hr⟩ #align ordnode.sized.node' Ordnode.Sized.node' theorem Sized.eq_node' {s l x r} (h : @Sized α (node s l x r)) : node s l x r = .node' l x r := by rw [h.1] #align ordnode.sized.eq_node' Ordnode.Sized.eq_node' theorem Sized.size_eq {s l x r} (H : Sized (@node α s l x r)) : size (@node α s l x r) = size l + size r + 1 := H.1 #align ordnode.sized.size_eq Ordnode.Sized.size_eq @[elab_as_elim] theorem Sized.induction {t} (hl : @Sized α t) {C : Ordnode α → Prop} (H0 : C nil) (H1 : ∀ l x r, C l → C r → C (.node' l x r)) : C t := by induction t with | nil => exact H0 | node _ _ _ _ t_ih_l t_ih_r => rw [hl.eq_node'] exact H1 _ _ _ (t_ih_l hl.2.1) (t_ih_r hl.2.2) #align ordnode.sized.induction Ordnode.Sized.induction theorem size_eq_realSize : ∀ {t : Ordnode α}, Sized t → size t = realSize t | nil, _ => rfl | node s l x r, ⟨h₁, h₂, h₃⟩ => by rw [size, h₁, size_eq_realSize h₂, size_eq_realSize h₃]; rfl #align ordnode.size_eq_real_size Ordnode.size_eq_realSize @[simp] theorem Sized.size_eq_zero {t : Ordnode α} (ht : Sized t) : size t = 0 ↔ t = nil := by cases t <;> [simp;simp [ht.1]] #align ordnode.sized.size_eq_zero Ordnode.Sized.size_eq_zero theorem Sized.pos {s l x r} (h : Sized (@node α s l x r)) : 0 < s := by rw [h.1]; apply Nat.le_add_left #align ordnode.sized.pos Ordnode.Sized.pos theorem dual_dual : ∀ t : Ordnode α, dual (dual t) = t | nil => rfl | node s l x r => by rw [dual, dual, dual_dual l, dual_dual r] #align ordnode.dual_dual Ordnode.dual_dual @[simp] theorem size_dual (t : Ordnode α) : size (dual t) = size t := by cases t <;> rfl #align ordnode.size_dual Ordnode.size_dual def BalancedSz (l r : ℕ) : Prop := l + r ≤ 1 ∨ l ≤ delta * r ∧ r ≤ delta * l #align ordnode.balanced_sz Ordnode.BalancedSz instance BalancedSz.dec : DecidableRel BalancedSz := fun _ _ => Or.decidable #align ordnode.balanced_sz.dec Ordnode.BalancedSz.dec def Balanced : Ordnode α → Prop | nil => True | node _ l _ r => BalancedSz (size l) (size r) ∧ Balanced l ∧ Balanced r #align ordnode.balanced Ordnode.Balanced instance Balanced.dec : DecidablePred (@Balanced α) | nil => by unfold Balanced infer_instance | node _ l _ r => by unfold Balanced haveI := Balanced.dec l haveI := Balanced.dec r infer_instance #align ordnode.balanced.dec Ordnode.Balanced.dec @[symm] theorem BalancedSz.symm {l r : ℕ} : BalancedSz l r → BalancedSz r l := Or.imp (by rw [add_comm]; exact id) And.symm #align ordnode.balanced_sz.symm Ordnode.BalancedSz.symm theorem balancedSz_zero {l : ℕ} : BalancedSz l 0 ↔ l ≤ 1 := by simp (config := { contextual := true }) [BalancedSz] #align ordnode.balanced_sz_zero Ordnode.balancedSz_zero theorem balancedSz_up {l r₁ r₂ : ℕ} (h₁ : r₁ ≤ r₂) (h₂ : l + r₂ ≤ 1 ∨ r₂ ≤ delta * l) (H : BalancedSz l r₁) : BalancedSz l r₂ := by refine or_iff_not_imp_left.2 fun h => ?_ refine ⟨?_, h₂.resolve_left h⟩ cases H with | inl H => cases r₂ · cases h (le_trans (Nat.add_le_add_left (Nat.zero_le _) _) H) · exact le_trans (le_trans (Nat.le_add_right _ _) H) (Nat.le_add_left 1 _) | inr H => exact le_trans H.1 (Nat.mul_le_mul_left _ h₁) #align ordnode.balanced_sz_up Ordnode.balancedSz_up theorem balancedSz_down {l r₁ r₂ : ℕ} (h₁ : r₁ ≤ r₂) (h₂ : l + r₂ ≤ 1 ∨ l ≤ delta * r₁) (H : BalancedSz l r₂) : BalancedSz l r₁ := have : l + r₂ ≤ 1 → BalancedSz l r₁ := fun H => Or.inl (le_trans (Nat.add_le_add_left h₁ _) H) Or.casesOn H this fun H => Or.casesOn h₂ this fun h₂ => Or.inr ⟨h₂, le_trans h₁ H.2⟩ #align ordnode.balanced_sz_down Ordnode.balancedSz_down theorem Balanced.dual : ∀ {t : Ordnode α}, Balanced t → Balanced (dual t) | nil, _ => ⟨⟩ | node _ l _ r, ⟨b, bl, br⟩ => ⟨by rw [size_dual, size_dual]; exact b.symm, br.dual, bl.dual⟩ #align ordnode.balanced.dual Ordnode.Balanced.dual def node3L (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : Ordnode α := node' (node' l x m) y r #align ordnode.node3_l Ordnode.node3L def node3R (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : Ordnode α := node' l x (node' m y r) #align ordnode.node3_r Ordnode.node3R def node4L : Ordnode α → α → Ordnode α → α → Ordnode α → Ordnode α | l, x, node _ ml y mr, z, r => node' (node' l x ml) y (node' mr z r) | l, x, nil, z, r => node3L l x nil z r #align ordnode.node4_l Ordnode.node4L -- should not happen def node4R : Ordnode α → α → Ordnode α → α → Ordnode α → Ordnode α | l, x, node _ ml y mr, z, r => node' (node' l x ml) y (node' mr z r) | l, x, nil, z, r => node3R l x nil z r #align ordnode.node4_r Ordnode.node4R -- should not happen def rotateL : Ordnode α → α → Ordnode α → Ordnode α | l, x, node _ m y r => if size m < ratio * size r then node3L l x m y r else node4L l x m y r | l, x, nil => node' l x nil #align ordnode.rotate_l Ordnode.rotateL -- Porting note (#11467): during the port we marked these lemmas with `@[eqns]` -- to emulate the old Lean 3 behaviour. theorem rotateL_node (l : Ordnode α) (x : α) (sz : ℕ) (m : Ordnode α) (y : α) (r : Ordnode α) : rotateL l x (node sz m y r) = if size m < ratio * size r then node3L l x m y r else node4L l x m y r := rfl theorem rotateL_nil (l : Ordnode α) (x : α) : rotateL l x nil = node' l x nil := rfl -- should not happen def rotateR : Ordnode α → α → Ordnode α → Ordnode α | node _ l x m, y, r => if size m < ratio * size l then node3R l x m y r else node4R l x m y r | nil, y, r => node' nil y r #align ordnode.rotate_r Ordnode.rotateR -- Porting note (#11467): during the port we marked these lemmas with `@[eqns]` -- to emulate the old Lean 3 behaviour. theorem rotateR_node (sz : ℕ) (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : rotateR (node sz l x m) y r = if size m < ratio * size l then node3R l x m y r else node4R l x m y r := rfl theorem rotateR_nil (y : α) (r : Ordnode α) : rotateR nil y r = node' nil y r := rfl -- should not happen def balanceL' (l : Ordnode α) (x : α) (r : Ordnode α) : Ordnode α := if size l + size r ≤ 1 then node' l x r else if size l > delta * size r then rotateR l x r else node' l x r #align ordnode.balance_l' Ordnode.balanceL' def balanceR' (l : Ordnode α) (x : α) (r : Ordnode α) : Ordnode α := if size l + size r ≤ 1 then node' l x r else if size r > delta * size l then rotateL l x r else node' l x r #align ordnode.balance_r' Ordnode.balanceR' def balance' (l : Ordnode α) (x : α) (r : Ordnode α) : Ordnode α := if size l + size r ≤ 1 then node' l x r else if size r > delta * size l then rotateL l x r else if size l > delta * size r then rotateR l x r else node' l x r #align ordnode.balance' Ordnode.balance' theorem dual_node' (l : Ordnode α) (x : α) (r : Ordnode α) : dual (node' l x r) = node' (dual r) x (dual l) := by simp [node', add_comm] #align ordnode.dual_node' Ordnode.dual_node' theorem dual_node3L (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : dual (node3L l x m y r) = node3R (dual r) y (dual m) x (dual l) := by simp [node3L, node3R, dual_node', add_comm] #align ordnode.dual_node3_l Ordnode.dual_node3L theorem dual_node3R (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : dual (node3R l x m y r) = node3L (dual r) y (dual m) x (dual l) := by simp [node3L, node3R, dual_node', add_comm] #align ordnode.dual_node3_r Ordnode.dual_node3R theorem dual_node4L (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : dual (node4L l x m y r) = node4R (dual r) y (dual m) x (dual l) := by cases m <;> simp [node4L, node4R, node3R, dual_node3L, dual_node', add_comm] #align ordnode.dual_node4_l Ordnode.dual_node4L theorem dual_node4R (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : dual (node4R l x m y r) = node4L (dual r) y (dual m) x (dual l) := by cases m <;> simp [node4L, node4R, node3L, dual_node3R, dual_node', add_comm] #align ordnode.dual_node4_r Ordnode.dual_node4R theorem dual_rotateL (l : Ordnode α) (x : α) (r : Ordnode α) : dual (rotateL l x r) = rotateR (dual r) x (dual l) := by cases r <;> simp [rotateL, rotateR, dual_node']; split_ifs <;> simp [dual_node3L, dual_node4L, node3R, add_comm] #align ordnode.dual_rotate_l Ordnode.dual_rotateL theorem dual_rotateR (l : Ordnode α) (x : α) (r : Ordnode α) : dual (rotateR l x r) = rotateL (dual r) x (dual l) := by rw [← dual_dual (rotateL _ _ _), dual_rotateL, dual_dual, dual_dual] #align ordnode.dual_rotate_r Ordnode.dual_rotateR theorem dual_balance' (l : Ordnode α) (x : α) (r : Ordnode α) : dual (balance' l x r) = balance' (dual r) x (dual l) := by simp [balance', add_comm]; split_ifs with h h_1 h_2 <;> simp [dual_node', dual_rotateL, dual_rotateR, add_comm] cases delta_lt_false h_1 h_2 #align ordnode.dual_balance' Ordnode.dual_balance' theorem dual_balanceL (l : Ordnode α) (x : α) (r : Ordnode α) : dual (balanceL l x r) = balanceR (dual r) x (dual l) := by unfold balanceL balanceR cases' r with rs rl rx rr · cases' l with ls ll lx lr; · rfl cases' ll with lls lll llx llr <;> cases' lr with lrs lrl lrx lrr <;> dsimp only [dual, id] <;> try rfl split_ifs with h <;> repeat simp [h, add_comm] · cases' l with ls ll lx lr; · rfl dsimp only [dual, id] split_ifs; swap; · simp [add_comm] cases' ll with lls lll llx llr <;> cases' lr with lrs lrl lrx lrr <;> try rfl dsimp only [dual, id] split_ifs with h <;> simp [h, add_comm] #align ordnode.dual_balance_l Ordnode.dual_balanceL theorem dual_balanceR (l : Ordnode α) (x : α) (r : Ordnode α) : dual (balanceR l x r) = balanceL (dual r) x (dual l) := by rw [← dual_dual (balanceL _ _ _), dual_balanceL, dual_dual, dual_dual] #align ordnode.dual_balance_r Ordnode.dual_balanceR theorem Sized.node3L {l x m y r} (hl : @Sized α l) (hm : Sized m) (hr : Sized r) : Sized (node3L l x m y r) := (hl.node' hm).node' hr #align ordnode.sized.node3_l Ordnode.Sized.node3L theorem Sized.node3R {l x m y r} (hl : @Sized α l) (hm : Sized m) (hr : Sized r) : Sized (node3R l x m y r) := hl.node' (hm.node' hr) #align ordnode.sized.node3_r Ordnode.Sized.node3R theorem Sized.node4L {l x m y r} (hl : @Sized α l) (hm : Sized m) (hr : Sized r) : Sized (node4L l x m y r) := by cases m <;> [exact (hl.node' hm).node' hr; exact (hl.node' hm.2.1).node' (hm.2.2.node' hr)] #align ordnode.sized.node4_l Ordnode.Sized.node4L theorem node3L_size {l x m y r} : size (@node3L α l x m y r) = size l + size m + size r + 2 := by dsimp [node3L, node', size]; rw [add_right_comm _ 1] #align ordnode.node3_l_size Ordnode.node3L_size theorem node3R_size {l x m y r} : size (@node3R α l x m y r) = size l + size m + size r + 2 := by dsimp [node3R, node', size]; rw [← add_assoc, ← add_assoc] #align ordnode.node3_r_size Ordnode.node3R_size theorem node4L_size {l x m y r} (hm : Sized m) : size (@node4L α l x m y r) = size l + size m + size r + 2 := by cases m <;> simp [node4L, node3L, node'] <;> [abel; (simp [size, hm.1]; abel)] #align ordnode.node4_l_size Ordnode.node4L_size theorem Sized.dual : ∀ {t : Ordnode α}, Sized t → Sized (dual t) | nil, _ => ⟨⟩ | node _ l _ r, ⟨rfl, sl, sr⟩ => ⟨by simp [size_dual, add_comm], Sized.dual sr, Sized.dual sl⟩ #align ordnode.sized.dual Ordnode.Sized.dual theorem Sized.dual_iff {t : Ordnode α} : Sized (.dual t) ↔ Sized t := ⟨fun h => by rw [← dual_dual t]; exact h.dual, Sized.dual⟩ #align ordnode.sized.dual_iff Ordnode.Sized.dual_iff theorem Sized.rotateL {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (rotateL l x r) := by cases r; · exact hl.node' hr rw [Ordnode.rotateL_node]; split_ifs · exact hl.node3L hr.2.1 hr.2.2 · exact hl.node4L hr.2.1 hr.2.2 #align ordnode.sized.rotate_l Ordnode.Sized.rotateL theorem Sized.rotateR {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (rotateR l x r) := Sized.dual_iff.1 <| by rw [dual_rotateR]; exact hr.dual.rotateL hl.dual #align ordnode.sized.rotate_r Ordnode.Sized.rotateR theorem Sized.rotateL_size {l x r} (hm : Sized r) : size (@Ordnode.rotateL α l x r) = size l + size r + 1 := by cases r <;> simp [Ordnode.rotateL] simp only [hm.1] split_ifs <;> simp [node3L_size, node4L_size hm.2.1] <;> abel #align ordnode.sized.rotate_l_size Ordnode.Sized.rotateL_size theorem Sized.rotateR_size {l x r} (hl : Sized l) : size (@Ordnode.rotateR α l x r) = size l + size r + 1 := by rw [← size_dual, dual_rotateR, hl.dual.rotateL_size, size_dual, size_dual, add_comm (size l)] #align ordnode.sized.rotate_r_size Ordnode.Sized.rotateR_size theorem Sized.balance' {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (balance' l x r) := by unfold balance'; split_ifs · exact hl.node' hr · exact hl.rotateL hr · exact hl.rotateR hr · exact hl.node' hr #align ordnode.sized.balance' Ordnode.Sized.balance' theorem size_balance' {l x r} (hl : @Sized α l) (hr : Sized r) : size (@balance' α l x r) = size l + size r + 1 := by unfold balance'; split_ifs · rfl · exact hr.rotateL_size · exact hl.rotateR_size · rfl #align ordnode.size_balance' Ordnode.size_balance' theorem All.imp {P Q : α → Prop} (H : ∀ a, P a → Q a) : ∀ {t}, All P t → All Q t | nil, _ => ⟨⟩ | node _ _ _ _, ⟨h₁, h₂, h₃⟩ => ⟨h₁.imp H, H _ h₂, h₃.imp H⟩ #align ordnode.all.imp Ordnode.All.imp theorem Any.imp {P Q : α → Prop} (H : ∀ a, P a → Q a) : ∀ {t}, Any P t → Any Q t | nil => id | node _ _ _ _ => Or.imp (Any.imp H) <| Or.imp (H _) (Any.imp H) #align ordnode.any.imp Ordnode.Any.imp theorem all_singleton {P : α → Prop} {x : α} : All P (singleton x) ↔ P x := ⟨fun h => h.2.1, fun h => ⟨⟨⟩, h, ⟨⟩⟩⟩ #align ordnode.all_singleton Ordnode.all_singleton theorem any_singleton {P : α → Prop} {x : α} : Any P (singleton x) ↔ P x := ⟨by rintro (⟨⟨⟩⟩ | h | ⟨⟨⟩⟩); exact h, fun h => Or.inr (Or.inl h)⟩ #align ordnode.any_singleton Ordnode.any_singleton theorem all_dual {P : α → Prop} : ∀ {t : Ordnode α}, All P (dual t) ↔ All P t | nil => Iff.rfl | node _ _l _x _r => ⟨fun ⟨hr, hx, hl⟩ => ⟨all_dual.1 hl, hx, all_dual.1 hr⟩, fun ⟨hl, hx, hr⟩ => ⟨all_dual.2 hr, hx, all_dual.2 hl⟩⟩ #align ordnode.all_dual Ordnode.all_dual theorem all_iff_forall {P : α → Prop} : ∀ {t}, All P t ↔ ∀ x, Emem x t → P x | nil => (iff_true_intro <| by rintro _ ⟨⟩).symm | node _ l x r => by simp [All, Emem, all_iff_forall, Any, or_imp, forall_and] #align ordnode.all_iff_forall Ordnode.all_iff_forall theorem any_iff_exists {P : α → Prop} : ∀ {t}, Any P t ↔ ∃ x, Emem x t ∧ P x | nil => ⟨by rintro ⟨⟩, by rintro ⟨_, ⟨⟩, _⟩⟩ | node _ l x r => by simp only [Emem]; simp [Any, any_iff_exists, or_and_right, exists_or] #align ordnode.any_iff_exists Ordnode.any_iff_exists theorem emem_iff_all {x : α} {t} : Emem x t ↔ ∀ P, All P t → P x := ⟨fun h _ al => all_iff_forall.1 al _ h, fun H => H _ <| all_iff_forall.2 fun _ => id⟩ #align ordnode.emem_iff_all Ordnode.emem_iff_all theorem all_node' {P l x r} : @All α P (node' l x r) ↔ All P l ∧ P x ∧ All P r := Iff.rfl #align ordnode.all_node' Ordnode.all_node' theorem all_node3L {P l x m y r} : @All α P (node3L l x m y r) ↔ All P l ∧ P x ∧ All P m ∧ P y ∧ All P r := by simp [node3L, all_node', and_assoc] #align ordnode.all_node3_l Ordnode.all_node3L theorem all_node3R {P l x m y r} : @All α P (node3R l x m y r) ↔ All P l ∧ P x ∧ All P m ∧ P y ∧ All P r := Iff.rfl #align ordnode.all_node3_r Ordnode.all_node3R theorem all_node4L {P l x m y r} : @All α P (node4L l x m y r) ↔ All P l ∧ P x ∧ All P m ∧ P y ∧ All P r := by cases m <;> simp [node4L, all_node', All, all_node3L, and_assoc] #align ordnode.all_node4_l Ordnode.all_node4L theorem all_node4R {P l x m y r} : @All α P (node4R l x m y r) ↔ All P l ∧ P x ∧ All P m ∧ P y ∧ All P r := by cases m <;> simp [node4R, all_node', All, all_node3R, and_assoc] #align ordnode.all_node4_r Ordnode.all_node4R theorem all_rotateL {P l x r} : @All α P (rotateL l x r) ↔ All P l ∧ P x ∧ All P r := by cases r <;> simp [rotateL, all_node']; split_ifs <;> simp [all_node3L, all_node4L, All, and_assoc] #align ordnode.all_rotate_l Ordnode.all_rotateL theorem all_rotateR {P l x r} : @All α P (rotateR l x r) ↔ All P l ∧ P x ∧ All P r := by rw [← all_dual, dual_rotateR, all_rotateL]; simp [all_dual, and_comm, and_left_comm, and_assoc] #align ordnode.all_rotate_r Ordnode.all_rotateR theorem all_balance' {P l x r} : @All α P (balance' l x r) ↔ All P l ∧ P x ∧ All P r := by rw [balance']; split_ifs <;> simp [all_node', all_rotateL, all_rotateR] #align ordnode.all_balance' Ordnode.all_balance' theorem foldr_cons_eq_toList : ∀ (t : Ordnode α) (r : List α), t.foldr List.cons r = toList t ++ r | nil, r => rfl | node _ l x r, r' => by rw [foldr, foldr_cons_eq_toList l, foldr_cons_eq_toList r, ← List.cons_append, ← List.append_assoc, ← foldr_cons_eq_toList l]; rfl #align ordnode.foldr_cons_eq_to_list Ordnode.foldr_cons_eq_toList @[simp] theorem toList_nil : toList (@nil α) = [] := rfl #align ordnode.to_list_nil Ordnode.toList_nil @[simp] theorem toList_node (s l x r) : toList (@node α s l x r) = toList l ++ x :: toList r := by rw [toList, foldr, foldr_cons_eq_toList]; rfl #align ordnode.to_list_node Ordnode.toList_node theorem emem_iff_mem_toList {x : α} {t} : Emem x t ↔ x ∈ toList t := by unfold Emem; induction t <;> simp [Any, *, or_assoc] #align ordnode.emem_iff_mem_to_list Ordnode.emem_iff_mem_toList theorem length_toList' : ∀ t : Ordnode α, (toList t).length = t.realSize | nil => rfl | node _ l _ r => by rw [toList_node, List.length_append, List.length_cons, length_toList' l, length_toList' r]; rfl #align ordnode.length_to_list' Ordnode.length_toList' theorem length_toList {t : Ordnode α} (h : Sized t) : (toList t).length = t.size := by rw [length_toList', size_eq_realSize h] #align ordnode.length_to_list Ordnode.length_toList theorem equiv_iff {t₁ t₂ : Ordnode α} (h₁ : Sized t₁) (h₂ : Sized t₂) : Equiv t₁ t₂ ↔ toList t₁ = toList t₂ := and_iff_right_of_imp fun h => by rw [← length_toList h₁, h, length_toList h₂] #align ordnode.equiv_iff Ordnode.equiv_iff theorem pos_size_of_mem [LE α] [@DecidableRel α (· ≤ ·)] {x : α} {t : Ordnode α} (h : Sized t) (h_mem : x ∈ t) : 0 < size t := by cases t; · { contradiction }; · { simp [h.1] } #align ordnode.pos_size_of_mem Ordnode.pos_size_of_mem theorem findMin'_dual : ∀ (t) (x : α), findMin' (dual t) x = findMax' x t | nil, _ => rfl | node _ _ x r, _ => findMin'_dual r x #align ordnode.find_min'_dual Ordnode.findMin'_dual theorem findMax'_dual (t) (x : α) : findMax' x (dual t) = findMin' t x := by rw [← findMin'_dual, dual_dual] #align ordnode.find_max'_dual Ordnode.findMax'_dual theorem findMin_dual : ∀ t : Ordnode α, findMin (dual t) = findMax t | nil => rfl | node _ _ _ _ => congr_arg some <| findMin'_dual _ _ #align ordnode.find_min_dual Ordnode.findMin_dual theorem findMax_dual (t : Ordnode α) : findMax (dual t) = findMin t := by rw [← findMin_dual, dual_dual] #align ordnode.find_max_dual Ordnode.findMax_dual theorem dual_eraseMin : ∀ t : Ordnode α, dual (eraseMin t) = eraseMax (dual t) | nil => rfl | node _ nil x r => rfl | node _ (node sz l' y r') x r => by rw [eraseMin, dual_balanceR, dual_eraseMin (node sz l' y r'), dual, dual, dual, eraseMax] #align ordnode.dual_erase_min Ordnode.dual_eraseMin theorem dual_eraseMax (t : Ordnode α) : dual (eraseMax t) = eraseMin (dual t) := by rw [← dual_dual (eraseMin _), dual_eraseMin, dual_dual] #align ordnode.dual_erase_max Ordnode.dual_eraseMax theorem splitMin_eq : ∀ (s l) (x : α) (r), splitMin' l x r = (findMin' l x, eraseMin (node s l x r)) | _, nil, x, r => rfl | _, node ls ll lx lr, x, r => by rw [splitMin', splitMin_eq ls ll lx lr, findMin', eraseMin] #align ordnode.split_min_eq Ordnode.splitMin_eq theorem splitMax_eq : ∀ (s l) (x : α) (r), splitMax' l x r = (eraseMax (node s l x r), findMax' x r) | _, l, x, nil => rfl | _, l, x, node ls ll lx lr => by rw [splitMax', splitMax_eq ls ll lx lr, findMax', eraseMax] #align ordnode.split_max_eq Ordnode.splitMax_eq -- @[elab_as_elim] -- Porting note: unexpected eliminator resulting type theorem findMin'_all {P : α → Prop} : ∀ (t) (x : α), All P t → P x → P (findMin' t x) | nil, _x, _, hx => hx | node _ ll lx _, _, ⟨h₁, h₂, _⟩, _ => findMin'_all ll lx h₁ h₂ #align ordnode.find_min'_all Ordnode.findMin'_all -- @[elab_as_elim] -- Porting note: unexpected eliminator resulting type theorem findMax'_all {P : α → Prop} : ∀ (x : α) (t), P x → All P t → P (findMax' x t) | _x, nil, hx, _ => hx | _, node _ _ lx lr, _, ⟨_, h₂, h₃⟩ => findMax'_all lx lr h₂ h₃ #align ordnode.find_max'_all Ordnode.findMax'_all @[simp] theorem merge_nil_left (t : Ordnode α) : merge t nil = t := by cases t <;> rfl #align ordnode.merge_nil_left Ordnode.merge_nil_left @[simp] theorem merge_nil_right (t : Ordnode α) : merge nil t = t := rfl #align ordnode.merge_nil_right Ordnode.merge_nil_right @[simp] theorem merge_node {ls ll lx lr rs rl rx rr} : merge (@node α ls ll lx lr) (node rs rl rx rr) = if delta * ls < rs then balanceL (merge (node ls ll lx lr) rl) rx rr else if delta * rs < ls then balanceR ll lx (merge lr (node rs rl rx rr)) else glue (node ls ll lx lr) (node rs rl rx rr) := rfl #align ordnode.merge_node Ordnode.merge_node theorem dual_insert [Preorder α] [IsTotal α (· ≤ ·)] [@DecidableRel α (· ≤ ·)] (x : α) : ∀ t : Ordnode α, dual (Ordnode.insert x t) = @Ordnode.insert αᵒᵈ _ _ x (dual t) | nil => rfl | node _ l y r => by have : @cmpLE αᵒᵈ _ _ x y = cmpLE y x := rfl rw [Ordnode.insert, dual, Ordnode.insert, this, ← cmpLE_swap x y] cases cmpLE x y <;> simp [Ordering.swap, Ordnode.insert, dual_balanceL, dual_balanceR, dual_insert] #align ordnode.dual_insert Ordnode.dual_insert theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l) (sr : Sized r) : @balance α l x r = balance' l x r := by cases' l with ls ll lx lr · cases' r with rs rl rx rr · rfl · rw [sr.eq_node'] at hr ⊢ cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;> dsimp [balance, balance'] · rfl · have : size rrl = 0 ∧ size rrr = 0 := by have := balancedSz_zero.1 hr.1.symm rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, Nat.le_zero, add_eq_zero_iff] at this cases sr.2.2.2.1.size_eq_zero.1 this.1 cases sr.2.2.2.2.size_eq_zero.1 this.2 obtain rfl : rrs = 1 := sr.2.2.1 rw [if_neg, if_pos, rotateL_node, if_pos]; · rfl all_goals dsimp only [size]; decide · have : size rll = 0 ∧ size rlr = 0 := by have := balancedSz_zero.1 hr.1 rwa [size, sr.2.1.1, Nat.succ_le_succ_iff, Nat.le_zero, add_eq_zero_iff] at this cases sr.2.1.2.1.size_eq_zero.1 this.1 cases sr.2.1.2.2.size_eq_zero.1 this.2 obtain rfl : rls = 1 := sr.2.1.1 rw [if_neg, if_pos, rotateL_node, if_neg]; · rfl all_goals dsimp only [size]; decide · symm; rw [zero_add, if_neg, if_pos, rotateL] · dsimp only [size_node]; split_ifs · simp [node3L, node']; abel · simp [node4L, node', sr.2.1.1]; abel · apply Nat.zero_lt_succ · exact not_le_of_gt (Nat.succ_lt_succ (add_pos sr.2.1.pos sr.2.2.pos)) · cases' r with rs rl rx rr · rw [sl.eq_node'] at hl ⊢ cases' ll with lls lll llx llr <;> cases' lr with lrs lrl lrx lrr <;> dsimp [balance, balance'] · rfl · have : size lrl = 0 ∧ size lrr = 0 := by have := balancedSz_zero.1 hl.1.symm rwa [size, sl.2.2.1, Nat.succ_le_succ_iff, Nat.le_zero, add_eq_zero_iff] at this cases sl.2.2.2.1.size_eq_zero.1 this.1 cases sl.2.2.2.2.size_eq_zero.1 this.2 obtain rfl : lrs = 1 := sl.2.2.1 rw [if_neg, if_neg, if_pos, rotateR_node, if_neg]; · rfl all_goals dsimp only [size]; decide · have : size lll = 0 ∧ size llr = 0 := by have := balancedSz_zero.1 hl.1 rwa [size, sl.2.1.1, Nat.succ_le_succ_iff, Nat.le_zero, add_eq_zero_iff] at this cases sl.2.1.2.1.size_eq_zero.1 this.1 cases sl.2.1.2.2.size_eq_zero.1 this.2 obtain rfl : lls = 1 := sl.2.1.1 rw [if_neg, if_neg, if_pos, rotateR_node, if_pos]; · rfl all_goals dsimp only [size]; decide · symm; rw [if_neg, if_neg, if_pos, rotateR] · dsimp only [size_node]; split_ifs · simp [node3R, node']; abel · simp [node4R, node', sl.2.2.1]; abel · apply Nat.zero_lt_succ · apply Nat.not_lt_zero · exact not_le_of_gt (Nat.succ_lt_succ (add_pos sl.2.1.pos sl.2.2.pos)) · simp [balance, balance'] symm; rw [if_neg] · split_ifs with h h_1 · have rd : delta ≤ size rl + size rr := by have := lt_of_le_of_lt (Nat.mul_le_mul_left _ sl.pos) h rwa [sr.1, Nat.lt_succ_iff] at this cases' rl with rls rll rlx rlr · rw [size, zero_add] at rd exact absurd (le_trans rd (balancedSz_zero.1 hr.1.symm)) (by decide) cases' rr with rrs rrl rrx rrr · exact absurd (le_trans rd (balancedSz_zero.1 hr.1)) (by decide) dsimp [rotateL]; split_ifs · simp [node3L, node', sr.1]; abel · simp [node4L, node', sr.1, sr.2.1.1]; abel · have ld : delta ≤ size ll + size lr := by have := lt_of_le_of_lt (Nat.mul_le_mul_left _ sr.pos) h_1 rwa [sl.1, Nat.lt_succ_iff] at this cases' ll with lls lll llx llr · rw [size, zero_add] at ld exact absurd (le_trans ld (balancedSz_zero.1 hl.1.symm)) (by decide) cases' lr with lrs lrl lrx lrr · exact absurd (le_trans ld (balancedSz_zero.1 hl.1)) (by decide) dsimp [rotateR]; split_ifs · simp [node3R, node', sl.1]; abel · simp [node4R, node', sl.1, sl.2.2.1]; abel · simp [node'] · exact not_le_of_gt (add_le_add (Nat.succ_le_of_lt sl.pos) (Nat.succ_le_of_lt sr.pos)) #align ordnode.balance_eq_balance' Ordnode.balance_eq_balance' theorem balanceL_eq_balance {l x r} (sl : Sized l) (sr : Sized r) (H1 : size l = 0 → size r ≤ 1) (H2 : 1 ≤ size l → 1 ≤ size r → size r ≤ delta * size l) : @balanceL α l x r = balance l x r := by cases' r with rs rl rx rr · rfl · cases' l with ls ll lx lr · have : size rl = 0 ∧ size rr = 0 := by have := H1 rfl rwa [size, sr.1, Nat.succ_le_succ_iff, Nat.le_zero, add_eq_zero_iff] at this cases sr.2.1.size_eq_zero.1 this.1 cases sr.2.2.size_eq_zero.1 this.2 rw [sr.eq_node']; rfl · replace H2 : ¬rs > delta * ls := not_lt_of_le (H2 sl.pos sr.pos) simp [balanceL, balance, H2]; split_ifs <;> simp [add_comm] #align ordnode.balance_l_eq_balance Ordnode.balanceL_eq_balance def Raised (n m : ℕ) : Prop := m = n ∨ m = n + 1 #align ordnode.raised Ordnode.Raised theorem raised_iff {n m} : Raised n m ↔ n ≤ m ∧ m ≤ n + 1 := by constructor · rintro (rfl | rfl) · exact ⟨le_rfl, Nat.le_succ _⟩ · exact ⟨Nat.le_succ _, le_rfl⟩ · rintro ⟨h₁, h₂⟩ rcases eq_or_lt_of_le h₁ with (rfl | h₁) · exact Or.inl rfl · exact Or.inr (le_antisymm h₂ h₁) #align ordnode.raised_iff Ordnode.raised_iff theorem Raised.dist_le {n m} (H : Raised n m) : Nat.dist n m ≤ 1 := by cases' raised_iff.1 H with H1 H2; rwa [Nat.dist_eq_sub_of_le H1, tsub_le_iff_left] #align ordnode.raised.dist_le Ordnode.Raised.dist_le theorem Raised.dist_le' {n m} (H : Raised n m) : Nat.dist m n ≤ 1 := by rw [Nat.dist_comm]; exact H.dist_le #align ordnode.raised.dist_le' Ordnode.Raised.dist_le' theorem Raised.add_left (k) {n m} (H : Raised n m) : Raised (k + n) (k + m) := by rcases H with (rfl | rfl) · exact Or.inl rfl · exact Or.inr rfl #align ordnode.raised.add_left Ordnode.Raised.add_left theorem Raised.add_right (k) {n m} (H : Raised n m) : Raised (n + k) (m + k) := by rw [add_comm, add_comm m]; exact H.add_left _ #align ordnode.raised.add_right Ordnode.Raised.add_right theorem Raised.right {l x₁ x₂ r₁ r₂} (H : Raised (size r₁) (size r₂)) : Raised (size (@node' α l x₁ r₁)) (size (@node' α l x₂ r₂)) := by rw [node', size_node, size_node]; generalize size r₂ = m at H ⊢ rcases H with (rfl | rfl) · exact Or.inl rfl · exact Or.inr rfl #align ordnode.raised.right Ordnode.Raised.right theorem balanceL_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l) (sr : Sized r) (H : (∃ l', Raised l' (size l) ∧ BalancedSz l' (size r)) ∨ ∃ r', Raised (size r) r' ∧ BalancedSz (size l) r') : @balanceL α l x r = balance' l x r := by rw [← balance_eq_balance' hl hr sl sr, balanceL_eq_balance sl sr] · intro l0; rw [l0] at H rcases H with (⟨_, ⟨⟨⟩⟩ | ⟨⟨⟩⟩, H⟩ | ⟨r', e, H⟩) · exact balancedSz_zero.1 H.symm exact le_trans (raised_iff.1 e).1 (balancedSz_zero.1 H.symm) · intro l1 _ rcases H with (⟨l', e, H | ⟨_, H₂⟩⟩ | ⟨r', e, H | ⟨_, H₂⟩⟩) · exact le_trans (le_trans (Nat.le_add_left _ _) H) (mul_pos (by decide) l1 : (0 : ℕ) < _) · exact le_trans H₂ (Nat.mul_le_mul_left _ (raised_iff.1 e).1) · cases raised_iff.1 e; unfold delta; omega · exact le_trans (raised_iff.1 e).1 H₂ #align ordnode.balance_l_eq_balance' Ordnode.balanceL_eq_balance' theorem balance_sz_dual {l r} (H : (∃ l', Raised (@size α l) l' ∧ BalancedSz l' (@size α r)) ∨ ∃ r', Raised r' (size r) ∧ BalancedSz (size l) r') : (∃ l', Raised l' (size (dual r)) ∧ BalancedSz l' (size (dual l))) ∨ ∃ r', Raised (size (dual l)) r' ∧ BalancedSz (size (dual r)) r' := by rw [size_dual, size_dual] exact H.symm.imp (Exists.imp fun _ => And.imp_right BalancedSz.symm) (Exists.imp fun _ => And.imp_right BalancedSz.symm) #align ordnode.balance_sz_dual Ordnode.balance_sz_dual
Mathlib/Data/Ordmap/Ordset.lean
850
854
theorem size_balanceL {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l) (sr : Sized r) (H : (∃ l', Raised l' (size l) ∧ BalancedSz l' (size r)) ∨ ∃ r', Raised (size r) r' ∧ BalancedSz (size l) r') : size (@balanceL α l x r) = size l + size r + 1 := by
rw [balanceL_eq_balance' hl hr sl sr H, size_balance' sl sr]
import Mathlib.Analysis.Normed.Group.InfiniteSum import Mathlib.Analysis.Normed.MulAction import Mathlib.Topology.Algebra.Order.LiminfLimsup import Mathlib.Topology.PartialHomeomorph #align_import analysis.asymptotics.asymptotics from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open Filter Set open scoped Classical open Topology Filter NNReal namespace Asymptotics set_option linter.uppercaseLean3 false variable {α : Type*} {β : Type*} {E : Type*} {F : Type*} {G : Type*} {E' : Type*} {F' : Type*} {G' : Type*} {E'' : Type*} {F'' : Type*} {G'' : Type*} {E''' : Type*} {R : Type*} {R' : Type*} {𝕜 : Type*} {𝕜' : Type*} variable [Norm E] [Norm F] [Norm G] variable [SeminormedAddCommGroup E'] [SeminormedAddCommGroup F'] [SeminormedAddCommGroup G'] [NormedAddCommGroup E''] [NormedAddCommGroup F''] [NormedAddCommGroup G''] [SeminormedRing R] [SeminormedAddGroup E'''] [SeminormedRing R'] variable [NormedDivisionRing 𝕜] [NormedDivisionRing 𝕜'] variable {c c' c₁ c₂ : ℝ} {f : α → E} {g : α → F} {k : α → G} variable {f' : α → E'} {g' : α → F'} {k' : α → G'} variable {f'' : α → E''} {g'' : α → F''} {k'' : α → G''} variable {l l' : Filter α} section Defs irreducible_def IsBigOWith (c : ℝ) (l : Filter α) (f : α → E) (g : α → F) : Prop := ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ #align asymptotics.is_O_with Asymptotics.IsBigOWith theorem isBigOWith_iff : IsBigOWith c l f g ↔ ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := by rw [IsBigOWith_def] #align asymptotics.is_O_with_iff Asymptotics.isBigOWith_iff alias ⟨IsBigOWith.bound, IsBigOWith.of_bound⟩ := isBigOWith_iff #align asymptotics.is_O_with.bound Asymptotics.IsBigOWith.bound #align asymptotics.is_O_with.of_bound Asymptotics.IsBigOWith.of_bound irreducible_def IsBigO (l : Filter α) (f : α → E) (g : α → F) : Prop := ∃ c : ℝ, IsBigOWith c l f g #align asymptotics.is_O Asymptotics.IsBigO @[inherit_doc] notation:100 f " =O[" l "] " g:100 => IsBigO l f g theorem isBigO_iff_isBigOWith : f =O[l] g ↔ ∃ c : ℝ, IsBigOWith c l f g := by rw [IsBigO_def] #align asymptotics.is_O_iff_is_O_with Asymptotics.isBigO_iff_isBigOWith theorem isBigO_iff : f =O[l] g ↔ ∃ c : ℝ, ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := by simp only [IsBigO_def, IsBigOWith_def] #align asymptotics.is_O_iff Asymptotics.isBigO_iff theorem isBigO_iff' {g : α → E'''} : f =O[l] g ↔ ∃ c > 0, ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := by refine ⟨fun h => ?mp, fun h => ?mpr⟩ case mp => rw [isBigO_iff] at h obtain ⟨c, hc⟩ := h refine ⟨max c 1, zero_lt_one.trans_le (le_max_right _ _), ?_⟩ filter_upwards [hc] with x hx apply hx.trans gcongr exact le_max_left _ _ case mpr => rw [isBigO_iff] obtain ⟨c, ⟨_, hc⟩⟩ := h exact ⟨c, hc⟩
Mathlib/Analysis/Asymptotics/Asymptotics.lean
135
149
theorem isBigO_iff'' {g : α → E'''} : f =O[l] g ↔ ∃ c > 0, ∀ᶠ x in l, c * ‖f x‖ ≤ ‖g x‖ := by
refine ⟨fun h => ?mp, fun h => ?mpr⟩ case mp => rw [isBigO_iff'] at h obtain ⟨c, ⟨hc_pos, hc⟩⟩ := h refine ⟨c⁻¹, ⟨by positivity, ?_⟩⟩ filter_upwards [hc] with x hx rwa [inv_mul_le_iff (by positivity)] case mpr => rw [isBigO_iff'] obtain ⟨c, ⟨hc_pos, hc⟩⟩ := h refine ⟨c⁻¹, ⟨by positivity, ?_⟩⟩ filter_upwards [hc] with x hx rwa [← inv_inv c, inv_mul_le_iff (by positivity)] at hx
import Mathlib.Algebra.Order.Group.Nat import Mathlib.Data.List.Rotate import Mathlib.GroupTheory.Perm.Support #align_import group_theory.perm.list from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" namespace List variable {α β : Type*} section FormPerm variable [DecidableEq α] (l : List α) open Equiv Equiv.Perm def formPerm : Equiv.Perm α := (zipWith Equiv.swap l l.tail).prod #align list.form_perm List.formPerm @[simp] theorem formPerm_nil : formPerm ([] : List α) = 1 := rfl #align list.form_perm_nil List.formPerm_nil @[simp] theorem formPerm_singleton (x : α) : formPerm [x] = 1 := rfl #align list.form_perm_singleton List.formPerm_singleton @[simp] theorem formPerm_cons_cons (x y : α) (l : List α) : formPerm (x :: y :: l) = swap x y * formPerm (y :: l) := prod_cons #align list.form_perm_cons_cons List.formPerm_cons_cons theorem formPerm_pair (x y : α) : formPerm [x, y] = swap x y := rfl #align list.form_perm_pair List.formPerm_pair theorem mem_or_mem_of_zipWith_swap_prod_ne : ∀ {l l' : List α} {x : α}, (zipWith swap l l').prod x ≠ x → x ∈ l ∨ x ∈ l' | [], _, _ => by simp | _, [], _ => by simp | a::l, b::l', x => fun hx ↦ if h : (zipWith swap l l').prod x = x then (eq_or_eq_of_swap_apply_ne_self (by simpa [h] using hx)).imp (by rintro rfl; exact .head _) (by rintro rfl; exact .head _) else (mem_or_mem_of_zipWith_swap_prod_ne h).imp (.tail _) (.tail _) theorem zipWith_swap_prod_support' (l l' : List α) : { x | (zipWith swap l l').prod x ≠ x } ≤ l.toFinset ⊔ l'.toFinset := fun _ h ↦ by simpa using mem_or_mem_of_zipWith_swap_prod_ne h #align list.zip_with_swap_prod_support' List.zipWith_swap_prod_support' theorem zipWith_swap_prod_support [Fintype α] (l l' : List α) : (zipWith swap l l').prod.support ≤ l.toFinset ⊔ l'.toFinset := by intro x hx have hx' : x ∈ { x | (zipWith swap l l').prod x ≠ x } := by simpa using hx simpa using zipWith_swap_prod_support' _ _ hx' #align list.zip_with_swap_prod_support List.zipWith_swap_prod_support theorem support_formPerm_le' : { x | formPerm l x ≠ x } ≤ l.toFinset := by refine (zipWith_swap_prod_support' l l.tail).trans ?_ simpa [Finset.subset_iff] using tail_subset l #align list.support_form_perm_le' List.support_formPerm_le' theorem support_formPerm_le [Fintype α] : support (formPerm l) ≤ l.toFinset := by intro x hx have hx' : x ∈ { x | formPerm l x ≠ x } := by simpa using hx simpa using support_formPerm_le' _ hx' #align list.support_form_perm_le List.support_formPerm_le variable {l} {x : α} theorem mem_of_formPerm_apply_ne (h : l.formPerm x ≠ x) : x ∈ l := by simpa [or_iff_left_of_imp mem_of_mem_tail] using mem_or_mem_of_zipWith_swap_prod_ne h #align list.mem_of_form_perm_apply_ne List.mem_of_formPerm_apply_ne theorem formPerm_apply_of_not_mem (h : x ∉ l) : formPerm l x = x := not_imp_comm.1 mem_of_formPerm_apply_ne h #align list.form_perm_apply_of_not_mem List.formPerm_apply_of_not_mem theorem formPerm_apply_mem_of_mem (h : x ∈ l) : formPerm l x ∈ l := by cases' l with y l · simp at h induction' l with z l IH generalizing x y · simpa using h · by_cases hx : x ∈ z :: l · rw [formPerm_cons_cons, mul_apply, swap_apply_def] split_ifs · simp [IH _ hx] · simp · simp [*] · replace h : x = y := Or.resolve_right (mem_cons.1 h) hx simp [formPerm_apply_of_not_mem hx, ← h] #align list.form_perm_apply_mem_of_mem List.formPerm_apply_mem_of_mem theorem mem_of_formPerm_apply_mem (h : l.formPerm x ∈ l) : x ∈ l := by contrapose h rwa [formPerm_apply_of_not_mem h] #align list.mem_of_form_perm_apply_mem List.mem_of_formPerm_apply_mem @[simp] theorem formPerm_mem_iff_mem : l.formPerm x ∈ l ↔ x ∈ l := ⟨l.mem_of_formPerm_apply_mem, l.formPerm_apply_mem_of_mem⟩ #align list.form_perm_mem_iff_mem List.formPerm_mem_iff_mem @[simp] theorem formPerm_cons_concat_apply_last (x y : α) (xs : List α) : formPerm (x :: (xs ++ [y])) y = x := by induction' xs with z xs IH generalizing x y · simp · simp [IH] #align list.form_perm_cons_concat_apply_last List.formPerm_cons_concat_apply_last @[simp] theorem formPerm_apply_getLast (x : α) (xs : List α) : formPerm (x :: xs) ((x :: xs).getLast (cons_ne_nil x xs)) = x := by induction' xs using List.reverseRecOn with xs y _ generalizing x <;> simp #align list.form_perm_apply_last List.formPerm_apply_getLast @[simp] theorem formPerm_apply_get_length (x : α) (xs : List α) : formPerm (x :: xs) ((x :: xs).get (Fin.mk xs.length (by simp))) = x := by rw [get_cons_length, formPerm_apply_getLast]; rfl; set_option linter.deprecated false in @[simp, deprecated formPerm_apply_get_length (since := "2024-05-30")] theorem formPerm_apply_nthLe_length (x : α) (xs : List α) : formPerm (x :: xs) ((x :: xs).nthLe xs.length (by simp)) = x := by apply formPerm_apply_get_length #align list.form_perm_apply_nth_le_length List.formPerm_apply_nthLe_length theorem formPerm_apply_head (x y : α) (xs : List α) (h : Nodup (x :: y :: xs)) : formPerm (x :: y :: xs) x = y := by simp [formPerm_apply_of_not_mem h.not_mem] #align list.form_perm_apply_head List.formPerm_apply_head theorem formPerm_apply_get_zero (l : List α) (h : Nodup l) (hl : 1 < l.length) : formPerm l (l.get (Fin.mk 0 (by omega))) = l.get (Fin.mk 1 hl) := by rcases l with (_ | ⟨x, _ | ⟨y, tl⟩⟩) · simp at hl · rw [get, get_singleton]; rfl; · rw [get, formPerm_apply_head, get, get] exact h set_option linter.deprecated false in @[deprecated formPerm_apply_get_zero (since := "2024-05-30")] theorem formPerm_apply_nthLe_zero (l : List α) (h : Nodup l) (hl : 1 < l.length) : formPerm l (l.nthLe 0 (by omega)) = l.nthLe 1 hl := by apply formPerm_apply_get_zero _ h #align list.form_perm_apply_nth_le_zero List.formPerm_apply_nthLe_zero variable (l) theorem formPerm_eq_head_iff_eq_getLast (x y : α) : formPerm (y :: l) x = y ↔ x = getLast (y :: l) (cons_ne_nil _ _) := Iff.trans (by rw [formPerm_apply_getLast]) (formPerm (y :: l)).injective.eq_iff #align list.form_perm_eq_head_iff_eq_last List.formPerm_eq_head_iff_eq_getLast theorem formPerm_apply_lt_get (xs : List α) (h : Nodup xs) (n : ℕ) (hn : n + 1 < xs.length) : formPerm xs (xs.get (Fin.mk n ((Nat.lt_succ_self n).trans hn))) = xs.get (Fin.mk (n + 1) hn) := by induction' n with n IH generalizing xs · simpa using formPerm_apply_get_zero _ h _ · rcases xs with (_ | ⟨x, _ | ⟨y, l⟩⟩) · simp at hn · rw [formPerm_singleton, get_singleton, get_singleton] rfl; · specialize IH (y :: l) h.of_cons _ · simpa [Nat.succ_lt_succ_iff] using hn simp only [swap_apply_eq_iff, coe_mul, formPerm_cons_cons, Function.comp] simp only [get_cons_succ] at * rw [← IH, swap_apply_of_ne_of_ne] <;> · intro hx rw [← hx, IH] at h simp [get_mem] at h set_option linter.deprecated false in @[deprecated formPerm_apply_lt_get (since := "2024-05-30")] theorem formPerm_apply_lt (xs : List α) (h : Nodup xs) (n : ℕ) (hn : n + 1 < xs.length) : formPerm xs (xs.nthLe n ((Nat.lt_succ_self n).trans hn)) = xs.nthLe (n + 1) hn := by apply formPerm_apply_lt_get _ h #align list.form_perm_apply_lt List.formPerm_apply_lt theorem formPerm_apply_get (xs : List α) (h : Nodup xs) (i : Fin xs.length) : formPerm xs (xs.get i) = xs.get ⟨((i.val + 1) % xs.length), (Nat.mod_lt _ (i.val.zero_le.trans_lt i.isLt))⟩ := by let ⟨n, hn⟩ := i cases' xs with x xs · simp at hn · have : n ≤ xs.length := by refine Nat.le_of_lt_succ ?_ simpa using hn rcases this.eq_or_lt with (rfl | hn') · simp · rw [formPerm_apply_lt_get (x :: xs) h _ (Nat.succ_lt_succ hn')] congr rw [Nat.mod_eq_of_lt]; simpa [Nat.succ_eq_add_one] set_option linter.deprecated false in @[deprecated formPerm_apply_get (since := "2024-04-23")] theorem formPerm_apply_nthLe (xs : List α) (h : Nodup xs) (n : ℕ) (hn : n < xs.length) : formPerm xs (xs.nthLe n hn) = xs.nthLe ((n + 1) % xs.length) (Nat.mod_lt _ (n.zero_le.trans_lt hn)) := by apply formPerm_apply_get _ h #align list.form_perm_apply_nth_le List.formPerm_apply_nthLe theorem support_formPerm_of_nodup' (l : List α) (h : Nodup l) (h' : ∀ x : α, l ≠ [x]) : { x | formPerm l x ≠ x } = l.toFinset := by apply _root_.le_antisymm · exact support_formPerm_le' l · intro x hx simp only [Finset.mem_coe, mem_toFinset] at hx obtain ⟨⟨n, hn⟩, rfl⟩ := get_of_mem hx rw [Set.mem_setOf_eq, formPerm_apply_get _ h] intro H rw [nodup_iff_injective_get, Function.Injective] at h specialize h H rcases (Nat.succ_le_of_lt hn).eq_or_lt with hn' | hn' · simp only [← hn', Nat.mod_self] at h refine' not_exists.mpr h' _ rw [← length_eq_one, ← hn', (Fin.mk.inj_iff.mp h).symm] · simp [Nat.mod_eq_of_lt hn'] at h #align list.support_form_perm_of_nodup' List.support_formPerm_of_nodup' theorem support_formPerm_of_nodup [Fintype α] (l : List α) (h : Nodup l) (h' : ∀ x : α, l ≠ [x]) : support (formPerm l) = l.toFinset := by rw [← Finset.coe_inj] convert support_formPerm_of_nodup' _ h h' simp [Set.ext_iff] #align list.support_form_perm_of_nodup List.support_formPerm_of_nodup theorem formPerm_rotate_one (l : List α) (h : Nodup l) : formPerm (l.rotate 1) = formPerm l := by have h' : Nodup (l.rotate 1) := by simpa using h ext x by_cases hx : x ∈ l.rotate 1 · obtain ⟨⟨k, hk⟩, rfl⟩ := get_of_mem hx rw [formPerm_apply_get _ h', get_rotate l, get_rotate l, formPerm_apply_get _ h] simp · rw [formPerm_apply_of_not_mem hx, formPerm_apply_of_not_mem] simpa using hx #align list.form_perm_rotate_one List.formPerm_rotate_one theorem formPerm_rotate (l : List α) (h : Nodup l) (n : ℕ) : formPerm (l.rotate n) = formPerm l := by induction' n with n hn · simp · rw [← rotate_rotate, formPerm_rotate_one, hn] rwa [IsRotated.nodup_iff] exact IsRotated.forall l n #align list.form_perm_rotate List.formPerm_rotate theorem formPerm_eq_of_isRotated {l l' : List α} (hd : Nodup l) (h : l ~r l') : formPerm l = formPerm l' := by obtain ⟨n, rfl⟩ := h exact (formPerm_rotate l hd n).symm #align list.form_perm_eq_of_is_rotated List.formPerm_eq_of_isRotated theorem formPerm_append_pair : ∀ (l : List α) (a b : α), formPerm (l ++ [a, b]) = formPerm (l ++ [a]) * swap a b | [], _, _ => rfl | [x], _, _ => rfl | x::y::l, a, b => by simpa [mul_assoc] using formPerm_append_pair (y::l) a b theorem formPerm_reverse : ∀ l : List α, formPerm l.reverse = (formPerm l)⁻¹ | [] => rfl | [_] => rfl | a::b::l => by simp [formPerm_append_pair, swap_comm, ← formPerm_reverse (b::l)] #align list.form_perm_reverse List.formPerm_reverse theorem formPerm_pow_apply_get (l : List α) (h : Nodup l) (n : ℕ) (i : Fin l.length) : (formPerm l ^ n) (l.get i) = l.get ⟨((i.val + n) % l.length), (Nat.mod_lt _ (i.val.zero_le.trans_lt i.isLt))⟩ := by induction' n with n hn · simp [Nat.mod_eq_of_lt i.isLt] · simp [pow_succ', mul_apply, hn, formPerm_apply_get _ h, Nat.succ_eq_add_one, ← Nat.add_assoc] set_option linter.deprecated false in @[deprecated formPerm_pow_apply_get (since := "2024-04-23")] theorem formPerm_pow_apply_nthLe (l : List α) (h : Nodup l) (n k : ℕ) (hk : k < l.length) : (formPerm l ^ n) (l.nthLe k hk) = l.nthLe ((k + n) % l.length) (Nat.mod_lt _ (k.zero_le.trans_lt hk)) := formPerm_pow_apply_get l h n ⟨k, hk⟩ #align list.form_perm_pow_apply_nth_le List.formPerm_pow_apply_nthLe theorem formPerm_pow_apply_head (x : α) (l : List α) (h : Nodup (x :: l)) (n : ℕ) : (formPerm (x :: l) ^ n) x = (x :: l).get ⟨(n % (x :: l).length), (Nat.mod_lt _ (Nat.zero_lt_succ _))⟩ := by convert formPerm_pow_apply_get _ h n ⟨0, Nat.succ_pos _⟩ simp #align list.form_perm_pow_apply_head List.formPerm_pow_apply_head theorem formPerm_ext_iff {x y x' y' : α} {l l' : List α} (hd : Nodup (x :: y :: l)) (hd' : Nodup (x' :: y' :: l')) : formPerm (x :: y :: l) = formPerm (x' :: y' :: l') ↔ (x :: y :: l) ~r (x' :: y' :: l') := by refine ⟨fun h => ?_, fun hr => formPerm_eq_of_isRotated hd hr⟩ rw [Equiv.Perm.ext_iff] at h have hx : x' ∈ x :: y :: l := by have : x' ∈ { z | formPerm (x :: y :: l) z ≠ z } := by rw [Set.mem_setOf_eq, h x', formPerm_apply_head _ _ _ hd'] simp only [mem_cons, nodup_cons] at hd' push_neg at hd' exact hd'.left.left.symm simpa using support_formPerm_le' _ this obtain ⟨⟨n, hn⟩, hx'⟩ := get_of_mem hx have hl : (x :: y :: l).length = (x' :: y' :: l').length := by rw [← dedup_eq_self.mpr hd, ← dedup_eq_self.mpr hd', ← card_toFinset, ← card_toFinset] refine congr_arg Finset.card ?_ rw [← Finset.coe_inj, ← support_formPerm_of_nodup' _ hd (by simp), ← support_formPerm_of_nodup' _ hd' (by simp)] simp only [h] use n apply List.ext_get · rw [length_rotate, hl] · intro k hk hk' rw [get_rotate] induction' k with k IH · refine Eq.trans ?_ hx' congr simpa using hn · conv => congr <;> · arg 2; (congr; (simp only [Fin.val_mk]; rw [← Nat.mod_eq_of_lt hk'])) rw [← formPerm_apply_get _ hd' ⟨k, k.lt_succ_self.trans hk'⟩, ← IH (k.lt_succ_self.trans hk), ← h, formPerm_apply_get _ hd] congr 2 simp only [Fin.val_mk] rw [hl, Nat.mod_eq_of_lt hk', add_right_comm] apply Nat.add_mod #align list.form_perm_ext_iff List.formPerm_ext_iff theorem formPerm_apply_mem_eq_self_iff (hl : Nodup l) (x : α) (hx : x ∈ l) : formPerm l x = x ↔ length l ≤ 1 := by obtain ⟨⟨k, hk⟩, rfl⟩ := get_of_mem hx rw [formPerm_apply_get _ hl ⟨k, hk⟩, hl.get_inj_iff, Fin.mk.inj_iff] simp only [Fin.val_mk] cases hn : l.length · exact absurd k.zero_le (hk.trans_le hn.le).not_le · rw [hn] at hk rcases (Nat.le_of_lt_succ hk).eq_or_lt with hk' | hk' · simp [← hk', Nat.succ_le_succ_iff, eq_comm] · simpa [Nat.mod_eq_of_lt (Nat.succ_lt_succ hk'), Nat.succ_lt_succ_iff] using (k.zero_le.trans_lt hk').ne.symm #align list.form_perm_apply_mem_eq_self_iff List.formPerm_apply_mem_eq_self_iff
Mathlib/GroupTheory/Perm/List.lean
379
382
theorem formPerm_apply_mem_ne_self_iff (hl : Nodup l) (x : α) (hx : x ∈ l) : formPerm l x ≠ x ↔ 2 ≤ l.length := by
rw [Ne, formPerm_apply_mem_eq_self_iff _ hl x hx, not_le] exact ⟨Nat.succ_le_of_lt, Nat.lt_of_succ_le⟩
import Batteries.Data.Rat.Basic import Batteries.Tactic.SeqFocus namespace Rat theorem ext : {p q : Rat} → p.num = q.num → p.den = q.den → p = q | ⟨_,_,_,_⟩, ⟨_,_,_,_⟩, rfl, rfl => rfl @[simp] theorem mk_den_one {r : Int} : ⟨r, 1, Nat.one_ne_zero, (Nat.coprime_one_right _)⟩ = (r : Rat) := rfl @[simp] theorem zero_num : (0 : Rat).num = 0 := rfl @[simp] theorem zero_den : (0 : Rat).den = 1 := rfl @[simp] theorem one_num : (1 : Rat).num = 1 := rfl @[simp] theorem one_den : (1 : Rat).den = 1 := rfl @[simp] theorem maybeNormalize_eq {num den g} (den_nz reduced) : maybeNormalize num den g den_nz reduced = { num := num.div g, den := den / g, den_nz, reduced } := by unfold maybeNormalize; split · subst g; simp · rfl theorem normalize.reduced' {num : Int} {den g : Nat} (den_nz : den ≠ 0) (e : g = num.natAbs.gcd den) : (num / g).natAbs.Coprime (den / g) := by rw [← Int.div_eq_ediv_of_dvd (e ▸ Int.ofNat_dvd_left.2 (Nat.gcd_dvd_left ..))] exact normalize.reduced den_nz e theorem normalize_eq {num den} (den_nz) : normalize num den den_nz = { num := num / num.natAbs.gcd den den := den / num.natAbs.gcd den den_nz := normalize.den_nz den_nz rfl reduced := normalize.reduced' den_nz rfl } := by simp only [normalize, maybeNormalize_eq, Int.div_eq_ediv_of_dvd (Int.ofNat_dvd_left.2 (Nat.gcd_dvd_left ..))] @[simp] theorem normalize_zero (nz) : normalize 0 d nz = 0 := by simp [normalize, Int.zero_div, Int.natAbs_zero, Nat.div_self (Nat.pos_of_ne_zero nz)]; rfl theorem mk_eq_normalize (num den nz c) : ⟨num, den, nz, c⟩ = normalize num den nz := by simp [normalize_eq, c.gcd_eq_one] theorem normalize_self (r : Rat) : normalize r.num r.den r.den_nz = r := (mk_eq_normalize ..).symm theorem normalize_mul_left {a : Nat} (d0 : d ≠ 0) (a0 : a ≠ 0) : normalize (↑a * n) (a * d) (Nat.mul_ne_zero a0 d0) = normalize n d d0 := by simp [normalize_eq, mk'.injEq, Int.natAbs_mul, Nat.gcd_mul_left, Nat.mul_div_mul_left _ _ (Nat.pos_of_ne_zero a0), Int.ofNat_mul, Int.mul_ediv_mul_of_pos _ _ (Int.ofNat_pos.2 <| Nat.pos_of_ne_zero a0)] theorem normalize_mul_right {a : Nat} (d0 : d ≠ 0) (a0 : a ≠ 0) : normalize (n * a) (d * a) (Nat.mul_ne_zero d0 a0) = normalize n d d0 := by rw [← normalize_mul_left (d0 := d0) a0]; congr 1 <;> [apply Int.mul_comm; apply Nat.mul_comm] theorem normalize_eq_iff (z₁ : d₁ ≠ 0) (z₂ : d₂ ≠ 0) : normalize n₁ d₁ z₁ = normalize n₂ d₂ z₂ ↔ n₁ * d₂ = n₂ * d₁ := by constructor <;> intro h · simp only [normalize_eq, mk'.injEq] at h have' hn₁ := Int.ofNat_dvd_left.2 <| Nat.gcd_dvd_left n₁.natAbs d₁ have' hn₂ := Int.ofNat_dvd_left.2 <| Nat.gcd_dvd_left n₂.natAbs d₂ have' hd₁ := Int.ofNat_dvd.2 <| Nat.gcd_dvd_right n₁.natAbs d₁ have' hd₂ := Int.ofNat_dvd.2 <| Nat.gcd_dvd_right n₂.natAbs d₂ rw [← Int.ediv_mul_cancel (Int.dvd_trans hd₂ (Int.dvd_mul_left ..)), Int.mul_ediv_assoc _ hd₂, ← Int.ofNat_ediv, ← h.2, Int.ofNat_ediv, ← Int.mul_ediv_assoc _ hd₁, Int.mul_ediv_assoc' _ hn₁, Int.mul_right_comm, h.1, Int.ediv_mul_cancel hn₂] · rw [← normalize_mul_right _ z₂, ← normalize_mul_left z₂ z₁, Int.mul_comm d₁, h] theorem maybeNormalize_eq_normalize {num : Int} {den g : Nat} (den_nz reduced) (hn : ↑g ∣ num) (hd : g ∣ den) : maybeNormalize num den g den_nz reduced = normalize num den (mt (by simp [·]) den_nz) := by simp only [maybeNormalize_eq, mk_eq_normalize, Int.div_eq_ediv_of_dvd hn] have : g ≠ 0 := mt (by simp [·]) den_nz rw [← normalize_mul_right _ this, Int.ediv_mul_cancel hn] congr 1; exact Nat.div_mul_cancel hd @[simp] theorem normalize_eq_zero (d0 : d ≠ 0) : normalize n d d0 = 0 ↔ n = 0 := by have' := normalize_eq_iff d0 Nat.one_ne_zero rw [normalize_zero (d := 1)] at this; rw [this]; simp theorem normalize_num_den' (num den nz) : ∃ d : Nat, d ≠ 0 ∧ num = (normalize num den nz).num * d ∧ den = (normalize num den nz).den * d := by refine ⟨num.natAbs.gcd den, Nat.gcd_ne_zero_right nz, ?_⟩ simp [normalize_eq, Int.ediv_mul_cancel (Int.ofNat_dvd_left.2 <| Nat.gcd_dvd_left ..), Nat.div_mul_cancel (Nat.gcd_dvd_right ..)] theorem normalize_num_den (h : normalize n d z = ⟨n', d', z', c⟩) : ∃ m : Nat, m ≠ 0 ∧ n = n' * m ∧ d = d' * m := by have := normalize_num_den' n d z; rwa [h] at this theorem normalize_eq_mkRat {num den} (den_nz) : normalize num den den_nz = mkRat num den := by simp [mkRat, den_nz] theorem mkRat_num_den (z : d ≠ 0) (h : mkRat n d = ⟨n', d', z', c⟩) : ∃ m : Nat, m ≠ 0 ∧ n = n' * m ∧ d = d' * m := normalize_num_den ((normalize_eq_mkRat z).symm ▸ h) theorem mkRat_def (n d) : mkRat n d = if d0 : d = 0 then 0 else normalize n d d0 := rfl theorem mkRat_self (a : Rat) : mkRat a.num a.den = a := by rw [← normalize_eq_mkRat a.den_nz, normalize_self]
.lake/packages/batteries/Batteries/Data/Rat/Lemmas.lean
110
111
theorem mk_eq_mkRat (num den nz c) : ⟨num, den, nz, c⟩ = mkRat num den := by
simp [mk_eq_normalize, normalize_eq_mkRat]
import Mathlib.Order.Filter.Basic import Mathlib.Topology.Bases import Mathlib.Data.Set.Accumulate import Mathlib.Topology.Bornology.Basic import Mathlib.Topology.LocallyFinite open Set Filter Topology TopologicalSpace Classical Function universe u v variable {X : Type u} {Y : Type v} {ι : Type*} variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X} -- compact sets section Compact lemma IsCompact.exists_clusterPt (hs : IsCompact s) {f : Filter X} [NeBot f] (hf : f ≤ 𝓟 s) : ∃ x ∈ s, ClusterPt x f := hs hf lemma IsCompact.exists_mapClusterPt {ι : Type*} (hs : IsCompact s) {f : Filter ι} [NeBot f] {u : ι → X} (hf : Filter.map u f ≤ 𝓟 s) : ∃ x ∈ s, MapClusterPt x f u := hs hf theorem IsCompact.compl_mem_sets (hs : IsCompact s) {f : Filter X} (hf : ∀ x ∈ s, sᶜ ∈ 𝓝 x ⊓ f) : sᶜ ∈ f := by contrapose! hf simp only [not_mem_iff_inf_principal_compl, compl_compl, inf_assoc] at hf ⊢ exact @hs _ hf inf_le_right #align is_compact.compl_mem_sets IsCompact.compl_mem_sets theorem IsCompact.compl_mem_sets_of_nhdsWithin (hs : IsCompact s) {f : Filter X} (hf : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, tᶜ ∈ f) : sᶜ ∈ f := by refine hs.compl_mem_sets fun x hx => ?_ rcases hf x hx with ⟨t, ht, hst⟩ replace ht := mem_inf_principal.1 ht apply mem_inf_of_inter ht hst rintro x ⟨h₁, h₂⟩ hs exact h₂ (h₁ hs) #align is_compact.compl_mem_sets_of_nhds_within IsCompact.compl_mem_sets_of_nhdsWithin @[elab_as_elim] theorem IsCompact.induction_on (hs : IsCompact s) {p : Set X → Prop} (he : p ∅) (hmono : ∀ ⦃s t⦄, s ⊆ t → p t → p s) (hunion : ∀ ⦃s t⦄, p s → p t → p (s ∪ t)) (hnhds : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, p t) : p s := by let f : Filter X := comk p he (fun _t ht _s hsub ↦ hmono hsub ht) (fun _s hs _t ht ↦ hunion hs ht) have : sᶜ ∈ f := hs.compl_mem_sets_of_nhdsWithin (by simpa [f] using hnhds) rwa [← compl_compl s] #align is_compact.induction_on IsCompact.induction_on theorem IsCompact.inter_right (hs : IsCompact s) (ht : IsClosed t) : IsCompact (s ∩ t) := by intro f hnf hstf obtain ⟨x, hsx, hx⟩ : ∃ x ∈ s, ClusterPt x f := hs (le_trans hstf (le_principal_iff.2 inter_subset_left)) have : x ∈ t := ht.mem_of_nhdsWithin_neBot <| hx.mono <| le_trans hstf (le_principal_iff.2 inter_subset_right) exact ⟨x, ⟨hsx, this⟩, hx⟩ #align is_compact.inter_right IsCompact.inter_right theorem IsCompact.inter_left (ht : IsCompact t) (hs : IsClosed s) : IsCompact (s ∩ t) := inter_comm t s ▸ ht.inter_right hs #align is_compact.inter_left IsCompact.inter_left theorem IsCompact.diff (hs : IsCompact s) (ht : IsOpen t) : IsCompact (s \ t) := hs.inter_right (isClosed_compl_iff.mpr ht) #align is_compact.diff IsCompact.diff theorem IsCompact.of_isClosed_subset (hs : IsCompact s) (ht : IsClosed t) (h : t ⊆ s) : IsCompact t := inter_eq_self_of_subset_right h ▸ hs.inter_right ht #align is_compact_of_is_closed_subset IsCompact.of_isClosed_subset theorem IsCompact.image_of_continuousOn {f : X → Y} (hs : IsCompact s) (hf : ContinuousOn f s) : IsCompact (f '' s) := by intro l lne ls have : NeBot (l.comap f ⊓ 𝓟 s) := comap_inf_principal_neBot_of_image_mem lne (le_principal_iff.1 ls) obtain ⟨x, hxs, hx⟩ : ∃ x ∈ s, ClusterPt x (l.comap f ⊓ 𝓟 s) := @hs _ this inf_le_right haveI := hx.neBot use f x, mem_image_of_mem f hxs have : Tendsto f (𝓝 x ⊓ (comap f l ⊓ 𝓟 s)) (𝓝 (f x) ⊓ l) := by convert (hf x hxs).inf (@tendsto_comap _ _ f l) using 1 rw [nhdsWithin] ac_rfl exact this.neBot #align is_compact.image_of_continuous_on IsCompact.image_of_continuousOn theorem IsCompact.image {f : X → Y} (hs : IsCompact s) (hf : Continuous f) : IsCompact (f '' s) := hs.image_of_continuousOn hf.continuousOn #align is_compact.image IsCompact.image theorem IsCompact.adherence_nhdset {f : Filter X} (hs : IsCompact s) (hf₂ : f ≤ 𝓟 s) (ht₁ : IsOpen t) (ht₂ : ∀ x ∈ s, ClusterPt x f → x ∈ t) : t ∈ f := Classical.by_cases mem_of_eq_bot fun (this : f ⊓ 𝓟 tᶜ ≠ ⊥) => let ⟨x, hx, (hfx : ClusterPt x <| f ⊓ 𝓟 tᶜ)⟩ := @hs _ ⟨this⟩ <| inf_le_of_left_le hf₂ have : x ∈ t := ht₂ x hx hfx.of_inf_left have : tᶜ ∩ t ∈ 𝓝[tᶜ] x := inter_mem_nhdsWithin _ (IsOpen.mem_nhds ht₁ this) have A : 𝓝[tᶜ] x = ⊥ := empty_mem_iff_bot.1 <| compl_inter_self t ▸ this have : 𝓝[tᶜ] x ≠ ⊥ := hfx.of_inf_right.ne absurd A this #align is_compact.adherence_nhdset IsCompact.adherence_nhdset theorem isCompact_iff_ultrafilter_le_nhds : IsCompact s ↔ ∀ f : Ultrafilter X, ↑f ≤ 𝓟 s → ∃ x ∈ s, ↑f ≤ 𝓝 x := by refine (forall_neBot_le_iff ?_).trans ?_ · rintro f g hle ⟨x, hxs, hxf⟩ exact ⟨x, hxs, hxf.mono hle⟩ · simp only [Ultrafilter.clusterPt_iff] #align is_compact_iff_ultrafilter_le_nhds isCompact_iff_ultrafilter_le_nhds alias ⟨IsCompact.ultrafilter_le_nhds, _⟩ := isCompact_iff_ultrafilter_le_nhds #align is_compact.ultrafilter_le_nhds IsCompact.ultrafilter_le_nhds theorem isCompact_iff_ultrafilter_le_nhds' : IsCompact s ↔ ∀ f : Ultrafilter X, s ∈ f → ∃ x ∈ s, ↑f ≤ 𝓝 x := by simp only [isCompact_iff_ultrafilter_le_nhds, le_principal_iff, Ultrafilter.mem_coe] alias ⟨IsCompact.ultrafilter_le_nhds', _⟩ := isCompact_iff_ultrafilter_le_nhds' lemma IsCompact.le_nhds_of_unique_clusterPt (hs : IsCompact s) {l : Filter X} {y : X} (hmem : s ∈ l) (h : ∀ x ∈ s, ClusterPt x l → x = y) : l ≤ 𝓝 y := by refine le_iff_ultrafilter.2 fun f hf ↦ ?_ rcases hs.ultrafilter_le_nhds' f (hf hmem) with ⟨x, hxs, hx⟩ convert ← hx exact h x hxs (.mono (.of_le_nhds hx) hf) lemma IsCompact.tendsto_nhds_of_unique_mapClusterPt {l : Filter Y} {y : X} {f : Y → X} (hs : IsCompact s) (hmem : ∀ᶠ x in l, f x ∈ s) (h : ∀ x ∈ s, MapClusterPt x l f → x = y) : Tendsto f l (𝓝 y) := hs.le_nhds_of_unique_clusterPt (mem_map.2 hmem) h theorem IsCompact.elim_directed_cover {ι : Type v} [hι : Nonempty ι] (hs : IsCompact s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) (hsU : s ⊆ ⋃ i, U i) (hdU : Directed (· ⊆ ·) U) : ∃ i, s ⊆ U i := hι.elim fun i₀ => IsCompact.induction_on hs ⟨i₀, empty_subset _⟩ (fun _ _ hs ⟨i, hi⟩ => ⟨i, hs.trans hi⟩) (fun _ _ ⟨i, hi⟩ ⟨j, hj⟩ => let ⟨k, hki, hkj⟩ := hdU i j ⟨k, union_subset (Subset.trans hi hki) (Subset.trans hj hkj)⟩) fun _x hx => let ⟨i, hi⟩ := mem_iUnion.1 (hsU hx) ⟨U i, mem_nhdsWithin_of_mem_nhds (IsOpen.mem_nhds (hUo i) hi), i, Subset.refl _⟩ #align is_compact.elim_directed_cover IsCompact.elim_directed_cover theorem IsCompact.elim_finite_subcover {ι : Type v} (hs : IsCompact s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) (hsU : s ⊆ ⋃ i, U i) : ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i := hs.elim_directed_cover _ (fun _ => isOpen_biUnion fun i _ => hUo i) (iUnion_eq_iUnion_finset U ▸ hsU) (directed_of_isDirected_le fun _ _ h => biUnion_subset_biUnion_left h) #align is_compact.elim_finite_subcover IsCompact.elim_finite_subcover lemma IsCompact.elim_nhds_subcover_nhdsSet' (hs : IsCompact s) (U : ∀ x ∈ s, Set X) (hU : ∀ x hx, U x hx ∈ 𝓝 x) : ∃ t : Finset s, (⋃ x ∈ t, U x.1 x.2) ∈ 𝓝ˢ s := by rcases hs.elim_finite_subcover (fun x : s ↦ interior (U x x.2)) (fun _ ↦ isOpen_interior) fun x hx ↦ mem_iUnion.2 ⟨⟨x, hx⟩, mem_interior_iff_mem_nhds.2 <| hU _ _⟩ with ⟨t, hst⟩ refine ⟨t, mem_nhdsSet_iff_forall.2 fun x hx ↦ ?_⟩ rcases mem_iUnion₂.1 (hst hx) with ⟨y, hyt, hy⟩ refine mem_of_superset ?_ (subset_biUnion_of_mem hyt) exact mem_interior_iff_mem_nhds.1 hy lemma IsCompact.elim_nhds_subcover_nhdsSet (hs : IsCompact s) {U : X → Set X} (hU : ∀ x ∈ s, U x ∈ 𝓝 x) : ∃ t : Finset X, (∀ x ∈ t, x ∈ s) ∧ (⋃ x ∈ t, U x) ∈ 𝓝ˢ s := let ⟨t, ht⟩ := hs.elim_nhds_subcover_nhdsSet' (fun x _ => U x) hU ⟨t.image (↑), fun x hx => let ⟨y, _, hyx⟩ := Finset.mem_image.1 hx hyx ▸ y.2, by rwa [Finset.set_biUnion_finset_image]⟩ theorem IsCompact.elim_nhds_subcover' (hs : IsCompact s) (U : ∀ x ∈ s, Set X) (hU : ∀ x (hx : x ∈ s), U x ‹x ∈ s› ∈ 𝓝 x) : ∃ t : Finset s, s ⊆ ⋃ x ∈ t, U (x : s) x.2 := (hs.elim_nhds_subcover_nhdsSet' U hU).imp fun _ ↦ subset_of_mem_nhdsSet #align is_compact.elim_nhds_subcover' IsCompact.elim_nhds_subcover' theorem IsCompact.elim_nhds_subcover (hs : IsCompact s) (U : X → Set X) (hU : ∀ x ∈ s, U x ∈ 𝓝 x) : ∃ t : Finset X, (∀ x ∈ t, x ∈ s) ∧ s ⊆ ⋃ x ∈ t, U x := (hs.elim_nhds_subcover_nhdsSet hU).imp fun _ h ↦ h.imp_right subset_of_mem_nhdsSet #align is_compact.elim_nhds_subcover IsCompact.elim_nhds_subcover theorem IsCompact.disjoint_nhdsSet_left {l : Filter X} (hs : IsCompact s) : Disjoint (𝓝ˢ s) l ↔ ∀ x ∈ s, Disjoint (𝓝 x) l := by refine ⟨fun h x hx => h.mono_left <| nhds_le_nhdsSet hx, fun H => ?_⟩ choose! U hxU hUl using fun x hx => (nhds_basis_opens x).disjoint_iff_left.1 (H x hx) choose hxU hUo using hxU rcases hs.elim_nhds_subcover U fun x hx => (hUo x hx).mem_nhds (hxU x hx) with ⟨t, hts, hst⟩ refine (hasBasis_nhdsSet _).disjoint_iff_left.2 ⟨⋃ x ∈ t, U x, ⟨isOpen_biUnion fun x hx => hUo x (hts x hx), hst⟩, ?_⟩ rw [compl_iUnion₂, biInter_finset_mem] exact fun x hx => hUl x (hts x hx) #align is_compact.disjoint_nhds_set_left IsCompact.disjoint_nhdsSet_left theorem IsCompact.disjoint_nhdsSet_right {l : Filter X} (hs : IsCompact s) : Disjoint l (𝓝ˢ s) ↔ ∀ x ∈ s, Disjoint l (𝓝 x) := by simpa only [disjoint_comm] using hs.disjoint_nhdsSet_left #align is_compact.disjoint_nhds_set_right IsCompact.disjoint_nhdsSet_right -- Porting note (#11215): TODO: reformulate using `Disjoint` theorem IsCompact.elim_directed_family_closed {ι : Type v} [hι : Nonempty ι] (hs : IsCompact s) (t : ι → Set X) (htc : ∀ i, IsClosed (t i)) (hst : (s ∩ ⋂ i, t i) = ∅) (hdt : Directed (· ⊇ ·) t) : ∃ i : ι, s ∩ t i = ∅ := let ⟨t, ht⟩ := hs.elim_directed_cover (compl ∘ t) (fun i => (htc i).isOpen_compl) (by simpa only [subset_def, not_forall, eq_empty_iff_forall_not_mem, mem_iUnion, exists_prop, mem_inter_iff, not_and, iff_self_iff, mem_iInter, mem_compl_iff] using hst) (hdt.mono_comp _ fun _ _ => compl_subset_compl.mpr) ⟨t, by simpa only [subset_def, not_forall, eq_empty_iff_forall_not_mem, mem_iUnion, exists_prop, mem_inter_iff, not_and, iff_self_iff, mem_iInter, mem_compl_iff] using ht⟩ #align is_compact.elim_directed_family_closed IsCompact.elim_directed_family_closed -- Porting note (#11215): TODO: reformulate using `Disjoint` theorem IsCompact.elim_finite_subfamily_closed {ι : Type v} (hs : IsCompact s) (t : ι → Set X) (htc : ∀ i, IsClosed (t i)) (hst : (s ∩ ⋂ i, t i) = ∅) : ∃ u : Finset ι, (s ∩ ⋂ i ∈ u, t i) = ∅ := hs.elim_directed_family_closed _ (fun t ↦ isClosed_biInter fun _ _ ↦ htc _) (by rwa [← iInter_eq_iInter_finset]) (directed_of_isDirected_le fun _ _ h ↦ biInter_subset_biInter_left h) #align is_compact.elim_finite_subfamily_closed IsCompact.elim_finite_subfamily_closed theorem LocallyFinite.finite_nonempty_inter_compact {f : ι → Set X} (hf : LocallyFinite f) (hs : IsCompact s) : { i | (f i ∩ s).Nonempty }.Finite := by choose U hxU hUf using hf rcases hs.elim_nhds_subcover U fun x _ => hxU x with ⟨t, -, hsU⟩ refine (t.finite_toSet.biUnion fun x _ => hUf x).subset ?_ rintro i ⟨x, hx⟩ rcases mem_iUnion₂.1 (hsU hx.2) with ⟨c, hct, hcx⟩ exact mem_biUnion hct ⟨x, hx.1, hcx⟩ #align locally_finite.finite_nonempty_inter_compact LocallyFinite.finite_nonempty_inter_compact theorem IsCompact.inter_iInter_nonempty {ι : Type v} (hs : IsCompact s) (t : ι → Set X) (htc : ∀ i, IsClosed (t i)) (hst : ∀ u : Finset ι, (s ∩ ⋂ i ∈ u, t i).Nonempty) : (s ∩ ⋂ i, t i).Nonempty := by contrapose! hst exact hs.elim_finite_subfamily_closed t htc hst #align is_compact.inter_Inter_nonempty IsCompact.inter_iInter_nonempty theorem IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed {ι : Type v} [hι : Nonempty ι] (t : ι → Set X) (htd : Directed (· ⊇ ·) t) (htn : ∀ i, (t i).Nonempty) (htc : ∀ i, IsCompact (t i)) (htcl : ∀ i, IsClosed (t i)) : (⋂ i, t i).Nonempty := by let i₀ := hι.some suffices (t i₀ ∩ ⋂ i, t i).Nonempty by rwa [inter_eq_right.mpr (iInter_subset _ i₀)] at this simp only [nonempty_iff_ne_empty] at htn ⊢ apply mt ((htc i₀).elim_directed_family_closed t htcl) push_neg simp only [← nonempty_iff_ne_empty] at htn ⊢ refine ⟨htd, fun i => ?_⟩ rcases htd i₀ i with ⟨j, hji₀, hji⟩ exact (htn j).mono (subset_inter hji₀ hji) #align is_compact.nonempty_Inter_of_directed_nonempty_compact_closed IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed @[deprecated (since := "2024-02-28")] alias IsCompact.nonempty_iInter_of_directed_nonempty_compact_closed := IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed theorem IsCompact.nonempty_sInter_of_directed_nonempty_isCompact_isClosed {S : Set (Set X)} [hS : Nonempty S] (hSd : DirectedOn (· ⊇ ·) S) (hSn : ∀ U ∈ S, U.Nonempty) (hSc : ∀ U ∈ S, IsCompact U) (hScl : ∀ U ∈ S, IsClosed U) : (⋂₀ S).Nonempty := by rw [sInter_eq_iInter] exact IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed _ (DirectedOn.directed_val hSd) (fun i ↦ hSn i i.2) (fun i ↦ hSc i i.2) (fun i ↦ hScl i i.2) theorem IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed (t : ℕ → Set X) (htd : ∀ i, t (i + 1) ⊆ t i) (htn : ∀ i, (t i).Nonempty) (ht0 : IsCompact (t 0)) (htcl : ∀ i, IsClosed (t i)) : (⋂ i, t i).Nonempty := have tmono : Antitone t := antitone_nat_of_succ_le htd have htd : Directed (· ⊇ ·) t := tmono.directed_ge have : ∀ i, t i ⊆ t 0 := fun i => tmono <| zero_le i have htc : ∀ i, IsCompact (t i) := fun i => ht0.of_isClosed_subset (htcl i) (this i) IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed t htd htn htc htcl #align is_compact.nonempty_Inter_of_sequence_nonempty_compact_closed IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed @[deprecated (since := "2024-02-28")] alias IsCompact.nonempty_iInter_of_sequence_nonempty_compact_closed := IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed theorem IsCompact.elim_finite_subcover_image {b : Set ι} {c : ι → Set X} (hs : IsCompact s) (hc₁ : ∀ i ∈ b, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i ∈ b, c i) : ∃ b', b' ⊆ b ∧ Set.Finite b' ∧ s ⊆ ⋃ i ∈ b', c i := by simp only [Subtype.forall', biUnion_eq_iUnion] at hc₁ hc₂ rcases hs.elim_finite_subcover (fun i => c i : b → Set X) hc₁ hc₂ with ⟨d, hd⟩ refine ⟨Subtype.val '' d.toSet, ?_, d.finite_toSet.image _, ?_⟩ · simp · rwa [biUnion_image] #align is_compact.elim_finite_subcover_image IsCompact.elim_finite_subcover_imageₓ theorem isCompact_of_finite_subcover (h : ∀ {ι : Type u} (U : ι → Set X), (∀ i, IsOpen (U i)) → (s ⊆ ⋃ i, U i) → ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i) : IsCompact s := fun f hf hfs => by contrapose! h simp only [ClusterPt, not_neBot, ← disjoint_iff, SetCoe.forall', (nhds_basis_opens _).disjoint_iff_left] at h choose U hU hUf using h refine ⟨s, U, fun x => (hU x).2, fun x hx => mem_iUnion.2 ⟨⟨x, hx⟩, (hU _).1⟩, fun t ht => ?_⟩ refine compl_not_mem (le_principal_iff.1 hfs) ?_ refine mem_of_superset ((biInter_finset_mem t).2 fun x _ => hUf x) ?_ rw [subset_compl_comm, compl_iInter₂] simpa only [compl_compl] #align is_compact_of_finite_subcover isCompact_of_finite_subcover -- Porting note (#11215): TODO: reformulate using `Disjoint` theorem isCompact_of_finite_subfamily_closed (h : ∀ {ι : Type u} (t : ι → Set X), (∀ i, IsClosed (t i)) → (s ∩ ⋂ i, t i) = ∅ → ∃ u : Finset ι, (s ∩ ⋂ i ∈ u, t i) = ∅) : IsCompact s := isCompact_of_finite_subcover fun U hUo hsU => by rw [← disjoint_compl_right_iff_subset, compl_iUnion, disjoint_iff] at hsU rcases h (fun i => (U i)ᶜ) (fun i => (hUo _).isClosed_compl) hsU with ⟨t, ht⟩ refine ⟨t, ?_⟩ rwa [← disjoint_compl_right_iff_subset, compl_iUnion₂, disjoint_iff] #align is_compact_of_finite_subfamily_closed isCompact_of_finite_subfamily_closed theorem isCompact_iff_finite_subcover : IsCompact s ↔ ∀ {ι : Type u} (U : ι → Set X), (∀ i, IsOpen (U i)) → (s ⊆ ⋃ i, U i) → ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i := ⟨fun hs => hs.elim_finite_subcover, isCompact_of_finite_subcover⟩ #align is_compact_iff_finite_subcover isCompact_iff_finite_subcover theorem isCompact_iff_finite_subfamily_closed : IsCompact s ↔ ∀ {ι : Type u} (t : ι → Set X), (∀ i, IsClosed (t i)) → (s ∩ ⋂ i, t i) = ∅ → ∃ u : Finset ι, (s ∩ ⋂ i ∈ u, t i) = ∅ := ⟨fun hs => hs.elim_finite_subfamily_closed, isCompact_of_finite_subfamily_closed⟩ #align is_compact_iff_finite_subfamily_closed isCompact_iff_finite_subfamily_closed theorem IsCompact.mem_nhdsSet_prod_of_forall {K : Set X} {l : Filter Y} {s : Set (X × Y)} (hK : IsCompact K) (hs : ∀ x ∈ K, s ∈ 𝓝 x ×ˢ l) : s ∈ (𝓝ˢ K) ×ˢ l := by refine hK.induction_on (by simp) (fun t t' ht hs ↦ ?_) (fun t t' ht ht' ↦ ?_) fun x hx ↦ ?_ · exact prod_mono (nhdsSet_mono ht) le_rfl hs · simp [sup_prod, *] · rcases ((nhds_basis_opens _).prod l.basis_sets).mem_iff.1 (hs x hx) with ⟨⟨u, v⟩, ⟨⟨hx, huo⟩, hv⟩, hs⟩ refine ⟨u, nhdsWithin_le_nhds (huo.mem_nhds hx), mem_of_superset ?_ hs⟩ exact prod_mem_prod (huo.mem_nhdsSet.2 Subset.rfl) hv theorem IsCompact.nhdsSet_prod_eq_biSup {K : Set X} (hK : IsCompact K) (l : Filter Y) : (𝓝ˢ K) ×ˢ l = ⨆ x ∈ K, 𝓝 x ×ˢ l := le_antisymm (fun s hs ↦ hK.mem_nhdsSet_prod_of_forall <| by simpa using hs) (iSup₂_le fun x hx ↦ prod_mono (nhds_le_nhdsSet hx) le_rfl) theorem IsCompact.prod_nhdsSet_eq_biSup {K : Set Y} (hK : IsCompact K) (l : Filter X) : l ×ˢ (𝓝ˢ K) = ⨆ y ∈ K, l ×ˢ 𝓝 y := by simp only [prod_comm (f := l), hK.nhdsSet_prod_eq_biSup, map_iSup] theorem IsCompact.mem_prod_nhdsSet_of_forall {K : Set Y} {l : Filter X} {s : Set (X × Y)} (hK : IsCompact K) (hs : ∀ y ∈ K, s ∈ l ×ˢ 𝓝 y) : s ∈ l ×ˢ 𝓝ˢ K := (hK.prod_nhdsSet_eq_biSup l).symm ▸ by simpa using hs -- TODO: Is there a way to prove directly the `inf` version and then deduce the `Prod` one ? -- That would seem a bit more natural. theorem IsCompact.nhdsSet_inf_eq_biSup {K : Set X} (hK : IsCompact K) (l : Filter X) : (𝓝ˢ K) ⊓ l = ⨆ x ∈ K, 𝓝 x ⊓ l := by have : ∀ f : Filter X, f ⊓ l = comap (fun x ↦ (x, x)) (f ×ˢ l) := fun f ↦ by simpa only [comap_prod] using congrArg₂ (· ⊓ ·) comap_id.symm comap_id.symm simp_rw [this, ← comap_iSup, hK.nhdsSet_prod_eq_biSup]
Mathlib/Topology/Compactness/Compact.lean
430
432
theorem IsCompact.inf_nhdsSet_eq_biSup {K : Set X} (hK : IsCompact K) (l : Filter X) : l ⊓ (𝓝ˢ K) = ⨆ x ∈ K, l ⊓ 𝓝 x := by
simp only [inf_comm l, hK.nhdsSet_inf_eq_biSup]
import Mathlib.RingTheory.IntegrallyClosed import Mathlib.RingTheory.Trace import Mathlib.RingTheory.Norm #align_import ring_theory.discriminant from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" universe u v w z open scoped Matrix open Matrix FiniteDimensional Fintype Polynomial Finset IntermediateField namespace Algebra variable (A : Type u) {B : Type v} (C : Type z) {ι : Type w} [DecidableEq ι] variable [CommRing A] [CommRing B] [Algebra A B] [CommRing C] [Algebra A C] section Discr -- Porting note: using `[DecidableEq ι]` instead of `by classical...` did not work in -- mathlib3. noncomputable def discr (A : Type u) {B : Type v} [CommRing A] [CommRing B] [Algebra A B] [Fintype ι] (b : ι → B) := (traceMatrix A b).det #align algebra.discr Algebra.discr theorem discr_def [Fintype ι] (b : ι → B) : discr A b = (traceMatrix A b).det := rfl variable {A C} in theorem discr_eq_discr_of_algEquiv [Fintype ι] (b : ι → B) (f : B ≃ₐ[A] C) : Algebra.discr A b = Algebra.discr A (f ∘ b) := by rw [discr_def]; congr; ext simp_rw [traceMatrix_apply, traceForm_apply, Function.comp, ← map_mul f, trace_eq_of_algEquiv] #align algebra.discr_def Algebra.discr_def variable {ι' : Type*} [Fintype ι'] [Fintype ι] [DecidableEq ι'] section Basic @[simp] theorem discr_reindex (b : Basis ι A B) (f : ι ≃ ι') : discr A (b ∘ ⇑f.symm) = discr A b := by classical rw [← Basis.coe_reindex, discr_def, traceMatrix_reindex, det_reindex_self, ← discr_def] #align algebra.discr_reindex Algebra.discr_reindex theorem discr_zero_of_not_linearIndependent [IsDomain A] {b : ι → B} (hli : ¬LinearIndependent A b) : discr A b = 0 := by classical obtain ⟨g, hg, i, hi⟩ := Fintype.not_linearIndependent_iff.1 hli have : (traceMatrix A b) *ᵥ g = 0 := by ext i have : ∀ j, (trace A B) (b i * b j) * g j = (trace A B) (g j • b j * b i) := by intro j; simp [mul_comm] simp only [mulVec, dotProduct, traceMatrix_apply, Pi.zero_apply, traceForm_apply, fun j => this j, ← map_sum, ← sum_mul, hg, zero_mul, LinearMap.map_zero] by_contra h rw [discr_def] at h simp [Matrix.eq_zero_of_mulVec_eq_zero h this] at hi #align algebra.discr_zero_of_not_linear_independent Algebra.discr_zero_of_not_linearIndependent variable {A}
Mathlib/RingTheory/Discriminant.lean
113
116
theorem discr_of_matrix_vecMul (b : ι → B) (P : Matrix ι ι A) : discr A (b ᵥ* P.map (algebraMap A B)) = P.det ^ 2 * discr A b := by
rw [discr_def, traceMatrix_of_matrix_vecMul, det_mul, det_mul, det_transpose, mul_comm, ← mul_assoc, discr_def, pow_two]
import Batteries.Data.List.Count import Batteries.Data.Fin.Lemmas open Nat Function namespace List theorem rel_of_pairwise_cons (p : (a :: l).Pairwise R) : ∀ {a'}, a' ∈ l → R a a' := (pairwise_cons.1 p).1 _ theorem Pairwise.of_cons (p : (a :: l).Pairwise R) : Pairwise R l := (pairwise_cons.1 p).2 theorem Pairwise.tail : ∀ {l : List α} (_p : Pairwise R l), Pairwise R l.tail | [], h => h | _ :: _, h => h.of_cons theorem Pairwise.drop : ∀ {l : List α} {n : Nat}, List.Pairwise R l → List.Pairwise R (l.drop n) | _, 0, h => h | [], _ + 1, _ => List.Pairwise.nil | _ :: _, n + 1, h => Pairwise.drop (n := n) (pairwise_cons.mp h).right theorem Pairwise.imp_of_mem {S : α → α → Prop} (H : ∀ {a b}, a ∈ l → b ∈ l → R a b → S a b) (p : Pairwise R l) : Pairwise S l := by induction p with | nil => constructor | @cons a l r _ ih => constructor · exact fun x h => H (mem_cons_self ..) (mem_cons_of_mem _ h) <| r x h · exact ih fun m m' => H (mem_cons_of_mem _ m) (mem_cons_of_mem _ m') theorem Pairwise.and (hR : Pairwise R l) (hS : Pairwise S l) : l.Pairwise fun a b => R a b ∧ S a b := by induction hR with | nil => simp only [Pairwise.nil] | cons R1 _ IH => simp only [Pairwise.nil, pairwise_cons] at hS ⊢ exact ⟨fun b bl => ⟨R1 b bl, hS.1 b bl⟩, IH hS.2⟩ theorem pairwise_and_iff : l.Pairwise (fun a b => R a b ∧ S a b) ↔ Pairwise R l ∧ Pairwise S l := ⟨fun h => ⟨h.imp fun h => h.1, h.imp fun h => h.2⟩, fun ⟨hR, hS⟩ => hR.and hS⟩ theorem Pairwise.imp₂ (H : ∀ a b, R a b → S a b → T a b) (hR : Pairwise R l) (hS : l.Pairwise S) : l.Pairwise T := (hR.and hS).imp fun ⟨h₁, h₂⟩ => H _ _ h₁ h₂ theorem Pairwise.iff_of_mem {S : α → α → Prop} {l : List α} (H : ∀ {a b}, a ∈ l → b ∈ l → (R a b ↔ S a b)) : Pairwise R l ↔ Pairwise S l := ⟨Pairwise.imp_of_mem fun m m' => (H m m').1, Pairwise.imp_of_mem fun m m' => (H m m').2⟩ theorem Pairwise.iff {S : α → α → Prop} (H : ∀ a b, R a b ↔ S a b) {l : List α} : Pairwise R l ↔ Pairwise S l := Pairwise.iff_of_mem fun _ _ => H .. theorem pairwise_of_forall {l : List α} (H : ∀ x y, R x y) : Pairwise R l := by induction l <;> simp [*] theorem Pairwise.and_mem {l : List α} : Pairwise R l ↔ Pairwise (fun x y => x ∈ l ∧ y ∈ l ∧ R x y) l := Pairwise.iff_of_mem <| by simp (config := { contextual := true }) theorem Pairwise.imp_mem {l : List α} : Pairwise R l ↔ Pairwise (fun x y => x ∈ l → y ∈ l → R x y) l := Pairwise.iff_of_mem <| by simp (config := { contextual := true }) theorem Pairwise.forall_of_forall_of_flip (h₁ : ∀ x ∈ l, R x x) (h₂ : Pairwise R l) (h₃ : l.Pairwise (flip R)) : ∀ ⦃x⦄, x ∈ l → ∀ ⦃y⦄, y ∈ l → R x y := by induction l with | nil => exact forall_mem_nil _ | cons a l ih => rw [pairwise_cons] at h₂ h₃ simp only [mem_cons] rintro x (rfl | hx) y (rfl | hy) · exact h₁ _ (l.mem_cons_self _) · exact h₂.1 _ hy · exact h₃.1 _ hx · exact ih (fun x hx => h₁ _ <| mem_cons_of_mem _ hx) h₂.2 h₃.2 hx hy theorem pairwise_singleton (R) (a : α) : Pairwise R [a] := by simp theorem pairwise_pair {a b : α} : Pairwise R [a, b] ↔ R a b := by simp
.lake/packages/batteries/Batteries/Data/List/Pairwise.lean
108
112
theorem pairwise_append_comm {R : α → α → Prop} (s : ∀ {x y}, R x y → R y x) {l₁ l₂ : List α} : Pairwise R (l₁ ++ l₂) ↔ Pairwise R (l₂ ++ l₁) := by
have (l₁ l₂ : List α) (H : ∀ x : α, x ∈ l₁ → ∀ y : α, y ∈ l₂ → R x y) (x : α) (xm : x ∈ l₂) (y : α) (ym : y ∈ l₁) : R x y := s (H y ym x xm) simp only [pairwise_append, and_left_comm]; rw [Iff.intro (this l₁ l₂) (this l₂ l₁)]
import Mathlib.Topology.MetricSpace.ProperSpace import Mathlib.Topology.MetricSpace.Cauchy open Set Filter Bornology open scoped ENNReal Uniformity Topology Pointwise universe u v w variable {α : Type u} {β : Type v} {X ι : Type*} variable [PseudoMetricSpace α] namespace Metric #align metric.bounded Bornology.IsBounded section Bounded variable {x : α} {s t : Set α} {r : ℝ} #noalign metric.bounded_iff_is_bounded #align metric.bounded_empty Bornology.isBounded_empty #align metric.bounded_iff_mem_bounded Bornology.isBounded_iff_forall_mem #align metric.bounded.mono Bornology.IsBounded.subset theorem isBounded_closedBall : IsBounded (closedBall x r) := isBounded_iff.2 ⟨r + r, fun y hy z hz => calc dist y z ≤ dist y x + dist z x := dist_triangle_right _ _ _ _ ≤ r + r := add_le_add hy hz⟩ #align metric.bounded_closed_ball Metric.isBounded_closedBall theorem isBounded_ball : IsBounded (ball x r) := isBounded_closedBall.subset ball_subset_closedBall #align metric.bounded_ball Metric.isBounded_ball theorem isBounded_sphere : IsBounded (sphere x r) := isBounded_closedBall.subset sphere_subset_closedBall #align metric.bounded_sphere Metric.isBounded_sphere theorem isBounded_iff_subset_closedBall (c : α) : IsBounded s ↔ ∃ r, s ⊆ closedBall c r := ⟨fun h ↦ (isBounded_iff.1 (h.insert c)).imp fun _r hr _x hx ↦ hr (.inr hx) (mem_insert _ _), fun ⟨_r, hr⟩ ↦ isBounded_closedBall.subset hr⟩ #align metric.bounded_iff_subset_ball Metric.isBounded_iff_subset_closedBall theorem _root_.Bornology.IsBounded.subset_closedBall (h : IsBounded s) (c : α) : ∃ r, s ⊆ closedBall c r := (isBounded_iff_subset_closedBall c).1 h #align metric.bounded.subset_ball Bornology.IsBounded.subset_closedBall theorem _root_.Bornology.IsBounded.subset_ball_lt (h : IsBounded s) (a : ℝ) (c : α) : ∃ r, a < r ∧ s ⊆ ball c r := let ⟨r, hr⟩ := h.subset_closedBall c ⟨max r a + 1, (le_max_right _ _).trans_lt (lt_add_one _), hr.trans <| closedBall_subset_ball <| (le_max_left _ _).trans_lt (lt_add_one _)⟩ theorem _root_.Bornology.IsBounded.subset_ball (h : IsBounded s) (c : α) : ∃ r, s ⊆ ball c r := (h.subset_ball_lt 0 c).imp fun _ ↦ And.right theorem isBounded_iff_subset_ball (c : α) : IsBounded s ↔ ∃ r, s ⊆ ball c r := ⟨(IsBounded.subset_ball · c), fun ⟨_r, hr⟩ ↦ isBounded_ball.subset hr⟩ theorem _root_.Bornology.IsBounded.subset_closedBall_lt (h : IsBounded s) (a : ℝ) (c : α) : ∃ r, a < r ∧ s ⊆ closedBall c r := let ⟨r, har, hr⟩ := h.subset_ball_lt a c ⟨r, har, hr.trans ball_subset_closedBall⟩ #align metric.bounded.subset_ball_lt Bornology.IsBounded.subset_closedBall_lt theorem isBounded_closure_of_isBounded (h : IsBounded s) : IsBounded (closure s) := let ⟨C, h⟩ := isBounded_iff.1 h isBounded_iff.2 ⟨C, fun _a ha _b hb => isClosed_Iic.closure_subset <| map_mem_closure₂ continuous_dist ha hb h⟩ #align metric.bounded_closure_of_bounded Metric.isBounded_closure_of_isBounded protected theorem _root_.Bornology.IsBounded.closure (h : IsBounded s) : IsBounded (closure s) := isBounded_closure_of_isBounded h #align metric.bounded.closure Bornology.IsBounded.closure @[simp] theorem isBounded_closure_iff : IsBounded (closure s) ↔ IsBounded s := ⟨fun h => h.subset subset_closure, fun h => h.closure⟩ #align metric.bounded_closure_iff Metric.isBounded_closure_iff #align metric.bounded_union Bornology.isBounded_union #align metric.bounded.union Bornology.IsBounded.union #align metric.bounded_bUnion Bornology.isBounded_biUnion #align metric.bounded.prod Bornology.IsBounded.prod theorem hasBasis_cobounded_compl_closedBall (c : α) : (cobounded α).HasBasis (fun _ ↦ True) (fun r ↦ (closedBall c r)ᶜ) := ⟨compl_surjective.forall.2 fun _ ↦ (isBounded_iff_subset_closedBall c).trans <| by simp⟩ theorem hasBasis_cobounded_compl_ball (c : α) : (cobounded α).HasBasis (fun _ ↦ True) (fun r ↦ (ball c r)ᶜ) := ⟨compl_surjective.forall.2 fun _ ↦ (isBounded_iff_subset_ball c).trans <| by simp⟩ @[simp] theorem comap_dist_right_atTop (c : α) : comap (dist · c) atTop = cobounded α := (atTop_basis.comap _).eq_of_same_basis <| by simpa only [compl_def, mem_ball, not_lt] using hasBasis_cobounded_compl_ball c @[simp] theorem comap_dist_left_atTop (c : α) : comap (dist c) atTop = cobounded α := by simpa only [dist_comm _ c] using comap_dist_right_atTop c @[simp] theorem tendsto_dist_right_atTop_iff (c : α) {f : β → α} {l : Filter β} : Tendsto (fun x ↦ dist (f x) c) l atTop ↔ Tendsto f l (cobounded α) := by rw [← comap_dist_right_atTop c, tendsto_comap_iff, Function.comp_def] @[simp] theorem tendsto_dist_left_atTop_iff (c : α) {f : β → α} {l : Filter β} : Tendsto (fun x ↦ dist c (f x)) l atTop ↔ Tendsto f l (cobounded α) := by simp only [dist_comm c, tendsto_dist_right_atTop_iff] theorem tendsto_dist_right_cobounded_atTop (c : α) : Tendsto (dist · c) (cobounded α) atTop := tendsto_iff_comap.2 (comap_dist_right_atTop c).ge theorem tendsto_dist_left_cobounded_atTop (c : α) : Tendsto (dist c) (cobounded α) atTop := tendsto_iff_comap.2 (comap_dist_left_atTop c).ge theorem _root_.TotallyBounded.isBounded {s : Set α} (h : TotallyBounded s) : IsBounded s := -- We cover the totally bounded set by finitely many balls of radius 1, -- and then argue that a finite union of bounded sets is bounded let ⟨_t, fint, subs⟩ := (totallyBounded_iff.mp h) 1 zero_lt_one ((isBounded_biUnion fint).2 fun _ _ => isBounded_ball).subset subs #align totally_bounded.bounded TotallyBounded.isBounded theorem _root_.IsCompact.isBounded {s : Set α} (h : IsCompact s) : IsBounded s := -- A compact set is totally bounded, thus bounded h.totallyBounded.isBounded #align is_compact.bounded IsCompact.isBounded #align metric.bounded_of_finite Set.Finite.isBounded #align set.finite.bounded Set.Finite.isBounded #align metric.bounded_singleton Bornology.isBounded_singleton theorem cobounded_le_cocompact : cobounded α ≤ cocompact α := hasBasis_cocompact.ge_iff.2 fun _s hs ↦ hs.isBounded #align comap_dist_right_at_top_le_cocompact Metric.cobounded_le_cocompactₓ #align comap_dist_left_at_top_le_cocompact Metric.cobounded_le_cocompactₓ theorem isCobounded_iff_closedBall_compl_subset {s : Set α} (c : α) : IsCobounded s ↔ ∃ (r : ℝ), (Metric.closedBall c r)ᶜ ⊆ s := by rw [← isBounded_compl_iff, isBounded_iff_subset_closedBall c] apply exists_congr intro r rw [compl_subset_comm] theorem _root_.Bornology.IsCobounded.closedBall_compl_subset {s : Set α} (hs : IsCobounded s) (c : α) : ∃ (r : ℝ), (Metric.closedBall c r)ᶜ ⊆ s := (isCobounded_iff_closedBall_compl_subset c).mp hs theorem closedBall_compl_subset_of_mem_cocompact {s : Set α} (hs : s ∈ cocompact α) (c : α) : ∃ (r : ℝ), (Metric.closedBall c r)ᶜ ⊆ s := IsCobounded.closedBall_compl_subset (cobounded_le_cocompact hs) c theorem mem_cocompact_of_closedBall_compl_subset [ProperSpace α] (c : α) (h : ∃ r, (closedBall c r)ᶜ ⊆ s) : s ∈ cocompact α := by rcases h with ⟨r, h⟩ rw [Filter.mem_cocompact] exact ⟨closedBall c r, isCompact_closedBall c r, h⟩ theorem mem_cocompact_iff_closedBall_compl_subset [ProperSpace α] (c : α) : s ∈ cocompact α ↔ ∃ r, (closedBall c r)ᶜ ⊆ s := ⟨(closedBall_compl_subset_of_mem_cocompact · _), mem_cocompact_of_closedBall_compl_subset _⟩ theorem isBounded_range_iff {f : β → α} : IsBounded (range f) ↔ ∃ C, ∀ x y, dist (f x) (f y) ≤ C := isBounded_iff.trans <| by simp only [forall_mem_range] #align metric.bounded_range_iff Metric.isBounded_range_iff theorem isBounded_image_iff {f : β → α} {s : Set β} : IsBounded (f '' s) ↔ ∃ C, ∀ x ∈ s, ∀ y ∈ s, dist (f x) (f y) ≤ C := isBounded_iff.trans <| by simp only [forall_mem_image] theorem isBounded_range_of_tendsto_cofinite_uniformity {f : β → α} (hf : Tendsto (Prod.map f f) (.cofinite ×ˢ .cofinite) (𝓤 α)) : IsBounded (range f) := by rcases (hasBasis_cofinite.prod_self.tendsto_iff uniformity_basis_dist).1 hf 1 zero_lt_one with ⟨s, hsf, hs1⟩ rw [← image_union_image_compl_eq_range] refine (hsf.image f).isBounded.union (isBounded_image_iff.2 ⟨1, fun x hx y hy ↦ ?_⟩) exact le_of_lt (hs1 (x, y) ⟨hx, hy⟩) #align metric.bounded_range_of_tendsto_cofinite_uniformity Metric.isBounded_range_of_tendsto_cofinite_uniformity theorem isBounded_range_of_cauchy_map_cofinite {f : β → α} (hf : Cauchy (map f cofinite)) : IsBounded (range f) := isBounded_range_of_tendsto_cofinite_uniformity <| (cauchy_map_iff.1 hf).2 #align metric.bounded_range_of_cauchy_map_cofinite Metric.isBounded_range_of_cauchy_map_cofinite theorem _root_.CauchySeq.isBounded_range {f : ℕ → α} (hf : CauchySeq f) : IsBounded (range f) := isBounded_range_of_cauchy_map_cofinite <| by rwa [Nat.cofinite_eq_atTop] #align cauchy_seq.bounded_range CauchySeq.isBounded_range theorem isBounded_range_of_tendsto_cofinite {f : β → α} {a : α} (hf : Tendsto f cofinite (𝓝 a)) : IsBounded (range f) := isBounded_range_of_tendsto_cofinite_uniformity <| (hf.prod_map hf).mono_right <| nhds_prod_eq.symm.trans_le (nhds_le_uniformity a) #align metric.bounded_range_of_tendsto_cofinite Metric.isBounded_range_of_tendsto_cofinite theorem isBounded_of_compactSpace [CompactSpace α] : IsBounded s := isCompact_univ.isBounded.subset (subset_univ _) #align metric.bounded_of_compact_space Metric.isBounded_of_compactSpace theorem isBounded_range_of_tendsto (u : ℕ → α) {x : α} (hu : Tendsto u atTop (𝓝 x)) : IsBounded (range u) := hu.cauchySeq.isBounded_range #align metric.bounded_range_of_tendsto Metric.isBounded_range_of_tendsto theorem disjoint_nhds_cobounded (x : α) : Disjoint (𝓝 x) (cobounded α) := disjoint_of_disjoint_of_mem disjoint_compl_right (ball_mem_nhds _ one_pos) isBounded_ball theorem disjoint_cobounded_nhds (x : α) : Disjoint (cobounded α) (𝓝 x) := (disjoint_nhds_cobounded x).symm theorem disjoint_nhdsSet_cobounded {s : Set α} (hs : IsCompact s) : Disjoint (𝓝ˢ s) (cobounded α) := hs.disjoint_nhdsSet_left.2 fun _ _ ↦ disjoint_nhds_cobounded _ theorem disjoint_cobounded_nhdsSet {s : Set α} (hs : IsCompact s) : Disjoint (cobounded α) (𝓝ˢ s) := (disjoint_nhdsSet_cobounded hs).symm theorem exists_isBounded_image_of_tendsto {α β : Type*} [PseudoMetricSpace β] {l : Filter α} {f : α → β} {x : β} (hf : Tendsto f l (𝓝 x)) : ∃ s ∈ l, IsBounded (f '' s) := (l.basis_sets.map f).disjoint_iff_left.mp <| (disjoint_nhds_cobounded x).mono_left hf theorem exists_isOpen_isBounded_image_inter_of_isCompact_of_forall_continuousWithinAt [TopologicalSpace β] {k s : Set β} {f : β → α} (hk : IsCompact k) (hf : ∀ x ∈ k, ContinuousWithinAt f s x) : ∃ t, k ⊆ t ∧ IsOpen t ∧ IsBounded (f '' (t ∩ s)) := by have : Disjoint (𝓝ˢ k ⊓ 𝓟 s) (comap f (cobounded α)) := by rw [disjoint_assoc, inf_comm, hk.disjoint_nhdsSet_left] exact fun x hx ↦ disjoint_left_comm.2 <| tendsto_comap.disjoint (disjoint_cobounded_nhds _) (hf x hx) rcases ((((hasBasis_nhdsSet _).inf_principal _)).disjoint_iff ((basis_sets _).comap _)).1 this with ⟨U, ⟨hUo, hkU⟩, t, ht, hd⟩ refine ⟨U, hkU, hUo, (isBounded_compl_iff.2 ht).subset ?_⟩ rwa [image_subset_iff, preimage_compl, subset_compl_iff_disjoint_right] #align metric.exists_is_open_bounded_image_inter_of_is_compact_of_forall_continuous_within_at Metric.exists_isOpen_isBounded_image_inter_of_isCompact_of_forall_continuousWithinAt theorem exists_isOpen_isBounded_image_of_isCompact_of_forall_continuousAt [TopologicalSpace β] {k : Set β} {f : β → α} (hk : IsCompact k) (hf : ∀ x ∈ k, ContinuousAt f x) : ∃ t, k ⊆ t ∧ IsOpen t ∧ IsBounded (f '' t) := by simp_rw [← continuousWithinAt_univ] at hf simpa only [inter_univ] using exists_isOpen_isBounded_image_inter_of_isCompact_of_forall_continuousWithinAt hk hf #align metric.exists_is_open_bounded_image_of_is_compact_of_forall_continuous_at Metric.exists_isOpen_isBounded_image_of_isCompact_of_forall_continuousAt theorem exists_isOpen_isBounded_image_inter_of_isCompact_of_continuousOn [TopologicalSpace β] {k s : Set β} {f : β → α} (hk : IsCompact k) (hks : k ⊆ s) (hf : ContinuousOn f s) : ∃ t, k ⊆ t ∧ IsOpen t ∧ IsBounded (f '' (t ∩ s)) := exists_isOpen_isBounded_image_inter_of_isCompact_of_forall_continuousWithinAt hk fun x hx => hf x (hks hx) #align metric.exists_is_open_bounded_image_inter_of_is_compact_of_continuous_on Metric.exists_isOpen_isBounded_image_inter_of_isCompact_of_continuousOn theorem exists_isOpen_isBounded_image_of_isCompact_of_continuousOn [TopologicalSpace β] {k s : Set β} {f : β → α} (hk : IsCompact k) (hs : IsOpen s) (hks : k ⊆ s) (hf : ContinuousOn f s) : ∃ t, k ⊆ t ∧ IsOpen t ∧ IsBounded (f '' t) := exists_isOpen_isBounded_image_of_isCompact_of_forall_continuousAt hk fun _x hx => hf.continuousAt (hs.mem_nhds (hks hx)) #align metric.exists_is_open_bounded_image_of_is_compact_of_continuous_on Metric.exists_isOpen_isBounded_image_of_isCompact_of_continuousOn theorem isCompact_of_isClosed_isBounded [ProperSpace α] (hc : IsClosed s) (hb : IsBounded s) : IsCompact s := by rcases eq_empty_or_nonempty s with (rfl | ⟨x, -⟩) · exact isCompact_empty · rcases hb.subset_closedBall x with ⟨r, hr⟩ exact (isCompact_closedBall x r).of_isClosed_subset hc hr #align metric.is_compact_of_is_closed_bounded Metric.isCompact_of_isClosed_isBounded theorem _root_.Bornology.IsBounded.isCompact_closure [ProperSpace α] (h : IsBounded s) : IsCompact (closure s) := isCompact_of_isClosed_isBounded isClosed_closure h.closure #align metric.bounded.is_compact_closure Bornology.IsBounded.isCompact_closure -- Porting note (#11215): TODO: assume `[MetricSpace α]` -- instead of `[PseudoMetricSpace α] [T2Space α]` theorem isCompact_iff_isClosed_bounded [T2Space α] [ProperSpace α] : IsCompact s ↔ IsClosed s ∧ IsBounded s := ⟨fun h => ⟨h.isClosed, h.isBounded⟩, fun h => isCompact_of_isClosed_isBounded h.1 h.2⟩ #align metric.is_compact_iff_is_closed_bounded Metric.isCompact_iff_isClosed_bounded theorem compactSpace_iff_isBounded_univ [ProperSpace α] : CompactSpace α ↔ IsBounded (univ : Set α) := ⟨@isBounded_of_compactSpace α _ _, fun hb => ⟨isCompact_of_isClosed_isBounded isClosed_univ hb⟩⟩ #align metric.compact_space_iff_bounded_univ Metric.compactSpace_iff_isBounded_univ section Diam variable {s : Set α} {x y z : α} noncomputable def diam (s : Set α) : ℝ := ENNReal.toReal (EMetric.diam s) #align metric.diam Metric.diam theorem diam_nonneg : 0 ≤ diam s := ENNReal.toReal_nonneg #align metric.diam_nonneg Metric.diam_nonneg theorem diam_subsingleton (hs : s.Subsingleton) : diam s = 0 := by simp only [diam, EMetric.diam_subsingleton hs, ENNReal.zero_toReal] #align metric.diam_subsingleton Metric.diam_subsingleton @[simp] theorem diam_empty : diam (∅ : Set α) = 0 := diam_subsingleton subsingleton_empty #align metric.diam_empty Metric.diam_empty @[simp] theorem diam_singleton : diam ({x} : Set α) = 0 := diam_subsingleton subsingleton_singleton #align metric.diam_singleton Metric.diam_singleton @[to_additive (attr := simp)] theorem diam_one [One α] : diam (1 : Set α) = 0 := diam_singleton #align metric.diam_one Metric.diam_one #align metric.diam_zero Metric.diam_zero -- Does not work as a simp-lemma, since {x, y} reduces to (insert y {x}) theorem diam_pair : diam ({x, y} : Set α) = dist x y := by simp only [diam, EMetric.diam_pair, dist_edist] #align metric.diam_pair Metric.diam_pair -- Does not work as a simp-lemma, since {x, y, z} reduces to (insert z (insert y {x})) theorem diam_triple : Metric.diam ({x, y, z} : Set α) = max (max (dist x y) (dist x z)) (dist y z) := by simp only [Metric.diam, EMetric.diam_triple, dist_edist] rw [ENNReal.toReal_max, ENNReal.toReal_max] <;> apply_rules [ne_of_lt, edist_lt_top, max_lt] #align metric.diam_triple Metric.diam_triple theorem ediam_le_of_forall_dist_le {C : ℝ} (h : ∀ x ∈ s, ∀ y ∈ s, dist x y ≤ C) : EMetric.diam s ≤ ENNReal.ofReal C := EMetric.diam_le fun x hx y hy => (edist_dist x y).symm ▸ ENNReal.ofReal_le_ofReal (h x hx y hy) #align metric.ediam_le_of_forall_dist_le Metric.ediam_le_of_forall_dist_le theorem diam_le_of_forall_dist_le {C : ℝ} (h₀ : 0 ≤ C) (h : ∀ x ∈ s, ∀ y ∈ s, dist x y ≤ C) : diam s ≤ C := ENNReal.toReal_le_of_le_ofReal h₀ (ediam_le_of_forall_dist_le h) #align metric.diam_le_of_forall_dist_le Metric.diam_le_of_forall_dist_le theorem diam_le_of_forall_dist_le_of_nonempty (hs : s.Nonempty) {C : ℝ} (h : ∀ x ∈ s, ∀ y ∈ s, dist x y ≤ C) : diam s ≤ C := have h₀ : 0 ≤ C := let ⟨x, hx⟩ := hs le_trans dist_nonneg (h x hx x hx) diam_le_of_forall_dist_le h₀ h #align metric.diam_le_of_forall_dist_le_of_nonempty Metric.diam_le_of_forall_dist_le_of_nonempty
Mathlib/Topology/MetricSpace/Bounded.lean
456
460
theorem dist_le_diam_of_mem' (h : EMetric.diam s ≠ ⊤) (hx : x ∈ s) (hy : y ∈ s) : dist x y ≤ diam s := by
rw [diam, dist_edist] rw [ENNReal.toReal_le_toReal (edist_ne_top _ _) h] exact EMetric.edist_le_diam_of_mem hx hy
import Mathlib.Analysis.InnerProductSpace.PiL2 import Mathlib.Combinatorics.Additive.AP.Three.Defs import Mathlib.Combinatorics.Pigeonhole import Mathlib.Data.Complex.ExponentialBounds #align_import combinatorics.additive.behrend from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" open Nat hiding log open Finset Metric Real open scoped Pointwise lemma threeAPFree_frontier {𝕜 E : Type*} [LinearOrderedField 𝕜] [TopologicalSpace E] [AddCommMonoid E] [Module 𝕜 E] {s : Set E} (hs₀ : IsClosed s) (hs₁ : StrictConvex 𝕜 s) : ThreeAPFree (frontier s) := by intro a ha b hb c hc habc obtain rfl : (1 / 2 : 𝕜) • a + (1 / 2 : 𝕜) • c = b := by rwa [← smul_add, one_div, inv_smul_eq_iff₀ (show (2 : 𝕜) ≠ 0 by norm_num), two_smul] have := hs₁.eq (hs₀.frontier_subset ha) (hs₀.frontier_subset hc) one_half_pos one_half_pos (add_halves _) hb.2 simp [this, ← add_smul] ring_nf simp #align add_salem_spencer_frontier threeAPFree_frontier lemma threeAPFree_sphere {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [StrictConvexSpace ℝ E] (x : E) (r : ℝ) : ThreeAPFree (sphere x r) := by obtain rfl | hr := eq_or_ne r 0 · rw [sphere_zero] exact threeAPFree_singleton _ · convert threeAPFree_frontier isClosed_ball (strictConvex_closedBall ℝ x r) exact (frontier_closedBall _ hr).symm #align add_salem_spencer_sphere threeAPFree_sphere namespace Behrend variable {α β : Type*} {n d k N : ℕ} {x : Fin n → ℕ} def box (n d : ℕ) : Finset (Fin n → ℕ) := Fintype.piFinset fun _ => range d #align behrend.box Behrend.box theorem mem_box : x ∈ box n d ↔ ∀ i, x i < d := by simp only [box, Fintype.mem_piFinset, mem_range] #align behrend.mem_box Behrend.mem_box @[simp] theorem card_box : (box n d).card = d ^ n := by simp [box] #align behrend.card_box Behrend.card_box @[simp] theorem box_zero : box (n + 1) 0 = ∅ := by simp [box] #align behrend.box_zero Behrend.box_zero def sphere (n d k : ℕ) : Finset (Fin n → ℕ) := (box n d).filter fun x => ∑ i, x i ^ 2 = k #align behrend.sphere Behrend.sphere theorem sphere_zero_subset : sphere n d 0 ⊆ 0 := fun x => by simp [sphere, Function.funext_iff] #align behrend.sphere_zero_subset Behrend.sphere_zero_subset @[simp] theorem sphere_zero_right (n k : ℕ) : sphere (n + 1) 0 k = ∅ := by simp [sphere] #align behrend.sphere_zero_right Behrend.sphere_zero_right theorem sphere_subset_box : sphere n d k ⊆ box n d := filter_subset _ _ #align behrend.sphere_subset_box Behrend.sphere_subset_box theorem norm_of_mem_sphere {x : Fin n → ℕ} (hx : x ∈ sphere n d k) : ‖(WithLp.equiv 2 _).symm ((↑) ∘ x : Fin n → ℝ)‖ = √↑k := by rw [EuclideanSpace.norm_eq] dsimp simp_rw [abs_cast, ← cast_pow, ← cast_sum, (mem_filter.1 hx).2] #align behrend.norm_of_mem_sphere Behrend.norm_of_mem_sphere theorem sphere_subset_preimage_metric_sphere : (sphere n d k : Set (Fin n → ℕ)) ⊆ (fun x : Fin n → ℕ => (WithLp.equiv 2 _).symm ((↑) ∘ x : Fin n → ℝ)) ⁻¹' Metric.sphere (0 : PiLp 2 fun _ : Fin n => ℝ) (√↑k) := fun x hx => by rw [Set.mem_preimage, mem_sphere_zero_iff_norm, norm_of_mem_sphere hx] #align behrend.sphere_subset_preimage_metric_sphere Behrend.sphere_subset_preimage_metric_sphere @[simps] def map (d : ℕ) : (Fin n → ℕ) →+ ℕ where toFun a := ∑ i, a i * d ^ (i : ℕ) map_zero' := by simp_rw [Pi.zero_apply, zero_mul, sum_const_zero] map_add' a b := by simp_rw [Pi.add_apply, add_mul, sum_add_distrib] #align behrend.map Behrend.map -- @[simp] -- Porting note (#10618): simp can prove this theorem map_zero (d : ℕ) (a : Fin 0 → ℕ) : map d a = 0 := by simp [map] #align behrend.map_zero Behrend.map_zero theorem map_succ (a : Fin (n + 1) → ℕ) : map d a = a 0 + (∑ x : Fin n, a x.succ * d ^ (x : ℕ)) * d := by simp [map, Fin.sum_univ_succ, _root_.pow_succ, ← mul_assoc, ← sum_mul] #align behrend.map_succ Behrend.map_succ theorem map_succ' (a : Fin (n + 1) → ℕ) : map d a = a 0 + map d (a ∘ Fin.succ) * d := map_succ _ #align behrend.map_succ' Behrend.map_succ' theorem map_monotone (d : ℕ) : Monotone (map d : (Fin n → ℕ) → ℕ) := fun x y h => by dsimp; exact sum_le_sum fun i _ => Nat.mul_le_mul_right _ <| h i #align behrend.map_monotone Behrend.map_monotone theorem map_mod (a : Fin n.succ → ℕ) : map d a % d = a 0 % d := by rw [map_succ, Nat.add_mul_mod_self_right] #align behrend.map_mod Behrend.map_mod theorem map_eq_iff {x₁ x₂ : Fin n.succ → ℕ} (hx₁ : ∀ i, x₁ i < d) (hx₂ : ∀ i, x₂ i < d) : map d x₁ = map d x₂ ↔ x₁ 0 = x₂ 0 ∧ map d (x₁ ∘ Fin.succ) = map d (x₂ ∘ Fin.succ) := by refine ⟨fun h => ?_, fun h => by rw [map_succ', map_succ', h.1, h.2]⟩ have : x₁ 0 = x₂ 0 := by rw [← mod_eq_of_lt (hx₁ _), ← map_mod, ← mod_eq_of_lt (hx₂ _), ← map_mod, h] rw [map_succ, map_succ, this, add_right_inj, mul_eq_mul_right_iff] at h exact ⟨this, h.resolve_right (pos_of_gt (hx₁ 0)).ne'⟩ #align behrend.map_eq_iff Behrend.map_eq_iff theorem map_injOn : {x : Fin n → ℕ | ∀ i, x i < d}.InjOn (map d) := by intro x₁ hx₁ x₂ hx₂ h induction' n with n ih · simp [eq_iff_true_of_subsingleton] rw [forall_const] at ih ext i have x := (map_eq_iff hx₁ hx₂).1 h refine Fin.cases x.1 (congr_fun <| ih (fun _ => ?_) (fun _ => ?_) x.2) i · exact hx₁ _ · exact hx₂ _ #align behrend.map_inj_on Behrend.map_injOn theorem map_le_of_mem_box (hx : x ∈ box n d) : map (2 * d - 1) x ≤ ∑ i : Fin n, (d - 1) * (2 * d - 1) ^ (i : ℕ) := map_monotone (2 * d - 1) fun _ => Nat.le_sub_one_of_lt <| mem_box.1 hx _ #align behrend.map_le_of_mem_box Behrend.map_le_of_mem_box nonrec theorem threeAPFree_sphere : ThreeAPFree (sphere n d k : Set (Fin n → ℕ)) := by set f : (Fin n → ℕ) →+ EuclideanSpace ℝ (Fin n) := { toFun := fun f => ((↑) : ℕ → ℝ) ∘ f map_zero' := funext fun _ => cast_zero map_add' := fun _ _ => funext fun _ => cast_add _ _ } refine ThreeAPFree.of_image (AddMonoidHomClass.isAddFreimanHom f (Set.mapsTo_image _ _)) cast_injective.comp_left.injOn (Set.subset_univ _) ?_ refine (threeAPFree_sphere 0 (√↑k)).mono (Set.image_subset_iff.2 fun x => ?_) rw [Set.mem_preimage, mem_sphere_zero_iff_norm] exact norm_of_mem_sphere #align behrend.add_salem_spencer_sphere Behrend.threeAPFree_sphere theorem threeAPFree_image_sphere : ThreeAPFree ((sphere n d k).image (map (2 * d - 1)) : Set ℕ) := by rw [coe_image] apply ThreeAPFree.image' (α := Fin n → ℕ) (β := ℕ) (s := sphere n d k) (map (2 * d - 1)) (map_injOn.mono _) threeAPFree_sphere · rw [Set.add_subset_iff] rintro a ha b hb i have hai := mem_box.1 (sphere_subset_box ha) i have hbi := mem_box.1 (sphere_subset_box hb) i rw [lt_tsub_iff_right, ← succ_le_iff, two_mul] exact (add_add_add_comm _ _ 1 1).trans_le (_root_.add_le_add hai hbi) · exact x #align behrend.add_salem_spencer_image_sphere Behrend.threeAPFree_image_sphere theorem sum_sq_le_of_mem_box (hx : x ∈ box n d) : ∑ i : Fin n, x i ^ 2 ≤ n * (d - 1) ^ 2 := by rw [mem_box] at hx have : ∀ i, x i ^ 2 ≤ (d - 1) ^ 2 := fun i => Nat.pow_le_pow_left (Nat.le_sub_one_of_lt (hx i)) _ exact (sum_le_card_nsmul univ _ _ fun i _ => this i).trans (by rw [card_fin, smul_eq_mul]) #align behrend.sum_sq_le_of_mem_box Behrend.sum_sq_le_of_mem_box theorem sum_eq : (∑ i : Fin n, d * (2 * d + 1) ^ (i : ℕ)) = ((2 * d + 1) ^ n - 1) / 2 := by refine (Nat.div_eq_of_eq_mul_left zero_lt_two ?_).symm rw [← sum_range fun i => d * (2 * d + 1) ^ (i : ℕ), ← mul_sum, mul_right_comm, mul_comm d, ← geom_sum_mul_add, add_tsub_cancel_right, mul_comm] #align behrend.sum_eq Behrend.sum_eq theorem sum_lt : (∑ i : Fin n, d * (2 * d + 1) ^ (i : ℕ)) < (2 * d + 1) ^ n := sum_eq.trans_lt <| (Nat.div_le_self _ 2).trans_lt <| pred_lt (pow_pos (succ_pos _) _).ne' #align behrend.sum_lt Behrend.sum_lt theorem card_sphere_le_rothNumberNat (n d k : ℕ) : (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by cases n · dsimp; refine (card_le_univ _).trans_eq ?_; rfl cases d · simp apply threeAPFree_image_sphere.le_rothNumberNat _ _ (card_image_of_injOn _) · intro; assumption · simp only [subset_iff, mem_image, and_imp, forall_exists_index, mem_range, forall_apply_eq_imp_iff₂, sphere, mem_filter] rintro _ x hx _ rfl exact (map_le_of_mem_box hx).trans_lt sum_lt apply map_injOn.mono fun x => ?_ · intro; assumption simp only [mem_coe, sphere, mem_filter, mem_box, and_imp, two_mul] exact fun h _ i => (h i).trans_le le_self_add #align behrend.card_sphere_le_roth_number_nat Behrend.card_sphere_le_rothNumberNat theorem exists_large_sphere_aux (n d : ℕ) : ∃ k ∈ range (n * (d - 1) ^ 2 + 1), (↑(d ^ n) / ((n * (d - 1) ^ 2 :) + 1) : ℝ) ≤ (sphere n d k).card := by refine exists_le_card_fiber_of_nsmul_le_card_of_maps_to (fun x hx => ?_) nonempty_range_succ ?_ · rw [mem_range, Nat.lt_succ_iff] exact sum_sq_le_of_mem_box hx · rw [card_range, _root_.nsmul_eq_mul, mul_div_assoc', cast_add_one, mul_div_cancel_left₀, card_box] exact (cast_add_one_pos _).ne' #align behrend.exists_large_sphere_aux Behrend.exists_large_sphere_aux theorem exists_large_sphere (n d : ℕ) : ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d refine ⟨k, ?_⟩ obtain rfl | hn := n.eq_zero_or_pos · simp obtain rfl | hd := d.eq_zero_or_pos · simp refine (div_le_div_of_nonneg_left ?_ ?_ ?_).trans hk · exact cast_nonneg _ · exact cast_add_one_pos _ simp only [← le_sub_iff_add_le', cast_mul, ← mul_sub, cast_pow, cast_sub hd, sub_sq, one_pow, cast_one, mul_one, sub_add, sub_sub_self] apply one_le_mul_of_one_le_of_one_le · rwa [one_le_cast] rw [_root_.le_sub_iff_add_le] set_option tactic.skipAssignedInstances false in norm_num exact one_le_cast.2 hd #align behrend.exists_large_sphere Behrend.exists_large_sphere theorem bound_aux' (n d : ℕ) : ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ rothNumberNat ((2 * d - 1) ^ n) := let ⟨_, h⟩ := exists_large_sphere n d h.trans <| cast_le.2 <| card_sphere_le_rothNumberNat _ _ _ #align behrend.bound_aux' Behrend.bound_aux' theorem bound_aux (hd : d ≠ 0) (hn : 2 ≤ n) : (d ^ (n - 2 :) / n : ℝ) ≤ rothNumberNat ((2 * d - 1) ^ n) := by convert bound_aux' n d using 1 rw [cast_mul, cast_pow, mul_comm, ← div_div, pow_sub₀ _ _ hn, ← div_eq_mul_inv, cast_pow] rwa [cast_ne_zero] #align behrend.bound_aux Behrend.bound_aux open scoped Filter Topology open Real section NumericalBounds theorem log_two_mul_two_le_sqrt_log_eight : log 2 * 2 ≤ √(log 8) := by have : (8 : ℝ) = 2 ^ ((3 : ℕ) : ℝ) := by rw [rpow_natCast]; norm_num rw [this, log_rpow zero_lt_two (3 : ℕ)] apply le_sqrt_of_sq_le rw [mul_pow, sq (log 2), mul_assoc, mul_comm] refine mul_le_mul_of_nonneg_right ?_ (log_nonneg one_le_two) rw [← le_div_iff] on_goal 1 => apply log_two_lt_d9.le.trans all_goals norm_num1 #align behrend.log_two_mul_two_le_sqrt_log_eight Behrend.log_two_mul_two_le_sqrt_log_eight
Mathlib/Combinatorics/Additive/AP/Three/Behrend.lean
323
327
theorem two_div_one_sub_two_div_e_le_eight : 2 / (1 - 2 / exp 1) ≤ 8 := by
rw [div_le_iff, mul_sub, mul_one, mul_div_assoc', le_sub_comm, div_le_iff (exp_pos _)] · have : 16 < 6 * (2.7182818283 : ℝ) := by norm_num linarith [exp_one_gt_d9] rw [sub_pos, div_lt_one] <;> exact exp_one_gt_d9.trans' (by norm_num)
import Mathlib.Topology.Algebra.Module.WeakDual import Mathlib.MeasureTheory.Integral.BoundedContinuousFunction import Mathlib.MeasureTheory.Measure.HasOuterApproxClosed #align_import measure_theory.measure.finite_measure from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" noncomputable section open MeasureTheory open Set open Filter open BoundedContinuousFunction open scoped Topology ENNReal NNReal BoundedContinuousFunction namespace MeasureTheory namespace FiniteMeasure section FiniteMeasure variable {Ω : Type*} [MeasurableSpace Ω] def _root_.MeasureTheory.FiniteMeasure (Ω : Type*) [MeasurableSpace Ω] : Type _ := { μ : Measure Ω // IsFiniteMeasure μ } #align measure_theory.finite_measure MeasureTheory.FiniteMeasure -- Porting note: as with other subtype synonyms (e.g., `ℝ≥0`, we need a new function for the -- coercion instead of relying on `Subtype.val`. @[coe] def toMeasure : FiniteMeasure Ω → Measure Ω := Subtype.val instance instCoe : Coe (FiniteMeasure Ω) (MeasureTheory.Measure Ω) where coe := toMeasure instance isFiniteMeasure (μ : FiniteMeasure Ω) : IsFiniteMeasure (μ : Measure Ω) := μ.prop #align measure_theory.finite_measure.is_finite_measure MeasureTheory.FiniteMeasure.isFiniteMeasure @[simp] theorem val_eq_toMeasure (ν : FiniteMeasure Ω) : ν.val = (ν : Measure Ω) := rfl #align measure_theory.finite_measure.val_eq_to_measure MeasureTheory.FiniteMeasure.val_eq_toMeasure theorem toMeasure_injective : Function.Injective ((↑) : FiniteMeasure Ω → Measure Ω) := Subtype.coe_injective #align measure_theory.finite_measure.coe_injective MeasureTheory.FiniteMeasure.toMeasure_injective instance instFunLike : FunLike (FiniteMeasure Ω) (Set Ω) ℝ≥0 where coe μ s := ((μ : Measure Ω) s).toNNReal coe_injective' μ ν h := toMeasure_injective $ Measure.ext fun s _ ↦ by simpa [ENNReal.toNNReal_eq_toNNReal_iff, measure_ne_top] using congr_fun h s lemma coeFn_def (μ : FiniteMeasure Ω) : μ = fun s ↦ ((μ : Measure Ω) s).toNNReal := rfl #align measure_theory.finite_measure.coe_fn_eq_to_nnreal_coe_fn_to_measure MeasureTheory.FiniteMeasure.coeFn_def lemma coeFn_mk (μ : Measure Ω) (hμ) : DFunLike.coe (F := FiniteMeasure Ω) ⟨μ, hμ⟩ = fun s ↦ (μ s).toNNReal := rfl @[simp, norm_cast] lemma mk_apply (μ : Measure Ω) (hμ) (s : Set Ω) : DFunLike.coe (F := FiniteMeasure Ω) ⟨μ, hμ⟩ s = (μ s).toNNReal := rfl @[simp] theorem ennreal_coeFn_eq_coeFn_toMeasure (ν : FiniteMeasure Ω) (s : Set Ω) : (ν s : ℝ≥0∞) = (ν : Measure Ω) s := ENNReal.coe_toNNReal (measure_lt_top (↑ν) s).ne #align measure_theory.finite_measure.ennreal_coe_fn_eq_coe_fn_to_measure MeasureTheory.FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure theorem apply_mono (μ : FiniteMeasure Ω) {s₁ s₂ : Set Ω} (h : s₁ ⊆ s₂) : μ s₁ ≤ μ s₂ := by change ((μ : Measure Ω) s₁).toNNReal ≤ ((μ : Measure Ω) s₂).toNNReal have key : (μ : Measure Ω) s₁ ≤ (μ : Measure Ω) s₂ := (μ : Measure Ω).mono h apply (ENNReal.toNNReal_le_toNNReal (measure_ne_top _ s₁) (measure_ne_top _ s₂)).mpr key #align measure_theory.finite_measure.apply_mono MeasureTheory.FiniteMeasure.apply_mono def mass (μ : FiniteMeasure Ω) : ℝ≥0 := μ univ #align measure_theory.finite_measure.mass MeasureTheory.FiniteMeasure.mass @[simp] theorem apply_le_mass (μ : FiniteMeasure Ω) (s : Set Ω) : μ s ≤ μ.mass := by simpa using apply_mono μ (subset_univ s) @[simp] theorem ennreal_mass {μ : FiniteMeasure Ω} : (μ.mass : ℝ≥0∞) = (μ : Measure Ω) univ := ennreal_coeFn_eq_coeFn_toMeasure μ Set.univ #align measure_theory.finite_measure.ennreal_mass MeasureTheory.FiniteMeasure.ennreal_mass instance instZero : Zero (FiniteMeasure Ω) where zero := ⟨0, MeasureTheory.isFiniteMeasureZero⟩ #align measure_theory.finite_measure.has_zero MeasureTheory.FiniteMeasure.instZero @[simp, norm_cast] lemma coeFn_zero : ⇑(0 : FiniteMeasure Ω) = 0 := rfl #align measure_theory.finite_measure.coe_fn_zero MeasureTheory.FiniteMeasure.coeFn_zero @[simp] theorem zero_mass : (0 : FiniteMeasure Ω).mass = 0 := rfl #align measure_theory.finite_measure.zero.mass MeasureTheory.FiniteMeasure.zero_mass @[simp] theorem mass_zero_iff (μ : FiniteMeasure Ω) : μ.mass = 0 ↔ μ = 0 := by refine ⟨fun μ_mass => ?_, fun hμ => by simp only [hμ, zero_mass]⟩ apply toMeasure_injective apply Measure.measure_univ_eq_zero.mp rwa [← ennreal_mass, ENNReal.coe_eq_zero] #align measure_theory.finite_measure.mass_zero_iff MeasureTheory.FiniteMeasure.mass_zero_iff theorem mass_nonzero_iff (μ : FiniteMeasure Ω) : μ.mass ≠ 0 ↔ μ ≠ 0 := by rw [not_iff_not] exact FiniteMeasure.mass_zero_iff μ #align measure_theory.finite_measure.mass_nonzero_iff MeasureTheory.FiniteMeasure.mass_nonzero_iff @[ext] theorem eq_of_forall_toMeasure_apply_eq (μ ν : FiniteMeasure Ω) (h : ∀ s : Set Ω, MeasurableSet s → (μ : Measure Ω) s = (ν : Measure Ω) s) : μ = ν := by apply Subtype.ext ext1 s s_mble exact h s s_mble #align measure_theory.finite_measure.eq_of_forall_measure_apply_eq MeasureTheory.FiniteMeasure.eq_of_forall_toMeasure_apply_eq theorem eq_of_forall_apply_eq (μ ν : FiniteMeasure Ω) (h : ∀ s : Set Ω, MeasurableSet s → μ s = ν s) : μ = ν := by ext1 s s_mble simpa [ennreal_coeFn_eq_coeFn_toMeasure] using congr_arg ((↑) : ℝ≥0 → ℝ≥0∞) (h s s_mble) #align measure_theory.finite_measure.eq_of_forall_apply_eq MeasureTheory.FiniteMeasure.eq_of_forall_apply_eq instance instInhabited : Inhabited (FiniteMeasure Ω) := ⟨0⟩ instance instAdd : Add (FiniteMeasure Ω) where add μ ν := ⟨μ + ν, MeasureTheory.isFiniteMeasureAdd⟩ variable {R : Type*} [SMul R ℝ≥0] [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0 ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] instance instSMul : SMul R (FiniteMeasure Ω) where smul (c : R) μ := ⟨c • (μ : Measure Ω), MeasureTheory.isFiniteMeasureSMulOfNNRealTower⟩ @[simp, norm_cast] theorem toMeasure_zero : ((↑) : FiniteMeasure Ω → Measure Ω) 0 = 0 := rfl #align measure_theory.finite_measure.coe_zero MeasureTheory.FiniteMeasure.toMeasure_zero -- Porting note: with `simp` here the `coeFn` lemmas below fall prey to `simpNF`: the LHS simplifies @[norm_cast] theorem toMeasure_add (μ ν : FiniteMeasure Ω) : ↑(μ + ν) = (↑μ + ↑ν : Measure Ω) := rfl #align measure_theory.finite_measure.coe_add MeasureTheory.FiniteMeasure.toMeasure_add @[simp, norm_cast] theorem toMeasure_smul (c : R) (μ : FiniteMeasure Ω) : ↑(c • μ) = c • (μ : Measure Ω) := rfl #align measure_theory.finite_measure.coe_smul MeasureTheory.FiniteMeasure.toMeasure_smul @[simp, norm_cast] theorem coeFn_add (μ ν : FiniteMeasure Ω) : (⇑(μ + ν) : Set Ω → ℝ≥0) = (⇑μ + ⇑ν : Set Ω → ℝ≥0) := by funext simp only [Pi.add_apply, ← ENNReal.coe_inj, ne_eq, ennreal_coeFn_eq_coeFn_toMeasure, ENNReal.coe_add] norm_cast #align measure_theory.finite_measure.coe_fn_add MeasureTheory.FiniteMeasure.coeFn_add @[simp, norm_cast] theorem coeFn_smul [IsScalarTower R ℝ≥0 ℝ≥0] (c : R) (μ : FiniteMeasure Ω) : (⇑(c • μ) : Set Ω → ℝ≥0) = c • (⇑μ : Set Ω → ℝ≥0) := by funext; simp [← ENNReal.coe_inj, ENNReal.coe_smul] #align measure_theory.finite_measure.coe_fn_smul MeasureTheory.FiniteMeasure.coeFn_smul instance instAddCommMonoid : AddCommMonoid (FiniteMeasure Ω) := toMeasure_injective.addCommMonoid (↑) toMeasure_zero toMeasure_add fun _ _ => toMeasure_smul _ _ @[simps] def toMeasureAddMonoidHom : FiniteMeasure Ω →+ Measure Ω where toFun := (↑) map_zero' := toMeasure_zero map_add' := toMeasure_add #align measure_theory.finite_measure.coe_add_monoid_hom MeasureTheory.FiniteMeasure.toMeasureAddMonoidHom instance {Ω : Type*} [MeasurableSpace Ω] : Module ℝ≥0 (FiniteMeasure Ω) := Function.Injective.module _ toMeasureAddMonoidHom toMeasure_injective toMeasure_smul @[simp] theorem smul_apply [IsScalarTower R ℝ≥0 ℝ≥0] (c : R) (μ : FiniteMeasure Ω) (s : Set Ω) : (c • μ) s = c • μ s := by rw [coeFn_smul, Pi.smul_apply] #align measure_theory.finite_measure.coe_fn_smul_apply MeasureTheory.FiniteMeasure.smul_apply def restrict (μ : FiniteMeasure Ω) (A : Set Ω) : FiniteMeasure Ω where val := (μ : Measure Ω).restrict A property := MeasureTheory.isFiniteMeasureRestrict (μ : Measure Ω) A #align measure_theory.finite_measure.restrict MeasureTheory.FiniteMeasure.restrict theorem restrict_measure_eq (μ : FiniteMeasure Ω) (A : Set Ω) : (μ.restrict A : Measure Ω) = (μ : Measure Ω).restrict A := rfl #align measure_theory.finite_measure.restrict_measure_eq MeasureTheory.FiniteMeasure.restrict_measure_eq theorem restrict_apply_measure (μ : FiniteMeasure Ω) (A : Set Ω) {s : Set Ω} (s_mble : MeasurableSet s) : (μ.restrict A : Measure Ω) s = (μ : Measure Ω) (s ∩ A) := Measure.restrict_apply s_mble #align measure_theory.finite_measure.restrict_apply_measure MeasureTheory.FiniteMeasure.restrict_apply_measure theorem restrict_apply (μ : FiniteMeasure Ω) (A : Set Ω) {s : Set Ω} (s_mble : MeasurableSet s) : (μ.restrict A) s = μ (s ∩ A) := by apply congr_arg ENNReal.toNNReal exact Measure.restrict_apply s_mble #align measure_theory.finite_measure.restrict_apply MeasureTheory.FiniteMeasure.restrict_apply theorem restrict_mass (μ : FiniteMeasure Ω) (A : Set Ω) : (μ.restrict A).mass = μ A := by simp only [mass, restrict_apply μ A MeasurableSet.univ, univ_inter] #align measure_theory.finite_measure.restrict_mass MeasureTheory.FiniteMeasure.restrict_mass theorem restrict_eq_zero_iff (μ : FiniteMeasure Ω) (A : Set Ω) : μ.restrict A = 0 ↔ μ A = 0 := by rw [← mass_zero_iff, restrict_mass] #align measure_theory.finite_measure.restrict_eq_zero_iff MeasureTheory.FiniteMeasure.restrict_eq_zero_iff theorem restrict_nonzero_iff (μ : FiniteMeasure Ω) (A : Set Ω) : μ.restrict A ≠ 0 ↔ μ A ≠ 0 := by rw [← mass_nonzero_iff, restrict_mass] #align measure_theory.finite_measure.restrict_nonzero_iff MeasureTheory.FiniteMeasure.restrict_nonzero_iff variable [TopologicalSpace Ω] theorem ext_of_forall_lintegral_eq [HasOuterApproxClosed Ω] [BorelSpace Ω] {μ ν : FiniteMeasure Ω} (h : ∀ (f : Ω →ᵇ ℝ≥0), ∫⁻ x, f x ∂μ = ∫⁻ x, f x ∂ν) : μ = ν := by apply Subtype.ext change (μ : Measure Ω) = (ν : Measure Ω) exact ext_of_forall_lintegral_eq_of_IsFiniteMeasure h def testAgainstNN (μ : FiniteMeasure Ω) (f : Ω →ᵇ ℝ≥0) : ℝ≥0 := (∫⁻ ω, f ω ∂(μ : Measure Ω)).toNNReal #align measure_theory.finite_measure.test_against_nn MeasureTheory.FiniteMeasure.testAgainstNN @[simp] theorem testAgainstNN_coe_eq {μ : FiniteMeasure Ω} {f : Ω →ᵇ ℝ≥0} : (μ.testAgainstNN f : ℝ≥0∞) = ∫⁻ ω, f ω ∂(μ : Measure Ω) := ENNReal.coe_toNNReal (f.lintegral_lt_top_of_nnreal _).ne #align measure_theory.finite_measure.test_against_nn_coe_eq MeasureTheory.FiniteMeasure.testAgainstNN_coe_eq theorem testAgainstNN_const (μ : FiniteMeasure Ω) (c : ℝ≥0) : μ.testAgainstNN (BoundedContinuousFunction.const Ω c) = c * μ.mass := by simp [← ENNReal.coe_inj] #align measure_theory.finite_measure.test_against_nn_const MeasureTheory.FiniteMeasure.testAgainstNN_const theorem testAgainstNN_mono (μ : FiniteMeasure Ω) {f g : Ω →ᵇ ℝ≥0} (f_le_g : (f : Ω → ℝ≥0) ≤ g) : μ.testAgainstNN f ≤ μ.testAgainstNN g := by simp only [← ENNReal.coe_le_coe, testAgainstNN_coe_eq] gcongr apply f_le_g #align measure_theory.finite_measure.test_against_nn_mono MeasureTheory.FiniteMeasure.testAgainstNN_mono @[simp] theorem testAgainstNN_zero (μ : FiniteMeasure Ω) : μ.testAgainstNN 0 = 0 := by simpa only [zero_mul] using μ.testAgainstNN_const 0 #align measure_theory.finite_measure.test_against_nn_zero MeasureTheory.FiniteMeasure.testAgainstNN_zero @[simp] theorem testAgainstNN_one (μ : FiniteMeasure Ω) : μ.testAgainstNN 1 = μ.mass := by simp only [testAgainstNN, coe_one, Pi.one_apply, ENNReal.coe_one, lintegral_one] rfl #align measure_theory.finite_measure.test_against_nn_one MeasureTheory.FiniteMeasure.testAgainstNN_one @[simp] theorem zero_testAgainstNN_apply (f : Ω →ᵇ ℝ≥0) : (0 : FiniteMeasure Ω).testAgainstNN f = 0 := by simp only [testAgainstNN, toMeasure_zero, lintegral_zero_measure, ENNReal.zero_toNNReal] #align measure_theory.finite_measure.zero.test_against_nn_apply MeasureTheory.FiniteMeasure.zero_testAgainstNN_apply theorem zero_testAgainstNN : (0 : FiniteMeasure Ω).testAgainstNN = 0 := by funext; simp only [zero_testAgainstNN_apply, Pi.zero_apply] #align measure_theory.finite_measure.zero.test_against_nn MeasureTheory.FiniteMeasure.zero_testAgainstNN @[simp] theorem smul_testAgainstNN_apply (c : ℝ≥0) (μ : FiniteMeasure Ω) (f : Ω →ᵇ ℝ≥0) : (c • μ).testAgainstNN f = c • μ.testAgainstNN f := by simp only [testAgainstNN, toMeasure_smul, smul_eq_mul, ← ENNReal.smul_toNNReal, ENNReal.smul_def, lintegral_smul_measure] #align measure_theory.finite_measure.smul_test_against_nn_apply MeasureTheory.FiniteMeasure.smul_testAgainstNN_apply section weak_convergence variable [OpensMeasurableSpace Ω] theorem testAgainstNN_add (μ : FiniteMeasure Ω) (f₁ f₂ : Ω →ᵇ ℝ≥0) : μ.testAgainstNN (f₁ + f₂) = μ.testAgainstNN f₁ + μ.testAgainstNN f₂ := by simp only [← ENNReal.coe_inj, BoundedContinuousFunction.coe_add, ENNReal.coe_add, Pi.add_apply, testAgainstNN_coe_eq] exact lintegral_add_left (BoundedContinuousFunction.measurable_coe_ennreal_comp _) _ #align measure_theory.finite_measure.test_against_nn_add MeasureTheory.FiniteMeasure.testAgainstNN_add theorem testAgainstNN_smul [IsScalarTower R ℝ≥0 ℝ≥0] [PseudoMetricSpace R] [Zero R] [BoundedSMul R ℝ≥0] (μ : FiniteMeasure Ω) (c : R) (f : Ω →ᵇ ℝ≥0) : μ.testAgainstNN (c • f) = c • μ.testAgainstNN f := by simp only [← ENNReal.coe_inj, BoundedContinuousFunction.coe_smul, testAgainstNN_coe_eq, ENNReal.coe_smul] simp_rw [← smul_one_smul ℝ≥0∞ c (f _ : ℝ≥0∞), ← smul_one_smul ℝ≥0∞ c (lintegral _ _ : ℝ≥0∞), smul_eq_mul] exact @lintegral_const_mul _ _ (μ : Measure Ω) (c • (1 : ℝ≥0∞)) _ f.measurable_coe_ennreal_comp #align measure_theory.finite_measure.test_against_nn_smul MeasureTheory.FiniteMeasure.testAgainstNN_smul theorem testAgainstNN_lipschitz_estimate (μ : FiniteMeasure Ω) (f g : Ω →ᵇ ℝ≥0) : μ.testAgainstNN f ≤ μ.testAgainstNN g + nndist f g * μ.mass := by simp only [← μ.testAgainstNN_const (nndist f g), ← testAgainstNN_add, ← ENNReal.coe_le_coe, BoundedContinuousFunction.coe_add, const_apply, ENNReal.coe_add, Pi.add_apply, coe_nnreal_ennreal_nndist, testAgainstNN_coe_eq] apply lintegral_mono have le_dist : ∀ ω, dist (f ω) (g ω) ≤ nndist f g := BoundedContinuousFunction.dist_coe_le_dist intro ω have le' : f ω ≤ g ω + nndist f g := by apply (NNReal.le_add_nndist (f ω) (g ω)).trans rw [add_le_add_iff_left] exact dist_le_coe.mp (le_dist ω) have le : (f ω : ℝ≥0∞) ≤ (g ω : ℝ≥0∞) + nndist f g := by rw [← ENNReal.coe_add]; exact ENNReal.coe_mono le' rwa [coe_nnreal_ennreal_nndist] at le #align measure_theory.finite_measure.test_against_nn_lipschitz_estimate MeasureTheory.FiniteMeasure.testAgainstNN_lipschitz_estimate theorem testAgainstNN_lipschitz (μ : FiniteMeasure Ω) : LipschitzWith μ.mass fun f : Ω →ᵇ ℝ≥0 => μ.testAgainstNN f := by rw [lipschitzWith_iff_dist_le_mul] intro f₁ f₂ suffices abs (μ.testAgainstNN f₁ - μ.testAgainstNN f₂ : ℝ) ≤ μ.mass * dist f₁ f₂ by rwa [NNReal.dist_eq] apply abs_le.mpr constructor · have key' := μ.testAgainstNN_lipschitz_estimate f₂ f₁ rw [mul_comm] at key' suffices ↑(μ.testAgainstNN f₂) ≤ ↑(μ.testAgainstNN f₁) + ↑μ.mass * dist f₁ f₂ by linarith have key := NNReal.coe_mono key' rwa [NNReal.coe_add, NNReal.coe_mul, nndist_comm] at key · have key' := μ.testAgainstNN_lipschitz_estimate f₁ f₂ rw [mul_comm] at key' suffices ↑(μ.testAgainstNN f₁) ≤ ↑(μ.testAgainstNN f₂) + ↑μ.mass * dist f₁ f₂ by linarith have key := NNReal.coe_mono key' rwa [NNReal.coe_add, NNReal.coe_mul] at key #align measure_theory.finite_measure.test_against_nn_lipschitz MeasureTheory.FiniteMeasure.testAgainstNN_lipschitz def toWeakDualBCNN (μ : FiniteMeasure Ω) : WeakDual ℝ≥0 (Ω →ᵇ ℝ≥0) where toFun f := μ.testAgainstNN f map_add' := testAgainstNN_add μ map_smul' := testAgainstNN_smul μ cont := μ.testAgainstNN_lipschitz.continuous #align measure_theory.finite_measure.to_weak_dual_bcnn MeasureTheory.FiniteMeasure.toWeakDualBCNN @[simp] theorem coe_toWeakDualBCNN (μ : FiniteMeasure Ω) : ⇑μ.toWeakDualBCNN = μ.testAgainstNN := rfl #align measure_theory.finite_measure.coe_to_weak_dual_bcnn MeasureTheory.FiniteMeasure.coe_toWeakDualBCNN @[simp] theorem toWeakDualBCNN_apply (μ : FiniteMeasure Ω) (f : Ω →ᵇ ℝ≥0) : μ.toWeakDualBCNN f = (∫⁻ x, f x ∂(μ : Measure Ω)).toNNReal := rfl #align measure_theory.finite_measure.to_weak_dual_bcnn_apply MeasureTheory.FiniteMeasure.toWeakDualBCNN_apply instance instTopologicalSpace : TopologicalSpace (FiniteMeasure Ω) := TopologicalSpace.induced toWeakDualBCNN inferInstance theorem toWeakDualBCNN_continuous : Continuous (@toWeakDualBCNN Ω _ _ _) := continuous_induced_dom #align measure_theory.finite_measure.to_weak_dual_bcnn_continuous MeasureTheory.FiniteMeasure.toWeakDualBCNN_continuous theorem continuous_testAgainstNN_eval (f : Ω →ᵇ ℝ≥0) : Continuous fun μ : FiniteMeasure Ω => μ.testAgainstNN f := by show Continuous ((fun φ : WeakDual ℝ≥0 (Ω →ᵇ ℝ≥0) => φ f) ∘ toWeakDualBCNN) refine Continuous.comp ?_ (toWeakDualBCNN_continuous (Ω := Ω)) exact WeakBilin.eval_continuous (𝕜 := ℝ≥0) (E := (Ω →ᵇ ℝ≥0) →L[ℝ≥0] ℝ≥0) _ _ #align measure_theory.finite_measure.continuous_test_against_nn_eval MeasureTheory.FiniteMeasure.continuous_testAgainstNN_eval theorem continuous_mass : Continuous fun μ : FiniteMeasure Ω => μ.mass := by simp_rw [← testAgainstNN_one]; exact continuous_testAgainstNN_eval 1 #align measure_theory.finite_measure.continuous_mass MeasureTheory.FiniteMeasure.continuous_mass theorem _root_.Filter.Tendsto.mass {γ : Type*} {F : Filter γ} {μs : γ → FiniteMeasure Ω} {μ : FiniteMeasure Ω} (h : Tendsto μs F (𝓝 μ)) : Tendsto (fun i => (μs i).mass) F (𝓝 μ.mass) := (continuous_mass.tendsto μ).comp h #align filter.tendsto.mass Filter.Tendsto.mass theorem tendsto_iff_weak_star_tendsto {γ : Type*} {F : Filter γ} {μs : γ → FiniteMeasure Ω} {μ : FiniteMeasure Ω} : Tendsto μs F (𝓝 μ) ↔ Tendsto (fun i => (μs i).toWeakDualBCNN) F (𝓝 μ.toWeakDualBCNN) := Inducing.tendsto_nhds_iff ⟨rfl⟩ #align measure_theory.finite_measure.tendsto_iff_weak_star_tendsto MeasureTheory.FiniteMeasure.tendsto_iff_weak_star_tendsto theorem tendsto_iff_forall_toWeakDualBCNN_tendsto {γ : Type*} {F : Filter γ} {μs : γ → FiniteMeasure Ω} {μ : FiniteMeasure Ω} : Tendsto μs F (𝓝 μ) ↔ ∀ f : Ω →ᵇ ℝ≥0, Tendsto (fun i => (μs i).toWeakDualBCNN f) F (𝓝 (μ.toWeakDualBCNN f)) := by rw [tendsto_iff_weak_star_tendsto, tendsto_iff_forall_eval_tendsto_topDualPairing]; rfl #align measure_theory.finite_measure.tendsto_iff_forall_to_weak_dual_bcnn_tendsto MeasureTheory.FiniteMeasure.tendsto_iff_forall_toWeakDualBCNN_tendsto theorem tendsto_iff_forall_testAgainstNN_tendsto {γ : Type*} {F : Filter γ} {μs : γ → FiniteMeasure Ω} {μ : FiniteMeasure Ω} : Tendsto μs F (𝓝 μ) ↔ ∀ f : Ω →ᵇ ℝ≥0, Tendsto (fun i => (μs i).testAgainstNN f) F (𝓝 (μ.testAgainstNN f)) := by rw [FiniteMeasure.tendsto_iff_forall_toWeakDualBCNN_tendsto]; rfl #align measure_theory.finite_measure.tendsto_iff_forall_test_against_nn_tendsto MeasureTheory.FiniteMeasure.tendsto_iff_forall_testAgainstNN_tendsto
Mathlib/MeasureTheory/Measure/FiniteMeasure.lean
522
535
theorem tendsto_zero_testAgainstNN_of_tendsto_zero_mass {γ : Type*} {F : Filter γ} {μs : γ → FiniteMeasure Ω} (mass_lim : Tendsto (fun i => (μs i).mass) F (𝓝 0)) (f : Ω →ᵇ ℝ≥0) : Tendsto (fun i => (μs i).testAgainstNN f) F (𝓝 0) := by
apply tendsto_iff_dist_tendsto_zero.mpr have obs := fun i => (μs i).testAgainstNN_lipschitz_estimate f 0 simp_rw [testAgainstNN_zero, zero_add] at obs simp_rw [show ∀ i, dist ((μs i).testAgainstNN f) 0 = (μs i).testAgainstNN f by simp only [dist_nndist, NNReal.nndist_zero_eq_val', eq_self_iff_true, imp_true_iff]] refine squeeze_zero (fun i => NNReal.coe_nonneg _) obs ?_ have lim_pair : Tendsto (fun i => (⟨nndist f 0, (μs i).mass⟩ : ℝ × ℝ)) F (𝓝 ⟨nndist f 0, 0⟩) := by refine (Prod.tendsto_iff _ _).mpr ⟨tendsto_const_nhds, ?_⟩ exact (NNReal.continuous_coe.tendsto 0).comp mass_lim have key := tendsto_mul.comp lim_pair rwa [mul_zero] at key
import Mathlib.Combinatorics.SimpleGraph.Finite import Mathlib.Combinatorics.SimpleGraph.Maps #align_import combinatorics.simple_graph.subgraph from "leanprover-community/mathlib"@"c6ef6387ede9983aee397d442974e61f89dfd87b" universe u v namespace SimpleGraph @[ext] structure Subgraph {V : Type u} (G : SimpleGraph V) where verts : Set V Adj : V → V → Prop adj_sub : ∀ {v w : V}, Adj v w → G.Adj v w edge_vert : ∀ {v w : V}, Adj v w → v ∈ verts symm : Symmetric Adj := by aesop_graph -- Porting note: Originally `by obviously` #align simple_graph.subgraph SimpleGraph.Subgraph initialize_simps_projections SimpleGraph.Subgraph (Adj → adj) variable {ι : Sort*} {V : Type u} {W : Type v} @[simps] protected def singletonSubgraph (G : SimpleGraph V) (v : V) : G.Subgraph where verts := {v} Adj := ⊥ adj_sub := False.elim edge_vert := False.elim symm _ _ := False.elim #align simple_graph.singleton_subgraph SimpleGraph.singletonSubgraph @[simps] def subgraphOfAdj (G : SimpleGraph V) {v w : V} (hvw : G.Adj v w) : G.Subgraph where verts := {v, w} Adj a b := s(v, w) = s(a, b) adj_sub h := by rw [← G.mem_edgeSet, ← h] exact hvw edge_vert {a b} h := by apply_fun fun e ↦ a ∈ e at h simp only [Sym2.mem_iff, true_or, eq_iff_iff, iff_true] at h exact h #align simple_graph.subgraph_of_adj SimpleGraph.subgraphOfAdj namespace Subgraph variable {G : SimpleGraph V} {G₁ G₂ : G.Subgraph} {a b : V} protected theorem loopless (G' : Subgraph G) : Irreflexive G'.Adj := fun v h ↦ G.loopless v (G'.adj_sub h) #align simple_graph.subgraph.loopless SimpleGraph.Subgraph.loopless theorem adj_comm (G' : Subgraph G) (v w : V) : G'.Adj v w ↔ G'.Adj w v := ⟨fun x ↦ G'.symm x, fun x ↦ G'.symm x⟩ #align simple_graph.subgraph.adj_comm SimpleGraph.Subgraph.adj_comm @[symm] theorem adj_symm (G' : Subgraph G) {u v : V} (h : G'.Adj u v) : G'.Adj v u := G'.symm h #align simple_graph.subgraph.adj_symm SimpleGraph.Subgraph.adj_symm protected theorem Adj.symm {G' : Subgraph G} {u v : V} (h : G'.Adj u v) : G'.Adj v u := G'.symm h #align simple_graph.subgraph.adj.symm SimpleGraph.Subgraph.Adj.symm protected theorem Adj.adj_sub {H : G.Subgraph} {u v : V} (h : H.Adj u v) : G.Adj u v := H.adj_sub h #align simple_graph.subgraph.adj.adj_sub SimpleGraph.Subgraph.Adj.adj_sub protected theorem Adj.fst_mem {H : G.Subgraph} {u v : V} (h : H.Adj u v) : u ∈ H.verts := H.edge_vert h #align simple_graph.subgraph.adj.fst_mem SimpleGraph.Subgraph.Adj.fst_mem protected theorem Adj.snd_mem {H : G.Subgraph} {u v : V} (h : H.Adj u v) : v ∈ H.verts := h.symm.fst_mem #align simple_graph.subgraph.adj.snd_mem SimpleGraph.Subgraph.Adj.snd_mem protected theorem Adj.ne {H : G.Subgraph} {u v : V} (h : H.Adj u v) : u ≠ v := h.adj_sub.ne #align simple_graph.subgraph.adj.ne SimpleGraph.Subgraph.Adj.ne @[simps] protected def coe (G' : Subgraph G) : SimpleGraph G'.verts where Adj v w := G'.Adj v w symm _ _ h := G'.symm h loopless v h := loopless G v (G'.adj_sub h) #align simple_graph.subgraph.coe SimpleGraph.Subgraph.coe @[simp] theorem coe_adj_sub (G' : Subgraph G) (u v : G'.verts) (h : G'.coe.Adj u v) : G.Adj u v := G'.adj_sub h #align simple_graph.subgraph.coe_adj_sub SimpleGraph.Subgraph.coe_adj_sub -- Given `h : H.Adj u v`, then `h.coe : H.coe.Adj ⟨u, _⟩ ⟨v, _⟩`. protected theorem Adj.coe {H : G.Subgraph} {u v : V} (h : H.Adj u v) : H.coe.Adj ⟨u, H.edge_vert h⟩ ⟨v, H.edge_vert h.symm⟩ := h #align simple_graph.subgraph.adj.coe SimpleGraph.Subgraph.Adj.coe def IsSpanning (G' : Subgraph G) : Prop := ∀ v : V, v ∈ G'.verts #align simple_graph.subgraph.is_spanning SimpleGraph.Subgraph.IsSpanning theorem isSpanning_iff {G' : Subgraph G} : G'.IsSpanning ↔ G'.verts = Set.univ := Set.eq_univ_iff_forall.symm #align simple_graph.subgraph.is_spanning_iff SimpleGraph.Subgraph.isSpanning_iff @[simps] protected def spanningCoe (G' : Subgraph G) : SimpleGraph V where Adj := G'.Adj symm := G'.symm loopless v hv := G.loopless v (G'.adj_sub hv) #align simple_graph.subgraph.spanning_coe SimpleGraph.Subgraph.spanningCoe @[simp] theorem Adj.of_spanningCoe {G' : Subgraph G} {u v : G'.verts} (h : G'.spanningCoe.Adj u v) : G.Adj u v := G'.adj_sub h #align simple_graph.subgraph.adj.of_spanning_coe SimpleGraph.Subgraph.Adj.of_spanningCoe theorem spanningCoe_inj : G₁.spanningCoe = G₂.spanningCoe ↔ G₁.Adj = G₂.Adj := by simp [Subgraph.spanningCoe] #align simple_graph.subgraph.spanning_coe_inj SimpleGraph.Subgraph.spanningCoe_inj @[simps] def spanningCoeEquivCoeOfSpanning (G' : Subgraph G) (h : G'.IsSpanning) : G'.spanningCoe ≃g G'.coe where toFun v := ⟨v, h v⟩ invFun v := v left_inv _ := rfl right_inv _ := rfl map_rel_iff' := Iff.rfl #align simple_graph.subgraph.spanning_coe_equiv_coe_of_spanning SimpleGraph.Subgraph.spanningCoeEquivCoeOfSpanning def IsInduced (G' : Subgraph G) : Prop := ∀ {v w : V}, v ∈ G'.verts → w ∈ G'.verts → G.Adj v w → G'.Adj v w #align simple_graph.subgraph.is_induced SimpleGraph.Subgraph.IsInduced def support (H : Subgraph G) : Set V := Rel.dom H.Adj #align simple_graph.subgraph.support SimpleGraph.Subgraph.support theorem mem_support (H : Subgraph G) {v : V} : v ∈ H.support ↔ ∃ w, H.Adj v w := Iff.rfl #align simple_graph.subgraph.mem_support SimpleGraph.Subgraph.mem_support theorem support_subset_verts (H : Subgraph G) : H.support ⊆ H.verts := fun _ ⟨_, h⟩ ↦ H.edge_vert h #align simple_graph.subgraph.support_subset_verts SimpleGraph.Subgraph.support_subset_verts def neighborSet (G' : Subgraph G) (v : V) : Set V := {w | G'.Adj v w} #align simple_graph.subgraph.neighbor_set SimpleGraph.Subgraph.neighborSet theorem neighborSet_subset (G' : Subgraph G) (v : V) : G'.neighborSet v ⊆ G.neighborSet v := fun _ ↦ G'.adj_sub #align simple_graph.subgraph.neighbor_set_subset SimpleGraph.Subgraph.neighborSet_subset theorem neighborSet_subset_verts (G' : Subgraph G) (v : V) : G'.neighborSet v ⊆ G'.verts := fun _ h ↦ G'.edge_vert (adj_symm G' h) #align simple_graph.subgraph.neighbor_set_subset_verts SimpleGraph.Subgraph.neighborSet_subset_verts @[simp] theorem mem_neighborSet (G' : Subgraph G) (v w : V) : w ∈ G'.neighborSet v ↔ G'.Adj v w := Iff.rfl #align simple_graph.subgraph.mem_neighbor_set SimpleGraph.Subgraph.mem_neighborSet def coeNeighborSetEquiv {G' : Subgraph G} (v : G'.verts) : G'.coe.neighborSet v ≃ G'.neighborSet v where toFun w := ⟨w, w.2⟩ invFun w := ⟨⟨w, G'.edge_vert (G'.adj_symm w.2)⟩, w.2⟩ left_inv _ := rfl right_inv _ := rfl #align simple_graph.subgraph.coe_neighbor_set_equiv SimpleGraph.Subgraph.coeNeighborSetEquiv def edgeSet (G' : Subgraph G) : Set (Sym2 V) := Sym2.fromRel G'.symm #align simple_graph.subgraph.edge_set SimpleGraph.Subgraph.edgeSet theorem edgeSet_subset (G' : Subgraph G) : G'.edgeSet ⊆ G.edgeSet := Sym2.ind (fun _ _ ↦ G'.adj_sub) #align simple_graph.subgraph.edge_set_subset SimpleGraph.Subgraph.edgeSet_subset @[simp] theorem mem_edgeSet {G' : Subgraph G} {v w : V} : s(v, w) ∈ G'.edgeSet ↔ G'.Adj v w := Iff.rfl #align simple_graph.subgraph.mem_edge_set SimpleGraph.Subgraph.mem_edgeSet theorem mem_verts_if_mem_edge {G' : Subgraph G} {e : Sym2 V} {v : V} (he : e ∈ G'.edgeSet) (hv : v ∈ e) : v ∈ G'.verts := by revert hv refine Sym2.ind (fun v w he ↦ ?_) e he intro hv rcases Sym2.mem_iff.mp hv with (rfl | rfl) · exact G'.edge_vert he · exact G'.edge_vert (G'.symm he) #align simple_graph.subgraph.mem_verts_if_mem_edge SimpleGraph.Subgraph.mem_verts_if_mem_edge def incidenceSet (G' : Subgraph G) (v : V) : Set (Sym2 V) := {e ∈ G'.edgeSet | v ∈ e} #align simple_graph.subgraph.incidence_set SimpleGraph.Subgraph.incidenceSet theorem incidenceSet_subset_incidenceSet (G' : Subgraph G) (v : V) : G'.incidenceSet v ⊆ G.incidenceSet v := fun _ h ↦ ⟨G'.edgeSet_subset h.1, h.2⟩ #align simple_graph.subgraph.incidence_set_subset_incidence_set SimpleGraph.Subgraph.incidenceSet_subset_incidenceSet theorem incidenceSet_subset (G' : Subgraph G) (v : V) : G'.incidenceSet v ⊆ G'.edgeSet := fun _ h ↦ h.1 #align simple_graph.subgraph.incidence_set_subset SimpleGraph.Subgraph.incidenceSet_subset abbrev vert (G' : Subgraph G) (v : V) (h : v ∈ G'.verts) : G'.verts := ⟨v, h⟩ #align simple_graph.subgraph.vert SimpleGraph.Subgraph.vert def copy (G' : Subgraph G) (V'' : Set V) (hV : V'' = G'.verts) (adj' : V → V → Prop) (hadj : adj' = G'.Adj) : Subgraph G where verts := V'' Adj := adj' adj_sub := hadj.symm ▸ G'.adj_sub edge_vert := hV.symm ▸ hadj.symm ▸ G'.edge_vert symm := hadj.symm ▸ G'.symm #align simple_graph.subgraph.copy SimpleGraph.Subgraph.copy theorem copy_eq (G' : Subgraph G) (V'' : Set V) (hV : V'' = G'.verts) (adj' : V → V → Prop) (hadj : adj' = G'.Adj) : G'.copy V'' hV adj' hadj = G' := Subgraph.ext _ _ hV hadj #align simple_graph.subgraph.copy_eq SimpleGraph.Subgraph.copy_eq instance : Sup G.Subgraph where sup G₁ G₂ := { verts := G₁.verts ∪ G₂.verts Adj := G₁.Adj ⊔ G₂.Adj adj_sub := fun hab => Or.elim hab (fun h => G₁.adj_sub h) fun h => G₂.adj_sub h edge_vert := Or.imp (fun h => G₁.edge_vert h) fun h => G₂.edge_vert h symm := fun _ _ => Or.imp G₁.adj_symm G₂.adj_symm } instance : Inf G.Subgraph where inf G₁ G₂ := { verts := G₁.verts ∩ G₂.verts Adj := G₁.Adj ⊓ G₂.Adj adj_sub := fun hab => G₁.adj_sub hab.1 edge_vert := And.imp (fun h => G₁.edge_vert h) fun h => G₂.edge_vert h symm := fun _ _ => And.imp G₁.adj_symm G₂.adj_symm } instance : Top G.Subgraph where top := { verts := Set.univ Adj := G.Adj adj_sub := id edge_vert := @fun v _ _ => Set.mem_univ v symm := G.symm } instance : Bot G.Subgraph where bot := { verts := ∅ Adj := ⊥ adj_sub := False.elim edge_vert := False.elim symm := fun _ _ => id } instance : SupSet G.Subgraph where sSup s := { verts := ⋃ G' ∈ s, verts G' Adj := fun a b => ∃ G' ∈ s, Adj G' a b adj_sub := by rintro a b ⟨G', -, hab⟩ exact G'.adj_sub hab edge_vert := by rintro a b ⟨G', hG', hab⟩ exact Set.mem_iUnion₂_of_mem hG' (G'.edge_vert hab) symm := fun a b h => by simpa [adj_comm] using h } instance : InfSet G.Subgraph where sInf s := { verts := ⋂ G' ∈ s, verts G' Adj := fun a b => (∀ ⦃G'⦄, G' ∈ s → Adj G' a b) ∧ G.Adj a b adj_sub := And.right edge_vert := fun hab => Set.mem_iInter₂_of_mem fun G' hG' => G'.edge_vert <| hab.1 hG' symm := fun _ _ => And.imp (forall₂_imp fun _ _ => Adj.symm) G.adj_symm } @[simp] theorem sup_adj : (G₁ ⊔ G₂).Adj a b ↔ G₁.Adj a b ∨ G₂.Adj a b := Iff.rfl #align simple_graph.subgraph.sup_adj SimpleGraph.Subgraph.sup_adj @[simp] theorem inf_adj : (G₁ ⊓ G₂).Adj a b ↔ G₁.Adj a b ∧ G₂.Adj a b := Iff.rfl #align simple_graph.subgraph.inf_adj SimpleGraph.Subgraph.inf_adj @[simp] theorem top_adj : (⊤ : Subgraph G).Adj a b ↔ G.Adj a b := Iff.rfl #align simple_graph.subgraph.top_adj SimpleGraph.Subgraph.top_adj @[simp] theorem not_bot_adj : ¬ (⊥ : Subgraph G).Adj a b := not_false #align simple_graph.subgraph.not_bot_adj SimpleGraph.Subgraph.not_bot_adj @[simp] theorem verts_sup (G₁ G₂ : G.Subgraph) : (G₁ ⊔ G₂).verts = G₁.verts ∪ G₂.verts := rfl #align simple_graph.subgraph.verts_sup SimpleGraph.Subgraph.verts_sup @[simp] theorem verts_inf (G₁ G₂ : G.Subgraph) : (G₁ ⊓ G₂).verts = G₁.verts ∩ G₂.verts := rfl #align simple_graph.subgraph.verts_inf SimpleGraph.Subgraph.verts_inf @[simp] theorem verts_top : (⊤ : G.Subgraph).verts = Set.univ := rfl #align simple_graph.subgraph.verts_top SimpleGraph.Subgraph.verts_top @[simp] theorem verts_bot : (⊥ : G.Subgraph).verts = ∅ := rfl #align simple_graph.subgraph.verts_bot SimpleGraph.Subgraph.verts_bot @[simp] theorem sSup_adj {s : Set G.Subgraph} : (sSup s).Adj a b ↔ ∃ G ∈ s, Adj G a b := Iff.rfl #align simple_graph.subgraph.Sup_adj SimpleGraph.Subgraph.sSup_adj @[simp] theorem sInf_adj {s : Set G.Subgraph} : (sInf s).Adj a b ↔ (∀ G' ∈ s, Adj G' a b) ∧ G.Adj a b := Iff.rfl #align simple_graph.subgraph.Inf_adj SimpleGraph.Subgraph.sInf_adj @[simp] theorem iSup_adj {f : ι → G.Subgraph} : (⨆ i, f i).Adj a b ↔ ∃ i, (f i).Adj a b := by simp [iSup] #align simple_graph.subgraph.supr_adj SimpleGraph.Subgraph.iSup_adj @[simp] theorem iInf_adj {f : ι → G.Subgraph} : (⨅ i, f i).Adj a b ↔ (∀ i, (f i).Adj a b) ∧ G.Adj a b := by simp [iInf] #align simple_graph.subgraph.infi_adj SimpleGraph.Subgraph.iInf_adj theorem sInf_adj_of_nonempty {s : Set G.Subgraph} (hs : s.Nonempty) : (sInf s).Adj a b ↔ ∀ G' ∈ s, Adj G' a b := sInf_adj.trans <| and_iff_left_of_imp <| by obtain ⟨G', hG'⟩ := hs exact fun h => G'.adj_sub (h _ hG') #align simple_graph.subgraph.Inf_adj_of_nonempty SimpleGraph.Subgraph.sInf_adj_of_nonempty theorem iInf_adj_of_nonempty [Nonempty ι] {f : ι → G.Subgraph} : (⨅ i, f i).Adj a b ↔ ∀ i, (f i).Adj a b := by rw [iInf, sInf_adj_of_nonempty (Set.range_nonempty _)] simp #align simple_graph.subgraph.infi_adj_of_nonempty SimpleGraph.Subgraph.iInf_adj_of_nonempty @[simp] theorem verts_sSup (s : Set G.Subgraph) : (sSup s).verts = ⋃ G' ∈ s, verts G' := rfl #align simple_graph.subgraph.verts_Sup SimpleGraph.Subgraph.verts_sSup @[simp] theorem verts_sInf (s : Set G.Subgraph) : (sInf s).verts = ⋂ G' ∈ s, verts G' := rfl #align simple_graph.subgraph.verts_Inf SimpleGraph.Subgraph.verts_sInf @[simp] theorem verts_iSup {f : ι → G.Subgraph} : (⨆ i, f i).verts = ⋃ i, (f i).verts := by simp [iSup] #align simple_graph.subgraph.verts_supr SimpleGraph.Subgraph.verts_iSup @[simp] theorem verts_iInf {f : ι → G.Subgraph} : (⨅ i, f i).verts = ⋂ i, (f i).verts := by simp [iInf] #align simple_graph.subgraph.verts_infi SimpleGraph.Subgraph.verts_iInf theorem verts_spanningCoe_injective : (fun G' : Subgraph G => (G'.verts, G'.spanningCoe)).Injective := by intro G₁ G₂ h rw [Prod.ext_iff] at h exact Subgraph.ext _ _ h.1 (spanningCoe_inj.1 h.2) instance distribLattice : DistribLattice G.Subgraph := { show DistribLattice G.Subgraph from verts_spanningCoe_injective.distribLattice _ (fun _ _ => rfl) fun _ _ => rfl with le := fun x y => x.verts ⊆ y.verts ∧ ∀ ⦃v w : V⦄, x.Adj v w → y.Adj v w } instance : BoundedOrder (Subgraph G) where top := ⊤ bot := ⊥ le_top x := ⟨Set.subset_univ _, fun _ _ => x.adj_sub⟩ bot_le _ := ⟨Set.empty_subset _, fun _ _ => False.elim⟩ -- Note that subgraphs do not form a Boolean algebra, because of `verts`. instance : CompletelyDistribLattice G.Subgraph := { Subgraph.distribLattice with le := (· ≤ ·) sup := (· ⊔ ·) inf := (· ⊓ ·) top := ⊤ bot := ⊥ le_top := fun G' => ⟨Set.subset_univ _, fun a b => G'.adj_sub⟩ bot_le := fun G' => ⟨Set.empty_subset _, fun a b => False.elim⟩ sSup := sSup -- Porting note: needed `apply` here to modify elaboration; previously the term itself was fine. le_sSup := fun s G' hG' => ⟨by apply Set.subset_iUnion₂ G' hG', fun a b hab => ⟨G', hG', hab⟩⟩ sSup_le := fun s G' hG' => ⟨Set.iUnion₂_subset fun H hH => (hG' _ hH).1, by rintro a b ⟨H, hH, hab⟩ exact (hG' _ hH).2 hab⟩ sInf := sInf sInf_le := fun s G' hG' => ⟨Set.iInter₂_subset G' hG', fun a b hab => hab.1 hG'⟩ le_sInf := fun s G' hG' => ⟨Set.subset_iInter₂ fun H hH => (hG' _ hH).1, fun a b hab => ⟨fun H hH => (hG' _ hH).2 hab, G'.adj_sub hab⟩⟩ iInf_iSup_eq := fun f => Subgraph.ext _ _ (by simpa using iInf_iSup_eq) (by ext; simp [Classical.skolem]) } @[simps] instance subgraphInhabited : Inhabited (Subgraph G) := ⟨⊥⟩ #align simple_graph.subgraph.subgraph_inhabited SimpleGraph.Subgraph.subgraphInhabited @[simp] theorem neighborSet_sup {H H' : G.Subgraph} (v : V) : (H ⊔ H').neighborSet v = H.neighborSet v ∪ H'.neighborSet v := rfl #align simple_graph.subgraph.neighbor_set_sup SimpleGraph.Subgraph.neighborSet_sup @[simp] theorem neighborSet_inf {H H' : G.Subgraph} (v : V) : (H ⊓ H').neighborSet v = H.neighborSet v ∩ H'.neighborSet v := rfl #align simple_graph.subgraph.neighbor_set_inf SimpleGraph.Subgraph.neighborSet_inf @[simp] theorem neighborSet_top (v : V) : (⊤ : G.Subgraph).neighborSet v = G.neighborSet v := rfl #align simple_graph.subgraph.neighbor_set_top SimpleGraph.Subgraph.neighborSet_top @[simp] theorem neighborSet_bot (v : V) : (⊥ : G.Subgraph).neighborSet v = ∅ := rfl #align simple_graph.subgraph.neighbor_set_bot SimpleGraph.Subgraph.neighborSet_bot @[simp] theorem neighborSet_sSup (s : Set G.Subgraph) (v : V) : (sSup s).neighborSet v = ⋃ G' ∈ s, neighborSet G' v := by ext simp #align simple_graph.subgraph.neighbor_set_Sup SimpleGraph.Subgraph.neighborSet_sSup @[simp] theorem neighborSet_sInf (s : Set G.Subgraph) (v : V) : (sInf s).neighborSet v = (⋂ G' ∈ s, neighborSet G' v) ∩ G.neighborSet v := by ext simp #align simple_graph.subgraph.neighbor_set_Inf SimpleGraph.Subgraph.neighborSet_sInf @[simp] theorem neighborSet_iSup (f : ι → G.Subgraph) (v : V) : (⨆ i, f i).neighborSet v = ⋃ i, (f i).neighborSet v := by simp [iSup] #align simple_graph.subgraph.neighbor_set_supr SimpleGraph.Subgraph.neighborSet_iSup @[simp] theorem neighborSet_iInf (f : ι → G.Subgraph) (v : V) : (⨅ i, f i).neighborSet v = (⋂ i, (f i).neighborSet v) ∩ G.neighborSet v := by simp [iInf] #align simple_graph.subgraph.neighbor_set_infi SimpleGraph.Subgraph.neighborSet_iInf @[simp] theorem edgeSet_top : (⊤ : Subgraph G).edgeSet = G.edgeSet := rfl #align simple_graph.subgraph.edge_set_top SimpleGraph.Subgraph.edgeSet_top @[simp] theorem edgeSet_bot : (⊥ : Subgraph G).edgeSet = ∅ := Set.ext <| Sym2.ind (by simp) #align simple_graph.subgraph.edge_set_bot SimpleGraph.Subgraph.edgeSet_bot @[simp] theorem edgeSet_inf {H₁ H₂ : Subgraph G} : (H₁ ⊓ H₂).edgeSet = H₁.edgeSet ∩ H₂.edgeSet := Set.ext <| Sym2.ind (by simp) #align simple_graph.subgraph.edge_set_inf SimpleGraph.Subgraph.edgeSet_inf @[simp] theorem edgeSet_sup {H₁ H₂ : Subgraph G} : (H₁ ⊔ H₂).edgeSet = H₁.edgeSet ∪ H₂.edgeSet := Set.ext <| Sym2.ind (by simp) #align simple_graph.subgraph.edge_set_sup SimpleGraph.Subgraph.edgeSet_sup @[simp] theorem edgeSet_sSup (s : Set G.Subgraph) : (sSup s).edgeSet = ⋃ G' ∈ s, edgeSet G' := by ext e induction e using Sym2.ind simp #align simple_graph.subgraph.edge_set_Sup SimpleGraph.Subgraph.edgeSet_sSup @[simp] theorem edgeSet_sInf (s : Set G.Subgraph) : (sInf s).edgeSet = (⋂ G' ∈ s, edgeSet G') ∩ G.edgeSet := by ext e induction e using Sym2.ind simp #align simple_graph.subgraph.edge_set_Inf SimpleGraph.Subgraph.edgeSet_sInf @[simp] theorem edgeSet_iSup (f : ι → G.Subgraph) : (⨆ i, f i).edgeSet = ⋃ i, (f i).edgeSet := by simp [iSup] #align simple_graph.subgraph.edge_set_supr SimpleGraph.Subgraph.edgeSet_iSup @[simp] theorem edgeSet_iInf (f : ι → G.Subgraph) : (⨅ i, f i).edgeSet = (⋂ i, (f i).edgeSet) ∩ G.edgeSet := by simp [iInf] #align simple_graph.subgraph.edge_set_infi SimpleGraph.Subgraph.edgeSet_iInf @[simp] theorem spanningCoe_top : (⊤ : Subgraph G).spanningCoe = G := rfl #align simple_graph.subgraph.spanning_coe_top SimpleGraph.Subgraph.spanningCoe_top @[simp] theorem spanningCoe_bot : (⊥ : Subgraph G).spanningCoe = ⊥ := rfl #align simple_graph.subgraph.spanning_coe_bot SimpleGraph.Subgraph.spanningCoe_bot @[simps] def _root_.SimpleGraph.toSubgraph (H : SimpleGraph V) (h : H ≤ G) : G.Subgraph where verts := Set.univ Adj := H.Adj adj_sub e := h e edge_vert _ := Set.mem_univ _ symm := H.symm #align simple_graph.to_subgraph SimpleGraph.toSubgraph theorem support_mono {H H' : Subgraph G} (h : H ≤ H') : H.support ⊆ H'.support := Rel.dom_mono h.2 #align simple_graph.subgraph.support_mono SimpleGraph.Subgraph.support_mono theorem _root_.SimpleGraph.toSubgraph.isSpanning (H : SimpleGraph V) (h : H ≤ G) : (toSubgraph H h).IsSpanning := Set.mem_univ #align simple_graph.to_subgraph.is_spanning SimpleGraph.toSubgraph.isSpanning theorem spanningCoe_le_of_le {H H' : Subgraph G} (h : H ≤ H') : H.spanningCoe ≤ H'.spanningCoe := h.2 #align simple_graph.subgraph.spanning_coe_le_of_le SimpleGraph.Subgraph.spanningCoe_le_of_le def topEquiv : (⊤ : Subgraph G).coe ≃g G where toFun v := ↑v invFun v := ⟨v, trivial⟩ left_inv _ := rfl right_inv _ := rfl map_rel_iff' := Iff.rfl #align simple_graph.subgraph.top_equiv SimpleGraph.Subgraph.topEquiv def botEquiv : (⊥ : Subgraph G).coe ≃g (⊥ : SimpleGraph Empty) where toFun v := v.property.elim invFun v := v.elim left_inv := fun ⟨_, h⟩ ↦ h.elim right_inv v := v.elim map_rel_iff' := Iff.rfl #align simple_graph.subgraph.bot_equiv SimpleGraph.Subgraph.botEquiv theorem edgeSet_mono {H₁ H₂ : Subgraph G} (h : H₁ ≤ H₂) : H₁.edgeSet ≤ H₂.edgeSet := Sym2.ind h.2 #align simple_graph.subgraph.edge_set_mono SimpleGraph.Subgraph.edgeSet_mono theorem _root_.Disjoint.edgeSet {H₁ H₂ : Subgraph G} (h : Disjoint H₁ H₂) : Disjoint H₁.edgeSet H₂.edgeSet := disjoint_iff_inf_le.mpr <| by simpa using edgeSet_mono h.le_bot #align disjoint.edge_set Disjoint.edgeSet @[simps] protected def map {G' : SimpleGraph W} (f : G →g G') (H : G.Subgraph) : G'.Subgraph where verts := f '' H.verts Adj := Relation.Map H.Adj f f adj_sub := by rintro _ _ ⟨u, v, h, rfl, rfl⟩ exact f.map_rel (H.adj_sub h) edge_vert := by rintro _ _ ⟨u, v, h, rfl, rfl⟩ exact Set.mem_image_of_mem _ (H.edge_vert h) symm := by rintro _ _ ⟨u, v, h, rfl, rfl⟩ exact ⟨v, u, H.symm h, rfl, rfl⟩ #align simple_graph.subgraph.map SimpleGraph.Subgraph.map theorem map_monotone {G' : SimpleGraph W} (f : G →g G') : Monotone (Subgraph.map f) := by intro H H' h constructor · intro simp only [map_verts, Set.mem_image, forall_exists_index, and_imp] rintro v hv rfl exact ⟨_, h.1 hv, rfl⟩ · rintro _ _ ⟨u, v, ha, rfl, rfl⟩ exact ⟨_, _, h.2 ha, rfl, rfl⟩ #align simple_graph.subgraph.map_monotone SimpleGraph.Subgraph.map_monotone theorem map_sup {G : SimpleGraph V} {G' : SimpleGraph W} (f : G →g G') {H H' : G.Subgraph} : (H ⊔ H').map f = H.map f ⊔ H'.map f := by ext1 · simp only [Set.image_union, map_verts, verts_sup] · ext simp only [Relation.Map, map_adj, sup_adj] constructor · rintro ⟨a, b, h | h, rfl, rfl⟩ · exact Or.inl ⟨_, _, h, rfl, rfl⟩ · exact Or.inr ⟨_, _, h, rfl, rfl⟩ · rintro (⟨a, b, h, rfl, rfl⟩ | ⟨a, b, h, rfl, rfl⟩) · exact ⟨_, _, Or.inl h, rfl, rfl⟩ · exact ⟨_, _, Or.inr h, rfl, rfl⟩ #align simple_graph.subgraph.map_sup SimpleGraph.Subgraph.map_sup @[simps] protected def comap {G' : SimpleGraph W} (f : G →g G') (H : G'.Subgraph) : G.Subgraph where verts := f ⁻¹' H.verts Adj u v := G.Adj u v ∧ H.Adj (f u) (f v) adj_sub h := h.1 edge_vert h := Set.mem_preimage.1 (H.edge_vert h.2) symm _ _ h := ⟨G.symm h.1, H.symm h.2⟩ #align simple_graph.subgraph.comap SimpleGraph.Subgraph.comap
Mathlib/Combinatorics/SimpleGraph/Subgraph.lean
686
695
theorem comap_monotone {G' : SimpleGraph W} (f : G →g G') : Monotone (Subgraph.comap f) := by
intro H H' h constructor · intro simp only [comap_verts, Set.mem_preimage] apply h.1 · intro v w simp (config := { contextual := true }) only [comap_adj, and_imp, true_and_iff] intro apply h.2
import Mathlib.MeasureTheory.Integral.IntervalIntegral import Mathlib.Data.Set.Function #align_import analysis.sum_integral_comparisons from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" open Set MeasureTheory.MeasureSpace variable {x₀ : ℝ} {a b : ℕ} {f : ℝ → ℝ} theorem AntitoneOn.integral_le_sum (hf : AntitoneOn f (Icc x₀ (x₀ + a))) : (∫ x in x₀..x₀ + a, f x) ≤ ∑ i ∈ Finset.range a, f (x₀ + i) := by have hint : ∀ k : ℕ, k < a → IntervalIntegrable f volume (x₀ + k) (x₀ + (k + 1 : ℕ)) := by intro k hk refine (hf.mono ?_).intervalIntegrable rw [uIcc_of_le] · apply Icc_subset_Icc · simp only [le_add_iff_nonneg_right, Nat.cast_nonneg] · simp only [add_le_add_iff_left, Nat.cast_le, Nat.succ_le_of_lt hk] · simp only [add_le_add_iff_left, Nat.cast_le, Nat.le_succ] calc ∫ x in x₀..x₀ + a, f x = ∑ i ∈ Finset.range a, ∫ x in x₀ + i..x₀ + (i + 1 : ℕ), f x := by convert (intervalIntegral.sum_integral_adjacent_intervals hint).symm simp only [Nat.cast_zero, add_zero] _ ≤ ∑ i ∈ Finset.range a, ∫ _ in x₀ + i..x₀ + (i + 1 : ℕ), f (x₀ + i) := by apply Finset.sum_le_sum fun i hi => ?_ have ia : i < a := Finset.mem_range.1 hi refine intervalIntegral.integral_mono_on (by simp) (hint _ ia) (by simp) fun x hx => ?_ apply hf _ _ hx.1 · simp only [ia.le, mem_Icc, le_add_iff_nonneg_right, Nat.cast_nonneg, add_le_add_iff_left, Nat.cast_le, and_self_iff] · refine mem_Icc.2 ⟨le_trans (by simp) hx.1, le_trans hx.2 ?_⟩ simp only [add_le_add_iff_left, Nat.cast_le, Nat.succ_le_of_lt ia] _ = ∑ i ∈ Finset.range a, f (x₀ + i) := by simp #align antitone_on.integral_le_sum AntitoneOn.integral_le_sum theorem AntitoneOn.integral_le_sum_Ico (hab : a ≤ b) (hf : AntitoneOn f (Set.Icc a b)) : (∫ x in a..b, f x) ≤ ∑ x ∈ Finset.Ico a b, f x := by rw [(Nat.sub_add_cancel hab).symm, Nat.cast_add] conv => congr congr · skip · skip rw [add_comm] · skip · skip congr congr rw [← zero_add a] rw [← Finset.sum_Ico_add, Nat.Ico_zero_eq_range] conv => rhs congr · skip ext rw [Nat.cast_add] apply AntitoneOn.integral_le_sum simp only [hf, hab, Nat.cast_sub, add_sub_cancel] #align antitone_on.integral_le_sum_Ico AntitoneOn.integral_le_sum_Ico theorem AntitoneOn.sum_le_integral (hf : AntitoneOn f (Icc x₀ (x₀ + a))) : (∑ i ∈ Finset.range a, f (x₀ + (i + 1 : ℕ))) ≤ ∫ x in x₀..x₀ + a, f x := by have hint : ∀ k : ℕ, k < a → IntervalIntegrable f volume (x₀ + k) (x₀ + (k + 1 : ℕ)) := by intro k hk refine (hf.mono ?_).intervalIntegrable rw [uIcc_of_le] · apply Icc_subset_Icc · simp only [le_add_iff_nonneg_right, Nat.cast_nonneg] · simp only [add_le_add_iff_left, Nat.cast_le, Nat.succ_le_of_lt hk] · simp only [add_le_add_iff_left, Nat.cast_le, Nat.le_succ] calc (∑ i ∈ Finset.range a, f (x₀ + (i + 1 : ℕ))) = ∑ i ∈ Finset.range a, ∫ _ in x₀ + i..x₀ + (i + 1 : ℕ), f (x₀ + (i + 1 : ℕ)) := by simp _ ≤ ∑ i ∈ Finset.range a, ∫ x in x₀ + i..x₀ + (i + 1 : ℕ), f x := by apply Finset.sum_le_sum fun i hi => ?_ have ia : i + 1 ≤ a := Finset.mem_range.1 hi refine intervalIntegral.integral_mono_on (by simp) (by simp) (hint _ ia) fun x hx => ?_ apply hf _ _ hx.2 · refine mem_Icc.2 ⟨le_trans ((le_add_iff_nonneg_right _).2 (Nat.cast_nonneg _)) hx.1, le_trans hx.2 ?_⟩ simp only [Nat.cast_le, add_le_add_iff_left, ia] · refine mem_Icc.2 ⟨(le_add_iff_nonneg_right _).2 (Nat.cast_nonneg _), ?_⟩ simp only [add_le_add_iff_left, Nat.cast_le, ia] _ = ∫ x in x₀..x₀ + a, f x := by convert intervalIntegral.sum_integral_adjacent_intervals hint simp only [Nat.cast_zero, add_zero] #align antitone_on.sum_le_integral AntitoneOn.sum_le_integral theorem AntitoneOn.sum_le_integral_Ico (hab : a ≤ b) (hf : AntitoneOn f (Set.Icc a b)) : (∑ i ∈ Finset.Ico a b, f (i + 1 : ℕ)) ≤ ∫ x in a..b, f x := by rw [(Nat.sub_add_cancel hab).symm, Nat.cast_add] conv => congr congr congr rw [← zero_add a] · skip · skip · skip rw [add_comm] rw [← Finset.sum_Ico_add, Nat.Ico_zero_eq_range] conv => lhs congr congr · skip ext rw [add_assoc, Nat.cast_add] apply AntitoneOn.sum_le_integral simp only [hf, hab, Nat.cast_sub, add_sub_cancel] #align antitone_on.sum_le_integral_Ico AntitoneOn.sum_le_integral_Ico theorem MonotoneOn.sum_le_integral (hf : MonotoneOn f (Icc x₀ (x₀ + a))) : (∑ i ∈ Finset.range a, f (x₀ + i)) ≤ ∫ x in x₀..x₀ + a, f x := by rw [← neg_le_neg_iff, ← Finset.sum_neg_distrib, ← intervalIntegral.integral_neg] exact hf.neg.integral_le_sum #align monotone_on.sum_le_integral MonotoneOn.sum_le_integral
Mathlib/Analysis/SumIntegralComparisons.lean
156
159
theorem MonotoneOn.sum_le_integral_Ico (hab : a ≤ b) (hf : MonotoneOn f (Set.Icc a b)) : ∑ x ∈ Finset.Ico a b, f x ≤ ∫ x in a..b, f x := by
rw [← neg_le_neg_iff, ← Finset.sum_neg_distrib, ← intervalIntegral.integral_neg] exact hf.neg.integral_le_sum_Ico hab
import Mathlib.Topology.UniformSpace.CompleteSeparated import Mathlib.Topology.EMetricSpace.Lipschitz import Mathlib.Topology.MetricSpace.Basic import Mathlib.Topology.MetricSpace.Bounded #align_import topology.metric_space.antilipschitz from "leanprover-community/mathlib"@"c8f305514e0d47dfaa710f5a52f0d21b588e6328" variable {α β γ : Type*} open scoped NNReal ENNReal Uniformity Topology open Set Filter Bornology def AntilipschitzWith [PseudoEMetricSpace α] [PseudoEMetricSpace β] (K : ℝ≥0) (f : α → β) := ∀ x y, edist x y ≤ K * edist (f x) (f y) #align antilipschitz_with AntilipschitzWith theorem AntilipschitzWith.edist_lt_top [PseudoEMetricSpace α] [PseudoMetricSpace β] {K : ℝ≥0} {f : α → β} (h : AntilipschitzWith K f) (x y : α) : edist x y < ⊤ := (h x y).trans_lt <| ENNReal.mul_lt_top ENNReal.coe_ne_top (edist_ne_top _ _) #align antilipschitz_with.edist_lt_top AntilipschitzWith.edist_lt_top theorem AntilipschitzWith.edist_ne_top [PseudoEMetricSpace α] [PseudoMetricSpace β] {K : ℝ≥0} {f : α → β} (h : AntilipschitzWith K f) (x y : α) : edist x y ≠ ⊤ := (h.edist_lt_top x y).ne #align antilipschitz_with.edist_ne_top AntilipschitzWith.edist_ne_top section Metric variable [PseudoMetricSpace α] [PseudoMetricSpace β] {K : ℝ≥0} {f : α → β} theorem antilipschitzWith_iff_le_mul_nndist : AntilipschitzWith K f ↔ ∀ x y, nndist x y ≤ K * nndist (f x) (f y) := by simp only [AntilipschitzWith, edist_nndist] norm_cast #align antilipschitz_with_iff_le_mul_nndist antilipschitzWith_iff_le_mul_nndist alias ⟨AntilipschitzWith.le_mul_nndist, AntilipschitzWith.of_le_mul_nndist⟩ := antilipschitzWith_iff_le_mul_nndist #align antilipschitz_with.le_mul_nndist AntilipschitzWith.le_mul_nndist #align antilipschitz_with.of_le_mul_nndist AntilipschitzWith.of_le_mul_nndist theorem antilipschitzWith_iff_le_mul_dist : AntilipschitzWith K f ↔ ∀ x y, dist x y ≤ K * dist (f x) (f y) := by simp only [antilipschitzWith_iff_le_mul_nndist, dist_nndist] norm_cast #align antilipschitz_with_iff_le_mul_dist antilipschitzWith_iff_le_mul_dist alias ⟨AntilipschitzWith.le_mul_dist, AntilipschitzWith.of_le_mul_dist⟩ := antilipschitzWith_iff_le_mul_dist #align antilipschitz_with.le_mul_dist AntilipschitzWith.le_mul_dist #align antilipschitz_with.of_le_mul_dist AntilipschitzWith.of_le_mul_dist namespace AntilipschitzWith
Mathlib/Topology/MetricSpace/Antilipschitz.lean
77
79
theorem mul_le_nndist (hf : AntilipschitzWith K f) (x y : α) : K⁻¹ * nndist x y ≤ nndist (f x) (f y) := by
simpa only [div_eq_inv_mul] using NNReal.div_le_of_le_mul' (hf.le_mul_nndist x y)
import Mathlib.Data.Fintype.Option import Mathlib.Data.Fintype.Prod import Mathlib.Data.Fintype.Pi import Mathlib.Data.Vector.Basic import Mathlib.Data.PFun import Mathlib.Logic.Function.Iterate import Mathlib.Order.Basic import Mathlib.Tactic.ApplyFun #align_import computability.turing_machine from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" assert_not_exists MonoidWithZero open Relation open Nat (iterate) open Function (update iterate_succ iterate_succ_apply iterate_succ' iterate_succ_apply' iterate_zero_apply) namespace Turing def BlankExtends {Γ} [Inhabited Γ] (l₁ l₂ : List Γ) : Prop := ∃ n, l₂ = l₁ ++ List.replicate n default #align turing.blank_extends Turing.BlankExtends @[refl] theorem BlankExtends.refl {Γ} [Inhabited Γ] (l : List Γ) : BlankExtends l l := ⟨0, by simp⟩ #align turing.blank_extends.refl Turing.BlankExtends.refl @[trans] theorem BlankExtends.trans {Γ} [Inhabited Γ] {l₁ l₂ l₃ : List Γ} : BlankExtends l₁ l₂ → BlankExtends l₂ l₃ → BlankExtends l₁ l₃ := by rintro ⟨i, rfl⟩ ⟨j, rfl⟩ exact ⟨i + j, by simp [List.replicate_add]⟩ #align turing.blank_extends.trans Turing.BlankExtends.trans theorem BlankExtends.below_of_le {Γ} [Inhabited Γ] {l l₁ l₂ : List Γ} : BlankExtends l l₁ → BlankExtends l l₂ → l₁.length ≤ l₂.length → BlankExtends l₁ l₂ := by rintro ⟨i, rfl⟩ ⟨j, rfl⟩ h; use j - i simp only [List.length_append, Nat.add_le_add_iff_left, List.length_replicate] at h simp only [← List.replicate_add, Nat.add_sub_cancel' h, List.append_assoc] #align turing.blank_extends.below_of_le Turing.BlankExtends.below_of_le def BlankExtends.above {Γ} [Inhabited Γ] {l l₁ l₂ : List Γ} (h₁ : BlankExtends l l₁) (h₂ : BlankExtends l l₂) : { l' // BlankExtends l₁ l' ∧ BlankExtends l₂ l' } := if h : l₁.length ≤ l₂.length then ⟨l₂, h₁.below_of_le h₂ h, BlankExtends.refl _⟩ else ⟨l₁, BlankExtends.refl _, h₂.below_of_le h₁ (le_of_not_ge h)⟩ #align turing.blank_extends.above Turing.BlankExtends.above theorem BlankExtends.above_of_le {Γ} [Inhabited Γ] {l l₁ l₂ : List Γ} : BlankExtends l₁ l → BlankExtends l₂ l → l₁.length ≤ l₂.length → BlankExtends l₁ l₂ := by rintro ⟨i, rfl⟩ ⟨j, e⟩ h; use i - j refine List.append_cancel_right (e.symm.trans ?_) rw [List.append_assoc, ← List.replicate_add, Nat.sub_add_cancel] apply_fun List.length at e simp only [List.length_append, List.length_replicate] at e rwa [← Nat.add_le_add_iff_left, e, Nat.add_le_add_iff_right] #align turing.blank_extends.above_of_le Turing.BlankExtends.above_of_le def BlankRel {Γ} [Inhabited Γ] (l₁ l₂ : List Γ) : Prop := BlankExtends l₁ l₂ ∨ BlankExtends l₂ l₁ #align turing.blank_rel Turing.BlankRel @[refl] theorem BlankRel.refl {Γ} [Inhabited Γ] (l : List Γ) : BlankRel l l := Or.inl (BlankExtends.refl _) #align turing.blank_rel.refl Turing.BlankRel.refl @[symm] theorem BlankRel.symm {Γ} [Inhabited Γ] {l₁ l₂ : List Γ} : BlankRel l₁ l₂ → BlankRel l₂ l₁ := Or.symm #align turing.blank_rel.symm Turing.BlankRel.symm @[trans] theorem BlankRel.trans {Γ} [Inhabited Γ] {l₁ l₂ l₃ : List Γ} : BlankRel l₁ l₂ → BlankRel l₂ l₃ → BlankRel l₁ l₃ := by rintro (h₁ | h₁) (h₂ | h₂) · exact Or.inl (h₁.trans h₂) · rcases le_total l₁.length l₃.length with h | h · exact Or.inl (h₁.above_of_le h₂ h) · exact Or.inr (h₂.above_of_le h₁ h) · rcases le_total l₁.length l₃.length with h | h · exact Or.inl (h₁.below_of_le h₂ h) · exact Or.inr (h₂.below_of_le h₁ h) · exact Or.inr (h₂.trans h₁) #align turing.blank_rel.trans Turing.BlankRel.trans def BlankRel.above {Γ} [Inhabited Γ] {l₁ l₂ : List Γ} (h : BlankRel l₁ l₂) : { l // BlankExtends l₁ l ∧ BlankExtends l₂ l } := by refine if hl : l₁.length ≤ l₂.length then ⟨l₂, Or.elim h id fun h' ↦ ?_, BlankExtends.refl _⟩ else ⟨l₁, BlankExtends.refl _, Or.elim h (fun h' ↦ ?_) id⟩ · exact (BlankExtends.refl _).above_of_le h' hl · exact (BlankExtends.refl _).above_of_le h' (le_of_not_ge hl) #align turing.blank_rel.above Turing.BlankRel.above def BlankRel.below {Γ} [Inhabited Γ] {l₁ l₂ : List Γ} (h : BlankRel l₁ l₂) : { l // BlankExtends l l₁ ∧ BlankExtends l l₂ } := by refine if hl : l₁.length ≤ l₂.length then ⟨l₁, BlankExtends.refl _, Or.elim h id fun h' ↦ ?_⟩ else ⟨l₂, Or.elim h (fun h' ↦ ?_) id, BlankExtends.refl _⟩ · exact (BlankExtends.refl _).above_of_le h' hl · exact (BlankExtends.refl _).above_of_le h' (le_of_not_ge hl) #align turing.blank_rel.below Turing.BlankRel.below theorem BlankRel.equivalence (Γ) [Inhabited Γ] : Equivalence (@BlankRel Γ _) := ⟨BlankRel.refl, @BlankRel.symm _ _, @BlankRel.trans _ _⟩ #align turing.blank_rel.equivalence Turing.BlankRel.equivalence def BlankRel.setoid (Γ) [Inhabited Γ] : Setoid (List Γ) := ⟨_, BlankRel.equivalence _⟩ #align turing.blank_rel.setoid Turing.BlankRel.setoid def ListBlank (Γ) [Inhabited Γ] := Quotient (BlankRel.setoid Γ) #align turing.list_blank Turing.ListBlank instance ListBlank.inhabited {Γ} [Inhabited Γ] : Inhabited (ListBlank Γ) := ⟨Quotient.mk'' []⟩ #align turing.list_blank.inhabited Turing.ListBlank.inhabited instance ListBlank.hasEmptyc {Γ} [Inhabited Γ] : EmptyCollection (ListBlank Γ) := ⟨Quotient.mk'' []⟩ #align turing.list_blank.has_emptyc Turing.ListBlank.hasEmptyc -- Porting note: Removed `@[elab_as_elim]` protected abbrev ListBlank.liftOn {Γ} [Inhabited Γ] {α} (l : ListBlank Γ) (f : List Γ → α) (H : ∀ a b, BlankExtends a b → f a = f b) : α := l.liftOn' f <| by rintro a b (h | h) <;> [exact H _ _ h; exact (H _ _ h).symm] #align turing.list_blank.lift_on Turing.ListBlank.liftOn def ListBlank.mk {Γ} [Inhabited Γ] : List Γ → ListBlank Γ := Quotient.mk'' #align turing.list_blank.mk Turing.ListBlank.mk @[elab_as_elim] protected theorem ListBlank.induction_on {Γ} [Inhabited Γ] {p : ListBlank Γ → Prop} (q : ListBlank Γ) (h : ∀ a, p (ListBlank.mk a)) : p q := Quotient.inductionOn' q h #align turing.list_blank.induction_on Turing.ListBlank.induction_on def ListBlank.head {Γ} [Inhabited Γ] (l : ListBlank Γ) : Γ := by apply l.liftOn List.headI rintro a _ ⟨i, rfl⟩ cases a · cases i <;> rfl rfl #align turing.list_blank.head Turing.ListBlank.head @[simp] theorem ListBlank.head_mk {Γ} [Inhabited Γ] (l : List Γ) : ListBlank.head (ListBlank.mk l) = l.headI := rfl #align turing.list_blank.head_mk Turing.ListBlank.head_mk def ListBlank.tail {Γ} [Inhabited Γ] (l : ListBlank Γ) : ListBlank Γ := by apply l.liftOn (fun l ↦ ListBlank.mk l.tail) rintro a _ ⟨i, rfl⟩ refine Quotient.sound' (Or.inl ?_) cases a · cases' i with i <;> [exact ⟨0, rfl⟩; exact ⟨i, rfl⟩] exact ⟨i, rfl⟩ #align turing.list_blank.tail Turing.ListBlank.tail @[simp] theorem ListBlank.tail_mk {Γ} [Inhabited Γ] (l : List Γ) : ListBlank.tail (ListBlank.mk l) = ListBlank.mk l.tail := rfl #align turing.list_blank.tail_mk Turing.ListBlank.tail_mk def ListBlank.cons {Γ} [Inhabited Γ] (a : Γ) (l : ListBlank Γ) : ListBlank Γ := by apply l.liftOn (fun l ↦ ListBlank.mk (List.cons a l)) rintro _ _ ⟨i, rfl⟩ exact Quotient.sound' (Or.inl ⟨i, rfl⟩) #align turing.list_blank.cons Turing.ListBlank.cons @[simp] theorem ListBlank.cons_mk {Γ} [Inhabited Γ] (a : Γ) (l : List Γ) : ListBlank.cons a (ListBlank.mk l) = ListBlank.mk (a :: l) := rfl #align turing.list_blank.cons_mk Turing.ListBlank.cons_mk @[simp] theorem ListBlank.head_cons {Γ} [Inhabited Γ] (a : Γ) : ∀ l : ListBlank Γ, (l.cons a).head = a := Quotient.ind' fun _ ↦ rfl #align turing.list_blank.head_cons Turing.ListBlank.head_cons @[simp] theorem ListBlank.tail_cons {Γ} [Inhabited Γ] (a : Γ) : ∀ l : ListBlank Γ, (l.cons a).tail = l := Quotient.ind' fun _ ↦ rfl #align turing.list_blank.tail_cons Turing.ListBlank.tail_cons @[simp] theorem ListBlank.cons_head_tail {Γ} [Inhabited Γ] : ∀ l : ListBlank Γ, l.tail.cons l.head = l := by apply Quotient.ind' refine fun l ↦ Quotient.sound' (Or.inr ?_) cases l · exact ⟨1, rfl⟩ · rfl #align turing.list_blank.cons_head_tail Turing.ListBlank.cons_head_tail theorem ListBlank.exists_cons {Γ} [Inhabited Γ] (l : ListBlank Γ) : ∃ a l', l = ListBlank.cons a l' := ⟨_, _, (ListBlank.cons_head_tail _).symm⟩ #align turing.list_blank.exists_cons Turing.ListBlank.exists_cons def ListBlank.nth {Γ} [Inhabited Γ] (l : ListBlank Γ) (n : ℕ) : Γ := by apply l.liftOn (fun l ↦ List.getI l n) rintro l _ ⟨i, rfl⟩ cases' lt_or_le n _ with h h · rw [List.getI_append _ _ _ h] rw [List.getI_eq_default _ h] rcases le_or_lt _ n with h₂ | h₂ · rw [List.getI_eq_default _ h₂] rw [List.getI_eq_get _ h₂, List.get_append_right' h, List.get_replicate] #align turing.list_blank.nth Turing.ListBlank.nth @[simp] theorem ListBlank.nth_mk {Γ} [Inhabited Γ] (l : List Γ) (n : ℕ) : (ListBlank.mk l).nth n = l.getI n := rfl #align turing.list_blank.nth_mk Turing.ListBlank.nth_mk @[simp] theorem ListBlank.nth_zero {Γ} [Inhabited Γ] (l : ListBlank Γ) : l.nth 0 = l.head := by conv => lhs; rw [← ListBlank.cons_head_tail l] exact Quotient.inductionOn' l.tail fun l ↦ rfl #align turing.list_blank.nth_zero Turing.ListBlank.nth_zero @[simp] theorem ListBlank.nth_succ {Γ} [Inhabited Γ] (l : ListBlank Γ) (n : ℕ) : l.nth (n + 1) = l.tail.nth n := by conv => lhs; rw [← ListBlank.cons_head_tail l] exact Quotient.inductionOn' l.tail fun l ↦ rfl #align turing.list_blank.nth_succ Turing.ListBlank.nth_succ @[ext] theorem ListBlank.ext {Γ} [i : Inhabited Γ] {L₁ L₂ : ListBlank Γ} : (∀ i, L₁.nth i = L₂.nth i) → L₁ = L₂ := by refine ListBlank.induction_on L₁ fun l₁ ↦ ListBlank.induction_on L₂ fun l₂ H ↦ ?_ wlog h : l₁.length ≤ l₂.length · cases le_total l₁.length l₂.length <;> [skip; symm] <;> apply this <;> try assumption intro rw [H] refine Quotient.sound' (Or.inl ⟨l₂.length - l₁.length, ?_⟩) refine List.ext_get ?_ fun i h h₂ ↦ Eq.symm ?_ · simp only [Nat.add_sub_cancel' h, List.length_append, List.length_replicate] simp only [ListBlank.nth_mk] at H cases' lt_or_le i l₁.length with h' h' · simp only [List.get_append _ h', List.get?_eq_get h, List.get?_eq_get h', ← List.getI_eq_get _ h, ← List.getI_eq_get _ h', H] · simp only [List.get_append_right' h', List.get_replicate, List.get?_eq_get h, List.get?_len_le h', ← List.getI_eq_default _ h', H, List.getI_eq_get _ h] #align turing.list_blank.ext Turing.ListBlank.ext @[simp] def ListBlank.modifyNth {Γ} [Inhabited Γ] (f : Γ → Γ) : ℕ → ListBlank Γ → ListBlank Γ | 0, L => L.tail.cons (f L.head) | n + 1, L => (L.tail.modifyNth f n).cons L.head #align turing.list_blank.modify_nth Turing.ListBlank.modifyNth theorem ListBlank.nth_modifyNth {Γ} [Inhabited Γ] (f : Γ → Γ) (n i) (L : ListBlank Γ) : (L.modifyNth f n).nth i = if i = n then f (L.nth i) else L.nth i := by induction' n with n IH generalizing i L · cases i <;> simp only [ListBlank.nth_zero, if_true, ListBlank.head_cons, ListBlank.modifyNth, ListBlank.nth_succ, if_false, ListBlank.tail_cons, Nat.zero_eq] · cases i · rw [if_neg (Nat.succ_ne_zero _).symm] simp only [ListBlank.nth_zero, ListBlank.head_cons, ListBlank.modifyNth, Nat.zero_eq] · simp only [IH, ListBlank.modifyNth, ListBlank.nth_succ, ListBlank.tail_cons, Nat.succ.injEq] #align turing.list_blank.nth_modify_nth Turing.ListBlank.nth_modifyNth structure PointedMap.{u, v} (Γ : Type u) (Γ' : Type v) [Inhabited Γ] [Inhabited Γ'] : Type max u v where f : Γ → Γ' map_pt' : f default = default #align turing.pointed_map Turing.PointedMap instance {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] : Inhabited (PointedMap Γ Γ') := ⟨⟨default, rfl⟩⟩ instance {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] : CoeFun (PointedMap Γ Γ') fun _ ↦ Γ → Γ' := ⟨PointedMap.f⟩ -- @[simp] -- Porting note (#10685): dsimp can prove this theorem PointedMap.mk_val {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : Γ → Γ') (pt) : (PointedMap.mk f pt : Γ → Γ') = f := rfl #align turing.pointed_map.mk_val Turing.PointedMap.mk_val @[simp] theorem PointedMap.map_pt {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') : f default = default := PointedMap.map_pt' _ #align turing.pointed_map.map_pt Turing.PointedMap.map_pt @[simp] theorem PointedMap.headI_map {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : List Γ) : (l.map f).headI = f l.headI := by cases l <;> [exact (PointedMap.map_pt f).symm; rfl] #align turing.pointed_map.head_map Turing.PointedMap.headI_map def ListBlank.map {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : ListBlank Γ) : ListBlank Γ' := by apply l.liftOn (fun l ↦ ListBlank.mk (List.map f l)) rintro l _ ⟨i, rfl⟩; refine Quotient.sound' (Or.inl ⟨i, ?_⟩) simp only [PointedMap.map_pt, List.map_append, List.map_replicate] #align turing.list_blank.map Turing.ListBlank.map @[simp] theorem ListBlank.map_mk {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : List Γ) : (ListBlank.mk l).map f = ListBlank.mk (l.map f) := rfl #align turing.list_blank.map_mk Turing.ListBlank.map_mk @[simp] theorem ListBlank.head_map {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : ListBlank Γ) : (l.map f).head = f l.head := by conv => lhs; rw [← ListBlank.cons_head_tail l] exact Quotient.inductionOn' l fun a ↦ rfl #align turing.list_blank.head_map Turing.ListBlank.head_map @[simp] theorem ListBlank.tail_map {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : ListBlank Γ) : (l.map f).tail = l.tail.map f := by conv => lhs; rw [← ListBlank.cons_head_tail l] exact Quotient.inductionOn' l fun a ↦ rfl #align turing.list_blank.tail_map Turing.ListBlank.tail_map @[simp] theorem ListBlank.map_cons {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : ListBlank Γ) (a : Γ) : (l.cons a).map f = (l.map f).cons (f a) := by refine (ListBlank.cons_head_tail _).symm.trans ?_ simp only [ListBlank.head_map, ListBlank.head_cons, ListBlank.tail_map, ListBlank.tail_cons] #align turing.list_blank.map_cons Turing.ListBlank.map_cons @[simp] theorem ListBlank.nth_map {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : ListBlank Γ) (n : ℕ) : (l.map f).nth n = f (l.nth n) := by refine l.inductionOn fun l ↦ ?_ -- Porting note: Added `suffices` to get `simp` to work. suffices ((mk l).map f).nth n = f ((mk l).nth n) by exact this simp only [List.get?_map, ListBlank.map_mk, ListBlank.nth_mk, List.getI_eq_iget_get?] cases l.get? n · exact f.2.symm · rfl #align turing.list_blank.nth_map Turing.ListBlank.nth_map def proj {ι : Type*} {Γ : ι → Type*} [∀ i, Inhabited (Γ i)] (i : ι) : PointedMap (∀ i, Γ i) (Γ i) := ⟨fun a ↦ a i, rfl⟩ #align turing.proj Turing.proj theorem proj_map_nth {ι : Type*} {Γ : ι → Type*} [∀ i, Inhabited (Γ i)] (i : ι) (L n) : (ListBlank.map (@proj ι Γ _ i) L).nth n = L.nth n i := by rw [ListBlank.nth_map]; rfl #align turing.proj_map_nth Turing.proj_map_nth theorem ListBlank.map_modifyNth {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (F : PointedMap Γ Γ') (f : Γ → Γ) (f' : Γ' → Γ') (H : ∀ x, F (f x) = f' (F x)) (n) (L : ListBlank Γ) : (L.modifyNth f n).map F = (L.map F).modifyNth f' n := by induction' n with n IH generalizing L <;> simp only [*, ListBlank.head_map, ListBlank.modifyNth, ListBlank.map_cons, ListBlank.tail_map] #align turing.list_blank.map_modify_nth Turing.ListBlank.map_modifyNth @[simp] def ListBlank.append {Γ} [Inhabited Γ] : List Γ → ListBlank Γ → ListBlank Γ | [], L => L | a :: l, L => ListBlank.cons a (ListBlank.append l L) #align turing.list_blank.append Turing.ListBlank.append @[simp] theorem ListBlank.append_mk {Γ} [Inhabited Γ] (l₁ l₂ : List Γ) : ListBlank.append l₁ (ListBlank.mk l₂) = ListBlank.mk (l₁ ++ l₂) := by induction l₁ <;> simp only [*, ListBlank.append, List.nil_append, List.cons_append, ListBlank.cons_mk] #align turing.list_blank.append_mk Turing.ListBlank.append_mk theorem ListBlank.append_assoc {Γ} [Inhabited Γ] (l₁ l₂ : List Γ) (l₃ : ListBlank Γ) : ListBlank.append (l₁ ++ l₂) l₃ = ListBlank.append l₁ (ListBlank.append l₂ l₃) := by refine l₃.inductionOn fun l ↦ ?_ -- Porting note: Added `suffices` to get `simp` to work. suffices append (l₁ ++ l₂) (mk l) = append l₁ (append l₂ (mk l)) by exact this simp only [ListBlank.append_mk, List.append_assoc] #align turing.list_blank.append_assoc Turing.ListBlank.append_assoc def ListBlank.bind {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (l : ListBlank Γ) (f : Γ → List Γ') (hf : ∃ n, f default = List.replicate n default) : ListBlank Γ' := by apply l.liftOn (fun l ↦ ListBlank.mk (List.bind l f)) rintro l _ ⟨i, rfl⟩; cases' hf with n e; refine Quotient.sound' (Or.inl ⟨i * n, ?_⟩) rw [List.append_bind, mul_comm]; congr induction' i with i IH · rfl simp only [IH, e, List.replicate_add, Nat.mul_succ, add_comm, List.replicate_succ, List.cons_bind] #align turing.list_blank.bind Turing.ListBlank.bind @[simp] theorem ListBlank.bind_mk {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (l : List Γ) (f : Γ → List Γ') (hf) : (ListBlank.mk l).bind f hf = ListBlank.mk (l.bind f) := rfl #align turing.list_blank.bind_mk Turing.ListBlank.bind_mk @[simp] theorem ListBlank.cons_bind {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (a : Γ) (l : ListBlank Γ) (f : Γ → List Γ') (hf) : (l.cons a).bind f hf = (l.bind f hf).append (f a) := by refine l.inductionOn fun l ↦ ?_ -- Porting note: Added `suffices` to get `simp` to work. suffices ((mk l).cons a).bind f hf = ((mk l).bind f hf).append (f a) by exact this simp only [ListBlank.append_mk, ListBlank.bind_mk, ListBlank.cons_mk, List.cons_bind] #align turing.list_blank.cons_bind Turing.ListBlank.cons_bind structure Tape (Γ : Type*) [Inhabited Γ] where head : Γ left : ListBlank Γ right : ListBlank Γ #align turing.tape Turing.Tape instance Tape.inhabited {Γ} [Inhabited Γ] : Inhabited (Tape Γ) := ⟨by constructor <;> apply default⟩ #align turing.tape.inhabited Turing.Tape.inhabited inductive Dir | left | right deriving DecidableEq, Inhabited #align turing.dir Turing.Dir def Tape.left₀ {Γ} [Inhabited Γ] (T : Tape Γ) : ListBlank Γ := T.left.cons T.head #align turing.tape.left₀ Turing.Tape.left₀ def Tape.right₀ {Γ} [Inhabited Γ] (T : Tape Γ) : ListBlank Γ := T.right.cons T.head #align turing.tape.right₀ Turing.Tape.right₀ def Tape.move {Γ} [Inhabited Γ] : Dir → Tape Γ → Tape Γ | Dir.left, ⟨a, L, R⟩ => ⟨L.head, L.tail, R.cons a⟩ | Dir.right, ⟨a, L, R⟩ => ⟨R.head, L.cons a, R.tail⟩ #align turing.tape.move Turing.Tape.move @[simp] theorem Tape.move_left_right {Γ} [Inhabited Γ] (T : Tape Γ) : (T.move Dir.left).move Dir.right = T := by cases T; simp [Tape.move] #align turing.tape.move_left_right Turing.Tape.move_left_right @[simp] theorem Tape.move_right_left {Γ} [Inhabited Γ] (T : Tape Γ) : (T.move Dir.right).move Dir.left = T := by cases T; simp [Tape.move] #align turing.tape.move_right_left Turing.Tape.move_right_left def Tape.mk' {Γ} [Inhabited Γ] (L R : ListBlank Γ) : Tape Γ := ⟨R.head, L, R.tail⟩ #align turing.tape.mk' Turing.Tape.mk' @[simp] theorem Tape.mk'_left {Γ} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).left = L := rfl #align turing.tape.mk'_left Turing.Tape.mk'_left @[simp] theorem Tape.mk'_head {Γ} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).head = R.head := rfl #align turing.tape.mk'_head Turing.Tape.mk'_head @[simp] theorem Tape.mk'_right {Γ} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).right = R.tail := rfl #align turing.tape.mk'_right Turing.Tape.mk'_right @[simp] theorem Tape.mk'_right₀ {Γ} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).right₀ = R := ListBlank.cons_head_tail _ #align turing.tape.mk'_right₀ Turing.Tape.mk'_right₀ @[simp] theorem Tape.mk'_left_right₀ {Γ} [Inhabited Γ] (T : Tape Γ) : Tape.mk' T.left T.right₀ = T := by cases T simp only [Tape.right₀, Tape.mk', ListBlank.head_cons, ListBlank.tail_cons, eq_self_iff_true, and_self_iff] #align turing.tape.mk'_left_right₀ Turing.Tape.mk'_left_right₀ theorem Tape.exists_mk' {Γ} [Inhabited Γ] (T : Tape Γ) : ∃ L R, T = Tape.mk' L R := ⟨_, _, (Tape.mk'_left_right₀ _).symm⟩ #align turing.tape.exists_mk' Turing.Tape.exists_mk' @[simp]
Mathlib/Computability/TuringMachine.lean
587
590
theorem Tape.move_left_mk' {Γ} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).move Dir.left = Tape.mk' L.tail (R.cons L.head) := by
simp only [Tape.move, Tape.mk', ListBlank.head_cons, eq_self_iff_true, ListBlank.cons_head_tail, and_self_iff, ListBlank.tail_cons]
import Mathlib.RepresentationTheory.Action.Limits import Mathlib.RepresentationTheory.Action.Concrete import Mathlib.CategoryTheory.Monoidal.FunctorCategory import Mathlib.CategoryTheory.Monoidal.Transport import Mathlib.CategoryTheory.Monoidal.Rigid.OfEquivalence import Mathlib.CategoryTheory.Monoidal.Rigid.FunctorCategory import Mathlib.CategoryTheory.Monoidal.Linear import Mathlib.CategoryTheory.Monoidal.Braided.Basic import Mathlib.CategoryTheory.Monoidal.Types.Basic universe u v open CategoryTheory Limits variable {V : Type (u + 1)} [LargeCategory V] {G : MonCat.{u}} namespace Action section Monoidal open MonoidalCategory variable [MonoidalCategory V] instance instMonoidalCategory : MonoidalCategory (Action V G) := Monoidal.transport (Action.functorCategoryEquivalence _ _).symm @[simp] theorem tensorUnit_v : (𝟙_ (Action V G)).V = 𝟙_ V := rfl set_option linter.uppercaseLean3 false in #align Action.tensor_unit_V Action.tensorUnit_v -- Porting note: removed @[simp] as the simpNF linter complains theorem tensorUnit_rho {g : G} : (𝟙_ (Action V G)).ρ g = 𝟙 (𝟙_ V) := rfl set_option linter.uppercaseLean3 false in #align Action.tensor_unit_rho Action.tensorUnit_rho @[simp] theorem tensor_v {X Y : Action V G} : (X ⊗ Y).V = X.V ⊗ Y.V := rfl set_option linter.uppercaseLean3 false in #align Action.tensor_V Action.tensor_v -- Porting note: removed @[simp] as the simpNF linter complains theorem tensor_rho {X Y : Action V G} {g : G} : (X ⊗ Y).ρ g = X.ρ g ⊗ Y.ρ g := rfl set_option linter.uppercaseLean3 false in #align Action.tensor_rho Action.tensor_rho @[simp] theorem tensor_hom {W X Y Z : Action V G} (f : W ⟶ X) (g : Y ⟶ Z) : (f ⊗ g).hom = f.hom ⊗ g.hom := rfl set_option linter.uppercaseLean3 false in #align Action.tensor_hom Action.tensor_hom @[simp] theorem whiskerLeft_hom (X : Action V G) {Y Z : Action V G} (f : Y ⟶ Z) : (X ◁ f).hom = X.V ◁ f.hom := rfl @[simp] theorem whiskerRight_hom {X Y : Action V G} (f : X ⟶ Y) (Z : Action V G) : (f ▷ Z).hom = f.hom ▷ Z.V := rfl -- Porting note: removed @[simp] as the simpNF linter complains theorem associator_hom_hom {X Y Z : Action V G} : Hom.hom (α_ X Y Z).hom = (α_ X.V Y.V Z.V).hom := by dsimp simp set_option linter.uppercaseLean3 false in #align Action.associator_hom_hom Action.associator_hom_hom -- Porting note: removed @[simp] as the simpNF linter complains theorem associator_inv_hom {X Y Z : Action V G} : Hom.hom (α_ X Y Z).inv = (α_ X.V Y.V Z.V).inv := by dsimp simp set_option linter.uppercaseLean3 false in #align Action.associator_inv_hom Action.associator_inv_hom -- Porting note: removed @[simp] as the simpNF linter complains
Mathlib/RepresentationTheory/Action/Monoidal.lean
98
100
theorem leftUnitor_hom_hom {X : Action V G} : Hom.hom (λ_ X).hom = (λ_ X.V).hom := by
dsimp simp
import Mathlib.Analysis.SpecialFunctions.Gamma.Beta import Mathlib.NumberTheory.LSeries.HurwitzZeta import Mathlib.Analysis.Complex.RemovableSingularity import Mathlib.Analysis.PSeriesComplex #align_import number_theory.zeta_function from "leanprover-community/mathlib"@"57f9349f2fe19d2de7207e99b0341808d977cdcf" open MeasureTheory Set Filter Asymptotics TopologicalSpace Real Asymptotics Classical HurwitzZeta open Complex hiding exp norm_eq_abs abs_of_nonneg abs_two continuous_exp open scoped Topology Real Nat noncomputable section def completedRiemannZeta₀ (s : ℂ) : ℂ := completedHurwitzZetaEven₀ 0 s #align riemann_completed_zeta₀ completedRiemannZeta₀ def completedRiemannZeta (s : ℂ) : ℂ := completedHurwitzZetaEven 0 s #align riemann_completed_zeta completedRiemannZeta lemma HurwitzZeta.completedHurwitzZetaEven_zero (s : ℂ) : completedHurwitzZetaEven 0 s = completedRiemannZeta s := rfl lemma HurwitzZeta.completedHurwitzZetaEven₀_zero (s : ℂ) : completedHurwitzZetaEven₀ 0 s = completedRiemannZeta₀ s := rfl lemma HurwitzZeta.completedCosZeta_zero (s : ℂ) : completedCosZeta 0 s = completedRiemannZeta s := by rw [completedRiemannZeta, completedHurwitzZetaEven, completedCosZeta, hurwitzEvenFEPair_zero_symm] lemma HurwitzZeta.completedCosZeta₀_zero (s : ℂ) : completedCosZeta₀ 0 s = completedRiemannZeta₀ s := by rw [completedRiemannZeta₀, completedHurwitzZetaEven₀, completedCosZeta₀, hurwitzEvenFEPair_zero_symm] lemma completedRiemannZeta_eq (s : ℂ) : completedRiemannZeta s = completedRiemannZeta₀ s - 1 / s - 1 / (1 - s) := by simp_rw [completedRiemannZeta, completedRiemannZeta₀, completedHurwitzZetaEven_eq, if_true] theorem differentiable_completedZeta₀ : Differentiable ℂ completedRiemannZeta₀ := differentiable_completedHurwitzZetaEven₀ 0 #align differentiable_completed_zeta₀ differentiable_completedZeta₀ theorem differentiableAt_completedZeta {s : ℂ} (hs : s ≠ 0) (hs' : s ≠ 1) : DifferentiableAt ℂ completedRiemannZeta s := differentiableAt_completedHurwitzZetaEven 0 (Or.inl hs) hs' theorem completedRiemannZeta₀_one_sub (s : ℂ) : completedRiemannZeta₀ (1 - s) = completedRiemannZeta₀ s := by rw [← completedHurwitzZetaEven₀_zero, ← completedCosZeta₀_zero, completedHurwitzZetaEven₀_one_sub] #align riemann_completed_zeta₀_one_sub completedRiemannZeta₀_one_sub theorem completedRiemannZeta_one_sub (s : ℂ) : completedRiemannZeta (1 - s) = completedRiemannZeta s := by rw [← completedHurwitzZetaEven_zero, ← completedCosZeta_zero, completedHurwitzZetaEven_one_sub] #align riemann_completed_zeta_one_sub completedRiemannZeta_one_sub lemma completedRiemannZeta_residue_one : Tendsto (fun s ↦ (s - 1) * completedRiemannZeta s) (𝓝[≠] 1) (𝓝 1) := completedHurwitzZetaEven_residue_one 0 def riemannZeta := hurwitzZetaEven 0 #align riemann_zeta riemannZeta lemma HurwitzZeta.hurwitzZetaEven_zero : hurwitzZetaEven 0 = riemannZeta := rfl lemma HurwitzZeta.cosZeta_zero : cosZeta 0 = riemannZeta := by simp_rw [cosZeta, riemannZeta, hurwitzZetaEven, if_true, completedHurwitzZetaEven_zero, completedCosZeta_zero] lemma HurwitzZeta.hurwitzZeta_zero : hurwitzZeta 0 = riemannZeta := by ext1 s simpa [hurwitzZeta, hurwitzZetaEven_zero] using hurwitzZetaOdd_neg 0 s lemma HurwitzZeta.expZeta_zero : expZeta 0 = riemannZeta := by ext1 s rw [expZeta, cosZeta_zero, add_right_eq_self, mul_eq_zero, eq_false_intro I_ne_zero, false_or, ← eq_neg_self_iff, ← sinZeta_neg, neg_zero] theorem differentiableAt_riemannZeta {s : ℂ} (hs' : s ≠ 1) : DifferentiableAt ℂ riemannZeta s := differentiableAt_hurwitzZetaEven _ hs' #align differentiable_at_riemann_zeta differentiableAt_riemannZeta theorem riemannZeta_zero : riemannZeta 0 = -1 / 2 := by simp_rw [riemannZeta, hurwitzZetaEven, Function.update_same, if_true] #align riemann_zeta_zero riemannZeta_zero lemma riemannZeta_def_of_ne_zero {s : ℂ} (hs : s ≠ 0) : riemannZeta s = completedRiemannZeta s / Gammaℝ s := by rw [riemannZeta, hurwitzZetaEven, Function.update_noteq hs, completedHurwitzZetaEven_zero] theorem riemannZeta_neg_two_mul_nat_add_one (n : ℕ) : riemannZeta (-2 * (n + 1)) = 0 := hurwitzZetaEven_neg_two_mul_nat_add_one 0 n #align riemann_zeta_neg_two_mul_nat_add_one riemannZeta_neg_two_mul_nat_add_one theorem riemannZeta_one_sub {s : ℂ} (hs : ∀ n : ℕ, s ≠ -n) (hs' : s ≠ 1) : riemannZeta (1 - s) = 2 * (2 * π) ^ (-s) * Gamma s * cos (π * s / 2) * riemannZeta s := by rw [riemannZeta, hurwitzZetaEven_one_sub 0 hs (Or.inr hs'), cosZeta_zero, hurwitzZetaEven_zero] #align riemann_zeta_one_sub riemannZeta_one_sub def RiemannHypothesis : Prop := ∀ (s : ℂ) (_ : riemannZeta s = 0) (_ : ¬∃ n : ℕ, s = -2 * (n + 1)) (_ : s ≠ 1), s.re = 1 / 2 #align riemann_hypothesis RiemannHypothesis theorem completedZeta_eq_tsum_of_one_lt_re {s : ℂ} (hs : 1 < re s) : completedRiemannZeta s = (π : ℂ) ^ (-s / 2) * Gamma (s / 2) * ∑' n : ℕ, 1 / (n : ℂ) ^ s := by have := (hasSum_nat_completedCosZeta 0 hs).tsum_eq.symm simp only [QuotientAddGroup.mk_zero, completedCosZeta_zero] at this simp only [this, Gammaℝ_def, mul_zero, zero_mul, Real.cos_zero, ofReal_one, mul_one, mul_one_div, ← tsum_mul_left] congr 1 with n split_ifs with h · simp only [h, Nat.cast_zero, zero_cpow (Complex.ne_zero_of_one_lt_re hs), div_zero] · rfl #align completed_zeta_eq_tsum_of_one_lt_re completedZeta_eq_tsum_of_one_lt_re theorem zeta_eq_tsum_one_div_nat_cpow {s : ℂ} (hs : 1 < re s) : riemannZeta s = ∑' n : ℕ, 1 / (n : ℂ) ^ s := by simpa only [QuotientAddGroup.mk_zero, cosZeta_zero, mul_zero, zero_mul, Real.cos_zero, ofReal_one] using (hasSum_nat_cosZeta 0 hs).tsum_eq.symm #align zeta_eq_tsum_one_div_nat_cpow zeta_eq_tsum_one_div_nat_cpow
Mathlib/NumberTheory/LSeries/RiemannZeta.lean
203
208
theorem zeta_eq_tsum_one_div_nat_add_one_cpow {s : ℂ} (hs : 1 < re s) : riemannZeta s = ∑' n : ℕ, 1 / (n + 1 : ℂ) ^ s := by
have := zeta_eq_tsum_one_div_nat_cpow hs rw [tsum_eq_zero_add] at this · simpa [zero_cpow (Complex.ne_zero_of_one_lt_re hs)] · rwa [Complex.summable_one_div_nat_cpow]
import Mathlib.Data.Fintype.Basic import Mathlib.ModelTheory.Substructures #align_import model_theory.elementary_maps from "leanprover-community/mathlib"@"d11893b411025250c8e61ff2f12ccbd7ee35ab15" open FirstOrder namespace FirstOrder namespace Language open Structure variable (L : Language) (M : Type*) (N : Type*) {P : Type*} {Q : Type*} variable [L.Structure M] [L.Structure N] [L.Structure P] [L.Structure Q] structure ElementaryEmbedding where toFun : M → N -- Porting note: -- The autoparam here used to be `obviously`. We would like to replace it with `aesop` -- but that isn't currently sufficient. -- See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Aesop.20and.20cases -- If that can be improved, we should change this to `by aesop` and remove the proofs below. map_formula' : ∀ ⦃n⦄ (φ : L.Formula (Fin n)) (x : Fin n → M), φ.Realize (toFun ∘ x) ↔ φ.Realize x := by intros; trivial #align first_order.language.elementary_embedding FirstOrder.Language.ElementaryEmbedding #align first_order.language.elementary_embedding.to_fun FirstOrder.Language.ElementaryEmbedding.toFun #align first_order.language.elementary_embedding.map_formula' FirstOrder.Language.ElementaryEmbedding.map_formula' @[inherit_doc FirstOrder.Language.ElementaryEmbedding] scoped[FirstOrder] notation:25 A " ↪ₑ[" L "] " B => FirstOrder.Language.ElementaryEmbedding L A B variable {L} {M} {N} namespace ElementaryEmbedding attribute [coe] toFun instance instFunLike : FunLike (M ↪ₑ[L] N) M N where coe f := f.toFun coe_injective' f g h := by cases f cases g simp only [ElementaryEmbedding.mk.injEq] ext x exact Function.funext_iff.1 h x #align first_order.language.elementary_embedding.fun_like FirstOrder.Language.ElementaryEmbedding.instFunLike instance : CoeFun (M ↪ₑ[L] N) fun _ => M → N := DFunLike.hasCoeToFun @[simp] theorem map_boundedFormula (f : M ↪ₑ[L] N) {α : Type*} {n : ℕ} (φ : L.BoundedFormula α n) (v : α → M) (xs : Fin n → M) : φ.Realize (f ∘ v) (f ∘ xs) ↔ φ.Realize v xs := by classical rw [← BoundedFormula.realize_restrictFreeVar Set.Subset.rfl, Set.inclusion_eq_id, iff_eq_eq] have h := f.map_formula' ((φ.restrictFreeVar id).toFormula.relabel (Fintype.equivFin _)) (Sum.elim (v ∘ (↑)) xs ∘ (Fintype.equivFin _).symm) simp only [Formula.realize_relabel, BoundedFormula.realize_toFormula, iff_eq_eq] at h rw [← Function.comp.assoc _ _ (Fintype.equivFin _).symm, Function.comp.assoc _ (Fintype.equivFin _).symm (Fintype.equivFin _), _root_.Equiv.symm_comp_self, Function.comp_id, Function.comp.assoc, Sum.elim_comp_inl, Function.comp.assoc _ _ Sum.inr, Sum.elim_comp_inr, ← Function.comp.assoc] at h refine h.trans ?_ erw [Function.comp.assoc _ _ (Fintype.equivFin _), _root_.Equiv.symm_comp_self, Function.comp_id, Sum.elim_comp_inl, Sum.elim_comp_inr (v ∘ Subtype.val) xs, ← Set.inclusion_eq_id (s := (BoundedFormula.freeVarFinset φ : Set α)) Set.Subset.rfl, BoundedFormula.realize_restrictFreeVar Set.Subset.rfl] #align first_order.language.elementary_embedding.map_bounded_formula FirstOrder.Language.ElementaryEmbedding.map_boundedFormula @[simp]
Mathlib/ModelTheory/ElementaryMaps.lean
98
100
theorem map_formula (f : M ↪ₑ[L] N) {α : Type*} (φ : L.Formula α) (x : α → M) : φ.Realize (f ∘ x) ↔ φ.Realize x := by
rw [Formula.Realize, Formula.Realize, ← f.map_boundedFormula, Unique.eq_default (f ∘ default)]
import Mathlib.CategoryTheory.Functor.FullyFaithful import Mathlib.CategoryTheory.FullSubcategory import Mathlib.CategoryTheory.Whiskering import Mathlib.CategoryTheory.EssentialImage import Mathlib.Tactic.CategoryTheory.Slice #align_import category_theory.equivalence from "leanprover-community/mathlib"@"9aba7801eeecebb61f58a5763c2b6dd1b47dc6ef" namespace CategoryTheory open CategoryTheory.Functor NatIso Category -- declare the `v`'s first; see `CategoryTheory.Category` for an explanation universe v₁ v₂ v₃ u₁ u₂ u₃ @[ext] structure Equivalence (C : Type u₁) (D : Type u₂) [Category.{v₁} C] [Category.{v₂} D] where mk' :: functor : C ⥤ D inverse : D ⥤ C unitIso : 𝟭 C ≅ functor ⋙ inverse counitIso : inverse ⋙ functor ≅ 𝟭 D functor_unitIso_comp : ∀ X : C, functor.map (unitIso.hom.app X) ≫ counitIso.hom.app (functor.obj X) = 𝟙 (functor.obj X) := by aesop_cat #align category_theory.equivalence CategoryTheory.Equivalence #align category_theory.equivalence.unit_iso CategoryTheory.Equivalence.unitIso #align category_theory.equivalence.counit_iso CategoryTheory.Equivalence.counitIso #align category_theory.equivalence.functor_unit_iso_comp CategoryTheory.Equivalence.functor_unitIso_comp infixr:10 " ≌ " => Equivalence variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] namespace Equivalence abbrev unit (e : C ≌ D) : 𝟭 C ⟶ e.functor ⋙ e.inverse := e.unitIso.hom #align category_theory.equivalence.unit CategoryTheory.Equivalence.unit abbrev counit (e : C ≌ D) : e.inverse ⋙ e.functor ⟶ 𝟭 D := e.counitIso.hom #align category_theory.equivalence.counit CategoryTheory.Equivalence.counit abbrev unitInv (e : C ≌ D) : e.functor ⋙ e.inverse ⟶ 𝟭 C := e.unitIso.inv #align category_theory.equivalence.unit_inv CategoryTheory.Equivalence.unitInv abbrev counitInv (e : C ≌ D) : 𝟭 D ⟶ e.inverse ⋙ e.functor := e.counitIso.inv #align category_theory.equivalence.counit_inv CategoryTheory.Equivalence.counitInv @[simp] theorem Equivalence_mk'_unit (functor inverse unit_iso counit_iso f) : (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).unit = unit_iso.hom := rfl #align category_theory.equivalence.equivalence_mk'_unit CategoryTheory.Equivalence.Equivalence_mk'_unit @[simp] theorem Equivalence_mk'_counit (functor inverse unit_iso counit_iso f) : (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).counit = counit_iso.hom := rfl #align category_theory.equivalence.equivalence_mk'_counit CategoryTheory.Equivalence.Equivalence_mk'_counit @[simp] theorem Equivalence_mk'_unitInv (functor inverse unit_iso counit_iso f) : (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).unitInv = unit_iso.inv := rfl #align category_theory.equivalence.equivalence_mk'_unit_inv CategoryTheory.Equivalence.Equivalence_mk'_unitInv @[simp] theorem Equivalence_mk'_counitInv (functor inverse unit_iso counit_iso f) : (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).counitInv = counit_iso.inv := rfl #align category_theory.equivalence.equivalence_mk'_counit_inv CategoryTheory.Equivalence.Equivalence_mk'_counitInv @[reassoc (attr := simp)] theorem functor_unit_comp (e : C ≌ D) (X : C) : e.functor.map (e.unit.app X) ≫ e.counit.app (e.functor.obj X) = 𝟙 (e.functor.obj X) := e.functor_unitIso_comp X #align category_theory.equivalence.functor_unit_comp CategoryTheory.Equivalence.functor_unit_comp @[reassoc (attr := simp)]
Mathlib/CategoryTheory/Equivalence.lean
159
163
theorem counitInv_functor_comp (e : C ≌ D) (X : C) : e.counitInv.app (e.functor.obj X) ≫ e.functor.map (e.unitInv.app X) = 𝟙 (e.functor.obj X) := by
erw [Iso.inv_eq_inv (e.functor.mapIso (e.unitIso.app X) ≪≫ e.counitIso.app (e.functor.obj X)) (Iso.refl _)] exact e.functor_unit_comp X
import Mathlib.Order.Cover import Mathlib.Order.Interval.Finset.Defs #align_import data.finset.locally_finite from "leanprover-community/mathlib"@"442a83d738cb208d3600056c489be16900ba701d" assert_not_exists MonoidWithZero assert_not_exists Finset.sum open Function OrderDual open FinsetInterval variable {ι α : Type*} namespace Finset section Preorder variable [Preorder α] section LocallyFiniteOrder variable [LocallyFiniteOrder α] {a a₁ a₂ b b₁ b₂ c x : α} @[simp, aesop safe apply (rule_sets := [finsetNonempty])] theorem nonempty_Icc : (Icc a b).Nonempty ↔ a ≤ b := by rw [← coe_nonempty, coe_Icc, Set.nonempty_Icc] #align finset.nonempty_Icc Finset.nonempty_Icc @[simp, aesop safe apply (rule_sets := [finsetNonempty])] theorem nonempty_Ico : (Ico a b).Nonempty ↔ a < b := by rw [← coe_nonempty, coe_Ico, Set.nonempty_Ico] #align finset.nonempty_Ico Finset.nonempty_Ico @[simp, aesop safe apply (rule_sets := [finsetNonempty])] theorem nonempty_Ioc : (Ioc a b).Nonempty ↔ a < b := by rw [← coe_nonempty, coe_Ioc, Set.nonempty_Ioc] #align finset.nonempty_Ioc Finset.nonempty_Ioc -- TODO: This is nonsense. A locally finite order is never densely ordered @[simp] theorem nonempty_Ioo [DenselyOrdered α] : (Ioo a b).Nonempty ↔ a < b := by rw [← coe_nonempty, coe_Ioo, Set.nonempty_Ioo] #align finset.nonempty_Ioo Finset.nonempty_Ioo @[simp] theorem Icc_eq_empty_iff : Icc a b = ∅ ↔ ¬a ≤ b := by rw [← coe_eq_empty, coe_Icc, Set.Icc_eq_empty_iff] #align finset.Icc_eq_empty_iff Finset.Icc_eq_empty_iff @[simp] theorem Ico_eq_empty_iff : Ico a b = ∅ ↔ ¬a < b := by rw [← coe_eq_empty, coe_Ico, Set.Ico_eq_empty_iff] #align finset.Ico_eq_empty_iff Finset.Ico_eq_empty_iff @[simp] theorem Ioc_eq_empty_iff : Ioc a b = ∅ ↔ ¬a < b := by rw [← coe_eq_empty, coe_Ioc, Set.Ioc_eq_empty_iff] #align finset.Ioc_eq_empty_iff Finset.Ioc_eq_empty_iff -- TODO: This is nonsense. A locally finite order is never densely ordered @[simp] theorem Ioo_eq_empty_iff [DenselyOrdered α] : Ioo a b = ∅ ↔ ¬a < b := by rw [← coe_eq_empty, coe_Ioo, Set.Ioo_eq_empty_iff] #align finset.Ioo_eq_empty_iff Finset.Ioo_eq_empty_iff alias ⟨_, Icc_eq_empty⟩ := Icc_eq_empty_iff #align finset.Icc_eq_empty Finset.Icc_eq_empty alias ⟨_, Ico_eq_empty⟩ := Ico_eq_empty_iff #align finset.Ico_eq_empty Finset.Ico_eq_empty alias ⟨_, Ioc_eq_empty⟩ := Ioc_eq_empty_iff #align finset.Ioc_eq_empty Finset.Ioc_eq_empty @[simp] theorem Ioo_eq_empty (h : ¬a < b) : Ioo a b = ∅ := eq_empty_iff_forall_not_mem.2 fun _ hx => h ((mem_Ioo.1 hx).1.trans (mem_Ioo.1 hx).2) #align finset.Ioo_eq_empty Finset.Ioo_eq_empty @[simp] theorem Icc_eq_empty_of_lt (h : b < a) : Icc a b = ∅ := Icc_eq_empty h.not_le #align finset.Icc_eq_empty_of_lt Finset.Icc_eq_empty_of_lt @[simp] theorem Ico_eq_empty_of_le (h : b ≤ a) : Ico a b = ∅ := Ico_eq_empty h.not_lt #align finset.Ico_eq_empty_of_le Finset.Ico_eq_empty_of_le @[simp] theorem Ioc_eq_empty_of_le (h : b ≤ a) : Ioc a b = ∅ := Ioc_eq_empty h.not_lt #align finset.Ioc_eq_empty_of_le Finset.Ioc_eq_empty_of_le @[simp] theorem Ioo_eq_empty_of_le (h : b ≤ a) : Ioo a b = ∅ := Ioo_eq_empty h.not_lt #align finset.Ioo_eq_empty_of_le Finset.Ioo_eq_empty_of_le -- porting note (#10618): simp can prove this -- @[simp] theorem left_mem_Icc : a ∈ Icc a b ↔ a ≤ b := by simp only [mem_Icc, true_and_iff, le_rfl] #align finset.left_mem_Icc Finset.left_mem_Icc -- porting note (#10618): simp can prove this -- @[simp] theorem left_mem_Ico : a ∈ Ico a b ↔ a < b := by simp only [mem_Ico, true_and_iff, le_refl] #align finset.left_mem_Ico Finset.left_mem_Ico -- porting note (#10618): simp can prove this -- @[simp] theorem right_mem_Icc : b ∈ Icc a b ↔ a ≤ b := by simp only [mem_Icc, and_true_iff, le_rfl] #align finset.right_mem_Icc Finset.right_mem_Icc -- porting note (#10618): simp can prove this -- @[simp]
Mathlib/Order/Interval/Finset/Basic.lean
149
149
theorem right_mem_Ioc : b ∈ Ioc a b ↔ a < b := by
simp only [mem_Ioc, and_true_iff, le_rfl]
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex #align_import analysis.special_functions.trigonometric.arctan from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" noncomputable section namespace Real open Set Filter open scoped Topology Real theorem tan_add {x y : ℝ} (h : ((∀ k : ℤ, x ≠ (2 * k + 1) * π / 2) ∧ ∀ l : ℤ, y ≠ (2 * l + 1) * π / 2) ∨ (∃ k : ℤ, x = (2 * k + 1) * π / 2) ∧ ∃ l : ℤ, y = (2 * l + 1) * π / 2) : tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) := by simpa only [← Complex.ofReal_inj, Complex.ofReal_sub, Complex.ofReal_add, Complex.ofReal_div, Complex.ofReal_mul, Complex.ofReal_tan] using @Complex.tan_add (x : ℂ) (y : ℂ) (by convert h <;> norm_cast) #align real.tan_add Real.tan_add theorem tan_add' {x y : ℝ} (h : (∀ k : ℤ, x ≠ (2 * k + 1) * π / 2) ∧ ∀ l : ℤ, y ≠ (2 * l + 1) * π / 2) : tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) := tan_add (Or.inl h) #align real.tan_add' Real.tan_add' theorem tan_two_mul {x : ℝ} : tan (2 * x) = 2 * tan x / (1 - tan x ^ 2) := by have := @Complex.tan_two_mul x norm_cast at * #align real.tan_two_mul Real.tan_two_mul theorem tan_int_mul_pi_div_two (n : ℤ) : tan (n * π / 2) = 0 := tan_eq_zero_iff.mpr (by use n) #align real.tan_int_mul_pi_div_two Real.tan_int_mul_pi_div_two theorem continuousOn_tan : ContinuousOn tan {x | cos x ≠ 0} := by suffices ContinuousOn (fun x => sin x / cos x) {x | cos x ≠ 0} by have h_eq : (fun x => sin x / cos x) = tan := by ext1 x; rw [tan_eq_sin_div_cos] rwa [h_eq] at this exact continuousOn_sin.div continuousOn_cos fun x => id #align real.continuous_on_tan Real.continuousOn_tan @[continuity] theorem continuous_tan : Continuous fun x : {x | cos x ≠ 0} => tan x := continuousOn_iff_continuous_restrict.1 continuousOn_tan #align real.continuous_tan Real.continuous_tan theorem continuousOn_tan_Ioo : ContinuousOn tan (Ioo (-(π / 2)) (π / 2)) := by refine ContinuousOn.mono continuousOn_tan fun x => ?_ simp only [and_imp, mem_Ioo, mem_setOf_eq, Ne] rw [cos_eq_zero_iff] rintro hx_gt hx_lt ⟨r, hxr_eq⟩ rcases le_or_lt 0 r with h | h · rw [lt_iff_not_ge] at hx_lt refine hx_lt ?_ rw [hxr_eq, ← one_mul (π / 2), mul_div_assoc, ge_iff_le, mul_le_mul_right (half_pos pi_pos)] simp [h] · rw [lt_iff_not_ge] at hx_gt refine hx_gt ?_ rw [hxr_eq, ← one_mul (π / 2), mul_div_assoc, ge_iff_le, neg_mul_eq_neg_mul, mul_le_mul_right (half_pos pi_pos)] have hr_le : r ≤ -1 := by rwa [Int.lt_iff_add_one_le, ← le_neg_iff_add_nonpos_right] at h rw [← le_sub_iff_add_le, mul_comm, ← le_div_iff] · set_option tactic.skipAssignedInstances false in norm_num rw [← Int.cast_one, ← Int.cast_neg]; norm_cast · exact zero_lt_two #align real.continuous_on_tan_Ioo Real.continuousOn_tan_Ioo theorem surjOn_tan : SurjOn tan (Ioo (-(π / 2)) (π / 2)) univ := have := neg_lt_self pi_div_two_pos continuousOn_tan_Ioo.surjOn_of_tendsto (nonempty_Ioo.2 this) (by rw [tendsto_comp_coe_Ioo_atBot this]; exact tendsto_tan_neg_pi_div_two) (by rw [tendsto_comp_coe_Ioo_atTop this]; exact tendsto_tan_pi_div_two) #align real.surj_on_tan Real.surjOn_tan theorem tan_surjective : Function.Surjective tan := fun _ => surjOn_tan.subset_range trivial #align real.tan_surjective Real.tan_surjective theorem image_tan_Ioo : tan '' Ioo (-(π / 2)) (π / 2) = univ := univ_subset_iff.1 surjOn_tan #align real.image_tan_Ioo Real.image_tan_Ioo def tanOrderIso : Ioo (-(π / 2)) (π / 2) ≃o ℝ := (strictMonoOn_tan.orderIso _ _).trans <| (OrderIso.setCongr _ _ image_tan_Ioo).trans OrderIso.Set.univ #align real.tan_order_iso Real.tanOrderIso -- @[pp_nodot] -- Porting note: removed noncomputable def arctan (x : ℝ) : ℝ := tanOrderIso.symm x #align real.arctan Real.arctan @[simp] theorem tan_arctan (x : ℝ) : tan (arctan x) = x := tanOrderIso.apply_symm_apply x #align real.tan_arctan Real.tan_arctan theorem arctan_mem_Ioo (x : ℝ) : arctan x ∈ Ioo (-(π / 2)) (π / 2) := Subtype.coe_prop _ #align real.arctan_mem_Ioo Real.arctan_mem_Ioo @[simp] theorem range_arctan : range arctan = Ioo (-(π / 2)) (π / 2) := ((EquivLike.surjective _).range_comp _).trans Subtype.range_coe #align real.range_arctan Real.range_arctan theorem arctan_tan {x : ℝ} (hx₁ : -(π / 2) < x) (hx₂ : x < π / 2) : arctan (tan x) = x := Subtype.ext_iff.1 <| tanOrderIso.symm_apply_apply ⟨x, hx₁, hx₂⟩ #align real.arctan_tan Real.arctan_tan theorem cos_arctan_pos (x : ℝ) : 0 < cos (arctan x) := cos_pos_of_mem_Ioo <| arctan_mem_Ioo x #align real.cos_arctan_pos Real.cos_arctan_pos theorem cos_sq_arctan (x : ℝ) : cos (arctan x) ^ 2 = 1 / (1 + x ^ 2) := by rw_mod_cast [one_div, ← inv_one_add_tan_sq (cos_arctan_pos x).ne', tan_arctan] #align real.cos_sq_arctan Real.cos_sq_arctan theorem sin_arctan (x : ℝ) : sin (arctan x) = x / √(1 + x ^ 2) := by rw_mod_cast [← tan_div_sqrt_one_add_tan_sq (cos_arctan_pos x), tan_arctan] #align real.sin_arctan Real.sin_arctan theorem cos_arctan (x : ℝ) : cos (arctan x) = 1 / √(1 + x ^ 2) := by rw_mod_cast [one_div, ← inv_sqrt_one_add_tan_sq (cos_arctan_pos x), tan_arctan] #align real.cos_arctan Real.cos_arctan theorem arctan_lt_pi_div_two (x : ℝ) : arctan x < π / 2 := (arctan_mem_Ioo x).2 #align real.arctan_lt_pi_div_two Real.arctan_lt_pi_div_two theorem neg_pi_div_two_lt_arctan (x : ℝ) : -(π / 2) < arctan x := (arctan_mem_Ioo x).1 #align real.neg_pi_div_two_lt_arctan Real.neg_pi_div_two_lt_arctan theorem arctan_eq_arcsin (x : ℝ) : arctan x = arcsin (x / √(1 + x ^ 2)) := Eq.symm <| arcsin_eq_of_sin_eq (sin_arctan x) (mem_Icc_of_Ioo <| arctan_mem_Ioo x) #align real.arctan_eq_arcsin Real.arctan_eq_arcsin theorem arcsin_eq_arctan {x : ℝ} (h : x ∈ Ioo (-(1 : ℝ)) 1) : arcsin x = arctan (x / √(1 - x ^ 2)) := by rw_mod_cast [arctan_eq_arcsin, div_pow, sq_sqrt, one_add_div, div_div, ← sqrt_mul, mul_div_cancel₀, sub_add_cancel, sqrt_one, div_one] <;> simp at h <;> nlinarith [h.1, h.2] #align real.arcsin_eq_arctan Real.arcsin_eq_arctan @[simp] theorem arctan_zero : arctan 0 = 0 := by simp [arctan_eq_arcsin] #align real.arctan_zero Real.arctan_zero @[mono] theorem arctan_strictMono : StrictMono arctan := tanOrderIso.symm.strictMono theorem arctan_injective : arctan.Injective := arctan_strictMono.injective @[simp] theorem arctan_eq_zero_iff {x : ℝ} : arctan x = 0 ↔ x = 0 := .trans (by rw [arctan_zero]) arctan_injective.eq_iff theorem tendsto_arctan_atTop : Tendsto arctan atTop (𝓝[<] (π / 2)) := tendsto_Ioo_atTop.mp tanOrderIso.symm.tendsto_atTop theorem tendsto_arctan_atBot : Tendsto arctan atBot (𝓝[>] (-(π / 2))) := tendsto_Ioo_atBot.mp tanOrderIso.symm.tendsto_atBot theorem arctan_eq_of_tan_eq {x y : ℝ} (h : tan x = y) (hx : x ∈ Ioo (-(π / 2)) (π / 2)) : arctan y = x := injOn_tan (arctan_mem_Ioo _) hx (by rw [tan_arctan, h]) #align real.arctan_eq_of_tan_eq Real.arctan_eq_of_tan_eq @[simp] theorem arctan_one : arctan 1 = π / 4 := arctan_eq_of_tan_eq tan_pi_div_four <| by constructor <;> linarith [pi_pos] #align real.arctan_one Real.arctan_one @[simp] theorem arctan_neg (x : ℝ) : arctan (-x) = -arctan x := by simp [arctan_eq_arcsin, neg_div] #align real.arctan_neg Real.arctan_neg theorem arctan_eq_arccos {x : ℝ} (h : 0 ≤ x) : arctan x = arccos (√(1 + x ^ 2))⁻¹ := by rw [arctan_eq_arcsin, arccos_eq_arcsin]; swap; · exact inv_nonneg.2 (sqrt_nonneg _) congr 1 rw_mod_cast [← sqrt_inv, sq_sqrt, ← one_div, one_sub_div, add_sub_cancel_left, sqrt_div, sqrt_sq h] all_goals positivity #align real.arctan_eq_arccos Real.arctan_eq_arccos -- The junk values for `arccos` and `sqrt` make this true even for `1 < x`. theorem arccos_eq_arctan {x : ℝ} (h : 0 < x) : arccos x = arctan (√(1 - x ^ 2) / x) := by rw [arccos, eq_comm] refine arctan_eq_of_tan_eq ?_ ⟨?_, ?_⟩ · rw_mod_cast [tan_pi_div_two_sub, tan_arcsin, inv_div] · linarith only [arcsin_le_pi_div_two x, pi_pos] · linarith only [arcsin_pos.2 h] #align real.arccos_eq_arctan Real.arccos_eq_arctan theorem arctan_inv_of_pos {x : ℝ} (h : 0 < x) : arctan x⁻¹ = π / 2 - arctan x := by rw [← arctan_tan (x := _ - _), tan_pi_div_two_sub, tan_arctan] · norm_num exact (arctan_lt_pi_div_two x).trans (half_lt_self_iff.mpr pi_pos) · rw [sub_lt_self_iff, ← arctan_zero] exact tanOrderIso.symm.strictMono h theorem arctan_inv_of_neg {x : ℝ} (h : x < 0) : arctan x⁻¹ = -(π / 2) - arctan x := by have := arctan_inv_of_pos (neg_pos.mpr h) rwa [inv_neg, arctan_neg, neg_eq_iff_eq_neg, neg_sub', arctan_neg, neg_neg] at this section ArctanAdd lemma arctan_ne_mul_pi_div_two {x : ℝ} : ∀ (k : ℤ), arctan x ≠ (2 * k + 1) * π / 2 := by by_contra! obtain ⟨k, h⟩ := this obtain ⟨lb, ub⟩ := arctan_mem_Ioo x rw [h, neg_eq_neg_one_mul, mul_div_assoc, mul_lt_mul_right (by positivity)] at lb rw [h, ← one_mul (π / 2), mul_div_assoc, mul_lt_mul_right (by positivity)] at ub norm_cast at lb ub; change -1 < _ at lb; omega lemma arctan_add_arctan_lt_pi_div_two {x y : ℝ} (h : x * y < 1) : arctan x + arctan y < π / 2 := by cases' le_or_lt y 0 with hy hy · rw [← add_zero (π / 2), ← arctan_zero] exact add_lt_add_of_lt_of_le (arctan_lt_pi_div_two _) (tanOrderIso.symm.monotone hy) · rw [← lt_div_iff hy, ← inv_eq_one_div] at h replace h : arctan x < arctan y⁻¹ := tanOrderIso.symm.strictMono h rwa [arctan_inv_of_pos hy, lt_tsub_iff_right] at h
Mathlib/Analysis/SpecialFunctions/Trigonometric/Arctan.lean
247
256
theorem arctan_add {x y : ℝ} (h : x * y < 1) : arctan x + arctan y = arctan ((x + y) / (1 - x * y)) := by
rw [← arctan_tan (x := _ + _)] · congr conv_rhs => rw [← tan_arctan x, ← tan_arctan y] exact tan_add' ⟨arctan_ne_mul_pi_div_two, arctan_ne_mul_pi_div_two⟩ · rw [neg_lt, neg_add, ← arctan_neg, ← arctan_neg] rw [← neg_mul_neg] at h exact arctan_add_arctan_lt_pi_div_two h · exact arctan_add_arctan_lt_pi_div_two h
import Mathlib.Data.Fin.VecNotation import Mathlib.Logic.Embedding.Set #align_import logic.equiv.fin from "leanprover-community/mathlib"@"bd835ef554f37ef9b804f0903089211f89cb370b" assert_not_exists MonoidWithZero universe u variable {m n : ℕ} def finZeroEquiv : Fin 0 ≃ Empty := Equiv.equivEmpty _ #align fin_zero_equiv finZeroEquiv def finZeroEquiv' : Fin 0 ≃ PEmpty.{u} := Equiv.equivPEmpty _ #align fin_zero_equiv' finZeroEquiv' def finOneEquiv : Fin 1 ≃ Unit := Equiv.equivPUnit _ #align fin_one_equiv finOneEquiv def finTwoEquiv : Fin 2 ≃ Bool where toFun := ![false, true] invFun b := b.casesOn 0 1 left_inv := Fin.forall_fin_two.2 <| by simp right_inv := Bool.forall_bool.2 <| by simp #align fin_two_equiv finTwoEquiv @[simps (config := .asFn)] def piFinTwoEquiv (α : Fin 2 → Type u) : (∀ i, α i) ≃ α 0 × α 1 where toFun f := (f 0, f 1) invFun p := Fin.cons p.1 <| Fin.cons p.2 finZeroElim left_inv _ := funext <| Fin.forall_fin_two.2 ⟨rfl, rfl⟩ right_inv := fun _ => rfl #align pi_fin_two_equiv piFinTwoEquiv #align pi_fin_two_equiv_symm_apply piFinTwoEquiv_symm_apply #align pi_fin_two_equiv_apply piFinTwoEquiv_apply theorem Fin.preimage_apply_01_prod {α : Fin 2 → Type u} (s : Set (α 0)) (t : Set (α 1)) : (fun f : ∀ i, α i => (f 0, f 1)) ⁻¹' s ×ˢ t = Set.pi Set.univ (Fin.cons s <| Fin.cons t finZeroElim) := by ext f simp [Fin.forall_fin_two] #align fin.preimage_apply_01_prod Fin.preimage_apply_01_prod theorem Fin.preimage_apply_01_prod' {α : Type u} (s t : Set α) : (fun f : Fin 2 → α => (f 0, f 1)) ⁻¹' s ×ˢ t = Set.pi Set.univ ![s, t] := @Fin.preimage_apply_01_prod (fun _ => α) s t #align fin.preimage_apply_01_prod' Fin.preimage_apply_01_prod' @[simps! (config := .asFn)] def prodEquivPiFinTwo (α β : Type u) : α × β ≃ ∀ i : Fin 2, ![α, β] i := (piFinTwoEquiv (Fin.cons α (Fin.cons β finZeroElim))).symm #align prod_equiv_pi_fin_two prodEquivPiFinTwo #align prod_equiv_pi_fin_two_apply prodEquivPiFinTwo_apply #align prod_equiv_pi_fin_two_symm_apply prodEquivPiFinTwo_symm_apply @[simps (config := .asFn)] def finTwoArrowEquiv (α : Type*) : (Fin 2 → α) ≃ α × α := { piFinTwoEquiv fun _ => α with invFun := fun x => ![x.1, x.2] } #align fin_two_arrow_equiv finTwoArrowEquiv #align fin_two_arrow_equiv_symm_apply finTwoArrowEquiv_symm_apply #align fin_two_arrow_equiv_apply finTwoArrowEquiv_apply def OrderIso.piFinTwoIso (α : Fin 2 → Type u) [∀ i, Preorder (α i)] : (∀ i, α i) ≃o α 0 × α 1 where toEquiv := piFinTwoEquiv α map_rel_iff' := Iff.symm Fin.forall_fin_two #align order_iso.pi_fin_two_iso OrderIso.piFinTwoIso def OrderIso.finTwoArrowIso (α : Type*) [Preorder α] : (Fin 2 → α) ≃o α × α := { OrderIso.piFinTwoIso fun _ => α with toEquiv := finTwoArrowEquiv α } #align order_iso.fin_two_arrow_iso OrderIso.finTwoArrowIso def finSuccEquiv' (i : Fin (n + 1)) : Fin (n + 1) ≃ Option (Fin n) where toFun := i.insertNth none some invFun x := x.casesOn' i (Fin.succAbove i) left_inv x := Fin.succAboveCases i (by simp) (fun j => by simp) x right_inv x := by cases x <;> dsimp <;> simp #align fin_succ_equiv' finSuccEquiv' @[simp] theorem finSuccEquiv'_at (i : Fin (n + 1)) : (finSuccEquiv' i) i = none := by simp [finSuccEquiv'] #align fin_succ_equiv'_at finSuccEquiv'_at @[simp] theorem finSuccEquiv'_succAbove (i : Fin (n + 1)) (j : Fin n) : finSuccEquiv' i (i.succAbove j) = some j := @Fin.insertNth_apply_succAbove n (fun _ => Option (Fin n)) i _ _ _ #align fin_succ_equiv'_succ_above finSuccEquiv'_succAbove theorem finSuccEquiv'_below {i : Fin (n + 1)} {m : Fin n} (h : Fin.castSucc m < i) : (finSuccEquiv' i) (Fin.castSucc m) = m := by rw [← Fin.succAbove_of_castSucc_lt _ _ h, finSuccEquiv'_succAbove] #align fin_succ_equiv'_below finSuccEquiv'_below theorem finSuccEquiv'_above {i : Fin (n + 1)} {m : Fin n} (h : i ≤ Fin.castSucc m) : (finSuccEquiv' i) m.succ = some m := by rw [← Fin.succAbove_of_le_castSucc _ _ h, finSuccEquiv'_succAbove] #align fin_succ_equiv'_above finSuccEquiv'_above @[simp] theorem finSuccEquiv'_symm_none (i : Fin (n + 1)) : (finSuccEquiv' i).symm none = i := rfl #align fin_succ_equiv'_symm_none finSuccEquiv'_symm_none @[simp] theorem finSuccEquiv'_symm_some (i : Fin (n + 1)) (j : Fin n) : (finSuccEquiv' i).symm (some j) = i.succAbove j := rfl #align fin_succ_equiv'_symm_some finSuccEquiv'_symm_some theorem finSuccEquiv'_symm_some_below {i : Fin (n + 1)} {m : Fin n} (h : Fin.castSucc m < i) : (finSuccEquiv' i).symm (some m) = Fin.castSucc m := Fin.succAbove_of_castSucc_lt i m h #align fin_succ_equiv'_symm_some_below finSuccEquiv'_symm_some_below theorem finSuccEquiv'_symm_some_above {i : Fin (n + 1)} {m : Fin n} (h : i ≤ Fin.castSucc m) : (finSuccEquiv' i).symm (some m) = m.succ := Fin.succAbove_of_le_castSucc i m h #align fin_succ_equiv'_symm_some_above finSuccEquiv'_symm_some_above theorem finSuccEquiv'_symm_coe_below {i : Fin (n + 1)} {m : Fin n} (h : Fin.castSucc m < i) : (finSuccEquiv' i).symm m = Fin.castSucc m := finSuccEquiv'_symm_some_below h #align fin_succ_equiv'_symm_coe_below finSuccEquiv'_symm_coe_below theorem finSuccEquiv'_symm_coe_above {i : Fin (n + 1)} {m : Fin n} (h : i ≤ Fin.castSucc m) : (finSuccEquiv' i).symm m = m.succ := finSuccEquiv'_symm_some_above h #align fin_succ_equiv'_symm_coe_above finSuccEquiv'_symm_coe_above def finSuccEquiv (n : ℕ) : Fin (n + 1) ≃ Option (Fin n) := finSuccEquiv' 0 #align fin_succ_equiv finSuccEquiv @[simp] theorem finSuccEquiv_zero : (finSuccEquiv n) 0 = none := rfl #align fin_succ_equiv_zero finSuccEquiv_zero @[simp] theorem finSuccEquiv_succ (m : Fin n) : (finSuccEquiv n) m.succ = some m := finSuccEquiv'_above (Fin.zero_le _) #align fin_succ_equiv_succ finSuccEquiv_succ @[simp] theorem finSuccEquiv_symm_none : (finSuccEquiv n).symm none = 0 := finSuccEquiv'_symm_none _ #align fin_succ_equiv_symm_none finSuccEquiv_symm_none @[simp] theorem finSuccEquiv_symm_some (m : Fin n) : (finSuccEquiv n).symm (some m) = m.succ := congr_fun Fin.succAbove_zero m #align fin_succ_equiv_symm_some finSuccEquiv_symm_some #align fin_succ_equiv_symm_coe finSuccEquiv_symm_some theorem finSuccEquiv'_zero : finSuccEquiv' (0 : Fin (n + 1)) = finSuccEquiv n := rfl #align fin_succ_equiv'_zero finSuccEquiv'_zero theorem finSuccEquiv'_last_apply_castSucc (i : Fin n) : finSuccEquiv' (Fin.last n) (Fin.castSucc i) = i := by rw [← Fin.succAbove_last, finSuccEquiv'_succAbove] theorem finSuccEquiv'_last_apply {i : Fin (n + 1)} (h : i ≠ Fin.last n) : finSuccEquiv' (Fin.last n) i = Fin.castLT i (Fin.val_lt_last h) := by rcases Fin.exists_castSucc_eq.2 h with ⟨i, rfl⟩ rw [finSuccEquiv'_last_apply_castSucc] rfl #align fin_succ_equiv'_last_apply finSuccEquiv'_last_apply theorem finSuccEquiv'_ne_last_apply {i j : Fin (n + 1)} (hi : i ≠ Fin.last n) (hj : j ≠ i) : finSuccEquiv' i j = (i.castLT (Fin.val_lt_last hi)).predAbove j := by rcases Fin.exists_succAbove_eq hj with ⟨j, rfl⟩ rcases Fin.exists_castSucc_eq.2 hi with ⟨i, rfl⟩ simp #align fin_succ_equiv'_ne_last_apply finSuccEquiv'_ne_last_apply def finSuccAboveEquiv (p : Fin (n + 1)) : Fin n ≃o { x : Fin (n + 1) // x ≠ p } := { Equiv.optionSubtype p ⟨(finSuccEquiv' p).symm, rfl⟩ with map_rel_iff' := p.succAboveOrderEmb.map_rel_iff' } #align fin_succ_above_equiv finSuccAboveEquiv theorem finSuccAboveEquiv_apply (p : Fin (n + 1)) (i : Fin n) : finSuccAboveEquiv p i = ⟨p.succAbove i, p.succAbove_ne i⟩ := rfl #align fin_succ_above_equiv_apply finSuccAboveEquiv_apply theorem finSuccAboveEquiv_symm_apply_last (x : { x : Fin (n + 1) // x ≠ Fin.last n }) : (finSuccAboveEquiv (Fin.last n)).symm x = Fin.castLT x.1 (Fin.val_lt_last x.2) := by rw [← Option.some_inj] simpa [finSuccAboveEquiv, OrderIso.symm] using finSuccEquiv'_last_apply x.property #align fin_succ_above_equiv_symm_apply_last finSuccAboveEquiv_symm_apply_last theorem finSuccAboveEquiv_symm_apply_ne_last {p : Fin (n + 1)} (h : p ≠ Fin.last n) (x : { x : Fin (n + 1) // x ≠ p }) : (finSuccAboveEquiv p).symm x = (p.castLT (Fin.val_lt_last h)).predAbove x := by rw [← Option.some_inj] simpa [finSuccAboveEquiv, OrderIso.symm] using finSuccEquiv'_ne_last_apply h x.property #align fin_succ_above_equiv_symm_apply_ne_last finSuccAboveEquiv_symm_apply_ne_last def finSuccEquivLast : Fin (n + 1) ≃ Option (Fin n) := finSuccEquiv' (Fin.last n) #align fin_succ_equiv_last finSuccEquivLast @[simp] theorem finSuccEquivLast_castSucc (i : Fin n) : finSuccEquivLast (Fin.castSucc i) = some i := finSuccEquiv'_below i.2 #align fin_succ_equiv_last_cast_succ finSuccEquivLast_castSucc @[simp] theorem finSuccEquivLast_last : finSuccEquivLast (Fin.last n) = none := by simp [finSuccEquivLast] #align fin_succ_equiv_last_last finSuccEquivLast_last @[simp] theorem finSuccEquivLast_symm_some (i : Fin n) : finSuccEquivLast.symm (some i) = Fin.castSucc i := finSuccEquiv'_symm_some_below i.2 #align fin_succ_equiv_last_symm_some finSuccEquivLast_symm_some #align fin_succ_equiv_last_symm_coe finSuccEquivLast_symm_some @[simp] theorem finSuccEquivLast_symm_none : finSuccEquivLast.symm none = Fin.last n := finSuccEquiv'_symm_none _ #align fin_succ_equiv_last_symm_none finSuccEquivLast_symm_none @[simps (config := .asFn)] def Equiv.piFinSuccAbove (α : Fin (n + 1) → Type u) (i : Fin (n + 1)) : (∀ j, α j) ≃ α i × ∀ j, α (i.succAbove j) where toFun f := i.extractNth f invFun f := i.insertNth f.1 f.2 left_inv f := by simp right_inv f := by simp #align equiv.pi_fin_succ_above_equiv Equiv.piFinSuccAbove #align equiv.pi_fin_succ_above_equiv_apply Equiv.piFinSuccAbove_apply #align equiv.pi_fin_succ_above_equiv_symm_apply Equiv.piFinSuccAbove_symm_apply def OrderIso.piFinSuccAboveIso (α : Fin (n + 1) → Type u) [∀ i, LE (α i)] (i : Fin (n + 1)) : (∀ j, α j) ≃o α i × ∀ j, α (i.succAbove j) where toEquiv := Equiv.piFinSuccAbove α i map_rel_iff' := Iff.symm i.forall_iff_succAbove #align order_iso.pi_fin_succ_above_iso OrderIso.piFinSuccAboveIso @[simps! (config := .asFn)] def Equiv.piFinSucc (n : ℕ) (β : Type u) : (Fin (n + 1) → β) ≃ β × (Fin n → β) := Equiv.piFinSuccAbove (fun _ => β) 0 #align equiv.pi_fin_succ Equiv.piFinSucc #align equiv.pi_fin_succ_apply Equiv.piFinSucc_apply #align equiv.pi_fin_succ_symm_apply Equiv.piFinSucc_symm_apply def Equiv.embeddingFinSucc (n : ℕ) (ι : Type*) : (Fin (n+1) ↪ ι) ≃ (Σ (e : Fin n ↪ ι), {i // i ∉ Set.range e}) := ((finSuccEquiv n).embeddingCongr (Equiv.refl ι)).trans (Function.Embedding.optionEmbeddingEquiv (Fin n) ι) @[simp] lemma Equiv.embeddingFinSucc_fst {n : ℕ} {ι : Type*} (e : Fin (n+1) ↪ ι) : ((Equiv.embeddingFinSucc n ι e).1 : Fin n → ι) = e ∘ Fin.succ := rfl @[simp] lemma Equiv.embeddingFinSucc_snd {n : ℕ} {ι : Type*} (e : Fin (n+1) ↪ ι) : ((Equiv.embeddingFinSucc n ι e).2 : ι) = e 0 := rfl @[simp] lemma Equiv.coe_embeddingFinSucc_symm {n : ℕ} {ι : Type*} (f : Σ (e : Fin n ↪ ι), {i // i ∉ Set.range e}) : ((Equiv.embeddingFinSucc n ι).symm f : Fin (n + 1) → ι) = Fin.cons f.2.1 f.1 := by ext i exact Fin.cases rfl (fun j ↦ rfl) i @[simps! (config := .asFn)] def Equiv.piFinCastSucc (n : ℕ) (β : Type u) : (Fin (n + 1) → β) ≃ β × (Fin n → β) := Equiv.piFinSuccAbove (fun _ => β) (.last _) def finSumFinEquiv : Sum (Fin m) (Fin n) ≃ Fin (m + n) where toFun := Sum.elim (Fin.castAdd n) (Fin.natAdd m) invFun i := @Fin.addCases m n (fun _ => Sum (Fin m) (Fin n)) Sum.inl Sum.inr i left_inv x := by cases' x with y y <;> dsimp <;> simp right_inv x := by refine Fin.addCases (fun i => ?_) (fun i => ?_) x <;> simp #align fin_sum_fin_equiv finSumFinEquiv @[simp] theorem finSumFinEquiv_apply_left (i : Fin m) : (finSumFinEquiv (Sum.inl i) : Fin (m + n)) = Fin.castAdd n i := rfl #align fin_sum_fin_equiv_apply_left finSumFinEquiv_apply_left @[simp] theorem finSumFinEquiv_apply_right (i : Fin n) : (finSumFinEquiv (Sum.inr i) : Fin (m + n)) = Fin.natAdd m i := rfl #align fin_sum_fin_equiv_apply_right finSumFinEquiv_apply_right @[simp] theorem finSumFinEquiv_symm_apply_castAdd (x : Fin m) : finSumFinEquiv.symm (Fin.castAdd n x) = Sum.inl x := finSumFinEquiv.symm_apply_apply (Sum.inl x) #align fin_sum_fin_equiv_symm_apply_cast_add finSumFinEquiv_symm_apply_castAdd @[simp] theorem finSumFinEquiv_symm_apply_natAdd (x : Fin n) : finSumFinEquiv.symm (Fin.natAdd m x) = Sum.inr x := finSumFinEquiv.symm_apply_apply (Sum.inr x) #align fin_sum_fin_equiv_symm_apply_nat_add finSumFinEquiv_symm_apply_natAdd @[simp] theorem finSumFinEquiv_symm_last : finSumFinEquiv.symm (Fin.last n) = Sum.inr 0 := finSumFinEquiv_symm_apply_natAdd 0 #align fin_sum_fin_equiv_symm_last finSumFinEquiv_symm_last def finAddFlip : Fin (m + n) ≃ Fin (n + m) := (finSumFinEquiv.symm.trans (Equiv.sumComm _ _)).trans finSumFinEquiv #align fin_add_flip finAddFlip @[simp] theorem finAddFlip_apply_castAdd (k : Fin m) (n : ℕ) : finAddFlip (Fin.castAdd n k) = Fin.natAdd n k := by simp [finAddFlip] #align fin_add_flip_apply_cast_add finAddFlip_apply_castAdd @[simp] theorem finAddFlip_apply_natAdd (k : Fin n) (m : ℕ) : finAddFlip (Fin.natAdd m k) = Fin.castAdd m k := by simp [finAddFlip] #align fin_add_flip_apply_nat_add finAddFlip_apply_natAdd @[simp] theorem finAddFlip_apply_mk_left {k : ℕ} (h : k < m) (hk : k < m + n := Nat.lt_add_right n h) (hnk : n + k < n + m := Nat.add_lt_add_left h n) : finAddFlip (⟨k, hk⟩ : Fin (m + n)) = ⟨n + k, hnk⟩ := by convert finAddFlip_apply_castAdd ⟨k, h⟩ n #align fin_add_flip_apply_mk_left finAddFlip_apply_mk_left @[simp] theorem finAddFlip_apply_mk_right {k : ℕ} (h₁ : m ≤ k) (h₂ : k < m + n) : finAddFlip (⟨k, h₂⟩ : Fin (m + n)) = ⟨k - m, by omega⟩ := by convert @finAddFlip_apply_natAdd n ⟨k - m, by omega⟩ m simp [Nat.add_sub_cancel' h₁] #align fin_add_flip_apply_mk_right finAddFlip_apply_mk_right def finRotate : ∀ n, Equiv.Perm (Fin n) | 0 => Equiv.refl _ | n + 1 => finAddFlip.trans (finCongr (Nat.add_comm 1 n)) #align fin_rotate finRotate @[simp] lemma finRotate_zero : finRotate 0 = Equiv.refl _ := rfl #align fin_rotate_zero finRotate_zero lemma finRotate_succ (n : ℕ) : finRotate (n + 1) = finAddFlip.trans (finCongr (Nat.add_comm 1 n)) := rfl theorem finRotate_of_lt {k : ℕ} (h : k < n) : finRotate (n + 1) ⟨k, h.trans_le n.le_succ⟩ = ⟨k + 1, Nat.succ_lt_succ h⟩ := by ext dsimp [finRotate_succ] simp [finAddFlip_apply_mk_left h, Nat.add_comm] #align fin_rotate_of_lt finRotate_of_lt theorem finRotate_last' : finRotate (n + 1) ⟨n, by omega⟩ = ⟨0, Nat.zero_lt_succ _⟩ := by dsimp [finRotate_succ] rw [finAddFlip_apply_mk_right le_rfl] simp #align fin_rotate_last' finRotate_last' theorem finRotate_last : finRotate (n + 1) (Fin.last _) = 0 := finRotate_last' #align fin_rotate_last finRotate_last theorem Fin.snoc_eq_cons_rotate {α : Type*} (v : Fin n → α) (a : α) : @Fin.snoc _ (fun _ => α) v a = fun i => @Fin.cons _ (fun _ => α) a v (finRotate _ i) := by ext ⟨i, h⟩ by_cases h' : i < n · rw [finRotate_of_lt h', Fin.snoc, Fin.cons, dif_pos h'] rfl · have h'' : n = i := by simp only [not_lt] at h' exact (Nat.eq_of_le_of_lt_succ h' h).symm subst h'' rw [finRotate_last', Fin.snoc, Fin.cons, dif_neg (lt_irrefl _)] rfl #align fin.snoc_eq_cons_rotate Fin.snoc_eq_cons_rotate @[simp] theorem finRotate_one : finRotate 1 = Equiv.refl _ := Subsingleton.elim _ _ #align fin_rotate_one finRotate_one @[simp] theorem finRotate_succ_apply (i : Fin (n + 1)) : finRotate (n + 1) i = i + 1 := by cases n · exact @Subsingleton.elim (Fin 1) _ _ _ rcases i.le_last.eq_or_lt with (rfl | h) · simp [finRotate_last] · cases i simp only [Fin.lt_iff_val_lt_val, Fin.val_last, Fin.val_mk] at h simp [finRotate_of_lt h, Fin.ext_iff, Fin.add_def, Nat.mod_eq_of_lt (Nat.succ_lt_succ h)] #align fin_rotate_succ_apply finRotate_succ_apply -- Porting note: was a @[simp] theorem finRotate_apply_zero : finRotate n.succ 0 = 1 := by rw [finRotate_succ_apply, Fin.zero_add] #align fin_rotate_apply_zero finRotate_apply_zero
Mathlib/Logic/Equiv/Fin.lean
445
449
theorem coe_finRotate_of_ne_last {i : Fin n.succ} (h : i ≠ Fin.last n) : (finRotate (n + 1) i : ℕ) = i + 1 := by
rw [finRotate_succ_apply] have : (i : ℕ) < n := Fin.val_lt_last h exact Fin.val_add_one_of_lt this
import Mathlib.MeasureTheory.Measure.MeasureSpace open scoped ENNReal NNReal Topology open Set MeasureTheory Measure Filter MeasurableSpace ENNReal Function variable {R α β δ γ ι : Type*} namespace MeasureTheory variable {m0 : MeasurableSpace α} [MeasurableSpace β] [MeasurableSpace γ] variable {μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α} {s s' t : Set α} namespace Measure noncomputable def restrictₗ {m0 : MeasurableSpace α} (s : Set α) : Measure α →ₗ[ℝ≥0∞] Measure α := liftLinear (OuterMeasure.restrict s) fun μ s' hs' t => by suffices μ (s ∩ t) = μ (s ∩ t ∩ s') + μ ((s ∩ t) \ s') by simpa [← Set.inter_assoc, Set.inter_comm _ s, ← inter_diff_assoc] exact le_toOuterMeasure_caratheodory _ _ hs' _ #align measure_theory.measure.restrictₗ MeasureTheory.Measure.restrictₗ noncomputable def restrict {_m0 : MeasurableSpace α} (μ : Measure α) (s : Set α) : Measure α := restrictₗ s μ #align measure_theory.measure.restrict MeasureTheory.Measure.restrict @[simp] theorem restrictₗ_apply {_m0 : MeasurableSpace α} (s : Set α) (μ : Measure α) : restrictₗ s μ = μ.restrict s := rfl #align measure_theory.measure.restrictₗ_apply MeasureTheory.Measure.restrictₗ_apply theorem restrict_toOuterMeasure_eq_toOuterMeasure_restrict (h : MeasurableSet s) : (μ.restrict s).toOuterMeasure = OuterMeasure.restrict s μ.toOuterMeasure := by simp_rw [restrict, restrictₗ, liftLinear, LinearMap.coe_mk, AddHom.coe_mk, toMeasure_toOuterMeasure, OuterMeasure.restrict_trim h, μ.trimmed] #align measure_theory.measure.restrict_to_outer_measure_eq_to_outer_measure_restrict MeasureTheory.Measure.restrict_toOuterMeasure_eq_toOuterMeasure_restrict theorem restrict_apply₀ (ht : NullMeasurableSet t (μ.restrict s)) : μ.restrict s t = μ (t ∩ s) := by rw [← restrictₗ_apply, restrictₗ, liftLinear_apply₀ _ ht, OuterMeasure.restrict_apply, coe_toOuterMeasure] #align measure_theory.measure.restrict_apply₀ MeasureTheory.Measure.restrict_apply₀ @[simp] theorem restrict_apply (ht : MeasurableSet t) : μ.restrict s t = μ (t ∩ s) := restrict_apply₀ ht.nullMeasurableSet #align measure_theory.measure.restrict_apply MeasureTheory.Measure.restrict_apply theorem restrict_mono' {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ ⦃μ ν : Measure α⦄ (hs : s ≤ᵐ[μ] s') (hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' := Measure.le_iff.2 fun t ht => calc μ.restrict s t = μ (t ∩ s) := restrict_apply ht _ ≤ μ (t ∩ s') := (measure_mono_ae <| hs.mono fun _x hx ⟨hxt, hxs⟩ => ⟨hxt, hx hxs⟩) _ ≤ ν (t ∩ s') := le_iff'.1 hμν (t ∩ s') _ = ν.restrict s' t := (restrict_apply ht).symm #align measure_theory.measure.restrict_mono' MeasureTheory.Measure.restrict_mono' @[mono] theorem restrict_mono {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ (hs : s ⊆ s') ⦃μ ν : Measure α⦄ (hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' := restrict_mono' (ae_of_all _ hs) hμν #align measure_theory.measure.restrict_mono MeasureTheory.Measure.restrict_mono theorem restrict_mono_ae (h : s ≤ᵐ[μ] t) : μ.restrict s ≤ μ.restrict t := restrict_mono' h (le_refl μ) #align measure_theory.measure.restrict_mono_ae MeasureTheory.Measure.restrict_mono_ae theorem restrict_congr_set (h : s =ᵐ[μ] t) : μ.restrict s = μ.restrict t := le_antisymm (restrict_mono_ae h.le) (restrict_mono_ae h.symm.le) #align measure_theory.measure.restrict_congr_set MeasureTheory.Measure.restrict_congr_set @[simp] theorem restrict_apply' (hs : MeasurableSet s) : μ.restrict s t = μ (t ∩ s) := by rw [← toOuterMeasure_apply, Measure.restrict_toOuterMeasure_eq_toOuterMeasure_restrict hs, OuterMeasure.restrict_apply s t _, toOuterMeasure_apply] #align measure_theory.measure.restrict_apply' MeasureTheory.Measure.restrict_apply' theorem restrict_apply₀' (hs : NullMeasurableSet s μ) : μ.restrict s t = μ (t ∩ s) := by rw [← restrict_congr_set hs.toMeasurable_ae_eq, restrict_apply' (measurableSet_toMeasurable _ _), measure_congr ((ae_eq_refl t).inter hs.toMeasurable_ae_eq)] #align measure_theory.measure.restrict_apply₀' MeasureTheory.Measure.restrict_apply₀' theorem restrict_le_self : μ.restrict s ≤ μ := Measure.le_iff.2 fun t ht => calc μ.restrict s t = μ (t ∩ s) := restrict_apply ht _ ≤ μ t := measure_mono inter_subset_left #align measure_theory.measure.restrict_le_self MeasureTheory.Measure.restrict_le_self variable (μ) theorem restrict_eq_self (h : s ⊆ t) : μ.restrict t s = μ s := (le_iff'.1 restrict_le_self s).antisymm <| calc μ s ≤ μ (toMeasurable (μ.restrict t) s ∩ t) := measure_mono (subset_inter (subset_toMeasurable _ _) h) _ = μ.restrict t s := by rw [← restrict_apply (measurableSet_toMeasurable _ _), measure_toMeasurable] #align measure_theory.measure.restrict_eq_self MeasureTheory.Measure.restrict_eq_self @[simp] theorem restrict_apply_self (s : Set α) : (μ.restrict s) s = μ s := restrict_eq_self μ Subset.rfl #align measure_theory.measure.restrict_apply_self MeasureTheory.Measure.restrict_apply_self variable {μ} theorem restrict_apply_univ (s : Set α) : μ.restrict s univ = μ s := by rw [restrict_apply MeasurableSet.univ, Set.univ_inter] #align measure_theory.measure.restrict_apply_univ MeasureTheory.Measure.restrict_apply_univ theorem le_restrict_apply (s t : Set α) : μ (t ∩ s) ≤ μ.restrict s t := calc μ (t ∩ s) = μ.restrict s (t ∩ s) := (restrict_eq_self μ inter_subset_right).symm _ ≤ μ.restrict s t := measure_mono inter_subset_left #align measure_theory.measure.le_restrict_apply MeasureTheory.Measure.le_restrict_apply theorem restrict_apply_le (s t : Set α) : μ.restrict s t ≤ μ t := Measure.le_iff'.1 restrict_le_self _ theorem restrict_apply_superset (h : s ⊆ t) : μ.restrict s t = μ s := ((measure_mono (subset_univ _)).trans_eq <| restrict_apply_univ _).antisymm ((restrict_apply_self μ s).symm.trans_le <| measure_mono h) #align measure_theory.measure.restrict_apply_superset MeasureTheory.Measure.restrict_apply_superset @[simp] theorem restrict_add {_m0 : MeasurableSpace α} (μ ν : Measure α) (s : Set α) : (μ + ν).restrict s = μ.restrict s + ν.restrict s := (restrictₗ s).map_add μ ν #align measure_theory.measure.restrict_add MeasureTheory.Measure.restrict_add @[simp] theorem restrict_zero {_m0 : MeasurableSpace α} (s : Set α) : (0 : Measure α).restrict s = 0 := (restrictₗ s).map_zero #align measure_theory.measure.restrict_zero MeasureTheory.Measure.restrict_zero @[simp] theorem restrict_smul {_m0 : MeasurableSpace α} (c : ℝ≥0∞) (μ : Measure α) (s : Set α) : (c • μ).restrict s = c • μ.restrict s := (restrictₗ s).map_smul c μ #align measure_theory.measure.restrict_smul MeasureTheory.Measure.restrict_smul theorem restrict_restrict₀ (hs : NullMeasurableSet s (μ.restrict t)) : (μ.restrict t).restrict s = μ.restrict (s ∩ t) := ext fun u hu => by simp only [Set.inter_assoc, restrict_apply hu, restrict_apply₀ (hu.nullMeasurableSet.inter hs)] #align measure_theory.measure.restrict_restrict₀ MeasureTheory.Measure.restrict_restrict₀ @[simp] theorem restrict_restrict (hs : MeasurableSet s) : (μ.restrict t).restrict s = μ.restrict (s ∩ t) := restrict_restrict₀ hs.nullMeasurableSet #align measure_theory.measure.restrict_restrict MeasureTheory.Measure.restrict_restrict theorem restrict_restrict_of_subset (h : s ⊆ t) : (μ.restrict t).restrict s = μ.restrict s := by ext1 u hu rw [restrict_apply hu, restrict_apply hu, restrict_eq_self] exact inter_subset_right.trans h #align measure_theory.measure.restrict_restrict_of_subset MeasureTheory.Measure.restrict_restrict_of_subset theorem restrict_restrict₀' (ht : NullMeasurableSet t μ) : (μ.restrict t).restrict s = μ.restrict (s ∩ t) := ext fun u hu => by simp only [restrict_apply hu, restrict_apply₀' ht, inter_assoc] #align measure_theory.measure.restrict_restrict₀' MeasureTheory.Measure.restrict_restrict₀' theorem restrict_restrict' (ht : MeasurableSet t) : (μ.restrict t).restrict s = μ.restrict (s ∩ t) := restrict_restrict₀' ht.nullMeasurableSet #align measure_theory.measure.restrict_restrict' MeasureTheory.Measure.restrict_restrict' theorem restrict_comm (hs : MeasurableSet s) : (μ.restrict t).restrict s = (μ.restrict s).restrict t := by rw [restrict_restrict hs, restrict_restrict' hs, inter_comm] #align measure_theory.measure.restrict_comm MeasureTheory.Measure.restrict_comm theorem restrict_apply_eq_zero (ht : MeasurableSet t) : μ.restrict s t = 0 ↔ μ (t ∩ s) = 0 := by rw [restrict_apply ht] #align measure_theory.measure.restrict_apply_eq_zero MeasureTheory.Measure.restrict_apply_eq_zero theorem measure_inter_eq_zero_of_restrict (h : μ.restrict s t = 0) : μ (t ∩ s) = 0 := nonpos_iff_eq_zero.1 (h ▸ le_restrict_apply _ _) #align measure_theory.measure.measure_inter_eq_zero_of_restrict MeasureTheory.Measure.measure_inter_eq_zero_of_restrict theorem restrict_apply_eq_zero' (hs : MeasurableSet s) : μ.restrict s t = 0 ↔ μ (t ∩ s) = 0 := by rw [restrict_apply' hs] #align measure_theory.measure.restrict_apply_eq_zero' MeasureTheory.Measure.restrict_apply_eq_zero' @[simp] theorem restrict_eq_zero : μ.restrict s = 0 ↔ μ s = 0 := by rw [← measure_univ_eq_zero, restrict_apply_univ] #align measure_theory.measure.restrict_eq_zero MeasureTheory.Measure.restrict_eq_zero instance restrict.neZero [NeZero (μ s)] : NeZero (μ.restrict s) := ⟨mt restrict_eq_zero.mp <| NeZero.ne _⟩ theorem restrict_zero_set {s : Set α} (h : μ s = 0) : μ.restrict s = 0 := restrict_eq_zero.2 h #align measure_theory.measure.restrict_zero_set MeasureTheory.Measure.restrict_zero_set @[simp] theorem restrict_empty : μ.restrict ∅ = 0 := restrict_zero_set measure_empty #align measure_theory.measure.restrict_empty MeasureTheory.Measure.restrict_empty @[simp] theorem restrict_univ : μ.restrict univ = μ := ext fun s hs => by simp [hs] #align measure_theory.measure.restrict_univ MeasureTheory.Measure.restrict_univ
Mathlib/MeasureTheory/Measure/Restrict.lean
243
247
theorem restrict_inter_add_diff₀ (s : Set α) (ht : NullMeasurableSet t μ) : μ.restrict (s ∩ t) + μ.restrict (s \ t) = μ.restrict s := by
ext1 u hu simp only [add_apply, restrict_apply hu, ← inter_assoc, diff_eq] exact measure_inter_add_diff₀ (u ∩ s) ht
import Mathlib.Algebra.Order.Monoid.Defs import Mathlib.Algebra.Order.Sub.Defs import Mathlib.Util.AssertExists #align_import algebra.order.group.defs from "leanprover-community/mathlib"@"b599f4e4e5cf1fbcb4194503671d3d9e569c1fce" open Function universe u variable {α : Type u} class OrderedAddCommGroup (α : Type u) extends AddCommGroup α, PartialOrder α where protected add_le_add_left : ∀ a b : α, a ≤ b → ∀ c : α, c + a ≤ c + b #align ordered_add_comm_group OrderedAddCommGroup class OrderedCommGroup (α : Type u) extends CommGroup α, PartialOrder α where protected mul_le_mul_left : ∀ a b : α, a ≤ b → ∀ c : α, c * a ≤ c * b #align ordered_comm_group OrderedCommGroup attribute [to_additive] OrderedCommGroup @[to_additive] instance OrderedCommGroup.to_covariantClass_left_le (α : Type u) [OrderedCommGroup α] : CovariantClass α α (· * ·) (· ≤ ·) where elim a b c bc := OrderedCommGroup.mul_le_mul_left b c bc a #align ordered_comm_group.to_covariant_class_left_le OrderedCommGroup.to_covariantClass_left_le #align ordered_add_comm_group.to_covariant_class_left_le OrderedAddCommGroup.to_covariantClass_left_le -- See note [lower instance priority] @[to_additive OrderedAddCommGroup.toOrderedCancelAddCommMonoid] instance (priority := 100) OrderedCommGroup.toOrderedCancelCommMonoid [OrderedCommGroup α] : OrderedCancelCommMonoid α := { ‹OrderedCommGroup α› with le_of_mul_le_mul_left := fun a b c ↦ le_of_mul_le_mul_left' } #align ordered_comm_group.to_ordered_cancel_comm_monoid OrderedCommGroup.toOrderedCancelCommMonoid #align ordered_add_comm_group.to_ordered_cancel_add_comm_monoid OrderedAddCommGroup.toOrderedCancelAddCommMonoid example (α : Type u) [OrderedAddCommGroup α] : CovariantClass α α (swap (· + ·)) (· < ·) := IsRightCancelAdd.covariant_swap_add_lt_of_covariant_swap_add_le α -- Porting note: this instance is not used, -- and causes timeouts after lean4#2210. -- It was introduced in https://github.com/leanprover-community/mathlib/pull/17564 -- but without the motivation clearly explained. @[to_additive "A choice-free shortcut instance."] theorem OrderedCommGroup.to_contravariantClass_left_le (α : Type u) [OrderedCommGroup α] : ContravariantClass α α (· * ·) (· ≤ ·) where elim a b c bc := by simpa using mul_le_mul_left' bc a⁻¹ #align ordered_comm_group.to_contravariant_class_left_le OrderedCommGroup.to_contravariantClass_left_le #align ordered_add_comm_group.to_contravariant_class_left_le OrderedAddCommGroup.to_contravariantClass_left_le -- Porting note: this instance is not used, -- and causes timeouts after lean4#2210. -- See further explanation on `OrderedCommGroup.to_contravariantClass_left_le`. @[to_additive "A choice-free shortcut instance."] theorem OrderedCommGroup.to_contravariantClass_right_le (α : Type u) [OrderedCommGroup α] : ContravariantClass α α (swap (· * ·)) (· ≤ ·) where elim a b c bc := by simpa using mul_le_mul_right' bc a⁻¹ #align ordered_comm_group.to_contravariant_class_right_le OrderedCommGroup.to_contravariantClass_right_le #align ordered_add_comm_group.to_contravariant_class_right_le OrderedAddCommGroup.to_contravariantClass_right_le section Group variable [Group α] section TypeclassesLeftLT variable [LT α] [CovariantClass α α (· * ·) (· < ·)] {a b c : α} @[to_additive (attr := simp) Left.neg_pos_iff "Uses `left` co(ntra)variant."] theorem Left.one_lt_inv_iff : 1 < a⁻¹ ↔ a < 1 := by rw [← mul_lt_mul_iff_left a, mul_inv_self, mul_one] #align left.one_lt_inv_iff Left.one_lt_inv_iff #align left.neg_pos_iff Left.neg_pos_iff @[to_additive (attr := simp) "Uses `left` co(ntra)variant."]
Mathlib/Algebra/Order/Group/Defs.lean
165
166
theorem Left.inv_lt_one_iff : a⁻¹ < 1 ↔ 1 < a := by
rw [← mul_lt_mul_iff_left a, mul_inv_self, mul_one]
import Mathlib.Topology.Constructions #align_import topology.continuous_on from "leanprover-community/mathlib"@"d4f691b9e5f94cfc64639973f3544c95f8d5d494" open Set Filter Function Topology Filter variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} variable [TopologicalSpace α] @[simp] theorem nhds_bind_nhdsWithin {a : α} {s : Set α} : ((𝓝 a).bind fun x => 𝓝[s] x) = 𝓝[s] a := bind_inf_principal.trans <| congr_arg₂ _ nhds_bind_nhds rfl #align nhds_bind_nhds_within nhds_bind_nhdsWithin @[simp] theorem eventually_nhds_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝 a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := Filter.ext_iff.1 nhds_bind_nhdsWithin { x | p x } #align eventually_nhds_nhds_within eventually_nhds_nhdsWithin theorem eventually_nhdsWithin_iff {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ x in 𝓝[s] a, p x) ↔ ∀ᶠ x in 𝓝 a, x ∈ s → p x := eventually_inf_principal #align eventually_nhds_within_iff eventually_nhdsWithin_iff theorem frequently_nhdsWithin_iff {z : α} {s : Set α} {p : α → Prop} : (∃ᶠ x in 𝓝[s] z, p x) ↔ ∃ᶠ x in 𝓝 z, p x ∧ x ∈ s := frequently_inf_principal.trans <| by simp only [and_comm] #align frequently_nhds_within_iff frequently_nhdsWithin_iff theorem mem_closure_ne_iff_frequently_within {z : α} {s : Set α} : z ∈ closure (s \ {z}) ↔ ∃ᶠ x in 𝓝[≠] z, x ∈ s := by simp [mem_closure_iff_frequently, frequently_nhdsWithin_iff] #align mem_closure_ne_iff_frequently_within mem_closure_ne_iff_frequently_within @[simp] theorem eventually_nhdsWithin_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝[s] a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := by refine ⟨fun h => ?_, fun h => (eventually_nhds_nhdsWithin.2 h).filter_mono inf_le_left⟩ simp only [eventually_nhdsWithin_iff] at h ⊢ exact h.mono fun x hx hxs => (hx hxs).self_of_nhds hxs #align eventually_nhds_within_nhds_within eventually_nhdsWithin_nhdsWithin theorem nhdsWithin_eq (a : α) (s : Set α) : 𝓝[s] a = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (t ∩ s) := ((nhds_basis_opens a).inf_principal s).eq_biInf #align nhds_within_eq nhdsWithin_eq theorem nhdsWithin_univ (a : α) : 𝓝[Set.univ] a = 𝓝 a := by rw [nhdsWithin, principal_univ, inf_top_eq] #align nhds_within_univ nhdsWithin_univ theorem nhdsWithin_hasBasis {p : β → Prop} {s : β → Set α} {a : α} (h : (𝓝 a).HasBasis p s) (t : Set α) : (𝓝[t] a).HasBasis p fun i => s i ∩ t := h.inf_principal t #align nhds_within_has_basis nhdsWithin_hasBasis theorem nhdsWithin_basis_open (a : α) (t : Set α) : (𝓝[t] a).HasBasis (fun u => a ∈ u ∧ IsOpen u) fun u => u ∩ t := nhdsWithin_hasBasis (nhds_basis_opens a) t #align nhds_within_basis_open nhdsWithin_basis_open theorem mem_nhdsWithin {t : Set α} {a : α} {s : Set α} : t ∈ 𝓝[s] a ↔ ∃ u, IsOpen u ∧ a ∈ u ∧ u ∩ s ⊆ t := by simpa only [and_assoc, and_left_comm] using (nhdsWithin_basis_open a s).mem_iff #align mem_nhds_within mem_nhdsWithin theorem mem_nhdsWithin_iff_exists_mem_nhds_inter {t : Set α} {a : α} {s : Set α} : t ∈ 𝓝[s] a ↔ ∃ u ∈ 𝓝 a, u ∩ s ⊆ t := (nhdsWithin_hasBasis (𝓝 a).basis_sets s).mem_iff #align mem_nhds_within_iff_exists_mem_nhds_inter mem_nhdsWithin_iff_exists_mem_nhds_inter theorem diff_mem_nhdsWithin_compl {x : α} {s : Set α} (hs : s ∈ 𝓝 x) (t : Set α) : s \ t ∈ 𝓝[tᶜ] x := diff_mem_inf_principal_compl hs t #align diff_mem_nhds_within_compl diff_mem_nhdsWithin_compl theorem diff_mem_nhdsWithin_diff {x : α} {s t : Set α} (hs : s ∈ 𝓝[t] x) (t' : Set α) : s \ t' ∈ 𝓝[t \ t'] x := by rw [nhdsWithin, diff_eq, diff_eq, ← inf_principal, ← inf_assoc] exact inter_mem_inf hs (mem_principal_self _) #align diff_mem_nhds_within_diff diff_mem_nhdsWithin_diff theorem nhds_of_nhdsWithin_of_nhds {s t : Set α} {a : α} (h1 : s ∈ 𝓝 a) (h2 : t ∈ 𝓝[s] a) : t ∈ 𝓝 a := by rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.mp h2 with ⟨_, Hw, hw⟩ exact (𝓝 a).sets_of_superset ((𝓝 a).inter_sets Hw h1) hw #align nhds_of_nhds_within_of_nhds nhds_of_nhdsWithin_of_nhds theorem mem_nhdsWithin_iff_eventually {s t : Set α} {x : α} : t ∈ 𝓝[s] x ↔ ∀ᶠ y in 𝓝 x, y ∈ s → y ∈ t := eventually_inf_principal #align mem_nhds_within_iff_eventually mem_nhdsWithin_iff_eventually theorem mem_nhdsWithin_iff_eventuallyEq {s t : Set α} {x : α} : t ∈ 𝓝[s] x ↔ s =ᶠ[𝓝 x] (s ∩ t : Set α) := by simp_rw [mem_nhdsWithin_iff_eventually, eventuallyEq_set, mem_inter_iff, iff_self_and] #align mem_nhds_within_iff_eventually_eq mem_nhdsWithin_iff_eventuallyEq theorem nhdsWithin_eq_iff_eventuallyEq {s t : Set α} {x : α} : 𝓝[s] x = 𝓝[t] x ↔ s =ᶠ[𝓝 x] t := set_eventuallyEq_iff_inf_principal.symm #align nhds_within_eq_iff_eventually_eq nhdsWithin_eq_iff_eventuallyEq theorem nhdsWithin_le_iff {s t : Set α} {x : α} : 𝓝[s] x ≤ 𝓝[t] x ↔ t ∈ 𝓝[s] x := set_eventuallyLE_iff_inf_principal_le.symm.trans set_eventuallyLE_iff_mem_inf_principal #align nhds_within_le_iff nhdsWithin_le_iff -- Porting note: golfed, dropped an unneeded assumption theorem preimage_nhdsWithin_coinduced' {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t) (hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) : π ⁻¹' s ∈ 𝓝[t] a := by lift a to t using h replace hs : (fun x : t => π x) ⁻¹' s ∈ 𝓝 a := preimage_nhds_coinduced hs rwa [← map_nhds_subtype_val, mem_map] #align preimage_nhds_within_coinduced' preimage_nhdsWithin_coinduced'ₓ theorem mem_nhdsWithin_of_mem_nhds {s t : Set α} {a : α} (h : s ∈ 𝓝 a) : s ∈ 𝓝[t] a := mem_inf_of_left h #align mem_nhds_within_of_mem_nhds mem_nhdsWithin_of_mem_nhds theorem self_mem_nhdsWithin {a : α} {s : Set α} : s ∈ 𝓝[s] a := mem_inf_of_right (mem_principal_self s) #align self_mem_nhds_within self_mem_nhdsWithin theorem eventually_mem_nhdsWithin {a : α} {s : Set α} : ∀ᶠ x in 𝓝[s] a, x ∈ s := self_mem_nhdsWithin #align eventually_mem_nhds_within eventually_mem_nhdsWithin theorem inter_mem_nhdsWithin (s : Set α) {t : Set α} {a : α} (h : t ∈ 𝓝 a) : s ∩ t ∈ 𝓝[s] a := inter_mem self_mem_nhdsWithin (mem_inf_of_left h) #align inter_mem_nhds_within inter_mem_nhdsWithin theorem nhdsWithin_mono (a : α) {s t : Set α} (h : s ⊆ t) : 𝓝[s] a ≤ 𝓝[t] a := inf_le_inf_left _ (principal_mono.mpr h) #align nhds_within_mono nhdsWithin_mono theorem pure_le_nhdsWithin {a : α} {s : Set α} (ha : a ∈ s) : pure a ≤ 𝓝[s] a := le_inf (pure_le_nhds a) (le_principal_iff.2 ha) #align pure_le_nhds_within pure_le_nhdsWithin theorem mem_of_mem_nhdsWithin {a : α} {s t : Set α} (ha : a ∈ s) (ht : t ∈ 𝓝[s] a) : a ∈ t := pure_le_nhdsWithin ha ht #align mem_of_mem_nhds_within mem_of_mem_nhdsWithin theorem Filter.Eventually.self_of_nhdsWithin {p : α → Prop} {s : Set α} {x : α} (h : ∀ᶠ y in 𝓝[s] x, p y) (hx : x ∈ s) : p x := mem_of_mem_nhdsWithin hx h #align filter.eventually.self_of_nhds_within Filter.Eventually.self_of_nhdsWithin theorem tendsto_const_nhdsWithin {l : Filter β} {s : Set α} {a : α} (ha : a ∈ s) : Tendsto (fun _ : β => a) l (𝓝[s] a) := tendsto_const_pure.mono_right <| pure_le_nhdsWithin ha #align tendsto_const_nhds_within tendsto_const_nhdsWithin theorem nhdsWithin_restrict'' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝[s] a) : 𝓝[s] a = 𝓝[s ∩ t] a := le_antisymm (le_inf inf_le_left (le_principal_iff.mpr (inter_mem self_mem_nhdsWithin h))) (inf_le_inf_left _ (principal_mono.mpr Set.inter_subset_left)) #align nhds_within_restrict'' nhdsWithin_restrict'' theorem nhdsWithin_restrict' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝 a) : 𝓝[s] a = 𝓝[s ∩ t] a := nhdsWithin_restrict'' s <| mem_inf_of_left h #align nhds_within_restrict' nhdsWithin_restrict' theorem nhdsWithin_restrict {a : α} (s : Set α) {t : Set α} (h₀ : a ∈ t) (h₁ : IsOpen t) : 𝓝[s] a = 𝓝[s ∩ t] a := nhdsWithin_restrict' s (IsOpen.mem_nhds h₁ h₀) #align nhds_within_restrict nhdsWithin_restrict theorem nhdsWithin_le_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[t] a ≤ 𝓝[s] a := nhdsWithin_le_iff.mpr h #align nhds_within_le_of_mem nhdsWithin_le_of_mem theorem nhdsWithin_le_nhds {a : α} {s : Set α} : 𝓝[s] a ≤ 𝓝 a := by rw [← nhdsWithin_univ] apply nhdsWithin_le_of_mem exact univ_mem #align nhds_within_le_nhds nhdsWithin_le_nhds theorem nhdsWithin_eq_nhdsWithin' {a : α} {s t u : Set α} (hs : s ∈ 𝓝 a) (h₂ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict' t hs, nhdsWithin_restrict' u hs, h₂] #align nhds_within_eq_nhds_within' nhdsWithin_eq_nhdsWithin' theorem nhdsWithin_eq_nhdsWithin {a : α} {s t u : Set α} (h₀ : a ∈ s) (h₁ : IsOpen s) (h₂ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict t h₀ h₁, nhdsWithin_restrict u h₀ h₁, h₂] #align nhds_within_eq_nhds_within nhdsWithin_eq_nhdsWithin @[simp] theorem nhdsWithin_eq_nhds {a : α} {s : Set α} : 𝓝[s] a = 𝓝 a ↔ s ∈ 𝓝 a := inf_eq_left.trans le_principal_iff #align nhds_within_eq_nhds nhdsWithin_eq_nhds theorem IsOpen.nhdsWithin_eq {a : α} {s : Set α} (h : IsOpen s) (ha : a ∈ s) : 𝓝[s] a = 𝓝 a := nhdsWithin_eq_nhds.2 <| h.mem_nhds ha #align is_open.nhds_within_eq IsOpen.nhdsWithin_eq theorem preimage_nhds_within_coinduced {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t) (ht : IsOpen t) (hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) : π ⁻¹' s ∈ 𝓝 a := by rw [← ht.nhdsWithin_eq h] exact preimage_nhdsWithin_coinduced' h hs #align preimage_nhds_within_coinduced preimage_nhds_within_coinduced @[simp] theorem nhdsWithin_empty (a : α) : 𝓝[∅] a = ⊥ := by rw [nhdsWithin, principal_empty, inf_bot_eq] #align nhds_within_empty nhdsWithin_empty theorem nhdsWithin_union (a : α) (s t : Set α) : 𝓝[s ∪ t] a = 𝓝[s] a ⊔ 𝓝[t] a := by delta nhdsWithin rw [← inf_sup_left, sup_principal] #align nhds_within_union nhdsWithin_union theorem nhdsWithin_biUnion {ι} {I : Set ι} (hI : I.Finite) (s : ι → Set α) (a : α) : 𝓝[⋃ i ∈ I, s i] a = ⨆ i ∈ I, 𝓝[s i] a := Set.Finite.induction_on hI (by simp) fun _ _ hT ↦ by simp only [hT, nhdsWithin_union, iSup_insert, biUnion_insert] #align nhds_within_bUnion nhdsWithin_biUnion theorem nhdsWithin_sUnion {S : Set (Set α)} (hS : S.Finite) (a : α) : 𝓝[⋃₀ S] a = ⨆ s ∈ S, 𝓝[s] a := by rw [sUnion_eq_biUnion, nhdsWithin_biUnion hS] #align nhds_within_sUnion nhdsWithin_sUnion theorem nhdsWithin_iUnion {ι} [Finite ι] (s : ι → Set α) (a : α) : 𝓝[⋃ i, s i] a = ⨆ i, 𝓝[s i] a := by rw [← sUnion_range, nhdsWithin_sUnion (finite_range s), iSup_range] #align nhds_within_Union nhdsWithin_iUnion theorem nhdsWithin_inter (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓝[t] a := by delta nhdsWithin rw [inf_left_comm, inf_assoc, inf_principal, ← inf_assoc, inf_idem] #align nhds_within_inter nhdsWithin_inter theorem nhdsWithin_inter' (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓟 t := by delta nhdsWithin rw [← inf_principal, inf_assoc] #align nhds_within_inter' nhdsWithin_inter' theorem nhdsWithin_inter_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[s ∩ t] a = 𝓝[t] a := by rw [nhdsWithin_inter, inf_eq_right] exact nhdsWithin_le_of_mem h #align nhds_within_inter_of_mem nhdsWithin_inter_of_mem theorem nhdsWithin_inter_of_mem' {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) : 𝓝[s ∩ t] a = 𝓝[s] a := by rw [inter_comm, nhdsWithin_inter_of_mem h] #align nhds_within_inter_of_mem' nhdsWithin_inter_of_mem' @[simp] theorem nhdsWithin_singleton (a : α) : 𝓝[{a}] a = pure a := by rw [nhdsWithin, principal_singleton, inf_eq_right.2 (pure_le_nhds a)] #align nhds_within_singleton nhdsWithin_singleton @[simp] theorem nhdsWithin_insert (a : α) (s : Set α) : 𝓝[insert a s] a = pure a ⊔ 𝓝[s] a := by rw [← singleton_union, nhdsWithin_union, nhdsWithin_singleton] #align nhds_within_insert nhdsWithin_insert theorem mem_nhdsWithin_insert {a : α} {s t : Set α} : t ∈ 𝓝[insert a s] a ↔ a ∈ t ∧ t ∈ 𝓝[s] a := by simp #align mem_nhds_within_insert mem_nhdsWithin_insert theorem insert_mem_nhdsWithin_insert {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) : insert a t ∈ 𝓝[insert a s] a := by simp [mem_of_superset h] #align insert_mem_nhds_within_insert insert_mem_nhdsWithin_insert theorem insert_mem_nhds_iff {a : α} {s : Set α} : insert a s ∈ 𝓝 a ↔ s ∈ 𝓝[≠] a := by simp only [nhdsWithin, mem_inf_principal, mem_compl_iff, mem_singleton_iff, or_iff_not_imp_left, insert_def] #align insert_mem_nhds_iff insert_mem_nhds_iff @[simp] theorem nhdsWithin_compl_singleton_sup_pure (a : α) : 𝓝[≠] a ⊔ pure a = 𝓝 a := by rw [← nhdsWithin_singleton, ← nhdsWithin_union, compl_union_self, nhdsWithin_univ] #align nhds_within_compl_singleton_sup_pure nhdsWithin_compl_singleton_sup_pure theorem nhdsWithin_prod {α : Type*} [TopologicalSpace α] {β : Type*} [TopologicalSpace β] {s u : Set α} {t v : Set β} {a : α} {b : β} (hu : u ∈ 𝓝[s] a) (hv : v ∈ 𝓝[t] b) : u ×ˢ v ∈ 𝓝[s ×ˢ t] (a, b) := by rw [nhdsWithin_prod_eq] exact prod_mem_prod hu hv #align nhds_within_prod nhdsWithin_prod theorem nhdsWithin_pi_eq' {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi I s] x = ⨅ i, comap (fun x => x i) (𝓝 (x i) ⊓ ⨅ (_ : i ∈ I), 𝓟 (s i)) := by simp only [nhdsWithin, nhds_pi, Filter.pi, comap_inf, comap_iInf, pi_def, comap_principal, ← iInf_principal_finite hI, ← iInf_inf_eq] #align nhds_within_pi_eq' nhdsWithin_pi_eq' theorem nhdsWithin_pi_eq {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi I s] x = (⨅ i ∈ I, comap (fun x => x i) (𝓝[s i] x i)) ⊓ ⨅ (i) (_ : i ∉ I), comap (fun x => x i) (𝓝 (x i)) := by simp only [nhdsWithin, nhds_pi, Filter.pi, pi_def, ← iInf_principal_finite hI, comap_inf, comap_principal, eval] rw [iInf_split _ fun i => i ∈ I, inf_right_comm] simp only [iInf_inf_eq] #align nhds_within_pi_eq nhdsWithin_pi_eq theorem nhdsWithin_pi_univ_eq {ι : Type*} {α : ι → Type*} [Finite ι] [∀ i, TopologicalSpace (α i)] (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi univ s] x = ⨅ i, comap (fun x => x i) (𝓝[s i] x i) := by simpa [nhdsWithin] using nhdsWithin_pi_eq finite_univ s x #align nhds_within_pi_univ_eq nhdsWithin_pi_univ_eq theorem nhdsWithin_pi_eq_bot {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : 𝓝[pi I s] x = ⊥ ↔ ∃ i ∈ I, 𝓝[s i] x i = ⊥ := by simp only [nhdsWithin, nhds_pi, pi_inf_principal_pi_eq_bot] #align nhds_within_pi_eq_bot nhdsWithin_pi_eq_bot theorem nhdsWithin_pi_neBot {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : (𝓝[pi I s] x).NeBot ↔ ∀ i ∈ I, (𝓝[s i] x i).NeBot := by simp [neBot_iff, nhdsWithin_pi_eq_bot] #align nhds_within_pi_ne_bot nhdsWithin_pi_neBot theorem Filter.Tendsto.piecewise_nhdsWithin {f g : α → β} {t : Set α} [∀ x, Decidable (x ∈ t)] {a : α} {s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ t] a) l) (h₁ : Tendsto g (𝓝[s ∩ tᶜ] a) l) : Tendsto (piecewise t f g) (𝓝[s] a) l := by apply Tendsto.piecewise <;> rwa [← nhdsWithin_inter'] #align filter.tendsto.piecewise_nhds_within Filter.Tendsto.piecewise_nhdsWithin theorem Filter.Tendsto.if_nhdsWithin {f g : α → β} {p : α → Prop} [DecidablePred p] {a : α} {s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ { x | p x }] a) l) (h₁ : Tendsto g (𝓝[s ∩ { x | ¬p x }] a) l) : Tendsto (fun x => if p x then f x else g x) (𝓝[s] a) l := h₀.piecewise_nhdsWithin h₁ #align filter.tendsto.if_nhds_within Filter.Tendsto.if_nhdsWithin theorem map_nhdsWithin (f : α → β) (a : α) (s : Set α) : map f (𝓝[s] a) = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (f '' (t ∩ s)) := ((nhdsWithin_basis_open a s).map f).eq_biInf #align map_nhds_within map_nhdsWithin theorem tendsto_nhdsWithin_mono_left {f : α → β} {a : α} {s t : Set α} {l : Filter β} (hst : s ⊆ t) (h : Tendsto f (𝓝[t] a) l) : Tendsto f (𝓝[s] a) l := h.mono_left <| nhdsWithin_mono a hst #align tendsto_nhds_within_mono_left tendsto_nhdsWithin_mono_left theorem tendsto_nhdsWithin_mono_right {f : β → α} {l : Filter β} {a : α} {s t : Set α} (hst : s ⊆ t) (h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝[t] a) := h.mono_right (nhdsWithin_mono a hst) #align tendsto_nhds_within_mono_right tendsto_nhdsWithin_mono_right theorem tendsto_nhdsWithin_of_tendsto_nhds {f : α → β} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f (𝓝 a) l) : Tendsto f (𝓝[s] a) l := h.mono_left inf_le_left #align tendsto_nhds_within_of_tendsto_nhds tendsto_nhdsWithin_of_tendsto_nhds theorem eventually_mem_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f l (𝓝[s] a)) : ∀ᶠ i in l, f i ∈ s := by simp_rw [nhdsWithin_eq, tendsto_iInf, mem_setOf_eq, tendsto_principal, mem_inter_iff, eventually_and] at h exact (h univ ⟨mem_univ a, isOpen_univ⟩).2 #align eventually_mem_of_tendsto_nhds_within eventually_mem_of_tendsto_nhdsWithin theorem tendsto_nhds_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝 a) := h.mono_right nhdsWithin_le_nhds #align tendsto_nhds_of_tendsto_nhds_within tendsto_nhds_of_tendsto_nhdsWithin theorem nhdsWithin_neBot_of_mem {s : Set α} {x : α} (hx : x ∈ s) : NeBot (𝓝[s] x) := mem_closure_iff_nhdsWithin_neBot.1 <| subset_closure hx #align nhds_within_ne_bot_of_mem nhdsWithin_neBot_of_mem theorem IsClosed.mem_of_nhdsWithin_neBot {s : Set α} (hs : IsClosed s) {x : α} (hx : NeBot <| 𝓝[s] x) : x ∈ s := hs.closure_eq ▸ mem_closure_iff_nhdsWithin_neBot.2 hx #align is_closed.mem_of_nhds_within_ne_bot IsClosed.mem_of_nhdsWithin_neBot theorem DenseRange.nhdsWithin_neBot {ι : Type*} {f : ι → α} (h : DenseRange f) (x : α) : NeBot (𝓝[range f] x) := mem_closure_iff_clusterPt.1 (h x) #align dense_range.nhds_within_ne_bot DenseRange.nhdsWithin_neBot theorem mem_closure_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : x ∈ closure (pi I s) ↔ ∀ i ∈ I, x i ∈ closure (s i) := by simp only [mem_closure_iff_nhdsWithin_neBot, nhdsWithin_pi_neBot] #align mem_closure_pi mem_closure_pi theorem closure_pi_set {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] (I : Set ι) (s : ∀ i, Set (α i)) : closure (pi I s) = pi I fun i => closure (s i) := Set.ext fun _ => mem_closure_pi #align closure_pi_set closure_pi_set theorem dense_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {s : ∀ i, Set (α i)} (I : Set ι) (hs : ∀ i ∈ I, Dense (s i)) : Dense (pi I s) := by simp only [dense_iff_closure_eq, closure_pi_set, pi_congr rfl fun i hi => (hs i hi).closure_eq, pi_univ] #align dense_pi dense_pi theorem eventuallyEq_nhdsWithin_iff {f g : α → β} {s : Set α} {a : α} : f =ᶠ[𝓝[s] a] g ↔ ∀ᶠ x in 𝓝 a, x ∈ s → f x = g x := mem_inf_principal #align eventually_eq_nhds_within_iff eventuallyEq_nhdsWithin_iff theorem eventuallyEq_nhdsWithin_of_eqOn {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) : f =ᶠ[𝓝[s] a] g := mem_inf_of_right h #align eventually_eq_nhds_within_of_eq_on eventuallyEq_nhdsWithin_of_eqOn theorem Set.EqOn.eventuallyEq_nhdsWithin {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) : f =ᶠ[𝓝[s] a] g := eventuallyEq_nhdsWithin_of_eqOn h #align set.eq_on.eventually_eq_nhds_within Set.EqOn.eventuallyEq_nhdsWithin theorem tendsto_nhdsWithin_congr {f g : α → β} {s : Set α} {a : α} {l : Filter β} (hfg : ∀ x ∈ s, f x = g x) (hf : Tendsto f (𝓝[s] a) l) : Tendsto g (𝓝[s] a) l := (tendsto_congr' <| eventuallyEq_nhdsWithin_of_eqOn hfg).1 hf #align tendsto_nhds_within_congr tendsto_nhdsWithin_congr theorem eventually_nhdsWithin_of_forall {s : Set α} {a : α} {p : α → Prop} (h : ∀ x ∈ s, p x) : ∀ᶠ x in 𝓝[s] a, p x := mem_inf_of_right h #align eventually_nhds_within_of_forall eventually_nhdsWithin_of_forall theorem tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within {a : α} {l : Filter β} {s : Set α} (f : β → α) (h1 : Tendsto f l (𝓝 a)) (h2 : ∀ᶠ x in l, f x ∈ s) : Tendsto f l (𝓝[s] a) := tendsto_inf.2 ⟨h1, tendsto_principal.2 h2⟩ #align tendsto_nhds_within_of_tendsto_nhds_of_eventually_within tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within theorem tendsto_nhdsWithin_iff {a : α} {l : Filter β} {s : Set α} {f : β → α} : Tendsto f l (𝓝[s] a) ↔ Tendsto f l (𝓝 a) ∧ ∀ᶠ n in l, f n ∈ s := ⟨fun h => ⟨tendsto_nhds_of_tendsto_nhdsWithin h, eventually_mem_of_tendsto_nhdsWithin h⟩, fun h => tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ h.1 h.2⟩ #align tendsto_nhds_within_iff tendsto_nhdsWithin_iff @[simp] theorem tendsto_nhdsWithin_range {a : α} {l : Filter β} {f : β → α} : Tendsto f l (𝓝[range f] a) ↔ Tendsto f l (𝓝 a) := ⟨fun h => h.mono_right inf_le_left, fun h => tendsto_inf.2 ⟨h, tendsto_principal.2 <| eventually_of_forall mem_range_self⟩⟩ #align tendsto_nhds_within_range tendsto_nhdsWithin_range theorem Filter.EventuallyEq.eq_of_nhdsWithin {s : Set α} {f g : α → β} {a : α} (h : f =ᶠ[𝓝[s] a] g) (hmem : a ∈ s) : f a = g a := h.self_of_nhdsWithin hmem #align filter.eventually_eq.eq_of_nhds_within Filter.EventuallyEq.eq_of_nhdsWithin theorem eventually_nhdsWithin_of_eventually_nhds {α : Type*} [TopologicalSpace α] {s : Set α} {a : α} {p : α → Prop} (h : ∀ᶠ x in 𝓝 a, p x) : ∀ᶠ x in 𝓝[s] a, p x := mem_nhdsWithin_of_mem_nhds h #align eventually_nhds_within_of_eventually_nhds eventually_nhdsWithin_of_eventually_nhds theorem mem_nhdsWithin_subtype {s : Set α} {a : { x // x ∈ s }} {t u : Set { x // x ∈ s }} : t ∈ 𝓝[u] a ↔ t ∈ comap ((↑) : s → α) (𝓝[(↑) '' u] a) := by rw [nhdsWithin, nhds_subtype, principal_subtype, ← comap_inf, ← nhdsWithin] #align mem_nhds_within_subtype mem_nhdsWithin_subtype theorem nhdsWithin_subtype (s : Set α) (a : { x // x ∈ s }) (t : Set { x // x ∈ s }) : 𝓝[t] a = comap ((↑) : s → α) (𝓝[(↑) '' t] a) := Filter.ext fun _ => mem_nhdsWithin_subtype #align nhds_within_subtype nhdsWithin_subtype theorem nhdsWithin_eq_map_subtype_coe {s : Set α} {a : α} (h : a ∈ s) : 𝓝[s] a = map ((↑) : s → α) (𝓝 ⟨a, h⟩) := (map_nhds_subtype_val ⟨a, h⟩).symm #align nhds_within_eq_map_subtype_coe nhdsWithin_eq_map_subtype_coe theorem mem_nhds_subtype_iff_nhdsWithin {s : Set α} {a : s} {t : Set s} : t ∈ 𝓝 a ↔ (↑) '' t ∈ 𝓝[s] (a : α) := by rw [← map_nhds_subtype_val, image_mem_map_iff Subtype.val_injective] #align mem_nhds_subtype_iff_nhds_within mem_nhds_subtype_iff_nhdsWithin theorem preimage_coe_mem_nhds_subtype {s t : Set α} {a : s} : (↑) ⁻¹' t ∈ 𝓝 a ↔ t ∈ 𝓝[s] ↑a := by rw [← map_nhds_subtype_val, mem_map] #align preimage_coe_mem_nhds_subtype preimage_coe_mem_nhds_subtype theorem eventually_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) : (∀ᶠ x : s in 𝓝 a, P x) ↔ ∀ᶠ x in 𝓝[s] a, P x := preimage_coe_mem_nhds_subtype theorem frequently_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) : (∃ᶠ x : s in 𝓝 a, P x) ↔ ∃ᶠ x in 𝓝[s] a, P x := eventually_nhds_subtype_iff s a (¬ P ·) |>.not theorem tendsto_nhdsWithin_iff_subtype {s : Set α} {a : α} (h : a ∈ s) (f : α → β) (l : Filter β) : Tendsto f (𝓝[s] a) l ↔ Tendsto (s.restrict f) (𝓝 ⟨a, h⟩) l := by rw [nhdsWithin_eq_map_subtype_coe h, tendsto_map'_iff]; rfl #align tendsto_nhds_within_iff_subtype tendsto_nhdsWithin_iff_subtype variable [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ] theorem ContinuousWithinAt.tendsto {f : α → β} {s : Set α} {x : α} (h : ContinuousWithinAt f s x) : Tendsto f (𝓝[s] x) (𝓝 (f x)) := h #align continuous_within_at.tendsto ContinuousWithinAt.tendsto theorem ContinuousOn.continuousWithinAt {f : α → β} {s : Set α} {x : α} (hf : ContinuousOn f s) (hx : x ∈ s) : ContinuousWithinAt f s x := hf x hx #align continuous_on.continuous_within_at ContinuousOn.continuousWithinAt theorem continuousWithinAt_univ (f : α → β) (x : α) : ContinuousWithinAt f Set.univ x ↔ ContinuousAt f x := by rw [ContinuousAt, ContinuousWithinAt, nhdsWithin_univ] #align continuous_within_at_univ continuousWithinAt_univ theorem continuous_iff_continuousOn_univ {f : α → β} : Continuous f ↔ ContinuousOn f univ := by simp [continuous_iff_continuousAt, ContinuousOn, ContinuousAt, ContinuousWithinAt, nhdsWithin_univ] #align continuous_iff_continuous_on_univ continuous_iff_continuousOn_univ theorem continuousWithinAt_iff_continuousAt_restrict (f : α → β) {x : α} {s : Set α} (h : x ∈ s) : ContinuousWithinAt f s x ↔ ContinuousAt (s.restrict f) ⟨x, h⟩ := tendsto_nhdsWithin_iff_subtype h f _ #align continuous_within_at_iff_continuous_at_restrict continuousWithinAt_iff_continuousAt_restrict theorem ContinuousWithinAt.tendsto_nhdsWithin {f : α → β} {x : α} {s : Set α} {t : Set β} (h : ContinuousWithinAt f s x) (ht : MapsTo f s t) : Tendsto f (𝓝[s] x) (𝓝[t] f x) := tendsto_inf.2 ⟨h, tendsto_principal.2 <| mem_inf_of_right <| mem_principal.2 <| ht⟩ #align continuous_within_at.tendsto_nhds_within ContinuousWithinAt.tendsto_nhdsWithin theorem ContinuousWithinAt.tendsto_nhdsWithin_image {f : α → β} {x : α} {s : Set α} (h : ContinuousWithinAt f s x) : Tendsto f (𝓝[s] x) (𝓝[f '' s] f x) := h.tendsto_nhdsWithin (mapsTo_image _ _) #align continuous_within_at.tendsto_nhds_within_image ContinuousWithinAt.tendsto_nhdsWithin_image theorem ContinuousWithinAt.prod_map {f : α → γ} {g : β → δ} {s : Set α} {t : Set β} {x : α} {y : β} (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g t y) : ContinuousWithinAt (Prod.map f g) (s ×ˢ t) (x, y) := by unfold ContinuousWithinAt at * rw [nhdsWithin_prod_eq, Prod.map, nhds_prod_eq] exact hf.prod_map hg #align continuous_within_at.prod_map ContinuousWithinAt.prod_map theorem continuousWithinAt_prod_of_discrete_left [DiscreteTopology α] {f : α × β → γ} {s : Set (α × β)} {x : α × β} : ContinuousWithinAt f s x ↔ ContinuousWithinAt (f ⟨x.1, ·⟩) {b | (x.1, b) ∈ s} x.2 := by rw [← x.eta]; simp_rw [ContinuousWithinAt, nhdsWithin, nhds_prod_eq, nhds_discrete, pure_prod, ← map_inf_principal_preimage]; rfl theorem continuousWithinAt_prod_of_discrete_right [DiscreteTopology β] {f : α × β → γ} {s : Set (α × β)} {x : α × β} : ContinuousWithinAt f s x ↔ ContinuousWithinAt (f ⟨·, x.2⟩) {a | (a, x.2) ∈ s} x.1 := by rw [← x.eta]; simp_rw [ContinuousWithinAt, nhdsWithin, nhds_prod_eq, nhds_discrete, prod_pure, ← map_inf_principal_preimage]; rfl theorem continuousAt_prod_of_discrete_left [DiscreteTopology α] {f : α × β → γ} {x : α × β} : ContinuousAt f x ↔ ContinuousAt (f ⟨x.1, ·⟩) x.2 := by simp_rw [← continuousWithinAt_univ]; exact continuousWithinAt_prod_of_discrete_left theorem continuousAt_prod_of_discrete_right [DiscreteTopology β] {f : α × β → γ} {x : α × β} : ContinuousAt f x ↔ ContinuousAt (f ⟨·, x.2⟩) x.1 := by simp_rw [← continuousWithinAt_univ]; exact continuousWithinAt_prod_of_discrete_right theorem continuousOn_prod_of_discrete_left [DiscreteTopology α] {f : α × β → γ} {s : Set (α × β)} : ContinuousOn f s ↔ ∀ a, ContinuousOn (f ⟨a, ·⟩) {b | (a, b) ∈ s} := by simp_rw [ContinuousOn, Prod.forall, continuousWithinAt_prod_of_discrete_left]; rfl theorem continuousOn_prod_of_discrete_right [DiscreteTopology β] {f : α × β → γ} {s : Set (α × β)} : ContinuousOn f s ↔ ∀ b, ContinuousOn (f ⟨·, b⟩) {a | (a, b) ∈ s} := by simp_rw [ContinuousOn, Prod.forall, continuousWithinAt_prod_of_discrete_right]; apply forall_swap theorem continuous_prod_of_discrete_left [DiscreteTopology α] {f : α × β → γ} : Continuous f ↔ ∀ a, Continuous (f ⟨a, ·⟩) := by simp_rw [continuous_iff_continuousOn_univ]; exact continuousOn_prod_of_discrete_left theorem continuous_prod_of_discrete_right [DiscreteTopology β] {f : α × β → γ} : Continuous f ↔ ∀ b, Continuous (f ⟨·, b⟩) := by simp_rw [continuous_iff_continuousOn_univ]; exact continuousOn_prod_of_discrete_right theorem isOpenMap_prod_of_discrete_left [DiscreteTopology α] {f : α × β → γ} : IsOpenMap f ↔ ∀ a, IsOpenMap (f ⟨a, ·⟩) := by simp_rw [isOpenMap_iff_nhds_le, Prod.forall, nhds_prod_eq, nhds_discrete, pure_prod, map_map] rfl theorem isOpenMap_prod_of_discrete_right [DiscreteTopology β] {f : α × β → γ} : IsOpenMap f ↔ ∀ b, IsOpenMap (f ⟨·, b⟩) := by simp_rw [isOpenMap_iff_nhds_le, Prod.forall, forall_swap (α := α) (β := β), nhds_prod_eq, nhds_discrete, prod_pure, map_map]; rfl theorem continuousWithinAt_pi {ι : Type*} {π : ι → Type*} [∀ i, TopologicalSpace (π i)] {f : α → ∀ i, π i} {s : Set α} {x : α} : ContinuousWithinAt f s x ↔ ∀ i, ContinuousWithinAt (fun y => f y i) s x := tendsto_pi_nhds #align continuous_within_at_pi continuousWithinAt_pi theorem continuousOn_pi {ι : Type*} {π : ι → Type*} [∀ i, TopologicalSpace (π i)] {f : α → ∀ i, π i} {s : Set α} : ContinuousOn f s ↔ ∀ i, ContinuousOn (fun y => f y i) s := ⟨fun h i x hx => tendsto_pi_nhds.1 (h x hx) i, fun h x hx => tendsto_pi_nhds.2 fun i => h i x hx⟩ #align continuous_on_pi continuousOn_pi @[fun_prop] theorem continuousOn_pi' {ι : Type*} {π : ι → Type*} [∀ i, TopologicalSpace (π i)] {f : α → ∀ i, π i} {s : Set α} (hf : ∀ i, ContinuousOn (fun y => f y i) s) : ContinuousOn f s := continuousOn_pi.2 hf theorem ContinuousWithinAt.fin_insertNth {n} {π : Fin (n + 1) → Type*} [∀ i, TopologicalSpace (π i)] (i : Fin (n + 1)) {f : α → π i} {a : α} {s : Set α} (hf : ContinuousWithinAt f s a) {g : α → ∀ j : Fin n, π (i.succAbove j)} (hg : ContinuousWithinAt g s a) : ContinuousWithinAt (fun a => i.insertNth (f a) (g a)) s a := hf.tendsto.fin_insertNth i hg #align continuous_within_at.fin_insert_nth ContinuousWithinAt.fin_insertNth nonrec theorem ContinuousOn.fin_insertNth {n} {π : Fin (n + 1) → Type*} [∀ i, TopologicalSpace (π i)] (i : Fin (n + 1)) {f : α → π i} {s : Set α} (hf : ContinuousOn f s) {g : α → ∀ j : Fin n, π (i.succAbove j)} (hg : ContinuousOn g s) : ContinuousOn (fun a => i.insertNth (f a) (g a)) s := fun a ha => (hf a ha).fin_insertNth i (hg a ha) #align continuous_on.fin_insert_nth ContinuousOn.fin_insertNth theorem continuousOn_iff {f : α → β} {s : Set α} : ContinuousOn f s ↔ ∀ x ∈ s, ∀ t : Set β, IsOpen t → f x ∈ t → ∃ u, IsOpen u ∧ x ∈ u ∧ u ∩ s ⊆ f ⁻¹' t := by simp only [ContinuousOn, ContinuousWithinAt, tendsto_nhds, mem_nhdsWithin] #align continuous_on_iff continuousOn_iff theorem continuousOn_iff_continuous_restrict {f : α → β} {s : Set α} : ContinuousOn f s ↔ Continuous (s.restrict f) := by rw [ContinuousOn, continuous_iff_continuousAt]; constructor · rintro h ⟨x, xs⟩ exact (continuousWithinAt_iff_continuousAt_restrict f xs).mp (h x xs) intro h x xs exact (continuousWithinAt_iff_continuousAt_restrict f xs).mpr (h ⟨x, xs⟩) #align continuous_on_iff_continuous_restrict continuousOn_iff_continuous_restrict -- Porting note: 2 new lemmas alias ⟨ContinuousOn.restrict, _⟩ := continuousOn_iff_continuous_restrict theorem ContinuousOn.restrict_mapsTo {f : α → β} {s : Set α} {t : Set β} (hf : ContinuousOn f s) (ht : MapsTo f s t) : Continuous (ht.restrict f s t) := hf.restrict.codRestrict _ theorem continuousOn_iff' {f : α → β} {s : Set α} : ContinuousOn f s ↔ ∀ t : Set β, IsOpen t → ∃ u, IsOpen u ∧ f ⁻¹' t ∩ s = u ∩ s := by have : ∀ t, IsOpen (s.restrict f ⁻¹' t) ↔ ∃ u : Set α, IsOpen u ∧ f ⁻¹' t ∩ s = u ∩ s := by intro t rw [isOpen_induced_iff, Set.restrict_eq, Set.preimage_comp] simp only [Subtype.preimage_coe_eq_preimage_coe_iff] constructor <;> · rintro ⟨u, ou, useq⟩ exact ⟨u, ou, by simpa only [Set.inter_comm, eq_comm] using useq⟩ rw [continuousOn_iff_continuous_restrict, continuous_def]; simp only [this] #align continuous_on_iff' continuousOn_iff' theorem ContinuousOn.mono_dom {α β : Type*} {t₁ t₂ : TopologicalSpace α} {t₃ : TopologicalSpace β} (h₁ : t₂ ≤ t₁) {s : Set α} {f : α → β} (h₂ : @ContinuousOn α β t₁ t₃ f s) : @ContinuousOn α β t₂ t₃ f s := fun x hx _u hu => map_mono (inf_le_inf_right _ <| nhds_mono h₁) (h₂ x hx hu) #align continuous_on.mono_dom ContinuousOn.mono_dom theorem ContinuousOn.mono_rng {α β : Type*} {t₁ : TopologicalSpace α} {t₂ t₃ : TopologicalSpace β} (h₁ : t₂ ≤ t₃) {s : Set α} {f : α → β} (h₂ : @ContinuousOn α β t₁ t₂ f s) : @ContinuousOn α β t₁ t₃ f s := fun x hx _u hu => h₂ x hx <| nhds_mono h₁ hu #align continuous_on.mono_rng ContinuousOn.mono_rng theorem continuousOn_iff_isClosed {f : α → β} {s : Set α} : ContinuousOn f s ↔ ∀ t : Set β, IsClosed t → ∃ u, IsClosed u ∧ f ⁻¹' t ∩ s = u ∩ s := by have : ∀ t, IsClosed (s.restrict f ⁻¹' t) ↔ ∃ u : Set α, IsClosed u ∧ f ⁻¹' t ∩ s = u ∩ s := by intro t rw [isClosed_induced_iff, Set.restrict_eq, Set.preimage_comp] simp only [Subtype.preimage_coe_eq_preimage_coe_iff, eq_comm, Set.inter_comm s] rw [continuousOn_iff_continuous_restrict, continuous_iff_isClosed]; simp only [this] #align continuous_on_iff_is_closed continuousOn_iff_isClosed theorem ContinuousOn.prod_map {f : α → γ} {g : β → δ} {s : Set α} {t : Set β} (hf : ContinuousOn f s) (hg : ContinuousOn g t) : ContinuousOn (Prod.map f g) (s ×ˢ t) := fun ⟨x, y⟩ ⟨hx, hy⟩ => ContinuousWithinAt.prod_map (hf x hx) (hg y hy) #align continuous_on.prod_map ContinuousOn.prod_map theorem continuous_of_cover_nhds {ι : Sort*} {f : α → β} {s : ι → Set α} (hs : ∀ x : α, ∃ i, s i ∈ 𝓝 x) (hf : ∀ i, ContinuousOn f (s i)) : Continuous f := continuous_iff_continuousAt.mpr fun x ↦ let ⟨i, hi⟩ := hs x; by rw [ContinuousAt, ← nhdsWithin_eq_nhds.2 hi] exact hf _ _ (mem_of_mem_nhds hi) #align continuous_of_cover_nhds continuous_of_cover_nhds theorem continuousOn_empty (f : α → β) : ContinuousOn f ∅ := fun _ => False.elim #align continuous_on_empty continuousOn_empty @[simp] theorem continuousOn_singleton (f : α → β) (a : α) : ContinuousOn f {a} := forall_eq.2 <| by simpa only [ContinuousWithinAt, nhdsWithin_singleton, tendsto_pure_left] using fun s => mem_of_mem_nhds #align continuous_on_singleton continuousOn_singleton theorem Set.Subsingleton.continuousOn {s : Set α} (hs : s.Subsingleton) (f : α → β) : ContinuousOn f s := hs.induction_on (continuousOn_empty f) (continuousOn_singleton f) #align set.subsingleton.continuous_on Set.Subsingleton.continuousOn theorem nhdsWithin_le_comap {x : α} {s : Set α} {f : α → β} (ctsf : ContinuousWithinAt f s x) : 𝓝[s] x ≤ comap f (𝓝[f '' s] f x) := ctsf.tendsto_nhdsWithin_image.le_comap #align nhds_within_le_comap nhdsWithin_le_comap @[simp] theorem comap_nhdsWithin_range {α} (f : α → β) (y : β) : comap f (𝓝[range f] y) = comap f (𝓝 y) := comap_inf_principal_range #align comap_nhds_within_range comap_nhdsWithin_range theorem ContinuousWithinAt.mono {f : α → β} {s t : Set α} {x : α} (h : ContinuousWithinAt f t x) (hs : s ⊆ t) : ContinuousWithinAt f s x := h.mono_left (nhdsWithin_mono x hs) #align continuous_within_at.mono ContinuousWithinAt.mono theorem ContinuousWithinAt.mono_of_mem {f : α → β} {s t : Set α} {x : α} (h : ContinuousWithinAt f t x) (hs : t ∈ 𝓝[s] x) : ContinuousWithinAt f s x := h.mono_left (nhdsWithin_le_of_mem hs) #align continuous_within_at.mono_of_mem ContinuousWithinAt.mono_of_mem theorem continuousWithinAt_congr_nhds {f : α → β} {s t : Set α} {x : α} (h : 𝓝[s] x = 𝓝[t] x) : ContinuousWithinAt f s x ↔ ContinuousWithinAt f t x := by simp only [ContinuousWithinAt, h] theorem continuousWithinAt_inter' {f : α → β} {s t : Set α} {x : α} (h : t ∈ 𝓝[s] x) : ContinuousWithinAt f (s ∩ t) x ↔ ContinuousWithinAt f s x := by simp [ContinuousWithinAt, nhdsWithin_restrict'' s h] #align continuous_within_at_inter' continuousWithinAt_inter' theorem continuousWithinAt_inter {f : α → β} {s t : Set α} {x : α} (h : t ∈ 𝓝 x) : ContinuousWithinAt f (s ∩ t) x ↔ ContinuousWithinAt f s x := by simp [ContinuousWithinAt, nhdsWithin_restrict' s h] #align continuous_within_at_inter continuousWithinAt_inter theorem continuousWithinAt_union {f : α → β} {s t : Set α} {x : α} : ContinuousWithinAt f (s ∪ t) x ↔ ContinuousWithinAt f s x ∧ ContinuousWithinAt f t x := by simp only [ContinuousWithinAt, nhdsWithin_union, tendsto_sup] #align continuous_within_at_union continuousWithinAt_union theorem ContinuousWithinAt.union {f : α → β} {s t : Set α} {x : α} (hs : ContinuousWithinAt f s x) (ht : ContinuousWithinAt f t x) : ContinuousWithinAt f (s ∪ t) x := continuousWithinAt_union.2 ⟨hs, ht⟩ #align continuous_within_at.union ContinuousWithinAt.union theorem ContinuousWithinAt.mem_closure_image {f : α → β} {s : Set α} {x : α} (h : ContinuousWithinAt f s x) (hx : x ∈ closure s) : f x ∈ closure (f '' s) := haveI := mem_closure_iff_nhdsWithin_neBot.1 hx mem_closure_of_tendsto h <| mem_of_superset self_mem_nhdsWithin (subset_preimage_image f s) #align continuous_within_at.mem_closure_image ContinuousWithinAt.mem_closure_image theorem ContinuousWithinAt.mem_closure {f : α → β} {s : Set α} {x : α} {A : Set β} (h : ContinuousWithinAt f s x) (hx : x ∈ closure s) (hA : MapsTo f s A) : f x ∈ closure A := closure_mono (image_subset_iff.2 hA) (h.mem_closure_image hx) #align continuous_within_at.mem_closure ContinuousWithinAt.mem_closure theorem Set.MapsTo.closure_of_continuousWithinAt {f : α → β} {s : Set α} {t : Set β} (h : MapsTo f s t) (hc : ∀ x ∈ closure s, ContinuousWithinAt f s x) : MapsTo f (closure s) (closure t) := fun x hx => (hc x hx).mem_closure hx h #align set.maps_to.closure_of_continuous_within_at Set.MapsTo.closure_of_continuousWithinAt theorem Set.MapsTo.closure_of_continuousOn {f : α → β} {s : Set α} {t : Set β} (h : MapsTo f s t) (hc : ContinuousOn f (closure s)) : MapsTo f (closure s) (closure t) := h.closure_of_continuousWithinAt fun x hx => (hc x hx).mono subset_closure #align set.maps_to.closure_of_continuous_on Set.MapsTo.closure_of_continuousOn theorem ContinuousWithinAt.image_closure {f : α → β} {s : Set α} (hf : ∀ x ∈ closure s, ContinuousWithinAt f s x) : f '' closure s ⊆ closure (f '' s) := ((mapsTo_image f s).closure_of_continuousWithinAt hf).image_subset #align continuous_within_at.image_closure ContinuousWithinAt.image_closure theorem ContinuousOn.image_closure {f : α → β} {s : Set α} (hf : ContinuousOn f (closure s)) : f '' closure s ⊆ closure (f '' s) := ContinuousWithinAt.image_closure fun x hx => (hf x hx).mono subset_closure #align continuous_on.image_closure ContinuousOn.image_closure @[simp] theorem continuousWithinAt_singleton {f : α → β} {x : α} : ContinuousWithinAt f {x} x := by simp only [ContinuousWithinAt, nhdsWithin_singleton, tendsto_pure_nhds] #align continuous_within_at_singleton continuousWithinAt_singleton @[simp] theorem continuousWithinAt_insert_self {f : α → β} {x : α} {s : Set α} : ContinuousWithinAt f (insert x s) x ↔ ContinuousWithinAt f s x := by simp only [← singleton_union, continuousWithinAt_union, continuousWithinAt_singleton, true_and_iff] #align continuous_within_at_insert_self continuousWithinAt_insert_self alias ⟨_, ContinuousWithinAt.insert_self⟩ := continuousWithinAt_insert_self #align continuous_within_at.insert_self ContinuousWithinAt.insert_self theorem ContinuousWithinAt.diff_iff {f : α → β} {s t : Set α} {x : α} (ht : ContinuousWithinAt f t x) : ContinuousWithinAt f (s \ t) x ↔ ContinuousWithinAt f s x := ⟨fun h => (h.union ht).mono <| by simp only [diff_union_self, subset_union_left], fun h => h.mono diff_subset⟩ #align continuous_within_at.diff_iff ContinuousWithinAt.diff_iff @[simp] theorem continuousWithinAt_diff_self {f : α → β} {s : Set α} {x : α} : ContinuousWithinAt f (s \ {x}) x ↔ ContinuousWithinAt f s x := continuousWithinAt_singleton.diff_iff #align continuous_within_at_diff_self continuousWithinAt_diff_self @[simp] theorem continuousWithinAt_compl_self {f : α → β} {a : α} : ContinuousWithinAt f {a}ᶜ a ↔ ContinuousAt f a := by rw [compl_eq_univ_diff, continuousWithinAt_diff_self, continuousWithinAt_univ] #align continuous_within_at_compl_self continuousWithinAt_compl_self @[simp] theorem continuousWithinAt_update_same [DecidableEq α] {f : α → β} {s : Set α} {x : α} {y : β} : ContinuousWithinAt (update f x y) s x ↔ Tendsto f (𝓝[s \ {x}] x) (𝓝 y) := calc ContinuousWithinAt (update f x y) s x ↔ Tendsto (update f x y) (𝓝[s \ {x}] x) (𝓝 y) := by { rw [← continuousWithinAt_diff_self, ContinuousWithinAt, update_same] } _ ↔ Tendsto f (𝓝[s \ {x}] x) (𝓝 y) := tendsto_congr' <| eventually_nhdsWithin_iff.2 <| eventually_of_forall fun z hz => update_noteq hz.2 _ _ #align continuous_within_at_update_same continuousWithinAt_update_same @[simp] theorem continuousAt_update_same [DecidableEq α] {f : α → β} {x : α} {y : β} : ContinuousAt (Function.update f x y) x ↔ Tendsto f (𝓝[≠] x) (𝓝 y) := by rw [← continuousWithinAt_univ, continuousWithinAt_update_same, compl_eq_univ_diff] #align continuous_at_update_same continuousAt_update_same theorem IsOpenMap.continuousOn_image_of_leftInvOn {f : α → β} {s : Set α} (h : IsOpenMap (s.restrict f)) {finv : β → α} (hleft : LeftInvOn finv f s) : ContinuousOn finv (f '' s) := by refine continuousOn_iff'.2 fun t ht => ⟨f '' (t ∩ s), ?_, ?_⟩ · rw [← image_restrict] exact h _ (ht.preimage continuous_subtype_val) · rw [inter_eq_self_of_subset_left (image_subset f inter_subset_right), hleft.image_inter'] #align is_open_map.continuous_on_image_of_left_inv_on IsOpenMap.continuousOn_image_of_leftInvOn theorem IsOpenMap.continuousOn_range_of_leftInverse {f : α → β} (hf : IsOpenMap f) {finv : β → α} (hleft : Function.LeftInverse finv f) : ContinuousOn finv (range f) := by rw [← image_univ] exact (hf.restrict isOpen_univ).continuousOn_image_of_leftInvOn fun x _ => hleft x #align is_open_map.continuous_on_range_of_left_inverse IsOpenMap.continuousOn_range_of_leftInverse theorem ContinuousOn.congr_mono {f g : α → β} {s s₁ : Set α} (h : ContinuousOn f s) (h' : EqOn g f s₁) (h₁ : s₁ ⊆ s) : ContinuousOn g s₁ := by intro x hx unfold ContinuousWithinAt have A := (h x (h₁ hx)).mono h₁ unfold ContinuousWithinAt at A rw [← h' hx] at A exact A.congr' h'.eventuallyEq_nhdsWithin.symm #align continuous_on.congr_mono ContinuousOn.congr_mono theorem ContinuousOn.congr {f g : α → β} {s : Set α} (h : ContinuousOn f s) (h' : EqOn g f s) : ContinuousOn g s := h.congr_mono h' (Subset.refl _) #align continuous_on.congr ContinuousOn.congr theorem continuousOn_congr {f g : α → β} {s : Set α} (h' : EqOn g f s) : ContinuousOn g s ↔ ContinuousOn f s := ⟨fun h => ContinuousOn.congr h h'.symm, fun h => h.congr h'⟩ #align continuous_on_congr continuousOn_congr theorem ContinuousAt.continuousWithinAt {f : α → β} {s : Set α} {x : α} (h : ContinuousAt f x) : ContinuousWithinAt f s x := ContinuousWithinAt.mono ((continuousWithinAt_univ f x).2 h) (subset_univ _) #align continuous_at.continuous_within_at ContinuousAt.continuousWithinAt theorem continuousWithinAt_iff_continuousAt {f : α → β} {s : Set α} {x : α} (h : s ∈ 𝓝 x) : ContinuousWithinAt f s x ↔ ContinuousAt f x := by rw [← univ_inter s, continuousWithinAt_inter h, continuousWithinAt_univ] #align continuous_within_at_iff_continuous_at continuousWithinAt_iff_continuousAt theorem ContinuousWithinAt.continuousAt {f : α → β} {s : Set α} {x : α} (h : ContinuousWithinAt f s x) (hs : s ∈ 𝓝 x) : ContinuousAt f x := (continuousWithinAt_iff_continuousAt hs).mp h #align continuous_within_at.continuous_at ContinuousWithinAt.continuousAt theorem IsOpen.continuousOn_iff {f : α → β} {s : Set α} (hs : IsOpen s) : ContinuousOn f s ↔ ∀ ⦃a⦄, a ∈ s → ContinuousAt f a := forall₂_congr fun _ => continuousWithinAt_iff_continuousAt ∘ hs.mem_nhds #align is_open.continuous_on_iff IsOpen.continuousOn_iff theorem ContinuousOn.continuousAt {f : α → β} {s : Set α} {x : α} (h : ContinuousOn f s) (hx : s ∈ 𝓝 x) : ContinuousAt f x := (h x (mem_of_mem_nhds hx)).continuousAt hx #align continuous_on.continuous_at ContinuousOn.continuousAt theorem ContinuousAt.continuousOn {f : α → β} {s : Set α} (hcont : ∀ x ∈ s, ContinuousAt f x) : ContinuousOn f s := fun x hx => (hcont x hx).continuousWithinAt #align continuous_at.continuous_on ContinuousAt.continuousOn theorem ContinuousWithinAt.comp {g : β → γ} {f : α → β} {s : Set α} {t : Set β} {x : α} (hg : ContinuousWithinAt g t (f x)) (hf : ContinuousWithinAt f s x) (h : MapsTo f s t) : ContinuousWithinAt (g ∘ f) s x := hg.tendsto.comp (hf.tendsto_nhdsWithin h) #align continuous_within_at.comp ContinuousWithinAt.comp theorem ContinuousWithinAt.comp' {g : β → γ} {f : α → β} {s : Set α} {t : Set β} {x : α} (hg : ContinuousWithinAt g t (f x)) (hf : ContinuousWithinAt f s x) : ContinuousWithinAt (g ∘ f) (s ∩ f ⁻¹' t) x := hg.comp (hf.mono inter_subset_left) inter_subset_right #align continuous_within_at.comp' ContinuousWithinAt.comp' theorem ContinuousAt.comp_continuousWithinAt {g : β → γ} {f : α → β} {s : Set α} {x : α} (hg : ContinuousAt g (f x)) (hf : ContinuousWithinAt f s x) : ContinuousWithinAt (g ∘ f) s x := hg.continuousWithinAt.comp hf (mapsTo_univ _ _) #align continuous_at.comp_continuous_within_at ContinuousAt.comp_continuousWithinAt theorem ContinuousOn.comp {g : β → γ} {f : α → β} {s : Set α} {t : Set β} (hg : ContinuousOn g t) (hf : ContinuousOn f s) (h : MapsTo f s t) : ContinuousOn (g ∘ f) s := fun x hx => ContinuousWithinAt.comp (hg _ (h hx)) (hf x hx) h #align continuous_on.comp ContinuousOn.comp @[fun_prop] theorem ContinuousOn.comp'' {g : β → γ} {f : α → β} {s : Set α} {t : Set β} (hg : ContinuousOn g t) (hf : ContinuousOn f s) (h : Set.MapsTo f s t) : ContinuousOn (fun x => g (f x)) s := ContinuousOn.comp hg hf h theorem ContinuousOn.mono {f : α → β} {s t : Set α} (hf : ContinuousOn f s) (h : t ⊆ s) : ContinuousOn f t := fun x hx => (hf x (h hx)).mono_left (nhdsWithin_mono _ h) #align continuous_on.mono ContinuousOn.mono theorem antitone_continuousOn {f : α → β} : Antitone (ContinuousOn f) := fun _s _t hst hf => hf.mono hst #align antitone_continuous_on antitone_continuousOn @[fun_prop] theorem ContinuousOn.comp' {g : β → γ} {f : α → β} {s : Set α} {t : Set β} (hg : ContinuousOn g t) (hf : ContinuousOn f s) : ContinuousOn (g ∘ f) (s ∩ f ⁻¹' t) := hg.comp (hf.mono inter_subset_left) inter_subset_right #align continuous_on.comp' ContinuousOn.comp' @[fun_prop] theorem Continuous.continuousOn {f : α → β} {s : Set α} (h : Continuous f) : ContinuousOn f s := by rw [continuous_iff_continuousOn_univ] at h exact h.mono (subset_univ _) #align continuous.continuous_on Continuous.continuousOn theorem Continuous.continuousWithinAt {f : α → β} {s : Set α} {x : α} (h : Continuous f) : ContinuousWithinAt f s x := h.continuousAt.continuousWithinAt #align continuous.continuous_within_at Continuous.continuousWithinAt theorem Continuous.comp_continuousOn {g : β → γ} {f : α → β} {s : Set α} (hg : Continuous g) (hf : ContinuousOn f s) : ContinuousOn (g ∘ f) s := hg.continuousOn.comp hf (mapsTo_univ _ _) #align continuous.comp_continuous_on Continuous.comp_continuousOn @[fun_prop] theorem Continuous.comp_continuousOn' {α β γ : Type*} [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ] {g : β → γ} {f : α → β} {s : Set α} (hg : Continuous g) (hf : ContinuousOn f s) : ContinuousOn (fun x ↦ g (f x)) s := hg.comp_continuousOn hf theorem ContinuousOn.comp_continuous {g : β → γ} {f : α → β} {s : Set β} (hg : ContinuousOn g s) (hf : Continuous f) (hs : ∀ x, f x ∈ s) : Continuous (g ∘ f) := by rw [continuous_iff_continuousOn_univ] at * exact hg.comp hf fun x _ => hs x #align continuous_on.comp_continuous ContinuousOn.comp_continuous @[fun_prop] theorem continuousOn_apply {ι : Type*} {π : ι → Type*} [∀ i, TopologicalSpace (π i)] (i : ι) (s) : ContinuousOn (fun p : ∀ i, π i => p i) s := Continuous.continuousOn (continuous_apply i) theorem ContinuousWithinAt.preimage_mem_nhdsWithin {f : α → β} {x : α} {s : Set α} {t : Set β} (h : ContinuousWithinAt f s x) (ht : t ∈ 𝓝 (f x)) : f ⁻¹' t ∈ 𝓝[s] x := h ht #align continuous_within_at.preimage_mem_nhds_within ContinuousWithinAt.preimage_mem_nhdsWithin theorem Set.LeftInvOn.map_nhdsWithin_eq {f : α → β} {g : β → α} {x : β} {s : Set β} (h : LeftInvOn f g s) (hx : f (g x) = x) (hf : ContinuousWithinAt f (g '' s) (g x)) (hg : ContinuousWithinAt g s x) : map g (𝓝[s] x) = 𝓝[g '' s] g x := by apply le_antisymm · exact hg.tendsto_nhdsWithin (mapsTo_image _ _) · have A : g ∘ f =ᶠ[𝓝[g '' s] g x] id := h.rightInvOn_image.eqOn.eventuallyEq_of_mem self_mem_nhdsWithin refine le_map_of_right_inverse A ?_ simpa only [hx] using hf.tendsto_nhdsWithin (h.mapsTo (surjOn_image _ _)) #align set.left_inv_on.map_nhds_within_eq Set.LeftInvOn.map_nhdsWithin_eq theorem Function.LeftInverse.map_nhds_eq {f : α → β} {g : β → α} {x : β} (h : Function.LeftInverse f g) (hf : ContinuousWithinAt f (range g) (g x)) (hg : ContinuousAt g x) : map g (𝓝 x) = 𝓝[range g] g x := by simpa only [nhdsWithin_univ, image_univ] using (h.leftInvOn univ).map_nhdsWithin_eq (h x) (by rwa [image_univ]) hg.continuousWithinAt #align function.left_inverse.map_nhds_eq Function.LeftInverse.map_nhds_eq theorem ContinuousWithinAt.preimage_mem_nhdsWithin' {f : α → β} {x : α} {s : Set α} {t : Set β} (h : ContinuousWithinAt f s x) (ht : t ∈ 𝓝[f '' s] f x) : f ⁻¹' t ∈ 𝓝[s] x := h.tendsto_nhdsWithin (mapsTo_image _ _) ht #align continuous_within_at.preimage_mem_nhds_within' ContinuousWithinAt.preimage_mem_nhdsWithin' theorem ContinuousWithinAt.preimage_mem_nhdsWithin'' {f : α → β} {x : α} {y : β} {s t : Set β} (h : ContinuousWithinAt f (f ⁻¹' s) x) (ht : t ∈ 𝓝[s] y) (hxy : y = f x) : f ⁻¹' t ∈ 𝓝[f ⁻¹' s] x := by rw [hxy] at ht exact h.preimage_mem_nhdsWithin' (nhdsWithin_mono _ (image_preimage_subset f s) ht) theorem Filter.EventuallyEq.congr_continuousWithinAt {f g : α → β} {s : Set α} {x : α} (h : f =ᶠ[𝓝[s] x] g) (hx : f x = g x) : ContinuousWithinAt f s x ↔ ContinuousWithinAt g s x := by rw [ContinuousWithinAt, hx, tendsto_congr' h, ContinuousWithinAt] #align filter.eventually_eq.congr_continuous_within_at Filter.EventuallyEq.congr_continuousWithinAt theorem ContinuousWithinAt.congr_of_eventuallyEq {f f₁ : α → β} {s : Set α} {x : α} (h : ContinuousWithinAt f s x) (h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) : ContinuousWithinAt f₁ s x := (h₁.congr_continuousWithinAt hx).2 h #align continuous_within_at.congr_of_eventually_eq ContinuousWithinAt.congr_of_eventuallyEq theorem ContinuousWithinAt.congr {f f₁ : α → β} {s : Set α} {x : α} (h : ContinuousWithinAt f s x) (h₁ : ∀ y ∈ s, f₁ y = f y) (hx : f₁ x = f x) : ContinuousWithinAt f₁ s x := h.congr_of_eventuallyEq (mem_of_superset self_mem_nhdsWithin h₁) hx #align continuous_within_at.congr ContinuousWithinAt.congr theorem ContinuousWithinAt.congr_mono {f g : α → β} {s s₁ : Set α} {x : α} (h : ContinuousWithinAt f s x) (h' : EqOn g f s₁) (h₁ : s₁ ⊆ s) (hx : g x = f x) : ContinuousWithinAt g s₁ x := (h.mono h₁).congr h' hx #align continuous_within_at.congr_mono ContinuousWithinAt.congr_mono @[fun_prop] theorem continuousOn_const {s : Set α} {c : β} : ContinuousOn (fun _ => c) s := continuous_const.continuousOn #align continuous_on_const continuousOn_const theorem continuousWithinAt_const {b : β} {s : Set α} {x : α} : ContinuousWithinAt (fun _ : α => b) s x := continuous_const.continuousWithinAt #align continuous_within_at_const continuousWithinAt_const theorem continuousOn_id {s : Set α} : ContinuousOn id s := continuous_id.continuousOn #align continuous_on_id continuousOn_id @[fun_prop] theorem continuousOn_id' (s : Set α) : ContinuousOn (fun x : α => x) s := continuousOn_id theorem continuousWithinAt_id {s : Set α} {x : α} : ContinuousWithinAt id s x := continuous_id.continuousWithinAt #align continuous_within_at_id continuousWithinAt_id theorem continuousOn_open_iff {f : α → β} {s : Set α} (hs : IsOpen s) : ContinuousOn f s ↔ ∀ t, IsOpen t → IsOpen (s ∩ f ⁻¹' t) := by rw [continuousOn_iff'] constructor · intro h t ht rcases h t ht with ⟨u, u_open, hu⟩ rw [inter_comm, hu] apply IsOpen.inter u_open hs · intro h t ht refine ⟨s ∩ f ⁻¹' t, h t ht, ?_⟩ rw [@inter_comm _ s (f ⁻¹' t), inter_assoc, inter_self] #align continuous_on_open_iff continuousOn_open_iff theorem ContinuousOn.isOpen_inter_preimage {f : α → β} {s : Set α} {t : Set β} (hf : ContinuousOn f s) (hs : IsOpen s) (ht : IsOpen t) : IsOpen (s ∩ f ⁻¹' t) := (continuousOn_open_iff hs).1 hf t ht #align continuous_on.preimage_open_of_open ContinuousOn.isOpen_inter_preimage theorem ContinuousOn.isOpen_preimage {f : α → β} {s : Set α} {t : Set β} (h : ContinuousOn f s) (hs : IsOpen s) (hp : f ⁻¹' t ⊆ s) (ht : IsOpen t) : IsOpen (f ⁻¹' t) := by convert (continuousOn_open_iff hs).mp h t ht rw [inter_comm, inter_eq_self_of_subset_left hp] #align continuous_on.is_open_preimage ContinuousOn.isOpen_preimage theorem ContinuousOn.preimage_isClosed_of_isClosed {f : α → β} {s : Set α} {t : Set β} (hf : ContinuousOn f s) (hs : IsClosed s) (ht : IsClosed t) : IsClosed (s ∩ f ⁻¹' t) := by rcases continuousOn_iff_isClosed.1 hf t ht with ⟨u, hu⟩ rw [inter_comm, hu.2] apply IsClosed.inter hu.1 hs #align continuous_on.preimage_closed_of_closed ContinuousOn.preimage_isClosed_of_isClosed theorem ContinuousOn.preimage_interior_subset_interior_preimage {f : α → β} {s : Set α} {t : Set β} (hf : ContinuousOn f s) (hs : IsOpen s) : s ∩ f ⁻¹' interior t ⊆ s ∩ interior (f ⁻¹' t) := calc s ∩ f ⁻¹' interior t ⊆ interior (s ∩ f ⁻¹' t) := interior_maximal (inter_subset_inter (Subset.refl _) (preimage_mono interior_subset)) (hf.isOpen_inter_preimage hs isOpen_interior) _ = s ∩ interior (f ⁻¹' t) := by rw [interior_inter, hs.interior_eq] #align continuous_on.preimage_interior_subset_interior_preimage ContinuousOn.preimage_interior_subset_interior_preimage theorem continuousOn_of_locally_continuousOn {f : α → β} {s : Set α} (h : ∀ x ∈ s, ∃ t, IsOpen t ∧ x ∈ t ∧ ContinuousOn f (s ∩ t)) : ContinuousOn f s := by intro x xs rcases h x xs with ⟨t, open_t, xt, ct⟩ have := ct x ⟨xs, xt⟩ rwa [ContinuousWithinAt, ← nhdsWithin_restrict _ xt open_t] at this #align continuous_on_of_locally_continuous_on continuousOn_of_locally_continuousOn -- Porting note (#10756): new lemma theorem continuousOn_to_generateFrom_iff {s : Set α} {T : Set (Set β)} {f : α → β} : @ContinuousOn α β _ (.generateFrom T) f s ↔ ∀ x ∈ s, ∀ t ∈ T, f x ∈ t → f ⁻¹' t ∈ 𝓝[s] x := forall₂_congr fun x _ => by delta ContinuousWithinAt simp only [TopologicalSpace.nhds_generateFrom, tendsto_iInf, tendsto_principal, mem_setOf_eq, and_imp] exact forall_congr' fun t => forall_swap -- Porting note: dropped an unneeded assumption theorem continuousOn_isOpen_of_generateFrom {β : Type*} {s : Set α} {T : Set (Set β)} {f : α → β} (h : ∀ t ∈ T, IsOpen (s ∩ f ⁻¹' t)) : @ContinuousOn α β _ (.generateFrom T) f s := continuousOn_to_generateFrom_iff.2 fun _x hx t ht hxt => mem_nhdsWithin.2 ⟨_, h t ht, ⟨hx, hxt⟩, fun _y hy => hy.1.2⟩ #align continuous_on_open_of_generate_from continuousOn_isOpen_of_generateFromₓ theorem ContinuousWithinAt.prod {f : α → β} {g : α → γ} {s : Set α} {x : α} (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) : ContinuousWithinAt (fun x => (f x, g x)) s x := hf.prod_mk_nhds hg #align continuous_within_at.prod ContinuousWithinAt.prod @[fun_prop] theorem ContinuousOn.prod {f : α → β} {g : α → γ} {s : Set α} (hf : ContinuousOn f s) (hg : ContinuousOn g s) : ContinuousOn (fun x => (f x, g x)) s := fun x hx => ContinuousWithinAt.prod (hf x hx) (hg x hx) #align continuous_on.prod ContinuousOn.prod theorem ContinuousAt.comp₂_continuousWithinAt {f : β × γ → δ} {g : α → β} {h : α → γ} {x : α} {s : Set α} (hf : ContinuousAt f (g x, h x)) (hg : ContinuousWithinAt g s x) (hh : ContinuousWithinAt h s x) : ContinuousWithinAt (fun x ↦ f (g x, h x)) s x := ContinuousAt.comp_continuousWithinAt hf (hg.prod hh) theorem ContinuousAt.comp₂_continuousWithinAt_of_eq {f : β × γ → δ} {g : α → β} {h : α → γ} {x : α} {s : Set α} {y : β × γ} (hf : ContinuousAt f y) (hg : ContinuousWithinAt g s x) (hh : ContinuousWithinAt h s x) (e : (g x, h x) = y) : ContinuousWithinAt (fun x ↦ f (g x, h x)) s x := by rw [← e] at hf exact hf.comp₂_continuousWithinAt hg hh theorem Inducing.continuousWithinAt_iff {f : α → β} {g : β → γ} (hg : Inducing g) {s : Set α} {x : α} : ContinuousWithinAt f s x ↔ ContinuousWithinAt (g ∘ f) s x := by simp_rw [ContinuousWithinAt, Inducing.tendsto_nhds_iff hg]; rfl #align inducing.continuous_within_at_iff Inducing.continuousWithinAt_iff theorem Inducing.continuousOn_iff {f : α → β} {g : β → γ} (hg : Inducing g) {s : Set α} : ContinuousOn f s ↔ ContinuousOn (g ∘ f) s := by simp_rw [ContinuousOn, hg.continuousWithinAt_iff] #align inducing.continuous_on_iff Inducing.continuousOn_iff theorem Embedding.continuousOn_iff {f : α → β} {g : β → γ} (hg : Embedding g) {s : Set α} : ContinuousOn f s ↔ ContinuousOn (g ∘ f) s := Inducing.continuousOn_iff hg.1 #align embedding.continuous_on_iff Embedding.continuousOn_iff theorem Embedding.map_nhdsWithin_eq {f : α → β} (hf : Embedding f) (s : Set α) (x : α) : map f (𝓝[s] x) = 𝓝[f '' s] f x := by rw [nhdsWithin, Filter.map_inf hf.inj, hf.map_nhds_eq, map_principal, ← nhdsWithin_inter', inter_eq_self_of_subset_right (image_subset_range _ _)] #align embedding.map_nhds_within_eq Embedding.map_nhdsWithin_eq theorem OpenEmbedding.map_nhdsWithin_preimage_eq {f : α → β} (hf : OpenEmbedding f) (s : Set β) (x : α) : map f (𝓝[f ⁻¹' s] x) = 𝓝[s] f x := by rw [hf.toEmbedding.map_nhdsWithin_eq, image_preimage_eq_inter_range] apply nhdsWithin_eq_nhdsWithin (mem_range_self _) hf.isOpen_range rw [inter_assoc, inter_self] #align open_embedding.map_nhds_within_preimage_eq OpenEmbedding.map_nhdsWithin_preimage_eq theorem continuousWithinAt_of_not_mem_closure {f : α → β} {s : Set α} {x : α} (hx : x ∉ closure s) : ContinuousWithinAt f s x := by rw [mem_closure_iff_nhdsWithin_neBot, not_neBot] at hx rw [ContinuousWithinAt, hx] exact tendsto_bot #align continuous_within_at_of_not_mem_closure continuousWithinAt_of_not_mem_closure theorem ContinuousOn.if' {s : Set α} {p : α → Prop} {f g : α → β} [∀ a, Decidable (p a)] (hpf : ∀ a ∈ s ∩ frontier { a | p a }, Tendsto f (𝓝[s ∩ { a | p a }] a) (𝓝 <| if p a then f a else g a)) (hpg : ∀ a ∈ s ∩ frontier { a | p a }, Tendsto g (𝓝[s ∩ { a | ¬p a }] a) (𝓝 <| if p a then f a else g a)) (hf : ContinuousOn f <| s ∩ { a | p a }) (hg : ContinuousOn g <| s ∩ { a | ¬p a }) : ContinuousOn (fun a => if p a then f a else g a) s := by intro x hx by_cases hx' : x ∈ frontier { a | p a } · exact (hpf x ⟨hx, hx'⟩).piecewise_nhdsWithin (hpg x ⟨hx, hx'⟩) · rw [← inter_univ s, ← union_compl_self { a | p a }, inter_union_distrib_left] at hx ⊢ cases' hx with hx hx · apply ContinuousWithinAt.union · exact (hf x hx).congr (fun y hy => if_pos hy.2) (if_pos hx.2) · have : x ∉ closure { a | p a }ᶜ := fun h => hx' ⟨subset_closure hx.2, by rwa [closure_compl] at h⟩ exact continuousWithinAt_of_not_mem_closure fun h => this (closure_inter_subset_inter_closure _ _ h).2 · apply ContinuousWithinAt.union · have : x ∉ closure { a | p a } := fun h => hx' ⟨h, fun h' : x ∈ interior { a | p a } => hx.2 (interior_subset h')⟩ exact continuousWithinAt_of_not_mem_closure fun h => this (closure_inter_subset_inter_closure _ _ h).2 · exact (hg x hx).congr (fun y hy => if_neg hy.2) (if_neg hx.2) #align continuous_on.if' ContinuousOn.if' theorem ContinuousOn.piecewise' {s t : Set α} {f g : α → β} [∀ a, Decidable (a ∈ t)] (hpf : ∀ a ∈ s ∩ frontier t, Tendsto f (𝓝[s ∩ t] a) (𝓝 (piecewise t f g a))) (hpg : ∀ a ∈ s ∩ frontier t, Tendsto g (𝓝[s ∩ tᶜ] a) (𝓝 (piecewise t f g a))) (hf : ContinuousOn f <| s ∩ t) (hg : ContinuousOn g <| s ∩ tᶜ) : ContinuousOn (piecewise t f g) s := hf.if' hpf hpg hg #align continuous_on.piecewise' ContinuousOn.piecewise' theorem ContinuousOn.if {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] {p : α → Prop} [∀ a, Decidable (p a)] {s : Set α} {f g : α → β} (hp : ∀ a ∈ s ∩ frontier { a | p a }, f a = g a) (hf : ContinuousOn f <| s ∩ closure { a | p a }) (hg : ContinuousOn g <| s ∩ closure { a | ¬p a }) : ContinuousOn (fun a => if p a then f a else g a) s := by apply ContinuousOn.if' · rintro a ha simp only [← hp a ha, ite_self] apply tendsto_nhdsWithin_mono_left (inter_subset_inter_right s subset_closure) exact hf a ⟨ha.1, ha.2.1⟩ · rintro a ha simp only [hp a ha, ite_self] apply tendsto_nhdsWithin_mono_left (inter_subset_inter_right s subset_closure) rcases ha with ⟨has, ⟨_, ha⟩⟩ rw [← mem_compl_iff, ← closure_compl] at ha apply hg a ⟨has, ha⟩ · exact hf.mono (inter_subset_inter_right s subset_closure) · exact hg.mono (inter_subset_inter_right s subset_closure) #align continuous_on.if ContinuousOn.if theorem ContinuousOn.piecewise {s t : Set α} {f g : α → β} [∀ a, Decidable (a ∈ t)] (ht : ∀ a ∈ s ∩ frontier t, f a = g a) (hf : ContinuousOn f <| s ∩ closure t) (hg : ContinuousOn g <| s ∩ closure tᶜ) : ContinuousOn (piecewise t f g) s := hf.if ht hg #align continuous_on.piecewise ContinuousOn.piecewise theorem continuous_if' {p : α → Prop} {f g : α → β} [∀ a, Decidable (p a)] (hpf : ∀ a ∈ frontier { x | p x }, Tendsto f (𝓝[{ x | p x }] a) (𝓝 <| ite (p a) (f a) (g a))) (hpg : ∀ a ∈ frontier { x | p x }, Tendsto g (𝓝[{ x | ¬p x }] a) (𝓝 <| ite (p a) (f a) (g a))) (hf : ContinuousOn f { x | p x }) (hg : ContinuousOn g { x | ¬p x }) : Continuous fun a => ite (p a) (f a) (g a) := by rw [continuous_iff_continuousOn_univ] apply ContinuousOn.if' <;> simp [*] <;> assumption #align continuous_if' continuous_if' theorem continuous_if {p : α → Prop} {f g : α → β} [∀ a, Decidable (p a)] (hp : ∀ a ∈ frontier { x | p x }, f a = g a) (hf : ContinuousOn f (closure { x | p x })) (hg : ContinuousOn g (closure { x | ¬p x })) : Continuous fun a => if p a then f a else g a := by rw [continuous_iff_continuousOn_univ] apply ContinuousOn.if <;> simp <;> assumption #align continuous_if continuous_if theorem Continuous.if {p : α → Prop} {f g : α → β} [∀ a, Decidable (p a)] (hp : ∀ a ∈ frontier { x | p x }, f a = g a) (hf : Continuous f) (hg : Continuous g) : Continuous fun a => if p a then f a else g a := continuous_if hp hf.continuousOn hg.continuousOn #align continuous.if Continuous.if theorem continuous_if_const (p : Prop) {f g : α → β} [Decidable p] (hf : p → Continuous f) (hg : ¬p → Continuous g) : Continuous fun a => if p then f a else g a := by split_ifs with h exacts [hf h, hg h] #align continuous_if_const continuous_if_const theorem Continuous.if_const (p : Prop) {f g : α → β} [Decidable p] (hf : Continuous f) (hg : Continuous g) : Continuous fun a => if p then f a else g a := continuous_if_const p (fun _ => hf) fun _ => hg #align continuous.if_const Continuous.if_const theorem continuous_piecewise {s : Set α} {f g : α → β} [∀ a, Decidable (a ∈ s)] (hs : ∀ a ∈ frontier s, f a = g a) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure sᶜ)) : Continuous (piecewise s f g) := continuous_if hs hf hg #align continuous_piecewise continuous_piecewise theorem Continuous.piecewise {s : Set α} {f g : α → β} [∀ a, Decidable (a ∈ s)] (hs : ∀ a ∈ frontier s, f a = g a) (hf : Continuous f) (hg : Continuous g) : Continuous (piecewise s f g) := hf.if hs hg #align continuous.piecewise Continuous.piecewise
Mathlib/Topology/ContinuousOn.lean
1,318
1,324
theorem IsOpen.ite' {s s' t : Set α} (hs : IsOpen s) (hs' : IsOpen s') (ht : ∀ x ∈ frontier t, x ∈ s ↔ x ∈ s') : IsOpen (t.ite s s') := by
classical simp only [isOpen_iff_continuous_mem, Set.ite] at * convert continuous_piecewise (fun x hx => propext (ht x hx)) hs.continuousOn hs'.continuousOn rename_i x by_cases hx : x ∈ t <;> simp [hx]
import Mathlib.CategoryTheory.EpiMono import Mathlib.CategoryTheory.Limits.HasLimits #align_import category_theory.limits.shapes.equalizers from "leanprover-community/mathlib"@"4698e35ca56a0d4fa53aa5639c3364e0a77f4eba" section open CategoryTheory Opposite namespace CategoryTheory.Limits -- attribute [local tidy] tactic.case_bash -- Porting note: no tidy nor cases_bash universe v v₂ u u₂ inductive WalkingParallelPair : Type | zero | one deriving DecidableEq, Inhabited #align category_theory.limits.walking_parallel_pair CategoryTheory.Limits.WalkingParallelPair open WalkingParallelPair inductive WalkingParallelPairHom : WalkingParallelPair → WalkingParallelPair → Type | left : WalkingParallelPairHom zero one | right : WalkingParallelPairHom zero one | id (X : WalkingParallelPair) : WalkingParallelPairHom X X deriving DecidableEq #align category_theory.limits.walking_parallel_pair_hom CategoryTheory.Limits.WalkingParallelPairHom attribute [-simp, nolint simpNF] WalkingParallelPairHom.id.sizeOf_spec instance : Inhabited (WalkingParallelPairHom zero one) where default := WalkingParallelPairHom.left open WalkingParallelPairHom def WalkingParallelPairHom.comp : -- Porting note: changed X Y Z to implicit to match comp fields in precategory ∀ { X Y Z : WalkingParallelPair } (_ : WalkingParallelPairHom X Y) (_ : WalkingParallelPairHom Y Z), WalkingParallelPairHom X Z | _, _, _, id _, h => h | _, _, _, left, id one => left | _, _, _, right, id one => right #align category_theory.limits.walking_parallel_pair_hom.comp CategoryTheory.Limits.WalkingParallelPairHom.comp -- Porting note: adding these since they are simple and aesop couldn't directly prove them theorem WalkingParallelPairHom.id_comp {X Y : WalkingParallelPair} (g : WalkingParallelPairHom X Y) : comp (id X) g = g := rfl theorem WalkingParallelPairHom.comp_id {X Y : WalkingParallelPair} (f : WalkingParallelPairHom X Y) : comp f (id Y) = f := by cases f <;> rfl theorem WalkingParallelPairHom.assoc {X Y Z W : WalkingParallelPair} (f : WalkingParallelPairHom X Y) (g: WalkingParallelPairHom Y Z) (h : WalkingParallelPairHom Z W) : comp (comp f g) h = comp f (comp g h) := by cases f <;> cases g <;> cases h <;> rfl instance walkingParallelPairHomCategory : SmallCategory WalkingParallelPair where Hom := WalkingParallelPairHom id := id comp := comp comp_id := comp_id id_comp := id_comp assoc := assoc #align category_theory.limits.walking_parallel_pair_hom_category CategoryTheory.Limits.walkingParallelPairHomCategory @[simp] theorem walkingParallelPairHom_id (X : WalkingParallelPair) : WalkingParallelPairHom.id X = 𝟙 X := rfl #align category_theory.limits.walking_parallel_pair_hom_id CategoryTheory.Limits.walkingParallelPairHom_id -- Porting note: simpNF asked me to do this because the LHS of the non-primed version reduced @[simp] theorem WalkingParallelPairHom.id.sizeOf_spec' (X : WalkingParallelPair) : (WalkingParallelPairHom._sizeOf_inst X X).sizeOf (𝟙 X) = 1 + sizeOf X := by cases X <;> rfl def walkingParallelPairOp : WalkingParallelPair ⥤ WalkingParallelPairᵒᵖ where obj x := op <| by cases x; exacts [one, zero] map f := by cases f <;> apply Quiver.Hom.op exacts [left, right, WalkingParallelPairHom.id _] map_comp := by rintro _ _ _ (_|_|_) g <;> cases g <;> rfl #align category_theory.limits.walking_parallel_pair_op CategoryTheory.Limits.walkingParallelPairOp @[simp] theorem walkingParallelPairOp_zero : walkingParallelPairOp.obj zero = op one := rfl #align category_theory.limits.walking_parallel_pair_op_zero CategoryTheory.Limits.walkingParallelPairOp_zero @[simp] theorem walkingParallelPairOp_one : walkingParallelPairOp.obj one = op zero := rfl #align category_theory.limits.walking_parallel_pair_op_one CategoryTheory.Limits.walkingParallelPairOp_one @[simp] theorem walkingParallelPairOp_left : walkingParallelPairOp.map left = @Quiver.Hom.op _ _ zero one left := rfl #align category_theory.limits.walking_parallel_pair_op_left CategoryTheory.Limits.walkingParallelPairOp_left @[simp] theorem walkingParallelPairOp_right : walkingParallelPairOp.map right = @Quiver.Hom.op _ _ zero one right := rfl #align category_theory.limits.walking_parallel_pair_op_right CategoryTheory.Limits.walkingParallelPairOp_right @[simps functor inverse] def walkingParallelPairOpEquiv : WalkingParallelPair ≌ WalkingParallelPairᵒᵖ where functor := walkingParallelPairOp inverse := walkingParallelPairOp.leftOp unitIso := NatIso.ofComponents (fun j => eqToIso (by cases j <;> rfl)) (by rintro _ _ (_ | _ | _) <;> simp) counitIso := NatIso.ofComponents (fun j => eqToIso (by induction' j with X cases X <;> rfl)) (fun {i} {j} f => by induction' i with i induction' j with j let g := f.unop have : f = g.op := rfl rw [this] cases i <;> cases j <;> cases g <;> rfl) functor_unitIso_comp := fun j => by cases j <;> rfl #align category_theory.limits.walking_parallel_pair_op_equiv CategoryTheory.Limits.walkingParallelPairOpEquiv @[simp] theorem walkingParallelPairOpEquiv_unitIso_zero : walkingParallelPairOpEquiv.unitIso.app zero = Iso.refl zero := rfl #align category_theory.limits.walking_parallel_pair_op_equiv_unit_iso_zero CategoryTheory.Limits.walkingParallelPairOpEquiv_unitIso_zero @[simp] theorem walkingParallelPairOpEquiv_unitIso_one : walkingParallelPairOpEquiv.unitIso.app one = Iso.refl one := rfl #align category_theory.limits.walking_parallel_pair_op_equiv_unit_iso_one CategoryTheory.Limits.walkingParallelPairOpEquiv_unitIso_one @[simp] theorem walkingParallelPairOpEquiv_counitIso_zero : walkingParallelPairOpEquiv.counitIso.app (op zero) = Iso.refl (op zero) := rfl #align category_theory.limits.walking_parallel_pair_op_equiv_counit_iso_zero CategoryTheory.Limits.walkingParallelPairOpEquiv_counitIso_zero @[simp] theorem walkingParallelPairOpEquiv_counitIso_one : walkingParallelPairOpEquiv.counitIso.app (op one) = Iso.refl (op one) := rfl #align category_theory.limits.walking_parallel_pair_op_equiv_counit_iso_one CategoryTheory.Limits.walkingParallelPairOpEquiv_counitIso_one variable {C : Type u} [Category.{v} C] variable {X Y : C} def parallelPair (f g : X ⟶ Y) : WalkingParallelPair ⥤ C where obj x := match x with | zero => X | one => Y map h := match h with | WalkingParallelPairHom.id _ => 𝟙 _ | left => f | right => g -- `sorry` can cope with this, but it's too slow: map_comp := by rintro _ _ _ ⟨⟩ g <;> cases g <;> {dsimp; simp} #align category_theory.limits.parallel_pair CategoryTheory.Limits.parallelPair @[simp] theorem parallelPair_obj_zero (f g : X ⟶ Y) : (parallelPair f g).obj zero = X := rfl #align category_theory.limits.parallel_pair_obj_zero CategoryTheory.Limits.parallelPair_obj_zero @[simp] theorem parallelPair_obj_one (f g : X ⟶ Y) : (parallelPair f g).obj one = Y := rfl #align category_theory.limits.parallel_pair_obj_one CategoryTheory.Limits.parallelPair_obj_one @[simp] theorem parallelPair_map_left (f g : X ⟶ Y) : (parallelPair f g).map left = f := rfl #align category_theory.limits.parallel_pair_map_left CategoryTheory.Limits.parallelPair_map_left @[simp] theorem parallelPair_map_right (f g : X ⟶ Y) : (parallelPair f g).map right = g := rfl #align category_theory.limits.parallel_pair_map_right CategoryTheory.Limits.parallelPair_map_right @[simp] theorem parallelPair_functor_obj {F : WalkingParallelPair ⥤ C} (j : WalkingParallelPair) : (parallelPair (F.map left) (F.map right)).obj j = F.obj j := by cases j <;> rfl #align category_theory.limits.parallel_pair_functor_obj CategoryTheory.Limits.parallelPair_functor_obj @[simps!] def diagramIsoParallelPair (F : WalkingParallelPair ⥤ C) : F ≅ parallelPair (F.map left) (F.map right) := NatIso.ofComponents (fun j => eqToIso <| by cases j <;> rfl) (by rintro _ _ (_|_|_) <;> simp) #align category_theory.limits.diagram_iso_parallel_pair CategoryTheory.Limits.diagramIsoParallelPair def parallelPairHom {X' Y' : C} (f g : X ⟶ Y) (f' g' : X' ⟶ Y') (p : X ⟶ X') (q : Y ⟶ Y') (wf : f ≫ q = p ≫ f') (wg : g ≫ q = p ≫ g') : parallelPair f g ⟶ parallelPair f' g' where app j := match j with | zero => p | one => q naturality := by rintro _ _ ⟨⟩ <;> {dsimp; simp [wf,wg]} #align category_theory.limits.parallel_pair_hom CategoryTheory.Limits.parallelPairHom @[simp] theorem parallelPairHom_app_zero {X' Y' : C} (f g : X ⟶ Y) (f' g' : X' ⟶ Y') (p : X ⟶ X') (q : Y ⟶ Y') (wf : f ≫ q = p ≫ f') (wg : g ≫ q = p ≫ g') : (parallelPairHom f g f' g' p q wf wg).app zero = p := rfl #align category_theory.limits.parallel_pair_hom_app_zero CategoryTheory.Limits.parallelPairHom_app_zero @[simp] theorem parallelPairHom_app_one {X' Y' : C} (f g : X ⟶ Y) (f' g' : X' ⟶ Y') (p : X ⟶ X') (q : Y ⟶ Y') (wf : f ≫ q = p ≫ f') (wg : g ≫ q = p ≫ g') : (parallelPairHom f g f' g' p q wf wg).app one = q := rfl #align category_theory.limits.parallel_pair_hom_app_one CategoryTheory.Limits.parallelPairHom_app_one @[simps!] def parallelPair.ext {F G : WalkingParallelPair ⥤ C} (zero : F.obj zero ≅ G.obj zero) (one : F.obj one ≅ G.obj one) (left : F.map left ≫ one.hom = zero.hom ≫ G.map left) (right : F.map right ≫ one.hom = zero.hom ≫ G.map right) : F ≅ G := NatIso.ofComponents (by rintro ⟨j⟩ exacts [zero, one]) (by rintro _ _ ⟨_⟩ <;> simp [left, right]) #align category_theory.limits.parallel_pair.ext CategoryTheory.Limits.parallelPair.ext @[simps!] def parallelPair.eqOfHomEq {f g f' g' : X ⟶ Y} (hf : f = f') (hg : g = g') : parallelPair f g ≅ parallelPair f' g' := parallelPair.ext (Iso.refl _) (Iso.refl _) (by simp [hf]) (by simp [hg]) #align category_theory.limits.parallel_pair.eq_of_hom_eq CategoryTheory.Limits.parallelPair.eqOfHomEq abbrev Fork (f g : X ⟶ Y) := Cone (parallelPair f g) #align category_theory.limits.fork CategoryTheory.Limits.Fork abbrev Cofork (f g : X ⟶ Y) := Cocone (parallelPair f g) #align category_theory.limits.cofork CategoryTheory.Limits.Cofork variable {f g : X ⟶ Y} def Fork.ι (t : Fork f g) := t.π.app zero #align category_theory.limits.fork.ι CategoryTheory.Limits.Fork.ι @[simp] theorem Fork.app_zero_eq_ι (t : Fork f g) : t.π.app zero = t.ι := rfl #align category_theory.limits.fork.app_zero_eq_ι CategoryTheory.Limits.Fork.app_zero_eq_ι def Cofork.π (t : Cofork f g) := t.ι.app one #align category_theory.limits.cofork.π CategoryTheory.Limits.Cofork.π @[simp] theorem Cofork.app_one_eq_π (t : Cofork f g) : t.ι.app one = t.π := rfl #align category_theory.limits.cofork.app_one_eq_π CategoryTheory.Limits.Cofork.app_one_eq_π @[simp] theorem Fork.app_one_eq_ι_comp_left (s : Fork f g) : s.π.app one = s.ι ≫ f := by rw [← s.app_zero_eq_ι, ← s.w left, parallelPair_map_left] #align category_theory.limits.fork.app_one_eq_ι_comp_left CategoryTheory.Limits.Fork.app_one_eq_ι_comp_left @[reassoc] theorem Fork.app_one_eq_ι_comp_right (s : Fork f g) : s.π.app one = s.ι ≫ g := by rw [← s.app_zero_eq_ι, ← s.w right, parallelPair_map_right] #align category_theory.limits.fork.app_one_eq_ι_comp_right CategoryTheory.Limits.Fork.app_one_eq_ι_comp_right @[simp] theorem Cofork.app_zero_eq_comp_π_left (s : Cofork f g) : s.ι.app zero = f ≫ s.π := by rw [← s.app_one_eq_π, ← s.w left, parallelPair_map_left] #align category_theory.limits.cofork.app_zero_eq_comp_π_left CategoryTheory.Limits.Cofork.app_zero_eq_comp_π_left @[reassoc] theorem Cofork.app_zero_eq_comp_π_right (s : Cofork f g) : s.ι.app zero = g ≫ s.π := by rw [← s.app_one_eq_π, ← s.w right, parallelPair_map_right] #align category_theory.limits.cofork.app_zero_eq_comp_π_right CategoryTheory.Limits.Cofork.app_zero_eq_comp_π_right @[simps] def Fork.ofι {P : C} (ι : P ⟶ X) (w : ι ≫ f = ι ≫ g) : Fork f g where pt := P π := { app := fun X => by cases X · exact ι · exact ι ≫ f naturality := fun {X} {Y} f => by cases X <;> cases Y <;> cases f <;> dsimp <;> simp; assumption } #align category_theory.limits.fork.of_ι CategoryTheory.Limits.Fork.ofι @[simps] def Cofork.ofπ {P : C} (π : Y ⟶ P) (w : f ≫ π = g ≫ π) : Cofork f g where pt := P ι := { app := fun X => WalkingParallelPair.casesOn X (f ≫ π) π naturality := fun i j f => by cases f <;> dsimp <;> simp [w] } #align category_theory.limits.cofork.of_π CategoryTheory.Limits.Cofork.ofπ -- See note [dsimp, simp] @[simp] theorem Fork.ι_ofι {P : C} (ι : P ⟶ X) (w : ι ≫ f = ι ≫ g) : (Fork.ofι ι w).ι = ι := rfl #align category_theory.limits.fork.ι_of_ι CategoryTheory.Limits.Fork.ι_ofι @[simp] theorem Cofork.π_ofπ {P : C} (π : Y ⟶ P) (w : f ≫ π = g ≫ π) : (Cofork.ofπ π w).π = π := rfl #align category_theory.limits.cofork.π_of_π CategoryTheory.Limits.Cofork.π_ofπ @[reassoc (attr := simp)] theorem Fork.condition (t : Fork f g) : t.ι ≫ f = t.ι ≫ g := by rw [← t.app_one_eq_ι_comp_left, ← t.app_one_eq_ι_comp_right] #align category_theory.limits.fork.condition CategoryTheory.Limits.Fork.condition @[reassoc (attr := simp)] theorem Cofork.condition (t : Cofork f g) : f ≫ t.π = g ≫ t.π := by rw [← t.app_zero_eq_comp_π_left, ← t.app_zero_eq_comp_π_right] #align category_theory.limits.cofork.condition CategoryTheory.Limits.Cofork.condition
Mathlib/CategoryTheory/Limits/Shapes/Equalizers.lean
403
409
theorem Fork.equalizer_ext (s : Fork f g) {W : C} {k l : W ⟶ s.pt} (h : k ≫ s.ι = l ≫ s.ι) : ∀ j : WalkingParallelPair, k ≫ s.π.app j = l ≫ s.π.app j | zero => h | one => by have : k ≫ ι s ≫ f = l ≫ ι s ≫ f := by
simp only [← Category.assoc]; exact congrArg (· ≫ f) h rw [s.app_one_eq_ι_comp_left, this]
import Mathlib.Algebra.GroupWithZero.NonZeroDivisors import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.RingTheory.Coprime.Basic import Mathlib.Tactic.AdaptationNote #align_import ring_theory.polynomial.scale_roots from "leanprover-community/mathlib"@"40ac1b258344e0c2b4568dc37bfad937ec35a727" variable {R S A K : Type*} namespace Polynomial open Polynomial section Semiring variable [Semiring R] [Semiring S] noncomputable def scaleRoots (p : R[X]) (s : R) : R[X] := ∑ i ∈ p.support, monomial i (p.coeff i * s ^ (p.natDegree - i)) #align polynomial.scale_roots Polynomial.scaleRoots @[simp] theorem coeff_scaleRoots (p : R[X]) (s : R) (i : ℕ) : (scaleRoots p s).coeff i = coeff p i * s ^ (p.natDegree - i) := by simp (config := { contextual := true }) [scaleRoots, coeff_monomial] #align polynomial.coeff_scale_roots Polynomial.coeff_scaleRoots theorem coeff_scaleRoots_natDegree (p : R[X]) (s : R) : (scaleRoots p s).coeff p.natDegree = p.leadingCoeff := by rw [leadingCoeff, coeff_scaleRoots, tsub_self, pow_zero, mul_one] #align polynomial.coeff_scale_roots_nat_degree Polynomial.coeff_scaleRoots_natDegree @[simp] theorem zero_scaleRoots (s : R) : scaleRoots 0 s = 0 := by ext simp #align polynomial.zero_scale_roots Polynomial.zero_scaleRoots theorem scaleRoots_ne_zero {p : R[X]} (hp : p ≠ 0) (s : R) : scaleRoots p s ≠ 0 := by intro h have : p.coeff p.natDegree ≠ 0 := mt leadingCoeff_eq_zero.mp hp have : (scaleRoots p s).coeff p.natDegree = 0 := congr_fun (congr_arg (coeff : R[X] → ℕ → R) h) p.natDegree rw [coeff_scaleRoots_natDegree] at this contradiction #align polynomial.scale_roots_ne_zero Polynomial.scaleRoots_ne_zero theorem support_scaleRoots_le (p : R[X]) (s : R) : (scaleRoots p s).support ≤ p.support := by intro simpa using left_ne_zero_of_mul #align polynomial.support_scale_roots_le Polynomial.support_scaleRoots_le theorem support_scaleRoots_eq (p : R[X]) {s : R} (hs : s ∈ nonZeroDivisors R) : (scaleRoots p s).support = p.support := le_antisymm (support_scaleRoots_le p s) (by intro i simp only [coeff_scaleRoots, Polynomial.mem_support_iff] intro p_ne_zero ps_zero have := pow_mem hs (p.natDegree - i) _ ps_zero contradiction) #align polynomial.support_scale_roots_eq Polynomial.support_scaleRoots_eq @[simp] theorem degree_scaleRoots (p : R[X]) {s : R} : degree (scaleRoots p s) = degree p := by haveI := Classical.propDecidable by_cases hp : p = 0 · rw [hp, zero_scaleRoots] refine le_antisymm (Finset.sup_mono (support_scaleRoots_le p s)) (degree_le_degree ?_) rw [coeff_scaleRoots_natDegree] intro h have := leadingCoeff_eq_zero.mp h contradiction #align polynomial.degree_scale_roots Polynomial.degree_scaleRoots @[simp] theorem natDegree_scaleRoots (p : R[X]) (s : R) : natDegree (scaleRoots p s) = natDegree p := by simp only [natDegree, degree_scaleRoots] #align polynomial.nat_degree_scale_roots Polynomial.natDegree_scaleRoots theorem monic_scaleRoots_iff {p : R[X]} (s : R) : Monic (scaleRoots p s) ↔ Monic p := by simp only [Monic, leadingCoeff, natDegree_scaleRoots, coeff_scaleRoots_natDegree] #align polynomial.monic_scale_roots_iff Polynomial.monic_scaleRoots_iff
Mathlib/RingTheory/Polynomial/ScaleRoots.lean
98
101
theorem map_scaleRoots (p : R[X]) (x : R) (f : R →+* S) (h : f p.leadingCoeff ≠ 0) : (p.scaleRoots x).map f = (p.map f).scaleRoots (f x) := by
ext simp [Polynomial.natDegree_map_of_leadingCoeff_ne_zero _ h]
import Mathlib.LinearAlgebra.FiniteDimensional import Mathlib.LinearAlgebra.FreeModule.Finite.Basic import Mathlib.LinearAlgebra.FreeModule.StrongRankCondition import Mathlib.LinearAlgebra.Projection import Mathlib.LinearAlgebra.SesquilinearForm import Mathlib.RingTheory.TensorProduct.Basic import Mathlib.RingTheory.Ideal.LocalRing #align_import linear_algebra.dual from "leanprover-community/mathlib"@"b1c017582e9f18d8494e5c18602a8cb4a6f843ac" noncomputable section namespace Module -- Porting note: max u v universe issues so name and specific below universe uR uA uM uM' uM'' variable (R : Type uR) (A : Type uA) (M : Type uM) variable [CommSemiring R] [AddCommMonoid M] [Module R M] abbrev Dual := M →ₗ[R] R #align module.dual Module.Dual def dualPairing (R M) [CommSemiring R] [AddCommMonoid M] [Module R M] : Module.Dual R M →ₗ[R] M →ₗ[R] R := LinearMap.id #align module.dual_pairing Module.dualPairing @[simp] theorem dualPairing_apply (v x) : dualPairing R M v x = v x := rfl #align module.dual_pairing_apply Module.dualPairing_apply namespace Dual instance : Inhabited (Dual R M) := ⟨0⟩ def eval : M →ₗ[R] Dual R (Dual R M) := LinearMap.flip LinearMap.id #align module.dual.eval Module.Dual.eval @[simp] theorem eval_apply (v : M) (a : Dual R M) : eval R M v a = a v := rfl #align module.dual.eval_apply Module.Dual.eval_apply variable {R M} {M' : Type uM'} variable [AddCommMonoid M'] [Module R M'] def transpose : (M →ₗ[R] M') →ₗ[R] Dual R M' →ₗ[R] Dual R M := (LinearMap.llcomp R M M' R).flip #align module.dual.transpose Module.Dual.transpose -- Porting note: with reducible def need to specify some parameters to transpose explicitly theorem transpose_apply (u : M →ₗ[R] M') (l : Dual R M') : transpose (R := R) u l = l.comp u := rfl #align module.dual.transpose_apply Module.Dual.transpose_apply variable {M'' : Type uM''} [AddCommMonoid M''] [Module R M''] -- Porting note: with reducible def need to specify some parameters to transpose explicitly theorem transpose_comp (u : M' →ₗ[R] M'') (v : M →ₗ[R] M') : transpose (R := R) (u.comp v) = (transpose (R := R) v).comp (transpose (R := R) u) := rfl #align module.dual.transpose_comp Module.Dual.transpose_comp end Dual section Prod variable (M' : Type uM') [AddCommMonoid M'] [Module R M'] @[simps!] def dualProdDualEquivDual : (Module.Dual R M × Module.Dual R M') ≃ₗ[R] Module.Dual R (M × M') := LinearMap.coprodEquiv R #align module.dual_prod_dual_equiv_dual Module.dualProdDualEquivDual @[simp] theorem dualProdDualEquivDual_apply (φ : Module.Dual R M) (ψ : Module.Dual R M') : dualProdDualEquivDual R M M' (φ, ψ) = φ.coprod ψ := rfl #align module.dual_prod_dual_equiv_dual_apply Module.dualProdDualEquivDual_apply end Prod end Module namespace Basis universe u v w open Module Module.Dual Submodule LinearMap Cardinal Function universe uR uM uK uV uι variable {R : Type uR} {M : Type uM} {K : Type uK} {V : Type uV} {ι : Type uι} section CommSemiring variable [CommSemiring R] [AddCommMonoid M] [Module R M] [DecidableEq ι] variable (b : Basis ι R M) def toDual : M →ₗ[R] Module.Dual R M := b.constr ℕ fun v => b.constr ℕ fun w => if w = v then (1 : R) else 0 #align basis.to_dual Basis.toDual theorem toDual_apply (i j : ι) : b.toDual (b i) (b j) = if i = j then 1 else 0 := by erw [constr_basis b, constr_basis b] simp only [eq_comm] #align basis.to_dual_apply Basis.toDual_apply @[simp] theorem toDual_total_left (f : ι →₀ R) (i : ι) : b.toDual (Finsupp.total ι M R b f) (b i) = f i := by rw [Finsupp.total_apply, Finsupp.sum, _root_.map_sum, LinearMap.sum_apply] simp_rw [LinearMap.map_smul, LinearMap.smul_apply, toDual_apply, smul_eq_mul, mul_boole, Finset.sum_ite_eq'] split_ifs with h · rfl · rw [Finsupp.not_mem_support_iff.mp h] #align basis.to_dual_total_left Basis.toDual_total_left @[simp]
Mathlib/LinearAlgebra/Dual.lean
320
326
theorem toDual_total_right (f : ι →₀ R) (i : ι) : b.toDual (b i) (Finsupp.total ι M R b f) = f i := by
rw [Finsupp.total_apply, Finsupp.sum, _root_.map_sum] simp_rw [LinearMap.map_smul, toDual_apply, smul_eq_mul, mul_boole, Finset.sum_ite_eq] split_ifs with h · rfl · rw [Finsupp.not_mem_support_iff.mp h]
import Mathlib.CategoryTheory.Sites.Plus import Mathlib.CategoryTheory.Limits.Shapes.ConcreteCategory #align_import category_theory.sites.sheafification from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" namespace CategoryTheory open CategoryTheory.Limits Opposite universe w v u variable {C : Type u} [Category.{v} C] {J : GrothendieckTopology C} variable {D : Type w} [Category.{max v u} D] section variable [ConcreteCategory.{max v u} D] attribute [local instance] ConcreteCategory.hasCoeToSort ConcreteCategory.instFunLike -- porting note (#5171): removed @[nolint has_nonempty_instance] def Meq {X : C} (P : Cᵒᵖ ⥤ D) (S : J.Cover X) := { x : ∀ I : S.Arrow, P.obj (op I.Y) // ∀ I : S.Relation, P.map I.g₁.op (x I.fst) = P.map I.g₂.op (x I.snd) } #align category_theory.meq CategoryTheory.Meq end namespace GrothendieckTopology variable (J) variable [∀ (P : Cᵒᵖ ⥤ D) (X : C) (S : J.Cover X), HasMultiequalizer (S.index P)] [∀ X : C, HasColimitsOfShape (J.Cover X)ᵒᵖ D] noncomputable def sheafify (P : Cᵒᵖ ⥤ D) : Cᵒᵖ ⥤ D := J.plusObj (J.plusObj P) #align category_theory.grothendieck_topology.sheafify CategoryTheory.GrothendieckTopology.sheafify noncomputable def toSheafify (P : Cᵒᵖ ⥤ D) : P ⟶ J.sheafify P := J.toPlus P ≫ J.plusMap (J.toPlus P) #align category_theory.grothendieck_topology.to_sheafify CategoryTheory.GrothendieckTopology.toSheafify noncomputable def sheafifyMap {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) : J.sheafify P ⟶ J.sheafify Q := J.plusMap <| J.plusMap η #align category_theory.grothendieck_topology.sheafify_map CategoryTheory.GrothendieckTopology.sheafifyMap @[simp] theorem sheafifyMap_id (P : Cᵒᵖ ⥤ D) : J.sheafifyMap (𝟙 P) = 𝟙 (J.sheafify P) := by dsimp [sheafifyMap, sheafify] simp #align category_theory.grothendieck_topology.sheafify_map_id CategoryTheory.GrothendieckTopology.sheafifyMap_id @[simp]
Mathlib/CategoryTheory/Sites/ConcreteSheafification.lean
483
486
theorem sheafifyMap_comp {P Q R : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (γ : Q ⟶ R) : J.sheafifyMap (η ≫ γ) = J.sheafifyMap η ≫ J.sheafifyMap γ := by
dsimp [sheafifyMap, sheafify] simp
import Mathlib.RingTheory.WittVector.Frobenius import Mathlib.RingTheory.WittVector.Verschiebung import Mathlib.RingTheory.WittVector.MulP #align_import ring_theory.witt_vector.identities from "leanprover-community/mathlib"@"0798037604b2d91748f9b43925fb7570a5f3256c" namespace WittVector variable {p : ℕ} {R : Type*} [hp : Fact p.Prime] [CommRing R] -- type as `\bbW` local notation "𝕎" => WittVector p noncomputable section -- Porting note: `ghost_calc` failure: `simp only []` and the manual instances had to be added. theorem frobenius_verschiebung (x : 𝕎 R) : frobenius (verschiebung x) = x * p := by have : IsPoly p fun {R} [CommRing R] x ↦ frobenius (verschiebung x) := IsPoly.comp (hg := frobenius_isPoly p) (hf := verschiebung_isPoly) have : IsPoly p fun {R} [CommRing R] x ↦ x * p := mulN_isPoly p p ghost_calc x ghost_simp [mul_comm] #align witt_vector.frobenius_verschiebung WittVector.frobenius_verschiebung theorem verschiebung_zmod (x : 𝕎 (ZMod p)) : verschiebung x = x * p := by rw [← frobenius_verschiebung, frobenius_zmodp] #align witt_vector.verschiebung_zmod WittVector.verschiebung_zmod variable (p R)
Mathlib/RingTheory/WittVector/Identities.lean
57
61
theorem coeff_p_pow [CharP R p] (i : ℕ) : ((p : 𝕎 R) ^ i).coeff i = 1 := by
induction' i with i h · simp only [Nat.zero_eq, one_coeff_zero, Ne, pow_zero] · rw [pow_succ, ← frobenius_verschiebung, coeff_frobenius_charP, verschiebung_coeff_succ, h, one_pow]
import Mathlib.Algebra.ModEq import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.Archimedean import Mathlib.Algebra.Periodic import Mathlib.Data.Int.SuccPred import Mathlib.GroupTheory.QuotientGroup import Mathlib.Order.Circular import Mathlib.Data.List.TFAE import Mathlib.Data.Set.Lattice #align_import algebra.order.to_interval_mod from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec" noncomputable section section LinearOrderedAddCommGroup variable {α : Type*} [LinearOrderedAddCommGroup α] [hα : Archimedean α] {p : α} (hp : 0 < p) {a b c : α} {n : ℤ} def toIcoDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ico hp b a).choose #align to_Ico_div toIcoDiv theorem sub_toIcoDiv_zsmul_mem_Ico (a b : α) : b - toIcoDiv hp a b • p ∈ Set.Ico a (a + p) := (existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.1 #align sub_to_Ico_div_zsmul_mem_Ico sub_toIcoDiv_zsmul_mem_Ico theorem toIcoDiv_eq_of_sub_zsmul_mem_Ico (h : b - n • p ∈ Set.Ico a (a + p)) : toIcoDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.2 _ h).symm #align to_Ico_div_eq_of_sub_zsmul_mem_Ico toIcoDiv_eq_of_sub_zsmul_mem_Ico def toIocDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose #align to_Ioc_div toIocDiv theorem sub_toIocDiv_zsmul_mem_Ioc (a b : α) : b - toIocDiv hp a b • p ∈ Set.Ioc a (a + p) := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.1 #align sub_to_Ioc_div_zsmul_mem_Ioc sub_toIocDiv_zsmul_mem_Ioc theorem toIocDiv_eq_of_sub_zsmul_mem_Ioc (h : b - n • p ∈ Set.Ioc a (a + p)) : toIocDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.2 _ h).symm #align to_Ioc_div_eq_of_sub_zsmul_mem_Ioc toIocDiv_eq_of_sub_zsmul_mem_Ioc def toIcoMod (a b : α) : α := b - toIcoDiv hp a b • p #align to_Ico_mod toIcoMod def toIocMod (a b : α) : α := b - toIocDiv hp a b • p #align to_Ioc_mod toIocMod theorem toIcoMod_mem_Ico (a b : α) : toIcoMod hp a b ∈ Set.Ico a (a + p) := sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_mod_mem_Ico toIcoMod_mem_Ico theorem toIcoMod_mem_Ico' (b : α) : toIcoMod hp 0 b ∈ Set.Ico 0 p := by convert toIcoMod_mem_Ico hp 0 b exact (zero_add p).symm #align to_Ico_mod_mem_Ico' toIcoMod_mem_Ico' theorem toIocMod_mem_Ioc (a b : α) : toIocMod hp a b ∈ Set.Ioc a (a + p) := sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_mod_mem_Ioc toIocMod_mem_Ioc theorem left_le_toIcoMod (a b : α) : a ≤ toIcoMod hp a b := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).1 #align left_le_to_Ico_mod left_le_toIcoMod theorem left_lt_toIocMod (a b : α) : a < toIocMod hp a b := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).1 #align left_lt_to_Ioc_mod left_lt_toIocMod theorem toIcoMod_lt_right (a b : α) : toIcoMod hp a b < a + p := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).2 #align to_Ico_mod_lt_right toIcoMod_lt_right theorem toIocMod_le_right (a b : α) : toIocMod hp a b ≤ a + p := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).2 #align to_Ioc_mod_le_right toIocMod_le_right @[simp] theorem self_sub_toIcoDiv_zsmul (a b : α) : b - toIcoDiv hp a b • p = toIcoMod hp a b := rfl #align self_sub_to_Ico_div_zsmul self_sub_toIcoDiv_zsmul @[simp] theorem self_sub_toIocDiv_zsmul (a b : α) : b - toIocDiv hp a b • p = toIocMod hp a b := rfl #align self_sub_to_Ioc_div_zsmul self_sub_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_self (a b : α) : toIcoDiv hp a b • p - b = -toIcoMod hp a b := by rw [toIcoMod, neg_sub] #align to_Ico_div_zsmul_sub_self toIcoDiv_zsmul_sub_self @[simp] theorem toIocDiv_zsmul_sub_self (a b : α) : toIocDiv hp a b • p - b = -toIocMod hp a b := by rw [toIocMod, neg_sub] #align to_Ioc_div_zsmul_sub_self toIocDiv_zsmul_sub_self @[simp] theorem toIcoMod_sub_self (a b : α) : toIcoMod hp a b - b = -toIcoDiv hp a b • p := by rw [toIcoMod, sub_sub_cancel_left, neg_smul] #align to_Ico_mod_sub_self toIcoMod_sub_self @[simp] theorem toIocMod_sub_self (a b : α) : toIocMod hp a b - b = -toIocDiv hp a b • p := by rw [toIocMod, sub_sub_cancel_left, neg_smul] #align to_Ioc_mod_sub_self toIocMod_sub_self @[simp] theorem self_sub_toIcoMod (a b : α) : b - toIcoMod hp a b = toIcoDiv hp a b • p := by rw [toIcoMod, sub_sub_cancel] #align self_sub_to_Ico_mod self_sub_toIcoMod @[simp] theorem self_sub_toIocMod (a b : α) : b - toIocMod hp a b = toIocDiv hp a b • p := by rw [toIocMod, sub_sub_cancel] #align self_sub_to_Ioc_mod self_sub_toIocMod @[simp] theorem toIcoMod_add_toIcoDiv_zsmul (a b : α) : toIcoMod hp a b + toIcoDiv hp a b • p = b := by rw [toIcoMod, sub_add_cancel] #align to_Ico_mod_add_to_Ico_div_zsmul toIcoMod_add_toIcoDiv_zsmul @[simp] theorem toIocMod_add_toIocDiv_zsmul (a b : α) : toIocMod hp a b + toIocDiv hp a b • p = b := by rw [toIocMod, sub_add_cancel] #align to_Ioc_mod_add_to_Ioc_div_zsmul toIocMod_add_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_toIcoMod (a b : α) : toIcoDiv hp a b • p + toIcoMod hp a b = b := by rw [add_comm, toIcoMod_add_toIcoDiv_zsmul] #align to_Ico_div_zsmul_sub_to_Ico_mod toIcoDiv_zsmul_sub_toIcoMod @[simp] theorem toIocDiv_zsmul_sub_toIocMod (a b : α) : toIocDiv hp a b • p + toIocMod hp a b = b := by rw [add_comm, toIocMod_add_toIocDiv_zsmul] #align to_Ioc_div_zsmul_sub_to_Ioc_mod toIocDiv_zsmul_sub_toIocMod theorem toIcoMod_eq_iff : toIcoMod hp a b = c ↔ c ∈ Set.Ico a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by refine ⟨fun h => ⟨h ▸ toIcoMod_mem_Ico hp a b, toIcoDiv hp a b, h ▸ (toIcoMod_add_toIcoDiv_zsmul _ _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIcoDiv_eq_of_sub_zsmul_mem_Ico hp hc, toIcoMod] #align to_Ico_mod_eq_iff toIcoMod_eq_iff theorem toIocMod_eq_iff : toIocMod hp a b = c ↔ c ∈ Set.Ioc a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by refine ⟨fun h => ⟨h ▸ toIocMod_mem_Ioc hp a b, toIocDiv hp a b, h ▸ (toIocMod_add_toIocDiv_zsmul hp _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIocDiv_eq_of_sub_zsmul_mem_Ioc hp hc, toIocMod] #align to_Ioc_mod_eq_iff toIocMod_eq_iff @[simp] theorem toIcoDiv_apply_left (a : α) : toIcoDiv hp a a = 0 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_left toIcoDiv_apply_left @[simp] theorem toIocDiv_apply_left (a : α) : toIocDiv hp a a = -1 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_left toIocDiv_apply_left @[simp] theorem toIcoMod_apply_left (a : α) : toIcoMod hp a a = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ico_mod_apply_left toIcoMod_apply_left @[simp] theorem toIocMod_apply_left (a : α) : toIocMod hp a a = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, -1, by simp⟩ #align to_Ioc_mod_apply_left toIocMod_apply_left theorem toIcoDiv_apply_right (a : α) : toIcoDiv hp a (a + p) = 1 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_right toIcoDiv_apply_right theorem toIocDiv_apply_right (a : α) : toIocDiv hp a (a + p) = 0 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_right toIocDiv_apply_right theorem toIcoMod_apply_right (a : α) : toIcoMod hp a (a + p) = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 1, by simp⟩ #align to_Ico_mod_apply_right toIcoMod_apply_right theorem toIocMod_apply_right (a : α) : toIocMod hp a (a + p) = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ioc_mod_apply_right toIocMod_apply_right @[simp] theorem toIcoDiv_add_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b + m • p) = toIcoDiv hp a b + m := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul toIcoDiv_add_zsmul @[simp] theorem toIcoDiv_add_zsmul' (a b : α) (m : ℤ) : toIcoDiv hp (a + m • p) b = toIcoDiv hp a b - m := by refine toIcoDiv_eq_of_sub_zsmul_mem_Ico _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul' toIcoDiv_add_zsmul' @[simp] theorem toIocDiv_add_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b + m • p) = toIocDiv hp a b + m := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul toIocDiv_add_zsmul @[simp] theorem toIocDiv_add_zsmul' (a b : α) (m : ℤ) : toIocDiv hp (a + m • p) b = toIocDiv hp a b - m := by refine toIocDiv_eq_of_sub_zsmul_mem_Ioc _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul' toIocDiv_add_zsmul' @[simp] theorem toIcoDiv_zsmul_add (a b : α) (m : ℤ) : toIcoDiv hp a (m • p + b) = m + toIcoDiv hp a b := by rw [add_comm, toIcoDiv_add_zsmul, add_comm] #align to_Ico_div_zsmul_add toIcoDiv_zsmul_add @[simp] theorem toIocDiv_zsmul_add (a b : α) (m : ℤ) : toIocDiv hp a (m • p + b) = m + toIocDiv hp a b := by rw [add_comm, toIocDiv_add_zsmul, add_comm] #align to_Ioc_div_zsmul_add toIocDiv_zsmul_add @[simp] theorem toIcoDiv_sub_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b - m • p) = toIcoDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul, sub_eq_add_neg] #align to_Ico_div_sub_zsmul toIcoDiv_sub_zsmul @[simp] theorem toIcoDiv_sub_zsmul' (a b : α) (m : ℤ) : toIcoDiv hp (a - m • p) b = toIcoDiv hp a b + m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul', sub_neg_eq_add] #align to_Ico_div_sub_zsmul' toIcoDiv_sub_zsmul' @[simp] theorem toIocDiv_sub_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b - m • p) = toIocDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul, sub_eq_add_neg] #align to_Ioc_div_sub_zsmul toIocDiv_sub_zsmul @[simp] theorem toIocDiv_sub_zsmul' (a b : α) (m : ℤ) : toIocDiv hp (a - m • p) b = toIocDiv hp a b + m := by rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul', sub_neg_eq_add] #align to_Ioc_div_sub_zsmul' toIocDiv_sub_zsmul' @[simp] theorem toIcoDiv_add_right (a b : α) : toIcoDiv hp a (b + p) = toIcoDiv hp a b + 1 := by simpa only [one_zsmul] using toIcoDiv_add_zsmul hp a b 1 #align to_Ico_div_add_right toIcoDiv_add_right @[simp] theorem toIcoDiv_add_right' (a b : α) : toIcoDiv hp (a + p) b = toIcoDiv hp a b - 1 := by simpa only [one_zsmul] using toIcoDiv_add_zsmul' hp a b 1 #align to_Ico_div_add_right' toIcoDiv_add_right' @[simp] theorem toIocDiv_add_right (a b : α) : toIocDiv hp a (b + p) = toIocDiv hp a b + 1 := by simpa only [one_zsmul] using toIocDiv_add_zsmul hp a b 1 #align to_Ioc_div_add_right toIocDiv_add_right @[simp] theorem toIocDiv_add_right' (a b : α) : toIocDiv hp (a + p) b = toIocDiv hp a b - 1 := by simpa only [one_zsmul] using toIocDiv_add_zsmul' hp a b 1 #align to_Ioc_div_add_right' toIocDiv_add_right' @[simp] theorem toIcoDiv_add_left (a b : α) : toIcoDiv hp a (p + b) = toIcoDiv hp a b + 1 := by rw [add_comm, toIcoDiv_add_right] #align to_Ico_div_add_left toIcoDiv_add_left @[simp] theorem toIcoDiv_add_left' (a b : α) : toIcoDiv hp (p + a) b = toIcoDiv hp a b - 1 := by rw [add_comm, toIcoDiv_add_right'] #align to_Ico_div_add_left' toIcoDiv_add_left' @[simp] theorem toIocDiv_add_left (a b : α) : toIocDiv hp a (p + b) = toIocDiv hp a b + 1 := by rw [add_comm, toIocDiv_add_right] #align to_Ioc_div_add_left toIocDiv_add_left @[simp] theorem toIocDiv_add_left' (a b : α) : toIocDiv hp (p + a) b = toIocDiv hp a b - 1 := by rw [add_comm, toIocDiv_add_right'] #align to_Ioc_div_add_left' toIocDiv_add_left' @[simp] theorem toIcoDiv_sub (a b : α) : toIcoDiv hp a (b - p) = toIcoDiv hp a b - 1 := by simpa only [one_zsmul] using toIcoDiv_sub_zsmul hp a b 1 #align to_Ico_div_sub toIcoDiv_sub @[simp] theorem toIcoDiv_sub' (a b : α) : toIcoDiv hp (a - p) b = toIcoDiv hp a b + 1 := by simpa only [one_zsmul] using toIcoDiv_sub_zsmul' hp a b 1 #align to_Ico_div_sub' toIcoDiv_sub' @[simp]
Mathlib/Algebra/Order/ToIntervalMod.lean
349
350
theorem toIocDiv_sub (a b : α) : toIocDiv hp a (b - p) = toIocDiv hp a b - 1 := by
simpa only [one_zsmul] using toIocDiv_sub_zsmul hp a b 1
import Mathlib.MeasureTheory.Constructions.Prod.Basic import Mathlib.MeasureTheory.Integral.DominatedConvergence import Mathlib.MeasureTheory.Integral.SetIntegral #align_import measure_theory.constructions.prod.integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" noncomputable section open scoped Classical Topology ENNReal MeasureTheory open Set Function Real ENNReal open MeasureTheory MeasurableSpace MeasureTheory.Measure open TopologicalSpace open Filter hiding prod_eq map variable {α α' β β' γ E : Type*} variable [MeasurableSpace α] [MeasurableSpace α'] [MeasurableSpace β] [MeasurableSpace β'] variable [MeasurableSpace γ] variable {μ μ' : Measure α} {ν ν' : Measure β} {τ : Measure γ} variable [NormedAddCommGroup E] theorem measurableSet_integrable [SigmaFinite ν] ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) : MeasurableSet {x | Integrable (f x) ν} := by simp_rw [Integrable, hf.of_uncurry_left.aestronglyMeasurable, true_and_iff] exact measurableSet_lt (Measurable.lintegral_prod_right hf.ennnorm) measurable_const #align measurable_set_integrable measurableSet_integrable section variable [NormedSpace ℝ E] theorem MeasureTheory.StronglyMeasurable.integral_prod_right [SigmaFinite ν] ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun x => ∫ y, f x y ∂ν := by by_cases hE : CompleteSpace E; swap; · simp [integral, hE, stronglyMeasurable_const] borelize E haveI : SeparableSpace (range (uncurry f) ∪ {0} : Set E) := hf.separableSpace_range_union_singleton let s : ℕ → SimpleFunc (α × β) E := SimpleFunc.approxOn _ hf.measurable (range (uncurry f) ∪ {0}) 0 (by simp) let s' : ℕ → α → SimpleFunc β E := fun n x => (s n).comp (Prod.mk x) measurable_prod_mk_left let f' : ℕ → α → E := fun n => {x | Integrable (f x) ν}.indicator fun x => (s' n x).integral ν have hf' : ∀ n, StronglyMeasurable (f' n) := by intro n; refine StronglyMeasurable.indicator ?_ (measurableSet_integrable hf) have : ∀ x, ((s' n x).range.filter fun x => x ≠ 0) ⊆ (s n).range := by intro x; refine Finset.Subset.trans (Finset.filter_subset _ _) ?_; intro y simp_rw [SimpleFunc.mem_range]; rintro ⟨z, rfl⟩; exact ⟨(x, z), rfl⟩ simp only [SimpleFunc.integral_eq_sum_of_subset (this _)] refine Finset.stronglyMeasurable_sum _ fun x _ => ?_ refine (Measurable.ennreal_toReal ?_).stronglyMeasurable.smul_const _ simp only [s', SimpleFunc.coe_comp, preimage_comp] apply measurable_measure_prod_mk_left exact (s n).measurableSet_fiber x have h2f' : Tendsto f' atTop (𝓝 fun x : α => ∫ y : β, f x y ∂ν) := by rw [tendsto_pi_nhds]; intro x by_cases hfx : Integrable (f x) ν · have (n) : Integrable (s' n x) ν := by apply (hfx.norm.add hfx.norm).mono' (s' n x).aestronglyMeasurable filter_upwards with y simp_rw [s', SimpleFunc.coe_comp]; exact SimpleFunc.norm_approxOn_zero_le _ _ (x, y) n simp only [f', hfx, SimpleFunc.integral_eq_integral _ (this _), indicator_of_mem, mem_setOf_eq] refine tendsto_integral_of_dominated_convergence (fun y => ‖f x y‖ + ‖f x y‖) (fun n => (s' n x).aestronglyMeasurable) (hfx.norm.add hfx.norm) ?_ ?_ · refine fun n => eventually_of_forall fun y => SimpleFunc.norm_approxOn_zero_le ?_ ?_ (x, y) n -- Porting note: Lean 3 solved the following two subgoals on its own · exact hf.measurable · simp · refine eventually_of_forall fun y => SimpleFunc.tendsto_approxOn ?_ ?_ ?_ -- Porting note: Lean 3 solved the following two subgoals on its own · exact hf.measurable.of_uncurry_left · simp apply subset_closure simp [-uncurry_apply_pair] · simp [f', hfx, integral_undef] exact stronglyMeasurable_of_tendsto _ hf' h2f' #align measure_theory.strongly_measurable.integral_prod_right MeasureTheory.StronglyMeasurable.integral_prod_right theorem MeasureTheory.StronglyMeasurable.integral_prod_right' [SigmaFinite ν] ⦃f : α × β → E⦄ (hf : StronglyMeasurable f) : StronglyMeasurable fun x => ∫ y, f (x, y) ∂ν := by rw [← uncurry_curry f] at hf; exact hf.integral_prod_right #align measure_theory.strongly_measurable.integral_prod_right' MeasureTheory.StronglyMeasurable.integral_prod_right' theorem MeasureTheory.StronglyMeasurable.integral_prod_left [SigmaFinite μ] ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun y => ∫ x, f x y ∂μ := (hf.comp_measurable measurable_swap).integral_prod_right' #align measure_theory.strongly_measurable.integral_prod_left MeasureTheory.StronglyMeasurable.integral_prod_left theorem MeasureTheory.StronglyMeasurable.integral_prod_left' [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : StronglyMeasurable f) : StronglyMeasurable fun y => ∫ x, f (x, y) ∂μ := (hf.comp_measurable measurable_swap).integral_prod_right' #align measure_theory.strongly_measurable.integral_prod_left' MeasureTheory.StronglyMeasurable.integral_prod_left' end open MeasureTheory.Measure section nonrec theorem MeasureTheory.AEStronglyMeasurable.prod_swap {γ : Type*} [TopologicalSpace γ] [SigmaFinite μ] [SigmaFinite ν] {f : β × α → γ} (hf : AEStronglyMeasurable f (ν.prod μ)) : AEStronglyMeasurable (fun z : α × β => f z.swap) (μ.prod ν) := by rw [← prod_swap] at hf exact hf.comp_measurable measurable_swap #align measure_theory.ae_strongly_measurable.prod_swap MeasureTheory.AEStronglyMeasurable.prod_swap theorem MeasureTheory.AEStronglyMeasurable.fst {γ} [TopologicalSpace γ] [SigmaFinite ν] {f : α → γ} (hf : AEStronglyMeasurable f μ) : AEStronglyMeasurable (fun z : α × β => f z.1) (μ.prod ν) := hf.comp_quasiMeasurePreserving quasiMeasurePreserving_fst #align measure_theory.ae_strongly_measurable.fst MeasureTheory.AEStronglyMeasurable.fst theorem MeasureTheory.AEStronglyMeasurable.snd {γ} [TopologicalSpace γ] [SigmaFinite ν] {f : β → γ} (hf : AEStronglyMeasurable f ν) : AEStronglyMeasurable (fun z : α × β => f z.2) (μ.prod ν) := hf.comp_quasiMeasurePreserving quasiMeasurePreserving_snd #align measure_theory.ae_strongly_measurable.snd MeasureTheory.AEStronglyMeasurable.snd theorem MeasureTheory.AEStronglyMeasurable.integral_prod_right' [SigmaFinite ν] [NormedSpace ℝ E] ⦃f : α × β → E⦄ (hf : AEStronglyMeasurable f (μ.prod ν)) : AEStronglyMeasurable (fun x => ∫ y, f (x, y) ∂ν) μ := ⟨fun x => ∫ y, hf.mk f (x, y) ∂ν, hf.stronglyMeasurable_mk.integral_prod_right', by filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with _ hx using integral_congr_ae hx⟩ #align measure_theory.ae_strongly_measurable.integral_prod_right' MeasureTheory.AEStronglyMeasurable.integral_prod_right' theorem MeasureTheory.AEStronglyMeasurable.prod_mk_left {γ : Type*} [SigmaFinite ν] [TopologicalSpace γ] {f : α × β → γ} (hf : AEStronglyMeasurable f (μ.prod ν)) : ∀ᵐ x ∂μ, AEStronglyMeasurable (fun y => f (x, y)) ν := by filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with x hx exact ⟨fun y => hf.mk f (x, y), hf.stronglyMeasurable_mk.comp_measurable measurable_prod_mk_left, hx⟩ #align measure_theory.ae_strongly_measurable.prod_mk_left MeasureTheory.AEStronglyMeasurable.prod_mk_left end namespace MeasureTheory variable [SigmaFinite ν] section theorem integrable_swap_iff [SigmaFinite μ] {f : α × β → E} : Integrable (f ∘ Prod.swap) (ν.prod μ) ↔ Integrable f (μ.prod ν) := measurePreserving_swap.integrable_comp_emb MeasurableEquiv.prodComm.measurableEmbedding #align measure_theory.integrable_swap_iff MeasureTheory.integrable_swap_iff theorem Integrable.swap [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : Integrable (f ∘ Prod.swap) (ν.prod μ) := integrable_swap_iff.2 hf #align measure_theory.integrable.swap MeasureTheory.Integrable.swap theorem hasFiniteIntegral_prod_iff ⦃f : α × β → E⦄ (h1f : StronglyMeasurable f) : HasFiniteIntegral f (μ.prod ν) ↔ (∀ᵐ x ∂μ, HasFiniteIntegral (fun y => f (x, y)) ν) ∧ HasFiniteIntegral (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ := by simp only [HasFiniteIntegral, lintegral_prod_of_measurable _ h1f.ennnorm] have (x) : ∀ᵐ y ∂ν, 0 ≤ ‖f (x, y)‖ := by filter_upwards with y using norm_nonneg _ simp_rw [integral_eq_lintegral_of_nonneg_ae (this _) (h1f.norm.comp_measurable measurable_prod_mk_left).aestronglyMeasurable, ennnorm_eq_ofReal toReal_nonneg, ofReal_norm_eq_coe_nnnorm] -- this fact is probably too specialized to be its own lemma have : ∀ {p q r : Prop} (_ : r → p), (r ↔ p ∧ q) ↔ p → (r ↔ q) := fun {p q r} h1 => by rw [← and_congr_right_iff, and_iff_right_of_imp h1] rw [this] · intro h2f; rw [lintegral_congr_ae] filter_upwards [h2f] with x hx rw [ofReal_toReal]; rw [← lt_top_iff_ne_top]; exact hx · intro h2f; refine ae_lt_top ?_ h2f.ne; exact h1f.ennnorm.lintegral_prod_right' #align measure_theory.has_finite_integral_prod_iff MeasureTheory.hasFiniteIntegral_prod_iff theorem hasFiniteIntegral_prod_iff' ⦃f : α × β → E⦄ (h1f : AEStronglyMeasurable f (μ.prod ν)) : HasFiniteIntegral f (μ.prod ν) ↔ (∀ᵐ x ∂μ, HasFiniteIntegral (fun y => f (x, y)) ν) ∧ HasFiniteIntegral (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ := by rw [hasFiniteIntegral_congr h1f.ae_eq_mk, hasFiniteIntegral_prod_iff h1f.stronglyMeasurable_mk] apply and_congr · apply eventually_congr filter_upwards [ae_ae_of_ae_prod h1f.ae_eq_mk.symm] intro x hx exact hasFiniteIntegral_congr hx · apply hasFiniteIntegral_congr filter_upwards [ae_ae_of_ae_prod h1f.ae_eq_mk.symm] with _ hx using integral_congr_ae (EventuallyEq.fun_comp hx _) #align measure_theory.has_finite_integral_prod_iff' MeasureTheory.hasFiniteIntegral_prod_iff' theorem integrable_prod_iff ⦃f : α × β → E⦄ (h1f : AEStronglyMeasurable f (μ.prod ν)) : Integrable f (μ.prod ν) ↔ (∀ᵐ x ∂μ, Integrable (fun y => f (x, y)) ν) ∧ Integrable (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ := by simp [Integrable, h1f, hasFiniteIntegral_prod_iff', h1f.norm.integral_prod_right', h1f.prod_mk_left] #align measure_theory.integrable_prod_iff MeasureTheory.integrable_prod_iff
Mathlib/MeasureTheory/Constructions/Prod/Integral.lean
280
285
theorem integrable_prod_iff' [SigmaFinite μ] ⦃f : α × β → E⦄ (h1f : AEStronglyMeasurable f (μ.prod ν)) : Integrable f (μ.prod ν) ↔ (∀ᵐ y ∂ν, Integrable (fun x => f (x, y)) μ) ∧ Integrable (fun y => ∫ x, ‖f (x, y)‖ ∂μ) ν := by
convert integrable_prod_iff h1f.prod_swap using 1 rw [funext fun _ => Function.comp_apply.symm, integrable_swap_iff]
import Mathlib.RingTheory.IntegralClosure import Mathlib.RingTheory.FractionalIdeal.Basic #align_import ring_theory.fractional_ideal from "leanprover-community/mathlib"@"ed90a7d327c3a5caf65a6faf7e8a0d63c4605df7" open IsLocalization Pointwise nonZeroDivisors namespace FractionalIdeal open Set Submodule variable {R : Type*} [CommRing R] {S : Submonoid R} {P : Type*} [CommRing P] variable [Algebra R P] [loc : IsLocalization S P] section variable {P' : Type*} [CommRing P'] [Algebra R P'] [loc' : IsLocalization S P'] variable {P'' : Type*} [CommRing P''] [Algebra R P''] [loc'' : IsLocalization S P''] theorem _root_.IsFractional.map (g : P →ₐ[R] P') {I : Submodule R P} : IsFractional S I → IsFractional S (Submodule.map g.toLinearMap I) | ⟨a, a_nonzero, hI⟩ => ⟨a, a_nonzero, fun b hb => by obtain ⟨b', b'_mem, hb'⟩ := Submodule.mem_map.mp hb rw [AlgHom.toLinearMap_apply] at hb' obtain ⟨x, hx⟩ := hI b' b'_mem use x rw [← g.commutes, hx, g.map_smul, hb']⟩ #align is_fractional.map IsFractional.map def map (g : P →ₐ[R] P') : FractionalIdeal S P → FractionalIdeal S P' := fun I => ⟨Submodule.map g.toLinearMap I, I.isFractional.map g⟩ #align fractional_ideal.map FractionalIdeal.map @[simp, norm_cast] theorem coe_map (g : P →ₐ[R] P') (I : FractionalIdeal S P) : ↑(map g I) = Submodule.map g.toLinearMap I := rfl #align fractional_ideal.coe_map FractionalIdeal.coe_map @[simp] theorem mem_map {I : FractionalIdeal S P} {g : P →ₐ[R] P'} {y : P'} : y ∈ I.map g ↔ ∃ x, x ∈ I ∧ g x = y := Submodule.mem_map #align fractional_ideal.mem_map FractionalIdeal.mem_map variable (I J : FractionalIdeal S P) (g : P →ₐ[R] P') @[simp] theorem map_id : I.map (AlgHom.id _ _) = I := coeToSubmodule_injective (Submodule.map_id (I : Submodule R P)) #align fractional_ideal.map_id FractionalIdeal.map_id @[simp] theorem map_comp (g' : P' →ₐ[R] P'') : I.map (g'.comp g) = (I.map g).map g' := coeToSubmodule_injective (Submodule.map_comp g.toLinearMap g'.toLinearMap I) #align fractional_ideal.map_comp FractionalIdeal.map_comp @[simp, norm_cast] theorem map_coeIdeal (I : Ideal R) : (I : FractionalIdeal S P).map g = I := by ext x simp only [mem_coeIdeal] constructor · rintro ⟨_, ⟨y, hy, rfl⟩, rfl⟩ exact ⟨y, hy, (g.commutes y).symm⟩ · rintro ⟨y, hy, rfl⟩ exact ⟨_, ⟨y, hy, rfl⟩, g.commutes y⟩ #align fractional_ideal.map_coe_ideal FractionalIdeal.map_coeIdeal @[simp] theorem map_one : (1 : FractionalIdeal S P).map g = 1 := map_coeIdeal g ⊤ #align fractional_ideal.map_one FractionalIdeal.map_one @[simp] theorem map_zero : (0 : FractionalIdeal S P).map g = 0 := map_coeIdeal g 0 #align fractional_ideal.map_zero FractionalIdeal.map_zero @[simp] theorem map_add : (I + J).map g = I.map g + J.map g := coeToSubmodule_injective (Submodule.map_sup _ _ _) #align fractional_ideal.map_add FractionalIdeal.map_add @[simp] theorem map_mul : (I * J).map g = I.map g * J.map g := by simp only [mul_def] exact coeToSubmodule_injective (Submodule.map_mul _ _ _) #align fractional_ideal.map_mul FractionalIdeal.map_mul @[simp] theorem map_map_symm (g : P ≃ₐ[R] P') : (I.map (g : P →ₐ[R] P')).map (g.symm : P' →ₐ[R] P) = I := by rw [← map_comp, g.symm_comp, map_id] #align fractional_ideal.map_map_symm FractionalIdeal.map_map_symm @[simp]
Mathlib/RingTheory/FractionalIdeal/Operations.lean
128
130
theorem map_symm_map (I : FractionalIdeal S P') (g : P ≃ₐ[R] P') : (I.map (g.symm : P' →ₐ[R] P)).map (g : P →ₐ[R] P') = I := by
rw [← map_comp, g.comp_symm, map_id]
import Mathlib.RingTheory.Localization.FractionRing import Mathlib.Algebra.Polynomial.RingDivision #align_import field_theory.ratfunc from "leanprover-community/mathlib"@"bf9bbbcf0c1c1ead18280b0d010e417b10abb1b6" noncomputable section open scoped Classical open scoped nonZeroDivisors Polynomial universe u v variable (K : Type u) structure RatFunc [CommRing K] : Type u where ofFractionRing :: toFractionRing : FractionRing K[X] #align ratfunc RatFunc #align ratfunc.of_fraction_ring RatFunc.ofFractionRing #align ratfunc.to_fraction_ring RatFunc.toFractionRing namespace RatFunc section CommRing variable {K} variable [CommRing K] section Rec theorem ofFractionRing_injective : Function.Injective (ofFractionRing : _ → RatFunc K) := fun _ _ => ofFractionRing.inj #align ratfunc.of_fraction_ring_injective RatFunc.ofFractionRing_injective theorem toFractionRing_injective : Function.Injective (toFractionRing : _ → FractionRing K[X]) -- Porting note: the `xy` input was `rfl` and then there was no need for the `subst` | ⟨x⟩, ⟨y⟩, xy => by subst xy; rfl #align ratfunc.to_fraction_ring_injective RatFunc.toFractionRing_injective protected irreducible_def liftOn {P : Sort v} (x : RatFunc K) (f : K[X] → K[X] → P) (H : ∀ {p q p' q'} (_hq : q ∈ K[X]⁰) (_hq' : q' ∈ K[X]⁰), q' * p = q * p' → f p q = f p' q') : P := by refine Localization.liftOn (toFractionRing x) (fun p q => f p q) ?_ intros p p' q q' h exact H q.2 q'.2 (let ⟨⟨c, hc⟩, mul_eq⟩ := Localization.r_iff_exists.mp h mul_cancel_left_coe_nonZeroDivisors.mp mul_eq) -- Porting note: the definition above was as follows -- (-- Fix timeout by manipulating elaboration order -- fun p q => f p q) -- fun p p' q q' h => by -- exact H q.2 q'.2 -- (let ⟨⟨c, hc⟩, mul_eq⟩ := Localization.r_iff_exists.mp h -- mul_cancel_left_coe_nonZeroDivisors.mp mul_eq) #align ratfunc.lift_on RatFunc.liftOn theorem liftOn_ofFractionRing_mk {P : Sort v} (n : K[X]) (d : K[X]⁰) (f : K[X] → K[X] → P) (H : ∀ {p q p' q'} (_hq : q ∈ K[X]⁰) (_hq' : q' ∈ K[X]⁰), q' * p = q * p' → f p q = f p' q') : RatFunc.liftOn (ofFractionRing (Localization.mk n d)) f @H = f n d := by rw [RatFunc.liftOn] exact Localization.liftOn_mk _ _ _ _ #align ratfunc.lift_on_of_fraction_ring_mk RatFunc.liftOn_ofFractionRing_mk theorem liftOn_condition_of_liftOn'_condition {P : Sort v} {f : K[X] → K[X] → P} (H : ∀ {p q a} (hq : q ≠ 0) (_ha : a ≠ 0), f (a * p) (a * q) = f p q) ⦃p q p' q' : K[X]⦄ (hq : q ≠ 0) (hq' : q' ≠ 0) (h : q' * p = q * p') : f p q = f p' q' := calc f p q = f (q' * p) (q' * q) := (H hq hq').symm _ = f (q * p') (q * q') := by rw [h, mul_comm q'] _ = f p' q' := H hq' hq #align ratfunc.lift_on_condition_of_lift_on'_condition RatFunc.liftOn_condition_of_liftOn'_condition section IsDomain variable [IsDomain K] protected irreducible_def mk (p q : K[X]) : RatFunc K := ofFractionRing (algebraMap _ _ p / algebraMap _ _ q) #align ratfunc.mk RatFunc.mk theorem mk_eq_div' (p q : K[X]) : RatFunc.mk p q = ofFractionRing (algebraMap _ _ p / algebraMap _ _ q) := by rw [RatFunc.mk] #align ratfunc.mk_eq_div' RatFunc.mk_eq_div' theorem mk_zero (p : K[X]) : RatFunc.mk p 0 = ofFractionRing (0 : FractionRing K[X]) := by rw [mk_eq_div', RingHom.map_zero, div_zero] #align ratfunc.mk_zero RatFunc.mk_zero theorem mk_coe_def (p : K[X]) (q : K[X]⁰) : -- Porting note: filled in `(FractionRing K[X])` that was an underscore. RatFunc.mk p q = ofFractionRing (IsLocalization.mk' (FractionRing K[X]) p q) := by simp only [mk_eq_div', ← Localization.mk_eq_mk', FractionRing.mk_eq_div] #align ratfunc.mk_coe_def RatFunc.mk_coe_def theorem mk_def_of_mem (p : K[X]) {q} (hq : q ∈ K[X]⁰) : RatFunc.mk p q = ofFractionRing (IsLocalization.mk' (FractionRing K[X]) p ⟨q, hq⟩) := by -- Porting note: there was an `[anonymous]` in the simp set simp only [← mk_coe_def] #align ratfunc.mk_def_of_mem RatFunc.mk_def_of_mem theorem mk_def_of_ne (p : K[X]) {q : K[X]} (hq : q ≠ 0) : RatFunc.mk p q = ofFractionRing (IsLocalization.mk' (FractionRing K[X]) p ⟨q, mem_nonZeroDivisors_iff_ne_zero.mpr hq⟩) := mk_def_of_mem p _ #align ratfunc.mk_def_of_ne RatFunc.mk_def_of_ne
Mathlib/FieldTheory/RatFunc/Defs.lean
181
185
theorem mk_eq_localization_mk (p : K[X]) {q : K[X]} (hq : q ≠ 0) : RatFunc.mk p q = ofFractionRing (Localization.mk p ⟨q, mem_nonZeroDivisors_iff_ne_zero.mpr hq⟩) := by
-- Porting note: the original proof, did not need to pass `hq` rw [mk_def_of_ne _ hq, Localization.mk_eq_mk']
import Mathlib.Analysis.Calculus.FDeriv.Analytic import Mathlib.Analysis.Asymptotics.SpecificAsymptotics import Mathlib.Analysis.Complex.CauchyIntegral #align_import analysis.complex.removable_singularity from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open TopologicalSpace Metric Set Filter Asymptotics Function open scoped Topology Filter NNReal Real universe u variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℂ E] [CompleteSpace E] namespace Complex theorem analyticAt_of_differentiable_on_punctured_nhds_of_continuousAt {f : ℂ → E} {c : ℂ} (hd : ∀ᶠ z in 𝓝[≠] c, DifferentiableAt ℂ f z) (hc : ContinuousAt f c) : AnalyticAt ℂ f c := by rcases (nhdsWithin_hasBasis nhds_basis_closedBall _).mem_iff.1 hd with ⟨R, hR0, hRs⟩ lift R to ℝ≥0 using hR0.le replace hc : ContinuousOn f (closedBall c R) := by refine fun z hz => ContinuousAt.continuousWithinAt ?_ rcases eq_or_ne z c with (rfl | hne) exacts [hc, (hRs ⟨hz, hne⟩).continuousAt] exact (hasFPowerSeriesOnBall_of_differentiable_off_countable (countable_singleton c) hc (fun z hz => hRs (diff_subset_diff_left ball_subset_closedBall hz)) hR0).analyticAt #align complex.analytic_at_of_differentiable_on_punctured_nhds_of_continuous_at Complex.analyticAt_of_differentiable_on_punctured_nhds_of_continuousAt theorem differentiableOn_compl_singleton_and_continuousAt_iff {f : ℂ → E} {s : Set ℂ} {c : ℂ} (hs : s ∈ 𝓝 c) : DifferentiableOn ℂ f (s \ {c}) ∧ ContinuousAt f c ↔ DifferentiableOn ℂ f s := by refine ⟨?_, fun hd => ⟨hd.mono diff_subset, (hd.differentiableAt hs).continuousAt⟩⟩ rintro ⟨hd, hc⟩ x hx rcases eq_or_ne x c with (rfl | hne) · refine (analyticAt_of_differentiable_on_punctured_nhds_of_continuousAt ?_ hc).differentiableAt.differentiableWithinAt refine eventually_nhdsWithin_iff.2 ((eventually_mem_nhds.2 hs).mono fun z hz hzx => ?_) exact hd.differentiableAt (inter_mem hz (isOpen_ne.mem_nhds hzx)) · simpa only [DifferentiableWithinAt, HasFDerivWithinAt, hne.nhdsWithin_diff_singleton] using hd x ⟨hx, hne⟩ #align complex.differentiable_on_compl_singleton_and_continuous_at_iff Complex.differentiableOn_compl_singleton_and_continuousAt_iff theorem differentiableOn_dslope {f : ℂ → E} {s : Set ℂ} {c : ℂ} (hc : s ∈ 𝓝 c) : DifferentiableOn ℂ (dslope f c) s ↔ DifferentiableOn ℂ f s := ⟨fun h => h.of_dslope, fun h => (differentiableOn_compl_singleton_and_continuousAt_iff hc).mp <| ⟨Iff.mpr (differentiableOn_dslope_of_nmem fun h => h.2 rfl) (h.mono diff_subset), continuousAt_dslope_same.2 <| h.differentiableAt hc⟩⟩ #align complex.differentiable_on_dslope Complex.differentiableOn_dslope theorem differentiableOn_update_limUnder_of_isLittleO {f : ℂ → E} {s : Set ℂ} {c : ℂ} (hc : s ∈ 𝓝 c) (hd : DifferentiableOn ℂ f (s \ {c})) (ho : (fun z => f z - f c) =o[𝓝[≠] c] fun z => (z - c)⁻¹) : DifferentiableOn ℂ (update f c (limUnder (𝓝[≠] c) f)) s := by set F : ℂ → E := fun z => (z - c) • f z suffices DifferentiableOn ℂ F (s \ {c}) ∧ ContinuousAt F c by rw [differentiableOn_compl_singleton_and_continuousAt_iff hc, ← differentiableOn_dslope hc, dslope_sub_smul] at this have hc : Tendsto f (𝓝[≠] c) (𝓝 (deriv F c)) := continuousAt_update_same.mp (this.continuousOn.continuousAt hc) rwa [hc.limUnder_eq] refine ⟨(differentiableOn_id.sub_const _).smul hd, ?_⟩ rw [← continuousWithinAt_compl_self] have H := ho.tendsto_inv_smul_nhds_zero have H' : Tendsto (fun z => (z - c) • f c) (𝓝[≠] c) (𝓝 (F c)) := (continuousWithinAt_id.tendsto.sub tendsto_const_nhds).smul tendsto_const_nhds simpa [← smul_add, ContinuousWithinAt] using H.add H' #align complex.differentiable_on_update_lim_of_is_o Complex.differentiableOn_update_limUnder_of_isLittleO theorem differentiableOn_update_limUnder_insert_of_isLittleO {f : ℂ → E} {s : Set ℂ} {c : ℂ} (hc : s ∈ 𝓝[≠] c) (hd : DifferentiableOn ℂ f s) (ho : (fun z => f z - f c) =o[𝓝[≠] c] fun z => (z - c)⁻¹) : DifferentiableOn ℂ (update f c (limUnder (𝓝[≠] c) f)) (insert c s) := differentiableOn_update_limUnder_of_isLittleO (insert_mem_nhds_iff.2 hc) (hd.mono fun _ hz => hz.1.resolve_left hz.2) ho #align complex.differentiable_on_update_lim_insert_of_is_o Complex.differentiableOn_update_limUnder_insert_of_isLittleO theorem differentiableOn_update_limUnder_of_bddAbove {f : ℂ → E} {s : Set ℂ} {c : ℂ} (hc : s ∈ 𝓝 c) (hd : DifferentiableOn ℂ f (s \ {c})) (hb : BddAbove (norm ∘ f '' (s \ {c}))) : DifferentiableOn ℂ (update f c (limUnder (𝓝[≠] c) f)) s := differentiableOn_update_limUnder_of_isLittleO hc hd <| IsBoundedUnder.isLittleO_sub_self_inv <| let ⟨C, hC⟩ := hb ⟨C + ‖f c‖, eventually_map.2 <| mem_nhdsWithin_iff_exists_mem_nhds_inter.2 ⟨s, hc, fun _ hz => norm_sub_le_of_le (hC <| mem_image_of_mem _ hz) le_rfl⟩⟩ #align complex.differentiable_on_update_lim_of_bdd_above Complex.differentiableOn_update_limUnder_of_bddAbove
Mathlib/Analysis/Complex/RemovableSingularity.lean
115
123
theorem tendsto_limUnder_of_differentiable_on_punctured_nhds_of_isLittleO {f : ℂ → E} {c : ℂ} (hd : ∀ᶠ z in 𝓝[≠] c, DifferentiableAt ℂ f z) (ho : (fun z => f z - f c) =o[𝓝[≠] c] fun z => (z - c)⁻¹) : Tendsto f (𝓝[≠] c) (𝓝 <| limUnder (𝓝[≠] c) f) := by
rw [eventually_nhdsWithin_iff] at hd have : DifferentiableOn ℂ f ({z | z ≠ c → DifferentiableAt ℂ f z} \ {c}) := fun z hz => (hz.1 hz.2).differentiableWithinAt have H := differentiableOn_update_limUnder_of_isLittleO hd this ho exact continuousAt_update_same.1 (H.differentiableAt hd).continuousAt
import Mathlib.Analysis.InnerProductSpace.Projection import Mathlib.Geometry.Euclidean.PerpBisector import Mathlib.Algebra.QuadraticDiscriminant #align_import geometry.euclidean.basic from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0" noncomputable section open scoped Classical open RealInnerProductSpace namespace EuclideanGeometry variable {V : Type*} {P : Type*} variable [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] variable [NormedAddTorsor V P] theorem dist_left_midpoint_eq_dist_right_midpoint (p1 p2 : P) : dist p1 (midpoint ℝ p1 p2) = dist p2 (midpoint ℝ p1 p2) := by rw [dist_left_midpoint (𝕜 := ℝ) p1 p2, dist_right_midpoint (𝕜 := ℝ) p1 p2] #align euclidean_geometry.dist_left_midpoint_eq_dist_right_midpoint EuclideanGeometry.dist_left_midpoint_eq_dist_right_midpoint theorem inner_weightedVSub {ι₁ : Type*} {s₁ : Finset ι₁} {w₁ : ι₁ → ℝ} (p₁ : ι₁ → P) (h₁ : ∑ i ∈ s₁, w₁ i = 0) {ι₂ : Type*} {s₂ : Finset ι₂} {w₂ : ι₂ → ℝ} (p₂ : ι₂ → P) (h₂ : ∑ i ∈ s₂, w₂ i = 0) : ⟪s₁.weightedVSub p₁ w₁, s₂.weightedVSub p₂ w₂⟫ = (-∑ i₁ ∈ s₁, ∑ i₂ ∈ s₂, w₁ i₁ * w₂ i₂ * (dist (p₁ i₁) (p₂ i₂) * dist (p₁ i₁) (p₂ i₂))) / 2 := by rw [Finset.weightedVSub_apply, Finset.weightedVSub_apply, inner_sum_smul_sum_smul_of_sum_eq_zero _ h₁ _ h₂] simp_rw [vsub_sub_vsub_cancel_right] rcongr (i₁ i₂) <;> rw [dist_eq_norm_vsub V (p₁ i₁) (p₂ i₂)] #align euclidean_geometry.inner_weighted_vsub EuclideanGeometry.inner_weightedVSub theorem dist_affineCombination {ι : Type*} {s : Finset ι} {w₁ w₂ : ι → ℝ} (p : ι → P) (h₁ : ∑ i ∈ s, w₁ i = 1) (h₂ : ∑ i ∈ s, w₂ i = 1) : by have a₁ := s.affineCombination ℝ p w₁ have a₂ := s.affineCombination ℝ p w₂ exact dist a₁ a₂ * dist a₁ a₂ = (-∑ i₁ ∈ s, ∑ i₂ ∈ s, (w₁ - w₂) i₁ * (w₁ - w₂) i₂ * (dist (p i₁) (p i₂) * dist (p i₁) (p i₂))) / 2 := by dsimp only rw [dist_eq_norm_vsub V (s.affineCombination ℝ p w₁) (s.affineCombination ℝ p w₂), ← @inner_self_eq_norm_mul_norm ℝ, Finset.affineCombination_vsub] have h : (∑ i ∈ s, (w₁ - w₂) i) = 0 := by simp_rw [Pi.sub_apply, Finset.sum_sub_distrib, h₁, h₂, sub_self] exact inner_weightedVSub p h p h #align euclidean_geometry.dist_affine_combination EuclideanGeometry.dist_affineCombination -- Porting note: `inner_vsub_vsub_of_dist_eq_of_dist_eq` moved to `PerpendicularBisector` theorem dist_smul_vadd_sq (r : ℝ) (v : V) (p₁ p₂ : P) : dist (r • v +ᵥ p₁) p₂ * dist (r • v +ᵥ p₁) p₂ = ⟪v, v⟫ * r * r + 2 * ⟪v, p₁ -ᵥ p₂⟫ * r + ⟪p₁ -ᵥ p₂, p₁ -ᵥ p₂⟫ := by rw [dist_eq_norm_vsub V _ p₂, ← real_inner_self_eq_norm_mul_norm, vadd_vsub_assoc, real_inner_add_add_self, real_inner_smul_left, real_inner_smul_left, real_inner_smul_right] ring #align euclidean_geometry.dist_smul_vadd_sq EuclideanGeometry.dist_smul_vadd_sq theorem dist_smul_vadd_eq_dist {v : V} (p₁ p₂ : P) (hv : v ≠ 0) (r : ℝ) : dist (r • v +ᵥ p₁) p₂ = dist p₁ p₂ ↔ r = 0 ∨ r = -2 * ⟪v, p₁ -ᵥ p₂⟫ / ⟪v, v⟫ := by conv_lhs => rw [← mul_self_inj_of_nonneg dist_nonneg dist_nonneg, dist_smul_vadd_sq, ← sub_eq_zero, add_sub_assoc, dist_eq_norm_vsub V p₁ p₂, ← real_inner_self_eq_norm_mul_norm, sub_self] have hvi : ⟪v, v⟫ ≠ 0 := by simpa using hv have hd : discrim ⟪v, v⟫ (2 * ⟪v, p₁ -ᵥ p₂⟫) 0 = 2 * ⟪v, p₁ -ᵥ p₂⟫ * (2 * ⟪v, p₁ -ᵥ p₂⟫) := by rw [discrim] ring rw [quadratic_eq_zero_iff hvi hd, add_left_neg, zero_div, neg_mul_eq_neg_mul, ← mul_sub_right_distrib, sub_eq_add_neg, ← mul_two, mul_assoc, mul_div_assoc, mul_div_mul_left, mul_div_assoc] norm_num #align euclidean_geometry.dist_smul_vadd_eq_dist EuclideanGeometry.dist_smul_vadd_eq_dist open AffineSubspace FiniteDimensional theorem eq_of_dist_eq_of_dist_eq_of_mem_of_finrank_eq_two {s : AffineSubspace ℝ P} [FiniteDimensional ℝ s.direction] (hd : finrank ℝ s.direction = 2) {c₁ c₂ p₁ p₂ p : P} (hc₁s : c₁ ∈ s) (hc₂s : c₂ ∈ s) (hp₁s : p₁ ∈ s) (hp₂s : p₂ ∈ s) (hps : p ∈ s) {r₁ r₂ : ℝ} (hc : c₁ ≠ c₂) (hp : p₁ ≠ p₂) (hp₁c₁ : dist p₁ c₁ = r₁) (hp₂c₁ : dist p₂ c₁ = r₁) (hpc₁ : dist p c₁ = r₁) (hp₁c₂ : dist p₁ c₂ = r₂) (hp₂c₂ : dist p₂ c₂ = r₂) (hpc₂ : dist p c₂ = r₂) : p = p₁ ∨ p = p₂ := by have ho : ⟪c₂ -ᵥ c₁, p₂ -ᵥ p₁⟫ = 0 := inner_vsub_vsub_of_dist_eq_of_dist_eq (hp₁c₁.trans hp₂c₁.symm) (hp₁c₂.trans hp₂c₂.symm) have hop : ⟪c₂ -ᵥ c₁, p -ᵥ p₁⟫ = 0 := inner_vsub_vsub_of_dist_eq_of_dist_eq (hp₁c₁.trans hpc₁.symm) (hp₁c₂.trans hpc₂.symm) let b : Fin 2 → V := ![c₂ -ᵥ c₁, p₂ -ᵥ p₁] have hb : LinearIndependent ℝ b := by refine linearIndependent_of_ne_zero_of_inner_eq_zero ?_ ?_ · intro i fin_cases i <;> simp [b, hc.symm, hp.symm] · intro i j hij fin_cases i <;> fin_cases j <;> try exact False.elim (hij rfl) · exact ho · rw [real_inner_comm] exact ho have hbs : Submodule.span ℝ (Set.range b) = s.direction := by refine eq_of_le_of_finrank_eq ?_ ?_ · rw [Submodule.span_le, Set.range_subset_iff] intro i fin_cases i · exact vsub_mem_direction hc₂s hc₁s · exact vsub_mem_direction hp₂s hp₁s · rw [finrank_span_eq_card hb, Fintype.card_fin, hd] have hv : ∀ v ∈ s.direction, ∃ t₁ t₂ : ℝ, v = t₁ • (c₂ -ᵥ c₁) + t₂ • (p₂ -ᵥ p₁) := by intro v hv have hr : Set.range b = {c₂ -ᵥ c₁, p₂ -ᵥ p₁} := by have hu : (Finset.univ : Finset (Fin 2)) = {0, 1} := by decide rw [← Fintype.coe_image_univ, hu] simp [b] rw [← hbs, hr, Submodule.mem_span_insert] at hv rcases hv with ⟨t₁, v', hv', hv⟩ rw [Submodule.mem_span_singleton] at hv' rcases hv' with ⟨t₂, rfl⟩ exact ⟨t₁, t₂, hv⟩ rcases hv (p -ᵥ p₁) (vsub_mem_direction hps hp₁s) with ⟨t₁, t₂, hpt⟩ simp only [hpt, inner_add_right, inner_smul_right, ho, mul_zero, add_zero, mul_eq_zero, inner_self_eq_zero, vsub_eq_zero_iff_eq, hc.symm, or_false_iff] at hop rw [hop, zero_smul, zero_add, ← eq_vadd_iff_vsub_eq] at hpt subst hpt have hp' : (p₂ -ᵥ p₁ : V) ≠ 0 := by simp [hp.symm] have hp₂ : dist ((1 : ℝ) • (p₂ -ᵥ p₁) +ᵥ p₁) c₁ = r₁ := by simp [hp₂c₁] rw [← hp₁c₁, dist_smul_vadd_eq_dist _ _ hp'] at hpc₁ hp₂ simp only [one_ne_zero, false_or_iff] at hp₂ rw [hp₂.symm] at hpc₁ cases' hpc₁ with hpc₁ hpc₁ <;> simp [hpc₁] #align euclidean_geometry.eq_of_dist_eq_of_dist_eq_of_mem_of_finrank_eq_two EuclideanGeometry.eq_of_dist_eq_of_dist_eq_of_mem_of_finrank_eq_two theorem eq_of_dist_eq_of_dist_eq_of_finrank_eq_two [FiniteDimensional ℝ V] (hd : finrank ℝ V = 2) {c₁ c₂ p₁ p₂ p : P} {r₁ r₂ : ℝ} (hc : c₁ ≠ c₂) (hp : p₁ ≠ p₂) (hp₁c₁ : dist p₁ c₁ = r₁) (hp₂c₁ : dist p₂ c₁ = r₁) (hpc₁ : dist p c₁ = r₁) (hp₁c₂ : dist p₁ c₂ = r₂) (hp₂c₂ : dist p₂ c₂ = r₂) (hpc₂ : dist p c₂ = r₂) : p = p₁ ∨ p = p₂ := haveI hd' : finrank ℝ (⊤ : AffineSubspace ℝ P).direction = 2 := by rw [direction_top, finrank_top] exact hd eq_of_dist_eq_of_dist_eq_of_mem_of_finrank_eq_two hd' (mem_top ℝ V _) (mem_top ℝ V _) (mem_top ℝ V _) (mem_top ℝ V _) (mem_top ℝ V _) hc hp hp₁c₁ hp₂c₁ hpc₁ hp₁c₂ hp₂c₂ hpc₂ #align euclidean_geometry.eq_of_dist_eq_of_dist_eq_of_finrank_eq_two EuclideanGeometry.eq_of_dist_eq_of_dist_eq_of_finrank_eq_two def orthogonalProjectionFn (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : P := Classical.choose <| inter_eq_singleton_of_nonempty_of_isCompl (nonempty_subtype.mp ‹_›) (mk'_nonempty p s.directionᗮ) (by rw [direction_mk' p s.directionᗮ] exact Submodule.isCompl_orthogonal_of_completeSpace) #align euclidean_geometry.orthogonal_projection_fn EuclideanGeometry.orthogonalProjectionFn theorem inter_eq_singleton_orthogonalProjectionFn {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : (s : Set P) ∩ mk' p s.directionᗮ = {orthogonalProjectionFn s p} := Classical.choose_spec <| inter_eq_singleton_of_nonempty_of_isCompl (nonempty_subtype.mp ‹_›) (mk'_nonempty p s.directionᗮ) (by rw [direction_mk' p s.directionᗮ] exact Submodule.isCompl_orthogonal_of_completeSpace) #align euclidean_geometry.inter_eq_singleton_orthogonal_projection_fn EuclideanGeometry.inter_eq_singleton_orthogonalProjectionFn theorem orthogonalProjectionFn_mem {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : orthogonalProjectionFn s p ∈ s := by rw [← mem_coe, ← Set.singleton_subset_iff, ← inter_eq_singleton_orthogonalProjectionFn] exact Set.inter_subset_left #align euclidean_geometry.orthogonal_projection_fn_mem EuclideanGeometry.orthogonalProjectionFn_mem theorem orthogonalProjectionFn_mem_orthogonal {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : orthogonalProjectionFn s p ∈ mk' p s.directionᗮ := by rw [← mem_coe, ← Set.singleton_subset_iff, ← inter_eq_singleton_orthogonalProjectionFn] exact Set.inter_subset_right #align euclidean_geometry.orthogonal_projection_fn_mem_orthogonal EuclideanGeometry.orthogonalProjectionFn_mem_orthogonal theorem orthogonalProjectionFn_vsub_mem_direction_orthogonal {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : orthogonalProjectionFn s p -ᵥ p ∈ s.directionᗮ := direction_mk' p s.directionᗮ ▸ vsub_mem_direction (orthogonalProjectionFn_mem_orthogonal p) (self_mem_mk' _ _) #align euclidean_geometry.orthogonal_projection_fn_vsub_mem_direction_orthogonal EuclideanGeometry.orthogonalProjectionFn_vsub_mem_direction_orthogonal attribute [local instance] AffineSubspace.toAddTorsor nonrec def orthogonalProjection (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] : P →ᵃ[ℝ] s where toFun p := ⟨orthogonalProjectionFn s p, orthogonalProjectionFn_mem p⟩ linear := orthogonalProjection s.direction map_vadd' p v := by have hs : ((orthogonalProjection s.direction) v : V) +ᵥ orthogonalProjectionFn s p ∈ s := vadd_mem_of_mem_direction (orthogonalProjection s.direction v).2 (orthogonalProjectionFn_mem p) have ho : ((orthogonalProjection s.direction) v : V) +ᵥ orthogonalProjectionFn s p ∈ mk' (v +ᵥ p) s.directionᗮ := by rw [← vsub_right_mem_direction_iff_mem (self_mem_mk' _ _) _, direction_mk', vsub_vadd_eq_vsub_sub, vadd_vsub_assoc, add_comm, add_sub_assoc] refine Submodule.add_mem _ (orthogonalProjectionFn_vsub_mem_direction_orthogonal p) ?_ rw [Submodule.mem_orthogonal'] intro w hw rw [← neg_sub, inner_neg_left, orthogonalProjection_inner_eq_zero _ w hw, neg_zero] have hm : ((orthogonalProjection s.direction) v : V) +ᵥ orthogonalProjectionFn s p ∈ ({orthogonalProjectionFn s (v +ᵥ p)} : Set P) := by rw [← inter_eq_singleton_orthogonalProjectionFn (v +ᵥ p)] exact Set.mem_inter hs ho rw [Set.mem_singleton_iff] at hm ext exact hm.symm #align euclidean_geometry.orthogonal_projection EuclideanGeometry.orthogonalProjection @[simp] theorem orthogonalProjectionFn_eq {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : orthogonalProjectionFn s p = orthogonalProjection s p := rfl #align euclidean_geometry.orthogonal_projection_fn_eq EuclideanGeometry.orthogonalProjectionFn_eq @[simp] theorem orthogonalProjection_linear {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] : (orthogonalProjection s).linear = _root_.orthogonalProjection s.direction := rfl #align euclidean_geometry.orthogonal_projection_linear EuclideanGeometry.orthogonalProjection_linear theorem inter_eq_singleton_orthogonalProjection {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : (s : Set P) ∩ mk' p s.directionᗮ = {↑(orthogonalProjection s p)} := by rw [← orthogonalProjectionFn_eq] exact inter_eq_singleton_orthogonalProjectionFn p #align euclidean_geometry.inter_eq_singleton_orthogonal_projection EuclideanGeometry.inter_eq_singleton_orthogonalProjection theorem orthogonalProjection_mem {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : ↑(orthogonalProjection s p) ∈ s := (orthogonalProjection s p).2 #align euclidean_geometry.orthogonal_projection_mem EuclideanGeometry.orthogonalProjection_mem theorem orthogonalProjection_mem_orthogonal (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : ↑(orthogonalProjection s p) ∈ mk' p s.directionᗮ := orthogonalProjectionFn_mem_orthogonal p #align euclidean_geometry.orthogonal_projection_mem_orthogonal EuclideanGeometry.orthogonalProjection_mem_orthogonal theorem orthogonalProjection_vsub_mem_direction {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {p1 : P} (p2 : P) (hp1 : p1 ∈ s) : ↑(orthogonalProjection s p2 -ᵥ ⟨p1, hp1⟩ : s.direction) ∈ s.direction := (orthogonalProjection s p2 -ᵥ ⟨p1, hp1⟩ : s.direction).2 #align euclidean_geometry.orthogonal_projection_vsub_mem_direction EuclideanGeometry.orthogonalProjection_vsub_mem_direction theorem vsub_orthogonalProjection_mem_direction {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {p1 : P} (p2 : P) (hp1 : p1 ∈ s) : ↑((⟨p1, hp1⟩ : s) -ᵥ orthogonalProjection s p2 : s.direction) ∈ s.direction := ((⟨p1, hp1⟩ : s) -ᵥ orthogonalProjection s p2 : s.direction).2 #align euclidean_geometry.vsub_orthogonal_projection_mem_direction EuclideanGeometry.vsub_orthogonalProjection_mem_direction theorem orthogonalProjection_eq_self_iff {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {p : P} : ↑(orthogonalProjection s p) = p ↔ p ∈ s := by constructor · exact fun h => h ▸ orthogonalProjection_mem p · intro h have hp : p ∈ (s : Set P) ∩ mk' p s.directionᗮ := ⟨h, self_mem_mk' p _⟩ rw [inter_eq_singleton_orthogonalProjection p] at hp symm exact hp #align euclidean_geometry.orthogonal_projection_eq_self_iff EuclideanGeometry.orthogonalProjection_eq_self_iff @[simp] theorem orthogonalProjection_mem_subspace_eq_self {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] (p : s) : orthogonalProjection s p = p := by ext rw [orthogonalProjection_eq_self_iff] exact p.2 #align euclidean_geometry.orthogonal_projection_mem_subspace_eq_self EuclideanGeometry.orthogonalProjection_mem_subspace_eq_self -- @[simp] -- Porting note (#10618): simp can prove this theorem orthogonalProjection_orthogonalProjection (s : AffineSubspace ℝ P) [Nonempty s] [HasOrthogonalProjection s.direction] (p : P) : orthogonalProjection s (orthogonalProjection s p) = orthogonalProjection s p := by ext rw [orthogonalProjection_eq_self_iff] exact orthogonalProjection_mem p #align euclidean_geometry.orthogonal_projection_orthogonal_projection EuclideanGeometry.orthogonalProjection_orthogonalProjection theorem eq_orthogonalProjection_of_eq_subspace {s s' : AffineSubspace ℝ P} [Nonempty s] [Nonempty s'] [HasOrthogonalProjection s.direction] [HasOrthogonalProjection s'.direction] (h : s = s') (p : P) : (orthogonalProjection s p : P) = (orthogonalProjection s' p : P) := by subst h rfl #align euclidean_geometry.eq_orthogonal_projection_of_eq_subspace EuclideanGeometry.eq_orthogonalProjection_of_eq_subspace
Mathlib/Geometry/Euclidean/Basic.lean
398
401
theorem dist_orthogonalProjection_eq_zero_iff {s : AffineSubspace ℝ P} [Nonempty s] [HasOrthogonalProjection s.direction] {p : P} : dist p (orthogonalProjection s p) = 0 ↔ p ∈ s := by
rw [dist_comm, dist_eq_zero, orthogonalProjection_eq_self_iff]
import Mathlib.Data.Matrix.Basic import Mathlib.Data.PEquiv #align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" namespace PEquiv open Matrix universe u v variable {k l m n : Type*} variable {α : Type v} open Matrix def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α := of fun i j => if j ∈ f i then (1 : α) else 0 #align pequiv.to_matrix PEquiv.toMatrix -- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024 @[simp] theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) : toMatrix f i j = if j ∈ f i then (1 : α) else 0 := rfl #align pequiv.to_matrix_apply PEquiv.toMatrix_apply theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α) (i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f i with fi · simp [h] · rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm] #align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : (f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by ext simp only [transpose, mem_iff_mem f, toMatrix_apply] congr #align pequiv.to_matrix_symm PEquiv.toMatrix_symm @[simp] theorem toMatrix_refl [DecidableEq n] [Zero α] [One α] : ((PEquiv.refl n).toMatrix : Matrix n n α) = 1 := by ext simp [toMatrix_apply, one_apply] #align pequiv.to_matrix_refl PEquiv.toMatrix_refl theorem matrix_mul_apply [Fintype m] [Semiring α] [DecidableEq n] (M : Matrix l m α) (f : m ≃. n) (i j) : (M * f.toMatrix :) i j = Option.casesOn (f.symm j) 0 fun fj => M i fj := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f.symm j with fj · simp [h, ← f.eq_some_iff] · rw [Finset.sum_eq_single fj] · simp [h, ← f.eq_some_iff] · rintro b - n simp [h, ← f.eq_some_iff, n.symm] · simp #align pequiv.matrix_mul_apply PEquiv.matrix_mul_apply theorem toPEquiv_mul_matrix [Fintype m] [DecidableEq m] [Semiring α] (f : m ≃ m) (M : Matrix m n α) : f.toPEquiv.toMatrix * M = M.submatrix f id := by ext i j rw [mul_matrix_apply, Equiv.toPEquiv_apply, submatrix_apply, id] #align pequiv.to_pequiv_mul_matrix PEquiv.toPEquiv_mul_matrix theorem mul_toPEquiv_toMatrix {m n α : Type*} [Fintype n] [DecidableEq n] [Semiring α] (f : n ≃ n) (M : Matrix m n α) : M * f.toPEquiv.toMatrix = M.submatrix id f.symm := Matrix.ext fun i j => by rw [PEquiv.matrix_mul_apply, ← Equiv.toPEquiv_symm, Equiv.toPEquiv_apply, Matrix.submatrix_apply, id] #align pequiv.mul_to_pequiv_to_matrix PEquiv.mul_toPEquiv_toMatrix theorem toMatrix_trans [Fintype m] [DecidableEq m] [DecidableEq n] [Semiring α] (f : l ≃. m) (g : m ≃. n) : ((f.trans g).toMatrix : Matrix l n α) = f.toMatrix * g.toMatrix := by ext i j rw [mul_matrix_apply] dsimp [toMatrix, PEquiv.trans] cases f i <;> simp #align pequiv.to_matrix_trans PEquiv.toMatrix_trans @[simp] theorem toMatrix_bot [DecidableEq n] [Zero α] [One α] : ((⊥ : PEquiv m n).toMatrix : Matrix m n α) = 0 := rfl #align pequiv.to_matrix_bot PEquiv.toMatrix_bot theorem toMatrix_injective [DecidableEq n] [MonoidWithZero α] [Nontrivial α] : Function.Injective (@toMatrix m n α _ _ _) := by classical intro f g refine not_imp_not.1 ?_ simp only [Matrix.ext_iff.symm, toMatrix_apply, PEquiv.ext_iff, not_forall, exists_imp] intro i hi use i cases' hf : f i with fi · cases' hg : g i with gi -- Porting note: was `cc` · rw [hf, hg] at hi exact (hi rfl).elim · use gi simp · use fi simp [hf.symm, Ne.symm hi] #align pequiv.to_matrix_injective PEquiv.toMatrix_injective theorem toMatrix_swap [DecidableEq n] [Ring α] (i j : n) : (Equiv.swap i j).toPEquiv.toMatrix = (1 : Matrix n n α) - (single i i).toMatrix - (single j j).toMatrix + (single i j).toMatrix + (single j i).toMatrix := by ext dsimp [toMatrix, single, Equiv.swap_apply_def, Equiv.toPEquiv, one_apply] split_ifs <;> simp_all #align pequiv.to_matrix_swap PEquiv.toMatrix_swap @[simp]
Mathlib/Data/Matrix/PEquiv.lean
152
155
theorem single_mul_single [Fintype n] [DecidableEq k] [DecidableEq m] [DecidableEq n] [Semiring α] (a : m) (b : n) (c : k) : ((single a b).toMatrix : Matrix _ _ α) * (single b c).toMatrix = (single a c).toMatrix := by
rw [← toMatrix_trans, single_trans_single]
import Mathlib.GroupTheory.GroupAction.BigOperators import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Pi import Mathlib.Algebra.Module.Prod import Mathlib.Algebra.Module.Submodule.Ker #align_import linear_algebra.pi from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" universe u v w x y z u' v' w' x' y' variable {R : Type u} {K : Type u'} {M : Type v} {V : Type v'} {M₂ : Type w} {V₂ : Type w'} variable {M₃ : Type y} {V₃ : Type y'} {M₄ : Type z} {ι : Type x} {ι' : Type x'} open Function Submodule namespace LinearMap universe i variable [Semiring R] [AddCommMonoid M₂] [Module R M₂] [AddCommMonoid M₃] [Module R M₃] {φ : ι → Type i} [(i : ι) → AddCommMonoid (φ i)] [(i : ι) → Module R (φ i)] def pi (f : (i : ι) → M₂ →ₗ[R] φ i) : M₂ →ₗ[R] (i : ι) → φ i := { Pi.addHom fun i => (f i).toAddHom with toFun := fun c i => f i c map_smul' := fun _ _ => funext fun i => (f i).map_smul _ _ } #align linear_map.pi LinearMap.pi @[simp] theorem pi_apply (f : (i : ι) → M₂ →ₗ[R] φ i) (c : M₂) (i : ι) : pi f c i = f i c := rfl #align linear_map.pi_apply LinearMap.pi_apply theorem ker_pi (f : (i : ι) → M₂ →ₗ[R] φ i) : ker (pi f) = ⨅ i : ι, ker (f i) := by ext c; simp [funext_iff] #align linear_map.ker_pi LinearMap.ker_pi
Mathlib/LinearAlgebra/Pi.lean
64
66
theorem pi_eq_zero (f : (i : ι) → M₂ →ₗ[R] φ i) : pi f = 0 ↔ ∀ i, f i = 0 := by
simp only [LinearMap.ext_iff, pi_apply, funext_iff]; exact ⟨fun h a b => h b a, fun h a b => h b a⟩
import Mathlib.Algebra.CharP.Invertible import Mathlib.Algebra.Order.Interval.Set.Group import Mathlib.Analysis.Convex.Segment import Mathlib.LinearAlgebra.AffineSpace.FiniteDimensional import Mathlib.Tactic.FieldSimp #align_import analysis.convex.between from "leanprover-community/mathlib"@"571e13cacbed7bf042fd3058ce27157101433842" variable (R : Type*) {V V' P P' : Type*} open AffineEquiv AffineMap section OrderedRing variable [OrderedRing R] [AddCommGroup V] [Module R V] [AddTorsor V P] variable [AddCommGroup V'] [Module R V'] [AddTorsor V' P'] def affineSegment (x y : P) := lineMap x y '' Set.Icc (0 : R) 1 #align affine_segment affineSegment theorem affineSegment_eq_segment (x y : V) : affineSegment R x y = segment R x y := by rw [segment_eq_image_lineMap, affineSegment] #align affine_segment_eq_segment affineSegment_eq_segment theorem affineSegment_comm (x y : P) : affineSegment R x y = affineSegment R y x := by refine Set.ext fun z => ?_ constructor <;> · rintro ⟨t, ht, hxy⟩ refine ⟨1 - t, ?_, ?_⟩ · rwa [Set.sub_mem_Icc_iff_right, sub_self, sub_zero] · rwa [lineMap_apply_one_sub] #align affine_segment_comm affineSegment_comm theorem left_mem_affineSegment (x y : P) : x ∈ affineSegment R x y := ⟨0, Set.left_mem_Icc.2 zero_le_one, lineMap_apply_zero _ _⟩ #align left_mem_affine_segment left_mem_affineSegment theorem right_mem_affineSegment (x y : P) : y ∈ affineSegment R x y := ⟨1, Set.right_mem_Icc.2 zero_le_one, lineMap_apply_one _ _⟩ #align right_mem_affine_segment right_mem_affineSegment @[simp] theorem affineSegment_same (x : P) : affineSegment R x x = {x} := by -- Porting note: added as this doesn't do anything in `simp_rw` any more rw [affineSegment] -- Note: when adding "simp made no progress" in lean4#2336, -- had to change `lineMap_same` to `lineMap_same _`. Not sure why? -- Porting note: added `_ _` and `Function.const` simp_rw [lineMap_same _, AffineMap.coe_const _ _, Function.const, (Set.nonempty_Icc.mpr zero_le_one).image_const] #align affine_segment_same affineSegment_same variable {R} @[simp] theorem affineSegment_image (f : P →ᵃ[R] P') (x y : P) : f '' affineSegment R x y = affineSegment R (f x) (f y) := by rw [affineSegment, affineSegment, Set.image_image, ← comp_lineMap] rfl #align affine_segment_image affineSegment_image variable (R) @[simp] theorem affineSegment_const_vadd_image (x y : P) (v : V) : (v +ᵥ ·) '' affineSegment R x y = affineSegment R (v +ᵥ x) (v +ᵥ y) := affineSegment_image (AffineEquiv.constVAdd R P v : P →ᵃ[R] P) x y #align affine_segment_const_vadd_image affineSegment_const_vadd_image @[simp] theorem affineSegment_vadd_const_image (x y : V) (p : P) : (· +ᵥ p) '' affineSegment R x y = affineSegment R (x +ᵥ p) (y +ᵥ p) := affineSegment_image (AffineEquiv.vaddConst R p : V →ᵃ[R] P) x y #align affine_segment_vadd_const_image affineSegment_vadd_const_image @[simp] theorem affineSegment_const_vsub_image (x y p : P) : (p -ᵥ ·) '' affineSegment R x y = affineSegment R (p -ᵥ x) (p -ᵥ y) := affineSegment_image (AffineEquiv.constVSub R p : P →ᵃ[R] V) x y #align affine_segment_const_vsub_image affineSegment_const_vsub_image @[simp] theorem affineSegment_vsub_const_image (x y p : P) : (· -ᵥ p) '' affineSegment R x y = affineSegment R (x -ᵥ p) (y -ᵥ p) := affineSegment_image ((AffineEquiv.vaddConst R p).symm : P →ᵃ[R] V) x y #align affine_segment_vsub_const_image affineSegment_vsub_const_image variable {R} @[simp] theorem mem_const_vadd_affineSegment {x y z : P} (v : V) : v +ᵥ z ∈ affineSegment R (v +ᵥ x) (v +ᵥ y) ↔ z ∈ affineSegment R x y := by rw [← affineSegment_const_vadd_image, (AddAction.injective v).mem_set_image] #align mem_const_vadd_affine_segment mem_const_vadd_affineSegment @[simp] theorem mem_vadd_const_affineSegment {x y z : V} (p : P) : z +ᵥ p ∈ affineSegment R (x +ᵥ p) (y +ᵥ p) ↔ z ∈ affineSegment R x y := by rw [← affineSegment_vadd_const_image, (vadd_right_injective p).mem_set_image] #align mem_vadd_const_affine_segment mem_vadd_const_affineSegment @[simp] theorem mem_const_vsub_affineSegment {x y z : P} (p : P) : p -ᵥ z ∈ affineSegment R (p -ᵥ x) (p -ᵥ y) ↔ z ∈ affineSegment R x y := by rw [← affineSegment_const_vsub_image, (vsub_right_injective p).mem_set_image] #align mem_const_vsub_affine_segment mem_const_vsub_affineSegment @[simp] theorem mem_vsub_const_affineSegment {x y z : P} (p : P) : z -ᵥ p ∈ affineSegment R (x -ᵥ p) (y -ᵥ p) ↔ z ∈ affineSegment R x y := by rw [← affineSegment_vsub_const_image, (vsub_left_injective p).mem_set_image] #align mem_vsub_const_affine_segment mem_vsub_const_affineSegment variable (R) def Wbtw (x y z : P) : Prop := y ∈ affineSegment R x z #align wbtw Wbtw def Sbtw (x y z : P) : Prop := Wbtw R x y z ∧ y ≠ x ∧ y ≠ z #align sbtw Sbtw variable {R} lemma mem_segment_iff_wbtw {x y z : V} : y ∈ segment R x z ↔ Wbtw R x y z := by rw [Wbtw, affineSegment_eq_segment] theorem Wbtw.map {x y z : P} (h : Wbtw R x y z) (f : P →ᵃ[R] P') : Wbtw R (f x) (f y) (f z) := by rw [Wbtw, ← affineSegment_image] exact Set.mem_image_of_mem _ h #align wbtw.map Wbtw.map theorem Function.Injective.wbtw_map_iff {x y z : P} {f : P →ᵃ[R] P'} (hf : Function.Injective f) : Wbtw R (f x) (f y) (f z) ↔ Wbtw R x y z := by refine ⟨fun h => ?_, fun h => h.map _⟩ rwa [Wbtw, ← affineSegment_image, hf.mem_set_image] at h #align function.injective.wbtw_map_iff Function.Injective.wbtw_map_iff theorem Function.Injective.sbtw_map_iff {x y z : P} {f : P →ᵃ[R] P'} (hf : Function.Injective f) : Sbtw R (f x) (f y) (f z) ↔ Sbtw R x y z := by simp_rw [Sbtw, hf.wbtw_map_iff, hf.ne_iff] #align function.injective.sbtw_map_iff Function.Injective.sbtw_map_iff @[simp] theorem AffineEquiv.wbtw_map_iff {x y z : P} (f : P ≃ᵃ[R] P') : Wbtw R (f x) (f y) (f z) ↔ Wbtw R x y z := by refine Function.Injective.wbtw_map_iff (?_ : Function.Injective f.toAffineMap) exact f.injective #align affine_equiv.wbtw_map_iff AffineEquiv.wbtw_map_iff @[simp] theorem AffineEquiv.sbtw_map_iff {x y z : P} (f : P ≃ᵃ[R] P') : Sbtw R (f x) (f y) (f z) ↔ Sbtw R x y z := by refine Function.Injective.sbtw_map_iff (?_ : Function.Injective f.toAffineMap) exact f.injective #align affine_equiv.sbtw_map_iff AffineEquiv.sbtw_map_iff @[simp] theorem wbtw_const_vadd_iff {x y z : P} (v : V) : Wbtw R (v +ᵥ x) (v +ᵥ y) (v +ᵥ z) ↔ Wbtw R x y z := mem_const_vadd_affineSegment _ #align wbtw_const_vadd_iff wbtw_const_vadd_iff @[simp] theorem wbtw_vadd_const_iff {x y z : V} (p : P) : Wbtw R (x +ᵥ p) (y +ᵥ p) (z +ᵥ p) ↔ Wbtw R x y z := mem_vadd_const_affineSegment _ #align wbtw_vadd_const_iff wbtw_vadd_const_iff @[simp] theorem wbtw_const_vsub_iff {x y z : P} (p : P) : Wbtw R (p -ᵥ x) (p -ᵥ y) (p -ᵥ z) ↔ Wbtw R x y z := mem_const_vsub_affineSegment _ #align wbtw_const_vsub_iff wbtw_const_vsub_iff @[simp] theorem wbtw_vsub_const_iff {x y z : P} (p : P) : Wbtw R (x -ᵥ p) (y -ᵥ p) (z -ᵥ p) ↔ Wbtw R x y z := mem_vsub_const_affineSegment _ #align wbtw_vsub_const_iff wbtw_vsub_const_iff @[simp] theorem sbtw_const_vadd_iff {x y z : P} (v : V) : Sbtw R (v +ᵥ x) (v +ᵥ y) (v +ᵥ z) ↔ Sbtw R x y z := by rw [Sbtw, Sbtw, wbtw_const_vadd_iff, (AddAction.injective v).ne_iff, (AddAction.injective v).ne_iff] #align sbtw_const_vadd_iff sbtw_const_vadd_iff @[simp] theorem sbtw_vadd_const_iff {x y z : V} (p : P) : Sbtw R (x +ᵥ p) (y +ᵥ p) (z +ᵥ p) ↔ Sbtw R x y z := by rw [Sbtw, Sbtw, wbtw_vadd_const_iff, (vadd_right_injective p).ne_iff, (vadd_right_injective p).ne_iff] #align sbtw_vadd_const_iff sbtw_vadd_const_iff @[simp] theorem sbtw_const_vsub_iff {x y z : P} (p : P) : Sbtw R (p -ᵥ x) (p -ᵥ y) (p -ᵥ z) ↔ Sbtw R x y z := by rw [Sbtw, Sbtw, wbtw_const_vsub_iff, (vsub_right_injective p).ne_iff, (vsub_right_injective p).ne_iff] #align sbtw_const_vsub_iff sbtw_const_vsub_iff @[simp] theorem sbtw_vsub_const_iff {x y z : P} (p : P) : Sbtw R (x -ᵥ p) (y -ᵥ p) (z -ᵥ p) ↔ Sbtw R x y z := by rw [Sbtw, Sbtw, wbtw_vsub_const_iff, (vsub_left_injective p).ne_iff, (vsub_left_injective p).ne_iff] #align sbtw_vsub_const_iff sbtw_vsub_const_iff theorem Sbtw.wbtw {x y z : P} (h : Sbtw R x y z) : Wbtw R x y z := h.1 #align sbtw.wbtw Sbtw.wbtw theorem Sbtw.ne_left {x y z : P} (h : Sbtw R x y z) : y ≠ x := h.2.1 #align sbtw.ne_left Sbtw.ne_left theorem Sbtw.left_ne {x y z : P} (h : Sbtw R x y z) : x ≠ y := h.2.1.symm #align sbtw.left_ne Sbtw.left_ne theorem Sbtw.ne_right {x y z : P} (h : Sbtw R x y z) : y ≠ z := h.2.2 #align sbtw.ne_right Sbtw.ne_right theorem Sbtw.right_ne {x y z : P} (h : Sbtw R x y z) : z ≠ y := h.2.2.symm #align sbtw.right_ne Sbtw.right_ne theorem Sbtw.mem_image_Ioo {x y z : P} (h : Sbtw R x y z) : y ∈ lineMap x z '' Set.Ioo (0 : R) 1 := by rcases h with ⟨⟨t, ht, rfl⟩, hyx, hyz⟩ rcases Set.eq_endpoints_or_mem_Ioo_of_mem_Icc ht with (rfl | rfl | ho) · exfalso exact hyx (lineMap_apply_zero _ _) · exfalso exact hyz (lineMap_apply_one _ _) · exact ⟨t, ho, rfl⟩ #align sbtw.mem_image_Ioo Sbtw.mem_image_Ioo theorem Wbtw.mem_affineSpan {x y z : P} (h : Wbtw R x y z) : y ∈ line[R, x, z] := by rcases h with ⟨r, ⟨-, rfl⟩⟩ exact lineMap_mem_affineSpan_pair _ _ _ #align wbtw.mem_affine_span Wbtw.mem_affineSpan theorem wbtw_comm {x y z : P} : Wbtw R x y z ↔ Wbtw R z y x := by rw [Wbtw, Wbtw, affineSegment_comm] #align wbtw_comm wbtw_comm alias ⟨Wbtw.symm, _⟩ := wbtw_comm #align wbtw.symm Wbtw.symm theorem sbtw_comm {x y z : P} : Sbtw R x y z ↔ Sbtw R z y x := by rw [Sbtw, Sbtw, wbtw_comm, ← and_assoc, ← and_assoc, and_right_comm] #align sbtw_comm sbtw_comm alias ⟨Sbtw.symm, _⟩ := sbtw_comm #align sbtw.symm Sbtw.symm variable (R) @[simp] theorem wbtw_self_left (x y : P) : Wbtw R x x y := left_mem_affineSegment _ _ _ #align wbtw_self_left wbtw_self_left @[simp] theorem wbtw_self_right (x y : P) : Wbtw R x y y := right_mem_affineSegment _ _ _ #align wbtw_self_right wbtw_self_right @[simp] theorem wbtw_self_iff {x y : P} : Wbtw R x y x ↔ y = x := by refine ⟨fun h => ?_, fun h => ?_⟩ · -- Porting note: Originally `simpa [Wbtw, affineSegment] using h` have ⟨_, _, h₂⟩ := h rw [h₂.symm, lineMap_same_apply] · rw [h] exact wbtw_self_left R x x #align wbtw_self_iff wbtw_self_iff @[simp] theorem not_sbtw_self_left (x y : P) : ¬Sbtw R x x y := fun h => h.ne_left rfl #align not_sbtw_self_left not_sbtw_self_left @[simp] theorem not_sbtw_self_right (x y : P) : ¬Sbtw R x y y := fun h => h.ne_right rfl #align not_sbtw_self_right not_sbtw_self_right variable {R} theorem Wbtw.left_ne_right_of_ne_left {x y z : P} (h : Wbtw R x y z) (hne : y ≠ x) : x ≠ z := by rintro rfl rw [wbtw_self_iff] at h exact hne h #align wbtw.left_ne_right_of_ne_left Wbtw.left_ne_right_of_ne_left theorem Wbtw.left_ne_right_of_ne_right {x y z : P} (h : Wbtw R x y z) (hne : y ≠ z) : x ≠ z := by rintro rfl rw [wbtw_self_iff] at h exact hne h #align wbtw.left_ne_right_of_ne_right Wbtw.left_ne_right_of_ne_right theorem Sbtw.left_ne_right {x y z : P} (h : Sbtw R x y z) : x ≠ z := h.wbtw.left_ne_right_of_ne_left h.2.1 #align sbtw.left_ne_right Sbtw.left_ne_right theorem sbtw_iff_mem_image_Ioo_and_ne [NoZeroSMulDivisors R V] {x y z : P} : Sbtw R x y z ↔ y ∈ lineMap x z '' Set.Ioo (0 : R) 1 ∧ x ≠ z := by refine ⟨fun h => ⟨h.mem_image_Ioo, h.left_ne_right⟩, fun h => ?_⟩ rcases h with ⟨⟨t, ht, rfl⟩, hxz⟩ refine ⟨⟨t, Set.mem_Icc_of_Ioo ht, rfl⟩, ?_⟩ rw [lineMap_apply, ← @vsub_ne_zero V, ← @vsub_ne_zero V _ _ _ _ z, vadd_vsub_assoc, vsub_self, vadd_vsub_assoc, ← neg_vsub_eq_vsub_rev z x, ← @neg_one_smul R, ← add_smul, ← sub_eq_add_neg] simp [smul_ne_zero, sub_eq_zero, ht.1.ne.symm, ht.2.ne, hxz.symm] #align sbtw_iff_mem_image_Ioo_and_ne sbtw_iff_mem_image_Ioo_and_ne variable (R) @[simp] theorem not_sbtw_self (x y : P) : ¬Sbtw R x y x := fun h => h.left_ne_right rfl #align not_sbtw_self not_sbtw_self theorem wbtw_swap_left_iff [NoZeroSMulDivisors R V] {x y : P} (z : P) : Wbtw R x y z ∧ Wbtw R y x z ↔ x = y := by constructor · rintro ⟨hxyz, hyxz⟩ rcases hxyz with ⟨ty, hty, rfl⟩ rcases hyxz with ⟨tx, htx, hx⟩ rw [lineMap_apply, lineMap_apply, ← add_vadd] at hx rw [← @vsub_eq_zero_iff_eq V, vadd_vsub, vsub_vadd_eq_vsub_sub, smul_sub, smul_smul, ← sub_smul, ← add_smul, smul_eq_zero] at hx rcases hx with (h | h) · nth_rw 1 [← mul_one tx] at h rw [← mul_sub, add_eq_zero_iff_neg_eq] at h have h' : ty = 0 := by refine le_antisymm ?_ hty.1 rw [← h, Left.neg_nonpos_iff] exact mul_nonneg htx.1 (sub_nonneg.2 hty.2) simp [h'] · rw [vsub_eq_zero_iff_eq] at h rw [h, lineMap_same_apply] · rintro rfl exact ⟨wbtw_self_left _ _ _, wbtw_self_left _ _ _⟩ #align wbtw_swap_left_iff wbtw_swap_left_iff
Mathlib/Analysis/Convex/Between.lean
377
380
theorem wbtw_swap_right_iff [NoZeroSMulDivisors R V] (x : P) {y z : P} : Wbtw R x y z ∧ Wbtw R x z y ↔ y = z := by
rw [wbtw_comm, wbtw_comm (z := y), eq_comm] exact wbtw_swap_left_iff R x
import Mathlib.Algebra.Associated import Mathlib.Algebra.Star.Unitary import Mathlib.RingTheory.Int.Basic import Mathlib.RingTheory.PrincipalIdealDomain import Mathlib.Tactic.Ring #align_import number_theory.zsqrtd.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" @[ext] structure Zsqrtd (d : ℤ) where re : ℤ im : ℤ deriving DecidableEq #align zsqrtd Zsqrtd #align zsqrtd.ext Zsqrtd.ext_iff prefix:100 "ℤ√" => Zsqrtd namespace Zsqrtd section variable {d : ℤ} def ofInt (n : ℤ) : ℤ√d := ⟨n, 0⟩ #align zsqrtd.of_int Zsqrtd.ofInt theorem ofInt_re (n : ℤ) : (ofInt n : ℤ√d).re = n := rfl #align zsqrtd.of_int_re Zsqrtd.ofInt_re theorem ofInt_im (n : ℤ) : (ofInt n : ℤ√d).im = 0 := rfl #align zsqrtd.of_int_im Zsqrtd.ofInt_im instance : Zero (ℤ√d) := ⟨ofInt 0⟩ @[simp] theorem zero_re : (0 : ℤ√d).re = 0 := rfl #align zsqrtd.zero_re Zsqrtd.zero_re @[simp] theorem zero_im : (0 : ℤ√d).im = 0 := rfl #align zsqrtd.zero_im Zsqrtd.zero_im instance : Inhabited (ℤ√d) := ⟨0⟩ instance : One (ℤ√d) := ⟨ofInt 1⟩ @[simp] theorem one_re : (1 : ℤ√d).re = 1 := rfl #align zsqrtd.one_re Zsqrtd.one_re @[simp] theorem one_im : (1 : ℤ√d).im = 0 := rfl #align zsqrtd.one_im Zsqrtd.one_im def sqrtd : ℤ√d := ⟨0, 1⟩ #align zsqrtd.sqrtd Zsqrtd.sqrtd @[simp] theorem sqrtd_re : (sqrtd : ℤ√d).re = 0 := rfl #align zsqrtd.sqrtd_re Zsqrtd.sqrtd_re @[simp] theorem sqrtd_im : (sqrtd : ℤ√d).im = 1 := rfl #align zsqrtd.sqrtd_im Zsqrtd.sqrtd_im instance : Add (ℤ√d) := ⟨fun z w => ⟨z.1 + w.1, z.2 + w.2⟩⟩ @[simp] theorem add_def (x y x' y' : ℤ) : (⟨x, y⟩ + ⟨x', y'⟩ : ℤ√d) = ⟨x + x', y + y'⟩ := rfl #align zsqrtd.add_def Zsqrtd.add_def @[simp] theorem add_re (z w : ℤ√d) : (z + w).re = z.re + w.re := rfl #align zsqrtd.add_re Zsqrtd.add_re @[simp] theorem add_im (z w : ℤ√d) : (z + w).im = z.im + w.im := rfl #align zsqrtd.add_im Zsqrtd.add_im #noalign zsqrtd.bit0_re #noalign zsqrtd.bit0_im #noalign zsqrtd.bit1_re #noalign zsqrtd.bit1_im instance : Neg (ℤ√d) := ⟨fun z => ⟨-z.1, -z.2⟩⟩ @[simp] theorem neg_re (z : ℤ√d) : (-z).re = -z.re := rfl #align zsqrtd.neg_re Zsqrtd.neg_re @[simp] theorem neg_im (z : ℤ√d) : (-z).im = -z.im := rfl #align zsqrtd.neg_im Zsqrtd.neg_im instance : Mul (ℤ√d) := ⟨fun z w => ⟨z.1 * w.1 + d * z.2 * w.2, z.1 * w.2 + z.2 * w.1⟩⟩ @[simp] theorem mul_re (z w : ℤ√d) : (z * w).re = z.re * w.re + d * z.im * w.im := rfl #align zsqrtd.mul_re Zsqrtd.mul_re @[simp] theorem mul_im (z w : ℤ√d) : (z * w).im = z.re * w.im + z.im * w.re := rfl #align zsqrtd.mul_im Zsqrtd.mul_im instance addCommGroup : AddCommGroup (ℤ√d) := by refine { add := (· + ·) zero := (0 : ℤ√d) sub := fun a b => a + -b neg := Neg.neg nsmul := @nsmulRec (ℤ√d) ⟨0⟩ ⟨(· + ·)⟩ zsmul := @zsmulRec (ℤ√d) ⟨0⟩ ⟨(· + ·)⟩ ⟨Neg.neg⟩ (@nsmulRec (ℤ√d) ⟨0⟩ ⟨(· + ·)⟩) add_assoc := ?_ zero_add := ?_ add_zero := ?_ add_left_neg := ?_ add_comm := ?_ } <;> intros <;> ext <;> simp [add_comm, add_left_comm] @[simp] theorem sub_re (z w : ℤ√d) : (z - w).re = z.re - w.re := rfl @[simp] theorem sub_im (z w : ℤ√d) : (z - w).im = z.im - w.im := rfl instance addGroupWithOne : AddGroupWithOne (ℤ√d) := { Zsqrtd.addCommGroup with natCast := fun n => ofInt n intCast := ofInt one := 1 } instance commRing : CommRing (ℤ√d) := by refine { Zsqrtd.addGroupWithOne with mul := (· * ·) npow := @npowRec (ℤ√d) ⟨1⟩ ⟨(· * ·)⟩, add_comm := ?_ left_distrib := ?_ right_distrib := ?_ zero_mul := ?_ mul_zero := ?_ mul_assoc := ?_ one_mul := ?_ mul_one := ?_ mul_comm := ?_ } <;> intros <;> ext <;> simp <;> ring instance : AddMonoid (ℤ√d) := by infer_instance instance : Monoid (ℤ√d) := by infer_instance instance : CommMonoid (ℤ√d) := by infer_instance instance : CommSemigroup (ℤ√d) := by infer_instance instance : Semigroup (ℤ√d) := by infer_instance instance : AddCommSemigroup (ℤ√d) := by infer_instance instance : AddSemigroup (ℤ√d) := by infer_instance instance : CommSemiring (ℤ√d) := by infer_instance instance : Semiring (ℤ√d) := by infer_instance instance : Ring (ℤ√d) := by infer_instance instance : Distrib (ℤ√d) := by infer_instance instance : Star (ℤ√d) where star z := ⟨z.1, -z.2⟩ @[simp] theorem star_mk (x y : ℤ) : star (⟨x, y⟩ : ℤ√d) = ⟨x, -y⟩ := rfl #align zsqrtd.star_mk Zsqrtd.star_mk @[simp] theorem star_re (z : ℤ√d) : (star z).re = z.re := rfl #align zsqrtd.star_re Zsqrtd.star_re @[simp] theorem star_im (z : ℤ√d) : (star z).im = -z.im := rfl #align zsqrtd.star_im Zsqrtd.star_im instance : StarRing (ℤ√d) where star_involutive x := Zsqrtd.ext _ _ rfl (neg_neg _) star_mul a b := by ext <;> simp <;> ring star_add a b := Zsqrtd.ext _ _ rfl (neg_add _ _) -- Porting note: proof was `by decide` instance nontrivial : Nontrivial (ℤ√d) := ⟨⟨0, 1, (Zsqrtd.ext_iff 0 1).not.mpr (by simp)⟩⟩ @[simp] theorem natCast_re (n : ℕ) : (n : ℤ√d).re = n := rfl #align zsqrtd.coe_nat_re Zsqrtd.natCast_re @[simp] theorem ofNat_re (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n) : ℤ√d).re = n := rfl @[simp] theorem natCast_im (n : ℕ) : (n : ℤ√d).im = 0 := rfl #align zsqrtd.coe_nat_im Zsqrtd.natCast_im @[simp] theorem ofNat_im (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n) : ℤ√d).im = 0 := rfl theorem natCast_val (n : ℕ) : (n : ℤ√d) = ⟨n, 0⟩ := rfl #align zsqrtd.coe_nat_val Zsqrtd.natCast_val @[simp] theorem intCast_re (n : ℤ) : (n : ℤ√d).re = n := by cases n <;> rfl #align zsqrtd.coe_int_re Zsqrtd.intCast_re @[simp] theorem intCast_im (n : ℤ) : (n : ℤ√d).im = 0 := by cases n <;> rfl #align zsqrtd.coe_int_im Zsqrtd.intCast_im theorem intCast_val (n : ℤ) : (n : ℤ√d) = ⟨n, 0⟩ := by ext <;> simp #align zsqrtd.coe_int_val Zsqrtd.intCast_val instance : CharZero (ℤ√d) where cast_injective m n := by simp [Zsqrtd.ext_iff] @[simp] theorem ofInt_eq_intCast (n : ℤ) : (ofInt n : ℤ√d) = n := by ext <;> simp [ofInt_re, ofInt_im] #align zsqrtd.of_int_eq_coe Zsqrtd.ofInt_eq_intCast @[deprecated (since := "2024-04-05")] alias coe_nat_re := natCast_re @[deprecated (since := "2024-04-05")] alias coe_nat_im := natCast_im @[deprecated (since := "2024-04-05")] alias coe_nat_val := natCast_val @[deprecated (since := "2024-04-05")] alias coe_int_re := intCast_re @[deprecated (since := "2024-04-05")] alias coe_int_im := intCast_im @[deprecated (since := "2024-04-05")] alias coe_int_val := intCast_val @[deprecated (since := "2024-04-05")] alias ofInt_eq_coe := ofInt_eq_intCast @[simp] theorem smul_val (n x y : ℤ) : (n : ℤ√d) * ⟨x, y⟩ = ⟨n * x, n * y⟩ := by ext <;> simp #align zsqrtd.smul_val Zsqrtd.smul_val theorem smul_re (a : ℤ) (b : ℤ√d) : (↑a * b).re = a * b.re := by simp #align zsqrtd.smul_re Zsqrtd.smul_re theorem smul_im (a : ℤ) (b : ℤ√d) : (↑a * b).im = a * b.im := by simp #align zsqrtd.smul_im Zsqrtd.smul_im @[simp] theorem muld_val (x y : ℤ) : sqrtd (d := d) * ⟨x, y⟩ = ⟨d * y, x⟩ := by ext <;> simp #align zsqrtd.muld_val Zsqrtd.muld_val @[simp] theorem dmuld : sqrtd (d := d) * sqrtd (d := d) = d := by ext <;> simp #align zsqrtd.dmuld Zsqrtd.dmuld @[simp] theorem smuld_val (n x y : ℤ) : sqrtd * (n : ℤ√d) * ⟨x, y⟩ = ⟨d * n * y, n * x⟩ := by ext <;> simp #align zsqrtd.smuld_val Zsqrtd.smuld_val theorem decompose {x y : ℤ} : (⟨x, y⟩ : ℤ√d) = x + sqrtd (d := d) * y := by ext <;> simp #align zsqrtd.decompose Zsqrtd.decompose theorem mul_star {x y : ℤ} : (⟨x, y⟩ * star ⟨x, y⟩ : ℤ√d) = x * x - d * y * y := by ext <;> simp [sub_eq_add_neg, mul_comm] #align zsqrtd.mul_star Zsqrtd.mul_star @[deprecated (since := "2024-05-25")] alias coe_int_add := Int.cast_add @[deprecated (since := "2024-05-25")] alias coe_int_sub := Int.cast_sub @[deprecated (since := "2024-05-25")] alias coe_int_mul := Int.cast_mul @[deprecated (since := "2024-05-25")] alias coe_int_inj := Int.cast_inj theorem intCast_dvd (z : ℤ) (a : ℤ√d) : ↑z ∣ a ↔ z ∣ a.re ∧ z ∣ a.im := by constructor · rintro ⟨x, rfl⟩ simp only [add_zero, intCast_re, zero_mul, mul_im, dvd_mul_right, and_self_iff, mul_re, mul_zero, intCast_im] · rintro ⟨⟨r, hr⟩, ⟨i, hi⟩⟩ use ⟨r, i⟩ rw [smul_val, Zsqrtd.ext_iff] exact ⟨hr, hi⟩ #align zsqrtd.coe_int_dvd_iff Zsqrtd.intCast_dvd @[simp, norm_cast] theorem intCast_dvd_intCast (a b : ℤ) : (a : ℤ√d) ∣ b ↔ a ∣ b := by rw [intCast_dvd] constructor · rintro ⟨hre, -⟩ rwa [intCast_re] at hre · rw [intCast_re, intCast_im] exact fun hc => ⟨hc, dvd_zero a⟩ #align zsqrtd.coe_int_dvd_coe_int Zsqrtd.intCast_dvd_intCast @[deprecated (since := "2024-05-25")] alias coe_int_dvd_iff := intCast_dvd @[deprecated (since := "2024-05-25")] alias coe_int_dvd_coe_int := intCast_dvd_intCast protected theorem eq_of_smul_eq_smul_left {a : ℤ} {b c : ℤ√d} (ha : a ≠ 0) (h : ↑a * b = a * c) : b = c := by rw [Zsqrtd.ext_iff] at h ⊢ apply And.imp _ _ h <;> simpa only [smul_re, smul_im] using mul_left_cancel₀ ha #align zsqrtd.eq_of_smul_eq_smul_left Zsqrtd.eq_of_smul_eq_smul_left def SqLe (a c b d : ℕ) : Prop := c * a * a ≤ d * b * b #align zsqrtd.sq_le Zsqrtd.SqLe theorem sqLe_of_le {c d x y z w : ℕ} (xz : z ≤ x) (yw : y ≤ w) (xy : SqLe x c y d) : SqLe z c w d := le_trans (mul_le_mul (Nat.mul_le_mul_left _ xz) xz (Nat.zero_le _) (Nat.zero_le _)) <| le_trans xy (mul_le_mul (Nat.mul_le_mul_left _ yw) yw (Nat.zero_le _) (Nat.zero_le _)) #align zsqrtd.sq_le_of_le Zsqrtd.sqLe_of_le theorem sqLe_add_mixed {c d x y z w : ℕ} (xy : SqLe x c y d) (zw : SqLe z c w d) : c * (x * z) ≤ d * (y * w) := Nat.mul_self_le_mul_self_iff.1 <| by simpa [mul_comm, mul_left_comm] using mul_le_mul xy zw (Nat.zero_le _) (Nat.zero_le _) #align zsqrtd.sq_le_add_mixed Zsqrtd.sqLe_add_mixed theorem sqLe_add {c d x y z w : ℕ} (xy : SqLe x c y d) (zw : SqLe z c w d) : SqLe (x + z) c (y + w) d := by have xz := sqLe_add_mixed xy zw simp? [SqLe, mul_assoc] at xy zw says simp only [SqLe, mul_assoc] at xy zw simp [SqLe, mul_add, mul_comm, mul_left_comm, add_le_add, *] #align zsqrtd.sq_le_add Zsqrtd.sqLe_add theorem sqLe_cancel {c d x y z w : ℕ} (zw : SqLe y d x c) (h : SqLe (x + z) c (y + w) d) : SqLe z c w d := by apply le_of_not_gt intro l refine not_le_of_gt ?_ h simp only [SqLe, mul_add, mul_comm, mul_left_comm, add_assoc, gt_iff_lt] have hm := sqLe_add_mixed zw (le_of_lt l) simp only [SqLe, mul_assoc, gt_iff_lt] at l zw exact lt_of_le_of_lt (add_le_add_right zw _) (add_lt_add_left (add_lt_add_of_le_of_lt hm (add_lt_add_of_le_of_lt hm l)) _) #align zsqrtd.sq_le_cancel Zsqrtd.sqLe_cancel theorem sqLe_smul {c d x y : ℕ} (n : ℕ) (xy : SqLe x c y d) : SqLe (n * x) c (n * y) d := by simpa [SqLe, mul_left_comm, mul_assoc] using Nat.mul_le_mul_left (n * n) xy #align zsqrtd.sq_le_smul Zsqrtd.sqLe_smul theorem sqLe_mul {d x y z w : ℕ} : (SqLe x 1 y d → SqLe z 1 w d → SqLe (x * w + y * z) d (x * z + d * y * w) 1) ∧ (SqLe x 1 y d → SqLe w d z 1 → SqLe (x * z + d * y * w) 1 (x * w + y * z) d) ∧ (SqLe y d x 1 → SqLe z 1 w d → SqLe (x * z + d * y * w) 1 (x * w + y * z) d) ∧ (SqLe y d x 1 → SqLe w d z 1 → SqLe (x * w + y * z) d (x * z + d * y * w) 1) := by refine ⟨?_, ?_, ?_, ?_⟩ <;> · intro xy zw have := Int.mul_nonneg (sub_nonneg_of_le (Int.ofNat_le_ofNat_of_le xy)) (sub_nonneg_of_le (Int.ofNat_le_ofNat_of_le zw)) refine Int.le_of_ofNat_le_ofNat (le_of_sub_nonneg ?_) convert this using 1 simp only [one_mul, Int.ofNat_add, Int.ofNat_mul] ring #align zsqrtd.sq_le_mul Zsqrtd.sqLe_mul open Int in def Nonnegg (c d : ℕ) : ℤ → ℤ → Prop | (a : ℕ), (b : ℕ) => True | (a : ℕ), -[b+1] => SqLe (b + 1) c a d | -[a+1], (b : ℕ) => SqLe (a + 1) d b c | -[_+1], -[_+1] => False #align zsqrtd.nonnegg Zsqrtd.Nonnegg theorem nonnegg_comm {c d : ℕ} {x y : ℤ} : Nonnegg c d x y = Nonnegg d c y x := by induction x <;> induction y <;> rfl #align zsqrtd.nonnegg_comm Zsqrtd.nonnegg_comm theorem nonnegg_neg_pos {c d} : ∀ {a b : ℕ}, Nonnegg c d (-a) b ↔ SqLe a d b c | 0, b => ⟨by simp [SqLe, Nat.zero_le], fun _ => trivial⟩ | a + 1, b => by rw [← Int.negSucc_coe]; rfl #align zsqrtd.nonnegg_neg_pos Zsqrtd.nonnegg_neg_pos theorem nonnegg_pos_neg {c d} {a b : ℕ} : Nonnegg c d a (-b) ↔ SqLe b c a d := by rw [nonnegg_comm]; exact nonnegg_neg_pos #align zsqrtd.nonnegg_pos_neg Zsqrtd.nonnegg_pos_neg open Int in theorem nonnegg_cases_right {c d} {a : ℕ} : ∀ {b : ℤ}, (∀ x : ℕ, b = -x → SqLe x c a d) → Nonnegg c d a b | (b : Nat), _ => trivial | -[b+1], h => h (b + 1) rfl #align zsqrtd.nonnegg_cases_right Zsqrtd.nonnegg_cases_right theorem nonnegg_cases_left {c d} {b : ℕ} {a : ℤ} (h : ∀ x : ℕ, a = -x → SqLe x d b c) : Nonnegg c d a b := cast nonnegg_comm (nonnegg_cases_right h) #align zsqrtd.nonnegg_cases_left Zsqrtd.nonnegg_cases_left end section variable {d : ℕ} def Nonneg : ℤ√d → Prop | ⟨a, b⟩ => Nonnegg d 1 a b #align zsqrtd.nonneg Zsqrtd.Nonneg instance : LE (ℤ√d) := ⟨fun a b => Nonneg (b - a)⟩ instance : LT (ℤ√d) := ⟨fun a b => ¬b ≤ a⟩ instance decidableNonnegg (c d a b) : Decidable (Nonnegg c d a b) := by cases a <;> cases b <;> unfold Nonnegg SqLe <;> infer_instance #align zsqrtd.decidable_nonnegg Zsqrtd.decidableNonnegg instance decidableNonneg : ∀ a : ℤ√d, Decidable (Nonneg a) | ⟨_, _⟩ => Zsqrtd.decidableNonnegg _ _ _ _ #align zsqrtd.decidable_nonneg Zsqrtd.decidableNonneg instance decidableLE : @DecidableRel (ℤ√d) (· ≤ ·) := fun _ _ => decidableNonneg _ #align zsqrtd.decidable_le Zsqrtd.decidableLE open Int in theorem nonneg_cases : ∀ {a : ℤ√d}, Nonneg a → ∃ x y : ℕ, a = ⟨x, y⟩ ∨ a = ⟨x, -y⟩ ∨ a = ⟨-x, y⟩ | ⟨(x : ℕ), (y : ℕ)⟩, _ => ⟨x, y, Or.inl rfl⟩ | ⟨(x : ℕ), -[y+1]⟩, _ => ⟨x, y + 1, Or.inr <| Or.inl rfl⟩ | ⟨-[x+1], (y : ℕ)⟩, _ => ⟨x + 1, y, Or.inr <| Or.inr rfl⟩ | ⟨-[_+1], -[_+1]⟩, h => False.elim h #align zsqrtd.nonneg_cases Zsqrtd.nonneg_cases open Int in theorem nonneg_add_lem {x y z w : ℕ} (xy : Nonneg (⟨x, -y⟩ : ℤ√d)) (zw : Nonneg (⟨-z, w⟩ : ℤ√d)) : Nonneg (⟨x, -y⟩ + ⟨-z, w⟩ : ℤ√d) := by have : Nonneg ⟨Int.subNatNat x z, Int.subNatNat w y⟩ := Int.subNatNat_elim x z (fun m n i => SqLe y d m 1 → SqLe n 1 w d → Nonneg ⟨i, Int.subNatNat w y⟩) (fun j k => Int.subNatNat_elim w y (fun m n i => SqLe n d (k + j) 1 → SqLe k 1 m d → Nonneg ⟨Int.ofNat j, i⟩) (fun _ _ _ _ => trivial) fun m n xy zw => sqLe_cancel zw xy) (fun j k => Int.subNatNat_elim w y (fun m n i => SqLe n d k 1 → SqLe (k + j + 1) 1 m d → Nonneg ⟨-[j+1], i⟩) (fun m n xy zw => sqLe_cancel xy zw) fun m n xy zw => let t := Nat.le_trans zw (sqLe_of_le (Nat.le_add_right n (m + 1)) le_rfl xy) have : k + j + 1 ≤ k := Nat.mul_self_le_mul_self_iff.1 (by simpa [one_mul] using t) absurd this (not_le_of_gt <| Nat.succ_le_succ <| Nat.le_add_right _ _)) (nonnegg_pos_neg.1 xy) (nonnegg_neg_pos.1 zw) rw [add_def, neg_add_eq_sub] rwa [Int.subNatNat_eq_coe, Int.subNatNat_eq_coe] at this #align zsqrtd.nonneg_add_lem Zsqrtd.nonneg_add_lem theorem Nonneg.add {a b : ℤ√d} (ha : Nonneg a) (hb : Nonneg b) : Nonneg (a + b) := by rcases nonneg_cases ha with ⟨x, y, rfl | rfl | rfl⟩ <;> rcases nonneg_cases hb with ⟨z, w, rfl | rfl | rfl⟩ · trivial · refine nonnegg_cases_right fun i h => sqLe_of_le ?_ ?_ (nonnegg_pos_neg.1 hb) · dsimp only at h exact Int.ofNat_le.1 (le_of_neg_le_neg (Int.le.intro y (by simp [add_comm, *]))) · apply Nat.le_add_left · refine nonnegg_cases_left fun i h => sqLe_of_le ?_ ?_ (nonnegg_neg_pos.1 hb) · dsimp only at h exact Int.ofNat_le.1 (le_of_neg_le_neg (Int.le.intro x (by simp [add_comm, *]))) · apply Nat.le_add_left · refine nonnegg_cases_right fun i h => sqLe_of_le ?_ ?_ (nonnegg_pos_neg.1 ha) · dsimp only at h exact Int.ofNat_le.1 (le_of_neg_le_neg (Int.le.intro w (by simp [*]))) · apply Nat.le_add_right · have : Nonneg ⟨_, _⟩ := nonnegg_pos_neg.2 (sqLe_add (nonnegg_pos_neg.1 ha) (nonnegg_pos_neg.1 hb)) rw [Nat.cast_add, Nat.cast_add, neg_add] at this rwa [add_def] -- Porting note: was -- simpa [add_comm] using -- nonnegg_pos_neg.2 (sqLe_add (nonnegg_pos_neg.1 ha) (nonnegg_pos_neg.1 hb)) · exact nonneg_add_lem ha hb · refine nonnegg_cases_left fun i h => sqLe_of_le ?_ ?_ (nonnegg_neg_pos.1 ha) · dsimp only at h exact Int.ofNat_le.1 (le_of_neg_le_neg (Int.le.intro _ h)) · apply Nat.le_add_right · dsimp rw [add_comm, add_comm (y : ℤ)] exact nonneg_add_lem hb ha · have : Nonneg ⟨_, _⟩ := nonnegg_neg_pos.2 (sqLe_add (nonnegg_neg_pos.1 ha) (nonnegg_neg_pos.1 hb)) rw [Nat.cast_add, Nat.cast_add, neg_add] at this rwa [add_def] -- Porting note: was -- simpa [add_comm] using -- nonnegg_neg_pos.2 (sqLe_add (nonnegg_neg_pos.1 ha) (nonnegg_neg_pos.1 hb)) #align zsqrtd.nonneg.add Zsqrtd.Nonneg.add theorem nonneg_iff_zero_le {a : ℤ√d} : Nonneg a ↔ 0 ≤ a := show _ ↔ Nonneg _ by simp #align zsqrtd.nonneg_iff_zero_le Zsqrtd.nonneg_iff_zero_le theorem le_of_le_le {x y z w : ℤ} (xz : x ≤ z) (yw : y ≤ w) : (⟨x, y⟩ : ℤ√d) ≤ ⟨z, w⟩ := show Nonneg ⟨z - x, w - y⟩ from match z - x, w - y, Int.le.dest_sub xz, Int.le.dest_sub yw with | _, _, ⟨_, rfl⟩, ⟨_, rfl⟩ => trivial #align zsqrtd.le_of_le_le Zsqrtd.le_of_le_le open Int in protected theorem nonneg_total : ∀ a : ℤ√d, Nonneg a ∨ Nonneg (-a) | ⟨(x : ℕ), (y : ℕ)⟩ => Or.inl trivial | ⟨-[_+1], -[_+1]⟩ => Or.inr trivial | ⟨0, -[_+1]⟩ => Or.inr trivial | ⟨-[_+1], 0⟩ => Or.inr trivial | ⟨(_ + 1 : ℕ), -[_+1]⟩ => Nat.le_total _ _ | ⟨-[_+1], (_ + 1 : ℕ)⟩ => Nat.le_total _ _ #align zsqrtd.nonneg_total Zsqrtd.nonneg_total protected theorem le_total (a b : ℤ√d) : a ≤ b ∨ b ≤ a := by have t := (b - a).nonneg_total rwa [neg_sub] at t #align zsqrtd.le_total Zsqrtd.le_total instance preorder : Preorder (ℤ√d) where le := (· ≤ ·) le_refl a := show Nonneg (a - a) by simp only [sub_self]; trivial le_trans a b c hab hbc := by simpa [sub_add_sub_cancel'] using hab.add hbc lt := (· < ·) lt_iff_le_not_le a b := (and_iff_right_of_imp (Zsqrtd.le_total _ _).resolve_left).symm open Int in theorem le_arch (a : ℤ√d) : ∃ n : ℕ, a ≤ n := by obtain ⟨x, y, (h : a ≤ ⟨x, y⟩)⟩ : ∃ x y : ℕ, Nonneg (⟨x, y⟩ + -a) := match -a with | ⟨Int.ofNat x, Int.ofNat y⟩ => ⟨0, 0, by trivial⟩ | ⟨Int.ofNat x, -[y+1]⟩ => ⟨0, y + 1, by simp [add_def, Int.negSucc_coe, add_assoc]; trivial⟩ | ⟨-[x+1], Int.ofNat y⟩ => ⟨x + 1, 0, by simp [Int.negSucc_coe, add_assoc]; trivial⟩ | ⟨-[x+1], -[y+1]⟩ => ⟨x + 1, y + 1, by simp [Int.negSucc_coe, add_assoc]; trivial⟩ refine ⟨x + d * y, h.trans ?_⟩ change Nonneg ⟨↑x + d * y - ↑x, 0 - ↑y⟩ cases' y with y · simp trivial have h : ∀ y, SqLe y d (d * y) 1 := fun y => by simpa [SqLe, mul_comm, mul_left_comm] using Nat.mul_le_mul_right (y * y) (Nat.le_mul_self d) rw [show (x : ℤ) + d * Nat.succ y - x = d * Nat.succ y by simp] exact h (y + 1) #align zsqrtd.le_arch Zsqrtd.le_arch protected theorem add_le_add_left (a b : ℤ√d) (ab : a ≤ b) (c : ℤ√d) : c + a ≤ c + b := show Nonneg _ by rw [add_sub_add_left_eq_sub]; exact ab #align zsqrtd.add_le_add_left Zsqrtd.add_le_add_left protected theorem le_of_add_le_add_left (a b c : ℤ√d) (h : c + a ≤ c + b) : a ≤ b := by simpa using Zsqrtd.add_le_add_left _ _ h (-c) #align zsqrtd.le_of_add_le_add_left Zsqrtd.le_of_add_le_add_left protected theorem add_lt_add_left (a b : ℤ√d) (h : a < b) (c) : c + a < c + b := fun h' => h (Zsqrtd.le_of_add_le_add_left _ _ _ h') #align zsqrtd.add_lt_add_left Zsqrtd.add_lt_add_left theorem nonneg_smul {a : ℤ√d} {n : ℕ} (ha : Nonneg a) : Nonneg ((n : ℤ√d) * a) := by rw [← Int.cast_natCast n] exact match a, nonneg_cases ha, ha with | _, ⟨x, y, Or.inl rfl⟩, _ => by rw [smul_val]; trivial | _, ⟨x, y, Or.inr <| Or.inl rfl⟩, ha => by rw [smul_val]; simpa using nonnegg_pos_neg.2 (sqLe_smul n <| nonnegg_pos_neg.1 ha) | _, ⟨x, y, Or.inr <| Or.inr rfl⟩, ha => by rw [smul_val]; simpa using nonnegg_neg_pos.2 (sqLe_smul n <| nonnegg_neg_pos.1 ha) #align zsqrtd.nonneg_smul Zsqrtd.nonneg_smul theorem nonneg_muld {a : ℤ√d} (ha : Nonneg a) : Nonneg (sqrtd * a) := match a, nonneg_cases ha, ha with | _, ⟨_, _, Or.inl rfl⟩, _ => trivial | _, ⟨x, y, Or.inr <| Or.inl rfl⟩, ha => by simp only [muld_val, mul_neg] apply nonnegg_neg_pos.2 simpa [SqLe, mul_comm, mul_left_comm] using Nat.mul_le_mul_left d (nonnegg_pos_neg.1 ha) | _, ⟨x, y, Or.inr <| Or.inr rfl⟩, ha => by simp only [muld_val] apply nonnegg_pos_neg.2 simpa [SqLe, mul_comm, mul_left_comm] using Nat.mul_le_mul_left d (nonnegg_neg_pos.1 ha) #align zsqrtd.nonneg_muld Zsqrtd.nonneg_muld
Mathlib/NumberTheory/Zsqrtd/Basic.lean
806
810
theorem nonneg_mul_lem {x y : ℕ} {a : ℤ√d} (ha : Nonneg a) : Nonneg (⟨x, y⟩ * a) := by
have : (⟨x, y⟩ * a : ℤ√d) = (x : ℤ√d) * a + sqrtd * ((y : ℤ√d) * a) := by rw [decompose, right_distrib, mul_assoc, Int.cast_natCast, Int.cast_natCast] rw [this] exact (nonneg_smul ha).add (nonneg_muld <| nonneg_smul ha)
import Mathlib.Algebra.Category.GroupCat.Preadditive import Mathlib.GroupTheory.QuotientGroup import Mathlib.CategoryTheory.Limits.Shapes.Kernels import Mathlib.CategoryTheory.Limits.Shapes.FiniteLimits import Mathlib.CategoryTheory.ConcreteCategory.Elementwise #align_import algebra.category.Group.colimits from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" -- Porting note: `AddCommGroup` in all the names set_option linter.uppercaseLean3 false universe w u v open CategoryTheory Limits -- [ROBOT VOICE]: -- You should pretend for now that this file was automatically generated. -- It follows the same template as colimits in Mon. namespace AddCommGroupCat variable {J : Type u} [Category.{v} J] (F : J ⥤ AddCommGroupCat.{max u v w}) namespace Colimits inductive Prequotient -- There's always `of` | of : ∀ (j : J) (_ : F.obj j), Prequotient -- Then one generator for each operation | zero : Prequotient | neg : Prequotient → Prequotient | add : Prequotient → Prequotient → Prequotient #align AddCommGroup.colimits.prequotient AddCommGroupCat.Colimits.Prequotient instance : Inhabited (Prequotient.{w} F) := ⟨Prequotient.zero⟩ open Prequotient inductive Relation : Prequotient.{w} F → Prequotient.{w} F → Prop -- Make it an equivalence relation: | refl : ∀ x, Relation x x | symm : ∀ (x y) (_ : Relation x y), Relation y x | trans : ∀ (x y z) (_ : Relation x y) (_ : Relation y z), Relation x z -- There's always a `map` relation | map : ∀ (j j' : J) (f : j ⟶ j') (x : F.obj j), Relation (Prequotient.of j' (F.map f x)) (Prequotient.of j x) -- Then one relation per operation, describing the interaction with `of` | zero : ∀ j, Relation (Prequotient.of j 0) zero | neg : ∀ (j) (x : F.obj j), Relation (Prequotient.of j (-x)) (neg (Prequotient.of j x)) | add : ∀ (j) (x y : F.obj j), Relation (Prequotient.of j (x + y)) (add (Prequotient.of j x) (Prequotient.of j y)) -- Then one relation per argument of each operation | neg_1 : ∀ (x x') (_ : Relation x x'), Relation (neg x) (neg x') | add_1 : ∀ (x x' y) (_ : Relation x x'), Relation (add x y) (add x' y) | add_2 : ∀ (x y y') (_ : Relation y y'), Relation (add x y) (add x y') -- And one relation per axiom | zero_add : ∀ x, Relation (add zero x) x | add_zero : ∀ x, Relation (add x zero) x | add_left_neg : ∀ x, Relation (add (neg x) x) zero | add_comm : ∀ x y, Relation (add x y) (add y x) | add_assoc : ∀ x y z, Relation (add (add x y) z) (add x (add y z)) #align AddCommGroup.colimits.relation AddCommGroupCat.Colimits.Relation def colimitSetoid : Setoid (Prequotient.{w} F) where r := Relation F iseqv := ⟨Relation.refl, fun r => Relation.symm _ _ r, fun r => Relation.trans _ _ _ r⟩ #align AddCommGroup.colimits.colimit_setoid AddCommGroupCat.Colimits.colimitSetoid attribute [instance] colimitSetoid def ColimitType : Type max u v w := Quotient (colimitSetoid.{w} F) #align AddCommGroup.colimits.colimit_type AddCommGroupCat.Colimits.ColimitType instance : Zero (ColimitType.{w} F) where zero := Quotient.mk _ zero instance : Neg (ColimitType.{w} F) where neg := Quotient.map neg Relation.neg_1 instance : Add (ColimitType.{w} F) where add := Quotient.map₂ add <| fun _x x' rx y _y' ry => Setoid.trans (Relation.add_1 _ _ y rx) (Relation.add_2 x' _ _ ry) instance : AddCommGroup (ColimitType.{w} F) where zero_add := Quotient.ind <| fun _ => Quotient.sound <| Relation.zero_add _ add_zero := Quotient.ind <| fun _ => Quotient.sound <| Relation.add_zero _ add_left_neg := Quotient.ind <| fun _ => Quotient.sound <| Relation.add_left_neg _ add_comm := Quotient.ind₂ <| fun _ _ => Quotient.sound <| Relation.add_comm _ _ add_assoc := Quotient.ind <| fun _ => Quotient.ind₂ <| fun _ _ => Quotient.sound <| Relation.add_assoc _ _ _ nsmul := nsmulRec zsmul := zsmulRec instance ColimitTypeInhabited : Inhabited (ColimitType.{w} F) := ⟨0⟩ @[simp] theorem quot_zero : Quot.mk Setoid.r zero = (0 : ColimitType.{w} F) := rfl #align AddCommGroup.colimits.quot_zero AddCommGroupCat.Colimits.quot_zero @[simp] theorem quot_neg (x) : -- Porting note: force Lean to treat `ColimitType F` no as `Quot _` (by exact Quot.mk Setoid.r (neg x) : ColimitType.{w} F) = -(by exact Quot.mk Setoid.r x) := rfl #align AddCommGroup.colimits.quot_neg AddCommGroupCat.Colimits.quot_neg @[simp] theorem quot_add (x y) : (by exact Quot.mk Setoid.r (add x y) : ColimitType.{w} F) = -- Porting note: force Lean to treat `ColimitType F` no as `Quot _` (by exact Quot.mk Setoid.r x) + (by exact Quot.mk Setoid.r y) := rfl #align AddCommGroup.colimits.quot_add AddCommGroupCat.Colimits.quot_add def colimit : AddCommGroupCat := AddCommGroupCat.of (ColimitType.{w} F) #align AddCommGroup.colimits.colimit AddCommGroupCat.Colimits.colimit def coconeFun (j : J) (x : F.obj j) : ColimitType.{w} F := Quot.mk _ (Prequotient.of j x) #align AddCommGroup.colimits.cocone_fun AddCommGroupCat.Colimits.coconeFun def coconeMorphism (j : J) : F.obj j ⟶ colimit.{w} F where toFun := coconeFun F j map_zero' := by apply Quot.sound; apply Relation.zero map_add' := by intros; apply Quot.sound; apply Relation.add #align AddCommGroup.colimits.cocone_morphism AddCommGroupCat.Colimits.coconeMorphism @[simp] theorem cocone_naturality {j j' : J} (f : j ⟶ j') : F.map f ≫ coconeMorphism.{w} F j' = coconeMorphism F j := by ext apply Quot.sound apply Relation.map #align AddCommGroup.colimits.cocone_naturality AddCommGroupCat.Colimits.cocone_naturality @[simp]
Mathlib/Algebra/Category/GroupCat/Colimits.lean
181
184
theorem cocone_naturality_components (j j' : J) (f : j ⟶ j') (x : F.obj j) : (coconeMorphism.{w} F j') (F.map f x) = (coconeMorphism F j) x := by
rw [← cocone_naturality F f] rfl
import Mathlib.Order.Interval.Set.OrdConnected import Mathlib.Data.Set.Lattice #align_import data.set.intervals.ord_connected_component from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7" open Interval Function OrderDual namespace Set variable {α : Type*} [LinearOrder α] {s t : Set α} {x y z : α} def ordConnectedComponent (s : Set α) (x : α) : Set α := { y | [[x, y]] ⊆ s } #align set.ord_connected_component Set.ordConnectedComponent theorem mem_ordConnectedComponent : y ∈ ordConnectedComponent s x ↔ [[x, y]] ⊆ s := Iff.rfl #align set.mem_ord_connected_component Set.mem_ordConnectedComponent theorem dual_ordConnectedComponent : ordConnectedComponent (ofDual ⁻¹' s) (toDual x) = ofDual ⁻¹' ordConnectedComponent s x := ext <| (Surjective.forall toDual.surjective).2 fun x => by rw [mem_ordConnectedComponent, dual_uIcc] rfl #align set.dual_ord_connected_component Set.dual_ordConnectedComponent theorem ordConnectedComponent_subset : ordConnectedComponent s x ⊆ s := fun _ hy => hy right_mem_uIcc #align set.ord_connected_component_subset Set.ordConnectedComponent_subset theorem subset_ordConnectedComponent {t} [h : OrdConnected s] (hs : x ∈ s) (ht : s ⊆ t) : s ⊆ ordConnectedComponent t x := fun _ hy => (h.uIcc_subset hs hy).trans ht #align set.subset_ord_connected_component Set.subset_ordConnectedComponent @[simp] theorem self_mem_ordConnectedComponent : x ∈ ordConnectedComponent s x ↔ x ∈ s := by rw [mem_ordConnectedComponent, uIcc_self, singleton_subset_iff] #align set.self_mem_ord_connected_component Set.self_mem_ordConnectedComponent @[simp] theorem nonempty_ordConnectedComponent : (ordConnectedComponent s x).Nonempty ↔ x ∈ s := ⟨fun ⟨_, hy⟩ => hy <| left_mem_uIcc, fun h => ⟨x, self_mem_ordConnectedComponent.2 h⟩⟩ #align set.nonempty_ord_connected_component Set.nonempty_ordConnectedComponent @[simp] theorem ordConnectedComponent_eq_empty : ordConnectedComponent s x = ∅ ↔ x ∉ s := by rw [← not_nonempty_iff_eq_empty, nonempty_ordConnectedComponent] #align set.ord_connected_component_eq_empty Set.ordConnectedComponent_eq_empty @[simp] theorem ordConnectedComponent_empty : ordConnectedComponent ∅ x = ∅ := ordConnectedComponent_eq_empty.2 (not_mem_empty x) #align set.ord_connected_component_empty Set.ordConnectedComponent_empty @[simp] theorem ordConnectedComponent_univ : ordConnectedComponent univ x = univ := by simp [ordConnectedComponent] #align set.ord_connected_component_univ Set.ordConnectedComponent_univ theorem ordConnectedComponent_inter (s t : Set α) (x : α) : ordConnectedComponent (s ∩ t) x = ordConnectedComponent s x ∩ ordConnectedComponent t x := by simp [ordConnectedComponent, setOf_and] #align set.ord_connected_component_inter Set.ordConnectedComponent_inter theorem mem_ordConnectedComponent_comm : y ∈ ordConnectedComponent s x ↔ x ∈ ordConnectedComponent s y := by rw [mem_ordConnectedComponent, mem_ordConnectedComponent, uIcc_comm] #align set.mem_ord_connected_component_comm Set.mem_ordConnectedComponent_comm theorem mem_ordConnectedComponent_trans (hxy : y ∈ ordConnectedComponent s x) (hyz : z ∈ ordConnectedComponent s y) : z ∈ ordConnectedComponent s x := calc [[x, z]] ⊆ [[x, y]] ∪ [[y, z]] := uIcc_subset_uIcc_union_uIcc _ ⊆ s := union_subset hxy hyz #align set.mem_ord_connected_component_trans Set.mem_ordConnectedComponent_trans theorem ordConnectedComponent_eq (h : [[x, y]] ⊆ s) : ordConnectedComponent s x = ordConnectedComponent s y := ext fun _ => ⟨mem_ordConnectedComponent_trans (mem_ordConnectedComponent_comm.2 h), mem_ordConnectedComponent_trans h⟩ #align set.ord_connected_component_eq Set.ordConnectedComponent_eq instance : OrdConnected (ordConnectedComponent s x) := ordConnected_of_uIcc_subset_left fun _ hy _ hz => (uIcc_subset_uIcc_left hz).trans hy noncomputable def ordConnectedProj (s : Set α) : s → α := fun x : s => (nonempty_ordConnectedComponent.2 x.2).some #align set.ord_connected_proj Set.ordConnectedProj theorem ordConnectedProj_mem_ordConnectedComponent (s : Set α) (x : s) : ordConnectedProj s x ∈ ordConnectedComponent s x := Nonempty.some_mem _ #align set.ord_connected_proj_mem_ord_connected_component Set.ordConnectedProj_mem_ordConnectedComponent theorem mem_ordConnectedComponent_ordConnectedProj (s : Set α) (x : s) : ↑x ∈ ordConnectedComponent s (ordConnectedProj s x) := mem_ordConnectedComponent_comm.2 <| ordConnectedProj_mem_ordConnectedComponent s x #align set.mem_ord_connected_component_ord_connected_proj Set.mem_ordConnectedComponent_ordConnectedProj @[simp] theorem ordConnectedComponent_ordConnectedProj (s : Set α) (x : s) : ordConnectedComponent s (ordConnectedProj s x) = ordConnectedComponent s x := ordConnectedComponent_eq <| mem_ordConnectedComponent_ordConnectedProj _ _ #align set.ord_connected_component_ord_connected_proj Set.ordConnectedComponent_ordConnectedProj @[simp] theorem ordConnectedProj_eq {x y : s} : ordConnectedProj s x = ordConnectedProj s y ↔ [[(x : α), y]] ⊆ s := by constructor <;> intro h · rw [← mem_ordConnectedComponent, ← ordConnectedComponent_ordConnectedProj, h, ordConnectedComponent_ordConnectedProj, self_mem_ordConnectedComponent] exact y.2 · simp only [ordConnectedProj, ordConnectedComponent_eq h] #align set.ord_connected_proj_eq Set.ordConnectedProj_eq def ordConnectedSection (s : Set α) : Set α := range <| ordConnectedProj s #align set.ord_connected_section Set.ordConnectedSection
Mathlib/Order/Interval/Set/OrdConnectedComponent.lean
142
149
theorem dual_ordConnectedSection (s : Set α) : ordConnectedSection (ofDual ⁻¹' s) = ofDual ⁻¹' ordConnectedSection s := by
simp only [ordConnectedSection] simp (config := { unfoldPartialApp := true }) only [ordConnectedProj] ext x simp only [mem_range, Subtype.exists, mem_preimage, OrderDual.exists, dual_ordConnectedComponent, ofDual_toDual] tauto
import Mathlib.Algebra.Polynomial.Degree.Definitions import Mathlib.Algebra.Polynomial.Eval import Mathlib.Algebra.Polynomial.Monic import Mathlib.Algebra.Polynomial.RingDivision import Mathlib.Tactic.Abel #align_import ring_theory.polynomial.pochhammer from "leanprover-community/mathlib"@"53b216bcc1146df1c4a0a86877890ea9f1f01589" universe u v open Polynomial open Polynomial section Semiring variable (S : Type u) [Semiring S] noncomputable def ascPochhammer : ℕ → S[X] | 0 => 1 | n + 1 => X * (ascPochhammer n).comp (X + 1) #align pochhammer ascPochhammer @[simp] theorem ascPochhammer_zero : ascPochhammer S 0 = 1 := rfl #align pochhammer_zero ascPochhammer_zero @[simp] theorem ascPochhammer_one : ascPochhammer S 1 = X := by simp [ascPochhammer] #align pochhammer_one ascPochhammer_one theorem ascPochhammer_succ_left (n : ℕ) : ascPochhammer S (n + 1) = X * (ascPochhammer S n).comp (X + 1) := by rw [ascPochhammer] #align pochhammer_succ_left ascPochhammer_succ_left theorem monic_ascPochhammer (n : ℕ) [Nontrivial S] [NoZeroDivisors S] : Monic <| ascPochhammer S n := by induction' n with n hn · simp · have : leadingCoeff (X + 1 : S[X]) = 1 := leadingCoeff_X_add_C 1 rw [ascPochhammer_succ_left, Monic.def, leadingCoeff_mul, leadingCoeff_comp (ne_zero_of_eq_one <| natDegree_X_add_C 1 : natDegree (X + 1) ≠ 0), hn, monic_X, one_mul, one_mul, this, one_pow] section variable {S} {T : Type v} [Semiring T] @[simp] theorem ascPochhammer_map (f : S →+* T) (n : ℕ) : (ascPochhammer S n).map f = ascPochhammer T n := by induction' n with n ih · simp · simp [ih, ascPochhammer_succ_left, map_comp] #align pochhammer_map ascPochhammer_map theorem ascPochhammer_eval₂ (f : S →+* T) (n : ℕ) (t : T) : (ascPochhammer T n).eval t = (ascPochhammer S n).eval₂ f t := by rw [← ascPochhammer_map f] exact eval_map f t theorem ascPochhammer_eval_comp {R : Type*} [CommSemiring R] (n : ℕ) (p : R[X]) [Algebra R S] (x : S) : ((ascPochhammer S n).comp (p.map (algebraMap R S))).eval x = (ascPochhammer S n).eval (p.eval₂ (algebraMap R S) x) := by rw [ascPochhammer_eval₂ (algebraMap R S), ← eval₂_comp', ← ascPochhammer_map (algebraMap R S), ← map_comp, eval_map] end @[simp, norm_cast] theorem ascPochhammer_eval_cast (n k : ℕ) : (((ascPochhammer ℕ n).eval k : ℕ) : S) = ((ascPochhammer S n).eval k : S) := by rw [← ascPochhammer_map (algebraMap ℕ S), eval_map, ← eq_natCast (algebraMap ℕ S), eval₂_at_natCast,Nat.cast_id] #align pochhammer_eval_cast ascPochhammer_eval_cast theorem ascPochhammer_eval_zero {n : ℕ} : (ascPochhammer S n).eval 0 = if n = 0 then 1 else 0 := by cases n · simp · simp [X_mul, Nat.succ_ne_zero, ascPochhammer_succ_left] #align pochhammer_eval_zero ascPochhammer_eval_zero theorem ascPochhammer_zero_eval_zero : (ascPochhammer S 0).eval 0 = 1 := by simp #align pochhammer_zero_eval_zero ascPochhammer_zero_eval_zero @[simp] theorem ascPochhammer_ne_zero_eval_zero {n : ℕ} (h : n ≠ 0) : (ascPochhammer S n).eval 0 = 0 := by simp [ascPochhammer_eval_zero, h] #align pochhammer_ne_zero_eval_zero ascPochhammer_ne_zero_eval_zero theorem ascPochhammer_succ_right (n : ℕ) : ascPochhammer S (n + 1) = ascPochhammer S n * (X + (n : S[X])) := by suffices h : ascPochhammer ℕ (n + 1) = ascPochhammer ℕ n * (X + (n : ℕ[X])) by apply_fun Polynomial.map (algebraMap ℕ S) at h simpa only [ascPochhammer_map, Polynomial.map_mul, Polynomial.map_add, map_X, Polynomial.map_natCast] using h induction' n with n ih · simp · conv_lhs => rw [ascPochhammer_succ_left, ih, mul_comp, ← mul_assoc, ← ascPochhammer_succ_left, add_comp, X_comp, natCast_comp, add_assoc, add_comm (1 : ℕ[X]), ← Nat.cast_succ] #align pochhammer_succ_right ascPochhammer_succ_right theorem ascPochhammer_succ_eval {S : Type*} [Semiring S] (n : ℕ) (k : S) : (ascPochhammer S (n + 1)).eval k = (ascPochhammer S n).eval k * (k + n) := by rw [ascPochhammer_succ_right, mul_add, eval_add, eval_mul_X, ← Nat.cast_comm, ← C_eq_natCast, eval_C_mul, Nat.cast_comm, ← mul_add] #align pochhammer_succ_eval ascPochhammer_succ_eval theorem ascPochhammer_succ_comp_X_add_one (n : ℕ) : (ascPochhammer S (n + 1)).comp (X + 1) = ascPochhammer S (n + 1) + (n + 1) • (ascPochhammer S n).comp (X + 1) := by suffices (ascPochhammer ℕ (n + 1)).comp (X + 1) = ascPochhammer ℕ (n + 1) + (n + 1) * (ascPochhammer ℕ n).comp (X + 1) by simpa [map_comp] using congr_arg (Polynomial.map (Nat.castRingHom S)) this nth_rw 2 [ascPochhammer_succ_left] rw [← add_mul, ascPochhammer_succ_right ℕ n, mul_comp, mul_comm, add_comp, X_comp, natCast_comp, add_comm, ← add_assoc] ring set_option linter.uppercaseLean3 false in #align pochhammer_succ_comp_X_add_one ascPochhammer_succ_comp_X_add_one
Mathlib/RingTheory/Polynomial/Pochhammer.lean
156
161
theorem ascPochhammer_mul (n m : ℕ) : ascPochhammer S n * (ascPochhammer S m).comp (X + (n : S[X])) = ascPochhammer S (n + m) := by
induction' m with m ih · simp · rw [ascPochhammer_succ_right, Polynomial.mul_X_add_natCast_comp, ← mul_assoc, ih, ← add_assoc, ascPochhammer_succ_right, Nat.cast_add, add_assoc]
import Mathlib.Analysis.InnerProductSpace.Orthogonal import Mathlib.Analysis.Normed.Group.AddTorsor #align_import geometry.euclidean.basic from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0" open Set open scoped RealInnerProductSpace variable {V P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] variable [NormedAddTorsor V P] noncomputable section namespace AffineSubspace variable {c c₁ c₂ p₁ p₂ : P} def perpBisector (p₁ p₂ : P) : AffineSubspace ℝ P := .comap ((AffineEquiv.vaddConst ℝ (midpoint ℝ p₁ p₂)).symm : P →ᵃ[ℝ] V) <| (LinearMap.ker (innerₛₗ ℝ (p₂ -ᵥ p₁))).toAffineSubspace theorem mem_perpBisector_iff_inner_eq_zero' : c ∈ perpBisector p₁ p₂ ↔ ⟪p₂ -ᵥ p₁, c -ᵥ midpoint ℝ p₁ p₂⟫ = 0 := Iff.rfl theorem mem_perpBisector_iff_inner_eq_zero : c ∈ perpBisector p₁ p₂ ↔ ⟪c -ᵥ midpoint ℝ p₁ p₂, p₂ -ᵥ p₁⟫ = 0 := inner_eq_zero_symm theorem mem_perpBisector_iff_inner_pointReflection_vsub_eq_zero : c ∈ perpBisector p₁ p₂ ↔ ⟪Equiv.pointReflection c p₁ -ᵥ p₂, p₂ -ᵥ p₁⟫ = 0 := by rw [mem_perpBisector_iff_inner_eq_zero, Equiv.pointReflection_apply, vsub_midpoint, invOf_eq_inv, ← smul_add, real_inner_smul_left, vadd_vsub_assoc] simp theorem mem_perpBisector_pointReflection_iff_inner_eq_zero : c ∈ perpBisector p₁ (Equiv.pointReflection p₂ p₁) ↔ ⟪c -ᵥ p₂, p₁ -ᵥ p₂⟫ = 0 := by rw [mem_perpBisector_iff_inner_eq_zero, midpoint_pointReflection_right, Equiv.pointReflection_apply, vadd_vsub_assoc, inner_add_right, add_self_eq_zero, ← neg_eq_zero, ← inner_neg_right, neg_vsub_eq_vsub_rev] theorem midpoint_mem_perpBisector (p₁ p₂ : P) : midpoint ℝ p₁ p₂ ∈ perpBisector p₁ p₂ := by simp [mem_perpBisector_iff_inner_eq_zero] theorem perpBisector_nonempty : (perpBisector p₁ p₂ : Set P).Nonempty := ⟨_, midpoint_mem_perpBisector _ _⟩ @[simp] theorem direction_perpBisector (p₁ p₂ : P) : (perpBisector p₁ p₂).direction = (ℝ ∙ (p₂ -ᵥ p₁))ᗮ := by erw [perpBisector, comap_symm, map_direction, Submodule.map_id, Submodule.toAffineSubspace_direction] ext x exact Submodule.mem_orthogonal_singleton_iff_inner_right.symm theorem mem_perpBisector_iff_inner_eq_inner : c ∈ perpBisector p₁ p₂ ↔ ⟪c -ᵥ p₁, p₂ -ᵥ p₁⟫ = ⟪c -ᵥ p₂, p₁ -ᵥ p₂⟫ := by rw [Iff.comm, mem_perpBisector_iff_inner_eq_zero, ← add_neg_eq_zero, ← inner_neg_right, neg_vsub_eq_vsub_rev, ← inner_add_left, vsub_midpoint, invOf_eq_inv, ← smul_add, real_inner_smul_left]; simp theorem mem_perpBisector_iff_inner_eq : c ∈ perpBisector p₁ p₂ ↔ ⟪c -ᵥ p₁, p₂ -ᵥ p₁⟫ = (dist p₁ p₂) ^ 2 / 2 := by rw [mem_perpBisector_iff_inner_eq_zero, ← vsub_sub_vsub_cancel_right _ _ p₁, inner_sub_left, sub_eq_zero, midpoint_vsub_left, invOf_eq_inv, real_inner_smul_left, real_inner_self_eq_norm_sq, dist_eq_norm_vsub' V, div_eq_inv_mul]
Mathlib/Geometry/Euclidean/PerpBisector.lean
92
95
theorem mem_perpBisector_iff_dist_eq : c ∈ perpBisector p₁ p₂ ↔ dist c p₁ = dist c p₂ := by
rw [dist_eq_norm_vsub V, dist_eq_norm_vsub V, ← real_inner_add_sub_eq_zero_iff, vsub_sub_vsub_cancel_left, inner_add_left, add_eq_zero_iff_eq_neg, ← inner_neg_right, neg_vsub_eq_vsub_rev, mem_perpBisector_iff_inner_eq_inner]
import Mathlib.Algebra.ModEq import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.Archimedean import Mathlib.Algebra.Periodic import Mathlib.Data.Int.SuccPred import Mathlib.GroupTheory.QuotientGroup import Mathlib.Order.Circular import Mathlib.Data.List.TFAE import Mathlib.Data.Set.Lattice #align_import algebra.order.to_interval_mod from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec" noncomputable section section LinearOrderedAddCommGroup variable {α : Type*} [LinearOrderedAddCommGroup α] [hα : Archimedean α] {p : α} (hp : 0 < p) {a b c : α} {n : ℤ} def toIcoDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ico hp b a).choose #align to_Ico_div toIcoDiv theorem sub_toIcoDiv_zsmul_mem_Ico (a b : α) : b - toIcoDiv hp a b • p ∈ Set.Ico a (a + p) := (existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.1 #align sub_to_Ico_div_zsmul_mem_Ico sub_toIcoDiv_zsmul_mem_Ico theorem toIcoDiv_eq_of_sub_zsmul_mem_Ico (h : b - n • p ∈ Set.Ico a (a + p)) : toIcoDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.2 _ h).symm #align to_Ico_div_eq_of_sub_zsmul_mem_Ico toIcoDiv_eq_of_sub_zsmul_mem_Ico def toIocDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose #align to_Ioc_div toIocDiv theorem sub_toIocDiv_zsmul_mem_Ioc (a b : α) : b - toIocDiv hp a b • p ∈ Set.Ioc a (a + p) := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.1 #align sub_to_Ioc_div_zsmul_mem_Ioc sub_toIocDiv_zsmul_mem_Ioc theorem toIocDiv_eq_of_sub_zsmul_mem_Ioc (h : b - n • p ∈ Set.Ioc a (a + p)) : toIocDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.2 _ h).symm #align to_Ioc_div_eq_of_sub_zsmul_mem_Ioc toIocDiv_eq_of_sub_zsmul_mem_Ioc def toIcoMod (a b : α) : α := b - toIcoDiv hp a b • p #align to_Ico_mod toIcoMod def toIocMod (a b : α) : α := b - toIocDiv hp a b • p #align to_Ioc_mod toIocMod theorem toIcoMod_mem_Ico (a b : α) : toIcoMod hp a b ∈ Set.Ico a (a + p) := sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_mod_mem_Ico toIcoMod_mem_Ico theorem toIcoMod_mem_Ico' (b : α) : toIcoMod hp 0 b ∈ Set.Ico 0 p := by convert toIcoMod_mem_Ico hp 0 b exact (zero_add p).symm #align to_Ico_mod_mem_Ico' toIcoMod_mem_Ico' theorem toIocMod_mem_Ioc (a b : α) : toIocMod hp a b ∈ Set.Ioc a (a + p) := sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_mod_mem_Ioc toIocMod_mem_Ioc theorem left_le_toIcoMod (a b : α) : a ≤ toIcoMod hp a b := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).1 #align left_le_to_Ico_mod left_le_toIcoMod theorem left_lt_toIocMod (a b : α) : a < toIocMod hp a b := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).1 #align left_lt_to_Ioc_mod left_lt_toIocMod theorem toIcoMod_lt_right (a b : α) : toIcoMod hp a b < a + p := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).2 #align to_Ico_mod_lt_right toIcoMod_lt_right theorem toIocMod_le_right (a b : α) : toIocMod hp a b ≤ a + p := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).2 #align to_Ioc_mod_le_right toIocMod_le_right @[simp] theorem self_sub_toIcoDiv_zsmul (a b : α) : b - toIcoDiv hp a b • p = toIcoMod hp a b := rfl #align self_sub_to_Ico_div_zsmul self_sub_toIcoDiv_zsmul @[simp] theorem self_sub_toIocDiv_zsmul (a b : α) : b - toIocDiv hp a b • p = toIocMod hp a b := rfl #align self_sub_to_Ioc_div_zsmul self_sub_toIocDiv_zsmul @[simp]
Mathlib/Algebra/Order/ToIntervalMod.lean
123
124
theorem toIcoDiv_zsmul_sub_self (a b : α) : toIcoDiv hp a b • p - b = -toIcoMod hp a b := by
rw [toIcoMod, neg_sub]
import Mathlib.RingTheory.Polynomial.Cyclotomic.Basic import Mathlib.RingTheory.RootsOfUnity.Minpoly #align_import ring_theory.polynomial.cyclotomic.roots from "leanprover-community/mathlib"@"7fdeecc0d03cd40f7a165e6cf00a4d2286db599f" namespace Polynomial variable {R : Type*} [CommRing R] {n : ℕ} theorem isRoot_of_unity_of_root_cyclotomic {ζ : R} {i : ℕ} (hi : i ∈ n.divisors) (h : (cyclotomic i R).IsRoot ζ) : ζ ^ n = 1 := by rcases n.eq_zero_or_pos with (rfl | hn) · exact pow_zero _ have := congr_arg (eval ζ) (prod_cyclotomic_eq_X_pow_sub_one hn R).symm rw [eval_sub, eval_pow, eval_X, eval_one] at this convert eq_add_of_sub_eq' this convert (add_zero (M := R) _).symm apply eval_eq_zero_of_dvd_of_eval_eq_zero _ h exact Finset.dvd_prod_of_mem _ hi #align polynomial.is_root_of_unity_of_root_cyclotomic Polynomial.isRoot_of_unity_of_root_cyclotomic section IsDomain variable [IsDomain R] theorem _root_.isRoot_of_unity_iff (h : 0 < n) (R : Type*) [CommRing R] [IsDomain R] {ζ : R} : ζ ^ n = 1 ↔ ∃ i ∈ n.divisors, (cyclotomic i R).IsRoot ζ := by rw [← mem_nthRoots h, nthRoots, mem_roots <| X_pow_sub_C_ne_zero h _, C_1, ← prod_cyclotomic_eq_X_pow_sub_one h, isRoot_prod] #align is_root_of_unity_iff isRoot_of_unity_iff theorem _root_.IsPrimitiveRoot.isRoot_cyclotomic (hpos : 0 < n) {μ : R} (h : IsPrimitiveRoot μ n) : IsRoot (cyclotomic n R) μ := by rw [← mem_roots (cyclotomic_ne_zero n R), cyclotomic_eq_prod_X_sub_primitiveRoots h, roots_prod_X_sub_C, ← Finset.mem_def] rwa [← mem_primitiveRoots hpos] at h #align is_primitive_root.is_root_cyclotomic IsPrimitiveRoot.isRoot_cyclotomic private theorem isRoot_cyclotomic_iff' {n : ℕ} {K : Type*} [Field K] {μ : K} [NeZero (n : K)] : IsRoot (cyclotomic n K) μ ↔ IsPrimitiveRoot μ n := by -- in this proof, `o` stands for `orderOf μ` have hnpos : 0 < n := (NeZero.of_neZero_natCast K).out.bot_lt refine ⟨fun hμ => ?_, IsPrimitiveRoot.isRoot_cyclotomic hnpos⟩ have hμn : μ ^ n = 1 := by rw [isRoot_of_unity_iff hnpos _] exact ⟨n, n.mem_divisors_self hnpos.ne', hμ⟩ by_contra hnμ have ho : 0 < orderOf μ := (isOfFinOrder_iff_pow_eq_one.2 <| ⟨n, hnpos, hμn⟩).orderOf_pos have := pow_orderOf_eq_one μ rw [isRoot_of_unity_iff ho] at this obtain ⟨i, hio, hiμ⟩ := this replace hio := Nat.dvd_of_mem_divisors hio rw [IsPrimitiveRoot.not_iff] at hnμ rw [← orderOf_dvd_iff_pow_eq_one] at hμn have key : i < n := (Nat.le_of_dvd ho hio).trans_lt ((Nat.le_of_dvd hnpos hμn).lt_of_ne hnμ) have key' : i ∣ n := hio.trans hμn rw [← Polynomial.dvd_iff_isRoot] at hμ hiμ have hni : {i, n} ⊆ n.divisors := by simpa [Finset.insert_subset_iff, key'] using hnpos.ne' obtain ⟨k, hk⟩ := hiμ obtain ⟨j, hj⟩ := hμ have := prod_cyclotomic_eq_X_pow_sub_one hnpos K rw [← Finset.prod_sdiff hni, Finset.prod_pair key.ne, hk, hj] at this have hn := (X_pow_sub_one_separable_iff.mpr <| NeZero.natCast_ne n K).squarefree rw [← this, Squarefree] at hn specialize hn (X - C μ) ⟨(∏ x ∈ n.divisors \ {i, n}, cyclotomic x K) * k * j, by ring⟩ simp [Polynomial.isUnit_iff_degree_eq_zero] at hn theorem isRoot_cyclotomic_iff [NeZero (n : R)] {μ : R} : IsRoot (cyclotomic n R) μ ↔ IsPrimitiveRoot μ n := by have hf : Function.Injective _ := IsFractionRing.injective R (FractionRing R) haveI : NeZero (n : FractionRing R) := NeZero.nat_of_injective hf rw [← isRoot_map_iff hf, ← IsPrimitiveRoot.map_iff_of_injective hf, map_cyclotomic, ← isRoot_cyclotomic_iff'] #align polynomial.is_root_cyclotomic_iff Polynomial.isRoot_cyclotomic_iff theorem roots_cyclotomic_nodup [NeZero (n : R)] : (cyclotomic n R).roots.Nodup := by obtain h | ⟨ζ, hζ⟩ := (cyclotomic n R).roots.empty_or_exists_mem · exact h.symm ▸ Multiset.nodup_zero rw [mem_roots <| cyclotomic_ne_zero n R, isRoot_cyclotomic_iff] at hζ refine Multiset.nodup_of_le (roots.le_of_dvd (X_pow_sub_C_ne_zero (NeZero.pos_of_neZero_natCast R) 1) <| cyclotomic.dvd_X_pow_sub_one n R) hζ.nthRoots_one_nodup #align polynomial.roots_cyclotomic_nodup Polynomial.roots_cyclotomic_nodup theorem cyclotomic.roots_to_finset_eq_primitiveRoots [NeZero (n : R)] : (⟨(cyclotomic n R).roots, roots_cyclotomic_nodup⟩ : Finset _) = primitiveRoots n R := by ext a -- Porting note: was -- `simp [cyclotomic_ne_zero n R, isRoot_cyclotomic_iff, mem_primitiveRoots,` -- ` NeZero.pos_of_neZero_natCast R]` simp only [mem_primitiveRoots, NeZero.pos_of_neZero_natCast R] convert isRoot_cyclotomic_iff (n := n) (μ := a) simp [cyclotomic_ne_zero n R] #align polynomial.cyclotomic.roots_to_finset_eq_primitive_roots Polynomial.cyclotomic.roots_to_finset_eq_primitiveRoots
Mathlib/RingTheory/Polynomial/Cyclotomic/Roots.lean
127
129
theorem cyclotomic.roots_eq_primitiveRoots_val [NeZero (n : R)] : (cyclotomic n R).roots = (primitiveRoots n R).val := by
rw [← cyclotomic.roots_to_finset_eq_primitiveRoots]
import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Algebra.Group.Int import Mathlib.Data.Nat.Dist import Mathlib.Data.Ordmap.Ordnode import Mathlib.Tactic.Abel import Mathlib.Tactic.Linarith #align_import data.ordmap.ordset from "leanprover-community/mathlib"@"47b51515e69f59bca5cf34ef456e6000fe205a69" variable {α : Type*} namespace Ordnode theorem not_le_delta {s} (H : 1 ≤ s) : ¬s ≤ delta * 0 := not_le_of_gt H #align ordnode.not_le_delta Ordnode.not_le_delta theorem delta_lt_false {a b : ℕ} (h₁ : delta * a < b) (h₂ : delta * b < a) : False := not_le_of_lt (lt_trans ((mul_lt_mul_left (by decide)).2 h₁) h₂) <| by simpa [mul_assoc] using Nat.mul_le_mul_right a (by decide : 1 ≤ delta * delta) #align ordnode.delta_lt_false Ordnode.delta_lt_false def realSize : Ordnode α → ℕ | nil => 0 | node _ l _ r => realSize l + realSize r + 1 #align ordnode.real_size Ordnode.realSize def Sized : Ordnode α → Prop | nil => True | node s l _ r => s = size l + size r + 1 ∧ Sized l ∧ Sized r #align ordnode.sized Ordnode.Sized theorem Sized.node' {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (node' l x r) := ⟨rfl, hl, hr⟩ #align ordnode.sized.node' Ordnode.Sized.node'
Mathlib/Data/Ordmap/Ordset.lean
114
115
theorem Sized.eq_node' {s l x r} (h : @Sized α (node s l x r)) : node s l x r = .node' l x r := by
rw [h.1]
import Mathlib.Combinatorics.SimpleGraph.Regularity.Bound import Mathlib.Combinatorics.SimpleGraph.Regularity.Equitabilise import Mathlib.Combinatorics.SimpleGraph.Regularity.Uniform #align_import combinatorics.simple_graph.regularity.chunk from "leanprover-community/mathlib"@"bf7ef0e83e5b7e6c1169e97f055e58a2e4e9d52d" open Finpartition Finset Fintype Rel Nat open scoped SzemerediRegularity.Positivity namespace SzemerediRegularity variable {α : Type*} [Fintype α] [DecidableEq α] {P : Finpartition (univ : Finset α)} (hP : P.IsEquipartition) (G : SimpleGraph α) [DecidableRel G.Adj] (ε : ℝ) {U : Finset α} (hU : U ∈ P.parts) (V : Finset α) local notation3 "m" => (card α / stepBound P.parts.card : ℕ) noncomputable def chunk : Finpartition U := if hUcard : U.card = m * 4 ^ P.parts.card + (card α / P.parts.card - m * 4 ^ P.parts.card) then (atomise U <| P.nonuniformWitnesses G ε U).equitabilise <| card_aux₁ hUcard else (atomise U <| P.nonuniformWitnesses G ε U).equitabilise <| card_aux₂ hP hU hUcard #align szemeredi_regularity.chunk SzemerediRegularity.chunk -- `hP` and `hU` are used to get that `U` has size -- `m * 4 ^ P.parts.card + a or m * 4 ^ P.parts.card + a + 1` noncomputable def star (V : Finset α) : Finset (Finset α) := (chunk hP G ε hU).parts.filter (· ⊆ G.nonuniformWitness ε U V) #align szemeredi_regularity.star SzemerediRegularity.star theorem biUnion_star_subset_nonuniformWitness : (star hP G ε hU V).biUnion id ⊆ G.nonuniformWitness ε U V := biUnion_subset_iff_forall_subset.2 fun _ hA => (mem_filter.1 hA).2 #align szemeredi_regularity.bUnion_star_subset_nonuniform_witness SzemerediRegularity.biUnion_star_subset_nonuniformWitness variable {hP G ε hU V} {𝒜 : Finset (Finset α)} {s : Finset α} theorem star_subset_chunk : star hP G ε hU V ⊆ (chunk hP G ε hU).parts := filter_subset _ _ #align szemeredi_regularity.star_subset_chunk SzemerediRegularity.star_subset_chunk private theorem card_nonuniformWitness_sdiff_biUnion_star (hV : V ∈ P.parts) (hUV : U ≠ V) (h₂ : ¬G.IsUniform ε U V) : (G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id).card ≤ 2 ^ (P.parts.card - 1) * m := by have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U := nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV have q : G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆ ((atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty).biUnion fun B => B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id := by intro x hx rw [← biUnion_filter_atomise hX (G.nonuniformWitness_subset h₂), star, mem_sdiff, mem_biUnion] at hx simp only [not_exists, mem_biUnion, and_imp, exists_prop, mem_filter, not_and, mem_sdiff, id, mem_sdiff] at hx ⊢ obtain ⟨⟨B, hB₁, hB₂⟩, hx⟩ := hx exact ⟨B, hB₁, hB₂, fun A hA AB => hx A hA <| AB.trans hB₁.2.1⟩ apply (card_le_card q).trans (card_biUnion_le.trans _) trans ∑ _i in (atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty, m · suffices ∀ B ∈ (atomise U <| P.nonuniformWitnesses G ε U).parts, (B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id).card ≤ m by exact sum_le_sum fun B hB => this B <| filter_subset _ _ hB intro B hB unfold chunk split_ifs with h₁ · convert card_parts_equitabilise_subset_le _ (card_aux₁ h₁) hB · convert card_parts_equitabilise_subset_le _ (card_aux₂ hP hU h₁) hB rw [sum_const] refine mul_le_mul_right' ?_ _ have t := card_filter_atomise_le_two_pow (s := U) hX refine t.trans (pow_le_pow_right (by norm_num) <| tsub_le_tsub_right ?_ _) exact card_image_le.trans (card_le_card <| filter_subset _ _) private theorem one_sub_eps_mul_card_nonuniformWitness_le_card_star (hV : V ∈ P.parts) (hUV : U ≠ V) (hunif : ¬G.IsUniform ε U V) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) : (1 - ε / 10) * (G.nonuniformWitness ε U V).card ≤ ((star hP G ε hU V).biUnion id).card := by have hP₁ : 0 < P.parts.card := Finset.card_pos.2 ⟨_, hU⟩ have : (↑2 ^ P.parts.card : ℝ) * m / (U.card * ε) ≤ ε / 10 := by rw [← div_div, div_le_iff'] swap · sz_positivity refine le_of_mul_le_mul_left ?_ (pow_pos zero_lt_two P.parts.card) calc ↑2 ^ P.parts.card * ((↑2 ^ P.parts.card * m : ℝ) / U.card) = ((2 : ℝ) * 2) ^ P.parts.card * m / U.card := by rw [mul_pow, ← mul_div_assoc, mul_assoc] _ = ↑4 ^ P.parts.card * m / U.card := by norm_num _ ≤ 1 := div_le_one_of_le (pow_mul_m_le_card_part hP hU) (cast_nonneg _) _ ≤ ↑2 ^ P.parts.card * ε ^ 2 / 10 := by refine (one_le_sq_iff <| by positivity).1 ?_ rw [div_pow, mul_pow, pow_right_comm, ← pow_mul ε, one_le_div (sq_pos_of_ne_zero <| by norm_num)] calc (↑10 ^ 2) = 100 := by norm_num _ ≤ ↑4 ^ P.parts.card * ε ^ 5 := hPε _ ≤ ↑4 ^ P.parts.card * ε ^ 4 := (mul_le_mul_of_nonneg_left (pow_le_pow_of_le_one (by sz_positivity) hε₁ <| le_succ _) (by positivity)) _ = (↑2 ^ 2) ^ P.parts.card * ε ^ (2 * 2) := by norm_num _ = ↑2 ^ P.parts.card * (ε * (ε / 10)) := by rw [mul_div_assoc, sq, mul_div_assoc] calc (↑1 - ε / 10) * (G.nonuniformWitness ε U V).card ≤ (↑1 - ↑2 ^ P.parts.card * m / (U.card * ε)) * (G.nonuniformWitness ε U V).card := mul_le_mul_of_nonneg_right (sub_le_sub_left this _) (cast_nonneg _) _ = (G.nonuniformWitness ε U V).card - ↑2 ^ P.parts.card * m / (U.card * ε) * (G.nonuniformWitness ε U V).card := by rw [sub_mul, one_mul] _ ≤ (G.nonuniformWitness ε U V).card - ↑2 ^ (P.parts.card - 1) * m := by refine sub_le_sub_left ?_ _ have : (2 : ℝ) ^ P.parts.card = ↑2 ^ (P.parts.card - 1) * 2 := by rw [← _root_.pow_succ, tsub_add_cancel_of_le (succ_le_iff.2 hP₁)] rw [← mul_div_right_comm, this, mul_right_comm _ (2 : ℝ), mul_assoc, le_div_iff] · refine mul_le_mul_of_nonneg_left ?_ (by positivity) exact (G.le_card_nonuniformWitness hunif).trans (le_mul_of_one_le_left (cast_nonneg _) one_le_two) have := Finset.card_pos.mpr (P.nonempty_of_mem_parts hU) sz_positivity _ ≤ ((star hP G ε hU V).biUnion id).card := by rw [sub_le_comm, ← cast_sub (card_le_card <| biUnion_star_subset_nonuniformWitness hP G ε hU V), ← card_sdiff (biUnion_star_subset_nonuniformWitness hP G ε hU V)] exact mod_cast card_nonuniformWitness_sdiff_biUnion_star hV hUV hunif theorem card_chunk (hm : m ≠ 0) : (chunk hP G ε hU).parts.card = 4 ^ P.parts.card := by unfold chunk split_ifs · rw [card_parts_equitabilise _ _ hm, tsub_add_cancel_of_le] exact le_of_lt a_add_one_le_four_pow_parts_card · rw [card_parts_equitabilise _ _ hm, tsub_add_cancel_of_le a_add_one_le_four_pow_parts_card] #align szemeredi_regularity.card_chunk SzemerediRegularity.card_chunk
Mathlib/Combinatorics/SimpleGraph/Regularity/Chunk.lean
188
191
theorem card_eq_of_mem_parts_chunk (hs : s ∈ (chunk hP G ε hU).parts) : s.card = m ∨ s.card = m + 1 := by
unfold chunk at hs split_ifs at hs <;> exact card_eq_of_mem_parts_equitabilise hs
import Mathlib.LinearAlgebra.AffineSpace.AffineEquiv #align_import linear_algebra.affine_space.affine_subspace from "leanprover-community/mathlib"@"e96bdfbd1e8c98a09ff75f7ac6204d142debc840" noncomputable section open Affine open Set section variable (k : Type*) {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V] variable [AffineSpace V P] def vectorSpan (s : Set P) : Submodule k V := Submodule.span k (s -ᵥ s) #align vector_span vectorSpan theorem vectorSpan_def (s : Set P) : vectorSpan k s = Submodule.span k (s -ᵥ s) := rfl #align vector_span_def vectorSpan_def theorem vectorSpan_mono {s₁ s₂ : Set P} (h : s₁ ⊆ s₂) : vectorSpan k s₁ ≤ vectorSpan k s₂ := Submodule.span_mono (vsub_self_mono h) #align vector_span_mono vectorSpan_mono variable (P) @[simp] theorem vectorSpan_empty : vectorSpan k (∅ : Set P) = (⊥ : Submodule k V) := by rw [vectorSpan_def, vsub_empty, Submodule.span_empty] #align vector_span_empty vectorSpan_empty variable {P} @[simp] theorem vectorSpan_singleton (p : P) : vectorSpan k ({p} : Set P) = ⊥ := by simp [vectorSpan_def] #align vector_span_singleton vectorSpan_singleton theorem vsub_set_subset_vectorSpan (s : Set P) : s -ᵥ s ⊆ ↑(vectorSpan k s) := Submodule.subset_span #align vsub_set_subset_vector_span vsub_set_subset_vectorSpan theorem vsub_mem_vectorSpan {s : Set P} {p1 p2 : P} (hp1 : p1 ∈ s) (hp2 : p2 ∈ s) : p1 -ᵥ p2 ∈ vectorSpan k s := vsub_set_subset_vectorSpan k s (vsub_mem_vsub hp1 hp2) #align vsub_mem_vector_span vsub_mem_vectorSpan def spanPoints (s : Set P) : Set P := { p | ∃ p1 ∈ s, ∃ v ∈ vectorSpan k s, p = v +ᵥ p1 } #align span_points spanPoints theorem mem_spanPoints (p : P) (s : Set P) : p ∈ s → p ∈ spanPoints k s | hp => ⟨p, hp, 0, Submodule.zero_mem _, (zero_vadd V p).symm⟩ #align mem_span_points mem_spanPoints theorem subset_spanPoints (s : Set P) : s ⊆ spanPoints k s := fun p => mem_spanPoints k p s #align subset_span_points subset_spanPoints @[simp] theorem spanPoints_nonempty (s : Set P) : (spanPoints k s).Nonempty ↔ s.Nonempty := by constructor · contrapose rw [Set.not_nonempty_iff_eq_empty, Set.not_nonempty_iff_eq_empty] intro h simp [h, spanPoints] · exact fun h => h.mono (subset_spanPoints _ _) #align span_points_nonempty spanPoints_nonempty theorem vadd_mem_spanPoints_of_mem_spanPoints_of_mem_vectorSpan {s : Set P} {p : P} {v : V} (hp : p ∈ spanPoints k s) (hv : v ∈ vectorSpan k s) : v +ᵥ p ∈ spanPoints k s := by rcases hp with ⟨p2, ⟨hp2, ⟨v2, ⟨hv2, hv2p⟩⟩⟩⟩ rw [hv2p, vadd_vadd] exact ⟨p2, hp2, v + v2, (vectorSpan k s).add_mem hv hv2, rfl⟩ #align vadd_mem_span_points_of_mem_span_points_of_mem_vector_span vadd_mem_spanPoints_of_mem_spanPoints_of_mem_vectorSpan theorem vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints {s : Set P} {p1 p2 : P} (hp1 : p1 ∈ spanPoints k s) (hp2 : p2 ∈ spanPoints k s) : p1 -ᵥ p2 ∈ vectorSpan k s := by rcases hp1 with ⟨p1a, ⟨hp1a, ⟨v1, ⟨hv1, hv1p⟩⟩⟩⟩ rcases hp2 with ⟨p2a, ⟨hp2a, ⟨v2, ⟨hv2, hv2p⟩⟩⟩⟩ rw [hv1p, hv2p, vsub_vadd_eq_vsub_sub (v1 +ᵥ p1a), vadd_vsub_assoc, add_comm, add_sub_assoc] have hv1v2 : v1 - v2 ∈ vectorSpan k s := (vectorSpan k s).sub_mem hv1 hv2 refine (vectorSpan k s).add_mem ?_ hv1v2 exact vsub_mem_vectorSpan k hp1a hp2a #align vsub_mem_vector_span_of_mem_span_points_of_mem_span_points vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints end structure AffineSubspace (k : Type*) {V : Type*} (P : Type*) [Ring k] [AddCommGroup V] [Module k V] [AffineSpace V P] where carrier : Set P smul_vsub_vadd_mem : ∀ (c : k) {p1 p2 p3 : P}, p1 ∈ carrier → p2 ∈ carrier → p3 ∈ carrier → c • (p1 -ᵥ p2 : V) +ᵥ p3 ∈ carrier #align affine_subspace AffineSubspace namespace AffineSubspace variable (k : Type*) {V : Type*} (P : Type*) [Ring k] [AddCommGroup V] [Module k V] [AffineSpace V P] instance : SetLike (AffineSubspace k P) P where coe := carrier coe_injective' p q _ := by cases p; cases q; congr -- Porting note: removed `simp`, proof is `simp only [SetLike.mem_coe]` theorem mem_coe (p : P) (s : AffineSubspace k P) : p ∈ (s : Set P) ↔ p ∈ s := Iff.rfl #align affine_subspace.mem_coe AffineSubspace.mem_coe variable {k P} def direction (s : AffineSubspace k P) : Submodule k V := vectorSpan k (s : Set P) #align affine_subspace.direction AffineSubspace.direction theorem direction_eq_vectorSpan (s : AffineSubspace k P) : s.direction = vectorSpan k (s : Set P) := rfl #align affine_subspace.direction_eq_vector_span AffineSubspace.direction_eq_vectorSpan def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where carrier := (s : Set P) -ᵥ s zero_mem' := by cases' h with p hp exact vsub_self p ▸ vsub_mem_vsub hp hp add_mem' := by rintro _ _ ⟨p1, hp1, p2, hp2, rfl⟩ ⟨p3, hp3, p4, hp4, rfl⟩ rw [← vadd_vsub_assoc] refine vsub_mem_vsub ?_ hp4 convert s.smul_vsub_vadd_mem 1 hp1 hp2 hp3 rw [one_smul] smul_mem' := by rintro c _ ⟨p1, hp1, p2, hp2, rfl⟩ rw [← vadd_vsub (c • (p1 -ᵥ p2)) p2] refine vsub_mem_vsub ?_ hp2 exact s.smul_vsub_vadd_mem c hp1 hp2 hp2 #align affine_subspace.direction_of_nonempty AffineSubspace.directionOfNonempty theorem directionOfNonempty_eq_direction {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : directionOfNonempty h = s.direction := by refine le_antisymm ?_ (Submodule.span_le.2 Set.Subset.rfl) rw [← SetLike.coe_subset_coe, directionOfNonempty, direction, Submodule.coe_set_mk, AddSubmonoid.coe_set_mk] exact vsub_set_subset_vectorSpan k _ #align affine_subspace.direction_of_nonempty_eq_direction AffineSubspace.directionOfNonempty_eq_direction theorem coe_direction_eq_vsub_set {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : (s.direction : Set V) = (s : Set P) -ᵥ s := directionOfNonempty_eq_direction h ▸ rfl #align affine_subspace.coe_direction_eq_vsub_set AffineSubspace.coe_direction_eq_vsub_set theorem mem_direction_iff_eq_vsub {s : AffineSubspace k P} (h : (s : Set P).Nonempty) (v : V) : v ∈ s.direction ↔ ∃ p1 ∈ s, ∃ p2 ∈ s, v = p1 -ᵥ p2 := by rw [← SetLike.mem_coe, coe_direction_eq_vsub_set h, Set.mem_vsub] simp only [SetLike.mem_coe, eq_comm] #align affine_subspace.mem_direction_iff_eq_vsub AffineSubspace.mem_direction_iff_eq_vsub theorem vadd_mem_of_mem_direction {s : AffineSubspace k P} {v : V} (hv : v ∈ s.direction) {p : P} (hp : p ∈ s) : v +ᵥ p ∈ s := by rw [mem_direction_iff_eq_vsub ⟨p, hp⟩] at hv rcases hv with ⟨p1, hp1, p2, hp2, hv⟩ rw [hv] convert s.smul_vsub_vadd_mem 1 hp1 hp2 hp rw [one_smul] exact s.mem_coe k P _ #align affine_subspace.vadd_mem_of_mem_direction AffineSubspace.vadd_mem_of_mem_direction theorem vsub_mem_direction {s : AffineSubspace k P} {p1 p2 : P} (hp1 : p1 ∈ s) (hp2 : p2 ∈ s) : p1 -ᵥ p2 ∈ s.direction := vsub_mem_vectorSpan k hp1 hp2 #align affine_subspace.vsub_mem_direction AffineSubspace.vsub_mem_direction theorem vadd_mem_iff_mem_direction {s : AffineSubspace k P} (v : V) {p : P} (hp : p ∈ s) : v +ᵥ p ∈ s ↔ v ∈ s.direction := ⟨fun h => by simpa using vsub_mem_direction h hp, fun h => vadd_mem_of_mem_direction h hp⟩ #align affine_subspace.vadd_mem_iff_mem_direction AffineSubspace.vadd_mem_iff_mem_direction theorem vadd_mem_iff_mem_of_mem_direction {s : AffineSubspace k P} {v : V} (hv : v ∈ s.direction) {p : P} : v +ᵥ p ∈ s ↔ p ∈ s := by refine ⟨fun h => ?_, fun h => vadd_mem_of_mem_direction hv h⟩ convert vadd_mem_of_mem_direction (Submodule.neg_mem _ hv) h simp #align affine_subspace.vadd_mem_iff_mem_of_mem_direction AffineSubspace.vadd_mem_iff_mem_of_mem_direction theorem coe_direction_eq_vsub_set_right {s : AffineSubspace k P} {p : P} (hp : p ∈ s) : (s.direction : Set V) = (· -ᵥ p) '' s := by rw [coe_direction_eq_vsub_set ⟨p, hp⟩] refine le_antisymm ?_ ?_ · rintro v ⟨p1, hp1, p2, hp2, rfl⟩ exact ⟨p1 -ᵥ p2 +ᵥ p, vadd_mem_of_mem_direction (vsub_mem_direction hp1 hp2) hp, vadd_vsub _ _⟩ · rintro v ⟨p2, hp2, rfl⟩ exact ⟨p2, hp2, p, hp, rfl⟩ #align affine_subspace.coe_direction_eq_vsub_set_right AffineSubspace.coe_direction_eq_vsub_set_right theorem coe_direction_eq_vsub_set_left {s : AffineSubspace k P} {p : P} (hp : p ∈ s) : (s.direction : Set V) = (p -ᵥ ·) '' s := by ext v rw [SetLike.mem_coe, ← Submodule.neg_mem_iff, ← SetLike.mem_coe, coe_direction_eq_vsub_set_right hp, Set.mem_image, Set.mem_image] conv_lhs => congr ext rw [← neg_vsub_eq_vsub_rev, neg_inj] #align affine_subspace.coe_direction_eq_vsub_set_left AffineSubspace.coe_direction_eq_vsub_set_left theorem mem_direction_iff_eq_vsub_right {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (v : V) : v ∈ s.direction ↔ ∃ p2 ∈ s, v = p2 -ᵥ p := by rw [← SetLike.mem_coe, coe_direction_eq_vsub_set_right hp] exact ⟨fun ⟨p2, hp2, hv⟩ => ⟨p2, hp2, hv.symm⟩, fun ⟨p2, hp2, hv⟩ => ⟨p2, hp2, hv.symm⟩⟩ #align affine_subspace.mem_direction_iff_eq_vsub_right AffineSubspace.mem_direction_iff_eq_vsub_right theorem mem_direction_iff_eq_vsub_left {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (v : V) : v ∈ s.direction ↔ ∃ p2 ∈ s, v = p -ᵥ p2 := by rw [← SetLike.mem_coe, coe_direction_eq_vsub_set_left hp] exact ⟨fun ⟨p2, hp2, hv⟩ => ⟨p2, hp2, hv.symm⟩, fun ⟨p2, hp2, hv⟩ => ⟨p2, hp2, hv.symm⟩⟩ #align affine_subspace.mem_direction_iff_eq_vsub_left AffineSubspace.mem_direction_iff_eq_vsub_left theorem vsub_right_mem_direction_iff_mem {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (p2 : P) : p2 -ᵥ p ∈ s.direction ↔ p2 ∈ s := by rw [mem_direction_iff_eq_vsub_right hp] simp #align affine_subspace.vsub_right_mem_direction_iff_mem AffineSubspace.vsub_right_mem_direction_iff_mem theorem vsub_left_mem_direction_iff_mem {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (p2 : P) : p -ᵥ p2 ∈ s.direction ↔ p2 ∈ s := by rw [mem_direction_iff_eq_vsub_left hp] simp #align affine_subspace.vsub_left_mem_direction_iff_mem AffineSubspace.vsub_left_mem_direction_iff_mem theorem coe_injective : Function.Injective ((↑) : AffineSubspace k P → Set P) := SetLike.coe_injective #align affine_subspace.coe_injective AffineSubspace.coe_injective @[ext] theorem ext {p q : AffineSubspace k P} (h : ∀ x, x ∈ p ↔ x ∈ q) : p = q := SetLike.ext h #align affine_subspace.ext AffineSubspace.ext -- Porting note: removed `simp`, proof is `simp only [SetLike.ext'_iff]` theorem ext_iff (s₁ s₂ : AffineSubspace k P) : (s₁ : Set P) = s₂ ↔ s₁ = s₂ := SetLike.ext'_iff.symm #align affine_subspace.ext_iff AffineSubspace.ext_iff theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction) (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by ext p have hq1 := Set.mem_of_mem_inter_left hn.some_mem have hq2 := Set.mem_of_mem_inter_right hn.some_mem constructor · intro hp rw [← vsub_vadd p hn.some] refine vadd_mem_of_mem_direction ?_ hq2 rw [← hd] exact vsub_mem_direction hp hq1 · intro hp rw [← vsub_vadd p hn.some] refine vadd_mem_of_mem_direction ?_ hq1 rw [hd] exact vsub_mem_direction hp hq2 #align affine_subspace.ext_of_direction_eq AffineSubspace.ext_of_direction_eq -- See note [reducible non instances] abbrev toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction s where vadd a b := ⟨(a : V) +ᵥ (b : P), vadd_mem_of_mem_direction a.2 b.2⟩ zero_vadd := fun a => by ext exact zero_vadd _ _ add_vadd a b c := by ext apply add_vadd vsub a b := ⟨(a : P) -ᵥ (b : P), (vsub_left_mem_direction_iff_mem a.2 _).mpr b.2⟩ vsub_vadd' a b := by ext apply AddTorsor.vsub_vadd' vadd_vsub' a b := by ext apply AddTorsor.vadd_vsub' #align affine_subspace.to_add_torsor AffineSubspace.toAddTorsor attribute [local instance] toAddTorsor @[simp, norm_cast] theorem coe_vsub (s : AffineSubspace k P) [Nonempty s] (a b : s) : ↑(a -ᵥ b) = (a : P) -ᵥ (b : P) := rfl #align affine_subspace.coe_vsub AffineSubspace.coe_vsub @[simp, norm_cast] theorem coe_vadd (s : AffineSubspace k P) [Nonempty s] (a : s.direction) (b : s) : ↑(a +ᵥ b) = (a : V) +ᵥ (b : P) := rfl #align affine_subspace.coe_vadd AffineSubspace.coe_vadd protected def subtype (s : AffineSubspace k P) [Nonempty s] : s →ᵃ[k] P where toFun := (↑) linear := s.direction.subtype map_vadd' _ _ := rfl #align affine_subspace.subtype AffineSubspace.subtype @[simp] theorem subtype_linear (s : AffineSubspace k P) [Nonempty s] : s.subtype.linear = s.direction.subtype := rfl #align affine_subspace.subtype_linear AffineSubspace.subtype_linear theorem subtype_apply (s : AffineSubspace k P) [Nonempty s] (p : s) : s.subtype p = p := rfl #align affine_subspace.subtype_apply AffineSubspace.subtype_apply @[simp] theorem coeSubtype (s : AffineSubspace k P) [Nonempty s] : (s.subtype : s → P) = ((↑) : s → P) := rfl #align affine_subspace.coe_subtype AffineSubspace.coeSubtype theorem injective_subtype (s : AffineSubspace k P) [Nonempty s] : Function.Injective s.subtype := Subtype.coe_injective #align affine_subspace.injective_subtype AffineSubspace.injective_subtype theorem eq_iff_direction_eq_of_mem {s₁ s₂ : AffineSubspace k P} {p : P} (h₁ : p ∈ s₁) (h₂ : p ∈ s₂) : s₁ = s₂ ↔ s₁.direction = s₂.direction := ⟨fun h => h ▸ rfl, fun h => ext_of_direction_eq h ⟨p, h₁, h₂⟩⟩ #align affine_subspace.eq_iff_direction_eq_of_mem AffineSubspace.eq_iff_direction_eq_of_mem def mk' (p : P) (direction : Submodule k V) : AffineSubspace k P where carrier := { q | ∃ v ∈ direction, q = v +ᵥ p } smul_vsub_vadd_mem c p1 p2 p3 hp1 hp2 hp3 := by rcases hp1 with ⟨v1, hv1, hp1⟩ rcases hp2 with ⟨v2, hv2, hp2⟩ rcases hp3 with ⟨v3, hv3, hp3⟩ use c • (v1 - v2) + v3, direction.add_mem (direction.smul_mem c (direction.sub_mem hv1 hv2)) hv3 simp [hp1, hp2, hp3, vadd_vadd] #align affine_subspace.mk' AffineSubspace.mk' theorem self_mem_mk' (p : P) (direction : Submodule k V) : p ∈ mk' p direction := ⟨0, ⟨direction.zero_mem, (zero_vadd _ _).symm⟩⟩ #align affine_subspace.self_mem_mk' AffineSubspace.self_mem_mk' theorem vadd_mem_mk' {v : V} (p : P) {direction : Submodule k V} (hv : v ∈ direction) : v +ᵥ p ∈ mk' p direction := ⟨v, hv, rfl⟩ #align affine_subspace.vadd_mem_mk' AffineSubspace.vadd_mem_mk' theorem mk'_nonempty (p : P) (direction : Submodule k V) : (mk' p direction : Set P).Nonempty := ⟨p, self_mem_mk' p direction⟩ #align affine_subspace.mk'_nonempty AffineSubspace.mk'_nonempty @[simp] theorem direction_mk' (p : P) (direction : Submodule k V) : (mk' p direction).direction = direction := by ext v rw [mem_direction_iff_eq_vsub (mk'_nonempty _ _)] constructor · rintro ⟨p1, ⟨v1, hv1, hp1⟩, p2, ⟨v2, hv2, hp2⟩, hv⟩ rw [hv, hp1, hp2, vadd_vsub_vadd_cancel_right] exact direction.sub_mem hv1 hv2 · exact fun hv => ⟨v +ᵥ p, vadd_mem_mk' _ hv, p, self_mem_mk' _ _, (vadd_vsub _ _).symm⟩ #align affine_subspace.direction_mk' AffineSubspace.direction_mk'
Mathlib/LinearAlgebra/AffineSpace/AffineSubspace.lean
479
485
theorem mem_mk'_iff_vsub_mem {p₁ p₂ : P} {direction : Submodule k V} : p₂ ∈ mk' p₁ direction ↔ p₂ -ᵥ p₁ ∈ direction := by
refine ⟨fun h => ?_, fun h => ?_⟩ · rw [← direction_mk' p₁ direction] exact vsub_mem_direction h (self_mem_mk' _ _) · rw [← vsub_vadd p₂ p₁] exact vadd_mem_mk' p₁ h
import Mathlib.Data.List.Nodup import Mathlib.Data.List.Zip import Mathlib.Data.Nat.Defs import Mathlib.Data.List.Infix #align_import data.list.rotate from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" universe u variable {α : Type u} open Nat Function namespace List theorem rotate_mod (l : List α) (n : ℕ) : l.rotate (n % l.length) = l.rotate n := by simp [rotate] #align list.rotate_mod List.rotate_mod @[simp] theorem rotate_nil (n : ℕ) : ([] : List α).rotate n = [] := by simp [rotate] #align list.rotate_nil List.rotate_nil @[simp] theorem rotate_zero (l : List α) : l.rotate 0 = l := by simp [rotate] #align list.rotate_zero List.rotate_zero -- Porting note: removing simp, simp can prove it theorem rotate'_nil (n : ℕ) : ([] : List α).rotate' n = [] := by cases n <;> rfl #align list.rotate'_nil List.rotate'_nil @[simp] theorem rotate'_zero (l : List α) : l.rotate' 0 = l := by cases l <;> rfl #align list.rotate'_zero List.rotate'_zero theorem rotate'_cons_succ (l : List α) (a : α) (n : ℕ) : (a :: l : List α).rotate' n.succ = (l ++ [a]).rotate' n := by simp [rotate'] #align list.rotate'_cons_succ List.rotate'_cons_succ @[simp] theorem length_rotate' : ∀ (l : List α) (n : ℕ), (l.rotate' n).length = l.length | [], _ => by simp | a :: l, 0 => rfl | a :: l, n + 1 => by rw [List.rotate', length_rotate' (l ++ [a]) n]; simp #align list.length_rotate' List.length_rotate' theorem rotate'_eq_drop_append_take : ∀ {l : List α} {n : ℕ}, n ≤ l.length → l.rotate' n = l.drop n ++ l.take n | [], n, h => by simp [drop_append_of_le_length h] | l, 0, h => by simp [take_append_of_le_length h] | a :: l, n + 1, h => by have hnl : n ≤ l.length := le_of_succ_le_succ h have hnl' : n ≤ (l ++ [a]).length := by rw [length_append, length_cons, List.length]; exact le_of_succ_le h rw [rotate'_cons_succ, rotate'_eq_drop_append_take hnl', drop, take, drop_append_of_le_length hnl, take_append_of_le_length hnl]; simp #align list.rotate'_eq_drop_append_take List.rotate'_eq_drop_append_take theorem rotate'_rotate' : ∀ (l : List α) (n m : ℕ), (l.rotate' n).rotate' m = l.rotate' (n + m) | a :: l, 0, m => by simp | [], n, m => by simp | a :: l, n + 1, m => by rw [rotate'_cons_succ, rotate'_rotate' _ n, Nat.add_right_comm, ← rotate'_cons_succ, Nat.succ_eq_add_one] #align list.rotate'_rotate' List.rotate'_rotate' @[simp] theorem rotate'_length (l : List α) : rotate' l l.length = l := by rw [rotate'_eq_drop_append_take le_rfl]; simp #align list.rotate'_length List.rotate'_length @[simp] theorem rotate'_length_mul (l : List α) : ∀ n : ℕ, l.rotate' (l.length * n) = l | 0 => by simp | n + 1 => calc l.rotate' (l.length * (n + 1)) = (l.rotate' (l.length * n)).rotate' (l.rotate' (l.length * n)).length := by simp [-rotate'_length, Nat.mul_succ, rotate'_rotate'] _ = l := by rw [rotate'_length, rotate'_length_mul l n] #align list.rotate'_length_mul List.rotate'_length_mul theorem rotate'_mod (l : List α) (n : ℕ) : l.rotate' (n % l.length) = l.rotate' n := calc l.rotate' (n % l.length) = (l.rotate' (n % l.length)).rotate' ((l.rotate' (n % l.length)).length * (n / l.length)) := by rw [rotate'_length_mul] _ = l.rotate' n := by rw [rotate'_rotate', length_rotate', Nat.mod_add_div] #align list.rotate'_mod List.rotate'_mod theorem rotate_eq_rotate' (l : List α) (n : ℕ) : l.rotate n = l.rotate' n := if h : l.length = 0 then by simp_all [length_eq_zero] else by rw [← rotate'_mod, rotate'_eq_drop_append_take (le_of_lt (Nat.mod_lt _ (Nat.pos_of_ne_zero h)))]; simp [rotate] #align list.rotate_eq_rotate' List.rotate_eq_rotate' theorem rotate_cons_succ (l : List α) (a : α) (n : ℕ) : (a :: l : List α).rotate (n + 1) = (l ++ [a]).rotate n := by rw [rotate_eq_rotate', rotate_eq_rotate', rotate'_cons_succ] #align list.rotate_cons_succ List.rotate_cons_succ @[simp] theorem mem_rotate : ∀ {l : List α} {a : α} {n : ℕ}, a ∈ l.rotate n ↔ a ∈ l | [], _, n => by simp | a :: l, _, 0 => by simp | a :: l, _, n + 1 => by simp [rotate_cons_succ, mem_rotate, or_comm] #align list.mem_rotate List.mem_rotate @[simp] theorem length_rotate (l : List α) (n : ℕ) : (l.rotate n).length = l.length := by rw [rotate_eq_rotate', length_rotate'] #align list.length_rotate List.length_rotate @[simp] theorem rotate_replicate (a : α) (n : ℕ) (k : ℕ) : (replicate n a).rotate k = replicate n a := eq_replicate.2 ⟨by rw [length_rotate, length_replicate], fun b hb => eq_of_mem_replicate <| mem_rotate.1 hb⟩ #align list.rotate_replicate List.rotate_replicate
Mathlib/Data/List/Rotate.lean
142
144
theorem rotate_eq_drop_append_take {l : List α} {n : ℕ} : n ≤ l.length → l.rotate n = l.drop n ++ l.take n := by
rw [rotate_eq_rotate']; exact rotate'_eq_drop_append_take
import Mathlib.Dynamics.Ergodic.MeasurePreserving import Mathlib.MeasureTheory.Function.SimpleFunc import Mathlib.MeasureTheory.Measure.MutuallySingular import Mathlib.MeasureTheory.Measure.Count import Mathlib.Topology.IndicatorConstPointwise import Mathlib.MeasureTheory.Constructions.BorelSpace.Real #align_import measure_theory.integral.lebesgue from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" assert_not_exists NormedSpace set_option autoImplicit true noncomputable section open Set hiding restrict restrict_apply open Filter ENNReal open Function (support) open scoped Classical open Topology NNReal ENNReal MeasureTheory namespace MeasureTheory local infixr:25 " →ₛ " => SimpleFunc variable {α β γ δ : Type*} section Lintegral open SimpleFunc variable {m : MeasurableSpace α} {μ ν : Measure α} irreducible_def lintegral {_ : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) : ℝ≥0∞ := ⨆ (g : α →ₛ ℝ≥0∞) (_ : ⇑g ≤ f), g.lintegral μ #align measure_theory.lintegral MeasureTheory.lintegral @[inherit_doc MeasureTheory.lintegral] notation3 "∫⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => lintegral μ r @[inherit_doc MeasureTheory.lintegral] notation3 "∫⁻ "(...)", "r:60:(scoped f => lintegral volume f) => r @[inherit_doc MeasureTheory.lintegral] notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => lintegral (Measure.restrict μ s) r @[inherit_doc MeasureTheory.lintegral] notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => lintegral (Measure.restrict volume s) f) => r theorem SimpleFunc.lintegral_eq_lintegral {m : MeasurableSpace α} (f : α →ₛ ℝ≥0∞) (μ : Measure α) : ∫⁻ a, f a ∂μ = f.lintegral μ := by rw [MeasureTheory.lintegral] exact le_antisymm (iSup₂_le fun g hg => lintegral_mono hg <| le_rfl) (le_iSup₂_of_le f le_rfl le_rfl) #align measure_theory.simple_func.lintegral_eq_lintegral MeasureTheory.SimpleFunc.lintegral_eq_lintegral @[mono] theorem lintegral_mono' {m : MeasurableSpace α} ⦃μ ν : Measure α⦄ (hμν : μ ≤ ν) ⦃f g : α → ℝ≥0∞⦄ (hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂ν := by rw [lintegral, lintegral] exact iSup_mono fun φ => iSup_mono' fun hφ => ⟨le_trans hφ hfg, lintegral_mono (le_refl φ) hμν⟩ #align measure_theory.lintegral_mono' MeasureTheory.lintegral_mono' -- workaround for the known eta-reduction issue with `@[gcongr]` @[gcongr] theorem lintegral_mono_fn' ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) (h2 : μ ≤ ν) : lintegral μ f ≤ lintegral ν g := lintegral_mono' h2 hfg theorem lintegral_mono ⦃f g : α → ℝ≥0∞⦄ (hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := lintegral_mono' (le_refl μ) hfg #align measure_theory.lintegral_mono MeasureTheory.lintegral_mono -- workaround for the known eta-reduction issue with `@[gcongr]` @[gcongr] theorem lintegral_mono_fn ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) : lintegral μ f ≤ lintegral μ g := lintegral_mono hfg theorem lintegral_mono_nnreal {f g : α → ℝ≥0} (h : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := lintegral_mono fun a => ENNReal.coe_le_coe.2 (h a) #align measure_theory.lintegral_mono_nnreal MeasureTheory.lintegral_mono_nnreal theorem iSup_lintegral_measurable_le_eq_lintegral (f : α → ℝ≥0∞) : ⨆ (g : α → ℝ≥0∞) (_ : Measurable g) (_ : g ≤ f), ∫⁻ a, g a ∂μ = ∫⁻ a, f a ∂μ := by apply le_antisymm · exact iSup_le fun i => iSup_le fun _ => iSup_le fun h'i => lintegral_mono h'i · rw [lintegral] refine iSup₂_le fun i hi => le_iSup₂_of_le i i.measurable <| le_iSup_of_le hi ?_ exact le_of_eq (i.lintegral_eq_lintegral _).symm #align measure_theory.supr_lintegral_measurable_le_eq_lintegral MeasureTheory.iSup_lintegral_measurable_le_eq_lintegral theorem lintegral_mono_set {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞} (hst : s ⊆ t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ := lintegral_mono' (Measure.restrict_mono hst (le_refl μ)) (le_refl f) #align measure_theory.lintegral_mono_set MeasureTheory.lintegral_mono_set theorem lintegral_mono_set' {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞} (hst : s ≤ᵐ[μ] t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ := lintegral_mono' (Measure.restrict_mono' hst (le_refl μ)) (le_refl f) #align measure_theory.lintegral_mono_set' MeasureTheory.lintegral_mono_set' theorem monotone_lintegral {_ : MeasurableSpace α} (μ : Measure α) : Monotone (lintegral μ) := lintegral_mono #align measure_theory.monotone_lintegral MeasureTheory.monotone_lintegral @[simp] theorem lintegral_const (c : ℝ≥0∞) : ∫⁻ _, c ∂μ = c * μ univ := by rw [← SimpleFunc.const_lintegral, ← SimpleFunc.lintegral_eq_lintegral, SimpleFunc.coe_const] rfl #align measure_theory.lintegral_const MeasureTheory.lintegral_const theorem lintegral_zero : ∫⁻ _ : α, 0 ∂μ = 0 := by simp #align measure_theory.lintegral_zero MeasureTheory.lintegral_zero theorem lintegral_zero_fun : lintegral μ (0 : α → ℝ≥0∞) = 0 := lintegral_zero #align measure_theory.lintegral_zero_fun MeasureTheory.lintegral_zero_fun -- @[simp] -- Porting note (#10618): simp can prove this theorem lintegral_one : ∫⁻ _, (1 : ℝ≥0∞) ∂μ = μ univ := by rw [lintegral_const, one_mul] #align measure_theory.lintegral_one MeasureTheory.lintegral_one theorem set_lintegral_const (s : Set α) (c : ℝ≥0∞) : ∫⁻ _ in s, c ∂μ = c * μ s := by rw [lintegral_const, Measure.restrict_apply_univ] #align measure_theory.set_lintegral_const MeasureTheory.set_lintegral_const theorem set_lintegral_one (s) : ∫⁻ _ in s, 1 ∂μ = μ s := by rw [set_lintegral_const, one_mul] #align measure_theory.set_lintegral_one MeasureTheory.set_lintegral_one theorem set_lintegral_const_lt_top [IsFiniteMeasure μ] (s : Set α) {c : ℝ≥0∞} (hc : c ≠ ∞) : ∫⁻ _ in s, c ∂μ < ∞ := by rw [lintegral_const] exact ENNReal.mul_lt_top hc (measure_ne_top (μ.restrict s) univ) #align measure_theory.set_lintegral_const_lt_top MeasureTheory.set_lintegral_const_lt_top theorem lintegral_const_lt_top [IsFiniteMeasure μ] {c : ℝ≥0∞} (hc : c ≠ ∞) : ∫⁻ _, c ∂μ < ∞ := by simpa only [Measure.restrict_univ] using set_lintegral_const_lt_top (univ : Set α) hc #align measure_theory.lintegral_const_lt_top MeasureTheory.lintegral_const_lt_top section variable (μ) theorem exists_measurable_le_lintegral_eq (f : α → ℝ≥0∞) : ∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := by rcases eq_or_ne (∫⁻ a, f a ∂μ) 0 with h₀ | h₀ · exact ⟨0, measurable_zero, zero_le f, h₀.trans lintegral_zero.symm⟩ rcases exists_seq_strictMono_tendsto' h₀.bot_lt with ⟨L, _, hLf, hL_tendsto⟩ have : ∀ n, ∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ L n < ∫⁻ a, g a ∂μ := by intro n simpa only [← iSup_lintegral_measurable_le_eq_lintegral f, lt_iSup_iff, exists_prop] using (hLf n).2 choose g hgm hgf hLg using this refine ⟨fun x => ⨆ n, g n x, measurable_iSup hgm, fun x => iSup_le fun n => hgf n x, le_antisymm ?_ ?_⟩ · refine le_of_tendsto' hL_tendsto fun n => (hLg n).le.trans <| lintegral_mono fun x => ?_ exact le_iSup (fun n => g n x) n · exact lintegral_mono fun x => iSup_le fun n => hgf n x #align measure_theory.exists_measurable_le_lintegral_eq MeasureTheory.exists_measurable_le_lintegral_eq end theorem lintegral_eq_nnreal {m : MeasurableSpace α} (f : α → ℝ≥0∞) (μ : Measure α) : ∫⁻ a, f a ∂μ = ⨆ (φ : α →ₛ ℝ≥0) (_ : ∀ x, ↑(φ x) ≤ f x), (φ.map ((↑) : ℝ≥0 → ℝ≥0∞)).lintegral μ := by rw [lintegral] refine le_antisymm (iSup₂_le fun φ hφ => ?_) (iSup_mono' fun φ => ⟨φ.map ((↑) : ℝ≥0 → ℝ≥0∞), le_rfl⟩) by_cases h : ∀ᵐ a ∂μ, φ a ≠ ∞ · let ψ := φ.map ENNReal.toNNReal replace h : ψ.map ((↑) : ℝ≥0 → ℝ≥0∞) =ᵐ[μ] φ := h.mono fun a => ENNReal.coe_toNNReal have : ∀ x, ↑(ψ x) ≤ f x := fun x => le_trans ENNReal.coe_toNNReal_le_self (hφ x) exact le_iSup_of_le (φ.map ENNReal.toNNReal) (le_iSup_of_le this (ge_of_eq <| lintegral_congr h)) · have h_meas : μ (φ ⁻¹' {∞}) ≠ 0 := mt measure_zero_iff_ae_nmem.1 h refine le_trans le_top (ge_of_eq <| (iSup_eq_top _).2 fun b hb => ?_) obtain ⟨n, hn⟩ : ∃ n : ℕ, b < n * μ (φ ⁻¹' {∞}) := exists_nat_mul_gt h_meas (ne_of_lt hb) use (const α (n : ℝ≥0)).restrict (φ ⁻¹' {∞}) simp only [lt_iSup_iff, exists_prop, coe_restrict, φ.measurableSet_preimage, coe_const, ENNReal.coe_indicator, map_coe_ennreal_restrict, SimpleFunc.map_const, ENNReal.coe_natCast, restrict_const_lintegral] refine ⟨indicator_le fun x hx => le_trans ?_ (hφ _), hn⟩ simp only [mem_preimage, mem_singleton_iff] at hx simp only [hx, le_top] #align measure_theory.lintegral_eq_nnreal MeasureTheory.lintegral_eq_nnreal theorem exists_simpleFunc_forall_lintegral_sub_lt_of_pos {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ φ : α →ₛ ℝ≥0, (∀ x, ↑(φ x) ≤ f x) ∧ ∀ ψ : α →ₛ ℝ≥0, (∀ x, ↑(ψ x) ≤ f x) → (map (↑) (ψ - φ)).lintegral μ < ε := by rw [lintegral_eq_nnreal] at h have := ENNReal.lt_add_right h hε erw [ENNReal.biSup_add] at this <;> [skip; exact ⟨0, fun x => zero_le _⟩] simp_rw [lt_iSup_iff, iSup_lt_iff, iSup_le_iff] at this rcases this with ⟨φ, hle : ∀ x, ↑(φ x) ≤ f x, b, hbφ, hb⟩ refine ⟨φ, hle, fun ψ hψ => ?_⟩ have : (map (↑) φ).lintegral μ ≠ ∞ := ne_top_of_le_ne_top h (by exact le_iSup₂ (α := ℝ≥0∞) φ hle) rw [← ENNReal.add_lt_add_iff_left this, ← add_lintegral, ← SimpleFunc.map_add @ENNReal.coe_add] refine (hb _ fun x => le_trans ?_ (max_le (hle x) (hψ x))).trans_lt hbφ norm_cast simp only [add_apply, sub_apply, add_tsub_eq_max] rfl #align measure_theory.exists_simple_func_forall_lintegral_sub_lt_of_pos MeasureTheory.exists_simpleFunc_forall_lintegral_sub_lt_of_pos theorem iSup_lintegral_le {ι : Sort*} (f : ι → α → ℝ≥0∞) : ⨆ i, ∫⁻ a, f i a ∂μ ≤ ∫⁻ a, ⨆ i, f i a ∂μ := by simp only [← iSup_apply] exact (monotone_lintegral μ).le_map_iSup #align measure_theory.supr_lintegral_le MeasureTheory.iSup_lintegral_le theorem iSup₂_lintegral_le {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) : ⨆ (i) (j), ∫⁻ a, f i j a ∂μ ≤ ∫⁻ a, ⨆ (i) (j), f i j a ∂μ := by convert (monotone_lintegral μ).le_map_iSup₂ f with a simp only [iSup_apply] #align measure_theory.supr₂_lintegral_le MeasureTheory.iSup₂_lintegral_le theorem le_iInf_lintegral {ι : Sort*} (f : ι → α → ℝ≥0∞) : ∫⁻ a, ⨅ i, f i a ∂μ ≤ ⨅ i, ∫⁻ a, f i a ∂μ := by simp only [← iInf_apply] exact (monotone_lintegral μ).map_iInf_le #align measure_theory.le_infi_lintegral MeasureTheory.le_iInf_lintegral theorem le_iInf₂_lintegral {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) : ∫⁻ a, ⨅ (i) (h : ι' i), f i h a ∂μ ≤ ⨅ (i) (h : ι' i), ∫⁻ a, f i h a ∂μ := by convert (monotone_lintegral μ).map_iInf₂_le f with a simp only [iInf_apply] #align measure_theory.le_infi₂_lintegral MeasureTheory.le_iInf₂_lintegral theorem lintegral_mono_ae {f g : α → ℝ≥0∞} (h : ∀ᵐ a ∂μ, f a ≤ g a) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := by rcases exists_measurable_superset_of_null h with ⟨t, hts, ht, ht0⟩ have : ∀ᵐ x ∂μ, x ∉ t := measure_zero_iff_ae_nmem.1 ht0 rw [lintegral, lintegral] refine iSup_le fun s => iSup_le fun hfs => le_iSup_of_le (s.restrict tᶜ) <| le_iSup_of_le ?_ ?_ · intro a by_cases h : a ∈ t <;> simp only [restrict_apply s ht.compl, mem_compl_iff, h, not_true, not_false_eq_true, indicator_of_not_mem, zero_le, not_false_eq_true, indicator_of_mem] exact le_trans (hfs a) (_root_.by_contradiction fun hnfg => h (hts hnfg)) · refine le_of_eq (SimpleFunc.lintegral_congr <| this.mono fun a hnt => ?_) by_cases hat : a ∈ t <;> simp only [restrict_apply s ht.compl, mem_compl_iff, hat, not_true, not_false_eq_true, indicator_of_not_mem, not_false_eq_true, indicator_of_mem] exact (hnt hat).elim #align measure_theory.lintegral_mono_ae MeasureTheory.lintegral_mono_ae theorem set_lintegral_mono_ae {s : Set α} {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) (hfg : ∀ᵐ x ∂μ, x ∈ s → f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ := lintegral_mono_ae <| (ae_restrict_iff <| measurableSet_le hf hg).2 hfg #align measure_theory.set_lintegral_mono_ae MeasureTheory.set_lintegral_mono_ae theorem set_lintegral_mono {s : Set α} {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) (hfg : ∀ x ∈ s, f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ := set_lintegral_mono_ae hf hg (ae_of_all _ hfg) #align measure_theory.set_lintegral_mono MeasureTheory.set_lintegral_mono theorem set_lintegral_mono_ae' {s : Set α} {f g : α → ℝ≥0∞} (hs : MeasurableSet s) (hfg : ∀ᵐ x ∂μ, x ∈ s → f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ := lintegral_mono_ae <| (ae_restrict_iff' hs).2 hfg theorem set_lintegral_mono' {s : Set α} {f g : α → ℝ≥0∞} (hs : MeasurableSet s) (hfg : ∀ x ∈ s, f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ := set_lintegral_mono_ae' hs (ae_of_all _ hfg) theorem set_lintegral_le_lintegral (s : Set α) (f : α → ℝ≥0∞) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x, f x ∂μ := lintegral_mono' Measure.restrict_le_self le_rfl theorem lintegral_congr_ae {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) : ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := le_antisymm (lintegral_mono_ae <| h.le) (lintegral_mono_ae <| h.symm.le) #align measure_theory.lintegral_congr_ae MeasureTheory.lintegral_congr_ae theorem lintegral_congr {f g : α → ℝ≥0∞} (h : ∀ a, f a = g a) : ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := by simp only [h] #align measure_theory.lintegral_congr MeasureTheory.lintegral_congr theorem set_lintegral_congr {f : α → ℝ≥0∞} {s t : Set α} (h : s =ᵐ[μ] t) : ∫⁻ x in s, f x ∂μ = ∫⁻ x in t, f x ∂μ := by rw [Measure.restrict_congr_set h] #align measure_theory.set_lintegral_congr MeasureTheory.set_lintegral_congr theorem set_lintegral_congr_fun {f g : α → ℝ≥0∞} {s : Set α} (hs : MeasurableSet s) (hfg : ∀ᵐ x ∂μ, x ∈ s → f x = g x) : ∫⁻ x in s, f x ∂μ = ∫⁻ x in s, g x ∂μ := by rw [lintegral_congr_ae] rw [EventuallyEq] rwa [ae_restrict_iff' hs] #align measure_theory.set_lintegral_congr_fun MeasureTheory.set_lintegral_congr_fun theorem lintegral_ofReal_le_lintegral_nnnorm (f : α → ℝ) : ∫⁻ x, ENNReal.ofReal (f x) ∂μ ≤ ∫⁻ x, ‖f x‖₊ ∂μ := by simp_rw [← ofReal_norm_eq_coe_nnnorm] refine lintegral_mono fun x => ENNReal.ofReal_le_ofReal ?_ rw [Real.norm_eq_abs] exact le_abs_self (f x) #align measure_theory.lintegral_of_real_le_lintegral_nnnorm MeasureTheory.lintegral_ofReal_le_lintegral_nnnorm theorem lintegral_nnnorm_eq_of_ae_nonneg {f : α → ℝ} (h_nonneg : 0 ≤ᵐ[μ] f) : ∫⁻ x, ‖f x‖₊ ∂μ = ∫⁻ x, ENNReal.ofReal (f x) ∂μ := by apply lintegral_congr_ae filter_upwards [h_nonneg] with x hx rw [Real.nnnorm_of_nonneg hx, ENNReal.ofReal_eq_coe_nnreal hx] #align measure_theory.lintegral_nnnorm_eq_of_ae_nonneg MeasureTheory.lintegral_nnnorm_eq_of_ae_nonneg theorem lintegral_nnnorm_eq_of_nonneg {f : α → ℝ} (h_nonneg : 0 ≤ f) : ∫⁻ x, ‖f x‖₊ ∂μ = ∫⁻ x, ENNReal.ofReal (f x) ∂μ := lintegral_nnnorm_eq_of_ae_nonneg (Filter.eventually_of_forall h_nonneg) #align measure_theory.lintegral_nnnorm_eq_of_nonneg MeasureTheory.lintegral_nnnorm_eq_of_nonneg theorem lintegral_iSup {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, Measurable (f n)) (h_mono : Monotone f) : ∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by set c : ℝ≥0 → ℝ≥0∞ := (↑) set F := fun a : α => ⨆ n, f n a refine le_antisymm ?_ (iSup_lintegral_le _) rw [lintegral_eq_nnreal] refine iSup_le fun s => iSup_le fun hsf => ?_ refine ENNReal.le_of_forall_lt_one_mul_le fun a ha => ?_ rcases ENNReal.lt_iff_exists_coe.1 ha with ⟨r, rfl, _⟩ have ha : r < 1 := ENNReal.coe_lt_coe.1 ha let rs := s.map fun a => r * a have eq_rs : rs.map c = (const α r : α →ₛ ℝ≥0∞) * map c s := rfl have eq : ∀ p, rs.map c ⁻¹' {p} = ⋃ n, rs.map c ⁻¹' {p} ∩ { a | p ≤ f n a } := by intro p rw [← inter_iUnion]; nth_rw 1 [← inter_univ (map c rs ⁻¹' {p})] refine Set.ext fun x => and_congr_right fun hx => true_iff_iff.2 ?_ by_cases p_eq : p = 0 · simp [p_eq] simp only [coe_map, mem_preimage, Function.comp_apply, mem_singleton_iff] at hx subst hx have : r * s x ≠ 0 := by rwa [Ne, ← ENNReal.coe_eq_zero] have : s x ≠ 0 := right_ne_zero_of_mul this have : (rs.map c) x < ⨆ n : ℕ, f n x := by refine lt_of_lt_of_le (ENNReal.coe_lt_coe.2 ?_) (hsf x) suffices r * s x < 1 * s x by simpa exact mul_lt_mul_of_pos_right ha (pos_iff_ne_zero.2 this) rcases lt_iSup_iff.1 this with ⟨i, hi⟩ exact mem_iUnion.2 ⟨i, le_of_lt hi⟩ have mono : ∀ r : ℝ≥0∞, Monotone fun n => rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a } := by intro r i j h refine inter_subset_inter_right _ ?_ simp_rw [subset_def, mem_setOf] intro x hx exact le_trans hx (h_mono h x) have h_meas : ∀ n, MeasurableSet {a : α | map c rs a ≤ f n a} := fun n => measurableSet_le (SimpleFunc.measurable _) (hf n) calc (r : ℝ≥0∞) * (s.map c).lintegral μ = ∑ r ∈ (rs.map c).range, r * μ (rs.map c ⁻¹' {r}) := by rw [← const_mul_lintegral, eq_rs, SimpleFunc.lintegral] _ = ∑ r ∈ (rs.map c).range, r * μ (⋃ n, rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := by simp only [(eq _).symm] _ = ∑ r ∈ (rs.map c).range, ⨆ n, r * μ (rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := (Finset.sum_congr rfl fun x _ => by rw [measure_iUnion_eq_iSup (mono x).directed_le, ENNReal.mul_iSup]) _ = ⨆ n, ∑ r ∈ (rs.map c).range, r * μ (rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := by refine ENNReal.finset_sum_iSup_nat fun p i j h ↦ ?_ gcongr _ * μ ?_ exact mono p h _ ≤ ⨆ n : ℕ, ((rs.map c).restrict { a | (rs.map c) a ≤ f n a }).lintegral μ := by gcongr with n rw [restrict_lintegral _ (h_meas n)] refine le_of_eq (Finset.sum_congr rfl fun r _ => ?_) congr 2 with a refine and_congr_right ?_ simp (config := { contextual := true }) _ ≤ ⨆ n, ∫⁻ a, f n a ∂μ := by simp only [← SimpleFunc.lintegral_eq_lintegral] gcongr with n a simp only [map_apply] at h_meas simp only [coe_map, restrict_apply _ (h_meas _), (· ∘ ·)] exact indicator_apply_le id #align measure_theory.lintegral_supr MeasureTheory.lintegral_iSup theorem lintegral_iSup' {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, AEMeasurable (f n) μ) (h_mono : ∀ᵐ x ∂μ, Monotone fun n => f n x) : ∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by simp_rw [← iSup_apply] let p : α → (ℕ → ℝ≥0∞) → Prop := fun _ f' => Monotone f' have hp : ∀ᵐ x ∂μ, p x fun i => f i x := h_mono have h_ae_seq_mono : Monotone (aeSeq hf p) := by intro n m hnm x by_cases hx : x ∈ aeSeqSet hf p · exact aeSeq.prop_of_mem_aeSeqSet hf hx hnm · simp only [aeSeq, hx, if_false, le_rfl] rw [lintegral_congr_ae (aeSeq.iSup hf hp).symm] simp_rw [iSup_apply] rw [lintegral_iSup (aeSeq.measurable hf p) h_ae_seq_mono] congr with n exact lintegral_congr_ae (aeSeq.aeSeq_n_eq_fun_n_ae hf hp n) #align measure_theory.lintegral_supr' MeasureTheory.lintegral_iSup' theorem lintegral_tendsto_of_tendsto_of_monotone {f : ℕ → α → ℝ≥0∞} {F : α → ℝ≥0∞} (hf : ∀ n, AEMeasurable (f n) μ) (h_mono : ∀ᵐ x ∂μ, Monotone fun n => f n x) (h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 <| F x)) : Tendsto (fun n => ∫⁻ x, f n x ∂μ) atTop (𝓝 <| ∫⁻ x, F x ∂μ) := by have : Monotone fun n => ∫⁻ x, f n x ∂μ := fun i j hij => lintegral_mono_ae (h_mono.mono fun x hx => hx hij) suffices key : ∫⁻ x, F x ∂μ = ⨆ n, ∫⁻ x, f n x ∂μ by rw [key] exact tendsto_atTop_iSup this rw [← lintegral_iSup' hf h_mono] refine lintegral_congr_ae ?_ filter_upwards [h_mono, h_tendsto] with _ hx_mono hx_tendsto using tendsto_nhds_unique hx_tendsto (tendsto_atTop_iSup hx_mono) #align measure_theory.lintegral_tendsto_of_tendsto_of_monotone MeasureTheory.lintegral_tendsto_of_tendsto_of_monotone theorem lintegral_eq_iSup_eapprox_lintegral {f : α → ℝ≥0∞} (hf : Measurable f) : ∫⁻ a, f a ∂μ = ⨆ n, (eapprox f n).lintegral μ := calc ∫⁻ a, f a ∂μ = ∫⁻ a, ⨆ n, (eapprox f n : α → ℝ≥0∞) a ∂μ := by congr; ext a; rw [iSup_eapprox_apply f hf] _ = ⨆ n, ∫⁻ a, (eapprox f n : α → ℝ≥0∞) a ∂μ := by apply lintegral_iSup · measurability · intro i j h exact monotone_eapprox f h _ = ⨆ n, (eapprox f n).lintegral μ := by congr; ext n; rw [(eapprox f n).lintegral_eq_lintegral] #align measure_theory.lintegral_eq_supr_eapprox_lintegral MeasureTheory.lintegral_eq_iSup_eapprox_lintegral theorem exists_pos_set_lintegral_lt_of_measure_lt {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ δ > 0, ∀ s, μ s < δ → ∫⁻ x in s, f x ∂μ < ε := by rcases exists_between (pos_iff_ne_zero.mpr hε) with ⟨ε₂, hε₂0, hε₂ε⟩ rcases exists_between hε₂0 with ⟨ε₁, hε₁0, hε₁₂⟩ rcases exists_simpleFunc_forall_lintegral_sub_lt_of_pos h hε₁0.ne' with ⟨φ, _, hφ⟩ rcases φ.exists_forall_le with ⟨C, hC⟩ use (ε₂ - ε₁) / C, ENNReal.div_pos_iff.2 ⟨(tsub_pos_iff_lt.2 hε₁₂).ne', ENNReal.coe_ne_top⟩ refine fun s hs => lt_of_le_of_lt ?_ hε₂ε simp only [lintegral_eq_nnreal, iSup_le_iff] intro ψ hψ calc (map (↑) ψ).lintegral (μ.restrict s) ≤ (map (↑) φ).lintegral (μ.restrict s) + (map (↑) (ψ - φ)).lintegral (μ.restrict s) := by rw [← SimpleFunc.add_lintegral, ← SimpleFunc.map_add @ENNReal.coe_add] refine SimpleFunc.lintegral_mono (fun x => ?_) le_rfl simp only [add_tsub_eq_max, le_max_right, coe_map, Function.comp_apply, SimpleFunc.coe_add, SimpleFunc.coe_sub, Pi.add_apply, Pi.sub_apply, ENNReal.coe_max (φ x) (ψ x)] _ ≤ (map (↑) φ).lintegral (μ.restrict s) + ε₁ := by gcongr refine le_trans ?_ (hφ _ hψ).le exact SimpleFunc.lintegral_mono le_rfl Measure.restrict_le_self _ ≤ (SimpleFunc.const α (C : ℝ≥0∞)).lintegral (μ.restrict s) + ε₁ := by gcongr exact SimpleFunc.lintegral_mono (fun x ↦ ENNReal.coe_le_coe.2 (hC x)) le_rfl _ = C * μ s + ε₁ := by simp only [← SimpleFunc.lintegral_eq_lintegral, coe_const, lintegral_const, Measure.restrict_apply, MeasurableSet.univ, univ_inter, Function.const] _ ≤ C * ((ε₂ - ε₁) / C) + ε₁ := by gcongr _ ≤ ε₂ - ε₁ + ε₁ := by gcongr; apply mul_div_le _ = ε₂ := tsub_add_cancel_of_le hε₁₂.le #align measure_theory.exists_pos_set_lintegral_lt_of_measure_lt MeasureTheory.exists_pos_set_lintegral_lt_of_measure_lt theorem tendsto_set_lintegral_zero {ι} {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {l : Filter ι} {s : ι → Set α} (hl : Tendsto (μ ∘ s) l (𝓝 0)) : Tendsto (fun i => ∫⁻ x in s i, f x ∂μ) l (𝓝 0) := by simp only [ENNReal.nhds_zero, tendsto_iInf, tendsto_principal, mem_Iio, ← pos_iff_ne_zero] at hl ⊢ intro ε ε0 rcases exists_pos_set_lintegral_lt_of_measure_lt h ε0.ne' with ⟨δ, δ0, hδ⟩ exact (hl δ δ0).mono fun i => hδ _ #align measure_theory.tendsto_set_lintegral_zero MeasureTheory.tendsto_set_lintegral_zero theorem le_lintegral_add (f g : α → ℝ≥0∞) : ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ ≤ ∫⁻ a, f a + g a ∂μ := by simp only [lintegral] refine ENNReal.biSup_add_biSup_le' (p := fun h : α →ₛ ℝ≥0∞ => h ≤ f) (q := fun h : α →ₛ ℝ≥0∞ => h ≤ g) ⟨0, zero_le f⟩ ⟨0, zero_le g⟩ fun f' hf' g' hg' => ?_ exact le_iSup₂_of_le (f' + g') (add_le_add hf' hg') (add_lintegral _ _).ge #align measure_theory.le_lintegral_add MeasureTheory.le_lintegral_add -- Use stronger lemmas `lintegral_add_left`/`lintegral_add_right` instead theorem lintegral_add_aux {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := calc ∫⁻ a, f a + g a ∂μ = ∫⁻ a, (⨆ n, (eapprox f n : α → ℝ≥0∞) a) + ⨆ n, (eapprox g n : α → ℝ≥0∞) a ∂μ := by simp only [iSup_eapprox_apply, hf, hg] _ = ∫⁻ a, ⨆ n, (eapprox f n + eapprox g n : α → ℝ≥0∞) a ∂μ := by congr; funext a rw [ENNReal.iSup_add_iSup_of_monotone] · simp only [Pi.add_apply] · intro i j h exact monotone_eapprox _ h a · intro i j h exact monotone_eapprox _ h a _ = ⨆ n, (eapprox f n).lintegral μ + (eapprox g n).lintegral μ := by rw [lintegral_iSup] · congr funext n rw [← SimpleFunc.add_lintegral, ← SimpleFunc.lintegral_eq_lintegral] simp only [Pi.add_apply, SimpleFunc.coe_add] · measurability · intro i j h a dsimp gcongr <;> exact monotone_eapprox _ h _ _ = (⨆ n, (eapprox f n).lintegral μ) + ⨆ n, (eapprox g n).lintegral μ := by refine (ENNReal.iSup_add_iSup_of_monotone ?_ ?_).symm <;> · intro i j h exact SimpleFunc.lintegral_mono (monotone_eapprox _ h) le_rfl _ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by rw [lintegral_eq_iSup_eapprox_lintegral hf, lintegral_eq_iSup_eapprox_lintegral hg] #align measure_theory.lintegral_add_aux MeasureTheory.lintegral_add_aux @[simp] theorem lintegral_add_left {f : α → ℝ≥0∞} (hf : Measurable f) (g : α → ℝ≥0∞) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by refine le_antisymm ?_ (le_lintegral_add _ _) rcases exists_measurable_le_lintegral_eq μ fun a => f a + g a with ⟨φ, hφm, hφ_le, hφ_eq⟩ calc ∫⁻ a, f a + g a ∂μ = ∫⁻ a, φ a ∂μ := hφ_eq _ ≤ ∫⁻ a, f a + (φ a - f a) ∂μ := lintegral_mono fun a => le_add_tsub _ = ∫⁻ a, f a ∂μ + ∫⁻ a, φ a - f a ∂μ := lintegral_add_aux hf (hφm.sub hf) _ ≤ ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := add_le_add_left (lintegral_mono fun a => tsub_le_iff_left.2 <| hφ_le a) _ #align measure_theory.lintegral_add_left MeasureTheory.lintegral_add_left theorem lintegral_add_left' {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (g : α → ℝ≥0∞) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by rw [lintegral_congr_ae hf.ae_eq_mk, ← lintegral_add_left hf.measurable_mk, lintegral_congr_ae (hf.ae_eq_mk.add (ae_eq_refl g))] #align measure_theory.lintegral_add_left' MeasureTheory.lintegral_add_left' theorem lintegral_add_right' (f : α → ℝ≥0∞) {g : α → ℝ≥0∞} (hg : AEMeasurable g μ) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by simpa only [add_comm] using lintegral_add_left' hg f #align measure_theory.lintegral_add_right' MeasureTheory.lintegral_add_right' @[simp] theorem lintegral_add_right (f : α → ℝ≥0∞) {g : α → ℝ≥0∞} (hg : Measurable g) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := lintegral_add_right' f hg.aemeasurable #align measure_theory.lintegral_add_right MeasureTheory.lintegral_add_right @[simp] theorem lintegral_smul_measure (c : ℝ≥0∞) (f : α → ℝ≥0∞) : ∫⁻ a, f a ∂c • μ = c * ∫⁻ a, f a ∂μ := by simp only [lintegral, iSup_subtype', SimpleFunc.lintegral_smul, ENNReal.mul_iSup, smul_eq_mul] #align measure_theory.lintegral_smul_measure MeasureTheory.lintegral_smul_measure lemma set_lintegral_smul_measure (c : ℝ≥0∞) (f : α → ℝ≥0∞) (s : Set α) : ∫⁻ a in s, f a ∂(c • μ) = c * ∫⁻ a in s, f a ∂μ := by rw [Measure.restrict_smul, lintegral_smul_measure] @[simp] theorem lintegral_sum_measure {m : MeasurableSpace α} {ι} (f : α → ℝ≥0∞) (μ : ι → Measure α) : ∫⁻ a, f a ∂Measure.sum μ = ∑' i, ∫⁻ a, f a ∂μ i := by simp only [lintegral, iSup_subtype', SimpleFunc.lintegral_sum, ENNReal.tsum_eq_iSup_sum] rw [iSup_comm] congr; funext s induction' s using Finset.induction_on with i s hi hs · simp simp only [Finset.sum_insert hi, ← hs] refine (ENNReal.iSup_add_iSup ?_).symm intro φ ψ exact ⟨⟨φ ⊔ ψ, fun x => sup_le (φ.2 x) (ψ.2 x)⟩, add_le_add (SimpleFunc.lintegral_mono le_sup_left le_rfl) (Finset.sum_le_sum fun j _ => SimpleFunc.lintegral_mono le_sup_right le_rfl)⟩ #align measure_theory.lintegral_sum_measure MeasureTheory.lintegral_sum_measure theorem hasSum_lintegral_measure {ι} {_ : MeasurableSpace α} (f : α → ℝ≥0∞) (μ : ι → Measure α) : HasSum (fun i => ∫⁻ a, f a ∂μ i) (∫⁻ a, f a ∂Measure.sum μ) := (lintegral_sum_measure f μ).symm ▸ ENNReal.summable.hasSum #align measure_theory.has_sum_lintegral_measure MeasureTheory.hasSum_lintegral_measure @[simp] theorem lintegral_add_measure {m : MeasurableSpace α} (f : α → ℝ≥0∞) (μ ν : Measure α) : ∫⁻ a, f a ∂(μ + ν) = ∫⁻ a, f a ∂μ + ∫⁻ a, f a ∂ν := by simpa [tsum_fintype] using lintegral_sum_measure f fun b => cond b μ ν #align measure_theory.lintegral_add_measure MeasureTheory.lintegral_add_measure @[simp] theorem lintegral_finset_sum_measure {ι} {m : MeasurableSpace α} (s : Finset ι) (f : α → ℝ≥0∞) (μ : ι → Measure α) : ∫⁻ a, f a ∂(∑ i ∈ s, μ i) = ∑ i ∈ s, ∫⁻ a, f a ∂μ i := by rw [← Measure.sum_coe_finset, lintegral_sum_measure, ← Finset.tsum_subtype'] simp only [Finset.coe_sort_coe] #align measure_theory.lintegral_finset_sum_measure MeasureTheory.lintegral_finset_sum_measure @[simp] theorem lintegral_zero_measure {m : MeasurableSpace α} (f : α → ℝ≥0∞) : ∫⁻ a, f a ∂(0 : Measure α) = 0 := by simp [lintegral] #align measure_theory.lintegral_zero_measure MeasureTheory.lintegral_zero_measure @[simp] theorem lintegral_of_isEmpty {α} [MeasurableSpace α] [IsEmpty α] (μ : Measure α) (f : α → ℝ≥0∞) : ∫⁻ x, f x ∂μ = 0 := by have : Subsingleton (Measure α) := inferInstance convert lintegral_zero_measure f theorem set_lintegral_empty (f : α → ℝ≥0∞) : ∫⁻ x in ∅, f x ∂μ = 0 := by rw [Measure.restrict_empty, lintegral_zero_measure] #align measure_theory.set_lintegral_empty MeasureTheory.set_lintegral_empty theorem set_lintegral_univ (f : α → ℝ≥0∞) : ∫⁻ x in univ, f x ∂μ = ∫⁻ x, f x ∂μ := by rw [Measure.restrict_univ] #align measure_theory.set_lintegral_univ MeasureTheory.set_lintegral_univ theorem set_lintegral_measure_zero (s : Set α) (f : α → ℝ≥0∞) (hs' : μ s = 0) : ∫⁻ x in s, f x ∂μ = 0 := by convert lintegral_zero_measure _ exact Measure.restrict_eq_zero.2 hs' #align measure_theory.set_lintegral_measure_zero MeasureTheory.set_lintegral_measure_zero theorem lintegral_finset_sum' (s : Finset β) {f : β → α → ℝ≥0∞} (hf : ∀ b ∈ s, AEMeasurable (f b) μ) : ∫⁻ a, ∑ b ∈ s, f b a ∂μ = ∑ b ∈ s, ∫⁻ a, f b a ∂μ := by induction' s using Finset.induction_on with a s has ih · simp · simp only [Finset.sum_insert has] rw [Finset.forall_mem_insert] at hf rw [lintegral_add_left' hf.1, ih hf.2] #align measure_theory.lintegral_finset_sum' MeasureTheory.lintegral_finset_sum' theorem lintegral_finset_sum (s : Finset β) {f : β → α → ℝ≥0∞} (hf : ∀ b ∈ s, Measurable (f b)) : ∫⁻ a, ∑ b ∈ s, f b a ∂μ = ∑ b ∈ s, ∫⁻ a, f b a ∂μ := lintegral_finset_sum' s fun b hb => (hf b hb).aemeasurable #align measure_theory.lintegral_finset_sum MeasureTheory.lintegral_finset_sum @[simp] theorem lintegral_const_mul (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : Measurable f) : ∫⁻ a, r * f a ∂μ = r * ∫⁻ a, f a ∂μ := calc ∫⁻ a, r * f a ∂μ = ∫⁻ a, ⨆ n, (const α r * eapprox f n) a ∂μ := by congr funext a rw [← iSup_eapprox_apply f hf, ENNReal.mul_iSup] simp _ = ⨆ n, r * (eapprox f n).lintegral μ := by rw [lintegral_iSup] · congr funext n rw [← SimpleFunc.const_mul_lintegral, ← SimpleFunc.lintegral_eq_lintegral] · intro n exact SimpleFunc.measurable _ · intro i j h a exact mul_le_mul_left' (monotone_eapprox _ h _) _ _ = r * ∫⁻ a, f a ∂μ := by rw [← ENNReal.mul_iSup, lintegral_eq_iSup_eapprox_lintegral hf] #align measure_theory.lintegral_const_mul MeasureTheory.lintegral_const_mul theorem lintegral_const_mul'' (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) : ∫⁻ a, r * f a ∂μ = r * ∫⁻ a, f a ∂μ := by have A : ∫⁻ a, f a ∂μ = ∫⁻ a, hf.mk f a ∂μ := lintegral_congr_ae hf.ae_eq_mk have B : ∫⁻ a, r * f a ∂μ = ∫⁻ a, r * hf.mk f a ∂μ := lintegral_congr_ae (EventuallyEq.fun_comp hf.ae_eq_mk _) rw [A, B, lintegral_const_mul _ hf.measurable_mk] #align measure_theory.lintegral_const_mul'' MeasureTheory.lintegral_const_mul'' theorem lintegral_const_mul_le (r : ℝ≥0∞) (f : α → ℝ≥0∞) : r * ∫⁻ a, f a ∂μ ≤ ∫⁻ a, r * f a ∂μ := by rw [lintegral, ENNReal.mul_iSup] refine iSup_le fun s => ?_ rw [ENNReal.mul_iSup, iSup_le_iff] intro hs rw [← SimpleFunc.const_mul_lintegral, lintegral] refine le_iSup_of_le (const α r * s) (le_iSup_of_le (fun x => ?_) le_rfl) exact mul_le_mul_left' (hs x) _ #align measure_theory.lintegral_const_mul_le MeasureTheory.lintegral_const_mul_le theorem lintegral_const_mul' (r : ℝ≥0∞) (f : α → ℝ≥0∞) (hr : r ≠ ∞) : ∫⁻ a, r * f a ∂μ = r * ∫⁻ a, f a ∂μ := by by_cases h : r = 0 · simp [h] apply le_antisymm _ (lintegral_const_mul_le r f) have rinv : r * r⁻¹ = 1 := ENNReal.mul_inv_cancel h hr have rinv' : r⁻¹ * r = 1 := by rw [mul_comm] exact rinv have := lintegral_const_mul_le (μ := μ) r⁻¹ fun x => r * f x simp? [(mul_assoc _ _ _).symm, rinv'] at this says simp only [(mul_assoc _ _ _).symm, rinv', one_mul] at this simpa [(mul_assoc _ _ _).symm, rinv] using mul_le_mul_left' this r #align measure_theory.lintegral_const_mul' MeasureTheory.lintegral_const_mul' theorem lintegral_mul_const (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : Measurable f) : ∫⁻ a, f a * r ∂μ = (∫⁻ a, f a ∂μ) * r := by simp_rw [mul_comm, lintegral_const_mul r hf] #align measure_theory.lintegral_mul_const MeasureTheory.lintegral_mul_const theorem lintegral_mul_const'' (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) : ∫⁻ a, f a * r ∂μ = (∫⁻ a, f a ∂μ) * r := by simp_rw [mul_comm, lintegral_const_mul'' r hf] #align measure_theory.lintegral_mul_const'' MeasureTheory.lintegral_mul_const'' theorem lintegral_mul_const_le (r : ℝ≥0∞) (f : α → ℝ≥0∞) : (∫⁻ a, f a ∂μ) * r ≤ ∫⁻ a, f a * r ∂μ := by simp_rw [mul_comm, lintegral_const_mul_le r f] #align measure_theory.lintegral_mul_const_le MeasureTheory.lintegral_mul_const_le theorem lintegral_mul_const' (r : ℝ≥0∞) (f : α → ℝ≥0∞) (hr : r ≠ ∞) : ∫⁻ a, f a * r ∂μ = (∫⁻ a, f a ∂μ) * r := by simp_rw [mul_comm, lintegral_const_mul' r f hr] #align measure_theory.lintegral_mul_const' MeasureTheory.lintegral_mul_const' theorem lintegral_lintegral_mul {β} [MeasurableSpace β] {ν : Measure β} {f : α → ℝ≥0∞} {g : β → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g ν) : ∫⁻ x, ∫⁻ y, f x * g y ∂ν ∂μ = (∫⁻ x, f x ∂μ) * ∫⁻ y, g y ∂ν := by simp [lintegral_const_mul'' _ hg, lintegral_mul_const'' _ hf] #align measure_theory.lintegral_lintegral_mul MeasureTheory.lintegral_lintegral_mul -- TODO: Need a better way of rewriting inside of an integral theorem lintegral_rw₁ {f f' : α → β} (h : f =ᵐ[μ] f') (g : β → ℝ≥0∞) : ∫⁻ a, g (f a) ∂μ = ∫⁻ a, g (f' a) ∂μ := lintegral_congr_ae <| h.mono fun a h => by dsimp only; rw [h] #align measure_theory.lintegral_rw₁ MeasureTheory.lintegral_rw₁ -- TODO: Need a better way of rewriting inside of an integral theorem lintegral_rw₂ {f₁ f₁' : α → β} {f₂ f₂' : α → γ} (h₁ : f₁ =ᵐ[μ] f₁') (h₂ : f₂ =ᵐ[μ] f₂') (g : β → γ → ℝ≥0∞) : ∫⁻ a, g (f₁ a) (f₂ a) ∂μ = ∫⁻ a, g (f₁' a) (f₂' a) ∂μ := lintegral_congr_ae <| h₁.mp <| h₂.mono fun _ h₂ h₁ => by dsimp only; rw [h₁, h₂] #align measure_theory.lintegral_rw₂ MeasureTheory.lintegral_rw₂ theorem lintegral_indicator_le (f : α → ℝ≥0∞) (s : Set α) : ∫⁻ a, s.indicator f a ∂μ ≤ ∫⁻ a in s, f a ∂μ := by simp only [lintegral] apply iSup_le (fun g ↦ (iSup_le (fun hg ↦ ?_))) have : g ≤ f := hg.trans (indicator_le_self s f) refine le_iSup_of_le g (le_iSup_of_le this (le_of_eq ?_)) rw [lintegral_restrict, SimpleFunc.lintegral] congr with t by_cases H : t = 0 · simp [H] congr with x simp only [mem_preimage, mem_singleton_iff, mem_inter_iff, iff_self_and] rintro rfl contrapose! H simpa [H] using hg x @[simp] theorem lintegral_indicator (f : α → ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) : ∫⁻ a, s.indicator f a ∂μ = ∫⁻ a in s, f a ∂μ := by apply le_antisymm (lintegral_indicator_le f s) simp only [lintegral, ← restrict_lintegral_eq_lintegral_restrict _ hs, iSup_subtype'] refine iSup_mono' (Subtype.forall.2 fun φ hφ => ?_) refine ⟨⟨φ.restrict s, fun x => ?_⟩, le_rfl⟩ simp [hφ x, hs, indicator_le_indicator] #align measure_theory.lintegral_indicator MeasureTheory.lintegral_indicator theorem lintegral_indicator₀ (f : α → ℝ≥0∞) {s : Set α} (hs : NullMeasurableSet s μ) : ∫⁻ a, s.indicator f a ∂μ = ∫⁻ a in s, f a ∂μ := by rw [← lintegral_congr_ae (indicator_ae_eq_of_ae_eq_set hs.toMeasurable_ae_eq), lintegral_indicator _ (measurableSet_toMeasurable _ _), Measure.restrict_congr_set hs.toMeasurable_ae_eq] #align measure_theory.lintegral_indicator₀ MeasureTheory.lintegral_indicator₀ theorem lintegral_indicator_const_le (s : Set α) (c : ℝ≥0∞) : ∫⁻ a, s.indicator (fun _ => c) a ∂μ ≤ c * μ s := (lintegral_indicator_le _ _).trans (set_lintegral_const s c).le theorem lintegral_indicator_const₀ {s : Set α} (hs : NullMeasurableSet s μ) (c : ℝ≥0∞) : ∫⁻ a, s.indicator (fun _ => c) a ∂μ = c * μ s := by rw [lintegral_indicator₀ _ hs, set_lintegral_const] theorem lintegral_indicator_const {s : Set α} (hs : MeasurableSet s) (c : ℝ≥0∞) : ∫⁻ a, s.indicator (fun _ => c) a ∂μ = c * μ s := lintegral_indicator_const₀ hs.nullMeasurableSet c #align measure_theory.lintegral_indicator_const MeasureTheory.lintegral_indicator_const theorem set_lintegral_eq_const {f : α → ℝ≥0∞} (hf : Measurable f) (r : ℝ≥0∞) : ∫⁻ x in { x | f x = r }, f x ∂μ = r * μ { x | f x = r } := by have : ∀ᵐ x ∂μ, x ∈ { x | f x = r } → f x = r := ae_of_all μ fun _ hx => hx rw [set_lintegral_congr_fun _ this] · rw [lintegral_const, Measure.restrict_apply MeasurableSet.univ, Set.univ_inter] · exact hf (measurableSet_singleton r) #align measure_theory.set_lintegral_eq_const MeasureTheory.set_lintegral_eq_const theorem lintegral_indicator_one_le (s : Set α) : ∫⁻ a, s.indicator 1 a ∂μ ≤ μ s := (lintegral_indicator_const_le _ _).trans <| (one_mul _).le @[simp] theorem lintegral_indicator_one₀ (hs : NullMeasurableSet s μ) : ∫⁻ a, s.indicator 1 a ∂μ = μ s := (lintegral_indicator_const₀ hs _).trans <| one_mul _ @[simp] theorem lintegral_indicator_one (hs : MeasurableSet s) : ∫⁻ a, s.indicator 1 a ∂μ = μ s := (lintegral_indicator_const hs _).trans <| one_mul _ #align measure_theory.lintegral_indicator_one MeasureTheory.lintegral_indicator_one theorem lintegral_add_mul_meas_add_le_le_lintegral {f g : α → ℝ≥0∞} (hle : f ≤ᵐ[μ] g) (hg : AEMeasurable g μ) (ε : ℝ≥0∞) : ∫⁻ a, f a ∂μ + ε * μ { x | f x + ε ≤ g x } ≤ ∫⁻ a, g a ∂μ := by rcases exists_measurable_le_lintegral_eq μ f with ⟨φ, hφm, hφ_le, hφ_eq⟩ calc ∫⁻ x, f x ∂μ + ε * μ { x | f x + ε ≤ g x } = ∫⁻ x, φ x ∂μ + ε * μ { x | f x + ε ≤ g x } := by rw [hφ_eq] _ ≤ ∫⁻ x, φ x ∂μ + ε * μ { x | φ x + ε ≤ g x } := by gcongr exact fun x => (add_le_add_right (hφ_le _) _).trans _ = ∫⁻ x, φ x + indicator { x | φ x + ε ≤ g x } (fun _ => ε) x ∂μ := by rw [lintegral_add_left hφm, lintegral_indicator₀, set_lintegral_const] exact measurableSet_le (hφm.nullMeasurable.measurable'.add_const _) hg.nullMeasurable _ ≤ ∫⁻ x, g x ∂μ := lintegral_mono_ae (hle.mono fun x hx₁ => ?_) simp only [indicator_apply]; split_ifs with hx₂ exacts [hx₂, (add_zero _).trans_le <| (hφ_le x).trans hx₁] #align measure_theory.lintegral_add_mul_meas_add_le_le_lintegral MeasureTheory.lintegral_add_mul_meas_add_le_le_lintegral theorem mul_meas_ge_le_lintegral₀ {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (ε : ℝ≥0∞) : ε * μ { x | ε ≤ f x } ≤ ∫⁻ a, f a ∂μ := by simpa only [lintegral_zero, zero_add] using lintegral_add_mul_meas_add_le_le_lintegral (ae_of_all _ fun x => zero_le (f x)) hf ε #align measure_theory.mul_meas_ge_le_lintegral₀ MeasureTheory.mul_meas_ge_le_lintegral₀ theorem mul_meas_ge_le_lintegral {f : α → ℝ≥0∞} (hf : Measurable f) (ε : ℝ≥0∞) : ε * μ { x | ε ≤ f x } ≤ ∫⁻ a, f a ∂μ := mul_meas_ge_le_lintegral₀ hf.aemeasurable ε #align measure_theory.mul_meas_ge_le_lintegral MeasureTheory.mul_meas_ge_le_lintegral lemma meas_le_lintegral₀ {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) {s : Set α} (hs : ∀ x ∈ s, 1 ≤ f x) : μ s ≤ ∫⁻ a, f a ∂μ := by apply le_trans _ (mul_meas_ge_le_lintegral₀ hf 1) rw [one_mul] exact measure_mono hs lemma lintegral_le_meas {s : Set α} {f : α → ℝ≥0∞} (hf : ∀ a, f a ≤ 1) (h'f : ∀ a ∈ sᶜ, f a = 0) : ∫⁻ a, f a ∂μ ≤ μ s := by apply (lintegral_mono (fun x ↦ ?_)).trans (lintegral_indicator_one_le s) by_cases hx : x ∈ s · simpa [hx] using hf x · simpa [hx] using h'f x hx theorem lintegral_eq_top_of_measure_eq_top_ne_zero {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hμf : μ {x | f x = ∞} ≠ 0) : ∫⁻ x, f x ∂μ = ∞ := eq_top_iff.mpr <| calc ∞ = ∞ * μ { x | ∞ ≤ f x } := by simp [mul_eq_top, hμf] _ ≤ ∫⁻ x, f x ∂μ := mul_meas_ge_le_lintegral₀ hf ∞ #align measure_theory.lintegral_eq_top_of_measure_eq_top_ne_zero MeasureTheory.lintegral_eq_top_of_measure_eq_top_ne_zero theorem setLintegral_eq_top_of_measure_eq_top_ne_zero (hf : AEMeasurable f (μ.restrict s)) (hμf : μ ({x ∈ s | f x = ∞}) ≠ 0) : ∫⁻ x in s, f x ∂μ = ∞ := lintegral_eq_top_of_measure_eq_top_ne_zero hf <| mt (eq_bot_mono <| by rw [← setOf_inter_eq_sep]; exact Measure.le_restrict_apply _ _) hμf #align measure_theory.set_lintegral_eq_top_of_measure_eq_top_ne_zero MeasureTheory.setLintegral_eq_top_of_measure_eq_top_ne_zero theorem measure_eq_top_of_lintegral_ne_top (hf : AEMeasurable f μ) (hμf : ∫⁻ x, f x ∂μ ≠ ∞) : μ {x | f x = ∞} = 0 := of_not_not fun h => hμf <| lintegral_eq_top_of_measure_eq_top_ne_zero hf h #align measure_theory.measure_eq_top_of_lintegral_ne_top MeasureTheory.measure_eq_top_of_lintegral_ne_top theorem measure_eq_top_of_setLintegral_ne_top (hf : AEMeasurable f (μ.restrict s)) (hμf : ∫⁻ x in s, f x ∂μ ≠ ∞) : μ ({x ∈ s | f x = ∞}) = 0 := of_not_not fun h => hμf <| setLintegral_eq_top_of_measure_eq_top_ne_zero hf h #align measure_theory.measure_eq_top_of_set_lintegral_ne_top MeasureTheory.measure_eq_top_of_setLintegral_ne_top theorem meas_ge_le_lintegral_div {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) (hε' : ε ≠ ∞) : μ { x | ε ≤ f x } ≤ (∫⁻ a, f a ∂μ) / ε := (ENNReal.le_div_iff_mul_le (Or.inl hε) (Or.inl hε')).2 <| by rw [mul_comm] exact mul_meas_ge_le_lintegral₀ hf ε #align measure_theory.meas_ge_le_lintegral_div MeasureTheory.meas_ge_le_lintegral_div theorem ae_eq_of_ae_le_of_lintegral_le {f g : α → ℝ≥0∞} (hfg : f ≤ᵐ[μ] g) (hf : ∫⁻ x, f x ∂μ ≠ ∞) (hg : AEMeasurable g μ) (hgf : ∫⁻ x, g x ∂μ ≤ ∫⁻ x, f x ∂μ) : f =ᵐ[μ] g := by have : ∀ n : ℕ, ∀ᵐ x ∂μ, g x < f x + (n : ℝ≥0∞)⁻¹ := by intro n simp only [ae_iff, not_lt] have : ∫⁻ x, f x ∂μ + (↑n)⁻¹ * μ { x : α | f x + (n : ℝ≥0∞)⁻¹ ≤ g x } ≤ ∫⁻ x, f x ∂μ := (lintegral_add_mul_meas_add_le_le_lintegral hfg hg n⁻¹).trans hgf rw [(ENNReal.cancel_of_ne hf).add_le_iff_nonpos_right, nonpos_iff_eq_zero, mul_eq_zero] at this exact this.resolve_left (ENNReal.inv_ne_zero.2 (ENNReal.natCast_ne_top _)) refine hfg.mp ((ae_all_iff.2 this).mono fun x hlt hle => hle.antisymm ?_) suffices Tendsto (fun n : ℕ => f x + (n : ℝ≥0∞)⁻¹) atTop (𝓝 (f x)) from ge_of_tendsto' this fun i => (hlt i).le simpa only [inv_top, add_zero] using tendsto_const_nhds.add (ENNReal.tendsto_inv_iff.2 ENNReal.tendsto_nat_nhds_top) #align measure_theory.ae_eq_of_ae_le_of_lintegral_le MeasureTheory.ae_eq_of_ae_le_of_lintegral_le @[simp] theorem lintegral_eq_zero_iff' {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) : ∫⁻ a, f a ∂μ = 0 ↔ f =ᵐ[μ] 0 := have : ∫⁻ _ : α, 0 ∂μ ≠ ∞ := by simp [lintegral_zero, zero_ne_top] ⟨fun h => (ae_eq_of_ae_le_of_lintegral_le (ae_of_all _ <| zero_le f) this hf (h.trans lintegral_zero.symm).le).symm, fun h => (lintegral_congr_ae h).trans lintegral_zero⟩ #align measure_theory.lintegral_eq_zero_iff' MeasureTheory.lintegral_eq_zero_iff' @[simp] theorem lintegral_eq_zero_iff {f : α → ℝ≥0∞} (hf : Measurable f) : ∫⁻ a, f a ∂μ = 0 ↔ f =ᵐ[μ] 0 := lintegral_eq_zero_iff' hf.aemeasurable #align measure_theory.lintegral_eq_zero_iff MeasureTheory.lintegral_eq_zero_iff theorem lintegral_pos_iff_support {f : α → ℝ≥0∞} (hf : Measurable f) : (0 < ∫⁻ a, f a ∂μ) ↔ 0 < μ (Function.support f) := by simp [pos_iff_ne_zero, hf, Filter.EventuallyEq, ae_iff, Function.support] #align measure_theory.lintegral_pos_iff_support MeasureTheory.lintegral_pos_iff_support theorem setLintegral_pos_iff {f : α → ℝ≥0∞} (hf : Measurable f) {s : Set α} : 0 < ∫⁻ a in s, f a ∂μ ↔ 0 < μ (Function.support f ∩ s) := by rw [lintegral_pos_iff_support hf, Measure.restrict_apply (measurableSet_support hf)]
Mathlib/MeasureTheory/Integral/Lebesgue.lean
946
964
theorem lintegral_iSup_ae {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, Measurable (f n)) (h_mono : ∀ n, ∀ᵐ a ∂μ, f n a ≤ f n.succ a) : ∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by
let ⟨s, hs⟩ := exists_measurable_superset_of_null (ae_iff.1 (ae_all_iff.2 h_mono)) let g n a := if a ∈ s then 0 else f n a have g_eq_f : ∀ᵐ a ∂μ, ∀ n, g n a = f n a := (measure_zero_iff_ae_nmem.1 hs.2.2).mono fun a ha n => if_neg ha calc ∫⁻ a, ⨆ n, f n a ∂μ = ∫⁻ a, ⨆ n, g n a ∂μ := lintegral_congr_ae <| g_eq_f.mono fun a ha => by simp only [ha] _ = ⨆ n, ∫⁻ a, g n a ∂μ := (lintegral_iSup (fun n => measurable_const.piecewise hs.2.1 (hf n)) (monotone_nat_of_le_succ fun n a => ?_)) _ = ⨆ n, ∫⁻ a, f n a ∂μ := by simp only [lintegral_congr_ae (g_eq_f.mono fun _a ha => ha _)] simp only [g] split_ifs with h · rfl · have := Set.not_mem_subset hs.1 h simp only [not_forall, not_le, mem_setOf_eq, not_exists, not_lt] at this exact this n
import Mathlib.Data.Set.Lattice import Mathlib.Data.SetLike.Basic import Mathlib.Order.GaloisConnection import Mathlib.Order.Hom.Basic #align_import order.closure from "leanprover-community/mathlib"@"f252872231e87a5db80d9938fc05530e70f23a94" open Set variable (α : Type*) {ι : Sort*} {κ : ι → Sort*} structure ClosureOperator [Preorder α] extends α →o α where le_closure' : ∀ x, x ≤ toFun x idempotent' : ∀ x, toFun (toFun x) = toFun x IsClosed (x : α) : Prop := toFun x = x isClosed_iff {x : α} : IsClosed x ↔ toFun x = x := by aesop #align closure_operator ClosureOperator namespace ClosureOperator instance [Preorder α] : FunLike (ClosureOperator α) α α where coe c := c.1 coe_injective' := by rintro ⟨⟩ ⟨⟩ h; obtain rfl := DFunLike.ext' h; congr with x; simp_all instance [Preorder α] : OrderHomClass (ClosureOperator α) α α where map_rel f _ _ h := f.mono h initialize_simps_projections ClosureOperator (toFun → apply, IsClosed → isClosed) @[simps apply] def conjBy {α β} [Preorder α] [Preorder β] (c : ClosureOperator α) (e : α ≃o β) : ClosureOperator β where toFun := e.conj c IsClosed b := c.IsClosed (e.symm b) monotone' _ _ h := (map_le_map_iff e).mpr <| c.monotone <| (map_le_map_iff e.symm).mpr h le_closure' _ := e.symm_apply_le.mp (c.le_closure' _) idempotent' _ := congrArg e <| Eq.trans (congrArg c (e.symm_apply_apply _)) (c.idempotent' _) isClosed_iff := Iff.trans c.isClosed_iff e.eq_symm_apply lemma conjBy_refl {α} [Preorder α] (c : ClosureOperator α) : c.conjBy (OrderIso.refl α) = c := rfl lemma conjBy_trans {α β γ} [Preorder α] [Preorder β] [Preorder γ] (e₁ : α ≃o β) (e₂ : β ≃o γ) (c : ClosureOperator α) : c.conjBy (e₁.trans e₂) = (c.conjBy e₁).conjBy e₂ := rfl section PartialOrder variable [PartialOrder α] @[simps!] def id : ClosureOperator α where toOrderHom := OrderHom.id le_closure' _ := le_rfl idempotent' _ := rfl IsClosed _ := True #align closure_operator.id ClosureOperator.id #align closure_operator.id_apply ClosureOperator.id_apply #align closure_operator.closed ClosureOperator.IsClosed #align closure_operator.mem_closed_iff ClosureOperator.isClosed_iff instance : Inhabited (ClosureOperator α) := ⟨id α⟩ variable {α} [PartialOrder α] (c : ClosureOperator α) @[ext] theorem ext : ∀ c₁ c₂ : ClosureOperator α, (∀ x, c₁ x = c₂ x) → c₁ = c₂ := DFunLike.ext @[simps] def mk' (f : α → α) (hf₁ : Monotone f) (hf₂ : ∀ x, x ≤ f x) (hf₃ : ∀ x, f (f x) ≤ f x) : ClosureOperator α where toFun := f monotone' := hf₁ le_closure' := hf₂ idempotent' x := (hf₃ x).antisymm (hf₁ (hf₂ x)) #align closure_operator.mk' ClosureOperator.mk' #align closure_operator.mk'_apply ClosureOperator.mk'_apply @[simps] def mk₂ (f : α → α) (hf : ∀ x, x ≤ f x) (hmin : ∀ ⦃x y⦄, x ≤ f y → f x ≤ f y) : ClosureOperator α where toFun := f monotone' _ y hxy := hmin (hxy.trans (hf y)) le_closure' := hf idempotent' _ := (hmin le_rfl).antisymm (hf _) #align closure_operator.mk₂ ClosureOperator.mk₂ #align closure_operator.mk₂_apply ClosureOperator.mk₂_apply @[simps!] def ofPred (f : α → α) (p : α → Prop) (hf : ∀ x, x ≤ f x) (hfp : ∀ x, p (f x)) (hmin : ∀ ⦃x y⦄, x ≤ y → p y → f x ≤ y) : ClosureOperator α where __ := mk₂ f hf fun _ y hxy => hmin hxy (hfp y) IsClosed := p isClosed_iff := ⟨fun hx ↦ (hmin le_rfl hx).antisymm <| hf _, fun hx ↦ hx ▸ hfp _⟩ #align closure_operator.mk₃ ClosureOperator.ofPred #align closure_operator.mk₃_apply ClosureOperator.ofPred_apply #align closure_operator.mem_mk₃_closed ClosureOperator.ofPred_isClosed #noalign closure_operator.closure_mem_ofPred #noalign closure_operator.closure_le_ofPred_iff @[mono] theorem monotone : Monotone c := c.monotone' #align closure_operator.monotone ClosureOperator.monotone theorem le_closure (x : α) : x ≤ c x := c.le_closure' x #align closure_operator.le_closure ClosureOperator.le_closure @[simp] theorem idempotent (x : α) : c (c x) = c x := c.idempotent' x #align closure_operator.idempotent ClosureOperator.idempotent @[simp] lemma isClosed_closure (x : α) : c.IsClosed (c x) := c.isClosed_iff.2 <| c.idempotent x #align closure_operator.closure_is_closed ClosureOperator.isClosed_closure abbrev Closeds := {x // c.IsClosed x} def toCloseds (x : α) : c.Closeds := ⟨c x, c.isClosed_closure x⟩ #align closure_operator.to_closed ClosureOperator.toCloseds variable {c} {x y : α} theorem IsClosed.closure_eq : c.IsClosed x → c x = x := c.isClosed_iff.1 #align closure_operator.closure_eq_self_of_mem_closed ClosureOperator.IsClosed.closure_eq theorem isClosed_iff_closure_le : c.IsClosed x ↔ c x ≤ x := ⟨fun h ↦ h.closure_eq.le, fun h ↦ c.isClosed_iff.2 <| h.antisymm <| c.le_closure x⟩ #align closure_operator.mem_closed_iff_closure_le ClosureOperator.isClosed_iff_closure_le
Mathlib/Order/Closure.lean
204
205
theorem setOf_isClosed_eq_range_closure : {x | c.IsClosed x} = Set.range c := by
ext x; exact ⟨fun hx ↦ ⟨x, hx.closure_eq⟩, by rintro ⟨y, rfl⟩; exact c.isClosed_closure _⟩
import Mathlib.Order.Interval.Set.OrdConnected import Mathlib.Data.Set.Lattice #align_import data.set.intervals.ord_connected_component from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7" open Interval Function OrderDual namespace Set variable {α : Type*} [LinearOrder α] {s t : Set α} {x y z : α} def ordConnectedComponent (s : Set α) (x : α) : Set α := { y | [[x, y]] ⊆ s } #align set.ord_connected_component Set.ordConnectedComponent theorem mem_ordConnectedComponent : y ∈ ordConnectedComponent s x ↔ [[x, y]] ⊆ s := Iff.rfl #align set.mem_ord_connected_component Set.mem_ordConnectedComponent theorem dual_ordConnectedComponent : ordConnectedComponent (ofDual ⁻¹' s) (toDual x) = ofDual ⁻¹' ordConnectedComponent s x := ext <| (Surjective.forall toDual.surjective).2 fun x => by rw [mem_ordConnectedComponent, dual_uIcc] rfl #align set.dual_ord_connected_component Set.dual_ordConnectedComponent theorem ordConnectedComponent_subset : ordConnectedComponent s x ⊆ s := fun _ hy => hy right_mem_uIcc #align set.ord_connected_component_subset Set.ordConnectedComponent_subset theorem subset_ordConnectedComponent {t} [h : OrdConnected s] (hs : x ∈ s) (ht : s ⊆ t) : s ⊆ ordConnectedComponent t x := fun _ hy => (h.uIcc_subset hs hy).trans ht #align set.subset_ord_connected_component Set.subset_ordConnectedComponent @[simp] theorem self_mem_ordConnectedComponent : x ∈ ordConnectedComponent s x ↔ x ∈ s := by rw [mem_ordConnectedComponent, uIcc_self, singleton_subset_iff] #align set.self_mem_ord_connected_component Set.self_mem_ordConnectedComponent @[simp] theorem nonempty_ordConnectedComponent : (ordConnectedComponent s x).Nonempty ↔ x ∈ s := ⟨fun ⟨_, hy⟩ => hy <| left_mem_uIcc, fun h => ⟨x, self_mem_ordConnectedComponent.2 h⟩⟩ #align set.nonempty_ord_connected_component Set.nonempty_ordConnectedComponent @[simp] theorem ordConnectedComponent_eq_empty : ordConnectedComponent s x = ∅ ↔ x ∉ s := by rw [← not_nonempty_iff_eq_empty, nonempty_ordConnectedComponent] #align set.ord_connected_component_eq_empty Set.ordConnectedComponent_eq_empty @[simp] theorem ordConnectedComponent_empty : ordConnectedComponent ∅ x = ∅ := ordConnectedComponent_eq_empty.2 (not_mem_empty x) #align set.ord_connected_component_empty Set.ordConnectedComponent_empty @[simp] theorem ordConnectedComponent_univ : ordConnectedComponent univ x = univ := by simp [ordConnectedComponent] #align set.ord_connected_component_univ Set.ordConnectedComponent_univ theorem ordConnectedComponent_inter (s t : Set α) (x : α) : ordConnectedComponent (s ∩ t) x = ordConnectedComponent s x ∩ ordConnectedComponent t x := by simp [ordConnectedComponent, setOf_and] #align set.ord_connected_component_inter Set.ordConnectedComponent_inter theorem mem_ordConnectedComponent_comm : y ∈ ordConnectedComponent s x ↔ x ∈ ordConnectedComponent s y := by rw [mem_ordConnectedComponent, mem_ordConnectedComponent, uIcc_comm] #align set.mem_ord_connected_component_comm Set.mem_ordConnectedComponent_comm theorem mem_ordConnectedComponent_trans (hxy : y ∈ ordConnectedComponent s x) (hyz : z ∈ ordConnectedComponent s y) : z ∈ ordConnectedComponent s x := calc [[x, z]] ⊆ [[x, y]] ∪ [[y, z]] := uIcc_subset_uIcc_union_uIcc _ ⊆ s := union_subset hxy hyz #align set.mem_ord_connected_component_trans Set.mem_ordConnectedComponent_trans theorem ordConnectedComponent_eq (h : [[x, y]] ⊆ s) : ordConnectedComponent s x = ordConnectedComponent s y := ext fun _ => ⟨mem_ordConnectedComponent_trans (mem_ordConnectedComponent_comm.2 h), mem_ordConnectedComponent_trans h⟩ #align set.ord_connected_component_eq Set.ordConnectedComponent_eq instance : OrdConnected (ordConnectedComponent s x) := ordConnected_of_uIcc_subset_left fun _ hy _ hz => (uIcc_subset_uIcc_left hz).trans hy noncomputable def ordConnectedProj (s : Set α) : s → α := fun x : s => (nonempty_ordConnectedComponent.2 x.2).some #align set.ord_connected_proj Set.ordConnectedProj theorem ordConnectedProj_mem_ordConnectedComponent (s : Set α) (x : s) : ordConnectedProj s x ∈ ordConnectedComponent s x := Nonempty.some_mem _ #align set.ord_connected_proj_mem_ord_connected_component Set.ordConnectedProj_mem_ordConnectedComponent theorem mem_ordConnectedComponent_ordConnectedProj (s : Set α) (x : s) : ↑x ∈ ordConnectedComponent s (ordConnectedProj s x) := mem_ordConnectedComponent_comm.2 <| ordConnectedProj_mem_ordConnectedComponent s x #align set.mem_ord_connected_component_ord_connected_proj Set.mem_ordConnectedComponent_ordConnectedProj @[simp] theorem ordConnectedComponent_ordConnectedProj (s : Set α) (x : s) : ordConnectedComponent s (ordConnectedProj s x) = ordConnectedComponent s x := ordConnectedComponent_eq <| mem_ordConnectedComponent_ordConnectedProj _ _ #align set.ord_connected_component_ord_connected_proj Set.ordConnectedComponent_ordConnectedProj @[simp] theorem ordConnectedProj_eq {x y : s} : ordConnectedProj s x = ordConnectedProj s y ↔ [[(x : α), y]] ⊆ s := by constructor <;> intro h · rw [← mem_ordConnectedComponent, ← ordConnectedComponent_ordConnectedProj, h, ordConnectedComponent_ordConnectedProj, self_mem_ordConnectedComponent] exact y.2 · simp only [ordConnectedProj, ordConnectedComponent_eq h] #align set.ord_connected_proj_eq Set.ordConnectedProj_eq def ordConnectedSection (s : Set α) : Set α := range <| ordConnectedProj s #align set.ord_connected_section Set.ordConnectedSection theorem dual_ordConnectedSection (s : Set α) : ordConnectedSection (ofDual ⁻¹' s) = ofDual ⁻¹' ordConnectedSection s := by simp only [ordConnectedSection] simp (config := { unfoldPartialApp := true }) only [ordConnectedProj] ext x simp only [mem_range, Subtype.exists, mem_preimage, OrderDual.exists, dual_ordConnectedComponent, ofDual_toDual] tauto #align set.dual_ord_connected_section Set.dual_ordConnectedSection theorem ordConnectedSection_subset : ordConnectedSection s ⊆ s := range_subset_iff.2 fun _ => ordConnectedComponent_subset <| Nonempty.some_mem _ #align set.ord_connected_section_subset Set.ordConnectedSection_subset theorem eq_of_mem_ordConnectedSection_of_uIcc_subset (hx : x ∈ ordConnectedSection s) (hy : y ∈ ordConnectedSection s) (h : [[x, y]] ⊆ s) : x = y := by rcases hx with ⟨x, rfl⟩; rcases hy with ⟨y, rfl⟩ exact ordConnectedProj_eq.2 (mem_ordConnectedComponent_trans (mem_ordConnectedComponent_trans (ordConnectedProj_mem_ordConnectedComponent _ _) h) (mem_ordConnectedComponent_ordConnectedProj _ _)) #align set.eq_of_mem_ord_connected_section_of_uIcc_subset Set.eq_of_mem_ordConnectedSection_of_uIcc_subset def ordSeparatingSet (s t : Set α) : Set α := (⋃ x ∈ s, ordConnectedComponent tᶜ x) ∩ ⋃ x ∈ t, ordConnectedComponent sᶜ x #align set.ord_separating_set Set.ordSeparatingSet theorem ordSeparatingSet_comm (s t : Set α) : ordSeparatingSet s t = ordSeparatingSet t s := inter_comm _ _ #align set.ord_separating_set_comm Set.ordSeparatingSet_comm theorem disjoint_left_ordSeparatingSet : Disjoint s (ordSeparatingSet s t) := Disjoint.inter_right' _ <| disjoint_iUnion₂_right.2 fun _ _ => disjoint_compl_right.mono_right <| ordConnectedComponent_subset #align set.disjoint_left_ord_separating_set Set.disjoint_left_ordSeparatingSet theorem disjoint_right_ordSeparatingSet : Disjoint t (ordSeparatingSet s t) := ordSeparatingSet_comm t s ▸ disjoint_left_ordSeparatingSet #align set.disjoint_right_ord_separating_set Set.disjoint_right_ordSeparatingSet theorem dual_ordSeparatingSet : ordSeparatingSet (ofDual ⁻¹' s) (ofDual ⁻¹' t) = ofDual ⁻¹' ordSeparatingSet s t := by simp only [ordSeparatingSet, mem_preimage, ← toDual.surjective.iUnion_comp, ofDual_toDual, dual_ordConnectedComponent, ← preimage_compl, preimage_inter, preimage_iUnion] #align set.dual_ord_separating_set Set.dual_ordSeparatingSet def ordT5Nhd (s t : Set α) : Set α := ⋃ x ∈ s, ordConnectedComponent (tᶜ ∩ (ordConnectedSection <| ordSeparatingSet s t)ᶜ) x #align set.ord_t5_nhd Set.ordT5Nhd
Mathlib/Order/Interval/Set/OrdConnectedComponent.lean
200
234
theorem disjoint_ordT5Nhd : Disjoint (ordT5Nhd s t) (ordT5Nhd t s) := by
rw [disjoint_iff_inf_le] rintro x ⟨hx₁, hx₂⟩ rcases mem_iUnion₂.1 hx₁ with ⟨a, has, ha⟩ clear hx₁ rcases mem_iUnion₂.1 hx₂ with ⟨b, hbt, hb⟩ clear hx₂ rw [mem_ordConnectedComponent, subset_inter_iff] at ha hb wlog hab : a ≤ b with H · exact H (x := x) (y := y) (z := z) b hbt hb a has ha (le_of_not_le hab) cases' ha with ha ha' cases' hb with hb hb' have hsub : [[a, b]] ⊆ (ordSeparatingSet s t).ordConnectedSectionᶜ := by rw [ordSeparatingSet_comm, uIcc_comm] at hb' calc [[a, b]] ⊆ [[a, x]] ∪ [[x, b]] := uIcc_subset_uIcc_union_uIcc _ ⊆ (ordSeparatingSet s t).ordConnectedSectionᶜ := union_subset ha' hb' clear ha' hb' rcases le_total x a with hxa | hax · exact hb (Icc_subset_uIcc' ⟨hxa, hab⟩) has rcases le_total b x with hbx | hxb · exact ha (Icc_subset_uIcc ⟨hab, hbx⟩) hbt have h' : x ∈ ordSeparatingSet s t := ⟨mem_iUnion₂.2 ⟨a, has, ha⟩, mem_iUnion₂.2 ⟨b, hbt, hb⟩⟩ lift x to ordSeparatingSet s t using h' suffices ordConnectedComponent (ordSeparatingSet s t) x ⊆ [[a, b]] from hsub (this <| ordConnectedProj_mem_ordConnectedComponent _ x) (mem_range_self _) rintro y hy rw [uIcc_of_le hab, mem_Icc, ← not_lt, ← not_lt] have sol1 := fun (hya : y < a) => (disjoint_left (t := ordSeparatingSet s t)).1 disjoint_left_ordSeparatingSet has (hy <| Icc_subset_uIcc' ⟨hya.le, hax⟩) have sol2 := fun (hby : b < y) => (disjoint_left (t := ordSeparatingSet s t)).1 disjoint_right_ordSeparatingSet hbt (hy <| Icc_subset_uIcc ⟨hxb, hby.le⟩) exact ⟨sol1, sol2⟩
import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.List.Perm import Mathlib.Data.List.Range #align_import data.list.sublists from "leanprover-community/mathlib"@"ccad6d5093bd2f5c6ca621fc74674cce51355af6" universe u v w variable {α : Type u} {β : Type v} {γ : Type w} open Nat namespace List @[simp] theorem sublists'_nil : sublists' (@nil α) = [[]] := rfl #align list.sublists'_nil List.sublists'_nil @[simp] theorem sublists'_singleton (a : α) : sublists' [a] = [[], [a]] := rfl #align list.sublists'_singleton List.sublists'_singleton #noalign list.map_sublists'_aux #noalign list.sublists'_aux_append #noalign list.sublists'_aux_eq_sublists' -- Porting note: Not the same as `sublists'_aux` from Lean3 def sublists'Aux (a : α) (r₁ r₂ : List (List α)) : List (List α) := r₁.foldl (init := r₂) fun r l => r ++ [a :: l] #align list.sublists'_aux List.sublists'Aux theorem sublists'Aux_eq_array_foldl (a : α) : ∀ (r₁ r₂ : List (List α)), sublists'Aux a r₁ r₂ = ((r₁.toArray).foldl (init := r₂.toArray) (fun r l => r.push (a :: l))).toList := by intro r₁ r₂ rw [sublists'Aux, Array.foldl_eq_foldl_data] have := List.foldl_hom Array.toList (fun r l => r.push (a :: l)) (fun r l => r ++ [a :: l]) r₁ r₂.toArray (by simp) simpa using this theorem sublists'_eq_sublists'Aux (l : List α) : sublists' l = l.foldr (fun a r => sublists'Aux a r r) [[]] := by simp only [sublists', sublists'Aux_eq_array_foldl] rw [← List.foldr_hom Array.toList] · rfl · intros _ _; congr <;> simp theorem sublists'Aux_eq_map (a : α) (r₁ : List (List α)) : ∀ (r₂ : List (List α)), sublists'Aux a r₁ r₂ = r₂ ++ map (cons a) r₁ := List.reverseRecOn r₁ (fun _ => by simp [sublists'Aux]) fun r₁ l ih r₂ => by rw [map_append, map_singleton, ← append_assoc, ← ih, sublists'Aux, foldl_append, foldl] simp [sublists'Aux] -- Porting note: simp can prove `sublists'_singleton` @[simp 900] theorem sublists'_cons (a : α) (l : List α) : sublists' (a :: l) = sublists' l ++ map (cons a) (sublists' l) := by simp [sublists'_eq_sublists'Aux, foldr_cons, sublists'Aux_eq_map] #align list.sublists'_cons List.sublists'_cons @[simp] theorem mem_sublists' {s t : List α} : s ∈ sublists' t ↔ s <+ t := by induction' t with a t IH generalizing s · simp only [sublists'_nil, mem_singleton] exact ⟨fun h => by rw [h], eq_nil_of_sublist_nil⟩ simp only [sublists'_cons, mem_append, IH, mem_map] constructor <;> intro h · rcases h with (h | ⟨s, h, rfl⟩) · exact sublist_cons_of_sublist _ h · exact h.cons_cons _ · cases' h with _ _ _ h s _ _ h · exact Or.inl h · exact Or.inr ⟨s, h, rfl⟩ #align list.mem_sublists' List.mem_sublists' @[simp] theorem length_sublists' : ∀ l : List α, length (sublists' l) = 2 ^ length l | [] => rfl | a :: l => by simp_arith only [sublists'_cons, length_append, length_sublists' l, length_map, length, Nat.pow_succ'] #align list.length_sublists' List.length_sublists' @[simp] theorem sublists_nil : sublists (@nil α) = [[]] := rfl #align list.sublists_nil List.sublists_nil @[simp] theorem sublists_singleton (a : α) : sublists [a] = [[], [a]] := rfl #align list.sublists_singleton List.sublists_singleton -- Porting note: Not the same as `sublists_aux` from Lean3 def sublistsAux (a : α) (r : List (List α)) : List (List α) := r.foldl (init := []) fun r l => r ++ [l, a :: l] #align list.sublists_aux List.sublistsAux theorem sublistsAux_eq_array_foldl : sublistsAux = fun (a : α) (r : List (List α)) => (r.toArray.foldl (init := #[]) fun r l => (r.push l).push (a :: l)).toList := by funext a r simp only [sublistsAux, Array.foldl_eq_foldl_data, Array.mkEmpty] have := foldl_hom Array.toList (fun r l => (r.push l).push (a :: l)) (fun (r : List (List α)) l => r ++ [l, a :: l]) r #[] (by simp) simpa using this theorem sublistsAux_eq_bind : sublistsAux = fun (a : α) (r : List (List α)) => r.bind fun l => [l, a :: l] := funext fun a => funext fun r => List.reverseRecOn r (by simp [sublistsAux]) (fun r l ih => by rw [append_bind, ← ih, bind_singleton, sublistsAux, foldl_append] simp [sublistsAux]) @[csimp] theorem sublists_eq_sublistsFast : @sublists = @sublistsFast := by ext α l : 2 trans l.foldr sublistsAux [[]] · rw [sublistsAux_eq_bind, sublists] · simp only [sublistsFast, sublistsAux_eq_array_foldl, Array.foldr_eq_foldr_data] rw [← foldr_hom Array.toList] · rfl · intros _ _; congr <;> simp #noalign list.sublists_aux₁_eq_sublists_aux #noalign list.sublists_aux_cons_eq_sublists_aux₁ #noalign list.sublists_aux_eq_foldr.aux #noalign list.sublists_aux_eq_foldr #noalign list.sublists_aux_cons_cons #noalign list.sublists_aux₁_append #noalign list.sublists_aux₁_concat #noalign list.sublists_aux₁_bind #noalign list.sublists_aux_cons_append theorem sublists_append (l₁ l₂ : List α) : sublists (l₁ ++ l₂) = (sublists l₂) >>= (fun x => (sublists l₁).map (· ++ x)) := by simp only [sublists, foldr_append] induction l₁ with | nil => simp | cons a l₁ ih => rw [foldr_cons, ih] simp [List.bind, join_join, Function.comp] #align list.sublists_append List.sublists_append -- Porting note (#10756): new theorem theorem sublists_cons (a : α) (l : List α) : sublists (a :: l) = sublists l >>= (fun x => [x, a :: x]) := show sublists ([a] ++ l) = _ by rw [sublists_append] simp only [sublists_singleton, map_cons, bind_eq_bind, nil_append, cons_append, map_nil] @[simp] theorem sublists_concat (l : List α) (a : α) : sublists (l ++ [a]) = sublists l ++ map (fun x => x ++ [a]) (sublists l) := by rw [sublists_append, sublists_singleton, bind_eq_bind, cons_bind, cons_bind, nil_bind, map_id'' append_nil, append_nil] #align list.sublists_concat List.sublists_concat theorem sublists_reverse (l : List α) : sublists (reverse l) = map reverse (sublists' l) := by induction' l with hd tl ih <;> [rfl; simp only [reverse_cons, sublists_append, sublists'_cons, map_append, ih, sublists_singleton, map_eq_map, bind_eq_bind, map_map, cons_bind, append_nil, nil_bind, (· ∘ ·)]] #align list.sublists_reverse List.sublists_reverse theorem sublists_eq_sublists' (l : List α) : sublists l = map reverse (sublists' (reverse l)) := by rw [← sublists_reverse, reverse_reverse] #align list.sublists_eq_sublists' List.sublists_eq_sublists' theorem sublists'_reverse (l : List α) : sublists' (reverse l) = map reverse (sublists l) := by simp only [sublists_eq_sublists', map_map, map_id'' reverse_reverse, Function.comp] #align list.sublists'_reverse List.sublists'_reverse theorem sublists'_eq_sublists (l : List α) : sublists' l = map reverse (sublists (reverse l)) := by rw [← sublists'_reverse, reverse_reverse] #align list.sublists'_eq_sublists List.sublists'_eq_sublists #noalign list.sublists_aux_ne_nil @[simp] theorem mem_sublists {s t : List α} : s ∈ sublists t ↔ s <+ t := by rw [← reverse_sublist, ← mem_sublists', sublists'_reverse, mem_map_of_injective reverse_injective] #align list.mem_sublists List.mem_sublists @[simp] theorem length_sublists (l : List α) : length (sublists l) = 2 ^ length l := by simp only [sublists_eq_sublists', length_map, length_sublists', length_reverse] #align list.length_sublists List.length_sublists theorem map_pure_sublist_sublists (l : List α) : map pure l <+ sublists l := by induction' l using reverseRecOn with l a ih <;> simp only [map, map_append, sublists_concat] · simp only [sublists_nil, sublist_cons] exact ((append_sublist_append_left _).2 <| singleton_sublist.2 <| mem_map.2 ⟨[], mem_sublists.2 (nil_sublist _), by rfl⟩).trans ((append_sublist_append_right _).2 ih) #align list.map_ret_sublist_sublists List.map_pure_sublist_sublists set_option linter.deprecated false in @[deprecated map_pure_sublist_sublists (since := "2024-03-24")] theorem map_ret_sublist_sublists (l : List α) : map List.ret l <+ sublists l := map_pure_sublist_sublists l def sublistsLenAux : ℕ → List α → (List α → β) → List β → List β | 0, _, f, r => f [] :: r | _ + 1, [], _, r => r | n + 1, a :: l, f, r => sublistsLenAux (n + 1) l f (sublistsLenAux n l (f ∘ List.cons a) r) #align list.sublists_len_aux List.sublistsLenAux def sublistsLen (n : ℕ) (l : List α) : List (List α) := sublistsLenAux n l id [] #align list.sublists_len List.sublistsLen theorem sublistsLenAux_append : ∀ (n : ℕ) (l : List α) (f : List α → β) (g : β → γ) (r : List β) (s : List γ), sublistsLenAux n l (g ∘ f) (r.map g ++ s) = (sublistsLenAux n l f r).map g ++ s | 0, l, f, g, r, s => by unfold sublistsLenAux; simp | n + 1, [], f, g, r, s => rfl | n + 1, a :: l, f, g, r, s => by unfold sublistsLenAux simp only [show (g ∘ f) ∘ List.cons a = g ∘ f ∘ List.cons a by rfl, sublistsLenAux_append, sublistsLenAux_append] #align list.sublists_len_aux_append List.sublistsLenAux_append theorem sublistsLenAux_eq (l : List α) (n) (f : List α → β) (r) : sublistsLenAux n l f r = (sublistsLen n l).map f ++ r := by rw [sublistsLen, ← sublistsLenAux_append]; rfl #align list.sublists_len_aux_eq List.sublistsLenAux_eq
Mathlib/Data/List/Sublists.lean
261
262
theorem sublistsLenAux_zero (l : List α) (f : List α → β) (r) : sublistsLenAux 0 l f r = f [] :: r := by
cases l <;> rfl
import Mathlib.Data.FunLike.Equiv import Mathlib.Data.Quot import Mathlib.Init.Data.Bool.Lemmas import Mathlib.Logic.Unique import Mathlib.Tactic.Substs import Mathlib.Tactic.Conv #align_import logic.equiv.defs from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" open Function universe u v w z variable {α : Sort u} {β : Sort v} {γ : Sort w} structure Equiv (α : Sort*) (β : Sort _) where protected toFun : α → β protected invFun : β → α protected left_inv : LeftInverse invFun toFun protected right_inv : RightInverse invFun toFun #align equiv Equiv @[inherit_doc] infixl:25 " ≃ " => Equiv @[coe] def EquivLike.toEquiv {F} [EquivLike F α β] (f : F) : α ≃ β where toFun := f invFun := EquivLike.inv f left_inv := EquivLike.left_inv f right_inv := EquivLike.right_inv f instance {F} [EquivLike F α β] : CoeTC F (α ≃ β) := ⟨EquivLike.toEquiv⟩ abbrev Equiv.Perm (α : Sort*) := Equiv α α #align equiv.perm Equiv.Perm namespace Equiv instance : EquivLike (α ≃ β) α β where coe := Equiv.toFun inv := Equiv.invFun left_inv := Equiv.left_inv right_inv := Equiv.right_inv coe_injective' e₁ e₂ h₁ h₂ := by cases e₁; cases e₂; congr instance : FunLike (α ≃ β) α β where coe := Equiv.toFun coe_injective' := DFunLike.coe_injective @[simp, norm_cast] lemma _root_.EquivLike.coe_coe {F} [EquivLike F α β] (e : F) : ((e : α ≃ β) : α → β) = e := rfl @[simp] theorem coe_fn_mk (f : α → β) (g l r) : (Equiv.mk f g l r : α → β) = f := rfl #align equiv.coe_fn_mk Equiv.coe_fn_mk theorem coe_fn_injective : @Function.Injective (α ≃ β) (α → β) (fun e => e) := DFunLike.coe_injective' #align equiv.coe_fn_injective Equiv.coe_fn_injective protected theorem coe_inj {e₁ e₂ : α ≃ β} : (e₁ : α → β) = e₂ ↔ e₁ = e₂ := @DFunLike.coe_fn_eq _ _ _ _ e₁ e₂ #align equiv.coe_inj Equiv.coe_inj @[ext] theorem ext {f g : Equiv α β} (H : ∀ x, f x = g x) : f = g := DFunLike.ext f g H #align equiv.ext Equiv.ext protected theorem congr_arg {f : Equiv α β} {x x' : α} : x = x' → f x = f x' := DFunLike.congr_arg f #align equiv.congr_arg Equiv.congr_arg protected theorem congr_fun {f g : Equiv α β} (h : f = g) (x : α) : f x = g x := DFunLike.congr_fun h x #align equiv.congr_fun Equiv.congr_fun theorem ext_iff {f g : Equiv α β} : f = g ↔ ∀ x, f x = g x := DFunLike.ext_iff #align equiv.ext_iff Equiv.ext_iff @[ext] theorem Perm.ext {σ τ : Equiv.Perm α} (H : ∀ x, σ x = τ x) : σ = τ := Equiv.ext H #align equiv.perm.ext Equiv.Perm.ext protected theorem Perm.congr_arg {f : Equiv.Perm α} {x x' : α} : x = x' → f x = f x' := Equiv.congr_arg #align equiv.perm.congr_arg Equiv.Perm.congr_arg protected theorem Perm.congr_fun {f g : Equiv.Perm α} (h : f = g) (x : α) : f x = g x := Equiv.congr_fun h x #align equiv.perm.congr_fun Equiv.Perm.congr_fun theorem Perm.ext_iff {σ τ : Equiv.Perm α} : σ = τ ↔ ∀ x, σ x = τ x := Equiv.ext_iff #align equiv.perm.ext_iff Equiv.Perm.ext_iff @[refl] protected def refl (α : Sort*) : α ≃ α := ⟨id, id, fun _ => rfl, fun _ => rfl⟩ #align equiv.refl Equiv.refl instance inhabited' : Inhabited (α ≃ α) := ⟨Equiv.refl α⟩ @[symm] protected def symm (e : α ≃ β) : β ≃ α := ⟨e.invFun, e.toFun, e.right_inv, e.left_inv⟩ #align equiv.symm Equiv.symm def Simps.symm_apply (e : α ≃ β) : β → α := e.symm #align equiv.simps.symm_apply Equiv.Simps.symm_apply initialize_simps_projections Equiv (toFun → apply, invFun → symm_apply) -- Porting note: -- Added these lemmas as restatements of `left_inv` and `right_inv`, -- which use the coercions. -- We might even consider switching the names, and having these as a public API. theorem left_inv' (e : α ≃ β) : Function.LeftInverse e.symm e := e.left_inv theorem right_inv' (e : α ≃ β) : Function.RightInverse e.symm e := e.right_inv @[trans] protected def trans (e₁ : α ≃ β) (e₂ : β ≃ γ) : α ≃ γ := ⟨e₂ ∘ e₁, e₁.symm ∘ e₂.symm, e₂.left_inv.comp e₁.left_inv, e₂.right_inv.comp e₁.right_inv⟩ #align equiv.trans Equiv.trans @[simps] instance : Trans Equiv Equiv Equiv where trans := Equiv.trans -- Porting note: this is not a syntactic tautology any more because -- the coercion from `e` to a function is now `DFunLike.coe` not `e.toFun` @[simp, mfld_simps] theorem toFun_as_coe (e : α ≃ β) : e.toFun = e := rfl #align equiv.to_fun_as_coe Equiv.toFun_as_coe @[simp, mfld_simps] theorem invFun_as_coe (e : α ≃ β) : e.invFun = e.symm := rfl #align equiv.inv_fun_as_coe Equiv.invFun_as_coe protected theorem injective (e : α ≃ β) : Injective e := EquivLike.injective e #align equiv.injective Equiv.injective protected theorem surjective (e : α ≃ β) : Surjective e := EquivLike.surjective e #align equiv.surjective Equiv.surjective protected theorem bijective (e : α ≃ β) : Bijective e := EquivLike.bijective e #align equiv.bijective Equiv.bijective protected theorem subsingleton (e : α ≃ β) [Subsingleton β] : Subsingleton α := e.injective.subsingleton #align equiv.subsingleton Equiv.subsingleton protected theorem subsingleton.symm (e : α ≃ β) [Subsingleton α] : Subsingleton β := e.symm.injective.subsingleton #align equiv.subsingleton.symm Equiv.subsingleton.symm theorem subsingleton_congr (e : α ≃ β) : Subsingleton α ↔ Subsingleton β := ⟨fun _ => e.symm.subsingleton, fun _ => e.subsingleton⟩ #align equiv.subsingleton_congr Equiv.subsingleton_congr instance equiv_subsingleton_cod [Subsingleton β] : Subsingleton (α ≃ β) := ⟨fun _ _ => Equiv.ext fun _ => Subsingleton.elim _ _⟩ instance equiv_subsingleton_dom [Subsingleton α] : Subsingleton (α ≃ β) := ⟨fun f _ => Equiv.ext fun _ => @Subsingleton.elim _ (Equiv.subsingleton.symm f) _ _⟩ instance permUnique [Subsingleton α] : Unique (Perm α) := uniqueOfSubsingleton (Equiv.refl α) theorem Perm.subsingleton_eq_refl [Subsingleton α] (e : Perm α) : e = Equiv.refl α := Subsingleton.elim _ _ #align equiv.perm.subsingleton_eq_refl Equiv.Perm.subsingleton_eq_refl protected def decidableEq (e : α ≃ β) [DecidableEq β] : DecidableEq α := e.injective.decidableEq #align equiv.decidable_eq Equiv.decidableEq theorem nonempty_congr (e : α ≃ β) : Nonempty α ↔ Nonempty β := Nonempty.congr e e.symm #align equiv.nonempty_congr Equiv.nonempty_congr protected theorem nonempty (e : α ≃ β) [Nonempty β] : Nonempty α := e.nonempty_congr.mpr ‹_› #align equiv.nonempty Equiv.nonempty protected def inhabited [Inhabited β] (e : α ≃ β) : Inhabited α := ⟨e.symm default⟩ #align equiv.inhabited Equiv.inhabited protected def unique [Unique β] (e : α ≃ β) : Unique α := e.symm.surjective.unique #align equiv.unique Equiv.unique protected def cast {α β : Sort _} (h : α = β) : α ≃ β := ⟨cast h, cast h.symm, fun _ => by cases h; rfl, fun _ => by cases h; rfl⟩ #align equiv.cast Equiv.cast @[simp] theorem coe_fn_symm_mk (f : α → β) (g l r) : ((Equiv.mk f g l r).symm : β → α) = g := rfl #align equiv.coe_fn_symm_mk Equiv.coe_fn_symm_mk @[simp] theorem coe_refl : (Equiv.refl α : α → α) = id := rfl #align equiv.coe_refl Equiv.coe_refl
Mathlib/Logic/Equiv/Defs.lean
262
263
theorem Perm.coe_subsingleton {α : Type*} [Subsingleton α] (e : Perm α) : (e : α → α) = id := by
rw [Perm.subsingleton_eq_refl e, coe_refl]
import Mathlib.Topology.Order import Mathlib.Topology.Sets.Opens import Mathlib.Topology.ContinuousFunction.Basic #align_import topology.continuous_function.t0_sierpinski from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" noncomputable section namespace TopologicalSpace theorem eq_induced_by_maps_to_sierpinski (X : Type*) [t : TopologicalSpace X] : t = ⨅ u : Opens X, sierpinskiSpace.induced (· ∈ u) := by apply le_antisymm · rw [le_iInf_iff] exact fun u => Continuous.le_induced (isOpen_iff_continuous_mem.mp u.2) · intro u h rw [← generateFrom_iUnion_isOpen] apply isOpen_generateFrom_of_mem simp only [Set.mem_iUnion, Set.mem_setOf_eq, isOpen_induced_iff] exact ⟨⟨u, h⟩, {True}, isOpen_singleton_true, by simp [Set.preimage]⟩ #align topological_space.eq_induced_by_maps_to_sierpinski TopologicalSpace.eq_induced_by_maps_to_sierpinski variable (X : Type*) [TopologicalSpace X] def productOfMemOpens : C(X, Opens X → Prop) where toFun x u := x ∈ u continuous_toFun := continuous_pi_iff.2 fun u => continuous_Prop.2 u.isOpen #align topological_space.product_of_mem_opens TopologicalSpace.productOfMemOpens theorem productOfMemOpens_inducing : Inducing (productOfMemOpens X) := by convert inducing_iInf_to_pi fun (u : Opens X) (x : X) => x ∈ u apply eq_induced_by_maps_to_sierpinski #align topological_space.product_of_mem_opens_inducing TopologicalSpace.productOfMemOpens_inducing
Mathlib/Topology/ContinuousFunction/T0Sierpinski.lean
55
58
theorem productOfMemOpens_injective [T0Space X] : Function.Injective (productOfMemOpens X) := by
intro x1 x2 h apply Inseparable.eq rw [← Inducing.inseparable_iff (productOfMemOpens_inducing X), h]
import Mathlib.Algebra.Ring.InjSurj import Mathlib.Algebra.Group.Units.Hom import Mathlib.Algebra.Ring.Hom.Defs #align_import algebra.ring.units from "leanprover-community/mathlib"@"2ed7e4aec72395b6a7c3ac4ac7873a7a43ead17c" universe u v w x variable {α : Type u} {β : Type v} {γ : Type w} {R : Type x} open Function namespace Units section HasDistribNeg variable [Monoid α] [HasDistribNeg α] {a b : α} instance : Neg αˣ := ⟨fun u => ⟨-↑u, -↑u⁻¹, by simp, by simp⟩⟩ @[simp, norm_cast] protected theorem val_neg (u : αˣ) : (↑(-u) : α) = -u := rfl #align units.coe_neg Units.val_neg @[simp, norm_cast] protected theorem coe_neg_one : ((-1 : αˣ) : α) = -1 := rfl #align units.coe_neg_one Units.coe_neg_one instance : HasDistribNeg αˣ := Units.ext.hasDistribNeg _ Units.val_neg Units.val_mul @[field_simps]
Mathlib/Algebra/Ring/Units.lean
50
50
theorem neg_divp (a : α) (u : αˣ) : -(a /ₚ u) = -a /ₚ u := by
simp only [divp, neg_mul]
import Batteries.Data.Nat.Gcd import Mathlib.Init.Data.Nat.Notation import Mathlib.Mathport.Rename #align_import init.data.nat.gcd from "leanprover-community/lean"@"855e5b74e3a52a40552e8f067169d747d48743fd" open WellFounded namespace Nat #align nat.gcd Nat.gcd #align nat.gcd_zero_left Nat.gcd_zero_left #align nat.gcd_succ Nat.gcd_succ #align nat.gcd_one_left Nat.gcd_one_left #align nat.gcd_self Nat.gcd_self #align nat.gcd_zero_right Nat.gcd_zero_right #align nat.gcd_rec Nat.gcd_rec #align nat.gcd.induction Nat.gcd.induction #align nat.lcm Nat.lcm
Mathlib/Init/Data/Nat/GCD.lean
35
36
theorem gcd_def (x y : ℕ) : gcd x y = if x = 0 then y else gcd (y % x) x := by
cases x <;> simp [Nat.gcd_succ]
import Mathlib.Algebra.ContinuedFractions.Translations #align_import algebra.continued_fractions.continuants_recurrence from "leanprover-community/mathlib"@"5f11361a98ae4acd77f5c1837686f6f0102cdc25" namespace GeneralizedContinuedFraction variable {K : Type*} {g : GeneralizedContinuedFraction K} {n : ℕ} [DivisionRing K] theorem continuantsAux_recurrence {gp ppred pred : Pair K} (nth_s_eq : g.s.get? n = some gp) (nth_conts_aux_eq : g.continuantsAux n = ppred) (succ_nth_conts_aux_eq : g.continuantsAux (n + 1) = pred) : g.continuantsAux (n + 2) = ⟨gp.b * pred.a + gp.a * ppred.a, gp.b * pred.b + gp.a * ppred.b⟩ := by simp [*, continuantsAux, nextContinuants, nextDenominator, nextNumerator] #align generalized_continued_fraction.continuants_aux_recurrence GeneralizedContinuedFraction.continuantsAux_recurrence
Mathlib/Algebra/ContinuedFractions/ContinuantsRecurrence.lean
33
38
theorem continuants_recurrenceAux {gp ppred pred : Pair K} (nth_s_eq : g.s.get? n = some gp) (nth_conts_aux_eq : g.continuantsAux n = ppred) (succ_nth_conts_aux_eq : g.continuantsAux (n + 1) = pred) : g.continuants (n + 1) = ⟨gp.b * pred.a + gp.a * ppred.a, gp.b * pred.b + gp.a * ppred.b⟩ := by
simp [nth_cont_eq_succ_nth_cont_aux, continuantsAux_recurrence nth_s_eq nth_conts_aux_eq succ_nth_conts_aux_eq]
import Mathlib.Logic.Equiv.Fin import Mathlib.Topology.DenseEmbedding import Mathlib.Topology.Support import Mathlib.Topology.Connected.LocallyConnected #align_import topology.homeomorph from "leanprover-community/mathlib"@"4c3e1721c58ef9087bbc2c8c38b540f70eda2e53" open Set Filter open Topology variable {X : Type*} {Y : Type*} {Z : Type*} -- not all spaces are homeomorphic to each other structure Homeomorph (X : Type*) (Y : Type*) [TopologicalSpace X] [TopologicalSpace Y] extends X ≃ Y where continuous_toFun : Continuous toFun := by continuity continuous_invFun : Continuous invFun := by continuity #align homeomorph Homeomorph @[inherit_doc] infixl:25 " ≃ₜ " => Homeomorph namespace Homeomorph variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] {X' Y' : Type*} [TopologicalSpace X'] [TopologicalSpace Y'] theorem toEquiv_injective : Function.Injective (toEquiv : X ≃ₜ Y → X ≃ Y) | ⟨_, _, _⟩, ⟨_, _, _⟩, rfl => rfl #align homeomorph.to_equiv_injective Homeomorph.toEquiv_injective instance : EquivLike (X ≃ₜ Y) X Y where coe := fun h => h.toEquiv inv := fun h => h.toEquiv.symm left_inv := fun h => h.left_inv right_inv := fun h => h.right_inv coe_injective' := fun _ _ H _ => toEquiv_injective <| DFunLike.ext' H instance : CoeFun (X ≃ₜ Y) fun _ ↦ X → Y := ⟨DFunLike.coe⟩ @[simp] theorem homeomorph_mk_coe (a : X ≃ Y) (b c) : (Homeomorph.mk a b c : X → Y) = a := rfl #align homeomorph.homeomorph_mk_coe Homeomorph.homeomorph_mk_coe protected def empty [IsEmpty X] [IsEmpty Y] : X ≃ₜ Y where __ := Equiv.equivOfIsEmpty X Y @[symm] protected def symm (h : X ≃ₜ Y) : Y ≃ₜ X where continuous_toFun := h.continuous_invFun continuous_invFun := h.continuous_toFun toEquiv := h.toEquiv.symm #align homeomorph.symm Homeomorph.symm @[simp] theorem symm_symm (h : X ≃ₜ Y) : h.symm.symm = h := rfl #align homeomorph.symm_symm Homeomorph.symm_symm theorem symm_bijective : Function.Bijective (Homeomorph.symm : (X ≃ₜ Y) → Y ≃ₜ X) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ def Simps.symm_apply (h : X ≃ₜ Y) : Y → X := h.symm #align homeomorph.simps.symm_apply Homeomorph.Simps.symm_apply initialize_simps_projections Homeomorph (toFun → apply, invFun → symm_apply) @[simp] theorem coe_toEquiv (h : X ≃ₜ Y) : ⇑h.toEquiv = h := rfl #align homeomorph.coe_to_equiv Homeomorph.coe_toEquiv @[simp] theorem coe_symm_toEquiv (h : X ≃ₜ Y) : ⇑h.toEquiv.symm = h.symm := rfl #align homeomorph.coe_symm_to_equiv Homeomorph.coe_symm_toEquiv @[ext] theorem ext {h h' : X ≃ₜ Y} (H : ∀ x, h x = h' x) : h = h' := DFunLike.ext _ _ H #align homeomorph.ext Homeomorph.ext @[simps! (config := .asFn) apply] protected def refl (X : Type*) [TopologicalSpace X] : X ≃ₜ X where continuous_toFun := continuous_id continuous_invFun := continuous_id toEquiv := Equiv.refl X #align homeomorph.refl Homeomorph.refl @[trans] protected def trans (h₁ : X ≃ₜ Y) (h₂ : Y ≃ₜ Z) : X ≃ₜ Z where continuous_toFun := h₂.continuous_toFun.comp h₁.continuous_toFun continuous_invFun := h₁.continuous_invFun.comp h₂.continuous_invFun toEquiv := Equiv.trans h₁.toEquiv h₂.toEquiv #align homeomorph.trans Homeomorph.trans @[simp] theorem trans_apply (h₁ : X ≃ₜ Y) (h₂ : Y ≃ₜ Z) (x : X) : h₁.trans h₂ x = h₂ (h₁ x) := rfl #align homeomorph.trans_apply Homeomorph.trans_apply @[simp] theorem symm_trans_apply (f : X ≃ₜ Y) (g : Y ≃ₜ Z) (z : Z) : (f.trans g).symm z = f.symm (g.symm z) := rfl @[simp] theorem homeomorph_mk_coe_symm (a : X ≃ Y) (b c) : ((Homeomorph.mk a b c).symm : Y → X) = a.symm := rfl #align homeomorph.homeomorph_mk_coe_symm Homeomorph.homeomorph_mk_coe_symm @[simp] theorem refl_symm : (Homeomorph.refl X).symm = Homeomorph.refl X := rfl #align homeomorph.refl_symm Homeomorph.refl_symm @[continuity] protected theorem continuous (h : X ≃ₜ Y) : Continuous h := h.continuous_toFun #align homeomorph.continuous Homeomorph.continuous -- otherwise `by continuity` can't prove continuity of `h.to_equiv.symm` @[continuity] protected theorem continuous_symm (h : X ≃ₜ Y) : Continuous h.symm := h.continuous_invFun #align homeomorph.continuous_symm Homeomorph.continuous_symm @[simp] theorem apply_symm_apply (h : X ≃ₜ Y) (y : Y) : h (h.symm y) = y := h.toEquiv.apply_symm_apply y #align homeomorph.apply_symm_apply Homeomorph.apply_symm_apply @[simp] theorem symm_apply_apply (h : X ≃ₜ Y) (x : X) : h.symm (h x) = x := h.toEquiv.symm_apply_apply x #align homeomorph.symm_apply_apply Homeomorph.symm_apply_apply @[simp] theorem self_trans_symm (h : X ≃ₜ Y) : h.trans h.symm = Homeomorph.refl X := by ext apply symm_apply_apply #align homeomorph.self_trans_symm Homeomorph.self_trans_symm @[simp] theorem symm_trans_self (h : X ≃ₜ Y) : h.symm.trans h = Homeomorph.refl Y := by ext apply apply_symm_apply #align homeomorph.symm_trans_self Homeomorph.symm_trans_self protected theorem bijective (h : X ≃ₜ Y) : Function.Bijective h := h.toEquiv.bijective #align homeomorph.bijective Homeomorph.bijective protected theorem injective (h : X ≃ₜ Y) : Function.Injective h := h.toEquiv.injective #align homeomorph.injective Homeomorph.injective protected theorem surjective (h : X ≃ₜ Y) : Function.Surjective h := h.toEquiv.surjective #align homeomorph.surjective Homeomorph.surjective def changeInv (f : X ≃ₜ Y) (g : Y → X) (hg : Function.RightInverse g f) : X ≃ₜ Y := haveI : g = f.symm := (f.left_inv.eq_rightInverse hg).symm { toFun := f invFun := g left_inv := by convert f.left_inv right_inv := by convert f.right_inv using 1 continuous_toFun := f.continuous continuous_invFun := by convert f.symm.continuous } #align homeomorph.change_inv Homeomorph.changeInv @[simp] theorem symm_comp_self (h : X ≃ₜ Y) : h.symm ∘ h = id := funext h.symm_apply_apply #align homeomorph.symm_comp_self Homeomorph.symm_comp_self @[simp] theorem self_comp_symm (h : X ≃ₜ Y) : h ∘ h.symm = id := funext h.apply_symm_apply #align homeomorph.self_comp_symm Homeomorph.self_comp_symm @[simp] theorem range_coe (h : X ≃ₜ Y) : range h = univ := h.surjective.range_eq #align homeomorph.range_coe Homeomorph.range_coe theorem image_symm (h : X ≃ₜ Y) : image h.symm = preimage h := funext h.symm.toEquiv.image_eq_preimage #align homeomorph.image_symm Homeomorph.image_symm theorem preimage_symm (h : X ≃ₜ Y) : preimage h.symm = image h := (funext h.toEquiv.image_eq_preimage).symm #align homeomorph.preimage_symm Homeomorph.preimage_symm @[simp] theorem image_preimage (h : X ≃ₜ Y) (s : Set Y) : h '' (h ⁻¹' s) = s := h.toEquiv.image_preimage s #align homeomorph.image_preimage Homeomorph.image_preimage @[simp] theorem preimage_image (h : X ≃ₜ Y) (s : Set X) : h ⁻¹' (h '' s) = s := h.toEquiv.preimage_image s #align homeomorph.preimage_image Homeomorph.preimage_image lemma image_compl (h : X ≃ₜ Y) (s : Set X) : h '' (sᶜ) = (h '' s)ᶜ := h.toEquiv.image_compl s protected theorem inducing (h : X ≃ₜ Y) : Inducing h := inducing_of_inducing_compose h.continuous h.symm.continuous <| by simp only [symm_comp_self, inducing_id] #align homeomorph.inducing Homeomorph.inducing theorem induced_eq (h : X ≃ₜ Y) : TopologicalSpace.induced h ‹_› = ‹_› := h.inducing.1.symm #align homeomorph.induced_eq Homeomorph.induced_eq protected theorem quotientMap (h : X ≃ₜ Y) : QuotientMap h := QuotientMap.of_quotientMap_compose h.symm.continuous h.continuous <| by simp only [self_comp_symm, QuotientMap.id] #align homeomorph.quotient_map Homeomorph.quotientMap theorem coinduced_eq (h : X ≃ₜ Y) : TopologicalSpace.coinduced h ‹_› = ‹_› := h.quotientMap.2.symm #align homeomorph.coinduced_eq Homeomorph.coinduced_eq protected theorem embedding (h : X ≃ₜ Y) : Embedding h := ⟨h.inducing, h.injective⟩ #align homeomorph.embedding Homeomorph.embedding noncomputable def ofEmbedding (f : X → Y) (hf : Embedding f) : X ≃ₜ Set.range f where continuous_toFun := hf.continuous.subtype_mk _ continuous_invFun := hf.continuous_iff.2 <| by simp [continuous_subtype_val] toEquiv := Equiv.ofInjective f hf.inj #align homeomorph.of_embedding Homeomorph.ofEmbedding protected theorem secondCountableTopology [SecondCountableTopology Y] (h : X ≃ₜ Y) : SecondCountableTopology X := h.inducing.secondCountableTopology #align homeomorph.second_countable_topology Homeomorph.secondCountableTopology @[simp] theorem isCompact_image {s : Set X} (h : X ≃ₜ Y) : IsCompact (h '' s) ↔ IsCompact s := h.embedding.isCompact_iff.symm #align homeomorph.is_compact_image Homeomorph.isCompact_image @[simp] theorem isCompact_preimage {s : Set Y} (h : X ≃ₜ Y) : IsCompact (h ⁻¹' s) ↔ IsCompact s := by rw [← image_symm]; exact h.symm.isCompact_image #align homeomorph.is_compact_preimage Homeomorph.isCompact_preimage @[simp] theorem isSigmaCompact_image {s : Set X} (h : X ≃ₜ Y) : IsSigmaCompact (h '' s) ↔ IsSigmaCompact s := h.embedding.isSigmaCompact_iff.symm @[simp] theorem isSigmaCompact_preimage {s : Set Y} (h : X ≃ₜ Y) : IsSigmaCompact (h ⁻¹' s) ↔ IsSigmaCompact s := by rw [← image_symm]; exact h.symm.isSigmaCompact_image @[simp] theorem isPreconnected_image {s : Set X} (h : X ≃ₜ Y) : IsPreconnected (h '' s) ↔ IsPreconnected s := ⟨fun hs ↦ by simpa only [image_symm, preimage_image] using hs.image _ h.symm.continuous.continuousOn, fun hs ↦ hs.image _ h.continuous.continuousOn⟩ @[simp] theorem isPreconnected_preimage {s : Set Y} (h : X ≃ₜ Y) : IsPreconnected (h ⁻¹' s) ↔ IsPreconnected s := by rw [← image_symm, isPreconnected_image] @[simp] theorem isConnected_image {s : Set X} (h : X ≃ₜ Y) : IsConnected (h '' s) ↔ IsConnected s := image_nonempty.and h.isPreconnected_image @[simp] theorem isConnected_preimage {s : Set Y} (h : X ≃ₜ Y) : IsConnected (h ⁻¹' s) ↔ IsConnected s := by rw [← image_symm, isConnected_image] theorem image_connectedComponentIn {s : Set X} (h : X ≃ₜ Y) {x : X} (hx : x ∈ s) : h '' connectedComponentIn s x = connectedComponentIn (h '' s) (h x) := by refine (h.continuous.image_connectedComponentIn_subset hx).antisymm ?_ have := h.symm.continuous.image_connectedComponentIn_subset (mem_image_of_mem h hx) rwa [image_subset_iff, h.preimage_symm, h.image_symm, h.preimage_image, h.symm_apply_apply] at this @[simp] theorem comap_cocompact (h : X ≃ₜ Y) : comap h (cocompact Y) = cocompact X := (comap_cocompact_le h.continuous).antisymm <| (hasBasis_cocompact.le_basis_iff (hasBasis_cocompact.comap h)).2 fun K hK => ⟨h ⁻¹' K, h.isCompact_preimage.2 hK, Subset.rfl⟩ #align homeomorph.comap_cocompact Homeomorph.comap_cocompact @[simp] theorem map_cocompact (h : X ≃ₜ Y) : map h (cocompact X) = cocompact Y := by rw [← h.comap_cocompact, map_comap_of_surjective h.surjective] #align homeomorph.map_cocompact Homeomorph.map_cocompact protected theorem compactSpace [CompactSpace X] (h : X ≃ₜ Y) : CompactSpace Y where isCompact_univ := h.symm.isCompact_preimage.2 isCompact_univ #align homeomorph.compact_space Homeomorph.compactSpace protected theorem t0Space [T0Space X] (h : X ≃ₜ Y) : T0Space Y := h.symm.embedding.t0Space #align homeomorph.t0_space Homeomorph.t0Space protected theorem t1Space [T1Space X] (h : X ≃ₜ Y) : T1Space Y := h.symm.embedding.t1Space #align homeomorph.t1_space Homeomorph.t1Space protected theorem t2Space [T2Space X] (h : X ≃ₜ Y) : T2Space Y := h.symm.embedding.t2Space #align homeomorph.t2_space Homeomorph.t2Space protected theorem t3Space [T3Space X] (h : X ≃ₜ Y) : T3Space Y := h.symm.embedding.t3Space #align homeomorph.t3_space Homeomorph.t3Space protected theorem denseEmbedding (h : X ≃ₜ Y) : DenseEmbedding h := { h.embedding with dense := h.surjective.denseRange } #align homeomorph.dense_embedding Homeomorph.denseEmbedding @[simp] theorem isOpen_preimage (h : X ≃ₜ Y) {s : Set Y} : IsOpen (h ⁻¹' s) ↔ IsOpen s := h.quotientMap.isOpen_preimage #align homeomorph.is_open_preimage Homeomorph.isOpen_preimage @[simp] theorem isOpen_image (h : X ≃ₜ Y) {s : Set X} : IsOpen (h '' s) ↔ IsOpen s := by rw [← preimage_symm, isOpen_preimage] #align homeomorph.is_open_image Homeomorph.isOpen_image protected theorem isOpenMap (h : X ≃ₜ Y) : IsOpenMap h := fun _ => h.isOpen_image.2 #align homeomorph.is_open_map Homeomorph.isOpenMap @[simp] theorem isClosed_preimage (h : X ≃ₜ Y) {s : Set Y} : IsClosed (h ⁻¹' s) ↔ IsClosed s := by simp only [← isOpen_compl_iff, ← preimage_compl, isOpen_preimage] #align homeomorph.is_closed_preimage Homeomorph.isClosed_preimage @[simp] theorem isClosed_image (h : X ≃ₜ Y) {s : Set X} : IsClosed (h '' s) ↔ IsClosed s := by rw [← preimage_symm, isClosed_preimage] #align homeomorph.is_closed_image Homeomorph.isClosed_image protected theorem isClosedMap (h : X ≃ₜ Y) : IsClosedMap h := fun _ => h.isClosed_image.2 #align homeomorph.is_closed_map Homeomorph.isClosedMap protected theorem openEmbedding (h : X ≃ₜ Y) : OpenEmbedding h := openEmbedding_of_embedding_open h.embedding h.isOpenMap #align homeomorph.open_embedding Homeomorph.openEmbedding protected theorem closedEmbedding (h : X ≃ₜ Y) : ClosedEmbedding h := closedEmbedding_of_embedding_closed h.embedding h.isClosedMap #align homeomorph.closed_embedding Homeomorph.closedEmbedding protected theorem normalSpace [NormalSpace X] (h : X ≃ₜ Y) : NormalSpace Y := h.symm.closedEmbedding.normalSpace protected theorem t4Space [T4Space X] (h : X ≃ₜ Y) : T4Space Y := h.symm.closedEmbedding.t4Space #align homeomorph.normal_space Homeomorph.t4Space theorem preimage_closure (h : X ≃ₜ Y) (s : Set Y) : h ⁻¹' closure s = closure (h ⁻¹' s) := h.isOpenMap.preimage_closure_eq_closure_preimage h.continuous _ #align homeomorph.preimage_closure Homeomorph.preimage_closure theorem image_closure (h : X ≃ₜ Y) (s : Set X) : h '' closure s = closure (h '' s) := by rw [← preimage_symm, preimage_closure] #align homeomorph.image_closure Homeomorph.image_closure theorem preimage_interior (h : X ≃ₜ Y) (s : Set Y) : h ⁻¹' interior s = interior (h ⁻¹' s) := h.isOpenMap.preimage_interior_eq_interior_preimage h.continuous _ #align homeomorph.preimage_interior Homeomorph.preimage_interior theorem image_interior (h : X ≃ₜ Y) (s : Set X) : h '' interior s = interior (h '' s) := by rw [← preimage_symm, preimage_interior] #align homeomorph.image_interior Homeomorph.image_interior theorem preimage_frontier (h : X ≃ₜ Y) (s : Set Y) : h ⁻¹' frontier s = frontier (h ⁻¹' s) := h.isOpenMap.preimage_frontier_eq_frontier_preimage h.continuous _ #align homeomorph.preimage_frontier Homeomorph.preimage_frontier theorem image_frontier (h : X ≃ₜ Y) (s : Set X) : h '' frontier s = frontier (h '' s) := by rw [← preimage_symm, preimage_frontier] #align homeomorph.image_frontier Homeomorph.image_frontier @[to_additive] theorem _root_.HasCompactMulSupport.comp_homeomorph {M} [One M] {f : Y → M} (hf : HasCompactMulSupport f) (φ : X ≃ₜ Y) : HasCompactMulSupport (f ∘ φ) := hf.comp_closedEmbedding φ.closedEmbedding #align has_compact_mul_support.comp_homeomorph HasCompactMulSupport.comp_homeomorph #align has_compact_support.comp_homeomorph HasCompactSupport.comp_homeomorph @[simp] theorem map_nhds_eq (h : X ≃ₜ Y) (x : X) : map h (𝓝 x) = 𝓝 (h x) := h.embedding.map_nhds_of_mem _ (by simp) #align homeomorph.map_nhds_eq Homeomorph.map_nhds_eq @[simp] theorem map_punctured_nhds_eq (h : X ≃ₜ Y) (x : X) : map h (𝓝[≠] x) = 𝓝[≠] (h x) := by convert h.embedding.map_nhdsWithin_eq ({x}ᶜ) x rw [h.image_compl, Set.image_singleton]
Mathlib/Topology/Homeomorph.lean
446
447
theorem symm_map_nhds_eq (h : X ≃ₜ Y) (x : X) : map h.symm (𝓝 (h x)) = 𝓝 x := by
rw [h.symm.map_nhds_eq, h.symm_apply_apply]
import Mathlib.Topology.UniformSpace.UniformConvergenceTopology #align_import topology.uniform_space.equicontinuity from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" section open UniformSpace Filter Set Uniformity Topology UniformConvergence Function variable {ι κ X X' Y Z α α' β β' γ 𝓕 : Type*} [tX : TopologicalSpace X] [tY : TopologicalSpace Y] [tZ : TopologicalSpace Z] [uα : UniformSpace α] [uβ : UniformSpace β] [uγ : UniformSpace γ] def EquicontinuousAt (F : ι → X → α) (x₀ : X) : Prop := ∀ U ∈ 𝓤 α, ∀ᶠ x in 𝓝 x₀, ∀ i, (F i x₀, F i x) ∈ U #align equicontinuous_at EquicontinuousAt protected abbrev Set.EquicontinuousAt (H : Set <| X → α) (x₀ : X) : Prop := EquicontinuousAt ((↑) : H → X → α) x₀ #align set.equicontinuous_at Set.EquicontinuousAt def EquicontinuousWithinAt (F : ι → X → α) (S : Set X) (x₀ : X) : Prop := ∀ U ∈ 𝓤 α, ∀ᶠ x in 𝓝[S] x₀, ∀ i, (F i x₀, F i x) ∈ U protected abbrev Set.EquicontinuousWithinAt (H : Set <| X → α) (S : Set X) (x₀ : X) : Prop := EquicontinuousWithinAt ((↑) : H → X → α) S x₀ def Equicontinuous (F : ι → X → α) : Prop := ∀ x₀, EquicontinuousAt F x₀ #align equicontinuous Equicontinuous protected abbrev Set.Equicontinuous (H : Set <| X → α) : Prop := Equicontinuous ((↑) : H → X → α) #align set.equicontinuous Set.Equicontinuous def EquicontinuousOn (F : ι → X → α) (S : Set X) : Prop := ∀ x₀ ∈ S, EquicontinuousWithinAt F S x₀ protected abbrev Set.EquicontinuousOn (H : Set <| X → α) (S : Set X) : Prop := EquicontinuousOn ((↑) : H → X → α) S def UniformEquicontinuous (F : ι → β → α) : Prop := ∀ U ∈ 𝓤 α, ∀ᶠ xy : β × β in 𝓤 β, ∀ i, (F i xy.1, F i xy.2) ∈ U #align uniform_equicontinuous UniformEquicontinuous protected abbrev Set.UniformEquicontinuous (H : Set <| β → α) : Prop := UniformEquicontinuous ((↑) : H → β → α) #align set.uniform_equicontinuous Set.UniformEquicontinuous def UniformEquicontinuousOn (F : ι → β → α) (S : Set β) : Prop := ∀ U ∈ 𝓤 α, ∀ᶠ xy : β × β in 𝓤 β ⊓ 𝓟 (S ×ˢ S), ∀ i, (F i xy.1, F i xy.2) ∈ U protected abbrev Set.UniformEquicontinuousOn (H : Set <| β → α) (S : Set β) : Prop := UniformEquicontinuousOn ((↑) : H → β → α) S lemma EquicontinuousAt.equicontinuousWithinAt {F : ι → X → α} {x₀ : X} (H : EquicontinuousAt F x₀) (S : Set X) : EquicontinuousWithinAt F S x₀ := fun U hU ↦ (H U hU).filter_mono inf_le_left lemma EquicontinuousWithinAt.mono {F : ι → X → α} {x₀ : X} {S T : Set X} (H : EquicontinuousWithinAt F T x₀) (hST : S ⊆ T) : EquicontinuousWithinAt F S x₀ := fun U hU ↦ (H U hU).filter_mono <| nhdsWithin_mono x₀ hST @[simp] lemma equicontinuousWithinAt_univ (F : ι → X → α) (x₀ : X) : EquicontinuousWithinAt F univ x₀ ↔ EquicontinuousAt F x₀ := by rw [EquicontinuousWithinAt, EquicontinuousAt, nhdsWithin_univ] lemma equicontinuousAt_restrict_iff (F : ι → X → α) {S : Set X} (x₀ : S) : EquicontinuousAt (S.restrict ∘ F) x₀ ↔ EquicontinuousWithinAt F S x₀ := by simp [EquicontinuousWithinAt, EquicontinuousAt, ← eventually_nhds_subtype_iff] lemma Equicontinuous.equicontinuousOn {F : ι → X → α} (H : Equicontinuous F) (S : Set X) : EquicontinuousOn F S := fun x _ ↦ (H x).equicontinuousWithinAt S lemma EquicontinuousOn.mono {F : ι → X → α} {S T : Set X} (H : EquicontinuousOn F T) (hST : S ⊆ T) : EquicontinuousOn F S := fun x hx ↦ (H x (hST hx)).mono hST lemma equicontinuousOn_univ (F : ι → X → α) : EquicontinuousOn F univ ↔ Equicontinuous F := by simp [EquicontinuousOn, Equicontinuous] lemma equicontinuous_restrict_iff (F : ι → X → α) {S : Set X} : Equicontinuous (S.restrict ∘ F) ↔ EquicontinuousOn F S := by simp [Equicontinuous, EquicontinuousOn, equicontinuousAt_restrict_iff] lemma UniformEquicontinuous.uniformEquicontinuousOn {F : ι → β → α} (H : UniformEquicontinuous F) (S : Set β) : UniformEquicontinuousOn F S := fun U hU ↦ (H U hU).filter_mono inf_le_left lemma UniformEquicontinuousOn.mono {F : ι → β → α} {S T : Set β} (H : UniformEquicontinuousOn F T) (hST : S ⊆ T) : UniformEquicontinuousOn F S := fun U hU ↦ (H U hU).filter_mono <| by gcongr lemma uniformEquicontinuousOn_univ (F : ι → β → α) : UniformEquicontinuousOn F univ ↔ UniformEquicontinuous F := by simp [UniformEquicontinuousOn, UniformEquicontinuous] lemma uniformEquicontinuous_restrict_iff (F : ι → β → α) {S : Set β} : UniformEquicontinuous (S.restrict ∘ F) ↔ UniformEquicontinuousOn F S := by rw [UniformEquicontinuous, UniformEquicontinuousOn] conv in _ ⊓ _ => rw [← Subtype.range_val (s := S), ← range_prod_map, ← map_comap] rfl @[simp] lemma equicontinuousAt_empty [h : IsEmpty ι] (F : ι → X → α) (x₀ : X) : EquicontinuousAt F x₀ := fun _ _ ↦ eventually_of_forall (fun _ ↦ h.elim) @[simp] lemma equicontinuousWithinAt_empty [h : IsEmpty ι] (F : ι → X → α) (S : Set X) (x₀ : X) : EquicontinuousWithinAt F S x₀ := fun _ _ ↦ eventually_of_forall (fun _ ↦ h.elim) @[simp] lemma equicontinuous_empty [IsEmpty ι] (F : ι → X → α) : Equicontinuous F := equicontinuousAt_empty F @[simp] lemma equicontinuousOn_empty [IsEmpty ι] (F : ι → X → α) (S : Set X) : EquicontinuousOn F S := fun x₀ _ ↦ equicontinuousWithinAt_empty F S x₀ @[simp] lemma uniformEquicontinuous_empty [h : IsEmpty ι] (F : ι → β → α) : UniformEquicontinuous F := fun _ _ ↦ eventually_of_forall (fun _ ↦ h.elim) @[simp] lemma uniformEquicontinuousOn_empty [h : IsEmpty ι] (F : ι → β → α) (S : Set β) : UniformEquicontinuousOn F S := fun _ _ ↦ eventually_of_forall (fun _ ↦ h.elim) theorem equicontinuousAt_finite [Finite ι] {F : ι → X → α} {x₀ : X} : EquicontinuousAt F x₀ ↔ ∀ i, ContinuousAt (F i) x₀ := by simp [EquicontinuousAt, ContinuousAt, (nhds_basis_uniformity' (𝓤 α).basis_sets).tendsto_right_iff, UniformSpace.ball, @forall_swap _ ι] theorem equicontinuousWithinAt_finite [Finite ι] {F : ι → X → α} {S : Set X} {x₀ : X} : EquicontinuousWithinAt F S x₀ ↔ ∀ i, ContinuousWithinAt (F i) S x₀ := by simp [EquicontinuousWithinAt, ContinuousWithinAt, (nhds_basis_uniformity' (𝓤 α).basis_sets).tendsto_right_iff, UniformSpace.ball, @forall_swap _ ι] theorem equicontinuous_finite [Finite ι] {F : ι → X → α} : Equicontinuous F ↔ ∀ i, Continuous (F i) := by simp only [Equicontinuous, equicontinuousAt_finite, continuous_iff_continuousAt, @forall_swap ι] theorem equicontinuousOn_finite [Finite ι] {F : ι → X → α} {S : Set X} : EquicontinuousOn F S ↔ ∀ i, ContinuousOn (F i) S := by simp only [EquicontinuousOn, equicontinuousWithinAt_finite, ContinuousOn, @forall_swap ι] theorem uniformEquicontinuous_finite [Finite ι] {F : ι → β → α} : UniformEquicontinuous F ↔ ∀ i, UniformContinuous (F i) := by simp only [UniformEquicontinuous, eventually_all, @forall_swap _ ι]; rfl theorem uniformEquicontinuousOn_finite [Finite ι] {F : ι → β → α} {S : Set β} : UniformEquicontinuousOn F S ↔ ∀ i, UniformContinuousOn (F i) S := by simp only [UniformEquicontinuousOn, eventually_all, @forall_swap _ ι]; rfl theorem equicontinuousAt_unique [Unique ι] {F : ι → X → α} {x : X} : EquicontinuousAt F x ↔ ContinuousAt (F default) x := equicontinuousAt_finite.trans Unique.forall_iff theorem equicontinuousWithinAt_unique [Unique ι] {F : ι → X → α} {S : Set X} {x : X} : EquicontinuousWithinAt F S x ↔ ContinuousWithinAt (F default) S x := equicontinuousWithinAt_finite.trans Unique.forall_iff theorem equicontinuous_unique [Unique ι] {F : ι → X → α} : Equicontinuous F ↔ Continuous (F default) := equicontinuous_finite.trans Unique.forall_iff theorem equicontinuousOn_unique [Unique ι] {F : ι → X → α} {S : Set X} : EquicontinuousOn F S ↔ ContinuousOn (F default) S := equicontinuousOn_finite.trans Unique.forall_iff theorem uniformEquicontinuous_unique [Unique ι] {F : ι → β → α} : UniformEquicontinuous F ↔ UniformContinuous (F default) := uniformEquicontinuous_finite.trans Unique.forall_iff theorem uniformEquicontinuousOn_unique [Unique ι] {F : ι → β → α} {S : Set β} : UniformEquicontinuousOn F S ↔ UniformContinuousOn (F default) S := uniformEquicontinuousOn_finite.trans Unique.forall_iff theorem equicontinuousWithinAt_iff_pair {F : ι → X → α} {S : Set X} {x₀ : X} (hx₀ : x₀ ∈ S) : EquicontinuousWithinAt F S x₀ ↔ ∀ U ∈ 𝓤 α, ∃ V ∈ 𝓝[S] x₀, ∀ x ∈ V, ∀ y ∈ V, ∀ i, (F i x, F i y) ∈ U := by constructor <;> intro H U hU · rcases comp_symm_mem_uniformity_sets hU with ⟨V, hV, hVsymm, hVU⟩ refine ⟨_, H V hV, fun x hx y hy i => hVU (prod_mk_mem_compRel ?_ (hy i))⟩ exact hVsymm.mk_mem_comm.mp (hx i) · rcases H U hU with ⟨V, hV, hVU⟩ filter_upwards [hV] using fun x hx i => hVU x₀ (mem_of_mem_nhdsWithin hx₀ hV) x hx i theorem equicontinuousAt_iff_pair {F : ι → X → α} {x₀ : X} : EquicontinuousAt F x₀ ↔ ∀ U ∈ 𝓤 α, ∃ V ∈ 𝓝 x₀, ∀ x ∈ V, ∀ y ∈ V, ∀ i, (F i x, F i y) ∈ U := by simp_rw [← equicontinuousWithinAt_univ, equicontinuousWithinAt_iff_pair (mem_univ x₀), nhdsWithin_univ] #align equicontinuous_at_iff_pair equicontinuousAt_iff_pair theorem UniformEquicontinuous.equicontinuous {F : ι → β → α} (h : UniformEquicontinuous F) : Equicontinuous F := fun x₀ U hU ↦ mem_of_superset (ball_mem_nhds x₀ (h U hU)) fun _ hx i ↦ hx i #align uniform_equicontinuous.equicontinuous UniformEquicontinuous.equicontinuous theorem UniformEquicontinuousOn.equicontinuousOn {F : ι → β → α} {S : Set β} (h : UniformEquicontinuousOn F S) : EquicontinuousOn F S := fun _ hx₀ U hU ↦ mem_of_superset (ball_mem_nhdsWithin hx₀ (h U hU)) fun _ hx i ↦ hx i theorem EquicontinuousAt.continuousAt {F : ι → X → α} {x₀ : X} (h : EquicontinuousAt F x₀) (i : ι) : ContinuousAt (F i) x₀ := (UniformSpace.hasBasis_nhds _).tendsto_right_iff.2 fun U ⟨hU, _⟩ ↦ (h U hU).mono fun _x hx ↦ hx i #align equicontinuous_at.continuous_at EquicontinuousAt.continuousAt theorem EquicontinuousWithinAt.continuousWithinAt {F : ι → X → α} {S : Set X} {x₀ : X} (h : EquicontinuousWithinAt F S x₀) (i : ι) : ContinuousWithinAt (F i) S x₀ := (UniformSpace.hasBasis_nhds _).tendsto_right_iff.2 fun U ⟨hU, _⟩ ↦ (h U hU).mono fun _x hx ↦ hx i protected theorem Set.EquicontinuousAt.continuousAt_of_mem {H : Set <| X → α} {x₀ : X} (h : H.EquicontinuousAt x₀) {f : X → α} (hf : f ∈ H) : ContinuousAt f x₀ := h.continuousAt ⟨f, hf⟩ #align set.equicontinuous_at.continuous_at_of_mem Set.EquicontinuousAt.continuousAt_of_mem protected theorem Set.EquicontinuousWithinAt.continuousWithinAt_of_mem {H : Set <| X → α} {S : Set X} {x₀ : X} (h : H.EquicontinuousWithinAt S x₀) {f : X → α} (hf : f ∈ H) : ContinuousWithinAt f S x₀ := h.continuousWithinAt ⟨f, hf⟩ theorem Equicontinuous.continuous {F : ι → X → α} (h : Equicontinuous F) (i : ι) : Continuous (F i) := continuous_iff_continuousAt.mpr fun x => (h x).continuousAt i #align equicontinuous.continuous Equicontinuous.continuous theorem EquicontinuousOn.continuousOn {F : ι → X → α} {S : Set X} (h : EquicontinuousOn F S) (i : ι) : ContinuousOn (F i) S := fun x hx ↦ (h x hx).continuousWithinAt i protected theorem Set.Equicontinuous.continuous_of_mem {H : Set <| X → α} (h : H.Equicontinuous) {f : X → α} (hf : f ∈ H) : Continuous f := h.continuous ⟨f, hf⟩ #align set.equicontinuous.continuous_of_mem Set.Equicontinuous.continuous_of_mem protected theorem Set.EquicontinuousOn.continuousOn_of_mem {H : Set <| X → α} {S : Set X} (h : H.EquicontinuousOn S) {f : X → α} (hf : f ∈ H) : ContinuousOn f S := h.continuousOn ⟨f, hf⟩ theorem UniformEquicontinuous.uniformContinuous {F : ι → β → α} (h : UniformEquicontinuous F) (i : ι) : UniformContinuous (F i) := fun U hU => mem_map.mpr (mem_of_superset (h U hU) fun _ hxy => hxy i) #align uniform_equicontinuous.uniform_continuous UniformEquicontinuous.uniformContinuous theorem UniformEquicontinuousOn.uniformContinuousOn {F : ι → β → α} {S : Set β} (h : UniformEquicontinuousOn F S) (i : ι) : UniformContinuousOn (F i) S := fun U hU => mem_map.mpr (mem_of_superset (h U hU) fun _ hxy => hxy i) protected theorem Set.UniformEquicontinuous.uniformContinuous_of_mem {H : Set <| β → α} (h : H.UniformEquicontinuous) {f : β → α} (hf : f ∈ H) : UniformContinuous f := h.uniformContinuous ⟨f, hf⟩ #align set.uniform_equicontinuous.uniform_continuous_of_mem Set.UniformEquicontinuous.uniformContinuous_of_mem protected theorem Set.UniformEquicontinuousOn.uniformContinuousOn_of_mem {H : Set <| β → α} {S : Set β} (h : H.UniformEquicontinuousOn S) {f : β → α} (hf : f ∈ H) : UniformContinuousOn f S := h.uniformContinuousOn ⟨f, hf⟩ theorem EquicontinuousAt.comp {F : ι → X → α} {x₀ : X} (h : EquicontinuousAt F x₀) (u : κ → ι) : EquicontinuousAt (F ∘ u) x₀ := fun U hU => (h U hU).mono fun _ H k => H (u k) #align equicontinuous_at.comp EquicontinuousAt.comp theorem EquicontinuousWithinAt.comp {F : ι → X → α} {S : Set X} {x₀ : X} (h : EquicontinuousWithinAt F S x₀) (u : κ → ι) : EquicontinuousWithinAt (F ∘ u) S x₀ := fun U hU ↦ (h U hU).mono fun _ H k => H (u k) protected theorem Set.EquicontinuousAt.mono {H H' : Set <| X → α} {x₀ : X} (h : H.EquicontinuousAt x₀) (hH : H' ⊆ H) : H'.EquicontinuousAt x₀ := h.comp (inclusion hH) #align set.equicontinuous_at.mono Set.EquicontinuousAt.mono protected theorem Set.EquicontinuousWithinAt.mono {H H' : Set <| X → α} {S : Set X} {x₀ : X} (h : H.EquicontinuousWithinAt S x₀) (hH : H' ⊆ H) : H'.EquicontinuousWithinAt S x₀ := h.comp (inclusion hH) theorem Equicontinuous.comp {F : ι → X → α} (h : Equicontinuous F) (u : κ → ι) : Equicontinuous (F ∘ u) := fun x => (h x).comp u #align equicontinuous.comp Equicontinuous.comp theorem EquicontinuousOn.comp {F : ι → X → α} {S : Set X} (h : EquicontinuousOn F S) (u : κ → ι) : EquicontinuousOn (F ∘ u) S := fun x hx ↦ (h x hx).comp u protected theorem Set.Equicontinuous.mono {H H' : Set <| X → α} (h : H.Equicontinuous) (hH : H' ⊆ H) : H'.Equicontinuous := h.comp (inclusion hH) #align set.equicontinuous.mono Set.Equicontinuous.mono protected theorem Set.EquicontinuousOn.mono {H H' : Set <| X → α} {S : Set X} (h : H.EquicontinuousOn S) (hH : H' ⊆ H) : H'.EquicontinuousOn S := h.comp (inclusion hH) theorem UniformEquicontinuous.comp {F : ι → β → α} (h : UniformEquicontinuous F) (u : κ → ι) : UniformEquicontinuous (F ∘ u) := fun U hU => (h U hU).mono fun _ H k => H (u k) #align uniform_equicontinuous.comp UniformEquicontinuous.comp theorem UniformEquicontinuousOn.comp {F : ι → β → α} {S : Set β} (h : UniformEquicontinuousOn F S) (u : κ → ι) : UniformEquicontinuousOn (F ∘ u) S := fun U hU ↦ (h U hU).mono fun _ H k => H (u k) protected theorem Set.UniformEquicontinuous.mono {H H' : Set <| β → α} (h : H.UniformEquicontinuous) (hH : H' ⊆ H) : H'.UniformEquicontinuous := h.comp (inclusion hH) #align set.uniform_equicontinuous.mono Set.UniformEquicontinuous.mono protected theorem Set.UniformEquicontinuousOn.mono {H H' : Set <| β → α} {S : Set β} (h : H.UniformEquicontinuousOn S) (hH : H' ⊆ H) : H'.UniformEquicontinuousOn S := h.comp (inclusion hH) theorem equicontinuousAt_iff_range {F : ι → X → α} {x₀ : X} : EquicontinuousAt F x₀ ↔ EquicontinuousAt ((↑) : range F → X → α) x₀ := by simp only [EquicontinuousAt, forall_subtype_range_iff] #align equicontinuous_at_iff_range equicontinuousAt_iff_range theorem equicontinuousWithinAt_iff_range {F : ι → X → α} {S : Set X} {x₀ : X} : EquicontinuousWithinAt F S x₀ ↔ EquicontinuousWithinAt ((↑) : range F → X → α) S x₀ := by simp only [EquicontinuousWithinAt, forall_subtype_range_iff] theorem equicontinuous_iff_range {F : ι → X → α} : Equicontinuous F ↔ Equicontinuous ((↑) : range F → X → α) := forall_congr' fun _ => equicontinuousAt_iff_range #align equicontinuous_iff_range equicontinuous_iff_range theorem equicontinuousOn_iff_range {F : ι → X → α} {S : Set X} : EquicontinuousOn F S ↔ EquicontinuousOn ((↑) : range F → X → α) S := forall_congr' fun _ ↦ forall_congr' fun _ ↦ equicontinuousWithinAt_iff_range theorem uniformEquicontinuous_iff_range {F : ι → β → α} : UniformEquicontinuous F ↔ UniformEquicontinuous ((↑) : range F → β → α) := ⟨fun h => by rw [← comp_rangeSplitting F]; exact h.comp _, fun h => h.comp (rangeFactorization F)⟩ #align uniform_equicontinuous_at_iff_range uniformEquicontinuous_iff_range theorem uniformEquicontinuousOn_iff_range {F : ι → β → α} {S : Set β} : UniformEquicontinuousOn F S ↔ UniformEquicontinuousOn ((↑) : range F → β → α) S := ⟨fun h => by rw [← comp_rangeSplitting F]; exact h.comp _, fun h => h.comp (rangeFactorization F)⟩ section open UniformFun theorem equicontinuousAt_iff_continuousAt {F : ι → X → α} {x₀ : X} : EquicontinuousAt F x₀ ↔ ContinuousAt (ofFun ∘ Function.swap F : X → ι →ᵤ α) x₀ := by rw [ContinuousAt, (UniformFun.hasBasis_nhds ι α _).tendsto_right_iff] rfl #align equicontinuous_at_iff_continuous_at equicontinuousAt_iff_continuousAt theorem equicontinuousWithinAt_iff_continuousWithinAt {F : ι → X → α} {S : Set X} {x₀ : X} : EquicontinuousWithinAt F S x₀ ↔ ContinuousWithinAt (ofFun ∘ Function.swap F : X → ι →ᵤ α) S x₀ := by rw [ContinuousWithinAt, (UniformFun.hasBasis_nhds ι α _).tendsto_right_iff] rfl theorem equicontinuous_iff_continuous {F : ι → X → α} : Equicontinuous F ↔ Continuous (ofFun ∘ Function.swap F : X → ι →ᵤ α) := by simp_rw [Equicontinuous, continuous_iff_continuousAt, equicontinuousAt_iff_continuousAt] #align equicontinuous_iff_continuous equicontinuous_iff_continuous theorem equicontinuousOn_iff_continuousOn {F : ι → X → α} {S : Set X} : EquicontinuousOn F S ↔ ContinuousOn (ofFun ∘ Function.swap F : X → ι →ᵤ α) S := by simp_rw [EquicontinuousOn, ContinuousOn, equicontinuousWithinAt_iff_continuousWithinAt] theorem uniformEquicontinuous_iff_uniformContinuous {F : ι → β → α} : UniformEquicontinuous F ↔ UniformContinuous (ofFun ∘ Function.swap F : β → ι →ᵤ α) := by rw [UniformContinuous, (UniformFun.hasBasis_uniformity ι α).tendsto_right_iff] rfl #align uniform_equicontinuous_iff_uniform_continuous uniformEquicontinuous_iff_uniformContinuous theorem uniformEquicontinuousOn_iff_uniformContinuousOn {F : ι → β → α} {S : Set β} : UniformEquicontinuousOn F S ↔ UniformContinuousOn (ofFun ∘ Function.swap F : β → ι →ᵤ α) S := by rw [UniformContinuousOn, (UniformFun.hasBasis_uniformity ι α).tendsto_right_iff] rfl theorem equicontinuousWithinAt_iInf_rng {u : κ → UniformSpace α'} {F : ι → X → α'} {S : Set X} {x₀ : X} : EquicontinuousWithinAt (uα := ⨅ k, u k) F S x₀ ↔ ∀ k, EquicontinuousWithinAt (uα := u k) F S x₀ := by simp only [equicontinuousWithinAt_iff_continuousWithinAt (uα := _), topologicalSpace] unfold ContinuousWithinAt rw [UniformFun.iInf_eq, toTopologicalSpace_iInf, nhds_iInf, tendsto_iInf] theorem equicontinuousAt_iInf_rng {u : κ → UniformSpace α'} {F : ι → X → α'} {x₀ : X} : EquicontinuousAt (uα := ⨅ k, u k) F x₀ ↔ ∀ k, EquicontinuousAt (uα := u k) F x₀ := by simp only [← equicontinuousWithinAt_univ (uα := _), equicontinuousWithinAt_iInf_rng] theorem equicontinuous_iInf_rng {u : κ → UniformSpace α'} {F : ι → X → α'} : Equicontinuous (uα := ⨅ k, u k) F ↔ ∀ k, Equicontinuous (uα := u k) F := by simp_rw [equicontinuous_iff_continuous (uα := _), UniformFun.topologicalSpace] rw [UniformFun.iInf_eq, toTopologicalSpace_iInf, continuous_iInf_rng] theorem equicontinuousOn_iInf_rng {u : κ → UniformSpace α'} {F : ι → X → α'} {S : Set X} : EquicontinuousOn (uα := ⨅ k, u k) F S ↔ ∀ k, EquicontinuousOn (uα := u k) F S := by simp_rw [EquicontinuousOn, equicontinuousWithinAt_iInf_rng, @forall_swap _ κ] theorem uniformEquicontinuous_iInf_rng {u : κ → UniformSpace α'} {F : ι → β → α'} : UniformEquicontinuous (uα := ⨅ k, u k) F ↔ ∀ k, UniformEquicontinuous (uα := u k) F := by simp_rw [uniformEquicontinuous_iff_uniformContinuous (uα := _)] rw [UniformFun.iInf_eq, uniformContinuous_iInf_rng] theorem uniformEquicontinuousOn_iInf_rng {u : κ → UniformSpace α'} {F : ι → β → α'} {S : Set β} : UniformEquicontinuousOn (uα := ⨅ k, u k) F S ↔ ∀ k, UniformEquicontinuousOn (uα := u k) F S := by simp_rw [uniformEquicontinuousOn_iff_uniformContinuousOn (uα := _)] unfold UniformContinuousOn rw [UniformFun.iInf_eq, iInf_uniformity, tendsto_iInf] theorem equicontinuousWithinAt_iInf_dom {t : κ → TopologicalSpace X'} {F : ι → X' → α} {S : Set X'} {x₀ : X'} {k : κ} (hk : EquicontinuousWithinAt (tX := t k) F S x₀) : EquicontinuousWithinAt (tX := ⨅ k, t k) F S x₀ := by simp [equicontinuousWithinAt_iff_continuousWithinAt (tX := _)] at hk ⊢ unfold ContinuousWithinAt nhdsWithin at hk ⊢ rw [nhds_iInf] exact hk.mono_left <| inf_le_inf_right _ <| iInf_le _ k
Mathlib/Topology/UniformSpace/Equicontinuity.lean
603
607
theorem equicontinuousAt_iInf_dom {t : κ → TopologicalSpace X'} {F : ι → X' → α} {x₀ : X'} {k : κ} (hk : EquicontinuousAt (tX := t k) F x₀) : EquicontinuousAt (tX := ⨅ k, t k) F x₀ := by
rw [← equicontinuousWithinAt_univ (tX := _)] at hk ⊢ exact equicontinuousWithinAt_iInf_dom hk
import Mathlib.Algebra.Module.BigOperators import Mathlib.Data.Fintype.BigOperators import Mathlib.LinearAlgebra.AffineSpace.AffineMap import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace import Mathlib.LinearAlgebra.Finsupp import Mathlib.Tactic.FinCases #align_import linear_algebra.affine_space.combination from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0" noncomputable section open Affine namespace Finset theorem univ_fin2 : (univ : Finset (Fin 2)) = {0, 1} := by ext x fin_cases x <;> simp #align finset.univ_fin2 Finset.univ_fin2 variable {k : Type*} {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V] variable [S : AffineSpace V P] variable {ι : Type*} (s : Finset ι) variable {ι₂ : Type*} (s₂ : Finset ι₂) def weightedVSubOfPoint (p : ι → P) (b : P) : (ι → k) →ₗ[k] V := ∑ i ∈ s, (LinearMap.proj i : (ι → k) →ₗ[k] k).smulRight (p i -ᵥ b) #align finset.weighted_vsub_of_point Finset.weightedVSubOfPoint @[simp] theorem weightedVSubOfPoint_apply (w : ι → k) (p : ι → P) (b : P) : s.weightedVSubOfPoint p b w = ∑ i ∈ s, w i • (p i -ᵥ b) := by simp [weightedVSubOfPoint, LinearMap.sum_apply] #align finset.weighted_vsub_of_point_apply Finset.weightedVSubOfPoint_apply @[simp (high)] theorem weightedVSubOfPoint_apply_const (w : ι → k) (p : P) (b : P) : s.weightedVSubOfPoint (fun _ => p) b w = (∑ i ∈ s, w i) • (p -ᵥ b) := by rw [weightedVSubOfPoint_apply, sum_smul] #align finset.weighted_vsub_of_point_apply_const Finset.weightedVSubOfPoint_apply_const theorem weightedVSubOfPoint_congr {w₁ w₂ : ι → k} (hw : ∀ i ∈ s, w₁ i = w₂ i) {p₁ p₂ : ι → P} (hp : ∀ i ∈ s, p₁ i = p₂ i) (b : P) : s.weightedVSubOfPoint p₁ b w₁ = s.weightedVSubOfPoint p₂ b w₂ := by simp_rw [weightedVSubOfPoint_apply] refine sum_congr rfl fun i hi => ?_ rw [hw i hi, hp i hi] #align finset.weighted_vsub_of_point_congr Finset.weightedVSubOfPoint_congr theorem weightedVSubOfPoint_eq_of_weights_eq (p : ι → P) (j : ι) (w₁ w₂ : ι → k) (hw : ∀ i, i ≠ j → w₁ i = w₂ i) : s.weightedVSubOfPoint p (p j) w₁ = s.weightedVSubOfPoint p (p j) w₂ := by simp only [Finset.weightedVSubOfPoint_apply] congr ext i rcases eq_or_ne i j with h | h · simp [h] · simp [hw i h] #align finset.weighted_vsub_of_point_eq_of_weights_eq Finset.weightedVSubOfPoint_eq_of_weights_eq theorem weightedVSubOfPoint_eq_of_sum_eq_zero (w : ι → k) (p : ι → P) (h : ∑ i ∈ s, w i = 0) (b₁ b₂ : P) : s.weightedVSubOfPoint p b₁ w = s.weightedVSubOfPoint p b₂ w := by apply eq_of_sub_eq_zero rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← sum_sub_distrib] conv_lhs => congr · skip · ext rw [← smul_sub, vsub_sub_vsub_cancel_left] rw [← sum_smul, h, zero_smul] #align finset.weighted_vsub_of_point_eq_of_sum_eq_zero Finset.weightedVSubOfPoint_eq_of_sum_eq_zero theorem weightedVSubOfPoint_vadd_eq_of_sum_eq_one (w : ι → k) (p : ι → P) (h : ∑ i ∈ s, w i = 1) (b₁ b₂ : P) : s.weightedVSubOfPoint p b₁ w +ᵥ b₁ = s.weightedVSubOfPoint p b₂ w +ᵥ b₂ := by erw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← @vsub_eq_zero_iff_eq V, vadd_vsub_assoc, vsub_vadd_eq_vsub_sub, ← add_sub_assoc, add_comm, add_sub_assoc, ← sum_sub_distrib] conv_lhs => congr · skip · congr · skip · ext rw [← smul_sub, vsub_sub_vsub_cancel_left] rw [← sum_smul, h, one_smul, vsub_add_vsub_cancel, vsub_self] #align finset.weighted_vsub_of_point_vadd_eq_of_sum_eq_one Finset.weightedVSubOfPoint_vadd_eq_of_sum_eq_one @[simp (high)] theorem weightedVSubOfPoint_erase [DecidableEq ι] (w : ι → k) (p : ι → P) (i : ι) : (s.erase i).weightedVSubOfPoint p (p i) w = s.weightedVSubOfPoint p (p i) w := by rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply] apply sum_erase rw [vsub_self, smul_zero] #align finset.weighted_vsub_of_point_erase Finset.weightedVSubOfPoint_erase @[simp (high)] theorem weightedVSubOfPoint_insert [DecidableEq ι] (w : ι → k) (p : ι → P) (i : ι) : (insert i s).weightedVSubOfPoint p (p i) w = s.weightedVSubOfPoint p (p i) w := by rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply] apply sum_insert_zero rw [vsub_self, smul_zero] #align finset.weighted_vsub_of_point_insert Finset.weightedVSubOfPoint_insert theorem weightedVSubOfPoint_indicator_subset (w : ι → k) (p : ι → P) (b : P) {s₁ s₂ : Finset ι} (h : s₁ ⊆ s₂) : s₁.weightedVSubOfPoint p b w = s₂.weightedVSubOfPoint p b (Set.indicator (↑s₁) w) := by rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply] exact Eq.symm <| sum_indicator_subset_of_eq_zero w (fun i wi => wi • (p i -ᵥ b : V)) h fun i => zero_smul k _ #align finset.weighted_vsub_of_point_indicator_subset Finset.weightedVSubOfPoint_indicator_subset theorem weightedVSubOfPoint_map (e : ι₂ ↪ ι) (w : ι → k) (p : ι → P) (b : P) : (s₂.map e).weightedVSubOfPoint p b w = s₂.weightedVSubOfPoint (p ∘ e) b (w ∘ e) := by simp_rw [weightedVSubOfPoint_apply] exact Finset.sum_map _ _ _ #align finset.weighted_vsub_of_point_map Finset.weightedVSubOfPoint_map theorem sum_smul_vsub_eq_weightedVSubOfPoint_sub (w : ι → k) (p₁ p₂ : ι → P) (b : P) : (∑ i ∈ s, w i • (p₁ i -ᵥ p₂ i)) = s.weightedVSubOfPoint p₁ b w - s.weightedVSubOfPoint p₂ b w := by simp_rw [weightedVSubOfPoint_apply, ← sum_sub_distrib, ← smul_sub, vsub_sub_vsub_cancel_right] #align finset.sum_smul_vsub_eq_weighted_vsub_of_point_sub Finset.sum_smul_vsub_eq_weightedVSubOfPoint_sub theorem sum_smul_vsub_const_eq_weightedVSubOfPoint_sub (w : ι → k) (p₁ : ι → P) (p₂ b : P) : (∑ i ∈ s, w i • (p₁ i -ᵥ p₂)) = s.weightedVSubOfPoint p₁ b w - (∑ i ∈ s, w i) • (p₂ -ᵥ b) := by rw [sum_smul_vsub_eq_weightedVSubOfPoint_sub, weightedVSubOfPoint_apply_const] #align finset.sum_smul_vsub_const_eq_weighted_vsub_of_point_sub Finset.sum_smul_vsub_const_eq_weightedVSubOfPoint_sub theorem sum_smul_const_vsub_eq_sub_weightedVSubOfPoint (w : ι → k) (p₂ : ι → P) (p₁ b : P) : (∑ i ∈ s, w i • (p₁ -ᵥ p₂ i)) = (∑ i ∈ s, w i) • (p₁ -ᵥ b) - s.weightedVSubOfPoint p₂ b w := by rw [sum_smul_vsub_eq_weightedVSubOfPoint_sub, weightedVSubOfPoint_apply_const] #align finset.sum_smul_const_vsub_eq_sub_weighted_vsub_of_point Finset.sum_smul_const_vsub_eq_sub_weightedVSubOfPoint theorem weightedVSubOfPoint_sdiff [DecidableEq ι] {s₂ : Finset ι} (h : s₂ ⊆ s) (w : ι → k) (p : ι → P) (b : P) : (s \ s₂).weightedVSubOfPoint p b w + s₂.weightedVSubOfPoint p b w = s.weightedVSubOfPoint p b w := by simp_rw [weightedVSubOfPoint_apply, sum_sdiff h] #align finset.weighted_vsub_of_point_sdiff Finset.weightedVSubOfPoint_sdiff theorem weightedVSubOfPoint_sdiff_sub [DecidableEq ι] {s₂ : Finset ι} (h : s₂ ⊆ s) (w : ι → k) (p : ι → P) (b : P) : (s \ s₂).weightedVSubOfPoint p b w - s₂.weightedVSubOfPoint p b (-w) = s.weightedVSubOfPoint p b w := by rw [map_neg, sub_neg_eq_add, s.weightedVSubOfPoint_sdiff h] #align finset.weighted_vsub_of_point_sdiff_sub Finset.weightedVSubOfPoint_sdiff_sub theorem weightedVSubOfPoint_subtype_eq_filter (w : ι → k) (p : ι → P) (b : P) (pred : ι → Prop) [DecidablePred pred] : ((s.subtype pred).weightedVSubOfPoint (fun i => p i) b fun i => w i) = (s.filter pred).weightedVSubOfPoint p b w := by rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← sum_subtype_eq_sum_filter] #align finset.weighted_vsub_of_point_subtype_eq_filter Finset.weightedVSubOfPoint_subtype_eq_filter theorem weightedVSubOfPoint_filter_of_ne (w : ι → k) (p : ι → P) (b : P) {pred : ι → Prop} [DecidablePred pred] (h : ∀ i ∈ s, w i ≠ 0 → pred i) : (s.filter pred).weightedVSubOfPoint p b w = s.weightedVSubOfPoint p b w := by rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, sum_filter_of_ne] intro i hi hne refine h i hi ?_ intro hw simp [hw] at hne #align finset.weighted_vsub_of_point_filter_of_ne Finset.weightedVSubOfPoint_filter_of_ne theorem weightedVSubOfPoint_const_smul (w : ι → k) (p : ι → P) (b : P) (c : k) : s.weightedVSubOfPoint p b (c • w) = c • s.weightedVSubOfPoint p b w := by simp_rw [weightedVSubOfPoint_apply, smul_sum, Pi.smul_apply, smul_smul, smul_eq_mul] #align finset.weighted_vsub_of_point_const_smul Finset.weightedVSubOfPoint_const_smul def weightedVSub (p : ι → P) : (ι → k) →ₗ[k] V := s.weightedVSubOfPoint p (Classical.choice S.nonempty) #align finset.weighted_vsub Finset.weightedVSub theorem weightedVSub_apply (w : ι → k) (p : ι → P) : s.weightedVSub p w = ∑ i ∈ s, w i • (p i -ᵥ Classical.choice S.nonempty) := by simp [weightedVSub, LinearMap.sum_apply] #align finset.weighted_vsub_apply Finset.weightedVSub_apply theorem weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero (w : ι → k) (p : ι → P) (h : ∑ i ∈ s, w i = 0) (b : P) : s.weightedVSub p w = s.weightedVSubOfPoint p b w := s.weightedVSubOfPoint_eq_of_sum_eq_zero w p h _ _ #align finset.weighted_vsub_eq_weighted_vsub_of_point_of_sum_eq_zero Finset.weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero @[simp] theorem weightedVSub_apply_const (w : ι → k) (p : P) (h : ∑ i ∈ s, w i = 0) : s.weightedVSub (fun _ => p) w = 0 := by rw [weightedVSub, weightedVSubOfPoint_apply_const, h, zero_smul] #align finset.weighted_vsub_apply_const Finset.weightedVSub_apply_const @[simp] theorem weightedVSub_empty (w : ι → k) (p : ι → P) : (∅ : Finset ι).weightedVSub p w = (0 : V) := by simp [weightedVSub_apply] #align finset.weighted_vsub_empty Finset.weightedVSub_empty theorem weightedVSub_congr {w₁ w₂ : ι → k} (hw : ∀ i ∈ s, w₁ i = w₂ i) {p₁ p₂ : ι → P} (hp : ∀ i ∈ s, p₁ i = p₂ i) : s.weightedVSub p₁ w₁ = s.weightedVSub p₂ w₂ := s.weightedVSubOfPoint_congr hw hp _ #align finset.weighted_vsub_congr Finset.weightedVSub_congr theorem weightedVSub_indicator_subset (w : ι → k) (p : ι → P) {s₁ s₂ : Finset ι} (h : s₁ ⊆ s₂) : s₁.weightedVSub p w = s₂.weightedVSub p (Set.indicator (↑s₁) w) := weightedVSubOfPoint_indicator_subset _ _ _ h #align finset.weighted_vsub_indicator_subset Finset.weightedVSub_indicator_subset theorem weightedVSub_map (e : ι₂ ↪ ι) (w : ι → k) (p : ι → P) : (s₂.map e).weightedVSub p w = s₂.weightedVSub (p ∘ e) (w ∘ e) := s₂.weightedVSubOfPoint_map _ _ _ _ #align finset.weighted_vsub_map Finset.weightedVSub_map theorem sum_smul_vsub_eq_weightedVSub_sub (w : ι → k) (p₁ p₂ : ι → P) : (∑ i ∈ s, w i • (p₁ i -ᵥ p₂ i)) = s.weightedVSub p₁ w - s.weightedVSub p₂ w := s.sum_smul_vsub_eq_weightedVSubOfPoint_sub _ _ _ _ #align finset.sum_smul_vsub_eq_weighted_vsub_sub Finset.sum_smul_vsub_eq_weightedVSub_sub theorem sum_smul_vsub_const_eq_weightedVSub (w : ι → k) (p₁ : ι → P) (p₂ : P) (h : ∑ i ∈ s, w i = 0) : (∑ i ∈ s, w i • (p₁ i -ᵥ p₂)) = s.weightedVSub p₁ w := by rw [sum_smul_vsub_eq_weightedVSub_sub, s.weightedVSub_apply_const _ _ h, sub_zero] #align finset.sum_smul_vsub_const_eq_weighted_vsub Finset.sum_smul_vsub_const_eq_weightedVSub theorem sum_smul_const_vsub_eq_neg_weightedVSub (w : ι → k) (p₂ : ι → P) (p₁ : P) (h : ∑ i ∈ s, w i = 0) : (∑ i ∈ s, w i • (p₁ -ᵥ p₂ i)) = -s.weightedVSub p₂ w := by rw [sum_smul_vsub_eq_weightedVSub_sub, s.weightedVSub_apply_const _ _ h, zero_sub] #align finset.sum_smul_const_vsub_eq_neg_weighted_vsub Finset.sum_smul_const_vsub_eq_neg_weightedVSub theorem weightedVSub_sdiff [DecidableEq ι] {s₂ : Finset ι} (h : s₂ ⊆ s) (w : ι → k) (p : ι → P) : (s \ s₂).weightedVSub p w + s₂.weightedVSub p w = s.weightedVSub p w := s.weightedVSubOfPoint_sdiff h _ _ _ #align finset.weighted_vsub_sdiff Finset.weightedVSub_sdiff theorem weightedVSub_sdiff_sub [DecidableEq ι] {s₂ : Finset ι} (h : s₂ ⊆ s) (w : ι → k) (p : ι → P) : (s \ s₂).weightedVSub p w - s₂.weightedVSub p (-w) = s.weightedVSub p w := s.weightedVSubOfPoint_sdiff_sub h _ _ _ #align finset.weighted_vsub_sdiff_sub Finset.weightedVSub_sdiff_sub theorem weightedVSub_subtype_eq_filter (w : ι → k) (p : ι → P) (pred : ι → Prop) [DecidablePred pred] : ((s.subtype pred).weightedVSub (fun i => p i) fun i => w i) = (s.filter pred).weightedVSub p w := s.weightedVSubOfPoint_subtype_eq_filter _ _ _ _ #align finset.weighted_vsub_subtype_eq_filter Finset.weightedVSub_subtype_eq_filter theorem weightedVSub_filter_of_ne (w : ι → k) (p : ι → P) {pred : ι → Prop} [DecidablePred pred] (h : ∀ i ∈ s, w i ≠ 0 → pred i) : (s.filter pred).weightedVSub p w = s.weightedVSub p w := s.weightedVSubOfPoint_filter_of_ne _ _ _ h #align finset.weighted_vsub_filter_of_ne Finset.weightedVSub_filter_of_ne theorem weightedVSub_const_smul (w : ι → k) (p : ι → P) (c : k) : s.weightedVSub p (c • w) = c • s.weightedVSub p w := s.weightedVSubOfPoint_const_smul _ _ _ _ #align finset.weighted_vsub_const_smul Finset.weightedVSub_const_smul instance : AffineSpace (ι → k) (ι → k) := Pi.instAddTorsor variable (k) def affineCombination (p : ι → P) : (ι → k) →ᵃ[k] P where toFun w := s.weightedVSubOfPoint p (Classical.choice S.nonempty) w +ᵥ Classical.choice S.nonempty linear := s.weightedVSub p map_vadd' w₁ w₂ := by simp_rw [vadd_vadd, weightedVSub, vadd_eq_add, LinearMap.map_add] #align finset.affine_combination Finset.affineCombination @[simp] theorem affineCombination_linear (p : ι → P) : (s.affineCombination k p).linear = s.weightedVSub p := rfl #align finset.affine_combination_linear Finset.affineCombination_linear variable {k} theorem affineCombination_apply (w : ι → k) (p : ι → P) : (s.affineCombination k p) w = s.weightedVSubOfPoint p (Classical.choice S.nonempty) w +ᵥ Classical.choice S.nonempty := rfl #align finset.affine_combination_apply Finset.affineCombination_apply @[simp] theorem affineCombination_apply_const (w : ι → k) (p : P) (h : ∑ i ∈ s, w i = 1) : s.affineCombination k (fun _ => p) w = p := by rw [affineCombination_apply, s.weightedVSubOfPoint_apply_const, h, one_smul, vsub_vadd] #align finset.affine_combination_apply_const Finset.affineCombination_apply_const theorem affineCombination_congr {w₁ w₂ : ι → k} (hw : ∀ i ∈ s, w₁ i = w₂ i) {p₁ p₂ : ι → P} (hp : ∀ i ∈ s, p₁ i = p₂ i) : s.affineCombination k p₁ w₁ = s.affineCombination k p₂ w₂ := by simp_rw [affineCombination_apply, s.weightedVSubOfPoint_congr hw hp] #align finset.affine_combination_congr Finset.affineCombination_congr theorem affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one (w : ι → k) (p : ι → P) (h : ∑ i ∈ s, w i = 1) (b : P) : s.affineCombination k p w = s.weightedVSubOfPoint p b w +ᵥ b := s.weightedVSubOfPoint_vadd_eq_of_sum_eq_one w p h _ _ #align finset.affine_combination_eq_weighted_vsub_of_point_vadd_of_sum_eq_one Finset.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one theorem weightedVSub_vadd_affineCombination (w₁ w₂ : ι → k) (p : ι → P) : s.weightedVSub p w₁ +ᵥ s.affineCombination k p w₂ = s.affineCombination k p (w₁ + w₂) := by rw [← vadd_eq_add, AffineMap.map_vadd, affineCombination_linear] #align finset.weighted_vsub_vadd_affine_combination Finset.weightedVSub_vadd_affineCombination theorem affineCombination_vsub (w₁ w₂ : ι → k) (p : ι → P) : s.affineCombination k p w₁ -ᵥ s.affineCombination k p w₂ = s.weightedVSub p (w₁ - w₂) := by rw [← AffineMap.linearMap_vsub, affineCombination_linear, vsub_eq_sub] #align finset.affine_combination_vsub Finset.affineCombination_vsub theorem attach_affineCombination_of_injective [DecidableEq P] (s : Finset P) (w : P → k) (f : s → P) (hf : Function.Injective f) : s.attach.affineCombination k f (w ∘ f) = (image f univ).affineCombination k id w := by simp only [affineCombination, weightedVSubOfPoint_apply, id, vadd_right_cancel_iff, Function.comp_apply, AffineMap.coe_mk] let g₁ : s → V := fun i => w (f i) • (f i -ᵥ Classical.choice S.nonempty) let g₂ : P → V := fun i => w i • (i -ᵥ Classical.choice S.nonempty) change univ.sum g₁ = (image f univ).sum g₂ have hgf : g₁ = g₂ ∘ f := by ext simp rw [hgf, sum_image] · simp only [Function.comp_apply] · exact fun _ _ _ _ hxy => hf hxy #align finset.attach_affine_combination_of_injective Finset.attach_affineCombination_of_injective theorem attach_affineCombination_coe (s : Finset P) (w : P → k) : s.attach.affineCombination k ((↑) : s → P) (w ∘ (↑)) = s.affineCombination k id w := by classical rw [attach_affineCombination_of_injective s w ((↑) : s → P) Subtype.coe_injective, univ_eq_attach, attach_image_val] #align finset.attach_affine_combination_coe Finset.attach_affineCombination_coe @[simp] theorem weightedVSub_eq_linear_combination {ι} (s : Finset ι) {w : ι → k} {p : ι → V} (hw : s.sum w = 0) : s.weightedVSub p w = ∑ i ∈ s, w i • p i := by simp [s.weightedVSub_apply, vsub_eq_sub, smul_sub, ← Finset.sum_smul, hw] #align finset.weighted_vsub_eq_linear_combination Finset.weightedVSub_eq_linear_combination @[simp] theorem affineCombination_eq_linear_combination (s : Finset ι) (p : ι → V) (w : ι → k) (hw : ∑ i ∈ s, w i = 1) : s.affineCombination k p w = ∑ i ∈ s, w i • p i := by simp [s.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one w p hw 0] #align finset.affine_combination_eq_linear_combination Finset.affineCombination_eq_linear_combination @[simp] theorem affineCombination_of_eq_one_of_eq_zero (w : ι → k) (p : ι → P) {i : ι} (his : i ∈ s) (hwi : w i = 1) (hw0 : ∀ i2 ∈ s, i2 ≠ i → w i2 = 0) : s.affineCombination k p w = p i := by have h1 : ∑ i ∈ s, w i = 1 := hwi ▸ sum_eq_single i hw0 fun h => False.elim (h his) rw [s.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one w p h1 (p i), weightedVSubOfPoint_apply] convert zero_vadd V (p i) refine sum_eq_zero ?_ intro i2 hi2 by_cases h : i2 = i · simp [h] · simp [hw0 i2 hi2 h] #align finset.affine_combination_of_eq_one_of_eq_zero Finset.affineCombination_of_eq_one_of_eq_zero theorem affineCombination_indicator_subset (w : ι → k) (p : ι → P) {s₁ s₂ : Finset ι} (h : s₁ ⊆ s₂) : s₁.affineCombination k p w = s₂.affineCombination k p (Set.indicator (↑s₁) w) := by rw [affineCombination_apply, affineCombination_apply, weightedVSubOfPoint_indicator_subset _ _ _ h] #align finset.affine_combination_indicator_subset Finset.affineCombination_indicator_subset theorem affineCombination_map (e : ι₂ ↪ ι) (w : ι → k) (p : ι → P) : (s₂.map e).affineCombination k p w = s₂.affineCombination k (p ∘ e) (w ∘ e) := by simp_rw [affineCombination_apply, weightedVSubOfPoint_map] #align finset.affine_combination_map Finset.affineCombination_map theorem sum_smul_vsub_eq_affineCombination_vsub (w : ι → k) (p₁ p₂ : ι → P) : (∑ i ∈ s, w i • (p₁ i -ᵥ p₂ i)) = s.affineCombination k p₁ w -ᵥ s.affineCombination k p₂ w := by simp_rw [affineCombination_apply, vadd_vsub_vadd_cancel_right] exact s.sum_smul_vsub_eq_weightedVSubOfPoint_sub _ _ _ _ #align finset.sum_smul_vsub_eq_affine_combination_vsub Finset.sum_smul_vsub_eq_affineCombination_vsub
Mathlib/LinearAlgebra/AffineSpace/Combination.lean
513
515
theorem sum_smul_vsub_const_eq_affineCombination_vsub (w : ι → k) (p₁ : ι → P) (p₂ : P) (h : ∑ i ∈ s, w i = 1) : (∑ i ∈ s, w i • (p₁ i -ᵥ p₂)) = s.affineCombination k p₁ w -ᵥ p₂ := by
rw [sum_smul_vsub_eq_affineCombination_vsub, affineCombination_apply_const _ _ _ h]
import Mathlib.SetTheory.Game.Ordinal import Mathlib.SetTheory.Ordinal.NaturalOps #align_import set_theory.game.birthday from "leanprover-community/mathlib"@"a347076985674932c0e91da09b9961ed0a79508c" universe u open Ordinal namespace SetTheory open scoped NaturalOps PGame namespace PGame noncomputable def birthday : PGame.{u} → Ordinal.{u} | ⟨_, _, xL, xR⟩ => max (lsub.{u, u} fun i => birthday (xL i)) (lsub.{u, u} fun i => birthday (xR i)) #align pgame.birthday SetTheory.PGame.birthday theorem birthday_def (x : PGame) : birthday x = max (lsub.{u, u} fun i => birthday (x.moveLeft i)) (lsub.{u, u} fun i => birthday (x.moveRight i)) := by cases x; rw [birthday]; rfl #align pgame.birthday_def SetTheory.PGame.birthday_def
Mathlib/SetTheory/Game/Birthday.lean
54
56
theorem birthday_moveLeft_lt {x : PGame} (i : x.LeftMoves) : (x.moveLeft i).birthday < x.birthday := by
cases x; rw [birthday]; exact lt_max_of_lt_left (lt_lsub _ i)
import Mathlib.Analysis.Calculus.FDeriv.Analytic import Mathlib.Analysis.Asymptotics.SpecificAsymptotics import Mathlib.Analysis.Complex.CauchyIntegral #align_import analysis.complex.removable_singularity from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open TopologicalSpace Metric Set Filter Asymptotics Function open scoped Topology Filter NNReal Real universe u variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℂ E] [CompleteSpace E] namespace Complex theorem analyticAt_of_differentiable_on_punctured_nhds_of_continuousAt {f : ℂ → E} {c : ℂ} (hd : ∀ᶠ z in 𝓝[≠] c, DifferentiableAt ℂ f z) (hc : ContinuousAt f c) : AnalyticAt ℂ f c := by rcases (nhdsWithin_hasBasis nhds_basis_closedBall _).mem_iff.1 hd with ⟨R, hR0, hRs⟩ lift R to ℝ≥0 using hR0.le replace hc : ContinuousOn f (closedBall c R) := by refine fun z hz => ContinuousAt.continuousWithinAt ?_ rcases eq_or_ne z c with (rfl | hne) exacts [hc, (hRs ⟨hz, hne⟩).continuousAt] exact (hasFPowerSeriesOnBall_of_differentiable_off_countable (countable_singleton c) hc (fun z hz => hRs (diff_subset_diff_left ball_subset_closedBall hz)) hR0).analyticAt #align complex.analytic_at_of_differentiable_on_punctured_nhds_of_continuous_at Complex.analyticAt_of_differentiable_on_punctured_nhds_of_continuousAt theorem differentiableOn_compl_singleton_and_continuousAt_iff {f : ℂ → E} {s : Set ℂ} {c : ℂ} (hs : s ∈ 𝓝 c) : DifferentiableOn ℂ f (s \ {c}) ∧ ContinuousAt f c ↔ DifferentiableOn ℂ f s := by refine ⟨?_, fun hd => ⟨hd.mono diff_subset, (hd.differentiableAt hs).continuousAt⟩⟩ rintro ⟨hd, hc⟩ x hx rcases eq_or_ne x c with (rfl | hne) · refine (analyticAt_of_differentiable_on_punctured_nhds_of_continuousAt ?_ hc).differentiableAt.differentiableWithinAt refine eventually_nhdsWithin_iff.2 ((eventually_mem_nhds.2 hs).mono fun z hz hzx => ?_) exact hd.differentiableAt (inter_mem hz (isOpen_ne.mem_nhds hzx)) · simpa only [DifferentiableWithinAt, HasFDerivWithinAt, hne.nhdsWithin_diff_singleton] using hd x ⟨hx, hne⟩ #align complex.differentiable_on_compl_singleton_and_continuous_at_iff Complex.differentiableOn_compl_singleton_and_continuousAt_iff theorem differentiableOn_dslope {f : ℂ → E} {s : Set ℂ} {c : ℂ} (hc : s ∈ 𝓝 c) : DifferentiableOn ℂ (dslope f c) s ↔ DifferentiableOn ℂ f s := ⟨fun h => h.of_dslope, fun h => (differentiableOn_compl_singleton_and_continuousAt_iff hc).mp <| ⟨Iff.mpr (differentiableOn_dslope_of_nmem fun h => h.2 rfl) (h.mono diff_subset), continuousAt_dslope_same.2 <| h.differentiableAt hc⟩⟩ #align complex.differentiable_on_dslope Complex.differentiableOn_dslope
Mathlib/Analysis/Complex/RemovableSingularity.lean
71
87
theorem differentiableOn_update_limUnder_of_isLittleO {f : ℂ → E} {s : Set ℂ} {c : ℂ} (hc : s ∈ 𝓝 c) (hd : DifferentiableOn ℂ f (s \ {c})) (ho : (fun z => f z - f c) =o[𝓝[≠] c] fun z => (z - c)⁻¹) : DifferentiableOn ℂ (update f c (limUnder (𝓝[≠] c) f)) s := by
set F : ℂ → E := fun z => (z - c) • f z suffices DifferentiableOn ℂ F (s \ {c}) ∧ ContinuousAt F c by rw [differentiableOn_compl_singleton_and_continuousAt_iff hc, ← differentiableOn_dslope hc, dslope_sub_smul] at this have hc : Tendsto f (𝓝[≠] c) (𝓝 (deriv F c)) := continuousAt_update_same.mp (this.continuousOn.continuousAt hc) rwa [hc.limUnder_eq] refine ⟨(differentiableOn_id.sub_const _).smul hd, ?_⟩ rw [← continuousWithinAt_compl_self] have H := ho.tendsto_inv_smul_nhds_zero have H' : Tendsto (fun z => (z - c) • f c) (𝓝[≠] c) (𝓝 (F c)) := (continuousWithinAt_id.tendsto.sub tendsto_const_nhds).smul tendsto_const_nhds simpa [← smul_add, ContinuousWithinAt] using H.add H'
import Mathlib.Analysis.Normed.Group.InfiniteSum import Mathlib.Analysis.Normed.MulAction import Mathlib.Topology.Algebra.Order.LiminfLimsup import Mathlib.Topology.PartialHomeomorph #align_import analysis.asymptotics.asymptotics from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open Filter Set open scoped Classical open Topology Filter NNReal namespace Asymptotics set_option linter.uppercaseLean3 false variable {α : Type*} {β : Type*} {E : Type*} {F : Type*} {G : Type*} {E' : Type*} {F' : Type*} {G' : Type*} {E'' : Type*} {F'' : Type*} {G'' : Type*} {E''' : Type*} {R : Type*} {R' : Type*} {𝕜 : Type*} {𝕜' : Type*} variable [Norm E] [Norm F] [Norm G] variable [SeminormedAddCommGroup E'] [SeminormedAddCommGroup F'] [SeminormedAddCommGroup G'] [NormedAddCommGroup E''] [NormedAddCommGroup F''] [NormedAddCommGroup G''] [SeminormedRing R] [SeminormedAddGroup E'''] [SeminormedRing R'] variable [NormedDivisionRing 𝕜] [NormedDivisionRing 𝕜'] variable {c c' c₁ c₂ : ℝ} {f : α → E} {g : α → F} {k : α → G} variable {f' : α → E'} {g' : α → F'} {k' : α → G'} variable {f'' : α → E''} {g'' : α → F''} {k'' : α → G''} variable {l l' : Filter α} section Defs irreducible_def IsBigOWith (c : ℝ) (l : Filter α) (f : α → E) (g : α → F) : Prop := ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ #align asymptotics.is_O_with Asymptotics.IsBigOWith theorem isBigOWith_iff : IsBigOWith c l f g ↔ ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := by rw [IsBigOWith_def] #align asymptotics.is_O_with_iff Asymptotics.isBigOWith_iff alias ⟨IsBigOWith.bound, IsBigOWith.of_bound⟩ := isBigOWith_iff #align asymptotics.is_O_with.bound Asymptotics.IsBigOWith.bound #align asymptotics.is_O_with.of_bound Asymptotics.IsBigOWith.of_bound irreducible_def IsBigO (l : Filter α) (f : α → E) (g : α → F) : Prop := ∃ c : ℝ, IsBigOWith c l f g #align asymptotics.is_O Asymptotics.IsBigO @[inherit_doc] notation:100 f " =O[" l "] " g:100 => IsBigO l f g
Mathlib/Analysis/Asymptotics/Asymptotics.lean
109
109
theorem isBigO_iff_isBigOWith : f =O[l] g ↔ ∃ c : ℝ, IsBigOWith c l f g := by
rw [IsBigO_def]
import Mathlib.Analysis.Calculus.Deriv.Inv import Mathlib.Analysis.NormedSpace.BallAction import Mathlib.Analysis.SpecialFunctions.ExpDeriv import Mathlib.Analysis.InnerProductSpace.Calculus import Mathlib.Analysis.InnerProductSpace.PiL2 import Mathlib.Geometry.Manifold.Algebra.LieGroup import Mathlib.Geometry.Manifold.Instances.Real import Mathlib.Geometry.Manifold.MFDeriv.Basic #align_import geometry.manifold.instances.sphere from "leanprover-community/mathlib"@"0dc4079202c28226b2841a51eb6d3cc2135bb80f" variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] noncomputable section open Metric FiniteDimensional Function open scoped Manifold section StereographicProjection variable (v : E) def stereoToFun (x : E) : (ℝ ∙ v)ᗮ := (2 / ((1 : ℝ) - innerSL ℝ v x)) • orthogonalProjection (ℝ ∙ v)ᗮ x #align stereo_to_fun stereoToFun variable {v} @[simp] theorem stereoToFun_apply (x : E) : stereoToFun v x = (2 / ((1 : ℝ) - innerSL ℝ v x)) • orthogonalProjection (ℝ ∙ v)ᗮ x := rfl #align stereo_to_fun_apply stereoToFun_apply theorem contDiffOn_stereoToFun : ContDiffOn ℝ ⊤ (stereoToFun v) {x : E | innerSL _ v x ≠ (1 : ℝ)} := by refine ContDiffOn.smul ?_ (orthogonalProjection (ℝ ∙ v)ᗮ).contDiff.contDiffOn refine contDiff_const.contDiffOn.div ?_ ?_ · exact (contDiff_const.sub (innerSL ℝ v).contDiff).contDiffOn · intro x h h' exact h (sub_eq_zero.mp h').symm #align cont_diff_on_stereo_to_fun contDiffOn_stereoToFun theorem continuousOn_stereoToFun : ContinuousOn (stereoToFun v) {x : E | innerSL _ v x ≠ (1 : ℝ)} := contDiffOn_stereoToFun.continuousOn #align continuous_on_stereo_to_fun continuousOn_stereoToFun variable (v) def stereoInvFunAux (w : E) : E := (‖w‖ ^ 2 + 4)⁻¹ • ((4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v) #align stereo_inv_fun_aux stereoInvFunAux variable {v} @[simp] theorem stereoInvFunAux_apply (w : E) : stereoInvFunAux v w = (‖w‖ ^ 2 + 4)⁻¹ • ((4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v) := rfl #align stereo_inv_fun_aux_apply stereoInvFunAux_apply theorem stereoInvFunAux_mem (hv : ‖v‖ = 1) {w : E} (hw : w ∈ (ℝ ∙ v)ᗮ) : stereoInvFunAux v w ∈ sphere (0 : E) 1 := by have h₁ : (0 : ℝ) < ‖w‖ ^ 2 + 4 := by positivity suffices ‖(4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v‖ = ‖w‖ ^ 2 + 4 by simp only [mem_sphere_zero_iff_norm, norm_smul, Real.norm_eq_abs, abs_inv, this, abs_of_pos h₁, stereoInvFunAux_apply, inv_mul_cancel h₁.ne'] suffices ‖(4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v‖ ^ 2 = (‖w‖ ^ 2 + 4) ^ 2 by simpa [sq_eq_sq_iff_abs_eq_abs, abs_of_pos h₁] using this rw [Submodule.mem_orthogonal_singleton_iff_inner_left] at hw simp [norm_add_sq_real, norm_smul, inner_smul_left, inner_smul_right, hw, mul_pow, Real.norm_eq_abs, hv] ring #align stereo_inv_fun_aux_mem stereoInvFunAux_mem theorem hasFDerivAt_stereoInvFunAux (v : E) : HasFDerivAt (stereoInvFunAux v) (ContinuousLinearMap.id ℝ E) 0 := by have h₀ : HasFDerivAt (fun w : E => ‖w‖ ^ 2) (0 : E →L[ℝ] ℝ) 0 := by convert (hasStrictFDerivAt_norm_sq (0 : E)).hasFDerivAt simp have h₁ : HasFDerivAt (fun w : E => (‖w‖ ^ 2 + 4)⁻¹) (0 : E →L[ℝ] ℝ) 0 := by convert (hasFDerivAt_inv _).comp _ (h₀.add (hasFDerivAt_const 4 0)) <;> simp have h₂ : HasFDerivAt (fun w => (4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v) ((4 : ℝ) • ContinuousLinearMap.id ℝ E) 0 := by convert ((hasFDerivAt_const (4 : ℝ) 0).smul (hasFDerivAt_id 0)).add ((h₀.sub (hasFDerivAt_const (4 : ℝ) 0)).smul (hasFDerivAt_const v 0)) using 1 ext w simp convert h₁.smul h₂ using 1 ext w simp #align has_fderiv_at_stereo_inv_fun_aux hasFDerivAt_stereoInvFunAux theorem hasFDerivAt_stereoInvFunAux_comp_coe (v : E) : HasFDerivAt (stereoInvFunAux v ∘ ((↑) : (ℝ ∙ v)ᗮ → E)) (ℝ ∙ v)ᗮ.subtypeL 0 := by have : HasFDerivAt (stereoInvFunAux v) (ContinuousLinearMap.id ℝ E) ((ℝ ∙ v)ᗮ.subtypeL 0) := hasFDerivAt_stereoInvFunAux v convert this.comp (0 : (ℝ ∙ v)ᗮ) (by apply ContinuousLinearMap.hasFDerivAt) #align has_fderiv_at_stereo_inv_fun_aux_comp_coe hasFDerivAt_stereoInvFunAux_comp_coe theorem contDiff_stereoInvFunAux : ContDiff ℝ ⊤ (stereoInvFunAux v) := by have h₀ : ContDiff ℝ ⊤ fun w : E => ‖w‖ ^ 2 := contDiff_norm_sq ℝ have h₁ : ContDiff ℝ ⊤ fun w : E => (‖w‖ ^ 2 + 4)⁻¹ := by refine (h₀.add contDiff_const).inv ?_ intro x nlinarith have h₂ : ContDiff ℝ ⊤ fun w => (4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v := by refine (contDiff_const.smul contDiff_id).add ?_ exact (h₀.sub contDiff_const).smul contDiff_const exact h₁.smul h₂ #align cont_diff_stereo_inv_fun_aux contDiff_stereoInvFunAux def stereoInvFun (hv : ‖v‖ = 1) (w : (ℝ ∙ v)ᗮ) : sphere (0 : E) 1 := ⟨stereoInvFunAux v (w : E), stereoInvFunAux_mem hv w.2⟩ #align stereo_inv_fun stereoInvFun @[simp] theorem stereoInvFun_apply (hv : ‖v‖ = 1) (w : (ℝ ∙ v)ᗮ) : (stereoInvFun hv w : E) = (‖w‖ ^ 2 + 4)⁻¹ • ((4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v) := rfl #align stereo_inv_fun_apply stereoInvFun_apply theorem stereoInvFun_ne_north_pole (hv : ‖v‖ = 1) (w : (ℝ ∙ v)ᗮ) : stereoInvFun hv w ≠ (⟨v, by simp [hv]⟩ : sphere (0 : E) 1) := by refine Subtype.coe_ne_coe.1 ?_ rw [← inner_lt_one_iff_real_of_norm_one _ hv] · have hw : ⟪v, w⟫_ℝ = 0 := Submodule.mem_orthogonal_singleton_iff_inner_right.mp w.2 have hw' : (‖(w : E)‖ ^ 2 + 4)⁻¹ * (‖(w : E)‖ ^ 2 - 4) < 1 := by refine (inv_mul_lt_iff' ?_).mpr ?_ · nlinarith linarith simpa [real_inner_comm, inner_add_right, inner_smul_right, real_inner_self_eq_norm_mul_norm, hw, hv] using hw' · simpa using stereoInvFunAux_mem hv w.2 #align stereo_inv_fun_ne_north_pole stereoInvFun_ne_north_pole theorem continuous_stereoInvFun (hv : ‖v‖ = 1) : Continuous (stereoInvFun hv) := continuous_induced_rng.2 (contDiff_stereoInvFunAux.continuous.comp continuous_subtype_val) #align continuous_stereo_inv_fun continuous_stereoInvFun theorem stereo_left_inv (hv : ‖v‖ = 1) {x : sphere (0 : E) 1} (hx : (x : E) ≠ v) : stereoInvFun hv (stereoToFun v x) = x := by ext simp only [stereoToFun_apply, stereoInvFun_apply, smul_add] -- name two frequently-occuring quantities and write down their basic properties set a : ℝ := innerSL _ v x set y := orthogonalProjection (ℝ ∙ v)ᗮ x have split : ↑x = a • v + ↑y := by convert (orthogonalProjection_add_orthogonalProjection_orthogonal (ℝ ∙ v) x).symm exact (orthogonalProjection_unit_singleton ℝ hv x).symm have hvy : ⟪v, y⟫_ℝ = 0 := Submodule.mem_orthogonal_singleton_iff_inner_right.mp y.2 have pythag : 1 = a ^ 2 + ‖y‖ ^ 2 := by have hvy' : ⟪a • v, y⟫_ℝ = 0 := by simp only [inner_smul_left, hvy, mul_zero] convert norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero _ _ hvy' using 2 · simp [← split] · simp [norm_smul, hv, ← sq, sq_abs] · exact sq _ -- two facts which will be helpful for clearing denominators in the main calculation have ha : 1 - a ≠ 0 := by have : a < 1 := (inner_lt_one_iff_real_of_norm_one hv (by simp)).mpr hx.symm linarith -- the core of the problem is these two algebraic identities: have h₁ : (2 ^ 2 / (1 - a) ^ 2 * ‖y‖ ^ 2 + 4)⁻¹ * 4 * (2 / (1 - a)) = 1 := by field_simp; simp only [Submodule.coe_norm] at *; nlinarith have h₂ : (2 ^ 2 / (1 - a) ^ 2 * ‖y‖ ^ 2 + 4)⁻¹ * (2 ^ 2 / (1 - a) ^ 2 * ‖y‖ ^ 2 - 4) = a := by field_simp transitivity (1 - a) ^ 2 * (a * (2 ^ 2 * ‖y‖ ^ 2 + 4 * (1 - a) ^ 2)) · congr simp only [Submodule.coe_norm] at * nlinarith ring! convert congr_arg₂ Add.add (congr_arg (fun t => t • (y : E)) h₁) (congr_arg (fun t => t • v) h₂) using 1 · simp [a, inner_add_right, inner_smul_right, hvy, real_inner_self_eq_norm_mul_norm, hv, mul_smul, mul_pow, Real.norm_eq_abs, sq_abs, norm_smul] -- Porting note: used to be simp only [split, add_comm] but get maxRec errors rw [split, add_comm] ac_rfl -- Porting note: this branch did not exit in ml3 · rw [split, add_comm] congr! dsimp rw [one_smul] #align stereo_left_inv stereo_left_inv theorem stereo_right_inv (hv : ‖v‖ = 1) (w : (ℝ ∙ v)ᗮ) : stereoToFun v (stereoInvFun hv w) = w := by have : 2 / (1 - (‖(w : E)‖ ^ 2 + 4)⁻¹ * (‖(w : E)‖ ^ 2 - 4)) * (‖(w : E)‖ ^ 2 + 4)⁻¹ * 4 = 1 := by field_simp; ring convert congr_arg (· • w) this · have h₁ : orthogonalProjection (ℝ ∙ v)ᗮ v = 0 := orthogonalProjection_orthogonalComplement_singleton_eq_zero v -- Porting note: was innerSL _ and now just inner have h₃ : inner v w = (0 : ℝ) := Submodule.mem_orthogonal_singleton_iff_inner_right.mp w.2 -- Porting note: was innerSL _ and now just inner have h₄ : inner v v = (1 : ℝ) := by simp [real_inner_self_eq_norm_mul_norm, hv] simp [h₁, h₃, h₄, ContinuousLinearMap.map_add, ContinuousLinearMap.map_smul, mul_smul] · simp #align stereo_right_inv stereo_right_inv def stereographic (hv : ‖v‖ = 1) : PartialHomeomorph (sphere (0 : E) 1) (ℝ ∙ v)ᗮ where toFun := stereoToFun v ∘ (↑) invFun := stereoInvFun hv source := {⟨v, by simp [hv]⟩}ᶜ target := Set.univ map_source' := by simp map_target' {w} _ := fun h => (stereoInvFun_ne_north_pole hv w) (Set.eq_of_mem_singleton h) left_inv' x hx := stereo_left_inv hv fun h => hx (by rw [← h] at hv apply Subtype.ext dsimp exact h) right_inv' w _ := stereo_right_inv hv w open_source := isOpen_compl_singleton open_target := isOpen_univ continuousOn_toFun := continuousOn_stereoToFun.comp continuous_subtype_val.continuousOn fun w h => by dsimp exact h ∘ Subtype.ext ∘ Eq.symm ∘ (inner_eq_one_iff_of_norm_one hv (by simp)).mp continuousOn_invFun := (continuous_stereoInvFun hv).continuousOn #align stereographic stereographic theorem stereographic_apply (hv : ‖v‖ = 1) (x : sphere (0 : E) 1) : stereographic hv x = (2 / ((1 : ℝ) - inner v x)) • orthogonalProjection (ℝ ∙ v)ᗮ x := rfl #align stereographic_apply stereographic_apply @[simp] theorem stereographic_source (hv : ‖v‖ = 1) : (stereographic hv).source = {⟨v, by simp [hv]⟩}ᶜ := rfl #align stereographic_source stereographic_source @[simp] theorem stereographic_target (hv : ‖v‖ = 1) : (stereographic hv).target = Set.univ := rfl #align stereographic_target stereographic_target @[simp] theorem stereographic_apply_neg (v : sphere (0 : E) 1) : stereographic (norm_eq_of_mem_sphere v) (-v) = 0 := by simp [stereographic_apply, orthogonalProjection_orthogonalComplement_singleton_eq_zero] #align stereographic_apply_neg stereographic_apply_neg @[simp]
Mathlib/Geometry/Manifold/Instances/Sphere.lean
318
322
theorem stereographic_neg_apply (v : sphere (0 : E) 1) : stereographic (norm_eq_of_mem_sphere (-v)) v = 0 := by
convert stereographic_apply_neg (-v) ext1 simp
import Mathlib.MeasureTheory.Measure.Haar.InnerProductSpace import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar import Mathlib.MeasureTheory.Integral.SetIntegral #align_import measure_theory.measure.haar.normed_space from "leanprover-community/mathlib"@"b84aee748341da06a6d78491367e2c0e9f15e8a5" noncomputable section open scoped NNReal ENNReal Pointwise Topology open Inv Set Function MeasureTheory.Measure Filter open FiniteDimensional namespace MeasureTheory namespace Measure example {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [Nontrivial E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [IsAddHaarMeasure μ] : NoAtoms μ := by infer_instance variable {F : Type*} [NormedAddCommGroup F]
Mathlib/MeasureTheory/Measure/Haar/NormedSpace.lean
163
177
theorem integrable_comp_smul_iff {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace E] [BorelSpace E] [FiniteDimensional ℝ E] (μ : Measure E) [IsAddHaarMeasure μ] (f : E → F) {R : ℝ} (hR : R ≠ 0) : Integrable (fun x => f (R • x)) μ ↔ Integrable f μ := by
-- reduce to one-way implication suffices ∀ {g : E → F} (_ : Integrable g μ) {S : ℝ} (_ : S ≠ 0), Integrable (fun x => g (S • x)) μ by refine ⟨fun hf => ?_, fun hf => this hf hR⟩ convert this hf (inv_ne_zero hR) rw [← mul_smul, mul_inv_cancel hR, one_smul] -- now prove intro g hg S hS let t := ((Homeomorph.smul (isUnit_iff_ne_zero.2 hS).unit).toMeasurableEquiv : E ≃ᵐ E) refine (integrable_map_equiv t g).mp (?_ : Integrable g (map (S • ·) μ)) rwa [map_addHaar_smul μ hS, integrable_smul_measure _ ENNReal.ofReal_ne_top] simpa only [Ne, ENNReal.ofReal_eq_zero, not_le, abs_pos] using inv_ne_zero (pow_ne_zero _ hS)
import Mathlib.Algebra.Field.Defs import Mathlib.Algebra.GroupWithZero.Units.Lemmas import Mathlib.Algebra.Ring.Commute import Mathlib.Algebra.Ring.Invertible import Mathlib.Order.Synonym #align_import algebra.field.basic from "leanprover-community/mathlib"@"05101c3df9d9cfe9430edc205860c79b6d660102" open Function OrderDual Set universe u variable {α β K : Type*} section DivisionMonoid variable [DivisionMonoid K] [HasDistribNeg K] {a b : K} theorem one_div_neg_one_eq_neg_one : (1 : K) / -1 = -1 := have : -1 * -1 = (1 : K) := by rw [neg_mul_neg, one_mul] Eq.symm (eq_one_div_of_mul_eq_one_right this) #align one_div_neg_one_eq_neg_one one_div_neg_one_eq_neg_one
Mathlib/Algebra/Field/Basic.lean
101
106
theorem one_div_neg_eq_neg_one_div (a : K) : 1 / -a = -(1 / a) := calc 1 / -a = 1 / (-1 * a) := by
rw [neg_eq_neg_one_mul] _ = 1 / a * (1 / -1) := by rw [one_div_mul_one_div_rev] _ = 1 / a * -1 := by rw [one_div_neg_one_eq_neg_one] _ = -(1 / a) := by rw [mul_neg, mul_one]
import Mathlib.Data.ENat.Lattice import Mathlib.Order.OrderIsoNat import Mathlib.Tactic.TFAE #align_import order.height from "leanprover-community/mathlib"@"bf27744463e9620ca4e4ebe951fe83530ae6949b" open List hiding le_antisymm open OrderDual universe u v variable {α β : Type*} namespace Set section LT variable [LT α] [LT β] (s t : Set α) def subchain : Set (List α) := { l | l.Chain' (· < ·) ∧ ∀ i ∈ l, i ∈ s } #align set.subchain Set.subchain @[simp] -- porting note: new `simp` theorem nil_mem_subchain : [] ∈ s.subchain := ⟨trivial, fun _ ↦ nofun⟩ #align set.nil_mem_subchain Set.nil_mem_subchain variable {s} {l : List α} {a : α} theorem cons_mem_subchain_iff : (a::l) ∈ s.subchain ↔ a ∈ s ∧ l ∈ s.subchain ∧ ∀ b ∈ l.head?, a < b := by simp only [subchain, mem_setOf_eq, forall_mem_cons, chain'_cons', and_left_comm, and_comm, and_assoc] #align set.cons_mem_subchain_iff Set.cons_mem_subchain_iff @[simp] -- Porting note (#10756): new lemma + `simp` theorem singleton_mem_subchain_iff : [a] ∈ s.subchain ↔ a ∈ s := by simp [cons_mem_subchain_iff] instance : Nonempty s.subchain := ⟨⟨[], s.nil_mem_subchain⟩⟩ variable (s) noncomputable def chainHeight : ℕ∞ := ⨆ l ∈ s.subchain, length l #align set.chain_height Set.chainHeight theorem chainHeight_eq_iSup_subtype : s.chainHeight = ⨆ l : s.subchain, ↑l.1.length := iSup_subtype' #align set.chain_height_eq_supr_subtype Set.chainHeight_eq_iSup_subtype theorem exists_chain_of_le_chainHeight {n : ℕ} (hn : ↑n ≤ s.chainHeight) : ∃ l ∈ s.subchain, length l = n := by rcases (le_top : s.chainHeight ≤ ⊤).eq_or_lt with ha | ha <;> rw [chainHeight_eq_iSup_subtype] at ha · obtain ⟨_, ⟨⟨l, h₁, h₂⟩, rfl⟩, h₃⟩ := not_bddAbove_iff'.mp (WithTop.iSup_coe_eq_top.1 ha) n exact ⟨l.take n, ⟨h₁.take _, fun x h ↦ h₂ _ <| take_subset _ _ h⟩, (l.length_take n).trans <| min_eq_left <| le_of_not_ge h₃⟩ · rw [ENat.iSup_coe_lt_top] at ha obtain ⟨⟨l, h₁, h₂⟩, e : l.length = _⟩ := Nat.sSup_mem (Set.range_nonempty _) ha refine ⟨l.take n, ⟨h₁.take _, fun x h ↦ h₂ _ <| take_subset _ _ h⟩, (l.length_take n).trans <| min_eq_left <| ?_⟩ rwa [e, ← Nat.cast_le (α := ℕ∞), sSup_range, ENat.coe_iSup ha, ← chainHeight_eq_iSup_subtype] #align set.exists_chain_of_le_chain_height Set.exists_chain_of_le_chainHeight
Mathlib/Order/Height.lean
109
114
theorem le_chainHeight_TFAE (n : ℕ) : TFAE [↑n ≤ s.chainHeight, ∃ l ∈ s.subchain, length l = n, ∃ l ∈ s.subchain, n ≤ length l] := by
tfae_have 1 → 2; · exact s.exists_chain_of_le_chainHeight tfae_have 2 → 3; · rintro ⟨l, hls, he⟩; exact ⟨l, hls, he.ge⟩ tfae_have 3 → 1; · rintro ⟨l, hs, hn⟩; exact le_iSup₂_of_le l hs (WithTop.coe_le_coe.2 hn) tfae_finish
import Mathlib.MeasureTheory.Integral.Lebesgue #align_import measure_theory.measure.giry_monad from "leanprover-community/mathlib"@"56f4cd1ef396e9fd389b5d8371ee9ad91d163625" noncomputable section open scoped Classical open ENNReal open scoped Classical open Set Filter variable {α β : Type*} namespace MeasureTheory namespace Measure variable [MeasurableSpace α] [MeasurableSpace β] instance instMeasurableSpace : MeasurableSpace (Measure α) := ⨆ (s : Set α) (_ : MeasurableSet s), (borel ℝ≥0∞).comap fun μ => μ s #align measure_theory.measure.measurable_space MeasureTheory.Measure.instMeasurableSpace theorem measurable_coe {s : Set α} (hs : MeasurableSet s) : Measurable fun μ : Measure α => μ s := Measurable.of_comap_le <| le_iSup_of_le s <| le_iSup_of_le hs <| le_rfl #align measure_theory.measure.measurable_coe MeasureTheory.Measure.measurable_coe theorem measurable_of_measurable_coe (f : β → Measure α) (h : ∀ (s : Set α), MeasurableSet s → Measurable fun b => f b s) : Measurable f := Measurable.of_le_map <| iSup₂_le fun s hs => MeasurableSpace.comap_le_iff_le_map.2 <| by rw [MeasurableSpace.map_comp]; exact h s hs #align measure_theory.measure.measurable_of_measurable_coe MeasureTheory.Measure.measurable_of_measurable_coe instance instMeasurableAdd₂ {α : Type*} {m : MeasurableSpace α} : MeasurableAdd₂ (Measure α) := by refine ⟨Measure.measurable_of_measurable_coe _ fun s hs => ?_⟩ simp_rw [Measure.coe_add, Pi.add_apply] refine Measurable.add ?_ ?_ · exact (Measure.measurable_coe hs).comp measurable_fst · exact (Measure.measurable_coe hs).comp measurable_snd #align measure_theory.measure.has_measurable_add₂ MeasureTheory.Measure.instMeasurableAdd₂ theorem measurable_measure {μ : α → Measure β} : Measurable μ ↔ ∀ (s : Set β), MeasurableSet s → Measurable fun b => μ b s := ⟨fun hμ _s hs => (measurable_coe hs).comp hμ, measurable_of_measurable_coe μ⟩ #align measure_theory.measure.measurable_measure MeasureTheory.Measure.measurable_measure theorem measurable_map (f : α → β) (hf : Measurable f) : Measurable fun μ : Measure α => map f μ := by refine measurable_of_measurable_coe _ fun s hs => ?_ simp_rw [map_apply hf hs] exact measurable_coe (hf hs) #align measure_theory.measure.measurable_map MeasureTheory.Measure.measurable_map theorem measurable_dirac : Measurable (Measure.dirac : α → Measure α) := by refine measurable_of_measurable_coe _ fun s hs => ?_ simp_rw [dirac_apply' _ hs] exact measurable_one.indicator hs #align measure_theory.measure.measurable_dirac MeasureTheory.Measure.measurable_dirac theorem measurable_lintegral {f : α → ℝ≥0∞} (hf : Measurable f) : Measurable fun μ : Measure α => ∫⁻ x, f x ∂μ := by simp only [lintegral_eq_iSup_eapprox_lintegral, hf, SimpleFunc.lintegral] refine measurable_iSup fun n => Finset.measurable_sum _ fun i _ => ?_ refine Measurable.const_mul ?_ _ exact measurable_coe ((SimpleFunc.eapprox f n).measurableSet_preimage _) #align measure_theory.measure.measurable_lintegral MeasureTheory.Measure.measurable_lintegral def join (m : Measure (Measure α)) : Measure α := Measure.ofMeasurable (fun s _ => ∫⁻ μ, μ s ∂m) (by simp only [measure_empty, lintegral_const, zero_mul]) (by intro f hf h simp_rw [measure_iUnion h hf] apply lintegral_tsum intro i; exact (measurable_coe (hf i)).aemeasurable) #align measure_theory.measure.join MeasureTheory.Measure.join @[simp] theorem join_apply {m : Measure (Measure α)} {s : Set α} (hs : MeasurableSet s) : join m s = ∫⁻ μ, μ s ∂m := Measure.ofMeasurable_apply s hs #align measure_theory.measure.join_apply MeasureTheory.Measure.join_apply @[simp] theorem join_zero : (0 : Measure (Measure α)).join = 0 := by ext1 s hs simp only [hs, join_apply, lintegral_zero_measure, coe_zero, Pi.zero_apply] #align measure_theory.measure.join_zero MeasureTheory.Measure.join_zero theorem measurable_join : Measurable (join : Measure (Measure α) → Measure α) := measurable_of_measurable_coe _ fun s hs => by simp only [join_apply hs]; exact measurable_lintegral (measurable_coe hs) #align measure_theory.measure.measurable_join MeasureTheory.Measure.measurable_join theorem lintegral_join {m : Measure (Measure α)} {f : α → ℝ≥0∞} (hf : Measurable f) : ∫⁻ x, f x ∂join m = ∫⁻ μ, ∫⁻ x, f x ∂μ ∂m := by simp_rw [lintegral_eq_iSup_eapprox_lintegral hf, SimpleFunc.lintegral, join_apply (SimpleFunc.measurableSet_preimage _ _)] suffices ∀ (s : ℕ → Finset ℝ≥0∞) (f : ℕ → ℝ≥0∞ → Measure α → ℝ≥0∞), (∀ n r, Measurable (f n r)) → Monotone (fun n μ => ∑ r ∈ s n, r * f n r μ) → ⨆ n, ∑ r ∈ s n, r * ∫⁻ μ, f n r μ ∂m = ∫⁻ μ, ⨆ n, ∑ r ∈ s n, r * f n r μ ∂m by refine this (fun n => SimpleFunc.range (SimpleFunc.eapprox f n)) (fun n r μ => μ (SimpleFunc.eapprox f n ⁻¹' {r})) ?_ ?_ · exact fun n r => measurable_coe (SimpleFunc.measurableSet_preimage _ _) · exact fun n m h μ => SimpleFunc.lintegral_mono (SimpleFunc.monotone_eapprox _ h) le_rfl intro s f hf hm rw [lintegral_iSup _ hm] swap · exact fun n => Finset.measurable_sum _ fun r _ => (hf _ _).const_mul _ congr funext n rw [lintegral_finset_sum (s n)] · simp_rw [lintegral_const_mul _ (hf _ _)] · exact fun r _ => (hf _ _).const_mul _ #align measure_theory.measure.lintegral_join MeasureTheory.Measure.lintegral_join def bind (m : Measure α) (f : α → Measure β) : Measure β := join (map f m) #align measure_theory.measure.bind MeasureTheory.Measure.bind @[simp] theorem bind_zero_left (f : α → Measure β) : bind 0 f = 0 := by simp [bind] #align measure_theory.measure.bind_zero_left MeasureTheory.Measure.bind_zero_left @[simp] theorem bind_zero_right (m : Measure α) : bind m (0 : α → Measure β) = 0 := by ext1 s hs simp only [bind, hs, join_apply, coe_zero, Pi.zero_apply] rw [lintegral_map (measurable_coe hs) measurable_zero] simp only [Pi.zero_apply, coe_zero, lintegral_const, zero_mul] #align measure_theory.measure.bind_zero_right MeasureTheory.Measure.bind_zero_right @[simp] theorem bind_zero_right' (m : Measure α) : bind m (fun _ => 0 : α → Measure β) = 0 := bind_zero_right m #align measure_theory.measure.bind_zero_right' MeasureTheory.Measure.bind_zero_right' @[simp]
Mathlib/MeasureTheory/Measure/GiryMonad.lean
176
178
theorem bind_apply {m : Measure α} {f : α → Measure β} {s : Set β} (hs : MeasurableSet s) (hf : Measurable f) : bind m f s = ∫⁻ a, f a s ∂m := by
rw [bind, join_apply hs, lintegral_map (measurable_coe hs) hf]
import Mathlib.CategoryTheory.Limits.Shapes.Equalizers import Mathlib.CategoryTheory.Limits.Shapes.KernelPair #align_import category_theory.limits.shapes.reflexive from "leanprover-community/mathlib"@"d6814c584384ddf2825ff038e868451a7c956f31" namespace CategoryTheory universe v v₂ u u₂ variable {C : Type u} [Category.{v} C] variable {D : Type u₂} [Category.{v₂} D] variable {A B : C} {f g : A ⟶ B} class IsReflexivePair (f g : A ⟶ B) : Prop where common_section' : ∃ s : B ⟶ A, s ≫ f = 𝟙 B ∧ s ≫ g = 𝟙 B #align category_theory.is_reflexive_pair CategoryTheory.IsReflexivePair -- Porting note (#10756): added theorem, because of unsupported infer kinds theorem IsReflexivePair.common_section (f g : A ⟶ B) [IsReflexivePair f g] : ∃ s : B ⟶ A, s ≫ f = 𝟙 B ∧ s ≫ g = 𝟙 B := IsReflexivePair.common_section' class IsCoreflexivePair (f g : A ⟶ B) : Prop where common_retraction' : ∃ s : B ⟶ A, f ≫ s = 𝟙 A ∧ g ≫ s = 𝟙 A #align category_theory.is_coreflexive_pair CategoryTheory.IsCoreflexivePair -- Porting note (#10756): added theorem, because of unsupported infer kinds theorem IsCoreflexivePair.common_retraction (f g : A ⟶ B) [IsCoreflexivePair f g] : ∃ s : B ⟶ A, f ≫ s = 𝟙 A ∧ g ≫ s = 𝟙 A := IsCoreflexivePair.common_retraction' theorem IsReflexivePair.mk' (s : B ⟶ A) (sf : s ≫ f = 𝟙 B) (sg : s ≫ g = 𝟙 B) : IsReflexivePair f g := ⟨⟨s, sf, sg⟩⟩ #align category_theory.is_reflexive_pair.mk' CategoryTheory.IsReflexivePair.mk' theorem IsCoreflexivePair.mk' (s : B ⟶ A) (fs : f ≫ s = 𝟙 A) (gs : g ≫ s = 𝟙 A) : IsCoreflexivePair f g := ⟨⟨s, fs, gs⟩⟩ #align category_theory.is_coreflexive_pair.mk' CategoryTheory.IsCoreflexivePair.mk' noncomputable def commonSection (f g : A ⟶ B) [IsReflexivePair f g] : B ⟶ A := (IsReflexivePair.common_section f g).choose #align category_theory.common_section CategoryTheory.commonSection @[reassoc (attr := simp)] theorem section_comp_left (f g : A ⟶ B) [IsReflexivePair f g] : commonSection f g ≫ f = 𝟙 B := (IsReflexivePair.common_section f g).choose_spec.1 #align category_theory.section_comp_left CategoryTheory.section_comp_left @[reassoc (attr := simp)] theorem section_comp_right (f g : A ⟶ B) [IsReflexivePair f g] : commonSection f g ≫ g = 𝟙 B := (IsReflexivePair.common_section f g).choose_spec.2 #align category_theory.section_comp_right CategoryTheory.section_comp_right noncomputable def commonRetraction (f g : A ⟶ B) [IsCoreflexivePair f g] : B ⟶ A := (IsCoreflexivePair.common_retraction f g).choose #align category_theory.common_retraction CategoryTheory.commonRetraction @[reassoc (attr := simp)] theorem left_comp_retraction (f g : A ⟶ B) [IsCoreflexivePair f g] : f ≫ commonRetraction f g = 𝟙 A := (IsCoreflexivePair.common_retraction f g).choose_spec.1 #align category_theory.left_comp_retraction CategoryTheory.left_comp_retraction @[reassoc (attr := simp)] theorem right_comp_retraction (f g : A ⟶ B) [IsCoreflexivePair f g] : g ≫ commonRetraction f g = 𝟙 A := (IsCoreflexivePair.common_retraction f g).choose_spec.2 #align category_theory.right_comp_retraction CategoryTheory.right_comp_retraction theorem IsKernelPair.isReflexivePair {R : C} {f g : R ⟶ A} {q : A ⟶ B} (h : IsKernelPair q f g) : IsReflexivePair f g := IsReflexivePair.mk' _ (h.lift' _ _ rfl).2.1 (h.lift' _ _ _).2.2 #align category_theory.is_kernel_pair.is_reflexive_pair CategoryTheory.IsKernelPair.isReflexivePair -- This shouldn't be an instance as it would instantly loop. theorem IsReflexivePair.swap [IsReflexivePair f g] : IsReflexivePair g f := IsReflexivePair.mk' _ (section_comp_right f g) (section_comp_left f g) #align category_theory.is_reflexive_pair.swap CategoryTheory.IsReflexivePair.swap -- This shouldn't be an instance as it would instantly loop. theorem IsCoreflexivePair.swap [IsCoreflexivePair f g] : IsCoreflexivePair g f := IsCoreflexivePair.mk' _ (right_comp_retraction f g) (left_comp_retraction f g) #align category_theory.is_coreflexive_pair.swap CategoryTheory.IsCoreflexivePair.swap variable {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) instance (B : D) : IsReflexivePair (F.map (G.map (adj.counit.app B))) (adj.counit.app (F.obj (G.obj B))) := IsReflexivePair.mk' (F.map (adj.unit.app (G.obj B))) (by rw [← F.map_comp, adj.right_triangle_components] apply F.map_id) (adj.left_triangle_components _) namespace Limits variable (C) class HasReflexiveCoequalizers : Prop where has_coeq : ∀ ⦃A B : C⦄ (f g : A ⟶ B) [IsReflexivePair f g], HasCoequalizer f g #align category_theory.limits.has_reflexive_coequalizers CategoryTheory.Limits.HasReflexiveCoequalizers class HasCoreflexiveEqualizers : Prop where has_eq : ∀ ⦃A B : C⦄ (f g : A ⟶ B) [IsCoreflexivePair f g], HasEqualizer f g #align category_theory.limits.has_coreflexive_equalizers CategoryTheory.Limits.HasCoreflexiveEqualizers attribute [instance 1] HasReflexiveCoequalizers.has_coeq attribute [instance 1] HasCoreflexiveEqualizers.has_eq theorem hasCoequalizer_of_common_section [HasReflexiveCoequalizers C] {A B : C} {f g : A ⟶ B} (r : B ⟶ A) (rf : r ≫ f = 𝟙 _) (rg : r ≫ g = 𝟙 _) : HasCoequalizer f g := by letI := IsReflexivePair.mk' r rf rg infer_instance #align category_theory.limits.has_coequalizer_of_common_section CategoryTheory.Limits.hasCoequalizer_of_common_section
Mathlib/CategoryTheory/Limits/Shapes/Reflexive.lean
156
159
theorem hasEqualizer_of_common_retraction [HasCoreflexiveEqualizers C] {A B : C} {f g : A ⟶ B} (r : B ⟶ A) (fr : f ≫ r = 𝟙 _) (gr : g ≫ r = 𝟙 _) : HasEqualizer f g := by
letI := IsCoreflexivePair.mk' r fr gr infer_instance
import Mathlib.Algebra.MvPolynomial.Derivation import Mathlib.Algebra.MvPolynomial.Variables #align_import data.mv_polynomial.pderiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" noncomputable section universe u v namespace MvPolynomial open Set Function Finsupp variable {R : Type u} {σ : Type v} {a a' a₁ a₂ : R} {s : σ →₀ ℕ} section PDeriv variable [CommSemiring R] def pderiv (i : σ) : Derivation R (MvPolynomial σ R) (MvPolynomial σ R) := letI := Classical.decEq σ mkDerivation R <| Pi.single i 1 #align mv_polynomial.pderiv MvPolynomial.pderiv theorem pderiv_def [DecidableEq σ] (i : σ) : pderiv i = mkDerivation R (Pi.single i 1) := by unfold pderiv; congr! #align mv_polynomial.pderiv_def MvPolynomial.pderiv_def @[simp]
Mathlib/Algebra/MvPolynomial/PDeriv.lean
69
77
theorem pderiv_monomial {i : σ} : pderiv i (monomial s a) = monomial (s - single i 1) (a * s i) := by
classical simp only [pderiv_def, mkDerivation_monomial, Finsupp.smul_sum, smul_eq_mul, ← smul_mul_assoc, ← (monomial _).map_smul] refine (Finset.sum_eq_single i (fun j _ hne => ?_) fun hi => ?_).trans ?_ · simp [Pi.single_eq_of_ne hne] · rw [Finsupp.not_mem_support_iff] at hi; simp [hi] · simp
import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Reverse import Mathlib.Algebra.Polynomial.Inductions import Mathlib.RingTheory.Localization.Basic #align_import data.polynomial.laurent from "leanprover-community/mathlib"@"831c494092374cfe9f50591ed0ac81a25efc5b86" open Polynomial Function AddMonoidAlgebra Finsupp noncomputable section variable {R : Type*} abbrev LaurentPolynomial (R : Type*) [Semiring R] := AddMonoidAlgebra R ℤ #align laurent_polynomial LaurentPolynomial @[nolint docBlame] scoped[LaurentPolynomial] notation:9000 R "[T;T⁻¹]" => LaurentPolynomial R open LaurentPolynomial -- Porting note: `ext` no longer applies `Finsupp.ext` automatically @[ext] theorem LaurentPolynomial.ext [Semiring R] {p q : R[T;T⁻¹]} (h : ∀ a, p a = q a) : p = q := Finsupp.ext h def Polynomial.toLaurent [Semiring R] : R[X] →+* R[T;T⁻¹] := (mapDomainRingHom R Int.ofNatHom).comp (toFinsuppIso R) #align polynomial.to_laurent Polynomial.toLaurent theorem Polynomial.toLaurent_apply [Semiring R] (p : R[X]) : toLaurent p = p.toFinsupp.mapDomain (↑) := rfl #align polynomial.to_laurent_apply Polynomial.toLaurent_apply def Polynomial.toLaurentAlg [CommSemiring R] : R[X] →ₐ[R] R[T;T⁻¹] := (mapDomainAlgHom R R Int.ofNatHom).comp (toFinsuppIsoAlg R).toAlgHom #align polynomial.to_laurent_alg Polynomial.toLaurentAlg @[simp] lemma Polynomial.coe_toLaurentAlg [CommSemiring R] : (toLaurentAlg : R[X] → R[T;T⁻¹]) = toLaurent := rfl theorem Polynomial.toLaurentAlg_apply [CommSemiring R] (f : R[X]) : toLaurentAlg f = toLaurent f := rfl #align polynomial.to_laurent_alg_apply Polynomial.toLaurentAlg_apply namespace LaurentPolynomial section Semiring variable [Semiring R] theorem single_zero_one_eq_one : (Finsupp.single 0 1 : R[T;T⁻¹]) = (1 : R[T;T⁻¹]) := rfl #align laurent_polynomial.single_zero_one_eq_one LaurentPolynomial.single_zero_one_eq_one def C : R →+* R[T;T⁻¹] := singleZeroRingHom set_option linter.uppercaseLean3 false in #align laurent_polynomial.C LaurentPolynomial.C theorem algebraMap_apply {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] (r : R) : algebraMap R (LaurentPolynomial A) r = C (algebraMap R A r) := rfl #align laurent_polynomial.algebra_map_apply LaurentPolynomial.algebraMap_apply theorem C_eq_algebraMap {R : Type*} [CommSemiring R] (r : R) : C r = algebraMap R R[T;T⁻¹] r := rfl set_option linter.uppercaseLean3 false in #align laurent_polynomial.C_eq_algebra_map LaurentPolynomial.C_eq_algebraMap theorem single_eq_C (r : R) : Finsupp.single 0 r = C r := rfl set_option linter.uppercaseLean3 false in #align laurent_polynomial.single_eq_C LaurentPolynomial.single_eq_C @[simp] lemma C_apply (t : R) (n : ℤ) : C t n = if n = 0 then t else 0 := by rw [← single_eq_C, Finsupp.single_apply]; aesop def T (n : ℤ) : R[T;T⁻¹] := Finsupp.single n 1 set_option linter.uppercaseLean3 false in #align laurent_polynomial.T LaurentPolynomial.T @[simp] lemma T_apply (m n : ℤ) : (T n : R[T;T⁻¹]) m = if n = m then 1 else 0 := Finsupp.single_apply @[simp] theorem T_zero : (T 0 : R[T;T⁻¹]) = 1 := rfl set_option linter.uppercaseLean3 false in #align laurent_polynomial.T_zero LaurentPolynomial.T_zero theorem T_add (m n : ℤ) : (T (m + n) : R[T;T⁻¹]) = T m * T n := by -- Porting note: was `convert single_mul_single.symm` simp [T, single_mul_single] set_option linter.uppercaseLean3 false in #align laurent_polynomial.T_add LaurentPolynomial.T_add theorem T_sub (m n : ℤ) : (T (m - n) : R[T;T⁻¹]) = T m * T (-n) := by rw [← T_add, sub_eq_add_neg] set_option linter.uppercaseLean3 false in #align laurent_polynomial.T_sub LaurentPolynomial.T_sub @[simp] theorem T_pow (m : ℤ) (n : ℕ) : (T m ^ n : R[T;T⁻¹]) = T (n * m) := by rw [T, T, single_pow n, one_pow, nsmul_eq_mul] set_option linter.uppercaseLean3 false in #align laurent_polynomial.T_pow LaurentPolynomial.T_pow @[simp] theorem mul_T_assoc (f : R[T;T⁻¹]) (m n : ℤ) : f * T m * T n = f * T (m + n) := by simp [← T_add, mul_assoc] set_option linter.uppercaseLean3 false in #align laurent_polynomial.mul_T_assoc LaurentPolynomial.mul_T_assoc @[simp] theorem single_eq_C_mul_T (r : R) (n : ℤ) : (Finsupp.single n r : R[T;T⁻¹]) = (C r * T n : R[T;T⁻¹]) := by -- Porting note: was `convert single_mul_single.symm` simp [C, T, single_mul_single] set_option linter.uppercaseLean3 false in #align laurent_polynomial.single_eq_C_mul_T LaurentPolynomial.single_eq_C_mul_T -- This lemma locks in the right changes and is what Lean proved directly. -- The actual `simp`-normal form of a Laurent monomial is `C a * T n`, whenever it can be reached. @[simp] theorem _root_.Polynomial.toLaurent_C_mul_T (n : ℕ) (r : R) : (toLaurent (Polynomial.monomial n r) : R[T;T⁻¹]) = C r * T n := show Finsupp.mapDomain (↑) (monomial n r).toFinsupp = (C r * T n : R[T;T⁻¹]) by rw [toFinsupp_monomial, Finsupp.mapDomain_single, single_eq_C_mul_T] set_option linter.uppercaseLean3 false in #align polynomial.to_laurent_C_mul_T Polynomial.toLaurent_C_mul_T @[simp] theorem _root_.Polynomial.toLaurent_C (r : R) : toLaurent (Polynomial.C r) = C r := by convert Polynomial.toLaurent_C_mul_T 0 r simp only [Int.ofNat_zero, T_zero, mul_one] set_option linter.uppercaseLean3 false in #align polynomial.to_laurent_C Polynomial.toLaurent_C @[simp] theorem _root_.Polynomial.toLaurent_comp_C : toLaurent (R := R) ∘ Polynomial.C = C := funext Polynomial.toLaurent_C @[simp] theorem _root_.Polynomial.toLaurent_X : (toLaurent Polynomial.X : R[T;T⁻¹]) = T 1 := by have : (Polynomial.X : R[X]) = monomial 1 1 := by simp [← C_mul_X_pow_eq_monomial] simp [this, Polynomial.toLaurent_C_mul_T] set_option linter.uppercaseLean3 false in #align polynomial.to_laurent_X Polynomial.toLaurent_X -- @[simp] -- Porting note (#10618): simp can prove this theorem _root_.Polynomial.toLaurent_one : (Polynomial.toLaurent : R[X] → R[T;T⁻¹]) 1 = 1 := map_one Polynomial.toLaurent #align polynomial.to_laurent_one Polynomial.toLaurent_one -- @[simp] -- Porting note (#10618): simp can prove this theorem _root_.Polynomial.toLaurent_C_mul_eq (r : R) (f : R[X]) : toLaurent (Polynomial.C r * f) = C r * toLaurent f := by simp only [_root_.map_mul, Polynomial.toLaurent_C] set_option linter.uppercaseLean3 false in #align polynomial.to_laurent_C_mul_eq Polynomial.toLaurent_C_mul_eq -- @[simp] -- Porting note (#10618): simp can prove this theorem _root_.Polynomial.toLaurent_X_pow (n : ℕ) : toLaurent (X ^ n : R[X]) = T n := by simp only [map_pow, Polynomial.toLaurent_X, T_pow, mul_one] set_option linter.uppercaseLean3 false in #align polynomial.to_laurent_X_pow Polynomial.toLaurent_X_pow -- @[simp] -- Porting note (#10618): simp can prove this theorem _root_.Polynomial.toLaurent_C_mul_X_pow (n : ℕ) (r : R) : toLaurent (Polynomial.C r * X ^ n) = C r * T n := by simp only [_root_.map_mul, Polynomial.toLaurent_C, Polynomial.toLaurent_X_pow] set_option linter.uppercaseLean3 false in #align polynomial.to_laurent_C_mul_X_pow Polynomial.toLaurent_C_mul_X_pow instance invertibleT (n : ℤ) : Invertible (T n : R[T;T⁻¹]) where invOf := T (-n) invOf_mul_self := by rw [← T_add, add_left_neg, T_zero] mul_invOf_self := by rw [← T_add, add_right_neg, T_zero] set_option linter.uppercaseLean3 false in #align laurent_polynomial.invertible_T LaurentPolynomial.invertibleT @[simp] theorem invOf_T (n : ℤ) : ⅟ (T n : R[T;T⁻¹]) = T (-n) := rfl set_option linter.uppercaseLean3 false in #align laurent_polynomial.inv_of_T LaurentPolynomial.invOf_T theorem isUnit_T (n : ℤ) : IsUnit (T n : R[T;T⁻¹]) := isUnit_of_invertible _ set_option linter.uppercaseLean3 false in #align laurent_polynomial.is_unit_T LaurentPolynomial.isUnit_T @[elab_as_elim] protected theorem induction_on {M : R[T;T⁻¹] → Prop} (p : R[T;T⁻¹]) (h_C : ∀ a, M (C a)) (h_add : ∀ {p q}, M p → M q → M (p + q)) (h_C_mul_T : ∀ (n : ℕ) (a : R), M (C a * T n) → M (C a * T (n + 1))) (h_C_mul_T_Z : ∀ (n : ℕ) (a : R), M (C a * T (-n)) → M (C a * T (-n - 1))) : M p := by have A : ∀ {n : ℤ} {a : R}, M (C a * T n) := by intro n a refine Int.induction_on n ?_ ?_ ?_ · simpa only [T_zero, mul_one] using h_C a · exact fun m => h_C_mul_T m a · exact fun m => h_C_mul_T_Z m a have B : ∀ s : Finset ℤ, M (s.sum fun n : ℤ => C (p.toFun n) * T n) := by apply Finset.induction · convert h_C 0 simp only [Finset.sum_empty, _root_.map_zero] · intro n s ns ih rw [Finset.sum_insert ns] exact h_add A ih convert B p.support ext a simp_rw [← single_eq_C_mul_T] -- Porting note: did not make progress in `simp_rw` rw [Finset.sum_apply'] simp_rw [Finsupp.single_apply, Finset.sum_ite_eq'] split_ifs with h · rfl · exact Finsupp.not_mem_support_iff.mp h #align laurent_polynomial.induction_on LaurentPolynomial.induction_on @[elab_as_elim] protected theorem induction_on' {M : R[T;T⁻¹] → Prop} (p : R[T;T⁻¹]) (h_add : ∀ p q, M p → M q → M (p + q)) (h_C_mul_T : ∀ (n : ℤ) (a : R), M (C a * T n)) : M p := by refine p.induction_on (fun a => ?_) (fun {p q} => h_add p q) ?_ ?_ <;> try exact fun n f _ => h_C_mul_T _ f convert h_C_mul_T 0 a exact (mul_one _).symm #align laurent_polynomial.induction_on' LaurentPolynomial.induction_on' theorem commute_T (n : ℤ) (f : R[T;T⁻¹]) : Commute (T n) f := f.induction_on' (fun p q Tp Tq => Commute.add_right Tp Tq) fun m a => show T n * _ = _ by rw [T, T, ← single_eq_C, single_mul_single, single_mul_single, single_mul_single] simp [add_comm] set_option linter.uppercaseLean3 false in #align laurent_polynomial.commute_T LaurentPolynomial.commute_T @[simp] theorem T_mul (n : ℤ) (f : R[T;T⁻¹]) : T n * f = f * T n := (commute_T n f).eq set_option linter.uppercaseLean3 false in #align laurent_polynomial.T_mul LaurentPolynomial.T_mul def trunc : R[T;T⁻¹] →+ R[X] := (toFinsuppIso R).symm.toAddMonoidHom.comp <| comapDomain.addMonoidHom fun _ _ => Int.ofNat.inj #align laurent_polynomial.trunc LaurentPolynomial.trunc @[simp] theorem trunc_C_mul_T (n : ℤ) (r : R) : trunc (C r * T n) = ite (0 ≤ n) (monomial n.toNat r) 0 := by apply (toFinsuppIso R).injective rw [← single_eq_C_mul_T, trunc, AddMonoidHom.coe_comp, Function.comp_apply] -- Porting note (#10691): was `rw` erw [comapDomain.addMonoidHom_apply Int.ofNat_injective] rw [toFinsuppIso_apply] -- Porting note: rewrote proof below relative to mathlib3. by_cases n0 : 0 ≤ n · lift n to ℕ using n0 erw [comapDomain_single] simp only [Nat.cast_nonneg, Int.toNat_ofNat, ite_true, toFinsupp_monomial] · lift -n to ℕ using (neg_pos.mpr (not_le.mp n0)).le with m rw [toFinsupp_inj, if_neg n0] ext a have := ((not_le.mp n0).trans_le (Int.ofNat_zero_le a)).ne simp only [coeff_ofFinsupp, comapDomain_apply, Int.ofNat_eq_coe, coeff_zero, single_eq_of_ne this] set_option linter.uppercaseLean3 false in #align laurent_polynomial.trunc_C_mul_T LaurentPolynomial.trunc_C_mul_T @[simp] theorem leftInverse_trunc_toLaurent : Function.LeftInverse (trunc : R[T;T⁻¹] → R[X]) Polynomial.toLaurent := by refine fun f => f.induction_on' ?_ ?_ · intro f g hf hg simp only [hf, hg, _root_.map_add] · intro n r simp only [Polynomial.toLaurent_C_mul_T, trunc_C_mul_T, Int.natCast_nonneg, Int.toNat_natCast, if_true] #align laurent_polynomial.left_inverse_trunc_to_laurent LaurentPolynomial.leftInverse_trunc_toLaurent @[simp] theorem _root_.Polynomial.trunc_toLaurent (f : R[X]) : trunc (toLaurent f) = f := leftInverse_trunc_toLaurent _ #align polynomial.trunc_to_laurent Polynomial.trunc_toLaurent theorem _root_.Polynomial.toLaurent_injective : Function.Injective (Polynomial.toLaurent : R[X] → R[T;T⁻¹]) := leftInverse_trunc_toLaurent.injective #align polynomial.to_laurent_injective Polynomial.toLaurent_injective @[simp] theorem _root_.Polynomial.toLaurent_inj (f g : R[X]) : toLaurent f = toLaurent g ↔ f = g := ⟨fun h => Polynomial.toLaurent_injective h, congr_arg _⟩ #align polynomial.to_laurent_inj Polynomial.toLaurent_inj theorem _root_.Polynomial.toLaurent_ne_zero {f : R[X]} : f ≠ 0 ↔ toLaurent f ≠ 0 := (map_ne_zero_iff _ Polynomial.toLaurent_injective).symm #align polynomial.to_laurent_ne_zero Polynomial.toLaurent_ne_zero theorem exists_T_pow (f : R[T;T⁻¹]) : ∃ (n : ℕ) (f' : R[X]), toLaurent f' = f * T n := by refine f.induction_on' ?_ fun n a => ?_ <;> clear f · rintro f g ⟨m, fn, hf⟩ ⟨n, gn, hg⟩ refine ⟨m + n, fn * X ^ n + gn * X ^ m, ?_⟩ simp only [hf, hg, add_mul, add_comm (n : ℤ), map_add, map_mul, Polynomial.toLaurent_X_pow, mul_T_assoc, Int.ofNat_add] · cases' n with n n · exact ⟨0, Polynomial.C a * X ^ n, by simp⟩ · refine ⟨n + 1, Polynomial.C a, ?_⟩ simp only [Int.negSucc_eq, Polynomial.toLaurent_C, Int.ofNat_succ, mul_T_assoc, add_left_neg, T_zero, mul_one] set_option linter.uppercaseLean3 false in #align laurent_polynomial.exists_T_pow LaurentPolynomial.exists_T_pow @[elab_as_elim]
Mathlib/Algebra/Polynomial/Laurent.lean
418
423
theorem induction_on_mul_T {Q : R[T;T⁻¹] → Prop} (f : R[T;T⁻¹]) (Qf : ∀ {f : R[X]} {n : ℕ}, Q (toLaurent f * T (-n))) : Q f := by
rcases f.exists_T_pow with ⟨n, f', hf⟩ rw [← mul_one f, ← T_zero, ← Nat.cast_zero, ← Nat.sub_self n, Nat.cast_sub rfl.le, T_sub, ← mul_assoc, ← hf] exact Qf
import Mathlib.MeasureTheory.Integral.Lebesgue #align_import measure_theory.measure.giry_monad from "leanprover-community/mathlib"@"56f4cd1ef396e9fd389b5d8371ee9ad91d163625" noncomputable section open scoped Classical open ENNReal open scoped Classical open Set Filter variable {α β : Type*} namespace MeasureTheory namespace Measure variable [MeasurableSpace α] [MeasurableSpace β] instance instMeasurableSpace : MeasurableSpace (Measure α) := ⨆ (s : Set α) (_ : MeasurableSet s), (borel ℝ≥0∞).comap fun μ => μ s #align measure_theory.measure.measurable_space MeasureTheory.Measure.instMeasurableSpace theorem measurable_coe {s : Set α} (hs : MeasurableSet s) : Measurable fun μ : Measure α => μ s := Measurable.of_comap_le <| le_iSup_of_le s <| le_iSup_of_le hs <| le_rfl #align measure_theory.measure.measurable_coe MeasureTheory.Measure.measurable_coe theorem measurable_of_measurable_coe (f : β → Measure α) (h : ∀ (s : Set α), MeasurableSet s → Measurable fun b => f b s) : Measurable f := Measurable.of_le_map <| iSup₂_le fun s hs => MeasurableSpace.comap_le_iff_le_map.2 <| by rw [MeasurableSpace.map_comp]; exact h s hs #align measure_theory.measure.measurable_of_measurable_coe MeasureTheory.Measure.measurable_of_measurable_coe instance instMeasurableAdd₂ {α : Type*} {m : MeasurableSpace α} : MeasurableAdd₂ (Measure α) := by refine ⟨Measure.measurable_of_measurable_coe _ fun s hs => ?_⟩ simp_rw [Measure.coe_add, Pi.add_apply] refine Measurable.add ?_ ?_ · exact (Measure.measurable_coe hs).comp measurable_fst · exact (Measure.measurable_coe hs).comp measurable_snd #align measure_theory.measure.has_measurable_add₂ MeasureTheory.Measure.instMeasurableAdd₂ theorem measurable_measure {μ : α → Measure β} : Measurable μ ↔ ∀ (s : Set β), MeasurableSet s → Measurable fun b => μ b s := ⟨fun hμ _s hs => (measurable_coe hs).comp hμ, measurable_of_measurable_coe μ⟩ #align measure_theory.measure.measurable_measure MeasureTheory.Measure.measurable_measure theorem measurable_map (f : α → β) (hf : Measurable f) : Measurable fun μ : Measure α => map f μ := by refine measurable_of_measurable_coe _ fun s hs => ?_ simp_rw [map_apply hf hs] exact measurable_coe (hf hs) #align measure_theory.measure.measurable_map MeasureTheory.Measure.measurable_map theorem measurable_dirac : Measurable (Measure.dirac : α → Measure α) := by refine measurable_of_measurable_coe _ fun s hs => ?_ simp_rw [dirac_apply' _ hs] exact measurable_one.indicator hs #align measure_theory.measure.measurable_dirac MeasureTheory.Measure.measurable_dirac theorem measurable_lintegral {f : α → ℝ≥0∞} (hf : Measurable f) : Measurable fun μ : Measure α => ∫⁻ x, f x ∂μ := by simp only [lintegral_eq_iSup_eapprox_lintegral, hf, SimpleFunc.lintegral] refine measurable_iSup fun n => Finset.measurable_sum _ fun i _ => ?_ refine Measurable.const_mul ?_ _ exact measurable_coe ((SimpleFunc.eapprox f n).measurableSet_preimage _) #align measure_theory.measure.measurable_lintegral MeasureTheory.Measure.measurable_lintegral def join (m : Measure (Measure α)) : Measure α := Measure.ofMeasurable (fun s _ => ∫⁻ μ, μ s ∂m) (by simp only [measure_empty, lintegral_const, zero_mul]) (by intro f hf h simp_rw [measure_iUnion h hf] apply lintegral_tsum intro i; exact (measurable_coe (hf i)).aemeasurable) #align measure_theory.measure.join MeasureTheory.Measure.join @[simp] theorem join_apply {m : Measure (Measure α)} {s : Set α} (hs : MeasurableSet s) : join m s = ∫⁻ μ, μ s ∂m := Measure.ofMeasurable_apply s hs #align measure_theory.measure.join_apply MeasureTheory.Measure.join_apply @[simp] theorem join_zero : (0 : Measure (Measure α)).join = 0 := by ext1 s hs simp only [hs, join_apply, lintegral_zero_measure, coe_zero, Pi.zero_apply] #align measure_theory.measure.join_zero MeasureTheory.Measure.join_zero theorem measurable_join : Measurable (join : Measure (Measure α) → Measure α) := measurable_of_measurable_coe _ fun s hs => by simp only [join_apply hs]; exact measurable_lintegral (measurable_coe hs) #align measure_theory.measure.measurable_join MeasureTheory.Measure.measurable_join theorem lintegral_join {m : Measure (Measure α)} {f : α → ℝ≥0∞} (hf : Measurable f) : ∫⁻ x, f x ∂join m = ∫⁻ μ, ∫⁻ x, f x ∂μ ∂m := by simp_rw [lintegral_eq_iSup_eapprox_lintegral hf, SimpleFunc.lintegral, join_apply (SimpleFunc.measurableSet_preimage _ _)] suffices ∀ (s : ℕ → Finset ℝ≥0∞) (f : ℕ → ℝ≥0∞ → Measure α → ℝ≥0∞), (∀ n r, Measurable (f n r)) → Monotone (fun n μ => ∑ r ∈ s n, r * f n r μ) → ⨆ n, ∑ r ∈ s n, r * ∫⁻ μ, f n r μ ∂m = ∫⁻ μ, ⨆ n, ∑ r ∈ s n, r * f n r μ ∂m by refine this (fun n => SimpleFunc.range (SimpleFunc.eapprox f n)) (fun n r μ => μ (SimpleFunc.eapprox f n ⁻¹' {r})) ?_ ?_ · exact fun n r => measurable_coe (SimpleFunc.measurableSet_preimage _ _) · exact fun n m h μ => SimpleFunc.lintegral_mono (SimpleFunc.monotone_eapprox _ h) le_rfl intro s f hf hm rw [lintegral_iSup _ hm] swap · exact fun n => Finset.measurable_sum _ fun r _ => (hf _ _).const_mul _ congr funext n rw [lintegral_finset_sum (s n)] · simp_rw [lintegral_const_mul _ (hf _ _)] · exact fun r _ => (hf _ _).const_mul _ #align measure_theory.measure.lintegral_join MeasureTheory.Measure.lintegral_join def bind (m : Measure α) (f : α → Measure β) : Measure β := join (map f m) #align measure_theory.measure.bind MeasureTheory.Measure.bind @[simp] theorem bind_zero_left (f : α → Measure β) : bind 0 f = 0 := by simp [bind] #align measure_theory.measure.bind_zero_left MeasureTheory.Measure.bind_zero_left @[simp] theorem bind_zero_right (m : Measure α) : bind m (0 : α → Measure β) = 0 := by ext1 s hs simp only [bind, hs, join_apply, coe_zero, Pi.zero_apply] rw [lintegral_map (measurable_coe hs) measurable_zero] simp only [Pi.zero_apply, coe_zero, lintegral_const, zero_mul] #align measure_theory.measure.bind_zero_right MeasureTheory.Measure.bind_zero_right @[simp] theorem bind_zero_right' (m : Measure α) : bind m (fun _ => 0 : α → Measure β) = 0 := bind_zero_right m #align measure_theory.measure.bind_zero_right' MeasureTheory.Measure.bind_zero_right' @[simp] theorem bind_apply {m : Measure α} {f : α → Measure β} {s : Set β} (hs : MeasurableSet s) (hf : Measurable f) : bind m f s = ∫⁻ a, f a s ∂m := by rw [bind, join_apply hs, lintegral_map (measurable_coe hs) hf] #align measure_theory.measure.bind_apply MeasureTheory.Measure.bind_apply theorem measurable_bind' {g : α → Measure β} (hg : Measurable g) : Measurable fun m => bind m g := measurable_join.comp (measurable_map _ hg) #align measure_theory.measure.measurable_bind' MeasureTheory.Measure.measurable_bind' theorem lintegral_bind {m : Measure α} {μ : α → Measure β} {f : β → ℝ≥0∞} (hμ : Measurable μ) (hf : Measurable f) : ∫⁻ x, f x ∂bind m μ = ∫⁻ a, ∫⁻ x, f x ∂μ a ∂m := (lintegral_join hf).trans (lintegral_map (measurable_lintegral hf) hμ) #align measure_theory.measure.lintegral_bind MeasureTheory.Measure.lintegral_bind theorem bind_bind {γ} [MeasurableSpace γ] {m : Measure α} {f : α → Measure β} {g : β → Measure γ} (hf : Measurable f) (hg : Measurable g) : bind (bind m f) g = bind m fun a => bind (f a) g := by ext1 s hs erw [bind_apply hs hg, bind_apply hs ((measurable_bind' hg).comp hf), lintegral_bind hf ((measurable_coe hs).comp hg)] conv_rhs => enter [2, a]; erw [bind_apply hs hg] rfl #align measure_theory.measure.bind_bind MeasureTheory.Measure.bind_bind theorem bind_dirac {f : α → Measure β} (hf : Measurable f) (a : α) : bind (dirac a) f = f a := by ext1 s hs erw [bind_apply hs hf, lintegral_dirac' a ((measurable_coe hs).comp hf)] rfl #align measure_theory.measure.bind_dirac MeasureTheory.Measure.bind_dirac theorem dirac_bind {m : Measure α} : bind m dirac = m := by ext1 s hs simp only [bind_apply hs measurable_dirac, dirac_apply' _ hs, lintegral_indicator 1 hs, Pi.one_apply, lintegral_one, restrict_apply, MeasurableSet.univ, univ_inter] #align measure_theory.measure.dirac_bind MeasureTheory.Measure.dirac_bind theorem join_eq_bind (μ : Measure (Measure α)) : join μ = bind μ id := by rw [bind, map_id] #align measure_theory.measure.join_eq_bind MeasureTheory.Measure.join_eq_bind
Mathlib/MeasureTheory/Measure/GiryMonad.lean
214
219
theorem join_map_map {f : α → β} (hf : Measurable f) (μ : Measure (Measure α)) : join (map (map f) μ) = map f (join μ) := by
ext1 s hs rw [join_apply hs, map_apply hf hs, join_apply (hf hs), lintegral_map (measurable_coe hs) (measurable_map f hf)] simp_rw [map_apply hf hs]
import Mathlib.Algebra.Algebra.Subalgebra.Operations import Mathlib.Algebra.Ring.Fin import Mathlib.RingTheory.Ideal.Quotient #align_import ring_theory.ideal.quotient_operations from "leanprover-community/mathlib"@"b88d81c84530450a8989e918608e5960f015e6c8" universe u v w namespace Ideal open Function RingHom variable {R : Type u} {S : Type v} {F : Type w} [CommRing R] [Semiring S] @[simp] theorem map_quotient_self (I : Ideal R) : map (Quotient.mk I) I = ⊥ := eq_bot_iff.2 <| Ideal.map_le_iff_le_comap.2 fun _ hx => (Submodule.mem_bot (R ⧸ I)).2 <| Ideal.Quotient.eq_zero_iff_mem.2 hx #align ideal.map_quotient_self Ideal.map_quotient_self @[simp] theorem mk_ker {I : Ideal R} : ker (Quotient.mk I) = I := by ext rw [ker, mem_comap, Submodule.mem_bot, Quotient.eq_zero_iff_mem] #align ideal.mk_ker Ideal.mk_ker theorem map_mk_eq_bot_of_le {I J : Ideal R} (h : I ≤ J) : I.map (Quotient.mk J) = ⊥ := by rw [map_eq_bot_iff_le_ker, mk_ker] exact h #align ideal.map_mk_eq_bot_of_le Ideal.map_mk_eq_bot_of_le theorem ker_quotient_lift {I : Ideal R} (f : R →+* S) (H : I ≤ ker f) : ker (Ideal.Quotient.lift I f H) = f.ker.map (Quotient.mk I) := by apply Ideal.ext intro x constructor · intro hx obtain ⟨y, hy⟩ := Quotient.mk_surjective x rw [mem_ker, ← hy, Ideal.Quotient.lift_mk, ← mem_ker] at hx rw [← hy, mem_map_iff_of_surjective (Quotient.mk I) Quotient.mk_surjective] exact ⟨y, hx, rfl⟩ · intro hx rw [mem_map_iff_of_surjective (Quotient.mk I) Quotient.mk_surjective] at hx obtain ⟨y, hy⟩ := hx rw [mem_ker, ← hy.right, Ideal.Quotient.lift_mk] exact hy.left #align ideal.ker_quotient_lift Ideal.ker_quotient_lift lemma injective_lift_iff {I : Ideal R} {f : R →+* S} (H : ∀ (a : R), a ∈ I → f a = 0) : Injective (Quotient.lift I f H) ↔ ker f = I := by rw [injective_iff_ker_eq_bot, ker_quotient_lift, map_eq_bot_iff_le_ker, mk_ker] constructor · exact fun h ↦ le_antisymm h H · rintro rfl; rfl lemma ker_Pi_Quotient_mk {ι : Type*} (I : ι → Ideal R) : ker (Pi.ringHom fun i : ι ↦ Quotient.mk (I i)) = ⨅ i, I i := by simp [Pi.ker_ringHom, mk_ker] @[simp] theorem bot_quotient_isMaximal_iff (I : Ideal R) : (⊥ : Ideal (R ⧸ I)).IsMaximal ↔ I.IsMaximal := ⟨fun hI => mk_ker (I := I) ▸ comap_isMaximal_of_surjective (Quotient.mk I) Quotient.mk_surjective (K := ⊥) (H := hI), fun hI => by letI := Quotient.field I exact bot_isMaximal⟩ #align ideal.bot_quotient_is_maximal_iff Ideal.bot_quotient_isMaximal_iff @[simp] theorem mem_quotient_iff_mem_sup {I J : Ideal R} {x : R} : Quotient.mk I x ∈ J.map (Quotient.mk I) ↔ x ∈ J ⊔ I := by rw [← mem_comap, comap_map_of_surjective (Quotient.mk I) Quotient.mk_surjective, ← ker_eq_comap_bot, mk_ker] #align ideal.mem_quotient_iff_mem_sup Ideal.mem_quotient_iff_mem_sup theorem mem_quotient_iff_mem {I J : Ideal R} (hIJ : I ≤ J) {x : R} : Quotient.mk I x ∈ J.map (Quotient.mk I) ↔ x ∈ J := by rw [mem_quotient_iff_mem_sup, sup_eq_left.mpr hIJ] #align ideal.mem_quotient_iff_mem Ideal.mem_quotient_iff_mem section ChineseRemainder open Function Quotient Finset variable {ι : Type*} def quotientInfToPiQuotient (I : ι → Ideal R) : (R ⧸ ⨅ i, I i) →+* ∀ i, R ⧸ I i := Quotient.lift (⨅ i, I i) (Pi.ringHom fun i : ι ↦ Quotient.mk (I i)) (by simp [← RingHom.mem_ker, ker_Pi_Quotient_mk]) lemma quotientInfToPiQuotient_mk (I : ι → Ideal R) (x : R) : quotientInfToPiQuotient I (Quotient.mk _ x) = fun i : ι ↦ Quotient.mk (I i) x := rfl lemma quotientInfToPiQuotient_mk' (I : ι → Ideal R) (x : R) (i : ι) : quotientInfToPiQuotient I (Quotient.mk _ x) i = Quotient.mk (I i) x := rfl lemma quotientInfToPiQuotient_inj (I : ι → Ideal R) : Injective (quotientInfToPiQuotient I) := by rw [quotientInfToPiQuotient, injective_lift_iff, ker_Pi_Quotient_mk] lemma quotientInfToPiQuotient_surj [Finite ι] {I : ι → Ideal R} (hI : Pairwise fun i j => IsCoprime (I i) (I j)) : Surjective (quotientInfToPiQuotient I) := by classical cases nonempty_fintype ι intro g choose f hf using fun i ↦ mk_surjective (g i) have key : ∀ i, ∃ e : R, mk (I i) e = 1 ∧ ∀ j, j ≠ i → mk (I j) e = 0 := by intro i have hI' : ∀ j ∈ ({i} : Finset ι)ᶜ, IsCoprime (I i) (I j) := by intros j hj exact hI (by simpa [ne_comm, isCoprime_iff_add] using hj) rcases isCoprime_iff_exists.mp (isCoprime_biInf hI') with ⟨u, hu, e, he, hue⟩ replace he : ∀ j, j ≠ i → e ∈ I j := by simpa using he refine ⟨e, ?_, ?_⟩ · simp [eq_sub_of_add_eq' hue, map_sub, eq_zero_iff_mem.mpr hu] · exact fun j hj ↦ eq_zero_iff_mem.mpr (he j hj) choose e he using key use mk _ (∑ i, f i*e i) ext i rw [quotientInfToPiQuotient_mk', map_sum, Fintype.sum_eq_single i] · simp [(he i).1, hf] · intros j hj simp [(he j).2 i hj.symm] noncomputable def quotientInfRingEquivPiQuotient [Finite ι] (f : ι → Ideal R) (hf : Pairwise fun i j => IsCoprime (f i) (f j)) : (R ⧸ ⨅ i, f i) ≃+* ∀ i, R ⧸ f i := { Equiv.ofBijective _ ⟨quotientInfToPiQuotient_inj f, quotientInfToPiQuotient_surj hf⟩, quotientInfToPiQuotient f with } #align ideal.quotient_inf_ring_equiv_pi_quotient Ideal.quotientInfRingEquivPiQuotient lemma pi_quotient_surjective {R : Type*} [CommRing R] {ι : Type*} [Finite ι] {I : ι → Ideal R} (hf : Pairwise fun i j ↦ IsCoprime (I i) (I j)) (x : (i : ι) → R ⧸ I i) : ∃ r : R, ∀ i, r = x i := by obtain ⟨y, rfl⟩ := Ideal.quotientInfToPiQuotient_surj hf x obtain ⟨r, rfl⟩ := Ideal.Quotient.mk_surjective y exact ⟨r, fun i ↦ rfl⟩ -- variant of `IsDedekindDomain.exists_forall_sub_mem_ideal` which doesn't assume Dedekind domain! lemma exists_forall_sub_mem_ideal {R : Type*} [CommRing R] {ι : Type*} [Finite ι] {I : ι → Ideal R} (hI : Pairwise fun i j ↦ IsCoprime (I i) (I j)) (x : ι → R) : ∃ r : R, ∀ i, r - x i ∈ I i := by obtain ⟨y, hy⟩ := Ideal.pi_quotient_surjective hI (fun i ↦ x i) exact ⟨y, fun i ↦ (Submodule.Quotient.eq (I i)).mp <| hy i⟩ noncomputable def quotientInfEquivQuotientProd (I J : Ideal R) (coprime : IsCoprime I J) : R ⧸ I ⊓ J ≃+* (R ⧸ I) × R ⧸ J := let f : Fin 2 → Ideal R := ![I, J] have hf : Pairwise fun i j => IsCoprime (f i) (f j) := by intro i j h fin_cases i <;> fin_cases j <;> try contradiction · assumption · exact coprime.symm (Ideal.quotEquivOfEq (by simp [f, iInf, inf_comm])).trans <| (Ideal.quotientInfRingEquivPiQuotient f hf).trans <| RingEquiv.piFinTwo fun i => R ⧸ f i #align ideal.quotient_inf_equiv_quotient_prod Ideal.quotientInfEquivQuotientProd @[simp] theorem quotientInfEquivQuotientProd_fst (I J : Ideal R) (coprime : IsCoprime I J) (x : R ⧸ I ⊓ J) : (quotientInfEquivQuotientProd I J coprime x).fst = Ideal.Quotient.factor (I ⊓ J) I inf_le_left x := Quot.inductionOn x fun _ => rfl #align ideal.quotient_inf_equiv_quotient_prod_fst Ideal.quotientInfEquivQuotientProd_fst @[simp] theorem quotientInfEquivQuotientProd_snd (I J : Ideal R) (coprime : IsCoprime I J) (x : R ⧸ I ⊓ J) : (quotientInfEquivQuotientProd I J coprime x).snd = Ideal.Quotient.factor (I ⊓ J) J inf_le_right x := Quot.inductionOn x fun _ => rfl #align ideal.quotient_inf_equiv_quotient_prod_snd Ideal.quotientInfEquivQuotientProd_snd @[simp] theorem fst_comp_quotientInfEquivQuotientProd (I J : Ideal R) (coprime : IsCoprime I J) : (RingHom.fst _ _).comp (quotientInfEquivQuotientProd I J coprime : R ⧸ I ⊓ J →+* (R ⧸ I) × R ⧸ J) = Ideal.Quotient.factor (I ⊓ J) I inf_le_left := by apply Quotient.ringHom_ext; ext; rfl #align ideal.fst_comp_quotient_inf_equiv_quotient_prod Ideal.fst_comp_quotientInfEquivQuotientProd @[simp] theorem snd_comp_quotientInfEquivQuotientProd (I J : Ideal R) (coprime : IsCoprime I J) : (RingHom.snd _ _).comp (quotientInfEquivQuotientProd I J coprime : R ⧸ I ⊓ J →+* (R ⧸ I) × R ⧸ J) = Ideal.Quotient.factor (I ⊓ J) J inf_le_right := by apply Quotient.ringHom_ext; ext; rfl #align ideal.snd_comp_quotient_inf_equiv_quotient_prod Ideal.snd_comp_quotientInfEquivQuotientProd noncomputable def quotientMulEquivQuotientProd (I J : Ideal R) (coprime : IsCoprime I J) : R ⧸ I * J ≃+* (R ⧸ I) × R ⧸ J := Ideal.quotEquivOfEq (inf_eq_mul_of_isCoprime coprime).symm |>.trans <| Ideal.quotientInfEquivQuotientProd I J coprime #align ideal.quotient_mul_equiv_quotient_prod Ideal.quotientMulEquivQuotientProd @[simp] theorem quotientMulEquivQuotientProd_fst (I J : Ideal R) (coprime : IsCoprime I J) (x : R ⧸ I * J) : (quotientMulEquivQuotientProd I J coprime x).fst = Ideal.Quotient.factor (I * J) I mul_le_right x := Quot.inductionOn x fun _ => rfl @[simp] theorem quotientMulEquivQuotientProd_snd (I J : Ideal R) (coprime : IsCoprime I J) (x : R ⧸ I * J) : (quotientMulEquivQuotientProd I J coprime x).snd = Ideal.Quotient.factor (I * J) J mul_le_left x := Quot.inductionOn x fun _ => rfl @[simp]
Mathlib/RingTheory/Ideal/QuotientOperations.lean
329
333
theorem fst_comp_quotientMulEquivQuotientProd (I J : Ideal R) (coprime : IsCoprime I J) : (RingHom.fst _ _).comp (quotientMulEquivQuotientProd I J coprime : R ⧸ I * J →+* (R ⧸ I) × R ⧸ J) = Ideal.Quotient.factor (I * J) I mul_le_right := by
apply Quotient.ringHom_ext; ext; rfl
import Mathlib.Algebra.Group.Aut import Mathlib.Algebra.Group.Subgroup.Basic import Mathlib.Logic.Function.Basic #align_import group_theory.semidirect_product from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" variable (N : Type*) (G : Type*) {H : Type*} [Group N] [Group G] [Group H] @[ext] structure SemidirectProduct (φ : G →* MulAut N) where left : N right : G deriving DecidableEq #align semidirect_product SemidirectProduct -- Porting note: these lemmas are autogenerated by the inductive definition and are not -- in simple form due to the existence of mk_eq_inl_mul_inr attribute [nolint simpNF] SemidirectProduct.mk.injEq attribute [nolint simpNF] SemidirectProduct.mk.sizeOf_spec -- Porting note: unknown attribute -- attribute [pp_using_anonymous_constructor] SemidirectProduct @[inherit_doc] notation:35 N " ⋊[" φ:35 "] " G:35 => SemidirectProduct N G φ namespace SemidirectProduct variable {N G} variable {φ : G →* MulAut N} instance : Mul (SemidirectProduct N G φ) where mul a b := ⟨a.1 * φ a.2 b.1, a.2 * b.2⟩ lemma mul_def (a b : SemidirectProduct N G φ) : a * b = ⟨a.1 * φ a.2 b.1, a.2 * b.2⟩ := rfl @[simp] theorem mul_left (a b : N ⋊[φ] G) : (a * b).left = a.left * φ a.right b.left := rfl #align semidirect_product.mul_left SemidirectProduct.mul_left @[simp] theorem mul_right (a b : N ⋊[φ] G) : (a * b).right = a.right * b.right := rfl #align semidirect_product.mul_right SemidirectProduct.mul_right instance : One (SemidirectProduct N G φ) where one := ⟨1, 1⟩ @[simp] theorem one_left : (1 : N ⋊[φ] G).left = 1 := rfl #align semidirect_product.one_left SemidirectProduct.one_left @[simp] theorem one_right : (1 : N ⋊[φ] G).right = 1 := rfl #align semidirect_product.one_right SemidirectProduct.one_right instance : Inv (SemidirectProduct N G φ) where inv x := ⟨φ x.2⁻¹ x.1⁻¹, x.2⁻¹⟩ @[simp] theorem inv_left (a : N ⋊[φ] G) : a⁻¹.left = φ a.right⁻¹ a.left⁻¹ := rfl #align semidirect_product.inv_left SemidirectProduct.inv_left @[simp] theorem inv_right (a : N ⋊[φ] G) : a⁻¹.right = a.right⁻¹ := rfl #align semidirect_product.inv_right SemidirectProduct.inv_right instance : Group (N ⋊[φ] G) where mul_assoc a b c := SemidirectProduct.ext _ _ (by simp [mul_assoc]) (by simp [mul_assoc]) one_mul a := SemidirectProduct.ext _ _ (by simp) (one_mul a.2) mul_one a := SemidirectProduct.ext _ _ (by simp) (mul_one _) mul_left_inv a := SemidirectProduct.ext _ _ (by simp) (by simp) instance : Inhabited (N ⋊[φ] G) := ⟨1⟩ def inl : N →* N ⋊[φ] G where toFun n := ⟨n, 1⟩ map_one' := rfl map_mul' := by intros; ext <;> simp only [mul_left, map_one, MulAut.one_apply, mul_right, mul_one] #align semidirect_product.inl SemidirectProduct.inl @[simp] theorem left_inl (n : N) : (inl n : N ⋊[φ] G).left = n := rfl #align semidirect_product.left_inl SemidirectProduct.left_inl @[simp] theorem right_inl (n : N) : (inl n : N ⋊[φ] G).right = 1 := rfl #align semidirect_product.right_inl SemidirectProduct.right_inl theorem inl_injective : Function.Injective (inl : N → N ⋊[φ] G) := Function.injective_iff_hasLeftInverse.2 ⟨left, left_inl⟩ #align semidirect_product.inl_injective SemidirectProduct.inl_injective @[simp] theorem inl_inj {n₁ n₂ : N} : (inl n₁ : N ⋊[φ] G) = inl n₂ ↔ n₁ = n₂ := inl_injective.eq_iff #align semidirect_product.inl_inj SemidirectProduct.inl_inj def inr : G →* N ⋊[φ] G where toFun g := ⟨1, g⟩ map_one' := rfl map_mul' := by intros; ext <;> simp #align semidirect_product.inr SemidirectProduct.inr @[simp] theorem left_inr (g : G) : (inr g : N ⋊[φ] G).left = 1 := rfl #align semidirect_product.left_inr SemidirectProduct.left_inr @[simp] theorem right_inr (g : G) : (inr g : N ⋊[φ] G).right = g := rfl #align semidirect_product.right_inr SemidirectProduct.right_inr theorem inr_injective : Function.Injective (inr : G → N ⋊[φ] G) := Function.injective_iff_hasLeftInverse.2 ⟨right, right_inr⟩ #align semidirect_product.inr_injective SemidirectProduct.inr_injective @[simp] theorem inr_inj {g₁ g₂ : G} : (inr g₁ : N ⋊[φ] G) = inr g₂ ↔ g₁ = g₂ := inr_injective.eq_iff #align semidirect_product.inr_inj SemidirectProduct.inr_inj theorem inl_aut (g : G) (n : N) : (inl (φ g n) : N ⋊[φ] G) = inr g * inl n * inr g⁻¹ := by ext <;> simp #align semidirect_product.inl_aut SemidirectProduct.inl_aut theorem inl_aut_inv (g : G) (n : N) : (inl ((φ g)⁻¹ n) : N ⋊[φ] G) = inr g⁻¹ * inl n * inr g := by rw [← MonoidHom.map_inv, inl_aut, inv_inv] #align semidirect_product.inl_aut_inv SemidirectProduct.inl_aut_inv @[simp] theorem mk_eq_inl_mul_inr (g : G) (n : N) : (⟨n, g⟩ : N ⋊[φ] G) = inl n * inr g := by ext <;> simp #align semidirect_product.mk_eq_inl_mul_inr SemidirectProduct.mk_eq_inl_mul_inr @[simp] theorem inl_left_mul_inr_right (x : N ⋊[φ] G) : inl x.left * inr x.right = x := by ext <;> simp #align semidirect_product.inl_left_mul_inr_right SemidirectProduct.inl_left_mul_inr_right def rightHom : N ⋊[φ] G →* G where toFun := SemidirectProduct.right map_one' := rfl map_mul' _ _ := rfl #align semidirect_product.right_hom SemidirectProduct.rightHom @[simp] theorem rightHom_eq_right : (rightHom : N ⋊[φ] G → G) = right := rfl #align semidirect_product.right_hom_eq_right SemidirectProduct.rightHom_eq_right @[simp] theorem rightHom_comp_inl : (rightHom : N ⋊[φ] G →* G).comp inl = 1 := by ext; simp [rightHom] #align semidirect_product.right_hom_comp_inl SemidirectProduct.rightHom_comp_inl @[simp] theorem rightHom_comp_inr : (rightHom : N ⋊[φ] G →* G).comp inr = MonoidHom.id _ := by ext; simp [rightHom] #align semidirect_product.right_hom_comp_inr SemidirectProduct.rightHom_comp_inr @[simp] theorem rightHom_inl (n : N) : rightHom (inl n : N ⋊[φ] G) = 1 := by simp [rightHom] #align semidirect_product.right_hom_inl SemidirectProduct.rightHom_inl @[simp] theorem rightHom_inr (g : G) : rightHom (inr g : N ⋊[φ] G) = g := by simp [rightHom] #align semidirect_product.right_hom_inr SemidirectProduct.rightHom_inr theorem rightHom_surjective : Function.Surjective (rightHom : N ⋊[φ] G → G) := Function.surjective_iff_hasRightInverse.2 ⟨inr, rightHom_inr⟩ #align semidirect_product.right_hom_surjective SemidirectProduct.rightHom_surjective theorem range_inl_eq_ker_rightHom : (inl : N →* N ⋊[φ] G).range = rightHom.ker := le_antisymm (fun _ ↦ by simp (config := { contextual := true }) [MonoidHom.mem_ker, eq_comm]) fun x hx ↦ ⟨x.left, by ext <;> simp_all [MonoidHom.mem_ker]⟩ #align semidirect_product.range_inl_eq_ker_right_hom SemidirectProduct.range_inl_eq_ker_rightHom section lift variable (f₁ : N →* H) (f₂ : G →* H) (h : ∀ g, f₁.comp (φ g).toMonoidHom = (MulAut.conj (f₂ g)).toMonoidHom.comp f₁) def lift (f₁ : N →* H) (f₂ : G →* H) (h : ∀ g, f₁.comp (φ g).toMonoidHom = (MulAut.conj (f₂ g)).toMonoidHom.comp f₁) : N ⋊[φ] G →* H where toFun a := f₁ a.1 * f₂ a.2 map_one' := by simp map_mul' a b := by have := fun n g ↦ DFunLike.ext_iff.1 (h n) g simp only [MulAut.conj_apply, MonoidHom.comp_apply, MulEquiv.coe_toMonoidHom] at this simp only [mul_left, mul_right, map_mul, this, mul_assoc, inv_mul_cancel_left] #align semidirect_product.lift SemidirectProduct.lift @[simp] theorem lift_inl (n : N) : lift f₁ f₂ h (inl n) = f₁ n := by simp [lift] #align semidirect_product.lift_inl SemidirectProduct.lift_inl @[simp] theorem lift_comp_inl : (lift f₁ f₂ h).comp inl = f₁ := by ext; simp #align semidirect_product.lift_comp_inl SemidirectProduct.lift_comp_inl @[simp] theorem lift_inr (g : G) : lift f₁ f₂ h (inr g) = f₂ g := by simp [lift] #align semidirect_product.lift_inr SemidirectProduct.lift_inr @[simp] theorem lift_comp_inr : (lift f₁ f₂ h).comp inr = f₂ := by ext; simp #align semidirect_product.lift_comp_inr SemidirectProduct.lift_comp_inr theorem lift_unique (F : N ⋊[φ] G →* H) : F = lift (F.comp inl) (F.comp inr) fun _ ↦ by ext; simp [inl_aut] := by rw [DFunLike.ext_iff] simp only [lift, MonoidHom.comp_apply, MonoidHom.coe_mk, OneHom.coe_mk, ← map_mul, inl_left_mul_inr_right, forall_const] #align semidirect_product.lift_unique SemidirectProduct.lift_unique
Mathlib/GroupTheory/SemidirectProduct.lean
252
255
theorem hom_ext {f g : N ⋊[φ] G →* H} (hl : f.comp inl = g.comp inl) (hr : f.comp inr = g.comp inr) : f = g := by
rw [lift_unique f, lift_unique g] simp only [*]
import Mathlib.CategoryTheory.Equivalence #align_import algebraic_topology.dold_kan.compatibility from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504" open CategoryTheory CategoryTheory.Category namespace AlgebraicTopology namespace DoldKan namespace Compatibility variable {A A' B B' : Type*} [Category A] [Category A'] [Category B] [Category B'] (eA : A ≌ A') (eB : B ≌ B') (e' : A' ≌ B') {F : A ⥤ B'} (hF : eA.functor ⋙ e'.functor ≅ F) {G : B ⥤ A} (hG : eB.functor ⋙ e'.inverse ≅ G ⋙ eA.functor) @[simps! functor inverse unitIso_hom_app] def equivalence₀ : A ≌ B' := eA.trans e' #align algebraic_topology.dold_kan.compatibility.equivalence₀ AlgebraicTopology.DoldKan.Compatibility.equivalence₀ variable {eA} {e'} @[simps! functor] def equivalence₁ : A ≌ B' := (equivalence₀ eA e').changeFunctor hF #align algebraic_topology.dold_kan.compatibility.equivalence₁ AlgebraicTopology.DoldKan.Compatibility.equivalence₁ theorem equivalence₁_inverse : (equivalence₁ hF).inverse = e'.inverse ⋙ eA.inverse := rfl #align algebraic_topology.dold_kan.compatibility.equivalence₁_inverse AlgebraicTopology.DoldKan.Compatibility.equivalence₁_inverse @[simps!] def equivalence₁CounitIso : (e'.inverse ⋙ eA.inverse) ⋙ F ≅ 𝟭 B' := calc (e'.inverse ⋙ eA.inverse) ⋙ F ≅ (e'.inverse ⋙ eA.inverse) ⋙ eA.functor ⋙ e'.functor := isoWhiskerLeft _ hF.symm _ ≅ e'.inverse ⋙ (eA.inverse ⋙ eA.functor) ⋙ e'.functor := Iso.refl _ _ ≅ e'.inverse ⋙ 𝟭 _ ⋙ e'.functor := isoWhiskerLeft _ (isoWhiskerRight eA.counitIso _) _ ≅ e'.inverse ⋙ e'.functor := Iso.refl _ _ ≅ 𝟭 B' := e'.counitIso #align algebraic_topology.dold_kan.compatibility.equivalence₁_counit_iso AlgebraicTopology.DoldKan.Compatibility.equivalence₁CounitIso theorem equivalence₁CounitIso_eq : (equivalence₁ hF).counitIso = equivalence₁CounitIso hF := by ext Y simp [equivalence₁, equivalence₀] #align algebraic_topology.dold_kan.compatibility.equivalence₁_counit_iso_eq AlgebraicTopology.DoldKan.Compatibility.equivalence₁CounitIso_eq @[simps!] def equivalence₁UnitIso : 𝟭 A ≅ F ⋙ e'.inverse ⋙ eA.inverse := calc 𝟭 A ≅ eA.functor ⋙ eA.inverse := eA.unitIso _ ≅ eA.functor ⋙ 𝟭 A' ⋙ eA.inverse := Iso.refl _ _ ≅ eA.functor ⋙ (e'.functor ⋙ e'.inverse) ⋙ eA.inverse := isoWhiskerLeft _ (isoWhiskerRight e'.unitIso _) _ ≅ (eA.functor ⋙ e'.functor) ⋙ e'.inverse ⋙ eA.inverse := Iso.refl _ _ ≅ F ⋙ e'.inverse ⋙ eA.inverse := isoWhiskerRight hF _ #align algebraic_topology.dold_kan.compatibility.equivalence₁_unit_iso AlgebraicTopology.DoldKan.Compatibility.equivalence₁UnitIso theorem equivalence₁UnitIso_eq : (equivalence₁ hF).unitIso = equivalence₁UnitIso hF := by ext X simp [equivalence₁] #align algebraic_topology.dold_kan.compatibility.equivalence₁_unit_iso_eq AlgebraicTopology.DoldKan.Compatibility.equivalence₁UnitIso_eq @[simps! functor] def equivalence₂ : A ≌ B := (equivalence₁ hF).trans eB.symm #align algebraic_topology.dold_kan.compatibility.equivalence₂ AlgebraicTopology.DoldKan.Compatibility.equivalence₂ theorem equivalence₂_inverse : (equivalence₂ eB hF).inverse = eB.functor ⋙ e'.inverse ⋙ eA.inverse := rfl #align algebraic_topology.dold_kan.compatibility.equivalence₂_inverse AlgebraicTopology.DoldKan.Compatibility.equivalence₂_inverse @[simps!] def equivalence₂CounitIso : (eB.functor ⋙ e'.inverse ⋙ eA.inverse) ⋙ F ⋙ eB.inverse ≅ 𝟭 B := calc (eB.functor ⋙ e'.inverse ⋙ eA.inverse) ⋙ F ⋙ eB.inverse ≅ eB.functor ⋙ (e'.inverse ⋙ eA.inverse ⋙ F) ⋙ eB.inverse := Iso.refl _ _ ≅ eB.functor ⋙ 𝟭 _ ⋙ eB.inverse := isoWhiskerLeft _ (isoWhiskerRight (equivalence₁CounitIso hF) _) _ ≅ eB.functor ⋙ eB.inverse := Iso.refl _ _ ≅ 𝟭 B := eB.unitIso.symm #align algebraic_topology.dold_kan.compatibility.equivalence₂_counit_iso AlgebraicTopology.DoldKan.Compatibility.equivalence₂CounitIso
Mathlib/AlgebraicTopology/DoldKan/Compatibility.lean
133
138
theorem equivalence₂CounitIso_eq : (equivalence₂ eB hF).counitIso = equivalence₂CounitIso eB hF := by
ext Y' dsimp [equivalence₂, Iso.refl] simp only [equivalence₁CounitIso_eq, equivalence₂CounitIso_hom_app, equivalence₁CounitIso_hom_app, Functor.map_comp, assoc]
import Mathlib.LinearAlgebra.Dimension.Free import Mathlib.Algebra.Module.Torsion #align_import linear_algebra.dimension from "leanprover-community/mathlib"@"47a5f8186becdbc826190ced4312f8199f9db6a5" noncomputable section universe u v v' u₁' w w' variable {R S : Type u} {M : Type v} {M' : Type v'} {M₁ : Type v} variable {ι : Type w} {ι' : Type w'} {η : Type u₁'} {φ : η → Type*} open Cardinal Basis Submodule Function Set FiniteDimensional DirectSum variable [Ring R] [CommRing S] [AddCommGroup M] [AddCommGroup M'] [AddCommGroup M₁] variable [Module R M] [Module R M'] [Module R M₁] section Finsupp variable (R M M') variable [StrongRankCondition R] [Module.Free R M] [Module.Free R M'] open Module.Free @[simp] theorem rank_finsupp (ι : Type w) : Module.rank R (ι →₀ M) = Cardinal.lift.{v} #ι * Cardinal.lift.{w} (Module.rank R M) := by obtain ⟨⟨_, bs⟩⟩ := Module.Free.exists_basis (R := R) (M := M) rw [← bs.mk_eq_rank'', ← (Finsupp.basis fun _ : ι => bs).mk_eq_rank'', Cardinal.mk_sigma, Cardinal.sum_const] #align rank_finsupp rank_finsupp theorem rank_finsupp' (ι : Type v) : Module.rank R (ι →₀ M) = #ι * Module.rank R M := by simp [rank_finsupp] #align rank_finsupp' rank_finsupp' -- Porting note, this should not be `@[simp]`, as simp can prove it. -- @[simp] theorem rank_finsupp_self (ι : Type w) : Module.rank R (ι →₀ R) = Cardinal.lift.{u} #ι := by simp [rank_finsupp] #align rank_finsupp_self rank_finsupp_self theorem rank_finsupp_self' {ι : Type u} : Module.rank R (ι →₀ R) = #ι := by simp #align rank_finsupp_self' rank_finsupp_self' @[simp] theorem rank_directSum {ι : Type v} (M : ι → Type w) [∀ i : ι, AddCommGroup (M i)] [∀ i : ι, Module R (M i)] [∀ i : ι, Module.Free R (M i)] : Module.rank R (⨁ i, M i) = Cardinal.sum fun i => Module.rank R (M i) := by let B i := chooseBasis R (M i) let b : Basis _ R (⨁ i, M i) := DFinsupp.basis fun i => B i simp [← b.mk_eq_rank'', fun i => (B i).mk_eq_rank''] #align rank_direct_sum rank_directSum @[simp] theorem rank_matrix (m : Type v) (n : Type w) [Finite m] [Finite n] : Module.rank R (Matrix m n R) = Cardinal.lift.{max v w u, v} #m * Cardinal.lift.{max v w u, w} #n := by cases nonempty_fintype m cases nonempty_fintype n have h := (Matrix.stdBasis R m n).mk_eq_rank rw [← lift_lift.{max v w u, max v w}, lift_inj] at h simpa using h.symm #align rank_matrix rank_matrix @[simp high] theorem rank_matrix' (m n : Type v) [Finite m] [Finite n] : Module.rank R (Matrix m n R) = Cardinal.lift.{u} (#m * #n) := by rw [rank_matrix, lift_mul, lift_umax.{v, u}] #align rank_matrix' rank_matrix' -- @[simp] -- Porting note (#10618): simp can prove this theorem rank_matrix'' (m n : Type u) [Finite m] [Finite n] : Module.rank R (Matrix m n R) = #m * #n := by simp #align rank_matrix'' rank_matrix'' variable [Module.Finite R M] [Module.Finite R M'] open Fintype section SubalgebraRank open Module variable {F E : Type*} [CommRing F] [Ring E] [Algebra F E] @[simp] theorem Subalgebra.rank_toSubmodule (S : Subalgebra F E) : Module.rank F (Subalgebra.toSubmodule S) = Module.rank F S := rfl #align subalgebra.rank_to_submodule Subalgebra.rank_toSubmodule @[simp] theorem Subalgebra.finrank_toSubmodule (S : Subalgebra F E) : finrank F (Subalgebra.toSubmodule S) = finrank F S := rfl #align subalgebra.finrank_to_submodule Subalgebra.finrank_toSubmodule theorem subalgebra_top_rank_eq_submodule_top_rank : Module.rank F (⊤ : Subalgebra F E) = Module.rank F (⊤ : Submodule F E) := by rw [← Algebra.top_toSubmodule] rfl #align subalgebra_top_rank_eq_submodule_top_rank subalgebra_top_rank_eq_submodule_top_rank theorem subalgebra_top_finrank_eq_submodule_top_finrank : finrank F (⊤ : Subalgebra F E) = finrank F (⊤ : Submodule F E) := by rw [← Algebra.top_toSubmodule] rfl #align subalgebra_top_finrank_eq_submodule_top_finrank subalgebra_top_finrank_eq_submodule_top_finrank
Mathlib/LinearAlgebra/Dimension/Constructions.lean
550
552
theorem Subalgebra.rank_top : Module.rank F (⊤ : Subalgebra F E) = Module.rank F E := by
rw [subalgebra_top_rank_eq_submodule_top_rank] exact _root_.rank_top F E
import Mathlib.Analysis.SpecialFunctions.Exp import Mathlib.Tactic.Positivity.Core import Mathlib.Algebra.Ring.NegOnePow #align_import analysis.special_functions.trigonometric.basic from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" noncomputable section open scoped Classical open Topology Filter Set namespace Real open Real @[simp] theorem sin_pi : sin π = 0 := by rw [← mul_div_cancel_left₀ π (two_ne_zero' ℝ), two_mul, add_div, sin_add, cos_pi_div_two]; simp #align real.sin_pi Real.sin_pi @[simp] theorem cos_pi : cos π = -1 := by rw [← mul_div_cancel_left₀ π (two_ne_zero' ℝ), mul_div_assoc, cos_two_mul, cos_pi_div_two] norm_num #align real.cos_pi Real.cos_pi @[simp] theorem sin_two_pi : sin (2 * π) = 0 := by simp [two_mul, sin_add] #align real.sin_two_pi Real.sin_two_pi @[simp] theorem cos_two_pi : cos (2 * π) = 1 := by simp [two_mul, cos_add] #align real.cos_two_pi Real.cos_two_pi theorem sin_antiperiodic : Function.Antiperiodic sin π := by simp [sin_add] #align real.sin_antiperiodic Real.sin_antiperiodic theorem sin_periodic : Function.Periodic sin (2 * π) := sin_antiperiodic.periodic_two_mul #align real.sin_periodic Real.sin_periodic @[simp] theorem sin_add_pi (x : ℝ) : sin (x + π) = -sin x := sin_antiperiodic x #align real.sin_add_pi Real.sin_add_pi @[simp] theorem sin_add_two_pi (x : ℝ) : sin (x + 2 * π) = sin x := sin_periodic x #align real.sin_add_two_pi Real.sin_add_two_pi @[simp] theorem sin_sub_pi (x : ℝ) : sin (x - π) = -sin x := sin_antiperiodic.sub_eq x #align real.sin_sub_pi Real.sin_sub_pi @[simp] theorem sin_sub_two_pi (x : ℝ) : sin (x - 2 * π) = sin x := sin_periodic.sub_eq x #align real.sin_sub_two_pi Real.sin_sub_two_pi @[simp] theorem sin_pi_sub (x : ℝ) : sin (π - x) = sin x := neg_neg (sin x) ▸ sin_neg x ▸ sin_antiperiodic.sub_eq' #align real.sin_pi_sub Real.sin_pi_sub @[simp] theorem sin_two_pi_sub (x : ℝ) : sin (2 * π - x) = -sin x := sin_neg x ▸ sin_periodic.sub_eq' #align real.sin_two_pi_sub Real.sin_two_pi_sub @[simp] theorem sin_nat_mul_pi (n : ℕ) : sin (n * π) = 0 := sin_antiperiodic.nat_mul_eq_of_eq_zero sin_zero n #align real.sin_nat_mul_pi Real.sin_nat_mul_pi @[simp] theorem sin_int_mul_pi (n : ℤ) : sin (n * π) = 0 := sin_antiperiodic.int_mul_eq_of_eq_zero sin_zero n #align real.sin_int_mul_pi Real.sin_int_mul_pi @[simp] theorem sin_add_nat_mul_two_pi (x : ℝ) (n : ℕ) : sin (x + n * (2 * π)) = sin x := sin_periodic.nat_mul n x #align real.sin_add_nat_mul_two_pi Real.sin_add_nat_mul_two_pi @[simp] theorem sin_add_int_mul_two_pi (x : ℝ) (n : ℤ) : sin (x + n * (2 * π)) = sin x := sin_periodic.int_mul n x #align real.sin_add_int_mul_two_pi Real.sin_add_int_mul_two_pi @[simp] theorem sin_sub_nat_mul_two_pi (x : ℝ) (n : ℕ) : sin (x - n * (2 * π)) = sin x := sin_periodic.sub_nat_mul_eq n #align real.sin_sub_nat_mul_two_pi Real.sin_sub_nat_mul_two_pi @[simp] theorem sin_sub_int_mul_two_pi (x : ℝ) (n : ℤ) : sin (x - n * (2 * π)) = sin x := sin_periodic.sub_int_mul_eq n #align real.sin_sub_int_mul_two_pi Real.sin_sub_int_mul_two_pi @[simp] theorem sin_nat_mul_two_pi_sub (x : ℝ) (n : ℕ) : sin (n * (2 * π) - x) = -sin x := sin_neg x ▸ sin_periodic.nat_mul_sub_eq n #align real.sin_nat_mul_two_pi_sub Real.sin_nat_mul_two_pi_sub @[simp] theorem sin_int_mul_two_pi_sub (x : ℝ) (n : ℤ) : sin (n * (2 * π) - x) = -sin x := sin_neg x ▸ sin_periodic.int_mul_sub_eq n #align real.sin_int_mul_two_pi_sub Real.sin_int_mul_two_pi_sub theorem sin_add_int_mul_pi (x : ℝ) (n : ℤ) : sin (x + n * π) = (-1) ^ n * sin x := n.coe_negOnePow ℝ ▸ sin_antiperiodic.add_int_mul_eq n theorem sin_add_nat_mul_pi (x : ℝ) (n : ℕ) : sin (x + n * π) = (-1) ^ n * sin x := sin_antiperiodic.add_nat_mul_eq n theorem sin_sub_int_mul_pi (x : ℝ) (n : ℤ) : sin (x - n * π) = (-1) ^ n * sin x := n.coe_negOnePow ℝ ▸ sin_antiperiodic.sub_int_mul_eq n theorem sin_sub_nat_mul_pi (x : ℝ) (n : ℕ) : sin (x - n * π) = (-1) ^ n * sin x := sin_antiperiodic.sub_nat_mul_eq n theorem sin_int_mul_pi_sub (x : ℝ) (n : ℤ) : sin (n * π - x) = -((-1) ^ n * sin x) := by simpa only [sin_neg, mul_neg, Int.coe_negOnePow] using sin_antiperiodic.int_mul_sub_eq n theorem sin_nat_mul_pi_sub (x : ℝ) (n : ℕ) : sin (n * π - x) = -((-1) ^ n * sin x) := by simpa only [sin_neg, mul_neg] using sin_antiperiodic.nat_mul_sub_eq n theorem cos_antiperiodic : Function.Antiperiodic cos π := by simp [cos_add] #align real.cos_antiperiodic Real.cos_antiperiodic theorem cos_periodic : Function.Periodic cos (2 * π) := cos_antiperiodic.periodic_two_mul #align real.cos_periodic Real.cos_periodic @[simp] theorem cos_add_pi (x : ℝ) : cos (x + π) = -cos x := cos_antiperiodic x #align real.cos_add_pi Real.cos_add_pi @[simp] theorem cos_add_two_pi (x : ℝ) : cos (x + 2 * π) = cos x := cos_periodic x #align real.cos_add_two_pi Real.cos_add_two_pi @[simp] theorem cos_sub_pi (x : ℝ) : cos (x - π) = -cos x := cos_antiperiodic.sub_eq x #align real.cos_sub_pi Real.cos_sub_pi @[simp] theorem cos_sub_two_pi (x : ℝ) : cos (x - 2 * π) = cos x := cos_periodic.sub_eq x #align real.cos_sub_two_pi Real.cos_sub_two_pi @[simp] theorem cos_pi_sub (x : ℝ) : cos (π - x) = -cos x := cos_neg x ▸ cos_antiperiodic.sub_eq' #align real.cos_pi_sub Real.cos_pi_sub @[simp] theorem cos_two_pi_sub (x : ℝ) : cos (2 * π - x) = cos x := cos_neg x ▸ cos_periodic.sub_eq' #align real.cos_two_pi_sub Real.cos_two_pi_sub @[simp] theorem cos_nat_mul_two_pi (n : ℕ) : cos (n * (2 * π)) = 1 := (cos_periodic.nat_mul_eq n).trans cos_zero #align real.cos_nat_mul_two_pi Real.cos_nat_mul_two_pi @[simp] theorem cos_int_mul_two_pi (n : ℤ) : cos (n * (2 * π)) = 1 := (cos_periodic.int_mul_eq n).trans cos_zero #align real.cos_int_mul_two_pi Real.cos_int_mul_two_pi @[simp] theorem cos_add_nat_mul_two_pi (x : ℝ) (n : ℕ) : cos (x + n * (2 * π)) = cos x := cos_periodic.nat_mul n x #align real.cos_add_nat_mul_two_pi Real.cos_add_nat_mul_two_pi @[simp] theorem cos_add_int_mul_two_pi (x : ℝ) (n : ℤ) : cos (x + n * (2 * π)) = cos x := cos_periodic.int_mul n x #align real.cos_add_int_mul_two_pi Real.cos_add_int_mul_two_pi @[simp] theorem cos_sub_nat_mul_two_pi (x : ℝ) (n : ℕ) : cos (x - n * (2 * π)) = cos x := cos_periodic.sub_nat_mul_eq n #align real.cos_sub_nat_mul_two_pi Real.cos_sub_nat_mul_two_pi @[simp] theorem cos_sub_int_mul_two_pi (x : ℝ) (n : ℤ) : cos (x - n * (2 * π)) = cos x := cos_periodic.sub_int_mul_eq n #align real.cos_sub_int_mul_two_pi Real.cos_sub_int_mul_two_pi @[simp] theorem cos_nat_mul_two_pi_sub (x : ℝ) (n : ℕ) : cos (n * (2 * π) - x) = cos x := cos_neg x ▸ cos_periodic.nat_mul_sub_eq n #align real.cos_nat_mul_two_pi_sub Real.cos_nat_mul_two_pi_sub @[simp] theorem cos_int_mul_two_pi_sub (x : ℝ) (n : ℤ) : cos (n * (2 * π) - x) = cos x := cos_neg x ▸ cos_periodic.int_mul_sub_eq n #align real.cos_int_mul_two_pi_sub Real.cos_int_mul_two_pi_sub theorem cos_add_int_mul_pi (x : ℝ) (n : ℤ) : cos (x + n * π) = (-1) ^ n * cos x := n.coe_negOnePow ℝ ▸ cos_antiperiodic.add_int_mul_eq n theorem cos_add_nat_mul_pi (x : ℝ) (n : ℕ) : cos (x + n * π) = (-1) ^ n * cos x := cos_antiperiodic.add_nat_mul_eq n theorem cos_sub_int_mul_pi (x : ℝ) (n : ℤ) : cos (x - n * π) = (-1) ^ n * cos x := n.coe_negOnePow ℝ ▸ cos_antiperiodic.sub_int_mul_eq n theorem cos_sub_nat_mul_pi (x : ℝ) (n : ℕ) : cos (x - n * π) = (-1) ^ n * cos x := cos_antiperiodic.sub_nat_mul_eq n theorem cos_int_mul_pi_sub (x : ℝ) (n : ℤ) : cos (n * π - x) = (-1) ^ n * cos x := n.coe_negOnePow ℝ ▸ cos_neg x ▸ cos_antiperiodic.int_mul_sub_eq n theorem cos_nat_mul_pi_sub (x : ℝ) (n : ℕ) : cos (n * π - x) = (-1) ^ n * cos x := cos_neg x ▸ cos_antiperiodic.nat_mul_sub_eq n -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_nat_mul_two_pi_add_pi (n : ℕ) : cos (n * (2 * π) + π) = -1 := by simpa only [cos_zero] using (cos_periodic.nat_mul n).add_antiperiod_eq cos_antiperiodic #align real.cos_nat_mul_two_pi_add_pi Real.cos_nat_mul_two_pi_add_pi -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_int_mul_two_pi_add_pi (n : ℤ) : cos (n * (2 * π) + π) = -1 := by simpa only [cos_zero] using (cos_periodic.int_mul n).add_antiperiod_eq cos_antiperiodic #align real.cos_int_mul_two_pi_add_pi Real.cos_int_mul_two_pi_add_pi -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_nat_mul_two_pi_sub_pi (n : ℕ) : cos (n * (2 * π) - π) = -1 := by simpa only [cos_zero] using (cos_periodic.nat_mul n).sub_antiperiod_eq cos_antiperiodic #align real.cos_nat_mul_two_pi_sub_pi Real.cos_nat_mul_two_pi_sub_pi -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_int_mul_two_pi_sub_pi (n : ℤ) : cos (n * (2 * π) - π) = -1 := by simpa only [cos_zero] using (cos_periodic.int_mul n).sub_antiperiod_eq cos_antiperiodic #align real.cos_int_mul_two_pi_sub_pi Real.cos_int_mul_two_pi_sub_pi theorem sin_pos_of_pos_of_lt_pi {x : ℝ} (h0x : 0 < x) (hxp : x < π) : 0 < sin x := if hx2 : x ≤ 2 then sin_pos_of_pos_of_le_two h0x hx2 else have : (2 : ℝ) + 2 = 4 := by norm_num have : π - x ≤ 2 := sub_le_iff_le_add.2 (le_trans pi_le_four (this ▸ add_le_add_left (le_of_not_ge hx2) _)) sin_pi_sub x ▸ sin_pos_of_pos_of_le_two (sub_pos.2 hxp) this #align real.sin_pos_of_pos_of_lt_pi Real.sin_pos_of_pos_of_lt_pi theorem sin_pos_of_mem_Ioo {x : ℝ} (hx : x ∈ Ioo 0 π) : 0 < sin x := sin_pos_of_pos_of_lt_pi hx.1 hx.2 #align real.sin_pos_of_mem_Ioo Real.sin_pos_of_mem_Ioo theorem sin_nonneg_of_mem_Icc {x : ℝ} (hx : x ∈ Icc 0 π) : 0 ≤ sin x := by rw [← closure_Ioo pi_ne_zero.symm] at hx exact closure_lt_subset_le continuous_const continuous_sin (closure_mono (fun y => sin_pos_of_mem_Ioo) hx) #align real.sin_nonneg_of_mem_Icc Real.sin_nonneg_of_mem_Icc theorem sin_nonneg_of_nonneg_of_le_pi {x : ℝ} (h0x : 0 ≤ x) (hxp : x ≤ π) : 0 ≤ sin x := sin_nonneg_of_mem_Icc ⟨h0x, hxp⟩ #align real.sin_nonneg_of_nonneg_of_le_pi Real.sin_nonneg_of_nonneg_of_le_pi theorem sin_neg_of_neg_of_neg_pi_lt {x : ℝ} (hx0 : x < 0) (hpx : -π < x) : sin x < 0 := neg_pos.1 <| sin_neg x ▸ sin_pos_of_pos_of_lt_pi (neg_pos.2 hx0) (neg_lt.1 hpx) #align real.sin_neg_of_neg_of_neg_pi_lt Real.sin_neg_of_neg_of_neg_pi_lt theorem sin_nonpos_of_nonnpos_of_neg_pi_le {x : ℝ} (hx0 : x ≤ 0) (hpx : -π ≤ x) : sin x ≤ 0 := neg_nonneg.1 <| sin_neg x ▸ sin_nonneg_of_nonneg_of_le_pi (neg_nonneg.2 hx0) (neg_le.1 hpx) #align real.sin_nonpos_of_nonnpos_of_neg_pi_le Real.sin_nonpos_of_nonnpos_of_neg_pi_le @[simp] theorem sin_pi_div_two : sin (π / 2) = 1 := have : sin (π / 2) = 1 ∨ sin (π / 2) = -1 := by simpa [sq, mul_self_eq_one_iff] using sin_sq_add_cos_sq (π / 2) this.resolve_right fun h => show ¬(0 : ℝ) < -1 by norm_num <| h ▸ sin_pos_of_pos_of_lt_pi pi_div_two_pos (half_lt_self pi_pos) #align real.sin_pi_div_two Real.sin_pi_div_two theorem sin_add_pi_div_two (x : ℝ) : sin (x + π / 2) = cos x := by simp [sin_add] #align real.sin_add_pi_div_two Real.sin_add_pi_div_two theorem sin_sub_pi_div_two (x : ℝ) : sin (x - π / 2) = -cos x := by simp [sub_eq_add_neg, sin_add] #align real.sin_sub_pi_div_two Real.sin_sub_pi_div_two theorem sin_pi_div_two_sub (x : ℝ) : sin (π / 2 - x) = cos x := by simp [sub_eq_add_neg, sin_add] #align real.sin_pi_div_two_sub Real.sin_pi_div_two_sub theorem cos_add_pi_div_two (x : ℝ) : cos (x + π / 2) = -sin x := by simp [cos_add] #align real.cos_add_pi_div_two Real.cos_add_pi_div_two theorem cos_sub_pi_div_two (x : ℝ) : cos (x - π / 2) = sin x := by simp [sub_eq_add_neg, cos_add] #align real.cos_sub_pi_div_two Real.cos_sub_pi_div_two theorem cos_pi_div_two_sub (x : ℝ) : cos (π / 2 - x) = sin x := by rw [← cos_neg, neg_sub, cos_sub_pi_div_two] #align real.cos_pi_div_two_sub Real.cos_pi_div_two_sub theorem cos_pos_of_mem_Ioo {x : ℝ} (hx : x ∈ Ioo (-(π / 2)) (π / 2)) : 0 < cos x := sin_add_pi_div_two x ▸ sin_pos_of_mem_Ioo ⟨by linarith [hx.1], by linarith [hx.2]⟩ #align real.cos_pos_of_mem_Ioo Real.cos_pos_of_mem_Ioo theorem cos_nonneg_of_mem_Icc {x : ℝ} (hx : x ∈ Icc (-(π / 2)) (π / 2)) : 0 ≤ cos x := sin_add_pi_div_two x ▸ sin_nonneg_of_mem_Icc ⟨by linarith [hx.1], by linarith [hx.2]⟩ #align real.cos_nonneg_of_mem_Icc Real.cos_nonneg_of_mem_Icc theorem cos_nonneg_of_neg_pi_div_two_le_of_le {x : ℝ} (hl : -(π / 2) ≤ x) (hu : x ≤ π / 2) : 0 ≤ cos x := cos_nonneg_of_mem_Icc ⟨hl, hu⟩ #align real.cos_nonneg_of_neg_pi_div_two_le_of_le Real.cos_nonneg_of_neg_pi_div_two_le_of_le theorem cos_neg_of_pi_div_two_lt_of_lt {x : ℝ} (hx₁ : π / 2 < x) (hx₂ : x < π + π / 2) : cos x < 0 := neg_pos.1 <| cos_pi_sub x ▸ cos_pos_of_mem_Ioo ⟨by linarith, by linarith⟩ #align real.cos_neg_of_pi_div_two_lt_of_lt Real.cos_neg_of_pi_div_two_lt_of_lt theorem cos_nonpos_of_pi_div_two_le_of_le {x : ℝ} (hx₁ : π / 2 ≤ x) (hx₂ : x ≤ π + π / 2) : cos x ≤ 0 := neg_nonneg.1 <| cos_pi_sub x ▸ cos_nonneg_of_mem_Icc ⟨by linarith, by linarith⟩ #align real.cos_nonpos_of_pi_div_two_le_of_le Real.cos_nonpos_of_pi_div_two_le_of_le theorem sin_eq_sqrt_one_sub_cos_sq {x : ℝ} (hl : 0 ≤ x) (hu : x ≤ π) : sin x = √(1 - cos x ^ 2) := by rw [← abs_sin_eq_sqrt_one_sub_cos_sq, abs_of_nonneg (sin_nonneg_of_nonneg_of_le_pi hl hu)] #align real.sin_eq_sqrt_one_sub_cos_sq Real.sin_eq_sqrt_one_sub_cos_sq theorem cos_eq_sqrt_one_sub_sin_sq {x : ℝ} (hl : -(π / 2) ≤ x) (hu : x ≤ π / 2) : cos x = √(1 - sin x ^ 2) := by rw [← abs_cos_eq_sqrt_one_sub_sin_sq, abs_of_nonneg (cos_nonneg_of_mem_Icc ⟨hl, hu⟩)] #align real.cos_eq_sqrt_one_sub_sin_sq Real.cos_eq_sqrt_one_sub_sin_sq lemma cos_half {x : ℝ} (hl : -π ≤ x) (hr : x ≤ π) : cos (x / 2) = sqrt ((1 + cos x) / 2) := by have : 0 ≤ cos (x / 2) := cos_nonneg_of_mem_Icc <| by constructor <;> linarith rw [← sqrt_sq this, cos_sq, add_div, two_mul, add_halves] lemma abs_sin_half (x : ℝ) : |sin (x / 2)| = sqrt ((1 - cos x) / 2) := by rw [← sqrt_sq_eq_abs, sin_sq_eq_half_sub, two_mul, add_halves, sub_div] lemma sin_half_eq_sqrt {x : ℝ} (hl : 0 ≤ x) (hr : x ≤ 2 * π) : sin (x / 2) = sqrt ((1 - cos x) / 2) := by rw [← abs_sin_half, abs_of_nonneg] apply sin_nonneg_of_nonneg_of_le_pi <;> linarith lemma sin_half_eq_neg_sqrt {x : ℝ} (hl : -(2 * π) ≤ x) (hr : x ≤ 0) : sin (x / 2) = -sqrt ((1 - cos x) / 2) := by rw [← abs_sin_half, abs_of_nonpos, neg_neg] apply sin_nonpos_of_nonnpos_of_neg_pi_le <;> linarith theorem sin_eq_zero_iff_of_lt_of_lt {x : ℝ} (hx₁ : -π < x) (hx₂ : x < π) : sin x = 0 ↔ x = 0 := ⟨fun h => by contrapose! h cases h.lt_or_lt with | inl h0 => exact (sin_neg_of_neg_of_neg_pi_lt h0 hx₁).ne | inr h0 => exact (sin_pos_of_pos_of_lt_pi h0 hx₂).ne', fun h => by simp [h]⟩ #align real.sin_eq_zero_iff_of_lt_of_lt Real.sin_eq_zero_iff_of_lt_of_lt theorem sin_eq_zero_iff {x : ℝ} : sin x = 0 ↔ ∃ n : ℤ, (n : ℝ) * π = x := ⟨fun h => ⟨⌊x / π⌋, le_antisymm (sub_nonneg.1 (Int.sub_floor_div_mul_nonneg _ pi_pos)) (sub_nonpos.1 <| le_of_not_gt fun h₃ => (sin_pos_of_pos_of_lt_pi h₃ (Int.sub_floor_div_mul_lt _ pi_pos)).ne (by simp [sub_eq_add_neg, sin_add, h, sin_int_mul_pi]))⟩, fun ⟨n, hn⟩ => hn ▸ sin_int_mul_pi _⟩ #align real.sin_eq_zero_iff Real.sin_eq_zero_iff theorem sin_ne_zero_iff {x : ℝ} : sin x ≠ 0 ↔ ∀ n : ℤ, (n : ℝ) * π ≠ x := by rw [← not_exists, not_iff_not, sin_eq_zero_iff] #align real.sin_ne_zero_iff Real.sin_ne_zero_iff theorem sin_eq_zero_iff_cos_eq {x : ℝ} : sin x = 0 ↔ cos x = 1 ∨ cos x = -1 := by rw [← mul_self_eq_one_iff, ← sin_sq_add_cos_sq x, sq, sq, ← sub_eq_iff_eq_add, sub_self] exact ⟨fun h => by rw [h, mul_zero], eq_zero_of_mul_self_eq_zero ∘ Eq.symm⟩ #align real.sin_eq_zero_iff_cos_eq Real.sin_eq_zero_iff_cos_eq theorem cos_eq_one_iff (x : ℝ) : cos x = 1 ↔ ∃ n : ℤ, (n : ℝ) * (2 * π) = x := ⟨fun h => let ⟨n, hn⟩ := sin_eq_zero_iff.1 (sin_eq_zero_iff_cos_eq.2 (Or.inl h)) ⟨n / 2, (Int.emod_two_eq_zero_or_one n).elim (fun hn0 => by rwa [← mul_assoc, ← @Int.cast_two ℝ, ← Int.cast_mul, Int.ediv_mul_cancel ((Int.dvd_iff_emod_eq_zero _ _).2 hn0)]) fun hn1 => by rw [← Int.emod_add_ediv n 2, hn1, Int.cast_add, Int.cast_one, add_mul, one_mul, add_comm, mul_comm (2 : ℤ), Int.cast_mul, mul_assoc, Int.cast_two] at hn rw [← hn, cos_int_mul_two_pi_add_pi] at h exact absurd h (by norm_num)⟩, fun ⟨n, hn⟩ => hn ▸ cos_int_mul_two_pi _⟩ #align real.cos_eq_one_iff Real.cos_eq_one_iff theorem cos_eq_one_iff_of_lt_of_lt {x : ℝ} (hx₁ : -(2 * π) < x) (hx₂ : x < 2 * π) : cos x = 1 ↔ x = 0 := ⟨fun h => by rcases (cos_eq_one_iff _).1 h with ⟨n, rfl⟩ rw [mul_lt_iff_lt_one_left two_pi_pos] at hx₂ rw [neg_lt, neg_mul_eq_neg_mul, mul_lt_iff_lt_one_left two_pi_pos] at hx₁ norm_cast at hx₁ hx₂ obtain rfl : n = 0 := le_antisymm (by omega) (by omega) simp, fun h => by simp [h]⟩ #align real.cos_eq_one_iff_of_lt_of_lt Real.cos_eq_one_iff_of_lt_of_lt theorem sin_lt_sin_of_lt_of_le_pi_div_two {x y : ℝ} (hx₁ : -(π / 2) ≤ x) (hy₂ : y ≤ π / 2) (hxy : x < y) : sin x < sin y := by rw [← sub_pos, sin_sub_sin] have : 0 < sin ((y - x) / 2) := by apply sin_pos_of_pos_of_lt_pi <;> linarith have : 0 < cos ((y + x) / 2) := by refine cos_pos_of_mem_Ioo ⟨?_, ?_⟩ <;> linarith positivity #align real.sin_lt_sin_of_lt_of_le_pi_div_two Real.sin_lt_sin_of_lt_of_le_pi_div_two theorem strictMonoOn_sin : StrictMonoOn sin (Icc (-(π / 2)) (π / 2)) := fun _ hx _ hy hxy => sin_lt_sin_of_lt_of_le_pi_div_two hx.1 hy.2 hxy #align real.strict_mono_on_sin Real.strictMonoOn_sin theorem cos_lt_cos_of_nonneg_of_le_pi {x y : ℝ} (hx₁ : 0 ≤ x) (hy₂ : y ≤ π) (hxy : x < y) : cos y < cos x := by rw [← sin_pi_div_two_sub, ← sin_pi_div_two_sub] apply sin_lt_sin_of_lt_of_le_pi_div_two <;> linarith #align real.cos_lt_cos_of_nonneg_of_le_pi Real.cos_lt_cos_of_nonneg_of_le_pi theorem cos_lt_cos_of_nonneg_of_le_pi_div_two {x y : ℝ} (hx₁ : 0 ≤ x) (hy₂ : y ≤ π / 2) (hxy : x < y) : cos y < cos x := cos_lt_cos_of_nonneg_of_le_pi hx₁ (hy₂.trans (by linarith)) hxy #align real.cos_lt_cos_of_nonneg_of_le_pi_div_two Real.cos_lt_cos_of_nonneg_of_le_pi_div_two theorem strictAntiOn_cos : StrictAntiOn cos (Icc 0 π) := fun _ hx _ hy hxy => cos_lt_cos_of_nonneg_of_le_pi hx.1 hy.2 hxy #align real.strict_anti_on_cos Real.strictAntiOn_cos theorem cos_le_cos_of_nonneg_of_le_pi {x y : ℝ} (hx₁ : 0 ≤ x) (hy₂ : y ≤ π) (hxy : x ≤ y) : cos y ≤ cos x := (strictAntiOn_cos.le_iff_le ⟨hx₁.trans hxy, hy₂⟩ ⟨hx₁, hxy.trans hy₂⟩).2 hxy #align real.cos_le_cos_of_nonneg_of_le_pi Real.cos_le_cos_of_nonneg_of_le_pi theorem sin_le_sin_of_le_of_le_pi_div_two {x y : ℝ} (hx₁ : -(π / 2) ≤ x) (hy₂ : y ≤ π / 2) (hxy : x ≤ y) : sin x ≤ sin y := (strictMonoOn_sin.le_iff_le ⟨hx₁, hxy.trans hy₂⟩ ⟨hx₁.trans hxy, hy₂⟩).2 hxy #align real.sin_le_sin_of_le_of_le_pi_div_two Real.sin_le_sin_of_le_of_le_pi_div_two theorem injOn_sin : InjOn sin (Icc (-(π / 2)) (π / 2)) := strictMonoOn_sin.injOn #align real.inj_on_sin Real.injOn_sin theorem injOn_cos : InjOn cos (Icc 0 π) := strictAntiOn_cos.injOn #align real.inj_on_cos Real.injOn_cos theorem surjOn_sin : SurjOn sin (Icc (-(π / 2)) (π / 2)) (Icc (-1) 1) := by simpa only [sin_neg, sin_pi_div_two] using intermediate_value_Icc (neg_le_self pi_div_two_pos.le) continuous_sin.continuousOn #align real.surj_on_sin Real.surjOn_sin theorem surjOn_cos : SurjOn cos (Icc 0 π) (Icc (-1) 1) := by simpa only [cos_zero, cos_pi] using intermediate_value_Icc' pi_pos.le continuous_cos.continuousOn #align real.surj_on_cos Real.surjOn_cos theorem sin_mem_Icc (x : ℝ) : sin x ∈ Icc (-1 : ℝ) 1 := ⟨neg_one_le_sin x, sin_le_one x⟩ #align real.sin_mem_Icc Real.sin_mem_Icc theorem cos_mem_Icc (x : ℝ) : cos x ∈ Icc (-1 : ℝ) 1 := ⟨neg_one_le_cos x, cos_le_one x⟩ #align real.cos_mem_Icc Real.cos_mem_Icc theorem mapsTo_sin (s : Set ℝ) : MapsTo sin s (Icc (-1 : ℝ) 1) := fun x _ => sin_mem_Icc x #align real.maps_to_sin Real.mapsTo_sin theorem mapsTo_cos (s : Set ℝ) : MapsTo cos s (Icc (-1 : ℝ) 1) := fun x _ => cos_mem_Icc x #align real.maps_to_cos Real.mapsTo_cos theorem bijOn_sin : BijOn sin (Icc (-(π / 2)) (π / 2)) (Icc (-1) 1) := ⟨mapsTo_sin _, injOn_sin, surjOn_sin⟩ #align real.bij_on_sin Real.bijOn_sin theorem bijOn_cos : BijOn cos (Icc 0 π) (Icc (-1) 1) := ⟨mapsTo_cos _, injOn_cos, surjOn_cos⟩ #align real.bij_on_cos Real.bijOn_cos @[simp] theorem range_cos : range cos = (Icc (-1) 1 : Set ℝ) := Subset.antisymm (range_subset_iff.2 cos_mem_Icc) surjOn_cos.subset_range #align real.range_cos Real.range_cos @[simp] theorem range_sin : range sin = (Icc (-1) 1 : Set ℝ) := Subset.antisymm (range_subset_iff.2 sin_mem_Icc) surjOn_sin.subset_range #align real.range_sin Real.range_sin theorem range_cos_infinite : (range Real.cos).Infinite := by rw [Real.range_cos] exact Icc_infinite (by norm_num) #align real.range_cos_infinite Real.range_cos_infinite theorem range_sin_infinite : (range Real.sin).Infinite := by rw [Real.range_sin] exact Icc_infinite (by norm_num) #align real.range_sin_infinite Real.range_sin_infinite namespace Complex open Real theorem sin_eq_zero_iff_cos_eq {z : ℂ} : sin z = 0 ↔ cos z = 1 ∨ cos z = -1 := by rw [← mul_self_eq_one_iff, ← sin_sq_add_cos_sq, sq, sq, ← sub_eq_iff_eq_add, sub_self] exact ⟨fun h => by rw [h, mul_zero], eq_zero_of_mul_self_eq_zero ∘ Eq.symm⟩ #align complex.sin_eq_zero_iff_cos_eq Complex.sin_eq_zero_iff_cos_eq @[simp] theorem cos_pi_div_two : cos (π / 2) = 0 := calc cos (π / 2) = Real.cos (π / 2) := by rw [ofReal_cos]; simp _ = 0 := by simp #align complex.cos_pi_div_two Complex.cos_pi_div_two @[simp] theorem sin_pi_div_two : sin (π / 2) = 1 := calc sin (π / 2) = Real.sin (π / 2) := by rw [ofReal_sin]; simp _ = 1 := by simp #align complex.sin_pi_div_two Complex.sin_pi_div_two @[simp] theorem sin_pi : sin π = 0 := by rw [← ofReal_sin, Real.sin_pi]; simp #align complex.sin_pi Complex.sin_pi @[simp] theorem cos_pi : cos π = -1 := by rw [← ofReal_cos, Real.cos_pi]; simp #align complex.cos_pi Complex.cos_pi @[simp] theorem sin_two_pi : sin (2 * π) = 0 := by simp [two_mul, sin_add] #align complex.sin_two_pi Complex.sin_two_pi @[simp] theorem cos_two_pi : cos (2 * π) = 1 := by simp [two_mul, cos_add] #align complex.cos_two_pi Complex.cos_two_pi theorem sin_antiperiodic : Function.Antiperiodic sin π := by simp [sin_add] #align complex.sin_antiperiodic Complex.sin_antiperiodic theorem sin_periodic : Function.Periodic sin (2 * π) := sin_antiperiodic.periodic_two_mul #align complex.sin_periodic Complex.sin_periodic theorem sin_add_pi (x : ℂ) : sin (x + π) = -sin x := sin_antiperiodic x #align complex.sin_add_pi Complex.sin_add_pi theorem sin_add_two_pi (x : ℂ) : sin (x + 2 * π) = sin x := sin_periodic x #align complex.sin_add_two_pi Complex.sin_add_two_pi theorem sin_sub_pi (x : ℂ) : sin (x - π) = -sin x := sin_antiperiodic.sub_eq x #align complex.sin_sub_pi Complex.sin_sub_pi theorem sin_sub_two_pi (x : ℂ) : sin (x - 2 * π) = sin x := sin_periodic.sub_eq x #align complex.sin_sub_two_pi Complex.sin_sub_two_pi theorem sin_pi_sub (x : ℂ) : sin (π - x) = sin x := neg_neg (sin x) ▸ sin_neg x ▸ sin_antiperiodic.sub_eq' #align complex.sin_pi_sub Complex.sin_pi_sub theorem sin_two_pi_sub (x : ℂ) : sin (2 * π - x) = -sin x := sin_neg x ▸ sin_periodic.sub_eq' #align complex.sin_two_pi_sub Complex.sin_two_pi_sub theorem sin_nat_mul_pi (n : ℕ) : sin (n * π) = 0 := sin_antiperiodic.nat_mul_eq_of_eq_zero sin_zero n #align complex.sin_nat_mul_pi Complex.sin_nat_mul_pi theorem sin_int_mul_pi (n : ℤ) : sin (n * π) = 0 := sin_antiperiodic.int_mul_eq_of_eq_zero sin_zero n #align complex.sin_int_mul_pi Complex.sin_int_mul_pi theorem sin_add_nat_mul_two_pi (x : ℂ) (n : ℕ) : sin (x + n * (2 * π)) = sin x := sin_periodic.nat_mul n x #align complex.sin_add_nat_mul_two_pi Complex.sin_add_nat_mul_two_pi theorem sin_add_int_mul_two_pi (x : ℂ) (n : ℤ) : sin (x + n * (2 * π)) = sin x := sin_periodic.int_mul n x #align complex.sin_add_int_mul_two_pi Complex.sin_add_int_mul_two_pi theorem sin_sub_nat_mul_two_pi (x : ℂ) (n : ℕ) : sin (x - n * (2 * π)) = sin x := sin_periodic.sub_nat_mul_eq n #align complex.sin_sub_nat_mul_two_pi Complex.sin_sub_nat_mul_two_pi theorem sin_sub_int_mul_two_pi (x : ℂ) (n : ℤ) : sin (x - n * (2 * π)) = sin x := sin_periodic.sub_int_mul_eq n #align complex.sin_sub_int_mul_two_pi Complex.sin_sub_int_mul_two_pi theorem sin_nat_mul_two_pi_sub (x : ℂ) (n : ℕ) : sin (n * (2 * π) - x) = -sin x := sin_neg x ▸ sin_periodic.nat_mul_sub_eq n #align complex.sin_nat_mul_two_pi_sub Complex.sin_nat_mul_two_pi_sub theorem sin_int_mul_two_pi_sub (x : ℂ) (n : ℤ) : sin (n * (2 * π) - x) = -sin x := sin_neg x ▸ sin_periodic.int_mul_sub_eq n #align complex.sin_int_mul_two_pi_sub Complex.sin_int_mul_two_pi_sub theorem cos_antiperiodic : Function.Antiperiodic cos π := by simp [cos_add] #align complex.cos_antiperiodic Complex.cos_antiperiodic theorem cos_periodic : Function.Periodic cos (2 * π) := cos_antiperiodic.periodic_two_mul #align complex.cos_periodic Complex.cos_periodic theorem cos_add_pi (x : ℂ) : cos (x + π) = -cos x := cos_antiperiodic x #align complex.cos_add_pi Complex.cos_add_pi theorem cos_add_two_pi (x : ℂ) : cos (x + 2 * π) = cos x := cos_periodic x #align complex.cos_add_two_pi Complex.cos_add_two_pi theorem cos_sub_pi (x : ℂ) : cos (x - π) = -cos x := cos_antiperiodic.sub_eq x #align complex.cos_sub_pi Complex.cos_sub_pi theorem cos_sub_two_pi (x : ℂ) : cos (x - 2 * π) = cos x := cos_periodic.sub_eq x #align complex.cos_sub_two_pi Complex.cos_sub_two_pi theorem cos_pi_sub (x : ℂ) : cos (π - x) = -cos x := cos_neg x ▸ cos_antiperiodic.sub_eq' #align complex.cos_pi_sub Complex.cos_pi_sub theorem cos_two_pi_sub (x : ℂ) : cos (2 * π - x) = cos x := cos_neg x ▸ cos_periodic.sub_eq' #align complex.cos_two_pi_sub Complex.cos_two_pi_sub theorem cos_nat_mul_two_pi (n : ℕ) : cos (n * (2 * π)) = 1 := (cos_periodic.nat_mul_eq n).trans cos_zero #align complex.cos_nat_mul_two_pi Complex.cos_nat_mul_two_pi theorem cos_int_mul_two_pi (n : ℤ) : cos (n * (2 * π)) = 1 := (cos_periodic.int_mul_eq n).trans cos_zero #align complex.cos_int_mul_two_pi Complex.cos_int_mul_two_pi theorem cos_add_nat_mul_two_pi (x : ℂ) (n : ℕ) : cos (x + n * (2 * π)) = cos x := cos_periodic.nat_mul n x #align complex.cos_add_nat_mul_two_pi Complex.cos_add_nat_mul_two_pi theorem cos_add_int_mul_two_pi (x : ℂ) (n : ℤ) : cos (x + n * (2 * π)) = cos x := cos_periodic.int_mul n x #align complex.cos_add_int_mul_two_pi Complex.cos_add_int_mul_two_pi theorem cos_sub_nat_mul_two_pi (x : ℂ) (n : ℕ) : cos (x - n * (2 * π)) = cos x := cos_periodic.sub_nat_mul_eq n #align complex.cos_sub_nat_mul_two_pi Complex.cos_sub_nat_mul_two_pi theorem cos_sub_int_mul_two_pi (x : ℂ) (n : ℤ) : cos (x - n * (2 * π)) = cos x := cos_periodic.sub_int_mul_eq n #align complex.cos_sub_int_mul_two_pi Complex.cos_sub_int_mul_two_pi theorem cos_nat_mul_two_pi_sub (x : ℂ) (n : ℕ) : cos (n * (2 * π) - x) = cos x := cos_neg x ▸ cos_periodic.nat_mul_sub_eq n #align complex.cos_nat_mul_two_pi_sub Complex.cos_nat_mul_two_pi_sub theorem cos_int_mul_two_pi_sub (x : ℂ) (n : ℤ) : cos (n * (2 * π) - x) = cos x := cos_neg x ▸ cos_periodic.int_mul_sub_eq n #align complex.cos_int_mul_two_pi_sub Complex.cos_int_mul_two_pi_sub theorem cos_nat_mul_two_pi_add_pi (n : ℕ) : cos (n * (2 * π) + π) = -1 := by simpa only [cos_zero] using (cos_periodic.nat_mul n).add_antiperiod_eq cos_antiperiodic #align complex.cos_nat_mul_two_pi_add_pi Complex.cos_nat_mul_two_pi_add_pi theorem cos_int_mul_two_pi_add_pi (n : ℤ) : cos (n * (2 * π) + π) = -1 := by simpa only [cos_zero] using (cos_periodic.int_mul n).add_antiperiod_eq cos_antiperiodic #align complex.cos_int_mul_two_pi_add_pi Complex.cos_int_mul_two_pi_add_pi theorem cos_nat_mul_two_pi_sub_pi (n : ℕ) : cos (n * (2 * π) - π) = -1 := by simpa only [cos_zero] using (cos_periodic.nat_mul n).sub_antiperiod_eq cos_antiperiodic #align complex.cos_nat_mul_two_pi_sub_pi Complex.cos_nat_mul_two_pi_sub_pi theorem cos_int_mul_two_pi_sub_pi (n : ℤ) : cos (n * (2 * π) - π) = -1 := by simpa only [cos_zero] using (cos_periodic.int_mul n).sub_antiperiod_eq cos_antiperiodic #align complex.cos_int_mul_two_pi_sub_pi Complex.cos_int_mul_two_pi_sub_pi theorem sin_add_pi_div_two (x : ℂ) : sin (x + π / 2) = cos x := by simp [sin_add] #align complex.sin_add_pi_div_two Complex.sin_add_pi_div_two theorem sin_sub_pi_div_two (x : ℂ) : sin (x - π / 2) = -cos x := by simp [sub_eq_add_neg, sin_add] #align complex.sin_sub_pi_div_two Complex.sin_sub_pi_div_two
Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean
1,302
1,302
theorem sin_pi_div_two_sub (x : ℂ) : sin (π / 2 - x) = cos x := by
simp [sub_eq_add_neg, sin_add]
import Mathlib.Data.Fintype.Card import Mathlib.Order.UpperLower.Basic #align_import combinatorics.set_family.intersecting from "leanprover-community/mathlib"@"d90e4e186f1d18e375dcd4e5b5f6364b01cb3e46" open Finset variable {α : Type*} namespace Set section SemilatticeInf variable [SemilatticeInf α] [OrderBot α] {s t : Set α} {a b c : α} def Intersecting (s : Set α) : Prop := ∀ ⦃a⦄, a ∈ s → ∀ ⦃b⦄, b ∈ s → ¬Disjoint a b #align set.intersecting Set.Intersecting @[mono] theorem Intersecting.mono (h : t ⊆ s) (hs : s.Intersecting) : t.Intersecting := fun _a ha _b hb => hs (h ha) (h hb) #align set.intersecting.mono Set.Intersecting.mono theorem Intersecting.not_bot_mem (hs : s.Intersecting) : ⊥ ∉ s := fun h => hs h h disjoint_bot_left #align set.intersecting.not_bot_mem Set.Intersecting.not_bot_mem theorem Intersecting.ne_bot (hs : s.Intersecting) (ha : a ∈ s) : a ≠ ⊥ := ne_of_mem_of_not_mem ha hs.not_bot_mem #align set.intersecting.ne_bot Set.Intersecting.ne_bot theorem intersecting_empty : (∅ : Set α).Intersecting := fun _ => False.elim #align set.intersecting_empty Set.intersecting_empty @[simp] theorem intersecting_singleton : ({a} : Set α).Intersecting ↔ a ≠ ⊥ := by simp [Intersecting] #align set.intersecting_singleton Set.intersecting_singleton protected theorem Intersecting.insert (hs : s.Intersecting) (ha : a ≠ ⊥) (h : ∀ b ∈ s, ¬Disjoint a b) : (insert a s).Intersecting := by rintro b (rfl | hb) c (rfl | hc) · rwa [disjoint_self] · exact h _ hc · exact fun H => h _ hb H.symm · exact hs hb hc #align set.intersecting.insert Set.Intersecting.insert theorem intersecting_insert : (insert a s).Intersecting ↔ s.Intersecting ∧ a ≠ ⊥ ∧ ∀ b ∈ s, ¬Disjoint a b := ⟨fun h => ⟨h.mono <| subset_insert _ _, h.ne_bot <| mem_insert _ _, fun _b hb => h (mem_insert _ _) <| mem_insert_of_mem _ hb⟩, fun h => h.1.insert h.2.1 h.2.2⟩ #align set.intersecting_insert Set.intersecting_insert theorem intersecting_iff_pairwise_not_disjoint : s.Intersecting ↔ (s.Pairwise fun a b => ¬Disjoint a b) ∧ s ≠ {⊥} := by refine ⟨fun h => ⟨fun a ha b hb _ => h ha hb, ?_⟩, fun h a ha b hb hab => ?_⟩ · rintro rfl exact intersecting_singleton.1 h rfl have := h.1.eq ha hb (Classical.not_not.2 hab) rw [this, disjoint_self] at hab rw [hab] at hb exact h.2 (eq_singleton_iff_unique_mem.2 ⟨hb, fun c hc => not_ne_iff.1 fun H => h.1 hb hc H.symm disjoint_bot_left⟩) #align set.intersecting_iff_pairwise_not_disjoint Set.intersecting_iff_pairwise_not_disjoint protected theorem Subsingleton.intersecting (hs : s.Subsingleton) : s.Intersecting ↔ s ≠ {⊥} := intersecting_iff_pairwise_not_disjoint.trans <| and_iff_right <| hs.pairwise _ #align set.subsingleton.intersecting Set.Subsingleton.intersecting theorem intersecting_iff_eq_empty_of_subsingleton [Subsingleton α] (s : Set α) : s.Intersecting ↔ s = ∅ := by refine subsingleton_of_subsingleton.intersecting.trans ⟨not_imp_comm.2 fun h => subsingleton_of_subsingleton.eq_singleton_of_mem ?_, ?_⟩ · obtain ⟨a, ha⟩ := nonempty_iff_ne_empty.2 h rwa [Subsingleton.elim ⊥ a] · rintro rfl exact (Set.singleton_nonempty _).ne_empty.symm #align set.intersecting_iff_eq_empty_of_subsingleton Set.intersecting_iff_eq_empty_of_subsingleton protected theorem Intersecting.isUpperSet (hs : s.Intersecting) (h : ∀ t : Set α, t.Intersecting → s ⊆ t → s = t) : IsUpperSet s := by classical rintro a b hab ha rw [h (Insert.insert b s) _ (subset_insert _ _)] · exact mem_insert _ _ exact hs.insert (mt (eq_bot_mono hab) <| hs.ne_bot ha) fun c hc hbc => hs ha hc <| hbc.mono_left hab #align set.intersecting.is_upper_set Set.Intersecting.isUpperSet
Mathlib/Combinatorics/SetFamily/Intersecting.lean
122
130
theorem Intersecting.isUpperSet' {s : Finset α} (hs : (s : Set α).Intersecting) (h : ∀ t : Finset α, (t : Set α).Intersecting → s ⊆ t → s = t) : IsUpperSet (s : Set α) := by
classical rintro a b hab ha rw [h (Insert.insert b s) _ (Finset.subset_insert _ _)] · exact mem_insert_self _ _ rw [coe_insert] exact hs.insert (mt (eq_bot_mono hab) <| hs.ne_bot ha) fun c hc hbc => hs ha hc <| hbc.mono_left hab
import Mathlib.Data.Finsupp.Multiset import Mathlib.Data.Nat.GCD.BigOperators import Mathlib.Data.Nat.PrimeFin import Mathlib.NumberTheory.Padics.PadicVal import Mathlib.Order.Interval.Finset.Nat #align_import data.nat.factorization.basic from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" -- Workaround for lean4#2038 attribute [-instance] instBEqNat open Nat Finset List Finsupp namespace Nat variable {a b m n p : ℕ} def factorization (n : ℕ) : ℕ →₀ ℕ where support := n.primeFactors toFun p := if p.Prime then padicValNat p n else 0 mem_support_toFun := by simp [not_or]; aesop #align nat.factorization Nat.factorization @[simp] lemma support_factorization (n : ℕ) : (factorization n).support = n.primeFactors := rfl theorem factorization_def (n : ℕ) {p : ℕ} (pp : p.Prime) : n.factorization p = padicValNat p n := by simpa [factorization] using absurd pp #align nat.factorization_def Nat.factorization_def @[simp] theorem factors_count_eq {n p : ℕ} : n.factors.count p = n.factorization p := by rcases n.eq_zero_or_pos with (rfl | hn0) · simp [factorization, count] if pp : p.Prime then ?_ else rw [count_eq_zero_of_not_mem (mt prime_of_mem_factors pp)] simp [factorization, pp] simp only [factorization_def _ pp] apply _root_.le_antisymm · rw [le_padicValNat_iff_replicate_subperm_factors pp hn0.ne'] exact List.le_count_iff_replicate_sublist.mp le_rfl |>.subperm · rw [← lt_add_one_iff, lt_iff_not_ge, ge_iff_le, le_padicValNat_iff_replicate_subperm_factors pp hn0.ne'] intro h have := h.count_le p simp at this #align nat.factors_count_eq Nat.factors_count_eq theorem factorization_eq_factors_multiset (n : ℕ) : n.factorization = Multiset.toFinsupp (n.factors : Multiset ℕ) := by ext p simp #align nat.factorization_eq_factors_multiset Nat.factorization_eq_factors_multiset theorem multiplicity_eq_factorization {n p : ℕ} (pp : p.Prime) (hn : n ≠ 0) : multiplicity p n = n.factorization p := by simp [factorization, pp, padicValNat_def' pp.ne_one hn.bot_lt] #align nat.multiplicity_eq_factorization Nat.multiplicity_eq_factorization @[simp] theorem factorization_prod_pow_eq_self {n : ℕ} (hn : n ≠ 0) : n.factorization.prod (· ^ ·) = n := by rw [factorization_eq_factors_multiset n] simp only [← prod_toMultiset, factorization, Multiset.prod_coe, Multiset.toFinsupp_toMultiset] exact prod_factors hn #align nat.factorization_prod_pow_eq_self Nat.factorization_prod_pow_eq_self theorem eq_of_factorization_eq {a b : ℕ} (ha : a ≠ 0) (hb : b ≠ 0) (h : ∀ p : ℕ, a.factorization p = b.factorization p) : a = b := eq_of_perm_factors ha hb (by simpa only [List.perm_iff_count, factors_count_eq] using h) #align nat.eq_of_factorization_eq Nat.eq_of_factorization_eq theorem factorization_inj : Set.InjOn factorization { x : ℕ | x ≠ 0 } := fun a ha b hb h => eq_of_factorization_eq ha hb fun p => by simp [h] #align nat.factorization_inj Nat.factorization_inj @[simp] theorem factorization_zero : factorization 0 = 0 := by ext; simp [factorization] #align nat.factorization_zero Nat.factorization_zero @[simp] theorem factorization_one : factorization 1 = 0 := by ext; simp [factorization] #align nat.factorization_one Nat.factorization_one #noalign nat.support_factorization #align nat.factor_iff_mem_factorization Nat.mem_primeFactors_iff_mem_factors #align nat.prime_of_mem_factorization Nat.prime_of_mem_primeFactors #align nat.pos_of_mem_factorization Nat.pos_of_mem_primeFactors #align nat.le_of_mem_factorization Nat.le_of_mem_primeFactors theorem factorization_eq_zero_iff (n p : ℕ) : n.factorization p = 0 ↔ ¬p.Prime ∨ ¬p ∣ n ∨ n = 0 := by simp_rw [← not_mem_support_iff, support_factorization, mem_primeFactors, not_and_or, not_ne_iff] #align nat.factorization_eq_zero_iff Nat.factorization_eq_zero_iff @[simp] theorem factorization_eq_zero_of_non_prime (n : ℕ) {p : ℕ} (hp : ¬p.Prime) : n.factorization p = 0 := by simp [factorization_eq_zero_iff, hp] #align nat.factorization_eq_zero_of_non_prime Nat.factorization_eq_zero_of_non_prime theorem factorization_eq_zero_of_not_dvd {n p : ℕ} (h : ¬p ∣ n) : n.factorization p = 0 := by simp [factorization_eq_zero_iff, h] #align nat.factorization_eq_zero_of_not_dvd Nat.factorization_eq_zero_of_not_dvd theorem factorization_eq_zero_of_lt {n p : ℕ} (h : n < p) : n.factorization p = 0 := Finsupp.not_mem_support_iff.mp (mt le_of_mem_primeFactors (not_le_of_lt h)) #align nat.factorization_eq_zero_of_lt Nat.factorization_eq_zero_of_lt @[simp] theorem factorization_zero_right (n : ℕ) : n.factorization 0 = 0 := factorization_eq_zero_of_non_prime _ not_prime_zero #align nat.factorization_zero_right Nat.factorization_zero_right @[simp] theorem factorization_one_right (n : ℕ) : n.factorization 1 = 0 := factorization_eq_zero_of_non_prime _ not_prime_one #align nat.factorization_one_right Nat.factorization_one_right theorem dvd_of_factorization_pos {n p : ℕ} (hn : n.factorization p ≠ 0) : p ∣ n := dvd_of_mem_factors <| mem_primeFactors_iff_mem_factors.1 <| mem_support_iff.2 hn #align nat.dvd_of_factorization_pos Nat.dvd_of_factorization_pos theorem Prime.factorization_pos_of_dvd {n p : ℕ} (hp : p.Prime) (hn : n ≠ 0) (h : p ∣ n) : 0 < n.factorization p := by rwa [← factors_count_eq, count_pos_iff_mem, mem_factors_iff_dvd hn hp] #align nat.prime.factorization_pos_of_dvd Nat.Prime.factorization_pos_of_dvd theorem factorization_eq_zero_of_remainder {p r : ℕ} (i : ℕ) (hr : ¬p ∣ r) : (p * i + r).factorization p = 0 := by apply factorization_eq_zero_of_not_dvd rwa [← Nat.dvd_add_iff_right (Dvd.intro i rfl)] #align nat.factorization_eq_zero_of_remainder Nat.factorization_eq_zero_of_remainder theorem factorization_eq_zero_iff_remainder {p r : ℕ} (i : ℕ) (pp : p.Prime) (hr0 : r ≠ 0) : ¬p ∣ r ↔ (p * i + r).factorization p = 0 := by refine ⟨factorization_eq_zero_of_remainder i, fun h => ?_⟩ rw [factorization_eq_zero_iff] at h contrapose! h refine ⟨pp, ?_, ?_⟩ · rwa [← Nat.dvd_add_iff_right (dvd_mul_right p i)] · contrapose! hr0 exact (add_eq_zero_iff.mp hr0).2 #align nat.factorization_eq_zero_iff_remainder Nat.factorization_eq_zero_iff_remainder theorem factorization_eq_zero_iff' (n : ℕ) : n.factorization = 0 ↔ n = 0 ∨ n = 1 := by rw [factorization_eq_factors_multiset n] simp [factorization, AddEquiv.map_eq_zero_iff, Multiset.coe_eq_zero] #align nat.factorization_eq_zero_iff' Nat.factorization_eq_zero_iff' @[simp] theorem factorization_mul {a b : ℕ} (ha : a ≠ 0) (hb : b ≠ 0) : (a * b).factorization = a.factorization + b.factorization := by ext p simp only [add_apply, ← factors_count_eq, perm_iff_count.mp (perm_factors_mul ha hb) p, count_append] #align nat.factorization_mul Nat.factorization_mul #align nat.factorization_mul_support Nat.primeFactors_mul lemma prod_factorization_eq_prod_primeFactors {β : Type*} [CommMonoid β] (f : ℕ → ℕ → β) : n.factorization.prod f = ∏ p ∈ n.primeFactors, f p (n.factorization p) := rfl #align nat.prod_factorization_eq_prod_factors Nat.prod_factorization_eq_prod_primeFactors lemma prod_primeFactors_prod_factorization {β : Type*} [CommMonoid β] (f : ℕ → β) : ∏ p ∈ n.primeFactors, f p = n.factorization.prod (fun p _ ↦ f p) := rfl theorem factorization_prod {α : Type*} {S : Finset α} {g : α → ℕ} (hS : ∀ x ∈ S, g x ≠ 0) : (S.prod g).factorization = S.sum fun x => (g x).factorization := by classical ext p refine Finset.induction_on' S ?_ ?_ · simp · intro x T hxS hTS hxT IH have hT : T.prod g ≠ 0 := prod_ne_zero_iff.mpr fun x hx => hS x (hTS hx) simp [prod_insert hxT, sum_insert hxT, ← IH, factorization_mul (hS x hxS) hT] #align nat.factorization_prod Nat.factorization_prod @[simp] theorem factorization_pow (n k : ℕ) : factorization (n ^ k) = k • n.factorization := by induction' k with k ih; · simp rcases eq_or_ne n 0 with (rfl | hn) · simp rw [Nat.pow_succ, mul_comm, factorization_mul hn (pow_ne_zero _ hn), ih, add_smul, one_smul, add_comm] #align nat.factorization_pow Nat.factorization_pow @[simp] protected theorem Prime.factorization {p : ℕ} (hp : Prime p) : p.factorization = single p 1 := by ext q rw [← factors_count_eq, factors_prime hp, single_apply, count_singleton', if_congr eq_comm] <;> rfl #align nat.prime.factorization Nat.Prime.factorization @[simp] theorem Prime.factorization_self {p : ℕ} (hp : Prime p) : p.factorization p = 1 := by simp [hp] #align nat.prime.factorization_self Nat.Prime.factorization_self theorem Prime.factorization_pow {p k : ℕ} (hp : Prime p) : (p ^ k).factorization = single p k := by simp [hp] #align nat.prime.factorization_pow Nat.Prime.factorization_pow theorem eq_pow_of_factorization_eq_single {n p k : ℕ} (hn : n ≠ 0) (h : n.factorization = Finsupp.single p k) : n = p ^ k := by -- Porting note: explicitly added `Finsupp.prod_single_index` rw [← Nat.factorization_prod_pow_eq_self hn, h, Finsupp.prod_single_index] simp #align nat.eq_pow_of_factorization_eq_single Nat.eq_pow_of_factorization_eq_single theorem Prime.eq_of_factorization_pos {p q : ℕ} (hp : Prime p) (h : p.factorization q ≠ 0) : p = q := by simpa [hp.factorization, single_apply] using h #align nat.prime.eq_of_factorization_pos Nat.Prime.eq_of_factorization_pos theorem prod_pow_factorization_eq_self {f : ℕ →₀ ℕ} (hf : ∀ p : ℕ, p ∈ f.support → Prime p) : (f.prod (· ^ ·)).factorization = f := by have h : ∀ x : ℕ, x ∈ f.support → x ^ f x ≠ 0 := fun p hp => pow_ne_zero _ (Prime.ne_zero (hf p hp)) simp only [Finsupp.prod, factorization_prod h] conv => rhs rw [(sum_single f).symm] exact sum_congr rfl fun p hp => Prime.factorization_pow (hf p hp) #align nat.prod_pow_factorization_eq_self Nat.prod_pow_factorization_eq_self theorem eq_factorization_iff {n : ℕ} {f : ℕ →₀ ℕ} (hn : n ≠ 0) (hf : ∀ p ∈ f.support, Prime p) : f = n.factorization ↔ f.prod (· ^ ·) = n := ⟨fun h => by rw [h, factorization_prod_pow_eq_self hn], fun h => by rw [← h, prod_pow_factorization_eq_self hf]⟩ #align nat.eq_factorization_iff Nat.eq_factorization_iff def factorizationEquiv : ℕ+ ≃ { f : ℕ →₀ ℕ | ∀ p ∈ f.support, Prime p } where toFun := fun ⟨n, _⟩ => ⟨n.factorization, fun _ => prime_of_mem_primeFactors⟩ invFun := fun ⟨f, hf⟩ => ⟨f.prod _, prod_pow_pos_of_zero_not_mem_support fun H => not_prime_zero (hf 0 H)⟩ left_inv := fun ⟨_, hx⟩ => Subtype.ext <| factorization_prod_pow_eq_self hx.ne.symm right_inv := fun ⟨_, hf⟩ => Subtype.ext <| prod_pow_factorization_eq_self hf #align nat.factorization_equiv Nat.factorizationEquiv theorem factorizationEquiv_apply (n : ℕ+) : (factorizationEquiv n).1 = n.1.factorization := by cases n rfl #align nat.factorization_equiv_apply Nat.factorizationEquiv_apply theorem factorizationEquiv_inv_apply {f : ℕ →₀ ℕ} (hf : ∀ p ∈ f.support, Prime p) : (factorizationEquiv.symm ⟨f, hf⟩).1 = f.prod (· ^ ·) := rfl #align nat.factorization_equiv_inv_apply Nat.factorizationEquiv_inv_apply -- Porting note: Lean 4 thinks we need `HPow` without this set_option quotPrecheck false in notation "ord_proj[" p "] " n:arg => p ^ Nat.factorization n p notation "ord_compl[" p "] " n:arg => n / ord_proj[p] n @[simp] theorem ord_proj_of_not_prime (n p : ℕ) (hp : ¬p.Prime) : ord_proj[p] n = 1 := by simp [factorization_eq_zero_of_non_prime n hp] #align nat.ord_proj_of_not_prime Nat.ord_proj_of_not_prime @[simp] theorem ord_compl_of_not_prime (n p : ℕ) (hp : ¬p.Prime) : ord_compl[p] n = n := by simp [factorization_eq_zero_of_non_prime n hp] #align nat.ord_compl_of_not_prime Nat.ord_compl_of_not_prime theorem ord_proj_dvd (n p : ℕ) : ord_proj[p] n ∣ n := by if hp : p.Prime then ?_ else simp [hp] rw [← factors_count_eq] apply dvd_of_factors_subperm (pow_ne_zero _ hp.ne_zero) rw [hp.factors_pow, List.subperm_ext_iff] intro q hq simp [List.eq_of_mem_replicate hq] #align nat.ord_proj_dvd Nat.ord_proj_dvd theorem ord_compl_dvd (n p : ℕ) : ord_compl[p] n ∣ n := div_dvd_of_dvd (ord_proj_dvd n p) #align nat.ord_compl_dvd Nat.ord_compl_dvd theorem ord_proj_pos (n p : ℕ) : 0 < ord_proj[p] n := by if pp : p.Prime then simp [pow_pos pp.pos] else simp [pp] #align nat.ord_proj_pos Nat.ord_proj_pos theorem ord_proj_le {n : ℕ} (p : ℕ) (hn : n ≠ 0) : ord_proj[p] n ≤ n := le_of_dvd hn.bot_lt (Nat.ord_proj_dvd n p) #align nat.ord_proj_le Nat.ord_proj_le theorem ord_compl_pos {n : ℕ} (p : ℕ) (hn : n ≠ 0) : 0 < ord_compl[p] n := by if pp : p.Prime then exact Nat.div_pos (ord_proj_le p hn) (ord_proj_pos n p) else simpa [Nat.factorization_eq_zero_of_non_prime n pp] using hn.bot_lt #align nat.ord_compl_pos Nat.ord_compl_pos theorem ord_compl_le (n p : ℕ) : ord_compl[p] n ≤ n := Nat.div_le_self _ _ #align nat.ord_compl_le Nat.ord_compl_le theorem ord_proj_mul_ord_compl_eq_self (n p : ℕ) : ord_proj[p] n * ord_compl[p] n = n := Nat.mul_div_cancel' (ord_proj_dvd n p) #align nat.ord_proj_mul_ord_compl_eq_self Nat.ord_proj_mul_ord_compl_eq_self theorem ord_proj_mul {a b : ℕ} (p : ℕ) (ha : a ≠ 0) (hb : b ≠ 0) : ord_proj[p] (a * b) = ord_proj[p] a * ord_proj[p] b := by simp [factorization_mul ha hb, pow_add] #align nat.ord_proj_mul Nat.ord_proj_mul theorem ord_compl_mul (a b p : ℕ) : ord_compl[p] (a * b) = ord_compl[p] a * ord_compl[p] b := by if ha : a = 0 then simp [ha] else if hb : b = 0 then simp [hb] else simp only [ord_proj_mul p ha hb] rw [div_mul_div_comm (ord_proj_dvd a p) (ord_proj_dvd b p)] #align nat.ord_compl_mul Nat.ord_compl_mul #align nat.dvd_of_mem_factorization Nat.dvd_of_mem_primeFactors
Mathlib/Data/Nat/Factorization/Basic.lean
393
397
theorem factorization_lt {n : ℕ} (p : ℕ) (hn : n ≠ 0) : n.factorization p < n := by
by_cases pp : p.Prime · exact (pow_lt_pow_iff_right pp.one_lt).1 <| (ord_proj_le p hn).trans_lt <| lt_pow_self pp.one_lt _ · simpa only [factorization_eq_zero_of_non_prime n pp] using hn.bot_lt
import Mathlib.Analysis.Complex.AbsMax import Mathlib.Analysis.LocallyConvex.WithSeminorms import Mathlib.Geometry.Manifold.MFDeriv.Basic import Mathlib.Topology.LocallyConstant.Basic #align_import geometry.manifold.complex from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open scoped Manifold Topology Filter open Function Set Filter Complex variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℂ F] variable {H : Type*} [TopologicalSpace H] {I : ModelWithCorners ℂ E H} [I.Boundaryless] variable {M : Type*} [TopologicalSpace M] [CompactSpace M] [ChartedSpace H M] [SmoothManifoldWithCorners I M] theorem Complex.norm_eventually_eq_of_mdifferentiableAt_of_isLocalMax {f : M → F} {c : M} (hd : ∀ᶠ z in 𝓝 c, MDifferentiableAt I 𝓘(ℂ, F) f z) (hc : IsLocalMax (norm ∘ f) c) : ∀ᶠ y in 𝓝 c, ‖f y‖ = ‖f c‖ := by set e := extChartAt I c have hI : range I = univ := ModelWithCorners.Boundaryless.range_eq_univ have H₁ : 𝓝[range I] (e c) = 𝓝 (e c) := by rw [hI, nhdsWithin_univ] have H₂ : map e.symm (𝓝 (e c)) = 𝓝 c := by rw [← map_extChartAt_symm_nhdsWithin_range I c, H₁] rw [← H₂, eventually_map] replace hd : ∀ᶠ y in 𝓝 (e c), DifferentiableAt ℂ (f ∘ e.symm) y := by have : e.target ∈ 𝓝 (e c) := H₁ ▸ extChartAt_target_mem_nhdsWithin I c filter_upwards [this, Tendsto.eventually H₂.le hd] with y hyt hy₂ have hys : e.symm y ∈ (chartAt H c).source := by rw [← extChartAt_source I c] exact (extChartAt I c).map_target hyt have hfy : f (e.symm y) ∈ (chartAt F (0 : F)).source := mem_univ _ rw [mdifferentiableAt_iff_of_mem_source hys hfy, hI, differentiableWithinAt_univ, e.right_inv hyt] at hy₂ exact hy₂.2 convert norm_eventually_eq_of_isLocalMax hd _ · exact congr_arg f (extChartAt_to_inv _ _).symm · simpa only [e, IsLocalMax, IsMaxFilter, ← H₂, (· ∘ ·), extChartAt_to_inv] using hc namespace MDifferentiableOn theorem norm_eqOn_of_isPreconnected_of_isMaxOn {f : M → F} {U : Set M} {c : M} (hd : MDifferentiableOn I 𝓘(ℂ, F) f U) (hc : IsPreconnected U) (ho : IsOpen U) (hcU : c ∈ U) (hm : IsMaxOn (norm ∘ f) U c) : EqOn (norm ∘ f) (const M ‖f c‖) U := by set V := {z ∈ U | ‖f z‖ = ‖f c‖} suffices U ⊆ V from fun x hx ↦ (this hx).2 have hVo : IsOpen V := by refine isOpen_iff_mem_nhds.2 fun x hx ↦ inter_mem (ho.mem_nhds hx.1) ?_ replace hm : IsLocalMax (‖f ·‖) x := mem_of_superset (ho.mem_nhds hx.1) fun z hz ↦ (hm hz).out.trans_eq hx.2.symm replace hd : ∀ᶠ y in 𝓝 x, MDifferentiableAt I 𝓘(ℂ, F) f y := (eventually_mem_nhds.2 (ho.mem_nhds hx.1)).mono fun z ↦ hd.mdifferentiableAt exact (Complex.norm_eventually_eq_of_mdifferentiableAt_of_isLocalMax hd hm).mono fun _ ↦ (Eq.trans · hx.2) have hVne : (U ∩ V).Nonempty := ⟨c, hcU, hcU, rfl⟩ set W := U ∩ {z | ‖f z‖ = ‖f c‖}ᶜ have hWo : IsOpen W := hd.continuousOn.norm.isOpen_inter_preimage ho isOpen_ne have hdVW : Disjoint V W := disjoint_compl_right.mono inf_le_right inf_le_right have hUVW : U ⊆ V ∪ W := fun x hx => (eq_or_ne ‖f x‖ ‖f c‖).imp (.intro hx) (.intro hx) exact hc.subset_left_of_subset_union hVo hWo hdVW hUVW hVne theorem eqOn_of_isPreconnected_of_isMaxOn_norm [StrictConvexSpace ℝ F] {f : M → F} {U : Set M} {c : M} (hd : MDifferentiableOn I 𝓘(ℂ, F) f U) (hc : IsPreconnected U) (ho : IsOpen U) (hcU : c ∈ U) (hm : IsMaxOn (norm ∘ f) U c) : EqOn f (const M (f c)) U := fun x hx => have H₁ : ‖f x‖ = ‖f c‖ := hd.norm_eqOn_of_isPreconnected_of_isMaxOn hc ho hcU hm hx -- TODO: Add `MDifferentiableOn.add` etc; does it mean importing `Manifold.Algebra.Monoid`? have hd' : MDifferentiableOn I 𝓘(ℂ, F) (f · + f c) U := fun x hx ↦ ⟨(hd x hx).1.add continuousWithinAt_const, (hd x hx).2.add_const _⟩ have H₂ : ‖f x + f c‖ = ‖f c + f c‖ := hd'.norm_eqOn_of_isPreconnected_of_isMaxOn hc ho hcU hm.norm_add_self hx eq_of_norm_eq_of_norm_add_eq H₁ <| by simp only [H₂, SameRay.rfl.norm_add, H₁, Function.const]
Mathlib/Geometry/Manifold/Complex.lean
123
135
theorem apply_eq_of_isPreconnected_isCompact_isOpen {f : M → F} {U : Set M} {a b : M} (hd : MDifferentiableOn I 𝓘(ℂ, F) f U) (hpc : IsPreconnected U) (hc : IsCompact U) (ho : IsOpen U) (ha : a ∈ U) (hb : b ∈ U) : f a = f b := by
refine ?_ -- Subtract `f b` to avoid the assumption `[StrictConvexSpace ℝ F]` wlog hb₀ : f b = 0 generalizing f · have hd' : MDifferentiableOn I 𝓘(ℂ, F) (f · - f b) U := fun x hx ↦ ⟨(hd x hx).1.sub continuousWithinAt_const, (hd x hx).2.sub_const _⟩ simpa [sub_eq_zero] using this hd' (sub_self _) rcases hc.exists_isMaxOn ⟨a, ha⟩ hd.continuousOn.norm with ⟨c, hcU, hc⟩ have : ∀ x ∈ U, ‖f x‖ = ‖f c‖ := norm_eqOn_of_isPreconnected_of_isMaxOn hd hpc ho hcU hc rw [hb₀, ← norm_eq_zero, this a ha, ← this b hb, hb₀, norm_zero]
import Mathlib.Topology.Algebra.InfiniteSum.Group import Mathlib.Logic.Encodable.Lattice noncomputable section open Filter Finset Function Encodable open scoped Topology variable {M : Type*} [CommMonoid M] [TopologicalSpace M] {m m' : M} variable {G : Type*} [CommGroup G] {g g' : G} -- don't declare [TopologicalAddGroup G] here as some results require [UniformAddGroup G] instead section Nat section Monoid namespace HasProd @[to_additive "If `f : ℕ → M` has sum `m`, then the partial sums `∑ i ∈ range n, f i` converge to `m`."] theorem tendsto_prod_nat {f : ℕ → M} (h : HasProd f m) : Tendsto (fun n ↦ ∏ i ∈ range n, f i) atTop (𝓝 m) := h.comp tendsto_finset_range #align has_sum.tendsto_sum_nat HasSum.tendsto_sum_nat @[to_additive "If `f : ℕ → M` is summable, then the partial sums `∑ i ∈ range n, f i` converge to `∑' i, f i`."] theorem Multipliable.tendsto_prod_tprod_nat {f : ℕ → M} (h : Multipliable f) : Tendsto (fun n ↦ ∏ i ∈ range n, f i) atTop (𝓝 (∏' i, f i)) := tendsto_prod_nat h.hasProd namespace Multipliable @[to_additive]
Mathlib/Topology/Algebra/InfiniteSum/NatInt.lean
88
92
theorem hasProd_iff_tendsto_nat [T2Space M] {f : ℕ → M} (hf : Multipliable f) : HasProd f m ↔ Tendsto (fun n : ℕ ↦ ∏ i ∈ range n, f i) atTop (𝓝 m) := by
refine ⟨fun h ↦ h.tendsto_prod_nat, fun h ↦ ?_⟩ rw [tendsto_nhds_unique h hf.hasProd.tendsto_prod_nat] exact hf.hasProd
import Mathlib.Tactic.Qify import Mathlib.Data.ZMod.Basic import Mathlib.NumberTheory.DiophantineApproximation import Mathlib.NumberTheory.Zsqrtd.Basic #align_import number_theory.pell from "leanprover-community/mathlib"@"7ad820c4997738e2f542f8a20f32911f52020e26" namespace Pell open Zsqrtd theorem is_pell_solution_iff_mem_unitary {d : ℤ} {a : ℤ√d} : a.re ^ 2 - d * a.im ^ 2 = 1 ↔ a ∈ unitary (ℤ√d) := by rw [← norm_eq_one_iff_mem_unitary, norm_def, sq, sq, ← mul_assoc] #align pell.is_pell_solution_iff_mem_unitary Pell.is_pell_solution_iff_mem_unitary -- We use `solution₁ d` to allow for a more general structure `solution d m` that -- encodes solutions to `x^2 - d*y^2 = m` to be added later. def Solution₁ (d : ℤ) : Type := ↥(unitary (ℤ√d)) #align pell.solution₁ Pell.Solution₁ namespace Solution₁ variable {d : ℤ} -- Porting note(https://github.com/leanprover-community/mathlib4/issues/5020): manual deriving instance instCommGroup : CommGroup (Solution₁ d) := inferInstanceAs (CommGroup (unitary (ℤ√d))) #align pell.solution₁.comm_group Pell.Solution₁.instCommGroup instance instHasDistribNeg : HasDistribNeg (Solution₁ d) := inferInstanceAs (HasDistribNeg (unitary (ℤ√d))) #align pell.solution₁.has_distrib_neg Pell.Solution₁.instHasDistribNeg instance instInhabited : Inhabited (Solution₁ d) := inferInstanceAs (Inhabited (unitary (ℤ√d))) #align pell.solution₁.inhabited Pell.Solution₁.instInhabited instance : Coe (Solution₁ d) (ℤ√d) where coe := Subtype.val protected def x (a : Solution₁ d) : ℤ := (a : ℤ√d).re #align pell.solution₁.x Pell.Solution₁.x protected def y (a : Solution₁ d) : ℤ := (a : ℤ√d).im #align pell.solution₁.y Pell.Solution₁.y theorem prop (a : Solution₁ d) : a.x ^ 2 - d * a.y ^ 2 = 1 := is_pell_solution_iff_mem_unitary.mpr a.property #align pell.solution₁.prop Pell.Solution₁.prop theorem prop_x (a : Solution₁ d) : a.x ^ 2 = 1 + d * a.y ^ 2 := by rw [← a.prop]; ring #align pell.solution₁.prop_x Pell.Solution₁.prop_x theorem prop_y (a : Solution₁ d) : d * a.y ^ 2 = a.x ^ 2 - 1 := by rw [← a.prop]; ring #align pell.solution₁.prop_y Pell.Solution₁.prop_y @[ext] theorem ext {a b : Solution₁ d} (hx : a.x = b.x) (hy : a.y = b.y) : a = b := Subtype.ext <| Zsqrtd.ext _ _ hx hy #align pell.solution₁.ext Pell.Solution₁.ext def mk (x y : ℤ) (prop : x ^ 2 - d * y ^ 2 = 1) : Solution₁ d where val := ⟨x, y⟩ property := is_pell_solution_iff_mem_unitary.mp prop #align pell.solution₁.mk Pell.Solution₁.mk @[simp] theorem x_mk (x y : ℤ) (prop : x ^ 2 - d * y ^ 2 = 1) : (mk x y prop).x = x := rfl #align pell.solution₁.x_mk Pell.Solution₁.x_mk @[simp] theorem y_mk (x y : ℤ) (prop : x ^ 2 - d * y ^ 2 = 1) : (mk x y prop).y = y := rfl #align pell.solution₁.y_mk Pell.Solution₁.y_mk @[simp] theorem coe_mk (x y : ℤ) (prop : x ^ 2 - d * y ^ 2 = 1) : (↑(mk x y prop) : ℤ√d) = ⟨x, y⟩ := Zsqrtd.ext _ _ (x_mk x y prop) (y_mk x y prop) #align pell.solution₁.coe_mk Pell.Solution₁.coe_mk @[simp] theorem x_one : (1 : Solution₁ d).x = 1 := rfl #align pell.solution₁.x_one Pell.Solution₁.x_one @[simp] theorem y_one : (1 : Solution₁ d).y = 0 := rfl #align pell.solution₁.y_one Pell.Solution₁.y_one @[simp] theorem x_mul (a b : Solution₁ d) : (a * b).x = a.x * b.x + d * (a.y * b.y) := by rw [← mul_assoc] rfl #align pell.solution₁.x_mul Pell.Solution₁.x_mul @[simp] theorem y_mul (a b : Solution₁ d) : (a * b).y = a.x * b.y + a.y * b.x := rfl #align pell.solution₁.y_mul Pell.Solution₁.y_mul @[simp] theorem x_inv (a : Solution₁ d) : a⁻¹.x = a.x := rfl #align pell.solution₁.x_inv Pell.Solution₁.x_inv @[simp] theorem y_inv (a : Solution₁ d) : a⁻¹.y = -a.y := rfl #align pell.solution₁.y_inv Pell.Solution₁.y_inv @[simp] theorem x_neg (a : Solution₁ d) : (-a).x = -a.x := rfl #align pell.solution₁.x_neg Pell.Solution₁.x_neg @[simp] theorem y_neg (a : Solution₁ d) : (-a).y = -a.y := rfl #align pell.solution₁.y_neg Pell.Solution₁.y_neg theorem eq_zero_of_d_neg (h₀ : d < 0) (a : Solution₁ d) : a.x = 0 ∨ a.y = 0 := by have h := a.prop contrapose! h have h1 := sq_pos_of_ne_zero h.1 have h2 := sq_pos_of_ne_zero h.2 nlinarith #align pell.solution₁.eq_zero_of_d_neg Pell.Solution₁.eq_zero_of_d_neg theorem x_ne_zero (h₀ : 0 ≤ d) (a : Solution₁ d) : a.x ≠ 0 := by intro hx have h : 0 ≤ d * a.y ^ 2 := mul_nonneg h₀ (sq_nonneg _) rw [a.prop_y, hx, sq, zero_mul, zero_sub] at h exact not_le.mpr (neg_one_lt_zero : (-1 : ℤ) < 0) h #align pell.solution₁.x_ne_zero Pell.Solution₁.x_ne_zero theorem y_ne_zero_of_one_lt_x {a : Solution₁ d} (ha : 1 < a.x) : a.y ≠ 0 := by intro hy have prop := a.prop rw [hy, sq (0 : ℤ), zero_mul, mul_zero, sub_zero] at prop exact lt_irrefl _ (((one_lt_sq_iff <| zero_le_one.trans ha.le).mpr ha).trans_eq prop) #align pell.solution₁.y_ne_zero_of_one_lt_x Pell.Solution₁.y_ne_zero_of_one_lt_x theorem d_pos_of_one_lt_x {a : Solution₁ d} (ha : 1 < a.x) : 0 < d := by refine pos_of_mul_pos_left ?_ (sq_nonneg a.y) rw [a.prop_y, sub_pos] exact one_lt_pow ha two_ne_zero #align pell.solution₁.d_pos_of_one_lt_x Pell.Solution₁.d_pos_of_one_lt_x theorem d_nonsquare_of_one_lt_x {a : Solution₁ d} (ha : 1 < a.x) : ¬IsSquare d := by have hp := a.prop rintro ⟨b, rfl⟩ simp_rw [← sq, ← mul_pow, sq_sub_sq, Int.mul_eq_one_iff_eq_one_or_neg_one] at hp rcases hp with (⟨hp₁, hp₂⟩ | ⟨hp₁, hp₂⟩) <;> omega #align pell.solution₁.d_nonsquare_of_one_lt_x Pell.Solution₁.d_nonsquare_of_one_lt_x theorem eq_one_of_x_eq_one (h₀ : d ≠ 0) {a : Solution₁ d} (ha : a.x = 1) : a = 1 := by have prop := a.prop_y rw [ha, one_pow, sub_self, mul_eq_zero, or_iff_right h₀, sq_eq_zero_iff] at prop exact ext ha prop #align pell.solution₁.eq_one_of_x_eq_one Pell.Solution₁.eq_one_of_x_eq_one theorem eq_one_or_neg_one_iff_y_eq_zero {a : Solution₁ d} : a = 1 ∨ a = -1 ↔ a.y = 0 := by refine ⟨fun H => H.elim (fun h => by simp [h]) fun h => by simp [h], fun H => ?_⟩ have prop := a.prop rw [H, sq (0 : ℤ), mul_zero, mul_zero, sub_zero, sq_eq_one_iff] at prop exact prop.imp (fun h => ext h H) fun h => ext h H #align pell.solution₁.eq_one_or_neg_one_iff_y_eq_zero Pell.Solution₁.eq_one_or_neg_one_iff_y_eq_zero theorem x_mul_pos {a b : Solution₁ d} (ha : 0 < a.x) (hb : 0 < b.x) : 0 < (a * b).x := by simp only [x_mul] refine neg_lt_iff_pos_add'.mp (abs_lt.mp ?_).1 rw [← abs_of_pos ha, ← abs_of_pos hb, ← abs_mul, ← sq_lt_sq, mul_pow a.x, a.prop_x, b.prop_x, ← sub_pos] ring_nf rcases le_or_lt 0 d with h | h · positivity · rw [(eq_zero_of_d_neg h a).resolve_left ha.ne', (eq_zero_of_d_neg h b).resolve_left hb.ne'] -- Porting note: was -- rw [zero_pow two_ne_zero, zero_add, zero_mul, zero_add] -- exact one_pos -- but this relied on the exact output of `ring_nf` simp #align pell.solution₁.x_mul_pos Pell.Solution₁.x_mul_pos
Mathlib/NumberTheory/Pell.lean
281
284
theorem y_mul_pos {a b : Solution₁ d} (hax : 0 < a.x) (hay : 0 < a.y) (hbx : 0 < b.x) (hby : 0 < b.y) : 0 < (a * b).y := by
simp only [y_mul] positivity
namespace Nat @[reducible] def Coprime (m n : Nat) : Prop := gcd m n = 1 instance (m n : Nat) : Decidable (Coprime m n) := inferInstanceAs (Decidable (_ = 1)) theorem coprime_iff_gcd_eq_one : Coprime m n ↔ gcd m n = 1 := .rfl theorem Coprime.gcd_eq_one : Coprime m n → gcd m n = 1 := id theorem Coprime.symm : Coprime n m → Coprime m n := (gcd_comm m n).trans theorem coprime_comm : Coprime n m ↔ Coprime m n := ⟨Coprime.symm, Coprime.symm⟩ theorem Coprime.dvd_of_dvd_mul_right (H1 : Coprime k n) (H2 : k ∣ m * n) : k ∣ m := by let t := dvd_gcd (Nat.dvd_mul_left k m) H2 rwa [gcd_mul_left, H1.gcd_eq_one, Nat.mul_one] at t theorem Coprime.dvd_of_dvd_mul_left (H1 : Coprime k m) (H2 : k ∣ m * n) : k ∣ n := H1.dvd_of_dvd_mul_right (by rwa [Nat.mul_comm]) theorem Coprime.gcd_mul_left_cancel (m : Nat) (H : Coprime k n) : gcd (k * m) n = gcd m n := have H1 : Coprime (gcd (k * m) n) k := by rw [Coprime, Nat.gcd_assoc, H.symm.gcd_eq_one, gcd_one_right] Nat.dvd_antisymm (dvd_gcd (H1.dvd_of_dvd_mul_left (gcd_dvd_left _ _)) (gcd_dvd_right _ _)) (gcd_dvd_gcd_mul_left _ _ _) theorem Coprime.gcd_mul_right_cancel (m : Nat) (H : Coprime k n) : gcd (m * k) n = gcd m n := by rw [Nat.mul_comm m k, H.gcd_mul_left_cancel m] theorem Coprime.gcd_mul_left_cancel_right (n : Nat) (H : Coprime k m) : gcd m (k * n) = gcd m n := by rw [gcd_comm m n, gcd_comm m (k * n), H.gcd_mul_left_cancel n] theorem Coprime.gcd_mul_right_cancel_right (n : Nat) (H : Coprime k m) : gcd m (n * k) = gcd m n := by rw [Nat.mul_comm n k, H.gcd_mul_left_cancel_right n] theorem coprime_div_gcd_div_gcd (H : 0 < gcd m n) : Coprime (m / gcd m n) (n / gcd m n) := by rw [coprime_iff_gcd_eq_one, gcd_div (gcd_dvd_left m n) (gcd_dvd_right m n), Nat.div_self H] theorem not_coprime_of_dvd_of_dvd (dgt1 : 1 < d) (Hm : d ∣ m) (Hn : d ∣ n) : ¬ Coprime m n := fun co => Nat.not_le_of_gt dgt1 <| Nat.le_of_dvd Nat.zero_lt_one <| by rw [← co.gcd_eq_one]; exact dvd_gcd Hm Hn theorem exists_coprime (m n : Nat) : ∃ m' n', Coprime m' n' ∧ m = m' * gcd m n ∧ n = n' * gcd m n := by cases eq_zero_or_pos (gcd m n) with | inl h0 => rw [gcd_eq_zero_iff] at h0 refine ⟨1, 1, gcd_one_left 1, ?_⟩ simp [h0] | inr hpos => exact ⟨_, _, coprime_div_gcd_div_gcd hpos, (Nat.div_mul_cancel (gcd_dvd_left m n)).symm, (Nat.div_mul_cancel (gcd_dvd_right m n)).symm⟩ theorem exists_coprime' (H : 0 < gcd m n) : ∃ g m' n', 0 < g ∧ Coprime m' n' ∧ m = m' * g ∧ n = n' * g := let ⟨m', n', h⟩ := exists_coprime m n; ⟨_, m', n', H, h⟩ theorem Coprime.mul (H1 : Coprime m k) (H2 : Coprime n k) : Coprime (m * n) k := (H1.gcd_mul_left_cancel n).trans H2 theorem Coprime.mul_right (H1 : Coprime k m) (H2 : Coprime k n) : Coprime k (m * n) := (H1.symm.mul H2.symm).symm theorem Coprime.coprime_dvd_left (H1 : m ∣ k) (H2 : Coprime k n) : Coprime m n := by apply eq_one_of_dvd_one rw [Coprime] at H2 have := Nat.gcd_dvd_gcd_of_dvd_left n H1 rwa [← H2] theorem Coprime.coprime_dvd_right (H1 : n ∣ m) (H2 : Coprime k m) : Coprime k n := (H2.symm.coprime_dvd_left H1).symm theorem Coprime.coprime_mul_left (H : Coprime (k * m) n) : Coprime m n := H.coprime_dvd_left (Nat.dvd_mul_left _ _) theorem Coprime.coprime_mul_right (H : Coprime (m * k) n) : Coprime m n := H.coprime_dvd_left (Nat.dvd_mul_right _ _) theorem Coprime.coprime_mul_left_right (H : Coprime m (k * n)) : Coprime m n := H.coprime_dvd_right (Nat.dvd_mul_left _ _) theorem Coprime.coprime_mul_right_right (H : Coprime m (n * k)) : Coprime m n := H.coprime_dvd_right (Nat.dvd_mul_right _ _)
.lake/packages/batteries/Batteries/Data/Nat/Gcd.lean
108
118
theorem Coprime.coprime_div_left (cmn : Coprime m n) (dvd : a ∣ m) : Coprime (m / a) n := by
match eq_zero_or_pos a with | .inl h0 => rw [h0] at dvd rw [Nat.eq_zero_of_zero_dvd dvd] at cmn ⊢ simp; assumption | .inr hpos => let ⟨k, hk⟩ := dvd rw [hk, Nat.mul_div_cancel_left _ hpos] rw [hk] at cmn exact cmn.coprime_mul_left
import Mathlib.CategoryTheory.Preadditive.Yoneda.Basic import Mathlib.CategoryTheory.Preadditive.Injective import Mathlib.Algebra.Category.GroupCat.EpiMono import Mathlib.Algebra.Category.ModuleCat.EpiMono #align_import category_theory.preadditive.yoneda.injective from "leanprover-community/mathlib"@"f8d8465c3c392a93b9ed226956e26dee00975946" universe v u open Opposite namespace CategoryTheory variable {C : Type u} [Category.{v} C] section Preadditive variable [Preadditive C] namespace Injective theorem injective_iff_preservesEpimorphisms_preadditiveYoneda_obj (J : C) : Injective J ↔ (preadditiveYoneda.obj J).PreservesEpimorphisms := by rw [injective_iff_preservesEpimorphisms_yoneda_obj] refine ⟨fun h : (preadditiveYoneda.obj J ⋙ (forget AddCommGroupCat)).PreservesEpimorphisms => ?_, ?_⟩ · exact Functor.preservesEpimorphisms_of_preserves_of_reflects (preadditiveYoneda.obj J) (forget _) · intro exact (inferInstance : (preadditiveYoneda.obj J ⋙ forget _).PreservesEpimorphisms) #align category_theory.injective.injective_iff_preserves_epimorphisms_preadditive_yoneda_obj CategoryTheory.Injective.injective_iff_preservesEpimorphisms_preadditiveYoneda_obj
Mathlib/CategoryTheory/Preadditive/Yoneda/Injective.lean
43
51
theorem injective_iff_preservesEpimorphisms_preadditive_yoneda_obj' (J : C) : Injective J ↔ (preadditiveYonedaObj J).PreservesEpimorphisms := by
rw [injective_iff_preservesEpimorphisms_yoneda_obj] refine ⟨fun h : (preadditiveYonedaObj J ⋙ (forget <| ModuleCat (End J))).PreservesEpimorphisms => ?_, ?_⟩ · exact Functor.preservesEpimorphisms_of_preserves_of_reflects (preadditiveYonedaObj J) (forget _) · intro exact (inferInstance : (preadditiveYonedaObj J ⋙ forget _).PreservesEpimorphisms)
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv #align_import analysis.special_functions.trigonometric.inverse_deriv from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" noncomputable section open scoped Classical Topology Filter open Set Filter open scoped Real namespace Real section Arcsin theorem deriv_arcsin_aux {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) : HasStrictDerivAt arcsin (1 / √(1 - x ^ 2)) x ∧ ContDiffAt ℝ ⊤ arcsin x := by cases' h₁.lt_or_lt with h₁ h₁ · have : 1 - x ^ 2 < 0 := by nlinarith [h₁] rw [sqrt_eq_zero'.2 this.le, div_zero] have : arcsin =ᶠ[𝓝 x] fun _ => -(π / 2) := (gt_mem_nhds h₁).mono fun y hy => arcsin_of_le_neg_one hy.le exact ⟨(hasStrictDerivAt_const _ _).congr_of_eventuallyEq this.symm, contDiffAt_const.congr_of_eventuallyEq this⟩ cases' h₂.lt_or_lt with h₂ h₂ · have : 0 < √(1 - x ^ 2) := sqrt_pos.2 (by nlinarith [h₁, h₂]) simp only [← cos_arcsin, one_div] at this ⊢ exact ⟨sinPartialHomeomorph.hasStrictDerivAt_symm ⟨h₁, h₂⟩ this.ne' (hasStrictDerivAt_sin _), sinPartialHomeomorph.contDiffAt_symm_deriv this.ne' ⟨h₁, h₂⟩ (hasDerivAt_sin _) contDiff_sin.contDiffAt⟩ · have : 1 - x ^ 2 < 0 := by nlinarith [h₂] rw [sqrt_eq_zero'.2 this.le, div_zero] have : arcsin =ᶠ[𝓝 x] fun _ => π / 2 := (lt_mem_nhds h₂).mono fun y hy => arcsin_of_one_le hy.le exact ⟨(hasStrictDerivAt_const _ _).congr_of_eventuallyEq this.symm, contDiffAt_const.congr_of_eventuallyEq this⟩ #align real.deriv_arcsin_aux Real.deriv_arcsin_aux theorem hasStrictDerivAt_arcsin {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) : HasStrictDerivAt arcsin (1 / √(1 - x ^ 2)) x := (deriv_arcsin_aux h₁ h₂).1 #align real.has_strict_deriv_at_arcsin Real.hasStrictDerivAt_arcsin theorem hasDerivAt_arcsin {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) : HasDerivAt arcsin (1 / √(1 - x ^ 2)) x := (hasStrictDerivAt_arcsin h₁ h₂).hasDerivAt #align real.has_deriv_at_arcsin Real.hasDerivAt_arcsin theorem contDiffAt_arcsin {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) {n : ℕ∞} : ContDiffAt ℝ n arcsin x := (deriv_arcsin_aux h₁ h₂).2.of_le le_top #align real.cont_diff_at_arcsin Real.contDiffAt_arcsin
Mathlib/Analysis/SpecialFunctions/Trigonometric/InverseDeriv.lean
66
71
theorem hasDerivWithinAt_arcsin_Ici {x : ℝ} (h : x ≠ -1) : HasDerivWithinAt arcsin (1 / √(1 - x ^ 2)) (Ici x) x := by
rcases eq_or_ne x 1 with (rfl | h') · convert (hasDerivWithinAt_const (1 : ℝ) _ (π / 2)).congr _ _ <;> simp (config := { contextual := true }) [arcsin_of_one_le] · exact (hasDerivAt_arcsin h h').hasDerivWithinAt
import Mathlib.Order.Interval.Multiset #align_import data.nat.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29" -- TODO -- assert_not_exists Ring open Finset Nat variable (a b c : ℕ) namespace Nat instance instLocallyFiniteOrder : LocallyFiniteOrder ℕ where finsetIcc a b := ⟨List.range' a (b + 1 - a), List.nodup_range' _ _⟩ finsetIco a b := ⟨List.range' a (b - a), List.nodup_range' _ _⟩ finsetIoc a b := ⟨List.range' (a + 1) (b - a), List.nodup_range' _ _⟩ finsetIoo a b := ⟨List.range' (a + 1) (b - a - 1), List.nodup_range' _ _⟩ finset_mem_Icc a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega finset_mem_Ico a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega finset_mem_Ioc a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega finset_mem_Ioo a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega theorem Icc_eq_range' : Icc a b = ⟨List.range' a (b + 1 - a), List.nodup_range' _ _⟩ := rfl #align nat.Icc_eq_range' Nat.Icc_eq_range' theorem Ico_eq_range' : Ico a b = ⟨List.range' a (b - a), List.nodup_range' _ _⟩ := rfl #align nat.Ico_eq_range' Nat.Ico_eq_range' theorem Ioc_eq_range' : Ioc a b = ⟨List.range' (a + 1) (b - a), List.nodup_range' _ _⟩ := rfl #align nat.Ioc_eq_range' Nat.Ioc_eq_range' theorem Ioo_eq_range' : Ioo a b = ⟨List.range' (a + 1) (b - a - 1), List.nodup_range' _ _⟩ := rfl #align nat.Ioo_eq_range' Nat.Ioo_eq_range' theorem uIcc_eq_range' : uIcc a b = ⟨List.range' (min a b) (max a b + 1 - min a b), List.nodup_range' _ _⟩ := rfl #align nat.uIcc_eq_range' Nat.uIcc_eq_range' theorem Iio_eq_range : Iio = range := by ext b x rw [mem_Iio, mem_range] #align nat.Iio_eq_range Nat.Iio_eq_range @[simp] theorem Ico_zero_eq_range : Ico 0 = range := by rw [← Nat.bot_eq_zero, ← Iio_eq_Ico, Iio_eq_range] #align nat.Ico_zero_eq_range Nat.Ico_zero_eq_range lemma range_eq_Icc_zero_sub_one (n : ℕ) (hn : n ≠ 0): range n = Icc 0 (n - 1) := by ext b simp_all only [mem_Icc, zero_le, true_and, mem_range] exact lt_iff_le_pred (zero_lt_of_ne_zero hn) theorem _root_.Finset.range_eq_Ico : range = Ico 0 := Ico_zero_eq_range.symm #align finset.range_eq_Ico Finset.range_eq_Ico @[simp] theorem card_Icc : (Icc a b).card = b + 1 - a := List.length_range' _ _ _ #align nat.card_Icc Nat.card_Icc @[simp] theorem card_Ico : (Ico a b).card = b - a := List.length_range' _ _ _ #align nat.card_Ico Nat.card_Ico @[simp] theorem card_Ioc : (Ioc a b).card = b - a := List.length_range' _ _ _ #align nat.card_Ioc Nat.card_Ioc @[simp] theorem card_Ioo : (Ioo a b).card = b - a - 1 := List.length_range' _ _ _ #align nat.card_Ioo Nat.card_Ioo @[simp] theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 := (card_Icc _ _).trans $ by rw [← Int.natCast_inj, sup_eq_max, inf_eq_min, Int.ofNat_sub] <;> omega #align nat.card_uIcc Nat.card_uIcc @[simp] lemma card_Iic : (Iic b).card = b + 1 := by rw [Iic_eq_Icc, card_Icc, Nat.bot_eq_zero, Nat.sub_zero] #align nat.card_Iic Nat.card_Iic @[simp] theorem card_Iio : (Iio b).card = b := by rw [Iio_eq_Ico, card_Ico, Nat.bot_eq_zero, Nat.sub_zero] #align nat.card_Iio Nat.card_Iio -- Porting note (#10618): simp can prove this -- @[simp] theorem card_fintypeIcc : Fintype.card (Set.Icc a b) = b + 1 - a := by rw [Fintype.card_ofFinset, card_Icc] #align nat.card_fintype_Icc Nat.card_fintypeIcc -- Porting note (#10618): simp can prove this -- @[simp] theorem card_fintypeIco : Fintype.card (Set.Ico a b) = b - a := by rw [Fintype.card_ofFinset, card_Ico] #align nat.card_fintype_Ico Nat.card_fintypeIco -- Porting note (#10618): simp can prove this -- @[simp] theorem card_fintypeIoc : Fintype.card (Set.Ioc a b) = b - a := by rw [Fintype.card_ofFinset, card_Ioc] #align nat.card_fintype_Ioc Nat.card_fintypeIoc -- Porting note (#10618): simp can prove this -- @[simp] theorem card_fintypeIoo : Fintype.card (Set.Ioo a b) = b - a - 1 := by rw [Fintype.card_ofFinset, card_Ioo] #align nat.card_fintype_Ioo Nat.card_fintypeIoo -- Porting note (#10618): simp can prove this -- @[simp] theorem card_fintypeIic : Fintype.card (Set.Iic b) = b + 1 := by rw [Fintype.card_ofFinset, card_Iic] #align nat.card_fintype_Iic Nat.card_fintypeIic -- Porting note (#10618): simp can prove this -- @[simp] theorem card_fintypeIio : Fintype.card (Set.Iio b) = b := by rw [Fintype.card_ofFinset, card_Iio] #align nat.card_fintype_Iio Nat.card_fintypeIio -- TODO@Yaël: Generalize all the following lemmas to `SuccOrder` theorem Icc_succ_left : Icc a.succ b = Ioc a b := by ext x rw [mem_Icc, mem_Ioc, succ_le_iff] #align nat.Icc_succ_left Nat.Icc_succ_left theorem Ico_succ_right : Ico a b.succ = Icc a b := by ext x rw [mem_Ico, mem_Icc, Nat.lt_succ_iff] #align nat.Ico_succ_right Nat.Ico_succ_right theorem Ico_succ_left : Ico a.succ b = Ioo a b := by ext x rw [mem_Ico, mem_Ioo, succ_le_iff] #align nat.Ico_succ_left Nat.Ico_succ_left theorem Icc_pred_right {b : ℕ} (h : 0 < b) : Icc a (b - 1) = Ico a b := by ext x rw [mem_Icc, mem_Ico, lt_iff_le_pred h] #align nat.Icc_pred_right Nat.Icc_pred_right theorem Ico_succ_succ : Ico a.succ b.succ = Ioc a b := by ext x rw [mem_Ico, mem_Ioc, succ_le_iff, Nat.lt_succ_iff] #align nat.Ico_succ_succ Nat.Ico_succ_succ @[simp] theorem Ico_succ_singleton : Ico a (a + 1) = {a} := by rw [Ico_succ_right, Icc_self] #align nat.Ico_succ_singleton Nat.Ico_succ_singleton @[simp]
Mathlib/Order/Interval/Finset/Nat.lean
178
179
theorem Ico_pred_singleton {a : ℕ} (h : 0 < a) : Ico (a - 1) a = {a - 1} := by
rw [← Icc_pred_right _ h, Icc_self]