Context
stringlengths
57
85k
file_name
stringlengths
21
79
start
int64
14
2.42k
end
int64
18
2.43k
theorem
stringlengths
25
2.71k
proof
stringlengths
5
10.6k
import Mathlib.Algebra.CharP.LocalRing import Mathlib.RingTheory.Ideal.Quotient import Mathlib.Tactic.FieldSimp #align_import algebra.char_p.mixed_char_zero from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" variable (R : Type*) [CommRing R] class MixedCharZero (p : ℕ) : Prop where [toCharZero : CharZero R] charP_quotient : ∃ I : Ideal R, I ≠ ⊤ ∧ CharP (R ⧸ I) p #align mixed_char_zero MixedCharZero namespace EqualCharZero theorem of_algebraRat [Algebra ℚ R] : ∀ I : Ideal R, I ≠ ⊤ → CharZero (R ⧸ I) := by intro I hI constructor intro a b h_ab contrapose! hI -- `↑a - ↑b` is a unit contained in `I`, which contradicts `I ≠ ⊤`. refine I.eq_top_of_isUnit_mem ?_ (IsUnit.map (algebraMap ℚ R) (IsUnit.mk0 (a - b : ℚ) ?_)) · simpa only [← Ideal.Quotient.eq_zero_iff_mem, map_sub, sub_eq_zero, map_natCast] simpa only [Ne, sub_eq_zero] using (@Nat.cast_injective ℚ _ _).ne hI set_option linter.uppercaseLean3 false in #align Q_algebra_to_equal_char_zero EqualCharZero.of_algebraRat section ConstructionAlgebraRat variable {R} theorem PNat.isUnit_natCast [h : Fact (∀ I : Ideal R, I ≠ ⊤ → CharZero (R ⧸ I))] (n : ℕ+) : IsUnit (n : R) := by -- `n : R` is a unit iff `(n)` is not a proper ideal in `R`. rw [← Ideal.span_singleton_eq_top] -- So by contrapositive, we should show the quotient does not have characteristic zero. apply not_imp_comm.mp (h.elim (Ideal.span {↑n})) intro h_char_zero -- In particular, the image of `n` in the quotient should be nonzero. apply h_char_zero.cast_injective.ne n.ne_zero -- But `n` generates the ideal, so its image is clearly zero. rw [← map_natCast (Ideal.Quotient.mk _), Nat.cast_zero, Ideal.Quotient.eq_zero_iff_mem] exact Ideal.subset_span (Set.mem_singleton _) #align equal_char_zero.pnat_coe_is_unit EqualCharZero.PNat.isUnit_natCast @[coe] noncomputable def pnatCast [Fact (∀ I : Ideal R, I ≠ ⊤ → CharZero (R ⧸ I))] : ℕ+ → Rˣ := fun n => (PNat.isUnit_natCast n).unit noncomputable instance coePNatUnits [Fact (∀ I : Ideal R, I ≠ ⊤ → CharZero (R ⧸ I))] : Coe ℕ+ Rˣ := ⟨EqualCharZero.pnatCast⟩ #align equal_char_zero.pnat_has_coe_units EqualCharZero.coePNatUnits @[simp] theorem pnatCast_one [Fact (∀ I : Ideal R, I ≠ ⊤ → CharZero (R ⧸ I))] : ((1 : ℕ+) : Rˣ) = 1 := by apply Units.ext rw [Units.val_one] change ((PNat.isUnit_natCast (R := R) 1).unit : R) = 1 rw [IsUnit.unit_spec (PNat.isUnit_natCast 1)] rw [PNat.one_coe, Nat.cast_one] #align equal_char_zero.pnat_coe_units_eq_one EqualCharZero.pnatCast_one @[simp]
Mathlib/Algebra/CharP/MixedCharZero.lean
214
217
theorem pnatCast_eq_natCast [Fact (∀ I : Ideal R, I ≠ ⊤ → CharZero (R ⧸ I))] (n : ℕ+) : ((n : Rˣ) : R) = ↑n := by
change ((PNat.isUnit_natCast (R := R) n).unit : R) = ↑n simp only [IsUnit.unit_spec]
import Mathlib.Algebra.Group.WithOne.Defs import Mathlib.Algebra.GroupWithZero.InjSurj import Mathlib.Algebra.GroupWithZero.Units.Equiv import Mathlib.Algebra.GroupWithZero.WithZero import Mathlib.Algebra.Order.Group.Units import Mathlib.Algebra.Order.GroupWithZero.Synonym import Mathlib.Algebra.Order.Monoid.Basic import Mathlib.Algebra.Order.Monoid.OrderDual import Mathlib.Algebra.Order.Monoid.TypeTags import Mathlib.Algebra.Order.ZeroLEOne #align_import algebra.order.monoid.with_zero.defs from "leanprover-community/mathlib"@"4dc134b97a3de65ef2ed881f3513d56260971562" #align_import algebra.order.monoid.with_zero.basic from "leanprover-community/mathlib"@"dad7ecf9a1feae63e6e49f07619b7087403fb8d4" #align_import algebra.order.with_zero from "leanprover-community/mathlib"@"655994e298904d7e5bbd1e18c95defd7b543eb94" variable {α : Type*} class LinearOrderedCommMonoidWithZero (α : Type*) extends LinearOrderedCommMonoid α, CommMonoidWithZero α where zero_le_one : (0 : α) ≤ 1 #align linear_ordered_comm_monoid_with_zero LinearOrderedCommMonoidWithZero class LinearOrderedCommGroupWithZero (α : Type*) extends LinearOrderedCommMonoidWithZero α, CommGroupWithZero α #align linear_ordered_comm_group_with_zero LinearOrderedCommGroupWithZero instance (priority := 100) LinearOrderedCommMonoidWithZero.toZeroLeOneClass [LinearOrderedCommMonoidWithZero α] : ZeroLEOneClass α := { ‹LinearOrderedCommMonoidWithZero α› with } #align linear_ordered_comm_monoid_with_zero.to_zero_le_one_class LinearOrderedCommMonoidWithZero.toZeroLeOneClass instance (priority := 100) canonicallyOrderedAddCommMonoid.toZeroLeOneClass [CanonicallyOrderedAddCommMonoid α] [One α] : ZeroLEOneClass α := ⟨zero_le 1⟩ #align canonically_ordered_add_monoid.to_zero_le_one_class canonicallyOrderedAddCommMonoid.toZeroLeOneClass section LinearOrderedCommGroupWithZero variable [LinearOrderedCommGroupWithZero α] {a b c d : α} {m n : ℕ} -- TODO: Do we really need the following two? theorem mul_le_one₀ (ha : a ≤ 1) (hb : b ≤ 1) : a * b ≤ 1 := mul_le_one' ha hb #align mul_le_one₀ mul_le_one₀ theorem one_le_mul₀ (ha : 1 ≤ a) (hb : 1 ≤ b) : 1 ≤ a * b := one_le_mul ha hb #align one_le_mul₀ one_le_mul₀
Mathlib/Algebra/Order/GroupWithZero/Canonical.lean
128
129
theorem le_of_le_mul_right (h : c ≠ 0) (hab : a * c ≤ b * c) : a ≤ b := by
simpa only [mul_inv_cancel_right₀ h] using mul_le_mul_right' hab c⁻¹
import Mathlib.Algebra.BigOperators.Option import Mathlib.Analysis.BoxIntegral.Box.Basic import Mathlib.Data.Set.Pairwise.Lattice #align_import analysis.box_integral.partition.basic from "leanprover-community/mathlib"@"84dc0bd6619acaea625086d6f53cb35cdd554219" open Set Finset Function open scoped Classical open NNReal noncomputable section namespace BoxIntegral variable {ι : Type*} structure Prepartition (I : Box ι) where boxes : Finset (Box ι) le_of_mem' : ∀ J ∈ boxes, J ≤ I pairwiseDisjoint : Set.Pairwise (↑boxes) (Disjoint on ((↑) : Box ι → Set (ι → ℝ))) #align box_integral.prepartition BoxIntegral.Prepartition namespace Prepartition variable {I J J₁ J₂ : Box ι} (π : Prepartition I) {π₁ π₂ : Prepartition I} {x : ι → ℝ} instance : Membership (Box ι) (Prepartition I) := ⟨fun J π => J ∈ π.boxes⟩ @[simp] theorem mem_boxes : J ∈ π.boxes ↔ J ∈ π := Iff.rfl #align box_integral.prepartition.mem_boxes BoxIntegral.Prepartition.mem_boxes @[simp] theorem mem_mk {s h₁ h₂} : J ∈ (mk s h₁ h₂ : Prepartition I) ↔ J ∈ s := Iff.rfl #align box_integral.prepartition.mem_mk BoxIntegral.Prepartition.mem_mk theorem disjoint_coe_of_mem (h₁ : J₁ ∈ π) (h₂ : J₂ ∈ π) (h : J₁ ≠ J₂) : Disjoint (J₁ : Set (ι → ℝ)) J₂ := π.pairwiseDisjoint h₁ h₂ h #align box_integral.prepartition.disjoint_coe_of_mem BoxIntegral.Prepartition.disjoint_coe_of_mem theorem eq_of_mem_of_mem (h₁ : J₁ ∈ π) (h₂ : J₂ ∈ π) (hx₁ : x ∈ J₁) (hx₂ : x ∈ J₂) : J₁ = J₂ := by_contra fun H => (π.disjoint_coe_of_mem h₁ h₂ H).le_bot ⟨hx₁, hx₂⟩ #align box_integral.prepartition.eq_of_mem_of_mem BoxIntegral.Prepartition.eq_of_mem_of_mem theorem eq_of_le_of_le (h₁ : J₁ ∈ π) (h₂ : J₂ ∈ π) (hle₁ : J ≤ J₁) (hle₂ : J ≤ J₂) : J₁ = J₂ := π.eq_of_mem_of_mem h₁ h₂ (hle₁ J.upper_mem) (hle₂ J.upper_mem) #align box_integral.prepartition.eq_of_le_of_le BoxIntegral.Prepartition.eq_of_le_of_le theorem eq_of_le (h₁ : J₁ ∈ π) (h₂ : J₂ ∈ π) (hle : J₁ ≤ J₂) : J₁ = J₂ := π.eq_of_le_of_le h₁ h₂ le_rfl hle #align box_integral.prepartition.eq_of_le BoxIntegral.Prepartition.eq_of_le theorem le_of_mem (hJ : J ∈ π) : J ≤ I := π.le_of_mem' J hJ #align box_integral.prepartition.le_of_mem BoxIntegral.Prepartition.le_of_mem theorem lower_le_lower (hJ : J ∈ π) : I.lower ≤ J.lower := Box.antitone_lower (π.le_of_mem hJ) #align box_integral.prepartition.lower_le_lower BoxIntegral.Prepartition.lower_le_lower theorem upper_le_upper (hJ : J ∈ π) : J.upper ≤ I.upper := Box.monotone_upper (π.le_of_mem hJ) #align box_integral.prepartition.upper_le_upper BoxIntegral.Prepartition.upper_le_upper theorem injective_boxes : Function.Injective (boxes : Prepartition I → Finset (Box ι)) := by rintro ⟨s₁, h₁, h₁'⟩ ⟨s₂, h₂, h₂'⟩ (rfl : s₁ = s₂) rfl #align box_integral.prepartition.injective_boxes BoxIntegral.Prepartition.injective_boxes @[ext] theorem ext (h : ∀ J, J ∈ π₁ ↔ J ∈ π₂) : π₁ = π₂ := injective_boxes <| Finset.ext h #align box_integral.prepartition.ext BoxIntegral.Prepartition.ext @[simps] def single (I J : Box ι) (h : J ≤ I) : Prepartition I := ⟨{J}, by simpa, by simp⟩ #align box_integral.prepartition.single BoxIntegral.Prepartition.single @[simp] theorem mem_single {J'} (h : J ≤ I) : J' ∈ single I J h ↔ J' = J := mem_singleton #align box_integral.prepartition.mem_single BoxIntegral.Prepartition.mem_single instance : LE (Prepartition I) := ⟨fun π π' => ∀ ⦃I⦄, I ∈ π → ∃ I' ∈ π', I ≤ I'⟩ instance partialOrder : PartialOrder (Prepartition I) where le := (· ≤ ·) le_refl π I hI := ⟨I, hI, le_rfl⟩ le_trans π₁ π₂ π₃ h₁₂ h₂₃ I₁ hI₁ := let ⟨I₂, hI₂, hI₁₂⟩ := h₁₂ hI₁ let ⟨I₃, hI₃, hI₂₃⟩ := h₂₃ hI₂ ⟨I₃, hI₃, hI₁₂.trans hI₂₃⟩ le_antisymm := by suffices ∀ {π₁ π₂ : Prepartition I}, π₁ ≤ π₂ → π₂ ≤ π₁ → π₁.boxes ⊆ π₂.boxes from fun π₁ π₂ h₁ h₂ => injective_boxes (Subset.antisymm (this h₁ h₂) (this h₂ h₁)) intro π₁ π₂ h₁ h₂ J hJ rcases h₁ hJ with ⟨J', hJ', hle⟩; rcases h₂ hJ' with ⟨J'', hJ'', hle'⟩ obtain rfl : J = J'' := π₁.eq_of_le hJ hJ'' (hle.trans hle') obtain rfl : J' = J := le_antisymm ‹_› ‹_› assumption instance : OrderTop (Prepartition I) where top := single I I le_rfl le_top π J hJ := ⟨I, by simp, π.le_of_mem hJ⟩ instance : OrderBot (Prepartition I) where bot := ⟨∅, fun _ hJ => (Finset.not_mem_empty _ hJ).elim, fun _ hJ => (Set.not_mem_empty _ <| Finset.coe_empty ▸ hJ).elim⟩ bot_le _ _ hJ := (Finset.not_mem_empty _ hJ).elim instance : Inhabited (Prepartition I) := ⟨⊤⟩ theorem le_def : π₁ ≤ π₂ ↔ ∀ J ∈ π₁, ∃ J' ∈ π₂, J ≤ J' := Iff.rfl #align box_integral.prepartition.le_def BoxIntegral.Prepartition.le_def @[simp] theorem mem_top : J ∈ (⊤ : Prepartition I) ↔ J = I := mem_singleton #align box_integral.prepartition.mem_top BoxIntegral.Prepartition.mem_top @[simp] theorem top_boxes : (⊤ : Prepartition I).boxes = {I} := rfl #align box_integral.prepartition.top_boxes BoxIntegral.Prepartition.top_boxes @[simp] theorem not_mem_bot : J ∉ (⊥ : Prepartition I) := Finset.not_mem_empty _ #align box_integral.prepartition.not_mem_bot BoxIntegral.Prepartition.not_mem_bot @[simp] theorem bot_boxes : (⊥ : Prepartition I).boxes = ∅ := rfl #align box_integral.prepartition.bot_boxes BoxIntegral.Prepartition.bot_boxes theorem injOn_setOf_mem_Icc_setOf_lower_eq (x : ι → ℝ) : InjOn (fun J : Box ι => { i | J.lower i = x i }) { J | J ∈ π ∧ x ∈ Box.Icc J } := by rintro J₁ ⟨h₁, hx₁⟩ J₂ ⟨h₂, hx₂⟩ (H : { i | J₁.lower i = x i } = { i | J₂.lower i = x i }) suffices ∀ i, (Ioc (J₁.lower i) (J₁.upper i) ∩ Ioc (J₂.lower i) (J₂.upper i)).Nonempty by choose y hy₁ hy₂ using this exact π.eq_of_mem_of_mem h₁ h₂ hy₁ hy₂ intro i simp only [Set.ext_iff, mem_setOf] at H rcases (hx₁.1 i).eq_or_lt with hi₁ | hi₁ · have hi₂ : J₂.lower i = x i := (H _).1 hi₁ have H₁ : x i < J₁.upper i := by simpa only [hi₁] using J₁.lower_lt_upper i have H₂ : x i < J₂.upper i := by simpa only [hi₂] using J₂.lower_lt_upper i rw [Ioc_inter_Ioc, hi₁, hi₂, sup_idem, Set.nonempty_Ioc] exact lt_min H₁ H₂ · have hi₂ : J₂.lower i < x i := (hx₂.1 i).lt_of_ne (mt (H _).2 hi₁.ne) exact ⟨x i, ⟨hi₁, hx₁.2 i⟩, ⟨hi₂, hx₂.2 i⟩⟩ #align box_integral.prepartition.inj_on_set_of_mem_Icc_set_of_lower_eq BoxIntegral.Prepartition.injOn_setOf_mem_Icc_setOf_lower_eq theorem card_filter_mem_Icc_le [Fintype ι] (x : ι → ℝ) : (π.boxes.filter fun J : Box ι => x ∈ Box.Icc J).card ≤ 2 ^ Fintype.card ι := by rw [← Fintype.card_set] refine Finset.card_le_card_of_inj_on (fun J : Box ι => { i | J.lower i = x i }) (fun _ _ => Finset.mem_univ _) ?_ simpa only [Finset.mem_filter] using π.injOn_setOf_mem_Icc_setOf_lower_eq x #align box_integral.prepartition.card_filter_mem_Icc_le BoxIntegral.Prepartition.card_filter_mem_Icc_le protected def iUnion : Set (ι → ℝ) := ⋃ J ∈ π, ↑J #align box_integral.prepartition.Union BoxIntegral.Prepartition.iUnion theorem iUnion_def : π.iUnion = ⋃ J ∈ π, ↑J := rfl #align box_integral.prepartition.Union_def BoxIntegral.Prepartition.iUnion_def theorem iUnion_def' : π.iUnion = ⋃ J ∈ π.boxes, ↑J := rfl #align box_integral.prepartition.Union_def' BoxIntegral.Prepartition.iUnion_def' -- Porting note: Previous proof was `:= Set.mem_iUnion₂` @[simp] theorem mem_iUnion : x ∈ π.iUnion ↔ ∃ J ∈ π, x ∈ J := by convert Set.mem_iUnion₂ rw [Box.mem_coe, exists_prop] #align box_integral.prepartition.mem_Union BoxIntegral.Prepartition.mem_iUnion @[simp] theorem iUnion_single (h : J ≤ I) : (single I J h).iUnion = J := by simp [iUnion_def] #align box_integral.prepartition.Union_single BoxIntegral.Prepartition.iUnion_single @[simp] theorem iUnion_top : (⊤ : Prepartition I).iUnion = I := by simp [Prepartition.iUnion] #align box_integral.prepartition.Union_top BoxIntegral.Prepartition.iUnion_top @[simp] theorem iUnion_eq_empty : π₁.iUnion = ∅ ↔ π₁ = ⊥ := by simp [← injective_boxes.eq_iff, Finset.ext_iff, Prepartition.iUnion, imp_false] #align box_integral.prepartition.Union_eq_empty BoxIntegral.Prepartition.iUnion_eq_empty @[simp] theorem iUnion_bot : (⊥ : Prepartition I).iUnion = ∅ := iUnion_eq_empty.2 rfl #align box_integral.prepartition.Union_bot BoxIntegral.Prepartition.iUnion_bot theorem subset_iUnion (h : J ∈ π) : ↑J ⊆ π.iUnion := subset_biUnion_of_mem h #align box_integral.prepartition.subset_Union BoxIntegral.Prepartition.subset_iUnion theorem iUnion_subset : π.iUnion ⊆ I := iUnion₂_subset π.le_of_mem' #align box_integral.prepartition.Union_subset BoxIntegral.Prepartition.iUnion_subset @[mono] theorem iUnion_mono (h : π₁ ≤ π₂) : π₁.iUnion ⊆ π₂.iUnion := fun _ hx => let ⟨_, hJ₁, hx⟩ := π₁.mem_iUnion.1 hx let ⟨J₂, hJ₂, hle⟩ := h hJ₁ π₂.mem_iUnion.2 ⟨J₂, hJ₂, hle hx⟩ #align box_integral.prepartition.Union_mono BoxIntegral.Prepartition.iUnion_mono theorem disjoint_boxes_of_disjoint_iUnion (h : Disjoint π₁.iUnion π₂.iUnion) : Disjoint π₁.boxes π₂.boxes := Finset.disjoint_left.2 fun J h₁ h₂ => Disjoint.le_bot (h.mono (π₁.subset_iUnion h₁) (π₂.subset_iUnion h₂)) ⟨J.upper_mem, J.upper_mem⟩ #align box_integral.prepartition.disjoint_boxes_of_disjoint_Union BoxIntegral.Prepartition.disjoint_boxes_of_disjoint_iUnion theorem le_iff_nonempty_imp_le_and_iUnion_subset : π₁ ≤ π₂ ↔ (∀ J ∈ π₁, ∀ J' ∈ π₂, (J ∩ J' : Set (ι → ℝ)).Nonempty → J ≤ J') ∧ π₁.iUnion ⊆ π₂.iUnion := by constructor · refine fun H => ⟨fun J hJ J' hJ' Hne => ?_, iUnion_mono H⟩ rcases H hJ with ⟨J'', hJ'', Hle⟩ rcases Hne with ⟨x, hx, hx'⟩ rwa [π₂.eq_of_mem_of_mem hJ' hJ'' hx' (Hle hx)] · rintro ⟨H, HU⟩ J hJ simp only [Set.subset_def, mem_iUnion] at HU rcases HU J.upper ⟨J, hJ, J.upper_mem⟩ with ⟨J₂, hJ₂, hx⟩ exact ⟨J₂, hJ₂, H _ hJ _ hJ₂ ⟨_, J.upper_mem, hx⟩⟩ #align box_integral.prepartition.le_iff_nonempty_imp_le_and_Union_subset BoxIntegral.Prepartition.le_iff_nonempty_imp_le_and_iUnion_subset theorem eq_of_boxes_subset_iUnion_superset (h₁ : π₁.boxes ⊆ π₂.boxes) (h₂ : π₂.iUnion ⊆ π₁.iUnion) : π₁ = π₂ := le_antisymm (fun J hJ => ⟨J, h₁ hJ, le_rfl⟩) <| le_iff_nonempty_imp_le_and_iUnion_subset.2 ⟨fun _ hJ₁ _ hJ₂ Hne => (π₂.eq_of_mem_of_mem hJ₁ (h₁ hJ₂) Hne.choose_spec.1 Hne.choose_spec.2).le, h₂⟩ #align box_integral.prepartition.eq_of_boxes_subset_Union_superset BoxIntegral.Prepartition.eq_of_boxes_subset_iUnion_superset @[simps] def biUnion (πi : ∀ J : Box ι, Prepartition J) : Prepartition I where boxes := π.boxes.biUnion fun J => (πi J).boxes le_of_mem' J hJ := by simp only [Finset.mem_biUnion, exists_prop, mem_boxes] at hJ rcases hJ with ⟨J', hJ', hJ⟩ exact ((πi J').le_of_mem hJ).trans (π.le_of_mem hJ') pairwiseDisjoint := by simp only [Set.Pairwise, Finset.mem_coe, Finset.mem_biUnion] rintro J₁' ⟨J₁, hJ₁, hJ₁'⟩ J₂' ⟨J₂, hJ₂, hJ₂'⟩ Hne rw [Function.onFun, Set.disjoint_left] rintro x hx₁ hx₂; apply Hne obtain rfl : J₁ = J₂ := π.eq_of_mem_of_mem hJ₁ hJ₂ ((πi J₁).le_of_mem hJ₁' hx₁) ((πi J₂).le_of_mem hJ₂' hx₂) exact (πi J₁).eq_of_mem_of_mem hJ₁' hJ₂' hx₁ hx₂ #align box_integral.prepartition.bUnion BoxIntegral.Prepartition.biUnion variable {πi πi₁ πi₂ : ∀ J : Box ι, Prepartition J} @[simp] theorem mem_biUnion : J ∈ π.biUnion πi ↔ ∃ J' ∈ π, J ∈ πi J' := by simp [biUnion] #align box_integral.prepartition.mem_bUnion BoxIntegral.Prepartition.mem_biUnion theorem biUnion_le (πi : ∀ J, Prepartition J) : π.biUnion πi ≤ π := fun _ hJ => let ⟨J', hJ', hJ⟩ := π.mem_biUnion.1 hJ ⟨J', hJ', (πi J').le_of_mem hJ⟩ #align box_integral.prepartition.bUnion_le BoxIntegral.Prepartition.biUnion_le @[simp] theorem biUnion_top : (π.biUnion fun _ => ⊤) = π := by ext simp #align box_integral.prepartition.bUnion_top BoxIntegral.Prepartition.biUnion_top @[congr] theorem biUnion_congr (h : π₁ = π₂) (hi : ∀ J ∈ π₁, πi₁ J = πi₂ J) : π₁.biUnion πi₁ = π₂.biUnion πi₂ := by subst π₂ ext J simp only [mem_biUnion] constructor <;> exact fun ⟨J', h₁, h₂⟩ => ⟨J', h₁, hi J' h₁ ▸ h₂⟩ #align box_integral.prepartition.bUnion_congr BoxIntegral.Prepartition.biUnion_congr theorem biUnion_congr_of_le (h : π₁ = π₂) (hi : ∀ J ≤ I, πi₁ J = πi₂ J) : π₁.biUnion πi₁ = π₂.biUnion πi₂ := biUnion_congr h fun J hJ => hi J (π₁.le_of_mem hJ) #align box_integral.prepartition.bUnion_congr_of_le BoxIntegral.Prepartition.biUnion_congr_of_le @[simp] theorem iUnion_biUnion (πi : ∀ J : Box ι, Prepartition J) : (π.biUnion πi).iUnion = ⋃ J ∈ π, (πi J).iUnion := by simp [Prepartition.iUnion] #align box_integral.prepartition.Union_bUnion BoxIntegral.Prepartition.iUnion_biUnion @[simp] theorem sum_biUnion_boxes {M : Type*} [AddCommMonoid M] (π : Prepartition I) (πi : ∀ J, Prepartition J) (f : Box ι → M) : (∑ J ∈ π.boxes.biUnion fun J => (πi J).boxes, f J) = ∑ J ∈ π.boxes, ∑ J' ∈ (πi J).boxes, f J' := by refine Finset.sum_biUnion fun J₁ h₁ J₂ h₂ hne => Finset.disjoint_left.2 fun J' h₁' h₂' => ?_ exact hne (π.eq_of_le_of_le h₁ h₂ ((πi J₁).le_of_mem h₁') ((πi J₂).le_of_mem h₂')) #align box_integral.prepartition.sum_bUnion_boxes BoxIntegral.Prepartition.sum_biUnion_boxes def biUnionIndex (πi : ∀ (J : Box ι), Prepartition J) (J : Box ι) : Box ι := if hJ : J ∈ π.biUnion πi then (π.mem_biUnion.1 hJ).choose else I #align box_integral.prepartition.bUnion_index BoxIntegral.Prepartition.biUnionIndex theorem biUnionIndex_mem (hJ : J ∈ π.biUnion πi) : π.biUnionIndex πi J ∈ π := by rw [biUnionIndex, dif_pos hJ] exact (π.mem_biUnion.1 hJ).choose_spec.1 #align box_integral.prepartition.bUnion_index_mem BoxIntegral.Prepartition.biUnionIndex_mem theorem biUnionIndex_le (πi : ∀ J, Prepartition J) (J : Box ι) : π.biUnionIndex πi J ≤ I := by by_cases hJ : J ∈ π.biUnion πi · exact π.le_of_mem (π.biUnionIndex_mem hJ) · rw [biUnionIndex, dif_neg hJ] #align box_integral.prepartition.bUnion_index_le BoxIntegral.Prepartition.biUnionIndex_le theorem mem_biUnionIndex (hJ : J ∈ π.biUnion πi) : J ∈ πi (π.biUnionIndex πi J) := by convert (π.mem_biUnion.1 hJ).choose_spec.2 <;> exact dif_pos hJ #align box_integral.prepartition.mem_bUnion_index BoxIntegral.Prepartition.mem_biUnionIndex theorem le_biUnionIndex (hJ : J ∈ π.biUnion πi) : J ≤ π.biUnionIndex πi J := le_of_mem _ (π.mem_biUnionIndex hJ) #align box_integral.prepartition.le_bUnion_index BoxIntegral.Prepartition.le_biUnionIndex theorem biUnionIndex_of_mem (hJ : J ∈ π) {J'} (hJ' : J' ∈ πi J) : π.biUnionIndex πi J' = J := have : J' ∈ π.biUnion πi := π.mem_biUnion.2 ⟨J, hJ, hJ'⟩ π.eq_of_le_of_le (π.biUnionIndex_mem this) hJ (π.le_biUnionIndex this) (le_of_mem _ hJ') #align box_integral.prepartition.bUnion_index_of_mem BoxIntegral.Prepartition.biUnionIndex_of_mem theorem biUnion_assoc (πi : ∀ J, Prepartition J) (πi' : Box ι → ∀ J : Box ι, Prepartition J) : (π.biUnion fun J => (πi J).biUnion (πi' J)) = (π.biUnion πi).biUnion fun J => πi' (π.biUnionIndex πi J) J := by ext J simp only [mem_biUnion, exists_prop] constructor · rintro ⟨J₁, hJ₁, J₂, hJ₂, hJ⟩ refine ⟨J₂, ⟨J₁, hJ₁, hJ₂⟩, ?_⟩ rwa [π.biUnionIndex_of_mem hJ₁ hJ₂] · rintro ⟨J₁, ⟨J₂, hJ₂, hJ₁⟩, hJ⟩ refine ⟨J₂, hJ₂, J₁, hJ₁, ?_⟩ rwa [π.biUnionIndex_of_mem hJ₂ hJ₁] at hJ #align box_integral.prepartition.bUnion_assoc BoxIntegral.Prepartition.biUnion_assoc def ofWithBot (boxes : Finset (WithBot (Box ι))) (le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I) (pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint) : Prepartition I where boxes := Finset.eraseNone boxes le_of_mem' J hJ := by rw [mem_eraseNone] at hJ simpa only [WithBot.some_eq_coe, WithBot.coe_le_coe] using le_of_mem _ hJ pairwiseDisjoint J₁ h₁ J₂ h₂ hne := by simp only [mem_coe, mem_eraseNone] at h₁ h₂ exact Box.disjoint_coe.1 (pairwise_disjoint h₁ h₂ (mt Option.some_inj.1 hne)) #align box_integral.prepartition.of_with_bot BoxIntegral.Prepartition.ofWithBot @[simp] theorem mem_ofWithBot {boxes : Finset (WithBot (Box ι))} {h₁ h₂} : J ∈ (ofWithBot boxes h₁ h₂ : Prepartition I) ↔ (J : WithBot (Box ι)) ∈ boxes := mem_eraseNone #align box_integral.prepartition.mem_of_with_bot BoxIntegral.Prepartition.mem_ofWithBot @[simp] theorem iUnion_ofWithBot (boxes : Finset (WithBot (Box ι))) (le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I) (pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint) : (ofWithBot boxes le_of_mem pairwise_disjoint).iUnion = ⋃ J ∈ boxes, ↑J := by suffices ⋃ (J : Box ι) (_ : ↑J ∈ boxes), ↑J = ⋃ J ∈ boxes, (J : Set (ι → ℝ)) by simpa [ofWithBot, Prepartition.iUnion] simp only [← Box.biUnion_coe_eq_coe, @iUnion_comm _ _ (Box ι), @iUnion_comm _ _ (@Eq _ _ _), iUnion_iUnion_eq_right] #align box_integral.prepartition.Union_of_with_bot BoxIntegral.Prepartition.iUnion_ofWithBot theorem ofWithBot_le {boxes : Finset (WithBot (Box ι))} {le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I} {pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint} (H : ∀ J ∈ boxes, J ≠ ⊥ → ∃ J' ∈ π, J ≤ ↑J') : ofWithBot boxes le_of_mem pairwise_disjoint ≤ π := by have : ∀ J : Box ι, ↑J ∈ boxes → ∃ J' ∈ π, J ≤ J' := fun J hJ => by simpa only [WithBot.coe_le_coe] using H J hJ WithBot.coe_ne_bot simpa [ofWithBot, le_def] #align box_integral.prepartition.of_with_bot_le BoxIntegral.Prepartition.ofWithBot_le theorem le_ofWithBot {boxes : Finset (WithBot (Box ι))} {le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I} {pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint} (H : ∀ J ∈ π, ∃ J' ∈ boxes, ↑J ≤ J') : π ≤ ofWithBot boxes le_of_mem pairwise_disjoint := by intro J hJ rcases H J hJ with ⟨J', J'mem, hle⟩ lift J' to Box ι using ne_bot_of_le_ne_bot WithBot.coe_ne_bot hle exact ⟨J', mem_ofWithBot.2 J'mem, WithBot.coe_le_coe.1 hle⟩ #align box_integral.prepartition.le_of_with_bot BoxIntegral.Prepartition.le_ofWithBot theorem ofWithBot_mono {boxes₁ : Finset (WithBot (Box ι))} {le_of_mem₁ : ∀ J ∈ boxes₁, (J : WithBot (Box ι)) ≤ I} {pairwise_disjoint₁ : Set.Pairwise (boxes₁ : Set (WithBot (Box ι))) Disjoint} {boxes₂ : Finset (WithBot (Box ι))} {le_of_mem₂ : ∀ J ∈ boxes₂, (J : WithBot (Box ι)) ≤ I} {pairwise_disjoint₂ : Set.Pairwise (boxes₂ : Set (WithBot (Box ι))) Disjoint} (H : ∀ J ∈ boxes₁, J ≠ ⊥ → ∃ J' ∈ boxes₂, J ≤ J') : ofWithBot boxes₁ le_of_mem₁ pairwise_disjoint₁ ≤ ofWithBot boxes₂ le_of_mem₂ pairwise_disjoint₂ := le_ofWithBot _ fun J hJ => H J (mem_ofWithBot.1 hJ) WithBot.coe_ne_bot #align box_integral.prepartition.of_with_bot_mono BoxIntegral.Prepartition.ofWithBot_mono theorem sum_ofWithBot {M : Type*} [AddCommMonoid M] (boxes : Finset (WithBot (Box ι))) (le_of_mem : ∀ J ∈ boxes, (J : WithBot (Box ι)) ≤ I) (pairwise_disjoint : Set.Pairwise (boxes : Set (WithBot (Box ι))) Disjoint) (f : Box ι → M) : (∑ J ∈ (ofWithBot boxes le_of_mem pairwise_disjoint).boxes, f J) = ∑ J ∈ boxes, Option.elim' 0 f J := Finset.sum_eraseNone _ _ #align box_integral.prepartition.sum_of_with_bot BoxIntegral.Prepartition.sum_ofWithBot def restrict (π : Prepartition I) (J : Box ι) : Prepartition J := ofWithBot (π.boxes.image fun J' : Box ι => J ⊓ J') (fun J' hJ' => by rcases Finset.mem_image.1 hJ' with ⟨J', -, rfl⟩ exact inf_le_left) (by simp only [Set.Pairwise, onFun, Finset.mem_coe, Finset.mem_image] rintro _ ⟨J₁, h₁, rfl⟩ _ ⟨J₂, h₂, rfl⟩ Hne have : J₁ ≠ J₂ := by rintro rfl exact Hne rfl exact ((Box.disjoint_coe.2 <| π.disjoint_coe_of_mem h₁ h₂ this).inf_left' _).inf_right' _) #align box_integral.prepartition.restrict BoxIntegral.Prepartition.restrict @[simp] theorem mem_restrict : J₁ ∈ π.restrict J ↔ ∃ J' ∈ π, (J₁ : WithBot (Box ι)) = ↑J ⊓ ↑J' := by simp [restrict, eq_comm] #align box_integral.prepartition.mem_restrict BoxIntegral.Prepartition.mem_restrict theorem mem_restrict' : J₁ ∈ π.restrict J ↔ ∃ J' ∈ π, (J₁ : Set (ι → ℝ)) = ↑J ∩ ↑J' := by simp only [mem_restrict, ← Box.withBotCoe_inj, Box.coe_inf, Box.coe_coe] #align box_integral.prepartition.mem_restrict' BoxIntegral.Prepartition.mem_restrict' @[mono] theorem restrict_mono {π₁ π₂ : Prepartition I} (Hle : π₁ ≤ π₂) : π₁.restrict J ≤ π₂.restrict J := by refine ofWithBot_mono fun J₁ hJ₁ hne => ?_ rw [Finset.mem_image] at hJ₁; rcases hJ₁ with ⟨J₁, hJ₁, rfl⟩ rcases Hle hJ₁ with ⟨J₂, hJ₂, hle⟩ exact ⟨_, Finset.mem_image_of_mem _ hJ₂, inf_le_inf_left _ <| WithBot.coe_le_coe.2 hle⟩ #align box_integral.prepartition.restrict_mono BoxIntegral.Prepartition.restrict_mono theorem monotone_restrict : Monotone fun π : Prepartition I => restrict π J := fun _ _ => restrict_mono #align box_integral.prepartition.monotone_restrict BoxIntegral.Prepartition.monotone_restrict theorem restrict_boxes_of_le (π : Prepartition I) (h : I ≤ J) : (π.restrict J).boxes = π.boxes := by simp only [restrict, ofWithBot, eraseNone_eq_biUnion] refine Finset.image_biUnion.trans ?_ refine (Finset.biUnion_congr rfl ?_).trans Finset.biUnion_singleton_eq_self intro J' hJ' rw [inf_of_le_right, ← WithBot.some_eq_coe, Option.toFinset_some] exact WithBot.coe_le_coe.2 ((π.le_of_mem hJ').trans h) #align box_integral.prepartition.restrict_boxes_of_le BoxIntegral.Prepartition.restrict_boxes_of_le @[simp] theorem restrict_self : π.restrict I = π := injective_boxes <| restrict_boxes_of_le π le_rfl #align box_integral.prepartition.restrict_self BoxIntegral.Prepartition.restrict_self @[simp] theorem iUnion_restrict : (π.restrict J).iUnion = (J : Set (ι → ℝ)) ∩ (π.iUnion) := by simp [restrict, ← inter_iUnion, ← iUnion_def] #align box_integral.prepartition.Union_restrict BoxIntegral.Prepartition.iUnion_restrict @[simp] theorem restrict_biUnion (πi : ∀ J, Prepartition J) (hJ : J ∈ π) : (π.biUnion πi).restrict J = πi J := by refine (eq_of_boxes_subset_iUnion_superset (fun J₁ h₁ => ?_) ?_).symm · refine (mem_restrict _).2 ⟨J₁, π.mem_biUnion.2 ⟨J, hJ, h₁⟩, (inf_of_le_right ?_).symm⟩ exact WithBot.coe_le_coe.2 (le_of_mem _ h₁) · simp only [iUnion_restrict, iUnion_biUnion, Set.subset_def, Set.mem_inter_iff, Set.mem_iUnion] rintro x ⟨hxJ, J₁, h₁, hx⟩ obtain rfl : J = J₁ := π.eq_of_mem_of_mem hJ h₁ hxJ (iUnion_subset _ hx) exact hx #align box_integral.prepartition.restrict_bUnion BoxIntegral.Prepartition.restrict_biUnion
Mathlib/Analysis/BoxIntegral/Partition/Basic.lean
544
553
theorem biUnion_le_iff {πi : ∀ J, Prepartition J} {π' : Prepartition I} : π.biUnion πi ≤ π' ↔ ∀ J ∈ π, πi J ≤ π'.restrict J := by
constructor <;> intro H J hJ · rw [← π.restrict_biUnion πi hJ] exact restrict_mono H · rw [mem_biUnion] at hJ rcases hJ with ⟨J₁, h₁, hJ⟩ rcases H J₁ h₁ hJ with ⟨J₂, h₂, Hle⟩ rcases π'.mem_restrict.mp h₂ with ⟨J₃, h₃, H⟩ exact ⟨J₃, h₃, Hle.trans <| WithBot.coe_le_coe.1 <| H.trans_le inf_le_right⟩
import Mathlib.Analysis.SpecialFunctions.Integrals import Mathlib.MeasureTheory.Integral.PeakFunction #align_import analysis.special_functions.trigonometric.euler_sine_prod from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" open scoped Real Topology open Real Set Filter intervalIntegral MeasureTheory.MeasureSpace namespace EulerSine section IntegralRecursion variable {z : ℂ} {n : ℕ} theorem antideriv_cos_comp_const_mul (hz : z ≠ 0) (x : ℝ) : HasDerivAt (fun y : ℝ => Complex.sin (2 * z * y) / (2 * z)) (Complex.cos (2 * z * x)) x := by have a : HasDerivAt (fun y : ℂ => y * (2 * z)) _ x := hasDerivAt_mul_const _ have b : HasDerivAt (fun y : ℂ => Complex.sin (y * (2 * z))) _ x := HasDerivAt.comp (x : ℂ) (Complex.hasDerivAt_sin (x * (2 * z))) a have c := b.comp_ofReal.div_const (2 * z) field_simp at c; simp only [fun y => mul_comm y (2 * z)] at c exact c #align euler_sine.antideriv_cos_comp_const_mul EulerSine.antideriv_cos_comp_const_mul theorem antideriv_sin_comp_const_mul (hz : z ≠ 0) (x : ℝ) : HasDerivAt (fun y : ℝ => -Complex.cos (2 * z * y) / (2 * z)) (Complex.sin (2 * z * x)) x := by have a : HasDerivAt (fun y : ℂ => y * (2 * z)) _ x := hasDerivAt_mul_const _ have b : HasDerivAt (fun y : ℂ => Complex.cos (y * (2 * z))) _ x := HasDerivAt.comp (x : ℂ) (Complex.hasDerivAt_cos (x * (2 * z))) a have c := (b.comp_ofReal.div_const (2 * z)).neg field_simp at c; simp only [fun y => mul_comm y (2 * z)] at c exact c #align euler_sine.antideriv_sin_comp_const_mul EulerSine.antideriv_sin_comp_const_mul
Mathlib/Analysis/SpecialFunctions/Trigonometric/EulerSineProd.lean
59
85
theorem integral_cos_mul_cos_pow_aux (hn : 2 ≤ n) (hz : z ≠ 0) : (∫ x in (0 : ℝ)..π / 2, Complex.cos (2 * z * x) * (cos x : ℂ) ^ n) = n / (2 * z) * ∫ x in (0 : ℝ)..π / 2, Complex.sin (2 * z * x) * sin x * (cos x : ℂ) ^ (n - 1) := by
have der1 : ∀ x : ℝ, x ∈ uIcc 0 (π / 2) → HasDerivAt (fun y : ℝ => (cos y : ℂ) ^ n) (-n * sin x * (cos x : ℂ) ^ (n - 1)) x := by intro x _ have b : HasDerivAt (fun y : ℝ => (cos y : ℂ)) (-sin x) x := by simpa using (hasDerivAt_cos x).ofReal_comp convert HasDerivAt.comp x (hasDerivAt_pow _ _) b using 1 ring convert (config := { sameFun := true }) integral_mul_deriv_eq_deriv_mul der1 (fun x _ => antideriv_cos_comp_const_mul hz x) _ _ using 2 · ext1 x; rw [mul_comm] · rw [Complex.ofReal_zero, mul_zero, Complex.sin_zero, zero_div, mul_zero, sub_zero, cos_pi_div_two, Complex.ofReal_zero, zero_pow (by positivity : n ≠ 0), zero_mul, zero_sub, ← integral_neg, ← integral_const_mul] refine integral_congr fun x _ => ?_ field_simp; ring · apply Continuous.intervalIntegrable exact (continuous_const.mul (Complex.continuous_ofReal.comp continuous_sin)).mul ((Complex.continuous_ofReal.comp continuous_cos).pow (n - 1)) · apply Continuous.intervalIntegrable exact Complex.continuous_cos.comp (continuous_const.mul Complex.continuous_ofReal)
import Mathlib.Data.Finset.Lattice #align_import combinatorics.set_family.compression.down from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" variable {α : Type*} [DecidableEq α] {𝒜 ℬ : Finset (Finset α)} {s : Finset α} {a : α} namespace Finset def nonMemberSubfamily (a : α) (𝒜 : Finset (Finset α)) : Finset (Finset α) := 𝒜.filter fun s => a ∉ s #align finset.non_member_subfamily Finset.nonMemberSubfamily def memberSubfamily (a : α) (𝒜 : Finset (Finset α)) : Finset (Finset α) := (𝒜.filter fun s => a ∈ s).image fun s => erase s a #align finset.member_subfamily Finset.memberSubfamily @[simp] theorem mem_nonMemberSubfamily : s ∈ 𝒜.nonMemberSubfamily a ↔ s ∈ 𝒜 ∧ a ∉ s := by simp [nonMemberSubfamily] #align finset.mem_non_member_subfamily Finset.mem_nonMemberSubfamily @[simp] theorem mem_memberSubfamily : s ∈ 𝒜.memberSubfamily a ↔ insert a s ∈ 𝒜 ∧ a ∉ s := by simp_rw [memberSubfamily, mem_image, mem_filter] refine ⟨?_, fun h => ⟨insert a s, ⟨h.1, by simp⟩, erase_insert h.2⟩⟩ rintro ⟨s, ⟨hs1, hs2⟩, rfl⟩ rw [insert_erase hs2] exact ⟨hs1, not_mem_erase _ _⟩ #align finset.mem_member_subfamily Finset.mem_memberSubfamily theorem nonMemberSubfamily_inter (a : α) (𝒜 ℬ : Finset (Finset α)) : (𝒜 ∩ ℬ).nonMemberSubfamily a = 𝒜.nonMemberSubfamily a ∩ ℬ.nonMemberSubfamily a := filter_inter_distrib _ _ _ #align finset.non_member_subfamily_inter Finset.nonMemberSubfamily_inter theorem memberSubfamily_inter (a : α) (𝒜 ℬ : Finset (Finset α)) : (𝒜 ∩ ℬ).memberSubfamily a = 𝒜.memberSubfamily a ∩ ℬ.memberSubfamily a := by unfold memberSubfamily rw [filter_inter_distrib, image_inter_of_injOn _ _ ((erase_injOn' _).mono _)] simp #align finset.member_subfamily_inter Finset.memberSubfamily_inter theorem nonMemberSubfamily_union (a : α) (𝒜 ℬ : Finset (Finset α)) : (𝒜 ∪ ℬ).nonMemberSubfamily a = 𝒜.nonMemberSubfamily a ∪ ℬ.nonMemberSubfamily a := filter_union _ _ _ #align finset.non_member_subfamily_union Finset.nonMemberSubfamily_union theorem memberSubfamily_union (a : α) (𝒜 ℬ : Finset (Finset α)) : (𝒜 ∪ ℬ).memberSubfamily a = 𝒜.memberSubfamily a ∪ ℬ.memberSubfamily a := by simp_rw [memberSubfamily, filter_union, image_union] #align finset.member_subfamily_union Finset.memberSubfamily_union theorem card_memberSubfamily_add_card_nonMemberSubfamily (a : α) (𝒜 : Finset (Finset α)) : (𝒜.memberSubfamily a).card + (𝒜.nonMemberSubfamily a).card = 𝒜.card := by rw [memberSubfamily, nonMemberSubfamily, card_image_of_injOn] · conv_rhs => rw [← filter_card_add_filter_neg_card_eq_card (fun s => (a ∈ s))] · apply (erase_injOn' _).mono simp #align finset.card_member_subfamily_add_card_non_member_subfamily Finset.card_memberSubfamily_add_card_nonMemberSubfamily theorem memberSubfamily_union_nonMemberSubfamily (a : α) (𝒜 : Finset (Finset α)) : 𝒜.memberSubfamily a ∪ 𝒜.nonMemberSubfamily a = 𝒜.image fun s => s.erase a := by ext s simp only [mem_union, mem_memberSubfamily, mem_nonMemberSubfamily, mem_image, exists_prop] constructor · rintro (h | h) · exact ⟨_, h.1, erase_insert h.2⟩ · exact ⟨_, h.1, erase_eq_of_not_mem h.2⟩ · rintro ⟨s, hs, rfl⟩ by_cases ha : a ∈ s · exact Or.inl ⟨by rwa [insert_erase ha], not_mem_erase _ _⟩ · exact Or.inr ⟨by rwa [erase_eq_of_not_mem ha], not_mem_erase _ _⟩ #align finset.member_subfamily_union_non_member_subfamily Finset.memberSubfamily_union_nonMemberSubfamily @[simp]
Mathlib/Combinatorics/SetFamily/Compression/Down.lean
114
116
theorem memberSubfamily_memberSubfamily : (𝒜.memberSubfamily a).memberSubfamily a = ∅ := by
ext simp
import Mathlib.Order.Filter.Lift import Mathlib.Topology.Separation import Mathlib.Order.Interval.Set.Monotone #align_import topology.filter from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" open Set Filter TopologicalSpace open Filter Topology variable {ι : Sort*} {α β X Y : Type*} namespace Filter instance : TopologicalSpace (Filter α) := generateFrom <| range <| Iic ∘ 𝓟 theorem isOpen_Iic_principal {s : Set α} : IsOpen (Iic (𝓟 s)) := GenerateOpen.basic _ (mem_range_self _) #align filter.is_open_Iic_principal Filter.isOpen_Iic_principal theorem isOpen_setOf_mem {s : Set α} : IsOpen { l : Filter α | s ∈ l } := by simpa only [Iic_principal] using isOpen_Iic_principal #align filter.is_open_set_of_mem Filter.isOpen_setOf_mem theorem isTopologicalBasis_Iic_principal : IsTopologicalBasis (range (Iic ∘ 𝓟 : Set α → Set (Filter α))) := { exists_subset_inter := by rintro _ ⟨s, rfl⟩ _ ⟨t, rfl⟩ l hl exact ⟨Iic (𝓟 s) ∩ Iic (𝓟 t), ⟨s ∩ t, by simp⟩, hl, Subset.rfl⟩ sUnion_eq := sUnion_eq_univ_iff.2 fun l => ⟨Iic ⊤, ⟨univ, congr_arg Iic principal_univ⟩, mem_Iic.2 le_top⟩ eq_generateFrom := rfl } #align filter.is_topological_basis_Iic_principal Filter.isTopologicalBasis_Iic_principal theorem isOpen_iff {s : Set (Filter α)} : IsOpen s ↔ ∃ T : Set (Set α), s = ⋃ t ∈ T, Iic (𝓟 t) := isTopologicalBasis_Iic_principal.open_iff_eq_sUnion.trans <| by simp only [exists_subset_range_and_iff, sUnion_image, (· ∘ ·)] #align filter.is_open_iff Filter.isOpen_iff theorem nhds_eq (l : Filter α) : 𝓝 l = l.lift' (Iic ∘ 𝓟) := nhds_generateFrom.trans <| by simp only [mem_setOf_eq, @and_comm (l ∈ _), iInf_and, iInf_range, Filter.lift', Filter.lift, (· ∘ ·), mem_Iic, le_principal_iff] #align filter.nhds_eq Filter.nhds_eq theorem nhds_eq' (l : Filter α) : 𝓝 l = l.lift' fun s => { l' | s ∈ l' } := by simpa only [(· ∘ ·), Iic_principal] using nhds_eq l #align filter.nhds_eq' Filter.nhds_eq' protected theorem tendsto_nhds {la : Filter α} {lb : Filter β} {f : α → Filter β} : Tendsto f la (𝓝 lb) ↔ ∀ s ∈ lb, ∀ᶠ a in la, s ∈ f a := by simp only [nhds_eq', tendsto_lift', mem_setOf_eq] #align filter.tendsto_nhds Filter.tendsto_nhds protected theorem HasBasis.nhds {l : Filter α} {p : ι → Prop} {s : ι → Set α} (h : HasBasis l p s) : HasBasis (𝓝 l) p fun i => Iic (𝓟 (s i)) := by rw [nhds_eq] exact h.lift' monotone_principal.Iic #align filter.has_basis.nhds Filter.HasBasis.nhds protected theorem tendsto_pure_self (l : Filter X) : Tendsto (pure : X → Filter X) l (𝓝 l) := by rw [Filter.tendsto_nhds] exact fun s hs ↦ Eventually.mono hs fun x ↦ id instance {l : Filter α} [IsCountablyGenerated l] : IsCountablyGenerated (𝓝 l) := let ⟨_b, hb⟩ := l.exists_antitone_basis HasCountableBasis.isCountablyGenerated <| ⟨hb.nhds, Set.to_countable _⟩ theorem HasBasis.nhds' {l : Filter α} {p : ι → Prop} {s : ι → Set α} (h : HasBasis l p s) : HasBasis (𝓝 l) p fun i => { l' | s i ∈ l' } := by simpa only [Iic_principal] using h.nhds #align filter.has_basis.nhds' Filter.HasBasis.nhds' protected theorem mem_nhds_iff {l : Filter α} {S : Set (Filter α)} : S ∈ 𝓝 l ↔ ∃ t ∈ l, Iic (𝓟 t) ⊆ S := l.basis_sets.nhds.mem_iff #align filter.mem_nhds_iff Filter.mem_nhds_iff theorem mem_nhds_iff' {l : Filter α} {S : Set (Filter α)} : S ∈ 𝓝 l ↔ ∃ t ∈ l, ∀ ⦃l' : Filter α⦄, t ∈ l' → l' ∈ S := l.basis_sets.nhds'.mem_iff #align filter.mem_nhds_iff' Filter.mem_nhds_iff' @[simp] theorem nhds_bot : 𝓝 (⊥ : Filter α) = pure ⊥ := by simp [nhds_eq, (· ∘ ·), lift'_bot monotone_principal.Iic] #align filter.nhds_bot Filter.nhds_bot @[simp]
Mathlib/Topology/Filter.lean
125
125
theorem nhds_top : 𝓝 (⊤ : Filter α) = ⊤ := by
simp [nhds_eq]
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
Mathlib/Tactic/Ring/RingNF.lean
123
123
theorem int_rawCast_neg {R} [Ring R] : (Int.rawCast (.negOfNat n) : R) = -Nat.rawCast n := by
simp
import Mathlib.Data.ZMod.Basic import Mathlib.RingTheory.Int.Basic import Mathlib.RingTheory.PrincipalIdealDomain #align_import data.zmod.coprime from "leanprover-community/mathlib"@"4b4975cf92a1ffe2ddfeff6ff91b0c46a9162bf5" namespace ZMod
Mathlib/Data/ZMod/Coprime.lean
24
28
theorem eq_zero_iff_gcd_ne_one {a : ℤ} {p : ℕ} [pp : Fact p.Prime] : (a : ZMod p) = 0 ↔ a.gcd p ≠ 1 := by
rw [Ne, Int.gcd_comm, Int.gcd_eq_one_iff_coprime, (Nat.prime_iff_prime_int.1 pp.1).coprime_iff_not_dvd, Classical.not_not, intCast_zmod_eq_zero_iff_dvd]
import Mathlib.Topology.Maps import Mathlib.Topology.NhdsSet #align_import topology.constructions from "leanprover-community/mathlib"@"f7ebde7ee0d1505dfccac8644ae12371aa3c1c9f" noncomputable section open scoped Classical open Topology TopologicalSpace Set Filter Function universe u v variable {X : Type u} {Y : Type v} {Z W ε ζ : Type*} section Constructions instance instTopologicalSpaceSubtype {p : X → Prop} [t : TopologicalSpace X] : TopologicalSpace (Subtype p) := induced (↑) t instance {r : X → X → Prop} [t : TopologicalSpace X] : TopologicalSpace (Quot r) := coinduced (Quot.mk r) t instance instTopologicalSpaceQuotient {s : Setoid X} [t : TopologicalSpace X] : TopologicalSpace (Quotient s) := coinduced Quotient.mk' t instance instTopologicalSpaceProd [t₁ : TopologicalSpace X] [t₂ : TopologicalSpace Y] : TopologicalSpace (X × Y) := induced Prod.fst t₁ ⊓ induced Prod.snd t₂ instance instTopologicalSpaceSum [t₁ : TopologicalSpace X] [t₂ : TopologicalSpace Y] : TopologicalSpace (X ⊕ Y) := coinduced Sum.inl t₁ ⊔ coinduced Sum.inr t₂ instance instTopologicalSpaceSigma {ι : Type*} {X : ι → Type v} [t₂ : ∀ i, TopologicalSpace (X i)] : TopologicalSpace (Sigma X) := ⨆ i, coinduced (Sigma.mk i) (t₂ i) instance Pi.topologicalSpace {ι : Type*} {Y : ι → Type v} [t₂ : (i : ι) → TopologicalSpace (Y i)] : TopologicalSpace ((i : ι) → Y i) := ⨅ i, induced (fun f => f i) (t₂ i) #align Pi.topological_space Pi.topologicalSpace instance ULift.topologicalSpace [t : TopologicalSpace X] : TopologicalSpace (ULift.{v, u} X) := t.induced ULift.down #align ulift.topological_space ULift.topologicalSpace section variable [TopologicalSpace X] open Additive Multiplicative instance : TopologicalSpace (Additive X) := ‹TopologicalSpace X› instance : TopologicalSpace (Multiplicative X) := ‹TopologicalSpace X› instance [DiscreteTopology X] : DiscreteTopology (Additive X) := ‹DiscreteTopology X› instance [DiscreteTopology X] : DiscreteTopology (Multiplicative X) := ‹DiscreteTopology X› theorem continuous_ofMul : Continuous (ofMul : X → Additive X) := continuous_id #align continuous_of_mul continuous_ofMul theorem continuous_toMul : Continuous (toMul : Additive X → X) := continuous_id #align continuous_to_mul continuous_toMul theorem continuous_ofAdd : Continuous (ofAdd : X → Multiplicative X) := continuous_id #align continuous_of_add continuous_ofAdd theorem continuous_toAdd : Continuous (toAdd : Multiplicative X → X) := continuous_id #align continuous_to_add continuous_toAdd theorem isOpenMap_ofMul : IsOpenMap (ofMul : X → Additive X) := IsOpenMap.id #align is_open_map_of_mul isOpenMap_ofMul theorem isOpenMap_toMul : IsOpenMap (toMul : Additive X → X) := IsOpenMap.id #align is_open_map_to_mul isOpenMap_toMul theorem isOpenMap_ofAdd : IsOpenMap (ofAdd : X → Multiplicative X) := IsOpenMap.id #align is_open_map_of_add isOpenMap_ofAdd theorem isOpenMap_toAdd : IsOpenMap (toAdd : Multiplicative X → X) := IsOpenMap.id #align is_open_map_to_add isOpenMap_toAdd theorem isClosedMap_ofMul : IsClosedMap (ofMul : X → Additive X) := IsClosedMap.id #align is_closed_map_of_mul isClosedMap_ofMul theorem isClosedMap_toMul : IsClosedMap (toMul : Additive X → X) := IsClosedMap.id #align is_closed_map_to_mul isClosedMap_toMul theorem isClosedMap_ofAdd : IsClosedMap (ofAdd : X → Multiplicative X) := IsClosedMap.id #align is_closed_map_of_add isClosedMap_ofAdd theorem isClosedMap_toAdd : IsClosedMap (toAdd : Multiplicative X → X) := IsClosedMap.id #align is_closed_map_to_add isClosedMap_toAdd theorem nhds_ofMul (x : X) : 𝓝 (ofMul x) = map ofMul (𝓝 x) := rfl #align nhds_of_mul nhds_ofMul theorem nhds_ofAdd (x : X) : 𝓝 (ofAdd x) = map ofAdd (𝓝 x) := rfl #align nhds_of_add nhds_ofAdd theorem nhds_toMul (x : Additive X) : 𝓝 (toMul x) = map toMul (𝓝 x) := rfl #align nhds_to_mul nhds_toMul theorem nhds_toAdd (x : Multiplicative X) : 𝓝 (toAdd x) = map toAdd (𝓝 x) := rfl #align nhds_to_add nhds_toAdd end section variable [TopologicalSpace X] open OrderDual instance : TopologicalSpace Xᵒᵈ := ‹TopologicalSpace X› instance [DiscreteTopology X] : DiscreteTopology Xᵒᵈ := ‹DiscreteTopology X› theorem continuous_toDual : Continuous (toDual : X → Xᵒᵈ) := continuous_id #align continuous_to_dual continuous_toDual theorem continuous_ofDual : Continuous (ofDual : Xᵒᵈ → X) := continuous_id #align continuous_of_dual continuous_ofDual theorem isOpenMap_toDual : IsOpenMap (toDual : X → Xᵒᵈ) := IsOpenMap.id #align is_open_map_to_dual isOpenMap_toDual theorem isOpenMap_ofDual : IsOpenMap (ofDual : Xᵒᵈ → X) := IsOpenMap.id #align is_open_map_of_dual isOpenMap_ofDual theorem isClosedMap_toDual : IsClosedMap (toDual : X → Xᵒᵈ) := IsClosedMap.id #align is_closed_map_to_dual isClosedMap_toDual theorem isClosedMap_ofDual : IsClosedMap (ofDual : Xᵒᵈ → X) := IsClosedMap.id #align is_closed_map_of_dual isClosedMap_ofDual theorem nhds_toDual (x : X) : 𝓝 (toDual x) = map toDual (𝓝 x) := rfl #align nhds_to_dual nhds_toDual theorem nhds_ofDual (x : X) : 𝓝 (ofDual x) = map ofDual (𝓝 x) := rfl #align nhds_of_dual nhds_ofDual end theorem Quotient.preimage_mem_nhds [TopologicalSpace X] [s : Setoid X] {V : Set <| Quotient s} {x : X} (hs : V ∈ 𝓝 (Quotient.mk' x)) : Quotient.mk' ⁻¹' V ∈ 𝓝 x := preimage_nhds_coinduced hs #align quotient.preimage_mem_nhds Quotient.preimage_mem_nhds theorem Dense.quotient [Setoid X] [TopologicalSpace X] {s : Set X} (H : Dense s) : Dense (Quotient.mk' '' s) := Quotient.surjective_Quotient_mk''.denseRange.dense_image continuous_coinduced_rng H #align dense.quotient Dense.quotient theorem DenseRange.quotient [Setoid X] [TopologicalSpace X] {f : Y → X} (hf : DenseRange f) : DenseRange (Quotient.mk' ∘ f) := Quotient.surjective_Quotient_mk''.denseRange.comp hf continuous_coinduced_rng #align dense_range.quotient DenseRange.quotient theorem continuous_map_of_le {α : Type*} [TopologicalSpace α] {s t : Setoid α} (h : s ≤ t) : Continuous (Setoid.map_of_le h) := continuous_coinduced_rng theorem continuous_map_sInf {α : Type*} [TopologicalSpace α] {S : Set (Setoid α)} {s : Setoid α} (h : s ∈ S) : Continuous (Setoid.map_sInf h) := continuous_coinduced_rng instance {p : X → Prop} [TopologicalSpace X] [DiscreteTopology X] : DiscreteTopology (Subtype p) := ⟨bot_unique fun s _ => ⟨(↑) '' s, isOpen_discrete _, preimage_image_eq _ Subtype.val_injective⟩⟩ instance Sum.discreteTopology [TopologicalSpace X] [TopologicalSpace Y] [h : DiscreteTopology X] [hY : DiscreteTopology Y] : DiscreteTopology (X ⊕ Y) := ⟨sup_eq_bot_iff.2 <| by simp [h.eq_bot, hY.eq_bot]⟩ #align sum.discrete_topology Sum.discreteTopology instance Sigma.discreteTopology {ι : Type*} {Y : ι → Type v} [∀ i, TopologicalSpace (Y i)] [h : ∀ i, DiscreteTopology (Y i)] : DiscreteTopology (Sigma Y) := ⟨iSup_eq_bot.2 fun _ => by simp only [(h _).eq_bot, coinduced_bot]⟩ #align sigma.discrete_topology Sigma.discreteTopology def CofiniteTopology (X : Type*) := X #align cofinite_topology CofiniteTopology section Monad variable [TopologicalSpace X] {s : Set X} {t : Set s}
Mathlib/Topology/Constructions.lean
1,763
1,766
theorem IsOpen.trans (ht : IsOpen t) (hs : IsOpen s) : IsOpen (t : Set X) := by
rcases isOpen_induced_iff.mp ht with ⟨s', hs', rfl⟩ rw [Subtype.image_preimage_coe] exact hs.inter hs'
import Mathlib.Data.ENNReal.Real import Mathlib.Order.Interval.Finset.Nat import Mathlib.Topology.UniformSpace.Pi import Mathlib.Topology.UniformSpace.UniformConvergence import Mathlib.Topology.UniformSpace.UniformEmbedding #align_import topology.metric_space.emetric_space from "leanprover-community/mathlib"@"c8f305514e0d47dfaa710f5a52f0d21b588e6328" open Set Filter Classical open scoped Uniformity Topology Filter NNReal ENNReal Pointwise universe u v w variable {α : Type u} {β : Type v} {X : Type*} theorem uniformity_dist_of_mem_uniformity [LinearOrder β] {U : Filter (α × α)} (z : β) (D : α → α → β) (H : ∀ s, s ∈ U ↔ ∃ ε > z, ∀ {a b : α}, D a b < ε → (a, b) ∈ s) : U = ⨅ ε > z, 𝓟 { p : α × α | D p.1 p.2 < ε } := HasBasis.eq_biInf ⟨fun s => by simp only [H, subset_def, Prod.forall, mem_setOf]⟩ #align uniformity_dist_of_mem_uniformity uniformity_dist_of_mem_uniformity @[ext] class EDist (α : Type*) where edist : α → α → ℝ≥0∞ #align has_edist EDist export EDist (edist) def uniformSpaceOfEDist (edist : α → α → ℝ≥0∞) (edist_self : ∀ x : α, edist x x = 0) (edist_comm : ∀ x y : α, edist x y = edist y x) (edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z) : UniformSpace α := .ofFun edist edist_self edist_comm edist_triangle fun ε ε0 => ⟨ε / 2, ENNReal.half_pos ε0.ne', fun _ h₁ _ h₂ => (ENNReal.add_lt_add h₁ h₂).trans_eq (ENNReal.add_halves _)⟩ #align uniform_space_of_edist uniformSpaceOfEDist -- the uniform structure is embedded in the emetric space structure -- to avoid instance diamond issues. See Note [forgetful inheritance]. class PseudoEMetricSpace (α : Type u) extends EDist α : Type u where edist_self : ∀ x : α, edist x x = 0 edist_comm : ∀ x y : α, edist x y = edist y x edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z toUniformSpace : UniformSpace α := uniformSpaceOfEDist edist edist_self edist_comm edist_triangle uniformity_edist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | edist p.1 p.2 < ε } := by rfl #align pseudo_emetric_space PseudoEMetricSpace attribute [instance] PseudoEMetricSpace.toUniformSpace @[ext] protected theorem PseudoEMetricSpace.ext {α : Type*} {m m' : PseudoEMetricSpace α} (h : m.toEDist = m'.toEDist) : m = m' := by cases' m with ed _ _ _ U hU cases' m' with ed' _ _ _ U' hU' congr 1 exact UniformSpace.ext (((show ed = ed' from h) ▸ hU).trans hU'.symm) variable [PseudoEMetricSpace α] export PseudoEMetricSpace (edist_self edist_comm edist_triangle) attribute [simp] edist_self theorem edist_triangle_left (x y z : α) : edist x y ≤ edist z x + edist z y := by rw [edist_comm z]; apply edist_triangle #align edist_triangle_left edist_triangle_left theorem edist_triangle_right (x y z : α) : edist x y ≤ edist x z + edist y z := by rw [edist_comm y]; apply edist_triangle #align edist_triangle_right edist_triangle_right theorem edist_congr_right {x y z : α} (h : edist x y = 0) : edist x z = edist y z := by apply le_antisymm · rw [← zero_add (edist y z), ← h] apply edist_triangle · rw [edist_comm] at h rw [← zero_add (edist x z), ← h] apply edist_triangle #align edist_congr_right edist_congr_right theorem edist_congr_left {x y z : α} (h : edist x y = 0) : edist z x = edist z y := by rw [edist_comm z x, edist_comm z y] apply edist_congr_right h #align edist_congr_left edist_congr_left -- new theorem theorem edist_congr {w x y z : α} (hl : edist w x = 0) (hr : edist y z = 0) : edist w y = edist x z := (edist_congr_right hl).trans (edist_congr_left hr) theorem edist_triangle4 (x y z t : α) : edist x t ≤ edist x y + edist y z + edist z t := calc edist x t ≤ edist x z + edist z t := edist_triangle x z t _ ≤ edist x y + edist y z + edist z t := add_le_add_right (edist_triangle x y z) _ #align edist_triangle4 edist_triangle4 theorem edist_le_Ico_sum_edist (f : ℕ → α) {m n} (h : m ≤ n) : edist (f m) (f n) ≤ ∑ i ∈ Finset.Ico m n, edist (f i) (f (i + 1)) := by induction n, h using Nat.le_induction with | base => rw [Finset.Ico_self, Finset.sum_empty, edist_self] | succ n hle ihn => calc edist (f m) (f (n + 1)) ≤ edist (f m) (f n) + edist (f n) (f (n + 1)) := edist_triangle _ _ _ _ ≤ (∑ i ∈ Finset.Ico m n, _) + _ := add_le_add ihn le_rfl _ = ∑ i ∈ Finset.Ico m (n + 1), _ := by { rw [Nat.Ico_succ_right_eq_insert_Ico hle, Finset.sum_insert, add_comm]; simp } #align edist_le_Ico_sum_edist edist_le_Ico_sum_edist theorem edist_le_range_sum_edist (f : ℕ → α) (n : ℕ) : edist (f 0) (f n) ≤ ∑ i ∈ Finset.range n, edist (f i) (f (i + 1)) := Nat.Ico_zero_eq_range ▸ edist_le_Ico_sum_edist f (Nat.zero_le n) #align edist_le_range_sum_edist edist_le_range_sum_edist theorem edist_le_Ico_sum_of_edist_le {f : ℕ → α} {m n} (hmn : m ≤ n) {d : ℕ → ℝ≥0∞} (hd : ∀ {k}, m ≤ k → k < n → edist (f k) (f (k + 1)) ≤ d k) : edist (f m) (f n) ≤ ∑ i ∈ Finset.Ico m n, d i := le_trans (edist_le_Ico_sum_edist f hmn) <| Finset.sum_le_sum fun _k hk => hd (Finset.mem_Ico.1 hk).1 (Finset.mem_Ico.1 hk).2 #align edist_le_Ico_sum_of_edist_le edist_le_Ico_sum_of_edist_le theorem edist_le_range_sum_of_edist_le {f : ℕ → α} (n : ℕ) {d : ℕ → ℝ≥0∞} (hd : ∀ {k}, k < n → edist (f k) (f (k + 1)) ≤ d k) : edist (f 0) (f n) ≤ ∑ i ∈ Finset.range n, d i := Nat.Ico_zero_eq_range ▸ edist_le_Ico_sum_of_edist_le (zero_le n) fun _ => hd #align edist_le_range_sum_of_edist_le edist_le_range_sum_of_edist_le theorem uniformity_pseudoedist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | edist p.1 p.2 < ε } := PseudoEMetricSpace.uniformity_edist #align uniformity_pseudoedist uniformity_pseudoedist theorem uniformSpace_edist : ‹PseudoEMetricSpace α›.toUniformSpace = uniformSpaceOfEDist edist edist_self edist_comm edist_triangle := UniformSpace.ext uniformity_pseudoedist #align uniform_space_edist uniformSpace_edist theorem uniformity_basis_edist : (𝓤 α).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 < ε } := (@uniformSpace_edist α _).symm ▸ UniformSpace.hasBasis_ofFun ⟨1, one_pos⟩ _ _ _ _ _ #align uniformity_basis_edist uniformity_basis_edist theorem mem_uniformity_edist {s : Set (α × α)} : s ∈ 𝓤 α ↔ ∃ ε > 0, ∀ {a b : α}, edist a b < ε → (a, b) ∈ s := uniformity_basis_edist.mem_uniformity_iff #align mem_uniformity_edist mem_uniformity_edist protected theorem EMetric.mk_uniformity_basis {β : Type*} {p : β → Prop} {f : β → ℝ≥0∞} (hf₀ : ∀ x, p x → 0 < f x) (hf : ∀ ε, 0 < ε → ∃ x, p x ∧ f x ≤ ε) : (𝓤 α).HasBasis p fun x => { p : α × α | edist p.1 p.2 < f x } := by refine ⟨fun s => uniformity_basis_edist.mem_iff.trans ?_⟩ constructor · rintro ⟨ε, ε₀, hε⟩ rcases hf ε ε₀ with ⟨i, hi, H⟩ exact ⟨i, hi, fun x hx => hε <| lt_of_lt_of_le hx.out H⟩ · exact fun ⟨i, hi, H⟩ => ⟨f i, hf₀ i hi, H⟩ #align emetric.mk_uniformity_basis EMetric.mk_uniformity_basis protected theorem EMetric.mk_uniformity_basis_le {β : Type*} {p : β → Prop} {f : β → ℝ≥0∞} (hf₀ : ∀ x, p x → 0 < f x) (hf : ∀ ε, 0 < ε → ∃ x, p x ∧ f x ≤ ε) : (𝓤 α).HasBasis p fun x => { p : α × α | edist p.1 p.2 ≤ f x } := by refine ⟨fun s => uniformity_basis_edist.mem_iff.trans ?_⟩ constructor · rintro ⟨ε, ε₀, hε⟩ rcases exists_between ε₀ with ⟨ε', hε'⟩ rcases hf ε' hε'.1 with ⟨i, hi, H⟩ exact ⟨i, hi, fun x hx => hε <| lt_of_le_of_lt (le_trans hx.out H) hε'.2⟩ · exact fun ⟨i, hi, H⟩ => ⟨f i, hf₀ i hi, fun x hx => H (le_of_lt hx.out)⟩ #align emetric.mk_uniformity_basis_le EMetric.mk_uniformity_basis_le theorem uniformity_basis_edist_le : (𝓤 α).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 ≤ ε } := EMetric.mk_uniformity_basis_le (fun _ => id) fun ε ε₀ => ⟨ε, ε₀, le_refl ε⟩ #align uniformity_basis_edist_le uniformity_basis_edist_le theorem uniformity_basis_edist' (ε' : ℝ≥0∞) (hε' : 0 < ε') : (𝓤 α).HasBasis (fun ε : ℝ≥0∞ => ε ∈ Ioo 0 ε') fun ε => { p : α × α | edist p.1 p.2 < ε } := EMetric.mk_uniformity_basis (fun _ => And.left) fun ε ε₀ => let ⟨δ, hδ⟩ := exists_between hε' ⟨min ε δ, ⟨lt_min ε₀ hδ.1, lt_of_le_of_lt (min_le_right _ _) hδ.2⟩, min_le_left _ _⟩ #align uniformity_basis_edist' uniformity_basis_edist' theorem uniformity_basis_edist_le' (ε' : ℝ≥0∞) (hε' : 0 < ε') : (𝓤 α).HasBasis (fun ε : ℝ≥0∞ => ε ∈ Ioo 0 ε') fun ε => { p : α × α | edist p.1 p.2 ≤ ε } := EMetric.mk_uniformity_basis_le (fun _ => And.left) fun ε ε₀ => let ⟨δ, hδ⟩ := exists_between hε' ⟨min ε δ, ⟨lt_min ε₀ hδ.1, lt_of_le_of_lt (min_le_right _ _) hδ.2⟩, min_le_left _ _⟩ #align uniformity_basis_edist_le' uniformity_basis_edist_le' theorem uniformity_basis_edist_nnreal : (𝓤 α).HasBasis (fun ε : ℝ≥0 => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 < ε } := EMetric.mk_uniformity_basis (fun _ => ENNReal.coe_pos.2) fun _ε ε₀ => let ⟨δ, hδ⟩ := ENNReal.lt_iff_exists_nnreal_btwn.1 ε₀ ⟨δ, ENNReal.coe_pos.1 hδ.1, le_of_lt hδ.2⟩ #align uniformity_basis_edist_nnreal uniformity_basis_edist_nnreal theorem uniformity_basis_edist_nnreal_le : (𝓤 α).HasBasis (fun ε : ℝ≥0 => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 ≤ ε } := EMetric.mk_uniformity_basis_le (fun _ => ENNReal.coe_pos.2) fun _ε ε₀ => let ⟨δ, hδ⟩ := ENNReal.lt_iff_exists_nnreal_btwn.1 ε₀ ⟨δ, ENNReal.coe_pos.1 hδ.1, le_of_lt hδ.2⟩ #align uniformity_basis_edist_nnreal_le uniformity_basis_edist_nnreal_le theorem uniformity_basis_edist_inv_nat : (𝓤 α).HasBasis (fun _ => True) fun n : ℕ => { p : α × α | edist p.1 p.2 < (↑n)⁻¹ } := EMetric.mk_uniformity_basis (fun n _ ↦ ENNReal.inv_pos.2 <| ENNReal.natCast_ne_top n) fun _ε ε₀ ↦ let ⟨n, hn⟩ := ENNReal.exists_inv_nat_lt (ne_of_gt ε₀) ⟨n, trivial, le_of_lt hn⟩ #align uniformity_basis_edist_inv_nat uniformity_basis_edist_inv_nat theorem uniformity_basis_edist_inv_two_pow : (𝓤 α).HasBasis (fun _ => True) fun n : ℕ => { p : α × α | edist p.1 p.2 < 2⁻¹ ^ n } := EMetric.mk_uniformity_basis (fun _ _ => ENNReal.pow_pos (ENNReal.inv_pos.2 ENNReal.two_ne_top) _) fun _ε ε₀ => let ⟨n, hn⟩ := ENNReal.exists_inv_two_pow_lt (ne_of_gt ε₀) ⟨n, trivial, le_of_lt hn⟩ #align uniformity_basis_edist_inv_two_pow uniformity_basis_edist_inv_two_pow theorem edist_mem_uniformity {ε : ℝ≥0∞} (ε0 : 0 < ε) : { p : α × α | edist p.1 p.2 < ε } ∈ 𝓤 α := mem_uniformity_edist.2 ⟨ε, ε0, id⟩ #align edist_mem_uniformity edist_mem_uniformity namespace EMetric instance (priority := 900) instIsCountablyGeneratedUniformity : IsCountablyGenerated (𝓤 α) := isCountablyGenerated_of_seq ⟨_, uniformity_basis_edist_inv_nat.eq_iInf⟩ -- Porting note: changed explicit/implicit theorem uniformContinuousOn_iff [PseudoEMetricSpace β] {f : α → β} {s : Set α} : UniformContinuousOn f s ↔ ∀ ε > 0, ∃ δ > 0, ∀ {a}, a ∈ s → ∀ {b}, b ∈ s → edist a b < δ → edist (f a) (f b) < ε := uniformity_basis_edist.uniformContinuousOn_iff uniformity_basis_edist #align emetric.uniform_continuous_on_iff EMetric.uniformContinuousOn_iff theorem uniformContinuous_iff [PseudoEMetricSpace β] {f : α → β} : UniformContinuous f ↔ ∀ ε > 0, ∃ δ > 0, ∀ {a b : α}, edist a b < δ → edist (f a) (f b) < ε := uniformity_basis_edist.uniformContinuous_iff uniformity_basis_edist #align emetric.uniform_continuous_iff EMetric.uniformContinuous_iff -- Porting note (#10756): new lemma theorem uniformInducing_iff [PseudoEMetricSpace β] {f : α → β} : UniformInducing f ↔ UniformContinuous f ∧ ∀ δ > 0, ∃ ε > 0, ∀ {a b : α}, edist (f a) (f b) < ε → edist a b < δ := uniformInducing_iff'.trans <| Iff.rfl.and <| ((uniformity_basis_edist.comap _).le_basis_iff uniformity_basis_edist).trans <| by simp only [subset_def, Prod.forall]; rfl nonrec theorem uniformEmbedding_iff [PseudoEMetricSpace β] {f : α → β} : UniformEmbedding f ↔ Function.Injective f ∧ UniformContinuous f ∧ ∀ δ > 0, ∃ ε > 0, ∀ {a b : α}, edist (f a) (f b) < ε → edist a b < δ := (uniformEmbedding_iff _).trans <| and_comm.trans <| Iff.rfl.and uniformInducing_iff #align emetric.uniform_embedding_iff EMetric.uniformEmbedding_iff theorem controlled_of_uniformEmbedding [PseudoEMetricSpace β] {f : α → β} (h : UniformEmbedding f) : (∀ ε > 0, ∃ δ > 0, ∀ {a b : α}, edist a b < δ → edist (f a) (f b) < ε) ∧ ∀ δ > 0, ∃ ε > 0, ∀ {a b : α}, edist (f a) (f b) < ε → edist a b < δ := ⟨uniformContinuous_iff.1 h.uniformContinuous, (uniformEmbedding_iff.1 h).2.2⟩ #align emetric.controlled_of_uniform_embedding EMetric.controlled_of_uniformEmbedding protected theorem cauchy_iff {f : Filter α} : Cauchy f ↔ f ≠ ⊥ ∧ ∀ ε > 0, ∃ t ∈ f, ∀ x, x ∈ t → ∀ y, y ∈ t → edist x y < ε := by rw [← neBot_iff]; exact uniformity_basis_edist.cauchy_iff #align emetric.cauchy_iff EMetric.cauchy_iff theorem complete_of_convergent_controlled_sequences (B : ℕ → ℝ≥0∞) (hB : ∀ n, 0 < B n) (H : ∀ u : ℕ → α, (∀ N n m : ℕ, N ≤ n → N ≤ m → edist (u n) (u m) < B N) → ∃ x, Tendsto u atTop (𝓝 x)) : CompleteSpace α := UniformSpace.complete_of_convergent_controlled_sequences (fun n => { p : α × α | edist p.1 p.2 < B n }) (fun n => edist_mem_uniformity <| hB n) H #align emetric.complete_of_convergent_controlled_sequences EMetric.complete_of_convergent_controlled_sequences theorem complete_of_cauchySeq_tendsto : (∀ u : ℕ → α, CauchySeq u → ∃ a, Tendsto u atTop (𝓝 a)) → CompleteSpace α := UniformSpace.complete_of_cauchySeq_tendsto #align emetric.complete_of_cauchy_seq_tendsto EMetric.complete_of_cauchySeq_tendsto theorem tendstoLocallyUniformlyOn_iff {ι : Type*} [TopologicalSpace β] {F : ι → β → α} {f : β → α} {p : Filter ι} {s : Set β} : TendstoLocallyUniformlyOn F f p s ↔ ∀ ε > 0, ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, ∀ᶠ n in p, ∀ y ∈ t, edist (f y) (F n y) < ε := by refine ⟨fun H ε hε => H _ (edist_mem_uniformity hε), fun H u hu x hx => ?_⟩ rcases mem_uniformity_edist.1 hu with ⟨ε, εpos, hε⟩ rcases H ε εpos x hx with ⟨t, ht, Ht⟩ exact ⟨t, ht, Ht.mono fun n hs x hx => hε (hs x hx)⟩ #align emetric.tendsto_locally_uniformly_on_iff EMetric.tendstoLocallyUniformlyOn_iff
Mathlib/Topology/EMetricSpace/Basic.lean
368
372
theorem tendstoUniformlyOn_iff {ι : Type*} {F : ι → β → α} {f : β → α} {p : Filter ι} {s : Set β} : TendstoUniformlyOn F f p s ↔ ∀ ε > 0, ∀ᶠ n in p, ∀ x ∈ s, edist (f x) (F n x) < ε := by
refine ⟨fun H ε hε => H _ (edist_mem_uniformity hε), fun H u hu => ?_⟩ rcases mem_uniformity_edist.1 hu with ⟨ε, εpos, hε⟩ exact (H ε εpos).mono fun n hs x hx => hε (hs x hx)
import Mathlib.GroupTheory.Archimedean import Mathlib.Topology.Order.Basic #align_import topology.algebra.order.archimedean from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" open Set theorem Rat.denseRange_cast {𝕜} [LinearOrderedField 𝕜] [TopologicalSpace 𝕜] [OrderTopology 𝕜] [Archimedean 𝕜] : DenseRange ((↑) : ℚ → 𝕜) := dense_of_exists_between fun _ _ h => Set.exists_range_iff.2 <| exists_rat_btwn h #align rat.dense_range_cast Rat.denseRange_cast namespace AddSubgroup variable {G : Type*} [LinearOrderedAddCommGroup G] [TopologicalSpace G] [OrderTopology G] [Archimedean G] theorem dense_of_not_isolated_zero (S : AddSubgroup G) (hS : ∀ ε > 0, ∃ g ∈ S, g ∈ Ioo 0 ε) : Dense (S : Set G) := by cases subsingleton_or_nontrivial G · refine fun x => _root_.subset_closure ?_ rw [Subsingleton.elim x 0] exact zero_mem S refine dense_of_exists_between fun a b hlt => ?_ rcases hS (b - a) (sub_pos.2 hlt) with ⟨g, hgS, hg0, hg⟩ rcases (existsUnique_add_zsmul_mem_Ioc hg0 0 a).exists with ⟨m, hm⟩ rw [zero_add] at hm refine ⟨m • g, zsmul_mem hgS _, hm.1, hm.2.trans_lt ?_⟩ rwa [lt_sub_iff_add_lt'] at hg
Mathlib/Topology/Algebra/Order/Archimedean.lean
58
62
theorem dense_of_no_min (S : AddSubgroup G) (hbot : S ≠ ⊥) (H : ¬∃ a : G, IsLeast { g : G | g ∈ S ∧ 0 < g } a) : Dense (S : Set G) := by
refine S.dense_of_not_isolated_zero fun ε ε0 => ?_ contrapose! H exact exists_isLeast_pos hbot ε0 (disjoint_left.2 H)
import Mathlib.Tactic.Ring import Mathlib.Data.PNat.Prime #align_import data.pnat.xgcd from "leanprover-community/mathlib"@"6afc9b06856ad973f6a2619e3e8a0a8d537a58f2" open Nat namespace PNat structure XgcdType where wp : ℕ x : ℕ y : ℕ zp : ℕ ap : ℕ bp : ℕ deriving Inhabited #align pnat.xgcd_type PNat.XgcdType namespace XgcdType variable (u : XgcdType) instance : SizeOf XgcdType := ⟨fun u => u.bp⟩ instance : Repr XgcdType where reprPrec | g, _ => s!"[[[{repr (g.wp + 1)}, {repr g.x}], \ [{repr g.y}, {repr (g.zp + 1)}]], \ [{repr (g.ap + 1)}, {repr (g.bp + 1)}]]" def mk' (w : ℕ+) (x : ℕ) (y : ℕ) (z : ℕ+) (a : ℕ+) (b : ℕ+) : XgcdType := mk w.val.pred x y z.val.pred a.val.pred b.val.pred #align pnat.xgcd_type.mk' PNat.XgcdType.mk' def w : ℕ+ := succPNat u.wp #align pnat.xgcd_type.w PNat.XgcdType.w def z : ℕ+ := succPNat u.zp #align pnat.xgcd_type.z PNat.XgcdType.z def a : ℕ+ := succPNat u.ap #align pnat.xgcd_type.a PNat.XgcdType.a def b : ℕ+ := succPNat u.bp #align pnat.xgcd_type.b PNat.XgcdType.b def r : ℕ := (u.ap + 1) % (u.bp + 1) #align pnat.xgcd_type.r PNat.XgcdType.r def q : ℕ := (u.ap + 1) / (u.bp + 1) #align pnat.xgcd_type.q PNat.XgcdType.q def qp : ℕ := u.q - 1 #align pnat.xgcd_type.qp PNat.XgcdType.qp def vp : ℕ × ℕ := ⟨u.wp + u.x + u.ap + u.wp * u.ap + u.x * u.bp, u.y + u.zp + u.bp + u.y * u.ap + u.zp * u.bp⟩ #align pnat.xgcd_type.vp PNat.XgcdType.vp def v : ℕ × ℕ := ⟨u.w * u.a + u.x * u.b, u.y * u.a + u.z * u.b⟩ #align pnat.xgcd_type.v PNat.XgcdType.v def succ₂ (t : ℕ × ℕ) : ℕ × ℕ := ⟨t.1.succ, t.2.succ⟩ #align pnat.xgcd_type.succ₂ PNat.XgcdType.succ₂ theorem v_eq_succ_vp : u.v = succ₂ u.vp := by ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> ring_nf #align pnat.xgcd_type.v_eq_succ_vp PNat.XgcdType.v_eq_succ_vp def IsSpecial : Prop := u.wp + u.zp + u.wp * u.zp = u.x * u.y #align pnat.xgcd_type.is_special PNat.XgcdType.IsSpecial def IsSpecial' : Prop := u.w * u.z = succPNat (u.x * u.y) #align pnat.xgcd_type.is_special' PNat.XgcdType.IsSpecial' theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by dsimp [IsSpecial, IsSpecial'] let ⟨wp, x, y, zp, ap, bp⟩ := u constructor <;> intro h <;> simp [w, z, succPNat] at * <;> simp only [← coe_inj, mul_coe, mk_coe] at * · simp_all [← h, Nat.mul, Nat.succ_eq_add_one]; ring · simp [Nat.succ_eq_add_one, Nat.mul_add, Nat.add_mul, ← Nat.add_assoc] at h; rw [← h]; ring -- Porting note: Old code has been removed as it was much more longer. #align pnat.xgcd_type.is_special_iff PNat.XgcdType.isSpecial_iff def IsReduced : Prop := u.ap = u.bp #align pnat.xgcd_type.is_reduced PNat.XgcdType.IsReduced def IsReduced' : Prop := u.a = u.b #align pnat.xgcd_type.is_reduced' PNat.XgcdType.IsReduced' theorem isReduced_iff : u.IsReduced ↔ u.IsReduced' := succPNat_inj.symm #align pnat.xgcd_type.is_reduced_iff PNat.XgcdType.isReduced_iff def flip : XgcdType where wp := u.zp x := u.y y := u.x zp := u.wp ap := u.bp bp := u.ap #align pnat.xgcd_type.flip PNat.XgcdType.flip @[simp] theorem flip_w : (flip u).w = u.z := rfl #align pnat.xgcd_type.flip_w PNat.XgcdType.flip_w @[simp] theorem flip_x : (flip u).x = u.y := rfl #align pnat.xgcd_type.flip_x PNat.XgcdType.flip_x @[simp] theorem flip_y : (flip u).y = u.x := rfl #align pnat.xgcd_type.flip_y PNat.XgcdType.flip_y @[simp] theorem flip_z : (flip u).z = u.w := rfl #align pnat.xgcd_type.flip_z PNat.XgcdType.flip_z @[simp] theorem flip_a : (flip u).a = u.b := rfl #align pnat.xgcd_type.flip_a PNat.XgcdType.flip_a @[simp] theorem flip_b : (flip u).b = u.a := rfl #align pnat.xgcd_type.flip_b PNat.XgcdType.flip_b theorem flip_isReduced : (flip u).IsReduced ↔ u.IsReduced := by dsimp [IsReduced, flip] constructor <;> intro h <;> exact h.symm #align pnat.xgcd_type.flip_is_reduced PNat.XgcdType.flip_isReduced theorem flip_isSpecial : (flip u).IsSpecial ↔ u.IsSpecial := by dsimp [IsSpecial, flip] rw [mul_comm u.x, mul_comm u.zp, add_comm u.zp] #align pnat.xgcd_type.flip_is_special PNat.XgcdType.flip_isSpecial theorem flip_v : (flip u).v = u.v.swap := by dsimp [v] ext · simp only ring · simp only ring #align pnat.xgcd_type.flip_v PNat.XgcdType.flip_v theorem rq_eq : u.r + (u.bp + 1) * u.q = u.ap + 1 := Nat.mod_add_div (u.ap + 1) (u.bp + 1) #align pnat.xgcd_type.rq_eq PNat.XgcdType.rq_eq theorem qp_eq (hr : u.r = 0) : u.q = u.qp + 1 := by by_cases hq : u.q = 0 · let h := u.rq_eq rw [hr, hq, mul_zero, add_zero] at h cases h · exact (Nat.succ_pred_eq_of_pos (Nat.pos_of_ne_zero hq)).symm #align pnat.xgcd_type.qp_eq PNat.XgcdType.qp_eq def start (a b : ℕ+) : XgcdType := ⟨0, 0, 0, 0, a - 1, b - 1⟩ #align pnat.xgcd_type.start PNat.XgcdType.start theorem start_isSpecial (a b : ℕ+) : (start a b).IsSpecial := by dsimp [start, IsSpecial] #align pnat.xgcd_type.start_is_special PNat.XgcdType.start_isSpecial
Mathlib/Data/PNat/Xgcd.lean
262
267
theorem start_v (a b : ℕ+) : (start a b).v = ⟨a, b⟩ := by
dsimp [start, v, XgcdType.a, XgcdType.b, w, z] rw [one_mul, one_mul, zero_mul, zero_mul] have := a.pos have := b.pos congr <;> omega
import Mathlib.Analysis.InnerProductSpace.Basic import Mathlib.Analysis.NormedSpace.Dual import Mathlib.MeasureTheory.Function.StronglyMeasurable.Lp import Mathlib.MeasureTheory.Integral.SetIntegral #align_import measure_theory.function.ae_eq_of_integral from "leanprover-community/mathlib"@"915591b2bb3ea303648db07284a161a7f2a9e3d4" open MeasureTheory TopologicalSpace NormedSpace Filter open scoped ENNReal NNReal MeasureTheory Topology namespace MeasureTheory variable {α E : Type*} {m m0 : MeasurableSpace α} {μ : Measure α} {s t : Set α} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] {p : ℝ≥0∞} section AeEqOfForallSetIntegralEq theorem ae_const_le_iff_forall_lt_measure_zero {β} [LinearOrder β] [TopologicalSpace β] [OrderTopology β] [FirstCountableTopology β] (f : α → β) (c : β) : (∀ᵐ x ∂μ, c ≤ f x) ↔ ∀ b < c, μ {x | f x ≤ b} = 0 := by rw [ae_iff] push_neg constructor · intro h b hb exact measure_mono_null (fun y hy => (lt_of_le_of_lt hy hb : _)) h intro hc by_cases h : ∀ b, c ≤ b · have : {a : α | f a < c} = ∅ := by apply Set.eq_empty_iff_forall_not_mem.2 fun x hx => ?_ exact (lt_irrefl _ (lt_of_lt_of_le hx (h (f x)))).elim simp [this] by_cases H : ¬IsLUB (Set.Iio c) c · have : c ∈ upperBounds (Set.Iio c) := fun y hy => le_of_lt hy obtain ⟨b, b_up, bc⟩ : ∃ b : β, b ∈ upperBounds (Set.Iio c) ∧ b < c := by simpa [IsLUB, IsLeast, this, lowerBounds] using H exact measure_mono_null (fun x hx => b_up hx) (hc b bc) push_neg at H h obtain ⟨u, _, u_lt, u_lim, -⟩ : ∃ u : ℕ → β, StrictMono u ∧ (∀ n : ℕ, u n < c) ∧ Tendsto u atTop (𝓝 c) ∧ ∀ n : ℕ, u n ∈ Set.Iio c := H.exists_seq_strictMono_tendsto_of_not_mem (lt_irrefl c) h have h_Union : {x | f x < c} = ⋃ n : ℕ, {x | f x ≤ u n} := by ext1 x simp_rw [Set.mem_iUnion, Set.mem_setOf_eq] constructor <;> intro h · obtain ⟨n, hn⟩ := ((tendsto_order.1 u_lim).1 _ h).exists; exact ⟨n, hn.le⟩ · obtain ⟨n, hn⟩ := h; exact hn.trans_lt (u_lt _) rw [h_Union, measure_iUnion_null_iff] intro n exact hc _ (u_lt n) #align measure_theory.ae_const_le_iff_forall_lt_measure_zero MeasureTheory.ae_const_le_iff_forall_lt_measure_zero section Real variable {f : α → ℝ} theorem ae_nonneg_of_forall_setIntegral_nonneg_of_stronglyMeasurable (hfm : StronglyMeasurable f) (hf : Integrable f μ) (hf_zero : ∀ s, MeasurableSet s → μ s < ∞ → 0 ≤ ∫ x in s, f x ∂μ) : 0 ≤ᵐ[μ] f := by simp_rw [EventuallyLE, Pi.zero_apply] rw [ae_const_le_iff_forall_lt_measure_zero] intro b hb_neg let s := {x | f x ≤ b} have hs : MeasurableSet s := hfm.measurableSet_le stronglyMeasurable_const have mus : μ s < ∞ := Integrable.measure_le_lt_top hf hb_neg have h_int_gt : (∫ x in s, f x ∂μ) ≤ b * (μ s).toReal := by have h_const_le : (∫ x in s, f x ∂μ) ≤ ∫ _ in s, b ∂μ := by refine setIntegral_mono_ae_restrict hf.integrableOn (integrableOn_const.mpr (Or.inr mus)) ?_ rw [EventuallyLE, ae_restrict_iff hs] exact eventually_of_forall fun x hxs => hxs rwa [setIntegral_const, smul_eq_mul, mul_comm] at h_const_le by_contra h refine (lt_self_iff_false (∫ x in s, f x ∂μ)).mp (h_int_gt.trans_lt ?_) refine (mul_neg_iff.mpr (Or.inr ⟨hb_neg, ?_⟩)).trans_le ?_ swap · exact hf_zero s hs mus refine ENNReal.toReal_nonneg.lt_of_ne fun h_eq => h ?_ cases' (ENNReal.toReal_eq_zero_iff _).mp h_eq.symm with hμs_eq_zero hμs_eq_top · exact hμs_eq_zero · exact absurd hμs_eq_top mus.ne #align measure_theory.ae_nonneg_of_forall_set_integral_nonneg_of_strongly_measurable MeasureTheory.ae_nonneg_of_forall_setIntegral_nonneg_of_stronglyMeasurable @[deprecated (since := "2024-04-17")] alias ae_nonneg_of_forall_set_integral_nonneg_of_stronglyMeasurable := ae_nonneg_of_forall_setIntegral_nonneg_of_stronglyMeasurable theorem ae_nonneg_of_forall_setIntegral_nonneg (hf : Integrable f μ) (hf_zero : ∀ s, MeasurableSet s → μ s < ∞ → 0 ≤ ∫ x in s, f x ∂μ) : 0 ≤ᵐ[μ] f := by rcases hf.1 with ⟨f', hf'_meas, hf_ae⟩ have hf'_integrable : Integrable f' μ := Integrable.congr hf hf_ae have hf'_zero : ∀ s, MeasurableSet s → μ s < ∞ → 0 ≤ ∫ x in s, f' x ∂μ := by intro s hs h's rw [setIntegral_congr_ae hs (hf_ae.mono fun x hx _ => hx.symm)] exact hf_zero s hs h's exact (ae_nonneg_of_forall_setIntegral_nonneg_of_stronglyMeasurable hf'_meas hf'_integrable hf'_zero).trans hf_ae.symm.le #align measure_theory.ae_nonneg_of_forall_set_integral_nonneg MeasureTheory.ae_nonneg_of_forall_setIntegral_nonneg @[deprecated (since := "2024-04-17")] alias ae_nonneg_of_forall_set_integral_nonneg := ae_nonneg_of_forall_setIntegral_nonneg theorem ae_le_of_forall_setIntegral_le {f g : α → ℝ} (hf : Integrable f μ) (hg : Integrable g μ) (hf_le : ∀ s, MeasurableSet s → μ s < ∞ → (∫ x in s, f x ∂μ) ≤ ∫ x in s, g x ∂μ) : f ≤ᵐ[μ] g := by rw [← eventually_sub_nonneg] refine ae_nonneg_of_forall_setIntegral_nonneg (hg.sub hf) fun s hs => ?_ rw [integral_sub' hg.integrableOn hf.integrableOn, sub_nonneg] exact hf_le s hs #align measure_theory.ae_le_of_forall_set_integral_le MeasureTheory.ae_le_of_forall_setIntegral_le @[deprecated (since := "2024-04-17")] alias ae_le_of_forall_set_integral_le := ae_le_of_forall_setIntegral_le theorem ae_nonneg_restrict_of_forall_setIntegral_nonneg_inter {f : α → ℝ} {t : Set α} (hf : IntegrableOn f t μ) (hf_zero : ∀ s, MeasurableSet s → μ (s ∩ t) < ∞ → 0 ≤ ∫ x in s ∩ t, f x ∂μ) : 0 ≤ᵐ[μ.restrict t] f := by refine ae_nonneg_of_forall_setIntegral_nonneg hf fun s hs h's => ?_ simp_rw [Measure.restrict_restrict hs] apply hf_zero s hs rwa [Measure.restrict_apply hs] at h's #align measure_theory.ae_nonneg_restrict_of_forall_set_integral_nonneg_inter MeasureTheory.ae_nonneg_restrict_of_forall_setIntegral_nonneg_inter @[deprecated (since := "2024-04-17")] alias ae_nonneg_restrict_of_forall_set_integral_nonneg_inter := ae_nonneg_restrict_of_forall_setIntegral_nonneg_inter theorem ae_nonneg_of_forall_setIntegral_nonneg_of_sigmaFinite [SigmaFinite μ] {f : α → ℝ} (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hf_zero : ∀ s, MeasurableSet s → μ s < ∞ → 0 ≤ ∫ x in s, f x ∂μ) : 0 ≤ᵐ[μ] f := by apply ae_of_forall_measure_lt_top_ae_restrict intro t t_meas t_lt_top apply ae_nonneg_restrict_of_forall_setIntegral_nonneg_inter (hf_int_finite t t_meas t_lt_top) intro s s_meas _ exact hf_zero _ (s_meas.inter t_meas) (lt_of_le_of_lt (measure_mono (Set.inter_subset_right)) t_lt_top) #align measure_theory.ae_nonneg_of_forall_set_integral_nonneg_of_sigma_finite MeasureTheory.ae_nonneg_of_forall_setIntegral_nonneg_of_sigmaFinite @[deprecated (since := "2024-04-17")] alias ae_nonneg_of_forall_set_integral_nonneg_of_sigmaFinite := ae_nonneg_of_forall_setIntegral_nonneg_of_sigmaFinite theorem AEFinStronglyMeasurable.ae_nonneg_of_forall_setIntegral_nonneg {f : α → ℝ} (hf : AEFinStronglyMeasurable f μ) (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hf_zero : ∀ s, MeasurableSet s → μ s < ∞ → 0 ≤ ∫ x in s, f x ∂μ) : 0 ≤ᵐ[μ] f := by let t := hf.sigmaFiniteSet suffices 0 ≤ᵐ[μ.restrict t] f from ae_of_ae_restrict_of_ae_restrict_compl _ this hf.ae_eq_zero_compl.symm.le haveI : SigmaFinite (μ.restrict t) := hf.sigmaFinite_restrict refine ae_nonneg_of_forall_setIntegral_nonneg_of_sigmaFinite (fun s hs hμts => ?_) fun s hs hμts => ?_ · rw [IntegrableOn, Measure.restrict_restrict hs] rw [Measure.restrict_apply hs] at hμts exact hf_int_finite (s ∩ t) (hs.inter hf.measurableSet) hμts · rw [Measure.restrict_restrict hs] rw [Measure.restrict_apply hs] at hμts exact hf_zero (s ∩ t) (hs.inter hf.measurableSet) hμts #align measure_theory.ae_fin_strongly_measurable.ae_nonneg_of_forall_set_integral_nonneg MeasureTheory.AEFinStronglyMeasurable.ae_nonneg_of_forall_setIntegral_nonneg @[deprecated (since := "2024-04-17")] alias AEFinStronglyMeasurable.ae_nonneg_of_forall_set_integral_nonneg := AEFinStronglyMeasurable.ae_nonneg_of_forall_setIntegral_nonneg
Mathlib/MeasureTheory/Function/AEEqOfIntegral.lean
373
381
theorem ae_nonneg_restrict_of_forall_setIntegral_nonneg {f : α → ℝ} (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hf_zero : ∀ s, MeasurableSet s → μ s < ∞ → 0 ≤ ∫ x in s, f x ∂μ) {t : Set α} (ht : MeasurableSet t) (hμt : μ t ≠ ∞) : 0 ≤ᵐ[μ.restrict t] f := by
refine ae_nonneg_restrict_of_forall_setIntegral_nonneg_inter (hf_int_finite t ht (lt_top_iff_ne_top.mpr hμt)) fun s hs _ => ?_ refine hf_zero (s ∩ t) (hs.inter ht) ?_ exact (measure_mono Set.inter_subset_right).trans_lt (lt_top_iff_ne_top.mpr hμt)
import Mathlib.Init.ZeroOne import Mathlib.Data.Set.Defs import Mathlib.Order.Basic import Mathlib.Order.SymmDiff import Mathlib.Tactic.Tauto import Mathlib.Tactic.ByContra import Mathlib.Util.Delaborators #align_import data.set.basic from "leanprover-community/mathlib"@"001ffdc42920050657fd45bd2b8bfbec8eaaeb29" open Function universe u v w x namespace Set variable {α : Type u} {s t : Set α} instance instBooleanAlgebraSet : BooleanAlgebra (Set α) := { (inferInstance : BooleanAlgebra (α → Prop)) with sup := (· ∪ ·), le := (· ≤ ·), lt := fun s t => s ⊆ t ∧ ¬t ⊆ s, inf := (· ∩ ·), bot := ∅, compl := (·ᶜ), top := univ, sdiff := (· \ ·) } instance : HasSSubset (Set α) := ⟨(· < ·)⟩ @[simp] theorem top_eq_univ : (⊤ : Set α) = univ := rfl #align set.top_eq_univ Set.top_eq_univ @[simp] theorem bot_eq_empty : (⊥ : Set α) = ∅ := rfl #align set.bot_eq_empty Set.bot_eq_empty @[simp] theorem sup_eq_union : ((· ⊔ ·) : Set α → Set α → Set α) = (· ∪ ·) := rfl #align set.sup_eq_union Set.sup_eq_union @[simp] theorem inf_eq_inter : ((· ⊓ ·) : Set α → Set α → Set α) = (· ∩ ·) := rfl #align set.inf_eq_inter Set.inf_eq_inter @[simp] theorem le_eq_subset : ((· ≤ ·) : Set α → Set α → Prop) = (· ⊆ ·) := rfl #align set.le_eq_subset Set.le_eq_subset @[simp] theorem lt_eq_ssubset : ((· < ·) : Set α → Set α → Prop) = (· ⊂ ·) := rfl #align set.lt_eq_ssubset Set.lt_eq_ssubset theorem le_iff_subset : s ≤ t ↔ s ⊆ t := Iff.rfl #align set.le_iff_subset Set.le_iff_subset theorem lt_iff_ssubset : s < t ↔ s ⊂ t := Iff.rfl #align set.lt_iff_ssubset Set.lt_iff_ssubset alias ⟨_root_.LE.le.subset, _root_.HasSubset.Subset.le⟩ := le_iff_subset #align has_subset.subset.le HasSubset.Subset.le alias ⟨_root_.LT.lt.ssubset, _root_.HasSSubset.SSubset.lt⟩ := lt_iff_ssubset #align has_ssubset.ssubset.lt HasSSubset.SSubset.lt instance PiSetCoe.canLift (ι : Type u) (α : ι → Type v) [∀ i, Nonempty (α i)] (s : Set ι) : CanLift (∀ i : s, α i) (∀ i, α i) (fun f i => f i) fun _ => True := PiSubtype.canLift ι α s #align set.pi_set_coe.can_lift Set.PiSetCoe.canLift instance PiSetCoe.canLift' (ι : Type u) (α : Type v) [Nonempty α] (s : Set ι) : CanLift (s → α) (ι → α) (fun f i => f i) fun _ => True := PiSetCoe.canLift ι (fun _ => α) s #align set.pi_set_coe.can_lift' Set.PiSetCoe.canLift' end Set theorem Subtype.mem {α : Type*} {s : Set α} (p : s) : (p : α) ∈ s := p.prop #align subtype.mem Subtype.mem theorem Eq.subset {α} {s t : Set α} : s = t → s ⊆ t := fun h₁ _ h₂ => by rw [← h₁]; exact h₂ #align eq.subset Eq.subset namespace Set variable {α : Type u} {β : Type v} {γ : Type w} {ι : Sort x} {a b : α} {s s₁ s₂ t t₁ t₂ u : Set α} instance : Inhabited (Set α) := ⟨∅⟩ theorem ext_iff {s t : Set α} : s = t ↔ ∀ x, x ∈ s ↔ x ∈ t := ⟨fun h x => by rw [h], ext⟩ #align set.ext_iff Set.ext_iff @[trans] theorem mem_of_mem_of_subset {x : α} {s t : Set α} (hx : x ∈ s) (h : s ⊆ t) : x ∈ t := h hx #align set.mem_of_mem_of_subset Set.mem_of_mem_of_subset theorem forall_in_swap {p : α → β → Prop} : (∀ a ∈ s, ∀ (b), p a b) ↔ ∀ (b), ∀ a ∈ s, p a b := by tauto #align set.forall_in_swap Set.forall_in_swap theorem mem_setOf {a : α} {p : α → Prop} : a ∈ { x | p x } ↔ p a := Iff.rfl #align set.mem_set_of Set.mem_setOf theorem _root_.Membership.mem.out {p : α → Prop} {a : α} (h : a ∈ { x | p x }) : p a := h #align has_mem.mem.out Membership.mem.out theorem nmem_setOf_iff {a : α} {p : α → Prop} : a ∉ { x | p x } ↔ ¬p a := Iff.rfl #align set.nmem_set_of_iff Set.nmem_setOf_iff @[simp] theorem setOf_mem_eq {s : Set α} : { x | x ∈ s } = s := rfl #align set.set_of_mem_eq Set.setOf_mem_eq theorem setOf_set {s : Set α} : setOf s = s := rfl #align set.set_of_set Set.setOf_set theorem setOf_app_iff {p : α → Prop} {x : α} : { x | p x } x ↔ p x := Iff.rfl #align set.set_of_app_iff Set.setOf_app_iff theorem mem_def {a : α} {s : Set α} : a ∈ s ↔ s a := Iff.rfl #align set.mem_def Set.mem_def theorem setOf_bijective : Bijective (setOf : (α → Prop) → Set α) := bijective_id #align set.set_of_bijective Set.setOf_bijective theorem subset_setOf {p : α → Prop} {s : Set α} : s ⊆ setOf p ↔ ∀ x, x ∈ s → p x := Iff.rfl theorem setOf_subset {p : α → Prop} {s : Set α} : setOf p ⊆ s ↔ ∀ x, p x → x ∈ s := Iff.rfl @[simp] theorem setOf_subset_setOf {p q : α → Prop} : { a | p a } ⊆ { a | q a } ↔ ∀ a, p a → q a := Iff.rfl #align set.set_of_subset_set_of Set.setOf_subset_setOf theorem setOf_and {p q : α → Prop} : { a | p a ∧ q a } = { a | p a } ∩ { a | q a } := rfl #align set.set_of_and Set.setOf_and theorem setOf_or {p q : α → Prop} : { a | p a ∨ q a } = { a | p a } ∪ { a | q a } := rfl #align set.set_of_or Set.setOf_or instance : IsRefl (Set α) (· ⊆ ·) := show IsRefl (Set α) (· ≤ ·) by infer_instance instance : IsTrans (Set α) (· ⊆ ·) := show IsTrans (Set α) (· ≤ ·) by infer_instance instance : Trans ((· ⊆ ·) : Set α → Set α → Prop) (· ⊆ ·) (· ⊆ ·) := show Trans (· ≤ ·) (· ≤ ·) (· ≤ ·) by infer_instance instance : IsAntisymm (Set α) (· ⊆ ·) := show IsAntisymm (Set α) (· ≤ ·) by infer_instance instance : IsIrrefl (Set α) (· ⊂ ·) := show IsIrrefl (Set α) (· < ·) by infer_instance instance : IsTrans (Set α) (· ⊂ ·) := show IsTrans (Set α) (· < ·) by infer_instance instance : Trans ((· ⊂ ·) : Set α → Set α → Prop) (· ⊂ ·) (· ⊂ ·) := show Trans (· < ·) (· < ·) (· < ·) by infer_instance instance : Trans ((· ⊂ ·) : Set α → Set α → Prop) (· ⊆ ·) (· ⊂ ·) := show Trans (· < ·) (· ≤ ·) (· < ·) by infer_instance instance : Trans ((· ⊆ ·) : Set α → Set α → Prop) (· ⊂ ·) (· ⊂ ·) := show Trans (· ≤ ·) (· < ·) (· < ·) by infer_instance instance : IsAsymm (Set α) (· ⊂ ·) := show IsAsymm (Set α) (· < ·) by infer_instance instance : IsNonstrictStrictOrder (Set α) (· ⊆ ·) (· ⊂ ·) := ⟨fun _ _ => Iff.rfl⟩ -- TODO(Jeremy): write a tactic to unfold specific instances of generic notation? theorem subset_def : (s ⊆ t) = ∀ x, x ∈ s → x ∈ t := rfl #align set.subset_def Set.subset_def theorem ssubset_def : (s ⊂ t) = (s ⊆ t ∧ ¬t ⊆ s) := rfl #align set.ssubset_def Set.ssubset_def @[refl] theorem Subset.refl (a : Set α) : a ⊆ a := fun _ => id #align set.subset.refl Set.Subset.refl theorem Subset.rfl {s : Set α} : s ⊆ s := Subset.refl s #align set.subset.rfl Set.Subset.rfl @[trans] theorem Subset.trans {a b c : Set α} (ab : a ⊆ b) (bc : b ⊆ c) : a ⊆ c := fun _ h => bc <| ab h #align set.subset.trans Set.Subset.trans @[trans] theorem mem_of_eq_of_mem {x y : α} {s : Set α} (hx : x = y) (h : y ∈ s) : x ∈ s := hx.symm ▸ h #align set.mem_of_eq_of_mem Set.mem_of_eq_of_mem theorem Subset.antisymm {a b : Set α} (h₁ : a ⊆ b) (h₂ : b ⊆ a) : a = b := Set.ext fun _ => ⟨@h₁ _, @h₂ _⟩ #align set.subset.antisymm Set.Subset.antisymm theorem Subset.antisymm_iff {a b : Set α} : a = b ↔ a ⊆ b ∧ b ⊆ a := ⟨fun e => ⟨e.subset, e.symm.subset⟩, fun ⟨h₁, h₂⟩ => Subset.antisymm h₁ h₂⟩ #align set.subset.antisymm_iff Set.Subset.antisymm_iff -- an alternative name theorem eq_of_subset_of_subset {a b : Set α} : a ⊆ b → b ⊆ a → a = b := Subset.antisymm #align set.eq_of_subset_of_subset Set.eq_of_subset_of_subset theorem mem_of_subset_of_mem {s₁ s₂ : Set α} {a : α} (h : s₁ ⊆ s₂) : a ∈ s₁ → a ∈ s₂ := @h _ #align set.mem_of_subset_of_mem Set.mem_of_subset_of_mem theorem not_mem_subset (h : s ⊆ t) : a ∉ t → a ∉ s := mt <| mem_of_subset_of_mem h #align set.not_mem_subset Set.not_mem_subset theorem not_subset : ¬s ⊆ t ↔ ∃ a ∈ s, a ∉ t := by simp only [subset_def, not_forall, exists_prop] #align set.not_subset Set.not_subset lemma eq_of_forall_subset_iff (h : ∀ u, s ⊆ u ↔ t ⊆ u) : s = t := eq_of_forall_ge_iff h protected theorem eq_or_ssubset_of_subset (h : s ⊆ t) : s = t ∨ s ⊂ t := eq_or_lt_of_le h #align set.eq_or_ssubset_of_subset Set.eq_or_ssubset_of_subset theorem exists_of_ssubset {s t : Set α} (h : s ⊂ t) : ∃ x ∈ t, x ∉ s := not_subset.1 h.2 #align set.exists_of_ssubset Set.exists_of_ssubset protected theorem ssubset_iff_subset_ne {s t : Set α} : s ⊂ t ↔ s ⊆ t ∧ s ≠ t := @lt_iff_le_and_ne (Set α) _ s t #align set.ssubset_iff_subset_ne Set.ssubset_iff_subset_ne theorem ssubset_iff_of_subset {s t : Set α} (h : s ⊆ t) : s ⊂ t ↔ ∃ x ∈ t, x ∉ s := ⟨exists_of_ssubset, fun ⟨_, hxt, hxs⟩ => ⟨h, fun h => hxs <| h hxt⟩⟩ #align set.ssubset_iff_of_subset Set.ssubset_iff_of_subset protected theorem ssubset_of_ssubset_of_subset {s₁ s₂ s₃ : Set α} (hs₁s₂ : s₁ ⊂ s₂) (hs₂s₃ : s₂ ⊆ s₃) : s₁ ⊂ s₃ := ⟨Subset.trans hs₁s₂.1 hs₂s₃, fun hs₃s₁ => hs₁s₂.2 (Subset.trans hs₂s₃ hs₃s₁)⟩ #align set.ssubset_of_ssubset_of_subset Set.ssubset_of_ssubset_of_subset protected theorem ssubset_of_subset_of_ssubset {s₁ s₂ s₃ : Set α} (hs₁s₂ : s₁ ⊆ s₂) (hs₂s₃ : s₂ ⊂ s₃) : s₁ ⊂ s₃ := ⟨Subset.trans hs₁s₂ hs₂s₃.1, fun hs₃s₁ => hs₂s₃.2 (Subset.trans hs₃s₁ hs₁s₂)⟩ #align set.ssubset_of_subset_of_ssubset Set.ssubset_of_subset_of_ssubset theorem not_mem_empty (x : α) : ¬x ∈ (∅ : Set α) := id #align set.not_mem_empty Set.not_mem_empty -- Porting note (#10618): removed `simp` because `simp` can prove it theorem not_not_mem : ¬a ∉ s ↔ a ∈ s := not_not #align set.not_not_mem Set.not_not_mem -- Porting note: we seem to need parentheses at `(↥s)`, -- even if we increase the right precedence of `↥` in `Mathlib.Tactic.Coe`. -- Porting note: removed `simp` as it is competing with `nonempty_subtype`. -- @[simp] theorem nonempty_coe_sort {s : Set α} : Nonempty (↥s) ↔ s.Nonempty := nonempty_subtype #align set.nonempty_coe_sort Set.nonempty_coe_sort alias ⟨_, Nonempty.coe_sort⟩ := nonempty_coe_sort #align set.nonempty.coe_sort Set.Nonempty.coe_sort theorem nonempty_def : s.Nonempty ↔ ∃ x, x ∈ s := Iff.rfl #align set.nonempty_def Set.nonempty_def theorem nonempty_of_mem {x} (h : x ∈ s) : s.Nonempty := ⟨x, h⟩ #align set.nonempty_of_mem Set.nonempty_of_mem theorem Nonempty.not_subset_empty : s.Nonempty → ¬s ⊆ ∅ | ⟨_, hx⟩, hs => hs hx #align set.nonempty.not_subset_empty Set.Nonempty.not_subset_empty protected noncomputable def Nonempty.some (h : s.Nonempty) : α := Classical.choose h #align set.nonempty.some Set.Nonempty.some protected theorem Nonempty.some_mem (h : s.Nonempty) : h.some ∈ s := Classical.choose_spec h #align set.nonempty.some_mem Set.Nonempty.some_mem theorem Nonempty.mono (ht : s ⊆ t) (hs : s.Nonempty) : t.Nonempty := hs.imp ht #align set.nonempty.mono Set.Nonempty.mono theorem nonempty_of_not_subset (h : ¬s ⊆ t) : (s \ t).Nonempty := let ⟨x, xs, xt⟩ := not_subset.1 h ⟨x, xs, xt⟩ #align set.nonempty_of_not_subset Set.nonempty_of_not_subset theorem nonempty_of_ssubset (ht : s ⊂ t) : (t \ s).Nonempty := nonempty_of_not_subset ht.2 #align set.nonempty_of_ssubset Set.nonempty_of_ssubset theorem Nonempty.of_diff (h : (s \ t).Nonempty) : s.Nonempty := h.imp fun _ => And.left #align set.nonempty.of_diff Set.Nonempty.of_diff theorem nonempty_of_ssubset' (ht : s ⊂ t) : t.Nonempty := (nonempty_of_ssubset ht).of_diff #align set.nonempty_of_ssubset' Set.nonempty_of_ssubset' theorem Nonempty.inl (hs : s.Nonempty) : (s ∪ t).Nonempty := hs.imp fun _ => Or.inl #align set.nonempty.inl Set.Nonempty.inl theorem Nonempty.inr (ht : t.Nonempty) : (s ∪ t).Nonempty := ht.imp fun _ => Or.inr #align set.nonempty.inr Set.Nonempty.inr @[simp] theorem union_nonempty : (s ∪ t).Nonempty ↔ s.Nonempty ∨ t.Nonempty := exists_or #align set.union_nonempty Set.union_nonempty theorem Nonempty.left (h : (s ∩ t).Nonempty) : s.Nonempty := h.imp fun _ => And.left #align set.nonempty.left Set.Nonempty.left theorem Nonempty.right (h : (s ∩ t).Nonempty) : t.Nonempty := h.imp fun _ => And.right #align set.nonempty.right Set.Nonempty.right theorem inter_nonempty : (s ∩ t).Nonempty ↔ ∃ x, x ∈ s ∧ x ∈ t := Iff.rfl #align set.inter_nonempty Set.inter_nonempty theorem inter_nonempty_iff_exists_left : (s ∩ t).Nonempty ↔ ∃ x ∈ s, x ∈ t := by simp_rw [inter_nonempty] #align set.inter_nonempty_iff_exists_left Set.inter_nonempty_iff_exists_left theorem inter_nonempty_iff_exists_right : (s ∩ t).Nonempty ↔ ∃ x ∈ t, x ∈ s := by simp_rw [inter_nonempty, and_comm] #align set.inter_nonempty_iff_exists_right Set.inter_nonempty_iff_exists_right theorem nonempty_iff_univ_nonempty : Nonempty α ↔ (univ : Set α).Nonempty := ⟨fun ⟨x⟩ => ⟨x, trivial⟩, fun ⟨x, _⟩ => ⟨x⟩⟩ #align set.nonempty_iff_univ_nonempty Set.nonempty_iff_univ_nonempty @[simp] theorem univ_nonempty : ∀ [Nonempty α], (univ : Set α).Nonempty | ⟨x⟩ => ⟨x, trivial⟩ #align set.univ_nonempty Set.univ_nonempty theorem Nonempty.to_subtype : s.Nonempty → Nonempty (↥s) := nonempty_subtype.2 #align set.nonempty.to_subtype Set.Nonempty.to_subtype theorem Nonempty.to_type : s.Nonempty → Nonempty α := fun ⟨x, _⟩ => ⟨x⟩ #align set.nonempty.to_type Set.Nonempty.to_type instance univ.nonempty [Nonempty α] : Nonempty (↥(Set.univ : Set α)) := Set.univ_nonempty.to_subtype #align set.univ.nonempty Set.univ.nonempty theorem nonempty_of_nonempty_subtype [Nonempty (↥s)] : s.Nonempty := nonempty_subtype.mp ‹_› #align set.nonempty_of_nonempty_subtype Set.nonempty_of_nonempty_subtype theorem empty_def : (∅ : Set α) = { _x : α | False } := rfl #align set.empty_def Set.empty_def @[simp] theorem mem_empty_iff_false (x : α) : x ∈ (∅ : Set α) ↔ False := Iff.rfl #align set.mem_empty_iff_false Set.mem_empty_iff_false @[simp] theorem setOf_false : { _a : α | False } = ∅ := rfl #align set.set_of_false Set.setOf_false @[simp] theorem setOf_bot : { _x : α | ⊥ } = ∅ := rfl @[simp] theorem empty_subset (s : Set α) : ∅ ⊆ s := nofun #align set.empty_subset Set.empty_subset theorem subset_empty_iff {s : Set α} : s ⊆ ∅ ↔ s = ∅ := (Subset.antisymm_iff.trans <| and_iff_left (empty_subset _)).symm #align set.subset_empty_iff Set.subset_empty_iff theorem eq_empty_iff_forall_not_mem {s : Set α} : s = ∅ ↔ ∀ x, x ∉ s := subset_empty_iff.symm #align set.eq_empty_iff_forall_not_mem Set.eq_empty_iff_forall_not_mem theorem eq_empty_of_forall_not_mem (h : ∀ x, x ∉ s) : s = ∅ := subset_empty_iff.1 h #align set.eq_empty_of_forall_not_mem Set.eq_empty_of_forall_not_mem theorem eq_empty_of_subset_empty {s : Set α} : s ⊆ ∅ → s = ∅ := subset_empty_iff.1 #align set.eq_empty_of_subset_empty Set.eq_empty_of_subset_empty theorem eq_empty_of_isEmpty [IsEmpty α] (s : Set α) : s = ∅ := eq_empty_of_subset_empty fun x _ => isEmptyElim x #align set.eq_empty_of_is_empty Set.eq_empty_of_isEmpty instance uniqueEmpty [IsEmpty α] : Unique (Set α) where default := ∅ uniq := eq_empty_of_isEmpty #align set.unique_empty Set.uniqueEmpty theorem not_nonempty_iff_eq_empty {s : Set α} : ¬s.Nonempty ↔ s = ∅ := by simp only [Set.Nonempty, not_exists, eq_empty_iff_forall_not_mem] #align set.not_nonempty_iff_eq_empty Set.not_nonempty_iff_eq_empty theorem nonempty_iff_ne_empty : s.Nonempty ↔ s ≠ ∅ := not_nonempty_iff_eq_empty.not_right #align set.nonempty_iff_ne_empty Set.nonempty_iff_ne_empty theorem not_nonempty_iff_eq_empty' : ¬Nonempty s ↔ s = ∅ := by rw [nonempty_subtype, not_exists, eq_empty_iff_forall_not_mem] theorem nonempty_iff_ne_empty' : Nonempty s ↔ s ≠ ∅ := not_nonempty_iff_eq_empty'.not_right alias ⟨Nonempty.ne_empty, _⟩ := nonempty_iff_ne_empty #align set.nonempty.ne_empty Set.Nonempty.ne_empty @[simp] theorem not_nonempty_empty : ¬(∅ : Set α).Nonempty := fun ⟨_, hx⟩ => hx #align set.not_nonempty_empty Set.not_nonempty_empty -- Porting note: removing `@[simp]` as it is competing with `isEmpty_subtype`. -- @[simp] theorem isEmpty_coe_sort {s : Set α} : IsEmpty (↥s) ↔ s = ∅ := not_iff_not.1 <| by simpa using nonempty_iff_ne_empty #align set.is_empty_coe_sort Set.isEmpty_coe_sort theorem eq_empty_or_nonempty (s : Set α) : s = ∅ ∨ s.Nonempty := or_iff_not_imp_left.2 nonempty_iff_ne_empty.2 #align set.eq_empty_or_nonempty Set.eq_empty_or_nonempty theorem subset_eq_empty {s t : Set α} (h : t ⊆ s) (e : s = ∅) : t = ∅ := subset_empty_iff.1 <| e ▸ h #align set.subset_eq_empty Set.subset_eq_empty theorem forall_mem_empty {p : α → Prop} : (∀ x ∈ (∅ : Set α), p x) ↔ True := iff_true_intro fun _ => False.elim #align set.ball_empty_iff Set.forall_mem_empty @[deprecated (since := "2024-03-23")] alias ball_empty_iff := forall_mem_empty instance (α : Type u) : IsEmpty.{u + 1} (↥(∅ : Set α)) := ⟨fun x => x.2⟩ @[simp] theorem empty_ssubset : ∅ ⊂ s ↔ s.Nonempty := (@bot_lt_iff_ne_bot (Set α) _ _ _).trans nonempty_iff_ne_empty.symm #align set.empty_ssubset Set.empty_ssubset alias ⟨_, Nonempty.empty_ssubset⟩ := empty_ssubset #align set.nonempty.empty_ssubset Set.Nonempty.empty_ssubset @[simp] theorem setOf_true : { _x : α | True } = univ := rfl #align set.set_of_true Set.setOf_true @[simp] theorem setOf_top : { _x : α | ⊤ } = univ := rfl @[simp] theorem univ_eq_empty_iff : (univ : Set α) = ∅ ↔ IsEmpty α := eq_empty_iff_forall_not_mem.trans ⟨fun H => ⟨fun x => H x trivial⟩, fun H x _ => @IsEmpty.false α H x⟩ #align set.univ_eq_empty_iff Set.univ_eq_empty_iff theorem empty_ne_univ [Nonempty α] : (∅ : Set α) ≠ univ := fun e => not_isEmpty_of_nonempty α <| univ_eq_empty_iff.1 e.symm #align set.empty_ne_univ Set.empty_ne_univ @[simp] theorem subset_univ (s : Set α) : s ⊆ univ := fun _ _ => trivial #align set.subset_univ Set.subset_univ @[simp] theorem univ_subset_iff {s : Set α} : univ ⊆ s ↔ s = univ := @top_le_iff _ _ _ s #align set.univ_subset_iff Set.univ_subset_iff alias ⟨eq_univ_of_univ_subset, _⟩ := univ_subset_iff #align set.eq_univ_of_univ_subset Set.eq_univ_of_univ_subset theorem eq_univ_iff_forall {s : Set α} : s = univ ↔ ∀ x, x ∈ s := univ_subset_iff.symm.trans <| forall_congr' fun _ => imp_iff_right trivial #align set.eq_univ_iff_forall Set.eq_univ_iff_forall theorem eq_univ_of_forall {s : Set α} : (∀ x, x ∈ s) → s = univ := eq_univ_iff_forall.2 #align set.eq_univ_of_forall Set.eq_univ_of_forall theorem Nonempty.eq_univ [Subsingleton α] : s.Nonempty → s = univ := by rintro ⟨x, hx⟩ exact eq_univ_of_forall fun y => by rwa [Subsingleton.elim y x] #align set.nonempty.eq_univ Set.Nonempty.eq_univ theorem eq_univ_of_subset {s t : Set α} (h : s ⊆ t) (hs : s = univ) : t = univ := eq_univ_of_univ_subset <| (hs ▸ h : univ ⊆ t) #align set.eq_univ_of_subset Set.eq_univ_of_subset theorem exists_mem_of_nonempty (α) : ∀ [Nonempty α], ∃ x : α, x ∈ (univ : Set α) | ⟨x⟩ => ⟨x, trivial⟩ #align set.exists_mem_of_nonempty Set.exists_mem_of_nonempty theorem ne_univ_iff_exists_not_mem {α : Type*} (s : Set α) : s ≠ univ ↔ ∃ a, a ∉ s := by rw [← not_forall, ← eq_univ_iff_forall] #align set.ne_univ_iff_exists_not_mem Set.ne_univ_iff_exists_not_mem theorem not_subset_iff_exists_mem_not_mem {α : Type*} {s t : Set α} : ¬s ⊆ t ↔ ∃ x, x ∈ s ∧ x ∉ t := by simp [subset_def] #align set.not_subset_iff_exists_mem_not_mem Set.not_subset_iff_exists_mem_not_mem theorem univ_unique [Unique α] : @Set.univ α = {default} := Set.ext fun x => iff_of_true trivial <| Subsingleton.elim x default #align set.univ_unique Set.univ_unique theorem ssubset_univ_iff : s ⊂ univ ↔ s ≠ univ := lt_top_iff_ne_top #align set.ssubset_univ_iff Set.ssubset_univ_iff instance nontrivial_of_nonempty [Nonempty α] : Nontrivial (Set α) := ⟨⟨∅, univ, empty_ne_univ⟩⟩ #align set.nontrivial_of_nonempty Set.nontrivial_of_nonempty theorem union_def {s₁ s₂ : Set α} : s₁ ∪ s₂ = { a | a ∈ s₁ ∨ a ∈ s₂ } := rfl #align set.union_def Set.union_def theorem mem_union_left {x : α} {a : Set α} (b : Set α) : x ∈ a → x ∈ a ∪ b := Or.inl #align set.mem_union_left Set.mem_union_left theorem mem_union_right {x : α} {b : Set α} (a : Set α) : x ∈ b → x ∈ a ∪ b := Or.inr #align set.mem_union_right Set.mem_union_right theorem mem_or_mem_of_mem_union {x : α} {a b : Set α} (H : x ∈ a ∪ b) : x ∈ a ∨ x ∈ b := H #align set.mem_or_mem_of_mem_union Set.mem_or_mem_of_mem_union theorem MemUnion.elim {x : α} {a b : Set α} {P : Prop} (H₁ : x ∈ a ∪ b) (H₂ : x ∈ a → P) (H₃ : x ∈ b → P) : P := Or.elim H₁ H₂ H₃ #align set.mem_union.elim Set.MemUnion.elim @[simp] theorem mem_union (x : α) (a b : Set α) : x ∈ a ∪ b ↔ x ∈ a ∨ x ∈ b := Iff.rfl #align set.mem_union Set.mem_union @[simp] theorem union_self (a : Set α) : a ∪ a = a := ext fun _ => or_self_iff #align set.union_self Set.union_self @[simp] theorem union_empty (a : Set α) : a ∪ ∅ = a := ext fun _ => or_false_iff _ #align set.union_empty Set.union_empty @[simp] theorem empty_union (a : Set α) : ∅ ∪ a = a := ext fun _ => false_or_iff _ #align set.empty_union Set.empty_union theorem union_comm (a b : Set α) : a ∪ b = b ∪ a := ext fun _ => or_comm #align set.union_comm Set.union_comm theorem union_assoc (a b c : Set α) : a ∪ b ∪ c = a ∪ (b ∪ c) := ext fun _ => or_assoc #align set.union_assoc Set.union_assoc instance union_isAssoc : Std.Associative (α := Set α) (· ∪ ·) := ⟨union_assoc⟩ #align set.union_is_assoc Set.union_isAssoc instance union_isComm : Std.Commutative (α := Set α) (· ∪ ·) := ⟨union_comm⟩ #align set.union_is_comm Set.union_isComm theorem union_left_comm (s₁ s₂ s₃ : Set α) : s₁ ∪ (s₂ ∪ s₃) = s₂ ∪ (s₁ ∪ s₃) := ext fun _ => or_left_comm #align set.union_left_comm Set.union_left_comm theorem union_right_comm (s₁ s₂ s₃ : Set α) : s₁ ∪ s₂ ∪ s₃ = s₁ ∪ s₃ ∪ s₂ := ext fun _ => or_right_comm #align set.union_right_comm Set.union_right_comm @[simp] theorem union_eq_left {s t : Set α} : s ∪ t = s ↔ t ⊆ s := sup_eq_left #align set.union_eq_left_iff_subset Set.union_eq_left @[simp] theorem union_eq_right {s t : Set α} : s ∪ t = t ↔ s ⊆ t := sup_eq_right #align set.union_eq_right_iff_subset Set.union_eq_right theorem union_eq_self_of_subset_left {s t : Set α} (h : s ⊆ t) : s ∪ t = t := union_eq_right.mpr h #align set.union_eq_self_of_subset_left Set.union_eq_self_of_subset_left theorem union_eq_self_of_subset_right {s t : Set α} (h : t ⊆ s) : s ∪ t = s := union_eq_left.mpr h #align set.union_eq_self_of_subset_right Set.union_eq_self_of_subset_right @[simp] theorem subset_union_left {s t : Set α} : s ⊆ s ∪ t := fun _ => Or.inl #align set.subset_union_left Set.subset_union_left @[simp] theorem subset_union_right {s t : Set α} : t ⊆ s ∪ t := fun _ => Or.inr #align set.subset_union_right Set.subset_union_right theorem union_subset {s t r : Set α} (sr : s ⊆ r) (tr : t ⊆ r) : s ∪ t ⊆ r := fun _ => Or.rec (@sr _) (@tr _) #align set.union_subset Set.union_subset @[simp] theorem union_subset_iff {s t u : Set α} : s ∪ t ⊆ u ↔ s ⊆ u ∧ t ⊆ u := (forall_congr' fun _ => or_imp).trans forall_and #align set.union_subset_iff Set.union_subset_iff @[gcongr] theorem union_subset_union {s₁ s₂ t₁ t₂ : Set α} (h₁ : s₁ ⊆ s₂) (h₂ : t₁ ⊆ t₂) : s₁ ∪ t₁ ⊆ s₂ ∪ t₂ := fun _ => Or.imp (@h₁ _) (@h₂ _) #align set.union_subset_union Set.union_subset_union @[gcongr] theorem union_subset_union_left {s₁ s₂ : Set α} (t) (h : s₁ ⊆ s₂) : s₁ ∪ t ⊆ s₂ ∪ t := union_subset_union h Subset.rfl #align set.union_subset_union_left Set.union_subset_union_left @[gcongr] theorem union_subset_union_right (s) {t₁ t₂ : Set α} (h : t₁ ⊆ t₂) : s ∪ t₁ ⊆ s ∪ t₂ := union_subset_union Subset.rfl h #align set.union_subset_union_right Set.union_subset_union_right theorem subset_union_of_subset_left {s t : Set α} (h : s ⊆ t) (u : Set α) : s ⊆ t ∪ u := h.trans subset_union_left #align set.subset_union_of_subset_left Set.subset_union_of_subset_left theorem subset_union_of_subset_right {s u : Set α} (h : s ⊆ u) (t : Set α) : s ⊆ t ∪ u := h.trans subset_union_right #align set.subset_union_of_subset_right Set.subset_union_of_subset_right -- Porting note: replaced `⊔` in RHS theorem union_congr_left (ht : t ⊆ s ∪ u) (hu : u ⊆ s ∪ t) : s ∪ t = s ∪ u := sup_congr_left ht hu #align set.union_congr_left Set.union_congr_left theorem union_congr_right (hs : s ⊆ t ∪ u) (ht : t ⊆ s ∪ u) : s ∪ u = t ∪ u := sup_congr_right hs ht #align set.union_congr_right Set.union_congr_right theorem union_eq_union_iff_left : s ∪ t = s ∪ u ↔ t ⊆ s ∪ u ∧ u ⊆ s ∪ t := sup_eq_sup_iff_left #align set.union_eq_union_iff_left Set.union_eq_union_iff_left theorem union_eq_union_iff_right : s ∪ u = t ∪ u ↔ s ⊆ t ∪ u ∧ t ⊆ s ∪ u := sup_eq_sup_iff_right #align set.union_eq_union_iff_right Set.union_eq_union_iff_right @[simp] theorem union_empty_iff {s t : Set α} : s ∪ t = ∅ ↔ s = ∅ ∧ t = ∅ := by simp only [← subset_empty_iff] exact union_subset_iff #align set.union_empty_iff Set.union_empty_iff @[simp] theorem union_univ (s : Set α) : s ∪ univ = univ := sup_top_eq _ #align set.union_univ Set.union_univ @[simp] theorem univ_union (s : Set α) : univ ∪ s = univ := top_sup_eq _ #align set.univ_union Set.univ_union theorem inter_def {s₁ s₂ : Set α} : s₁ ∩ s₂ = { a | a ∈ s₁ ∧ a ∈ s₂ } := rfl #align set.inter_def Set.inter_def @[simp, mfld_simps] theorem mem_inter_iff (x : α) (a b : Set α) : x ∈ a ∩ b ↔ x ∈ a ∧ x ∈ b := Iff.rfl #align set.mem_inter_iff Set.mem_inter_iff theorem mem_inter {x : α} {a b : Set α} (ha : x ∈ a) (hb : x ∈ b) : x ∈ a ∩ b := ⟨ha, hb⟩ #align set.mem_inter Set.mem_inter theorem mem_of_mem_inter_left {x : α} {a b : Set α} (h : x ∈ a ∩ b) : x ∈ a := h.left #align set.mem_of_mem_inter_left Set.mem_of_mem_inter_left theorem mem_of_mem_inter_right {x : α} {a b : Set α} (h : x ∈ a ∩ b) : x ∈ b := h.right #align set.mem_of_mem_inter_right Set.mem_of_mem_inter_right @[simp] theorem inter_self (a : Set α) : a ∩ a = a := ext fun _ => and_self_iff #align set.inter_self Set.inter_self @[simp] theorem inter_empty (a : Set α) : a ∩ ∅ = ∅ := ext fun _ => and_false_iff _ #align set.inter_empty Set.inter_empty @[simp] theorem empty_inter (a : Set α) : ∅ ∩ a = ∅ := ext fun _ => false_and_iff _ #align set.empty_inter Set.empty_inter theorem inter_comm (a b : Set α) : a ∩ b = b ∩ a := ext fun _ => and_comm #align set.inter_comm Set.inter_comm theorem inter_assoc (a b c : Set α) : a ∩ b ∩ c = a ∩ (b ∩ c) := ext fun _ => and_assoc #align set.inter_assoc Set.inter_assoc instance inter_isAssoc : Std.Associative (α := Set α) (· ∩ ·) := ⟨inter_assoc⟩ #align set.inter_is_assoc Set.inter_isAssoc instance inter_isComm : Std.Commutative (α := Set α) (· ∩ ·) := ⟨inter_comm⟩ #align set.inter_is_comm Set.inter_isComm theorem inter_left_comm (s₁ s₂ s₃ : Set α) : s₁ ∩ (s₂ ∩ s₃) = s₂ ∩ (s₁ ∩ s₃) := ext fun _ => and_left_comm #align set.inter_left_comm Set.inter_left_comm theorem inter_right_comm (s₁ s₂ s₃ : Set α) : s₁ ∩ s₂ ∩ s₃ = s₁ ∩ s₃ ∩ s₂ := ext fun _ => and_right_comm #align set.inter_right_comm Set.inter_right_comm @[simp, mfld_simps] theorem inter_subset_left {s t : Set α} : s ∩ t ⊆ s := fun _ => And.left #align set.inter_subset_left Set.inter_subset_left @[simp] theorem inter_subset_right {s t : Set α} : s ∩ t ⊆ t := fun _ => And.right #align set.inter_subset_right Set.inter_subset_right theorem subset_inter {s t r : Set α} (rs : r ⊆ s) (rt : r ⊆ t) : r ⊆ s ∩ t := fun _ h => ⟨rs h, rt h⟩ #align set.subset_inter Set.subset_inter @[simp] theorem subset_inter_iff {s t r : Set α} : r ⊆ s ∩ t ↔ r ⊆ s ∧ r ⊆ t := (forall_congr' fun _ => imp_and).trans forall_and #align set.subset_inter_iff Set.subset_inter_iff @[simp] lemma inter_eq_left : s ∩ t = s ↔ s ⊆ t := inf_eq_left #align set.inter_eq_left_iff_subset Set.inter_eq_left @[simp] lemma inter_eq_right : s ∩ t = t ↔ t ⊆ s := inf_eq_right #align set.inter_eq_right_iff_subset Set.inter_eq_right @[simp] lemma left_eq_inter : s = s ∩ t ↔ s ⊆ t := left_eq_inf @[simp] lemma right_eq_inter : t = s ∩ t ↔ t ⊆ s := right_eq_inf theorem inter_eq_self_of_subset_left {s t : Set α} : s ⊆ t → s ∩ t = s := inter_eq_left.mpr #align set.inter_eq_self_of_subset_left Set.inter_eq_self_of_subset_left theorem inter_eq_self_of_subset_right {s t : Set α} : t ⊆ s → s ∩ t = t := inter_eq_right.mpr #align set.inter_eq_self_of_subset_right Set.inter_eq_self_of_subset_right theorem inter_congr_left (ht : s ∩ u ⊆ t) (hu : s ∩ t ⊆ u) : s ∩ t = s ∩ u := inf_congr_left ht hu #align set.inter_congr_left Set.inter_congr_left theorem inter_congr_right (hs : t ∩ u ⊆ s) (ht : s ∩ u ⊆ t) : s ∩ u = t ∩ u := inf_congr_right hs ht #align set.inter_congr_right Set.inter_congr_right theorem inter_eq_inter_iff_left : s ∩ t = s ∩ u ↔ s ∩ u ⊆ t ∧ s ∩ t ⊆ u := inf_eq_inf_iff_left #align set.inter_eq_inter_iff_left Set.inter_eq_inter_iff_left theorem inter_eq_inter_iff_right : s ∩ u = t ∩ u ↔ t ∩ u ⊆ s ∧ s ∩ u ⊆ t := inf_eq_inf_iff_right #align set.inter_eq_inter_iff_right Set.inter_eq_inter_iff_right @[simp, mfld_simps] theorem inter_univ (a : Set α) : a ∩ univ = a := inf_top_eq _ #align set.inter_univ Set.inter_univ @[simp, mfld_simps] theorem univ_inter (a : Set α) : univ ∩ a = a := top_inf_eq _ #align set.univ_inter Set.univ_inter @[gcongr] theorem inter_subset_inter {s₁ s₂ t₁ t₂ : Set α} (h₁ : s₁ ⊆ t₁) (h₂ : s₂ ⊆ t₂) : s₁ ∩ s₂ ⊆ t₁ ∩ t₂ := fun _ => And.imp (@h₁ _) (@h₂ _) #align set.inter_subset_inter Set.inter_subset_inter @[gcongr] theorem inter_subset_inter_left {s t : Set α} (u : Set α) (H : s ⊆ t) : s ∩ u ⊆ t ∩ u := inter_subset_inter H Subset.rfl #align set.inter_subset_inter_left Set.inter_subset_inter_left @[gcongr] theorem inter_subset_inter_right {s t : Set α} (u : Set α) (H : s ⊆ t) : u ∩ s ⊆ u ∩ t := inter_subset_inter Subset.rfl H #align set.inter_subset_inter_right Set.inter_subset_inter_right theorem union_inter_cancel_left {s t : Set α} : (s ∪ t) ∩ s = s := inter_eq_self_of_subset_right subset_union_left #align set.union_inter_cancel_left Set.union_inter_cancel_left theorem union_inter_cancel_right {s t : Set α} : (s ∪ t) ∩ t = t := inter_eq_self_of_subset_right subset_union_right #align set.union_inter_cancel_right Set.union_inter_cancel_right theorem inter_setOf_eq_sep (s : Set α) (p : α → Prop) : s ∩ {a | p a} = {a ∈ s | p a} := rfl #align set.inter_set_of_eq_sep Set.inter_setOf_eq_sep theorem setOf_inter_eq_sep (p : α → Prop) (s : Set α) : {a | p a} ∩ s = {a ∈ s | p a} := inter_comm _ _ #align set.set_of_inter_eq_sep Set.setOf_inter_eq_sep theorem inter_union_distrib_left (s t u : Set α) : s ∩ (t ∪ u) = s ∩ t ∪ s ∩ u := inf_sup_left _ _ _ #align set.inter_distrib_left Set.inter_union_distrib_left theorem union_inter_distrib_right (s t u : Set α) : (s ∪ t) ∩ u = s ∩ u ∪ t ∩ u := inf_sup_right _ _ _ #align set.inter_distrib_right Set.union_inter_distrib_right theorem union_inter_distrib_left (s t u : Set α) : s ∪ t ∩ u = (s ∪ t) ∩ (s ∪ u) := sup_inf_left _ _ _ #align set.union_distrib_left Set.union_inter_distrib_left theorem inter_union_distrib_right (s t u : Set α) : s ∩ t ∪ u = (s ∪ u) ∩ (t ∪ u) := sup_inf_right _ _ _ #align set.union_distrib_right Set.inter_union_distrib_right -- 2024-03-22 @[deprecated] alias inter_distrib_left := inter_union_distrib_left @[deprecated] alias inter_distrib_right := union_inter_distrib_right @[deprecated] alias union_distrib_left := union_inter_distrib_left @[deprecated] alias union_distrib_right := inter_union_distrib_right theorem union_union_distrib_left (s t u : Set α) : s ∪ (t ∪ u) = s ∪ t ∪ (s ∪ u) := sup_sup_distrib_left _ _ _ #align set.union_union_distrib_left Set.union_union_distrib_left theorem union_union_distrib_right (s t u : Set α) : s ∪ t ∪ u = s ∪ u ∪ (t ∪ u) := sup_sup_distrib_right _ _ _ #align set.union_union_distrib_right Set.union_union_distrib_right theorem inter_inter_distrib_left (s t u : Set α) : s ∩ (t ∩ u) = s ∩ t ∩ (s ∩ u) := inf_inf_distrib_left _ _ _ #align set.inter_inter_distrib_left Set.inter_inter_distrib_left theorem inter_inter_distrib_right (s t u : Set α) : s ∩ t ∩ u = s ∩ u ∩ (t ∩ u) := inf_inf_distrib_right _ _ _ #align set.inter_inter_distrib_right Set.inter_inter_distrib_right theorem union_union_union_comm (s t u v : Set α) : s ∪ t ∪ (u ∪ v) = s ∪ u ∪ (t ∪ v) := sup_sup_sup_comm _ _ _ _ #align set.union_union_union_comm Set.union_union_union_comm theorem inter_inter_inter_comm (s t u v : Set α) : s ∩ t ∩ (u ∩ v) = s ∩ u ∩ (t ∩ v) := inf_inf_inf_comm _ _ _ _ #align set.inter_inter_inter_comm Set.inter_inter_inter_comm theorem insert_def (x : α) (s : Set α) : insert x s = { y | y = x ∨ y ∈ s } := rfl #align set.insert_def Set.insert_def @[simp] theorem subset_insert (x : α) (s : Set α) : s ⊆ insert x s := fun _ => Or.inr #align set.subset_insert Set.subset_insert theorem mem_insert (x : α) (s : Set α) : x ∈ insert x s := Or.inl rfl #align set.mem_insert Set.mem_insert theorem mem_insert_of_mem {x : α} {s : Set α} (y : α) : x ∈ s → x ∈ insert y s := Or.inr #align set.mem_insert_of_mem Set.mem_insert_of_mem theorem eq_or_mem_of_mem_insert {x a : α} {s : Set α} : x ∈ insert a s → x = a ∨ x ∈ s := id #align set.eq_or_mem_of_mem_insert Set.eq_or_mem_of_mem_insert theorem mem_of_mem_insert_of_ne : b ∈ insert a s → b ≠ a → b ∈ s := Or.resolve_left #align set.mem_of_mem_insert_of_ne Set.mem_of_mem_insert_of_ne theorem eq_of_not_mem_of_mem_insert : b ∈ insert a s → b ∉ s → b = a := Or.resolve_right #align set.eq_of_not_mem_of_mem_insert Set.eq_of_not_mem_of_mem_insert @[simp] theorem mem_insert_iff {x a : α} {s : Set α} : x ∈ insert a s ↔ x = a ∨ x ∈ s := Iff.rfl #align set.mem_insert_iff Set.mem_insert_iff @[simp] theorem insert_eq_of_mem {a : α} {s : Set α} (h : a ∈ s) : insert a s = s := ext fun _ => or_iff_right_of_imp fun e => e.symm ▸ h #align set.insert_eq_of_mem Set.insert_eq_of_mem theorem ne_insert_of_not_mem {s : Set α} (t : Set α) {a : α} : a ∉ s → s ≠ insert a t := mt fun e => e.symm ▸ mem_insert _ _ #align set.ne_insert_of_not_mem Set.ne_insert_of_not_mem @[simp] theorem insert_eq_self : insert a s = s ↔ a ∈ s := ⟨fun h => h ▸ mem_insert _ _, insert_eq_of_mem⟩ #align set.insert_eq_self Set.insert_eq_self theorem insert_ne_self : insert a s ≠ s ↔ a ∉ s := insert_eq_self.not #align set.insert_ne_self Set.insert_ne_self theorem insert_subset_iff : insert a s ⊆ t ↔ a ∈ t ∧ s ⊆ t := by simp only [subset_def, mem_insert_iff, or_imp, forall_and, forall_eq] #align set.insert_subset Set.insert_subset_iff theorem insert_subset (ha : a ∈ t) (hs : s ⊆ t) : insert a s ⊆ t := insert_subset_iff.mpr ⟨ha, hs⟩ theorem insert_subset_insert (h : s ⊆ t) : insert a s ⊆ insert a t := fun _ => Or.imp_right (@h _) #align set.insert_subset_insert Set.insert_subset_insert @[simp] theorem insert_subset_insert_iff (ha : a ∉ s) : insert a s ⊆ insert a t ↔ s ⊆ t := by refine ⟨fun h x hx => ?_, insert_subset_insert⟩ rcases h (subset_insert _ _ hx) with (rfl | hxt) exacts [(ha hx).elim, hxt] #align set.insert_subset_insert_iff Set.insert_subset_insert_iff theorem subset_insert_iff_of_not_mem (ha : a ∉ s) : s ⊆ insert a t ↔ s ⊆ t := forall₂_congr fun _ hb => or_iff_right <| ne_of_mem_of_not_mem hb ha #align set.subset_insert_iff_of_not_mem Set.subset_insert_iff_of_not_mem theorem ssubset_iff_insert {s t : Set α} : s ⊂ t ↔ ∃ a ∉ s, insert a s ⊆ t := by simp only [insert_subset_iff, exists_and_right, ssubset_def, not_subset] aesop #align set.ssubset_iff_insert Set.ssubset_iff_insert theorem ssubset_insert {s : Set α} {a : α} (h : a ∉ s) : s ⊂ insert a s := ssubset_iff_insert.2 ⟨a, h, Subset.rfl⟩ #align set.ssubset_insert Set.ssubset_insert theorem insert_comm (a b : α) (s : Set α) : insert a (insert b s) = insert b (insert a s) := ext fun _ => or_left_comm #align set.insert_comm Set.insert_comm -- Porting note (#10618): removing `simp` attribute because `simp` can prove it theorem insert_idem (a : α) (s : Set α) : insert a (insert a s) = insert a s := insert_eq_of_mem <| mem_insert _ _ #align set.insert_idem Set.insert_idem theorem insert_union : insert a s ∪ t = insert a (s ∪ t) := ext fun _ => or_assoc #align set.insert_union Set.insert_union @[simp] theorem union_insert : s ∪ insert a t = insert a (s ∪ t) := ext fun _ => or_left_comm #align set.union_insert Set.union_insert @[simp] theorem insert_nonempty (a : α) (s : Set α) : (insert a s).Nonempty := ⟨a, mem_insert a s⟩ #align set.insert_nonempty Set.insert_nonempty instance (a : α) (s : Set α) : Nonempty (insert a s : Set α) := (insert_nonempty a s).to_subtype theorem insert_inter_distrib (a : α) (s t : Set α) : insert a (s ∩ t) = insert a s ∩ insert a t := ext fun _ => or_and_left #align set.insert_inter_distrib Set.insert_inter_distrib theorem insert_union_distrib (a : α) (s t : Set α) : insert a (s ∪ t) = insert a s ∪ insert a t := ext fun _ => or_or_distrib_left #align set.insert_union_distrib Set.insert_union_distrib theorem insert_inj (ha : a ∉ s) : insert a s = insert b s ↔ a = b := ⟨fun h => eq_of_not_mem_of_mem_insert (h.subst <| mem_insert a s) ha, congr_arg (fun x => insert x s)⟩ #align set.insert_inj Set.insert_inj -- useful in proofs by induction theorem forall_of_forall_insert {P : α → Prop} {a : α} {s : Set α} (H : ∀ x, x ∈ insert a s → P x) (x) (h : x ∈ s) : P x := H _ (Or.inr h) #align set.forall_of_forall_insert Set.forall_of_forall_insert theorem forall_insert_of_forall {P : α → Prop} {a : α} {s : Set α} (H : ∀ x, x ∈ s → P x) (ha : P a) (x) (h : x ∈ insert a s) : P x := h.elim (fun e => e.symm ▸ ha) (H _) #align set.forall_insert_of_forall Set.forall_insert_of_forall theorem exists_mem_insert {P : α → Prop} {a : α} {s : Set α} : (∃ x ∈ insert a s, P x) ↔ (P a ∨ ∃ x ∈ s, P x) := by simp [mem_insert_iff, or_and_right, exists_and_left, exists_or] #align set.bex_insert_iff Set.exists_mem_insert @[deprecated (since := "2024-03-23")] alias bex_insert_iff := exists_mem_insert theorem forall_mem_insert {P : α → Prop} {a : α} {s : Set α} : (∀ x ∈ insert a s, P x) ↔ P a ∧ ∀ x ∈ s, P x := forall₂_or_left.trans <| and_congr_left' forall_eq #align set.ball_insert_iff Set.forall_mem_insert @[deprecated (since := "2024-03-23")] alias ball_insert_iff := forall_mem_insert instance : LawfulSingleton α (Set α) := ⟨fun x => Set.ext fun a => by simp only [mem_empty_iff_false, mem_insert_iff, or_false] exact Iff.rfl⟩ theorem singleton_def (a : α) : ({a} : Set α) = insert a ∅ := (insert_emptyc_eq a).symm #align set.singleton_def Set.singleton_def @[simp] theorem mem_singleton_iff {a b : α} : a ∈ ({b} : Set α) ↔ a = b := Iff.rfl #align set.mem_singleton_iff Set.mem_singleton_iff @[simp] theorem setOf_eq_eq_singleton {a : α} : { n | n = a } = {a} := rfl #align set.set_of_eq_eq_singleton Set.setOf_eq_eq_singleton @[simp] theorem setOf_eq_eq_singleton' {a : α} : { x | a = x } = {a} := ext fun _ => eq_comm #align set.set_of_eq_eq_singleton' Set.setOf_eq_eq_singleton' -- TODO: again, annotation needed --Porting note (#11119): removed `simp` attribute theorem mem_singleton (a : α) : a ∈ ({a} : Set α) := @rfl _ _ #align set.mem_singleton Set.mem_singleton theorem eq_of_mem_singleton {x y : α} (h : x ∈ ({y} : Set α)) : x = y := h #align set.eq_of_mem_singleton Set.eq_of_mem_singleton @[simp] theorem singleton_eq_singleton_iff {x y : α} : {x} = ({y} : Set α) ↔ x = y := ext_iff.trans eq_iff_eq_cancel_left #align set.singleton_eq_singleton_iff Set.singleton_eq_singleton_iff theorem singleton_injective : Injective (singleton : α → Set α) := fun _ _ => singleton_eq_singleton_iff.mp #align set.singleton_injective Set.singleton_injective theorem mem_singleton_of_eq {x y : α} (H : x = y) : x ∈ ({y} : Set α) := H #align set.mem_singleton_of_eq Set.mem_singleton_of_eq theorem insert_eq (x : α) (s : Set α) : insert x s = ({x} : Set α) ∪ s := rfl #align set.insert_eq Set.insert_eq @[simp] theorem singleton_nonempty (a : α) : ({a} : Set α).Nonempty := ⟨a, rfl⟩ #align set.singleton_nonempty Set.singleton_nonempty @[simp] theorem singleton_ne_empty (a : α) : ({a} : Set α) ≠ ∅ := (singleton_nonempty _).ne_empty #align set.singleton_ne_empty Set.singleton_ne_empty --Porting note (#10618): removed `simp` attribute because `simp` can prove it theorem empty_ssubset_singleton : (∅ : Set α) ⊂ {a} := (singleton_nonempty _).empty_ssubset #align set.empty_ssubset_singleton Set.empty_ssubset_singleton @[simp] theorem singleton_subset_iff {a : α} {s : Set α} : {a} ⊆ s ↔ a ∈ s := forall_eq #align set.singleton_subset_iff Set.singleton_subset_iff
Mathlib/Data/Set/Basic.lean
1,292
1,292
theorem singleton_subset_singleton : ({a} : Set α) ⊆ {b} ↔ a = b := by
simp
import Mathlib.Combinatorics.SimpleGraph.Clique open Finset namespace SimpleGraph variable {V : Type*} [Fintype V] [DecidableEq V] (G H : SimpleGraph V) [DecidableRel G.Adj] {n r : ℕ} def IsTuranMaximal (r : ℕ) : Prop := G.CliqueFree (r + 1) ∧ ∀ (H : SimpleGraph V) [DecidableRel H.Adj], H.CliqueFree (r + 1) → H.edgeFinset.card ≤ G.edgeFinset.card variable {G H} lemma IsTuranMaximal.le_iff_eq (hG : G.IsTuranMaximal r) (hH : H.CliqueFree (r + 1)) : G ≤ H ↔ G = H := by classical exact ⟨fun hGH ↦ edgeFinset_inj.1 <| eq_of_subset_of_card_le (edgeFinset_subset_edgeFinset.2 hGH) (hG.2 _ hH), le_of_eq⟩ def turanGraph (n r : ℕ) : SimpleGraph (Fin n) where Adj v w := v % r ≠ w % r instance turanGraph.instDecidableRelAdj : DecidableRel (turanGraph n r).Adj := by dsimp only [turanGraph]; infer_instance @[simp] lemma turanGraph_zero : turanGraph n 0 = ⊤ := by ext a b; simp_rw [turanGraph, top_adj, Nat.mod_zero, not_iff_not, Fin.val_inj] @[simp] theorem turanGraph_eq_top : turanGraph n r = ⊤ ↔ r = 0 ∨ n ≤ r := by simp_rw [SimpleGraph.ext_iff, Function.funext_iff, turanGraph, top_adj, eq_iff_iff, not_iff_not] refine ⟨fun h ↦ ?_, ?_⟩ · contrapose! h use ⟨0, (Nat.pos_of_ne_zero h.1).trans h.2⟩, ⟨r, h.2⟩ simp [h.1.symm] · rintro (rfl | h) a b · simp [Fin.val_inj] · rw [Nat.mod_eq_of_lt (a.2.trans_le h), Nat.mod_eq_of_lt (b.2.trans_le h), Fin.val_inj] variable (hr : 0 < r) theorem turanGraph_cliqueFree : (turanGraph n r).CliqueFree (r + 1) := by rw [cliqueFree_iff] by_contra h rw [not_isEmpty_iff] at h obtain ⟨f, ha⟩ := h simp only [turanGraph, top_adj] at ha obtain ⟨x, y, d, c⟩ := Fintype.exists_ne_map_eq_of_card_lt (fun x ↦ (⟨(f x).1 % r, Nat.mod_lt _ hr⟩ : Fin r)) (by simp) simp only [Fin.mk.injEq] at c exact absurd c ((@ha x y).mpr d) theorem isTuranMaximal_turanGraph (h : n ≤ r) : (turanGraph n r).IsTuranMaximal r := ⟨turanGraph_cliqueFree hr, fun _ _ _ ↦ card_le_card (edgeFinset_mono ((turanGraph_eq_top.mpr (Or.inr h)).symm ▸ le_top))⟩
Mathlib/Combinatorics/SimpleGraph/Turan.lean
84
92
theorem not_cliqueFree_of_isTuranMaximal (hn : r ≤ Fintype.card V) (hG : G.IsTuranMaximal r) : ¬G.CliqueFree r := by
rintro h obtain ⟨K, _, rfl⟩ := exists_smaller_set (univ : Finset V) r hn obtain ⟨a, -, b, -, hab, hGab⟩ : ∃ a ∈ K, ∃ b ∈ K, a ≠ b ∧ ¬ G.Adj a b := by simpa only [isNClique_iff, IsClique, Set.Pairwise, mem_coe, ne_eq, and_true, not_forall, exists_prop, exists_and_right] using h K exact hGab <| le_sup_right.trans_eq ((hG.le_iff_eq <| h.sup_edge _ _).1 le_sup_left).symm <| (edge_adj ..).2 ⟨Or.inl ⟨rfl, rfl⟩, hab⟩
import Mathlib.Analysis.Calculus.Deriv.Mul import Mathlib.Analysis.Calculus.Deriv.Comp #align_import analysis.calculus.deriv.inv from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" universe u v w open scoped Classical open Topology Filter ENNReal open Filter Asymptotics Set open ContinuousLinearMap (smulRight smulRight_one_eq_iff) variable {𝕜 : Type u} [NontriviallyNormedField 𝕜] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {f f₀ f₁ g : 𝕜 → F} variable {f' f₀' f₁' g' : F} variable {x : 𝕜} variable {s t : Set 𝕜} variable {L : Filter 𝕜} section Inverse theorem hasStrictDerivAt_inv (hx : x ≠ 0) : HasStrictDerivAt Inv.inv (-(x ^ 2)⁻¹) x := by suffices (fun p : 𝕜 × 𝕜 => (p.1 - p.2) * ((x * x)⁻¹ - (p.1 * p.2)⁻¹)) =o[𝓝 (x, x)] fun p => (p.1 - p.2) * 1 by refine this.congr' ?_ (eventually_of_forall fun _ => mul_one _) refine Eventually.mono ((isOpen_ne.prod isOpen_ne).mem_nhds ⟨hx, hx⟩) ?_ rintro ⟨y, z⟩ ⟨hy, hz⟩ simp only [mem_setOf_eq] at hy hz -- hy : y ≠ 0, hz : z ≠ 0 field_simp [hx, hy, hz] ring refine (isBigO_refl (fun p : 𝕜 × 𝕜 => p.1 - p.2) _).mul_isLittleO ((isLittleO_one_iff 𝕜).2 ?_) rw [← sub_self (x * x)⁻¹] exact tendsto_const_nhds.sub ((continuous_mul.tendsto (x, x)).inv₀ <| mul_ne_zero hx hx) #align has_strict_deriv_at_inv hasStrictDerivAt_inv theorem hasDerivAt_inv (x_ne_zero : x ≠ 0) : HasDerivAt (fun y => y⁻¹) (-(x ^ 2)⁻¹) x := (hasStrictDerivAt_inv x_ne_zero).hasDerivAt #align has_deriv_at_inv hasDerivAt_inv theorem hasDerivWithinAt_inv (x_ne_zero : x ≠ 0) (s : Set 𝕜) : HasDerivWithinAt (fun x => x⁻¹) (-(x ^ 2)⁻¹) s x := (hasDerivAt_inv x_ne_zero).hasDerivWithinAt #align has_deriv_within_at_inv hasDerivWithinAt_inv theorem differentiableAt_inv : DifferentiableAt 𝕜 (fun x => x⁻¹) x ↔ x ≠ 0 := ⟨fun H => NormedField.continuousAt_inv.1 H.continuousAt, fun H => (hasDerivAt_inv H).differentiableAt⟩ #align differentiable_at_inv differentiableAt_inv theorem differentiableWithinAt_inv (x_ne_zero : x ≠ 0) : DifferentiableWithinAt 𝕜 (fun x => x⁻¹) s x := (differentiableAt_inv.2 x_ne_zero).differentiableWithinAt #align differentiable_within_at_inv differentiableWithinAt_inv theorem differentiableOn_inv : DifferentiableOn 𝕜 (fun x : 𝕜 => x⁻¹) { x | x ≠ 0 } := fun _x hx => differentiableWithinAt_inv hx #align differentiable_on_inv differentiableOn_inv theorem deriv_inv : deriv (fun x => x⁻¹) x = -(x ^ 2)⁻¹ := by rcases eq_or_ne x 0 with (rfl | hne) · simp [deriv_zero_of_not_differentiableAt (mt differentiableAt_inv.1 (not_not.2 rfl))] · exact (hasDerivAt_inv hne).deriv #align deriv_inv deriv_inv @[simp] theorem deriv_inv' : (deriv fun x : 𝕜 => x⁻¹) = fun x => -(x ^ 2)⁻¹ := funext fun _ => deriv_inv #align deriv_inv' deriv_inv'
Mathlib/Analysis/Calculus/Deriv/Inv.lean
98
101
theorem derivWithin_inv (x_ne_zero : x ≠ 0) (hxs : UniqueDiffWithinAt 𝕜 s x) : derivWithin (fun x => x⁻¹) s x = -(x ^ 2)⁻¹ := by
rw [DifferentiableAt.derivWithin (differentiableAt_inv.2 x_ne_zero) hxs] exact deriv_inv
import Mathlib.FieldTheory.Normal import Mathlib.FieldTheory.Perfect import Mathlib.RingTheory.Localization.Integral #align_import field_theory.is_alg_closed.basic from "leanprover-community/mathlib"@"00f91228655eecdcd3ac97a7fd8dbcb139fe990a" universe u v w open scoped Classical Polynomial open Polynomial variable (k : Type u) [Field k] class IsAlgClosed : Prop where splits : ∀ p : k[X], p.Splits <| RingHom.id k #align is_alg_closed IsAlgClosed
Mathlib/FieldTheory/IsAlgClosed/Basic.lean
68
69
theorem IsAlgClosed.splits_codomain {k K : Type*} [Field k] [IsAlgClosed k] [Field K] {f : K →+* k} (p : K[X]) : p.Splits f := by
convert IsAlgClosed.splits (p.map f); simp [splits_map_iff]
import Mathlib.Data.Finset.Sort import Mathlib.Data.List.FinRange import Mathlib.Data.Prod.Lex import Mathlib.GroupTheory.Perm.Basic import Mathlib.Order.Interval.Finset.Fin #align_import data.fin.tuple.sort from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" namespace Tuple variable {n : ℕ} variable {α : Type*} [LinearOrder α] def graph (f : Fin n → α) : Finset (α ×ₗ Fin n) := Finset.univ.image fun i => (f i, i) #align tuple.graph Tuple.graph def graph.proj {f : Fin n → α} : graph f → α := fun p => p.1.1 #align tuple.graph.proj Tuple.graph.proj @[simp]
Mathlib/Data/Fin/Tuple/Sort.lean
50
57
theorem graph.card (f : Fin n → α) : (graph f).card = n := by
rw [graph, Finset.card_image_of_injective] · exact Finset.card_fin _ · intro _ _ -- porting note (#10745): was `simp` dsimp only rw [Prod.ext_iff] simp
import Mathlib.Analysis.NormedSpace.Multilinear.Basic import Mathlib.Analysis.NormedSpace.Units import Mathlib.Analysis.NormedSpace.OperatorNorm.Completeness import Mathlib.Analysis.NormedSpace.OperatorNorm.Mul #align_import analysis.normed_space.bounded_linear_maps from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a" noncomputable section open Topology open Filter (Tendsto) open Metric ContinuousLinearMap variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] structure IsBoundedLinearMap (𝕜 : Type*) [NormedField 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] (f : E → F) extends IsLinearMap 𝕜 f : Prop where bound : ∃ M, 0 < M ∧ ∀ x : E, ‖f x‖ ≤ M * ‖x‖ #align is_bounded_linear_map IsBoundedLinearMap theorem IsLinearMap.with_bound {f : E → F} (hf : IsLinearMap 𝕜 f) (M : ℝ) (h : ∀ x : E, ‖f x‖ ≤ M * ‖x‖) : IsBoundedLinearMap 𝕜 f := ⟨hf, by_cases (fun (this : M ≤ 0) => ⟨1, zero_lt_one, fun x => (h x).trans <| mul_le_mul_of_nonneg_right (this.trans zero_le_one) (norm_nonneg x)⟩) fun (this : ¬M ≤ 0) => ⟨M, lt_of_not_ge this, h⟩⟩ #align is_linear_map.with_bound IsLinearMap.with_bound theorem ContinuousLinearMap.isBoundedLinearMap (f : E →L[𝕜] F) : IsBoundedLinearMap 𝕜 f := { f.toLinearMap.isLinear with bound := f.bound } #align continuous_linear_map.is_bounded_linear_map ContinuousLinearMap.isBoundedLinearMap namespace IsBoundedLinearMap def toLinearMap (f : E → F) (h : IsBoundedLinearMap 𝕜 f) : E →ₗ[𝕜] F := IsLinearMap.mk' _ h.toIsLinearMap #align is_bounded_linear_map.to_linear_map IsBoundedLinearMap.toLinearMap def toContinuousLinearMap {f : E → F} (hf : IsBoundedLinearMap 𝕜 f) : E →L[𝕜] F := { toLinearMap f hf with cont := let ⟨C, _, hC⟩ := hf.bound AddMonoidHomClass.continuous_of_bound (toLinearMap f hf) C hC } #align is_bounded_linear_map.to_continuous_linear_map IsBoundedLinearMap.toContinuousLinearMap theorem zero : IsBoundedLinearMap 𝕜 fun _ : E => (0 : F) := (0 : E →ₗ[𝕜] F).isLinear.with_bound 0 <| by simp [le_refl] #align is_bounded_linear_map.zero IsBoundedLinearMap.zero theorem id : IsBoundedLinearMap 𝕜 fun x : E => x := LinearMap.id.isLinear.with_bound 1 <| by simp [le_refl] #align is_bounded_linear_map.id IsBoundedLinearMap.id theorem fst : IsBoundedLinearMap 𝕜 fun x : E × F => x.1 := by refine (LinearMap.fst 𝕜 E F).isLinear.with_bound 1 fun x => ?_ rw [one_mul] exact le_max_left _ _ #align is_bounded_linear_map.fst IsBoundedLinearMap.fst
Mathlib/Analysis/NormedSpace/BoundedLinearMaps.lean
121
124
theorem snd : IsBoundedLinearMap 𝕜 fun x : E × F => x.2 := by
refine (LinearMap.snd 𝕜 E F).isLinear.with_bound 1 fun x => ?_ rw [one_mul] exact le_max_right _ _
import Mathlib.Algebra.Category.ModuleCat.Abelian import Mathlib.CategoryTheory.Limits.Shapes.Images #align_import algebra.category.Module.images from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" open CategoryTheory open CategoryTheory.Limits universe u v namespace ModuleCat set_option linter.uppercaseLean3 false -- `Module` variable {R : Type u} [Ring R] variable {G H : ModuleCat.{v} R} (f : G ⟶ H) attribute [local ext] Subtype.ext_val section -- implementation details of `HasImage` for ModuleCat; use the API, not these def image : ModuleCat R := ModuleCat.of R (LinearMap.range f) #align Module.image ModuleCat.image def image.ι : image f ⟶ H := f.range.subtype #align Module.image.ι ModuleCat.image.ι instance : Mono (image.ι f) := ConcreteCategory.mono_of_injective (image.ι f) Subtype.val_injective def factorThruImage : G ⟶ image f := f.rangeRestrict #align Module.factor_thru_image ModuleCat.factorThruImage theorem image.fac : factorThruImage f ≫ image.ι f = f := rfl #align Module.image.fac ModuleCat.image.fac attribute [local simp] image.fac variable {f} noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I) map_add' x y := by apply (mono_iff_injective F'.m).1 · infer_instance rw [LinearMap.map_add] change (F'.e ≫ F'.m) _ = (F'.e ≫ F'.m) _ + (F'.e ≫ F'.m) _ simp_rw [F'.fac, (Classical.indefiniteDescription (fun z => f z = _) _).2] rfl map_smul' c x := by apply (mono_iff_injective F'.m).1 · infer_instance rw [LinearMap.map_smul] change (F'.e ≫ F'.m) _ = _ • (F'.e ≫ F'.m) _ simp_rw [F'.fac, (Classical.indefiniteDescription (fun z => f z = _) _).2] rfl #align Module.image.lift ModuleCat.image.lift theorem image.lift_fac (F' : MonoFactorisation f) : image.lift F' ≫ F'.m = image.ι f := by ext x change (F'.e ≫ F'.m) _ = _ rw [F'.fac, (Classical.indefiniteDescription _ x.2).2] rfl #align Module.image.lift_fac ModuleCat.image.lift_fac end def monoFactorisation : MonoFactorisation f where I := image f m := image.ι f e := factorThruImage f #align Module.mono_factorisation ModuleCat.monoFactorisation noncomputable def isImage : IsImage (monoFactorisation f) where lift := image.lift lift_fac := image.lift_fac #align Module.is_image ModuleCat.isImage noncomputable def imageIsoRange {G H : ModuleCat.{v} R} (f : G ⟶ H) : Limits.image f ≅ ModuleCat.of R (LinearMap.range f) := IsImage.isoExt (Image.isImage f) (isImage f) #align Module.image_iso_range ModuleCat.imageIsoRange @[simp, reassoc, elementwise] theorem imageIsoRange_inv_image_ι {G H : ModuleCat.{v} R} (f : G ⟶ H) : (imageIsoRange f).inv ≫ Limits.image.ι f = ModuleCat.ofHom f.range.subtype := IsImage.isoExt_inv_m _ _ #align Module.image_iso_range_inv_image_ι ModuleCat.imageIsoRange_inv_image_ι @[simp, reassoc, elementwise]
Mathlib/Algebra/Category/ModuleCat/Images.lean
117
119
theorem imageIsoRange_hom_subtype {G H : ModuleCat.{v} R} (f : G ⟶ H) : (imageIsoRange f).hom ≫ ModuleCat.ofHom f.range.subtype = Limits.image.ι f := by
erw [← imageIsoRange_inv_image_ι f, Iso.hom_inv_id_assoc]
import Mathlib.CategoryTheory.Galois.Basic import Mathlib.RepresentationTheory.Action.Basic import Mathlib.RepresentationTheory.Action.Concrete import Mathlib.RepresentationTheory.Action.Limits import Mathlib.CategoryTheory.Limits.FintypeCat import Mathlib.CategoryTheory.Limits.Shapes.Types import Mathlib.Logic.Equiv.TransferInstance universe u v w namespace CategoryTheory namespace FintypeCat open Limits Functor PreGaloisCategory noncomputable def imageComplement {X Y : FintypeCat.{u}} (f : X ⟶ Y) : FintypeCat.{u} := by haveI : Fintype (↑(Set.range f)ᶜ) := Fintype.ofFinite _ exact FintypeCat.of (↑(Set.range f)ᶜ) def imageComplementIncl {X Y : FintypeCat.{u}} (f : X ⟶ Y) : imageComplement f ⟶ Y := Subtype.val variable (G : Type u) [Group G] noncomputable def Action.imageComplement {X Y : Action FintypeCat (MonCat.of G)} (f : X ⟶ Y) : Action FintypeCat (MonCat.of G) where V := FintypeCat.imageComplement f.hom ρ := MonCat.ofHom <| { toFun := fun g y ↦ Subtype.mk (Y.ρ g y.val) <| by intro ⟨x, h⟩ apply y.property use X.ρ g⁻¹ x calc (X.ρ g⁻¹ ≫ f.hom) x = (Y.ρ g⁻¹ * Y.ρ g) y.val := by rw [f.comm, FintypeCat.comp_apply, h]; rfl _ = y.val := by rw [← map_mul, mul_left_inv, Action.ρ_one, FintypeCat.id_apply] map_one' := by simp only [Action.ρ_one]; rfl map_mul' := fun g h ↦ FintypeCat.hom_ext _ _ <| fun y ↦ Subtype.ext <| by exact congrFun (MonoidHom.map_mul Y.ρ g h) y.val } def Action.imageComplementIncl {X Y : Action FintypeCat (MonCat.of G)} (f : X ⟶ Y) : Action.imageComplement G f ⟶ Y where hom := FintypeCat.imageComplementIncl f.hom comm _ := rfl instance {X Y : Action FintypeCat (MonCat.of G)} (f : X ⟶ Y) : Mono (Action.imageComplementIncl G f) := by apply Functor.mono_of_mono_map (forget _) apply ConcreteCategory.mono_of_injective exact Subtype.val_injective instance [Finite G] : HasColimitsOfShape (SingleObj G) FintypeCat.{w} := by obtain ⟨G', hg, hf, ⟨e⟩⟩ := Finite.exists_type_zero_nonempty_mulEquiv G exact Limits.hasColimitsOfShape_of_equivalence e.toSingleObjEquiv.symm noncomputable instance : PreservesFiniteLimits (forget (Action FintypeCat (MonCat.of G))) := by show PreservesFiniteLimits (Action.forget FintypeCat _ ⋙ FintypeCat.incl) apply compPreservesFiniteLimits instance : PreGaloisCategory (Action FintypeCat (MonCat.of G)) where hasQuotientsByFiniteGroups G _ _ := inferInstance monoInducesIsoOnDirectSummand {X Y} i h := ⟨Action.imageComplement G i, Action.imageComplementIncl G i, ⟨isColimitOfReflects (Action.forget _ _ ⋙ FintypeCat.incl) <| (isColimitMapCoconeBinaryCofanEquiv (forget _) i _).symm (Types.isCoprodOfMono ((forget _).map i))⟩⟩ noncomputable instance : FiberFunctor (Action.forget FintypeCat (MonCat.of G)) where preservesFiniteCoproducts := ⟨fun _ _ ↦ inferInstance⟩ preservesQuotientsByFiniteGroups _ _ _ := inferInstance reflectsIsos := ⟨fun f (h : IsIso f.hom) => inferInstance⟩ instance : GaloisCategory (Action FintypeCat (MonCat.of G)) where hasFiberFunctor := ⟨Action.forget FintypeCat (MonCat.of G), ⟨inferInstance⟩⟩ theorem Action.pretransitive_of_isConnected (X : Action FintypeCat (MonCat.of G)) [IsConnected X] : MulAction.IsPretransitive G X.V where exists_smul_eq x y := by let T : Set X.V := MulAction.orbit G x have : Fintype T := Fintype.ofFinite T letI : MulAction G (FintypeCat.of T) := inferInstanceAs <| MulAction G ↑(MulAction.orbit G x) let T' : Action FintypeCat (MonCat.of G) := Action.FintypeCat.ofMulAction G (FintypeCat.of T) let i : T' ⟶ X := ⟨Subtype.val, fun _ ↦ rfl⟩ have : Mono i := ConcreteCategory.mono_of_injective _ (Subtype.val_injective) have : IsIso i := by apply IsConnected.noTrivialComponent T' i apply (not_initial_iff_fiber_nonempty (Action.forget _ _) T').mpr exact Set.Nonempty.coe_sort (MulAction.orbit_nonempty x) have hb : Function.Bijective i.hom := by apply (ConcreteCategory.isIso_iff_bijective i.hom).mp exact map_isIso (forget₂ _ FintypeCat) i obtain ⟨⟨y', ⟨g, (hg : g • x = y')⟩⟩, (hy' : y' = y)⟩ := hb.surjective y use g exact hg.trans hy'
Mathlib/CategoryTheory/Galois/Examples.lean
127
145
theorem Action.isConnected_of_transitive (X : FintypeCat) [MulAction G X] [MulAction.IsPretransitive G X] [h : Nonempty X] : IsConnected (Action.FintypeCat.ofMulAction G X) where notInitial := not_initial_of_inhabited (Action.forget _ _) h.some noTrivialComponent Y i hm hni := by
/- We show that the induced inclusion `i.hom` of finite sets is surjective, using the transitivity of the `G`-action. -/ obtain ⟨(y : Y.V)⟩ := (not_initial_iff_fiber_nonempty (Action.forget _ _) Y).mp hni have : IsIso i.hom := by refine (ConcreteCategory.isIso_iff_bijective i.hom).mpr ⟨?_, fun x' ↦ ?_⟩ · haveI : Mono i.hom := map_mono (forget₂ _ _) i exact ConcreteCategory.injective_of_mono_of_preservesPullback i.hom · letI x : X := i.hom y obtain ⟨σ, hσ⟩ := MulAction.exists_smul_eq G x x' use σ • y show (Y.ρ σ ≫ i.hom) y = x' rw [i.comm, FintypeCat.comp_apply] exact hσ apply isIso_of_reflects_iso i (Action.forget _ _)
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
Mathlib/GroupTheory/Perm/List.lean
95
97
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
import Mathlib.CategoryTheory.Sites.Sheaf #align_import category_theory.sites.canonical from "leanprover-community/mathlib"@"9e7c80f638149bfb3504ba8ff48dfdbfc949fb1a" universe v u namespace CategoryTheory open scoped Classical open CategoryTheory Category Limits Sieve variable {C : Type u} [Category.{v} C] namespace Sheaf variable {P : Cᵒᵖ ⥤ Type v} variable {X Y : C} {S : Sieve X} {R : Presieve X} variable (J J₂ : GrothendieckTopology C) theorem isSheafFor_bind (P : Cᵒᵖ ⥤ Type v) (U : Sieve X) (B : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄, U f → Sieve Y) (hU : Presieve.IsSheafFor P (U : Presieve X)) (hB : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), Presieve.IsSheafFor P (B hf : Presieve Y)) (hB' : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (h : U f) ⦃Z⦄ (g : Z ⟶ Y), Presieve.IsSeparatedFor P (((B h).pullback g) : Presieve Z)) : Presieve.IsSheafFor P (Sieve.bind (U : Presieve X) B : Presieve X) := by intro s hs let y : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), Presieve.FamilyOfElements P (B hf : Presieve Y) := fun Y f hf Z g hg => s _ (Presieve.bind_comp _ _ hg) have hy : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), (y hf).Compatible := by intro Y f H Y₁ Y₂ Z g₁ g₂ f₁ f₂ hf₁ hf₂ comm apply hs apply reassoc_of% comm let t : Presieve.FamilyOfElements P (U : Presieve X) := fun Y f hf => (hB hf).amalgamate (y hf) (hy hf) have ht : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), (y hf).IsAmalgamation (t f hf) := fun Y f hf => (hB hf).isAmalgamation _ have hT : t.Compatible := by rw [Presieve.compatible_iff_sieveCompatible] intro Z W f h hf apply (hB (U.downward_closed hf h)).isSeparatedFor.ext intro Y l hl apply (hB' hf (l ≫ h)).ext intro M m hm have : bind U B (m ≫ l ≫ h ≫ f) := by -- Porting note: had to make explicit the parameter `((m ≫ l ≫ h) ≫ f)` and -- using `by exact` have : bind U B ((m ≫ l ≫ h) ≫ f) := by exact Presieve.bind_comp f hf hm simpa using this trans s (m ≫ l ≫ h ≫ f) this · have := ht (U.downward_closed hf h) _ ((B _).downward_closed hl m) rw [op_comp, FunctorToTypes.map_comp_apply] at this rw [this] change s _ _ = s _ _ -- Porting note: the proof was `by simp` congr 1 simp only [assoc] · have h : s _ _ = _ := (ht hf _ hm).symm -- Porting note: this was done by `simp only [assoc] at` conv_lhs at h => congr; rw [assoc, assoc] rw [h] simp only [op_comp, assoc, FunctorToTypes.map_comp_apply] refine ⟨hU.amalgamate t hT, ?_, ?_⟩ · rintro Z _ ⟨Y, f, g, hg, hf, rfl⟩ rw [op_comp, FunctorToTypes.map_comp_apply, Presieve.IsSheafFor.valid_glue _ _ _ hg] apply ht hg _ hf · intro y hy apply hU.isSeparatedFor.ext intro Y f hf apply (hB hf).isSeparatedFor.ext intro Z g hg rw [← FunctorToTypes.map_comp_apply, ← op_comp, hy _ (Presieve.bind_comp _ _ hg), hU.valid_glue _ _ hf, ht hf _ hg] #align category_theory.sheaf.is_sheaf_for_bind CategoryTheory.Sheaf.isSheafFor_bind theorem isSheafFor_trans (P : Cᵒᵖ ⥤ Type v) (R S : Sieve X) (hR : Presieve.IsSheafFor P (R : Presieve X)) (hR' : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (_ : S f), Presieve.IsSeparatedFor P (R.pullback f : Presieve Y)) (hS : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (_ : R f), Presieve.IsSheafFor P (S.pullback f : Presieve Y)) : Presieve.IsSheafFor P (S : Presieve X) := by have : (bind R fun Y f _ => S.pullback f : Presieve X) ≤ S := by rintro Z f ⟨W, f, g, hg, hf : S _, rfl⟩ apply hf apply Presieve.isSheafFor_subsieve_aux P this · apply isSheafFor_bind _ _ _ hR hS intro Y f hf Z g rw [← pullback_comp] apply (hS (R.downward_closed hf _)).isSeparatedFor · intro Y f hf have : Sieve.pullback f (bind R fun T (k : T ⟶ X) (_ : R k) => pullback k S) = R.pullback f := by ext Z g constructor · rintro ⟨W, k, l, hl, _, comm⟩ rw [pullback_apply, ← comm] simp [hl] · intro a refine ⟨Z, 𝟙 Z, _, a, ?_⟩ simp [hf] rw [this] apply hR' hf #align category_theory.sheaf.is_sheaf_for_trans CategoryTheory.Sheaf.isSheafFor_trans def finestTopologySingle (P : Cᵒᵖ ⥤ Type v) : GrothendieckTopology C where sieves X S := ∀ (Y) (f : Y ⟶ X), Presieve.IsSheafFor P (S.pullback f : Presieve Y) top_mem' X Y f := by rw [Sieve.pullback_top] exact Presieve.isSheafFor_top_sieve P pullback_stable' X Y S f hS Z g := by rw [← pullback_comp] apply hS transitive' X S hS R hR Z g := by -- This is the hard part of the construction, showing that the given set of sieves satisfies -- the transitivity axiom. refine isSheafFor_trans P (pullback g S) _ (hS Z g) ?_ ?_ · intro Y f _ rw [← pullback_comp] apply (hS _ _).isSeparatedFor · intro Y f hf have := hR hf _ (𝟙 _) rw [pullback_id, pullback_comp] at this apply this #align category_theory.sheaf.finest_topology_single CategoryTheory.Sheaf.finestTopologySingle def finestTopology (Ps : Set (Cᵒᵖ ⥤ Type v)) : GrothendieckTopology C := sInf (finestTopologySingle '' Ps) #align category_theory.sheaf.finest_topology CategoryTheory.Sheaf.finestTopology theorem sheaf_for_finestTopology (Ps : Set (Cᵒᵖ ⥤ Type v)) (h : P ∈ Ps) : Presieve.IsSheaf (finestTopology Ps) P := fun X S hS => by simpa using hS _ ⟨⟨_, _, ⟨_, h, rfl⟩, rfl⟩, rfl⟩ _ (𝟙 _) #align category_theory.sheaf.sheaf_for_finest_topology CategoryTheory.Sheaf.sheaf_for_finestTopology
Mathlib/CategoryTheory/Sites/Canonical.lean
197
202
theorem le_finestTopology (Ps : Set (Cᵒᵖ ⥤ Type v)) (J : GrothendieckTopology C) (hJ : ∀ P ∈ Ps, Presieve.IsSheaf J P) : J ≤ finestTopology Ps := by
rintro X S hS _ ⟨⟨_, _, ⟨P, hP, rfl⟩, rfl⟩, rfl⟩ intro Y f -- this can't be combined with the previous because the `subst` is applied at the end exact hJ P hP (S.pullback f) (J.pullback_stable f hS)
import Mathlib.Data.Complex.Basic import Mathlib.Data.Real.Cardinality #align_import data.complex.cardinality from "leanprover-community/mathlib"@"1c4e18434eeb5546b212e830b2b39de6a83c473c" -- Porting note: the lemmas `mk_complex` and `mk_univ_complex` should be in the namespace `Cardinal` -- like their real counterparts. open Cardinal Set open Cardinal @[simp] theorem mk_complex : #ℂ = 𝔠 := by rw [mk_congr Complex.equivRealProd, mk_prod, lift_id, mk_real, continuum_mul_self] #align mk_complex mk_complex -- @[simp] -- Porting note (#10618): simp can prove this
Mathlib/Data/Complex/Cardinality.lean
31
31
theorem mk_univ_complex : #(Set.univ : Set ℂ) = 𝔠 := by
rw [mk_univ, mk_complex]
import Mathlib.CategoryTheory.Adjunction.Basic open CategoryTheory variable {C D : Type*} [Category C] [Category D] namespace CategoryTheory.Adjunction @[simps] def natTransEquiv {F F' : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') : (G ⟶ G') ≃ (F' ⟶ F) where toFun f := { app := fun X ↦ F'.map ((adj1.unit ≫ whiskerLeft F f).app X) ≫ adj2.counit.app _ naturality := by intro X Y g simp only [← Category.assoc, ← Functor.map_comp] erw [(adj1.unit ≫ (whiskerLeft F f)).naturality] simp } invFun f := { app := fun X ↦ adj2.unit.app (G.obj X) ≫ G'.map (f.app (G.obj X) ≫ adj1.counit.app X) naturality := by intro X Y g erw [← adj2.unit_naturality_assoc] simp only [← Functor.map_comp] simp } left_inv f := by ext X simp only [Functor.comp_obj, NatTrans.comp_app, Functor.id_obj, whiskerLeft_app, Functor.map_comp, Category.assoc, unit_naturality_assoc, right_triangle_components_assoc] erw [← f.naturality (adj1.counit.app X), ← Category.assoc] simp right_inv f := by ext simp @[simp] lemma natTransEquiv_id {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) : natTransEquiv adj adj (𝟙 _) = 𝟙 _ := by ext; simp @[simp] lemma natTransEquiv_id_symm {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) : (natTransEquiv adj adj).symm (𝟙 _) = 𝟙 _ := by ext; simp @[simp] lemma natTransEquiv_comp {F F' F'' : C ⥤ D} {G G' G'' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') (adj3 : F'' ⊣ G'') (f : G ⟶ G') (g : G' ⟶ G'') : natTransEquiv adj2 adj3 g ≫ natTransEquiv adj1 adj2 f = natTransEquiv adj1 adj3 (f ≫ g) := by apply (natTransEquiv adj1 adj3).symm.injective ext X simp only [natTransEquiv_symm_apply_app, Functor.comp_obj, NatTrans.comp_app, natTransEquiv_apply_app, Functor.id_obj, whiskerLeft_app, Functor.map_comp, Category.assoc, unit_naturality_assoc, right_triangle_components_assoc, Equiv.symm_apply_apply, ← g.naturality_assoc, ← g.naturality] simp only [← Category.assoc, unit_naturality, Functor.comp_obj, right_triangle_components, Category.comp_id, ← f.naturality, Category.id_comp] @[simp] lemma natTransEquiv_comp_symm {F F' F'' : C ⥤ D} {G G' G'' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') (adj3 : F'' ⊣ G'') (f : F' ⟶ F) (g : F'' ⟶ F') : (natTransEquiv adj1 adj2).symm f ≫ (natTransEquiv adj2 adj3).symm g = (natTransEquiv adj1 adj3).symm (g ≫ f) := by apply (natTransEquiv adj1 adj3).injective ext simp @[simps] def natIsoEquiv {F F' : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') : (G ≅ G') ≃ (F' ≅ F) where toFun i := { hom := natTransEquiv adj1 adj2 i.hom inv := natTransEquiv adj2 adj1 i.inv } invFun i := { hom := (natTransEquiv adj1 adj2).symm i.hom inv := (natTransEquiv adj2 adj1).symm i.inv } left_inv i := by simp right_inv i := by simp def leftAdjointUniq {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) : F ≅ F' := (natIsoEquiv adj1 adj2 (Iso.refl _)).symm #align category_theory.adjunction.left_adjoint_uniq CategoryTheory.Adjunction.leftAdjointUniq -- Porting note (#10618): removed simp as simp can prove this theorem homEquiv_leftAdjointUniq_hom_app {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) : adj1.homEquiv _ _ ((leftAdjointUniq adj1 adj2).hom.app x) = adj2.unit.app x := by simp [leftAdjointUniq] #align category_theory.adjunction.hom_equiv_left_adjoint_uniq_hom_app CategoryTheory.Adjunction.homEquiv_leftAdjointUniq_hom_app @[reassoc (attr := simp)]
Mathlib/CategoryTheory/Adjunction/Unique.lean
123
127
theorem unit_leftAdjointUniq_hom {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) : adj1.unit ≫ whiskerRight (leftAdjointUniq adj1 adj2).hom G = adj2.unit := by
ext x rw [NatTrans.comp_app, ← homEquiv_leftAdjointUniq_hom_app adj1 adj2] simp [← G.map_comp]
import Mathlib.Algebra.GroupWithZero.Divisibility import Mathlib.Algebra.Order.Group.Int import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Algebra.Ring.Rat import Mathlib.Data.PNat.Defs #align_import data.rat.lemmas from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11" namespace Rat open Rat theorem num_dvd (a) {b : ℤ} (b0 : b ≠ 0) : (a /. b).num ∣ a := by cases' e : a /. b with n d h c rw [Rat.mk'_eq_divInt, divInt_eq_iff b0 (mod_cast h)] at e refine Int.natAbs_dvd.1 <| Int.dvd_natAbs.1 <| Int.natCast_dvd_natCast.2 <| c.dvd_of_dvd_mul_right ?_ have := congr_arg Int.natAbs e simp only [Int.natAbs_mul, Int.natAbs_ofNat] at this; simp [this] #align rat.num_dvd Rat.num_dvd theorem den_dvd (a b : ℤ) : ((a /. b).den : ℤ) ∣ b := by by_cases b0 : b = 0; · simp [b0] cases' e : a /. b with n d h c rw [mk'_eq_divInt, divInt_eq_iff b0 (ne_of_gt (Int.natCast_pos.2 (Nat.pos_of_ne_zero h)))] at e refine Int.dvd_natAbs.1 <| Int.natCast_dvd_natCast.2 <| c.symm.dvd_of_dvd_mul_left ?_ rw [← Int.natAbs_mul, ← Int.natCast_dvd_natCast, Int.dvd_natAbs, ← e]; simp #align rat.denom_dvd Rat.den_dvd theorem num_den_mk {q : ℚ} {n d : ℤ} (hd : d ≠ 0) (qdf : q = n /. d) : ∃ c : ℤ, n = c * q.num ∧ d = c * q.den := by obtain rfl | hn := eq_or_ne n 0 · simp [qdf] have : q.num * d = n * ↑q.den := by refine (divInt_eq_iff ?_ hd).mp ?_ · exact Int.natCast_ne_zero.mpr (Rat.den_nz _) · rwa [num_divInt_den] have hqdn : q.num ∣ n := by rw [qdf] exact Rat.num_dvd _ hd refine ⟨n / q.num, ?_, ?_⟩ · rw [Int.ediv_mul_cancel hqdn] · refine Int.eq_mul_div_of_mul_eq_mul_of_dvd_left ?_ hqdn this rw [qdf] exact Rat.num_ne_zero.2 ((divInt_ne_zero hd).mpr hn) #align rat.num_denom_mk Rat.num_den_mk #noalign rat.mk_pnat_num #noalign rat.mk_pnat_denom theorem num_mk (n d : ℤ) : (n /. d).num = d.sign * n / n.gcd d := by have (m : ℕ) : Int.natAbs (m + 1) = m + 1 := by rw [← Nat.cast_one, ← Nat.cast_add, Int.natAbs_cast] rcases d with ((_ | _) | _) <;> rw [← Int.div_eq_ediv_of_dvd] <;> simp [divInt, mkRat, Rat.normalize, Nat.succPNat, Int.sign, Int.gcd, Int.zero_ediv, Int.ofNat_dvd_left, Nat.gcd_dvd_left, this] #align rat.num_mk Rat.num_mk theorem den_mk (n d : ℤ) : (n /. d).den = if d = 0 then 1 else d.natAbs / n.gcd d := by have (m : ℕ) : Int.natAbs (m + 1) = m + 1 := by rw [← Nat.cast_one, ← Nat.cast_add, Int.natAbs_cast] rcases d with ((_ | _) | _) <;> simp [divInt, mkRat, Rat.normalize, Nat.succPNat, Int.sign, Int.gcd, if_neg (Nat.cast_add_one_ne_zero _), this] #align rat.denom_mk Rat.den_mk #noalign rat.mk_pnat_denom_dvd theorem add_den_dvd (q₁ q₂ : ℚ) : (q₁ + q₂).den ∣ q₁.den * q₂.den := by rw [add_def, normalize_eq] apply Nat.div_dvd_of_dvd apply Nat.gcd_dvd_right #align rat.add_denom_dvd Rat.add_den_dvd theorem mul_den_dvd (q₁ q₂ : ℚ) : (q₁ * q₂).den ∣ q₁.den * q₂.den := by rw [mul_def, normalize_eq] apply Nat.div_dvd_of_dvd apply Nat.gcd_dvd_right #align rat.mul_denom_dvd Rat.mul_den_dvd theorem mul_num (q₁ q₂ : ℚ) : (q₁ * q₂).num = q₁.num * q₂.num / Nat.gcd (q₁.num * q₂.num).natAbs (q₁.den * q₂.den) := by rw [mul_def, normalize_eq] #align rat.mul_num Rat.mul_num theorem mul_den (q₁ q₂ : ℚ) : (q₁ * q₂).den = q₁.den * q₂.den / Nat.gcd (q₁.num * q₂.num).natAbs (q₁.den * q₂.den) := by rw [mul_def, normalize_eq] #align rat.mul_denom Rat.mul_den theorem mul_self_num (q : ℚ) : (q * q).num = q.num * q.num := by rw [mul_num, Int.natAbs_mul, Nat.Coprime.gcd_eq_one, Int.ofNat_one, Int.ediv_one] exact (q.reduced.mul_right q.reduced).mul (q.reduced.mul_right q.reduced) #align rat.mul_self_num Rat.mul_self_num theorem mul_self_den (q : ℚ) : (q * q).den = q.den * q.den := by rw [Rat.mul_den, Int.natAbs_mul, Nat.Coprime.gcd_eq_one, Nat.div_one] exact (q.reduced.mul_right q.reduced).mul (q.reduced.mul_right q.reduced) #align rat.mul_self_denom Rat.mul_self_den theorem add_num_den (q r : ℚ) : q + r = (q.num * r.den + q.den * r.num : ℤ) /. (↑q.den * ↑r.den : ℤ) := by have hqd : (q.den : ℤ) ≠ 0 := Int.natCast_ne_zero_iff_pos.2 q.den_pos have hrd : (r.den : ℤ) ≠ 0 := Int.natCast_ne_zero_iff_pos.2 r.den_pos conv_lhs => rw [← num_divInt_den q, ← num_divInt_den r, divInt_add_divInt _ _ hqd hrd] rw [mul_comm r.num q.den] #align rat.add_num_denom Rat.add_num_den protected theorem inv_neg (q : ℚ) : (-q)⁻¹ = -q⁻¹ := by rw [← num_divInt_den q] simp only [Rat.neg_divInt, Rat.inv_divInt', eq_self_iff_true, Rat.divInt_neg] #align rat.inv_neg Rat.inv_neg theorem num_div_eq_of_coprime {a b : ℤ} (hb0 : 0 < b) (h : Nat.Coprime a.natAbs b.natAbs) : (a / b : ℚ).num = a := by -- Porting note: was `lift b to ℕ using le_of_lt hb0` rw [← Int.natAbs_of_nonneg hb0.le, ← Rat.divInt_eq_div, ← mk_eq_divInt _ _ (Int.natAbs_ne_zero.mpr hb0.ne') h] #align rat.num_div_eq_of_coprime Rat.num_div_eq_of_coprime theorem den_div_eq_of_coprime {a b : ℤ} (hb0 : 0 < b) (h : Nat.Coprime a.natAbs b.natAbs) : ((a / b : ℚ).den : ℤ) = b := by -- Porting note: was `lift b to ℕ using le_of_lt hb0` rw [← Int.natAbs_of_nonneg hb0.le, ← Rat.divInt_eq_div, ← mk_eq_divInt _ _ (Int.natAbs_ne_zero.mpr hb0.ne') h] #align rat.denom_div_eq_of_coprime Rat.den_div_eq_of_coprime theorem div_int_inj {a b c d : ℤ} (hb0 : 0 < b) (hd0 : 0 < d) (h1 : Nat.Coprime a.natAbs b.natAbs) (h2 : Nat.Coprime c.natAbs d.natAbs) (h : (a : ℚ) / b = (c : ℚ) / d) : a = c ∧ b = d := by apply And.intro · rw [← num_div_eq_of_coprime hb0 h1, h, num_div_eq_of_coprime hd0 h2] · rw [← den_div_eq_of_coprime hb0 h1, h, den_div_eq_of_coprime hd0 h2] #align rat.div_int_inj Rat.div_int_inj @[norm_cast] theorem intCast_div_self (n : ℤ) : ((n / n : ℤ) : ℚ) = n / n := by by_cases hn : n = 0 · subst hn simp only [Int.cast_zero, Int.zero_div, zero_div, Int.ediv_zero] · have : (n : ℚ) ≠ 0 := by rwa [← coe_int_inj] at hn simp only [Int.ediv_self hn, Int.cast_one, Ne, not_false_iff, div_self this] #align rat.coe_int_div_self Rat.intCast_div_self @[norm_cast] theorem natCast_div_self (n : ℕ) : ((n / n : ℕ) : ℚ) = n / n := intCast_div_self n #align rat.coe_nat_div_self Rat.natCast_div_self theorem intCast_div (a b : ℤ) (h : b ∣ a) : ((a / b : ℤ) : ℚ) = a / b := by rcases h with ⟨c, rfl⟩ rw [mul_comm b, Int.mul_ediv_assoc c (dvd_refl b), Int.cast_mul, intCast_div_self, Int.cast_mul, mul_div_assoc] #align rat.coe_int_div Rat.intCast_div theorem natCast_div (a b : ℕ) (h : b ∣ a) : ((a / b : ℕ) : ℚ) = a / b := intCast_div a b (Int.ofNat_dvd.mpr h) #align rat.coe_nat_div Rat.natCast_div theorem den_div_intCast_eq_one_iff (m n : ℤ) (hn : n ≠ 0) : ((m : ℚ) / n).den = 1 ↔ n ∣ m := by replace hn : (n : ℚ) ≠ 0 := num_ne_zero.mp hn constructor · rw [Rat.den_eq_one_iff, eq_div_iff hn] exact mod_cast (Dvd.intro_left _) · exact (intCast_div _ _ · ▸ rfl) #align rat.denom_div_cast_eq_one_iff Rat.den_div_intCast_eq_one_iff theorem den_div_natCast_eq_one_iff (m n : ℕ) (hn : n ≠ 0) : ((m : ℚ) / n).den = 1 ↔ n ∣ m := (den_div_intCast_eq_one_iff m n (Int.ofNat_ne_zero.mpr hn)).trans Int.ofNat_dvd -- 2024-05-11 @[deprecated] alias den_div_cast_eq_one_iff := den_div_intCast_eq_one_iff theorem inv_intCast_num_of_pos {a : ℤ} (ha0 : 0 < a) : (a : ℚ)⁻¹.num = 1 := by rw [← ofInt_eq_cast, ofInt, mk_eq_divInt, Rat.inv_divInt', divInt_eq_div, Nat.cast_one] apply num_div_eq_of_coprime ha0 rw [Int.natAbs_one] exact Nat.coprime_one_left _ #align rat.inv_coe_int_num_of_pos Rat.inv_intCast_num_of_pos theorem inv_natCast_num_of_pos {a : ℕ} (ha0 : 0 < a) : (a : ℚ)⁻¹.num = 1 := inv_intCast_num_of_pos (mod_cast ha0 : 0 < (a : ℤ)) #align rat.inv_coe_nat_num_of_pos Rat.inv_natCast_num_of_pos
Mathlib/Data/Rat/Lemmas.lean
248
252
theorem inv_intCast_den_of_pos {a : ℤ} (ha0 : 0 < a) : ((a : ℚ)⁻¹.den : ℤ) = a := by
rw [← ofInt_eq_cast, ofInt, mk_eq_divInt, Rat.inv_divInt', divInt_eq_div, Nat.cast_one] apply den_div_eq_of_coprime ha0 rw [Int.natAbs_one] exact Nat.coprime_one_left _
import Mathlib.LinearAlgebra.Dimension.Basic import Mathlib.SetTheory.Cardinal.ToNat #align_import linear_algebra.finrank from "leanprover-community/mathlib"@"347636a7a80595d55bedf6e6fbd996a3c39da69a" universe u v w open Cardinal Submodule Module Function variable {R : Type u} {M : Type v} {N : Type w} variable [Ring R] [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N] namespace FiniteDimensional section Ring noncomputable def finrank (R M : Type*) [Semiring R] [AddCommGroup M] [Module R M] : ℕ := Cardinal.toNat (Module.rank R M) #align finite_dimensional.finrank FiniteDimensional.finrank theorem finrank_eq_of_rank_eq {n : ℕ} (h : Module.rank R M = ↑n) : finrank R M = n := by apply_fun toNat at h rw [toNat_natCast] at h exact mod_cast h #align finite_dimensional.finrank_eq_of_rank_eq FiniteDimensional.finrank_eq_of_rank_eq lemma rank_eq_one_iff_finrank_eq_one : Module.rank R M = 1 ↔ finrank R M = 1 := Cardinal.toNat_eq_one.symm lemma rank_eq_ofNat_iff_finrank_eq_ofNat (n : ℕ) [Nat.AtLeastTwo n] : Module.rank R M = OfNat.ofNat n ↔ finrank R M = OfNat.ofNat n := Cardinal.toNat_eq_ofNat.symm
Mathlib/LinearAlgebra/Dimension/Finrank.lean
72
75
theorem finrank_le_of_rank_le {n : ℕ} (h : Module.rank R M ≤ ↑n) : finrank R M ≤ n := by
rwa [← Cardinal.toNat_le_iff_le_of_lt_aleph0, toNat_natCast] at h · exact h.trans_lt (nat_lt_aleph0 n) · exact nat_lt_aleph0 n
import Mathlib.LinearAlgebra.FiniteDimensional import Mathlib.MeasureTheory.Group.Pointwise import Mathlib.MeasureTheory.Measure.Lebesgue.Basic import Mathlib.MeasureTheory.Measure.Haar.Basic import Mathlib.MeasureTheory.Measure.Doubling import Mathlib.MeasureTheory.Constructions.BorelSpace.Metric #align_import measure_theory.measure.lebesgue.eq_haar from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" assert_not_exists MeasureTheory.integral open TopologicalSpace Set Filter Metric Bornology open scoped ENNReal Pointwise Topology NNReal def TopologicalSpace.PositiveCompacts.Icc01 : PositiveCompacts ℝ where carrier := Icc 0 1 isCompact' := isCompact_Icc interior_nonempty' := by simp_rw [interior_Icc, nonempty_Ioo, zero_lt_one] #align topological_space.positive_compacts.Icc01 TopologicalSpace.PositiveCompacts.Icc01 universe u def TopologicalSpace.PositiveCompacts.piIcc01 (ι : Type*) [Finite ι] : PositiveCompacts (ι → ℝ) where carrier := pi univ fun _ => Icc 0 1 isCompact' := isCompact_univ_pi fun _ => isCompact_Icc interior_nonempty' := by simp only [interior_pi_set, Set.toFinite, interior_Icc, univ_pi_nonempty_iff, nonempty_Ioo, imp_true_iff, zero_lt_one] #align topological_space.positive_compacts.pi_Icc01 TopologicalSpace.PositiveCompacts.piIcc01 theorem Basis.parallelepiped_basisFun (ι : Type*) [Fintype ι] : (Pi.basisFun ℝ ι).parallelepiped = TopologicalSpace.PositiveCompacts.piIcc01 ι := SetLike.coe_injective <| by refine Eq.trans ?_ ((uIcc_of_le ?_).trans (Set.pi_univ_Icc _ _).symm) · classical convert parallelepiped_single (ι := ι) 1 · exact zero_le_one #align basis.parallelepiped_basis_fun Basis.parallelepiped_basisFun theorem Basis.parallelepiped_eq_map {ι E : Type*} [Fintype ι] [NormedAddCommGroup E] [NormedSpace ℝ E] (b : Basis ι ℝ E) : b.parallelepiped = (PositiveCompacts.piIcc01 ι).map b.equivFun.symm b.equivFunL.symm.continuous b.equivFunL.symm.isOpenMap := by classical rw [← Basis.parallelepiped_basisFun, ← Basis.parallelepiped_map] congr with x simp open MeasureTheory MeasureTheory.Measure theorem Basis.map_addHaar {ι E F : Type*} [Fintype ι] [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedSpace ℝ E] [NormedSpace ℝ F] [MeasurableSpace E] [MeasurableSpace F] [BorelSpace E] [BorelSpace F] [SecondCountableTopology F] [SigmaCompactSpace F] (b : Basis ι ℝ E) (f : E ≃L[ℝ] F) : map f b.addHaar = (b.map f.toLinearEquiv).addHaar := by have : IsAddHaarMeasure (map f b.addHaar) := AddEquiv.isAddHaarMeasure_map b.addHaar f.toAddEquiv f.continuous f.symm.continuous rw [eq_comm, Basis.addHaar_eq_iff, Measure.map_apply f.continuous.measurable (PositiveCompacts.isCompact _).measurableSet, Basis.coe_parallelepiped, Basis.coe_map] erw [← image_parallelepiped, f.toEquiv.preimage_image, addHaar_self] namespace MeasureTheory open Measure TopologicalSpace.PositiveCompacts FiniteDimensional theorem addHaarMeasure_eq_volume : addHaarMeasure Icc01 = volume := by convert (addHaarMeasure_unique volume Icc01).symm; simp [Icc01] #align measure_theory.add_haar_measure_eq_volume MeasureTheory.addHaarMeasure_eq_volume theorem addHaarMeasure_eq_volume_pi (ι : Type*) [Fintype ι] : addHaarMeasure (piIcc01 ι) = volume := by convert (addHaarMeasure_unique volume (piIcc01 ι)).symm simp only [piIcc01, volume_pi_pi fun _ => Icc (0 : ℝ) 1, PositiveCompacts.coe_mk, Compacts.coe_mk, Finset.prod_const_one, ENNReal.ofReal_one, Real.volume_Icc, one_smul, sub_zero] #align measure_theory.add_haar_measure_eq_volume_pi MeasureTheory.addHaarMeasure_eq_volume_pi -- Porting note (#11215): TODO: remove this instance? instance isAddHaarMeasure_volume_pi (ι : Type*) [Fintype ι] : IsAddHaarMeasure (volume : Measure (ι → ℝ)) := inferInstance #align measure_theory.is_add_haar_measure_volume_pi MeasureTheory.isAddHaarMeasure_volume_pi namespace Measure theorem addHaar_eq_zero_of_disjoint_translates_aux {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace E] [BorelSpace E] [FiniteDimensional ℝ E] (μ : Measure E) [IsAddHaarMeasure μ] {s : Set E} (u : ℕ → E) (sb : IsBounded s) (hu : IsBounded (range u)) (hs : Pairwise (Disjoint on fun n => {u n} + s)) (h's : MeasurableSet s) : μ s = 0 := by by_contra h apply lt_irrefl ∞ calc ∞ = ∑' _ : ℕ, μ s := (ENNReal.tsum_const_eq_top_of_ne_zero h).symm _ = ∑' n : ℕ, μ ({u n} + s) := by congr 1; ext1 n; simp only [image_add_left, measure_preimage_add, singleton_add] _ = μ (⋃ n, {u n} + s) := Eq.symm <| measure_iUnion hs fun n => by simpa only [image_add_left, singleton_add] using measurable_id.const_add _ h's _ = μ (range u + s) := by rw [← iUnion_add, iUnion_singleton_eq_range] _ < ∞ := (hu.add sb).measure_lt_top #align measure_theory.measure.add_haar_eq_zero_of_disjoint_translates_aux MeasureTheory.Measure.addHaar_eq_zero_of_disjoint_translates_aux theorem addHaar_eq_zero_of_disjoint_translates {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace E] [BorelSpace E] [FiniteDimensional ℝ E] (μ : Measure E) [IsAddHaarMeasure μ] {s : Set E} (u : ℕ → E) (hu : IsBounded (range u)) (hs : Pairwise (Disjoint on fun n => {u n} + s)) (h's : MeasurableSet s) : μ s = 0 := by suffices H : ∀ R, μ (s ∩ closedBall 0 R) = 0 by apply le_antisymm _ (zero_le _) calc μ s ≤ ∑' n : ℕ, μ (s ∩ closedBall 0 n) := by conv_lhs => rw [← iUnion_inter_closedBall_nat s 0] exact measure_iUnion_le _ _ = 0 := by simp only [H, tsum_zero] intro R apply addHaar_eq_zero_of_disjoint_translates_aux μ u (isBounded_closedBall.subset inter_subset_right) hu _ (h's.inter measurableSet_closedBall) refine pairwise_disjoint_mono hs fun n => ?_ exact add_subset_add Subset.rfl inter_subset_left #align measure_theory.measure.add_haar_eq_zero_of_disjoint_translates MeasureTheory.Measure.addHaar_eq_zero_of_disjoint_translates theorem addHaar_submodule {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace E] [BorelSpace E] [FiniteDimensional ℝ E] (μ : Measure E) [IsAddHaarMeasure μ] (s : Submodule ℝ E) (hs : s ≠ ⊤) : μ s = 0 := by obtain ⟨x, hx⟩ : ∃ x, x ∉ s := by simpa only [Submodule.eq_top_iff', not_exists, Ne, not_forall] using hs obtain ⟨c, cpos, cone⟩ : ∃ c : ℝ, 0 < c ∧ c < 1 := ⟨1 / 2, by norm_num, by norm_num⟩ have A : IsBounded (range fun n : ℕ => c ^ n • x) := have : Tendsto (fun n : ℕ => c ^ n • x) atTop (𝓝 ((0 : ℝ) • x)) := (tendsto_pow_atTop_nhds_zero_of_lt_one cpos.le cone).smul_const x isBounded_range_of_tendsto _ this apply addHaar_eq_zero_of_disjoint_translates μ _ A _ (Submodule.closed_of_finiteDimensional s).measurableSet intro m n hmn simp only [Function.onFun, image_add_left, singleton_add, disjoint_left, mem_preimage, SetLike.mem_coe] intro y hym hyn have A : (c ^ n - c ^ m) • x ∈ s := by convert s.sub_mem hym hyn using 1 simp only [sub_smul, neg_sub_neg, add_sub_add_right_eq_sub] have H : c ^ n - c ^ m ≠ 0 := by simpa only [sub_eq_zero, Ne] using (pow_right_strictAnti cpos cone).injective.ne hmn.symm have : x ∈ s := by convert s.smul_mem (c ^ n - c ^ m)⁻¹ A rw [smul_smul, inv_mul_cancel H, one_smul] exact hx this #align measure_theory.measure.add_haar_submodule MeasureTheory.Measure.addHaar_submodule theorem addHaar_affineSubspace {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace E] [BorelSpace E] [FiniteDimensional ℝ E] (μ : Measure E) [IsAddHaarMeasure μ] (s : AffineSubspace ℝ E) (hs : s ≠ ⊤) : μ s = 0 := by rcases s.eq_bot_or_nonempty with (rfl | hne) · rw [AffineSubspace.bot_coe, measure_empty] rw [Ne, ← AffineSubspace.direction_eq_top_iff_of_nonempty hne] at hs rcases hne with ⟨x, hx : x ∈ s⟩ simpa only [AffineSubspace.coe_direction_eq_vsub_set_right hx, vsub_eq_sub, sub_eq_add_neg, image_add_right, neg_neg, measure_preimage_add_right] using addHaar_submodule μ s.direction hs #align measure_theory.measure.add_haar_affine_subspace MeasureTheory.Measure.addHaar_affineSubspace theorem map_linearMap_addHaar_pi_eq_smul_addHaar {ι : Type*} [Finite ι] {f : (ι → ℝ) →ₗ[ℝ] ι → ℝ} (hf : LinearMap.det f ≠ 0) (μ : Measure (ι → ℝ)) [IsAddHaarMeasure μ] : Measure.map f μ = ENNReal.ofReal (abs (LinearMap.det f)⁻¹) • μ := by cases nonempty_fintype ι have := addHaarMeasure_unique μ (piIcc01 ι) rw [this, addHaarMeasure_eq_volume_pi, Measure.map_smul, Real.map_linearMap_volume_pi_eq_smul_volume_pi hf, smul_comm] #align measure_theory.measure.map_linear_map_add_haar_pi_eq_smul_add_haar MeasureTheory.Measure.map_linearMap_addHaar_pi_eq_smul_addHaar variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace E] [BorelSpace E] [FiniteDimensional ℝ E] (μ : Measure E) [IsAddHaarMeasure μ] {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] theorem map_linearMap_addHaar_eq_smul_addHaar {f : E →ₗ[ℝ] E} (hf : LinearMap.det f ≠ 0) : Measure.map f μ = ENNReal.ofReal |(LinearMap.det f)⁻¹| • μ := by -- we reduce to the case of `E = ι → ℝ`, for which we have already proved the result using -- matrices in `map_linearMap_addHaar_pi_eq_smul_addHaar`. let ι := Fin (finrank ℝ E) haveI : FiniteDimensional ℝ (ι → ℝ) := by infer_instance have : finrank ℝ E = finrank ℝ (ι → ℝ) := by simp [ι] have e : E ≃ₗ[ℝ] ι → ℝ := LinearEquiv.ofFinrankEq E (ι → ℝ) this -- next line is to avoid `g` getting reduced by `simp`. obtain ⟨g, hg⟩ : ∃ g, g = (e : E →ₗ[ℝ] ι → ℝ).comp (f.comp (e.symm : (ι → ℝ) →ₗ[ℝ] E)) := ⟨_, rfl⟩ have gdet : LinearMap.det g = LinearMap.det f := by rw [hg]; exact LinearMap.det_conj f e rw [← gdet] at hf ⊢ have fg : f = (e.symm : (ι → ℝ) →ₗ[ℝ] E).comp (g.comp (e : E →ₗ[ℝ] ι → ℝ)) := by ext x simp only [LinearEquiv.coe_coe, Function.comp_apply, LinearMap.coe_comp, LinearEquiv.symm_apply_apply, hg] simp only [fg, LinearEquiv.coe_coe, LinearMap.coe_comp] have Ce : Continuous e := (e : E →ₗ[ℝ] ι → ℝ).continuous_of_finiteDimensional have Cg : Continuous g := LinearMap.continuous_of_finiteDimensional g have Cesymm : Continuous e.symm := (e.symm : (ι → ℝ) →ₗ[ℝ] E).continuous_of_finiteDimensional rw [← map_map Cesymm.measurable (Cg.comp Ce).measurable, ← map_map Cg.measurable Ce.measurable] haveI : IsAddHaarMeasure (map e μ) := (e : E ≃+ (ι → ℝ)).isAddHaarMeasure_map μ Ce Cesymm have ecomp : e.symm ∘ e = id := by ext x; simp only [id, Function.comp_apply, LinearEquiv.symm_apply_apply] rw [map_linearMap_addHaar_pi_eq_smul_addHaar hf (map e μ), Measure.map_smul, map_map Cesymm.measurable Ce.measurable, ecomp, Measure.map_id] #align measure_theory.measure.map_linear_map_add_haar_eq_smul_add_haar MeasureTheory.Measure.map_linearMap_addHaar_eq_smul_addHaar @[simp] theorem addHaar_preimage_linearMap {f : E →ₗ[ℝ] E} (hf : LinearMap.det f ≠ 0) (s : Set E) : μ (f ⁻¹' s) = ENNReal.ofReal |(LinearMap.det f)⁻¹| * μ s := calc μ (f ⁻¹' s) = Measure.map f μ s := ((f.equivOfDetNeZero hf).toContinuousLinearEquiv.toHomeomorph.toMeasurableEquiv.map_apply s).symm _ = ENNReal.ofReal |(LinearMap.det f)⁻¹| * μ s := by rw [map_linearMap_addHaar_eq_smul_addHaar μ hf]; rfl #align measure_theory.measure.add_haar_preimage_linear_map MeasureTheory.Measure.addHaar_preimage_linearMap @[simp] theorem addHaar_preimage_continuousLinearMap {f : E →L[ℝ] E} (hf : LinearMap.det (f : E →ₗ[ℝ] E) ≠ 0) (s : Set E) : μ (f ⁻¹' s) = ENNReal.ofReal (abs (LinearMap.det (f : E →ₗ[ℝ] E))⁻¹) * μ s := addHaar_preimage_linearMap μ hf s #align measure_theory.measure.add_haar_preimage_continuous_linear_map MeasureTheory.Measure.addHaar_preimage_continuousLinearMap @[simp] theorem addHaar_preimage_linearEquiv (f : E ≃ₗ[ℝ] E) (s : Set E) : μ (f ⁻¹' s) = ENNReal.ofReal |LinearMap.det (f.symm : E →ₗ[ℝ] E)| * μ s := by have A : LinearMap.det (f : E →ₗ[ℝ] E) ≠ 0 := (LinearEquiv.isUnit_det' f).ne_zero convert addHaar_preimage_linearMap μ A s simp only [LinearEquiv.det_coe_symm] #align measure_theory.measure.add_haar_preimage_linear_equiv MeasureTheory.Measure.addHaar_preimage_linearEquiv @[simp] theorem addHaar_preimage_continuousLinearEquiv (f : E ≃L[ℝ] E) (s : Set E) : μ (f ⁻¹' s) = ENNReal.ofReal |LinearMap.det (f.symm : E →ₗ[ℝ] E)| * μ s := addHaar_preimage_linearEquiv μ _ s #align measure_theory.measure.add_haar_preimage_continuous_linear_equiv MeasureTheory.Measure.addHaar_preimage_continuousLinearEquiv @[simp] theorem addHaar_image_linearMap (f : E →ₗ[ℝ] E) (s : Set E) : μ (f '' s) = ENNReal.ofReal |LinearMap.det f| * μ s := by rcases ne_or_eq (LinearMap.det f) 0 with (hf | hf) · let g := (f.equivOfDetNeZero hf).toContinuousLinearEquiv change μ (g '' s) = _ rw [ContinuousLinearEquiv.image_eq_preimage g s, addHaar_preimage_continuousLinearEquiv] congr · simp only [hf, zero_mul, ENNReal.ofReal_zero, abs_zero] have : μ (LinearMap.range f) = 0 := addHaar_submodule μ _ (LinearMap.range_lt_top_of_det_eq_zero hf).ne exact le_antisymm (le_trans (measure_mono (image_subset_range _ _)) this.le) (zero_le _) #align measure_theory.measure.add_haar_image_linear_map MeasureTheory.Measure.addHaar_image_linearMap @[simp] theorem addHaar_image_continuousLinearMap (f : E →L[ℝ] E) (s : Set E) : μ (f '' s) = ENNReal.ofReal |LinearMap.det (f : E →ₗ[ℝ] E)| * μ s := addHaar_image_linearMap μ _ s #align measure_theory.measure.add_haar_image_continuous_linear_map MeasureTheory.Measure.addHaar_image_continuousLinearMap @[simp] theorem addHaar_image_continuousLinearEquiv (f : E ≃L[ℝ] E) (s : Set E) : μ (f '' s) = ENNReal.ofReal |LinearMap.det (f : E →ₗ[ℝ] E)| * μ s := μ.addHaar_image_linearMap (f : E →ₗ[ℝ] E) s #align measure_theory.measure.add_haar_image_continuous_linear_equiv MeasureTheory.Measure.addHaar_image_continuousLinearEquiv theorem LinearMap.quasiMeasurePreserving (f : E →ₗ[ℝ] E) (hf : LinearMap.det f ≠ 0) : QuasiMeasurePreserving f μ μ := by refine ⟨f.continuous_of_finiteDimensional.measurable, ?_⟩ rw [map_linearMap_addHaar_eq_smul_addHaar μ hf] exact smul_absolutelyContinuous theorem ContinuousLinearMap.quasiMeasurePreserving (f : E →L[ℝ] E) (hf : f.det ≠ 0) : QuasiMeasurePreserving f μ μ := LinearMap.quasiMeasurePreserving μ (f : E →ₗ[ℝ] E) hf theorem map_addHaar_smul {r : ℝ} (hr : r ≠ 0) : Measure.map (r • ·) μ = ENNReal.ofReal (abs (r ^ finrank ℝ E)⁻¹) • μ := by let f : E →ₗ[ℝ] E := r • (1 : E →ₗ[ℝ] E) change Measure.map f μ = _ have hf : LinearMap.det f ≠ 0 := by simp only [f, mul_one, LinearMap.det_smul, Ne, MonoidHom.map_one] intro h exact hr (pow_eq_zero h) simp only [f, map_linearMap_addHaar_eq_smul_addHaar μ hf, mul_one, LinearMap.det_smul, map_one] #align measure_theory.measure.map_add_haar_smul MeasureTheory.Measure.map_addHaar_smul theorem quasiMeasurePreserving_smul {r : ℝ} (hr : r ≠ 0) : QuasiMeasurePreserving (r • ·) μ μ := by refine ⟨measurable_const_smul r, ?_⟩ rw [map_addHaar_smul μ hr] exact smul_absolutelyContinuous @[simp] theorem addHaar_preimage_smul {r : ℝ} (hr : r ≠ 0) (s : Set E) : μ ((r • ·) ⁻¹' s) = ENNReal.ofReal (abs (r ^ finrank ℝ E)⁻¹) * μ s := calc μ ((r • ·) ⁻¹' s) = Measure.map (r • ·) μ s := ((Homeomorph.smul (isUnit_iff_ne_zero.2 hr).unit).toMeasurableEquiv.map_apply s).symm _ = ENNReal.ofReal (abs (r ^ finrank ℝ E)⁻¹) * μ s := by rw [map_addHaar_smul μ hr, coe_smul, Pi.smul_apply, smul_eq_mul] #align measure_theory.measure.add_haar_preimage_smul MeasureTheory.Measure.addHaar_preimage_smul @[simp] theorem addHaar_smul (r : ℝ) (s : Set E) : μ (r • s) = ENNReal.ofReal (abs (r ^ finrank ℝ E)) * μ s := by rcases ne_or_eq r 0 with (h | rfl) · rw [← preimage_smul_inv₀ h, addHaar_preimage_smul μ (inv_ne_zero h), inv_pow, inv_inv] rcases eq_empty_or_nonempty s with (rfl | hs) · simp only [measure_empty, mul_zero, smul_set_empty] rw [zero_smul_set hs, ← singleton_zero] by_cases h : finrank ℝ E = 0 · haveI : Subsingleton E := finrank_zero_iff.1 h simp only [h, one_mul, ENNReal.ofReal_one, abs_one, Subsingleton.eq_univ_of_nonempty hs, pow_zero, Subsingleton.eq_univ_of_nonempty (singleton_nonempty (0 : E))] · haveI : Nontrivial E := nontrivial_of_finrank_pos (bot_lt_iff_ne_bot.2 h) simp only [h, zero_mul, ENNReal.ofReal_zero, abs_zero, Ne, not_false_iff, zero_pow, measure_singleton] #align measure_theory.measure.add_haar_smul MeasureTheory.Measure.addHaar_smul theorem addHaar_smul_of_nonneg {r : ℝ} (hr : 0 ≤ r) (s : Set E) : μ (r • s) = ENNReal.ofReal (r ^ finrank ℝ E) * μ s := by rw [addHaar_smul, abs_pow, abs_of_nonneg hr] #align measure_theory.measure.add_haar_smul_of_nonneg MeasureTheory.Measure.addHaar_smul_of_nonneg variable {μ} {s : Set E} -- Note: We might want to rename this once we acquire the lemma corresponding to -- `MeasurableSet.const_smul` theorem NullMeasurableSet.const_smul (hs : NullMeasurableSet s μ) (r : ℝ) : NullMeasurableSet (r • s) μ := by obtain rfl | hs' := s.eq_empty_or_nonempty · simp obtain rfl | hr := eq_or_ne r 0 · simpa [zero_smul_set hs'] using nullMeasurableSet_singleton _ obtain ⟨t, ht, hst⟩ := hs refine ⟨_, ht.const_smul_of_ne_zero hr, ?_⟩ rw [← measure_symmDiff_eq_zero_iff] at hst ⊢ rw [← smul_set_symmDiff₀ hr, addHaar_smul μ, hst, mul_zero] #align measure_theory.measure.null_measurable_set.const_smul MeasureTheory.Measure.NullMeasurableSet.const_smul variable (μ) @[simp] theorem addHaar_image_homothety (x : E) (r : ℝ) (s : Set E) : μ (AffineMap.homothety x r '' s) = ENNReal.ofReal (abs (r ^ finrank ℝ E)) * μ s := calc μ (AffineMap.homothety x r '' s) = μ ((fun y => y + x) '' (r • (fun y => y + -x) '' s)) := by simp only [← image_smul, image_image, ← sub_eq_add_neg]; rfl _ = ENNReal.ofReal (abs (r ^ finrank ℝ E)) * μ s := by simp only [image_add_right, measure_preimage_add_right, addHaar_smul] #align measure_theory.measure.add_haar_image_homothety MeasureTheory.Measure.addHaar_image_homothety theorem addHaar_ball_center {E : Type*} [NormedAddCommGroup E] [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [IsAddHaarMeasure μ] (x : E) (r : ℝ) : μ (ball x r) = μ (ball (0 : E) r) := by have : ball (0 : E) r = (x + ·) ⁻¹' ball x r := by simp [preimage_add_ball] rw [this, measure_preimage_add] #align measure_theory.measure.add_haar_ball_center MeasureTheory.Measure.addHaar_ball_center theorem addHaar_closedBall_center {E : Type*} [NormedAddCommGroup E] [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [IsAddHaarMeasure μ] (x : E) (r : ℝ) : μ (closedBall x r) = μ (closedBall (0 : E) r) := by have : closedBall (0 : E) r = (x + ·) ⁻¹' closedBall x r := by simp [preimage_add_closedBall] rw [this, measure_preimage_add] #align measure_theory.measure.add_haar_closed_ball_center MeasureTheory.Measure.addHaar_closedBall_center theorem addHaar_ball_mul_of_pos (x : E) {r : ℝ} (hr : 0 < r) (s : ℝ) : μ (ball x (r * s)) = ENNReal.ofReal (r ^ finrank ℝ E) * μ (ball 0 s) := by have : ball (0 : E) (r * s) = r • ball (0 : E) s := by simp only [_root_.smul_ball hr.ne' (0 : E) s, Real.norm_eq_abs, abs_of_nonneg hr.le, smul_zero] simp only [this, addHaar_smul, abs_of_nonneg hr.le, addHaar_ball_center, abs_pow] #align measure_theory.measure.add_haar_ball_mul_of_pos MeasureTheory.Measure.addHaar_ball_mul_of_pos theorem addHaar_ball_of_pos (x : E) {r : ℝ} (hr : 0 < r) : μ (ball x r) = ENNReal.ofReal (r ^ finrank ℝ E) * μ (ball 0 1) := by rw [← addHaar_ball_mul_of_pos μ x hr, mul_one] #align measure_theory.measure.add_haar_ball_of_pos MeasureTheory.Measure.addHaar_ball_of_pos theorem addHaar_ball_mul [Nontrivial E] (x : E) {r : ℝ} (hr : 0 ≤ r) (s : ℝ) : μ (ball x (r * s)) = ENNReal.ofReal (r ^ finrank ℝ E) * μ (ball 0 s) := by rcases hr.eq_or_lt with (rfl | h) · simp only [zero_pow (finrank_pos (R := ℝ) (M := E)).ne', measure_empty, zero_mul, ENNReal.ofReal_zero, ball_zero] · exact addHaar_ball_mul_of_pos μ x h s #align measure_theory.measure.add_haar_ball_mul MeasureTheory.Measure.addHaar_ball_mul theorem addHaar_ball [Nontrivial E] (x : E) {r : ℝ} (hr : 0 ≤ r) : μ (ball x r) = ENNReal.ofReal (r ^ finrank ℝ E) * μ (ball 0 1) := by rw [← addHaar_ball_mul μ x hr, mul_one] #align measure_theory.measure.add_haar_ball MeasureTheory.Measure.addHaar_ball theorem addHaar_closedBall_mul_of_pos (x : E) {r : ℝ} (hr : 0 < r) (s : ℝ) : μ (closedBall x (r * s)) = ENNReal.ofReal (r ^ finrank ℝ E) * μ (closedBall 0 s) := by have : closedBall (0 : E) (r * s) = r • closedBall (0 : E) s := by simp [smul_closedBall' hr.ne' (0 : E), abs_of_nonneg hr.le] simp only [this, addHaar_smul, abs_of_nonneg hr.le, addHaar_closedBall_center, abs_pow] #align measure_theory.measure.add_haar_closed_ball_mul_of_pos MeasureTheory.Measure.addHaar_closedBall_mul_of_pos theorem addHaar_closedBall_mul (x : E) {r : ℝ} (hr : 0 ≤ r) {s : ℝ} (hs : 0 ≤ s) : μ (closedBall x (r * s)) = ENNReal.ofReal (r ^ finrank ℝ E) * μ (closedBall 0 s) := by have : closedBall (0 : E) (r * s) = r • closedBall (0 : E) s := by simp [smul_closedBall r (0 : E) hs, abs_of_nonneg hr] simp only [this, addHaar_smul, abs_of_nonneg hr, addHaar_closedBall_center, abs_pow] #align measure_theory.measure.add_haar_closed_ball_mul MeasureTheory.Measure.addHaar_closedBall_mul theorem addHaar_closedBall' (x : E) {r : ℝ} (hr : 0 ≤ r) : μ (closedBall x r) = ENNReal.ofReal (r ^ finrank ℝ E) * μ (closedBall 0 1) := by rw [← addHaar_closedBall_mul μ x hr zero_le_one, mul_one] #align measure_theory.measure.add_haar_closed_ball' MeasureTheory.Measure.addHaar_closedBall' theorem addHaar_closed_unit_ball_eq_addHaar_unit_ball : μ (closedBall (0 : E) 1) = μ (ball 0 1) := by apply le_antisymm _ (measure_mono ball_subset_closedBall) have A : Tendsto (fun r : ℝ => ENNReal.ofReal (r ^ finrank ℝ E) * μ (closedBall (0 : E) 1)) (𝓝[<] 1) (𝓝 (ENNReal.ofReal ((1 : ℝ) ^ finrank ℝ E) * μ (closedBall (0 : E) 1))) := by refine ENNReal.Tendsto.mul ?_ (by simp) tendsto_const_nhds (by simp) exact ENNReal.tendsto_ofReal ((tendsto_id'.2 nhdsWithin_le_nhds).pow _) simp only [one_pow, one_mul, ENNReal.ofReal_one] at A refine le_of_tendsto A ?_ refine mem_nhdsWithin_Iio_iff_exists_Ioo_subset.2 ⟨(0 : ℝ), by simp, fun r hr => ?_⟩ dsimp rw [← addHaar_closedBall' μ (0 : E) hr.1.le] exact measure_mono (closedBall_subset_ball hr.2) #align measure_theory.measure.add_haar_closed_unit_ball_eq_add_haar_unit_ball MeasureTheory.Measure.addHaar_closed_unit_ball_eq_addHaar_unit_ball theorem addHaar_closedBall (x : E) {r : ℝ} (hr : 0 ≤ r) : μ (closedBall x r) = ENNReal.ofReal (r ^ finrank ℝ E) * μ (ball 0 1) := by rw [addHaar_closedBall' μ x hr, addHaar_closed_unit_ball_eq_addHaar_unit_ball] #align measure_theory.measure.add_haar_closed_ball MeasureTheory.Measure.addHaar_closedBall
Mathlib/MeasureTheory/Measure/Lebesgue/EqHaar.lean
522
527
theorem addHaar_closedBall_eq_addHaar_ball [Nontrivial E] (x : E) (r : ℝ) : μ (closedBall x r) = μ (ball x r) := by
by_cases h : r < 0 · rw [Metric.closedBall_eq_empty.mpr h, Metric.ball_eq_empty.mpr h.le] push_neg at h rw [addHaar_closedBall μ x h, addHaar_ball μ x h]
import Mathlib.Algebra.Field.Opposite import Mathlib.Algebra.Group.Subgroup.ZPowers import Mathlib.Algebra.Group.Submonoid.Membership import Mathlib.Algebra.Ring.NegOnePow import Mathlib.Algebra.Order.Archimedean import Mathlib.GroupTheory.Coset #align_import algebra.periodic from "leanprover-community/mathlib"@"30413fc89f202a090a54d78e540963ed3de0056e" variable {α β γ : Type*} {f g : α → β} {c c₁ c₂ x : α} open Set namespace Function @[simp] def Periodic [Add α] (f : α → β) (c : α) : Prop := ∀ x : α, f (x + c) = f x #align function.periodic Function.Periodic protected theorem Periodic.funext [Add α] (h : Periodic f c) : (fun x => f (x + c)) = f := funext h #align function.periodic.funext Function.Periodic.funext protected theorem Periodic.comp [Add α] (h : Periodic f c) (g : β → γ) : Periodic (g ∘ f) c := by simp_all #align function.periodic.comp Function.Periodic.comp theorem Periodic.comp_addHom [Add α] [Add γ] (h : Periodic f c) (g : AddHom γ α) (g_inv : α → γ) (hg : RightInverse g_inv g) : Periodic (f ∘ g) (g_inv c) := fun x => by simp only [hg c, h (g x), map_add, comp_apply] #align function.periodic.comp_add_hom Function.Periodic.comp_addHom @[to_additive] protected theorem Periodic.mul [Add α] [Mul β] (hf : Periodic f c) (hg : Periodic g c) : Periodic (f * g) c := by simp_all #align function.periodic.mul Function.Periodic.mul #align function.periodic.add Function.Periodic.add @[to_additive] protected theorem Periodic.div [Add α] [Div β] (hf : Periodic f c) (hg : Periodic g c) : Periodic (f / g) c := by simp_all #align function.periodic.div Function.Periodic.div #align function.periodic.sub Function.Periodic.sub @[to_additive] theorem _root_.List.periodic_prod [Add α] [Monoid β] (l : List (α → β)) (hl : ∀ f ∈ l, Periodic f c) : Periodic l.prod c := by induction' l with g l ih hl · simp · rw [List.forall_mem_cons] at hl simpa only [List.prod_cons] using hl.1.mul (ih hl.2) #align list.periodic_prod List.periodic_prod #align list.periodic_sum List.periodic_sum @[to_additive] theorem _root_.Multiset.periodic_prod [Add α] [CommMonoid β] (s : Multiset (α → β)) (hs : ∀ f ∈ s, Periodic f c) : Periodic s.prod c := (s.prod_toList ▸ s.toList.periodic_prod) fun f hf => hs f <| Multiset.mem_toList.mp hf #align multiset.periodic_prod Multiset.periodic_prod #align multiset.periodic_sum Multiset.periodic_sum @[to_additive] theorem _root_.Finset.periodic_prod [Add α] [CommMonoid β] {ι : Type*} {f : ι → α → β} (s : Finset ι) (hs : ∀ i ∈ s, Periodic (f i) c) : Periodic (∏ i ∈ s, f i) c := s.prod_to_list f ▸ (s.toList.map f).periodic_prod (by simpa [-Periodic] ) #align finset.periodic_prod Finset.periodic_prod #align finset.periodic_sum Finset.periodic_sum @[to_additive] protected theorem Periodic.smul [Add α] [SMul γ β] (h : Periodic f c) (a : γ) : Periodic (a • f) c := by simp_all #align function.periodic.smul Function.Periodic.smul #align function.periodic.vadd Function.Periodic.vadd protected theorem Periodic.const_smul [AddMonoid α] [Group γ] [DistribMulAction γ α] (h : Periodic f c) (a : γ) : Periodic (fun x => f (a • x)) (a⁻¹ • c) := fun x => by simpa only [smul_add, smul_inv_smul] using h (a • x) #align function.periodic.const_smul Function.Periodic.const_smul protected theorem Periodic.const_smul₀ [AddCommMonoid α] [DivisionSemiring γ] [Module γ α] (h : Periodic f c) (a : γ) : Periodic (fun x => f (a • x)) (a⁻¹ • c) := fun x => by by_cases ha : a = 0 · simp only [ha, zero_smul] · simpa only [smul_add, smul_inv_smul₀ ha] using h (a • x) #align function.periodic.const_smul₀ Function.Periodic.const_smul₀ protected theorem Periodic.const_mul [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (a * x)) (a⁻¹ * c) := Periodic.const_smul₀ h a #align function.periodic.const_mul Function.Periodic.const_mul theorem Periodic.const_inv_smul [AddMonoid α] [Group γ] [DistribMulAction γ α] (h : Periodic f c) (a : γ) : Periodic (fun x => f (a⁻¹ • x)) (a • c) := by simpa only [inv_inv] using h.const_smul a⁻¹ #align function.periodic.const_inv_smul Function.Periodic.const_inv_smul theorem Periodic.const_inv_smul₀ [AddCommMonoid α] [DivisionSemiring γ] [Module γ α] (h : Periodic f c) (a : γ) : Periodic (fun x => f (a⁻¹ • x)) (a • c) := by simpa only [inv_inv] using h.const_smul₀ a⁻¹ #align function.periodic.const_inv_smul₀ Function.Periodic.const_inv_smul₀ theorem Periodic.const_inv_mul [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (a⁻¹ * x)) (a * c) := h.const_inv_smul₀ a #align function.periodic.const_inv_mul Function.Periodic.const_inv_mul theorem Periodic.mul_const [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x * a)) (c * a⁻¹) := h.const_smul₀ (MulOpposite.op a) #align function.periodic.mul_const Function.Periodic.mul_const theorem Periodic.mul_const' [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x * a)) (c / a) := by simpa only [div_eq_mul_inv] using h.mul_const a #align function.periodic.mul_const' Function.Periodic.mul_const' theorem Periodic.mul_const_inv [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x * a⁻¹)) (c * a) := h.const_inv_smul₀ (MulOpposite.op a) #align function.periodic.mul_const_inv Function.Periodic.mul_const_inv theorem Periodic.div_const [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x / a)) (c * a) := by simpa only [div_eq_mul_inv] using h.mul_const_inv a #align function.periodic.div_const Function.Periodic.div_const
Mathlib/Algebra/Periodic.lean
156
157
theorem Periodic.add_period [AddSemigroup α] (h1 : Periodic f c₁) (h2 : Periodic f c₂) : Periodic f (c₁ + c₂) := by
simp_all [← add_assoc]
import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Basic import Mathlib.RingTheory.Ideal.Maps import Mathlib.RingTheory.MvPowerSeries.Basic #align_import ring_theory.power_series.basic from "leanprover-community/mathlib"@"2d5739b61641ee4e7e53eca5688a08f66f2e6a60" noncomputable section open Finset (antidiagonal mem_antidiagonal) def PowerSeries (R : Type*) := MvPowerSeries Unit R #align power_series PowerSeries namespace PowerSeries open Finsupp (single) variable {R : Type*} section -- Porting note: not available in Lean 4 -- local reducible PowerSeries scoped notation:9000 R "⟦X⟧" => PowerSeries R instance [Inhabited R] : Inhabited R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [Zero R] : Zero R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [AddMonoid R] : AddMonoid R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [AddGroup R] : AddGroup R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [AddCommMonoid R] : AddCommMonoid R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [AddCommGroup R] : AddCommGroup R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [Semiring R] : Semiring R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [CommSemiring R] : CommSemiring R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [Ring R] : Ring R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [CommRing R] : CommRing R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [Nontrivial R] : Nontrivial R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance {A} [Semiring R] [AddCommMonoid A] [Module R A] : Module R A⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance {A S} [Semiring R] [Semiring S] [AddCommMonoid A] [Module R A] [Module S A] [SMul R S] [IsScalarTower R S A] : IsScalarTower R S A⟦X⟧ := Pi.isScalarTower instance {A} [Semiring A] [CommSemiring R] [Algebra R A] : Algebra R A⟦X⟧ := by dsimp only [PowerSeries] infer_instance end section Semiring variable (R) [Semiring R] def coeff (n : ℕ) : R⟦X⟧ →ₗ[R] R := MvPowerSeries.coeff R (single () n) #align power_series.coeff PowerSeries.coeff def monomial (n : ℕ) : R →ₗ[R] R⟦X⟧ := MvPowerSeries.monomial R (single () n) #align power_series.monomial PowerSeries.monomial variable {R}
Mathlib/RingTheory/PowerSeries/Basic.lean
150
151
theorem coeff_def {s : Unit →₀ ℕ} {n : ℕ} (h : s () = n) : coeff R n = MvPowerSeries.coeff R s := by
erw [coeff, ← h, ← Finsupp.unique_single s]
import Mathlib.Algebra.Ring.Int import Mathlib.Data.Nat.Bitwise import Mathlib.Data.Nat.Size #align_import data.int.bitwise from "leanprover-community/mathlib"@"0743cc5d9d86bcd1bba10f480e948a257d65056f" #align_import init.data.int.bitwise from "leanprover-community/lean"@"855e5b74e3a52a40552e8f067169d747d48743fd" namespace Int def div2 : ℤ → ℤ | (n : ℕ) => n.div2 | -[n +1] => negSucc n.div2 #align int.div2 Int.div2 def bodd : ℤ → Bool | (n : ℕ) => n.bodd | -[n +1] => not (n.bodd) #align int.bodd Int.bodd -- Porting note: `bit0, bit1` deprecated, do we need to adapt `bit`? set_option linter.deprecated false in def bit (b : Bool) : ℤ → ℤ := cond b bit1 bit0 #align int.bit Int.bit def testBit : ℤ → ℕ → Bool | (m : ℕ), n => Nat.testBit m n | -[m +1], n => !(Nat.testBit m n) #align int.test_bit Int.testBit def natBitwise (f : Bool → Bool → Bool) (m n : ℕ) : ℤ := cond (f false false) -[ Nat.bitwise (fun x y => not (f x y)) m n +1] (Nat.bitwise f m n) #align int.nat_bitwise Int.natBitwise def bitwise (f : Bool → Bool → Bool) : ℤ → ℤ → ℤ | (m : ℕ), (n : ℕ) => natBitwise f m n | (m : ℕ), -[n +1] => natBitwise (fun x y => f x (not y)) m n | -[m +1], (n : ℕ) => natBitwise (fun x y => f (not x) y) m n | -[m +1], -[n +1] => natBitwise (fun x y => f (not x) (not y)) m n #align int.bitwise Int.bitwise def lnot : ℤ → ℤ | (m : ℕ) => -[m +1] | -[m +1] => m #align int.lnot Int.lnot def lor : ℤ → ℤ → ℤ | (m : ℕ), (n : ℕ) => m ||| n | (m : ℕ), -[n +1] => -[Nat.ldiff n m +1] | -[m +1], (n : ℕ) => -[Nat.ldiff m n +1] | -[m +1], -[n +1] => -[m &&& n +1] #align int.lor Int.lor def land : ℤ → ℤ → ℤ | (m : ℕ), (n : ℕ) => m &&& n | (m : ℕ), -[n +1] => Nat.ldiff m n | -[m +1], (n : ℕ) => Nat.ldiff n m | -[m +1], -[n +1] => -[m ||| n +1] #align int.land Int.land -- Porting note: I don't know why `Nat.ldiff` got the prime, but I'm matching this change here def ldiff : ℤ → ℤ → ℤ | (m : ℕ), (n : ℕ) => Nat.ldiff m n | (m : ℕ), -[n +1] => m &&& n | -[m +1], (n : ℕ) => -[m ||| n +1] | -[m +1], -[n +1] => Nat.ldiff n m #align int.ldiff Int.ldiff -- Porting note: I don't know why `Nat.xor'` got the prime, but I'm matching this change here protected def xor : ℤ → ℤ → ℤ | (m : ℕ), (n : ℕ) => (m ^^^ n) | (m : ℕ), -[n +1] => -[(m ^^^ n) +1] | -[m +1], (n : ℕ) => -[(m ^^^ n) +1] | -[m +1], -[n +1] => (m ^^^ n) #align int.lxor Int.xor instance : ShiftLeft ℤ where shiftLeft | (m : ℕ), (n : ℕ) => Nat.shiftLeft' false m n | (m : ℕ), -[n +1] => m >>> (Nat.succ n) | -[m +1], (n : ℕ) => -[Nat.shiftLeft' true m n +1] | -[m +1], -[n +1] => -[m >>> (Nat.succ n) +1] #align int.shiftl ShiftLeft.shiftLeft instance : ShiftRight ℤ where shiftRight m n := m <<< (-n) #align int.shiftr ShiftRight.shiftRight @[simp] theorem bodd_zero : bodd 0 = false := rfl #align int.bodd_zero Int.bodd_zero @[simp] theorem bodd_one : bodd 1 = true := rfl #align int.bodd_one Int.bodd_one theorem bodd_two : bodd 2 = false := rfl #align int.bodd_two Int.bodd_two @[simp, norm_cast] theorem bodd_coe (n : ℕ) : Int.bodd n = Nat.bodd n := rfl #align int.bodd_coe Int.bodd_coe @[simp] theorem bodd_subNatNat (m n : ℕ) : bodd (subNatNat m n) = xor m.bodd n.bodd := by apply subNatNat_elim m n fun m n i => bodd i = xor m.bodd n.bodd <;> intros i j <;> simp only [Int.bodd, Int.bodd_coe, Nat.bodd_add] <;> cases Nat.bodd i <;> simp #align int.bodd_sub_nat_nat Int.bodd_subNatNat @[simp] theorem bodd_negOfNat (n : ℕ) : bodd (negOfNat n) = n.bodd := by cases n <;> simp (config := {decide := true}) rfl #align int.bodd_neg_of_nat Int.bodd_negOfNat @[simp]
Mathlib/Data/Int/Bitwise.lean
159
167
theorem bodd_neg (n : ℤ) : bodd (-n) = bodd n := by
cases n with | ofNat => rw [← negOfNat_eq, bodd_negOfNat] simp | negSucc n => rw [neg_negSucc, bodd_coe, Nat.bodd_succ] change (!Nat.bodd n) = !(bodd n) rw [bodd_coe]
import Mathlib.CategoryTheory.Adjunction.FullyFaithful import Mathlib.CategoryTheory.Conj import Mathlib.CategoryTheory.Functor.ReflectsIso #align_import category_theory.adjunction.reflective from "leanprover-community/mathlib"@"239d882c4fb58361ee8b3b39fb2091320edef10a" universe v₁ v₂ v₃ u₁ u₂ u₃ noncomputable section namespace CategoryTheory open Category Adjunction variable {C : Type u₁} {D : Type u₂} {E : Type u₃} variable [Category.{v₁} C] [Category.{v₂} D] [Category.{v₃} E] class Reflective (R : D ⥤ C) extends R.Full, R.Faithful where L : C ⥤ D adj : L ⊣ R #align category_theory.reflective CategoryTheory.Reflective variable (i : D ⥤ C) def reflector [Reflective i] : C ⥤ D := Reflective.L (R := i) def reflectorAdjunction [Reflective i] : reflector i ⊣ i := Reflective.adj instance [Reflective i] : i.IsRightAdjoint := ⟨_, ⟨reflectorAdjunction i⟩⟩ instance [Reflective i] : (reflector i).IsLeftAdjoint := ⟨_, ⟨reflectorAdjunction i⟩⟩ def Functor.fullyFaithfulOfReflective [Reflective i] : i.FullyFaithful := (reflectorAdjunction i).fullyFaithfulROfIsIsoCounit -- TODO: This holds more generally for idempotent adjunctions, not just reflective adjunctions. theorem unit_obj_eq_map_unit [Reflective i] (X : C) : (reflectorAdjunction i).unit.app (i.obj ((reflector i).obj X)) = i.map ((reflector i).map ((reflectorAdjunction i).unit.app X)) := by rw [← cancel_mono (i.map ((reflectorAdjunction i).counit.app ((reflector i).obj X))), ← i.map_comp] simp #align category_theory.unit_obj_eq_map_unit CategoryTheory.unit_obj_eq_map_unit example [Reflective i] {B : D} : IsIso ((reflectorAdjunction i).unit.app (i.obj B)) := inferInstance variable {i} theorem Functor.essImage.unit_isIso [Reflective i] {A : C} (h : A ∈ i.essImage) : IsIso ((reflectorAdjunction i).unit.app A) := by rwa [isIso_unit_app_iff_mem_essImage] #align category_theory.functor.ess_image.unit_is_iso CategoryTheory.Functor.essImage.unit_isIso theorem mem_essImage_of_unit_isIso {L : C ⥤ D} (adj : L ⊣ i) (A : C) [IsIso (adj.unit.app A)] : A ∈ i.essImage := ⟨L.obj A, ⟨(asIso (adj.unit.app A)).symm⟩⟩ #align category_theory.mem_ess_image_of_unit_is_iso CategoryTheory.mem_essImage_of_unit_isIso theorem mem_essImage_of_unit_isSplitMono [Reflective i] {A : C} [IsSplitMono ((reflectorAdjunction i).unit.app A)] : A ∈ i.essImage := by let η : 𝟭 C ⟶ reflector i ⋙ i := (reflectorAdjunction i).unit haveI : IsIso (η.app (i.obj ((reflector i).obj A))) := Functor.essImage.unit_isIso ((i.obj_mem_essImage _)) have : Epi (η.app A) := by refine @epi_of_epi _ _ _ _ _ (retraction (η.app A)) (η.app A) ?_ rw [show retraction _ ≫ η.app A = _ from η.naturality (retraction (η.app A))] apply epi_comp (η.app (i.obj ((reflector i).obj A))) haveI := isIso_of_epi_of_isSplitMono (η.app A) exact mem_essImage_of_unit_isIso (reflectorAdjunction i) A #align category_theory.mem_ess_image_of_unit_is_split_mono CategoryTheory.mem_essImage_of_unit_isSplitMono instance Reflective.comp (F : C ⥤ D) (G : D ⥤ E) [Reflective F] [Reflective G] : Reflective (F ⋙ G) where L := reflector G ⋙ reflector F adj := (reflectorAdjunction G).comp (reflectorAdjunction F) #align category_theory.reflective.comp CategoryTheory.Reflective.comp def unitCompPartialBijectiveAux [Reflective i] (A : C) (B : D) : (A ⟶ i.obj B) ≃ (i.obj ((reflector i).obj A) ⟶ i.obj B) := ((reflectorAdjunction i).homEquiv _ _).symm.trans (Functor.FullyFaithful.ofFullyFaithful i).homEquiv #align category_theory.unit_comp_partial_bijective_aux CategoryTheory.unitCompPartialBijectiveAux theorem unitCompPartialBijectiveAux_symm_apply [Reflective i] {A : C} {B : D} (f : i.obj ((reflector i).obj A) ⟶ i.obj B) : (unitCompPartialBijectiveAux _ _).symm f = (reflectorAdjunction i).unit.app A ≫ f := by simp [unitCompPartialBijectiveAux] #align category_theory.unit_comp_partial_bijective_aux_symm_apply CategoryTheory.unitCompPartialBijectiveAux_symm_apply def unitCompPartialBijective [Reflective i] (A : C) {B : C} (hB : B ∈ i.essImage) : (A ⟶ B) ≃ (i.obj ((reflector i).obj A) ⟶ B) := calc (A ⟶ B) ≃ (A ⟶ i.obj (Functor.essImage.witness hB)) := Iso.homCongr (Iso.refl _) hB.getIso.symm _ ≃ (i.obj _ ⟶ i.obj (Functor.essImage.witness hB)) := unitCompPartialBijectiveAux _ _ _ ≃ (i.obj ((reflector i).obj A) ⟶ B) := Iso.homCongr (Iso.refl _) (Functor.essImage.getIso hB) #align category_theory.unit_comp_partial_bijective CategoryTheory.unitCompPartialBijective @[simp] theorem unitCompPartialBijective_symm_apply [Reflective i] (A : C) {B : C} (hB : B ∈ i.essImage) (f) : (unitCompPartialBijective A hB).symm f = (reflectorAdjunction i).unit.app A ≫ f := by simp [unitCompPartialBijective, unitCompPartialBijectiveAux_symm_apply] #align category_theory.unit_comp_partial_bijective_symm_apply CategoryTheory.unitCompPartialBijective_symm_apply
Mathlib/CategoryTheory/Adjunction/Reflective.lean
159
162
theorem unitCompPartialBijective_symm_natural [Reflective i] (A : C) {B B' : C} (h : B ⟶ B') (hB : B ∈ i.essImage) (hB' : B' ∈ i.essImage) (f : i.obj ((reflector i).obj A) ⟶ B) : (unitCompPartialBijective A hB').symm (f ≫ h) = (unitCompPartialBijective A hB).symm f ≫ h := by
simp
import Mathlib.FieldTheory.SeparableClosure import Mathlib.Algebra.CharP.IntermediateField open FiniteDimensional Polynomial IntermediateField Field noncomputable section universe u v w variable (F : Type u) (E : Type v) [Field F] [Field E] [Algebra F E] variable (K : Type w) [Field K] [Algebra F K] section IsPurelyInseparable class IsPurelyInseparable : Prop where isIntegral : Algebra.IsIntegral F E inseparable' (x : E) : (minpoly F x).Separable → x ∈ (algebraMap F E).range attribute [instance] IsPurelyInseparable.isIntegral variable {E} in theorem IsPurelyInseparable.isIntegral' [IsPurelyInseparable F E] (x : E) : IsIntegral F x := Algebra.IsIntegral.isIntegral _ theorem IsPurelyInseparable.isAlgebraic [IsPurelyInseparable F E] : Algebra.IsAlgebraic F E := inferInstance variable {E} theorem IsPurelyInseparable.inseparable [IsPurelyInseparable F E] : ∀ x : E, (minpoly F x).Separable → x ∈ (algebraMap F E).range := IsPurelyInseparable.inseparable' variable {F K} theorem isPurelyInseparable_iff : IsPurelyInseparable F E ↔ ∀ x : E, IsIntegral F x ∧ ((minpoly F x).Separable → x ∈ (algebraMap F E).range) := ⟨fun h x ↦ ⟨h.isIntegral' x, h.inseparable' x⟩, fun h ↦ ⟨⟨fun x ↦ (h x).1⟩, fun x ↦ (h x).2⟩⟩ theorem AlgEquiv.isPurelyInseparable (e : K ≃ₐ[F] E) [IsPurelyInseparable F K] : IsPurelyInseparable F E := by refine ⟨⟨fun _ ↦ by rw [← isIntegral_algEquiv e.symm]; exact IsPurelyInseparable.isIntegral' F _⟩, fun x h ↦ ?_⟩ rw [← minpoly.algEquiv_eq e.symm] at h simpa only [RingHom.mem_range, algebraMap_eq_apply] using IsPurelyInseparable.inseparable F _ h theorem AlgEquiv.isPurelyInseparable_iff (e : K ≃ₐ[F] E) : IsPurelyInseparable F K ↔ IsPurelyInseparable F E := ⟨fun _ ↦ e.isPurelyInseparable, fun _ ↦ e.symm.isPurelyInseparable⟩ theorem Algebra.IsAlgebraic.isPurelyInseparable_of_isSepClosed [Algebra.IsAlgebraic F E] [IsSepClosed F] : IsPurelyInseparable F E := ⟨inferInstance, fun x h ↦ minpoly.mem_range_of_degree_eq_one F x <| IsSepClosed.degree_eq_one_of_irreducible F (minpoly.irreducible (Algebra.IsIntegral.isIntegral _)) h⟩ variable (F E K) theorem IsPurelyInseparable.surjective_algebraMap_of_isSeparable [IsPurelyInseparable F E] [IsSeparable F E] : Function.Surjective (algebraMap F E) := fun x ↦ IsPurelyInseparable.inseparable F x (IsSeparable.separable F x) theorem IsPurelyInseparable.bijective_algebraMap_of_isSeparable [IsPurelyInseparable F E] [IsSeparable F E] : Function.Bijective (algebraMap F E) := ⟨(algebraMap F E).injective, surjective_algebraMap_of_isSeparable F E⟩ variable {F E} in theorem IntermediateField.eq_bot_of_isPurelyInseparable_of_isSeparable (L : IntermediateField F E) [IsPurelyInseparable F L] [IsSeparable F L] : L = ⊥ := bot_unique fun x hx ↦ by obtain ⟨y, hy⟩ := IsPurelyInseparable.surjective_algebraMap_of_isSeparable F L ⟨x, hx⟩ exact ⟨y, congr_arg (algebraMap L E) hy⟩ theorem separableClosure.eq_bot_of_isPurelyInseparable [IsPurelyInseparable F E] : separableClosure F E = ⊥ := bot_unique fun x h ↦ IsPurelyInseparable.inseparable F x (mem_separableClosure_iff.1 h) variable {F E} in theorem separableClosure.eq_bot_iff [Algebra.IsAlgebraic F E] : separableClosure F E = ⊥ ↔ IsPurelyInseparable F E := ⟨fun h ↦ isPurelyInseparable_iff.2 fun x ↦ ⟨Algebra.IsIntegral.isIntegral x, fun hs ↦ by simpa only [h] using mem_separableClosure_iff.2 hs⟩, fun _ ↦ eq_bot_of_isPurelyInseparable F E⟩ instance isPurelyInseparable_self : IsPurelyInseparable F F := ⟨inferInstance, fun x _ ↦ ⟨x, rfl⟩⟩ variable {E}
Mathlib/FieldTheory/PurelyInseparable.lean
230
243
theorem isPurelyInseparable_iff_pow_mem (q : ℕ) [ExpChar F q] : IsPurelyInseparable F E ↔ ∀ x : E, ∃ n : ℕ, x ^ q ^ n ∈ (algebraMap F E).range := by
rw [isPurelyInseparable_iff] refine ⟨fun h x ↦ ?_, fun h x ↦ ?_⟩ · obtain ⟨g, h1, n, h2⟩ := (minpoly.irreducible (h x).1).hasSeparableContraction q exact ⟨n, (h _).2 <| h1.of_dvd <| minpoly.dvd F _ <| by simpa only [expand_aeval, minpoly.aeval] using congr_arg (aeval x) h2⟩ have hdeg := (minpoly.natSepDegree_eq_one_iff_pow_mem q).2 (h x) have halg : IsIntegral F x := by_contra fun h' ↦ by simp only [minpoly.eq_zero h', natSepDegree_zero, zero_ne_one] at hdeg refine ⟨halg, fun hsep ↦ ?_⟩ rw [hsep.natSepDegree_eq_natDegree, ← adjoin.finrank halg, IntermediateField.finrank_eq_one_iff] at hdeg simpa only [hdeg] using mem_adjoin_simple_self F x
import Mathlib.Control.Functor.Multivariate import Mathlib.Data.PFunctor.Univariate.Basic #align_import data.pfunctor.multivariate.basic from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d" universe u v open MvFunctor @[pp_with_univ] structure MvPFunctor (n : ℕ) where A : Type u B : A → TypeVec.{u} n #align mvpfunctor MvPFunctor namespace MvPFunctor open MvFunctor (LiftP LiftR) variable {n m : ℕ} (P : MvPFunctor.{u} n) @[coe] def Obj (α : TypeVec.{u} n) : Type u := Σ a : P.A, P.B a ⟹ α #align mvpfunctor.obj MvPFunctor.Obj instance : CoeFun (MvPFunctor.{u} n) (fun _ => TypeVec.{u} n → Type u) where coe := Obj def map {α β : TypeVec n} (f : α ⟹ β) : P α → P β := fun ⟨a, g⟩ => ⟨a, TypeVec.comp f g⟩ #align mvpfunctor.map MvPFunctor.map instance : Inhabited (MvPFunctor n) := ⟨⟨default, default⟩⟩ instance Obj.inhabited {α : TypeVec n} [Inhabited P.A] [∀ i, Inhabited (α i)] : Inhabited (P α) := ⟨⟨default, fun _ _ => default⟩⟩ #align mvpfunctor.obj.inhabited MvPFunctor.Obj.inhabited instance : MvFunctor.{u} P.Obj := ⟨@MvPFunctor.map n P⟩ theorem map_eq {α β : TypeVec n} (g : α ⟹ β) (a : P.A) (f : P.B a ⟹ α) : @MvFunctor.map _ P.Obj _ _ _ g ⟨a, f⟩ = ⟨a, g ⊚ f⟩ := rfl #align mvpfunctor.map_eq MvPFunctor.map_eq theorem id_map {α : TypeVec n} : ∀ x : P α, TypeVec.id <$$> x = x | ⟨_, _⟩ => rfl #align mvpfunctor.id_map MvPFunctor.id_map theorem comp_map {α β γ : TypeVec n} (f : α ⟹ β) (g : β ⟹ γ) : ∀ x : P α, (g ⊚ f) <$$> x = g <$$> f <$$> x | ⟨_, _⟩ => rfl #align mvpfunctor.comp_map MvPFunctor.comp_map instance : LawfulMvFunctor.{u} P.Obj where id_map := @id_map _ P comp_map := @comp_map _ P def const (n : ℕ) (A : Type u) : MvPFunctor n := { A B := fun _ _ => PEmpty } #align mvpfunctor.const MvPFunctor.const def comp (P : MvPFunctor.{u} n) (Q : Fin2 n → MvPFunctor.{u} m) : MvPFunctor m where A := Σ a₂ : P.1, ∀ i, P.2 a₂ i → (Q i).1 B a i := Σ(j : _) (b : P.2 a.1 j), (Q j).2 (a.snd j b) i #align mvpfunctor.comp MvPFunctor.comp variable {P} {Q : Fin2 n → MvPFunctor.{u} m} {α β : TypeVec.{u} m} def comp.mk (x : P (fun i => Q i α)) : comp P Q α := ⟨⟨x.1, fun _ a => (x.2 _ a).1⟩, fun i a => (x.snd a.fst a.snd.fst).snd i a.snd.snd⟩ #align mvpfunctor.comp.mk MvPFunctor.comp.mk def comp.get (x : comp P Q α) : P (fun i => Q i α) := ⟨x.1.1, fun i a => ⟨x.fst.snd i a, fun (j : Fin2 m) (b : (Q i).B _ j) => x.snd j ⟨i, ⟨a, b⟩⟩⟩⟩ #align mvpfunctor.comp.get MvPFunctor.comp.get theorem comp.get_map (f : α ⟹ β) (x : comp P Q α) : comp.get (f <$$> x) = (fun i (x : Q i α) => f <$$> x) <$$> comp.get x := by rfl #align mvpfunctor.comp.get_map MvPFunctor.comp.get_map @[simp] theorem comp.get_mk (x : P (fun i => Q i α)) : comp.get (comp.mk x) = x := by rfl #align mvpfunctor.comp.get_mk MvPFunctor.comp.get_mk @[simp] theorem comp.mk_get (x : comp P Q α) : comp.mk (comp.get x) = x := by rfl #align mvpfunctor.comp.mk_get MvPFunctor.comp.mk_get
Mathlib/Data/PFunctor/Multivariate/Basic.lean
160
170
theorem liftP_iff {α : TypeVec n} (p : ∀ ⦃i⦄, α i → Prop) (x : P α) : LiftP p x ↔ ∃ a f, x = ⟨a, f⟩ ∧ ∀ i j, p (f i j) := by
constructor · rintro ⟨y, hy⟩ cases' h : y with a f refine ⟨a, fun i j => (f i j).val, ?_, fun i j => (f i j).property⟩ rw [← hy, h, map_eq] rfl rintro ⟨a, f, xeq, pf⟩ use ⟨a, fun i j => ⟨f i j, pf i j⟩⟩ rw [xeq]; rfl
import Mathlib.Algebra.MvPolynomial.PDeriv import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Data.Nat.Choose.Sum import Mathlib.LinearAlgebra.LinearIndependent import Mathlib.RingTheory.Polynomial.Pochhammer #align_import ring_theory.polynomial.bernstein from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821" noncomputable section open Nat (choose) open Polynomial (X) open scoped Polynomial variable (R : Type*) [CommRing R] def bernsteinPolynomial (n ν : ℕ) : R[X] := (choose n ν : R[X]) * X ^ ν * (1 - X) ^ (n - ν) #align bernstein_polynomial bernsteinPolynomial example : bernsteinPolynomial ℤ 3 2 = 3 * X ^ 2 - 3 * X ^ 3 := by norm_num [bernsteinPolynomial, choose] ring namespace bernsteinPolynomial theorem eq_zero_of_lt {n ν : ℕ} (h : n < ν) : bernsteinPolynomial R n ν = 0 := by simp [bernsteinPolynomial, Nat.choose_eq_zero_of_lt h] #align bernstein_polynomial.eq_zero_of_lt bernsteinPolynomial.eq_zero_of_lt section variable {R} {S : Type*} [CommRing S] @[simp] theorem map (f : R →+* S) (n ν : ℕ) : (bernsteinPolynomial R n ν).map f = bernsteinPolynomial S n ν := by simp [bernsteinPolynomial] #align bernstein_polynomial.map bernsteinPolynomial.map end theorem flip (n ν : ℕ) (h : ν ≤ n) : (bernsteinPolynomial R n ν).comp (1 - X) = bernsteinPolynomial R n (n - ν) := by simp [bernsteinPolynomial, h, tsub_tsub_assoc, mul_right_comm] #align bernstein_polynomial.flip bernsteinPolynomial.flip theorem flip' (n ν : ℕ) (h : ν ≤ n) : bernsteinPolynomial R n ν = (bernsteinPolynomial R n (n - ν)).comp (1 - X) := by simp [← flip _ _ _ h, Polynomial.comp_assoc] #align bernstein_polynomial.flip' bernsteinPolynomial.flip' theorem eval_at_0 (n ν : ℕ) : (bernsteinPolynomial R n ν).eval 0 = if ν = 0 then 1 else 0 := by rw [bernsteinPolynomial] split_ifs with h · subst h; simp · simp [zero_pow h] #align bernstein_polynomial.eval_at_0 bernsteinPolynomial.eval_at_0 theorem eval_at_1 (n ν : ℕ) : (bernsteinPolynomial R n ν).eval 1 = if ν = n then 1 else 0 := by rw [bernsteinPolynomial] split_ifs with h · subst h; simp · obtain hνn | hnν := Ne.lt_or_lt h · simp [zero_pow $ Nat.sub_ne_zero_of_lt hνn] · simp [Nat.choose_eq_zero_of_lt hnν] #align bernstein_polynomial.eval_at_1 bernsteinPolynomial.eval_at_1 theorem derivative_succ_aux (n ν : ℕ) : Polynomial.derivative (bernsteinPolynomial R (n + 1) (ν + 1)) = (n + 1) * (bernsteinPolynomial R n ν - bernsteinPolynomial R n (ν + 1)) := by rw [bernsteinPolynomial] suffices ((n + 1).choose (ν + 1) : R[X]) * ((↑(ν + 1 : ℕ) : R[X]) * X ^ ν) * (1 - X) ^ (n - ν) - ((n + 1).choose (ν + 1) : R[X]) * X ^ (ν + 1) * ((↑(n - ν) : R[X]) * (1 - X) ^ (n - ν - 1)) = (↑(n + 1) : R[X]) * ((n.choose ν : R[X]) * X ^ ν * (1 - X) ^ (n - ν) - (n.choose (ν + 1) : R[X]) * X ^ (ν + 1) * (1 - X) ^ (n - (ν + 1))) by simpa [Polynomial.derivative_pow, ← sub_eq_add_neg, Nat.succ_sub_succ_eq_sub, Polynomial.derivative_mul, Polynomial.derivative_natCast, zero_mul, Nat.cast_add, algebraMap.coe_one, Polynomial.derivative_X, mul_one, zero_add, Polynomial.derivative_sub, Polynomial.derivative_one, zero_sub, mul_neg, Nat.sub_zero, bernsteinPolynomial, map_add, map_natCast, Nat.cast_one] conv_rhs => rw [mul_sub] -- We'll prove the two terms match up separately. refine congr (congr_arg Sub.sub ?_) ?_ · simp only [← mul_assoc] apply congr (congr_arg (· * ·) (congr (congr_arg (· * ·) _) rfl)) rfl -- Now it's just about binomial coefficients exact mod_cast congr_arg (fun m : ℕ => (m : R[X])) (Nat.succ_mul_choose_eq n ν).symm · rw [← tsub_add_eq_tsub_tsub, ← mul_assoc, ← mul_assoc]; congr 1 rw [mul_comm, ← mul_assoc, ← mul_assoc]; congr 1 norm_cast congr 1 convert (Nat.choose_mul_succ_eq n (ν + 1)).symm using 1 · -- Porting note: was -- convert mul_comm _ _ using 2 -- simp rw [mul_comm, Nat.succ_sub_succ_eq_sub] · apply mul_comm #align bernstein_polynomial.derivative_succ_aux bernsteinPolynomial.derivative_succ_aux theorem derivative_succ (n ν : ℕ) : Polynomial.derivative (bernsteinPolynomial R n (ν + 1)) = n * (bernsteinPolynomial R (n - 1) ν - bernsteinPolynomial R (n - 1) (ν + 1)) := by cases n · simp [bernsteinPolynomial] · rw [Nat.cast_succ]; apply derivative_succ_aux #align bernstein_polynomial.derivative_succ bernsteinPolynomial.derivative_succ theorem derivative_zero (n : ℕ) : Polynomial.derivative (bernsteinPolynomial R n 0) = -n * bernsteinPolynomial R (n - 1) 0 := by simp [bernsteinPolynomial, Polynomial.derivative_pow] #align bernstein_polynomial.derivative_zero bernsteinPolynomial.derivative_zero theorem iterate_derivative_at_0_eq_zero_of_lt (n : ℕ) {ν k : ℕ} : k < ν → (Polynomial.derivative^[k] (bernsteinPolynomial R n ν)).eval 0 = 0 := by cases' ν with ν · rintro ⟨⟩ · rw [Nat.lt_succ_iff] induction' k with k ih generalizing n ν · simp [eval_at_0] · simp only [derivative_succ, Int.natCast_eq_zero, mul_eq_zero, Function.comp_apply, Function.iterate_succ, Polynomial.iterate_derivative_sub, Polynomial.iterate_derivative_natCast_mul, Polynomial.eval_mul, Polynomial.eval_natCast, Polynomial.eval_sub] intro h apply mul_eq_zero_of_right rw [ih _ _ (Nat.le_of_succ_le h), sub_zero] convert ih _ _ (Nat.pred_le_pred h) exact (Nat.succ_pred_eq_of_pos (k.succ_pos.trans_le h)).symm #align bernstein_polynomial.iterate_derivative_at_0_eq_zero_of_lt bernsteinPolynomial.iterate_derivative_at_0_eq_zero_of_lt @[simp] theorem iterate_derivative_succ_at_0_eq_zero (n ν : ℕ) : (Polynomial.derivative^[ν] (bernsteinPolynomial R n (ν + 1))).eval 0 = 0 := iterate_derivative_at_0_eq_zero_of_lt R n (lt_add_one ν) #align bernstein_polynomial.iterate_derivative_succ_at_0_eq_zero bernsteinPolynomial.iterate_derivative_succ_at_0_eq_zero open Polynomial @[simp] theorem iterate_derivative_at_0 (n ν : ℕ) : (Polynomial.derivative^[ν] (bernsteinPolynomial R n ν)).eval 0 = (ascPochhammer R ν).eval ((n - (ν - 1) : ℕ) : R) := by by_cases h : ν ≤ n · induction' ν with ν ih generalizing n · simp [eval_at_0] · have h' : ν ≤ n - 1 := le_tsub_of_add_le_right h simp only [derivative_succ, ih (n - 1) h', iterate_derivative_succ_at_0_eq_zero, Nat.succ_sub_succ_eq_sub, tsub_zero, sub_zero, iterate_derivative_sub, iterate_derivative_natCast_mul, eval_one, eval_mul, eval_add, eval_sub, eval_X, eval_comp, eval_natCast, Function.comp_apply, Function.iterate_succ, ascPochhammer_succ_left] obtain rfl | h'' := ν.eq_zero_or_pos · simp · have : n - 1 - (ν - 1) = n - ν := by rw [gt_iff_lt, ← Nat.succ_le_iff] at h'' rw [← tsub_add_eq_tsub_tsub, add_comm, tsub_add_cancel_of_le h''] rw [this, ascPochhammer_eval_succ] rw_mod_cast [tsub_add_cancel_of_le (h'.trans n.pred_le)] · simp only [not_le] at h rw [tsub_eq_zero_iff_le.mpr (Nat.le_sub_one_of_lt h), eq_zero_of_lt R h] simp [pos_iff_ne_zero.mp (pos_of_gt h)] #align bernstein_polynomial.iterate_derivative_at_0 bernsteinPolynomial.iterate_derivative_at_0 theorem iterate_derivative_at_0_ne_zero [CharZero R] (n ν : ℕ) (h : ν ≤ n) : (Polynomial.derivative^[ν] (bernsteinPolynomial R n ν)).eval 0 ≠ 0 := by simp only [Int.natCast_eq_zero, bernsteinPolynomial.iterate_derivative_at_0, Ne, Nat.cast_eq_zero] simp only [← ascPochhammer_eval_cast] norm_cast apply ne_of_gt obtain rfl | h' := Nat.eq_zero_or_pos ν · simp · rw [← Nat.succ_pred_eq_of_pos h'] at h exact ascPochhammer_pos _ _ (tsub_pos_of_lt (Nat.lt_of_succ_le h)) #align bernstein_polynomial.iterate_derivative_at_0_ne_zero bernsteinPolynomial.iterate_derivative_at_0_ne_zero theorem iterate_derivative_at_1_eq_zero_of_lt (n : ℕ) {ν k : ℕ} : k < n - ν → (Polynomial.derivative^[k] (bernsteinPolynomial R n ν)).eval 1 = 0 := by intro w rw [flip' _ _ _ (tsub_pos_iff_lt.mp (pos_of_gt w)).le] simp [Polynomial.eval_comp, iterate_derivative_at_0_eq_zero_of_lt R n w] #align bernstein_polynomial.iterate_derivative_at_1_eq_zero_of_lt bernsteinPolynomial.iterate_derivative_at_1_eq_zero_of_lt @[simp] theorem iterate_derivative_at_1 (n ν : ℕ) (h : ν ≤ n) : (Polynomial.derivative^[n - ν] (bernsteinPolynomial R n ν)).eval 1 = (-1) ^ (n - ν) * (ascPochhammer R (n - ν)).eval (ν + 1 : R) := by rw [flip' _ _ _ h] simp [Polynomial.eval_comp, h] obtain rfl | h' := h.eq_or_lt · simp · norm_cast congr omega #align bernstein_polynomial.iterate_derivative_at_1 bernsteinPolynomial.iterate_derivative_at_1 theorem iterate_derivative_at_1_ne_zero [CharZero R] (n ν : ℕ) (h : ν ≤ n) : (Polynomial.derivative^[n - ν] (bernsteinPolynomial R n ν)).eval 1 ≠ 0 := by rw [bernsteinPolynomial.iterate_derivative_at_1 _ _ _ h, Ne, neg_one_pow_mul_eq_zero_iff, ← Nat.cast_succ, ← ascPochhammer_eval_cast, ← Nat.cast_zero, Nat.cast_inj] exact (ascPochhammer_pos _ _ (Nat.succ_pos ν)).ne' #align bernstein_polynomial.iterate_derivative_at_1_ne_zero bernsteinPolynomial.iterate_derivative_at_1_ne_zero open Submodule theorem linearIndependent_aux (n k : ℕ) (h : k ≤ n + 1) : LinearIndependent ℚ fun ν : Fin k => bernsteinPolynomial ℚ n ν := by induction' k with k ih · apply linearIndependent_empty_type · apply linearIndependent_fin_succ'.mpr fconstructor · exact ih (le_of_lt h) · -- The actual work! -- We show that the (n-k)-th derivative at 1 doesn't vanish, -- but vanishes for everything in the span. clear ih simp only [Nat.succ_eq_add_one, add_le_add_iff_right] at h simp only [Fin.val_last, Fin.init_def] dsimp apply not_mem_span_of_apply_not_mem_span_image (@Polynomial.derivative ℚ _ ^ (n - k)) -- Note: #8386 had to change `span_image` into `span_image _` simp only [not_exists, not_and, Submodule.mem_map, Submodule.span_image _] intro p m apply_fun Polynomial.eval (1 : ℚ) simp only [LinearMap.pow_apply] -- The right hand side is nonzero, -- so it will suffice to show the left hand side is always zero. suffices (Polynomial.derivative^[n - k] p).eval 1 = 0 by rw [this] exact (iterate_derivative_at_1_ne_zero ℚ n k h).symm refine span_induction m ?_ ?_ ?_ ?_ · simp rintro ⟨a, w⟩; simp only [Fin.val_mk] rw [iterate_derivative_at_1_eq_zero_of_lt ℚ n ((tsub_lt_tsub_iff_left_of_le h).mpr w)] · simp · intro x y hx hy; simp [hx, hy] · intro a x h; simp [h] #align bernstein_polynomial.linear_independent_aux bernsteinPolynomial.linearIndependent_aux theorem linearIndependent (n : ℕ) : LinearIndependent ℚ fun ν : Fin (n + 1) => bernsteinPolynomial ℚ n ν := linearIndependent_aux n (n + 1) le_rfl #align bernstein_polynomial.linear_independent bernsteinPolynomial.linearIndependent
Mathlib/RingTheory/Polynomial/Bernstein.lean
289
294
theorem sum (n : ℕ) : (∑ ν ∈ Finset.range (n + 1), bernsteinPolynomial R n ν) = 1 := calc (∑ ν ∈ Finset.range (n + 1), bernsteinPolynomial R n ν) = (X + (1 - X)) ^ n := by
rw [add_pow] simp only [bernsteinPolynomial, mul_comm, mul_assoc, mul_left_comm] _ = 1 := by simp
import Mathlib.MeasureTheory.Constructions.Prod.Basic import Mathlib.MeasureTheory.Integral.DominatedConvergence import Mathlib.MeasureTheory.Integral.SetIntegral #align_import measure_theory.constructions.prod.integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" noncomputable section open scoped Classical Topology ENNReal MeasureTheory open Set Function Real ENNReal open MeasureTheory MeasurableSpace MeasureTheory.Measure open TopologicalSpace open Filter hiding prod_eq map variable {α α' β β' γ E : Type*} variable [MeasurableSpace α] [MeasurableSpace α'] [MeasurableSpace β] [MeasurableSpace β'] variable [MeasurableSpace γ] variable {μ μ' : Measure α} {ν ν' : Measure β} {τ : Measure γ} variable [NormedAddCommGroup E] theorem measurableSet_integrable [SigmaFinite ν] ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) : MeasurableSet {x | Integrable (f x) ν} := by simp_rw [Integrable, hf.of_uncurry_left.aestronglyMeasurable, true_and_iff] exact measurableSet_lt (Measurable.lintegral_prod_right hf.ennnorm) measurable_const #align measurable_set_integrable measurableSet_integrable section variable [NormedSpace ℝ E] theorem MeasureTheory.StronglyMeasurable.integral_prod_right [SigmaFinite ν] ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun x => ∫ y, f x y ∂ν := by by_cases hE : CompleteSpace E; swap; · simp [integral, hE, stronglyMeasurable_const] borelize E haveI : SeparableSpace (range (uncurry f) ∪ {0} : Set E) := hf.separableSpace_range_union_singleton let s : ℕ → SimpleFunc (α × β) E := SimpleFunc.approxOn _ hf.measurable (range (uncurry f) ∪ {0}) 0 (by simp) let s' : ℕ → α → SimpleFunc β E := fun n x => (s n).comp (Prod.mk x) measurable_prod_mk_left let f' : ℕ → α → E := fun n => {x | Integrable (f x) ν}.indicator fun x => (s' n x).integral ν have hf' : ∀ n, StronglyMeasurable (f' n) := by intro n; refine StronglyMeasurable.indicator ?_ (measurableSet_integrable hf) have : ∀ x, ((s' n x).range.filter fun x => x ≠ 0) ⊆ (s n).range := by intro x; refine Finset.Subset.trans (Finset.filter_subset _ _) ?_; intro y simp_rw [SimpleFunc.mem_range]; rintro ⟨z, rfl⟩; exact ⟨(x, z), rfl⟩ simp only [SimpleFunc.integral_eq_sum_of_subset (this _)] refine Finset.stronglyMeasurable_sum _ fun x _ => ?_ refine (Measurable.ennreal_toReal ?_).stronglyMeasurable.smul_const _ simp only [s', SimpleFunc.coe_comp, preimage_comp] apply measurable_measure_prod_mk_left exact (s n).measurableSet_fiber x have h2f' : Tendsto f' atTop (𝓝 fun x : α => ∫ y : β, f x y ∂ν) := by rw [tendsto_pi_nhds]; intro x by_cases hfx : Integrable (f x) ν · have (n) : Integrable (s' n x) ν := by apply (hfx.norm.add hfx.norm).mono' (s' n x).aestronglyMeasurable filter_upwards with y simp_rw [s', SimpleFunc.coe_comp]; exact SimpleFunc.norm_approxOn_zero_le _ _ (x, y) n simp only [f', hfx, SimpleFunc.integral_eq_integral _ (this _), indicator_of_mem, mem_setOf_eq] refine tendsto_integral_of_dominated_convergence (fun y => ‖f x y‖ + ‖f x y‖) (fun n => (s' n x).aestronglyMeasurable) (hfx.norm.add hfx.norm) ?_ ?_ · refine fun n => eventually_of_forall fun y => SimpleFunc.norm_approxOn_zero_le ?_ ?_ (x, y) n -- Porting note: Lean 3 solved the following two subgoals on its own · exact hf.measurable · simp · refine eventually_of_forall fun y => SimpleFunc.tendsto_approxOn ?_ ?_ ?_ -- Porting note: Lean 3 solved the following two subgoals on its own · exact hf.measurable.of_uncurry_left · simp apply subset_closure simp [-uncurry_apply_pair] · simp [f', hfx, integral_undef] exact stronglyMeasurable_of_tendsto _ hf' h2f' #align measure_theory.strongly_measurable.integral_prod_right MeasureTheory.StronglyMeasurable.integral_prod_right theorem MeasureTheory.StronglyMeasurable.integral_prod_right' [SigmaFinite ν] ⦃f : α × β → E⦄ (hf : StronglyMeasurable f) : StronglyMeasurable fun x => ∫ y, f (x, y) ∂ν := by rw [← uncurry_curry f] at hf; exact hf.integral_prod_right #align measure_theory.strongly_measurable.integral_prod_right' MeasureTheory.StronglyMeasurable.integral_prod_right' theorem MeasureTheory.StronglyMeasurable.integral_prod_left [SigmaFinite μ] ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun y => ∫ x, f x y ∂μ := (hf.comp_measurable measurable_swap).integral_prod_right' #align measure_theory.strongly_measurable.integral_prod_left MeasureTheory.StronglyMeasurable.integral_prod_left theorem MeasureTheory.StronglyMeasurable.integral_prod_left' [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : StronglyMeasurable f) : StronglyMeasurable fun y => ∫ x, f (x, y) ∂μ := (hf.comp_measurable measurable_swap).integral_prod_right' #align measure_theory.strongly_measurable.integral_prod_left' MeasureTheory.StronglyMeasurable.integral_prod_left' end open MeasureTheory.Measure section nonrec theorem MeasureTheory.AEStronglyMeasurable.prod_swap {γ : Type*} [TopologicalSpace γ] [SigmaFinite μ] [SigmaFinite ν] {f : β × α → γ} (hf : AEStronglyMeasurable f (ν.prod μ)) : AEStronglyMeasurable (fun z : α × β => f z.swap) (μ.prod ν) := by rw [← prod_swap] at hf exact hf.comp_measurable measurable_swap #align measure_theory.ae_strongly_measurable.prod_swap MeasureTheory.AEStronglyMeasurable.prod_swap theorem MeasureTheory.AEStronglyMeasurable.fst {γ} [TopologicalSpace γ] [SigmaFinite ν] {f : α → γ} (hf : AEStronglyMeasurable f μ) : AEStronglyMeasurable (fun z : α × β => f z.1) (μ.prod ν) := hf.comp_quasiMeasurePreserving quasiMeasurePreserving_fst #align measure_theory.ae_strongly_measurable.fst MeasureTheory.AEStronglyMeasurable.fst theorem MeasureTheory.AEStronglyMeasurable.snd {γ} [TopologicalSpace γ] [SigmaFinite ν] {f : β → γ} (hf : AEStronglyMeasurable f ν) : AEStronglyMeasurable (fun z : α × β => f z.2) (μ.prod ν) := hf.comp_quasiMeasurePreserving quasiMeasurePreserving_snd #align measure_theory.ae_strongly_measurable.snd MeasureTheory.AEStronglyMeasurable.snd theorem MeasureTheory.AEStronglyMeasurable.integral_prod_right' [SigmaFinite ν] [NormedSpace ℝ E] ⦃f : α × β → E⦄ (hf : AEStronglyMeasurable f (μ.prod ν)) : AEStronglyMeasurable (fun x => ∫ y, f (x, y) ∂ν) μ := ⟨fun x => ∫ y, hf.mk f (x, y) ∂ν, hf.stronglyMeasurable_mk.integral_prod_right', by filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with _ hx using integral_congr_ae hx⟩ #align measure_theory.ae_strongly_measurable.integral_prod_right' MeasureTheory.AEStronglyMeasurable.integral_prod_right' theorem MeasureTheory.AEStronglyMeasurable.prod_mk_left {γ : Type*} [SigmaFinite ν] [TopologicalSpace γ] {f : α × β → γ} (hf : AEStronglyMeasurable f (μ.prod ν)) : ∀ᵐ x ∂μ, AEStronglyMeasurable (fun y => f (x, y)) ν := by filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with x hx exact ⟨fun y => hf.mk f (x, y), hf.stronglyMeasurable_mk.comp_measurable measurable_prod_mk_left, hx⟩ #align measure_theory.ae_strongly_measurable.prod_mk_left MeasureTheory.AEStronglyMeasurable.prod_mk_left end namespace MeasureTheory variable [SigmaFinite ν] section theorem integrable_swap_iff [SigmaFinite μ] {f : α × β → E} : Integrable (f ∘ Prod.swap) (ν.prod μ) ↔ Integrable f (μ.prod ν) := measurePreserving_swap.integrable_comp_emb MeasurableEquiv.prodComm.measurableEmbedding #align measure_theory.integrable_swap_iff MeasureTheory.integrable_swap_iff theorem Integrable.swap [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : Integrable (f ∘ Prod.swap) (ν.prod μ) := integrable_swap_iff.2 hf #align measure_theory.integrable.swap MeasureTheory.Integrable.swap theorem hasFiniteIntegral_prod_iff ⦃f : α × β → E⦄ (h1f : StronglyMeasurable f) : HasFiniteIntegral f (μ.prod ν) ↔ (∀ᵐ x ∂μ, HasFiniteIntegral (fun y => f (x, y)) ν) ∧ HasFiniteIntegral (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ := by simp only [HasFiniteIntegral, lintegral_prod_of_measurable _ h1f.ennnorm] have (x) : ∀ᵐ y ∂ν, 0 ≤ ‖f (x, y)‖ := by filter_upwards with y using norm_nonneg _ simp_rw [integral_eq_lintegral_of_nonneg_ae (this _) (h1f.norm.comp_measurable measurable_prod_mk_left).aestronglyMeasurable, ennnorm_eq_ofReal toReal_nonneg, ofReal_norm_eq_coe_nnnorm] -- this fact is probably too specialized to be its own lemma have : ∀ {p q r : Prop} (_ : r → p), (r ↔ p ∧ q) ↔ p → (r ↔ q) := fun {p q r} h1 => by rw [← and_congr_right_iff, and_iff_right_of_imp h1] rw [this] · intro h2f; rw [lintegral_congr_ae] filter_upwards [h2f] with x hx rw [ofReal_toReal]; rw [← lt_top_iff_ne_top]; exact hx · intro h2f; refine ae_lt_top ?_ h2f.ne; exact h1f.ennnorm.lintegral_prod_right' #align measure_theory.has_finite_integral_prod_iff MeasureTheory.hasFiniteIntegral_prod_iff theorem hasFiniteIntegral_prod_iff' ⦃f : α × β → E⦄ (h1f : AEStronglyMeasurable f (μ.prod ν)) : HasFiniteIntegral f (μ.prod ν) ↔ (∀ᵐ x ∂μ, HasFiniteIntegral (fun y => f (x, y)) ν) ∧ HasFiniteIntegral (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ := by rw [hasFiniteIntegral_congr h1f.ae_eq_mk, hasFiniteIntegral_prod_iff h1f.stronglyMeasurable_mk] apply and_congr · apply eventually_congr filter_upwards [ae_ae_of_ae_prod h1f.ae_eq_mk.symm] intro x hx exact hasFiniteIntegral_congr hx · apply hasFiniteIntegral_congr filter_upwards [ae_ae_of_ae_prod h1f.ae_eq_mk.symm] with _ hx using integral_congr_ae (EventuallyEq.fun_comp hx _) #align measure_theory.has_finite_integral_prod_iff' MeasureTheory.hasFiniteIntegral_prod_iff' theorem integrable_prod_iff ⦃f : α × β → E⦄ (h1f : AEStronglyMeasurable f (μ.prod ν)) : Integrable f (μ.prod ν) ↔ (∀ᵐ x ∂μ, Integrable (fun y => f (x, y)) ν) ∧ Integrable (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ := by simp [Integrable, h1f, hasFiniteIntegral_prod_iff', h1f.norm.integral_prod_right', h1f.prod_mk_left] #align measure_theory.integrable_prod_iff MeasureTheory.integrable_prod_iff theorem integrable_prod_iff' [SigmaFinite μ] ⦃f : α × β → E⦄ (h1f : AEStronglyMeasurable f (μ.prod ν)) : Integrable f (μ.prod ν) ↔ (∀ᵐ y ∂ν, Integrable (fun x => f (x, y)) μ) ∧ Integrable (fun y => ∫ x, ‖f (x, y)‖ ∂μ) ν := by convert integrable_prod_iff h1f.prod_swap using 1 rw [funext fun _ => Function.comp_apply.symm, integrable_swap_iff] #align measure_theory.integrable_prod_iff' MeasureTheory.integrable_prod_iff' theorem Integrable.prod_left_ae [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : ∀ᵐ y ∂ν, Integrable (fun x => f (x, y)) μ := ((integrable_prod_iff' hf.aestronglyMeasurable).mp hf).1 #align measure_theory.integrable.prod_left_ae MeasureTheory.Integrable.prod_left_ae theorem Integrable.prod_right_ae [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : ∀ᵐ x ∂μ, Integrable (fun y => f (x, y)) ν := hf.swap.prod_left_ae #align measure_theory.integrable.prod_right_ae MeasureTheory.Integrable.prod_right_ae theorem Integrable.integral_norm_prod_left ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : Integrable (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ := ((integrable_prod_iff hf.aestronglyMeasurable).mp hf).2 #align measure_theory.integrable.integral_norm_prod_left MeasureTheory.Integrable.integral_norm_prod_left theorem Integrable.integral_norm_prod_right [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : Integrable (fun y => ∫ x, ‖f (x, y)‖ ∂μ) ν := hf.swap.integral_norm_prod_left #align measure_theory.integrable.integral_norm_prod_right MeasureTheory.Integrable.integral_norm_prod_right theorem Integrable.prod_smul {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] {f : α → 𝕜} {g : β → E} (hf : Integrable f μ) (hg : Integrable g ν) : Integrable (fun z : α × β => f z.1 • g z.2) (μ.prod ν) := by refine (integrable_prod_iff ?_).2 ⟨?_, ?_⟩ · exact hf.1.fst.smul hg.1.snd · exact eventually_of_forall fun x => hg.smul (f x) · simpa only [norm_smul, integral_mul_left] using hf.norm.mul_const _ theorem Integrable.prod_mul {L : Type*} [RCLike L] {f : α → L} {g : β → L} (hf : Integrable f μ) (hg : Integrable g ν) : Integrable (fun z : α × β => f z.1 * g z.2) (μ.prod ν) := hf.prod_smul hg #align measure_theory.integrable_prod_mul MeasureTheory.Integrable.prod_mul end variable [NormedSpace ℝ E] theorem Integrable.integral_prod_left ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : Integrable (fun x => ∫ y, f (x, y) ∂ν) μ := Integrable.mono hf.integral_norm_prod_left hf.aestronglyMeasurable.integral_prod_right' <| eventually_of_forall fun x => (norm_integral_le_integral_norm _).trans_eq <| (norm_of_nonneg <| integral_nonneg_of_ae <| eventually_of_forall fun y => (norm_nonneg (f (x, y)) : _)).symm #align measure_theory.integrable.integral_prod_left MeasureTheory.Integrable.integral_prod_left theorem Integrable.integral_prod_right [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : Integrable (fun y => ∫ x, f (x, y) ∂μ) ν := hf.swap.integral_prod_left #align measure_theory.integrable.integral_prod_right MeasureTheory.Integrable.integral_prod_right variable [SigmaFinite μ] theorem integral_prod_swap (f : α × β → E) : ∫ z, f z.swap ∂ν.prod μ = ∫ z, f z ∂μ.prod ν := measurePreserving_swap.integral_comp MeasurableEquiv.prodComm.measurableEmbedding _ #align measure_theory.integral_prod_swap MeasureTheory.integral_prod_swap variable {E' : Type*} [NormedAddCommGroup E'] [NormedSpace ℝ E'] theorem integral_fn_integral_add ⦃f g : α × β → E⦄ (F : E → E') (hf : Integrable f (μ.prod ν)) (hg : Integrable g (μ.prod ν)) : (∫ x, F (∫ y, f (x, y) + g (x, y) ∂ν) ∂μ) = ∫ x, F ((∫ y, f (x, y) ∂ν) + ∫ y, g (x, y) ∂ν) ∂μ := by refine integral_congr_ae ?_ filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g simp [integral_add h2f h2g] #align measure_theory.integral_fn_integral_add MeasureTheory.integral_fn_integral_add theorem integral_fn_integral_sub ⦃f g : α × β → E⦄ (F : E → E') (hf : Integrable f (μ.prod ν)) (hg : Integrable g (μ.prod ν)) : (∫ x, F (∫ y, f (x, y) - g (x, y) ∂ν) ∂μ) = ∫ x, F ((∫ y, f (x, y) ∂ν) - ∫ y, g (x, y) ∂ν) ∂μ := by refine integral_congr_ae ?_ filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g simp [integral_sub h2f h2g] #align measure_theory.integral_fn_integral_sub MeasureTheory.integral_fn_integral_sub theorem lintegral_fn_integral_sub ⦃f g : α × β → E⦄ (F : E → ℝ≥0∞) (hf : Integrable f (μ.prod ν)) (hg : Integrable g (μ.prod ν)) : (∫⁻ x, F (∫ y, f (x, y) - g (x, y) ∂ν) ∂μ) = ∫⁻ x, F ((∫ y, f (x, y) ∂ν) - ∫ y, g (x, y) ∂ν) ∂μ := by refine lintegral_congr_ae ?_ filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g simp [integral_sub h2f h2g] #align measure_theory.lintegral_fn_integral_sub MeasureTheory.lintegral_fn_integral_sub theorem integral_integral_add ⦃f g : α × β → E⦄ (hf : Integrable f (μ.prod ν)) (hg : Integrable g (μ.prod ν)) : (∫ x, ∫ y, f (x, y) + g (x, y) ∂ν ∂μ) = (∫ x, ∫ y, f (x, y) ∂ν ∂μ) + ∫ x, ∫ y, g (x, y) ∂ν ∂μ := (integral_fn_integral_add id hf hg).trans <| integral_add hf.integral_prod_left hg.integral_prod_left #align measure_theory.integral_integral_add MeasureTheory.integral_integral_add theorem integral_integral_add' ⦃f g : α × β → E⦄ (hf : Integrable f (μ.prod ν)) (hg : Integrable g (μ.prod ν)) : (∫ x, ∫ y, (f + g) (x, y) ∂ν ∂μ) = (∫ x, ∫ y, f (x, y) ∂ν ∂μ) + ∫ x, ∫ y, g (x, y) ∂ν ∂μ := integral_integral_add hf hg #align measure_theory.integral_integral_add' MeasureTheory.integral_integral_add' theorem integral_integral_sub ⦃f g : α × β → E⦄ (hf : Integrable f (μ.prod ν)) (hg : Integrable g (μ.prod ν)) : (∫ x, ∫ y, f (x, y) - g (x, y) ∂ν ∂μ) = (∫ x, ∫ y, f (x, y) ∂ν ∂μ) - ∫ x, ∫ y, g (x, y) ∂ν ∂μ := (integral_fn_integral_sub id hf hg).trans <| integral_sub hf.integral_prod_left hg.integral_prod_left #align measure_theory.integral_integral_sub MeasureTheory.integral_integral_sub theorem integral_integral_sub' ⦃f g : α × β → E⦄ (hf : Integrable f (μ.prod ν)) (hg : Integrable g (μ.prod ν)) : (∫ x, ∫ y, (f - g) (x, y) ∂ν ∂μ) = (∫ x, ∫ y, f (x, y) ∂ν ∂μ) - ∫ x, ∫ y, g (x, y) ∂ν ∂μ := integral_integral_sub hf hg #align measure_theory.integral_integral_sub' MeasureTheory.integral_integral_sub' theorem continuous_integral_integral : Continuous fun f : α × β →₁[μ.prod ν] E => ∫ x, ∫ y, f (x, y) ∂ν ∂μ := by rw [continuous_iff_continuousAt]; intro g refine tendsto_integral_of_L1 _ (L1.integrable_coeFn g).integral_prod_left (eventually_of_forall fun h => (L1.integrable_coeFn h).integral_prod_left) ?_ simp_rw [← lintegral_fn_integral_sub (fun x => (‖x‖₊ : ℝ≥0∞)) (L1.integrable_coeFn _) (L1.integrable_coeFn g)] apply tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds _ (fun i => zero_le _) _ · exact fun i => ∫⁻ x, ∫⁻ y, ‖i (x, y) - g (x, y)‖₊ ∂ν ∂μ swap; · exact fun i => lintegral_mono fun x => ennnorm_integral_le_lintegral_ennnorm _ show Tendsto (fun i : α × β →₁[μ.prod ν] E => ∫⁻ x, ∫⁻ y : β, ‖i (x, y) - g (x, y)‖₊ ∂ν ∂μ) (𝓝 g) (𝓝 0) have : ∀ i : α × β →₁[μ.prod ν] E, Measurable fun z => (‖i z - g z‖₊ : ℝ≥0∞) := fun i => ((Lp.stronglyMeasurable i).sub (Lp.stronglyMeasurable g)).ennnorm -- Porting note: was -- simp_rw [← lintegral_prod_of_measurable _ (this _), ← L1.ofReal_norm_sub_eq_lintegral, ← -- ofReal_zero] conv => congr ext rw [← lintegral_prod_of_measurable _ (this _), ← L1.ofReal_norm_sub_eq_lintegral] rw [← ofReal_zero] refine (continuous_ofReal.tendsto 0).comp ?_ rw [← tendsto_iff_norm_sub_tendsto_zero]; exact tendsto_id #align measure_theory.continuous_integral_integral MeasureTheory.continuous_integral_integral
Mathlib/MeasureTheory/Constructions/Prod/Integral.lean
454
472
theorem integral_prod (f : α × β → E) (hf : Integrable f (μ.prod ν)) : ∫ z, f z ∂μ.prod ν = ∫ x, ∫ y, f (x, y) ∂ν ∂μ := by
by_cases hE : CompleteSpace E; swap; · simp only [integral, dif_neg hE] revert f apply Integrable.induction · intro c s hs h2s simp_rw [integral_indicator hs, ← indicator_comp_right, Function.comp, integral_indicator (measurable_prod_mk_left hs), setIntegral_const, integral_smul_const, integral_toReal (measurable_measure_prod_mk_left hs).aemeasurable (ae_measure_lt_top hs h2s.ne)] -- Porting note: was `simp_rw` rw [prod_apply hs] · rintro f g - i_f i_g hf hg simp_rw [integral_add' i_f i_g, integral_integral_add' i_f i_g, hf, hg] · exact isClosed_eq continuous_integral continuous_integral_integral · rintro f g hfg - hf; convert hf using 1 · exact integral_congr_ae hfg.symm · apply integral_congr_ae filter_upwards [ae_ae_of_ae_prod hfg] with x hfgx using integral_congr_ae (ae_eq_symm hfgx)
import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Ring.Prod import Mathlib.Algebra.Ring.InjSurj import Mathlib.Tactic.Monotonicity.Attr #align_import algebra.order.kleene from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90" open Function universe u variable {α β ι : Type*} {π : ι → Type*} class IdemSemiring (α : Type u) extends Semiring α, SemilatticeSup α where protected sup := (· + ·) protected add_eq_sup : ∀ a b : α, a + b = a ⊔ b := by intros rfl protected bot : α := 0 protected bot_le : ∀ a, bot ≤ a #align idem_semiring IdemSemiring class IdemCommSemiring (α : Type u) extends CommSemiring α, IdemSemiring α #align idem_comm_semiring IdemCommSemiring class KStar (α : Type*) where protected kstar : α → α #align has_kstar KStar @[inherit_doc] scoped[Computability] postfix:1024 "∗" => KStar.kstar open Computability class KleeneAlgebra (α : Type*) extends IdemSemiring α, KStar α where protected one_le_kstar : ∀ a : α, 1 ≤ a∗ protected mul_kstar_le_kstar : ∀ a : α, a * a∗ ≤ a∗ protected kstar_mul_le_kstar : ∀ a : α, a∗ * a ≤ a∗ protected mul_kstar_le_self : ∀ a b : α, b * a ≤ b → b * a∗ ≤ b protected kstar_mul_le_self : ∀ a b : α, a * b ≤ b → a∗ * b ≤ b #align kleene_algebra KleeneAlgebra -- See note [lower instance priority] instance (priority := 100) IdemSemiring.toOrderBot [IdemSemiring α] : OrderBot α := { ‹IdemSemiring α› with } #align idem_semiring.to_order_bot IdemSemiring.toOrderBot -- See note [reducible non-instances] abbrev IdemSemiring.ofSemiring [Semiring α] (h : ∀ a : α, a + a = a) : IdemSemiring α := { ‹Semiring α› with le := fun a b ↦ a + b = b le_refl := h le_trans := fun a b c hab hbc ↦ by simp only rw [← hbc, ← add_assoc, hab] le_antisymm := fun a b hab hba ↦ by rwa [← hba, add_comm] sup := (· + ·) le_sup_left := fun a b ↦ by simp only rw [← add_assoc, h] le_sup_right := fun a b ↦ by simp only rw [add_comm, add_assoc, h] sup_le := fun a b c hab hbc ↦ by simp only rwa [add_assoc, hbc] bot := 0 bot_le := zero_add } #align idem_semiring.of_semiring IdemSemiring.ofSemiring section IdemSemiring variable [IdemSemiring α] {a b c : α} theorem add_eq_sup (a b : α) : a + b = a ⊔ b := IdemSemiring.add_eq_sup _ _ #align add_eq_sup add_eq_sup -- Porting note: This simp theorem often leads to timeout when `α` has rich structure. -- So, this theorem should be scoped. scoped[Computability] attribute [simp] add_eq_sup theorem add_idem (a : α) : a + a = a := by simp #align add_idem add_idem theorem nsmul_eq_self : ∀ {n : ℕ} (_ : n ≠ 0) (a : α), n • a = a | 0, h => (h rfl).elim | 1, _ => one_nsmul | n + 2, _ => fun a ↦ by rw [succ_nsmul, nsmul_eq_self n.succ_ne_zero, add_idem] #align nsmul_eq_self nsmul_eq_self theorem add_eq_left_iff_le : a + b = a ↔ b ≤ a := by simp #align add_eq_left_iff_le add_eq_left_iff_le
Mathlib/Algebra/Order/Kleene.lean
154
154
theorem add_eq_right_iff_le : a + b = b ↔ a ≤ b := by
simp
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 _⟩⟩ def compositionAsSetEquiv (n : ℕ) : CompositionAsSet n ≃ Finset (Fin (n - 1)) where toFun c := { i : Fin (n - 1) | (⟨1 + (i : ℕ), by apply (add_lt_add_left i.is_lt 1).trans_le rw [Nat.succ_eq_add_one, add_comm] exact add_le_add (Nat.sub_le n 1) (le_refl 1)⟩ : Fin n.succ) ∈ c.boundaries }.toFinset invFun s := { boundaries := { i : Fin n.succ | i = 0 ∨ i = Fin.last n ∨ ∃ (j : Fin (n - 1)) (_hj : j ∈ s), (i : ℕ) = j + 1 }.toFinset zero_mem := by simp getLast_mem := by simp } left_inv := by intro c ext i simp only [add_comm, Set.toFinset_setOf, Finset.mem_univ, forall_true_left, Finset.mem_filter, true_and, exists_prop] constructor · rintro (rfl | rfl | ⟨j, hj1, hj2⟩) · exact c.zero_mem · exact c.getLast_mem · convert hj1 · simp only [or_iff_not_imp_left] intro i_mem i_ne_zero i_ne_last simp? [Fin.ext_iff] at i_ne_zero i_ne_last says simp only [Nat.succ_eq_add_one, Fin.ext_iff, Fin.val_zero, Fin.val_last] at i_ne_zero i_ne_last have A : (1 + (i - 1) : ℕ) = (i : ℕ) := by rw [add_comm] exact Nat.succ_pred_eq_of_pos (pos_iff_ne_zero.mpr i_ne_zero) refine ⟨⟨i - 1, ?_⟩, ?_, ?_⟩ · have : (i : ℕ) < n + 1 := i.2 simp? [Nat.lt_succ_iff_lt_or_eq, i_ne_last] at this says simp only [Nat.succ_eq_add_one, Nat.lt_succ_iff_lt_or_eq, i_ne_last, or_false] at this exact Nat.pred_lt_pred i_ne_zero this · convert i_mem simp only [ge_iff_le] rwa [add_comm] · simp only [ge_iff_le] symm rwa [add_comm] right_inv := by intro s ext i have : 1 + (i : ℕ) ≠ n := by apply ne_of_lt convert add_lt_add_left i.is_lt 1 rw [add_comm] apply (Nat.succ_pred_eq_of_pos _).symm exact (zero_le i.val).trans_lt (i.2.trans_le (Nat.sub_le n 1)) simp only [add_comm, Fin.ext_iff, Fin.val_zero, Fin.val_last, exists_prop, Set.toFinset_setOf, Finset.mem_univ, forall_true_left, Finset.mem_filter, add_eq_zero_iff, and_false, add_left_inj, false_or, true_and] erw [Set.mem_setOf_eq] simp [this, false_or_iff, add_right_inj, add_eq_zero_iff, one_ne_zero, false_and_iff, Fin.val_mk] constructor · intro h cases' h with n h · rw [add_comm] at this contradiction · cases' h with w h; cases' h with h₁ h₂ rw [← Fin.ext_iff] at h₂ rwa [h₂] · intro h apply Or.inr use i, h #align composition_as_set_equiv compositionAsSetEquiv instance compositionAsSetFintype (n : ℕ) : Fintype (CompositionAsSet n) := Fintype.ofEquiv _ (compositionAsSetEquiv n).symm #align composition_as_set_fintype compositionAsSetFintype theorem compositionAsSet_card (n : ℕ) : Fintype.card (CompositionAsSet n) = 2 ^ (n - 1) := by have : Fintype.card (Finset (Fin (n - 1))) = 2 ^ (n - 1) := by simp rw [← this] exact Fintype.card_congr (compositionAsSetEquiv n) #align composition_as_set_card compositionAsSet_card namespace CompositionAsSet variable (c : CompositionAsSet n) theorem boundaries_nonempty : c.boundaries.Nonempty := ⟨0, c.zero_mem⟩ #align composition_as_set.boundaries_nonempty CompositionAsSet.boundaries_nonempty theorem card_boundaries_pos : 0 < Finset.card c.boundaries := Finset.card_pos.mpr c.boundaries_nonempty #align composition_as_set.card_boundaries_pos CompositionAsSet.card_boundaries_pos def length : ℕ := Finset.card c.boundaries - 1 #align composition_as_set.length CompositionAsSet.length theorem card_boundaries_eq_succ_length : c.boundaries.card = c.length + 1 := (tsub_eq_iff_eq_add_of_le (Nat.succ_le_of_lt c.card_boundaries_pos)).mp rfl #align composition_as_set.card_boundaries_eq_succ_length CompositionAsSet.card_boundaries_eq_succ_length
Mathlib/Combinatorics/Enumerative/Composition.lean
870
872
theorem length_lt_card_boundaries : c.length < c.boundaries.card := by
rw [c.card_boundaries_eq_succ_length] exact lt_add_one _
import Mathlib.Combinatorics.Quiver.Cast import Mathlib.Combinatorics.Quiver.Symmetric #align_import combinatorics.quiver.single_obj from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226" namespace Quiver -- Porting note: Removed `deriving Unique`. @[nolint unusedArguments] def SingleObj (_ : Type*) : Type := Unit #align quiver.single_obj Quiver.SingleObj -- Porting note: `deriving` from above has been moved to below. instance {α : Type*} : Unique (SingleObj α) where default := ⟨⟩ uniq := fun _ => rfl namespace SingleObj variable (α β γ : Type*) instance : Quiver (SingleObj α) := ⟨fun _ _ => α⟩ def star : SingleObj α := Unit.unit #align quiver.single_obj.star Quiver.SingleObj.star instance : Inhabited (SingleObj α) := ⟨star α⟩ variable {α β γ} lemma ext {x y : SingleObj α} : x = y := Unit.ext x y -- See note [reducible non-instances] abbrev hasReverse (rev : α → α) : HasReverse (SingleObj α) := ⟨rev⟩ #align quiver.single_obj.has_reverse Quiver.SingleObj.hasReverse -- See note [reducible non-instances] abbrev hasInvolutiveReverse (rev : α → α) (h : Function.Involutive rev) : HasInvolutiveReverse (SingleObj α) where toHasReverse := hasReverse rev inv' := h #align quiver.single_obj.has_involutive_reverse Quiver.SingleObj.hasInvolutiveReverse @[simps!] def toHom : α ≃ (star α ⟶ star α) := Equiv.refl _ #align quiver.single_obj.to_hom Quiver.SingleObj.toHom #align quiver.single_obj.to_hom_apply Quiver.SingleObj.toHom_apply #align quiver.single_obj.to_hom_symm_apply Quiver.SingleObj.toHom_symm_apply @[simps] def toPrefunctor : (α → β) ≃ SingleObj α ⥤q SingleObj β where toFun f := ⟨id, f⟩ invFun f a := f.map (toHom a) left_inv _ := rfl right_inv _ := rfl #align quiver.single_obj.to_prefunctor_symm_apply Quiver.SingleObj.toPrefunctor_symm_apply #align quiver.single_obj.to_prefunctor_apply_map Quiver.SingleObj.toPrefunctor_apply_map #align quiver.single_obj.to_prefunctor_apply_obj Quiver.SingleObj.toPrefunctor_apply_obj #align quiver.single_obj.to_prefunctor Quiver.SingleObj.toPrefunctor theorem toPrefunctor_id : toPrefunctor id = 𝟭q (SingleObj α) := rfl #align quiver.single_obj.to_prefunctor_id Quiver.SingleObj.toPrefunctor_id @[simp] theorem toPrefunctor_symm_id : toPrefunctor.symm (𝟭q (SingleObj α)) = id := rfl #align quiver.single_obj.to_prefunctor_symm_id Quiver.SingleObj.toPrefunctor_symm_id theorem toPrefunctor_comp (f : α → β) (g : β → γ) : toPrefunctor (g ∘ f) = toPrefunctor f ⋙q toPrefunctor g := rfl #align quiver.single_obj.to_prefunctor_comp Quiver.SingleObj.toPrefunctor_comp @[simp]
Mathlib/Combinatorics/Quiver/SingleObj.lean
110
112
theorem toPrefunctor_symm_comp (f : SingleObj α ⥤q SingleObj β) (g : SingleObj β ⥤q SingleObj γ) : toPrefunctor.symm (f ⋙q g) = toPrefunctor.symm g ∘ toPrefunctor.symm f := by
simp only [Equiv.symm_apply_eq, toPrefunctor_comp, Equiv.apply_symm_apply]
import Mathlib.Analysis.SpecialFunctions.ExpDeriv import Mathlib.Analysis.SpecialFunctions.Complex.Circle import Mathlib.Analysis.InnerProductSpace.l2Space import Mathlib.MeasureTheory.Function.ContinuousMapDense import Mathlib.MeasureTheory.Function.L2Space import Mathlib.MeasureTheory.Group.Integral import Mathlib.MeasureTheory.Integral.Periodic import Mathlib.Topology.ContinuousFunction.StoneWeierstrass import Mathlib.MeasureTheory.Integral.FundThmCalculus #align_import analysis.fourier.add_circle from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92" noncomputable section open scoped ENNReal ComplexConjugate Real open TopologicalSpace ContinuousMap MeasureTheory MeasureTheory.Measure Algebra Submodule Set variable {T : ℝ} open AddCircle section Monomials def fourier (n : ℤ) : C(AddCircle T, ℂ) where toFun x := toCircle (n • x :) continuous_toFun := continuous_induced_dom.comp <| continuous_toCircle.comp <| continuous_zsmul _ #align fourier fourier @[simp] theorem fourier_apply {n : ℤ} {x : AddCircle T} : fourier n x = toCircle (n • x :) := rfl #align fourier_apply fourier_apply -- @[simp] -- Porting note: simp normal form is `fourier_coe_apply'` theorem fourier_coe_apply {n : ℤ} {x : ℝ} : fourier n (x : AddCircle T) = Complex.exp (2 * π * Complex.I * n * x / T) := by rw [fourier_apply, ← QuotientAddGroup.mk_zsmul, toCircle, Function.Periodic.lift_coe, expMapCircle_apply, Complex.ofReal_mul, Complex.ofReal_div, Complex.ofReal_mul, zsmul_eq_mul, Complex.ofReal_mul, Complex.ofReal_intCast] norm_num congr 1; ring #align fourier_coe_apply fourier_coe_apply @[simp] theorem fourier_coe_apply' {n : ℤ} {x : ℝ} : toCircle (n • (x : AddCircle T) :) = Complex.exp (2 * π * Complex.I * n * x / T) := by rw [← fourier_apply]; exact fourier_coe_apply -- @[simp] -- Porting note: simp normal form is `fourier_zero'` theorem fourier_zero {x : AddCircle T} : fourier 0 x = 1 := by induction x using QuotientAddGroup.induction_on' simp only [fourier_coe_apply] norm_num #align fourier_zero fourier_zero @[simp] theorem fourier_zero' {x : AddCircle T} : @toCircle T 0 = (1 : ℂ) := by have : fourier 0 x = @toCircle T 0 := by rw [fourier_apply, zero_smul] rw [← this]; exact fourier_zero -- @[simp] -- Porting note: simp normal form is *also* `fourier_zero'` theorem fourier_eval_zero (n : ℤ) : fourier n (0 : AddCircle T) = 1 := by rw [← QuotientAddGroup.mk_zero, fourier_coe_apply, Complex.ofReal_zero, mul_zero, zero_div, Complex.exp_zero] #align fourier_eval_zero fourier_eval_zero -- @[simp] -- Porting note (#10618): simp can prove this theorem fourier_one {x : AddCircle T} : fourier 1 x = toCircle x := by rw [fourier_apply, one_zsmul] #align fourier_one fourier_one -- @[simp] -- Porting note: simp normal form is `fourier_neg'` theorem fourier_neg {n : ℤ} {x : AddCircle T} : fourier (-n) x = conj (fourier n x) := by induction x using QuotientAddGroup.induction_on' simp_rw [fourier_apply, toCircle] rw [← QuotientAddGroup.mk_zsmul, ← QuotientAddGroup.mk_zsmul] simp_rw [Function.Periodic.lift_coe, ← coe_inv_circle_eq_conj, ← expMapCircle_neg, neg_smul, mul_neg] #align fourier_neg fourier_neg @[simp] theorem fourier_neg' {n : ℤ} {x : AddCircle T} : @toCircle T (-(n • x)) = conj (fourier n x) := by rw [← neg_smul, ← fourier_apply]; exact fourier_neg -- @[simp] -- Porting note: simp normal form is `fourier_add'` theorem fourier_add {m n : ℤ} {x : AddCircle T} : fourier (m+n) x = fourier m x * fourier n x := by simp_rw [fourier_apply, add_zsmul, toCircle_add, coe_mul_unitSphere] #align fourier_add fourier_add @[simp] theorem fourier_add' {m n : ℤ} {x : AddCircle T} : toCircle ((m + n) • x :) = fourier m x * fourier n x := by rw [← fourier_apply]; exact fourier_add theorem fourier_norm [Fact (0 < T)] (n : ℤ) : ‖@fourier T n‖ = 1 := by rw [ContinuousMap.norm_eq_iSup_norm] have : ∀ x : AddCircle T, ‖fourier n x‖ = 1 := fun x => abs_coe_circle _ simp_rw [this] exact @ciSup_const _ _ _ Zero.instNonempty _ #align fourier_norm fourier_norm theorem fourier_add_half_inv_index {n : ℤ} (hn : n ≠ 0) (hT : 0 < T) (x : AddCircle T) : @fourier T n (x + ↑(T / 2 / n)) = -fourier n x := by rw [fourier_apply, zsmul_add, ← QuotientAddGroup.mk_zsmul, toCircle_add, coe_mul_unitSphere] have : (n : ℂ) ≠ 0 := by simpa using hn have : (@toCircle T (n • (T / 2 / n) : ℝ) : ℂ) = -1 := by rw [zsmul_eq_mul, toCircle, Function.Periodic.lift_coe, expMapCircle_apply] replace hT := Complex.ofReal_ne_zero.mpr hT.ne' convert Complex.exp_pi_mul_I using 3 field_simp; ring rw [this]; simp #align fourier_add_half_inv_index fourier_add_half_inv_index def fourierSubalgebra : StarSubalgebra ℂ C(AddCircle T, ℂ) where toSubalgebra := Algebra.adjoin ℂ (range fourier) star_mem' := by show Algebra.adjoin ℂ (range (fourier (T := T))) ≤ star (Algebra.adjoin ℂ (range (fourier (T := T)))) refine adjoin_le ?_ rintro - ⟨n, rfl⟩ exact subset_adjoin ⟨-n, ext fun _ => fourier_neg⟩ #align fourier_subalgebra fourierSubalgebra
Mathlib/Analysis/Fourier/AddCircle.lean
210
220
theorem fourierSubalgebra_coe : Subalgebra.toSubmodule (@fourierSubalgebra T).toSubalgebra = span ℂ (range (@fourier T)) := by
apply adjoin_eq_span_of_subset refine Subset.trans ?_ Submodule.subset_span intro x hx refine Submonoid.closure_induction hx (fun _ => id) ⟨0, ?_⟩ ?_ · ext1 z; exact fourier_zero · rintro _ _ ⟨m, rfl⟩ ⟨n, rfl⟩ refine ⟨m + n, ?_⟩ ext1 z exact fourier_add
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic import Mathlib.Analysis.Normed.Group.AddCircle import Mathlib.Algebra.CharZero.Quotient import Mathlib.Topology.Instances.Sign #align_import analysis.special_functions.trigonometric.angle from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec" open Real noncomputable section namespace Real -- Porting note: can't derive `NormedAddCommGroup, Inhabited` def Angle : Type := AddCircle (2 * π) #align real.angle Real.Angle namespace Angle -- Porting note (#10754): added due to missing instances due to no deriving instance : NormedAddCommGroup Angle := inferInstanceAs (NormedAddCommGroup (AddCircle (2 * π))) -- Porting note (#10754): added due to missing instances due to no deriving instance : Inhabited Angle := inferInstanceAs (Inhabited (AddCircle (2 * π))) -- Porting note (#10754): added due to missing instances due to no deriving -- also, without this, a plain `QuotientAddGroup.mk` -- causes coerced terms to be of type `ℝ ⧸ AddSubgroup.zmultiples (2 * π)` @[coe] protected def coe (r : ℝ) : Angle := QuotientAddGroup.mk r instance : Coe ℝ Angle := ⟨Angle.coe⟩ instance : CircularOrder Real.Angle := QuotientAddGroup.circularOrder (hp' := ⟨by norm_num [pi_pos]⟩) @[continuity] theorem continuous_coe : Continuous ((↑) : ℝ → Angle) := continuous_quotient_mk' #align real.angle.continuous_coe Real.Angle.continuous_coe def coeHom : ℝ →+ Angle := QuotientAddGroup.mk' _ #align real.angle.coe_hom Real.Angle.coeHom @[simp] theorem coe_coeHom : (coeHom : ℝ → Angle) = ((↑) : ℝ → Angle) := rfl #align real.angle.coe_coe_hom Real.Angle.coe_coeHom @[elab_as_elim] protected theorem induction_on {p : Angle → Prop} (θ : Angle) (h : ∀ x : ℝ, p x) : p θ := Quotient.inductionOn' θ h #align real.angle.induction_on Real.Angle.induction_on @[simp] theorem coe_zero : ↑(0 : ℝ) = (0 : Angle) := rfl #align real.angle.coe_zero Real.Angle.coe_zero @[simp] theorem coe_add (x y : ℝ) : ↑(x + y : ℝ) = (↑x + ↑y : Angle) := rfl #align real.angle.coe_add Real.Angle.coe_add @[simp] theorem coe_neg (x : ℝ) : ↑(-x : ℝ) = -(↑x : Angle) := rfl #align real.angle.coe_neg Real.Angle.coe_neg @[simp] theorem coe_sub (x y : ℝ) : ↑(x - y : ℝ) = (↑x - ↑y : Angle) := rfl #align real.angle.coe_sub Real.Angle.coe_sub theorem coe_nsmul (n : ℕ) (x : ℝ) : ↑(n • x : ℝ) = n • (↑x : Angle) := rfl #align real.angle.coe_nsmul Real.Angle.coe_nsmul theorem coe_zsmul (z : ℤ) (x : ℝ) : ↑(z • x : ℝ) = z • (↑x : Angle) := rfl #align real.angle.coe_zsmul Real.Angle.coe_zsmul @[simp, norm_cast] theorem natCast_mul_eq_nsmul (x : ℝ) (n : ℕ) : ↑((n : ℝ) * x) = n • (↑x : Angle) := by simpa only [nsmul_eq_mul] using coeHom.map_nsmul x n #align real.angle.coe_nat_mul_eq_nsmul Real.Angle.natCast_mul_eq_nsmul @[simp, norm_cast] theorem intCast_mul_eq_zsmul (x : ℝ) (n : ℤ) : ↑((n : ℝ) * x : ℝ) = n • (↑x : Angle) := by simpa only [zsmul_eq_mul] using coeHom.map_zsmul x n #align real.angle.coe_int_mul_eq_zsmul Real.Angle.intCast_mul_eq_zsmul @[deprecated (since := "2024-05-25")] alias coe_nat_mul_eq_nsmul := natCast_mul_eq_nsmul @[deprecated (since := "2024-05-25")] alias coe_int_mul_eq_zsmul := intCast_mul_eq_zsmul theorem angle_eq_iff_two_pi_dvd_sub {ψ θ : ℝ} : (θ : Angle) = ψ ↔ ∃ k : ℤ, θ - ψ = 2 * π * k := by simp only [QuotientAddGroup.eq, AddSubgroup.zmultiples_eq_closure, AddSubgroup.mem_closure_singleton, zsmul_eq_mul', (sub_eq_neg_add _ _).symm, eq_comm] -- Porting note: added `rw`, `simp [Angle.coe, QuotientAddGroup.eq]` doesn't fire otherwise rw [Angle.coe, Angle.coe, QuotientAddGroup.eq] simp only [AddSubgroup.zmultiples_eq_closure, AddSubgroup.mem_closure_singleton, zsmul_eq_mul', (sub_eq_neg_add _ _).symm, eq_comm] #align real.angle.angle_eq_iff_two_pi_dvd_sub Real.Angle.angle_eq_iff_two_pi_dvd_sub @[simp] theorem coe_two_pi : ↑(2 * π : ℝ) = (0 : Angle) := angle_eq_iff_two_pi_dvd_sub.2 ⟨1, by rw [sub_zero, Int.cast_one, mul_one]⟩ #align real.angle.coe_two_pi Real.Angle.coe_two_pi @[simp] theorem neg_coe_pi : -(π : Angle) = π := by rw [← coe_neg, angle_eq_iff_two_pi_dvd_sub] use -1 simp [two_mul, sub_eq_add_neg] #align real.angle.neg_coe_pi Real.Angle.neg_coe_pi @[simp] theorem two_nsmul_coe_div_two (θ : ℝ) : (2 : ℕ) • (↑(θ / 2) : Angle) = θ := by rw [← coe_nsmul, two_nsmul, add_halves] #align real.angle.two_nsmul_coe_div_two Real.Angle.two_nsmul_coe_div_two @[simp] theorem two_zsmul_coe_div_two (θ : ℝ) : (2 : ℤ) • (↑(θ / 2) : Angle) = θ := by rw [← coe_zsmul, two_zsmul, add_halves] #align real.angle.two_zsmul_coe_div_two Real.Angle.two_zsmul_coe_div_two -- Porting note (#10618): @[simp] can prove it theorem two_nsmul_neg_pi_div_two : (2 : ℕ) • (↑(-π / 2) : Angle) = π := by rw [two_nsmul_coe_div_two, coe_neg, neg_coe_pi] #align real.angle.two_nsmul_neg_pi_div_two Real.Angle.two_nsmul_neg_pi_div_two -- Porting note (#10618): @[simp] can prove it theorem two_zsmul_neg_pi_div_two : (2 : ℤ) • (↑(-π / 2) : Angle) = π := by rw [two_zsmul, ← two_nsmul, two_nsmul_neg_pi_div_two] #align real.angle.two_zsmul_neg_pi_div_two Real.Angle.two_zsmul_neg_pi_div_two theorem sub_coe_pi_eq_add_coe_pi (θ : Angle) : θ - π = θ + π := by rw [sub_eq_add_neg, neg_coe_pi] #align real.angle.sub_coe_pi_eq_add_coe_pi Real.Angle.sub_coe_pi_eq_add_coe_pi @[simp] theorem two_nsmul_coe_pi : (2 : ℕ) • (π : Angle) = 0 := by simp [← natCast_mul_eq_nsmul] #align real.angle.two_nsmul_coe_pi Real.Angle.two_nsmul_coe_pi @[simp] theorem two_zsmul_coe_pi : (2 : ℤ) • (π : Angle) = 0 := by simp [← intCast_mul_eq_zsmul] #align real.angle.two_zsmul_coe_pi Real.Angle.two_zsmul_coe_pi @[simp] theorem coe_pi_add_coe_pi : (π : Real.Angle) + π = 0 := by rw [← two_nsmul, two_nsmul_coe_pi] #align real.angle.coe_pi_add_coe_pi Real.Angle.coe_pi_add_coe_pi theorem zsmul_eq_iff {ψ θ : Angle} {z : ℤ} (hz : z ≠ 0) : z • ψ = z • θ ↔ ∃ k : Fin z.natAbs, ψ = θ + (k : ℕ) • (2 * π / z : ℝ) := QuotientAddGroup.zmultiples_zsmul_eq_zsmul_iff hz #align real.angle.zsmul_eq_iff Real.Angle.zsmul_eq_iff theorem nsmul_eq_iff {ψ θ : Angle} {n : ℕ} (hz : n ≠ 0) : n • ψ = n • θ ↔ ∃ k : Fin n, ψ = θ + (k : ℕ) • (2 * π / n : ℝ) := QuotientAddGroup.zmultiples_nsmul_eq_nsmul_iff hz #align real.angle.nsmul_eq_iff Real.Angle.nsmul_eq_iff theorem two_zsmul_eq_iff {ψ θ : Angle} : (2 : ℤ) • ψ = (2 : ℤ) • θ ↔ ψ = θ ∨ ψ = θ + ↑π := by -- Porting note: no `Int.natAbs_bit0` anymore have : Int.natAbs 2 = 2 := rfl rw [zsmul_eq_iff two_ne_zero, this, Fin.exists_fin_two, Fin.val_zero, Fin.val_one, zero_smul, add_zero, one_smul, Int.cast_two, mul_div_cancel_left₀ (_ : ℝ) two_ne_zero] #align real.angle.two_zsmul_eq_iff Real.Angle.two_zsmul_eq_iff theorem two_nsmul_eq_iff {ψ θ : Angle} : (2 : ℕ) • ψ = (2 : ℕ) • θ ↔ ψ = θ ∨ ψ = θ + ↑π := by simp_rw [← natCast_zsmul, Nat.cast_ofNat, two_zsmul_eq_iff] #align real.angle.two_nsmul_eq_iff Real.Angle.two_nsmul_eq_iff theorem two_nsmul_eq_zero_iff {θ : Angle} : (2 : ℕ) • θ = 0 ↔ θ = 0 ∨ θ = π := by convert two_nsmul_eq_iff <;> simp #align real.angle.two_nsmul_eq_zero_iff Real.Angle.two_nsmul_eq_zero_iff theorem two_nsmul_ne_zero_iff {θ : Angle} : (2 : ℕ) • θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π := by rw [← not_or, ← two_nsmul_eq_zero_iff] #align real.angle.two_nsmul_ne_zero_iff Real.Angle.two_nsmul_ne_zero_iff theorem two_zsmul_eq_zero_iff {θ : Angle} : (2 : ℤ) • θ = 0 ↔ θ = 0 ∨ θ = π := by simp_rw [two_zsmul, ← two_nsmul, two_nsmul_eq_zero_iff] #align real.angle.two_zsmul_eq_zero_iff Real.Angle.two_zsmul_eq_zero_iff theorem two_zsmul_ne_zero_iff {θ : Angle} : (2 : ℤ) • θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π := by rw [← not_or, ← two_zsmul_eq_zero_iff] #align real.angle.two_zsmul_ne_zero_iff Real.Angle.two_zsmul_ne_zero_iff theorem eq_neg_self_iff {θ : Angle} : θ = -θ ↔ θ = 0 ∨ θ = π := by rw [← add_eq_zero_iff_eq_neg, ← two_nsmul, two_nsmul_eq_zero_iff] #align real.angle.eq_neg_self_iff Real.Angle.eq_neg_self_iff theorem ne_neg_self_iff {θ : Angle} : θ ≠ -θ ↔ θ ≠ 0 ∧ θ ≠ π := by rw [← not_or, ← eq_neg_self_iff.not] #align real.angle.ne_neg_self_iff Real.Angle.ne_neg_self_iff theorem neg_eq_self_iff {θ : Angle} : -θ = θ ↔ θ = 0 ∨ θ = π := by rw [eq_comm, eq_neg_self_iff] #align real.angle.neg_eq_self_iff Real.Angle.neg_eq_self_iff theorem neg_ne_self_iff {θ : Angle} : -θ ≠ θ ↔ θ ≠ 0 ∧ θ ≠ π := by rw [← not_or, ← neg_eq_self_iff.not] #align real.angle.neg_ne_self_iff Real.Angle.neg_ne_self_iff theorem two_nsmul_eq_pi_iff {θ : Angle} : (2 : ℕ) • θ = π ↔ θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ) := by have h : (π : Angle) = ((2 : ℕ) • (π / 2 : ℝ) :) := by rw [two_nsmul, add_halves] nth_rw 1 [h] rw [coe_nsmul, two_nsmul_eq_iff] -- Porting note: `congr` didn't simplify the goal of iff of `Or`s convert Iff.rfl rw [add_comm, ← coe_add, ← sub_eq_zero, ← coe_sub, neg_div, ← neg_sub, sub_neg_eq_add, add_assoc, add_halves, ← two_mul, coe_neg, coe_two_pi, neg_zero] #align real.angle.two_nsmul_eq_pi_iff Real.Angle.two_nsmul_eq_pi_iff theorem two_zsmul_eq_pi_iff {θ : Angle} : (2 : ℤ) • θ = π ↔ θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ) := by rw [two_zsmul, ← two_nsmul, two_nsmul_eq_pi_iff] #align real.angle.two_zsmul_eq_pi_iff Real.Angle.two_zsmul_eq_pi_iff theorem cos_eq_iff_coe_eq_or_eq_neg {θ ψ : ℝ} : cos θ = cos ψ ↔ (θ : Angle) = ψ ∨ (θ : Angle) = -ψ := by constructor · intro Hcos rw [← sub_eq_zero, cos_sub_cos, mul_eq_zero, mul_eq_zero, neg_eq_zero, eq_false (two_ne_zero' ℝ), false_or_iff, sin_eq_zero_iff, sin_eq_zero_iff] at Hcos rcases Hcos with (⟨n, hn⟩ | ⟨n, hn⟩) · right rw [eq_div_iff_mul_eq (two_ne_zero' ℝ), ← sub_eq_iff_eq_add] at hn rw [← hn, coe_sub, eq_neg_iff_add_eq_zero, sub_add_cancel, mul_assoc, intCast_mul_eq_zsmul, mul_comm, coe_two_pi, zsmul_zero] · left rw [eq_div_iff_mul_eq (two_ne_zero' ℝ), eq_sub_iff_add_eq] at hn rw [← hn, coe_add, mul_assoc, intCast_mul_eq_zsmul, mul_comm, coe_two_pi, zsmul_zero, zero_add] · rw [angle_eq_iff_two_pi_dvd_sub, ← coe_neg, angle_eq_iff_two_pi_dvd_sub] rintro (⟨k, H⟩ | ⟨k, H⟩) · rw [← sub_eq_zero, cos_sub_cos, H, mul_assoc 2 π k, mul_div_cancel_left₀ _ (two_ne_zero' ℝ), mul_comm π _, sin_int_mul_pi, mul_zero] rw [← sub_eq_zero, cos_sub_cos, ← sub_neg_eq_add, H, mul_assoc 2 π k, mul_div_cancel_left₀ _ (two_ne_zero' ℝ), mul_comm π _, sin_int_mul_pi, mul_zero, zero_mul] #align real.angle.cos_eq_iff_coe_eq_or_eq_neg Real.Angle.cos_eq_iff_coe_eq_or_eq_neg theorem sin_eq_iff_coe_eq_or_add_eq_pi {θ ψ : ℝ} : sin θ = sin ψ ↔ (θ : Angle) = ψ ∨ (θ : Angle) + ψ = π := by constructor · intro Hsin rw [← cos_pi_div_two_sub, ← cos_pi_div_two_sub] at Hsin cases' cos_eq_iff_coe_eq_or_eq_neg.mp Hsin with h h · left rw [coe_sub, coe_sub] at h exact sub_right_inj.1 h right rw [coe_sub, coe_sub, eq_neg_iff_add_eq_zero, add_sub, sub_add_eq_add_sub, ← coe_add, add_halves, sub_sub, sub_eq_zero] at h exact h.symm · rw [angle_eq_iff_two_pi_dvd_sub, ← eq_sub_iff_add_eq, ← coe_sub, angle_eq_iff_two_pi_dvd_sub] rintro (⟨k, H⟩ | ⟨k, H⟩) · rw [← sub_eq_zero, sin_sub_sin, H, mul_assoc 2 π k, mul_div_cancel_left₀ _ (two_ne_zero' ℝ), mul_comm π _, sin_int_mul_pi, mul_zero, zero_mul] have H' : θ + ψ = 2 * k * π + π := by rwa [← sub_add, sub_add_eq_add_sub, sub_eq_iff_eq_add, mul_assoc, mul_comm π _, ← mul_assoc] at H rw [← sub_eq_zero, sin_sub_sin, H', add_div, mul_assoc 2 _ π, mul_div_cancel_left₀ _ (two_ne_zero' ℝ), cos_add_pi_div_two, sin_int_mul_pi, neg_zero, mul_zero] #align real.angle.sin_eq_iff_coe_eq_or_add_eq_pi Real.Angle.sin_eq_iff_coe_eq_or_add_eq_pi theorem cos_sin_inj {θ ψ : ℝ} (Hcos : cos θ = cos ψ) (Hsin : sin θ = sin ψ) : (θ : Angle) = ψ := by cases' cos_eq_iff_coe_eq_or_eq_neg.mp Hcos with hc hc; · exact hc cases' sin_eq_iff_coe_eq_or_add_eq_pi.mp Hsin with hs hs; · exact hs rw [eq_neg_iff_add_eq_zero, hs] at hc obtain ⟨n, hn⟩ : ∃ n, n • _ = _ := QuotientAddGroup.leftRel_apply.mp (Quotient.exact' hc) rw [← neg_one_mul, add_zero, ← sub_eq_zero, zsmul_eq_mul, ← mul_assoc, ← sub_mul, mul_eq_zero, eq_false (ne_of_gt pi_pos), or_false_iff, sub_neg_eq_add, ← Int.cast_zero, ← Int.cast_one, ← Int.cast_ofNat, ← Int.cast_mul, ← Int.cast_add, Int.cast_inj] at hn have : (n * 2 + 1) % (2 : ℤ) = 0 % (2 : ℤ) := congr_arg (· % (2 : ℤ)) hn rw [add_comm, Int.add_mul_emod_self] at this exact absurd this one_ne_zero #align real.angle.cos_sin_inj Real.Angle.cos_sin_inj def sin (θ : Angle) : ℝ := sin_periodic.lift θ #align real.angle.sin Real.Angle.sin @[simp] theorem sin_coe (x : ℝ) : sin (x : Angle) = Real.sin x := rfl #align real.angle.sin_coe Real.Angle.sin_coe @[continuity] theorem continuous_sin : Continuous sin := Real.continuous_sin.quotient_liftOn' _ #align real.angle.continuous_sin Real.Angle.continuous_sin def cos (θ : Angle) : ℝ := cos_periodic.lift θ #align real.angle.cos Real.Angle.cos @[simp] theorem cos_coe (x : ℝ) : cos (x : Angle) = Real.cos x := rfl #align real.angle.cos_coe Real.Angle.cos_coe @[continuity] theorem continuous_cos : Continuous cos := Real.continuous_cos.quotient_liftOn' _ #align real.angle.continuous_cos Real.Angle.continuous_cos theorem cos_eq_real_cos_iff_eq_or_eq_neg {θ : Angle} {ψ : ℝ} : cos θ = Real.cos ψ ↔ θ = ψ ∨ θ = -ψ := by induction θ using Real.Angle.induction_on exact cos_eq_iff_coe_eq_or_eq_neg #align real.angle.cos_eq_real_cos_iff_eq_or_eq_neg Real.Angle.cos_eq_real_cos_iff_eq_or_eq_neg theorem cos_eq_iff_eq_or_eq_neg {θ ψ : Angle} : cos θ = cos ψ ↔ θ = ψ ∨ θ = -ψ := by induction ψ using Real.Angle.induction_on exact cos_eq_real_cos_iff_eq_or_eq_neg #align real.angle.cos_eq_iff_eq_or_eq_neg Real.Angle.cos_eq_iff_eq_or_eq_neg theorem sin_eq_real_sin_iff_eq_or_add_eq_pi {θ : Angle} {ψ : ℝ} : sin θ = Real.sin ψ ↔ θ = ψ ∨ θ + ψ = π := by induction θ using Real.Angle.induction_on exact sin_eq_iff_coe_eq_or_add_eq_pi #align real.angle.sin_eq_real_sin_iff_eq_or_add_eq_pi Real.Angle.sin_eq_real_sin_iff_eq_or_add_eq_pi theorem sin_eq_iff_eq_or_add_eq_pi {θ ψ : Angle} : sin θ = sin ψ ↔ θ = ψ ∨ θ + ψ = π := by induction ψ using Real.Angle.induction_on exact sin_eq_real_sin_iff_eq_or_add_eq_pi #align real.angle.sin_eq_iff_eq_or_add_eq_pi Real.Angle.sin_eq_iff_eq_or_add_eq_pi @[simp] theorem sin_zero : sin (0 : Angle) = 0 := by rw [← coe_zero, sin_coe, Real.sin_zero] #align real.angle.sin_zero Real.Angle.sin_zero -- Porting note (#10618): @[simp] can prove it theorem sin_coe_pi : sin (π : Angle) = 0 := by rw [sin_coe, Real.sin_pi] #align real.angle.sin_coe_pi Real.Angle.sin_coe_pi theorem sin_eq_zero_iff {θ : Angle} : sin θ = 0 ↔ θ = 0 ∨ θ = π := by nth_rw 1 [← sin_zero] rw [sin_eq_iff_eq_or_add_eq_pi] simp #align real.angle.sin_eq_zero_iff Real.Angle.sin_eq_zero_iff theorem sin_ne_zero_iff {θ : Angle} : sin θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π := by rw [← not_or, ← sin_eq_zero_iff] #align real.angle.sin_ne_zero_iff Real.Angle.sin_ne_zero_iff @[simp] theorem sin_neg (θ : Angle) : sin (-θ) = -sin θ := by induction θ using Real.Angle.induction_on exact Real.sin_neg _ #align real.angle.sin_neg Real.Angle.sin_neg theorem sin_antiperiodic : Function.Antiperiodic sin (π : Angle) := by intro θ induction θ using Real.Angle.induction_on exact Real.sin_antiperiodic _ #align real.angle.sin_antiperiodic Real.Angle.sin_antiperiodic @[simp] theorem sin_add_pi (θ : Angle) : sin (θ + π) = -sin θ := sin_antiperiodic θ #align real.angle.sin_add_pi Real.Angle.sin_add_pi @[simp] theorem sin_sub_pi (θ : Angle) : sin (θ - π) = -sin θ := sin_antiperiodic.sub_eq θ #align real.angle.sin_sub_pi Real.Angle.sin_sub_pi @[simp] theorem cos_zero : cos (0 : Angle) = 1 := by rw [← coe_zero, cos_coe, Real.cos_zero] #align real.angle.cos_zero Real.Angle.cos_zero -- Porting note (#10618): @[simp] can prove it theorem cos_coe_pi : cos (π : Angle) = -1 := by rw [cos_coe, Real.cos_pi] #align real.angle.cos_coe_pi Real.Angle.cos_coe_pi @[simp] theorem cos_neg (θ : Angle) : cos (-θ) = cos θ := by induction θ using Real.Angle.induction_on exact Real.cos_neg _ #align real.angle.cos_neg Real.Angle.cos_neg theorem cos_antiperiodic : Function.Antiperiodic cos (π : Angle) := by intro θ induction θ using Real.Angle.induction_on exact Real.cos_antiperiodic _ #align real.angle.cos_antiperiodic Real.Angle.cos_antiperiodic @[simp] theorem cos_add_pi (θ : Angle) : cos (θ + π) = -cos θ := cos_antiperiodic θ #align real.angle.cos_add_pi Real.Angle.cos_add_pi @[simp] theorem cos_sub_pi (θ : Angle) : cos (θ - π) = -cos θ := cos_antiperiodic.sub_eq θ #align real.angle.cos_sub_pi Real.Angle.cos_sub_pi theorem cos_eq_zero_iff {θ : Angle} : cos θ = 0 ↔ θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ) := by rw [← cos_pi_div_two, ← cos_coe, cos_eq_iff_eq_or_eq_neg, ← coe_neg, ← neg_div] #align real.angle.cos_eq_zero_iff Real.Angle.cos_eq_zero_iff theorem sin_add (θ₁ θ₂ : Real.Angle) : sin (θ₁ + θ₂) = sin θ₁ * cos θ₂ + cos θ₁ * sin θ₂ := by induction θ₁ using Real.Angle.induction_on induction θ₂ using Real.Angle.induction_on exact Real.sin_add _ _ #align real.angle.sin_add Real.Angle.sin_add theorem cos_add (θ₁ θ₂ : Real.Angle) : cos (θ₁ + θ₂) = cos θ₁ * cos θ₂ - sin θ₁ * sin θ₂ := by induction θ₂ using Real.Angle.induction_on induction θ₁ using Real.Angle.induction_on exact Real.cos_add _ _ #align real.angle.cos_add Real.Angle.cos_add @[simp] theorem cos_sq_add_sin_sq (θ : Real.Angle) : cos θ ^ 2 + sin θ ^ 2 = 1 := by induction θ using Real.Angle.induction_on exact Real.cos_sq_add_sin_sq _ #align real.angle.cos_sq_add_sin_sq Real.Angle.cos_sq_add_sin_sq theorem sin_add_pi_div_two (θ : Angle) : sin (θ + ↑(π / 2)) = cos θ := by induction θ using Real.Angle.induction_on exact Real.sin_add_pi_div_two _ #align real.angle.sin_add_pi_div_two Real.Angle.sin_add_pi_div_two theorem sin_sub_pi_div_two (θ : Angle) : sin (θ - ↑(π / 2)) = -cos θ := by induction θ using Real.Angle.induction_on exact Real.sin_sub_pi_div_two _ #align real.angle.sin_sub_pi_div_two Real.Angle.sin_sub_pi_div_two theorem sin_pi_div_two_sub (θ : Angle) : sin (↑(π / 2) - θ) = cos θ := by induction θ using Real.Angle.induction_on exact Real.sin_pi_div_two_sub _ #align real.angle.sin_pi_div_two_sub Real.Angle.sin_pi_div_two_sub theorem cos_add_pi_div_two (θ : Angle) : cos (θ + ↑(π / 2)) = -sin θ := by induction θ using Real.Angle.induction_on exact Real.cos_add_pi_div_two _ #align real.angle.cos_add_pi_div_two Real.Angle.cos_add_pi_div_two theorem cos_sub_pi_div_two (θ : Angle) : cos (θ - ↑(π / 2)) = sin θ := by induction θ using Real.Angle.induction_on exact Real.cos_sub_pi_div_two _ #align real.angle.cos_sub_pi_div_two Real.Angle.cos_sub_pi_div_two theorem cos_pi_div_two_sub (θ : Angle) : cos (↑(π / 2) - θ) = sin θ := by induction θ using Real.Angle.induction_on exact Real.cos_pi_div_two_sub _ #align real.angle.cos_pi_div_two_sub Real.Angle.cos_pi_div_two_sub theorem abs_sin_eq_of_two_nsmul_eq {θ ψ : Angle} (h : (2 : ℕ) • θ = (2 : ℕ) • ψ) : |sin θ| = |sin ψ| := by rw [two_nsmul_eq_iff] at h rcases h with (rfl | rfl) · rfl · rw [sin_add_pi, abs_neg] #align real.angle.abs_sin_eq_of_two_nsmul_eq Real.Angle.abs_sin_eq_of_two_nsmul_eq theorem abs_sin_eq_of_two_zsmul_eq {θ ψ : Angle} (h : (2 : ℤ) • θ = (2 : ℤ) • ψ) : |sin θ| = |sin ψ| := by simp_rw [two_zsmul, ← two_nsmul] at h exact abs_sin_eq_of_two_nsmul_eq h #align real.angle.abs_sin_eq_of_two_zsmul_eq Real.Angle.abs_sin_eq_of_two_zsmul_eq theorem abs_cos_eq_of_two_nsmul_eq {θ ψ : Angle} (h : (2 : ℕ) • θ = (2 : ℕ) • ψ) : |cos θ| = |cos ψ| := by rw [two_nsmul_eq_iff] at h rcases h with (rfl | rfl) · rfl · rw [cos_add_pi, abs_neg] #align real.angle.abs_cos_eq_of_two_nsmul_eq Real.Angle.abs_cos_eq_of_two_nsmul_eq theorem abs_cos_eq_of_two_zsmul_eq {θ ψ : Angle} (h : (2 : ℤ) • θ = (2 : ℤ) • ψ) : |cos θ| = |cos ψ| := by simp_rw [two_zsmul, ← two_nsmul] at h exact abs_cos_eq_of_two_nsmul_eq h #align real.angle.abs_cos_eq_of_two_zsmul_eq Real.Angle.abs_cos_eq_of_two_zsmul_eq @[simp] theorem coe_toIcoMod (θ ψ : ℝ) : ↑(toIcoMod two_pi_pos ψ θ) = (θ : Angle) := by rw [angle_eq_iff_two_pi_dvd_sub] refine ⟨-toIcoDiv two_pi_pos ψ θ, ?_⟩ rw [toIcoMod_sub_self, zsmul_eq_mul, mul_comm] #align real.angle.coe_to_Ico_mod Real.Angle.coe_toIcoMod @[simp] theorem coe_toIocMod (θ ψ : ℝ) : ↑(toIocMod two_pi_pos ψ θ) = (θ : Angle) := by rw [angle_eq_iff_two_pi_dvd_sub] refine ⟨-toIocDiv two_pi_pos ψ θ, ?_⟩ rw [toIocMod_sub_self, zsmul_eq_mul, mul_comm] #align real.angle.coe_to_Ioc_mod Real.Angle.coe_toIocMod def toReal (θ : Angle) : ℝ := (toIocMod_periodic two_pi_pos (-π)).lift θ #align real.angle.to_real Real.Angle.toReal theorem toReal_coe (θ : ℝ) : (θ : Angle).toReal = toIocMod two_pi_pos (-π) θ := rfl #align real.angle.to_real_coe Real.Angle.toReal_coe theorem toReal_coe_eq_self_iff {θ : ℝ} : (θ : Angle).toReal = θ ↔ -π < θ ∧ θ ≤ π := by rw [toReal_coe, toIocMod_eq_self two_pi_pos] ring_nf rfl #align real.angle.to_real_coe_eq_self_iff Real.Angle.toReal_coe_eq_self_iff theorem toReal_coe_eq_self_iff_mem_Ioc {θ : ℝ} : (θ : Angle).toReal = θ ↔ θ ∈ Set.Ioc (-π) π := by rw [toReal_coe_eq_self_iff, ← Set.mem_Ioc] #align real.angle.to_real_coe_eq_self_iff_mem_Ioc Real.Angle.toReal_coe_eq_self_iff_mem_Ioc theorem toReal_injective : Function.Injective toReal := by intro θ ψ h induction θ using Real.Angle.induction_on induction ψ using Real.Angle.induction_on simpa [toReal_coe, toIocMod_eq_toIocMod, zsmul_eq_mul, mul_comm _ (2 * π), ← angle_eq_iff_two_pi_dvd_sub, eq_comm] using h #align real.angle.to_real_injective Real.Angle.toReal_injective @[simp] theorem toReal_inj {θ ψ : Angle} : θ.toReal = ψ.toReal ↔ θ = ψ := toReal_injective.eq_iff #align real.angle.to_real_inj Real.Angle.toReal_inj @[simp] theorem coe_toReal (θ : Angle) : (θ.toReal : Angle) = θ := by induction θ using Real.Angle.induction_on exact coe_toIocMod _ _ #align real.angle.coe_to_real Real.Angle.coe_toReal theorem neg_pi_lt_toReal (θ : Angle) : -π < θ.toReal := by induction θ using Real.Angle.induction_on exact left_lt_toIocMod _ _ _ #align real.angle.neg_pi_lt_to_real Real.Angle.neg_pi_lt_toReal theorem toReal_le_pi (θ : Angle) : θ.toReal ≤ π := by induction θ using Real.Angle.induction_on convert toIocMod_le_right two_pi_pos _ _ ring #align real.angle.to_real_le_pi Real.Angle.toReal_le_pi theorem abs_toReal_le_pi (θ : Angle) : |θ.toReal| ≤ π := abs_le.2 ⟨(neg_pi_lt_toReal _).le, toReal_le_pi _⟩ #align real.angle.abs_to_real_le_pi Real.Angle.abs_toReal_le_pi theorem toReal_mem_Ioc (θ : Angle) : θ.toReal ∈ Set.Ioc (-π) π := ⟨neg_pi_lt_toReal _, toReal_le_pi _⟩ #align real.angle.to_real_mem_Ioc Real.Angle.toReal_mem_Ioc @[simp] theorem toIocMod_toReal (θ : Angle) : toIocMod two_pi_pos (-π) θ.toReal = θ.toReal := by induction θ using Real.Angle.induction_on rw [toReal_coe] exact toIocMod_toIocMod _ _ _ _ #align real.angle.to_Ioc_mod_to_real Real.Angle.toIocMod_toReal @[simp] theorem toReal_zero : (0 : Angle).toReal = 0 := by rw [← coe_zero, toReal_coe_eq_self_iff] exact ⟨Left.neg_neg_iff.2 Real.pi_pos, Real.pi_pos.le⟩ #align real.angle.to_real_zero Real.Angle.toReal_zero @[simp] theorem toReal_eq_zero_iff {θ : Angle} : θ.toReal = 0 ↔ θ = 0 := by nth_rw 1 [← toReal_zero] exact toReal_inj #align real.angle.to_real_eq_zero_iff Real.Angle.toReal_eq_zero_iff @[simp] theorem toReal_pi : (π : Angle).toReal = π := by rw [toReal_coe_eq_self_iff] exact ⟨Left.neg_lt_self Real.pi_pos, le_refl _⟩ #align real.angle.to_real_pi Real.Angle.toReal_pi @[simp] theorem toReal_eq_pi_iff {θ : Angle} : θ.toReal = π ↔ θ = π := by rw [← toReal_inj, toReal_pi] #align real.angle.to_real_eq_pi_iff Real.Angle.toReal_eq_pi_iff theorem pi_ne_zero : (π : Angle) ≠ 0 := by rw [← toReal_injective.ne_iff, toReal_pi, toReal_zero] exact Real.pi_ne_zero #align real.angle.pi_ne_zero Real.Angle.pi_ne_zero @[simp] theorem toReal_pi_div_two : ((π / 2 : ℝ) : Angle).toReal = π / 2 := toReal_coe_eq_self_iff.2 <| by constructor <;> linarith [pi_pos] #align real.angle.to_real_pi_div_two Real.Angle.toReal_pi_div_two @[simp] theorem toReal_eq_pi_div_two_iff {θ : Angle} : θ.toReal = π / 2 ↔ θ = (π / 2 : ℝ) := by rw [← toReal_inj, toReal_pi_div_two] #align real.angle.to_real_eq_pi_div_two_iff Real.Angle.toReal_eq_pi_div_two_iff @[simp] theorem toReal_neg_pi_div_two : ((-π / 2 : ℝ) : Angle).toReal = -π / 2 := toReal_coe_eq_self_iff.2 <| by constructor <;> linarith [pi_pos] #align real.angle.to_real_neg_pi_div_two Real.Angle.toReal_neg_pi_div_two @[simp] theorem toReal_eq_neg_pi_div_two_iff {θ : Angle} : θ.toReal = -π / 2 ↔ θ = (-π / 2 : ℝ) := by rw [← toReal_inj, toReal_neg_pi_div_two] #align real.angle.to_real_eq_neg_pi_div_two_iff Real.Angle.toReal_eq_neg_pi_div_two_iff theorem pi_div_two_ne_zero : ((π / 2 : ℝ) : Angle) ≠ 0 := by rw [← toReal_injective.ne_iff, toReal_pi_div_two, toReal_zero] exact div_ne_zero Real.pi_ne_zero two_ne_zero #align real.angle.pi_div_two_ne_zero Real.Angle.pi_div_two_ne_zero theorem neg_pi_div_two_ne_zero : ((-π / 2 : ℝ) : Angle) ≠ 0 := by rw [← toReal_injective.ne_iff, toReal_neg_pi_div_two, toReal_zero] exact div_ne_zero (neg_ne_zero.2 Real.pi_ne_zero) two_ne_zero #align real.angle.neg_pi_div_two_ne_zero Real.Angle.neg_pi_div_two_ne_zero theorem abs_toReal_coe_eq_self_iff {θ : ℝ} : |(θ : Angle).toReal| = θ ↔ 0 ≤ θ ∧ θ ≤ π := ⟨fun h => h ▸ ⟨abs_nonneg _, abs_toReal_le_pi _⟩, fun h => (toReal_coe_eq_self_iff.2 ⟨(Left.neg_neg_iff.2 Real.pi_pos).trans_le h.1, h.2⟩).symm ▸ abs_eq_self.2 h.1⟩ #align real.angle.abs_to_real_coe_eq_self_iff Real.Angle.abs_toReal_coe_eq_self_iff theorem abs_toReal_neg_coe_eq_self_iff {θ : ℝ} : |(-θ : Angle).toReal| = θ ↔ 0 ≤ θ ∧ θ ≤ π := by refine ⟨fun h => h ▸ ⟨abs_nonneg _, abs_toReal_le_pi _⟩, fun h => ?_⟩ by_cases hnegpi : θ = π; · simp [hnegpi, Real.pi_pos.le] rw [← coe_neg, toReal_coe_eq_self_iff.2 ⟨neg_lt_neg (lt_of_le_of_ne h.2 hnegpi), (neg_nonpos.2 h.1).trans Real.pi_pos.le⟩, abs_neg, abs_eq_self.2 h.1] #align real.angle.abs_to_real_neg_coe_eq_self_iff Real.Angle.abs_toReal_neg_coe_eq_self_iff theorem abs_toReal_eq_pi_div_two_iff {θ : Angle} : |θ.toReal| = π / 2 ↔ θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ) := by rw [abs_eq (div_nonneg Real.pi_pos.le two_pos.le), ← neg_div, toReal_eq_pi_div_two_iff, toReal_eq_neg_pi_div_two_iff] #align real.angle.abs_to_real_eq_pi_div_two_iff Real.Angle.abs_toReal_eq_pi_div_two_iff theorem nsmul_toReal_eq_mul {n : ℕ} (h : n ≠ 0) {θ : Angle} : (n • θ).toReal = n * θ.toReal ↔ θ.toReal ∈ Set.Ioc (-π / n) (π / n) := by nth_rw 1 [← coe_toReal θ] have h' : 0 < (n : ℝ) := mod_cast Nat.pos_of_ne_zero h rw [← coe_nsmul, nsmul_eq_mul, toReal_coe_eq_self_iff, Set.mem_Ioc, div_lt_iff' h', le_div_iff' h'] #align real.angle.nsmul_to_real_eq_mul Real.Angle.nsmul_toReal_eq_mul theorem two_nsmul_toReal_eq_two_mul {θ : Angle} : ((2 : ℕ) • θ).toReal = 2 * θ.toReal ↔ θ.toReal ∈ Set.Ioc (-π / 2) (π / 2) := mod_cast nsmul_toReal_eq_mul two_ne_zero #align real.angle.two_nsmul_to_real_eq_two_mul Real.Angle.two_nsmul_toReal_eq_two_mul theorem two_zsmul_toReal_eq_two_mul {θ : Angle} : ((2 : ℤ) • θ).toReal = 2 * θ.toReal ↔ θ.toReal ∈ Set.Ioc (-π / 2) (π / 2) := by rw [two_zsmul, ← two_nsmul, two_nsmul_toReal_eq_two_mul] #align real.angle.two_zsmul_to_real_eq_two_mul Real.Angle.two_zsmul_toReal_eq_two_mul theorem toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff {θ : ℝ} {k : ℤ} : (θ : Angle).toReal = θ - 2 * k * π ↔ θ ∈ Set.Ioc ((2 * k - 1 : ℝ) * π) ((2 * k + 1) * π) := by rw [← sub_zero (θ : Angle), ← zsmul_zero k, ← coe_two_pi, ← coe_zsmul, ← coe_sub, zsmul_eq_mul, ← mul_assoc, mul_comm (k : ℝ), toReal_coe_eq_self_iff, Set.mem_Ioc] exact ⟨fun h => ⟨by linarith, by linarith⟩, fun h => ⟨by linarith, by linarith⟩⟩ #align real.angle.to_real_coe_eq_self_sub_two_mul_int_mul_pi_iff Real.Angle.toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff theorem toReal_coe_eq_self_sub_two_pi_iff {θ : ℝ} : (θ : Angle).toReal = θ - 2 * π ↔ θ ∈ Set.Ioc π (3 * π) := by convert @toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff θ 1 <;> norm_num #align real.angle.to_real_coe_eq_self_sub_two_pi_iff Real.Angle.toReal_coe_eq_self_sub_two_pi_iff theorem toReal_coe_eq_self_add_two_pi_iff {θ : ℝ} : (θ : Angle).toReal = θ + 2 * π ↔ θ ∈ Set.Ioc (-3 * π) (-π) := by convert @toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff θ (-1) using 2 <;> set_option tactic.skipAssignedInstances false in norm_num #align real.angle.to_real_coe_eq_self_add_two_pi_iff Real.Angle.toReal_coe_eq_self_add_two_pi_iff theorem two_nsmul_toReal_eq_two_mul_sub_two_pi {θ : Angle} : ((2 : ℕ) • θ).toReal = 2 * θ.toReal - 2 * π ↔ π / 2 < θ.toReal := by nth_rw 1 [← coe_toReal θ] rw [← coe_nsmul, two_nsmul, ← two_mul, toReal_coe_eq_self_sub_two_pi_iff, Set.mem_Ioc] exact ⟨fun h => by linarith, fun h => ⟨(div_lt_iff' (zero_lt_two' ℝ)).1 h, by linarith [pi_pos, toReal_le_pi θ]⟩⟩ #align real.angle.two_nsmul_to_real_eq_two_mul_sub_two_pi Real.Angle.two_nsmul_toReal_eq_two_mul_sub_two_pi theorem two_zsmul_toReal_eq_two_mul_sub_two_pi {θ : Angle} : ((2 : ℤ) • θ).toReal = 2 * θ.toReal - 2 * π ↔ π / 2 < θ.toReal := by rw [two_zsmul, ← two_nsmul, two_nsmul_toReal_eq_two_mul_sub_two_pi] #align real.angle.two_zsmul_to_real_eq_two_mul_sub_two_pi Real.Angle.two_zsmul_toReal_eq_two_mul_sub_two_pi theorem two_nsmul_toReal_eq_two_mul_add_two_pi {θ : Angle} : ((2 : ℕ) • θ).toReal = 2 * θ.toReal + 2 * π ↔ θ.toReal ≤ -π / 2 := by nth_rw 1 [← coe_toReal θ] rw [← coe_nsmul, two_nsmul, ← two_mul, toReal_coe_eq_self_add_two_pi_iff, Set.mem_Ioc] refine ⟨fun h => by linarith, fun h => ⟨by linarith [pi_pos, neg_pi_lt_toReal θ], (le_div_iff' (zero_lt_two' ℝ)).1 h⟩⟩ #align real.angle.two_nsmul_to_real_eq_two_mul_add_two_pi Real.Angle.two_nsmul_toReal_eq_two_mul_add_two_pi theorem two_zsmul_toReal_eq_two_mul_add_two_pi {θ : Angle} : ((2 : ℤ) • θ).toReal = 2 * θ.toReal + 2 * π ↔ θ.toReal ≤ -π / 2 := by rw [two_zsmul, ← two_nsmul, two_nsmul_toReal_eq_two_mul_add_two_pi] #align real.angle.two_zsmul_to_real_eq_two_mul_add_two_pi Real.Angle.two_zsmul_toReal_eq_two_mul_add_two_pi @[simp] theorem sin_toReal (θ : Angle) : Real.sin θ.toReal = sin θ := by conv_rhs => rw [← coe_toReal θ, sin_coe] #align real.angle.sin_to_real Real.Angle.sin_toReal @[simp] theorem cos_toReal (θ : Angle) : Real.cos θ.toReal = cos θ := by conv_rhs => rw [← coe_toReal θ, cos_coe] #align real.angle.cos_to_real Real.Angle.cos_toReal theorem cos_nonneg_iff_abs_toReal_le_pi_div_two {θ : Angle} : 0 ≤ cos θ ↔ |θ.toReal| ≤ π / 2 := by nth_rw 1 [← coe_toReal θ] rw [abs_le, cos_coe] refine ⟨fun h => ?_, cos_nonneg_of_mem_Icc⟩ by_contra hn rw [not_and_or, not_le, not_le] at hn refine (not_lt.2 h) ?_ rcases hn with (hn | hn) · rw [← Real.cos_neg] refine cos_neg_of_pi_div_two_lt_of_lt (by linarith) ?_ linarith [neg_pi_lt_toReal θ] · refine cos_neg_of_pi_div_two_lt_of_lt hn ?_ linarith [toReal_le_pi θ] #align real.angle.cos_nonneg_iff_abs_to_real_le_pi_div_two Real.Angle.cos_nonneg_iff_abs_toReal_le_pi_div_two theorem cos_pos_iff_abs_toReal_lt_pi_div_two {θ : Angle} : 0 < cos θ ↔ |θ.toReal| < π / 2 := by rw [lt_iff_le_and_ne, lt_iff_le_and_ne, cos_nonneg_iff_abs_toReal_le_pi_div_two, ← and_congr_right] rintro - rw [Ne, Ne, not_iff_not, @eq_comm ℝ 0, abs_toReal_eq_pi_div_two_iff, cos_eq_zero_iff] #align real.angle.cos_pos_iff_abs_to_real_lt_pi_div_two Real.Angle.cos_pos_iff_abs_toReal_lt_pi_div_two theorem cos_neg_iff_pi_div_two_lt_abs_toReal {θ : Angle} : cos θ < 0 ↔ π / 2 < |θ.toReal| := by rw [← not_le, ← not_le, not_iff_not, cos_nonneg_iff_abs_toReal_le_pi_div_two] #align real.angle.cos_neg_iff_pi_div_two_lt_abs_to_real Real.Angle.cos_neg_iff_pi_div_two_lt_abs_toReal theorem abs_cos_eq_abs_sin_of_two_nsmul_add_two_nsmul_eq_pi {θ ψ : Angle} (h : (2 : ℕ) • θ + (2 : ℕ) • ψ = π) : |cos θ| = |sin ψ| := by rw [← eq_sub_iff_add_eq, ← two_nsmul_coe_div_two, ← nsmul_sub, two_nsmul_eq_iff] at h rcases h with (rfl | rfl) <;> simp [cos_pi_div_two_sub] #align real.angle.abs_cos_eq_abs_sin_of_two_nsmul_add_two_nsmul_eq_pi Real.Angle.abs_cos_eq_abs_sin_of_two_nsmul_add_two_nsmul_eq_pi theorem abs_cos_eq_abs_sin_of_two_zsmul_add_two_zsmul_eq_pi {θ ψ : Angle} (h : (2 : ℤ) • θ + (2 : ℤ) • ψ = π) : |cos θ| = |sin ψ| := by simp_rw [two_zsmul, ← two_nsmul] at h exact abs_cos_eq_abs_sin_of_two_nsmul_add_two_nsmul_eq_pi h #align real.angle.abs_cos_eq_abs_sin_of_two_zsmul_add_two_zsmul_eq_pi Real.Angle.abs_cos_eq_abs_sin_of_two_zsmul_add_two_zsmul_eq_pi def tan (θ : Angle) : ℝ := sin θ / cos θ #align real.angle.tan Real.Angle.tan theorem tan_eq_sin_div_cos (θ : Angle) : tan θ = sin θ / cos θ := rfl #align real.angle.tan_eq_sin_div_cos Real.Angle.tan_eq_sin_div_cos @[simp] theorem tan_coe (x : ℝ) : tan (x : Angle) = Real.tan x := by rw [tan, sin_coe, cos_coe, Real.tan_eq_sin_div_cos] #align real.angle.tan_coe Real.Angle.tan_coe @[simp] theorem tan_zero : tan (0 : Angle) = 0 := by rw [← coe_zero, tan_coe, Real.tan_zero] #align real.angle.tan_zero Real.Angle.tan_zero -- Porting note (#10618): @[simp] can now prove it theorem tan_coe_pi : tan (π : Angle) = 0 := by rw [tan_coe, Real.tan_pi] #align real.angle.tan_coe_pi Real.Angle.tan_coe_pi theorem tan_periodic : Function.Periodic tan (π : Angle) := by intro θ induction θ using Real.Angle.induction_on rw [← coe_add, tan_coe, tan_coe] exact Real.tan_periodic _ #align real.angle.tan_periodic Real.Angle.tan_periodic @[simp] theorem tan_add_pi (θ : Angle) : tan (θ + π) = tan θ := tan_periodic θ #align real.angle.tan_add_pi Real.Angle.tan_add_pi @[simp] theorem tan_sub_pi (θ : Angle) : tan (θ - π) = tan θ := tan_periodic.sub_eq θ #align real.angle.tan_sub_pi Real.Angle.tan_sub_pi @[simp] theorem tan_toReal (θ : Angle) : Real.tan θ.toReal = tan θ := by conv_rhs => rw [← coe_toReal θ, tan_coe] #align real.angle.tan_to_real Real.Angle.tan_toReal theorem tan_eq_of_two_nsmul_eq {θ ψ : Angle} (h : (2 : ℕ) • θ = (2 : ℕ) • ψ) : tan θ = tan ψ := by rw [two_nsmul_eq_iff] at h rcases h with (rfl | rfl) · rfl · exact tan_add_pi _ #align real.angle.tan_eq_of_two_nsmul_eq Real.Angle.tan_eq_of_two_nsmul_eq theorem tan_eq_of_two_zsmul_eq {θ ψ : Angle} (h : (2 : ℤ) • θ = (2 : ℤ) • ψ) : tan θ = tan ψ := by simp_rw [two_zsmul, ← two_nsmul] at h exact tan_eq_of_two_nsmul_eq h #align real.angle.tan_eq_of_two_zsmul_eq Real.Angle.tan_eq_of_two_zsmul_eq theorem tan_eq_inv_of_two_nsmul_add_two_nsmul_eq_pi {θ ψ : Angle} (h : (2 : ℕ) • θ + (2 : ℕ) • ψ = π) : tan ψ = (tan θ)⁻¹ := by induction θ using Real.Angle.induction_on induction ψ using Real.Angle.induction_on rw [← smul_add, ← coe_add, ← coe_nsmul, two_nsmul, ← two_mul, angle_eq_iff_two_pi_dvd_sub] at h rcases h with ⟨k, h⟩ rw [sub_eq_iff_eq_add, ← mul_inv_cancel_left₀ two_ne_zero π, mul_assoc, ← mul_add, mul_right_inj' (two_ne_zero' ℝ), ← eq_sub_iff_add_eq', mul_inv_cancel_left₀ two_ne_zero π, inv_mul_eq_div, mul_comm] at h rw [tan_coe, tan_coe, ← tan_pi_div_two_sub, h, add_sub_assoc, add_comm] exact Real.tan_periodic.int_mul _ _ #align real.angle.tan_eq_inv_of_two_nsmul_add_two_nsmul_eq_pi Real.Angle.tan_eq_inv_of_two_nsmul_add_two_nsmul_eq_pi theorem tan_eq_inv_of_two_zsmul_add_two_zsmul_eq_pi {θ ψ : Angle} (h : (2 : ℤ) • θ + (2 : ℤ) • ψ = π) : tan ψ = (tan θ)⁻¹ := by simp_rw [two_zsmul, ← two_nsmul] at h exact tan_eq_inv_of_two_nsmul_add_two_nsmul_eq_pi h #align real.angle.tan_eq_inv_of_two_zsmul_add_two_zsmul_eq_pi Real.Angle.tan_eq_inv_of_two_zsmul_add_two_zsmul_eq_pi def sign (θ : Angle) : SignType := SignType.sign (sin θ) #align real.angle.sign Real.Angle.sign @[simp] theorem sign_zero : (0 : Angle).sign = 0 := by rw [sign, sin_zero, _root_.sign_zero] #align real.angle.sign_zero Real.Angle.sign_zero @[simp] theorem sign_coe_pi : (π : Angle).sign = 0 := by rw [sign, sin_coe_pi, _root_.sign_zero] #align real.angle.sign_coe_pi Real.Angle.sign_coe_pi @[simp] theorem sign_neg (θ : Angle) : (-θ).sign = -θ.sign := by simp_rw [sign, sin_neg, Left.sign_neg] #align real.angle.sign_neg Real.Angle.sign_neg theorem sign_antiperiodic : Function.Antiperiodic sign (π : Angle) := fun θ => by rw [sign, sign, sin_add_pi, Left.sign_neg] #align real.angle.sign_antiperiodic Real.Angle.sign_antiperiodic @[simp] theorem sign_add_pi (θ : Angle) : (θ + π).sign = -θ.sign := sign_antiperiodic θ #align real.angle.sign_add_pi Real.Angle.sign_add_pi @[simp] theorem sign_pi_add (θ : Angle) : ((π : Angle) + θ).sign = -θ.sign := by rw [add_comm, sign_add_pi] #align real.angle.sign_pi_add Real.Angle.sign_pi_add @[simp] theorem sign_sub_pi (θ : Angle) : (θ - π).sign = -θ.sign := sign_antiperiodic.sub_eq θ #align real.angle.sign_sub_pi Real.Angle.sign_sub_pi @[simp] theorem sign_pi_sub (θ : Angle) : ((π : Angle) - θ).sign = θ.sign := by simp [sign_antiperiodic.sub_eq'] #align real.angle.sign_pi_sub Real.Angle.sign_pi_sub theorem sign_eq_zero_iff {θ : Angle} : θ.sign = 0 ↔ θ = 0 ∨ θ = π := by rw [sign, _root_.sign_eq_zero_iff, sin_eq_zero_iff] #align real.angle.sign_eq_zero_iff Real.Angle.sign_eq_zero_iff theorem sign_ne_zero_iff {θ : Angle} : θ.sign ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π := by rw [← not_or, ← sign_eq_zero_iff] #align real.angle.sign_ne_zero_iff Real.Angle.sign_ne_zero_iff theorem toReal_neg_iff_sign_neg {θ : Angle} : θ.toReal < 0 ↔ θ.sign = -1 := by rw [sign, ← sin_toReal, sign_eq_neg_one_iff] rcases lt_trichotomy θ.toReal 0 with (h | h | h) · exact ⟨fun _ => Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_toReal θ), fun _ => h⟩ · simp [h] · exact ⟨fun hn => False.elim (h.asymm hn), fun hn => False.elim (hn.not_le (sin_nonneg_of_nonneg_of_le_pi h.le (toReal_le_pi θ)))⟩ #align real.angle.to_real_neg_iff_sign_neg Real.Angle.toReal_neg_iff_sign_neg theorem toReal_nonneg_iff_sign_nonneg {θ : Angle} : 0 ≤ θ.toReal ↔ 0 ≤ θ.sign := by rcases lt_trichotomy θ.toReal 0 with (h | h | h) · refine ⟨fun hn => False.elim (h.not_le hn), fun hn => ?_⟩ rw [toReal_neg_iff_sign_neg.1 h] at hn exact False.elim (hn.not_lt (by decide)) · simp [h, sign, ← sin_toReal] · refine ⟨fun _ => ?_, fun _ => h.le⟩ rw [sign, ← sin_toReal, sign_nonneg_iff] exact sin_nonneg_of_nonneg_of_le_pi h.le (toReal_le_pi θ) #align real.angle.to_real_nonneg_iff_sign_nonneg Real.Angle.toReal_nonneg_iff_sign_nonneg @[simp]
Mathlib/Analysis/SpecialFunctions/Trigonometric/Angle.lean
924
930
theorem sign_toReal {θ : Angle} (h : θ ≠ π) : SignType.sign θ.toReal = θ.sign := by
rcases lt_trichotomy θ.toReal 0 with (ht | ht | ht) · simp [ht, toReal_neg_iff_sign_neg.1 ht] · simp [sign, ht, ← sin_toReal] · rw [sign, ← sin_toReal, sign_pos ht, sign_pos (sin_pos_of_pos_of_lt_pi ht ((toReal_le_pi θ).lt_of_ne (toReal_eq_pi_iff.not.2 h)))]
import Mathlib.Data.Matrix.Basic variable {l m n o : Type*} universe u v w variable {R : Type*} {α : Type v} {β : Type w} namespace Matrix def col (w : m → α) : Matrix m Unit α := of fun x _ => w x #align matrix.col Matrix.col -- TODO: set as an equation lemma for `col`, see mathlib4#3024 @[simp] theorem col_apply (w : m → α) (i j) : col w i j = w i := rfl #align matrix.col_apply Matrix.col_apply def row (v : n → α) : Matrix Unit n α := of fun _ y => v y #align matrix.row Matrix.row -- TODO: set as an equation lemma for `row`, see mathlib4#3024 @[simp] theorem row_apply (v : n → α) (i j) : row v i j = v j := rfl #align matrix.row_apply Matrix.row_apply theorem col_injective : Function.Injective (col : (m → α) → _) := fun _x _y h => funext fun i => congr_fun₂ h i () @[simp] theorem col_inj {v w : m → α} : col v = col w ↔ v = w := col_injective.eq_iff @[simp] theorem col_zero [Zero α] : col (0 : m → α) = 0 := rfl @[simp] theorem col_eq_zero [Zero α] (v : m → α) : col v = 0 ↔ v = 0 := col_inj @[simp] theorem col_add [Add α] (v w : m → α) : col (v + w) = col v + col w := by ext rfl #align matrix.col_add Matrix.col_add @[simp] theorem col_smul [SMul R α] (x : R) (v : m → α) : col (x • v) = x • col v := by ext rfl #align matrix.col_smul Matrix.col_smul theorem row_injective : Function.Injective (row : (n → α) → _) := fun _x _y h => funext fun j => congr_fun₂ h () j @[simp] theorem row_inj {v w : n → α} : row v = row w ↔ v = w := row_injective.eq_iff @[simp] theorem row_zero [Zero α] : row (0 : n → α) = 0 := rfl @[simp] theorem row_eq_zero [Zero α] (v : n → α) : row v = 0 ↔ v = 0 := row_inj @[simp] theorem row_add [Add α] (v w : m → α) : row (v + w) = row v + row w := by ext rfl #align matrix.row_add Matrix.row_add @[simp] theorem row_smul [SMul R α] (x : R) (v : m → α) : row (x • v) = x • row v := by ext rfl #align matrix.row_smul Matrix.row_smul @[simp] theorem transpose_col (v : m → α) : (Matrix.col v)ᵀ = Matrix.row v := by ext rfl #align matrix.transpose_col Matrix.transpose_col @[simp] theorem transpose_row (v : m → α) : (Matrix.row v)ᵀ = Matrix.col v := by ext rfl #align matrix.transpose_row Matrix.transpose_row @[simp] theorem conjTranspose_col [Star α] (v : m → α) : (col v)ᴴ = row (star v) := by ext rfl #align matrix.conj_transpose_col Matrix.conjTranspose_col @[simp] theorem conjTranspose_row [Star α] (v : m → α) : (row v)ᴴ = col (star v) := by ext rfl #align matrix.conj_transpose_row Matrix.conjTranspose_row theorem row_vecMul [Fintype m] [NonUnitalNonAssocSemiring α] (M : Matrix m n α) (v : m → α) : Matrix.row (v ᵥ* M) = Matrix.row v * M := by ext rfl #align matrix.row_vec_mul Matrix.row_vecMul theorem col_vecMul [Fintype m] [NonUnitalNonAssocSemiring α] (M : Matrix m n α) (v : m → α) : Matrix.col (v ᵥ* M) = (Matrix.row v * M)ᵀ := by ext rfl #align matrix.col_vec_mul Matrix.col_vecMul theorem col_mulVec [Fintype n] [NonUnitalNonAssocSemiring α] (M : Matrix m n α) (v : n → α) : Matrix.col (M *ᵥ v) = M * Matrix.col v := by ext rfl #align matrix.col_mul_vec Matrix.col_mulVec theorem row_mulVec [Fintype n] [NonUnitalNonAssocSemiring α] (M : Matrix m n α) (v : n → α) : Matrix.row (M *ᵥ v) = (M * Matrix.col v)ᵀ := by ext rfl #align matrix.row_mul_vec Matrix.row_mulVec @[simp] theorem row_mul_col_apply [Fintype m] [Mul α] [AddCommMonoid α] (v w : m → α) (i j) : (row v * col w) i j = v ⬝ᵥ w := rfl #align matrix.row_mul_col_apply Matrix.row_mul_col_apply @[simp] theorem diag_col_mul_row [Mul α] [AddCommMonoid α] (a b : n → α) : diag (col a * row b) = a * b := by ext simp [Matrix.mul_apply, col, row] #align matrix.diag_col_mul_row Matrix.diag_col_mul_row theorem vecMulVec_eq [Mul α] [AddCommMonoid α] (w : m → α) (v : n → α) : vecMulVec w v = col w * row v := by ext simp only [vecMulVec, mul_apply, Fintype.univ_punit, Finset.sum_singleton] rfl #align matrix.vec_mul_vec_eq Matrix.vecMulVec_eq def updateRow [DecidableEq m] (M : Matrix m n α) (i : m) (b : n → α) : Matrix m n α := of <| Function.update M i b #align matrix.update_row Matrix.updateRow def updateColumn [DecidableEq n] (M : Matrix m n α) (j : n) (b : m → α) : Matrix m n α := of fun i => Function.update (M i) j (b i) #align matrix.update_column Matrix.updateColumn variable {M : Matrix m n α} {i : m} {j : n} {b : n → α} {c : m → α} @[simp] theorem updateRow_self [DecidableEq m] : updateRow M i b i = b := -- Porting note: (implicit arg) added `(β := _)` Function.update_same (β := fun _ => (n → α)) i b M #align matrix.update_row_self Matrix.updateRow_self @[simp] theorem updateColumn_self [DecidableEq n] : updateColumn M j c i j = c i := -- Porting note: (implicit arg) added `(β := _)` Function.update_same (β := fun _ => α) j (c i) (M i) #align matrix.update_column_self Matrix.updateColumn_self @[simp] theorem updateRow_ne [DecidableEq m] {i' : m} (i_ne : i' ≠ i) : updateRow M i b i' = M i' := -- Porting note: (implicit arg) added `(β := _)` Function.update_noteq (β := fun _ => (n → α)) i_ne b M #align matrix.update_row_ne Matrix.updateRow_ne @[simp] theorem updateColumn_ne [DecidableEq n] {j' : n} (j_ne : j' ≠ j) : updateColumn M j c i j' = M i j' := -- Porting note: (implicit arg) added `(β := _)` Function.update_noteq (β := fun _ => α) j_ne (c i) (M i) #align matrix.update_column_ne Matrix.updateColumn_ne theorem updateRow_apply [DecidableEq m] {i' : m} : updateRow M i b i' j = if i' = i then b j else M i' j := by by_cases h : i' = i · rw [h, updateRow_self, if_pos rfl] · rw [updateRow_ne h, if_neg h] #align matrix.update_row_apply Matrix.updateRow_apply theorem updateColumn_apply [DecidableEq n] {j' : n} : updateColumn M j c i j' = if j' = j then c i else M i j' := by by_cases h : j' = j · rw [h, updateColumn_self, if_pos rfl] · rw [updateColumn_ne h, if_neg h] #align matrix.update_column_apply Matrix.updateColumn_apply @[simp] theorem updateColumn_subsingleton [Subsingleton n] (A : Matrix m n R) (i : n) (b : m → R) : A.updateColumn i b = (col b).submatrix id (Function.const n ()) := by ext x y simp [updateColumn_apply, Subsingleton.elim i y] #align matrix.update_column_subsingleton Matrix.updateColumn_subsingleton @[simp] theorem updateRow_subsingleton [Subsingleton m] (A : Matrix m n R) (i : m) (b : n → R) : A.updateRow i b = (row b).submatrix (Function.const m ()) id := by ext x y simp [updateColumn_apply, Subsingleton.elim i x] #align matrix.update_row_subsingleton Matrix.updateRow_subsingleton theorem map_updateRow [DecidableEq m] (f : α → β) : map (updateRow M i b) f = updateRow (M.map f) i (f ∘ b) := by ext rw [updateRow_apply, map_apply, map_apply, updateRow_apply] exact apply_ite f _ _ _ #align matrix.map_update_row Matrix.map_updateRow theorem map_updateColumn [DecidableEq n] (f : α → β) : map (updateColumn M j c) f = updateColumn (M.map f) j (f ∘ c) := by ext rw [updateColumn_apply, map_apply, map_apply, updateColumn_apply] exact apply_ite f _ _ _ #align matrix.map_update_column Matrix.map_updateColumn theorem updateRow_transpose [DecidableEq n] : updateRow Mᵀ j c = (updateColumn M j c)ᵀ := by ext rw [transpose_apply, updateRow_apply, updateColumn_apply] rfl #align matrix.update_row_transpose Matrix.updateRow_transpose theorem updateColumn_transpose [DecidableEq m] : updateColumn Mᵀ i b = (updateRow M i b)ᵀ := by ext rw [transpose_apply, updateRow_apply, updateColumn_apply] rfl #align matrix.update_column_transpose Matrix.updateColumn_transpose theorem updateRow_conjTranspose [DecidableEq n] [Star α] : updateRow Mᴴ j (star c) = (updateColumn M j c)ᴴ := by rw [conjTranspose, conjTranspose, transpose_map, transpose_map, updateRow_transpose, map_updateColumn] rfl #align matrix.update_row_conj_transpose Matrix.updateRow_conjTranspose theorem updateColumn_conjTranspose [DecidableEq m] [Star α] : updateColumn Mᴴ i (star b) = (updateRow M i b)ᴴ := by rw [conjTranspose, conjTranspose, transpose_map, transpose_map, updateColumn_transpose, map_updateRow] rfl #align matrix.update_column_conj_transpose Matrix.updateColumn_conjTranspose @[simp] theorem updateRow_eq_self [DecidableEq m] (A : Matrix m n α) (i : m) : A.updateRow i (A i) = A := Function.update_eq_self i A #align matrix.update_row_eq_self Matrix.updateRow_eq_self @[simp] theorem updateColumn_eq_self [DecidableEq n] (A : Matrix m n α) (i : n) : (A.updateColumn i fun j => A j i) = A := funext fun j => Function.update_eq_self i (A j) #align matrix.update_column_eq_self Matrix.updateColumn_eq_self theorem diagonal_updateColumn_single [DecidableEq n] [Zero α] (v : n → α) (i : n) (x : α) : (diagonal v).updateColumn i (Pi.single i x) = diagonal (Function.update v i x) := by ext j k obtain rfl | hjk := eq_or_ne j k · rw [diagonal_apply_eq] obtain rfl | hji := eq_or_ne j i · rw [updateColumn_self, Pi.single_eq_same, Function.update_same] · rw [updateColumn_ne hji, diagonal_apply_eq, Function.update_noteq hji] · rw [diagonal_apply_ne _ hjk] obtain rfl | hki := eq_or_ne k i · rw [updateColumn_self, Pi.single_eq_of_ne hjk] · rw [updateColumn_ne hki, diagonal_apply_ne _ hjk] #align matrix.diagonal_update_column_single Matrix.diagonal_updateColumn_single theorem diagonal_updateRow_single [DecidableEq n] [Zero α] (v : n → α) (i : n) (x : α) : (diagonal v).updateRow i (Pi.single i x) = diagonal (Function.update v i x) := by rw [← diagonal_transpose, updateRow_transpose, diagonal_updateColumn_single, diagonal_transpose] #align matrix.diagonal_update_row_single Matrix.diagonal_updateRow_single
Mathlib/Data/Matrix/RowCol.lean
301
305
theorem updateRow_submatrix_equiv [DecidableEq l] [DecidableEq m] (A : Matrix m n α) (i : l) (r : o → α) (e : l ≃ m) (f : o ≃ n) : updateRow (A.submatrix e f) i r = (A.updateRow (e i) fun j => r (f.symm j)).submatrix e f := by
ext i' j simp only [submatrix_apply, updateRow_apply, Equiv.apply_eq_iff_eq, Equiv.symm_apply_apply]
import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.Polynomial.Degree.Lemmas #align_import data.polynomial.erase_lead from "leanprover-community/mathlib"@"fa256f00ce018e7b40e1dc756e403c86680bf448" noncomputable section open Polynomial open Polynomial Finset namespace Polynomial variable {R : Type*} [Semiring R] {f : R[X]} def eraseLead (f : R[X]) : R[X] := Polynomial.erase f.natDegree f #align polynomial.erase_lead Polynomial.eraseLead section EraseLead theorem eraseLead_support (f : R[X]) : f.eraseLead.support = f.support.erase f.natDegree := by simp only [eraseLead, support_erase] #align polynomial.erase_lead_support Polynomial.eraseLead_support theorem eraseLead_coeff (i : ℕ) : f.eraseLead.coeff i = if i = f.natDegree then 0 else f.coeff i := by simp only [eraseLead, coeff_erase] #align polynomial.erase_lead_coeff Polynomial.eraseLead_coeff @[simp] theorem eraseLead_coeff_natDegree : f.eraseLead.coeff f.natDegree = 0 := by simp [eraseLead_coeff] #align polynomial.erase_lead_coeff_nat_degree Polynomial.eraseLead_coeff_natDegree theorem eraseLead_coeff_of_ne (i : ℕ) (hi : i ≠ f.natDegree) : f.eraseLead.coeff i = f.coeff i := by simp [eraseLead_coeff, hi] #align polynomial.erase_lead_coeff_of_ne Polynomial.eraseLead_coeff_of_ne @[simp] theorem eraseLead_zero : eraseLead (0 : R[X]) = 0 := by simp only [eraseLead, erase_zero] #align polynomial.erase_lead_zero Polynomial.eraseLead_zero @[simp] theorem eraseLead_add_monomial_natDegree_leadingCoeff (f : R[X]) : f.eraseLead + monomial f.natDegree f.leadingCoeff = f := (add_comm _ _).trans (f.monomial_add_erase _) #align polynomial.erase_lead_add_monomial_nat_degree_leading_coeff Polynomial.eraseLead_add_monomial_natDegree_leadingCoeff @[simp] theorem eraseLead_add_C_mul_X_pow (f : R[X]) : f.eraseLead + C f.leadingCoeff * X ^ f.natDegree = f := by rw [C_mul_X_pow_eq_monomial, eraseLead_add_monomial_natDegree_leadingCoeff] set_option linter.uppercaseLean3 false in #align polynomial.erase_lead_add_C_mul_X_pow Polynomial.eraseLead_add_C_mul_X_pow @[simp] theorem self_sub_monomial_natDegree_leadingCoeff {R : Type*} [Ring R] (f : R[X]) : f - monomial f.natDegree f.leadingCoeff = f.eraseLead := (eq_sub_iff_add_eq.mpr (eraseLead_add_monomial_natDegree_leadingCoeff f)).symm #align polynomial.self_sub_monomial_nat_degree_leading_coeff Polynomial.self_sub_monomial_natDegree_leadingCoeff @[simp] theorem self_sub_C_mul_X_pow {R : Type*} [Ring R] (f : R[X]) : f - C f.leadingCoeff * X ^ f.natDegree = f.eraseLead := by rw [C_mul_X_pow_eq_monomial, self_sub_monomial_natDegree_leadingCoeff] set_option linter.uppercaseLean3 false in #align polynomial.self_sub_C_mul_X_pow Polynomial.self_sub_C_mul_X_pow theorem eraseLead_ne_zero (f0 : 2 ≤ f.support.card) : eraseLead f ≠ 0 := by rw [Ne, ← card_support_eq_zero, eraseLead_support] exact (zero_lt_one.trans_le <| (tsub_le_tsub_right f0 1).trans Finset.pred_card_le_card_erase).ne.symm #align polynomial.erase_lead_ne_zero Polynomial.eraseLead_ne_zero theorem lt_natDegree_of_mem_eraseLead_support {a : ℕ} (h : a ∈ (eraseLead f).support) : a < f.natDegree := by rw [eraseLead_support, mem_erase] at h exact (le_natDegree_of_mem_supp a h.2).lt_of_ne h.1 #align polynomial.lt_nat_degree_of_mem_erase_lead_support Polynomial.lt_natDegree_of_mem_eraseLead_support theorem ne_natDegree_of_mem_eraseLead_support {a : ℕ} (h : a ∈ (eraseLead f).support) : a ≠ f.natDegree := (lt_natDegree_of_mem_eraseLead_support h).ne #align polynomial.ne_nat_degree_of_mem_erase_lead_support Polynomial.ne_natDegree_of_mem_eraseLead_support theorem natDegree_not_mem_eraseLead_support : f.natDegree ∉ (eraseLead f).support := fun h => ne_natDegree_of_mem_eraseLead_support h rfl #align polynomial.nat_degree_not_mem_erase_lead_support Polynomial.natDegree_not_mem_eraseLead_support theorem eraseLead_support_card_lt (h : f ≠ 0) : (eraseLead f).support.card < f.support.card := by rw [eraseLead_support] exact card_lt_card (erase_ssubset <| natDegree_mem_support_of_nonzero h) #align polynomial.erase_lead_support_card_lt Polynomial.eraseLead_support_card_lt theorem card_support_eraseLead_add_one (h : f ≠ 0) : f.eraseLead.support.card + 1 = f.support.card := by set c := f.support.card with hc cases h₁ : c case zero => by_contra exact h (card_support_eq_zero.mp h₁) case succ => rw [eraseLead_support, card_erase_of_mem (natDegree_mem_support_of_nonzero h), ← hc, h₁] rfl @[simp] theorem card_support_eraseLead : f.eraseLead.support.card = f.support.card - 1 := by by_cases hf : f = 0 · rw [hf, eraseLead_zero, support_zero, card_empty] · rw [← card_support_eraseLead_add_one hf, add_tsub_cancel_right] theorem card_support_eraseLead' {c : ℕ} (fc : f.support.card = c + 1) : f.eraseLead.support.card = c := by rw [card_support_eraseLead, fc, add_tsub_cancel_right] #align polynomial.erase_lead_card_support' Polynomial.card_support_eraseLead' theorem card_support_eq_one_of_eraseLead_eq_zero (h₀ : f ≠ 0) (h₁ : f.eraseLead = 0) : f.support.card = 1 := (card_support_eq_zero.mpr h₁ ▸ card_support_eraseLead_add_one h₀).symm theorem card_support_le_one_of_eraseLead_eq_zero (h : f.eraseLead = 0) : f.support.card ≤ 1 := by by_cases hpz : f = 0 case pos => simp [hpz] case neg => exact le_of_eq (card_support_eq_one_of_eraseLead_eq_zero hpz h) @[simp] theorem eraseLead_monomial (i : ℕ) (r : R) : eraseLead (monomial i r) = 0 := by classical by_cases hr : r = 0 · subst r simp only [monomial_zero_right, eraseLead_zero] · rw [eraseLead, natDegree_monomial, if_neg hr, erase_monomial] #align polynomial.erase_lead_monomial Polynomial.eraseLead_monomial @[simp] theorem eraseLead_C (r : R) : eraseLead (C r) = 0 := eraseLead_monomial _ _ set_option linter.uppercaseLean3 false in #align polynomial.erase_lead_C Polynomial.eraseLead_C @[simp] theorem eraseLead_X : eraseLead (X : R[X]) = 0 := eraseLead_monomial _ _ set_option linter.uppercaseLean3 false in #align polynomial.erase_lead_X Polynomial.eraseLead_X @[simp] theorem eraseLead_X_pow (n : ℕ) : eraseLead (X ^ n : R[X]) = 0 := by rw [X_pow_eq_monomial, eraseLead_monomial] set_option linter.uppercaseLean3 false in #align polynomial.erase_lead_X_pow Polynomial.eraseLead_X_pow @[simp] theorem eraseLead_C_mul_X_pow (r : R) (n : ℕ) : eraseLead (C r * X ^ n) = 0 := by rw [C_mul_X_pow_eq_monomial, eraseLead_monomial] set_option linter.uppercaseLean3 false in #align polynomial.erase_lead_C_mul_X_pow Polynomial.eraseLead_C_mul_X_pow @[simp] lemma eraseLead_C_mul_X (r : R) : eraseLead (C r * X) = 0 := by simpa using eraseLead_C_mul_X_pow _ 1 theorem eraseLead_add_of_natDegree_lt_left {p q : R[X]} (pq : q.natDegree < p.natDegree) : (p + q).eraseLead = p.eraseLead + q := by ext n by_cases nd : n = p.natDegree · rw [nd, eraseLead_coeff, if_pos (natDegree_add_eq_left_of_natDegree_lt pq).symm] simpa using (coeff_eq_zero_of_natDegree_lt pq).symm · rw [eraseLead_coeff, coeff_add, coeff_add, eraseLead_coeff, if_neg, if_neg nd] rintro rfl exact nd (natDegree_add_eq_left_of_natDegree_lt pq) #align polynomial.erase_lead_add_of_nat_degree_lt_left Polynomial.eraseLead_add_of_natDegree_lt_left theorem eraseLead_add_of_natDegree_lt_right {p q : R[X]} (pq : p.natDegree < q.natDegree) : (p + q).eraseLead = p + q.eraseLead := by ext n by_cases nd : n = q.natDegree · rw [nd, eraseLead_coeff, if_pos (natDegree_add_eq_right_of_natDegree_lt pq).symm] simpa using (coeff_eq_zero_of_natDegree_lt pq).symm · rw [eraseLead_coeff, coeff_add, coeff_add, eraseLead_coeff, if_neg, if_neg nd] rintro rfl exact nd (natDegree_add_eq_right_of_natDegree_lt pq) #align polynomial.erase_lead_add_of_nat_degree_lt_right Polynomial.eraseLead_add_of_natDegree_lt_right theorem eraseLead_degree_le : (eraseLead f).degree ≤ f.degree := f.degree_erase_le _ #align polynomial.erase_lead_degree_le Polynomial.eraseLead_degree_le theorem eraseLead_natDegree_le_aux : (eraseLead f).natDegree ≤ f.natDegree := natDegree_le_natDegree eraseLead_degree_le #align polynomial.erase_lead_nat_degree_le_aux Polynomial.eraseLead_natDegree_le_aux theorem eraseLead_natDegree_lt (f0 : 2 ≤ f.support.card) : (eraseLead f).natDegree < f.natDegree := lt_of_le_of_ne eraseLead_natDegree_le_aux <| ne_natDegree_of_mem_eraseLead_support <| natDegree_mem_support_of_nonzero <| eraseLead_ne_zero f0 #align polynomial.erase_lead_nat_degree_lt Polynomial.eraseLead_natDegree_lt
Mathlib/Algebra/Polynomial/EraseLead.lean
218
221
theorem natDegree_pos_of_eraseLead_ne_zero (h : f.eraseLead ≠ 0) : 0 < f.natDegree := by
by_contra h₂ rw [eq_C_of_natDegree_eq_zero (Nat.eq_zero_of_not_pos h₂)] at h simp at h
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 [Semiring R] [NoZeroDivisors R] {p q : R[X]} instance : NoZeroDivisors R[X] where eq_zero_or_eq_zero_of_mul_eq_zero h := by rw [← leadingCoeff_eq_zero, ← leadingCoeff_eq_zero] refine eq_zero_or_eq_zero_of_mul_eq_zero ?_ rw [← leadingCoeff_zero, ← leadingCoeff_mul, h] theorem natDegree_mul (hp : p ≠ 0) (hq : q ≠ 0) : (p*q).natDegree = p.natDegree + q.natDegree := by rw [← Nat.cast_inj (R := WithBot ℕ), ← degree_eq_natDegree (mul_ne_zero hp hq), Nat.cast_add, ← degree_eq_natDegree hp, ← degree_eq_natDegree hq, degree_mul] #align polynomial.nat_degree_mul Polynomial.natDegree_mul theorem trailingDegree_mul : (p * q).trailingDegree = p.trailingDegree + q.trailingDegree := by by_cases hp : p = 0 · rw [hp, zero_mul, trailingDegree_zero, top_add] by_cases hq : q = 0 · rw [hq, mul_zero, trailingDegree_zero, add_top] · rw [trailingDegree_eq_natTrailingDegree hp, trailingDegree_eq_natTrailingDegree hq, trailingDegree_eq_natTrailingDegree (mul_ne_zero hp hq), natTrailingDegree_mul hp hq] apply WithTop.coe_add #align polynomial.trailing_degree_mul Polynomial.trailingDegree_mul @[simp]
Mathlib/Algebra/Polynomial/RingDivision.lean
140
145
theorem natDegree_pow (p : R[X]) (n : ℕ) : natDegree (p ^ n) = n * natDegree p := by
classical obtain rfl | hp := eq_or_ne p 0 · obtain rfl | hn := eq_or_ne n 0 <;> simp [*] exact natDegree_pow' $ by rw [← leadingCoeff_pow, Ne, leadingCoeff_eq_zero]; exact pow_ne_zero _ hp
import Mathlib.Algebra.ModEq import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.Archimedean import Mathlib.Algebra.Periodic import Mathlib.Data.Int.SuccPred import Mathlib.GroupTheory.QuotientGroup import Mathlib.Order.Circular import Mathlib.Data.List.TFAE import Mathlib.Data.Set.Lattice #align_import algebra.order.to_interval_mod from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec" noncomputable section section LinearOrderedAddCommGroup variable {α : Type*} [LinearOrderedAddCommGroup α] [hα : Archimedean α] {p : α} (hp : 0 < p) {a b c : α} {n : ℤ} def toIcoDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ico hp b a).choose #align to_Ico_div toIcoDiv theorem sub_toIcoDiv_zsmul_mem_Ico (a b : α) : b - toIcoDiv hp a b • p ∈ Set.Ico a (a + p) := (existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.1 #align sub_to_Ico_div_zsmul_mem_Ico sub_toIcoDiv_zsmul_mem_Ico theorem toIcoDiv_eq_of_sub_zsmul_mem_Ico (h : b - n • p ∈ Set.Ico a (a + p)) : toIcoDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.2 _ h).symm #align to_Ico_div_eq_of_sub_zsmul_mem_Ico toIcoDiv_eq_of_sub_zsmul_mem_Ico def toIocDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose #align to_Ioc_div toIocDiv theorem sub_toIocDiv_zsmul_mem_Ioc (a b : α) : b - toIocDiv hp a b • p ∈ Set.Ioc a (a + p) := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.1 #align sub_to_Ioc_div_zsmul_mem_Ioc sub_toIocDiv_zsmul_mem_Ioc theorem toIocDiv_eq_of_sub_zsmul_mem_Ioc (h : b - n • p ∈ Set.Ioc a (a + p)) : toIocDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.2 _ h).symm #align to_Ioc_div_eq_of_sub_zsmul_mem_Ioc toIocDiv_eq_of_sub_zsmul_mem_Ioc def toIcoMod (a b : α) : α := b - toIcoDiv hp a b • p #align to_Ico_mod toIcoMod def toIocMod (a b : α) : α := b - toIocDiv hp a b • p #align to_Ioc_mod toIocMod theorem toIcoMod_mem_Ico (a b : α) : toIcoMod hp a b ∈ Set.Ico a (a + p) := sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_mod_mem_Ico toIcoMod_mem_Ico theorem toIcoMod_mem_Ico' (b : α) : toIcoMod hp 0 b ∈ Set.Ico 0 p := by convert toIcoMod_mem_Ico hp 0 b exact (zero_add p).symm #align to_Ico_mod_mem_Ico' toIcoMod_mem_Ico' theorem toIocMod_mem_Ioc (a b : α) : toIocMod hp a b ∈ Set.Ioc a (a + p) := sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_mod_mem_Ioc toIocMod_mem_Ioc theorem left_le_toIcoMod (a b : α) : a ≤ toIcoMod hp a b := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).1 #align left_le_to_Ico_mod left_le_toIcoMod theorem left_lt_toIocMod (a b : α) : a < toIocMod hp a b := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).1 #align left_lt_to_Ioc_mod left_lt_toIocMod theorem toIcoMod_lt_right (a b : α) : toIcoMod hp a b < a + p := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).2 #align to_Ico_mod_lt_right toIcoMod_lt_right theorem toIocMod_le_right (a b : α) : toIocMod hp a b ≤ a + p := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).2 #align to_Ioc_mod_le_right toIocMod_le_right @[simp] theorem self_sub_toIcoDiv_zsmul (a b : α) : b - toIcoDiv hp a b • p = toIcoMod hp a b := rfl #align self_sub_to_Ico_div_zsmul self_sub_toIcoDiv_zsmul @[simp] theorem self_sub_toIocDiv_zsmul (a b : α) : b - toIocDiv hp a b • p = toIocMod hp a b := rfl #align self_sub_to_Ioc_div_zsmul self_sub_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_self (a b : α) : toIcoDiv hp a b • p - b = -toIcoMod hp a b := by rw [toIcoMod, neg_sub] #align to_Ico_div_zsmul_sub_self toIcoDiv_zsmul_sub_self @[simp] theorem toIocDiv_zsmul_sub_self (a b : α) : toIocDiv hp a b • p - b = -toIocMod hp a b := by rw [toIocMod, neg_sub] #align to_Ioc_div_zsmul_sub_self toIocDiv_zsmul_sub_self @[simp] theorem toIcoMod_sub_self (a b : α) : toIcoMod hp a b - b = -toIcoDiv hp a b • p := by rw [toIcoMod, sub_sub_cancel_left, neg_smul] #align to_Ico_mod_sub_self toIcoMod_sub_self @[simp] theorem toIocMod_sub_self (a b : α) : toIocMod hp a b - b = -toIocDiv hp a b • p := by rw [toIocMod, sub_sub_cancel_left, neg_smul] #align to_Ioc_mod_sub_self toIocMod_sub_self @[simp] theorem self_sub_toIcoMod (a b : α) : b - toIcoMod hp a b = toIcoDiv hp a b • p := by rw [toIcoMod, sub_sub_cancel] #align self_sub_to_Ico_mod self_sub_toIcoMod @[simp] theorem self_sub_toIocMod (a b : α) : b - toIocMod hp a b = toIocDiv hp a b • p := by rw [toIocMod, sub_sub_cancel] #align self_sub_to_Ioc_mod self_sub_toIocMod @[simp] theorem toIcoMod_add_toIcoDiv_zsmul (a b : α) : toIcoMod hp a b + toIcoDiv hp a b • p = b := by rw [toIcoMod, sub_add_cancel] #align to_Ico_mod_add_to_Ico_div_zsmul toIcoMod_add_toIcoDiv_zsmul @[simp] theorem toIocMod_add_toIocDiv_zsmul (a b : α) : toIocMod hp a b + toIocDiv hp a b • p = b := by rw [toIocMod, sub_add_cancel] #align to_Ioc_mod_add_to_Ioc_div_zsmul toIocMod_add_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_toIcoMod (a b : α) : toIcoDiv hp a b • p + toIcoMod hp a b = b := by rw [add_comm, toIcoMod_add_toIcoDiv_zsmul] #align to_Ico_div_zsmul_sub_to_Ico_mod toIcoDiv_zsmul_sub_toIcoMod @[simp] theorem toIocDiv_zsmul_sub_toIocMod (a b : α) : toIocDiv hp a b • p + toIocMod hp a b = b := by rw [add_comm, toIocMod_add_toIocDiv_zsmul] #align to_Ioc_div_zsmul_sub_to_Ioc_mod toIocDiv_zsmul_sub_toIocMod theorem toIcoMod_eq_iff : toIcoMod hp a b = c ↔ c ∈ Set.Ico a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by refine ⟨fun h => ⟨h ▸ toIcoMod_mem_Ico hp a b, toIcoDiv hp a b, h ▸ (toIcoMod_add_toIcoDiv_zsmul _ _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIcoDiv_eq_of_sub_zsmul_mem_Ico hp hc, toIcoMod] #align to_Ico_mod_eq_iff toIcoMod_eq_iff theorem toIocMod_eq_iff : toIocMod hp a b = c ↔ c ∈ Set.Ioc a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by refine ⟨fun h => ⟨h ▸ toIocMod_mem_Ioc hp a b, toIocDiv hp a b, h ▸ (toIocMod_add_toIocDiv_zsmul hp _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIocDiv_eq_of_sub_zsmul_mem_Ioc hp hc, toIocMod] #align to_Ioc_mod_eq_iff toIocMod_eq_iff @[simp] theorem toIcoDiv_apply_left (a : α) : toIcoDiv hp a a = 0 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_left toIcoDiv_apply_left @[simp] theorem toIocDiv_apply_left (a : α) : toIocDiv hp a a = -1 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_left toIocDiv_apply_left @[simp] theorem toIcoMod_apply_left (a : α) : toIcoMod hp a a = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ico_mod_apply_left toIcoMod_apply_left @[simp] theorem toIocMod_apply_left (a : α) : toIocMod hp a a = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, -1, by simp⟩ #align to_Ioc_mod_apply_left toIocMod_apply_left theorem toIcoDiv_apply_right (a : α) : toIcoDiv hp a (a + p) = 1 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_right toIcoDiv_apply_right theorem toIocDiv_apply_right (a : α) : toIocDiv hp a (a + p) = 0 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_right toIocDiv_apply_right theorem toIcoMod_apply_right (a : α) : toIcoMod hp a (a + p) = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 1, by simp⟩ #align to_Ico_mod_apply_right toIcoMod_apply_right theorem toIocMod_apply_right (a : α) : toIocMod hp a (a + p) = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ioc_mod_apply_right toIocMod_apply_right @[simp] theorem toIcoDiv_add_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b + m • p) = toIcoDiv hp a b + m := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul toIcoDiv_add_zsmul @[simp] theorem toIcoDiv_add_zsmul' (a b : α) (m : ℤ) : toIcoDiv hp (a + m • p) b = toIcoDiv hp a b - m := by refine toIcoDiv_eq_of_sub_zsmul_mem_Ico _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul' toIcoDiv_add_zsmul' @[simp] theorem toIocDiv_add_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b + m • p) = toIocDiv hp a b + m := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul toIocDiv_add_zsmul @[simp] theorem toIocDiv_add_zsmul' (a b : α) (m : ℤ) : toIocDiv hp (a + m • p) b = toIocDiv hp a b - m := by refine toIocDiv_eq_of_sub_zsmul_mem_Ioc _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul' toIocDiv_add_zsmul' @[simp] theorem toIcoDiv_zsmul_add (a b : α) (m : ℤ) : toIcoDiv hp a (m • p + b) = m + toIcoDiv hp a b := by rw [add_comm, toIcoDiv_add_zsmul, add_comm] #align to_Ico_div_zsmul_add toIcoDiv_zsmul_add @[simp] theorem toIocDiv_zsmul_add (a b : α) (m : ℤ) : toIocDiv hp a (m • p + b) = m + toIocDiv hp a b := by rw [add_comm, toIocDiv_add_zsmul, add_comm] #align to_Ioc_div_zsmul_add toIocDiv_zsmul_add @[simp] theorem toIcoDiv_sub_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b - m • p) = toIcoDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul, sub_eq_add_neg] #align to_Ico_div_sub_zsmul toIcoDiv_sub_zsmul @[simp] theorem toIcoDiv_sub_zsmul' (a b : α) (m : ℤ) : toIcoDiv hp (a - m • p) b = toIcoDiv hp a b + m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul', sub_neg_eq_add] #align to_Ico_div_sub_zsmul' toIcoDiv_sub_zsmul' @[simp] theorem toIocDiv_sub_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b - m • p) = toIocDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul, sub_eq_add_neg] #align to_Ioc_div_sub_zsmul toIocDiv_sub_zsmul @[simp] theorem toIocDiv_sub_zsmul' (a b : α) (m : ℤ) : toIocDiv hp (a - m • p) b = toIocDiv hp a b + m := by rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul', sub_neg_eq_add] #align to_Ioc_div_sub_zsmul' toIocDiv_sub_zsmul' @[simp] theorem toIcoDiv_add_right (a b : α) : toIcoDiv hp a (b + p) = toIcoDiv hp a b + 1 := by simpa only [one_zsmul] using toIcoDiv_add_zsmul hp a b 1 #align to_Ico_div_add_right toIcoDiv_add_right @[simp]
Mathlib/Algebra/Order/ToIntervalMod.lean
304
305
theorem toIcoDiv_add_right' (a b : α) : toIcoDiv hp (a + p) b = toIcoDiv hp a b - 1 := by
simpa only [one_zsmul] using toIcoDiv_add_zsmul' hp a b 1
import Mathlib.Algebra.Order.Ring.WithTop import Mathlib.Algebra.Order.Sub.WithTop import Mathlib.Data.Real.NNReal import Mathlib.Order.Interval.Set.WithBotTop #align_import data.real.ennreal from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" open Function Set NNReal variable {α : Type*} def ENNReal := WithTop ℝ≥0 deriving Zero, AddCommMonoidWithOne, SemilatticeSup, DistribLattice, Nontrivial #align ennreal ENNReal @[inherit_doc] scoped[ENNReal] notation "ℝ≥0∞" => ENNReal scoped[ENNReal] notation "∞" => (⊤ : ENNReal) namespace ENNReal instance : OrderBot ℝ≥0∞ := inferInstanceAs (OrderBot (WithTop ℝ≥0)) instance : BoundedOrder ℝ≥0∞ := inferInstanceAs (BoundedOrder (WithTop ℝ≥0)) instance : CharZero ℝ≥0∞ := inferInstanceAs (CharZero (WithTop ℝ≥0)) noncomputable instance : CanonicallyOrderedCommSemiring ℝ≥0∞ := inferInstanceAs (CanonicallyOrderedCommSemiring (WithTop ℝ≥0)) noncomputable instance : CompleteLinearOrder ℝ≥0∞ := inferInstanceAs (CompleteLinearOrder (WithTop ℝ≥0)) instance : DenselyOrdered ℝ≥0∞ := inferInstanceAs (DenselyOrdered (WithTop ℝ≥0)) noncomputable instance : CanonicallyLinearOrderedAddCommMonoid ℝ≥0∞ := inferInstanceAs (CanonicallyLinearOrderedAddCommMonoid (WithTop ℝ≥0)) noncomputable instance instSub : Sub ℝ≥0∞ := inferInstanceAs (Sub (WithTop ℝ≥0)) noncomputable instance : OrderedSub ℝ≥0∞ := inferInstanceAs (OrderedSub (WithTop ℝ≥0)) noncomputable instance : LinearOrderedAddCommMonoidWithTop ℝ≥0∞ := inferInstanceAs (LinearOrderedAddCommMonoidWithTop (WithTop ℝ≥0)) -- Porting note: rfc: redefine using pattern matching? noncomputable instance : Inv ℝ≥0∞ := ⟨fun a => sInf { b | 1 ≤ a * b }⟩ noncomputable instance : DivInvMonoid ℝ≥0∞ where variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0} -- Porting note: are these 2 instances still required in Lean 4? instance covariantClass_mul_le : CovariantClass ℝ≥0∞ ℝ≥0∞ (· * ·) (· ≤ ·) := inferInstance #align ennreal.covariant_class_mul_le ENNReal.covariantClass_mul_le instance covariantClass_add_le : CovariantClass ℝ≥0∞ ℝ≥0∞ (· + ·) (· ≤ ·) := inferInstance #align ennreal.covariant_class_add_le ENNReal.covariantClass_add_le -- Porting note (#11215): TODO: add a `WithTop` instance and use it here noncomputable instance : LinearOrderedCommMonoidWithZero ℝ≥0∞ := { inferInstanceAs (LinearOrderedAddCommMonoidWithTop ℝ≥0∞), inferInstanceAs (CommSemiring ℝ≥0∞) with mul_le_mul_left := fun _ _ => mul_le_mul_left' zero_le_one := zero_le 1 } noncomputable instance : Unique (AddUnits ℝ≥0∞) where default := 0 uniq a := AddUnits.ext <| le_zero_iff.1 <| by rw [← a.add_neg]; exact le_self_add instance : Inhabited ℝ≥0∞ := ⟨0⟩ @[coe, match_pattern] def ofNNReal : ℝ≥0 → ℝ≥0∞ := WithTop.some instance : Coe ℝ≥0 ℝ≥0∞ := ⟨ofNNReal⟩ @[elab_as_elim, induction_eliminator, cases_eliminator] def recTopCoe {C : ℝ≥0∞ → Sort*} (top : C ∞) (coe : ∀ x : ℝ≥0, C x) (x : ℝ≥0∞) : C x := WithTop.recTopCoe top coe x instance canLift : CanLift ℝ≥0∞ ℝ≥0 ofNNReal (· ≠ ∞) := WithTop.canLift #align ennreal.can_lift ENNReal.canLift @[simp] theorem none_eq_top : (none : ℝ≥0∞) = ∞ := rfl #align ennreal.none_eq_top ENNReal.none_eq_top @[simp] theorem some_eq_coe (a : ℝ≥0) : (Option.some a : ℝ≥0∞) = (↑a : ℝ≥0∞) := rfl #align ennreal.some_eq_coe ENNReal.some_eq_coe @[simp] theorem some_eq_coe' (a : ℝ≥0) : (WithTop.some a : ℝ≥0∞) = (↑a : ℝ≥0∞) := rfl lemma coe_injective : Injective ((↑) : ℝ≥0 → ℝ≥0∞) := WithTop.coe_injective @[simp, norm_cast] lemma coe_inj : (p : ℝ≥0∞) = q ↔ p = q := coe_injective.eq_iff #align ennreal.coe_eq_coe ENNReal.coe_inj lemma coe_ne_coe : (p : ℝ≥0∞) ≠ q ↔ p ≠ q := coe_inj.not theorem range_coe' : range ofNNReal = Iio ∞ := WithTop.range_coe theorem range_coe : range ofNNReal = {∞}ᶜ := (isCompl_range_some_none ℝ≥0).symm.compl_eq.symm protected def toNNReal : ℝ≥0∞ → ℝ≥0 := WithTop.untop' 0 #align ennreal.to_nnreal ENNReal.toNNReal protected def toReal (a : ℝ≥0∞) : Real := a.toNNReal #align ennreal.to_real ENNReal.toReal protected noncomputable def ofReal (r : Real) : ℝ≥0∞ := r.toNNReal #align ennreal.of_real ENNReal.ofReal @[simp, norm_cast] theorem toNNReal_coe : (r : ℝ≥0∞).toNNReal = r := rfl #align ennreal.to_nnreal_coe ENNReal.toNNReal_coe @[simp] theorem coe_toNNReal : ∀ {a : ℝ≥0∞}, a ≠ ∞ → ↑a.toNNReal = a | ofNNReal _, _ => rfl | ⊤, h => (h rfl).elim #align ennreal.coe_to_nnreal ENNReal.coe_toNNReal @[simp] theorem ofReal_toReal {a : ℝ≥0∞} (h : a ≠ ∞) : ENNReal.ofReal a.toReal = a := by simp [ENNReal.toReal, ENNReal.ofReal, h] #align ennreal.of_real_to_real ENNReal.ofReal_toReal @[simp] theorem toReal_ofReal {r : ℝ} (h : 0 ≤ r) : (ENNReal.ofReal r).toReal = r := max_eq_left h #align ennreal.to_real_of_real ENNReal.toReal_ofReal theorem toReal_ofReal' {r : ℝ} : (ENNReal.ofReal r).toReal = max r 0 := rfl #align ennreal.to_real_of_real' ENNReal.toReal_ofReal' theorem coe_toNNReal_le_self : ∀ {a : ℝ≥0∞}, ↑a.toNNReal ≤ a | ofNNReal r => by rw [toNNReal_coe] | ⊤ => le_top #align ennreal.coe_to_nnreal_le_self ENNReal.coe_toNNReal_le_self theorem coe_nnreal_eq (r : ℝ≥0) : (r : ℝ≥0∞) = ENNReal.ofReal r := by rw [ENNReal.ofReal, Real.toNNReal_coe] #align ennreal.coe_nnreal_eq ENNReal.coe_nnreal_eq theorem ofReal_eq_coe_nnreal {x : ℝ} (h : 0 ≤ x) : ENNReal.ofReal x = ofNNReal ⟨x, h⟩ := (coe_nnreal_eq ⟨x, h⟩).symm #align ennreal.of_real_eq_coe_nnreal ENNReal.ofReal_eq_coe_nnreal @[simp] theorem ofReal_coe_nnreal : ENNReal.ofReal p = p := (coe_nnreal_eq p).symm #align ennreal.of_real_coe_nnreal ENNReal.ofReal_coe_nnreal @[simp, norm_cast] theorem coe_zero : ↑(0 : ℝ≥0) = (0 : ℝ≥0∞) := rfl #align ennreal.coe_zero ENNReal.coe_zero @[simp, norm_cast] theorem coe_one : ↑(1 : ℝ≥0) = (1 : ℝ≥0∞) := rfl #align ennreal.coe_one ENNReal.coe_one @[simp] theorem toReal_nonneg {a : ℝ≥0∞} : 0 ≤ a.toReal := a.toNNReal.2 #align ennreal.to_real_nonneg ENNReal.toReal_nonneg @[simp] theorem top_toNNReal : ∞.toNNReal = 0 := rfl #align ennreal.top_to_nnreal ENNReal.top_toNNReal @[simp] theorem top_toReal : ∞.toReal = 0 := rfl #align ennreal.top_to_real ENNReal.top_toReal @[simp] theorem one_toReal : (1 : ℝ≥0∞).toReal = 1 := rfl #align ennreal.one_to_real ENNReal.one_toReal @[simp] theorem one_toNNReal : (1 : ℝ≥0∞).toNNReal = 1 := rfl #align ennreal.one_to_nnreal ENNReal.one_toNNReal @[simp] theorem coe_toReal (r : ℝ≥0) : (r : ℝ≥0∞).toReal = r := rfl #align ennreal.coe_to_real ENNReal.coe_toReal @[simp] theorem zero_toNNReal : (0 : ℝ≥0∞).toNNReal = 0 := rfl #align ennreal.zero_to_nnreal ENNReal.zero_toNNReal @[simp] theorem zero_toReal : (0 : ℝ≥0∞).toReal = 0 := rfl #align ennreal.zero_to_real ENNReal.zero_toReal @[simp] theorem ofReal_zero : ENNReal.ofReal (0 : ℝ) = 0 := by simp [ENNReal.ofReal] #align ennreal.of_real_zero ENNReal.ofReal_zero @[simp] theorem ofReal_one : ENNReal.ofReal (1 : ℝ) = (1 : ℝ≥0∞) := by simp [ENNReal.ofReal] #align ennreal.of_real_one ENNReal.ofReal_one theorem ofReal_toReal_le {a : ℝ≥0∞} : ENNReal.ofReal a.toReal ≤ a := if ha : a = ∞ then ha.symm ▸ le_top else le_of_eq (ofReal_toReal ha) #align ennreal.of_real_to_real_le ENNReal.ofReal_toReal_le theorem forall_ennreal {p : ℝ≥0∞ → Prop} : (∀ a, p a) ↔ (∀ r : ℝ≥0, p r) ∧ p ∞ := Option.forall.trans and_comm #align ennreal.forall_ennreal ENNReal.forall_ennreal theorem forall_ne_top {p : ℝ≥0∞ → Prop} : (∀ a, a ≠ ∞ → p a) ↔ ∀ r : ℝ≥0, p r := Option.ball_ne_none #align ennreal.forall_ne_top ENNReal.forall_ne_top theorem exists_ne_top {p : ℝ≥0∞ → Prop} : (∃ a ≠ ∞, p a) ↔ ∃ r : ℝ≥0, p r := Option.exists_ne_none #align ennreal.exists_ne_top ENNReal.exists_ne_top theorem toNNReal_eq_zero_iff (x : ℝ≥0∞) : x.toNNReal = 0 ↔ x = 0 ∨ x = ∞ := WithTop.untop'_eq_self_iff #align ennreal.to_nnreal_eq_zero_iff ENNReal.toNNReal_eq_zero_iff theorem toReal_eq_zero_iff (x : ℝ≥0∞) : x.toReal = 0 ↔ x = 0 ∨ x = ∞ := by simp [ENNReal.toReal, toNNReal_eq_zero_iff] #align ennreal.to_real_eq_zero_iff ENNReal.toReal_eq_zero_iff theorem toNNReal_ne_zero : a.toNNReal ≠ 0 ↔ a ≠ 0 ∧ a ≠ ∞ := a.toNNReal_eq_zero_iff.not.trans not_or #align ennreal.to_nnreal_ne_zero ENNReal.toNNReal_ne_zero theorem toReal_ne_zero : a.toReal ≠ 0 ↔ a ≠ 0 ∧ a ≠ ∞ := a.toReal_eq_zero_iff.not.trans not_or #align ennreal.to_real_ne_zero ENNReal.toReal_ne_zero theorem toNNReal_eq_one_iff (x : ℝ≥0∞) : x.toNNReal = 1 ↔ x = 1 := WithTop.untop'_eq_iff.trans <| by simp #align ennreal.to_nnreal_eq_one_iff ENNReal.toNNReal_eq_one_iff theorem toReal_eq_one_iff (x : ℝ≥0∞) : x.toReal = 1 ↔ x = 1 := by rw [ENNReal.toReal, NNReal.coe_eq_one, ENNReal.toNNReal_eq_one_iff] #align ennreal.to_real_eq_one_iff ENNReal.toReal_eq_one_iff theorem toNNReal_ne_one : a.toNNReal ≠ 1 ↔ a ≠ 1 := a.toNNReal_eq_one_iff.not #align ennreal.to_nnreal_ne_one ENNReal.toNNReal_ne_one theorem toReal_ne_one : a.toReal ≠ 1 ↔ a ≠ 1 := a.toReal_eq_one_iff.not #align ennreal.to_real_ne_one ENNReal.toReal_ne_one @[simp] theorem coe_ne_top : (r : ℝ≥0∞) ≠ ∞ := WithTop.coe_ne_top #align ennreal.coe_ne_top ENNReal.coe_ne_top @[simp] theorem top_ne_coe : ∞ ≠ (r : ℝ≥0∞) := WithTop.top_ne_coe #align ennreal.top_ne_coe ENNReal.top_ne_coe @[simp] theorem coe_lt_top : (r : ℝ≥0∞) < ∞ := WithTop.coe_lt_top r #align ennreal.coe_lt_top ENNReal.coe_lt_top @[simp] theorem ofReal_ne_top {r : ℝ} : ENNReal.ofReal r ≠ ∞ := coe_ne_top #align ennreal.of_real_ne_top ENNReal.ofReal_ne_top @[simp] theorem ofReal_lt_top {r : ℝ} : ENNReal.ofReal r < ∞ := coe_lt_top #align ennreal.of_real_lt_top ENNReal.ofReal_lt_top @[simp] theorem top_ne_ofReal {r : ℝ} : ∞ ≠ ENNReal.ofReal r := top_ne_coe #align ennreal.top_ne_of_real ENNReal.top_ne_ofReal @[simp] theorem ofReal_toReal_eq_iff : ENNReal.ofReal a.toReal = a ↔ a ≠ ⊤ := ⟨fun h => by rw [← h] exact ofReal_ne_top, ofReal_toReal⟩ #align ennreal.of_real_to_real_eq_iff ENNReal.ofReal_toReal_eq_iff @[simp] theorem toReal_ofReal_eq_iff {a : ℝ} : (ENNReal.ofReal a).toReal = a ↔ 0 ≤ a := ⟨fun h => by rw [← h] exact toReal_nonneg, toReal_ofReal⟩ #align ennreal.to_real_of_real_eq_iff ENNReal.toReal_ofReal_eq_iff @[simp] theorem zero_ne_top : 0 ≠ ∞ := coe_ne_top #align ennreal.zero_ne_top ENNReal.zero_ne_top @[simp] theorem top_ne_zero : ∞ ≠ 0 := top_ne_coe #align ennreal.top_ne_zero ENNReal.top_ne_zero @[simp] theorem one_ne_top : 1 ≠ ∞ := coe_ne_top #align ennreal.one_ne_top ENNReal.one_ne_top @[simp] theorem top_ne_one : ∞ ≠ 1 := top_ne_coe #align ennreal.top_ne_one ENNReal.top_ne_one @[simp] theorem zero_lt_top : 0 < ∞ := coe_lt_top @[simp, norm_cast] theorem coe_le_coe : (↑r : ℝ≥0∞) ≤ ↑q ↔ r ≤ q := WithTop.coe_le_coe #align ennreal.coe_le_coe ENNReal.coe_le_coe @[simp, norm_cast] theorem coe_lt_coe : (↑r : ℝ≥0∞) < ↑q ↔ r < q := WithTop.coe_lt_coe #align ennreal.coe_lt_coe ENNReal.coe_lt_coe -- Needed until `@[gcongr]` accepts iff statements alias ⟨_, coe_le_coe_of_le⟩ := coe_le_coe attribute [gcongr] ENNReal.coe_le_coe_of_le -- Needed until `@[gcongr]` accepts iff statements alias ⟨_, coe_lt_coe_of_lt⟩ := coe_lt_coe attribute [gcongr] ENNReal.coe_lt_coe_of_lt theorem coe_mono : Monotone ofNNReal := fun _ _ => coe_le_coe.2 #align ennreal.coe_mono ENNReal.coe_mono theorem coe_strictMono : StrictMono ofNNReal := fun _ _ => coe_lt_coe.2 @[simp, norm_cast] theorem coe_eq_zero : (↑r : ℝ≥0∞) = 0 ↔ r = 0 := coe_inj #align ennreal.coe_eq_zero ENNReal.coe_eq_zero @[simp, norm_cast] theorem zero_eq_coe : 0 = (↑r : ℝ≥0∞) ↔ 0 = r := coe_inj #align ennreal.zero_eq_coe ENNReal.zero_eq_coe @[simp, norm_cast] theorem coe_eq_one : (↑r : ℝ≥0∞) = 1 ↔ r = 1 := coe_inj #align ennreal.coe_eq_one ENNReal.coe_eq_one @[simp, norm_cast] theorem one_eq_coe : 1 = (↑r : ℝ≥0∞) ↔ 1 = r := coe_inj #align ennreal.one_eq_coe ENNReal.one_eq_coe @[simp, norm_cast] theorem coe_pos : 0 < (r : ℝ≥0∞) ↔ 0 < r := coe_lt_coe #align ennreal.coe_pos ENNReal.coe_pos theorem coe_ne_zero : (r : ℝ≥0∞) ≠ 0 ↔ r ≠ 0 := coe_eq_zero.not #align ennreal.coe_ne_zero ENNReal.coe_ne_zero lemma coe_ne_one : (r : ℝ≥0∞) ≠ 1 ↔ r ≠ 1 := coe_eq_one.not @[simp, norm_cast] lemma coe_add (x y : ℝ≥0) : (↑(x + y) : ℝ≥0∞) = x + y := rfl #align ennreal.coe_add ENNReal.coe_add @[simp, norm_cast] lemma coe_mul (x y : ℝ≥0) : (↑(x * y) : ℝ≥0∞) = x * y := rfl #align ennreal.coe_mul ENNReal.coe_mul @[norm_cast] lemma coe_nsmul (n : ℕ) (x : ℝ≥0) : (↑(n • x) : ℝ≥0∞) = n • x := rfl @[simp, norm_cast] lemma coe_pow (x : ℝ≥0) (n : ℕ) : (↑(x ^ n) : ℝ≥0∞) = x ^ n := rfl #noalign ennreal.coe_bit0 #noalign ennreal.coe_bit1 -- See note [no_index around OfNat.ofNat] @[simp, norm_cast] -- Porting note (#10756): new theorem theorem coe_ofNat (n : ℕ) [n.AtLeastTwo] : ((no_index (OfNat.ofNat n) : ℝ≥0) : ℝ≥0∞) = OfNat.ofNat n := rfl -- Porting note (#11215): TODO: add lemmas about `OfNat.ofNat` and `<`/`≤` theorem coe_two : ((2 : ℝ≥0) : ℝ≥0∞) = 2 := rfl #align ennreal.coe_two ENNReal.coe_two theorem toNNReal_eq_toNNReal_iff (x y : ℝ≥0∞) : x.toNNReal = y.toNNReal ↔ x = y ∨ x = 0 ∧ y = ⊤ ∨ x = ⊤ ∧ y = 0 := WithTop.untop'_eq_untop'_iff #align ennreal.to_nnreal_eq_to_nnreal_iff ENNReal.toNNReal_eq_toNNReal_iff
Mathlib/Data/ENNReal/Basic.lean
438
440
theorem toReal_eq_toReal_iff (x y : ℝ≥0∞) : x.toReal = y.toReal ↔ x = y ∨ x = 0 ∧ y = ⊤ ∨ x = ⊤ ∧ y = 0 := by
simp only [ENNReal.toReal, NNReal.coe_inj, toNNReal_eq_toNNReal_iff]
import Mathlib.Data.Set.Function import Mathlib.Logic.Equiv.Defs import Mathlib.Tactic.Core import Mathlib.Tactic.Attr.Core #align_import logic.equiv.local_equiv from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" open Lean Meta Elab Tactic def mfld_cfg : Simps.Config where attrs := [`mfld_simps] fullyApplied := false #align mfld_cfg mfld_cfg open Function Set variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} structure PartialEquiv (α : Type*) (β : Type*) where toFun : α → β invFun : β → α source : Set α target : Set β map_source' : ∀ ⦃x⦄, x ∈ source → toFun x ∈ target map_target' : ∀ ⦃x⦄, x ∈ target → invFun x ∈ source left_inv' : ∀ ⦃x⦄, x ∈ source → invFun (toFun x) = x right_inv' : ∀ ⦃x⦄, x ∈ target → toFun (invFun x) = x #align local_equiv PartialEquiv attribute [coe] PartialEquiv.toFun namespace PartialEquiv variable (e : PartialEquiv α β) (e' : PartialEquiv β γ) instance [Inhabited α] [Inhabited β] : Inhabited (PartialEquiv α β) := ⟨⟨const α default, const β default, ∅, ∅, mapsTo_empty _ _, mapsTo_empty _ _, eqOn_empty _ _, eqOn_empty _ _⟩⟩ @[symm] protected def symm : PartialEquiv β α where toFun := e.invFun invFun := e.toFun source := e.target target := e.source map_source' := e.map_target' map_target' := e.map_source' left_inv' := e.right_inv' right_inv' := e.left_inv' #align local_equiv.symm PartialEquiv.symm instance : CoeFun (PartialEquiv α β) fun _ => α → β := ⟨PartialEquiv.toFun⟩ def Simps.symm_apply (e : PartialEquiv α β) : β → α := e.symm #align local_equiv.simps.symm_apply PartialEquiv.Simps.symm_apply initialize_simps_projections PartialEquiv (toFun → apply, invFun → symm_apply) -- Porting note: this can be proven with `dsimp only` -- @[simp, mfld_simps] -- theorem coe_mk (f : α → β) (g s t ml mr il ir) : -- (PartialEquiv.mk f g s t ml mr il ir : α → β) = f := by dsimp only -- #align local_equiv.coe_mk PartialEquiv.coe_mk #noalign local_equiv.coe_mk @[simp, mfld_simps] theorem coe_symm_mk (f : α → β) (g s t ml mr il ir) : ((PartialEquiv.mk f g s t ml mr il ir).symm : β → α) = g := rfl #align local_equiv.coe_symm_mk PartialEquiv.coe_symm_mk -- Porting note: this is now a syntactic tautology -- @[simp, mfld_simps] -- theorem toFun_as_coe : e.toFun = e := rfl -- #align local_equiv.to_fun_as_coe PartialEquiv.toFun_as_coe #noalign local_equiv.to_fun_as_coe @[simp, mfld_simps] theorem invFun_as_coe : e.invFun = e.symm := rfl #align local_equiv.inv_fun_as_coe PartialEquiv.invFun_as_coe @[simp, mfld_simps] theorem map_source {x : α} (h : x ∈ e.source) : e x ∈ e.target := e.map_source' h #align local_equiv.map_source PartialEquiv.map_source lemma map_source'' : e '' e.source ⊆ e.target := fun _ ⟨_, hx, hex⟩ ↦ mem_of_eq_of_mem (id hex.symm) (e.map_source' hx) @[simp, mfld_simps] theorem map_target {x : β} (h : x ∈ e.target) : e.symm x ∈ e.source := e.map_target' h #align local_equiv.map_target PartialEquiv.map_target @[simp, mfld_simps] theorem left_inv {x : α} (h : x ∈ e.source) : e.symm (e x) = x := e.left_inv' h #align local_equiv.left_inv PartialEquiv.left_inv @[simp, mfld_simps] theorem right_inv {x : β} (h : x ∈ e.target) : e (e.symm x) = x := e.right_inv' h #align local_equiv.right_inv PartialEquiv.right_inv theorem eq_symm_apply {x : α} {y : β} (hx : x ∈ e.source) (hy : y ∈ e.target) : x = e.symm y ↔ e x = y := ⟨fun h => by rw [← e.right_inv hy, h], fun h => by rw [← e.left_inv hx, h]⟩ #align local_equiv.eq_symm_apply PartialEquiv.eq_symm_apply protected theorem mapsTo : MapsTo e e.source e.target := fun _ => e.map_source #align local_equiv.maps_to PartialEquiv.mapsTo theorem symm_mapsTo : MapsTo e.symm e.target e.source := e.symm.mapsTo #align local_equiv.symm_maps_to PartialEquiv.symm_mapsTo protected theorem leftInvOn : LeftInvOn e.symm e e.source := fun _ => e.left_inv #align local_equiv.left_inv_on PartialEquiv.leftInvOn protected theorem rightInvOn : RightInvOn e.symm e e.target := fun _ => e.right_inv #align local_equiv.right_inv_on PartialEquiv.rightInvOn protected theorem invOn : InvOn e.symm e e.source e.target := ⟨e.leftInvOn, e.rightInvOn⟩ #align local_equiv.inv_on PartialEquiv.invOn protected theorem injOn : InjOn e e.source := e.leftInvOn.injOn #align local_equiv.inj_on PartialEquiv.injOn protected theorem bijOn : BijOn e e.source e.target := e.invOn.bijOn e.mapsTo e.symm_mapsTo #align local_equiv.bij_on PartialEquiv.bijOn protected theorem surjOn : SurjOn e e.source e.target := e.bijOn.surjOn #align local_equiv.surj_on PartialEquiv.surjOn @[simps (config := .asFn)] def _root_.Equiv.toPartialEquivOfImageEq (e : α ≃ β) (s : Set α) (t : Set β) (h : e '' s = t) : PartialEquiv α β where toFun := e invFun := e.symm source := s target := t map_source' x hx := h ▸ mem_image_of_mem _ hx map_target' x hx := by subst t rcases hx with ⟨x, hx, rfl⟩ rwa [e.symm_apply_apply] left_inv' x _ := e.symm_apply_apply x right_inv' x _ := e.apply_symm_apply x @[simps! (config := mfld_cfg)] def _root_.Equiv.toPartialEquiv (e : α ≃ β) : PartialEquiv α β := e.toPartialEquivOfImageEq univ univ <| by rw [image_univ, e.surjective.range_eq] #align equiv.to_local_equiv Equiv.toPartialEquiv #align equiv.to_local_equiv_symm_apply Equiv.toPartialEquiv_symm_apply #align equiv.to_local_equiv_target Equiv.toPartialEquiv_target #align equiv.to_local_equiv_apply Equiv.toPartialEquiv_apply #align equiv.to_local_equiv_source Equiv.toPartialEquiv_source instance inhabitedOfEmpty [IsEmpty α] [IsEmpty β] : Inhabited (PartialEquiv α β) := ⟨((Equiv.equivEmpty α).trans (Equiv.equivEmpty β).symm).toPartialEquiv⟩ #align local_equiv.inhabited_of_empty PartialEquiv.inhabitedOfEmpty @[simps (config := .asFn)] def copy (e : PartialEquiv α β) (f : α → β) (hf : ⇑e = f) (g : β → α) (hg : ⇑e.symm = g) (s : Set α) (hs : e.source = s) (t : Set β) (ht : e.target = t) : PartialEquiv α β where toFun := f invFun := g source := s target := t map_source' _ := ht ▸ hs ▸ hf ▸ e.map_source map_target' _ := hs ▸ ht ▸ hg ▸ e.map_target left_inv' _ := hs ▸ hf ▸ hg ▸ e.left_inv right_inv' _ := ht ▸ hf ▸ hg ▸ e.right_inv #align local_equiv.copy PartialEquiv.copy #align local_equiv.copy_source PartialEquiv.copy_source #align local_equiv.copy_apply PartialEquiv.copy_apply #align local_equiv.copy_symm_apply PartialEquiv.copy_symm_apply #align local_equiv.copy_target PartialEquiv.copy_target theorem copy_eq (e : PartialEquiv α β) (f : α → β) (hf : ⇑e = f) (g : β → α) (hg : ⇑e.symm = g) (s : Set α) (hs : e.source = s) (t : Set β) (ht : e.target = t) : e.copy f hf g hg s hs t ht = e := by substs f g s t cases e rfl #align local_equiv.copy_eq PartialEquiv.copy_eq protected def toEquiv : e.source ≃ e.target where toFun x := ⟨e x, e.map_source x.mem⟩ invFun y := ⟨e.symm y, e.map_target y.mem⟩ left_inv := fun ⟨_, hx⟩ => Subtype.eq <| e.left_inv hx right_inv := fun ⟨_, hy⟩ => Subtype.eq <| e.right_inv hy #align local_equiv.to_equiv PartialEquiv.toEquiv @[simp, mfld_simps] theorem symm_source : e.symm.source = e.target := rfl #align local_equiv.symm_source PartialEquiv.symm_source @[simp, mfld_simps] theorem symm_target : e.symm.target = e.source := rfl #align local_equiv.symm_target PartialEquiv.symm_target @[simp, mfld_simps] theorem symm_symm : e.symm.symm = e := by cases e rfl #align local_equiv.symm_symm PartialEquiv.symm_symm theorem symm_bijective : Function.Bijective (PartialEquiv.symm : PartialEquiv α β → PartialEquiv β α) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ theorem image_source_eq_target : e '' e.source = e.target := e.bijOn.image_eq #align local_equiv.image_source_eq_target PartialEquiv.image_source_eq_target theorem forall_mem_target {p : β → Prop} : (∀ y ∈ e.target, p y) ↔ ∀ x ∈ e.source, p (e x) := by rw [← image_source_eq_target, forall_mem_image] #align local_equiv.forall_mem_target PartialEquiv.forall_mem_target theorem exists_mem_target {p : β → Prop} : (∃ y ∈ e.target, p y) ↔ ∃ x ∈ e.source, p (e x) := by rw [← image_source_eq_target, exists_mem_image] #align local_equiv.exists_mem_target PartialEquiv.exists_mem_target def IsImage (s : Set α) (t : Set β) : Prop := ∀ ⦃x⦄, x ∈ e.source → (e x ∈ t ↔ x ∈ s) #align local_equiv.is_image PartialEquiv.IsImage namespace IsImage variable {e} {s : Set α} {t : Set β} {x : α} {y : β} theorem apply_mem_iff (h : e.IsImage s t) (hx : x ∈ e.source) : e x ∈ t ↔ x ∈ s := h hx #align local_equiv.is_image.apply_mem_iff PartialEquiv.IsImage.apply_mem_iff theorem symm_apply_mem_iff (h : e.IsImage s t) : ∀ ⦃y⦄, y ∈ e.target → (e.symm y ∈ s ↔ y ∈ t) := e.forall_mem_target.mpr fun x hx => by rw [e.left_inv hx, h hx] #align local_equiv.is_image.symm_apply_mem_iff PartialEquiv.IsImage.symm_apply_mem_iff protected theorem symm (h : e.IsImage s t) : e.symm.IsImage t s := h.symm_apply_mem_iff #align local_equiv.is_image.symm PartialEquiv.IsImage.symm @[simp] theorem symm_iff : e.symm.IsImage t s ↔ e.IsImage s t := ⟨fun h => h.symm, fun h => h.symm⟩ #align local_equiv.is_image.symm_iff PartialEquiv.IsImage.symm_iff protected theorem mapsTo (h : e.IsImage s t) : MapsTo e (e.source ∩ s) (e.target ∩ t) := fun _ hx => ⟨e.mapsTo hx.1, (h hx.1).2 hx.2⟩ #align local_equiv.is_image.maps_to PartialEquiv.IsImage.mapsTo theorem symm_mapsTo (h : e.IsImage s t) : MapsTo e.symm (e.target ∩ t) (e.source ∩ s) := h.symm.mapsTo #align local_equiv.is_image.symm_maps_to PartialEquiv.IsImage.symm_mapsTo @[simps (config := .asFn)] def restr (h : e.IsImage s t) : PartialEquiv α β where toFun := e invFun := e.symm source := e.source ∩ s target := e.target ∩ t map_source' := h.mapsTo map_target' := h.symm_mapsTo left_inv' := e.leftInvOn.mono inter_subset_left right_inv' := e.rightInvOn.mono inter_subset_left #align local_equiv.is_image.restr PartialEquiv.IsImage.restr #align local_equiv.is_image.restr_apply PartialEquiv.IsImage.restr_apply #align local_equiv.is_image.restr_source PartialEquiv.IsImage.restr_source #align local_equiv.is_image.restr_target PartialEquiv.IsImage.restr_target #align local_equiv.is_image.restr_symm_apply PartialEquiv.IsImage.restr_symm_apply theorem image_eq (h : e.IsImage s t) : e '' (e.source ∩ s) = e.target ∩ t := h.restr.image_source_eq_target #align local_equiv.is_image.image_eq PartialEquiv.IsImage.image_eq theorem symm_image_eq (h : e.IsImage s t) : e.symm '' (e.target ∩ t) = e.source ∩ s := h.symm.image_eq #align local_equiv.is_image.symm_image_eq PartialEquiv.IsImage.symm_image_eq
Mathlib/Logic/Equiv/PartialEquiv.lean
418
419
theorem iff_preimage_eq : e.IsImage s t ↔ e.source ∩ e ⁻¹' t = e.source ∩ s := by
simp only [IsImage, ext_iff, mem_inter_iff, mem_preimage, and_congr_right_iff]
import Mathlib.Data.List.Join #align_import data.list.permutation from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734" -- Make sure we don't import algebra assert_not_exists Monoid open Nat variable {α β : Type*} namespace List theorem permutationsAux2_fst (t : α) (ts : List α) (r : List β) : ∀ (ys : List α) (f : List α → β), (permutationsAux2 t ts r ys f).1 = ys ++ ts | [], f => rfl | y :: ys, f => by simp [permutationsAux2, permutationsAux2_fst t _ _ ys] #align list.permutations_aux2_fst List.permutationsAux2_fst @[simp] theorem permutationsAux2_snd_nil (t : α) (ts : List α) (r : List β) (f : List α → β) : (permutationsAux2 t ts r [] f).2 = r := rfl #align list.permutations_aux2_snd_nil List.permutationsAux2_snd_nil @[simp] theorem permutationsAux2_snd_cons (t : α) (ts : List α) (r : List β) (y : α) (ys : List α) (f : List α → β) : (permutationsAux2 t ts r (y :: ys) f).2 = f (t :: y :: ys ++ ts) :: (permutationsAux2 t ts r ys fun x : List α => f (y :: x)).2 := by simp [permutationsAux2, permutationsAux2_fst t _ _ ys] #align list.permutations_aux2_snd_cons List.permutationsAux2_snd_cons
Mathlib/Data/List/Permutation.lean
77
79
theorem permutationsAux2_append (t : α) (ts : List α) (r : List β) (ys : List α) (f : List α → β) : (permutationsAux2 t ts nil ys f).2 ++ r = (permutationsAux2 t ts r ys f).2 := by
induction ys generalizing f <;> simp [*]
import Mathlib.Logic.Relation import Mathlib.Data.Option.Basic import Mathlib.Data.Seq.Seq #align_import data.seq.wseq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" namespace Stream' open Function universe u v w def WSeq (α) := Seq (Option α) #align stream.wseq Stream'.WSeq namespace WSeq variable {α : Type u} {β : Type v} {γ : Type w} @[coe] def ofSeq : Seq α → WSeq α := (· <$> ·) some #align stream.wseq.of_seq Stream'.WSeq.ofSeq @[coe] def ofList (l : List α) : WSeq α := ofSeq l #align stream.wseq.of_list Stream'.WSeq.ofList @[coe] def ofStream (l : Stream' α) : WSeq α := ofSeq l #align stream.wseq.of_stream Stream'.WSeq.ofStream instance coeSeq : Coe (Seq α) (WSeq α) := ⟨ofSeq⟩ #align stream.wseq.coe_seq Stream'.WSeq.coeSeq instance coeList : Coe (List α) (WSeq α) := ⟨ofList⟩ #align stream.wseq.coe_list Stream'.WSeq.coeList instance coeStream : Coe (Stream' α) (WSeq α) := ⟨ofStream⟩ #align stream.wseq.coe_stream Stream'.WSeq.coeStream def nil : WSeq α := Seq.nil #align stream.wseq.nil Stream'.WSeq.nil instance inhabited : Inhabited (WSeq α) := ⟨nil⟩ #align stream.wseq.inhabited Stream'.WSeq.inhabited def cons (a : α) : WSeq α → WSeq α := Seq.cons (some a) #align stream.wseq.cons Stream'.WSeq.cons def think : WSeq α → WSeq α := Seq.cons none #align stream.wseq.think Stream'.WSeq.think def destruct : WSeq α → Computation (Option (α × WSeq α)) := Computation.corec fun s => match Seq.destruct s with | none => Sum.inl none | some (none, s') => Sum.inr s' | some (some a, s') => Sum.inl (some (a, s')) #align stream.wseq.destruct Stream'.WSeq.destruct def recOn {C : WSeq α → Sort v} (s : WSeq α) (h1 : C nil) (h2 : ∀ x s, C (cons x s)) (h3 : ∀ s, C (think s)) : C s := Seq.recOn s h1 fun o => Option.recOn o h3 h2 #align stream.wseq.rec_on Stream'.WSeq.recOn protected def Mem (a : α) (s : WSeq α) := Seq.Mem (some a) s #align stream.wseq.mem Stream'.WSeq.Mem instance membership : Membership α (WSeq α) := ⟨WSeq.Mem⟩ #align stream.wseq.has_mem Stream'.WSeq.membership theorem not_mem_nil (a : α) : a ∉ @nil α := Seq.not_mem_nil (some a) #align stream.wseq.not_mem_nil Stream'.WSeq.not_mem_nil def head (s : WSeq α) : Computation (Option α) := Computation.map (Prod.fst <$> ·) (destruct s) #align stream.wseq.head Stream'.WSeq.head def flatten : Computation (WSeq α) → WSeq α := Seq.corec fun c => match Computation.destruct c with | Sum.inl s => Seq.omap (return ·) (Seq.destruct s) | Sum.inr c' => some (none, c') #align stream.wseq.flatten Stream'.WSeq.flatten def tail (s : WSeq α) : WSeq α := flatten <| (fun o => Option.recOn o nil Prod.snd) <$> destruct s #align stream.wseq.tail Stream'.WSeq.tail def drop (s : WSeq α) : ℕ → WSeq α | 0 => s | n + 1 => tail (drop s n) #align stream.wseq.drop Stream'.WSeq.drop def get? (s : WSeq α) (n : ℕ) : Computation (Option α) := head (drop s n) #align stream.wseq.nth Stream'.WSeq.get? def toList (s : WSeq α) : Computation (List α) := @Computation.corec (List α) (List α × WSeq α) (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) ([], s) #align stream.wseq.to_list Stream'.WSeq.toList def length (s : WSeq α) : Computation ℕ := @Computation.corec ℕ (ℕ × WSeq α) (fun ⟨n, s⟩ => match Seq.destruct s with | none => Sum.inl n | some (none, s') => Sum.inr (n, s') | some (some _, s') => Sum.inr (n + 1, s')) (0, s) #align stream.wseq.length Stream'.WSeq.length class IsFinite (s : WSeq α) : Prop where out : (toList s).Terminates #align stream.wseq.is_finite Stream'.WSeq.IsFinite instance toList_terminates (s : WSeq α) [h : IsFinite s] : (toList s).Terminates := h.out #align stream.wseq.to_list_terminates Stream'.WSeq.toList_terminates def get (s : WSeq α) [IsFinite s] : List α := (toList s).get #align stream.wseq.get Stream'.WSeq.get class Productive (s : WSeq α) : Prop where get?_terminates : ∀ n, (get? s n).Terminates #align stream.wseq.productive Stream'.WSeq.Productive #align stream.wseq.productive.nth_terminates Stream'.WSeq.Productive.get?_terminates theorem productive_iff (s : WSeq α) : Productive s ↔ ∀ n, (get? s n).Terminates := ⟨fun h => h.1, fun h => ⟨h⟩⟩ #align stream.wseq.productive_iff Stream'.WSeq.productive_iff instance get?_terminates (s : WSeq α) [h : Productive s] : ∀ n, (get? s n).Terminates := h.get?_terminates #align stream.wseq.nth_terminates Stream'.WSeq.get?_terminates instance head_terminates (s : WSeq α) [Productive s] : (head s).Terminates := s.get?_terminates 0 #align stream.wseq.head_terminates Stream'.WSeq.head_terminates def updateNth (s : WSeq α) (n : ℕ) (a : α) : WSeq α := @Seq.corec (Option α) (ℕ × WSeq α) (fun ⟨n, s⟩ => match Seq.destruct s, n with | none, _ => none | some (none, s'), n => some (none, n, s') | some (some a', s'), 0 => some (some a', 0, s') | some (some _, s'), 1 => some (some a, 0, s') | some (some a', s'), n + 2 => some (some a', n + 1, s')) (n + 1, s) #align stream.wseq.update_nth Stream'.WSeq.updateNth def removeNth (s : WSeq α) (n : ℕ) : WSeq α := @Seq.corec (Option α) (ℕ × WSeq α) (fun ⟨n, s⟩ => match Seq.destruct s, n with | none, _ => none | some (none, s'), n => some (none, n, s') | some (some a', s'), 0 => some (some a', 0, s') | some (some _, s'), 1 => some (none, 0, s') | some (some a', s'), n + 2 => some (some a', n + 1, s')) (n + 1, s) #align stream.wseq.remove_nth Stream'.WSeq.removeNth def filterMap (f : α → Option β) : WSeq α → WSeq β := Seq.corec fun s => match Seq.destruct s with | none => none | some (none, s') => some (none, s') | some (some a, s') => some (f a, s') #align stream.wseq.filter_map Stream'.WSeq.filterMap def filter (p : α → Prop) [DecidablePred p] : WSeq α → WSeq α := filterMap fun a => if p a then some a else none #align stream.wseq.filter Stream'.WSeq.filter -- example of infinite list manipulations def find (p : α → Prop) [DecidablePred p] (s : WSeq α) : Computation (Option α) := head <| filter p s #align stream.wseq.find Stream'.WSeq.find def zipWith (f : α → β → γ) (s1 : WSeq α) (s2 : WSeq β) : WSeq γ := @Seq.corec (Option γ) (WSeq α × WSeq β) (fun ⟨s1, s2⟩ => match Seq.destruct s1, Seq.destruct s2 with | some (none, s1'), some (none, s2') => some (none, s1', s2') | some (some _, _), some (none, s2') => some (none, s1, s2') | some (none, s1'), some (some _, _) => some (none, s1', s2) | some (some a1, s1'), some (some a2, s2') => some (some (f a1 a2), s1', s2') | _, _ => none) (s1, s2) #align stream.wseq.zip_with Stream'.WSeq.zipWith def zip : WSeq α → WSeq β → WSeq (α × β) := zipWith Prod.mk #align stream.wseq.zip Stream'.WSeq.zip def findIndexes (p : α → Prop) [DecidablePred p] (s : WSeq α) : WSeq ℕ := (zip s (Stream'.nats : WSeq ℕ)).filterMap fun ⟨a, n⟩ => if p a then some n else none #align stream.wseq.find_indexes Stream'.WSeq.findIndexes def findIndex (p : α → Prop) [DecidablePred p] (s : WSeq α) : Computation ℕ := (fun o => Option.getD o 0) <$> head (findIndexes p s) #align stream.wseq.find_index Stream'.WSeq.findIndex def indexOf [DecidableEq α] (a : α) : WSeq α → Computation ℕ := findIndex (Eq a) #align stream.wseq.index_of Stream'.WSeq.indexOf def indexesOf [DecidableEq α] (a : α) : WSeq α → WSeq ℕ := findIndexes (Eq a) #align stream.wseq.indexes_of Stream'.WSeq.indexesOf def union (s1 s2 : WSeq α) : WSeq α := @Seq.corec (Option α) (WSeq α × WSeq α) (fun ⟨s1, s2⟩ => match Seq.destruct s1, Seq.destruct s2 with | none, none => none | some (a1, s1'), none => some (a1, s1', nil) | none, some (a2, s2') => some (a2, nil, s2') | some (none, s1'), some (none, s2') => some (none, s1', s2') | some (some a1, s1'), some (none, s2') => some (some a1, s1', s2') | some (none, s1'), some (some a2, s2') => some (some a2, s1', s2') | some (some a1, s1'), some (some a2, s2') => some (some a1, cons a2 s1', s2')) (s1, s2) #align stream.wseq.union Stream'.WSeq.union def isEmpty (s : WSeq α) : Computation Bool := Computation.map Option.isNone <| head s #align stream.wseq.is_empty Stream'.WSeq.isEmpty def compute (s : WSeq α) : WSeq α := match Seq.destruct s with | some (none, s') => s' | _ => s #align stream.wseq.compute Stream'.WSeq.compute def take (s : WSeq α) (n : ℕ) : WSeq α := @Seq.corec (Option α) (ℕ × WSeq α) (fun ⟨n, s⟩ => match n, Seq.destruct s with | 0, _ => none | _ + 1, none => none | m + 1, some (none, s') => some (none, m + 1, s') | m + 1, some (some a, s') => some (some a, m, s')) (n, s) #align stream.wseq.take Stream'.WSeq.take def splitAt (s : WSeq α) (n : ℕ) : Computation (List α × WSeq α) := @Computation.corec (List α × WSeq α) (ℕ × List α × WSeq α) (fun ⟨n, l, s⟩ => match n, Seq.destruct s with | 0, _ => Sum.inl (l.reverse, s) | _ + 1, none => Sum.inl (l.reverse, s) | _ + 1, some (none, s') => Sum.inr (n, l, s') | m + 1, some (some a, s') => Sum.inr (m, a::l, s')) (n, [], s) #align stream.wseq.split_at Stream'.WSeq.splitAt def any (s : WSeq α) (p : α → Bool) : Computation Bool := Computation.corec (fun s : WSeq α => match Seq.destruct s with | none => Sum.inl false | some (none, s') => Sum.inr s' | some (some a, s') => if p a then Sum.inl true else Sum.inr s') s #align stream.wseq.any Stream'.WSeq.any def all (s : WSeq α) (p : α → Bool) : Computation Bool := Computation.corec (fun s : WSeq α => match Seq.destruct s with | none => Sum.inl true | some (none, s') => Sum.inr s' | some (some a, s') => if p a then Sum.inr s' else Sum.inl false) s #align stream.wseq.all Stream'.WSeq.all def scanl (f : α → β → α) (a : α) (s : WSeq β) : WSeq α := cons a <| @Seq.corec (Option α) (α × WSeq β) (fun ⟨a, s⟩ => match Seq.destruct s with | none => none | some (none, s') => some (none, a, s') | some (some b, s') => let a' := f a b some (some a', a', s')) (a, s) #align stream.wseq.scanl Stream'.WSeq.scanl def inits (s : WSeq α) : WSeq (List α) := cons [] <| @Seq.corec (Option (List α)) (Batteries.DList α × WSeq α) (fun ⟨l, s⟩ => match Seq.destruct s with | none => none | some (none, s') => some (none, l, s') | some (some a, s') => let l' := l.push a some (some l'.toList, l', s')) (Batteries.DList.empty, s) #align stream.wseq.inits Stream'.WSeq.inits def collect (s : WSeq α) (n : ℕ) : List α := (Seq.take n s).filterMap id #align stream.wseq.collect Stream'.WSeq.collect def append : WSeq α → WSeq α → WSeq α := Seq.append #align stream.wseq.append Stream'.WSeq.append def map (f : α → β) : WSeq α → WSeq β := Seq.map (Option.map f) #align stream.wseq.map Stream'.WSeq.map def join (S : WSeq (WSeq α)) : WSeq α := Seq.join ((fun o : Option (WSeq α) => match o with | none => Seq1.ret none | some s => (none, s)) <$> S) #align stream.wseq.join Stream'.WSeq.join def bind (s : WSeq α) (f : α → WSeq β) : WSeq β := join (map f s) #align stream.wseq.bind Stream'.WSeq.bind @[simp] def LiftRelO (R : α → β → Prop) (C : WSeq α → WSeq β → Prop) : Option (α × WSeq α) → Option (β × WSeq β) → Prop | none, none => True | some (a, s), some (b, t) => R a b ∧ C s t | _, _ => False #align stream.wseq.lift_rel_o Stream'.WSeq.LiftRelO theorem LiftRelO.imp {R S : α → β → Prop} {C D : WSeq α → WSeq β → Prop} (H1 : ∀ a b, R a b → S a b) (H2 : ∀ s t, C s t → D s t) : ∀ {o p}, LiftRelO R C o p → LiftRelO S D o p | none, none, _ => trivial | some (_, _), some (_, _), h => And.imp (H1 _ _) (H2 _ _) h | none, some _, h => False.elim h | some (_, _), none, h => False.elim h #align stream.wseq.lift_rel_o.imp Stream'.WSeq.LiftRelO.imp theorem LiftRelO.imp_right (R : α → β → Prop) {C D : WSeq α → WSeq β → Prop} (H : ∀ s t, C s t → D s t) {o p} : LiftRelO R C o p → LiftRelO R D o p := LiftRelO.imp (fun _ _ => id) H #align stream.wseq.lift_rel_o.imp_right Stream'.WSeq.LiftRelO.imp_right @[simp] def BisimO (R : WSeq α → WSeq α → Prop) : Option (α × WSeq α) → Option (α × WSeq α) → Prop := LiftRelO (· = ·) R #align stream.wseq.bisim_o Stream'.WSeq.BisimO theorem BisimO.imp {R S : WSeq α → WSeq α → Prop} (H : ∀ s t, R s t → S s t) {o p} : BisimO R o p → BisimO S o p := LiftRelO.imp_right _ H #align stream.wseq.bisim_o.imp Stream'.WSeq.BisimO.imp def LiftRel (R : α → β → Prop) (s : WSeq α) (t : WSeq β) : Prop := ∃ C : WSeq α → WSeq β → Prop, C s t ∧ ∀ {s t}, C s t → Computation.LiftRel (LiftRelO R C) (destruct s) (destruct t) #align stream.wseq.lift_rel Stream'.WSeq.LiftRel def Equiv : WSeq α → WSeq α → Prop := LiftRel (· = ·) #align stream.wseq.equiv Stream'.WSeq.Equiv theorem liftRel_destruct {R : α → β → Prop} {s : WSeq α} {t : WSeq β} : LiftRel R s t → Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t) | ⟨R, h1, h2⟩ => by refine Computation.LiftRel.imp ?_ _ _ (h2 h1) apply LiftRelO.imp_right exact fun s' t' h' => ⟨R, h', @h2⟩ #align stream.wseq.lift_rel_destruct Stream'.WSeq.liftRel_destruct theorem liftRel_destruct_iff {R : α → β → Prop} {s : WSeq α} {t : WSeq β} : LiftRel R s t ↔ Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t) := ⟨liftRel_destruct, fun h => ⟨fun s t => LiftRel R s t ∨ Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t), Or.inr h, fun {s t} h => by have h : Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t) := by cases' h with h h · exact liftRel_destruct h · assumption apply Computation.LiftRel.imp _ _ _ h intro a b apply LiftRelO.imp_right intro s t apply Or.inl⟩⟩ #align stream.wseq.lift_rel_destruct_iff Stream'.WSeq.liftRel_destruct_iff -- Porting note: To avoid ambiguous notation, `~` became `~ʷ`. infixl:50 " ~ʷ " => Equiv theorem destruct_congr {s t : WSeq α} : s ~ʷ t → Computation.LiftRel (BisimO (· ~ʷ ·)) (destruct s) (destruct t) := liftRel_destruct #align stream.wseq.destruct_congr Stream'.WSeq.destruct_congr theorem destruct_congr_iff {s t : WSeq α} : s ~ʷ t ↔ Computation.LiftRel (BisimO (· ~ʷ ·)) (destruct s) (destruct t) := liftRel_destruct_iff #align stream.wseq.destruct_congr_iff Stream'.WSeq.destruct_congr_iff theorem LiftRel.refl (R : α → α → Prop) (H : Reflexive R) : Reflexive (LiftRel R) := fun s => by refine ⟨(· = ·), rfl, fun {s t} (h : s = t) => ?_⟩ rw [← h] apply Computation.LiftRel.refl intro a cases' a with a · simp · cases a simp only [LiftRelO, and_true] apply H #align stream.wseq.lift_rel.refl Stream'.WSeq.LiftRel.refl theorem LiftRelO.swap (R : α → β → Prop) (C) : swap (LiftRelO R C) = LiftRelO (swap R) (swap C) := by funext x y rcases x with ⟨⟩ | ⟨hx, jx⟩ <;> rcases y with ⟨⟩ | ⟨hy, jy⟩ <;> rfl #align stream.wseq.lift_rel_o.swap Stream'.WSeq.LiftRelO.swap theorem LiftRel.swap_lem {R : α → β → Prop} {s1 s2} (h : LiftRel R s1 s2) : LiftRel (swap R) s2 s1 := by refine ⟨swap (LiftRel R), h, fun {s t} (h : LiftRel R t s) => ?_⟩ rw [← LiftRelO.swap, Computation.LiftRel.swap] apply liftRel_destruct h #align stream.wseq.lift_rel.swap_lem Stream'.WSeq.LiftRel.swap_lem theorem LiftRel.swap (R : α → β → Prop) : swap (LiftRel R) = LiftRel (swap R) := funext fun _ => funext fun _ => propext ⟨LiftRel.swap_lem, LiftRel.swap_lem⟩ #align stream.wseq.lift_rel.swap Stream'.WSeq.LiftRel.swap theorem LiftRel.symm (R : α → α → Prop) (H : Symmetric R) : Symmetric (LiftRel R) := fun s1 s2 (h : Function.swap (LiftRel R) s2 s1) => by rwa [LiftRel.swap, H.swap_eq] at h #align stream.wseq.lift_rel.symm Stream'.WSeq.LiftRel.symm theorem LiftRel.trans (R : α → α → Prop) (H : Transitive R) : Transitive (LiftRel R) := fun s t u h1 h2 => by refine ⟨fun s u => ∃ t, LiftRel R s t ∧ LiftRel R t u, ⟨t, h1, h2⟩, fun {s u} h => ?_⟩ rcases h with ⟨t, h1, h2⟩ have h1 := liftRel_destruct h1 have h2 := liftRel_destruct h2 refine Computation.liftRel_def.2 ⟨(Computation.terminates_of_liftRel h1).trans (Computation.terminates_of_liftRel h2), fun {a c} ha hc => ?_⟩ rcases h1.left ha with ⟨b, hb, t1⟩ have t2 := Computation.rel_of_liftRel h2 hb hc cases' a with a <;> cases' c with c · trivial · cases b · cases t2 · cases t1 · cases a cases' b with b · cases t1 · cases b cases t2 · cases' a with a s cases' b with b · cases t1 cases' b with b t cases' c with c u cases' t1 with ab st cases' t2 with bc tu exact ⟨H ab bc, t, st, tu⟩ #align stream.wseq.lift_rel.trans Stream'.WSeq.LiftRel.trans theorem LiftRel.equiv (R : α → α → Prop) : Equivalence R → Equivalence (LiftRel R) | ⟨refl, symm, trans⟩ => ⟨LiftRel.refl R refl, @(LiftRel.symm R @symm), @(LiftRel.trans R @trans)⟩ #align stream.wseq.lift_rel.equiv Stream'.WSeq.LiftRel.equiv @[refl] theorem Equiv.refl : ∀ s : WSeq α, s ~ʷ s := LiftRel.refl (· = ·) Eq.refl #align stream.wseq.equiv.refl Stream'.WSeq.Equiv.refl @[symm] theorem Equiv.symm : ∀ {s t : WSeq α}, s ~ʷ t → t ~ʷ s := @(LiftRel.symm (· = ·) (@Eq.symm _)) #align stream.wseq.equiv.symm Stream'.WSeq.Equiv.symm @[trans] theorem Equiv.trans : ∀ {s t u : WSeq α}, s ~ʷ t → t ~ʷ u → s ~ʷ u := @(LiftRel.trans (· = ·) (@Eq.trans _)) #align stream.wseq.equiv.trans Stream'.WSeq.Equiv.trans theorem Equiv.equivalence : Equivalence (@Equiv α) := ⟨@Equiv.refl _, @Equiv.symm _, @Equiv.trans _⟩ #align stream.wseq.equiv.equivalence Stream'.WSeq.Equiv.equivalence open Computation @[simp] theorem destruct_nil : destruct (nil : WSeq α) = Computation.pure none := Computation.destruct_eq_pure rfl #align stream.wseq.destruct_nil Stream'.WSeq.destruct_nil @[simp] theorem destruct_cons (a : α) (s) : destruct (cons a s) = Computation.pure (some (a, s)) := Computation.destruct_eq_pure <| by simp [destruct, cons, Computation.rmap] #align stream.wseq.destruct_cons Stream'.WSeq.destruct_cons @[simp] theorem destruct_think (s : WSeq α) : destruct (think s) = (destruct s).think := Computation.destruct_eq_think <| by simp [destruct, think, Computation.rmap] #align stream.wseq.destruct_think Stream'.WSeq.destruct_think @[simp] theorem seq_destruct_nil : Seq.destruct (nil : WSeq α) = none := Seq.destruct_nil #align stream.wseq.seq_destruct_nil Stream'.WSeq.seq_destruct_nil @[simp] theorem seq_destruct_cons (a : α) (s) : Seq.destruct (cons a s) = some (some a, s) := Seq.destruct_cons _ _ #align stream.wseq.seq_destruct_cons Stream'.WSeq.seq_destruct_cons @[simp] theorem seq_destruct_think (s : WSeq α) : Seq.destruct (think s) = some (none, s) := Seq.destruct_cons _ _ #align stream.wseq.seq_destruct_think Stream'.WSeq.seq_destruct_think @[simp] theorem head_nil : head (nil : WSeq α) = Computation.pure none := by simp [head] #align stream.wseq.head_nil Stream'.WSeq.head_nil @[simp] theorem head_cons (a : α) (s) : head (cons a s) = Computation.pure (some a) := by simp [head] #align stream.wseq.head_cons Stream'.WSeq.head_cons @[simp] theorem head_think (s : WSeq α) : head (think s) = (head s).think := by simp [head] #align stream.wseq.head_think Stream'.WSeq.head_think @[simp] theorem flatten_pure (s : WSeq α) : flatten (Computation.pure s) = s := by refine Seq.eq_of_bisim (fun s1 s2 => flatten (Computation.pure s2) = s1) ?_ rfl intro s' s h rw [← h] simp only [Seq.BisimO, flatten, Seq.omap, pure_def, Seq.corec_eq, destruct_pure] cases Seq.destruct s with | none => simp | some val => cases' val with o s' simp #align stream.wseq.flatten_ret Stream'.WSeq.flatten_pure @[simp] theorem flatten_think (c : Computation (WSeq α)) : flatten c.think = think (flatten c) := Seq.destruct_eq_cons <| by simp [flatten, think] #align stream.wseq.flatten_think Stream'.WSeq.flatten_think @[simp] theorem destruct_flatten (c : Computation (WSeq α)) : destruct (flatten c) = c >>= destruct := by refine Computation.eq_of_bisim (fun c1 c2 => c1 = c2 ∨ ∃ c, c1 = destruct (flatten c) ∧ c2 = Computation.bind c destruct) ?_ (Or.inr ⟨c, rfl, rfl⟩) intro c1 c2 h exact match c1, c2, h with | c, _, Or.inl rfl => by cases c.destruct <;> simp | _, _, Or.inr ⟨c, rfl, rfl⟩ => by induction' c using Computation.recOn with a c' <;> simp · cases (destruct a).destruct <;> simp · exact Or.inr ⟨c', rfl, rfl⟩ #align stream.wseq.destruct_flatten Stream'.WSeq.destruct_flatten theorem head_terminates_iff (s : WSeq α) : Terminates (head s) ↔ Terminates (destruct s) := terminates_map_iff _ (destruct s) #align stream.wseq.head_terminates_iff Stream'.WSeq.head_terminates_iff @[simp] theorem tail_nil : tail (nil : WSeq α) = nil := by simp [tail] #align stream.wseq.tail_nil Stream'.WSeq.tail_nil @[simp] theorem tail_cons (a : α) (s) : tail (cons a s) = s := by simp [tail] #align stream.wseq.tail_cons Stream'.WSeq.tail_cons @[simp] theorem tail_think (s : WSeq α) : tail (think s) = (tail s).think := by simp [tail] #align stream.wseq.tail_think Stream'.WSeq.tail_think @[simp] theorem dropn_nil (n) : drop (nil : WSeq α) n = nil := by induction n <;> simp [*, drop] #align stream.wseq.dropn_nil Stream'.WSeq.dropn_nil @[simp] theorem dropn_cons (a : α) (s) (n) : drop (cons a s) (n + 1) = drop s n := by induction n with | zero => simp [drop] | succ n n_ih => -- porting note (#10745): was `simp [*, drop]`. simp [drop, ← n_ih] #align stream.wseq.dropn_cons Stream'.WSeq.dropn_cons @[simp] theorem dropn_think (s : WSeq α) (n) : drop (think s) n = (drop s n).think := by induction n <;> simp [*, drop] #align stream.wseq.dropn_think Stream'.WSeq.dropn_think theorem dropn_add (s : WSeq α) (m) : ∀ n, drop s (m + n) = drop (drop s m) n | 0 => rfl | n + 1 => congr_arg tail (dropn_add s m n) #align stream.wseq.dropn_add Stream'.WSeq.dropn_add theorem dropn_tail (s : WSeq α) (n) : drop (tail s) n = drop s (n + 1) := by rw [Nat.add_comm] symm apply dropn_add #align stream.wseq.dropn_tail Stream'.WSeq.dropn_tail theorem get?_add (s : WSeq α) (m n) : get? s (m + n) = get? (drop s m) n := congr_arg head (dropn_add _ _ _) #align stream.wseq.nth_add Stream'.WSeq.get?_add theorem get?_tail (s : WSeq α) (n) : get? (tail s) n = get? s (n + 1) := congr_arg head (dropn_tail _ _) #align stream.wseq.nth_tail Stream'.WSeq.get?_tail @[simp] theorem join_nil : join nil = (nil : WSeq α) := Seq.join_nil #align stream.wseq.join_nil Stream'.WSeq.join_nil @[simp] theorem join_think (S : WSeq (WSeq α)) : join (think S) = think (join S) := by simp only [join, think] dsimp only [(· <$> ·)] simp [join, Seq1.ret] #align stream.wseq.join_think Stream'.WSeq.join_think @[simp] theorem join_cons (s : WSeq α) (S) : join (cons s S) = think (append s (join S)) := by simp only [join, think] dsimp only [(· <$> ·)] simp [join, cons, append] #align stream.wseq.join_cons Stream'.WSeq.join_cons @[simp] theorem nil_append (s : WSeq α) : append nil s = s := Seq.nil_append _ #align stream.wseq.nil_append Stream'.WSeq.nil_append @[simp] theorem cons_append (a : α) (s t) : append (cons a s) t = cons a (append s t) := Seq.cons_append _ _ _ #align stream.wseq.cons_append Stream'.WSeq.cons_append @[simp] theorem think_append (s t : WSeq α) : append (think s) t = think (append s t) := Seq.cons_append _ _ _ #align stream.wseq.think_append Stream'.WSeq.think_append @[simp] theorem append_nil (s : WSeq α) : append s nil = s := Seq.append_nil _ #align stream.wseq.append_nil Stream'.WSeq.append_nil @[simp] theorem append_assoc (s t u : WSeq α) : append (append s t) u = append s (append t u) := Seq.append_assoc _ _ _ #align stream.wseq.append_assoc Stream'.WSeq.append_assoc @[simp] def tail.aux : Option (α × WSeq α) → Computation (Option (α × WSeq α)) | none => Computation.pure none | some (_, s) => destruct s #align stream.wseq.tail.aux Stream'.WSeq.tail.aux theorem destruct_tail (s : WSeq α) : destruct (tail s) = destruct s >>= tail.aux := by simp only [tail, destruct_flatten, tail.aux]; rw [← bind_pure_comp, LawfulMonad.bind_assoc] apply congr_arg; ext1 (_ | ⟨a, s⟩) <;> apply (@pure_bind Computation _ _ _ _ _ _).trans _ <;> simp #align stream.wseq.destruct_tail Stream'.WSeq.destruct_tail @[simp] def drop.aux : ℕ → Option (α × WSeq α) → Computation (Option (α × WSeq α)) | 0 => Computation.pure | n + 1 => fun a => tail.aux a >>= drop.aux n #align stream.wseq.drop.aux Stream'.WSeq.drop.aux theorem drop.aux_none : ∀ n, @drop.aux α n none = Computation.pure none | 0 => rfl | n + 1 => show Computation.bind (Computation.pure none) (drop.aux n) = Computation.pure none by rw [ret_bind, drop.aux_none n] #align stream.wseq.drop.aux_none Stream'.WSeq.drop.aux_none theorem destruct_dropn : ∀ (s : WSeq α) (n), destruct (drop s n) = destruct s >>= drop.aux n | s, 0 => (bind_pure' _).symm | s, n + 1 => by rw [← dropn_tail, destruct_dropn _ n, destruct_tail, LawfulMonad.bind_assoc] rfl #align stream.wseq.destruct_dropn Stream'.WSeq.destruct_dropn theorem head_terminates_of_head_tail_terminates (s : WSeq α) [T : Terminates (head (tail s))] : Terminates (head s) := (head_terminates_iff _).2 <| by rcases (head_terminates_iff _).1 T with ⟨⟨a, h⟩⟩ simp? [tail] at h says simp only [tail, destruct_flatten] at h rcases exists_of_mem_bind h with ⟨s', h1, _⟩ unfold Functor.map at h1 exact let ⟨t, h3, _⟩ := Computation.exists_of_mem_map h1 Computation.terminates_of_mem h3 #align stream.wseq.head_terminates_of_head_tail_terminates Stream'.WSeq.head_terminates_of_head_tail_terminates theorem destruct_some_of_destruct_tail_some {s : WSeq α} {a} (h : some a ∈ destruct (tail s)) : ∃ a', some a' ∈ destruct s := by unfold tail Functor.map at h; simp only [destruct_flatten] at h rcases exists_of_mem_bind h with ⟨t, tm, td⟩; clear h rcases Computation.exists_of_mem_map tm with ⟨t', ht', ht2⟩; clear tm cases' t' with t' <;> rw [← ht2] at td <;> simp only [destruct_nil] at td · have := mem_unique td (ret_mem _) contradiction · exact ⟨_, ht'⟩ #align stream.wseq.destruct_some_of_destruct_tail_some Stream'.WSeq.destruct_some_of_destruct_tail_some theorem head_some_of_head_tail_some {s : WSeq α} {a} (h : some a ∈ head (tail s)) : ∃ a', some a' ∈ head s := by unfold head at h rcases Computation.exists_of_mem_map h with ⟨o, md, e⟩; clear h cases' o with o <;> [injection e; injection e with h']; clear h' cases' destruct_some_of_destruct_tail_some md with a am exact ⟨_, Computation.mem_map (@Prod.fst α (WSeq α) <$> ·) am⟩ #align stream.wseq.head_some_of_head_tail_some Stream'.WSeq.head_some_of_head_tail_some theorem head_some_of_get?_some {s : WSeq α} {a n} (h : some a ∈ get? s n) : ∃ a', some a' ∈ head s := by induction n generalizing a with | zero => exact ⟨_, h⟩ | succ n IH => let ⟨a', h'⟩ := head_some_of_head_tail_some h exact IH h' #align stream.wseq.head_some_of_nth_some Stream'.WSeq.head_some_of_get?_some instance productive_tail (s : WSeq α) [Productive s] : Productive (tail s) := ⟨fun n => by rw [get?_tail]; infer_instance⟩ #align stream.wseq.productive_tail Stream'.WSeq.productive_tail instance productive_dropn (s : WSeq α) [Productive s] (n) : Productive (drop s n) := ⟨fun m => by rw [← get?_add]; infer_instance⟩ #align stream.wseq.productive_dropn Stream'.WSeq.productive_dropn def toSeq (s : WSeq α) [Productive s] : Seq α := ⟨fun n => (get? s n).get, fun {n} h => by cases e : Computation.get (get? s (n + 1)) · assumption have := Computation.mem_of_get_eq _ e simp? [get?] at this h says simp only [get?] at this h cases' head_some_of_head_tail_some this with a' h' have := mem_unique h' (@Computation.mem_of_get_eq _ _ _ _ h) contradiction⟩ #align stream.wseq.to_seq Stream'.WSeq.toSeq theorem get?_terminates_le {s : WSeq α} {m n} (h : m ≤ n) : Terminates (get? s n) → Terminates (get? s m) := by induction' h with m' _ IH exacts [id, fun T => IH (@head_terminates_of_head_tail_terminates _ _ T)] #align stream.wseq.nth_terminates_le Stream'.WSeq.get?_terminates_le theorem head_terminates_of_get?_terminates {s : WSeq α} {n} : Terminates (get? s n) → Terminates (head s) := get?_terminates_le (Nat.zero_le n) #align stream.wseq.head_terminates_of_nth_terminates Stream'.WSeq.head_terminates_of_get?_terminates theorem destruct_terminates_of_get?_terminates {s : WSeq α} {n} (T : Terminates (get? s n)) : Terminates (destruct s) := (head_terminates_iff _).1 <| head_terminates_of_get?_terminates T #align stream.wseq.destruct_terminates_of_nth_terminates Stream'.WSeq.destruct_terminates_of_get?_terminates theorem mem_rec_on {C : WSeq α → Prop} {a s} (M : a ∈ s) (h1 : ∀ b s', a = b ∨ C s' → C (cons b s')) (h2 : ∀ s, C s → C (think s)) : C s := by apply Seq.mem_rec_on M intro o s' h; cases' o with b · apply h2 cases h · contradiction · assumption · apply h1 apply Or.imp_left _ h intro h injection h #align stream.wseq.mem_rec_on Stream'.WSeq.mem_rec_on @[simp] theorem mem_think (s : WSeq α) (a) : a ∈ think s ↔ a ∈ s := by cases' s with f al change (some (some a) ∈ some none::f) ↔ some (some a) ∈ f constructor <;> intro h · apply (Stream'.eq_or_mem_of_mem_cons h).resolve_left intro injections · apply Stream'.mem_cons_of_mem _ h #align stream.wseq.mem_think Stream'.WSeq.mem_think theorem eq_or_mem_iff_mem {s : WSeq α} {a a' s'} : some (a', s') ∈ destruct s → (a ∈ s ↔ a = a' ∨ a ∈ s') := by generalize e : destruct s = c; intro h revert s apply Computation.memRecOn h <;> [skip; intro c IH] <;> intro s <;> induction' s using WSeq.recOn with x s s <;> intro m <;> have := congr_arg Computation.destruct m <;> simp at this · cases' this with i1 i2 rw [i1, i2] cases' s' with f al dsimp only [cons, (· ∈ ·), WSeq.Mem, Seq.Mem, Seq.cons] have h_a_eq_a' : a = a' ↔ some (some a) = some (some a') := by simp rw [h_a_eq_a'] refine ⟨Stream'.eq_or_mem_of_mem_cons, fun o => ?_⟩ · cases' o with e m · rw [e] apply Stream'.mem_cons · exact Stream'.mem_cons_of_mem _ m · simp [IH this] #align stream.wseq.eq_or_mem_iff_mem Stream'.WSeq.eq_or_mem_iff_mem @[simp] theorem mem_cons_iff (s : WSeq α) (b) {a} : a ∈ cons b s ↔ a = b ∨ a ∈ s := eq_or_mem_iff_mem <| by simp [ret_mem] #align stream.wseq.mem_cons_iff Stream'.WSeq.mem_cons_iff theorem mem_cons_of_mem {s : WSeq α} (b) {a} (h : a ∈ s) : a ∈ cons b s := (mem_cons_iff _ _).2 (Or.inr h) #align stream.wseq.mem_cons_of_mem Stream'.WSeq.mem_cons_of_mem theorem mem_cons (s : WSeq α) (a) : a ∈ cons a s := (mem_cons_iff _ _).2 (Or.inl rfl) #align stream.wseq.mem_cons Stream'.WSeq.mem_cons theorem mem_of_mem_tail {s : WSeq α} {a} : a ∈ tail s → a ∈ s := by intro h; have := h; cases' h with n e; revert s; simp only [Stream'.get] induction' n with n IH <;> intro s <;> induction' s using WSeq.recOn with x s s <;> simp <;> intro m e <;> injections · exact Or.inr m · exact Or.inr m · apply IH m rw [e] cases tail s rfl #align stream.wseq.mem_of_mem_tail Stream'.WSeq.mem_of_mem_tail theorem mem_of_mem_dropn {s : WSeq α} {a} : ∀ {n}, a ∈ drop s n → a ∈ s | 0, h => h | n + 1, h => @mem_of_mem_dropn s a n (mem_of_mem_tail h) #align stream.wseq.mem_of_mem_dropn Stream'.WSeq.mem_of_mem_dropn theorem get?_mem {s : WSeq α} {a n} : some a ∈ get? s n → a ∈ s := by revert s; induction' n with n IH <;> intro s h · -- Porting note: This line is required to infer metavariables in -- `Computation.exists_of_mem_map`. dsimp only [get?, head] at h rcases Computation.exists_of_mem_map h with ⟨o, h1, h2⟩ cases' o with o · injection h2 injection h2 with h' cases' o with a' s' exact (eq_or_mem_iff_mem h1).2 (Or.inl h'.symm) · have := @IH (tail s) rw [get?_tail] at this exact mem_of_mem_tail (this h) #align stream.wseq.nth_mem Stream'.WSeq.get?_mem theorem exists_get?_of_mem {s : WSeq α} {a} (h : a ∈ s) : ∃ n, some a ∈ get? s n := by apply mem_rec_on h · intro a' s' h cases' h with h h · exists 0 simp only [get?, drop, head_cons] rw [h] apply ret_mem · cases' h with n h exists n + 1 -- porting note (#10745): was `simp [get?]`. simpa [get?] · intro s' h cases' h with n h exists n simp only [get?, dropn_think, head_think] apply think_mem h #align stream.wseq.exists_nth_of_mem Stream'.WSeq.exists_get?_of_mem theorem exists_dropn_of_mem {s : WSeq α} {a} (h : a ∈ s) : ∃ n s', some (a, s') ∈ destruct (drop s n) := let ⟨n, h⟩ := exists_get?_of_mem h ⟨n, by rcases (head_terminates_iff _).1 ⟨⟨_, h⟩⟩ with ⟨⟨o, om⟩⟩ have := Computation.mem_unique (Computation.mem_map _ om) h cases' o with o · injection this injection this with i cases' o with a' s' dsimp at i rw [i] at om exact ⟨_, om⟩⟩ #align stream.wseq.exists_dropn_of_mem Stream'.WSeq.exists_dropn_of_mem theorem liftRel_dropn_destruct {R : α → β → Prop} {s t} (H : LiftRel R s t) : ∀ n, Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct (drop s n)) (destruct (drop t n)) | 0 => liftRel_destruct H | n + 1 => by simp only [LiftRelO, drop, Nat.add_eq, Nat.add_zero, destruct_tail, tail.aux] apply liftRel_bind · apply liftRel_dropn_destruct H n exact fun {a b} o => match a, b, o with | none, none, _ => by -- Porting note: These 2 theorems should be excluded. simp [-liftRel_pure_left, -liftRel_pure_right] | some (a, s), some (b, t), ⟨_, h2⟩ => by simpa [tail.aux] using liftRel_destruct h2 #align stream.wseq.lift_rel_dropn_destruct Stream'.WSeq.liftRel_dropn_destruct theorem exists_of_liftRel_left {R : α → β → Prop} {s t} (H : LiftRel R s t) {a} (h : a ∈ s) : ∃ b, b ∈ t ∧ R a b := by let ⟨n, h⟩ := exists_get?_of_mem h -- Porting note: This line is required to infer metavariables in -- `Computation.exists_of_mem_map`. dsimp only [get?, head] at h let ⟨some (_, s'), sd, rfl⟩ := Computation.exists_of_mem_map h let ⟨some (b, t'), td, ⟨ab, _⟩⟩ := (liftRel_dropn_destruct H n).left sd exact ⟨b, get?_mem (Computation.mem_map (Prod.fst.{v, v} <$> ·) td), ab⟩ #align stream.wseq.exists_of_lift_rel_left Stream'.WSeq.exists_of_liftRel_left theorem exists_of_liftRel_right {R : α → β → Prop} {s t} (H : LiftRel R s t) {b} (h : b ∈ t) : ∃ a, a ∈ s ∧ R a b := by rw [← LiftRel.swap] at H; exact exists_of_liftRel_left H h #align stream.wseq.exists_of_lift_rel_right Stream'.WSeq.exists_of_liftRel_right theorem head_terminates_of_mem {s : WSeq α} {a} (h : a ∈ s) : Terminates (head s) := let ⟨_, h⟩ := exists_get?_of_mem h head_terminates_of_get?_terminates ⟨⟨_, h⟩⟩ #align stream.wseq.head_terminates_of_mem Stream'.WSeq.head_terminates_of_mem theorem of_mem_append {s₁ s₂ : WSeq α} {a : α} : a ∈ append s₁ s₂ → a ∈ s₁ ∨ a ∈ s₂ := Seq.of_mem_append #align stream.wseq.of_mem_append Stream'.WSeq.of_mem_append theorem mem_append_left {s₁ s₂ : WSeq α} {a : α} : a ∈ s₁ → a ∈ append s₁ s₂ := Seq.mem_append_left #align stream.wseq.mem_append_left Stream'.WSeq.mem_append_left theorem exists_of_mem_map {f} {b : β} : ∀ {s : WSeq α}, b ∈ map f s → ∃ a, a ∈ s ∧ f a = b | ⟨g, al⟩, h => by let ⟨o, om, oe⟩ := Seq.exists_of_mem_map h cases' o with a · injection oe injection oe with h' exact ⟨a, om, h'⟩ #align stream.wseq.exists_of_mem_map Stream'.WSeq.exists_of_mem_map @[simp] theorem liftRel_nil (R : α → β → Prop) : LiftRel R nil nil := by rw [liftRel_destruct_iff] -- Porting note: These 2 theorems should be excluded. simp [-liftRel_pure_left, -liftRel_pure_right] #align stream.wseq.lift_rel_nil Stream'.WSeq.liftRel_nil @[simp] theorem liftRel_cons (R : α → β → Prop) (a b s t) : LiftRel R (cons a s) (cons b t) ↔ R a b ∧ LiftRel R s t := by rw [liftRel_destruct_iff] -- Porting note: These 2 theorems should be excluded. simp [-liftRel_pure_left, -liftRel_pure_right] #align stream.wseq.lift_rel_cons Stream'.WSeq.liftRel_cons @[simp] theorem liftRel_think_left (R : α → β → Prop) (s t) : LiftRel R (think s) t ↔ LiftRel R s t := by rw [liftRel_destruct_iff, liftRel_destruct_iff]; simp #align stream.wseq.lift_rel_think_left Stream'.WSeq.liftRel_think_left @[simp] theorem liftRel_think_right (R : α → β → Prop) (s t) : LiftRel R s (think t) ↔ LiftRel R s t := by rw [liftRel_destruct_iff, liftRel_destruct_iff]; simp #align stream.wseq.lift_rel_think_right Stream'.WSeq.liftRel_think_right theorem cons_congr {s t : WSeq α} (a : α) (h : s ~ʷ t) : cons a s ~ʷ cons a t := by unfold Equiv; simpa using h #align stream.wseq.cons_congr Stream'.WSeq.cons_congr theorem think_equiv (s : WSeq α) : think s ~ʷ s := by unfold Equiv; simpa using Equiv.refl _ #align stream.wseq.think_equiv Stream'.WSeq.think_equiv theorem think_congr {s t : WSeq α} (h : s ~ʷ t) : think s ~ʷ think t := by unfold Equiv; simpa using h #align stream.wseq.think_congr Stream'.WSeq.think_congr theorem head_congr : ∀ {s t : WSeq α}, s ~ʷ t → head s ~ head t := by suffices ∀ {s t : WSeq α}, s ~ʷ t → ∀ {o}, o ∈ head s → o ∈ head t from fun s t h o => ⟨this h, this h.symm⟩ intro s t h o ho rcases @Computation.exists_of_mem_map _ _ _ _ (destruct s) ho with ⟨ds, dsm, dse⟩ rw [← dse] cases' destruct_congr h with l r rcases l dsm with ⟨dt, dtm, dst⟩ cases' ds with a <;> cases' dt with b · apply Computation.mem_map _ dtm · cases b cases dst · cases a cases dst · cases' a with a s' cases' b with b t' rw [dst.left] exact @Computation.mem_map _ _ (@Functor.map _ _ (α × WSeq α) _ Prod.fst) (some (b, t')) (destruct t) dtm #align stream.wseq.head_congr Stream'.WSeq.head_congr theorem flatten_equiv {c : Computation (WSeq α)} {s} (h : s ∈ c) : flatten c ~ʷ s := by apply Computation.memRecOn h · simp [Equiv.refl] · intro s' apply Equiv.trans simp [think_equiv] #align stream.wseq.flatten_equiv Stream'.WSeq.flatten_equiv theorem liftRel_flatten {R : α → β → Prop} {c1 : Computation (WSeq α)} {c2 : Computation (WSeq β)} (h : c1.LiftRel (LiftRel R) c2) : LiftRel R (flatten c1) (flatten c2) := let S s t := ∃ c1 c2, s = flatten c1 ∧ t = flatten c2 ∧ Computation.LiftRel (LiftRel R) c1 c2 ⟨S, ⟨c1, c2, rfl, rfl, h⟩, fun {s t} h => match s, t, h with | _, _, ⟨c1, c2, rfl, rfl, h⟩ => by simp only [destruct_flatten]; apply liftRel_bind _ _ h intro a b ab; apply Computation.LiftRel.imp _ _ _ (liftRel_destruct ab) intro a b; apply LiftRelO.imp_right intro s t h; refine ⟨Computation.pure s, Computation.pure t, ?_, ?_, ?_⟩ <;> -- Porting note: These 2 theorems should be excluded. simp [h, -liftRel_pure_left, -liftRel_pure_right]⟩ #align stream.wseq.lift_rel_flatten Stream'.WSeq.liftRel_flatten theorem flatten_congr {c1 c2 : Computation (WSeq α)} : Computation.LiftRel Equiv c1 c2 → flatten c1 ~ʷ flatten c2 := liftRel_flatten #align stream.wseq.flatten_congr Stream'.WSeq.flatten_congr theorem tail_congr {s t : WSeq α} (h : s ~ʷ t) : tail s ~ʷ tail t := by apply flatten_congr dsimp only [(· <$> ·)]; rw [← Computation.bind_pure, ← Computation.bind_pure] apply liftRel_bind _ _ (destruct_congr h) intro a b h; simp only [comp_apply, liftRel_pure] cases' a with a <;> cases' b with b · trivial · cases h · cases a cases h · cases' a with a s' cases' b with b t' exact h.right #align stream.wseq.tail_congr Stream'.WSeq.tail_congr theorem dropn_congr {s t : WSeq α} (h : s ~ʷ t) (n) : drop s n ~ʷ drop t n := by induction n <;> simp [*, tail_congr, drop] #align stream.wseq.dropn_congr Stream'.WSeq.dropn_congr theorem get?_congr {s t : WSeq α} (h : s ~ʷ t) (n) : get? s n ~ get? t n := head_congr (dropn_congr h _) #align stream.wseq.nth_congr Stream'.WSeq.get?_congr theorem mem_congr {s t : WSeq α} (h : s ~ʷ t) (a) : a ∈ s ↔ a ∈ t := suffices ∀ {s t : WSeq α}, s ~ʷ t → a ∈ s → a ∈ t from ⟨this h, this h.symm⟩ fun {_ _} h as => let ⟨_, hn⟩ := exists_get?_of_mem as get?_mem ((get?_congr h _ _).1 hn) #align stream.wseq.mem_congr Stream'.WSeq.mem_congr theorem productive_congr {s t : WSeq α} (h : s ~ʷ t) : Productive s ↔ Productive t := by simp only [productive_iff]; exact forall_congr' fun n => terminates_congr <| get?_congr h _ #align stream.wseq.productive_congr Stream'.WSeq.productive_congr theorem Equiv.ext {s t : WSeq α} (h : ∀ n, get? s n ~ get? t n) : s ~ʷ t := ⟨fun s t => ∀ n, get? s n ~ get? t n, h, fun {s t} h => by refine liftRel_def.2 ⟨?_, ?_⟩ · rw [← head_terminates_iff, ← head_terminates_iff] exact terminates_congr (h 0) · intro a b ma mb cases' a with a <;> cases' b with b · trivial · injection mem_unique (Computation.mem_map _ ma) ((h 0 _).2 (Computation.mem_map _ mb)) · injection mem_unique (Computation.mem_map _ ma) ((h 0 _).2 (Computation.mem_map _ mb)) · cases' a with a s' cases' b with b t' injection mem_unique (Computation.mem_map _ ma) ((h 0 _).2 (Computation.mem_map _ mb)) with ab refine ⟨ab, fun n => ?_⟩ refine (get?_congr (flatten_equiv (Computation.mem_map _ ma)) n).symm.trans ((?_ : get? (tail s) n ~ get? (tail t) n).trans (get?_congr (flatten_equiv (Computation.mem_map _ mb)) n)) rw [get?_tail, get?_tail] apply h⟩ #align stream.wseq.equiv.ext Stream'.WSeq.Equiv.ext theorem length_eq_map (s : WSeq α) : length s = Computation.map List.length (toList s) := by refine Computation.eq_of_bisim (fun c1 c2 => ∃ (l : List α) (s : WSeq α), c1 = Computation.corec (fun ⟨n, s⟩ => match Seq.destruct s with | none => Sum.inl n | some (none, s') => Sum.inr (n, s') | some (some _, s') => Sum.inr (n + 1, s')) (l.length, s) ∧ c2 = Computation.map List.length (Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (l, s))) ?_ ⟨[], s, rfl, rfl⟩ intro s1 s2 h; rcases h with ⟨l, s, h⟩; rw [h.left, h.right] induction' s using WSeq.recOn with a s s <;> simp [toList, nil, cons, think, length] · refine ⟨a::l, s, ?_, ?_⟩ <;> simp · refine ⟨l, s, ?_, ?_⟩ <;> simp #align stream.wseq.length_eq_map Stream'.WSeq.length_eq_map @[simp] theorem ofList_nil : ofList [] = (nil : WSeq α) := rfl #align stream.wseq.of_list_nil Stream'.WSeq.ofList_nil @[simp] theorem ofList_cons (a : α) (l) : ofList (a::l) = cons a (ofList l) := show Seq.map some (Seq.ofList (a::l)) = Seq.cons (some a) (Seq.map some (Seq.ofList l)) by simp #align stream.wseq.of_list_cons Stream'.WSeq.ofList_cons @[simp] theorem toList'_nil (l : List α) : Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (l, nil) = Computation.pure l.reverse := destruct_eq_pure rfl #align stream.wseq.to_list'_nil Stream'.WSeq.toList'_nil @[simp] theorem toList'_cons (l : List α) (s : WSeq α) (a : α) : Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (l, cons a s) = (Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (a::l, s)).think := destruct_eq_think <| by simp [toList, cons] #align stream.wseq.to_list'_cons Stream'.WSeq.toList'_cons @[simp] theorem toList'_think (l : List α) (s : WSeq α) : Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (l, think s) = (Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (l, s)).think := destruct_eq_think <| by simp [toList, think] #align stream.wseq.to_list'_think Stream'.WSeq.toList'_think
Mathlib/Data/Seq/WSeq.lean
1,303
1,327
theorem toList'_map (l : List α) (s : WSeq α) : Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a :: l, s')) (l, s) = (l.reverse ++ ·) <$> toList s := by
refine Computation.eq_of_bisim (fun c1 c2 => ∃ (l' : List α) (s : WSeq α), c1 = Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (l' ++ l, s) ∧ c2 = Computation.map (l.reverse ++ ·) (Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (l', s))) ?_ ⟨[], s, rfl, rfl⟩ intro s1 s2 h; rcases h with ⟨l', s, h⟩; rw [h.left, h.right] induction' s using WSeq.recOn with a s s <;> simp [toList, nil, cons, think, length] · refine ⟨a::l', s, ?_, ?_⟩ <;> simp · refine ⟨l', s, ?_, ?_⟩ <;> simp
import Mathlib.Geometry.Manifold.ContMDiff.Defs open Set Filter Function open scoped Topology Manifold variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] -- declare a smooth manifold `M` over the pair `(E, H)`. {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {H : Type*} [TopologicalSpace H] (I : ModelWithCorners 𝕜 E H) {M : Type*} [TopologicalSpace M] [ChartedSpace H M] [SmoothManifoldWithCorners I M] -- declare a smooth manifold `M'` over the pair `(E', H')`. {E' : Type*} [NormedAddCommGroup E'] [NormedSpace 𝕜 E'] {H' : Type*} [TopologicalSpace H'] (I' : ModelWithCorners 𝕜 E' H') {M' : Type*} [TopologicalSpace M'] [ChartedSpace H' M'] [SmoothManifoldWithCorners I' M'] -- declare a manifold `M''` over the pair `(E'', H'')`. {E'' : Type*} [NormedAddCommGroup E''] [NormedSpace 𝕜 E''] {H'' : Type*} [TopologicalSpace H''] {I'' : ModelWithCorners 𝕜 E'' H''} {M'' : Type*} [TopologicalSpace M''] [ChartedSpace H'' M''] -- declare functions, sets, points and smoothness indices {e : PartialHomeomorph M H} {e' : PartialHomeomorph M' H'} {f f₁ : M → M'} {s s₁ t : Set M} {x : M} {m n : ℕ∞} variable {I I'} section id variable {c : M'} theorem contMDiff_const : ContMDiff I I' n fun _ : M => c := by intro x refine ⟨continuousWithinAt_const, ?_⟩ simp only [ContDiffWithinAtProp, (· ∘ ·)] exact contDiffWithinAt_const #align cont_mdiff_const contMDiff_const @[to_additive] theorem contMDiff_one [One M'] : ContMDiff I I' n (1 : M → M') := by simp only [Pi.one_def, contMDiff_const] #align cont_mdiff_one contMDiff_one #align cont_mdiff_zero contMDiff_zero theorem smooth_const : Smooth I I' fun _ : M => c := contMDiff_const #align smooth_const smooth_const @[to_additive]
Mathlib/Geometry/Manifold/ContMDiff/Basic.lean
262
262
theorem smooth_one [One M'] : Smooth I I' (1 : M → M') := by
simp only [Pi.one_def, smooth_const]
import Mathlib.Data.Set.Image import Mathlib.Order.SuccPred.Relation import Mathlib.Topology.Clopen import Mathlib.Topology.Irreducible #align_import topology.connected from "leanprover-community/mathlib"@"d101e93197bb5f6ea89bd7ba386b7f7dff1f3903" open Set Function Topology TopologicalSpace Relation open scoped Classical universe u v variable {α : Type u} {β : Type v} {ι : Type*} {π : ι → Type*} [TopologicalSpace α] {s t u v : Set α} section Preconnected def IsPreconnected (s : Set α) : Prop := ∀ u v : Set α, IsOpen u → IsOpen v → s ⊆ u ∪ v → (s ∩ u).Nonempty → (s ∩ v).Nonempty → (s ∩ (u ∩ v)).Nonempty #align is_preconnected IsPreconnected def IsConnected (s : Set α) : Prop := s.Nonempty ∧ IsPreconnected s #align is_connected IsConnected theorem IsConnected.nonempty {s : Set α} (h : IsConnected s) : s.Nonempty := h.1 #align is_connected.nonempty IsConnected.nonempty theorem IsConnected.isPreconnected {s : Set α} (h : IsConnected s) : IsPreconnected s := h.2 #align is_connected.is_preconnected IsConnected.isPreconnected theorem IsPreirreducible.isPreconnected {s : Set α} (H : IsPreirreducible s) : IsPreconnected s := fun _ _ hu hv _ => H _ _ hu hv #align is_preirreducible.is_preconnected IsPreirreducible.isPreconnected theorem IsIrreducible.isConnected {s : Set α} (H : IsIrreducible s) : IsConnected s := ⟨H.nonempty, H.isPreirreducible.isPreconnected⟩ #align is_irreducible.is_connected IsIrreducible.isConnected theorem isPreconnected_empty : IsPreconnected (∅ : Set α) := isPreirreducible_empty.isPreconnected #align is_preconnected_empty isPreconnected_empty theorem isConnected_singleton {x} : IsConnected ({x} : Set α) := isIrreducible_singleton.isConnected #align is_connected_singleton isConnected_singleton theorem isPreconnected_singleton {x} : IsPreconnected ({x} : Set α) := isConnected_singleton.isPreconnected #align is_preconnected_singleton isPreconnected_singleton theorem Set.Subsingleton.isPreconnected {s : Set α} (hs : s.Subsingleton) : IsPreconnected s := hs.induction_on isPreconnected_empty fun _ => isPreconnected_singleton #align set.subsingleton.is_preconnected Set.Subsingleton.isPreconnected theorem isPreconnected_of_forall {s : Set α} (x : α) (H : ∀ y ∈ s, ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t) : IsPreconnected s := by rintro u v hu hv hs ⟨z, zs, zu⟩ ⟨y, ys, yv⟩ have xs : x ∈ s := by rcases H y ys with ⟨t, ts, xt, -, -⟩ exact ts xt -- Porting note (#11215): TODO: use `wlog xu : x ∈ u := hs xs using u v y z, v u z y` cases hs xs with | inl xu => rcases H y ys with ⟨t, ts, xt, yt, ht⟩ have := ht u v hu hv (ts.trans hs) ⟨x, xt, xu⟩ ⟨y, yt, yv⟩ exact this.imp fun z hz => ⟨ts hz.1, hz.2⟩ | inr xv => rcases H z zs with ⟨t, ts, xt, zt, ht⟩ have := ht v u hv hu (ts.trans <| by rwa [union_comm]) ⟨x, xt, xv⟩ ⟨z, zt, zu⟩ exact this.imp fun _ h => ⟨ts h.1, h.2.2, h.2.1⟩ #align is_preconnected_of_forall isPreconnected_of_forall theorem isPreconnected_of_forall_pair {s : Set α} (H : ∀ x ∈ s, ∀ y ∈ s, ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t) : IsPreconnected s := by rcases eq_empty_or_nonempty s with (rfl | ⟨x, hx⟩) exacts [isPreconnected_empty, isPreconnected_of_forall x fun y => H x hx y] #align is_preconnected_of_forall_pair isPreconnected_of_forall_pair theorem isPreconnected_sUnion (x : α) (c : Set (Set α)) (H1 : ∀ s ∈ c, x ∈ s) (H2 : ∀ s ∈ c, IsPreconnected s) : IsPreconnected (⋃₀ c) := by apply isPreconnected_of_forall x rintro y ⟨s, sc, ys⟩ exact ⟨s, subset_sUnion_of_mem sc, H1 s sc, ys, H2 s sc⟩ #align is_preconnected_sUnion isPreconnected_sUnion theorem isPreconnected_iUnion {ι : Sort*} {s : ι → Set α} (h₁ : (⋂ i, s i).Nonempty) (h₂ : ∀ i, IsPreconnected (s i)) : IsPreconnected (⋃ i, s i) := Exists.elim h₁ fun f hf => isPreconnected_sUnion f _ hf (forall_mem_range.2 h₂) #align is_preconnected_Union isPreconnected_iUnion theorem IsPreconnected.union (x : α) {s t : Set α} (H1 : x ∈ s) (H2 : x ∈ t) (H3 : IsPreconnected s) (H4 : IsPreconnected t) : IsPreconnected (s ∪ t) := sUnion_pair s t ▸ isPreconnected_sUnion x {s, t} (by rintro r (rfl | rfl | h) <;> assumption) (by rintro r (rfl | rfl | h) <;> assumption) #align is_preconnected.union IsPreconnected.union theorem IsPreconnected.union' {s t : Set α} (H : (s ∩ t).Nonempty) (hs : IsPreconnected s) (ht : IsPreconnected t) : IsPreconnected (s ∪ t) := by rcases H with ⟨x, hxs, hxt⟩ exact hs.union x hxs hxt ht #align is_preconnected.union' IsPreconnected.union' theorem IsConnected.union {s t : Set α} (H : (s ∩ t).Nonempty) (Hs : IsConnected s) (Ht : IsConnected t) : IsConnected (s ∪ t) := by rcases H with ⟨x, hx⟩ refine ⟨⟨x, mem_union_left t (mem_of_mem_inter_left hx)⟩, ?_⟩ exact Hs.isPreconnected.union x (mem_of_mem_inter_left hx) (mem_of_mem_inter_right hx) Ht.isPreconnected #align is_connected.union IsConnected.union theorem IsPreconnected.sUnion_directed {S : Set (Set α)} (K : DirectedOn (· ⊆ ·) S) (H : ∀ s ∈ S, IsPreconnected s) : IsPreconnected (⋃₀ S) := by rintro u v hu hv Huv ⟨a, ⟨s, hsS, has⟩, hau⟩ ⟨b, ⟨t, htS, hbt⟩, hbv⟩ obtain ⟨r, hrS, hsr, htr⟩ : ∃ r ∈ S, s ⊆ r ∧ t ⊆ r := K s hsS t htS have Hnuv : (r ∩ (u ∩ v)).Nonempty := H _ hrS u v hu hv ((subset_sUnion_of_mem hrS).trans Huv) ⟨a, hsr has, hau⟩ ⟨b, htr hbt, hbv⟩ have Kruv : r ∩ (u ∩ v) ⊆ ⋃₀ S ∩ (u ∩ v) := inter_subset_inter_left _ (subset_sUnion_of_mem hrS) exact Hnuv.mono Kruv #align is_preconnected.sUnion_directed IsPreconnected.sUnion_directed theorem IsPreconnected.biUnion_of_reflTransGen {ι : Type*} {t : Set ι} {s : ι → Set α} (H : ∀ i ∈ t, IsPreconnected (s i)) (K : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen (fun i j => (s i ∩ s j).Nonempty ∧ i ∈ t) i j) : IsPreconnected (⋃ n ∈ t, s n) := by let R := fun i j : ι => (s i ∩ s j).Nonempty ∧ i ∈ t have P : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen R i j → ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ j ∈ p, s j) := fun i hi j hj h => by induction h with | refl => refine ⟨{i}, singleton_subset_iff.mpr hi, mem_singleton i, mem_singleton i, ?_⟩ rw [biUnion_singleton] exact H i hi | @tail j k _ hjk ih => obtain ⟨p, hpt, hip, hjp, hp⟩ := ih hjk.2 refine ⟨insert k p, insert_subset_iff.mpr ⟨hj, hpt⟩, mem_insert_of_mem k hip, mem_insert k p, ?_⟩ rw [biUnion_insert] refine (H k hj).union' (hjk.1.mono ?_) hp rw [inter_comm] exact inter_subset_inter_right _ (subset_biUnion_of_mem hjp) refine isPreconnected_of_forall_pair ?_ intro x hx y hy obtain ⟨i : ι, hi : i ∈ t, hxi : x ∈ s i⟩ := mem_iUnion₂.1 hx obtain ⟨j : ι, hj : j ∈ t, hyj : y ∈ s j⟩ := mem_iUnion₂.1 hy obtain ⟨p, hpt, hip, hjp, hp⟩ := P i hi j hj (K i hi j hj) exact ⟨⋃ j ∈ p, s j, biUnion_subset_biUnion_left hpt, mem_biUnion hip hxi, mem_biUnion hjp hyj, hp⟩ #align is_preconnected.bUnion_of_refl_trans_gen IsPreconnected.biUnion_of_reflTransGen theorem IsConnected.biUnion_of_reflTransGen {ι : Type*} {t : Set ι} {s : ι → Set α} (ht : t.Nonempty) (H : ∀ i ∈ t, IsConnected (s i)) (K : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty ∧ i ∈ t) i j) : IsConnected (⋃ n ∈ t, s n) := ⟨nonempty_biUnion.2 <| ⟨ht.some, ht.some_mem, (H _ ht.some_mem).nonempty⟩, IsPreconnected.biUnion_of_reflTransGen (fun i hi => (H i hi).isPreconnected) K⟩ #align is_connected.bUnion_of_refl_trans_gen IsConnected.biUnion_of_reflTransGen theorem IsPreconnected.iUnion_of_reflTransGen {ι : Type*} {s : ι → Set α} (H : ∀ i, IsPreconnected (s i)) (K : ∀ i j, ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty) i j) : IsPreconnected (⋃ n, s n) := by rw [← biUnion_univ] exact IsPreconnected.biUnion_of_reflTransGen (fun i _ => H i) fun i _ j _ => by simpa [mem_univ] using K i j #align is_preconnected.Union_of_refl_trans_gen IsPreconnected.iUnion_of_reflTransGen theorem IsConnected.iUnion_of_reflTransGen {ι : Type*} [Nonempty ι] {s : ι → Set α} (H : ∀ i, IsConnected (s i)) (K : ∀ i j, ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty) i j) : IsConnected (⋃ n, s n) := ⟨nonempty_iUnion.2 <| Nonempty.elim ‹_› fun i : ι => ⟨i, (H _).nonempty⟩, IsPreconnected.iUnion_of_reflTransGen (fun i => (H i).isPreconnected) K⟩ #align is_connected.Union_of_refl_trans_gen IsConnected.iUnion_of_reflTransGen protected theorem IsPreconnected.subset_closure {s : Set α} {t : Set α} (H : IsPreconnected s) (Kst : s ⊆ t) (Ktcs : t ⊆ closure s) : IsPreconnected t := fun u v hu hv htuv ⟨_y, hyt, hyu⟩ ⟨_z, hzt, hzv⟩ => let ⟨p, hpu, hps⟩ := mem_closure_iff.1 (Ktcs hyt) u hu hyu let ⟨q, hqv, hqs⟩ := mem_closure_iff.1 (Ktcs hzt) v hv hzv let ⟨r, hrs, hruv⟩ := H u v hu hv (Subset.trans Kst htuv) ⟨p, hps, hpu⟩ ⟨q, hqs, hqv⟩ ⟨r, Kst hrs, hruv⟩ #align is_preconnected.subset_closure IsPreconnected.subset_closure protected theorem IsConnected.subset_closure {s : Set α} {t : Set α} (H : IsConnected s) (Kst : s ⊆ t) (Ktcs : t ⊆ closure s) : IsConnected t := ⟨Nonempty.mono Kst H.left, IsPreconnected.subset_closure H.right Kst Ktcs⟩ #align is_connected.subset_closure IsConnected.subset_closure protected theorem IsPreconnected.closure {s : Set α} (H : IsPreconnected s) : IsPreconnected (closure s) := IsPreconnected.subset_closure H subset_closure Subset.rfl #align is_preconnected.closure IsPreconnected.closure protected theorem IsConnected.closure {s : Set α} (H : IsConnected s) : IsConnected (closure s) := IsConnected.subset_closure H subset_closure <| Subset.rfl #align is_connected.closure IsConnected.closure protected theorem IsPreconnected.image [TopologicalSpace β] {s : Set α} (H : IsPreconnected s) (f : α → β) (hf : ContinuousOn f s) : IsPreconnected (f '' s) := by -- Unfold/destruct definitions in hypotheses rintro u v hu hv huv ⟨_, ⟨x, xs, rfl⟩, xu⟩ ⟨_, ⟨y, ys, rfl⟩, yv⟩ rcases continuousOn_iff'.1 hf u hu with ⟨u', hu', u'_eq⟩ rcases continuousOn_iff'.1 hf v hv with ⟨v', hv', v'_eq⟩ -- Reformulate `huv : f '' s ⊆ u ∪ v` in terms of `u'` and `v'` replace huv : s ⊆ u' ∪ v' := by rw [image_subset_iff, preimage_union] at huv replace huv := subset_inter huv Subset.rfl rw [union_inter_distrib_right, u'_eq, v'_eq, ← union_inter_distrib_right] at huv exact (subset_inter_iff.1 huv).1 -- Now `s ⊆ u' ∪ v'`, so we can apply `‹IsPreconnected s›` obtain ⟨z, hz⟩ : (s ∩ (u' ∩ v')).Nonempty := by refine H u' v' hu' hv' huv ⟨x, ?_⟩ ⟨y, ?_⟩ <;> rw [inter_comm] exacts [u'_eq ▸ ⟨xu, xs⟩, v'_eq ▸ ⟨yv, ys⟩] rw [← inter_self s, inter_assoc, inter_left_comm s u', ← inter_assoc, inter_comm s, inter_comm s, ← u'_eq, ← v'_eq] at hz exact ⟨f z, ⟨z, hz.1.2, rfl⟩, hz.1.1, hz.2.1⟩ #align is_preconnected.image IsPreconnected.image protected theorem IsConnected.image [TopologicalSpace β] {s : Set α} (H : IsConnected s) (f : α → β) (hf : ContinuousOn f s) : IsConnected (f '' s) := ⟨image_nonempty.mpr H.nonempty, H.isPreconnected.image f hf⟩ #align is_connected.image IsConnected.image theorem isPreconnected_closed_iff {s : Set α} : IsPreconnected s ↔ ∀ t t', IsClosed t → IsClosed t' → s ⊆ t ∪ t' → (s ∩ t).Nonempty → (s ∩ t').Nonempty → (s ∩ (t ∩ t')).Nonempty := ⟨by rintro h t t' ht ht' htt' ⟨x, xs, xt⟩ ⟨y, ys, yt'⟩ rw [← not_disjoint_iff_nonempty_inter, ← subset_compl_iff_disjoint_right, compl_inter] intro h' have xt' : x ∉ t' := (h' xs).resolve_left (absurd xt) have yt : y ∉ t := (h' ys).resolve_right (absurd yt') have := h _ _ ht.isOpen_compl ht'.isOpen_compl h' ⟨y, ys, yt⟩ ⟨x, xs, xt'⟩ rw [← compl_union] at this exact this.ne_empty htt'.disjoint_compl_right.inter_eq, by rintro h u v hu hv huv ⟨x, xs, xu⟩ ⟨y, ys, yv⟩ rw [← not_disjoint_iff_nonempty_inter, ← subset_compl_iff_disjoint_right, compl_inter] intro h' have xv : x ∉ v := (h' xs).elim (absurd xu) id have yu : y ∉ u := (h' ys).elim id (absurd yv) have := h _ _ hu.isClosed_compl hv.isClosed_compl h' ⟨y, ys, yu⟩ ⟨x, xs, xv⟩ rw [← compl_union] at this exact this.ne_empty huv.disjoint_compl_right.inter_eq⟩ #align is_preconnected_closed_iff isPreconnected_closed_iff theorem Inducing.isPreconnected_image [TopologicalSpace β] {s : Set α} {f : α → β} (hf : Inducing f) : IsPreconnected (f '' s) ↔ IsPreconnected s := by refine ⟨fun h => ?_, fun h => h.image _ hf.continuous.continuousOn⟩ rintro u v hu' hv' huv ⟨x, hxs, hxu⟩ ⟨y, hys, hyv⟩ rcases hf.isOpen_iff.1 hu' with ⟨u, hu, rfl⟩ rcases hf.isOpen_iff.1 hv' with ⟨v, hv, rfl⟩ replace huv : f '' s ⊆ u ∪ v := by rwa [image_subset_iff] rcases h u v hu hv huv ⟨f x, mem_image_of_mem _ hxs, hxu⟩ ⟨f y, mem_image_of_mem _ hys, hyv⟩ with ⟨_, ⟨z, hzs, rfl⟩, hzuv⟩ exact ⟨z, hzs, hzuv⟩ #align inducing.is_preconnected_image Inducing.isPreconnected_image theorem IsPreconnected.preimage_of_isOpenMap [TopologicalSpace β] {f : α → β} {s : Set β} (hs : IsPreconnected s) (hinj : Function.Injective f) (hf : IsOpenMap f) (hsf : s ⊆ range f) : IsPreconnected (f ⁻¹' s) := fun u v hu hv hsuv hsu hsv => by replace hsf : f '' (f ⁻¹' s) = s := image_preimage_eq_of_subset hsf obtain ⟨_, has, ⟨a, hau, rfl⟩, hav⟩ : (s ∩ (f '' u ∩ f '' v)).Nonempty := by refine hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_ · simpa only [hsf, image_union] using image_subset f hsuv · simpa only [image_preimage_inter] using hsu.image f · simpa only [image_preimage_inter] using hsv.image f · exact ⟨a, has, hau, hinj.mem_set_image.1 hav⟩ #align is_preconnected.preimage_of_open_map IsPreconnected.preimage_of_isOpenMap theorem IsPreconnected.preimage_of_isClosedMap [TopologicalSpace β] {s : Set β} (hs : IsPreconnected s) {f : α → β} (hinj : Function.Injective f) (hf : IsClosedMap f) (hsf : s ⊆ range f) : IsPreconnected (f ⁻¹' s) := isPreconnected_closed_iff.2 fun u v hu hv hsuv hsu hsv => by replace hsf : f '' (f ⁻¹' s) = s := image_preimage_eq_of_subset hsf obtain ⟨_, has, ⟨a, hau, rfl⟩, hav⟩ : (s ∩ (f '' u ∩ f '' v)).Nonempty := by refine isPreconnected_closed_iff.1 hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_ · simpa only [hsf, image_union] using image_subset f hsuv · simpa only [image_preimage_inter] using hsu.image f · simpa only [image_preimage_inter] using hsv.image f · exact ⟨a, has, hau, hinj.mem_set_image.1 hav⟩ #align is_preconnected.preimage_of_closed_map IsPreconnected.preimage_of_isClosedMap theorem IsConnected.preimage_of_isOpenMap [TopologicalSpace β] {s : Set β} (hs : IsConnected s) {f : α → β} (hinj : Function.Injective f) (hf : IsOpenMap f) (hsf : s ⊆ range f) : IsConnected (f ⁻¹' s) := ⟨hs.nonempty.preimage' hsf, hs.isPreconnected.preimage_of_isOpenMap hinj hf hsf⟩ #align is_connected.preimage_of_open_map IsConnected.preimage_of_isOpenMap theorem IsConnected.preimage_of_isClosedMap [TopologicalSpace β] {s : Set β} (hs : IsConnected s) {f : α → β} (hinj : Function.Injective f) (hf : IsClosedMap f) (hsf : s ⊆ range f) : IsConnected (f ⁻¹' s) := ⟨hs.nonempty.preimage' hsf, hs.isPreconnected.preimage_of_isClosedMap hinj hf hsf⟩ #align is_connected.preimage_of_closed_map IsConnected.preimage_of_isClosedMap theorem IsPreconnected.subset_or_subset (hu : IsOpen u) (hv : IsOpen v) (huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hs : IsPreconnected s) : s ⊆ u ∨ s ⊆ v := by specialize hs u v hu hv hsuv obtain hsu | hsu := (s ∩ u).eq_empty_or_nonempty · exact Or.inr ((Set.disjoint_iff_inter_eq_empty.2 hsu).subset_right_of_subset_union hsuv) · replace hs := mt (hs hsu) simp_rw [Set.not_nonempty_iff_eq_empty, ← Set.disjoint_iff_inter_eq_empty, disjoint_iff_inter_eq_empty.1 huv] at hs exact Or.inl ((hs s.disjoint_empty).subset_left_of_subset_union hsuv) #align is_preconnected.subset_or_subset IsPreconnected.subset_or_subset theorem IsPreconnected.subset_left_of_subset_union (hu : IsOpen u) (hv : IsOpen v) (huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hsu : (s ∩ u).Nonempty) (hs : IsPreconnected s) : s ⊆ u := Disjoint.subset_left_of_subset_union hsuv (by by_contra hsv rw [not_disjoint_iff_nonempty_inter] at hsv obtain ⟨x, _, hx⟩ := hs u v hu hv hsuv hsu hsv exact Set.disjoint_iff.1 huv hx) #align is_preconnected.subset_left_of_subset_union IsPreconnected.subset_left_of_subset_union theorem IsPreconnected.subset_right_of_subset_union (hu : IsOpen u) (hv : IsOpen v) (huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hsv : (s ∩ v).Nonempty) (hs : IsPreconnected s) : s ⊆ v := hs.subset_left_of_subset_union hv hu huv.symm (union_comm u v ▸ hsuv) hsv #align is_preconnected.subset_right_of_subset_union IsPreconnected.subset_right_of_subset_union -- Porting note: moved up theorem IsPreconnected.subset_isClopen {s t : Set α} (hs : IsPreconnected s) (ht : IsClopen t) (hne : (s ∩ t).Nonempty) : s ⊆ t := hs.subset_left_of_subset_union ht.isOpen ht.compl.isOpen disjoint_compl_right (by simp) hne #align is_preconnected.subset_clopen IsPreconnected.subset_isClopen theorem IsPreconnected.subset_of_closure_inter_subset (hs : IsPreconnected s) (hu : IsOpen u) (h'u : (s ∩ u).Nonempty) (h : closure u ∩ s ⊆ u) : s ⊆ u := by have A : s ⊆ u ∪ (closure u)ᶜ := by intro x hx by_cases xu : x ∈ u · exact Or.inl xu · right intro h'x exact xu (h (mem_inter h'x hx)) apply hs.subset_left_of_subset_union hu isClosed_closure.isOpen_compl _ A h'u exact disjoint_compl_right.mono_right (compl_subset_compl.2 subset_closure) #align is_preconnected.subset_of_closure_inter_subset IsPreconnected.subset_of_closure_inter_subset theorem IsPreconnected.prod [TopologicalSpace β] {s : Set α} {t : Set β} (hs : IsPreconnected s) (ht : IsPreconnected t) : IsPreconnected (s ×ˢ t) := by apply isPreconnected_of_forall_pair rintro ⟨a₁, b₁⟩ ⟨ha₁, hb₁⟩ ⟨a₂, b₂⟩ ⟨ha₂, hb₂⟩ refine ⟨Prod.mk a₁ '' t ∪ flip Prod.mk b₂ '' s, ?_, .inl ⟨b₁, hb₁, rfl⟩, .inr ⟨a₂, ha₂, rfl⟩, ?_⟩ · rintro _ (⟨y, hy, rfl⟩ | ⟨x, hx, rfl⟩) exacts [⟨ha₁, hy⟩, ⟨hx, hb₂⟩] · exact (ht.image _ (Continuous.Prod.mk _).continuousOn).union (a₁, b₂) ⟨b₂, hb₂, rfl⟩ ⟨a₁, ha₁, rfl⟩ (hs.image _ (continuous_id.prod_mk continuous_const).continuousOn) #align is_preconnected.prod IsPreconnected.prod theorem IsConnected.prod [TopologicalSpace β] {s : Set α} {t : Set β} (hs : IsConnected s) (ht : IsConnected t) : IsConnected (s ×ˢ t) := ⟨hs.1.prod ht.1, hs.2.prod ht.2⟩ #align is_connected.prod IsConnected.prod theorem isPreconnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)} (hs : ∀ i, IsPreconnected (s i)) : IsPreconnected (pi univ s) := by rintro u v uo vo hsuv ⟨f, hfs, hfu⟩ ⟨g, hgs, hgv⟩ rcases exists_finset_piecewise_mem_of_mem_nhds (uo.mem_nhds hfu) g with ⟨I, hI⟩ induction' I using Finset.induction_on with i I _ ihI · refine ⟨g, hgs, ⟨?_, hgv⟩⟩ simpa using hI · rw [Finset.piecewise_insert] at hI have := I.piecewise_mem_set_pi hfs hgs refine (hsuv this).elim ihI fun h => ?_ set S := update (I.piecewise f g) i '' s i have hsub : S ⊆ pi univ s := by refine image_subset_iff.2 fun z hz => ?_ rwa [update_preimage_univ_pi] exact fun j _ => this j trivial have hconn : IsPreconnected S := (hs i).image _ (continuous_const.update i continuous_id).continuousOn have hSu : (S ∩ u).Nonempty := ⟨_, mem_image_of_mem _ (hfs _ trivial), hI⟩ have hSv : (S ∩ v).Nonempty := ⟨_, ⟨_, this _ trivial, update_eq_self _ _⟩, h⟩ refine (hconn u v uo vo (hsub.trans hsuv) hSu hSv).mono ?_ exact inter_subset_inter_left _ hsub #align is_preconnected_univ_pi isPreconnected_univ_pi @[simp] theorem isConnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)} : IsConnected (pi univ s) ↔ ∀ i, IsConnected (s i) := by simp only [IsConnected, ← univ_pi_nonempty_iff, forall_and, and_congr_right_iff] refine fun hne => ⟨fun hc i => ?_, isPreconnected_univ_pi⟩ rw [← eval_image_univ_pi hne] exact hc.image _ (continuous_apply _).continuousOn #align is_connected_univ_pi isConnected_univ_pi theorem Sigma.isConnected_iff [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} : IsConnected s ↔ ∃ i t, IsConnected t ∧ s = Sigma.mk i '' t := by refine ⟨fun hs => ?_, ?_⟩ · obtain ⟨⟨i, x⟩, hx⟩ := hs.nonempty have : s ⊆ range (Sigma.mk i) := hs.isPreconnected.subset_isClopen isClopen_range_sigmaMk ⟨⟨i, x⟩, hx, x, rfl⟩ exact ⟨i, Sigma.mk i ⁻¹' s, hs.preimage_of_isOpenMap sigma_mk_injective isOpenMap_sigmaMk this, (Set.image_preimage_eq_of_subset this).symm⟩ · rintro ⟨i, t, ht, rfl⟩ exact ht.image _ continuous_sigmaMk.continuousOn #align sigma.is_connected_iff Sigma.isConnected_iff theorem Sigma.isPreconnected_iff [hι : Nonempty ι] [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} : IsPreconnected s ↔ ∃ i t, IsPreconnected t ∧ s = Sigma.mk i '' t := by refine ⟨fun hs => ?_, ?_⟩ · obtain rfl | h := s.eq_empty_or_nonempty · exact ⟨Classical.choice hι, ∅, isPreconnected_empty, (Set.image_empty _).symm⟩ · obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩ exact ⟨a, t, ht.isPreconnected, rfl⟩ · rintro ⟨a, t, ht, rfl⟩ exact ht.image _ continuous_sigmaMk.continuousOn #align sigma.is_preconnected_iff Sigma.isPreconnected_iff theorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} : IsConnected s ↔ (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by refine ⟨fun hs => ?_, ?_⟩ · obtain ⟨x | x, hx⟩ := hs.nonempty · have h : s ⊆ range Sum.inl := hs.isPreconnected.subset_isClopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩ refine Or.inl ⟨Sum.inl ⁻¹' s, ?_, ?_⟩ · exact hs.preimage_of_isOpenMap Sum.inl_injective isOpenMap_inl h · exact (image_preimage_eq_of_subset h).symm · have h : s ⊆ range Sum.inr := hs.isPreconnected.subset_isClopen isClopen_range_inr ⟨.inr x, hx, x, rfl⟩ refine Or.inr ⟨Sum.inr ⁻¹' s, ?_, ?_⟩ · exact hs.preimage_of_isOpenMap Sum.inr_injective isOpenMap_inr h · exact (image_preimage_eq_of_subset h).symm · rintro (⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩) · exact ht.image _ continuous_inl.continuousOn · exact ht.image _ continuous_inr.continuousOn #align sum.is_connected_iff Sum.isConnected_iff theorem Sum.isPreconnected_iff [TopologicalSpace β] {s : Set (Sum α β)} : IsPreconnected s ↔ (∃ t, IsPreconnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsPreconnected t ∧ s = Sum.inr '' t := by refine ⟨fun hs => ?_, ?_⟩ · obtain rfl | h := s.eq_empty_or_nonempty · exact Or.inl ⟨∅, isPreconnected_empty, (Set.image_empty _).symm⟩ obtain ⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩ := Sum.isConnected_iff.1 ⟨h, hs⟩ · exact Or.inl ⟨t, ht.isPreconnected, rfl⟩ · exact Or.inr ⟨t, ht.isPreconnected, rfl⟩ · rintro (⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩) · exact ht.image _ continuous_inl.continuousOn · exact ht.image _ continuous_inr.continuousOn #align sum.is_preconnected_iff Sum.isPreconnected_iff def connectedComponent (x : α) : Set α := ⋃₀ { s : Set α | IsPreconnected s ∧ x ∈ s } #align connected_component connectedComponent def connectedComponentIn (F : Set α) (x : α) : Set α := if h : x ∈ F then (↑) '' connectedComponent (⟨x, h⟩ : F) else ∅ #align connected_component_in connectedComponentIn theorem connectedComponentIn_eq_image {F : Set α} {x : α} (h : x ∈ F) : connectedComponentIn F x = (↑) '' connectedComponent (⟨x, h⟩ : F) := dif_pos h #align connected_component_in_eq_image connectedComponentIn_eq_image theorem connectedComponentIn_eq_empty {F : Set α} {x : α} (h : x ∉ F) : connectedComponentIn F x = ∅ := dif_neg h #align connected_component_in_eq_empty connectedComponentIn_eq_empty theorem mem_connectedComponent {x : α} : x ∈ connectedComponent x := mem_sUnion_of_mem (mem_singleton x) ⟨isPreconnected_singleton, mem_singleton x⟩ #align mem_connected_component mem_connectedComponent theorem mem_connectedComponentIn {x : α} {F : Set α} (hx : x ∈ F) : x ∈ connectedComponentIn F x := by simp [connectedComponentIn_eq_image hx, mem_connectedComponent, hx] #align mem_connected_component_in mem_connectedComponentIn theorem connectedComponent_nonempty {x : α} : (connectedComponent x).Nonempty := ⟨x, mem_connectedComponent⟩ #align connected_component_nonempty connectedComponent_nonempty theorem connectedComponentIn_nonempty_iff {x : α} {F : Set α} : (connectedComponentIn F x).Nonempty ↔ x ∈ F := by rw [connectedComponentIn] split_ifs <;> simp [connectedComponent_nonempty, *] #align connected_component_in_nonempty_iff connectedComponentIn_nonempty_iff theorem connectedComponentIn_subset (F : Set α) (x : α) : connectedComponentIn F x ⊆ F := by rw [connectedComponentIn] split_ifs <;> simp #align connected_component_in_subset connectedComponentIn_subset theorem isPreconnected_connectedComponent {x : α} : IsPreconnected (connectedComponent x) := isPreconnected_sUnion x _ (fun _ => And.right) fun _ => And.left #align is_preconnected_connected_component isPreconnected_connectedComponent theorem isPreconnected_connectedComponentIn {x : α} {F : Set α} : IsPreconnected (connectedComponentIn F x) := by rw [connectedComponentIn]; split_ifs · exact inducing_subtype_val.isPreconnected_image.mpr isPreconnected_connectedComponent · exact isPreconnected_empty #align is_preconnected_connected_component_in isPreconnected_connectedComponentIn theorem isConnected_connectedComponent {x : α} : IsConnected (connectedComponent x) := ⟨⟨x, mem_connectedComponent⟩, isPreconnected_connectedComponent⟩ #align is_connected_connected_component isConnected_connectedComponent theorem isConnected_connectedComponentIn_iff {x : α} {F : Set α} : IsConnected (connectedComponentIn F x) ↔ x ∈ F := by simp_rw [← connectedComponentIn_nonempty_iff, IsConnected, isPreconnected_connectedComponentIn, and_true_iff] #align is_connected_connected_component_in_iff isConnected_connectedComponentIn_iff theorem IsPreconnected.subset_connectedComponent {x : α} {s : Set α} (H1 : IsPreconnected s) (H2 : x ∈ s) : s ⊆ connectedComponent x := fun _z hz => mem_sUnion_of_mem hz ⟨H1, H2⟩ #align is_preconnected.subset_connected_component IsPreconnected.subset_connectedComponent theorem IsPreconnected.subset_connectedComponentIn {x : α} {F : Set α} (hs : IsPreconnected s) (hxs : x ∈ s) (hsF : s ⊆ F) : s ⊆ connectedComponentIn F x := by have : IsPreconnected (((↑) : F → α) ⁻¹' s) := by refine inducing_subtype_val.isPreconnected_image.mp ?_ rwa [Subtype.image_preimage_coe, inter_eq_right.mpr hsF] have h2xs : (⟨x, hsF hxs⟩ : F) ∈ (↑) ⁻¹' s := by rw [mem_preimage] exact hxs have := this.subset_connectedComponent h2xs rw [connectedComponentIn_eq_image (hsF hxs)] refine Subset.trans ?_ (image_subset _ this) rw [Subtype.image_preimage_coe, inter_eq_right.mpr hsF] #align is_preconnected.subset_connected_component_in IsPreconnected.subset_connectedComponentIn theorem IsConnected.subset_connectedComponent {x : α} {s : Set α} (H1 : IsConnected s) (H2 : x ∈ s) : s ⊆ connectedComponent x := H1.2.subset_connectedComponent H2 #align is_connected.subset_connected_component IsConnected.subset_connectedComponent theorem IsPreconnected.connectedComponentIn {x : α} {F : Set α} (h : IsPreconnected F) (hx : x ∈ F) : connectedComponentIn F x = F := (connectedComponentIn_subset F x).antisymm (h.subset_connectedComponentIn hx subset_rfl) #align is_preconnected.connected_component_in IsPreconnected.connectedComponentIn theorem connectedComponent_eq {x y : α} (h : y ∈ connectedComponent x) : connectedComponent x = connectedComponent y := eq_of_subset_of_subset (isConnected_connectedComponent.subset_connectedComponent h) (isConnected_connectedComponent.subset_connectedComponent (Set.mem_of_mem_of_subset mem_connectedComponent (isConnected_connectedComponent.subset_connectedComponent h))) #align connected_component_eq connectedComponent_eq theorem connectedComponent_eq_iff_mem {x y : α} : connectedComponent x = connectedComponent y ↔ x ∈ connectedComponent y := ⟨fun h => h ▸ mem_connectedComponent, fun h => (connectedComponent_eq h).symm⟩ #align connected_component_eq_iff_mem connectedComponent_eq_iff_mem theorem connectedComponentIn_eq {x y : α} {F : Set α} (h : y ∈ connectedComponentIn F x) : connectedComponentIn F x = connectedComponentIn F y := by have hx : x ∈ F := connectedComponentIn_nonempty_iff.mp ⟨y, h⟩ simp_rw [connectedComponentIn_eq_image hx] at h ⊢ obtain ⟨⟨y, hy⟩, h2y, rfl⟩ := h simp_rw [connectedComponentIn_eq_image hy, connectedComponent_eq h2y] #align connected_component_in_eq connectedComponentIn_eq theorem connectedComponentIn_univ (x : α) : connectedComponentIn univ x = connectedComponent x := subset_antisymm (isPreconnected_connectedComponentIn.subset_connectedComponent <| mem_connectedComponentIn trivial) (isPreconnected_connectedComponent.subset_connectedComponentIn mem_connectedComponent <| subset_univ _) #align connected_component_in_univ connectedComponentIn_univ theorem connectedComponent_disjoint {x y : α} (h : connectedComponent x ≠ connectedComponent y) : Disjoint (connectedComponent x) (connectedComponent y) := Set.disjoint_left.2 fun _ h1 h2 => h ((connectedComponent_eq h1).trans (connectedComponent_eq h2).symm) #align connected_component_disjoint connectedComponent_disjoint theorem isClosed_connectedComponent {x : α} : IsClosed (connectedComponent x) := closure_subset_iff_isClosed.1 <| isConnected_connectedComponent.closure.subset_connectedComponent <| subset_closure mem_connectedComponent #align is_closed_connected_component isClosed_connectedComponent theorem Continuous.image_connectedComponent_subset [TopologicalSpace β] {f : α → β} (h : Continuous f) (a : α) : f '' connectedComponent a ⊆ connectedComponent (f a) := (isConnected_connectedComponent.image f h.continuousOn).subset_connectedComponent ((mem_image f (connectedComponent a) (f a)).2 ⟨a, mem_connectedComponent, rfl⟩) #align continuous.image_connected_component_subset Continuous.image_connectedComponent_subset theorem Continuous.image_connectedComponentIn_subset [TopologicalSpace β] {f : α → β} {s : Set α} {a : α} (hf : Continuous f) (hx : a ∈ s) : f '' connectedComponentIn s a ⊆ connectedComponentIn (f '' s) (f a) := (isPreconnected_connectedComponentIn.image _ hf.continuousOn).subset_connectedComponentIn (mem_image_of_mem _ <| mem_connectedComponentIn hx) (image_subset _ <| connectedComponentIn_subset _ _) theorem Continuous.mapsTo_connectedComponent [TopologicalSpace β] {f : α → β} (h : Continuous f) (a : α) : MapsTo f (connectedComponent a) (connectedComponent (f a)) := mapsTo'.2 <| h.image_connectedComponent_subset a #align continuous.maps_to_connected_component Continuous.mapsTo_connectedComponent theorem Continuous.mapsTo_connectedComponentIn [TopologicalSpace β] {f : α → β} {s : Set α} (h : Continuous f) {a : α} (hx : a ∈ s) : MapsTo f (connectedComponentIn s a) (connectedComponentIn (f '' s) (f a)) := mapsTo'.2 <| image_connectedComponentIn_subset h hx theorem irreducibleComponent_subset_connectedComponent {x : α} : irreducibleComponent x ⊆ connectedComponent x := isIrreducible_irreducibleComponent.isConnected.subset_connectedComponent mem_irreducibleComponent #align irreducible_component_subset_connected_component irreducibleComponent_subset_connectedComponent @[mono] theorem connectedComponentIn_mono (x : α) {F G : Set α} (h : F ⊆ G) : connectedComponentIn F x ⊆ connectedComponentIn G x := by by_cases hx : x ∈ F · rw [connectedComponentIn_eq_image hx, connectedComponentIn_eq_image (h hx), ← show ((↑) : G → α) ∘ inclusion h = (↑) from rfl, image_comp] exact image_subset _ ((continuous_inclusion h).image_connectedComponent_subset ⟨x, hx⟩) · rw [connectedComponentIn_eq_empty hx] exact Set.empty_subset _ #align connected_component_in_mono connectedComponentIn_mono class PreconnectedSpace (α : Type u) [TopologicalSpace α] : Prop where isPreconnected_univ : IsPreconnected (univ : Set α) #align preconnected_space PreconnectedSpace export PreconnectedSpace (isPreconnected_univ) class ConnectedSpace (α : Type u) [TopologicalSpace α] extends PreconnectedSpace α : Prop where toNonempty : Nonempty α #align connected_space ConnectedSpace attribute [instance 50] ConnectedSpace.toNonempty -- see Note [lower instance priority] -- see Note [lower instance priority] theorem isConnected_univ [ConnectedSpace α] : IsConnected (univ : Set α) := ⟨univ_nonempty, isPreconnected_univ⟩ #align is_connected_univ isConnected_univ lemma preconnectedSpace_iff_univ : PreconnectedSpace α ↔ IsPreconnected (univ : Set α) := ⟨fun h ↦ h.1, fun h ↦ ⟨h⟩⟩ lemma connectedSpace_iff_univ : ConnectedSpace α ↔ IsConnected (univ : Set α) := ⟨fun h ↦ ⟨univ_nonempty, h.1.1⟩, fun h ↦ ConnectedSpace.mk (toPreconnectedSpace := ⟨h.2⟩) ⟨h.1.some⟩⟩ theorem isPreconnected_range [TopologicalSpace β] [PreconnectedSpace α] {f : α → β} (h : Continuous f) : IsPreconnected (range f) := @image_univ _ _ f ▸ isPreconnected_univ.image _ h.continuousOn #align is_preconnected_range isPreconnected_range theorem isConnected_range [TopologicalSpace β] [ConnectedSpace α] {f : α → β} (h : Continuous f) : IsConnected (range f) := ⟨range_nonempty f, isPreconnected_range h⟩ #align is_connected_range isConnected_range theorem Function.Surjective.connectedSpace [ConnectedSpace α] [TopologicalSpace β] {f : α → β} (hf : Surjective f) (hf' : Continuous f) : ConnectedSpace β := by rw [connectedSpace_iff_univ, ← hf.range_eq] exact isConnected_range hf' instance Quotient.instConnectedSpace {s : Setoid α} [ConnectedSpace α] : ConnectedSpace (Quotient s) := (surjective_quotient_mk' _).connectedSpace continuous_coinduced_rng theorem DenseRange.preconnectedSpace [TopologicalSpace β] [PreconnectedSpace α] {f : α → β} (hf : DenseRange f) (hc : Continuous f) : PreconnectedSpace β := ⟨hf.closure_eq ▸ (isPreconnected_range hc).closure⟩ #align dense_range.preconnected_space DenseRange.preconnectedSpace theorem connectedSpace_iff_connectedComponent : ConnectedSpace α ↔ ∃ x : α, connectedComponent x = univ := by constructor · rintro ⟨⟨x⟩⟩ exact ⟨x, eq_univ_of_univ_subset <| isPreconnected_univ.subset_connectedComponent (mem_univ x)⟩ · rintro ⟨x, h⟩ haveI : PreconnectedSpace α := ⟨by rw [← h]; exact isPreconnected_connectedComponent⟩ exact ⟨⟨x⟩⟩ #align connected_space_iff_connected_component connectedSpace_iff_connectedComponent theorem preconnectedSpace_iff_connectedComponent : PreconnectedSpace α ↔ ∀ x : α, connectedComponent x = univ := by constructor · intro h x exact eq_univ_of_univ_subset <| isPreconnected_univ.subset_connectedComponent (mem_univ x) · intro h cases' isEmpty_or_nonempty α with hα hα · exact ⟨by rw [univ_eq_empty_iff.mpr hα]; exact isPreconnected_empty⟩ · exact ⟨by rw [← h (Classical.choice hα)]; exact isPreconnected_connectedComponent⟩ #align preconnected_space_iff_connected_component preconnectedSpace_iff_connectedComponent @[simp] theorem PreconnectedSpace.connectedComponent_eq_univ {X : Type*} [TopologicalSpace X] [h : PreconnectedSpace X] (x : X) : connectedComponent x = univ := preconnectedSpace_iff_connectedComponent.mp h x #align preconnected_space.connected_component_eq_univ PreconnectedSpace.connectedComponent_eq_univ instance [TopologicalSpace β] [PreconnectedSpace α] [PreconnectedSpace β] : PreconnectedSpace (α × β) := ⟨by rw [← univ_prod_univ] exact isPreconnected_univ.prod isPreconnected_univ⟩ instance [TopologicalSpace β] [ConnectedSpace α] [ConnectedSpace β] : ConnectedSpace (α × β) := ⟨inferInstance⟩ instance [∀ i, TopologicalSpace (π i)] [∀ i, PreconnectedSpace (π i)] : PreconnectedSpace (∀ i, π i) := ⟨by rw [← pi_univ univ]; exact isPreconnected_univ_pi fun i => isPreconnected_univ⟩ instance [∀ i, TopologicalSpace (π i)] [∀ i, ConnectedSpace (π i)] : ConnectedSpace (∀ i, π i) := ⟨inferInstance⟩ -- see Note [lower instance priority] instance (priority := 100) PreirreducibleSpace.preconnectedSpace (α : Type u) [TopologicalSpace α] [PreirreducibleSpace α] : PreconnectedSpace α := ⟨isPreirreducible_univ.isPreconnected⟩ #align preirreducible_space.preconnected_space PreirreducibleSpace.preconnectedSpace -- see Note [lower instance priority] instance (priority := 100) IrreducibleSpace.connectedSpace (α : Type u) [TopologicalSpace α] [IrreducibleSpace α] : ConnectedSpace α where toNonempty := IrreducibleSpace.toNonempty #align irreducible_space.connected_space IrreducibleSpace.connectedSpace theorem Continuous.exists_lift_sigma [ConnectedSpace α] [∀ i, TopologicalSpace (π i)] {f : α → Σ i, π i} (hf : Continuous f) : ∃ (i : ι) (g : α → π i), Continuous g ∧ f = Sigma.mk i ∘ g := by obtain ⟨i, hi⟩ : ∃ i, range f ⊆ range (.mk i) := by rcases Sigma.isConnected_iff.1 (isConnected_range hf) with ⟨i, s, -, hs⟩ exact ⟨i, hs.trans_subset (image_subset_range _ _)⟩ rcases range_subset_range_iff_exists_comp.1 hi with ⟨g, rfl⟩ refine ⟨i, g, ?_, rfl⟩ rwa [← embedding_sigmaMk.continuous_iff] at hf theorem nonempty_inter [PreconnectedSpace α] {s t : Set α} : IsOpen s → IsOpen t → s ∪ t = univ → s.Nonempty → t.Nonempty → (s ∩ t).Nonempty := by simpa only [univ_inter, univ_subset_iff] using @PreconnectedSpace.isPreconnected_univ α _ _ s t #align nonempty_inter nonempty_inter theorem isClopen_iff [PreconnectedSpace α] {s : Set α} : IsClopen s ↔ s = ∅ ∨ s = univ := ⟨fun hs => by_contradiction fun h => have h1 : s ≠ ∅ ∧ sᶜ ≠ ∅ := ⟨mt Or.inl h, mt (fun h2 => Or.inr <| (by rw [← compl_compl s, h2, compl_empty] : s = univ)) h⟩ let ⟨_, h2, h3⟩ := nonempty_inter hs.2 hs.1.isOpen_compl (union_compl_self s) (nonempty_iff_ne_empty.2 h1.1) (nonempty_iff_ne_empty.2 h1.2) h3 h2, by rintro (rfl | rfl) <;> [exact isClopen_empty; exact isClopen_univ]⟩ #align is_clopen_iff isClopen_iff theorem IsClopen.eq_univ [PreconnectedSpace α] {s : Set α} (h' : IsClopen s) (h : s.Nonempty) : s = univ := (isClopen_iff.mp h').resolve_left h.ne_empty #align is_clopen.eq_univ IsClopen.eq_univ theorem frontier_eq_empty_iff [PreconnectedSpace α] {s : Set α} : frontier s = ∅ ↔ s = ∅ ∨ s = univ := isClopen_iff_frontier_eq_empty.symm.trans isClopen_iff #align frontier_eq_empty_iff frontier_eq_empty_iff theorem nonempty_frontier_iff [PreconnectedSpace α] {s : Set α} : (frontier s).Nonempty ↔ s.Nonempty ∧ s ≠ univ := by simp only [nonempty_iff_ne_empty, Ne, frontier_eq_empty_iff, not_or] #align nonempty_frontier_iff nonempty_frontier_iff theorem Subtype.preconnectedSpace {s : Set α} (h : IsPreconnected s) : PreconnectedSpace s where isPreconnected_univ := by rwa [← inducing_subtype_val.isPreconnected_image, image_univ, Subtype.range_val] #align subtype.preconnected_space Subtype.preconnectedSpace theorem Subtype.connectedSpace {s : Set α} (h : IsConnected s) : ConnectedSpace s where toPreconnectedSpace := Subtype.preconnectedSpace h.isPreconnected toNonempty := h.nonempty.to_subtype #align subtype.connected_space Subtype.connectedSpace theorem isPreconnected_iff_preconnectedSpace {s : Set α} : IsPreconnected s ↔ PreconnectedSpace s := ⟨Subtype.preconnectedSpace, fun h => by simpa using isPreconnected_univ.image ((↑) : s → α) continuous_subtype_val.continuousOn⟩ #align is_preconnected_iff_preconnected_space isPreconnected_iff_preconnectedSpace theorem isConnected_iff_connectedSpace {s : Set α} : IsConnected s ↔ ConnectedSpace s := ⟨Subtype.connectedSpace, fun h => ⟨nonempty_subtype.mp h.2, isPreconnected_iff_preconnectedSpace.mpr h.1⟩⟩ #align is_connected_iff_connected_space isConnected_iff_connectedSpace lemma PreconnectedSpace.induction₂' [PreconnectedSpace α] (P : α → α → Prop) (h : ∀ x, ∀ᶠ y in 𝓝 x, P x y ∧ P y x) (h' : Transitive P) (x y : α) : P x y := by let u := {z | P x z} have A : IsClosed u := by apply isClosed_iff_nhds.2 (fun z hz ↦ ?_) rcases hz _ (h z) with ⟨t, ht, h't⟩ exact h' h't ht.2 have B : IsOpen u := by apply isOpen_iff_mem_nhds.2 (fun z hz ↦ ?_) filter_upwards [h z] with t ht exact h' hz ht.1 have C : u.Nonempty := ⟨x, (mem_of_mem_nhds (h x)).1⟩ have D : u = Set.univ := IsClopen.eq_univ ⟨A, B⟩ C show y ∈ u simp [D] lemma PreconnectedSpace.induction₂ [PreconnectedSpace α] (P : α → α → Prop) (h : ∀ x, ∀ᶠ y in 𝓝 x, P x y) (h' : Transitive P) (h'' : Symmetric P) (x y : α) : P x y := by refine PreconnectedSpace.induction₂' P (fun z ↦ ?_) h' x y filter_upwards [h z] with a ha exact ⟨ha, h'' ha⟩ lemma IsPreconnected.induction₂' {s : Set α} (hs : IsPreconnected s) (P : α → α → Prop) (h : ∀ x ∈ s, ∀ᶠ y in 𝓝[s] x, P x y ∧ P y x) (h' : ∀ x y z, x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z) {x y : α} (hx : x ∈ s) (hy : y ∈ s) : P x y := by let Q : s → s → Prop := fun a b ↦ P a b show Q ⟨x, hx⟩ ⟨y, hy⟩ have : PreconnectedSpace s := Subtype.preconnectedSpace hs apply PreconnectedSpace.induction₂' · rintro ⟨x, hx⟩ have Z := h x hx rwa [nhdsWithin_eq_map_subtype_coe] at Z · rintro ⟨a, ha⟩ ⟨b, hb⟩ ⟨c, hc⟩ hab hbc exact h' a b c ha hb hc hab hbc lemma IsPreconnected.induction₂ {s : Set α} (hs : IsPreconnected s) (P : α → α → Prop) (h : ∀ x ∈ s, ∀ᶠ y in 𝓝[s] x, P x y) (h' : ∀ x y z, x ∈ s → y ∈ s → z ∈ s → P x y → P y z → P x z) (h'' : ∀ x y, x ∈ s → y ∈ s → P x y → P y x) {x y : α} (hx : x ∈ s) (hy : y ∈ s) : P x y := by apply hs.induction₂' P (fun z hz ↦ ?_) h' hx hy filter_upwards [h z hz, self_mem_nhdsWithin] with a ha h'a exact ⟨ha, h'' z a hz h'a ha⟩ theorem isPreconnected_iff_subset_of_disjoint {s : Set α} : IsPreconnected s ↔ ∀ u v, IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v := by constructor <;> intro h · intro u v hu hv hs huv specialize h u v hu hv hs contrapose! huv simp [not_subset] at huv rcases huv with ⟨⟨x, hxs, hxu⟩, ⟨y, hys, hyv⟩⟩ have hxv : x ∈ v := or_iff_not_imp_left.mp (hs hxs) hxu have hyu : y ∈ u := or_iff_not_imp_right.mp (hs hys) hyv exact h ⟨y, hys, hyu⟩ ⟨x, hxs, hxv⟩ · intro u v hu hv hs hsu hsv by_contra H specialize h u v hu hv hs (Set.not_nonempty_iff_eq_empty.mp H) apply H cases' h with h h · rcases hsv with ⟨x, hxs, hxv⟩ exact ⟨x, hxs, ⟨h hxs, hxv⟩⟩ · rcases hsu with ⟨x, hxs, hxu⟩ exact ⟨x, hxs, ⟨hxu, h hxs⟩⟩ #align is_preconnected_iff_subset_of_disjoint isPreconnected_iff_subset_of_disjoint theorem isConnected_iff_sUnion_disjoint_open {s : Set α} : IsConnected s ↔ ∀ U : Finset (Set α), (∀ u v : Set α, u ∈ U → v ∈ U → (s ∩ (u ∩ v)).Nonempty → u = v) → (∀ u ∈ U, IsOpen u) → (s ⊆ ⋃₀ ↑U) → ∃ u ∈ U, s ⊆ u := by rw [IsConnected, isPreconnected_iff_subset_of_disjoint] refine ⟨fun ⟨hne, h⟩ U hU hUo hsU => ?_, fun h => ⟨?_, fun u v hu hv hs hsuv => ?_⟩⟩ · induction U using Finset.induction_on with | empty => exact absurd (by simpa using hsU) hne.not_subset_empty | @insert u U uU IH => simp only [← forall_cond_comm, Finset.forall_mem_insert, Finset.exists_mem_insert, Finset.coe_insert, sUnion_insert, implies_true, true_and] at * refine (h _ hUo.1 (⋃₀ ↑U) (isOpen_sUnion hUo.2) hsU ?_).imp_right ?_ · refine subset_empty_iff.1 fun x ⟨hxs, hxu, v, hvU, hxv⟩ => ?_ exact ne_of_mem_of_not_mem hvU uU (hU.1 v hvU ⟨x, hxs, hxu, hxv⟩).symm · exact IH (fun u hu => (hU.2 u hu).2) hUo.2 · simpa [subset_empty_iff, nonempty_iff_ne_empty] using h ∅ · rw [← not_nonempty_iff_eq_empty] at hsuv have := hsuv; rw [inter_comm u] at this simpa [*, or_imp, forall_and] using h {u, v} #align is_connected_iff_sUnion_disjoint_open isConnected_iff_sUnion_disjoint_open -- Porting note: `IsPreconnected.subset_isClopen` moved up from here theorem disjoint_or_subset_of_isClopen {s t : Set α} (hs : IsPreconnected s) (ht : IsClopen t) : Disjoint s t ∨ s ⊆ t := (disjoint_or_nonempty_inter s t).imp_right <| hs.subset_isClopen ht #align disjoint_or_subset_of_clopen disjoint_or_subset_of_isClopen theorem isPreconnected_iff_subset_of_disjoint_closed : IsPreconnected s ↔ ∀ u v, IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v := by constructor <;> intro h · intro u v hu hv hs huv rw [isPreconnected_closed_iff] at h specialize h u v hu hv hs contrapose! huv simp [not_subset] at huv rcases huv with ⟨⟨x, hxs, hxu⟩, ⟨y, hys, hyv⟩⟩ have hxv : x ∈ v := or_iff_not_imp_left.mp (hs hxs) hxu have hyu : y ∈ u := or_iff_not_imp_right.mp (hs hys) hyv exact h ⟨y, hys, hyu⟩ ⟨x, hxs, hxv⟩ · rw [isPreconnected_closed_iff] intro u v hu hv hs hsu hsv by_contra H specialize h u v hu hv hs (Set.not_nonempty_iff_eq_empty.mp H) apply H cases' h with h h · rcases hsv with ⟨x, hxs, hxv⟩ exact ⟨x, hxs, ⟨h hxs, hxv⟩⟩ · rcases hsu with ⟨x, hxs, hxu⟩ exact ⟨x, hxs, ⟨hxu, h hxs⟩⟩ #align is_preconnected_iff_subset_of_disjoint_closed isPreconnected_iff_subset_of_disjoint_closed
Mathlib/Topology/Connected/Basic.lean
1,112
1,124
theorem isPreconnected_iff_subset_of_fully_disjoint_closed {s : Set α} (hs : IsClosed s) : IsPreconnected s ↔ ∀ u v, IsClosed u → IsClosed v → s ⊆ u ∪ v → Disjoint u v → s ⊆ u ∨ s ⊆ v := by
refine isPreconnected_iff_subset_of_disjoint_closed.trans ⟨?_, ?_⟩ <;> intro H u v hu hv hss huv · apply H u v hu hv hss rw [huv.inter_eq, inter_empty] have H1 := H (u ∩ s) (v ∩ s) rw [subset_inter_iff, subset_inter_iff] at H1 simp only [Subset.refl, and_true] at H1 apply H1 (hu.inter hs) (hv.inter hs) · rw [← union_inter_distrib_right] exact subset_inter hss Subset.rfl · rwa [disjoint_iff_inter_eq_empty, ← inter_inter_distrib_right, inter_comm]
import Mathlib.Algebra.BigOperators.Finprod import Mathlib.Order.Filter.Pointwise import Mathlib.Topology.Algebra.MulAction import Mathlib.Algebra.BigOperators.Pi import Mathlib.Topology.ContinuousFunction.Basic import Mathlib.Algebra.Group.ULift #align_import topology.algebra.monoid from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" universe u v open scoped Classical open Set Filter TopologicalSpace open scoped Classical open Topology Pointwise variable {ι α M N X : Type*} [TopologicalSpace X] @[to_additive (attr := continuity, fun_prop)] theorem continuous_one [TopologicalSpace M] [One M] : Continuous (1 : X → M) := @continuous_const _ _ _ _ 1 #align continuous_one continuous_one #align continuous_zero continuous_zero class ContinuousAdd (M : Type u) [TopologicalSpace M] [Add M] : Prop where continuous_add : Continuous fun p : M × M => p.1 + p.2 #align has_continuous_add ContinuousAdd @[to_additive] class ContinuousMul (M : Type u) [TopologicalSpace M] [Mul M] : Prop where continuous_mul : Continuous fun p : M × M => p.1 * p.2 #align has_continuous_mul ContinuousMul section ContinuousMul variable [TopologicalSpace M] [Mul M] [ContinuousMul M] @[to_additive] instance : ContinuousMul Mᵒᵈ := ‹ContinuousMul M› @[to_additive (attr := continuity)] theorem continuous_mul : Continuous fun p : M × M => p.1 * p.2 := ContinuousMul.continuous_mul #align continuous_mul continuous_mul #align continuous_add continuous_add @[to_additive] instance : ContinuousMul (ULift.{u} M) := by constructor apply continuous_uLift_up.comp exact continuous_mul.comp₂ (continuous_uLift_down.comp continuous_fst) (continuous_uLift_down.comp continuous_snd) @[to_additive] instance ContinuousMul.to_continuousSMul : ContinuousSMul M M := ⟨continuous_mul⟩ #align has_continuous_mul.to_has_continuous_smul ContinuousMul.to_continuousSMul #align has_continuous_add.to_has_continuous_vadd ContinuousAdd.to_continuousVAdd @[to_additive] instance ContinuousMul.to_continuousSMul_op : ContinuousSMul Mᵐᵒᵖ M := ⟨show Continuous ((fun p : M × M => p.1 * p.2) ∘ Prod.swap ∘ Prod.map MulOpposite.unop id) from continuous_mul.comp <| continuous_swap.comp <| Continuous.prod_map MulOpposite.continuous_unop continuous_id⟩ #align has_continuous_mul.to_has_continuous_smul_op ContinuousMul.to_continuousSMul_op #align has_continuous_add.to_has_continuous_vadd_op ContinuousAdd.to_continuousVAdd_op @[to_additive (attr := continuity, fun_prop)] theorem Continuous.mul {f g : X → M} (hf : Continuous f) (hg : Continuous g) : Continuous fun x => f x * g x := continuous_mul.comp (hf.prod_mk hg : _) #align continuous.mul Continuous.mul #align continuous.add Continuous.add @[to_additive (attr := continuity)] theorem continuous_mul_left (a : M) : Continuous fun b : M => a * b := continuous_const.mul continuous_id #align continuous_mul_left continuous_mul_left #align continuous_add_left continuous_add_left @[to_additive (attr := continuity)] theorem continuous_mul_right (a : M) : Continuous fun b : M => b * a := continuous_id.mul continuous_const #align continuous_mul_right continuous_mul_right #align continuous_add_right continuous_add_right @[to_additive (attr := fun_prop)] theorem ContinuousOn.mul {f g : X → M} {s : Set X} (hf : ContinuousOn f s) (hg : ContinuousOn g s) : ContinuousOn (fun x => f x * g x) s := (continuous_mul.comp_continuousOn (hf.prod hg) : _) #align continuous_on.mul ContinuousOn.mul #align continuous_on.add ContinuousOn.add @[to_additive] theorem tendsto_mul {a b : M} : Tendsto (fun p : M × M => p.fst * p.snd) (𝓝 (a, b)) (𝓝 (a * b)) := continuous_iff_continuousAt.mp ContinuousMul.continuous_mul (a, b) #align tendsto_mul tendsto_mul #align tendsto_add tendsto_add @[to_additive] theorem Filter.Tendsto.mul {f g : α → M} {x : Filter α} {a b : M} (hf : Tendsto f x (𝓝 a)) (hg : Tendsto g x (𝓝 b)) : Tendsto (fun x => f x * g x) x (𝓝 (a * b)) := tendsto_mul.comp (hf.prod_mk_nhds hg) #align filter.tendsto.mul Filter.Tendsto.mul #align filter.tendsto.add Filter.Tendsto.add @[to_additive] theorem Filter.Tendsto.const_mul (b : M) {c : M} {f : α → M} {l : Filter α} (h : Tendsto (fun k : α => f k) l (𝓝 c)) : Tendsto (fun k : α => b * f k) l (𝓝 (b * c)) := tendsto_const_nhds.mul h #align filter.tendsto.const_mul Filter.Tendsto.const_mul #align filter.tendsto.const_add Filter.Tendsto.const_add @[to_additive] theorem Filter.Tendsto.mul_const (b : M) {c : M} {f : α → M} {l : Filter α} (h : Tendsto (fun k : α => f k) l (𝓝 c)) : Tendsto (fun k : α => f k * b) l (𝓝 (c * b)) := h.mul tendsto_const_nhds #align filter.tendsto.mul_const Filter.Tendsto.mul_const #align filter.tendsto.add_const Filter.Tendsto.add_const @[to_additive] theorem le_nhds_mul (a b : M) : 𝓝 a * 𝓝 b ≤ 𝓝 (a * b) := by rw [← map₂_mul, ← map_uncurry_prod, ← nhds_prod_eq] exact continuous_mul.tendsto _ #align le_nhds_mul le_nhds_mul #align le_nhds_add le_nhds_add @[to_additive (attr := simp)] theorem nhds_one_mul_nhds {M} [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] (a : M) : 𝓝 (1 : M) * 𝓝 a = 𝓝 a := ((le_nhds_mul _ _).trans_eq <| congr_arg _ (one_mul a)).antisymm <| le_mul_of_one_le_left' <| pure_le_nhds 1 #align nhds_one_mul_nhds nhds_one_mul_nhds #align nhds_zero_add_nhds nhds_zero_add_nhds @[to_additive (attr := simp)] theorem nhds_mul_nhds_one {M} [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] (a : M) : 𝓝 a * 𝓝 1 = 𝓝 a := ((le_nhds_mul _ _).trans_eq <| congr_arg _ (mul_one a)).antisymm <| le_mul_of_one_le_right' <| pure_le_nhds 1 #align nhds_mul_nhds_one nhds_mul_nhds_one #align nhds_add_nhds_zero nhds_add_nhds_zero @[to_additive] protected theorem Specializes.mul {a b c d : M} (hab : a ⤳ b) (hcd : c ⤳ d) : (a * c) ⤳ (b * d) := hab.smul hcd @[to_additive] protected theorem Inseparable.mul {a b c d : M} (hab : Inseparable a b) (hcd : Inseparable c d) : Inseparable (a * c) (b * d) := hab.smul hcd @[to_additive] protected theorem Specializes.pow {M : Type*} [Monoid M] [TopologicalSpace M] [ContinuousMul M] {a b : M} (h : a ⤳ b) (n : ℕ) : (a ^ n) ⤳ (b ^ n) := Nat.recOn n (by simp only [pow_zero, specializes_rfl]) fun _ ihn ↦ by simpa only [pow_succ] using ihn.mul h @[to_additive] protected theorem Inseparable.pow {M : Type*} [Monoid M] [TopologicalSpace M] [ContinuousMul M] {a b : M} (h : Inseparable a b) (n : ℕ) : Inseparable (a ^ n) (b ^ n) := (h.specializes.pow n).antisymm (h.specializes'.pow n) @[to_additive (attr := simps) "Construct an additive unit from limits of additive units and their negatives."] def Filter.Tendsto.units [TopologicalSpace N] [Monoid N] [ContinuousMul N] [T2Space N] {f : ι → Nˣ} {r₁ r₂ : N} {l : Filter ι} [l.NeBot] (h₁ : Tendsto (fun x => ↑(f x)) l (𝓝 r₁)) (h₂ : Tendsto (fun x => ↑(f x)⁻¹) l (𝓝 r₂)) : Nˣ where val := r₁ inv := r₂ val_inv := by symm simpa using h₁.mul h₂ inv_val := by symm simpa using h₂.mul h₁ #align filter.tendsto.units Filter.Tendsto.units #align filter.tendsto.add_units Filter.Tendsto.addUnits @[to_additive (attr := fun_prop)] theorem ContinuousAt.mul {f g : X → M} {x : X} (hf : ContinuousAt f x) (hg : ContinuousAt g x) : ContinuousAt (fun x => f x * g x) x := Filter.Tendsto.mul hf hg #align continuous_at.mul ContinuousAt.mul #align continuous_at.add ContinuousAt.add @[to_additive] theorem ContinuousWithinAt.mul {f g : X → M} {s : Set X} {x : X} (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) : ContinuousWithinAt (fun x => f x * g x) s x := Filter.Tendsto.mul hf hg #align continuous_within_at.mul ContinuousWithinAt.mul #align continuous_within_at.add ContinuousWithinAt.add @[to_additive] instance Prod.continuousMul [TopologicalSpace N] [Mul N] [ContinuousMul N] : ContinuousMul (M × N) := ⟨(continuous_fst.fst'.mul continuous_fst.snd').prod_mk (continuous_snd.fst'.mul continuous_snd.snd')⟩ @[to_additive] instance Pi.continuousMul {C : ι → Type*} [∀ i, TopologicalSpace (C i)] [∀ i, Mul (C i)] [∀ i, ContinuousMul (C i)] : ContinuousMul (∀ i, C i) where continuous_mul := continuous_pi fun i => (continuous_apply i).fst'.mul (continuous_apply i).snd' #align pi.has_continuous_mul Pi.continuousMul #align pi.has_continuous_add Pi.continuousAdd @[to_additive "A version of `Pi.continuousAdd` for non-dependent functions. It is needed because sometimes Lean fails to use `Pi.continuousAdd` for non-dependent functions."] instance Pi.continuousMul' : ContinuousMul (ι → M) := Pi.continuousMul #align pi.has_continuous_mul' Pi.continuousMul' #align pi.has_continuous_add' Pi.continuousAdd' @[to_additive] instance (priority := 100) continuousMul_of_discreteTopology [TopologicalSpace N] [Mul N] [DiscreteTopology N] : ContinuousMul N := ⟨continuous_of_discreteTopology⟩ #align has_continuous_mul_of_discrete_topology continuousMul_of_discreteTopology #align has_continuous_add_of_discrete_topology continuousAdd_of_discreteTopology open Filter open Function @[to_additive] theorem ContinuousMul.of_nhds_one {M : Type u} [Monoid M] [TopologicalSpace M] (hmul : Tendsto (uncurry ((· * ·) : M → M → M)) (𝓝 1 ×ˢ 𝓝 1) <| 𝓝 1) (hleft : ∀ x₀ : M, 𝓝 x₀ = map (fun x => x₀ * x) (𝓝 1)) (hright : ∀ x₀ : M, 𝓝 x₀ = map (fun x => x * x₀) (𝓝 1)) : ContinuousMul M := ⟨by rw [continuous_iff_continuousAt] rintro ⟨x₀, y₀⟩ have key : (fun p : M × M => x₀ * p.1 * (p.2 * y₀)) = ((fun x => x₀ * x) ∘ fun x => x * y₀) ∘ uncurry (· * ·) := by ext p simp [uncurry, mul_assoc] have key₂ : ((fun x => x₀ * x) ∘ fun x => y₀ * x) = fun x => x₀ * y₀ * x := by ext x simp [mul_assoc] calc map (uncurry (· * ·)) (𝓝 (x₀, y₀)) = map (uncurry (· * ·)) (𝓝 x₀ ×ˢ 𝓝 y₀) := by rw [nhds_prod_eq] _ = map (fun p : M × M => x₀ * p.1 * (p.2 * y₀)) (𝓝 1 ×ˢ 𝓝 1) := by -- Porting note: `rw` was able to prove this -- Now it fails with `failed to rewrite using equation theorems for 'Function.uncurry'` -- and `failed to rewrite using equation theorems for 'Function.comp'`. -- Removing those two lemmas, the `rw` would succeed, but then needs a `rfl`. simp (config := { unfoldPartialApp := true }) only [uncurry] simp_rw [hleft x₀, hright y₀, prod_map_map_eq, Filter.map_map, Function.comp_def] _ = map ((fun x => x₀ * x) ∘ fun x => x * y₀) (map (uncurry (· * ·)) (𝓝 1 ×ˢ 𝓝 1)) := by rw [key, ← Filter.map_map] _ ≤ map ((fun x : M => x₀ * x) ∘ fun x => x * y₀) (𝓝 1) := map_mono hmul _ = 𝓝 (x₀ * y₀) := by rw [← Filter.map_map, ← hright, hleft y₀, Filter.map_map, key₂, ← hleft]⟩ #align has_continuous_mul.of_nhds_one ContinuousMul.of_nhds_one #align has_continuous_add.of_nhds_zero ContinuousAdd.of_nhds_zero @[to_additive]
Mathlib/Topology/Algebra/Monoid.lean
326
331
theorem continuousMul_of_comm_of_nhds_one (M : Type u) [CommMonoid M] [TopologicalSpace M] (hmul : Tendsto (uncurry ((· * ·) : M → M → M)) (𝓝 1 ×ˢ 𝓝 1) (𝓝 1)) (hleft : ∀ x₀ : M, 𝓝 x₀ = map (fun x => x₀ * x) (𝓝 1)) : ContinuousMul M := by
apply ContinuousMul.of_nhds_one hmul hleft intro x₀ simp_rw [mul_comm, hleft x₀]
import Mathlib.Analysis.InnerProductSpace.Adjoint #align_import analysis.inner_product_space.positive from "leanprover-community/mathlib"@"caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c" open InnerProductSpace RCLike ContinuousLinearMap open scoped InnerProduct ComplexConjugate namespace ContinuousLinearMap variable {𝕜 E F : Type*} [RCLike 𝕜] variable [NormedAddCommGroup E] [NormedAddCommGroup F] variable [InnerProductSpace 𝕜 E] [InnerProductSpace 𝕜 F] variable [CompleteSpace E] [CompleteSpace F] local notation "⟪" x ", " y "⟫" => @inner 𝕜 _ _ x y def IsPositive (T : E →L[𝕜] E) : Prop := IsSelfAdjoint T ∧ ∀ x, 0 ≤ T.reApplyInnerSelf x #align continuous_linear_map.is_positive ContinuousLinearMap.IsPositive theorem IsPositive.isSelfAdjoint {T : E →L[𝕜] E} (hT : IsPositive T) : IsSelfAdjoint T := hT.1 #align continuous_linear_map.is_positive.is_self_adjoint ContinuousLinearMap.IsPositive.isSelfAdjoint theorem IsPositive.inner_nonneg_left {T : E →L[𝕜] E} (hT : IsPositive T) (x : E) : 0 ≤ re ⟪T x, x⟫ := hT.2 x #align continuous_linear_map.is_positive.inner_nonneg_left ContinuousLinearMap.IsPositive.inner_nonneg_left
Mathlib/Analysis/InnerProductSpace/Positive.lean
67
68
theorem IsPositive.inner_nonneg_right {T : E →L[𝕜] E} (hT : IsPositive T) (x : E) : 0 ≤ re ⟪x, T x⟫ := by
rw [inner_re_symm]; exact hT.inner_nonneg_left x
import Mathlib.Algebra.BigOperators.Group.Multiset import Mathlib.Data.PNat.Prime import Mathlib.Data.Nat.Factors import Mathlib.Data.Multiset.Sort #align_import data.pnat.factors from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d" -- Porting note: `deriving` contained Inhabited, CanonicallyOrderedAddCommMonoid, DistribLattice, -- SemilatticeSup, OrderBot, Sub, OrderedSub def PrimeMultiset := Multiset Nat.Primes deriving Inhabited, CanonicallyOrderedAddCommMonoid, DistribLattice, SemilatticeSup, Sub #align prime_multiset PrimeMultiset instance : OrderBot PrimeMultiset where bot_le := by simp only [bot_le, forall_const] instance : OrderedSub PrimeMultiset where tsub_le_iff_right _ _ _ := Multiset.sub_le_iff_le_add namespace PrimeMultiset -- `@[derive]` doesn't work for `meta` instances unsafe instance : Repr PrimeMultiset := by delta PrimeMultiset; infer_instance def ofPrime (p : Nat.Primes) : PrimeMultiset := ({p} : Multiset Nat.Primes) #align prime_multiset.of_prime PrimeMultiset.ofPrime theorem card_ofPrime (p : Nat.Primes) : Multiset.card (ofPrime p) = 1 := rfl #align prime_multiset.card_of_prime PrimeMultiset.card_ofPrime def toNatMultiset : PrimeMultiset → Multiset ℕ := fun v => v.map Coe.coe #align prime_multiset.to_nat_multiset PrimeMultiset.toNatMultiset instance coeNat : Coe PrimeMultiset (Multiset ℕ) := ⟨toNatMultiset⟩ #align prime_multiset.coe_nat PrimeMultiset.coeNat def coeNatMonoidHom : PrimeMultiset →+ Multiset ℕ := { Multiset.mapAddMonoidHom Coe.coe with toFun := Coe.coe } #align prime_multiset.coe_nat_monoid_hom PrimeMultiset.coeNatMonoidHom @[simp] theorem coe_coeNatMonoidHom : (coeNatMonoidHom : PrimeMultiset → Multiset ℕ) = Coe.coe := rfl #align prime_multiset.coe_coe_nat_monoid_hom PrimeMultiset.coe_coeNatMonoidHom theorem coeNat_injective : Function.Injective (Coe.coe : PrimeMultiset → Multiset ℕ) := Multiset.map_injective Nat.Primes.coe_nat_injective #align prime_multiset.coe_nat_injective PrimeMultiset.coeNat_injective theorem coeNat_ofPrime (p : Nat.Primes) : (ofPrime p : Multiset ℕ) = {(p : ℕ)} := rfl #align prime_multiset.coe_nat_of_prime PrimeMultiset.coeNat_ofPrime theorem coeNat_prime (v : PrimeMultiset) (p : ℕ) (h : p ∈ (v : Multiset ℕ)) : p.Prime := by rcases Multiset.mem_map.mp h with ⟨⟨_, hp'⟩, ⟨_, h_eq⟩⟩ exact h_eq ▸ hp' #align prime_multiset.coe_nat_prime PrimeMultiset.coeNat_prime def toPNatMultiset : PrimeMultiset → Multiset ℕ+ := fun v => v.map Coe.coe #align prime_multiset.to_pnat_multiset PrimeMultiset.toPNatMultiset instance coePNat : Coe PrimeMultiset (Multiset ℕ+) := ⟨toPNatMultiset⟩ #align prime_multiset.coe_pnat PrimeMultiset.coePNat def coePNatMonoidHom : PrimeMultiset →+ Multiset ℕ+ := { Multiset.mapAddMonoidHom Coe.coe with toFun := Coe.coe } #align prime_multiset.coe_pnat_monoid_hom PrimeMultiset.coePNatMonoidHom @[simp] theorem coe_coePNatMonoidHom : (coePNatMonoidHom : PrimeMultiset → Multiset ℕ+) = Coe.coe := rfl #align prime_multiset.coe_coe_pnat_monoid_hom PrimeMultiset.coe_coePNatMonoidHom theorem coePNat_injective : Function.Injective (Coe.coe : PrimeMultiset → Multiset ℕ+) := Multiset.map_injective Nat.Primes.coe_pnat_injective #align prime_multiset.coe_pnat_injective PrimeMultiset.coePNat_injective theorem coePNat_ofPrime (p : Nat.Primes) : (ofPrime p : Multiset ℕ+) = {(p : ℕ+)} := rfl #align prime_multiset.coe_pnat_of_prime PrimeMultiset.coePNat_ofPrime theorem coePNat_prime (v : PrimeMultiset) (p : ℕ+) (h : p ∈ (v : Multiset ℕ+)) : p.Prime := by rcases Multiset.mem_map.mp h with ⟨⟨_, hp'⟩, ⟨_, h_eq⟩⟩ exact h_eq ▸ hp' #align prime_multiset.coe_pnat_prime PrimeMultiset.coePNat_prime instance coeMultisetPNatNat : Coe (Multiset ℕ+) (Multiset ℕ) := ⟨fun v => v.map Coe.coe⟩ #align prime_multiset.coe_multiset_pnat_nat PrimeMultiset.coeMultisetPNatNat theorem coePNat_nat (v : PrimeMultiset) : ((v : Multiset ℕ+) : Multiset ℕ) = (v : Multiset ℕ) := by change (v.map (Coe.coe : Nat.Primes → ℕ+)).map Subtype.val = v.map Subtype.val rw [Multiset.map_map] congr #align prime_multiset.coe_pnat_nat PrimeMultiset.coePNat_nat def prod (v : PrimeMultiset) : ℕ+ := (v : Multiset PNat).prod #align prime_multiset.prod PrimeMultiset.prod theorem coe_prod (v : PrimeMultiset) : (v.prod : ℕ) = (v : Multiset ℕ).prod := by let h : (v.prod : ℕ) = ((v.map Coe.coe).map Coe.coe).prod := PNat.coeMonoidHom.map_multiset_prod v.toPNatMultiset rw [Multiset.map_map] at h have : (Coe.coe : ℕ+ → ℕ) ∘ (Coe.coe : Nat.Primes → ℕ+) = Coe.coe := funext fun p => rfl rw [this] at h; exact h #align prime_multiset.coe_prod PrimeMultiset.coe_prod theorem prod_ofPrime (p : Nat.Primes) : (ofPrime p).prod = (p : ℕ+) := Multiset.prod_singleton _ #align prime_multiset.prod_of_prime PrimeMultiset.prod_ofPrime def ofNatMultiset (v : Multiset ℕ) (h : ∀ p : ℕ, p ∈ v → p.Prime) : PrimeMultiset := @Multiset.pmap ℕ Nat.Primes Nat.Prime (fun p hp => ⟨p, hp⟩) v h #align prime_multiset.of_nat_multiset PrimeMultiset.ofNatMultiset theorem to_ofNatMultiset (v : Multiset ℕ) (h) : (ofNatMultiset v h : Multiset ℕ) = v := by dsimp [ofNatMultiset, toNatMultiset] have : (fun p h => (Coe.coe : Nat.Primes → ℕ) ⟨p, h⟩) = fun p _ => id p := by funext p h rfl rw [Multiset.map_pmap, this, Multiset.pmap_eq_map, Multiset.map_id] #align prime_multiset.to_of_nat_multiset PrimeMultiset.to_ofNatMultiset theorem prod_ofNatMultiset (v : Multiset ℕ) (h) : ((ofNatMultiset v h).prod : ℕ) = (v.prod : ℕ) := by rw [coe_prod, to_ofNatMultiset] #align prime_multiset.prod_of_nat_multiset PrimeMultiset.prod_ofNatMultiset def ofPNatMultiset (v : Multiset ℕ+) (h : ∀ p : ℕ+, p ∈ v → p.Prime) : PrimeMultiset := @Multiset.pmap ℕ+ Nat.Primes PNat.Prime (fun p hp => ⟨(p : ℕ), hp⟩) v h #align prime_multiset.of_pnat_multiset PrimeMultiset.ofPNatMultiset theorem to_ofPNatMultiset (v : Multiset ℕ+) (h) : (ofPNatMultiset v h : Multiset ℕ+) = v := by dsimp [ofPNatMultiset, toPNatMultiset] have : (fun (p : ℕ+) (h : p.Prime) => (Coe.coe : Nat.Primes → ℕ+) ⟨p, h⟩) = fun p _ => id p := by funext p h apply Subtype.eq rfl rw [Multiset.map_pmap, this, Multiset.pmap_eq_map, Multiset.map_id] #align prime_multiset.to_of_pnat_multiset PrimeMultiset.to_ofPNatMultiset theorem prod_ofPNatMultiset (v : Multiset ℕ+) (h) : ((ofPNatMultiset v h).prod : ℕ+) = v.prod := by dsimp [prod] rw [to_ofPNatMultiset] #align prime_multiset.prod_of_pnat_multiset PrimeMultiset.prod_ofPNatMultiset def ofNatList (l : List ℕ) (h : ∀ p : ℕ, p ∈ l → p.Prime) : PrimeMultiset := ofNatMultiset (l : Multiset ℕ) h #align prime_multiset.of_nat_list PrimeMultiset.ofNatList
Mathlib/Data/PNat/Factors.lean
195
198
theorem prod_ofNatList (l : List ℕ) (h) : ((ofNatList l h).prod : ℕ) = l.prod := by
have := prod_ofNatMultiset (l : Multiset ℕ) h rw [Multiset.prod_coe] at this exact this
import Mathlib.LinearAlgebra.AffineSpace.Independent import Mathlib.LinearAlgebra.Basis #align_import linear_algebra.affine_space.basis from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0" open Affine open Set universe u₁ u₂ u₃ u₄ structure AffineBasis (ι : Type u₁) (k : Type u₂) {V : Type u₃} (P : Type u₄) [AddCommGroup V] [AffineSpace V P] [Ring k] [Module k V] where protected toFun : ι → P protected ind' : AffineIndependent k toFun protected tot' : affineSpan k (range toFun) = ⊤ #align affine_basis AffineBasis variable {ι ι' k V P : Type*} [AddCommGroup V] [AffineSpace V P] namespace AffineBasis section Ring variable [Ring k] [Module k V] (b : AffineBasis ι k P) {s : Finset ι} {i j : ι} (e : ι ≃ ι') instance : Inhabited (AffineBasis PUnit k PUnit) := ⟨⟨id, affineIndependent_of_subsingleton k id, by simp⟩⟩ instance instFunLike : FunLike (AffineBasis ι k P) ι P where coe := AffineBasis.toFun coe_injective' f g h := by cases f; cases g; congr #align affine_basis.fun_like AffineBasis.instFunLike @[ext] theorem ext {b₁ b₂ : AffineBasis ι k P} (h : (b₁ : ι → P) = b₂) : b₁ = b₂ := DFunLike.coe_injective h #align affine_basis.ext AffineBasis.ext theorem ind : AffineIndependent k b := b.ind' #align affine_basis.ind AffineBasis.ind theorem tot : affineSpan k (range b) = ⊤ := b.tot' #align affine_basis.tot AffineBasis.tot protected theorem nonempty : Nonempty ι := not_isEmpty_iff.mp fun hι => by simpa only [@range_eq_empty _ _ hι, AffineSubspace.span_empty, bot_ne_top] using b.tot #align affine_basis.nonempty AffineBasis.nonempty def reindex (e : ι ≃ ι') : AffineBasis ι' k P := ⟨b ∘ e.symm, b.ind.comp_embedding e.symm.toEmbedding, by rw [e.symm.surjective.range_comp] exact b.3⟩ #align affine_basis.reindex AffineBasis.reindex @[simp, norm_cast] theorem coe_reindex : ⇑(b.reindex e) = b ∘ e.symm := rfl #align affine_basis.coe_reindex AffineBasis.coe_reindex @[simp] theorem reindex_apply (i' : ι') : b.reindex e i' = b (e.symm i') := rfl #align affine_basis.reindex_apply AffineBasis.reindex_apply @[simp] theorem reindex_refl : b.reindex (Equiv.refl _) = b := ext rfl #align affine_basis.reindex_refl AffineBasis.reindex_refl noncomputable def basisOf (i : ι) : Basis { j : ι // j ≠ i } k V := Basis.mk ((affineIndependent_iff_linearIndependent_vsub k b i).mp b.ind) (by suffices Submodule.span k (range fun j : { x // x ≠ i } => b ↑j -ᵥ b i) = vectorSpan k (range b) by rw [this, ← direction_affineSpan, b.tot, AffineSubspace.direction_top] conv_rhs => rw [← image_univ] rw [vectorSpan_image_eq_span_vsub_set_right_ne k b (mem_univ i)] congr ext v simp) #align affine_basis.basis_of AffineBasis.basisOf @[simp] theorem basisOf_apply (i : ι) (j : { j : ι // j ≠ i }) : b.basisOf i j = b ↑j -ᵥ b i := by simp [basisOf] #align affine_basis.basis_of_apply AffineBasis.basisOf_apply @[simp] theorem basisOf_reindex (i : ι') : (b.reindex e).basisOf i = (b.basisOf <| e.symm i).reindex (e.subtypeEquiv fun _ => e.eq_symm_apply.not) := by ext j simp #align affine_basis.basis_of_reindex AffineBasis.basisOf_reindex noncomputable def coord (i : ι) : P →ᵃ[k] k where toFun q := 1 - (b.basisOf i).sumCoords (q -ᵥ b i) linear := -(b.basisOf i).sumCoords map_vadd' q v := by dsimp only rw [vadd_vsub_assoc, LinearMap.map_add, vadd_eq_add, LinearMap.neg_apply, sub_add_eq_sub_sub_swap, add_comm, sub_eq_add_neg] #align affine_basis.coord AffineBasis.coord @[simp] theorem linear_eq_sumCoords (i : ι) : (b.coord i).linear = -(b.basisOf i).sumCoords := rfl #align affine_basis.linear_eq_sum_coords AffineBasis.linear_eq_sumCoords @[simp] theorem coord_reindex (i : ι') : (b.reindex e).coord i = b.coord (e.symm i) := by ext classical simp [AffineBasis.coord] #align affine_basis.coord_reindex AffineBasis.coord_reindex @[simp]
Mathlib/LinearAlgebra/AffineSpace/Basis.lean
168
170
theorem coord_apply_eq (i : ι) : b.coord i (b i) = 1 := by
simp only [coord, Basis.coe_sumCoords, LinearEquiv.map_zero, LinearEquiv.coe_coe, sub_zero, AffineMap.coe_mk, Finsupp.sum_zero_index, vsub_self]
import Mathlib.MeasureTheory.Group.GeometryOfNumbers import Mathlib.MeasureTheory.Measure.Lebesgue.VolumeOfBalls import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic #align_import number_theory.number_field.canonical_embedding from "leanprover-community/mathlib"@"60da01b41bbe4206f05d34fd70c8dd7498717a30" variable (K : Type*) [Field K] namespace NumberField.mixedEmbedding open NumberField NumberField.InfinitePlace FiniteDimensional local notation "E" K => ({w : InfinitePlace K // IsReal w} → ℝ) × ({w : InfinitePlace K // IsComplex w} → ℂ) section convexBodySum open ENNReal MeasureTheory Fintype open scoped Real Classical NNReal variable [NumberField K] (B : ℝ) variable {K} noncomputable abbrev convexBodySumFun (x : E K) : ℝ := ∑ w, mult w * normAtPlace w x theorem convexBodySumFun_apply (x : E K) : convexBodySumFun x = ∑ w, mult w * normAtPlace w x := rfl theorem convexBodySumFun_apply' (x : E K) : convexBodySumFun x = ∑ w, ‖x.1 w‖ + 2 * ∑ w, ‖x.2 w‖ := by simp_rw [convexBodySumFun_apply, ← Finset.sum_add_sum_compl {w | IsReal w}.toFinset, Set.toFinset_setOf, Finset.compl_filter, not_isReal_iff_isComplex, ← Finset.subtype_univ, ← Finset.univ.sum_subtype_eq_sum_filter, Finset.mul_sum] congr · ext w rw [mult, if_pos w.prop, normAtPlace_apply_isReal, Nat.cast_one, one_mul] · ext w rw [mult, if_neg (not_isReal_iff_isComplex.mpr w.prop), normAtPlace_apply_isComplex, Nat.cast_ofNat] theorem convexBodySumFun_nonneg (x : E K) : 0 ≤ convexBodySumFun x := Finset.sum_nonneg (fun _ _ => mul_nonneg (Nat.cast_pos.mpr mult_pos).le (normAtPlace_nonneg _ _)) theorem convexBodySumFun_neg (x : E K) : convexBodySumFun (- x) = convexBodySumFun x := by simp_rw [convexBodySumFun, normAtPlace_neg] theorem convexBodySumFun_add_le (x y : E K) : convexBodySumFun (x + y) ≤ convexBodySumFun x + convexBodySumFun y := by simp_rw [convexBodySumFun, ← Finset.sum_add_distrib, ← mul_add] exact Finset.sum_le_sum fun _ _ ↦ mul_le_mul_of_nonneg_left (normAtPlace_add_le _ x y) (Nat.cast_pos.mpr mult_pos).le theorem convexBodySumFun_smul (c : ℝ) (x : E K) : convexBodySumFun (c • x) = |c| * convexBodySumFun x := by simp_rw [convexBodySumFun, normAtPlace_smul, ← mul_assoc, mul_comm, Finset.mul_sum, mul_assoc]
Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean
316
324
theorem convexBodySumFun_eq_zero_iff (x : E K) : convexBodySumFun x = 0 ↔ x = 0 := by
rw [← normAtPlace_eq_zero, convexBodySumFun, Finset.sum_eq_zero_iff_of_nonneg fun _ _ => mul_nonneg (Nat.cast_pos.mpr mult_pos).le (normAtPlace_nonneg _ _)] conv => enter [1, w, hw] rw [mul_left_mem_nonZeroDivisors_eq_zero_iff (mem_nonZeroDivisors_iff_ne_zero.mpr <| Nat.cast_ne_zero.mpr mult_ne_zero)] simp_rw [Finset.mem_univ, true_implies]
import Mathlib.LinearAlgebra.Isomorphisms import Mathlib.Algebra.Category.ModuleCat.Kernels import Mathlib.Algebra.Category.ModuleCat.Limits import Mathlib.CategoryTheory.Abelian.Exact #align_import algebra.category.Module.abelian from "leanprover-community/mathlib"@"09f981f72d43749f1fa072deade828d9c1e185bb" open CategoryTheory open CategoryTheory.Limits noncomputable section universe w v u namespace ModuleCat variable {R : Type u} [Ring R] {M N : ModuleCat.{v} R} (f : M ⟶ N) def normalMono (hf : Mono f) : NormalMono f where Z := of R (N ⧸ LinearMap.range f) g := f.range.mkQ w := LinearMap.range_mkQ_comp _ isLimit := IsKernel.isoKernel _ _ (kernelIsLimit _) (LinearEquiv.toModuleIso' ((Submodule.quotEquivOfEqBot _ (ker_eq_bot_of_mono _)).symm ≪≫ₗ (LinearMap.quotKerEquivRange f ≪≫ₗ LinearEquiv.ofEq _ _ (Submodule.ker_mkQ _).symm))) <| by ext; rfl set_option linter.uppercaseLean3 false in #align Module.normal_mono ModuleCat.normalMono def normalEpi (hf : Epi f) : NormalEpi f where W := of R (LinearMap.ker f) g := (LinearMap.ker f).subtype w := LinearMap.comp_ker_subtype _ isColimit := IsCokernel.cokernelIso _ _ (cokernelIsColimit _) (LinearEquiv.toModuleIso' (Submodule.quotEquivOfEq _ _ (Submodule.range_subtype _) ≪≫ₗ LinearMap.quotKerEquivRange f ≪≫ₗ LinearEquiv.ofTop _ (range_eq_top_of_epi _))) <| by ext; rfl set_option linter.uppercaseLean3 false in #align Module.normal_epi ModuleCat.normalEpi instance abelian : Abelian (ModuleCat.{v} R) where has_cokernels := hasCokernels_moduleCat normalMonoOfMono := normalMono normalEpiOfEpi := normalEpi set_option linter.uppercaseLean3 false in #align Module.abelian ModuleCat.abelian variable {O : ModuleCat.{v} R} (g : N ⟶ O) open LinearMap attribute [local instance] Preadditive.hasEqualizers_of_hasKernels
Mathlib/Algebra/Category/ModuleCat/Abelian.lean
123
127
theorem exact_iff : Exact f g ↔ LinearMap.range f = LinearMap.ker g := by
rw [abelian.exact_iff' f g (kernelIsLimit _) (cokernelIsColimit _)] exact ⟨fun h => le_antisymm (range_le_ker_iff.2 h.1) (ker_le_range_iff.2 h.2), fun h => ⟨range_le_ker_iff.1 <| le_of_eq h, ker_le_range_iff.1 <| le_of_eq h.symm⟩⟩
import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.MvPolynomial.Rename import Mathlib.Algebra.MvPolynomial.Degrees import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" noncomputable section open Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp [f, g] rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp [f, g] rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section variable (S₁ S₂ S₃) def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum @[simp] theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C @[simp] theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X @[simp] theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv @[simps!] def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right @[simps!] def optionEquivLeft : MvPolynomial (Option S₁) R ≃ₐ[R] Polynomial (MvPolynomial S₁ R) := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim Polynomial.X fun s => Polynomial.C (X s)) (Polynomial.aevalTower (MvPolynomial.rename some) (X none)) (by ext : 2 <;> simp) (by ext i : 2; cases i <;> simp) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft lemma optionEquivLeft_X_some (x : S₁) : optionEquivLeft R S₁ (X (some x)) = Polynomial.C (X x) := by simp only [optionEquivLeft_apply, aeval_X] lemma optionEquivLeft_X_none : optionEquivLeft R S₁ (X none) = Polynomial.X := by simp only [optionEquivLeft_apply, aeval_X] lemma optionEquivLeft_C (r : R) : optionEquivLeft R S₁ (C r) = Polynomial.C (C r) := by simp only [optionEquivLeft_apply, aeval_C, Polynomial.algebraMap_apply, algebraMap_eq] end @[simps!] def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight lemma optionEquivRight_X_some (x : S₁) : optionEquivRight R S₁ (X (some x)) = X x := by simp only [optionEquivRight_apply, aeval_X] lemma optionEquivRight_X_none : optionEquivRight R S₁ (X none) = C Polynomial.X := by simp only [optionEquivRight_apply, aeval_X] lemma optionEquivRight_C (r : R) : optionEquivRight R S₁ (C r) = C (Polynomial.C r) := by simp only [optionEquivRight_apply, aeval_C, algebraMap_apply, Polynomial.algebraMap_eq] variable (n : ℕ) def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine Fin.cases ?_ ?_ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine RingHom.ext fun x => ?_ rw [RingHom.comp_apply] refine (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) ?_) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero
Mathlib/Algebra/MvPolynomial/Equiv.lean
377
378
theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by
simp
import Mathlib.Analysis.SpecialFunctions.Integrals import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar import Mathlib.MeasureTheory.Integral.Layercake #align_import analysis.special_functions.japanese_bracket from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" noncomputable section open scoped NNReal Filter Topology ENNReal open Asymptotics Filter Set Real MeasureTheory FiniteDimensional variable {E : Type*} [NormedAddCommGroup E] theorem sqrt_one_add_norm_sq_le (x : E) : √((1 : ℝ) + ‖x‖ ^ 2) ≤ 1 + ‖x‖ := by rw [sqrt_le_left (by positivity)] simp [add_sq] #align sqrt_one_add_norm_sq_le sqrt_one_add_norm_sq_le theorem one_add_norm_le_sqrt_two_mul_sqrt (x : E) : (1 : ℝ) + ‖x‖ ≤ √2 * √(1 + ‖x‖ ^ 2) := by rw [← sqrt_mul zero_le_two] have := sq_nonneg (‖x‖ - 1) apply le_sqrt_of_sq_le linarith #align one_add_norm_le_sqrt_two_mul_sqrt one_add_norm_le_sqrt_two_mul_sqrt theorem rpow_neg_one_add_norm_sq_le {r : ℝ} (x : E) (hr : 0 < r) : ((1 : ℝ) + ‖x‖ ^ 2) ^ (-r / 2) ≤ (2 : ℝ) ^ (r / 2) * (1 + ‖x‖) ^ (-r) := calc ((1 : ℝ) + ‖x‖ ^ 2) ^ (-r / 2) = (2 : ℝ) ^ (r / 2) * ((√2 * √((1 : ℝ) + ‖x‖ ^ 2)) ^ r)⁻¹ := by rw [rpow_div_two_eq_sqrt, rpow_div_two_eq_sqrt, mul_rpow, mul_inv, rpow_neg, mul_inv_cancel_left₀] <;> positivity _ ≤ (2 : ℝ) ^ (r / 2) * ((1 + ‖x‖) ^ r)⁻¹ := by gcongr apply one_add_norm_le_sqrt_two_mul_sqrt _ = (2 : ℝ) ^ (r / 2) * (1 + ‖x‖) ^ (-r) := by rw [rpow_neg]; positivity #align rpow_neg_one_add_norm_sq_le rpow_neg_one_add_norm_sq_le
Mathlib/Analysis/SpecialFunctions/JapaneseBracket.lean
62
65
theorem le_rpow_one_add_norm_iff_norm_le {r t : ℝ} (hr : 0 < r) (ht : 0 < t) (x : E) : t ≤ (1 + ‖x‖) ^ (-r) ↔ ‖x‖ ≤ t ^ (-r⁻¹) - 1 := by
rw [le_sub_iff_add_le', neg_inv] exact (Real.le_rpow_inv_iff_of_neg (by positivity) ht (neg_lt_zero.mpr hr)).symm
import Mathlib.RingTheory.Polynomial.Cyclotomic.Roots import Mathlib.Tactic.ByContra import Mathlib.Topology.Algebra.Polynomial import Mathlib.NumberTheory.Padics.PadicVal import Mathlib.Analysis.Complex.Arg #align_import ring_theory.polynomial.cyclotomic.eval from "leanprover-community/mathlib"@"5bfbcca0a7ffdd21cf1682e59106d6c942434a32" namespace Polynomial open Finset Nat @[simp] theorem eval_one_cyclotomic_prime {R : Type*} [CommRing R] {p : ℕ} [hn : Fact p.Prime] : eval 1 (cyclotomic p R) = p := by simp only [cyclotomic_prime, eval_X, one_pow, Finset.sum_const, eval_pow, eval_finset_sum, Finset.card_range, smul_one_eq_cast] #align polynomial.eval_one_cyclotomic_prime Polynomial.eval_one_cyclotomic_prime -- @[simp] -- Porting note (#10618): simp already proves this
Mathlib/RingTheory/Polynomial/Cyclotomic/Eval.lean
36
37
theorem eval₂_one_cyclotomic_prime {R S : Type*} [CommRing R] [Semiring S] (f : R →+* S) {p : ℕ} [Fact p.Prime] : eval₂ f 1 (cyclotomic p R) = p := by
simp
import Mathlib.Analysis.SpecialFunctions.Pow.Complex import Qq #align_import analysis.special_functions.pow.real from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" noncomputable section open scoped Classical open Real ComplexConjugate open Finset Set namespace Real variable {x y z : ℝ} noncomputable def rpow (x y : ℝ) := ((x : ℂ) ^ (y : ℂ)).re #align real.rpow Real.rpow noncomputable instance : Pow ℝ ℝ := ⟨rpow⟩ @[simp] theorem rpow_eq_pow (x y : ℝ) : rpow x y = x ^ y := rfl #align real.rpow_eq_pow Real.rpow_eq_pow theorem rpow_def (x y : ℝ) : x ^ y = ((x : ℂ) ^ (y : ℂ)).re := rfl #align real.rpow_def Real.rpow_def theorem rpow_def_of_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) := by simp only [rpow_def, Complex.cpow_def]; split_ifs <;> simp_all [(Complex.ofReal_log hx).symm, -Complex.ofReal_mul, -RCLike.ofReal_mul, (Complex.ofReal_mul _ _).symm, Complex.exp_ofReal_re, Complex.ofReal_eq_zero] #align real.rpow_def_of_nonneg Real.rpow_def_of_nonneg theorem rpow_def_of_pos {x : ℝ} (hx : 0 < x) (y : ℝ) : x ^ y = exp (log x * y) := by rw [rpow_def_of_nonneg (le_of_lt hx), if_neg (ne_of_gt hx)] #align real.rpow_def_of_pos Real.rpow_def_of_pos theorem exp_mul (x y : ℝ) : exp (x * y) = exp x ^ y := by rw [rpow_def_of_pos (exp_pos _), log_exp] #align real.exp_mul Real.exp_mul @[simp, norm_cast] theorem rpow_intCast (x : ℝ) (n : ℤ) : x ^ (n : ℝ) = x ^ n := by simp only [rpow_def, ← Complex.ofReal_zpow, Complex.cpow_intCast, Complex.ofReal_intCast, Complex.ofReal_re] #align real.rpow_int_cast Real.rpow_intCast @[deprecated (since := "2024-04-17")] alias rpow_int_cast := rpow_intCast @[simp, norm_cast] theorem rpow_natCast (x : ℝ) (n : ℕ) : x ^ (n : ℝ) = x ^ n := by simpa using rpow_intCast x n #align real.rpow_nat_cast Real.rpow_natCast @[deprecated (since := "2024-04-17")] alias rpow_nat_cast := rpow_natCast @[simp] theorem exp_one_rpow (x : ℝ) : exp 1 ^ x = exp x := by rw [← exp_mul, one_mul] #align real.exp_one_rpow Real.exp_one_rpow @[simp] lemma exp_one_pow (n : ℕ) : exp 1 ^ n = exp n := by rw [← rpow_natCast, exp_one_rpow] theorem rpow_eq_zero_iff_of_nonneg (hx : 0 ≤ x) : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by simp only [rpow_def_of_nonneg hx] split_ifs <;> simp [*, exp_ne_zero] #align real.rpow_eq_zero_iff_of_nonneg Real.rpow_eq_zero_iff_of_nonneg @[simp] lemma rpow_eq_zero (hx : 0 ≤ x) (hy : y ≠ 0) : x ^ y = 0 ↔ x = 0 := by simp [rpow_eq_zero_iff_of_nonneg, *] @[simp] lemma rpow_ne_zero (hx : 0 ≤ x) (hy : y ≠ 0) : x ^ y ≠ 0 ↔ x ≠ 0 := Real.rpow_eq_zero hx hy |>.not open Real theorem rpow_def_of_neg {x : ℝ} (hx : x < 0) (y : ℝ) : x ^ y = exp (log x * y) * cos (y * π) := by rw [rpow_def, Complex.cpow_def, if_neg] · have : Complex.log x * y = ↑(log (-x) * y) + ↑(y * π) * Complex.I := by simp only [Complex.log, abs_of_neg hx, Complex.arg_ofReal_of_neg hx, Complex.abs_ofReal, Complex.ofReal_mul] ring rw [this, Complex.exp_add_mul_I, ← Complex.ofReal_exp, ← Complex.ofReal_cos, ← Complex.ofReal_sin, mul_add, ← Complex.ofReal_mul, ← mul_assoc, ← Complex.ofReal_mul, Complex.add_re, Complex.ofReal_re, Complex.mul_re, Complex.I_re, Complex.ofReal_im, Real.log_neg_eq_log] ring · rw [Complex.ofReal_eq_zero] exact ne_of_lt hx #align real.rpow_def_of_neg Real.rpow_def_of_neg theorem rpow_def_of_nonpos {x : ℝ} (hx : x ≤ 0) (y : ℝ) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) * cos (y * π) := by split_ifs with h <;> simp [rpow_def, *]; exact rpow_def_of_neg (lt_of_le_of_ne hx h) _ #align real.rpow_def_of_nonpos Real.rpow_def_of_nonpos theorem rpow_pos_of_pos {x : ℝ} (hx : 0 < x) (y : ℝ) : 0 < x ^ y := by rw [rpow_def_of_pos hx]; apply exp_pos #align real.rpow_pos_of_pos Real.rpow_pos_of_pos @[simp]
Mathlib/Analysis/SpecialFunctions/Pow/Real.lean
125
125
theorem rpow_zero (x : ℝ) : x ^ (0 : ℝ) = 1 := by
simp [rpow_def]
import Mathlib.Dynamics.Ergodic.AddCircle import Mathlib.MeasureTheory.Covering.LiminfLimsup #align_import number_theory.well_approximable from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" open Set Filter Function Metric MeasureTheory open scoped MeasureTheory Topology Pointwise @[to_additive "In a seminormed additive group `A`, given `n : ℕ` and `δ : ℝ`, `approxAddOrderOf A n δ` is the set of elements within a distance `δ` of a point of order `n`."] def approxOrderOf (A : Type*) [SeminormedGroup A] (n : ℕ) (δ : ℝ) : Set A := thickening δ {y | orderOf y = n} #align approx_order_of approxOrderOf #align approx_add_order_of approxAddOrderOf @[to_additive mem_approx_add_orderOf_iff] theorem mem_approxOrderOf_iff {A : Type*} [SeminormedGroup A] {n : ℕ} {δ : ℝ} {a : A} : a ∈ approxOrderOf A n δ ↔ ∃ b : A, orderOf b = n ∧ a ∈ ball b δ := by simp only [approxOrderOf, thickening_eq_biUnion_ball, mem_iUnion₂, mem_setOf_eq, exists_prop] #align mem_approx_order_of_iff mem_approxOrderOf_iff #align mem_approx_add_order_of_iff mem_approx_add_orderOf_iff @[to_additive addWellApproximable "In a seminormed additive group `A`, given a sequence of distances `δ₁, δ₂, ...`, `addWellApproximable A δ` is the limsup as `n → ∞` of the sets `approxAddOrderOf A n δₙ`. Thus, it is the set of points that lie in infinitely many of the sets `approxAddOrderOf A n δₙ`."] def wellApproximable (A : Type*) [SeminormedGroup A] (δ : ℕ → ℝ) : Set A := blimsup (fun n => approxOrderOf A n (δ n)) atTop fun n => 0 < n #align well_approximable wellApproximable #align add_well_approximable addWellApproximable @[to_additive mem_add_wellApproximable_iff] theorem mem_wellApproximable_iff {A : Type*} [SeminormedGroup A] {δ : ℕ → ℝ} {a : A} : a ∈ wellApproximable A δ ↔ a ∈ blimsup (fun n => approxOrderOf A n (δ n)) atTop fun n => 0 < n := Iff.rfl #align mem_well_approximable_iff mem_wellApproximable_iff #align mem_add_well_approximable_iff mem_add_wellApproximable_iff namespace approxOrderOf variable {A : Type*} [SeminormedCommGroup A] {a : A} {m n : ℕ} (δ : ℝ) @[to_additive] theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.Coprime m) : (fun (y : A) => y ^ m) '' approxOrderOf A n δ ⊆ approxOrderOf A n (m * δ) := by rintro - ⟨a, ha, rfl⟩ obtain ⟨b, hb, hab⟩ := mem_approxOrderOf_iff.mp ha replace hb : b ^ m ∈ {u : A | orderOf u = n} := by rw [← hb] at hmn ⊢; exact hmn.orderOf_pow apply ball_subset_thickening hb ((m : ℝ) • δ) convert pow_mem_ball hm hab using 1 simp only [nsmul_eq_mul, Algebra.id.smul_eq_mul] #align approx_order_of.image_pow_subset_of_coprime approxOrderOf.image_pow_subset_of_coprime #align approx_add_order_of.image_nsmul_subset_of_coprime approxAddOrderOf.image_nsmul_subset_of_coprime @[to_additive] theorem image_pow_subset (n : ℕ) (hm : 0 < m) : (fun (y : A) => y ^ m) '' approxOrderOf A (n * m) δ ⊆ approxOrderOf A n (m * δ) := by rintro - ⟨a, ha, rfl⟩ obtain ⟨b, hb : orderOf b = n * m, hab : a ∈ ball b δ⟩ := mem_approxOrderOf_iff.mp ha replace hb : b ^ m ∈ {y : A | orderOf y = n} := by rw [mem_setOf_eq, orderOf_pow' b hm.ne', hb, Nat.gcd_mul_left_left, n.mul_div_cancel hm] apply ball_subset_thickening hb (m * δ) convert pow_mem_ball hm hab using 1 simp only [nsmul_eq_mul] #align approx_order_of.image_pow_subset approxOrderOf.image_pow_subset #align approx_add_order_of.image_nsmul_subset approxAddOrderOf.image_nsmul_subset @[to_additive] theorem smul_subset_of_coprime (han : (orderOf a).Coprime n) : a • approxOrderOf A n δ ⊆ approxOrderOf A (orderOf a * n) δ := by simp_rw [approxOrderOf, thickening_eq_biUnion_ball, ← image_smul, image_iUnion₂, image_smul, smul_ball'', smul_eq_mul, mem_setOf_eq] refine iUnion₂_subset_iff.mpr fun b hb c hc => ?_ simp only [mem_iUnion, exists_prop] refine ⟨a * b, ?_, hc⟩ rw [← hb] at han ⊢ exact (Commute.all a b).orderOf_mul_eq_mul_orderOf_of_coprime han #align approx_order_of.smul_subset_of_coprime approxOrderOf.smul_subset_of_coprime #align approx_add_order_of.vadd_subset_of_coprime approxAddOrderOf.vadd_subset_of_coprime @[to_additive vadd_eq_of_mul_dvd]
Mathlib/NumberTheory/WellApproximable.lean
147
166
theorem smul_eq_of_mul_dvd (hn : 0 < n) (han : orderOf a ^ 2 ∣ n) : a • approxOrderOf A n δ = approxOrderOf A n δ := by
simp_rw [approxOrderOf, thickening_eq_biUnion_ball, ← image_smul, image_iUnion₂, image_smul, smul_ball'', smul_eq_mul, mem_setOf_eq] replace han : ∀ {b : A}, orderOf b = n → orderOf (a * b) = n := by intro b hb rw [← hb] at han hn rw [sq] at han rwa [(Commute.all a b).orderOf_mul_eq_right_of_forall_prime_mul_dvd (orderOf_pos_iff.mp hn) fun p _ hp' => dvd_trans (mul_dvd_mul_right hp' <| orderOf a) han] let f : {b : A | orderOf b = n} → {b : A | orderOf b = n} := fun b => ⟨a * b, han b.property⟩ have hf : Surjective f := by rintro ⟨b, hb⟩ refine ⟨⟨a⁻¹ * b, ?_⟩, ?_⟩ · rw [mem_setOf_eq, ← orderOf_inv, mul_inv_rev, inv_inv, mul_comm] apply han simpa · simp only [f, Subtype.mk_eq_mk, Subtype.coe_mk, mul_inv_cancel_left] simpa only [mem_setOf_eq, Subtype.coe_mk, iUnion_coe_set] using hf.iUnion_comp fun b => ball (b : A) δ
import Mathlib.Data.Fin.VecNotation import Mathlib.Logic.Embedding.Set #align_import logic.equiv.fin from "leanprover-community/mathlib"@"bd835ef554f37ef9b804f0903089211f89cb370b" assert_not_exists MonoidWithZero universe u variable {m n : ℕ} def finZeroEquiv : Fin 0 ≃ Empty := Equiv.equivEmpty _ #align fin_zero_equiv finZeroEquiv def finZeroEquiv' : Fin 0 ≃ PEmpty.{u} := Equiv.equivPEmpty _ #align fin_zero_equiv' finZeroEquiv' def finOneEquiv : Fin 1 ≃ Unit := Equiv.equivPUnit _ #align fin_one_equiv finOneEquiv def finTwoEquiv : Fin 2 ≃ Bool where toFun := ![false, true] invFun b := b.casesOn 0 1 left_inv := Fin.forall_fin_two.2 <| by simp right_inv := Bool.forall_bool.2 <| by simp #align fin_two_equiv finTwoEquiv @[simps (config := .asFn)] def piFinTwoEquiv (α : Fin 2 → Type u) : (∀ i, α i) ≃ α 0 × α 1 where toFun f := (f 0, f 1) invFun p := Fin.cons p.1 <| Fin.cons p.2 finZeroElim left_inv _ := funext <| Fin.forall_fin_two.2 ⟨rfl, rfl⟩ right_inv := fun _ => rfl #align pi_fin_two_equiv piFinTwoEquiv #align pi_fin_two_equiv_symm_apply piFinTwoEquiv_symm_apply #align pi_fin_two_equiv_apply piFinTwoEquiv_apply theorem Fin.preimage_apply_01_prod {α : Fin 2 → Type u} (s : Set (α 0)) (t : Set (α 1)) : (fun f : ∀ i, α i => (f 0, f 1)) ⁻¹' s ×ˢ t = Set.pi Set.univ (Fin.cons s <| Fin.cons t finZeroElim) := by ext f simp [Fin.forall_fin_two] #align fin.preimage_apply_01_prod Fin.preimage_apply_01_prod theorem Fin.preimage_apply_01_prod' {α : Type u} (s t : Set α) : (fun f : Fin 2 → α => (f 0, f 1)) ⁻¹' s ×ˢ t = Set.pi Set.univ ![s, t] := @Fin.preimage_apply_01_prod (fun _ => α) s t #align fin.preimage_apply_01_prod' Fin.preimage_apply_01_prod' @[simps! (config := .asFn)] def prodEquivPiFinTwo (α β : Type u) : α × β ≃ ∀ i : Fin 2, ![α, β] i := (piFinTwoEquiv (Fin.cons α (Fin.cons β finZeroElim))).symm #align prod_equiv_pi_fin_two prodEquivPiFinTwo #align prod_equiv_pi_fin_two_apply prodEquivPiFinTwo_apply #align prod_equiv_pi_fin_two_symm_apply prodEquivPiFinTwo_symm_apply @[simps (config := .asFn)] def finTwoArrowEquiv (α : Type*) : (Fin 2 → α) ≃ α × α := { piFinTwoEquiv fun _ => α with invFun := fun x => ![x.1, x.2] } #align fin_two_arrow_equiv finTwoArrowEquiv #align fin_two_arrow_equiv_symm_apply finTwoArrowEquiv_symm_apply #align fin_two_arrow_equiv_apply finTwoArrowEquiv_apply def OrderIso.piFinTwoIso (α : Fin 2 → Type u) [∀ i, Preorder (α i)] : (∀ i, α i) ≃o α 0 × α 1 where toEquiv := piFinTwoEquiv α map_rel_iff' := Iff.symm Fin.forall_fin_two #align order_iso.pi_fin_two_iso OrderIso.piFinTwoIso def OrderIso.finTwoArrowIso (α : Type*) [Preorder α] : (Fin 2 → α) ≃o α × α := { OrderIso.piFinTwoIso fun _ => α with toEquiv := finTwoArrowEquiv α } #align order_iso.fin_two_arrow_iso OrderIso.finTwoArrowIso def finSuccEquiv' (i : Fin (n + 1)) : Fin (n + 1) ≃ Option (Fin n) where toFun := i.insertNth none some invFun x := x.casesOn' i (Fin.succAbove i) left_inv x := Fin.succAboveCases i (by simp) (fun j => by simp) x right_inv x := by cases x <;> dsimp <;> simp #align fin_succ_equiv' finSuccEquiv' @[simp] theorem finSuccEquiv'_at (i : Fin (n + 1)) : (finSuccEquiv' i) i = none := by simp [finSuccEquiv'] #align fin_succ_equiv'_at finSuccEquiv'_at @[simp] theorem finSuccEquiv'_succAbove (i : Fin (n + 1)) (j : Fin n) : finSuccEquiv' i (i.succAbove j) = some j := @Fin.insertNth_apply_succAbove n (fun _ => Option (Fin n)) i _ _ _ #align fin_succ_equiv'_succ_above finSuccEquiv'_succAbove theorem finSuccEquiv'_below {i : Fin (n + 1)} {m : Fin n} (h : Fin.castSucc m < i) : (finSuccEquiv' i) (Fin.castSucc m) = m := by rw [← Fin.succAbove_of_castSucc_lt _ _ h, finSuccEquiv'_succAbove] #align fin_succ_equiv'_below finSuccEquiv'_below theorem finSuccEquiv'_above {i : Fin (n + 1)} {m : Fin n} (h : i ≤ Fin.castSucc m) : (finSuccEquiv' i) m.succ = some m := by rw [← Fin.succAbove_of_le_castSucc _ _ h, finSuccEquiv'_succAbove] #align fin_succ_equiv'_above finSuccEquiv'_above @[simp] theorem finSuccEquiv'_symm_none (i : Fin (n + 1)) : (finSuccEquiv' i).symm none = i := rfl #align fin_succ_equiv'_symm_none finSuccEquiv'_symm_none @[simp] theorem finSuccEquiv'_symm_some (i : Fin (n + 1)) (j : Fin n) : (finSuccEquiv' i).symm (some j) = i.succAbove j := rfl #align fin_succ_equiv'_symm_some finSuccEquiv'_symm_some theorem finSuccEquiv'_symm_some_below {i : Fin (n + 1)} {m : Fin n} (h : Fin.castSucc m < i) : (finSuccEquiv' i).symm (some m) = Fin.castSucc m := Fin.succAbove_of_castSucc_lt i m h #align fin_succ_equiv'_symm_some_below finSuccEquiv'_symm_some_below theorem finSuccEquiv'_symm_some_above {i : Fin (n + 1)} {m : Fin n} (h : i ≤ Fin.castSucc m) : (finSuccEquiv' i).symm (some m) = m.succ := Fin.succAbove_of_le_castSucc i m h #align fin_succ_equiv'_symm_some_above finSuccEquiv'_symm_some_above theorem finSuccEquiv'_symm_coe_below {i : Fin (n + 1)} {m : Fin n} (h : Fin.castSucc m < i) : (finSuccEquiv' i).symm m = Fin.castSucc m := finSuccEquiv'_symm_some_below h #align fin_succ_equiv'_symm_coe_below finSuccEquiv'_symm_coe_below theorem finSuccEquiv'_symm_coe_above {i : Fin (n + 1)} {m : Fin n} (h : i ≤ Fin.castSucc m) : (finSuccEquiv' i).symm m = m.succ := finSuccEquiv'_symm_some_above h #align fin_succ_equiv'_symm_coe_above finSuccEquiv'_symm_coe_above def finSuccEquiv (n : ℕ) : Fin (n + 1) ≃ Option (Fin n) := finSuccEquiv' 0 #align fin_succ_equiv finSuccEquiv @[simp] theorem finSuccEquiv_zero : (finSuccEquiv n) 0 = none := rfl #align fin_succ_equiv_zero finSuccEquiv_zero @[simp] theorem finSuccEquiv_succ (m : Fin n) : (finSuccEquiv n) m.succ = some m := finSuccEquiv'_above (Fin.zero_le _) #align fin_succ_equiv_succ finSuccEquiv_succ @[simp] theorem finSuccEquiv_symm_none : (finSuccEquiv n).symm none = 0 := finSuccEquiv'_symm_none _ #align fin_succ_equiv_symm_none finSuccEquiv_symm_none @[simp] theorem finSuccEquiv_symm_some (m : Fin n) : (finSuccEquiv n).symm (some m) = m.succ := congr_fun Fin.succAbove_zero m #align fin_succ_equiv_symm_some finSuccEquiv_symm_some #align fin_succ_equiv_symm_coe finSuccEquiv_symm_some theorem finSuccEquiv'_zero : finSuccEquiv' (0 : Fin (n + 1)) = finSuccEquiv n := rfl #align fin_succ_equiv'_zero finSuccEquiv'_zero theorem finSuccEquiv'_last_apply_castSucc (i : Fin n) : finSuccEquiv' (Fin.last n) (Fin.castSucc i) = i := by rw [← Fin.succAbove_last, finSuccEquiv'_succAbove] theorem finSuccEquiv'_last_apply {i : Fin (n + 1)} (h : i ≠ Fin.last n) : finSuccEquiv' (Fin.last n) i = Fin.castLT i (Fin.val_lt_last h) := by rcases Fin.exists_castSucc_eq.2 h with ⟨i, rfl⟩ rw [finSuccEquiv'_last_apply_castSucc] rfl #align fin_succ_equiv'_last_apply finSuccEquiv'_last_apply theorem finSuccEquiv'_ne_last_apply {i j : Fin (n + 1)} (hi : i ≠ Fin.last n) (hj : j ≠ i) : finSuccEquiv' i j = (i.castLT (Fin.val_lt_last hi)).predAbove j := by rcases Fin.exists_succAbove_eq hj with ⟨j, rfl⟩ rcases Fin.exists_castSucc_eq.2 hi with ⟨i, rfl⟩ simp #align fin_succ_equiv'_ne_last_apply finSuccEquiv'_ne_last_apply def finSuccAboveEquiv (p : Fin (n + 1)) : Fin n ≃o { x : Fin (n + 1) // x ≠ p } := { Equiv.optionSubtype p ⟨(finSuccEquiv' p).symm, rfl⟩ with map_rel_iff' := p.succAboveOrderEmb.map_rel_iff' } #align fin_succ_above_equiv finSuccAboveEquiv theorem finSuccAboveEquiv_apply (p : Fin (n + 1)) (i : Fin n) : finSuccAboveEquiv p i = ⟨p.succAbove i, p.succAbove_ne i⟩ := rfl #align fin_succ_above_equiv_apply finSuccAboveEquiv_apply theorem finSuccAboveEquiv_symm_apply_last (x : { x : Fin (n + 1) // x ≠ Fin.last n }) : (finSuccAboveEquiv (Fin.last n)).symm x = Fin.castLT x.1 (Fin.val_lt_last x.2) := by rw [← Option.some_inj] simpa [finSuccAboveEquiv, OrderIso.symm] using finSuccEquiv'_last_apply x.property #align fin_succ_above_equiv_symm_apply_last finSuccAboveEquiv_symm_apply_last theorem finSuccAboveEquiv_symm_apply_ne_last {p : Fin (n + 1)} (h : p ≠ Fin.last n) (x : { x : Fin (n + 1) // x ≠ p }) : (finSuccAboveEquiv p).symm x = (p.castLT (Fin.val_lt_last h)).predAbove x := by rw [← Option.some_inj] simpa [finSuccAboveEquiv, OrderIso.symm] using finSuccEquiv'_ne_last_apply h x.property #align fin_succ_above_equiv_symm_apply_ne_last finSuccAboveEquiv_symm_apply_ne_last def finSuccEquivLast : Fin (n + 1) ≃ Option (Fin n) := finSuccEquiv' (Fin.last n) #align fin_succ_equiv_last finSuccEquivLast @[simp] theorem finSuccEquivLast_castSucc (i : Fin n) : finSuccEquivLast (Fin.castSucc i) = some i := finSuccEquiv'_below i.2 #align fin_succ_equiv_last_cast_succ finSuccEquivLast_castSucc @[simp] theorem finSuccEquivLast_last : finSuccEquivLast (Fin.last n) = none := by simp [finSuccEquivLast] #align fin_succ_equiv_last_last finSuccEquivLast_last @[simp] theorem finSuccEquivLast_symm_some (i : Fin n) : finSuccEquivLast.symm (some i) = Fin.castSucc i := finSuccEquiv'_symm_some_below i.2 #align fin_succ_equiv_last_symm_some finSuccEquivLast_symm_some #align fin_succ_equiv_last_symm_coe finSuccEquivLast_symm_some @[simp] theorem finSuccEquivLast_symm_none : finSuccEquivLast.symm none = Fin.last n := finSuccEquiv'_symm_none _ #align fin_succ_equiv_last_symm_none finSuccEquivLast_symm_none @[simps (config := .asFn)] def Equiv.piFinSuccAbove (α : Fin (n + 1) → Type u) (i : Fin (n + 1)) : (∀ j, α j) ≃ α i × ∀ j, α (i.succAbove j) where toFun f := i.extractNth f invFun f := i.insertNth f.1 f.2 left_inv f := by simp right_inv f := by simp #align equiv.pi_fin_succ_above_equiv Equiv.piFinSuccAbove #align equiv.pi_fin_succ_above_equiv_apply Equiv.piFinSuccAbove_apply #align equiv.pi_fin_succ_above_equiv_symm_apply Equiv.piFinSuccAbove_symm_apply def OrderIso.piFinSuccAboveIso (α : Fin (n + 1) → Type u) [∀ i, LE (α i)] (i : Fin (n + 1)) : (∀ j, α j) ≃o α i × ∀ j, α (i.succAbove j) where toEquiv := Equiv.piFinSuccAbove α i map_rel_iff' := Iff.symm i.forall_iff_succAbove #align order_iso.pi_fin_succ_above_iso OrderIso.piFinSuccAboveIso @[simps! (config := .asFn)] def Equiv.piFinSucc (n : ℕ) (β : Type u) : (Fin (n + 1) → β) ≃ β × (Fin n → β) := Equiv.piFinSuccAbove (fun _ => β) 0 #align equiv.pi_fin_succ Equiv.piFinSucc #align equiv.pi_fin_succ_apply Equiv.piFinSucc_apply #align equiv.pi_fin_succ_symm_apply Equiv.piFinSucc_symm_apply def Equiv.embeddingFinSucc (n : ℕ) (ι : Type*) : (Fin (n+1) ↪ ι) ≃ (Σ (e : Fin n ↪ ι), {i // i ∉ Set.range e}) := ((finSuccEquiv n).embeddingCongr (Equiv.refl ι)).trans (Function.Embedding.optionEmbeddingEquiv (Fin n) ι) @[simp] lemma Equiv.embeddingFinSucc_fst {n : ℕ} {ι : Type*} (e : Fin (n+1) ↪ ι) : ((Equiv.embeddingFinSucc n ι e).1 : Fin n → ι) = e ∘ Fin.succ := rfl @[simp] lemma Equiv.embeddingFinSucc_snd {n : ℕ} {ι : Type*} (e : Fin (n+1) ↪ ι) : ((Equiv.embeddingFinSucc n ι e).2 : ι) = e 0 := rfl @[simp] lemma Equiv.coe_embeddingFinSucc_symm {n : ℕ} {ι : Type*} (f : Σ (e : Fin n ↪ ι), {i // i ∉ Set.range e}) : ((Equiv.embeddingFinSucc n ι).symm f : Fin (n + 1) → ι) = Fin.cons f.2.1 f.1 := by ext i exact Fin.cases rfl (fun j ↦ rfl) i @[simps! (config := .asFn)] def Equiv.piFinCastSucc (n : ℕ) (β : Type u) : (Fin (n + 1) → β) ≃ β × (Fin n → β) := Equiv.piFinSuccAbove (fun _ => β) (.last _) def finSumFinEquiv : Sum (Fin m) (Fin n) ≃ Fin (m + n) where toFun := Sum.elim (Fin.castAdd n) (Fin.natAdd m) invFun i := @Fin.addCases m n (fun _ => Sum (Fin m) (Fin n)) Sum.inl Sum.inr i left_inv x := by cases' x with y y <;> dsimp <;> simp right_inv x := by refine Fin.addCases (fun i => ?_) (fun i => ?_) x <;> simp #align fin_sum_fin_equiv finSumFinEquiv @[simp] theorem finSumFinEquiv_apply_left (i : Fin m) : (finSumFinEquiv (Sum.inl i) : Fin (m + n)) = Fin.castAdd n i := rfl #align fin_sum_fin_equiv_apply_left finSumFinEquiv_apply_left @[simp] theorem finSumFinEquiv_apply_right (i : Fin n) : (finSumFinEquiv (Sum.inr i) : Fin (m + n)) = Fin.natAdd m i := rfl #align fin_sum_fin_equiv_apply_right finSumFinEquiv_apply_right @[simp] theorem finSumFinEquiv_symm_apply_castAdd (x : Fin m) : finSumFinEquiv.symm (Fin.castAdd n x) = Sum.inl x := finSumFinEquiv.symm_apply_apply (Sum.inl x) #align fin_sum_fin_equiv_symm_apply_cast_add finSumFinEquiv_symm_apply_castAdd @[simp] theorem finSumFinEquiv_symm_apply_natAdd (x : Fin n) : finSumFinEquiv.symm (Fin.natAdd m x) = Sum.inr x := finSumFinEquiv.symm_apply_apply (Sum.inr x) #align fin_sum_fin_equiv_symm_apply_nat_add finSumFinEquiv_symm_apply_natAdd @[simp] theorem finSumFinEquiv_symm_last : finSumFinEquiv.symm (Fin.last n) = Sum.inr 0 := finSumFinEquiv_symm_apply_natAdd 0 #align fin_sum_fin_equiv_symm_last finSumFinEquiv_symm_last def finAddFlip : Fin (m + n) ≃ Fin (n + m) := (finSumFinEquiv.symm.trans (Equiv.sumComm _ _)).trans finSumFinEquiv #align fin_add_flip finAddFlip @[simp] theorem finAddFlip_apply_castAdd (k : Fin m) (n : ℕ) : finAddFlip (Fin.castAdd n k) = Fin.natAdd n k := by simp [finAddFlip] #align fin_add_flip_apply_cast_add finAddFlip_apply_castAdd @[simp] theorem finAddFlip_apply_natAdd (k : Fin n) (m : ℕ) : finAddFlip (Fin.natAdd m k) = Fin.castAdd m k := by simp [finAddFlip] #align fin_add_flip_apply_nat_add finAddFlip_apply_natAdd @[simp] theorem finAddFlip_apply_mk_left {k : ℕ} (h : k < m) (hk : k < m + n := Nat.lt_add_right n h) (hnk : n + k < n + m := Nat.add_lt_add_left h n) : finAddFlip (⟨k, hk⟩ : Fin (m + n)) = ⟨n + k, hnk⟩ := by convert finAddFlip_apply_castAdd ⟨k, h⟩ n #align fin_add_flip_apply_mk_left finAddFlip_apply_mk_left @[simp] theorem finAddFlip_apply_mk_right {k : ℕ} (h₁ : m ≤ k) (h₂ : k < m + n) : finAddFlip (⟨k, h₂⟩ : Fin (m + n)) = ⟨k - m, by omega⟩ := by convert @finAddFlip_apply_natAdd n ⟨k - m, by omega⟩ m simp [Nat.add_sub_cancel' h₁] #align fin_add_flip_apply_mk_right finAddFlip_apply_mk_right def finRotate : ∀ n, Equiv.Perm (Fin n) | 0 => Equiv.refl _ | n + 1 => finAddFlip.trans (finCongr (Nat.add_comm 1 n)) #align fin_rotate finRotate @[simp] lemma finRotate_zero : finRotate 0 = Equiv.refl _ := rfl #align fin_rotate_zero finRotate_zero lemma finRotate_succ (n : ℕ) : finRotate (n + 1) = finAddFlip.trans (finCongr (Nat.add_comm 1 n)) := rfl theorem finRotate_of_lt {k : ℕ} (h : k < n) : finRotate (n + 1) ⟨k, h.trans_le n.le_succ⟩ = ⟨k + 1, Nat.succ_lt_succ h⟩ := by ext dsimp [finRotate_succ] simp [finAddFlip_apply_mk_left h, Nat.add_comm] #align fin_rotate_of_lt finRotate_of_lt theorem finRotate_last' : finRotate (n + 1) ⟨n, by omega⟩ = ⟨0, Nat.zero_lt_succ _⟩ := by dsimp [finRotate_succ] rw [finAddFlip_apply_mk_right le_rfl] simp #align fin_rotate_last' finRotate_last' theorem finRotate_last : finRotate (n + 1) (Fin.last _) = 0 := finRotate_last' #align fin_rotate_last finRotate_last theorem Fin.snoc_eq_cons_rotate {α : Type*} (v : Fin n → α) (a : α) : @Fin.snoc _ (fun _ => α) v a = fun i => @Fin.cons _ (fun _ => α) a v (finRotate _ i) := by ext ⟨i, h⟩ by_cases h' : i < n · rw [finRotate_of_lt h', Fin.snoc, Fin.cons, dif_pos h'] rfl · have h'' : n = i := by simp only [not_lt] at h' exact (Nat.eq_of_le_of_lt_succ h' h).symm subst h'' rw [finRotate_last', Fin.snoc, Fin.cons, dif_neg (lt_irrefl _)] rfl #align fin.snoc_eq_cons_rotate Fin.snoc_eq_cons_rotate @[simp] theorem finRotate_one : finRotate 1 = Equiv.refl _ := Subsingleton.elim _ _ #align fin_rotate_one finRotate_one @[simp] theorem finRotate_succ_apply (i : Fin (n + 1)) : finRotate (n + 1) i = i + 1 := by cases n · exact @Subsingleton.elim (Fin 1) _ _ _ rcases i.le_last.eq_or_lt with (rfl | h) · simp [finRotate_last] · cases i simp only [Fin.lt_iff_val_lt_val, Fin.val_last, Fin.val_mk] at h simp [finRotate_of_lt h, Fin.ext_iff, Fin.add_def, Nat.mod_eq_of_lt (Nat.succ_lt_succ h)] #align fin_rotate_succ_apply finRotate_succ_apply -- Porting note: was a @[simp] theorem finRotate_apply_zero : finRotate n.succ 0 = 1 := by rw [finRotate_succ_apply, Fin.zero_add] #align fin_rotate_apply_zero finRotate_apply_zero theorem coe_finRotate_of_ne_last {i : Fin n.succ} (h : i ≠ Fin.last n) : (finRotate (n + 1) i : ℕ) = i + 1 := by rw [finRotate_succ_apply] have : (i : ℕ) < n := Fin.val_lt_last h exact Fin.val_add_one_of_lt this #align coe_fin_rotate_of_ne_last coe_finRotate_of_ne_last
Mathlib/Logic/Equiv/Fin.lean
452
454
theorem coe_finRotate (i : Fin n.succ) : (finRotate n.succ i : ℕ) = if i = Fin.last n then (0 : ℕ) else i + 1 := by
rw [finRotate_succ_apply, Fin.val_add_one i]
import Mathlib.Probability.Notation import Mathlib.Probability.Integration import Mathlib.MeasureTheory.Function.L2Space #align_import probability.variance from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" open MeasureTheory Filter Finset noncomputable section open scoped MeasureTheory ProbabilityTheory ENNReal NNReal namespace ProbabilityTheory -- Porting note: this lemma replaces `ENNReal.toReal_bit0`, which does not exist in Lean 4 private lemma coe_two : ENNReal.toReal 2 = (2 : ℝ) := rfl -- Porting note: Consider if `evariance` or `eVariance` is better. Also, -- consider `eVariationOn` in `Mathlib.Analysis.BoundedVariation`. def evariance {Ω : Type*} {_ : MeasurableSpace Ω} (X : Ω → ℝ) (μ : Measure Ω) : ℝ≥0∞ := ∫⁻ ω, (‖X ω - μ[X]‖₊ : ℝ≥0∞) ^ 2 ∂μ #align probability_theory.evariance ProbabilityTheory.evariance def variance {Ω : Type*} {_ : MeasurableSpace Ω} (X : Ω → ℝ) (μ : Measure Ω) : ℝ := (evariance X μ).toReal #align probability_theory.variance ProbabilityTheory.variance variable {Ω : Type*} {m : MeasurableSpace Ω} {X : Ω → ℝ} {μ : Measure Ω} theorem _root_.MeasureTheory.Memℒp.evariance_lt_top [IsFiniteMeasure μ] (hX : Memℒp X 2 μ) : evariance X μ < ∞ := by have := ENNReal.pow_lt_top (hX.sub <| memℒp_const <| μ[X]).2 2 rw [snorm_eq_lintegral_rpow_nnnorm two_ne_zero ENNReal.two_ne_top, ← ENNReal.rpow_two] at this simp only [coe_two, Pi.sub_apply, ENNReal.one_toReal, one_div] at this rw [← ENNReal.rpow_mul, inv_mul_cancel (two_ne_zero : (2 : ℝ) ≠ 0), ENNReal.rpow_one] at this simp_rw [ENNReal.rpow_two] at this exact this #align measure_theory.mem_ℒp.evariance_lt_top MeasureTheory.Memℒp.evariance_lt_top theorem evariance_eq_top [IsFiniteMeasure μ] (hXm : AEStronglyMeasurable X μ) (hX : ¬Memℒp X 2 μ) : evariance X μ = ∞ := by by_contra h rw [← Ne, ← lt_top_iff_ne_top] at h have : Memℒp (fun ω => X ω - μ[X]) 2 μ := by refine ⟨hXm.sub aestronglyMeasurable_const, ?_⟩ rw [snorm_eq_lintegral_rpow_nnnorm two_ne_zero ENNReal.two_ne_top] simp only [coe_two, ENNReal.one_toReal, ENNReal.rpow_two, Ne] exact ENNReal.rpow_lt_top_of_nonneg (by linarith) h.ne refine hX ?_ -- Porting note: `μ[X]` without whitespace is ambiguous as it could be GetElem, -- and `convert` cannot disambiguate based on typeclass inference failure. convert this.add (memℒp_const <| μ [X]) ext ω rw [Pi.add_apply, sub_add_cancel] #align probability_theory.evariance_eq_top ProbabilityTheory.evariance_eq_top theorem evariance_lt_top_iff_memℒp [IsFiniteMeasure μ] (hX : AEStronglyMeasurable X μ) : evariance X μ < ∞ ↔ Memℒp X 2 μ := by refine ⟨?_, MeasureTheory.Memℒp.evariance_lt_top⟩ contrapose rw [not_lt, top_le_iff] exact evariance_eq_top hX #align probability_theory.evariance_lt_top_iff_mem_ℒp ProbabilityTheory.evariance_lt_top_iff_memℒp theorem _root_.MeasureTheory.Memℒp.ofReal_variance_eq [IsFiniteMeasure μ] (hX : Memℒp X 2 μ) : ENNReal.ofReal (variance X μ) = evariance X μ := by rw [variance, ENNReal.ofReal_toReal] exact hX.evariance_lt_top.ne #align measure_theory.mem_ℒp.of_real_variance_eq MeasureTheory.Memℒp.ofReal_variance_eq theorem evariance_eq_lintegral_ofReal (X : Ω → ℝ) (μ : Measure Ω) : evariance X μ = ∫⁻ ω, ENNReal.ofReal ((X ω - μ[X]) ^ 2) ∂μ := by rw [evariance] congr ext1 ω rw [pow_two, ← ENNReal.coe_mul, ← nnnorm_mul, ← pow_two] congr exact (Real.toNNReal_eq_nnnorm_of_nonneg <| sq_nonneg _).symm #align probability_theory.evariance_eq_lintegral_of_real ProbabilityTheory.evariance_eq_lintegral_ofReal theorem _root_.MeasureTheory.Memℒp.variance_eq_of_integral_eq_zero (hX : Memℒp X 2 μ) (hXint : μ[X] = 0) : variance X μ = μ[X ^ (2 : Nat)] := by rw [variance, evariance_eq_lintegral_ofReal, ← ofReal_integral_eq_lintegral_ofReal, ENNReal.toReal_ofReal (by positivity)] <;> simp_rw [hXint, sub_zero] · rfl · convert hX.integrable_norm_rpow two_ne_zero ENNReal.two_ne_top with ω simp only [Pi.sub_apply, Real.norm_eq_abs, coe_two, ENNReal.one_toReal, Real.rpow_two, sq_abs, abs_pow] · exact ae_of_all _ fun ω => pow_two_nonneg _ #align measure_theory.mem_ℒp.variance_eq_of_integral_eq_zero MeasureTheory.Memℒp.variance_eq_of_integral_eq_zero theorem _root_.MeasureTheory.Memℒp.variance_eq [IsFiniteMeasure μ] (hX : Memℒp X 2 μ) : variance X μ = μ[(X - fun _ => μ[X] :) ^ (2 : Nat)] := by rw [variance, evariance_eq_lintegral_ofReal, ← ofReal_integral_eq_lintegral_ofReal, ENNReal.toReal_ofReal (by positivity)] · rfl · -- Porting note: `μ[X]` without whitespace is ambiguous as it could be GetElem, -- and `convert` cannot disambiguate based on typeclass inference failure. convert (hX.sub <| memℒp_const (μ [X])).integrable_norm_rpow two_ne_zero ENNReal.two_ne_top with ω simp only [Pi.sub_apply, Real.norm_eq_abs, coe_two, ENNReal.one_toReal, Real.rpow_two, sq_abs, abs_pow] · exact ae_of_all _ fun ω => pow_two_nonneg _ #align measure_theory.mem_ℒp.variance_eq MeasureTheory.Memℒp.variance_eq @[simp] theorem evariance_zero : evariance 0 μ = 0 := by simp [evariance] #align probability_theory.evariance_zero ProbabilityTheory.evariance_zero theorem evariance_eq_zero_iff (hX : AEMeasurable X μ) : evariance X μ = 0 ↔ X =ᵐ[μ] fun _ => μ[X] := by rw [evariance, lintegral_eq_zero_iff'] constructor <;> intro hX <;> filter_upwards [hX] with ω hω · simpa only [Pi.zero_apply, sq_eq_zero_iff, ENNReal.coe_eq_zero, nnnorm_eq_zero, sub_eq_zero] using hω · rw [hω] simp · exact (hX.sub_const _).ennnorm.pow_const _ -- TODO `measurability` and `fun_prop` fail #align probability_theory.evariance_eq_zero_iff ProbabilityTheory.evariance_eq_zero_iff theorem evariance_mul (c : ℝ) (X : Ω → ℝ) (μ : Measure Ω) : evariance (fun ω => c * X ω) μ = ENNReal.ofReal (c ^ 2) * evariance X μ := by rw [evariance, evariance, ← lintegral_const_mul' _ _ ENNReal.ofReal_lt_top.ne] congr ext1 ω rw [ENNReal.ofReal, ← ENNReal.coe_pow, ← ENNReal.coe_pow, ← ENNReal.coe_mul] congr rw [← sq_abs, ← Real.rpow_two, Real.toNNReal_rpow_of_nonneg (abs_nonneg _), NNReal.rpow_two, ← mul_pow, Real.toNNReal_mul_nnnorm _ (abs_nonneg _)] conv_rhs => rw [← nnnorm_norm, norm_mul, norm_abs_eq_norm, ← norm_mul, nnnorm_norm, mul_sub] congr rw [mul_comm] simp_rw [← smul_eq_mul, ← integral_smul_const, smul_eq_mul, mul_comm] #align probability_theory.evariance_mul ProbabilityTheory.evariance_mul scoped notation "eVar[" X "]" => ProbabilityTheory.evariance X MeasureTheory.MeasureSpace.volume @[simp] theorem variance_zero (μ : Measure Ω) : variance 0 μ = 0 := by simp only [variance, evariance_zero, ENNReal.zero_toReal] #align probability_theory.variance_zero ProbabilityTheory.variance_zero theorem variance_nonneg (X : Ω → ℝ) (μ : Measure Ω) : 0 ≤ variance X μ := ENNReal.toReal_nonneg #align probability_theory.variance_nonneg ProbabilityTheory.variance_nonneg theorem variance_mul (c : ℝ) (X : Ω → ℝ) (μ : Measure Ω) : variance (fun ω => c * X ω) μ = c ^ 2 * variance X μ := by rw [variance, evariance_mul, ENNReal.toReal_mul, ENNReal.toReal_ofReal (sq_nonneg _)] rfl #align probability_theory.variance_mul ProbabilityTheory.variance_mul theorem variance_smul (c : ℝ) (X : Ω → ℝ) (μ : Measure Ω) : variance (c • X) μ = c ^ 2 * variance X μ := variance_mul c X μ #align probability_theory.variance_smul ProbabilityTheory.variance_smul theorem variance_smul' {A : Type*} [CommSemiring A] [Algebra A ℝ] (c : A) (X : Ω → ℝ) (μ : Measure Ω) : variance (c • X) μ = c ^ 2 • variance X μ := by convert variance_smul (algebraMap A ℝ c) X μ using 1 · congr; simp only [algebraMap_smul] · simp only [Algebra.smul_def, map_pow] #align probability_theory.variance_smul' ProbabilityTheory.variance_smul' scoped notation "Var[" X "]" => ProbabilityTheory.variance X MeasureTheory.MeasureSpace.volume variable [MeasureSpace Ω] theorem variance_def' [@IsProbabilityMeasure Ω _ ℙ] {X : Ω → ℝ} (hX : Memℒp X 2) : Var[X] = 𝔼[X ^ 2] - 𝔼[X] ^ 2 := by rw [hX.variance_eq, sub_sq', integral_sub', integral_add']; rotate_left · exact hX.integrable_sq · convert @integrable_const Ω ℝ (_) ℙ _ _ (𝔼[X] ^ 2) · apply hX.integrable_sq.add convert @integrable_const Ω ℝ (_) ℙ _ _ (𝔼[X] ^ 2) · exact ((hX.integrable one_le_two).const_mul 2).mul_const' _ simp only [Pi.pow_apply, integral_const, measure_univ, ENNReal.one_toReal, smul_eq_mul, one_mul, Pi.mul_apply, Pi.ofNat_apply, Nat.cast_ofNat, integral_mul_right, integral_mul_left] ring #align probability_theory.variance_def' ProbabilityTheory.variance_def' theorem variance_le_expectation_sq [@IsProbabilityMeasure Ω _ ℙ] {X : Ω → ℝ} (hm : AEStronglyMeasurable X ℙ) : Var[X] ≤ 𝔼[X ^ 2] := by by_cases hX : Memℒp X 2 · rw [variance_def' hX] simp only [sq_nonneg, sub_le_self_iff] rw [variance, evariance_eq_lintegral_ofReal, ← integral_eq_lintegral_of_nonneg_ae] · by_cases hint : Integrable X; swap · simp only [integral_undef hint, Pi.pow_apply, Pi.sub_apply, sub_zero] exact le_rfl · rw [integral_undef] · exact integral_nonneg fun a => sq_nonneg _ intro h have A : Memℒp (X - fun ω : Ω => 𝔼[X]) 2 ℙ := (memℒp_two_iff_integrable_sq (hint.aestronglyMeasurable.sub aestronglyMeasurable_const)).2 h have B : Memℒp (fun _ : Ω => 𝔼[X]) 2 ℙ := memℒp_const _ apply hX convert A.add B simp · exact eventually_of_forall fun x => sq_nonneg _ · exact (AEMeasurable.pow_const (hm.aemeasurable.sub_const _) _).aestronglyMeasurable #align probability_theory.variance_le_expectation_sq ProbabilityTheory.variance_le_expectation_sq theorem evariance_def' [@IsProbabilityMeasure Ω _ ℙ] {X : Ω → ℝ} (hX : AEStronglyMeasurable X ℙ) : eVar[X] = (∫⁻ ω, (‖X ω‖₊ ^ 2 :)) - ENNReal.ofReal (𝔼[X] ^ 2) := by by_cases hℒ : Memℒp X 2 · rw [← hℒ.ofReal_variance_eq, variance_def' hℒ, ENNReal.ofReal_sub _ (sq_nonneg _)] congr rw [lintegral_coe_eq_integral] · congr 2 with ω simp only [Pi.pow_apply, NNReal.coe_pow, coe_nnnorm, Real.norm_eq_abs, Even.pow_abs even_two] · exact hℒ.abs.integrable_sq · symm rw [evariance_eq_top hX hℒ, ENNReal.sub_eq_top_iff] refine ⟨?_, ENNReal.ofReal_ne_top⟩ rw [Memℒp, not_and] at hℒ specialize hℒ hX simp only [snorm_eq_lintegral_rpow_nnnorm two_ne_zero ENNReal.two_ne_top, not_lt, top_le_iff, coe_two, one_div, ENNReal.rpow_eq_top_iff, inv_lt_zero, inv_pos, and_true_iff, or_iff_not_imp_left, not_and_or, zero_lt_two] at hℒ exact mod_cast hℒ fun _ => zero_le_two #align probability_theory.evariance_def' ProbabilityTheory.evariance_def' theorem meas_ge_le_evariance_div_sq {X : Ω → ℝ} (hX : AEStronglyMeasurable X ℙ) {c : ℝ≥0} (hc : c ≠ 0) : ℙ {ω | ↑c ≤ |X ω - 𝔼[X]|} ≤ eVar[X] / c ^ 2 := by have A : (c : ℝ≥0∞) ≠ 0 := by rwa [Ne, ENNReal.coe_eq_zero] have B : AEStronglyMeasurable (fun _ : Ω => 𝔼[X]) ℙ := aestronglyMeasurable_const convert meas_ge_le_mul_pow_snorm ℙ two_ne_zero ENNReal.two_ne_top (hX.sub B) A using 1 · congr simp only [Pi.sub_apply, ENNReal.coe_le_coe, ← Real.norm_eq_abs, ← coe_nnnorm, NNReal.coe_le_coe, ENNReal.ofReal_coe_nnreal] · rw [snorm_eq_lintegral_rpow_nnnorm two_ne_zero ENNReal.two_ne_top] simp only [show ENNReal.ofNNReal (c ^ 2) = (ENNReal.ofNNReal c) ^ 2 by norm_cast, coe_two, one_div, Pi.sub_apply] rw [div_eq_mul_inv, ENNReal.inv_pow, mul_comm, ENNReal.rpow_two] congr simp_rw [← ENNReal.rpow_mul, inv_mul_cancel (two_ne_zero : (2 : ℝ) ≠ 0), ENNReal.rpow_two, ENNReal.rpow_one, evariance] #align probability_theory.meas_ge_le_evariance_div_sq ProbabilityTheory.meas_ge_le_evariance_div_sq
Mathlib/Probability/Variance.lean
280
286
theorem meas_ge_le_variance_div_sq [@IsFiniteMeasure Ω _ ℙ] {X : Ω → ℝ} (hX : Memℒp X 2) {c : ℝ} (hc : 0 < c) : ℙ {ω | c ≤ |X ω - 𝔼[X]|} ≤ ENNReal.ofReal (Var[X] / c ^ 2) := by
rw [ENNReal.ofReal_div_of_pos (sq_pos_of_ne_zero hc.ne.symm), hX.ofReal_variance_eq] convert @meas_ge_le_evariance_div_sq _ _ _ hX.1 c.toNNReal (by simp [hc]) using 1 · simp only [Real.coe_toNNReal', max_le_iff, abs_nonneg, and_true_iff] · rw [ENNReal.ofReal_pow hc.le] rfl
import Mathlib.CategoryTheory.Limits.IsLimit import Mathlib.CategoryTheory.Category.ULift import Mathlib.CategoryTheory.EssentiallySmall import Mathlib.Logic.Equiv.Basic #align_import category_theory.limits.has_limits from "leanprover-community/mathlib"@"2738d2ca56cbc63be80c3bd48e9ed90ad94e947d" noncomputable section open CategoryTheory CategoryTheory.Category CategoryTheory.Functor Opposite namespace CategoryTheory.Limits -- morphism levels before object levels. See note [CategoryTheory universes]. universe v₁ u₁ v₂ u₂ v₃ u₃ v v' v'' u u' u'' variable {J : Type u₁} [Category.{v₁} J] {K : Type u₂} [Category.{v₂} K] variable {C : Type u} [Category.{v} C] variable {F : J ⥤ C} section Limit -- @[nolint has_nonempty_instance] -- Porting note(#5171): removed; linter not ported yet structure LimitCone (F : J ⥤ C) where cone : Cone F isLimit : IsLimit cone #align category_theory.limits.limit_cone CategoryTheory.Limits.LimitCone #align category_theory.limits.limit_cone.is_limit CategoryTheory.Limits.LimitCone.isLimit class HasLimit (F : J ⥤ C) : Prop where mk' :: exists_limit : Nonempty (LimitCone F) #align category_theory.limits.has_limit CategoryTheory.Limits.HasLimit theorem HasLimit.mk {F : J ⥤ C} (d : LimitCone F) : HasLimit F := ⟨Nonempty.intro d⟩ #align category_theory.limits.has_limit.mk CategoryTheory.Limits.HasLimit.mk def getLimitCone (F : J ⥤ C) [HasLimit F] : LimitCone F := Classical.choice <| HasLimit.exists_limit #align category_theory.limits.get_limit_cone CategoryTheory.Limits.getLimitCone variable (J C) class HasLimitsOfShape : Prop where has_limit : ∀ F : J ⥤ C, HasLimit F := by infer_instance #align category_theory.limits.has_limits_of_shape CategoryTheory.Limits.HasLimitsOfShape @[pp_with_univ] class HasLimitsOfSize (C : Type u) [Category.{v} C] : Prop where has_limits_of_shape : ∀ (J : Type u₁) [Category.{v₁} J], HasLimitsOfShape J C := by infer_instance #align category_theory.limits.has_limits_of_size CategoryTheory.Limits.HasLimitsOfSize abbrev HasLimits (C : Type u) [Category.{v} C] : Prop := HasLimitsOfSize.{v, v} C #align category_theory.limits.has_limits CategoryTheory.Limits.HasLimits theorem HasLimits.has_limits_of_shape {C : Type u} [Category.{v} C] [HasLimits C] (J : Type v) [Category.{v} J] : HasLimitsOfShape J C := HasLimitsOfSize.has_limits_of_shape J #align category_theory.limits.has_limits.has_limits_of_shape CategoryTheory.Limits.HasLimits.has_limits_of_shape variable {J C} -- see Note [lower instance priority] instance (priority := 100) hasLimitOfHasLimitsOfShape {J : Type u₁} [Category.{v₁} J] [HasLimitsOfShape J C] (F : J ⥤ C) : HasLimit F := HasLimitsOfShape.has_limit F #align category_theory.limits.has_limit_of_has_limits_of_shape CategoryTheory.Limits.hasLimitOfHasLimitsOfShape -- see Note [lower instance priority] instance (priority := 100) hasLimitsOfShapeOfHasLimits {J : Type u₁} [Category.{v₁} J] [HasLimitsOfSize.{v₁, u₁} C] : HasLimitsOfShape J C := HasLimitsOfSize.has_limits_of_shape J #align category_theory.limits.has_limits_of_shape_of_has_limits CategoryTheory.Limits.hasLimitsOfShapeOfHasLimits -- Interface to the `HasLimit` class. def limit.cone (F : J ⥤ C) [HasLimit F] : Cone F := (getLimitCone F).cone #align category_theory.limits.limit.cone CategoryTheory.Limits.limit.cone def limit (F : J ⥤ C) [HasLimit F] := (limit.cone F).pt #align category_theory.limits.limit CategoryTheory.Limits.limit def limit.π (F : J ⥤ C) [HasLimit F] (j : J) : limit F ⟶ F.obj j := (limit.cone F).π.app j #align category_theory.limits.limit.π CategoryTheory.Limits.limit.π @[simp] theorem limit.cone_x {F : J ⥤ C} [HasLimit F] : (limit.cone F).pt = limit F := rfl set_option linter.uppercaseLean3 false in #align category_theory.limits.limit.cone_X CategoryTheory.Limits.limit.cone_x @[simp] theorem limit.cone_π {F : J ⥤ C} [HasLimit F] : (limit.cone F).π.app = limit.π _ := rfl #align category_theory.limits.limit.cone_π CategoryTheory.Limits.limit.cone_π @[reassoc (attr := simp)] theorem limit.w (F : J ⥤ C) [HasLimit F] {j j' : J} (f : j ⟶ j') : limit.π F j ≫ F.map f = limit.π F j' := (limit.cone F).w f #align category_theory.limits.limit.w CategoryTheory.Limits.limit.w def limit.isLimit (F : J ⥤ C) [HasLimit F] : IsLimit (limit.cone F) := (getLimitCone F).isLimit #align category_theory.limits.limit.is_limit CategoryTheory.Limits.limit.isLimit def limit.lift (F : J ⥤ C) [HasLimit F] (c : Cone F) : c.pt ⟶ limit F := (limit.isLimit F).lift c #align category_theory.limits.limit.lift CategoryTheory.Limits.limit.lift @[simp] theorem limit.isLimit_lift {F : J ⥤ C} [HasLimit F] (c : Cone F) : (limit.isLimit F).lift c = limit.lift F c := rfl #align category_theory.limits.limit.is_limit_lift CategoryTheory.Limits.limit.isLimit_lift @[reassoc (attr := simp)] theorem limit.lift_π {F : J ⥤ C} [HasLimit F] (c : Cone F) (j : J) : limit.lift F c ≫ limit.π F j = c.π.app j := IsLimit.fac _ c j #align category_theory.limits.limit.lift_π CategoryTheory.Limits.limit.lift_π def limMap {F G : J ⥤ C} [HasLimit F] [HasLimit G] (α : F ⟶ G) : limit F ⟶ limit G := IsLimit.map _ (limit.isLimit G) α #align category_theory.limits.lim_map CategoryTheory.Limits.limMap @[reassoc (attr := simp)] theorem limMap_π {F G : J ⥤ C} [HasLimit F] [HasLimit G] (α : F ⟶ G) (j : J) : limMap α ≫ limit.π G j = limit.π F j ≫ α.app j := limit.lift_π _ j #align category_theory.limits.lim_map_π CategoryTheory.Limits.limMap_π def limit.coneMorphism {F : J ⥤ C} [HasLimit F] (c : Cone F) : c ⟶ limit.cone F := (limit.isLimit F).liftConeMorphism c #align category_theory.limits.limit.cone_morphism CategoryTheory.Limits.limit.coneMorphism @[simp] theorem limit.coneMorphism_hom {F : J ⥤ C} [HasLimit F] (c : Cone F) : (limit.coneMorphism c).hom = limit.lift F c := rfl #align category_theory.limits.limit.cone_morphism_hom CategoryTheory.Limits.limit.coneMorphism_hom
Mathlib/CategoryTheory/Limits/HasLimits.lean
224
225
theorem limit.coneMorphism_π {F : J ⥤ C} [HasLimit F] (c : Cone F) (j : J) : (limit.coneMorphism c).hom ≫ limit.π F j = c.π.app j := by
simp
import Mathlib.SetTheory.Ordinal.Basic import Mathlib.Data.Nat.SuccPred #align_import set_theory.ordinal.arithmetic from "leanprover-community/mathlib"@"31b269b60935483943542d547a6dd83a66b37dc7" assert_not_exists Field assert_not_exists Module noncomputable section open Function Cardinal Set Equiv Order open scoped Classical open Cardinal Ordinal universe u v w namespace Ordinal variable {α : Type*} {β : Type*} {γ : Type*} {r : α → α → Prop} {s : β → β → Prop} {t : γ → γ → Prop} @[simp] theorem lift_add (a b : Ordinal.{v}) : lift.{u} (a + b) = lift.{u} a + lift.{u} b := Quotient.inductionOn₂ a b fun ⟨_α, _r, _⟩ ⟨_β, _s, _⟩ => Quotient.sound ⟨(RelIso.preimage Equiv.ulift _).trans (RelIso.sumLexCongr (RelIso.preimage Equiv.ulift _) (RelIso.preimage Equiv.ulift _)).symm⟩ #align ordinal.lift_add Ordinal.lift_add @[simp] theorem lift_succ (a : Ordinal.{v}) : lift.{u} (succ a) = succ (lift.{u} a) := by rw [← add_one_eq_succ, lift_add, lift_one] rfl #align ordinal.lift_succ Ordinal.lift_succ instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) := ⟨fun a b c => inductionOn a fun α r hr => inductionOn b fun β₁ s₁ hs₁ => inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ => ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using @InitialSeg.eq _ _ _ _ _ ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by intro b; cases e : f (Sum.inr b) · rw [← fl] at e have := f.inj' e contradiction · exact ⟨_, rfl⟩ let g (b) := (this b).1 have fr : ∀ b, f (Sum.inr b) = Sum.inr (g b) := fun b => (this b).2 ⟨⟨⟨g, fun x y h => by injection f.inj' (by rw [fr, fr, h] : f (Sum.inr x) = f (Sum.inr y))⟩, @fun a b => by -- Porting note: -- `relEmbedding.coe_fn_to_embedding` & `initial_seg.coe_fn_to_rel_embedding` -- → `InitialSeg.coe_coe_fn` simpa only [Sum.lex_inr_inr, fr, InitialSeg.coe_coe_fn, Embedding.coeFn_mk] using @RelEmbedding.map_rel_iff _ _ _ _ f.toRelEmbedding (Sum.inr a) (Sum.inr b)⟩, fun a b H => by rcases f.init (by rw [fr] <;> exact Sum.lex_inr_inr.2 H) with ⟨a' | a', h⟩ · rw [fl] at h cases h · rw [fr] at h exact ⟨a', Sum.inr.inj h⟩⟩⟩⟩ #align ordinal.add_contravariant_class_le Ordinal.add_contravariantClass_le theorem add_left_cancel (a) {b c : Ordinal} : a + b = a + c ↔ b = c := by simp only [le_antisymm_iff, add_le_add_iff_left] #align ordinal.add_left_cancel Ordinal.add_left_cancel private theorem add_lt_add_iff_left' (a) {b c : Ordinal} : a + b < a + c ↔ b < c := by rw [← not_le, ← not_le, add_le_add_iff_left] instance add_covariantClass_lt : CovariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· < ·) := ⟨fun a _b _c => (add_lt_add_iff_left' a).2⟩ #align ordinal.add_covariant_class_lt Ordinal.add_covariantClass_lt instance add_contravariantClass_lt : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· < ·) := ⟨fun a _b _c => (add_lt_add_iff_left' a).1⟩ #align ordinal.add_contravariant_class_lt Ordinal.add_contravariantClass_lt instance add_swap_contravariantClass_lt : ContravariantClass Ordinal.{u} Ordinal.{u} (swap (· + ·)) (· < ·) := ⟨fun _a _b _c => lt_imp_lt_of_le_imp_le fun h => add_le_add_right h _⟩ #align ordinal.add_swap_contravariant_class_lt Ordinal.add_swap_contravariantClass_lt theorem add_le_add_iff_right {a b : Ordinal} : ∀ n : ℕ, a + n ≤ b + n ↔ a ≤ b | 0 => by simp | n + 1 => by simp only [natCast_succ, add_succ, add_succ, succ_le_succ_iff, add_le_add_iff_right] #align ordinal.add_le_add_iff_right Ordinal.add_le_add_iff_right theorem add_right_cancel {a b : Ordinal} (n : ℕ) : a + n = b + n ↔ a = b := by simp only [le_antisymm_iff, add_le_add_iff_right] #align ordinal.add_right_cancel Ordinal.add_right_cancel theorem add_eq_zero_iff {a b : Ordinal} : a + b = 0 ↔ a = 0 ∧ b = 0 := inductionOn a fun α r _ => inductionOn b fun β s _ => by simp_rw [← type_sum_lex, type_eq_zero_iff_isEmpty] exact isEmpty_sum #align ordinal.add_eq_zero_iff Ordinal.add_eq_zero_iff theorem left_eq_zero_of_add_eq_zero {a b : Ordinal} (h : a + b = 0) : a = 0 := (add_eq_zero_iff.1 h).1 #align ordinal.left_eq_zero_of_add_eq_zero Ordinal.left_eq_zero_of_add_eq_zero theorem right_eq_zero_of_add_eq_zero {a b : Ordinal} (h : a + b = 0) : b = 0 := (add_eq_zero_iff.1 h).2 #align ordinal.right_eq_zero_of_add_eq_zero Ordinal.right_eq_zero_of_add_eq_zero def pred (o : Ordinal) : Ordinal := if h : ∃ a, o = succ a then Classical.choose h else o #align ordinal.pred Ordinal.pred @[simp] theorem pred_succ (o) : pred (succ o) = o := by have h : ∃ a, succ o = succ a := ⟨_, rfl⟩; simpa only [pred, dif_pos h] using (succ_injective <| Classical.choose_spec h).symm #align ordinal.pred_succ Ordinal.pred_succ theorem pred_le_self (o) : pred o ≤ o := if h : ∃ a, o = succ a then by let ⟨a, e⟩ := h rw [e, pred_succ]; exact le_succ a else by rw [pred, dif_neg h] #align ordinal.pred_le_self Ordinal.pred_le_self theorem pred_eq_iff_not_succ {o} : pred o = o ↔ ¬∃ a, o = succ a := ⟨fun e ⟨a, e'⟩ => by rw [e', pred_succ] at e; exact (lt_succ a).ne e, fun h => dif_neg h⟩ #align ordinal.pred_eq_iff_not_succ Ordinal.pred_eq_iff_not_succ theorem pred_eq_iff_not_succ' {o} : pred o = o ↔ ∀ a, o ≠ succ a := by simpa using pred_eq_iff_not_succ #align ordinal.pred_eq_iff_not_succ' Ordinal.pred_eq_iff_not_succ' theorem pred_lt_iff_is_succ {o} : pred o < o ↔ ∃ a, o = succ a := Iff.trans (by simp only [le_antisymm_iff, pred_le_self, true_and_iff, not_le]) (iff_not_comm.1 pred_eq_iff_not_succ).symm #align ordinal.pred_lt_iff_is_succ Ordinal.pred_lt_iff_is_succ @[simp] theorem pred_zero : pred 0 = 0 := pred_eq_iff_not_succ'.2 fun a => (succ_ne_zero a).symm #align ordinal.pred_zero Ordinal.pred_zero theorem succ_pred_iff_is_succ {o} : succ (pred o) = o ↔ ∃ a, o = succ a := ⟨fun e => ⟨_, e.symm⟩, fun ⟨a, e⟩ => by simp only [e, pred_succ]⟩ #align ordinal.succ_pred_iff_is_succ Ordinal.succ_pred_iff_is_succ theorem succ_lt_of_not_succ {o b : Ordinal} (h : ¬∃ a, o = succ a) : succ b < o ↔ b < o := ⟨(lt_succ b).trans, fun l => lt_of_le_of_ne (succ_le_of_lt l) fun e => h ⟨_, e.symm⟩⟩ #align ordinal.succ_lt_of_not_succ Ordinal.succ_lt_of_not_succ theorem lt_pred {a b} : a < pred b ↔ succ a < b := if h : ∃ a, b = succ a then by let ⟨c, e⟩ := h rw [e, pred_succ, succ_lt_succ_iff] else by simp only [pred, dif_neg h, succ_lt_of_not_succ h] #align ordinal.lt_pred Ordinal.lt_pred theorem pred_le {a b} : pred a ≤ b ↔ a ≤ succ b := le_iff_le_iff_lt_iff_lt.2 lt_pred #align ordinal.pred_le Ordinal.pred_le @[simp] theorem lift_is_succ {o : Ordinal.{v}} : (∃ a, lift.{u} o = succ a) ↔ ∃ a, o = succ a := ⟨fun ⟨a, h⟩ => let ⟨b, e⟩ := lift_down <| show a ≤ lift.{u} o from le_of_lt <| h.symm ▸ lt_succ a ⟨b, lift_inj.1 <| by rw [h, ← e, lift_succ]⟩, fun ⟨a, h⟩ => ⟨lift.{u} a, by simp only [h, lift_succ]⟩⟩ #align ordinal.lift_is_succ Ordinal.lift_is_succ @[simp] theorem lift_pred (o : Ordinal.{v}) : lift.{u} (pred o) = pred (lift.{u} o) := if h : ∃ a, o = succ a then by cases' h with a e; simp only [e, pred_succ, lift_succ] else by rw [pred_eq_iff_not_succ.2 h, pred_eq_iff_not_succ.2 (mt lift_is_succ.1 h)] #align ordinal.lift_pred Ordinal.lift_pred def IsLimit (o : Ordinal) : Prop := o ≠ 0 ∧ ∀ a < o, succ a < o #align ordinal.is_limit Ordinal.IsLimit theorem IsLimit.isSuccLimit {o} (h : IsLimit o) : IsSuccLimit o := isSuccLimit_iff_succ_lt.mpr h.2 theorem IsLimit.succ_lt {o a : Ordinal} (h : IsLimit o) : a < o → succ a < o := h.2 a #align ordinal.is_limit.succ_lt Ordinal.IsLimit.succ_lt theorem isSuccLimit_zero : IsSuccLimit (0 : Ordinal) := isSuccLimit_bot theorem not_zero_isLimit : ¬IsLimit 0 | ⟨h, _⟩ => h rfl #align ordinal.not_zero_is_limit Ordinal.not_zero_isLimit theorem not_succ_isLimit (o) : ¬IsLimit (succ o) | ⟨_, h⟩ => lt_irrefl _ (h _ (lt_succ o)) #align ordinal.not_succ_is_limit Ordinal.not_succ_isLimit theorem not_succ_of_isLimit {o} (h : IsLimit o) : ¬∃ a, o = succ a | ⟨a, e⟩ => not_succ_isLimit a (e ▸ h) #align ordinal.not_succ_of_is_limit Ordinal.not_succ_of_isLimit theorem succ_lt_of_isLimit {o a : Ordinal} (h : IsLimit o) : succ a < o ↔ a < o := ⟨(lt_succ a).trans, h.2 _⟩ #align ordinal.succ_lt_of_is_limit Ordinal.succ_lt_of_isLimit theorem le_succ_of_isLimit {o} (h : IsLimit o) {a} : o ≤ succ a ↔ o ≤ a := le_iff_le_iff_lt_iff_lt.2 <| succ_lt_of_isLimit h #align ordinal.le_succ_of_is_limit Ordinal.le_succ_of_isLimit theorem limit_le {o} (h : IsLimit o) {a} : o ≤ a ↔ ∀ x < o, x ≤ a := ⟨fun h _x l => l.le.trans h, fun H => (le_succ_of_isLimit h).1 <| le_of_not_lt fun hn => not_lt_of_le (H _ hn) (lt_succ a)⟩ #align ordinal.limit_le Ordinal.limit_le theorem lt_limit {o} (h : IsLimit o) {a} : a < o ↔ ∃ x < o, a < x := by -- Porting note: `bex_def` is required. simpa only [not_forall₂, not_le, bex_def] using not_congr (@limit_le _ h a) #align ordinal.lt_limit Ordinal.lt_limit @[simp] theorem lift_isLimit (o) : IsLimit (lift o) ↔ IsLimit o := and_congr (not_congr <| by simpa only [lift_zero] using @lift_inj o 0) ⟨fun H a h => lift_lt.1 <| by simpa only [lift_succ] using H _ (lift_lt.2 h), fun H a h => by obtain ⟨a', rfl⟩ := lift_down h.le rw [← lift_succ, lift_lt] exact H a' (lift_lt.1 h)⟩ #align ordinal.lift_is_limit Ordinal.lift_isLimit theorem IsLimit.pos {o : Ordinal} (h : IsLimit o) : 0 < o := lt_of_le_of_ne (Ordinal.zero_le _) h.1.symm #align ordinal.is_limit.pos Ordinal.IsLimit.pos theorem IsLimit.one_lt {o : Ordinal} (h : IsLimit o) : 1 < o := by simpa only [succ_zero] using h.2 _ h.pos #align ordinal.is_limit.one_lt Ordinal.IsLimit.one_lt theorem IsLimit.nat_lt {o : Ordinal} (h : IsLimit o) : ∀ n : ℕ, (n : Ordinal) < o | 0 => h.pos | n + 1 => h.2 _ (IsLimit.nat_lt h n) #align ordinal.is_limit.nat_lt Ordinal.IsLimit.nat_lt theorem zero_or_succ_or_limit (o : Ordinal) : o = 0 ∨ (∃ a, o = succ a) ∨ IsLimit o := if o0 : o = 0 then Or.inl o0 else if h : ∃ a, o = succ a then Or.inr (Or.inl h) else Or.inr <| Or.inr ⟨o0, fun _a => (succ_lt_of_not_succ h).2⟩ #align ordinal.zero_or_succ_or_limit Ordinal.zero_or_succ_or_limit @[elab_as_elim] def limitRecOn {C : Ordinal → Sort*} (o : Ordinal) (H₁ : C 0) (H₂ : ∀ o, C o → C (succ o)) (H₃ : ∀ o, IsLimit o → (∀ o' < o, C o') → C o) : C o := SuccOrder.limitRecOn o (fun o _ ↦ H₂ o) fun o hl ↦ if h : o = 0 then fun _ ↦ h ▸ H₁ else H₃ o ⟨h, fun _ ↦ hl.succ_lt⟩ #align ordinal.limit_rec_on Ordinal.limitRecOn @[simp] theorem limitRecOn_zero {C} (H₁ H₂ H₃) : @limitRecOn C 0 H₁ H₂ H₃ = H₁ := by rw [limitRecOn, SuccOrder.limitRecOn_limit _ _ isSuccLimit_zero, dif_pos rfl] #align ordinal.limit_rec_on_zero Ordinal.limitRecOn_zero @[simp] theorem limitRecOn_succ {C} (o H₁ H₂ H₃) : @limitRecOn C (succ o) H₁ H₂ H₃ = H₂ o (@limitRecOn C o H₁ H₂ H₃) := by simp_rw [limitRecOn, SuccOrder.limitRecOn_succ _ _ (not_isMax _)] #align ordinal.limit_rec_on_succ Ordinal.limitRecOn_succ @[simp] theorem limitRecOn_limit {C} (o H₁ H₂ H₃ h) : @limitRecOn C o H₁ H₂ H₃ = H₃ o h fun x _h => @limitRecOn C x H₁ H₂ H₃ := by simp_rw [limitRecOn, SuccOrder.limitRecOn_limit _ _ h.isSuccLimit, dif_neg h.1] #align ordinal.limit_rec_on_limit Ordinal.limitRecOn_limit instance orderTopOutSucc (o : Ordinal) : OrderTop (succ o).out.α := @OrderTop.mk _ _ (Top.mk _) le_enum_succ #align ordinal.order_top_out_succ Ordinal.orderTopOutSucc theorem enum_succ_eq_top {o : Ordinal} : enum (· < ·) o (by rw [type_lt] exact lt_succ o) = (⊤ : (succ o).out.α) := rfl #align ordinal.enum_succ_eq_top Ordinal.enum_succ_eq_top theorem has_succ_of_type_succ_lt {α} {r : α → α → Prop} [wo : IsWellOrder α r] (h : ∀ a < type r, succ a < type r) (x : α) : ∃ y, r x y := by use enum r (succ (typein r x)) (h _ (typein_lt_type r x)) convert (enum_lt_enum (typein_lt_type r x) (h _ (typein_lt_type r x))).mpr (lt_succ _); rw [enum_typein] #align ordinal.has_succ_of_type_succ_lt Ordinal.has_succ_of_type_succ_lt theorem out_no_max_of_succ_lt {o : Ordinal} (ho : ∀ a < o, succ a < o) : NoMaxOrder o.out.α := ⟨has_succ_of_type_succ_lt (by rwa [type_lt])⟩ #align ordinal.out_no_max_of_succ_lt Ordinal.out_no_max_of_succ_lt theorem bounded_singleton {r : α → α → Prop} [IsWellOrder α r] (hr : (type r).IsLimit) (x) : Bounded r {x} := by refine ⟨enum r (succ (typein r x)) (hr.2 _ (typein_lt_type r x)), ?_⟩ intro b hb rw [mem_singleton_iff.1 hb] nth_rw 1 [← enum_typein r x] rw [@enum_lt_enum _ r] apply lt_succ #align ordinal.bounded_singleton Ordinal.bounded_singleton -- Porting note: `· < ·` requires a type ascription for an `IsWellOrder` instance. theorem type_subrel_lt (o : Ordinal.{u}) : type (Subrel ((· < ·) : Ordinal → Ordinal → Prop) { o' : Ordinal | o' < o }) = Ordinal.lift.{u + 1} o := by refine Quotient.inductionOn o ?_ rintro ⟨α, r, wo⟩; apply Quotient.sound -- Porting note: `symm; refine' [term]` → `refine' [term].symm` constructor; refine ((RelIso.preimage Equiv.ulift r).trans (enumIso r).symm).symm #align ordinal.type_subrel_lt Ordinal.type_subrel_lt theorem mk_initialSeg (o : Ordinal.{u}) : #{ o' : Ordinal | o' < o } = Cardinal.lift.{u + 1} o.card := by rw [lift_card, ← type_subrel_lt, card_type] #align ordinal.mk_initial_seg Ordinal.mk_initialSeg def IsNormal (f : Ordinal → Ordinal) : Prop := (∀ o, f o < f (succ o)) ∧ ∀ o, IsLimit o → ∀ a, f o ≤ a ↔ ∀ b < o, f b ≤ a #align ordinal.is_normal Ordinal.IsNormal theorem IsNormal.limit_le {f} (H : IsNormal f) : ∀ {o}, IsLimit o → ∀ {a}, f o ≤ a ↔ ∀ b < o, f b ≤ a := @H.2 #align ordinal.is_normal.limit_le Ordinal.IsNormal.limit_le theorem IsNormal.limit_lt {f} (H : IsNormal f) {o} (h : IsLimit o) {a} : a < f o ↔ ∃ b < o, a < f b := not_iff_not.1 <| by simpa only [exists_prop, not_exists, not_and, not_lt] using H.2 _ h a #align ordinal.is_normal.limit_lt Ordinal.IsNormal.limit_lt theorem IsNormal.strictMono {f} (H : IsNormal f) : StrictMono f := fun a b => limitRecOn b (Not.elim (not_lt_of_le <| Ordinal.zero_le _)) (fun _b IH h => (lt_or_eq_of_le (le_of_lt_succ h)).elim (fun h => (IH h).trans (H.1 _)) fun e => e ▸ H.1 _) fun _b l _IH h => lt_of_lt_of_le (H.1 a) ((H.2 _ l _).1 le_rfl _ (l.2 _ h)) #align ordinal.is_normal.strict_mono Ordinal.IsNormal.strictMono theorem IsNormal.monotone {f} (H : IsNormal f) : Monotone f := H.strictMono.monotone #align ordinal.is_normal.monotone Ordinal.IsNormal.monotone theorem isNormal_iff_strictMono_limit (f : Ordinal → Ordinal) : IsNormal f ↔ StrictMono f ∧ ∀ o, IsLimit o → ∀ a, (∀ b < o, f b ≤ a) → f o ≤ a := ⟨fun hf => ⟨hf.strictMono, fun a ha c => (hf.2 a ha c).2⟩, fun ⟨hs, hl⟩ => ⟨fun a => hs (lt_succ a), fun a ha c => ⟨fun hac _b hba => ((hs hba).trans_le hac).le, hl a ha c⟩⟩⟩ #align ordinal.is_normal_iff_strict_mono_limit Ordinal.isNormal_iff_strictMono_limit theorem IsNormal.lt_iff {f} (H : IsNormal f) {a b} : f a < f b ↔ a < b := StrictMono.lt_iff_lt <| H.strictMono #align ordinal.is_normal.lt_iff Ordinal.IsNormal.lt_iff theorem IsNormal.le_iff {f} (H : IsNormal f) {a b} : f a ≤ f b ↔ a ≤ b := le_iff_le_iff_lt_iff_lt.2 H.lt_iff #align ordinal.is_normal.le_iff Ordinal.IsNormal.le_iff theorem IsNormal.inj {f} (H : IsNormal f) {a b} : f a = f b ↔ a = b := by simp only [le_antisymm_iff, H.le_iff] #align ordinal.is_normal.inj Ordinal.IsNormal.inj theorem IsNormal.self_le {f} (H : IsNormal f) (a) : a ≤ f a := lt_wf.self_le_of_strictMono H.strictMono a #align ordinal.is_normal.self_le Ordinal.IsNormal.self_le theorem IsNormal.le_set {f o} (H : IsNormal f) (p : Set Ordinal) (p0 : p.Nonempty) (b) (H₂ : ∀ o, b ≤ o ↔ ∀ a ∈ p, a ≤ o) : f b ≤ o ↔ ∀ a ∈ p, f a ≤ o := ⟨fun h a pa => (H.le_iff.2 ((H₂ _).1 le_rfl _ pa)).trans h, fun h => by -- Porting note: `refine'` didn't work well so `induction` is used induction b using limitRecOn with | H₁ => cases' p0 with x px have := Ordinal.le_zero.1 ((H₂ _).1 (Ordinal.zero_le _) _ px) rw [this] at px exact h _ px | H₂ S _ => rcases not_forall₂.1 (mt (H₂ S).2 <| (lt_succ S).not_le) with ⟨a, h₁, h₂⟩ exact (H.le_iff.2 <| succ_le_of_lt <| not_le.1 h₂).trans (h _ h₁) | H₃ S L _ => refine (H.2 _ L _).2 fun a h' => ?_ rcases not_forall₂.1 (mt (H₂ a).2 h'.not_le) with ⟨b, h₁, h₂⟩ exact (H.le_iff.2 <| (not_le.1 h₂).le).trans (h _ h₁)⟩ #align ordinal.is_normal.le_set Ordinal.IsNormal.le_set theorem IsNormal.le_set' {f o} (H : IsNormal f) (p : Set α) (p0 : p.Nonempty) (g : α → Ordinal) (b) (H₂ : ∀ o, b ≤ o ↔ ∀ a ∈ p, g a ≤ o) : f b ≤ o ↔ ∀ a ∈ p, f (g a) ≤ o := by simpa [H₂] using H.le_set (g '' p) (p0.image g) b #align ordinal.is_normal.le_set' Ordinal.IsNormal.le_set' theorem IsNormal.refl : IsNormal id := ⟨lt_succ, fun _o l _a => Ordinal.limit_le l⟩ #align ordinal.is_normal.refl Ordinal.IsNormal.refl theorem IsNormal.trans {f g} (H₁ : IsNormal f) (H₂ : IsNormal g) : IsNormal (f ∘ g) := ⟨fun _x => H₁.lt_iff.2 (H₂.1 _), fun o l _a => H₁.le_set' (· < o) ⟨0, l.pos⟩ g _ fun _c => H₂.2 _ l _⟩ #align ordinal.is_normal.trans Ordinal.IsNormal.trans theorem IsNormal.isLimit {f} (H : IsNormal f) {o} (l : IsLimit o) : IsLimit (f o) := ⟨ne_of_gt <| (Ordinal.zero_le _).trans_lt <| H.lt_iff.2 l.pos, fun _ h => let ⟨_b, h₁, h₂⟩ := (H.limit_lt l).1 h (succ_le_of_lt h₂).trans_lt (H.lt_iff.2 h₁)⟩ #align ordinal.is_normal.is_limit Ordinal.IsNormal.isLimit theorem IsNormal.le_iff_eq {f} (H : IsNormal f) {a} : f a ≤ a ↔ f a = a := (H.self_le a).le_iff_eq #align ordinal.is_normal.le_iff_eq Ordinal.IsNormal.le_iff_eq theorem add_le_of_limit {a b c : Ordinal} (h : IsLimit b) : a + b ≤ c ↔ ∀ b' < b, a + b' ≤ c := ⟨fun h b' l => (add_le_add_left l.le _).trans h, fun H => le_of_not_lt <| by -- Porting note: `induction` tactics are required because of the parser bug. induction a using inductionOn with | H α r => induction b using inductionOn with | H β s => intro l suffices ∀ x : β, Sum.Lex r s (Sum.inr x) (enum _ _ l) by -- Porting note: `revert` & `intro` is required because `cases'` doesn't replace -- `enum _ _ l` in `this`. revert this; cases' enum _ _ l with x x <;> intro this · cases this (enum s 0 h.pos) · exact irrefl _ (this _) intro x rw [← typein_lt_typein (Sum.Lex r s), typein_enum] have := H _ (h.2 _ (typein_lt_type s x)) rw [add_succ, succ_le_iff] at this refine (RelEmbedding.ofMonotone (fun a => ?_) fun a b => ?_).ordinal_type_le.trans_lt this · rcases a with ⟨a | b, h⟩ · exact Sum.inl a · exact Sum.inr ⟨b, by cases h; assumption⟩ · rcases a with ⟨a | a, h₁⟩ <;> rcases b with ⟨b | b, h₂⟩ <;> cases h₁ <;> cases h₂ <;> rintro ⟨⟩ <;> constructor <;> assumption⟩ #align ordinal.add_le_of_limit Ordinal.add_le_of_limit theorem add_isNormal (a : Ordinal) : IsNormal (a + ·) := ⟨fun b => (add_lt_add_iff_left a).2 (lt_succ b), fun _b l _c => add_le_of_limit l⟩ #align ordinal.add_is_normal Ordinal.add_isNormal theorem add_isLimit (a) {b} : IsLimit b → IsLimit (a + b) := (add_isNormal a).isLimit #align ordinal.add_is_limit Ordinal.add_isLimit alias IsLimit.add := add_isLimit #align ordinal.is_limit.add Ordinal.IsLimit.add theorem sub_nonempty {a b : Ordinal} : { o | a ≤ b + o }.Nonempty := ⟨a, le_add_left _ _⟩ #align ordinal.sub_nonempty Ordinal.sub_nonempty instance sub : Sub Ordinal := ⟨fun a b => sInf { o | a ≤ b + o }⟩ theorem le_add_sub (a b : Ordinal) : a ≤ b + (a - b) := csInf_mem sub_nonempty #align ordinal.le_add_sub Ordinal.le_add_sub theorem sub_le {a b c : Ordinal} : a - b ≤ c ↔ a ≤ b + c := ⟨fun h => (le_add_sub a b).trans (add_le_add_left h _), fun h => csInf_le' h⟩ #align ordinal.sub_le Ordinal.sub_le theorem lt_sub {a b c : Ordinal} : a < b - c ↔ c + a < b := lt_iff_lt_of_le_iff_le sub_le #align ordinal.lt_sub Ordinal.lt_sub theorem add_sub_cancel (a b : Ordinal) : a + b - a = b := le_antisymm (sub_le.2 <| le_rfl) ((add_le_add_iff_left a).1 <| le_add_sub _ _) #align ordinal.add_sub_cancel Ordinal.add_sub_cancel theorem sub_eq_of_add_eq {a b c : Ordinal} (h : a + b = c) : c - a = b := h ▸ add_sub_cancel _ _ #align ordinal.sub_eq_of_add_eq Ordinal.sub_eq_of_add_eq theorem sub_le_self (a b : Ordinal) : a - b ≤ a := sub_le.2 <| le_add_left _ _ #align ordinal.sub_le_self Ordinal.sub_le_self protected theorem add_sub_cancel_of_le {a b : Ordinal} (h : b ≤ a) : b + (a - b) = a := (le_add_sub a b).antisymm' (by rcases zero_or_succ_or_limit (a - b) with (e | ⟨c, e⟩ | l) · simp only [e, add_zero, h] · rw [e, add_succ, succ_le_iff, ← lt_sub, e] exact lt_succ c · exact (add_le_of_limit l).2 fun c l => (lt_sub.1 l).le) #align ordinal.add_sub_cancel_of_le Ordinal.add_sub_cancel_of_le theorem le_sub_of_le {a b c : Ordinal} (h : b ≤ a) : c ≤ a - b ↔ b + c ≤ a := by rw [← add_le_add_iff_left b, Ordinal.add_sub_cancel_of_le h] #align ordinal.le_sub_of_le Ordinal.le_sub_of_le theorem sub_lt_of_le {a b c : Ordinal} (h : b ≤ a) : a - b < c ↔ a < b + c := lt_iff_lt_of_le_iff_le (le_sub_of_le h) #align ordinal.sub_lt_of_le Ordinal.sub_lt_of_le instance existsAddOfLE : ExistsAddOfLE Ordinal := ⟨fun h => ⟨_, (Ordinal.add_sub_cancel_of_le h).symm⟩⟩ @[simp] theorem sub_zero (a : Ordinal) : a - 0 = a := by simpa only [zero_add] using add_sub_cancel 0 a #align ordinal.sub_zero Ordinal.sub_zero @[simp] theorem zero_sub (a : Ordinal) : 0 - a = 0 := by rw [← Ordinal.le_zero]; apply sub_le_self #align ordinal.zero_sub Ordinal.zero_sub @[simp] theorem sub_self (a : Ordinal) : a - a = 0 := by simpa only [add_zero] using add_sub_cancel a 0 #align ordinal.sub_self Ordinal.sub_self protected theorem sub_eq_zero_iff_le {a b : Ordinal} : a - b = 0 ↔ a ≤ b := ⟨fun h => by simpa only [h, add_zero] using le_add_sub a b, fun h => by rwa [← Ordinal.le_zero, sub_le, add_zero]⟩ #align ordinal.sub_eq_zero_iff_le Ordinal.sub_eq_zero_iff_le theorem sub_sub (a b c : Ordinal) : a - b - c = a - (b + c) := eq_of_forall_ge_iff fun d => by rw [sub_le, sub_le, sub_le, add_assoc] #align ordinal.sub_sub Ordinal.sub_sub @[simp] theorem add_sub_add_cancel (a b c : Ordinal) : a + b - (a + c) = b - c := by rw [← sub_sub, add_sub_cancel] #align ordinal.add_sub_add_cancel Ordinal.add_sub_add_cancel theorem sub_isLimit {a b} (l : IsLimit a) (h : b < a) : IsLimit (a - b) := ⟨ne_of_gt <| lt_sub.2 <| by rwa [add_zero], fun c h => by rw [lt_sub, add_succ]; exact l.2 _ (lt_sub.1 h)⟩ #align ordinal.sub_is_limit Ordinal.sub_isLimit -- @[simp] -- Porting note (#10618): simp can prove this theorem one_add_omega : 1 + ω = ω := by refine le_antisymm ?_ (le_add_left _ _) rw [omega, ← lift_one.{_, 0}, ← lift_add, lift_le, ← type_unit, ← type_sum_lex] refine ⟨RelEmbedding.collapse (RelEmbedding.ofMonotone ?_ ?_)⟩ · apply Sum.rec · exact fun _ => 0 · exact Nat.succ · intro a b cases a <;> cases b <;> intro H <;> cases' H with _ _ H _ _ H <;> [exact H.elim; exact Nat.succ_pos _; exact Nat.succ_lt_succ H] #align ordinal.one_add_omega Ordinal.one_add_omega @[simp] theorem one_add_of_omega_le {o} (h : ω ≤ o) : 1 + o = o := by rw [← Ordinal.add_sub_cancel_of_le h, ← add_assoc, one_add_omega] #align ordinal.one_add_of_omega_le Ordinal.one_add_of_omega_le instance monoid : Monoid Ordinal.{u} where mul a b := Quotient.liftOn₂ a b (fun ⟨α, r, wo⟩ ⟨β, s, wo'⟩ => ⟦⟨β × α, Prod.Lex s r, inferInstance⟩⟧ : WellOrder → WellOrder → Ordinal) fun ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩ => Quot.sound ⟨RelIso.prodLexCongr g f⟩ one := 1 mul_assoc a b c := Quotient.inductionOn₃ a b c fun ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ => Eq.symm <| Quotient.sound ⟨⟨prodAssoc _ _ _, @fun a b => by rcases a with ⟨⟨a₁, a₂⟩, a₃⟩ rcases b with ⟨⟨b₁, b₂⟩, b₃⟩ simp [Prod.lex_def, and_or_left, or_assoc, and_assoc]⟩⟩ mul_one a := inductionOn a fun α r _ => Quotient.sound ⟨⟨punitProd _, @fun a b => by rcases a with ⟨⟨⟨⟩⟩, a⟩; rcases b with ⟨⟨⟨⟩⟩, b⟩ simp only [Prod.lex_def, EmptyRelation, false_or_iff] simp only [eq_self_iff_true, true_and_iff] rfl⟩⟩ one_mul a := inductionOn a fun α r _ => Quotient.sound ⟨⟨prodPUnit _, @fun a b => by rcases a with ⟨a, ⟨⟨⟩⟩⟩; rcases b with ⟨b, ⟨⟨⟩⟩⟩ simp only [Prod.lex_def, EmptyRelation, and_false_iff, or_false_iff] rfl⟩⟩ @[simp] theorem type_prod_lex {α β : Type u} (r : α → α → Prop) (s : β → β → Prop) [IsWellOrder α r] [IsWellOrder β s] : type (Prod.Lex s r) = type r * type s := rfl #align ordinal.type_prod_lex Ordinal.type_prod_lex private theorem mul_eq_zero' {a b : Ordinal} : a * b = 0 ↔ a = 0 ∨ b = 0 := inductionOn a fun α _ _ => inductionOn b fun β _ _ => by simp_rw [← type_prod_lex, type_eq_zero_iff_isEmpty] rw [or_comm] exact isEmpty_prod instance monoidWithZero : MonoidWithZero Ordinal := { Ordinal.monoid with zero := 0 mul_zero := fun _a => mul_eq_zero'.2 <| Or.inr rfl zero_mul := fun _a => mul_eq_zero'.2 <| Or.inl rfl } instance noZeroDivisors : NoZeroDivisors Ordinal := ⟨fun {_ _} => mul_eq_zero'.1⟩ @[simp] theorem lift_mul (a b : Ordinal.{v}) : lift.{u} (a * b) = lift.{u} a * lift.{u} b := Quotient.inductionOn₂ a b fun ⟨_α, _r, _⟩ ⟨_β, _s, _⟩ => Quotient.sound ⟨(RelIso.preimage Equiv.ulift _).trans (RelIso.prodLexCongr (RelIso.preimage Equiv.ulift _) (RelIso.preimage Equiv.ulift _)).symm⟩ #align ordinal.lift_mul Ordinal.lift_mul @[simp] theorem card_mul (a b) : card (a * b) = card a * card b := Quotient.inductionOn₂ a b fun ⟨α, _r, _⟩ ⟨β, _s, _⟩ => mul_comm #β #α #align ordinal.card_mul Ordinal.card_mul instance leftDistribClass : LeftDistribClass Ordinal.{u} := ⟨fun a b c => Quotient.inductionOn₃ a b c fun ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ => Quotient.sound ⟨⟨sumProdDistrib _ _ _, by rintro ⟨a₁ | a₁, a₂⟩ ⟨b₁ | b₁, b₂⟩ <;> simp only [Prod.lex_def, Sum.lex_inl_inl, Sum.Lex.sep, Sum.lex_inr_inl, Sum.lex_inr_inr, sumProdDistrib_apply_left, sumProdDistrib_apply_right] <;> -- Porting note: `Sum.inr.inj_iff` is required. simp only [Sum.inl.inj_iff, Sum.inr.inj_iff, true_or_iff, false_and_iff, false_or_iff]⟩⟩⟩ theorem mul_succ (a b : Ordinal) : a * succ b = a * b + a := mul_add_one a b #align ordinal.mul_succ Ordinal.mul_succ instance mul_covariantClass_le : CovariantClass Ordinal.{u} Ordinal.{u} (· * ·) (· ≤ ·) := ⟨fun c a b => Quotient.inductionOn₃ a b c fun ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩ => by refine (RelEmbedding.ofMonotone (fun a : α × γ => (f a.1, a.2)) fun a b h => ?_).ordinal_type_le cases' h with a₁ b₁ a₂ b₂ h' a b₁ b₂ h' · exact Prod.Lex.left _ _ (f.toRelEmbedding.map_rel_iff.2 h') · exact Prod.Lex.right _ h'⟩ #align ordinal.mul_covariant_class_le Ordinal.mul_covariantClass_le instance mul_swap_covariantClass_le : CovariantClass Ordinal.{u} Ordinal.{u} (swap (· * ·)) (· ≤ ·) := ⟨fun c a b => Quotient.inductionOn₃ a b c fun ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩ => by refine (RelEmbedding.ofMonotone (fun a : γ × α => (a.1, f a.2)) fun a b h => ?_).ordinal_type_le cases' h with a₁ b₁ a₂ b₂ h' a b₁ b₂ h' · exact Prod.Lex.left _ _ h' · exact Prod.Lex.right _ (f.toRelEmbedding.map_rel_iff.2 h')⟩ #align ordinal.mul_swap_covariant_class_le Ordinal.mul_swap_covariantClass_le theorem le_mul_left (a : Ordinal) {b : Ordinal} (hb : 0 < b) : a ≤ a * b := by convert mul_le_mul_left' (one_le_iff_pos.2 hb) a rw [mul_one a] #align ordinal.le_mul_left Ordinal.le_mul_left theorem le_mul_right (a : Ordinal) {b : Ordinal} (hb : 0 < b) : a ≤ b * a := by convert mul_le_mul_right' (one_le_iff_pos.2 hb) a rw [one_mul a] #align ordinal.le_mul_right Ordinal.le_mul_right private theorem mul_le_of_limit_aux {α β r s} [IsWellOrder α r] [IsWellOrder β s] {c} (h : IsLimit (type s)) (H : ∀ b' < type s, type r * b' ≤ c) (l : c < type r * type s) : False := by suffices ∀ a b, Prod.Lex s r (b, a) (enum _ _ l) by cases' enum _ _ l with b a exact irrefl _ (this _ _) intro a b rw [← typein_lt_typein (Prod.Lex s r), typein_enum] have := H _ (h.2 _ (typein_lt_type s b)) rw [mul_succ] at this have := ((add_lt_add_iff_left _).2 (typein_lt_type _ a)).trans_le this refine (RelEmbedding.ofMonotone (fun a => ?_) fun a b => ?_).ordinal_type_le.trans_lt this · rcases a with ⟨⟨b', a'⟩, h⟩ by_cases e : b = b' · refine Sum.inr ⟨a', ?_⟩ subst e cases' h with _ _ _ _ h _ _ _ h · exact (irrefl _ h).elim · exact h · refine Sum.inl (⟨b', ?_⟩, a') cases' h with _ _ _ _ h _ _ _ h · exact h · exact (e rfl).elim · rcases a with ⟨⟨b₁, a₁⟩, h₁⟩ rcases b with ⟨⟨b₂, a₂⟩, h₂⟩ intro h by_cases e₁ : b = b₁ <;> by_cases e₂ : b = b₂ · substs b₁ b₂ simpa only [subrel_val, Prod.lex_def, @irrefl _ s _ b, true_and_iff, false_or_iff, eq_self_iff_true, dif_pos, Sum.lex_inr_inr] using h · subst b₁ simp only [subrel_val, Prod.lex_def, e₂, Prod.lex_def, dif_pos, subrel_val, eq_self_iff_true, or_false_iff, dif_neg, not_false_iff, Sum.lex_inr_inl, false_and_iff] at h ⊢ cases' h₂ with _ _ _ _ h₂_h h₂_h <;> [exact asymm h h₂_h; exact e₂ rfl] -- Porting note: `cc` hadn't ported yet. · simp [e₂, dif_neg e₁, show b₂ ≠ b₁ from e₂ ▸ e₁] · simpa only [dif_neg e₁, dif_neg e₂, Prod.lex_def, subrel_val, Subtype.mk_eq_mk, Sum.lex_inl_inl] using h theorem mul_le_of_limit {a b c : Ordinal} (h : IsLimit b) : a * b ≤ c ↔ ∀ b' < b, a * b' ≤ c := ⟨fun h b' l => (mul_le_mul_left' l.le _).trans h, fun H => -- Porting note: `induction` tactics are required because of the parser bug. le_of_not_lt <| by induction a using inductionOn with | H α r => induction b using inductionOn with | H β s => exact mul_le_of_limit_aux h H⟩ #align ordinal.mul_le_of_limit Ordinal.mul_le_of_limit theorem mul_isNormal {a : Ordinal} (h : 0 < a) : IsNormal (a * ·) := -- Porting note(#12129): additional beta reduction needed ⟨fun b => by beta_reduce rw [mul_succ] simpa only [add_zero] using (add_lt_add_iff_left (a * b)).2 h, fun b l c => mul_le_of_limit l⟩ #align ordinal.mul_is_normal Ordinal.mul_isNormal theorem lt_mul_of_limit {a b c : Ordinal} (h : IsLimit c) : a < b * c ↔ ∃ c' < c, a < b * c' := by -- Porting note: `bex_def` is required. simpa only [not_forall₂, not_le, bex_def] using not_congr (@mul_le_of_limit b c a h) #align ordinal.lt_mul_of_limit Ordinal.lt_mul_of_limit theorem mul_lt_mul_iff_left {a b c : Ordinal} (a0 : 0 < a) : a * b < a * c ↔ b < c := (mul_isNormal a0).lt_iff #align ordinal.mul_lt_mul_iff_left Ordinal.mul_lt_mul_iff_left theorem mul_le_mul_iff_left {a b c : Ordinal} (a0 : 0 < a) : a * b ≤ a * c ↔ b ≤ c := (mul_isNormal a0).le_iff #align ordinal.mul_le_mul_iff_left Ordinal.mul_le_mul_iff_left theorem mul_lt_mul_of_pos_left {a b c : Ordinal} (h : a < b) (c0 : 0 < c) : c * a < c * b := (mul_lt_mul_iff_left c0).2 h #align ordinal.mul_lt_mul_of_pos_left Ordinal.mul_lt_mul_of_pos_left theorem mul_pos {a b : Ordinal} (h₁ : 0 < a) (h₂ : 0 < b) : 0 < a * b := by simpa only [mul_zero] using mul_lt_mul_of_pos_left h₂ h₁ #align ordinal.mul_pos Ordinal.mul_pos theorem mul_ne_zero {a b : Ordinal} : a ≠ 0 → b ≠ 0 → a * b ≠ 0 := by simpa only [Ordinal.pos_iff_ne_zero] using mul_pos #align ordinal.mul_ne_zero Ordinal.mul_ne_zero theorem le_of_mul_le_mul_left {a b c : Ordinal} (h : c * a ≤ c * b) (h0 : 0 < c) : a ≤ b := le_imp_le_of_lt_imp_lt (fun h' => mul_lt_mul_of_pos_left h' h0) h #align ordinal.le_of_mul_le_mul_left Ordinal.le_of_mul_le_mul_left theorem mul_right_inj {a b c : Ordinal} (a0 : 0 < a) : a * b = a * c ↔ b = c := (mul_isNormal a0).inj #align ordinal.mul_right_inj Ordinal.mul_right_inj theorem mul_isLimit {a b : Ordinal} (a0 : 0 < a) : IsLimit b → IsLimit (a * b) := (mul_isNormal a0).isLimit #align ordinal.mul_is_limit Ordinal.mul_isLimit theorem mul_isLimit_left {a b : Ordinal} (l : IsLimit a) (b0 : 0 < b) : IsLimit (a * b) := by rcases zero_or_succ_or_limit b with (rfl | ⟨b, rfl⟩ | lb) · exact b0.false.elim · rw [mul_succ] exact add_isLimit _ l · exact mul_isLimit l.pos lb #align ordinal.mul_is_limit_left Ordinal.mul_isLimit_left theorem smul_eq_mul : ∀ (n : ℕ) (a : Ordinal), n • a = a * n | 0, a => by rw [zero_nsmul, Nat.cast_zero, mul_zero] | n + 1, a => by rw [succ_nsmul, Nat.cast_add, mul_add, Nat.cast_one, mul_one, smul_eq_mul n] #align ordinal.smul_eq_mul Ordinal.smul_eq_mul theorem div_nonempty {a b : Ordinal} (h : b ≠ 0) : { o | a < b * succ o }.Nonempty := ⟨a, (succ_le_iff (a := a) (b := b * succ a)).1 <| by simpa only [succ_zero, one_mul] using mul_le_mul_right' (succ_le_of_lt (Ordinal.pos_iff_ne_zero.2 h)) (succ a)⟩ #align ordinal.div_nonempty Ordinal.div_nonempty instance div : Div Ordinal := ⟨fun a b => if _h : b = 0 then 0 else sInf { o | a < b * succ o }⟩ @[simp] theorem div_zero (a : Ordinal) : a / 0 = 0 := dif_pos rfl #align ordinal.div_zero Ordinal.div_zero theorem div_def (a) {b : Ordinal} (h : b ≠ 0) : a / b = sInf { o | a < b * succ o } := dif_neg h #align ordinal.div_def Ordinal.div_def theorem lt_mul_succ_div (a) {b : Ordinal} (h : b ≠ 0) : a < b * succ (a / b) := by rw [div_def a h]; exact csInf_mem (div_nonempty h) #align ordinal.lt_mul_succ_div Ordinal.lt_mul_succ_div theorem lt_mul_div_add (a) {b : Ordinal} (h : b ≠ 0) : a < b * (a / b) + b := by simpa only [mul_succ] using lt_mul_succ_div a h #align ordinal.lt_mul_div_add Ordinal.lt_mul_div_add theorem div_le {a b c : Ordinal} (b0 : b ≠ 0) : a / b ≤ c ↔ a < b * succ c := ⟨fun h => (lt_mul_succ_div a b0).trans_le (mul_le_mul_left' (succ_le_succ_iff.2 h) _), fun h => by rw [div_def a b0]; exact csInf_le' h⟩ #align ordinal.div_le Ordinal.div_le theorem lt_div {a b c : Ordinal} (h : c ≠ 0) : a < b / c ↔ c * succ a ≤ b := by rw [← not_le, div_le h, not_lt] #align ordinal.lt_div Ordinal.lt_div theorem div_pos {b c : Ordinal} (h : c ≠ 0) : 0 < b / c ↔ c ≤ b := by simp [lt_div h] #align ordinal.div_pos Ordinal.div_pos theorem le_div {a b c : Ordinal} (c0 : c ≠ 0) : a ≤ b / c ↔ c * a ≤ b := by induction a using limitRecOn with | H₁ => simp only [mul_zero, Ordinal.zero_le] | H₂ _ _ => rw [succ_le_iff, lt_div c0] | H₃ _ h₁ h₂ => revert h₁ h₂ simp (config := { contextual := true }) only [mul_le_of_limit, limit_le, iff_self_iff, forall_true_iff] #align ordinal.le_div Ordinal.le_div theorem div_lt {a b c : Ordinal} (b0 : b ≠ 0) : a / b < c ↔ a < b * c := lt_iff_lt_of_le_iff_le <| le_div b0 #align ordinal.div_lt Ordinal.div_lt theorem div_le_of_le_mul {a b c : Ordinal} (h : a ≤ b * c) : a / b ≤ c := if b0 : b = 0 then by simp only [b0, div_zero, Ordinal.zero_le] else (div_le b0).2 <| h.trans_lt <| mul_lt_mul_of_pos_left (lt_succ c) (Ordinal.pos_iff_ne_zero.2 b0) #align ordinal.div_le_of_le_mul Ordinal.div_le_of_le_mul theorem mul_lt_of_lt_div {a b c : Ordinal} : a < b / c → c * a < b := lt_imp_lt_of_le_imp_le div_le_of_le_mul #align ordinal.mul_lt_of_lt_div Ordinal.mul_lt_of_lt_div @[simp] theorem zero_div (a : Ordinal) : 0 / a = 0 := Ordinal.le_zero.1 <| div_le_of_le_mul <| Ordinal.zero_le _ #align ordinal.zero_div Ordinal.zero_div theorem mul_div_le (a b : Ordinal) : b * (a / b) ≤ a := if b0 : b = 0 then by simp only [b0, zero_mul, Ordinal.zero_le] else (le_div b0).1 le_rfl #align ordinal.mul_div_le Ordinal.mul_div_le theorem mul_add_div (a) {b : Ordinal} (b0 : b ≠ 0) (c) : (b * a + c) / b = a + c / b := by apply le_antisymm · apply (div_le b0).2 rw [mul_succ, mul_add, add_assoc, add_lt_add_iff_left] apply lt_mul_div_add _ b0 · rw [le_div b0, mul_add, add_le_add_iff_left] apply mul_div_le #align ordinal.mul_add_div Ordinal.mul_add_div theorem div_eq_zero_of_lt {a b : Ordinal} (h : a < b) : a / b = 0 := by rw [← Ordinal.le_zero, div_le <| Ordinal.pos_iff_ne_zero.1 <| (Ordinal.zero_le _).trans_lt h] simpa only [succ_zero, mul_one] using h #align ordinal.div_eq_zero_of_lt Ordinal.div_eq_zero_of_lt @[simp] theorem mul_div_cancel (a) {b : Ordinal} (b0 : b ≠ 0) : b * a / b = a := by simpa only [add_zero, zero_div] using mul_add_div a b0 0 #align ordinal.mul_div_cancel Ordinal.mul_div_cancel @[simp] theorem div_one (a : Ordinal) : a / 1 = a := by simpa only [one_mul] using mul_div_cancel a Ordinal.one_ne_zero #align ordinal.div_one Ordinal.div_one @[simp] theorem div_self {a : Ordinal} (h : a ≠ 0) : a / a = 1 := by simpa only [mul_one] using mul_div_cancel 1 h #align ordinal.div_self Ordinal.div_self theorem mul_sub (a b c : Ordinal) : a * (b - c) = a * b - a * c := if a0 : a = 0 then by simp only [a0, zero_mul, sub_self] else eq_of_forall_ge_iff fun d => by rw [sub_le, ← le_div a0, sub_le, ← le_div a0, mul_add_div _ a0] #align ordinal.mul_sub Ordinal.mul_sub theorem isLimit_add_iff {a b} : IsLimit (a + b) ↔ IsLimit b ∨ b = 0 ∧ IsLimit a := by constructor <;> intro h · by_cases h' : b = 0 · rw [h', add_zero] at h right exact ⟨h', h⟩ left rw [← add_sub_cancel a b] apply sub_isLimit h suffices a + 0 < a + b by simpa only [add_zero] using this rwa [add_lt_add_iff_left, Ordinal.pos_iff_ne_zero] rcases h with (h | ⟨rfl, h⟩) · exact add_isLimit a h · simpa only [add_zero] #align ordinal.is_limit_add_iff Ordinal.isLimit_add_iff theorem dvd_add_iff : ∀ {a b c : Ordinal}, a ∣ b → (a ∣ b + c ↔ a ∣ c) | a, _, c, ⟨b, rfl⟩ => ⟨fun ⟨d, e⟩ => ⟨d - b, by rw [mul_sub, ← e, add_sub_cancel]⟩, fun ⟨d, e⟩ => by rw [e, ← mul_add] apply dvd_mul_right⟩ #align ordinal.dvd_add_iff Ordinal.dvd_add_iff theorem div_mul_cancel : ∀ {a b : Ordinal}, a ≠ 0 → a ∣ b → a * (b / a) = b | a, _, a0, ⟨b, rfl⟩ => by rw [mul_div_cancel _ a0] #align ordinal.div_mul_cancel Ordinal.div_mul_cancel theorem le_of_dvd : ∀ {a b : Ordinal}, b ≠ 0 → a ∣ b → a ≤ b -- Porting note: `⟨b, rfl⟩ => by` → `⟨b, e⟩ => by subst e` | a, _, b0, ⟨b, e⟩ => by subst e -- Porting note: `Ne` is required. simpa only [mul_one] using mul_le_mul_left' (one_le_iff_ne_zero.2 fun h : b = 0 => by simp only [h, mul_zero, Ne, not_true_eq_false] at b0) a #align ordinal.le_of_dvd Ordinal.le_of_dvd theorem dvd_antisymm {a b : Ordinal} (h₁ : a ∣ b) (h₂ : b ∣ a) : a = b := if a0 : a = 0 then by subst a; exact (eq_zero_of_zero_dvd h₁).symm else if b0 : b = 0 then by subst b; exact eq_zero_of_zero_dvd h₂ else (le_of_dvd b0 h₁).antisymm (le_of_dvd a0 h₂) #align ordinal.dvd_antisymm Ordinal.dvd_antisymm instance isAntisymm : IsAntisymm Ordinal (· ∣ ·) := ⟨@dvd_antisymm⟩ instance mod : Mod Ordinal := ⟨fun a b => a - b * (a / b)⟩ theorem mod_def (a b : Ordinal) : a % b = a - b * (a / b) := rfl #align ordinal.mod_def Ordinal.mod_def theorem mod_le (a b : Ordinal) : a % b ≤ a := sub_le_self a _ #align ordinal.mod_le Ordinal.mod_le @[simp] theorem mod_zero (a : Ordinal) : a % 0 = a := by simp only [mod_def, div_zero, zero_mul, sub_zero] #align ordinal.mod_zero Ordinal.mod_zero theorem mod_eq_of_lt {a b : Ordinal} (h : a < b) : a % b = a := by simp only [mod_def, div_eq_zero_of_lt h, mul_zero, sub_zero] #align ordinal.mod_eq_of_lt Ordinal.mod_eq_of_lt @[simp] theorem zero_mod (b : Ordinal) : 0 % b = 0 := by simp only [mod_def, zero_div, mul_zero, sub_self] #align ordinal.zero_mod Ordinal.zero_mod theorem div_add_mod (a b : Ordinal) : b * (a / b) + a % b = a := Ordinal.add_sub_cancel_of_le <| mul_div_le _ _ #align ordinal.div_add_mod Ordinal.div_add_mod theorem mod_lt (a) {b : Ordinal} (h : b ≠ 0) : a % b < b := (add_lt_add_iff_left (b * (a / b))).1 <| by rw [div_add_mod]; exact lt_mul_div_add a h #align ordinal.mod_lt Ordinal.mod_lt @[simp] theorem mod_self (a : Ordinal) : a % a = 0 := if a0 : a = 0 then by simp only [a0, zero_mod] else by simp only [mod_def, div_self a0, mul_one, sub_self] #align ordinal.mod_self Ordinal.mod_self @[simp] theorem mod_one (a : Ordinal) : a % 1 = 0 := by simp only [mod_def, div_one, one_mul, sub_self] #align ordinal.mod_one Ordinal.mod_one theorem dvd_of_mod_eq_zero {a b : Ordinal} (H : a % b = 0) : b ∣ a := ⟨a / b, by simpa [H] using (div_add_mod a b).symm⟩ #align ordinal.dvd_of_mod_eq_zero Ordinal.dvd_of_mod_eq_zero theorem mod_eq_zero_of_dvd {a b : Ordinal} (H : b ∣ a) : a % b = 0 := by rcases H with ⟨c, rfl⟩ rcases eq_or_ne b 0 with (rfl | hb) · simp · simp [mod_def, hb] #align ordinal.mod_eq_zero_of_dvd Ordinal.mod_eq_zero_of_dvd theorem dvd_iff_mod_eq_zero {a b : Ordinal} : b ∣ a ↔ a % b = 0 := ⟨mod_eq_zero_of_dvd, dvd_of_mod_eq_zero⟩ #align ordinal.dvd_iff_mod_eq_zero Ordinal.dvd_iff_mod_eq_zero @[simp] theorem mul_add_mod_self (x y z : Ordinal) : (x * y + z) % x = z % x := by rcases eq_or_ne x 0 with rfl | hx · simp · rwa [mod_def, mul_add_div, mul_add, ← sub_sub, add_sub_cancel, mod_def] #align ordinal.mul_add_mod_self Ordinal.mul_add_mod_self @[simp] theorem mul_mod (x y : Ordinal) : x * y % x = 0 := by simpa using mul_add_mod_self x y 0 #align ordinal.mul_mod Ordinal.mul_mod theorem mod_mod_of_dvd (a : Ordinal) {b c : Ordinal} (h : c ∣ b) : a % b % c = a % c := by nth_rw 2 [← div_add_mod a b] rcases h with ⟨d, rfl⟩ rw [mul_assoc, mul_add_mod_self] #align ordinal.mod_mod_of_dvd Ordinal.mod_mod_of_dvd @[simp] theorem mod_mod (a b : Ordinal) : a % b % b = a % b := mod_mod_of_dvd a dvd_rfl #align ordinal.mod_mod Ordinal.mod_mod def bfamilyOfFamily' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] (f : ι → α) : ∀ a < type r, α := fun a ha => f (enum r a ha) #align ordinal.bfamily_of_family' Ordinal.bfamilyOfFamily' def bfamilyOfFamily {ι : Type u} : (ι → α) → ∀ a < type (@WellOrderingRel ι), α := bfamilyOfFamily' WellOrderingRel #align ordinal.bfamily_of_family Ordinal.bfamilyOfFamily def familyOfBFamily' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] {o} (ho : type r = o) (f : ∀ a < o, α) : ι → α := fun i => f (typein r i) (by rw [← ho] exact typein_lt_type r i) #align ordinal.family_of_bfamily' Ordinal.familyOfBFamily' def familyOfBFamily (o : Ordinal) (f : ∀ a < o, α) : o.out.α → α := familyOfBFamily' (· < ·) (type_lt o) f #align ordinal.family_of_bfamily Ordinal.familyOfBFamily @[simp] theorem bfamilyOfFamily'_typein {ι} (r : ι → ι → Prop) [IsWellOrder ι r] (f : ι → α) (i) : bfamilyOfFamily' r f (typein r i) (typein_lt_type r i) = f i := by simp only [bfamilyOfFamily', enum_typein] #align ordinal.bfamily_of_family'_typein Ordinal.bfamilyOfFamily'_typein @[simp] theorem bfamilyOfFamily_typein {ι} (f : ι → α) (i) : bfamilyOfFamily f (typein _ i) (typein_lt_type _ i) = f i := bfamilyOfFamily'_typein _ f i #align ordinal.bfamily_of_family_typein Ordinal.bfamilyOfFamily_typein @[simp, nolint simpNF] -- Porting note (#10959): simp cannot prove this theorem familyOfBFamily'_enum {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] {o} (ho : type r = o) (f : ∀ a < o, α) (i hi) : familyOfBFamily' r ho f (enum r i (by rwa [ho])) = f i hi := by simp only [familyOfBFamily', typein_enum] #align ordinal.family_of_bfamily'_enum Ordinal.familyOfBFamily'_enum @[simp, nolint simpNF] -- Porting note (#10959): simp cannot prove this theorem familyOfBFamily_enum (o : Ordinal) (f : ∀ a < o, α) (i hi) : familyOfBFamily o f (enum (· < ·) i (by convert hi exact type_lt _)) = f i hi := familyOfBFamily'_enum _ (type_lt o) f _ _ #align ordinal.family_of_bfamily_enum Ordinal.familyOfBFamily_enum def brange (o : Ordinal) (f : ∀ a < o, α) : Set α := { a | ∃ i hi, f i hi = a } #align ordinal.brange Ordinal.brange theorem mem_brange {o : Ordinal} {f : ∀ a < o, α} {a} : a ∈ brange o f ↔ ∃ i hi, f i hi = a := Iff.rfl #align ordinal.mem_brange Ordinal.mem_brange theorem mem_brange_self {o} (f : ∀ a < o, α) (i hi) : f i hi ∈ brange o f := ⟨i, hi, rfl⟩ #align ordinal.mem_brange_self Ordinal.mem_brange_self @[simp] theorem range_familyOfBFamily' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] {o} (ho : type r = o) (f : ∀ a < o, α) : range (familyOfBFamily' r ho f) = brange o f := by refine Set.ext fun a => ⟨?_, ?_⟩ · rintro ⟨b, rfl⟩ apply mem_brange_self · rintro ⟨i, hi, rfl⟩ exact ⟨_, familyOfBFamily'_enum _ _ _ _ _⟩ #align ordinal.range_family_of_bfamily' Ordinal.range_familyOfBFamily' @[simp] theorem range_familyOfBFamily {o} (f : ∀ a < o, α) : range (familyOfBFamily o f) = brange o f := range_familyOfBFamily' _ _ f #align ordinal.range_family_of_bfamily Ordinal.range_familyOfBFamily @[simp] theorem brange_bfamilyOfFamily' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] (f : ι → α) : brange _ (bfamilyOfFamily' r f) = range f := by refine Set.ext fun a => ⟨?_, ?_⟩ · rintro ⟨i, hi, rfl⟩ apply mem_range_self · rintro ⟨b, rfl⟩ exact ⟨_, _, bfamilyOfFamily'_typein _ _ _⟩ #align ordinal.brange_bfamily_of_family' Ordinal.brange_bfamilyOfFamily' @[simp] theorem brange_bfamilyOfFamily {ι : Type u} (f : ι → α) : brange _ (bfamilyOfFamily f) = range f := brange_bfamilyOfFamily' _ _ #align ordinal.brange_bfamily_of_family Ordinal.brange_bfamilyOfFamily @[simp] theorem brange_const {o : Ordinal} (ho : o ≠ 0) {c : α} : (brange o fun _ _ => c) = {c} := by rw [← range_familyOfBFamily] exact @Set.range_const _ o.out.α (out_nonempty_iff_ne_zero.2 ho) c #align ordinal.brange_const Ordinal.brange_const theorem comp_bfamilyOfFamily' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] (f : ι → α) (g : α → β) : (fun i hi => g (bfamilyOfFamily' r f i hi)) = bfamilyOfFamily' r (g ∘ f) := rfl #align ordinal.comp_bfamily_of_family' Ordinal.comp_bfamilyOfFamily' theorem comp_bfamilyOfFamily {ι : Type u} (f : ι → α) (g : α → β) : (fun i hi => g (bfamilyOfFamily f i hi)) = bfamilyOfFamily (g ∘ f) := rfl #align ordinal.comp_bfamily_of_family Ordinal.comp_bfamilyOfFamily theorem comp_familyOfBFamily' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] {o} (ho : type r = o) (f : ∀ a < o, α) (g : α → β) : g ∘ familyOfBFamily' r ho f = familyOfBFamily' r ho fun i hi => g (f i hi) := rfl #align ordinal.comp_family_of_bfamily' Ordinal.comp_familyOfBFamily' theorem comp_familyOfBFamily {o} (f : ∀ a < o, α) (g : α → β) : g ∘ familyOfBFamily o f = familyOfBFamily o fun i hi => g (f i hi) := rfl #align ordinal.comp_family_of_bfamily Ordinal.comp_familyOfBFamily -- Porting note: Universes should be specified in `sup`s. def sup {ι : Type u} (f : ι → Ordinal.{max u v}) : Ordinal.{max u v} := iSup f #align ordinal.sup Ordinal.sup @[simp] theorem sSup_eq_sup {ι : Type u} (f : ι → Ordinal.{max u v}) : sSup (Set.range f) = sup.{_, v} f := rfl #align ordinal.Sup_eq_sup Ordinal.sSup_eq_sup theorem bddAbove_range {ι : Type u} (f : ι → Ordinal.{max u v}) : BddAbove (Set.range f) := ⟨(iSup (succ ∘ card ∘ f)).ord, by rintro a ⟨i, rfl⟩ exact le_of_lt (Cardinal.lt_ord.2 ((lt_succ _).trans_le (le_ciSup (Cardinal.bddAbove_range.{_, v} _) _)))⟩ #align ordinal.bdd_above_range Ordinal.bddAbove_range theorem le_sup {ι : Type u} (f : ι → Ordinal.{max u v}) : ∀ i, f i ≤ sup.{_, v} f := fun i => le_csSup (bddAbove_range.{_, v} f) (mem_range_self i) #align ordinal.le_sup Ordinal.le_sup theorem sup_le_iff {ι : Type u} {f : ι → Ordinal.{max u v}} {a} : sup.{_, v} f ≤ a ↔ ∀ i, f i ≤ a := (csSup_le_iff' (bddAbove_range.{_, v} f)).trans (by simp) #align ordinal.sup_le_iff Ordinal.sup_le_iff theorem sup_le {ι : Type u} {f : ι → Ordinal.{max u v}} {a} : (∀ i, f i ≤ a) → sup.{_, v} f ≤ a := sup_le_iff.2 #align ordinal.sup_le Ordinal.sup_le theorem lt_sup {ι : Type u} {f : ι → Ordinal.{max u v}} {a} : a < sup.{_, v} f ↔ ∃ i, a < f i := by simpa only [not_forall, not_le] using not_congr (@sup_le_iff.{_, v} _ f a) #align ordinal.lt_sup Ordinal.lt_sup theorem ne_sup_iff_lt_sup {ι : Type u} {f : ι → Ordinal.{max u v}} : (∀ i, f i ≠ sup.{_, v} f) ↔ ∀ i, f i < sup.{_, v} f := ⟨fun hf _ => lt_of_le_of_ne (le_sup _ _) (hf _), fun hf _ => ne_of_lt (hf _)⟩ #align ordinal.ne_sup_iff_lt_sup Ordinal.ne_sup_iff_lt_sup theorem sup_not_succ_of_ne_sup {ι : Type u} {f : ι → Ordinal.{max u v}} (hf : ∀ i, f i ≠ sup.{_, v} f) {a} (hao : a < sup.{_, v} f) : succ a < sup.{_, v} f := by by_contra! hoa exact hao.not_le (sup_le fun i => le_of_lt_succ <| (lt_of_le_of_ne (le_sup _ _) (hf i)).trans_le hoa) #align ordinal.sup_not_succ_of_ne_sup Ordinal.sup_not_succ_of_ne_sup @[simp] theorem sup_eq_zero_iff {ι : Type u} {f : ι → Ordinal.{max u v}} : sup.{_, v} f = 0 ↔ ∀ i, f i = 0 := by refine ⟨fun h i => ?_, fun h => le_antisymm (sup_le fun i => Ordinal.le_zero.2 (h i)) (Ordinal.zero_le _)⟩ rw [← Ordinal.le_zero, ← h] exact le_sup f i #align ordinal.sup_eq_zero_iff Ordinal.sup_eq_zero_iff theorem IsNormal.sup {f : Ordinal.{max u v} → Ordinal.{max u w}} (H : IsNormal f) {ι : Type u} (g : ι → Ordinal.{max u v}) [Nonempty ι] : f (sup.{_, v} g) = sup.{_, w} (f ∘ g) := eq_of_forall_ge_iff fun a => by rw [sup_le_iff]; simp only [comp]; rw [H.le_set' Set.univ Set.univ_nonempty g] <;> simp [sup_le_iff] #align ordinal.is_normal.sup Ordinal.IsNormal.sup @[simp] theorem sup_empty {ι} [IsEmpty ι] (f : ι → Ordinal) : sup f = 0 := ciSup_of_empty f #align ordinal.sup_empty Ordinal.sup_empty @[simp] theorem sup_const {ι} [_hι : Nonempty ι] (o : Ordinal) : (sup fun _ : ι => o) = o := ciSup_const #align ordinal.sup_const Ordinal.sup_const @[simp] theorem sup_unique {ι} [Unique ι] (f : ι → Ordinal) : sup f = f default := ciSup_unique #align ordinal.sup_unique Ordinal.sup_unique theorem sup_le_of_range_subset {ι ι'} {f : ι → Ordinal} {g : ι' → Ordinal} (h : Set.range f ⊆ Set.range g) : sup.{u, max v w} f ≤ sup.{v, max u w} g := sup_le fun i => match h (mem_range_self i) with | ⟨_j, hj⟩ => hj ▸ le_sup _ _ #align ordinal.sup_le_of_range_subset Ordinal.sup_le_of_range_subset theorem sup_eq_of_range_eq {ι ι'} {f : ι → Ordinal} {g : ι' → Ordinal} (h : Set.range f = Set.range g) : sup.{u, max v w} f = sup.{v, max u w} g := (sup_le_of_range_subset.{u, v, w} h.le).antisymm (sup_le_of_range_subset.{v, u, w} h.ge) #align ordinal.sup_eq_of_range_eq Ordinal.sup_eq_of_range_eq @[simp] theorem sup_sum {α : Type u} {β : Type v} (f : Sum α β → Ordinal) : sup.{max u v, w} f = max (sup.{u, max v w} fun a => f (Sum.inl a)) (sup.{v, max u w} fun b => f (Sum.inr b)) := by apply (sup_le_iff.2 _).antisymm (max_le_iff.2 ⟨_, _⟩) · rintro (i | i) · exact le_max_of_le_left (le_sup _ i) · exact le_max_of_le_right (le_sup _ i) all_goals apply sup_le_of_range_subset.{_, max u v, w} rintro i ⟨a, rfl⟩ apply mem_range_self #align ordinal.sup_sum Ordinal.sup_sum theorem unbounded_range_of_sup_ge {α β : Type u} (r : α → α → Prop) [IsWellOrder α r] (f : β → α) (h : type r ≤ sup.{u, u} (typein r ∘ f)) : Unbounded r (range f) := (not_bounded_iff _).1 fun ⟨x, hx⟩ => not_lt_of_le h <| lt_of_le_of_lt (sup_le fun y => le_of_lt <| (typein_lt_typein r).2 <| hx _ <| mem_range_self y) (typein_lt_type r x) #align ordinal.unbounded_range_of_sup_ge Ordinal.unbounded_range_of_sup_ge theorem le_sup_shrink_equiv {s : Set Ordinal.{u}} (hs : Small.{u} s) (a) (ha : a ∈ s) : a ≤ sup.{u, u} fun x => ((@equivShrink s hs).symm x).val := by convert le_sup.{u, u} (fun x => ((@equivShrink s hs).symm x).val) ((@equivShrink s hs) ⟨a, ha⟩) rw [symm_apply_apply] #align ordinal.le_sup_shrink_equiv Ordinal.le_sup_shrink_equiv instance small_Iio (o : Ordinal.{u}) : Small.{u} (Set.Iio o) := let f : o.out.α → Set.Iio o := fun x => ⟨typein ((· < ·) : o.out.α → o.out.α → Prop) x, typein_lt_self x⟩ let hf : Surjective f := fun b => ⟨enum (· < ·) b.val (by rw [type_lt] exact b.prop), Subtype.ext (typein_enum _ _)⟩ small_of_surjective hf #align ordinal.small_Iio Ordinal.small_Iio instance small_Iic (o : Ordinal.{u}) : Small.{u} (Set.Iic o) := by rw [← Iio_succ] infer_instance #align ordinal.small_Iic Ordinal.small_Iic theorem bddAbove_iff_small {s : Set Ordinal.{u}} : BddAbove s ↔ Small.{u} s := ⟨fun ⟨a, h⟩ => small_subset <| show s ⊆ Iic a from fun _x hx => h hx, fun h => ⟨sup.{u, u} fun x => ((@equivShrink s h).symm x).val, le_sup_shrink_equiv h⟩⟩ #align ordinal.bdd_above_iff_small Ordinal.bddAbove_iff_small theorem bddAbove_of_small (s : Set Ordinal.{u}) [h : Small.{u} s] : BddAbove s := bddAbove_iff_small.2 h #align ordinal.bdd_above_of_small Ordinal.bddAbove_of_small theorem sup_eq_sSup {s : Set Ordinal.{u}} (hs : Small.{u} s) : (sup.{u, u} fun x => (@equivShrink s hs).symm x) = sSup s := let hs' := bddAbove_iff_small.2 hs ((csSup_le_iff' hs').2 (le_sup_shrink_equiv hs)).antisymm' (sup_le fun _x => le_csSup hs' (Subtype.mem _)) #align ordinal.sup_eq_Sup Ordinal.sup_eq_sSup theorem sSup_ord {s : Set Cardinal.{u}} (hs : BddAbove s) : (sSup s).ord = sSup (ord '' s) := eq_of_forall_ge_iff fun a => by rw [csSup_le_iff' (bddAbove_iff_small.2 (@small_image _ _ _ s (Cardinal.bddAbove_iff_small.1 hs))), ord_le, csSup_le_iff' hs] simp [ord_le] #align ordinal.Sup_ord Ordinal.sSup_ord theorem iSup_ord {ι} {f : ι → Cardinal} (hf : BddAbove (range f)) : (iSup f).ord = ⨆ i, (f i).ord := by unfold iSup convert sSup_ord hf -- Porting note: `change` is required. conv_lhs => change range (ord ∘ f) rw [range_comp] #align ordinal.supr_ord Ordinal.iSup_ord private theorem sup_le_sup {ι ι' : Type u} (r : ι → ι → Prop) (r' : ι' → ι' → Prop) [IsWellOrder ι r] [IsWellOrder ι' r'] {o} (ho : type r = o) (ho' : type r' = o) (f : ∀ a < o, Ordinal.{max u v}) : sup.{_, v} (familyOfBFamily' r ho f) ≤ sup.{_, v} (familyOfBFamily' r' ho' f) := sup_le fun i => by cases' typein_surj r' (by rw [ho', ← ho] exact typein_lt_type r i) with j hj simp_rw [familyOfBFamily', ← hj] apply le_sup theorem sup_eq_sup {ι ι' : Type u} (r : ι → ι → Prop) (r' : ι' → ι' → Prop) [IsWellOrder ι r] [IsWellOrder ι' r'] {o : Ordinal.{u}} (ho : type r = o) (ho' : type r' = o) (f : ∀ a < o, Ordinal.{max u v}) : sup.{_, v} (familyOfBFamily' r ho f) = sup.{_, v} (familyOfBFamily' r' ho' f) := sup_eq_of_range_eq.{u, u, v} (by simp) #align ordinal.sup_eq_sup Ordinal.sup_eq_sup def bsup (o : Ordinal.{u}) (f : ∀ a < o, Ordinal.{max u v}) : Ordinal.{max u v} := sup.{_, v} (familyOfBFamily o f) #align ordinal.bsup Ordinal.bsup @[simp] theorem sup_eq_bsup {o : Ordinal.{u}} (f : ∀ a < o, Ordinal.{max u v}) : sup.{_, v} (familyOfBFamily o f) = bsup.{_, v} o f := rfl #align ordinal.sup_eq_bsup Ordinal.sup_eq_bsup @[simp] theorem sup_eq_bsup' {o : Ordinal.{u}} {ι} (r : ι → ι → Prop) [IsWellOrder ι r] (ho : type r = o) (f : ∀ a < o, Ordinal.{max u v}) : sup.{_, v} (familyOfBFamily' r ho f) = bsup.{_, v} o f := sup_eq_sup r _ ho _ f #align ordinal.sup_eq_bsup' Ordinal.sup_eq_bsup' @[simp, nolint simpNF] -- Porting note (#10959): simp cannot prove this theorem sSup_eq_bsup {o : Ordinal.{u}} (f : ∀ a < o, Ordinal.{max u v}) : sSup (brange o f) = bsup.{_, v} o f := by congr rw [range_familyOfBFamily] #align ordinal.Sup_eq_bsup Ordinal.sSup_eq_bsup @[simp] theorem bsup_eq_sup' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] (f : ι → Ordinal.{max u v}) : bsup.{_, v} _ (bfamilyOfFamily' r f) = sup.{_, v} f := by simp (config := { unfoldPartialApp := true }) only [← sup_eq_bsup' r, enum_typein, familyOfBFamily', bfamilyOfFamily'] #align ordinal.bsup_eq_sup' Ordinal.bsup_eq_sup' theorem bsup_eq_bsup {ι : Type u} (r r' : ι → ι → Prop) [IsWellOrder ι r] [IsWellOrder ι r'] (f : ι → Ordinal.{max u v}) : bsup.{_, v} _ (bfamilyOfFamily' r f) = bsup.{_, v} _ (bfamilyOfFamily' r' f) := by rw [bsup_eq_sup', bsup_eq_sup'] #align ordinal.bsup_eq_bsup Ordinal.bsup_eq_bsup @[simp] theorem bsup_eq_sup {ι : Type u} (f : ι → Ordinal.{max u v}) : bsup.{_, v} _ (bfamilyOfFamily f) = sup.{_, v} f := bsup_eq_sup' _ f #align ordinal.bsup_eq_sup Ordinal.bsup_eq_sup @[congr] theorem bsup_congr {o₁ o₂ : Ordinal.{u}} (f : ∀ a < o₁, Ordinal.{max u v}) (ho : o₁ = o₂) : bsup.{_, v} o₁ f = bsup.{_, v} o₂ fun a h => f a (h.trans_eq ho.symm) := by subst ho -- Porting note: `rfl` is required. rfl #align ordinal.bsup_congr Ordinal.bsup_congr theorem bsup_le_iff {o f a} : bsup.{u, v} o f ≤ a ↔ ∀ i h, f i h ≤ a := sup_le_iff.trans ⟨fun h i hi => by rw [← familyOfBFamily_enum o f] exact h _, fun h i => h _ _⟩ #align ordinal.bsup_le_iff Ordinal.bsup_le_iff theorem bsup_le {o : Ordinal} {f : ∀ b < o, Ordinal} {a} : (∀ i h, f i h ≤ a) → bsup.{u, v} o f ≤ a := bsup_le_iff.2 #align ordinal.bsup_le Ordinal.bsup_le theorem le_bsup {o} (f : ∀ a < o, Ordinal) (i h) : f i h ≤ bsup o f := bsup_le_iff.1 le_rfl _ _ #align ordinal.le_bsup Ordinal.le_bsup theorem lt_bsup {o : Ordinal.{u}} (f : ∀ a < o, Ordinal.{max u v}) {a} : a < bsup.{_, v} o f ↔ ∃ i hi, a < f i hi := by simpa only [not_forall, not_le] using not_congr (@bsup_le_iff.{_, v} _ f a) #align ordinal.lt_bsup Ordinal.lt_bsup theorem IsNormal.bsup {f : Ordinal.{max u v} → Ordinal.{max u w}} (H : IsNormal f) {o : Ordinal.{u}} : ∀ (g : ∀ a < o, Ordinal), o ≠ 0 → f (bsup.{_, v} o g) = bsup.{_, w} o fun a h => f (g a h) := inductionOn o fun α r _ g h => by haveI := type_ne_zero_iff_nonempty.1 h rw [← sup_eq_bsup' r, IsNormal.sup.{_, v, w} H, ← sup_eq_bsup' r] <;> rfl #align ordinal.is_normal.bsup Ordinal.IsNormal.bsup theorem lt_bsup_of_ne_bsup {o : Ordinal.{u}} {f : ∀ a < o, Ordinal.{max u v}} : (∀ i h, f i h ≠ bsup.{_, v} o f) ↔ ∀ i h, f i h < bsup.{_, v} o f := ⟨fun hf _ _ => lt_of_le_of_ne (le_bsup _ _ _) (hf _ _), fun hf _ _ => ne_of_lt (hf _ _)⟩ #align ordinal.lt_bsup_of_ne_bsup Ordinal.lt_bsup_of_ne_bsup theorem bsup_not_succ_of_ne_bsup {o : Ordinal.{u}} {f : ∀ a < o, Ordinal.{max u v}} (hf : ∀ {i : Ordinal} (h : i < o), f i h ≠ bsup.{_, v} o f) (a) : a < bsup.{_, v} o f → succ a < bsup.{_, v} o f := by rw [← sup_eq_bsup] at * exact sup_not_succ_of_ne_sup fun i => hf _ #align ordinal.bsup_not_succ_of_ne_bsup Ordinal.bsup_not_succ_of_ne_bsup @[simp] theorem bsup_eq_zero_iff {o} {f : ∀ a < o, Ordinal} : bsup o f = 0 ↔ ∀ i hi, f i hi = 0 := by refine ⟨fun h i hi => ?_, fun h => le_antisymm (bsup_le fun i hi => Ordinal.le_zero.2 (h i hi)) (Ordinal.zero_le _)⟩ rw [← Ordinal.le_zero, ← h] exact le_bsup f i hi #align ordinal.bsup_eq_zero_iff Ordinal.bsup_eq_zero_iff theorem lt_bsup_of_limit {o : Ordinal} {f : ∀ a < o, Ordinal} (hf : ∀ {a a'} (ha : a < o) (ha' : a' < o), a < a' → f a ha < f a' ha') (ho : ∀ a < o, succ a < o) (i h) : f i h < bsup o f := (hf _ _ <| lt_succ i).trans_le (le_bsup f (succ i) <| ho _ h) #align ordinal.lt_bsup_of_limit Ordinal.lt_bsup_of_limit theorem bsup_succ_of_mono {o : Ordinal} {f : ∀ a < succ o, Ordinal} (hf : ∀ {i j} (hi hj), i ≤ j → f i hi ≤ f j hj) : bsup _ f = f o (lt_succ o) := le_antisymm (bsup_le fun _i hi => hf _ _ <| le_of_lt_succ hi) (le_bsup _ _ _) #align ordinal.bsup_succ_of_mono Ordinal.bsup_succ_of_mono @[simp] theorem bsup_zero (f : ∀ a < (0 : Ordinal), Ordinal) : bsup 0 f = 0 := bsup_eq_zero_iff.2 fun i hi => (Ordinal.not_lt_zero i hi).elim #align ordinal.bsup_zero Ordinal.bsup_zero theorem bsup_const {o : Ordinal.{u}} (ho : o ≠ 0) (a : Ordinal.{max u v}) : (bsup.{_, v} o fun _ _ => a) = a := le_antisymm (bsup_le fun _ _ => le_rfl) (le_bsup _ 0 (Ordinal.pos_iff_ne_zero.2 ho)) #align ordinal.bsup_const Ordinal.bsup_const @[simp] theorem bsup_one (f : ∀ a < (1 : Ordinal), Ordinal) : bsup 1 f = f 0 zero_lt_one := by simp_rw [← sup_eq_bsup, sup_unique, familyOfBFamily, familyOfBFamily', typein_one_out] #align ordinal.bsup_one Ordinal.bsup_one theorem bsup_le_of_brange_subset {o o'} {f : ∀ a < o, Ordinal} {g : ∀ a < o', Ordinal} (h : brange o f ⊆ brange o' g) : bsup.{u, max v w} o f ≤ bsup.{v, max u w} o' g := bsup_le fun i hi => by obtain ⟨j, hj, hj'⟩ := h ⟨i, hi, rfl⟩ rw [← hj'] apply le_bsup #align ordinal.bsup_le_of_brange_subset Ordinal.bsup_le_of_brange_subset theorem bsup_eq_of_brange_eq {o o'} {f : ∀ a < o, Ordinal} {g : ∀ a < o', Ordinal} (h : brange o f = brange o' g) : bsup.{u, max v w} o f = bsup.{v, max u w} o' g := (bsup_le_of_brange_subset.{u, v, w} h.le).antisymm (bsup_le_of_brange_subset.{v, u, w} h.ge) #align ordinal.bsup_eq_of_brange_eq Ordinal.bsup_eq_of_brange_eq def lsub {ι} (f : ι → Ordinal) : Ordinal := sup (succ ∘ f) #align ordinal.lsub Ordinal.lsub @[simp] theorem sup_eq_lsub {ι : Type u} (f : ι → Ordinal.{max u v}) : sup.{_, v} (succ ∘ f) = lsub.{_, v} f := rfl #align ordinal.sup_eq_lsub Ordinal.sup_eq_lsub theorem lsub_le_iff {ι : Type u} {f : ι → Ordinal.{max u v}} {a} : lsub.{_, v} f ≤ a ↔ ∀ i, f i < a := by convert sup_le_iff.{_, v} (f := succ ∘ f) (a := a) using 2 -- Porting note: `comp_apply` is required. simp only [comp_apply, succ_le_iff] #align ordinal.lsub_le_iff Ordinal.lsub_le_iff theorem lsub_le {ι} {f : ι → Ordinal} {a} : (∀ i, f i < a) → lsub f ≤ a := lsub_le_iff.2 #align ordinal.lsub_le Ordinal.lsub_le theorem lt_lsub {ι} (f : ι → Ordinal) (i) : f i < lsub f := succ_le_iff.1 (le_sup _ i) #align ordinal.lt_lsub Ordinal.lt_lsub theorem lt_lsub_iff {ι : Type u} {f : ι → Ordinal.{max u v}} {a} : a < lsub.{_, v} f ↔ ∃ i, a ≤ f i := by simpa only [not_forall, not_lt, not_le] using not_congr (@lsub_le_iff.{_, v} _ f a) #align ordinal.lt_lsub_iff Ordinal.lt_lsub_iff theorem sup_le_lsub {ι : Type u} (f : ι → Ordinal.{max u v}) : sup.{_, v} f ≤ lsub.{_, v} f := sup_le fun i => (lt_lsub f i).le #align ordinal.sup_le_lsub Ordinal.sup_le_lsub theorem lsub_le_sup_succ {ι : Type u} (f : ι → Ordinal.{max u v}) : lsub.{_, v} f ≤ succ (sup.{_, v} f) := lsub_le fun i => lt_succ_iff.2 (le_sup f i) #align ordinal.lsub_le_sup_succ Ordinal.lsub_le_sup_succ theorem sup_eq_lsub_or_sup_succ_eq_lsub {ι : Type u} (f : ι → Ordinal.{max u v}) : sup.{_, v} f = lsub.{_, v} f ∨ succ (sup.{_, v} f) = lsub.{_, v} f := by cases' eq_or_lt_of_le (sup_le_lsub.{_, v} f) with h h · exact Or.inl h · exact Or.inr ((succ_le_of_lt h).antisymm (lsub_le_sup_succ f)) #align ordinal.sup_eq_lsub_or_sup_succ_eq_lsub Ordinal.sup_eq_lsub_or_sup_succ_eq_lsub theorem sup_succ_le_lsub {ι : Type u} (f : ι → Ordinal.{max u v}) : succ (sup.{_, v} f) ≤ lsub.{_, v} f ↔ ∃ i, f i = sup.{_, v} f := by refine ⟨fun h => ?_, ?_⟩ · by_contra! hf exact (succ_le_iff.1 h).ne ((sup_le_lsub f).antisymm (lsub_le (ne_sup_iff_lt_sup.1 hf))) rintro ⟨_, hf⟩ rw [succ_le_iff, ← hf] exact lt_lsub _ _ #align ordinal.sup_succ_le_lsub Ordinal.sup_succ_le_lsub theorem sup_succ_eq_lsub {ι : Type u} (f : ι → Ordinal.{max u v}) : succ (sup.{_, v} f) = lsub.{_, v} f ↔ ∃ i, f i = sup.{_, v} f := (lsub_le_sup_succ f).le_iff_eq.symm.trans (sup_succ_le_lsub f) #align ordinal.sup_succ_eq_lsub Ordinal.sup_succ_eq_lsub theorem sup_eq_lsub_iff_succ {ι : Type u} (f : ι → Ordinal.{max u v}) : sup.{_, v} f = lsub.{_, v} f ↔ ∀ a < lsub.{_, v} f, succ a < lsub.{_, v} f := by refine ⟨fun h => ?_, fun hf => le_antisymm (sup_le_lsub f) (lsub_le fun i => ?_)⟩ · rw [← h] exact fun a => sup_not_succ_of_ne_sup fun i => (lsub_le_iff.1 (le_of_eq h.symm) i).ne by_contra! hle have heq := (sup_succ_eq_lsub f).2 ⟨i, le_antisymm (le_sup _ _) hle⟩ have := hf _ (by rw [← heq] exact lt_succ (sup f)) rw [heq] at this exact this.false #align ordinal.sup_eq_lsub_iff_succ Ordinal.sup_eq_lsub_iff_succ theorem sup_eq_lsub_iff_lt_sup {ι : Type u} (f : ι → Ordinal.{max u v}) : sup.{_, v} f = lsub.{_, v} f ↔ ∀ i, f i < sup.{_, v} f := ⟨fun h i => by rw [h] apply lt_lsub, fun h => le_antisymm (sup_le_lsub f) (lsub_le h)⟩ #align ordinal.sup_eq_lsub_iff_lt_sup Ordinal.sup_eq_lsub_iff_lt_sup @[simp] theorem lsub_empty {ι} [h : IsEmpty ι] (f : ι → Ordinal) : lsub f = 0 := by rw [← Ordinal.le_zero, lsub_le_iff] exact h.elim #align ordinal.lsub_empty Ordinal.lsub_empty theorem lsub_pos {ι : Type u} [h : Nonempty ι] (f : ι → Ordinal.{max u v}) : 0 < lsub.{_, v} f := h.elim fun i => (Ordinal.zero_le _).trans_lt (lt_lsub f i) #align ordinal.lsub_pos Ordinal.lsub_pos @[simp] theorem lsub_eq_zero_iff {ι : Type u} (f : ι → Ordinal.{max u v}) : lsub.{_, v} f = 0 ↔ IsEmpty ι := by refine ⟨fun h => ⟨fun i => ?_⟩, fun h => @lsub_empty _ h _⟩ have := @lsub_pos.{_, v} _ ⟨i⟩ f rw [h] at this exact this.false #align ordinal.lsub_eq_zero_iff Ordinal.lsub_eq_zero_iff @[simp] theorem lsub_const {ι} [Nonempty ι] (o : Ordinal) : (lsub fun _ : ι => o) = succ o := sup_const (succ o) #align ordinal.lsub_const Ordinal.lsub_const @[simp] theorem lsub_unique {ι} [Unique ι] (f : ι → Ordinal) : lsub f = succ (f default) := sup_unique _ #align ordinal.lsub_unique Ordinal.lsub_unique theorem lsub_le_of_range_subset {ι ι'} {f : ι → Ordinal} {g : ι' → Ordinal} (h : Set.range f ⊆ Set.range g) : lsub.{u, max v w} f ≤ lsub.{v, max u w} g := sup_le_of_range_subset.{u, v, w} (by convert Set.image_subset succ h <;> apply Set.range_comp) #align ordinal.lsub_le_of_range_subset Ordinal.lsub_le_of_range_subset theorem lsub_eq_of_range_eq {ι ι'} {f : ι → Ordinal} {g : ι' → Ordinal} (h : Set.range f = Set.range g) : lsub.{u, max v w} f = lsub.{v, max u w} g := (lsub_le_of_range_subset.{u, v, w} h.le).antisymm (lsub_le_of_range_subset.{v, u, w} h.ge) #align ordinal.lsub_eq_of_range_eq Ordinal.lsub_eq_of_range_eq @[simp] theorem lsub_sum {α : Type u} {β : Type v} (f : Sum α β → Ordinal) : lsub.{max u v, w} f = max (lsub.{u, max v w} fun a => f (Sum.inl a)) (lsub.{v, max u w} fun b => f (Sum.inr b)) := sup_sum _ #align ordinal.lsub_sum Ordinal.lsub_sum theorem lsub_not_mem_range {ι : Type u} (f : ι → Ordinal.{max u v}) : lsub.{_, v} f ∉ Set.range f := fun ⟨i, h⟩ => h.not_lt (lt_lsub f i) #align ordinal.lsub_not_mem_range Ordinal.lsub_not_mem_range theorem nonempty_compl_range {ι : Type u} (f : ι → Ordinal.{max u v}) : (Set.range f)ᶜ.Nonempty := ⟨_, lsub_not_mem_range.{_, v} f⟩ #align ordinal.nonempty_compl_range Ordinal.nonempty_compl_range @[simp] theorem lsub_typein (o : Ordinal) : lsub.{u, u} (typein ((· < ·) : o.out.α → o.out.α → Prop)) = o := (lsub_le.{u, u} typein_lt_self).antisymm (by by_contra! h -- Porting note: `nth_rw` → `conv_rhs` & `rw` conv_rhs at h => rw [← type_lt o] simpa [typein_enum] using lt_lsub.{u, u} (typein (· < ·)) (enum (· < ·) _ h)) #align ordinal.lsub_typein Ordinal.lsub_typein theorem sup_typein_limit {o : Ordinal} (ho : ∀ a, a < o → succ a < o) : sup.{u, u} (typein ((· < ·) : o.out.α → o.out.α → Prop)) = o := by -- Porting note: `rwa` → `rw` & `assumption` rw [(sup_eq_lsub_iff_succ.{u, u} (typein (· < ·))).2] <;> rw [lsub_typein o]; assumption #align ordinal.sup_typein_limit Ordinal.sup_typein_limit @[simp] theorem sup_typein_succ {o : Ordinal} : sup.{u, u} (typein ((· < ·) : (succ o).out.α → (succ o).out.α → Prop)) = o := by cases' sup_eq_lsub_or_sup_succ_eq_lsub.{u, u} (typein ((· < ·) : (succ o).out.α → (succ o).out.α → Prop)) with h h · rw [sup_eq_lsub_iff_succ] at h simp only [lsub_typein] at h exact (h o (lt_succ o)).false.elim rw [← succ_eq_succ_iff, h] apply lsub_typein #align ordinal.sup_typein_succ Ordinal.sup_typein_succ def blsub (o : Ordinal.{u}) (f : ∀ a < o, Ordinal.{max u v}) : Ordinal.{max u v} := bsup.{_, v} o fun a ha => succ (f a ha) #align ordinal.blsub Ordinal.blsub @[simp] theorem bsup_eq_blsub (o : Ordinal.{u}) (f : ∀ a < o, Ordinal.{max u v}) : (bsup.{_, v} o fun a ha => succ (f a ha)) = blsub.{_, v} o f := rfl #align ordinal.bsup_eq_blsub Ordinal.bsup_eq_blsub theorem lsub_eq_blsub' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] {o} (ho : type r = o) (f : ∀ a < o, Ordinal.{max u v}) : lsub.{_, v} (familyOfBFamily' r ho f) = blsub.{_, v} o f := sup_eq_bsup'.{_, v} r ho fun a ha => succ (f a ha) #align ordinal.lsub_eq_blsub' Ordinal.lsub_eq_blsub' theorem lsub_eq_lsub {ι ι' : Type u} (r : ι → ι → Prop) (r' : ι' → ι' → Prop) [IsWellOrder ι r] [IsWellOrder ι' r'] {o} (ho : type r = o) (ho' : type r' = o) (f : ∀ a < o, Ordinal.{max u v}) : lsub.{_, v} (familyOfBFamily' r ho f) = lsub.{_, v} (familyOfBFamily' r' ho' f) := by rw [lsub_eq_blsub', lsub_eq_blsub'] #align ordinal.lsub_eq_lsub Ordinal.lsub_eq_lsub @[simp] theorem lsub_eq_blsub {o : Ordinal.{u}} (f : ∀ a < o, Ordinal.{max u v}) : lsub.{_, v} (familyOfBFamily o f) = blsub.{_, v} o f := lsub_eq_blsub' _ _ _ #align ordinal.lsub_eq_blsub Ordinal.lsub_eq_blsub @[simp] theorem blsub_eq_lsub' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] (f : ι → Ordinal.{max u v}) : blsub.{_, v} _ (bfamilyOfFamily' r f) = lsub.{_, v} f := bsup_eq_sup'.{_, v} r (succ ∘ f) #align ordinal.blsub_eq_lsub' Ordinal.blsub_eq_lsub' theorem blsub_eq_blsub {ι : Type u} (r r' : ι → ι → Prop) [IsWellOrder ι r] [IsWellOrder ι r'] (f : ι → Ordinal.{max u v}) : blsub.{_, v} _ (bfamilyOfFamily' r f) = blsub.{_, v} _ (bfamilyOfFamily' r' f) := by rw [blsub_eq_lsub', blsub_eq_lsub'] #align ordinal.blsub_eq_blsub Ordinal.blsub_eq_blsub @[simp] theorem blsub_eq_lsub {ι : Type u} (f : ι → Ordinal.{max u v}) : blsub.{_, v} _ (bfamilyOfFamily f) = lsub.{_, v} f := blsub_eq_lsub' _ _ #align ordinal.blsub_eq_lsub Ordinal.blsub_eq_lsub @[congr] theorem blsub_congr {o₁ o₂ : Ordinal.{u}} (f : ∀ a < o₁, Ordinal.{max u v}) (ho : o₁ = o₂) : blsub.{_, v} o₁ f = blsub.{_, v} o₂ fun a h => f a (h.trans_eq ho.symm) := by subst ho -- Porting note: `rfl` is required. rfl #align ordinal.blsub_congr Ordinal.blsub_congr theorem blsub_le_iff {o : Ordinal.{u}} {f : ∀ a < o, Ordinal.{max u v}} {a} : blsub.{_, v} o f ≤ a ↔ ∀ i h, f i h < a := by convert bsup_le_iff.{_, v} (f := fun a ha => succ (f a ha)) (a := a) using 2 simp_rw [succ_le_iff] #align ordinal.blsub_le_iff Ordinal.blsub_le_iff theorem blsub_le {o : Ordinal} {f : ∀ b < o, Ordinal} {a} : (∀ i h, f i h < a) → blsub o f ≤ a := blsub_le_iff.2 #align ordinal.blsub_le Ordinal.blsub_le theorem lt_blsub {o} (f : ∀ a < o, Ordinal) (i h) : f i h < blsub o f := blsub_le_iff.1 le_rfl _ _ #align ordinal.lt_blsub Ordinal.lt_blsub theorem lt_blsub_iff {o : Ordinal.{u}} {f : ∀ b < o, Ordinal.{max u v}} {a} : a < blsub.{_, v} o f ↔ ∃ i hi, a ≤ f i hi := by simpa only [not_forall, not_lt, not_le] using not_congr (@blsub_le_iff.{_, v} _ f a) #align ordinal.lt_blsub_iff Ordinal.lt_blsub_iff theorem bsup_le_blsub {o : Ordinal.{u}} (f : ∀ a < o, Ordinal.{max u v}) : bsup.{_, v} o f ≤ blsub.{_, v} o f := bsup_le fun i h => (lt_blsub f i h).le #align ordinal.bsup_le_blsub Ordinal.bsup_le_blsub theorem blsub_le_bsup_succ {o : Ordinal.{u}} (f : ∀ a < o, Ordinal.{max u v}) : blsub.{_, v} o f ≤ succ (bsup.{_, v} o f) := blsub_le fun i h => lt_succ_iff.2 (le_bsup f i h) #align ordinal.blsub_le_bsup_succ Ordinal.blsub_le_bsup_succ theorem bsup_eq_blsub_or_succ_bsup_eq_blsub {o : Ordinal.{u}} (f : ∀ a < o, Ordinal.{max u v}) : bsup.{_, v} o f = blsub.{_, v} o f ∨ succ (bsup.{_, v} o f) = blsub.{_, v} o f := by rw [← sup_eq_bsup, ← lsub_eq_blsub] exact sup_eq_lsub_or_sup_succ_eq_lsub _ #align ordinal.bsup_eq_blsub_or_succ_bsup_eq_blsub Ordinal.bsup_eq_blsub_or_succ_bsup_eq_blsub theorem bsup_succ_le_blsub {o : Ordinal.{u}} (f : ∀ a < o, Ordinal.{max u v}) : succ (bsup.{_, v} o f) ≤ blsub.{_, v} o f ↔ ∃ i hi, f i hi = bsup.{_, v} o f := by refine ⟨fun h => ?_, ?_⟩ · by_contra! hf exact ne_of_lt (succ_le_iff.1 h) (le_antisymm (bsup_le_blsub f) (blsub_le (lt_bsup_of_ne_bsup.1 hf))) rintro ⟨_, _, hf⟩ rw [succ_le_iff, ← hf] exact lt_blsub _ _ _ #align ordinal.bsup_succ_le_blsub Ordinal.bsup_succ_le_blsub theorem bsup_succ_eq_blsub {o : Ordinal.{u}} (f : ∀ a < o, Ordinal.{max u v}) : succ (bsup.{_, v} o f) = blsub.{_, v} o f ↔ ∃ i hi, f i hi = bsup.{_, v} o f := (blsub_le_bsup_succ f).le_iff_eq.symm.trans (bsup_succ_le_blsub f) #align ordinal.bsup_succ_eq_blsub Ordinal.bsup_succ_eq_blsub theorem bsup_eq_blsub_iff_succ {o : Ordinal.{u}} (f : ∀ a < o, Ordinal.{max u v}) : bsup.{_, v} o f = blsub.{_, v} o f ↔ ∀ a < blsub.{_, v} o f, succ a < blsub.{_, v} o f := by rw [← sup_eq_bsup, ← lsub_eq_blsub] apply sup_eq_lsub_iff_succ #align ordinal.bsup_eq_blsub_iff_succ Ordinal.bsup_eq_blsub_iff_succ theorem bsup_eq_blsub_iff_lt_bsup {o : Ordinal.{u}} (f : ∀ a < o, Ordinal.{max u v}) : bsup.{_, v} o f = blsub.{_, v} o f ↔ ∀ i hi, f i hi < bsup.{_, v} o f := ⟨fun h i => by rw [h] apply lt_blsub, fun h => le_antisymm (bsup_le_blsub f) (blsub_le h)⟩ #align ordinal.bsup_eq_blsub_iff_lt_bsup Ordinal.bsup_eq_blsub_iff_lt_bsup theorem bsup_eq_blsub_of_lt_succ_limit {o : Ordinal.{u}} (ho : IsLimit o) {f : ∀ a < o, Ordinal.{max u v}} (hf : ∀ a ha, f a ha < f (succ a) (ho.2 a ha)) : bsup.{_, v} o f = blsub.{_, v} o f := by rw [bsup_eq_blsub_iff_lt_bsup] exact fun i hi => (hf i hi).trans_le (le_bsup f _ _) #align ordinal.bsup_eq_blsub_of_lt_succ_limit Ordinal.bsup_eq_blsub_of_lt_succ_limit theorem blsub_succ_of_mono {o : Ordinal.{u}} {f : ∀ a < succ o, Ordinal.{max u v}} (hf : ∀ {i j} (hi hj), i ≤ j → f i hi ≤ f j hj) : blsub.{_, v} _ f = succ (f o (lt_succ o)) := bsup_succ_of_mono fun {_ _} hi hj h => succ_le_succ (hf hi hj h) #align ordinal.blsub_succ_of_mono Ordinal.blsub_succ_of_mono @[simp] theorem blsub_eq_zero_iff {o} {f : ∀ a < o, Ordinal} : blsub o f = 0 ↔ o = 0 := by rw [← lsub_eq_blsub, lsub_eq_zero_iff] exact out_empty_iff_eq_zero #align ordinal.blsub_eq_zero_iff Ordinal.blsub_eq_zero_iff -- Porting note: `rwa` → `rw` @[simp] theorem blsub_zero (f : ∀ a < (0 : Ordinal), Ordinal) : blsub 0 f = 0 := by rw [blsub_eq_zero_iff] #align ordinal.blsub_zero Ordinal.blsub_zero theorem blsub_pos {o : Ordinal} (ho : 0 < o) (f : ∀ a < o, Ordinal) : 0 < blsub o f := (Ordinal.zero_le _).trans_lt (lt_blsub f 0 ho) #align ordinal.blsub_pos Ordinal.blsub_pos theorem blsub_type {α : Type u} (r : α → α → Prop) [IsWellOrder α r] (f : ∀ a < type r, Ordinal.{max u v}) : blsub.{_, v} (type r) f = lsub.{_, v} fun a => f (typein r a) (typein_lt_type _ _) := eq_of_forall_ge_iff fun o => by rw [blsub_le_iff, lsub_le_iff]; exact ⟨fun H b => H _ _, fun H i h => by simpa only [typein_enum] using H (enum r i h)⟩ #align ordinal.blsub_type Ordinal.blsub_type theorem blsub_const {o : Ordinal} (ho : o ≠ 0) (a : Ordinal) : (blsub.{u, v} o fun _ _ => a) = succ a := bsup_const.{u, v} ho (succ a) #align ordinal.blsub_const Ordinal.blsub_const @[simp] theorem blsub_one (f : ∀ a < (1 : Ordinal), Ordinal) : blsub 1 f = succ (f 0 zero_lt_one) := bsup_one _ #align ordinal.blsub_one Ordinal.blsub_one @[simp] theorem blsub_id : ∀ o, (blsub.{u, u} o fun x _ => x) = o := lsub_typein #align ordinal.blsub_id Ordinal.blsub_id theorem bsup_id_limit {o : Ordinal} : (∀ a < o, succ a < o) → (bsup.{u, u} o fun x _ => x) = o := sup_typein_limit #align ordinal.bsup_id_limit Ordinal.bsup_id_limit @[simp] theorem bsup_id_succ (o) : (bsup.{u, u} (succ o) fun x _ => x) = o := sup_typein_succ #align ordinal.bsup_id_succ Ordinal.bsup_id_succ theorem blsub_le_of_brange_subset {o o'} {f : ∀ a < o, Ordinal} {g : ∀ a < o', Ordinal} (h : brange o f ⊆ brange o' g) : blsub.{u, max v w} o f ≤ blsub.{v, max u w} o' g := bsup_le_of_brange_subset.{u, v, w} fun a ⟨b, hb, hb'⟩ => by obtain ⟨c, hc, hc'⟩ := h ⟨b, hb, rfl⟩ simp_rw [← hc'] at hb' exact ⟨c, hc, hb'⟩ #align ordinal.blsub_le_of_brange_subset Ordinal.blsub_le_of_brange_subset theorem blsub_eq_of_brange_eq {o o'} {f : ∀ a < o, Ordinal} {g : ∀ a < o', Ordinal} (h : { o | ∃ i hi, f i hi = o } = { o | ∃ i hi, g i hi = o }) : blsub.{u, max v w} o f = blsub.{v, max u w} o' g := (blsub_le_of_brange_subset.{u, v, w} h.le).antisymm (blsub_le_of_brange_subset.{v, u, w} h.ge) #align ordinal.blsub_eq_of_brange_eq Ordinal.blsub_eq_of_brange_eq theorem bsup_comp {o o' : Ordinal.{max u v}} {f : ∀ a < o, Ordinal.{max u v w}} (hf : ∀ {i j} (hi) (hj), i ≤ j → f i hi ≤ f j hj) {g : ∀ a < o', Ordinal.{max u v}} (hg : blsub.{_, u} o' g = o) : (bsup.{_, w} o' fun a ha => f (g a ha) (by rw [← hg]; apply lt_blsub)) = bsup.{_, w} o f := by apply le_antisymm <;> refine bsup_le fun i hi => ?_ · apply le_bsup · rw [← hg, lt_blsub_iff] at hi rcases hi with ⟨j, hj, hj'⟩ exact (hf _ _ hj').trans (le_bsup _ _ _) #align ordinal.bsup_comp Ordinal.bsup_comp theorem blsub_comp {o o' : Ordinal.{max u v}} {f : ∀ a < o, Ordinal.{max u v w}} (hf : ∀ {i j} (hi) (hj), i ≤ j → f i hi ≤ f j hj) {g : ∀ a < o', Ordinal.{max u v}} (hg : blsub.{_, u} o' g = o) : (blsub.{_, w} o' fun a ha => f (g a ha) (by rw [← hg]; apply lt_blsub)) = blsub.{_, w} o f := @bsup_comp.{u, v, w} o _ (fun a ha => succ (f a ha)) (fun {_ _} _ _ h => succ_le_succ_iff.2 (hf _ _ h)) g hg #align ordinal.blsub_comp Ordinal.blsub_comp theorem IsNormal.bsup_eq {f : Ordinal.{u} → Ordinal.{max u v}} (H : IsNormal f) {o : Ordinal.{u}} (h : IsLimit o) : (Ordinal.bsup.{_, v} o fun x _ => f x) = f o := by rw [← IsNormal.bsup.{u, u, v} H (fun x _ => x) h.1, bsup_id_limit h.2] #align ordinal.is_normal.bsup_eq Ordinal.IsNormal.bsup_eq theorem IsNormal.blsub_eq {f : Ordinal.{u} → Ordinal.{max u v}} (H : IsNormal f) {o : Ordinal.{u}} (h : IsLimit o) : (blsub.{_, v} o fun x _ => f x) = f o := by rw [← IsNormal.bsup_eq.{u, v} H h, bsup_eq_blsub_of_lt_succ_limit h] exact fun a _ => H.1 a #align ordinal.is_normal.blsub_eq Ordinal.IsNormal.blsub_eq theorem isNormal_iff_lt_succ_and_bsup_eq {f : Ordinal.{u} → Ordinal.{max u v}} : IsNormal f ↔ (∀ a, f a < f (succ a)) ∧ ∀ o, IsLimit o → (bsup.{_, v} o fun x _ => f x) = f o := ⟨fun h => ⟨h.1, @IsNormal.bsup_eq f h⟩, fun ⟨h₁, h₂⟩ => ⟨h₁, fun o ho a => by rw [← h₂ o ho] exact bsup_le_iff⟩⟩ #align ordinal.is_normal_iff_lt_succ_and_bsup_eq Ordinal.isNormal_iff_lt_succ_and_bsup_eq theorem isNormal_iff_lt_succ_and_blsub_eq {f : Ordinal.{u} → Ordinal.{max u v}} : IsNormal f ↔ (∀ a, f a < f (succ a)) ∧ ∀ o, IsLimit o → (blsub.{_, v} o fun x _ => f x) = f o := by rw [isNormal_iff_lt_succ_and_bsup_eq.{u, v}, and_congr_right_iff] intro h constructor <;> intro H o ho <;> have := H o ho <;> rwa [← bsup_eq_blsub_of_lt_succ_limit ho fun a _ => h a] at * #align ordinal.is_normal_iff_lt_succ_and_blsub_eq Ordinal.isNormal_iff_lt_succ_and_blsub_eq theorem IsNormal.eq_iff_zero_and_succ {f g : Ordinal.{u} → Ordinal.{u}} (hf : IsNormal f) (hg : IsNormal g) : f = g ↔ f 0 = g 0 ∧ ∀ a, f a = g a → f (succ a) = g (succ a) := ⟨fun h => by simp [h], fun ⟨h₁, h₂⟩ => funext fun a => by induction' a using limitRecOn with _ _ _ ho H any_goals solve_by_elim rw [← IsNormal.bsup_eq.{u, u} hf ho, ← IsNormal.bsup_eq.{u, u} hg ho] congr ext b hb exact H b hb⟩ #align ordinal.is_normal.eq_iff_zero_and_succ Ordinal.IsNormal.eq_iff_zero_and_succ def blsub₂ (o₁ o₂ : Ordinal) (op : {a : Ordinal} → (a < o₁) → {b : Ordinal} → (b < o₂) → Ordinal) : Ordinal := lsub (fun x : o₁.out.α × o₂.out.α => op (typein_lt_self x.1) (typein_lt_self x.2)) #align ordinal.blsub₂ Ordinal.blsub₂ theorem lt_blsub₂ {o₁ o₂ : Ordinal} (op : {a : Ordinal} → (a < o₁) → {b : Ordinal} → (b < o₂) → Ordinal) {a b : Ordinal} (ha : a < o₁) (hb : b < o₂) : op ha hb < blsub₂ o₁ o₂ op := by convert lt_lsub _ (Prod.mk (enum (· < ·) a (by rwa [type_lt])) (enum (· < ·) b (by rwa [type_lt]))) simp only [typein_enum] #align ordinal.lt_blsub₂ Ordinal.lt_blsub₂ def mex {ι : Type u} (f : ι → Ordinal.{max u v}) : Ordinal := sInf (Set.range f)ᶜ #align ordinal.mex Ordinal.mex theorem mex_not_mem_range {ι : Type u} (f : ι → Ordinal.{max u v}) : mex.{_, v} f ∉ Set.range f := csInf_mem (nonempty_compl_range.{_, v} f) #align ordinal.mex_not_mem_range Ordinal.mex_not_mem_range theorem le_mex_of_forall {ι : Type u} {f : ι → Ordinal.{max u v}} {a : Ordinal} (H : ∀ b < a, ∃ i, f i = b) : a ≤ mex.{_, v} f := by by_contra! h exact mex_not_mem_range f (H _ h) #align ordinal.le_mex_of_forall Ordinal.le_mex_of_forall theorem ne_mex {ι : Type u} (f : ι → Ordinal.{max u v}) : ∀ i, f i ≠ mex.{_, v} f := by simpa using mex_not_mem_range.{_, v} f #align ordinal.ne_mex Ordinal.ne_mex theorem mex_le_of_ne {ι} {f : ι → Ordinal} {a} (ha : ∀ i, f i ≠ a) : mex f ≤ a := csInf_le' (by simp [ha]) #align ordinal.mex_le_of_ne Ordinal.mex_le_of_ne theorem exists_of_lt_mex {ι} {f : ι → Ordinal} {a} (ha : a < mex f) : ∃ i, f i = a := by by_contra! ha' exact ha.not_le (mex_le_of_ne ha') #align ordinal.exists_of_lt_mex Ordinal.exists_of_lt_mex theorem mex_le_lsub {ι : Type u} (f : ι → Ordinal.{max u v}) : mex.{_, v} f ≤ lsub.{_, v} f := csInf_le' (lsub_not_mem_range f) #align ordinal.mex_le_lsub Ordinal.mex_le_lsub theorem mex_monotone {α β : Type u} {f : α → Ordinal.{max u v}} {g : β → Ordinal.{max u v}} (h : Set.range f ⊆ Set.range g) : mex.{_, v} f ≤ mex.{_, v} g := by refine mex_le_of_ne fun i hi => ?_ cases' h ⟨i, rfl⟩ with j hj rw [← hj] at hi exact ne_mex g j hi #align ordinal.mex_monotone Ordinal.mex_monotone theorem mex_lt_ord_succ_mk {ι : Type u} (f : ι → Ordinal.{u}) : mex.{_, u} f < (succ #ι).ord := by by_contra! h apply (lt_succ #ι).not_le have H := fun a => exists_of_lt_mex ((typein_lt_self a).trans_le h) let g : (succ #ι).ord.out.α → ι := fun a => Classical.choose (H a) have hg : Injective g := fun a b h' => by have Hf : ∀ x, f (g x) = typein ((· < ·) : (succ #ι).ord.out.α → (succ #ι).ord.out.α → Prop) x := fun a => Classical.choose_spec (H a) apply_fun f at h' rwa [Hf, Hf, typein_inj] at h' convert Cardinal.mk_le_of_injective hg rw [Cardinal.mk_ord_out (succ #ι)] #align ordinal.mex_lt_ord_succ_mk Ordinal.mex_lt_ord_succ_mk def bmex (o : Ordinal) (f : ∀ a < o, Ordinal) : Ordinal := mex (familyOfBFamily o f) #align ordinal.bmex Ordinal.bmex theorem bmex_not_mem_brange {o : Ordinal} (f : ∀ a < o, Ordinal) : bmex o f ∉ brange o f := by rw [← range_familyOfBFamily] apply mex_not_mem_range #align ordinal.bmex_not_mem_brange Ordinal.bmex_not_mem_brange
Mathlib/SetTheory/Ordinal/Arithmetic.lean
2,086
2,089
theorem le_bmex_of_forall {o : Ordinal} (f : ∀ a < o, Ordinal) {a : Ordinal} (H : ∀ b < a, ∃ i hi, f i hi = b) : a ≤ bmex o f := by
by_contra! h exact bmex_not_mem_brange f (H _ h)
import Mathlib.Data.Nat.Defs import Mathlib.Data.Option.Basic import Mathlib.Data.List.Defs import Mathlib.Init.Data.List.Basic import Mathlib.Init.Data.List.Instances import Mathlib.Init.Data.List.Lemmas import Mathlib.Logic.Unique import Mathlib.Order.Basic import Mathlib.Tactic.Common #align_import data.list.basic from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" assert_not_exists Set.range assert_not_exists GroupWithZero assert_not_exists Ring open Function open Nat hiding one_pos namespace List universe u v w variable {ι : Type*} {α : Type u} {β : Type v} {γ : Type w} {l₁ l₂ : List α} -- Porting note: Delete this attribute -- attribute [inline] List.head! instance uniqueOfIsEmpty [IsEmpty α] : Unique (List α) := { instInhabitedList with uniq := fun l => match l with | [] => rfl | a :: _ => isEmptyElim a } #align list.unique_of_is_empty List.uniqueOfIsEmpty instance : Std.LawfulIdentity (α := List α) Append.append [] where left_id := nil_append right_id := append_nil instance : Std.Associative (α := List α) Append.append where assoc := append_assoc #align list.cons_ne_nil List.cons_ne_nil #align list.cons_ne_self List.cons_ne_self #align list.head_eq_of_cons_eq List.head_eq_of_cons_eqₓ -- implicits order #align list.tail_eq_of_cons_eq List.tail_eq_of_cons_eqₓ -- implicits order @[simp] theorem cons_injective {a : α} : Injective (cons a) := fun _ _ => tail_eq_of_cons_eq #align list.cons_injective List.cons_injective #align list.cons_inj List.cons_inj #align list.cons_eq_cons List.cons_eq_cons theorem singleton_injective : Injective fun a : α => [a] := fun _ _ h => (cons_eq_cons.1 h).1 #align list.singleton_injective List.singleton_injective theorem singleton_inj {a b : α} : [a] = [b] ↔ a = b := singleton_injective.eq_iff #align list.singleton_inj List.singleton_inj #align list.exists_cons_of_ne_nil List.exists_cons_of_ne_nil theorem set_of_mem_cons (l : List α) (a : α) : { x | x ∈ a :: l } = insert a { x | x ∈ l } := Set.ext fun _ => mem_cons #align list.set_of_mem_cons List.set_of_mem_cons #align list.mem_singleton_self List.mem_singleton_self #align list.eq_of_mem_singleton List.eq_of_mem_singleton #align list.mem_singleton List.mem_singleton #align list.mem_of_mem_cons_of_mem List.mem_of_mem_cons_of_mem theorem _root_.Decidable.List.eq_or_ne_mem_of_mem [DecidableEq α] {a b : α} {l : List α} (h : a ∈ b :: l) : a = b ∨ a ≠ b ∧ a ∈ l := by by_cases hab : a = b · exact Or.inl hab · exact ((List.mem_cons.1 h).elim Or.inl (fun h => Or.inr ⟨hab, h⟩)) #align decidable.list.eq_or_ne_mem_of_mem Decidable.List.eq_or_ne_mem_of_mem #align list.eq_or_ne_mem_of_mem List.eq_or_ne_mem_of_mem #align list.not_mem_append List.not_mem_append #align list.ne_nil_of_mem List.ne_nil_of_mem lemma mem_pair {a b c : α} : a ∈ [b, c] ↔ a = b ∨ a = c := by rw [mem_cons, mem_singleton] @[deprecated (since := "2024-03-23")] alias mem_split := append_of_mem #align list.mem_split List.append_of_mem #align list.mem_of_ne_of_mem List.mem_of_ne_of_mem #align list.ne_of_not_mem_cons List.ne_of_not_mem_cons #align list.not_mem_of_not_mem_cons List.not_mem_of_not_mem_cons #align list.not_mem_cons_of_ne_of_not_mem List.not_mem_cons_of_ne_of_not_mem #align list.ne_and_not_mem_of_not_mem_cons List.ne_and_not_mem_of_not_mem_cons #align list.mem_map List.mem_map #align list.exists_of_mem_map List.exists_of_mem_map #align list.mem_map_of_mem List.mem_map_of_memₓ -- implicits order -- The simpNF linter says that the LHS can be simplified via `List.mem_map`. -- However this is a higher priority lemma. -- https://github.com/leanprover/std4/issues/207 @[simp 1100, nolint simpNF] theorem mem_map_of_injective {f : α → β} (H : Injective f) {a : α} {l : List α} : f a ∈ map f l ↔ a ∈ l := ⟨fun m => let ⟨_, m', e⟩ := exists_of_mem_map m; H e ▸ m', mem_map_of_mem _⟩ #align list.mem_map_of_injective List.mem_map_of_injective @[simp] theorem _root_.Function.Involutive.exists_mem_and_apply_eq_iff {f : α → α} (hf : Function.Involutive f) (x : α) (l : List α) : (∃ y : α, y ∈ l ∧ f y = x) ↔ f x ∈ l := ⟨by rintro ⟨y, h, rfl⟩; rwa [hf y], fun h => ⟨f x, h, hf _⟩⟩ #align function.involutive.exists_mem_and_apply_eq_iff Function.Involutive.exists_mem_and_apply_eq_iff theorem mem_map_of_involutive {f : α → α} (hf : Involutive f) {a : α} {l : List α} : a ∈ map f l ↔ f a ∈ l := by rw [mem_map, hf.exists_mem_and_apply_eq_iff] #align list.mem_map_of_involutive List.mem_map_of_involutive #align list.forall_mem_map_iff List.forall_mem_map_iffₓ -- universe order #align list.map_eq_nil List.map_eq_nilₓ -- universe order attribute [simp] List.mem_join #align list.mem_join List.mem_join #align list.exists_of_mem_join List.exists_of_mem_join #align list.mem_join_of_mem List.mem_join_of_memₓ -- implicits order attribute [simp] List.mem_bind #align list.mem_bind List.mem_bindₓ -- implicits order -- Porting note: bExists in Lean3, And in Lean4 #align list.exists_of_mem_bind List.exists_of_mem_bindₓ -- implicits order #align list.mem_bind_of_mem List.mem_bind_of_memₓ -- implicits order #align list.bind_map List.bind_mapₓ -- implicits order theorem map_bind (g : β → List γ) (f : α → β) : ∀ l : List α, (List.map f l).bind g = l.bind fun a => g (f a) | [] => rfl | a :: l => by simp only [cons_bind, map_cons, map_bind _ _ l] #align list.map_bind List.map_bind #align list.length_eq_zero List.length_eq_zero #align list.length_singleton List.length_singleton #align list.length_pos_of_mem List.length_pos_of_mem #align list.exists_mem_of_length_pos List.exists_mem_of_length_pos #align list.length_pos_iff_exists_mem List.length_pos_iff_exists_mem alias ⟨ne_nil_of_length_pos, length_pos_of_ne_nil⟩ := length_pos #align list.ne_nil_of_length_pos List.ne_nil_of_length_pos #align list.length_pos_of_ne_nil List.length_pos_of_ne_nil theorem length_pos_iff_ne_nil {l : List α} : 0 < length l ↔ l ≠ [] := ⟨ne_nil_of_length_pos, length_pos_of_ne_nil⟩ #align list.length_pos_iff_ne_nil List.length_pos_iff_ne_nil #align list.exists_mem_of_ne_nil List.exists_mem_of_ne_nil #align list.length_eq_one List.length_eq_one theorem exists_of_length_succ {n} : ∀ l : List α, l.length = n + 1 → ∃ h t, l = h :: t | [], H => absurd H.symm <| succ_ne_zero n | h :: t, _ => ⟨h, t, rfl⟩ #align list.exists_of_length_succ List.exists_of_length_succ @[simp] lemma length_injective_iff : Injective (List.length : List α → ℕ) ↔ Subsingleton α := by constructor · intro h; refine ⟨fun x y => ?_⟩; (suffices [x] = [y] by simpa using this); apply h; rfl · intros hα l1 l2 hl induction l1 generalizing l2 <;> cases l2 · rfl · cases hl · cases hl · next ih _ _ => congr · exact Subsingleton.elim _ _ · apply ih; simpa using hl #align list.length_injective_iff List.length_injective_iff @[simp default+1] -- Porting note: this used to be just @[simp] lemma length_injective [Subsingleton α] : Injective (length : List α → ℕ) := length_injective_iff.mpr inferInstance #align list.length_injective List.length_injective theorem length_eq_two {l : List α} : l.length = 2 ↔ ∃ a b, l = [a, b] := ⟨fun _ => let [a, b] := l; ⟨a, b, rfl⟩, fun ⟨_, _, e⟩ => e ▸ rfl⟩ #align list.length_eq_two List.length_eq_two theorem length_eq_three {l : List α} : l.length = 3 ↔ ∃ a b c, l = [a, b, c] := ⟨fun _ => let [a, b, c] := l; ⟨a, b, c, rfl⟩, fun ⟨_, _, _, e⟩ => e ▸ rfl⟩ #align list.length_eq_three List.length_eq_three #align list.sublist.length_le List.Sublist.length_le -- ADHOC Porting note: instance from Lean3 core instance instSingletonList : Singleton α (List α) := ⟨fun x => [x]⟩ #align list.has_singleton List.instSingletonList -- ADHOC Porting note: instance from Lean3 core instance [DecidableEq α] : Insert α (List α) := ⟨List.insert⟩ -- ADHOC Porting note: instance from Lean3 core instance [DecidableEq α] : LawfulSingleton α (List α) := { insert_emptyc_eq := fun x => show (if x ∈ ([] : List α) then [] else [x]) = [x] from if_neg (not_mem_nil _) } #align list.empty_eq List.empty_eq theorem singleton_eq (x : α) : ({x} : List α) = [x] := rfl #align list.singleton_eq List.singleton_eq theorem insert_neg [DecidableEq α] {x : α} {l : List α} (h : x ∉ l) : Insert.insert x l = x :: l := insert_of_not_mem h #align list.insert_neg List.insert_neg theorem insert_pos [DecidableEq α] {x : α} {l : List α} (h : x ∈ l) : Insert.insert x l = l := insert_of_mem h #align list.insert_pos List.insert_pos theorem doubleton_eq [DecidableEq α] {x y : α} (h : x ≠ y) : ({x, y} : List α) = [x, y] := by rw [insert_neg, singleton_eq] rwa [singleton_eq, mem_singleton] #align list.doubleton_eq List.doubleton_eq #align list.forall_mem_nil List.forall_mem_nil #align list.forall_mem_cons List.forall_mem_cons theorem forall_mem_of_forall_mem_cons {p : α → Prop} {a : α} {l : List α} (h : ∀ x ∈ a :: l, p x) : ∀ x ∈ l, p x := (forall_mem_cons.1 h).2 #align list.forall_mem_of_forall_mem_cons List.forall_mem_of_forall_mem_cons #align list.forall_mem_singleton List.forall_mem_singleton #align list.forall_mem_append List.forall_mem_append #align list.not_exists_mem_nil List.not_exists_mem_nilₓ -- bExists change -- Porting note: bExists in Lean3 and And in Lean4 theorem exists_mem_cons_of {p : α → Prop} {a : α} (l : List α) (h : p a) : ∃ x ∈ a :: l, p x := ⟨a, mem_cons_self _ _, h⟩ #align list.exists_mem_cons_of List.exists_mem_cons_ofₓ -- bExists change -- Porting note: bExists in Lean3 and And in Lean4 theorem exists_mem_cons_of_exists {p : α → Prop} {a : α} {l : List α} : (∃ x ∈ l, p x) → ∃ x ∈ a :: l, p x := fun ⟨x, xl, px⟩ => ⟨x, mem_cons_of_mem _ xl, px⟩ #align list.exists_mem_cons_of_exists List.exists_mem_cons_of_existsₓ -- bExists change -- Porting note: bExists in Lean3 and And in Lean4 theorem or_exists_of_exists_mem_cons {p : α → Prop} {a : α} {l : List α} : (∃ x ∈ a :: l, p x) → p a ∨ ∃ x ∈ l, p x := fun ⟨x, xal, px⟩ => Or.elim (eq_or_mem_of_mem_cons xal) (fun h : x = a => by rw [← h]; left; exact px) fun h : x ∈ l => Or.inr ⟨x, h, px⟩ #align list.or_exists_of_exists_mem_cons List.or_exists_of_exists_mem_consₓ -- bExists change theorem exists_mem_cons_iff (p : α → Prop) (a : α) (l : List α) : (∃ x ∈ a :: l, p x) ↔ p a ∨ ∃ x ∈ l, p x := Iff.intro or_exists_of_exists_mem_cons fun h => Or.elim h (exists_mem_cons_of l) exists_mem_cons_of_exists #align list.exists_mem_cons_iff List.exists_mem_cons_iff instance : IsTrans (List α) Subset where trans := fun _ _ _ => List.Subset.trans #align list.subset_def List.subset_def #align list.subset_append_of_subset_left List.subset_append_of_subset_left #align list.subset_append_of_subset_right List.subset_append_of_subset_right #align list.cons_subset List.cons_subset theorem cons_subset_of_subset_of_mem {a : α} {l m : List α} (ainm : a ∈ m) (lsubm : l ⊆ m) : a::l ⊆ m := cons_subset.2 ⟨ainm, lsubm⟩ #align list.cons_subset_of_subset_of_mem List.cons_subset_of_subset_of_mem theorem append_subset_of_subset_of_subset {l₁ l₂ l : List α} (l₁subl : l₁ ⊆ l) (l₂subl : l₂ ⊆ l) : l₁ ++ l₂ ⊆ l := fun _ h ↦ (mem_append.1 h).elim (@l₁subl _) (@l₂subl _) #align list.append_subset_of_subset_of_subset List.append_subset_of_subset_of_subset -- Porting note: in Batteries #align list.append_subset_iff List.append_subset alias ⟨eq_nil_of_subset_nil, _⟩ := subset_nil #align list.eq_nil_of_subset_nil List.eq_nil_of_subset_nil #align list.eq_nil_iff_forall_not_mem List.eq_nil_iff_forall_not_mem #align list.map_subset List.map_subset theorem map_subset_iff {l₁ l₂ : List α} (f : α → β) (h : Injective f) : map f l₁ ⊆ map f l₂ ↔ l₁ ⊆ l₂ := by refine ⟨?_, map_subset f⟩; intro h2 x hx rcases mem_map.1 (h2 (mem_map_of_mem f hx)) with ⟨x', hx', hxx'⟩ cases h hxx'; exact hx' #align list.map_subset_iff List.map_subset_iff theorem append_eq_has_append {L₁ L₂ : List α} : List.append L₁ L₂ = L₁ ++ L₂ := rfl #align list.append_eq_has_append List.append_eq_has_append #align list.singleton_append List.singleton_append #align list.append_ne_nil_of_ne_nil_left List.append_ne_nil_of_ne_nil_left #align list.append_ne_nil_of_ne_nil_right List.append_ne_nil_of_ne_nil_right #align list.append_eq_nil List.append_eq_nil -- Porting note: in Batteries #align list.nil_eq_append_iff List.nil_eq_append @[deprecated (since := "2024-03-24")] alias append_eq_cons_iff := append_eq_cons #align list.append_eq_cons_iff List.append_eq_cons @[deprecated (since := "2024-03-24")] alias cons_eq_append_iff := cons_eq_append #align list.cons_eq_append_iff List.cons_eq_append #align list.append_eq_append_iff List.append_eq_append_iff #align list.take_append_drop List.take_append_drop #align list.append_inj List.append_inj #align list.append_inj_right List.append_inj_rightₓ -- implicits order #align list.append_inj_left List.append_inj_leftₓ -- implicits order #align list.append_inj' List.append_inj'ₓ -- implicits order #align list.append_inj_right' List.append_inj_right'ₓ -- implicits order #align list.append_inj_left' List.append_inj_left'ₓ -- implicits order @[deprecated (since := "2024-01-18")] alias append_left_cancel := append_cancel_left #align list.append_left_cancel List.append_cancel_left @[deprecated (since := "2024-01-18")] alias append_right_cancel := append_cancel_right #align list.append_right_cancel List.append_cancel_right @[simp] theorem append_left_eq_self {x y : List α} : x ++ y = y ↔ x = [] := by rw [← append_left_inj (s₁ := x), nil_append] @[simp] theorem self_eq_append_left {x y : List α} : y = x ++ y ↔ x = [] := by rw [eq_comm, append_left_eq_self] @[simp] theorem append_right_eq_self {x y : List α} : x ++ y = x ↔ y = [] := by rw [← append_right_inj (t₁ := y), append_nil] @[simp] theorem self_eq_append_right {x y : List α} : x = x ++ y ↔ y = [] := by rw [eq_comm, append_right_eq_self] theorem append_right_injective (s : List α) : Injective fun t ↦ s ++ t := fun _ _ ↦ append_cancel_left #align list.append_right_injective List.append_right_injective #align list.append_right_inj List.append_right_inj theorem append_left_injective (t : List α) : Injective fun s ↦ s ++ t := fun _ _ ↦ append_cancel_right #align list.append_left_injective List.append_left_injective #align list.append_left_inj List.append_left_inj #align list.map_eq_append_split List.map_eq_append_split @[simp] lemma replicate_zero (a : α) : replicate 0 a = [] := rfl #align list.replicate_zero List.replicate_zero attribute [simp] replicate_succ #align list.replicate_succ List.replicate_succ lemma replicate_one (a : α) : replicate 1 a = [a] := rfl #align list.replicate_one List.replicate_one #align list.length_replicate List.length_replicate #align list.mem_replicate List.mem_replicate #align list.eq_of_mem_replicate List.eq_of_mem_replicate theorem eq_replicate_length {a : α} : ∀ {l : List α}, l = replicate l.length a ↔ ∀ b ∈ l, b = a | [] => by simp | (b :: l) => by simp [eq_replicate_length] #align list.eq_replicate_length List.eq_replicate_length #align list.eq_replicate_of_mem List.eq_replicate_of_mem #align list.eq_replicate List.eq_replicate theorem replicate_add (m n) (a : α) : replicate (m + n) a = replicate m a ++ replicate n a := by induction m <;> simp [*, succ_add, replicate] #align list.replicate_add List.replicate_add theorem replicate_succ' (n) (a : α) : replicate (n + 1) a = replicate n a ++ [a] := replicate_add n 1 a #align list.replicate_succ' List.replicate_succ' theorem replicate_subset_singleton (n) (a : α) : replicate n a ⊆ [a] := fun _ h => mem_singleton.2 (eq_of_mem_replicate h) #align list.replicate_subset_singleton List.replicate_subset_singleton theorem subset_singleton_iff {a : α} {L : List α} : L ⊆ [a] ↔ ∃ n, L = replicate n a := by simp only [eq_replicate, subset_def, mem_singleton, exists_eq_left'] #align list.subset_singleton_iff List.subset_singleton_iff @[simp] theorem map_replicate (f : α → β) (n) (a : α) : map f (replicate n a) = replicate n (f a) := by induction n <;> [rfl; simp only [*, replicate, map]] #align list.map_replicate List.map_replicate @[simp] theorem tail_replicate (a : α) (n) : tail (replicate n a) = replicate (n - 1) a := by cases n <;> rfl #align list.tail_replicate List.tail_replicate @[simp] theorem join_replicate_nil (n : ℕ) : join (replicate n []) = @nil α := by induction n <;> [rfl; simp only [*, replicate, join, append_nil]] #align list.join_replicate_nil List.join_replicate_nil theorem replicate_right_injective {n : ℕ} (hn : n ≠ 0) : Injective (@replicate α n) := fun _ _ h => (eq_replicate.1 h).2 _ <| mem_replicate.2 ⟨hn, rfl⟩ #align list.replicate_right_injective List.replicate_right_injective theorem replicate_right_inj {a b : α} {n : ℕ} (hn : n ≠ 0) : replicate n a = replicate n b ↔ a = b := (replicate_right_injective hn).eq_iff #align list.replicate_right_inj List.replicate_right_inj @[simp] theorem replicate_right_inj' {a b : α} : ∀ {n}, replicate n a = replicate n b ↔ n = 0 ∨ a = b | 0 => by simp | n + 1 => (replicate_right_inj n.succ_ne_zero).trans <| by simp only [n.succ_ne_zero, false_or] #align list.replicate_right_inj' List.replicate_right_inj' theorem replicate_left_injective (a : α) : Injective (replicate · a) := LeftInverse.injective (length_replicate · a) #align list.replicate_left_injective List.replicate_left_injective @[simp] theorem replicate_left_inj {a : α} {n m : ℕ} : replicate n a = replicate m a ↔ n = m := (replicate_left_injective a).eq_iff #align list.replicate_left_inj List.replicate_left_inj @[simp] theorem head_replicate (n : ℕ) (a : α) (h) : head (replicate n a) h = a := by cases n <;> simp at h ⊢ theorem mem_pure (x y : α) : x ∈ (pure y : List α) ↔ x = y := by simp #align list.mem_pure List.mem_pure @[simp] theorem bind_eq_bind {α β} (f : α → List β) (l : List α) : l >>= f = l.bind f := rfl #align list.bind_eq_bind List.bind_eq_bind #align list.bind_append List.append_bind #align list.concat_nil List.concat_nil #align list.concat_cons List.concat_cons #align list.concat_eq_append List.concat_eq_append #align list.init_eq_of_concat_eq List.init_eq_of_concat_eq #align list.last_eq_of_concat_eq List.last_eq_of_concat_eq #align list.concat_ne_nil List.concat_ne_nil #align list.concat_append List.concat_append #align list.length_concat List.length_concat #align list.append_concat List.append_concat #align list.reverse_nil List.reverse_nil #align list.reverse_core List.reverseAux -- Porting note: Do we need this? attribute [local simp] reverseAux #align list.reverse_cons List.reverse_cons #align list.reverse_core_eq List.reverseAux_eq theorem reverse_cons' (a : α) (l : List α) : reverse (a :: l) = concat (reverse l) a := by simp only [reverse_cons, concat_eq_append] #align list.reverse_cons' List.reverse_cons' theorem reverse_concat' (l : List α) (a : α) : (l ++ [a]).reverse = a :: l.reverse := by rw [reverse_append]; rfl -- Porting note (#10618): simp can prove this -- @[simp] theorem reverse_singleton (a : α) : reverse [a] = [a] := rfl #align list.reverse_singleton List.reverse_singleton #align list.reverse_append List.reverse_append #align list.reverse_concat List.reverse_concat #align list.reverse_reverse List.reverse_reverse @[simp] theorem reverse_involutive : Involutive (@reverse α) := reverse_reverse #align list.reverse_involutive List.reverse_involutive @[simp] theorem reverse_injective : Injective (@reverse α) := reverse_involutive.injective #align list.reverse_injective List.reverse_injective theorem reverse_surjective : Surjective (@reverse α) := reverse_involutive.surjective #align list.reverse_surjective List.reverse_surjective theorem reverse_bijective : Bijective (@reverse α) := reverse_involutive.bijective #align list.reverse_bijective List.reverse_bijective @[simp] theorem reverse_inj {l₁ l₂ : List α} : reverse l₁ = reverse l₂ ↔ l₁ = l₂ := reverse_injective.eq_iff #align list.reverse_inj List.reverse_inj theorem reverse_eq_iff {l l' : List α} : l.reverse = l' ↔ l = l'.reverse := reverse_involutive.eq_iff #align list.reverse_eq_iff List.reverse_eq_iff #align list.reverse_eq_nil List.reverse_eq_nil_iff theorem concat_eq_reverse_cons (a : α) (l : List α) : concat l a = reverse (a :: reverse l) := by simp only [concat_eq_append, reverse_cons, reverse_reverse] #align list.concat_eq_reverse_cons List.concat_eq_reverse_cons #align list.length_reverse List.length_reverse -- Porting note: This one was @[simp] in mathlib 3, -- but Lean contains a competing simp lemma reverse_map. -- For now we remove @[simp] to avoid simplification loops. -- TODO: Change Lean lemma to match mathlib 3? theorem map_reverse (f : α → β) (l : List α) : map f (reverse l) = reverse (map f l) := (reverse_map f l).symm #align list.map_reverse List.map_reverse theorem map_reverseAux (f : α → β) (l₁ l₂ : List α) : map f (reverseAux l₁ l₂) = reverseAux (map f l₁) (map f l₂) := by simp only [reverseAux_eq, map_append, map_reverse] #align list.map_reverse_core List.map_reverseAux #align list.mem_reverse List.mem_reverse @[simp] theorem reverse_replicate (n) (a : α) : reverse (replicate n a) = replicate n a := eq_replicate.2 ⟨by rw [length_reverse, length_replicate], fun b h => eq_of_mem_replicate (mem_reverse.1 h)⟩ #align list.reverse_replicate List.reverse_replicate -- Porting note: this does not work as desired -- attribute [simp] List.isEmpty theorem isEmpty_iff_eq_nil {l : List α} : l.isEmpty ↔ l = [] := by cases l <;> simp [isEmpty] #align list.empty_iff_eq_nil List.isEmpty_iff_eq_nil #align list.length_init List.length_dropLast @[simp] theorem getLast_cons {a : α} {l : List α} : ∀ h : l ≠ nil, getLast (a :: l) (cons_ne_nil a l) = getLast l h := by induction l <;> intros · contradiction · rfl #align list.last_cons List.getLast_cons theorem getLast_append_singleton {a : α} (l : List α) : getLast (l ++ [a]) (append_ne_nil_of_ne_nil_right l _ (cons_ne_nil a _)) = a := by simp only [getLast_append] #align list.last_append_singleton List.getLast_append_singleton -- Porting note: name should be fixed upstream theorem getLast_append' (l₁ l₂ : List α) (h : l₂ ≠ []) : getLast (l₁ ++ l₂) (append_ne_nil_of_ne_nil_right l₁ l₂ h) = getLast l₂ h := by induction' l₁ with _ _ ih · simp · simp only [cons_append] rw [List.getLast_cons] exact ih #align list.last_append List.getLast_append' theorem getLast_concat' {a : α} (l : List α) : getLast (concat l a) (concat_ne_nil a l) = a := getLast_concat .. #align list.last_concat List.getLast_concat' @[simp] theorem getLast_singleton' (a : α) : getLast [a] (cons_ne_nil a []) = a := rfl #align list.last_singleton List.getLast_singleton' -- Porting note (#10618): simp can prove this -- @[simp] theorem getLast_cons_cons (a₁ a₂ : α) (l : List α) : getLast (a₁ :: a₂ :: l) (cons_ne_nil _ _) = getLast (a₂ :: l) (cons_ne_nil a₂ l) := rfl #align list.last_cons_cons List.getLast_cons_cons theorem dropLast_append_getLast : ∀ {l : List α} (h : l ≠ []), dropLast l ++ [getLast l h] = l | [], h => absurd rfl h | [a], h => rfl | a :: b :: l, h => by rw [dropLast_cons₂, cons_append, getLast_cons (cons_ne_nil _ _)] congr exact dropLast_append_getLast (cons_ne_nil b l) #align list.init_append_last List.dropLast_append_getLast theorem getLast_congr {l₁ l₂ : List α} (h₁ : l₁ ≠ []) (h₂ : l₂ ≠ []) (h₃ : l₁ = l₂) : getLast l₁ h₁ = getLast l₂ h₂ := by subst l₁; rfl #align list.last_congr List.getLast_congr #align list.last_mem List.getLast_mem theorem getLast_replicate_succ (m : ℕ) (a : α) : (replicate (m + 1) a).getLast (ne_nil_of_length_eq_succ (length_replicate _ _)) = a := by simp only [replicate_succ'] exact getLast_append_singleton _ #align list.last_replicate_succ List.getLast_replicate_succ -- Porting note: Moved earlier in file, for use in subsequent lemmas. @[simp] theorem getLast?_cons_cons (a b : α) (l : List α) : getLast? (a :: b :: l) = getLast? (b :: l) := rfl @[simp] theorem getLast?_isNone : ∀ {l : List α}, (getLast? l).isNone ↔ l = [] | [] => by simp | [a] => by simp | a :: b :: l => by simp [@getLast?_isNone (b :: l)] #align list.last'_is_none List.getLast?_isNone @[simp] theorem getLast?_isSome : ∀ {l : List α}, l.getLast?.isSome ↔ l ≠ [] | [] => by simp | [a] => by simp | a :: b :: l => by simp [@getLast?_isSome (b :: l)] #align list.last'_is_some List.getLast?_isSome theorem mem_getLast?_eq_getLast : ∀ {l : List α} {x : α}, x ∈ l.getLast? → ∃ h, x = getLast l h | [], x, hx => False.elim <| by simp at hx | [a], x, hx => have : a = x := by simpa using hx this ▸ ⟨cons_ne_nil a [], rfl⟩ | a :: b :: l, x, hx => by rw [getLast?_cons_cons] at hx rcases mem_getLast?_eq_getLast hx with ⟨_, h₂⟩ use cons_ne_nil _ _ assumption #align list.mem_last'_eq_last List.mem_getLast?_eq_getLast theorem getLast?_eq_getLast_of_ne_nil : ∀ {l : List α} (h : l ≠ []), l.getLast? = some (l.getLast h) | [], h => (h rfl).elim | [_], _ => rfl | _ :: b :: l, _ => @getLast?_eq_getLast_of_ne_nil (b :: l) (cons_ne_nil _ _) #align list.last'_eq_last_of_ne_nil List.getLast?_eq_getLast_of_ne_nil theorem mem_getLast?_cons {x y : α} : ∀ {l : List α}, x ∈ l.getLast? → x ∈ (y :: l).getLast? | [], _ => by contradiction | _ :: _, h => h #align list.mem_last'_cons List.mem_getLast?_cons theorem mem_of_mem_getLast? {l : List α} {a : α} (ha : a ∈ l.getLast?) : a ∈ l := let ⟨_, h₂⟩ := mem_getLast?_eq_getLast ha h₂.symm ▸ getLast_mem _ #align list.mem_of_mem_last' List.mem_of_mem_getLast? theorem dropLast_append_getLast? : ∀ {l : List α}, ∀ a ∈ l.getLast?, dropLast l ++ [a] = l | [], a, ha => (Option.not_mem_none a ha).elim | [a], _, rfl => rfl | a :: b :: l, c, hc => by rw [getLast?_cons_cons] at hc rw [dropLast_cons₂, cons_append, dropLast_append_getLast? _ hc] #align list.init_append_last' List.dropLast_append_getLast? theorem getLastI_eq_getLast? [Inhabited α] : ∀ l : List α, l.getLastI = l.getLast?.iget | [] => by simp [getLastI, Inhabited.default] | [a] => rfl | [a, b] => rfl | [a, b, c] => rfl | _ :: _ :: c :: l => by simp [getLastI, getLastI_eq_getLast? (c :: l)] #align list.ilast_eq_last' List.getLastI_eq_getLast? @[simp] theorem getLast?_append_cons : ∀ (l₁ : List α) (a : α) (l₂ : List α), getLast? (l₁ ++ a :: l₂) = getLast? (a :: l₂) | [], a, l₂ => rfl | [b], a, l₂ => rfl | b :: c :: l₁, a, l₂ => by rw [cons_append, cons_append, getLast?_cons_cons, ← cons_append, getLast?_append_cons (c :: l₁)] #align list.last'_append_cons List.getLast?_append_cons #align list.last'_cons_cons List.getLast?_cons_cons theorem getLast?_append_of_ne_nil (l₁ : List α) : ∀ {l₂ : List α} (_ : l₂ ≠ []), getLast? (l₁ ++ l₂) = getLast? l₂ | [], hl₂ => by contradiction | b :: l₂, _ => getLast?_append_cons l₁ b l₂ #align list.last'_append_of_ne_nil List.getLast?_append_of_ne_nil theorem getLast?_append {l₁ l₂ : List α} {x : α} (h : x ∈ l₂.getLast?) : x ∈ (l₁ ++ l₂).getLast? := by cases l₂ · contradiction · rw [List.getLast?_append_cons] exact h #align list.last'_append List.getLast?_append @[simp] theorem head!_nil [Inhabited α] : ([] : List α).head! = default := rfl @[simp] theorem head_cons_tail (x : List α) (h : x ≠ []) : x.head h :: x.tail = x := by cases x <;> simp at h ⊢ theorem head!_eq_head? [Inhabited α] (l : List α) : head! l = (head? l).iget := by cases l <;> rfl #align list.head_eq_head' List.head!_eq_head? theorem surjective_head! [Inhabited α] : Surjective (@head! α _) := fun x => ⟨[x], rfl⟩ #align list.surjective_head List.surjective_head! theorem surjective_head? : Surjective (@head? α) := Option.forall.2 ⟨⟨[], rfl⟩, fun x => ⟨[x], rfl⟩⟩ #align list.surjective_head' List.surjective_head? theorem surjective_tail : Surjective (@tail α) | [] => ⟨[], rfl⟩ | a :: l => ⟨a :: a :: l, rfl⟩ #align list.surjective_tail List.surjective_tail theorem eq_cons_of_mem_head? {x : α} : ∀ {l : List α}, x ∈ l.head? → l = x :: tail l | [], h => (Option.not_mem_none _ h).elim | a :: l, h => by simp only [head?, Option.mem_def, Option.some_inj] at h exact h ▸ rfl #align list.eq_cons_of_mem_head' List.eq_cons_of_mem_head? theorem mem_of_mem_head? {x : α} {l : List α} (h : x ∈ l.head?) : x ∈ l := (eq_cons_of_mem_head? h).symm ▸ mem_cons_self _ _ #align list.mem_of_mem_head' List.mem_of_mem_head? @[simp] theorem head!_cons [Inhabited α] (a : α) (l : List α) : head! (a :: l) = a := rfl #align list.head_cons List.head!_cons #align list.tail_nil List.tail_nil #align list.tail_cons List.tail_cons @[simp] theorem head!_append [Inhabited α] (t : List α) {s : List α} (h : s ≠ []) : head! (s ++ t) = head! s := by induction s · contradiction · rfl #align list.head_append List.head!_append theorem head?_append {s t : List α} {x : α} (h : x ∈ s.head?) : x ∈ (s ++ t).head? := by cases s · contradiction · exact h #align list.head'_append List.head?_append theorem head?_append_of_ne_nil : ∀ (l₁ : List α) {l₂ : List α} (_ : l₁ ≠ []), head? (l₁ ++ l₂) = head? l₁ | _ :: _, _, _ => rfl #align list.head'_append_of_ne_nil List.head?_append_of_ne_nil theorem tail_append_singleton_of_ne_nil {a : α} {l : List α} (h : l ≠ nil) : tail (l ++ [a]) = tail l ++ [a] := by induction l · contradiction · rw [tail, cons_append, tail] #align list.tail_append_singleton_of_ne_nil List.tail_append_singleton_of_ne_nil theorem cons_head?_tail : ∀ {l : List α} {a : α}, a ∈ head? l → a :: tail l = l | [], a, h => by contradiction | b :: l, a, h => by simp? at h says simp only [head?_cons, Option.mem_def, Option.some.injEq] at h simp [h] #align list.cons_head'_tail List.cons_head?_tail theorem head!_mem_head? [Inhabited α] : ∀ {l : List α}, l ≠ [] → head! l ∈ head? l | [], h => by contradiction | a :: l, _ => rfl #align list.head_mem_head' List.head!_mem_head? theorem cons_head!_tail [Inhabited α] {l : List α} (h : l ≠ []) : head! l :: tail l = l := cons_head?_tail (head!_mem_head? h) #align list.cons_head_tail List.cons_head!_tail theorem head!_mem_self [Inhabited α] {l : List α} (h : l ≠ nil) : l.head! ∈ l := by have h' := mem_cons_self l.head! l.tail rwa [cons_head!_tail h] at h' #align list.head_mem_self List.head!_mem_self theorem head_mem {l : List α} : ∀ (h : l ≠ nil), l.head h ∈ l := by cases l <;> simp @[simp] theorem head?_map (f : α → β) (l) : head? (map f l) = (head? l).map f := by cases l <;> rfl #align list.head'_map List.head?_map theorem tail_append_of_ne_nil (l l' : List α) (h : l ≠ []) : (l ++ l').tail = l.tail ++ l' := by cases l · contradiction · simp #align list.tail_append_of_ne_nil List.tail_append_of_ne_nil #align list.nth_le_eq_iff List.get_eq_iff theorem get_eq_get? (l : List α) (i : Fin l.length) : l.get i = (l.get? i).get (by simp [get?_eq_get]) := by simp [get_eq_iff] #align list.some_nth_le_eq List.get?_eq_get section deprecated set_option linter.deprecated false -- TODO(Mario): make replacements for theorems in this section @[deprecated get (since := "2023-01-05")] def nthLe (l : List α) (n) (h : n < l.length) : α := get l ⟨n, h⟩ #align list.nth_le List.nthLe @[simp] theorem nthLe_tail (l : List α) (i) (h : i < l.tail.length) (h' : i + 1 < l.length := (by simp only [length_tail] at h; omega)) : l.tail.nthLe i h = l.nthLe (i + 1) h' := by cases l <;> [cases h; rfl] #align list.nth_le_tail List.nthLe_tail theorem nthLe_cons_aux {l : List α} {a : α} {n} (hn : n ≠ 0) (h : n < (a :: l).length) : n - 1 < l.length := by contrapose! h rw [length_cons] omega #align list.nth_le_cons_aux List.nthLe_cons_aux
Mathlib/Data/List/Basic.lean
892
901
theorem nthLe_cons {l : List α} {a : α} {n} (hl) : (a :: l).nthLe n hl = if hn : n = 0 then a else l.nthLe (n - 1) (nthLe_cons_aux hn hl) := by
split_ifs with h · simp [nthLe, h] cases l · rw [length_singleton, Nat.lt_succ_iff] at hl omega cases n · contradiction rfl
import Mathlib.Algebra.GroupWithZero.Units.Lemmas import Mathlib.Data.Rat.Cast.Defs #align_import data.rat.cast from "leanprover-community/mathlib"@"acebd8d49928f6ed8920e502a6c90674e75bd441" variable {F ι α β : Type*} namespace Rat open Rat section WithDivRing variable [DivisionRing α] @[simp, norm_cast] theorem cast_inj [CharZero α] : ∀ {m n : ℚ}, (m : α) = n ↔ m = n | ⟨n₁, d₁, d₁0, c₁⟩, ⟨n₂, d₂, d₂0, c₂⟩ => by refine ⟨fun h => ?_, congr_arg _⟩ have d₁a : (d₁ : α) ≠ 0 := Nat.cast_ne_zero.2 d₁0 have d₂a : (d₂ : α) ≠ 0 := Nat.cast_ne_zero.2 d₂0 rw [mk'_eq_divInt, mk'_eq_divInt] at h ⊢ rw [cast_divInt_of_ne_zero, cast_divInt_of_ne_zero] at h <;> simp [d₁0, d₂0] at h ⊢ rwa [eq_div_iff_mul_eq d₂a, division_def, mul_assoc, (d₁.cast_commute (d₂ : α)).inv_left₀.eq, ← mul_assoc, ← division_def, eq_comm, eq_div_iff_mul_eq d₁a, eq_comm, ← Int.cast_natCast d₁, ← Int.cast_mul, ← Int.cast_natCast d₂, ← Int.cast_mul, Int.cast_inj, ← mkRat_eq_iff d₁0 d₂0] at h #align rat.cast_inj Rat.cast_inj theorem cast_injective [CharZero α] : Function.Injective ((↑) : ℚ → α) | _, _ => cast_inj.1 #align rat.cast_injective Rat.cast_injective @[simp]
Mathlib/Data/Rat/Cast/CharZero.lean
46
46
theorem cast_eq_zero [CharZero α] {n : ℚ} : (n : α) = 0 ↔ n = 0 := by
rw [← cast_zero, cast_inj]
import Mathlib.Analysis.Calculus.FDeriv.Bilinear #align_import analysis.calculus.fderiv.mul from "leanprover-community/mathlib"@"d608fc5d4e69d4cc21885913fb573a88b0deb521" open scoped Classical open Filter Asymptotics ContinuousLinearMap Set Metric Topology NNReal ENNReal noncomputable section section variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] variable {G' : Type*} [NormedAddCommGroup G'] [NormedSpace 𝕜 G'] variable {f f₀ f₁ g : E → F} variable {f' f₀' f₁' g' : E →L[𝕜] F} variable (e : E →L[𝕜] F) variable {x : E} variable {s t : Set E} variable {L L₁ L₂ : Filter E} section ContinuousMultilinearApplyConst variable {ι : Type*} [Fintype ι] {M : ι → Type*} [∀ i, NormedAddCommGroup (M i)] [∀ i, NormedSpace 𝕜 (M i)] {H : Type*} [NormedAddCommGroup H] [NormedSpace 𝕜 H] {c : E → ContinuousMultilinearMap 𝕜 M H} {c' : E →L[𝕜] ContinuousMultilinearMap 𝕜 M H} @[fun_prop] theorem HasStrictFDerivAt.continuousMultilinear_apply_const (hc : HasStrictFDerivAt c c' x) (u : ∀ i, M i) : HasStrictFDerivAt (fun y ↦ (c y) u) (c'.flipMultilinear u) x := (ContinuousMultilinearMap.apply 𝕜 M H u).hasStrictFDerivAt.comp x hc @[fun_prop] theorem HasFDerivWithinAt.continuousMultilinear_apply_const (hc : HasFDerivWithinAt c c' s x) (u : ∀ i, M i) : HasFDerivWithinAt (fun y ↦ (c y) u) (c'.flipMultilinear u) s x := (ContinuousMultilinearMap.apply 𝕜 M H u).hasFDerivAt.comp_hasFDerivWithinAt x hc @[fun_prop] theorem HasFDerivAt.continuousMultilinear_apply_const (hc : HasFDerivAt c c' x) (u : ∀ i, M i) : HasFDerivAt (fun y ↦ (c y) u) (c'.flipMultilinear u) x := (ContinuousMultilinearMap.apply 𝕜 M H u).hasFDerivAt.comp x hc @[fun_prop] theorem DifferentiableWithinAt.continuousMultilinear_apply_const (hc : DifferentiableWithinAt 𝕜 c s x) (u : ∀ i, M i) : DifferentiableWithinAt 𝕜 (fun y ↦ (c y) u) s x := (hc.hasFDerivWithinAt.continuousMultilinear_apply_const u).differentiableWithinAt @[fun_prop] theorem DifferentiableAt.continuousMultilinear_apply_const (hc : DifferentiableAt 𝕜 c x) (u : ∀ i, M i) : DifferentiableAt 𝕜 (fun y ↦ (c y) u) x := (hc.hasFDerivAt.continuousMultilinear_apply_const u).differentiableAt @[fun_prop] theorem DifferentiableOn.continuousMultilinear_apply_const (hc : DifferentiableOn 𝕜 c s) (u : ∀ i, M i) : DifferentiableOn 𝕜 (fun y ↦ (c y) u) s := fun x hx ↦ (hc x hx).continuousMultilinear_apply_const u @[fun_prop] theorem Differentiable.continuousMultilinear_apply_const (hc : Differentiable 𝕜 c) (u : ∀ i, M i) : Differentiable 𝕜 fun y ↦ (c y) u := fun x ↦ (hc x).continuousMultilinear_apply_const u theorem fderivWithin_continuousMultilinear_apply_const (hxs : UniqueDiffWithinAt 𝕜 s x) (hc : DifferentiableWithinAt 𝕜 c s x) (u : ∀ i, M i) : fderivWithin 𝕜 (fun y ↦ (c y) u) s x = ((fderivWithin 𝕜 c s x).flipMultilinear u) := (hc.hasFDerivWithinAt.continuousMultilinear_apply_const u).fderivWithin hxs theorem fderiv_continuousMultilinear_apply_const (hc : DifferentiableAt 𝕜 c x) (u : ∀ i, M i) : (fderiv 𝕜 (fun y ↦ (c y) u) x) = (fderiv 𝕜 c x).flipMultilinear u := (hc.hasFDerivAt.continuousMultilinear_apply_const u).fderiv theorem fderivWithin_continuousMultilinear_apply_const_apply (hxs : UniqueDiffWithinAt 𝕜 s x) (hc : DifferentiableWithinAt 𝕜 c s x) (u : ∀ i, M i) (m : E) : (fderivWithin 𝕜 (fun y ↦ (c y) u) s x) m = (fderivWithin 𝕜 c s x) m u := by simp [fderivWithin_continuousMultilinear_apply_const hxs hc]
Mathlib/Analysis/Calculus/FDeriv/Mul.lean
230
233
theorem fderiv_continuousMultilinear_apply_const_apply (hc : DifferentiableAt 𝕜 c x) (u : ∀ i, M i) (m : E) : (fderiv 𝕜 (fun y ↦ (c y) u) x) m = (fderiv 𝕜 c x) m u := by
simp [fderiv_continuousMultilinear_apply_const hc]
import Mathlib.LinearAlgebra.Matrix.DotProduct import Mathlib.LinearAlgebra.Determinant import Mathlib.LinearAlgebra.Matrix.Diagonal #align_import data.matrix.rank from "leanprover-community/mathlib"@"17219820a8aa8abe85adf5dfde19af1dd1bd8ae7" open Matrix namespace Matrix open FiniteDimensional variable {l m n o R : Type*} [Fintype n] [Fintype o] section CommRing variable [CommRing R] noncomputable def rank (A : Matrix m n R) : ℕ := finrank R <| LinearMap.range A.mulVecLin #align matrix.rank Matrix.rank @[simp] theorem rank_one [StrongRankCondition R] [DecidableEq n] : rank (1 : Matrix n n R) = Fintype.card n := by rw [rank, mulVecLin_one, LinearMap.range_id, finrank_top, finrank_pi] #align matrix.rank_one Matrix.rank_one @[simp] theorem rank_zero [Nontrivial R] : rank (0 : Matrix m n R) = 0 := by rw [rank, mulVecLin_zero, LinearMap.range_zero, finrank_bot] #align matrix.rank_zero Matrix.rank_zero theorem rank_le_card_width [StrongRankCondition R] (A : Matrix m n R) : A.rank ≤ Fintype.card n := by haveI : Module.Finite R (n → R) := Module.Finite.pi haveI : Module.Free R (n → R) := Module.Free.pi _ _ exact A.mulVecLin.finrank_range_le.trans_eq (finrank_pi _) #align matrix.rank_le_card_width Matrix.rank_le_card_width theorem rank_le_width [StrongRankCondition R] {m n : ℕ} (A : Matrix (Fin m) (Fin n) R) : A.rank ≤ n := A.rank_le_card_width.trans <| (Fintype.card_fin n).le #align matrix.rank_le_width Matrix.rank_le_width theorem rank_mul_le_left [StrongRankCondition R] (A : Matrix m n R) (B : Matrix n o R) : (A * B).rank ≤ A.rank := by rw [rank, rank, mulVecLin_mul] exact Cardinal.toNat_le_toNat (LinearMap.rank_comp_le_left _ _) (rank_lt_aleph0 _ _) #align matrix.rank_mul_le_left Matrix.rank_mul_le_left theorem rank_mul_le_right [StrongRankCondition R] (A : Matrix m n R) (B : Matrix n o R) : (A * B).rank ≤ B.rank := by rw [rank, rank, mulVecLin_mul] exact finrank_le_finrank_of_rank_le_rank (LinearMap.lift_rank_comp_le_right _ _) (rank_lt_aleph0 _ _) #align matrix.rank_mul_le_right Matrix.rank_mul_le_right theorem rank_mul_le [StrongRankCondition R] (A : Matrix m n R) (B : Matrix n o R) : (A * B).rank ≤ min A.rank B.rank := le_min (rank_mul_le_left _ _) (rank_mul_le_right _ _) #align matrix.rank_mul_le Matrix.rank_mul_le theorem rank_unit [StrongRankCondition R] [DecidableEq n] (A : (Matrix n n R)ˣ) : (A : Matrix n n R).rank = Fintype.card n := by apply le_antisymm (rank_le_card_width (A : Matrix n n R)) _ have := rank_mul_le_left (A : Matrix n n R) (↑A⁻¹ : Matrix n n R) rwa [← Units.val_mul, mul_inv_self, Units.val_one, rank_one] at this #align matrix.rank_unit Matrix.rank_unit theorem rank_of_isUnit [StrongRankCondition R] [DecidableEq n] (A : Matrix n n R) (h : IsUnit A) : A.rank = Fintype.card n := by obtain ⟨A, rfl⟩ := h exact rank_unit A #align matrix.rank_of_is_unit Matrix.rank_of_isUnit @[simp] lemma rank_mul_eq_left_of_isUnit_det [DecidableEq n] (A : Matrix n n R) (B : Matrix m n R) (hA : IsUnit A.det) : (B * A).rank = B.rank := by suffices Function.Surjective A.mulVecLin by rw [rank, mulVecLin_mul, LinearMap.range_comp_of_range_eq_top _ (LinearMap.range_eq_top.mpr this), ← rank] intro v exact ⟨(A⁻¹).mulVecLin v, by simp [mul_nonsing_inv _ hA]⟩ @[simp] lemma rank_mul_eq_right_of_isUnit_det [Fintype m] [DecidableEq m] (A : Matrix m m R) (B : Matrix m n R) (hA : IsUnit A.det) : (A * B).rank = B.rank := by let b : Basis m R (m → R) := Pi.basisFun R m replace hA : IsUnit (LinearMap.toMatrix b b A.mulVecLin).det := by convert hA; rw [← LinearEquiv.eq_symm_apply]; rfl have hAB : mulVecLin (A * B) = (LinearEquiv.ofIsUnitDet hA).comp (mulVecLin B) := by ext; simp rw [rank, rank, hAB, LinearMap.range_comp, LinearEquiv.finrank_map_eq] theorem rank_submatrix_le [StrongRankCondition R] [Fintype m] (f : n → m) (e : n ≃ m) (A : Matrix m m R) : rank (A.submatrix f e) ≤ rank A := by rw [rank, rank, mulVecLin_submatrix, LinearMap.range_comp, LinearMap.range_comp, show LinearMap.funLeft R R e.symm = LinearEquiv.funCongrLeft R R e.symm from rfl, LinearEquiv.range, Submodule.map_top] exact Submodule.finrank_map_le _ _ #align matrix.rank_submatrix_le Matrix.rank_submatrix_le theorem rank_reindex [Fintype m] (e₁ e₂ : m ≃ n) (A : Matrix m m R) : rank (reindex e₁ e₂ A) = rank A := by rw [rank, rank, mulVecLin_reindex, LinearMap.range_comp, LinearMap.range_comp, LinearEquiv.range, Submodule.map_top, LinearEquiv.finrank_map_eq] #align matrix.rank_reindex Matrix.rank_reindex @[simp] theorem rank_submatrix [Fintype m] (A : Matrix m m R) (e₁ e₂ : n ≃ m) : rank (A.submatrix e₁ e₂) = rank A := by simpa only [reindex_apply] using rank_reindex e₁.symm e₂.symm A #align matrix.rank_submatrix Matrix.rank_submatrix theorem rank_eq_finrank_range_toLin [Finite m] [DecidableEq n] {M₁ M₂ : Type*} [AddCommGroup M₁] [AddCommGroup M₂] [Module R M₁] [Module R M₂] (A : Matrix m n R) (v₁ : Basis m R M₁) (v₂ : Basis n R M₂) : A.rank = finrank R (LinearMap.range (toLin v₂ v₁ A)) := by cases nonempty_fintype m let e₁ := (Pi.basisFun R m).equiv v₁ (Equiv.refl _) let e₂ := (Pi.basisFun R n).equiv v₂ (Equiv.refl _) have range_e₂ : LinearMap.range e₂ = ⊤ := by rw [LinearMap.range_eq_top] exact e₂.surjective refine LinearEquiv.finrank_eq (e₁.ofSubmodules _ _ ?_) rw [← LinearMap.range_comp, ← LinearMap.range_comp_of_range_eq_top (toLin v₂ v₁ A) range_e₂] congr 1 apply LinearMap.pi_ext' rintro i apply LinearMap.ext_ring have aux₁ := toLin_self (Pi.basisFun R n) (Pi.basisFun R m) A i have aux₂ := Basis.equiv_apply (Pi.basisFun R n) i v₂ rw [toLin_eq_toLin', toLin'_apply'] at aux₁ rw [Pi.basisFun_apply, LinearMap.coe_stdBasis] at aux₁ aux₂ simp only [e₁, e₁, LinearMap.comp_apply, LinearEquiv.coe_coe, Equiv.refl_apply, aux₁, aux₂, LinearMap.coe_single, toLin_self, map_sum, LinearEquiv.map_smul, Basis.equiv_apply] #align matrix.rank_eq_finrank_range_to_lin Matrix.rank_eq_finrank_range_toLin theorem rank_le_card_height [Fintype m] [StrongRankCondition R] (A : Matrix m n R) : A.rank ≤ Fintype.card m := by haveI : Module.Finite R (m → R) := Module.Finite.pi haveI : Module.Free R (m → R) := Module.Free.pi _ _ exact (Submodule.finrank_le _).trans (finrank_pi R).le #align matrix.rank_le_card_height Matrix.rank_le_card_height theorem rank_le_height [StrongRankCondition R] {m n : ℕ} (A : Matrix (Fin m) (Fin n) R) : A.rank ≤ m := A.rank_le_card_height.trans <| (Fintype.card_fin m).le #align matrix.rank_le_height Matrix.rank_le_height
Mathlib/Data/Matrix/Rank.lean
181
182
theorem rank_eq_finrank_span_cols (A : Matrix m n R) : A.rank = finrank R (Submodule.span R (Set.range Aᵀ)) := by
rw [rank, Matrix.range_mulVecLin]
import Mathlib.Algebra.BigOperators.Group.List import Mathlib.Algebra.Group.Prod import Mathlib.Data.Multiset.Basic #align_import algebra.big_operators.multiset.basic from "leanprover-community/mathlib"@"6c5f73fd6f6cc83122788a80a27cdd54663609f4" assert_not_exists MonoidWithZero variable {F ι α β γ : Type*} namespace Multiset section CommMonoid variable [CommMonoid α] [CommMonoid β] {s t : Multiset α} {a : α} {m : Multiset ι} {f g : ι → α} @[to_additive "Sum of a multiset given a commutative additive monoid structure on `α`. `sum {a, b, c} = a + b + c`"] def prod : Multiset α → α := foldr (· * ·) (fun x y z => by simp [mul_left_comm]) 1 #align multiset.prod Multiset.prod #align multiset.sum Multiset.sum @[to_additive] theorem prod_eq_foldr (s : Multiset α) : prod s = foldr (· * ·) (fun x y z => by simp [mul_left_comm]) 1 s := rfl #align multiset.prod_eq_foldr Multiset.prod_eq_foldr #align multiset.sum_eq_foldr Multiset.sum_eq_foldr @[to_additive] theorem prod_eq_foldl (s : Multiset α) : prod s = foldl (· * ·) (fun x y z => by simp [mul_right_comm]) 1 s := (foldr_swap _ _ _ _).trans (by simp [mul_comm]) #align multiset.prod_eq_foldl Multiset.prod_eq_foldl #align multiset.sum_eq_foldl Multiset.sum_eq_foldl @[to_additive (attr := simp, norm_cast)] theorem prod_coe (l : List α) : prod ↑l = l.prod := prod_eq_foldl _ #align multiset.coe_prod Multiset.prod_coe #align multiset.coe_sum Multiset.sum_coe @[to_additive (attr := simp)] theorem prod_toList (s : Multiset α) : s.toList.prod = s.prod := by conv_rhs => rw [← coe_toList s] rw [prod_coe] #align multiset.prod_to_list Multiset.prod_toList #align multiset.sum_to_list Multiset.sum_toList @[to_additive (attr := simp)] theorem prod_zero : @prod α _ 0 = 1 := rfl #align multiset.prod_zero Multiset.prod_zero #align multiset.sum_zero Multiset.sum_zero @[to_additive (attr := simp)] theorem prod_cons (a : α) (s) : prod (a ::ₘ s) = a * prod s := foldr_cons _ _ _ _ _ #align multiset.prod_cons Multiset.prod_cons #align multiset.sum_cons Multiset.sum_cons @[to_additive (attr := simp)] theorem prod_erase [DecidableEq α] (h : a ∈ s) : a * (s.erase a).prod = s.prod := by rw [← s.coe_toList, coe_erase, prod_coe, prod_coe, List.prod_erase (mem_toList.2 h)] #align multiset.prod_erase Multiset.prod_erase #align multiset.sum_erase Multiset.sum_erase @[to_additive (attr := simp)] theorem prod_map_erase [DecidableEq ι] {a : ι} (h : a ∈ m) : f a * ((m.erase a).map f).prod = (m.map f).prod := by rw [← m.coe_toList, coe_erase, map_coe, map_coe, prod_coe, prod_coe, List.prod_map_erase f (mem_toList.2 h)] #align multiset.prod_map_erase Multiset.prod_map_erase #align multiset.sum_map_erase Multiset.sum_map_erase @[to_additive (attr := simp)] theorem prod_singleton (a : α) : prod {a} = a := by simp only [mul_one, prod_cons, ← cons_zero, eq_self_iff_true, prod_zero] #align multiset.prod_singleton Multiset.prod_singleton #align multiset.sum_singleton Multiset.sum_singleton @[to_additive] theorem prod_pair (a b : α) : ({a, b} : Multiset α).prod = a * b := by rw [insert_eq_cons, prod_cons, prod_singleton] #align multiset.prod_pair Multiset.prod_pair #align multiset.sum_pair Multiset.sum_pair @[to_additive (attr := simp)] theorem prod_add (s t : Multiset α) : prod (s + t) = prod s * prod t := Quotient.inductionOn₂ s t fun l₁ l₂ => by simp #align multiset.prod_add Multiset.prod_add #align multiset.sum_add Multiset.sum_add @[to_additive] theorem prod_nsmul (m : Multiset α) : ∀ n : ℕ, (n • m).prod = m.prod ^ n | 0 => by rw [zero_nsmul, pow_zero] rfl | n + 1 => by rw [add_nsmul, one_nsmul, pow_add, pow_one, prod_add, prod_nsmul m n] #align multiset.prod_nsmul Multiset.prod_nsmul @[to_additive] theorem prod_filter_mul_prod_filter_not (p) [DecidablePred p] : (s.filter p).prod * (s.filter (fun a ↦ ¬ p a)).prod = s.prod := by rw [← prod_add, filter_add_not] @[to_additive (attr := simp)] theorem prod_replicate (n : ℕ) (a : α) : (replicate n a).prod = a ^ n := by simp [replicate, List.prod_replicate] #align multiset.prod_replicate Multiset.prod_replicate #align multiset.sum_replicate Multiset.sum_replicate @[to_additive] theorem prod_map_eq_pow_single [DecidableEq ι] (i : ι) (hf : ∀ i' ≠ i, i' ∈ m → f i' = 1) : (m.map f).prod = f i ^ m.count i := by induction' m using Quotient.inductionOn with l simp [List.prod_map_eq_pow_single i f hf] #align multiset.prod_map_eq_pow_single Multiset.prod_map_eq_pow_single #align multiset.sum_map_eq_nsmul_single Multiset.sum_map_eq_nsmul_single @[to_additive] theorem prod_eq_pow_single [DecidableEq α] (a : α) (h : ∀ a' ≠ a, a' ∈ s → a' = 1) : s.prod = a ^ s.count a := by induction' s using Quotient.inductionOn with l simp [List.prod_eq_pow_single a h] #align multiset.prod_eq_pow_single Multiset.prod_eq_pow_single #align multiset.sum_eq_nsmul_single Multiset.sum_eq_nsmul_single @[to_additive] lemma prod_eq_one (h : ∀ x ∈ s, x = (1 : α)) : s.prod = 1 := by induction' s using Quotient.inductionOn with l; simp [List.prod_eq_one h] #align multiset.prod_eq_one Multiset.prod_eq_one #align multiset.sum_eq_zero Multiset.sum_eq_zero @[to_additive] theorem pow_count [DecidableEq α] (a : α) : a ^ s.count a = (s.filter (Eq a)).prod := by rw [filter_eq, prod_replicate] #align multiset.pow_count Multiset.pow_count #align multiset.nsmul_count Multiset.nsmul_count @[to_additive] theorem prod_hom [CommMonoid β] (s : Multiset α) {F : Type*} [FunLike F α β] [MonoidHomClass F α β] (f : F) : (s.map f).prod = f s.prod := Quotient.inductionOn s fun l => by simp only [l.prod_hom f, quot_mk_to_coe, map_coe, prod_coe] #align multiset.prod_hom Multiset.prod_hom #align multiset.sum_hom Multiset.sum_hom @[to_additive] theorem prod_hom' [CommMonoid β] (s : Multiset ι) {F : Type*} [FunLike F α β] [MonoidHomClass F α β] (f : F) (g : ι → α) : (s.map fun i => f <| g i).prod = f (s.map g).prod := by convert (s.map g).prod_hom f exact (map_map _ _ _).symm #align multiset.prod_hom' Multiset.prod_hom' #align multiset.sum_hom' Multiset.sum_hom' @[to_additive] theorem prod_hom₂ [CommMonoid β] [CommMonoid γ] (s : Multiset ι) (f : α → β → γ) (hf : ∀ a b c d, f (a * b) (c * d) = f a c * f b d) (hf' : f 1 1 = 1) (f₁ : ι → α) (f₂ : ι → β) : (s.map fun i => f (f₁ i) (f₂ i)).prod = f (s.map f₁).prod (s.map f₂).prod := Quotient.inductionOn s fun l => by simp only [l.prod_hom₂ f hf hf', quot_mk_to_coe, map_coe, prod_coe] #align multiset.prod_hom₂ Multiset.prod_hom₂ #align multiset.sum_hom₂ Multiset.sum_hom₂ @[to_additive] theorem prod_hom_rel [CommMonoid β] (s : Multiset ι) {r : α → β → Prop} {f : ι → α} {g : ι → β} (h₁ : r 1 1) (h₂ : ∀ ⦃a b c⦄, r b c → r (f a * b) (g a * c)) : r (s.map f).prod (s.map g).prod := Quotient.inductionOn s fun l => by simp only [l.prod_hom_rel h₁ h₂, quot_mk_to_coe, map_coe, prod_coe] #align multiset.prod_hom_rel Multiset.prod_hom_rel #align multiset.sum_hom_rel Multiset.sum_hom_rel @[to_additive] theorem prod_map_one : prod (m.map fun _ => (1 : α)) = 1 := by rw [map_const', prod_replicate, one_pow] #align multiset.prod_map_one Multiset.prod_map_one #align multiset.sum_map_zero Multiset.sum_map_zero @[to_additive (attr := simp)] theorem prod_map_mul : (m.map fun i => f i * g i).prod = (m.map f).prod * (m.map g).prod := m.prod_hom₂ (· * ·) mul_mul_mul_comm (mul_one _) _ _ #align multiset.prod_map_mul Multiset.prod_map_mul #align multiset.sum_map_add Multiset.sum_map_add @[to_additive] theorem prod_map_pow {n : ℕ} : (m.map fun i => f i ^ n).prod = (m.map f).prod ^ n := m.prod_hom' (powMonoidHom n : α →* α) f #align multiset.prod_map_pow Multiset.prod_map_pow #align multiset.sum_map_nsmul Multiset.sum_map_nsmul @[to_additive] theorem prod_map_prod_map (m : Multiset β) (n : Multiset γ) {f : β → γ → α} : prod (m.map fun a => prod <| n.map fun b => f a b) = prod (n.map fun b => prod <| m.map fun a => f a b) := Multiset.induction_on m (by simp) fun a m ih => by simp [ih] #align multiset.prod_map_prod_map Multiset.prod_map_prod_map #align multiset.sum_map_sum_map Multiset.sum_map_sum_map @[to_additive] theorem prod_induction (p : α → Prop) (s : Multiset α) (p_mul : ∀ a b, p a → p b → p (a * b)) (p_one : p 1) (p_s : ∀ a ∈ s, p a) : p s.prod := by rw [prod_eq_foldr] exact foldr_induction (· * ·) (fun x y z => by simp [mul_left_comm]) 1 p s p_mul p_one p_s #align multiset.prod_induction Multiset.prod_induction #align multiset.sum_induction Multiset.sum_induction @[to_additive] theorem prod_induction_nonempty (p : α → Prop) (p_mul : ∀ a b, p a → p b → p (a * b)) (hs : s ≠ ∅) (p_s : ∀ a ∈ s, p a) : p s.prod := by -- Porting note: used to be `refine' Multiset.induction _ _` induction' s using Multiset.induction_on with a s hsa · simp at hs rw [prod_cons] by_cases hs_empty : s = ∅ · simp [hs_empty, p_s a] have hps : ∀ x, x ∈ s → p x := fun x hxs => p_s x (mem_cons_of_mem hxs) exact p_mul a s.prod (p_s a (mem_cons_self a s)) (hsa hs_empty hps) #align multiset.prod_induction_nonempty Multiset.prod_induction_nonempty #align multiset.sum_induction_nonempty Multiset.sum_induction_nonempty
Mathlib/Algebra/BigOperators/Group/Multiset.lean
246
248
theorem prod_dvd_prod_of_le (h : s ≤ t) : s.prod ∣ t.prod := by
obtain ⟨z, rfl⟩ := exists_add_of_le h simp only [prod_add, dvd_mul_right]
import Mathlib.Topology.Category.TopCat.EpiMono import Mathlib.Topology.Category.TopCat.Limits.Basic import Mathlib.CategoryTheory.Limits.Shapes.Products import Mathlib.CategoryTheory.Limits.ConcreteCategory import Mathlib.Data.Set.Subsingleton import Mathlib.Tactic.CategoryTheory.Elementwise #align_import topology.category.Top.limits.products from "leanprover-community/mathlib"@"178a32653e369dce2da68dc6b2694e385d484ef1" -- Porting note: every ML3 decl has an uppercase letter set_option linter.uppercaseLean3 false open TopologicalSpace open CategoryTheory open CategoryTheory.Limits universe v u w noncomputable section namespace TopCat variable {J : Type v} [SmallCategory J] abbrev piπ {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) : TopCat.of (∀ i, α i) ⟶ α i := ⟨fun f => f i, continuous_apply i⟩ #align Top.pi_π TopCat.piπ @[simps! pt π_app] def piFan {ι : Type v} (α : ι → TopCat.{max v u}) : Fan α := Fan.mk (TopCat.of (∀ i, α i)) (piπ.{v,u} α) #align Top.pi_fan TopCat.piFan def piFanIsLimit {ι : Type v} (α : ι → TopCat.{max v u}) : IsLimit (piFan α) where lift S := { toFun := fun s i => S.π.app ⟨i⟩ s continuous_toFun := continuous_pi (fun i => (S.π.app ⟨i⟩).2) } uniq := by intro S m h apply ContinuousMap.ext; intro x funext i set_option tactic.skipAssignedInstances false in dsimp rw [ContinuousMap.coe_mk, ← h ⟨i⟩] rfl fac s j := rfl #align Top.pi_fan_is_limit TopCat.piFanIsLimit def piIsoPi {ι : Type v} (α : ι → TopCat.{max v u}) : ∏ᶜ α ≅ TopCat.of (∀ i, α i) := (limit.isLimit _).conePointUniqueUpToIso (piFanIsLimit.{v, u} α) -- Specifying the universes in `piFanIsLimit` wasn't necessary when we had `TopCatMax`  #align Top.pi_iso_pi TopCat.piIsoPi @[reassoc (attr := simp)] theorem piIsoPi_inv_π {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) : (piIsoPi α).inv ≫ Pi.π α i = piπ α i := by simp [piIsoPi] #align Top.pi_iso_pi_inv_π TopCat.piIsoPi_inv_π theorem piIsoPi_inv_π_apply {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) (x : ∀ i, α i) : (Pi.π α i : _) ((piIsoPi α).inv x) = x i := ConcreteCategory.congr_hom (piIsoPi_inv_π α i) x #align Top.pi_iso_pi_inv_π_apply TopCat.piIsoPi_inv_π_apply -- Porting note: needing the type ascription on `∏ᶜ α : TopCat.{max v u}` is unfortunate.
Mathlib/Topology/Category/TopCat/Limits/Products.lean
82
86
theorem piIsoPi_hom_apply {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) (x : (∏ᶜ α : TopCat.{max v u})) : (piIsoPi α).hom x i = (Pi.π α i : _) x := by
have := piIsoPi_inv_π α i rw [Iso.inv_comp_eq] at this exact ConcreteCategory.congr_hom this x
import Mathlib.Algebra.Order.Module.OrderedSMul import Mathlib.Analysis.Convex.Star import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace #align_import analysis.convex.basic from "leanprover-community/mathlib"@"92bd7b1ffeb306a89f450bee126ddd8a284c259d" variable {𝕜 E F β : Type*} open LinearMap Set open scoped Convex Pointwise section OrderedSemiring variable [OrderedSemiring 𝕜] section AddCommMonoid variable [AddCommMonoid E] [AddCommMonoid F] section SMul variable (𝕜) [SMul 𝕜 E] [SMul 𝕜 F] (s : Set E) {x : E} def Convex : Prop := ∀ ⦃x : E⦄, x ∈ s → StarConvex 𝕜 x s #align convex Convex variable {𝕜 s} theorem Convex.starConvex (hs : Convex 𝕜 s) (hx : x ∈ s) : StarConvex 𝕜 x s := hs hx #align convex.star_convex Convex.starConvex theorem convex_iff_segment_subset : Convex 𝕜 s ↔ ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → [x -[𝕜] y] ⊆ s := forall₂_congr fun _ _ => starConvex_iff_segment_subset #align convex_iff_segment_subset convex_iff_segment_subset theorem Convex.segment_subset (h : Convex 𝕜 s) {x y : E} (hx : x ∈ s) (hy : y ∈ s) : [x -[𝕜] y] ⊆ s := convex_iff_segment_subset.1 h hx hy #align convex.segment_subset Convex.segment_subset theorem Convex.openSegment_subset (h : Convex 𝕜 s) {x y : E} (hx : x ∈ s) (hy : y ∈ s) : openSegment 𝕜 x y ⊆ s := (openSegment_subset_segment 𝕜 x y).trans (h.segment_subset hx hy) #align convex.open_segment_subset Convex.openSegment_subset theorem convex_iff_pointwise_add_subset : Convex 𝕜 s ↔ ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → a + b = 1 → a • s + b • s ⊆ s := Iff.intro (by rintro hA a b ha hb hab w ⟨au, ⟨u, hu, rfl⟩, bv, ⟨v, hv, rfl⟩, rfl⟩ exact hA hu hv ha hb hab) fun h x hx y hy a b ha hb hab => (h ha hb hab) (Set.add_mem_add ⟨_, hx, rfl⟩ ⟨_, hy, rfl⟩) #align convex_iff_pointwise_add_subset convex_iff_pointwise_add_subset alias ⟨Convex.set_combo_subset, _⟩ := convex_iff_pointwise_add_subset #align convex.set_combo_subset Convex.set_combo_subset theorem convex_empty : Convex 𝕜 (∅ : Set E) := fun _ => False.elim #align convex_empty convex_empty theorem convex_univ : Convex 𝕜 (Set.univ : Set E) := fun _ _ => starConvex_univ _ #align convex_univ convex_univ theorem Convex.inter {t : Set E} (hs : Convex 𝕜 s) (ht : Convex 𝕜 t) : Convex 𝕜 (s ∩ t) := fun _ hx => (hs hx.1).inter (ht hx.2) #align convex.inter Convex.inter theorem convex_sInter {S : Set (Set E)} (h : ∀ s ∈ S, Convex 𝕜 s) : Convex 𝕜 (⋂₀ S) := fun _ hx => starConvex_sInter fun _ hs => h _ hs <| hx _ hs #align convex_sInter convex_sInter theorem convex_iInter {ι : Sort*} {s : ι → Set E} (h : ∀ i, Convex 𝕜 (s i)) : Convex 𝕜 (⋂ i, s i) := sInter_range s ▸ convex_sInter <| forall_mem_range.2 h #align convex_Inter convex_iInter theorem convex_iInter₂ {ι : Sort*} {κ : ι → Sort*} {s : ∀ i, κ i → Set E} (h : ∀ i j, Convex 𝕜 (s i j)) : Convex 𝕜 (⋂ (i) (j), s i j) := convex_iInter fun i => convex_iInter <| h i #align convex_Inter₂ convex_iInter₂ theorem Convex.prod {s : Set E} {t : Set F} (hs : Convex 𝕜 s) (ht : Convex 𝕜 t) : Convex 𝕜 (s ×ˢ t) := fun _ hx => (hs hx.1).prod (ht hx.2) #align convex.prod Convex.prod theorem convex_pi {ι : Type*} {E : ι → Type*} [∀ i, AddCommMonoid (E i)] [∀ i, SMul 𝕜 (E i)] {s : Set ι} {t : ∀ i, Set (E i)} (ht : ∀ ⦃i⦄, i ∈ s → Convex 𝕜 (t i)) : Convex 𝕜 (s.pi t) := fun _ hx => starConvex_pi fun _ hi => ht hi <| hx _ hi #align convex_pi convex_pi
Mathlib/Analysis/Convex/Basic.lean
121
128
theorem Directed.convex_iUnion {ι : Sort*} {s : ι → Set E} (hdir : Directed (· ⊆ ·) s) (hc : ∀ ⦃i : ι⦄, Convex 𝕜 (s i)) : Convex 𝕜 (⋃ i, s i) := by
rintro x hx y hy a b ha hb hab rw [mem_iUnion] at hx hy ⊢ obtain ⟨i, hx⟩ := hx obtain ⟨j, hy⟩ := hy obtain ⟨k, hik, hjk⟩ := hdir i j exact ⟨k, hc (hik hx) (hjk hy) ha hb hab⟩
import Mathlib.CategoryTheory.Abelian.Exact import Mathlib.CategoryTheory.Preadditive.Injective import Mathlib.CategoryTheory.Preadditive.Yoneda.Limits import Mathlib.CategoryTheory.Preadditive.Yoneda.Injective #align_import category_theory.abelian.injective from "leanprover-community/mathlib"@"f8d8465c3c392a93b9ed226956e26dee00975946" noncomputable section open CategoryTheory open CategoryTheory.Limits open CategoryTheory.Injective open Opposite universe v u namespace CategoryTheory variable {C : Type u} [Category.{v} C] [Abelian C] def preservesFiniteColimitsPreadditiveYonedaObjOfInjective (J : C) [hP : Injective J] : PreservesFiniteColimits (preadditiveYonedaObj J) := by letI := (injective_iff_preservesEpimorphisms_preadditive_yoneda_obj' J).mp hP apply Functor.preservesFiniteColimitsOfPreservesEpisAndKernels #align category_theory.preserves_finite_colimits_preadditive_yoneda_obj_of_injective CategoryTheory.preservesFiniteColimitsPreadditiveYonedaObjOfInjective
Mathlib/CategoryTheory/Abelian/Injective.lean
45
48
theorem injective_of_preservesFiniteColimits_preadditiveYonedaObj (J : C) [hP : PreservesFiniteColimits (preadditiveYonedaObj J)] : Injective J := by
rw [injective_iff_preservesEpimorphisms_preadditive_yoneda_obj'] infer_instance
import Mathlib.Probability.Martingale.Convergence import Mathlib.Probability.Martingale.OptionalStopping import Mathlib.Probability.Martingale.Centering #align_import probability.martingale.borel_cantelli from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" open Filter open scoped NNReal ENNReal MeasureTheory ProbabilityTheory BigOperators Topology namespace MeasureTheory variable {Ω : Type*} {m0 : MeasurableSpace Ω} {μ : Measure Ω} {ℱ : Filtration ℕ m0} {f : ℕ → Ω → ℝ} {ω : Ω} -- TODO: `leastGE` should be defined taking values in `WithTop ℕ` once the `stoppedProcess` -- refactor is complete noncomputable def leastGE (f : ℕ → Ω → ℝ) (r : ℝ) (n : ℕ) := hitting f (Set.Ici r) 0 n #align measure_theory.least_ge MeasureTheory.leastGE theorem Adapted.isStoppingTime_leastGE (r : ℝ) (n : ℕ) (hf : Adapted ℱ f) : IsStoppingTime ℱ (leastGE f r n) := hitting_isStoppingTime hf measurableSet_Ici #align measure_theory.adapted.is_stopping_time_least_ge MeasureTheory.Adapted.isStoppingTime_leastGE theorem leastGE_le {i : ℕ} {r : ℝ} (ω : Ω) : leastGE f r i ω ≤ i := hitting_le ω #align measure_theory.least_ge_le MeasureTheory.leastGE_le -- The following four lemmas shows `leastGE` behaves like a stopped process. Ideally we should -- define `leastGE` as a stopping time and take its stopped process. However, we can't do that -- with our current definition since a stopping time takes only finite indicies. An upcomming -- refactor should hopefully make it possible to have stopping times taking infinity as a value theorem leastGE_mono {n m : ℕ} (hnm : n ≤ m) (r : ℝ) (ω : Ω) : leastGE f r n ω ≤ leastGE f r m ω := hitting_mono hnm #align measure_theory.least_ge_mono MeasureTheory.leastGE_mono theorem leastGE_eq_min (π : Ω → ℕ) (r : ℝ) (ω : Ω) {n : ℕ} (hπn : ∀ ω, π ω ≤ n) : leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω) := by classical refine le_antisymm (le_min (leastGE_le _) (leastGE_mono (hπn ω) r ω)) ?_ by_cases hle : π ω ≤ leastGE f r n ω · rw [min_eq_left hle, leastGE] by_cases h : ∃ j ∈ Set.Icc 0 (π ω), f j ω ∈ Set.Ici r · refine hle.trans (Eq.le ?_) rw [leastGE, ← hitting_eq_hitting_of_exists (hπn ω) h] · simp only [hitting, if_neg h, le_rfl] · rw [min_eq_right (not_le.1 hle).le, leastGE, leastGE, ← hitting_eq_hitting_of_exists (hπn ω) _] rw [not_le, leastGE, hitting_lt_iff _ (hπn ω)] at hle exact let ⟨j, hj₁, hj₂⟩ := hle ⟨j, ⟨hj₁.1, hj₁.2.le⟩, hj₂⟩ #align measure_theory.least_ge_eq_min MeasureTheory.leastGE_eq_min theorem stoppedValue_stoppedValue_leastGE (f : ℕ → Ω → ℝ) (π : Ω → ℕ) (r : ℝ) {n : ℕ} (hπn : ∀ ω, π ω ≤ n) : stoppedValue (fun i => stoppedValue f (leastGE f r i)) π = stoppedValue (stoppedProcess f (leastGE f r n)) π := by ext1 ω simp (config := { unfoldPartialApp := true }) only [stoppedProcess, stoppedValue] rw [leastGE_eq_min _ _ _ hπn] #align measure_theory.stopped_value_stopped_value_least_ge MeasureTheory.stoppedValue_stoppedValue_leastGE theorem Submartingale.stoppedValue_leastGE [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ) (r : ℝ) : Submartingale (fun i => stoppedValue f (leastGE f r i)) ℱ μ := by rw [submartingale_iff_expected_stoppedValue_mono] · intro σ π hσ hπ hσ_le_π hπ_bdd obtain ⟨n, hπ_le_n⟩ := hπ_bdd simp_rw [stoppedValue_stoppedValue_leastGE f σ r fun i => (hσ_le_π i).trans (hπ_le_n i)] simp_rw [stoppedValue_stoppedValue_leastGE f π r hπ_le_n] refine hf.expected_stoppedValue_mono ?_ ?_ ?_ fun ω => (min_le_left _ _).trans (hπ_le_n ω) · exact hσ.min (hf.adapted.isStoppingTime_leastGE _ _) · exact hπ.min (hf.adapted.isStoppingTime_leastGE _ _) · exact fun ω => min_le_min (hσ_le_π ω) le_rfl · exact fun i => stronglyMeasurable_stoppedValue_of_le hf.adapted.progMeasurable_of_discrete (hf.adapted.isStoppingTime_leastGE _ _) leastGE_le · exact fun i => integrable_stoppedValue _ (hf.adapted.isStoppingTime_leastGE _ _) hf.integrable leastGE_le #align measure_theory.submartingale.stopped_value_least_ge MeasureTheory.Submartingale.stoppedValue_leastGE variable {r : ℝ} {R : ℝ≥0} theorem norm_stoppedValue_leastGE_le (hr : 0 ≤ r) (hf0 : f 0 = 0) (hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) (i : ℕ) : ∀ᵐ ω ∂μ, stoppedValue f (leastGE f r i) ω ≤ r + R := by filter_upwards [hbdd] with ω hbddω change f (leastGE f r i ω) ω ≤ r + R by_cases heq : leastGE f r i ω = 0 · rw [heq, hf0, Pi.zero_apply] exact add_nonneg hr R.coe_nonneg · obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero heq rw [hk, add_comm, ← sub_le_iff_le_add] have := not_mem_of_lt_hitting (hk.symm ▸ k.lt_succ_self : k < leastGE f r i ω) (zero_le _) simp only [Set.mem_union, Set.mem_Iic, Set.mem_Ici, not_or, not_le] at this exact (sub_lt_sub_left this _).le.trans ((le_abs_self _).trans (hbddω _)) #align measure_theory.norm_stopped_value_least_ge_le MeasureTheory.norm_stoppedValue_leastGE_le theorem Submartingale.stoppedValue_leastGE_snorm_le [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ) (hr : 0 ≤ r) (hf0 : f 0 = 0) (hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) (i : ℕ) : snorm (stoppedValue f (leastGE f r i)) 1 μ ≤ 2 * μ Set.univ * ENNReal.ofReal (r + R) := by refine snorm_one_le_of_le' ((hf.stoppedValue_leastGE r).integrable _) ?_ (norm_stoppedValue_leastGE_le hr hf0 hbdd i) rw [← integral_univ] refine le_trans ?_ ((hf.stoppedValue_leastGE r).setIntegral_le (zero_le _) MeasurableSet.univ) simp_rw [stoppedValue, leastGE, hitting_of_le le_rfl, hf0, integral_zero', le_rfl] #align measure_theory.submartingale.stopped_value_least_ge_snorm_le MeasureTheory.Submartingale.stoppedValue_leastGE_snorm_le theorem Submartingale.stoppedValue_leastGE_snorm_le' [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ) (hr : 0 ≤ r) (hf0 : f 0 = 0) (hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) (i : ℕ) : snorm (stoppedValue f (leastGE f r i)) 1 μ ≤ ENNReal.toNNReal (2 * μ Set.univ * ENNReal.ofReal (r + R)) := by refine (hf.stoppedValue_leastGE_snorm_le hr hf0 hbdd i).trans ?_ simp [ENNReal.coe_toNNReal (measure_ne_top μ _), ENNReal.coe_toNNReal] #align measure_theory.submartingale.stopped_value_least_ge_snorm_le' MeasureTheory.Submartingale.stoppedValue_leastGE_snorm_le' theorem Submartingale.exists_tendsto_of_abs_bddAbove_aux [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ) (hf0 : f 0 = 0) (hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) : ∀ᵐ ω ∂μ, BddAbove (Set.range fun n => f n ω) → ∃ c, Tendsto (fun n => f n ω) atTop (𝓝 c) := by have ht : ∀ᵐ ω ∂μ, ∀ i : ℕ, ∃ c, Tendsto (fun n => stoppedValue f (leastGE f i n) ω) atTop (𝓝 c) := by rw [ae_all_iff] exact fun i => Submartingale.exists_ae_tendsto_of_bdd (hf.stoppedValue_leastGE i) (hf.stoppedValue_leastGE_snorm_le' i.cast_nonneg hf0 hbdd) filter_upwards [ht] with ω hω hωb rw [BddAbove] at hωb obtain ⟨i, hi⟩ := exists_nat_gt hωb.some have hib : ∀ n, f n ω < i := by intro n exact lt_of_le_of_lt ((mem_upperBounds.1 hωb.some_mem) _ ⟨n, rfl⟩) hi have heq : ∀ n, stoppedValue f (leastGE f i n) ω = f n ω := by intro n rw [leastGE]; unfold hitting; rw [stoppedValue] rw [if_neg] simp only [Set.mem_Icc, Set.mem_union, Set.mem_Ici] push_neg exact fun j _ => hib j simp only [← heq, hω i] #align measure_theory.submartingale.exists_tendsto_of_abs_bdd_above_aux MeasureTheory.Submartingale.exists_tendsto_of_abs_bddAbove_aux theorem Submartingale.bddAbove_iff_exists_tendsto_aux [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ) (hf0 : f 0 = 0) (hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) : ∀ᵐ ω ∂μ, BddAbove (Set.range fun n => f n ω) ↔ ∃ c, Tendsto (fun n => f n ω) atTop (𝓝 c) := by filter_upwards [hf.exists_tendsto_of_abs_bddAbove_aux hf0 hbdd] with ω hω using ⟨hω, fun ⟨c, hc⟩ => hc.bddAbove_range⟩ #align measure_theory.submartingale.bdd_above_iff_exists_tendsto_aux MeasureTheory.Submartingale.bddAbove_iff_exists_tendsto_aux theorem Submartingale.bddAbove_iff_exists_tendsto [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ) (hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) : ∀ᵐ ω ∂μ, BddAbove (Set.range fun n => f n ω) ↔ ∃ c, Tendsto (fun n => f n ω) atTop (𝓝 c) := by set g : ℕ → Ω → ℝ := fun n ω => f n ω - f 0 ω have hg : Submartingale g ℱ μ := hf.sub_martingale (martingale_const_fun _ _ (hf.adapted 0) (hf.integrable 0)) have hg0 : g 0 = 0 := by ext ω simp only [g, sub_self, Pi.zero_apply] have hgbdd : ∀ᵐ ω ∂μ, ∀ i : ℕ, |g (i + 1) ω - g i ω| ≤ ↑R := by simpa only [g, sub_sub_sub_cancel_right] filter_upwards [hg.bddAbove_iff_exists_tendsto_aux hg0 hgbdd] with ω hω convert hω using 1 · refine ⟨fun h => ?_, fun h => ?_⟩ <;> obtain ⟨b, hb⟩ := h <;> refine ⟨b + |f 0 ω|, fun y hy => ?_⟩ <;> obtain ⟨n, rfl⟩ := hy · simp_rw [g, sub_eq_add_neg] exact add_le_add (hb ⟨n, rfl⟩) (neg_le_abs _) · exact sub_le_iff_le_add.1 (le_trans (sub_le_sub_left (le_abs_self _) _) (hb ⟨n, rfl⟩)) · refine ⟨fun h => ?_, fun h => ?_⟩ <;> obtain ⟨c, hc⟩ := h · exact ⟨c - f 0 ω, hc.sub_const _⟩ · refine ⟨c + f 0 ω, ?_⟩ have := hc.add_const (f 0 ω) simpa only [g, sub_add_cancel] #align measure_theory.submartingale.bdd_above_iff_exists_tendsto MeasureTheory.Submartingale.bddAbove_iff_exists_tendsto theorem Martingale.bddAbove_range_iff_bddBelow_range [IsFiniteMeasure μ] (hf : Martingale f ℱ μ) (hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) : ∀ᵐ ω ∂μ, BddAbove (Set.range fun n => f n ω) ↔ BddBelow (Set.range fun n => f n ω) := by have hbdd' : ∀ᵐ ω ∂μ, ∀ i, |(-f) (i + 1) ω - (-f) i ω| ≤ R := by filter_upwards [hbdd] with ω hω i erw [← abs_neg, neg_sub, sub_neg_eq_add, neg_add_eq_sub] exact hω i have hup := hf.submartingale.bddAbove_iff_exists_tendsto hbdd have hdown := hf.neg.submartingale.bddAbove_iff_exists_tendsto hbdd' filter_upwards [hup, hdown] with ω hω₁ hω₂ have : (∃ c, Tendsto (fun n => f n ω) atTop (𝓝 c)) ↔ ∃ c, Tendsto (fun n => (-f) n ω) atTop (𝓝 c) := by constructor <;> rintro ⟨c, hc⟩ · exact ⟨-c, hc.neg⟩ · refine ⟨-c, ?_⟩ convert hc.neg simp only [neg_neg, Pi.neg_apply] rw [hω₁, this, ← hω₂] constructor <;> rintro ⟨c, hc⟩ <;> refine ⟨-c, fun ω hω => ?_⟩ · rw [mem_upperBounds] at hc refine neg_le.2 (hc _ ?_) simpa only [Pi.neg_apply, Set.mem_range, neg_inj] · rw [mem_lowerBounds] at hc simp_rw [Set.mem_range, Pi.neg_apply, neg_eq_iff_eq_neg] at hω refine le_neg.1 (hc _ ?_) simpa only [Set.mem_range] #align measure_theory.martingale.bdd_above_range_iff_bdd_below_range MeasureTheory.Martingale.bddAbove_range_iff_bddBelow_range theorem Martingale.ae_not_tendsto_atTop_atTop [IsFiniteMeasure μ] (hf : Martingale f ℱ μ) (hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) : ∀ᵐ ω ∂μ, ¬Tendsto (fun n => f n ω) atTop atTop := by filter_upwards [hf.bddAbove_range_iff_bddBelow_range hbdd] with ω hω htop using unbounded_of_tendsto_atTop htop (hω.2 <| bddBelow_range_of_tendsto_atTop_atTop htop) #align measure_theory.martingale.ae_not_tendsto_at_top_at_top MeasureTheory.Martingale.ae_not_tendsto_atTop_atTop theorem Martingale.ae_not_tendsto_atTop_atBot [IsFiniteMeasure μ] (hf : Martingale f ℱ μ) (hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) : ∀ᵐ ω ∂μ, ¬Tendsto (fun n => f n ω) atTop atBot := by filter_upwards [hf.bddAbove_range_iff_bddBelow_range hbdd] with ω hω htop using unbounded_of_tendsto_atBot htop (hω.1 <| bddAbove_range_of_tendsto_atTop_atBot htop) #align measure_theory.martingale.ae_not_tendsto_at_top_at_bot MeasureTheory.Martingale.ae_not_tendsto_atTop_atBot namespace BorelCantelli noncomputable def process (s : ℕ → Set Ω) (n : ℕ) : Ω → ℝ := ∑ k ∈ Finset.range n, (s (k + 1)).indicator 1 #align measure_theory.borel_cantelli.process MeasureTheory.BorelCantelli.process variable {s : ℕ → Set Ω} theorem process_zero : process s 0 = 0 := by rw [process, Finset.range_zero, Finset.sum_empty] #align measure_theory.borel_cantelli.process_zero MeasureTheory.BorelCantelli.process_zero theorem adapted_process (hs : ∀ n, MeasurableSet[ℱ n] (s n)) : Adapted ℱ (process s) := fun _ => Finset.stronglyMeasurable_sum' _ fun _ hk => stronglyMeasurable_one.indicator <| ℱ.mono (Finset.mem_range.1 hk) _ <| hs _ #align measure_theory.borel_cantelli.adapted_process MeasureTheory.BorelCantelli.adapted_process theorem martingalePart_process_ae_eq (ℱ : Filtration ℕ m0) (μ : Measure Ω) (s : ℕ → Set Ω) (n : ℕ) : martingalePart (process s) ℱ μ n = ∑ k ∈ Finset.range n, ((s (k + 1)).indicator 1 - μ[(s (k + 1)).indicator 1|ℱ k]) := by simp only [martingalePart_eq_sum, process_zero, zero_add] refine Finset.sum_congr rfl fun k _ => ?_ simp only [process, Finset.sum_range_succ_sub_sum] #align measure_theory.borel_cantelli.martingale_part_process_ae_eq MeasureTheory.BorelCantelli.martingalePart_process_ae_eq
Mathlib/Probability/Martingale/BorelCantelli.lean
303
308
theorem predictablePart_process_ae_eq (ℱ : Filtration ℕ m0) (μ : Measure Ω) (s : ℕ → Set Ω) (n : ℕ) : predictablePart (process s) ℱ μ n = ∑ k ∈ Finset.range n, μ[(s (k + 1)).indicator (1 : Ω → ℝ)|ℱ k] := by
have := martingalePart_process_ae_eq ℱ μ s n simp_rw [martingalePart, process, Finset.sum_sub_distrib] at this exact sub_right_injective this
import Mathlib.AlgebraicTopology.DoldKan.Decomposition import Mathlib.Tactic.FinCases #align_import algebraic_topology.dold_kan.degeneracies from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504" open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Preadditive Simplicial namespace AlgebraicTopology namespace DoldKan variable {C : Type*} [Category C] [Preadditive C] theorem HigherFacesVanish.comp_σ {Y : C} {X : SimplicialObject C} {n b q : ℕ} {φ : Y ⟶ X _[n + 1]} (v : HigherFacesVanish q φ) (hnbq : n + 1 = b + q) : HigherFacesVanish q (φ ≫ X.σ ⟨b, by simp only [hnbq, Nat.lt_add_one_iff, le_add_iff_nonneg_right, zero_le]⟩) := fun j hj => by rw [assoc, SimplicialObject.δ_comp_σ_of_gt', Fin.pred_succ, v.comp_δ_eq_zero_assoc _ _ hj, zero_comp] · dsimp rw [Fin.lt_iff_val_lt_val, Fin.val_succ] linarith · intro hj' simp only [hnbq, add_comm b, add_assoc, hj', Fin.val_zero, zero_add, add_le_iff_nonpos_right, nonpos_iff_eq_zero, add_eq_zero, false_and] at hj #align algebraic_topology.dold_kan.higher_faces_vanish.comp_σ AlgebraicTopology.DoldKan.HigherFacesVanish.comp_σ theorem σ_comp_P_eq_zero (X : SimplicialObject C) {n q : ℕ} (i : Fin (n + 1)) (hi : n + 1 ≤ i + q) : X.σ i ≫ (P q).f (n + 1) = 0 := by revert i hi induction' q with q hq · intro i (hi : n + 1 ≤ i) exfalso linarith [Fin.is_lt i] · intro i (hi : n + 1 ≤ i + q + 1) by_cases h : n + 1 ≤ (i : ℕ) + q · rw [P_succ, HomologicalComplex.comp_f, ← assoc, hq i h, zero_comp] · replace hi : n = i + q := by obtain ⟨j, hj⟩ := le_iff_exists_add.mp hi rw [← Nat.lt_succ_iff, Nat.succ_eq_add_one, hj, not_lt, add_le_iff_nonpos_right, nonpos_iff_eq_zero] at h rw [← add_left_inj 1, hj, self_eq_add_right, h] rcases n with _|n · fin_cases i dsimp at h hi rw [show q = 0 by omega] change X.σ 0 ≫ (P 1).f 1 = 0 simp only [P_succ, HomologicalComplex.add_f_apply, comp_add, HomologicalComplex.id_f, AlternatingFaceMapComplex.obj_d_eq, Hσ, HomologicalComplex.comp_f, Homotopy.nullHomotopicMap'_f (c_mk 2 1 rfl) (c_mk 1 0 rfl), comp_id] erw [hσ'_eq' (zero_add 0).symm, hσ'_eq' (add_zero 1).symm, comp_id, Fin.sum_univ_two, Fin.sum_univ_succ, Fin.sum_univ_two] simp only [Fin.val_zero, pow_zero, pow_one, pow_add, one_smul, neg_smul, Fin.mk_one, Fin.val_succ, Fin.val_one, Fin.succ_one_eq_two, P_zero, HomologicalComplex.id_f, Fin.val_two, pow_two, mul_neg, one_mul, neg_mul, neg_neg, id_comp, add_comp, comp_add, Fin.mk_zero, neg_comp, comp_neg, Fin.succ_zero_eq_one] erw [SimplicialObject.δ_comp_σ_self, SimplicialObject.δ_comp_σ_self_assoc, SimplicialObject.δ_comp_σ_succ, comp_id, SimplicialObject.δ_comp_σ_of_le X (show (0 : Fin 2) ≤ Fin.castSucc 0 by rw [Fin.castSucc_zero]), SimplicialObject.δ_comp_σ_self_assoc, SimplicialObject.δ_comp_σ_succ_assoc] simp only [add_right_neg, add_zero, zero_add] · rw [← id_comp (X.σ i), ← (P_add_Q_f q n.succ : _ = 𝟙 (X.obj _)), add_comp, add_comp, P_succ] have v : HigherFacesVanish q ((P q).f n.succ ≫ X.σ i) := (HigherFacesVanish.of_P q n).comp_σ hi erw [← assoc, v.comp_P_eq_self, HomologicalComplex.add_f_apply, Preadditive.comp_add, comp_id, v.comp_Hσ_eq hi, assoc, SimplicialObject.δ_comp_σ_succ_assoc, Fin.eta, decomposition_Q n q, sum_comp, sum_comp, Finset.sum_eq_zero, add_zero, add_neg_eq_zero] intro j hj simp only [true_and_iff, Finset.mem_univ, Finset.mem_filter] at hj simp only [Nat.succ_eq_add_one] at hi obtain ⟨k, hk⟩ := Nat.le.dest (Nat.lt_succ_iff.mp (Fin.is_lt j)) rw [add_comm] at hk have hi' : i = Fin.castSucc ⟨i, by omega⟩ := by ext simp only [Fin.castSucc_mk, Fin.eta] have eq := hq j.rev.succ (by simp only [← hk, Fin.rev_eq j hk.symm, Nat.succ_eq_add_one, Fin.succ_mk, Fin.val_mk] omega) rw [HomologicalComplex.comp_f, assoc, assoc, assoc, hi', SimplicialObject.σ_comp_σ_assoc, reassoc_of% eq, zero_comp, comp_zero, comp_zero, comp_zero] simp only [Fin.rev_eq j hk.symm, Fin.le_iff_val_le_val, Fin.val_mk] omega set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.σ_comp_P_eq_zero AlgebraicTopology.DoldKan.σ_comp_P_eq_zero @[reassoc (attr := simp)] theorem σ_comp_PInfty (X : SimplicialObject C) {n : ℕ} (i : Fin (n + 1)) : X.σ i ≫ PInfty.f (n + 1) = 0 := by rw [PInfty_f, σ_comp_P_eq_zero X i] simp only [le_add_iff_nonneg_left, zero_le] set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.σ_comp_P_infty AlgebraicTopology.DoldKan.σ_comp_PInfty @[reassoc]
Mathlib/AlgebraicTopology/DoldKan/Degeneracies.lean
128
140
theorem degeneracy_comp_PInfty (X : SimplicialObject C) (n : ℕ) {Δ' : SimplexCategory} (θ : ([n] : SimplexCategory) ⟶ Δ') (hθ : ¬Mono θ) : X.map θ.op ≫ PInfty.f n = 0 := by
rw [SimplexCategory.mono_iff_injective] at hθ cases n · exfalso apply hθ intro x y h fin_cases x fin_cases y rfl · obtain ⟨i, α, h⟩ := SimplexCategory.eq_σ_comp_of_not_injective θ hθ rw [h, op_comp, X.map_comp, assoc, show X.map (SimplexCategory.σ i).op = X.σ i by rfl, σ_comp_PInfty, comp_zero]
import Mathlib.Algebra.Star.Basic import Mathlib.Algebra.Order.CauSeq.Completion #align_import data.real.basic from "leanprover-community/mathlib"@"cb42593171ba005beaaf4549fcfe0dece9ada4c9" assert_not_exists Finset assert_not_exists Module assert_not_exists Submonoid assert_not_exists FloorRing structure Real where ofCauchy :: cauchy : CauSeq.Completion.Cauchy (abs : ℚ → ℚ) #align real Real @[inherit_doc] notation "ℝ" => Real -- Porting note: unknown attribute -- attribute [pp_using_anonymous_constructor] Real namespace Real open CauSeq CauSeq.Completion variable {x y : ℝ} theorem ext_cauchy_iff : ∀ {x y : Real}, x = y ↔ x.cauchy = y.cauchy | ⟨a⟩, ⟨b⟩ => by rw [ofCauchy.injEq] #align real.ext_cauchy_iff Real.ext_cauchy_iff theorem ext_cauchy {x y : Real} : x.cauchy = y.cauchy → x = y := ext_cauchy_iff.2 #align real.ext_cauchy Real.ext_cauchy def equivCauchy : ℝ ≃ CauSeq.Completion.Cauchy (abs : ℚ → ℚ) := ⟨Real.cauchy, Real.ofCauchy, fun ⟨_⟩ => rfl, fun _ => rfl⟩ set_option linter.uppercaseLean3 false in #align real.equiv_Cauchy Real.equivCauchy -- irreducible doesn't work for instances: https://github.com/leanprover-community/lean/issues/511 private irreducible_def zero : ℝ := ⟨0⟩ private irreducible_def one : ℝ := ⟨1⟩ private irreducible_def add : ℝ → ℝ → ℝ | ⟨a⟩, ⟨b⟩ => ⟨a + b⟩ private irreducible_def neg : ℝ → ℝ | ⟨a⟩ => ⟨-a⟩ private irreducible_def mul : ℝ → ℝ → ℝ | ⟨a⟩, ⟨b⟩ => ⟨a * b⟩ private noncomputable irreducible_def inv' : ℝ → ℝ | ⟨a⟩ => ⟨a⁻¹⟩ instance : Zero ℝ := ⟨zero⟩ instance : One ℝ := ⟨one⟩ instance : Add ℝ := ⟨add⟩ instance : Neg ℝ := ⟨neg⟩ instance : Mul ℝ := ⟨mul⟩ instance : Sub ℝ := ⟨fun a b => a + -b⟩ noncomputable instance : Inv ℝ := ⟨inv'⟩ theorem ofCauchy_zero : (⟨0⟩ : ℝ) = 0 := zero_def.symm #align real.of_cauchy_zero Real.ofCauchy_zero theorem ofCauchy_one : (⟨1⟩ : ℝ) = 1 := one_def.symm #align real.of_cauchy_one Real.ofCauchy_one theorem ofCauchy_add (a b) : (⟨a + b⟩ : ℝ) = ⟨a⟩ + ⟨b⟩ := (add_def _ _).symm #align real.of_cauchy_add Real.ofCauchy_add theorem ofCauchy_neg (a) : (⟨-a⟩ : ℝ) = -⟨a⟩ := (neg_def _).symm #align real.of_cauchy_neg Real.ofCauchy_neg theorem ofCauchy_sub (a b) : (⟨a - b⟩ : ℝ) = ⟨a⟩ - ⟨b⟩ := by rw [sub_eq_add_neg, ofCauchy_add, ofCauchy_neg] rfl #align real.of_cauchy_sub Real.ofCauchy_sub theorem ofCauchy_mul (a b) : (⟨a * b⟩ : ℝ) = ⟨a⟩ * ⟨b⟩ := (mul_def _ _).symm #align real.of_cauchy_mul Real.ofCauchy_mul theorem ofCauchy_inv {f} : (⟨f⁻¹⟩ : ℝ) = ⟨f⟩⁻¹ := show _ = inv' _ by rw [inv'] #align real.of_cauchy_inv Real.ofCauchy_inv theorem cauchy_zero : (0 : ℝ).cauchy = 0 := show zero.cauchy = 0 by rw [zero_def] #align real.cauchy_zero Real.cauchy_zero theorem cauchy_one : (1 : ℝ).cauchy = 1 := show one.cauchy = 1 by rw [one_def] #align real.cauchy_one Real.cauchy_one theorem cauchy_add : ∀ a b, (a + b : ℝ).cauchy = a.cauchy + b.cauchy | ⟨a⟩, ⟨b⟩ => show (add _ _).cauchy = _ by rw [add_def] #align real.cauchy_add Real.cauchy_add theorem cauchy_neg : ∀ a, (-a : ℝ).cauchy = -a.cauchy | ⟨a⟩ => show (neg _).cauchy = _ by rw [neg_def] #align real.cauchy_neg Real.cauchy_neg theorem cauchy_mul : ∀ a b, (a * b : ℝ).cauchy = a.cauchy * b.cauchy | ⟨a⟩, ⟨b⟩ => show (mul _ _).cauchy = _ by rw [mul_def] #align real.cauchy_mul Real.cauchy_mul theorem cauchy_sub : ∀ a b, (a - b : ℝ).cauchy = a.cauchy - b.cauchy | ⟨a⟩, ⟨b⟩ => by rw [sub_eq_add_neg, ← cauchy_neg, ← cauchy_add] rfl #align real.cauchy_sub Real.cauchy_sub theorem cauchy_inv : ∀ f, (f⁻¹ : ℝ).cauchy = f.cauchy⁻¹ | ⟨f⟩ => show (inv' _).cauchy = _ by rw [inv'] #align real.cauchy_inv Real.cauchy_inv instance instNatCast : NatCast ℝ where natCast n := ⟨n⟩ instance instIntCast : IntCast ℝ where intCast z := ⟨z⟩ instance instNNRatCast : NNRatCast ℝ where nnratCast q := ⟨q⟩ instance instRatCast : RatCast ℝ where ratCast q := ⟨q⟩ lemma ofCauchy_natCast (n : ℕ) : (⟨n⟩ : ℝ) = n := rfl lemma ofCauchy_intCast (z : ℤ) : (⟨z⟩ : ℝ) = z := rfl lemma ofCauchy_nnratCast (q : ℚ≥0) : (⟨q⟩ : ℝ) = q := rfl lemma ofCauchy_ratCast (q : ℚ) : (⟨q⟩ : ℝ) = q := rfl #align real.of_cauchy_nat_cast Real.ofCauchy_natCast #align real.of_cauchy_int_cast Real.ofCauchy_intCast #align real.of_cauchy_rat_cast Real.ofCauchy_ratCast lemma cauchy_natCast (n : ℕ) : (n : ℝ).cauchy = n := rfl lemma cauchy_intCast (z : ℤ) : (z : ℝ).cauchy = z := rfl lemma cauchy_nnratCast (q : ℚ≥0) : (q : ℝ).cauchy = q := rfl lemma cauchy_ratCast (q : ℚ) : (q : ℝ).cauchy = q := rfl #align real.cauchy_nat_cast Real.cauchy_natCast #align real.cauchy_int_cast Real.cauchy_intCast #align real.cauchy_rat_cast Real.cauchy_ratCast instance commRing : CommRing ℝ where natCast n := ⟨n⟩ intCast z := ⟨z⟩ zero := (0 : ℝ) one := (1 : ℝ) mul := (· * ·) add := (· + ·) neg := @Neg.neg ℝ _ sub := @Sub.sub ℝ _ npow := @npowRec ℝ ⟨1⟩ ⟨(· * ·)⟩ nsmul := @nsmulRec ℝ ⟨0⟩ ⟨(· + ·)⟩ zsmul := @zsmulRec ℝ ⟨0⟩ ⟨(· + ·)⟩ ⟨@Neg.neg ℝ _⟩ (@nsmulRec ℝ ⟨0⟩ ⟨(· + ·)⟩) add_zero a := by apply ext_cauchy; simp [cauchy_add, cauchy_zero] zero_add a := by apply ext_cauchy; simp [cauchy_add, cauchy_zero] add_comm a b := by apply ext_cauchy; simp only [cauchy_add, add_comm] add_assoc a b c := by apply ext_cauchy; simp only [cauchy_add, add_assoc] mul_zero a := by apply ext_cauchy; simp [cauchy_mul, cauchy_zero] zero_mul a := by apply ext_cauchy; simp [cauchy_mul, cauchy_zero] mul_one a := by apply ext_cauchy; simp [cauchy_mul, cauchy_one] one_mul a := by apply ext_cauchy; simp [cauchy_mul, cauchy_one] mul_comm a b := by apply ext_cauchy; simp only [cauchy_mul, mul_comm] mul_assoc a b c := by apply ext_cauchy; simp only [cauchy_mul, mul_assoc] left_distrib a b c := by apply ext_cauchy; simp only [cauchy_add, cauchy_mul, mul_add] right_distrib a b c := by apply ext_cauchy; simp only [cauchy_add, cauchy_mul, add_mul] add_left_neg a := by apply ext_cauchy; simp [cauchy_add, cauchy_neg, cauchy_zero] natCast_zero := by apply ext_cauchy; simp [cauchy_zero] natCast_succ n := by apply ext_cauchy; simp [cauchy_one, cauchy_add] intCast_negSucc z := by apply ext_cauchy; simp [cauchy_neg, cauchy_natCast] @[simps] def ringEquivCauchy : ℝ ≃+* CauSeq.Completion.Cauchy (abs : ℚ → ℚ) := { equivCauchy with toFun := cauchy invFun := ofCauchy map_add' := cauchy_add map_mul' := cauchy_mul } set_option linter.uppercaseLean3 false in #align real.ring_equiv_Cauchy Real.ringEquivCauchy set_option linter.uppercaseLean3 false in #align real.ring_equiv_Cauchy_apply Real.ringEquivCauchy_apply set_option linter.uppercaseLean3 false in #align real.ring_equiv_Cauchy_symm_apply_cauchy Real.ringEquivCauchy_symm_apply_cauchy instance instRing : Ring ℝ := by infer_instance instance : CommSemiring ℝ := by infer_instance instance semiring : Semiring ℝ := by infer_instance instance : CommMonoidWithZero ℝ := by infer_instance instance : MonoidWithZero ℝ := by infer_instance instance : AddCommGroup ℝ := by infer_instance instance : AddGroup ℝ := by infer_instance instance : AddCommMonoid ℝ := by infer_instance instance : AddMonoid ℝ := by infer_instance instance : AddLeftCancelSemigroup ℝ := by infer_instance instance : AddRightCancelSemigroup ℝ := by infer_instance instance : AddCommSemigroup ℝ := by infer_instance instance : AddSemigroup ℝ := by infer_instance instance : CommMonoid ℝ := by infer_instance instance : Monoid ℝ := by infer_instance instance : CommSemigroup ℝ := by infer_instance instance : Semigroup ℝ := by infer_instance instance : Inhabited ℝ := ⟨0⟩ instance : StarRing ℝ := starRingOfComm instance : TrivialStar ℝ := ⟨fun _ => rfl⟩ def mk (x : CauSeq ℚ abs) : ℝ := ⟨CauSeq.Completion.mk x⟩ #align real.mk Real.mk theorem mk_eq {f g : CauSeq ℚ abs} : mk f = mk g ↔ f ≈ g := ext_cauchy_iff.trans CauSeq.Completion.mk_eq #align real.mk_eq Real.mk_eq private irreducible_def lt : ℝ → ℝ → Prop | ⟨x⟩, ⟨y⟩ => (Quotient.liftOn₂ x y (· < ·)) fun _ _ _ _ hf hg => propext <| ⟨fun h => lt_of_eq_of_lt (Setoid.symm hf) (lt_of_lt_of_eq h hg), fun h => lt_of_eq_of_lt hf (lt_of_lt_of_eq h (Setoid.symm hg))⟩ instance : LT ℝ := ⟨lt⟩ theorem lt_cauchy {f g} : (⟨⟦f⟧⟩ : ℝ) < ⟨⟦g⟧⟩ ↔ f < g := show lt _ _ ↔ _ by rw [lt_def]; rfl #align real.lt_cauchy Real.lt_cauchy @[simp] theorem mk_lt {f g : CauSeq ℚ abs} : mk f < mk g ↔ f < g := lt_cauchy #align real.mk_lt Real.mk_lt theorem mk_zero : mk 0 = 0 := by rw [← ofCauchy_zero]; rfl #align real.mk_zero Real.mk_zero theorem mk_one : mk 1 = 1 := by rw [← ofCauchy_one]; rfl #align real.mk_one Real.mk_one theorem mk_add {f g : CauSeq ℚ abs} : mk (f + g) = mk f + mk g := by simp [mk, ← ofCauchy_add] #align real.mk_add Real.mk_add theorem mk_mul {f g : CauSeq ℚ abs} : mk (f * g) = mk f * mk g := by simp [mk, ← ofCauchy_mul] #align real.mk_mul Real.mk_mul theorem mk_neg {f : CauSeq ℚ abs} : mk (-f) = -mk f := by simp [mk, ← ofCauchy_neg] #align real.mk_neg Real.mk_neg @[simp] theorem mk_pos {f : CauSeq ℚ abs} : 0 < mk f ↔ Pos f := by rw [← mk_zero, mk_lt] exact iff_of_eq (congr_arg Pos (sub_zero f)) #align real.mk_pos Real.mk_pos private irreducible_def le (x y : ℝ) : Prop := x < y ∨ x = y instance : LE ℝ := ⟨le⟩ private theorem le_def' {x y : ℝ} : x ≤ y ↔ x < y ∨ x = y := show le _ _ ↔ _ by rw [le_def] @[simp] theorem mk_le {f g : CauSeq ℚ abs} : mk f ≤ mk g ↔ f ≤ g := by simp only [le_def', mk_lt, mk_eq]; rfl #align real.mk_le Real.mk_le @[elab_as_elim] protected theorem ind_mk {C : Real → Prop} (x : Real) (h : ∀ y, C (mk y)) : C x := by cases' x with x induction' x using Quot.induction_on with x exact h x #align real.ind_mk Real.ind_mk
Mathlib/Data/Real/Basic.lean
358
363
theorem add_lt_add_iff_left {a b : ℝ} (c : ℝ) : c + a < c + b ↔ a < b := by
induction a using Real.ind_mk induction b using Real.ind_mk induction c using Real.ind_mk simp only [mk_lt, ← mk_add] show Pos _ ↔ Pos _; rw [add_sub_add_left_eq_sub]
import Mathlib.Analysis.Fourier.AddCircle import Mathlib.Analysis.Fourier.FourierTransform import Mathlib.Analysis.PSeries import Mathlib.Analysis.Distribution.SchwartzSpace import Mathlib.MeasureTheory.Measure.Lebesgue.Integral #align_import analysis.fourier.poisson_summation from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" noncomputable section open Function hiding comp_apply open Set hiding restrict_apply open Complex hiding abs_of_nonneg open Real open TopologicalSpace Filter MeasureTheory Asymptotics open scoped Real Filter FourierTransform open ContinuousMap
Mathlib/Analysis/Fourier/PoissonSummation.lean
56
103
theorem Real.fourierCoeff_tsum_comp_add {f : C(ℝ, ℂ)} (hf : ∀ K : Compacts ℝ, Summable fun n : ℤ => ‖(f.comp (ContinuousMap.addRight n)).restrict K‖) (m : ℤ) : fourierCoeff (Periodic.lift <| f.periodic_tsum_comp_add_zsmul 1) m = 𝓕 f m := by
-- NB: This proof can be shortened somewhat by telescoping together some of the steps in the calc -- block, but I think it's more legible this way. We start with preliminaries about the integrand. let e : C(ℝ, ℂ) := (fourier (-m)).comp ⟨((↑) : ℝ → UnitAddCircle), continuous_quotient_mk'⟩ have neK : ∀ (K : Compacts ℝ) (g : C(ℝ, ℂ)), ‖(e * g).restrict K‖ = ‖g.restrict K‖ := by have (x : ℝ) : ‖e x‖ = 1 := abs_coe_circle (AddCircle.toCircle (-m • x)) intro K g simp_rw [norm_eq_iSup_norm, restrict_apply, mul_apply, norm_mul, this, one_mul] have eadd : ∀ (n : ℤ), e.comp (ContinuousMap.addRight n) = e := by intro n; ext1 x have : Periodic e 1 := Periodic.comp (fun x => AddCircle.coe_add_period 1 x) (fourier (-m)) simpa only [mul_one] using this.int_mul n x -- Now the main argument. First unwind some definitions. calc fourierCoeff (Periodic.lift <| f.periodic_tsum_comp_add_zsmul 1) m = ∫ x in (0 : ℝ)..1, e x * (∑' n : ℤ, f.comp (ContinuousMap.addRight n)) x := by simp_rw [fourierCoeff_eq_intervalIntegral _ m 0, div_one, one_smul, zero_add, e, comp_apply, coe_mk, Periodic.lift_coe, zsmul_one, smul_eq_mul] -- Transform sum in C(ℝ, ℂ) evaluated at x into pointwise sum of values. _ = ∫ x in (0:ℝ)..1, ∑' n : ℤ, (e * f.comp (ContinuousMap.addRight n)) x := by simp_rw [coe_mul, Pi.mul_apply, ← ContinuousMap.tsum_apply (summable_of_locally_summable_norm hf), tsum_mul_left] -- Swap sum and integral. _ = ∑' n : ℤ, ∫ x in (0:ℝ)..1, (e * f.comp (ContinuousMap.addRight n)) x := by refine (intervalIntegral.tsum_intervalIntegral_eq_of_summable_norm ?_).symm convert hf ⟨uIcc 0 1, isCompact_uIcc⟩ using 1 exact funext fun n => neK _ _ _ = ∑' n : ℤ, ∫ x in (0:ℝ)..1, (e * f).comp (ContinuousMap.addRight n) x := by simp only [ContinuousMap.comp_apply, mul_comp] at eadd ⊢ simp_rw [eadd] -- Rearrange sum of interval integrals into an integral over `ℝ`. _ = ∫ x, e x * f x := by suffices Integrable (e * f) from this.hasSum_intervalIntegral_comp_add_int.tsum_eq apply integrable_of_summable_norm_Icc convert hf ⟨Icc 0 1, isCompact_Icc⟩ using 1 simp_rw [mul_comp] at eadd ⊢ simp_rw [eadd] exact funext fun n => neK ⟨Icc 0 1, isCompact_Icc⟩ _ -- Minor tidying to finish _ = 𝓕 f m := by rw [fourierIntegral_real_eq_integral_exp_smul] congr 1 with x : 1 rw [smul_eq_mul, comp_apply, coe_mk, coe_mk, ContinuousMap.toFun_eq_coe, fourier_coe_apply] congr 2 push_cast ring
import Mathlib.MeasureTheory.Constructions.Prod.Basic import Mathlib.MeasureTheory.Integral.DominatedConvergence import Mathlib.MeasureTheory.Integral.SetIntegral #align_import measure_theory.constructions.prod.integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" noncomputable section open scoped Classical Topology ENNReal MeasureTheory open Set Function Real ENNReal open MeasureTheory MeasurableSpace MeasureTheory.Measure open TopologicalSpace open Filter hiding prod_eq map variable {α α' β β' γ E : Type*} variable [MeasurableSpace α] [MeasurableSpace α'] [MeasurableSpace β] [MeasurableSpace β'] variable [MeasurableSpace γ] variable {μ μ' : Measure α} {ν ν' : Measure β} {τ : Measure γ} variable [NormedAddCommGroup E] theorem measurableSet_integrable [SigmaFinite ν] ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) : MeasurableSet {x | Integrable (f x) ν} := by simp_rw [Integrable, hf.of_uncurry_left.aestronglyMeasurable, true_and_iff] exact measurableSet_lt (Measurable.lintegral_prod_right hf.ennnorm) measurable_const #align measurable_set_integrable measurableSet_integrable section variable [NormedSpace ℝ E] theorem MeasureTheory.StronglyMeasurable.integral_prod_right [SigmaFinite ν] ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun x => ∫ y, f x y ∂ν := by by_cases hE : CompleteSpace E; swap; · simp [integral, hE, stronglyMeasurable_const] borelize E haveI : SeparableSpace (range (uncurry f) ∪ {0} : Set E) := hf.separableSpace_range_union_singleton let s : ℕ → SimpleFunc (α × β) E := SimpleFunc.approxOn _ hf.measurable (range (uncurry f) ∪ {0}) 0 (by simp) let s' : ℕ → α → SimpleFunc β E := fun n x => (s n).comp (Prod.mk x) measurable_prod_mk_left let f' : ℕ → α → E := fun n => {x | Integrable (f x) ν}.indicator fun x => (s' n x).integral ν have hf' : ∀ n, StronglyMeasurable (f' n) := by intro n; refine StronglyMeasurable.indicator ?_ (measurableSet_integrable hf) have : ∀ x, ((s' n x).range.filter fun x => x ≠ 0) ⊆ (s n).range := by intro x; refine Finset.Subset.trans (Finset.filter_subset _ _) ?_; intro y simp_rw [SimpleFunc.mem_range]; rintro ⟨z, rfl⟩; exact ⟨(x, z), rfl⟩ simp only [SimpleFunc.integral_eq_sum_of_subset (this _)] refine Finset.stronglyMeasurable_sum _ fun x _ => ?_ refine (Measurable.ennreal_toReal ?_).stronglyMeasurable.smul_const _ simp only [s', SimpleFunc.coe_comp, preimage_comp] apply measurable_measure_prod_mk_left exact (s n).measurableSet_fiber x have h2f' : Tendsto f' atTop (𝓝 fun x : α => ∫ y : β, f x y ∂ν) := by rw [tendsto_pi_nhds]; intro x by_cases hfx : Integrable (f x) ν · have (n) : Integrable (s' n x) ν := by apply (hfx.norm.add hfx.norm).mono' (s' n x).aestronglyMeasurable filter_upwards with y simp_rw [s', SimpleFunc.coe_comp]; exact SimpleFunc.norm_approxOn_zero_le _ _ (x, y) n simp only [f', hfx, SimpleFunc.integral_eq_integral _ (this _), indicator_of_mem, mem_setOf_eq] refine tendsto_integral_of_dominated_convergence (fun y => ‖f x y‖ + ‖f x y‖) (fun n => (s' n x).aestronglyMeasurable) (hfx.norm.add hfx.norm) ?_ ?_ · refine fun n => eventually_of_forall fun y => SimpleFunc.norm_approxOn_zero_le ?_ ?_ (x, y) n -- Porting note: Lean 3 solved the following two subgoals on its own · exact hf.measurable · simp · refine eventually_of_forall fun y => SimpleFunc.tendsto_approxOn ?_ ?_ ?_ -- Porting note: Lean 3 solved the following two subgoals on its own · exact hf.measurable.of_uncurry_left · simp apply subset_closure simp [-uncurry_apply_pair] · simp [f', hfx, integral_undef] exact stronglyMeasurable_of_tendsto _ hf' h2f' #align measure_theory.strongly_measurable.integral_prod_right MeasureTheory.StronglyMeasurable.integral_prod_right theorem MeasureTheory.StronglyMeasurable.integral_prod_right' [SigmaFinite ν] ⦃f : α × β → E⦄ (hf : StronglyMeasurable f) : StronglyMeasurable fun x => ∫ y, f (x, y) ∂ν := by rw [← uncurry_curry f] at hf; exact hf.integral_prod_right #align measure_theory.strongly_measurable.integral_prod_right' MeasureTheory.StronglyMeasurable.integral_prod_right' theorem MeasureTheory.StronglyMeasurable.integral_prod_left [SigmaFinite μ] ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun y => ∫ x, f x y ∂μ := (hf.comp_measurable measurable_swap).integral_prod_right' #align measure_theory.strongly_measurable.integral_prod_left MeasureTheory.StronglyMeasurable.integral_prod_left theorem MeasureTheory.StronglyMeasurable.integral_prod_left' [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : StronglyMeasurable f) : StronglyMeasurable fun y => ∫ x, f (x, y) ∂μ := (hf.comp_measurable measurable_swap).integral_prod_right' #align measure_theory.strongly_measurable.integral_prod_left' MeasureTheory.StronglyMeasurable.integral_prod_left' end open MeasureTheory.Measure section nonrec theorem MeasureTheory.AEStronglyMeasurable.prod_swap {γ : Type*} [TopologicalSpace γ] [SigmaFinite μ] [SigmaFinite ν] {f : β × α → γ} (hf : AEStronglyMeasurable f (ν.prod μ)) : AEStronglyMeasurable (fun z : α × β => f z.swap) (μ.prod ν) := by rw [← prod_swap] at hf exact hf.comp_measurable measurable_swap #align measure_theory.ae_strongly_measurable.prod_swap MeasureTheory.AEStronglyMeasurable.prod_swap theorem MeasureTheory.AEStronglyMeasurable.fst {γ} [TopologicalSpace γ] [SigmaFinite ν] {f : α → γ} (hf : AEStronglyMeasurable f μ) : AEStronglyMeasurable (fun z : α × β => f z.1) (μ.prod ν) := hf.comp_quasiMeasurePreserving quasiMeasurePreserving_fst #align measure_theory.ae_strongly_measurable.fst MeasureTheory.AEStronglyMeasurable.fst theorem MeasureTheory.AEStronglyMeasurable.snd {γ} [TopologicalSpace γ] [SigmaFinite ν] {f : β → γ} (hf : AEStronglyMeasurable f ν) : AEStronglyMeasurable (fun z : α × β => f z.2) (μ.prod ν) := hf.comp_quasiMeasurePreserving quasiMeasurePreserving_snd #align measure_theory.ae_strongly_measurable.snd MeasureTheory.AEStronglyMeasurable.snd theorem MeasureTheory.AEStronglyMeasurable.integral_prod_right' [SigmaFinite ν] [NormedSpace ℝ E] ⦃f : α × β → E⦄ (hf : AEStronglyMeasurable f (μ.prod ν)) : AEStronglyMeasurable (fun x => ∫ y, f (x, y) ∂ν) μ := ⟨fun x => ∫ y, hf.mk f (x, y) ∂ν, hf.stronglyMeasurable_mk.integral_prod_right', by filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with _ hx using integral_congr_ae hx⟩ #align measure_theory.ae_strongly_measurable.integral_prod_right' MeasureTheory.AEStronglyMeasurable.integral_prod_right' theorem MeasureTheory.AEStronglyMeasurable.prod_mk_left {γ : Type*} [SigmaFinite ν] [TopologicalSpace γ] {f : α × β → γ} (hf : AEStronglyMeasurable f (μ.prod ν)) : ∀ᵐ x ∂μ, AEStronglyMeasurable (fun y => f (x, y)) ν := by filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with x hx exact ⟨fun y => hf.mk f (x, y), hf.stronglyMeasurable_mk.comp_measurable measurable_prod_mk_left, hx⟩ #align measure_theory.ae_strongly_measurable.prod_mk_left MeasureTheory.AEStronglyMeasurable.prod_mk_left end namespace MeasureTheory variable [SigmaFinite ν] section theorem integrable_swap_iff [SigmaFinite μ] {f : α × β → E} : Integrable (f ∘ Prod.swap) (ν.prod μ) ↔ Integrable f (μ.prod ν) := measurePreserving_swap.integrable_comp_emb MeasurableEquiv.prodComm.measurableEmbedding #align measure_theory.integrable_swap_iff MeasureTheory.integrable_swap_iff theorem Integrable.swap [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : Integrable (f ∘ Prod.swap) (ν.prod μ) := integrable_swap_iff.2 hf #align measure_theory.integrable.swap MeasureTheory.Integrable.swap theorem hasFiniteIntegral_prod_iff ⦃f : α × β → E⦄ (h1f : StronglyMeasurable f) : HasFiniteIntegral f (μ.prod ν) ↔ (∀ᵐ x ∂μ, HasFiniteIntegral (fun y => f (x, y)) ν) ∧ HasFiniteIntegral (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ := by simp only [HasFiniteIntegral, lintegral_prod_of_measurable _ h1f.ennnorm] have (x) : ∀ᵐ y ∂ν, 0 ≤ ‖f (x, y)‖ := by filter_upwards with y using norm_nonneg _ simp_rw [integral_eq_lintegral_of_nonneg_ae (this _) (h1f.norm.comp_measurable measurable_prod_mk_left).aestronglyMeasurable, ennnorm_eq_ofReal toReal_nonneg, ofReal_norm_eq_coe_nnnorm] -- this fact is probably too specialized to be its own lemma have : ∀ {p q r : Prop} (_ : r → p), (r ↔ p ∧ q) ↔ p → (r ↔ q) := fun {p q r} h1 => by rw [← and_congr_right_iff, and_iff_right_of_imp h1] rw [this] · intro h2f; rw [lintegral_congr_ae] filter_upwards [h2f] with x hx rw [ofReal_toReal]; rw [← lt_top_iff_ne_top]; exact hx · intro h2f; refine ae_lt_top ?_ h2f.ne; exact h1f.ennnorm.lintegral_prod_right' #align measure_theory.has_finite_integral_prod_iff MeasureTheory.hasFiniteIntegral_prod_iff theorem hasFiniteIntegral_prod_iff' ⦃f : α × β → E⦄ (h1f : AEStronglyMeasurable f (μ.prod ν)) : HasFiniteIntegral f (μ.prod ν) ↔ (∀ᵐ x ∂μ, HasFiniteIntegral (fun y => f (x, y)) ν) ∧ HasFiniteIntegral (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ := by rw [hasFiniteIntegral_congr h1f.ae_eq_mk, hasFiniteIntegral_prod_iff h1f.stronglyMeasurable_mk] apply and_congr · apply eventually_congr filter_upwards [ae_ae_of_ae_prod h1f.ae_eq_mk.symm] intro x hx exact hasFiniteIntegral_congr hx · apply hasFiniteIntegral_congr filter_upwards [ae_ae_of_ae_prod h1f.ae_eq_mk.symm] with _ hx using integral_congr_ae (EventuallyEq.fun_comp hx _) #align measure_theory.has_finite_integral_prod_iff' MeasureTheory.hasFiniteIntegral_prod_iff' theorem integrable_prod_iff ⦃f : α × β → E⦄ (h1f : AEStronglyMeasurable f (μ.prod ν)) : Integrable f (μ.prod ν) ↔ (∀ᵐ x ∂μ, Integrable (fun y => f (x, y)) ν) ∧ Integrable (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ := by simp [Integrable, h1f, hasFiniteIntegral_prod_iff', h1f.norm.integral_prod_right', h1f.prod_mk_left] #align measure_theory.integrable_prod_iff MeasureTheory.integrable_prod_iff theorem integrable_prod_iff' [SigmaFinite μ] ⦃f : α × β → E⦄ (h1f : AEStronglyMeasurable f (μ.prod ν)) : Integrable f (μ.prod ν) ↔ (∀ᵐ y ∂ν, Integrable (fun x => f (x, y)) μ) ∧ Integrable (fun y => ∫ x, ‖f (x, y)‖ ∂μ) ν := by convert integrable_prod_iff h1f.prod_swap using 1 rw [funext fun _ => Function.comp_apply.symm, integrable_swap_iff] #align measure_theory.integrable_prod_iff' MeasureTheory.integrable_prod_iff' theorem Integrable.prod_left_ae [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : ∀ᵐ y ∂ν, Integrable (fun x => f (x, y)) μ := ((integrable_prod_iff' hf.aestronglyMeasurable).mp hf).1 #align measure_theory.integrable.prod_left_ae MeasureTheory.Integrable.prod_left_ae theorem Integrable.prod_right_ae [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : ∀ᵐ x ∂μ, Integrable (fun y => f (x, y)) ν := hf.swap.prod_left_ae #align measure_theory.integrable.prod_right_ae MeasureTheory.Integrable.prod_right_ae theorem Integrable.integral_norm_prod_left ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : Integrable (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ := ((integrable_prod_iff hf.aestronglyMeasurable).mp hf).2 #align measure_theory.integrable.integral_norm_prod_left MeasureTheory.Integrable.integral_norm_prod_left theorem Integrable.integral_norm_prod_right [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : Integrable (fun y => ∫ x, ‖f (x, y)‖ ∂μ) ν := hf.swap.integral_norm_prod_left #align measure_theory.integrable.integral_norm_prod_right MeasureTheory.Integrable.integral_norm_prod_right theorem Integrable.prod_smul {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] {f : α → 𝕜} {g : β → E} (hf : Integrable f μ) (hg : Integrable g ν) : Integrable (fun z : α × β => f z.1 • g z.2) (μ.prod ν) := by refine (integrable_prod_iff ?_).2 ⟨?_, ?_⟩ · exact hf.1.fst.smul hg.1.snd · exact eventually_of_forall fun x => hg.smul (f x) · simpa only [norm_smul, integral_mul_left] using hf.norm.mul_const _ theorem Integrable.prod_mul {L : Type*} [RCLike L] {f : α → L} {g : β → L} (hf : Integrable f μ) (hg : Integrable g ν) : Integrable (fun z : α × β => f z.1 * g z.2) (μ.prod ν) := hf.prod_smul hg #align measure_theory.integrable_prod_mul MeasureTheory.Integrable.prod_mul end variable [NormedSpace ℝ E] theorem Integrable.integral_prod_left ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : Integrable (fun x => ∫ y, f (x, y) ∂ν) μ := Integrable.mono hf.integral_norm_prod_left hf.aestronglyMeasurable.integral_prod_right' <| eventually_of_forall fun x => (norm_integral_le_integral_norm _).trans_eq <| (norm_of_nonneg <| integral_nonneg_of_ae <| eventually_of_forall fun y => (norm_nonneg (f (x, y)) : _)).symm #align measure_theory.integrable.integral_prod_left MeasureTheory.Integrable.integral_prod_left theorem Integrable.integral_prod_right [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : Integrable (fun y => ∫ x, f (x, y) ∂μ) ν := hf.swap.integral_prod_left #align measure_theory.integrable.integral_prod_right MeasureTheory.Integrable.integral_prod_right variable [SigmaFinite μ] theorem integral_prod_swap (f : α × β → E) : ∫ z, f z.swap ∂ν.prod μ = ∫ z, f z ∂μ.prod ν := measurePreserving_swap.integral_comp MeasurableEquiv.prodComm.measurableEmbedding _ #align measure_theory.integral_prod_swap MeasureTheory.integral_prod_swap variable {E' : Type*} [NormedAddCommGroup E'] [NormedSpace ℝ E'] theorem integral_fn_integral_add ⦃f g : α × β → E⦄ (F : E → E') (hf : Integrable f (μ.prod ν)) (hg : Integrable g (μ.prod ν)) : (∫ x, F (∫ y, f (x, y) + g (x, y) ∂ν) ∂μ) = ∫ x, F ((∫ y, f (x, y) ∂ν) + ∫ y, g (x, y) ∂ν) ∂μ := by refine integral_congr_ae ?_ filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g simp [integral_add h2f h2g] #align measure_theory.integral_fn_integral_add MeasureTheory.integral_fn_integral_add theorem integral_fn_integral_sub ⦃f g : α × β → E⦄ (F : E → E') (hf : Integrable f (μ.prod ν)) (hg : Integrable g (μ.prod ν)) : (∫ x, F (∫ y, f (x, y) - g (x, y) ∂ν) ∂μ) = ∫ x, F ((∫ y, f (x, y) ∂ν) - ∫ y, g (x, y) ∂ν) ∂μ := by refine integral_congr_ae ?_ filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g simp [integral_sub h2f h2g] #align measure_theory.integral_fn_integral_sub MeasureTheory.integral_fn_integral_sub theorem lintegral_fn_integral_sub ⦃f g : α × β → E⦄ (F : E → ℝ≥0∞) (hf : Integrable f (μ.prod ν)) (hg : Integrable g (μ.prod ν)) : (∫⁻ x, F (∫ y, f (x, y) - g (x, y) ∂ν) ∂μ) = ∫⁻ x, F ((∫ y, f (x, y) ∂ν) - ∫ y, g (x, y) ∂ν) ∂μ := by refine lintegral_congr_ae ?_ filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g simp [integral_sub h2f h2g] #align measure_theory.lintegral_fn_integral_sub MeasureTheory.lintegral_fn_integral_sub theorem integral_integral_add ⦃f g : α × β → E⦄ (hf : Integrable f (μ.prod ν)) (hg : Integrable g (μ.prod ν)) : (∫ x, ∫ y, f (x, y) + g (x, y) ∂ν ∂μ) = (∫ x, ∫ y, f (x, y) ∂ν ∂μ) + ∫ x, ∫ y, g (x, y) ∂ν ∂μ := (integral_fn_integral_add id hf hg).trans <| integral_add hf.integral_prod_left hg.integral_prod_left #align measure_theory.integral_integral_add MeasureTheory.integral_integral_add theorem integral_integral_add' ⦃f g : α × β → E⦄ (hf : Integrable f (μ.prod ν)) (hg : Integrable g (μ.prod ν)) : (∫ x, ∫ y, (f + g) (x, y) ∂ν ∂μ) = (∫ x, ∫ y, f (x, y) ∂ν ∂μ) + ∫ x, ∫ y, g (x, y) ∂ν ∂μ := integral_integral_add hf hg #align measure_theory.integral_integral_add' MeasureTheory.integral_integral_add' theorem integral_integral_sub ⦃f g : α × β → E⦄ (hf : Integrable f (μ.prod ν)) (hg : Integrable g (μ.prod ν)) : (∫ x, ∫ y, f (x, y) - g (x, y) ∂ν ∂μ) = (∫ x, ∫ y, f (x, y) ∂ν ∂μ) - ∫ x, ∫ y, g (x, y) ∂ν ∂μ := (integral_fn_integral_sub id hf hg).trans <| integral_sub hf.integral_prod_left hg.integral_prod_left #align measure_theory.integral_integral_sub MeasureTheory.integral_integral_sub theorem integral_integral_sub' ⦃f g : α × β → E⦄ (hf : Integrable f (μ.prod ν)) (hg : Integrable g (μ.prod ν)) : (∫ x, ∫ y, (f - g) (x, y) ∂ν ∂μ) = (∫ x, ∫ y, f (x, y) ∂ν ∂μ) - ∫ x, ∫ y, g (x, y) ∂ν ∂μ := integral_integral_sub hf hg #align measure_theory.integral_integral_sub' MeasureTheory.integral_integral_sub' theorem continuous_integral_integral : Continuous fun f : α × β →₁[μ.prod ν] E => ∫ x, ∫ y, f (x, y) ∂ν ∂μ := by rw [continuous_iff_continuousAt]; intro g refine tendsto_integral_of_L1 _ (L1.integrable_coeFn g).integral_prod_left (eventually_of_forall fun h => (L1.integrable_coeFn h).integral_prod_left) ?_ simp_rw [← lintegral_fn_integral_sub (fun x => (‖x‖₊ : ℝ≥0∞)) (L1.integrable_coeFn _) (L1.integrable_coeFn g)] apply tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds _ (fun i => zero_le _) _ · exact fun i => ∫⁻ x, ∫⁻ y, ‖i (x, y) - g (x, y)‖₊ ∂ν ∂μ swap; · exact fun i => lintegral_mono fun x => ennnorm_integral_le_lintegral_ennnorm _ show Tendsto (fun i : α × β →₁[μ.prod ν] E => ∫⁻ x, ∫⁻ y : β, ‖i (x, y) - g (x, y)‖₊ ∂ν ∂μ) (𝓝 g) (𝓝 0) have : ∀ i : α × β →₁[μ.prod ν] E, Measurable fun z => (‖i z - g z‖₊ : ℝ≥0∞) := fun i => ((Lp.stronglyMeasurable i).sub (Lp.stronglyMeasurable g)).ennnorm -- Porting note: was -- simp_rw [← lintegral_prod_of_measurable _ (this _), ← L1.ofReal_norm_sub_eq_lintegral, ← -- ofReal_zero] conv => congr ext rw [← lintegral_prod_of_measurable _ (this _), ← L1.ofReal_norm_sub_eq_lintegral] rw [← ofReal_zero] refine (continuous_ofReal.tendsto 0).comp ?_ rw [← tendsto_iff_norm_sub_tendsto_zero]; exact tendsto_id #align measure_theory.continuous_integral_integral MeasureTheory.continuous_integral_integral theorem integral_prod (f : α × β → E) (hf : Integrable f (μ.prod ν)) : ∫ z, f z ∂μ.prod ν = ∫ x, ∫ y, f (x, y) ∂ν ∂μ := by by_cases hE : CompleteSpace E; swap; · simp only [integral, dif_neg hE] revert f apply Integrable.induction · intro c s hs h2s simp_rw [integral_indicator hs, ← indicator_comp_right, Function.comp, integral_indicator (measurable_prod_mk_left hs), setIntegral_const, integral_smul_const, integral_toReal (measurable_measure_prod_mk_left hs).aemeasurable (ae_measure_lt_top hs h2s.ne)] -- Porting note: was `simp_rw` rw [prod_apply hs] · rintro f g - i_f i_g hf hg simp_rw [integral_add' i_f i_g, integral_integral_add' i_f i_g, hf, hg] · exact isClosed_eq continuous_integral continuous_integral_integral · rintro f g hfg - hf; convert hf using 1 · exact integral_congr_ae hfg.symm · apply integral_congr_ae filter_upwards [ae_ae_of_ae_prod hfg] with x hfgx using integral_congr_ae (ae_eq_symm hfgx) #align measure_theory.integral_prod MeasureTheory.integral_prod theorem integral_prod_symm (f : α × β → E) (hf : Integrable f (μ.prod ν)) : ∫ z, f z ∂μ.prod ν = ∫ y, ∫ x, f (x, y) ∂μ ∂ν := by rw [← integral_prod_swap f]; exact integral_prod _ hf.swap #align measure_theory.integral_prod_symm MeasureTheory.integral_prod_symm theorem integral_integral {f : α → β → E} (hf : Integrable (uncurry f) (μ.prod ν)) : ∫ x, ∫ y, f x y ∂ν ∂μ = ∫ z, f z.1 z.2 ∂μ.prod ν := (integral_prod _ hf).symm #align measure_theory.integral_integral MeasureTheory.integral_integral theorem integral_integral_symm {f : α → β → E} (hf : Integrable (uncurry f) (μ.prod ν)) : ∫ x, ∫ y, f x y ∂ν ∂μ = ∫ z, f z.2 z.1 ∂ν.prod μ := (integral_prod_symm _ hf.swap).symm #align measure_theory.integral_integral_symm MeasureTheory.integral_integral_symm theorem integral_integral_swap ⦃f : α → β → E⦄ (hf : Integrable (uncurry f) (μ.prod ν)) : ∫ x, ∫ y, f x y ∂ν ∂μ = ∫ y, ∫ x, f x y ∂μ ∂ν := (integral_integral hf).trans (integral_prod_symm _ hf) #align measure_theory.integral_integral_swap MeasureTheory.integral_integral_swap
Mathlib/MeasureTheory/Constructions/Prod/Integral.lean
502
506
theorem setIntegral_prod (f : α × β → E) {s : Set α} {t : Set β} (hf : IntegrableOn f (s ×ˢ t) (μ.prod ν)) : ∫ z in s ×ˢ t, f z ∂μ.prod ν = ∫ x in s, ∫ y in t, f (x, y) ∂ν ∂μ := by
simp only [← Measure.prod_restrict s t, IntegrableOn] at hf ⊢ exact integral_prod f hf
import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation #align_import linear_algebra.clifford_algebra.star from "leanprover-community/mathlib"@"4d66277cfec381260ba05c68f9ae6ce2a118031d" variable {R : Type*} [CommRing R] variable {M : Type*} [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} namespace CliffordAlgebra instance instStarRing : StarRing (CliffordAlgebra Q) where star x := reverse (involute x) star_involutive x := by simp only [reverse_involute_commute.eq, reverse_reverse, involute_involute] star_mul x y := by simp only [map_mul, reverse.map_mul] star_add x y := by simp only [map_add] theorem star_def (x : CliffordAlgebra Q) : star x = reverse (involute x) := rfl #align clifford_algebra.star_def CliffordAlgebra.star_def theorem star_def' (x : CliffordAlgebra Q) : star x = involute (reverse x) := reverse_involute _ #align clifford_algebra.star_def' CliffordAlgebra.star_def' @[simp] theorem star_ι (m : M) : star (ι Q m) = -ι Q m := by rw [star_def, involute_ι, map_neg, reverse_ι] #align clifford_algebra.star_ι CliffordAlgebra.star_ι @[simp]
Mathlib/LinearAlgebra/CliffordAlgebra/Star.lean
57
58
theorem star_smul (r : R) (x : CliffordAlgebra Q) : star (r • x) = r • star x := by
rw [star_def, star_def, map_smul, map_smul]
import Mathlib.Analysis.Calculus.ContDiff.Basic import Mathlib.Data.Finset.Sym import Mathlib.Data.Nat.Choose.Cast import Mathlib.Data.Nat.Choose.Multinomial #align_import analysis.calculus.cont_diff from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" noncomputable section open scoped Classical NNReal Nat universe u uD uE uF uG open Set Fin Filter Function variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {D : Type uD} [NormedAddCommGroup D] [NormedSpace 𝕜 D] {E : Type uE} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type uF} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type uG} [NormedAddCommGroup G] [NormedSpace 𝕜 G] {s s₁ t u : Set E} theorem ContinuousLinearMap.norm_iteratedFDerivWithin_le_of_bilinear_aux {Du Eu Fu Gu : Type u} [NormedAddCommGroup Du] [NormedSpace 𝕜 Du] [NormedAddCommGroup Eu] [NormedSpace 𝕜 Eu] [NormedAddCommGroup Fu] [NormedSpace 𝕜 Fu] [NormedAddCommGroup Gu] [NormedSpace 𝕜 Gu] (B : Eu →L[𝕜] Fu →L[𝕜] Gu) {f : Du → Eu} {g : Du → Fu} {n : ℕ} {s : Set Du} {x : Du} (hf : ContDiffOn 𝕜 n f s) (hg : ContDiffOn 𝕜 n g s) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) : ‖iteratedFDerivWithin 𝕜 n (fun y => B (f y) (g y)) s x‖ ≤ ‖B‖ * ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDerivWithin 𝕜 i f s x‖ * ‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ := by induction' n with n IH generalizing Eu Fu Gu · simp only [Nat.zero_eq, norm_iteratedFDerivWithin_zero, zero_add, Finset.range_one, Finset.sum_singleton, Nat.choose_self, Nat.cast_one, one_mul, Nat.sub_zero, ← mul_assoc] apply B.le_opNorm₂ · have In : (n : ℕ∞) + 1 ≤ n.succ := by simp only [Nat.cast_succ, le_refl] -- Porting note: the next line is a hack allowing Lean to find the operator norm instance. let norm := @ContinuousLinearMap.hasOpNorm _ _ Eu ((Du →L[𝕜] Fu) →L[𝕜] Du →L[𝕜] Gu) _ _ _ _ _ _ (RingHom.id 𝕜) have I1 : ‖iteratedFDerivWithin 𝕜 n (fun y : Du => B.precompR Du (f y) (fderivWithin 𝕜 g s y)) s x‖ ≤ ‖B‖ * ∑ i ∈ Finset.range (n + 1), n.choose i * ‖iteratedFDerivWithin 𝕜 i f s x‖ * ‖iteratedFDerivWithin 𝕜 (n + 1 - i) g s x‖ := by calc ‖iteratedFDerivWithin 𝕜 n (fun y : Du => B.precompR Du (f y) (fderivWithin 𝕜 g s y)) s x‖ ≤ ‖B.precompR Du‖ * ∑ i ∈ Finset.range (n + 1), n.choose i * ‖iteratedFDerivWithin 𝕜 i f s x‖ * ‖iteratedFDerivWithin 𝕜 (n - i) (fderivWithin 𝕜 g s) s x‖ := IH _ (hf.of_le (Nat.cast_le.2 (Nat.le_succ n))) (hg.fderivWithin hs In) _ ≤ ‖B‖ * ∑ i ∈ Finset.range (n + 1), n.choose i * ‖iteratedFDerivWithin 𝕜 i f s x‖ * ‖iteratedFDerivWithin 𝕜 (n - i) (fderivWithin 𝕜 g s) s x‖ := mul_le_mul_of_nonneg_right (B.norm_precompR_le Du) (by positivity) _ = _ := by congr 1 apply Finset.sum_congr rfl fun i hi => ?_ rw [Nat.succ_sub (Nat.lt_succ_iff.1 (Finset.mem_range.1 hi)), ← norm_iteratedFDerivWithin_fderivWithin hs hx] -- Porting note: the next line is a hack allowing Lean to find the operator norm instance. let norm := @ContinuousLinearMap.hasOpNorm _ _ (Du →L[𝕜] Eu) (Fu →L[𝕜] Du →L[𝕜] Gu) _ _ _ _ _ _ (RingHom.id 𝕜) have I2 : ‖iteratedFDerivWithin 𝕜 n (fun y : Du => B.precompL Du (fderivWithin 𝕜 f s y) (g y)) s x‖ ≤ ‖B‖ * ∑ i ∈ Finset.range (n + 1), n.choose i * ‖iteratedFDerivWithin 𝕜 (i + 1) f s x‖ * ‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ := calc ‖iteratedFDerivWithin 𝕜 n (fun y : Du => B.precompL Du (fderivWithin 𝕜 f s y) (g y)) s x‖ ≤ ‖B.precompL Du‖ * ∑ i ∈ Finset.range (n + 1), n.choose i * ‖iteratedFDerivWithin 𝕜 i (fderivWithin 𝕜 f s) s x‖ * ‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ := IH _ (hf.fderivWithin hs In) (hg.of_le (Nat.cast_le.2 (Nat.le_succ n))) _ ≤ ‖B‖ * ∑ i ∈ Finset.range (n + 1), n.choose i * ‖iteratedFDerivWithin 𝕜 i (fderivWithin 𝕜 f s) s x‖ * ‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ := mul_le_mul_of_nonneg_right (B.norm_precompL_le Du) (by positivity) _ = _ := by congr 1 apply Finset.sum_congr rfl fun i _ => ?_ rw [← norm_iteratedFDerivWithin_fderivWithin hs hx] have J : iteratedFDerivWithin 𝕜 n (fun y : Du => fderivWithin 𝕜 (fun y : Du => B (f y) (g y)) s y) s x = iteratedFDerivWithin 𝕜 n (fun y => B.precompR Du (f y) (fderivWithin 𝕜 g s y) + B.precompL Du (fderivWithin 𝕜 f s y) (g y)) s x := by apply iteratedFDerivWithin_congr (fun y hy => ?_) hx have L : (1 : ℕ∞) ≤ n.succ := by simpa only [ENat.coe_one, Nat.one_le_cast] using Nat.succ_pos n exact B.fderivWithin_of_bilinear (hf.differentiableOn L y hy) (hg.differentiableOn L y hy) (hs y hy) rw [← norm_iteratedFDerivWithin_fderivWithin hs hx, J] have A : ContDiffOn 𝕜 n (fun y => B.precompR Du (f y) (fderivWithin 𝕜 g s y)) s := (B.precompR Du).isBoundedBilinearMap.contDiff.comp_contDiff_on₂ (hf.of_le (Nat.cast_le.2 (Nat.le_succ n))) (hg.fderivWithin hs In) have A' : ContDiffOn 𝕜 n (fun y => B.precompL Du (fderivWithin 𝕜 f s y) (g y)) s := (B.precompL Du).isBoundedBilinearMap.contDiff.comp_contDiff_on₂ (hf.fderivWithin hs In) (hg.of_le (Nat.cast_le.2 (Nat.le_succ n))) rw [iteratedFDerivWithin_add_apply' A A' hs hx] apply (norm_add_le _ _).trans ((add_le_add I1 I2).trans (le_of_eq ?_)) simp_rw [← mul_add, mul_assoc] congr 1 exact (Finset.sum_choose_succ_mul (fun i j => ‖iteratedFDerivWithin 𝕜 i f s x‖ * ‖iteratedFDerivWithin 𝕜 j g s x‖) n).symm #align continuous_linear_map.norm_iterated_fderiv_within_le_of_bilinear_aux ContinuousLinearMap.norm_iteratedFDerivWithin_le_of_bilinear_aux theorem ContinuousLinearMap.norm_iteratedFDerivWithin_le_of_bilinear (B : E →L[𝕜] F →L[𝕜] G) {f : D → E} {g : D → F} {N : ℕ∞} {s : Set D} {x : D} (hf : ContDiffOn 𝕜 N f s) (hg : ContDiffOn 𝕜 N g s) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {n : ℕ} (hn : (n : ℕ∞) ≤ N) : ‖iteratedFDerivWithin 𝕜 n (fun y => B (f y) (g y)) s x‖ ≤ ‖B‖ * ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDerivWithin 𝕜 i f s x‖ * ‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ := by let Du : Type max uD uE uF uG := ULift.{max uE uF uG, uD} D let Eu : Type max uD uE uF uG := ULift.{max uD uF uG, uE} E let Fu : Type max uD uE uF uG := ULift.{max uD uE uG, uF} F let Gu : Type max uD uE uF uG := ULift.{max uD uE uF, uG} G have isoD : Du ≃ₗᵢ[𝕜] D := LinearIsometryEquiv.ulift 𝕜 D have isoE : Eu ≃ₗᵢ[𝕜] E := LinearIsometryEquiv.ulift 𝕜 E have isoF : Fu ≃ₗᵢ[𝕜] F := LinearIsometryEquiv.ulift 𝕜 F have isoG : Gu ≃ₗᵢ[𝕜] G := LinearIsometryEquiv.ulift 𝕜 G -- lift `f` and `g` to versions `fu` and `gu` on the lifted spaces. set fu : Du → Eu := isoE.symm ∘ f ∘ isoD with hfu set gu : Du → Fu := isoF.symm ∘ g ∘ isoD with hgu -- lift the bilinear map `B` to a bilinear map `Bu` on the lifted spaces. set Bu₀ : Eu →L[𝕜] Fu →L[𝕜] G := ((B.comp (isoE : Eu →L[𝕜] E)).flip.comp (isoF : Fu →L[𝕜] F)).flip with hBu₀ let Bu : Eu →L[𝕜] Fu →L[𝕜] Gu := ContinuousLinearMap.compL 𝕜 Eu (Fu →L[𝕜] G) (Fu →L[𝕜] Gu) (ContinuousLinearMap.compL 𝕜 Fu G Gu (isoG.symm : G →L[𝕜] Gu)) Bu₀ have hBu : Bu = ContinuousLinearMap.compL 𝕜 Eu (Fu →L[𝕜] G) (Fu →L[𝕜] Gu) (ContinuousLinearMap.compL 𝕜 Fu G Gu (isoG.symm : G →L[𝕜] Gu)) Bu₀ := rfl have Bu_eq : (fun y => Bu (fu y) (gu y)) = isoG.symm ∘ (fun y => B (f y) (g y)) ∘ isoD := by ext1 y simp [hBu, hBu₀, hfu, hgu] -- All norms are preserved by the lifting process. have Bu_le : ‖Bu‖ ≤ ‖B‖ := by refine' ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg B) fun y => _ refine' ContinuousLinearMap.opNorm_le_bound _ (by positivity) fun x => _ simp only [hBu, hBu₀, compL_apply, coe_comp', Function.comp_apply, ContinuousLinearEquiv.coe_coe, LinearIsometryEquiv.coe_coe, flip_apply, LinearIsometryEquiv.norm_map] calc ‖B (isoE y) (isoF x)‖ ≤ ‖B (isoE y)‖ * ‖isoF x‖ := ContinuousLinearMap.le_opNorm _ _ _ ≤ ‖B‖ * ‖isoE y‖ * ‖isoF x‖ := by gcongr; apply ContinuousLinearMap.le_opNorm _ = ‖B‖ * ‖y‖ * ‖x‖ := by simp only [LinearIsometryEquiv.norm_map] let su := isoD ⁻¹' s have hsu : UniqueDiffOn 𝕜 su := isoD.toContinuousLinearEquiv.uniqueDiffOn_preimage_iff.2 hs let xu := isoD.symm x have hxu : xu ∈ su := by simpa only [xu, su, Set.mem_preimage, LinearIsometryEquiv.apply_symm_apply] using hx have xu_x : isoD xu = x := by simp only [xu, LinearIsometryEquiv.apply_symm_apply] have hfu : ContDiffOn 𝕜 n fu su := isoE.symm.contDiff.comp_contDiffOn ((hf.of_le hn).comp_continuousLinearMap (isoD : Du →L[𝕜] D)) have hgu : ContDiffOn 𝕜 n gu su := isoF.symm.contDiff.comp_contDiffOn ((hg.of_le hn).comp_continuousLinearMap (isoD : Du →L[𝕜] D)) have Nfu : ∀ i, ‖iteratedFDerivWithin 𝕜 i fu su xu‖ = ‖iteratedFDerivWithin 𝕜 i f s x‖ := by intro i rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ hsu hxu] rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_right _ _ hs, xu_x] rwa [← xu_x] at hx have Ngu : ∀ i, ‖iteratedFDerivWithin 𝕜 i gu su xu‖ = ‖iteratedFDerivWithin 𝕜 i g s x‖ := by intro i rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ hsu hxu] rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_right _ _ hs, xu_x] rwa [← xu_x] at hx have NBu : ‖iteratedFDerivWithin 𝕜 n (fun y => Bu (fu y) (gu y)) su xu‖ = ‖iteratedFDerivWithin 𝕜 n (fun y => B (f y) (g y)) s x‖ := by rw [Bu_eq] rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ hsu hxu] rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_right _ _ hs, xu_x] rwa [← xu_x] at hx -- state the bound for the lifted objects, and deduce the original bound from it. have : ‖iteratedFDerivWithin 𝕜 n (fun y => Bu (fu y) (gu y)) su xu‖ ≤ ‖Bu‖ * ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDerivWithin 𝕜 i fu su xu‖ * ‖iteratedFDerivWithin 𝕜 (n - i) gu su xu‖ := Bu.norm_iteratedFDerivWithin_le_of_bilinear_aux hfu hgu hsu hxu simp only [Nfu, Ngu, NBu] at this exact this.trans (mul_le_mul_of_nonneg_right Bu_le (by positivity)) #align continuous_linear_map.norm_iterated_fderiv_within_le_of_bilinear ContinuousLinearMap.norm_iteratedFDerivWithin_le_of_bilinear theorem ContinuousLinearMap.norm_iteratedFDeriv_le_of_bilinear (B : E →L[𝕜] F →L[𝕜] G) {f : D → E} {g : D → F} {N : ℕ∞} (hf : ContDiff 𝕜 N f) (hg : ContDiff 𝕜 N g) (x : D) {n : ℕ} (hn : (n : ℕ∞) ≤ N) : ‖iteratedFDeriv 𝕜 n (fun y => B (f y) (g y)) x‖ ≤ ‖B‖ * ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDeriv 𝕜 i f x‖ * ‖iteratedFDeriv 𝕜 (n - i) g x‖ := by simp_rw [← iteratedFDerivWithin_univ] exact B.norm_iteratedFDerivWithin_le_of_bilinear hf.contDiffOn hg.contDiffOn uniqueDiffOn_univ (mem_univ x) hn #align continuous_linear_map.norm_iterated_fderiv_le_of_bilinear ContinuousLinearMap.norm_iteratedFDeriv_le_of_bilinear theorem ContinuousLinearMap.norm_iteratedFDerivWithin_le_of_bilinear_of_le_one (B : E →L[𝕜] F →L[𝕜] G) {f : D → E} {g : D → F} {N : ℕ∞} {s : Set D} {x : D} (hf : ContDiffOn 𝕜 N f s) (hg : ContDiffOn 𝕜 N g s) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {n : ℕ} (hn : (n : ℕ∞) ≤ N) (hB : ‖B‖ ≤ 1) : ‖iteratedFDerivWithin 𝕜 n (fun y => B (f y) (g y)) s x‖ ≤ ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDerivWithin 𝕜 i f s x‖ * ‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ := by apply (B.norm_iteratedFDerivWithin_le_of_bilinear hf hg hs hx hn).trans exact mul_le_of_le_one_left (by positivity) hB #align continuous_linear_map.norm_iterated_fderiv_within_le_of_bilinear_of_le_one ContinuousLinearMap.norm_iteratedFDerivWithin_le_of_bilinear_of_le_one theorem ContinuousLinearMap.norm_iteratedFDeriv_le_of_bilinear_of_le_one (B : E →L[𝕜] F →L[𝕜] G) {f : D → E} {g : D → F} {N : ℕ∞} (hf : ContDiff 𝕜 N f) (hg : ContDiff 𝕜 N g) (x : D) {n : ℕ} (hn : (n : ℕ∞) ≤ N) (hB : ‖B‖ ≤ 1) : ‖iteratedFDeriv 𝕜 n (fun y => B (f y) (g y)) x‖ ≤ ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDeriv 𝕜 i f x‖ * ‖iteratedFDeriv 𝕜 (n - i) g x‖ := by simp_rw [← iteratedFDerivWithin_univ] exact B.norm_iteratedFDerivWithin_le_of_bilinear_of_le_one hf.contDiffOn hg.contDiffOn uniqueDiffOn_univ (mem_univ x) hn hB #align continuous_linear_map.norm_iterated_fderiv_le_of_bilinear_of_le_one ContinuousLinearMap.norm_iteratedFDeriv_le_of_bilinear_of_le_one section variable {𝕜' : Type*} [NormedField 𝕜'] [NormedAlgebra 𝕜 𝕜'] [NormedSpace 𝕜' F] [IsScalarTower 𝕜 𝕜' F] theorem norm_iteratedFDerivWithin_smul_le {f : E → 𝕜'} {g : E → F} {N : ℕ∞} (hf : ContDiffOn 𝕜 N f s) (hg : ContDiffOn 𝕜 N g s) (hs : UniqueDiffOn 𝕜 s) {x : E} (hx : x ∈ s) {n : ℕ} (hn : (n : ℕ∞) ≤ N) : ‖iteratedFDerivWithin 𝕜 n (fun y => f y • g y) s x‖ ≤ ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDerivWithin 𝕜 i f s x‖ * ‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ := (ContinuousLinearMap.lsmul 𝕜 𝕜' : 𝕜' →L[𝕜] F →L[𝕜] F).norm_iteratedFDerivWithin_le_of_bilinear_of_le_one hf hg hs hx hn ContinuousLinearMap.opNorm_lsmul_le #align norm_iterated_fderiv_within_smul_le norm_iteratedFDerivWithin_smul_le theorem norm_iteratedFDeriv_smul_le {f : E → 𝕜'} {g : E → F} {N : ℕ∞} (hf : ContDiff 𝕜 N f) (hg : ContDiff 𝕜 N g) (x : E) {n : ℕ} (hn : (n : ℕ∞) ≤ N) : ‖iteratedFDeriv 𝕜 n (fun y => f y • g y) x‖ ≤ ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDeriv 𝕜 i f x‖ * ‖iteratedFDeriv 𝕜 (n - i) g x‖ := (ContinuousLinearMap.lsmul 𝕜 𝕜' : 𝕜' →L[𝕜] F →L[𝕜] F).norm_iteratedFDeriv_le_of_bilinear_of_le_one hf hg x hn ContinuousLinearMap.opNorm_lsmul_le #align norm_iterated_fderiv_smul_le norm_iteratedFDeriv_smul_le end section variable {ι : Type*} {A : Type*} [NormedRing A] [NormedAlgebra 𝕜 A] {A' : Type*} [NormedCommRing A'] [NormedAlgebra 𝕜 A'] theorem norm_iteratedFDerivWithin_mul_le {f : E → A} {g : E → A} {N : ℕ∞} (hf : ContDiffOn 𝕜 N f s) (hg : ContDiffOn 𝕜 N g s) (hs : UniqueDiffOn 𝕜 s) {x : E} (hx : x ∈ s) {n : ℕ} (hn : (n : ℕ∞) ≤ N) : ‖iteratedFDerivWithin 𝕜 n (fun y => f y * g y) s x‖ ≤ ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDerivWithin 𝕜 i f s x‖ * ‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ := (ContinuousLinearMap.mul 𝕜 A : A →L[𝕜] A →L[𝕜] A).norm_iteratedFDerivWithin_le_of_bilinear_of_le_one hf hg hs hx hn (ContinuousLinearMap.opNorm_mul_le _ _) #align norm_iterated_fderiv_within_mul_le norm_iteratedFDerivWithin_mul_le theorem norm_iteratedFDeriv_mul_le {f : E → A} {g : E → A} {N : ℕ∞} (hf : ContDiff 𝕜 N f) (hg : ContDiff 𝕜 N g) (x : E) {n : ℕ} (hn : (n : ℕ∞) ≤ N) : ‖iteratedFDeriv 𝕜 n (fun y => f y * g y) x‖ ≤ ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDeriv 𝕜 i f x‖ * ‖iteratedFDeriv 𝕜 (n - i) g x‖ := by simp_rw [← iteratedFDerivWithin_univ] exact norm_iteratedFDerivWithin_mul_le hf.contDiffOn hg.contDiffOn uniqueDiffOn_univ (mem_univ x) hn #align norm_iterated_fderiv_mul_le norm_iteratedFDeriv_mul_le -- TODO: Add `norm_iteratedFDeriv[Within]_list_prod_le` for non-commutative `NormedRing A`. theorem norm_iteratedFDerivWithin_prod_le [DecidableEq ι] [NormOneClass A'] {u : Finset ι} {f : ι → E → A'} {N : ℕ∞} (hf : ∀ i ∈ u, ContDiffOn 𝕜 N (f i) s) (hs : UniqueDiffOn 𝕜 s) {x : E} (hx : x ∈ s) {n : ℕ} (hn : (n : ℕ∞) ≤ N) : ‖iteratedFDerivWithin 𝕜 n (∏ j ∈ u, f j ·) s x‖ ≤ ∑ p ∈ u.sym n, (p : Multiset ι).multinomial * ∏ j ∈ u, ‖iteratedFDerivWithin 𝕜 (Multiset.count j p) (f j) s x‖ := by induction u using Finset.induction generalizing n with | empty => cases n with | zero => simp [Sym.eq_nil_of_card_zero] | succ n => simp [iteratedFDerivWithin_succ_const _ _ hs hx] | @insert i u hi IH => conv => lhs; simp only [Finset.prod_insert hi] simp only [Finset.mem_insert, forall_eq_or_imp] at hf refine le_trans (norm_iteratedFDerivWithin_mul_le hf.1 (contDiffOn_prod hf.2) hs hx hn) ?_ rw [← Finset.sum_coe_sort (Finset.sym _ _)] rw [Finset.sum_equiv (Finset.symInsertEquiv hi) (t := Finset.univ) (g := (fun v ↦ v.multinomial * ∏ j ∈ insert i u, ‖iteratedFDerivWithin 𝕜 (v.count j) (f j) s x‖) ∘ Sym.toMultiset ∘ Subtype.val ∘ (Finset.symInsertEquiv hi).symm) (by simp) (by simp only [← comp_apply (g := Finset.symInsertEquiv hi), comp.assoc]; simp)] rw [← Finset.univ_sigma_univ, Finset.sum_sigma, Finset.sum_range] simp only [comp_apply, Finset.symInsertEquiv_symm_apply_coe] refine Finset.sum_le_sum ?_ intro m _ specialize IH hf.2 (n := n - m) (le_trans (WithTop.coe_le_coe.mpr (n.sub_le m)) hn) refine le_trans (mul_le_mul_of_nonneg_left IH (by simp [mul_nonneg])) ?_ rw [Finset.mul_sum, ← Finset.sum_coe_sort] refine Finset.sum_le_sum ?_ simp only [Finset.mem_univ, forall_true_left, Subtype.forall, Finset.mem_sym_iff] intro p hp refine le_of_eq ?_ rw [Finset.prod_insert hi] have hip : i ∉ p := mt (hp i) hi rw [Sym.count_coe_fill_self_of_not_mem hip, Sym.multinomial_coe_fill_of_not_mem hip] suffices ∏ j ∈ u, ‖iteratedFDerivWithin 𝕜 (Multiset.count j p) (f j) s x‖ = ∏ j ∈ u, ‖iteratedFDerivWithin 𝕜 (Multiset.count j (Sym.fill i m p)) (f j) s x‖ by rw [this, Nat.cast_mul] ring refine Finset.prod_congr rfl ?_ intro j hj have hji : j ≠ i := mt (· ▸ hj) hi rw [Sym.count_coe_fill_of_ne hji]
Mathlib/Analysis/Calculus/ContDiff/Bounds.lean
342
350
theorem norm_iteratedFDeriv_prod_le [DecidableEq ι] [NormOneClass A'] {u : Finset ι} {f : ι → E → A'} {N : ℕ∞} (hf : ∀ i ∈ u, ContDiff 𝕜 N (f i)) {x : E} {n : ℕ} (hn : (n : ℕ∞) ≤ N) : ‖iteratedFDeriv 𝕜 n (∏ j ∈ u, f j ·) x‖ ≤ ∑ p ∈ u.sym n, (p : Multiset ι).multinomial * ∏ j ∈ u, ‖iteratedFDeriv 𝕜 ((p : Multiset ι).count j) (f j) x‖ := by
simpa [iteratedFDerivWithin_univ] using norm_iteratedFDerivWithin_prod_le (fun i hi ↦ (hf i hi).contDiffOn) uniqueDiffOn_univ (mem_univ x) hn
import Mathlib.MeasureTheory.Measure.Content import Mathlib.MeasureTheory.Group.Prod import Mathlib.Topology.Algebra.Group.Compact #align_import measure_theory.measure.haar.basic from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" noncomputable section open Set Inv Function TopologicalSpace MeasurableSpace open scoped NNReal Classical ENNReal Pointwise Topology namespace MeasureTheory namespace Measure section Group variable {G : Type*} [Group G] namespace haar -- Porting note: Even in `noncomputable section`, a definition with `to_additive` require -- `noncomputable` to generate an additive definition. -- Please refer to leanprover/lean4#2077. @[to_additive addIndex "additive version of `MeasureTheory.Measure.haar.index`"] noncomputable def index (K V : Set G) : ℕ := sInf <| Finset.card '' { t : Finset G | K ⊆ ⋃ g ∈ t, (fun h => g * h) ⁻¹' V } #align measure_theory.measure.haar.index MeasureTheory.Measure.haar.index #align measure_theory.measure.haar.add_index MeasureTheory.Measure.haar.addIndex @[to_additive addIndex_empty] theorem index_empty {V : Set G} : index ∅ V = 0 := by simp only [index, Nat.sInf_eq_zero]; left; use ∅ simp only [Finset.card_empty, empty_subset, mem_setOf_eq, eq_self_iff_true, and_self_iff] #align measure_theory.measure.haar.index_empty MeasureTheory.Measure.haar.index_empty #align measure_theory.measure.haar.add_index_empty MeasureTheory.Measure.haar.addIndex_empty variable [TopologicalSpace G] @[to_additive "additive version of `MeasureTheory.Measure.haar.prehaar`"] noncomputable def prehaar (K₀ U : Set G) (K : Compacts G) : ℝ := (index (K : Set G) U : ℝ) / index K₀ U #align measure_theory.measure.haar.prehaar MeasureTheory.Measure.haar.prehaar #align measure_theory.measure.haar.add_prehaar MeasureTheory.Measure.haar.addPrehaar @[to_additive] theorem prehaar_empty (K₀ : PositiveCompacts G) {U : Set G} : prehaar (K₀ : Set G) U ⊥ = 0 := by rw [prehaar, Compacts.coe_bot, index_empty, Nat.cast_zero, zero_div] #align measure_theory.measure.haar.prehaar_empty MeasureTheory.Measure.haar.prehaar_empty #align measure_theory.measure.haar.add_prehaar_empty MeasureTheory.Measure.haar.addPrehaar_empty @[to_additive] theorem prehaar_nonneg (K₀ : PositiveCompacts G) {U : Set G} (K : Compacts G) : 0 ≤ prehaar (K₀ : Set G) U K := by apply div_nonneg <;> norm_cast <;> apply zero_le #align measure_theory.measure.haar.prehaar_nonneg MeasureTheory.Measure.haar.prehaar_nonneg #align measure_theory.measure.haar.add_prehaar_nonneg MeasureTheory.Measure.haar.addPrehaar_nonneg @[to_additive "additive version of `MeasureTheory.Measure.haar.haarProduct`"] def haarProduct (K₀ : Set G) : Set (Compacts G → ℝ) := pi univ fun K => Icc 0 <| index (K : Set G) K₀ #align measure_theory.measure.haar.haar_product MeasureTheory.Measure.haar.haarProduct #align measure_theory.measure.haar.add_haar_product MeasureTheory.Measure.haar.addHaarProduct @[to_additive (attr := simp)] theorem mem_prehaar_empty {K₀ : Set G} {f : Compacts G → ℝ} : f ∈ haarProduct K₀ ↔ ∀ K : Compacts G, f K ∈ Icc (0 : ℝ) (index (K : Set G) K₀) := by simp only [haarProduct, Set.pi, forall_prop_of_true, mem_univ, mem_setOf_eq] #align measure_theory.measure.haar.mem_prehaar_empty MeasureTheory.Measure.haar.mem_prehaar_empty #align measure_theory.measure.haar.mem_add_prehaar_empty MeasureTheory.Measure.haar.mem_addPrehaar_empty @[to_additive "additive version of `MeasureTheory.Measure.haar.clPrehaar`"] def clPrehaar (K₀ : Set G) (V : OpenNhdsOf (1 : G)) : Set (Compacts G → ℝ) := closure <| prehaar K₀ '' { U : Set G | U ⊆ V.1 ∧ IsOpen U ∧ (1 : G) ∈ U } #align measure_theory.measure.haar.cl_prehaar MeasureTheory.Measure.haar.clPrehaar #align measure_theory.measure.haar.cl_add_prehaar MeasureTheory.Measure.haar.clAddPrehaar variable [TopologicalGroup G] @[to_additive addIndex_defined "If `K` is compact and `V` has nonempty interior, then the index `(K : V)` is well-defined, there is a finite set `t` satisfying the desired properties."] theorem index_defined {K V : Set G} (hK : IsCompact K) (hV : (interior V).Nonempty) : ∃ n : ℕ, n ∈ Finset.card '' { t : Finset G | K ⊆ ⋃ g ∈ t, (fun h => g * h) ⁻¹' V } := by rcases compact_covered_by_mul_left_translates hK hV with ⟨t, ht⟩; exact ⟨t.card, t, ht, rfl⟩ #align measure_theory.measure.haar.index_defined MeasureTheory.Measure.haar.index_defined #align measure_theory.measure.haar.add_index_defined MeasureTheory.Measure.haar.addIndex_defined @[to_additive addIndex_elim] theorem index_elim {K V : Set G} (hK : IsCompact K) (hV : (interior V).Nonempty) : ∃ t : Finset G, (K ⊆ ⋃ g ∈ t, (fun h => g * h) ⁻¹' V) ∧ Finset.card t = index K V := by have := Nat.sInf_mem (index_defined hK hV); rwa [mem_image] at this #align measure_theory.measure.haar.index_elim MeasureTheory.Measure.haar.index_elim #align measure_theory.measure.haar.add_index_elim MeasureTheory.Measure.haar.addIndex_elim @[to_additive le_addIndex_mul] theorem le_index_mul (K₀ : PositiveCompacts G) (K : Compacts G) {V : Set G} (hV : (interior V).Nonempty) : index (K : Set G) V ≤ index (K : Set G) K₀ * index (K₀ : Set G) V := by obtain ⟨s, h1s, h2s⟩ := index_elim K.isCompact K₀.interior_nonempty obtain ⟨t, h1t, h2t⟩ := index_elim K₀.isCompact hV rw [← h2s, ← h2t, mul_comm] refine le_trans ?_ Finset.card_mul_le apply Nat.sInf_le; refine ⟨_, ?_, rfl⟩; rw [mem_setOf_eq]; refine Subset.trans h1s ?_ apply iUnion₂_subset; intro g₁ hg₁; rw [preimage_subset_iff]; intro g₂ hg₂ have := h1t hg₂ rcases this with ⟨_, ⟨g₃, rfl⟩, A, ⟨hg₃, rfl⟩, h2V⟩; rw [mem_preimage, ← mul_assoc] at h2V exact mem_biUnion (Finset.mul_mem_mul hg₃ hg₁) h2V #align measure_theory.measure.haar.le_index_mul MeasureTheory.Measure.haar.le_index_mul #align measure_theory.measure.haar.le_add_index_mul MeasureTheory.Measure.haar.le_addIndex_mul @[to_additive addIndex_pos] theorem index_pos (K : PositiveCompacts G) {V : Set G} (hV : (interior V).Nonempty) : 0 < index (K : Set G) V := by unfold index; rw [Nat.sInf_def, Nat.find_pos, mem_image] · rintro ⟨t, h1t, h2t⟩; rw [Finset.card_eq_zero] at h2t; subst h2t obtain ⟨g, hg⟩ := K.interior_nonempty show g ∈ (∅ : Set G) convert h1t (interior_subset hg); symm simp only [Finset.not_mem_empty, iUnion_of_empty, iUnion_empty] · exact index_defined K.isCompact hV #align measure_theory.measure.haar.index_pos MeasureTheory.Measure.haar.index_pos #align measure_theory.measure.haar.add_index_pos MeasureTheory.Measure.haar.addIndex_pos @[to_additive addIndex_mono] theorem index_mono {K K' V : Set G} (hK' : IsCompact K') (h : K ⊆ K') (hV : (interior V).Nonempty) : index K V ≤ index K' V := by rcases index_elim hK' hV with ⟨s, h1s, h2s⟩ apply Nat.sInf_le; rw [mem_image]; exact ⟨s, Subset.trans h h1s, h2s⟩ #align measure_theory.measure.haar.index_mono MeasureTheory.Measure.haar.index_mono #align measure_theory.measure.haar.add_index_mono MeasureTheory.Measure.haar.addIndex_mono @[to_additive addIndex_union_le] theorem index_union_le (K₁ K₂ : Compacts G) {V : Set G} (hV : (interior V).Nonempty) : index (K₁.1 ∪ K₂.1) V ≤ index K₁.1 V + index K₂.1 V := by rcases index_elim K₁.2 hV with ⟨s, h1s, h2s⟩ rcases index_elim K₂.2 hV with ⟨t, h1t, h2t⟩ rw [← h2s, ← h2t] refine le_trans ?_ (Finset.card_union_le _ _) apply Nat.sInf_le; refine ⟨_, ?_, rfl⟩; rw [mem_setOf_eq] apply union_subset <;> refine Subset.trans (by assumption) ?_ <;> apply biUnion_subset_biUnion_left <;> intro g hg <;> simp only [mem_def] at hg <;> simp only [mem_def, Multiset.mem_union, Finset.union_val, hg, or_true_iff, true_or_iff] #align measure_theory.measure.haar.index_union_le MeasureTheory.Measure.haar.index_union_le #align measure_theory.measure.haar.add_index_union_le MeasureTheory.Measure.haar.addIndex_union_le @[to_additive addIndex_union_eq] theorem index_union_eq (K₁ K₂ : Compacts G) {V : Set G} (hV : (interior V).Nonempty) (h : Disjoint (K₁.1 * V⁻¹) (K₂.1 * V⁻¹)) : index (K₁.1 ∪ K₂.1) V = index K₁.1 V + index K₂.1 V := by apply le_antisymm (index_union_le K₁ K₂ hV) rcases index_elim (K₁.2.union K₂.2) hV with ⟨s, h1s, h2s⟩; rw [← h2s] have : ∀ K : Set G, (K ⊆ ⋃ g ∈ s, (fun h => g * h) ⁻¹' V) → index K V ≤ (s.filter fun g => ((fun h : G => g * h) ⁻¹' V ∩ K).Nonempty).card := by intro K hK; apply Nat.sInf_le; refine ⟨_, ?_, rfl⟩; rw [mem_setOf_eq] intro g hg; rcases hK hg with ⟨_, ⟨g₀, rfl⟩, _, ⟨h1g₀, rfl⟩, h2g₀⟩ simp only [mem_preimage] at h2g₀ simp only [mem_iUnion]; use g₀; constructor; swap · simp only [Finset.mem_filter, h1g₀, true_and_iff]; use g simp only [hg, h2g₀, mem_inter_iff, mem_preimage, and_self_iff] exact h2g₀ refine le_trans (add_le_add (this K₁.1 <| Subset.trans subset_union_left h1s) (this K₂.1 <| Subset.trans subset_union_right h1s)) ?_ rw [← Finset.card_union_of_disjoint, Finset.filter_union_right] · exact s.card_filter_le _ apply Finset.disjoint_filter.mpr rintro g₁ _ ⟨g₂, h1g₂, h2g₂⟩ ⟨g₃, h1g₃, h2g₃⟩ simp only [mem_preimage] at h1g₃ h1g₂ refine h.le_bot (?_ : g₁⁻¹ ∈ _) constructor <;> simp only [Set.mem_inv, Set.mem_mul, exists_exists_and_eq_and, exists_and_left] · refine ⟨_, h2g₂, (g₁ * g₂)⁻¹, ?_, ?_⟩ · simp only [inv_inv, h1g₂] · simp only [mul_inv_rev, mul_inv_cancel_left] · refine ⟨_, h2g₃, (g₁ * g₃)⁻¹, ?_, ?_⟩ · simp only [inv_inv, h1g₃] · simp only [mul_inv_rev, mul_inv_cancel_left] #align measure_theory.measure.haar.index_union_eq MeasureTheory.Measure.haar.index_union_eq #align measure_theory.measure.haar.add_index_union_eq MeasureTheory.Measure.haar.addIndex_union_eq @[to_additive add_left_addIndex_le] theorem mul_left_index_le {K : Set G} (hK : IsCompact K) {V : Set G} (hV : (interior V).Nonempty) (g : G) : index ((fun h => g * h) '' K) V ≤ index K V := by rcases index_elim hK hV with ⟨s, h1s, h2s⟩; rw [← h2s] apply Nat.sInf_le; rw [mem_image] refine ⟨s.map (Equiv.mulRight g⁻¹).toEmbedding, ?_, Finset.card_map _⟩ simp only [mem_setOf_eq]; refine Subset.trans (image_subset _ h1s) ?_ rintro _ ⟨g₁, ⟨_, ⟨g₂, rfl⟩, ⟨_, ⟨hg₂, rfl⟩, hg₁⟩⟩, rfl⟩ simp only [mem_preimage] at hg₁; simp only [exists_prop, mem_iUnion, Finset.mem_map, Equiv.coe_mulRight, exists_exists_and_eq_and, mem_preimage, Equiv.toEmbedding_apply] refine ⟨_, hg₂, ?_⟩; simp only [mul_assoc, hg₁, inv_mul_cancel_left] #align measure_theory.measure.haar.mul_left_index_le MeasureTheory.Measure.haar.mul_left_index_le #align measure_theory.measure.haar.add_left_add_index_le MeasureTheory.Measure.haar.add_left_addIndex_le @[to_additive is_left_invariant_addIndex] theorem is_left_invariant_index {K : Set G} (hK : IsCompact K) (g : G) {V : Set G} (hV : (interior V).Nonempty) : index ((fun h => g * h) '' K) V = index K V := by refine le_antisymm (mul_left_index_le hK hV g) ?_ convert mul_left_index_le (hK.image <| continuous_mul_left g) hV g⁻¹ rw [image_image]; symm; convert image_id' _ with h; apply inv_mul_cancel_left #align measure_theory.measure.haar.is_left_invariant_index MeasureTheory.Measure.haar.is_left_invariant_index #align measure_theory.measure.haar.is_left_invariant_add_index MeasureTheory.Measure.haar.is_left_invariant_addIndex @[to_additive add_prehaar_le_addIndex] theorem prehaar_le_index (K₀ : PositiveCompacts G) {U : Set G} (K : Compacts G) (hU : (interior U).Nonempty) : prehaar (K₀ : Set G) U K ≤ index (K : Set G) K₀ := by unfold prehaar; rw [div_le_iff] <;> norm_cast · apply le_index_mul K₀ K hU · exact index_pos K₀ hU #align measure_theory.measure.haar.prehaar_le_index MeasureTheory.Measure.haar.prehaar_le_index #align measure_theory.measure.haar.add_prehaar_le_add_index MeasureTheory.Measure.haar.add_prehaar_le_addIndex @[to_additive] theorem prehaar_pos (K₀ : PositiveCompacts G) {U : Set G} (hU : (interior U).Nonempty) {K : Set G} (h1K : IsCompact K) (h2K : (interior K).Nonempty) : 0 < prehaar (K₀ : Set G) U ⟨K, h1K⟩ := by apply div_pos <;> norm_cast · apply index_pos ⟨⟨K, h1K⟩, h2K⟩ hU · exact index_pos K₀ hU #align measure_theory.measure.haar.prehaar_pos MeasureTheory.Measure.haar.prehaar_pos #align measure_theory.measure.haar.add_prehaar_pos MeasureTheory.Measure.haar.addPrehaar_pos @[to_additive] theorem prehaar_mono {K₀ : PositiveCompacts G} {U : Set G} (hU : (interior U).Nonempty) {K₁ K₂ : Compacts G} (h : (K₁ : Set G) ⊆ K₂.1) : prehaar (K₀ : Set G) U K₁ ≤ prehaar (K₀ : Set G) U K₂ := by simp only [prehaar]; rw [div_le_div_right] · exact mod_cast index_mono K₂.2 h hU · exact mod_cast index_pos K₀ hU #align measure_theory.measure.haar.prehaar_mono MeasureTheory.Measure.haar.prehaar_mono #align measure_theory.measure.haar.add_prehaar_mono MeasureTheory.Measure.haar.addPrehaar_mono @[to_additive] theorem prehaar_self {K₀ : PositiveCompacts G} {U : Set G} (hU : (interior U).Nonempty) : prehaar (K₀ : Set G) U K₀.toCompacts = 1 := div_self <| ne_of_gt <| mod_cast index_pos K₀ hU #align measure_theory.measure.haar.prehaar_self MeasureTheory.Measure.haar.prehaar_self #align measure_theory.measure.haar.add_prehaar_self MeasureTheory.Measure.haar.addPrehaar_self @[to_additive] theorem prehaar_sup_le {K₀ : PositiveCompacts G} {U : Set G} (K₁ K₂ : Compacts G) (hU : (interior U).Nonempty) : prehaar (K₀ : Set G) U (K₁ ⊔ K₂) ≤ prehaar (K₀ : Set G) U K₁ + prehaar (K₀ : Set G) U K₂ := by simp only [prehaar]; rw [div_add_div_same, div_le_div_right] · exact mod_cast index_union_le K₁ K₂ hU · exact mod_cast index_pos K₀ hU #align measure_theory.measure.haar.prehaar_sup_le MeasureTheory.Measure.haar.prehaar_sup_le #align measure_theory.measure.haar.add_prehaar_sup_le MeasureTheory.Measure.haar.addPrehaar_sup_le @[to_additive] theorem prehaar_sup_eq {K₀ : PositiveCompacts G} {U : Set G} {K₁ K₂ : Compacts G} (hU : (interior U).Nonempty) (h : Disjoint (K₁.1 * U⁻¹) (K₂.1 * U⁻¹)) : prehaar (K₀ : Set G) U (K₁ ⊔ K₂) = prehaar (K₀ : Set G) U K₁ + prehaar (K₀ : Set G) U K₂ := by simp only [prehaar]; rw [div_add_div_same] -- Porting note: Here was `congr`, but `to_additive` failed to generate a theorem. refine congr_arg (fun x : ℝ => x / index K₀ U) ?_ exact mod_cast index_union_eq K₁ K₂ hU h #align measure_theory.measure.haar.prehaar_sup_eq MeasureTheory.Measure.haar.prehaar_sup_eq #align measure_theory.measure.haar.add_prehaar_sup_eq MeasureTheory.Measure.haar.addPrehaar_sup_eq @[to_additive] theorem is_left_invariant_prehaar {K₀ : PositiveCompacts G} {U : Set G} (hU : (interior U).Nonempty) (g : G) (K : Compacts G) : prehaar (K₀ : Set G) U (K.map _ <| continuous_mul_left g) = prehaar (K₀ : Set G) U K := by simp only [prehaar, Compacts.coe_map, is_left_invariant_index K.isCompact _ hU] #align measure_theory.measure.haar.is_left_invariant_prehaar MeasureTheory.Measure.haar.is_left_invariant_prehaar #align measure_theory.measure.haar.is_left_invariant_add_prehaar MeasureTheory.Measure.haar.is_left_invariant_addPrehaar @[to_additive] theorem prehaar_mem_haarProduct (K₀ : PositiveCompacts G) {U : Set G} (hU : (interior U).Nonempty) : prehaar (K₀ : Set G) U ∈ haarProduct (K₀ : Set G) := by rintro ⟨K, hK⟩ _; rw [mem_Icc]; exact ⟨prehaar_nonneg K₀ _, prehaar_le_index K₀ _ hU⟩ #align measure_theory.measure.haar.prehaar_mem_haar_product MeasureTheory.Measure.haar.prehaar_mem_haarProduct #align measure_theory.measure.haar.add_prehaar_mem_add_haar_product MeasureTheory.Measure.haar.addPrehaar_mem_addHaarProduct @[to_additive] theorem nonempty_iInter_clPrehaar (K₀ : PositiveCompacts G) : (haarProduct (K₀ : Set G) ∩ ⋂ V : OpenNhdsOf (1 : G), clPrehaar K₀ V).Nonempty := by have : IsCompact (haarProduct (K₀ : Set G)) := by apply isCompact_univ_pi; intro K; apply isCompact_Icc refine this.inter_iInter_nonempty (clPrehaar K₀) (fun s => isClosed_closure) fun t => ?_ let V₀ := ⋂ V ∈ t, (V : OpenNhdsOf (1 : G)).carrier have h1V₀ : IsOpen V₀ := isOpen_biInter_finset <| by rintro ⟨⟨V, hV₁⟩, hV₂⟩ _; exact hV₁ have h2V₀ : (1 : G) ∈ V₀ := by simp only [V₀, mem_iInter]; rintro ⟨⟨V, hV₁⟩, hV₂⟩ _; exact hV₂ refine ⟨prehaar K₀ V₀, ?_⟩ constructor · apply prehaar_mem_haarProduct K₀; use 1; rwa [h1V₀.interior_eq] · simp only [mem_iInter]; rintro ⟨V, hV⟩ h2V; apply subset_closure apply mem_image_of_mem; rw [mem_setOf_eq] exact ⟨Subset.trans (iInter_subset _ ⟨V, hV⟩) (iInter_subset _ h2V), h1V₀, h2V₀⟩ #align measure_theory.measure.haar.nonempty_Inter_cl_prehaar MeasureTheory.Measure.haar.nonempty_iInter_clPrehaar #align measure_theory.measure.haar.nonempty_Inter_cl_add_prehaar MeasureTheory.Measure.haar.nonempty_iInter_clAddPrehaar -- Porting note: Even in `noncomputable section`, a definition with `to_additive` require -- `noncomputable` to generate an additive definition. -- Please refer to leanprover/lean4#2077. @[to_additive addCHaar "additive version of `MeasureTheory.Measure.haar.chaar`"] noncomputable def chaar (K₀ : PositiveCompacts G) (K : Compacts G) : ℝ := Classical.choose (nonempty_iInter_clPrehaar K₀) K #align measure_theory.measure.haar.chaar MeasureTheory.Measure.haar.chaar #align measure_theory.measure.haar.add_chaar MeasureTheory.Measure.haar.addCHaar @[to_additive addCHaar_mem_addHaarProduct] theorem chaar_mem_haarProduct (K₀ : PositiveCompacts G) : chaar K₀ ∈ haarProduct (K₀ : Set G) := (Classical.choose_spec (nonempty_iInter_clPrehaar K₀)).1 #align measure_theory.measure.haar.chaar_mem_haar_product MeasureTheory.Measure.haar.chaar_mem_haarProduct #align measure_theory.measure.haar.add_chaar_mem_add_haar_product MeasureTheory.Measure.haar.addCHaar_mem_addHaarProduct @[to_additive addCHaar_mem_clAddPrehaar] theorem chaar_mem_clPrehaar (K₀ : PositiveCompacts G) (V : OpenNhdsOf (1 : G)) : chaar K₀ ∈ clPrehaar (K₀ : Set G) V := by have := (Classical.choose_spec (nonempty_iInter_clPrehaar K₀)).2; rw [mem_iInter] at this exact this V #align measure_theory.measure.haar.chaar_mem_cl_prehaar MeasureTheory.Measure.haar.chaar_mem_clPrehaar #align measure_theory.measure.haar.add_chaar_mem_cl_add_prehaar MeasureTheory.Measure.haar.addCHaar_mem_clAddPrehaar @[to_additive addCHaar_nonneg] theorem chaar_nonneg (K₀ : PositiveCompacts G) (K : Compacts G) : 0 ≤ chaar K₀ K := by have := chaar_mem_haarProduct K₀ K (mem_univ _); rw [mem_Icc] at this; exact this.1 #align measure_theory.measure.haar.chaar_nonneg MeasureTheory.Measure.haar.chaar_nonneg #align measure_theory.measure.haar.add_chaar_nonneg MeasureTheory.Measure.haar.addCHaar_nonneg @[to_additive addCHaar_empty]
Mathlib/MeasureTheory/Measure/Haar/Basic.lean
436
443
theorem chaar_empty (K₀ : PositiveCompacts G) : chaar K₀ ⊥ = 0 := by
let eval : (Compacts G → ℝ) → ℝ := fun f => f ⊥ have : Continuous eval := continuous_apply ⊥ show chaar K₀ ∈ eval ⁻¹' {(0 : ℝ)} apply mem_of_subset_of_mem _ (chaar_mem_clPrehaar K₀ ⊤) unfold clPrehaar; rw [IsClosed.closure_subset_iff] · rintro _ ⟨U, _, rfl⟩; apply prehaar_empty · apply continuous_iff_isClosed.mp this; exact isClosed_singleton
import Mathlib.CategoryTheory.Adjunction.Basic open CategoryTheory variable {C D : Type*} [Category C] [Category D] namespace CategoryTheory.Adjunction @[simps] def natTransEquiv {F F' : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') : (G ⟶ G') ≃ (F' ⟶ F) where toFun f := { app := fun X ↦ F'.map ((adj1.unit ≫ whiskerLeft F f).app X) ≫ adj2.counit.app _ naturality := by intro X Y g simp only [← Category.assoc, ← Functor.map_comp] erw [(adj1.unit ≫ (whiskerLeft F f)).naturality] simp } invFun f := { app := fun X ↦ adj2.unit.app (G.obj X) ≫ G'.map (f.app (G.obj X) ≫ adj1.counit.app X) naturality := by intro X Y g erw [← adj2.unit_naturality_assoc] simp only [← Functor.map_comp] simp } left_inv f := by ext X simp only [Functor.comp_obj, NatTrans.comp_app, Functor.id_obj, whiskerLeft_app, Functor.map_comp, Category.assoc, unit_naturality_assoc, right_triangle_components_assoc] erw [← f.naturality (adj1.counit.app X), ← Category.assoc] simp right_inv f := by ext simp @[simp] lemma natTransEquiv_id {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) : natTransEquiv adj adj (𝟙 _) = 𝟙 _ := by ext; simp @[simp] lemma natTransEquiv_id_symm {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) : (natTransEquiv adj adj).symm (𝟙 _) = 𝟙 _ := by ext; simp @[simp] lemma natTransEquiv_comp {F F' F'' : C ⥤ D} {G G' G'' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') (adj3 : F'' ⊣ G'') (f : G ⟶ G') (g : G' ⟶ G'') : natTransEquiv adj2 adj3 g ≫ natTransEquiv adj1 adj2 f = natTransEquiv adj1 adj3 (f ≫ g) := by apply (natTransEquiv adj1 adj3).symm.injective ext X simp only [natTransEquiv_symm_apply_app, Functor.comp_obj, NatTrans.comp_app, natTransEquiv_apply_app, Functor.id_obj, whiskerLeft_app, Functor.map_comp, Category.assoc, unit_naturality_assoc, right_triangle_components_assoc, Equiv.symm_apply_apply, ← g.naturality_assoc, ← g.naturality] simp only [← Category.assoc, unit_naturality, Functor.comp_obj, right_triangle_components, Category.comp_id, ← f.naturality, Category.id_comp] @[simp] lemma natTransEquiv_comp_symm {F F' F'' : C ⥤ D} {G G' G'' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') (adj3 : F'' ⊣ G'') (f : F' ⟶ F) (g : F'' ⟶ F') : (natTransEquiv adj1 adj2).symm f ≫ (natTransEquiv adj2 adj3).symm g = (natTransEquiv adj1 adj3).symm (g ≫ f) := by apply (natTransEquiv adj1 adj3).injective ext simp @[simps] def natIsoEquiv {F F' : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') : (G ≅ G') ≃ (F' ≅ F) where toFun i := { hom := natTransEquiv adj1 adj2 i.hom inv := natTransEquiv adj2 adj1 i.inv } invFun i := { hom := (natTransEquiv adj1 adj2).symm i.hom inv := (natTransEquiv adj2 adj1).symm i.inv } left_inv i := by simp right_inv i := by simp def leftAdjointUniq {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) : F ≅ F' := (natIsoEquiv adj1 adj2 (Iso.refl _)).symm #align category_theory.adjunction.left_adjoint_uniq CategoryTheory.Adjunction.leftAdjointUniq -- Porting note (#10618): removed simp as simp can prove this theorem homEquiv_leftAdjointUniq_hom_app {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) : adj1.homEquiv _ _ ((leftAdjointUniq adj1 adj2).hom.app x) = adj2.unit.app x := by simp [leftAdjointUniq] #align category_theory.adjunction.hom_equiv_left_adjoint_uniq_hom_app CategoryTheory.Adjunction.homEquiv_leftAdjointUniq_hom_app @[reassoc (attr := simp)] theorem unit_leftAdjointUniq_hom {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) : adj1.unit ≫ whiskerRight (leftAdjointUniq adj1 adj2).hom G = adj2.unit := by ext x rw [NatTrans.comp_app, ← homEquiv_leftAdjointUniq_hom_app adj1 adj2] simp [← G.map_comp] #align category_theory.adjunction.unit_left_adjoint_uniq_hom CategoryTheory.Adjunction.unit_leftAdjointUniq_hom @[reassoc (attr := simp)] theorem unit_leftAdjointUniq_hom_app {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) : adj1.unit.app x ≫ G.map ((leftAdjointUniq adj1 adj2).hom.app x) = adj2.unit.app x := by rw [← unit_leftAdjointUniq_hom adj1 adj2]; rfl #align category_theory.adjunction.unit_left_adjoint_uniq_hom_app CategoryTheory.Adjunction.unit_leftAdjointUniq_hom_app @[reassoc (attr := simp)] theorem leftAdjointUniq_hom_counit {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) : whiskerLeft G (leftAdjointUniq adj1 adj2).hom ≫ adj2.counit = adj1.counit := by ext x simp only [Functor.comp_obj, Functor.id_obj, leftAdjointUniq, Iso.symm_hom, natIsoEquiv_apply_inv, Iso.refl_inv, NatTrans.comp_app, whiskerLeft_app, natTransEquiv_apply_app, whiskerLeft_id', Category.comp_id, Category.assoc] rw [← adj1.counit_naturality, ← Category.assoc, ← F.map_comp] simp #align category_theory.adjunction.left_adjoint_uniq_hom_counit CategoryTheory.Adjunction.leftAdjointUniq_hom_counit @[reassoc (attr := simp)] theorem leftAdjointUniq_hom_app_counit {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : D) : (leftAdjointUniq adj1 adj2).hom.app (G.obj x) ≫ adj2.counit.app x = adj1.counit.app x := by rw [← leftAdjointUniq_hom_counit adj1 adj2] rfl #align category_theory.adjunction.left_adjoint_uniq_hom_app_counit CategoryTheory.Adjunction.leftAdjointUniq_hom_app_counit theorem leftAdjointUniq_inv_app {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) : (leftAdjointUniq adj1 adj2).inv.app x = (leftAdjointUniq adj2 adj1).hom.app x := rfl #align category_theory.adjunction.left_adjoint_uniq_inv_app CategoryTheory.Adjunction.leftAdjointUniq_inv_app @[reassoc (attr := simp)] theorem leftAdjointUniq_trans {F F' F'' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (adj3 : F'' ⊣ G) : (leftAdjointUniq adj1 adj2).hom ≫ (leftAdjointUniq adj2 adj3).hom = (leftAdjointUniq adj1 adj3).hom := by simp [leftAdjointUniq] #align category_theory.adjunction.left_adjoint_uniq_trans CategoryTheory.Adjunction.leftAdjointUniq_trans @[reassoc (attr := simp)] theorem leftAdjointUniq_trans_app {F F' F'' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (adj3 : F'' ⊣ G) (x : C) : (leftAdjointUniq adj1 adj2).hom.app x ≫ (leftAdjointUniq adj2 adj3).hom.app x = (leftAdjointUniq adj1 adj3).hom.app x := by rw [← leftAdjointUniq_trans adj1 adj2 adj3] rfl #align category_theory.adjunction.left_adjoint_uniq_trans_app CategoryTheory.Adjunction.leftAdjointUniq_trans_app @[simp] theorem leftAdjointUniq_refl {F : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) : (leftAdjointUniq adj1 adj1).hom = 𝟙 _ := by simp [leftAdjointUniq] #align category_theory.adjunction.left_adjoint_uniq_refl CategoryTheory.Adjunction.leftAdjointUniq_refl def rightAdjointUniq {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') : G ≅ G' := (natIsoEquiv adj1 adj2).symm (Iso.refl _) #align category_theory.adjunction.right_adjoint_uniq CategoryTheory.Adjunction.rightAdjointUniq -- Porting note (#10618): simp can prove this theorem homEquiv_symm_rightAdjointUniq_hom_app {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') (x : D) : (adj2.homEquiv _ _).symm ((rightAdjointUniq adj1 adj2).hom.app x) = adj1.counit.app x := by simp [rightAdjointUniq] #align category_theory.adjunction.hom_equiv_symm_right_adjoint_uniq_hom_app CategoryTheory.Adjunction.homEquiv_symm_rightAdjointUniq_hom_app @[reassoc (attr := simp)] theorem unit_rightAdjointUniq_hom_app {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') (x : C) : adj1.unit.app x ≫ (rightAdjointUniq adj1 adj2).hom.app (F.obj x) = adj2.unit.app x := by simp only [Functor.id_obj, Functor.comp_obj, rightAdjointUniq, natIsoEquiv_symm_apply_hom, Iso.refl_hom, natTransEquiv_symm_apply_app, NatTrans.id_app, Category.id_comp] rw [← adj2.unit_naturality_assoc, ← G'.map_comp] simp #align category_theory.adjunction.unit_right_adjoint_uniq_hom_app CategoryTheory.Adjunction.unit_rightAdjointUniq_hom_app @[reassoc (attr := simp)]
Mathlib/CategoryTheory/Adjunction/Unique.lean
207
210
theorem unit_rightAdjointUniq_hom {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') : adj1.unit ≫ whiskerLeft F (rightAdjointUniq adj1 adj2).hom = adj2.unit := by
ext x simp
import Mathlib.Data.Countable.Basic import Mathlib.Data.Fin.VecNotation import Mathlib.Order.Disjointed import Mathlib.MeasureTheory.OuterMeasure.Defs #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 section OuterMeasureClass variable {α ι F : Type*} [FunLike F (Set α) ℝ≥0∞] [OuterMeasureClass F α] {μ : F} {s t : Set α} @[simp] theorem measure_empty : μ ∅ = 0 := OuterMeasureClass.measure_empty μ #align measure_theory.measure_empty MeasureTheory.measure_empty @[mono, gcongr] theorem measure_mono (h : s ⊆ t) : μ s ≤ μ t := OuterMeasureClass.measure_mono μ h #align measure_theory.measure_mono MeasureTheory.measure_mono theorem measure_mono_null (h : s ⊆ t) (ht : μ t = 0) : μ s = 0 := eq_bot_mono (measure_mono h) ht #align measure_theory.measure_mono_null MeasureTheory.measure_mono_null theorem measure_pos_of_superset (h : s ⊆ t) (hs : μ s ≠ 0) : 0 < μ t := hs.bot_lt.trans_le (measure_mono h) theorem measure_iUnion_le [Countable ι] (s : ι → Set α) : μ (⋃ i, s i) ≤ ∑' i, μ (s i) := by refine rel_iSup_tsum μ measure_empty (· ≤ ·) (fun t ↦ ?_) _ calc μ (⋃ i, t i) = μ (⋃ i, disjointed t i) := by rw [iUnion_disjointed] _ ≤ ∑' i, μ (disjointed t i) := OuterMeasureClass.measure_iUnion_nat_le _ _ (disjoint_disjointed _) _ ≤ ∑' i, μ (t i) := by gcongr; apply disjointed_subset #align measure_theory.measure_Union_le MeasureTheory.measure_iUnion_le theorem measure_biUnion_le {I : Set ι} (μ : F) (hI : I.Countable) (s : ι → Set α) : μ (⋃ i ∈ I, s i) ≤ ∑' i : I, μ (s i) := by have := hI.to_subtype rw [biUnion_eq_iUnion] apply measure_iUnion_le #align measure_theory.measure_bUnion_le MeasureTheory.measure_biUnion_le theorem measure_biUnion_finset_le (I : Finset ι) (s : ι → Set α) : μ (⋃ i ∈ I, s i) ≤ ∑ i ∈ I, μ (s i) := (measure_biUnion_le μ I.countable_toSet s).trans_eq <| I.tsum_subtype (μ <| s ·) #align measure_theory.measure_bUnion_finset_le MeasureTheory.measure_biUnion_finset_le
Mathlib/MeasureTheory/OuterMeasure/Basic.lean
84
86
theorem measure_iUnion_fintype_le [Fintype ι] (μ : F) (s : ι → Set α) : μ (⋃ i, s i) ≤ ∑ i, μ (s i) := by
simpa using measure_biUnion_finset_le Finset.univ s
import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Tactic.LinearCombination #align_import ring_theory.polynomial.chebyshev from "leanprover-community/mathlib"@"d774451114d6045faeb6751c396bea1eb9058946" namespace Polynomial.Chebyshev set_option linter.uppercaseLean3 false -- `T` `U` `X` open Polynomial variable (R S : Type*) [CommRing R] [CommRing S] -- Well-founded definitions are now irreducible by default; -- as this was implemented before this change, -- we just set it back to semireducible to avoid needing to change any proofs. @[semireducible] noncomputable def T : ℤ → R[X] | 0 => 1 | 1 => X | (n : ℕ) + 2 => 2 * X * T (n + 1) - T n | -((n : ℕ) + 1) => 2 * X * T (-n) - T (-n + 1) termination_by n => Int.natAbs n + Int.natAbs (n - 1) #align polynomial.chebyshev.T Polynomial.Chebyshev.T @[elab_as_elim] protected theorem induct (motive : ℤ → Prop) (zero : motive 0) (one : motive 1) (add_two : ∀ (n : ℕ), motive (↑n + 1) → motive ↑n → motive (↑n + 2)) (neg_add_one : ∀ (n : ℕ), motive (-↑n) → motive (-↑n + 1) → motive (-↑n - 1)) : ∀ (a : ℤ), motive a := T.induct Unit motive zero one add_two fun n hn hnm => by simpa only [Int.negSucc_eq, neg_add] using neg_add_one n hn hnm @[simp] theorem T_add_two : ∀ n, T R (n + 2) = 2 * X * T R (n + 1) - T R n | (k : ℕ) => T.eq_3 R k | -(k + 1 : ℕ) => by linear_combination (norm := (simp [Int.negSucc_eq]; ring_nf)) T.eq_4 R k #align polynomial.chebyshev.T_add_two Polynomial.Chebyshev.T_add_two theorem T_add_one (n : ℤ) : T R (n + 1) = 2 * X * T R n - T R (n - 1) := by linear_combination (norm := ring_nf) T_add_two R (n - 1) theorem T_sub_two (n : ℤ) : T R (n - 2) = 2 * X * T R (n - 1) - T R n := by linear_combination (norm := ring_nf) T_add_two R (n - 2) theorem T_sub_one (n : ℤ) : T R (n - 1) = 2 * X * T R n - T R (n + 1) := by linear_combination (norm := ring_nf) T_add_two R (n - 1) theorem T_eq (n : ℤ) : T R n = 2 * X * T R (n - 1) - T R (n - 2) := by linear_combination (norm := ring_nf) T_add_two R (n - 2) #align polynomial.chebyshev.T_of_two_le Polynomial.Chebyshev.T_eq @[simp] theorem T_zero : T R 0 = 1 := rfl #align polynomial.chebyshev.T_zero Polynomial.Chebyshev.T_zero @[simp] theorem T_one : T R 1 = X := rfl #align polynomial.chebyshev.T_one Polynomial.Chebyshev.T_one theorem T_neg_one : T R (-1) = X := (by ring : 2 * X * 1 - X = X) theorem T_two : T R 2 = 2 * X ^ 2 - 1 := by simpa [pow_two, mul_assoc] using T_add_two R 0 #align polynomial.chebyshev.T_two Polynomial.Chebyshev.T_two @[simp] theorem T_neg (n : ℤ) : T R (-n) = T R n := by induction n using Polynomial.Chebyshev.induct with | zero => rfl | one => show 2 * X * 1 - X = X; ring | add_two n ih1 ih2 => have h₁ := T_add_two R n have h₂ := T_sub_two R (-n) linear_combination (norm := ring_nf) (2 * (X:R[X])) * ih1 - ih2 - h₁ + h₂ | neg_add_one n ih1 ih2 => have h₁ := T_add_one R n have h₂ := T_sub_one R (-n) linear_combination (norm := ring_nf) (2 * (X:R[X])) * ih1 - ih2 + h₁ - h₂ theorem T_natAbs (n : ℤ) : T R n.natAbs = T R n := by obtain h | h := Int.natAbs_eq n <;> nth_rw 2 [h]; simp theorem T_neg_two : T R (-2) = 2 * X ^ 2 - 1 := by simp [T_two] -- Well-founded definitions are now irreducible by default; -- as this was implemented before this change, -- we just set it back to semireducible to avoid needing to change any proofs. @[semireducible] noncomputable def U : ℤ → R[X] | 0 => 1 | 1 => 2 * X | (n : ℕ) + 2 => 2 * X * U (n + 1) - U n | -((n : ℕ) + 1) => 2 * X * U (-n) - U (-n + 1) termination_by n => Int.natAbs n + Int.natAbs (n - 1) #align polynomial.chebyshev.U Polynomial.Chebyshev.U @[simp] theorem U_add_two : ∀ n, U R (n + 2) = 2 * X * U R (n + 1) - U R n | (k : ℕ) => U.eq_3 R k | -(k + 1 : ℕ) => by linear_combination (norm := (simp [Int.negSucc_eq]; ring_nf)) U.eq_4 R k theorem U_add_one (n : ℤ) : U R (n + 1) = 2 * X * U R n - U R (n - 1) := by linear_combination (norm := ring_nf) U_add_two R (n - 1) theorem U_sub_two (n : ℤ) : U R (n - 2) = 2 * X * U R (n - 1) - U R n := by linear_combination (norm := ring_nf) U_add_two R (n - 2) theorem U_sub_one (n : ℤ) : U R (n - 1) = 2 * X * U R n - U R (n + 1) := by linear_combination (norm := ring_nf) U_add_two R (n - 1) theorem U_eq (n : ℤ) : U R n = 2 * X * U R (n - 1) - U R (n - 2) := by linear_combination (norm := ring_nf) U_add_two R (n - 2) #align polynomial.chebyshev.U_of_two_le Polynomial.Chebyshev.U_eq @[simp] theorem U_zero : U R 0 = 1 := rfl #align polynomial.chebyshev.U_zero Polynomial.Chebyshev.U_zero @[simp] theorem U_one : U R 1 = 2 * X := rfl #align polynomial.chebyshev.U_one Polynomial.Chebyshev.U_one @[simp] theorem U_neg_one : U R (-1) = 0 := by simpa using U_sub_one R 0 theorem U_two : U R 2 = 4 * X ^ 2 - 1 := by have := U_add_two R 0 simp only [zero_add, U_one, U_zero] at this linear_combination this #align polynomial.chebyshev.U_two Polynomial.Chebyshev.U_two @[simp] theorem U_neg_two : U R (-2) = -1 := by simpa [zero_sub, Int.reduceNeg, U_neg_one, mul_zero, U_zero] using U_sub_two R 0 theorem U_neg_sub_one (n : ℤ) : U R (-n - 1) = -U R (n - 1) := by induction n using Polynomial.Chebyshev.induct with | zero => simp | one => simp | add_two n ih1 ih2 => have h₁ := U_add_one R n have h₂ := U_sub_two R (-n - 1) linear_combination (norm := ring_nf) 2 * (X:R[X]) * ih1 - ih2 + h₁ + h₂ | neg_add_one n ih1 ih2 => have h₁ := U_eq R n have h₂ := U_sub_two R (-n) linear_combination (norm := ring_nf) 2 * (X:R[X]) * ih1 - ih2 + h₁ + h₂
Mathlib/RingTheory/Polynomial/Chebyshev.lean
200
200
theorem U_neg (n : ℤ) : U R (-n) = -U R (n - 2) := by
simpa [sub_sub] using U_neg_sub_one R (n - 1)
import Mathlib.Algebra.Module.Submodule.EqLocus import Mathlib.Algebra.Module.Submodule.RestrictScalars import Mathlib.Algebra.Ring.Idempotents import Mathlib.Data.Set.Pointwise.SMul import Mathlib.LinearAlgebra.Basic import Mathlib.Order.CompactlyGenerated.Basic import Mathlib.Order.OmegaCompletePartialOrder #align_import linear_algebra.span from "leanprover-community/mathlib"@"10878f6bf1dab863445907ab23fbfcefcb5845d0" variable {R R₂ K M M₂ V S : Type*} namespace Submodule open Function Set open Pointwise section AddCommMonoid variable [Semiring R] [AddCommMonoid M] [Module R M] variable {x : M} (p p' : Submodule R M) variable [Semiring R₂] {σ₁₂ : R →+* R₂} variable [AddCommMonoid M₂] [Module R₂ M₂] variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂] section variable (R) def span (s : Set M) : Submodule R M := sInf { p | s ⊆ p } #align submodule.span Submodule.span variable {R} -- Porting note: renamed field to `principal'` and added `principal` to fix explicit argument @[mk_iff] class IsPrincipal (S : Submodule R M) : Prop where principal' : ∃ a, S = span R {a} #align submodule.is_principal Submodule.IsPrincipal theorem IsPrincipal.principal (S : Submodule R M) [S.IsPrincipal] : ∃ a, S = span R {a} := Submodule.IsPrincipal.principal' #align submodule.is_principal.principal Submodule.IsPrincipal.principal end variable {s t : Set M} theorem mem_span : x ∈ span R s ↔ ∀ p : Submodule R M, s ⊆ p → x ∈ p := mem_iInter₂ #align submodule.mem_span Submodule.mem_span @[aesop safe 20 apply (rule_sets := [SetLike])] theorem subset_span : s ⊆ span R s := fun _ h => mem_span.2 fun _ hp => hp h #align submodule.subset_span Submodule.subset_span theorem span_le {p} : span R s ≤ p ↔ s ⊆ p := ⟨Subset.trans subset_span, fun ss _ h => mem_span.1 h _ ss⟩ #align submodule.span_le Submodule.span_le theorem span_mono (h : s ⊆ t) : span R s ≤ span R t := span_le.2 <| Subset.trans h subset_span #align submodule.span_mono Submodule.span_mono theorem span_monotone : Monotone (span R : Set M → Submodule R M) := fun _ _ => span_mono #align submodule.span_monotone Submodule.span_monotone theorem span_eq_of_le (h₁ : s ⊆ p) (h₂ : p ≤ span R s) : span R s = p := le_antisymm (span_le.2 h₁) h₂ #align submodule.span_eq_of_le Submodule.span_eq_of_le theorem span_eq : span R (p : Set M) = p := span_eq_of_le _ (Subset.refl _) subset_span #align submodule.span_eq Submodule.span_eq theorem span_eq_span (hs : s ⊆ span R t) (ht : t ⊆ span R s) : span R s = span R t := le_antisymm (span_le.2 hs) (span_le.2 ht) #align submodule.span_eq_span Submodule.span_eq_span lemma coe_span_eq_self [SetLike S M] [AddSubmonoidClass S M] [SMulMemClass S R M] (s : S) : (span R (s : Set M) : Set M) = s := by refine le_antisymm ?_ subset_span let s' : Submodule R M := { carrier := s add_mem' := add_mem zero_mem' := zero_mem _ smul_mem' := SMulMemClass.smul_mem } exact span_le (p := s') |>.mpr le_rfl @[simp] theorem span_coe_eq_restrictScalars [Semiring S] [SMul S R] [Module S M] [IsScalarTower S R M] : span S (p : Set M) = p.restrictScalars S := span_eq (p.restrictScalars S) #align submodule.span_coe_eq_restrict_scalars Submodule.span_coe_eq_restrictScalars theorem image_span_subset (f : F) (s : Set M) (N : Submodule R₂ M₂) : f '' span R s ⊆ N ↔ ∀ m ∈ s, f m ∈ N := image_subset_iff.trans <| span_le (p := N.comap f) theorem image_span_subset_span (f : F) (s : Set M) : f '' span R s ⊆ span R₂ (f '' s) := (image_span_subset f s _).2 fun x hx ↦ subset_span ⟨x, hx, rfl⟩ theorem map_span [RingHomSurjective σ₁₂] (f : F) (s : Set M) : (span R s).map f = span R₂ (f '' s) := Eq.symm <| span_eq_of_le _ (Set.image_subset f subset_span) (image_span_subset_span f s) #align submodule.map_span Submodule.map_span alias _root_.LinearMap.map_span := Submodule.map_span #align linear_map.map_span LinearMap.map_span theorem map_span_le [RingHomSurjective σ₁₂] (f : F) (s : Set M) (N : Submodule R₂ M₂) : map f (span R s) ≤ N ↔ ∀ m ∈ s, f m ∈ N := image_span_subset f s N #align submodule.map_span_le Submodule.map_span_le alias _root_.LinearMap.map_span_le := Submodule.map_span_le #align linear_map.map_span_le LinearMap.map_span_le @[simp] theorem span_insert_zero : span R (insert (0 : M) s) = span R s := by refine le_antisymm ?_ (Submodule.span_mono (Set.subset_insert 0 s)) rw [span_le, Set.insert_subset_iff] exact ⟨by simp only [SetLike.mem_coe, Submodule.zero_mem], Submodule.subset_span⟩ #align submodule.span_insert_zero Submodule.span_insert_zero -- See also `span_preimage_eq` below. theorem span_preimage_le (f : F) (s : Set M₂) : span R (f ⁻¹' s) ≤ (span R₂ s).comap f := by rw [span_le, comap_coe] exact preimage_mono subset_span #align submodule.span_preimage_le Submodule.span_preimage_le alias _root_.LinearMap.span_preimage_le := Submodule.span_preimage_le #align linear_map.span_preimage_le LinearMap.span_preimage_le theorem closure_subset_span {s : Set M} : (AddSubmonoid.closure s : Set M) ⊆ span R s := (@AddSubmonoid.closure_le _ _ _ (span R s).toAddSubmonoid).mpr subset_span #align submodule.closure_subset_span Submodule.closure_subset_span theorem closure_le_toAddSubmonoid_span {s : Set M} : AddSubmonoid.closure s ≤ (span R s).toAddSubmonoid := closure_subset_span #align submodule.closure_le_to_add_submonoid_span Submodule.closure_le_toAddSubmonoid_span @[simp] theorem span_closure {s : Set M} : span R (AddSubmonoid.closure s : Set M) = span R s := le_antisymm (span_le.mpr closure_subset_span) (span_mono AddSubmonoid.subset_closure) #align submodule.span_closure Submodule.span_closure @[elab_as_elim] theorem span_induction {p : M → Prop} (h : x ∈ span R s) (mem : ∀ x ∈ s, p x) (zero : p 0) (add : ∀ x y, p x → p y → p (x + y)) (smul : ∀ (a : R) (x), p x → p (a • x)) : p x := ((@span_le (p := ⟨⟨⟨p, by intros x y; exact add x y⟩, zero⟩, smul⟩)) s).2 mem h #align submodule.span_induction Submodule.span_induction theorem span_induction₂ {p : M → M → Prop} {a b : M} (ha : a ∈ Submodule.span R s) (hb : b ∈ Submodule.span R s) (mem_mem : ∀ x ∈ s, ∀ y ∈ s, p x y) (zero_left : ∀ y, p 0 y) (zero_right : ∀ x, p x 0) (add_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ + x₂) y) (add_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ + y₂)) (smul_left : ∀ (r : R) x y, p x y → p (r • x) y) (smul_right : ∀ (r : R) x y, p x y → p x (r • y)) : p a b := Submodule.span_induction ha (fun x hx => Submodule.span_induction hb (mem_mem x hx) (zero_right x) (add_right x) fun r => smul_right r x) (zero_left b) (fun x₁ x₂ => add_left x₁ x₂ b) fun r x => smul_left r x b @[elab_as_elim] theorem span_induction' {p : ∀ x, x ∈ span R s → Prop} (mem : ∀ (x) (h : x ∈ s), p x (subset_span h)) (zero : p 0 (Submodule.zero_mem _)) (add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›)) (smul : ∀ (a : R) (x hx), p x hx → p (a • x) (Submodule.smul_mem _ _ ‹_›)) {x} (hx : x ∈ span R s) : p x hx := by refine Exists.elim ?_ fun (hx : x ∈ span R s) (hc : p x hx) => hc refine span_induction hx (fun m hm => ⟨subset_span hm, mem m hm⟩) ⟨zero_mem _, zero⟩ (fun x y hx hy => Exists.elim hx fun hx' hx => Exists.elim hy fun hy' hy => ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩) fun r x hx => Exists.elim hx fun hx' hx => ⟨smul_mem _ _ hx', smul r _ _ hx⟩ #align submodule.span_induction' Submodule.span_induction' open AddSubmonoid in theorem span_eq_closure {s : Set M} : (span R s).toAddSubmonoid = closure (@univ R • s) := by refine le_antisymm (fun x hx ↦ span_induction hx (fun x hx ↦ subset_closure ⟨1, trivial, x, hx, one_smul R x⟩) (zero_mem _) (fun _ _ ↦ add_mem) fun r m hm ↦ closure_induction hm ?_ ?_ fun _ _ h h' ↦ ?_) (closure_le.2 ?_) · rintro _ ⟨r, -, m, hm, rfl⟩; exact smul_mem _ _ (subset_span hm) · rintro _ ⟨r', -, m, hm, rfl⟩; exact subset_closure ⟨r * r', trivial, m, hm, mul_smul r r' m⟩ · rw [smul_zero]; apply zero_mem · rw [smul_add]; exact add_mem h h' @[elab_as_elim] theorem closure_induction {p : M → Prop} (h : x ∈ span R s) (zero : p 0) (add : ∀ x y, p x → p y → p (x + y)) (smul_mem : ∀ r : R, ∀ x ∈ s, p (r • x)) : p x := by rw [← mem_toAddSubmonoid, span_eq_closure] at h refine AddSubmonoid.closure_induction h ?_ zero add rintro _ ⟨r, -, m, hm, rfl⟩ exact smul_mem r m hm @[elab_as_elim] theorem closure_induction' {p : ∀ x, x ∈ span R s → Prop} (zero : p 0 (Submodule.zero_mem _)) (add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›)) (smul_mem : ∀ (r x) (h : x ∈ s), p (r • x) (Submodule.smul_mem _ _ <| subset_span h)) {x} (hx : x ∈ span R s) : p x hx := by refine Exists.elim ?_ fun (hx : x ∈ span R s) (hc : p x hx) ↦ hc refine closure_induction hx ⟨zero_mem _, zero⟩ (fun x y hx hy ↦ Exists.elim hx fun hx' hx ↦ Exists.elim hy fun hy' hy ↦ ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩) fun r x hx ↦ ⟨Submodule.smul_mem _ _ (subset_span hx), smul_mem r x hx⟩ @[simp] theorem span_span_coe_preimage : span R (((↑) : span R s → M) ⁻¹' s) = ⊤ := eq_top_iff.2 fun x ↦ Subtype.recOn x fun x hx _ ↦ by refine span_induction' (p := fun x hx ↦ (⟨x, hx⟩ : span R s) ∈ span R (Subtype.val ⁻¹' s)) (fun x' hx' ↦ subset_span hx') ?_ (fun x _ y _ ↦ ?_) (fun r x _ ↦ ?_) hx · exact zero_mem _ · exact add_mem · exact smul_mem _ _ #align submodule.span_span_coe_preimage Submodule.span_span_coe_preimage @[simp] lemma span_setOf_mem_eq_top : span R {x : span R s | (x : M) ∈ s} = ⊤ := span_span_coe_preimage theorem span_nat_eq_addSubmonoid_closure (s : Set M) : (span ℕ s).toAddSubmonoid = AddSubmonoid.closure s := by refine Eq.symm (AddSubmonoid.closure_eq_of_le subset_span ?_) apply (OrderIso.to_galoisConnection (AddSubmonoid.toNatSubmodule (M := M)).symm).l_le (a := span ℕ s) (b := AddSubmonoid.closure s) rw [span_le] exact AddSubmonoid.subset_closure #align submodule.span_nat_eq_add_submonoid_closure Submodule.span_nat_eq_addSubmonoid_closure @[simp] theorem span_nat_eq (s : AddSubmonoid M) : (span ℕ (s : Set M)).toAddSubmonoid = s := by rw [span_nat_eq_addSubmonoid_closure, s.closure_eq] #align submodule.span_nat_eq Submodule.span_nat_eq theorem span_int_eq_addSubgroup_closure {M : Type*} [AddCommGroup M] (s : Set M) : (span ℤ s).toAddSubgroup = AddSubgroup.closure s := Eq.symm <| AddSubgroup.closure_eq_of_le _ subset_span fun x hx => span_induction hx (fun x hx => AddSubgroup.subset_closure hx) (AddSubgroup.zero_mem _) (fun _ _ => AddSubgroup.add_mem _) fun _ _ _ => AddSubgroup.zsmul_mem _ ‹_› _ #align submodule.span_int_eq_add_subgroup_closure Submodule.span_int_eq_addSubgroup_closure @[simp] theorem span_int_eq {M : Type*} [AddCommGroup M] (s : AddSubgroup M) : (span ℤ (s : Set M)).toAddSubgroup = s := by rw [span_int_eq_addSubgroup_closure, s.closure_eq] #align submodule.span_int_eq Submodule.span_int_eq section variable (R M) protected def gi : GaloisInsertion (@span R M _ _ _) (↑) where choice s _ := span R s gc _ _ := span_le le_l_u _ := subset_span choice_eq _ _ := rfl #align submodule.gi Submodule.gi end @[simp] theorem span_empty : span R (∅ : Set M) = ⊥ := (Submodule.gi R M).gc.l_bot #align submodule.span_empty Submodule.span_empty @[simp] theorem span_univ : span R (univ : Set M) = ⊤ := eq_top_iff.2 <| SetLike.le_def.2 <| subset_span #align submodule.span_univ Submodule.span_univ theorem span_union (s t : Set M) : span R (s ∪ t) = span R s ⊔ span R t := (Submodule.gi R M).gc.l_sup #align submodule.span_union Submodule.span_union theorem span_iUnion {ι} (s : ι → Set M) : span R (⋃ i, s i) = ⨆ i, span R (s i) := (Submodule.gi R M).gc.l_iSup #align submodule.span_Union Submodule.span_iUnion theorem span_iUnion₂ {ι} {κ : ι → Sort*} (s : ∀ i, κ i → Set M) : span R (⋃ (i) (j), s i j) = ⨆ (i) (j), span R (s i j) := (Submodule.gi R M).gc.l_iSup₂ #align submodule.span_Union₂ Submodule.span_iUnion₂ theorem span_attach_biUnion [DecidableEq M] {α : Type*} (s : Finset α) (f : s → Finset M) : span R (s.attach.biUnion f : Set M) = ⨆ x, span R (f x) := by simp [span_iUnion] #align submodule.span_attach_bUnion Submodule.span_attach_biUnion
Mathlib/LinearAlgebra/Span.lean
336
336
theorem sup_span : p ⊔ span R s = span R (p ∪ s) := by
rw [Submodule.span_union, p.span_eq]
import Mathlib.Analysis.Normed.Group.Seminorm import Mathlib.Order.LiminfLimsup import Mathlib.Topology.Instances.Rat import Mathlib.Topology.MetricSpace.Algebra import Mathlib.Topology.MetricSpace.IsometricSMul import Mathlib.Topology.Sequences #align_import analysis.normed.group.basic from "leanprover-community/mathlib"@"41bef4ae1254365bc190aee63b947674d2977f01" variable {𝓕 𝕜 α ι κ E F G : Type*} open Filter Function Metric Bornology open ENNReal Filter NNReal Uniformity Pointwise Topology @[notation_class] class Norm (E : Type*) where norm : E → ℝ #align has_norm Norm @[notation_class] class NNNorm (E : Type*) where nnnorm : E → ℝ≥0 #align has_nnnorm NNNorm export Norm (norm) export NNNorm (nnnorm) @[inherit_doc] notation "‖" e "‖" => norm e @[inherit_doc] notation "‖" e "‖₊" => nnnorm e class SeminormedAddGroup (E : Type*) extends Norm E, AddGroup E, PseudoMetricSpace E where dist := fun x y => ‖x - y‖ dist_eq : ∀ x y, dist x y = ‖x - y‖ := by aesop #align seminormed_add_group SeminormedAddGroup @[to_additive] class SeminormedGroup (E : Type*) extends Norm E, Group E, PseudoMetricSpace E where dist := fun x y => ‖x / y‖ dist_eq : ∀ x y, dist x y = ‖x / y‖ := by aesop #align seminormed_group SeminormedGroup class NormedAddGroup (E : Type*) extends Norm E, AddGroup E, MetricSpace E where dist := fun x y => ‖x - y‖ dist_eq : ∀ x y, dist x y = ‖x - y‖ := by aesop #align normed_add_group NormedAddGroup @[to_additive] class NormedGroup (E : Type*) extends Norm E, Group E, MetricSpace E where dist := fun x y => ‖x / y‖ dist_eq : ∀ x y, dist x y = ‖x / y‖ := by aesop #align normed_group NormedGroup class SeminormedAddCommGroup (E : Type*) extends Norm E, AddCommGroup E, PseudoMetricSpace E where dist := fun x y => ‖x - y‖ dist_eq : ∀ x y, dist x y = ‖x - y‖ := by aesop #align seminormed_add_comm_group SeminormedAddCommGroup @[to_additive] class SeminormedCommGroup (E : Type*) extends Norm E, CommGroup E, PseudoMetricSpace E where dist := fun x y => ‖x / y‖ dist_eq : ∀ x y, dist x y = ‖x / y‖ := by aesop #align seminormed_comm_group SeminormedCommGroup class NormedAddCommGroup (E : Type*) extends Norm E, AddCommGroup E, MetricSpace E where dist := fun x y => ‖x - y‖ dist_eq : ∀ x y, dist x y = ‖x - y‖ := by aesop #align normed_add_comm_group NormedAddCommGroup @[to_additive] class NormedCommGroup (E : Type*) extends Norm E, CommGroup E, MetricSpace E where dist := fun x y => ‖x / y‖ dist_eq : ∀ x y, dist x y = ‖x / y‖ := by aesop #align normed_comm_group NormedCommGroup -- See note [lower instance priority] @[to_additive] instance (priority := 100) NormedGroup.toSeminormedGroup [NormedGroup E] : SeminormedGroup E := { ‹NormedGroup E› with } #align normed_group.to_seminormed_group NormedGroup.toSeminormedGroup #align normed_add_group.to_seminormed_add_group NormedAddGroup.toSeminormedAddGroup -- See note [lower instance priority] @[to_additive] instance (priority := 100) NormedCommGroup.toSeminormedCommGroup [NormedCommGroup E] : SeminormedCommGroup E := { ‹NormedCommGroup E› with } #align normed_comm_group.to_seminormed_comm_group NormedCommGroup.toSeminormedCommGroup #align normed_add_comm_group.to_seminormed_add_comm_group NormedAddCommGroup.toSeminormedAddCommGroup -- See note [lower instance priority] @[to_additive] instance (priority := 100) SeminormedCommGroup.toSeminormedGroup [SeminormedCommGroup E] : SeminormedGroup E := { ‹SeminormedCommGroup E› with } #align seminormed_comm_group.to_seminormed_group SeminormedCommGroup.toSeminormedGroup #align seminormed_add_comm_group.to_seminormed_add_group SeminormedAddCommGroup.toSeminormedAddGroup -- See note [lower instance priority] @[to_additive] instance (priority := 100) NormedCommGroup.toNormedGroup [NormedCommGroup E] : NormedGroup E := { ‹NormedCommGroup E› with } #align normed_comm_group.to_normed_group NormedCommGroup.toNormedGroup #align normed_add_comm_group.to_normed_add_group NormedAddCommGroup.toNormedAddGroup -- See note [reducible non-instances] @[to_additive (attr := reducible) "Construct a `NormedAddGroup` from a `SeminormedAddGroup` satisfying `∀ x, ‖x‖ = 0 → x = 0`. This avoids having to go back to the `(Pseudo)MetricSpace` level when declaring a `NormedAddGroup` instance as a special case of a more general `SeminormedAddGroup` instance."] def NormedGroup.ofSeparation [SeminormedGroup E] (h : ∀ x : E, ‖x‖ = 0 → x = 1) : NormedGroup E where dist_eq := ‹SeminormedGroup E›.dist_eq toMetricSpace := { eq_of_dist_eq_zero := fun hxy => div_eq_one.1 <| h _ <| by exact (‹SeminormedGroup E›.dist_eq _ _).symm.trans hxy } -- Porting note: the `rwa` no longer worked, but it was easy enough to provide the term. -- however, notice that if you make `x` and `y` accessible, then the following does work: -- `have := ‹SeminormedGroup E›.dist_eq x y; rwa [← this]`, so I'm not sure why the `rwa` -- was broken. #align normed_group.of_separation NormedGroup.ofSeparation #align normed_add_group.of_separation NormedAddGroup.ofSeparation -- See note [reducible non-instances] @[to_additive (attr := reducible) "Construct a `NormedAddCommGroup` from a `SeminormedAddCommGroup` satisfying `∀ x, ‖x‖ = 0 → x = 0`. This avoids having to go back to the `(Pseudo)MetricSpace` level when declaring a `NormedAddCommGroup` instance as a special case of a more general `SeminormedAddCommGroup` instance."] def NormedCommGroup.ofSeparation [SeminormedCommGroup E] (h : ∀ x : E, ‖x‖ = 0 → x = 1) : NormedCommGroup E := { ‹SeminormedCommGroup E›, NormedGroup.ofSeparation h with } #align normed_comm_group.of_separation NormedCommGroup.ofSeparation #align normed_add_comm_group.of_separation NormedAddCommGroup.ofSeparation -- See note [reducible non-instances] @[to_additive (attr := reducible) "Construct a seminormed group from a translation-invariant distance."] def SeminormedGroup.ofMulDist [Norm E] [Group E] [PseudoMetricSpace E] (h₁ : ∀ x : E, ‖x‖ = dist x 1) (h₂ : ∀ x y z : E, dist x y ≤ dist (x * z) (y * z)) : SeminormedGroup E where dist_eq x y := by rw [h₁]; apply le_antisymm · simpa only [div_eq_mul_inv, ← mul_right_inv y] using h₂ _ _ _ · simpa only [div_mul_cancel, one_mul] using h₂ (x / y) 1 y #align seminormed_group.of_mul_dist SeminormedGroup.ofMulDist #align seminormed_add_group.of_add_dist SeminormedAddGroup.ofAddDist -- See note [reducible non-instances] @[to_additive (attr := reducible) "Construct a seminormed group from a translation-invariant pseudodistance."] def SeminormedGroup.ofMulDist' [Norm E] [Group E] [PseudoMetricSpace E] (h₁ : ∀ x : E, ‖x‖ = dist x 1) (h₂ : ∀ x y z : E, dist (x * z) (y * z) ≤ dist x y) : SeminormedGroup E where dist_eq x y := by rw [h₁]; apply le_antisymm · simpa only [div_mul_cancel, one_mul] using h₂ (x / y) 1 y · simpa only [div_eq_mul_inv, ← mul_right_inv y] using h₂ _ _ _ #align seminormed_group.of_mul_dist' SeminormedGroup.ofMulDist' #align seminormed_add_group.of_add_dist' SeminormedAddGroup.ofAddDist' -- See note [reducible non-instances] @[to_additive (attr := reducible) "Construct a seminormed group from a translation-invariant pseudodistance."] def SeminormedCommGroup.ofMulDist [Norm E] [CommGroup E] [PseudoMetricSpace E] (h₁ : ∀ x : E, ‖x‖ = dist x 1) (h₂ : ∀ x y z : E, dist x y ≤ dist (x * z) (y * z)) : SeminormedCommGroup E := { SeminormedGroup.ofMulDist h₁ h₂ with mul_comm := mul_comm } #align seminormed_comm_group.of_mul_dist SeminormedCommGroup.ofMulDist #align seminormed_add_comm_group.of_add_dist SeminormedAddCommGroup.ofAddDist -- See note [reducible non-instances] @[to_additive (attr := reducible) "Construct a seminormed group from a translation-invariant pseudodistance."] def SeminormedCommGroup.ofMulDist' [Norm E] [CommGroup E] [PseudoMetricSpace E] (h₁ : ∀ x : E, ‖x‖ = dist x 1) (h₂ : ∀ x y z : E, dist (x * z) (y * z) ≤ dist x y) : SeminormedCommGroup E := { SeminormedGroup.ofMulDist' h₁ h₂ with mul_comm := mul_comm } #align seminormed_comm_group.of_mul_dist' SeminormedCommGroup.ofMulDist' #align seminormed_add_comm_group.of_add_dist' SeminormedAddCommGroup.ofAddDist' -- See note [reducible non-instances] @[to_additive (attr := reducible) "Construct a normed group from a translation-invariant distance."] def NormedGroup.ofMulDist [Norm E] [Group E] [MetricSpace E] (h₁ : ∀ x : E, ‖x‖ = dist x 1) (h₂ : ∀ x y z : E, dist x y ≤ dist (x * z) (y * z)) : NormedGroup E := { SeminormedGroup.ofMulDist h₁ h₂ with eq_of_dist_eq_zero := eq_of_dist_eq_zero } #align normed_group.of_mul_dist NormedGroup.ofMulDist #align normed_add_group.of_add_dist NormedAddGroup.ofAddDist -- See note [reducible non-instances] @[to_additive (attr := reducible) "Construct a normed group from a translation-invariant pseudodistance."] def NormedGroup.ofMulDist' [Norm E] [Group E] [MetricSpace E] (h₁ : ∀ x : E, ‖x‖ = dist x 1) (h₂ : ∀ x y z : E, dist (x * z) (y * z) ≤ dist x y) : NormedGroup E := { SeminormedGroup.ofMulDist' h₁ h₂ with eq_of_dist_eq_zero := eq_of_dist_eq_zero } #align normed_group.of_mul_dist' NormedGroup.ofMulDist' #align normed_add_group.of_add_dist' NormedAddGroup.ofAddDist' -- See note [reducible non-instances] @[to_additive (attr := reducible) "Construct a normed group from a translation-invariant pseudodistance."] def NormedCommGroup.ofMulDist [Norm E] [CommGroup E] [MetricSpace E] (h₁ : ∀ x : E, ‖x‖ = dist x 1) (h₂ : ∀ x y z : E, dist x y ≤ dist (x * z) (y * z)) : NormedCommGroup E := { NormedGroup.ofMulDist h₁ h₂ with mul_comm := mul_comm } #align normed_comm_group.of_mul_dist NormedCommGroup.ofMulDist #align normed_add_comm_group.of_add_dist NormedAddCommGroup.ofAddDist -- See note [reducible non-instances] @[to_additive (attr := reducible) "Construct a normed group from a translation-invariant pseudodistance."] def NormedCommGroup.ofMulDist' [Norm E] [CommGroup E] [MetricSpace E] (h₁ : ∀ x : E, ‖x‖ = dist x 1) (h₂ : ∀ x y z : E, dist (x * z) (y * z) ≤ dist x y) : NormedCommGroup E := { NormedGroup.ofMulDist' h₁ h₂ with mul_comm := mul_comm } #align normed_comm_group.of_mul_dist' NormedCommGroup.ofMulDist' #align normed_add_comm_group.of_add_dist' NormedAddCommGroup.ofAddDist' -- See note [reducible non-instances] @[to_additive (attr := reducible) "Construct a seminormed group from a seminorm, i.e., registering the pseudodistance and the pseudometric space structure from the seminorm properties. Note that in most cases this instance creates bad definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on `E`)."] def GroupSeminorm.toSeminormedGroup [Group E] (f : GroupSeminorm E) : SeminormedGroup E where dist x y := f (x / y) norm := f dist_eq x y := rfl dist_self x := by simp only [div_self', map_one_eq_zero] dist_triangle := le_map_div_add_map_div f dist_comm := map_div_rev f edist_dist x y := by exact ENNReal.coe_nnreal_eq _ -- Porting note: how did `mathlib3` solve this automatically? #align group_seminorm.to_seminormed_group GroupSeminorm.toSeminormedGroup #align add_group_seminorm.to_seminormed_add_group AddGroupSeminorm.toSeminormedAddGroup -- See note [reducible non-instances] @[to_additive (attr := reducible) "Construct a seminormed group from a seminorm, i.e., registering the pseudodistance and the pseudometric space structure from the seminorm properties. Note that in most cases this instance creates bad definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on `E`)."] def GroupSeminorm.toSeminormedCommGroup [CommGroup E] (f : GroupSeminorm E) : SeminormedCommGroup E := { f.toSeminormedGroup with mul_comm := mul_comm } #align group_seminorm.to_seminormed_comm_group GroupSeminorm.toSeminormedCommGroup #align add_group_seminorm.to_seminormed_add_comm_group AddGroupSeminorm.toSeminormedAddCommGroup -- See note [reducible non-instances] @[to_additive (attr := reducible) "Construct a normed group from a norm, i.e., registering the distance and the metric space structure from the norm properties. Note that in most cases this instance creates bad definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on `E`)."] def GroupNorm.toNormedGroup [Group E] (f : GroupNorm E) : NormedGroup E := { f.toGroupSeminorm.toSeminormedGroup with eq_of_dist_eq_zero := fun h => div_eq_one.1 <| eq_one_of_map_eq_zero f h } #align group_norm.to_normed_group GroupNorm.toNormedGroup #align add_group_norm.to_normed_add_group AddGroupNorm.toNormedAddGroup -- See note [reducible non-instances] @[to_additive (attr := reducible) "Construct a normed group from a norm, i.e., registering the distance and the metric space structure from the norm properties. Note that in most cases this instance creates bad definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on `E`)."] def GroupNorm.toNormedCommGroup [CommGroup E] (f : GroupNorm E) : NormedCommGroup E := { f.toNormedGroup with mul_comm := mul_comm } #align group_norm.to_normed_comm_group GroupNorm.toNormedCommGroup #align add_group_norm.to_normed_add_comm_group AddGroupNorm.toNormedAddCommGroup instance PUnit.normedAddCommGroup : NormedAddCommGroup PUnit where norm := Function.const _ 0 dist_eq _ _ := rfl @[simp] theorem PUnit.norm_eq_zero (r : PUnit) : ‖r‖ = 0 := rfl #align punit.norm_eq_zero PUnit.norm_eq_zero section SeminormedGroup variable [SeminormedGroup E] [SeminormedGroup F] [SeminormedGroup G] {s : Set E} {a a₁ a₂ b b₁ b₂ : E} {r r₁ r₂ : ℝ} @[to_additive] theorem dist_eq_norm_div (a b : E) : dist a b = ‖a / b‖ := SeminormedGroup.dist_eq _ _ #align dist_eq_norm_div dist_eq_norm_div #align dist_eq_norm_sub dist_eq_norm_sub @[to_additive]
Mathlib/Analysis/Normed/Group/Basic.lean
407
407
theorem dist_eq_norm_div' (a b : E) : dist a b = ‖b / a‖ := by
rw [dist_comm, dist_eq_norm_div]
import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Basic import Mathlib.RingTheory.Ideal.Maps import Mathlib.RingTheory.MvPowerSeries.Basic #align_import ring_theory.power_series.basic from "leanprover-community/mathlib"@"2d5739b61641ee4e7e53eca5688a08f66f2e6a60" noncomputable section open Finset (antidiagonal mem_antidiagonal) def PowerSeries (R : Type*) := MvPowerSeries Unit R #align power_series PowerSeries namespace PowerSeries open Finsupp (single) variable {R : Type*} section -- Porting note: not available in Lean 4 -- local reducible PowerSeries scoped notation:9000 R "⟦X⟧" => PowerSeries R instance [Inhabited R] : Inhabited R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [Zero R] : Zero R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [AddMonoid R] : AddMonoid R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [AddGroup R] : AddGroup R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [AddCommMonoid R] : AddCommMonoid R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [AddCommGroup R] : AddCommGroup R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [Semiring R] : Semiring R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [CommSemiring R] : CommSemiring R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [Ring R] : Ring R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [CommRing R] : CommRing R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance [Nontrivial R] : Nontrivial R⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance {A} [Semiring R] [AddCommMonoid A] [Module R A] : Module R A⟦X⟧ := by dsimp only [PowerSeries] infer_instance instance {A S} [Semiring R] [Semiring S] [AddCommMonoid A] [Module R A] [Module S A] [SMul R S] [IsScalarTower R S A] : IsScalarTower R S A⟦X⟧ := Pi.isScalarTower instance {A} [Semiring A] [CommSemiring R] [Algebra R A] : Algebra R A⟦X⟧ := by dsimp only [PowerSeries] infer_instance end section Semiring variable (R) [Semiring R] def coeff (n : ℕ) : R⟦X⟧ →ₗ[R] R := MvPowerSeries.coeff R (single () n) #align power_series.coeff PowerSeries.coeff def monomial (n : ℕ) : R →ₗ[R] R⟦X⟧ := MvPowerSeries.monomial R (single () n) #align power_series.monomial PowerSeries.monomial variable {R} theorem coeff_def {s : Unit →₀ ℕ} {n : ℕ} (h : s () = n) : coeff R n = MvPowerSeries.coeff R s := by erw [coeff, ← h, ← Finsupp.unique_single s] #align power_series.coeff_def PowerSeries.coeff_def @[ext] theorem ext {φ ψ : R⟦X⟧} (h : ∀ n, coeff R n φ = coeff R n ψ) : φ = ψ := MvPowerSeries.ext fun n => by rw [← coeff_def] · apply h rfl #align power_series.ext PowerSeries.ext theorem ext_iff {φ ψ : R⟦X⟧} : φ = ψ ↔ ∀ n, coeff R n φ = coeff R n ψ := ⟨fun h n => congr_arg (coeff R n) h, ext⟩ #align power_series.ext_iff PowerSeries.ext_iff instance [Subsingleton R] : Subsingleton R⟦X⟧ := by simp only [subsingleton_iff, ext_iff] exact fun _ _ _ ↦ (subsingleton_iff).mp (by infer_instance) _ _ def mk {R} (f : ℕ → R) : R⟦X⟧ := fun s => f (s ()) #align power_series.mk PowerSeries.mk @[simp] theorem coeff_mk (n : ℕ) (f : ℕ → R) : coeff R n (mk f) = f n := congr_arg f Finsupp.single_eq_same #align power_series.coeff_mk PowerSeries.coeff_mk theorem coeff_monomial (m n : ℕ) (a : R) : coeff R m (monomial R n a) = if m = n then a else 0 := calc coeff R m (monomial R n a) = _ := MvPowerSeries.coeff_monomial _ _ _ _ = if m = n then a else 0 := by simp only [Finsupp.unique_single_eq_iff] #align power_series.coeff_monomial PowerSeries.coeff_monomial theorem monomial_eq_mk (n : ℕ) (a : R) : monomial R n a = mk fun m => if m = n then a else 0 := ext fun m => by rw [coeff_monomial, coeff_mk] #align power_series.monomial_eq_mk PowerSeries.monomial_eq_mk @[simp] theorem coeff_monomial_same (n : ℕ) (a : R) : coeff R n (monomial R n a) = a := MvPowerSeries.coeff_monomial_same _ _ #align power_series.coeff_monomial_same PowerSeries.coeff_monomial_same @[simp] theorem coeff_comp_monomial (n : ℕ) : (coeff R n).comp (monomial R n) = LinearMap.id := LinearMap.ext <| coeff_monomial_same n #align power_series.coeff_comp_monomial PowerSeries.coeff_comp_monomial variable (R) def constantCoeff : R⟦X⟧ →+* R := MvPowerSeries.constantCoeff Unit R #align power_series.constant_coeff PowerSeries.constantCoeff def C : R →+* R⟦X⟧ := MvPowerSeries.C Unit R set_option linter.uppercaseLean3 false in #align power_series.C PowerSeries.C variable {R} def X : R⟦X⟧ := MvPowerSeries.X () set_option linter.uppercaseLean3 false in #align power_series.X PowerSeries.X theorem commute_X (φ : R⟦X⟧) : Commute φ X := MvPowerSeries.commute_X _ _ set_option linter.uppercaseLean3 false in #align power_series.commute_X PowerSeries.commute_X @[simp] theorem coeff_zero_eq_constantCoeff : ⇑(coeff R 0) = constantCoeff R := by rw [coeff, Finsupp.single_zero] rfl #align power_series.coeff_zero_eq_constant_coeff PowerSeries.coeff_zero_eq_constantCoeff theorem coeff_zero_eq_constantCoeff_apply (φ : R⟦X⟧) : coeff R 0 φ = constantCoeff R φ := by rw [coeff_zero_eq_constantCoeff] #align power_series.coeff_zero_eq_constant_coeff_apply PowerSeries.coeff_zero_eq_constantCoeff_apply @[simp]
Mathlib/RingTheory/PowerSeries/Basic.lean
239
241
theorem monomial_zero_eq_C : ⇑(monomial R 0) = C R := by
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [monomial, Finsupp.single_zero, MvPowerSeries.monomial_zero_eq_C]
import Mathlib.Topology.ExtendFrom import Mathlib.Topology.Order.DenselyOrdered #align_import topology.algebra.order.extend_from from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977" set_option autoImplicit true open Filter Set TopologicalSpace open scoped Classical open Topology
Mathlib/Topology/Order/ExtendFrom.lean
23
33
theorem continuousOn_Icc_extendFrom_Ioo [TopologicalSpace α] [LinearOrder α] [DenselyOrdered α] [OrderTopology α] [TopologicalSpace β] [RegularSpace β] {f : α → β} {a b : α} {la lb : β} (hab : a ≠ b) (hf : ContinuousOn f (Ioo a b)) (ha : Tendsto f (𝓝[>] a) (𝓝 la)) (hb : Tendsto f (𝓝[<] b) (𝓝 lb)) : ContinuousOn (extendFrom (Ioo a b) f) (Icc a b) := by
apply continuousOn_extendFrom · rw [closure_Ioo hab] · intro x x_in rcases eq_endpoints_or_mem_Ioo_of_mem_Icc x_in with (rfl | rfl | h) · exact ⟨la, ha.mono_left <| nhdsWithin_mono _ Ioo_subset_Ioi_self⟩ · exact ⟨lb, hb.mono_left <| nhdsWithin_mono _ Ioo_subset_Iio_self⟩ · exact ⟨f x, hf x h⟩
import Mathlib.Algebra.Order.Pointwise import Mathlib.Analysis.NormedSpace.SphereNormEquiv import Mathlib.Analysis.SpecialFunctions.Integrals import Mathlib.MeasureTheory.Constructions.Prod.Integral import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar open Set Function Metric MeasurableSpace intervalIntegral open scoped Pointwise ENNReal NNReal local notation "dim" => FiniteDimensional.finrank ℝ noncomputable section namespace MeasureTheory variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] namespace Measure def toSphere (μ : Measure E) : Measure (sphere (0 : E) 1) := dim E • ((μ.comap (Subtype.val ∘ (homeomorphUnitSphereProd E).symm)).restrict (univ ×ˢ Iio ⟨1, mem_Ioi.2 one_pos⟩)).fst variable (μ : Measure E) theorem toSphere_apply_aux (s : Set (sphere (0 : E) 1)) (r : Ioi (0 : ℝ)) : μ ((↑) '' (homeomorphUnitSphereProd E ⁻¹' s ×ˢ Iio r)) = μ (Ioo (0 : ℝ) r • ((↑) '' s)) := by rw [← image2_smul, image2_image_right, ← Homeomorph.image_symm, image_image, ← image_subtype_val_Ioi_Iio, image2_image_left, image2_swap, ← image_prod] rfl theorem toSphere_apply' {s : Set (sphere (0 : E) 1)} (hs : MeasurableSet s) : μ.toSphere s = dim E * μ (Ioo (0 : ℝ) 1 • ((↑) '' s)) := by rw [toSphere, smul_apply, fst_apply hs, restrict_apply (measurable_fst hs), ((MeasurableEmbedding.subtype_coe (measurableSet_singleton _).compl).comp (Homeomorph.measurableEmbedding _)).comap_apply, image_comp, Homeomorph.image_symm, univ_prod, ← Set.prod_eq, nsmul_eq_mul, toSphere_apply_aux]
Mathlib/MeasureTheory/Constructions/HaarToSphere.lean
62
63
theorem toSphere_apply_univ' : μ.toSphere univ = dim E * μ (ball 0 1 \ {0}) := by
rw [μ.toSphere_apply' .univ, image_univ, Subtype.range_coe, Ioo_smul_sphere_zero] <;> simp
import Mathlib.Data.Complex.Module import Mathlib.Data.Complex.Order import Mathlib.Data.Complex.Exponential import Mathlib.Analysis.RCLike.Basic import Mathlib.Topology.Algebra.InfiniteSum.Module import Mathlib.Topology.Instances.RealVectorSpace #align_import analysis.complex.basic from "leanprover-community/mathlib"@"3f655f5297b030a87d641ad4e825af8d9679eb0b" assert_not_exists Absorbs noncomputable section namespace Complex variable {z : ℂ} open ComplexConjugate Topology Filter instance : Norm ℂ := ⟨abs⟩ @[simp] theorem norm_eq_abs (z : ℂ) : ‖z‖ = abs z := rfl #align complex.norm_eq_abs Complex.norm_eq_abs lemma norm_I : ‖I‖ = 1 := abs_I
Mathlib/Analysis/Complex/Basic.lean
58
59
theorem norm_exp_ofReal_mul_I (t : ℝ) : ‖exp (t * I)‖ = 1 := by
simp only [norm_eq_abs, abs_exp_ofReal_mul_I]
import Mathlib.CategoryTheory.Subobject.MonoOver import Mathlib.CategoryTheory.Skeletal import Mathlib.CategoryTheory.ConcreteCategory.Basic import Mathlib.Tactic.ApplyFun import Mathlib.Tactic.CategoryTheory.Elementwise #align_import category_theory.subobject.basic from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe v₁ v₂ u₁ u₂ noncomputable section namespace CategoryTheory open CategoryTheory CategoryTheory.Category CategoryTheory.Limits variable {C : Type u₁} [Category.{v₁} C] {X Y Z : C} variable {D : Type u₂} [Category.{v₂} D] def Subobject (X : C) := ThinSkeleton (MonoOver X) #align category_theory.subobject CategoryTheory.Subobject instance (X : C) : PartialOrder (Subobject X) := by dsimp only [Subobject] infer_instance namespace Subobject -- Porting note: made it a def rather than an abbreviation -- because Lean would make it too transparent def mk {X A : C} (f : A ⟶ X) [Mono f] : Subobject X := (toThinSkeleton _).obj (MonoOver.mk' f) #align category_theory.subobject.mk CategoryTheory.Subobject.mk section attribute [local ext] CategoryTheory.Comma protected theorem ind {X : C} (p : Subobject X → Prop) (h : ∀ ⦃A : C⦄ (f : A ⟶ X) [Mono f], p (Subobject.mk f)) (P : Subobject X) : p P := by apply Quotient.inductionOn' intro a exact h a.arrow #align category_theory.subobject.ind CategoryTheory.Subobject.ind protected theorem ind₂ {X : C} (p : Subobject X → Subobject X → Prop) (h : ∀ ⦃A B : C⦄ (f : A ⟶ X) (g : B ⟶ X) [Mono f] [Mono g], p (Subobject.mk f) (Subobject.mk g)) (P Q : Subobject X) : p P Q := by apply Quotient.inductionOn₂' intro a b exact h a.arrow b.arrow #align category_theory.subobject.ind₂ CategoryTheory.Subobject.ind₂ end protected def lift {α : Sort*} {X : C} (F : ∀ ⦃A : C⦄ (f : A ⟶ X) [Mono f], α) (h : ∀ ⦃A B : C⦄ (f : A ⟶ X) (g : B ⟶ X) [Mono f] [Mono g] (i : A ≅ B), i.hom ≫ g = f → F f = F g) : Subobject X → α := fun P => Quotient.liftOn' P (fun m => F m.arrow) fun m n ⟨i⟩ => h m.arrow n.arrow ((MonoOver.forget X ⋙ Over.forget X).mapIso i) (Over.w i.hom) #align category_theory.subobject.lift CategoryTheory.Subobject.lift @[simp] protected theorem lift_mk {α : Sort*} {X : C} (F : ∀ ⦃A : C⦄ (f : A ⟶ X) [Mono f], α) {h A} (f : A ⟶ X) [Mono f] : Subobject.lift F h (Subobject.mk f) = F f := rfl #align category_theory.subobject.lift_mk CategoryTheory.Subobject.lift_mk noncomputable def equivMonoOver (X : C) : Subobject X ≌ MonoOver X := ThinSkeleton.equivalence _ #align category_theory.subobject.equiv_mono_over CategoryTheory.Subobject.equivMonoOver noncomputable def representative {X : C} : Subobject X ⥤ MonoOver X := (equivMonoOver X).functor #align category_theory.subobject.representative CategoryTheory.Subobject.representative noncomputable def representativeIso {X : C} (A : MonoOver X) : representative.obj ((toThinSkeleton _).obj A) ≅ A := (equivMonoOver X).counitIso.app A #align category_theory.subobject.representative_iso CategoryTheory.Subobject.representativeIso noncomputable def underlying {X : C} : Subobject X ⥤ C := representative ⋙ MonoOver.forget _ ⋙ Over.forget _ #align category_theory.subobject.underlying CategoryTheory.Subobject.underlying instance : CoeOut (Subobject X) C where coe Y := underlying.obj Y -- Porting note: removed as it has become a syntactic tautology -- @[simp] -- theorem underlying_as_coe {X : C} (P : Subobject X) : underlying.obj P = P := -- rfl -- #align category_theory.subobject.underlying_as_coe CategoryTheory.Subobject.underlying_as_coe noncomputable def underlyingIso {X Y : C} (f : X ⟶ Y) [Mono f] : (Subobject.mk f : C) ≅ X := (MonoOver.forget _ ⋙ Over.forget _).mapIso (representativeIso (MonoOver.mk' f)) #align category_theory.subobject.underlying_iso CategoryTheory.Subobject.underlyingIso noncomputable def arrow {X : C} (Y : Subobject X) : (Y : C) ⟶ X := (representative.obj Y).obj.hom #align category_theory.subobject.arrow CategoryTheory.Subobject.arrow instance arrow_mono {X : C} (Y : Subobject X) : Mono Y.arrow := (representative.obj Y).property #align category_theory.subobject.arrow_mono CategoryTheory.Subobject.arrow_mono @[simp] theorem arrow_congr {A : C} (X Y : Subobject A) (h : X = Y) : eqToHom (congr_arg (fun X : Subobject A => (X : C)) h) ≫ Y.arrow = X.arrow := by induction h simp #align category_theory.subobject.arrow_congr CategoryTheory.Subobject.arrow_congr @[simp] theorem representative_coe (Y : Subobject X) : (representative.obj Y : C) = (Y : C) := rfl #align category_theory.subobject.representative_coe CategoryTheory.Subobject.representative_coe @[simp] theorem representative_arrow (Y : Subobject X) : (representative.obj Y).arrow = Y.arrow := rfl #align category_theory.subobject.representative_arrow CategoryTheory.Subobject.representative_arrow @[reassoc (attr := simp)] theorem underlying_arrow {X : C} {Y Z : Subobject X} (f : Y ⟶ Z) : underlying.map f ≫ arrow Z = arrow Y := Over.w (representative.map f) #align category_theory.subobject.underlying_arrow CategoryTheory.Subobject.underlying_arrow @[reassoc (attr := simp), elementwise (attr := simp)] theorem underlyingIso_arrow {X Y : C} (f : X ⟶ Y) [Mono f] : (underlyingIso f).inv ≫ (Subobject.mk f).arrow = f := Over.w _ #align category_theory.subobject.underlying_iso_arrow CategoryTheory.Subobject.underlyingIso_arrow @[reassoc (attr := simp)] theorem underlyingIso_hom_comp_eq_mk {X Y : C} (f : X ⟶ Y) [Mono f] : (underlyingIso f).hom ≫ f = (mk f).arrow := (Iso.eq_inv_comp _).1 (underlyingIso_arrow f).symm #align category_theory.subobject.underlying_iso_hom_comp_eq_mk CategoryTheory.Subobject.underlyingIso_hom_comp_eq_mk @[ext] theorem eq_of_comp_arrow_eq {X Y : C} {P : Subobject Y} {f g : X ⟶ P} (h : f ≫ P.arrow = g ≫ P.arrow) : f = g := (cancel_mono P.arrow).mp h #align category_theory.subobject.eq_of_comp_arrow_eq CategoryTheory.Subobject.eq_of_comp_arrow_eq theorem mk_le_mk_of_comm {B A₁ A₂ : C} {f₁ : A₁ ⟶ B} {f₂ : A₂ ⟶ B} [Mono f₁] [Mono f₂] (g : A₁ ⟶ A₂) (w : g ≫ f₂ = f₁) : mk f₁ ≤ mk f₂ := ⟨MonoOver.homMk _ w⟩ #align category_theory.subobject.mk_le_mk_of_comm CategoryTheory.Subobject.mk_le_mk_of_comm @[simp] theorem mk_arrow (P : Subobject X) : mk P.arrow = P := Quotient.inductionOn' P fun Q => by obtain ⟨e⟩ := @Quotient.mk_out' _ (isIsomorphicSetoid _) Q exact Quotient.sound' ⟨MonoOver.isoMk (Iso.refl _) ≪≫ e⟩ #align category_theory.subobject.mk_arrow CategoryTheory.Subobject.mk_arrow theorem le_of_comm {B : C} {X Y : Subobject B} (f : (X : C) ⟶ (Y : C)) (w : f ≫ Y.arrow = X.arrow) : X ≤ Y := by convert mk_le_mk_of_comm _ w <;> simp #align category_theory.subobject.le_of_comm CategoryTheory.Subobject.le_of_comm theorem le_mk_of_comm {B A : C} {X : Subobject B} {f : A ⟶ B} [Mono f] (g : (X : C) ⟶ A) (w : g ≫ f = X.arrow) : X ≤ mk f := le_of_comm (g ≫ (underlyingIso f).inv) <| by simp [w] #align category_theory.subobject.le_mk_of_comm CategoryTheory.Subobject.le_mk_of_comm theorem mk_le_of_comm {B A : C} {X : Subobject B} {f : A ⟶ B} [Mono f] (g : A ⟶ (X : C)) (w : g ≫ X.arrow = f) : mk f ≤ X := le_of_comm ((underlyingIso f).hom ≫ g) <| by simp [w] #align category_theory.subobject.mk_le_of_comm CategoryTheory.Subobject.mk_le_of_comm @[ext] theorem eq_of_comm {B : C} {X Y : Subobject B} (f : (X : C) ≅ (Y : C)) (w : f.hom ≫ Y.arrow = X.arrow) : X = Y := le_antisymm (le_of_comm f.hom w) <| le_of_comm f.inv <| f.inv_comp_eq.2 w.symm #align category_theory.subobject.eq_of_comm CategoryTheory.Subobject.eq_of_comm -- Porting note (#11182): removed @[ext] theorem eq_mk_of_comm {B A : C} {X : Subobject B} (f : A ⟶ B) [Mono f] (i : (X : C) ≅ A) (w : i.hom ≫ f = X.arrow) : X = mk f := eq_of_comm (i.trans (underlyingIso f).symm) <| by simp [w] #align category_theory.subobject.eq_mk_of_comm CategoryTheory.Subobject.eq_mk_of_comm -- Porting note (#11182): removed @[ext] theorem mk_eq_of_comm {B A : C} {X : Subobject B} (f : A ⟶ B) [Mono f] (i : A ≅ (X : C)) (w : i.hom ≫ X.arrow = f) : mk f = X := Eq.symm <| eq_mk_of_comm _ i.symm <| by rw [Iso.symm_hom, Iso.inv_comp_eq, w] #align category_theory.subobject.mk_eq_of_comm CategoryTheory.Subobject.mk_eq_of_comm -- Porting note (#11182): removed @[ext] theorem mk_eq_mk_of_comm {B A₁ A₂ : C} (f : A₁ ⟶ B) (g : A₂ ⟶ B) [Mono f] [Mono g] (i : A₁ ≅ A₂) (w : i.hom ≫ g = f) : mk f = mk g := eq_mk_of_comm _ ((underlyingIso f).trans i) <| by simp [w] #align category_theory.subobject.mk_eq_mk_of_comm CategoryTheory.Subobject.mk_eq_mk_of_comm -- We make `X` and `Y` explicit arguments here so that when `ofLE` appears in goal statements -- it is possible to see its source and target -- (`h` will just display as `_`, because it is in `Prop`). def ofLE {B : C} (X Y : Subobject B) (h : X ≤ Y) : (X : C) ⟶ (Y : C) := underlying.map <| h.hom #align category_theory.subobject.of_le CategoryTheory.Subobject.ofLE @[reassoc (attr := simp)] theorem ofLE_arrow {B : C} {X Y : Subobject B} (h : X ≤ Y) : ofLE X Y h ≫ Y.arrow = X.arrow := underlying_arrow _ #align category_theory.subobject.of_le_arrow CategoryTheory.Subobject.ofLE_arrow instance {B : C} (X Y : Subobject B) (h : X ≤ Y) : Mono (ofLE X Y h) := by fconstructor intro Z f g w replace w := w =≫ Y.arrow ext simpa using w theorem ofLE_mk_le_mk_of_comm {B A₁ A₂ : C} {f₁ : A₁ ⟶ B} {f₂ : A₂ ⟶ B} [Mono f₁] [Mono f₂] (g : A₁ ⟶ A₂) (w : g ≫ f₂ = f₁) : ofLE _ _ (mk_le_mk_of_comm g w) = (underlyingIso _).hom ≫ g ≫ (underlyingIso _).inv := by ext simp [w] #align category_theory.subobject.of_le_mk_le_mk_of_comm CategoryTheory.Subobject.ofLE_mk_le_mk_of_comm def ofLEMk {B A : C} (X : Subobject B) (f : A ⟶ B) [Mono f] (h : X ≤ mk f) : (X : C) ⟶ A := ofLE X (mk f) h ≫ (underlyingIso f).hom #align category_theory.subobject.of_le_mk CategoryTheory.Subobject.ofLEMk instance {B A : C} (X : Subobject B) (f : A ⟶ B) [Mono f] (h : X ≤ mk f) : Mono (ofLEMk X f h) := by dsimp only [ofLEMk] infer_instance @[simp] theorem ofLEMk_comp {B A : C} {X : Subobject B} {f : A ⟶ B} [Mono f] (h : X ≤ mk f) : ofLEMk X f h ≫ f = X.arrow := by simp [ofLEMk] #align category_theory.subobject.of_le_mk_comp CategoryTheory.Subobject.ofLEMk_comp def ofMkLE {B A : C} (f : A ⟶ B) [Mono f] (X : Subobject B) (h : mk f ≤ X) : A ⟶ (X : C) := (underlyingIso f).inv ≫ ofLE (mk f) X h #align category_theory.subobject.of_mk_le CategoryTheory.Subobject.ofMkLE instance {B A : C} (f : A ⟶ B) [Mono f] (X : Subobject B) (h : mk f ≤ X) : Mono (ofMkLE f X h) := by dsimp only [ofMkLE] infer_instance @[simp] theorem ofMkLE_arrow {B A : C} {f : A ⟶ B} [Mono f] {X : Subobject B} (h : mk f ≤ X) : ofMkLE f X h ≫ X.arrow = f := by simp [ofMkLE] #align category_theory.subobject.of_mk_le_arrow CategoryTheory.Subobject.ofMkLE_arrow def ofMkLEMk {B A₁ A₂ : C} (f : A₁ ⟶ B) (g : A₂ ⟶ B) [Mono f] [Mono g] (h : mk f ≤ mk g) : A₁ ⟶ A₂ := (underlyingIso f).inv ≫ ofLE (mk f) (mk g) h ≫ (underlyingIso g).hom #align category_theory.subobject.of_mk_le_mk CategoryTheory.Subobject.ofMkLEMk instance {B A₁ A₂ : C} (f : A₁ ⟶ B) (g : A₂ ⟶ B) [Mono f] [Mono g] (h : mk f ≤ mk g) : Mono (ofMkLEMk f g h) := by dsimp only [ofMkLEMk] infer_instance @[simp] theorem ofMkLEMk_comp {B A₁ A₂ : C} {f : A₁ ⟶ B} {g : A₂ ⟶ B} [Mono f] [Mono g] (h : mk f ≤ mk g) : ofMkLEMk f g h ≫ g = f := by simp [ofMkLEMk] #align category_theory.subobject.of_mk_le_mk_comp CategoryTheory.Subobject.ofMkLEMk_comp @[reassoc (attr := simp)] theorem ofLE_comp_ofLE {B : C} (X Y Z : Subobject B) (h₁ : X ≤ Y) (h₂ : Y ≤ Z) : ofLE X Y h₁ ≫ ofLE Y Z h₂ = ofLE X Z (h₁.trans h₂) := by simp only [ofLE, ← Functor.map_comp underlying] congr 1 #align category_theory.subobject.of_le_comp_of_le CategoryTheory.Subobject.ofLE_comp_ofLE @[reassoc (attr := simp)]
Mathlib/CategoryTheory/Subobject/Basic.lean
392
395
theorem ofLE_comp_ofLEMk {B A : C} (X Y : Subobject B) (f : A ⟶ B) [Mono f] (h₁ : X ≤ Y) (h₂ : Y ≤ mk f) : ofLE X Y h₁ ≫ ofLEMk Y f h₂ = ofLEMk X f (h₁.trans h₂) := by
simp only [ofMkLE, ofLEMk, ofLE, ← Functor.map_comp_assoc underlying] congr 1
import Mathlib.Order.Interval.Set.Disjoint import Mathlib.MeasureTheory.Integral.SetIntegral import Mathlib.MeasureTheory.Measure.Lebesgue.Basic #align_import measure_theory.integral.interval_integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" noncomputable section open scoped Classical open MeasureTheory Set Filter Function open scoped Classical Topology Filter ENNReal Interval NNReal variable {ι 𝕜 E F A : Type*} [NormedAddCommGroup E] def IntervalIntegrable (f : ℝ → E) (μ : Measure ℝ) (a b : ℝ) : Prop := IntegrableOn f (Ioc a b) μ ∧ IntegrableOn f (Ioc b a) μ #align interval_integrable IntervalIntegrable section variable {f : ℝ → E} {a b : ℝ} {μ : Measure ℝ}
Mathlib/MeasureTheory/Integral/IntervalIntegral.lean
83
84
theorem intervalIntegrable_iff : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ι a b) μ := by
rw [uIoc_eq_union, integrableOn_union, IntervalIntegrable]
import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Algebra.Ring.Pi import Mathlib.GroupTheory.GroupAction.Pi #align_import algebra.big_operators.pi from "leanprover-community/mathlib"@"fa2309577c7009ea243cffdf990cd6c84f0ad497" @[to_additive (attr := simp)] theorem Finset.prod_apply {α : Type*} {β : α → Type*} {γ} [∀ a, CommMonoid (β a)] (a : α) (s : Finset γ) (g : γ → ∀ a, β a) : (∏ c ∈ s, g c) a = ∏ c ∈ s, g c a := map_prod (Pi.evalMonoidHom β a) _ _ #align finset.prod_apply Finset.prod_apply #align finset.sum_apply Finset.sum_apply @[to_additive "An 'unapplied' analogue of `Finset.sum_apply`."] theorem Finset.prod_fn {α : Type*} {β : α → Type*} {γ} [∀ a, CommMonoid (β a)] (s : Finset γ) (g : γ → ∀ a, β a) : ∏ c ∈ s, g c = fun a ↦ ∏ c ∈ s, g c a := funext fun _ ↦ Finset.prod_apply _ _ _ #align finset.prod_fn Finset.prod_fn #align finset.sum_fn Finset.sum_fn @[to_additive] theorem Fintype.prod_apply {α : Type*} {β : α → Type*} {γ : Type*} [Fintype γ] [∀ a, CommMonoid (β a)] (a : α) (g : γ → ∀ a, β a) : (∏ c, g c) a = ∏ c, g c a := Finset.prod_apply a Finset.univ g #align fintype.prod_apply Fintype.prod_apply #align fintype.sum_apply Fintype.sum_apply @[to_additive prod_mk_sum] theorem prod_mk_prod {α β γ : Type*} [CommMonoid α] [CommMonoid β] (s : Finset γ) (f : γ → α) (g : γ → β) : (∏ x ∈ s, f x, ∏ x ∈ s, g x) = ∏ x ∈ s, (f x, g x) := haveI := Classical.decEq γ Finset.induction_on s rfl (by simp (config := { contextual := true }) [Prod.ext_iff]) #align prod_mk_prod prod_mk_prod #align prod_mk_sum prod_mk_sum theorem pi_eq_sum_univ {ι : Type*} [Fintype ι] [DecidableEq ι] {R : Type*} [Semiring R] (x : ι → R) : x = ∑ i, (x i) • fun j => if i = j then (1 : R) else 0 := by ext simp #align pi_eq_sum_univ pi_eq_sum_univ section MulSingle variable {I : Type*} [DecidableEq I] {Z : I → Type*} variable [∀ i, CommMonoid (Z i)] @[to_additive] theorem Finset.univ_prod_mulSingle [Fintype I] (f : ∀ i, Z i) : (∏ i, Pi.mulSingle i (f i)) = f := by ext a simp #align finset.univ_prod_mul_single Finset.univ_prod_mulSingle #align finset.univ_sum_single Finset.univ_sum_single @[to_additive]
Mathlib/Algebra/BigOperators/Pi.lean
89
94
theorem MonoidHom.functions_ext [Finite I] (G : Type*) [CommMonoid G] (g h : (∀ i, Z i) →* G) (H : ∀ i x, g (Pi.mulSingle i x) = h (Pi.mulSingle i x)) : g = h := by
cases nonempty_fintype I ext k rw [← Finset.univ_prod_mulSingle k, map_prod, map_prod] simp only [H]
import Mathlib.FieldTheory.RatFunc.AsPolynomial import Mathlib.RingTheory.EuclideanDomain import Mathlib.RingTheory.Localization.FractionRing import Mathlib.RingTheory.Polynomial.Content noncomputable section universe u variable {K : Type u} namespace RatFunc section IntDegree open Polynomial variable [Field K] def intDegree (x : RatFunc K) : ℤ := natDegree x.num - natDegree x.denom #align ratfunc.int_degree RatFunc.intDegree @[simp] theorem intDegree_zero : intDegree (0 : RatFunc K) = 0 := by rw [intDegree, num_zero, natDegree_zero, denom_zero, natDegree_one, sub_self] #align ratfunc.int_degree_zero RatFunc.intDegree_zero @[simp] theorem intDegree_one : intDegree (1 : RatFunc K) = 0 := by rw [intDegree, num_one, denom_one, sub_self] #align ratfunc.int_degree_one RatFunc.intDegree_one @[simp] theorem intDegree_C (k : K) : intDegree (C k) = 0 := by rw [intDegree, num_C, natDegree_C, denom_C, natDegree_one, sub_self] set_option linter.uppercaseLean3 false in #align ratfunc.int_degree_C RatFunc.intDegree_C @[simp] theorem intDegree_X : intDegree (X : RatFunc K) = 1 := by rw [intDegree, num_X, Polynomial.natDegree_X, denom_X, Polynomial.natDegree_one, Int.ofNat_one, Int.ofNat_zero, sub_zero] set_option linter.uppercaseLean3 false in #align ratfunc.int_degree_X RatFunc.intDegree_X @[simp] theorem intDegree_polynomial {p : K[X]} : intDegree (algebraMap K[X] (RatFunc K) p) = natDegree p := by rw [intDegree, RatFunc.num_algebraMap, RatFunc.denom_algebraMap, Polynomial.natDegree_one, Int.ofNat_zero, sub_zero] #align ratfunc.int_degree_polynomial RatFunc.intDegree_polynomial theorem intDegree_mul {x y : RatFunc K} (hx : x ≠ 0) (hy : y ≠ 0) : intDegree (x * y) = intDegree x + intDegree y := by simp only [intDegree, add_sub, sub_add, sub_sub_eq_add_sub, sub_sub, sub_eq_sub_iff_add_eq_add] norm_cast rw [← Polynomial.natDegree_mul x.denom_ne_zero y.denom_ne_zero, ← Polynomial.natDegree_mul (RatFunc.num_ne_zero (mul_ne_zero hx hy)) (mul_ne_zero x.denom_ne_zero y.denom_ne_zero), ← Polynomial.natDegree_mul (RatFunc.num_ne_zero hx) (RatFunc.num_ne_zero hy), ← Polynomial.natDegree_mul (mul_ne_zero (RatFunc.num_ne_zero hx) (RatFunc.num_ne_zero hy)) (x * y).denom_ne_zero, RatFunc.num_denom_mul] #align ratfunc.int_degree_mul RatFunc.intDegree_mul @[simp] theorem intDegree_neg (x : RatFunc K) : intDegree (-x) = intDegree x := by by_cases hx : x = 0 · rw [hx, neg_zero] · rw [intDegree, intDegree, ← natDegree_neg x.num] exact natDegree_sub_eq_of_prod_eq (num_ne_zero (neg_ne_zero.mpr hx)) (denom_ne_zero (-x)) (neg_ne_zero.mpr (num_ne_zero hx)) (denom_ne_zero x) (num_denom_neg x) #align ratfunc.int_degree_neg RatFunc.intDegree_neg theorem intDegree_add {x y : RatFunc K} (hxy : x + y ≠ 0) : (x + y).intDegree = (x.num * y.denom + x.denom * y.num).natDegree - (x.denom * y.denom).natDegree := natDegree_sub_eq_of_prod_eq (num_ne_zero hxy) (x + y).denom_ne_zero (num_mul_denom_add_denom_mul_num_ne_zero hxy) (mul_ne_zero x.denom_ne_zero y.denom_ne_zero) (num_denom_add x y) #align ratfunc.int_degree_add RatFunc.intDegree_add
Mathlib/FieldTheory/RatFunc/Degree.lean
102
107
theorem natDegree_num_mul_right_sub_natDegree_denom_mul_left_eq_intDegree {x : RatFunc K} (hx : x ≠ 0) {s : K[X]} (hs : s ≠ 0) : ((x.num * s).natDegree : ℤ) - (s * x.denom).natDegree = x.intDegree := by
apply natDegree_sub_eq_of_prod_eq (mul_ne_zero (num_ne_zero hx) hs) (mul_ne_zero hs x.denom_ne_zero) (num_ne_zero hx) x.denom_ne_zero rw [mul_assoc]
import Mathlib.Algebra.Algebra.Subalgebra.Basic import Mathlib.RingTheory.Ideal.Maps #align_import algebra.algebra.subalgebra.basic from "leanprover-community/mathlib"@"b915e9392ecb2a861e1e766f0e1df6ac481188ca" namespace Subalgebra open Algebra variable {R S : Type*} [CommSemiring R] [CommRing S] [Algebra R S] variable (S' : Subalgebra R S)
Mathlib/Algebra/Algebra/Subalgebra/Operations.lean
40
68
theorem mem_of_finset_sum_eq_one_of_pow_smul_mem {ι : Type*} (ι' : Finset ι) (s : ι → S) (l : ι → S) (e : ∑ i ∈ ι', l i * s i = 1) (hs : ∀ i, s i ∈ S') (hl : ∀ i, l i ∈ S') (x : S) (H : ∀ i, ∃ n : ℕ, (s i ^ n : S) • x ∈ S') : x ∈ S' := by
-- Porting note: needed to add this instance let _i : Algebra { x // x ∈ S' } { x // x ∈ S' } := Algebra.id _ suffices x ∈ Subalgebra.toSubmodule (Algebra.ofId S' S).range by obtain ⟨x, rfl⟩ := this exact x.2 choose n hn using H let s' : ι → S' := fun x => ⟨s x, hs x⟩ let l' : ι → S' := fun x => ⟨l x, hl x⟩ have e' : ∑ i ∈ ι', l' i * s' i = 1 := by ext show S'.subtype (∑ i ∈ ι', l' i * s' i) = 1 simpa only [map_sum, map_mul] using e have : Ideal.span (s' '' ι') = ⊤ := by rw [Ideal.eq_top_iff_one, ← e'] apply sum_mem intros i hi exact Ideal.mul_mem_left _ _ <| Ideal.subset_span <| Set.mem_image_of_mem s' hi let N := ι'.sup n have hN := Ideal.span_pow_eq_top _ this N apply (Algebra.ofId S' S).range.toSubmodule.mem_of_span_top_of_smul_mem _ hN rintro ⟨_, _, ⟨i, hi, rfl⟩, rfl⟩ change s' i ^ N • x ∈ _ rw [← tsub_add_cancel_of_le (show n i ≤ N from Finset.le_sup hi), pow_add, mul_smul] refine Submodule.smul_mem _ (⟨_, pow_mem (hs i) _⟩ : S') ?_ exact ⟨⟨_, hn i⟩, rfl⟩
import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.ContDiff.Defs #align_import analysis.calculus.iterated_deriv from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" noncomputable section open scoped Classical Topology open Filter Asymptotics Set variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] def iteratedDeriv (n : ℕ) (f : 𝕜 → F) (x : 𝕜) : F := (iteratedFDeriv 𝕜 n f x : (Fin n → 𝕜) → F) fun _ : Fin n => 1 #align iterated_deriv iteratedDeriv def iteratedDerivWithin (n : ℕ) (f : 𝕜 → F) (s : Set 𝕜) (x : 𝕜) : F := (iteratedFDerivWithin 𝕜 n f s x : (Fin n → 𝕜) → F) fun _ : Fin n => 1 #align iterated_deriv_within iteratedDerivWithin variable {n : ℕ} {f : 𝕜 → F} {s : Set 𝕜} {x : 𝕜} theorem iteratedDerivWithin_univ : iteratedDerivWithin n f univ = iteratedDeriv n f := by ext x rw [iteratedDerivWithin, iteratedDeriv, iteratedFDerivWithin_univ] #align iterated_deriv_within_univ iteratedDerivWithin_univ theorem iteratedDerivWithin_eq_iteratedFDerivWithin : iteratedDerivWithin n f s x = (iteratedFDerivWithin 𝕜 n f s x : (Fin n → 𝕜) → F) fun _ : Fin n => 1 := rfl #align iterated_deriv_within_eq_iterated_fderiv_within iteratedDerivWithin_eq_iteratedFDerivWithin theorem iteratedDerivWithin_eq_equiv_comp : iteratedDerivWithin n f s = (ContinuousMultilinearMap.piFieldEquiv 𝕜 (Fin n) F).symm ∘ iteratedFDerivWithin 𝕜 n f s := by ext x; rfl #align iterated_deriv_within_eq_equiv_comp iteratedDerivWithin_eq_equiv_comp theorem iteratedFDerivWithin_eq_equiv_comp : iteratedFDerivWithin 𝕜 n f s = ContinuousMultilinearMap.piFieldEquiv 𝕜 (Fin n) F ∘ iteratedDerivWithin n f s := by rw [iteratedDerivWithin_eq_equiv_comp, ← Function.comp.assoc, LinearIsometryEquiv.self_comp_symm, Function.id_comp] #align iterated_fderiv_within_eq_equiv_comp iteratedFDerivWithin_eq_equiv_comp theorem iteratedFDerivWithin_apply_eq_iteratedDerivWithin_mul_prod {m : Fin n → 𝕜} : (iteratedFDerivWithin 𝕜 n f s x : (Fin n → 𝕜) → F) m = (∏ i, m i) • iteratedDerivWithin n f s x := by rw [iteratedDerivWithin_eq_iteratedFDerivWithin, ← ContinuousMultilinearMap.map_smul_univ] simp #align iterated_fderiv_within_apply_eq_iterated_deriv_within_mul_prod iteratedFDerivWithin_apply_eq_iteratedDerivWithin_mul_prod theorem norm_iteratedFDerivWithin_eq_norm_iteratedDerivWithin : ‖iteratedFDerivWithin 𝕜 n f s x‖ = ‖iteratedDerivWithin n f s x‖ := by rw [iteratedDerivWithin_eq_equiv_comp, Function.comp_apply, LinearIsometryEquiv.norm_map] #align norm_iterated_fderiv_within_eq_norm_iterated_deriv_within norm_iteratedFDerivWithin_eq_norm_iteratedDerivWithin @[simp] theorem iteratedDerivWithin_zero : iteratedDerivWithin 0 f s = f := by ext x simp [iteratedDerivWithin] #align iterated_deriv_within_zero iteratedDerivWithin_zero @[simp] theorem iteratedDerivWithin_one {x : 𝕜} (h : UniqueDiffWithinAt 𝕜 s x) : iteratedDerivWithin 1 f s x = derivWithin f s x := by simp only [iteratedDerivWithin, iteratedFDerivWithin_one_apply h]; rfl #align iterated_deriv_within_one iteratedDerivWithin_one theorem contDiffOn_of_continuousOn_differentiableOn_deriv {n : ℕ∞} (Hcont : ∀ m : ℕ, (m : ℕ∞) ≤ n → ContinuousOn (fun x => iteratedDerivWithin m f s x) s) (Hdiff : ∀ m : ℕ, (m : ℕ∞) < n → DifferentiableOn 𝕜 (fun x => iteratedDerivWithin m f s x) s) : ContDiffOn 𝕜 n f s := by apply contDiffOn_of_continuousOn_differentiableOn · simpa only [iteratedFDerivWithin_eq_equiv_comp, LinearIsometryEquiv.comp_continuousOn_iff] · simpa only [iteratedFDerivWithin_eq_equiv_comp, LinearIsometryEquiv.comp_differentiableOn_iff] #align cont_diff_on_of_continuous_on_differentiable_on_deriv contDiffOn_of_continuousOn_differentiableOn_deriv theorem contDiffOn_of_differentiableOn_deriv {n : ℕ∞} (h : ∀ m : ℕ, (m : ℕ∞) ≤ n → DifferentiableOn 𝕜 (iteratedDerivWithin m f s) s) : ContDiffOn 𝕜 n f s := by apply contDiffOn_of_differentiableOn simpa only [iteratedFDerivWithin_eq_equiv_comp, LinearIsometryEquiv.comp_differentiableOn_iff] #align cont_diff_on_of_differentiable_on_deriv contDiffOn_of_differentiableOn_deriv theorem ContDiffOn.continuousOn_iteratedDerivWithin {n : ℕ∞} {m : ℕ} (h : ContDiffOn 𝕜 n f s) (hmn : (m : ℕ∞) ≤ n) (hs : UniqueDiffOn 𝕜 s) : ContinuousOn (iteratedDerivWithin m f s) s := by simpa only [iteratedDerivWithin_eq_equiv_comp, LinearIsometryEquiv.comp_continuousOn_iff] using h.continuousOn_iteratedFDerivWithin hmn hs #align cont_diff_on.continuous_on_iterated_deriv_within ContDiffOn.continuousOn_iteratedDerivWithin
Mathlib/Analysis/Calculus/IteratedDeriv/Defs.lean
157
162
theorem ContDiffWithinAt.differentiableWithinAt_iteratedDerivWithin {n : ℕ∞} {m : ℕ} (h : ContDiffWithinAt 𝕜 n f s x) (hmn : (m : ℕ∞) < n) (hs : UniqueDiffOn 𝕜 (insert x s)) : DifferentiableWithinAt 𝕜 (iteratedDerivWithin m f s) s x := by
simpa only [iteratedDerivWithin_eq_equiv_comp, LinearIsometryEquiv.comp_differentiableWithinAt_iff] using h.differentiableWithinAt_iteratedFDerivWithin hmn hs
import Mathlib.CategoryTheory.Adjunction.Basic open CategoryTheory variable {C D : Type*} [Category C] [Category D] namespace CategoryTheory.Adjunction @[simps] def natTransEquiv {F F' : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') : (G ⟶ G') ≃ (F' ⟶ F) where toFun f := { app := fun X ↦ F'.map ((adj1.unit ≫ whiskerLeft F f).app X) ≫ adj2.counit.app _ naturality := by intro X Y g simp only [← Category.assoc, ← Functor.map_comp] erw [(adj1.unit ≫ (whiskerLeft F f)).naturality] simp } invFun f := { app := fun X ↦ adj2.unit.app (G.obj X) ≫ G'.map (f.app (G.obj X) ≫ adj1.counit.app X) naturality := by intro X Y g erw [← adj2.unit_naturality_assoc] simp only [← Functor.map_comp] simp } left_inv f := by ext X simp only [Functor.comp_obj, NatTrans.comp_app, Functor.id_obj, whiskerLeft_app, Functor.map_comp, Category.assoc, unit_naturality_assoc, right_triangle_components_assoc] erw [← f.naturality (adj1.counit.app X), ← Category.assoc] simp right_inv f := by ext simp @[simp] lemma natTransEquiv_id {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) : natTransEquiv adj adj (𝟙 _) = 𝟙 _ := by ext; simp @[simp] lemma natTransEquiv_id_symm {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) : (natTransEquiv adj adj).symm (𝟙 _) = 𝟙 _ := by ext; simp @[simp] lemma natTransEquiv_comp {F F' F'' : C ⥤ D} {G G' G'' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') (adj3 : F'' ⊣ G'') (f : G ⟶ G') (g : G' ⟶ G'') : natTransEquiv adj2 adj3 g ≫ natTransEquiv adj1 adj2 f = natTransEquiv adj1 adj3 (f ≫ g) := by apply (natTransEquiv adj1 adj3).symm.injective ext X simp only [natTransEquiv_symm_apply_app, Functor.comp_obj, NatTrans.comp_app, natTransEquiv_apply_app, Functor.id_obj, whiskerLeft_app, Functor.map_comp, Category.assoc, unit_naturality_assoc, right_triangle_components_assoc, Equiv.symm_apply_apply, ← g.naturality_assoc, ← g.naturality] simp only [← Category.assoc, unit_naturality, Functor.comp_obj, right_triangle_components, Category.comp_id, ← f.naturality, Category.id_comp] @[simp] lemma natTransEquiv_comp_symm {F F' F'' : C ⥤ D} {G G' G'' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') (adj3 : F'' ⊣ G'') (f : F' ⟶ F) (g : F'' ⟶ F') : (natTransEquiv adj1 adj2).symm f ≫ (natTransEquiv adj2 adj3).symm g = (natTransEquiv adj1 adj3).symm (g ≫ f) := by apply (natTransEquiv adj1 adj3).injective ext simp @[simps] def natIsoEquiv {F F' : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G') : (G ≅ G') ≃ (F' ≅ F) where toFun i := { hom := natTransEquiv adj1 adj2 i.hom inv := natTransEquiv adj2 adj1 i.inv } invFun i := { hom := (natTransEquiv adj1 adj2).symm i.hom inv := (natTransEquiv adj2 adj1).symm i.inv } left_inv i := by simp right_inv i := by simp def leftAdjointUniq {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) : F ≅ F' := (natIsoEquiv adj1 adj2 (Iso.refl _)).symm #align category_theory.adjunction.left_adjoint_uniq CategoryTheory.Adjunction.leftAdjointUniq -- Porting note (#10618): removed simp as simp can prove this theorem homEquiv_leftAdjointUniq_hom_app {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) : adj1.homEquiv _ _ ((leftAdjointUniq adj1 adj2).hom.app x) = adj2.unit.app x := by simp [leftAdjointUniq] #align category_theory.adjunction.hom_equiv_left_adjoint_uniq_hom_app CategoryTheory.Adjunction.homEquiv_leftAdjointUniq_hom_app @[reassoc (attr := simp)] theorem unit_leftAdjointUniq_hom {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) : adj1.unit ≫ whiskerRight (leftAdjointUniq adj1 adj2).hom G = adj2.unit := by ext x rw [NatTrans.comp_app, ← homEquiv_leftAdjointUniq_hom_app adj1 adj2] simp [← G.map_comp] #align category_theory.adjunction.unit_left_adjoint_uniq_hom CategoryTheory.Adjunction.unit_leftAdjointUniq_hom @[reassoc (attr := simp)] theorem unit_leftAdjointUniq_hom_app {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) : adj1.unit.app x ≫ G.map ((leftAdjointUniq adj1 adj2).hom.app x) = adj2.unit.app x := by rw [← unit_leftAdjointUniq_hom adj1 adj2]; rfl #align category_theory.adjunction.unit_left_adjoint_uniq_hom_app CategoryTheory.Adjunction.unit_leftAdjointUniq_hom_app @[reassoc (attr := simp)] theorem leftAdjointUniq_hom_counit {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) : whiskerLeft G (leftAdjointUniq adj1 adj2).hom ≫ adj2.counit = adj1.counit := by ext x simp only [Functor.comp_obj, Functor.id_obj, leftAdjointUniq, Iso.symm_hom, natIsoEquiv_apply_inv, Iso.refl_inv, NatTrans.comp_app, whiskerLeft_app, natTransEquiv_apply_app, whiskerLeft_id', Category.comp_id, Category.assoc] rw [← adj1.counit_naturality, ← Category.assoc, ← F.map_comp] simp #align category_theory.adjunction.left_adjoint_uniq_hom_counit CategoryTheory.Adjunction.leftAdjointUniq_hom_counit @[reassoc (attr := simp)] theorem leftAdjointUniq_hom_app_counit {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : D) : (leftAdjointUniq adj1 adj2).hom.app (G.obj x) ≫ adj2.counit.app x = adj1.counit.app x := by rw [← leftAdjointUniq_hom_counit adj1 adj2] rfl #align category_theory.adjunction.left_adjoint_uniq_hom_app_counit CategoryTheory.Adjunction.leftAdjointUniq_hom_app_counit theorem leftAdjointUniq_inv_app {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) : (leftAdjointUniq adj1 adj2).inv.app x = (leftAdjointUniq adj2 adj1).hom.app x := rfl #align category_theory.adjunction.left_adjoint_uniq_inv_app CategoryTheory.Adjunction.leftAdjointUniq_inv_app @[reassoc (attr := simp)] theorem leftAdjointUniq_trans {F F' F'' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (adj3 : F'' ⊣ G) : (leftAdjointUniq adj1 adj2).hom ≫ (leftAdjointUniq adj2 adj3).hom = (leftAdjointUniq adj1 adj3).hom := by simp [leftAdjointUniq] #align category_theory.adjunction.left_adjoint_uniq_trans CategoryTheory.Adjunction.leftAdjointUniq_trans @[reassoc (attr := simp)] theorem leftAdjointUniq_trans_app {F F' F'' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (adj3 : F'' ⊣ G) (x : C) : (leftAdjointUniq adj1 adj2).hom.app x ≫ (leftAdjointUniq adj2 adj3).hom.app x = (leftAdjointUniq adj1 adj3).hom.app x := by rw [← leftAdjointUniq_trans adj1 adj2 adj3] rfl #align category_theory.adjunction.left_adjoint_uniq_trans_app CategoryTheory.Adjunction.leftAdjointUniq_trans_app @[simp] theorem leftAdjointUniq_refl {F : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) : (leftAdjointUniq adj1 adj1).hom = 𝟙 _ := by simp [leftAdjointUniq] #align category_theory.adjunction.left_adjoint_uniq_refl CategoryTheory.Adjunction.leftAdjointUniq_refl def rightAdjointUniq {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') : G ≅ G' := (natIsoEquiv adj1 adj2).symm (Iso.refl _) #align category_theory.adjunction.right_adjoint_uniq CategoryTheory.Adjunction.rightAdjointUniq -- Porting note (#10618): simp can prove this theorem homEquiv_symm_rightAdjointUniq_hom_app {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') (x : D) : (adj2.homEquiv _ _).symm ((rightAdjointUniq adj1 adj2).hom.app x) = adj1.counit.app x := by simp [rightAdjointUniq] #align category_theory.adjunction.hom_equiv_symm_right_adjoint_uniq_hom_app CategoryTheory.Adjunction.homEquiv_symm_rightAdjointUniq_hom_app @[reassoc (attr := simp)] theorem unit_rightAdjointUniq_hom_app {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') (x : C) : adj1.unit.app x ≫ (rightAdjointUniq adj1 adj2).hom.app (F.obj x) = adj2.unit.app x := by simp only [Functor.id_obj, Functor.comp_obj, rightAdjointUniq, natIsoEquiv_symm_apply_hom, Iso.refl_hom, natTransEquiv_symm_apply_app, NatTrans.id_app, Category.id_comp] rw [← adj2.unit_naturality_assoc, ← G'.map_comp] simp #align category_theory.adjunction.unit_right_adjoint_uniq_hom_app CategoryTheory.Adjunction.unit_rightAdjointUniq_hom_app @[reassoc (attr := simp)] theorem unit_rightAdjointUniq_hom {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') : adj1.unit ≫ whiskerLeft F (rightAdjointUniq adj1 adj2).hom = adj2.unit := by ext x simp #align category_theory.adjunction.unit_right_adjoint_uniq_hom CategoryTheory.Adjunction.unit_rightAdjointUniq_hom @[reassoc (attr := simp)]
Mathlib/CategoryTheory/Adjunction/Unique.lean
214
217
theorem rightAdjointUniq_hom_app_counit {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') (x : D) : F.map ((rightAdjointUniq adj1 adj2).hom.app x) ≫ adj2.counit.app x = adj1.counit.app x := by
simp [rightAdjointUniq]
import Mathlib.NumberTheory.FLT.Basic import Mathlib.NumberTheory.PythagoreanTriples import Mathlib.RingTheory.Coprime.Lemmas import Mathlib.Tactic.LinearCombination #align_import number_theory.fermat4 from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1" noncomputable section open scoped Classical def Fermat42 (a b c : ℤ) : Prop := a ≠ 0 ∧ b ≠ 0 ∧ a ^ 4 + b ^ 4 = c ^ 2 #align fermat_42 Fermat42 namespace Fermat42 theorem comm {a b c : ℤ} : Fermat42 a b c ↔ Fermat42 b a c := by delta Fermat42 rw [add_comm] tauto #align fermat_42.comm Fermat42.comm theorem mul {a b c k : ℤ} (hk0 : k ≠ 0) : Fermat42 a b c ↔ Fermat42 (k * a) (k * b) (k ^ 2 * c) := by delta Fermat42 constructor · intro f42 constructor · exact mul_ne_zero hk0 f42.1 constructor · exact mul_ne_zero hk0 f42.2.1 · have H : a ^ 4 + b ^ 4 = c ^ 2 := f42.2.2 linear_combination k ^ 4 * H · intro f42 constructor · exact right_ne_zero_of_mul f42.1 constructor · exact right_ne_zero_of_mul f42.2.1 apply (mul_right_inj' (pow_ne_zero 4 hk0)).mp linear_combination f42.2.2 #align fermat_42.mul Fermat42.mul theorem ne_zero {a b c : ℤ} (h : Fermat42 a b c) : c ≠ 0 := by apply ne_zero_pow two_ne_zero _; apply ne_of_gt rw [← h.2.2, (by ring : a ^ 4 + b ^ 4 = (a ^ 2) ^ 2 + (b ^ 2) ^ 2)] exact add_pos (sq_pos_of_ne_zero (pow_ne_zero 2 h.1)) (sq_pos_of_ne_zero (pow_ne_zero 2 h.2.1)) #align fermat_42.ne_zero Fermat42.ne_zero def Minimal (a b c : ℤ) : Prop := Fermat42 a b c ∧ ∀ a1 b1 c1 : ℤ, Fermat42 a1 b1 c1 → Int.natAbs c ≤ Int.natAbs c1 #align fermat_42.minimal Fermat42.Minimal
Mathlib/NumberTheory/FLT/Four.lean
72
85
theorem exists_minimal {a b c : ℤ} (h : Fermat42 a b c) : ∃ a0 b0 c0, Minimal a0 b0 c0 := by
let S : Set ℕ := { n | ∃ s : ℤ × ℤ × ℤ, Fermat42 s.1 s.2.1 s.2.2 ∧ n = Int.natAbs s.2.2 } have S_nonempty : S.Nonempty := by use Int.natAbs c rw [Set.mem_setOf_eq] use ⟨a, ⟨b, c⟩⟩ let m : ℕ := Nat.find S_nonempty have m_mem : m ∈ S := Nat.find_spec S_nonempty rcases m_mem with ⟨s0, hs0, hs1⟩ use s0.1, s0.2.1, s0.2.2, hs0 intro a1 b1 c1 h1 rw [← hs1] apply Nat.find_min' use ⟨a1, ⟨b1, c1⟩⟩
import Mathlib.Order.Filter.EventuallyConst import Mathlib.Order.PartialSups import Mathlib.Algebra.Module.Submodule.IterateMapComap import Mathlib.RingTheory.OrzechProperty import Mathlib.RingTheory.Nilpotent.Lemmas #align_import ring_theory.noetherian from "leanprover-community/mathlib"@"210657c4ea4a4a7b234392f70a3a2a83346dfa90" open Set Filter Pointwise -- Porting note: should this be renamed to `Noetherian`? class IsNoetherian (R M) [Semiring R] [AddCommMonoid M] [Module R M] : Prop where noetherian : ∀ s : Submodule R M, s.FG #align is_noetherian IsNoetherian attribute [inherit_doc IsNoetherian] IsNoetherian.noetherian section variable {R : Type*} {M : Type*} {P : Type*} variable [Semiring R] [AddCommMonoid M] [AddCommMonoid P] variable [Module R M] [Module R P] open IsNoetherian theorem isNoetherian_def : IsNoetherian R M ↔ ∀ s : Submodule R M, s.FG := ⟨fun h => h.noetherian, IsNoetherian.mk⟩ #align is_noetherian_def isNoetherian_def theorem isNoetherian_submodule {N : Submodule R M} : IsNoetherian R N ↔ ∀ s : Submodule R M, s ≤ N → s.FG := by refine ⟨fun ⟨hn⟩ => fun s hs => have : s ≤ LinearMap.range N.subtype := N.range_subtype.symm ▸ hs Submodule.map_comap_eq_self this ▸ (hn _).map _, fun h => ⟨fun s => ?_⟩⟩ have f := (Submodule.equivMapOfInjective N.subtype Subtype.val_injective s).symm have h₁ := h (s.map N.subtype) (Submodule.map_subtype_le N s) have h₂ : (⊤ : Submodule R (s.map N.subtype)).map f = ⊤ := by simp have h₃ := ((Submodule.fg_top _).2 h₁).map (↑f : _ →ₗ[R] s) exact (Submodule.fg_top _).1 (h₂ ▸ h₃) #align is_noetherian_submodule isNoetherian_submodule theorem isNoetherian_submodule_left {N : Submodule R M} : IsNoetherian R N ↔ ∀ s : Submodule R M, (N ⊓ s).FG := isNoetherian_submodule.trans ⟨fun H _ => H _ inf_le_left, fun H _ hs => inf_of_le_right hs ▸ H _⟩ #align is_noetherian_submodule_left isNoetherian_submodule_left theorem isNoetherian_submodule_right {N : Submodule R M} : IsNoetherian R N ↔ ∀ s : Submodule R M, (s ⊓ N).FG := isNoetherian_submodule.trans ⟨fun H _ => H _ inf_le_right, fun H _ hs => inf_of_le_left hs ▸ H _⟩ #align is_noetherian_submodule_right isNoetherian_submodule_right instance isNoetherian_submodule' [IsNoetherian R M] (N : Submodule R M) : IsNoetherian R N := isNoetherian_submodule.2 fun _ _ => IsNoetherian.noetherian _ #align is_noetherian_submodule' isNoetherian_submodule' theorem isNoetherian_of_le {s t : Submodule R M} [ht : IsNoetherian R t] (h : s ≤ t) : IsNoetherian R s := isNoetherian_submodule.mpr fun _ hs' => isNoetherian_submodule.mp ht _ (le_trans hs' h) #align is_noetherian_of_le isNoetherian_of_le variable (M) theorem isNoetherian_of_surjective (f : M →ₗ[R] P) (hf : LinearMap.range f = ⊤) [IsNoetherian R M] : IsNoetherian R P := ⟨fun s => have : (s.comap f).map f = s := Submodule.map_comap_eq_self <| hf.symm ▸ le_top this ▸ (noetherian _).map _⟩ #align is_noetherian_of_surjective isNoetherian_of_surjective variable {M} instance isNoetherian_quotient {R} [Ring R] {M} [AddCommGroup M] [Module R M] (N : Submodule R M) [IsNoetherian R M] : IsNoetherian R (M ⧸ N) := isNoetherian_of_surjective _ _ (LinearMap.range_eq_top.mpr N.mkQ_surjective) #align submodule.quotient.is_noetherian isNoetherian_quotient @[deprecated (since := "2024-04-27"), nolint defLemma] alias Submodule.Quotient.isNoetherian := isNoetherian_quotient theorem isNoetherian_of_linearEquiv (f : M ≃ₗ[R] P) [IsNoetherian R M] : IsNoetherian R P := isNoetherian_of_surjective _ f.toLinearMap f.range #align is_noetherian_of_linear_equiv isNoetherian_of_linearEquiv theorem isNoetherian_top_iff : IsNoetherian R (⊤ : Submodule R M) ↔ IsNoetherian R M := by constructor <;> intro h · exact isNoetherian_of_linearEquiv (LinearEquiv.ofTop (⊤ : Submodule R M) rfl) · exact isNoetherian_of_linearEquiv (LinearEquiv.ofTop (⊤ : Submodule R M) rfl).symm #align is_noetherian_top_iff isNoetherian_top_iff theorem isNoetherian_of_injective [IsNoetherian R P] (f : M →ₗ[R] P) (hf : Function.Injective f) : IsNoetherian R M := isNoetherian_of_linearEquiv (LinearEquiv.ofInjective f hf).symm #align is_noetherian_of_injective isNoetherian_of_injective theorem fg_of_injective [IsNoetherian R P] {N : Submodule R M} (f : M →ₗ[R] P) (hf : Function.Injective f) : N.FG := haveI := isNoetherian_of_injective f hf IsNoetherian.noetherian N #align fg_of_injective fg_of_injective end section variable {R : Type*} {M : Type*} {P : Type*} variable [Ring R] [AddCommGroup M] [AddCommGroup P] variable [Module R M] [Module R P] open IsNoetherian theorem isNoetherian_of_ker_bot [IsNoetherian R P] (f : M →ₗ[R] P) (hf : LinearMap.ker f = ⊥) : IsNoetherian R M := isNoetherian_of_linearEquiv (LinearEquiv.ofInjective f <| LinearMap.ker_eq_bot.mp hf).symm #align is_noetherian_of_ker_bot isNoetherian_of_ker_bot theorem fg_of_ker_bot [IsNoetherian R P] {N : Submodule R M} (f : M →ₗ[R] P) (hf : LinearMap.ker f = ⊥) : N.FG := haveI := isNoetherian_of_ker_bot f hf IsNoetherian.noetherian N #align fg_of_ker_bot fg_of_ker_bot instance isNoetherian_prod [IsNoetherian R M] [IsNoetherian R P] : IsNoetherian R (M × P) := ⟨fun s => Submodule.fg_of_fg_map_of_fg_inf_ker (LinearMap.snd R M P) (noetherian _) <| have : s ⊓ LinearMap.ker (LinearMap.snd R M P) ≤ LinearMap.range (LinearMap.inl R M P) := fun x ⟨_, hx2⟩ => ⟨x.1, Prod.ext rfl <| Eq.symm <| LinearMap.mem_ker.1 hx2⟩ Submodule.map_comap_eq_self this ▸ (noetherian _).map _⟩ #align is_noetherian_prod isNoetherian_prod instance isNoetherian_pi {R ι : Type*} {M : ι → Type*} [Ring R] [∀ i, AddCommGroup (M i)] [∀ i, Module R (M i)] [Finite ι] [∀ i, IsNoetherian R (M i)] : IsNoetherian R (∀ i, M i) := by cases nonempty_fintype ι haveI := Classical.decEq ι suffices on_finset : ∀ s : Finset ι, IsNoetherian R (∀ i : s, M i) by let coe_e := Equiv.subtypeUnivEquiv <| @Finset.mem_univ ι _ letI : IsNoetherian R (∀ i : Finset.univ, M (coe_e i)) := on_finset Finset.univ exact isNoetherian_of_linearEquiv (LinearEquiv.piCongrLeft R M coe_e) intro s induction' s using Finset.induction with a s has ih · exact ⟨fun s => by have : s = ⊥ := by simp only [eq_iff_true_of_subsingleton] rw [this] apply Submodule.fg_bot⟩ refine @isNoetherian_of_linearEquiv R (M a × ((i : s) → M i)) _ _ _ _ _ _ ?_ <| @isNoetherian_prod R (M a) _ _ _ _ _ _ _ ih refine { toFun := fun f i => (Finset.mem_insert.1 i.2).by_cases (fun h : i.1 = a => show M i.1 from Eq.recOn h.symm f.1) (fun h : i.1 ∈ s => show M i.1 from f.2 ⟨i.1, h⟩), invFun := fun f => (f ⟨a, Finset.mem_insert_self _ _⟩, fun i => f ⟨i.1, Finset.mem_insert_of_mem i.2⟩), map_add' := ?_, map_smul' := ?_ left_inv := ?_, right_inv := ?_ } · intro f g ext i unfold Or.by_cases cases' i with i hi rcases Finset.mem_insert.1 hi with (rfl | h) · change _ = _ + _ simp only [dif_pos] rfl · change _ = _ + _ have : ¬i = a := by rintro rfl exact has h simp only [dif_neg this, dif_pos h] rfl · intro c f ext i unfold Or.by_cases cases' i with i hi rcases Finset.mem_insert.1 hi with (rfl | h) · dsimp simp only [dif_pos] · dsimp have : ¬i = a := by rintro rfl exact has h simp only [dif_neg this, dif_pos h] · intro f apply Prod.ext · simp only [Or.by_cases, dif_pos] · ext ⟨i, his⟩ have : ¬i = a := by rintro rfl exact has his simp only [Or.by_cases, this, not_false_iff, dif_neg] · intro f ext ⟨i, hi⟩ rcases Finset.mem_insert.1 hi with (rfl | h) · simp only [Or.by_cases, dif_pos] · have : ¬i = a := by rintro rfl exact has h simp only [Or.by_cases, dif_neg this, dif_pos h] #align is_noetherian_pi isNoetherian_pi instance isNoetherian_pi' {R ι M : Type*} [Ring R] [AddCommGroup M] [Module R M] [Finite ι] [IsNoetherian R M] : IsNoetherian R (ι → M) := isNoetherian_pi #align is_noetherian_pi' isNoetherian_pi' end open IsNoetherian Submodule Function section universe w variable {R M P : Type*} {N : Type w} [Semiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N] [AddCommMonoid P] [Module R P] theorem isNoetherian_iff_wellFounded : IsNoetherian R M ↔ WellFounded ((· > ·) : Submodule R M → Submodule R M → Prop) := by have := (CompleteLattice.wellFounded_characterisations <| Submodule R M).out 0 3 -- Porting note: inlining this makes rw complain about it being a metavariable rw [this] exact ⟨fun ⟨h⟩ => fun k => (fg_iff_compact k).mp (h k), fun h => ⟨fun k => (fg_iff_compact k).mpr (h k)⟩⟩ #align is_noetherian_iff_well_founded isNoetherian_iff_wellFounded theorem isNoetherian_iff_fg_wellFounded : IsNoetherian R M ↔ WellFounded ((· > ·) : { N : Submodule R M // N.FG } → { N : Submodule R M // N.FG } → Prop) := by let α := { N : Submodule R M // N.FG } constructor · intro H let f : α ↪o Submodule R M := OrderEmbedding.subtype _ exact OrderEmbedding.wellFounded f.dual (isNoetherian_iff_wellFounded.mp H) · intro H constructor intro N obtain ⟨⟨N₀, h₁⟩, e : N₀ ≤ N, h₂⟩ := WellFounded.has_min H { N' : α | N'.1 ≤ N } ⟨⟨⊥, Submodule.fg_bot⟩, @bot_le _ _ _ N⟩ convert h₁ refine (e.antisymm ?_).symm by_contra h₃ obtain ⟨x, hx₁ : x ∈ N, hx₂ : x ∉ N₀⟩ := Set.not_subset.mp h₃ apply hx₂ rw [eq_of_le_of_not_lt (le_sup_right : N₀ ≤ _) (h₂ ⟨_, Submodule.FG.sup ⟨{x}, by rw [Finset.coe_singleton]⟩ h₁⟩ <| sup_le ((Submodule.span_singleton_le_iff_mem _ _).mpr hx₁) e)] exact (le_sup_left : (R ∙ x) ≤ _) (Submodule.mem_span_singleton_self _) #align is_noetherian_iff_fg_well_founded isNoetherian_iff_fg_wellFounded variable (R M) theorem wellFounded_submodule_gt (R M) [Semiring R] [AddCommMonoid M] [Module R M] : ∀ [IsNoetherian R M], WellFounded ((· > ·) : Submodule R M → Submodule R M → Prop) := isNoetherian_iff_wellFounded.mp ‹_› #align well_founded_submodule_gt wellFounded_submodule_gt variable {R M} theorem set_has_maximal_iff_noetherian : (∀ a : Set <| Submodule R M, a.Nonempty → ∃ M' ∈ a, ∀ I ∈ a, ¬M' < I) ↔ IsNoetherian R M := by rw [isNoetherian_iff_wellFounded, WellFounded.wellFounded_iff_has_min] #align set_has_maximal_iff_noetherian set_has_maximal_iff_noetherian
Mathlib/RingTheory/Noetherian.lean
365
367
theorem monotone_stabilizes_iff_noetherian : (∀ f : ℕ →o Submodule R M, ∃ n, ∀ m, n ≤ m → f n = f m) ↔ IsNoetherian R M := by
rw [isNoetherian_iff_wellFounded, WellFounded.monotone_chain_condition]