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.CategoryTheory.EpiMono import Mathlib.CategoryTheory.Functor.FullyFaithful import Mathlib.Tactic.PPWithUniv import Mathlib.Data.Set.Defs #align_import category_theory.types from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded" namespace CategoryTheory -- morphism levels before object levels. See note [CategoryTheory universes]. universe v v' w u u' @[to_additive existing CategoryTheory.types] instance types : LargeCategory (Type u) where Hom a b := a → b id a := id comp f g := g ∘ f #align category_theory.types CategoryTheory.types theorem types_hom {α β : Type u} : (α ⟶ β) = (α → β) := rfl #align category_theory.types_hom CategoryTheory.types_hom -- porting note (#10688): this lemma was not here in Lean 3. Lean 3 `ext` would solve this goal -- because of its "if all else fails, apply all `ext` lemmas" policy, -- which apparently we want to move away from. @[ext] theorem types_ext {α β : Type u} (f g : α ⟶ β) (h : ∀ a : α, f a = g a) : f = g := by funext x exact h x theorem types_id (X : Type u) : 𝟙 X = id := rfl #align category_theory.types_id CategoryTheory.types_id theorem types_comp {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) : f ≫ g = g ∘ f := rfl #align category_theory.types_comp CategoryTheory.types_comp @[simp] theorem types_id_apply (X : Type u) (x : X) : (𝟙 X : X → X) x = x := rfl #align category_theory.types_id_apply CategoryTheory.types_id_apply @[simp] theorem types_comp_apply {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : (f ≫ g) x = g (f x) := rfl #align category_theory.types_comp_apply CategoryTheory.types_comp_apply @[simp] theorem hom_inv_id_apply {X Y : Type u} (f : X ≅ Y) (x : X) : f.inv (f.hom x) = x := congr_fun f.hom_inv_id x #align category_theory.hom_inv_id_apply CategoryTheory.hom_inv_id_apply @[simp] theorem inv_hom_id_apply {X Y : Type u} (f : X ≅ Y) (y : Y) : f.hom (f.inv y) = y := congr_fun f.inv_hom_id y #align category_theory.inv_hom_id_apply CategoryTheory.inv_hom_id_apply -- Unfortunately without this wrapper we can't use `CategoryTheory` idioms, such as `IsIso f`. abbrev asHom {α β : Type u} (f : α → β) : α ⟶ β := f #align category_theory.as_hom CategoryTheory.asHom @[inherit_doc] scoped notation "↾" f:200 => CategoryTheory.asHom f section -- We verify the expected type checking behaviour of `asHom` variable (α β γ : Type u) (f : α → β) (g : β → γ) example : α → γ := ↾f ≫ ↾g example [IsIso (↾f)] : Mono (↾f) := by infer_instance example [IsIso (↾f)] : ↾f ≫ inv (↾f) = 𝟙 α := by simp end def uliftTrivial (V : Type u) : ULift.{u} V ≅ V where hom a := a.1 inv a := .up a #align category_theory.ulift_trivial CategoryTheory.uliftTrivial @[pp_with_univ] def uliftFunctor : Type u ⥤ Type max u v where obj X := ULift.{v} X map {X} {Y} f := fun x : ULift.{v} X => ULift.up (f x.down) #align category_theory.ulift_functor CategoryTheory.uliftFunctor @[simp] theorem uliftFunctor_map {X Y : Type u} (f : X ⟶ Y) (x : ULift.{v} X) : uliftFunctor.map f x = ULift.up (f x.down) := rfl #align category_theory.ulift_functor_map CategoryTheory.uliftFunctor_map instance uliftFunctor_full : Functor.Full.{u} uliftFunctor where map_surjective f := ⟨fun x => (f (ULift.up x)).down, rfl⟩ #align category_theory.ulift_functor_full CategoryTheory.uliftFunctor_full instance uliftFunctor_faithful : uliftFunctor.Faithful where map_injective {_X} {_Y} f g p := funext fun x => congr_arg ULift.down (congr_fun p (ULift.up x) : ULift.up (f x) = ULift.up (g x)) #align category_theory.ulift_functor_faithful CategoryTheory.uliftFunctor_faithful def uliftFunctorTrivial : uliftFunctor.{u, u} ≅ 𝟭 _ := NatIso.ofComponents uliftTrivial #align category_theory.ulift_functor_trivial CategoryTheory.uliftFunctorTrivial -- TODO We should connect this to a general story about concrete categories -- whose forgetful functor is representable. def homOfElement {X : Type u} (x : X) : PUnit ⟶ X := fun _ => x #align category_theory.hom_of_element CategoryTheory.homOfElement theorem homOfElement_eq_iff {X : Type u} (x y : X) : homOfElement x = homOfElement y ↔ x = y := ⟨fun H => congr_fun H PUnit.unit, by aesop⟩ #align category_theory.hom_of_element_eq_iff CategoryTheory.homOfElement_eq_iff theorem mono_iff_injective {X Y : Type u} (f : X ⟶ Y) : Mono f ↔ Function.Injective f := by constructor · intro H x x' h rw [← homOfElement_eq_iff] at h ⊢ exact (cancel_mono f).mp h · exact fun H => ⟨fun g g' h => H.comp_left h⟩ #align category_theory.mono_iff_injective CategoryTheory.mono_iff_injective theorem injective_of_mono {X Y : Type u} (f : X ⟶ Y) [hf : Mono f] : Function.Injective f := (mono_iff_injective f).1 hf #align category_theory.injective_of_mono CategoryTheory.injective_of_mono
Mathlib/CategoryTheory/Types.lean
272
280
theorem epi_iff_surjective {X Y : Type u} (f : X ⟶ Y) : Epi f ↔ Function.Surjective f := by
constructor · rintro ⟨H⟩ refine Function.surjective_of_right_cancellable_Prop fun g₁ g₂ hg => ?_ rw [← Equiv.ulift.symm.injective.comp_left.eq_iff] apply H change ULift.up ∘ g₁ ∘ f = ULift.up ∘ g₂ ∘ f rw [hg] · exact fun H => ⟨fun g g' h => H.injective_comp_right h⟩
import Mathlib.Algebra.Order.ZeroLEOne import Mathlib.Data.List.InsertNth import Mathlib.Logic.Relation import Mathlib.Logic.Small.Defs import Mathlib.Order.GameAdd #align_import set_theory.game.pgame from "leanprover-community/mathlib"@"8900d545017cd21961daa2a1734bb658ef52c618" set_option autoImplicit true namespace SetTheory open Function Relation -- We'd like to be able to use multi-character auto-implicits in this file. set_option relaxedAutoImplicit true inductive PGame : Type (u + 1) | mk : ∀ α β : Type u, (α → PGame) → (β → PGame) → PGame #align pgame SetTheory.PGame compile_inductive% PGame namespace PGame def LeftMoves : PGame → Type u | mk l _ _ _ => l #align pgame.left_moves SetTheory.PGame.LeftMoves def RightMoves : PGame → Type u | mk _ r _ _ => r #align pgame.right_moves SetTheory.PGame.RightMoves def moveLeft : ∀ g : PGame, LeftMoves g → PGame | mk _l _ L _ => L #align pgame.move_left SetTheory.PGame.moveLeft def moveRight : ∀ g : PGame, RightMoves g → PGame | mk _ _r _ R => R #align pgame.move_right SetTheory.PGame.moveRight @[simp] theorem leftMoves_mk {xl xr xL xR} : (⟨xl, xr, xL, xR⟩ : PGame).LeftMoves = xl := rfl #align pgame.left_moves_mk SetTheory.PGame.leftMoves_mk @[simp] theorem moveLeft_mk {xl xr xL xR} : (⟨xl, xr, xL, xR⟩ : PGame).moveLeft = xL := rfl #align pgame.move_left_mk SetTheory.PGame.moveLeft_mk @[simp] theorem rightMoves_mk {xl xr xL xR} : (⟨xl, xr, xL, xR⟩ : PGame).RightMoves = xr := rfl #align pgame.right_moves_mk SetTheory.PGame.rightMoves_mk @[simp] theorem moveRight_mk {xl xr xL xR} : (⟨xl, xr, xL, xR⟩ : PGame).moveRight = xR := rfl #align pgame.move_right_mk SetTheory.PGame.moveRight_mk -- TODO define this at the level of games, as well, and perhaps also for finsets of games. def ofLists (L R : List PGame.{u}) : PGame.{u} := mk (ULift (Fin L.length)) (ULift (Fin R.length)) (fun i => L.get i.down) fun j ↦ R.get j.down #align pgame.of_lists SetTheory.PGame.ofLists theorem leftMoves_ofLists (L R : List PGame) : (ofLists L R).LeftMoves = ULift (Fin L.length) := rfl #align pgame.left_moves_of_lists SetTheory.PGame.leftMoves_ofLists theorem rightMoves_ofLists (L R : List PGame) : (ofLists L R).RightMoves = ULift (Fin R.length) := rfl #align pgame.right_moves_of_lists SetTheory.PGame.rightMoves_ofLists def toOfListsLeftMoves {L R : List PGame} : Fin L.length ≃ (ofLists L R).LeftMoves := ((Equiv.cast (leftMoves_ofLists L R).symm).trans Equiv.ulift).symm #align pgame.to_of_lists_left_moves SetTheory.PGame.toOfListsLeftMoves def toOfListsRightMoves {L R : List PGame} : Fin R.length ≃ (ofLists L R).RightMoves := ((Equiv.cast (rightMoves_ofLists L R).symm).trans Equiv.ulift).symm #align pgame.to_of_lists_right_moves SetTheory.PGame.toOfListsRightMoves theorem ofLists_moveLeft {L R : List PGame} (i : Fin L.length) : (ofLists L R).moveLeft (toOfListsLeftMoves i) = L.get i := rfl #align pgame.of_lists_move_left SetTheory.PGame.ofLists_moveLeft @[simp] theorem ofLists_moveLeft' {L R : List PGame} (i : (ofLists L R).LeftMoves) : (ofLists L R).moveLeft i = L.get (toOfListsLeftMoves.symm i) := rfl #align pgame.of_lists_move_left' SetTheory.PGame.ofLists_moveLeft' theorem ofLists_moveRight {L R : List PGame} (i : Fin R.length) : (ofLists L R).moveRight (toOfListsRightMoves i) = R.get i := rfl #align pgame.of_lists_move_right SetTheory.PGame.ofLists_moveRight @[simp] theorem ofLists_moveRight' {L R : List PGame} (i : (ofLists L R).RightMoves) : (ofLists L R).moveRight i = R.get (toOfListsRightMoves.symm i) := rfl #align pgame.of_lists_move_right' SetTheory.PGame.ofLists_moveRight' @[elab_as_elim] def moveRecOn {C : PGame → Sort*} (x : PGame) (IH : ∀ y : PGame, (∀ i, C (y.moveLeft i)) → (∀ j, C (y.moveRight j)) → C y) : C x := x.recOn fun yl yr yL yR => IH (mk yl yr yL yR) #align pgame.move_rec_on SetTheory.PGame.moveRecOn @[mk_iff] inductive IsOption : PGame → PGame → Prop | moveLeft {x : PGame} (i : x.LeftMoves) : IsOption (x.moveLeft i) x | moveRight {x : PGame} (i : x.RightMoves) : IsOption (x.moveRight i) x #align pgame.is_option SetTheory.PGame.IsOption theorem IsOption.mk_left {xl xr : Type u} (xL : xl → PGame) (xR : xr → PGame) (i : xl) : (xL i).IsOption (mk xl xr xL xR) := @IsOption.moveLeft (mk _ _ _ _) i #align pgame.is_option.mk_left SetTheory.PGame.IsOption.mk_left theorem IsOption.mk_right {xl xr : Type u} (xL : xl → PGame) (xR : xr → PGame) (i : xr) : (xR i).IsOption (mk xl xr xL xR) := @IsOption.moveRight (mk _ _ _ _) i #align pgame.is_option.mk_right SetTheory.PGame.IsOption.mk_right theorem wf_isOption : WellFounded IsOption := ⟨fun x => moveRecOn x fun x IHl IHr => Acc.intro x fun y h => by induction' h with _ i _ j · exact IHl i · exact IHr j⟩ #align pgame.wf_is_option SetTheory.PGame.wf_isOption def Subsequent : PGame → PGame → Prop := TransGen IsOption #align pgame.subsequent SetTheory.PGame.Subsequent instance : IsTrans _ Subsequent := inferInstanceAs <| IsTrans _ (TransGen _) @[trans] theorem Subsequent.trans {x y z} : Subsequent x y → Subsequent y z → Subsequent x z := TransGen.trans #align pgame.subsequent.trans SetTheory.PGame.Subsequent.trans theorem wf_subsequent : WellFounded Subsequent := wf_isOption.transGen #align pgame.wf_subsequent SetTheory.PGame.wf_subsequent instance : WellFoundedRelation PGame := ⟨_, wf_subsequent⟩ @[simp] theorem Subsequent.moveLeft {x : PGame} (i : x.LeftMoves) : Subsequent (x.moveLeft i) x := TransGen.single (IsOption.moveLeft i) #align pgame.subsequent.move_left SetTheory.PGame.Subsequent.moveLeft @[simp] theorem Subsequent.moveRight {x : PGame} (j : x.RightMoves) : Subsequent (x.moveRight j) x := TransGen.single (IsOption.moveRight j) #align pgame.subsequent.move_right SetTheory.PGame.Subsequent.moveRight @[simp] theorem Subsequent.mk_left {xl xr} (xL : xl → PGame) (xR : xr → PGame) (i : xl) : Subsequent (xL i) (mk xl xr xL xR) := @Subsequent.moveLeft (mk _ _ _ _) i #align pgame.subsequent.mk_left SetTheory.PGame.Subsequent.mk_left @[simp] theorem Subsequent.mk_right {xl xr} (xL : xl → PGame) (xR : xr → PGame) (j : xr) : Subsequent (xR j) (mk xl xr xL xR) := @Subsequent.moveRight (mk _ _ _ _) j #align pgame.subsequent.mk_right SetTheory.PGame.Subsequent.mk_right macro "pgame_wf_tac" : tactic => `(tactic| solve_by_elim (config := { maxDepth := 8 }) [Prod.Lex.left, Prod.Lex.right, PSigma.Lex.left, PSigma.Lex.right, Subsequent.moveLeft, Subsequent.moveRight, Subsequent.mk_left, Subsequent.mk_right, Subsequent.trans] ) -- Register some consequences of pgame_wf_tac as simp-lemmas for convenience -- (which are applied by default for WF goals) -- This is different from mk_right from the POV of the simplifier, -- because the unifier can't solve `xr =?= RightMoves (mk xl xr xL xR)` at reducible transparency. @[simp] theorem Subsequent.mk_right' (xL : xl → PGame) (xR : xr → PGame) (j : RightMoves (mk xl xr xL xR)) : Subsequent (xR j) (mk xl xr xL xR) := by pgame_wf_tac @[simp] theorem Subsequent.moveRight_mk_left (xL : xl → PGame) (j) : Subsequent ((xL i).moveRight j) (mk xl xr xL xR) := by pgame_wf_tac @[simp] theorem Subsequent.moveRight_mk_right (xR : xr → PGame) (j) : Subsequent ((xR i).moveRight j) (mk xl xr xL xR) := by pgame_wf_tac @[simp] theorem Subsequent.moveLeft_mk_left (xL : xl → PGame) (j) : Subsequent ((xL i).moveLeft j) (mk xl xr xL xR) := by pgame_wf_tac @[simp] theorem Subsequent.moveLeft_mk_right (xR : xr → PGame) (j) : Subsequent ((xR i).moveLeft j) (mk xl xr xL xR) := by pgame_wf_tac -- Porting note: linter claims these lemmas don't simplify? open Subsequent in attribute [nolint simpNF] mk_left mk_right mk_right' moveRight_mk_left moveRight_mk_right moveLeft_mk_left moveLeft_mk_right instance : Zero PGame := ⟨⟨PEmpty, PEmpty, PEmpty.elim, PEmpty.elim⟩⟩ @[simp] theorem zero_leftMoves : LeftMoves 0 = PEmpty := rfl #align pgame.zero_left_moves SetTheory.PGame.zero_leftMoves @[simp] theorem zero_rightMoves : RightMoves 0 = PEmpty := rfl #align pgame.zero_right_moves SetTheory.PGame.zero_rightMoves instance isEmpty_zero_leftMoves : IsEmpty (LeftMoves 0) := instIsEmptyPEmpty #align pgame.is_empty_zero_left_moves SetTheory.PGame.isEmpty_zero_leftMoves instance isEmpty_zero_rightMoves : IsEmpty (RightMoves 0) := instIsEmptyPEmpty #align pgame.is_empty_zero_right_moves SetTheory.PGame.isEmpty_zero_rightMoves instance : Inhabited PGame := ⟨0⟩ instance instOnePGame : One PGame := ⟨⟨PUnit, PEmpty, fun _ => 0, PEmpty.elim⟩⟩ @[simp] theorem one_leftMoves : LeftMoves 1 = PUnit := rfl #align pgame.one_left_moves SetTheory.PGame.one_leftMoves @[simp] theorem one_moveLeft (x) : moveLeft 1 x = 0 := rfl #align pgame.one_move_left SetTheory.PGame.one_moveLeft @[simp] theorem one_rightMoves : RightMoves 1 = PEmpty := rfl #align pgame.one_right_moves SetTheory.PGame.one_rightMoves instance uniqueOneLeftMoves : Unique (LeftMoves 1) := PUnit.unique #align pgame.unique_one_left_moves SetTheory.PGame.uniqueOneLeftMoves instance isEmpty_one_rightMoves : IsEmpty (RightMoves 1) := instIsEmptyPEmpty #align pgame.is_empty_one_right_moves SetTheory.PGame.isEmpty_one_rightMoves instance le : LE PGame := ⟨Sym2.GameAdd.fix wf_isOption fun x y le => (∀ i, ¬le y (x.moveLeft i) (Sym2.GameAdd.snd_fst <| IsOption.moveLeft i)) ∧ ∀ j, ¬le (y.moveRight j) x (Sym2.GameAdd.fst_snd <| IsOption.moveRight j)⟩ def LF (x y : PGame) : Prop := ¬y ≤ x #align pgame.lf SetTheory.PGame.LF @[inherit_doc] scoped infixl:50 " ⧏ " => PGame.LF @[simp] protected theorem not_le {x y : PGame} : ¬x ≤ y ↔ y ⧏ x := Iff.rfl #align pgame.not_le SetTheory.PGame.not_le @[simp] theorem not_lf {x y : PGame} : ¬x ⧏ y ↔ y ≤ x := Classical.not_not #align pgame.not_lf SetTheory.PGame.not_lf theorem _root_.LE.le.not_gf {x y : PGame} : x ≤ y → ¬y ⧏ x := not_lf.2 #align has_le.le.not_gf LE.le.not_gf theorem LF.not_ge {x y : PGame} : x ⧏ y → ¬y ≤ x := id #align pgame.lf.not_ge SetTheory.PGame.LF.not_ge theorem le_iff_forall_lf {x y : PGame} : x ≤ y ↔ (∀ i, x.moveLeft i ⧏ y) ∧ ∀ j, x ⧏ y.moveRight j := by unfold LE.le le simp only rw [Sym2.GameAdd.fix_eq] rfl #align pgame.le_iff_forall_lf SetTheory.PGame.le_iff_forall_lf @[simp] theorem mk_le_mk {xl xr xL xR yl yr yL yR} : mk xl xr xL xR ≤ mk yl yr yL yR ↔ (∀ i, xL i ⧏ mk yl yr yL yR) ∧ ∀ j, mk xl xr xL xR ⧏ yR j := le_iff_forall_lf #align pgame.mk_le_mk SetTheory.PGame.mk_le_mk theorem le_of_forall_lf {x y : PGame} (h₁ : ∀ i, x.moveLeft i ⧏ y) (h₂ : ∀ j, x ⧏ y.moveRight j) : x ≤ y := le_iff_forall_lf.2 ⟨h₁, h₂⟩ #align pgame.le_of_forall_lf SetTheory.PGame.le_of_forall_lf theorem lf_iff_exists_le {x y : PGame} : x ⧏ y ↔ (∃ i, x ≤ y.moveLeft i) ∨ ∃ j, x.moveRight j ≤ y := by rw [LF, le_iff_forall_lf, not_and_or] simp #align pgame.lf_iff_exists_le SetTheory.PGame.lf_iff_exists_le @[simp] theorem mk_lf_mk {xl xr xL xR yl yr yL yR} : mk xl xr xL xR ⧏ mk yl yr yL yR ↔ (∃ i, mk xl xr xL xR ≤ yL i) ∨ ∃ j, xR j ≤ mk yl yr yL yR := lf_iff_exists_le #align pgame.mk_lf_mk SetTheory.PGame.mk_lf_mk theorem le_or_gf (x y : PGame) : x ≤ y ∨ y ⧏ x := by rw [← PGame.not_le] apply em #align pgame.le_or_gf SetTheory.PGame.le_or_gf theorem moveLeft_lf_of_le {x y : PGame} (h : x ≤ y) (i) : x.moveLeft i ⧏ y := (le_iff_forall_lf.1 h).1 i #align pgame.move_left_lf_of_le SetTheory.PGame.moveLeft_lf_of_le alias _root_.LE.le.moveLeft_lf := moveLeft_lf_of_le #align has_le.le.move_left_lf LE.le.moveLeft_lf theorem lf_moveRight_of_le {x y : PGame} (h : x ≤ y) (j) : x ⧏ y.moveRight j := (le_iff_forall_lf.1 h).2 j #align pgame.lf_move_right_of_le SetTheory.PGame.lf_moveRight_of_le alias _root_.LE.le.lf_moveRight := lf_moveRight_of_le #align has_le.le.lf_move_right LE.le.lf_moveRight theorem lf_of_moveRight_le {x y : PGame} {j} (h : x.moveRight j ≤ y) : x ⧏ y := lf_iff_exists_le.2 <| Or.inr ⟨j, h⟩ #align pgame.lf_of_move_right_le SetTheory.PGame.lf_of_moveRight_le theorem lf_of_le_moveLeft {x y : PGame} {i} (h : x ≤ y.moveLeft i) : x ⧏ y := lf_iff_exists_le.2 <| Or.inl ⟨i, h⟩ #align pgame.lf_of_le_move_left SetTheory.PGame.lf_of_le_moveLeft theorem lf_of_le_mk {xl xr xL xR y} : mk xl xr xL xR ≤ y → ∀ i, xL i ⧏ y := moveLeft_lf_of_le #align pgame.lf_of_le_mk SetTheory.PGame.lf_of_le_mk theorem lf_of_mk_le {x yl yr yL yR} : x ≤ mk yl yr yL yR → ∀ j, x ⧏ yR j := lf_moveRight_of_le #align pgame.lf_of_mk_le SetTheory.PGame.lf_of_mk_le theorem mk_lf_of_le {xl xr y j} (xL) {xR : xr → PGame} : xR j ≤ y → mk xl xr xL xR ⧏ y := @lf_of_moveRight_le (mk _ _ _ _) y j #align pgame.mk_lf_of_le SetTheory.PGame.mk_lf_of_le theorem lf_mk_of_le {x yl yr} {yL : yl → PGame} (yR) {i} : x ≤ yL i → x ⧏ mk yl yr yL yR := @lf_of_le_moveLeft x (mk _ _ _ _) i #align pgame.lf_mk_of_le SetTheory.PGame.lf_mk_of_le private theorem le_trans_aux {x y z : PGame} (h₁ : ∀ {i}, y ≤ z → z ≤ x.moveLeft i → y ≤ x.moveLeft i) (h₂ : ∀ {j}, z.moveRight j ≤ x → x ≤ y → z.moveRight j ≤ y) (hxy : x ≤ y) (hyz : y ≤ z) : x ≤ z := le_of_forall_lf (fun i => PGame.not_le.1 fun h => (h₁ hyz h).not_gf <| hxy.moveLeft_lf i) fun j => PGame.not_le.1 fun h => (h₂ h hxy).not_gf <| hyz.lf_moveRight j instance : Preorder PGame := { PGame.le with le_refl := fun x => by induction' x with _ _ _ _ IHl IHr exact le_of_forall_lf (fun i => lf_of_le_moveLeft (IHl i)) fun i => lf_of_moveRight_le (IHr i) le_trans := by suffices ∀ {x y z : PGame}, (x ≤ y → y ≤ z → x ≤ z) ∧ (y ≤ z → z ≤ x → y ≤ x) ∧ (z ≤ x → x ≤ y → z ≤ y) from fun x y z => this.1 intro x y z induction' x with xl xr xL xR IHxl IHxr generalizing y z induction' y with yl yr yL yR IHyl IHyr generalizing z induction' z with zl zr zL zR IHzl IHzr exact ⟨le_trans_aux (fun {i} => (IHxl i).2.1) fun {j} => (IHzr j).2.2, le_trans_aux (fun {i} => (IHyl i).2.2) fun {j} => (IHxr j).1, le_trans_aux (fun {i} => (IHzl i).1) fun {j} => (IHyr j).2.1⟩ lt := fun x y => x ≤ y ∧ x ⧏ y } theorem lt_iff_le_and_lf {x y : PGame} : x < y ↔ x ≤ y ∧ x ⧏ y := Iff.rfl #align pgame.lt_iff_le_and_lf SetTheory.PGame.lt_iff_le_and_lf theorem lt_of_le_of_lf {x y : PGame} (h₁ : x ≤ y) (h₂ : x ⧏ y) : x < y := ⟨h₁, h₂⟩ #align pgame.lt_of_le_of_lf SetTheory.PGame.lt_of_le_of_lf theorem lf_of_lt {x y : PGame} (h : x < y) : x ⧏ y := h.2 #align pgame.lf_of_lt SetTheory.PGame.lf_of_lt alias _root_.LT.lt.lf := lf_of_lt #align has_lt.lt.lf LT.lt.lf theorem lf_irrefl (x : PGame) : ¬x ⧏ x := le_rfl.not_gf #align pgame.lf_irrefl SetTheory.PGame.lf_irrefl instance : IsIrrefl _ (· ⧏ ·) := ⟨lf_irrefl⟩ @[trans] theorem lf_of_le_of_lf {x y z : PGame} (h₁ : x ≤ y) (h₂ : y ⧏ z) : x ⧏ z := by rw [← PGame.not_le] at h₂ ⊢ exact fun h₃ => h₂ (h₃.trans h₁) #align pgame.lf_of_le_of_lf SetTheory.PGame.lf_of_le_of_lf -- Porting note (#10754): added instance instance : Trans (· ≤ ·) (· ⧏ ·) (· ⧏ ·) := ⟨lf_of_le_of_lf⟩ @[trans] theorem lf_of_lf_of_le {x y z : PGame} (h₁ : x ⧏ y) (h₂ : y ≤ z) : x ⧏ z := by rw [← PGame.not_le] at h₁ ⊢ exact fun h₃ => h₁ (h₂.trans h₃) #align pgame.lf_of_lf_of_le SetTheory.PGame.lf_of_lf_of_le -- Porting note (#10754): added instance instance : Trans (· ⧏ ·) (· ≤ ·) (· ⧏ ·) := ⟨lf_of_lf_of_le⟩ alias _root_.LE.le.trans_lf := lf_of_le_of_lf #align has_le.le.trans_lf LE.le.trans_lf alias LF.trans_le := lf_of_lf_of_le #align pgame.lf.trans_le SetTheory.PGame.LF.trans_le @[trans] theorem lf_of_lt_of_lf {x y z : PGame} (h₁ : x < y) (h₂ : y ⧏ z) : x ⧏ z := h₁.le.trans_lf h₂ #align pgame.lf_of_lt_of_lf SetTheory.PGame.lf_of_lt_of_lf @[trans] theorem lf_of_lf_of_lt {x y z : PGame} (h₁ : x ⧏ y) (h₂ : y < z) : x ⧏ z := h₁.trans_le h₂.le #align pgame.lf_of_lf_of_lt SetTheory.PGame.lf_of_lf_of_lt alias _root_.LT.lt.trans_lf := lf_of_lt_of_lf #align has_lt.lt.trans_lf LT.lt.trans_lf alias LF.trans_lt := lf_of_lf_of_lt #align pgame.lf.trans_lt SetTheory.PGame.LF.trans_lt theorem moveLeft_lf {x : PGame} : ∀ i, x.moveLeft i ⧏ x := le_rfl.moveLeft_lf #align pgame.move_left_lf SetTheory.PGame.moveLeft_lf theorem lf_moveRight {x : PGame} : ∀ j, x ⧏ x.moveRight j := le_rfl.lf_moveRight #align pgame.lf_move_right SetTheory.PGame.lf_moveRight theorem lf_mk {xl xr} (xL : xl → PGame) (xR : xr → PGame) (i) : xL i ⧏ mk xl xr xL xR := @moveLeft_lf (mk _ _ _ _) i #align pgame.lf_mk SetTheory.PGame.lf_mk theorem mk_lf {xl xr} (xL : xl → PGame) (xR : xr → PGame) (j) : mk xl xr xL xR ⧏ xR j := @lf_moveRight (mk _ _ _ _) j #align pgame.mk_lf SetTheory.PGame.mk_lf theorem le_of_forall_lt {x y : PGame} (h₁ : ∀ i, x.moveLeft i < y) (h₂ : ∀ j, x < y.moveRight j) : x ≤ y := le_of_forall_lf (fun i => (h₁ i).lf) fun i => (h₂ i).lf #align pgame.le_of_forall_lt SetTheory.PGame.le_of_forall_lt theorem le_def {x y : PGame} : x ≤ y ↔ (∀ i, (∃ i', x.moveLeft i ≤ y.moveLeft i') ∨ ∃ j, (x.moveLeft i).moveRight j ≤ y) ∧ ∀ j, (∃ i, x ≤ (y.moveRight j).moveLeft i) ∨ ∃ j', x.moveRight j' ≤ y.moveRight j := by rw [le_iff_forall_lf] conv => lhs simp only [lf_iff_exists_le] #align pgame.le_def SetTheory.PGame.le_def theorem lf_def {x y : PGame} : x ⧏ y ↔ (∃ i, (∀ i', x.moveLeft i' ⧏ y.moveLeft i) ∧ ∀ j, x ⧏ (y.moveLeft i).moveRight j) ∨ ∃ j, (∀ i, (x.moveRight j).moveLeft i ⧏ y) ∧ ∀ j', x.moveRight j ⧏ y.moveRight j' := by rw [lf_iff_exists_le] conv => lhs simp only [le_iff_forall_lf] #align pgame.lf_def SetTheory.PGame.lf_def theorem zero_le_lf {x : PGame} : 0 ≤ x ↔ ∀ j, 0 ⧏ x.moveRight j := by rw [le_iff_forall_lf] simp #align pgame.zero_le_lf SetTheory.PGame.zero_le_lf
Mathlib/SetTheory/Game/PGame.lean
653
655
theorem le_zero_lf {x : PGame} : x ≤ 0 ↔ ∀ i, x.moveLeft i ⧏ 0 := by
rw [le_iff_forall_lf] simp
import Mathlib.LinearAlgebra.Dimension.Finrank import Mathlib.LinearAlgebra.InvariantBasisNumber #align_import linear_algebra.dimension from "leanprover-community/mathlib"@"47a5f8186becdbc826190ced4312f8199f9db6a5" noncomputable section universe u v w w' variable {R : Type u} {M : Type v} [Ring R] [AddCommGroup M] [Module R M] variable {ι : Type w} {ι' : Type w'} open Cardinal Basis Submodule Function Set attribute [local instance] nontrivial_of_invariantBasisNumber section StrongRankCondition variable [StrongRankCondition R] open Submodule -- An auxiliary lemma for `linearIndependent_le_span'`, -- with the additional assumption that the linearly independent family is finite.
Mathlib/LinearAlgebra/Dimension/StrongRankCondition.lean
177
191
theorem linearIndependent_le_span_aux' {ι : Type*} [Fintype ι] (v : ι → M) (i : LinearIndependent R v) (w : Set M) [Fintype w] (s : range v ≤ span R w) : Fintype.card ι ≤ Fintype.card w := by
-- We construct an injective linear map `(ι → R) →ₗ[R] (w → R)`, -- by thinking of `f : ι → R` as a linear combination of the finite family `v`, -- and expressing that (using the axiom of choice) as a linear combination over `w`. -- We can do this linearly by constructing the map on a basis. fapply card_le_of_injective' R · apply Finsupp.total exact fun i => Span.repr R w ⟨v i, s (mem_range_self i)⟩ · intro f g h apply_fun Finsupp.total w M R (↑) at h simp only [Finsupp.total_total, Submodule.coe_mk, Span.finsupp_total_repr] at h rw [← sub_eq_zero, ← LinearMap.map_sub] at h exact sub_eq_zero.mp (linearIndependent_iff.mp i _ h)
import Mathlib.RingTheory.WittVector.StructurePolynomial #align_import ring_theory.witt_vector.defs from "leanprover-community/mathlib"@"f1944b30c97c5eb626e498307dec8b022a05bd0a" noncomputable section structure WittVector (p : ℕ) (R : Type*) where mk' :: coeff : ℕ → R #align witt_vector WittVector -- Porting note: added to make the `p` argument explicit def WittVector.mk (p : ℕ) {R : Type*} (coeff : ℕ → R) : WittVector p R := mk' coeff variable {p : ℕ} local notation "𝕎" => WittVector p -- type as `\bbW` namespace WittVector variable {R : Type*} @[ext]
Mathlib/RingTheory/WittVector/Defs.lean
74
78
theorem ext {x y : 𝕎 R} (h : ∀ n, x.coeff n = y.coeff n) : x = y := by
cases x cases y simp only at h simp [Function.funext_iff, h]
import Mathlib.Algebra.Field.Basic import Mathlib.Deprecated.Subring #align_import deprecated.subfield from "leanprover-community/mathlib"@"bd9851ca476957ea4549eb19b40e7b5ade9428cc" variable {F : Type*} [Field F] (S : Set F) structure IsSubfield extends IsSubring S : Prop where inv_mem : ∀ {x : F}, x ∈ S → x⁻¹ ∈ S #align is_subfield IsSubfield theorem IsSubfield.div_mem {S : Set F} (hS : IsSubfield S) {x y : F} (hx : x ∈ S) (hy : y ∈ S) : x / y ∈ S := by rw [div_eq_mul_inv] exact hS.toIsSubring.toIsSubmonoid.mul_mem hx (hS.inv_mem hy) #align is_subfield.div_mem IsSubfield.div_mem theorem IsSubfield.pow_mem {a : F} {n : ℤ} {s : Set F} (hs : IsSubfield s) (h : a ∈ s) : a ^ n ∈ s := by cases' n with n n · suffices a ^ (n : ℤ) ∈ s by exact this rw [zpow_natCast] exact hs.toIsSubring.toIsSubmonoid.pow_mem h · rw [zpow_negSucc] exact hs.inv_mem (hs.toIsSubring.toIsSubmonoid.pow_mem h) #align is_subfield.pow_mem IsSubfield.pow_mem theorem Univ.isSubfield : IsSubfield (@Set.univ F) := { Univ.isSubmonoid, IsAddSubgroup.univ_addSubgroup with inv_mem := fun _ ↦ trivial } #align univ.is_subfield Univ.isSubfield theorem Preimage.isSubfield {K : Type*} [Field K] (f : F →+* K) {s : Set K} (hs : IsSubfield s) : IsSubfield (f ⁻¹' s) := { f.isSubring_preimage hs.toIsSubring with inv_mem := fun {a} (ha : f a ∈ s) ↦ show f a⁻¹ ∈ s by rw [map_inv₀] exact hs.inv_mem ha } #align preimage.is_subfield Preimage.isSubfield theorem Image.isSubfield {K : Type*} [Field K] (f : F →+* K) {s : Set F} (hs : IsSubfield s) : IsSubfield (f '' s) := { f.isSubring_image hs.toIsSubring with inv_mem := fun ⟨x, xmem, ha⟩ ↦ ⟨x⁻¹, hs.inv_mem xmem, ha ▸ map_inv₀ f x⟩ } #align image.is_subfield Image.isSubfield theorem Range.isSubfield {K : Type*} [Field K] (f : F →+* K) : IsSubfield (Set.range f) := by rw [← Set.image_univ] apply Image.isSubfield _ Univ.isSubfield #align range.is_subfield Range.isSubfield namespace Field def closure : Set F := { x | ∃ y ∈ Ring.closure S, ∃ z ∈ Ring.closure S, y / z = x } #align field.closure Field.closure variable {S} theorem ring_closure_subset : Ring.closure S ⊆ closure S := fun x hx ↦ ⟨x, hx, 1, Ring.closure.isSubring.toIsSubmonoid.one_mem, div_one x⟩ #align field.ring_closure_subset Field.ring_closure_subset theorem closure.isSubmonoid : IsSubmonoid (closure S) := { mul_mem := by rintro _ _ ⟨p, hp, q, hq, hq0, rfl⟩ ⟨r, hr, s, hs, hs0, rfl⟩ exact ⟨p * r, IsSubmonoid.mul_mem Ring.closure.isSubring.toIsSubmonoid hp hr, q * s, IsSubmonoid.mul_mem Ring.closure.isSubring.toIsSubmonoid hq hs, (div_mul_div_comm _ _ _ _).symm⟩ one_mem := ring_closure_subset <| IsSubmonoid.one_mem Ring.closure.isSubring.toIsSubmonoid } #align field.closure.is_submonoid Field.closure.isSubmonoid
Mathlib/Deprecated/Subfield.lean
102
123
theorem closure.isSubfield : IsSubfield (closure S) := { closure.isSubmonoid with add_mem := by
intro a b ha hb rcases id ha with ⟨p, hp, q, hq, rfl⟩ rcases id hb with ⟨r, hr, s, hs, rfl⟩ by_cases hq0 : q = 0 · rwa [hq0, div_zero, zero_add] by_cases hs0 : s = 0 · rwa [hs0, div_zero, add_zero] exact ⟨p * s + q * r, IsAddSubmonoid.add_mem Ring.closure.isSubring.toIsAddSubgroup.toIsAddSubmonoid (Ring.closure.isSubring.toIsSubmonoid.mul_mem hp hs) (Ring.closure.isSubring.toIsSubmonoid.mul_mem hq hr), q * s, Ring.closure.isSubring.toIsSubmonoid.mul_mem hq hs, (div_add_div p r hq0 hs0).symm⟩ zero_mem := ring_closure_subset Ring.closure.isSubring.toIsAddSubgroup.toIsAddSubmonoid.zero_mem neg_mem := by rintro _ ⟨p, hp, q, hq, rfl⟩ exact ⟨-p, Ring.closure.isSubring.toIsAddSubgroup.neg_mem hp, q, hq, neg_div q p⟩ inv_mem := by rintro _ ⟨p, hp, q, hq, rfl⟩ exact ⟨q, hq, p, hp, (inv_div _ _).symm⟩ }
import Mathlib.Data.Nat.Squarefree import Mathlib.NumberTheory.Zsqrtd.QuadraticReciprocity import Mathlib.Tactic.LinearCombination #align_import number_theory.sum_two_squares from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" section General theorem sq_add_sq_mul {R} [CommRing R] {a b x y u v : R} (ha : a = x ^ 2 + y ^ 2) (hb : b = u ^ 2 + v ^ 2) : ∃ r s : R, a * b = r ^ 2 + s ^ 2 := ⟨x * u - y * v, x * v + y * u, by rw [ha, hb]; ring⟩ #align sq_add_sq_mul sq_add_sq_mul
Mathlib/NumberTheory/SumTwoSquares.lean
56
61
theorem Nat.sq_add_sq_mul {a b x y u v : ℕ} (ha : a = x ^ 2 + y ^ 2) (hb : b = u ^ 2 + v ^ 2) : ∃ r s : ℕ, a * b = r ^ 2 + s ^ 2 := by
zify at ha hb ⊢ obtain ⟨r, s, h⟩ := _root_.sq_add_sq_mul ha hb refine ⟨r.natAbs, s.natAbs, ?_⟩ simpa only [Int.natCast_natAbs, sq_abs]
import Mathlib.Algebra.Order.Archimedean import Mathlib.Order.Filter.AtTopBot import Mathlib.Tactic.GCongr #align_import order.filter.archimedean from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" variable {α R : Type*} open Filter Set Function @[simp] theorem Nat.comap_cast_atTop [StrictOrderedSemiring R] [Archimedean R] : comap ((↑) : ℕ → R) atTop = atTop := comap_embedding_atTop (fun _ _ => Nat.cast_le) exists_nat_ge #align nat.comap_coe_at_top Nat.comap_cast_atTop theorem tendsto_natCast_atTop_iff [StrictOrderedSemiring R] [Archimedean R] {f : α → ℕ} {l : Filter α} : Tendsto (fun n => (f n : R)) l atTop ↔ Tendsto f l atTop := tendsto_atTop_embedding (fun _ _ => Nat.cast_le) exists_nat_ge #align tendsto_coe_nat_at_top_iff tendsto_natCast_atTop_iff @[deprecated (since := "2024-04-17")] alias tendsto_nat_cast_atTop_iff := tendsto_natCast_atTop_iff theorem tendsto_natCast_atTop_atTop [OrderedSemiring R] [Archimedean R] : Tendsto ((↑) : ℕ → R) atTop atTop := Nat.mono_cast.tendsto_atTop_atTop exists_nat_ge #align tendsto_coe_nat_at_top_at_top tendsto_natCast_atTop_atTop @[deprecated (since := "2024-04-17")] alias tendsto_nat_cast_atTop_atTop := tendsto_natCast_atTop_atTop theorem Filter.Eventually.natCast_atTop [OrderedSemiring R] [Archimedean R] {p : R → Prop} (h : ∀ᶠ (x:R) in atTop, p x) : ∀ᶠ (n:ℕ) in atTop, p n := tendsto_natCast_atTop_atTop.eventually h @[deprecated (since := "2024-04-17")] alias Filter.Eventually.nat_cast_atTop := Filter.Eventually.natCast_atTop @[simp] theorem Int.comap_cast_atTop [StrictOrderedRing R] [Archimedean R] : comap ((↑) : ℤ → R) atTop = atTop := comap_embedding_atTop (fun _ _ => Int.cast_le) fun r => let ⟨n, hn⟩ := exists_nat_ge r; ⟨n, mod_cast hn⟩ #align int.comap_coe_at_top Int.comap_cast_atTop @[simp] theorem Int.comap_cast_atBot [StrictOrderedRing R] [Archimedean R] : comap ((↑) : ℤ → R) atBot = atBot := comap_embedding_atBot (fun _ _ => Int.cast_le) fun r => let ⟨n, hn⟩ := exists_nat_ge (-r) ⟨-n, by simpa [neg_le] using hn⟩ #align int.comap_coe_at_bot Int.comap_cast_atBot theorem tendsto_intCast_atTop_iff [StrictOrderedRing R] [Archimedean R] {f : α → ℤ} {l : Filter α} : Tendsto (fun n => (f n : R)) l atTop ↔ Tendsto f l atTop := by rw [← @Int.comap_cast_atTop R, tendsto_comap_iff]; rfl #align tendsto_coe_int_at_top_iff tendsto_intCast_atTop_iff @[deprecated (since := "2024-04-17")] alias tendsto_int_cast_atTop_iff := tendsto_intCast_atTop_iff theorem tendsto_intCast_atBot_iff [StrictOrderedRing R] [Archimedean R] {f : α → ℤ} {l : Filter α} : Tendsto (fun n => (f n : R)) l atBot ↔ Tendsto f l atBot := by rw [← @Int.comap_cast_atBot R, tendsto_comap_iff]; rfl #align tendsto_coe_int_at_bot_iff tendsto_intCast_atBot_iff @[deprecated (since := "2024-04-17")] alias tendsto_int_cast_atBot_iff := tendsto_intCast_atBot_iff theorem tendsto_intCast_atTop_atTop [StrictOrderedRing R] [Archimedean R] : Tendsto ((↑) : ℤ → R) atTop atTop := tendsto_intCast_atTop_iff.2 tendsto_id #align tendsto_coe_int_at_top_at_top tendsto_intCast_atTop_atTop @[deprecated (since := "2024-04-17")] alias tendsto_int_cast_atTop_atTop := tendsto_intCast_atTop_atTop theorem Filter.Eventually.intCast_atTop [StrictOrderedRing R] [Archimedean R] {p : R → Prop} (h : ∀ᶠ (x:R) in atTop, p x) : ∀ᶠ (n:ℤ) in atTop, p n := by rw [← Int.comap_cast_atTop (R := R)]; exact h.comap _ @[deprecated (since := "2024-04-17")] alias Filter.Eventually.int_cast_atTop := Filter.Eventually.intCast_atTop theorem Filter.Eventually.intCast_atBot [StrictOrderedRing R] [Archimedean R] {p : R → Prop} (h : ∀ᶠ (x:R) in atBot, p x) : ∀ᶠ (n:ℤ) in atBot, p n := by rw [← Int.comap_cast_atBot (R := R)]; exact h.comap _ @[deprecated (since := "2024-04-17")] alias Filter.Eventually.int_cast_atBot := Filter.Eventually.intCast_atBot @[simp] theorem Rat.comap_cast_atTop [LinearOrderedField R] [Archimedean R] : comap ((↑) : ℚ → R) atTop = atTop := comap_embedding_atTop (fun _ _ => Rat.cast_le) fun r => let ⟨n, hn⟩ := exists_nat_ge r; ⟨n, by simpa⟩ #align rat.comap_coe_at_top Rat.comap_cast_atTop @[simp] theorem Rat.comap_cast_atBot [LinearOrderedField R] [Archimedean R] : comap ((↑) : ℚ → R) atBot = atBot := comap_embedding_atBot (fun _ _ => Rat.cast_le) fun r => let ⟨n, hn⟩ := exists_nat_ge (-r) ⟨-n, by simpa [neg_le]⟩ #align rat.comap_coe_at_bot Rat.comap_cast_atBot theorem tendsto_ratCast_atTop_iff [LinearOrderedField R] [Archimedean R] {f : α → ℚ} {l : Filter α} : Tendsto (fun n => (f n : R)) l atTop ↔ Tendsto f l atTop := by rw [← @Rat.comap_cast_atTop R, tendsto_comap_iff]; rfl #align tendsto_coe_rat_at_top_iff tendsto_ratCast_atTop_iff @[deprecated (since := "2024-04-17")] alias tendsto_rat_cast_atTop_iff := tendsto_ratCast_atTop_iff theorem tendsto_ratCast_atBot_iff [LinearOrderedField R] [Archimedean R] {f : α → ℚ} {l : Filter α} : Tendsto (fun n => (f n : R)) l atBot ↔ Tendsto f l atBot := by rw [← @Rat.comap_cast_atBot R, tendsto_comap_iff]; rfl #align tendsto_coe_rat_at_bot_iff tendsto_ratCast_atBot_iff @[deprecated (since := "2024-04-17")] alias tendsto_rat_cast_atBot_iff := tendsto_ratCast_atBot_iff theorem Filter.Eventually.ratCast_atTop [LinearOrderedField R] [Archimedean R] {p : R → Prop} (h : ∀ᶠ (x:R) in atTop, p x) : ∀ᶠ (n:ℚ) in atTop, p n := by rw [← Rat.comap_cast_atTop (R := R)]; exact h.comap _ @[deprecated (since := "2024-04-17")] alias Filter.Eventually.rat_cast_atTop := Filter.Eventually.ratCast_atTop theorem Filter.Eventually.ratCast_atBot [LinearOrderedField R] [Archimedean R] {p : R → Prop} (h : ∀ᶠ (x:R) in atBot, p x) : ∀ᶠ (n:ℚ) in atBot, p n := by rw [← Rat.comap_cast_atBot (R := R)]; exact h.comap _ @[deprecated (since := "2024-04-17")] alias Filter.Eventually.rat_cast_atBot := Filter.Eventually.ratCast_atBot -- Porting note (#10756): new lemma theorem atTop_hasAntitoneBasis_of_archimedean [OrderedSemiring R] [Archimedean R] : (atTop : Filter R).HasAntitoneBasis fun n : ℕ => Ici n := hasAntitoneBasis_atTop.comp_mono Nat.mono_cast tendsto_natCast_atTop_atTop theorem atTop_hasCountableBasis_of_archimedean [StrictOrderedSemiring R] [Archimedean R] : (atTop : Filter R).HasCountableBasis (fun _ : ℕ => True) fun n => Ici n := ⟨atTop_hasAntitoneBasis_of_archimedean.1, to_countable _⟩ #align at_top_countable_basis_of_archimedean atTop_hasCountableBasis_of_archimedean -- Porting note (#11215): TODO: generalize to a `StrictOrderedRing` theorem atBot_hasCountableBasis_of_archimedean [LinearOrderedRing R] [Archimedean R] : (atBot : Filter R).HasCountableBasis (fun _ : ℤ => True) fun m => Iic m := { countable := to_countable _ toHasBasis := atBot_basis.to_hasBasis (fun x _ => let ⟨m, hm⟩ := exists_int_lt x; ⟨m, trivial, Iic_subset_Iic.2 hm.le⟩) fun m _ => ⟨m, trivial, Subset.rfl⟩ } #align at_bot_countable_basis_of_archimedean atBot_hasCountableBasis_of_archimedean instance (priority := 100) atTop_isCountablyGenerated_of_archimedean [StrictOrderedSemiring R] [Archimedean R] : (atTop : Filter R).IsCountablyGenerated := atTop_hasCountableBasis_of_archimedean.isCountablyGenerated #align at_top_countably_generated_of_archimedean atTop_isCountablyGenerated_of_archimedean instance (priority := 100) atBot_isCountablyGenerated_of_archimedean [LinearOrderedRing R] [Archimedean R] : (atBot : Filter R).IsCountablyGenerated := atBot_hasCountableBasis_of_archimedean.isCountablyGenerated #align at_bot_countably_generated_of_archimedean atBot_isCountablyGenerated_of_archimedean namespace Filter variable {l : Filter α} {f : α → R} {r : R} section LinearOrderedCancelAddCommMonoid variable [LinearOrderedCancelAddCommMonoid R] [Archimedean R]
Mathlib/Order/Filter/Archimedean.lean
267
271
theorem Tendsto.atTop_nsmul_const {f : α → ℕ} (hr : 0 < r) (hf : Tendsto f l atTop) : Tendsto (fun x => f x • r) l atTop := by
refine tendsto_atTop.mpr fun s => ?_ obtain ⟨n : ℕ, hn : s ≤ n • r⟩ := Archimedean.arch s hr exact (tendsto_atTop.mp hf n).mono fun a ha => hn.trans (nsmul_le_nsmul_left hr.le ha)
import Mathlib.Algebra.Group.Int import Mathlib.Algebra.Order.Group.Abs #align_import data.int.order.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" -- We should need only a minimal development of sets in order to get here. assert_not_exists Set.Subsingleton assert_not_exists Ring open Function Nat namespace Int theorem natCast_strictMono : StrictMono (· : ℕ → ℤ) := fun _ _ ↦ Int.ofNat_lt.2 #align int.coe_nat_strict_mono Int.natCast_strictMono @[deprecated (since := "2024-05-25")] alias coe_nat_strictMono := natCast_strictMono instance linearOrderedAddCommGroup : LinearOrderedAddCommGroup ℤ where __ := instLinearOrder __ := instAddCommGroup add_le_add_left _ _ := Int.add_le_add_left theorem abs_eq_natAbs : ∀ a : ℤ, |a| = natAbs a | (n : ℕ) => abs_of_nonneg <| ofNat_zero_le _ | -[_+1] => abs_of_nonpos <| le_of_lt <| negSucc_lt_zero _ #align int.abs_eq_nat_abs Int.abs_eq_natAbs @[simp, norm_cast] lemma natCast_natAbs (n : ℤ) : (n.natAbs : ℤ) = |n| := n.abs_eq_natAbs.symm #align int.coe_nat_abs Int.natCast_natAbs theorem natAbs_abs (a : ℤ) : natAbs |a| = natAbs a := by rw [abs_eq_natAbs]; rfl #align int.nat_abs_abs Int.natAbs_abs
Mathlib/Algebra/Order/Group/Int.lean
60
61
theorem sign_mul_abs (a : ℤ) : sign a * |a| = a := by
rw [abs_eq_natAbs, sign_mul_natAbs a]
import Mathlib.MeasureTheory.Integral.IntegrableOn import Mathlib.MeasureTheory.Integral.Bochner import Mathlib.MeasureTheory.Function.LocallyIntegrable import Mathlib.Topology.MetricSpace.ThickenedIndicator import Mathlib.Topology.ContinuousFunction.Compact import Mathlib.Analysis.NormedSpace.HahnBanach.SeparatingDual #align_import measure_theory.integral.setIntegral from "leanprover-community/mathlib"@"24e0c85412ff6adbeca08022c25ba4876eedf37a" assert_not_exists InnerProductSpace noncomputable section open Set Filter TopologicalSpace MeasureTheory Function RCLike open scoped Classical Topology ENNReal NNReal variable {X Y E F : Type*} [MeasurableSpace X] namespace MeasureTheory section NormedAddCommGroup variable [NormedAddCommGroup E] [NormedSpace ℝ E] {f g : X → E} {s t : Set X} {μ ν : Measure X} {l l' : Filter X} theorem setIntegral_congr_ae₀ (hs : NullMeasurableSet s μ) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) : ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ := integral_congr_ae ((ae_restrict_iff'₀ hs).2 h) #align measure_theory.set_integral_congr_ae₀ MeasureTheory.setIntegral_congr_ae₀ @[deprecated (since := "2024-04-17")] alias set_integral_congr_ae₀ := setIntegral_congr_ae₀ theorem setIntegral_congr_ae (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) : ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ := integral_congr_ae ((ae_restrict_iff' hs).2 h) #align measure_theory.set_integral_congr_ae MeasureTheory.setIntegral_congr_ae @[deprecated (since := "2024-04-17")] alias set_integral_congr_ae := setIntegral_congr_ae theorem setIntegral_congr₀ (hs : NullMeasurableSet s μ) (h : EqOn f g s) : ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ := setIntegral_congr_ae₀ hs <| eventually_of_forall h #align measure_theory.set_integral_congr₀ MeasureTheory.setIntegral_congr₀ @[deprecated (since := "2024-04-17")] alias set_integral_congr₀ := setIntegral_congr₀ theorem setIntegral_congr (hs : MeasurableSet s) (h : EqOn f g s) : ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ := setIntegral_congr_ae hs <| eventually_of_forall h #align measure_theory.set_integral_congr MeasureTheory.setIntegral_congr @[deprecated (since := "2024-04-17")] alias set_integral_congr := setIntegral_congr theorem setIntegral_congr_set_ae (hst : s =ᵐ[μ] t) : ∫ x in s, f x ∂μ = ∫ x in t, f x ∂μ := by rw [Measure.restrict_congr_set hst] #align measure_theory.set_integral_congr_set_ae MeasureTheory.setIntegral_congr_set_ae @[deprecated (since := "2024-04-17")] alias set_integral_congr_set_ae := setIntegral_congr_set_ae theorem integral_union_ae (hst : AEDisjoint μ s t) (ht : NullMeasurableSet t μ) (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ + ∫ x in t, f x ∂μ := by simp only [IntegrableOn, Measure.restrict_union₀ hst ht, integral_add_measure hfs hft] #align measure_theory.integral_union_ae MeasureTheory.integral_union_ae theorem integral_union (hst : Disjoint s t) (ht : MeasurableSet t) (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ + ∫ x in t, f x ∂μ := integral_union_ae hst.aedisjoint ht.nullMeasurableSet hfs hft #align measure_theory.integral_union MeasureTheory.integral_union theorem integral_diff (ht : MeasurableSet t) (hfs : IntegrableOn f s μ) (hts : t ⊆ s) : ∫ x in s \ t, f x ∂μ = ∫ x in s, f x ∂μ - ∫ x in t, f x ∂μ := by rw [eq_sub_iff_add_eq, ← integral_union, diff_union_of_subset hts] exacts [disjoint_sdiff_self_left, ht, hfs.mono_set diff_subset, hfs.mono_set hts] #align measure_theory.integral_diff MeasureTheory.integral_diff theorem integral_inter_add_diff₀ (ht : NullMeasurableSet t μ) (hfs : IntegrableOn f s μ) : ∫ x in s ∩ t, f x ∂μ + ∫ x in s \ t, f x ∂μ = ∫ x in s, f x ∂μ := by rw [← Measure.restrict_inter_add_diff₀ s ht, integral_add_measure] · exact Integrable.mono_measure hfs (Measure.restrict_mono inter_subset_left le_rfl) · exact Integrable.mono_measure hfs (Measure.restrict_mono diff_subset le_rfl) #align measure_theory.integral_inter_add_diff₀ MeasureTheory.integral_inter_add_diff₀ theorem integral_inter_add_diff (ht : MeasurableSet t) (hfs : IntegrableOn f s μ) : ∫ x in s ∩ t, f x ∂μ + ∫ x in s \ t, f x ∂μ = ∫ x in s, f x ∂μ := integral_inter_add_diff₀ ht.nullMeasurableSet hfs #align measure_theory.integral_inter_add_diff MeasureTheory.integral_inter_add_diff theorem integral_finset_biUnion {ι : Type*} (t : Finset ι) {s : ι → Set X} (hs : ∀ i ∈ t, MeasurableSet (s i)) (h's : Set.Pairwise (↑t) (Disjoint on s)) (hf : ∀ i ∈ t, IntegrableOn f (s i) μ) : ∫ x in ⋃ i ∈ t, s i, f x ∂μ = ∑ i ∈ t, ∫ x in s i, f x ∂μ := by induction' t using Finset.induction_on with a t hat IH hs h's · simp · simp only [Finset.coe_insert, Finset.forall_mem_insert, Set.pairwise_insert, Finset.set_biUnion_insert] at hs hf h's ⊢ rw [integral_union _ _ hf.1 (integrableOn_finset_iUnion.2 hf.2)] · rw [Finset.sum_insert hat, IH hs.2 h's.1 hf.2] · simp only [disjoint_iUnion_right] exact fun i hi => (h's.2 i hi (ne_of_mem_of_not_mem hi hat).symm).1 · exact Finset.measurableSet_biUnion _ hs.2 #align measure_theory.integral_finset_bUnion MeasureTheory.integral_finset_biUnion theorem integral_fintype_iUnion {ι : Type*} [Fintype ι] {s : ι → Set X} (hs : ∀ i, MeasurableSet (s i)) (h's : Pairwise (Disjoint on s)) (hf : ∀ i, IntegrableOn f (s i) μ) : ∫ x in ⋃ i, s i, f x ∂μ = ∑ i, ∫ x in s i, f x ∂μ := by convert integral_finset_biUnion Finset.univ (fun i _ => hs i) _ fun i _ => hf i · simp · simp [pairwise_univ, h's] #align measure_theory.integral_fintype_Union MeasureTheory.integral_fintype_iUnion theorem integral_empty : ∫ x in ∅, f x ∂μ = 0 := by rw [Measure.restrict_empty, integral_zero_measure] #align measure_theory.integral_empty MeasureTheory.integral_empty theorem integral_univ : ∫ x in univ, f x ∂μ = ∫ x, f x ∂μ := by rw [Measure.restrict_univ] #align measure_theory.integral_univ MeasureTheory.integral_univ theorem integral_add_compl₀ (hs : NullMeasurableSet s μ) (hfi : Integrable f μ) : ∫ x in s, f x ∂μ + ∫ x in sᶜ, f x ∂μ = ∫ x, f x ∂μ := by rw [ ← integral_union_ae disjoint_compl_right.aedisjoint hs.compl hfi.integrableOn hfi.integrableOn, union_compl_self, integral_univ] #align measure_theory.integral_add_compl₀ MeasureTheory.integral_add_compl₀ theorem integral_add_compl (hs : MeasurableSet s) (hfi : Integrable f μ) : ∫ x in s, f x ∂μ + ∫ x in sᶜ, f x ∂μ = ∫ x, f x ∂μ := integral_add_compl₀ hs.nullMeasurableSet hfi #align measure_theory.integral_add_compl MeasureTheory.integral_add_compl theorem integral_indicator (hs : MeasurableSet s) : ∫ x, indicator s f x ∂μ = ∫ x in s, f x ∂μ := by by_cases hfi : IntegrableOn f s μ; swap · rw [integral_undef hfi, integral_undef] rwa [integrable_indicator_iff hs] calc ∫ x, indicator s f x ∂μ = ∫ x in s, indicator s f x ∂μ + ∫ x in sᶜ, indicator s f x ∂μ := (integral_add_compl hs (hfi.integrable_indicator hs)).symm _ = ∫ x in s, f x ∂μ + ∫ x in sᶜ, 0 ∂μ := (congr_arg₂ (· + ·) (integral_congr_ae (indicator_ae_eq_restrict hs)) (integral_congr_ae (indicator_ae_eq_restrict_compl hs))) _ = ∫ x in s, f x ∂μ := by simp #align measure_theory.integral_indicator MeasureTheory.integral_indicator theorem setIntegral_indicator (ht : MeasurableSet t) : ∫ x in s, t.indicator f x ∂μ = ∫ x in s ∩ t, f x ∂μ := by rw [integral_indicator ht, Measure.restrict_restrict ht, Set.inter_comm] #align measure_theory.set_integral_indicator MeasureTheory.setIntegral_indicator @[deprecated (since := "2024-04-17")] alias set_integral_indicator := setIntegral_indicator theorem ofReal_setIntegral_one_of_measure_ne_top {X : Type*} {m : MeasurableSpace X} {μ : Measure X} {s : Set X} (hs : μ s ≠ ∞) : ENNReal.ofReal (∫ _ in s, (1 : ℝ) ∂μ) = μ s := calc ENNReal.ofReal (∫ _ in s, (1 : ℝ) ∂μ) = ENNReal.ofReal (∫ _ in s, ‖(1 : ℝ)‖ ∂μ) := by simp only [norm_one] _ = ∫⁻ _ in s, 1 ∂μ := by rw [ofReal_integral_norm_eq_lintegral_nnnorm (integrableOn_const.2 (Or.inr hs.lt_top))] simp only [nnnorm_one, ENNReal.coe_one] _ = μ s := set_lintegral_one _ #align measure_theory.of_real_set_integral_one_of_measure_ne_top MeasureTheory.ofReal_setIntegral_one_of_measure_ne_top @[deprecated (since := "2024-04-17")] alias ofReal_set_integral_one_of_measure_ne_top := ofReal_setIntegral_one_of_measure_ne_top theorem ofReal_setIntegral_one {X : Type*} {_ : MeasurableSpace X} (μ : Measure X) [IsFiniteMeasure μ] (s : Set X) : ENNReal.ofReal (∫ _ in s, (1 : ℝ) ∂μ) = μ s := ofReal_setIntegral_one_of_measure_ne_top (measure_ne_top μ s) #align measure_theory.of_real_set_integral_one MeasureTheory.ofReal_setIntegral_one @[deprecated (since := "2024-04-17")] alias ofReal_set_integral_one := ofReal_setIntegral_one theorem integral_piecewise [DecidablePred (· ∈ s)] (hs : MeasurableSet s) (hf : IntegrableOn f s μ) (hg : IntegrableOn g sᶜ μ) : ∫ x, s.piecewise f g x ∂μ = ∫ x in s, f x ∂μ + ∫ x in sᶜ, g x ∂μ := by rw [← Set.indicator_add_compl_eq_piecewise, integral_add' (hf.integrable_indicator hs) (hg.integrable_indicator hs.compl), integral_indicator hs, integral_indicator hs.compl] #align measure_theory.integral_piecewise MeasureTheory.integral_piecewise theorem tendsto_setIntegral_of_monotone {ι : Type*} [Countable ι] [SemilatticeSup ι] {s : ι → Set X} (hsm : ∀ i, MeasurableSet (s i)) (h_mono : Monotone s) (hfi : IntegrableOn f (⋃ n, s n) μ) : Tendsto (fun i => ∫ x in s i, f x ∂μ) atTop (𝓝 (∫ x in ⋃ n, s n, f x ∂μ)) := by have hfi' : ∫⁻ x in ⋃ n, s n, ‖f x‖₊ ∂μ < ∞ := hfi.2 set S := ⋃ i, s i have hSm : MeasurableSet S := MeasurableSet.iUnion hsm have hsub : ∀ {i}, s i ⊆ S := @(subset_iUnion s) rw [← withDensity_apply _ hSm] at hfi' set ν := μ.withDensity fun x => ‖f x‖₊ with hν refine Metric.nhds_basis_closedBall.tendsto_right_iff.2 fun ε ε0 => ?_ lift ε to ℝ≥0 using ε0.le have : ∀ᶠ i in atTop, ν (s i) ∈ Icc (ν S - ε) (ν S + ε) := tendsto_measure_iUnion h_mono (ENNReal.Icc_mem_nhds hfi'.ne (ENNReal.coe_pos.2 ε0).ne') filter_upwards [this] with i hi rw [mem_closedBall_iff_norm', ← integral_diff (hsm i) hfi hsub, ← coe_nnnorm, NNReal.coe_le_coe, ← ENNReal.coe_le_coe] refine (ennnorm_integral_le_lintegral_ennnorm _).trans ?_ rw [← withDensity_apply _ (hSm.diff (hsm _)), ← hν, measure_diff hsub (hsm _)] exacts [tsub_le_iff_tsub_le.mp hi.1, (hi.2.trans_lt <| ENNReal.add_lt_top.2 ⟨hfi', ENNReal.coe_lt_top⟩).ne] #align measure_theory.tendsto_set_integral_of_monotone MeasureTheory.tendsto_setIntegral_of_monotone @[deprecated (since := "2024-04-17")] alias tendsto_set_integral_of_monotone := tendsto_setIntegral_of_monotone theorem tendsto_setIntegral_of_antitone {ι : Type*} [Countable ι] [SemilatticeSup ι] {s : ι → Set X} (hsm : ∀ i, MeasurableSet (s i)) (h_anti : Antitone s) (hfi : ∃ i, IntegrableOn f (s i) μ) : Tendsto (fun i ↦ ∫ x in s i, f x ∂μ) atTop (𝓝 (∫ x in ⋂ n, s n, f x ∂μ)) := by set S := ⋂ i, s i have hSm : MeasurableSet S := MeasurableSet.iInter hsm have hsub i : S ⊆ s i := iInter_subset _ _ set ν := μ.withDensity fun x => ‖f x‖₊ with hν refine Metric.nhds_basis_closedBall.tendsto_right_iff.2 fun ε ε0 => ?_ lift ε to ℝ≥0 using ε0.le rcases hfi with ⟨i₀, hi₀⟩ have νi₀ : ν (s i₀) ≠ ∞ := by simpa [hsm i₀, ν, ENNReal.ofReal, norm_toNNReal] using hi₀.norm.lintegral_lt_top.ne have νS : ν S ≠ ∞ := ((measure_mono (hsub i₀)).trans_lt νi₀.lt_top).ne have : ∀ᶠ i in atTop, ν (s i) ∈ Icc (ν S - ε) (ν S + ε) := by apply tendsto_measure_iInter hsm h_anti ⟨i₀, νi₀⟩ apply ENNReal.Icc_mem_nhds νS (ENNReal.coe_pos.2 ε0).ne' filter_upwards [this, Ici_mem_atTop i₀] with i hi h'i rw [mem_closedBall_iff_norm, ← integral_diff hSm (hi₀.mono_set (h_anti h'i)) (hsub i), ← coe_nnnorm, NNReal.coe_le_coe, ← ENNReal.coe_le_coe] refine (ennnorm_integral_le_lintegral_ennnorm _).trans ?_ rw [← withDensity_apply _ ((hsm _).diff hSm), ← hν, measure_diff (hsub i) hSm νS] exact tsub_le_iff_left.2 hi.2 @[deprecated (since := "2024-04-17")] alias tendsto_set_integral_of_antitone := tendsto_setIntegral_of_antitone theorem hasSum_integral_iUnion_ae {ι : Type*} [Countable ι] {s : ι → Set X} (hm : ∀ i, NullMeasurableSet (s i) μ) (hd : Pairwise (AEDisjoint μ on s)) (hfi : IntegrableOn f (⋃ i, s i) μ) : HasSum (fun n => ∫ x in s n, f x ∂μ) (∫ x in ⋃ n, s n, f x ∂μ) := by simp only [IntegrableOn, Measure.restrict_iUnion_ae hd hm] at hfi ⊢ exact hasSum_integral_measure hfi #align measure_theory.has_sum_integral_Union_ae MeasureTheory.hasSum_integral_iUnion_ae theorem hasSum_integral_iUnion {ι : Type*} [Countable ι] {s : ι → Set X} (hm : ∀ i, MeasurableSet (s i)) (hd : Pairwise (Disjoint on s)) (hfi : IntegrableOn f (⋃ i, s i) μ) : HasSum (fun n => ∫ x in s n, f x ∂μ) (∫ x in ⋃ n, s n, f x ∂μ) := hasSum_integral_iUnion_ae (fun i => (hm i).nullMeasurableSet) (hd.mono fun _ _ h => h.aedisjoint) hfi #align measure_theory.has_sum_integral_Union MeasureTheory.hasSum_integral_iUnion theorem integral_iUnion {ι : Type*} [Countable ι] {s : ι → Set X} (hm : ∀ i, MeasurableSet (s i)) (hd : Pairwise (Disjoint on s)) (hfi : IntegrableOn f (⋃ i, s i) μ) : ∫ x in ⋃ n, s n, f x ∂μ = ∑' n, ∫ x in s n, f x ∂μ := (HasSum.tsum_eq (hasSum_integral_iUnion hm hd hfi)).symm #align measure_theory.integral_Union MeasureTheory.integral_iUnion theorem integral_iUnion_ae {ι : Type*} [Countable ι] {s : ι → Set X} (hm : ∀ i, NullMeasurableSet (s i) μ) (hd : Pairwise (AEDisjoint μ on s)) (hfi : IntegrableOn f (⋃ i, s i) μ) : ∫ x in ⋃ n, s n, f x ∂μ = ∑' n, ∫ x in s n, f x ∂μ := (HasSum.tsum_eq (hasSum_integral_iUnion_ae hm hd hfi)).symm #align measure_theory.integral_Union_ae MeasureTheory.integral_iUnion_ae theorem setIntegral_eq_zero_of_ae_eq_zero (ht_eq : ∀ᵐ x ∂μ, x ∈ t → f x = 0) : ∫ x in t, f x ∂μ = 0 := by by_cases hf : AEStronglyMeasurable f (μ.restrict t); swap · rw [integral_undef] contrapose! hf exact hf.1 have : ∫ x in t, hf.mk f x ∂μ = 0 := by refine integral_eq_zero_of_ae ?_ rw [EventuallyEq, ae_restrict_iff (hf.stronglyMeasurable_mk.measurableSet_eq_fun stronglyMeasurable_zero)] filter_upwards [ae_imp_of_ae_restrict hf.ae_eq_mk, ht_eq] with x hx h'x h''x rw [← hx h''x] exact h'x h''x rw [← this] exact integral_congr_ae hf.ae_eq_mk #align measure_theory.set_integral_eq_zero_of_ae_eq_zero MeasureTheory.setIntegral_eq_zero_of_ae_eq_zero @[deprecated (since := "2024-04-17")] alias set_integral_eq_zero_of_ae_eq_zero := setIntegral_eq_zero_of_ae_eq_zero theorem setIntegral_eq_zero_of_forall_eq_zero (ht_eq : ∀ x ∈ t, f x = 0) : ∫ x in t, f x ∂μ = 0 := setIntegral_eq_zero_of_ae_eq_zero (eventually_of_forall ht_eq) #align measure_theory.set_integral_eq_zero_of_forall_eq_zero MeasureTheory.setIntegral_eq_zero_of_forall_eq_zero @[deprecated (since := "2024-04-17")] alias set_integral_eq_zero_of_forall_eq_zero := setIntegral_eq_zero_of_forall_eq_zero theorem integral_union_eq_left_of_ae_aux (ht_eq : ∀ᵐ x ∂μ.restrict t, f x = 0) (haux : StronglyMeasurable f) (H : IntegrableOn f (s ∪ t) μ) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ := by let k := f ⁻¹' {0} have hk : MeasurableSet k := by borelize E; exact haux.measurable (measurableSet_singleton _) have h's : IntegrableOn f s μ := H.mono subset_union_left le_rfl have A : ∀ u : Set X, ∫ x in u ∩ k, f x ∂μ = 0 := fun u => setIntegral_eq_zero_of_forall_eq_zero fun x hx => hx.2 rw [← integral_inter_add_diff hk h's, ← integral_inter_add_diff hk H, A, A, zero_add, zero_add, union_diff_distrib, union_comm] apply setIntegral_congr_set_ae rw [union_ae_eq_right] apply measure_mono_null diff_subset rw [measure_zero_iff_ae_nmem] filter_upwards [ae_imp_of_ae_restrict ht_eq] with x hx h'x using h'x.2 (hx h'x.1) #align measure_theory.integral_union_eq_left_of_ae_aux MeasureTheory.integral_union_eq_left_of_ae_aux theorem integral_union_eq_left_of_ae (ht_eq : ∀ᵐ x ∂μ.restrict t, f x = 0) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ := by have ht : IntegrableOn f t μ := by apply integrableOn_zero.congr_fun_ae; symm; exact ht_eq by_cases H : IntegrableOn f (s ∪ t) μ; swap · rw [integral_undef H, integral_undef]; simpa [integrableOn_union, ht] using H let f' := H.1.mk f calc ∫ x : X in s ∪ t, f x ∂μ = ∫ x : X in s ∪ t, f' x ∂μ := integral_congr_ae H.1.ae_eq_mk _ = ∫ x in s, f' x ∂μ := by apply integral_union_eq_left_of_ae_aux _ H.1.stronglyMeasurable_mk (H.congr_fun_ae H.1.ae_eq_mk) filter_upwards [ht_eq, ae_mono (Measure.restrict_mono subset_union_right le_rfl) H.1.ae_eq_mk] with x hx h'x rw [← h'x, hx] _ = ∫ x in s, f x ∂μ := integral_congr_ae (ae_mono (Measure.restrict_mono subset_union_left le_rfl) H.1.ae_eq_mk.symm) #align measure_theory.integral_union_eq_left_of_ae MeasureTheory.integral_union_eq_left_of_ae theorem integral_union_eq_left_of_forall₀ {f : X → E} (ht : NullMeasurableSet t μ) (ht_eq : ∀ x ∈ t, f x = 0) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ := integral_union_eq_left_of_ae ((ae_restrict_iff'₀ ht).2 (eventually_of_forall ht_eq)) #align measure_theory.integral_union_eq_left_of_forall₀ MeasureTheory.integral_union_eq_left_of_forall₀ theorem integral_union_eq_left_of_forall {f : X → E} (ht : MeasurableSet t) (ht_eq : ∀ x ∈ t, f x = 0) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ := integral_union_eq_left_of_forall₀ ht.nullMeasurableSet ht_eq #align measure_theory.integral_union_eq_left_of_forall MeasureTheory.integral_union_eq_left_of_forall theorem setIntegral_eq_of_subset_of_ae_diff_eq_zero_aux (hts : s ⊆ t) (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) (haux : StronglyMeasurable f) (h'aux : IntegrableOn f t μ) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by let k := f ⁻¹' {0} have hk : MeasurableSet k := by borelize E; exact haux.measurable (measurableSet_singleton _) calc ∫ x in t, f x ∂μ = ∫ x in t ∩ k, f x ∂μ + ∫ x in t \ k, f x ∂μ := by rw [integral_inter_add_diff hk h'aux] _ = ∫ x in t \ k, f x ∂μ := by rw [setIntegral_eq_zero_of_forall_eq_zero fun x hx => ?_, zero_add]; exact hx.2 _ = ∫ x in s \ k, f x ∂μ := by apply setIntegral_congr_set_ae filter_upwards [h't] with x hx change (x ∈ t \ k) = (x ∈ s \ k) simp only [mem_preimage, mem_singleton_iff, eq_iff_iff, and_congr_left_iff, mem_diff] intro h'x by_cases xs : x ∈ s · simp only [xs, hts xs] · simp only [xs, iff_false_iff] intro xt exact h'x (hx ⟨xt, xs⟩) _ = ∫ x in s ∩ k, f x ∂μ + ∫ x in s \ k, f x ∂μ := by have : ∀ x ∈ s ∩ k, f x = 0 := fun x hx => hx.2 rw [setIntegral_eq_zero_of_forall_eq_zero this, zero_add] _ = ∫ x in s, f x ∂μ := by rw [integral_inter_add_diff hk (h'aux.mono hts le_rfl)] #align measure_theory.set_integral_eq_of_subset_of_ae_diff_eq_zero_aux MeasureTheory.setIntegral_eq_of_subset_of_ae_diff_eq_zero_aux @[deprecated (since := "2024-04-17")] alias set_integral_eq_of_subset_of_ae_diff_eq_zero_aux := setIntegral_eq_of_subset_of_ae_diff_eq_zero_aux theorem setIntegral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t) (h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by by_cases h : IntegrableOn f t μ; swap · have : ¬IntegrableOn f s μ := fun H => h (H.of_ae_diff_eq_zero ht h't) rw [integral_undef h, integral_undef this] let f' := h.1.mk f calc ∫ x in t, f x ∂μ = ∫ x in t, f' x ∂μ := integral_congr_ae h.1.ae_eq_mk _ = ∫ x in s, f' x ∂μ := by apply setIntegral_eq_of_subset_of_ae_diff_eq_zero_aux hts _ h.1.stronglyMeasurable_mk (h.congr h.1.ae_eq_mk) filter_upwards [h't, ae_imp_of_ae_restrict h.1.ae_eq_mk] with x hx h'x h''x rw [← h'x h''x.1, hx h''x] _ = ∫ x in s, f x ∂μ := by apply integral_congr_ae apply ae_restrict_of_ae_restrict_of_subset hts exact h.1.ae_eq_mk.symm #align measure_theory.set_integral_eq_of_subset_of_ae_diff_eq_zero MeasureTheory.setIntegral_eq_of_subset_of_ae_diff_eq_zero @[deprecated (since := "2024-04-17")] alias set_integral_eq_of_subset_of_ae_diff_eq_zero := setIntegral_eq_of_subset_of_ae_diff_eq_zero theorem setIntegral_eq_of_subset_of_forall_diff_eq_zero (ht : MeasurableSet t) (hts : s ⊆ t) (h't : ∀ x ∈ t \ s, f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := setIntegral_eq_of_subset_of_ae_diff_eq_zero ht.nullMeasurableSet hts (eventually_of_forall fun x hx => h't x hx) #align measure_theory.set_integral_eq_of_subset_of_forall_diff_eq_zero MeasureTheory.setIntegral_eq_of_subset_of_forall_diff_eq_zero @[deprecated (since := "2024-04-17")] alias set_integral_eq_of_subset_of_forall_diff_eq_zero := setIntegral_eq_of_subset_of_forall_diff_eq_zero theorem setIntegral_eq_integral_of_ae_compl_eq_zero (h : ∀ᵐ x ∂μ, x ∉ s → f x = 0) : ∫ x in s, f x ∂μ = ∫ x, f x ∂μ := by symm nth_rw 1 [← integral_univ] apply setIntegral_eq_of_subset_of_ae_diff_eq_zero nullMeasurableSet_univ (subset_univ _) filter_upwards [h] with x hx h'x using hx h'x.2 #align measure_theory.set_integral_eq_integral_of_ae_compl_eq_zero MeasureTheory.setIntegral_eq_integral_of_ae_compl_eq_zero @[deprecated (since := "2024-04-17")] alias set_integral_eq_integral_of_ae_compl_eq_zero := setIntegral_eq_integral_of_ae_compl_eq_zero theorem setIntegral_eq_integral_of_forall_compl_eq_zero (h : ∀ x, x ∉ s → f x = 0) : ∫ x in s, f x ∂μ = ∫ x, f x ∂μ := setIntegral_eq_integral_of_ae_compl_eq_zero (eventually_of_forall h) #align measure_theory.set_integral_eq_integral_of_forall_compl_eq_zero MeasureTheory.setIntegral_eq_integral_of_forall_compl_eq_zero @[deprecated (since := "2024-04-17")] alias set_integral_eq_integral_of_forall_compl_eq_zero := setIntegral_eq_integral_of_forall_compl_eq_zero
Mathlib/MeasureTheory/Integral/SetIntegral.lean
482
492
theorem setIntegral_neg_eq_setIntegral_nonpos [LinearOrder E] {f : X → E} (hf : AEStronglyMeasurable f μ) : ∫ x in {x | f x < 0}, f x ∂μ = ∫ x in {x | f x ≤ 0}, f x ∂μ := by
have h_union : {x | f x ≤ 0} = {x | f x < 0} ∪ {x | f x = 0} := by simp_rw [le_iff_lt_or_eq, setOf_or] rw [h_union] have B : NullMeasurableSet {x | f x = 0} μ := hf.nullMeasurableSet_eq_fun aestronglyMeasurable_zero symm refine integral_union_eq_left_of_ae ?_ filter_upwards [ae_restrict_mem₀ B] with x hx using hx
import Mathlib.Logic.Function.Basic import Mathlib.Tactic.MkIffOfInductiveProp #align_import data.sum.basic from "leanprover-community/mathlib"@"bd9851ca476957ea4549eb19b40e7b5ade9428cc" universe u v w x variable {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} {γ δ : Type*} namespace Sum #align sum.forall Sum.forall #align sum.exists Sum.exists theorem exists_sum {γ : α ⊕ β → Sort*} (p : (∀ ab, γ ab) → Prop) : (∃ fab, p fab) ↔ (∃ fa fb, p (Sum.rec fa fb)) := by rw [← not_forall_not, forall_sum] simp theorem inl_injective : Function.Injective (inl : α → Sum α β) := fun _ _ ↦ inl.inj #align sum.inl_injective Sum.inl_injective theorem inr_injective : Function.Injective (inr : β → Sum α β) := fun _ _ ↦ inr.inj #align sum.inr_injective Sum.inr_injective theorem sum_rec_congr (P : α ⊕ β → Sort*) (f : ∀ i, P (inl i)) (g : ∀ i, P (inr i)) {x y : α ⊕ β} (h : x = y) : @Sum.rec _ _ _ f g x = cast (congr_arg P h.symm) (@Sum.rec _ _ _ f g y) := by cases h; rfl section get #align sum.is_left Sum.isLeft #align sum.is_right Sum.isRight #align sum.get_left Sum.getLeft? #align sum.get_right Sum.getRight? variable {x y : Sum α β} #align sum.get_left_eq_none_iff Sum.getLeft?_eq_none_iff #align sum.get_right_eq_none_iff Sum.getRight?_eq_none_iff theorem eq_left_iff_getLeft_eq {a : α} : x = inl a ↔ ∃ h, x.getLeft h = a := by cases x <;> simp theorem eq_right_iff_getRight_eq {b : β} : x = inr b ↔ ∃ h, x.getRight h = b := by cases x <;> simp #align sum.get_left_eq_some_iff Sum.getLeft?_eq_some_iff #align sum.get_right_eq_some_iff Sum.getRight?_eq_some_iff
Mathlib/Data/Sum/Basic.lean
63
64
theorem getLeft_eq_getLeft? (h₁ : x.isLeft) (h₂ : x.getLeft?.isSome) : x.getLeft h₁ = x.getLeft?.get h₂ := by
simp [← getLeft?_eq_some_iff]
import Mathlib.Analysis.Calculus.MeanValue import Mathlib.Analysis.Convex.Slope open Metric Set Asymptotics ContinuousLinearMap Filter open scoped Classical Topology NNReal theorem MonotoneOn.convexOn_of_deriv {D : Set ℝ} (hD : Convex ℝ D) {f : ℝ → ℝ} (hf : ContinuousOn f D) (hf' : DifferentiableOn ℝ f (interior D)) (hf'_mono : MonotoneOn (deriv f) (interior D)) : ConvexOn ℝ D f := convexOn_of_slope_mono_adjacent hD (by intro x y z hx hz hxy hyz -- First we prove some trivial inclusions have hxzD : Icc x z ⊆ D := hD.ordConnected.out hx hz have hxyD : Icc x y ⊆ D := (Icc_subset_Icc_right hyz.le).trans hxzD have hxyD' : Ioo x y ⊆ interior D := subset_sUnion_of_mem ⟨isOpen_Ioo, Ioo_subset_Icc_self.trans hxyD⟩ have hyzD : Icc y z ⊆ D := (Icc_subset_Icc_left hxy.le).trans hxzD have hyzD' : Ioo y z ⊆ interior D := subset_sUnion_of_mem ⟨isOpen_Ioo, Ioo_subset_Icc_self.trans hyzD⟩ -- Then we apply MVT to both `[x, y]` and `[y, z]` obtain ⟨a, ⟨hxa, hay⟩, ha⟩ : ∃ a ∈ Ioo x y, deriv f a = (f y - f x) / (y - x) := exists_deriv_eq_slope f hxy (hf.mono hxyD) (hf'.mono hxyD') obtain ⟨b, ⟨hyb, hbz⟩, hb⟩ : ∃ b ∈ Ioo y z, deriv f b = (f z - f y) / (z - y) := exists_deriv_eq_slope f hyz (hf.mono hyzD) (hf'.mono hyzD') rw [← ha, ← hb] exact hf'_mono (hxyD' ⟨hxa, hay⟩) (hyzD' ⟨hyb, hbz⟩) (hay.trans hyb).le) #align monotone_on.convex_on_of_deriv MonotoneOn.convexOn_of_deriv theorem AntitoneOn.concaveOn_of_deriv {D : Set ℝ} (hD : Convex ℝ D) {f : ℝ → ℝ} (hf : ContinuousOn f D) (hf' : DifferentiableOn ℝ f (interior D)) (h_anti : AntitoneOn (deriv f) (interior D)) : ConcaveOn ℝ D f := haveI : MonotoneOn (deriv (-f)) (interior D) := by simpa only [← deriv.neg] using h_anti.neg neg_convexOn_iff.mp (this.convexOn_of_deriv hD hf.neg hf'.neg) #align antitone_on.concave_on_of_deriv AntitoneOn.concaveOn_of_deriv theorem StrictMonoOn.exists_slope_lt_deriv_aux {x y : ℝ} {f : ℝ → ℝ} (hf : ContinuousOn f (Icc x y)) (hxy : x < y) (hf'_mono : StrictMonoOn (deriv f) (Ioo x y)) (h : ∀ w ∈ Ioo x y, deriv f w ≠ 0) : ∃ a ∈ Ioo x y, (f y - f x) / (y - x) < deriv f a := by have A : DifferentiableOn ℝ f (Ioo x y) := fun w wmem => (differentiableAt_of_deriv_ne_zero (h w wmem)).differentiableWithinAt obtain ⟨a, ⟨hxa, hay⟩, ha⟩ : ∃ a ∈ Ioo x y, deriv f a = (f y - f x) / (y - x) := exists_deriv_eq_slope f hxy hf A rcases nonempty_Ioo.2 hay with ⟨b, ⟨hab, hby⟩⟩ refine ⟨b, ⟨hxa.trans hab, hby⟩, ?_⟩ rw [← ha] exact hf'_mono ⟨hxa, hay⟩ ⟨hxa.trans hab, hby⟩ hab #align strict_mono_on.exists_slope_lt_deriv_aux StrictMonoOn.exists_slope_lt_deriv_aux
Mathlib/Analysis/Convex/Deriv.lean
78
108
theorem StrictMonoOn.exists_slope_lt_deriv {x y : ℝ} {f : ℝ → ℝ} (hf : ContinuousOn f (Icc x y)) (hxy : x < y) (hf'_mono : StrictMonoOn (deriv f) (Ioo x y)) : ∃ a ∈ Ioo x y, (f y - f x) / (y - x) < deriv f a := by
by_cases h : ∀ w ∈ Ioo x y, deriv f w ≠ 0 · apply StrictMonoOn.exists_slope_lt_deriv_aux hf hxy hf'_mono h · push_neg at h rcases h with ⟨w, ⟨hxw, hwy⟩, hw⟩ obtain ⟨a, ⟨hxa, haw⟩, ha⟩ : ∃ a ∈ Ioo x w, (f w - f x) / (w - x) < deriv f a := by apply StrictMonoOn.exists_slope_lt_deriv_aux _ hxw _ _ · exact hf.mono (Icc_subset_Icc le_rfl hwy.le) · exact hf'_mono.mono (Ioo_subset_Ioo le_rfl hwy.le) · intro z hz rw [← hw] apply ne_of_lt exact hf'_mono ⟨hz.1, hz.2.trans hwy⟩ ⟨hxw, hwy⟩ hz.2 obtain ⟨b, ⟨hwb, hby⟩, hb⟩ : ∃ b ∈ Ioo w y, (f y - f w) / (y - w) < deriv f b := by apply StrictMonoOn.exists_slope_lt_deriv_aux _ hwy _ _ · refine hf.mono (Icc_subset_Icc hxw.le le_rfl) · exact hf'_mono.mono (Ioo_subset_Ioo hxw.le le_rfl) · intro z hz rw [← hw] apply ne_of_gt exact hf'_mono ⟨hxw, hwy⟩ ⟨hxw.trans hz.1, hz.2⟩ hz.1 refine ⟨b, ⟨hxw.trans hwb, hby⟩, ?_⟩ simp only [div_lt_iff, hxy, hxw, hwy, sub_pos] at ha hb ⊢ have : deriv f a * (w - x) < deriv f b * (w - x) := by apply mul_lt_mul _ le_rfl (sub_pos.2 hxw) _ · exact hf'_mono ⟨hxa, haw.trans hwy⟩ ⟨hxw.trans hwb, hby⟩ (haw.trans hwb) · rw [← hw] exact (hf'_mono ⟨hxw, hwy⟩ ⟨hxw.trans hwb, hby⟩ hwb).le linarith
import Mathlib.Algebra.CharP.Invertible import Mathlib.Algebra.Order.Invertible import Mathlib.Algebra.Order.Module.OrderedSMul import Mathlib.Algebra.Order.Group.Instances import Mathlib.LinearAlgebra.AffineSpace.Slope import Mathlib.LinearAlgebra.AffineSpace.Midpoint import Mathlib.Tactic.FieldSimp #align_import linear_algebra.affine_space.ordered from "leanprover-community/mathlib"@"78261225eb5cedc61c5c74ecb44e5b385d13b733" open AffineMap variable {k E PE : Type*} section OrderedRing variable [OrderedRing k] [OrderedAddCommGroup E] [Module k E] [OrderedSMul k E] variable {a a' b b' : E} {r r' : k} theorem lineMap_mono_left (ha : a ≤ a') (hr : r ≤ 1) : lineMap a b r ≤ lineMap a' b r := by simp only [lineMap_apply_module] exact add_le_add_right (smul_le_smul_of_nonneg_left ha (sub_nonneg.2 hr)) _ #align line_map_mono_left lineMap_mono_left theorem lineMap_strict_mono_left (ha : a < a') (hr : r < 1) : lineMap a b r < lineMap a' b r := by simp only [lineMap_apply_module] exact add_lt_add_right (smul_lt_smul_of_pos_left ha (sub_pos.2 hr)) _ #align line_map_strict_mono_left lineMap_strict_mono_left theorem lineMap_mono_right (hb : b ≤ b') (hr : 0 ≤ r) : lineMap a b r ≤ lineMap a b' r := by simp only [lineMap_apply_module] exact add_le_add_left (smul_le_smul_of_nonneg_left hb hr) _ #align line_map_mono_right lineMap_mono_right
Mathlib/LinearAlgebra/AffineSpace/Ordered.lean
67
69
theorem lineMap_strict_mono_right (hb : b < b') (hr : 0 < r) : lineMap a b r < lineMap a b' r := by
simp only [lineMap_apply_module] exact add_lt_add_left (smul_lt_smul_of_pos_left hb hr) _
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 Preorder variable [Preorder α] section CommGroup variable [CommGroup α] -- Most of the lemmas that are primed in this section appear in ordered_field. -- I (DT) did not try to minimise the assumptions. section Group variable [Group α] [LT α] section Right variable [CovariantClass α α (swap (· * ·)) (· < ·)] {a b c d : α} @[to_additive (attr := simp)]
Mathlib/Algebra/Order/Group/Defs.lean
875
876
theorem div_lt_div_iff_right (c : α) : a / c < b / c ↔ a < b := by
simpa only [div_eq_mul_inv] using mul_lt_mul_iff_right _
import Mathlib.Data.Fintype.Basic import Mathlib.Data.Set.Finite #align_import combinatorics.hall.finite from "leanprover-community/mathlib"@"d6fad0e5bf2d6f48da9175d25c3dc5706b3834ce" open Finset universe u v namespace HallMarriageTheorem variable {ι : Type u} {α : Type v} [DecidableEq α] {t : ι → Finset α} section Fintype variable [Fintype ι] theorem hall_cond_of_erase {x : ι} (a : α) (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card) (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by haveI := Classical.decEq ι specialize ha (s'.image fun z => z.1) rw [image_nonempty, Finset.card_image_of_injective s' Subtype.coe_injective] at ha by_cases he : s'.Nonempty · have ha' : s'.card < (s'.biUnion fun x => t x).card := by convert ha he fun h => by simpa [← h] using mem_univ x using 2 ext x simp only [mem_image, mem_biUnion, exists_prop, SetCoe.exists, exists_and_right, exists_eq_right, Subtype.coe_mk] rw [← erase_biUnion] by_cases hb : a ∈ s'.biUnion fun x => t x · rw [card_erase_of_mem hb] exact Nat.le_sub_one_of_lt ha' · rw [erase_eq_of_not_mem hb] exact Nat.le_of_lt ha' · rw [nonempty_iff_ne_empty, not_not] at he subst s' simp #align hall_marriage_theorem.hall_cond_of_erase HallMarriageTheorem.hall_cond_of_erase
Mathlib/Combinatorics/Hall/Finite.lean
78
121
theorem hall_hard_inductive_step_A {n : ℕ} (hn : Fintype.card ι = n + 1) (ht : ∀ s : Finset ι, s.card ≤ (s.biUnion t).card) (ih : ∀ {ι' : Type u} [Fintype ι'] (t' : ι' → Finset α), Fintype.card ι' ≤ n → (∀ s' : Finset ι', s'.card ≤ (s'.biUnion t').card) → ∃ f : ι' → α, Function.Injective f ∧ ∀ x, f x ∈ t' x) (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card) : ∃ f : ι → α, Function.Injective f ∧ ∀ x, f x ∈ t x := by
haveI : Nonempty ι := Fintype.card_pos_iff.mp (hn.symm ▸ Nat.succ_pos _) haveI := Classical.decEq ι -- Choose an arbitrary element `x : ι` and `y : t x`. let x := Classical.arbitrary ι have tx_ne : (t x).Nonempty := by rw [← Finset.card_pos] calc 0 < 1 := Nat.one_pos _ ≤ (Finset.biUnion {x} t).card := ht {x} _ = (t x).card := by rw [Finset.singleton_biUnion] choose y hy using tx_ne -- Restrict to everything except `x` and `y`. let ι' := { x' : ι | x' ≠ x } let t' : ι' → Finset α := fun x' => (t x').erase y have card_ι' : Fintype.card ι' = n := calc Fintype.card ι' = Fintype.card ι - 1 := Set.card_ne_eq _ _ = n := by rw [hn, Nat.add_succ_sub_one, add_zero] rcases ih t' card_ι'.le (hall_cond_of_erase y ha) with ⟨f', hfinj, hfr⟩ -- Extend the resulting function. refine ⟨fun z => if h : z = x then y else f' ⟨z, h⟩, ?_, ?_⟩ · rintro z₁ z₂ have key : ∀ {x}, y ≠ f' x := by intro x h simpa [t', ← h] using hfr x by_cases h₁ : z₁ = x <;> by_cases h₂ : z₂ = x <;> simp [h₁, h₂, hfinj.eq_iff, key, key.symm] · intro z simp only [ne_eq, Set.mem_setOf_eq] split_ifs with hz · rwa [hz] · specialize hfr ⟨z, hz⟩ rw [mem_erase] at hfr exact hfr.2
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] 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] #align turing.tape.move_left_mk' Turing.Tape.move_left_mk' @[simp] theorem Tape.move_right_mk' {Γ} [Inhabited Γ] (L R : ListBlank Γ) : (Tape.mk' L R).move Dir.right = Tape.mk' (L.cons R.head) R.tail := by simp only [Tape.move, Tape.mk', ListBlank.head_cons, eq_self_iff_true, ListBlank.cons_head_tail, and_self_iff, ListBlank.tail_cons] #align turing.tape.move_right_mk' Turing.Tape.move_right_mk' def Tape.mk₂ {Γ} [Inhabited Γ] (L R : List Γ) : Tape Γ := Tape.mk' (ListBlank.mk L) (ListBlank.mk R) #align turing.tape.mk₂ Turing.Tape.mk₂ def Tape.mk₁ {Γ} [Inhabited Γ] (l : List Γ) : Tape Γ := Tape.mk₂ [] l #align turing.tape.mk₁ Turing.Tape.mk₁ def Tape.nth {Γ} [Inhabited Γ] (T : Tape Γ) : ℤ → Γ | 0 => T.head | (n + 1 : ℕ) => T.right.nth n | -(n + 1 : ℕ) => T.left.nth n #align turing.tape.nth Turing.Tape.nth @[simp] theorem Tape.nth_zero {Γ} [Inhabited Γ] (T : Tape Γ) : T.nth 0 = T.1 := rfl #align turing.tape.nth_zero Turing.Tape.nth_zero theorem Tape.right₀_nth {Γ} [Inhabited Γ] (T : Tape Γ) (n : ℕ) : T.right₀.nth n = T.nth n := by cases n <;> simp only [Tape.nth, Tape.right₀, Int.ofNat_zero, ListBlank.nth_zero, ListBlank.nth_succ, ListBlank.head_cons, ListBlank.tail_cons, Nat.zero_eq] #align turing.tape.right₀_nth Turing.Tape.right₀_nth @[simp] theorem Tape.mk'_nth_nat {Γ} [Inhabited Γ] (L R : ListBlank Γ) (n : ℕ) : (Tape.mk' L R).nth n = R.nth n := by rw [← Tape.right₀_nth, Tape.mk'_right₀] #align turing.tape.mk'_nth_nat Turing.Tape.mk'_nth_nat @[simp] theorem Tape.move_left_nth {Γ} [Inhabited Γ] : ∀ (T : Tape Γ) (i : ℤ), (T.move Dir.left).nth i = T.nth (i - 1) | ⟨_, L, _⟩, -(n + 1 : ℕ) => (ListBlank.nth_succ _ _).symm | ⟨_, L, _⟩, 0 => (ListBlank.nth_zero _).symm | ⟨a, L, R⟩, 1 => (ListBlank.nth_zero _).trans (ListBlank.head_cons _ _) | ⟨a, L, R⟩, (n + 1 : ℕ) + 1 => by rw [add_sub_cancel_right] change (R.cons a).nth (n + 1) = R.nth n rw [ListBlank.nth_succ, ListBlank.tail_cons] #align turing.tape.move_left_nth Turing.Tape.move_left_nth @[simp] theorem Tape.move_right_nth {Γ} [Inhabited Γ] (T : Tape Γ) (i : ℤ) : (T.move Dir.right).nth i = T.nth (i + 1) := by conv => rhs; rw [← T.move_right_left] rw [Tape.move_left_nth, add_sub_cancel_right] #align turing.tape.move_right_nth Turing.Tape.move_right_nth @[simp] theorem Tape.move_right_n_head {Γ} [Inhabited Γ] (T : Tape Γ) (i : ℕ) : ((Tape.move Dir.right)^[i] T).head = T.nth i := by induction i generalizing T · rfl · simp only [*, Tape.move_right_nth, Int.ofNat_succ, iterate_succ, Function.comp_apply] #align turing.tape.move_right_n_head Turing.Tape.move_right_n_head def Tape.write {Γ} [Inhabited Γ] (b : Γ) (T : Tape Γ) : Tape Γ := { T with head := b } #align turing.tape.write Turing.Tape.write @[simp] theorem Tape.write_self {Γ} [Inhabited Γ] : ∀ T : Tape Γ, T.write T.1 = T := by rintro ⟨⟩; rfl #align turing.tape.write_self Turing.Tape.write_self @[simp] theorem Tape.write_nth {Γ} [Inhabited Γ] (b : Γ) : ∀ (T : Tape Γ) {i : ℤ}, (T.write b).nth i = if i = 0 then b else T.nth i | _, 0 => rfl | _, (_ + 1 : ℕ) => rfl | _, -(_ + 1 : ℕ) => rfl #align turing.tape.write_nth Turing.Tape.write_nth @[simp] theorem Tape.write_mk' {Γ} [Inhabited Γ] (a b : Γ) (L R : ListBlank Γ) : (Tape.mk' L (R.cons a)).write b = Tape.mk' L (R.cons b) := by simp only [Tape.write, Tape.mk', ListBlank.head_cons, ListBlank.tail_cons, eq_self_iff_true, and_self_iff] #align turing.tape.write_mk' Turing.Tape.write_mk' def Tape.map {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (T : Tape Γ) : Tape Γ' := ⟨f T.1, T.2.map f, T.3.map f⟩ #align turing.tape.map Turing.Tape.map @[simp] theorem Tape.map_fst {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') : ∀ T : Tape Γ, (T.map f).1 = f T.1 := by rintro ⟨⟩; rfl #align turing.tape.map_fst Turing.Tape.map_fst @[simp] theorem Tape.map_write {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (b : Γ) : ∀ T : Tape Γ, (T.write b).map f = (T.map f).write (f b) := by rintro ⟨⟩; rfl #align turing.tape.map_write Turing.Tape.map_write -- Porting note: `simpNF` complains about LHS does not simplify when using the simp lemma on -- itself, but it does indeed. @[simp, nolint simpNF] theorem Tape.write_move_right_n {Γ} [Inhabited Γ] (f : Γ → Γ) (L R : ListBlank Γ) (n : ℕ) : ((Tape.move Dir.right)^[n] (Tape.mk' L R)).write (f (R.nth n)) = (Tape.move Dir.right)^[n] (Tape.mk' L (R.modifyNth f n)) := by induction' n with n IH generalizing L R · simp only [ListBlank.nth_zero, ListBlank.modifyNth, iterate_zero_apply, Nat.zero_eq] rw [← Tape.write_mk', ListBlank.cons_head_tail] simp only [ListBlank.head_cons, ListBlank.nth_succ, ListBlank.modifyNth, Tape.move_right_mk', ListBlank.tail_cons, iterate_succ_apply, IH] #align turing.tape.write_move_right_n Turing.Tape.write_move_right_n theorem Tape.map_move {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (T : Tape Γ) (d) : (T.move d).map f = (T.map f).move d := by cases T cases d <;> simp only [Tape.move, Tape.map, ListBlank.head_map, eq_self_iff_true, ListBlank.map_cons, and_self_iff, ListBlank.tail_map] #align turing.tape.map_move Turing.Tape.map_move theorem Tape.map_mk' {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (L R : ListBlank Γ) : (Tape.mk' L R).map f = Tape.mk' (L.map f) (R.map f) := by simp only [Tape.mk', Tape.map, ListBlank.head_map, eq_self_iff_true, and_self_iff, ListBlank.tail_map] #align turing.tape.map_mk' Turing.Tape.map_mk' theorem Tape.map_mk₂ {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (L R : List Γ) : (Tape.mk₂ L R).map f = Tape.mk₂ (L.map f) (R.map f) := by simp only [Tape.mk₂, Tape.map_mk', ListBlank.map_mk] #align turing.tape.map_mk₂ Turing.Tape.map_mk₂ theorem Tape.map_mk₁ {Γ Γ'} [Inhabited Γ] [Inhabited Γ'] (f : PointedMap Γ Γ') (l : List Γ) : (Tape.mk₁ l).map f = Tape.mk₁ (l.map f) := Tape.map_mk₂ _ _ _ #align turing.tape.map_mk₁ Turing.Tape.map_mk₁ def eval {σ} (f : σ → Option σ) : σ → Part σ := PFun.fix fun s ↦ Part.some <| (f s).elim (Sum.inl s) Sum.inr #align turing.eval Turing.eval def Reaches {σ} (f : σ → Option σ) : σ → σ → Prop := ReflTransGen fun a b ↦ b ∈ f a #align turing.reaches Turing.Reaches def Reaches₁ {σ} (f : σ → Option σ) : σ → σ → Prop := TransGen fun a b ↦ b ∈ f a #align turing.reaches₁ Turing.Reaches₁ theorem reaches₁_eq {σ} {f : σ → Option σ} {a b c} (h : f a = f b) : Reaches₁ f a c ↔ Reaches₁ f b c := TransGen.head'_iff.trans (TransGen.head'_iff.trans <| by rw [h]).symm #align turing.reaches₁_eq Turing.reaches₁_eq theorem reaches_total {σ} {f : σ → Option σ} {a b c} (hab : Reaches f a b) (hac : Reaches f a c) : Reaches f b c ∨ Reaches f c b := ReflTransGen.total_of_right_unique (fun _ _ _ ↦ Option.mem_unique) hab hac #align turing.reaches_total Turing.reaches_total theorem reaches₁_fwd {σ} {f : σ → Option σ} {a b c} (h₁ : Reaches₁ f a c) (h₂ : b ∈ f a) : Reaches f b c := by rcases TransGen.head'_iff.1 h₁ with ⟨b', hab, hbc⟩ cases Option.mem_unique hab h₂; exact hbc #align turing.reaches₁_fwd Turing.reaches₁_fwd def Reaches₀ {σ} (f : σ → Option σ) (a b : σ) : Prop := ∀ c, Reaches₁ f b c → Reaches₁ f a c #align turing.reaches₀ Turing.Reaches₀ theorem Reaches₀.trans {σ} {f : σ → Option σ} {a b c : σ} (h₁ : Reaches₀ f a b) (h₂ : Reaches₀ f b c) : Reaches₀ f a c | _, h₃ => h₁ _ (h₂ _ h₃) #align turing.reaches₀.trans Turing.Reaches₀.trans @[refl] theorem Reaches₀.refl {σ} {f : σ → Option σ} (a : σ) : Reaches₀ f a a | _, h => h #align turing.reaches₀.refl Turing.Reaches₀.refl theorem Reaches₀.single {σ} {f : σ → Option σ} {a b : σ} (h : b ∈ f a) : Reaches₀ f a b | _, h₂ => h₂.head h #align turing.reaches₀.single Turing.Reaches₀.single theorem Reaches₀.head {σ} {f : σ → Option σ} {a b c : σ} (h : b ∈ f a) (h₂ : Reaches₀ f b c) : Reaches₀ f a c := (Reaches₀.single h).trans h₂ #align turing.reaches₀.head Turing.Reaches₀.head theorem Reaches₀.tail {σ} {f : σ → Option σ} {a b c : σ} (h₁ : Reaches₀ f a b) (h : c ∈ f b) : Reaches₀ f a c := h₁.trans (Reaches₀.single h) #align turing.reaches₀.tail Turing.Reaches₀.tail theorem reaches₀_eq {σ} {f : σ → Option σ} {a b} (e : f a = f b) : Reaches₀ f a b | _, h => (reaches₁_eq e).2 h #align turing.reaches₀_eq Turing.reaches₀_eq theorem Reaches₁.to₀ {σ} {f : σ → Option σ} {a b : σ} (h : Reaches₁ f a b) : Reaches₀ f a b | _, h₂ => h.trans h₂ #align turing.reaches₁.to₀ Turing.Reaches₁.to₀ theorem Reaches.to₀ {σ} {f : σ → Option σ} {a b : σ} (h : Reaches f a b) : Reaches₀ f a b | _, h₂ => h₂.trans_right h #align turing.reaches.to₀ Turing.Reaches.to₀ theorem Reaches₀.tail' {σ} {f : σ → Option σ} {a b c : σ} (h : Reaches₀ f a b) (h₂ : c ∈ f b) : Reaches₁ f a c := h _ (TransGen.single h₂) #align turing.reaches₀.tail' Turing.Reaches₀.tail' @[elab_as_elim] def evalInduction {σ} {f : σ → Option σ} {b : σ} {C : σ → Sort*} {a : σ} (h : b ∈ eval f a) (H : ∀ a, b ∈ eval f a → (∀ a', f a = some a' → C a') → C a) : C a := PFun.fixInduction h fun a' ha' h' ↦ H _ ha' fun b' e ↦ h' _ <| Part.mem_some_iff.2 <| by rw [e]; rfl #align turing.eval_induction Turing.evalInduction theorem mem_eval {σ} {f : σ → Option σ} {a b} : b ∈ eval f a ↔ Reaches f a b ∧ f b = none := by refine ⟨fun h ↦ ?_, fun ⟨h₁, h₂⟩ ↦ ?_⟩ · -- Porting note: Explicitly specify `c`. refine @evalInduction _ _ _ (fun a ↦ Reaches f a b ∧ f b = none) _ h fun a h IH ↦ ?_ cases' e : f a with a' · rw [Part.mem_unique h (PFun.mem_fix_iff.2 <| Or.inl <| Part.mem_some_iff.2 <| by rw [e] <;> rfl)] exact ⟨ReflTransGen.refl, e⟩ · rcases PFun.mem_fix_iff.1 h with (h | ⟨_, h, _⟩) <;> rw [e] at h <;> cases Part.mem_some_iff.1 h cases' IH a' e with h₁ h₂ exact ⟨ReflTransGen.head e h₁, h₂⟩ · refine ReflTransGen.head_induction_on h₁ ?_ fun h _ IH ↦ ?_ · refine PFun.mem_fix_iff.2 (Or.inl ?_) rw [h₂] apply Part.mem_some · refine PFun.mem_fix_iff.2 (Or.inr ⟨_, ?_, IH⟩) rw [h] apply Part.mem_some #align turing.mem_eval Turing.mem_eval theorem eval_maximal₁ {σ} {f : σ → Option σ} {a b} (h : b ∈ eval f a) (c) : ¬Reaches₁ f b c | bc => by let ⟨_, b0⟩ := mem_eval.1 h let ⟨b', h', _⟩ := TransGen.head'_iff.1 bc cases b0.symm.trans h' #align turing.eval_maximal₁ Turing.eval_maximal₁ theorem eval_maximal {σ} {f : σ → Option σ} {a b} (h : b ∈ eval f a) {c} : Reaches f b c ↔ c = b := let ⟨_, b0⟩ := mem_eval.1 h reflTransGen_iff_eq fun b' h' ↦ by cases b0.symm.trans h' #align turing.eval_maximal Turing.eval_maximal theorem reaches_eval {σ} {f : σ → Option σ} {a b} (ab : Reaches f a b) : eval f a = eval f b := by refine Part.ext fun _ ↦ ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · have ⟨ac, c0⟩ := mem_eval.1 h exact mem_eval.2 ⟨(or_iff_left_of_imp fun cb ↦ (eval_maximal h).1 cb ▸ ReflTransGen.refl).1 (reaches_total ab ac), c0⟩ · have ⟨bc, c0⟩ := mem_eval.1 h exact mem_eval.2 ⟨ab.trans bc, c0⟩ #align turing.reaches_eval Turing.reaches_eval def Respects {σ₁ σ₂} (f₁ : σ₁ → Option σ₁) (f₂ : σ₂ → Option σ₂) (tr : σ₁ → σ₂ → Prop) := ∀ ⦃a₁ a₂⦄, tr a₁ a₂ → (match f₁ a₁ with | some b₁ => ∃ b₂, tr b₁ b₂ ∧ Reaches₁ f₂ a₂ b₂ | none => f₂ a₂ = none : Prop) #align turing.respects Turing.Respects theorem tr_reaches₁ {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂ → Prop} (H : Respects f₁ f₂ tr) {a₁ a₂} (aa : tr a₁ a₂) {b₁} (ab : Reaches₁ f₁ a₁ b₁) : ∃ b₂, tr b₁ b₂ ∧ Reaches₁ f₂ a₂ b₂ := by induction' ab with c₁ ac c₁ d₁ _ cd IH · have := H aa rwa [show f₁ a₁ = _ from ac] at this · rcases IH with ⟨c₂, cc, ac₂⟩ have := H cc rw [show f₁ c₁ = _ from cd] at this rcases this with ⟨d₂, dd, cd₂⟩ exact ⟨_, dd, ac₂.trans cd₂⟩ #align turing.tr_reaches₁ Turing.tr_reaches₁ theorem tr_reaches {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂ → Prop} (H : Respects f₁ f₂ tr) {a₁ a₂} (aa : tr a₁ a₂) {b₁} (ab : Reaches f₁ a₁ b₁) : ∃ b₂, tr b₁ b₂ ∧ Reaches f₂ a₂ b₂ := by rcases reflTransGen_iff_eq_or_transGen.1 ab with (rfl | ab) · exact ⟨_, aa, ReflTransGen.refl⟩ · have ⟨b₂, bb, h⟩ := tr_reaches₁ H aa ab exact ⟨b₂, bb, h.to_reflTransGen⟩ #align turing.tr_reaches Turing.tr_reaches theorem tr_reaches_rev {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂ → Prop} (H : Respects f₁ f₂ tr) {a₁ a₂} (aa : tr a₁ a₂) {b₂} (ab : Reaches f₂ a₂ b₂) : ∃ c₁ c₂, Reaches f₂ b₂ c₂ ∧ tr c₁ c₂ ∧ Reaches f₁ a₁ c₁ := by induction' ab with c₂ d₂ _ cd IH · exact ⟨_, _, ReflTransGen.refl, aa, ReflTransGen.refl⟩ · rcases IH with ⟨e₁, e₂, ce, ee, ae⟩ rcases ReflTransGen.cases_head ce with (rfl | ⟨d', cd', de⟩) · have := H ee revert this cases' eg : f₁ e₁ with g₁ <;> simp only [Respects, and_imp, exists_imp] · intro c0 cases cd.symm.trans c0 · intro g₂ gg cg rcases TransGen.head'_iff.1 cg with ⟨d', cd', dg⟩ cases Option.mem_unique cd cd' exact ⟨_, _, dg, gg, ae.tail eg⟩ · cases Option.mem_unique cd cd' exact ⟨_, _, de, ee, ae⟩ #align turing.tr_reaches_rev Turing.tr_reaches_rev theorem tr_eval {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂ → Prop} (H : Respects f₁ f₂ tr) {a₁ b₁ a₂} (aa : tr a₁ a₂) (ab : b₁ ∈ eval f₁ a₁) : ∃ b₂, tr b₁ b₂ ∧ b₂ ∈ eval f₂ a₂ := by cases' mem_eval.1 ab with ab b0 rcases tr_reaches H aa ab with ⟨b₂, bb, ab⟩ refine ⟨_, bb, mem_eval.2 ⟨ab, ?_⟩⟩ have := H bb; rwa [b0] at this #align turing.tr_eval Turing.tr_eval theorem tr_eval_rev {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂ → Prop} (H : Respects f₁ f₂ tr) {a₁ b₂ a₂} (aa : tr a₁ a₂) (ab : b₂ ∈ eval f₂ a₂) : ∃ b₁, tr b₁ b₂ ∧ b₁ ∈ eval f₁ a₁ := by cases' mem_eval.1 ab with ab b0 rcases tr_reaches_rev H aa ab with ⟨c₁, c₂, bc, cc, ac⟩ cases (reflTransGen_iff_eq (Option.eq_none_iff_forall_not_mem.1 b0)).1 bc refine ⟨_, cc, mem_eval.2 ⟨ac, ?_⟩⟩ have := H cc cases' hfc : f₁ c₁ with d₁ · rfl rw [hfc] at this rcases this with ⟨d₂, _, bd⟩ rcases TransGen.head'_iff.1 bd with ⟨e, h, _⟩ cases b0.symm.trans h #align turing.tr_eval_rev Turing.tr_eval_rev theorem tr_eval_dom {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂ → Prop} (H : Respects f₁ f₂ tr) {a₁ a₂} (aa : tr a₁ a₂) : (eval f₂ a₂).Dom ↔ (eval f₁ a₁).Dom := ⟨fun h ↦ let ⟨_, _, h, _⟩ := tr_eval_rev H aa ⟨h, rfl⟩ h, fun h ↦ let ⟨_, _, h, _⟩ := tr_eval H aa ⟨h, rfl⟩ h⟩ #align turing.tr_eval_dom Turing.tr_eval_dom def FRespects {σ₁ σ₂} (f₂ : σ₂ → Option σ₂) (tr : σ₁ → σ₂) (a₂ : σ₂) : Option σ₁ → Prop | some b₁ => Reaches₁ f₂ a₂ (tr b₁) | none => f₂ a₂ = none #align turing.frespects Turing.FRespects theorem frespects_eq {σ₁ σ₂} {f₂ : σ₂ → Option σ₂} {tr : σ₁ → σ₂} {a₂ b₂} (h : f₂ a₂ = f₂ b₂) : ∀ {b₁}, FRespects f₂ tr a₂ b₁ ↔ FRespects f₂ tr b₂ b₁ | some b₁ => reaches₁_eq h | none => by unfold FRespects; rw [h] #align turing.frespects_eq Turing.frespects_eq theorem fun_respects {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂} : (Respects f₁ f₂ fun a b ↦ tr a = b) ↔ ∀ ⦃a₁⦄, FRespects f₂ tr (tr a₁) (f₁ a₁) := forall_congr' fun a₁ ↦ by cases f₁ a₁ <;> simp only [FRespects, Respects, exists_eq_left', forall_eq'] #align turing.fun_respects Turing.fun_respects theorem tr_eval' {σ₁ σ₂} (f₁ : σ₁ → Option σ₁) (f₂ : σ₂ → Option σ₂) (tr : σ₁ → σ₂) (H : Respects f₁ f₂ fun a b ↦ tr a = b) (a₁) : eval f₂ (tr a₁) = tr <$> eval f₁ a₁ := Part.ext fun b₂ ↦ ⟨fun h ↦ let ⟨b₁, bb, hb⟩ := tr_eval_rev H rfl h (Part.mem_map_iff _).2 ⟨b₁, hb, bb⟩, fun h ↦ by rcases (Part.mem_map_iff _).1 h with ⟨b₁, ab, bb⟩ rcases tr_eval H rfl ab with ⟨_, rfl, h⟩ rwa [bb] at h⟩ #align turing.tr_eval' Turing.tr_eval' namespace TM0 set_option linter.uppercaseLean3 false -- for "TM0" section -- type of tape symbols variable (Γ : Type*) [Inhabited Γ] -- type of "labels" or TM states variable (Λ : Type*) [Inhabited Λ] inductive Stmt | move : Dir → Stmt | write : Γ → Stmt #align turing.TM0.stmt Turing.TM0.Stmt local notation "Stmt₀" => Stmt Γ -- Porting note (#10750): added this to clean up types. instance Stmt.inhabited : Inhabited Stmt₀ := ⟨Stmt.write default⟩ #align turing.TM0.stmt.inhabited Turing.TM0.Stmt.inhabited @[nolint unusedArguments] -- this is a deliberate addition, see comment def Machine [Inhabited Λ] := Λ → Γ → Option (Λ × Stmt₀) #align turing.TM0.machine Turing.TM0.Machine local notation "Machine₀" => Machine Γ Λ -- Porting note (#10750): added this to clean up types. instance Machine.inhabited : Inhabited Machine₀ := by unfold Machine; infer_instance #align turing.TM0.machine.inhabited Turing.TM0.Machine.inhabited structure Cfg where q : Λ Tape : Tape Γ #align turing.TM0.cfg Turing.TM0.Cfg local notation "Cfg₀" => Cfg Γ Λ -- Porting note (#10750): added this to clean up types. instance Cfg.inhabited : Inhabited Cfg₀ := ⟨⟨default, default⟩⟩ #align turing.TM0.cfg.inhabited Turing.TM0.Cfg.inhabited variable {Γ Λ} def step (M : Machine₀) : Cfg₀ → Option Cfg₀ := fun ⟨q, T⟩ ↦ (M q T.1).map fun ⟨q', a⟩ ↦ ⟨q', match a with | Stmt.move d => T.move d | Stmt.write a => T.write a⟩ #align turing.TM0.step Turing.TM0.step def Reaches (M : Machine₀) : Cfg₀ → Cfg₀ → Prop := ReflTransGen fun a b ↦ b ∈ step M a #align turing.TM0.reaches Turing.TM0.Reaches def init (l : List Γ) : Cfg₀ := ⟨default, Tape.mk₁ l⟩ #align turing.TM0.init Turing.TM0.init def eval (M : Machine₀) (l : List Γ) : Part (ListBlank Γ) := (Turing.eval (step M) (init l)).map fun c ↦ c.Tape.right₀ #align turing.TM0.eval Turing.TM0.eval def Supports (M : Machine₀) (S : Set Λ) := default ∈ S ∧ ∀ {q a q' s}, (q', s) ∈ M q a → q ∈ S → q' ∈ S #align turing.TM0.supports Turing.TM0.Supports
Mathlib/Computability/TuringMachine.lean
1,117
1,121
theorem step_supports (M : Machine₀) {S : Set Λ} (ss : Supports M S) : ∀ {c c' : Cfg₀}, c' ∈ step M c → c.q ∈ S → c'.q ∈ S := by
intro ⟨q, T⟩ c' h₁ h₂ rcases Option.map_eq_some'.1 h₁ with ⟨⟨q', a⟩, h, rfl⟩ exact ss.2 h h₂
import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.GeomSum import Mathlib.LinearAlgebra.Matrix.Block import Mathlib.LinearAlgebra.Matrix.Determinant.Basic import Mathlib.LinearAlgebra.Matrix.Nondegenerate #align_import linear_algebra.vandermonde from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" variable {R : Type*} [CommRing R] open Equiv Finset open Matrix namespace Matrix def vandermonde {n : ℕ} (v : Fin n → R) : Matrix (Fin n) (Fin n) R := fun i j => v i ^ (j : ℕ) #align matrix.vandermonde Matrix.vandermonde @[simp] theorem vandermonde_apply {n : ℕ} (v : Fin n → R) (i j) : vandermonde v i j = v i ^ (j : ℕ) := rfl #align matrix.vandermonde_apply Matrix.vandermonde_apply @[simp] theorem vandermonde_cons {n : ℕ} (v0 : R) (v : Fin n → R) : vandermonde (Fin.cons v0 v : Fin n.succ → R) = Fin.cons (fun (j : Fin n.succ) => v0 ^ (j : ℕ)) fun i => Fin.cons 1 fun j => v i * vandermonde v i j := by ext i j refine Fin.cases (by simp) (fun i => ?_) i refine Fin.cases (by simp) (fun j => ?_) j simp [pow_succ'] #align matrix.vandermonde_cons Matrix.vandermonde_cons theorem vandermonde_succ {n : ℕ} (v : Fin n.succ → R) : vandermonde v = Fin.cons (fun (j : Fin n.succ) => v 0 ^ (j : ℕ)) fun i => Fin.cons 1 fun j => v i.succ * vandermonde (Fin.tail v) i j := by conv_lhs => rw [← Fin.cons_self_tail v, vandermonde_cons] rfl #align matrix.vandermonde_succ Matrix.vandermonde_succ theorem vandermonde_mul_vandermonde_transpose {n : ℕ} (v w : Fin n → R) (i j) : (vandermonde v * (vandermonde w)ᵀ) i j = ∑ k : Fin n, (v i * w j) ^ (k : ℕ) := by simp only [vandermonde_apply, Matrix.mul_apply, Matrix.transpose_apply, mul_pow] #align matrix.vandermonde_mul_vandermonde_transpose Matrix.vandermonde_mul_vandermonde_transpose theorem vandermonde_transpose_mul_vandermonde {n : ℕ} (v : Fin n → R) (i j) : ((vandermonde v)ᵀ * vandermonde v) i j = ∑ k : Fin n, v k ^ (i + j : ℕ) := by simp only [vandermonde_apply, Matrix.mul_apply, Matrix.transpose_apply, pow_add] #align matrix.vandermonde_transpose_mul_vandermonde Matrix.vandermonde_transpose_mul_vandermonde
Mathlib/LinearAlgebra/Vandermonde.lean
77
139
theorem det_vandermonde {n : ℕ} (v : Fin n → R) : det (vandermonde v) = ∏ i : Fin n, ∏ j ∈ Ioi i, (v j - v i) := by
unfold vandermonde induction' n with n ih · exact det_eq_one_of_card_eq_zero (Fintype.card_fin 0) calc det (of fun i j : Fin n.succ => v i ^ (j : ℕ)) = det (of fun i j : Fin n.succ => Matrix.vecCons (v 0 ^ (j : ℕ)) (fun i => v (Fin.succ i) ^ (j : ℕ) - v 0 ^ (j : ℕ)) i) := det_eq_of_forall_row_eq_smul_add_const (Matrix.vecCons 0 1) 0 (Fin.cons_zero _ _) ?_ _ = det (of fun i j : Fin n => Matrix.vecCons (v 0 ^ (j.succ : ℕ)) (fun i : Fin n => v (Fin.succ i) ^ (j.succ : ℕ) - v 0 ^ (j.succ : ℕ)) (Fin.succAbove 0 i)) := by simp_rw [det_succ_column_zero, Fin.sum_univ_succ, of_apply, Matrix.cons_val_zero, submatrix, of_apply, Matrix.cons_val_succ, Fin.val_zero, pow_zero, one_mul, sub_self, mul_zero, zero_mul, Finset.sum_const_zero, add_zero] _ = det (of fun i j : Fin n => (v (Fin.succ i) - v 0) * ∑ k ∈ Finset.range (j + 1 : ℕ), v i.succ ^ k * v 0 ^ (j - k : ℕ) : Matrix _ _ R) := by congr ext i j rw [Fin.succAbove_zero, Matrix.cons_val_succ, Fin.val_succ, mul_comm] exact (geom_sum₂_mul (v i.succ) (v 0) (j + 1 : ℕ)).symm _ = (∏ i ∈ Finset.univ, (v (Fin.succ i) - v 0)) * det fun i j : Fin n => ∑ k ∈ Finset.range (j + 1 : ℕ), v i.succ ^ k * v 0 ^ (j - k : ℕ) := (det_mul_column (fun i => v (Fin.succ i) - v 0) _) _ = (∏ i ∈ Finset.univ, (v (Fin.succ i) - v 0)) * det fun i j : Fin n => v (Fin.succ i) ^ (j : ℕ) := congr_arg _ ?_ _ = ∏ i : Fin n.succ, ∏ j ∈ Ioi i, (v j - v i) := by simp_rw [Fin.prod_univ_succ, Fin.prod_Ioi_zero, Fin.prod_Ioi_succ] have h := ih (v ∘ Fin.succ) unfold Function.comp at h rw [h] · intro i j simp_rw [of_apply] rw [Matrix.cons_val_zero] refine Fin.cases ?_ (fun i => ?_) i · simp rw [Matrix.cons_val_succ, Matrix.cons_val_succ, Pi.one_apply] ring · cases n · rw [det_eq_one_of_card_eq_zero (Fintype.card_fin 0), det_eq_one_of_card_eq_zero (Fintype.card_fin 0)] apply det_eq_of_forall_col_eq_smul_add_pred fun _ => v 0 · intro j simp · intro i j simp only [smul_eq_mul, Pi.add_apply, Fin.val_succ, Fin.coe_castSucc, Pi.smul_apply] rw [Finset.sum_range_succ, add_comm, tsub_self, pow_zero, mul_one, Finset.mul_sum] congr 1 refine Finset.sum_congr rfl fun i' hi' => ?_ rw [mul_left_comm (v 0), Nat.succ_sub, pow_succ'] exact Nat.lt_succ_iff.mp (Finset.mem_range.mp hi')
import Mathlib.Logic.Relation import Mathlib.Order.GaloisConnection #align_import data.setoid.basic from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821" variable {α : Type*} {β : Type*} def Setoid.Rel (r : Setoid α) : α → α → Prop := @Setoid.r _ r #align setoid.rel Setoid.Rel instance Setoid.decidableRel (r : Setoid α) [h : DecidableRel r.r] : DecidableRel r.Rel := h #align setoid.decidable_rel Setoid.decidableRel theorem Quotient.eq_rel {r : Setoid α} {x y} : (Quotient.mk' x : Quotient r) = Quotient.mk' y ↔ r.Rel x y := Quotient.eq #align quotient.eq_rel Quotient.eq_rel namespace Setoid @[ext] theorem ext' {r s : Setoid α} (H : ∀ a b, r.Rel a b ↔ s.Rel a b) : r = s := ext H #align setoid.ext' Setoid.ext' theorem ext_iff {r s : Setoid α} : r = s ↔ ∀ a b, r.Rel a b ↔ s.Rel a b := ⟨fun h _ _ => h ▸ Iff.rfl, ext'⟩ #align setoid.ext_iff Setoid.ext_iff theorem eq_iff_rel_eq {r₁ r₂ : Setoid α} : r₁ = r₂ ↔ r₁.Rel = r₂.Rel := ⟨fun h => h ▸ rfl, fun h => Setoid.ext' fun _ _ => h ▸ Iff.rfl⟩ #align setoid.eq_iff_rel_eq Setoid.eq_iff_rel_eq instance : LE (Setoid α) := ⟨fun r s => ∀ ⦃x y⦄, r.Rel x y → s.Rel x y⟩ theorem le_def {r s : Setoid α} : r ≤ s ↔ ∀ {x y}, r.Rel x y → s.Rel x y := Iff.rfl #align setoid.le_def Setoid.le_def @[refl] theorem refl' (r : Setoid α) (x) : r.Rel x x := r.iseqv.refl x #align setoid.refl' Setoid.refl' @[symm] theorem symm' (r : Setoid α) : ∀ {x y}, r.Rel x y → r.Rel y x := r.iseqv.symm #align setoid.symm' Setoid.symm' @[trans] theorem trans' (r : Setoid α) : ∀ {x y z}, r.Rel x y → r.Rel y z → r.Rel x z := r.iseqv.trans #align setoid.trans' Setoid.trans' theorem comm' (s : Setoid α) {x y} : s.Rel x y ↔ s.Rel y x := ⟨s.symm', s.symm'⟩ #align setoid.comm' Setoid.comm' def ker (f : α → β) : Setoid α := ⟨(· = ·) on f, eq_equivalence.comap f⟩ #align setoid.ker Setoid.ker @[simp] theorem ker_mk_eq (r : Setoid α) : ker (@Quotient.mk'' _ r) = r := ext' fun _ _ => Quotient.eq #align setoid.ker_mk_eq Setoid.ker_mk_eq theorem ker_apply_mk_out {f : α → β} (a : α) : f (haveI := Setoid.ker f; ⟦a⟧.out) = f a := @Quotient.mk_out _ (Setoid.ker f) a #align setoid.ker_apply_mk_out Setoid.ker_apply_mk_out theorem ker_apply_mk_out' {f : α → β} (a : α) : f (Quotient.mk _ a : Quotient <| Setoid.ker f).out' = f a := @Quotient.mk_out' _ (Setoid.ker f) a #align setoid.ker_apply_mk_out' Setoid.ker_apply_mk_out' theorem ker_def {f : α → β} {x y : α} : (ker f).Rel x y ↔ f x = f y := Iff.rfl #align setoid.ker_def Setoid.ker_def protected def prod (r : Setoid α) (s : Setoid β) : Setoid (α × β) where r x y := r.Rel x.1 y.1 ∧ s.Rel x.2 y.2 iseqv := ⟨fun x => ⟨r.refl' x.1, s.refl' x.2⟩, fun h => ⟨r.symm' h.1, s.symm' h.2⟩, fun h₁ h₂ => ⟨r.trans' h₁.1 h₂.1, s.trans' h₁.2 h₂.2⟩⟩ #align setoid.prod Setoid.prod instance : Inf (Setoid α) := ⟨fun r s => ⟨fun x y => r.Rel x y ∧ s.Rel x y, ⟨fun x => ⟨r.refl' x, s.refl' x⟩, fun h => ⟨r.symm' h.1, s.symm' h.2⟩, fun h1 h2 => ⟨r.trans' h1.1 h2.1, s.trans' h1.2 h2.2⟩⟩⟩⟩ theorem inf_def {r s : Setoid α} : (r ⊓ s).Rel = r.Rel ⊓ s.Rel := rfl #align setoid.inf_def Setoid.inf_def theorem inf_iff_and {r s : Setoid α} {x y} : (r ⊓ s).Rel x y ↔ r.Rel x y ∧ s.Rel x y := Iff.rfl #align setoid.inf_iff_and Setoid.inf_iff_and instance : InfSet (Setoid α) := ⟨fun S => { r := fun x y => ∀ r ∈ S, r.Rel x y iseqv := ⟨fun x r _ => r.refl' x, fun h r hr => r.symm' <| h r hr, fun h1 h2 r hr => r.trans' (h1 r hr) <| h2 r hr⟩ }⟩
Mathlib/Data/Setoid/Basic.lean
155
158
theorem sInf_def {s : Set (Setoid α)} : (sInf s).Rel = sInf (Rel '' s) := by
ext simp only [sInf_image, iInf_apply, iInf_Prop_eq] rfl
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 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 #align set.le_chain_height_tfae Set.le_chainHeight_TFAE variable {s t} theorem le_chainHeight_iff {n : ℕ} : ↑n ≤ s.chainHeight ↔ ∃ l ∈ s.subchain, length l = n := (le_chainHeight_TFAE s n).out 0 1 #align set.le_chain_height_iff Set.le_chainHeight_iff theorem length_le_chainHeight_of_mem_subchain (hl : l ∈ s.subchain) : ↑l.length ≤ s.chainHeight := le_chainHeight_iff.mpr ⟨l, hl, rfl⟩ #align set.length_le_chain_height_of_mem_subchain Set.length_le_chainHeight_of_mem_subchain theorem chainHeight_eq_top_iff : s.chainHeight = ⊤ ↔ ∀ n, ∃ l ∈ s.subchain, length l = n := by refine ⟨fun h n ↦ le_chainHeight_iff.1 (le_top.trans_eq h.symm), fun h ↦ ?_⟩ contrapose! h; obtain ⟨n, hn⟩ := WithTop.ne_top_iff_exists.1 h exact ⟨n + 1, fun l hs ↦ (Nat.lt_succ_iff.2 <| Nat.cast_le.1 <| (length_le_chainHeight_of_mem_subchain hs).trans_eq hn.symm).ne⟩ #align set.chain_height_eq_top_iff Set.chainHeight_eq_top_iff @[simp] theorem one_le_chainHeight_iff : 1 ≤ s.chainHeight ↔ s.Nonempty := by rw [← Nat.cast_one, Set.le_chainHeight_iff] simp only [length_eq_one, @and_comm (_ ∈ _), @eq_comm _ _ [_], exists_exists_eq_and, singleton_mem_subchain_iff, Set.Nonempty] #align set.one_le_chain_height_iff Set.one_le_chainHeight_iff @[simp] theorem chainHeight_eq_zero_iff : s.chainHeight = 0 ↔ s = ∅ := by rw [← not_iff_not, ← Ne, ← ENat.one_le_iff_ne_zero, one_le_chainHeight_iff, nonempty_iff_ne_empty] #align set.chain_height_eq_zero_iff Set.chainHeight_eq_zero_iff @[simp] theorem chainHeight_empty : (∅ : Set α).chainHeight = 0 := chainHeight_eq_zero_iff.2 rfl #align set.chain_height_empty Set.chainHeight_empty @[simp] theorem chainHeight_of_isEmpty [IsEmpty α] : s.chainHeight = 0 := chainHeight_eq_zero_iff.mpr (Subsingleton.elim _ _) #align set.chain_height_of_is_empty Set.chainHeight_of_isEmpty theorem le_chainHeight_add_nat_iff {n m : ℕ} : ↑n ≤ s.chainHeight + m ↔ ∃ l ∈ s.subchain, n ≤ length l + m := by simp_rw [← tsub_le_iff_right, ← ENat.coe_sub, (le_chainHeight_TFAE s (n - m)).out 0 2] #align set.le_chain_height_add_nat_iff Set.le_chainHeight_add_nat_iff theorem chainHeight_add_le_chainHeight_add (s : Set α) (t : Set β) (n m : ℕ) : s.chainHeight + n ≤ t.chainHeight + m ↔ ∀ l ∈ s.subchain, ∃ l' ∈ t.subchain, length l + n ≤ length l' + m := by refine ⟨fun e l h ↦ le_chainHeight_add_nat_iff.1 ((add_le_add_right (length_le_chainHeight_of_mem_subchain h) _).trans e), fun H ↦ ?_⟩ by_cases h : s.chainHeight = ⊤ · suffices t.chainHeight = ⊤ by rw [this, top_add] exact le_top rw [chainHeight_eq_top_iff] at h ⊢ intro k have := (le_chainHeight_TFAE t k).out 1 2 rw [this] obtain ⟨l, hs, hl⟩ := h (k + m) obtain ⟨l', ht, hl'⟩ := H l hs exact ⟨l', ht, (add_le_add_iff_right m).1 <| _root_.trans (hl.symm.trans_le le_self_add) hl'⟩ · obtain ⟨k, hk⟩ := WithTop.ne_top_iff_exists.1 h obtain ⟨l, hs, hl⟩ := le_chainHeight_iff.1 hk.le rw [← hk, ← hl] exact le_chainHeight_add_nat_iff.2 (H l hs) #align set.chain_height_add_le_chain_height_add Set.chainHeight_add_le_chainHeight_add theorem chainHeight_le_chainHeight_TFAE (s : Set α) (t : Set β) : TFAE [s.chainHeight ≤ t.chainHeight, ∀ l ∈ s.subchain, ∃ l' ∈ t.subchain, length l = length l', ∀ l ∈ s.subchain, ∃ l' ∈ t.subchain, length l ≤ length l'] := by tfae_have 1 ↔ 3 · convert ← chainHeight_add_le_chainHeight_add s t 0 0 <;> apply add_zero tfae_have 2 ↔ 3 · refine forall₂_congr fun l hl ↦ ?_ simp_rw [← (le_chainHeight_TFAE t l.length).out 1 2, eq_comm] tfae_finish #align set.chain_height_le_chain_height_tfae Set.chainHeight_le_chainHeight_TFAE theorem chainHeight_le_chainHeight_iff {t : Set β} : s.chainHeight ≤ t.chainHeight ↔ ∀ l ∈ s.subchain, ∃ l' ∈ t.subchain, length l = length l' := (chainHeight_le_chainHeight_TFAE s t).out 0 1 #align set.chain_height_le_chain_height_iff Set.chainHeight_le_chainHeight_iff theorem chainHeight_le_chainHeight_iff_le {t : Set β} : s.chainHeight ≤ t.chainHeight ↔ ∀ l ∈ s.subchain, ∃ l' ∈ t.subchain, length l ≤ length l' := (chainHeight_le_chainHeight_TFAE s t).out 0 2 #align set.chain_height_le_chain_height_iff_le Set.chainHeight_le_chainHeight_iff_le theorem chainHeight_mono (h : s ⊆ t) : s.chainHeight ≤ t.chainHeight := chainHeight_le_chainHeight_iff.2 fun l hl ↦ ⟨l, ⟨hl.1, fun i hi ↦ h <| hl.2 i hi⟩, rfl⟩ #align set.chain_height_mono Set.chainHeight_mono
Mathlib/Order/Height.lean
212
237
theorem chainHeight_image (f : α → β) (hf : ∀ {x y}, x < y ↔ f x < f y) (s : Set α) : (f '' s).chainHeight = s.chainHeight := by
apply le_antisymm <;> rw [chainHeight_le_chainHeight_iff] · suffices ∀ l ∈ (f '' s).subchain, ∃ l' ∈ s.subchain, map f l' = l by intro l hl obtain ⟨l', h₁, rfl⟩ := this l hl exact ⟨l', h₁, length_map _ _⟩ intro l induction' l with x xs hx · exact fun _ ↦ ⟨nil, ⟨trivial, fun x h ↦ (not_mem_nil x h).elim⟩, rfl⟩ · intro h rw [cons_mem_subchain_iff] at h obtain ⟨⟨x, hx', rfl⟩, h₁, h₂⟩ := h obtain ⟨l', h₃, rfl⟩ := hx h₁ refine ⟨x::l', Set.cons_mem_subchain_iff.mpr ⟨hx', h₃, ?_⟩, rfl⟩ cases l' · simp · simpa [← hf] using h₂ · intro l hl refine ⟨l.map f, ⟨?_, ?_⟩, ?_⟩ · simp_rw [chain'_map, ← hf] exact hl.1 · intro _ e obtain ⟨a, ha, rfl⟩ := mem_map.mp e exact Set.mem_image_of_mem _ (hl.2 _ ha) · rw [length_map]
import Mathlib.MeasureTheory.OuterMeasure.OfFunction import Mathlib.MeasureTheory.PiSystem #align_import measure_theory.measure.outer_measure from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55" noncomputable section open Set Function Filter open scoped Classical NNReal Topology ENNReal namespace MeasureTheory namespace OuterMeasure section CaratheodoryMeasurable universe u variable {α : Type u} (m : OuterMeasure α) attribute [local simp] Set.inter_comm Set.inter_left_comm Set.inter_assoc variable {s s₁ s₂ : Set α} def IsCaratheodory (s : Set α) : Prop := ∀ t, m t = m (t ∩ s) + m (t \ s) #align measure_theory.outer_measure.is_caratheodory MeasureTheory.OuterMeasure.IsCaratheodory theorem isCaratheodory_iff_le' {s : Set α} : IsCaratheodory m s ↔ ∀ t, m (t ∩ s) + m (t \ s) ≤ m t := forall_congr' fun _ => le_antisymm_iff.trans <| and_iff_right <| measure_le_inter_add_diff _ _ _ #align measure_theory.outer_measure.is_caratheodory_iff_le' MeasureTheory.OuterMeasure.isCaratheodory_iff_le' @[simp] theorem isCaratheodory_empty : IsCaratheodory m ∅ := by simp [IsCaratheodory, m.empty, diff_empty] #align measure_theory.outer_measure.is_caratheodory_empty MeasureTheory.OuterMeasure.isCaratheodory_empty theorem isCaratheodory_compl : IsCaratheodory m s₁ → IsCaratheodory m s₁ᶜ := by simp [IsCaratheodory, diff_eq, add_comm] #align measure_theory.outer_measure.is_caratheodory_compl MeasureTheory.OuterMeasure.isCaratheodory_compl @[simp] theorem isCaratheodory_compl_iff : IsCaratheodory m sᶜ ↔ IsCaratheodory m s := ⟨fun h => by simpa using isCaratheodory_compl m h, isCaratheodory_compl m⟩ #align measure_theory.outer_measure.is_caratheodory_compl_iff MeasureTheory.OuterMeasure.isCaratheodory_compl_iff theorem isCaratheodory_union (h₁ : IsCaratheodory m s₁) (h₂ : IsCaratheodory m s₂) : IsCaratheodory m (s₁ ∪ s₂) := fun t => by rw [h₁ t, h₂ (t ∩ s₁), h₂ (t \ s₁), h₁ (t ∩ (s₁ ∪ s₂)), inter_diff_assoc _ _ s₁, Set.inter_assoc _ _ s₁, inter_eq_self_of_subset_right Set.subset_union_left, union_diff_left, h₂ (t ∩ s₁)] simp [diff_eq, add_assoc] #align measure_theory.outer_measure.is_caratheodory_union MeasureTheory.OuterMeasure.isCaratheodory_union theorem measure_inter_union (h : s₁ ∩ s₂ ⊆ ∅) (h₁ : IsCaratheodory m s₁) {t : Set α} : m (t ∩ (s₁ ∪ s₂)) = m (t ∩ s₁) + m (t ∩ s₂) := by rw [h₁, Set.inter_assoc, Set.union_inter_cancel_left, inter_diff_assoc, union_diff_cancel_left h] #align measure_theory.outer_measure.measure_inter_union MeasureTheory.OuterMeasure.measure_inter_union theorem isCaratheodory_iUnion_lt {s : ℕ → Set α} : ∀ {n : ℕ}, (∀ i < n, IsCaratheodory m (s i)) → IsCaratheodory m (⋃ i < n, s i) | 0, _ => by simp [Nat.not_lt_zero] | n + 1, h => by rw [biUnion_lt_succ] exact isCaratheodory_union m (isCaratheodory_iUnion_lt fun i hi => h i <| lt_of_lt_of_le hi <| Nat.le_succ _) (h n (le_refl (n + 1))) #align measure_theory.outer_measure.is_caratheodory_Union_lt MeasureTheory.OuterMeasure.isCaratheodory_iUnion_lt theorem isCaratheodory_inter (h₁ : IsCaratheodory m s₁) (h₂ : IsCaratheodory m s₂) : IsCaratheodory m (s₁ ∩ s₂) := by rw [← isCaratheodory_compl_iff, Set.compl_inter] exact isCaratheodory_union _ (isCaratheodory_compl _ h₁) (isCaratheodory_compl _ h₂) #align measure_theory.outer_measure.is_caratheodory_inter MeasureTheory.OuterMeasure.isCaratheodory_inter theorem isCaratheodory_sum {s : ℕ → Set α} (h : ∀ i, IsCaratheodory m (s i)) (hd : Pairwise (Disjoint on s)) {t : Set α} : ∀ {n}, (∑ i ∈ Finset.range n, m (t ∩ s i)) = m (t ∩ ⋃ i < n, s i) | 0 => by simp [Nat.not_lt_zero, m.empty] | Nat.succ n => by rw [biUnion_lt_succ, Finset.sum_range_succ, Set.union_comm, isCaratheodory_sum h hd, m.measure_inter_union _ (h n), add_comm] intro a simpa using fun (h₁ : a ∈ s n) i (hi : i < n) h₂ => (hd (ne_of_gt hi)).le_bot ⟨h₁, h₂⟩ #align measure_theory.outer_measure.is_caratheodory_sum MeasureTheory.OuterMeasure.isCaratheodory_sum set_option linter.deprecated false in -- not immediately obvious how to replace `iUnion` here.
Mathlib/MeasureTheory/OuterMeasure/Caratheodory.lean
115
128
theorem isCaratheodory_iUnion_nat {s : ℕ → Set α} (h : ∀ i, IsCaratheodory m (s i)) (hd : Pairwise (Disjoint on s)) : IsCaratheodory m (⋃ i, s i) := by
apply (isCaratheodory_iff_le' m).mpr intro t have hp : m (t ∩ ⋃ i, s i) ≤ ⨆ n, m (t ∩ ⋃ i < n, s i) := by convert m.iUnion fun i => t ∩ s i using 1 · simp [inter_iUnion] · simp [ENNReal.tsum_eq_iSup_nat, isCaratheodory_sum m h hd] refine le_trans (add_le_add_right hp _) ?_ rw [ENNReal.iSup_add] refine iSup_le fun n => le_trans (add_le_add_left ?_ _) (ge_of_eq (isCaratheodory_iUnion_lt m (fun i _ => h i) _)) refine m.mono (diff_subset_diff_right ?_) exact iUnion₂_subset fun i _ => subset_iUnion _ i
import Mathlib.Algebra.ContinuedFractions.Computation.Approximations import Mathlib.Algebra.ContinuedFractions.Computation.CorrectnessTerminating import Mathlib.Data.Rat.Floor #align_import algebra.continued_fractions.computation.terminates_iff_rat from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" namespace GeneralizedContinuedFraction open GeneralizedContinuedFraction (of) variable {K : Type*} [LinearOrderedField K] [FloorRing K] attribute [local simp] Pair.map IntFractPair.mapFr section RatTranslation -- The lifting works for arbitrary linear ordered fields with a floor function. variable {v : K} {q : ℚ} (v_eq_q : v = (↑q : K)) (n : ℕ) section TerminatesOfRat namespace IntFractPair variable {q : ℚ} {n : ℕ} theorem of_inv_fr_num_lt_num_of_pos (q_pos : 0 < q) : (IntFractPair.of q⁻¹).fr.num < q.num := Rat.fract_inv_num_lt_num_of_pos q_pos #align generalized_continued_fraction.int_fract_pair.of_inv_fr_num_lt_num_of_pos GeneralizedContinuedFraction.IntFractPair.of_inv_fr_num_lt_num_of_pos theorem stream_succ_nth_fr_num_lt_nth_fr_num_rat {ifp_n ifp_succ_n : IntFractPair ℚ} (stream_nth_eq : IntFractPair.stream q n = some ifp_n) (stream_succ_nth_eq : IntFractPair.stream q (n + 1) = some ifp_succ_n) : ifp_succ_n.fr.num < ifp_n.fr.num := by obtain ⟨ifp_n', stream_nth_eq', ifp_n_fract_ne_zero, IntFractPair.of_eq_ifp_succ_n⟩ : ∃ ifp_n', IntFractPair.stream q n = some ifp_n' ∧ ifp_n'.fr ≠ 0 ∧ IntFractPair.of ifp_n'.fr⁻¹ = ifp_succ_n := succ_nth_stream_eq_some_iff.mp stream_succ_nth_eq have : ifp_n = ifp_n' := by injection Eq.trans stream_nth_eq.symm stream_nth_eq' cases this rw [← IntFractPair.of_eq_ifp_succ_n] cases' nth_stream_fr_nonneg_lt_one stream_nth_eq with zero_le_ifp_n_fract ifp_n_fract_lt_one have : 0 < ifp_n.fr := lt_of_le_of_ne zero_le_ifp_n_fract <| ifp_n_fract_ne_zero.symm exact of_inv_fr_num_lt_num_of_pos this #align generalized_continued_fraction.int_fract_pair.stream_succ_nth_fr_num_lt_nth_fr_num_rat GeneralizedContinuedFraction.IntFractPair.stream_succ_nth_fr_num_lt_nth_fr_num_rat
Mathlib/Algebra/ContinuedFractions/Computation/TerminatesIffRat.lean
295
312
theorem stream_nth_fr_num_le_fr_num_sub_n_rat : ∀ {ifp_n : IntFractPair ℚ}, IntFractPair.stream q n = some ifp_n → ifp_n.fr.num ≤ (IntFractPair.of q).fr.num - n := by
induction n with | zero => intro ifp_zero stream_zero_eq have : IntFractPair.of q = ifp_zero := by injection stream_zero_eq simp [le_refl, this.symm] | succ n IH => intro ifp_succ_n stream_succ_nth_eq suffices ifp_succ_n.fr.num + 1 ≤ (IntFractPair.of q).fr.num - n by rw [Int.ofNat_succ, sub_add_eq_sub_sub] solve_by_elim [le_sub_right_of_add_le] rcases succ_nth_stream_eq_some_iff.mp stream_succ_nth_eq with ⟨ifp_n, stream_nth_eq, -⟩ have : ifp_succ_n.fr.num < ifp_n.fr.num := stream_succ_nth_fr_num_lt_nth_fr_num_rat stream_nth_eq stream_succ_nth_eq have : ifp_succ_n.fr.num + 1 ≤ ifp_n.fr.num := Int.add_one_le_of_lt this exact le_trans this (IH stream_nth_eq)
import Mathlib.MeasureTheory.Measure.NullMeasurable import Mathlib.MeasureTheory.MeasurableSpace.Basic import Mathlib.Topology.Algebra.Order.LiminfLimsup #align_import measure_theory.measure.measure_space from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55" noncomputable section open Set open Filter hiding map open Function MeasurableSpace open scoped Classical symmDiff open Topology Filter ENNReal NNReal Interval MeasureTheory variable {α β γ δ ι R R' : Type*} namespace MeasureTheory section variable {m : MeasurableSpace α} {μ μ₁ μ₂ : Measure α} {s s₁ s₂ t : Set α} instance ae_isMeasurablyGenerated : IsMeasurablyGenerated (ae μ) := ⟨fun _s hs => let ⟨t, hst, htm, htμ⟩ := exists_measurable_superset_of_null hs ⟨tᶜ, compl_mem_ae_iff.2 htμ, htm.compl, compl_subset_comm.1 hst⟩⟩ #align measure_theory.ae_is_measurably_generated MeasureTheory.ae_isMeasurablyGenerated theorem ae_uIoc_iff [LinearOrder α] {a b : α} {P : α → Prop} : (∀ᵐ x ∂μ, x ∈ Ι a b → P x) ↔ (∀ᵐ x ∂μ, x ∈ Ioc a b → P x) ∧ ∀ᵐ x ∂μ, x ∈ Ioc b a → P x := by simp only [uIoc_eq_union, mem_union, or_imp, eventually_and] #align measure_theory.ae_uIoc_iff MeasureTheory.ae_uIoc_iff theorem measure_union (hd : Disjoint s₁ s₂) (h : MeasurableSet s₂) : μ (s₁ ∪ s₂) = μ s₁ + μ s₂ := measure_union₀ h.nullMeasurableSet hd.aedisjoint #align measure_theory.measure_union MeasureTheory.measure_union theorem measure_union' (hd : Disjoint s₁ s₂) (h : MeasurableSet s₁) : μ (s₁ ∪ s₂) = μ s₁ + μ s₂ := measure_union₀' h.nullMeasurableSet hd.aedisjoint #align measure_theory.measure_union' MeasureTheory.measure_union' theorem measure_inter_add_diff (s : Set α) (ht : MeasurableSet t) : μ (s ∩ t) + μ (s \ t) = μ s := measure_inter_add_diff₀ _ ht.nullMeasurableSet #align measure_theory.measure_inter_add_diff MeasureTheory.measure_inter_add_diff theorem measure_diff_add_inter (s : Set α) (ht : MeasurableSet t) : μ (s \ t) + μ (s ∩ t) = μ s := (add_comm _ _).trans (measure_inter_add_diff s ht) #align measure_theory.measure_diff_add_inter MeasureTheory.measure_diff_add_inter theorem measure_union_add_inter (s : Set α) (ht : MeasurableSet t) : μ (s ∪ t) + μ (s ∩ t) = μ s + μ t := by rw [← measure_inter_add_diff (s ∪ t) ht, Set.union_inter_cancel_right, union_diff_right, ← measure_inter_add_diff s ht] ac_rfl #align measure_theory.measure_union_add_inter MeasureTheory.measure_union_add_inter theorem measure_union_add_inter' (hs : MeasurableSet s) (t : Set α) : μ (s ∪ t) + μ (s ∩ t) = μ s + μ t := by rw [union_comm, inter_comm, measure_union_add_inter t hs, add_comm] #align measure_theory.measure_union_add_inter' MeasureTheory.measure_union_add_inter' lemma measure_symmDiff_eq (hs : MeasurableSet s) (ht : MeasurableSet t) : μ (s ∆ t) = μ (s \ t) + μ (t \ s) := by simpa only [symmDiff_def, sup_eq_union] using measure_union disjoint_sdiff_sdiff (ht.diff hs) lemma measure_symmDiff_le (s t u : Set α) : μ (s ∆ u) ≤ μ (s ∆ t) + μ (t ∆ u) := le_trans (μ.mono <| symmDiff_triangle s t u) (measure_union_le (s ∆ t) (t ∆ u)) theorem measure_add_measure_compl (h : MeasurableSet s) : μ s + μ sᶜ = μ univ := measure_add_measure_compl₀ h.nullMeasurableSet #align measure_theory.measure_add_measure_compl MeasureTheory.measure_add_measure_compl theorem measure_biUnion₀ {s : Set β} {f : β → Set α} (hs : s.Countable) (hd : s.Pairwise (AEDisjoint μ on f)) (h : ∀ b ∈ s, NullMeasurableSet (f b) μ) : μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) := by haveI := hs.toEncodable rw [biUnion_eq_iUnion] exact measure_iUnion₀ (hd.on_injective Subtype.coe_injective fun x => x.2) fun x => h x x.2 #align measure_theory.measure_bUnion₀ MeasureTheory.measure_biUnion₀ theorem measure_biUnion {s : Set β} {f : β → Set α} (hs : s.Countable) (hd : s.PairwiseDisjoint f) (h : ∀ b ∈ s, MeasurableSet (f b)) : μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) := measure_biUnion₀ hs hd.aedisjoint fun b hb => (h b hb).nullMeasurableSet #align measure_theory.measure_bUnion MeasureTheory.measure_biUnion theorem measure_sUnion₀ {S : Set (Set α)} (hs : S.Countable) (hd : S.Pairwise (AEDisjoint μ)) (h : ∀ s ∈ S, NullMeasurableSet s μ) : μ (⋃₀ S) = ∑' s : S, μ s := by rw [sUnion_eq_biUnion, measure_biUnion₀ hs hd h] #align measure_theory.measure_sUnion₀ MeasureTheory.measure_sUnion₀ theorem measure_sUnion {S : Set (Set α)} (hs : S.Countable) (hd : S.Pairwise Disjoint) (h : ∀ s ∈ S, MeasurableSet s) : μ (⋃₀ S) = ∑' s : S, μ s := by rw [sUnion_eq_biUnion, measure_biUnion hs hd h] #align measure_theory.measure_sUnion MeasureTheory.measure_sUnion theorem measure_biUnion_finset₀ {s : Finset ι} {f : ι → Set α} (hd : Set.Pairwise (↑s) (AEDisjoint μ on f)) (hm : ∀ b ∈ s, NullMeasurableSet (f b) μ) : μ (⋃ b ∈ s, f b) = ∑ p ∈ s, μ (f p) := by rw [← Finset.sum_attach, Finset.attach_eq_univ, ← tsum_fintype] exact measure_biUnion₀ s.countable_toSet hd hm #align measure_theory.measure_bUnion_finset₀ MeasureTheory.measure_biUnion_finset₀ theorem measure_biUnion_finset {s : Finset ι} {f : ι → Set α} (hd : PairwiseDisjoint (↑s) f) (hm : ∀ b ∈ s, MeasurableSet (f b)) : μ (⋃ b ∈ s, f b) = ∑ p ∈ s, μ (f p) := measure_biUnion_finset₀ hd.aedisjoint fun b hb => (hm b hb).nullMeasurableSet #align measure_theory.measure_bUnion_finset MeasureTheory.measure_biUnion_finset theorem tsum_meas_le_meas_iUnion_of_disjoint₀ {ι : Type*} [MeasurableSpace α] (μ : Measure α) {As : ι → Set α} (As_mble : ∀ i : ι, NullMeasurableSet (As i) μ) (As_disj : Pairwise (AEDisjoint μ on As)) : (∑' i, μ (As i)) ≤ μ (⋃ i, As i) := by rw [ENNReal.tsum_eq_iSup_sum, iSup_le_iff] intro s simp only [← measure_biUnion_finset₀ (fun _i _hi _j _hj hij => As_disj hij) fun i _ => As_mble i] gcongr exact iUnion_subset fun _ ↦ Subset.rfl theorem tsum_meas_le_meas_iUnion_of_disjoint {ι : Type*} [MeasurableSpace α] (μ : Measure α) {As : ι → Set α} (As_mble : ∀ i : ι, MeasurableSet (As i)) (As_disj : Pairwise (Disjoint on As)) : (∑' i, μ (As i)) ≤ μ (⋃ i, As i) := tsum_meas_le_meas_iUnion_of_disjoint₀ μ (fun i ↦ (As_mble i).nullMeasurableSet) (fun _ _ h ↦ Disjoint.aedisjoint (As_disj h)) #align measure_theory.tsum_meas_le_meas_Union_of_disjoint MeasureTheory.tsum_meas_le_meas_iUnion_of_disjoint theorem tsum_measure_preimage_singleton {s : Set β} (hs : s.Countable) {f : α → β} (hf : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y})) : (∑' b : s, μ (f ⁻¹' {↑b})) = μ (f ⁻¹' s) := by rw [← Set.biUnion_preimage_singleton, measure_biUnion hs (pairwiseDisjoint_fiber f s) hf] #align measure_theory.tsum_measure_preimage_singleton MeasureTheory.tsum_measure_preimage_singleton lemma measure_preimage_eq_zero_iff_of_countable {s : Set β} {f : α → β} (hs : s.Countable) : μ (f ⁻¹' s) = 0 ↔ ∀ x ∈ s, μ (f ⁻¹' {x}) = 0 := by rw [← biUnion_preimage_singleton, measure_biUnion_null_iff hs] theorem sum_measure_preimage_singleton (s : Finset β) {f : α → β} (hf : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y})) : (∑ b ∈ s, μ (f ⁻¹' {b})) = μ (f ⁻¹' ↑s) := by simp only [← measure_biUnion_finset (pairwiseDisjoint_fiber f s) hf, Finset.set_biUnion_preimage_singleton] #align measure_theory.sum_measure_preimage_singleton MeasureTheory.sum_measure_preimage_singleton theorem measure_diff_null' (h : μ (s₁ ∩ s₂) = 0) : μ (s₁ \ s₂) = μ s₁ := measure_congr <| diff_ae_eq_self.2 h #align measure_theory.measure_diff_null' MeasureTheory.measure_diff_null' theorem measure_add_diff (hs : MeasurableSet s) (t : Set α) : μ s + μ (t \ s) = μ (s ∪ t) := by rw [← measure_union' disjoint_sdiff_right hs, union_diff_self] #align measure_theory.measure_add_diff MeasureTheory.measure_add_diff theorem measure_diff' (s : Set α) (hm : MeasurableSet t) (h_fin : μ t ≠ ∞) : μ (s \ t) = μ (s ∪ t) - μ t := Eq.symm <| ENNReal.sub_eq_of_add_eq h_fin <| by rw [add_comm, measure_add_diff hm, union_comm] #align measure_theory.measure_diff' MeasureTheory.measure_diff' theorem measure_diff (h : s₂ ⊆ s₁) (h₂ : MeasurableSet s₂) (h_fin : μ s₂ ≠ ∞) : μ (s₁ \ s₂) = μ s₁ - μ s₂ := by rw [measure_diff' _ h₂ h_fin, union_eq_self_of_subset_right h] #align measure_theory.measure_diff MeasureTheory.measure_diff theorem le_measure_diff : μ s₁ - μ s₂ ≤ μ (s₁ \ s₂) := tsub_le_iff_left.2 <| (measure_le_inter_add_diff μ s₁ s₂).trans <| by gcongr; apply inter_subset_right #align measure_theory.le_measure_diff MeasureTheory.le_measure_diff theorem measure_eq_top_iff_of_symmDiff (hμst : μ (s ∆ t) ≠ ∞) : μ s = ∞ ↔ μ t = ∞ := by suffices h : ∀ u v, μ (u ∆ v) ≠ ∞ → μ u = ∞ → μ v = ∞ from ⟨h s t hμst, h t s (symmDiff_comm s t ▸ hμst)⟩ intro u v hμuv hμu by_contra! hμv apply hμuv rw [Set.symmDiff_def, eq_top_iff] calc ∞ = μ u - μ v := (WithTop.sub_eq_top_iff.2 ⟨hμu, hμv⟩).symm _ ≤ μ (u \ v) := le_measure_diff _ ≤ μ (u \ v ∪ v \ u) := measure_mono subset_union_left theorem measure_ne_top_iff_of_symmDiff (hμst : μ (s ∆ t) ≠ ∞) : μ s ≠ ∞ ↔ μ t ≠ ∞ := (measure_eq_top_iff_of_symmDiff hμst).ne theorem measure_diff_lt_of_lt_add (hs : MeasurableSet s) (hst : s ⊆ t) (hs' : μ s ≠ ∞) {ε : ℝ≥0∞} (h : μ t < μ s + ε) : μ (t \ s) < ε := by rw [measure_diff hst hs hs']; rw [add_comm] at h exact ENNReal.sub_lt_of_lt_add (measure_mono hst) h #align measure_theory.measure_diff_lt_of_lt_add MeasureTheory.measure_diff_lt_of_lt_add theorem measure_diff_le_iff_le_add (hs : MeasurableSet s) (hst : s ⊆ t) (hs' : μ s ≠ ∞) {ε : ℝ≥0∞} : μ (t \ s) ≤ ε ↔ μ t ≤ μ s + ε := by rw [measure_diff hst hs hs', tsub_le_iff_left] #align measure_theory.measure_diff_le_iff_le_add MeasureTheory.measure_diff_le_iff_le_add theorem measure_eq_measure_of_null_diff {s t : Set α} (hst : s ⊆ t) (h_nulldiff : μ (t \ s) = 0) : μ s = μ t := measure_congr <| EventuallyLE.antisymm (HasSubset.Subset.eventuallyLE hst) (ae_le_set.mpr h_nulldiff) #align measure_theory.measure_eq_measure_of_null_diff MeasureTheory.measure_eq_measure_of_null_diff theorem measure_eq_measure_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂) (h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₁ = μ s₂ ∧ μ s₂ = μ s₃ := by have le12 : μ s₁ ≤ μ s₂ := measure_mono h12 have le23 : μ s₂ ≤ μ s₃ := measure_mono h23 have key : μ s₃ ≤ μ s₁ := calc μ s₃ = μ (s₃ \ s₁ ∪ s₁) := by rw [diff_union_of_subset (h12.trans h23)] _ ≤ μ (s₃ \ s₁) + μ s₁ := measure_union_le _ _ _ = μ s₁ := by simp only [h_nulldiff, zero_add] exact ⟨le12.antisymm (le23.trans key), le23.antisymm (key.trans le12)⟩ #align measure_theory.measure_eq_measure_of_between_null_diff MeasureTheory.measure_eq_measure_of_between_null_diff theorem measure_eq_measure_smaller_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂) (h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₁ = μ s₂ := (measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).1 #align measure_theory.measure_eq_measure_smaller_of_between_null_diff MeasureTheory.measure_eq_measure_smaller_of_between_null_diff theorem measure_eq_measure_larger_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂) (h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₂ = μ s₃ := (measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).2 #align measure_theory.measure_eq_measure_larger_of_between_null_diff MeasureTheory.measure_eq_measure_larger_of_between_null_diff lemma measure_compl₀ (h : NullMeasurableSet s μ) (hs : μ s ≠ ∞) : μ sᶜ = μ Set.univ - μ s := by rw [← measure_add_measure_compl₀ h, ENNReal.add_sub_cancel_left hs] theorem measure_compl (h₁ : MeasurableSet s) (h_fin : μ s ≠ ∞) : μ sᶜ = μ univ - μ s := measure_compl₀ h₁.nullMeasurableSet h_fin #align measure_theory.measure_compl MeasureTheory.measure_compl lemma measure_inter_conull' (ht : μ (s \ t) = 0) : μ (s ∩ t) = μ s := by rw [← diff_compl, measure_diff_null']; rwa [← diff_eq] lemma measure_inter_conull (ht : μ tᶜ = 0) : μ (s ∩ t) = μ s := by rw [← diff_compl, measure_diff_null ht] @[simp] theorem union_ae_eq_left_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] s ↔ t ≤ᵐ[μ] s := by rw [ae_le_set] refine ⟨fun h => by simpa only [union_diff_left] using (ae_eq_set.mp h).1, fun h => eventuallyLE_antisymm_iff.mpr ⟨by rwa [ae_le_set, union_diff_left], HasSubset.Subset.eventuallyLE subset_union_left⟩⟩ #align measure_theory.union_ae_eq_left_iff_ae_subset MeasureTheory.union_ae_eq_left_iff_ae_subset @[simp] theorem union_ae_eq_right_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] t ↔ s ≤ᵐ[μ] t := by rw [union_comm, union_ae_eq_left_iff_ae_subset] #align measure_theory.union_ae_eq_right_iff_ae_subset MeasureTheory.union_ae_eq_right_iff_ae_subset theorem ae_eq_of_ae_subset_of_measure_ge (h₁ : s ≤ᵐ[μ] t) (h₂ : μ t ≤ μ s) (hsm : MeasurableSet s) (ht : μ t ≠ ∞) : s =ᵐ[μ] t := by refine eventuallyLE_antisymm_iff.mpr ⟨h₁, ae_le_set.mpr ?_⟩ replace h₂ : μ t = μ s := h₂.antisymm (measure_mono_ae h₁) replace ht : μ s ≠ ∞ := h₂ ▸ ht rw [measure_diff' t hsm ht, measure_congr (union_ae_eq_left_iff_ae_subset.mpr h₁), h₂, tsub_self] #align measure_theory.ae_eq_of_ae_subset_of_measure_ge MeasureTheory.ae_eq_of_ae_subset_of_measure_ge theorem ae_eq_of_subset_of_measure_ge (h₁ : s ⊆ t) (h₂ : μ t ≤ μ s) (hsm : MeasurableSet s) (ht : μ t ≠ ∞) : s =ᵐ[μ] t := ae_eq_of_ae_subset_of_measure_ge (HasSubset.Subset.eventuallyLE h₁) h₂ hsm ht #align measure_theory.ae_eq_of_subset_of_measure_ge MeasureTheory.ae_eq_of_subset_of_measure_ge theorem measure_iUnion_congr_of_subset [Countable β] {s : β → Set α} {t : β → Set α} (hsub : ∀ b, s b ⊆ t b) (h_le : ∀ b, μ (t b) ≤ μ (s b)) : μ (⋃ b, s b) = μ (⋃ b, t b) := by rcases Classical.em (∃ b, μ (t b) = ∞) with (⟨b, hb⟩ | htop) · calc μ (⋃ b, s b) = ∞ := top_unique (hb ▸ (h_le b).trans <| measure_mono <| subset_iUnion _ _) _ = μ (⋃ b, t b) := Eq.symm <| top_unique <| hb ▸ measure_mono (subset_iUnion _ _) push_neg at htop refine le_antisymm (measure_mono (iUnion_mono hsub)) ?_ set M := toMeasurable μ have H : ∀ b, (M (t b) ∩ M (⋃ b, s b) : Set α) =ᵐ[μ] M (t b) := by refine fun b => ae_eq_of_subset_of_measure_ge inter_subset_left ?_ ?_ ?_ · calc μ (M (t b)) = μ (t b) := measure_toMeasurable _ _ ≤ μ (s b) := h_le b _ ≤ μ (M (t b) ∩ M (⋃ b, s b)) := measure_mono <| subset_inter ((hsub b).trans <| subset_toMeasurable _ _) ((subset_iUnion _ _).trans <| subset_toMeasurable _ _) · exact (measurableSet_toMeasurable _ _).inter (measurableSet_toMeasurable _ _) · rw [measure_toMeasurable] exact htop b calc μ (⋃ b, t b) ≤ μ (⋃ b, M (t b)) := measure_mono (iUnion_mono fun b => subset_toMeasurable _ _) _ = μ (⋃ b, M (t b) ∩ M (⋃ b, s b)) := measure_congr (EventuallyEq.countable_iUnion H).symm _ ≤ μ (M (⋃ b, s b)) := measure_mono (iUnion_subset fun b => inter_subset_right) _ = μ (⋃ b, s b) := measure_toMeasurable _ #align measure_theory.measure_Union_congr_of_subset MeasureTheory.measure_iUnion_congr_of_subset theorem measure_union_congr_of_subset {t₁ t₂ : Set α} (hs : s₁ ⊆ s₂) (hsμ : μ s₂ ≤ μ s₁) (ht : t₁ ⊆ t₂) (htμ : μ t₂ ≤ μ t₁) : μ (s₁ ∪ t₁) = μ (s₂ ∪ t₂) := by rw [union_eq_iUnion, union_eq_iUnion] exact measure_iUnion_congr_of_subset (Bool.forall_bool.2 ⟨ht, hs⟩) (Bool.forall_bool.2 ⟨htμ, hsμ⟩) #align measure_theory.measure_union_congr_of_subset MeasureTheory.measure_union_congr_of_subset @[simp] theorem measure_iUnion_toMeasurable [Countable β] (s : β → Set α) : μ (⋃ b, toMeasurable μ (s b)) = μ (⋃ b, s b) := Eq.symm <| measure_iUnion_congr_of_subset (fun _b => subset_toMeasurable _ _) fun _b => (measure_toMeasurable _).le #align measure_theory.measure_Union_to_measurable MeasureTheory.measure_iUnion_toMeasurable theorem measure_biUnion_toMeasurable {I : Set β} (hc : I.Countable) (s : β → Set α) : μ (⋃ b ∈ I, toMeasurable μ (s b)) = μ (⋃ b ∈ I, s b) := by haveI := hc.toEncodable simp only [biUnion_eq_iUnion, measure_iUnion_toMeasurable] #align measure_theory.measure_bUnion_to_measurable MeasureTheory.measure_biUnion_toMeasurable @[simp] theorem measure_toMeasurable_union : μ (toMeasurable μ s ∪ t) = μ (s ∪ t) := Eq.symm <| measure_union_congr_of_subset (subset_toMeasurable _ _) (measure_toMeasurable _).le Subset.rfl le_rfl #align measure_theory.measure_to_measurable_union MeasureTheory.measure_toMeasurable_union @[simp] theorem measure_union_toMeasurable : μ (s ∪ toMeasurable μ t) = μ (s ∪ t) := Eq.symm <| measure_union_congr_of_subset Subset.rfl le_rfl (subset_toMeasurable _ _) (measure_toMeasurable _).le #align measure_theory.measure_union_to_measurable MeasureTheory.measure_union_toMeasurable theorem sum_measure_le_measure_univ {s : Finset ι} {t : ι → Set α} (h : ∀ i ∈ s, MeasurableSet (t i)) (H : Set.PairwiseDisjoint (↑s) t) : (∑ i ∈ s, μ (t i)) ≤ μ (univ : Set α) := by rw [← measure_biUnion_finset H h] exact measure_mono (subset_univ _) #align measure_theory.sum_measure_le_measure_univ MeasureTheory.sum_measure_le_measure_univ theorem tsum_measure_le_measure_univ {s : ι → Set α} (hs : ∀ i, MeasurableSet (s i)) (H : Pairwise (Disjoint on s)) : (∑' i, μ (s i)) ≤ μ (univ : Set α) := by rw [ENNReal.tsum_eq_iSup_sum] exact iSup_le fun s => sum_measure_le_measure_univ (fun i _hi => hs i) fun i _hi j _hj hij => H hij #align measure_theory.tsum_measure_le_measure_univ MeasureTheory.tsum_measure_le_measure_univ theorem exists_nonempty_inter_of_measure_univ_lt_tsum_measure {m : MeasurableSpace α} (μ : Measure α) {s : ι → Set α} (hs : ∀ i, MeasurableSet (s i)) (H : μ (univ : Set α) < ∑' i, μ (s i)) : ∃ i j, i ≠ j ∧ (s i ∩ s j).Nonempty := by contrapose! H apply tsum_measure_le_measure_univ hs intro i j hij exact disjoint_iff_inter_eq_empty.mpr (H i j hij) #align measure_theory.exists_nonempty_inter_of_measure_univ_lt_tsum_measure MeasureTheory.exists_nonempty_inter_of_measure_univ_lt_tsum_measure
Mathlib/MeasureTheory/Measure/MeasureSpace.lean
436
443
theorem exists_nonempty_inter_of_measure_univ_lt_sum_measure {m : MeasurableSpace α} (μ : Measure α) {s : Finset ι} {t : ι → Set α} (h : ∀ i ∈ s, MeasurableSet (t i)) (H : μ (univ : Set α) < ∑ i ∈ s, μ (t i)) : ∃ i ∈ s, ∃ j ∈ s, ∃ _h : i ≠ j, (t i ∩ t j).Nonempty := by
contrapose! H apply sum_measure_le_measure_univ h intro i hi j hj hij exact disjoint_iff_inter_eq_empty.mpr (H i hi j hj hij)
import Mathlib.Data.Matrix.Invertible import Mathlib.LinearAlgebra.Matrix.NonsingularInverse import Mathlib.LinearAlgebra.Matrix.PosDef #align_import linear_algebra.matrix.schur_complement from "leanprover-community/mathlib"@"a176cb1219e300e85793d44583dede42377b51af" variable {l m n α : Type*} namespace Matrix open scoped Matrix section CommRing variable [Fintype l] [Fintype m] [Fintype n] variable [DecidableEq l] [DecidableEq m] [DecidableEq n] variable [CommRing α] theorem fromBlocks_eq_of_invertible₁₁ (A : Matrix m m α) (B : Matrix m n α) (C : Matrix l m α) (D : Matrix l n α) [Invertible A] : fromBlocks A B C D = fromBlocks 1 0 (C * ⅟ A) 1 * fromBlocks A 0 0 (D - C * ⅟ A * B) * fromBlocks 1 (⅟ A * B) 0 1 := by simp only [fromBlocks_multiply, Matrix.mul_zero, Matrix.zero_mul, add_zero, zero_add, Matrix.one_mul, Matrix.mul_one, invOf_mul_self, Matrix.mul_invOf_self_assoc, Matrix.mul_invOf_mul_self_cancel, Matrix.mul_assoc, add_sub_cancel] #align matrix.from_blocks_eq_of_invertible₁₁ Matrix.fromBlocks_eq_of_invertible₁₁ theorem fromBlocks_eq_of_invertible₂₂ (A : Matrix l m α) (B : Matrix l n α) (C : Matrix n m α) (D : Matrix n n α) [Invertible D] : fromBlocks A B C D = fromBlocks 1 (B * ⅟ D) 0 1 * fromBlocks (A - B * ⅟ D * C) 0 0 D * fromBlocks 1 0 (⅟ D * C) 1 := (Matrix.reindex (Equiv.sumComm _ _) (Equiv.sumComm _ _)).injective <| by simpa [reindex_apply, Equiv.sumComm_symm, ← submatrix_mul_equiv _ _ _ (Equiv.sumComm n m), ← submatrix_mul_equiv _ _ _ (Equiv.sumComm n l), Equiv.sumComm_apply, fromBlocks_submatrix_sum_swap_sum_swap] using fromBlocks_eq_of_invertible₁₁ D C B A #align matrix.from_blocks_eq_of_invertible₂₂ Matrix.fromBlocks_eq_of_invertible₂₂ section Triangular def fromBlocksZero₂₁Invertible (A : Matrix m m α) (B : Matrix m n α) (D : Matrix n n α) [Invertible A] [Invertible D] : Invertible (fromBlocks A B 0 D) := invertibleOfLeftInverse _ (fromBlocks (⅟ A) (-(⅟ A * B * ⅟ D)) 0 (⅟ D)) <| by simp_rw [fromBlocks_multiply, Matrix.mul_zero, Matrix.zero_mul, zero_add, add_zero, Matrix.neg_mul, invOf_mul_self, Matrix.mul_invOf_mul_self_cancel, add_right_neg, fromBlocks_one] #align matrix.from_blocks_zero₂₁_invertible Matrix.fromBlocksZero₂₁Invertible def fromBlocksZero₁₂Invertible (A : Matrix m m α) (C : Matrix n m α) (D : Matrix n n α) [Invertible A] [Invertible D] : Invertible (fromBlocks A 0 C D) := invertibleOfLeftInverse _ (fromBlocks (⅟ A) 0 (-(⅟ D * C * ⅟ A)) (⅟ D)) <| by -- a symmetry argument is more work than just copying the proof simp_rw [fromBlocks_multiply, Matrix.mul_zero, Matrix.zero_mul, zero_add, add_zero, Matrix.neg_mul, invOf_mul_self, Matrix.mul_invOf_mul_self_cancel, add_left_neg, fromBlocks_one] #align matrix.from_blocks_zero₁₂_invertible Matrix.fromBlocksZero₁₂Invertible theorem invOf_fromBlocks_zero₂₁_eq (A : Matrix m m α) (B : Matrix m n α) (D : Matrix n n α) [Invertible A] [Invertible D] [Invertible (fromBlocks A B 0 D)] : ⅟ (fromBlocks A B 0 D) = fromBlocks (⅟ A) (-(⅟ A * B * ⅟ D)) 0 (⅟ D) := by letI := fromBlocksZero₂₁Invertible A B D convert (rfl : ⅟ (fromBlocks A B 0 D) = _) #align matrix.inv_of_from_blocks_zero₂₁_eq Matrix.invOf_fromBlocks_zero₂₁_eq theorem invOf_fromBlocks_zero₁₂_eq (A : Matrix m m α) (C : Matrix n m α) (D : Matrix n n α) [Invertible A] [Invertible D] [Invertible (fromBlocks A 0 C D)] : ⅟ (fromBlocks A 0 C D) = fromBlocks (⅟ A) 0 (-(⅟ D * C * ⅟ A)) (⅟ D) := by letI := fromBlocksZero₁₂Invertible A C D convert (rfl : ⅟ (fromBlocks A 0 C D) = _) #align matrix.inv_of_from_blocks_zero₁₂_eq Matrix.invOf_fromBlocks_zero₁₂_eq def invertibleOfFromBlocksZero₂₁Invertible (A : Matrix m m α) (B : Matrix m n α) (D : Matrix n n α) [Invertible (fromBlocks A B 0 D)] : Invertible A × Invertible D where fst := invertibleOfLeftInverse _ (⅟ (fromBlocks A B 0 D)).toBlocks₁₁ <| by have := invOf_mul_self (fromBlocks A B 0 D) rw [← fromBlocks_toBlocks (⅟ (fromBlocks A B 0 D)), fromBlocks_multiply] at this replace := congr_arg Matrix.toBlocks₁₁ this simpa only [Matrix.toBlocks_fromBlocks₁₁, Matrix.mul_zero, add_zero, ← fromBlocks_one] using this snd := invertibleOfRightInverse _ (⅟ (fromBlocks A B 0 D)).toBlocks₂₂ <| by have := mul_invOf_self (fromBlocks A B 0 D) rw [← fromBlocks_toBlocks (⅟ (fromBlocks A B 0 D)), fromBlocks_multiply] at this replace := congr_arg Matrix.toBlocks₂₂ this simpa only [Matrix.toBlocks_fromBlocks₂₂, Matrix.zero_mul, zero_add, ← fromBlocks_one] using this #align matrix.invertible_of_from_blocks_zero₂₁_invertible Matrix.invertibleOfFromBlocksZero₂₁Invertible def invertibleOfFromBlocksZero₁₂Invertible (A : Matrix m m α) (C : Matrix n m α) (D : Matrix n n α) [Invertible (fromBlocks A 0 C D)] : Invertible A × Invertible D where fst := invertibleOfRightInverse _ (⅟ (fromBlocks A 0 C D)).toBlocks₁₁ <| by have := mul_invOf_self (fromBlocks A 0 C D) rw [← fromBlocks_toBlocks (⅟ (fromBlocks A 0 C D)), fromBlocks_multiply] at this replace := congr_arg Matrix.toBlocks₁₁ this simpa only [Matrix.toBlocks_fromBlocks₁₁, Matrix.zero_mul, add_zero, ← fromBlocks_one] using this snd := invertibleOfLeftInverse _ (⅟ (fromBlocks A 0 C D)).toBlocks₂₂ <| by have := invOf_mul_self (fromBlocks A 0 C D) rw [← fromBlocks_toBlocks (⅟ (fromBlocks A 0 C D)), fromBlocks_multiply] at this replace := congr_arg Matrix.toBlocks₂₂ this simpa only [Matrix.toBlocks_fromBlocks₂₂, Matrix.mul_zero, zero_add, ← fromBlocks_one] using this #align matrix.invertible_of_from_blocks_zero₁₂_invertible Matrix.invertibleOfFromBlocksZero₁₂Invertible def fromBlocksZero₂₁InvertibleEquiv (A : Matrix m m α) (B : Matrix m n α) (D : Matrix n n α) : Invertible (fromBlocks A B 0 D) ≃ Invertible A × Invertible D where toFun _ := invertibleOfFromBlocksZero₂₁Invertible A B D invFun i := by letI := i.1 letI := i.2 exact fromBlocksZero₂₁Invertible A B D left_inv _ := Subsingleton.elim _ _ right_inv _ := Subsingleton.elim _ _ #align matrix.from_blocks_zero₂₁_invertible_equiv Matrix.fromBlocksZero₂₁InvertibleEquiv def fromBlocksZero₁₂InvertibleEquiv (A : Matrix m m α) (C : Matrix n m α) (D : Matrix n n α) : Invertible (fromBlocks A 0 C D) ≃ Invertible A × Invertible D where toFun _ := invertibleOfFromBlocksZero₁₂Invertible A C D invFun i := by letI := i.1 letI := i.2 exact fromBlocksZero₁₂Invertible A C D left_inv _ := Subsingleton.elim _ _ right_inv _ := Subsingleton.elim _ _ #align matrix.from_blocks_zero₁₂_invertible_equiv Matrix.fromBlocksZero₁₂InvertibleEquiv @[simp] theorem isUnit_fromBlocks_zero₂₁ {A : Matrix m m α} {B : Matrix m n α} {D : Matrix n n α} : IsUnit (fromBlocks A B 0 D) ↔ IsUnit A ∧ IsUnit D := by simp only [← nonempty_invertible_iff_isUnit, ← nonempty_prod, (fromBlocksZero₂₁InvertibleEquiv _ _ _).nonempty_congr] #align matrix.is_unit_from_blocks_zero₂₁ Matrix.isUnit_fromBlocks_zero₂₁ @[simp] theorem isUnit_fromBlocks_zero₁₂ {A : Matrix m m α} {C : Matrix n m α} {D : Matrix n n α} : IsUnit (fromBlocks A 0 C D) ↔ IsUnit A ∧ IsUnit D := by simp only [← nonempty_invertible_iff_isUnit, ← nonempty_prod, (fromBlocksZero₁₂InvertibleEquiv _ _ _).nonempty_congr] #align matrix.is_unit_from_blocks_zero₁₂ Matrix.isUnit_fromBlocks_zero₁₂ theorem inv_fromBlocks_zero₂₁_of_isUnit_iff (A : Matrix m m α) (B : Matrix m n α) (D : Matrix n n α) (hAD : IsUnit A ↔ IsUnit D) : (fromBlocks A B 0 D)⁻¹ = fromBlocks A⁻¹ (-(A⁻¹ * B * D⁻¹)) 0 D⁻¹ := by by_cases hA : IsUnit A · have hD := hAD.mp hA cases hA.nonempty_invertible cases hD.nonempty_invertible letI := fromBlocksZero₂₁Invertible A B D simp_rw [← invOf_eq_nonsing_inv, invOf_fromBlocks_zero₂₁_eq] · have hD := hAD.not.mp hA have : ¬IsUnit (fromBlocks A B 0 D) := isUnit_fromBlocks_zero₂₁.not.mpr (not_and'.mpr fun _ => hA) simp_rw [nonsing_inv_eq_ring_inverse, Ring.inverse_non_unit _ hA, Ring.inverse_non_unit _ hD, Ring.inverse_non_unit _ this, Matrix.zero_mul, neg_zero, fromBlocks_zero] #align matrix.inv_from_blocks_zero₂₁_of_is_unit_iff Matrix.inv_fromBlocks_zero₂₁_of_isUnit_iff
Mathlib/LinearAlgebra/Matrix/SchurComplement.lean
220
233
theorem inv_fromBlocks_zero₁₂_of_isUnit_iff (A : Matrix m m α) (C : Matrix n m α) (D : Matrix n n α) (hAD : IsUnit A ↔ IsUnit D) : (fromBlocks A 0 C D)⁻¹ = fromBlocks A⁻¹ 0 (-(D⁻¹ * C * A⁻¹)) D⁻¹ := by
by_cases hA : IsUnit A · have hD := hAD.mp hA cases hA.nonempty_invertible cases hD.nonempty_invertible letI := fromBlocksZero₁₂Invertible A C D simp_rw [← invOf_eq_nonsing_inv, invOf_fromBlocks_zero₁₂_eq] · have hD := hAD.not.mp hA have : ¬IsUnit (fromBlocks A 0 C D) := isUnit_fromBlocks_zero₁₂.not.mpr (not_and'.mpr fun _ => hA) simp_rw [nonsing_inv_eq_ring_inverse, Ring.inverse_non_unit _ hA, Ring.inverse_non_unit _ hD, Ring.inverse_non_unit _ this, Matrix.zero_mul, neg_zero, fromBlocks_zero]
import Mathlib.GroupTheory.QuotientGroup import Mathlib.RingTheory.DedekindDomain.Ideal #align_import ring_theory.class_group from "leanprover-community/mathlib"@"565eb991e264d0db702722b4bde52ee5173c9950" variable {R K L : Type*} [CommRing R] variable [Field K] [Field L] [DecidableEq L] variable [Algebra R K] [IsFractionRing R K] variable [Algebra K L] [FiniteDimensional K L] variable [Algebra R L] [IsScalarTower R K L] open scoped nonZeroDivisors open IsLocalization IsFractionRing FractionalIdeal Units section variable (R K) irreducible_def toPrincipalIdeal : Kˣ →* (FractionalIdeal R⁰ K)ˣ := { toFun := fun x => ⟨spanSingleton _ x, spanSingleton _ x⁻¹, by simp only [spanSingleton_one, Units.mul_inv', spanSingleton_mul_spanSingleton], by simp only [spanSingleton_one, Units.inv_mul', spanSingleton_mul_spanSingleton]⟩ map_mul' := fun x y => ext (by simp only [Units.val_mk, Units.val_mul, spanSingleton_mul_spanSingleton]) map_one' := ext (by simp only [spanSingleton_one, Units.val_mk, Units.val_one]) } #align to_principal_ideal toPrincipalIdeal variable {R K} @[simp] theorem coe_toPrincipalIdeal (x : Kˣ) : (toPrincipalIdeal R K x : FractionalIdeal R⁰ K) = spanSingleton _ (x : K) := by simp only [toPrincipalIdeal]; rfl #align coe_to_principal_ideal coe_toPrincipalIdeal @[simp] theorem toPrincipalIdeal_eq_iff {I : (FractionalIdeal R⁰ K)ˣ} {x : Kˣ} : toPrincipalIdeal R K x = I ↔ spanSingleton R⁰ (x : K) = I := by simp only [toPrincipalIdeal]; exact Units.ext_iff #align to_principal_ideal_eq_iff toPrincipalIdeal_eq_iff
Mathlib/RingTheory/ClassGroup.lean
72
79
theorem mem_principal_ideals_iff {I : (FractionalIdeal R⁰ K)ˣ} : I ∈ (toPrincipalIdeal R K).range ↔ ∃ x : K, spanSingleton R⁰ x = I := by
simp only [MonoidHom.mem_range, toPrincipalIdeal_eq_iff] constructor <;> rintro ⟨x, hx⟩ · exact ⟨x, hx⟩ · refine ⟨Units.mk0 x ?_, hx⟩ rintro rfl simp [I.ne_zero.symm] at hx
import Mathlib.Algebra.Order.Ring.Rat import Mathlib.Tactic.NormNum.Inv import Mathlib.Tactic.NormNum.Pow import Mathlib.Util.AtomM set_option autoImplicit true namespace Mathlib.Tactic namespace Ring open Mathlib.Meta Qq NormNum Lean.Meta AtomM open Lean (MetaM Expr mkRawNatLit) def instCommSemiringNat : CommSemiring ℕ := inferInstance def sℕ : Q(CommSemiring ℕ) := q(instCommSemiringNat) -- In this file, we would like to use multi-character auto-implicits. set_option relaxedAutoImplicit true mutual inductive ExBase : ∀ {α : Q(Type u)}, Q(CommSemiring $α) → (e : Q($α)) → Type | atom (id : ℕ) : ExBase sα e | sum (_ : ExSum sα e) : ExBase sα e inductive ExProd : ∀ {α : Q(Type u)}, Q(CommSemiring $α) → (e : Q($α)) → Type | const (value : ℚ) (hyp : Option Expr := none) : ExProd sα e | mul {α : Q(Type u)} {sα : Q(CommSemiring $α)} {x : Q($α)} {e : Q(ℕ)} {b : Q($α)} : ExBase sα x → ExProd sℕ e → ExProd sα b → ExProd sα q($x ^ $e * $b) inductive ExSum : ∀ {α : Q(Type u)}, Q(CommSemiring $α) → (e : Q($α)) → Type | zero {α : Q(Type u)} {sα : Q(CommSemiring $α)} : ExSum sα q(0 : $α) | add {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} : ExProd sα a → ExSum sα b → ExSum sα q($a + $b) end mutual -- partial only to speed up compilation partial def ExBase.eq : ExBase sα a → ExBase sα b → Bool | .atom i, .atom j => i == j | .sum a, .sum b => a.eq b | _, _ => false @[inherit_doc ExBase.eq] partial def ExProd.eq : ExProd sα a → ExProd sα b → Bool | .const i _, .const j _ => i == j | .mul a₁ a₂ a₃, .mul b₁ b₂ b₃ => a₁.eq b₁ && a₂.eq b₂ && a₃.eq b₃ | _, _ => false @[inherit_doc ExBase.eq] partial def ExSum.eq : ExSum sα a → ExSum sα b → Bool | .zero, .zero => true | .add a₁ a₂, .add b₁ b₂ => a₁.eq b₁ && a₂.eq b₂ | _, _ => false end mutual -- partial only to speed up compilation partial def ExBase.cmp : ExBase sα a → ExBase sα b → Ordering | .atom i, .atom j => compare i j | .sum a, .sum b => a.cmp b | .atom .., .sum .. => .lt | .sum .., .atom .. => .gt @[inherit_doc ExBase.cmp] partial def ExProd.cmp : ExProd sα a → ExProd sα b → Ordering | .const i _, .const j _ => compare i j | .mul a₁ a₂ a₃, .mul b₁ b₂ b₃ => (a₁.cmp b₁).then (a₂.cmp b₂) |>.then (a₃.cmp b₃) | .const _ _, .mul .. => .lt | .mul .., .const _ _ => .gt @[inherit_doc ExBase.cmp] partial def ExSum.cmp : ExSum sα a → ExSum sα b → Ordering | .zero, .zero => .eq | .add a₁ a₂, .add b₁ b₂ => (a₁.cmp b₁).then (a₂.cmp b₂) | .zero, .add .. => .lt | .add .., .zero => .gt end instance : Inhabited (Σ e, (ExBase sα) e) := ⟨default, .atom 0⟩ instance : Inhabited (Σ e, (ExSum sα) e) := ⟨_, .zero⟩ instance : Inhabited (Σ e, (ExProd sα) e) := ⟨default, .const 0 none⟩ mutual partial def ExBase.cast : ExBase sα a → Σ a, ExBase sβ a | .atom i => ⟨a, .atom i⟩ | .sum a => let ⟨_, vb⟩ := a.cast; ⟨_, .sum vb⟩ partial def ExProd.cast : ExProd sα a → Σ a, ExProd sβ a | .const i h => ⟨a, .const i h⟩ | .mul a₁ a₂ a₃ => ⟨_, .mul a₁.cast.2 a₂ a₃.cast.2⟩ partial def ExSum.cast : ExSum sα a → Σ a, ExSum sβ a | .zero => ⟨_, .zero⟩ | .add a₁ a₂ => ⟨_, .add a₁.cast.2 a₂.cast.2⟩ end structure Result {α : Q(Type u)} (E : Q($α) → Type) (e : Q($α)) where expr : Q($α) val : E expr proof : Q($e = $expr) instance [Inhabited (Σ e, E e)] : Inhabited (Result E e) := let ⟨e', v⟩ : Σ e, E e := default; ⟨e', v, default⟩ variable {α : Q(Type u)} (sα : Q(CommSemiring $α)) [CommSemiring R] def ExProd.mkNat (n : ℕ) : (e : Q($α)) × ExProd sα e := let lit : Q(ℕ) := mkRawNatLit n ⟨q(($lit).rawCast : $α), .const n none⟩ def ExProd.mkNegNat (_ : Q(Ring $α)) (n : ℕ) : (e : Q($α)) × ExProd sα e := let lit : Q(ℕ) := mkRawNatLit n ⟨q((Int.negOfNat $lit).rawCast : $α), .const (-n) none⟩ def ExProd.mkRat (_ : Q(DivisionRing $α)) (q : ℚ) (n : Q(ℤ)) (d : Q(ℕ)) (h : Expr) : (e : Q($α)) × ExProd sα e := ⟨q(Rat.rawCast $n $d : $α), .const q h⟩ section variable {sα} def ExBase.toProd (va : ExBase sα a) (vb : ExProd sℕ b) : ExProd sα q($a ^ $b * (nat_lit 1).rawCast) := .mul va vb (.const 1 none) def ExProd.toSum (v : ExProd sα e) : ExSum sα q($e + 0) := .add v .zero def ExProd.coeff : ExProd sα e → ℚ | .const q _ => q | .mul _ _ v => v.coeff end inductive Overlap (e : Q($α)) where | zero (_ : Q(IsNat $e (nat_lit 0))) | nonzero (_ : Result (ExProd sα) e) theorem add_overlap_pf (x : R) (e) (pq_pf : a + b = c) : x ^ e * a + x ^ e * b = x ^ e * c := by subst_vars; simp [mul_add] theorem add_overlap_pf_zero (x : R) (e) : IsNat (a + b) (nat_lit 0) → IsNat (x ^ e * a + x ^ e * b) (nat_lit 0) | ⟨h⟩ => ⟨by simp [h, ← mul_add]⟩ def evalAddOverlap (va : ExProd sα a) (vb : ExProd sα b) : Option (Overlap sα q($a + $b)) := match va, vb with | .const za ha, .const zb hb => do let ra := Result.ofRawRat za a ha; let rb := Result.ofRawRat zb b hb let res ← NormNum.evalAdd.core q($a + $b) q(HAdd.hAdd) a b ra rb match res with | .isNat _ (.lit (.natVal 0)) p => pure <| .zero p | rc => let ⟨zc, hc⟩ ← rc.toRatNZ let ⟨c, pc⟩ := rc.toRawEq pure <| .nonzero ⟨c, .const zc hc, pc⟩ | .mul (x := a₁) (e := a₂) va₁ va₂ va₃, .mul vb₁ vb₂ vb₃ => do guard (va₁.eq vb₁ && va₂.eq vb₂) match ← evalAddOverlap va₃ vb₃ with | .zero p => pure <| .zero (q(add_overlap_pf_zero $a₁ $a₂ $p) : Expr) | .nonzero ⟨_, vc, p⟩ => pure <| .nonzero ⟨_, .mul va₁ va₂ vc, (q(add_overlap_pf $a₁ $a₂ $p) : Expr)⟩ | _, _ => none theorem add_pf_zero_add (b : R) : 0 + b = b := by simp theorem add_pf_add_zero (a : R) : a + 0 = a := by simp theorem add_pf_add_overlap (_ : a₁ + b₁ = c₁) (_ : a₂ + b₂ = c₂) : (a₁ + a₂ : R) + (b₁ + b₂) = c₁ + c₂ := by subst_vars; simp [add_assoc, add_left_comm] theorem add_pf_add_overlap_zero (h : IsNat (a₁ + b₁) (nat_lit 0)) (h₄ : a₂ + b₂ = c) : (a₁ + a₂ : R) + (b₁ + b₂) = c := by subst_vars; rw [add_add_add_comm, h.1, Nat.cast_zero, add_pf_zero_add] theorem add_pf_add_lt (a₁ : R) (_ : a₂ + b = c) : (a₁ + a₂) + b = a₁ + c := by simp [*, add_assoc] theorem add_pf_add_gt (b₁ : R) (_ : a + b₂ = c) : a + (b₁ + b₂) = b₁ + c := by subst_vars; simp [add_left_comm] partial def evalAdd (va : ExSum sα a) (vb : ExSum sα b) : Result (ExSum sα) q($a + $b) := match va, vb with | .zero, vb => ⟨b, vb, q(add_pf_zero_add $b)⟩ | va, .zero => ⟨a, va, q(add_pf_add_zero $a)⟩ | .add (a := a₁) (b := _a₂) va₁ va₂, .add (a := b₁) (b := _b₂) vb₁ vb₂ => match evalAddOverlap sα va₁ vb₁ with | some (.nonzero ⟨_, vc₁, pc₁⟩) => let ⟨_, vc₂, pc₂⟩ := evalAdd va₂ vb₂ ⟨_, .add vc₁ vc₂, q(add_pf_add_overlap $pc₁ $pc₂)⟩ | some (.zero pc₁) => let ⟨c₂, vc₂, pc₂⟩ := evalAdd va₂ vb₂ ⟨c₂, vc₂, q(add_pf_add_overlap_zero $pc₁ $pc₂)⟩ | none => if let .lt := va₁.cmp vb₁ then let ⟨_c, vc, (pc : Q($_a₂ + ($b₁ + $_b₂) = $_c))⟩ := evalAdd va₂ vb ⟨_, .add va₁ vc, q(add_pf_add_lt $a₁ $pc)⟩ else let ⟨_c, vc, (pc : Q($a₁ + $_a₂ + $_b₂ = $_c))⟩ := evalAdd va vb₂ ⟨_, .add vb₁ vc, q(add_pf_add_gt $b₁ $pc)⟩ theorem one_mul (a : R) : (nat_lit 1).rawCast * a = a := by simp [Nat.rawCast] theorem mul_one (a : R) : a * (nat_lit 1).rawCast = a := by simp [Nat.rawCast] theorem mul_pf_left (a₁ : R) (a₂) (_ : a₃ * b = c) : (a₁ ^ a₂ * a₃ : R) * b = a₁ ^ a₂ * c := by subst_vars; rw [mul_assoc] theorem mul_pf_right (b₁ : R) (b₂) (_ : a * b₃ = c) : a * (b₁ ^ b₂ * b₃) = b₁ ^ b₂ * c := by subst_vars; rw [mul_left_comm] theorem mul_pp_pf_overlap (x : R) (_ : ea + eb = e) (_ : a₂ * b₂ = c) : (x ^ ea * a₂ : R) * (x ^ eb * b₂) = x ^ e * c := by subst_vars; simp [pow_add, mul_mul_mul_comm] partial def evalMulProd (va : ExProd sα a) (vb : ExProd sα b) : Result (ExProd sα) q($a * $b) := match va, vb with | .const za ha, .const zb hb => if za = 1 then ⟨b, .const zb hb, (q(one_mul $b) : Expr)⟩ else if zb = 1 then ⟨a, .const za ha, (q(mul_one $a) : Expr)⟩ else let ra := Result.ofRawRat za a ha; let rb := Result.ofRawRat zb b hb let rc := (NormNum.evalMul.core q($a * $b) q(HMul.hMul) _ _ q(CommSemiring.toSemiring) ra rb).get! let ⟨zc, hc⟩ := rc.toRatNZ.get! let ⟨c, pc⟩ := rc.toRawEq ⟨c, .const zc hc, pc⟩ | .mul (x := a₁) (e := a₂) va₁ va₂ va₃, .const _ _ => let ⟨_, vc, pc⟩ := evalMulProd va₃ vb ⟨_, .mul va₁ va₂ vc, (q(mul_pf_left $a₁ $a₂ $pc) : Expr)⟩ | .const _ _, .mul (x := b₁) (e := b₂) vb₁ vb₂ vb₃ => let ⟨_, vc, pc⟩ := evalMulProd va vb₃ ⟨_, .mul vb₁ vb₂ vc, (q(mul_pf_right $b₁ $b₂ $pc) : Expr)⟩ | .mul (x := xa) (e := ea) vxa vea va₂, .mul (x := xb) (e := eb) vxb veb vb₂ => Id.run do if vxa.eq vxb then if let some (.nonzero ⟨_, ve, pe⟩) := evalAddOverlap sℕ vea veb then let ⟨_, vc, pc⟩ := evalMulProd va₂ vb₂ return ⟨_, .mul vxa ve vc, (q(mul_pp_pf_overlap $xa $pe $pc) : Expr)⟩ if let .lt := (vxa.cmp vxb).then (vea.cmp veb) then let ⟨_, vc, pc⟩ := evalMulProd va₂ vb ⟨_, .mul vxa vea vc, (q(mul_pf_left $xa $ea $pc) : Expr)⟩ else let ⟨_, vc, pc⟩ := evalMulProd va vb₂ ⟨_, .mul vxb veb vc, (q(mul_pf_right $xb $eb $pc) : Expr)⟩ theorem mul_zero (a : R) : a * 0 = 0 := by simp theorem mul_add (_ : (a : R) * b₁ = c₁) (_ : a * b₂ = c₂) (_ : c₁ + 0 + c₂ = d) : a * (b₁ + b₂) = d := by subst_vars; simp [_root_.mul_add] def evalMul₁ (va : ExProd sα a) (vb : ExSum sα b) : Result (ExSum sα) q($a * $b) := match vb with | .zero => ⟨_, .zero, q(mul_zero $a)⟩ | .add vb₁ vb₂ => let ⟨_, vc₁, pc₁⟩ := evalMulProd sα va vb₁ let ⟨_, vc₂, pc₂⟩ := evalMul₁ va vb₂ let ⟨_, vd, pd⟩ := evalAdd sα vc₁.toSum vc₂ ⟨_, vd, q(mul_add $pc₁ $pc₂ $pd)⟩ theorem zero_mul (b : R) : 0 * b = 0 := by simp theorem add_mul (_ : (a₁ : R) * b = c₁) (_ : a₂ * b = c₂) (_ : c₁ + c₂ = d) : (a₁ + a₂) * b = d := by subst_vars; simp [_root_.add_mul] def evalMul (va : ExSum sα a) (vb : ExSum sα b) : Result (ExSum sα) q($a * $b) := match va with | .zero => ⟨_, .zero, q(zero_mul $b)⟩ | .add va₁ va₂ => let ⟨_, vc₁, pc₁⟩ := evalMul₁ sα va₁ vb let ⟨_, vc₂, pc₂⟩ := evalMul va₂ vb let ⟨_, vd, pd⟩ := evalAdd sα vc₁ vc₂ ⟨_, vd, q(add_mul $pc₁ $pc₂ $pd)⟩ theorem natCast_nat (n) : ((Nat.rawCast n : ℕ) : R) = Nat.rawCast n := by simp theorem natCast_mul (a₂) (_ : ((a₁ : ℕ) : R) = b₁) (_ : ((a₃ : ℕ) : R) = b₃) : ((a₁ ^ a₂ * a₃ : ℕ) : R) = b₁ ^ a₂ * b₃ := by subst_vars; simp theorem natCast_zero : ((0 : ℕ) : R) = 0 := Nat.cast_zero theorem natCast_add (_ : ((a₁ : ℕ) : R) = b₁) (_ : ((a₂ : ℕ) : R) = b₂) : ((a₁ + a₂ : ℕ) : R) = b₁ + b₂ := by subst_vars; simp mutual partial def ExBase.evalNatCast (va : ExBase sℕ a) : AtomM (Result (ExBase sα) q($a)) := match va with | .atom _ => do let a' : Q($α) := q($a) let i ← addAtom a' pure ⟨a', ExBase.atom i, (q(Eq.refl $a') : Expr)⟩ | .sum va => do let ⟨_, vc, p⟩ ← va.evalNatCast pure ⟨_, .sum vc, p⟩ partial def ExProd.evalNatCast (va : ExProd sℕ a) : AtomM (Result (ExProd sα) q($a)) := match va with | .const c hc => have n : Q(ℕ) := a.appArg! pure ⟨q(Nat.rawCast $n), .const c hc, (q(natCast_nat (R := $α) $n) : Expr)⟩ | .mul (e := a₂) va₁ va₂ va₃ => do let ⟨_, vb₁, pb₁⟩ ← va₁.evalNatCast let ⟨_, vb₃, pb₃⟩ ← va₃.evalNatCast pure ⟨_, .mul vb₁ va₂ vb₃, q(natCast_mul $a₂ $pb₁ $pb₃)⟩ partial def ExSum.evalNatCast (va : ExSum sℕ a) : AtomM (Result (ExSum sα) q($a)) := match va with | .zero => pure ⟨_, .zero, q(natCast_zero (R := $α))⟩ | .add va₁ va₂ => do let ⟨_, vb₁, pb₁⟩ ← va₁.evalNatCast let ⟨_, vb₂, pb₂⟩ ← va₂.evalNatCast pure ⟨_, .add vb₁ vb₂, q(natCast_add $pb₁ $pb₂)⟩ end theorem smul_nat (_ : (a * b : ℕ) = c) : a • b = c := by subst_vars; simp theorem smul_eq_cast (_ : ((a : ℕ) : R) = a') (_ : a' * b = c) : a • b = c := by subst_vars; simp def evalNSMul (va : ExSum sℕ a) (vb : ExSum sα b) : AtomM (Result (ExSum sα) q($a • $b)) := do if ← isDefEq sα sℕ then let ⟨_, va'⟩ := va.cast have _b : Q(ℕ) := b let ⟨(_c : Q(ℕ)), vc, (pc : Q($a * $_b = $_c))⟩ := evalMul sα va' vb pure ⟨_, vc, (q(smul_nat $pc) : Expr)⟩ else let ⟨_, va', pa'⟩ ← va.evalNatCast sα let ⟨_, vc, pc⟩ := evalMul sα va' vb pure ⟨_, vc, (q(smul_eq_cast $pa' $pc) : Expr)⟩ theorem neg_one_mul {R} [Ring R] {a b : R} (_ : (Int.negOfNat (nat_lit 1)).rawCast * a = b) : -a = b := by subst_vars; simp [Int.negOfNat] theorem neg_mul {R} [Ring R] (a₁ : R) (a₂) {a₃ b : R} (_ : -a₃ = b) : -(a₁ ^ a₂ * a₃) = a₁ ^ a₂ * b := by subst_vars; simp def evalNegProd (rα : Q(Ring $α)) (va : ExProd sα a) : Result (ExProd sα) q(-$a) := match va with | .const za ha => let lit : Q(ℕ) := mkRawNatLit 1 let ⟨m1, _⟩ := ExProd.mkNegNat sα rα 1 let rm := Result.isNegNat rα lit (q(IsInt.of_raw $α (.negOfNat $lit)) : Expr) let ra := Result.ofRawRat za a ha let rb := (NormNum.evalMul.core q($m1 * $a) q(HMul.hMul) _ _ q(CommSemiring.toSemiring) rm ra).get! let ⟨zb, hb⟩ := rb.toRatNZ.get! let ⟨b, (pb : Q((Int.negOfNat (nat_lit 1)).rawCast * $a = $b))⟩ := rb.toRawEq ⟨b, .const zb hb, (q(neg_one_mul (R := $α) $pb) : Expr)⟩ | .mul (x := a₁) (e := a₂) va₁ va₂ va₃ => let ⟨_, vb, pb⟩ := evalNegProd rα va₃ ⟨_, .mul va₁ va₂ vb, (q(neg_mul $a₁ $a₂ $pb) : Expr)⟩ theorem neg_zero {R} [Ring R] : -(0 : R) = 0 := by simp theorem neg_add {R} [Ring R] {a₁ a₂ b₁ b₂ : R} (_ : -a₁ = b₁) (_ : -a₂ = b₂) : -(a₁ + a₂) = b₁ + b₂ := by subst_vars; simp [add_comm] def evalNeg (rα : Q(Ring $α)) (va : ExSum sα a) : Result (ExSum sα) q(-$a) := match va with | .zero => ⟨_, .zero, (q(neg_zero (R := $α)) : Expr)⟩ | .add va₁ va₂ => let ⟨_, vb₁, pb₁⟩ := evalNegProd sα rα va₁ let ⟨_, vb₂, pb₂⟩ := evalNeg rα va₂ ⟨_, .add vb₁ vb₂, (q(neg_add $pb₁ $pb₂) : Expr)⟩ theorem sub_pf {R} [Ring R] {a b c d : R} (_ : -b = c) (_ : a + c = d) : a - b = d := by subst_vars; simp [sub_eq_add_neg] def evalSub (rα : Q(Ring $α)) (va : ExSum sα a) (vb : ExSum sα b) : Result (ExSum sα) q($a - $b) := let ⟨_c, vc, pc⟩ := evalNeg sα rα vb let ⟨d, vd, (pd : Q($a + $_c = $d))⟩ := evalAdd sα va vc ⟨d, vd, (q(sub_pf $pc $pd) : Expr)⟩ theorem pow_prod_atom (a : R) (b) : a ^ b = (a + 0) ^ b * (nat_lit 1).rawCast := by simp def evalPowProdAtom (va : ExProd sα a) (vb : ExProd sℕ b) : Result (ExProd sα) q($a ^ $b) := ⟨_, (ExBase.sum va.toSum).toProd vb, q(pow_prod_atom $a $b)⟩ theorem pow_atom (a : R) (b) : a ^ b = a ^ b * (nat_lit 1).rawCast + 0 := by simp def evalPowAtom (va : ExBase sα a) (vb : ExProd sℕ b) : Result (ExSum sα) q($a ^ $b) := ⟨_, (va.toProd vb).toSum, q(pow_atom $a $b)⟩ theorem const_pos (n : ℕ) (h : Nat.ble 1 n = true) : 0 < (n.rawCast : ℕ) := Nat.le_of_ble_eq_true h theorem mul_exp_pos (n) (h₁ : 0 < a₁) (h₂ : 0 < a₂) : 0 < a₁ ^ n * a₂ := Nat.mul_pos (Nat.pos_pow_of_pos _ h₁) h₂ theorem add_pos_left (a₂) (h : 0 < a₁) : 0 < a₁ + a₂ := Nat.lt_of_lt_of_le h (Nat.le_add_right ..) theorem add_pos_right (a₁) (h : 0 < a₂) : 0 < a₁ + a₂ := Nat.lt_of_lt_of_le h (Nat.le_add_left ..) mutual partial def ExBase.evalPos (va : ExBase sℕ a) : Option Q(0 < $a) := match va with | .atom _ => none | .sum va => va.evalPos partial def ExProd.evalPos (va : ExProd sℕ a) : Option Q(0 < $a) := match va with | .const _ _ => -- it must be positive because it is a nonzero nat literal have lit : Q(ℕ) := a.appArg! haveI : $a =Q Nat.rawCast $lit := ⟨⟩ haveI p : Nat.ble 1 $lit =Q true := ⟨⟩ some q(const_pos $lit $p) | .mul (e := ea₁) vxa₁ _ va₂ => do let pa₁ ← vxa₁.evalPos let pa₂ ← va₂.evalPos some q(mul_exp_pos $ea₁ $pa₁ $pa₂) partial def ExSum.evalPos (va : ExSum sℕ a) : Option Q(0 < $a) := match va with | .zero => none | .add (a := a₁) (b := a₂) va₁ va₂ => do match va₁.evalPos with | some p => some q(add_pos_left $a₂ $p) | none => let p ← va₂.evalPos; some q(add_pos_right $a₁ $p) end theorem pow_one (a : R) : a ^ nat_lit 1 = a := by simp
Mathlib/Tactic/Ring/Basic.lean
665
666
theorem pow_bit0 (_ : (a : R) ^ k = b) (_ : b * b = c) : a ^ (Nat.mul (nat_lit 2) k) = c := by
subst_vars; simp [Nat.succ_mul, pow_add]
import Mathlib.Algebra.DirectSum.Module import Mathlib.Analysis.Complex.Basic import Mathlib.Analysis.Convex.Uniform import Mathlib.Analysis.NormedSpace.Completion import Mathlib.Analysis.NormedSpace.BoundedLinearMaps #align_import analysis.inner_product_space.basic from "leanprover-community/mathlib"@"3f655f5297b030a87d641ad4e825af8d9679eb0b" noncomputable section open RCLike Real Filter open Topology ComplexConjugate open LinearMap (BilinForm) variable {𝕜 E F : Type*} [RCLike 𝕜] class Inner (𝕜 E : Type*) where inner : E → E → 𝕜 #align has_inner Inner export Inner (inner) notation3:max "⟪" x ", " y "⟫_" 𝕜:max => @inner 𝕜 _ _ x y class InnerProductSpace (𝕜 : Type*) (E : Type*) [RCLike 𝕜] [NormedAddCommGroup E] extends NormedSpace 𝕜 E, Inner 𝕜 E where norm_sq_eq_inner : ∀ x : E, ‖x‖ ^ 2 = re (inner x x) conj_symm : ∀ x y, conj (inner y x) = inner x y add_left : ∀ x y z, inner (x + y) z = inner x z + inner y z smul_left : ∀ x y r, inner (r • x) y = conj r * inner x y #align inner_product_space InnerProductSpace -- @[nolint HasNonemptyInstance] porting note: I don't think we have this linter anymore structure InnerProductSpace.Core (𝕜 : Type*) (F : Type*) [RCLike 𝕜] [AddCommGroup F] [Module 𝕜 F] extends Inner 𝕜 F where conj_symm : ∀ x y, conj (inner y x) = inner x y nonneg_re : ∀ x, 0 ≤ re (inner x x) definite : ∀ x, inner x x = 0 → x = 0 add_left : ∀ x y z, inner (x + y) z = inner x z + inner y z smul_left : ∀ x y r, inner (r • x) y = conj r * inner x y #align inner_product_space.core InnerProductSpace.Core attribute [class] InnerProductSpace.Core def InnerProductSpace.toCore [NormedAddCommGroup E] [c : InnerProductSpace 𝕜 E] : InnerProductSpace.Core 𝕜 E := { c with nonneg_re := fun x => by rw [← InnerProductSpace.norm_sq_eq_inner] apply sq_nonneg definite := fun x hx => norm_eq_zero.1 <| pow_eq_zero (n := 2) <| by rw [InnerProductSpace.norm_sq_eq_inner (𝕜 := 𝕜) x, hx, map_zero] } #align inner_product_space.to_core InnerProductSpace.toCore namespace InnerProductSpace.Core variable [AddCommGroup F] [Module 𝕜 F] [c : InnerProductSpace.Core 𝕜 F] local notation "⟪" x ", " y "⟫" => @inner 𝕜 F _ x y local notation "normSqK" => @RCLike.normSq 𝕜 _ local notation "reK" => @RCLike.re 𝕜 _ local notation "ext_iff" => @RCLike.ext_iff 𝕜 _ local postfix:90 "†" => starRingEnd _ def toInner' : Inner 𝕜 F := c.toInner #align inner_product_space.core.to_has_inner' InnerProductSpace.Core.toInner' attribute [local instance] toInner' def normSq (x : F) := reK ⟪x, x⟫ #align inner_product_space.core.norm_sq InnerProductSpace.Core.normSq local notation "normSqF" => @normSq 𝕜 F _ _ _ _ theorem inner_conj_symm (x y : F) : ⟪y, x⟫† = ⟪x, y⟫ := c.conj_symm x y #align inner_product_space.core.inner_conj_symm InnerProductSpace.Core.inner_conj_symm theorem inner_self_nonneg {x : F} : 0 ≤ re ⟪x, x⟫ := c.nonneg_re _ #align inner_product_space.core.inner_self_nonneg InnerProductSpace.Core.inner_self_nonneg theorem inner_self_im (x : F) : im ⟪x, x⟫ = 0 := by rw [← @ofReal_inj 𝕜, im_eq_conj_sub] simp [inner_conj_symm] #align inner_product_space.core.inner_self_im InnerProductSpace.Core.inner_self_im theorem inner_add_left (x y z : F) : ⟪x + y, z⟫ = ⟪x, z⟫ + ⟪y, z⟫ := c.add_left _ _ _ #align inner_product_space.core.inner_add_left InnerProductSpace.Core.inner_add_left theorem inner_add_right (x y z : F) : ⟪x, y + z⟫ = ⟪x, y⟫ + ⟪x, z⟫ := by rw [← inner_conj_symm, inner_add_left, RingHom.map_add]; simp only [inner_conj_symm] #align inner_product_space.core.inner_add_right InnerProductSpace.Core.inner_add_right theorem ofReal_normSq_eq_inner_self (x : F) : (normSqF x : 𝕜) = ⟪x, x⟫ := by rw [ext_iff] exact ⟨by simp only [ofReal_re]; rfl, by simp only [inner_self_im, ofReal_im]⟩ #align inner_product_space.core.coe_norm_sq_eq_inner_self InnerProductSpace.Core.ofReal_normSq_eq_inner_self theorem inner_re_symm (x y : F) : re ⟪x, y⟫ = re ⟪y, x⟫ := by rw [← inner_conj_symm, conj_re] #align inner_product_space.core.inner_re_symm InnerProductSpace.Core.inner_re_symm theorem inner_im_symm (x y : F) : im ⟪x, y⟫ = -im ⟪y, x⟫ := by rw [← inner_conj_symm, conj_im] #align inner_product_space.core.inner_im_symm InnerProductSpace.Core.inner_im_symm theorem inner_smul_left (x y : F) {r : 𝕜} : ⟪r • x, y⟫ = r† * ⟪x, y⟫ := c.smul_left _ _ _ #align inner_product_space.core.inner_smul_left InnerProductSpace.Core.inner_smul_left theorem inner_smul_right (x y : F) {r : 𝕜} : ⟪x, r • y⟫ = r * ⟪x, y⟫ := by rw [← inner_conj_symm, inner_smul_left]; simp only [conj_conj, inner_conj_symm, RingHom.map_mul] #align inner_product_space.core.inner_smul_right InnerProductSpace.Core.inner_smul_right theorem inner_zero_left (x : F) : ⟪0, x⟫ = 0 := by rw [← zero_smul 𝕜 (0 : F), inner_smul_left]; simp only [zero_mul, RingHom.map_zero] #align inner_product_space.core.inner_zero_left InnerProductSpace.Core.inner_zero_left theorem inner_zero_right (x : F) : ⟪x, 0⟫ = 0 := by rw [← inner_conj_symm, inner_zero_left]; simp only [RingHom.map_zero] #align inner_product_space.core.inner_zero_right InnerProductSpace.Core.inner_zero_right theorem inner_self_eq_zero {x : F} : ⟪x, x⟫ = 0 ↔ x = 0 := ⟨c.definite _, by rintro rfl exact inner_zero_left _⟩ #align inner_product_space.core.inner_self_eq_zero InnerProductSpace.Core.inner_self_eq_zero theorem normSq_eq_zero {x : F} : normSqF x = 0 ↔ x = 0 := Iff.trans (by simp only [normSq, ext_iff, map_zero, inner_self_im, eq_self_iff_true, and_true_iff]) (@inner_self_eq_zero 𝕜 _ _ _ _ _ x) #align inner_product_space.core.norm_sq_eq_zero InnerProductSpace.Core.normSq_eq_zero theorem inner_self_ne_zero {x : F} : ⟪x, x⟫ ≠ 0 ↔ x ≠ 0 := inner_self_eq_zero.not #align inner_product_space.core.inner_self_ne_zero InnerProductSpace.Core.inner_self_ne_zero theorem inner_self_ofReal_re (x : F) : (re ⟪x, x⟫ : 𝕜) = ⟪x, x⟫ := by norm_num [ext_iff, inner_self_im] set_option linter.uppercaseLean3 false in #align inner_product_space.core.inner_self_re_to_K InnerProductSpace.Core.inner_self_ofReal_re theorem norm_inner_symm (x y : F) : ‖⟪x, y⟫‖ = ‖⟪y, x⟫‖ := by rw [← inner_conj_symm, norm_conj] #align inner_product_space.core.norm_inner_symm InnerProductSpace.Core.norm_inner_symm
Mathlib/Analysis/InnerProductSpace/Basic.lean
277
279
theorem inner_neg_left (x y : F) : ⟪-x, y⟫ = -⟪x, y⟫ := by
rw [← neg_one_smul 𝕜 x, inner_smul_left] simp
import Mathlib.Dynamics.Ergodic.MeasurePreserving import Mathlib.LinearAlgebra.Determinant import Mathlib.LinearAlgebra.Matrix.Diagonal import Mathlib.LinearAlgebra.Matrix.Transvection import Mathlib.MeasureTheory.Group.LIntegral import Mathlib.MeasureTheory.Integral.Marginal import Mathlib.MeasureTheory.Measure.Stieltjes import Mathlib.MeasureTheory.Measure.Haar.OfBasis #align_import measure_theory.measure.lebesgue.basic from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" assert_not_exists MeasureTheory.integral noncomputable section open scoped Classical open Set Filter MeasureTheory MeasureTheory.Measure TopologicalSpace open ENNReal (ofReal) open scoped ENNReal NNReal Topology section regionBetween variable {α : Type*} def regionBetween (f g : α → ℝ) (s : Set α) : Set (α × ℝ) := { p : α × ℝ | p.1 ∈ s ∧ p.2 ∈ Ioo (f p.1) (g p.1) } #align region_between regionBetween theorem regionBetween_subset (f g : α → ℝ) (s : Set α) : regionBetween f g s ⊆ s ×ˢ univ := by simpa only [prod_univ, regionBetween, Set.preimage, setOf_subset_setOf] using fun a => And.left #align region_between_subset regionBetween_subset variable [MeasurableSpace α] {μ : Measure α} {f g : α → ℝ} {s : Set α} theorem measurableSet_regionBetween (hf : Measurable f) (hg : Measurable g) (hs : MeasurableSet s) : MeasurableSet (regionBetween f g s) := by dsimp only [regionBetween, Ioo, mem_setOf_eq, setOf_and] refine MeasurableSet.inter ?_ ((measurableSet_lt (hf.comp measurable_fst) measurable_snd).inter (measurableSet_lt measurable_snd (hg.comp measurable_fst))) exact measurable_fst hs #align measurable_set_region_between measurableSet_regionBetween theorem measurableSet_region_between_oc (hf : Measurable f) (hg : Measurable g) (hs : MeasurableSet s) : MeasurableSet { p : α × ℝ | p.fst ∈ s ∧ p.snd ∈ Ioc (f p.fst) (g p.fst) } := by dsimp only [regionBetween, Ioc, mem_setOf_eq, setOf_and] refine MeasurableSet.inter ?_ ((measurableSet_lt (hf.comp measurable_fst) measurable_snd).inter (measurableSet_le measurable_snd (hg.comp measurable_fst))) exact measurable_fst hs #align measurable_set_region_between_oc measurableSet_region_between_oc theorem measurableSet_region_between_co (hf : Measurable f) (hg : Measurable g) (hs : MeasurableSet s) : MeasurableSet { p : α × ℝ | p.fst ∈ s ∧ p.snd ∈ Ico (f p.fst) (g p.fst) } := by dsimp only [regionBetween, Ico, mem_setOf_eq, setOf_and] refine MeasurableSet.inter ?_ ((measurableSet_le (hf.comp measurable_fst) measurable_snd).inter (measurableSet_lt measurable_snd (hg.comp measurable_fst))) exact measurable_fst hs #align measurable_set_region_between_co measurableSet_region_between_co
Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean
494
502
theorem measurableSet_region_between_cc (hf : Measurable f) (hg : Measurable g) (hs : MeasurableSet s) : MeasurableSet { p : α × ℝ | p.fst ∈ s ∧ p.snd ∈ Icc (f p.fst) (g p.fst) } := by
dsimp only [regionBetween, Icc, mem_setOf_eq, setOf_and] refine MeasurableSet.inter ?_ ((measurableSet_le (hf.comp measurable_fst) measurable_snd).inter (measurableSet_le measurable_snd (hg.comp measurable_fst))) exact measurable_fst hs
import Mathlib.Algebra.EuclideanDomain.Defs import Mathlib.Algebra.Ring.Divisibility.Basic import Mathlib.Algebra.Ring.Regular import Mathlib.Algebra.GroupWithZero.Divisibility import Mathlib.Algebra.Ring.Basic #align_import algebra.euclidean_domain.basic from "leanprover-community/mathlib"@"bf9bbbcf0c1c1ead18280b0d010e417b10abb1b6" universe u namespace EuclideanDomain variable {R : Type u} variable [EuclideanDomain R] local infixl:50 " ≺ " => EuclideanDomain.R -- See note [lower instance priority] instance (priority := 100) toMulDivCancelClass : MulDivCancelClass R where mul_div_cancel a b hb := by refine (eq_of_sub_eq_zero ?_).symm by_contra h have := mul_right_not_lt b h rw [sub_mul, mul_comm (_ / _), sub_eq_iff_eq_add'.2 (div_add_mod (a * b) b).symm] at this exact this (mod_lt _ hb) #align euclidean_domain.mul_div_cancel_left mul_div_cancel_left₀ #align euclidean_domain.mul_div_cancel mul_div_cancel_right₀ @[simp] theorem mod_eq_zero {a b : R} : a % b = 0 ↔ b ∣ a := ⟨fun h => by rw [← div_add_mod a b, h, add_zero] exact dvd_mul_right _ _, fun ⟨c, e⟩ => by rw [e, ← add_left_cancel_iff, div_add_mod, add_zero] haveI := Classical.dec by_cases b0 : b = 0 · simp only [b0, zero_mul] · rw [mul_div_cancel_left₀ _ b0]⟩ #align euclidean_domain.mod_eq_zero EuclideanDomain.mod_eq_zero @[simp] theorem mod_self (a : R) : a % a = 0 := mod_eq_zero.2 dvd_rfl #align euclidean_domain.mod_self EuclideanDomain.mod_self theorem dvd_mod_iff {a b c : R} (h : c ∣ b) : c ∣ a % b ↔ c ∣ a := by rw [← dvd_add_right (h.mul_right _), div_add_mod] #align euclidean_domain.dvd_mod_iff EuclideanDomain.dvd_mod_iff @[simp] theorem mod_one (a : R) : a % 1 = 0 := mod_eq_zero.2 (one_dvd _) #align euclidean_domain.mod_one EuclideanDomain.mod_one @[simp] theorem zero_mod (b : R) : 0 % b = 0 := mod_eq_zero.2 (dvd_zero _) #align euclidean_domain.zero_mod EuclideanDomain.zero_mod @[simp] theorem zero_div {a : R} : 0 / a = 0 := by_cases (fun a0 : a = 0 => a0.symm ▸ div_zero 0) fun a0 => by simpa only [zero_mul] using mul_div_cancel_right₀ 0 a0 #align euclidean_domain.zero_div EuclideanDomain.zero_div @[simp] theorem div_self {a : R} (a0 : a ≠ 0) : a / a = 1 := by simpa only [one_mul] using mul_div_cancel_right₀ 1 a0 #align euclidean_domain.div_self EuclideanDomain.div_self
Mathlib/Algebra/EuclideanDomain/Basic.lean
88
89
theorem eq_div_of_mul_eq_left {a b c : R} (hb : b ≠ 0) (h : a * b = c) : a = c / b := by
rw [← h, mul_div_cancel_right₀ _ hb]
import Mathlib.Algebra.DirectSum.Module import Mathlib.Analysis.Complex.Basic import Mathlib.Analysis.Convex.Uniform import Mathlib.Analysis.NormedSpace.Completion import Mathlib.Analysis.NormedSpace.BoundedLinearMaps #align_import analysis.inner_product_space.basic from "leanprover-community/mathlib"@"3f655f5297b030a87d641ad4e825af8d9679eb0b" noncomputable section open RCLike Real Filter open Topology ComplexConjugate open LinearMap (BilinForm) variable {𝕜 E F : Type*} [RCLike 𝕜] class Inner (𝕜 E : Type*) where inner : E → E → 𝕜 #align has_inner Inner export Inner (inner) notation3:max "⟪" x ", " y "⟫_" 𝕜:max => @inner 𝕜 _ _ x y class InnerProductSpace (𝕜 : Type*) (E : Type*) [RCLike 𝕜] [NormedAddCommGroup E] extends NormedSpace 𝕜 E, Inner 𝕜 E where norm_sq_eq_inner : ∀ x : E, ‖x‖ ^ 2 = re (inner x x) conj_symm : ∀ x y, conj (inner y x) = inner x y add_left : ∀ x y z, inner (x + y) z = inner x z + inner y z smul_left : ∀ x y r, inner (r • x) y = conj r * inner x y #align inner_product_space InnerProductSpace -- @[nolint HasNonemptyInstance] porting note: I don't think we have this linter anymore structure InnerProductSpace.Core (𝕜 : Type*) (F : Type*) [RCLike 𝕜] [AddCommGroup F] [Module 𝕜 F] extends Inner 𝕜 F where conj_symm : ∀ x y, conj (inner y x) = inner x y nonneg_re : ∀ x, 0 ≤ re (inner x x) definite : ∀ x, inner x x = 0 → x = 0 add_left : ∀ x y z, inner (x + y) z = inner x z + inner y z smul_left : ∀ x y r, inner (r • x) y = conj r * inner x y #align inner_product_space.core InnerProductSpace.Core attribute [class] InnerProductSpace.Core def InnerProductSpace.toCore [NormedAddCommGroup E] [c : InnerProductSpace 𝕜 E] : InnerProductSpace.Core 𝕜 E := { c with nonneg_re := fun x => by rw [← InnerProductSpace.norm_sq_eq_inner] apply sq_nonneg definite := fun x hx => norm_eq_zero.1 <| pow_eq_zero (n := 2) <| by rw [InnerProductSpace.norm_sq_eq_inner (𝕜 := 𝕜) x, hx, map_zero] } #align inner_product_space.to_core InnerProductSpace.toCore namespace InnerProductSpace.Core variable [AddCommGroup F] [Module 𝕜 F] [c : InnerProductSpace.Core 𝕜 F] local notation "⟪" x ", " y "⟫" => @inner 𝕜 F _ x y local notation "normSqK" => @RCLike.normSq 𝕜 _ local notation "reK" => @RCLike.re 𝕜 _ local notation "ext_iff" => @RCLike.ext_iff 𝕜 _ local postfix:90 "†" => starRingEnd _ def toInner' : Inner 𝕜 F := c.toInner #align inner_product_space.core.to_has_inner' InnerProductSpace.Core.toInner' attribute [local instance] toInner' def normSq (x : F) := reK ⟪x, x⟫ #align inner_product_space.core.norm_sq InnerProductSpace.Core.normSq local notation "normSqF" => @normSq 𝕜 F _ _ _ _ theorem inner_conj_symm (x y : F) : ⟪y, x⟫† = ⟪x, y⟫ := c.conj_symm x y #align inner_product_space.core.inner_conj_symm InnerProductSpace.Core.inner_conj_symm theorem inner_self_nonneg {x : F} : 0 ≤ re ⟪x, x⟫ := c.nonneg_re _ #align inner_product_space.core.inner_self_nonneg InnerProductSpace.Core.inner_self_nonneg theorem inner_self_im (x : F) : im ⟪x, x⟫ = 0 := by rw [← @ofReal_inj 𝕜, im_eq_conj_sub] simp [inner_conj_symm] #align inner_product_space.core.inner_self_im InnerProductSpace.Core.inner_self_im theorem inner_add_left (x y z : F) : ⟪x + y, z⟫ = ⟪x, z⟫ + ⟪y, z⟫ := c.add_left _ _ _ #align inner_product_space.core.inner_add_left InnerProductSpace.Core.inner_add_left theorem inner_add_right (x y z : F) : ⟪x, y + z⟫ = ⟪x, y⟫ + ⟪x, z⟫ := by rw [← inner_conj_symm, inner_add_left, RingHom.map_add]; simp only [inner_conj_symm] #align inner_product_space.core.inner_add_right InnerProductSpace.Core.inner_add_right theorem ofReal_normSq_eq_inner_self (x : F) : (normSqF x : 𝕜) = ⟪x, x⟫ := by rw [ext_iff] exact ⟨by simp only [ofReal_re]; rfl, by simp only [inner_self_im, ofReal_im]⟩ #align inner_product_space.core.coe_norm_sq_eq_inner_self InnerProductSpace.Core.ofReal_normSq_eq_inner_self theorem inner_re_symm (x y : F) : re ⟪x, y⟫ = re ⟪y, x⟫ := by rw [← inner_conj_symm, conj_re] #align inner_product_space.core.inner_re_symm InnerProductSpace.Core.inner_re_symm theorem inner_im_symm (x y : F) : im ⟪x, y⟫ = -im ⟪y, x⟫ := by rw [← inner_conj_symm, conj_im] #align inner_product_space.core.inner_im_symm InnerProductSpace.Core.inner_im_symm theorem inner_smul_left (x y : F) {r : 𝕜} : ⟪r • x, y⟫ = r† * ⟪x, y⟫ := c.smul_left _ _ _ #align inner_product_space.core.inner_smul_left InnerProductSpace.Core.inner_smul_left theorem inner_smul_right (x y : F) {r : 𝕜} : ⟪x, r • y⟫ = r * ⟪x, y⟫ := by rw [← inner_conj_symm, inner_smul_left]; simp only [conj_conj, inner_conj_symm, RingHom.map_mul] #align inner_product_space.core.inner_smul_right InnerProductSpace.Core.inner_smul_right theorem inner_zero_left (x : F) : ⟪0, x⟫ = 0 := by rw [← zero_smul 𝕜 (0 : F), inner_smul_left]; simp only [zero_mul, RingHom.map_zero] #align inner_product_space.core.inner_zero_left InnerProductSpace.Core.inner_zero_left theorem inner_zero_right (x : F) : ⟪x, 0⟫ = 0 := by rw [← inner_conj_symm, inner_zero_left]; simp only [RingHom.map_zero] #align inner_product_space.core.inner_zero_right InnerProductSpace.Core.inner_zero_right theorem inner_self_eq_zero {x : F} : ⟪x, x⟫ = 0 ↔ x = 0 := ⟨c.definite _, by rintro rfl exact inner_zero_left _⟩ #align inner_product_space.core.inner_self_eq_zero InnerProductSpace.Core.inner_self_eq_zero theorem normSq_eq_zero {x : F} : normSqF x = 0 ↔ x = 0 := Iff.trans (by simp only [normSq, ext_iff, map_zero, inner_self_im, eq_self_iff_true, and_true_iff]) (@inner_self_eq_zero 𝕜 _ _ _ _ _ x) #align inner_product_space.core.norm_sq_eq_zero InnerProductSpace.Core.normSq_eq_zero theorem inner_self_ne_zero {x : F} : ⟪x, x⟫ ≠ 0 ↔ x ≠ 0 := inner_self_eq_zero.not #align inner_product_space.core.inner_self_ne_zero InnerProductSpace.Core.inner_self_ne_zero theorem inner_self_ofReal_re (x : F) : (re ⟪x, x⟫ : 𝕜) = ⟪x, x⟫ := by norm_num [ext_iff, inner_self_im] set_option linter.uppercaseLean3 false in #align inner_product_space.core.inner_self_re_to_K InnerProductSpace.Core.inner_self_ofReal_re theorem norm_inner_symm (x y : F) : ‖⟪x, y⟫‖ = ‖⟪y, x⟫‖ := by rw [← inner_conj_symm, norm_conj] #align inner_product_space.core.norm_inner_symm InnerProductSpace.Core.norm_inner_symm theorem inner_neg_left (x y : F) : ⟪-x, y⟫ = -⟪x, y⟫ := by rw [← neg_one_smul 𝕜 x, inner_smul_left] simp #align inner_product_space.core.inner_neg_left InnerProductSpace.Core.inner_neg_left theorem inner_neg_right (x y : F) : ⟪x, -y⟫ = -⟪x, y⟫ := by rw [← inner_conj_symm, inner_neg_left]; simp only [RingHom.map_neg, inner_conj_symm] #align inner_product_space.core.inner_neg_right InnerProductSpace.Core.inner_neg_right theorem inner_sub_left (x y z : F) : ⟪x - y, z⟫ = ⟪x, z⟫ - ⟪y, z⟫ := by simp [sub_eq_add_neg, inner_add_left, inner_neg_left] #align inner_product_space.core.inner_sub_left InnerProductSpace.Core.inner_sub_left theorem inner_sub_right (x y z : F) : ⟪x, y - z⟫ = ⟪x, y⟫ - ⟪x, z⟫ := by simp [sub_eq_add_neg, inner_add_right, inner_neg_right] #align inner_product_space.core.inner_sub_right InnerProductSpace.Core.inner_sub_right theorem inner_mul_symm_re_eq_norm (x y : F) : re (⟪x, y⟫ * ⟪y, x⟫) = ‖⟪x, y⟫ * ⟪y, x⟫‖ := by rw [← inner_conj_symm, mul_comm] exact re_eq_norm_of_mul_conj (inner y x) #align inner_product_space.core.inner_mul_symm_re_eq_norm InnerProductSpace.Core.inner_mul_symm_re_eq_norm theorem inner_add_add_self (x y : F) : ⟪x + y, x + y⟫ = ⟪x, x⟫ + ⟪x, y⟫ + ⟪y, x⟫ + ⟪y, y⟫ := by simp only [inner_add_left, inner_add_right]; ring #align inner_product_space.core.inner_add_add_self InnerProductSpace.Core.inner_add_add_self -- Expand `inner (x - y) (x - y)` theorem inner_sub_sub_self (x y : F) : ⟪x - y, x - y⟫ = ⟪x, x⟫ - ⟪x, y⟫ - ⟪y, x⟫ + ⟪y, y⟫ := by simp only [inner_sub_left, inner_sub_right]; ring #align inner_product_space.core.inner_sub_sub_self InnerProductSpace.Core.inner_sub_sub_self theorem cauchy_schwarz_aux (x y : F) : normSqF (⟪x, y⟫ • x - ⟪x, x⟫ • y) = normSqF x * (normSqF x * normSqF y - ‖⟪x, y⟫‖ ^ 2) := by rw [← @ofReal_inj 𝕜, ofReal_normSq_eq_inner_self] simp only [inner_sub_sub_self, inner_smul_left, inner_smul_right, conj_ofReal, mul_sub, ← ofReal_normSq_eq_inner_self x, ← ofReal_normSq_eq_inner_self y] rw [← mul_assoc, mul_conj, RCLike.conj_mul, mul_left_comm, ← inner_conj_symm y, mul_conj] push_cast ring #align inner_product_space.core.cauchy_schwarz_aux InnerProductSpace.Core.cauchy_schwarz_aux theorem inner_mul_inner_self_le (x y : F) : ‖⟪x, y⟫‖ * ‖⟪y, x⟫‖ ≤ re ⟪x, x⟫ * re ⟪y, y⟫ := by rcases eq_or_ne x 0 with (rfl | hx) · simpa only [inner_zero_left, map_zero, zero_mul, norm_zero] using le_rfl · have hx' : 0 < normSqF x := inner_self_nonneg.lt_of_ne' (mt normSq_eq_zero.1 hx) rw [← sub_nonneg, ← mul_nonneg_iff_right_nonneg_of_pos hx', ← normSq, ← normSq, norm_inner_symm y, ← sq, ← cauchy_schwarz_aux] exact inner_self_nonneg #align inner_product_space.core.inner_mul_inner_self_le InnerProductSpace.Core.inner_mul_inner_self_le def toNorm : Norm F where norm x := √(re ⟪x, x⟫) #align inner_product_space.core.to_has_norm InnerProductSpace.Core.toNorm attribute [local instance] toNorm theorem norm_eq_sqrt_inner (x : F) : ‖x‖ = √(re ⟪x, x⟫) := rfl #align inner_product_space.core.norm_eq_sqrt_inner InnerProductSpace.Core.norm_eq_sqrt_inner
Mathlib/Analysis/InnerProductSpace/Basic.lean
346
347
theorem inner_self_eq_norm_mul_norm (x : F) : re ⟪x, x⟫ = ‖x‖ * ‖x‖ := by
rw [norm_eq_sqrt_inner, ← sqrt_mul inner_self_nonneg (re ⟪x, x⟫), sqrt_mul_self inner_self_nonneg]
import Mathlib.Algebra.CharP.Invertible import Mathlib.Analysis.NormedSpace.Basic import Mathlib.Analysis.Normed.Group.AddTorsor import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace import Mathlib.Topology.Instances.RealVectorSpace #align_import analysis.normed_space.add_torsor from "leanprover-community/mathlib"@"837f72de63ad6cd96519cde5f1ffd5ed8d280ad0" noncomputable section open NNReal Topology open Filter variable {α V P W Q : Type*} [SeminormedAddCommGroup V] [PseudoMetricSpace P] [NormedAddTorsor V P] [NormedAddCommGroup W] [MetricSpace Q] [NormedAddTorsor W Q] section NormedSpace variable {𝕜 : Type*} [NormedField 𝕜] [NormedSpace 𝕜 V] [NormedSpace 𝕜 W] open AffineMap theorem AffineSubspace.isClosed_direction_iff (s : AffineSubspace 𝕜 Q) : IsClosed (s.direction : Set W) ↔ IsClosed (s : Set Q) := by rcases s.eq_bot_or_nonempty with (rfl | ⟨x, hx⟩); · simp [isClosed_singleton] rw [← (IsometryEquiv.vaddConst x).toHomeomorph.symm.isClosed_image, AffineSubspace.coe_direction_eq_vsub_set_right hx] rfl #align affine_subspace.is_closed_direction_iff AffineSubspace.isClosed_direction_iff @[simp] theorem dist_center_homothety (p₁ p₂ : P) (c : 𝕜) : dist p₁ (homothety p₁ c p₂) = ‖c‖ * dist p₁ p₂ := by simp [homothety_def, norm_smul, ← dist_eq_norm_vsub, dist_comm] #align dist_center_homothety dist_center_homothety @[simp] theorem nndist_center_homothety (p₁ p₂ : P) (c : 𝕜) : nndist p₁ (homothety p₁ c p₂) = ‖c‖₊ * nndist p₁ p₂ := NNReal.eq <| dist_center_homothety _ _ _ #align nndist_center_homothety nndist_center_homothety @[simp]
Mathlib/Analysis/NormedSpace/AddTorsor.lean
57
58
theorem dist_homothety_center (p₁ p₂ : P) (c : 𝕜) : dist (homothety p₁ c p₂) p₁ = ‖c‖ * dist p₁ p₂ := by
rw [dist_comm, dist_center_homothety]
import Mathlib.Order.Interval.Finset.Nat import Mathlib.Data.PNat.Defs #align_import data.pnat.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29" open Finset Function PNat namespace PNat variable (a b : ℕ+) instance instLocallyFiniteOrder : LocallyFiniteOrder ℕ+ := Subtype.instLocallyFiniteOrder _ theorem Icc_eq_finset_subtype : Icc a b = (Icc (a : ℕ) b).subtype fun n : ℕ => 0 < n := rfl #align pnat.Icc_eq_finset_subtype PNat.Icc_eq_finset_subtype theorem Ico_eq_finset_subtype : Ico a b = (Ico (a : ℕ) b).subtype fun n : ℕ => 0 < n := rfl #align pnat.Ico_eq_finset_subtype PNat.Ico_eq_finset_subtype theorem Ioc_eq_finset_subtype : Ioc a b = (Ioc (a : ℕ) b).subtype fun n : ℕ => 0 < n := rfl #align pnat.Ioc_eq_finset_subtype PNat.Ioc_eq_finset_subtype theorem Ioo_eq_finset_subtype : Ioo a b = (Ioo (a : ℕ) b).subtype fun n : ℕ => 0 < n := rfl #align pnat.Ioo_eq_finset_subtype PNat.Ioo_eq_finset_subtype theorem uIcc_eq_finset_subtype : uIcc a b = (uIcc (a : ℕ) b).subtype fun n : ℕ => 0 < n := rfl #align pnat.uIcc_eq_finset_subtype PNat.uIcc_eq_finset_subtype theorem map_subtype_embedding_Icc : (Icc a b).map (Embedding.subtype _) = Icc ↑a ↑b := Finset.map_subtype_embedding_Icc _ _ _ fun _c _ _x hx _ hc _ => hc.trans_le hx #align pnat.map_subtype_embedding_Icc PNat.map_subtype_embedding_Icc theorem map_subtype_embedding_Ico : (Ico a b).map (Embedding.subtype _) = Ico ↑a ↑b := Finset.map_subtype_embedding_Ico _ _ _ fun _c _ _x hx _ hc _ => hc.trans_le hx #align pnat.map_subtype_embedding_Ico PNat.map_subtype_embedding_Ico theorem map_subtype_embedding_Ioc : (Ioc a b).map (Embedding.subtype _) = Ioc ↑a ↑b := Finset.map_subtype_embedding_Ioc _ _ _ fun _c _ _x hx _ hc _ => hc.trans_le hx #align pnat.map_subtype_embedding_Ioc PNat.map_subtype_embedding_Ioc theorem map_subtype_embedding_Ioo : (Ioo a b).map (Embedding.subtype _) = Ioo ↑a ↑b := Finset.map_subtype_embedding_Ioo _ _ _ fun _c _ _x hx _ hc _ => hc.trans_le hx #align pnat.map_subtype_embedding_Ioo PNat.map_subtype_embedding_Ioo theorem map_subtype_embedding_uIcc : (uIcc a b).map (Embedding.subtype _) = uIcc ↑a ↑b := map_subtype_embedding_Icc _ _ #align pnat.map_subtype_embedding_uIcc PNat.map_subtype_embedding_uIcc @[simp] theorem card_Icc : (Icc a b).card = b + 1 - a := by rw [← Nat.card_Icc] -- Porting note: I had to change this to `erw` *and* provide the proof, yuck. -- https://github.com/leanprover-community/mathlib4/issues/5164 erw [← Finset.map_subtype_embedding_Icc _ a b (fun c x _ hx _ hc _ => hc.trans_le hx)] rw [card_map] #align pnat.card_Icc PNat.card_Icc @[simp] theorem card_Ico : (Ico a b).card = b - a := by rw [← Nat.card_Ico] -- Porting note: I had to change this to `erw` *and* provide the proof, yuck. -- https://github.com/leanprover-community/mathlib4/issues/5164 erw [← Finset.map_subtype_embedding_Ico _ a b (fun c x _ hx _ hc _ => hc.trans_le hx)] rw [card_map] #align pnat.card_Ico PNat.card_Ico @[simp] theorem card_Ioc : (Ioc a b).card = b - a := by rw [← Nat.card_Ioc] -- Porting note: I had to change this to `erw` *and* provide the proof, yuck. -- https://github.com/leanprover-community/mathlib4/issues/5164 erw [← Finset.map_subtype_embedding_Ioc _ a b (fun c x _ hx _ hc _ => hc.trans_le hx)] rw [card_map] #align pnat.card_Ioc PNat.card_Ioc @[simp] theorem card_Ioo : (Ioo a b).card = b - a - 1 := by rw [← Nat.card_Ioo] -- Porting note: I had to change this to `erw` *and* provide the proof, yuck. -- https://github.com/leanprover-community/mathlib4/issues/5164 erw [← Finset.map_subtype_embedding_Ioo _ a b (fun c x _ hx _ hc _ => hc.trans_le hx)] rw [card_map] #align pnat.card_Ioo PNat.card_Ioo @[simp] theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 := by rw [← Nat.card_uIcc, ← map_subtype_embedding_uIcc, card_map] #align pnat.card_uIcc PNat.card_uIcc -- Porting note: `simpNF` says `simp` can prove this theorem card_fintype_Icc : Fintype.card (Set.Icc a b) = b + 1 - a := by rw [← card_Icc, Fintype.card_ofFinset] #align pnat.card_fintype_Icc PNat.card_fintype_Icc -- Porting note: `simpNF` says `simp` can prove this theorem card_fintype_Ico : Fintype.card (Set.Ico a b) = b - a := by rw [← card_Ico, Fintype.card_ofFinset] #align pnat.card_fintype_Ico PNat.card_fintype_Ico -- Porting note: `simpNF` says `simp` can prove this theorem card_fintype_Ioc : Fintype.card (Set.Ioc a b) = b - a := by rw [← card_Ioc, Fintype.card_ofFinset] #align pnat.card_fintype_Ioc PNat.card_fintype_Ioc -- Porting note: `simpNF` says `simp` can prove this
Mathlib/Data/PNat/Interval.lean
123
124
theorem card_fintype_Ioo : Fintype.card (Set.Ioo a b) = b - a - 1 := by
rw [← card_Ioo, Fintype.card_ofFinset]
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Arctan import Mathlib.Analysis.SpecialFunctions.Trigonometric.ComplexDeriv #align_import analysis.special_functions.trigonometric.arctan_deriv from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" noncomputable section namespace Real open Set Filter open scoped Topology Real theorem hasStrictDerivAt_tan {x : ℝ} (h : cos x ≠ 0) : HasStrictDerivAt tan (1 / cos x ^ 2) x := mod_cast (Complex.hasStrictDerivAt_tan (by exact mod_cast h)).real_of_complex #align real.has_strict_deriv_at_tan Real.hasStrictDerivAt_tan theorem hasDerivAt_tan {x : ℝ} (h : cos x ≠ 0) : HasDerivAt tan (1 / cos x ^ 2) x := mod_cast (Complex.hasDerivAt_tan (by exact mod_cast h)).real_of_complex #align real.has_deriv_at_tan Real.hasDerivAt_tan
Mathlib/Analysis/SpecialFunctions/Trigonometric/ArctanDeriv.lean
34
40
theorem tendsto_abs_tan_of_cos_eq_zero {x : ℝ} (hx : cos x = 0) : Tendsto (fun x => abs (tan x)) (𝓝[≠] x) atTop := by
have hx : Complex.cos x = 0 := mod_cast hx simp only [← Complex.abs_ofReal, Complex.ofReal_tan] refine (Complex.tendsto_abs_tan_of_cos_eq_zero hx).comp ?_ refine Tendsto.inf Complex.continuous_ofReal.continuousAt ?_ exact tendsto_principal_principal.2 fun y => mt Complex.ofReal_inj.1
import Mathlib.Algebra.Polynomial.Module.Basic import Mathlib.Algebra.Ring.Idempotents import Mathlib.RingTheory.Ideal.LocalRing import Mathlib.RingTheory.Noetherian import Mathlib.RingTheory.ReesAlgebra import Mathlib.RingTheory.Finiteness import Mathlib.Order.Basic import Mathlib.Order.Hom.Lattice #align_import ring_theory.filtration from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe u v variable {R M : Type u} [CommRing R] [AddCommGroup M] [Module R M] (I : Ideal R) open Polynomial open scoped Polynomial @[ext] structure Ideal.Filtration (M : Type u) [AddCommGroup M] [Module R M] where N : ℕ → Submodule R M mono : ∀ i, N (i + 1) ≤ N i smul_le : ∀ i, I • N i ≤ N (i + 1) #align ideal.filtration Ideal.Filtration variable (F F' : I.Filtration M) {I} namespace Ideal.Filtration theorem pow_smul_le (i j : ℕ) : I ^ i • F.N j ≤ F.N (i + j) := by induction' i with _ ih · simp · rw [pow_succ', mul_smul, add_assoc, add_comm 1, ← add_assoc] exact (smul_mono_right _ ih).trans (F.smul_le _) #align ideal.filtration.pow_smul_le Ideal.Filtration.pow_smul_le theorem pow_smul_le_pow_smul (i j k : ℕ) : I ^ (i + k) • F.N j ≤ I ^ k • F.N (i + j) := by rw [add_comm, pow_add, mul_smul] exact smul_mono_right _ (F.pow_smul_le i j) #align ideal.filtration.pow_smul_le_pow_smul Ideal.Filtration.pow_smul_le_pow_smul protected theorem antitone : Antitone F.N := antitone_nat_of_succ_le F.mono #align ideal.filtration.antitone Ideal.Filtration.antitone @[simps] def _root_.Ideal.trivialFiltration (I : Ideal R) (N : Submodule R M) : I.Filtration M where N _ := N mono _ := le_rfl smul_le _ := Submodule.smul_le_right #align ideal.trivial_filtration Ideal.trivialFiltration instance : Sup (I.Filtration M) := ⟨fun F F' => ⟨F.N ⊔ F'.N, fun i => sup_le_sup (F.mono i) (F'.mono i), fun i => (Submodule.smul_sup _ _ _).trans_le <| sup_le_sup (F.smul_le i) (F'.smul_le i)⟩⟩ instance : SupSet (I.Filtration M) := ⟨fun S => { N := sSup (Ideal.Filtration.N '' S) mono := fun i => by apply sSup_le_sSup_of_forall_exists_le _ rintro _ ⟨⟨_, F, hF, rfl⟩, rfl⟩ exact ⟨_, ⟨⟨_, F, hF, rfl⟩, rfl⟩, F.mono i⟩ smul_le := fun i => by rw [sSup_eq_iSup', iSup_apply, Submodule.smul_iSup, iSup_apply] apply iSup_mono _ rintro ⟨_, F, hF, rfl⟩ exact F.smul_le i }⟩ instance : Inf (I.Filtration M) := ⟨fun F F' => ⟨F.N ⊓ F'.N, fun i => inf_le_inf (F.mono i) (F'.mono i), fun i => (smul_inf_le _ _ _).trans <| inf_le_inf (F.smul_le i) (F'.smul_le i)⟩⟩ instance : InfSet (I.Filtration M) := ⟨fun S => { N := sInf (Ideal.Filtration.N '' S) mono := fun i => by apply sInf_le_sInf_of_forall_exists_le _ rintro _ ⟨⟨_, F, hF, rfl⟩, rfl⟩ exact ⟨_, ⟨⟨_, F, hF, rfl⟩, rfl⟩, F.mono i⟩ smul_le := fun i => by rw [sInf_eq_iInf', iInf_apply, iInf_apply] refine smul_iInf_le.trans ?_ apply iInf_mono _ rintro ⟨_, F, hF, rfl⟩ exact F.smul_le i }⟩ instance : Top (I.Filtration M) := ⟨I.trivialFiltration ⊤⟩ instance : Bot (I.Filtration M) := ⟨I.trivialFiltration ⊥⟩ @[simp] theorem sup_N : (F ⊔ F').N = F.N ⊔ F'.N := rfl set_option linter.uppercaseLean3 false in #align ideal.filtration.sup_N Ideal.Filtration.sup_N @[simp] theorem sSup_N (S : Set (I.Filtration M)) : (sSup S).N = sSup (Ideal.Filtration.N '' S) := rfl set_option linter.uppercaseLean3 false in #align ideal.filtration.Sup_N Ideal.Filtration.sSup_N @[simp] theorem inf_N : (F ⊓ F').N = F.N ⊓ F'.N := rfl set_option linter.uppercaseLean3 false in #align ideal.filtration.inf_N Ideal.Filtration.inf_N @[simp] theorem sInf_N (S : Set (I.Filtration M)) : (sInf S).N = sInf (Ideal.Filtration.N '' S) := rfl set_option linter.uppercaseLean3 false in #align ideal.filtration.Inf_N Ideal.Filtration.sInf_N @[simp] theorem top_N : (⊤ : I.Filtration M).N = ⊤ := rfl set_option linter.uppercaseLean3 false in #align ideal.filtration.top_N Ideal.Filtration.top_N @[simp] theorem bot_N : (⊥ : I.Filtration M).N = ⊥ := rfl set_option linter.uppercaseLean3 false in #align ideal.filtration.bot_N Ideal.Filtration.bot_N @[simp] theorem iSup_N {ι : Sort*} (f : ι → I.Filtration M) : (iSup f).N = ⨆ i, (f i).N := congr_arg sSup (Set.range_comp _ _).symm set_option linter.uppercaseLean3 false in #align ideal.filtration.supr_N Ideal.Filtration.iSup_N @[simp] theorem iInf_N {ι : Sort*} (f : ι → I.Filtration M) : (iInf f).N = ⨅ i, (f i).N := congr_arg sInf (Set.range_comp _ _).symm set_option linter.uppercaseLean3 false in #align ideal.filtration.infi_N Ideal.Filtration.iInf_N instance : CompleteLattice (I.Filtration M) := Function.Injective.completeLattice Ideal.Filtration.N Ideal.Filtration.ext sup_N inf_N (fun _ => sSup_image) (fun _ => sInf_image) top_N bot_N instance : Inhabited (I.Filtration M) := ⟨⊥⟩ def Stable : Prop := ∃ n₀, ∀ n ≥ n₀, I • F.N n = F.N (n + 1) #align ideal.filtration.stable Ideal.Filtration.Stable @[simps] def _root_.Ideal.stableFiltration (I : Ideal R) (N : Submodule R M) : I.Filtration M where N i := I ^ i • N mono i := by dsimp only; rw [add_comm, pow_add, mul_smul]; exact Submodule.smul_le_right smul_le i := by dsimp only; rw [add_comm, pow_add, mul_smul, pow_one] #align ideal.stable_filtration Ideal.stableFiltration
Mathlib/RingTheory/Filtration.lean
206
211
theorem _root_.Ideal.stableFiltration_stable (I : Ideal R) (N : Submodule R M) : (I.stableFiltration N).Stable := by
use 0 intro n _ dsimp rw [add_comm, pow_add, mul_smul, pow_one]
import Mathlib.Topology.CompactOpen import Mathlib.Topology.LocallyFinite import Mathlib.Topology.ProperMap import Mathlib.Topology.UniformSpace.UniformConvergenceTopology #align_import topology.uniform_space.compact_convergence from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" universe u₁ u₂ u₃ open scoped Uniformity Topology UniformConvergence open UniformSpace Set Filter variable {α : Type u₁} {β : Type u₂} [TopologicalSpace α] [UniformSpace β] variable (K : Set α) (V : Set (β × β)) (f : C(α, β)) namespace ContinuousMap theorem tendsto_iff_forall_compact_tendstoUniformlyOn {ι : Type u₃} {p : Filter ι} {F : ι → C(α, β)} {f} : Tendsto F p (𝓝 f) ↔ ∀ K, IsCompact K → TendstoUniformlyOn (fun i a => F i a) f p K := by rw [tendsto_nhds_compactOpen] constructor · -- Let us prove that convergence in the compact-open topology -- implies uniform convergence on compacts. -- Consider a compact set `K` intro h K hK -- Since `K` is compact, it suffices to prove locally uniform convergence rw [← tendstoLocallyUniformlyOn_iff_tendstoUniformlyOn_of_compact hK] -- Now choose an entourage `U` in the codomain and a point `x ∈ K`. intro U hU x _ -- Choose an open symmetric entourage `V` such that `V ○ V ⊆ U`. rcases comp_open_symm_mem_uniformity_sets hU with ⟨V, hV, hVo, hVsymm, hVU⟩ -- Then choose a closed entourage `W ⊆ V` rcases mem_uniformity_isClosed hV with ⟨W, hW, hWc, hWU⟩ -- Consider `s = {y ∈ K | (f x, f y) ∈ W}` set s := K ∩ f ⁻¹' ball (f x) W -- This is a neighbourhood of `x` within `K`, because `W` is an entourage. have hnhds : s ∈ 𝓝[K] x := inter_mem_nhdsWithin _ <| f.continuousAt _ (ball_mem_nhds _ hW) -- This set is compact because it is an intersection of `K` -- with a closed set `{y | (f x, f y) ∈ W} = f ⁻¹' UniformSpace.ball (f x) W` have hcomp : IsCompact s := hK.inter_right <| (isClosed_ball _ hWc).preimage f.continuous -- `f` maps `s` to the open set `ball (f x) V = {z | (f x, z) ∈ V}` have hmaps : MapsTo f s (ball (f x) V) := fun x hx ↦ hWU hx.2 use s, hnhds -- Continuous maps `F i` in a neighbourhood of `f` map `s` to `ball (f x) V` as well. refine (h s hcomp _ (isOpen_ball _ hVo) hmaps).mono fun g hg y hy ↦ ?_ -- Then for `y ∈ s` we have `(f y, f x) ∈ V` and `(f x, F i y) ∈ V`, thus `(f y, F i y) ∈ U` exact hVU ⟨f x, hVsymm.mk_mem_comm.2 <| hmaps hy, hg hy⟩ · -- Now we prove that uniform convergence on compacts -- implies convergence in the compact-open topology -- Consider a compact set `K`, an open set `U`, and a continuous map `f` that maps `K` to `U` intro h K hK U hU hf -- Due to Lebesgue number lemma, there exists an entourage `V` -- such that `U` includes the `V`-thickening of `f '' K`. rcases lebesgue_number_of_compact_open (hK.image (map_continuous f)) hU hf.image_subset with ⟨V, hV, -, hVf⟩ -- Then any continuous map that is uniformly `V`-close to `f` on `K` -- maps `K` to `U` as well filter_upwards [h K hK V hV] with g hg x hx using hVf _ (mem_image_of_mem f hx) (hg x hx) #align continuous_map.tendsto_iff_forall_compact_tendsto_uniformly_on ContinuousMap.tendsto_iff_forall_compact_tendstoUniformlyOn def toUniformOnFunIsCompact (f : C(α, β)) : α →ᵤ[{K | IsCompact K}] β := UniformOnFun.ofFun {K | IsCompact K} f @[simp] theorem toUniformOnFun_toFun (f : C(α, β)) : UniformOnFun.toFun _ f.toUniformOnFunIsCompact = f := rfl open UniformSpace in instance compactConvergenceUniformSpace : UniformSpace C(α, β) := .replaceTopology (.comap toUniformOnFunIsCompact inferInstance) <| by refine TopologicalSpace.ext_nhds fun f ↦ eq_of_forall_le_iff fun l ↦ ?_ simp_rw [← tendsto_id', tendsto_iff_forall_compact_tendstoUniformlyOn, nhds_induced, tendsto_comap_iff, UniformOnFun.tendsto_iff_tendstoUniformlyOn] rfl #align continuous_map.compact_convergence_uniform_space ContinuousMap.compactConvergenceUniformSpace theorem uniformEmbedding_toUniformOnFunIsCompact : UniformEmbedding (toUniformOnFunIsCompact : C(α, β) → α →ᵤ[{K | IsCompact K}] β) where comap_uniformity := rfl inj := DFunLike.coe_injective -- The following definitions and theorems -- used to be a part of the construction of the `UniformSpace C(α, β)` structure -- before it was migrated to `UniformOnFun` #noalign continuous_map.compact_conv_nhd #noalign continuous_map.self_mem_compact_conv_nhd #noalign continuous_map.compact_conv_nhd_mono #noalign continuous_map.compact_conv_nhd_mem_comp #noalign continuous_map.compact_conv_nhd_nhd_basis #noalign continuous_map.compact_conv_nhd_subset_inter #noalign continuous_map.compact_conv_nhd_compact_entourage_nonempty #noalign continuous_map.compact_conv_nhd_filter_is_basis #noalign continuous_map.compact_convergence_filter_basis #noalign continuous_map.mem_compact_convergence_nhd_filter #noalign continuous_map.compact_convergence_topology #noalign continuous_map.nhds_compact_convergence #noalign continuous_map.has_basis_nhds_compact_convergence #noalign continuous_map.tendsto_iff_forall_compact_tendsto_uniformly_on' #noalign continuous_map.compact_conv_nhd_subset_compact_open #noalign continuous_map.Inter_compact_open_gen_subset_compact_conv_nhd #noalign continuous_map.compact_open_eq_compact_convergence #noalign continuous_map.compact_convergence_uniformity #noalign continuous_map.has_basis_compact_convergence_uniformity_aux #noalign continuous_map.mem_compact_convergence_uniformity theorem _root_.Filter.HasBasis.compactConvergenceUniformity {ι : Type*} {pi : ι → Prop} {s : ι → Set (β × β)} (h : (𝓤 β).HasBasis pi s) : HasBasis (𝓤 C(α, β)) (fun p : Set α × ι => IsCompact p.1 ∧ pi p.2) fun p => { fg : C(α, β) × C(α, β) | ∀ x ∈ p.1, (fg.1 x, fg.2 x) ∈ s p.2 } := by rw [← uniformEmbedding_toUniformOnFunIsCompact.comap_uniformity] exact .comap _ <| UniformOnFun.hasBasis_uniformity_of_basis _ _ {K | IsCompact K} ⟨∅, isCompact_empty⟩ (directedOn_of_sup_mem fun _ _ ↦ IsCompact.union) h #align filter.has_basis.compact_convergence_uniformity Filter.HasBasis.compactConvergenceUniformity theorem hasBasis_compactConvergenceUniformity : HasBasis (𝓤 C(α, β)) (fun p : Set α × Set (β × β) => IsCompact p.1 ∧ p.2 ∈ 𝓤 β) fun p => { fg : C(α, β) × C(α, β) | ∀ x ∈ p.1, (fg.1 x, fg.2 x) ∈ p.2 } := (basis_sets _).compactConvergenceUniformity #align continuous_map.has_basis_compact_convergence_uniformity ContinuousMap.hasBasis_compactConvergenceUniformity theorem mem_compactConvergence_entourage_iff (X : Set (C(α, β) × C(α, β))) : X ∈ 𝓤 C(α, β) ↔ ∃ (K : Set α) (V : Set (β × β)), IsCompact K ∧ V ∈ 𝓤 β ∧ { fg : C(α, β) × C(α, β) | ∀ x ∈ K, (fg.1 x, fg.2 x) ∈ V } ⊆ X := by simp [hasBasis_compactConvergenceUniformity.mem_iff, and_assoc] #align continuous_map.mem_compact_convergence_entourage_iff ContinuousMap.mem_compactConvergence_entourage_iff theorem _root_.CompactExhaustion.hasBasis_compactConvergenceUniformity {ι : Type*} {p : ι → Prop} {V : ι → Set (β × β)} (K : CompactExhaustion α) (hb : (𝓤 β).HasBasis p V) : HasBasis (𝓤 C(α, β)) (fun i : ℕ × ι ↦ p i.2) fun i ↦ {fg | ∀ x ∈ K i.1, (fg.1 x, fg.2 x) ∈ V i.2} := (UniformOnFun.hasBasis_uniformity_of_covering_of_basis {K | IsCompact K} K.isCompact (Monotone.directed_le K.subset) (fun _ ↦ K.exists_superset_of_isCompact) hb).comap _ theorem _root_.CompactExhaustion.hasAntitoneBasis_compactConvergenceUniformity {V : ℕ → Set (β × β)} (K : CompactExhaustion α) (hb : (𝓤 β).HasAntitoneBasis V) : HasAntitoneBasis (𝓤 C(α, β)) fun n ↦ {fg | ∀ x ∈ K n, (fg.1 x, fg.2 x) ∈ V n} := (UniformOnFun.hasAntitoneBasis_uniformity {K | IsCompact K} K.isCompact K.subset (fun _ ↦ K.exists_superset_of_isCompact) hb).comap _ instance [WeaklyLocallyCompactSpace α] [SigmaCompactSpace α] [IsCountablyGenerated (𝓤 β)] : IsCountablyGenerated (𝓤 (C(α, β))) := let ⟨_V, hV⟩ := exists_antitone_basis (𝓤 β) ((CompactExhaustion.choice α).hasAntitoneBasis_compactConvergenceUniformity hV).isCountablyGenerated variable {ι : Type u₃} {p : Filter ι} {F : ι → C(α, β)} {f} theorem tendsto_of_tendstoLocallyUniformly (h : TendstoLocallyUniformly (fun i a => F i a) f p) : Tendsto F p (𝓝 f) := by rw [tendsto_iff_forall_compact_tendstoUniformlyOn] intro K hK rw [← tendstoLocallyUniformlyOn_iff_tendstoUniformlyOn_of_compact hK] exact h.tendstoLocallyUniformlyOn #align continuous_map.tendsto_of_tendsto_locally_uniformly ContinuousMap.tendsto_of_tendstoLocallyUniformly theorem tendsto_iff_tendstoLocallyUniformly [WeaklyLocallyCompactSpace α] : Tendsto F p (𝓝 f) ↔ TendstoLocallyUniformly (fun i a => F i a) f p := by refine ⟨fun h V hV x ↦ ?_, tendsto_of_tendstoLocallyUniformly⟩ rw [tendsto_iff_forall_compact_tendstoUniformlyOn] at h obtain ⟨n, hn₁, hn₂⟩ := exists_compact_mem_nhds x exact ⟨n, hn₂, h n hn₁ V hV⟩ #align continuous_map.tendsto_iff_tendsto_locally_uniformly ContinuousMap.tendsto_iff_tendstoLocallyUniformly @[deprecated tendsto_iff_tendstoLocallyUniformly (since := "2023-09-03")] theorem tendstoLocallyUniformly_of_tendsto [WeaklyLocallyCompactSpace α] (h : Tendsto F p (𝓝 f)) : TendstoLocallyUniformly (fun i a => F i a) f p := tendsto_iff_tendstoLocallyUniformly.1 h #align continuous_map.tendsto_locally_uniformly_of_tendsto ContinuousMap.tendstoLocallyUniformly_of_tendsto
Mathlib/Topology/UniformSpace/CompactConvergence.lean
348
369
theorem uniformSpace_eq_inf_precomp_of_cover {δ₁ δ₂ : Type*} [TopologicalSpace δ₁] [TopologicalSpace δ₂] (φ₁ : C(δ₁, α)) (φ₂ : C(δ₂, α)) (h_proper₁ : IsProperMap φ₁) (h_proper₂ : IsProperMap φ₂) (h_cover : range φ₁ ∪ range φ₂ = univ) : (inferInstanceAs <| UniformSpace C(α, β)) = .comap (comp · φ₁) inferInstance ⊓ .comap (comp · φ₂) inferInstance := by
-- We check the analogous result for `UniformOnFun` using -- `UniformOnFun.uniformSpace_eq_inf_precomp_of_cover`... set 𝔖 : Set (Set α) := {K | IsCompact K} set 𝔗₁ : Set (Set δ₁) := {K | IsCompact K} set 𝔗₂ : Set (Set δ₂) := {K | IsCompact K} have h_image₁ : MapsTo (φ₁ '' ·) 𝔗₁ 𝔖 := fun K hK ↦ hK.image φ₁.continuous have h_image₂ : MapsTo (φ₂ '' ·) 𝔗₂ 𝔖 := fun K hK ↦ hK.image φ₂.continuous have h_preimage₁ : MapsTo (φ₁ ⁻¹' ·) 𝔖 𝔗₁ := fun K ↦ h_proper₁.isCompact_preimage have h_preimage₂ : MapsTo (φ₂ ⁻¹' ·) 𝔖 𝔗₂ := fun K ↦ h_proper₂.isCompact_preimage have h_cover' : ∀ S ∈ 𝔖, S ⊆ range φ₁ ∪ range φ₂ := fun S _ ↦ h_cover ▸ subset_univ _ -- ... and we just pull it back. simp_rw [compactConvergenceUniformSpace, replaceTopology_eq, inferInstanceAs, inferInstance, UniformOnFun.uniformSpace_eq_inf_precomp_of_cover _ _ _ _ _ h_image₁ h_image₂ h_preimage₁ h_preimage₂ h_cover', UniformSpace.comap_inf, ← UniformSpace.comap_comap] rfl
import Mathlib.Algebra.Algebra.Defs import Mathlib.Algebra.Polynomial.FieldDivision import Mathlib.FieldTheory.Minpoly.Basic import Mathlib.RingTheory.Adjoin.Basic import Mathlib.RingTheory.FinitePresentation import Mathlib.RingTheory.FiniteType import Mathlib.RingTheory.PowerBasis import Mathlib.RingTheory.PrincipalIdealDomain import Mathlib.RingTheory.QuotientNoetherian #align_import ring_theory.adjoin_root from "leanprover-community/mathlib"@"5c4b3d41a84bd2a1d79c7d9265e58a891e71be89" noncomputable section open scoped Classical open Polynomial universe u v w variable {R : Type u} {S : Type v} {K : Type w} open Polynomial Ideal def AdjoinRoot [CommRing R] (f : R[X]) : Type u := Polynomial R ⧸ (span {f} : Ideal R[X]) #align adjoin_root AdjoinRoot namespace AdjoinRoot section CommRing variable [CommRing R] (f : R[X]) instance instCommRing : CommRing (AdjoinRoot f) := Ideal.Quotient.commRing _ #align adjoin_root.comm_ring AdjoinRoot.instCommRing instance : Inhabited (AdjoinRoot f) := ⟨0⟩ instance : DecidableEq (AdjoinRoot f) := Classical.decEq _ protected theorem nontrivial [IsDomain R] (h : degree f ≠ 0) : Nontrivial (AdjoinRoot f) := Ideal.Quotient.nontrivial (by simp_rw [Ne, span_singleton_eq_top, Polynomial.isUnit_iff, not_exists, not_and] rintro x hx rfl exact h (degree_C hx.ne_zero)) #align adjoin_root.nontrivial AdjoinRoot.nontrivial def mk : R[X] →+* AdjoinRoot f := Ideal.Quotient.mk _ #align adjoin_root.mk AdjoinRoot.mk @[elab_as_elim] theorem induction_on {C : AdjoinRoot f → Prop} (x : AdjoinRoot f) (ih : ∀ p : R[X], C (mk f p)) : C x := Quotient.inductionOn' x ih #align adjoin_root.induction_on AdjoinRoot.induction_on def of : R →+* AdjoinRoot f := (mk f).comp C #align adjoin_root.of AdjoinRoot.of instance instSMulAdjoinRoot [DistribSMul S R] [IsScalarTower S R R] : SMul S (AdjoinRoot f) := Submodule.Quotient.instSMul' _ instance [DistribSMul S R] [IsScalarTower S R R] : DistribSMul S (AdjoinRoot f) := Submodule.Quotient.distribSMul' _ @[simp] theorem smul_mk [DistribSMul S R] [IsScalarTower S R R] (a : S) (x : R[X]) : a • mk f x = mk f (a • x) := rfl #align adjoin_root.smul_mk AdjoinRoot.smul_mk theorem smul_of [DistribSMul S R] [IsScalarTower S R R] (a : S) (x : R) : a • of f x = of f (a • x) := by rw [of, RingHom.comp_apply, RingHom.comp_apply, smul_mk, smul_C] #align adjoin_root.smul_of AdjoinRoot.smul_of instance (R₁ R₂ : Type*) [SMul R₁ R₂] [DistribSMul R₁ R] [DistribSMul R₂ R] [IsScalarTower R₁ R R] [IsScalarTower R₂ R R] [IsScalarTower R₁ R₂ R] (f : R[X]) : IsScalarTower R₁ R₂ (AdjoinRoot f) := Submodule.Quotient.isScalarTower _ _ instance (R₁ R₂ : Type*) [DistribSMul R₁ R] [DistribSMul R₂ R] [IsScalarTower R₁ R R] [IsScalarTower R₂ R R] [SMulCommClass R₁ R₂ R] (f : R[X]) : SMulCommClass R₁ R₂ (AdjoinRoot f) := Submodule.Quotient.smulCommClass _ _ instance isScalarTower_right [DistribSMul S R] [IsScalarTower S R R] : IsScalarTower S (AdjoinRoot f) (AdjoinRoot f) := Ideal.Quotient.isScalarTower_right #align adjoin_root.is_scalar_tower_right AdjoinRoot.isScalarTower_right instance [Monoid S] [DistribMulAction S R] [IsScalarTower S R R] (f : R[X]) : DistribMulAction S (AdjoinRoot f) := Submodule.Quotient.distribMulAction' _ instance [CommSemiring S] [Algebra S R] : Algebra S (AdjoinRoot f) := Ideal.Quotient.algebra S @[simp] theorem algebraMap_eq : algebraMap R (AdjoinRoot f) = of f := rfl #align adjoin_root.algebra_map_eq AdjoinRoot.algebraMap_eq variable (S) theorem algebraMap_eq' [CommSemiring S] [Algebra S R] : algebraMap S (AdjoinRoot f) = (of f).comp (algebraMap S R) := rfl #align adjoin_root.algebra_map_eq' AdjoinRoot.algebraMap_eq' variable {S} theorem finiteType : Algebra.FiniteType R (AdjoinRoot f) := (Algebra.FiniteType.polynomial R).of_surjective _ (Ideal.Quotient.mkₐ_surjective R _) #align adjoin_root.finite_type AdjoinRoot.finiteType theorem finitePresentation : Algebra.FinitePresentation R (AdjoinRoot f) := (Algebra.FinitePresentation.polynomial R).quotient (Submodule.fg_span_singleton f) #align adjoin_root.finite_presentation AdjoinRoot.finitePresentation def root : AdjoinRoot f := mk f X #align adjoin_root.root AdjoinRoot.root variable {f} instance hasCoeT : CoeTC R (AdjoinRoot f) := ⟨of f⟩ #align adjoin_root.has_coe_t AdjoinRoot.hasCoeT @[ext] theorem algHom_ext [Semiring S] [Algebra R S] {g₁ g₂ : AdjoinRoot f →ₐ[R] S} (h : g₁ (root f) = g₂ (root f)) : g₁ = g₂ := Ideal.Quotient.algHom_ext R <| Polynomial.algHom_ext h #align adjoin_root.alg_hom_ext AdjoinRoot.algHom_ext @[simp] theorem mk_eq_mk {g h : R[X]} : mk f g = mk f h ↔ f ∣ g - h := Ideal.Quotient.eq.trans Ideal.mem_span_singleton #align adjoin_root.mk_eq_mk AdjoinRoot.mk_eq_mk @[simp] theorem mk_eq_zero {g : R[X]} : mk f g = 0 ↔ f ∣ g := mk_eq_mk.trans <| by rw [sub_zero] #align adjoin_root.mk_eq_zero AdjoinRoot.mk_eq_zero @[simp] theorem mk_self : mk f f = 0 := Quotient.sound' <| QuotientAddGroup.leftRel_apply.mpr (mem_span_singleton.2 <| by simp) #align adjoin_root.mk_self AdjoinRoot.mk_self @[simp] theorem mk_C (x : R) : mk f (C x) = x := rfl set_option linter.uppercaseLean3 false in #align adjoin_root.mk_C AdjoinRoot.mk_C @[simp] theorem mk_X : mk f X = root f := rfl set_option linter.uppercaseLean3 false in #align adjoin_root.mk_X AdjoinRoot.mk_X theorem mk_ne_zero_of_degree_lt (hf : Monic f) {g : R[X]} (h0 : g ≠ 0) (hd : degree g < degree f) : mk f g ≠ 0 := mk_eq_zero.not.2 <| hf.not_dvd_of_degree_lt h0 hd #align adjoin_root.mk_ne_zero_of_degree_lt AdjoinRoot.mk_ne_zero_of_degree_lt theorem mk_ne_zero_of_natDegree_lt (hf : Monic f) {g : R[X]} (h0 : g ≠ 0) (hd : natDegree g < natDegree f) : mk f g ≠ 0 := mk_eq_zero.not.2 <| hf.not_dvd_of_natDegree_lt h0 hd #align adjoin_root.mk_ne_zero_of_nat_degree_lt AdjoinRoot.mk_ne_zero_of_natDegree_lt @[simp] theorem aeval_eq (p : R[X]) : aeval (root f) p = mk f p := Polynomial.induction_on p (fun x => by rw [aeval_C] rfl) (fun p q ihp ihq => by rw [AlgHom.map_add, RingHom.map_add, ihp, ihq]) fun n x _ => by rw [AlgHom.map_mul, aeval_C, AlgHom.map_pow, aeval_X, RingHom.map_mul, mk_C, RingHom.map_pow, mk_X] rfl #align adjoin_root.aeval_eq AdjoinRoot.aeval_eq -- Porting note: the following proof was partly in term-mode, but I was not able to fix it. theorem adjoinRoot_eq_top : Algebra.adjoin R ({root f} : Set (AdjoinRoot f)) = ⊤ := by refine Algebra.eq_top_iff.2 fun x => ?_ induction x using AdjoinRoot.induction_on with | ih p => exact (Algebra.adjoin_singleton_eq_range_aeval R (root f)).symm ▸ ⟨p, aeval_eq p⟩ #align adjoin_root.adjoin_root_eq_top AdjoinRoot.adjoinRoot_eq_top @[simp] theorem eval₂_root (f : R[X]) : f.eval₂ (of f) (root f) = 0 := by rw [← algebraMap_eq, ← aeval_def, aeval_eq, mk_self] #align adjoin_root.eval₂_root AdjoinRoot.eval₂_root theorem isRoot_root (f : R[X]) : IsRoot (f.map (of f)) (root f) := by rw [IsRoot, eval_map, eval₂_root] #align adjoin_root.is_root_root AdjoinRoot.isRoot_root theorem isAlgebraic_root (hf : f ≠ 0) : IsAlgebraic R (root f) := ⟨f, hf, eval₂_root f⟩ #align adjoin_root.is_algebraic_root AdjoinRoot.isAlgebraic_root theorem of.injective_of_degree_ne_zero [IsDomain R] (hf : f.degree ≠ 0) : Function.Injective (AdjoinRoot.of f) := by rw [injective_iff_map_eq_zero] intro p hp rw [AdjoinRoot.of, RingHom.comp_apply, AdjoinRoot.mk_eq_zero] at hp by_cases h : f = 0 · exact C_eq_zero.mp (eq_zero_of_zero_dvd (by rwa [h] at hp)) · contrapose! hf with h_contra rw [← degree_C h_contra] apply le_antisymm (degree_le_of_dvd hp (by rwa [Ne, C_eq_zero])) _ rwa [degree_C h_contra, zero_le_degree_iff] #align adjoin_root.of.injective_of_degree_ne_zero AdjoinRoot.of.injective_of_degree_ne_zero variable [CommRing S] def lift (i : R →+* S) (x : S) (h : f.eval₂ i x = 0) : AdjoinRoot f →+* S := by apply Ideal.Quotient.lift _ (eval₂RingHom i x) intro g H rcases mem_span_singleton.1 H with ⟨y, hy⟩ rw [hy, RingHom.map_mul, coe_eval₂RingHom, h, zero_mul] #align adjoin_root.lift AdjoinRoot.lift variable {i : R →+* S} {a : S} (h : f.eval₂ i a = 0) @[simp] theorem lift_mk (g : R[X]) : lift i a h (mk f g) = g.eval₂ i a := Ideal.Quotient.lift_mk _ _ _ #align adjoin_root.lift_mk AdjoinRoot.lift_mk @[simp] theorem lift_root : lift i a h (root f) = a := by rw [root, lift_mk, eval₂_X] #align adjoin_root.lift_root AdjoinRoot.lift_root @[simp] theorem lift_of {x : R} : lift i a h x = i x := by rw [← mk_C x, lift_mk, eval₂_C] #align adjoin_root.lift_of AdjoinRoot.lift_of @[simp] theorem lift_comp_of : (lift i a h).comp (of f) = i := RingHom.ext fun _ => @lift_of _ _ _ _ _ _ _ h _ #align adjoin_root.lift_comp_of AdjoinRoot.lift_comp_of variable (f) [Algebra R S] def liftHom (x : S) (hfx : aeval x f = 0) : AdjoinRoot f →ₐ[R] S := { lift (algebraMap R S) x hfx with commutes' := fun r => show lift _ _ hfx r = _ from lift_of hfx } #align adjoin_root.lift_hom AdjoinRoot.liftHom @[simp] theorem coe_liftHom (x : S) (hfx : aeval x f = 0) : (liftHom f x hfx : AdjoinRoot f →+* S) = lift (algebraMap R S) x hfx := rfl #align adjoin_root.coe_lift_hom AdjoinRoot.coe_liftHom @[simp] theorem aeval_algHom_eq_zero (ϕ : AdjoinRoot f →ₐ[R] S) : aeval (ϕ (root f)) f = 0 := by have h : ϕ.toRingHom.comp (of f) = algebraMap R S := RingHom.ext_iff.mpr ϕ.commutes rw [aeval_def, ← h, ← RingHom.map_zero ϕ.toRingHom, ← eval₂_root f, hom_eval₂] rfl #align adjoin_root.aeval_alg_hom_eq_zero AdjoinRoot.aeval_algHom_eq_zero @[simp] theorem liftHom_eq_algHom (f : R[X]) (ϕ : AdjoinRoot f →ₐ[R] S) : liftHom f (ϕ (root f)) (aeval_algHom_eq_zero f ϕ) = ϕ := by suffices ϕ.equalizer (liftHom f (ϕ (root f)) (aeval_algHom_eq_zero f ϕ)) = ⊤ by exact (AlgHom.ext fun x => (SetLike.ext_iff.mp this x).mpr Algebra.mem_top).symm rw [eq_top_iff, ← adjoinRoot_eq_top, Algebra.adjoin_le_iff, Set.singleton_subset_iff] exact (@lift_root _ _ _ _ _ _ _ (aeval_algHom_eq_zero f ϕ)).symm #align adjoin_root.lift_hom_eq_alg_hom AdjoinRoot.liftHom_eq_algHom variable (hfx : aeval a f = 0) @[simp] theorem liftHom_mk {g : R[X]} : liftHom f a hfx (mk f g) = aeval a g := lift_mk hfx g #align adjoin_root.lift_hom_mk AdjoinRoot.liftHom_mk @[simp] theorem liftHom_root : liftHom f a hfx (root f) = a := lift_root hfx #align adjoin_root.lift_hom_root AdjoinRoot.liftHom_root @[simp] theorem liftHom_of {x : R} : liftHom f a hfx (of f x) = algebraMap _ _ x := lift_of hfx #align adjoin_root.lift_hom_of AdjoinRoot.liftHom_of section Equiv -- Porting note: consider splitting the file here. In the current mathlib3, the only result -- that depends any of these lemmas was -- `normalizedFactorsMapEquivNormalizedFactorsMinPolyMk` in `NumberTheory.KummerDedekind` -- that uses -- `PowerBasis.quotientEquivQuotientMinpolyMap == PowerBasis.quotientEquivQuotientMinpolyMap` section open Ideal DoubleQuot Polynomial variable [CommRing R] (I : Ideal R) (f : R[X]) def quotMapOfEquivQuotMapCMapSpanMk : AdjoinRoot f ⧸ I.map (of f) ≃+* AdjoinRoot f ⧸ (I.map (C : R →+* R[X])).map (Ideal.Quotient.mk (span {f})) := Ideal.quotEquivOfEq (by rw [of, AdjoinRoot.mk, Ideal.map_map]) set_option linter.uppercaseLean3 false in #align adjoin_root.quot_map_of_equiv_quot_map_C_map_span_mk AdjoinRoot.quotMapOfEquivQuotMapCMapSpanMk @[simp] theorem quotMapOfEquivQuotMapCMapSpanMk_mk (x : AdjoinRoot f) : quotMapOfEquivQuotMapCMapSpanMk I f (Ideal.Quotient.mk (I.map (of f)) x) = Ideal.Quotient.mk (Ideal.map (Ideal.Quotient.mk (span {f})) (I.map (C : R →+* R[X]))) x := rfl set_option linter.uppercaseLean3 false in #align adjoin_root.quot_map_of_equiv_quot_map_C_map_span_mk_mk AdjoinRoot.quotMapOfEquivQuotMapCMapSpanMk_mk --this lemma should have the simp tag but this causes a lint issue theorem quotMapOfEquivQuotMapCMapSpanMk_symm_mk (x : AdjoinRoot f) : (quotMapOfEquivQuotMapCMapSpanMk I f).symm (Ideal.Quotient.mk ((I.map (C : R →+* R[X])).map (Ideal.Quotient.mk (span {f}))) x) = Ideal.Quotient.mk (I.map (of f)) x := by rw [quotMapOfEquivQuotMapCMapSpanMk, Ideal.quotEquivOfEq_symm] exact Ideal.quotEquivOfEq_mk _ _ set_option linter.uppercaseLean3 false in #align adjoin_root.quot_map_of_equiv_quot_map_C_map_span_mk_symm_mk AdjoinRoot.quotMapOfEquivQuotMapCMapSpanMk_symm_mk def quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk : AdjoinRoot f ⧸ (I.map (C : R →+* R[X])).map (Ideal.Quotient.mk (span ({f} : Set R[X]))) ≃+* (R[X] ⧸ I.map (C : R →+* R[X])) ⧸ (span ({f} : Set R[X])).map (Ideal.Quotient.mk (I.map (C : R →+* R[X]))) := quotQuotEquivComm (Ideal.span ({f} : Set R[X])) (I.map (C : R →+* R[X])) set_option linter.uppercaseLean3 false in #align adjoin_root.quot_map_C_map_span_mk_equiv_quot_map_C_quot_map_span_mk AdjoinRoot.quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk -- This lemma should have the simp tag but this causes a lint issue. theorem quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk_mk (p : R[X]) : quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk I f (Ideal.Quotient.mk _ (mk f p)) = quotQuotMk (I.map C) (span {f}) p := rfl set_option linter.uppercaseLean3 false in #align adjoin_root.quot_map_C_map_span_mk_equiv_quot_map_C_quot_map_span_mk_mk AdjoinRoot.quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk_mk @[simp] theorem quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk_symm_quotQuotMk (p : R[X]) : (quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk I f).symm (quotQuotMk (I.map C) (span {f}) p) = Ideal.Quotient.mk (Ideal.map (Ideal.Quotient.mk (span {f})) (I.map (C : R →+* R[X]))) (mk f p) := rfl set_option linter.uppercaseLean3 false in #align adjoin_root.quot_map_C_map_span_mk_equiv_quot_map_C_quot_map_span_mk_symm_quot_quot_mk AdjoinRoot.quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk_symm_quotQuotMk def Polynomial.quotQuotEquivComm : (R ⧸ I)[X] ⧸ span ({f.map (Ideal.Quotient.mk I)} : Set (Polynomial (R ⧸ I))) ≃+* (R[X] ⧸ (I.map C)) ⧸ span ({(Ideal.Quotient.mk (I.map C)) f} : Set (R[X] ⧸ (I.map C))) := quotientEquiv (span ({f.map (Ideal.Quotient.mk I)} : Set (Polynomial (R ⧸ I)))) (span {Ideal.Quotient.mk (I.map Polynomial.C) f}) (polynomialQuotientEquivQuotientPolynomial I) (by rw [map_span, Set.image_singleton, RingEquiv.coe_toRingHom, polynomialQuotientEquivQuotientPolynomial_map_mk I f]) #align adjoin_root.polynomial.quot_quot_equiv_comm AdjoinRoot.Polynomial.quotQuotEquivComm @[simp]
Mathlib/RingTheory/AdjoinRoot.lean
786
791
theorem Polynomial.quotQuotEquivComm_mk (p : R[X]) : (Polynomial.quotQuotEquivComm I f) (Ideal.Quotient.mk _ (p.map (Ideal.Quotient.mk I))) = Ideal.Quotient.mk (span ({(Ideal.Quotient.mk (I.map C)) f} : Set (R[X] ⧸ (I.map C)))) (Ideal.Quotient.mk (I.map C) p) := by
simp only [Polynomial.quotQuotEquivComm, quotientEquiv_mk, polynomialQuotientEquivQuotientPolynomial_map_mk]
import Mathlib.Data.Matrix.Block import Mathlib.Data.Matrix.Notation import Mathlib.Data.Matrix.RowCol import Mathlib.GroupTheory.GroupAction.Ring import Mathlib.GroupTheory.Perm.Fin import Mathlib.LinearAlgebra.Alternating.Basic #align_import linear_algebra.matrix.determinant from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395" universe u v w z open Equiv Equiv.Perm Finset Function namespace Matrix open Matrix variable {m n : Type*} [DecidableEq n] [Fintype n] [DecidableEq m] [Fintype m] variable {R : Type v} [CommRing R] local notation "ε " σ:arg => ((sign σ : ℤ) : R) def detRowAlternating : (n → R) [⋀^n]→ₗ[R] R := MultilinearMap.alternatization ((MultilinearMap.mkPiAlgebra R n R).compLinearMap LinearMap.proj) #align matrix.det_row_alternating Matrix.detRowAlternating abbrev det (M : Matrix n n R) : R := detRowAlternating M #align matrix.det Matrix.det theorem det_apply (M : Matrix n n R) : M.det = ∑ σ : Perm n, Equiv.Perm.sign σ • ∏ i, M (σ i) i := MultilinearMap.alternatization_apply _ M #align matrix.det_apply Matrix.det_apply -- This is what the old definition was. We use it to avoid having to change the old proofs below theorem det_apply' (M : Matrix n n R) : M.det = ∑ σ : Perm n, ε σ * ∏ i, M (σ i) i := by simp [det_apply, Units.smul_def] #align matrix.det_apply' Matrix.det_apply' @[simp] theorem det_diagonal {d : n → R} : det (diagonal d) = ∏ i, d i := by rw [det_apply'] refine (Finset.sum_eq_single 1 ?_ ?_).trans ?_ · rintro σ - h2 cases' not_forall.1 (mt Equiv.ext h2) with x h3 convert mul_zero (ε σ) apply Finset.prod_eq_zero (mem_univ x) exact if_neg h3 · simp · simp #align matrix.det_diagonal Matrix.det_diagonal -- @[simp] -- Porting note (#10618): simp can prove this theorem det_zero (_ : Nonempty n) : det (0 : Matrix n n R) = 0 := (detRowAlternating : (n → R) [⋀^n]→ₗ[R] R).map_zero #align matrix.det_zero Matrix.det_zero @[simp] theorem det_one : det (1 : Matrix n n R) = 1 := by rw [← diagonal_one]; simp [-diagonal_one] #align matrix.det_one Matrix.det_one theorem det_isEmpty [IsEmpty n] {A : Matrix n n R} : det A = 1 := by simp [det_apply] #align matrix.det_is_empty Matrix.det_isEmpty @[simp] theorem coe_det_isEmpty [IsEmpty n] : (det : Matrix n n R → R) = Function.const _ 1 := by ext exact det_isEmpty #align matrix.coe_det_is_empty Matrix.coe_det_isEmpty theorem det_eq_one_of_card_eq_zero {A : Matrix n n R} (h : Fintype.card n = 0) : det A = 1 := haveI : IsEmpty n := Fintype.card_eq_zero_iff.mp h det_isEmpty #align matrix.det_eq_one_of_card_eq_zero Matrix.det_eq_one_of_card_eq_zero @[simp] theorem det_unique {n : Type*} [Unique n] [DecidableEq n] [Fintype n] (A : Matrix n n R) : det A = A default default := by simp [det_apply, univ_unique] #align matrix.det_unique Matrix.det_unique theorem det_eq_elem_of_subsingleton [Subsingleton n] (A : Matrix n n R) (k : n) : det A = A k k := by have := uniqueOfSubsingleton k convert det_unique A #align matrix.det_eq_elem_of_subsingleton Matrix.det_eq_elem_of_subsingleton theorem det_eq_elem_of_card_eq_one {A : Matrix n n R} (h : Fintype.card n = 1) (k : n) : det A = A k k := haveI : Subsingleton n := Fintype.card_le_one_iff_subsingleton.mp h.le det_eq_elem_of_subsingleton _ _ #align matrix.det_eq_elem_of_card_eq_one Matrix.det_eq_elem_of_card_eq_one theorem det_mul_aux {M N : Matrix n n R} {p : n → n} (H : ¬Bijective p) : (∑ σ : Perm n, ε σ * ∏ x, M (σ x) (p x) * N (p x) x) = 0 := by obtain ⟨i, j, hpij, hij⟩ : ∃ i j, p i = p j ∧ i ≠ j := by rw [← Finite.injective_iff_bijective, Injective] at H push_neg at H exact H exact sum_involution (fun σ _ => σ * Equiv.swap i j) (fun σ _ => by have : (∏ x, M (σ x) (p x)) = ∏ x, M ((σ * Equiv.swap i j) x) (p x) := Fintype.prod_equiv (swap i j) _ _ (by simp [apply_swap_eq_self hpij]) simp [this, sign_swap hij, -sign_swap', prod_mul_distrib]) (fun σ _ _ => (not_congr mul_swap_eq_iff).mpr hij) (fun _ _ => mem_univ _) fun σ _ => mul_swap_involutive i j σ #align matrix.det_mul_aux Matrix.det_mul_aux @[simp] theorem det_mul (M N : Matrix n n R) : det (M * N) = det M * det N := calc det (M * N) = ∑ p : n → n, ∑ σ : Perm n, ε σ * ∏ i, M (σ i) (p i) * N (p i) i := by simp only [det_apply', mul_apply, prod_univ_sum, mul_sum, Fintype.piFinset_univ] rw [Finset.sum_comm] _ = ∑ p ∈ (@univ (n → n) _).filter Bijective, ∑ σ : Perm n, ε σ * ∏ i, M (σ i) (p i) * N (p i) i := (Eq.symm <| sum_subset (filter_subset _ _) fun f _ hbij => det_mul_aux <| by simpa only [true_and_iff, mem_filter, mem_univ] using hbij) _ = ∑ τ : Perm n, ∑ σ : Perm n, ε σ * ∏ i, M (σ i) (τ i) * N (τ i) i := sum_bij (fun p h ↦ Equiv.ofBijective p (mem_filter.1 h).2) (fun _ _ ↦ mem_univ _) (fun _ _ _ _ h ↦ by injection h) (fun b _ ↦ ⟨b, mem_filter.2 ⟨mem_univ _, b.bijective⟩, coe_fn_injective rfl⟩) fun _ _ ↦ rfl _ = ∑ σ : Perm n, ∑ τ : Perm n, (∏ i, N (σ i) i) * ε τ * ∏ j, M (τ j) (σ j) := by simp only [mul_comm, mul_left_comm, prod_mul_distrib, mul_assoc] _ = ∑ σ : Perm n, ∑ τ : Perm n, (∏ i, N (σ i) i) * (ε σ * ε τ) * ∏ i, M (τ i) i := (sum_congr rfl fun σ _ => Fintype.sum_equiv (Equiv.mulRight σ⁻¹) _ _ fun τ => by have : (∏ j, M (τ j) (σ j)) = ∏ j, M ((τ * σ⁻¹) j) j := by rw [← (σ⁻¹ : _ ≃ _).prod_comp] simp only [Equiv.Perm.coe_mul, apply_inv_self, Function.comp_apply] have h : ε σ * ε (τ * σ⁻¹) = ε τ := calc ε σ * ε (τ * σ⁻¹) = ε (τ * σ⁻¹ * σ) := by rw [mul_comm, sign_mul (τ * σ⁻¹)] simp only [Int.cast_mul, Units.val_mul] _ = ε τ := by simp only [inv_mul_cancel_right] simp_rw [Equiv.coe_mulRight, h] simp only [this]) _ = det M * det N := by simp only [det_apply', Finset.mul_sum, mul_comm, mul_left_comm, mul_assoc] #align matrix.det_mul Matrix.det_mul def detMonoidHom : Matrix n n R →* R where toFun := det map_one' := det_one map_mul' := det_mul #align matrix.det_monoid_hom Matrix.detMonoidHom @[simp] theorem coe_detMonoidHom : (detMonoidHom : Matrix n n R → R) = det := rfl #align matrix.coe_det_monoid_hom Matrix.coe_detMonoidHom theorem det_mul_comm (M N : Matrix m m R) : det (M * N) = det (N * M) := by rw [det_mul, det_mul, mul_comm] #align matrix.det_mul_comm Matrix.det_mul_comm
Mathlib/LinearAlgebra/Matrix/Determinant/Basic.lean
199
200
theorem det_mul_left_comm (M N P : Matrix m m R) : det (M * (N * P)) = det (N * (M * P)) := by
rw [← Matrix.mul_assoc, ← Matrix.mul_assoc, det_mul, det_mul_comm M N, ← det_mul]
import Mathlib.ModelTheory.FinitelyGenerated import Mathlib.ModelTheory.DirectLimit import Mathlib.ModelTheory.Bundled #align_import model_theory.fraisse from "leanprover-community/mathlib"@"0602c59878ff3d5f71dea69c2d32ccf2e93e5398" universe u v w w' open scoped FirstOrder open Set CategoryTheory namespace FirstOrder namespace Language open Structure Substructure variable (L : Language.{u, v}) def age (M : Type w) [L.Structure M] : Set (Bundled.{w} L.Structure) := {N | Structure.FG L N ∧ Nonempty (N ↪[L] M)} #align first_order.language.age FirstOrder.Language.age variable {L} (K : Set (Bundled.{w} L.Structure)) def Hereditary : Prop := ∀ M : Bundled.{w} L.Structure, M ∈ K → L.age M ⊆ K #align first_order.language.hereditary FirstOrder.Language.Hereditary def JointEmbedding : Prop := DirectedOn (fun M N : Bundled.{w} L.Structure => Nonempty (M ↪[L] N)) K #align first_order.language.joint_embedding FirstOrder.Language.JointEmbedding def Amalgamation : Prop := ∀ (M N P : Bundled.{w} L.Structure) (MN : M ↪[L] N) (MP : M ↪[L] P), M ∈ K → N ∈ K → P ∈ K → ∃ (Q : Bundled.{w} L.Structure) (NQ : N ↪[L] Q) (PQ : P ↪[L] Q), Q ∈ K ∧ NQ.comp MN = PQ.comp MP #align first_order.language.amalgamation FirstOrder.Language.Amalgamation class IsFraisse : Prop where is_nonempty : K.Nonempty FG : ∀ M : Bundled.{w} L.Structure, M ∈ K → Structure.FG L M is_equiv_invariant : ∀ M N : Bundled.{w} L.Structure, Nonempty (M ≃[L] N) → (M ∈ K ↔ N ∈ K) is_essentially_countable : (Quotient.mk' '' K).Countable hereditary : Hereditary K jointEmbedding : JointEmbedding K amalgamation : Amalgamation K #align first_order.language.is_fraisse FirstOrder.Language.IsFraisse variable {K} (L) (M : Type w) [Structure L M] theorem age.is_equiv_invariant (N P : Bundled.{w} L.Structure) (h : Nonempty (N ≃[L] P)) : N ∈ L.age M ↔ P ∈ L.age M := and_congr h.some.fg_iff ⟨Nonempty.map fun x => Embedding.comp x h.some.symm.toEmbedding, Nonempty.map fun x => Embedding.comp x h.some.toEmbedding⟩ #align first_order.language.age.is_equiv_invariant FirstOrder.Language.age.is_equiv_invariant variable {L} {M} {N : Type w} [Structure L N] theorem Embedding.age_subset_age (MN : M ↪[L] N) : L.age M ⊆ L.age N := fun _ => And.imp_right (Nonempty.map MN.comp) #align first_order.language.embedding.age_subset_age FirstOrder.Language.Embedding.age_subset_age theorem Equiv.age_eq_age (MN : M ≃[L] N) : L.age M = L.age N := le_antisymm MN.toEmbedding.age_subset_age MN.symm.toEmbedding.age_subset_age #align first_order.language.equiv.age_eq_age FirstOrder.Language.Equiv.age_eq_age theorem Structure.FG.mem_age_of_equiv {M N : Bundled L.Structure} (h : Structure.FG L M) (MN : Nonempty (M ≃[L] N)) : N ∈ L.age M := ⟨MN.some.fg_iff.1 h, ⟨MN.some.symm.toEmbedding⟩⟩ set_option linter.uppercaseLean3 false in #align first_order.language.Structure.fg.mem_age_of_equiv FirstOrder.Language.Structure.FG.mem_age_of_equiv theorem Hereditary.is_equiv_invariant_of_fg (h : Hereditary K) (fg : ∀ M : Bundled.{w} L.Structure, M ∈ K → Structure.FG L M) (M N : Bundled.{w} L.Structure) (hn : Nonempty (M ≃[L] N)) : M ∈ K ↔ N ∈ K := ⟨fun MK => h M MK ((fg M MK).mem_age_of_equiv hn), fun NK => h N NK ((fg N NK).mem_age_of_equiv ⟨hn.some.symm⟩)⟩ #align first_order.language.hereditary.is_equiv_invariant_of_fg FirstOrder.Language.Hereditary.is_equiv_invariant_of_fg variable (M) theorem age.nonempty : (L.age M).Nonempty := ⟨Bundled.of (Substructure.closure L (∅ : Set M)), (fg_iff_structure_fg _).1 (fg_closure Set.finite_empty), ⟨Substructure.subtype _⟩⟩ #align first_order.language.age.nonempty FirstOrder.Language.age.nonempty theorem age.hereditary : Hereditary (L.age M) := fun _ hN _ hP => hN.2.some.age_subset_age hP #align first_order.language.age.hereditary FirstOrder.Language.age.hereditary theorem age.jointEmbedding : JointEmbedding (L.age M) := fun _ hN _ hP => ⟨Bundled.of (↥(hN.2.some.toHom.range ⊔ hP.2.some.toHom.range)), ⟨(fg_iff_structure_fg _).1 ((hN.1.range hN.2.some.toHom).sup (hP.1.range hP.2.some.toHom)), ⟨Substructure.subtype _⟩⟩, ⟨Embedding.comp (inclusion le_sup_left) hN.2.some.equivRange.toEmbedding⟩, ⟨Embedding.comp (inclusion le_sup_right) hP.2.some.equivRange.toEmbedding⟩⟩ #align first_order.language.age.joint_embedding FirstOrder.Language.age.jointEmbedding theorem age.countable_quotient [h : Countable M] : (Quotient.mk' '' L.age M).Countable := by classical refine (congr_arg _ (Set.ext <| Quotient.forall.2 fun N => ?_)).mp (countable_range fun s : Finset M => ⟦⟨closure L (s : Set M), inferInstance⟩⟧) constructor · rintro ⟨s, hs⟩ use Bundled.of (closure L (s : Set M)) exact ⟨⟨(fg_iff_structure_fg _).1 (fg_closure s.finite_toSet), ⟨Substructure.subtype _⟩⟩, hs⟩ · simp only [mem_range, Quotient.eq] rintro ⟨P, ⟨⟨s, hs⟩, ⟨PM⟩⟩, hP2⟩ have : P ≈ N := by apply Quotient.eq'.mp; rw [hP2]; rfl -- Porting note: added refine ⟨s.image PM, Setoid.trans (b := P) ?_ this⟩ rw [← Embedding.coe_toHom, Finset.coe_image, closure_image PM.toHom, hs, ← Hom.range_eq_map] exact ⟨PM.equivRange.symm⟩ #align first_order.language.age.countable_quotient FirstOrder.Language.age.countable_quotient -- @[simp] -- Porting note: cannot simplify itself theorem age_directLimit {ι : Type w} [Preorder ι] [IsDirected ι (· ≤ ·)] [Nonempty ι] (G : ι → Type max w w') [∀ i, L.Structure (G i)] (f : ∀ i j, i ≤ j → G i ↪[L] G j) [DirectedSystem G fun i j h => f i j h] : L.age (DirectLimit G f) = ⋃ i : ι, L.age (G i) := by classical ext M simp only [mem_iUnion] constructor · rintro ⟨Mfg, ⟨e⟩⟩ obtain ⟨s, hs⟩ := Mfg.range e.toHom let out := @Quotient.out _ (DirectLimit.setoid G f) obtain ⟨i, hi⟩ := Finset.exists_le (s.image (Sigma.fst ∘ out)) have e' := (DirectLimit.of L ι G f i).equivRange.symm.toEmbedding refine ⟨i, Mfg, ⟨e'.comp ((Substructure.inclusion ?_).comp e.equivRange.toEmbedding)⟩⟩ rw [← hs, closure_le] intro x hx refine ⟨f (out x).1 i (hi (out x).1 (Finset.mem_image_of_mem _ hx)) (out x).2, ?_⟩ rw [Embedding.coe_toHom, DirectLimit.of_apply, @Quotient.mk_eq_iff_out _ (_), DirectLimit.equiv_iff G f _ (hi (out x).1 (Finset.mem_image_of_mem _ hx)), DirectedSystem.map_self] rfl · rintro ⟨i, Mfg, ⟨e⟩⟩ exact ⟨Mfg, ⟨Embedding.comp (DirectLimit.of L ι G f i) e⟩⟩ #align first_order.language.age_direct_limit FirstOrder.Language.age_directLimit
Mathlib/ModelTheory/Fraisse.lean
212
246
theorem exists_cg_is_age_of (hn : K.Nonempty) (h : ∀ M N : Bundled.{w} L.Structure, Nonempty (M ≃[L] N) → (M ∈ K ↔ N ∈ K)) (hc : (Quotient.mk' '' K).Countable) (fg : ∀ M : Bundled.{w} L.Structure, M ∈ K → Structure.FG L M) (hp : Hereditary K) (jep : JointEmbedding K) : ∃ M : Bundled.{w} L.Structure, Structure.CG L M ∧ L.age M = K := by
obtain ⟨F, hF⟩ := hc.exists_eq_range (hn.image _) simp only [Set.ext_iff, Quotient.forall, mem_image, mem_range, Quotient.eq'] at hF simp_rw [Quotient.eq_mk_iff_out] at hF have hF' : ∀ n : ℕ, (F n).out ∈ K := by intro n obtain ⟨P, hP1, hP2⟩ := (hF (F n).out).2 ⟨n, Setoid.refl _⟩ -- Porting note: fix hP2 because `Quotient.out (Quotient.mk' x) ≈ a` was not simplified -- to `x ≈ a` in hF replace hP2 := Setoid.trans (Setoid.symm (Quotient.mk_out P)) hP2 exact (h _ _ hP2).1 hP1 choose P hPK hP hFP using fun (N : K) (n : ℕ) => jep N N.2 (F (n + 1)).out (hF' _) let G : ℕ → K := @Nat.rec (fun _ => K) ⟨(F 0).out, hF' 0⟩ fun n N => ⟨P N n, hPK N n⟩ -- Poting note: was -- let f : ∀ i j, i ≤ j → G i ↪[L] G j := DirectedSystem.natLeRec fun n => (hP _ n).some let f : ∀ (i j : ℕ), i ≤ j → (G i).val ↪[L] (G j).val := by refine DirectedSystem.natLERec (G' := fun i => (G i).val) (L := L) ?_ dsimp only [G] exact fun n => (hP _ n).some have : DirectedSystem (fun n ↦ (G n).val) fun i j h ↦ ↑(f i j h) := by dsimp [f, G]; infer_instance refine ⟨Bundled.of (@DirectLimit L _ _ (fun n ↦ (G n).val) _ f _ _), ?_, ?_⟩ · exact DirectLimit.cg _ (fun n => (fg _ (G n).2).cg) · refine (age_directLimit (fun n ↦ (G n).val) f).trans (subset_antisymm (iUnion_subset fun n N hN => hp (G n).val (G n).2 hN) fun N KN => ?_) have : Quotient.out (Quotient.mk' N) ≈ N := Quotient.eq_mk_iff_out.mp rfl obtain ⟨n, ⟨e⟩⟩ := (hF N).1 ⟨N, KN, this⟩ refine mem_iUnion_of_mem n ⟨fg _ KN, ⟨Embedding.comp ?_ e.symm.toEmbedding⟩⟩ cases' n with n · dsimp [G]; exact Embedding.refl _ _ · dsimp [G]; exact (hFP _ n).some
import Mathlib.MeasureTheory.Constructions.BorelSpace.Order #align_import measure_theory.function.simple_func from "leanprover-community/mathlib"@"bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf" noncomputable section open Set hiding restrict restrict_apply open Filter ENNReal open Function (support) open scoped Classical open Topology NNReal ENNReal MeasureTheory namespace MeasureTheory variable {α β γ δ : Type*} structure SimpleFunc.{u, v} (α : Type u) [MeasurableSpace α] (β : Type v) where toFun : α → β measurableSet_fiber' : ∀ x, MeasurableSet (toFun ⁻¹' {x}) finite_range' : (Set.range toFun).Finite #align measure_theory.simple_func MeasureTheory.SimpleFunc #align measure_theory.simple_func.to_fun MeasureTheory.SimpleFunc.toFun #align measure_theory.simple_func.measurable_set_fiber' MeasureTheory.SimpleFunc.measurableSet_fiber' #align measure_theory.simple_func.finite_range' MeasureTheory.SimpleFunc.finite_range' local infixr:25 " →ₛ " => SimpleFunc namespace SimpleFunc section Measurable variable [MeasurableSpace α] attribute [coe] toFun instance instCoeFun : CoeFun (α →ₛ β) fun _ => α → β := ⟨toFun⟩ #align measure_theory.simple_func.has_coe_to_fun MeasureTheory.SimpleFunc.instCoeFun theorem coe_injective ⦃f g : α →ₛ β⦄ (H : (f : α → β) = g) : f = g := by cases f; cases g; congr #align measure_theory.simple_func.coe_injective MeasureTheory.SimpleFunc.coe_injective @[ext] theorem ext {f g : α →ₛ β} (H : ∀ a, f a = g a) : f = g := coe_injective <| funext H #align measure_theory.simple_func.ext MeasureTheory.SimpleFunc.ext theorem finite_range (f : α →ₛ β) : (Set.range f).Finite := f.finite_range' #align measure_theory.simple_func.finite_range MeasureTheory.SimpleFunc.finite_range theorem measurableSet_fiber (f : α →ₛ β) (x : β) : MeasurableSet (f ⁻¹' {x}) := f.measurableSet_fiber' x #align measure_theory.simple_func.measurable_set_fiber MeasureTheory.SimpleFunc.measurableSet_fiber -- @[simp] -- Porting note (#10618): simp can prove this theorem apply_mk (f : α → β) (h h') (x : α) : SimpleFunc.mk f h h' x = f x := rfl #align measure_theory.simple_func.apply_mk MeasureTheory.SimpleFunc.apply_mk def ofFinite [Finite α] [MeasurableSingletonClass α] (f : α → β) : α →ₛ β where toFun := f measurableSet_fiber' x := (toFinite (f ⁻¹' {x})).measurableSet finite_range' := Set.finite_range f @[deprecated (since := "2024-02-05")] alias ofFintype := ofFinite def ofIsEmpty [IsEmpty α] : α →ₛ β := ofFinite isEmptyElim #align measure_theory.simple_func.of_is_empty MeasureTheory.SimpleFunc.ofIsEmpty protected def range (f : α →ₛ β) : Finset β := f.finite_range.toFinset #align measure_theory.simple_func.range MeasureTheory.SimpleFunc.range @[simp] theorem mem_range {f : α →ₛ β} {b} : b ∈ f.range ↔ b ∈ range f := Finite.mem_toFinset _ #align measure_theory.simple_func.mem_range MeasureTheory.SimpleFunc.mem_range theorem mem_range_self (f : α →ₛ β) (x : α) : f x ∈ f.range := mem_range.2 ⟨x, rfl⟩ #align measure_theory.simple_func.mem_range_self MeasureTheory.SimpleFunc.mem_range_self @[simp] theorem coe_range (f : α →ₛ β) : (↑f.range : Set β) = Set.range f := f.finite_range.coe_toFinset #align measure_theory.simple_func.coe_range MeasureTheory.SimpleFunc.coe_range theorem mem_range_of_measure_ne_zero {f : α →ₛ β} {x : β} {μ : Measure α} (H : μ (f ⁻¹' {x}) ≠ 0) : x ∈ f.range := let ⟨a, ha⟩ := nonempty_of_measure_ne_zero H mem_range.2 ⟨a, ha⟩ #align measure_theory.simple_func.mem_range_of_measure_ne_zero MeasureTheory.SimpleFunc.mem_range_of_measure_ne_zero theorem forall_mem_range {f : α →ₛ β} {p : β → Prop} : (∀ y ∈ f.range, p y) ↔ ∀ x, p (f x) := by simp only [mem_range, Set.forall_mem_range] #align measure_theory.simple_func.forall_mem_range MeasureTheory.SimpleFunc.forall_mem_range theorem exists_range_iff {f : α →ₛ β} {p : β → Prop} : (∃ y ∈ f.range, p y) ↔ ∃ x, p (f x) := by simpa only [mem_range, exists_prop] using Set.exists_range_iff #align measure_theory.simple_func.exists_range_iff MeasureTheory.SimpleFunc.exists_range_iff theorem preimage_eq_empty_iff (f : α →ₛ β) (b : β) : f ⁻¹' {b} = ∅ ↔ b ∉ f.range := preimage_singleton_eq_empty.trans <| not_congr mem_range.symm #align measure_theory.simple_func.preimage_eq_empty_iff MeasureTheory.SimpleFunc.preimage_eq_empty_iff theorem exists_forall_le [Nonempty β] [Preorder β] [IsDirected β (· ≤ ·)] (f : α →ₛ β) : ∃ C, ∀ x, f x ≤ C := f.range.exists_le.imp fun _ => forall_mem_range.1 #align measure_theory.simple_func.exists_forall_le MeasureTheory.SimpleFunc.exists_forall_le def const (α) {β} [MeasurableSpace α] (b : β) : α →ₛ β := ⟨fun _ => b, fun _ => MeasurableSet.const _, finite_range_const⟩ #align measure_theory.simple_func.const MeasureTheory.SimpleFunc.const instance instInhabited [Inhabited β] : Inhabited (α →ₛ β) := ⟨const _ default⟩ #align measure_theory.simple_func.inhabited MeasureTheory.SimpleFunc.instInhabited theorem const_apply (a : α) (b : β) : (const α b) a = b := rfl #align measure_theory.simple_func.const_apply MeasureTheory.SimpleFunc.const_apply @[simp] theorem coe_const (b : β) : ⇑(const α b) = Function.const α b := rfl #align measure_theory.simple_func.coe_const MeasureTheory.SimpleFunc.coe_const @[simp] theorem range_const (α) [MeasurableSpace α] [Nonempty α] (b : β) : (const α b).range = {b} := Finset.coe_injective <| by simp (config := { unfoldPartialApp := true }) [Function.const] #align measure_theory.simple_func.range_const MeasureTheory.SimpleFunc.range_const theorem range_const_subset (α) [MeasurableSpace α] (b : β) : (const α b).range ⊆ {b} := Finset.coe_subset.1 <| by simp #align measure_theory.simple_func.range_const_subset MeasureTheory.SimpleFunc.range_const_subset theorem simpleFunc_bot {α} (f : @SimpleFunc α ⊥ β) [Nonempty β] : ∃ c, ∀ x, f x = c := by have hf_meas := @SimpleFunc.measurableSet_fiber α _ ⊥ f simp_rw [MeasurableSpace.measurableSet_bot_iff] at hf_meas exact (exists_eq_const_of_preimage_singleton hf_meas).imp fun c hc ↦ congr_fun hc #align measure_theory.simple_func.simple_func_bot MeasureTheory.SimpleFunc.simpleFunc_bot theorem simpleFunc_bot' {α} [Nonempty β] (f : @SimpleFunc α ⊥ β) : ∃ c, f = @SimpleFunc.const α _ ⊥ c := letI : MeasurableSpace α := ⊥; (simpleFunc_bot f).imp fun _ ↦ ext #align measure_theory.simple_func.simple_func_bot' MeasureTheory.SimpleFunc.simpleFunc_bot' theorem measurableSet_cut (r : α → β → Prop) (f : α →ₛ β) (h : ∀ b, MeasurableSet { a | r a b }) : MeasurableSet { a | r a (f a) } := by have : { a | r a (f a) } = ⋃ b ∈ range f, { a | r a b } ∩ f ⁻¹' {b} := by ext a suffices r a (f a) ↔ ∃ i, r a (f i) ∧ f a = f i by simpa exact ⟨fun h => ⟨a, ⟨h, rfl⟩⟩, fun ⟨a', ⟨h', e⟩⟩ => e.symm ▸ h'⟩ rw [this] exact MeasurableSet.biUnion f.finite_range.countable fun b _ => MeasurableSet.inter (h b) (f.measurableSet_fiber _) #align measure_theory.simple_func.measurable_set_cut MeasureTheory.SimpleFunc.measurableSet_cut @[measurability] theorem measurableSet_preimage (f : α →ₛ β) (s) : MeasurableSet (f ⁻¹' s) := measurableSet_cut (fun _ b => b ∈ s) f fun b => MeasurableSet.const (b ∈ s) #align measure_theory.simple_func.measurable_set_preimage MeasureTheory.SimpleFunc.measurableSet_preimage @[measurability] protected theorem measurable [MeasurableSpace β] (f : α →ₛ β) : Measurable f := fun s _ => measurableSet_preimage f s #align measure_theory.simple_func.measurable MeasureTheory.SimpleFunc.measurable @[measurability] protected theorem aemeasurable [MeasurableSpace β] {μ : Measure α} (f : α →ₛ β) : AEMeasurable f μ := f.measurable.aemeasurable #align measure_theory.simple_func.ae_measurable MeasureTheory.SimpleFunc.aemeasurable protected theorem sum_measure_preimage_singleton (f : α →ₛ β) {μ : Measure α} (s : Finset β) : (∑ y ∈ s, μ (f ⁻¹' {y})) = μ (f ⁻¹' ↑s) := sum_measure_preimage_singleton _ fun _ _ => f.measurableSet_fiber _ #align measure_theory.simple_func.sum_measure_preimage_singleton MeasureTheory.SimpleFunc.sum_measure_preimage_singleton theorem sum_range_measure_preimage_singleton (f : α →ₛ β) (μ : Measure α) : (∑ y ∈ f.range, μ (f ⁻¹' {y})) = μ univ := by rw [f.sum_measure_preimage_singleton, coe_range, preimage_range] #align measure_theory.simple_func.sum_range_measure_preimage_singleton MeasureTheory.SimpleFunc.sum_range_measure_preimage_singleton def piecewise (s : Set α) (hs : MeasurableSet s) (f g : α →ₛ β) : α →ₛ β := ⟨s.piecewise f g, fun _ => letI : MeasurableSpace β := ⊤ f.measurable.piecewise hs g.measurable trivial, (f.finite_range.union g.finite_range).subset range_ite_subset⟩ #align measure_theory.simple_func.piecewise MeasureTheory.SimpleFunc.piecewise @[simp] theorem coe_piecewise {s : Set α} (hs : MeasurableSet s) (f g : α →ₛ β) : ⇑(piecewise s hs f g) = s.piecewise f g := rfl #align measure_theory.simple_func.coe_piecewise MeasureTheory.SimpleFunc.coe_piecewise theorem piecewise_apply {s : Set α} (hs : MeasurableSet s) (f g : α →ₛ β) (a) : piecewise s hs f g a = if a ∈ s then f a else g a := rfl #align measure_theory.simple_func.piecewise_apply MeasureTheory.SimpleFunc.piecewise_apply @[simp] theorem piecewise_compl {s : Set α} (hs : MeasurableSet sᶜ) (f g : α →ₛ β) : piecewise sᶜ hs f g = piecewise s hs.of_compl g f := coe_injective <| by set_option tactic.skipAssignedInstances false in simp [hs]; convert Set.piecewise_compl s f g #align measure_theory.simple_func.piecewise_compl MeasureTheory.SimpleFunc.piecewise_compl @[simp] theorem piecewise_univ (f g : α →ₛ β) : piecewise univ MeasurableSet.univ f g = f := coe_injective <| by set_option tactic.skipAssignedInstances false in simp; convert Set.piecewise_univ f g #align measure_theory.simple_func.piecewise_univ MeasureTheory.SimpleFunc.piecewise_univ @[simp] theorem piecewise_empty (f g : α →ₛ β) : piecewise ∅ MeasurableSet.empty f g = g := coe_injective <| by set_option tactic.skipAssignedInstances false in simp; convert Set.piecewise_empty f g #align measure_theory.simple_func.piecewise_empty MeasureTheory.SimpleFunc.piecewise_empty @[simp] theorem piecewise_same (f : α →ₛ β) {s : Set α} (hs : MeasurableSet s) : piecewise s hs f f = f := coe_injective <| Set.piecewise_same _ _ theorem support_indicator [Zero β] {s : Set α} (hs : MeasurableSet s) (f : α →ₛ β) : Function.support (f.piecewise s hs (SimpleFunc.const α 0)) = s ∩ Function.support f := Set.support_indicator #align measure_theory.simple_func.support_indicator MeasureTheory.SimpleFunc.support_indicator
Mathlib/MeasureTheory/Function/SimpleFunc.lean
270
275
theorem range_indicator {s : Set α} (hs : MeasurableSet s) (hs_nonempty : s.Nonempty) (hs_ne_univ : s ≠ univ) (x y : β) : (piecewise s hs (const α x) (const α y)).range = {x, y} := by
simp only [← Finset.coe_inj, coe_range, coe_piecewise, range_piecewise, coe_const, Finset.coe_insert, Finset.coe_singleton, hs_nonempty.image_const, (nonempty_compl.2 hs_ne_univ).image_const, singleton_union, Function.const]
import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.MeasureTheory.Constructions.BorelSpace.ContinuousLinearMap import Mathlib.MeasureTheory.Covering.BesicovitchVectorSpace import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar import Mathlib.Analysis.NormedSpace.Pointwise import Mathlib.MeasureTheory.Constructions.Polish import Mathlib.Analysis.Calculus.InverseFunctionTheorem.ApproximatesLinearOn #align_import measure_theory.function.jacobian from "leanprover-community/mathlib"@"b84aee748341da06a6d78491367e2c0e9f15e8a5" open MeasureTheory MeasureTheory.Measure Metric Filter Set FiniteDimensional Asymptotics TopologicalSpace open scoped NNReal ENNReal Topology Pointwise variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] {s : Set E} {f : E → E} {f' : E → E →L[ℝ] E} theorem exists_closed_cover_approximatesLinearOn_of_hasFDerivWithinAt [SecondCountableTopology F] (f : E → F) (s : Set E) (f' : E → E →L[ℝ] F) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (r : (E →L[ℝ] F) → ℝ≥0) (rpos : ∀ A, r A ≠ 0) : ∃ (t : ℕ → Set E) (A : ℕ → E →L[ℝ] F), (∀ n, IsClosed (t n)) ∧ (s ⊆ ⋃ n, t n) ∧ (∀ n, ApproximatesLinearOn f (A n) (s ∩ t n) (r (A n))) ∧ (s.Nonempty → ∀ n, ∃ y ∈ s, A n = f' y) := by -- exclude the trivial case where `s` is empty rcases eq_empty_or_nonempty s with (rfl | hs) · refine ⟨fun _ => ∅, fun _ => 0, ?_, ?_, ?_, ?_⟩ <;> simp -- we will use countably many linear maps. Select these from all the derivatives since the -- space of linear maps is second-countable obtain ⟨T, T_count, hT⟩ : ∃ T : Set s, T.Countable ∧ ⋃ x ∈ T, ball (f' (x : E)) (r (f' x)) = ⋃ x : s, ball (f' x) (r (f' x)) := TopologicalSpace.isOpen_iUnion_countable _ fun x => isOpen_ball -- fix a sequence `u` of positive reals tending to zero. obtain ⟨u, _, u_pos, u_lim⟩ : ∃ u : ℕ → ℝ, StrictAnti u ∧ (∀ n : ℕ, 0 < u n) ∧ Tendsto u atTop (𝓝 0) := exists_seq_strictAnti_tendsto (0 : ℝ) -- `M n z` is the set of points `x` such that `f y - f x` is close to `f' z (y - x)` for `y` -- in the ball of radius `u n` around `x`. let M : ℕ → T → Set E := fun n z => {x | x ∈ s ∧ ∀ y ∈ s ∩ ball x (u n), ‖f y - f x - f' z (y - x)‖ ≤ r (f' z) * ‖y - x‖} -- As `f` is differentiable everywhere on `s`, the sets `M n z` cover `s` by design. have s_subset : ∀ x ∈ s, ∃ (n : ℕ) (z : T), x ∈ M n z := by intro x xs obtain ⟨z, zT, hz⟩ : ∃ z ∈ T, f' x ∈ ball (f' (z : E)) (r (f' z)) := by have : f' x ∈ ⋃ z ∈ T, ball (f' (z : E)) (r (f' z)) := by rw [hT] refine mem_iUnion.2 ⟨⟨x, xs⟩, ?_⟩ simpa only [mem_ball, Subtype.coe_mk, dist_self] using (rpos (f' x)).bot_lt rwa [mem_iUnion₂, bex_def] at this obtain ⟨ε, εpos, hε⟩ : ∃ ε : ℝ, 0 < ε ∧ ‖f' x - f' z‖ + ε ≤ r (f' z) := by refine ⟨r (f' z) - ‖f' x - f' z‖, ?_, le_of_eq (by abel)⟩ simpa only [sub_pos] using mem_ball_iff_norm.mp hz obtain ⟨δ, δpos, hδ⟩ : ∃ (δ : ℝ), 0 < δ ∧ ball x δ ∩ s ⊆ {y | ‖f y - f x - (f' x) (y - x)‖ ≤ ε * ‖y - x‖} := Metric.mem_nhdsWithin_iff.1 ((hf' x xs).isLittleO.def εpos) obtain ⟨n, hn⟩ : ∃ n, u n < δ := ((tendsto_order.1 u_lim).2 _ δpos).exists refine ⟨n, ⟨z, zT⟩, ⟨xs, ?_⟩⟩ intro y hy calc ‖f y - f x - (f' z) (y - x)‖ = ‖f y - f x - (f' x) (y - x) + (f' x - f' z) (y - x)‖ := by congr 1 simp only [ContinuousLinearMap.coe_sub', map_sub, Pi.sub_apply] abel _ ≤ ‖f y - f x - (f' x) (y - x)‖ + ‖(f' x - f' z) (y - x)‖ := norm_add_le _ _ _ ≤ ε * ‖y - x‖ + ‖f' x - f' z‖ * ‖y - x‖ := by refine add_le_add (hδ ?_) (ContinuousLinearMap.le_opNorm _ _) rw [inter_comm] exact inter_subset_inter_right _ (ball_subset_ball hn.le) hy _ ≤ r (f' z) * ‖y - x‖ := by rw [← add_mul, add_comm] gcongr -- the sets `M n z` are relatively closed in `s`, as all the conditions defining it are clearly -- closed have closure_M_subset : ∀ n z, s ∩ closure (M n z) ⊆ M n z := by rintro n z x ⟨xs, hx⟩ refine ⟨xs, fun y hy => ?_⟩ obtain ⟨a, aM, a_lim⟩ : ∃ a : ℕ → E, (∀ k, a k ∈ M n z) ∧ Tendsto a atTop (𝓝 x) := mem_closure_iff_seq_limit.1 hx have L1 : Tendsto (fun k : ℕ => ‖f y - f (a k) - (f' z) (y - a k)‖) atTop (𝓝 ‖f y - f x - (f' z) (y - x)‖) := by apply Tendsto.norm have L : Tendsto (fun k => f (a k)) atTop (𝓝 (f x)) := by apply (hf' x xs).continuousWithinAt.tendsto.comp apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ a_lim exact eventually_of_forall fun k => (aM k).1 apply Tendsto.sub (tendsto_const_nhds.sub L) exact ((f' z).continuous.tendsto _).comp (tendsto_const_nhds.sub a_lim) have L2 : Tendsto (fun k : ℕ => (r (f' z) : ℝ) * ‖y - a k‖) atTop (𝓝 (r (f' z) * ‖y - x‖)) := (tendsto_const_nhds.sub a_lim).norm.const_mul _ have I : ∀ᶠ k in atTop, ‖f y - f (a k) - (f' z) (y - a k)‖ ≤ r (f' z) * ‖y - a k‖ := by have L : Tendsto (fun k => dist y (a k)) atTop (𝓝 (dist y x)) := tendsto_const_nhds.dist a_lim filter_upwards [(tendsto_order.1 L).2 _ hy.2] intro k hk exact (aM k).2 y ⟨hy.1, hk⟩ exact le_of_tendsto_of_tendsto L1 L2 I -- choose a dense sequence `d p` rcases TopologicalSpace.exists_dense_seq E with ⟨d, hd⟩ -- split `M n z` into subsets `K n z p` of small diameters by intersecting with the ball -- `closedBall (d p) (u n / 3)`. let K : ℕ → T → ℕ → Set E := fun n z p => closure (M n z) ∩ closedBall (d p) (u n / 3) -- on the sets `K n z p`, the map `f` is well approximated by `f' z` by design. have K_approx : ∀ (n) (z : T) (p), ApproximatesLinearOn f (f' z) (s ∩ K n z p) (r (f' z)) := by intro n z p x hx y hy have yM : y ∈ M n z := closure_M_subset _ _ ⟨hy.1, hy.2.1⟩ refine yM.2 _ ⟨hx.1, ?_⟩ calc dist x y ≤ dist x (d p) + dist y (d p) := dist_triangle_right _ _ _ _ ≤ u n / 3 + u n / 3 := add_le_add hx.2.2 hy.2.2 _ < u n := by linarith [u_pos n] -- the sets `K n z p` are also closed, again by design. have K_closed : ∀ (n) (z : T) (p), IsClosed (K n z p) := fun n z p => isClosed_closure.inter isClosed_ball -- reindex the sets `K n z p`, to let them only depend on an integer parameter `q`. obtain ⟨F, hF⟩ : ∃ F : ℕ → ℕ × T × ℕ, Function.Surjective F := by haveI : Encodable T := T_count.toEncodable have : Nonempty T := by rcases hs with ⟨x, xs⟩ rcases s_subset x xs with ⟨n, z, _⟩ exact ⟨z⟩ inhabit ↥T exact ⟨_, Encodable.surjective_decode_iget (ℕ × T × ℕ)⟩ -- these sets `t q = K n z p` will do refine ⟨fun q => K (F q).1 (F q).2.1 (F q).2.2, fun q => f' (F q).2.1, fun n => K_closed _ _ _, fun x xs => ?_, fun q => K_approx _ _ _, fun _ q => ⟨(F q).2.1, (F q).2.1.1.2, rfl⟩⟩ -- the only fact that needs further checking is that they cover `s`. -- we already know that any point `x ∈ s` belongs to a set `M n z`. obtain ⟨n, z, hnz⟩ : ∃ (n : ℕ) (z : T), x ∈ M n z := s_subset x xs -- by density, it also belongs to a ball `closedBall (d p) (u n / 3)`. obtain ⟨p, hp⟩ : ∃ p : ℕ, x ∈ closedBall (d p) (u n / 3) := by have : Set.Nonempty (ball x (u n / 3)) := by simp only [nonempty_ball]; linarith [u_pos n] obtain ⟨p, hp⟩ : ∃ p : ℕ, d p ∈ ball x (u n / 3) := hd.exists_mem_open isOpen_ball this exact ⟨p, (mem_ball'.1 hp).le⟩ -- choose `q` for which `t q = K n z p`. obtain ⟨q, hq⟩ : ∃ q, F q = (n, z, p) := hF _ -- then `x` belongs to `t q`. apply mem_iUnion.2 ⟨q, _⟩ simp (config := { zeta := false }) only [K, hq, mem_inter_iff, hp, and_true] exact subset_closure hnz #align exists_closed_cover_approximates_linear_on_of_has_fderiv_within_at exists_closed_cover_approximatesLinearOn_of_hasFDerivWithinAt variable [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [IsAddHaarMeasure μ] theorem exists_partition_approximatesLinearOn_of_hasFDerivWithinAt [SecondCountableTopology F] (f : E → F) (s : Set E) (f' : E → E →L[ℝ] F) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (r : (E →L[ℝ] F) → ℝ≥0) (rpos : ∀ A, r A ≠ 0) : ∃ (t : ℕ → Set E) (A : ℕ → E →L[ℝ] F), Pairwise (Disjoint on t) ∧ (∀ n, MeasurableSet (t n)) ∧ (s ⊆ ⋃ n, t n) ∧ (∀ n, ApproximatesLinearOn f (A n) (s ∩ t n) (r (A n))) ∧ (s.Nonempty → ∀ n, ∃ y ∈ s, A n = f' y) := by rcases exists_closed_cover_approximatesLinearOn_of_hasFDerivWithinAt f s f' hf' r rpos with ⟨t, A, t_closed, st, t_approx, ht⟩ refine ⟨disjointed t, A, disjoint_disjointed _, MeasurableSet.disjointed fun n => (t_closed n).measurableSet, ?_, ?_, ht⟩ · rw [iUnion_disjointed]; exact st · intro n; exact (t_approx n).mono_set (inter_subset_inter_right _ (disjointed_subset _ _)) #align exists_partition_approximates_linear_on_of_has_fderiv_within_at exists_partition_approximatesLinearOn_of_hasFDerivWithinAt namespace MeasureTheory theorem addHaar_image_le_mul_of_det_lt (A : E →L[ℝ] E) {m : ℝ≥0} (hm : ENNReal.ofReal |A.det| < m) : ∀ᶠ δ in 𝓝[>] (0 : ℝ≥0), ∀ (s : Set E) (f : E → E), ApproximatesLinearOn f A s δ → μ (f '' s) ≤ m * μ s := by apply nhdsWithin_le_nhds let d := ENNReal.ofReal |A.det| -- construct a small neighborhood of `A '' (closedBall 0 1)` with measure comparable to -- the determinant of `A`. obtain ⟨ε, hε, εpos⟩ : ∃ ε : ℝ, μ (closedBall 0 ε + A '' closedBall 0 1) < m * μ (closedBall 0 1) ∧ 0 < ε := by have HC : IsCompact (A '' closedBall 0 1) := (ProperSpace.isCompact_closedBall _ _).image A.continuous have L0 : Tendsto (fun ε => μ (cthickening ε (A '' closedBall 0 1))) (𝓝[>] 0) (𝓝 (μ (A '' closedBall 0 1))) := by apply Tendsto.mono_left _ nhdsWithin_le_nhds exact tendsto_measure_cthickening_of_isCompact HC have L1 : Tendsto (fun ε => μ (closedBall 0 ε + A '' closedBall 0 1)) (𝓝[>] 0) (𝓝 (μ (A '' closedBall 0 1))) := by apply L0.congr' _ filter_upwards [self_mem_nhdsWithin] with r hr rw [← HC.add_closedBall_zero (le_of_lt hr), add_comm] have L2 : Tendsto (fun ε => μ (closedBall 0 ε + A '' closedBall 0 1)) (𝓝[>] 0) (𝓝 (d * μ (closedBall 0 1))) := by convert L1 exact (addHaar_image_continuousLinearMap _ _ _).symm have I : d * μ (closedBall 0 1) < m * μ (closedBall 0 1) := (ENNReal.mul_lt_mul_right (measure_closedBall_pos μ _ zero_lt_one).ne' measure_closedBall_lt_top.ne).2 hm have H : ∀ᶠ b : ℝ in 𝓝[>] 0, μ (closedBall 0 b + A '' closedBall 0 1) < m * μ (closedBall 0 1) := (tendsto_order.1 L2).2 _ I exact (H.and self_mem_nhdsWithin).exists have : Iio (⟨ε, εpos.le⟩ : ℝ≥0) ∈ 𝓝 (0 : ℝ≥0) := by apply Iio_mem_nhds; exact εpos filter_upwards [this] -- fix a function `f` which is close enough to `A`. intro δ hδ s f hf simp only [mem_Iio, ← NNReal.coe_lt_coe, NNReal.coe_mk] at hδ -- This function expands the volume of any ball by at most `m` have I : ∀ x r, x ∈ s → 0 ≤ r → μ (f '' (s ∩ closedBall x r)) ≤ m * μ (closedBall x r) := by intro x r xs r0 have K : f '' (s ∩ closedBall x r) ⊆ A '' closedBall 0 r + closedBall (f x) (ε * r) := by rintro y ⟨z, ⟨zs, zr⟩, rfl⟩ rw [mem_closedBall_iff_norm] at zr apply Set.mem_add.2 ⟨A (z - x), _, f z - f x - A (z - x) + f x, _, _⟩ · apply mem_image_of_mem simpa only [dist_eq_norm, mem_closedBall, mem_closedBall_zero_iff, sub_zero] using zr · rw [mem_closedBall_iff_norm, add_sub_cancel_right] calc ‖f z - f x - A (z - x)‖ ≤ δ * ‖z - x‖ := hf _ zs _ xs _ ≤ ε * r := by gcongr · simp only [map_sub, Pi.sub_apply] abel have : A '' closedBall 0 r + closedBall (f x) (ε * r) = {f x} + r • (A '' closedBall 0 1 + closedBall 0 ε) := by rw [smul_add, ← add_assoc, add_comm {f x}, add_assoc, smul_closedBall _ _ εpos.le, smul_zero, singleton_add_closedBall_zero, ← image_smul_set ℝ E E A, smul_closedBall _ _ zero_le_one, smul_zero, Real.norm_eq_abs, abs_of_nonneg r0, mul_one, mul_comm] rw [this] at K calc μ (f '' (s ∩ closedBall x r)) ≤ μ ({f x} + r • (A '' closedBall 0 1 + closedBall 0 ε)) := measure_mono K _ = ENNReal.ofReal (r ^ finrank ℝ E) * μ (A '' closedBall 0 1 + closedBall 0 ε) := by simp only [abs_of_nonneg r0, addHaar_smul, image_add_left, abs_pow, singleton_add, measure_preimage_add] _ ≤ ENNReal.ofReal (r ^ finrank ℝ E) * (m * μ (closedBall 0 1)) := by rw [add_comm]; gcongr _ = m * μ (closedBall x r) := by simp only [addHaar_closedBall' μ _ r0]; ring -- covering `s` by closed balls with total measure very close to `μ s`, one deduces that the -- measure of `f '' s` is at most `m * (μ s + a)` for any positive `a`. have J : ∀ᶠ a in 𝓝[>] (0 : ℝ≥0∞), μ (f '' s) ≤ m * (μ s + a) := by filter_upwards [self_mem_nhdsWithin] with a ha rw [mem_Ioi] at ha obtain ⟨t, r, t_count, ts, rpos, st, μt⟩ : ∃ (t : Set E) (r : E → ℝ), t.Countable ∧ t ⊆ s ∧ (∀ x : E, x ∈ t → 0 < r x) ∧ (s ⊆ ⋃ x ∈ t, closedBall x (r x)) ∧ (∑' x : ↥t, μ (closedBall (↑x) (r ↑x))) ≤ μ s + a := Besicovitch.exists_closedBall_covering_tsum_measure_le μ ha.ne' (fun _ => Ioi 0) s fun x _ δ δpos => ⟨δ / 2, by simp [half_pos δpos, δpos]⟩ haveI : Encodable t := t_count.toEncodable calc μ (f '' s) ≤ μ (⋃ x : t, f '' (s ∩ closedBall x (r x))) := by rw [biUnion_eq_iUnion] at st apply measure_mono rw [← image_iUnion, ← inter_iUnion] exact image_subset _ (subset_inter (Subset.refl _) st) _ ≤ ∑' x : t, μ (f '' (s ∩ closedBall x (r x))) := measure_iUnion_le _ _ ≤ ∑' x : t, m * μ (closedBall x (r x)) := (ENNReal.tsum_le_tsum fun x => I x (r x) (ts x.2) (rpos x x.2).le) _ ≤ m * (μ s + a) := by rw [ENNReal.tsum_mul_left]; gcongr -- taking the limit in `a`, one obtains the conclusion have L : Tendsto (fun a => (m : ℝ≥0∞) * (μ s + a)) (𝓝[>] 0) (𝓝 (m * (μ s + 0))) := by apply Tendsto.mono_left _ nhdsWithin_le_nhds apply ENNReal.Tendsto.const_mul (tendsto_const_nhds.add tendsto_id) simp only [ENNReal.coe_ne_top, Ne, or_true_iff, not_false_iff] rw [add_zero] at L exact ge_of_tendsto L J #align measure_theory.add_haar_image_le_mul_of_det_lt MeasureTheory.addHaar_image_le_mul_of_det_lt theorem mul_le_addHaar_image_of_lt_det (A : E →L[ℝ] E) {m : ℝ≥0} (hm : (m : ℝ≥0∞) < ENNReal.ofReal |A.det|) : ∀ᶠ δ in 𝓝[>] (0 : ℝ≥0), ∀ (s : Set E) (f : E → E), ApproximatesLinearOn f A s δ → (m : ℝ≥0∞) * μ s ≤ μ (f '' s) := by apply nhdsWithin_le_nhds -- The assumption `hm` implies that `A` is invertible. If `f` is close enough to `A`, it is also -- invertible. One can then pass to the inverses, and deduce the estimate from -- `addHaar_image_le_mul_of_det_lt` applied to `f⁻¹` and `A⁻¹`. -- exclude first the trivial case where `m = 0`. rcases eq_or_lt_of_le (zero_le m) with (rfl | mpos) · filter_upwards simp only [forall_const, zero_mul, imp_true_iff, zero_le, ENNReal.coe_zero] have hA : A.det ≠ 0 := by intro h; simp only [h, ENNReal.not_lt_zero, ENNReal.ofReal_zero, abs_zero] at hm -- let `B` be the continuous linear equiv version of `A`. let B := A.toContinuousLinearEquivOfDetNeZero hA -- the determinant of `B.symm` is bounded by `m⁻¹` have I : ENNReal.ofReal |(B.symm : E →L[ℝ] E).det| < (m⁻¹ : ℝ≥0) := by simp only [ENNReal.ofReal, abs_inv, Real.toNNReal_inv, ContinuousLinearEquiv.det_coe_symm, ContinuousLinearMap.coe_toContinuousLinearEquivOfDetNeZero, ENNReal.coe_lt_coe] at hm ⊢ exact NNReal.inv_lt_inv mpos.ne' hm -- therefore, we may apply `addHaar_image_le_mul_of_det_lt` to `B.symm` and `m⁻¹`. obtain ⟨δ₀, δ₀pos, hδ₀⟩ : ∃ δ : ℝ≥0, 0 < δ ∧ ∀ (t : Set E) (g : E → E), ApproximatesLinearOn g (B.symm : E →L[ℝ] E) t δ → μ (g '' t) ≤ ↑m⁻¹ * μ t := by have : ∀ᶠ δ : ℝ≥0 in 𝓝[>] 0, ∀ (t : Set E) (g : E → E), ApproximatesLinearOn g (B.symm : E →L[ℝ] E) t δ → μ (g '' t) ≤ ↑m⁻¹ * μ t := addHaar_image_le_mul_of_det_lt μ B.symm I rcases (this.and self_mem_nhdsWithin).exists with ⟨δ₀, h, h'⟩ exact ⟨δ₀, h', h⟩ -- record smallness conditions for `δ` that will be needed to apply `hδ₀` below. have L1 : ∀ᶠ δ in 𝓝 (0 : ℝ≥0), Subsingleton E ∨ δ < ‖(B.symm : E →L[ℝ] E)‖₊⁻¹ := by by_cases h : Subsingleton E · simp only [h, true_or_iff, eventually_const] simp only [h, false_or_iff] apply Iio_mem_nhds simpa only [h, false_or_iff, inv_pos] using B.subsingleton_or_nnnorm_symm_pos have L2 : ∀ᶠ δ in 𝓝 (0 : ℝ≥0), ‖(B.symm : E →L[ℝ] E)‖₊ * (‖(B.symm : E →L[ℝ] E)‖₊⁻¹ - δ)⁻¹ * δ < δ₀ := by have : Tendsto (fun δ => ‖(B.symm : E →L[ℝ] E)‖₊ * (‖(B.symm : E →L[ℝ] E)‖₊⁻¹ - δ)⁻¹ * δ) (𝓝 0) (𝓝 (‖(B.symm : E →L[ℝ] E)‖₊ * (‖(B.symm : E →L[ℝ] E)‖₊⁻¹ - 0)⁻¹ * 0)) := by rcases eq_or_ne ‖(B.symm : E →L[ℝ] E)‖₊ 0 with (H | H) · simpa only [H, zero_mul] using tendsto_const_nhds refine Tendsto.mul (tendsto_const_nhds.mul ?_) tendsto_id refine (Tendsto.sub tendsto_const_nhds tendsto_id).inv₀ ?_ simpa only [tsub_zero, inv_eq_zero, Ne] using H simp only [mul_zero] at this exact (tendsto_order.1 this).2 δ₀ δ₀pos -- let `δ` be small enough, and `f` approximated by `B` up to `δ`. filter_upwards [L1, L2] intro δ h1δ h2δ s f hf have hf' : ApproximatesLinearOn f (B : E →L[ℝ] E) s δ := by convert hf let F := hf'.toPartialEquiv h1δ -- the condition to be checked can be reformulated in terms of the inverse maps suffices H : μ (F.symm '' F.target) ≤ (m⁻¹ : ℝ≥0) * μ F.target by change (m : ℝ≥0∞) * μ F.source ≤ μ F.target rwa [← F.symm_image_target_eq_source, mul_comm, ← ENNReal.le_div_iff_mul_le, div_eq_mul_inv, mul_comm, ← ENNReal.coe_inv mpos.ne'] · apply Or.inl simpa only [ENNReal.coe_eq_zero, Ne] using mpos.ne' · simp only [ENNReal.coe_ne_top, true_or_iff, Ne, not_false_iff] -- as `f⁻¹` is well approximated by `B⁻¹`, the conclusion follows from `hδ₀` -- and our choice of `δ`. exact hδ₀ _ _ ((hf'.to_inv h1δ).mono_num h2δ.le) #align measure_theory.mul_le_add_haar_image_of_lt_det MeasureTheory.mul_le_addHaar_image_of_lt_det theorem _root_.ApproximatesLinearOn.norm_fderiv_sub_le {A : E →L[ℝ] E} {δ : ℝ≥0} (hf : ApproximatesLinearOn f A s δ) (hs : MeasurableSet s) (f' : E → E →L[ℝ] E) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) : ∀ᵐ x ∂μ.restrict s, ‖f' x - A‖₊ ≤ δ := by filter_upwards [Besicovitch.ae_tendsto_measure_inter_div μ s, ae_restrict_mem hs] -- start from a Lebesgue density point `x`, belonging to `s`. intro x hx xs -- consider an arbitrary vector `z`. apply ContinuousLinearMap.opNorm_le_bound _ δ.2 fun z => ?_ -- to show that `‖(f' x - A) z‖ ≤ δ ‖z‖`, it suffices to do it up to some error that vanishes -- asymptotically in terms of `ε > 0`. suffices H : ∀ ε, 0 < ε → ‖(f' x - A) z‖ ≤ (δ + ε) * (‖z‖ + ε) + ‖f' x - A‖ * ε by have : Tendsto (fun ε : ℝ => ((δ : ℝ) + ε) * (‖z‖ + ε) + ‖f' x - A‖ * ε) (𝓝[>] 0) (𝓝 ((δ + 0) * (‖z‖ + 0) + ‖f' x - A‖ * 0)) := Tendsto.mono_left (Continuous.tendsto (by continuity) 0) nhdsWithin_le_nhds simp only [add_zero, mul_zero] at this apply le_of_tendsto_of_tendsto tendsto_const_nhds this filter_upwards [self_mem_nhdsWithin] exact H -- fix a positive `ε`. intro ε εpos -- for small enough `r`, the rescaled ball `r • closedBall z ε` intersects `s`, as `x` is a -- density point have B₁ : ∀ᶠ r in 𝓝[>] (0 : ℝ), (s ∩ ({x} + r • closedBall z ε)).Nonempty := eventually_nonempty_inter_smul_of_density_one μ s x hx _ measurableSet_closedBall (measure_closedBall_pos μ z εpos).ne' obtain ⟨ρ, ρpos, hρ⟩ : ∃ ρ > 0, ball x ρ ∩ s ⊆ {y : E | ‖f y - f x - (f' x) (y - x)‖ ≤ ε * ‖y - x‖} := mem_nhdsWithin_iff.1 ((hf' x xs).isLittleO.def εpos) -- for small enough `r`, the rescaled ball `r • closedBall z ε` is included in the set where -- `f y - f x` is well approximated by `f' x (y - x)`. have B₂ : ∀ᶠ r in 𝓝[>] (0 : ℝ), {x} + r • closedBall z ε ⊆ ball x ρ := by apply nhdsWithin_le_nhds exact eventually_singleton_add_smul_subset isBounded_closedBall (ball_mem_nhds x ρpos) -- fix a small positive `r` satisfying the above properties, as well as a corresponding `y`. obtain ⟨r, ⟨y, ⟨ys, hy⟩⟩, rρ, rpos⟩ : ∃ r : ℝ, (s ∩ ({x} + r • closedBall z ε)).Nonempty ∧ {x} + r • closedBall z ε ⊆ ball x ρ ∧ 0 < r := (B₁.and (B₂.and self_mem_nhdsWithin)).exists -- write `y = x + r a` with `a ∈ closedBall z ε`. obtain ⟨a, az, ya⟩ : ∃ a, a ∈ closedBall z ε ∧ y = x + r • a := by simp only [mem_smul_set, image_add_left, mem_preimage, singleton_add] at hy rcases hy with ⟨a, az, ha⟩ exact ⟨a, az, by simp only [ha, add_neg_cancel_left]⟩ have norm_a : ‖a‖ ≤ ‖z‖ + ε := calc ‖a‖ = ‖z + (a - z)‖ := by simp only [add_sub_cancel] _ ≤ ‖z‖ + ‖a - z‖ := norm_add_le _ _ _ ≤ ‖z‖ + ε := add_le_add_left (mem_closedBall_iff_norm.1 az) _ -- use the approximation properties to control `(f' x - A) a`, and then `(f' x - A) z` as `z` is -- close to `a`. have I : r * ‖(f' x - A) a‖ ≤ r * (δ + ε) * (‖z‖ + ε) := calc r * ‖(f' x - A) a‖ = ‖(f' x - A) (r • a)‖ := by simp only [ContinuousLinearMap.map_smul, norm_smul, Real.norm_eq_abs, abs_of_nonneg rpos.le] _ = ‖f y - f x - A (y - x) - (f y - f x - (f' x) (y - x))‖ := by congr 1 simp only [ya, add_sub_cancel_left, sub_sub_sub_cancel_left, ContinuousLinearMap.coe_sub', eq_self_iff_true, sub_left_inj, Pi.sub_apply, ContinuousLinearMap.map_smul, smul_sub] _ ≤ ‖f y - f x - A (y - x)‖ + ‖f y - f x - (f' x) (y - x)‖ := norm_sub_le _ _ _ ≤ δ * ‖y - x‖ + ε * ‖y - x‖ := (add_le_add (hf _ ys _ xs) (hρ ⟨rρ hy, ys⟩)) _ = r * (δ + ε) * ‖a‖ := by simp only [ya, add_sub_cancel_left, norm_smul, Real.norm_eq_abs, abs_of_nonneg rpos.le] ring _ ≤ r * (δ + ε) * (‖z‖ + ε) := by gcongr calc ‖(f' x - A) z‖ = ‖(f' x - A) a + (f' x - A) (z - a)‖ := by congr 1 simp only [ContinuousLinearMap.coe_sub', map_sub, Pi.sub_apply] abel _ ≤ ‖(f' x - A) a‖ + ‖(f' x - A) (z - a)‖ := norm_add_le _ _ _ ≤ (δ + ε) * (‖z‖ + ε) + ‖f' x - A‖ * ‖z - a‖ := by apply add_le_add · rw [mul_assoc] at I; exact (mul_le_mul_left rpos).1 I · apply ContinuousLinearMap.le_opNorm _ ≤ (δ + ε) * (‖z‖ + ε) + ‖f' x - A‖ * ε := by rw [mem_closedBall_iff_norm'] at az gcongr #align approximates_linear_on.norm_fderiv_sub_le ApproximatesLinearOn.norm_fderiv_sub_le theorem addHaar_image_eq_zero_of_differentiableOn_of_addHaar_eq_zero (hf : DifferentiableOn ℝ f s) (hs : μ s = 0) : μ (f '' s) = 0 := by refine le_antisymm ?_ (zero_le _) have : ∀ A : E →L[ℝ] E, ∃ δ : ℝ≥0, 0 < δ ∧ ∀ (t : Set E), ApproximatesLinearOn f A t δ → μ (f '' t) ≤ (Real.toNNReal |A.det| + 1 : ℝ≥0) * μ t := by intro A let m : ℝ≥0 := Real.toNNReal |A.det| + 1 have I : ENNReal.ofReal |A.det| < m := by simp only [m, ENNReal.ofReal, lt_add_iff_pos_right, zero_lt_one, ENNReal.coe_lt_coe] rcases ((addHaar_image_le_mul_of_det_lt μ A I).and self_mem_nhdsWithin).exists with ⟨δ, h, h'⟩ exact ⟨δ, h', fun t ht => h t f ht⟩ choose δ hδ using this obtain ⟨t, A, _, _, t_cover, ht, -⟩ : ∃ (t : ℕ → Set E) (A : ℕ → E →L[ℝ] E), Pairwise (Disjoint on t) ∧ (∀ n : ℕ, MeasurableSet (t n)) ∧ (s ⊆ ⋃ n : ℕ, t n) ∧ (∀ n : ℕ, ApproximatesLinearOn f (A n) (s ∩ t n) (δ (A n))) ∧ (s.Nonempty → ∀ n, ∃ y ∈ s, A n = fderivWithin ℝ f s y) := exists_partition_approximatesLinearOn_of_hasFDerivWithinAt f s (fderivWithin ℝ f s) (fun x xs => (hf x xs).hasFDerivWithinAt) δ fun A => (hδ A).1.ne' calc μ (f '' s) ≤ μ (⋃ n, f '' (s ∩ t n)) := by apply measure_mono rw [← image_iUnion, ← inter_iUnion] exact image_subset f (subset_inter Subset.rfl t_cover) _ ≤ ∑' n, μ (f '' (s ∩ t n)) := measure_iUnion_le _ _ ≤ ∑' n, (Real.toNNReal |(A n).det| + 1 : ℝ≥0) * μ (s ∩ t n) := by apply ENNReal.tsum_le_tsum fun n => ?_ apply (hδ (A n)).2 exact ht n _ ≤ ∑' n, ((Real.toNNReal |(A n).det| + 1 : ℝ≥0) : ℝ≥0∞) * 0 := by refine ENNReal.tsum_le_tsum fun n => mul_le_mul_left' ?_ _ exact le_trans (measure_mono inter_subset_left) (le_of_eq hs) _ = 0 := by simp only [tsum_zero, mul_zero] #align measure_theory.add_haar_image_eq_zero_of_differentiable_on_of_add_haar_eq_zero MeasureTheory.addHaar_image_eq_zero_of_differentiableOn_of_addHaar_eq_zero theorem addHaar_image_eq_zero_of_det_fderivWithin_eq_zero_aux (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (R : ℝ) (hs : s ⊆ closedBall 0 R) (ε : ℝ≥0) (εpos : 0 < ε) (h'f' : ∀ x ∈ s, (f' x).det = 0) : μ (f '' s) ≤ ε * μ (closedBall 0 R) := by rcases eq_empty_or_nonempty s with (rfl | h's); · simp only [measure_empty, zero_le, image_empty] have : ∀ A : E →L[ℝ] E, ∃ δ : ℝ≥0, 0 < δ ∧ ∀ (t : Set E), ApproximatesLinearOn f A t δ → μ (f '' t) ≤ (Real.toNNReal |A.det| + ε : ℝ≥0) * μ t := by intro A let m : ℝ≥0 := Real.toNNReal |A.det| + ε have I : ENNReal.ofReal |A.det| < m := by simp only [m, ENNReal.ofReal, lt_add_iff_pos_right, εpos, ENNReal.coe_lt_coe] rcases ((addHaar_image_le_mul_of_det_lt μ A I).and self_mem_nhdsWithin).exists with ⟨δ, h, h'⟩ exact ⟨δ, h', fun t ht => h t f ht⟩ choose δ hδ using this obtain ⟨t, A, t_disj, t_meas, t_cover, ht, Af'⟩ : ∃ (t : ℕ → Set E) (A : ℕ → E →L[ℝ] E), Pairwise (Disjoint on t) ∧ (∀ n : ℕ, MeasurableSet (t n)) ∧ (s ⊆ ⋃ n : ℕ, t n) ∧ (∀ n : ℕ, ApproximatesLinearOn f (A n) (s ∩ t n) (δ (A n))) ∧ (s.Nonempty → ∀ n, ∃ y ∈ s, A n = f' y) := exists_partition_approximatesLinearOn_of_hasFDerivWithinAt f s f' hf' δ fun A => (hδ A).1.ne' calc μ (f '' s) ≤ μ (⋃ n, f '' (s ∩ t n)) := by rw [← image_iUnion, ← inter_iUnion] gcongr exact subset_inter Subset.rfl t_cover _ ≤ ∑' n, μ (f '' (s ∩ t n)) := measure_iUnion_le _ _ ≤ ∑' n, (Real.toNNReal |(A n).det| + ε : ℝ≥0) * μ (s ∩ t n) := by gcongr exact (hδ (A _)).2 _ (ht _) _ = ∑' n, ε * μ (s ∩ t n) := by congr with n rcases Af' h's n with ⟨y, ys, hy⟩ simp only [hy, h'f' y ys, Real.toNNReal_zero, abs_zero, zero_add] _ ≤ ε * ∑' n, μ (closedBall 0 R ∩ t n) := by rw [ENNReal.tsum_mul_left] gcongr _ = ε * μ (⋃ n, closedBall 0 R ∩ t n) := by rw [measure_iUnion] · exact pairwise_disjoint_mono t_disj fun n => inter_subset_right · intro n exact measurableSet_closedBall.inter (t_meas n) _ ≤ ε * μ (closedBall 0 R) := by rw [← inter_iUnion] exact mul_le_mul_left' (measure_mono inter_subset_left) _ #align measure_theory.add_haar_image_eq_zero_of_det_fderiv_within_eq_zero_aux MeasureTheory.addHaar_image_eq_zero_of_det_fderivWithin_eq_zero_aux theorem addHaar_image_eq_zero_of_det_fderivWithin_eq_zero (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (h'f' : ∀ x ∈ s, (f' x).det = 0) : μ (f '' s) = 0 := by suffices H : ∀ R, μ (f '' (s ∩ closedBall 0 R)) = 0 by apply le_antisymm _ (zero_le _) rw [← iUnion_inter_closedBall_nat s 0] calc μ (f '' ⋃ n : ℕ, s ∩ closedBall 0 n) ≤ ∑' n : ℕ, μ (f '' (s ∩ closedBall 0 n)) := by rw [image_iUnion]; exact measure_iUnion_le _ _ ≤ 0 := by simp only [H, tsum_zero, nonpos_iff_eq_zero] intro R have A : ∀ (ε : ℝ≥0), 0 < ε → μ (f '' (s ∩ closedBall 0 R)) ≤ ε * μ (closedBall 0 R) := fun ε εpos => addHaar_image_eq_zero_of_det_fderivWithin_eq_zero_aux μ (fun x hx => (hf' x hx.1).mono inter_subset_left) R inter_subset_right ε εpos fun x hx => h'f' x hx.1 have B : Tendsto (fun ε : ℝ≥0 => (ε : ℝ≥0∞) * μ (closedBall 0 R)) (𝓝[>] 0) (𝓝 0) := by have : Tendsto (fun ε : ℝ≥0 => (ε : ℝ≥0∞) * μ (closedBall 0 R)) (𝓝 0) (𝓝 (((0 : ℝ≥0) : ℝ≥0∞) * μ (closedBall 0 R))) := ENNReal.Tendsto.mul_const (ENNReal.tendsto_coe.2 tendsto_id) (Or.inr measure_closedBall_lt_top.ne) simp only [zero_mul, ENNReal.coe_zero] at this exact Tendsto.mono_left this nhdsWithin_le_nhds apply le_antisymm _ (zero_le _) apply ge_of_tendsto B filter_upwards [self_mem_nhdsWithin] exact A #align measure_theory.add_haar_image_eq_zero_of_det_fderiv_within_eq_zero MeasureTheory.addHaar_image_eq_zero_of_det_fderivWithin_eq_zero theorem aemeasurable_fderivWithin (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) : AEMeasurable f' (μ.restrict s) := by -- fix a precision `ε` refine aemeasurable_of_unif_approx fun ε εpos => ?_ let δ : ℝ≥0 := ⟨ε, le_of_lt εpos⟩ have δpos : 0 < δ := εpos -- partition `s` into sets `s ∩ t n` on which `f` is approximated by linear maps `A n`. obtain ⟨t, A, t_disj, t_meas, t_cover, ht, _⟩ : ∃ (t : ℕ → Set E) (A : ℕ → E →L[ℝ] E), Pairwise (Disjoint on t) ∧ (∀ n : ℕ, MeasurableSet (t n)) ∧ (s ⊆ ⋃ n : ℕ, t n) ∧ (∀ n : ℕ, ApproximatesLinearOn f (A n) (s ∩ t n) δ) ∧ (s.Nonempty → ∀ n, ∃ y ∈ s, A n = f' y) := exists_partition_approximatesLinearOn_of_hasFDerivWithinAt f s f' hf' (fun _ => δ) fun _ => δpos.ne' -- define a measurable function `g` which coincides with `A n` on `t n`. obtain ⟨g, g_meas, hg⟩ : ∃ g : E → E →L[ℝ] E, Measurable g ∧ ∀ (n : ℕ) (x : E), x ∈ t n → g x = A n := exists_measurable_piecewise t t_meas (fun n _ => A n) (fun n => measurable_const) <| t_disj.mono fun i j h => by simp only [h.inter_eq, eqOn_empty] refine ⟨g, g_meas.aemeasurable, ?_⟩ -- reduce to checking that `f'` and `g` are close on almost all of `s ∩ t n`, for all `n`. suffices H : ∀ᵐ x : E ∂sum fun n ↦ μ.restrict (s ∩ t n), dist (g x) (f' x) ≤ ε by have : μ.restrict s ≤ sum fun n => μ.restrict (s ∩ t n) := by have : s = ⋃ n, s ∩ t n := by rw [← inter_iUnion] exact Subset.antisymm (subset_inter Subset.rfl t_cover) inter_subset_left conv_lhs => rw [this] exact restrict_iUnion_le exact ae_mono this H -- fix such an `n`. refine ae_sum_iff.2 fun n => ?_ -- on almost all `s ∩ t n`, `f' x` is close to `A n` thanks to -- `ApproximatesLinearOn.norm_fderiv_sub_le`. have E₁ : ∀ᵐ x : E ∂μ.restrict (s ∩ t n), ‖f' x - A n‖₊ ≤ δ := (ht n).norm_fderiv_sub_le μ (hs.inter (t_meas n)) f' fun x hx => (hf' x hx.1).mono inter_subset_left -- moreover, `g x` is equal to `A n` there. have E₂ : ∀ᵐ x : E ∂μ.restrict (s ∩ t n), g x = A n := by suffices H : ∀ᵐ x : E ∂μ.restrict (t n), g x = A n from ae_mono (restrict_mono inter_subset_right le_rfl) H filter_upwards [ae_restrict_mem (t_meas n)] exact hg n -- putting these two properties together gives the conclusion. filter_upwards [E₁, E₂] with x hx1 hx2 rw [← nndist_eq_nnnorm] at hx1 rw [hx2, dist_comm] exact hx1 #align measure_theory.ae_measurable_fderiv_within MeasureTheory.aemeasurable_fderivWithin theorem aemeasurable_ofReal_abs_det_fderivWithin (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) : AEMeasurable (fun x => ENNReal.ofReal |(f' x).det|) (μ.restrict s) := by apply ENNReal.measurable_ofReal.comp_aemeasurable refine continuous_abs.measurable.comp_aemeasurable ?_ refine ContinuousLinearMap.continuous_det.measurable.comp_aemeasurable ?_ exact aemeasurable_fderivWithin μ hs hf' #align measure_theory.ae_measurable_of_real_abs_det_fderiv_within MeasureTheory.aemeasurable_ofReal_abs_det_fderivWithin theorem aemeasurable_toNNReal_abs_det_fderivWithin (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) : AEMeasurable (fun x => |(f' x).det|.toNNReal) (μ.restrict s) := by apply measurable_real_toNNReal.comp_aemeasurable refine continuous_abs.measurable.comp_aemeasurable ?_ refine ContinuousLinearMap.continuous_det.measurable.comp_aemeasurable ?_ exact aemeasurable_fderivWithin μ hs hf' #align measure_theory.ae_measurable_to_nnreal_abs_det_fderiv_within MeasureTheory.aemeasurable_toNNReal_abs_det_fderivWithin theorem measurable_image_of_fderivWithin (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : MeasurableSet (f '' s) := haveI : DifferentiableOn ℝ f s := fun x hx => (hf' x hx).differentiableWithinAt hs.image_of_continuousOn_injOn (DifferentiableOn.continuousOn this) hf #align measure_theory.measurable_image_of_fderiv_within MeasureTheory.measurable_image_of_fderivWithin theorem measurableEmbedding_of_fderivWithin (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : MeasurableEmbedding (s.restrict f) := haveI : DifferentiableOn ℝ f s := fun x hx => (hf' x hx).differentiableWithinAt this.continuousOn.measurableEmbedding hs hf #align measure_theory.measurable_embedding_of_fderiv_within MeasureTheory.measurableEmbedding_of_fderivWithin theorem addHaar_image_le_lintegral_abs_det_fderiv_aux1 (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) {ε : ℝ≥0} (εpos : 0 < ε) : μ (f '' s) ≤ (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) + 2 * ε * μ s := by have : ∀ A : E →L[ℝ] E, ∃ δ : ℝ≥0, 0 < δ ∧ (∀ B : E →L[ℝ] E, ‖B - A‖ ≤ δ → |B.det - A.det| ≤ ε) ∧ ∀ (t : Set E) (g : E → E), ApproximatesLinearOn g A t δ → μ (g '' t) ≤ (ENNReal.ofReal |A.det| + ε) * μ t := by intro A let m : ℝ≥0 := Real.toNNReal |A.det| + ε have I : ENNReal.ofReal |A.det| < m := by simp only [m, ENNReal.ofReal, lt_add_iff_pos_right, εpos, ENNReal.coe_lt_coe] rcases ((addHaar_image_le_mul_of_det_lt μ A I).and self_mem_nhdsWithin).exists with ⟨δ, h, δpos⟩ obtain ⟨δ', δ'pos, hδ'⟩ : ∃ (δ' : ℝ), 0 < δ' ∧ ∀ B, dist B A < δ' → dist B.det A.det < ↑ε := continuousAt_iff.1 ContinuousLinearMap.continuous_det.continuousAt ε εpos let δ'' : ℝ≥0 := ⟨δ' / 2, (half_pos δ'pos).le⟩ refine ⟨min δ δ'', lt_min δpos (half_pos δ'pos), ?_, ?_⟩ · intro B hB rw [← Real.dist_eq] apply (hδ' B _).le rw [dist_eq_norm] calc ‖B - A‖ ≤ (min δ δ'' : ℝ≥0) := hB _ ≤ δ'' := by simp only [le_refl, NNReal.coe_min, min_le_iff, or_true_iff] _ < δ' := half_lt_self δ'pos · intro t g htg exact h t g (htg.mono_num (min_le_left _ _)) choose δ hδ using this obtain ⟨t, A, t_disj, t_meas, t_cover, ht, -⟩ : ∃ (t : ℕ → Set E) (A : ℕ → E →L[ℝ] E), Pairwise (Disjoint on t) ∧ (∀ n : ℕ, MeasurableSet (t n)) ∧ (s ⊆ ⋃ n : ℕ, t n) ∧ (∀ n : ℕ, ApproximatesLinearOn f (A n) (s ∩ t n) (δ (A n))) ∧ (s.Nonempty → ∀ n, ∃ y ∈ s, A n = f' y) := exists_partition_approximatesLinearOn_of_hasFDerivWithinAt f s f' hf' δ fun A => (hδ A).1.ne' calc μ (f '' s) ≤ μ (⋃ n, f '' (s ∩ t n)) := by apply measure_mono rw [← image_iUnion, ← inter_iUnion] exact image_subset f (subset_inter Subset.rfl t_cover) _ ≤ ∑' n, μ (f '' (s ∩ t n)) := measure_iUnion_le _ _ ≤ ∑' n, (ENNReal.ofReal |(A n).det| + ε) * μ (s ∩ t n) := by apply ENNReal.tsum_le_tsum fun n => ?_ apply (hδ (A n)).2.2 exact ht n _ = ∑' n, ∫⁻ _ in s ∩ t n, ENNReal.ofReal |(A n).det| + ε ∂μ := by simp only [lintegral_const, MeasurableSet.univ, Measure.restrict_apply, univ_inter] _ ≤ ∑' n, ∫⁻ x in s ∩ t n, ENNReal.ofReal |(f' x).det| + 2 * ε ∂μ := by apply ENNReal.tsum_le_tsum fun n => ?_ apply lintegral_mono_ae filter_upwards [(ht n).norm_fderiv_sub_le μ (hs.inter (t_meas n)) f' fun x hx => (hf' x hx.1).mono inter_subset_left] intro x hx have I : |(A n).det| ≤ |(f' x).det| + ε := calc |(A n).det| = |(f' x).det - ((f' x).det - (A n).det)| := by congr 1; abel _ ≤ |(f' x).det| + |(f' x).det - (A n).det| := abs_sub _ _ _ ≤ |(f' x).det| + ε := add_le_add le_rfl ((hδ (A n)).2.1 _ hx) calc ENNReal.ofReal |(A n).det| + ε ≤ ENNReal.ofReal (|(f' x).det| + ε) + ε := by gcongr _ = ENNReal.ofReal |(f' x).det| + 2 * ε := by simp only [ENNReal.ofReal_add, abs_nonneg, two_mul, add_assoc, NNReal.zero_le_coe, ENNReal.ofReal_coe_nnreal] _ = ∫⁻ x in ⋃ n, s ∩ t n, ENNReal.ofReal |(f' x).det| + 2 * ε ∂μ := by have M : ∀ n : ℕ, MeasurableSet (s ∩ t n) := fun n => hs.inter (t_meas n) rw [lintegral_iUnion M] exact pairwise_disjoint_mono t_disj fun n => inter_subset_right _ = ∫⁻ x in s, ENNReal.ofReal |(f' x).det| + 2 * ε ∂μ := by rw [← inter_iUnion, inter_eq_self_of_subset_left t_cover] _ = (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) + 2 * ε * μ s := by simp only [lintegral_add_right' _ aemeasurable_const, set_lintegral_const] #align measure_theory.add_haar_image_le_lintegral_abs_det_fderiv_aux1 MeasureTheory.addHaar_image_le_lintegral_abs_det_fderiv_aux1 theorem addHaar_image_le_lintegral_abs_det_fderiv_aux2 (hs : MeasurableSet s) (h's : μ s ≠ ∞) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) : μ (f '' s) ≤ ∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ := by -- We just need to let the error tend to `0` in the previous lemma. have : Tendsto (fun ε : ℝ≥0 => (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) + 2 * ε * μ s) (𝓝[>] 0) (𝓝 ((∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) + 2 * (0 : ℝ≥0) * μ s)) := by apply Tendsto.mono_left _ nhdsWithin_le_nhds refine tendsto_const_nhds.add ?_ refine ENNReal.Tendsto.mul_const ?_ (Or.inr h's) exact ENNReal.Tendsto.const_mul (ENNReal.tendsto_coe.2 tendsto_id) (Or.inr ENNReal.coe_ne_top) simp only [add_zero, zero_mul, mul_zero, ENNReal.coe_zero] at this apply ge_of_tendsto this filter_upwards [self_mem_nhdsWithin] intro ε εpos rw [mem_Ioi] at εpos exact addHaar_image_le_lintegral_abs_det_fderiv_aux1 μ hs hf' εpos #align measure_theory.add_haar_image_le_lintegral_abs_det_fderiv_aux2 MeasureTheory.addHaar_image_le_lintegral_abs_det_fderiv_aux2 theorem addHaar_image_le_lintegral_abs_det_fderiv (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) : μ (f '' s) ≤ ∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ := by let u n := disjointed (spanningSets μ) n have u_meas : ∀ n, MeasurableSet (u n) := by intro n apply MeasurableSet.disjointed fun i => ?_ exact measurable_spanningSets μ i have A : s = ⋃ n, s ∩ u n := by rw [← inter_iUnion, iUnion_disjointed, iUnion_spanningSets, inter_univ] calc μ (f '' s) ≤ ∑' n, μ (f '' (s ∩ u n)) := by conv_lhs => rw [A, image_iUnion] exact measure_iUnion_le _ _ ≤ ∑' n, ∫⁻ x in s ∩ u n, ENNReal.ofReal |(f' x).det| ∂μ := by apply ENNReal.tsum_le_tsum fun n => ?_ apply addHaar_image_le_lintegral_abs_det_fderiv_aux2 μ (hs.inter (u_meas n)) _ fun x hx => (hf' x hx.1).mono inter_subset_left have : μ (u n) < ∞ := lt_of_le_of_lt (measure_mono (disjointed_subset _ _)) (measure_spanningSets_lt_top μ n) exact ne_of_lt (lt_of_le_of_lt (measure_mono inter_subset_right) this) _ = ∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ := by conv_rhs => rw [A] rw [lintegral_iUnion] · intro n; exact hs.inter (u_meas n) · exact pairwise_disjoint_mono (disjoint_disjointed _) fun n => inter_subset_right #align measure_theory.add_haar_image_le_lintegral_abs_det_fderiv MeasureTheory.addHaar_image_le_lintegral_abs_det_fderiv theorem lintegral_abs_det_fderiv_le_addHaar_image_aux1 (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) {ε : ℝ≥0} (εpos : 0 < ε) : (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) ≤ μ (f '' s) + 2 * ε * μ s := by have : ∀ A : E →L[ℝ] E, ∃ δ : ℝ≥0, 0 < δ ∧ (∀ B : E →L[ℝ] E, ‖B - A‖ ≤ δ → |B.det - A.det| ≤ ε) ∧ ∀ (t : Set E) (g : E → E), ApproximatesLinearOn g A t δ → ENNReal.ofReal |A.det| * μ t ≤ μ (g '' t) + ε * μ t := by intro A obtain ⟨δ', δ'pos, hδ'⟩ : ∃ (δ' : ℝ), 0 < δ' ∧ ∀ B, dist B A < δ' → dist B.det A.det < ↑ε := continuousAt_iff.1 ContinuousLinearMap.continuous_det.continuousAt ε εpos let δ'' : ℝ≥0 := ⟨δ' / 2, (half_pos δ'pos).le⟩ have I'' : ∀ B : E →L[ℝ] E, ‖B - A‖ ≤ ↑δ'' → |B.det - A.det| ≤ ↑ε := by intro B hB rw [← Real.dist_eq] apply (hδ' B _).le rw [dist_eq_norm] exact hB.trans_lt (half_lt_self δ'pos) rcases eq_or_ne A.det 0 with (hA | hA) · refine ⟨δ'', half_pos δ'pos, I'', ?_⟩ simp only [hA, forall_const, zero_mul, ENNReal.ofReal_zero, imp_true_iff, zero_le, abs_zero] let m : ℝ≥0 := Real.toNNReal |A.det| - ε have I : (m : ℝ≥0∞) < ENNReal.ofReal |A.det| := by simp only [m, ENNReal.ofReal, ENNReal.coe_sub] apply ENNReal.sub_lt_self ENNReal.coe_ne_top · simpa only [abs_nonpos_iff, Real.toNNReal_eq_zero, ENNReal.coe_eq_zero, Ne] using hA · simp only [εpos.ne', ENNReal.coe_eq_zero, Ne, not_false_iff] rcases ((mul_le_addHaar_image_of_lt_det μ A I).and self_mem_nhdsWithin).exists with ⟨δ, h, δpos⟩ refine ⟨min δ δ'', lt_min δpos (half_pos δ'pos), ?_, ?_⟩ · intro B hB apply I'' _ (hB.trans _) simp only [le_refl, NNReal.coe_min, min_le_iff, or_true_iff] · intro t g htg rcases eq_or_ne (μ t) ∞ with (ht | ht) · simp only [ht, εpos.ne', ENNReal.mul_top, ENNReal.coe_eq_zero, le_top, Ne, not_false_iff, _root_.add_top] have := h t g (htg.mono_num (min_le_left _ _)) rwa [ENNReal.coe_sub, ENNReal.sub_mul, tsub_le_iff_right] at this simp only [ht, imp_true_iff, Ne, not_false_iff] choose δ hδ using this obtain ⟨t, A, t_disj, t_meas, t_cover, ht, -⟩ : ∃ (t : ℕ → Set E) (A : ℕ → E →L[ℝ] E), Pairwise (Disjoint on t) ∧ (∀ n : ℕ, MeasurableSet (t n)) ∧ (s ⊆ ⋃ n : ℕ, t n) ∧ (∀ n : ℕ, ApproximatesLinearOn f (A n) (s ∩ t n) (δ (A n))) ∧ (s.Nonempty → ∀ n, ∃ y ∈ s, A n = f' y) := exists_partition_approximatesLinearOn_of_hasFDerivWithinAt f s f' hf' δ fun A => (hδ A).1.ne' have s_eq : s = ⋃ n, s ∩ t n := by rw [← inter_iUnion] exact Subset.antisymm (subset_inter Subset.rfl t_cover) inter_subset_left calc (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) = ∑' n, ∫⁻ x in s ∩ t n, ENNReal.ofReal |(f' x).det| ∂μ := by conv_lhs => rw [s_eq] rw [lintegral_iUnion] · exact fun n => hs.inter (t_meas n) · exact pairwise_disjoint_mono t_disj fun n => inter_subset_right _ ≤ ∑' n, ∫⁻ _ in s ∩ t n, ENNReal.ofReal |(A n).det| + ε ∂μ := by apply ENNReal.tsum_le_tsum fun n => ?_ apply lintegral_mono_ae filter_upwards [(ht n).norm_fderiv_sub_le μ (hs.inter (t_meas n)) f' fun x hx => (hf' x hx.1).mono inter_subset_left] intro x hx have I : |(f' x).det| ≤ |(A n).det| + ε := calc |(f' x).det| = |(A n).det + ((f' x).det - (A n).det)| := by congr 1; abel _ ≤ |(A n).det| + |(f' x).det - (A n).det| := abs_add _ _ _ ≤ |(A n).det| + ε := add_le_add le_rfl ((hδ (A n)).2.1 _ hx) calc ENNReal.ofReal |(f' x).det| ≤ ENNReal.ofReal (|(A n).det| + ε) := ENNReal.ofReal_le_ofReal I _ = ENNReal.ofReal |(A n).det| + ε := by simp only [ENNReal.ofReal_add, abs_nonneg, NNReal.zero_le_coe, ENNReal.ofReal_coe_nnreal] _ = ∑' n, (ENNReal.ofReal |(A n).det| * μ (s ∩ t n) + ε * μ (s ∩ t n)) := by simp only [set_lintegral_const, lintegral_add_right _ measurable_const] _ ≤ ∑' n, (μ (f '' (s ∩ t n)) + ε * μ (s ∩ t n) + ε * μ (s ∩ t n)) := by gcongr exact (hδ (A _)).2.2 _ _ (ht _) _ = μ (f '' s) + 2 * ε * μ s := by conv_rhs => rw [s_eq] rw [image_iUnion, measure_iUnion]; rotate_left · intro i j hij apply Disjoint.image _ hf inter_subset_left inter_subset_left exact Disjoint.mono inter_subset_right inter_subset_right (t_disj hij) · intro i exact measurable_image_of_fderivWithin (hs.inter (t_meas i)) (fun x hx => (hf' x hx.1).mono inter_subset_left) (hf.mono inter_subset_left) rw [measure_iUnion]; rotate_left · exact pairwise_disjoint_mono t_disj fun i => inter_subset_right · exact fun i => hs.inter (t_meas i) rw [← ENNReal.tsum_mul_left, ← ENNReal.tsum_add] congr 1 ext1 i rw [mul_assoc, two_mul, add_assoc] #align measure_theory.lintegral_abs_det_fderiv_le_add_haar_image_aux1 MeasureTheory.lintegral_abs_det_fderiv_le_addHaar_image_aux1 theorem lintegral_abs_det_fderiv_le_addHaar_image_aux2 (hs : MeasurableSet s) (h's : μ s ≠ ∞) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) ≤ μ (f '' s) := by -- We just need to let the error tend to `0` in the previous lemma. have : Tendsto (fun ε : ℝ≥0 => μ (f '' s) + 2 * ε * μ s) (𝓝[>] 0) (𝓝 (μ (f '' s) + 2 * (0 : ℝ≥0) * μ s)) := by apply Tendsto.mono_left _ nhdsWithin_le_nhds refine tendsto_const_nhds.add ?_ refine ENNReal.Tendsto.mul_const ?_ (Or.inr h's) exact ENNReal.Tendsto.const_mul (ENNReal.tendsto_coe.2 tendsto_id) (Or.inr ENNReal.coe_ne_top) simp only [add_zero, zero_mul, mul_zero, ENNReal.coe_zero] at this apply ge_of_tendsto this filter_upwards [self_mem_nhdsWithin] intro ε εpos rw [mem_Ioi] at εpos exact lintegral_abs_det_fderiv_le_addHaar_image_aux1 μ hs hf' hf εpos #align measure_theory.lintegral_abs_det_fderiv_le_add_haar_image_aux2 MeasureTheory.lintegral_abs_det_fderiv_le_addHaar_image_aux2 theorem lintegral_abs_det_fderiv_le_addHaar_image (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) ≤ μ (f '' s) := by let u n := disjointed (spanningSets μ) n have u_meas : ∀ n, MeasurableSet (u n) := by intro n apply MeasurableSet.disjointed fun i => ?_ exact measurable_spanningSets μ i have A : s = ⋃ n, s ∩ u n := by rw [← inter_iUnion, iUnion_disjointed, iUnion_spanningSets, inter_univ] calc (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) = ∑' n, ∫⁻ x in s ∩ u n, ENNReal.ofReal |(f' x).det| ∂μ := by conv_lhs => rw [A] rw [lintegral_iUnion] · intro n; exact hs.inter (u_meas n) · exact pairwise_disjoint_mono (disjoint_disjointed _) fun n => inter_subset_right _ ≤ ∑' n, μ (f '' (s ∩ u n)) := by apply ENNReal.tsum_le_tsum fun n => ?_ apply lintegral_abs_det_fderiv_le_addHaar_image_aux2 μ (hs.inter (u_meas n)) _ (fun x hx => (hf' x hx.1).mono inter_subset_left) (hf.mono inter_subset_left) have : μ (u n) < ∞ := lt_of_le_of_lt (measure_mono (disjointed_subset _ _)) (measure_spanningSets_lt_top μ n) exact ne_of_lt (lt_of_le_of_lt (measure_mono inter_subset_right) this) _ = μ (f '' s) := by conv_rhs => rw [A, image_iUnion] rw [measure_iUnion] · intro i j hij apply Disjoint.image _ hf inter_subset_left inter_subset_left exact Disjoint.mono inter_subset_right inter_subset_right (disjoint_disjointed _ hij) · intro i exact measurable_image_of_fderivWithin (hs.inter (u_meas i)) (fun x hx => (hf' x hx.1).mono inter_subset_left) (hf.mono inter_subset_left) #align measure_theory.lintegral_abs_det_fderiv_le_add_haar_image MeasureTheory.lintegral_abs_det_fderiv_le_addHaar_image theorem lintegral_abs_det_fderiv_eq_addHaar_image (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) = μ (f '' s) := le_antisymm (lintegral_abs_det_fderiv_le_addHaar_image μ hs hf' hf) (addHaar_image_le_lintegral_abs_det_fderiv μ hs hf') #align measure_theory.lintegral_abs_det_fderiv_eq_add_haar_image MeasureTheory.lintegral_abs_det_fderiv_eq_addHaar_image theorem map_withDensity_abs_det_fderiv_eq_addHaar (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) (h'f : Measurable f) : Measure.map f ((μ.restrict s).withDensity fun x => ENNReal.ofReal |(f' x).det|) = μ.restrict (f '' s) := by apply Measure.ext fun t ht => ?_ rw [map_apply h'f ht, withDensity_apply _ (h'f ht), Measure.restrict_apply ht, restrict_restrict (h'f ht), lintegral_abs_det_fderiv_eq_addHaar_image μ ((h'f ht).inter hs) (fun x hx => (hf' x hx.2).mono inter_subset_right) (hf.mono inter_subset_right), image_preimage_inter] #align measure_theory.map_with_density_abs_det_fderiv_eq_add_haar MeasureTheory.map_withDensity_abs_det_fderiv_eq_addHaar
Mathlib/MeasureTheory/Function/Jacobian.lean
1,128
1,151
theorem restrict_map_withDensity_abs_det_fderiv_eq_addHaar (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : Measure.map (s.restrict f) (comap (↑) (μ.withDensity fun x => ENNReal.ofReal |(f' x).det|)) = μ.restrict (f '' s) := by
obtain ⟨u, u_meas, uf⟩ : ∃ u, Measurable u ∧ EqOn u f s := by classical refine ⟨piecewise s f 0, ?_, piecewise_eqOn _ _ _⟩ refine ContinuousOn.measurable_piecewise ?_ continuous_zero.continuousOn hs have : DifferentiableOn ℝ f s := fun x hx => (hf' x hx).differentiableWithinAt exact this.continuousOn have u' : ∀ x ∈ s, HasFDerivWithinAt u (f' x) s x := fun x hx => (hf' x hx).congr (fun y hy => uf hy) (uf hx) set F : s → E := u ∘ (↑) with hF have A : Measure.map F (comap (↑) (μ.withDensity fun x => ENNReal.ofReal |(f' x).det|)) = μ.restrict (u '' s) := by rw [hF, ← Measure.map_map u_meas measurable_subtype_coe, map_comap_subtype_coe hs, restrict_withDensity hs] exact map_withDensity_abs_det_fderiv_eq_addHaar μ hs u' (hf.congr uf.symm) u_meas rw [uf.image_eq] at A have : F = s.restrict f := by ext x exact uf x.2 rwa [this] at A
import Mathlib.Order.Partition.Equipartition #align_import combinatorics.simple_graph.regularity.equitabilise from "leanprover-community/mathlib"@"bf7ef0e83e5b7e6c1169e97f055e58a2e4e9d52d" open Finset Nat namespace Finpartition variable {α : Type*} [DecidableEq α] {s t : Finset α} {m n a b : ℕ} {P : Finpartition s} theorem equitabilise_aux (hs : a * m + b * (m + 1) = s.card) : ∃ Q : Finpartition s, (∀ x : Finset α, x ∈ Q.parts → x.card = m ∨ x.card = m + 1) ∧ (∀ x, x ∈ P.parts → (x \ (Q.parts.filter fun y => y ⊆ x).biUnion id).card ≤ m) ∧ (Q.parts.filter fun i => card i = m + 1).card = b := by -- Get rid of the easy case `m = 0` obtain rfl | m_pos := m.eq_zero_or_pos · refine ⟨⊥, by simp, ?_, by simpa [Finset.filter_true_of_mem] using hs.symm⟩ simp only [le_zero_iff, card_eq_zero, mem_biUnion, exists_prop, mem_filter, id, and_assoc, sdiff_eq_empty_iff_subset, subset_iff] exact fun x hx a ha => ⟨{a}, mem_map_of_mem _ (P.le hx ha), singleton_subset_iff.2 ha, mem_singleton_self _⟩ -- Prove the case `m > 0` by strong induction on `s` induction' s using Finset.strongInduction with s ih generalizing a b -- If `a = b = 0`, then `s = ∅` and we can partition into zero parts by_cases hab : a = 0 ∧ b = 0 · simp only [hab.1, hab.2, add_zero, zero_mul, eq_comm, card_eq_zero, Finset.bot_eq_empty] at hs subst hs -- Porting note: to synthesize `Finpartition ∅`, `have` is required have : P = Finpartition.empty _ := Unique.eq_default (α := Finpartition ⊥) P exact ⟨Finpartition.empty _, by simp, by simp [this], by simp [hab.2]⟩ simp_rw [not_and_or, ← Ne.eq_def, ← pos_iff_ne_zero] at hab -- `n` will be the size of the smallest part set n := if 0 < a then m else m + 1 with hn -- Some easy facts about it obtain ⟨hn₀, hn₁, hn₂, hn₃⟩ : 0 < n ∧ n ≤ m + 1 ∧ n ≤ a * m + b * (m + 1) ∧ ite (0 < a) (a - 1) a * m + ite (0 < a) b (b - 1) * (m + 1) = s.card - n := by rw [hn, ← hs] split_ifs with h <;> rw [tsub_mul, one_mul] · refine ⟨m_pos, le_succ _, le_add_right (Nat.le_mul_of_pos_left _ ‹0 < a›), ?_⟩ rw [tsub_add_eq_add_tsub (Nat.le_mul_of_pos_left _ h)] · refine ⟨succ_pos', le_rfl, le_add_left (Nat.le_mul_of_pos_left _ <| hab.resolve_left ‹¬0 < a›), ?_⟩ rw [← add_tsub_assoc_of_le (Nat.le_mul_of_pos_left _ <| hab.resolve_left ‹¬0 < a›)] by_cases h : ∀ u ∈ P.parts, card u < m + 1 · obtain ⟨t, hts, htn⟩ := exists_smaller_set s n (hn₂.trans_eq hs) have ht : t.Nonempty := by rwa [← card_pos, htn] have hcard : ite (0 < a) (a - 1) a * m + ite (0 < a) b (b - 1) * (m + 1) = (s \ t).card := by rw [card_sdiff ‹t ⊆ s›, htn, hn₃] obtain ⟨R, hR₁, _, hR₃⟩ := @ih (s \ t) (sdiff_ssubset hts ‹t.Nonempty›) (if 0 < a then a - 1 else a) (if 0 < a then b else b - 1) (P.avoid t) hcard refine ⟨R.extend ht.ne_empty sdiff_disjoint (sdiff_sup_cancel hts), ?_, ?_, ?_⟩ · simp only [extend_parts, mem_insert, forall_eq_or_imp, and_iff_left hR₁, htn, hn] exact ite_eq_or_eq _ _ _ · exact fun x hx => (card_le_card sdiff_subset).trans (Nat.lt_succ_iff.1 <| h _ hx) simp_rw [extend_parts, filter_insert, htn, m.succ_ne_self.symm.ite_eq_right_iff] split_ifs with ha · rw [hR₃, if_pos ha] rw [card_insert_of_not_mem, hR₃, if_neg ha, tsub_add_cancel_of_le] · exact hab.resolve_left ha · intro H; exact ht.ne_empty (le_sdiff_iff.1 <| R.le <| filter_subset _ _ H) push_neg at h obtain ⟨u, hu₁, hu₂⟩ := h obtain ⟨t, htu, htn⟩ := exists_smaller_set _ _ (hn₁.trans hu₂) have ht : t.Nonempty := by rwa [← card_pos, htn] have hcard : ite (0 < a) (a - 1) a * m + ite (0 < a) b (b - 1) * (m + 1) = (s \ t).card := by rw [card_sdiff (htu.trans <| P.le hu₁), htn, hn₃] obtain ⟨R, hR₁, hR₂, hR₃⟩ := @ih (s \ t) (sdiff_ssubset (htu.trans <| P.le hu₁) ht) (if 0 < a then a - 1 else a) (if 0 < a then b else b - 1) (P.avoid t) hcard refine ⟨R.extend ht.ne_empty sdiff_disjoint (sdiff_sup_cancel <| htu.trans <| P.le hu₁), ?_, ?_, ?_⟩ · simp only [mem_insert, forall_eq_or_imp, extend_parts, and_iff_left hR₁, htn, hn] exact ite_eq_or_eq _ _ _ · conv in _ ∈ _ => rw [← insert_erase hu₁] simp only [and_imp, mem_insert, forall_eq_or_imp, Ne, extend_parts] refine ⟨?_, fun x hx => (card_le_card ?_).trans <| hR₂ x ?_⟩ · simp only [filter_insert, if_pos htu, biUnion_insert, mem_erase, id] obtain rfl | hut := eq_or_ne u t · rw [sdiff_eq_empty_iff_subset.2 subset_union_left] exact bot_le refine (card_le_card fun i => ?_).trans (hR₂ (u \ t) <| P.mem_avoid.2 ⟨u, hu₁, fun i => hut <| i.antisymm htu, rfl⟩) -- Porting note: `not_and` required because `∃ x ∈ s, p x` is defined differently simp only [not_exists, not_and, mem_biUnion, and_imp, mem_union, mem_filter, mem_sdiff, id, not_or] exact fun hi₁ hi₂ hi₃ => ⟨⟨hi₁, hi₂⟩, fun x hx hx' => hi₃ _ hx <| hx'.trans sdiff_subset⟩ · apply sdiff_subset_sdiff Subset.rfl (biUnion_subset_biUnion_of_subset_left _ _) exact filter_subset_filter _ (subset_insert _ _) simp only [avoid, ofErase, mem_erase, mem_image, bot_eq_empty] exact ⟨(nonempty_of_mem_parts _ <| mem_of_mem_erase hx).ne_empty, _, mem_of_mem_erase hx, (disjoint_of_subset_right htu <| P.disjoint (mem_of_mem_erase hx) hu₁ <| ne_of_mem_erase hx).sdiff_eq_left⟩ simp only [extend_parts, filter_insert, htn, hn, m.succ_ne_self.symm.ite_eq_right_iff] split_ifs with h · rw [hR₃, if_pos h] · rw [card_insert_of_not_mem, hR₃, if_neg h, Nat.sub_add_cancel (hab.resolve_left h)] intro H; exact ht.ne_empty (le_sdiff_iff.1 <| R.le <| filter_subset _ _ H) #align finpartition.equitabilise_aux Finpartition.equitabilise_aux variable (h : a * m + b * (m + 1) = s.card) noncomputable def equitabilise : Finpartition s := (P.equitabilise_aux h).choose #align finpartition.equitabilise Finpartition.equitabilise variable {h} theorem card_eq_of_mem_parts_equitabilise : t ∈ (P.equitabilise h).parts → t.card = m ∨ t.card = m + 1 := (P.equitabilise_aux h).choose_spec.1 _ #align finpartition.card_eq_of_mem_parts_equitabilise Finpartition.card_eq_of_mem_parts_equitabilise theorem equitabilise_isEquipartition : (P.equitabilise h).IsEquipartition := Set.equitableOn_iff_exists_eq_eq_add_one.2 ⟨m, fun _ => card_eq_of_mem_parts_equitabilise⟩ #align finpartition.equitabilise_is_equipartition Finpartition.equitabilise_isEquipartition variable (P h) theorem card_filter_equitabilise_big : ((P.equitabilise h).parts.filter fun u : Finset α => u.card = m + 1).card = b := (P.equitabilise_aux h).choose_spec.2.2 #align finpartition.card_filter_equitabilise_big Finpartition.card_filter_equitabilise_big
Mathlib/Combinatorics/SimpleGraph/Regularity/Equitabilise.lean
171
187
theorem card_filter_equitabilise_small (hm : m ≠ 0) : ((P.equitabilise h).parts.filter fun u : Finset α => u.card = m).card = a := by
refine (mul_eq_mul_right_iff.1 <| (add_left_inj (b * (m + 1))).1 ?_).resolve_right hm rw [h, ← (P.equitabilise h).sum_card_parts] have hunion : (P.equitabilise h).parts = ((P.equitabilise h).parts.filter fun u => u.card = m) ∪ (P.equitabilise h).parts.filter fun u => u.card = m + 1 := by rw [← filter_or, filter_true_of_mem] exact fun x => card_eq_of_mem_parts_equitabilise nth_rw 2 [hunion] rw [sum_union, sum_const_nat fun x hx => (mem_filter.1 hx).2, sum_const_nat fun x hx => (mem_filter.1 hx).2, P.card_filter_equitabilise_big] refine disjoint_filter_filter' _ _ ?_ intro x ha hb i h apply succ_ne_self m _ exact (hb i h).symm.trans (ha i h)
import Mathlib.Analysis.SpecialFunctions.Complex.Circle import Mathlib.Geometry.Euclidean.Angle.Oriented.Basic #align_import geometry.euclidean.angle.oriented.rotation from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" noncomputable section open FiniteDimensional Complex open scoped Real RealInnerProductSpace ComplexConjugate namespace Orientation attribute [local instance] Complex.finrank_real_complex_fact variable {V V' : Type*} variable [NormedAddCommGroup V] [NormedAddCommGroup V'] variable [InnerProductSpace ℝ V] [InnerProductSpace ℝ V'] variable [Fact (finrank ℝ V = 2)] [Fact (finrank ℝ V' = 2)] (o : Orientation ℝ V (Fin 2)) local notation "J" => o.rightAngleRotation def rotationAux (θ : Real.Angle) : V →ₗᵢ[ℝ] V := LinearMap.isometryOfInner (Real.Angle.cos θ • LinearMap.id + Real.Angle.sin θ • (LinearIsometryEquiv.toLinearEquiv J).toLinearMap) (by intro x y simp only [RCLike.conj_to_real, id, LinearMap.smul_apply, LinearMap.add_apply, LinearMap.id_coe, LinearEquiv.coe_coe, LinearIsometryEquiv.coe_toLinearEquiv, Orientation.areaForm_rightAngleRotation_left, Orientation.inner_rightAngleRotation_left, Orientation.inner_rightAngleRotation_right, inner_add_left, inner_smul_left, inner_add_right, inner_smul_right] linear_combination inner (𝕜 := ℝ) x y * θ.cos_sq_add_sin_sq) #align orientation.rotation_aux Orientation.rotationAux @[simp] theorem rotationAux_apply (θ : Real.Angle) (x : V) : o.rotationAux θ x = Real.Angle.cos θ • x + Real.Angle.sin θ • J x := rfl #align orientation.rotation_aux_apply Orientation.rotationAux_apply def rotation (θ : Real.Angle) : V ≃ₗᵢ[ℝ] V := LinearIsometryEquiv.ofLinearIsometry (o.rotationAux θ) (Real.Angle.cos θ • LinearMap.id - Real.Angle.sin θ • (LinearIsometryEquiv.toLinearEquiv J).toLinearMap) (by ext x convert congr_arg (fun t : ℝ => t • x) θ.cos_sq_add_sin_sq using 1 · simp only [o.rightAngleRotation_rightAngleRotation, o.rotationAux_apply, Function.comp_apply, id, LinearEquiv.coe_coe, LinearIsometry.coe_toLinearMap, LinearIsometryEquiv.coe_toLinearEquiv, map_smul, map_sub, LinearMap.coe_comp, LinearMap.id_coe, LinearMap.smul_apply, LinearMap.sub_apply, ← mul_smul, add_smul, smul_add, smul_neg, smul_sub, mul_comm, sq] abel · simp) (by ext x convert congr_arg (fun t : ℝ => t • x) θ.cos_sq_add_sin_sq using 1 · simp only [o.rightAngleRotation_rightAngleRotation, o.rotationAux_apply, Function.comp_apply, id, LinearEquiv.coe_coe, LinearIsometry.coe_toLinearMap, LinearIsometryEquiv.coe_toLinearEquiv, map_add, map_smul, LinearMap.coe_comp, LinearMap.id_coe, LinearMap.smul_apply, LinearMap.sub_apply, add_smul, smul_neg, smul_sub, smul_smul] ring_nf abel · simp) #align orientation.rotation Orientation.rotation theorem rotation_apply (θ : Real.Angle) (x : V) : o.rotation θ x = Real.Angle.cos θ • x + Real.Angle.sin θ • J x := rfl #align orientation.rotation_apply Orientation.rotation_apply theorem rotation_symm_apply (θ : Real.Angle) (x : V) : (o.rotation θ).symm x = Real.Angle.cos θ • x - Real.Angle.sin θ • J x := rfl #align orientation.rotation_symm_apply Orientation.rotation_symm_apply theorem rotation_eq_matrix_toLin (θ : Real.Angle) {x : V} (hx : x ≠ 0) : (o.rotation θ).toLinearMap = Matrix.toLin (o.basisRightAngleRotation x hx) (o.basisRightAngleRotation x hx) !![θ.cos, -θ.sin; θ.sin, θ.cos] := by apply (o.basisRightAngleRotation x hx).ext intro i fin_cases i · rw [Matrix.toLin_self] simp [rotation_apply, Fin.sum_univ_succ] · rw [Matrix.toLin_self] simp [rotation_apply, Fin.sum_univ_succ, add_comm] #align orientation.rotation_eq_matrix_to_lin Orientation.rotation_eq_matrix_toLin @[simp] theorem det_rotation (θ : Real.Angle) : LinearMap.det (o.rotation θ).toLinearMap = 1 := by haveI : Nontrivial V := FiniteDimensional.nontrivial_of_finrank_eq_succ (@Fact.out (finrank ℝ V = 2) _) obtain ⟨x, hx⟩ : ∃ x, x ≠ (0 : V) := exists_ne (0 : V) rw [o.rotation_eq_matrix_toLin θ hx] simpa [sq] using θ.cos_sq_add_sin_sq #align orientation.det_rotation Orientation.det_rotation @[simp] theorem linearEquiv_det_rotation (θ : Real.Angle) : LinearEquiv.det (o.rotation θ).toLinearEquiv = 1 := Units.ext <| by -- Porting note: Lean can't see through `LinearEquiv.coe_det` and needed the rewrite -- in mathlib3 this was just `units.ext <| o.det_rotation θ` simpa only [LinearEquiv.coe_det, Units.val_one] using o.det_rotation θ #align orientation.linear_equiv_det_rotation Orientation.linearEquiv_det_rotation @[simp] theorem rotation_symm (θ : Real.Angle) : (o.rotation θ).symm = o.rotation (-θ) := by ext; simp [o.rotation_apply, o.rotation_symm_apply, sub_eq_add_neg] #align orientation.rotation_symm Orientation.rotation_symm @[simp] theorem rotation_zero : o.rotation 0 = LinearIsometryEquiv.refl ℝ V := by ext; simp [rotation] #align orientation.rotation_zero Orientation.rotation_zero @[simp] theorem rotation_pi : o.rotation π = LinearIsometryEquiv.neg ℝ := by ext x simp [rotation] #align orientation.rotation_pi Orientation.rotation_pi theorem rotation_pi_apply (x : V) : o.rotation π x = -x := by simp #align orientation.rotation_pi_apply Orientation.rotation_pi_apply theorem rotation_pi_div_two : o.rotation (π / 2 : ℝ) = J := by ext x simp [rotation] #align orientation.rotation_pi_div_two Orientation.rotation_pi_div_two @[simp] theorem rotation_rotation (θ₁ θ₂ : Real.Angle) (x : V) : o.rotation θ₁ (o.rotation θ₂ x) = o.rotation (θ₁ + θ₂) x := by simp only [o.rotation_apply, ← mul_smul, Real.Angle.cos_add, Real.Angle.sin_add, add_smul, sub_smul, LinearIsometryEquiv.trans_apply, smul_add, LinearIsometryEquiv.map_add, LinearIsometryEquiv.map_smul, rightAngleRotation_rightAngleRotation, smul_neg] ring_nf abel #align orientation.rotation_rotation Orientation.rotation_rotation @[simp] theorem rotation_trans (θ₁ θ₂ : Real.Angle) : (o.rotation θ₁).trans (o.rotation θ₂) = o.rotation (θ₂ + θ₁) := LinearIsometryEquiv.ext fun _ => by rw [← rotation_rotation, LinearIsometryEquiv.trans_apply] #align orientation.rotation_trans Orientation.rotation_trans @[simp] theorem kahler_rotation_left (x y : V) (θ : Real.Angle) : o.kahler (o.rotation θ x) y = conj (θ.expMapCircle : ℂ) * o.kahler x y := by -- Porting note: this needed the `Complex.conj_ofReal` instead of `RCLike.conj_ofReal`; -- I believe this is because the respective coercions are no longer defeq, and -- `Real.Angle.coe_expMapCircle` uses the `Complex` version. simp only [o.rotation_apply, map_add, map_mul, LinearMap.map_smulₛₗ, RingHom.id_apply, LinearMap.add_apply, LinearMap.smul_apply, real_smul, kahler_rightAngleRotation_left, Real.Angle.coe_expMapCircle, Complex.conj_ofReal, conj_I] ring #align orientation.kahler_rotation_left Orientation.kahler_rotation_left theorem neg_rotation (θ : Real.Angle) (x : V) : -o.rotation θ x = o.rotation (π + θ) x := by rw [← o.rotation_pi_apply, rotation_rotation] #align orientation.neg_rotation Orientation.neg_rotation @[simp] theorem neg_rotation_neg_pi_div_two (x : V) : -o.rotation (-π / 2 : ℝ) x = o.rotation (π / 2 : ℝ) x := by rw [neg_rotation, ← Real.Angle.coe_add, neg_div, ← sub_eq_add_neg, sub_half] #align orientation.neg_rotation_neg_pi_div_two Orientation.neg_rotation_neg_pi_div_two theorem neg_rotation_pi_div_two (x : V) : -o.rotation (π / 2 : ℝ) x = o.rotation (-π / 2 : ℝ) x := (neg_eq_iff_eq_neg.mp <| o.neg_rotation_neg_pi_div_two _).symm #align orientation.neg_rotation_pi_div_two Orientation.neg_rotation_pi_div_two theorem kahler_rotation_left' (x y : V) (θ : Real.Angle) : o.kahler (o.rotation θ x) y = (-θ).expMapCircle * o.kahler x y := by simp only [Real.Angle.expMapCircle_neg, coe_inv_circle_eq_conj, kahler_rotation_left] #align orientation.kahler_rotation_left' Orientation.kahler_rotation_left' @[simp] theorem kahler_rotation_right (x y : V) (θ : Real.Angle) : o.kahler x (o.rotation θ y) = θ.expMapCircle * o.kahler x y := by simp only [o.rotation_apply, map_add, LinearMap.map_smulₛₗ, RingHom.id_apply, real_smul, kahler_rightAngleRotation_right, Real.Angle.coe_expMapCircle] ring #align orientation.kahler_rotation_right Orientation.kahler_rotation_right @[simp] theorem oangle_rotation_left {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) (θ : Real.Angle) : o.oangle (o.rotation θ x) y = o.oangle x y - θ := by simp only [oangle, o.kahler_rotation_left'] rw [Complex.arg_mul_coe_angle, Real.Angle.arg_expMapCircle] · abel · exact ne_zero_of_mem_circle _ · exact o.kahler_ne_zero hx hy #align orientation.oangle_rotation_left Orientation.oangle_rotation_left @[simp] theorem oangle_rotation_right {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) (θ : Real.Angle) : o.oangle x (o.rotation θ y) = o.oangle x y + θ := by simp only [oangle, o.kahler_rotation_right] rw [Complex.arg_mul_coe_angle, Real.Angle.arg_expMapCircle] · abel · exact ne_zero_of_mem_circle _ · exact o.kahler_ne_zero hx hy #align orientation.oangle_rotation_right Orientation.oangle_rotation_right @[simp] theorem oangle_rotation_self_left {x : V} (hx : x ≠ 0) (θ : Real.Angle) : o.oangle (o.rotation θ x) x = -θ := by simp [hx] #align orientation.oangle_rotation_self_left Orientation.oangle_rotation_self_left @[simp] theorem oangle_rotation_self_right {x : V} (hx : x ≠ 0) (θ : Real.Angle) : o.oangle x (o.rotation θ x) = θ := by simp [hx] #align orientation.oangle_rotation_self_right Orientation.oangle_rotation_self_right @[simp] theorem oangle_rotation_oangle_left (x y : V) : o.oangle (o.rotation (o.oangle x y) x) y = 0 := by by_cases hx : x = 0 · simp [hx] · by_cases hy : y = 0 · simp [hy] · simp [hx, hy] #align orientation.oangle_rotation_oangle_left Orientation.oangle_rotation_oangle_left @[simp] theorem oangle_rotation_oangle_right (x y : V) : o.oangle y (o.rotation (o.oangle x y) x) = 0 := by rw [oangle_rev] simp #align orientation.oangle_rotation_oangle_right Orientation.oangle_rotation_oangle_right @[simp] theorem oangle_rotation (x y : V) (θ : Real.Angle) : o.oangle (o.rotation θ x) (o.rotation θ y) = o.oangle x y := by by_cases hx : x = 0 <;> by_cases hy : y = 0 <;> simp [hx, hy] #align orientation.oangle_rotation Orientation.oangle_rotation @[simp] theorem rotation_eq_self_iff_angle_eq_zero {x : V} (hx : x ≠ 0) (θ : Real.Angle) : o.rotation θ x = x ↔ θ = 0 := by constructor · intro h rw [eq_comm] simpa [hx, h] using o.oangle_rotation_right hx hx θ · intro h simp [h] #align orientation.rotation_eq_self_iff_angle_eq_zero Orientation.rotation_eq_self_iff_angle_eq_zero @[simp] theorem eq_rotation_self_iff_angle_eq_zero {x : V} (hx : x ≠ 0) (θ : Real.Angle) : x = o.rotation θ x ↔ θ = 0 := by rw [← o.rotation_eq_self_iff_angle_eq_zero hx, eq_comm] #align orientation.eq_rotation_self_iff_angle_eq_zero Orientation.eq_rotation_self_iff_angle_eq_zero
Mathlib/Geometry/Euclidean/Angle/Oriented/Rotation.lean
302
303
theorem rotation_eq_self_iff (x : V) (θ : Real.Angle) : o.rotation θ x = x ↔ x = 0 ∨ θ = 0 := by
by_cases h : x = 0 <;> simp [h]
import Mathlib.CategoryTheory.Comma.Over import Mathlib.CategoryTheory.DiscreteCategory import Mathlib.CategoryTheory.EpiMono import Mathlib.CategoryTheory.Limits.Shapes.Terminal #align_import category_theory.limits.shapes.binary_products from "leanprover-community/mathlib"@"fec1d95fc61c750c1ddbb5b1f7f48b8e811a80d7" noncomputable section universe v u u₂ open CategoryTheory namespace CategoryTheory.Limits inductive WalkingPair : Type | left | right deriving DecidableEq, Inhabited #align category_theory.limits.walking_pair CategoryTheory.Limits.WalkingPair open WalkingPair def WalkingPair.swap : WalkingPair ≃ WalkingPair where toFun j := WalkingPair.recOn j right left invFun j := WalkingPair.recOn j right left left_inv j := by cases j; repeat rfl right_inv j := by cases j; repeat rfl #align category_theory.limits.walking_pair.swap CategoryTheory.Limits.WalkingPair.swap @[simp] theorem WalkingPair.swap_apply_left : WalkingPair.swap left = right := rfl #align category_theory.limits.walking_pair.swap_apply_left CategoryTheory.Limits.WalkingPair.swap_apply_left @[simp] theorem WalkingPair.swap_apply_right : WalkingPair.swap right = left := rfl #align category_theory.limits.walking_pair.swap_apply_right CategoryTheory.Limits.WalkingPair.swap_apply_right @[simp] theorem WalkingPair.swap_symm_apply_tt : WalkingPair.swap.symm left = right := rfl #align category_theory.limits.walking_pair.swap_symm_apply_tt CategoryTheory.Limits.WalkingPair.swap_symm_apply_tt @[simp] theorem WalkingPair.swap_symm_apply_ff : WalkingPair.swap.symm right = left := rfl #align category_theory.limits.walking_pair.swap_symm_apply_ff CategoryTheory.Limits.WalkingPair.swap_symm_apply_ff def WalkingPair.equivBool : WalkingPair ≃ Bool where toFun j := WalkingPair.recOn j true false -- to match equiv.sum_equiv_sigma_bool invFun b := Bool.recOn b right left left_inv j := by cases j; repeat rfl right_inv b := by cases b; repeat rfl #align category_theory.limits.walking_pair.equiv_bool CategoryTheory.Limits.WalkingPair.equivBool @[simp] theorem WalkingPair.equivBool_apply_left : WalkingPair.equivBool left = true := rfl #align category_theory.limits.walking_pair.equiv_bool_apply_left CategoryTheory.Limits.WalkingPair.equivBool_apply_left @[simp] theorem WalkingPair.equivBool_apply_right : WalkingPair.equivBool right = false := rfl #align category_theory.limits.walking_pair.equiv_bool_apply_right CategoryTheory.Limits.WalkingPair.equivBool_apply_right @[simp] theorem WalkingPair.equivBool_symm_apply_true : WalkingPair.equivBool.symm true = left := rfl #align category_theory.limits.walking_pair.equiv_bool_symm_apply_tt CategoryTheory.Limits.WalkingPair.equivBool_symm_apply_true @[simp] theorem WalkingPair.equivBool_symm_apply_false : WalkingPair.equivBool.symm false = right := rfl #align category_theory.limits.walking_pair.equiv_bool_symm_apply_ff CategoryTheory.Limits.WalkingPair.equivBool_symm_apply_false variable {C : Type u} def pairFunction (X Y : C) : WalkingPair → C := fun j => WalkingPair.casesOn j X Y #align category_theory.limits.pair_function CategoryTheory.Limits.pairFunction @[simp] theorem pairFunction_left (X Y : C) : pairFunction X Y left = X := rfl #align category_theory.limits.pair_function_left CategoryTheory.Limits.pairFunction_left @[simp] theorem pairFunction_right (X Y : C) : pairFunction X Y right = Y := rfl #align category_theory.limits.pair_function_right CategoryTheory.Limits.pairFunction_right variable [Category.{v} C] def pair (X Y : C) : Discrete WalkingPair ⥤ C := Discrete.functor fun j => WalkingPair.casesOn j X Y #align category_theory.limits.pair CategoryTheory.Limits.pair @[simp] theorem pair_obj_left (X Y : C) : (pair X Y).obj ⟨left⟩ = X := rfl #align category_theory.limits.pair_obj_left CategoryTheory.Limits.pair_obj_left @[simp] theorem pair_obj_right (X Y : C) : (pair X Y).obj ⟨right⟩ = Y := rfl #align category_theory.limits.pair_obj_right CategoryTheory.Limits.pair_obj_right section variable {F G : Discrete WalkingPair ⥤ C} (f : F.obj ⟨left⟩ ⟶ G.obj ⟨left⟩) (g : F.obj ⟨right⟩ ⟶ G.obj ⟨right⟩) attribute [local aesop safe tactic (rule_sets := [CategoryTheory])] CategoryTheory.Discrete.discreteCases def mapPair : F ⟶ G where app j := Discrete.recOn j fun j => WalkingPair.casesOn j f g naturality := fun ⟨X⟩ ⟨Y⟩ ⟨⟨u⟩⟩ => by aesop_cat #align category_theory.limits.map_pair CategoryTheory.Limits.mapPair @[simp] theorem mapPair_left : (mapPair f g).app ⟨left⟩ = f := rfl #align category_theory.limits.map_pair_left CategoryTheory.Limits.mapPair_left @[simp] theorem mapPair_right : (mapPair f g).app ⟨right⟩ = g := rfl #align category_theory.limits.map_pair_right CategoryTheory.Limits.mapPair_right @[simps!] def mapPairIso (f : F.obj ⟨left⟩ ≅ G.obj ⟨left⟩) (g : F.obj ⟨right⟩ ≅ G.obj ⟨right⟩) : F ≅ G := NatIso.ofComponents (fun j => Discrete.recOn j fun j => WalkingPair.casesOn j f g) (fun ⟨⟨u⟩⟩ => by aesop_cat) #align category_theory.limits.map_pair_iso CategoryTheory.Limits.mapPairIso end @[simps!] def diagramIsoPair (F : Discrete WalkingPair ⥤ C) : F ≅ pair (F.obj ⟨WalkingPair.left⟩) (F.obj ⟨WalkingPair.right⟩) := mapPairIso (Iso.refl _) (Iso.refl _) #align category_theory.limits.diagram_iso_pair CategoryTheory.Limits.diagramIsoPair section variable {D : Type u} [Category.{v} D] def pairComp (X Y : C) (F : C ⥤ D) : pair X Y ⋙ F ≅ pair (F.obj X) (F.obj Y) := diagramIsoPair _ #align category_theory.limits.pair_comp CategoryTheory.Limits.pairComp end abbrev BinaryFan (X Y : C) := Cone (pair X Y) #align category_theory.limits.binary_fan CategoryTheory.Limits.BinaryFan abbrev BinaryFan.fst {X Y : C} (s : BinaryFan X Y) := s.π.app ⟨WalkingPair.left⟩ #align category_theory.limits.binary_fan.fst CategoryTheory.Limits.BinaryFan.fst abbrev BinaryFan.snd {X Y : C} (s : BinaryFan X Y) := s.π.app ⟨WalkingPair.right⟩ #align category_theory.limits.binary_fan.snd CategoryTheory.Limits.BinaryFan.snd @[simp] theorem BinaryFan.π_app_left {X Y : C} (s : BinaryFan X Y) : s.π.app ⟨WalkingPair.left⟩ = s.fst := rfl #align category_theory.limits.binary_fan.π_app_left CategoryTheory.Limits.BinaryFan.π_app_left @[simp] theorem BinaryFan.π_app_right {X Y : C} (s : BinaryFan X Y) : s.π.app ⟨WalkingPair.right⟩ = s.snd := rfl #align category_theory.limits.binary_fan.π_app_right CategoryTheory.Limits.BinaryFan.π_app_right def BinaryFan.IsLimit.mk {X Y : C} (s : BinaryFan X Y) (lift : ∀ {T : C} (_ : T ⟶ X) (_ : T ⟶ Y), T ⟶ s.pt) (hl₁ : ∀ {T : C} (f : T ⟶ X) (g : T ⟶ Y), lift f g ≫ s.fst = f) (hl₂ : ∀ {T : C} (f : T ⟶ X) (g : T ⟶ Y), lift f g ≫ s.snd = g) (uniq : ∀ {T : C} (f : T ⟶ X) (g : T ⟶ Y) (m : T ⟶ s.pt) (_ : m ≫ s.fst = f) (_ : m ≫ s.snd = g), m = lift f g) : IsLimit s := Limits.IsLimit.mk (fun t => lift (BinaryFan.fst t) (BinaryFan.snd t)) (by rintro t (rfl | rfl) · exact hl₁ _ _ · exact hl₂ _ _) fun t m h => uniq _ _ _ (h ⟨WalkingPair.left⟩) (h ⟨WalkingPair.right⟩) #align category_theory.limits.binary_fan.is_limit.mk CategoryTheory.Limits.BinaryFan.IsLimit.mk theorem BinaryFan.IsLimit.hom_ext {W X Y : C} {s : BinaryFan X Y} (h : IsLimit s) {f g : W ⟶ s.pt} (h₁ : f ≫ s.fst = g ≫ s.fst) (h₂ : f ≫ s.snd = g ≫ s.snd) : f = g := h.hom_ext fun j => Discrete.recOn j fun j => WalkingPair.casesOn j h₁ h₂ #align category_theory.limits.binary_fan.is_limit.hom_ext CategoryTheory.Limits.BinaryFan.IsLimit.hom_ext abbrev BinaryCofan (X Y : C) := Cocone (pair X Y) #align category_theory.limits.binary_cofan CategoryTheory.Limits.BinaryCofan abbrev BinaryCofan.inl {X Y : C} (s : BinaryCofan X Y) := s.ι.app ⟨WalkingPair.left⟩ #align category_theory.limits.binary_cofan.inl CategoryTheory.Limits.BinaryCofan.inl abbrev BinaryCofan.inr {X Y : C} (s : BinaryCofan X Y) := s.ι.app ⟨WalkingPair.right⟩ #align category_theory.limits.binary_cofan.inr CategoryTheory.Limits.BinaryCofan.inr @[simp] theorem BinaryCofan.ι_app_left {X Y : C} (s : BinaryCofan X Y) : s.ι.app ⟨WalkingPair.left⟩ = s.inl := rfl #align category_theory.limits.binary_cofan.ι_app_left CategoryTheory.Limits.BinaryCofan.ι_app_left @[simp] theorem BinaryCofan.ι_app_right {X Y : C} (s : BinaryCofan X Y) : s.ι.app ⟨WalkingPair.right⟩ = s.inr := rfl #align category_theory.limits.binary_cofan.ι_app_right CategoryTheory.Limits.BinaryCofan.ι_app_right def BinaryCofan.IsColimit.mk {X Y : C} (s : BinaryCofan X Y) (desc : ∀ {T : C} (_ : X ⟶ T) (_ : Y ⟶ T), s.pt ⟶ T) (hd₁ : ∀ {T : C} (f : X ⟶ T) (g : Y ⟶ T), s.inl ≫ desc f g = f) (hd₂ : ∀ {T : C} (f : X ⟶ T) (g : Y ⟶ T), s.inr ≫ desc f g = g) (uniq : ∀ {T : C} (f : X ⟶ T) (g : Y ⟶ T) (m : s.pt ⟶ T) (_ : s.inl ≫ m = f) (_ : s.inr ≫ m = g), m = desc f g) : IsColimit s := Limits.IsColimit.mk (fun t => desc (BinaryCofan.inl t) (BinaryCofan.inr t)) (by rintro t (rfl | rfl) · exact hd₁ _ _ · exact hd₂ _ _) fun t m h => uniq _ _ _ (h ⟨WalkingPair.left⟩) (h ⟨WalkingPair.right⟩) #align category_theory.limits.binary_cofan.is_colimit.mk CategoryTheory.Limits.BinaryCofan.IsColimit.mk theorem BinaryCofan.IsColimit.hom_ext {W X Y : C} {s : BinaryCofan X Y} (h : IsColimit s) {f g : s.pt ⟶ W} (h₁ : s.inl ≫ f = s.inl ≫ g) (h₂ : s.inr ≫ f = s.inr ≫ g) : f = g := h.hom_ext fun j => Discrete.recOn j fun j => WalkingPair.casesOn j h₁ h₂ #align category_theory.limits.binary_cofan.is_colimit.hom_ext CategoryTheory.Limits.BinaryCofan.IsColimit.hom_ext variable {X Y : C} section attribute [local aesop safe tactic (rule_sets := [CategoryTheory])] CategoryTheory.Discrete.discreteCases -- Porting note: would it be okay to use this more generally? attribute [local aesop safe cases (rule_sets := [CategoryTheory])] Eq @[simps pt] def BinaryFan.mk {P : C} (π₁ : P ⟶ X) (π₂ : P ⟶ Y) : BinaryFan X Y where pt := P π := { app := fun ⟨j⟩ => by cases j <;> simpa } #align category_theory.limits.binary_fan.mk CategoryTheory.Limits.BinaryFan.mk @[simps pt] def BinaryCofan.mk {P : C} (ι₁ : X ⟶ P) (ι₂ : Y ⟶ P) : BinaryCofan X Y where pt := P ι := { app := fun ⟨j⟩ => by cases j <;> simpa } #align category_theory.limits.binary_cofan.mk CategoryTheory.Limits.BinaryCofan.mk end @[simp] theorem BinaryFan.mk_fst {P : C} (π₁ : P ⟶ X) (π₂ : P ⟶ Y) : (BinaryFan.mk π₁ π₂).fst = π₁ := rfl #align category_theory.limits.binary_fan.mk_fst CategoryTheory.Limits.BinaryFan.mk_fst @[simp] theorem BinaryFan.mk_snd {P : C} (π₁ : P ⟶ X) (π₂ : P ⟶ Y) : (BinaryFan.mk π₁ π₂).snd = π₂ := rfl #align category_theory.limits.binary_fan.mk_snd CategoryTheory.Limits.BinaryFan.mk_snd @[simp] theorem BinaryCofan.mk_inl {P : C} (ι₁ : X ⟶ P) (ι₂ : Y ⟶ P) : (BinaryCofan.mk ι₁ ι₂).inl = ι₁ := rfl #align category_theory.limits.binary_cofan.mk_inl CategoryTheory.Limits.BinaryCofan.mk_inl @[simp] theorem BinaryCofan.mk_inr {P : C} (ι₁ : X ⟶ P) (ι₂ : Y ⟶ P) : (BinaryCofan.mk ι₁ ι₂).inr = ι₂ := rfl #align category_theory.limits.binary_cofan.mk_inr CategoryTheory.Limits.BinaryCofan.mk_inr def isoBinaryFanMk {X Y : C} (c : BinaryFan X Y) : c ≅ BinaryFan.mk c.fst c.snd := Cones.ext (Iso.refl _) fun j => by cases' j with l; cases l; repeat simp #align category_theory.limits.iso_binary_fan_mk CategoryTheory.Limits.isoBinaryFanMk def isoBinaryCofanMk {X Y : C} (c : BinaryCofan X Y) : c ≅ BinaryCofan.mk c.inl c.inr := Cocones.ext (Iso.refl _) fun j => by cases' j with l; cases l; repeat simp #align category_theory.limits.iso_binary_cofan_mk CategoryTheory.Limits.isoBinaryCofanMk def BinaryFan.isLimitMk {W : C} {fst : W ⟶ X} {snd : W ⟶ Y} (lift : ∀ s : BinaryFan X Y, s.pt ⟶ W) (fac_left : ∀ s : BinaryFan X Y, lift s ≫ fst = s.fst) (fac_right : ∀ s : BinaryFan X Y, lift s ≫ snd = s.snd) (uniq : ∀ (s : BinaryFan X Y) (m : s.pt ⟶ W) (_ : m ≫ fst = s.fst) (_ : m ≫ snd = s.snd), m = lift s) : IsLimit (BinaryFan.mk fst snd) := { lift := lift fac := fun s j => by rcases j with ⟨⟨⟩⟩ exacts [fac_left s, fac_right s] uniq := fun s m w => uniq s m (w ⟨WalkingPair.left⟩) (w ⟨WalkingPair.right⟩) } #align category_theory.limits.binary_fan.is_limit_mk CategoryTheory.Limits.BinaryFan.isLimitMk def BinaryCofan.isColimitMk {W : C} {inl : X ⟶ W} {inr : Y ⟶ W} (desc : ∀ s : BinaryCofan X Y, W ⟶ s.pt) (fac_left : ∀ s : BinaryCofan X Y, inl ≫ desc s = s.inl) (fac_right : ∀ s : BinaryCofan X Y, inr ≫ desc s = s.inr) (uniq : ∀ (s : BinaryCofan X Y) (m : W ⟶ s.pt) (_ : inl ≫ m = s.inl) (_ : inr ≫ m = s.inr), m = desc s) : IsColimit (BinaryCofan.mk inl inr) := { desc := desc fac := fun s j => by rcases j with ⟨⟨⟩⟩ exacts [fac_left s, fac_right s] uniq := fun s m w => uniq s m (w ⟨WalkingPair.left⟩) (w ⟨WalkingPair.right⟩) } #align category_theory.limits.binary_cofan.is_colimit_mk CategoryTheory.Limits.BinaryCofan.isColimitMk @[simps] def BinaryFan.IsLimit.lift' {W X Y : C} {s : BinaryFan X Y} (h : IsLimit s) (f : W ⟶ X) (g : W ⟶ Y) : { l : W ⟶ s.pt // l ≫ s.fst = f ∧ l ≫ s.snd = g } := ⟨h.lift <| BinaryFan.mk f g, h.fac _ _, h.fac _ _⟩ #align category_theory.limits.binary_fan.is_limit.lift' CategoryTheory.Limits.BinaryFan.IsLimit.lift' @[simps] def BinaryCofan.IsColimit.desc' {W X Y : C} {s : BinaryCofan X Y} (h : IsColimit s) (f : X ⟶ W) (g : Y ⟶ W) : { l : s.pt ⟶ W // s.inl ≫ l = f ∧ s.inr ≫ l = g } := ⟨h.desc <| BinaryCofan.mk f g, h.fac _ _, h.fac _ _⟩ #align category_theory.limits.binary_cofan.is_colimit.desc' CategoryTheory.Limits.BinaryCofan.IsColimit.desc' def BinaryFan.isLimitFlip {X Y : C} {c : BinaryFan X Y} (hc : IsLimit c) : IsLimit (BinaryFan.mk c.snd c.fst) := BinaryFan.isLimitMk (fun s => hc.lift (BinaryFan.mk s.snd s.fst)) (fun _ => hc.fac _ _) (fun _ => hc.fac _ _) fun s _ e₁ e₂ => BinaryFan.IsLimit.hom_ext hc (e₂.trans (hc.fac (BinaryFan.mk s.snd s.fst) ⟨WalkingPair.left⟩).symm) (e₁.trans (hc.fac (BinaryFan.mk s.snd s.fst) ⟨WalkingPair.right⟩).symm) #align category_theory.limits.binary_fan.is_limit_flip CategoryTheory.Limits.BinaryFan.isLimitFlip theorem BinaryFan.isLimit_iff_isIso_fst {X Y : C} (h : IsTerminal Y) (c : BinaryFan X Y) : Nonempty (IsLimit c) ↔ IsIso c.fst := by constructor · rintro ⟨H⟩ obtain ⟨l, hl, -⟩ := BinaryFan.IsLimit.lift' H (𝟙 X) (h.from X) exact ⟨⟨l, BinaryFan.IsLimit.hom_ext H (by simpa [hl, -Category.comp_id] using Category.comp_id _) (h.hom_ext _ _), hl⟩⟩ · intro exact ⟨BinaryFan.IsLimit.mk _ (fun f _ => f ≫ inv c.fst) (fun _ _ => by simp) (fun _ _ => h.hom_ext _ _) fun _ _ _ e _ => by simp [← e]⟩ #align category_theory.limits.binary_fan.is_limit_iff_is_iso_fst CategoryTheory.Limits.BinaryFan.isLimit_iff_isIso_fst theorem BinaryFan.isLimit_iff_isIso_snd {X Y : C} (h : IsTerminal X) (c : BinaryFan X Y) : Nonempty (IsLimit c) ↔ IsIso c.snd := by refine Iff.trans ?_ (BinaryFan.isLimit_iff_isIso_fst h (BinaryFan.mk c.snd c.fst)) exact ⟨fun h => ⟨BinaryFan.isLimitFlip h.some⟩, fun h => ⟨(BinaryFan.isLimitFlip h.some).ofIsoLimit (isoBinaryFanMk c).symm⟩⟩ #align category_theory.limits.binary_fan.is_limit_iff_is_iso_snd CategoryTheory.Limits.BinaryFan.isLimit_iff_isIso_snd noncomputable def BinaryFan.isLimitCompLeftIso {X Y X' : C} (c : BinaryFan X Y) (f : X ⟶ X') [IsIso f] (h : IsLimit c) : IsLimit (BinaryFan.mk (c.fst ≫ f) c.snd) := by fapply BinaryFan.isLimitMk · exact fun s => h.lift (BinaryFan.mk (s.fst ≫ inv f) s.snd) · intro s -- Porting note: simp timed out here simp only [Category.comp_id,BinaryFan.π_app_left,IsIso.inv_hom_id, BinaryFan.mk_fst,IsLimit.fac_assoc,eq_self_iff_true,Category.assoc] · intro s -- Porting note: simp timed out here simp only [BinaryFan.π_app_right,BinaryFan.mk_snd,eq_self_iff_true,IsLimit.fac] · intro s m e₁ e₂ -- Porting note: simpa timed out here also apply BinaryFan.IsLimit.hom_ext h · simpa only [BinaryFan.π_app_left,BinaryFan.mk_fst,Category.assoc,IsLimit.fac,IsIso.eq_comp_inv] · simpa only [BinaryFan.π_app_right,BinaryFan.mk_snd,IsLimit.fac] #align category_theory.limits.binary_fan.is_limit_comp_left_iso CategoryTheory.Limits.BinaryFan.isLimitCompLeftIso noncomputable def BinaryFan.isLimitCompRightIso {X Y Y' : C} (c : BinaryFan X Y) (f : Y ⟶ Y') [IsIso f] (h : IsLimit c) : IsLimit (BinaryFan.mk c.fst (c.snd ≫ f)) := BinaryFan.isLimitFlip <| BinaryFan.isLimitCompLeftIso _ f (BinaryFan.isLimitFlip h) #align category_theory.limits.binary_fan.is_limit_comp_right_iso CategoryTheory.Limits.BinaryFan.isLimitCompRightIso def BinaryCofan.isColimitFlip {X Y : C} {c : BinaryCofan X Y} (hc : IsColimit c) : IsColimit (BinaryCofan.mk c.inr c.inl) := BinaryCofan.isColimitMk (fun s => hc.desc (BinaryCofan.mk s.inr s.inl)) (fun _ => hc.fac _ _) (fun _ => hc.fac _ _) fun s _ e₁ e₂ => BinaryCofan.IsColimit.hom_ext hc (e₂.trans (hc.fac (BinaryCofan.mk s.inr s.inl) ⟨WalkingPair.left⟩).symm) (e₁.trans (hc.fac (BinaryCofan.mk s.inr s.inl) ⟨WalkingPair.right⟩).symm) #align category_theory.limits.binary_cofan.is_colimit_flip CategoryTheory.Limits.BinaryCofan.isColimitFlip theorem BinaryCofan.isColimit_iff_isIso_inl {X Y : C} (h : IsInitial Y) (c : BinaryCofan X Y) : Nonempty (IsColimit c) ↔ IsIso c.inl := by constructor · rintro ⟨H⟩ obtain ⟨l, hl, -⟩ := BinaryCofan.IsColimit.desc' H (𝟙 X) (h.to X) refine ⟨⟨l, hl, BinaryCofan.IsColimit.hom_ext H (?_) (h.hom_ext _ _)⟩⟩ rw [Category.comp_id] have e : (inl c ≫ l) ≫ inl c = 𝟙 X ≫ inl c := congrArg (·≫inl c) hl rwa [Category.assoc,Category.id_comp] at e · intro exact ⟨BinaryCofan.IsColimit.mk _ (fun f _ => inv c.inl ≫ f) (fun _ _ => IsIso.hom_inv_id_assoc _ _) (fun _ _ => h.hom_ext _ _) fun _ _ _ e _ => (IsIso.eq_inv_comp _).mpr e⟩ #align category_theory.limits.binary_cofan.is_colimit_iff_is_iso_inl CategoryTheory.Limits.BinaryCofan.isColimit_iff_isIso_inl theorem BinaryCofan.isColimit_iff_isIso_inr {X Y : C} (h : IsInitial X) (c : BinaryCofan X Y) : Nonempty (IsColimit c) ↔ IsIso c.inr := by refine Iff.trans ?_ (BinaryCofan.isColimit_iff_isIso_inl h (BinaryCofan.mk c.inr c.inl)) exact ⟨fun h => ⟨BinaryCofan.isColimitFlip h.some⟩, fun h => ⟨(BinaryCofan.isColimitFlip h.some).ofIsoColimit (isoBinaryCofanMk c).symm⟩⟩ #align category_theory.limits.binary_cofan.is_colimit_iff_is_iso_inr CategoryTheory.Limits.BinaryCofan.isColimit_iff_isIso_inr noncomputable def BinaryCofan.isColimitCompLeftIso {X Y X' : C} (c : BinaryCofan X Y) (f : X' ⟶ X) [IsIso f] (h : IsColimit c) : IsColimit (BinaryCofan.mk (f ≫ c.inl) c.inr) := by fapply BinaryCofan.isColimitMk · exact fun s => h.desc (BinaryCofan.mk (inv f ≫ s.inl) s.inr) · intro s -- Porting note: simp timed out here too simp only [IsColimit.fac,BinaryCofan.ι_app_left,eq_self_iff_true, Category.assoc,BinaryCofan.mk_inl,IsIso.hom_inv_id_assoc] · intro s -- Porting note: simp timed out here too simp only [IsColimit.fac,BinaryCofan.ι_app_right,eq_self_iff_true,BinaryCofan.mk_inr] · intro s m e₁ e₂ apply BinaryCofan.IsColimit.hom_ext h · rw [← cancel_epi f] -- Porting note: simp timed out here too simpa only [IsColimit.fac,BinaryCofan.ι_app_left,eq_self_iff_true, Category.assoc,BinaryCofan.mk_inl,IsIso.hom_inv_id_assoc] using e₁ -- Porting note: simp timed out here too · simpa only [IsColimit.fac,BinaryCofan.ι_app_right,eq_self_iff_true,BinaryCofan.mk_inr] #align category_theory.limits.binary_cofan.is_colimit_comp_left_iso CategoryTheory.Limits.BinaryCofan.isColimitCompLeftIso noncomputable def BinaryCofan.isColimitCompRightIso {X Y Y' : C} (c : BinaryCofan X Y) (f : Y' ⟶ Y) [IsIso f] (h : IsColimit c) : IsColimit (BinaryCofan.mk c.inl (f ≫ c.inr)) := BinaryCofan.isColimitFlip <| BinaryCofan.isColimitCompLeftIso _ f (BinaryCofan.isColimitFlip h) #align category_theory.limits.binary_cofan.is_colimit_comp_right_iso CategoryTheory.Limits.BinaryCofan.isColimitCompRightIso abbrev HasBinaryProduct (X Y : C) := HasLimit (pair X Y) #align category_theory.limits.has_binary_product CategoryTheory.Limits.HasBinaryProduct abbrev HasBinaryCoproduct (X Y : C) := HasColimit (pair X Y) #align category_theory.limits.has_binary_coproduct CategoryTheory.Limits.HasBinaryCoproduct abbrev prod (X Y : C) [HasBinaryProduct X Y] := limit (pair X Y) #align category_theory.limits.prod CategoryTheory.Limits.prod abbrev coprod (X Y : C) [HasBinaryCoproduct X Y] := colimit (pair X Y) #align category_theory.limits.coprod CategoryTheory.Limits.coprod notation:20 X " ⨯ " Y:20 => prod X Y notation:20 X " ⨿ " Y:20 => coprod X Y abbrev prod.fst {X Y : C} [HasBinaryProduct X Y] : X ⨯ Y ⟶ X := limit.π (pair X Y) ⟨WalkingPair.left⟩ #align category_theory.limits.prod.fst CategoryTheory.Limits.prod.fst abbrev prod.snd {X Y : C} [HasBinaryProduct X Y] : X ⨯ Y ⟶ Y := limit.π (pair X Y) ⟨WalkingPair.right⟩ #align category_theory.limits.prod.snd CategoryTheory.Limits.prod.snd abbrev coprod.inl {X Y : C} [HasBinaryCoproduct X Y] : X ⟶ X ⨿ Y := colimit.ι (pair X Y) ⟨WalkingPair.left⟩ #align category_theory.limits.coprod.inl CategoryTheory.Limits.coprod.inl abbrev coprod.inr {X Y : C} [HasBinaryCoproduct X Y] : Y ⟶ X ⨿ Y := colimit.ι (pair X Y) ⟨WalkingPair.right⟩ #align category_theory.limits.coprod.inr CategoryTheory.Limits.coprod.inr def prodIsProd (X Y : C) [HasBinaryProduct X Y] : IsLimit (BinaryFan.mk (prod.fst : X ⨯ Y ⟶ X) prod.snd) := (limit.isLimit _).ofIsoLimit (Cones.ext (Iso.refl _) (fun ⟨u⟩ => by cases u · dsimp; simp only [Category.id_comp]; rfl · dsimp; simp only [Category.id_comp]; rfl )) #align category_theory.limits.prod_is_prod CategoryTheory.Limits.prodIsProd def coprodIsCoprod (X Y : C) [HasBinaryCoproduct X Y] : IsColimit (BinaryCofan.mk (coprod.inl : X ⟶ X ⨿ Y) coprod.inr) := (colimit.isColimit _).ofIsoColimit (Cocones.ext (Iso.refl _) (fun ⟨u⟩ => by cases u · dsimp; simp only [Category.comp_id] · dsimp; simp only [Category.comp_id] )) #align category_theory.limits.coprod_is_coprod CategoryTheory.Limits.coprodIsCoprod @[ext 1100] theorem prod.hom_ext {W X Y : C} [HasBinaryProduct X Y] {f g : W ⟶ X ⨯ Y} (h₁ : f ≫ prod.fst = g ≫ prod.fst) (h₂ : f ≫ prod.snd = g ≫ prod.snd) : f = g := BinaryFan.IsLimit.hom_ext (limit.isLimit _) h₁ h₂ #align category_theory.limits.prod.hom_ext CategoryTheory.Limits.prod.hom_ext @[ext 1100] theorem coprod.hom_ext {W X Y : C} [HasBinaryCoproduct X Y] {f g : X ⨿ Y ⟶ W} (h₁ : coprod.inl ≫ f = coprod.inl ≫ g) (h₂ : coprod.inr ≫ f = coprod.inr ≫ g) : f = g := BinaryCofan.IsColimit.hom_ext (colimit.isColimit _) h₁ h₂ #align category_theory.limits.coprod.hom_ext CategoryTheory.Limits.coprod.hom_ext abbrev prod.lift {W X Y : C} [HasBinaryProduct X Y] (f : W ⟶ X) (g : W ⟶ Y) : W ⟶ X ⨯ Y := limit.lift _ (BinaryFan.mk f g) #align category_theory.limits.prod.lift CategoryTheory.Limits.prod.lift abbrev diag (X : C) [HasBinaryProduct X X] : X ⟶ X ⨯ X := prod.lift (𝟙 _) (𝟙 _) #align category_theory.limits.diag CategoryTheory.Limits.diag abbrev coprod.desc {W X Y : C} [HasBinaryCoproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) : X ⨿ Y ⟶ W := colimit.desc _ (BinaryCofan.mk f g) #align category_theory.limits.coprod.desc CategoryTheory.Limits.coprod.desc abbrev codiag (X : C) [HasBinaryCoproduct X X] : X ⨿ X ⟶ X := coprod.desc (𝟙 _) (𝟙 _) #align category_theory.limits.codiag CategoryTheory.Limits.codiag -- Porting note (#10618): simp removes as simp can prove this @[reassoc] theorem prod.lift_fst {W X Y : C} [HasBinaryProduct X Y] (f : W ⟶ X) (g : W ⟶ Y) : prod.lift f g ≫ prod.fst = f := limit.lift_π _ _ #align category_theory.limits.prod.lift_fst CategoryTheory.Limits.prod.lift_fst #align category_theory.limits.prod.lift_fst_assoc CategoryTheory.Limits.prod.lift_fst_assoc -- Porting note (#10618): simp removes as simp can prove this @[reassoc] theorem prod.lift_snd {W X Y : C} [HasBinaryProduct X Y] (f : W ⟶ X) (g : W ⟶ Y) : prod.lift f g ≫ prod.snd = g := limit.lift_π _ _ #align category_theory.limits.prod.lift_snd CategoryTheory.Limits.prod.lift_snd #align category_theory.limits.prod.lift_snd_assoc CategoryTheory.Limits.prod.lift_snd_assoc -- The simp linter says simp can prove the reassoc version of this lemma. -- Porting note: it can also prove the og version @[reassoc] theorem coprod.inl_desc {W X Y : C} [HasBinaryCoproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) : coprod.inl ≫ coprod.desc f g = f := colimit.ι_desc _ _ #align category_theory.limits.coprod.inl_desc CategoryTheory.Limits.coprod.inl_desc #align category_theory.limits.coprod.inl_desc_assoc CategoryTheory.Limits.coprod.inl_desc_assoc -- The simp linter says simp can prove the reassoc version of this lemma. -- Porting note: it can also prove the og version @[reassoc] theorem coprod.inr_desc {W X Y : C} [HasBinaryCoproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) : coprod.inr ≫ coprod.desc f g = g := colimit.ι_desc _ _ #align category_theory.limits.coprod.inr_desc CategoryTheory.Limits.coprod.inr_desc #align category_theory.limits.coprod.inr_desc_assoc CategoryTheory.Limits.coprod.inr_desc_assoc instance prod.mono_lift_of_mono_left {W X Y : C} [HasBinaryProduct X Y] (f : W ⟶ X) (g : W ⟶ Y) [Mono f] : Mono (prod.lift f g) := mono_of_mono_fac <| prod.lift_fst _ _ #align category_theory.limits.prod.mono_lift_of_mono_left CategoryTheory.Limits.prod.mono_lift_of_mono_left instance prod.mono_lift_of_mono_right {W X Y : C} [HasBinaryProduct X Y] (f : W ⟶ X) (g : W ⟶ Y) [Mono g] : Mono (prod.lift f g) := mono_of_mono_fac <| prod.lift_snd _ _ #align category_theory.limits.prod.mono_lift_of_mono_right CategoryTheory.Limits.prod.mono_lift_of_mono_right instance coprod.epi_desc_of_epi_left {W X Y : C} [HasBinaryCoproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) [Epi f] : Epi (coprod.desc f g) := epi_of_epi_fac <| coprod.inl_desc _ _ #align category_theory.limits.coprod.epi_desc_of_epi_left CategoryTheory.Limits.coprod.epi_desc_of_epi_left instance coprod.epi_desc_of_epi_right {W X Y : C} [HasBinaryCoproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) [Epi g] : Epi (coprod.desc f g) := epi_of_epi_fac <| coprod.inr_desc _ _ #align category_theory.limits.coprod.epi_desc_of_epi_right CategoryTheory.Limits.coprod.epi_desc_of_epi_right def prod.lift' {W X Y : C} [HasBinaryProduct X Y] (f : W ⟶ X) (g : W ⟶ Y) : { l : W ⟶ X ⨯ Y // l ≫ prod.fst = f ∧ l ≫ prod.snd = g } := ⟨prod.lift f g, prod.lift_fst _ _, prod.lift_snd _ _⟩ #align category_theory.limits.prod.lift' CategoryTheory.Limits.prod.lift' def coprod.desc' {W X Y : C} [HasBinaryCoproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) : { l : X ⨿ Y ⟶ W // coprod.inl ≫ l = f ∧ coprod.inr ≫ l = g } := ⟨coprod.desc f g, coprod.inl_desc _ _, coprod.inr_desc _ _⟩ #align category_theory.limits.coprod.desc' CategoryTheory.Limits.coprod.desc' def prod.map {W X Y Z : C} [HasBinaryProduct W X] [HasBinaryProduct Y Z] (f : W ⟶ Y) (g : X ⟶ Z) : W ⨯ X ⟶ Y ⨯ Z := limMap (mapPair f g) #align category_theory.limits.prod.map CategoryTheory.Limits.prod.map def coprod.map {W X Y Z : C} [HasBinaryCoproduct W X] [HasBinaryCoproduct Y Z] (f : W ⟶ Y) (g : X ⟶ Z) : W ⨿ X ⟶ Y ⨿ Z := colimMap (mapPair f g) #align category_theory.limits.coprod.map CategoryTheory.Limits.coprod.map section CoprodLemmas -- @[reassoc (attr := simp)] @[simp] -- Porting note: removing reassoc tag since result is not hygienic (two h's) theorem coprod.desc_comp {V W X Y : C} [HasBinaryCoproduct X Y] (f : V ⟶ W) (g : X ⟶ V) (h : Y ⟶ V) : coprod.desc g h ≫ f = coprod.desc (g ≫ f) (h ≫ f) := by ext <;> simp #align category_theory.limits.coprod.desc_comp CategoryTheory.Limits.coprod.desc_comp -- Porting note: hand generated reassoc here. Simp can prove it theorem coprod.desc_comp_assoc {C : Type u} [Category C] {V W X Y : C} [HasBinaryCoproduct X Y] (f : V ⟶ W) (g : X ⟶ V) (h : Y ⟶ V) {Z : C} (l : W ⟶ Z) : coprod.desc g h ≫ f ≫ l = coprod.desc (g ≫ f) (h ≫ f) ≫ l := by simp #align category_theory.limits.coprod.desc_comp_assoc CategoryTheory.Limits.coprod.desc_comp theorem coprod.diag_comp {X Y : C} [HasBinaryCoproduct X X] (f : X ⟶ Y) : codiag X ≫ f = coprod.desc f f := by simp #align category_theory.limits.coprod.diag_comp CategoryTheory.Limits.coprod.diag_comp @[reassoc (attr := simp)] theorem coprod.inl_map {W X Y Z : C} [HasBinaryCoproduct W X] [HasBinaryCoproduct Y Z] (f : W ⟶ Y) (g : X ⟶ Z) : coprod.inl ≫ coprod.map f g = f ≫ coprod.inl := ι_colimMap _ _ #align category_theory.limits.coprod.inl_map CategoryTheory.Limits.coprod.inl_map #align category_theory.limits.coprod.inl_map_assoc CategoryTheory.Limits.coprod.inl_map_assoc @[reassoc (attr := simp)] theorem coprod.inr_map {W X Y Z : C} [HasBinaryCoproduct W X] [HasBinaryCoproduct Y Z] (f : W ⟶ Y) (g : X ⟶ Z) : coprod.inr ≫ coprod.map f g = g ≫ coprod.inr := ι_colimMap _ _ #align category_theory.limits.coprod.inr_map CategoryTheory.Limits.coprod.inr_map #align category_theory.limits.coprod.inr_map_assoc CategoryTheory.Limits.coprod.inr_map_assoc @[simp] theorem coprod.map_id_id {X Y : C} [HasBinaryCoproduct X Y] : coprod.map (𝟙 X) (𝟙 Y) = 𝟙 _ := by ext <;> simp #align category_theory.limits.coprod.map_id_id CategoryTheory.Limits.coprod.map_id_id @[simp] theorem coprod.desc_inl_inr {X Y : C} [HasBinaryCoproduct X Y] : coprod.desc coprod.inl coprod.inr = 𝟙 (X ⨿ Y) := by ext <;> simp #align category_theory.limits.coprod.desc_inl_inr CategoryTheory.Limits.coprod.desc_inl_inr -- The simp linter says simp can prove the reassoc version of this lemma. @[reassoc, simp] theorem coprod.map_desc {S T U V W : C} [HasBinaryCoproduct U W] [HasBinaryCoproduct T V] (f : U ⟶ S) (g : W ⟶ S) (h : T ⟶ U) (k : V ⟶ W) : coprod.map h k ≫ coprod.desc f g = coprod.desc (h ≫ f) (k ≫ g) := by ext <;> simp #align category_theory.limits.coprod.map_desc CategoryTheory.Limits.coprod.map_desc #align category_theory.limits.coprod.map_desc_assoc CategoryTheory.Limits.coprod.map_desc_assoc @[simp] theorem coprod.desc_comp_inl_comp_inr {W X Y Z : C} [HasBinaryCoproduct W Y] [HasBinaryCoproduct X Z] (g : W ⟶ X) (g' : Y ⟶ Z) : coprod.desc (g ≫ coprod.inl) (g' ≫ coprod.inr) = coprod.map g g' := by rw [← coprod.map_desc]; simp #align category_theory.limits.coprod.desc_comp_inl_comp_inr CategoryTheory.Limits.coprod.desc_comp_inl_comp_inr -- We take the right hand side here to be simp normal form, as this way composition lemmas for -- `f ≫ h` and `g ≫ k` can fire (eg `id_comp`) , while `inl_map` and `inr_map` can still work just -- as well. @[reassoc (attr := simp)] theorem coprod.map_map {A₁ A₂ A₃ B₁ B₂ B₃ : C} [HasBinaryCoproduct A₁ B₁] [HasBinaryCoproduct A₂ B₂] [HasBinaryCoproduct A₃ B₃] (f : A₁ ⟶ A₂) (g : B₁ ⟶ B₂) (h : A₂ ⟶ A₃) (k : B₂ ⟶ B₃) : coprod.map f g ≫ coprod.map h k = coprod.map (f ≫ h) (g ≫ k) := by ext <;> simp #align category_theory.limits.coprod.map_map CategoryTheory.Limits.coprod.map_map #align category_theory.limits.coprod.map_map_assoc CategoryTheory.Limits.coprod.map_map_assoc -- I don't think it's a good idea to make any of the following three simp lemmas. @[reassoc] theorem coprod.map_swap {A B X Y : C} (f : A ⟶ B) (g : X ⟶ Y) [HasColimitsOfShape (Discrete WalkingPair) C] : coprod.map (𝟙 X) f ≫ coprod.map g (𝟙 B) = coprod.map g (𝟙 A) ≫ coprod.map (𝟙 Y) f := by simp #align category_theory.limits.coprod.map_swap CategoryTheory.Limits.coprod.map_swap #align category_theory.limits.coprod.map_swap_assoc CategoryTheory.Limits.coprod.map_swap_assoc @[reassoc] theorem coprod.map_comp_id {X Y Z W : C} (f : X ⟶ Y) (g : Y ⟶ Z) [HasBinaryCoproduct Z W] [HasBinaryCoproduct Y W] [HasBinaryCoproduct X W] : coprod.map (f ≫ g) (𝟙 W) = coprod.map f (𝟙 W) ≫ coprod.map g (𝟙 W) := by simp #align category_theory.limits.coprod.map_comp_id CategoryTheory.Limits.coprod.map_comp_id #align category_theory.limits.coprod.map_comp_id_assoc CategoryTheory.Limits.coprod.map_comp_id_assoc @[reassoc] theorem coprod.map_id_comp {X Y Z W : C} (f : X ⟶ Y) (g : Y ⟶ Z) [HasBinaryCoproduct W X] [HasBinaryCoproduct W Y] [HasBinaryCoproduct W Z] : coprod.map (𝟙 W) (f ≫ g) = coprod.map (𝟙 W) f ≫ coprod.map (𝟙 W) g := by simp #align category_theory.limits.coprod.map_id_comp CategoryTheory.Limits.coprod.map_id_comp #align category_theory.limits.coprod.map_id_comp_assoc CategoryTheory.Limits.coprod.map_id_comp_assoc @[simps] def coprod.mapIso {W X Y Z : C} [HasBinaryCoproduct W X] [HasBinaryCoproduct Y Z] (f : W ≅ Y) (g : X ≅ Z) : W ⨿ X ≅ Y ⨿ Z where hom := coprod.map f.hom g.hom inv := coprod.map f.inv g.inv #align category_theory.limits.coprod.map_iso CategoryTheory.Limits.coprod.mapIso instance isIso_coprod {W X Y Z : C} [HasBinaryCoproduct W X] [HasBinaryCoproduct Y Z] (f : W ⟶ Y) (g : X ⟶ Z) [IsIso f] [IsIso g] : IsIso (coprod.map f g) := (coprod.mapIso (asIso f) (asIso g)).isIso_hom #align category_theory.limits.is_iso_coprod CategoryTheory.Limits.isIso_coprod instance coprod.map_epi {C : Type*} [Category C] {W X Y Z : C} (f : W ⟶ Y) (g : X ⟶ Z) [Epi f] [Epi g] [HasBinaryCoproduct W X] [HasBinaryCoproduct Y Z] : Epi (coprod.map f g) := ⟨fun i₁ i₂ h => by ext · rw [← cancel_epi f] simpa using congr_arg (fun f => coprod.inl ≫ f) h · rw [← cancel_epi g] simpa using congr_arg (fun f => coprod.inr ≫ f) h⟩ #align category_theory.limits.coprod.map_epi CategoryTheory.Limits.coprod.map_epi -- The simp linter says simp can prove the reassoc version of this lemma. -- Porting note: and the og version too @[reassoc] theorem coprod.map_codiag {X Y : C} (f : X ⟶ Y) [HasBinaryCoproduct X X] [HasBinaryCoproduct Y Y] : coprod.map f f ≫ codiag Y = codiag X ≫ f := by simp #align category_theory.limits.coprod.map_codiag CategoryTheory.Limits.coprod.map_codiag #align category_theory.limits.coprod.map_codiag_assoc CategoryTheory.Limits.coprod.map_codiag_assoc -- The simp linter says simp can prove the reassoc version of this lemma. -- Porting note: and the og version too @[reassoc]
Mathlib/CategoryTheory/Limits/Shapes/BinaryProducts.lean
960
962
theorem coprod.map_inl_inr_codiag {X Y : C} [HasBinaryCoproduct X Y] [HasBinaryCoproduct (X ⨿ Y) (X ⨿ Y)] : coprod.map coprod.inl coprod.inr ≫ codiag (X ⨿ Y) = 𝟙 (X ⨿ Y) := by
simp
import Mathlib.Algebra.Group.Units.Equiv import Mathlib.CategoryTheory.Endomorphism #align_import category_theory.conj from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514" universe v u namespace CategoryTheory namespace Iso variable {C : Type u} [Category.{v} C] def homCongr {X Y X₁ Y₁ : C} (α : X ≅ X₁) (β : Y ≅ Y₁) : (X ⟶ Y) ≃ (X₁ ⟶ Y₁) where toFun f := α.inv ≫ f ≫ β.hom invFun f := α.hom ≫ f ≫ β.inv left_inv f := show α.hom ≫ (α.inv ≫ f ≫ β.hom) ≫ β.inv = f by rw [Category.assoc, Category.assoc, β.hom_inv_id, α.hom_inv_id_assoc, Category.comp_id] right_inv f := show α.inv ≫ (α.hom ≫ f ≫ β.inv) ≫ β.hom = f by rw [Category.assoc, Category.assoc, β.inv_hom_id, α.inv_hom_id_assoc, Category.comp_id] #align category_theory.iso.hom_congr CategoryTheory.Iso.homCongr -- @[simp, nolint simpNF] Porting note (#10675): dsimp can not prove this @[simp] theorem homCongr_apply {X Y X₁ Y₁ : C} (α : X ≅ X₁) (β : Y ≅ Y₁) (f : X ⟶ Y) : α.homCongr β f = α.inv ≫ f ≫ β.hom := by rfl #align category_theory.iso.hom_congr_apply CategoryTheory.Iso.homCongr_apply theorem homCongr_comp {X Y Z X₁ Y₁ Z₁ : C} (α : X ≅ X₁) (β : Y ≅ Y₁) (γ : Z ≅ Z₁) (f : X ⟶ Y) (g : Y ⟶ Z) : α.homCongr γ (f ≫ g) = α.homCongr β f ≫ β.homCongr γ g := by simp #align category_theory.iso.hom_congr_comp CategoryTheory.Iso.homCongr_comp theorem homCongr_refl {X Y : C} (f : X ⟶ Y) : (Iso.refl X).homCongr (Iso.refl Y) f = f := by simp #align category_theory.iso.hom_congr_refl CategoryTheory.Iso.homCongr_refl theorem homCongr_trans {X₁ Y₁ X₂ Y₂ X₃ Y₃ : C} (α₁ : X₁ ≅ X₂) (β₁ : Y₁ ≅ Y₂) (α₂ : X₂ ≅ X₃) (β₂ : Y₂ ≅ Y₃) (f : X₁ ⟶ Y₁) : (α₁ ≪≫ α₂).homCongr (β₁ ≪≫ β₂) f = (α₁.homCongr β₁).trans (α₂.homCongr β₂) f := by simp #align category_theory.iso.hom_congr_trans CategoryTheory.Iso.homCongr_trans @[simp] theorem homCongr_symm {X₁ Y₁ X₂ Y₂ : C} (α : X₁ ≅ X₂) (β : Y₁ ≅ Y₂) : (α.homCongr β).symm = α.symm.homCongr β.symm := rfl #align category_theory.iso.hom_congr_symm CategoryTheory.Iso.homCongr_symm def isoCongr {X₁ Y₁ X₂ Y₂ : C} (f : X₁ ≅ X₂) (g : Y₁ ≅ Y₂) : (X₁ ≅ Y₁) ≃ (X₂ ≅ Y₂) where toFun h := f.symm.trans <| h.trans <| g invFun h := f.trans <| h.trans <| g.symm left_inv := by aesop_cat right_inv := by aesop_cat def isoCongrLeft {X₁ X₂ Y : C} (f : X₁ ≅ X₂) : (X₁ ≅ Y) ≃ (X₂ ≅ Y) := isoCongr f (Iso.refl _) def isoCongrRight {X Y₁ Y₂ : C} (g : Y₁ ≅ Y₂) : (X ≅ Y₁) ≃ (X ≅ Y₂) := isoCongr (Iso.refl _) g variable {X Y : C} (α : X ≅ Y) def conj : End X ≃* End Y := { homCongr α α with map_mul' := fun f g => homCongr_comp α α α g f } #align category_theory.iso.conj CategoryTheory.Iso.conj theorem conj_apply (f : End X) : α.conj f = α.inv ≫ f ≫ α.hom := rfl #align category_theory.iso.conj_apply CategoryTheory.Iso.conj_apply @[simp] theorem conj_comp (f g : End X) : α.conj (f ≫ g) = α.conj f ≫ α.conj g := α.conj.map_mul g f #align category_theory.iso.conj_comp CategoryTheory.Iso.conj_comp @[simp] theorem conj_id : α.conj (𝟙 X) = 𝟙 Y := α.conj.map_one #align category_theory.iso.conj_id CategoryTheory.Iso.conj_id @[simp] theorem refl_conj (f : End X) : (Iso.refl X).conj f = f := by rw [conj_apply, Iso.refl_inv, Iso.refl_hom, Category.id_comp, Category.comp_id] #align category_theory.iso.refl_conj CategoryTheory.Iso.refl_conj @[simp] theorem trans_conj {Z : C} (β : Y ≅ Z) (f : End X) : (α ≪≫ β).conj f = β.conj (α.conj f) := homCongr_trans α α β β f #align category_theory.iso.trans_conj CategoryTheory.Iso.trans_conj @[simp] theorem symm_self_conj (f : End X) : α.symm.conj (α.conj f) = f := by rw [← trans_conj, α.self_symm_id, refl_conj] #align category_theory.iso.symm_self_conj CategoryTheory.Iso.symm_self_conj @[simp] theorem self_symm_conj (f : End Y) : α.conj (α.symm.conj f) = f := α.symm.symm_self_conj f #align category_theory.iso.self_symm_conj CategoryTheory.Iso.self_symm_conj theorem conj_pow (f : End X) (n : ℕ) : α.conj (f ^ n) = α.conj f ^ n := α.conj.toMonoidHom.map_pow f n #align category_theory.iso.conj_pow CategoryTheory.Iso.conj_pow -- Porting note (#11215): TODO: change definition so that `conjAut_apply` becomes a `rfl`? def conjAut : Aut X ≃* Aut Y := (Aut.unitsEndEquivAut X).symm.trans <| (Units.mapEquiv α.conj).trans <| Aut.unitsEndEquivAut Y set_option linter.uppercaseLean3 false in #align category_theory.iso.conj_Aut CategoryTheory.Iso.conjAut theorem conjAut_apply (f : Aut X) : α.conjAut f = α.symm ≪≫ f ≪≫ α := by aesop_cat set_option linter.uppercaseLean3 false in #align category_theory.iso.conj_Aut_apply CategoryTheory.Iso.conjAut_apply @[simp] theorem conjAut_hom (f : Aut X) : (α.conjAut f).hom = α.conj f.hom := rfl set_option linter.uppercaseLean3 false in #align category_theory.iso.conj_Aut_hom CategoryTheory.Iso.conjAut_hom @[simp]
Mathlib/CategoryTheory/Conj.lean
156
158
theorem trans_conjAut {Z : C} (β : Y ≅ Z) (f : Aut X) : (α ≪≫ β).conjAut f = β.conjAut (α.conjAut f) := by
simp only [conjAut_apply, Iso.trans_symm, Iso.trans_assoc]
import Mathlib.Algebra.Associated import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Algebra.SMulWithZero import Mathlib.Data.Nat.PartENat import Mathlib.Tactic.Linarith #align_import ring_theory.multiplicity from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" variable {α β : Type*} open Nat Part def multiplicity [Monoid α] [DecidableRel ((· ∣ ·) : α → α → Prop)] (a b : α) : PartENat := PartENat.find fun n => ¬a ^ (n + 1) ∣ b #align multiplicity multiplicity namespace multiplicity section Monoid variable [Monoid α] [Monoid β] abbrev Finite (a b : α) : Prop := ∃ n : ℕ, ¬a ^ (n + 1) ∣ b #align multiplicity.finite multiplicity.Finite theorem finite_iff_dom [DecidableRel ((· ∣ ·) : α → α → Prop)] {a b : α} : Finite a b ↔ (multiplicity a b).Dom := Iff.rfl #align multiplicity.finite_iff_dom multiplicity.finite_iff_dom theorem finite_def {a b : α} : Finite a b ↔ ∃ n : ℕ, ¬a ^ (n + 1) ∣ b := Iff.rfl #align multiplicity.finite_def multiplicity.finite_def theorem not_dvd_one_of_finite_one_right {a : α} : Finite a 1 → ¬a ∣ 1 := fun ⟨n, hn⟩ ⟨d, hd⟩ => hn ⟨d ^ (n + 1), (pow_mul_pow_eq_one (n + 1) hd.symm).symm⟩ #align multiplicity.not_dvd_one_of_finite_one_right multiplicity.not_dvd_one_of_finite_one_right @[norm_cast] theorem Int.natCast_multiplicity (a b : ℕ) : multiplicity (a : ℤ) (b : ℤ) = multiplicity a b := by apply Part.ext' · rw [← @finite_iff_dom ℕ, @finite_def ℕ, ← @finite_iff_dom ℤ, @finite_def ℤ] norm_cast · intro h1 h2 apply _root_.le_antisymm <;> · apply Nat.find_mono norm_cast simp #align multiplicity.int.coe_nat_multiplicity multiplicity.Int.natCast_multiplicity @[deprecated (since := "2024-04-05")] alias Int.coe_nat_multiplicity := Int.natCast_multiplicity theorem not_finite_iff_forall {a b : α} : ¬Finite a b ↔ ∀ n : ℕ, a ^ n ∣ b := ⟨fun h n => Nat.casesOn n (by rw [_root_.pow_zero] exact one_dvd _) (by simpa [Finite, Classical.not_not] using h), by simp [Finite, multiplicity, Classical.not_not]; tauto⟩ #align multiplicity.not_finite_iff_forall multiplicity.not_finite_iff_forall theorem not_unit_of_finite {a b : α} (h : Finite a b) : ¬IsUnit a := let ⟨n, hn⟩ := h hn ∘ IsUnit.dvd ∘ IsUnit.pow (n + 1) #align multiplicity.not_unit_of_finite multiplicity.not_unit_of_finite theorem finite_of_finite_mul_right {a b c : α} : Finite a (b * c) → Finite a b := fun ⟨n, hn⟩ => ⟨n, fun h => hn (h.trans (dvd_mul_right _ _))⟩ #align multiplicity.finite_of_finite_mul_right multiplicity.finite_of_finite_mul_right variable [DecidableRel ((· ∣ ·) : α → α → Prop)] [DecidableRel ((· ∣ ·) : β → β → Prop)] theorem pow_dvd_of_le_multiplicity {a b : α} {k : ℕ} : (k : PartENat) ≤ multiplicity a b → a ^ k ∣ b := by rw [← PartENat.some_eq_natCast] exact Nat.casesOn k (fun _ => by rw [_root_.pow_zero] exact one_dvd _) fun k ⟨_, h₂⟩ => by_contradiction fun hk => Nat.find_min _ (lt_of_succ_le (h₂ ⟨k, hk⟩)) hk #align multiplicity.pow_dvd_of_le_multiplicity multiplicity.pow_dvd_of_le_multiplicity theorem pow_multiplicity_dvd {a b : α} (h : Finite a b) : a ^ get (multiplicity a b) h ∣ b := pow_dvd_of_le_multiplicity (by rw [PartENat.natCast_get]) #align multiplicity.pow_multiplicity_dvd multiplicity.pow_multiplicity_dvd theorem is_greatest {a b : α} {m : ℕ} (hm : multiplicity a b < m) : ¬a ^ m ∣ b := fun h => by rw [PartENat.lt_coe_iff] at hm; exact Nat.find_spec hm.fst ((pow_dvd_pow _ hm.snd).trans h) #align multiplicity.is_greatest multiplicity.is_greatest theorem is_greatest' {a b : α} {m : ℕ} (h : Finite a b) (hm : get (multiplicity a b) h < m) : ¬a ^ m ∣ b := is_greatest (by rwa [← PartENat.coe_lt_coe, PartENat.natCast_get] at hm) #align multiplicity.is_greatest' multiplicity.is_greatest' theorem pos_of_dvd {a b : α} (hfin : Finite a b) (hdiv : a ∣ b) : 0 < (multiplicity a b).get hfin := by refine zero_lt_iff.2 fun h => ?_ simpa [hdiv] using is_greatest' hfin (lt_one_iff.mpr h) #align multiplicity.pos_of_dvd multiplicity.pos_of_dvd theorem unique {a b : α} {k : ℕ} (hk : a ^ k ∣ b) (hsucc : ¬a ^ (k + 1) ∣ b) : (k : PartENat) = multiplicity a b := le_antisymm (le_of_not_gt fun hk' => is_greatest hk' hk) <| by have : Finite a b := ⟨k, hsucc⟩ rw [PartENat.le_coe_iff] exact ⟨this, Nat.find_min' _ hsucc⟩ #align multiplicity.unique multiplicity.unique theorem unique' {a b : α} {k : ℕ} (hk : a ^ k ∣ b) (hsucc : ¬a ^ (k + 1) ∣ b) : k = get (multiplicity a b) ⟨k, hsucc⟩ := by rw [← PartENat.natCast_inj, PartENat.natCast_get, unique hk hsucc] #align multiplicity.unique' multiplicity.unique' theorem le_multiplicity_of_pow_dvd {a b : α} {k : ℕ} (hk : a ^ k ∣ b) : (k : PartENat) ≤ multiplicity a b := le_of_not_gt fun hk' => is_greatest hk' hk #align multiplicity.le_multiplicity_of_pow_dvd multiplicity.le_multiplicity_of_pow_dvd theorem pow_dvd_iff_le_multiplicity {a b : α} {k : ℕ} : a ^ k ∣ b ↔ (k : PartENat) ≤ multiplicity a b := ⟨le_multiplicity_of_pow_dvd, pow_dvd_of_le_multiplicity⟩ #align multiplicity.pow_dvd_iff_le_multiplicity multiplicity.pow_dvd_iff_le_multiplicity
Mathlib/RingTheory/Multiplicity.lean
152
153
theorem multiplicity_lt_iff_not_dvd {a b : α} {k : ℕ} : multiplicity a b < (k : PartENat) ↔ ¬a ^ k ∣ b := by
rw [pow_dvd_iff_le_multiplicity, not_le]
import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Data.Finset.Sort import Mathlib.Data.Set.Subsingleton #align_import combinatorics.composition from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7" open List variable {n : ℕ} @[ext] structure Composition (n : ℕ) where blocks : List ℕ blocks_pos : ∀ {i}, i ∈ blocks → 0 < i blocks_sum : blocks.sum = n #align composition Composition @[ext] structure CompositionAsSet (n : ℕ) where boundaries : Finset (Fin n.succ) zero_mem : (0 : Fin n.succ) ∈ boundaries getLast_mem : Fin.last n ∈ boundaries #align composition_as_set CompositionAsSet instance {n : ℕ} : Inhabited (CompositionAsSet n) := ⟨⟨Finset.univ, Finset.mem_univ _, Finset.mem_univ _⟩⟩ namespace Composition variable (c : Composition n) instance (n : ℕ) : ToString (Composition n) := ⟨fun c => toString c.blocks⟩ abbrev length : ℕ := c.blocks.length #align composition.length Composition.length theorem blocks_length : c.blocks.length = c.length := rfl #align composition.blocks_length Composition.blocks_length def blocksFun : Fin c.length → ℕ := c.blocks.get #align composition.blocks_fun Composition.blocksFun theorem ofFn_blocksFun : ofFn c.blocksFun = c.blocks := ofFn_get _ #align composition.of_fn_blocks_fun Composition.ofFn_blocksFun theorem sum_blocksFun : ∑ i, c.blocksFun i = n := by conv_rhs => rw [← c.blocks_sum, ← ofFn_blocksFun, sum_ofFn] #align composition.sum_blocks_fun Composition.sum_blocksFun theorem blocksFun_mem_blocks (i : Fin c.length) : c.blocksFun i ∈ c.blocks := get_mem _ _ _ #align composition.blocks_fun_mem_blocks Composition.blocksFun_mem_blocks @[simp] theorem one_le_blocks {i : ℕ} (h : i ∈ c.blocks) : 1 ≤ i := c.blocks_pos h #align composition.one_le_blocks Composition.one_le_blocks @[simp] theorem one_le_blocks' {i : ℕ} (h : i < c.length) : 1 ≤ c.blocks.get ⟨i, h⟩ := c.one_le_blocks (get_mem (blocks c) i h) #align composition.one_le_blocks' Composition.one_le_blocks' @[simp] theorem blocks_pos' (i : ℕ) (h : i < c.length) : 0 < c.blocks.get ⟨i, h⟩ := c.one_le_blocks' h #align composition.blocks_pos' Composition.blocks_pos' theorem one_le_blocksFun (i : Fin c.length) : 1 ≤ c.blocksFun i := c.one_le_blocks (c.blocksFun_mem_blocks i) #align composition.one_le_blocks_fun Composition.one_le_blocksFun theorem length_le : c.length ≤ n := by conv_rhs => rw [← c.blocks_sum] exact length_le_sum_of_one_le _ fun i hi => c.one_le_blocks hi #align composition.length_le Composition.length_le theorem length_pos_of_pos (h : 0 < n) : 0 < c.length := by apply length_pos_of_sum_pos convert h exact c.blocks_sum #align composition.length_pos_of_pos Composition.length_pos_of_pos def sizeUpTo (i : ℕ) : ℕ := (c.blocks.take i).sum #align composition.size_up_to Composition.sizeUpTo @[simp] theorem sizeUpTo_zero : c.sizeUpTo 0 = 0 := by simp [sizeUpTo] #align composition.size_up_to_zero Composition.sizeUpTo_zero theorem sizeUpTo_ofLength_le (i : ℕ) (h : c.length ≤ i) : c.sizeUpTo i = n := by dsimp [sizeUpTo] convert c.blocks_sum exact take_all_of_le h #align composition.size_up_to_of_length_le Composition.sizeUpTo_ofLength_le @[simp] theorem sizeUpTo_length : c.sizeUpTo c.length = n := c.sizeUpTo_ofLength_le c.length le_rfl #align composition.size_up_to_length Composition.sizeUpTo_length theorem sizeUpTo_le (i : ℕ) : c.sizeUpTo i ≤ n := by conv_rhs => rw [← c.blocks_sum, ← sum_take_add_sum_drop _ i] exact Nat.le_add_right _ _ #align composition.size_up_to_le Composition.sizeUpTo_le theorem sizeUpTo_succ {i : ℕ} (h : i < c.length) : c.sizeUpTo (i + 1) = c.sizeUpTo i + c.blocks.get ⟨i, h⟩ := by simp only [sizeUpTo] rw [sum_take_succ _ _ h] #align composition.size_up_to_succ Composition.sizeUpTo_succ theorem sizeUpTo_succ' (i : Fin c.length) : c.sizeUpTo ((i : ℕ) + 1) = c.sizeUpTo i + c.blocksFun i := c.sizeUpTo_succ i.2 #align composition.size_up_to_succ' Composition.sizeUpTo_succ' theorem sizeUpTo_strict_mono {i : ℕ} (h : i < c.length) : c.sizeUpTo i < c.sizeUpTo (i + 1) := by rw [c.sizeUpTo_succ h] simp #align composition.size_up_to_strict_mono Composition.sizeUpTo_strict_mono theorem monotone_sizeUpTo : Monotone c.sizeUpTo := monotone_sum_take _ #align composition.monotone_size_up_to Composition.monotone_sizeUpTo def boundary : Fin (c.length + 1) ↪o Fin (n + 1) := (OrderEmbedding.ofStrictMono fun i => ⟨c.sizeUpTo i, Nat.lt_succ_of_le (c.sizeUpTo_le i)⟩) <| Fin.strictMono_iff_lt_succ.2 fun ⟨_, hi⟩ => c.sizeUpTo_strict_mono hi #align composition.boundary Composition.boundary @[simp] theorem boundary_zero : c.boundary 0 = 0 := by simp [boundary, Fin.ext_iff] #align composition.boundary_zero Composition.boundary_zero @[simp] theorem boundary_last : c.boundary (Fin.last c.length) = Fin.last n := by simp [boundary, Fin.ext_iff] #align composition.boundary_last Composition.boundary_last def boundaries : Finset (Fin (n + 1)) := Finset.univ.map c.boundary.toEmbedding #align composition.boundaries Composition.boundaries theorem card_boundaries_eq_succ_length : c.boundaries.card = c.length + 1 := by simp [boundaries] #align composition.card_boundaries_eq_succ_length Composition.card_boundaries_eq_succ_length def toCompositionAsSet : CompositionAsSet n where boundaries := c.boundaries zero_mem := by simp only [boundaries, Finset.mem_univ, exists_prop_of_true, Finset.mem_map] exact ⟨0, And.intro True.intro rfl⟩ getLast_mem := by simp only [boundaries, Finset.mem_univ, exists_prop_of_true, Finset.mem_map] exact ⟨Fin.last c.length, And.intro True.intro c.boundary_last⟩ #align composition.to_composition_as_set Composition.toCompositionAsSet theorem orderEmbOfFin_boundaries : c.boundaries.orderEmbOfFin c.card_boundaries_eq_succ_length = c.boundary := by refine (Finset.orderEmbOfFin_unique' _ ?_).symm exact fun i => (Finset.mem_map' _).2 (Finset.mem_univ _) #align composition.order_emb_of_fin_boundaries Composition.orderEmbOfFin_boundaries def embedding (i : Fin c.length) : Fin (c.blocksFun i) ↪o Fin n := (Fin.natAddOrderEmb <| c.sizeUpTo i).trans <| Fin.castLEOrderEmb <| calc c.sizeUpTo i + c.blocksFun i = c.sizeUpTo (i + 1) := (c.sizeUpTo_succ _).symm _ ≤ c.sizeUpTo c.length := monotone_sum_take _ i.2 _ = n := c.sizeUpTo_length #align composition.embedding Composition.embedding @[simp] theorem coe_embedding (i : Fin c.length) (j : Fin (c.blocksFun i)) : (c.embedding i j : ℕ) = c.sizeUpTo i + j := rfl #align composition.coe_embedding Composition.coe_embedding theorem index_exists {j : ℕ} (h : j < n) : ∃ i : ℕ, j < c.sizeUpTo (i + 1) ∧ i < c.length := by have n_pos : 0 < n := lt_of_le_of_lt (zero_le j) h have : 0 < c.blocks.sum := by rwa [← c.blocks_sum] at n_pos have length_pos : 0 < c.blocks.length := length_pos_of_sum_pos (blocks c) this refine ⟨c.length - 1, ?_, Nat.pred_lt (ne_of_gt length_pos)⟩ have : c.length - 1 + 1 = c.length := Nat.succ_pred_eq_of_pos length_pos simp [this, h] #align composition.index_exists Composition.index_exists def index (j : Fin n) : Fin c.length := ⟨Nat.find (c.index_exists j.2), (Nat.find_spec (c.index_exists j.2)).2⟩ #align composition.index Composition.index theorem lt_sizeUpTo_index_succ (j : Fin n) : (j : ℕ) < c.sizeUpTo (c.index j).succ := (Nat.find_spec (c.index_exists j.2)).1 #align composition.lt_size_up_to_index_succ Composition.lt_sizeUpTo_index_succ theorem sizeUpTo_index_le (j : Fin n) : c.sizeUpTo (c.index j) ≤ j := by by_contra H set i := c.index j push_neg at H have i_pos : (0 : ℕ) < i := by by_contra! i_pos revert H simp [nonpos_iff_eq_zero.1 i_pos, c.sizeUpTo_zero] let i₁ := (i : ℕ).pred have i₁_lt_i : i₁ < i := Nat.pred_lt (ne_of_gt i_pos) have i₁_succ : i₁ + 1 = i := Nat.succ_pred_eq_of_pos i_pos have := Nat.find_min (c.index_exists j.2) i₁_lt_i simp [lt_trans i₁_lt_i (c.index j).2, i₁_succ] at this exact Nat.lt_le_asymm H this #align composition.size_up_to_index_le Composition.sizeUpTo_index_le def invEmbedding (j : Fin n) : Fin (c.blocksFun (c.index j)) := ⟨j - c.sizeUpTo (c.index j), by rw [tsub_lt_iff_right, add_comm, ← sizeUpTo_succ'] · exact lt_sizeUpTo_index_succ _ _ · exact sizeUpTo_index_le _ _⟩ #align composition.inv_embedding Composition.invEmbedding @[simp] theorem coe_invEmbedding (j : Fin n) : (c.invEmbedding j : ℕ) = j - c.sizeUpTo (c.index j) := rfl #align composition.coe_inv_embedding Composition.coe_invEmbedding theorem embedding_comp_inv (j : Fin n) : c.embedding (c.index j) (c.invEmbedding j) = j := by rw [Fin.ext_iff] apply add_tsub_cancel_of_le (c.sizeUpTo_index_le j) #align composition.embedding_comp_inv Composition.embedding_comp_inv theorem mem_range_embedding_iff {j : Fin n} {i : Fin c.length} : j ∈ Set.range (c.embedding i) ↔ c.sizeUpTo i ≤ j ∧ (j : ℕ) < c.sizeUpTo (i : ℕ).succ := by constructor · intro h rcases Set.mem_range.2 h with ⟨k, hk⟩ rw [Fin.ext_iff] at hk dsimp at hk rw [← hk] simp [sizeUpTo_succ', k.is_lt] · intro h apply Set.mem_range.2 refine ⟨⟨j - c.sizeUpTo i, ?_⟩, ?_⟩ · rw [tsub_lt_iff_left, ← sizeUpTo_succ'] · exact h.2 · exact h.1 · rw [Fin.ext_iff] exact add_tsub_cancel_of_le h.1 #align composition.mem_range_embedding_iff Composition.mem_range_embedding_iff theorem disjoint_range {i₁ i₂ : Fin c.length} (h : i₁ ≠ i₂) : Disjoint (Set.range (c.embedding i₁)) (Set.range (c.embedding i₂)) := by classical wlog h' : i₁ < i₂ · exact (this c h.symm (h.lt_or_lt.resolve_left h')).symm by_contra d obtain ⟨x, hx₁, hx₂⟩ : ∃ x : Fin n, x ∈ Set.range (c.embedding i₁) ∧ x ∈ Set.range (c.embedding i₂) := Set.not_disjoint_iff.1 d have A : (i₁ : ℕ).succ ≤ i₂ := Nat.succ_le_of_lt h' apply lt_irrefl (x : ℕ) calc (x : ℕ) < c.sizeUpTo (i₁ : ℕ).succ := (c.mem_range_embedding_iff.1 hx₁).2 _ ≤ c.sizeUpTo (i₂ : ℕ) := monotone_sum_take _ A _ ≤ x := (c.mem_range_embedding_iff.1 hx₂).1 #align composition.disjoint_range Composition.disjoint_range theorem mem_range_embedding (j : Fin n) : j ∈ Set.range (c.embedding (c.index j)) := by have : c.embedding (c.index j) (c.invEmbedding j) ∈ Set.range (c.embedding (c.index j)) := Set.mem_range_self _ rwa [c.embedding_comp_inv j] at this #align composition.mem_range_embedding Composition.mem_range_embedding theorem mem_range_embedding_iff' {j : Fin n} {i : Fin c.length} : j ∈ Set.range (c.embedding i) ↔ i = c.index j := by constructor · rw [← not_imp_not] intro h exact Set.disjoint_right.1 (c.disjoint_range h) (c.mem_range_embedding j) · intro h rw [h] exact c.mem_range_embedding j #align composition.mem_range_embedding_iff' Composition.mem_range_embedding_iff' theorem index_embedding (i : Fin c.length) (j : Fin (c.blocksFun i)) : c.index (c.embedding i j) = i := by symm rw [← mem_range_embedding_iff'] apply Set.mem_range_self #align composition.index_embedding Composition.index_embedding theorem invEmbedding_comp (i : Fin c.length) (j : Fin (c.blocksFun i)) : (c.invEmbedding (c.embedding i j) : ℕ) = j := by simp_rw [coe_invEmbedding, index_embedding, coe_embedding, add_tsub_cancel_left] #align composition.inv_embedding_comp Composition.invEmbedding_comp def blocksFinEquiv : (Σi : Fin c.length, Fin (c.blocksFun i)) ≃ Fin n where toFun x := c.embedding x.1 x.2 invFun j := ⟨c.index j, c.invEmbedding j⟩ left_inv x := by rcases x with ⟨i, y⟩ dsimp congr; · exact c.index_embedding _ _ rw [Fin.heq_ext_iff] · exact c.invEmbedding_comp _ _ · rw [c.index_embedding] right_inv j := c.embedding_comp_inv j #align composition.blocks_fin_equiv Composition.blocksFinEquiv theorem blocksFun_congr {n₁ n₂ : ℕ} (c₁ : Composition n₁) (c₂ : Composition n₂) (i₁ : Fin c₁.length) (i₂ : Fin c₂.length) (hn : n₁ = n₂) (hc : c₁.blocks = c₂.blocks) (hi : (i₁ : ℕ) = i₂) : c₁.blocksFun i₁ = c₂.blocksFun i₂ := by cases hn rw [← Composition.ext_iff] at hc cases hc congr rwa [Fin.ext_iff] #align composition.blocks_fun_congr Composition.blocksFun_congr theorem sigma_eq_iff_blocks_eq {c : Σn, Composition n} {c' : Σn, Composition n} : c = c' ↔ c.2.blocks = c'.2.blocks := by refine ⟨fun H => by rw [H], fun H => ?_⟩ rcases c with ⟨n, c⟩ rcases c' with ⟨n', c'⟩ have : n = n' := by rw [← c.blocks_sum, ← c'.blocks_sum, H] induction this congr ext1 exact H #align composition.sigma_eq_iff_blocks_eq Composition.sigma_eq_iff_blocks_eq def ones (n : ℕ) : Composition n := ⟨replicate n (1 : ℕ), fun {i} hi => by simp [List.eq_of_mem_replicate hi], by simp⟩ #align composition.ones Composition.ones instance {n : ℕ} : Inhabited (Composition n) := ⟨Composition.ones n⟩ @[simp] theorem ones_length (n : ℕ) : (ones n).length = n := List.length_replicate n 1 #align composition.ones_length Composition.ones_length @[simp] theorem ones_blocks (n : ℕ) : (ones n).blocks = replicate n (1 : ℕ) := rfl #align composition.ones_blocks Composition.ones_blocks @[simp] theorem ones_blocksFun (n : ℕ) (i : Fin (ones n).length) : (ones n).blocksFun i = 1 := by simp only [blocksFun, ones, blocks, i.2, List.get_replicate] #align composition.ones_blocks_fun Composition.ones_blocksFun @[simp] theorem ones_sizeUpTo (n : ℕ) (i : ℕ) : (ones n).sizeUpTo i = min i n := by simp [sizeUpTo, ones_blocks, take_replicate] #align composition.ones_size_up_to Composition.ones_sizeUpTo @[simp] theorem ones_embedding (i : Fin (ones n).length) (h : 0 < (ones n).blocksFun i) : (ones n).embedding i ⟨0, h⟩ = ⟨i, lt_of_lt_of_le i.2 (ones n).length_le⟩ := by ext simpa using i.2.le #align composition.ones_embedding Composition.ones_embedding theorem eq_ones_iff {c : Composition n} : c = ones n ↔ ∀ i ∈ c.blocks, i = 1 := by constructor · rintro rfl exact fun i => eq_of_mem_replicate · intro H ext1 have A : c.blocks = replicate c.blocks.length 1 := eq_replicate_of_mem H have : c.blocks.length = n := by conv_rhs => rw [← c.blocks_sum, A] simp rw [A, this, ones_blocks] #align composition.eq_ones_iff Composition.eq_ones_iff theorem ne_ones_iff {c : Composition n} : c ≠ ones n ↔ ∃ i ∈ c.blocks, 1 < i := by refine (not_congr eq_ones_iff).trans ?_ have : ∀ j ∈ c.blocks, j = 1 ↔ j ≤ 1 := fun j hj => by simp [le_antisymm_iff, c.one_le_blocks hj] simp (config := { contextual := true }) [this] #align composition.ne_ones_iff Composition.ne_ones_iff
Mathlib/Combinatorics/Enumerative/Composition.lean
524
541
theorem eq_ones_iff_length {c : Composition n} : c = ones n ↔ c.length = n := by
constructor · rintro rfl exact ones_length n · contrapose intro H length_n apply lt_irrefl n calc n = ∑ i : Fin c.length, 1 := by simp [length_n] _ < ∑ i : Fin c.length, c.blocksFun i := by { obtain ⟨i, hi, i_blocks⟩ : ∃ i ∈ c.blocks, 1 < i := ne_ones_iff.1 H rw [← ofFn_blocksFun, mem_ofFn c.blocksFun, Set.mem_range] at hi obtain ⟨j : Fin c.length, hj : c.blocksFun j = i⟩ := hi rw [← hj] at i_blocks exact Finset.sum_lt_sum (fun i _ => one_le_blocksFun c i) ⟨j, Finset.mem_univ _, i_blocks⟩ } _ = n := c.sum_blocksFun
import Mathlib.Data.Set.Basic #align_import data.set.bool_indicator from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" open Bool namespace Set variable {α : Type*} (s : Set α) noncomputable def boolIndicator (x : α) := @ite _ (x ∈ s) (Classical.propDecidable _) true false #align set.bool_indicator Set.boolIndicator theorem mem_iff_boolIndicator (x : α) : x ∈ s ↔ s.boolIndicator x = true := by unfold boolIndicator split_ifs with h <;> simp [h] #align set.mem_iff_bool_indicator Set.mem_iff_boolIndicator theorem not_mem_iff_boolIndicator (x : α) : x ∉ s ↔ s.boolIndicator x = false := by unfold boolIndicator split_ifs with h <;> simp [h] #align set.not_mem_iff_bool_indicator Set.not_mem_iff_boolIndicator theorem preimage_boolIndicator_true : s.boolIndicator ⁻¹' {true} = s := ext fun x ↦ (s.mem_iff_boolIndicator x).symm #align set.preimage_bool_indicator_true Set.preimage_boolIndicator_true theorem preimage_boolIndicator_false : s.boolIndicator ⁻¹' {false} = sᶜ := ext fun x ↦ (s.not_mem_iff_boolIndicator x).symm #align set.preimage_bool_indicator_false Set.preimage_boolIndicator_false open scoped Classical
Mathlib/Data/Set/BoolIndicator.lean
47
51
theorem preimage_boolIndicator_eq_union (t : Set Bool) : s.boolIndicator ⁻¹' t = (if true ∈ t then s else ∅) ∪ if false ∈ t then sᶜ else ∅ := by
ext x simp only [boolIndicator, mem_preimage] split_ifs <;> simp [*]
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
Mathlib/Topology/ContinuousOn.lean
1,165
1,167
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]
import Mathlib.Data.List.Basic namespace List variable {α β : Type*} @[simp] theorem reduceOption_cons_of_some (x : α) (l : List (Option α)) : reduceOption (some x :: l) = x :: l.reduceOption := by simp only [reduceOption, filterMap, id, eq_self_iff_true, and_self_iff] #align list.reduce_option_cons_of_some List.reduceOption_cons_of_some @[simp] theorem reduceOption_cons_of_none (l : List (Option α)) : reduceOption (none :: l) = l.reduceOption := by simp only [reduceOption, filterMap, id] #align list.reduce_option_cons_of_none List.reduceOption_cons_of_none @[simp] theorem reduceOption_nil : @reduceOption α [] = [] := rfl #align list.reduce_option_nil List.reduceOption_nil @[simp] theorem reduceOption_map {l : List (Option α)} {f : α → β} : reduceOption (map (Option.map f) l) = map f (reduceOption l) := by induction' l with hd tl hl · simp only [reduceOption_nil, map_nil] · cases hd <;> simpa [true_and_iff, Option.map_some', map, eq_self_iff_true, reduceOption_cons_of_some] using hl #align list.reduce_option_map List.reduceOption_map theorem reduceOption_append (l l' : List (Option α)) : (l ++ l').reduceOption = l.reduceOption ++ l'.reduceOption := filterMap_append l l' id #align list.reduce_option_append List.reduceOption_append theorem reduceOption_length_eq {l : List (Option α)} : l.reduceOption.length = (l.filter Option.isSome).length := by induction' l with hd tl hl · simp_rw [reduceOption_nil, filter_nil, length] · cases hd <;> simp [hl] theorem length_eq_reduceOption_length_add_filter_none {l : List (Option α)} : l.length = l.reduceOption.length + (l.filter Option.isNone).length := by simp_rw [reduceOption_length_eq, l.length_eq_length_filter_add Option.isSome, Option.bnot_isSome] theorem reduceOption_length_le (l : List (Option α)) : l.reduceOption.length ≤ l.length := by rw [length_eq_reduceOption_length_add_filter_none] apply Nat.le_add_right #align list.reduce_option_length_le List.reduceOption_length_le theorem reduceOption_length_eq_iff {l : List (Option α)} : l.reduceOption.length = l.length ↔ ∀ x ∈ l, Option.isSome x := by rw [reduceOption_length_eq, List.filter_length_eq_length] #align list.reduce_option_length_eq_iff List.reduceOption_length_eq_iff
Mathlib/Data/List/ReduceOption.lean
69
74
theorem reduceOption_length_lt_iff {l : List (Option α)} : l.reduceOption.length < l.length ↔ none ∈ l := by
rw [Nat.lt_iff_le_and_ne, and_iff_right (reduceOption_length_le l), Ne, reduceOption_length_eq_iff] induction l <;> simp [*] rw [@eq_comm _ none, ← Option.not_isSome_iff_eq_none, Decidable.imp_iff_not_or]
import Mathlib.Analysis.Calculus.BumpFunction.Basic import Mathlib.MeasureTheory.Integral.SetIntegral import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar #align_import analysis.calculus.bump_function_inner from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" noncomputable section open Function Filter Set Metric MeasureTheory FiniteDimensional Measure open scoped Topology namespace ContDiffBump variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [HasContDiffBump E] [MeasurableSpace E] {c : E} (f : ContDiffBump c) {x : E} {n : ℕ∞} {μ : Measure E} protected def normed (μ : Measure E) : E → ℝ := fun x => f x / ∫ x, f x ∂μ #align cont_diff_bump.normed ContDiffBump.normed theorem normed_def {μ : Measure E} (x : E) : f.normed μ x = f x / ∫ x, f x ∂μ := rfl #align cont_diff_bump.normed_def ContDiffBump.normed_def theorem nonneg_normed (x : E) : 0 ≤ f.normed μ x := div_nonneg f.nonneg <| integral_nonneg f.nonneg' #align cont_diff_bump.nonneg_normed ContDiffBump.nonneg_normed theorem contDiff_normed {n : ℕ∞} : ContDiff ℝ n (f.normed μ) := f.contDiff.div_const _ #align cont_diff_bump.cont_diff_normed ContDiffBump.contDiff_normed theorem continuous_normed : Continuous (f.normed μ) := f.continuous.div_const _ #align cont_diff_bump.continuous_normed ContDiffBump.continuous_normed theorem normed_sub (x : E) : f.normed μ (c - x) = f.normed μ (c + x) := by simp_rw [f.normed_def, f.sub] #align cont_diff_bump.normed_sub ContDiffBump.normed_sub theorem normed_neg (f : ContDiffBump (0 : E)) (x : E) : f.normed μ (-x) = f.normed μ x := by simp_rw [f.normed_def, f.neg] #align cont_diff_bump.normed_neg ContDiffBump.normed_neg variable [BorelSpace E] [FiniteDimensional ℝ E] [IsLocallyFiniteMeasure μ] protected theorem integrable : Integrable f μ := f.continuous.integrable_of_hasCompactSupport f.hasCompactSupport #align cont_diff_bump.integrable ContDiffBump.integrable protected theorem integrable_normed : Integrable (f.normed μ) μ := f.integrable.div_const _ #align cont_diff_bump.integrable_normed ContDiffBump.integrable_normed variable [μ.IsOpenPosMeasure]
Mathlib/Analysis/Calculus/BumpFunction/Normed.lean
69
72
theorem integral_pos : 0 < ∫ x, f x ∂μ := by
refine (integral_pos_iff_support_of_nonneg f.nonneg' f.integrable).mpr ?_ rw [f.support_eq] exact measure_ball_pos μ c f.rOut_pos
import Mathlib.Analysis.NormedSpace.Star.Spectrum import Mathlib.Analysis.Normed.Group.Quotient import Mathlib.Analysis.NormedSpace.Algebra import Mathlib.Topology.ContinuousFunction.Units import Mathlib.Topology.ContinuousFunction.Compact import Mathlib.Topology.Algebra.Algebra import Mathlib.Topology.ContinuousFunction.Ideals import Mathlib.Topology.ContinuousFunction.StoneWeierstrass #align_import analysis.normed_space.star.gelfand_duality from "leanprover-community/mathlib"@"e65771194f9e923a70dfb49b6ca7be6e400d8b6f" open WeakDual open scoped NNReal section ComplexBanachAlgebra open Ideal variable {A : Type*} [NormedCommRing A] [NormedAlgebra ℂ A] [CompleteSpace A] (I : Ideal A) [Ideal.IsMaximal I] noncomputable def Ideal.toCharacterSpace : characterSpace ℂ A := CharacterSpace.equivAlgHom.symm <| ((NormedRing.algEquivComplexOfComplete (letI := Quotient.field I; isUnit_iff_ne_zero (G₀ := A ⧸ I))).symm : A ⧸ I →ₐ[ℂ] ℂ).comp <| Quotient.mkₐ ℂ I #align ideal.to_character_space Ideal.toCharacterSpace
Mathlib/Analysis/NormedSpace/Star/GelfandDuality.lean
88
94
theorem Ideal.toCharacterSpace_apply_eq_zero_of_mem {a : A} (ha : a ∈ I) : I.toCharacterSpace a = 0 := by
unfold Ideal.toCharacterSpace simp only [CharacterSpace.equivAlgHom_symm_coe, AlgHom.coe_comp, AlgHom.coe_coe, Quotient.mkₐ_eq_mk, Function.comp_apply, NormedRing.algEquivComplexOfComplete_symm_apply] simp_rw [Quotient.eq_zero_iff_mem.mpr ha, spectrum.zero_eq] exact Set.eq_of_mem_singleton (Set.singleton_nonempty (0 : ℂ)).some_mem
import Mathlib.Data.Set.Pointwise.SMul #align_import algebra.add_torsor from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" class AddTorsor (G : outParam Type*) (P : Type*) [AddGroup G] extends AddAction G P, VSub G P where [nonempty : Nonempty P] vsub_vadd' : ∀ p₁ p₂ : P, (p₁ -ᵥ p₂ : G) +ᵥ p₂ = p₁ vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g #align add_torsor AddTorsor -- Porting note(#12096): removed `nolint instance_priority`; lint not ported yet attribute [instance 100] AddTorsor.nonempty -- Porting note(#12094): removed nolint; dangerous_instance linter not ported yet --attribute [nolint dangerous_instance] AddTorsor.toVSub -- Porting note(#12096): linter not ported yet --@[nolint instance_priority] instance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G where vsub := Sub.sub vsub_vadd' := sub_add_cancel vadd_vsub' := add_sub_cancel_right #align add_group_is_add_torsor addGroupIsAddTorsor @[simp] theorem vsub_eq_sub {G : Type*} [AddGroup G] (g₁ g₂ : G) : g₁ -ᵥ g₂ = g₁ - g₂ := rfl #align vsub_eq_sub vsub_eq_sub section General variable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P] @[simp] theorem vsub_vadd (p₁ p₂ : P) : p₁ -ᵥ p₂ +ᵥ p₂ = p₁ := AddTorsor.vsub_vadd' p₁ p₂ #align vsub_vadd vsub_vadd @[simp] theorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g := AddTorsor.vadd_vsub' g p #align vadd_vsub vadd_vsub theorem vadd_right_cancel {g₁ g₂ : G} (p : P) (h : g₁ +ᵥ p = g₂ +ᵥ p) : g₁ = g₂ := by -- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p rw [← vadd_vsub g₁ p, h, vadd_vsub] #align vadd_right_cancel vadd_right_cancel @[simp] theorem vadd_right_cancel_iff {g₁ g₂ : G} (p : P) : g₁ +ᵥ p = g₂ +ᵥ p ↔ g₁ = g₂ := ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩ #align vadd_right_cancel_iff vadd_right_cancel_iff theorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ => vadd_right_cancel p #align vadd_right_injective vadd_right_injective theorem vadd_vsub_assoc (g : G) (p₁ p₂ : P) : g +ᵥ p₁ -ᵥ p₂ = g + (p₁ -ᵥ p₂) := by apply vadd_right_cancel p₂ rw [vsub_vadd, add_vadd, vsub_vadd] #align vadd_vsub_assoc vadd_vsub_assoc @[simp] theorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by rw [← zero_add (p -ᵥ p), ← vadd_vsub_assoc, vadd_vsub] #align vsub_self vsub_self theorem eq_of_vsub_eq_zero {p₁ p₂ : P} (h : p₁ -ᵥ p₂ = (0 : G)) : p₁ = p₂ := by rw [← vsub_vadd p₁ p₂, h, zero_vadd] #align eq_of_vsub_eq_zero eq_of_vsub_eq_zero @[simp] theorem vsub_eq_zero_iff_eq {p₁ p₂ : P} : p₁ -ᵥ p₂ = (0 : G) ↔ p₁ = p₂ := Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _ #align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq theorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q := not_congr vsub_eq_zero_iff_eq #align vsub_ne_zero vsub_ne_zero @[simp] theorem vsub_add_vsub_cancel (p₁ p₂ p₃ : P) : p₁ -ᵥ p₂ + (p₂ -ᵥ p₃) = p₁ -ᵥ p₃ := by apply vadd_right_cancel p₃ rw [add_vadd, vsub_vadd, vsub_vadd, vsub_vadd] #align vsub_add_vsub_cancel vsub_add_vsub_cancel @[simp] theorem neg_vsub_eq_vsub_rev (p₁ p₂ : P) : -(p₁ -ᵥ p₂) = p₂ -ᵥ p₁ := by refine neg_eq_of_add_eq_zero_right (vadd_right_cancel p₁ ?_) rw [vsub_add_vsub_cancel, vsub_self] #align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev theorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by rw [vadd_vsub_assoc, sub_eq_add_neg, neg_vsub_eq_vsub_rev] #align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub theorem vsub_vadd_eq_vsub_sub (p₁ p₂ : P) (g : G) : p₁ -ᵥ (g +ᵥ p₂) = p₁ -ᵥ p₂ - g := by rw [← add_right_inj (p₂ -ᵥ p₁ : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ← add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub] #align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub @[simp] theorem vsub_sub_vsub_cancel_right (p₁ p₂ p₃ : P) : p₁ -ᵥ p₃ - (p₂ -ᵥ p₃) = p₁ -ᵥ p₂ := by rw [← vsub_vadd_eq_vsub_sub, vsub_vadd] #align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right theorem eq_vadd_iff_vsub_eq (p₁ : P) (g : G) (p₂ : P) : p₁ = g +ᵥ p₂ ↔ p₁ -ᵥ p₂ = g := ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩ #align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq theorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} : v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by rw [eq_vadd_iff_vsub_eq, vadd_vsub_assoc, ← add_right_inj (-v₁), neg_add_cancel_left, eq_comm] #align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub section comm variable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P] @[simp]
Mathlib/Algebra/AddTorsor.lean
251
252
theorem vsub_sub_vsub_cancel_left (p₁ p₂ p₃ : P) : p₃ -ᵥ p₂ - (p₃ -ᵥ p₁) = p₁ -ᵥ p₂ := by
rw [sub_eq_add_neg, neg_vsub_eq_vsub_rev, add_comm, vsub_add_vsub_cancel]
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
Mathlib/MeasureTheory/Measure/FiniteMeasure.lean
220
223
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)
import Mathlib.Analysis.InnerProductSpace.Spectrum import Mathlib.Data.Matrix.Rank import Mathlib.LinearAlgebra.Matrix.Diagonal import Mathlib.LinearAlgebra.Matrix.Hermitian #align_import linear_algebra.matrix.spectrum from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" namespace Matrix variable {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n] variable {A : Matrix n n 𝕜} namespace IsHermitian section DecidableEq variable [DecidableEq n] variable (hA : A.IsHermitian) noncomputable def eigenvalues₀ : Fin (Fintype.card n) → ℝ := (isHermitian_iff_isSymmetric.1 hA).eigenvalues finrank_euclideanSpace #align matrix.is_hermitian.eigenvalues₀ Matrix.IsHermitian.eigenvalues₀ noncomputable def eigenvalues : n → ℝ := fun i => hA.eigenvalues₀ <| (Fintype.equivOfCardEq (Fintype.card_fin _)).symm i #align matrix.is_hermitian.eigenvalues Matrix.IsHermitian.eigenvalues noncomputable def eigenvectorBasis : OrthonormalBasis n 𝕜 (EuclideanSpace 𝕜 n) := ((isHermitian_iff_isSymmetric.1 hA).eigenvectorBasis finrank_euclideanSpace).reindex (Fintype.equivOfCardEq (Fintype.card_fin _)) #align matrix.is_hermitian.eigenvector_basis Matrix.IsHermitian.eigenvectorBasis lemma mulVec_eigenvectorBasis (j : n) : A *ᵥ ⇑(hA.eigenvectorBasis j) = (hA.eigenvalues j) • ⇑(hA.eigenvectorBasis j) := by simpa only [eigenvectorBasis, OrthonormalBasis.reindex_apply, toEuclideanLin_apply, RCLike.real_smul_eq_coe_smul (K := 𝕜)] using congr(⇑$((isHermitian_iff_isSymmetric.1 hA).apply_eigenvectorBasis finrank_euclideanSpace ((Fintype.equivOfCardEq (Fintype.card_fin _)).symm j))) noncomputable def eigenvectorUnitary {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n]{A : Matrix n n 𝕜} [DecidableEq n] (hA : Matrix.IsHermitian A) : Matrix.unitaryGroup n 𝕜 := ⟨(EuclideanSpace.basisFun n 𝕜).toBasis.toMatrix (hA.eigenvectorBasis).toBasis, (EuclideanSpace.basisFun n 𝕜).toMatrix_orthonormalBasis_mem_unitary (eigenvectorBasis hA)⟩ #align matrix.is_hermitian.eigenvector_matrix Matrix.IsHermitian.eigenvectorUnitary lemma eigenvectorUnitary_coe {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n] {A : Matrix n n 𝕜} [DecidableEq n] (hA : Matrix.IsHermitian A) : eigenvectorUnitary hA = (EuclideanSpace.basisFun n 𝕜).toBasis.toMatrix (hA.eigenvectorBasis).toBasis := rfl @[simp] theorem eigenvectorUnitary_apply (i j : n) : eigenvectorUnitary hA i j = ⇑(hA.eigenvectorBasis j) i := rfl #align matrix.is_hermitian.eigenvector_matrix_apply Matrix.IsHermitian.eigenvectorUnitary_apply theorem eigenvectorUnitary_mulVec (j : n) : eigenvectorUnitary hA *ᵥ Pi.single j 1 = ⇑(hA.eigenvectorBasis j) := by simp only [mulVec_single, eigenvectorUnitary_apply, mul_one] theorem star_eigenvectorUnitary_mulVec (j : n) : (star (eigenvectorUnitary hA : Matrix n n 𝕜)) *ᵥ ⇑(hA.eigenvectorBasis j) = Pi.single j 1 := by rw [← eigenvectorUnitary_mulVec, mulVec_mulVec, unitary.coe_star_mul_self, one_mulVec] theorem star_mul_self_mul_eq_diagonal : (star (eigenvectorUnitary hA : Matrix n n 𝕜)) * A * (eigenvectorUnitary hA : Matrix n n 𝕜) = diagonal (RCLike.ofReal ∘ hA.eigenvalues) := by apply Matrix.toEuclideanLin.injective apply Basis.ext (EuclideanSpace.basisFun n 𝕜).toBasis intro i simp only [toEuclideanLin_apply, OrthonormalBasis.coe_toBasis, EuclideanSpace.basisFun_apply, WithLp.equiv_single, ← mulVec_mulVec, eigenvectorUnitary_mulVec, ← mulVec_mulVec, mulVec_eigenvectorBasis, Matrix.diagonal_mulVec_single, mulVec_smul, star_eigenvectorUnitary_mulVec, RCLike.real_smul_eq_coe_smul (K := 𝕜), WithLp.equiv_symm_smul, WithLp.equiv_symm_single, Function.comp_apply, mul_one, WithLp.equiv_symm_single] apply PiLp.ext intro j simp only [PiLp.smul_apply, EuclideanSpace.single_apply, smul_eq_mul, mul_ite, mul_one, mul_zero]
Mathlib/LinearAlgebra/Matrix/Spectrum.lean
106
111
theorem spectral_theorem : A = (eigenvectorUnitary hA : Matrix n n 𝕜) * diagonal (RCLike.ofReal ∘ hA.eigenvalues) * (star (eigenvectorUnitary hA : Matrix n n 𝕜)) := by
rw [← star_mul_self_mul_eq_diagonal, mul_assoc, mul_assoc, (Matrix.mem_unitaryGroup_iff).mp (eigenvectorUnitary hA).2, mul_one, ← mul_assoc, (Matrix.mem_unitaryGroup_iff).mp (eigenvectorUnitary hA).2, one_mul]
import Mathlib.Tactic.Ring.Basic import Mathlib.Tactic.TryThis import Mathlib.Tactic.Conv import Mathlib.Util.Qq set_option autoImplicit true -- In this file we would like to be able to use multi-character auto-implicits. set_option relaxedAutoImplicit true namespace Mathlib.Tactic open Lean hiding Rat open Qq Meta namespace RingNF open Ring inductive RingMode where | SOP | raw deriving Inhabited, BEq, Repr structure Config where red := TransparencyMode.reducible recursive := true mode := RingMode.SOP deriving Inhabited, BEq, Repr declare_config_elab elabConfig Config structure Context where ctx : Simp.Context simp : Simp.Result → SimpM Simp.Result abbrev M := ReaderT Context AtomM def rewrite (parent : Expr) (root := true) : M Simp.Result := fun nctx rctx s ↦ do let pre : Simp.Simproc := fun e => try guard <| root || parent != e -- recursion guard let e ← withReducible <| whnf e guard e.isApp -- all interesting ring expressions are applications let ⟨u, α, e⟩ ← inferTypeQ' e let sα ← synthInstanceQ (q(CommSemiring $α) : Q(Type u)) let c ← mkCache sα let ⟨a, _, pa⟩ ← match ← isAtomOrDerivable sα c e rctx s with | none => eval sα c e rctx s -- `none` indicates that `eval` will find something algebraic. | some none => failure -- No point rewriting atoms | some (some r) => pure r -- Nothing algebraic for `eval` to use, but `norm_num` simplifies. let r ← nctx.simp { expr := a, proof? := pa } if ← withReducible <| isDefEq r.expr e then return .done { expr := r.expr } pure (.done r) catch _ => pure <| .continue let post := Simp.postDefault #[] (·.1) <$> Simp.main parent nctx.ctx (methods := { pre, post }) variable [CommSemiring R] theorem add_assoc_rev (a b c : R) : a + (b + c) = a + b + c := (add_assoc ..).symm theorem mul_assoc_rev (a b c : R) : a * (b * c) = a * b * c := (mul_assoc ..).symm theorem mul_neg {R} [Ring R] (a b : R) : a * -b = -(a * b) := by simp theorem add_neg {R} [Ring R] (a b : R) : a + -b = a - b := (sub_eq_add_neg ..).symm theorem nat_rawCast_0 : (Nat.rawCast 0 : R) = 0 := by simp theorem nat_rawCast_1 : (Nat.rawCast 1 : R) = 1 := by simp theorem nat_rawCast_2 [Nat.AtLeastTwo n] : (Nat.rawCast n : R) = OfNat.ofNat n := rfl theorem int_rawCast_neg {R} [Ring R] : (Int.rawCast (.negOfNat n) : R) = -Nat.rawCast n := by simp
Mathlib/Tactic/Ring/RingNF.lean
124
125
theorem rat_rawCast_pos {R} [DivisionRing R] : (Rat.rawCast (.ofNat n) d : R) = Nat.rawCast n / Nat.rawCast d := by
simp
import Mathlib.Algebra.Order.Floor import Mathlib.Algebra.Order.Field.Power import Mathlib.Data.Nat.Log #align_import data.int.log from "leanprover-community/mathlib"@"1f0096e6caa61e9c849ec2adbd227e960e9dff58" variable {R : Type*} [LinearOrderedSemifield R] [FloorSemiring R] namespace Int def log (b : ℕ) (r : R) : ℤ := if 1 ≤ r then Nat.log b ⌊r⌋₊ else -Nat.clog b ⌈r⁻¹⌉₊ #align int.log Int.log theorem log_of_one_le_right (b : ℕ) {r : R} (hr : 1 ≤ r) : log b r = Nat.log b ⌊r⌋₊ := if_pos hr #align int.log_of_one_le_right Int.log_of_one_le_right theorem log_of_right_le_one (b : ℕ) {r : R} (hr : r ≤ 1) : log b r = -Nat.clog b ⌈r⁻¹⌉₊ := by obtain rfl | hr := hr.eq_or_lt · rw [log, if_pos hr, inv_one, Nat.ceil_one, Nat.floor_one, Nat.log_one_right, Nat.clog_one_right, Int.ofNat_zero, neg_zero] · exact if_neg hr.not_le #align int.log_of_right_le_one Int.log_of_right_le_one @[simp, norm_cast] theorem log_natCast (b : ℕ) (n : ℕ) : log b (n : R) = Nat.log b n := by cases n · simp [log_of_right_le_one] · rw [log_of_one_le_right, Nat.floor_natCast] simp #align int.log_nat_cast Int.log_natCast -- See note [no_index around OfNat.ofNat] @[simp] theorem log_ofNat (b : ℕ) (n : ℕ) [n.AtLeastTwo] : log b (no_index (OfNat.ofNat n : R)) = Nat.log b (OfNat.ofNat n) := log_natCast b n theorem log_of_left_le_one {b : ℕ} (hb : b ≤ 1) (r : R) : log b r = 0 := by rcases le_total 1 r with h | h · rw [log_of_one_le_right _ h, Nat.log_of_left_le_one hb, Int.ofNat_zero] · rw [log_of_right_le_one _ h, Nat.clog_of_left_le_one hb, Int.ofNat_zero, neg_zero] #align int.log_of_left_le_one Int.log_of_left_le_one theorem log_of_right_le_zero (b : ℕ) {r : R} (hr : r ≤ 0) : log b r = 0 := by rw [log_of_right_le_one _ (hr.trans zero_le_one), Nat.clog_of_right_le_one ((Nat.ceil_eq_zero.mpr <| inv_nonpos.2 hr).trans_le zero_le_one), Int.ofNat_zero, neg_zero] #align int.log_of_right_le_zero Int.log_of_right_le_zero theorem zpow_log_le_self {b : ℕ} {r : R} (hb : 1 < b) (hr : 0 < r) : (b : R) ^ log b r ≤ r := by rcases le_total 1 r with hr1 | hr1 · rw [log_of_one_le_right _ hr1] rw [zpow_natCast, ← Nat.cast_pow, ← Nat.le_floor_iff hr.le] exact Nat.pow_log_le_self b (Nat.floor_pos.mpr hr1).ne' · rw [log_of_right_le_one _ hr1, zpow_neg, zpow_natCast, ← Nat.cast_pow] exact inv_le_of_inv_le hr (Nat.ceil_le.1 <| Nat.le_pow_clog hb _) #align int.zpow_log_le_self Int.zpow_log_le_self theorem lt_zpow_succ_log_self {b : ℕ} (hb : 1 < b) (r : R) : r < (b : R) ^ (log b r + 1) := by rcases le_or_lt r 0 with hr | hr · rw [log_of_right_le_zero _ hr, zero_add, zpow_one] exact hr.trans_lt (zero_lt_one.trans_le <| mod_cast hb.le) rcases le_or_lt 1 r with hr1 | hr1 · rw [log_of_one_le_right _ hr1] rw [Int.ofNat_add_one_out, zpow_natCast, ← Nat.cast_pow] apply Nat.lt_of_floor_lt exact Nat.lt_pow_succ_log_self hb _ · rw [log_of_right_le_one _ hr1.le] have hcri : 1 < r⁻¹ := one_lt_inv hr hr1 have : 1 ≤ Nat.clog b ⌈r⁻¹⌉₊ := Nat.succ_le_of_lt (Nat.clog_pos hb <| Nat.one_lt_cast.1 <| hcri.trans_le (Nat.le_ceil _)) rw [neg_add_eq_sub, ← neg_sub, ← Int.ofNat_one, ← Int.ofNat_sub this, zpow_neg, zpow_natCast, lt_inv hr (pow_pos (Nat.cast_pos.mpr <| zero_lt_one.trans hb) _), ← Nat.cast_pow] refine Nat.lt_ceil.1 ?_ exact Nat.pow_pred_clog_lt_self hb <| Nat.one_lt_cast.1 <| hcri.trans_le <| Nat.le_ceil _ #align int.lt_zpow_succ_log_self Int.lt_zpow_succ_log_self @[simp] theorem log_zero_right (b : ℕ) : log b (0 : R) = 0 := log_of_right_le_zero b le_rfl #align int.log_zero_right Int.log_zero_right @[simp] theorem log_one_right (b : ℕ) : log b (1 : R) = 0 := by rw [log_of_one_le_right _ le_rfl, Nat.floor_one, Nat.log_one_right, Int.ofNat_zero] #align int.log_one_right Int.log_one_right -- Porting note: needed to replace b ^ z with (b : R) ^ z in the below theorem log_zpow {b : ℕ} (hb : 1 < b) (z : ℤ) : log b ((b : R) ^ z : R) = z := by obtain ⟨n, rfl | rfl⟩ := Int.eq_nat_or_neg z · rw [log_of_one_le_right _ (one_le_zpow_of_nonneg _ <| Int.natCast_nonneg _), zpow_natCast, ← Nat.cast_pow, Nat.floor_natCast, Nat.log_pow hb] exact mod_cast hb.le · rw [log_of_right_le_one _ (zpow_le_one_of_nonpos _ <| neg_nonpos.mpr (Int.natCast_nonneg _)), zpow_neg, inv_inv, zpow_natCast, ← Nat.cast_pow, Nat.ceil_natCast, Nat.clog_pow _ _ hb] exact mod_cast hb.le #align int.log_zpow Int.log_zpow @[mono] theorem log_mono_right {b : ℕ} {r₁ r₂ : R} (h₀ : 0 < r₁) (h : r₁ ≤ r₂) : log b r₁ ≤ log b r₂ := by rcases le_total r₁ 1 with h₁ | h₁ <;> rcases le_total r₂ 1 with h₂ | h₂ · rw [log_of_right_le_one _ h₁, log_of_right_le_one _ h₂, neg_le_neg_iff, Int.ofNat_le] exact Nat.clog_mono_right _ (Nat.ceil_mono <| inv_le_inv_of_le h₀ h) · rw [log_of_right_le_one _ h₁, log_of_one_le_right _ h₂] exact (neg_nonpos.mpr (Int.natCast_nonneg _)).trans (Int.natCast_nonneg _) · obtain rfl := le_antisymm h (h₂.trans h₁) rfl · rw [log_of_one_le_right _ h₁, log_of_one_le_right _ h₂, Int.ofNat_le] exact Nat.log_mono_right (Nat.floor_mono h) #align int.log_mono_right Int.log_mono_right variable (R) def zpowLogGi {b : ℕ} (hb : 1 < b) : GaloisCoinsertion (fun z : ℤ => Subtype.mk ((b : R) ^ z) <| zpow_pos_of_pos (mod_cast zero_lt_one.trans hb) z) fun r : Set.Ioi (0 : R) => Int.log b (r : R) := GaloisCoinsertion.monotoneIntro (fun r₁ _ => log_mono_right r₁.2) (fun _ _ hz => Subtype.coe_le_coe.mp <| (zpow_strictMono <| mod_cast hb).monotone hz) (fun r => Subtype.coe_le_coe.mp <| zpow_log_le_self hb r.2) fun _ => log_zpow (R := R) hb _ #align int.zpow_log_gi Int.zpowLogGi variable {R} theorem lt_zpow_iff_log_lt {b : ℕ} (hb : 1 < b) {x : ℤ} {r : R} (hr : 0 < r) : r < (b : R) ^ x ↔ log b r < x := @GaloisConnection.lt_iff_lt _ _ _ _ _ _ (zpowLogGi R hb).gc x ⟨r, hr⟩ #align int.lt_zpow_iff_log_lt Int.lt_zpow_iff_log_lt theorem zpow_le_iff_le_log {b : ℕ} (hb : 1 < b) {x : ℤ} {r : R} (hr : 0 < r) : (b : R) ^ x ≤ r ↔ x ≤ log b r := @GaloisConnection.le_iff_le _ _ _ _ _ _ (zpowLogGi R hb).gc x ⟨r, hr⟩ #align int.zpow_le_iff_le_log Int.zpow_le_iff_le_log def clog (b : ℕ) (r : R) : ℤ := if 1 ≤ r then Nat.clog b ⌈r⌉₊ else -Nat.log b ⌊r⁻¹⌋₊ #align int.clog Int.clog theorem clog_of_one_le_right (b : ℕ) {r : R} (hr : 1 ≤ r) : clog b r = Nat.clog b ⌈r⌉₊ := if_pos hr #align int.clog_of_one_le_right Int.clog_of_one_le_right theorem clog_of_right_le_one (b : ℕ) {r : R} (hr : r ≤ 1) : clog b r = -Nat.log b ⌊r⁻¹⌋₊ := by obtain rfl | hr := hr.eq_or_lt · rw [clog, if_pos hr, inv_one, Nat.ceil_one, Nat.floor_one, Nat.log_one_right, Nat.clog_one_right, Int.ofNat_zero, neg_zero] · exact if_neg hr.not_le #align int.clog_of_right_le_one Int.clog_of_right_le_one theorem clog_of_right_le_zero (b : ℕ) {r : R} (hr : r ≤ 0) : clog b r = 0 := by rw [clog, if_neg (hr.trans_lt zero_lt_one).not_le, neg_eq_zero, Int.natCast_eq_zero, Nat.log_eq_zero_iff] rcases le_or_lt b 1 with hb | hb · exact Or.inr hb · refine Or.inl (lt_of_le_of_lt ?_ hb) exact Nat.floor_le_one_of_le_one ((inv_nonpos.2 hr).trans zero_le_one) #align int.clog_of_right_le_zero Int.clog_of_right_le_zero @[simp] theorem clog_inv (b : ℕ) (r : R) : clog b r⁻¹ = -log b r := by cases' lt_or_le 0 r with hrp hrp · obtain hr | hr := le_total 1 r · rw [clog_of_right_le_one _ (inv_le_one hr), log_of_one_le_right _ hr, inv_inv] · rw [clog_of_one_le_right _ (one_le_inv hrp hr), log_of_right_le_one _ hr, neg_neg] · rw [clog_of_right_le_zero _ (inv_nonpos.mpr hrp), log_of_right_le_zero _ hrp, neg_zero] #align int.clog_inv Int.clog_inv @[simp] theorem log_inv (b : ℕ) (r : R) : log b r⁻¹ = -clog b r := by rw [← inv_inv r, clog_inv, neg_neg, inv_inv] #align int.log_inv Int.log_inv -- note this is useful for writing in reverse
Mathlib/Data/Int/Log.lean
228
228
theorem neg_log_inv_eq_clog (b : ℕ) (r : R) : -log b r⁻¹ = clog b r := by
rw [log_inv, neg_neg]
import Mathlib.Probability.ConditionalProbability import Mathlib.MeasureTheory.Measure.Count #align_import probability.cond_count from "leanprover-community/mathlib"@"117e93f82b5f959f8193857370109935291f0cc4" noncomputable section open ProbabilityTheory open MeasureTheory MeasurableSpace namespace ProbabilityTheory variable {Ω : Type*} [MeasurableSpace Ω] def condCount (s : Set Ω) : Measure Ω := Measure.count[|s] #align probability_theory.cond_count ProbabilityTheory.condCount @[simp] theorem condCount_empty_meas : (condCount ∅ : Measure Ω) = 0 := by simp [condCount] #align probability_theory.cond_count_empty_meas ProbabilityTheory.condCount_empty_meas theorem condCount_empty {s : Set Ω} : condCount s ∅ = 0 := by simp #align probability_theory.cond_count_empty ProbabilityTheory.condCount_empty theorem finite_of_condCount_ne_zero {s t : Set Ω} (h : condCount s t ≠ 0) : s.Finite := by by_contra hs' simp [condCount, cond, Measure.count_apply_infinite hs'] at h #align probability_theory.finite_of_cond_count_ne_zero ProbabilityTheory.finite_of_condCount_ne_zero theorem condCount_univ [Fintype Ω] {s : Set Ω} : condCount Set.univ s = Measure.count s / Fintype.card Ω := by rw [condCount, cond_apply _ MeasurableSet.univ, ← ENNReal.div_eq_inv_mul, Set.univ_inter] congr rw [← Finset.coe_univ, Measure.count_apply, Finset.univ.tsum_subtype' fun _ => (1 : ENNReal)] · simp [Finset.card_univ] · exact (@Finset.coe_univ Ω _).symm ▸ MeasurableSet.univ #align probability_theory.cond_count_univ ProbabilityTheory.condCount_univ variable [MeasurableSingletonClass Ω] theorem condCount_isProbabilityMeasure {s : Set Ω} (hs : s.Finite) (hs' : s.Nonempty) : IsProbabilityMeasure (condCount s) := { measure_univ := by rw [condCount, cond_apply _ hs.measurableSet, Set.inter_univ, ENNReal.inv_mul_cancel] · exact fun h => hs'.ne_empty <| Measure.empty_of_count_eq_zero h · exact (Measure.count_apply_lt_top.2 hs).ne } #align probability_theory.cond_count_is_probability_measure ProbabilityTheory.condCount_isProbabilityMeasure theorem condCount_singleton (ω : Ω) (t : Set Ω) [Decidable (ω ∈ t)] : condCount {ω} t = if ω ∈ t then 1 else 0 := by rw [condCount, cond_apply _ (measurableSet_singleton ω), Measure.count_singleton, inv_one, one_mul] split_ifs · rw [(by simpa : ({ω} : Set Ω) ∩ t = {ω}), Measure.count_singleton] · rw [(by simpa : ({ω} : Set Ω) ∩ t = ∅), Measure.count_empty] #align probability_theory.cond_count_singleton ProbabilityTheory.condCount_singleton variable {s t u : Set Ω} theorem condCount_inter_self (hs : s.Finite) : condCount s (s ∩ t) = condCount s t := by rw [condCount, cond_inter_self _ hs.measurableSet] #align probability_theory.cond_count_inter_self ProbabilityTheory.condCount_inter_self theorem condCount_self (hs : s.Finite) (hs' : s.Nonempty) : condCount s s = 1 := by rw [condCount, cond_apply _ hs.measurableSet, Set.inter_self, ENNReal.inv_mul_cancel] · exact fun h => hs'.ne_empty <| Measure.empty_of_count_eq_zero h · exact (Measure.count_apply_lt_top.2 hs).ne #align probability_theory.cond_count_self ProbabilityTheory.condCount_self theorem condCount_eq_one_of (hs : s.Finite) (hs' : s.Nonempty) (ht : s ⊆ t) : condCount s t = 1 := by haveI := condCount_isProbabilityMeasure hs hs' refine eq_of_le_of_not_lt prob_le_one ?_ rw [not_lt, ← condCount_self hs hs'] exact measure_mono ht #align probability_theory.cond_count_eq_one_of ProbabilityTheory.condCount_eq_one_of theorem pred_true_of_condCount_eq_one (h : condCount s t = 1) : s ⊆ t := by have hsf := finite_of_condCount_ne_zero (by rw [h]; exact one_ne_zero) rw [condCount, cond_apply _ hsf.measurableSet, mul_comm] at h replace h := ENNReal.eq_inv_of_mul_eq_one_left h rw [inv_inv, Measure.count_apply_finite _ hsf, Measure.count_apply_finite _ (hsf.inter_of_left _), Nat.cast_inj] at h suffices s ∩ t = s by exact this ▸ fun x hx => hx.2 rw [← @Set.Finite.toFinset_inj _ _ _ (hsf.inter_of_left _) hsf] exact Finset.eq_of_subset_of_card_le (Set.Finite.toFinset_mono s.inter_subset_left) h.ge #align probability_theory.pred_true_of_cond_count_eq_one ProbabilityTheory.pred_true_of_condCount_eq_one theorem condCount_eq_zero_iff (hs : s.Finite) : condCount s t = 0 ↔ s ∩ t = ∅ := by simp [condCount, cond_apply _ hs.measurableSet, Measure.count_apply_eq_top, Set.not_infinite.2 hs, Measure.count_apply_finite _ (hs.inter_of_left _)] #align probability_theory.cond_count_eq_zero_iff ProbabilityTheory.condCount_eq_zero_iff theorem condCount_of_univ (hs : s.Finite) (hs' : s.Nonempty) : condCount s Set.univ = 1 := condCount_eq_one_of hs hs' s.subset_univ #align probability_theory.cond_count_of_univ ProbabilityTheory.condCount_of_univ theorem condCount_inter (hs : s.Finite) : condCount s (t ∩ u) = condCount (s ∩ t) u * condCount s t := by by_cases hst : s ∩ t = ∅ · rw [hst, condCount_empty_meas, Measure.coe_zero, Pi.zero_apply, zero_mul, condCount_eq_zero_iff hs, ← Set.inter_assoc, hst, Set.empty_inter] rw [condCount, condCount, cond_apply _ hs.measurableSet, cond_apply _ hs.measurableSet, cond_apply _ (hs.inter_of_left _).measurableSet, mul_comm _ (Measure.count (s ∩ t)), ← mul_assoc, mul_comm _ (Measure.count (s ∩ t)), ← mul_assoc, ENNReal.mul_inv_cancel, one_mul, mul_comm, Set.inter_assoc] · rwa [← Measure.count_eq_zero_iff] at hst · exact (Measure.count_apply_lt_top.2 <| hs.inter_of_left _).ne #align probability_theory.cond_count_inter ProbabilityTheory.condCount_inter
Mathlib/Probability/CondCount.lean
151
154
theorem condCount_inter' (hs : s.Finite) : condCount s (t ∩ u) = condCount (s ∩ u) t * condCount s u := by
rw [← Set.inter_comm] exact condCount_inter hs
import Mathlib.Analysis.Convex.Body import Mathlib.Analysis.Convex.Measure import Mathlib.MeasureTheory.Group.FundamentalDomain #align_import measure_theory.group.geometry_of_numbers from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" namespace MeasureTheory open ENNReal FiniteDimensional MeasureTheory MeasureTheory.Measure Set Filter open scoped Pointwise NNReal variable {E L : Type*} [MeasurableSpace E] {μ : Measure E} {F s : Set E} theorem exists_pair_mem_lattice_not_disjoint_vadd [AddCommGroup L] [Countable L] [AddAction L E] [MeasurableSpace L] [MeasurableVAdd L E] [VAddInvariantMeasure L E μ] (fund : IsAddFundamentalDomain L F μ) (hS : NullMeasurableSet s μ) (h : μ F < μ s) : ∃ x y : L, x ≠ y ∧ ¬Disjoint (x +ᵥ s) (y +ᵥ s) := by contrapose! h exact ((fund.measure_eq_tsum _).trans (measure_iUnion₀ (Pairwise.mono h fun i j hij => (hij.mono inf_le_left inf_le_left).aedisjoint) fun _ => (hS.vadd _).inter fund.nullMeasurableSet).symm).trans_le (measure_mono <| Set.iUnion_subset fun _ => Set.inter_subset_right) #align measure_theory.exists_pair_mem_lattice_not_disjoint_vadd MeasureTheory.exists_pair_mem_lattice_not_disjoint_vadd
Mathlib/MeasureTheory/Group/GeometryOfNumbers.lean
64
83
theorem exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure [NormedAddCommGroup E] [NormedSpace ℝ E] [BorelSpace E] [FiniteDimensional ℝ E] [IsAddHaarMeasure μ] {L : AddSubgroup E} [Countable L] (fund : IsAddFundamentalDomain L F μ) (h_symm : ∀ x ∈ s, -x ∈ s) (h_conv : Convex ℝ s) (h : μ F * 2 ^ finrank ℝ E < μ s) : ∃ x ≠ 0, ((x : L) : E) ∈ s := by
have h_vol : μ F < μ ((2⁻¹ : ℝ) • s) := by rw [addHaar_smul_of_nonneg μ (by norm_num : 0 ≤ (2 : ℝ)⁻¹) s, ← mul_lt_mul_right (pow_ne_zero (finrank ℝ E) (two_ne_zero' _)) (pow_ne_top two_ne_top), mul_right_comm, ofReal_pow (by norm_num : 0 ≤ (2 : ℝ)⁻¹), ofReal_inv_of_pos zero_lt_two] norm_num rwa [← mul_pow, ENNReal.inv_mul_cancel two_ne_zero two_ne_top, one_pow, one_mul] obtain ⟨x, y, hxy, h⟩ := exists_pair_mem_lattice_not_disjoint_vadd fund ((h_conv.smul _).nullMeasurableSet _) h_vol obtain ⟨_, ⟨v, hv, rfl⟩, w, hw, hvw⟩ := Set.not_disjoint_iff.mp h refine ⟨x - y, sub_ne_zero.2 hxy, ?_⟩ rw [Set.mem_inv_smul_set_iff₀ (two_ne_zero' ℝ)] at hv hw simp_rw [AddSubgroup.vadd_def, vadd_eq_add, add_comm _ w, ← sub_eq_sub_iff_add_eq_add, ← AddSubgroup.coe_sub] at hvw rw [← hvw, ← inv_smul_smul₀ (two_ne_zero' ℝ) (_ - _), smul_sub, sub_eq_add_neg, smul_add] refine h_conv hw (h_symm _ hv) ?_ ?_ ?_ <;> norm_num
import Mathlib.MeasureTheory.Decomposition.RadonNikodym import Mathlib.MeasureTheory.Measure.Haar.OfBasis import Mathlib.Probability.Independence.Basic #align_import probability.density from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" open scoped Classical MeasureTheory NNReal ENNReal open TopologicalSpace MeasureTheory.Measure noncomputable section namespace MeasureTheory variable {Ω E : Type*} [MeasurableSpace E] class HasPDF {m : MeasurableSpace Ω} (X : Ω → E) (ℙ : Measure Ω) (μ : Measure E := by volume_tac) : Prop where pdf' : AEMeasurable X ℙ ∧ (map X ℙ).HaveLebesgueDecomposition μ ∧ map X ℙ ≪ μ #align measure_theory.has_pdf MeasureTheory.HasPDF def pdf {_ : MeasurableSpace Ω} (X : Ω → E) (ℙ : Measure Ω) (μ : Measure E := by volume_tac) : E → ℝ≥0∞ := (map X ℙ).rnDeriv μ #align measure_theory.pdf MeasureTheory.pdf theorem pdf_def {_ : MeasurableSpace Ω} {ℙ : Measure Ω} {μ : Measure E} {X : Ω → E} : pdf X ℙ μ = (map X ℙ).rnDeriv μ := rfl theorem pdf_of_not_aemeasurable {_ : MeasurableSpace Ω} {ℙ : Measure Ω} {μ : Measure E} {X : Ω → E} (hX : ¬AEMeasurable X ℙ) : pdf X ℙ μ =ᵐ[μ] 0 := by rw [pdf_def, map_of_not_aemeasurable hX] exact rnDeriv_zero μ #align measure_theory.pdf_eq_zero_of_not_measurable MeasureTheory.pdf_of_not_aemeasurable theorem pdf_of_not_haveLebesgueDecomposition {_ : MeasurableSpace Ω} {ℙ : Measure Ω} {μ : Measure E} {X : Ω → E} (h : ¬(map X ℙ).HaveLebesgueDecomposition μ) : pdf X ℙ μ = 0 := rnDeriv_of_not_haveLebesgueDecomposition h theorem aemeasurable_of_pdf_ne_zero {m : MeasurableSpace Ω} {ℙ : Measure Ω} {μ : Measure E} (X : Ω → E) (h : ¬pdf X ℙ μ =ᵐ[μ] 0) : AEMeasurable X ℙ := by contrapose! h exact pdf_of_not_aemeasurable h #align measure_theory.measurable_of_pdf_ne_zero MeasureTheory.aemeasurable_of_pdf_ne_zero theorem hasPDF_of_pdf_ne_zero {m : MeasurableSpace Ω} {ℙ : Measure Ω} {μ : Measure E} {X : Ω → E} (hac : map X ℙ ≪ μ) (hpdf : ¬pdf X ℙ μ =ᵐ[μ] 0) : HasPDF X ℙ μ := by refine ⟨?_, ?_, hac⟩ · exact aemeasurable_of_pdf_ne_zero X hpdf · contrapose! hpdf have := pdf_of_not_haveLebesgueDecomposition hpdf filter_upwards using congrFun this #align measure_theory.has_pdf_of_pdf_ne_zero MeasureTheory.hasPDF_of_pdf_ne_zero @[measurability] theorem measurable_pdf {m : MeasurableSpace Ω} (X : Ω → E) (ℙ : Measure Ω) (μ : Measure E := by volume_tac) : Measurable (pdf X ℙ μ) := by exact measurable_rnDeriv _ _ #align measure_theory.measurable_pdf MeasureTheory.measurable_pdf theorem withDensity_pdf_le_map {_ : MeasurableSpace Ω} (X : Ω → E) (ℙ : Measure Ω) (μ : Measure E := by volume_tac) : μ.withDensity (pdf X ℙ μ) ≤ map X ℙ := withDensity_rnDeriv_le _ _
Mathlib/Probability/Density.lean
177
181
theorem set_lintegral_pdf_le_map {m : MeasurableSpace Ω} (X : Ω → E) (ℙ : Measure Ω) (μ : Measure E := by
volume_tac) (s : Set E) : ∫⁻ x in s, pdf X ℙ μ x ∂μ ≤ map X ℙ s := by apply (withDensity_apply_le _ s).trans exact withDensity_pdf_le_map _ _ _ s
import Mathlib.Topology.Order.LeftRightNhds open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) variable {α β γ : Type*} section OrderTopology variable [TopologicalSpace α] [TopologicalSpace β] [LinearOrder α] [LinearOrder β] [OrderTopology α] [OrderTopology β] theorem IsLUB.frequently_mem {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) : ∃ᶠ x in 𝓝[≤] a, x ∈ s := by rcases hs with ⟨a', ha'⟩ intro h rcases (ha.1 ha').eq_or_lt with (rfl | ha'a) · exact h.self_of_nhdsWithin le_rfl ha' · rcases (mem_nhdsWithin_Iic_iff_exists_Ioc_subset' ha'a).1 h with ⟨b, hba, hb⟩ rcases ha.exists_between hba with ⟨b', hb's, hb'⟩ exact hb hb' hb's #align is_lub.frequently_mem IsLUB.frequently_mem theorem IsLUB.frequently_nhds_mem {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) : ∃ᶠ x in 𝓝 a, x ∈ s := (ha.frequently_mem hs).filter_mono inf_le_left #align is_lub.frequently_nhds_mem IsLUB.frequently_nhds_mem theorem IsGLB.frequently_mem {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) : ∃ᶠ x in 𝓝[≥] a, x ∈ s := IsLUB.frequently_mem (α := αᵒᵈ) ha hs #align is_glb.frequently_mem IsGLB.frequently_mem theorem IsGLB.frequently_nhds_mem {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) : ∃ᶠ x in 𝓝 a, x ∈ s := (ha.frequently_mem hs).filter_mono inf_le_left #align is_glb.frequently_nhds_mem IsGLB.frequently_nhds_mem theorem IsLUB.mem_closure {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) : a ∈ closure s := (ha.frequently_nhds_mem hs).mem_closure #align is_lub.mem_closure IsLUB.mem_closure theorem IsGLB.mem_closure {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) : a ∈ closure s := (ha.frequently_nhds_mem hs).mem_closure #align is_glb.mem_closure IsGLB.mem_closure theorem IsLUB.nhdsWithin_neBot {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) : NeBot (𝓝[s] a) := mem_closure_iff_nhdsWithin_neBot.1 (ha.mem_closure hs) #align is_lub.nhds_within_ne_bot IsLUB.nhdsWithin_neBot theorem IsGLB.nhdsWithin_neBot : ∀ {a : α} {s : Set α}, IsGLB s a → s.Nonempty → NeBot (𝓝[s] a) := IsLUB.nhdsWithin_neBot (α := αᵒᵈ) #align is_glb.nhds_within_ne_bot IsGLB.nhdsWithin_neBot theorem isLUB_of_mem_nhds {s : Set α} {a : α} {f : Filter α} (hsa : a ∈ upperBounds s) (hsf : s ∈ f) [NeBot (f ⊓ 𝓝 a)] : IsLUB s a := ⟨hsa, fun b hb => not_lt.1 fun hba => have : s ∩ { a | b < a } ∈ f ⊓ 𝓝 a := inter_mem_inf hsf (IsOpen.mem_nhds (isOpen_lt' _) hba) let ⟨_x, ⟨hxs, hxb⟩⟩ := Filter.nonempty_of_mem this have : b < b := lt_of_lt_of_le hxb <| hb hxs lt_irrefl b this⟩ #align is_lub_of_mem_nhds isLUB_of_mem_nhds theorem isLUB_of_mem_closure {s : Set α} {a : α} (hsa : a ∈ upperBounds s) (hsf : a ∈ closure s) : IsLUB s a := by rw [mem_closure_iff_clusterPt, ClusterPt, inf_comm] at hsf exact isLUB_of_mem_nhds hsa (mem_principal_self s) #align is_lub_of_mem_closure isLUB_of_mem_closure theorem isGLB_of_mem_nhds : ∀ {s : Set α} {a : α} {f : Filter α}, a ∈ lowerBounds s → s ∈ f → NeBot (f ⊓ 𝓝 a) → IsGLB s a := isLUB_of_mem_nhds (α := αᵒᵈ) #align is_glb_of_mem_nhds isGLB_of_mem_nhds theorem isGLB_of_mem_closure {s : Set α} {a : α} (hsa : a ∈ lowerBounds s) (hsf : a ∈ closure s) : IsGLB s a := isLUB_of_mem_closure (α := αᵒᵈ) hsa hsf #align is_glb_of_mem_closure isGLB_of_mem_closure theorem IsLUB.mem_upperBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) (ha : IsLUB s a) (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ upperBounds (f '' s) := by rintro _ ⟨x, hx, rfl⟩ replace ha := ha.inter_Ici_of_mem hx haveI := ha.nhdsWithin_neBot ⟨x, hx, le_rfl⟩ refine ge_of_tendsto (hb.mono_left (nhdsWithin_mono a (inter_subset_left (t := Ici x)))) ?_ exact mem_of_superset self_mem_nhdsWithin fun y hy => hf hx hy.1 hy.2 #align is_lub.mem_upper_bounds_of_tendsto IsLUB.mem_upperBounds_of_tendsto -- For a version of this theorem in which the convergence considered on the domain `α` is as `x : α` -- tends to infinity, rather than tending to a point `x` in `α`, see `isLUB_of_tendsto_atTop` theorem IsLUB.isLUB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) (ha : IsLUB s a) (hs : s.Nonempty) (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : IsLUB (f '' s) b := haveI := ha.nhdsWithin_neBot hs ⟨ha.mem_upperBounds_of_tendsto hf hb, fun _b' hb' => le_of_tendsto hb (mem_of_superset self_mem_nhdsWithin fun _ hx => hb' <| mem_image_of_mem _ hx)⟩ #align is_lub.is_lub_of_tendsto IsLUB.isLUB_of_tendsto theorem IsGLB.mem_lowerBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) (ha : IsGLB s a) (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ lowerBounds (f '' s) := IsLUB.mem_upperBounds_of_tendsto (α := αᵒᵈ) (γ := γᵒᵈ) hf.dual ha hb #align is_glb.mem_lower_bounds_of_tendsto IsGLB.mem_lowerBounds_of_tendsto -- For a version of this theorem in which the convergence considered on the domain `α` is as -- `x : α` tends to negative infinity, rather than tending to a point `x` in `α`, see -- `isGLB_of_tendsto_atBot` theorem IsGLB.isGLB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) : IsGLB s a → s.Nonempty → Tendsto f (𝓝[s] a) (𝓝 b) → IsGLB (f '' s) b := IsLUB.isLUB_of_tendsto (α := αᵒᵈ) (γ := γᵒᵈ) hf.dual #align is_glb.is_glb_of_tendsto IsGLB.isGLB_of_tendsto theorem IsLUB.mem_lowerBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : AntitoneOn f s) (ha : IsLUB s a) (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ lowerBounds (f '' s) := IsLUB.mem_upperBounds_of_tendsto (γ := γᵒᵈ) hf ha hb #align is_lub.mem_lower_bounds_of_tendsto IsLUB.mem_lowerBounds_of_tendsto theorem IsLUB.isGLB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] : ∀ {f : α → γ} {s : Set α} {a : α} {b : γ}, AntitoneOn f s → IsLUB s a → s.Nonempty → Tendsto f (𝓝[s] a) (𝓝 b) → IsGLB (f '' s) b := IsLUB.isLUB_of_tendsto (γ := γᵒᵈ) #align is_lub.is_glb_of_tendsto IsLUB.isGLB_of_tendsto theorem IsGLB.mem_upperBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : AntitoneOn f s) (ha : IsGLB s a) (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ upperBounds (f '' s) := IsGLB.mem_lowerBounds_of_tendsto (γ := γᵒᵈ) hf ha hb #align is_glb.mem_upper_bounds_of_tendsto IsGLB.mem_upperBounds_of_tendsto theorem IsGLB.isLUB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] : ∀ {f : α → γ} {s : Set α} {a : α} {b : γ}, AntitoneOn f s → IsGLB s a → s.Nonempty → Tendsto f (𝓝[s] a) (𝓝 b) → IsLUB (f '' s) b := IsGLB.isGLB_of_tendsto (γ := γᵒᵈ) #align is_glb.is_lub_of_tendsto IsGLB.isLUB_of_tendsto theorem IsLUB.mem_of_isClosed {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) (sc : IsClosed s) : a ∈ s := sc.closure_subset <| ha.mem_closure hs #align is_lub.mem_of_is_closed IsLUB.mem_of_isClosed alias IsClosed.isLUB_mem := IsLUB.mem_of_isClosed #align is_closed.is_lub_mem IsClosed.isLUB_mem theorem IsGLB.mem_of_isClosed {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) (sc : IsClosed s) : a ∈ s := sc.closure_subset <| ha.mem_closure hs #align is_glb.mem_of_is_closed IsGLB.mem_of_isClosed alias IsClosed.isGLB_mem := IsGLB.mem_of_isClosed #align is_closed.is_glb_mem IsClosed.isGLB_mem theorem IsLUB.exists_seq_strictMono_tendsto_of_not_mem {t : Set α} {x : α} [IsCountablyGenerated (𝓝 x)] (htx : IsLUB t x) (not_mem : x ∉ t) (ht : t.Nonempty) : ∃ u : ℕ → α, StrictMono u ∧ (∀ n, u n < x) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t := by obtain ⟨v, hvx, hvt⟩ := exists_seq_forall_of_frequently (htx.frequently_mem ht) replace hvx := hvx.mono_right nhdsWithin_le_nhds have hvx' : ∀ {n}, v n < x := (htx.1 (hvt _)).lt_of_ne (ne_of_mem_of_not_mem (hvt _) not_mem) have : ∀ k, ∀ᶠ l in atTop, v k < v l := fun k => hvx.eventually (lt_mem_nhds hvx') choose N hN hvN using fun k => ((eventually_gt_atTop k).and (this k)).exists refine ⟨fun k => v (N^[k] 0), strictMono_nat_of_lt_succ fun _ => ?_, fun _ => hvx', hvx.comp (strictMono_nat_of_lt_succ fun _ => ?_).tendsto_atTop, fun _ => hvt _⟩ · rw [iterate_succ_apply']; exact hvN _ · rw [iterate_succ_apply']; exact hN _ #align is_lub.exists_seq_strict_mono_tendsto_of_not_mem IsLUB.exists_seq_strictMono_tendsto_of_not_mem theorem IsLUB.exists_seq_monotone_tendsto {t : Set α} {x : α} [IsCountablyGenerated (𝓝 x)] (htx : IsLUB t x) (ht : t.Nonempty) : ∃ u : ℕ → α, Monotone u ∧ (∀ n, u n ≤ x) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t := by by_cases h : x ∈ t · exact ⟨fun _ => x, monotone_const, fun n => le_rfl, tendsto_const_nhds, fun _ => h⟩ · rcases htx.exists_seq_strictMono_tendsto_of_not_mem h ht with ⟨u, hu⟩ exact ⟨u, hu.1.monotone, fun n => (hu.2.1 n).le, hu.2.2⟩ #align is_lub.exists_seq_monotone_tendsto IsLUB.exists_seq_monotone_tendsto theorem exists_seq_strictMono_tendsto' {α : Type*} [LinearOrder α] [TopologicalSpace α] [DenselyOrdered α] [OrderTopology α] [FirstCountableTopology α] {x y : α} (hy : y < x) : ∃ u : ℕ → α, StrictMono u ∧ (∀ n, u n ∈ Ioo y x) ∧ Tendsto u atTop (𝓝 x) := by have hx : x ∉ Ioo y x := fun h => (lt_irrefl x h.2).elim have ht : Set.Nonempty (Ioo y x) := nonempty_Ioo.2 hy rcases (isLUB_Ioo hy).exists_seq_strictMono_tendsto_of_not_mem hx ht with ⟨u, hu⟩ exact ⟨u, hu.1, hu.2.2.symm⟩ #align exists_seq_strict_mono_tendsto' exists_seq_strictMono_tendsto' theorem exists_seq_strictMono_tendsto [DenselyOrdered α] [NoMinOrder α] [FirstCountableTopology α] (x : α) : ∃ u : ℕ → α, StrictMono u ∧ (∀ n, u n < x) ∧ Tendsto u atTop (𝓝 x) := by obtain ⟨y, hy⟩ : ∃ y, y < x := exists_lt x rcases exists_seq_strictMono_tendsto' hy with ⟨u, hu_mono, hu_mem, hux⟩ exact ⟨u, hu_mono, fun n => (hu_mem n).2, hux⟩ #align exists_seq_strict_mono_tendsto exists_seq_strictMono_tendsto theorem exists_seq_strictMono_tendsto_nhdsWithin [DenselyOrdered α] [NoMinOrder α] [FirstCountableTopology α] (x : α) : ∃ u : ℕ → α, StrictMono u ∧ (∀ n, u n < x) ∧ Tendsto u atTop (𝓝[<] x) := let ⟨u, hu, hx, h⟩ := exists_seq_strictMono_tendsto x ⟨u, hu, hx, tendsto_nhdsWithin_mono_right (range_subset_iff.2 hx) <| tendsto_nhdsWithin_range.2 h⟩ #align exists_seq_strict_mono_tendsto_nhds_within exists_seq_strictMono_tendsto_nhdsWithin theorem exists_seq_tendsto_sSup {α : Type*} [ConditionallyCompleteLinearOrder α] [TopologicalSpace α] [OrderTopology α] [FirstCountableTopology α] {S : Set α} (hS : S.Nonempty) (hS' : BddAbove S) : ∃ u : ℕ → α, Monotone u ∧ Tendsto u atTop (𝓝 (sSup S)) ∧ ∀ n, u n ∈ S := by rcases (isLUB_csSup hS hS').exists_seq_monotone_tendsto hS with ⟨u, hu⟩ exact ⟨u, hu.1, hu.2.2⟩ #align exists_seq_tendsto_Sup exists_seq_tendsto_sSup theorem IsGLB.exists_seq_strictAnti_tendsto_of_not_mem {t : Set α} {x : α} [IsCountablyGenerated (𝓝 x)] (htx : IsGLB t x) (not_mem : x ∉ t) (ht : t.Nonempty) : ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, x < u n) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t := IsLUB.exists_seq_strictMono_tendsto_of_not_mem (α := αᵒᵈ) htx not_mem ht #align is_glb.exists_seq_strict_anti_tendsto_of_not_mem IsGLB.exists_seq_strictAnti_tendsto_of_not_mem theorem IsGLB.exists_seq_antitone_tendsto {t : Set α} {x : α} [IsCountablyGenerated (𝓝 x)] (htx : IsGLB t x) (ht : t.Nonempty) : ∃ u : ℕ → α, Antitone u ∧ (∀ n, x ≤ u n) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t := IsLUB.exists_seq_monotone_tendsto (α := αᵒᵈ) htx ht #align is_glb.exists_seq_antitone_tendsto IsGLB.exists_seq_antitone_tendsto
Mathlib/Topology/Order/IsLUB.lean
237
240
theorem exists_seq_strictAnti_tendsto' [DenselyOrdered α] [FirstCountableTopology α] {x y : α} (hy : x < y) : ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, u n ∈ Ioo x y) ∧ Tendsto u atTop (𝓝 x) := by
simpa only [dual_Ioo] using exists_seq_strictMono_tendsto' (α := αᵒᵈ) (OrderDual.toDual_lt_toDual.2 hy)
import Mathlib.Data.Fintype.List #align_import data.list.cycle from "leanprover-community/mathlib"@"7413128c3bcb3b0818e3e18720abc9ea3100fb49" assert_not_exists MonoidWithZero namespace List variable {α : Type*} [DecidableEq α] def nextOr : ∀ (_ : List α) (_ _ : α), α | [], _, default => default | [_], _, default => default -- Handles the not-found and the wraparound case | y :: z :: xs, x, default => if x = y then z else nextOr (z :: xs) x default #align list.next_or List.nextOr @[simp] theorem nextOr_nil (x d : α) : nextOr [] x d = d := rfl #align list.next_or_nil List.nextOr_nil @[simp] theorem nextOr_singleton (x y d : α) : nextOr [y] x d = d := rfl #align list.next_or_singleton List.nextOr_singleton @[simp] theorem nextOr_self_cons_cons (xs : List α) (x y d : α) : nextOr (x :: y :: xs) x d = y := if_pos rfl #align list.next_or_self_cons_cons List.nextOr_self_cons_cons theorem nextOr_cons_of_ne (xs : List α) (y x d : α) (h : x ≠ y) : nextOr (y :: xs) x d = nextOr xs x d := by cases' xs with z zs · rfl · exact if_neg h #align list.next_or_cons_of_ne List.nextOr_cons_of_ne theorem nextOr_eq_nextOr_of_mem_of_ne (xs : List α) (x d d' : α) (x_mem : x ∈ xs) (x_ne : x ≠ xs.getLast (ne_nil_of_mem x_mem)) : nextOr xs x d = nextOr xs x d' := by induction' xs with y ys IH · cases x_mem cases' ys with z zs · simp at x_mem x_ne contradiction by_cases h : x = y · rw [h, nextOr_self_cons_cons, nextOr_self_cons_cons] · rw [nextOr, nextOr, IH] · simpa [h] using x_mem · simpa using x_ne #align list.next_or_eq_next_or_of_mem_of_ne List.nextOr_eq_nextOr_of_mem_of_ne theorem mem_of_nextOr_ne {xs : List α} {x d : α} (h : nextOr xs x d ≠ d) : x ∈ xs := by induction' xs with y ys IH · simp at h cases' ys with z zs · simp at h · by_cases hx : x = y · simp [hx] · rw [nextOr_cons_of_ne _ _ _ _ hx] at h simpa [hx] using IH h #align list.mem_of_next_or_ne List.mem_of_nextOr_ne theorem nextOr_concat {xs : List α} {x : α} (d : α) (h : x ∉ xs) : nextOr (xs ++ [x]) x d = d := by induction' xs with z zs IH · simp · obtain ⟨hz, hzs⟩ := not_or.mp (mt mem_cons.2 h) rw [cons_append, nextOr_cons_of_ne _ _ _ _ hz, IH hzs] #align list.next_or_concat List.nextOr_concat theorem nextOr_mem {xs : List α} {x d : α} (hd : d ∈ xs) : nextOr xs x d ∈ xs := by revert hd suffices ∀ xs' : List α, (∀ x ∈ xs, x ∈ xs') → d ∈ xs' → nextOr xs x d ∈ xs' by exact this xs fun _ => id intro xs' hxs' hd induction' xs with y ys ih · exact hd cases' ys with z zs · exact hd rw [nextOr] split_ifs with h · exact hxs' _ (mem_cons_of_mem _ (mem_cons_self _ _)) · exact ih fun _ h => hxs' _ (mem_cons_of_mem _ h) #align list.next_or_mem List.nextOr_mem def next (l : List α) (x : α) (h : x ∈ l) : α := nextOr l x (l.get ⟨0, length_pos_of_mem h⟩) #align list.next List.next def prev : ∀ l : List α, ∀ x ∈ l, α | [], _, h => by simp at h | [y], _, _ => y | y :: z :: xs, x, h => if hx : x = y then getLast (z :: xs) (cons_ne_nil _ _) else if x = z then y else prev (z :: xs) x (by simpa [hx] using h) #align list.prev List.prev variable (l : List α) (x : α) @[simp] theorem next_singleton (x y : α) (h : x ∈ [y]) : next [y] x h = y := rfl #align list.next_singleton List.next_singleton @[simp] theorem prev_singleton (x y : α) (h : x ∈ [y]) : prev [y] x h = y := rfl #align list.prev_singleton List.prev_singleton theorem next_cons_cons_eq' (y z : α) (h : x ∈ y :: z :: l) (hx : x = y) : next (y :: z :: l) x h = z := by rw [next, nextOr, if_pos hx] #align list.next_cons_cons_eq' List.next_cons_cons_eq' @[simp] theorem next_cons_cons_eq (z : α) (h : x ∈ x :: z :: l) : next (x :: z :: l) x h = z := next_cons_cons_eq' l x x z h rfl #align list.next_cons_cons_eq List.next_cons_cons_eq theorem next_ne_head_ne_getLast (h : x ∈ l) (y : α) (h : x ∈ y :: l) (hy : x ≠ y) (hx : x ≠ getLast (y :: l) (cons_ne_nil _ _)) : next (y :: l) x h = next l x (by simpa [hy] using h) := by rw [next, next, nextOr_cons_of_ne _ _ _ _ hy, nextOr_eq_nextOr_of_mem_of_ne] · rwa [getLast_cons] at hx exact ne_nil_of_mem (by assumption) · rwa [getLast_cons] at hx #align list.next_ne_head_ne_last List.next_ne_head_ne_getLast theorem next_cons_concat (y : α) (hy : x ≠ y) (hx : x ∉ l) (h : x ∈ y :: l ++ [x] := mem_append_right _ (mem_singleton_self x)) : next (y :: l ++ [x]) x h = y := by rw [next, nextOr_concat] · rfl · simp [hy, hx] #align list.next_cons_concat List.next_cons_concat theorem next_getLast_cons (h : x ∈ l) (y : α) (h : x ∈ y :: l) (hy : x ≠ y) (hx : x = getLast (y :: l) (cons_ne_nil _ _)) (hl : Nodup l) : next (y :: l) x h = y := by rw [next, get, ← dropLast_append_getLast (cons_ne_nil y l), hx, nextOr_concat] subst hx intro H obtain ⟨⟨_ | k, hk⟩, hk'⟩ := get_of_mem H · rw [← Option.some_inj] at hk' rw [← get?_eq_get, dropLast_eq_take, get?_take, get?_zero, head?_cons, Option.some_inj] at hk' · exact hy (Eq.symm hk') rw [length_cons, Nat.pred_succ] exact length_pos_of_mem (by assumption) suffices k + 1 = l.length by simp [this] at hk cases' l with hd tl · simp at hk · rw [nodup_iff_injective_get] at hl rw [length, Nat.succ_inj'] refine Fin.val_eq_of_eq <| @hl ⟨k, Nat.lt_of_succ_lt <| by simpa using hk⟩ ⟨tl.length, by simp⟩ ?_ rw [← Option.some_inj] at hk' rw [← get?_eq_get, dropLast_eq_take, get?_take, get?, get?_eq_get, Option.some_inj] at hk' · rw [hk'] simp only [getLast_eq_get, length_cons, ge_iff_le, Nat.succ_sub_succ_eq_sub, nonpos_iff_eq_zero, add_eq_zero_iff, and_false, Nat.sub_zero, get_cons_succ] simpa using hk #align list.next_last_cons List.next_getLast_cons theorem prev_getLast_cons' (y : α) (hxy : x ∈ y :: l) (hx : x = y) : prev (y :: l) x hxy = getLast (y :: l) (cons_ne_nil _ _) := by cases l <;> simp [prev, hx] #align list.prev_last_cons' List.prev_getLast_cons' @[simp] theorem prev_getLast_cons (h : x ∈ x :: l) : prev (x :: l) x h = getLast (x :: l) (cons_ne_nil _ _) := prev_getLast_cons' l x x h rfl #align list.prev_last_cons List.prev_getLast_cons theorem prev_cons_cons_eq' (y z : α) (h : x ∈ y :: z :: l) (hx : x = y) : prev (y :: z :: l) x h = getLast (z :: l) (cons_ne_nil _ _) := by rw [prev, dif_pos hx] #align list.prev_cons_cons_eq' List.prev_cons_cons_eq' --@[simp] Porting note (#10618): `simp` can prove it theorem prev_cons_cons_eq (z : α) (h : x ∈ x :: z :: l) : prev (x :: z :: l) x h = getLast (z :: l) (cons_ne_nil _ _) := prev_cons_cons_eq' l x x z h rfl #align list.prev_cons_cons_eq List.prev_cons_cons_eq theorem prev_cons_cons_of_ne' (y z : α) (h : x ∈ y :: z :: l) (hy : x ≠ y) (hz : x = z) : prev (y :: z :: l) x h = y := by cases l · simp [prev, hy, hz] · rw [prev, dif_neg hy, if_pos hz] #align list.prev_cons_cons_of_ne' List.prev_cons_cons_of_ne' theorem prev_cons_cons_of_ne (y : α) (h : x ∈ y :: x :: l) (hy : x ≠ y) : prev (y :: x :: l) x h = y := prev_cons_cons_of_ne' _ _ _ _ _ hy rfl #align list.prev_cons_cons_of_ne List.prev_cons_cons_of_ne theorem prev_ne_cons_cons (y z : α) (h : x ∈ y :: z :: l) (hy : x ≠ y) (hz : x ≠ z) : prev (y :: z :: l) x h = prev (z :: l) x (by simpa [hy] using h) := by cases l · simp [hy, hz] at h · rw [prev, dif_neg hy, if_neg hz] #align list.prev_ne_cons_cons List.prev_ne_cons_cons theorem next_mem (h : x ∈ l) : l.next x h ∈ l := nextOr_mem (get_mem _ _ _) #align list.next_mem List.next_mem theorem prev_mem (h : x ∈ l) : l.prev x h ∈ l := by cases' l with hd tl · simp at h induction' tl with hd' tl hl generalizing hd · simp · by_cases hx : x = hd · simp only [hx, prev_cons_cons_eq] exact mem_cons_of_mem _ (getLast_mem _) · rw [prev, dif_neg hx] split_ifs with hm · exact mem_cons_self _ _ · exact mem_cons_of_mem _ (hl _ _) #align list.prev_mem List.prev_mem -- Porting note (#10756): new theorem theorem next_get : ∀ (l : List α) (_h : Nodup l) (i : Fin l.length), next l (l.get i) (get_mem _ _ _) = l.get ⟨(i + 1) % l.length, Nat.mod_lt _ (i.1.zero_le.trans_lt i.2)⟩ | [], _, i => by simpa using i.2 | [_], _, _ => by simp | x::y::l, _h, ⟨0, h0⟩ => by have h₁ : get (x :: y :: l) { val := 0, isLt := h0 } = x := by simp rw [next_cons_cons_eq' _ _ _ _ _ h₁] simp | x::y::l, hn, ⟨i+1, hi⟩ => by have hx' : (x :: y :: l).get ⟨i+1, hi⟩ ≠ x := by intro H suffices (i + 1 : ℕ) = 0 by simpa rw [nodup_iff_injective_get] at hn refine Fin.val_eq_of_eq (@hn ⟨i + 1, hi⟩ ⟨0, by simp⟩ ?_) simpa using H have hi' : i ≤ l.length := Nat.le_of_lt_succ (Nat.succ_lt_succ_iff.1 hi) rcases hi'.eq_or_lt with (hi' | hi') · subst hi' rw [next_getLast_cons] · simp [hi', get] · rw [get_cons_succ]; exact get_mem _ _ _ · exact hx' · simp [getLast_eq_get] · exact hn.of_cons · rw [next_ne_head_ne_getLast _ _ _ _ _ hx'] · simp only [get_cons_succ] rw [next_get (y::l), ← get_cons_succ (a := x)] · congr dsimp rw [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'), Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 (Nat.succ_lt_succ_iff.2 hi'))] · simp [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'), Nat.succ_eq_add_one, hi'] · exact hn.of_cons · rw [getLast_eq_get] intro h have := nodup_iff_injective_get.1 hn h simp at this; simp [this] at hi' · rw [get_cons_succ]; exact get_mem _ _ _ set_option linter.deprecated false in @[deprecated next_get (since := "2023-01-27")] theorem next_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) : next l (l.nthLe n hn) (nthLe_mem _ _ _) = l.nthLe ((n + 1) % l.length) (Nat.mod_lt _ (n.zero_le.trans_lt hn)) := next_get l h ⟨n, hn⟩ #align list.next_nth_le List.next_nthLe set_option linter.deprecated false in theorem prev_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) : prev l (l.nthLe n hn) (nthLe_mem _ _ _) = l.nthLe ((n + (l.length - 1)) % l.length) (Nat.mod_lt _ (n.zero_le.trans_lt hn)) := by cases' l with x l · simp at hn induction' l with y l hl generalizing n x · simp · rcases n with (_ | _ | n) · simp [Nat.add_succ_sub_one, add_zero, List.prev_cons_cons_eq, Nat.zero_eq, List.length, List.nthLe, Nat.succ_add_sub_one, zero_add, getLast_eq_get, Nat.mod_eq_of_lt (Nat.succ_lt_succ l.length.lt_succ_self)] · simp only [mem_cons, nodup_cons] at h push_neg at h simp only [List.prev_cons_cons_of_ne _ _ _ _ h.left.left.symm, Nat.zero_eq, List.length, List.nthLe, add_comm, eq_self_iff_true, Nat.succ_add_sub_one, Nat.mod_self, zero_add, List.get] · rw [prev_ne_cons_cons] · convert hl n.succ y h.of_cons (Nat.le_of_succ_le_succ hn) using 1 have : ∀ k hk, (y :: l).nthLe k hk = (x :: y :: l).nthLe (k + 1) (Nat.succ_lt_succ hk) := by intros simp [List.nthLe] rw [this] congr simp only [Nat.add_succ_sub_one, add_zero, length] simp only [length, Nat.succ_lt_succ_iff] at hn set k := l.length rw [Nat.succ_add, ← Nat.add_succ, Nat.add_mod_right, Nat.succ_add, ← Nat.add_succ _ k, Nat.add_mod_right, Nat.mod_eq_of_lt, Nat.mod_eq_of_lt] · exact Nat.lt_succ_of_lt hn · exact Nat.succ_lt_succ (Nat.lt_succ_of_lt hn) · intro H suffices n.succ.succ = 0 by simpa rw [nodup_iff_nthLe_inj] at h refine h _ _ hn Nat.succ_pos' ?_ simpa using H · intro H suffices n.succ.succ = 1 by simpa rw [nodup_iff_nthLe_inj] at h refine h _ _ hn (Nat.succ_lt_succ Nat.succ_pos') ?_ simpa using H #align list.prev_nth_le List.prev_nthLe set_option linter.deprecated false in theorem pmap_next_eq_rotate_one (h : Nodup l) : (l.pmap l.next fun _ h => h) = l.rotate 1 := by apply List.ext_nthLe · simp · intros rw [nthLe_pmap, nthLe_rotate, next_nthLe _ h] #align list.pmap_next_eq_rotate_one List.pmap_next_eq_rotate_one set_option linter.deprecated false in theorem pmap_prev_eq_rotate_length_sub_one (h : Nodup l) : (l.pmap l.prev fun _ h => h) = l.rotate (l.length - 1) := by apply List.ext_nthLe · simp · intro n hn hn' rw [nthLe_rotate, nthLe_pmap, prev_nthLe _ h] #align list.pmap_prev_eq_rotate_length_sub_one List.pmap_prev_eq_rotate_length_sub_one set_option linter.deprecated false in theorem prev_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) : prev l (next l x hx) (next_mem _ _ _) = x := by obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod] cases' l with hd tl · simp at hx · have : (n + 1 + length tl) % (length tl + 1) = n := by rw [length_cons, Nat.succ_eq_add_one] at hn rw [add_assoc, add_comm 1, Nat.add_mod_right, Nat.mod_eq_of_lt hn] simp only [length_cons, Nat.succ_sub_succ_eq_sub, Nat.sub_zero, Nat.succ_eq_add_one, this] #align list.prev_next List.prev_next set_option linter.deprecated false in theorem next_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) : next l (prev l x hx) (prev_mem _ _ _) = x := by obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod] cases' l with hd tl · simp at hx · have : (n + length tl + 1) % (length tl + 1) = n := by rw [length_cons, Nat.succ_eq_add_one] at hn rw [add_assoc, Nat.add_mod_right, Nat.mod_eq_of_lt hn] simp [this] #align list.next_prev List.next_prev set_option linter.deprecated false in
Mathlib/Data/List/Cycle.lean
400
414
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) : prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx have lpos : 0 < l.length := k.zero_le.trans_lt hk have key : l.length - 1 - k < l.length := by omega rw [← nthLe_pmap l.next (fun _ h => h) (by simpa using hk)] simp_rw [← nthLe_reverse l k (key.trans_le (by simp)), pmap_next_eq_rotate_one _ h] rw [← nthLe_pmap l.reverse.prev fun _ h => h] · simp_rw [pmap_prev_eq_rotate_length_sub_one _ (nodup_reverse.mpr h), rotate_reverse, length_reverse, Nat.mod_eq_of_lt (Nat.sub_lt lpos Nat.succ_pos'), Nat.sub_sub_self (Nat.succ_le_of_lt lpos)] rw [← nthLe_reverse] · simp [Nat.sub_sub_self (Nat.le_sub_one_of_lt hk)] · simpa using (Nat.sub_le _ _).trans_lt (Nat.sub_lt lpos Nat.succ_pos') · simpa
import Mathlib.AlgebraicTopology.DoldKan.GammaCompN import Mathlib.AlgebraicTopology.DoldKan.NReflectsIso #align_import algebraic_topology.dold_kan.n_comp_gamma from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504" noncomputable section open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Idempotents SimplexCategory Opposite SimplicialObject Simplicial DoldKan namespace AlgebraicTopology namespace DoldKan variable {C : Type*} [Category C] [Preadditive C] theorem PInfty_comp_map_mono_eq_zero (X : SimplicialObject C) {n : ℕ} {Δ' : SimplexCategory} (i : Δ' ⟶ [n]) [hi : Mono i] (h₁ : Δ'.len ≠ n) (h₂ : ¬Isδ₀ i) : PInfty.f n ≫ X.map i.op = 0 := by induction' Δ' using SimplexCategory.rec with m obtain ⟨k, hk⟩ := Nat.exists_eq_add_of_lt (len_lt_of_mono i fun h => by rw [← h] at h₁ exact h₁ rfl) simp only [len_mk] at hk rcases k with _|k · change n = m + 1 at hk subst hk obtain ⟨j, rfl⟩ := eq_δ_of_mono i rw [Isδ₀.iff] at h₂ have h₃ : 1 ≤ (j : ℕ) := by by_contra h exact h₂ (by simpa only [Fin.ext_iff, not_le, Nat.lt_one_iff] using h) exact (HigherFacesVanish.of_P (m + 1) m).comp_δ_eq_zero j h₂ (by omega) · simp only [Nat.succ_eq_add_one, ← add_assoc] at hk clear h₂ hi subst hk obtain ⟨j₁ : Fin (_ + 1), i, rfl⟩ := eq_comp_δ_of_not_surjective i fun h => by have h' := len_le_of_epi (SimplexCategory.epi_iff_surjective.2 h) dsimp at h' omega obtain ⟨j₂, i, rfl⟩ := eq_comp_δ_of_not_surjective i fun h => by have h' := len_le_of_epi (SimplexCategory.epi_iff_surjective.2 h) dsimp at h' omega by_cases hj₁ : j₁ = 0 · subst hj₁ rw [assoc, ← SimplexCategory.δ_comp_δ'' (Fin.zero_le _)] simp only [op_comp, X.map_comp, assoc, PInfty_f] erw [(HigherFacesVanish.of_P _ _).comp_δ_eq_zero_assoc _ j₂.succ_ne_zero, zero_comp] simp only [Nat.succ_eq_add_one, Nat.add, Fin.succ] omega · simp only [op_comp, X.map_comp, assoc, PInfty_f] erw [(HigherFacesVanish.of_P _ _).comp_δ_eq_zero_assoc _ hj₁, zero_comp] by_contra exact hj₁ (by simp only [Fin.ext_iff, Fin.val_zero]; linarith) set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.P_infty_comp_map_mono_eq_zero AlgebraicTopology.DoldKan.PInfty_comp_map_mono_eq_zero @[reassoc]
Mathlib/AlgebraicTopology/DoldKan/NCompGamma.lean
83
124
theorem Γ₀_obj_termwise_mapMono_comp_PInfty (X : SimplicialObject C) {Δ Δ' : SimplexCategory} (i : Δ ⟶ Δ') [Mono i] : Γ₀.Obj.Termwise.mapMono (AlternatingFaceMapComplex.obj X) i ≫ PInfty.f Δ.len = PInfty.f Δ'.len ≫ X.map i.op := by
induction' Δ using SimplexCategory.rec with n induction' Δ' using SimplexCategory.rec with n' dsimp -- We start with the case `i` is an identity by_cases h : n = n' · subst h simp only [SimplexCategory.eq_id_of_mono i, Γ₀.Obj.Termwise.mapMono_id, op_id, X.map_id] dsimp simp only [id_comp, comp_id] by_cases hi : Isδ₀ i -- The case `i = δ 0` · have h' : n' = n + 1 := hi.left subst h' simp only [Γ₀.Obj.Termwise.mapMono_δ₀' _ i hi] dsimp rw [← PInfty.comm _ n, AlternatingFaceMapComplex.obj_d_eq] simp only [eq_self_iff_true, id_comp, if_true, Preadditive.comp_sum] rw [Finset.sum_eq_single (0 : Fin (n + 2))] rotate_left · intro b _ hb rw [Preadditive.comp_zsmul] erw [PInfty_comp_map_mono_eq_zero X (SimplexCategory.δ b) h (by rw [Isδ₀.iff] exact hb), zsmul_zero] · simp only [Finset.mem_univ, not_true, IsEmpty.forall_iff] · simp only [hi.eq_δ₀, Fin.val_zero, pow_zero, one_zsmul] rfl -- The case `i ≠ δ 0` · rw [Γ₀.Obj.Termwise.mapMono_eq_zero _ i _ hi, zero_comp] swap · by_contra h' exact h (congr_arg SimplexCategory.len h'.symm) rw [PInfty_comp_map_mono_eq_zero] · exact h · by_contra h' exact hi h'
import Mathlib.Algebra.GeomSum import Mathlib.Order.Filter.Archimedean import Mathlib.Order.Iterate import Mathlib.Topology.Algebra.Algebra import Mathlib.Topology.Algebra.InfiniteSum.Real #align_import analysis.specific_limits.basic from "leanprover-community/mathlib"@"57ac39bd365c2f80589a700f9fbb664d3a1a30c2" noncomputable section open scoped Classical open Set Function Filter Finset Metric open scoped Classical open Topology Nat uniformity NNReal ENNReal variable {α : Type*} {β : Type*} {ι : Type*} theorem tendsto_inverse_atTop_nhds_zero_nat : Tendsto (fun n : ℕ ↦ (n : ℝ)⁻¹) atTop (𝓝 0) := tendsto_inv_atTop_zero.comp tendsto_natCast_atTop_atTop #align tendsto_inverse_at_top_nhds_0_nat tendsto_inverse_atTop_nhds_zero_nat @[deprecated (since := "2024-01-31")] alias tendsto_inverse_atTop_nhds_0_nat := tendsto_inverse_atTop_nhds_zero_nat theorem tendsto_const_div_atTop_nhds_zero_nat (C : ℝ) : Tendsto (fun n : ℕ ↦ C / n) atTop (𝓝 0) := by simpa only [mul_zero] using tendsto_const_nhds.mul tendsto_inverse_atTop_nhds_zero_nat #align tendsto_const_div_at_top_nhds_0_nat tendsto_const_div_atTop_nhds_zero_nat @[deprecated (since := "2024-01-31")] alias tendsto_const_div_atTop_nhds_0_nat := tendsto_const_div_atTop_nhds_zero_nat theorem tendsto_one_div_atTop_nhds_zero_nat : Tendsto (fun n : ℕ ↦ 1/(n : ℝ)) atTop (𝓝 0) := tendsto_const_div_atTop_nhds_zero_nat 1 @[deprecated (since := "2024-01-31")] alias tendsto_one_div_atTop_nhds_0_nat := tendsto_one_div_atTop_nhds_zero_nat theorem NNReal.tendsto_inverse_atTop_nhds_zero_nat : Tendsto (fun n : ℕ ↦ (n : ℝ≥0)⁻¹) atTop (𝓝 0) := by rw [← NNReal.tendsto_coe] exact _root_.tendsto_inverse_atTop_nhds_zero_nat #align nnreal.tendsto_inverse_at_top_nhds_0_nat NNReal.tendsto_inverse_atTop_nhds_zero_nat @[deprecated (since := "2024-01-31")] alias NNReal.tendsto_inverse_atTop_nhds_0_nat := NNReal.tendsto_inverse_atTop_nhds_zero_nat theorem NNReal.tendsto_const_div_atTop_nhds_zero_nat (C : ℝ≥0) : Tendsto (fun n : ℕ ↦ C / n) atTop (𝓝 0) := by simpa using tendsto_const_nhds.mul NNReal.tendsto_inverse_atTop_nhds_zero_nat #align nnreal.tendsto_const_div_at_top_nhds_0_nat NNReal.tendsto_const_div_atTop_nhds_zero_nat @[deprecated (since := "2024-01-31")] alias NNReal.tendsto_const_div_atTop_nhds_0_nat := NNReal.tendsto_const_div_atTop_nhds_zero_nat theorem tendsto_one_div_add_atTop_nhds_zero_nat : Tendsto (fun n : ℕ ↦ 1 / ((n : ℝ) + 1)) atTop (𝓝 0) := suffices Tendsto (fun n : ℕ ↦ 1 / (↑(n + 1) : ℝ)) atTop (𝓝 0) by simpa (tendsto_add_atTop_iff_nat 1).2 (_root_.tendsto_const_div_atTop_nhds_zero_nat 1) #align tendsto_one_div_add_at_top_nhds_0_nat tendsto_one_div_add_atTop_nhds_zero_nat @[deprecated (since := "2024-01-31")] alias tendsto_one_div_add_atTop_nhds_0_nat := tendsto_one_div_add_atTop_nhds_zero_nat theorem NNReal.tendsto_algebraMap_inverse_atTop_nhds_zero_nat (𝕜 : Type*) [Semiring 𝕜] [Algebra ℝ≥0 𝕜] [TopologicalSpace 𝕜] [ContinuousSMul ℝ≥0 𝕜] : Tendsto (algebraMap ℝ≥0 𝕜 ∘ fun n : ℕ ↦ (n : ℝ≥0)⁻¹) atTop (𝓝 0) := by convert (continuous_algebraMap ℝ≥0 𝕜).continuousAt.tendsto.comp tendsto_inverse_atTop_nhds_zero_nat rw [map_zero] @[deprecated (since := "2024-01-31")] alias NNReal.tendsto_algebraMap_inverse_atTop_nhds_0_nat := NNReal.tendsto_algebraMap_inverse_atTop_nhds_zero_nat theorem tendsto_algebraMap_inverse_atTop_nhds_zero_nat (𝕜 : Type*) [Semiring 𝕜] [Algebra ℝ 𝕜] [TopologicalSpace 𝕜] [ContinuousSMul ℝ 𝕜] : Tendsto (algebraMap ℝ 𝕜 ∘ fun n : ℕ ↦ (n : ℝ)⁻¹) atTop (𝓝 0) := NNReal.tendsto_algebraMap_inverse_atTop_nhds_zero_nat 𝕜 @[deprecated (since := "2024-01-31")] alias tendsto_algebraMap_inverse_atTop_nhds_0_nat := _root_.tendsto_algebraMap_inverse_atTop_nhds_zero_nat
Mathlib/Analysis/SpecificLimits/Basic.lean
97
113
theorem tendsto_natCast_div_add_atTop {𝕜 : Type*} [DivisionRing 𝕜] [TopologicalSpace 𝕜] [CharZero 𝕜] [Algebra ℝ 𝕜] [ContinuousSMul ℝ 𝕜] [TopologicalDivisionRing 𝕜] (x : 𝕜) : Tendsto (fun n : ℕ ↦ (n : 𝕜) / (n + x)) atTop (𝓝 1) := by
convert Tendsto.congr' ((eventually_ne_atTop 0).mp (eventually_of_forall fun n hn ↦ _)) _ · exact fun n : ℕ ↦ 1 / (1 + x / n) · field_simp [Nat.cast_ne_zero.mpr hn] · have : 𝓝 (1 : 𝕜) = 𝓝 (1 / (1 + x * (0 : 𝕜))) := by rw [mul_zero, add_zero, div_one] rw [this] refine tendsto_const_nhds.div (tendsto_const_nhds.add ?_) (by simp) simp_rw [div_eq_mul_inv] refine tendsto_const_nhds.mul ?_ have := ((continuous_algebraMap ℝ 𝕜).tendsto _).comp tendsto_inverse_atTop_nhds_zero_nat rw [map_zero, Filter.tendsto_atTop'] at this refine Iff.mpr tendsto_atTop' ?_ intros simp_all only [comp_apply, map_inv₀, map_natCast]
import Mathlib.Order.SuccPred.LinearLocallyFinite import Mathlib.Probability.Martingale.Basic #align_import probability.martingale.optional_sampling from "leanprover-community/mathlib"@"ba074af83b6cf54c3104e59402b39410ddbd6dca" open scoped MeasureTheory ENNReal open TopologicalSpace namespace MeasureTheory namespace Martingale variable {Ω E : Type*} {m : MeasurableSpace Ω} {μ : Measure Ω} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] section FirstCountableTopology variable {ι : Type*} [LinearOrder ι] [TopologicalSpace ι] [OrderTopology ι] [FirstCountableTopology ι] {ℱ : Filtration ι m} [SigmaFiniteFiltration μ ℱ] {τ σ : Ω → ι} {f : ι → Ω → E} {i n : ι} theorem condexp_stopping_time_ae_eq_restrict_eq_const [(Filter.atTop : Filter ι).IsCountablyGenerated] (h : Martingale f ℱ μ) (hτ : IsStoppingTime ℱ τ) [SigmaFinite (μ.trim hτ.measurableSpace_le)] (hin : i ≤ n) : μ[f n|hτ.measurableSpace] =ᵐ[μ.restrict {x | τ x = i}] f i := by refine Filter.EventuallyEq.trans ?_ (ae_restrict_of_ae (h.condexp_ae_eq hin)) refine condexp_ae_eq_restrict_of_measurableSpace_eq_on hτ.measurableSpace_le (ℱ.le i) (hτ.measurableSet_eq' i) fun t => ?_ rw [Set.inter_comm _ t, IsStoppingTime.measurableSet_inter_eq_iff] #align measure_theory.martingale.condexp_stopping_time_ae_eq_restrict_eq_const MeasureTheory.Martingale.condexp_stopping_time_ae_eq_restrict_eq_const theorem condexp_stopping_time_ae_eq_restrict_eq_const_of_le_const (h : Martingale f ℱ μ) (hτ : IsStoppingTime ℱ τ) (hτ_le : ∀ x, τ x ≤ n) [SigmaFinite (μ.trim (hτ.measurableSpace_le_of_le hτ_le))] (i : ι) : μ[f n|hτ.measurableSpace] =ᵐ[μ.restrict {x | τ x = i}] f i := by by_cases hin : i ≤ n · refine Filter.EventuallyEq.trans ?_ (ae_restrict_of_ae (h.condexp_ae_eq hin)) refine condexp_ae_eq_restrict_of_measurableSpace_eq_on (hτ.measurableSpace_le_of_le hτ_le) (ℱ.le i) (hτ.measurableSet_eq' i) fun t => ?_ rw [Set.inter_comm _ t, IsStoppingTime.measurableSet_inter_eq_iff] · suffices {x : Ω | τ x = i} = ∅ by simp [this]; norm_cast ext1 x simp only [Set.mem_setOf_eq, Set.mem_empty_iff_false, iff_false_iff] rintro rfl exact hin (hτ_le x) #align measure_theory.martingale.condexp_stopping_time_ae_eq_restrict_eq_const_of_le_const MeasureTheory.Martingale.condexp_stopping_time_ae_eq_restrict_eq_const_of_le_const
Mathlib/Probability/Martingale/OptionalSampling.lean
77
85
theorem stoppedValue_ae_eq_restrict_eq (h : Martingale f ℱ μ) (hτ : IsStoppingTime ℱ τ) (hτ_le : ∀ x, τ x ≤ n) [SigmaFinite (μ.trim (hτ.measurableSpace_le_of_le hτ_le))] (i : ι) : stoppedValue f τ =ᵐ[μ.restrict {x | τ x = i}] μ[f n|hτ.measurableSpace] := by
refine Filter.EventuallyEq.trans ?_ (condexp_stopping_time_ae_eq_restrict_eq_const_of_le_const h hτ hτ_le i).symm rw [Filter.EventuallyEq, ae_restrict_iff' (ℱ.le _ _ (hτ.measurableSet_eq i))] refine Filter.eventually_of_forall fun x hx => ?_ rw [Set.mem_setOf_eq] at hx simp_rw [stoppedValue, hx]
import Mathlib.GroupTheory.Perm.Cycle.Type import Mathlib.GroupTheory.Perm.Option import Mathlib.Logic.Equiv.Fin import Mathlib.Logic.Equiv.Fintype #align_import group_theory.perm.fin from "leanprover-community/mathlib"@"7e1c1263b6a25eb90bf16e80d8f47a657e403c4c" open Equiv def Equiv.Perm.decomposeFin {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) := ((Equiv.permCongr <| finSuccEquiv n).trans Equiv.Perm.decomposeOption).trans (Equiv.prodCongr (finSuccEquiv n).symm (Equiv.refl _)) #align equiv.perm.decompose_fin Equiv.Perm.decomposeFin @[simp]
Mathlib/GroupTheory/Perm/Fin.lean
29
31
theorem Equiv.Perm.decomposeFin_symm_of_refl {n : ℕ} (p : Fin (n + 1)) : Equiv.Perm.decomposeFin.symm (p, Equiv.refl _) = swap 0 p := by
simp [Equiv.Perm.decomposeFin, Equiv.permCongr_def]
import Mathlib.Data.Set.Equitable import Mathlib.Logic.Equiv.Fin import Mathlib.Order.Partition.Finpartition #align_import order.partition.equipartition from "leanprover-community/mathlib"@"b363547b3113d350d053abdf2884e9850a56b205" open Finset Fintype namespace Finpartition variable {α : Type*} [DecidableEq α] {s t : Finset α} (P : Finpartition s) def IsEquipartition : Prop := (P.parts : Set (Finset α)).EquitableOn card #align finpartition.is_equipartition Finpartition.IsEquipartition theorem isEquipartition_iff_card_parts_eq_average : P.IsEquipartition ↔ ∀ a : Finset α, a ∈ P.parts → a.card = s.card / P.parts.card ∨ a.card = s.card / P.parts.card + 1 := by simp_rw [IsEquipartition, Finset.equitableOn_iff, P.sum_card_parts] #align finpartition.is_equipartition_iff_card_parts_eq_average Finpartition.isEquipartition_iff_card_parts_eq_average variable {P} lemma not_isEquipartition : ¬P.IsEquipartition ↔ ∃ a ∈ P.parts, ∃ b ∈ P.parts, b.card + 1 < a.card := Set.not_equitableOn theorem _root_.Set.Subsingleton.isEquipartition (h : (P.parts : Set (Finset α)).Subsingleton) : P.IsEquipartition := Set.Subsingleton.equitableOn h _ #align finpartition.set.subsingleton.is_equipartition Set.Subsingleton.isEquipartition theorem IsEquipartition.card_parts_eq_average (hP : P.IsEquipartition) (ht : t ∈ P.parts) : t.card = s.card / P.parts.card ∨ t.card = s.card / P.parts.card + 1 := P.isEquipartition_iff_card_parts_eq_average.1 hP _ ht #align finpartition.is_equipartition.card_parts_eq_average Finpartition.IsEquipartition.card_parts_eq_average theorem IsEquipartition.card_part_eq_average_iff (hP : P.IsEquipartition) (ht : t ∈ P.parts) : t.card = s.card / P.parts.card ↔ t.card ≠ s.card / P.parts.card + 1 := by have a := hP.card_parts_eq_average ht have b : ¬(t.card = s.card / P.parts.card ∧ t.card = s.card / P.parts.card + 1) := by by_contra h; exact absurd (h.1 ▸ h.2) (lt_add_one _).ne tauto
Mathlib/Order/Partition/Equipartition.lean
68
71
theorem IsEquipartition.average_le_card_part (hP : P.IsEquipartition) (ht : t ∈ P.parts) : s.card / P.parts.card ≤ t.card := by
rw [← P.sum_card_parts] exact Finset.EquitableOn.le hP ht
import Mathlib.Order.ConditionallyCompleteLattice.Finset import Mathlib.Order.Interval.Finset.Nat #align_import data.nat.lattice from "leanprover-community/mathlib"@"52fa514ec337dd970d71d8de8d0fd68b455a1e54" assert_not_exists MonoidWithZero open Set namespace Nat open scoped Classical noncomputable instance : InfSet ℕ := ⟨fun s ↦ if h : ∃ n, n ∈ s then @Nat.find (fun n ↦ n ∈ s) _ h else 0⟩ noncomputable instance : SupSet ℕ := ⟨fun s ↦ if h : ∃ n, ∀ a ∈ s, a ≤ n then @Nat.find (fun n ↦ ∀ a ∈ s, a ≤ n) _ h else 0⟩ theorem sInf_def {s : Set ℕ} (h : s.Nonempty) : sInf s = @Nat.find (fun n ↦ n ∈ s) _ h := dif_pos _ #align nat.Inf_def Nat.sInf_def theorem sSup_def {s : Set ℕ} (h : ∃ n, ∀ a ∈ s, a ≤ n) : sSup s = @Nat.find (fun n ↦ ∀ a ∈ s, a ≤ n) _ h := dif_pos _ #align nat.Sup_def Nat.sSup_def theorem _root_.Set.Infinite.Nat.sSup_eq_zero {s : Set ℕ} (h : s.Infinite) : sSup s = 0 := dif_neg fun ⟨n, hn⟩ ↦ let ⟨k, hks, hk⟩ := h.exists_gt n (hn k hks).not_lt hk #align set.infinite.nat.Sup_eq_zero Set.Infinite.Nat.sSup_eq_zero @[simp] theorem sInf_eq_zero {s : Set ℕ} : sInf s = 0 ↔ 0 ∈ s ∨ s = ∅ := by cases eq_empty_or_nonempty s with | inl h => subst h simp only [or_true_iff, eq_self_iff_true, iff_true_iff, iInf, InfSet.sInf, mem_empty_iff_false, exists_false, dif_neg, not_false_iff] | inr h => simp only [h.ne_empty, or_false_iff, Nat.sInf_def, h, Nat.find_eq_zero] #align nat.Inf_eq_zero Nat.sInf_eq_zero @[simp] theorem sInf_empty : sInf ∅ = 0 := by rw [sInf_eq_zero] right rfl #align nat.Inf_empty Nat.sInf_empty @[simp] theorem iInf_of_empty {ι : Sort*} [IsEmpty ι] (f : ι → ℕ) : iInf f = 0 := by rw [iInf_of_isEmpty, sInf_empty] #align nat.infi_of_empty Nat.iInf_of_empty @[simp] lemma iInf_const_zero {ι : Sort*} : ⨅ i : ι, 0 = 0 := (isEmpty_or_nonempty ι).elim (fun h ↦ by simp) fun h ↦ sInf_eq_zero.2 <| by simp theorem sInf_mem {s : Set ℕ} (h : s.Nonempty) : sInf s ∈ s := by rw [Nat.sInf_def h] exact Nat.find_spec h #align nat.Inf_mem Nat.sInf_mem theorem not_mem_of_lt_sInf {s : Set ℕ} {m : ℕ} (hm : m < sInf s) : m ∉ s := by cases eq_empty_or_nonempty s with | inl h => subst h; apply not_mem_empty | inr h => rw [Nat.sInf_def h] at hm; exact Nat.find_min h hm #align nat.not_mem_of_lt_Inf Nat.not_mem_of_lt_sInf protected theorem sInf_le {s : Set ℕ} {m : ℕ} (hm : m ∈ s) : sInf s ≤ m := by rw [Nat.sInf_def ⟨m, hm⟩] exact Nat.find_min' ⟨m, hm⟩ hm #align nat.Inf_le Nat.sInf_le theorem nonempty_of_pos_sInf {s : Set ℕ} (h : 0 < sInf s) : s.Nonempty := by by_contra contra rw [Set.not_nonempty_iff_eq_empty] at contra have h' : sInf s ≠ 0 := ne_of_gt h apply h' rw [Nat.sInf_eq_zero] right assumption #align nat.nonempty_of_pos_Inf Nat.nonempty_of_pos_sInf theorem nonempty_of_sInf_eq_succ {s : Set ℕ} {k : ℕ} (h : sInf s = k + 1) : s.Nonempty := nonempty_of_pos_sInf (h.symm ▸ succ_pos k : sInf s > 0) #align nat.nonempty_of_Inf_eq_succ Nat.nonempty_of_sInf_eq_succ theorem eq_Ici_of_nonempty_of_upward_closed {s : Set ℕ} (hs : s.Nonempty) (hs' : ∀ k₁ k₂ : ℕ, k₁ ≤ k₂ → k₁ ∈ s → k₂ ∈ s) : s = Ici (sInf s) := ext fun n ↦ ⟨fun H ↦ Nat.sInf_le H, fun H ↦ hs' (sInf s) n H (sInf_mem hs)⟩ #align nat.eq_Ici_of_nonempty_of_upward_closed Nat.eq_Ici_of_nonempty_of_upward_closed theorem sInf_upward_closed_eq_succ_iff {s : Set ℕ} (hs : ∀ k₁ k₂ : ℕ, k₁ ≤ k₂ → k₁ ∈ s → k₂ ∈ s) (k : ℕ) : sInf s = k + 1 ↔ k + 1 ∈ s ∧ k ∉ s := by constructor · intro H rw [eq_Ici_of_nonempty_of_upward_closed (nonempty_of_sInf_eq_succ _) hs, H, mem_Ici, mem_Ici] · exact ⟨le_rfl, k.not_succ_le_self⟩; · exact k · assumption · rintro ⟨H, H'⟩ rw [sInf_def (⟨_, H⟩ : s.Nonempty), find_eq_iff] exact ⟨H, fun n hnk hns ↦ H' <| hs n k (Nat.lt_succ_iff.mp hnk) hns⟩ #align nat.Inf_upward_closed_eq_succ_iff Nat.sInf_upward_closed_eq_succ_iff instance : Lattice ℕ := LinearOrder.toLattice noncomputable instance : ConditionallyCompleteLinearOrderBot ℕ := { (inferInstance : OrderBot ℕ), (LinearOrder.toLattice : Lattice ℕ), (inferInstance : LinearOrder ℕ) with -- sup := sSup -- Porting note: removed, unnecessary? -- inf := sInf -- Porting note: removed, unnecessary? le_csSup := fun s a hb ha ↦ by rw [sSup_def hb]; revert a ha; exact @Nat.find_spec _ _ hb csSup_le := fun s a _ ha ↦ by rw [sSup_def ⟨a, ha⟩]; exact Nat.find_min' _ ha le_csInf := fun s a hs hb ↦ by rw [sInf_def hs]; exact hb (@Nat.find_spec (fun n ↦ n ∈ s) _ _) csInf_le := fun s a _ ha ↦ by rw [sInf_def ⟨a, ha⟩]; exact Nat.find_min' _ ha csSup_empty := by simp only [sSup_def, Set.mem_empty_iff_false, forall_const, forall_prop_of_false, not_false_iff, exists_const] apply bot_unique (Nat.find_min' _ _) trivial csSup_of_not_bddAbove := by intro s hs simp only [mem_univ, forall_true_left, sSup, mem_empty_iff_false, IsEmpty.forall_iff, forall_const, exists_const, dite_true] rw [dif_neg] · exact le_antisymm (zero_le _) (find_le trivial) · exact hs csInf_of_not_bddBelow := fun s hs ↦ by simp at hs } theorem sSup_mem {s : Set ℕ} (h₁ : s.Nonempty) (h₂ : BddAbove s) : sSup s ∈ s := let ⟨k, hk⟩ := h₂ h₁.csSup_mem ((finite_le_nat k).subset hk) #align nat.Sup_mem Nat.sSup_mem
Mathlib/Data/Nat/Lattice.lean
157
169
theorem sInf_add {n : ℕ} {p : ℕ → Prop} (hn : n ≤ sInf { m | p m }) : sInf { m | p (m + n) } + n = sInf { m | p m } := by
obtain h | ⟨m, hm⟩ := { m | p (m + n) }.eq_empty_or_nonempty · rw [h, Nat.sInf_empty, zero_add] obtain hnp | hnp := hn.eq_or_lt · exact hnp suffices hp : p (sInf { m | p m } - n + n) from (h.subset hp).elim rw [Nat.sub_add_cancel hn] exact csInf_mem (nonempty_of_pos_sInf <| n.zero_le.trans_lt hnp) · have hp : ∃ n, n ∈ { m | p m } := ⟨_, hm⟩ rw [Nat.sInf_def ⟨m, hm⟩, Nat.sInf_def hp] rw [Nat.sInf_def hp] at hn exact find_add hn
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]
Mathlib/Combinatorics/SimpleGraph/Subgraph.lean
565
566
theorem edgeSet_iSup (f : ι → G.Subgraph) : (⨆ i, f i).edgeSet = ⋃ i, (f i).edgeSet := by
simp [iSup]
import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.BigOperators import Mathlib.Algebra.Polynomial.Degree.Lemmas import Mathlib.Algebra.Polynomial.Div #align_import data.polynomial.ring_division from "leanprover-community/mathlib"@"8efcf8022aac8e01df8d302dcebdbc25d6a886c8" noncomputable section open Polynomial open Finset namespace Polynomial universe u v w z variable {R : Type u} {S : Type v} {T : Type w} {a b : R} {n : ℕ} section NoZeroDivisors variable [CommSemiring R] [NoZeroDivisors R] {p q : R[X]} theorem irreducible_of_monic (hp : p.Monic) (hp1 : p ≠ 1) : Irreducible p ↔ ∀ f g : R[X], f.Monic → g.Monic → f * g = p → f = 1 ∨ g = 1 := by refine ⟨fun h f g hf hg hp => (h.2 f g hp.symm).imp hf.eq_one_of_isUnit hg.eq_one_of_isUnit, fun h => ⟨hp1 ∘ hp.eq_one_of_isUnit, fun f g hfg => (h (g * C f.leadingCoeff) (f * C g.leadingCoeff) ?_ ?_ ?_).symm.imp (isUnit_of_mul_eq_one f _) (isUnit_of_mul_eq_one g _)⟩⟩ · rwa [Monic, leadingCoeff_mul, leadingCoeff_C, ← leadingCoeff_mul, mul_comm, ← hfg, ← Monic] · rwa [Monic, leadingCoeff_mul, leadingCoeff_C, ← leadingCoeff_mul, ← hfg, ← Monic] · rw [mul_mul_mul_comm, ← C_mul, ← leadingCoeff_mul, ← hfg, hp.leadingCoeff, C_1, mul_one, mul_comm, ← hfg] #align polynomial.irreducible_of_monic Polynomial.irreducible_of_monic theorem Monic.irreducible_iff_natDegree (hp : p.Monic) : Irreducible p ↔ p ≠ 1 ∧ ∀ f g : R[X], f.Monic → g.Monic → f * g = p → f.natDegree = 0 ∨ g.natDegree = 0 := by by_cases hp1 : p = 1; · simp [hp1] rw [irreducible_of_monic hp hp1, and_iff_right hp1] refine forall₄_congr fun a b ha hb => ?_ rw [ha.natDegree_eq_zero_iff_eq_one, hb.natDegree_eq_zero_iff_eq_one] #align polynomial.monic.irreducible_iff_nat_degree Polynomial.Monic.irreducible_iff_natDegree
Mathlib/Algebra/Polynomial/RingDivision.lean
268
279
theorem Monic.irreducible_iff_natDegree' (hp : p.Monic) : Irreducible p ↔ p ≠ 1 ∧ ∀ f g : R[X], f.Monic → g.Monic → f * g = p → g.natDegree ∉ Ioc 0 (p.natDegree / 2) := by
simp_rw [hp.irreducible_iff_natDegree, mem_Ioc, Nat.le_div_iff_mul_le zero_lt_two, mul_two] apply and_congr_right' constructor <;> intro h f g hf hg he <;> subst he · rw [hf.natDegree_mul hg, add_le_add_iff_right] exact fun ha => (h f g hf hg rfl).elim (ha.1.trans_le ha.2).ne' ha.1.ne' · simp_rw [hf.natDegree_mul hg, pos_iff_ne_zero] at h contrapose! h obtain hl | hl := le_total f.natDegree g.natDegree · exact ⟨g, f, hg, hf, mul_comm g f, h.1, add_le_add_left hl _⟩ · exact ⟨f, g, hf, hg, rfl, h.2, add_le_add_right hl _⟩
import Mathlib.LinearAlgebra.Dimension.Finite import Mathlib.LinearAlgebra.Dimension.Constructions open Cardinal Submodule Set FiniteDimensional universe u v section Module variable {K : Type u} {V : Type v} [Ring K] [StrongRankCondition K] [AddCommGroup V] [Module K V] noncomputable def Basis.ofRankEqZero [Module.Free K V] {ι : Type*} [IsEmpty ι] (hV : Module.rank K V = 0) : Basis ι K V := haveI : Subsingleton V := by obtain ⟨_, b⟩ := Module.Free.exists_basis (R := K) (M := V) haveI := mk_eq_zero_iff.1 (hV ▸ b.mk_eq_rank'') exact b.repr.toEquiv.subsingleton Basis.empty _ #align basis.of_rank_eq_zero Basis.ofRankEqZero @[simp] theorem Basis.ofRankEqZero_apply [Module.Free K V] {ι : Type*} [IsEmpty ι] (hV : Module.rank K V = 0) (i : ι) : Basis.ofRankEqZero hV i = 0 := rfl #align basis.of_rank_eq_zero_apply Basis.ofRankEqZero_apply theorem le_rank_iff_exists_linearIndependent [Module.Free K V] {c : Cardinal} : c ≤ Module.rank K V ↔ ∃ s : Set V, #s = c ∧ LinearIndependent K ((↑) : s → V) := by haveI := nontrivial_of_invariantBasisNumber K constructor · intro h obtain ⟨κ, t'⟩ := Module.Free.exists_basis (R := K) (M := V) let t := t'.reindexRange have : LinearIndependent K ((↑) : Set.range t' → V) := by convert t.linearIndependent ext; exact (Basis.reindexRange_apply _ _).symm rw [← t.mk_eq_rank'', le_mk_iff_exists_subset] at h rcases h with ⟨s, hst, hsc⟩ exact ⟨s, hsc, this.mono hst⟩ · rintro ⟨s, rfl, si⟩ exact si.cardinal_le_rank #align le_rank_iff_exists_linear_independent le_rank_iff_exists_linearIndependent theorem le_rank_iff_exists_linearIndependent_finset [Module.Free K V] {n : ℕ} : ↑n ≤ Module.rank K V ↔ ∃ s : Finset V, s.card = n ∧ LinearIndependent K ((↑) : ↥(s : Set V) → V) := by simp only [le_rank_iff_exists_linearIndependent, mk_set_eq_nat_iff_finset] constructor · rintro ⟨s, ⟨t, rfl, rfl⟩, si⟩ exact ⟨t, rfl, si⟩ · rintro ⟨s, rfl, si⟩ exact ⟨s, ⟨s, rfl, rfl⟩, si⟩ #align le_rank_iff_exists_linear_independent_finset le_rank_iff_exists_linearIndependent_finset theorem rank_le_one_iff [Module.Free K V] : Module.rank K V ≤ 1 ↔ ∃ v₀ : V, ∀ v, ∃ r : K, r • v₀ = v := by obtain ⟨κ, b⟩ := Module.Free.exists_basis (R := K) (M := V) constructor · intro hd rw [← b.mk_eq_rank'', le_one_iff_subsingleton] at hd rcases isEmpty_or_nonempty κ with hb | ⟨⟨i⟩⟩ · use 0 have h' : ∀ v : V, v = 0 := by simpa [range_eq_empty, Submodule.eq_bot_iff] using b.span_eq.symm intro v simp [h' v] · use b i have h' : (K ∙ b i) = ⊤ := (subsingleton_range b).eq_singleton_of_mem (mem_range_self i) ▸ b.span_eq intro v have hv : v ∈ (⊤ : Submodule K V) := mem_top rwa [← h', mem_span_singleton] at hv · rintro ⟨v₀, hv₀⟩ have h : (K ∙ v₀) = ⊤ := by ext simp [mem_span_singleton, hv₀] rw [← rank_top, ← h] refine (rank_span_le _).trans_eq ?_ simp #align rank_le_one_iff rank_le_one_iff theorem rank_eq_one_iff [Module.Free K V] : Module.rank K V = 1 ↔ ∃ v₀ : V, v₀ ≠ 0 ∧ ∀ v, ∃ r : K, r • v₀ = v := by haveI := nontrivial_of_invariantBasisNumber K refine ⟨fun h ↦ ?_, fun ⟨v₀, h, hv⟩ ↦ (rank_le_one_iff.2 ⟨v₀, hv⟩).antisymm ?_⟩ · obtain ⟨v₀, hv⟩ := rank_le_one_iff.1 h.le refine ⟨v₀, fun hzero ↦ ?_, hv⟩ simp_rw [hzero, smul_zero, exists_const] at hv haveI : Subsingleton V := .intro fun _ _ ↦ by simp_rw [← hv] exact one_ne_zero (h ▸ rank_subsingleton' K V) · by_contra H rw [not_le, lt_one_iff_zero] at H obtain ⟨κ, b⟩ := Module.Free.exists_basis (R := K) (M := V) haveI := mk_eq_zero_iff.1 (H ▸ b.mk_eq_rank'') haveI := b.repr.toEquiv.subsingleton exact h (Subsingleton.elim _ _) theorem rank_submodule_le_one_iff (s : Submodule K V) [Module.Free K s] : Module.rank K s ≤ 1 ↔ ∃ v₀ ∈ s, s ≤ K ∙ v₀ := by simp_rw [rank_le_one_iff, le_span_singleton_iff] constructor · rintro ⟨⟨v₀, hv₀⟩, h⟩ use v₀, hv₀ intro v hv obtain ⟨r, hr⟩ := h ⟨v, hv⟩ use r rwa [Subtype.ext_iff, coe_smul] at hr · rintro ⟨v₀, hv₀, h⟩ use ⟨v₀, hv₀⟩ rintro ⟨v, hv⟩ obtain ⟨r, hr⟩ := h v hv use r rwa [Subtype.ext_iff, coe_smul] #align rank_submodule_le_one_iff rank_submodule_le_one_iff theorem rank_submodule_eq_one_iff (s : Submodule K V) [Module.Free K s] : Module.rank K s = 1 ↔ ∃ v₀ ∈ s, v₀ ≠ 0 ∧ s ≤ K ∙ v₀ := by simp_rw [rank_eq_one_iff, le_span_singleton_iff] refine ⟨fun ⟨⟨v₀, hv₀⟩, H, h⟩ ↦ ⟨v₀, hv₀, fun h' ↦ by simp [h'] at H, fun v hv ↦ ?_⟩, fun ⟨v₀, hv₀, H, h⟩ ↦ ⟨⟨v₀, hv₀⟩, fun h' ↦ H (by simpa using h'), fun ⟨v, hv⟩ ↦ ?_⟩⟩ · obtain ⟨r, hr⟩ := h ⟨v, hv⟩ exact ⟨r, by rwa [Subtype.ext_iff, coe_smul] at hr⟩ · obtain ⟨r, hr⟩ := h v hv exact ⟨r, by rwa [Subtype.ext_iff, coe_smul]⟩ theorem rank_submodule_le_one_iff' (s : Submodule K V) [Module.Free K s] : Module.rank K s ≤ 1 ↔ ∃ v₀, s ≤ K ∙ v₀ := by haveI := nontrivial_of_invariantBasisNumber K constructor · rw [rank_submodule_le_one_iff] rintro ⟨v₀, _, h⟩ exact ⟨v₀, h⟩ · rintro ⟨v₀, h⟩ obtain ⟨κ, b⟩ := Module.Free.exists_basis (R := K) (M := s) simpa [b.mk_eq_rank''] using b.linearIndependent.map' _ (ker_inclusion _ _ h) |>.cardinal_le_rank.trans (rank_span_le {v₀}) #align rank_submodule_le_one_iff' rank_submodule_le_one_iff'
Mathlib/LinearAlgebra/Dimension/FreeAndStrongRankCondition.lean
171
181
theorem Submodule.rank_le_one_iff_isPrincipal (W : Submodule K V) [Module.Free K W] : Module.rank K W ≤ 1 ↔ W.IsPrincipal := by
simp only [rank_le_one_iff, Submodule.isPrincipal_iff, le_antisymm_iff, le_span_singleton_iff, span_singleton_le_iff_mem] constructor · rintro ⟨⟨m, hm⟩, hm'⟩ choose f hf using hm' exact ⟨m, ⟨fun v hv => ⟨f ⟨v, hv⟩, congr_arg ((↑) : W → V) (hf ⟨v, hv⟩)⟩, hm⟩⟩ · rintro ⟨a, ⟨h, ha⟩⟩ choose f hf using h exact ⟨⟨a, ha⟩, fun v => ⟨f v.1 v.2, Subtype.ext (hf v.1 v.2)⟩⟩
import Mathlib.Algebra.GCDMonoid.Basic import Mathlib.Algebra.Order.Ring.Int import Mathlib.Data.Int.GCD instance : GCDMonoid ℕ where gcd := Nat.gcd lcm := Nat.lcm gcd_dvd_left := Nat.gcd_dvd_left gcd_dvd_right := Nat.gcd_dvd_right dvd_gcd := Nat.dvd_gcd gcd_mul_lcm a b := by rw [Nat.gcd_mul_lcm]; rfl lcm_zero_left := Nat.lcm_zero_left lcm_zero_right := Nat.lcm_zero_right theorem gcd_eq_nat_gcd (m n : ℕ) : gcd m n = Nat.gcd m n := rfl #align gcd_eq_nat_gcd gcd_eq_nat_gcd theorem lcm_eq_nat_lcm (m n : ℕ) : lcm m n = Nat.lcm m n := rfl #align lcm_eq_nat_lcm lcm_eq_nat_lcm instance : NormalizedGCDMonoid ℕ := { (inferInstance : GCDMonoid ℕ), (inferInstance : NormalizationMonoid ℕ) with normalize_gcd := fun _ _ => normalize_eq _ normalize_lcm := fun _ _ => normalize_eq _ } namespace Int section NormalizationMonoid instance normalizationMonoid : NormalizationMonoid ℤ where normUnit a := if 0 ≤ a then 1 else -1 normUnit_zero := if_pos le_rfl normUnit_mul {a b} hna hnb := by cases' hna.lt_or_lt with ha ha <;> cases' hnb.lt_or_lt with hb hb <;> simp [mul_nonneg_iff, ha.le, ha.not_le, hb.le, hb.not_le] normUnit_coe_units u := (units_eq_one_or u).elim (fun eq => eq.symm ▸ if_pos zero_le_one) fun eq => eq.symm ▸ if_neg (not_le_of_gt <| show (-1 : ℤ) < 0 by decide) -- Porting note: added theorem normUnit_eq (z : ℤ) : normUnit z = if 0 ≤ z then 1 else -1 := rfl theorem normalize_of_nonneg {z : ℤ} (h : 0 ≤ z) : normalize z = z := by rw [normalize_apply, normUnit_eq, if_pos h, Units.val_one, mul_one] #align int.normalize_of_nonneg Int.normalize_of_nonneg
Mathlib/Algebra/GCDMonoid/Nat.lean
71
75
theorem normalize_of_nonpos {z : ℤ} (h : z ≤ 0) : normalize z = -z := by
obtain rfl | h := h.eq_or_lt · simp · rw [normalize_apply, normUnit_eq, if_neg (not_le_of_gt h), Units.val_neg, Units.val_one, mul_neg_one]
import Mathlib.Algebra.Associated import Mathlib.Algebra.Group.Submonoid.Membership import Mathlib.Algebra.Ring.Opposite import Mathlib.GroupTheory.GroupAction.Opposite #align_import ring_theory.non_zero_divisors from "leanprover-community/mathlib"@"1126441d6bccf98c81214a0780c73d499f6721fe" variable (M₀ : Type*) [MonoidWithZero M₀] def nonZeroDivisorsLeft : Submonoid M₀ where carrier := {x | ∀ y, y * x = 0 → y = 0} one_mem' := by simp mul_mem' {x} {y} hx hy := fun z hz ↦ hx _ <| hy _ (mul_assoc z x y ▸ hz) @[simp] lemma mem_nonZeroDivisorsLeft_iff {x : M₀} : x ∈ nonZeroDivisorsLeft M₀ ↔ ∀ y, y * x = 0 → y = 0 := Iff.rfl lemma nmem_nonZeroDivisorsLeft_iff {r : M₀} : r ∉ nonZeroDivisorsLeft M₀ ↔ {s | s * r = 0 ∧ s ≠ 0}.Nonempty := by simpa [mem_nonZeroDivisorsLeft_iff] using Set.nonempty_def.symm def nonZeroDivisorsRight : Submonoid M₀ where carrier := {x | ∀ y, x * y = 0 → y = 0} one_mem' := by simp mul_mem' := fun {x} {y} hx hy z hz ↦ hy _ (hx _ ((mul_assoc x y z).symm ▸ hz)) @[simp] lemma mem_nonZeroDivisorsRight_iff {x : M₀} : x ∈ nonZeroDivisorsRight M₀ ↔ ∀ y, x * y = 0 → y = 0 := Iff.rfl lemma nmem_nonZeroDivisorsRight_iff {r : M₀} : r ∉ nonZeroDivisorsRight M₀ ↔ {s | r * s = 0 ∧ s ≠ 0}.Nonempty := by simpa [mem_nonZeroDivisorsRight_iff] using Set.nonempty_def.symm lemma nonZeroDivisorsLeft_eq_right (M₀ : Type*) [CommMonoidWithZero M₀] : nonZeroDivisorsLeft M₀ = nonZeroDivisorsRight M₀ := by ext x; simp [mul_comm x] @[simp] lemma coe_nonZeroDivisorsLeft_eq [NoZeroDivisors M₀] [Nontrivial M₀] : nonZeroDivisorsLeft M₀ = {x : M₀ | x ≠ 0} := by ext x simp only [SetLike.mem_coe, mem_nonZeroDivisorsLeft_iff, mul_eq_zero, forall_eq_or_imp, true_and, Set.mem_setOf_eq] refine ⟨fun h ↦ ?_, fun hx y hx' ↦ by contradiction⟩ contrapose! h exact ⟨1, h, one_ne_zero⟩ @[simp] lemma coe_nonZeroDivisorsRight_eq [NoZeroDivisors M₀] [Nontrivial M₀] : nonZeroDivisorsRight M₀ = {x : M₀ | x ≠ 0} := by ext x simp only [SetLike.mem_coe, mem_nonZeroDivisorsRight_iff, mul_eq_zero, Set.mem_setOf_eq] refine ⟨fun h ↦ ?_, fun hx y hx' ↦ by aesop⟩ contrapose! h exact ⟨1, Or.inl h, one_ne_zero⟩ def nonZeroDivisors (R : Type*) [MonoidWithZero R] : Submonoid R where carrier := { x | ∀ z, z * x = 0 → z = 0 } one_mem' _ hz := by rwa [mul_one] at hz mul_mem' hx₁ hx₂ _ hz := by rw [← mul_assoc] at hz exact hx₁ _ (hx₂ _ hz) #align non_zero_divisors nonZeroDivisors scoped[nonZeroDivisors] notation:9000 R "⁰" => nonZeroDivisors R def nonZeroSMulDivisors (R : Type*) [MonoidWithZero R] (M : Type _) [Zero M] [MulAction R M] : Submonoid R where carrier := { r | ∀ m : M, r • m = 0 → m = 0} one_mem' m h := (one_smul R m) ▸ h mul_mem' {r₁ r₂} h₁ h₂ m H := h₂ _ <| h₁ _ <| mul_smul r₁ r₂ m ▸ H scoped[nonZeroSMulDivisors] notation:9000 R "⁰[" M "]" => nonZeroSMulDivisors R M section nonZeroDivisors open nonZeroDivisors variable {M M' M₁ R R' F : Type*} [MonoidWithZero M] [MonoidWithZero M'] [CommMonoidWithZero M₁] [Ring R] [CommRing R'] theorem mem_nonZeroDivisors_iff {r : M} : r ∈ M⁰ ↔ ∀ x, x * r = 0 → x = 0 := Iff.rfl #align mem_non_zero_divisors_iff mem_nonZeroDivisors_iff lemma nmem_nonZeroDivisors_iff {r : M} : r ∉ M⁰ ↔ {s | s * r = 0 ∧ s ≠ 0}.Nonempty := by simpa [mem_nonZeroDivisors_iff] using Set.nonempty_def.symm theorem mul_right_mem_nonZeroDivisors_eq_zero_iff {x r : M} (hr : r ∈ M⁰) : x * r = 0 ↔ x = 0 := ⟨hr _, by simp (config := { contextual := true })⟩ #align mul_right_mem_non_zero_divisors_eq_zero_iff mul_right_mem_nonZeroDivisors_eq_zero_iff @[simp] theorem mul_right_coe_nonZeroDivisors_eq_zero_iff {x : M} {c : M⁰} : x * c = 0 ↔ x = 0 := mul_right_mem_nonZeroDivisors_eq_zero_iff c.prop #align mul_right_coe_non_zero_divisors_eq_zero_iff mul_right_coe_nonZeroDivisors_eq_zero_iff
Mathlib/Algebra/GroupWithZero/NonZeroDivisors.lean
129
130
theorem mul_left_mem_nonZeroDivisors_eq_zero_iff {r x : M₁} (hr : r ∈ M₁⁰) : r * x = 0 ↔ x = 0 := by
rw [mul_comm, mul_right_mem_nonZeroDivisors_eq_zero_iff hr]
import Mathlib.AlgebraicGeometry.Gluing import Mathlib.CategoryTheory.Limits.Opposites import Mathlib.AlgebraicGeometry.AffineScheme import Mathlib.CategoryTheory.Limits.Shapes.Diagonal #align_import algebraic_geometry.pullbacks from "leanprover-community/mathlib"@"7316286ff2942aa14e540add9058c6b0aa1c8070" set_option linter.uppercaseLean3 false universe v u noncomputable section open CategoryTheory CategoryTheory.Limits AlgebraicGeometry namespace AlgebraicGeometry.Scheme namespace Pullback variable {C : Type u} [Category.{v} C] variable {X Y Z : Scheme.{u}} (𝒰 : OpenCover.{u} X) (f : X ⟶ Z) (g : Y ⟶ Z) variable [∀ i, HasPullback (𝒰.map i ≫ f) g] def v (i j : 𝒰.J) : Scheme := pullback ((pullback.fst : pullback (𝒰.map i ≫ f) g ⟶ _) ≫ 𝒰.map i) (𝒰.map j) #align algebraic_geometry.Scheme.pullback.V AlgebraicGeometry.Scheme.Pullback.v def t (i j : 𝒰.J) : v 𝒰 f g i j ⟶ v 𝒰 f g j i := by have : HasPullback (pullback.snd ≫ 𝒰.map i ≫ f) g := hasPullback_assoc_symm (𝒰.map j) (𝒰.map i) (𝒰.map i ≫ f) g have : HasPullback (pullback.snd ≫ 𝒰.map j ≫ f) g := hasPullback_assoc_symm (𝒰.map i) (𝒰.map j) (𝒰.map j ≫ f) g refine (pullbackSymmetry ..).hom ≫ (pullbackAssoc ..).inv ≫ ?_ refine ?_ ≫ (pullbackAssoc ..).hom ≫ (pullbackSymmetry ..).hom refine pullback.map _ _ _ _ (pullbackSymmetry _ _).hom (𝟙 _) (𝟙 _) ?_ ?_ · rw [pullbackSymmetry_hom_comp_snd_assoc, pullback.condition_assoc, Category.comp_id] · rw [Category.comp_id, Category.id_comp] #align algebraic_geometry.Scheme.pullback.t AlgebraicGeometry.Scheme.Pullback.t @[simp, reassoc] theorem t_fst_fst (i j : 𝒰.J) : t 𝒰 f g i j ≫ pullback.fst ≫ pullback.fst = pullback.snd := by simp only [t, Category.assoc, pullbackSymmetry_hom_comp_fst_assoc, pullbackAssoc_hom_snd_fst, pullback.lift_fst_assoc, pullbackSymmetry_hom_comp_snd, pullbackAssoc_inv_fst_fst, pullbackSymmetry_hom_comp_fst] #align algebraic_geometry.Scheme.pullback.t_fst_fst AlgebraicGeometry.Scheme.Pullback.t_fst_fst @[simp, reassoc]
Mathlib/AlgebraicGeometry/Pullbacks.lean
71
74
theorem t_fst_snd (i j : 𝒰.J) : t 𝒰 f g i j ≫ pullback.fst ≫ pullback.snd = pullback.fst ≫ pullback.snd := by
simp only [t, Category.assoc, pullbackSymmetry_hom_comp_fst_assoc, pullbackAssoc_hom_snd_snd, pullback.lift_snd, Category.comp_id, pullbackAssoc_inv_snd, pullbackSymmetry_hom_comp_snd_assoc]
import Mathlib.Order.BooleanAlgebra import Mathlib.Tactic.Common #align_import order.heyting.boundary from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" variable {α : Type*} namespace Coheyting variable [CoheytingAlgebra α] {a b : α} def boundary (a : α) : α := a ⊓ ¬a #align coheyting.boundary Coheyting.boundary scoped[Heyting] prefix:120 "∂ " => Coheyting.boundary -- Porting note: Should the notation be automatically included in the current scope? open Heyting -- Porting note: Should hnot be named hNot? theorem inf_hnot_self (a : α) : a ⊓ ¬a = ∂ a := rfl #align coheyting.inf_hnot_self Coheyting.inf_hnot_self theorem boundary_le : ∂ a ≤ a := inf_le_left #align coheyting.boundary_le Coheyting.boundary_le theorem boundary_le_hnot : ∂ a ≤ ¬a := inf_le_right #align coheyting.boundary_le_hnot Coheyting.boundary_le_hnot @[simp] theorem boundary_bot : ∂ (⊥ : α) = ⊥ := bot_inf_eq _ #align coheyting.boundary_bot Coheyting.boundary_bot @[simp] theorem boundary_top : ∂ (⊤ : α) = ⊥ := by rw [boundary, hnot_top, inf_bot_eq] #align coheyting.boundary_top Coheyting.boundary_top theorem boundary_hnot_le (a : α) : ∂ (¬a) ≤ ∂ a := (inf_comm _ _).trans_le <| inf_le_inf_right _ hnot_hnot_le #align coheyting.boundary_hnot_le Coheyting.boundary_hnot_le @[simp] theorem boundary_hnot_hnot (a : α) : ∂ (¬¬a) = ∂ (¬a) := by simp_rw [boundary, hnot_hnot_hnot, inf_comm] #align coheyting.boundary_hnot_hnot Coheyting.boundary_hnot_hnot @[simp] theorem hnot_boundary (a : α) : ¬∂ a = ⊤ := by rw [boundary, hnot_inf_distrib, sup_hnot_self] #align coheyting.hnot_boundary Coheyting.hnot_boundary theorem boundary_inf (a b : α) : ∂ (a ⊓ b) = ∂ a ⊓ b ⊔ a ⊓ ∂ b := by unfold boundary rw [hnot_inf_distrib, inf_sup_left, inf_right_comm, ← inf_assoc] #align coheyting.boundary_inf Coheyting.boundary_inf theorem boundary_inf_le : ∂ (a ⊓ b) ≤ ∂ a ⊔ ∂ b := (boundary_inf _ _).trans_le <| sup_le_sup inf_le_left inf_le_right #align coheyting.boundary_inf_le Coheyting.boundary_inf_le theorem boundary_sup_le : ∂ (a ⊔ b) ≤ ∂ a ⊔ ∂ b := by rw [boundary, inf_sup_right] exact sup_le_sup (inf_le_inf_left _ <| hnot_anti le_sup_left) (inf_le_inf_left _ <| hnot_anti le_sup_right) #align coheyting.boundary_sup_le Coheyting.boundary_sup_le example (a b : Prop) : (a ∧ b ∨ ¬(a ∧ b)) ∧ ((a ∨ b) ∨ ¬(a ∨ b)) → a ∨ ¬a := by rintro ⟨⟨ha, _⟩ | hnab, (ha | hb) | hnab⟩ <;> try exact Or.inl ha · exact Or.inr fun ha => hnab ⟨ha, hb⟩ · exact Or.inr fun ha => hnab <| Or.inl ha
Mathlib/Order/Heyting/Boundary.lean
105
117
theorem boundary_le_boundary_sup_sup_boundary_inf_left : ∂ a ≤ ∂ (a ⊔ b) ⊔ ∂ (a ⊓ b) := by
-- Porting note: the following simp generates the same term as mathlib3 if you remove -- sup_inf_right from both. With sup_inf_right included, mathlib4 and mathlib3 generate -- different terms simp only [boundary, sup_inf_left, sup_inf_right, sup_right_idem, le_inf_iff, sup_assoc, sup_comm _ a] refine ⟨⟨⟨?_, ?_⟩, ⟨?_, ?_⟩⟩, ?_, ?_⟩ <;> try { exact le_sup_of_le_left inf_le_left } <;> refine inf_le_of_right_le ?_ · rw [hnot_le_iff_codisjoint_right, codisjoint_left_comm] exact codisjoint_hnot_left · refine le_sup_of_le_right ?_ rw [hnot_le_iff_codisjoint_right] exact codisjoint_hnot_right.mono_right (hnot_anti inf_le_left)
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic #align_import number_theory.legendre_symbol.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" open Nat section Euler section Legendre open ZMod variable (p : ℕ) [Fact p.Prime] def legendreSym (a : ℤ) : ℤ := quadraticChar (ZMod p) a #align legendre_sym legendreSym namespace legendreSym theorem eq_pow (a : ℤ) : (legendreSym p a : ZMod p) = (a : ZMod p) ^ (p / 2) := by rcases eq_or_ne (ringChar (ZMod p)) 2 with hc | hc · by_cases ha : (a : ZMod p) = 0 · rw [legendreSym, ha, quadraticChar_zero, zero_pow (Nat.div_pos (@Fact.out p.Prime).two_le (succ_pos 1)).ne'] norm_cast · have := (ringChar_zmod_n p).symm.trans hc -- p = 2 subst p rw [legendreSym, quadraticChar_eq_one_of_char_two hc ha] revert ha push_cast generalize (a : ZMod 2) = b; fin_cases b · tauto · simp · convert quadraticChar_eq_pow_of_char_ne_two' hc (a : ZMod p) exact (card p).symm #align legendre_sym.eq_pow legendreSym.eq_pow theorem eq_one_or_neg_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a = 1 ∨ legendreSym p a = -1 := quadraticChar_dichotomy ha #align legendre_sym.eq_one_or_neg_one legendreSym.eq_one_or_neg_one theorem eq_neg_one_iff_not_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a = -1 ↔ ¬legendreSym p a = 1 := quadraticChar_eq_neg_one_iff_not_one ha #align legendre_sym.eq_neg_one_iff_not_one legendreSym.eq_neg_one_iff_not_one theorem eq_zero_iff (a : ℤ) : legendreSym p a = 0 ↔ (a : ZMod p) = 0 := quadraticChar_eq_zero_iff #align legendre_sym.eq_zero_iff legendreSym.eq_zero_iff @[simp] theorem at_zero : legendreSym p 0 = 0 := by rw [legendreSym, Int.cast_zero, MulChar.map_zero] #align legendre_sym.at_zero legendreSym.at_zero @[simp] theorem at_one : legendreSym p 1 = 1 := by rw [legendreSym, Int.cast_one, MulChar.map_one] #align legendre_sym.at_one legendreSym.at_one protected theorem mul (a b : ℤ) : legendreSym p (a * b) = legendreSym p a * legendreSym p b := by simp [legendreSym, Int.cast_mul, map_mul, quadraticCharFun_mul] #align legendre_sym.mul legendreSym.mul @[simps] def hom : ℤ →*₀ ℤ where toFun := legendreSym p map_zero' := at_zero p map_one' := at_one p map_mul' := legendreSym.mul p #align legendre_sym.hom legendreSym.hom theorem sq_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a ^ 2 = 1 := quadraticChar_sq_one ha #align legendre_sym.sq_one legendreSym.sq_one theorem sq_one' {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p (a ^ 2) = 1 := by dsimp only [legendreSym] rw [Int.cast_pow] exact quadraticChar_sq_one' ha #align legendre_sym.sq_one' legendreSym.sq_one' protected theorem mod (a : ℤ) : legendreSym p a = legendreSym p (a % p) := by simp only [legendreSym, intCast_mod] #align legendre_sym.mod legendreSym.mod theorem eq_one_iff {a : ℤ} (ha0 : (a : ZMod p) ≠ 0) : legendreSym p a = 1 ↔ IsSquare (a : ZMod p) := quadraticChar_one_iff_isSquare ha0 #align legendre_sym.eq_one_iff legendreSym.eq_one_iff
Mathlib/NumberTheory/LegendreSymbol/Basic.lean
195
199
theorem eq_one_iff' {a : ℕ} (ha0 : (a : ZMod p) ≠ 0) : legendreSym p a = 1 ↔ IsSquare (a : ZMod p) := by
rw [eq_one_iff] · norm_cast · exact mod_cast ha0
import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Order.Interval.Set.IsoIoo import Mathlib.Topology.Order.MonotoneContinuity import Mathlib.Topology.UrysohnsBounded #align_import topology.tietze_extension from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [NormalSpace Y] open Metric Set Filter open BoundedContinuousFunction Topology noncomputable section namespace BoundedContinuousFunction
Mathlib/Topology/TietzeExtension.lean
169
213
theorem tietze_extension_step (f : X →ᵇ ℝ) (e : C(X, Y)) (he : ClosedEmbedding e) : ∃ g : Y →ᵇ ℝ, ‖g‖ ≤ ‖f‖ / 3 ∧ dist (g.compContinuous e) f ≤ 2 / 3 * ‖f‖ := by
have h3 : (0 : ℝ) < 3 := by norm_num1 have h23 : 0 < (2 / 3 : ℝ) := by norm_num1 -- In the trivial case `f = 0`, we take `g = 0` rcases eq_or_ne f 0 with (rfl | hf) · use 0 simp replace hf : 0 < ‖f‖ := norm_pos_iff.2 hf /- Otherwise, the closed sets `e '' (f ⁻¹' (Iic (-‖f‖ / 3)))` and `e '' (f ⁻¹' (Ici (‖f‖ / 3)))` are disjoint, hence by Urysohn's lemma there exists a function `g` that is equal to `-‖f‖ / 3` on the former set and is equal to `‖f‖ / 3` on the latter set. This function `g` satisfies the assertions of the lemma. -/ have hf3 : -‖f‖ / 3 < ‖f‖ / 3 := (div_lt_div_right h3).2 (Left.neg_lt_self hf) have hc₁ : IsClosed (e '' (f ⁻¹' Iic (-‖f‖ / 3))) := he.isClosedMap _ (isClosed_Iic.preimage f.continuous) have hc₂ : IsClosed (e '' (f ⁻¹' Ici (‖f‖ / 3))) := he.isClosedMap _ (isClosed_Ici.preimage f.continuous) have hd : Disjoint (e '' (f ⁻¹' Iic (-‖f‖ / 3))) (e '' (f ⁻¹' Ici (‖f‖ / 3))) := by refine disjoint_image_of_injective he.inj (Disjoint.preimage _ ?_) rwa [Iic_disjoint_Ici, not_le] rcases exists_bounded_mem_Icc_of_closed_of_le hc₁ hc₂ hd hf3.le with ⟨g, hg₁, hg₂, hgf⟩ refine ⟨g, ?_, ?_⟩ · refine (norm_le <| div_nonneg hf.le h3.le).mpr fun y => ?_ simpa [abs_le, neg_div] using hgf y · refine (dist_le <| mul_nonneg h23.le hf.le).mpr fun x => ?_ have hfx : -‖f‖ ≤ f x ∧ f x ≤ ‖f‖ := by simpa only [Real.norm_eq_abs, abs_le] using f.norm_coe_le_norm x rcases le_total (f x) (-‖f‖ / 3) with hle₁ | hle₁ · calc |g (e x) - f x| = -‖f‖ / 3 - f x := by rw [hg₁ (mem_image_of_mem _ hle₁), Function.const_apply, abs_of_nonneg (sub_nonneg.2 hle₁)] _ ≤ 2 / 3 * ‖f‖ := by linarith · rcases le_total (f x) (‖f‖ / 3) with hle₂ | hle₂ · simp only [neg_div] at * calc dist (g (e x)) (f x) ≤ |g (e x)| + |f x| := dist_le_norm_add_norm _ _ _ ≤ ‖f‖ / 3 + ‖f‖ / 3 := (add_le_add (abs_le.2 <| hgf _) (abs_le.2 ⟨hle₁, hle₂⟩)) _ = 2 / 3 * ‖f‖ := by linarith · calc |g (e x) - f x| = f x - ‖f‖ / 3 := by rw [hg₂ (mem_image_of_mem _ hle₂), abs_sub_comm, Function.const_apply, abs_of_nonneg (sub_nonneg.2 hle₂)] _ ≤ 2 / 3 * ‖f‖ := by linarith
import Mathlib.Algebra.MvPolynomial.Variables #align_import data.mv_polynomial.supported from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" universe u v w namespace MvPolynomial variable {σ τ : Type*} {R : Type u} {S : Type v} {r : R} {e : ℕ} {n m : σ} section CommSemiring variable [CommSemiring R] {p q : MvPolynomial σ R} variable (R) noncomputable def supported (s : Set σ) : Subalgebra R (MvPolynomial σ R) := Algebra.adjoin R (X '' s) #align mv_polynomial.supported MvPolynomial.supported variable {R} open Algebra theorem supported_eq_range_rename (s : Set σ) : supported R s = (rename ((↑) : s → σ)).range := by rw [supported, Set.image_eq_range, adjoin_range_eq_range_aeval, rename] congr #align mv_polynomial.supported_eq_range_rename MvPolynomial.supported_eq_range_rename noncomputable def supportedEquivMvPolynomial (s : Set σ) : supported R s ≃ₐ[R] MvPolynomial s R := (Subalgebra.equivOfEq _ _ (supported_eq_range_rename s)).trans (AlgEquiv.ofInjective (rename ((↑) : s → σ)) (rename_injective _ Subtype.val_injective)).symm #align mv_polynomial.supported_equiv_mv_polynomial MvPolynomial.supportedEquivMvPolynomial @[simp, nolint simpNF] -- Porting note: the `simpNF` linter complained about this lemma. theorem supportedEquivMvPolynomial_symm_C (s : Set σ) (x : R) : (supportedEquivMvPolynomial s).symm (C x) = algebraMap R (supported R s) x := by ext1 simp [supportedEquivMvPolynomial, MvPolynomial.algebraMap_eq] set_option linter.uppercaseLean3 false in #align mv_polynomial.supported_equiv_mv_polynomial_symm_C MvPolynomial.supportedEquivMvPolynomial_symm_C @[simp, nolint simpNF] -- Porting note: the `simpNF` linter complained about this lemma. theorem supportedEquivMvPolynomial_symm_X (s : Set σ) (i : s) : (↑((supportedEquivMvPolynomial s).symm (X i : MvPolynomial s R)) : MvPolynomial σ R) = X ↑i := by simp [supportedEquivMvPolynomial] set_option linter.uppercaseLean3 false in #align mv_polynomial.supported_equiv_mv_polynomial_symm_X MvPolynomial.supportedEquivMvPolynomial_symm_X variable {s t : Set σ}
Mathlib/Algebra/MvPolynomial/Supported.lean
75
83
theorem mem_supported : p ∈ supported R s ↔ ↑p.vars ⊆ s := by
classical rw [supported_eq_range_rename, AlgHom.mem_range] constructor · rintro ⟨p, rfl⟩ refine _root_.trans (Finset.coe_subset.2 (vars_rename _ _)) ?_ simp · intro hs exact exists_rename_eq_of_vars_subset_range p ((↑) : s → σ) Subtype.val_injective (by simpa)
import Mathlib.Analysis.Calculus.LineDeriv.Measurable import Mathlib.Analysis.NormedSpace.FiniteDimension import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar import Mathlib.Analysis.BoundedVariation import Mathlib.MeasureTheory.Group.Integral import Mathlib.Analysis.Distribution.AEEqOfIntegralContDiff import Mathlib.MeasureTheory.Measure.Haar.Disintegration open Filter MeasureTheory Measure FiniteDimensional Metric Set Asymptotics open scoped NNReal ENNReal Topology variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] {C D : ℝ≥0} {f g : E → ℝ} {s : Set E} {μ : Measure E} [IsAddHaarMeasure μ] namespace LipschitzWith
Mathlib/Analysis/Calculus/Rademacher.lean
63
77
theorem ae_lineDifferentiableAt (hf : LipschitzWith C f) (v : E) : ∀ᵐ p ∂μ, LineDifferentiableAt ℝ f p v := by
let L : ℝ →L[ℝ] E := ContinuousLinearMap.smulRight (1 : ℝ →L[ℝ] ℝ) v suffices A : ∀ p, ∀ᵐ (t : ℝ) ∂volume, LineDifferentiableAt ℝ f (p + t • v) v from ae_mem_of_ae_add_linearMap_mem L.toLinearMap volume μ (measurableSet_lineDifferentiableAt hf.continuous) A intro p have : ∀ᵐ (s : ℝ), DifferentiableAt ℝ (fun t ↦ f (p + t • v)) s := (hf.comp ((LipschitzWith.const p).add L.lipschitz)).ae_differentiableAt_real filter_upwards [this] with s hs have h's : DifferentiableAt ℝ (fun t ↦ f (p + t • v)) (s + 0) := by simpa using hs have : DifferentiableAt ℝ (fun t ↦ s + t) 0 := differentiableAt_id.const_add _ simp only [LineDifferentiableAt] convert h's.comp 0 this with _ t simp only [LineDifferentiableAt, add_assoc, Function.comp_apply, add_smul]
import Mathlib.Analysis.Convex.Side import Mathlib.Geometry.Euclidean.Angle.Oriented.Rotation import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine #align_import geometry.euclidean.angle.oriented.affine from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" noncomputable section open FiniteDimensional Complex open scoped Affine EuclideanGeometry Real RealInnerProductSpace ComplexConjugate namespace EuclideanGeometry variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P] [hd2 : Fact (finrank ℝ V = 2)] [Module.Oriented ℝ V (Fin 2)] abbrev o := @Module.Oriented.positiveOrientation def oangle (p₁ p₂ p₃ : P) : Real.Angle := o.oangle (p₁ -ᵥ p₂) (p₃ -ᵥ p₂) #align euclidean_geometry.oangle EuclideanGeometry.oangle @[inherit_doc] scoped notation "∡" => EuclideanGeometry.oangle theorem continuousAt_oangle {x : P × P × P} (hx12 : x.1 ≠ x.2.1) (hx32 : x.2.2 ≠ x.2.1) : ContinuousAt (fun y : P × P × P => ∡ y.1 y.2.1 y.2.2) x := by let f : P × P × P → V × V := fun y => (y.1 -ᵥ y.2.1, y.2.2 -ᵥ y.2.1) have hf1 : (f x).1 ≠ 0 := by simp [hx12] have hf2 : (f x).2 ≠ 0 := by simp [hx32] exact (o.continuousAt_oangle hf1 hf2).comp ((continuous_fst.vsub continuous_snd.fst).prod_mk (continuous_snd.snd.vsub continuous_snd.fst)).continuousAt #align euclidean_geometry.continuous_at_oangle EuclideanGeometry.continuousAt_oangle @[simp] theorem oangle_self_left (p₁ p₂ : P) : ∡ p₁ p₁ p₂ = 0 := by simp [oangle] #align euclidean_geometry.oangle_self_left EuclideanGeometry.oangle_self_left @[simp] theorem oangle_self_right (p₁ p₂ : P) : ∡ p₁ p₂ p₂ = 0 := by simp [oangle] #align euclidean_geometry.oangle_self_right EuclideanGeometry.oangle_self_right @[simp] theorem oangle_self_left_right (p₁ p₂ : P) : ∡ p₁ p₂ p₁ = 0 := o.oangle_self _ #align euclidean_geometry.oangle_self_left_right EuclideanGeometry.oangle_self_left_right theorem left_ne_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₁ ≠ p₂ := by rw [← @vsub_ne_zero V]; exact o.left_ne_zero_of_oangle_ne_zero h #align euclidean_geometry.left_ne_of_oangle_ne_zero EuclideanGeometry.left_ne_of_oangle_ne_zero theorem right_ne_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₃ ≠ p₂ := by rw [← @vsub_ne_zero V]; exact o.right_ne_zero_of_oangle_ne_zero h #align euclidean_geometry.right_ne_of_oangle_ne_zero EuclideanGeometry.right_ne_of_oangle_ne_zero theorem left_ne_right_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₁ ≠ p₃ := by rw [← (vsub_left_injective p₂).ne_iff]; exact o.ne_of_oangle_ne_zero h #align euclidean_geometry.left_ne_right_of_oangle_ne_zero EuclideanGeometry.left_ne_right_of_oangle_ne_zero theorem left_ne_of_oangle_eq_pi {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = π) : p₁ ≠ p₂ := left_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_of_oangle_eq_pi EuclideanGeometry.left_ne_of_oangle_eq_pi theorem right_ne_of_oangle_eq_pi {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = π) : p₃ ≠ p₂ := right_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.right_ne_of_oangle_eq_pi EuclideanGeometry.right_ne_of_oangle_eq_pi theorem left_ne_right_of_oangle_eq_pi {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = π) : p₁ ≠ p₃ := left_ne_right_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_eq_pi EuclideanGeometry.left_ne_right_of_oangle_eq_pi theorem left_ne_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (π / 2 : ℝ)) : p₁ ≠ p₂ := left_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_of_oangle_eq_pi_div_two EuclideanGeometry.left_ne_of_oangle_eq_pi_div_two theorem right_ne_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (π / 2 : ℝ)) : p₃ ≠ p₂ := right_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.right_ne_of_oangle_eq_pi_div_two EuclideanGeometry.right_ne_of_oangle_eq_pi_div_two theorem left_ne_right_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (π / 2 : ℝ)) : p₁ ≠ p₃ := left_ne_right_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_eq_pi_div_two EuclideanGeometry.left_ne_right_of_oangle_eq_pi_div_two theorem left_ne_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (-π / 2 : ℝ)) : p₁ ≠ p₂ := left_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_of_oangle_eq_neg_pi_div_two EuclideanGeometry.left_ne_of_oangle_eq_neg_pi_div_two theorem right_ne_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (-π / 2 : ℝ)) : p₃ ≠ p₂ := right_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.right_ne_of_oangle_eq_neg_pi_div_two EuclideanGeometry.right_ne_of_oangle_eq_neg_pi_div_two theorem left_ne_right_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (-π / 2 : ℝ)) : p₁ ≠ p₃ := left_ne_right_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_eq_neg_pi_div_two EuclideanGeometry.left_ne_right_of_oangle_eq_neg_pi_div_two theorem left_ne_of_oangle_sign_ne_zero {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign ≠ 0) : p₁ ≠ p₂ := left_ne_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align euclidean_geometry.left_ne_of_oangle_sign_ne_zero EuclideanGeometry.left_ne_of_oangle_sign_ne_zero theorem right_ne_of_oangle_sign_ne_zero {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign ≠ 0) : p₃ ≠ p₂ := right_ne_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align euclidean_geometry.right_ne_of_oangle_sign_ne_zero EuclideanGeometry.right_ne_of_oangle_sign_ne_zero theorem left_ne_right_of_oangle_sign_ne_zero {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign ≠ 0) : p₁ ≠ p₃ := left_ne_right_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align euclidean_geometry.left_ne_right_of_oangle_sign_ne_zero EuclideanGeometry.left_ne_right_of_oangle_sign_ne_zero theorem left_ne_of_oangle_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) : p₁ ≠ p₂ := left_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.left_ne_of_oangle_sign_eq_one EuclideanGeometry.left_ne_of_oangle_sign_eq_one theorem right_ne_of_oangle_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) : p₃ ≠ p₂ := right_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.right_ne_of_oangle_sign_eq_one EuclideanGeometry.right_ne_of_oangle_sign_eq_one theorem left_ne_right_of_oangle_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) : p₁ ≠ p₃ := left_ne_right_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_sign_eq_one EuclideanGeometry.left_ne_right_of_oangle_sign_eq_one theorem left_ne_of_oangle_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) : p₁ ≠ p₂ := left_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.left_ne_of_oangle_sign_eq_neg_one EuclideanGeometry.left_ne_of_oangle_sign_eq_neg_one theorem right_ne_of_oangle_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) : p₃ ≠ p₂ := right_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.right_ne_of_oangle_sign_eq_neg_one EuclideanGeometry.right_ne_of_oangle_sign_eq_neg_one theorem left_ne_right_of_oangle_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) : p₁ ≠ p₃ := left_ne_right_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_sign_eq_neg_one EuclideanGeometry.left_ne_right_of_oangle_sign_eq_neg_one theorem oangle_rev (p₁ p₂ p₃ : P) : ∡ p₃ p₂ p₁ = -∡ p₁ p₂ p₃ := o.oangle_rev _ _ #align euclidean_geometry.oangle_rev EuclideanGeometry.oangle_rev @[simp] theorem oangle_add_oangle_rev (p₁ p₂ p₃ : P) : ∡ p₁ p₂ p₃ + ∡ p₃ p₂ p₁ = 0 := o.oangle_add_oangle_rev _ _ #align euclidean_geometry.oangle_add_oangle_rev EuclideanGeometry.oangle_add_oangle_rev theorem oangle_eq_zero_iff_oangle_rev_eq_zero {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = 0 ↔ ∡ p₃ p₂ p₁ = 0 := o.oangle_eq_zero_iff_oangle_rev_eq_zero #align euclidean_geometry.oangle_eq_zero_iff_oangle_rev_eq_zero EuclideanGeometry.oangle_eq_zero_iff_oangle_rev_eq_zero theorem oangle_eq_pi_iff_oangle_rev_eq_pi {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = π ↔ ∡ p₃ p₂ p₁ = π := o.oangle_eq_pi_iff_oangle_rev_eq_pi #align euclidean_geometry.oangle_eq_pi_iff_oangle_rev_eq_pi EuclideanGeometry.oangle_eq_pi_iff_oangle_rev_eq_pi theorem oangle_ne_zero_and_ne_pi_iff_affineIndependent {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ ≠ 0 ∧ ∡ p₁ p₂ p₃ ≠ π ↔ AffineIndependent ℝ ![p₁, p₂, p₃] := by rw [oangle, o.oangle_ne_zero_and_ne_pi_iff_linearIndependent, affineIndependent_iff_linearIndependent_vsub ℝ _ (1 : Fin 3), ← linearIndependent_equiv (finSuccAboveEquiv (1 : Fin 3)).toEquiv] convert Iff.rfl ext i fin_cases i <;> rfl #align euclidean_geometry.oangle_ne_zero_and_ne_pi_iff_affine_independent EuclideanGeometry.oangle_ne_zero_and_ne_pi_iff_affineIndependent theorem oangle_eq_zero_or_eq_pi_iff_collinear {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = 0 ∨ ∡ p₁ p₂ p₃ = π ↔ Collinear ℝ ({p₁, p₂, p₃} : Set P) := by rw [← not_iff_not, not_or, oangle_ne_zero_and_ne_pi_iff_affineIndependent, affineIndependent_iff_not_collinear_set] #align euclidean_geometry.oangle_eq_zero_or_eq_pi_iff_collinear EuclideanGeometry.oangle_eq_zero_or_eq_pi_iff_collinear theorem oangle_sign_eq_zero_iff_collinear {p₁ p₂ p₃ : P} : (∡ p₁ p₂ p₃).sign = 0 ↔ Collinear ℝ ({p₁, p₂, p₃} : Set P) := by rw [Real.Angle.sign_eq_zero_iff, oangle_eq_zero_or_eq_pi_iff_collinear] theorem affineIndependent_iff_of_two_zsmul_oangle_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (h : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆) : AffineIndependent ℝ ![p₁, p₂, p₃] ↔ AffineIndependent ℝ ![p₄, p₅, p₆] := by simp_rw [← oangle_ne_zero_and_ne_pi_iff_affineIndependent, ← Real.Angle.two_zsmul_ne_zero_iff, h] #align euclidean_geometry.affine_independent_iff_of_two_zsmul_oangle_eq EuclideanGeometry.affineIndependent_iff_of_two_zsmul_oangle_eq theorem collinear_iff_of_two_zsmul_oangle_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (h : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆) : Collinear ℝ ({p₁, p₂, p₃} : Set P) ↔ Collinear ℝ ({p₄, p₅, p₆} : Set P) := by simp_rw [← oangle_eq_zero_or_eq_pi_iff_collinear, ← Real.Angle.two_zsmul_eq_zero_iff, h] #align euclidean_geometry.collinear_iff_of_two_zsmul_oangle_eq EuclideanGeometry.collinear_iff_of_two_zsmul_oangle_eq theorem two_zsmul_oangle_of_vectorSpan_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (h₁₂₄₅ : vectorSpan ℝ ({p₁, p₂} : Set P) = vectorSpan ℝ ({p₄, p₅} : Set P)) (h₃₂₆₅ : vectorSpan ℝ ({p₃, p₂} : Set P) = vectorSpan ℝ ({p₆, p₅} : Set P)) : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆ := by simp_rw [vectorSpan_pair] at h₁₂₄₅ h₃₂₆₅ exact o.two_zsmul_oangle_of_span_eq_of_span_eq h₁₂₄₅ h₃₂₆₅ #align euclidean_geometry.two_zsmul_oangle_of_vector_span_eq EuclideanGeometry.two_zsmul_oangle_of_vectorSpan_eq theorem two_zsmul_oangle_of_parallel {p₁ p₂ p₃ p₄ p₅ p₆ : P} (h₁₂₄₅ : line[ℝ, p₁, p₂] ∥ line[ℝ, p₄, p₅]) (h₃₂₆₅ : line[ℝ, p₃, p₂] ∥ line[ℝ, p₆, p₅]) : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆ := by rw [AffineSubspace.affineSpan_pair_parallel_iff_vectorSpan_eq] at h₁₂₄₅ h₃₂₆₅ exact two_zsmul_oangle_of_vectorSpan_eq h₁₂₄₅ h₃₂₆₅ #align euclidean_geometry.two_zsmul_oangle_of_parallel EuclideanGeometry.two_zsmul_oangle_of_parallel @[simp] theorem oangle_add {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) : ∡ p₁ p p₂ + ∡ p₂ p p₃ = ∡ p₁ p p₃ := o.oangle_add (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) (vsub_ne_zero.2 hp₃) #align euclidean_geometry.oangle_add EuclideanGeometry.oangle_add @[simp] theorem oangle_add_swap {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) : ∡ p₂ p p₃ + ∡ p₁ p p₂ = ∡ p₁ p p₃ := o.oangle_add_swap (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) (vsub_ne_zero.2 hp₃) #align euclidean_geometry.oangle_add_swap EuclideanGeometry.oangle_add_swap @[simp] theorem oangle_sub_left {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) : ∡ p₁ p p₃ - ∡ p₁ p p₂ = ∡ p₂ p p₃ := o.oangle_sub_left (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) (vsub_ne_zero.2 hp₃) #align euclidean_geometry.oangle_sub_left EuclideanGeometry.oangle_sub_left @[simp] theorem oangle_sub_right {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) : ∡ p₁ p p₃ - ∡ p₂ p p₃ = ∡ p₁ p p₂ := o.oangle_sub_right (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) (vsub_ne_zero.2 hp₃) #align euclidean_geometry.oangle_sub_right EuclideanGeometry.oangle_sub_right @[simp] theorem oangle_add_cyc3 {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) : ∡ p₁ p p₂ + ∡ p₂ p p₃ + ∡ p₃ p p₁ = 0 := o.oangle_add_cyc3 (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) (vsub_ne_zero.2 hp₃) #align euclidean_geometry.oangle_add_cyc3 EuclideanGeometry.oangle_add_cyc3 theorem oangle_eq_oangle_of_dist_eq {p₁ p₂ p₃ : P} (h : dist p₁ p₂ = dist p₁ p₃) : ∡ p₁ p₂ p₃ = ∡ p₂ p₃ p₁ := by simp_rw [dist_eq_norm_vsub V] at h rw [oangle, oangle, ← vsub_sub_vsub_cancel_left p₃ p₂ p₁, ← vsub_sub_vsub_cancel_left p₂ p₃ p₁, o.oangle_sub_eq_oangle_sub_rev_of_norm_eq h] #align euclidean_geometry.oangle_eq_oangle_of_dist_eq EuclideanGeometry.oangle_eq_oangle_of_dist_eq theorem oangle_eq_pi_sub_two_zsmul_oangle_of_dist_eq {p₁ p₂ p₃ : P} (hn : p₂ ≠ p₃) (h : dist p₁ p₂ = dist p₁ p₃) : ∡ p₃ p₁ p₂ = π - (2 : ℤ) • ∡ p₁ p₂ p₃ := by simp_rw [dist_eq_norm_vsub V] at h rw [oangle, oangle] convert o.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq _ h using 1 · rw [← neg_vsub_eq_vsub_rev p₁ p₃, ← neg_vsub_eq_vsub_rev p₁ p₂, o.oangle_neg_neg] · rw [← o.oangle_sub_eq_oangle_sub_rev_of_norm_eq h]; simp · simpa using hn #align euclidean_geometry.oangle_eq_pi_sub_two_zsmul_oangle_of_dist_eq EuclideanGeometry.oangle_eq_pi_sub_two_zsmul_oangle_of_dist_eq theorem abs_oangle_right_toReal_lt_pi_div_two_of_dist_eq {p₁ p₂ p₃ : P} (h : dist p₁ p₂ = dist p₁ p₃) : |(∡ p₁ p₂ p₃).toReal| < π / 2 := by simp_rw [dist_eq_norm_vsub V] at h rw [oangle, ← vsub_sub_vsub_cancel_left p₃ p₂ p₁] exact o.abs_oangle_sub_right_toReal_lt_pi_div_two h #align euclidean_geometry.abs_oangle_right_to_real_lt_pi_div_two_of_dist_eq EuclideanGeometry.abs_oangle_right_toReal_lt_pi_div_two_of_dist_eq theorem abs_oangle_left_toReal_lt_pi_div_two_of_dist_eq {p₁ p₂ p₃ : P} (h : dist p₁ p₂ = dist p₁ p₃) : |(∡ p₂ p₃ p₁).toReal| < π / 2 := oangle_eq_oangle_of_dist_eq h ▸ abs_oangle_right_toReal_lt_pi_div_two_of_dist_eq h #align euclidean_geometry.abs_oangle_left_to_real_lt_pi_div_two_of_dist_eq EuclideanGeometry.abs_oangle_left_toReal_lt_pi_div_two_of_dist_eq theorem cos_oangle_eq_cos_angle {p p₁ p₂ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) : Real.Angle.cos (∡ p₁ p p₂) = Real.cos (∠ p₁ p p₂) := o.cos_oangle_eq_cos_angle (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) #align euclidean_geometry.cos_oangle_eq_cos_angle EuclideanGeometry.cos_oangle_eq_cos_angle theorem oangle_eq_angle_or_eq_neg_angle {p p₁ p₂ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) : ∡ p₁ p p₂ = ∠ p₁ p p₂ ∨ ∡ p₁ p p₂ = -∠ p₁ p p₂ := o.oangle_eq_angle_or_eq_neg_angle (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) #align euclidean_geometry.oangle_eq_angle_or_eq_neg_angle EuclideanGeometry.oangle_eq_angle_or_eq_neg_angle theorem angle_eq_abs_oangle_toReal {p p₁ p₂ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) : ∠ p₁ p p₂ = |(∡ p₁ p p₂).toReal| := o.angle_eq_abs_oangle_toReal (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) #align euclidean_geometry.angle_eq_abs_oangle_to_real EuclideanGeometry.angle_eq_abs_oangle_toReal theorem eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero {p p₁ p₂ : P} (h : (∡ p₁ p p₂).sign = 0) : p₁ = p ∨ p₂ = p ∨ ∠ p₁ p p₂ = 0 ∨ ∠ p₁ p p₂ = π := by convert o.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero h <;> simp #align euclidean_geometry.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero EuclideanGeometry.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero theorem oangle_eq_of_angle_eq_of_sign_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (h : ∠ p₁ p₂ p₃ = ∠ p₄ p₅ p₆) (hs : (∡ p₁ p₂ p₃).sign = (∡ p₄ p₅ p₆).sign) : ∡ p₁ p₂ p₃ = ∡ p₄ p₅ p₆ := o.oangle_eq_of_angle_eq_of_sign_eq h hs #align euclidean_geometry.oangle_eq_of_angle_eq_of_sign_eq EuclideanGeometry.oangle_eq_of_angle_eq_of_sign_eq theorem angle_eq_iff_oangle_eq_of_sign_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (hp₁ : p₁ ≠ p₂) (hp₃ : p₃ ≠ p₂) (hp₄ : p₄ ≠ p₅) (hp₆ : p₆ ≠ p₅) (hs : (∡ p₁ p₂ p₃).sign = (∡ p₄ p₅ p₆).sign) : ∠ p₁ p₂ p₃ = ∠ p₄ p₅ p₆ ↔ ∡ p₁ p₂ p₃ = ∡ p₄ p₅ p₆ := o.angle_eq_iff_oangle_eq_of_sign_eq (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₃) (vsub_ne_zero.2 hp₄) (vsub_ne_zero.2 hp₆) hs #align euclidean_geometry.angle_eq_iff_oangle_eq_of_sign_eq EuclideanGeometry.angle_eq_iff_oangle_eq_of_sign_eq theorem oangle_eq_angle_of_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) : ∡ p₁ p₂ p₃ = ∠ p₁ p₂ p₃ := o.oangle_eq_angle_of_sign_eq_one h #align euclidean_geometry.oangle_eq_angle_of_sign_eq_one EuclideanGeometry.oangle_eq_angle_of_sign_eq_one theorem oangle_eq_neg_angle_of_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) : ∡ p₁ p₂ p₃ = -∠ p₁ p₂ p₃ := o.oangle_eq_neg_angle_of_sign_eq_neg_one h #align euclidean_geometry.oangle_eq_neg_angle_of_sign_eq_neg_one EuclideanGeometry.oangle_eq_neg_angle_of_sign_eq_neg_one theorem oangle_eq_zero_iff_angle_eq_zero {p p₁ p₂ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) : ∡ p₁ p p₂ = 0 ↔ ∠ p₁ p p₂ = 0 := o.oangle_eq_zero_iff_angle_eq_zero (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) #align euclidean_geometry.oangle_eq_zero_iff_angle_eq_zero EuclideanGeometry.oangle_eq_zero_iff_angle_eq_zero theorem oangle_eq_pi_iff_angle_eq_pi {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = π ↔ ∠ p₁ p₂ p₃ = π := o.oangle_eq_pi_iff_angle_eq_pi #align euclidean_geometry.oangle_eq_pi_iff_angle_eq_pi EuclideanGeometry.oangle_eq_pi_iff_angle_eq_pi theorem angle_eq_pi_div_two_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) : ∠ p₁ p₂ p₃ = π / 2 := by rw [angle, ← InnerProductGeometry.inner_eq_zero_iff_angle_eq_pi_div_two] exact o.inner_eq_zero_of_oangle_eq_pi_div_two h #align euclidean_geometry.angle_eq_pi_div_two_of_oangle_eq_pi_div_two EuclideanGeometry.angle_eq_pi_div_two_of_oangle_eq_pi_div_two theorem angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) : ∠ p₃ p₂ p₁ = π / 2 := by rw [angle_comm] exact angle_eq_pi_div_two_of_oangle_eq_pi_div_two h #align euclidean_geometry.angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two EuclideanGeometry.angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two theorem angle_eq_pi_div_two_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(-π / 2)) : ∠ p₁ p₂ p₃ = π / 2 := by rw [angle, ← InnerProductGeometry.inner_eq_zero_iff_angle_eq_pi_div_two] exact o.inner_eq_zero_of_oangle_eq_neg_pi_div_two h #align euclidean_geometry.angle_eq_pi_div_two_of_oangle_eq_neg_pi_div_two EuclideanGeometry.angle_eq_pi_div_two_of_oangle_eq_neg_pi_div_two theorem angle_rev_eq_pi_div_two_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(-π / 2)) : ∠ p₃ p₂ p₁ = π / 2 := by rw [angle_comm] exact angle_eq_pi_div_two_of_oangle_eq_neg_pi_div_two h #align euclidean_geometry.angle_rev_eq_pi_div_two_of_oangle_eq_neg_pi_div_two EuclideanGeometry.angle_rev_eq_pi_div_two_of_oangle_eq_neg_pi_div_two theorem oangle_swap₁₂_sign (p₁ p₂ p₃ : P) : -(∡ p₁ p₂ p₃).sign = (∡ p₂ p₁ p₃).sign := by rw [eq_comm, oangle, oangle, ← o.oangle_neg_neg, neg_vsub_eq_vsub_rev, neg_vsub_eq_vsub_rev, ← vsub_sub_vsub_cancel_left p₁ p₃ p₂, ← neg_vsub_eq_vsub_rev p₃ p₂, sub_eq_add_neg, neg_vsub_eq_vsub_rev p₂ p₁, add_comm, ← @neg_one_smul ℝ] nth_rw 2 [← one_smul ℝ (p₁ -ᵥ p₂)] rw [o.oangle_sign_smul_add_smul_right] simp #align euclidean_geometry.oangle_swap₁₂_sign EuclideanGeometry.oangle_swap₁₂_sign theorem oangle_swap₁₃_sign (p₁ p₂ p₃ : P) : -(∡ p₁ p₂ p₃).sign = (∡ p₃ p₂ p₁).sign := by rw [oangle_rev, Real.Angle.sign_neg, neg_neg] #align euclidean_geometry.oangle_swap₁₃_sign EuclideanGeometry.oangle_swap₁₃_sign theorem oangle_swap₂₃_sign (p₁ p₂ p₃ : P) : -(∡ p₁ p₂ p₃).sign = (∡ p₁ p₃ p₂).sign := by rw [oangle_swap₁₃_sign, ← oangle_swap₁₂_sign, oangle_swap₁₃_sign] #align euclidean_geometry.oangle_swap₂₃_sign EuclideanGeometry.oangle_swap₂₃_sign theorem oangle_rotate_sign (p₁ p₂ p₃ : P) : (∡ p₂ p₃ p₁).sign = (∡ p₁ p₂ p₃).sign := by rw [← oangle_swap₁₂_sign, oangle_swap₁₃_sign] #align euclidean_geometry.oangle_rotate_sign EuclideanGeometry.oangle_rotate_sign
Mathlib/Geometry/Euclidean/Angle/Oriented/Affine.lean
476
477
theorem oangle_eq_pi_iff_sbtw {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = π ↔ Sbtw ℝ p₁ p₂ p₃ := by
rw [oangle_eq_pi_iff_angle_eq_pi, angle_eq_pi_iff_sbtw]
import Mathlib.Analysis.MeanInequalities import Mathlib.Analysis.MeanInequalitiesPow import Mathlib.Analysis.SpecialFunctions.Pow.Continuity import Mathlib.Data.Set.Image import Mathlib.Topology.Algebra.Order.LiminfLimsup #align_import analysis.normed_space.lp_space from "leanprover-community/mathlib"@"de83b43717abe353f425855fcf0cedf9ea0fe8a4" noncomputable section open scoped NNReal ENNReal Function variable {α : Type*} {E : α → Type*} {p q : ℝ≥0∞} [∀ i, NormedAddCommGroup (E i)] def Memℓp (f : ∀ i, E i) (p : ℝ≥0∞) : Prop := if p = 0 then Set.Finite { i | f i ≠ 0 } else if p = ∞ then BddAbove (Set.range fun i => ‖f i‖) else Summable fun i => ‖f i‖ ^ p.toReal #align mem_ℓp Memℓp theorem memℓp_zero_iff {f : ∀ i, E i} : Memℓp f 0 ↔ Set.Finite { i | f i ≠ 0 } := by dsimp [Memℓp] rw [if_pos rfl] #align mem_ℓp_zero_iff memℓp_zero_iff theorem memℓp_zero {f : ∀ i, E i} (hf : Set.Finite { i | f i ≠ 0 }) : Memℓp f 0 := memℓp_zero_iff.2 hf #align mem_ℓp_zero memℓp_zero theorem memℓp_infty_iff {f : ∀ i, E i} : Memℓp f ∞ ↔ BddAbove (Set.range fun i => ‖f i‖) := by dsimp [Memℓp] rw [if_neg ENNReal.top_ne_zero, if_pos rfl] #align mem_ℓp_infty_iff memℓp_infty_iff theorem memℓp_infty {f : ∀ i, E i} (hf : BddAbove (Set.range fun i => ‖f i‖)) : Memℓp f ∞ := memℓp_infty_iff.2 hf #align mem_ℓp_infty memℓp_infty theorem memℓp_gen_iff (hp : 0 < p.toReal) {f : ∀ i, E i} : Memℓp f p ↔ Summable fun i => ‖f i‖ ^ p.toReal := by rw [ENNReal.toReal_pos_iff] at hp dsimp [Memℓp] rw [if_neg hp.1.ne', if_neg hp.2.ne] #align mem_ℓp_gen_iff memℓp_gen_iff theorem memℓp_gen {f : ∀ i, E i} (hf : Summable fun i => ‖f i‖ ^ p.toReal) : Memℓp f p := by rcases p.trichotomy with (rfl | rfl | hp) · apply memℓp_zero have H : Summable fun _ : α => (1 : ℝ) := by simpa using hf exact (Set.Finite.of_summable_const (by norm_num) H).subset (Set.subset_univ _) · apply memℓp_infty have H : Summable fun _ : α => (1 : ℝ) := by simpa using hf simpa using ((Set.Finite.of_summable_const (by norm_num) H).image fun i => ‖f i‖).bddAbove exact (memℓp_gen_iff hp).2 hf #align mem_ℓp_gen memℓp_gen theorem memℓp_gen' {C : ℝ} {f : ∀ i, E i} (hf : ∀ s : Finset α, ∑ i ∈ s, ‖f i‖ ^ p.toReal ≤ C) : Memℓp f p := by apply memℓp_gen use ⨆ s : Finset α, ∑ i ∈ s, ‖f i‖ ^ p.toReal apply hasSum_of_isLUB_of_nonneg · intro b exact Real.rpow_nonneg (norm_nonneg _) _ apply isLUB_ciSup use C rintro - ⟨s, rfl⟩ exact hf s #align mem_ℓp_gen' memℓp_gen' theorem zero_memℓp : Memℓp (0 : ∀ i, E i) p := by rcases p.trichotomy with (rfl | rfl | hp) · apply memℓp_zero simp · apply memℓp_infty simp only [norm_zero, Pi.zero_apply] exact bddAbove_singleton.mono Set.range_const_subset · apply memℓp_gen simp [Real.zero_rpow hp.ne', summable_zero] #align zero_mem_ℓp zero_memℓp theorem zero_mem_ℓp' : Memℓp (fun i : α => (0 : E i)) p := zero_memℓp #align zero_mem_ℓp' zero_mem_ℓp' namespace Memℓp theorem finite_dsupport {f : ∀ i, E i} (hf : Memℓp f 0) : Set.Finite { i | f i ≠ 0 } := memℓp_zero_iff.1 hf #align mem_ℓp.finite_dsupport Memℓp.finite_dsupport theorem bddAbove {f : ∀ i, E i} (hf : Memℓp f ∞) : BddAbove (Set.range fun i => ‖f i‖) := memℓp_infty_iff.1 hf #align mem_ℓp.bdd_above Memℓp.bddAbove theorem summable (hp : 0 < p.toReal) {f : ∀ i, E i} (hf : Memℓp f p) : Summable fun i => ‖f i‖ ^ p.toReal := (memℓp_gen_iff hp).1 hf #align mem_ℓp.summable Memℓp.summable
Mathlib/Analysis/NormedSpace/lpSpace.lean
160
167
theorem neg {f : ∀ i, E i} (hf : Memℓp f p) : Memℓp (-f) p := by
rcases p.trichotomy with (rfl | rfl | hp) · apply memℓp_zero simp [hf.finite_dsupport] · apply memℓp_infty simpa using hf.bddAbove · apply memℓp_gen simpa using hf.summable hp
import Mathlib.Algebra.Group.Units import Mathlib.Algebra.GroupWithZero.Basic import Mathlib.Logic.Equiv.Defs import Mathlib.Tactic.Contrapose import Mathlib.Tactic.Nontriviality import Mathlib.Tactic.Spread import Mathlib.Util.AssertExists #align_import algebra.group_with_zero.units.basic from "leanprover-community/mathlib"@"df5e9937a06fdd349fc60106f54b84d47b1434f0" -- Guard against import creep assert_not_exists Multiplicative assert_not_exists DenselyOrdered variable {α M₀ G₀ M₀' G₀' F F' : Type*} variable [MonoidWithZero M₀] @[simp] theorem isUnit_zero_iff : IsUnit (0 : M₀) ↔ (0 : M₀) = 1 := ⟨fun ⟨⟨_, a, (a0 : 0 * a = 1), _⟩, rfl⟩ => by rwa [zero_mul] at a0, fun h => @isUnit_of_subsingleton _ _ (subsingleton_of_zero_eq_one h) 0⟩ #align is_unit_zero_iff isUnit_zero_iff -- Porting note: removed `simp` tag because `simpNF` says it's redundant theorem not_isUnit_zero [Nontrivial M₀] : ¬IsUnit (0 : M₀) := mt isUnit_zero_iff.1 zero_ne_one #align not_is_unit_zero not_isUnit_zero namespace Ring open scoped Classical noncomputable def inverse : M₀ → M₀ := fun x => if h : IsUnit x then ((h.unit⁻¹ : M₀ˣ) : M₀) else 0 #align ring.inverse Ring.inverse @[simp]
Mathlib/Algebra/GroupWithZero/Units/Basic.lean
98
99
theorem inverse_unit (u : M₀ˣ) : inverse (u : M₀) = (u⁻¹ : M₀ˣ) := by
rw [inverse, dif_pos u.isUnit, IsUnit.unit_of_val_units]
import Mathlib.NumberTheory.BernoulliPolynomials import Mathlib.MeasureTheory.Integral.IntervalIntegral import Mathlib.Analysis.Calculus.Deriv.Polynomial import Mathlib.Analysis.Fourier.AddCircle import Mathlib.Analysis.PSeries #align_import number_theory.zeta_values from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" noncomputable section open scoped Nat Real Interval open Complex MeasureTheory Set intervalIntegral local notation "𝕌" => UnitAddCircle section BernoulliFunProps def bernoulliFun (k : ℕ) (x : ℝ) : ℝ := (Polynomial.map (algebraMap ℚ ℝ) (Polynomial.bernoulli k)).eval x #align bernoulli_fun bernoulliFun theorem bernoulliFun_eval_zero (k : ℕ) : bernoulliFun k 0 = bernoulli k := by rw [bernoulliFun, Polynomial.eval_zero_map, Polynomial.bernoulli_eval_zero, eq_ratCast] #align bernoulli_fun_eval_zero bernoulliFun_eval_zero
Mathlib/NumberTheory/ZetaValues.lean
53
56
theorem bernoulliFun_endpoints_eq_of_ne_one {k : ℕ} (hk : k ≠ 1) : bernoulliFun k 1 = bernoulliFun k 0 := by
rw [bernoulliFun_eval_zero, bernoulliFun, Polynomial.eval_one_map, Polynomial.bernoulli_eval_one, bernoulli_eq_bernoulli'_of_ne_one hk, eq_ratCast]
import Mathlib.Data.Option.NAry import Mathlib.Data.Seq.Computation #align_import data.seq.seq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" namespace Stream' universe u v w def IsSeq {α : Type u} (s : Stream' (Option α)) : Prop := ∀ {n : ℕ}, s n = none → s (n + 1) = none #align stream.is_seq Stream'.IsSeq def Seq (α : Type u) : Type u := { f : Stream' (Option α) // f.IsSeq } #align stream.seq Stream'.Seq def Seq1 (α) := α × Seq α #align stream.seq1 Stream'.Seq1 namespace Seq variable {α : Type u} {β : Type v} {γ : Type w} def nil : Seq α := ⟨Stream'.const none, fun {_} _ => rfl⟩ #align stream.seq.nil Stream'.Seq.nil instance : Inhabited (Seq α) := ⟨nil⟩ def cons (a : α) (s : Seq α) : Seq α := ⟨some a::s.1, by rintro (n | _) h · contradiction · exact s.2 h⟩ #align stream.seq.cons Stream'.Seq.cons @[simp] theorem val_cons (s : Seq α) (x : α) : (cons x s).val = some x::s.val := rfl #align stream.seq.val_cons Stream'.Seq.val_cons def get? : Seq α → ℕ → Option α := Subtype.val #align stream.seq.nth Stream'.Seq.get? @[simp] theorem get?_mk (f hf) : @get? α ⟨f, hf⟩ = f := rfl #align stream.seq.nth_mk Stream'.Seq.get?_mk @[simp] theorem get?_nil (n : ℕ) : (@nil α).get? n = none := rfl #align stream.seq.nth_nil Stream'.Seq.get?_nil @[simp] theorem get?_cons_zero (a : α) (s : Seq α) : (cons a s).get? 0 = some a := rfl #align stream.seq.nth_cons_zero Stream'.Seq.get?_cons_zero @[simp] theorem get?_cons_succ (a : α) (s : Seq α) (n : ℕ) : (cons a s).get? (n + 1) = s.get? n := rfl #align stream.seq.nth_cons_succ Stream'.Seq.get?_cons_succ @[ext] protected theorem ext {s t : Seq α} (h : ∀ n : ℕ, s.get? n = t.get? n) : s = t := Subtype.eq <| funext h #align stream.seq.ext Stream'.Seq.ext theorem cons_injective2 : Function.Injective2 (cons : α → Seq α → Seq α) := fun x y s t h => ⟨by rw [← Option.some_inj, ← get?_cons_zero, h, get?_cons_zero], Seq.ext fun n => by simp_rw [← get?_cons_succ x s n, h, get?_cons_succ]⟩ #align stream.seq.cons_injective2 Stream'.Seq.cons_injective2 theorem cons_left_injective (s : Seq α) : Function.Injective fun x => cons x s := cons_injective2.left _ #align stream.seq.cons_left_injective Stream'.Seq.cons_left_injective theorem cons_right_injective (x : α) : Function.Injective (cons x) := cons_injective2.right _ #align stream.seq.cons_right_injective Stream'.Seq.cons_right_injective def TerminatedAt (s : Seq α) (n : ℕ) : Prop := s.get? n = none #align stream.seq.terminated_at Stream'.Seq.TerminatedAt instance terminatedAtDecidable (s : Seq α) (n : ℕ) : Decidable (s.TerminatedAt n) := decidable_of_iff' (s.get? n).isNone <| by unfold TerminatedAt; cases s.get? n <;> simp #align stream.seq.terminated_at_decidable Stream'.Seq.terminatedAtDecidable def Terminates (s : Seq α) : Prop := ∃ n : ℕ, s.TerminatedAt n #align stream.seq.terminates Stream'.Seq.Terminates theorem not_terminates_iff {s : Seq α} : ¬s.Terminates ↔ ∀ n, (s.get? n).isSome := by simp only [Terminates, TerminatedAt, ← Ne.eq_def, Option.ne_none_iff_isSome, not_exists, iff_self] #align stream.seq.not_terminates_iff Stream'.Seq.not_terminates_iff @[simp] def omap (f : β → γ) : Option (α × β) → Option (α × γ) | none => none | some (a, b) => some (a, f b) #align stream.seq.omap Stream'.Seq.omap def head (s : Seq α) : Option α := get? s 0 #align stream.seq.head Stream'.Seq.head def tail (s : Seq α) : Seq α := ⟨s.1.tail, fun n' => by cases' s with f al exact al n'⟩ #align stream.seq.tail Stream'.Seq.tail protected def Mem (a : α) (s : Seq α) := some a ∈ s.1 #align stream.seq.mem Stream'.Seq.Mem instance : Membership α (Seq α) := ⟨Seq.Mem⟩ theorem le_stable (s : Seq α) {m n} (h : m ≤ n) : s.get? m = none → s.get? n = none := by cases' s with f al induction' h with n _ IH exacts [id, fun h2 => al (IH h2)] #align stream.seq.le_stable Stream'.Seq.le_stable theorem terminated_stable : ∀ (s : Seq α) {m n : ℕ}, m ≤ n → s.TerminatedAt m → s.TerminatedAt n := le_stable #align stream.seq.terminated_stable Stream'.Seq.terminated_stable theorem ge_stable (s : Seq α) {aₙ : α} {n m : ℕ} (m_le_n : m ≤ n) (s_nth_eq_some : s.get? n = some aₙ) : ∃ aₘ : α, s.get? m = some aₘ := have : s.get? n ≠ none := by simp [s_nth_eq_some] have : s.get? m ≠ none := mt (s.le_stable m_le_n) this Option.ne_none_iff_exists'.mp this #align stream.seq.ge_stable Stream'.Seq.ge_stable theorem not_mem_nil (a : α) : a ∉ @nil α := fun ⟨_, (h : some a = none)⟩ => by injection h #align stream.seq.not_mem_nil Stream'.Seq.not_mem_nil theorem mem_cons (a : α) : ∀ s : Seq α, a ∈ cons a s | ⟨_, _⟩ => Stream'.mem_cons (some a) _ #align stream.seq.mem_cons Stream'.Seq.mem_cons theorem mem_cons_of_mem (y : α) {a : α} : ∀ {s : Seq α}, a ∈ s → a ∈ cons y s | ⟨_, _⟩ => Stream'.mem_cons_of_mem (some y) #align stream.seq.mem_cons_of_mem Stream'.Seq.mem_cons_of_mem theorem eq_or_mem_of_mem_cons {a b : α} : ∀ {s : Seq α}, a ∈ cons b s → a = b ∨ a ∈ s | ⟨f, al⟩, h => (Stream'.eq_or_mem_of_mem_cons h).imp_left fun h => by injection h #align stream.seq.eq_or_mem_of_mem_cons Stream'.Seq.eq_or_mem_of_mem_cons @[simp] theorem mem_cons_iff {a b : α} {s : Seq α} : a ∈ cons b s ↔ a = b ∨ a ∈ s := ⟨eq_or_mem_of_mem_cons, by rintro (rfl | m) <;> [apply mem_cons; exact mem_cons_of_mem _ m]⟩ #align stream.seq.mem_cons_iff Stream'.Seq.mem_cons_iff def destruct (s : Seq α) : Option (Seq1 α) := (fun a' => (a', s.tail)) <$> get? s 0 #align stream.seq.destruct Stream'.Seq.destruct theorem destruct_eq_nil {s : Seq α} : destruct s = none → s = nil := by dsimp [destruct] induction' f0 : get? s 0 <;> intro h · apply Subtype.eq funext n induction' n with n IH exacts [f0, s.2 IH] · contradiction #align stream.seq.destruct_eq_nil Stream'.Seq.destruct_eq_nil
Mathlib/Data/Seq/Seq.lean
217
228
theorem destruct_eq_cons {s : Seq α} {a s'} : destruct s = some (a, s') → s = cons a s' := by
dsimp [destruct] induction' f0 : get? s 0 with a' <;> intro h · contradiction · cases' s with f al injections _ h1 h2 rw [← h2] apply Subtype.eq dsimp [tail, cons] rw [h1] at f0 rw [← f0] exact (Stream'.eta f).symm
import Mathlib.Dynamics.Ergodic.MeasurePreserving import Mathlib.LinearAlgebra.Determinant import Mathlib.LinearAlgebra.Matrix.Diagonal import Mathlib.LinearAlgebra.Matrix.Transvection import Mathlib.MeasureTheory.Group.LIntegral import Mathlib.MeasureTheory.Integral.Marginal import Mathlib.MeasureTheory.Measure.Stieltjes import Mathlib.MeasureTheory.Measure.Haar.OfBasis #align_import measure_theory.measure.lebesgue.basic from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" assert_not_exists MeasureTheory.integral noncomputable section open scoped Classical open Set Filter MeasureTheory MeasureTheory.Measure TopologicalSpace open ENNReal (ofReal) open scoped ENNReal NNReal Topology namespace Real variable {ι : Type*} [Fintype ι] theorem volume_eq_stieltjes_id : (volume : Measure ℝ) = StieltjesFunction.id.measure := by haveI : IsAddLeftInvariant StieltjesFunction.id.measure := ⟨fun a => Eq.symm <| Real.measure_ext_Ioo_rat fun p q => by simp only [Measure.map_apply (measurable_const_add a) measurableSet_Ioo, sub_sub_sub_cancel_right, StieltjesFunction.measure_Ioo, StieltjesFunction.id_leftLim, StieltjesFunction.id_apply, id, preimage_const_add_Ioo]⟩ have A : StieltjesFunction.id.measure (stdOrthonormalBasis ℝ ℝ).toBasis.parallelepiped = 1 := by change StieltjesFunction.id.measure (parallelepiped (stdOrthonormalBasis ℝ ℝ)) = 1 rcases parallelepiped_orthonormalBasis_one_dim (stdOrthonormalBasis ℝ ℝ) with (H | H) <;> simp only [H, StieltjesFunction.measure_Icc, StieltjesFunction.id_apply, id, tsub_zero, StieltjesFunction.id_leftLim, sub_neg_eq_add, zero_add, ENNReal.ofReal_one] conv_rhs => rw [addHaarMeasure_unique StieltjesFunction.id.measure (stdOrthonormalBasis ℝ ℝ).toBasis.parallelepiped, A] simp only [volume, Basis.addHaar, one_smul] #align real.volume_eq_stieltjes_id Real.volume_eq_stieltjes_id theorem volume_val (s) : volume s = StieltjesFunction.id.measure s := by simp [volume_eq_stieltjes_id] #align real.volume_val Real.volume_val @[simp] theorem volume_Ico {a b : ℝ} : volume (Ico a b) = ofReal (b - a) := by simp [volume_val] #align real.volume_Ico Real.volume_Ico @[simp] theorem volume_Icc {a b : ℝ} : volume (Icc a b) = ofReal (b - a) := by simp [volume_val] #align real.volume_Icc Real.volume_Icc @[simp] theorem volume_Ioo {a b : ℝ} : volume (Ioo a b) = ofReal (b - a) := by simp [volume_val] #align real.volume_Ioo Real.volume_Ioo @[simp] theorem volume_Ioc {a b : ℝ} : volume (Ioc a b) = ofReal (b - a) := by simp [volume_val] #align real.volume_Ioc Real.volume_Ioc -- @[simp] -- Porting note (#10618): simp can prove this theorem volume_singleton {a : ℝ} : volume ({a} : Set ℝ) = 0 := by simp [volume_val] #align real.volume_singleton Real.volume_singleton -- @[simp] -- Porting note (#10618): simp can prove this, after mathlib4#4628 theorem volume_univ : volume (univ : Set ℝ) = ∞ := ENNReal.eq_top_of_forall_nnreal_le fun r => calc (r : ℝ≥0∞) = volume (Icc (0 : ℝ) r) := by simp _ ≤ volume univ := measure_mono (subset_univ _) #align real.volume_univ Real.volume_univ @[simp] theorem volume_ball (a r : ℝ) : volume (Metric.ball a r) = ofReal (2 * r) := by rw [ball_eq_Ioo, volume_Ioo, ← sub_add, add_sub_cancel_left, two_mul] #align real.volume_ball Real.volume_ball @[simp] theorem volume_closedBall (a r : ℝ) : volume (Metric.closedBall a r) = ofReal (2 * r) := by rw [closedBall_eq_Icc, volume_Icc, ← sub_add, add_sub_cancel_left, two_mul] #align real.volume_closed_ball Real.volume_closedBall @[simp] theorem volume_emetric_ball (a : ℝ) (r : ℝ≥0∞) : volume (EMetric.ball a r) = 2 * r := by rcases eq_or_ne r ∞ with (rfl | hr) · rw [Metric.emetric_ball_top, volume_univ, two_mul, _root_.top_add] · lift r to ℝ≥0 using hr rw [Metric.emetric_ball_nnreal, volume_ball, two_mul, ← NNReal.coe_add, ENNReal.ofReal_coe_nnreal, ENNReal.coe_add, two_mul] #align real.volume_emetric_ball Real.volume_emetric_ball @[simp] theorem volume_emetric_closedBall (a : ℝ) (r : ℝ≥0∞) : volume (EMetric.closedBall a r) = 2 * r := by rcases eq_or_ne r ∞ with (rfl | hr) · rw [EMetric.closedBall_top, volume_univ, two_mul, _root_.top_add] · lift r to ℝ≥0 using hr rw [Metric.emetric_closedBall_nnreal, volume_closedBall, two_mul, ← NNReal.coe_add, ENNReal.ofReal_coe_nnreal, ENNReal.coe_add, two_mul] #align real.volume_emetric_closed_ball Real.volume_emetric_closedBall instance noAtoms_volume : NoAtoms (volume : Measure ℝ) := ⟨fun _ => volume_singleton⟩ #align real.has_no_atoms_volume Real.noAtoms_volume @[simp] theorem volume_interval {a b : ℝ} : volume (uIcc a b) = ofReal |b - a| := by rw [← Icc_min_max, volume_Icc, max_sub_min_eq_abs] #align real.volume_interval Real.volume_interval @[simp] theorem volume_Ioi {a : ℝ} : volume (Ioi a) = ∞ := top_unique <| le_of_tendsto' ENNReal.tendsto_nat_nhds_top fun n => calc (n : ℝ≥0∞) = volume (Ioo a (a + n)) := by simp _ ≤ volume (Ioi a) := measure_mono Ioo_subset_Ioi_self #align real.volume_Ioi Real.volume_Ioi @[simp] theorem volume_Ici {a : ℝ} : volume (Ici a) = ∞ := by rw [← measure_congr Ioi_ae_eq_Ici]; simp #align real.volume_Ici Real.volume_Ici @[simp] theorem volume_Iio {a : ℝ} : volume (Iio a) = ∞ := top_unique <| le_of_tendsto' ENNReal.tendsto_nat_nhds_top fun n => calc (n : ℝ≥0∞) = volume (Ioo (a - n) a) := by simp _ ≤ volume (Iio a) := measure_mono Ioo_subset_Iio_self #align real.volume_Iio Real.volume_Iio @[simp] theorem volume_Iic {a : ℝ} : volume (Iic a) = ∞ := by rw [← measure_congr Iio_ae_eq_Iic]; simp #align real.volume_Iic Real.volume_Iic instance locallyFinite_volume : IsLocallyFiniteMeasure (volume : Measure ℝ) := ⟨fun x => ⟨Ioo (x - 1) (x + 1), IsOpen.mem_nhds isOpen_Ioo ⟨sub_lt_self _ zero_lt_one, lt_add_of_pos_right _ zero_lt_one⟩, by simp only [Real.volume_Ioo, ENNReal.ofReal_lt_top]⟩⟩ #align real.locally_finite_volume Real.locallyFinite_volume instance isFiniteMeasure_restrict_Icc (x y : ℝ) : IsFiniteMeasure (volume.restrict (Icc x y)) := ⟨by simp⟩ #align real.is_finite_measure_restrict_Icc Real.isFiniteMeasure_restrict_Icc instance isFiniteMeasure_restrict_Ico (x y : ℝ) : IsFiniteMeasure (volume.restrict (Ico x y)) := ⟨by simp⟩ #align real.is_finite_measure_restrict_Ico Real.isFiniteMeasure_restrict_Ico instance isFiniteMeasure_restrict_Ioc (x y : ℝ) : IsFiniteMeasure (volume.restrict (Ioc x y)) := ⟨by simp⟩ #align real.is_finite_measure_restrict_Ioc Real.isFiniteMeasure_restrict_Ioc instance isFiniteMeasure_restrict_Ioo (x y : ℝ) : IsFiniteMeasure (volume.restrict (Ioo x y)) := ⟨by simp⟩ #align real.is_finite_measure_restrict_Ioo Real.isFiniteMeasure_restrict_Ioo theorem volume_le_diam (s : Set ℝ) : volume s ≤ EMetric.diam s := by by_cases hs : Bornology.IsBounded s · rw [Real.ediam_eq hs, ← volume_Icc] exact volume.mono hs.subset_Icc_sInf_sSup · rw [Metric.ediam_of_unbounded hs]; exact le_top #align real.volume_le_diam Real.volume_le_diam theorem _root_.Filter.Eventually.volume_pos_of_nhds_real {p : ℝ → Prop} {a : ℝ} (h : ∀ᶠ x in 𝓝 a, p x) : (0 : ℝ≥0∞) < volume { x | p x } := by rcases h.exists_Ioo_subset with ⟨l, u, hx, hs⟩ refine lt_of_lt_of_le ?_ (measure_mono hs) simpa [-mem_Ioo] using hx.1.trans hx.2 #align filter.eventually.volume_pos_of_nhds_real Filter.Eventually.volume_pos_of_nhds_real theorem volume_Icc_pi {a b : ι → ℝ} : volume (Icc a b) = ∏ i, ENNReal.ofReal (b i - a i) := by rw [← pi_univ_Icc, volume_pi_pi] simp only [Real.volume_Icc] #align real.volume_Icc_pi Real.volume_Icc_pi @[simp] theorem volume_Icc_pi_toReal {a b : ι → ℝ} (h : a ≤ b) : (volume (Icc a b)).toReal = ∏ i, (b i - a i) := by simp only [volume_Icc_pi, ENNReal.toReal_prod, ENNReal.toReal_ofReal (sub_nonneg.2 (h _))] #align real.volume_Icc_pi_to_real Real.volume_Icc_pi_toReal theorem volume_pi_Ioo {a b : ι → ℝ} : volume (pi univ fun i => Ioo (a i) (b i)) = ∏ i, ENNReal.ofReal (b i - a i) := (measure_congr Measure.univ_pi_Ioo_ae_eq_Icc).trans volume_Icc_pi #align real.volume_pi_Ioo Real.volume_pi_Ioo @[simp] theorem volume_pi_Ioo_toReal {a b : ι → ℝ} (h : a ≤ b) : (volume (pi univ fun i => Ioo (a i) (b i))).toReal = ∏ i, (b i - a i) := by simp only [volume_pi_Ioo, ENNReal.toReal_prod, ENNReal.toReal_ofReal (sub_nonneg.2 (h _))] #align real.volume_pi_Ioo_to_real Real.volume_pi_Ioo_toReal theorem volume_pi_Ioc {a b : ι → ℝ} : volume (pi univ fun i => Ioc (a i) (b i)) = ∏ i, ENNReal.ofReal (b i - a i) := (measure_congr Measure.univ_pi_Ioc_ae_eq_Icc).trans volume_Icc_pi #align real.volume_pi_Ioc Real.volume_pi_Ioc @[simp] theorem volume_pi_Ioc_toReal {a b : ι → ℝ} (h : a ≤ b) : (volume (pi univ fun i => Ioc (a i) (b i))).toReal = ∏ i, (b i - a i) := by simp only [volume_pi_Ioc, ENNReal.toReal_prod, ENNReal.toReal_ofReal (sub_nonneg.2 (h _))] #align real.volume_pi_Ioc_to_real Real.volume_pi_Ioc_toReal theorem volume_pi_Ico {a b : ι → ℝ} : volume (pi univ fun i => Ico (a i) (b i)) = ∏ i, ENNReal.ofReal (b i - a i) := (measure_congr Measure.univ_pi_Ico_ae_eq_Icc).trans volume_Icc_pi #align real.volume_pi_Ico Real.volume_pi_Ico @[simp] theorem volume_pi_Ico_toReal {a b : ι → ℝ} (h : a ≤ b) : (volume (pi univ fun i => Ico (a i) (b i))).toReal = ∏ i, (b i - a i) := by simp only [volume_pi_Ico, ENNReal.toReal_prod, ENNReal.toReal_ofReal (sub_nonneg.2 (h _))] #align real.volume_pi_Ico_to_real Real.volume_pi_Ico_toReal @[simp] nonrec theorem volume_pi_ball (a : ι → ℝ) {r : ℝ} (hr : 0 < r) : volume (Metric.ball a r) = ENNReal.ofReal ((2 * r) ^ Fintype.card ι) := by simp only [MeasureTheory.volume_pi_ball a hr, volume_ball, Finset.prod_const] exact (ENNReal.ofReal_pow (mul_nonneg zero_le_two hr.le) _).symm #align real.volume_pi_ball Real.volume_pi_ball @[simp] nonrec theorem volume_pi_closedBall (a : ι → ℝ) {r : ℝ} (hr : 0 ≤ r) : volume (Metric.closedBall a r) = ENNReal.ofReal ((2 * r) ^ Fintype.card ι) := by simp only [MeasureTheory.volume_pi_closedBall a hr, volume_closedBall, Finset.prod_const] exact (ENNReal.ofReal_pow (mul_nonneg zero_le_two hr) _).symm #align real.volume_pi_closed_ball Real.volume_pi_closedBall theorem volume_pi_le_prod_diam (s : Set (ι → ℝ)) : volume s ≤ ∏ i : ι, EMetric.diam (Function.eval i '' s) := calc volume s ≤ volume (pi univ fun i => closure (Function.eval i '' s)) := volume.mono <| Subset.trans (subset_pi_eval_image univ s) <| pi_mono fun _ _ => subset_closure _ = ∏ i, volume (closure <| Function.eval i '' s) := volume_pi_pi _ _ ≤ ∏ i : ι, EMetric.diam (Function.eval i '' s) := Finset.prod_le_prod' fun _ _ => (volume_le_diam _).trans_eq (EMetric.diam_closure _) #align real.volume_pi_le_prod_diam Real.volume_pi_le_prod_diam theorem volume_pi_le_diam_pow (s : Set (ι → ℝ)) : volume s ≤ EMetric.diam s ^ Fintype.card ι := calc volume s ≤ ∏ i : ι, EMetric.diam (Function.eval i '' s) := volume_pi_le_prod_diam s _ ≤ ∏ _i : ι, (1 : ℝ≥0) * EMetric.diam s := (Finset.prod_le_prod' fun i _ => (LipschitzWith.eval i).ediam_image_le s) _ = EMetric.diam s ^ Fintype.card ι := by simp only [ENNReal.coe_one, one_mul, Finset.prod_const, Fintype.card] #align real.volume_pi_le_diam_pow Real.volume_pi_le_diam_pow theorem smul_map_volume_mul_left {a : ℝ} (h : a ≠ 0) : ENNReal.ofReal |a| • Measure.map (a * ·) volume = volume := by refine (Real.measure_ext_Ioo_rat fun p q => ?_).symm cases' lt_or_gt_of_ne h with h h · simp only [Real.volume_Ioo, Measure.smul_apply, ← ENNReal.ofReal_mul (le_of_lt <| neg_pos.2 h), Measure.map_apply (measurable_const_mul a) measurableSet_Ioo, neg_sub_neg, neg_mul, preimage_const_mul_Ioo_of_neg _ _ h, abs_of_neg h, mul_sub, smul_eq_mul, mul_div_cancel₀ _ (ne_of_lt h)] · simp only [Real.volume_Ioo, Measure.smul_apply, ← ENNReal.ofReal_mul (le_of_lt h), Measure.map_apply (measurable_const_mul a) measurableSet_Ioo, preimage_const_mul_Ioo _ _ h, abs_of_pos h, mul_sub, mul_div_cancel₀ _ (ne_of_gt h), smul_eq_mul] #align real.smul_map_volume_mul_left Real.smul_map_volume_mul_left theorem map_volume_mul_left {a : ℝ} (h : a ≠ 0) : Measure.map (a * ·) volume = ENNReal.ofReal |a⁻¹| • volume := by conv_rhs => rw [← Real.smul_map_volume_mul_left h, smul_smul, ← ENNReal.ofReal_mul (abs_nonneg _), ← abs_mul, inv_mul_cancel h, abs_one, ENNReal.ofReal_one, one_smul] #align real.map_volume_mul_left Real.map_volume_mul_left @[simp]
Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean
316
321
theorem volume_preimage_mul_left {a : ℝ} (h : a ≠ 0) (s : Set ℝ) : volume ((a * ·) ⁻¹' s) = ENNReal.ofReal (abs a⁻¹) * volume s := calc volume ((a * ·) ⁻¹' s) = Measure.map (a * ·) volume s := ((Homeomorph.mulLeft₀ a h).toMeasurableEquiv.map_apply s).symm _ = ENNReal.ofReal (abs a⁻¹) * volume s := by
rw [map_volume_mul_left h]; rfl
import Mathlib.Analysis.Complex.Basic import Mathlib.Topology.FiberBundle.IsHomeomorphicTrivialBundle #align_import analysis.complex.re_im_topology from "leanprover-community/mathlib"@"468b141b14016d54b479eb7a0fff1e360b7e3cf6" open Set noncomputable section namespace Complex theorem isHomeomorphicTrivialFiberBundle_re : IsHomeomorphicTrivialFiberBundle ℝ re := ⟨equivRealProdCLM.toHomeomorph, fun _ => rfl⟩ #align complex.is_homeomorphic_trivial_fiber_bundle_re Complex.isHomeomorphicTrivialFiberBundle_re theorem isHomeomorphicTrivialFiberBundle_im : IsHomeomorphicTrivialFiberBundle ℝ im := ⟨equivRealProdCLM.toHomeomorph.trans (Homeomorph.prodComm ℝ ℝ), fun _ => rfl⟩ #align complex.is_homeomorphic_trivial_fiber_bundle_im Complex.isHomeomorphicTrivialFiberBundle_im theorem isOpenMap_re : IsOpenMap re := isHomeomorphicTrivialFiberBundle_re.isOpenMap_proj #align complex.is_open_map_re Complex.isOpenMap_re theorem isOpenMap_im : IsOpenMap im := isHomeomorphicTrivialFiberBundle_im.isOpenMap_proj #align complex.is_open_map_im Complex.isOpenMap_im theorem quotientMap_re : QuotientMap re := isHomeomorphicTrivialFiberBundle_re.quotientMap_proj #align complex.quotient_map_re Complex.quotientMap_re theorem quotientMap_im : QuotientMap im := isHomeomorphicTrivialFiberBundle_im.quotientMap_proj #align complex.quotient_map_im Complex.quotientMap_im theorem interior_preimage_re (s : Set ℝ) : interior (re ⁻¹' s) = re ⁻¹' interior s := (isOpenMap_re.preimage_interior_eq_interior_preimage continuous_re _).symm #align complex.interior_preimage_re Complex.interior_preimage_re theorem interior_preimage_im (s : Set ℝ) : interior (im ⁻¹' s) = im ⁻¹' interior s := (isOpenMap_im.preimage_interior_eq_interior_preimage continuous_im _).symm #align complex.interior_preimage_im Complex.interior_preimage_im theorem closure_preimage_re (s : Set ℝ) : closure (re ⁻¹' s) = re ⁻¹' closure s := (isOpenMap_re.preimage_closure_eq_closure_preimage continuous_re _).symm #align complex.closure_preimage_re Complex.closure_preimage_re theorem closure_preimage_im (s : Set ℝ) : closure (im ⁻¹' s) = im ⁻¹' closure s := (isOpenMap_im.preimage_closure_eq_closure_preimage continuous_im _).symm #align complex.closure_preimage_im Complex.closure_preimage_im theorem frontier_preimage_re (s : Set ℝ) : frontier (re ⁻¹' s) = re ⁻¹' frontier s := (isOpenMap_re.preimage_frontier_eq_frontier_preimage continuous_re _).symm #align complex.frontier_preimage_re Complex.frontier_preimage_re theorem frontier_preimage_im (s : Set ℝ) : frontier (im ⁻¹' s) = im ⁻¹' frontier s := (isOpenMap_im.preimage_frontier_eq_frontier_preimage continuous_im _).symm #align complex.frontier_preimage_im Complex.frontier_preimage_im @[simp] theorem interior_setOf_re_le (a : ℝ) : interior { z : ℂ | z.re ≤ a } = { z | z.re < a } := by simpa only [interior_Iic] using interior_preimage_re (Iic a) #align complex.interior_set_of_re_le Complex.interior_setOf_re_le @[simp] theorem interior_setOf_im_le (a : ℝ) : interior { z : ℂ | z.im ≤ a } = { z | z.im < a } := by simpa only [interior_Iic] using interior_preimage_im (Iic a) #align complex.interior_set_of_im_le Complex.interior_setOf_im_le @[simp] theorem interior_setOf_le_re (a : ℝ) : interior { z : ℂ | a ≤ z.re } = { z | a < z.re } := by simpa only [interior_Ici] using interior_preimage_re (Ici a) #align complex.interior_set_of_le_re Complex.interior_setOf_le_re @[simp] theorem interior_setOf_le_im (a : ℝ) : interior { z : ℂ | a ≤ z.im } = { z | a < z.im } := by simpa only [interior_Ici] using interior_preimage_im (Ici a) #align complex.interior_set_of_le_im Complex.interior_setOf_le_im @[simp] theorem closure_setOf_re_lt (a : ℝ) : closure { z : ℂ | z.re < a } = { z | z.re ≤ a } := by simpa only [closure_Iio] using closure_preimage_re (Iio a) #align complex.closure_set_of_re_lt Complex.closure_setOf_re_lt @[simp] theorem closure_setOf_im_lt (a : ℝ) : closure { z : ℂ | z.im < a } = { z | z.im ≤ a } := by simpa only [closure_Iio] using closure_preimage_im (Iio a) #align complex.closure_set_of_im_lt Complex.closure_setOf_im_lt @[simp]
Mathlib/Analysis/Complex/ReImTopology.lean
124
125
theorem closure_setOf_lt_re (a : ℝ) : closure { z : ℂ | a < z.re } = { z | a ≤ z.re } := by
simpa only [closure_Ioi] using closure_preimage_re (Ioi a)
import Mathlib.Analysis.InnerProductSpace.TwoDim import Mathlib.Geometry.Euclidean.Angle.Unoriented.Basic #align_import geometry.euclidean.angle.oriented.basic from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" noncomputable section open FiniteDimensional Complex open scoped Real RealInnerProductSpace ComplexConjugate namespace Orientation attribute [local instance] Complex.finrank_real_complex_fact variable {V V' : Type*} variable [NormedAddCommGroup V] [NormedAddCommGroup V'] variable [InnerProductSpace ℝ V] [InnerProductSpace ℝ V'] variable [Fact (finrank ℝ V = 2)] [Fact (finrank ℝ V' = 2)] (o : Orientation ℝ V (Fin 2)) local notation "ω" => o.areaForm def oangle (x y : V) : Real.Angle := Complex.arg (o.kahler x y) #align orientation.oangle Orientation.oangle theorem continuousAt_oangle {x : V × V} (hx1 : x.1 ≠ 0) (hx2 : x.2 ≠ 0) : ContinuousAt (fun y : V × V => o.oangle y.1 y.2) x := by refine (Complex.continuousAt_arg_coe_angle ?_).comp ?_ · exact o.kahler_ne_zero hx1 hx2 exact ((continuous_ofReal.comp continuous_inner).add ((continuous_ofReal.comp o.areaForm'.continuous₂).mul continuous_const)).continuousAt #align orientation.continuous_at_oangle Orientation.continuousAt_oangle @[simp] theorem oangle_zero_left (x : V) : o.oangle 0 x = 0 := by simp [oangle] #align orientation.oangle_zero_left Orientation.oangle_zero_left @[simp] theorem oangle_zero_right (x : V) : o.oangle x 0 = 0 := by simp [oangle] #align orientation.oangle_zero_right Orientation.oangle_zero_right @[simp] theorem oangle_self (x : V) : o.oangle x x = 0 := by rw [oangle, kahler_apply_self, ← ofReal_pow] convert QuotientAddGroup.mk_zero (AddSubgroup.zmultiples (2 * π)) apply arg_ofReal_of_nonneg positivity #align orientation.oangle_self Orientation.oangle_self theorem left_ne_zero_of_oangle_ne_zero {x y : V} (h : o.oangle x y ≠ 0) : x ≠ 0 := by rintro rfl; simp at h #align orientation.left_ne_zero_of_oangle_ne_zero Orientation.left_ne_zero_of_oangle_ne_zero theorem right_ne_zero_of_oangle_ne_zero {x y : V} (h : o.oangle x y ≠ 0) : y ≠ 0 := by rintro rfl; simp at h #align orientation.right_ne_zero_of_oangle_ne_zero Orientation.right_ne_zero_of_oangle_ne_zero theorem ne_of_oangle_ne_zero {x y : V} (h : o.oangle x y ≠ 0) : x ≠ y := by rintro rfl; simp at h #align orientation.ne_of_oangle_ne_zero Orientation.ne_of_oangle_ne_zero theorem left_ne_zero_of_oangle_eq_pi {x y : V} (h : o.oangle x y = π) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : o.oangle x y ≠ 0) #align orientation.left_ne_zero_of_oangle_eq_pi Orientation.left_ne_zero_of_oangle_eq_pi theorem right_ne_zero_of_oangle_eq_pi {x y : V} (h : o.oangle x y = π) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : o.oangle x y ≠ 0) #align orientation.right_ne_zero_of_oangle_eq_pi Orientation.right_ne_zero_of_oangle_eq_pi theorem ne_of_oangle_eq_pi {x y : V} (h : o.oangle x y = π) : x ≠ y := o.ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : o.oangle x y ≠ 0) #align orientation.ne_of_oangle_eq_pi Orientation.ne_of_oangle_eq_pi theorem left_ne_zero_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.left_ne_zero_of_oangle_eq_pi_div_two Orientation.left_ne_zero_of_oangle_eq_pi_div_two theorem right_ne_zero_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.right_ne_zero_of_oangle_eq_pi_div_two Orientation.right_ne_zero_of_oangle_eq_pi_div_two theorem ne_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : x ≠ y := o.ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.ne_of_oangle_eq_pi_div_two Orientation.ne_of_oangle_eq_pi_div_two theorem left_ne_zero_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.left_ne_zero_of_oangle_eq_neg_pi_div_two Orientation.left_ne_zero_of_oangle_eq_neg_pi_div_two theorem right_ne_zero_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.right_ne_zero_of_oangle_eq_neg_pi_div_two Orientation.right_ne_zero_of_oangle_eq_neg_pi_div_two theorem ne_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : x ≠ y := o.ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.ne_of_oangle_eq_neg_pi_div_two Orientation.ne_of_oangle_eq_neg_pi_div_two theorem left_ne_zero_of_oangle_sign_ne_zero {x y : V} (h : (o.oangle x y).sign ≠ 0) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align orientation.left_ne_zero_of_oangle_sign_ne_zero Orientation.left_ne_zero_of_oangle_sign_ne_zero theorem right_ne_zero_of_oangle_sign_ne_zero {x y : V} (h : (o.oangle x y).sign ≠ 0) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align orientation.right_ne_zero_of_oangle_sign_ne_zero Orientation.right_ne_zero_of_oangle_sign_ne_zero theorem ne_of_oangle_sign_ne_zero {x y : V} (h : (o.oangle x y).sign ≠ 0) : x ≠ y := o.ne_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align orientation.ne_of_oangle_sign_ne_zero Orientation.ne_of_oangle_sign_ne_zero theorem left_ne_zero_of_oangle_sign_eq_one {x y : V} (h : (o.oangle x y).sign = 1) : x ≠ 0 := o.left_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.left_ne_zero_of_oangle_sign_eq_one Orientation.left_ne_zero_of_oangle_sign_eq_one theorem right_ne_zero_of_oangle_sign_eq_one {x y : V} (h : (o.oangle x y).sign = 1) : y ≠ 0 := o.right_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.right_ne_zero_of_oangle_sign_eq_one Orientation.right_ne_zero_of_oangle_sign_eq_one theorem ne_of_oangle_sign_eq_one {x y : V} (h : (o.oangle x y).sign = 1) : x ≠ y := o.ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.ne_of_oangle_sign_eq_one Orientation.ne_of_oangle_sign_eq_one theorem left_ne_zero_of_oangle_sign_eq_neg_one {x y : V} (h : (o.oangle x y).sign = -1) : x ≠ 0 := o.left_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.left_ne_zero_of_oangle_sign_eq_neg_one Orientation.left_ne_zero_of_oangle_sign_eq_neg_one theorem right_ne_zero_of_oangle_sign_eq_neg_one {x y : V} (h : (o.oangle x y).sign = -1) : y ≠ 0 := o.right_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.right_ne_zero_of_oangle_sign_eq_neg_one Orientation.right_ne_zero_of_oangle_sign_eq_neg_one theorem ne_of_oangle_sign_eq_neg_one {x y : V} (h : (o.oangle x y).sign = -1) : x ≠ y := o.ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.ne_of_oangle_sign_eq_neg_one Orientation.ne_of_oangle_sign_eq_neg_one theorem oangle_rev (x y : V) : o.oangle y x = -o.oangle x y := by simp only [oangle, o.kahler_swap y x, Complex.arg_conj_coe_angle] #align orientation.oangle_rev Orientation.oangle_rev @[simp] theorem oangle_add_oangle_rev (x y : V) : o.oangle x y + o.oangle y x = 0 := by simp [o.oangle_rev y x] #align orientation.oangle_add_oangle_rev Orientation.oangle_add_oangle_rev theorem oangle_neg_left {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : o.oangle (-x) y = o.oangle x y + π := by simp only [oangle, map_neg] convert Complex.arg_neg_coe_angle _ exact o.kahler_ne_zero hx hy #align orientation.oangle_neg_left Orientation.oangle_neg_left theorem oangle_neg_right {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : o.oangle x (-y) = o.oangle x y + π := by simp only [oangle, map_neg] convert Complex.arg_neg_coe_angle _ exact o.kahler_ne_zero hx hy #align orientation.oangle_neg_right Orientation.oangle_neg_right @[simp] theorem two_zsmul_oangle_neg_left (x y : V) : (2 : ℤ) • o.oangle (-x) y = (2 : ℤ) • o.oangle x y := by by_cases hx : x = 0 · simp [hx] · by_cases hy : y = 0 · simp [hy] · simp [o.oangle_neg_left hx hy] #align orientation.two_zsmul_oangle_neg_left Orientation.two_zsmul_oangle_neg_left @[simp] theorem two_zsmul_oangle_neg_right (x y : V) : (2 : ℤ) • o.oangle x (-y) = (2 : ℤ) • o.oangle x y := by by_cases hx : x = 0 · simp [hx] · by_cases hy : y = 0 · simp [hy] · simp [o.oangle_neg_right hx hy] #align orientation.two_zsmul_oangle_neg_right Orientation.two_zsmul_oangle_neg_right @[simp] theorem oangle_neg_neg (x y : V) : o.oangle (-x) (-y) = o.oangle x y := by simp [oangle] #align orientation.oangle_neg_neg Orientation.oangle_neg_neg theorem oangle_neg_left_eq_neg_right (x y : V) : o.oangle (-x) y = o.oangle x (-y) := by rw [← neg_neg y, oangle_neg_neg, neg_neg] #align orientation.oangle_neg_left_eq_neg_right Orientation.oangle_neg_left_eq_neg_right @[simp] theorem oangle_neg_self_left {x : V} (hx : x ≠ 0) : o.oangle (-x) x = π := by simp [oangle_neg_left, hx] #align orientation.oangle_neg_self_left Orientation.oangle_neg_self_left @[simp] theorem oangle_neg_self_right {x : V} (hx : x ≠ 0) : o.oangle x (-x) = π := by simp [oangle_neg_right, hx] #align orientation.oangle_neg_self_right Orientation.oangle_neg_self_right -- @[simp] -- Porting note (#10618): simp can prove this theorem two_zsmul_oangle_neg_self_left (x : V) : (2 : ℤ) • o.oangle (-x) x = 0 := by by_cases hx : x = 0 <;> simp [hx] #align orientation.two_zsmul_oangle_neg_self_left Orientation.two_zsmul_oangle_neg_self_left -- @[simp] -- Porting note (#10618): simp can prove this theorem two_zsmul_oangle_neg_self_right (x : V) : (2 : ℤ) • o.oangle x (-x) = 0 := by by_cases hx : x = 0 <;> simp [hx] #align orientation.two_zsmul_oangle_neg_self_right Orientation.two_zsmul_oangle_neg_self_right @[simp] theorem oangle_add_oangle_rev_neg_left (x y : V) : o.oangle (-x) y + o.oangle (-y) x = 0 := by rw [oangle_neg_left_eq_neg_right, oangle_rev, add_left_neg] #align orientation.oangle_add_oangle_rev_neg_left Orientation.oangle_add_oangle_rev_neg_left @[simp] theorem oangle_add_oangle_rev_neg_right (x y : V) : o.oangle x (-y) + o.oangle y (-x) = 0 := by rw [o.oangle_rev (-x), oangle_neg_left_eq_neg_right, add_neg_self] #align orientation.oangle_add_oangle_rev_neg_right Orientation.oangle_add_oangle_rev_neg_right @[simp] theorem oangle_smul_left_of_pos (x y : V) {r : ℝ} (hr : 0 < r) : o.oangle (r • x) y = o.oangle x y := by simp [oangle, Complex.arg_real_mul _ hr] #align orientation.oangle_smul_left_of_pos Orientation.oangle_smul_left_of_pos @[simp] theorem oangle_smul_right_of_pos (x y : V) {r : ℝ} (hr : 0 < r) : o.oangle x (r • y) = o.oangle x y := by simp [oangle, Complex.arg_real_mul _ hr] #align orientation.oangle_smul_right_of_pos Orientation.oangle_smul_right_of_pos @[simp] theorem oangle_smul_left_of_neg (x y : V) {r : ℝ} (hr : r < 0) : o.oangle (r • x) y = o.oangle (-x) y := by rw [← neg_neg r, neg_smul, ← smul_neg, o.oangle_smul_left_of_pos _ _ (neg_pos_of_neg hr)] #align orientation.oangle_smul_left_of_neg Orientation.oangle_smul_left_of_neg @[simp] theorem oangle_smul_right_of_neg (x y : V) {r : ℝ} (hr : r < 0) : o.oangle x (r • y) = o.oangle x (-y) := by rw [← neg_neg r, neg_smul, ← smul_neg, o.oangle_smul_right_of_pos _ _ (neg_pos_of_neg hr)] #align orientation.oangle_smul_right_of_neg Orientation.oangle_smul_right_of_neg @[simp] theorem oangle_smul_left_self_of_nonneg (x : V) {r : ℝ} (hr : 0 ≤ r) : o.oangle (r • x) x = 0 := by rcases hr.lt_or_eq with (h | h) · simp [h] · simp [h.symm] #align orientation.oangle_smul_left_self_of_nonneg Orientation.oangle_smul_left_self_of_nonneg @[simp] theorem oangle_smul_right_self_of_nonneg (x : V) {r : ℝ} (hr : 0 ≤ r) : o.oangle x (r • x) = 0 := by rcases hr.lt_or_eq with (h | h) · simp [h] · simp [h.symm] #align orientation.oangle_smul_right_self_of_nonneg Orientation.oangle_smul_right_self_of_nonneg @[simp] theorem oangle_smul_smul_self_of_nonneg (x : V) {r₁ r₂ : ℝ} (hr₁ : 0 ≤ r₁) (hr₂ : 0 ≤ r₂) : o.oangle (r₁ • x) (r₂ • x) = 0 := by rcases hr₁.lt_or_eq with (h | h) · simp [h, hr₂] · simp [h.symm] #align orientation.oangle_smul_smul_self_of_nonneg Orientation.oangle_smul_smul_self_of_nonneg @[simp] theorem two_zsmul_oangle_smul_left_of_ne_zero (x y : V) {r : ℝ} (hr : r ≠ 0) : (2 : ℤ) • o.oangle (r • x) y = (2 : ℤ) • o.oangle x y := by rcases hr.lt_or_lt with (h | h) <;> simp [h] #align orientation.two_zsmul_oangle_smul_left_of_ne_zero Orientation.two_zsmul_oangle_smul_left_of_ne_zero @[simp] theorem two_zsmul_oangle_smul_right_of_ne_zero (x y : V) {r : ℝ} (hr : r ≠ 0) : (2 : ℤ) • o.oangle x (r • y) = (2 : ℤ) • o.oangle x y := by rcases hr.lt_or_lt with (h | h) <;> simp [h] #align orientation.two_zsmul_oangle_smul_right_of_ne_zero Orientation.two_zsmul_oangle_smul_right_of_ne_zero @[simp] theorem two_zsmul_oangle_smul_left_self (x : V) {r : ℝ} : (2 : ℤ) • o.oangle (r • x) x = 0 := by rcases lt_or_le r 0 with (h | h) <;> simp [h] #align orientation.two_zsmul_oangle_smul_left_self Orientation.two_zsmul_oangle_smul_left_self @[simp] theorem two_zsmul_oangle_smul_right_self (x : V) {r : ℝ} : (2 : ℤ) • o.oangle x (r • x) = 0 := by rcases lt_or_le r 0 with (h | h) <;> simp [h] #align orientation.two_zsmul_oangle_smul_right_self Orientation.two_zsmul_oangle_smul_right_self @[simp] theorem two_zsmul_oangle_smul_smul_self (x : V) {r₁ r₂ : ℝ} : (2 : ℤ) • o.oangle (r₁ • x) (r₂ • x) = 0 := by by_cases h : r₁ = 0 <;> simp [h] #align orientation.two_zsmul_oangle_smul_smul_self Orientation.two_zsmul_oangle_smul_smul_self theorem two_zsmul_oangle_left_of_span_eq {x y : V} (z : V) (h : (ℝ ∙ x) = ℝ ∙ y) : (2 : ℤ) • o.oangle x z = (2 : ℤ) • o.oangle y z := by rw [Submodule.span_singleton_eq_span_singleton] at h rcases h with ⟨r, rfl⟩ exact (o.two_zsmul_oangle_smul_left_of_ne_zero _ _ (Units.ne_zero _)).symm #align orientation.two_zsmul_oangle_left_of_span_eq Orientation.two_zsmul_oangle_left_of_span_eq theorem two_zsmul_oangle_right_of_span_eq (x : V) {y z : V} (h : (ℝ ∙ y) = ℝ ∙ z) : (2 : ℤ) • o.oangle x y = (2 : ℤ) • o.oangle x z := by rw [Submodule.span_singleton_eq_span_singleton] at h rcases h with ⟨r, rfl⟩ exact (o.two_zsmul_oangle_smul_right_of_ne_zero _ _ (Units.ne_zero _)).symm #align orientation.two_zsmul_oangle_right_of_span_eq Orientation.two_zsmul_oangle_right_of_span_eq theorem two_zsmul_oangle_of_span_eq_of_span_eq {w x y z : V} (hwx : (ℝ ∙ w) = ℝ ∙ x) (hyz : (ℝ ∙ y) = ℝ ∙ z) : (2 : ℤ) • o.oangle w y = (2 : ℤ) • o.oangle x z := by rw [o.two_zsmul_oangle_left_of_span_eq y hwx, o.two_zsmul_oangle_right_of_span_eq x hyz] #align orientation.two_zsmul_oangle_of_span_eq_of_span_eq Orientation.two_zsmul_oangle_of_span_eq_of_span_eq theorem oangle_eq_zero_iff_oangle_rev_eq_zero {x y : V} : o.oangle x y = 0 ↔ o.oangle y x = 0 := by rw [oangle_rev, neg_eq_zero] #align orientation.oangle_eq_zero_iff_oangle_rev_eq_zero Orientation.oangle_eq_zero_iff_oangle_rev_eq_zero theorem oangle_eq_zero_iff_sameRay {x y : V} : o.oangle x y = 0 ↔ SameRay ℝ x y := by rw [oangle, kahler_apply_apply, Complex.arg_coe_angle_eq_iff_eq_toReal, Real.Angle.toReal_zero, Complex.arg_eq_zero_iff] simpa using o.nonneg_inner_and_areaForm_eq_zero_iff_sameRay x y #align orientation.oangle_eq_zero_iff_same_ray Orientation.oangle_eq_zero_iff_sameRay theorem oangle_eq_pi_iff_oangle_rev_eq_pi {x y : V} : o.oangle x y = π ↔ o.oangle y x = π := by rw [oangle_rev, neg_eq_iff_eq_neg, Real.Angle.neg_coe_pi] #align orientation.oangle_eq_pi_iff_oangle_rev_eq_pi Orientation.oangle_eq_pi_iff_oangle_rev_eq_pi theorem oangle_eq_pi_iff_sameRay_neg {x y : V} : o.oangle x y = π ↔ x ≠ 0 ∧ y ≠ 0 ∧ SameRay ℝ x (-y) := by rw [← o.oangle_eq_zero_iff_sameRay] constructor · intro h by_cases hx : x = 0; · simp [hx, Real.Angle.pi_ne_zero.symm] at h by_cases hy : y = 0; · simp [hy, Real.Angle.pi_ne_zero.symm] at h refine ⟨hx, hy, ?_⟩ rw [o.oangle_neg_right hx hy, h, Real.Angle.coe_pi_add_coe_pi] · rintro ⟨hx, hy, h⟩ rwa [o.oangle_neg_right hx hy, ← Real.Angle.sub_coe_pi_eq_add_coe_pi, sub_eq_zero] at h #align orientation.oangle_eq_pi_iff_same_ray_neg Orientation.oangle_eq_pi_iff_sameRay_neg theorem oangle_eq_zero_or_eq_pi_iff_not_linearIndependent {x y : V} : o.oangle x y = 0 ∨ o.oangle x y = π ↔ ¬LinearIndependent ℝ ![x, y] := by rw [oangle_eq_zero_iff_sameRay, oangle_eq_pi_iff_sameRay_neg, sameRay_or_ne_zero_and_sameRay_neg_iff_not_linearIndependent] #align orientation.oangle_eq_zero_or_eq_pi_iff_not_linear_independent Orientation.oangle_eq_zero_or_eq_pi_iff_not_linearIndependent theorem oangle_eq_zero_or_eq_pi_iff_right_eq_smul {x y : V} : o.oangle x y = 0 ∨ o.oangle x y = π ↔ x = 0 ∨ ∃ r : ℝ, y = r • x := by rw [oangle_eq_zero_iff_sameRay, oangle_eq_pi_iff_sameRay_neg] refine ⟨fun h => ?_, fun h => ?_⟩ · rcases h with (h | ⟨-, -, h⟩) · by_cases hx : x = 0; · simp [hx] obtain ⟨r, -, rfl⟩ := h.exists_nonneg_left hx exact Or.inr ⟨r, rfl⟩ · by_cases hx : x = 0; · simp [hx] obtain ⟨r, -, hy⟩ := h.exists_nonneg_left hx refine Or.inr ⟨-r, ?_⟩ simp [hy] · rcases h with (rfl | ⟨r, rfl⟩); · simp by_cases hx : x = 0; · simp [hx] rcases lt_trichotomy r 0 with (hr | hr | hr) · rw [← neg_smul] exact Or.inr ⟨hx, smul_ne_zero hr.ne hx, SameRay.sameRay_pos_smul_right x (Left.neg_pos_iff.2 hr)⟩ · simp [hr] · exact Or.inl (SameRay.sameRay_pos_smul_right x hr) #align orientation.oangle_eq_zero_or_eq_pi_iff_right_eq_smul Orientation.oangle_eq_zero_or_eq_pi_iff_right_eq_smul theorem oangle_ne_zero_and_ne_pi_iff_linearIndependent {x y : V} : o.oangle x y ≠ 0 ∧ o.oangle x y ≠ π ↔ LinearIndependent ℝ ![x, y] := by rw [← not_or, ← not_iff_not, Classical.not_not, oangle_eq_zero_or_eq_pi_iff_not_linearIndependent] #align orientation.oangle_ne_zero_and_ne_pi_iff_linear_independent Orientation.oangle_ne_zero_and_ne_pi_iff_linearIndependent theorem eq_iff_norm_eq_and_oangle_eq_zero (x y : V) : x = y ↔ ‖x‖ = ‖y‖ ∧ o.oangle x y = 0 := by rw [oangle_eq_zero_iff_sameRay] constructor · rintro rfl simp; rfl · rcases eq_or_ne y 0 with (rfl | hy) · simp rintro ⟨h₁, h₂⟩ obtain ⟨r, hr, rfl⟩ := h₂.exists_nonneg_right hy have : ‖y‖ ≠ 0 := by simpa using hy obtain rfl : r = 1 := by apply mul_right_cancel₀ this simpa [norm_smul, _root_.abs_of_nonneg hr] using h₁ simp #align orientation.eq_iff_norm_eq_and_oangle_eq_zero Orientation.eq_iff_norm_eq_and_oangle_eq_zero theorem eq_iff_oangle_eq_zero_of_norm_eq {x y : V} (h : ‖x‖ = ‖y‖) : x = y ↔ o.oangle x y = 0 := ⟨fun he => ((o.eq_iff_norm_eq_and_oangle_eq_zero x y).1 he).2, fun ha => (o.eq_iff_norm_eq_and_oangle_eq_zero x y).2 ⟨h, ha⟩⟩ #align orientation.eq_iff_oangle_eq_zero_of_norm_eq Orientation.eq_iff_oangle_eq_zero_of_norm_eq theorem eq_iff_norm_eq_of_oangle_eq_zero {x y : V} (h : o.oangle x y = 0) : x = y ↔ ‖x‖ = ‖y‖ := ⟨fun he => ((o.eq_iff_norm_eq_and_oangle_eq_zero x y).1 he).1, fun hn => (o.eq_iff_norm_eq_and_oangle_eq_zero x y).2 ⟨hn, h⟩⟩ #align orientation.eq_iff_norm_eq_of_oangle_eq_zero Orientation.eq_iff_norm_eq_of_oangle_eq_zero @[simp] theorem oangle_add {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x y + o.oangle y z = o.oangle x z := by simp_rw [oangle] rw [← Complex.arg_mul_coe_angle, o.kahler_mul y x z] · congr 1 convert Complex.arg_real_mul _ (_ : 0 < ‖y‖ ^ 2) using 2 · norm_cast · have : 0 < ‖y‖ := by simpa using hy positivity · exact o.kahler_ne_zero hx hy · exact o.kahler_ne_zero hy hz #align orientation.oangle_add Orientation.oangle_add @[simp] theorem oangle_add_swap {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle y z + o.oangle x y = o.oangle x z := by rw [add_comm, o.oangle_add hx hy hz] #align orientation.oangle_add_swap Orientation.oangle_add_swap @[simp] theorem oangle_sub_left {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x z - o.oangle x y = o.oangle y z := by rw [sub_eq_iff_eq_add, o.oangle_add_swap hx hy hz] #align orientation.oangle_sub_left Orientation.oangle_sub_left @[simp] theorem oangle_sub_right {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x z - o.oangle y z = o.oangle x y := by rw [sub_eq_iff_eq_add, o.oangle_add hx hy hz] #align orientation.oangle_sub_right Orientation.oangle_sub_right @[simp] theorem oangle_add_cyc3 {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x y + o.oangle y z + o.oangle z x = 0 := by simp [hx, hy, hz] #align orientation.oangle_add_cyc3 Orientation.oangle_add_cyc3 @[simp] theorem oangle_add_cyc3_neg_left {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle (-x) y + o.oangle (-y) z + o.oangle (-z) x = π := by rw [o.oangle_neg_left hx hy, o.oangle_neg_left hy hz, o.oangle_neg_left hz hx, show o.oangle x y + π + (o.oangle y z + π) + (o.oangle z x + π) = o.oangle x y + o.oangle y z + o.oangle z x + (π + π + π : Real.Angle) by abel, o.oangle_add_cyc3 hx hy hz, Real.Angle.coe_pi_add_coe_pi, zero_add, zero_add] #align orientation.oangle_add_cyc3_neg_left Orientation.oangle_add_cyc3_neg_left @[simp] theorem oangle_add_cyc3_neg_right {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x (-y) + o.oangle y (-z) + o.oangle z (-x) = π := by simp_rw [← oangle_neg_left_eq_neg_right, o.oangle_add_cyc3_neg_left hx hy hz] #align orientation.oangle_add_cyc3_neg_right Orientation.oangle_add_cyc3_neg_right theorem oangle_sub_eq_oangle_sub_rev_of_norm_eq {x y : V} (h : ‖x‖ = ‖y‖) : o.oangle x (x - y) = o.oangle (y - x) y := by simp [oangle, h] #align orientation.oangle_sub_eq_oangle_sub_rev_of_norm_eq Orientation.oangle_sub_eq_oangle_sub_rev_of_norm_eq theorem oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq {x y : V} (hn : x ≠ y) (h : ‖x‖ = ‖y‖) : o.oangle y x = π - (2 : ℤ) • o.oangle (y - x) y := by rw [two_zsmul] nth_rw 1 [← o.oangle_sub_eq_oangle_sub_rev_of_norm_eq h] rw [eq_sub_iff_add_eq, ← oangle_neg_neg, ← add_assoc] have hy : y ≠ 0 := by rintro rfl rw [norm_zero, norm_eq_zero] at h exact hn h have hx : x ≠ 0 := norm_ne_zero_iff.1 (h.symm ▸ norm_ne_zero_iff.2 hy) convert o.oangle_add_cyc3_neg_right (neg_ne_zero.2 hy) hx (sub_ne_zero_of_ne hn.symm) using 1 simp #align orientation.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq Orientation.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq @[simp]
Mathlib/Geometry/Euclidean/Angle/Oriented/Basic.lean
596
598
theorem oangle_map (x y : V') (f : V ≃ₗᵢ[ℝ] V') : (Orientation.map (Fin 2) f.toLinearEquiv o).oangle x y = o.oangle (f.symm x) (f.symm y) := by
simp [oangle, o.kahler_map]
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 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⟩ #align list.form_perm_apply_mem_ne_self_iff List.formPerm_apply_mem_ne_self_iff theorem mem_of_formPerm_ne_self (l : List α) (x : α) (h : formPerm l x ≠ x) : x ∈ l := by suffices x ∈ { y | formPerm l y ≠ y } by rw [← mem_toFinset] exact support_formPerm_le' _ this simpa using h #align list.mem_of_form_perm_ne_self List.mem_of_formPerm_ne_self theorem formPerm_eq_self_of_not_mem (l : List α) (x : α) (h : x ∉ l) : formPerm l x = x := by_contra fun H => h <| mem_of_formPerm_ne_self _ _ H #align list.form_perm_eq_self_of_not_mem List.formPerm_eq_self_of_not_mem theorem formPerm_eq_one_iff (hl : Nodup l) : formPerm l = 1 ↔ l.length ≤ 1 := by cases' l with hd tl · simp · rw [← formPerm_apply_mem_eq_self_iff _ hl hd (mem_cons_self _ _)] constructor · simp (config := { contextual := true }) · intro h simp only [(hd :: tl).formPerm_apply_mem_eq_self_iff hl hd (mem_cons_self hd tl), add_le_iff_nonpos_left, length, nonpos_iff_eq_zero, length_eq_zero] at h simp [h] #align list.form_perm_eq_one_iff List.formPerm_eq_one_iff theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) : l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩) · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero] refine ⟨fun h => Or.inr h, ?_⟩ rintro (rfl | h) · simp · exact h · suffices l'.length ≤ 1 ↔ [x] ~r l' ∨ l'.length ≤ 1 by simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero, le_rfl] refine ⟨fun h => Or.inr h, ?_⟩ rintro (h | h) · simp [← h.perm.length_eq] · exact h · rcases l' with (_ | ⟨x', _ | ⟨y', l'⟩⟩) · simp [formPerm_eq_one_iff _ hl, -formPerm_cons_cons] · simp [formPerm_eq_one_iff _ hl, -formPerm_cons_cons] · simp [-formPerm_cons_cons, formPerm_ext_iff hl hl', Nat.succ_le_succ_iff] #align list.form_perm_eq_form_perm_iff List.formPerm_eq_formPerm_iff theorem form_perm_zpow_apply_mem_imp_mem (l : List α) (x : α) (hx : x ∈ l) (n : ℤ) : (formPerm l ^ n) x ∈ l := by by_cases h : (l.formPerm ^ n) x = x · simpa [h] using hx · have h : x ∈ { x | (l.formPerm ^ n) x ≠ x } := h rw [← set_support_apply_mem] at h replace h := set_support_zpow_subset _ _ h simpa using support_formPerm_le' _ h #align list.form_perm_zpow_apply_mem_imp_mem List.form_perm_zpow_apply_mem_imp_mem
Mathlib/GroupTheory/Perm/List.lean
439
449
theorem formPerm_pow_length_eq_one_of_nodup (hl : Nodup l) : formPerm l ^ length l = 1 := by
ext x by_cases hx : x ∈ l · obtain ⟨⟨k, hk⟩, rfl⟩ := get_of_mem hx simp [formPerm_pow_apply_get _ hl, Nat.mod_eq_of_lt hk] · have : x ∉ { x | (l.formPerm ^ l.length) x ≠ x } := by intro H refine hx ?_ replace H := set_support_zpow_subset l.formPerm l.length H simpa using support_formPerm_le' _ H simpa using this
import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Index import Mathlib.GroupTheory.GroupAction.ConjAct import Mathlib.GroupTheory.GroupAction.Quotient import Mathlib.GroupTheory.Perm.Cycle.Type import Mathlib.GroupTheory.SpecificGroups.Cyclic import Mathlib.Tactic.IntervalCases #align_import group_theory.p_group from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" open Fintype MulAction variable (p : ℕ) (G : Type*) [Group G] def IsPGroup : Prop := ∀ g : G, ∃ k : ℕ, g ^ p ^ k = 1 #align is_p_group IsPGroup variable {p} {G} namespace IsPGroup theorem iff_orderOf [hp : Fact p.Prime] : IsPGroup p G ↔ ∀ g : G, ∃ k : ℕ, orderOf g = p ^ k := forall_congr' fun g => ⟨fun ⟨k, hk⟩ => Exists.imp (fun _ h => h.right) ((Nat.dvd_prime_pow hp.out).mp (orderOf_dvd_of_pow_eq_one hk)), Exists.imp fun k hk => by rw [← hk, pow_orderOf_eq_one]⟩ #align is_p_group.iff_order_of IsPGroup.iff_orderOf theorem of_card [Fintype G] {n : ℕ} (hG : card G = p ^ n) : IsPGroup p G := fun g => ⟨n, by rw [← hG, pow_card_eq_one]⟩ #align is_p_group.of_card IsPGroup.of_card theorem of_bot : IsPGroup p (⊥ : Subgroup G) := of_card (by rw [← Nat.card_eq_fintype_card, Subgroup.card_bot, pow_zero]) #align is_p_group.of_bot IsPGroup.of_bot theorem iff_card [Fact p.Prime] [Fintype G] : IsPGroup p G ↔ ∃ n : ℕ, card G = p ^ n := by have hG : card G ≠ 0 := card_ne_zero refine ⟨fun h => ?_, fun ⟨n, hn⟩ => of_card hn⟩ suffices ∀ q ∈ Nat.factors (card G), q = p by use (card G).factors.length rw [← List.prod_replicate, ← List.eq_replicate_of_mem this, Nat.prod_factors hG] intro q hq obtain ⟨hq1, hq2⟩ := (Nat.mem_factors hG).mp hq haveI : Fact q.Prime := ⟨hq1⟩ obtain ⟨g, hg⟩ := exists_prime_orderOf_dvd_card q hq2 obtain ⟨k, hk⟩ := (iff_orderOf.mp h) g exact (hq1.pow_eq_iff.mp (hg.symm.trans hk).symm).1.symm #align is_p_group.iff_card IsPGroup.iff_card alias ⟨exists_card_eq, _⟩ := iff_card section GIsPGroup variable (hG : IsPGroup p G) theorem of_injective {H : Type*} [Group H] (ϕ : H →* G) (hϕ : Function.Injective ϕ) : IsPGroup p H := by simp_rw [IsPGroup, ← hϕ.eq_iff, ϕ.map_pow, ϕ.map_one] exact fun h => hG (ϕ h) #align is_p_group.of_injective IsPGroup.of_injective theorem to_subgroup (H : Subgroup G) : IsPGroup p H := hG.of_injective H.subtype Subtype.coe_injective #align is_p_group.to_subgroup IsPGroup.to_subgroup theorem of_surjective {H : Type*} [Group H] (ϕ : G →* H) (hϕ : Function.Surjective ϕ) : IsPGroup p H := by refine fun h => Exists.elim (hϕ h) fun g hg => Exists.imp (fun k hk => ?_) (hG g) rw [← hg, ← ϕ.map_pow, hk, ϕ.map_one] #align is_p_group.of_surjective IsPGroup.of_surjective theorem to_quotient (H : Subgroup G) [H.Normal] : IsPGroup p (G ⧸ H) := hG.of_surjective (QuotientGroup.mk' H) Quotient.surjective_Quotient_mk'' #align is_p_group.to_quotient IsPGroup.to_quotient theorem of_equiv {H : Type*} [Group H] (ϕ : G ≃* H) : IsPGroup p H := hG.of_surjective ϕ.toMonoidHom ϕ.surjective #align is_p_group.of_equiv IsPGroup.of_equiv theorem orderOf_coprime {n : ℕ} (hn : p.Coprime n) (g : G) : (orderOf g).Coprime n := let ⟨k, hk⟩ := hG g (hn.pow_left k).coprime_dvd_left (orderOf_dvd_of_pow_eq_one hk) #align is_p_group.order_of_coprime IsPGroup.orderOf_coprime noncomputable def powEquiv {n : ℕ} (hn : p.Coprime n) : G ≃ G := let h : ∀ g : G, (Nat.card (Subgroup.zpowers g)).Coprime n := fun g => (Nat.card_zpowers g).symm ▸ hG.orderOf_coprime hn g { toFun := (· ^ n) invFun := fun g => (powCoprime (h g)).symm ⟨g, Subgroup.mem_zpowers g⟩ left_inv := fun g => Subtype.ext_iff.1 <| (powCoprime (h (g ^ n))).left_inv ⟨g, _, Subtype.ext_iff.1 <| (powCoprime (h g)).left_inv ⟨g, Subgroup.mem_zpowers g⟩⟩ right_inv := fun g => Subtype.ext_iff.1 <| (powCoprime (h g)).right_inv ⟨g, Subgroup.mem_zpowers g⟩ } #align is_p_group.pow_equiv IsPGroup.powEquiv @[simp] theorem powEquiv_apply {n : ℕ} (hn : p.Coprime n) (g : G) : hG.powEquiv hn g = g ^ n := rfl #align is_p_group.pow_equiv_apply IsPGroup.powEquiv_apply @[simp] theorem powEquiv_symm_apply {n : ℕ} (hn : p.Coprime n) (g : G) : (hG.powEquiv hn).symm g = g ^ (orderOf g).gcdB n := by rw [← Nat.card_zpowers]; rfl #align is_p_group.pow_equiv_symm_apply IsPGroup.powEquiv_symm_apply variable [hp : Fact p.Prime] noncomputable abbrev powEquiv' {n : ℕ} (hn : ¬p ∣ n) : G ≃ G := powEquiv hG (hp.out.coprime_iff_not_dvd.mpr hn) #align is_p_group.pow_equiv' IsPGroup.powEquiv' theorem index (H : Subgroup G) [H.FiniteIndex] : ∃ n : ℕ, H.index = p ^ n := by haveI := H.normalCore.fintypeQuotientOfFiniteIndex obtain ⟨n, hn⟩ := iff_card.mp (hG.to_quotient H.normalCore) obtain ⟨k, _, hk2⟩ := (Nat.dvd_prime_pow hp.out).mp ((congr_arg _ (H.normalCore.index_eq_card.trans hn)).mp (Subgroup.index_dvd_of_le H.normalCore_le)) exact ⟨k, hk2⟩ #align is_p_group.index IsPGroup.index theorem card_eq_or_dvd : Nat.card G = 1 ∨ p ∣ Nat.card G := by cases fintypeOrInfinite G · obtain ⟨n, hn⟩ := iff_card.mp hG rw [Nat.card_eq_fintype_card, hn] cases' n with n n · exact Or.inl rfl · exact Or.inr ⟨p ^ n, by rw [pow_succ']⟩ · rw [Nat.card_eq_zero_of_infinite] exact Or.inr ⟨0, rfl⟩ #align is_p_group.card_eq_or_dvd IsPGroup.card_eq_or_dvd theorem nontrivial_iff_card [Fintype G] : Nontrivial G ↔ ∃ n > 0, card G = p ^ n := ⟨fun hGnt => let ⟨k, hk⟩ := iff_card.1 hG ⟨k, Nat.pos_of_ne_zero fun hk0 => by rw [hk0, pow_zero] at hk; exact Fintype.one_lt_card.ne' hk, hk⟩, fun ⟨k, hk0, hk⟩ => one_lt_card_iff_nontrivial.1 <| hk.symm ▸ one_lt_pow (Fact.out (p := p.Prime)).one_lt (ne_of_gt hk0)⟩ #align is_p_group.nontrivial_iff_card IsPGroup.nontrivial_iff_card variable {α : Type*} [MulAction G α] theorem card_orbit (a : α) [Fintype (orbit G a)] : ∃ n : ℕ, card (orbit G a) = p ^ n := by let ϕ := orbitEquivQuotientStabilizer G a haveI := Fintype.ofEquiv (orbit G a) ϕ haveI := (stabilizer G a).finiteIndex_of_finite_quotient rw [card_congr ϕ, ← Subgroup.index_eq_card] exact hG.index (stabilizer G a) #align is_p_group.card_orbit IsPGroup.card_orbit variable (α) [Fintype α] theorem card_modEq_card_fixedPoints [Fintype (fixedPoints G α)] : card α ≡ card (fixedPoints G α) [MOD p] := by classical calc card α = card (Σy : Quotient (orbitRel G α), { x // Quotient.mk'' x = y }) := card_congr (Equiv.sigmaFiberEquiv (@Quotient.mk'' _ (orbitRel G α))).symm _ = ∑ a : Quotient (orbitRel G α), card { x // Quotient.mk'' x = a } := card_sigma _ ≡ ∑ _a : fixedPoints G α, 1 [MOD p] := ?_ _ = _ := by simp rw [← ZMod.eq_iff_modEq_nat p, Nat.cast_sum, Nat.cast_sum] have key : ∀ x, card { y // (Quotient.mk'' y : Quotient (orbitRel G α)) = Quotient.mk'' x } = card (orbit G x) := fun x => by simp only [Quotient.eq'']; congr refine Eq.symm (Finset.sum_bij_ne_zero (fun a _ _ => Quotient.mk'' a.1) (fun _ _ _ => Finset.mem_univ _) (fun a₁ _ _ a₂ _ _ h => Subtype.eq (mem_fixedPoints'.mp a₂.2 a₁.1 (Quotient.exact' h))) (fun b => Quotient.inductionOn' b fun b _ hb => ?_) fun a ha _ => by rw [key, mem_fixedPoints_iff_card_orbit_eq_one.mp a.2]) obtain ⟨k, hk⟩ := hG.card_orbit b have : k = 0 := Nat.le_zero.1 (Nat.le_of_lt_succ (lt_of_not_ge (mt (pow_dvd_pow p) (by rwa [pow_one, ← hk, ← Nat.modEq_zero_iff_dvd, ← ZMod.eq_iff_modEq_nat, ← key, Nat.cast_zero])))) exact ⟨⟨b, mem_fixedPoints_iff_card_orbit_eq_one.2 <| by rw [hk, this, pow_zero]⟩, Finset.mem_univ _, ne_of_eq_of_ne Nat.cast_one one_ne_zero, rfl⟩ #align is_p_group.card_modeq_card_fixed_points IsPGroup.card_modEq_card_fixedPoints theorem nonempty_fixed_point_of_prime_not_dvd_card (hpα : ¬p ∣ card α) [Finite (fixedPoints G α)] : (fixedPoints G α).Nonempty := @Set.nonempty_of_nonempty_subtype _ _ (by cases nonempty_fintype (fixedPoints G α) rw [← card_pos_iff, pos_iff_ne_zero] contrapose! hpα rw [← Nat.modEq_zero_iff_dvd, ← hpα] exact hG.card_modEq_card_fixedPoints α) #align is_p_group.nonempty_fixed_point_of_prime_not_dvd_card IsPGroup.nonempty_fixed_point_of_prime_not_dvd_card theorem exists_fixed_point_of_prime_dvd_card_of_fixed_point (hpα : p ∣ card α) {a : α} (ha : a ∈ fixedPoints G α) : ∃ b, b ∈ fixedPoints G α ∧ a ≠ b := by cases nonempty_fintype (fixedPoints G α) have hpf : p ∣ card (fixedPoints G α) := Nat.modEq_zero_iff_dvd.mp ((hG.card_modEq_card_fixedPoints α).symm.trans hpα.modEq_zero_nat) have hα : 1 < card (fixedPoints G α) := (Fact.out (p := p.Prime)).one_lt.trans_le (Nat.le_of_dvd (card_pos_iff.2 ⟨⟨a, ha⟩⟩) hpf) exact let ⟨⟨b, hb⟩, hba⟩ := exists_ne_of_one_lt_card hα ⟨a, ha⟩ ⟨b, hb, fun hab => hba (by simp_rw [hab])⟩ #align is_p_group.exists_fixed_point_of_prime_dvd_card_of_fixed_point IsPGroup.exists_fixed_point_of_prime_dvd_card_of_fixed_point
Mathlib/GroupTheory/PGroup.lean
244
253
theorem center_nontrivial [Nontrivial G] [Finite G] : Nontrivial (Subgroup.center G) := by
classical cases nonempty_fintype G have := (hG.of_equiv ConjAct.toConjAct).exists_fixed_point_of_prime_dvd_card_of_fixed_point G rw [ConjAct.fixedPoints_eq_center] at this have dvd : p ∣ card G := by obtain ⟨n, hn0, hn⟩ := hG.nontrivial_iff_card.mp inferInstance exact hn.symm ▸ dvd_pow_self _ (ne_of_gt hn0) obtain ⟨g, hg⟩ := this dvd (Subgroup.center G).one_mem exact ⟨⟨1, ⟨g, hg.1⟩, mt Subtype.ext_iff.mp hg.2⟩⟩
import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Combinatorics.SimpleGraph.Basic import Mathlib.Data.Sym.Card open Finset Function namespace SimpleGraph variable {V : Type*} (G : SimpleGraph V) {e : Sym2 V} section EdgeFinset variable {G₁ G₂ : SimpleGraph V} [Fintype G.edgeSet] [Fintype G₁.edgeSet] [Fintype G₂.edgeSet] abbrev edgeFinset : Finset (Sym2 V) := Set.toFinset G.edgeSet #align simple_graph.edge_finset SimpleGraph.edgeFinset @[norm_cast] theorem coe_edgeFinset : (G.edgeFinset : Set (Sym2 V)) = G.edgeSet := Set.coe_toFinset _ #align simple_graph.coe_edge_finset SimpleGraph.coe_edgeFinset variable {G} theorem mem_edgeFinset : e ∈ G.edgeFinset ↔ e ∈ G.edgeSet := Set.mem_toFinset #align simple_graph.mem_edge_finset SimpleGraph.mem_edgeFinset theorem not_isDiag_of_mem_edgeFinset : e ∈ G.edgeFinset → ¬e.IsDiag := not_isDiag_of_mem_edgeSet _ ∘ mem_edgeFinset.1 #align simple_graph.not_is_diag_of_mem_edge_finset SimpleGraph.not_isDiag_of_mem_edgeFinset theorem edgeFinset_inj : G₁.edgeFinset = G₂.edgeFinset ↔ G₁ = G₂ := by simp #align simple_graph.edge_finset_inj SimpleGraph.edgeFinset_inj theorem edgeFinset_subset_edgeFinset : G₁.edgeFinset ⊆ G₂.edgeFinset ↔ G₁ ≤ G₂ := by simp #align simple_graph.edge_finset_subset_edge_finset SimpleGraph.edgeFinset_subset_edgeFinset theorem edgeFinset_ssubset_edgeFinset : G₁.edgeFinset ⊂ G₂.edgeFinset ↔ G₁ < G₂ := by simp #align simple_graph.edge_finset_ssubset_edge_finset SimpleGraph.edgeFinset_ssubset_edgeFinset @[gcongr] alias ⟨_, edgeFinset_mono⟩ := edgeFinset_subset_edgeFinset #align simple_graph.edge_finset_mono SimpleGraph.edgeFinset_mono alias ⟨_, edgeFinset_strict_mono⟩ := edgeFinset_ssubset_edgeFinset #align simple_graph.edge_finset_strict_mono SimpleGraph.edgeFinset_strict_mono attribute [mono] edgeFinset_mono edgeFinset_strict_mono @[simp] theorem edgeFinset_bot : (⊥ : SimpleGraph V).edgeFinset = ∅ := by simp [edgeFinset] #align simple_graph.edge_finset_bot SimpleGraph.edgeFinset_bot @[simp] theorem edgeFinset_sup [Fintype (edgeSet (G₁ ⊔ G₂))] [DecidableEq V] : (G₁ ⊔ G₂).edgeFinset = G₁.edgeFinset ∪ G₂.edgeFinset := by simp [edgeFinset] #align simple_graph.edge_finset_sup SimpleGraph.edgeFinset_sup @[simp]
Mathlib/Combinatorics/SimpleGraph/Finite.lean
99
100
theorem edgeFinset_inf [DecidableEq V] : (G₁ ⊓ G₂).edgeFinset = G₁.edgeFinset ∩ G₂.edgeFinset := by
simp [edgeFinset]
import Mathlib.Algebra.Group.Pi.Basic import Mathlib.CategoryTheory.Limits.Shapes.Products import Mathlib.CategoryTheory.Limits.Shapes.Images import Mathlib.CategoryTheory.IsomorphismClasses import Mathlib.CategoryTheory.Limits.Shapes.ZeroObjects #align_import category_theory.limits.shapes.zero_morphisms from "leanprover-community/mathlib"@"f7707875544ef1f81b32cb68c79e0e24e45a0e76" noncomputable section universe v u universe v' u' open CategoryTheory open CategoryTheory.Category open scoped Classical namespace CategoryTheory.Limits variable (C : Type u) [Category.{v} C] variable (D : Type u') [Category.{v'} D] class HasZeroMorphisms where [zero : ∀ X Y : C, Zero (X ⟶ Y)] comp_zero : ∀ {X Y : C} (f : X ⟶ Y) (Z : C), f ≫ (0 : Y ⟶ Z) = (0 : X ⟶ Z) := by aesop_cat zero_comp : ∀ (X : C) {Y Z : C} (f : Y ⟶ Z), (0 : X ⟶ Y) ≫ f = (0 : X ⟶ Z) := by aesop_cat #align category_theory.limits.has_zero_morphisms CategoryTheory.Limits.HasZeroMorphisms #align category_theory.limits.has_zero_morphisms.comp_zero' CategoryTheory.Limits.HasZeroMorphisms.comp_zero #align category_theory.limits.has_zero_morphisms.zero_comp' CategoryTheory.Limits.HasZeroMorphisms.zero_comp attribute [instance] HasZeroMorphisms.zero variable {C} @[simp] theorem comp_zero [HasZeroMorphisms C] {X Y : C} {f : X ⟶ Y} {Z : C} : f ≫ (0 : Y ⟶ Z) = (0 : X ⟶ Z) := HasZeroMorphisms.comp_zero f Z #align category_theory.limits.comp_zero CategoryTheory.Limits.comp_zero @[simp] theorem zero_comp [HasZeroMorphisms C] {X : C} {Y Z : C} {f : Y ⟶ Z} : (0 : X ⟶ Y) ≫ f = (0 : X ⟶ Z) := HasZeroMorphisms.zero_comp X f #align category_theory.limits.zero_comp CategoryTheory.Limits.zero_comp instance hasZeroMorphismsPEmpty : HasZeroMorphisms (Discrete PEmpty) where zero := by aesop_cat #align category_theory.limits.has_zero_morphisms_pempty CategoryTheory.Limits.hasZeroMorphismsPEmpty instance hasZeroMorphismsPUnit : HasZeroMorphisms (Discrete PUnit) where zero X Y := by repeat (constructor) #align category_theory.limits.has_zero_morphisms_punit CategoryTheory.Limits.hasZeroMorphismsPUnit open Opposite HasZeroMorphisms instance hasZeroMorphismsOpposite [HasZeroMorphisms C] : HasZeroMorphisms Cᵒᵖ where zero X Y := ⟨(0 : unop Y ⟶ unop X).op⟩ comp_zero f Z := congr_arg Quiver.Hom.op (HasZeroMorphisms.zero_comp (unop Z) f.unop) zero_comp X {Y Z} (f : Y ⟶ Z) := congrArg Quiver.Hom.op (HasZeroMorphisms.comp_zero f.unop (unop X)) #align category_theory.limits.has_zero_morphisms_opposite CategoryTheory.Limits.hasZeroMorphismsOpposite section variable [HasZeroMorphisms C] @[simp] lemma op_zero (X Y : C) : (0 : X ⟶ Y).op = 0 := rfl #align category_theory.op_zero CategoryTheory.Limits.op_zero @[simp] lemma unop_zero (X Y : Cᵒᵖ) : (0 : X ⟶ Y).unop = 0 := rfl #align category_theory.unop_zero CategoryTheory.Limits.unop_zero theorem zero_of_comp_mono {X Y Z : C} {f : X ⟶ Y} (g : Y ⟶ Z) [Mono g] (h : f ≫ g = 0) : f = 0 := by rw [← zero_comp, cancel_mono] at h exact h #align category_theory.limits.zero_of_comp_mono CategoryTheory.Limits.zero_of_comp_mono theorem zero_of_epi_comp {X Y Z : C} (f : X ⟶ Y) {g : Y ⟶ Z} [Epi f] (h : f ≫ g = 0) : g = 0 := by rw [← comp_zero, cancel_epi] at h exact h #align category_theory.limits.zero_of_epi_comp CategoryTheory.Limits.zero_of_epi_comp theorem eq_zero_of_image_eq_zero {X Y : C} {f : X ⟶ Y} [HasImage f] (w : image.ι f = 0) : f = 0 := by rw [← image.fac f, w, HasZeroMorphisms.comp_zero] #align category_theory.limits.eq_zero_of_image_eq_zero CategoryTheory.Limits.eq_zero_of_image_eq_zero theorem nonzero_image_of_nonzero {X Y : C} {f : X ⟶ Y} [HasImage f] (w : f ≠ 0) : image.ι f ≠ 0 := fun h => w (eq_zero_of_image_eq_zero h) #align category_theory.limits.nonzero_image_of_nonzero CategoryTheory.Limits.nonzero_image_of_nonzero end section variable [HasZeroMorphisms D] instance : HasZeroMorphisms (C ⥤ D) where zero F G := ⟨{ app := fun X => 0 }⟩ comp_zero := fun η H => by ext X; dsimp; apply comp_zero zero_comp := fun F {G H} η => by ext X; dsimp; apply zero_comp @[simp] theorem zero_app (F G : C ⥤ D) (j : C) : (0 : F ⟶ G).app j = 0 := rfl #align category_theory.limits.zero_app CategoryTheory.Limits.zero_app end namespace IsZero variable [HasZeroMorphisms C] theorem eq_zero_of_src {X Y : C} (o : IsZero X) (f : X ⟶ Y) : f = 0 := o.eq_of_src _ _ #align category_theory.limits.is_zero.eq_zero_of_src CategoryTheory.Limits.IsZero.eq_zero_of_src theorem eq_zero_of_tgt {X Y : C} (o : IsZero Y) (f : X ⟶ Y) : f = 0 := o.eq_of_tgt _ _ #align category_theory.limits.is_zero.eq_zero_of_tgt CategoryTheory.Limits.IsZero.eq_zero_of_tgt theorem iff_id_eq_zero (X : C) : IsZero X ↔ 𝟙 X = 0 := ⟨fun h => h.eq_of_src _ _, fun h => ⟨fun Y => ⟨⟨⟨0⟩, fun f => by rw [← id_comp f, ← id_comp (0: X ⟶ Y), h, zero_comp, zero_comp]; simp only⟩⟩, fun Y => ⟨⟨⟨0⟩, fun f => by rw [← comp_id f, ← comp_id (0 : Y ⟶ X), h, comp_zero, comp_zero]; simp only ⟩⟩⟩⟩ #align category_theory.limits.is_zero.iff_id_eq_zero CategoryTheory.Limits.IsZero.iff_id_eq_zero theorem of_mono_zero (X Y : C) [Mono (0 : X ⟶ Y)] : IsZero X := (iff_id_eq_zero X).mpr ((cancel_mono (0 : X ⟶ Y)).1 (by simp)) #align category_theory.limits.is_zero.of_mono_zero CategoryTheory.Limits.IsZero.of_mono_zero theorem of_epi_zero (X Y : C) [Epi (0 : X ⟶ Y)] : IsZero Y := (iff_id_eq_zero Y).mpr ((cancel_epi (0 : X ⟶ Y)).1 (by simp)) #align category_theory.limits.is_zero.of_epi_zero CategoryTheory.Limits.IsZero.of_epi_zero theorem of_mono_eq_zero {X Y : C} (f : X ⟶ Y) [Mono f] (h : f = 0) : IsZero X := by subst h apply of_mono_zero X Y #align category_theory.limits.is_zero.of_mono_eq_zero CategoryTheory.Limits.IsZero.of_mono_eq_zero theorem of_epi_eq_zero {X Y : C} (f : X ⟶ Y) [Epi f] (h : f = 0) : IsZero Y := by subst h apply of_epi_zero X Y #align category_theory.limits.is_zero.of_epi_eq_zero CategoryTheory.Limits.IsZero.of_epi_eq_zero
Mathlib/CategoryTheory/Limits/Shapes/ZeroMorphisms.lean
215
222
theorem iff_isSplitMono_eq_zero {X Y : C} (f : X ⟶ Y) [IsSplitMono f] : IsZero X ↔ f = 0 := by
rw [iff_id_eq_zero] constructor · intro h rw [← Category.id_comp f, h, zero_comp] · intro h rw [← IsSplitMono.id f] simp only [h, zero_comp]
import Mathlib.Data.PFunctor.Univariate.M #align_import data.qpf.univariate.basic from "leanprover-community/mathlib"@"14b69e9f3c16630440a2cbd46f1ddad0d561dee7" universe u class QPF (F : Type u → Type u) [Functor F] where P : PFunctor.{u} abs : ∀ {α}, P α → F α repr : ∀ {α}, F α → P α abs_repr : ∀ {α} (x : F α), abs (repr x) = x abs_map : ∀ {α β} (f : α → β) (p : P α), abs (P.map f p) = f <$> abs p #align qpf QPF namespace QPF variable {F : Type u → Type u} [Functor F] [q : QPF F] open Functor (Liftp Liftr) theorem id_map {α : Type _} (x : F α) : id <$> x = x := by rw [← abs_repr x] cases' repr x with a f rw [← abs_map] rfl #align qpf.id_map QPF.id_map theorem comp_map {α β γ : Type _} (f : α → β) (g : β → γ) (x : F α) : (g ∘ f) <$> x = g <$> f <$> x := by rw [← abs_repr x] cases' repr x with a f rw [← abs_map, ← abs_map, ← abs_map] rfl #align qpf.comp_map QPF.comp_map theorem lawfulFunctor (h : ∀ α β : Type u, @Functor.mapConst F _ α _ = Functor.map ∘ Function.const β) : LawfulFunctor F := { map_const := @h id_map := @id_map F _ _ comp_map := @comp_map F _ _ } #align qpf.is_lawful_functor QPF.lawfulFunctor section open Functor theorem liftp_iff {α : Type u} (p : α → Prop) (x : F α) : Liftp p x ↔ ∃ a f, x = abs ⟨a, f⟩ ∧ ∀ i, p (f i) := by constructor · rintro ⟨y, hy⟩ cases' h : repr y with a f use a, fun i => (f i).val constructor · rw [← hy, ← abs_repr y, h, ← abs_map] rfl intro i apply (f i).property rintro ⟨a, f, h₀, h₁⟩ use abs ⟨a, fun i => ⟨f i, h₁ i⟩⟩ rw [← abs_map, h₀]; rfl #align qpf.liftp_iff QPF.liftp_iff theorem liftp_iff' {α : Type u} (p : α → Prop) (x : F α) : Liftp p x ↔ ∃ u : q.P α, abs u = x ∧ ∀ i, p (u.snd i) := by constructor · rintro ⟨y, hy⟩ cases' h : repr y with a f use ⟨a, fun i => (f i).val⟩ dsimp constructor · rw [← hy, ← abs_repr y, h, ← abs_map] rfl intro i apply (f i).property rintro ⟨⟨a, f⟩, h₀, h₁⟩; dsimp at * use abs ⟨a, fun i => ⟨f i, h₁ i⟩⟩ rw [← abs_map, ← h₀]; rfl #align qpf.liftp_iff' QPF.liftp_iff' theorem liftr_iff {α : Type u} (r : α → α → Prop) (x y : F α) : Liftr r x y ↔ ∃ a f₀ f₁, x = abs ⟨a, f₀⟩ ∧ y = abs ⟨a, f₁⟩ ∧ ∀ i, r (f₀ i) (f₁ i) := by constructor · rintro ⟨u, xeq, yeq⟩ cases' h : repr u with a f use a, fun i => (f i).val.fst, fun i => (f i).val.snd constructor · rw [← xeq, ← abs_repr u, h, ← abs_map] rfl constructor · rw [← yeq, ← abs_repr u, h, ← abs_map] rfl intro i exact (f i).property rintro ⟨a, f₀, f₁, xeq, yeq, h⟩ use abs ⟨a, fun i => ⟨(f₀ i, f₁ i), h i⟩⟩ constructor · rw [xeq, ← abs_map] rfl rw [yeq, ← abs_map]; rfl #align qpf.liftr_iff QPF.liftr_iff end def recF {α : Type _} (g : F α → α) : q.P.W → α | ⟨a, f⟩ => g (abs ⟨a, fun x => recF g (f x)⟩) set_option linter.uppercaseLean3 false in #align qpf.recF QPF.recF theorem recF_eq {α : Type _} (g : F α → α) (x : q.P.W) : recF g x = g (abs (q.P.map (recF g) x.dest)) := by cases x rfl set_option linter.uppercaseLean3 false in #align qpf.recF_eq QPF.recF_eq theorem recF_eq' {α : Type _} (g : F α → α) (a : q.P.A) (f : q.P.B a → q.P.W) : recF g ⟨a, f⟩ = g (abs (q.P.map (recF g) ⟨a, f⟩)) := rfl set_option linter.uppercaseLean3 false in #align qpf.recF_eq' QPF.recF_eq' inductive Wequiv : q.P.W → q.P.W → Prop | ind (a : q.P.A) (f f' : q.P.B a → q.P.W) : (∀ x, Wequiv (f x) (f' x)) → Wequiv ⟨a, f⟩ ⟨a, f'⟩ | abs (a : q.P.A) (f : q.P.B a → q.P.W) (a' : q.P.A) (f' : q.P.B a' → q.P.W) : abs ⟨a, f⟩ = abs ⟨a', f'⟩ → Wequiv ⟨a, f⟩ ⟨a', f'⟩ | trans (u v w : q.P.W) : Wequiv u v → Wequiv v w → Wequiv u w set_option linter.uppercaseLean3 false in #align qpf.Wequiv QPF.Wequiv theorem recF_eq_of_Wequiv {α : Type u} (u : F α → α) (x y : q.P.W) : Wequiv x y → recF u x = recF u y := by intro h induction h with | ind a f f' _ ih => simp only [recF_eq', PFunctor.map_eq, Function.comp, ih] | abs a f a' f' h => simp only [recF_eq', abs_map, h] | trans x y z _ _ ih₁ ih₂ => exact Eq.trans ih₁ ih₂ set_option linter.uppercaseLean3 false in #align qpf.recF_eq_of_Wequiv QPF.recF_eq_of_Wequiv theorem Wequiv.abs' (x y : q.P.W) (h : QPF.abs x.dest = QPF.abs y.dest) : Wequiv x y := by cases x cases y apply Wequiv.abs apply h set_option linter.uppercaseLean3 false in #align qpf.Wequiv.abs' QPF.Wequiv.abs' theorem Wequiv.refl (x : q.P.W) : Wequiv x x := by cases' x with a f exact Wequiv.abs a f a f rfl set_option linter.uppercaseLean3 false in #align qpf.Wequiv.refl QPF.Wequiv.refl theorem Wequiv.symm (x y : q.P.W) : Wequiv x y → Wequiv y x := by intro h induction h with | ind a f f' _ ih => exact Wequiv.ind _ _ _ ih | abs a f a' f' h => exact Wequiv.abs _ _ _ _ h.symm | trans x y z _ _ ih₁ ih₂ => exact QPF.Wequiv.trans _ _ _ ih₂ ih₁ set_option linter.uppercaseLean3 false in #align qpf.Wequiv.symm QPF.Wequiv.symm def Wrepr : q.P.W → q.P.W := recF (PFunctor.W.mk ∘ repr) set_option linter.uppercaseLean3 false in #align qpf.Wrepr QPF.Wrepr theorem Wrepr_equiv (x : q.P.W) : Wequiv (Wrepr x) x := by induction' x with a f ih apply Wequiv.trans · change Wequiv (Wrepr ⟨a, f⟩) (PFunctor.W.mk (q.P.map Wrepr ⟨a, f⟩)) apply Wequiv.abs' have : Wrepr ⟨a, f⟩ = PFunctor.W.mk (repr (abs (q.P.map Wrepr ⟨a, f⟩))) := rfl rw [this, PFunctor.W.dest_mk, abs_repr] rfl apply Wequiv.ind; exact ih set_option linter.uppercaseLean3 false in #align qpf.Wrepr_equiv QPF.Wrepr_equiv def Wsetoid : Setoid q.P.W := ⟨Wequiv, @Wequiv.refl _ _ _, @Wequiv.symm _ _ _, @Wequiv.trans _ _ _⟩ set_option linter.uppercaseLean3 false in #align qpf.W_setoid QPF.Wsetoid attribute [local instance] Wsetoid -- Porting note(#5171): this linter isn't ported yet. -- @[nolint has_nonempty_instance] def Fix (F : Type u → Type u) [Functor F] [q : QPF F] := Quotient (Wsetoid : Setoid q.P.W) #align qpf.fix QPF.Fix def Fix.rec {α : Type _} (g : F α → α) : Fix F → α := Quot.lift (recF g) (recF_eq_of_Wequiv g) #align qpf.fix.rec QPF.Fix.rec def fixToW : Fix F → q.P.W := Quotient.lift Wrepr (recF_eq_of_Wequiv fun x => @PFunctor.W.mk q.P (repr x)) set_option linter.uppercaseLean3 false in #align qpf.fix_to_W QPF.fixToW def Fix.mk (x : F (Fix F)) : Fix F := Quot.mk _ (PFunctor.W.mk (q.P.map fixToW (repr x))) #align qpf.fix.mk QPF.Fix.mk def Fix.dest : Fix F → F (Fix F) := Fix.rec (Functor.map Fix.mk) #align qpf.fix.dest QPF.Fix.dest theorem Fix.rec_eq {α : Type _} (g : F α → α) (x : F (Fix F)) : Fix.rec g (Fix.mk x) = g (Fix.rec g <$> x) := by have : recF g ∘ fixToW = Fix.rec g := by apply funext apply Quotient.ind intro x apply recF_eq_of_Wequiv rw [fixToW] apply Wrepr_equiv conv => lhs rw [Fix.rec, Fix.mk] dsimp cases' h : repr x with a f rw [PFunctor.map_eq, recF_eq, ← PFunctor.map_eq, PFunctor.W.dest_mk, PFunctor.map_map, abs_map, ← h, abs_repr, this] #align qpf.fix.rec_eq QPF.Fix.rec_eq theorem Fix.ind_aux (a : q.P.A) (f : q.P.B a → q.P.W) : Fix.mk (abs ⟨a, fun x => ⟦f x⟧⟩) = ⟦⟨a, f⟩⟧ := by have : Fix.mk (abs ⟨a, fun x => ⟦f x⟧⟩) = ⟦Wrepr ⟨a, f⟩⟧ := by apply Quot.sound; apply Wequiv.abs' rw [PFunctor.W.dest_mk, abs_map, abs_repr, ← abs_map, PFunctor.map_eq] simp only [Wrepr, recF_eq, PFunctor.W.dest_mk, abs_repr, Function.comp] rfl rw [this] apply Quot.sound apply Wrepr_equiv #align qpf.fix.ind_aux QPF.Fix.ind_aux theorem Fix.ind_rec {α : Type u} (g₁ g₂ : Fix F → α) (h : ∀ x : F (Fix F), g₁ <$> x = g₂ <$> x → g₁ (Fix.mk x) = g₂ (Fix.mk x)) : ∀ x, g₁ x = g₂ x := by apply Quot.ind intro x induction' x with a f ih change g₁ ⟦⟨a, f⟩⟧ = g₂ ⟦⟨a, f⟩⟧ rw [← Fix.ind_aux a f]; apply h rw [← abs_map, ← abs_map, PFunctor.map_eq, PFunctor.map_eq] congr with x apply ih #align qpf.fix.ind_rec QPF.Fix.ind_rec theorem Fix.rec_unique {α : Type u} (g : F α → α) (h : Fix F → α) (hyp : ∀ x, h (Fix.mk x) = g (h <$> x)) : Fix.rec g = h := by ext x apply Fix.ind_rec intro x hyp' rw [hyp, ← hyp', Fix.rec_eq] #align qpf.fix.rec_unique QPF.Fix.rec_unique theorem Fix.mk_dest (x : Fix F) : Fix.mk (Fix.dest x) = x := by change (Fix.mk ∘ Fix.dest) x = id x apply Fix.ind_rec (mk ∘ dest) id intro x rw [Function.comp_apply, id_eq, Fix.dest, Fix.rec_eq, id_map, comp_map] intro h rw [h] #align qpf.fix.mk_dest QPF.Fix.mk_dest
Mathlib/Data/QPF/Univariate/Basic.lean
339
345
theorem Fix.dest_mk (x : F (Fix F)) : Fix.dest (Fix.mk x) = x := by
unfold Fix.dest; rw [Fix.rec_eq, ← Fix.dest, ← comp_map] conv => rhs rw [← id_map x] congr with x apply Fix.mk_dest
import Mathlib.CategoryTheory.Opposites #align_import category_theory.eq_to_hom from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" universe v₁ v₂ v₃ u₁ u₂ u₃ -- morphism levels before object levels. See note [CategoryTheory universes]. namespace CategoryTheory open Opposite variable {C : Type u₁} [Category.{v₁} C] def eqToHom {X Y : C} (p : X = Y) : X ⟶ Y := by rw [p]; exact 𝟙 _ #align category_theory.eq_to_hom CategoryTheory.eqToHom @[simp] theorem eqToHom_refl (X : C) (p : X = X) : eqToHom p = 𝟙 X := rfl #align category_theory.eq_to_hom_refl CategoryTheory.eqToHom_refl @[reassoc (attr := simp)] theorem eqToHom_trans {X Y Z : C} (p : X = Y) (q : Y = Z) : eqToHom p ≫ eqToHom q = eqToHom (p.trans q) := by cases p cases q simp #align category_theory.eq_to_hom_trans CategoryTheory.eqToHom_trans theorem comp_eqToHom_iff {X Y Y' : C} (p : Y = Y') (f : X ⟶ Y) (g : X ⟶ Y') : f ≫ eqToHom p = g ↔ f = g ≫ eqToHom p.symm := { mp := fun h => h ▸ by simp mpr := fun h => by simp [eq_whisker h (eqToHom p)] } #align category_theory.comp_eq_to_hom_iff CategoryTheory.comp_eqToHom_iff theorem eqToHom_comp_iff {X X' Y : C} (p : X = X') (f : X ⟶ Y) (g : X' ⟶ Y) : eqToHom p ≫ g = f ↔ g = eqToHom p.symm ≫ f := { mp := fun h => h ▸ by simp mpr := fun h => h ▸ by simp [whisker_eq _ h] } #align category_theory.eq_to_hom_comp_iff CategoryTheory.eqToHom_comp_iff variable {β : Sort*} -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)]
Mathlib/CategoryTheory/EqToHom.lean
77
80
theorem eqToHom_naturality {f g : β → C} (z : ∀ b, f b ⟶ g b) {j j' : β} (w : j = j') : z j ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ z j' := by
cases w simp
import Mathlib.Combinatorics.Enumerative.DoubleCounting import Mathlib.Combinatorics.SimpleGraph.AdjMatrix import Mathlib.Combinatorics.SimpleGraph.Basic import Mathlib.Data.Set.Finite #align_import combinatorics.simple_graph.strongly_regular from "leanprover-community/mathlib"@"2b35fc7bea4640cb75e477e83f32fbd538920822" open Finset universe u namespace SimpleGraph variable {V : Type u} [Fintype V] [DecidableEq V] variable (G : SimpleGraph V) [DecidableRel G.Adj] structure IsSRGWith (n k ℓ μ : ℕ) : Prop where card : Fintype.card V = n regular : G.IsRegularOfDegree k of_adj : ∀ v w : V, G.Adj v w → Fintype.card (G.commonNeighbors v w) = ℓ of_not_adj : Pairwise fun v w => ¬G.Adj v w → Fintype.card (G.commonNeighbors v w) = μ set_option linter.uppercaseLean3 false in #align simple_graph.is_SRG_with SimpleGraph.IsSRGWith variable {G} {n k ℓ μ : ℕ} theorem bot_strongly_regular : (⊥ : SimpleGraph V).IsSRGWith (Fintype.card V) 0 ℓ 0 where card := rfl regular := bot_degree of_adj := fun v w h => h.elim of_not_adj := fun v w _h => by simp only [card_eq_zero, Fintype.card_ofFinset, forall_true_left, not_false_iff, bot_adj] ext simp [mem_commonNeighbors] #align simple_graph.bot_strongly_regular SimpleGraph.bot_strongly_regular theorem IsSRGWith.top : (⊤ : SimpleGraph V).IsSRGWith (Fintype.card V) (Fintype.card V - 1) (Fintype.card V - 2) μ where card := rfl regular := IsRegularOfDegree.top of_adj := fun v w h => by rw [card_commonNeighbors_top] exact h of_not_adj := fun v w h h' => False.elim (h' ((top_adj v w).2 h)) set_option linter.uppercaseLean3 false in #align simple_graph.is_SRG_with.top SimpleGraph.IsSRGWith.top theorem IsSRGWith.card_neighborFinset_union_eq {v w : V} (h : G.IsSRGWith n k ℓ μ) : (G.neighborFinset v ∪ G.neighborFinset w).card = 2 * k - Fintype.card (G.commonNeighbors v w) := by apply Nat.add_right_cancel (m := Fintype.card (G.commonNeighbors v w)) rw [Nat.sub_add_cancel, ← Set.toFinset_card] -- Porting note: Set.toFinset_inter needs workaround to use unification to solve for one of the -- instance arguments: · simp [commonNeighbors, @Set.toFinset_inter _ _ _ _ _ _ (_), ← neighborFinset_def, Finset.card_union_add_card_inter, card_neighborFinset_eq_degree, h.regular.degree_eq, two_mul] · apply le_trans (card_commonNeighbors_le_degree_left _ _ _) simp [h.regular.degree_eq, two_mul] set_option linter.uppercaseLean3 false in #align simple_graph.is_SRG_with.card_neighbor_finset_union_eq SimpleGraph.IsSRGWith.card_neighborFinset_union_eq theorem IsSRGWith.card_neighborFinset_union_of_not_adj {v w : V} (h : G.IsSRGWith n k ℓ μ) (hne : v ≠ w) (ha : ¬G.Adj v w) : (G.neighborFinset v ∪ G.neighborFinset w).card = 2 * k - μ := by rw [← h.of_not_adj hne ha] apply h.card_neighborFinset_union_eq set_option linter.uppercaseLean3 false in #align simple_graph.is_SRG_with.card_neighbor_finset_union_of_not_adj SimpleGraph.IsSRGWith.card_neighborFinset_union_of_not_adj theorem IsSRGWith.card_neighborFinset_union_of_adj {v w : V} (h : G.IsSRGWith n k ℓ μ) (ha : G.Adj v w) : (G.neighborFinset v ∪ G.neighborFinset w).card = 2 * k - ℓ := by rw [← h.of_adj v w ha] apply h.card_neighborFinset_union_eq set_option linter.uppercaseLean3 false in #align simple_graph.is_SRG_with.card_neighbor_finset_union_of_adj SimpleGraph.IsSRGWith.card_neighborFinset_union_of_adj theorem compl_neighborFinset_sdiff_inter_eq {v w : V} : (G.neighborFinset v)ᶜ \ {v} ∩ ((G.neighborFinset w)ᶜ \ {w}) = ((G.neighborFinset v)ᶜ ∩ (G.neighborFinset w)ᶜ) \ ({w} ∪ {v}) := by ext rw [← not_iff_not] simp [imp_iff_not_or, or_assoc, or_comm, or_left_comm] #align simple_graph.compl_neighbor_finset_sdiff_inter_eq SimpleGraph.compl_neighborFinset_sdiff_inter_eq theorem sdiff_compl_neighborFinset_inter_eq {v w : V} (h : G.Adj v w) : ((G.neighborFinset v)ᶜ ∩ (G.neighborFinset w)ᶜ) \ ({w} ∪ {v}) = (G.neighborFinset v)ᶜ ∩ (G.neighborFinset w)ᶜ := by ext simp only [and_imp, mem_union, mem_sdiff, mem_compl, and_iff_left_iff_imp, mem_neighborFinset, mem_inter, mem_singleton] rintro hnv hnw (rfl | rfl) · exact hnv h · apply hnw rwa [adj_comm] #align simple_graph.sdiff_compl_neighbor_finset_inter_eq SimpleGraph.sdiff_compl_neighborFinset_inter_eq theorem IsSRGWith.compl_is_regular (h : G.IsSRGWith n k ℓ μ) : Gᶜ.IsRegularOfDegree (n - k - 1) := by rw [← h.card, Nat.sub_sub, add_comm, ← Nat.sub_sub] exact h.regular.compl set_option linter.uppercaseLean3 false in #align simple_graph.is_SRG_with.compl_is_regular SimpleGraph.IsSRGWith.compl_is_regular
Mathlib/Combinatorics/SimpleGraph/StronglyRegular.lean
144
156
theorem IsSRGWith.card_commonNeighbors_eq_of_adj_compl (h : G.IsSRGWith n k ℓ μ) {v w : V} (ha : Gᶜ.Adj v w) : Fintype.card (Gᶜ.commonNeighbors v w) = n - (2 * k - μ) - 2 := by
simp only [← Set.toFinset_card, commonNeighbors, Set.toFinset_inter, neighborSet_compl, Set.toFinset_diff, Set.toFinset_singleton, Set.toFinset_compl, ← neighborFinset_def] simp_rw [compl_neighborFinset_sdiff_inter_eq] have hne : v ≠ w := ne_of_adj _ ha rw [compl_adj] at ha rw [card_sdiff, ← insert_eq, card_insert_of_not_mem, card_singleton, ← Finset.compl_union] · rw [card_compl, h.card_neighborFinset_union_of_not_adj hne ha.2, ← h.card] · simp only [hne.symm, not_false_iff, mem_singleton] · intro u simp only [mem_union, mem_compl, mem_neighborFinset, mem_inter, mem_singleton] rintro (rfl | rfl) <;> simpa [adj_comm] using ha.2
import Mathlib.Order.Hom.CompleteLattice import Mathlib.Topology.Bases import Mathlib.Topology.Homeomorph import Mathlib.Topology.ContinuousFunction.Basic import Mathlib.Order.CompactlyGenerated.Basic import Mathlib.Order.Copy #align_import topology.sets.opens from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" open Filter Function Order Set open Topology variable {ι α β γ : Type*} [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ] namespace TopologicalSpace variable (α) structure Opens where carrier : Set α is_open' : IsOpen carrier #align topological_space.opens TopologicalSpace.Opens variable {α} namespace Opens instance : SetLike (Opens α) α where coe := Opens.carrier coe_injective' := fun ⟨_, _⟩ ⟨_, _⟩ _ => by congr instance : CanLift (Set α) (Opens α) (↑) IsOpen := ⟨fun s h => ⟨⟨s, h⟩, rfl⟩⟩ theorem «forall» {p : Opens α → Prop} : (∀ U, p U) ↔ ∀ (U : Set α) (hU : IsOpen U), p ⟨U, hU⟩ := ⟨fun h _ _ => h _, fun h _ => h _ _⟩ #align topological_space.opens.forall TopologicalSpace.Opens.forall @[simp] theorem carrier_eq_coe (U : Opens α) : U.1 = ↑U := rfl #align topological_space.opens.carrier_eq_coe TopologicalSpace.Opens.carrier_eq_coe @[simp] theorem coe_mk {U : Set α} {hU : IsOpen U} : ↑(⟨U, hU⟩ : Opens α) = U := rfl #align topological_space.opens.coe_mk TopologicalSpace.Opens.coe_mk @[simp] theorem mem_mk {x : α} {U : Set α} {h : IsOpen U} : x ∈ mk U h ↔ x ∈ U := Iff.rfl #align topological_space.opens.mem_mk TopologicalSpace.Opens.mem_mk -- Porting note: removed @[simp] because LHS simplifies to `∃ x, x ∈ U` protected theorem nonempty_coeSort {U : Opens α} : Nonempty U ↔ (U : Set α).Nonempty := Set.nonempty_coe_sort #align topological_space.opens.nonempty_coe_sort TopologicalSpace.Opens.nonempty_coeSort -- Porting note (#10756): new lemma; todo: prove it for a `SetLike`? protected theorem nonempty_coe {U : Opens α} : (U : Set α).Nonempty ↔ ∃ x, x ∈ U := Iff.rfl @[ext] -- Porting note (#11215): TODO: replace with `∀ x, x ∈ U ↔ x ∈ V` theorem ext {U V : Opens α} (h : (U : Set α) = V) : U = V := SetLike.coe_injective h #align topological_space.opens.ext TopologicalSpace.Opens.ext -- Porting note: removed @[simp], simp can prove it theorem coe_inj {U V : Opens α} : (U : Set α) = V ↔ U = V := SetLike.ext'_iff.symm #align topological_space.opens.coe_inj TopologicalSpace.Opens.coe_inj protected theorem isOpen (U : Opens α) : IsOpen (U : Set α) := U.is_open' #align topological_space.opens.is_open TopologicalSpace.Opens.isOpen @[simp] theorem mk_coe (U : Opens α) : mk (↑U) U.isOpen = U := rfl #align topological_space.opens.mk_coe TopologicalSpace.Opens.mk_coe def Simps.coe (U : Opens α) : Set α := U #align topological_space.opens.simps.coe TopologicalSpace.Opens.Simps.coe initialize_simps_projections Opens (carrier → coe) nonrec def interior (s : Set α) : Opens α := ⟨interior s, isOpen_interior⟩ #align topological_space.opens.interior TopologicalSpace.Opens.interior theorem gc : GaloisConnection ((↑) : Opens α → Set α) interior := fun U _ => ⟨fun h => interior_maximal h U.isOpen, fun h => le_trans h interior_subset⟩ #align topological_space.opens.gc TopologicalSpace.Opens.gc def gi : GaloisCoinsertion (↑) (@interior α _) where choice s hs := ⟨s, interior_eq_iff_isOpen.mp <| le_antisymm interior_subset hs⟩ gc := gc u_l_le _ := interior_subset choice_eq _s hs := le_antisymm hs interior_subset #align topological_space.opens.gi TopologicalSpace.Opens.gi instance : CompleteLattice (Opens α) := CompleteLattice.copy (GaloisCoinsertion.liftCompleteLattice gi) -- le (fun U V => (U : Set α) ⊆ V) rfl -- top ⟨univ, isOpen_univ⟩ (ext interior_univ.symm) -- bot ⟨∅, isOpen_empty⟩ rfl -- sup (fun U V => ⟨↑U ∪ ↑V, U.2.union V.2⟩) rfl -- inf (fun U V => ⟨↑U ∩ ↑V, U.2.inter V.2⟩) (funext₂ fun U V => ext (U.2.inter V.2).interior_eq.symm) -- sSup (fun S => ⟨⋃ s ∈ S, ↑s, isOpen_biUnion fun s _ => s.2⟩) (funext fun _ => ext sSup_image.symm) -- sInf _ rfl @[simp] theorem mk_inf_mk {U V : Set α} {hU : IsOpen U} {hV : IsOpen V} : (⟨U, hU⟩ ⊓ ⟨V, hV⟩ : Opens α) = ⟨U ⊓ V, IsOpen.inter hU hV⟩ := rfl #align topological_space.opens.mk_inf_mk TopologicalSpace.Opens.mk_inf_mk @[simp, norm_cast] theorem coe_inf (s t : Opens α) : (↑(s ⊓ t) : Set α) = ↑s ∩ ↑t := rfl #align topological_space.opens.coe_inf TopologicalSpace.Opens.coe_inf @[simp, norm_cast] theorem coe_sup (s t : Opens α) : (↑(s ⊔ t) : Set α) = ↑s ∪ ↑t := rfl #align topological_space.opens.coe_sup TopologicalSpace.Opens.coe_sup @[simp, norm_cast] theorem coe_bot : ((⊥ : Opens α) : Set α) = ∅ := rfl #align topological_space.opens.coe_bot TopologicalSpace.Opens.coe_bot @[simp] theorem mk_empty : (⟨∅, isOpen_empty⟩ : Opens α) = ⊥ := rfl -- Porting note (#10756): new lemma @[simp, norm_cast] theorem coe_eq_empty {U : Opens α} : (U : Set α) = ∅ ↔ U = ⊥ := SetLike.coe_injective.eq_iff' rfl @[simp, norm_cast] theorem coe_top : ((⊤ : Opens α) : Set α) = Set.univ := rfl #align topological_space.opens.coe_top TopologicalSpace.Opens.coe_top @[simp] theorem mk_univ : (⟨univ, isOpen_univ⟩ : Opens α) = ⊤ := rfl -- Porting note (#10756): new lemma @[simp, norm_cast] theorem coe_eq_univ {U : Opens α} : (U : Set α) = univ ↔ U = ⊤ := SetLike.coe_injective.eq_iff' rfl @[simp, norm_cast] theorem coe_sSup {S : Set (Opens α)} : (↑(sSup S) : Set α) = ⋃ i ∈ S, ↑i := rfl #align topological_space.opens.coe_Sup TopologicalSpace.Opens.coe_sSup @[simp, norm_cast] theorem coe_finset_sup (f : ι → Opens α) (s : Finset ι) : (↑(s.sup f) : Set α) = s.sup ((↑) ∘ f) := map_finset_sup (⟨⟨(↑), coe_sup⟩, coe_bot⟩ : SupBotHom (Opens α) (Set α)) _ _ #align topological_space.opens.coe_finset_sup TopologicalSpace.Opens.coe_finset_sup @[simp, norm_cast] theorem coe_finset_inf (f : ι → Opens α) (s : Finset ι) : (↑(s.inf f) : Set α) = s.inf ((↑) ∘ f) := map_finset_inf (⟨⟨(↑), coe_inf⟩, coe_top⟩ : InfTopHom (Opens α) (Set α)) _ _ #align topological_space.opens.coe_finset_inf TopologicalSpace.Opens.coe_finset_inf instance : Inhabited (Opens α) := ⟨⊥⟩ -- porting note (#10754): new instance instance [IsEmpty α] : Unique (Opens α) where uniq _ := ext <| Subsingleton.elim _ _ -- porting note (#10754): new instance instance [Nonempty α] : Nontrivial (Opens α) where exists_pair_ne := ⟨⊥, ⊤, mt coe_inj.2 empty_ne_univ⟩ @[simp, norm_cast] theorem coe_iSup {ι} (s : ι → Opens α) : ((⨆ i, s i : Opens α) : Set α) = ⋃ i, s i := by simp [iSup] #align topological_space.opens.coe_supr TopologicalSpace.Opens.coe_iSup theorem iSup_def {ι} (s : ι → Opens α) : ⨆ i, s i = ⟨⋃ i, s i, isOpen_iUnion fun i => (s i).2⟩ := ext <| coe_iSup s #align topological_space.opens.supr_def TopologicalSpace.Opens.iSup_def @[simp] theorem iSup_mk {ι} (s : ι → Set α) (h : ∀ i, IsOpen (s i)) : (⨆ i, ⟨s i, h i⟩ : Opens α) = ⟨⋃ i, s i, isOpen_iUnion h⟩ := iSup_def _ #align topological_space.opens.supr_mk TopologicalSpace.Opens.iSup_mk @[simp] theorem mem_iSup {ι} {x : α} {s : ι → Opens α} : x ∈ iSup s ↔ ∃ i, x ∈ s i := by rw [← SetLike.mem_coe] simp #align topological_space.opens.mem_supr TopologicalSpace.Opens.mem_iSup @[simp] theorem mem_sSup {Us : Set (Opens α)} {x : α} : x ∈ sSup Us ↔ ∃ u ∈ Us, x ∈ u := by simp_rw [sSup_eq_iSup, mem_iSup, exists_prop] #align topological_space.opens.mem_Sup TopologicalSpace.Opens.mem_sSup instance : Frame (Opens α) := { inferInstanceAs (CompleteLattice (Opens α)) with sSup := sSup inf_sSup_le_iSup_inf := fun a s => (ext <| by simp only [coe_inf, coe_iSup, coe_sSup, Set.inter_iUnion₂]).le } theorem openEmbedding' (U : Opens α) : OpenEmbedding (Subtype.val : U → α) := U.isOpen.openEmbedding_subtype_val theorem openEmbedding_of_le {U V : Opens α} (i : U ≤ V) : OpenEmbedding (Set.inclusion <| SetLike.coe_subset_coe.2 i) := { toEmbedding := embedding_inclusion i isOpen_range := by rw [Set.range_inclusion i] exact U.isOpen.preimage continuous_subtype_val } #align topological_space.opens.open_embedding_of_le TopologicalSpace.Opens.openEmbedding_of_le theorem not_nonempty_iff_eq_bot (U : Opens α) : ¬Set.Nonempty (U : Set α) ↔ U = ⊥ := by rw [← coe_inj, coe_bot, ← Set.not_nonempty_iff_eq_empty] #align topological_space.opens.not_nonempty_iff_eq_bot TopologicalSpace.Opens.not_nonempty_iff_eq_bot theorem ne_bot_iff_nonempty (U : Opens α) : U ≠ ⊥ ↔ Set.Nonempty (U : Set α) := by rw [Ne, ← not_nonempty_iff_eq_bot, not_not] #align topological_space.opens.ne_bot_iff_nonempty TopologicalSpace.Opens.ne_bot_iff_nonempty theorem eq_bot_or_top {α} [t : TopologicalSpace α] (h : t = ⊤) (U : Opens α) : U = ⊥ ∨ U = ⊤ := by subst h; letI : TopologicalSpace α := ⊤ rw [← coe_eq_empty, ← coe_eq_univ, ← isOpen_top_iff] exact U.2 #align topological_space.opens.eq_bot_or_top TopologicalSpace.Opens.eq_bot_or_top -- porting note (#10754): new instance instance [Nonempty α] [Subsingleton α] : IsSimpleOrder (Opens α) where eq_bot_or_eq_top := eq_bot_or_top <| Subsingleton.elim _ _ def IsBasis (B : Set (Opens α)) : Prop := IsTopologicalBasis (((↑) : _ → Set α) '' B) #align topological_space.opens.is_basis TopologicalSpace.Opens.IsBasis theorem isBasis_iff_nbhd {B : Set (Opens α)} : IsBasis B ↔ ∀ {U : Opens α} {x}, x ∈ U → ∃ U' ∈ B, x ∈ U' ∧ U' ≤ U := by constructor <;> intro h · rintro ⟨sU, hU⟩ x hx rcases h.mem_nhds_iff.mp (IsOpen.mem_nhds hU hx) with ⟨sV, ⟨⟨V, H₁, H₂⟩, hsV⟩⟩ refine ⟨V, H₁, ?_⟩ cases V dsimp at H₂ subst H₂ exact hsV · refine isTopologicalBasis_of_isOpen_of_nhds ?_ ?_ · rintro sU ⟨U, -, rfl⟩ exact U.2 · intro x sU hx hsU rcases @h ⟨sU, hsU⟩ x hx with ⟨V, hV, H⟩ exact ⟨V, ⟨V, hV, rfl⟩, H⟩ #align topological_space.opens.is_basis_iff_nbhd TopologicalSpace.Opens.isBasis_iff_nbhd theorem isBasis_iff_cover {B : Set (Opens α)} : IsBasis B ↔ ∀ U : Opens α, ∃ Us, Us ⊆ B ∧ U = sSup Us := by constructor · intro hB U refine ⟨{ V : Opens α | V ∈ B ∧ V ≤ U }, fun U hU => hU.left, ext ?_⟩ rw [coe_sSup, hB.open_eq_sUnion' U.isOpen] simp_rw [sUnion_eq_biUnion, iUnion, mem_setOf_eq, iSup_and, iSup_image] rfl · intro h rw [isBasis_iff_nbhd] intro U x hx rcases h U with ⟨Us, hUs, rfl⟩ rcases mem_sSup.1 hx with ⟨U, Us, xU⟩ exact ⟨U, hUs Us, xU, le_sSup Us⟩ #align topological_space.opens.is_basis_iff_cover TopologicalSpace.Opens.isBasis_iff_cover
Mathlib/Topology/Sets/Opens.lean
334
341
theorem IsBasis.isCompact_open_iff_eq_finite_iUnion {ι : Type*} (b : ι → Opens α) (hb : IsBasis (Set.range b)) (hb' : ∀ i, IsCompact (b i : Set α)) (U : Set α) : IsCompact U ∧ IsOpen U ↔ ∃ s : Set ι, s.Finite ∧ U = ⋃ i ∈ s, b i := by
apply isCompact_open_iff_eq_finite_iUnion_of_isTopologicalBasis fun i : ι => (b i).1 · convert (config := {transparency := .default}) hb ext simp · exact hb'
import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.Deriv.Slope import Mathlib.Analysis.NormedSpace.FiniteDimension import Mathlib.MeasureTheory.Constructions.BorelSpace.ContinuousLinearMap import Mathlib.MeasureTheory.Function.StronglyMeasurable.Basic #align_import analysis.calculus.fderiv_measurable from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" set_option linter.uppercaseLean3 false -- A B D noncomputable section open Set Metric Asymptotics Filter ContinuousLinearMap MeasureTheory TopologicalSpace open scoped Topology section fderiv variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {f : E → F} (K : Set (E →L[𝕜] F)) namespace FDerivMeasurableAux def A (f : E → F) (L : E →L[𝕜] F) (r ε : ℝ) : Set E := { x | ∃ r' ∈ Ioc (r / 2) r, ∀ y ∈ ball x r', ∀ z ∈ ball x r', ‖f z - f y - L (z - y)‖ < ε * r } #align fderiv_measurable_aux.A FDerivMeasurableAux.A def B (f : E → F) (K : Set (E →L[𝕜] F)) (r s ε : ℝ) : Set E := ⋃ L ∈ K, A f L r ε ∩ A f L s ε #align fderiv_measurable_aux.B FDerivMeasurableAux.B def D (f : E → F) (K : Set (E →L[𝕜] F)) : Set E := ⋂ e : ℕ, ⋃ n : ℕ, ⋂ (p ≥ n) (q ≥ n), B f K ((1 / 2) ^ p) ((1 / 2) ^ q) ((1 / 2) ^ e) #align fderiv_measurable_aux.D FDerivMeasurableAux.D theorem isOpen_A (L : E →L[𝕜] F) (r ε : ℝ) : IsOpen (A f L r ε) := by rw [Metric.isOpen_iff] rintro x ⟨r', r'_mem, hr'⟩ obtain ⟨s, s_gt, s_lt⟩ : ∃ s : ℝ, r / 2 < s ∧ s < r' := exists_between r'_mem.1 have : s ∈ Ioc (r / 2) r := ⟨s_gt, le_of_lt (s_lt.trans_le r'_mem.2)⟩ refine ⟨r' - s, by linarith, fun x' hx' => ⟨s, this, ?_⟩⟩ have B : ball x' s ⊆ ball x r' := ball_subset (le_of_lt hx') intro y hy z hz exact hr' y (B hy) z (B hz) #align fderiv_measurable_aux.is_open_A FDerivMeasurableAux.isOpen_A theorem isOpen_B {K : Set (E →L[𝕜] F)} {r s ε : ℝ} : IsOpen (B f K r s ε) := by simp [B, isOpen_biUnion, IsOpen.inter, isOpen_A] #align fderiv_measurable_aux.is_open_B FDerivMeasurableAux.isOpen_B theorem A_mono (L : E →L[𝕜] F) (r : ℝ) {ε δ : ℝ} (h : ε ≤ δ) : A f L r ε ⊆ A f L r δ := by rintro x ⟨r', r'r, hr'⟩ refine ⟨r', r'r, fun y hy z hz => (hr' y hy z hz).trans_le (mul_le_mul_of_nonneg_right h ?_)⟩ linarith [mem_ball.1 hy, r'r.2, @dist_nonneg _ _ y x] #align fderiv_measurable_aux.A_mono FDerivMeasurableAux.A_mono theorem le_of_mem_A {r ε : ℝ} {L : E →L[𝕜] F} {x : E} (hx : x ∈ A f L r ε) {y z : E} (hy : y ∈ closedBall x (r / 2)) (hz : z ∈ closedBall x (r / 2)) : ‖f z - f y - L (z - y)‖ ≤ ε * r := by rcases hx with ⟨r', r'mem, hr'⟩ apply le_of_lt exact hr' _ ((mem_closedBall.1 hy).trans_lt r'mem.1) _ ((mem_closedBall.1 hz).trans_lt r'mem.1) #align fderiv_measurable_aux.le_of_mem_A FDerivMeasurableAux.le_of_mem_A theorem mem_A_of_differentiable {ε : ℝ} (hε : 0 < ε) {x : E} (hx : DifferentiableAt 𝕜 f x) : ∃ R > 0, ∀ r ∈ Ioo (0 : ℝ) R, x ∈ A f (fderiv 𝕜 f x) r ε := by let δ := (ε / 2) / 2 obtain ⟨R, R_pos, hR⟩ : ∃ R > 0, ∀ y ∈ ball x R, ‖f y - f x - fderiv 𝕜 f x (y - x)‖ ≤ δ * ‖y - x‖ := eventually_nhds_iff_ball.1 <| hx.hasFDerivAt.isLittleO.bound <| by positivity refine ⟨R, R_pos, fun r hr => ?_⟩ have : r ∈ Ioc (r / 2) r := right_mem_Ioc.2 <| half_lt_self hr.1 refine ⟨r, this, fun y hy z hz => ?_⟩ calc ‖f z - f y - (fderiv 𝕜 f x) (z - y)‖ = ‖f z - f x - (fderiv 𝕜 f x) (z - x) - (f y - f x - (fderiv 𝕜 f x) (y - x))‖ := by simp only [map_sub]; abel_nf _ ≤ ‖f z - f x - (fderiv 𝕜 f x) (z - x)‖ + ‖f y - f x - (fderiv 𝕜 f x) (y - x)‖ := norm_sub_le _ _ _ ≤ δ * ‖z - x‖ + δ * ‖y - x‖ := add_le_add (hR _ (ball_subset_ball hr.2.le hz)) (hR _ (ball_subset_ball hr.2.le hy)) _ ≤ δ * r + δ * r := by rw [mem_ball_iff_norm] at hz hy; gcongr _ = (ε / 2) * r := by ring _ < ε * r := by gcongr; exacts [hr.1, half_lt_self hε] #align fderiv_measurable_aux.mem_A_of_differentiable FDerivMeasurableAux.mem_A_of_differentiable theorem norm_sub_le_of_mem_A {c : 𝕜} (hc : 1 < ‖c‖) {r ε : ℝ} (hε : 0 < ε) (hr : 0 < r) {x : E} {L₁ L₂ : E →L[𝕜] F} (h₁ : x ∈ A f L₁ r ε) (h₂ : x ∈ A f L₂ r ε) : ‖L₁ - L₂‖ ≤ 4 * ‖c‖ * ε := by refine opNorm_le_of_shell (half_pos hr) (by positivity) hc ?_ intro y ley ylt rw [div_div, div_le_iff' (mul_pos (by norm_num : (0 : ℝ) < 2) (zero_lt_one.trans hc))] at ley calc ‖(L₁ - L₂) y‖ = ‖f (x + y) - f x - L₂ (x + y - x) - (f (x + y) - f x - L₁ (x + y - x))‖ := by simp _ ≤ ‖f (x + y) - f x - L₂ (x + y - x)‖ + ‖f (x + y) - f x - L₁ (x + y - x)‖ := norm_sub_le _ _ _ ≤ ε * r + ε * r := by apply add_le_add · apply le_of_mem_A h₂ · simp only [le_of_lt (half_pos hr), mem_closedBall, dist_self] · simp only [dist_eq_norm, add_sub_cancel_left, mem_closedBall, ylt.le] · apply le_of_mem_A h₁ · simp only [le_of_lt (half_pos hr), mem_closedBall, dist_self] · simp only [dist_eq_norm, add_sub_cancel_left, mem_closedBall, ylt.le] _ = 2 * ε * r := by ring _ ≤ 2 * ε * (2 * ‖c‖ * ‖y‖) := by gcongr _ = 4 * ‖c‖ * ε * ‖y‖ := by ring #align fderiv_measurable_aux.norm_sub_le_of_mem_A FDerivMeasurableAux.norm_sub_le_of_mem_A
Mathlib/Analysis/Calculus/FDeriv/Measurable.lean
207
219
theorem differentiable_set_subset_D : { x | DifferentiableAt 𝕜 f x ∧ fderiv 𝕜 f x ∈ K } ⊆ D f K := by
intro x hx rw [D, mem_iInter] intro e have : (0 : ℝ) < (1 / 2) ^ e := by positivity rcases mem_A_of_differentiable this hx.1 with ⟨R, R_pos, hR⟩ obtain ⟨n, hn⟩ : ∃ n : ℕ, (1 / 2) ^ n < R := exists_pow_lt_of_lt_one R_pos (by norm_num : (1 : ℝ) / 2 < 1) simp only [mem_iUnion, mem_iInter, B, mem_inter_iff] refine ⟨n, fun p hp q hq => ⟨fderiv 𝕜 f x, hx.2, ⟨?_, ?_⟩⟩⟩ <;> · refine hR _ ⟨pow_pos (by norm_num) _, lt_of_le_of_lt ?_ hn⟩ exact pow_le_pow_of_le_one (by norm_num) (by norm_num) (by assumption)
import Mathlib.Order.Filter.Basic #align_import order.filter.prod from "leanprover-community/mathlib"@"d6fad0e5bf2d6f48da9175d25c3dc5706b3834ce" open Set open Filter namespace Filter variable {α β γ δ : Type*} {ι : Sort*} section Prod variable {s : Set α} {t : Set β} {f : Filter α} {g : Filter β} protected def prod (f : Filter α) (g : Filter β) : Filter (α × β) := f.comap Prod.fst ⊓ g.comap Prod.snd #align filter.prod Filter.prod instance instSProd : SProd (Filter α) (Filter β) (Filter (α × β)) where sprod := Filter.prod theorem prod_mem_prod (hs : s ∈ f) (ht : t ∈ g) : s ×ˢ t ∈ f ×ˢ g := inter_mem_inf (preimage_mem_comap hs) (preimage_mem_comap ht) #align filter.prod_mem_prod Filter.prod_mem_prod theorem mem_prod_iff {s : Set (α × β)} {f : Filter α} {g : Filter β} : s ∈ f ×ˢ g ↔ ∃ t₁ ∈ f, ∃ t₂ ∈ g, t₁ ×ˢ t₂ ⊆ s := by simp only [SProd.sprod, Filter.prod] constructor · rintro ⟨t₁, ⟨s₁, hs₁, hts₁⟩, t₂, ⟨s₂, hs₂, hts₂⟩, rfl⟩ exact ⟨s₁, hs₁, s₂, hs₂, fun p ⟨h, h'⟩ => ⟨hts₁ h, hts₂ h'⟩⟩ · rintro ⟨t₁, ht₁, t₂, ht₂, h⟩ exact mem_inf_of_inter (preimage_mem_comap ht₁) (preimage_mem_comap ht₂) h #align filter.mem_prod_iff Filter.mem_prod_iff @[simp] theorem prod_mem_prod_iff [f.NeBot] [g.NeBot] : s ×ˢ t ∈ f ×ˢ g ↔ s ∈ f ∧ t ∈ g := ⟨fun h => let ⟨_s', hs', _t', ht', H⟩ := mem_prod_iff.1 h (prod_subset_prod_iff.1 H).elim (fun ⟨hs's, ht't⟩ => ⟨mem_of_superset hs' hs's, mem_of_superset ht' ht't⟩) fun h => h.elim (fun hs'e => absurd hs'e (nonempty_of_mem hs').ne_empty) fun ht'e => absurd ht'e (nonempty_of_mem ht').ne_empty, fun h => prod_mem_prod h.1 h.2⟩ #align filter.prod_mem_prod_iff Filter.prod_mem_prod_iff theorem mem_prod_principal {s : Set (α × β)} : s ∈ f ×ˢ 𝓟 t ↔ { a | ∀ b ∈ t, (a, b) ∈ s } ∈ f := by rw [← @exists_mem_subset_iff _ f, mem_prod_iff] refine exists_congr fun u => Iff.rfl.and ⟨?_, fun h => ⟨t, mem_principal_self t, ?_⟩⟩ · rintro ⟨v, v_in, hv⟩ a a_in b b_in exact hv (mk_mem_prod a_in <| v_in b_in) · rintro ⟨x, y⟩ ⟨hx, hy⟩ exact h hx y hy #align filter.mem_prod_principal Filter.mem_prod_principal theorem mem_prod_top {s : Set (α × β)} : s ∈ f ×ˢ (⊤ : Filter β) ↔ { a | ∀ b, (a, b) ∈ s } ∈ f := by rw [← principal_univ, mem_prod_principal] simp only [mem_univ, forall_true_left] #align filter.mem_prod_top Filter.mem_prod_top theorem eventually_prod_principal_iff {p : α × β → Prop} {s : Set β} : (∀ᶠ x : α × β in f ×ˢ 𝓟 s, p x) ↔ ∀ᶠ x : α in f, ∀ y : β, y ∈ s → p (x, y) := by rw [eventually_iff, eventually_iff, mem_prod_principal] simp only [mem_setOf_eq] #align filter.eventually_prod_principal_iff Filter.eventually_prod_principal_iff theorem comap_prod (f : α → β × γ) (b : Filter β) (c : Filter γ) : comap f (b ×ˢ c) = comap (Prod.fst ∘ f) b ⊓ comap (Prod.snd ∘ f) c := by erw [comap_inf, Filter.comap_comap, Filter.comap_comap] #align filter.comap_prod Filter.comap_prod theorem prod_top : f ×ˢ (⊤ : Filter β) = f.comap Prod.fst := by dsimp only [SProd.sprod] rw [Filter.prod, comap_top, inf_top_eq] #align filter.prod_top Filter.prod_top theorem top_prod : (⊤ : Filter α) ×ˢ g = g.comap Prod.snd := by dsimp only [SProd.sprod] rw [Filter.prod, comap_top, top_inf_eq] theorem sup_prod (f₁ f₂ : Filter α) (g : Filter β) : (f₁ ⊔ f₂) ×ˢ g = (f₁ ×ˢ g) ⊔ (f₂ ×ˢ g) := by dsimp only [SProd.sprod] rw [Filter.prod, comap_sup, inf_sup_right, ← Filter.prod, ← Filter.prod] #align filter.sup_prod Filter.sup_prod theorem prod_sup (f : Filter α) (g₁ g₂ : Filter β) : f ×ˢ (g₁ ⊔ g₂) = (f ×ˢ g₁) ⊔ (f ×ˢ g₂) := by dsimp only [SProd.sprod] rw [Filter.prod, comap_sup, inf_sup_left, ← Filter.prod, ← Filter.prod] #align filter.prod_sup Filter.prod_sup theorem eventually_prod_iff {p : α × β → Prop} : (∀ᶠ x in f ×ˢ g, p x) ↔ ∃ pa : α → Prop, (∀ᶠ x in f, pa x) ∧ ∃ pb : β → Prop, (∀ᶠ y in g, pb y) ∧ ∀ {x}, pa x → ∀ {y}, pb y → p (x, y) := by simpa only [Set.prod_subset_iff] using @mem_prod_iff α β p f g #align filter.eventually_prod_iff Filter.eventually_prod_iff theorem tendsto_fst : Tendsto Prod.fst (f ×ˢ g) f := tendsto_inf_left tendsto_comap #align filter.tendsto_fst Filter.tendsto_fst theorem tendsto_snd : Tendsto Prod.snd (f ×ˢ g) g := tendsto_inf_right tendsto_comap #align filter.tendsto_snd Filter.tendsto_snd theorem Tendsto.fst {h : Filter γ} {m : α → β × γ} (H : Tendsto m f (g ×ˢ h)) : Tendsto (fun a ↦ (m a).1) f g := tendsto_fst.comp H theorem Tendsto.snd {h : Filter γ} {m : α → β × γ} (H : Tendsto m f (g ×ˢ h)) : Tendsto (fun a ↦ (m a).2) f h := tendsto_snd.comp H theorem Tendsto.prod_mk {h : Filter γ} {m₁ : α → β} {m₂ : α → γ} (h₁ : Tendsto m₁ f g) (h₂ : Tendsto m₂ f h) : Tendsto (fun x => (m₁ x, m₂ x)) f (g ×ˢ h) := tendsto_inf.2 ⟨tendsto_comap_iff.2 h₁, tendsto_comap_iff.2 h₂⟩ #align filter.tendsto.prod_mk Filter.Tendsto.prod_mk theorem tendsto_prod_swap : Tendsto (Prod.swap : α × β → β × α) (f ×ˢ g) (g ×ˢ f) := tendsto_snd.prod_mk tendsto_fst #align filter.tendsto_prod_swap Filter.tendsto_prod_swap theorem Eventually.prod_inl {la : Filter α} {p : α → Prop} (h : ∀ᶠ x in la, p x) (lb : Filter β) : ∀ᶠ x in la ×ˢ lb, p (x : α × β).1 := tendsto_fst.eventually h #align filter.eventually.prod_inl Filter.Eventually.prod_inl theorem Eventually.prod_inr {lb : Filter β} {p : β → Prop} (h : ∀ᶠ x in lb, p x) (la : Filter α) : ∀ᶠ x in la ×ˢ lb, p (x : α × β).2 := tendsto_snd.eventually h #align filter.eventually.prod_inr Filter.Eventually.prod_inr theorem Eventually.prod_mk {la : Filter α} {pa : α → Prop} (ha : ∀ᶠ x in la, pa x) {lb : Filter β} {pb : β → Prop} (hb : ∀ᶠ y in lb, pb y) : ∀ᶠ p in la ×ˢ lb, pa (p : α × β).1 ∧ pb p.2 := (ha.prod_inl lb).and (hb.prod_inr la) #align filter.eventually.prod_mk Filter.Eventually.prod_mk theorem EventuallyEq.prod_map {δ} {la : Filter α} {fa ga : α → γ} (ha : fa =ᶠ[la] ga) {lb : Filter β} {fb gb : β → δ} (hb : fb =ᶠ[lb] gb) : Prod.map fa fb =ᶠ[la ×ˢ lb] Prod.map ga gb := (Eventually.prod_mk ha hb).mono fun _ h => Prod.ext h.1 h.2 #align filter.eventually_eq.prod_map Filter.EventuallyEq.prod_map theorem EventuallyLE.prod_map {δ} [LE γ] [LE δ] {la : Filter α} {fa ga : α → γ} (ha : fa ≤ᶠ[la] ga) {lb : Filter β} {fb gb : β → δ} (hb : fb ≤ᶠ[lb] gb) : Prod.map fa fb ≤ᶠ[la ×ˢ lb] Prod.map ga gb := Eventually.prod_mk ha hb #align filter.eventually_le.prod_map Filter.EventuallyLE.prod_map theorem Eventually.curry {la : Filter α} {lb : Filter β} {p : α × β → Prop} (h : ∀ᶠ x in la ×ˢ lb, p x) : ∀ᶠ x in la, ∀ᶠ y in lb, p (x, y) := by rcases eventually_prod_iff.1 h with ⟨pa, ha, pb, hb, h⟩ exact ha.mono fun a ha => hb.mono fun b hb => h ha hb #align filter.eventually.curry Filter.Eventually.curry protected lemma Frequently.uncurry {la : Filter α} {lb : Filter β} {p : α → β → Prop} (h : ∃ᶠ x in la, ∃ᶠ y in lb, p x y) : ∃ᶠ xy in la ×ˢ lb, p xy.1 xy.2 := mt (fun h ↦ by simpa only [not_frequently] using h.curry) h theorem Eventually.diag_of_prod {p : α × α → Prop} (h : ∀ᶠ i in f ×ˢ f, p i) : ∀ᶠ i in f, p (i, i) := by obtain ⟨t, ht, s, hs, hst⟩ := eventually_prod_iff.1 h apply (ht.and hs).mono fun x hx => hst hx.1 hx.2 #align filter.eventually.diag_of_prod Filter.Eventually.diag_of_prod theorem Eventually.diag_of_prod_left {f : Filter α} {g : Filter γ} {p : (α × α) × γ → Prop} : (∀ᶠ x in (f ×ˢ f) ×ˢ g, p x) → ∀ᶠ x : α × γ in f ×ˢ g, p ((x.1, x.1), x.2) := by intro h obtain ⟨t, ht, s, hs, hst⟩ := eventually_prod_iff.1 h exact (ht.diag_of_prod.prod_mk hs).mono fun x hx => by simp only [hst hx.1 hx.2] #align filter.eventually.diag_of_prod_left Filter.Eventually.diag_of_prod_left theorem Eventually.diag_of_prod_right {f : Filter α} {g : Filter γ} {p : α × γ × γ → Prop} : (∀ᶠ x in f ×ˢ (g ×ˢ g), p x) → ∀ᶠ x : α × γ in f ×ˢ g, p (x.1, x.2, x.2) := by intro h obtain ⟨t, ht, s, hs, hst⟩ := eventually_prod_iff.1 h exact (ht.prod_mk hs.diag_of_prod).mono fun x hx => by simp only [hst hx.1 hx.2] #align filter.eventually.diag_of_prod_right Filter.Eventually.diag_of_prod_right theorem tendsto_diag : Tendsto (fun i => (i, i)) f (f ×ˢ f) := tendsto_iff_eventually.mpr fun _ hpr => hpr.diag_of_prod #align filter.tendsto_diag Filter.tendsto_diag theorem prod_iInf_left [Nonempty ι] {f : ι → Filter α} {g : Filter β} : (⨅ i, f i) ×ˢ g = ⨅ i, f i ×ˢ g := by dsimp only [SProd.sprod] rw [Filter.prod, comap_iInf, iInf_inf] simp only [Filter.prod, eq_self_iff_true] #align filter.prod_infi_left Filter.prod_iInf_left theorem prod_iInf_right [Nonempty ι] {f : Filter α} {g : ι → Filter β} : (f ×ˢ ⨅ i, g i) = ⨅ i, f ×ˢ g i := by dsimp only [SProd.sprod] rw [Filter.prod, comap_iInf, inf_iInf] simp only [Filter.prod, eq_self_iff_true] #align filter.prod_infi_right Filter.prod_iInf_right @[mono, gcongr] theorem prod_mono {f₁ f₂ : Filter α} {g₁ g₂ : Filter β} (hf : f₁ ≤ f₂) (hg : g₁ ≤ g₂) : f₁ ×ˢ g₁ ≤ f₂ ×ˢ g₂ := inf_le_inf (comap_mono hf) (comap_mono hg) #align filter.prod_mono Filter.prod_mono @[gcongr] theorem prod_mono_left (g : Filter β) {f₁ f₂ : Filter α} (hf : f₁ ≤ f₂) : f₁ ×ˢ g ≤ f₂ ×ˢ g := Filter.prod_mono hf rfl.le #align filter.prod_mono_left Filter.prod_mono_left @[gcongr] theorem prod_mono_right (f : Filter α) {g₁ g₂ : Filter β} (hf : g₁ ≤ g₂) : f ×ˢ g₁ ≤ f ×ˢ g₂ := Filter.prod_mono rfl.le hf #align filter.prod_mono_right Filter.prod_mono_right theorem prod_comap_comap_eq.{u, v, w, x} {α₁ : Type u} {α₂ : Type v} {β₁ : Type w} {β₂ : Type x} {f₁ : Filter α₁} {f₂ : Filter α₂} {m₁ : β₁ → α₁} {m₂ : β₂ → α₂} : comap m₁ f₁ ×ˢ comap m₂ f₂ = comap (fun p : β₁ × β₂ => (m₁ p.1, m₂ p.2)) (f₁ ×ˢ f₂) := by simp only [SProd.sprod, Filter.prod, comap_comap, comap_inf, (· ∘ ·)] #align filter.prod_comap_comap_eq Filter.prod_comap_comap_eq theorem prod_comm' : f ×ˢ g = comap Prod.swap (g ×ˢ f) := by simp only [SProd.sprod, Filter.prod, comap_comap, (· ∘ ·), inf_comm, Prod.swap, comap_inf] #align filter.prod_comm' Filter.prod_comm' theorem prod_comm : f ×ˢ g = map (fun p : β × α => (p.2, p.1)) (g ×ˢ f) := by rw [prod_comm', ← map_swap_eq_comap_swap] rfl #align filter.prod_comm Filter.prod_comm theorem mem_prod_iff_left {s : Set (α × β)} : s ∈ f ×ˢ g ↔ ∃ t ∈ f, ∀ᶠ y in g, ∀ x ∈ t, (x, y) ∈ s := by simp only [mem_prod_iff, prod_subset_iff] refine exists_congr fun _ => Iff.rfl.and <| Iff.trans ?_ exists_mem_subset_iff exact exists_congr fun _ => Iff.rfl.and forall₂_swap theorem mem_prod_iff_right {s : Set (α × β)} : s ∈ f ×ˢ g ↔ ∃ t ∈ g, ∀ᶠ x in f, ∀ y ∈ t, (x, y) ∈ s := by rw [prod_comm, mem_map, mem_prod_iff_left]; rfl @[simp] theorem map_fst_prod (f : Filter α) (g : Filter β) [NeBot g] : map Prod.fst (f ×ˢ g) = f := by ext s simp only [mem_map, mem_prod_iff_left, mem_preimage, eventually_const, ← subset_def, exists_mem_subset_iff] #align filter.map_fst_prod Filter.map_fst_prod @[simp] theorem map_snd_prod (f : Filter α) (g : Filter β) [NeBot f] : map Prod.snd (f ×ˢ g) = g := by rw [prod_comm, map_map]; apply map_fst_prod #align filter.map_snd_prod Filter.map_snd_prod @[simp] theorem prod_le_prod {f₁ f₂ : Filter α} {g₁ g₂ : Filter β} [NeBot f₁] [NeBot g₁] : f₁ ×ˢ g₁ ≤ f₂ ×ˢ g₂ ↔ f₁ ≤ f₂ ∧ g₁ ≤ g₂ := ⟨fun h => ⟨map_fst_prod f₁ g₁ ▸ tendsto_fst.mono_left h, map_snd_prod f₁ g₁ ▸ tendsto_snd.mono_left h⟩, fun h => prod_mono h.1 h.2⟩ #align filter.prod_le_prod Filter.prod_le_prod @[simp] theorem prod_inj {f₁ f₂ : Filter α} {g₁ g₂ : Filter β} [NeBot f₁] [NeBot g₁] : f₁ ×ˢ g₁ = f₂ ×ˢ g₂ ↔ f₁ = f₂ ∧ g₁ = g₂ := by refine ⟨fun h => ?_, fun h => h.1 ▸ h.2 ▸ rfl⟩ have hle : f₁ ≤ f₂ ∧ g₁ ≤ g₂ := prod_le_prod.1 h.le haveI := neBot_of_le hle.1; haveI := neBot_of_le hle.2 exact ⟨hle.1.antisymm <| (prod_le_prod.1 h.ge).1, hle.2.antisymm <| (prod_le_prod.1 h.ge).2⟩ #align filter.prod_inj Filter.prod_inj theorem eventually_swap_iff {p : α × β → Prop} : (∀ᶠ x : α × β in f ×ˢ g, p x) ↔ ∀ᶠ y : β × α in g ×ˢ f, p y.swap := by rw [prod_comm]; rfl #align filter.eventually_swap_iff Filter.eventually_swap_iff theorem prod_assoc (f : Filter α) (g : Filter β) (h : Filter γ) : map (Equiv.prodAssoc α β γ) ((f ×ˢ g) ×ˢ h) = f ×ˢ (g ×ˢ h) := by simp_rw [← comap_equiv_symm, SProd.sprod, Filter.prod, comap_inf, comap_comap, inf_assoc, (· ∘ ·), Equiv.prodAssoc_symm_apply] #align filter.prod_assoc Filter.prod_assoc theorem prod_assoc_symm (f : Filter α) (g : Filter β) (h : Filter γ) : map (Equiv.prodAssoc α β γ).symm (f ×ˢ (g ×ˢ h)) = (f ×ˢ g) ×ˢ h := by simp_rw [map_equiv_symm, SProd.sprod, Filter.prod, comap_inf, comap_comap, inf_assoc, Function.comp, Equiv.prodAssoc_apply] #align filter.prod_assoc_symm Filter.prod_assoc_symm theorem tendsto_prodAssoc {h : Filter γ} : Tendsto (Equiv.prodAssoc α β γ) ((f ×ˢ g) ×ˢ h) (f ×ˢ (g ×ˢ h)) := (prod_assoc f g h).le #align filter.tendsto_prod_assoc Filter.tendsto_prodAssoc theorem tendsto_prodAssoc_symm {h : Filter γ} : Tendsto (Equiv.prodAssoc α β γ).symm (f ×ˢ (g ×ˢ h)) ((f ×ˢ g) ×ˢ h) := (prod_assoc_symm f g h).le #align filter.tendsto_prod_assoc_symm Filter.tendsto_prodAssoc_symm theorem map_swap4_prod {h : Filter γ} {k : Filter δ} : map (fun p : (α × β) × γ × δ => ((p.1.1, p.2.1), (p.1.2, p.2.2))) ((f ×ˢ g) ×ˢ (h ×ˢ k)) = (f ×ˢ h) ×ˢ (g ×ˢ k) := by simp_rw [map_swap4_eq_comap, SProd.sprod, Filter.prod, comap_inf, comap_comap]; ac_rfl #align filter.map_swap4_prod Filter.map_swap4_prod theorem tendsto_swap4_prod {h : Filter γ} {k : Filter δ} : Tendsto (fun p : (α × β) × γ × δ => ((p.1.1, p.2.1), (p.1.2, p.2.2))) ((f ×ˢ g) ×ˢ (h ×ˢ k)) ((f ×ˢ h) ×ˢ (g ×ˢ k)) := map_swap4_prod.le #align filter.tendsto_swap4_prod Filter.tendsto_swap4_prod theorem prod_map_map_eq.{u, v, w, x} {α₁ : Type u} {α₂ : Type v} {β₁ : Type w} {β₂ : Type x} {f₁ : Filter α₁} {f₂ : Filter α₂} {m₁ : α₁ → β₁} {m₂ : α₂ → β₂} : map m₁ f₁ ×ˢ map m₂ f₂ = map (fun p : α₁ × α₂ => (m₁ p.1, m₂ p.2)) (f₁ ×ˢ f₂) := le_antisymm (fun s hs => let ⟨s₁, hs₁, s₂, hs₂, h⟩ := mem_prod_iff.mp hs mem_of_superset (prod_mem_prod (image_mem_map hs₁) (image_mem_map hs₂)) <| by rwa [prod_image_image_eq, image_subset_iff]) ((tendsto_map.comp tendsto_fst).prod_mk (tendsto_map.comp tendsto_snd)) #align filter.prod_map_map_eq Filter.prod_map_map_eq theorem prod_map_map_eq' {α₁ : Type*} {α₂ : Type*} {β₁ : Type*} {β₂ : Type*} (f : α₁ → α₂) (g : β₁ → β₂) (F : Filter α₁) (G : Filter β₁) : map f F ×ˢ map g G = map (Prod.map f g) (F ×ˢ G) := prod_map_map_eq #align filter.prod_map_map_eq' Filter.prod_map_map_eq' theorem prod_map_left (f : α → β) (F : Filter α) (G : Filter γ) : map f F ×ˢ G = map (Prod.map f id) (F ×ˢ G) := by rw [← prod_map_map_eq', map_id] theorem prod_map_right (f : β → γ) (F : Filter α) (G : Filter β) : F ×ˢ map f G = map (Prod.map id f) (F ×ˢ G) := by rw [← prod_map_map_eq', map_id] theorem le_prod_map_fst_snd {f : Filter (α × β)} : f ≤ map Prod.fst f ×ˢ map Prod.snd f := le_inf le_comap_map le_comap_map #align filter.le_prod_map_fst_snd Filter.le_prod_map_fst_snd theorem Tendsto.prod_map {δ : Type*} {f : α → γ} {g : β → δ} {a : Filter α} {b : Filter β} {c : Filter γ} {d : Filter δ} (hf : Tendsto f a c) (hg : Tendsto g b d) : Tendsto (Prod.map f g) (a ×ˢ b) (c ×ˢ d) := by erw [Tendsto, ← prod_map_map_eq] exact Filter.prod_mono hf hg #align filter.tendsto.prod_map Filter.Tendsto.prod_map protected theorem map_prod (m : α × β → γ) (f : Filter α) (g : Filter β) : map m (f ×ˢ g) = (f.map fun a b => m (a, b)).seq g := by simp only [Filter.ext_iff, mem_map, mem_prod_iff, mem_map_seq_iff, exists_and_left] intro s constructor · exact fun ⟨t, ht, s, hs, h⟩ => ⟨s, hs, t, ht, fun x hx y hy => @h ⟨x, y⟩ ⟨hx, hy⟩⟩ · exact fun ⟨s, hs, t, ht, h⟩ => ⟨t, ht, s, hs, fun ⟨x, y⟩ ⟨hx, hy⟩ => h x hx y hy⟩ #align filter.map_prod Filter.map_prod theorem prod_eq : f ×ˢ g = (f.map Prod.mk).seq g := f.map_prod id g #align filter.prod_eq Filter.prod_eq theorem prod_inf_prod {f₁ f₂ : Filter α} {g₁ g₂ : Filter β} : (f₁ ×ˢ g₁) ⊓ (f₂ ×ˢ g₂) = (f₁ ⊓ f₂) ×ˢ (g₁ ⊓ g₂) := by simp only [SProd.sprod, Filter.prod, comap_inf, inf_comm, inf_assoc, inf_left_comm] #align filter.prod_inf_prod Filter.prod_inf_prod theorem inf_prod {f₁ f₂ : Filter α} : (f₁ ⊓ f₂) ×ˢ g = (f₁ ×ˢ g) ⊓ (f₂ ×ˢ g) := by rw [prod_inf_prod, inf_idem] theorem prod_inf {g₁ g₂ : Filter β} : f ×ˢ (g₁ ⊓ g₂) = (f ×ˢ g₁) ⊓ (f ×ˢ g₂) := by rw [prod_inf_prod, inf_idem] @[simp] theorem prod_principal_principal {s : Set α} {t : Set β} : 𝓟 s ×ˢ 𝓟 t = 𝓟 (s ×ˢ t) := by simp only [SProd.sprod, Filter.prod, comap_principal, principal_eq_iff_eq, comap_principal, inf_principal]; rfl #align filter.prod_principal_principal Filter.prod_principal_principal @[simp] theorem pure_prod {a : α} {f : Filter β} : pure a ×ˢ f = map (Prod.mk a) f := by rw [prod_eq, map_pure, pure_seq_eq_map] #align filter.pure_prod Filter.pure_prod theorem map_pure_prod (f : α → β → γ) (a : α) (B : Filter β) : map (Function.uncurry f) (pure a ×ˢ B) = map (f a) B := by rw [Filter.pure_prod]; rfl #align filter.map_pure_prod Filter.map_pure_prod @[simp] theorem prod_pure {b : β} : f ×ˢ pure b = map (fun a => (a, b)) f := by rw [prod_eq, seq_pure, map_map]; rfl #align filter.prod_pure Filter.prod_pure theorem prod_pure_pure {a : α} {b : β} : (pure a : Filter α) ×ˢ (pure b : Filter β) = pure (a, b) := by simp #align filter.prod_pure_pure Filter.prod_pure_pure @[simp] theorem prod_eq_bot : f ×ˢ g = ⊥ ↔ f = ⊥ ∨ g = ⊥ := by simp_rw [← empty_mem_iff_bot, mem_prod_iff, subset_empty_iff, prod_eq_empty_iff, ← exists_prop, Subtype.exists', exists_or, exists_const, Subtype.exists, exists_prop, exists_eq_right] #align filter.prod_eq_bot Filter.prod_eq_bot @[simp] theorem prod_bot : f ×ˢ (⊥ : Filter β) = ⊥ := prod_eq_bot.2 <| Or.inr rfl #align filter.prod_bot Filter.prod_bot @[simp] theorem bot_prod : (⊥ : Filter α) ×ˢ g = ⊥ := prod_eq_bot.2 <| Or.inl rfl #align filter.bot_prod Filter.bot_prod theorem prod_neBot : NeBot (f ×ˢ g) ↔ NeBot f ∧ NeBot g := by simp only [neBot_iff, Ne, prod_eq_bot, not_or] #align filter.prod_ne_bot Filter.prod_neBot protected theorem NeBot.prod (hf : NeBot f) (hg : NeBot g) : NeBot (f ×ˢ g) := prod_neBot.2 ⟨hf, hg⟩ #align filter.ne_bot.prod Filter.NeBot.prod instance prod.instNeBot [hf : NeBot f] [hg : NeBot g] : NeBot (f ×ˢ g) := hf.prod hg #align filter.prod_ne_bot' Filter.prod.instNeBot @[simp] lemma disjoint_prod {f' : Filter α} {g' : Filter β} : Disjoint (f ×ˢ g) (f' ×ˢ g') ↔ Disjoint f f' ∨ Disjoint g g' := by simp only [disjoint_iff, prod_inf_prod, prod_eq_bot] theorem frequently_prod_and {p : α → Prop} {q : β → Prop} : (∃ᶠ x in f ×ˢ g, p x.1 ∧ q x.2) ↔ (∃ᶠ a in f, p a) ∧ ∃ᶠ b in g, q b := by simp only [frequently_iff_neBot, ← prod_neBot, ← prod_inf_prod, prod_principal_principal] rfl
Mathlib/Order/Filter/Prod.lean
474
476
theorem tendsto_prod_iff {f : α × β → γ} {x : Filter α} {y : Filter β} {z : Filter γ} : Tendsto f (x ×ˢ y) z ↔ ∀ W ∈ z, ∃ U ∈ x, ∃ V ∈ y, ∀ x y, x ∈ U → y ∈ V → f (x, y) ∈ W := by
simp only [tendsto_def, mem_prod_iff, prod_sub_preimage_iff, exists_prop, iff_self_iff]
import Mathlib.MeasureTheory.Constructions.BorelSpace.Order import Mathlib.Topology.Order.LeftRightLim #align_import measure_theory.measure.stieltjes from "leanprover-community/mathlib"@"20d5763051978e9bc6428578ed070445df6a18b3" noncomputable section open scoped Classical open Set Filter Function ENNReal NNReal Topology MeasureTheory open ENNReal (ofReal) structure StieltjesFunction where toFun : ℝ → ℝ mono' : Monotone toFun right_continuous' : ∀ x, ContinuousWithinAt toFun (Ici x) x #align stieltjes_function StieltjesFunction #align stieltjes_function.to_fun StieltjesFunction.toFun #align stieltjes_function.mono' StieltjesFunction.mono' #align stieltjes_function.right_continuous' StieltjesFunction.right_continuous' namespace StieltjesFunction attribute [coe] toFun instance instCoeFun : CoeFun StieltjesFunction fun _ => ℝ → ℝ := ⟨toFun⟩ #align stieltjes_function.has_coe_to_fun StieltjesFunction.instCoeFun initialize_simps_projections StieltjesFunction (toFun → apply) @[ext] lemma ext {f g : StieltjesFunction} (h : ∀ x, f x = g x) : f = g := by exact (StieltjesFunction.mk.injEq ..).mpr (funext (by exact h)) variable (f : StieltjesFunction) theorem mono : Monotone f := f.mono' #align stieltjes_function.mono StieltjesFunction.mono theorem right_continuous (x : ℝ) : ContinuousWithinAt f (Ici x) x := f.right_continuous' x #align stieltjes_function.right_continuous StieltjesFunction.right_continuous theorem rightLim_eq (f : StieltjesFunction) (x : ℝ) : Function.rightLim f x = f x := by rw [← f.mono.continuousWithinAt_Ioi_iff_rightLim_eq, continuousWithinAt_Ioi_iff_Ici] exact f.right_continuous' x #align stieltjes_function.right_lim_eq StieltjesFunction.rightLim_eq theorem iInf_Ioi_eq (f : StieltjesFunction) (x : ℝ) : ⨅ r : Ioi x, f r = f x := by suffices Function.rightLim f x = ⨅ r : Ioi x, f r by rw [← this, f.rightLim_eq] rw [f.mono.rightLim_eq_sInf, sInf_image'] rw [← neBot_iff] infer_instance #align stieltjes_function.infi_Ioi_eq StieltjesFunction.iInf_Ioi_eq theorem iInf_rat_gt_eq (f : StieltjesFunction) (x : ℝ) : ⨅ r : { r' : ℚ // x < r' }, f r = f x := by rw [← iInf_Ioi_eq f x] refine (Real.iInf_Ioi_eq_iInf_rat_gt _ ?_ f.mono).symm refine ⟨f x, fun y => ?_⟩ rintro ⟨y, hy_mem, rfl⟩ exact f.mono (le_of_lt hy_mem) #align stieltjes_function.infi_rat_gt_eq StieltjesFunction.iInf_rat_gt_eq @[simps] protected def id : StieltjesFunction where toFun := id mono' _ _ := id right_continuous' _ := continuousWithinAt_id #align stieltjes_function.id StieltjesFunction.id #align stieltjes_function.id_apply StieltjesFunction.id_apply @[simp] theorem id_leftLim (x : ℝ) : leftLim StieltjesFunction.id x = x := tendsto_nhds_unique (StieltjesFunction.id.mono.tendsto_leftLim x) <| continuousAt_id.tendsto.mono_left nhdsWithin_le_nhds #align stieltjes_function.id_left_lim StieltjesFunction.id_leftLim instance instInhabited : Inhabited StieltjesFunction := ⟨StieltjesFunction.id⟩ #align stieltjes_function.inhabited StieltjesFunction.instInhabited noncomputable def _root_.Monotone.stieltjesFunction {f : ℝ → ℝ} (hf : Monotone f) : StieltjesFunction where toFun := rightLim f mono' x y hxy := hf.rightLim hxy right_continuous' := by intro x s hs obtain ⟨l, u, hlu, lus⟩ : ∃ l u : ℝ, rightLim f x ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset.1 hs obtain ⟨y, xy, h'y⟩ : ∃ (y : ℝ), x < y ∧ Ioc x y ⊆ f ⁻¹' Ioo l u := mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 (hf.tendsto_rightLim x (Ioo_mem_nhds hlu.1 hlu.2)) change ∀ᶠ y in 𝓝[≥] x, rightLim f y ∈ s filter_upwards [Ico_mem_nhdsWithin_Ici ⟨le_refl x, xy⟩] with z hz apply lus refine ⟨hlu.1.trans_le (hf.rightLim hz.1), ?_⟩ obtain ⟨a, za, ay⟩ : ∃ a : ℝ, z < a ∧ a < y := exists_between hz.2 calc rightLim f z ≤ f a := hf.rightLim_le za _ < u := (h'y ⟨hz.1.trans_lt za, ay.le⟩).2 #align monotone.stieltjes_function Monotone.stieltjesFunction theorem _root_.Monotone.stieltjesFunction_eq {f : ℝ → ℝ} (hf : Monotone f) (x : ℝ) : hf.stieltjesFunction x = rightLim f x := rfl #align monotone.stieltjes_function_eq Monotone.stieltjesFunction_eq theorem countable_leftLim_ne (f : StieltjesFunction) : Set.Countable { x | leftLim f x ≠ f x } := by refine Countable.mono ?_ f.mono.countable_not_continuousAt intro x hx h'x apply hx exact tendsto_nhds_unique (f.mono.tendsto_leftLim x) (h'x.tendsto.mono_left nhdsWithin_le_nhds) #align stieltjes_function.countable_left_lim_ne StieltjesFunction.countable_leftLim_ne def length (s : Set ℝ) : ℝ≥0∞ := ⨅ (a) (b) (_ : s ⊆ Ioc a b), ofReal (f b - f a) #align stieltjes_function.length StieltjesFunction.length @[simp] theorem length_empty : f.length ∅ = 0 := nonpos_iff_eq_zero.1 <| iInf_le_of_le 0 <| iInf_le_of_le 0 <| by simp #align stieltjes_function.length_empty StieltjesFunction.length_empty @[simp] theorem length_Ioc (a b : ℝ) : f.length (Ioc a b) = ofReal (f b - f a) := by refine le_antisymm (iInf_le_of_le a <| iInf₂_le b Subset.rfl) (le_iInf fun a' => le_iInf fun b' => le_iInf fun h => ENNReal.coe_le_coe.2 ?_) rcases le_or_lt b a with ab | ab · rw [Real.toNNReal_of_nonpos (sub_nonpos.2 (f.mono ab))] apply zero_le cases' (Ioc_subset_Ioc_iff ab).1 h with h₁ h₂ exact Real.toNNReal_le_toNNReal (sub_le_sub (f.mono h₁) (f.mono h₂)) #align stieltjes_function.length_Ioc StieltjesFunction.length_Ioc theorem length_mono {s₁ s₂ : Set ℝ} (h : s₁ ⊆ s₂) : f.length s₁ ≤ f.length s₂ := iInf_mono fun _ => biInf_mono fun _ => h.trans #align stieltjes_function.length_mono StieltjesFunction.length_mono open MeasureTheory protected def outer : OuterMeasure ℝ := OuterMeasure.ofFunction f.length f.length_empty #align stieltjes_function.outer StieltjesFunction.outer theorem outer_le_length (s : Set ℝ) : f.outer s ≤ f.length s := OuterMeasure.ofFunction_le _ #align stieltjes_function.outer_le_length StieltjesFunction.outer_le_length theorem length_subadditive_Icc_Ioo {a b : ℝ} {c d : ℕ → ℝ} (ss : Icc a b ⊆ ⋃ i, Ioo (c i) (d i)) : ofReal (f b - f a) ≤ ∑' i, ofReal (f (d i) - f (c i)) := by suffices ∀ (s : Finset ℕ) (b), Icc a b ⊆ (⋃ i ∈ (s : Set ℕ), Ioo (c i) (d i)) → (ofReal (f b - f a) : ℝ≥0∞) ≤ ∑ i ∈ s, ofReal (f (d i) - f (c i)) by rcases isCompact_Icc.elim_finite_subcover_image (fun (i : ℕ) (_ : i ∈ univ) => @isOpen_Ioo _ _ _ _ (c i) (d i)) (by simpa using ss) with ⟨s, _, hf, hs⟩ have e : ⋃ i ∈ (hf.toFinset : Set ℕ), Ioo (c i) (d i) = ⋃ i ∈ s, Ioo (c i) (d i) := by simp only [ext_iff, exists_prop, Finset.set_biUnion_coe, mem_iUnion, forall_const, iff_self_iff, Finite.mem_toFinset] rw [ENNReal.tsum_eq_iSup_sum] refine le_trans ?_ (le_iSup _ hf.toFinset) exact this hf.toFinset _ (by simpa only [e] ) clear ss b refine fun s => Finset.strongInductionOn s fun s IH b cv => ?_ rcases le_total b a with ab | ab · rw [ENNReal.ofReal_eq_zero.2 (sub_nonpos.2 (f.mono ab))] exact zero_le _ have := cv ⟨ab, le_rfl⟩ simp only [Finset.mem_coe, gt_iff_lt, not_lt, ge_iff_le, mem_iUnion, mem_Ioo, exists_and_left, exists_prop] at this rcases this with ⟨i, cb, is, bd⟩ rw [← Finset.insert_erase is] at cv ⊢ rw [Finset.coe_insert, biUnion_insert] at cv rw [Finset.sum_insert (Finset.not_mem_erase _ _)] refine le_trans ?_ (add_le_add_left (IH _ (Finset.erase_ssubset is) (c i) ?_) _) · refine le_trans (ENNReal.ofReal_le_ofReal ?_) ENNReal.ofReal_add_le rw [sub_add_sub_cancel] exact sub_le_sub_right (f.mono bd.le) _ · rintro x ⟨h₁, h₂⟩ exact (cv ⟨h₁, le_trans h₂ (le_of_lt cb)⟩).resolve_left (mt And.left (not_lt_of_le h₂)) #align stieltjes_function.length_subadditive_Icc_Ioo StieltjesFunction.length_subadditive_Icc_Ioo @[simp] theorem outer_Ioc (a b : ℝ) : f.outer (Ioc a b) = ofReal (f b - f a) := by refine le_antisymm (by rw [← f.length_Ioc] apply outer_le_length) (le_iInf₂ fun s hs => ENNReal.le_of_forall_pos_le_add fun ε εpos h => ?_) let δ := ε / 2 have δpos : 0 < (δ : ℝ≥0∞) := by simpa [δ] using εpos.ne' rcases ENNReal.exists_pos_sum_of_countable δpos.ne' ℕ with ⟨ε', ε'0, hε⟩ obtain ⟨a', ha', aa'⟩ : ∃ a', f a' - f a < δ ∧ a < a' := by have A : ContinuousWithinAt (fun r => f r - f a) (Ioi a) a := by refine ContinuousWithinAt.sub ?_ continuousWithinAt_const exact (f.right_continuous a).mono Ioi_subset_Ici_self have B : f a - f a < δ := by rwa [sub_self, NNReal.coe_pos, ← ENNReal.coe_pos] exact (((tendsto_order.1 A).2 _ B).and self_mem_nhdsWithin).exists have : ∀ i, ∃ p : ℝ × ℝ, s i ⊆ Ioo p.1 p.2 ∧ (ofReal (f p.2 - f p.1) : ℝ≥0∞) < f.length (s i) + ε' i := by intro i have hl := ENNReal.lt_add_right ((ENNReal.le_tsum i).trans_lt h).ne (ENNReal.coe_ne_zero.2 (ε'0 i).ne') conv at hl => lhs rw [length] simp only [iInf_lt_iff, exists_prop] at hl rcases hl with ⟨p, q', spq, hq'⟩ have : ContinuousWithinAt (fun r => ofReal (f r - f p)) (Ioi q') q' := by apply ENNReal.continuous_ofReal.continuousAt.comp_continuousWithinAt refine ContinuousWithinAt.sub ?_ continuousWithinAt_const exact (f.right_continuous q').mono Ioi_subset_Ici_self rcases (((tendsto_order.1 this).2 _ hq').and self_mem_nhdsWithin).exists with ⟨q, hq, q'q⟩ exact ⟨⟨p, q⟩, spq.trans (Ioc_subset_Ioo_right q'q), hq⟩ choose g hg using this have I_subset : Icc a' b ⊆ ⋃ i, Ioo (g i).1 (g i).2 := calc Icc a' b ⊆ Ioc a b := fun x hx => ⟨aa'.trans_le hx.1, hx.2⟩ _ ⊆ ⋃ i, s i := hs _ ⊆ ⋃ i, Ioo (g i).1 (g i).2 := iUnion_mono fun i => (hg i).1 calc ofReal (f b - f a) = ofReal (f b - f a' + (f a' - f a)) := by rw [sub_add_sub_cancel] _ ≤ ofReal (f b - f a') + ofReal (f a' - f a) := ENNReal.ofReal_add_le _ ≤ ∑' i, ofReal (f (g i).2 - f (g i).1) + ofReal δ := (add_le_add (f.length_subadditive_Icc_Ioo I_subset) (ENNReal.ofReal_le_ofReal ha'.le)) _ ≤ ∑' i, (f.length (s i) + ε' i) + δ := (add_le_add (ENNReal.tsum_le_tsum fun i => (hg i).2.le) (by simp only [ENNReal.ofReal_coe_nnreal, le_rfl])) _ = ∑' i, f.length (s i) + ∑' i, (ε' i : ℝ≥0∞) + δ := by rw [ENNReal.tsum_add] _ ≤ ∑' i, f.length (s i) + δ + δ := add_le_add (add_le_add le_rfl hε.le) le_rfl _ = ∑' i : ℕ, f.length (s i) + ε := by simp [δ, add_assoc, ENNReal.add_halves] #align stieltjes_function.outer_Ioc StieltjesFunction.outer_Ioc theorem measurableSet_Ioi {c : ℝ} : MeasurableSet[f.outer.caratheodory] (Ioi c) := by refine OuterMeasure.ofFunction_caratheodory fun t => ?_ refine le_iInf fun a => le_iInf fun b => le_iInf fun h => ?_ refine le_trans (add_le_add (f.length_mono <| inter_subset_inter_left _ h) (f.length_mono <| diff_subset_diff_left h)) ?_ rcases le_total a c with hac | hac <;> rcases le_total b c with hbc | hbc · simp only [Ioc_inter_Ioi, f.length_Ioc, hac, _root_.sup_eq_max, hbc, le_refl, Ioc_eq_empty, max_eq_right, min_eq_left, Ioc_diff_Ioi, f.length_empty, zero_add, not_lt] · simp only [hac, hbc, Ioc_inter_Ioi, Ioc_diff_Ioi, f.length_Ioc, min_eq_right, _root_.sup_eq_max, ← ENNReal.ofReal_add, f.mono hac, f.mono hbc, sub_nonneg, sub_add_sub_cancel, le_refl, max_eq_right] · simp only [hbc, le_refl, Ioc_eq_empty, Ioc_inter_Ioi, min_eq_left, Ioc_diff_Ioi, f.length_empty, zero_add, or_true_iff, le_sup_iff, f.length_Ioc, not_lt] · simp only [hac, hbc, Ioc_inter_Ioi, Ioc_diff_Ioi, f.length_Ioc, min_eq_right, _root_.sup_eq_max, le_refl, Ioc_eq_empty, add_zero, max_eq_left, f.length_empty, not_lt] #align stieltjes_function.measurable_set_Ioi StieltjesFunction.measurableSet_Ioi theorem outer_trim : f.outer.trim = f.outer := by refine le_antisymm (fun s => ?_) (OuterMeasure.le_trim _) rw [OuterMeasure.trim_eq_iInf] refine le_iInf fun t => le_iInf fun ht => ENNReal.le_of_forall_pos_le_add fun ε ε0 h => ?_ rcases ENNReal.exists_pos_sum_of_countable (ENNReal.coe_pos.2 ε0).ne' ℕ with ⟨ε', ε'0, hε⟩ refine le_trans ?_ (add_le_add_left (le_of_lt hε) _) rw [← ENNReal.tsum_add] choose g hg using show ∀ i, ∃ s, t i ⊆ s ∧ MeasurableSet s ∧ f.outer s ≤ f.length (t i) + ofReal (ε' i) by intro i have hl := ENNReal.lt_add_right ((ENNReal.le_tsum i).trans_lt h).ne (ENNReal.coe_pos.2 (ε'0 i)).ne' conv at hl => lhs rw [length] simp only [iInf_lt_iff] at hl rcases hl with ⟨a, b, h₁, h₂⟩ rw [← f.outer_Ioc] at h₂ exact ⟨_, h₁, measurableSet_Ioc, le_of_lt <| by simpa using h₂⟩ simp only [ofReal_coe_nnreal] at hg apply iInf_le_of_le (iUnion g) _ apply iInf_le_of_le (ht.trans <| iUnion_mono fun i => (hg i).1) _ apply iInf_le_of_le (MeasurableSet.iUnion fun i => (hg i).2.1) _ exact le_trans (measure_iUnion_le _) (ENNReal.tsum_le_tsum fun i => (hg i).2.2) #align stieltjes_function.outer_trim StieltjesFunction.outer_trim
Mathlib/MeasureTheory/Measure/Stieltjes.lean
334
337
theorem borel_le_measurable : borel ℝ ≤ f.outer.caratheodory := by
rw [borel_eq_generateFrom_Ioi] refine MeasurableSpace.generateFrom_le ?_ simp (config := { contextual := true }) [f.measurableSet_Ioi]
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
Mathlib/RingTheory/Polynomial/Cyclotomic/Roots.lean
99
104
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']
import Mathlib.Algebra.GroupWithZero.Indicator import Mathlib.Topology.ContinuousOn import Mathlib.Topology.Instances.ENNReal #align_import topology.semicontinuous from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open Topology ENNReal open Set Function Filter variable {α : Type*} [TopologicalSpace α] {β : Type*} [Preorder β] {f g : α → β} {x : α} {s t : Set α} {y z : β} def LowerSemicontinuousWithinAt (f : α → β) (s : Set α) (x : α) := ∀ y < f x, ∀ᶠ x' in 𝓝[s] x, y < f x' #align lower_semicontinuous_within_at LowerSemicontinuousWithinAt def LowerSemicontinuousOn (f : α → β) (s : Set α) := ∀ x ∈ s, LowerSemicontinuousWithinAt f s x #align lower_semicontinuous_on LowerSemicontinuousOn def LowerSemicontinuousAt (f : α → β) (x : α) := ∀ y < f x, ∀ᶠ x' in 𝓝 x, y < f x' #align lower_semicontinuous_at LowerSemicontinuousAt def LowerSemicontinuous (f : α → β) := ∀ x, LowerSemicontinuousAt f x #align lower_semicontinuous LowerSemicontinuous def UpperSemicontinuousWithinAt (f : α → β) (s : Set α) (x : α) := ∀ y, f x < y → ∀ᶠ x' in 𝓝[s] x, f x' < y #align upper_semicontinuous_within_at UpperSemicontinuousWithinAt def UpperSemicontinuousOn (f : α → β) (s : Set α) := ∀ x ∈ s, UpperSemicontinuousWithinAt f s x #align upper_semicontinuous_on UpperSemicontinuousOn def UpperSemicontinuousAt (f : α → β) (x : α) := ∀ y, f x < y → ∀ᶠ x' in 𝓝 x, f x' < y #align upper_semicontinuous_at UpperSemicontinuousAt def UpperSemicontinuous (f : α → β) := ∀ x, UpperSemicontinuousAt f x #align upper_semicontinuous UpperSemicontinuous theorem LowerSemicontinuousWithinAt.mono (h : LowerSemicontinuousWithinAt f s x) (hst : t ⊆ s) : LowerSemicontinuousWithinAt f t x := fun y hy => Filter.Eventually.filter_mono (nhdsWithin_mono _ hst) (h y hy) #align lower_semicontinuous_within_at.mono LowerSemicontinuousWithinAt.mono theorem lowerSemicontinuousWithinAt_univ_iff : LowerSemicontinuousWithinAt f univ x ↔ LowerSemicontinuousAt f x := by simp [LowerSemicontinuousWithinAt, LowerSemicontinuousAt, nhdsWithin_univ] #align lower_semicontinuous_within_at_univ_iff lowerSemicontinuousWithinAt_univ_iff theorem LowerSemicontinuousAt.lowerSemicontinuousWithinAt (s : Set α) (h : LowerSemicontinuousAt f x) : LowerSemicontinuousWithinAt f s x := fun y hy => Filter.Eventually.filter_mono nhdsWithin_le_nhds (h y hy) #align lower_semicontinuous_at.lower_semicontinuous_within_at LowerSemicontinuousAt.lowerSemicontinuousWithinAt theorem LowerSemicontinuousOn.lowerSemicontinuousWithinAt (h : LowerSemicontinuousOn f s) (hx : x ∈ s) : LowerSemicontinuousWithinAt f s x := h x hx #align lower_semicontinuous_on.lower_semicontinuous_within_at LowerSemicontinuousOn.lowerSemicontinuousWithinAt theorem LowerSemicontinuousOn.mono (h : LowerSemicontinuousOn f s) (hst : t ⊆ s) : LowerSemicontinuousOn f t := fun x hx => (h x (hst hx)).mono hst #align lower_semicontinuous_on.mono LowerSemicontinuousOn.mono theorem lowerSemicontinuousOn_univ_iff : LowerSemicontinuousOn f univ ↔ LowerSemicontinuous f := by simp [LowerSemicontinuousOn, LowerSemicontinuous, lowerSemicontinuousWithinAt_univ_iff] #align lower_semicontinuous_on_univ_iff lowerSemicontinuousOn_univ_iff theorem LowerSemicontinuous.lowerSemicontinuousAt (h : LowerSemicontinuous f) (x : α) : LowerSemicontinuousAt f x := h x #align lower_semicontinuous.lower_semicontinuous_at LowerSemicontinuous.lowerSemicontinuousAt theorem LowerSemicontinuous.lowerSemicontinuousWithinAt (h : LowerSemicontinuous f) (s : Set α) (x : α) : LowerSemicontinuousWithinAt f s x := (h x).lowerSemicontinuousWithinAt s #align lower_semicontinuous.lower_semicontinuous_within_at LowerSemicontinuous.lowerSemicontinuousWithinAt theorem LowerSemicontinuous.lowerSemicontinuousOn (h : LowerSemicontinuous f) (s : Set α) : LowerSemicontinuousOn f s := fun x _hx => h.lowerSemicontinuousWithinAt s x #align lower_semicontinuous.lower_semicontinuous_on LowerSemicontinuous.lowerSemicontinuousOn theorem lowerSemicontinuousWithinAt_const : LowerSemicontinuousWithinAt (fun _x => z) s x := fun _y hy => Filter.eventually_of_forall fun _x => hy #align lower_semicontinuous_within_at_const lowerSemicontinuousWithinAt_const theorem lowerSemicontinuousAt_const : LowerSemicontinuousAt (fun _x => z) x := fun _y hy => Filter.eventually_of_forall fun _x => hy #align lower_semicontinuous_at_const lowerSemicontinuousAt_const theorem lowerSemicontinuousOn_const : LowerSemicontinuousOn (fun _x => z) s := fun _x _hx => lowerSemicontinuousWithinAt_const #align lower_semicontinuous_on_const lowerSemicontinuousOn_const theorem lowerSemicontinuous_const : LowerSemicontinuous fun _x : α => z := fun _x => lowerSemicontinuousAt_const #align lower_semicontinuous_const lowerSemicontinuous_const section variable [Zero β] theorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) : LowerSemicontinuous (indicator s fun _x => y) := by intro x z hz by_cases h : x ∈ s <;> simp [h] at hz · filter_upwards [hs.mem_nhds h] simp (config := { contextual := true }) [hz] · refine Filter.eventually_of_forall fun x' => ?_ by_cases h' : x' ∈ s <;> simp [h', hz.trans_le hy, hz] #align is_open.lower_semicontinuous_indicator IsOpen.lowerSemicontinuous_indicator theorem IsOpen.lowerSemicontinuousOn_indicator (hs : IsOpen s) (hy : 0 ≤ y) : LowerSemicontinuousOn (indicator s fun _x => y) t := (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousOn t #align is_open.lower_semicontinuous_on_indicator IsOpen.lowerSemicontinuousOn_indicator theorem IsOpen.lowerSemicontinuousAt_indicator (hs : IsOpen s) (hy : 0 ≤ y) : LowerSemicontinuousAt (indicator s fun _x => y) x := (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousAt x #align is_open.lower_semicontinuous_at_indicator IsOpen.lowerSemicontinuousAt_indicator theorem IsOpen.lowerSemicontinuousWithinAt_indicator (hs : IsOpen s) (hy : 0 ≤ y) : LowerSemicontinuousWithinAt (indicator s fun _x => y) t x := (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousWithinAt t x #align is_open.lower_semicontinuous_within_at_indicator IsOpen.lowerSemicontinuousWithinAt_indicator
Mathlib/Topology/Semicontinuous.lean
238
245
theorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) : LowerSemicontinuous (indicator s fun _x => y) := by
intro x z hz by_cases h : x ∈ s <;> simp [h] at hz · refine Filter.eventually_of_forall fun x' => ?_ by_cases h' : x' ∈ s <;> simp [h', hz, hz.trans_le hy] · filter_upwards [hs.isOpen_compl.mem_nhds h] simp (config := { contextual := true }) [hz]
import Mathlib.Algebra.Field.Basic import Mathlib.Algebra.GroupWithZero.Units.Equiv import Mathlib.Algebra.Order.Field.Defs import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Order.Bounds.OrderIso import Mathlib.Tactic.Positivity.Core #align_import algebra.order.field.basic from "leanprover-community/mathlib"@"84771a9f5f0bd5e5d6218811556508ddf476dcbd" open Function OrderDual variable {ι α β : Type*} section LinearOrderedSemifield variable [LinearOrderedSemifield α] {a b c d e : α} {m n : ℤ} @[simps! (config := { simpRhs := true })] def OrderIso.mulLeft₀ (a : α) (ha : 0 < a) : α ≃o α := { Equiv.mulLeft₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_left ha } #align order_iso.mul_left₀ OrderIso.mulLeft₀ #align order_iso.mul_left₀_symm_apply OrderIso.mulLeft₀_symm_apply #align order_iso.mul_left₀_apply OrderIso.mulLeft₀_apply @[simps! (config := { simpRhs := true })] def OrderIso.mulRight₀ (a : α) (ha : 0 < a) : α ≃o α := { Equiv.mulRight₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_right ha } #align order_iso.mul_right₀ OrderIso.mulRight₀ #align order_iso.mul_right₀_symm_apply OrderIso.mulRight₀_symm_apply #align order_iso.mul_right₀_apply OrderIso.mulRight₀_apply theorem le_div_iff (hc : 0 < c) : a ≤ b / c ↔ a * c ≤ b := ⟨fun h => div_mul_cancel₀ b (ne_of_lt hc).symm ▸ mul_le_mul_of_nonneg_right h hc.le, fun h => calc a = a * c * (1 / c) := mul_mul_div a (ne_of_lt hc).symm _ ≤ b * (1 / c) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hc).le _ = b / c := (div_eq_mul_one_div b c).symm ⟩ #align le_div_iff le_div_iff theorem le_div_iff' (hc : 0 < c) : a ≤ b / c ↔ c * a ≤ b := by rw [mul_comm, le_div_iff hc] #align le_div_iff' le_div_iff' theorem div_le_iff (hb : 0 < b) : a / b ≤ c ↔ a ≤ c * b := ⟨fun h => calc a = a / b * b := by rw [div_mul_cancel₀ _ (ne_of_lt hb).symm] _ ≤ c * b := mul_le_mul_of_nonneg_right h hb.le , fun h => calc a / b = a * (1 / b) := div_eq_mul_one_div a b _ ≤ c * b * (1 / b) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hb).le _ = c * b / b := (div_eq_mul_one_div (c * b) b).symm _ = c := by refine (div_eq_iff (ne_of_gt hb)).mpr rfl ⟩ #align div_le_iff div_le_iff theorem div_le_iff' (hb : 0 < b) : a / b ≤ c ↔ a ≤ b * c := by rw [mul_comm, div_le_iff hb] #align div_le_iff' div_le_iff' lemma div_le_comm₀ (hb : 0 < b) (hc : 0 < c) : a / b ≤ c ↔ a / c ≤ b := by rw [div_le_iff hb, div_le_iff' hc] theorem lt_div_iff (hc : 0 < c) : a < b / c ↔ a * c < b := lt_iff_lt_of_le_iff_le <| div_le_iff hc #align lt_div_iff lt_div_iff theorem lt_div_iff' (hc : 0 < c) : a < b / c ↔ c * a < b := by rw [mul_comm, lt_div_iff hc] #align lt_div_iff' lt_div_iff' theorem div_lt_iff (hc : 0 < c) : b / c < a ↔ b < a * c := lt_iff_lt_of_le_iff_le (le_div_iff hc) #align div_lt_iff div_lt_iff theorem div_lt_iff' (hc : 0 < c) : b / c < a ↔ b < c * a := by rw [mul_comm, div_lt_iff hc] #align div_lt_iff' div_lt_iff' lemma div_lt_comm₀ (hb : 0 < b) (hc : 0 < c) : a / b < c ↔ a / c < b := by rw [div_lt_iff hb, div_lt_iff' hc] theorem inv_mul_le_iff (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ b * c := by rw [inv_eq_one_div, mul_comm, ← div_eq_mul_one_div] exact div_le_iff' h #align inv_mul_le_iff inv_mul_le_iff theorem inv_mul_le_iff' (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ c * b := by rw [inv_mul_le_iff h, mul_comm] #align inv_mul_le_iff' inv_mul_le_iff' theorem mul_inv_le_iff (h : 0 < b) : a * b⁻¹ ≤ c ↔ a ≤ b * c := by rw [mul_comm, inv_mul_le_iff h] #align mul_inv_le_iff mul_inv_le_iff theorem mul_inv_le_iff' (h : 0 < b) : a * b⁻¹ ≤ c ↔ a ≤ c * b := by rw [mul_comm, inv_mul_le_iff' h] #align mul_inv_le_iff' mul_inv_le_iff' theorem div_self_le_one (a : α) : a / a ≤ 1 := if h : a = 0 then by simp [h] else by simp [h] #align div_self_le_one div_self_le_one theorem inv_mul_lt_iff (h : 0 < b) : b⁻¹ * a < c ↔ a < b * c := by rw [inv_eq_one_div, mul_comm, ← div_eq_mul_one_div] exact div_lt_iff' h #align inv_mul_lt_iff inv_mul_lt_iff theorem inv_mul_lt_iff' (h : 0 < b) : b⁻¹ * a < c ↔ a < c * b := by rw [inv_mul_lt_iff h, mul_comm] #align inv_mul_lt_iff' inv_mul_lt_iff' theorem mul_inv_lt_iff (h : 0 < b) : a * b⁻¹ < c ↔ a < b * c := by rw [mul_comm, inv_mul_lt_iff h] #align mul_inv_lt_iff mul_inv_lt_iff theorem mul_inv_lt_iff' (h : 0 < b) : a * b⁻¹ < c ↔ a < c * b := by rw [mul_comm, inv_mul_lt_iff' h] #align mul_inv_lt_iff' mul_inv_lt_iff' theorem inv_pos_le_iff_one_le_mul (ha : 0 < a) : a⁻¹ ≤ b ↔ 1 ≤ b * a := by rw [inv_eq_one_div] exact div_le_iff ha #align inv_pos_le_iff_one_le_mul inv_pos_le_iff_one_le_mul theorem inv_pos_le_iff_one_le_mul' (ha : 0 < a) : a⁻¹ ≤ b ↔ 1 ≤ a * b := by rw [inv_eq_one_div] exact div_le_iff' ha #align inv_pos_le_iff_one_le_mul' inv_pos_le_iff_one_le_mul' theorem inv_pos_lt_iff_one_lt_mul (ha : 0 < a) : a⁻¹ < b ↔ 1 < b * a := by rw [inv_eq_one_div] exact div_lt_iff ha #align inv_pos_lt_iff_one_lt_mul inv_pos_lt_iff_one_lt_mul theorem inv_pos_lt_iff_one_lt_mul' (ha : 0 < a) : a⁻¹ < b ↔ 1 < a * b := by rw [inv_eq_one_div] exact div_lt_iff' ha #align inv_pos_lt_iff_one_lt_mul' inv_pos_lt_iff_one_lt_mul' theorem div_le_of_nonneg_of_le_mul (hb : 0 ≤ b) (hc : 0 ≤ c) (h : a ≤ c * b) : a / b ≤ c := by rcases eq_or_lt_of_le hb with (rfl | hb') · simp only [div_zero, hc] · rwa [div_le_iff hb'] #align div_le_of_nonneg_of_le_mul div_le_of_nonneg_of_le_mul lemma mul_le_of_nonneg_of_le_div (hb : 0 ≤ b) (hc : 0 ≤ c) (h : a ≤ b / c) : a * c ≤ b := by obtain rfl | hc := hc.eq_or_lt · simpa using hb · rwa [le_div_iff hc] at h #align mul_le_of_nonneg_of_le_div mul_le_of_nonneg_of_le_div theorem div_le_one_of_le (h : a ≤ b) (hb : 0 ≤ b) : a / b ≤ 1 := div_le_of_nonneg_of_le_mul hb zero_le_one <| by rwa [one_mul] #align div_le_one_of_le div_le_one_of_le lemma mul_inv_le_one_of_le (h : a ≤ b) (hb : 0 ≤ b) : a * b⁻¹ ≤ 1 := by simpa only [← div_eq_mul_inv] using div_le_one_of_le h hb lemma inv_mul_le_one_of_le (h : a ≤ b) (hb : 0 ≤ b) : b⁻¹ * a ≤ 1 := by simpa only [← div_eq_inv_mul] using div_le_one_of_le h hb @[gcongr] theorem inv_le_inv_of_le (ha : 0 < a) (h : a ≤ b) : b⁻¹ ≤ a⁻¹ := by rwa [← one_div a, le_div_iff' ha, ← div_eq_mul_inv, div_le_iff (ha.trans_le h), one_mul] #align inv_le_inv_of_le inv_le_inv_of_le theorem inv_le_inv (ha : 0 < a) (hb : 0 < b) : a⁻¹ ≤ b⁻¹ ↔ b ≤ a := by rw [← one_div, div_le_iff ha, ← div_eq_inv_mul, le_div_iff hb, one_mul] #align inv_le_inv inv_le_inv theorem inv_le (ha : 0 < a) (hb : 0 < b) : a⁻¹ ≤ b ↔ b⁻¹ ≤ a := by rw [← inv_le_inv hb (inv_pos.2 ha), inv_inv] #align inv_le inv_le theorem inv_le_of_inv_le (ha : 0 < a) (h : a⁻¹ ≤ b) : b⁻¹ ≤ a := (inv_le ha ((inv_pos.2 ha).trans_le h)).1 h #align inv_le_of_inv_le inv_le_of_inv_le theorem le_inv (ha : 0 < a) (hb : 0 < b) : a ≤ b⁻¹ ↔ b ≤ a⁻¹ := by rw [← inv_le_inv (inv_pos.2 hb) ha, inv_inv] #align le_inv le_inv theorem inv_lt_inv (ha : 0 < a) (hb : 0 < b) : a⁻¹ < b⁻¹ ↔ b < a := lt_iff_lt_of_le_iff_le (inv_le_inv hb ha) #align inv_lt_inv inv_lt_inv @[gcongr] theorem inv_lt_inv_of_lt (hb : 0 < b) (h : b < a) : a⁻¹ < b⁻¹ := (inv_lt_inv (hb.trans h) hb).2 h #align inv_lt_inv_of_lt inv_lt_inv_of_lt theorem inv_lt (ha : 0 < a) (hb : 0 < b) : a⁻¹ < b ↔ b⁻¹ < a := lt_iff_lt_of_le_iff_le (le_inv hb ha) #align inv_lt inv_lt theorem inv_lt_of_inv_lt (ha : 0 < a) (h : a⁻¹ < b) : b⁻¹ < a := (inv_lt ha ((inv_pos.2 ha).trans h)).1 h #align inv_lt_of_inv_lt inv_lt_of_inv_lt theorem lt_inv (ha : 0 < a) (hb : 0 < b) : a < b⁻¹ ↔ b < a⁻¹ := lt_iff_lt_of_le_iff_le (inv_le hb ha) #align lt_inv lt_inv theorem inv_lt_one (ha : 1 < a) : a⁻¹ < 1 := by rwa [inv_lt (zero_lt_one.trans ha) zero_lt_one, inv_one] #align inv_lt_one inv_lt_one theorem one_lt_inv (h₁ : 0 < a) (h₂ : a < 1) : 1 < a⁻¹ := by rwa [lt_inv (@zero_lt_one α _ _ _ _ _) h₁, inv_one] #align one_lt_inv one_lt_inv theorem inv_le_one (ha : 1 ≤ a) : a⁻¹ ≤ 1 := by rwa [inv_le (zero_lt_one.trans_le ha) zero_lt_one, inv_one] #align inv_le_one inv_le_one theorem one_le_inv (h₁ : 0 < a) (h₂ : a ≤ 1) : 1 ≤ a⁻¹ := by rwa [le_inv (@zero_lt_one α _ _ _ _ _) h₁, inv_one] #align one_le_inv one_le_inv theorem inv_lt_one_iff_of_pos (h₀ : 0 < a) : a⁻¹ < 1 ↔ 1 < a := ⟨fun h₁ => inv_inv a ▸ one_lt_inv (inv_pos.2 h₀) h₁, inv_lt_one⟩ #align inv_lt_one_iff_of_pos inv_lt_one_iff_of_pos theorem inv_lt_one_iff : a⁻¹ < 1 ↔ a ≤ 0 ∨ 1 < a := by rcases le_or_lt a 0 with ha | ha · simp [ha, (inv_nonpos.2 ha).trans_lt zero_lt_one] · simp only [ha.not_le, false_or_iff, inv_lt_one_iff_of_pos ha] #align inv_lt_one_iff inv_lt_one_iff theorem one_lt_inv_iff : 1 < a⁻¹ ↔ 0 < a ∧ a < 1 := ⟨fun h => ⟨inv_pos.1 (zero_lt_one.trans h), inv_inv a ▸ inv_lt_one h⟩, and_imp.2 one_lt_inv⟩ #align one_lt_inv_iff one_lt_inv_iff theorem inv_le_one_iff : a⁻¹ ≤ 1 ↔ a ≤ 0 ∨ 1 ≤ a := by rcases em (a = 1) with (rfl | ha) · simp [le_rfl] · simp only [Ne.le_iff_lt (Ne.symm ha), Ne.le_iff_lt (mt inv_eq_one.1 ha), inv_lt_one_iff] #align inv_le_one_iff inv_le_one_iff theorem one_le_inv_iff : 1 ≤ a⁻¹ ↔ 0 < a ∧ a ≤ 1 := ⟨fun h => ⟨inv_pos.1 (zero_lt_one.trans_le h), inv_inv a ▸ inv_le_one h⟩, and_imp.2 one_le_inv⟩ #align one_le_inv_iff one_le_inv_iff @[mono, gcongr] lemma div_le_div_of_nonneg_right (hab : a ≤ b) (hc : 0 ≤ c) : a / c ≤ b / c := by rw [div_eq_mul_one_div a c, div_eq_mul_one_div b c] exact mul_le_mul_of_nonneg_right hab (one_div_nonneg.2 hc) #align div_le_div_of_le_of_nonneg div_le_div_of_nonneg_right @[gcongr] lemma div_lt_div_of_pos_right (h : a < b) (hc : 0 < c) : a / c < b / c := by rw [div_eq_mul_one_div a c, div_eq_mul_one_div b c] exact mul_lt_mul_of_pos_right h (one_div_pos.2 hc) #align div_lt_div_of_lt div_lt_div_of_pos_right -- Not a `mono` lemma b/c `div_le_div` is strictly more general @[gcongr] lemma div_le_div_of_nonneg_left (ha : 0 ≤ a) (hc : 0 < c) (h : c ≤ b) : a / b ≤ a / c := by rw [div_eq_mul_inv, div_eq_mul_inv] exact mul_le_mul_of_nonneg_left ((inv_le_inv (hc.trans_le h) hc).mpr h) ha #align div_le_div_of_le_left div_le_div_of_nonneg_left @[gcongr] lemma div_lt_div_of_pos_left (ha : 0 < a) (hc : 0 < c) (h : c < b) : a / b < a / c := by simpa only [div_eq_mul_inv, mul_lt_mul_left ha, inv_lt_inv (hc.trans h) hc] #align div_lt_div_of_lt_left div_lt_div_of_pos_left -- 2024-02-16 @[deprecated] alias div_le_div_of_le_of_nonneg := div_le_div_of_nonneg_right @[deprecated] alias div_lt_div_of_lt := div_lt_div_of_pos_right @[deprecated] alias div_le_div_of_le_left := div_le_div_of_nonneg_left @[deprecated] alias div_lt_div_of_lt_left := div_lt_div_of_pos_left @[deprecated div_le_div_of_nonneg_right (since := "2024-02-16")] lemma div_le_div_of_le (hc : 0 ≤ c) (hab : a ≤ b) : a / c ≤ b / c := div_le_div_of_nonneg_right hab hc #align div_le_div_of_le div_le_div_of_le theorem div_le_div_right (hc : 0 < c) : a / c ≤ b / c ↔ a ≤ b := ⟨le_imp_le_of_lt_imp_lt fun hab ↦ div_lt_div_of_pos_right hab hc, fun hab ↦ div_le_div_of_nonneg_right hab hc.le⟩ #align div_le_div_right div_le_div_right theorem div_lt_div_right (hc : 0 < c) : a / c < b / c ↔ a < b := lt_iff_lt_of_le_iff_le <| div_le_div_right hc #align div_lt_div_right div_lt_div_right theorem div_lt_div_left (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : a / b < a / c ↔ c < b := by simp only [div_eq_mul_inv, mul_lt_mul_left ha, inv_lt_inv hb hc] #align div_lt_div_left div_lt_div_left theorem div_le_div_left (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : a / b ≤ a / c ↔ c ≤ b := le_iff_le_iff_lt_iff_lt.2 (div_lt_div_left ha hc hb) #align div_le_div_left div_le_div_left theorem div_lt_div_iff (b0 : 0 < b) (d0 : 0 < d) : a / b < c / d ↔ a * d < c * b := by rw [lt_div_iff d0, div_mul_eq_mul_div, div_lt_iff b0] #align div_lt_div_iff div_lt_div_iff theorem div_le_div_iff (b0 : 0 < b) (d0 : 0 < d) : a / b ≤ c / d ↔ a * d ≤ c * b := by rw [le_div_iff d0, div_mul_eq_mul_div, div_le_iff b0] #align div_le_div_iff div_le_div_iff @[mono, gcongr] theorem div_le_div (hc : 0 ≤ c) (hac : a ≤ c) (hd : 0 < d) (hbd : d ≤ b) : a / b ≤ c / d := by rw [div_le_div_iff (hd.trans_le hbd) hd] exact mul_le_mul hac hbd hd.le hc #align div_le_div div_le_div @[gcongr] theorem div_lt_div (hac : a < c) (hbd : d ≤ b) (c0 : 0 ≤ c) (d0 : 0 < d) : a / b < c / d := (div_lt_div_iff (d0.trans_le hbd) d0).2 (mul_lt_mul hac hbd d0 c0) #align div_lt_div div_lt_div theorem div_lt_div' (hac : a ≤ c) (hbd : d < b) (c0 : 0 < c) (d0 : 0 < d) : a / b < c / d := (div_lt_div_iff (d0.trans hbd) d0).2 (mul_lt_mul' hac hbd d0.le c0) #align div_lt_div' div_lt_div' theorem div_le_self (ha : 0 ≤ a) (hb : 1 ≤ b) : a / b ≤ a := by simpa only [div_one] using div_le_div_of_nonneg_left ha zero_lt_one hb #align div_le_self div_le_self theorem div_lt_self (ha : 0 < a) (hb : 1 < b) : a / b < a := by simpa only [div_one] using div_lt_div_of_pos_left ha zero_lt_one hb #align div_lt_self div_lt_self theorem le_div_self (ha : 0 ≤ a) (hb₀ : 0 < b) (hb₁ : b ≤ 1) : a ≤ a / b := by simpa only [div_one] using div_le_div_of_nonneg_left ha hb₀ hb₁ #align le_div_self le_div_self theorem one_le_div (hb : 0 < b) : 1 ≤ a / b ↔ b ≤ a := by rw [le_div_iff hb, one_mul] #align one_le_div one_le_div theorem div_le_one (hb : 0 < b) : a / b ≤ 1 ↔ a ≤ b := by rw [div_le_iff hb, one_mul] #align div_le_one div_le_one theorem one_lt_div (hb : 0 < b) : 1 < a / b ↔ b < a := by rw [lt_div_iff hb, one_mul] #align one_lt_div one_lt_div theorem div_lt_one (hb : 0 < b) : a / b < 1 ↔ a < b := by rw [div_lt_iff hb, one_mul] #align div_lt_one div_lt_one theorem one_div_le (ha : 0 < a) (hb : 0 < b) : 1 / a ≤ b ↔ 1 / b ≤ a := by simpa using inv_le ha hb #align one_div_le one_div_le theorem one_div_lt (ha : 0 < a) (hb : 0 < b) : 1 / a < b ↔ 1 / b < a := by simpa using inv_lt ha hb #align one_div_lt one_div_lt theorem le_one_div (ha : 0 < a) (hb : 0 < b) : a ≤ 1 / b ↔ b ≤ 1 / a := by simpa using le_inv ha hb #align le_one_div le_one_div theorem lt_one_div (ha : 0 < a) (hb : 0 < b) : a < 1 / b ↔ b < 1 / a := by simpa using lt_inv ha hb #align lt_one_div lt_one_div theorem one_div_le_one_div_of_le (ha : 0 < a) (h : a ≤ b) : 1 / b ≤ 1 / a := by simpa using inv_le_inv_of_le ha h #align one_div_le_one_div_of_le one_div_le_one_div_of_le
Mathlib/Algebra/Order/Field/Basic.lean
397
398
theorem one_div_lt_one_div_of_lt (ha : 0 < a) (h : a < b) : 1 / b < 1 / a := by
rwa [lt_div_iff' ha, ← div_eq_mul_one_div, div_lt_one (ha.trans h)]
import Mathlib.MeasureTheory.Measure.MeasureSpaceDef #align_import measure_theory.measure.ae_disjoint from "leanprover-community/mathlib"@"bc7d81beddb3d6c66f71449c5bc76c38cb77cf9e" open Set Function namespace MeasureTheory variable {ι α : Type*} {m : MeasurableSpace α} (μ : Measure α) def AEDisjoint (s t : Set α) := μ (s ∩ t) = 0 #align measure_theory.ae_disjoint MeasureTheory.AEDisjoint variable {μ} {s t u v : Set α} theorem exists_null_pairwise_disjoint_diff [Countable ι] {s : ι → Set α} (hd : Pairwise (AEDisjoint μ on s)) : ∃ t : ι → Set α, (∀ i, MeasurableSet (t i)) ∧ (∀ i, μ (t i) = 0) ∧ Pairwise (Disjoint on fun i => s i \ t i) := by refine ⟨fun i => toMeasurable μ (s i ∩ ⋃ j ∈ ({i}ᶜ : Set ι), s j), fun i => measurableSet_toMeasurable _ _, fun i => ?_, ?_⟩ · simp only [measure_toMeasurable, inter_iUnion] exact (measure_biUnion_null_iff <| to_countable _).2 fun j hj => hd (Ne.symm hj) · simp only [Pairwise, disjoint_left, onFun, mem_diff, not_and, and_imp, Classical.not_not] intro i j hne x hi hU hj replace hU : x ∉ s i ∩ iUnion fun j ↦ iUnion fun _ ↦ s j := fun h ↦ hU (subset_toMeasurable _ _ h) simp only [mem_inter_iff, mem_iUnion, not_and, not_exists] at hU exact (hU hi j hne.symm hj).elim #align measure_theory.exists_null_pairwise_disjoint_diff MeasureTheory.exists_null_pairwise_disjoint_diff namespace AEDisjoint protected theorem eq (h : AEDisjoint μ s t) : μ (s ∩ t) = 0 := h #align measure_theory.ae_disjoint.eq MeasureTheory.AEDisjoint.eq @[symm] protected theorem symm (h : AEDisjoint μ s t) : AEDisjoint μ t s := by rwa [AEDisjoint, inter_comm] #align measure_theory.ae_disjoint.symm MeasureTheory.AEDisjoint.symm protected theorem symmetric : Symmetric (AEDisjoint μ) := fun _ _ => AEDisjoint.symm #align measure_theory.ae_disjoint.symmetric MeasureTheory.AEDisjoint.symmetric protected theorem comm : AEDisjoint μ s t ↔ AEDisjoint μ t s := ⟨AEDisjoint.symm, AEDisjoint.symm⟩ #align measure_theory.ae_disjoint.comm MeasureTheory.AEDisjoint.comm protected theorem _root_.Disjoint.aedisjoint (h : Disjoint s t) : AEDisjoint μ s t := by rw [AEDisjoint, disjoint_iff_inter_eq_empty.1 h, measure_empty] #align disjoint.ae_disjoint Disjoint.aedisjoint protected theorem _root_.Pairwise.aedisjoint {f : ι → Set α} (hf : Pairwise (Disjoint on f)) : Pairwise (AEDisjoint μ on f) := hf.mono fun _i _j h => h.aedisjoint #align pairwise.ae_disjoint Pairwise.aedisjoint protected theorem _root_.Set.PairwiseDisjoint.aedisjoint {f : ι → Set α} {s : Set ι} (hf : s.PairwiseDisjoint f) : s.Pairwise (AEDisjoint μ on f) := hf.mono' fun _i _j h => h.aedisjoint #align set.pairwise_disjoint.ae_disjoint Set.PairwiseDisjoint.aedisjoint theorem mono_ae (h : AEDisjoint μ s t) (hu : u ≤ᵐ[μ] s) (hv : v ≤ᵐ[μ] t) : AEDisjoint μ u v := measure_mono_null_ae (hu.inter hv) h #align measure_theory.ae_disjoint.mono_ae MeasureTheory.AEDisjoint.mono_ae protected theorem mono (h : AEDisjoint μ s t) (hu : u ⊆ s) (hv : v ⊆ t) : AEDisjoint μ u v := mono_ae h (HasSubset.Subset.eventuallyLE hu) (HasSubset.Subset.eventuallyLE hv) #align measure_theory.ae_disjoint.mono MeasureTheory.AEDisjoint.mono protected theorem congr (h : AEDisjoint μ s t) (hu : u =ᵐ[μ] s) (hv : v =ᵐ[μ] t) : AEDisjoint μ u v := mono_ae h (Filter.EventuallyEq.le hu) (Filter.EventuallyEq.le hv) #align measure_theory.ae_disjoint.congr MeasureTheory.AEDisjoint.congr @[simp] theorem iUnion_left_iff [Countable ι] {s : ι → Set α} : AEDisjoint μ (⋃ i, s i) t ↔ ∀ i, AEDisjoint μ (s i) t := by simp only [AEDisjoint, iUnion_inter, measure_iUnion_null_iff] #align measure_theory.ae_disjoint.Union_left_iff MeasureTheory.AEDisjoint.iUnion_left_iff @[simp] theorem iUnion_right_iff [Countable ι] {t : ι → Set α} : AEDisjoint μ s (⋃ i, t i) ↔ ∀ i, AEDisjoint μ s (t i) := by simp only [AEDisjoint, inter_iUnion, measure_iUnion_null_iff] #align measure_theory.ae_disjoint.Union_right_iff MeasureTheory.AEDisjoint.iUnion_right_iff @[simp]
Mathlib/MeasureTheory/Measure/AEDisjoint.lean
106
107
theorem union_left_iff : AEDisjoint μ (s ∪ t) u ↔ AEDisjoint μ s u ∧ AEDisjoint μ t u := by
simp [union_eq_iUnion, and_comm]
import Mathlib.Analysis.InnerProductSpace.TwoDim import Mathlib.Geometry.Euclidean.Angle.Unoriented.Basic #align_import geometry.euclidean.angle.oriented.basic from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" noncomputable section open FiniteDimensional Complex open scoped Real RealInnerProductSpace ComplexConjugate namespace Orientation attribute [local instance] Complex.finrank_real_complex_fact variable {V V' : Type*} variable [NormedAddCommGroup V] [NormedAddCommGroup V'] variable [InnerProductSpace ℝ V] [InnerProductSpace ℝ V'] variable [Fact (finrank ℝ V = 2)] [Fact (finrank ℝ V' = 2)] (o : Orientation ℝ V (Fin 2)) local notation "ω" => o.areaForm def oangle (x y : V) : Real.Angle := Complex.arg (o.kahler x y) #align orientation.oangle Orientation.oangle theorem continuousAt_oangle {x : V × V} (hx1 : x.1 ≠ 0) (hx2 : x.2 ≠ 0) : ContinuousAt (fun y : V × V => o.oangle y.1 y.2) x := by refine (Complex.continuousAt_arg_coe_angle ?_).comp ?_ · exact o.kahler_ne_zero hx1 hx2 exact ((continuous_ofReal.comp continuous_inner).add ((continuous_ofReal.comp o.areaForm'.continuous₂).mul continuous_const)).continuousAt #align orientation.continuous_at_oangle Orientation.continuousAt_oangle @[simp] theorem oangle_zero_left (x : V) : o.oangle 0 x = 0 := by simp [oangle] #align orientation.oangle_zero_left Orientation.oangle_zero_left @[simp] theorem oangle_zero_right (x : V) : o.oangle x 0 = 0 := by simp [oangle] #align orientation.oangle_zero_right Orientation.oangle_zero_right @[simp] theorem oangle_self (x : V) : o.oangle x x = 0 := by rw [oangle, kahler_apply_self, ← ofReal_pow] convert QuotientAddGroup.mk_zero (AddSubgroup.zmultiples (2 * π)) apply arg_ofReal_of_nonneg positivity #align orientation.oangle_self Orientation.oangle_self theorem left_ne_zero_of_oangle_ne_zero {x y : V} (h : o.oangle x y ≠ 0) : x ≠ 0 := by rintro rfl; simp at h #align orientation.left_ne_zero_of_oangle_ne_zero Orientation.left_ne_zero_of_oangle_ne_zero theorem right_ne_zero_of_oangle_ne_zero {x y : V} (h : o.oangle x y ≠ 0) : y ≠ 0 := by rintro rfl; simp at h #align orientation.right_ne_zero_of_oangle_ne_zero Orientation.right_ne_zero_of_oangle_ne_zero theorem ne_of_oangle_ne_zero {x y : V} (h : o.oangle x y ≠ 0) : x ≠ y := by rintro rfl; simp at h #align orientation.ne_of_oangle_ne_zero Orientation.ne_of_oangle_ne_zero theorem left_ne_zero_of_oangle_eq_pi {x y : V} (h : o.oangle x y = π) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : o.oangle x y ≠ 0) #align orientation.left_ne_zero_of_oangle_eq_pi Orientation.left_ne_zero_of_oangle_eq_pi theorem right_ne_zero_of_oangle_eq_pi {x y : V} (h : o.oangle x y = π) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : o.oangle x y ≠ 0) #align orientation.right_ne_zero_of_oangle_eq_pi Orientation.right_ne_zero_of_oangle_eq_pi theorem ne_of_oangle_eq_pi {x y : V} (h : o.oangle x y = π) : x ≠ y := o.ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : o.oangle x y ≠ 0) #align orientation.ne_of_oangle_eq_pi Orientation.ne_of_oangle_eq_pi theorem left_ne_zero_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.left_ne_zero_of_oangle_eq_pi_div_two Orientation.left_ne_zero_of_oangle_eq_pi_div_two theorem right_ne_zero_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.right_ne_zero_of_oangle_eq_pi_div_two Orientation.right_ne_zero_of_oangle_eq_pi_div_two theorem ne_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : x ≠ y := o.ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.ne_of_oangle_eq_pi_div_two Orientation.ne_of_oangle_eq_pi_div_two theorem left_ne_zero_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.left_ne_zero_of_oangle_eq_neg_pi_div_two Orientation.left_ne_zero_of_oangle_eq_neg_pi_div_two theorem right_ne_zero_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.right_ne_zero_of_oangle_eq_neg_pi_div_two Orientation.right_ne_zero_of_oangle_eq_neg_pi_div_two theorem ne_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : x ≠ y := o.ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.ne_of_oangle_eq_neg_pi_div_two Orientation.ne_of_oangle_eq_neg_pi_div_two theorem left_ne_zero_of_oangle_sign_ne_zero {x y : V} (h : (o.oangle x y).sign ≠ 0) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align orientation.left_ne_zero_of_oangle_sign_ne_zero Orientation.left_ne_zero_of_oangle_sign_ne_zero theorem right_ne_zero_of_oangle_sign_ne_zero {x y : V} (h : (o.oangle x y).sign ≠ 0) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align orientation.right_ne_zero_of_oangle_sign_ne_zero Orientation.right_ne_zero_of_oangle_sign_ne_zero theorem ne_of_oangle_sign_ne_zero {x y : V} (h : (o.oangle x y).sign ≠ 0) : x ≠ y := o.ne_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align orientation.ne_of_oangle_sign_ne_zero Orientation.ne_of_oangle_sign_ne_zero theorem left_ne_zero_of_oangle_sign_eq_one {x y : V} (h : (o.oangle x y).sign = 1) : x ≠ 0 := o.left_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.left_ne_zero_of_oangle_sign_eq_one Orientation.left_ne_zero_of_oangle_sign_eq_one theorem right_ne_zero_of_oangle_sign_eq_one {x y : V} (h : (o.oangle x y).sign = 1) : y ≠ 0 := o.right_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.right_ne_zero_of_oangle_sign_eq_one Orientation.right_ne_zero_of_oangle_sign_eq_one theorem ne_of_oangle_sign_eq_one {x y : V} (h : (o.oangle x y).sign = 1) : x ≠ y := o.ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.ne_of_oangle_sign_eq_one Orientation.ne_of_oangle_sign_eq_one theorem left_ne_zero_of_oangle_sign_eq_neg_one {x y : V} (h : (o.oangle x y).sign = -1) : x ≠ 0 := o.left_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.left_ne_zero_of_oangle_sign_eq_neg_one Orientation.left_ne_zero_of_oangle_sign_eq_neg_one theorem right_ne_zero_of_oangle_sign_eq_neg_one {x y : V} (h : (o.oangle x y).sign = -1) : y ≠ 0 := o.right_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.right_ne_zero_of_oangle_sign_eq_neg_one Orientation.right_ne_zero_of_oangle_sign_eq_neg_one theorem ne_of_oangle_sign_eq_neg_one {x y : V} (h : (o.oangle x y).sign = -1) : x ≠ y := o.ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.ne_of_oangle_sign_eq_neg_one Orientation.ne_of_oangle_sign_eq_neg_one theorem oangle_rev (x y : V) : o.oangle y x = -o.oangle x y := by simp only [oangle, o.kahler_swap y x, Complex.arg_conj_coe_angle] #align orientation.oangle_rev Orientation.oangle_rev @[simp] theorem oangle_add_oangle_rev (x y : V) : o.oangle x y + o.oangle y x = 0 := by simp [o.oangle_rev y x] #align orientation.oangle_add_oangle_rev Orientation.oangle_add_oangle_rev theorem oangle_neg_left {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : o.oangle (-x) y = o.oangle x y + π := by simp only [oangle, map_neg] convert Complex.arg_neg_coe_angle _ exact o.kahler_ne_zero hx hy #align orientation.oangle_neg_left Orientation.oangle_neg_left theorem oangle_neg_right {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : o.oangle x (-y) = o.oangle x y + π := by simp only [oangle, map_neg] convert Complex.arg_neg_coe_angle _ exact o.kahler_ne_zero hx hy #align orientation.oangle_neg_right Orientation.oangle_neg_right @[simp] theorem two_zsmul_oangle_neg_left (x y : V) : (2 : ℤ) • o.oangle (-x) y = (2 : ℤ) • o.oangle x y := by by_cases hx : x = 0 · simp [hx] · by_cases hy : y = 0 · simp [hy] · simp [o.oangle_neg_left hx hy] #align orientation.two_zsmul_oangle_neg_left Orientation.two_zsmul_oangle_neg_left @[simp] theorem two_zsmul_oangle_neg_right (x y : V) : (2 : ℤ) • o.oangle x (-y) = (2 : ℤ) • o.oangle x y := by by_cases hx : x = 0 · simp [hx] · by_cases hy : y = 0 · simp [hy] · simp [o.oangle_neg_right hx hy] #align orientation.two_zsmul_oangle_neg_right Orientation.two_zsmul_oangle_neg_right @[simp] theorem oangle_neg_neg (x y : V) : o.oangle (-x) (-y) = o.oangle x y := by simp [oangle] #align orientation.oangle_neg_neg Orientation.oangle_neg_neg theorem oangle_neg_left_eq_neg_right (x y : V) : o.oangle (-x) y = o.oangle x (-y) := by rw [← neg_neg y, oangle_neg_neg, neg_neg] #align orientation.oangle_neg_left_eq_neg_right Orientation.oangle_neg_left_eq_neg_right @[simp] theorem oangle_neg_self_left {x : V} (hx : x ≠ 0) : o.oangle (-x) x = π := by simp [oangle_neg_left, hx] #align orientation.oangle_neg_self_left Orientation.oangle_neg_self_left @[simp] theorem oangle_neg_self_right {x : V} (hx : x ≠ 0) : o.oangle x (-x) = π := by simp [oangle_neg_right, hx] #align orientation.oangle_neg_self_right Orientation.oangle_neg_self_right -- @[simp] -- Porting note (#10618): simp can prove this theorem two_zsmul_oangle_neg_self_left (x : V) : (2 : ℤ) • o.oangle (-x) x = 0 := by by_cases hx : x = 0 <;> simp [hx] #align orientation.two_zsmul_oangle_neg_self_left Orientation.two_zsmul_oangle_neg_self_left -- @[simp] -- Porting note (#10618): simp can prove this theorem two_zsmul_oangle_neg_self_right (x : V) : (2 : ℤ) • o.oangle x (-x) = 0 := by by_cases hx : x = 0 <;> simp [hx] #align orientation.two_zsmul_oangle_neg_self_right Orientation.two_zsmul_oangle_neg_self_right @[simp]
Mathlib/Geometry/Euclidean/Angle/Oriented/Basic.lean
278
279
theorem oangle_add_oangle_rev_neg_left (x y : V) : o.oangle (-x) y + o.oangle (-y) x = 0 := by
rw [oangle_neg_left_eq_neg_right, oangle_rev, add_left_neg]