Context
stringlengths
285
6.98k
file_name
stringlengths
21
79
start
int64
14
184
end
int64
18
184
theorem
stringlengths
25
1.34k
proof
stringlengths
5
3.43k
/- Copyright (c) 2014 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Amelia Livingston, Yury Kudryashov, Neil Strickland, Aaron Anderson -/ import Mathlib.Algebra.Divisibility.Basic import Mathlib.Algebra.Group.Units #align_import algebra.divisibility.units from "leanprover-community/mathlib"@"e574b1a4e891376b0ef974b926da39e05da12a06" /-! # Divisibility and units ## Main definition * `IsRelPrime x y`: that `x` and `y` are relatively prime, defined to mean that the only common divisors of `x` and `y` are the units. -/ variable {α : Type*} namespace Units section Monoid variable [Monoid α] {a b : α} {u : αˣ} /-- Elements of the unit group of a monoid represented as elements of the monoid divide any element of the monoid. -/ theorem coe_dvd : ↑u ∣ a := ⟨↑u⁻¹ * a, by simp⟩ #align units.coe_dvd Units.coe_dvd /-- In a monoid, an element `a` divides an element `b` iff `a` divides all associates of `b`. -/ theorem dvd_mul_right : a ∣ b * u ↔ a ∣ b := Iff.intro (fun ⟨c, Eq⟩ ↦ ⟨c * ↑u⁻¹, by rw [← mul_assoc, ← Eq, Units.mul_inv_cancel_right]⟩) fun ⟨c, Eq⟩ ↦ Eq.symm ▸ (_root_.dvd_mul_right _ _).mul_right _ #align units.dvd_mul_right Units.dvd_mul_right /-- In a monoid, an element `a` divides an element `b` iff all associates of `a` divide `b`. -/ theorem mul_right_dvd : a * u ∣ b ↔ a ∣ b := Iff.intro (fun ⟨c, Eq⟩ => ⟨↑u * c, Eq.trans (mul_assoc _ _ _)⟩) fun h => dvd_trans (Dvd.intro (↑u⁻¹) (by rw [mul_assoc, u.mul_inv, mul_one])) h #align units.mul_right_dvd Units.mul_right_dvd end Monoid section CommMonoid variable [CommMonoid α] {a b : α} {u : αˣ} /-- In a commutative monoid, an element `a` divides an element `b` iff `a` divides all left associates of `b`. -/ theorem dvd_mul_left : a ∣ u * b ↔ a ∣ b := by rw [mul_comm] apply dvd_mul_right #align units.dvd_mul_left Units.dvd_mul_left /-- In a commutative monoid, an element `a` divides an element `b` iff all left associates of `a` divide `b`. -/ theorem mul_left_dvd : ↑u * a ∣ b ↔ a ∣ b := by rw [mul_comm] apply mul_right_dvd #align units.mul_left_dvd Units.mul_left_dvd end CommMonoid end Units namespace IsUnit section Monoid variable [Monoid α] {a b u : α} (hu : IsUnit u) /-- Units of a monoid divide any element of the monoid. -/ @[simp] theorem dvd : u ∣ a := by rcases hu with ⟨u, rfl⟩ apply Units.coe_dvd #align is_unit.dvd IsUnit.dvd @[simp] theorem dvd_mul_right : a ∣ b * u ↔ a ∣ b := by rcases hu with ⟨u, rfl⟩ apply Units.dvd_mul_right #align is_unit.dvd_mul_right IsUnit.dvd_mul_right /-- In a monoid, an element a divides an element b iff all associates of `a` divide `b`. -/ @[simp] theorem mul_right_dvd : a * u ∣ b ↔ a ∣ b := by rcases hu with ⟨u, rfl⟩ apply Units.mul_right_dvd #align is_unit.mul_right_dvd IsUnit.mul_right_dvd theorem isPrimal : IsPrimal u := fun _ _ _ ↦ ⟨u, 1, hu.dvd, one_dvd _, (mul_one u).symm⟩ end Monoid section CommMonoid variable [CommMonoid α] {a b u : α} (hu : IsUnit u) /-- In a commutative monoid, an element `a` divides an element `b` iff `a` divides all left associates of `b`. -/ @[simp]
Mathlib/Algebra/Divisibility/Units.lean
110
112
theorem dvd_mul_left : a ∣ u * b ↔ a ∣ b := by
rcases hu with ⟨u, rfl⟩ apply Units.dvd_mul_left
/- Copyright (c) 2020 Thomas Browning, Patrick Lutz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning, Patrick Lutz -/ import Mathlib.FieldTheory.Fixed import Mathlib.FieldTheory.NormalClosure import Mathlib.FieldTheory.PrimitiveElement import Mathlib.GroupTheory.GroupAction.FixingSubgroup #align_import field_theory.galois from "leanprover-community/mathlib"@"9fb8964792b4237dac6200193a0d533f1b3f7423" /-! # Galois Extensions In this file we define Galois extensions as extensions which are both separable and normal. ## Main definitions - `IsGalois F E` where `E` is an extension of `F` - `fixedField H` where `H : Subgroup (E ≃ₐ[F] E)` - `fixingSubgroup K` where `K : IntermediateField F E` - `intermediateFieldEquivSubgroup` where `E/F` is finite dimensional and Galois ## Main results - `IntermediateField.fixingSubgroup_fixedField` : If `E/F` is finite dimensional (but not necessarily Galois) then `fixingSubgroup (fixedField H) = H` - `IntermediateField.fixedField_fixingSubgroup`: If `E/F` is finite dimensional and Galois then `fixedField (fixingSubgroup K) = K` Together, these two results prove the Galois correspondence. - `IsGalois.tfae` : Equivalent characterizations of a Galois extension of finite degree -/ open scoped Polynomial IntermediateField open FiniteDimensional AlgEquiv section variable (F : Type*) [Field F] (E : Type*) [Field E] [Algebra F E] /-- A field extension E/F is Galois if it is both separable and normal. Note that in mathlib a separable extension of fields is by definition algebraic. -/ class IsGalois : Prop where [to_isSeparable : IsSeparable F E] [to_normal : Normal F E] #align is_galois IsGalois variable {F E} theorem isGalois_iff : IsGalois F E ↔ IsSeparable F E ∧ Normal F E := ⟨fun h => ⟨h.1, h.2⟩, fun h => { to_isSeparable := h.1 to_normal := h.2 }⟩ #align is_galois_iff isGalois_iff attribute [instance 100] IsGalois.to_isSeparable IsGalois.to_normal -- see Note [lower instance priority] variable (F E) namespace IsGalois instance self : IsGalois F F := ⟨⟩ #align is_galois.self IsGalois.self variable {E} theorem integral [IsGalois F E] (x : E) : IsIntegral F x := to_normal.isIntegral x #align is_galois.integral IsGalois.integral theorem separable [IsGalois F E] (x : E) : (minpoly F x).Separable := IsSeparable.separable F x #align is_galois.separable IsGalois.separable theorem splits [IsGalois F E] (x : E) : (minpoly F x).Splits (algebraMap F E) := Normal.splits' x #align is_galois.splits IsGalois.splits variable (E) instance of_fixed_field (G : Type*) [Group G] [Finite G] [MulSemiringAction G E] : IsGalois (FixedPoints.subfield G E) E := ⟨⟩ #align is_galois.of_fixed_field IsGalois.of_fixed_field theorem IntermediateField.AdjoinSimple.card_aut_eq_finrank [FiniteDimensional F E] {α : E} (hα : IsIntegral F α) (h_sep : (minpoly F α).Separable) (h_splits : (minpoly F α).Splits (algebraMap F F⟮α⟯)) : Fintype.card (F⟮α⟯ ≃ₐ[F] F⟮α⟯) = finrank F F⟮α⟯ := by letI : Fintype (F⟮α⟯ →ₐ[F] F⟮α⟯) := IntermediateField.fintypeOfAlgHomAdjoinIntegral F hα rw [IntermediateField.adjoin.finrank hα] rw [← IntermediateField.card_algHom_adjoin_integral F hα h_sep h_splits] exact Fintype.card_congr (algEquivEquivAlgHom F F⟮α⟯) #align is_galois.intermediate_field.adjoin_simple.card_aut_eq_finrank IsGalois.IntermediateField.AdjoinSimple.card_aut_eq_finrank
Mathlib/FieldTheory/Galois.lean
103
125
theorem card_aut_eq_finrank [FiniteDimensional F E] [IsGalois F E] : Fintype.card (E ≃ₐ[F] E) = finrank F E := by
cases' Field.exists_primitive_element F E with α hα let iso : F⟮α⟯ ≃ₐ[F] E := { toFun := fun e => e.val invFun := fun e => ⟨e, by rw [hα]; exact IntermediateField.mem_top⟩ left_inv := fun _ => by ext; rfl right_inv := fun _ => rfl map_mul' := fun _ _ => rfl map_add' := fun _ _ => rfl commutes' := fun _ => rfl } have H : IsIntegral F α := IsGalois.integral F α have h_sep : (minpoly F α).Separable := IsGalois.separable F α have h_splits : (minpoly F α).Splits (algebraMap F E) := IsGalois.splits F α replace h_splits : Polynomial.Splits (algebraMap F F⟮α⟯) (minpoly F α) := by simpa using Polynomial.splits_comp_of_splits (algebraMap F E) iso.symm.toAlgHom.toRingHom h_splits rw [← LinearEquiv.finrank_eq iso.toLinearEquiv] rw [← IntermediateField.AdjoinSimple.card_aut_eq_finrank F E H h_sep h_splits] apply Fintype.card_congr apply Equiv.mk (fun ϕ => iso.trans (ϕ.trans iso.symm)) fun ϕ => iso.symm.trans (ϕ.trans iso) · intro ϕ; ext1; simp only [trans_apply, apply_symm_apply] · intro ϕ; ext1; simp only [trans_apply, symm_apply_apply]
/- Copyright (c) 2022 Floris van Doorn, Heather Macbeth. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn, Heather Macbeth -/ import Mathlib.Geometry.Manifold.ContMDiff.NormedSpace #align_import geometry.manifold.vector_bundle.fiberwise_linear from "leanprover-community/mathlib"@"be2c24f56783935652cefffb4bfca7e4b25d167e" /-! # The groupoid of smooth, fiberwise-linear maps This file contains preliminaries for the definition of a smooth vector bundle: an associated `StructureGroupoid`, the groupoid of `smoothFiberwiseLinear` functions. -/ noncomputable section open Set TopologicalSpace open scoped Manifold Topology /-! ### The groupoid of smooth, fiberwise-linear maps -/ variable {𝕜 B F : Type*} [TopologicalSpace B] variable [NontriviallyNormedField 𝕜] [NormedAddCommGroup F] [NormedSpace 𝕜 F] namespace FiberwiseLinear variable {φ φ' : B → F ≃L[𝕜] F} {U U' : Set B} /-- For `B` a topological space and `F` a `𝕜`-normed space, a map from `U : Set B` to `F ≃L[𝕜] F` determines a partial homeomorphism from `B × F` to itself by its action fiberwise. -/ def partialHomeomorph (φ : B → F ≃L[𝕜] F) (hU : IsOpen U) (hφ : ContinuousOn (fun x => φ x : B → F →L[𝕜] F) U) (h2φ : ContinuousOn (fun x => (φ x).symm : B → F →L[𝕜] F) U) : PartialHomeomorph (B × F) (B × F) where toFun x := (x.1, φ x.1 x.2) invFun x := (x.1, (φ x.1).symm x.2) source := U ×ˢ univ target := U ×ˢ univ map_source' _x hx := mk_mem_prod hx.1 (mem_univ _) map_target' _x hx := mk_mem_prod hx.1 (mem_univ _) left_inv' _ _ := Prod.ext rfl (ContinuousLinearEquiv.symm_apply_apply _ _) right_inv' _ _ := Prod.ext rfl (ContinuousLinearEquiv.apply_symm_apply _ _) open_source := hU.prod isOpen_univ open_target := hU.prod isOpen_univ continuousOn_toFun := have : ContinuousOn (fun p : B × F => ((φ p.1 : F →L[𝕜] F), p.2)) (U ×ˢ univ) := hφ.prod_map continuousOn_id continuousOn_fst.prod (isBoundedBilinearMap_apply.continuous.comp_continuousOn this) continuousOn_invFun := haveI : ContinuousOn (fun p : B × F => (((φ p.1).symm : F →L[𝕜] F), p.2)) (U ×ˢ univ) := h2φ.prod_map continuousOn_id continuousOn_fst.prod (isBoundedBilinearMap_apply.continuous.comp_continuousOn this) #align fiberwise_linear.local_homeomorph FiberwiseLinear.partialHomeomorph /-- Compute the composition of two partial homeomorphisms induced by fiberwise linear equivalences. -/ theorem trans_partialHomeomorph_apply (hU : IsOpen U) (hφ : ContinuousOn (fun x => φ x : B → F →L[𝕜] F) U) (h2φ : ContinuousOn (fun x => (φ x).symm : B → F →L[𝕜] F) U) (hU' : IsOpen U') (hφ' : ContinuousOn (fun x => φ' x : B → F →L[𝕜] F) U') (h2φ' : ContinuousOn (fun x => (φ' x).symm : B → F →L[𝕜] F) U') (b : B) (v : F) : (FiberwiseLinear.partialHomeomorph φ hU hφ h2φ ≫ₕ FiberwiseLinear.partialHomeomorph φ' hU' hφ' h2φ') ⟨b, v⟩ = ⟨b, φ' b (φ b v)⟩ := rfl #align fiberwise_linear.trans_local_homeomorph_apply FiberwiseLinear.trans_partialHomeomorph_apply /-- Compute the source of the composition of two partial homeomorphisms induced by fiberwise linear equivalences. -/
Mathlib/Geometry/Manifold/VectorBundle/FiberwiseLinear.lean
74
82
theorem source_trans_partialHomeomorph (hU : IsOpen U) (hφ : ContinuousOn (fun x => φ x : B → F →L[𝕜] F) U) (h2φ : ContinuousOn (fun x => (φ x).symm : B → F →L[𝕜] F) U) (hU' : IsOpen U') (hφ' : ContinuousOn (fun x => φ' x : B → F →L[𝕜] F) U') (h2φ' : ContinuousOn (fun x => (φ' x).symm : B → F →L[𝕜] F) U') : (FiberwiseLinear.partialHomeomorph φ hU hφ h2φ ≫ₕ FiberwiseLinear.partialHomeomorph φ' hU' hφ' h2φ').source = (U ∩ U') ×ˢ univ := by
dsimp only [FiberwiseLinear.partialHomeomorph]; mfld_set_tac
/- Copyright (c) 2020 Thomas Browning and Patrick Lutz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning, Patrick Lutz -/ import Mathlib.GroupTheory.Solvable import Mathlib.FieldTheory.PolynomialGaloisGroup import Mathlib.RingTheory.RootsOfUnity.Basic #align_import field_theory.abel_ruffini from "leanprover-community/mathlib"@"e3f4be1fcb5376c4948d7f095bec45350bfb9d1a" /-! # The Abel-Ruffini Theorem This file proves one direction of the Abel-Ruffini theorem, namely that if an element is solvable by radicals, then its minimal polynomial has solvable Galois group. ## Main definitions * `solvableByRad F E` : the intermediate field of solvable-by-radicals elements ## Main results * the Abel-Ruffini Theorem `solvableByRad.isSolvable'` : An irreducible polynomial with a root that is solvable by radicals has a solvable Galois group. -/ noncomputable section open scoped Classical Polynomial IntermediateField open Polynomial IntermediateField section AbelRuffini variable {F : Type*} [Field F] {E : Type*} [Field E] [Algebra F E] theorem gal_zero_isSolvable : IsSolvable (0 : F[X]).Gal := by infer_instance #align gal_zero_is_solvable gal_zero_isSolvable theorem gal_one_isSolvable : IsSolvable (1 : F[X]).Gal := by infer_instance #align gal_one_is_solvable gal_one_isSolvable
Mathlib/FieldTheory/AbelRuffini.lean
45
45
theorem gal_C_isSolvable (x : F) : IsSolvable (C x).Gal := by
infer_instance
/- Copyright (c) 2022 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Geometry.Manifold.SmoothManifoldWithCorners import Mathlib.Topology.Compactness.Paracompact import Mathlib.Topology.Metrizable.Urysohn #align_import geometry.manifold.metrizable from "leanprover-community/mathlib"@"d1bd9c5df2867c1cb463bc6364446d57bdd9f7f1" /-! # Metrizability of a σ-compact manifold In this file we show that a σ-compact Hausdorff topological manifold over a finite dimensional real vector space is metrizable. -/ open TopologicalSpace /-- A σ-compact Hausdorff topological manifold over a finite dimensional real vector space is metrizable. -/
Mathlib/Geometry/Manifold/Metrizable.lean
24
31
theorem ManifoldWithCorners.metrizableSpace {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] {H : Type*} [TopologicalSpace H] (I : ModelWithCorners ℝ E H) (M : Type*) [TopologicalSpace M] [ChartedSpace H M] [SigmaCompactSpace M] [T2Space M] : MetrizableSpace M := by
haveI := I.locallyCompactSpace; haveI := ChartedSpace.locallyCompactSpace H M haveI := I.secondCountableTopology haveI := ChartedSpace.secondCountable_of_sigma_compact H M exact metrizableSpace_of_t3_second_countable M
/- Copyright (c) 2020 Thomas Browning. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning -/ import Mathlib.Algebra.GCDMonoid.Multiset import Mathlib.Combinatorics.Enumerative.Partition import Mathlib.Data.List.Rotate import Mathlib.GroupTheory.Perm.Cycle.Factors import Mathlib.GroupTheory.Perm.Closure import Mathlib.Algebra.GCDMonoid.Nat import Mathlib.Tactic.NormNum.GCD #align_import group_theory.perm.cycle.type from "leanprover-community/mathlib"@"47adfab39a11a072db552f47594bf8ed2cf8a722" /-! # Cycle Types In this file we define the cycle type of a permutation. ## Main definitions - `Equiv.Perm.cycleType σ` where `σ` is a permutation of a `Fintype` - `Equiv.Perm.partition σ` where `σ` is a permutation of a `Fintype` ## Main results - `sum_cycleType` : The sum of `σ.cycleType` equals `σ.support.card` - `lcm_cycleType` : The lcm of `σ.cycleType` equals `orderOf σ` - `isConj_iff_cycleType_eq` : Two permutations are conjugate if and only if they have the same cycle type. - `exists_prime_orderOf_dvd_card`: For every prime `p` dividing the order of a finite group `G` there exists an element of order `p` in `G`. This is known as Cauchy's theorem. -/ namespace Equiv.Perm open Equiv List Multiset variable {α : Type*} [Fintype α] section CycleType variable [DecidableEq α] /-- The cycle type of a permutation -/ def cycleType (σ : Perm α) : Multiset ℕ := σ.cycleFactorsFinset.1.map (Finset.card ∘ support) #align equiv.perm.cycle_type Equiv.Perm.cycleType theorem cycleType_def (σ : Perm α) : σ.cycleType = σ.cycleFactorsFinset.1.map (Finset.card ∘ support) := rfl #align equiv.perm.cycle_type_def Equiv.Perm.cycleType_def theorem cycleType_eq' {σ : Perm α} (s : Finset (Perm α)) (h1 : ∀ f : Perm α, f ∈ s → f.IsCycle) (h2 : (s : Set (Perm α)).Pairwise Disjoint) (h0 : s.noncommProd id (h2.imp fun _ _ => Disjoint.commute) = σ) : σ.cycleType = s.1.map (Finset.card ∘ support) := by rw [cycleType_def] congr rw [cycleFactorsFinset_eq_finset] exact ⟨h1, h2, h0⟩ #align equiv.perm.cycle_type_eq' Equiv.Perm.cycleType_eq' theorem cycleType_eq {σ : Perm α} (l : List (Perm α)) (h0 : l.prod = σ) (h1 : ∀ σ : Perm α, σ ∈ l → σ.IsCycle) (h2 : l.Pairwise Disjoint) : σ.cycleType = l.map (Finset.card ∘ support) := by have hl : l.Nodup := nodup_of_pairwise_disjoint_cycles h1 h2 rw [cycleType_eq' l.toFinset] · simp [List.dedup_eq_self.mpr hl, (· ∘ ·)] · simpa using h1 · simpa [hl] using h2 · simp [hl, h0] #align equiv.perm.cycle_type_eq Equiv.Perm.cycleType_eq @[simp] -- Porting note: new attr theorem cycleType_eq_zero {σ : Perm α} : σ.cycleType = 0 ↔ σ = 1 := by simp [cycleType_def, cycleFactorsFinset_eq_empty_iff] #align equiv.perm.cycle_type_eq_zero Equiv.Perm.cycleType_eq_zero @[simp] -- Porting note: new attr theorem cycleType_one : (1 : Perm α).cycleType = 0 := cycleType_eq_zero.2 rfl #align equiv.perm.cycle_type_one Equiv.Perm.cycleType_one theorem card_cycleType_eq_zero {σ : Perm α} : Multiset.card σ.cycleType = 0 ↔ σ = 1 := by rw [card_eq_zero, cycleType_eq_zero] #align equiv.perm.card_cycle_type_eq_zero Equiv.Perm.card_cycleType_eq_zero theorem card_cycleType_pos {σ : Perm α} : 0 < Multiset.card σ.cycleType ↔ σ ≠ 1 := pos_iff_ne_zero.trans card_cycleType_eq_zero.not theorem two_le_of_mem_cycleType {σ : Perm α} {n : ℕ} (h : n ∈ σ.cycleType) : 2 ≤ n := by simp only [cycleType_def, ← Finset.mem_def, Function.comp_apply, Multiset.mem_map, mem_cycleFactorsFinset_iff] at h obtain ⟨_, ⟨hc, -⟩, rfl⟩ := h exact hc.two_le_card_support #align equiv.perm.two_le_of_mem_cycle_type Equiv.Perm.two_le_of_mem_cycleType theorem one_lt_of_mem_cycleType {σ : Perm α} {n : ℕ} (h : n ∈ σ.cycleType) : 1 < n := two_le_of_mem_cycleType h #align equiv.perm.one_lt_of_mem_cycle_type Equiv.Perm.one_lt_of_mem_cycleType theorem IsCycle.cycleType {σ : Perm α} (hσ : IsCycle σ) : σ.cycleType = [σ.support.card] := cycleType_eq [σ] (mul_one σ) (fun _τ hτ => (congr_arg IsCycle (List.mem_singleton.mp hτ)).mpr hσ) (List.pairwise_singleton Disjoint σ) #align equiv.perm.is_cycle.cycle_type Equiv.Perm.IsCycle.cycleType theorem card_cycleType_eq_one {σ : Perm α} : Multiset.card σ.cycleType = 1 ↔ σ.IsCycle := by rw [card_eq_one] simp_rw [cycleType_def, Multiset.map_eq_singleton, ← Finset.singleton_val, Finset.val_inj, cycleFactorsFinset_eq_singleton_iff] constructor · rintro ⟨_, _, ⟨h, -⟩, -⟩ exact h · intro h use σ.support.card, σ simp [h] #align equiv.perm.card_cycle_type_eq_one Equiv.Perm.card_cycleType_eq_one
Mathlib/GroupTheory/Perm/Cycle/Type.lean
122
126
theorem Disjoint.cycleType {σ τ : Perm α} (h : Disjoint σ τ) : (σ * τ).cycleType = σ.cycleType + τ.cycleType := by
rw [cycleType_def, cycleType_def, cycleType_def, h.cycleFactorsFinset_mul_eq_union, ← Multiset.map_add, Finset.union_val, Multiset.add_eq_union_iff_disjoint.mpr _] exact Finset.disjoint_val.2 h.disjoint_cycleFactorsFinset
/- Copyright (c) 2022 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" /-! # Dropping or taking from lists on the right Taking or removing element from the tail end of a list ## Main definitions - `rdrop n`: drop `n : ℕ` elements from the tail - `rtake n`: take `n : ℕ` elements from the tail - `rdropWhile p`: remove all the elements from the tail of a list until it finds the first element for which `p : α → Bool` returns false. This element and everything before is returned. - `rtakeWhile p`: Returns the longest terminal segment of a list for which `p : α → Bool` returns true. ## Implementation detail The two predicate-based methods operate by performing the regular "from-left" operation on `List.reverse`, followed by another `List.reverse`, so they are not the most performant. The other two rely on `List.length l` so they still traverse the list twice. One could construct another function that takes a `L : ℕ` and use `L - n`. Under a proof condition that `L = l.length`, the function would do the right thing. -/ -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List /-- Drop `n` elements from the tail end of a list. -/ def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ /-- Take `n` elements from the tail end of a list. -/ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH] #align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse @[simp] theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by simp [rtake_eq_reverse_take_reverse] #align list.rtake_concat_succ List.rtake_concat_succ /-- Drop elements from the tail end of a list that satisfy `p : α → Bool`. Implemented naively via `List.reverse` -/ def rdropWhile : List α := reverse (l.reverse.dropWhile p) #align list.rdrop_while List.rdropWhile @[simp] theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdropWhile, dropWhile] #align list.rdrop_while_nil List.rdropWhile_nil theorem rdropWhile_concat (x : α) : rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] := by simp only [rdropWhile, dropWhile, reverse_append, reverse_singleton, singleton_append] split_ifs with h <;> simp [h] #align list.rdrop_while_concat List.rdropWhile_concat @[simp] theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by rw [rdropWhile_concat, if_pos h] #align list.rdrop_while_concat_pos List.rdropWhile_concat_pos @[simp] theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by rw [rdropWhile_concat, if_neg h] #align list.rdrop_while_concat_neg List.rdropWhile_concat_neg theorem rdropWhile_singleton (x : α) : rdropWhile p [x] = if p x then [] else [x] := by rw [← nil_append [x], rdropWhile_concat, rdropWhile_nil] #align list.rdrop_while_singleton List.rdropWhile_singleton theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l).getLast hl) := by simp_rw [rdropWhile] rw [getLast_reverse] exact dropWhile_nthLe_zero_not _ _ _ #align list.rdrop_while_last_not List.rdropWhile_last_not theorem rdropWhile_prefix : l.rdropWhile p <+: l := by rw [← reverse_suffix, rdropWhile, reverse_reverse] exact dropWhile_suffix _ #align list.rdrop_while_prefix List.rdropWhile_prefix variable {p} {l} @[simp]
Mathlib/Data/List/DropRight.lean
139
139
theorem rdropWhile_eq_nil_iff : rdropWhile p l = [] ↔ ∀ x ∈ l, p x := by
simp [rdropWhile]
/- Copyright (c) 2021 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.Topology.Separation #align_import topology.sober from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977" /-! # Sober spaces A quasi-sober space is a topological space where every irreducible closed subset has a generic point. A sober space is a quasi-sober space where every irreducible closed subset has a *unique* generic point. This is if and only if the space is T0, and thus sober spaces can be stated via `[QuasiSober α] [T0Space α]`. ## Main definition * `IsGenericPoint` : `x` is the generic point of `S` if `S` is the closure of `x`. * `QuasiSober` : A space is quasi-sober if every irreducible closed subset has a generic point. -/ open Set variable {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] section genericPoint /-- `x` is a generic point of `S` if `S` is the closure of `x`. -/ def IsGenericPoint (x : α) (S : Set α) : Prop := closure ({x} : Set α) = S #align is_generic_point IsGenericPoint theorem isGenericPoint_def {x : α} {S : Set α} : IsGenericPoint x S ↔ closure ({x} : Set α) = S := Iff.rfl #align is_generic_point_def isGenericPoint_def theorem IsGenericPoint.def {x : α} {S : Set α} (h : IsGenericPoint x S) : closure ({x} : Set α) = S := h #align is_generic_point.def IsGenericPoint.def theorem isGenericPoint_closure {x : α} : IsGenericPoint x (closure ({x} : Set α)) := refl _ #align is_generic_point_closure isGenericPoint_closure variable {x y : α} {S U Z : Set α} theorem isGenericPoint_iff_specializes : IsGenericPoint x S ↔ ∀ y, x ⤳ y ↔ y ∈ S := by simp only [specializes_iff_mem_closure, IsGenericPoint, Set.ext_iff] #align is_generic_point_iff_specializes isGenericPoint_iff_specializes namespace IsGenericPoint theorem specializes_iff_mem (h : IsGenericPoint x S) : x ⤳ y ↔ y ∈ S := isGenericPoint_iff_specializes.1 h y #align is_generic_point.specializes_iff_mem IsGenericPoint.specializes_iff_mem protected theorem specializes (h : IsGenericPoint x S) (h' : y ∈ S) : x ⤳ y := h.specializes_iff_mem.2 h' #align is_generic_point.specializes IsGenericPoint.specializes protected theorem mem (h : IsGenericPoint x S) : x ∈ S := h.specializes_iff_mem.1 specializes_rfl #align is_generic_point.mem IsGenericPoint.mem protected theorem isClosed (h : IsGenericPoint x S) : IsClosed S := h.def ▸ isClosed_closure #align is_generic_point.is_closed IsGenericPoint.isClosed protected theorem isIrreducible (h : IsGenericPoint x S) : IsIrreducible S := h.def ▸ isIrreducible_singleton.closure #align is_generic_point.is_irreducible IsGenericPoint.isIrreducible protected theorem inseparable (h : IsGenericPoint x S) (h' : IsGenericPoint y S) : Inseparable x y := (h.specializes h'.mem).antisymm (h'.specializes h.mem) /-- In a T₀ space, each set has at most one generic point. -/ protected theorem eq [T0Space α] (h : IsGenericPoint x S) (h' : IsGenericPoint y S) : x = y := (h.inseparable h').eq #align is_generic_point.eq IsGenericPoint.eq theorem mem_open_set_iff (h : IsGenericPoint x S) (hU : IsOpen U) : x ∈ U ↔ (S ∩ U).Nonempty := ⟨fun h' => ⟨x, h.mem, h'⟩, fun ⟨_y, hyS, hyU⟩ => (h.specializes hyS).mem_open hU hyU⟩ #align is_generic_point.mem_open_set_iff IsGenericPoint.mem_open_set_iff
Mathlib/Topology/Sober.lean
92
93
theorem disjoint_iff (h : IsGenericPoint x S) (hU : IsOpen U) : Disjoint S U ↔ x ∉ U := by
rw [h.mem_open_set_iff hU, ← not_disjoint_iff_nonempty_inter, Classical.not_not]
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Algebra.Group.Submonoid.Membership import Mathlib.Algebra.Order.BigOperators.Group.List import Mathlib.Data.Set.Pointwise.SMul import Mathlib.Order.WellFoundedSet #align_import group_theory.submonoid.pointwise from "leanprover-community/mathlib"@"2bbc7e3884ba234309d2a43b19144105a753292e" /-! # Pointwise instances on `Submonoid`s and `AddSubmonoid`s This file provides: * `Submonoid.inv` * `AddSubmonoid.neg` and the actions * `Submonoid.pointwiseMulAction` * `AddSubmonoid.pointwiseMulAction` which matches the action of `Set.mulActionSet`. These are all available in the `Pointwise` locale. Additionally, it provides various degrees of monoid structure: * `AddSubmonoid.one` * `AddSubmonoid.mul` * `AddSubmonoid.mulOneClass` * `AddSubmonoid.semigroup` * `AddSubmonoid.monoid` which is available globally to match the monoid structure implied by `Submodule.idemSemiring`. ## Implementation notes Most of the lemmas in this file are direct copies of lemmas from `Algebra/Pointwise.lean`. While the statements of these lemmas are defeq, we repeat them here due to them not being syntactically equal. Before adding new lemmas here, consider if they would also apply to the action on `Set`s. -/ open Set Pointwise variable {α : Type*} {G : Type*} {M : Type*} {R : Type*} {A : Type*} variable [Monoid M] [AddMonoid A] /-! Some lemmas about pointwise multiplication and submonoids. Ideally we put these in `GroupTheory.Submonoid.Basic`, but currently we cannot because that file is imported by this. -/ namespace Submonoid variable {s t u : Set M} @[to_additive] theorem mul_subset {S : Submonoid M} (hs : s ⊆ S) (ht : t ⊆ S) : s * t ⊆ S := mul_subset_iff.2 fun _x hx _y hy ↦ mul_mem (hs hx) (ht hy) #align submonoid.mul_subset Submonoid.mul_subset #align add_submonoid.add_subset AddSubmonoid.add_subset @[to_additive] theorem mul_subset_closure (hs : s ⊆ u) (ht : t ⊆ u) : s * t ⊆ Submonoid.closure u := mul_subset (Subset.trans hs Submonoid.subset_closure) (Subset.trans ht Submonoid.subset_closure) #align submonoid.mul_subset_closure Submonoid.mul_subset_closure #align add_submonoid.add_subset_closure AddSubmonoid.add_subset_closure @[to_additive] theorem coe_mul_self_eq (s : Submonoid M) : (s : Set M) * s = s := by ext x refine ⟨?_, fun h => ⟨x, h, 1, s.one_mem, mul_one x⟩⟩ rintro ⟨a, ha, b, hb, rfl⟩ exact s.mul_mem ha hb #align submonoid.coe_mul_self_eq Submonoid.coe_mul_self_eq #align add_submonoid.coe_add_self_eq AddSubmonoid.coe_add_self_eq @[to_additive] theorem closure_mul_le (S T : Set M) : closure (S * T) ≤ closure S ⊔ closure T := sInf_le fun _x ⟨_s, hs, _t, ht, hx⟩ => hx ▸ (closure S ⊔ closure T).mul_mem (SetLike.le_def.mp le_sup_left <| subset_closure hs) (SetLike.le_def.mp le_sup_right <| subset_closure ht) #align submonoid.closure_mul_le Submonoid.closure_mul_le #align add_submonoid.closure_add_le AddSubmonoid.closure_add_le @[to_additive] theorem sup_eq_closure_mul (H K : Submonoid M) : H ⊔ K = closure ((H : Set M) * (K : Set M)) := le_antisymm (sup_le (fun h hh => subset_closure ⟨h, hh, 1, K.one_mem, mul_one h⟩) fun k hk => subset_closure ⟨1, H.one_mem, k, hk, one_mul k⟩) ((closure_mul_le _ _).trans <| by rw [closure_eq, closure_eq]) #align submonoid.sup_eq_closure Submonoid.sup_eq_closure_mul #align add_submonoid.sup_eq_closure AddSubmonoid.sup_eq_closure_add @[to_additive]
Mathlib/Algebra/Group/Submonoid/Pointwise.lean
98
107
theorem pow_smul_mem_closure_smul {N : Type*} [CommMonoid N] [MulAction M N] [IsScalarTower M N N] (r : M) (s : Set N) {x : N} (hx : x ∈ closure s) : ∃ n : ℕ, r ^ n • x ∈ closure (r • s) := by
refine @closure_induction N _ s (fun x : N => ∃ n : ℕ, r ^ n • x ∈ closure (r • s)) _ hx ?_ ?_ ?_ · intro x hx exact ⟨1, subset_closure ⟨_, hx, by rw [pow_one]⟩⟩ · exact ⟨0, by simpa using one_mem _⟩ · rintro x y ⟨nx, hx⟩ ⟨ny, hy⟩ use ny + nx rw [pow_add, mul_smul, ← smul_mul_assoc, mul_comm, ← smul_mul_assoc] exact mul_mem hy hx
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker -/ import Mathlib.Algebra.Polynomial.Degree.Definitions import Mathlib.Algebra.Polynomial.Induction #align_import data.polynomial.eval from "leanprover-community/mathlib"@"728baa2f54e6062c5879a3e397ac6bac323e506f" /-! # Theory of univariate polynomials The main defs here are `eval₂`, `eval`, and `map`. We give several lemmas about their interaction with each other and with module operations. -/ set_option linter.uppercaseLean3 false noncomputable section open Finset AddMonoidAlgebra open Polynomial namespace Polynomial universe u v w y variable {R : Type u} {S : Type v} {T : Type w} {ι : Type y} {a b : R} {m n : ℕ} section Semiring variable [Semiring R] {p q r : R[X]} section variable [Semiring S] variable (f : R →+* S) (x : S) /-- Evaluate a polynomial `p` given a ring hom `f` from the scalar ring to the target and a value `x` for the variable in the target -/ irreducible_def eval₂ (p : R[X]) : S := p.sum fun e a => f a * x ^ e #align polynomial.eval₂ Polynomial.eval₂ theorem eval₂_eq_sum {f : R →+* S} {x : S} : p.eval₂ f x = p.sum fun e a => f a * x ^ e := by rw [eval₂_def] #align polynomial.eval₂_eq_sum Polynomial.eval₂_eq_sum theorem eval₂_congr {R S : Type*} [Semiring R] [Semiring S] {f g : R →+* S} {s t : S} {φ ψ : R[X]} : f = g → s = t → φ = ψ → eval₂ f s φ = eval₂ g t ψ := by rintro rfl rfl rfl; rfl #align polynomial.eval₂_congr Polynomial.eval₂_congr @[simp]
Mathlib/Algebra/Polynomial/Eval.lean
58
61
theorem eval₂_at_zero : p.eval₂ f 0 = f (coeff p 0) := by
simp (config := { contextual := true }) only [eval₂_eq_sum, zero_pow_eq, mul_ite, mul_zero, mul_one, sum, Classical.not_not, mem_support_iff, sum_ite_eq', ite_eq_left_iff, RingHom.map_zero, imp_true_iff, eq_self_iff_true]
/- Copyright (c) 2022 Violeta Hernández Palacios. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Violeta Hernández Palacios -/ import Mathlib.Order.SuccPred.Basic import Mathlib.Order.BoundedOrder #align_import order.succ_pred.limit from "leanprover-community/mathlib"@"1e05171a5e8cf18d98d9cf7b207540acb044acae" /-! # Successor and predecessor limits We define the predicate `Order.IsSuccLimit` for "successor limits", values that don't cover any others. They are so named since they can't be the successors of anything smaller. We define `Order.IsPredLimit` analogously, and prove basic results. ## Todo The plan is to eventually replace `Ordinal.IsLimit` and `Cardinal.IsLimit` with the common predicate `Order.IsSuccLimit`. -/ variable {α : Type*} namespace Order open Function Set OrderDual /-! ### Successor limits -/ section LT variable [LT α] /-- A successor limit is a value that doesn't cover any other. It's so named because in a successor order, a successor limit can't be the successor of anything smaller. -/ def IsSuccLimit (a : α) : Prop := ∀ b, ¬b ⋖ a #align order.is_succ_limit Order.IsSuccLimit theorem not_isSuccLimit_iff_exists_covBy (a : α) : ¬IsSuccLimit a ↔ ∃ b, b ⋖ a := by simp [IsSuccLimit] #align order.not_is_succ_limit_iff_exists_covby Order.not_isSuccLimit_iff_exists_covBy @[simp] theorem isSuccLimit_of_dense [DenselyOrdered α] (a : α) : IsSuccLimit a := fun _ => not_covBy #align order.is_succ_limit_of_dense Order.isSuccLimit_of_dense end LT section Preorder variable [Preorder α] {a : α} protected theorem _root_.IsMin.isSuccLimit : IsMin a → IsSuccLimit a := fun h _ hab => not_isMin_of_lt hab.lt h #align is_min.is_succ_limit IsMin.isSuccLimit theorem isSuccLimit_bot [OrderBot α] : IsSuccLimit (⊥ : α) := IsMin.isSuccLimit isMin_bot #align order.is_succ_limit_bot Order.isSuccLimit_bot variable [SuccOrder α] protected theorem IsSuccLimit.isMax (h : IsSuccLimit (succ a)) : IsMax a := by by_contra H exact h a (covBy_succ_of_not_isMax H) #align order.is_succ_limit.is_max Order.IsSuccLimit.isMax theorem not_isSuccLimit_succ_of_not_isMax (ha : ¬IsMax a) : ¬IsSuccLimit (succ a) := by contrapose! ha exact ha.isMax #align order.not_is_succ_limit_succ_of_not_is_max Order.not_isSuccLimit_succ_of_not_isMax section NoMaxOrder variable [NoMaxOrder α] theorem IsSuccLimit.succ_ne (h : IsSuccLimit a) (b : α) : succ b ≠ a := by rintro rfl exact not_isMax _ h.isMax #align order.is_succ_limit.succ_ne Order.IsSuccLimit.succ_ne @[simp] theorem not_isSuccLimit_succ (a : α) : ¬IsSuccLimit (succ a) := fun h => h.succ_ne _ rfl #align order.not_is_succ_limit_succ Order.not_isSuccLimit_succ end NoMaxOrder section IsSuccArchimedean variable [IsSuccArchimedean α] theorem IsSuccLimit.isMin_of_noMax [NoMaxOrder α] (h : IsSuccLimit a) : IsMin a := fun b hb => by rcases hb.exists_succ_iterate with ⟨_ | n, rfl⟩ · exact le_rfl · rw [iterate_succ_apply'] at h exact (not_isSuccLimit_succ _ h).elim #align order.is_succ_limit.is_min_of_no_max Order.IsSuccLimit.isMin_of_noMax @[simp] theorem isSuccLimit_iff_of_noMax [NoMaxOrder α] : IsSuccLimit a ↔ IsMin a := ⟨IsSuccLimit.isMin_of_noMax, IsMin.isSuccLimit⟩ #align order.is_succ_limit_iff_of_no_max Order.isSuccLimit_iff_of_noMax theorem not_isSuccLimit_of_noMax [NoMinOrder α] [NoMaxOrder α] : ¬IsSuccLimit a := by simp #align order.not_is_succ_limit_of_no_max Order.not_isSuccLimit_of_noMax end IsSuccArchimedean end Preorder section PartialOrder variable [PartialOrder α] [SuccOrder α] {a b : α} {C : α → Sort*} theorem isSuccLimit_of_succ_ne (h : ∀ b, succ b ≠ a) : IsSuccLimit a := fun b hba => h b (CovBy.succ_eq hba) #align order.is_succ_limit_of_succ_ne Order.isSuccLimit_of_succ_ne theorem not_isSuccLimit_iff : ¬IsSuccLimit a ↔ ∃ b, ¬IsMax b ∧ succ b = a := by rw [not_isSuccLimit_iff_exists_covBy] refine exists_congr fun b => ⟨fun hba => ⟨hba.lt.not_isMax, (CovBy.succ_eq hba)⟩, ?_⟩ rintro ⟨h, rfl⟩ exact covBy_succ_of_not_isMax h #align order.not_is_succ_limit_iff Order.not_isSuccLimit_iff /-- See `not_isSuccLimit_iff` for a version that states that `a` is a successor of a value other than itself. -/ theorem mem_range_succ_of_not_isSuccLimit (h : ¬IsSuccLimit a) : a ∈ range (@succ α _ _) := by cases' not_isSuccLimit_iff.1 h with b hb exact ⟨b, hb.2⟩ #align order.mem_range_succ_of_not_is_succ_limit Order.mem_range_succ_of_not_isSuccLimit theorem isSuccLimit_of_succ_lt (H : ∀ a < b, succ a < b) : IsSuccLimit b := fun a hab => (H a hab.lt).ne (CovBy.succ_eq hab) #align order.is_succ_limit_of_succ_lt Order.isSuccLimit_of_succ_lt
Mathlib/Order/SuccPred/Limit.lean
144
150
theorem IsSuccLimit.succ_lt (hb : IsSuccLimit b) (ha : a < b) : succ a < b := by
by_cases h : IsMax a · rwa [h.succ_eq] · rw [lt_iff_le_and_ne, succ_le_iff_of_not_isMax h] refine ⟨ha, fun hab => ?_⟩ subst hab exact (h hb.isMax).elim
/- Copyright (c) 2024 Josha Dekker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Josha Dekker, Devon Tuma, Kexing Ying -/ import Mathlib.Probability.Notation import Mathlib.Probability.Density import Mathlib.Probability.ConditionalProbability import Mathlib.Probability.ProbabilityMassFunction.Constructions /-! # Uniform distributions and probability mass functions This file defines two related notions of uniform distributions, which will be unified in the future. # Uniform distributions Defines the uniform distribution for any set with finite measure. ## Main definitions * `IsUniform X s ℙ μ` : A random variable `X` has uniform distribution on `s` under `ℙ` if the push-forward measure agrees with the rescaled restricted measure `μ`. # Uniform probability mass functions This file defines a number of uniform `PMF` distributions from various inputs, uniformly drawing from the corresponding object. ## Main definitions `PMF.uniformOfFinset` gives each element in the set equal probability, with `0` probability for elements not in the set. `PMF.uniformOfFintype` gives all elements equal probability, equal to the inverse of the size of the `Fintype`. `PMF.ofMultiset` draws randomly from the given `Multiset`, treating duplicate values as distinct. Each probability is given by the count of the element divided by the size of the `Multiset` # To Do: * Refactor the `PMF` definitions to come from a `uniformMeasure` on a `Finset`/`Fintype`/`Multiset`. -/ open scoped Classical MeasureTheory NNReal ENNReal -- TODO: We can't `open ProbabilityTheory` without opening the `ProbabilityTheory` locale :( open TopologicalSpace MeasureTheory.Measure PMF noncomputable section namespace MeasureTheory variable {E : Type*} [MeasurableSpace E] {m : Measure E} {μ : Measure E} namespace pdf variable {Ω : Type*} variable {_ : MeasurableSpace Ω} {ℙ : Measure Ω} /-- A random variable `X` has uniform distribution on `s` if its push-forward measure is `(μ s)⁻¹ • μ.restrict s`. -/ def IsUniform (X : Ω → E) (s : Set E) (ℙ : Measure Ω) (μ : Measure E := by volume_tac) := map X ℙ = ProbabilityTheory.cond μ s #align measure_theory.pdf.is_uniform MeasureTheory.pdf.IsUniform namespace IsUniform theorem aemeasurable {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞) (hu : IsUniform X s ℙ μ) : AEMeasurable X ℙ := by dsimp [IsUniform, ProbabilityTheory.cond] at hu by_contra h rw [map_of_not_aemeasurable h] at hu apply zero_ne_one' ℝ≥0∞ calc 0 = (0 : Measure E) Set.univ := rfl _ = _ := by rw [hu, smul_apply, restrict_apply MeasurableSet.univ, Set.univ_inter, smul_eq_mul, ENNReal.inv_mul_cancel hns hnt] theorem absolutelyContinuous {X : Ω → E} {s : Set E} (hu : IsUniform X s ℙ μ) : map X ℙ ≪ μ := by rw [hu]; exact ProbabilityTheory.cond_absolutelyContinuous theorem measure_preimage {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞) (hu : IsUniform X s ℙ μ) {A : Set E} (hA : MeasurableSet A) : ℙ (X ⁻¹' A) = μ (s ∩ A) / μ s := by rwa [← map_apply_of_aemeasurable (hu.aemeasurable hns hnt) hA, hu, ProbabilityTheory.cond_apply', ENNReal.div_eq_inv_mul] #align measure_theory.pdf.is_uniform.measure_preimage MeasureTheory.pdf.IsUniform.measure_preimage theorem isProbabilityMeasure {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞) (hu : IsUniform X s ℙ μ) : IsProbabilityMeasure ℙ := ⟨by have : X ⁻¹' Set.univ = Set.univ := Set.preimage_univ rw [← this, hu.measure_preimage hns hnt MeasurableSet.univ, Set.inter_univ, ENNReal.div_self hns hnt]⟩ #align measure_theory.pdf.is_uniform.is_probability_measure MeasureTheory.pdf.IsUniform.isProbabilityMeasure theorem toMeasurable_iff {X : Ω → E} {s : Set E} : IsUniform X (toMeasurable μ s) ℙ μ ↔ IsUniform X s ℙ μ := by unfold IsUniform rw [ProbabilityTheory.cond_toMeasurable_eq] protected theorem toMeasurable {X : Ω → E} {s : Set E} (hu : IsUniform X s ℙ μ) : IsUniform X (toMeasurable μ s) ℙ μ := by unfold IsUniform at * rwa [ProbabilityTheory.cond_toMeasurable_eq]
Mathlib/Probability/Distributions/Uniform.lean
105
111
theorem hasPDF {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞) (hu : IsUniform X s ℙ μ) : HasPDF X ℙ μ := by
let t := toMeasurable μ s apply hasPDF_of_map_eq_withDensity (hu.aemeasurable hns hnt) (t.indicator ((μ t)⁻¹ • 1)) <| (measurable_one.aemeasurable.const_smul (μ t)⁻¹).indicator (measurableSet_toMeasurable μ s) rw [hu, withDensity_indicator (measurableSet_toMeasurable μ s), withDensity_smul _ measurable_one, withDensity_one, restrict_toMeasurable hnt, measure_toMeasurable, ProbabilityTheory.cond]
/- Copyright (c) 2019 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.LinearAlgebra.FiniteDimensional import Mathlib.RingTheory.IntegralClosure import Mathlib.RingTheory.Polynomial.IntegralNormalization #align_import ring_theory.algebraic from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # Algebraic elements and algebraic extensions An element of an R-algebra is algebraic over R if it is the root of a nonzero polynomial. An R-algebra is algebraic over R if and only if all its elements are algebraic over R. The main result in this file proves transitivity of algebraicity: a tower of algebraic field extensions is algebraic. -/ universe u v w open scoped Classical open Polynomial section variable (R : Type u) {A : Type v} [CommRing R] [Ring A] [Algebra R A] /-- An element of an R-algebra is algebraic over R if it is a root of a nonzero polynomial with coefficients in R. -/ def IsAlgebraic (x : A) : Prop := ∃ p : R[X], p ≠ 0 ∧ aeval x p = 0 #align is_algebraic IsAlgebraic /-- An element of an R-algebra is transcendental over R if it is not algebraic over R. -/ def Transcendental (x : A) : Prop := ¬IsAlgebraic R x #align transcendental Transcendental theorem is_transcendental_of_subsingleton [Subsingleton R] (x : A) : Transcendental R x := fun ⟨p, h, _⟩ => h <| Subsingleton.elim p 0 #align is_transcendental_of_subsingleton is_transcendental_of_subsingleton variable {R} /-- A subalgebra is algebraic if all its elements are algebraic. -/ nonrec def Subalgebra.IsAlgebraic (S : Subalgebra R A) : Prop := ∀ x ∈ S, IsAlgebraic R x #align subalgebra.is_algebraic Subalgebra.IsAlgebraic variable (R A) /-- An algebra is algebraic if all its elements are algebraic. -/ protected class Algebra.IsAlgebraic : Prop := isAlgebraic : ∀ x : A, IsAlgebraic R x #align algebra.is_algebraic Algebra.IsAlgebraic variable {R A} lemma Algebra.isAlgebraic_def : Algebra.IsAlgebraic R A ↔ ∀ x : A, IsAlgebraic R x := ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩ /-- A subalgebra is algebraic if and only if it is algebraic as an algebra. -/ theorem Subalgebra.isAlgebraic_iff (S : Subalgebra R A) : S.IsAlgebraic ↔ @Algebra.IsAlgebraic R S _ _ S.algebra := by delta Subalgebra.IsAlgebraic rw [Subtype.forall', Algebra.isAlgebraic_def] refine forall_congr' fun x => exists_congr fun p => and_congr Iff.rfl ?_ have h : Function.Injective S.val := Subtype.val_injective conv_rhs => rw [← h.eq_iff, AlgHom.map_zero] rw [← aeval_algHom_apply, S.val_apply] #align subalgebra.is_algebraic_iff Subalgebra.isAlgebraic_iff /-- An algebra is algebraic if and only if it is algebraic as a subalgebra. -/ theorem Algebra.isAlgebraic_iff : Algebra.IsAlgebraic R A ↔ (⊤ : Subalgebra R A).IsAlgebraic := by delta Subalgebra.IsAlgebraic simp only [Algebra.isAlgebraic_def, Algebra.mem_top, forall_prop_of_true, iff_self_iff] #align algebra.is_algebraic_iff Algebra.isAlgebraic_iff theorem isAlgebraic_iff_not_injective {x : A} : IsAlgebraic R x ↔ ¬Function.Injective (Polynomial.aeval x : R[X] →ₐ[R] A) := by simp only [IsAlgebraic, injective_iff_map_eq_zero, not_forall, and_comm, exists_prop] #align is_algebraic_iff_not_injective isAlgebraic_iff_not_injective end section zero_ne_one variable {R : Type u} {S : Type*} {A : Type v} [CommRing R] variable [CommRing S] [Ring A] [Algebra R A] [Algebra R S] [Algebra S A] variable [IsScalarTower R S A] /-- An integral element of an algebra is algebraic. -/ theorem IsIntegral.isAlgebraic [Nontrivial R] {x : A} : IsIntegral R x → IsAlgebraic R x := fun ⟨p, hp, hpx⟩ => ⟨p, hp.ne_zero, hpx⟩ #align is_integral.is_algebraic IsIntegral.isAlgebraic instance Algebra.IsIntegral.isAlgebraic [Nontrivial R] [Algebra.IsIntegral R A] : Algebra.IsAlgebraic R A := ⟨fun a ↦ (Algebra.IsIntegral.isIntegral a).isAlgebraic⟩ theorem isAlgebraic_zero [Nontrivial R] : IsAlgebraic R (0 : A) := ⟨_, X_ne_zero, aeval_X 0⟩ #align is_algebraic_zero isAlgebraic_zero /-- An element of `R` is algebraic, when viewed as an element of the `R`-algebra `A`. -/ theorem isAlgebraic_algebraMap [Nontrivial R] (x : R) : IsAlgebraic R (algebraMap R A x) := ⟨_, X_sub_C_ne_zero x, by rw [_root_.map_sub, aeval_X, aeval_C, sub_self]⟩ #align is_algebraic_algebra_map isAlgebraic_algebraMap theorem isAlgebraic_one [Nontrivial R] : IsAlgebraic R (1 : A) := by rw [← _root_.map_one (algebraMap R A)] exact isAlgebraic_algebraMap 1 #align is_algebraic_one isAlgebraic_one theorem isAlgebraic_nat [Nontrivial R] (n : ℕ) : IsAlgebraic R (n : A) := by rw [← map_natCast (_ : R →+* A) n] exact isAlgebraic_algebraMap (Nat.cast n) #align is_algebraic_nat isAlgebraic_nat theorem isAlgebraic_int [Nontrivial R] (n : ℤ) : IsAlgebraic R (n : A) := by rw [← _root_.map_intCast (algebraMap R A)] exact isAlgebraic_algebraMap (Int.cast n) #align is_algebraic_int isAlgebraic_int
Mathlib/RingTheory/Algebraic.lean
128
131
theorem isAlgebraic_rat (R : Type u) {A : Type v} [DivisionRing A] [Field R] [Algebra R A] (n : ℚ) : IsAlgebraic R (n : A) := by
rw [← map_ratCast (algebraMap R A)] exact isAlgebraic_algebraMap (Rat.cast n)
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Data.Complex.Exponential import Mathlib.Data.Complex.Module import Mathlib.RingTheory.Polynomial.Chebyshev #align_import analysis.special_functions.trigonometric.chebyshev from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" /-! # Multiple angle formulas in terms of Chebyshev polynomials This file gives the trigonometric characterizations of Chebyshev polynomials, for both the real (`Real.cos`) and complex (`Complex.cos`) cosine. -/ set_option linter.uppercaseLean3 false namespace Polynomial.Chebyshev open Polynomial variable {R A : Type*} [CommRing R] [CommRing A] [Algebra R A] @[simp] theorem aeval_T (x : A) (n : ℤ) : aeval x (T R n) = (T A n).eval x := by rw [aeval_def, eval₂_eq_eval_map, map_T] #align polynomial.chebyshev.aeval_T Polynomial.Chebyshev.aeval_T @[simp] theorem aeval_U (x : A) (n : ℤ) : aeval x (U R n) = (U A n).eval x := by rw [aeval_def, eval₂_eq_eval_map, map_U] #align polynomial.chebyshev.aeval_U Polynomial.Chebyshev.aeval_U @[simp] theorem algebraMap_eval_T (x : R) (n : ℤ) : algebraMap R A ((T R n).eval x) = (T A n).eval (algebraMap R A x) := by rw [← aeval_algebraMap_apply_eq_algebraMap_eval, aeval_T] #align polynomial.chebyshev.algebra_map_eval_T Polynomial.Chebyshev.algebraMap_eval_T @[simp] theorem algebraMap_eval_U (x : R) (n : ℤ) : algebraMap R A ((U R n).eval x) = (U A n).eval (algebraMap R A x) := by rw [← aeval_algebraMap_apply_eq_algebraMap_eval, aeval_U] #align polynomial.chebyshev.algebra_map_eval_U Polynomial.Chebyshev.algebraMap_eval_U -- Porting note: added type ascriptions to the statement @[simp, norm_cast] theorem complex_ofReal_eval_T : ∀ (x : ℝ) n, (((T ℝ n).eval x : ℝ) : ℂ) = (T ℂ n).eval (x : ℂ) := @algebraMap_eval_T ℝ ℂ _ _ _ #align polynomial.chebyshev.complex_of_real_eval_T Polynomial.Chebyshev.complex_ofReal_eval_T -- Porting note: added type ascriptions to the statement @[simp, norm_cast] theorem complex_ofReal_eval_U : ∀ (x : ℝ) n, (((U ℝ n).eval x : ℝ) : ℂ) = (U ℂ n).eval (x : ℂ) := @algebraMap_eval_U ℝ ℂ _ _ _ #align polynomial.chebyshev.complex_of_real_eval_U Polynomial.Chebyshev.complex_ofReal_eval_U /-! ### Complex versions -/ section Complex open Complex variable (θ : ℂ) /-- The `n`-th Chebyshev polynomial of the first kind evaluates on `cos θ` to the value `cos (n * θ)`. -/ @[simp] theorem T_complex_cos (n : ℤ) : (T ℂ n).eval (cos θ) = cos (n * θ) := by induction n using Polynomial.Chebyshev.induct with | zero => simp | one => simp | add_two n ih1 ih2 => simp only [T_add_two, eval_sub, eval_mul, eval_X, eval_ofNat, ih1, ih2, sub_eq_iff_eq_add, cos_add_cos] push_cast ring_nf | neg_add_one n ih1 ih2 => simp only [T_sub_one, eval_sub, eval_mul, eval_X, eval_ofNat, ih1, ih2, sub_eq_iff_eq_add', cos_add_cos] push_cast ring_nf #align polynomial.chebyshev.T_complex_cos Polynomial.Chebyshev.T_complex_cos /-- The `n`-th Chebyshev polynomial of the second kind evaluates on `cos θ` to the value `sin ((n + 1) * θ) / sin θ`. -/ @[simp]
Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev.lean
92
105
theorem U_complex_cos (n : ℤ) : (U ℂ n).eval (cos θ) * sin θ = sin ((n + 1) * θ) := by
induction n using Polynomial.Chebyshev.induct with | zero => simp | one => simp [one_add_one_eq_two, sin_two_mul]; ring | add_two n ih1 ih2 => simp only [U_add_two, add_sub_cancel_right, eval_sub, eval_mul, eval_X, eval_ofNat, sub_mul, mul_assoc, ih1, ih2, sub_eq_iff_eq_add, sin_add_sin] push_cast ring_nf | neg_add_one n ih1 ih2 => simp only [U_sub_one, add_sub_cancel_right, eval_sub, eval_mul, eval_X, eval_ofNat, sub_mul, mul_assoc, ih1, ih2, sub_eq_iff_eq_add', sin_add_sin] push_cast ring_nf
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Init.Control.Combinators import Mathlib.Init.Function import Mathlib.Tactic.CasesM import Mathlib.Tactic.Attr.Core #align_import control.basic from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" /-! Extends the theory on functors, applicatives and monads. -/ universe u v w variable {α β γ : Type u} section Functor variable {f : Type u → Type v} [Functor f] [LawfulFunctor f] @[functor_norm] theorem Functor.map_map (m : α → β) (g : β → γ) (x : f α) : g <$> m <$> x = (g ∘ m) <$> x := (comp_map _ _ _).symm #align functor.map_map Functor.map_mapₓ -- order of implicits #align id_map' id_map'ₓ -- order of implicits end Functor section Applicative variable {F : Type u → Type v} [Applicative F] /-- A generalization of `List.zipWith` which combines list elements with an `Applicative`. -/ def zipWithM {α₁ α₂ φ : Type u} (f : α₁ → α₂ → F φ) : ∀ (_ : List α₁) (_ : List α₂), F (List φ) | x :: xs, y :: ys => (· :: ·) <$> f x y <*> zipWithM f xs ys | _, _ => pure [] #align mzip_with zipWithM /-- Like `zipWithM` but evaluates the result as it traverses the lists using `*>`. -/ def zipWithM' (f : α → β → F γ) : List α → List β → F PUnit | x :: xs, y :: ys => f x y *> zipWithM' f xs ys | [], _ => pure PUnit.unit | _, [] => pure PUnit.unit #align mzip_with' zipWithM' variable [LawfulApplicative F] @[simp] theorem pure_id'_seq (x : F α) : (pure fun x => x) <*> x = x := pure_id_seq x #align pure_id'_seq pure_id'_seq @[functor_norm] theorem seq_map_assoc (x : F (α → β)) (f : γ → α) (y : F γ) : x <*> f <$> y = (· ∘ f) <$> x <*> y := by simp only [← pure_seq] simp only [seq_assoc, Function.comp, seq_pure, ← comp_map] simp [pure_seq] #align seq_map_assoc seq_map_assoc @[functor_norm]
Mathlib/Control/Basic.lean
68
70
theorem map_seq (f : β → γ) (x : F (α → β)) (y : F α) : f <$> (x <*> y) = (f ∘ ·) <$> x <*> y := by
simp only [← pure_seq]; simp [seq_assoc]
/- Copyright (c) 2021 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.GroupTheory.QuotientGroup import Mathlib.RingTheory.DedekindDomain.Ideal #align_import ring_theory.class_group from "leanprover-community/mathlib"@"565eb991e264d0db702722b4bde52ee5173c9950" /-! # The ideal class group This file defines the ideal class group `ClassGroup R` of fractional ideals of `R` inside its field of fractions. ## Main definitions - `toPrincipalIdeal` sends an invertible `x : K` to an invertible fractional ideal - `ClassGroup` is the quotient of invertible fractional ideals modulo `toPrincipalIdeal.range` - `ClassGroup.mk0` sends a nonzero integral ideal in a Dedekind domain to its class ## Main results - `ClassGroup.mk0_eq_mk0_iff` shows the equivalence with the "classical" definition, where `I ~ J` iff `x I = y J` for `x y ≠ (0 : R)` ## Implementation details The definition of `ClassGroup R` involves `FractionRing R`. However, the API should be completely identical no matter the choice of field of fractions for `R`. -/ variable {R K L : Type*} [CommRing R] variable [Field K] [Field L] [DecidableEq L] variable [Algebra R K] [IsFractionRing R K] variable [Algebra K L] [FiniteDimensional K L] variable [Algebra R L] [IsScalarTower R K L] open scoped nonZeroDivisors open IsLocalization IsFractionRing FractionalIdeal Units section variable (R K) /-- `toPrincipalIdeal R K x` sends `x ≠ 0 : K` to the fractional `R`-ideal generated by `x` -/ irreducible_def toPrincipalIdeal : Kˣ →* (FractionalIdeal R⁰ K)ˣ := { toFun := fun x => ⟨spanSingleton _ x, spanSingleton _ x⁻¹, by simp only [spanSingleton_one, Units.mul_inv', spanSingleton_mul_spanSingleton], by simp only [spanSingleton_one, Units.inv_mul', spanSingleton_mul_spanSingleton]⟩ map_mul' := fun x y => ext (by simp only [Units.val_mk, Units.val_mul, spanSingleton_mul_spanSingleton]) map_one' := ext (by simp only [spanSingleton_one, Units.val_mk, Units.val_one]) } #align to_principal_ideal toPrincipalIdeal variable {R K} @[simp] theorem coe_toPrincipalIdeal (x : Kˣ) : (toPrincipalIdeal R K x : FractionalIdeal R⁰ K) = spanSingleton _ (x : K) := by simp only [toPrincipalIdeal]; rfl #align coe_to_principal_ideal coe_toPrincipalIdeal @[simp] theorem toPrincipalIdeal_eq_iff {I : (FractionalIdeal R⁰ K)ˣ} {x : Kˣ} : toPrincipalIdeal R K x = I ↔ spanSingleton R⁰ (x : K) = I := by simp only [toPrincipalIdeal]; exact Units.ext_iff #align to_principal_ideal_eq_iff toPrincipalIdeal_eq_iff theorem mem_principal_ideals_iff {I : (FractionalIdeal R⁰ K)ˣ} : I ∈ (toPrincipalIdeal R K).range ↔ ∃ x : K, spanSingleton R⁰ x = I := by simp only [MonoidHom.mem_range, toPrincipalIdeal_eq_iff] constructor <;> rintro ⟨x, hx⟩ · exact ⟨x, hx⟩ · refine ⟨Units.mk0 x ?_, hx⟩ rintro rfl simp [I.ne_zero.symm] at hx #align mem_principal_ideals_iff mem_principal_ideals_iff instance PrincipalIdeals.normal : (toPrincipalIdeal R K).range.Normal := Subgroup.normal_of_comm _ #align principal_ideals.normal PrincipalIdeals.normal end variable (R) variable [IsDomain R] /-- The ideal class group of `R` is the group of invertible fractional ideals modulo the principal ideals. -/ def ClassGroup := (FractionalIdeal R⁰ (FractionRing R))ˣ ⧸ (toPrincipalIdeal R (FractionRing R)).range #align class_group ClassGroup noncomputable instance : CommGroup (ClassGroup R) := QuotientGroup.Quotient.commGroup (toPrincipalIdeal R (FractionRing R)).range noncomputable instance : Inhabited (ClassGroup R) := ⟨1⟩ variable {R} /-- Send a nonzero fractional ideal to the corresponding class in the class group. -/ noncomputable def ClassGroup.mk : (FractionalIdeal R⁰ K)ˣ →* ClassGroup R := (QuotientGroup.mk' (toPrincipalIdeal R (FractionRing R)).range).comp (Units.map (FractionalIdeal.canonicalEquiv R⁰ K (FractionRing R))) #align class_group.mk ClassGroup.mk -- Can't be `@[simp]` because it can't figure out the quotient relation. theorem ClassGroup.Quot_mk_eq_mk (I : (FractionalIdeal R⁰ (FractionRing R))ˣ) : Quot.mk _ I = ClassGroup.mk I := by rw [ClassGroup.mk, canonicalEquiv_self, RingEquiv.coe_monoidHom_refl, Units.map_id] -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [MonoidHom.comp_apply] rw [MonoidHom.id_apply, QuotientGroup.mk'_apply] rfl
Mathlib/RingTheory/ClassGroup.lean
119
123
theorem ClassGroup.mk_eq_mk {I J : (FractionalIdeal R⁰ <| FractionRing R)ˣ} : ClassGroup.mk I = ClassGroup.mk J ↔ ∃ x : (FractionRing R)ˣ, I * toPrincipalIdeal R (FractionRing R) x = J := by
erw [QuotientGroup.mk'_eq_mk', canonicalEquiv_self, Units.map_id, Set.exists_range_iff] rfl
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.LinearAlgebra.Matrix.Adjugate import Mathlib.RingTheory.PolynomialAlgebra #align_import linear_algebra.matrix.charpoly.basic from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Characteristic polynomials and the Cayley-Hamilton theorem We define characteristic polynomials of matrices and prove the Cayley–Hamilton theorem over arbitrary commutative rings. See the file `Mathlib/LinearAlgebra/Matrix/Charpoly/Coeff.lean` for corollaries of this theorem. ## Main definitions * `Matrix.charpoly` is the characteristic polynomial of a matrix. ## Implementation details We follow a nice proof from http://drorbn.net/AcademicPensieve/2015-12/CayleyHamilton.pdf -/ noncomputable section universe u v w namespace Matrix open Finset Matrix Polynomial variable {R S : Type*} [CommRing R] [CommRing S] variable {m n : Type*} [DecidableEq m] [DecidableEq n] [Fintype m] [Fintype n] variable (M₁₁ : Matrix m m R) (M₁₂ : Matrix m n R) (M₂₁ : Matrix n m R) (M₂₂ M : Matrix n n R) variable (i j : n) /-- The "characteristic matrix" of `M : Matrix n n R` is the matrix of polynomials $t I - M$. The determinant of this matrix is the characteristic polynomial. -/ def charmatrix (M : Matrix n n R) : Matrix n n R[X] := Matrix.scalar n (X : R[X]) - (C : R →+* R[X]).mapMatrix M #align charmatrix Matrix.charmatrix theorem charmatrix_apply : charmatrix M i j = (Matrix.diagonal fun _ : n => X) i j - C (M i j) := rfl #align charmatrix_apply Matrix.charmatrix_apply @[simp]
Mathlib/LinearAlgebra/Matrix/Charpoly/Basic.lean
55
57
theorem charmatrix_apply_eq : charmatrix M i i = (X : R[X]) - C (M i i) := by
simp only [charmatrix, RingHom.mapMatrix_apply, sub_apply, scalar_apply, map_apply, diagonal_apply_eq]
/- Copyright (c) 2019 Yury Kudriashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudriashov -/ import Mathlib.Algebra.Order.BigOperators.Ring.Finset import Mathlib.Analysis.Convex.Hull import Mathlib.LinearAlgebra.AffineSpace.Basis #align_import analysis.convex.combination from "leanprover-community/mathlib"@"92bd7b1ffeb306a89f450bee126ddd8a284c259d" /-! # Convex combinations This file defines convex combinations of points in a vector space. ## Main declarations * `Finset.centerMass`: Center of mass of a finite family of points. ## Implementation notes We divide by the sum of the weights in the definition of `Finset.centerMass` because of the way mathematical arguments go: one doesn't change weights, but merely adds some. This also makes a few lemmas unconditional on the sum of the weights being `1`. -/ open Set Function open scoped Classical open Pointwise universe u u' variable {R R' E F ι ι' α : Type*} [LinearOrderedField R] [LinearOrderedField R'] [AddCommGroup E] [AddCommGroup F] [LinearOrderedAddCommGroup α] [Module R E] [Module R F] [Module R α] [OrderedSMul R α] {s : Set E} /-- Center of mass of a finite collection of points with prescribed weights. Note that we require neither `0 ≤ w i` nor `∑ w = 1`. -/ def Finset.centerMass (t : Finset ι) (w : ι → R) (z : ι → E) : E := (∑ i ∈ t, w i)⁻¹ • ∑ i ∈ t, w i • z i #align finset.center_mass Finset.centerMass variable (i j : ι) (c : R) (t : Finset ι) (w : ι → R) (z : ι → E) open Finset theorem Finset.centerMass_empty : (∅ : Finset ι).centerMass w z = 0 := by simp only [centerMass, sum_empty, smul_zero] #align finset.center_mass_empty Finset.centerMass_empty theorem Finset.centerMass_pair (hne : i ≠ j) : ({i, j} : Finset ι).centerMass w z = (w i / (w i + w j)) • z i + (w j / (w i + w j)) • z j := by simp only [centerMass, sum_pair hne, smul_add, (mul_smul _ _ _).symm, div_eq_inv_mul] #align finset.center_mass_pair Finset.centerMass_pair variable {w} theorem Finset.centerMass_insert (ha : i ∉ t) (hw : ∑ j ∈ t, w j ≠ 0) : (insert i t).centerMass w z = (w i / (w i + ∑ j ∈ t, w j)) • z i + ((∑ j ∈ t, w j) / (w i + ∑ j ∈ t, w j)) • t.centerMass w z := by simp only [centerMass, sum_insert ha, smul_add, (mul_smul _ _ _).symm, ← div_eq_inv_mul] congr 2 rw [div_mul_eq_mul_div, mul_inv_cancel hw, one_div] #align finset.center_mass_insert Finset.centerMass_insert theorem Finset.centerMass_singleton (hw : w i ≠ 0) : ({i} : Finset ι).centerMass w z = z i := by rw [centerMass, sum_singleton, sum_singleton, ← mul_smul, inv_mul_cancel hw, one_smul] #align finset.center_mass_singleton Finset.centerMass_singleton @[simp] lemma Finset.centerMass_neg_left : t.centerMass (-w) z = t.centerMass w z := by simp [centerMass, inv_neg] lemma Finset.centerMass_smul_left {c : R'} [Module R' R] [Module R' E] [SMulCommClass R' R R] [IsScalarTower R' R R] [SMulCommClass R R' E] [IsScalarTower R' R E] (hc : c ≠ 0) : t.centerMass (c • w) z = t.centerMass w z := by simp [centerMass, -smul_assoc, smul_assoc c, ← smul_sum, smul_inv₀, smul_smul_smul_comm, hc]
Mathlib/Analysis/Convex/Combination.lean
82
84
theorem Finset.centerMass_eq_of_sum_1 (hw : ∑ i ∈ t, w i = 1) : t.centerMass w z = ∑ i ∈ t, w i • z i := by
simp only [Finset.centerMass, hw, inv_one, one_smul]
/- Copyright (c) 2020 Kevin Kappelmann. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Kappelmann -/ import Mathlib.Algebra.ContinuedFractions.Computation.Basic import Mathlib.Algebra.ContinuedFractions.Translations #align_import algebra.continued_fractions.computation.translations from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" /-! # Basic Translation Lemmas Between Structures Defined for Computing Continued Fractions ## Summary This is a collection of simple lemmas between the different structures used for the computation of continued fractions defined in `Algebra.ContinuedFractions.Computation.Basic`. The file consists of three sections: 1. Recurrences and inversion lemmas for `IntFractPair.stream`: these lemmas give us inversion rules and recurrences for the computation of the stream of integer and fractional parts of a value. 2. Translation lemmas for the head term: these lemmas show us that the head term of the computed continued fraction of a value `v` is `⌊v⌋` and how this head term is moved along the structures used in the computation process. 3. Translation lemmas for the sequence: these lemmas show how the sequences of the involved structures (`IntFractPair.stream`, `IntFractPair.seq1`, and `GeneralizedContinuedFraction.of`) are connected, i.e. how the values are moved along the structures and the termination of one sequence implies the termination of another sequence. ## Main Theorems - `succ_nth_stream_eq_some_iff` gives as a recurrence to compute the `n + 1`th value of the sequence of integer and fractional parts of a value in case of non-termination. - `succ_nth_stream_eq_none_iff` gives as a recurrence to compute the `n + 1`th value of the sequence of integer and fractional parts of a value in case of termination. - `get?_of_eq_some_of_succ_get?_intFractPair_stream` and `get?_of_eq_some_of_get?_intFractPair_stream_fr_ne_zero` show how the entries of the sequence of the computed continued fraction can be obtained from the stream of integer and fractional parts. -/ namespace GeneralizedContinuedFraction open GeneralizedContinuedFraction (of) -- Fix a discrete linear ordered floor field and a value `v`. variable {K : Type*} [LinearOrderedField K] [FloorRing K] {v : K} namespace IntFractPair /-! ### Recurrences and Inversion Lemmas for `IntFractPair.stream` Here we state some lemmas that give us inversion rules and recurrences for the computation of the stream of integer and fractional parts of a value. -/ theorem stream_zero (v : K) : IntFractPair.stream v 0 = some (IntFractPair.of v) := rfl #align generalized_continued_fraction.int_fract_pair.stream_zero GeneralizedContinuedFraction.IntFractPair.stream_zero variable {n : ℕ} theorem stream_eq_none_of_fr_eq_zero {ifp_n : IntFractPair K} (stream_nth_eq : IntFractPair.stream v n = some ifp_n) (nth_fr_eq_zero : ifp_n.fr = 0) : IntFractPair.stream v (n + 1) = none := by cases' ifp_n with _ fr change fr = 0 at nth_fr_eq_zero simp [IntFractPair.stream, stream_nth_eq, nth_fr_eq_zero] #align generalized_continued_fraction.int_fract_pair.stream_eq_none_of_fr_eq_zero GeneralizedContinuedFraction.IntFractPair.stream_eq_none_of_fr_eq_zero /-- Gives a recurrence to compute the `n + 1`th value of the sequence of integer and fractional parts of a value in case of termination. -/ theorem succ_nth_stream_eq_none_iff : IntFractPair.stream v (n + 1) = none ↔ IntFractPair.stream v n = none ∨ ∃ ifp, IntFractPair.stream v n = some ifp ∧ ifp.fr = 0 := by rw [IntFractPair.stream] cases IntFractPair.stream v n <;> simp [imp_false] #align generalized_continued_fraction.int_fract_pair.succ_nth_stream_eq_none_iff GeneralizedContinuedFraction.IntFractPair.succ_nth_stream_eq_none_iff /-- Gives a recurrence to compute the `n + 1`th value of the sequence of integer and fractional parts of a value in case of non-termination. -/
Mathlib/Algebra/ContinuedFractions/Computation/Translations.lean
87
92
theorem succ_nth_stream_eq_some_iff {ifp_succ_n : IntFractPair K} : IntFractPair.stream v (n + 1) = some ifp_succ_n ↔ ∃ ifp_n : IntFractPair K, IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n := by
simp [IntFractPair.stream, ite_eq_iff, Option.bind_eq_some]
/- Copyright (c) 2022 Devon Tuma. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Devon Tuma -/ import Mathlib.Data.Vector.Basic #align_import data.vector.mem from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226" /-! # Theorems about membership of elements in vectors This file contains theorems for membership in a `v.toList` for a vector `v`. Having the length available in the type allows some of the lemmas to be simpler and more general than the original version for lists. In particular we can avoid some assumptions about types being `Inhabited`, and make more general statements about `head` and `tail`. -/ namespace Vector variable {α β : Type*} {n : ℕ} (a a' : α) @[simp] theorem get_mem (i : Fin n) (v : Vector α n) : v.get i ∈ v.toList := by rw [get_eq_get] exact List.get_mem _ _ _ #align vector.nth_mem Vector.get_mem theorem mem_iff_get (v : Vector α n) : a ∈ v.toList ↔ ∃ i, v.get i = a := by simp only [List.mem_iff_get, Fin.exists_iff, Vector.get_eq_get] exact ⟨fun ⟨i, hi, h⟩ => ⟨i, by rwa [toList_length] at hi, h⟩, fun ⟨i, hi, h⟩ => ⟨i, by rwa [toList_length], h⟩⟩ #align vector.mem_iff_nth Vector.mem_iff_get theorem not_mem_nil : a ∉ (Vector.nil : Vector α 0).toList := by unfold Vector.nil dsimp simp #align vector.not_mem_nil Vector.not_mem_nil theorem not_mem_zero (v : Vector α 0) : a ∉ v.toList := (Vector.eq_nil v).symm ▸ not_mem_nil a #align vector.not_mem_zero Vector.not_mem_zero theorem mem_cons_iff (v : Vector α n) : a' ∈ (a ::ᵥ v).toList ↔ a' = a ∨ a' ∈ v.toList := by rw [Vector.toList_cons, List.mem_cons] #align vector.mem_cons_iff Vector.mem_cons_iff
Mathlib/Data/Vector/Mem.lean
52
54
theorem mem_succ_iff (v : Vector α (n + 1)) : a ∈ v.toList ↔ a = v.head ∨ a ∈ v.tail.toList := by
obtain ⟨a', v', h⟩ := exists_eq_cons v simp_rw [h, Vector.mem_cons_iff, Vector.head_cons, Vector.tail_cons]
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.CategoryTheory.Preadditive.Basic #align_import category_theory.preadditive.functor_category from "leanprover-community/mathlib"@"829895f162a1f29d0133f4b3538f4cd1fb5bffd3" /-! # Preadditive structure on functor categories If `C` and `D` are categories and `D` is preadditive, then `C ⥤ D` is also preadditive. -/ namespace CategoryTheory open CategoryTheory.Limits Preadditive variable {C D : Type*} [Category C] [Category D] [Preadditive D] instance {F G : C ⥤ D} : Zero (F ⟶ G) where zero := { app := fun X => 0 } instance {F G : C ⥤ D} : Add (F ⟶ G) where add α β := { app := fun X => α.app X + β.app X } instance {F G : C ⥤ D} : Neg (F ⟶ G) where neg α := { app := fun X => -α.app X } instance functorCategoryPreadditive : Preadditive (C ⥤ D) where homGroup F G := { nsmul := nsmulRec zsmul := zsmulRec sub := fun α β => { app := fun X => α.app X - β.app X } add_assoc := by intros ext apply add_assoc zero_add := by intros dsimp ext apply zero_add add_zero := by intros dsimp ext apply add_zero add_comm := by intros dsimp ext apply add_comm sub_eq_add_neg := by intros dsimp ext apply sub_eq_add_neg add_left_neg := by intros dsimp ext apply add_left_neg } add_comp := by intros dsimp ext apply add_comp comp_add := by intros dsimp ext apply comp_add #align category_theory.functor_category_preadditive CategoryTheory.functorCategoryPreadditive namespace NatTrans variable {F G : C ⥤ D} /-- Application of a natural transformation at a fixed object, as group homomorphism -/ @[simps] def appHom (X : C) : (F ⟶ G) →+ (F.obj X ⟶ G.obj X) where toFun α := α.app X map_zero' := rfl map_add' _ _ := rfl #align category_theory.nat_trans.app_hom CategoryTheory.NatTrans.appHom @[simp] theorem app_zero (X : C) : (0 : F ⟶ G).app X = 0 := rfl #align category_theory.nat_trans.app_zero CategoryTheory.NatTrans.app_zero @[simp] theorem app_add (X : C) (α β : F ⟶ G) : (α + β).app X = α.app X + β.app X := rfl #align category_theory.nat_trans.app_add CategoryTheory.NatTrans.app_add @[simp] theorem app_sub (X : C) (α β : F ⟶ G) : (α - β).app X = α.app X - β.app X := rfl #align category_theory.nat_trans.app_sub CategoryTheory.NatTrans.app_sub @[simp] theorem app_neg (X : C) (α : F ⟶ G) : (-α).app X = -α.app X := rfl #align category_theory.nat_trans.app_neg CategoryTheory.NatTrans.app_neg @[simp] theorem app_nsmul (X : C) (α : F ⟶ G) (n : ℕ) : (n • α).app X = n • α.app X := (appHom X).map_nsmul α n #align category_theory.nat_trans.app_nsmul CategoryTheory.NatTrans.app_nsmul @[simp] theorem app_zsmul (X : C) (α : F ⟶ G) (n : ℤ) : (n • α).app X = n • α.app X := (appHom X : (F ⟶ G) →+ (F.obj X ⟶ G.obj X)).map_zsmul α n #align category_theory.nat_trans.app_zsmul CategoryTheory.NatTrans.app_zsmul @[simp] theorem app_units_zsmul (X : C) (α : F ⟶ G) (n : ℤˣ) : (n • α).app X = n • α.app X := by apply app_zsmul @[simp]
Mathlib/CategoryTheory/Preadditive/FunctorCategory.lean
127
129
theorem app_sum {ι : Type*} (s : Finset ι) (X : C) (α : ι → (F ⟶ G)) : (∑ i ∈ s, α i).app X = ∑ i ∈ s, (α i).app X := by
simp only [← appHom_apply, map_sum]
/- Copyright (c) 2022 Daniel Roca González. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Daniel Roca González -/ import Mathlib.Analysis.InnerProductSpace.Dual #align_import analysis.inner_product_space.lax_milgram from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # The Lax-Milgram Theorem We consider a Hilbert space `V` over `ℝ` equipped with a bounded bilinear form `B : V →L[ℝ] V →L[ℝ] ℝ`. Recall that a bilinear form `B : V →L[ℝ] V →L[ℝ] ℝ` is *coercive* iff `∃ C, (0 < C) ∧ ∀ u, C * ‖u‖ * ‖u‖ ≤ B u u`. Under the hypothesis that `B` is coercive we prove the Lax-Milgram theorem: that is, the map `InnerProductSpace.continuousLinearMapOfBilin` from `Analysis.InnerProductSpace.Dual` can be upgraded to a continuous equivalence `IsCoercive.continuousLinearEquivOfBilin : V ≃L[ℝ] V`. ## References * We follow the notes of Peter Howard's Spring 2020 *M612: Partial Differential Equations* lecture, see[howard] ## Tags dual, Lax-Milgram -/ noncomputable section open RCLike LinearMap ContinuousLinearMap InnerProductSpace open LinearMap (ker range) open RealInnerProductSpace NNReal universe u namespace IsCoercive variable {V : Type u} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [CompleteSpace V] variable {B : V →L[ℝ] V →L[ℝ] ℝ} local postfix:1024 "♯" => @continuousLinearMapOfBilin ℝ V _ _ _ _ theorem bounded_below (coercive : IsCoercive B) : ∃ C, 0 < C ∧ ∀ v, C * ‖v‖ ≤ ‖B♯ v‖ := by rcases coercive with ⟨C, C_ge_0, coercivity⟩ refine ⟨C, C_ge_0, ?_⟩ intro v by_cases h : 0 < ‖v‖ · refine (mul_le_mul_right h).mp ?_ calc C * ‖v‖ * ‖v‖ ≤ B v v := coercivity v _ = ⟪B♯ v, v⟫_ℝ := (continuousLinearMapOfBilin_apply B v v).symm _ ≤ ‖B♯ v‖ * ‖v‖ := real_inner_le_norm (B♯ v) v · have : v = 0 := by simpa using h simp [this] #align is_coercive.bounded_below IsCoercive.bounded_below theorem antilipschitz (coercive : IsCoercive B) : ∃ C : ℝ≥0, 0 < C ∧ AntilipschitzWith C B♯ := by rcases coercive.bounded_below with ⟨C, C_pos, below_bound⟩ refine ⟨C⁻¹.toNNReal, Real.toNNReal_pos.mpr (inv_pos.mpr C_pos), ?_⟩ refine ContinuousLinearMap.antilipschitz_of_bound B♯ ?_ simp_rw [Real.coe_toNNReal', max_eq_left_of_lt (inv_pos.mpr C_pos), ← inv_mul_le_iff (inv_pos.mpr C_pos)] simpa using below_bound #align is_coercive.antilipschitz IsCoercive.antilipschitz
Mathlib/Analysis/InnerProductSpace/LaxMilgram.lean
74
77
theorem ker_eq_bot (coercive : IsCoercive B) : ker B♯ = ⊥ := by
rw [LinearMapClass.ker_eq_bot] rcases coercive.antilipschitz with ⟨_, _, antilipschitz⟩ exact antilipschitz.injective
/- Copyright (c) 2020 Mathieu Guay-Paquet. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mathieu Guay-Paquet -/ import Mathlib.Order.Ideal #align_import order.pfilter from "leanprover-community/mathlib"@"740acc0e6f9adf4423f92a485d0456fc271482da" /-! # Order filters ## Main definitions Throughout this file, `P` is at least a preorder, but some sections require more structure, such as a bottom element, a top element, or a join-semilattice structure. - `Order.PFilter P`: The type of nonempty, downward directed, upward closed subsets of `P`. This is dual to `Order.Ideal`, so it simply wraps `Order.Ideal Pᵒᵈ`. - `Order.IsPFilter P`: a predicate for when a `Set P` is a filter. Note the relation between `Order/Filter` and `Order/PFilter`: for any type `α`, `Filter α` represents the same mathematical object as `PFilter (Set α)`. ## References - <https://en.wikipedia.org/wiki/Filter_(mathematics)> ## Tags pfilter, filter, ideal, dual -/ open OrderDual namespace Order /-- A filter on a preorder `P` is a subset of `P` that is - nonempty - downward directed - upward closed. -/ structure PFilter (P : Type*) [Preorder P] where dual : Ideal Pᵒᵈ #align order.pfilter Order.PFilter variable {P : Type*} /-- A predicate for when a subset of `P` is a filter. -/ def IsPFilter [Preorder P] (F : Set P) : Prop := IsIdeal (OrderDual.ofDual ⁻¹' F) #align order.is_pfilter Order.IsPFilter theorem IsPFilter.of_def [Preorder P] {F : Set P} (nonempty : F.Nonempty) (directed : DirectedOn (· ≥ ·) F) (mem_of_le : ∀ {x y : P}, x ≤ y → x ∈ F → y ∈ F) : IsPFilter F := ⟨fun _ _ _ _ => mem_of_le ‹_› ‹_›, nonempty, directed⟩ #align order.is_pfilter.of_def Order.IsPFilter.of_def /-- Create an element of type `Order.PFilter` from a set satisfying the predicate `Order.IsPFilter`. -/ def IsPFilter.toPFilter [Preorder P] {F : Set P} (h : IsPFilter F) : PFilter P := ⟨h.toIdeal⟩ #align order.is_pfilter.to_pfilter Order.IsPFilter.toPFilter namespace PFilter section Preorder variable [Preorder P] {x y : P} (F s t : PFilter P) instance [Inhabited P] : Inhabited (PFilter P) := ⟨⟨default⟩⟩ /-- A filter on `P` is a subset of `P`. -/ instance : SetLike (PFilter P) P where coe F := toDual ⁻¹' F.dual.carrier coe_injective' := fun ⟨_⟩ ⟨_⟩ h => congr_arg mk <| Ideal.ext h #align order.pfilter.mem_coe SetLike.mem_coeₓ theorem isPFilter : IsPFilter (F : Set P) := F.dual.isIdeal #align order.pfilter.is_pfilter Order.PFilter.isPFilter protected theorem nonempty : (F : Set P).Nonempty := F.dual.nonempty #align order.pfilter.nonempty Order.PFilter.nonempty theorem directed : DirectedOn (· ≥ ·) (F : Set P) := F.dual.directed #align order.pfilter.directed Order.PFilter.directed theorem mem_of_le {F : PFilter P} : x ≤ y → x ∈ F → y ∈ F := fun h => F.dual.lower h #align order.pfilter.mem_of_le Order.PFilter.mem_of_le /-- Two filters are equal when their underlying sets are equal. -/ @[ext] theorem ext (h : (s : Set P) = t) : s = t := SetLike.ext' h #align order.pfilter.ext Order.PFilter.ext @[trans] theorem mem_of_mem_of_le {F G : PFilter P} (hx : x ∈ F) (hle : F ≤ G) : x ∈ G := hle hx #align order.pfilter.mem_of_mem_of_le Order.PFilter.mem_of_mem_of_le /-- The smallest filter containing a given element. -/ def principal (p : P) : PFilter P := ⟨Ideal.principal (toDual p)⟩ #align order.pfilter.principal Order.PFilter.principal @[simp] theorem mem_mk (x : P) (I : Ideal Pᵒᵈ) : x ∈ (⟨I⟩ : PFilter P) ↔ toDual x ∈ I := Iff.rfl #align order.pfilter.mem_def Order.PFilter.mem_mk @[simp] theorem principal_le_iff {F : PFilter P} : principal x ≤ F ↔ x ∈ F := Ideal.principal_le_iff (x := toDual x) #align order.pfilter.principal_le_iff Order.PFilter.principal_le_iff @[simp] theorem mem_principal : x ∈ principal y ↔ y ≤ x := Iff.rfl #align order.pfilter.mem_principal Order.PFilter.mem_principal
Mathlib/Order/PFilter.lean
120
120
theorem principal_le_principal_iff {p q : P} : principal q ≤ principal p ↔ p ≤ q := by
simp
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Eric Wieser -/ import Mathlib.LinearAlgebra.Matrix.DotProduct import Mathlib.LinearAlgebra.Determinant import Mathlib.LinearAlgebra.Matrix.Diagonal #align_import data.matrix.rank from "leanprover-community/mathlib"@"17219820a8aa8abe85adf5dfde19af1dd1bd8ae7" /-! # Rank of matrices The rank of a matrix `A` is defined to be the rank of range of the linear map corresponding to `A`. This definition does not depend on the choice of basis, see `Matrix.rank_eq_finrank_range_toLin`. ## Main declarations * `Matrix.rank`: the rank of a matrix ## TODO * Do a better job of generalizing over `ℚ`, `ℝ`, and `ℂ` in `Matrix.rank_transpose` and `Matrix.rank_conjTranspose`. See [this Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/row.20rank.20equals.20column.20rank/near/350462992). -/ open Matrix namespace Matrix open FiniteDimensional variable {l m n o R : Type*} [Fintype n] [Fintype o] section CommRing variable [CommRing R] /-- The rank of a matrix is the rank of its image. -/ noncomputable def rank (A : Matrix m n R) : ℕ := finrank R <| LinearMap.range A.mulVecLin #align matrix.rank Matrix.rank @[simp]
Mathlib/Data/Matrix/Rank.lean
49
51
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]
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.GroupWithZero.Units.Basic import Mathlib.Algebra.Group.Semiconj.Units import Mathlib.Init.Classical #align_import algebra.group_with_zero.semiconj from "leanprover-community/mathlib"@"70d50ecfd4900dd6d328da39ab7ebd516abe4025" /-! # Lemmas about semiconjugate elements in a `GroupWithZero`. -/ assert_not_exists DenselyOrdered variable {α M₀ G₀ M₀' G₀' F F' : Type*} namespace SemiconjBy @[simp] theorem zero_right [MulZeroClass G₀] (a : G₀) : SemiconjBy a 0 0 := by simp only [SemiconjBy, mul_zero, zero_mul] #align semiconj_by.zero_right SemiconjBy.zero_right @[simp]
Mathlib/Algebra/GroupWithZero/Semiconj.lean
29
30
theorem zero_left [MulZeroClass G₀] (x y : G₀) : SemiconjBy 0 x y := by
simp only [SemiconjBy, mul_zero, zero_mul]
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.Topology.Sets.Opens #align_import topology.local_at_target from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Properties of maps that are local at the target. We show that the following properties of continuous maps are local at the target : - `Inducing` - `Embedding` - `OpenEmbedding` - `ClosedEmbedding` -/ open TopologicalSpace Set Filter open Topology Filter variable {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] {f : α → β} variable {s : Set β} {ι : Type*} {U : ι → Opens β} (hU : iSup U = ⊤) theorem Set.restrictPreimage_inducing (s : Set β) (h : Inducing f) : Inducing (s.restrictPreimage f) := by simp_rw [← inducing_subtype_val.of_comp_iff, inducing_iff_nhds, restrictPreimage, MapsTo.coe_restrict, restrict_eq, ← @Filter.comap_comap _ _ _ _ _ f, Function.comp_apply] at h ⊢ intro a rw [← h, ← inducing_subtype_val.nhds_eq_comap] #align set.restrict_preimage_inducing Set.restrictPreimage_inducing alias Inducing.restrictPreimage := Set.restrictPreimage_inducing #align inducing.restrict_preimage Inducing.restrictPreimage theorem Set.restrictPreimage_embedding (s : Set β) (h : Embedding f) : Embedding (s.restrictPreimage f) := ⟨h.1.restrictPreimage s, h.2.restrictPreimage s⟩ #align set.restrict_preimage_embedding Set.restrictPreimage_embedding alias Embedding.restrictPreimage := Set.restrictPreimage_embedding #align embedding.restrict_preimage Embedding.restrictPreimage theorem Set.restrictPreimage_openEmbedding (s : Set β) (h : OpenEmbedding f) : OpenEmbedding (s.restrictPreimage f) := ⟨h.1.restrictPreimage s, (s.range_restrictPreimage f).symm ▸ continuous_subtype_val.isOpen_preimage _ h.isOpen_range⟩ #align set.restrict_preimage_open_embedding Set.restrictPreimage_openEmbedding alias OpenEmbedding.restrictPreimage := Set.restrictPreimage_openEmbedding #align open_embedding.restrict_preimage OpenEmbedding.restrictPreimage theorem Set.restrictPreimage_closedEmbedding (s : Set β) (h : ClosedEmbedding f) : ClosedEmbedding (s.restrictPreimage f) := ⟨h.1.restrictPreimage s, (s.range_restrictPreimage f).symm ▸ inducing_subtype_val.isClosed_preimage _ h.isClosed_range⟩ #align set.restrict_preimage_closed_embedding Set.restrictPreimage_closedEmbedding alias ClosedEmbedding.restrictPreimage := Set.restrictPreimage_closedEmbedding #align closed_embedding.restrict_preimage ClosedEmbedding.restrictPreimage theorem IsClosedMap.restrictPreimage (H : IsClosedMap f) (s : Set β) : IsClosedMap (s.restrictPreimage f) := by intro t suffices ∀ u, IsClosed u → Subtype.val ⁻¹' u = t → ∃ v, IsClosed v ∧ Subtype.val ⁻¹' v = s.restrictPreimage f '' t by simpa [isClosed_induced_iff] exact fun u hu e => ⟨f '' u, H u hu, by simp [← e, image_restrictPreimage]⟩ @[deprecated (since := "2024-04-02")] theorem Set.restrictPreimage_isClosedMap (s : Set β) (H : IsClosedMap f) : IsClosedMap (s.restrictPreimage f) := H.restrictPreimage s theorem IsOpenMap.restrictPreimage (H : IsOpenMap f) (s : Set β) : IsOpenMap (s.restrictPreimage f) := by intro t suffices ∀ u, IsOpen u → Subtype.val ⁻¹' u = t → ∃ v, IsOpen v ∧ Subtype.val ⁻¹' v = s.restrictPreimage f '' t by simpa [isOpen_induced_iff] exact fun u hu e => ⟨f '' u, H u hu, by simp [← e, image_restrictPreimage]⟩ @[deprecated (since := "2024-04-02")] theorem Set.restrictPreimage_isOpenMap (s : Set β) (H : IsOpenMap f) : IsOpenMap (s.restrictPreimage f) := H.restrictPreimage s theorem isOpen_iff_inter_of_iSup_eq_top (s : Set β) : IsOpen s ↔ ∀ i, IsOpen (s ∩ U i) := by constructor · exact fun H i => H.inter (U i).2 · intro H have : ⋃ i, (U i : Set β) = Set.univ := by convert congr_arg (SetLike.coe) hU simp rw [← s.inter_univ, ← this, Set.inter_iUnion] exact isOpen_iUnion H #align is_open_iff_inter_of_supr_eq_top isOpen_iff_inter_of_iSup_eq_top theorem isOpen_iff_coe_preimage_of_iSup_eq_top (s : Set β) : IsOpen s ↔ ∀ i, IsOpen ((↑) ⁻¹' s : Set (U i)) := by -- Porting note: rewrote to avoid ´simp´ issues rw [isOpen_iff_inter_of_iSup_eq_top hU s] refine forall_congr' fun i => ?_ rw [(U _).2.openEmbedding_subtype_val.open_iff_image_open] erw [Set.image_preimage_eq_inter_range] rw [Subtype.range_coe, Opens.carrier_eq_coe] #align is_open_iff_coe_preimage_of_supr_eq_top isOpen_iff_coe_preimage_of_iSup_eq_top
Mathlib/Topology/LocalAtTarget.lean
111
113
theorem isClosed_iff_coe_preimage_of_iSup_eq_top (s : Set β) : IsClosed s ↔ ∀ i, IsClosed ((↑) ⁻¹' s : Set (U i)) := by
simpa using isOpen_iff_coe_preimage_of_iSup_eq_top hU sᶜ
/- Copyright (c) 2024 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen, Alex J. Best -/ import Mathlib.Algebra.Polynomial.Roots import Mathlib.Tactic.IntervalCases /-! # Polynomials of specific degree Facts about polynomials that have a specific integer degree. -/ namespace Polynomial section IsDomain variable {R : Type*} [CommRing R] [IsDomain R] /-- A polynomial of degree 2 or 3 is irreducible iff it doesn't have roots. -/ theorem Monic.irreducible_iff_roots_eq_zero_of_degree_le_three {p : R[X]} (hp : p.Monic) (hp2 : 2 ≤ p.natDegree) (hp3 : p.natDegree ≤ 3) : Irreducible p ↔ p.roots = 0 := by have hp0 : p ≠ 0 := hp.ne_zero have hp1 : p ≠ 1 := by rintro rfl; rw [natDegree_one] at hp2; cases hp2 rw [hp.irreducible_iff_lt_natDegree_lt hp1] simp_rw [show p.natDegree / 2 = 1 from (Nat.div_le_div_right hp3).antisymm (by apply Nat.div_le_div_right (c := 2) hp2), show Finset.Ioc 0 1 = {1} from rfl, Finset.mem_singleton, Multiset.eq_zero_iff_forall_not_mem, mem_roots hp0, ← dvd_iff_isRoot] refine ⟨fun h r ↦ h _ (monic_X_sub_C r) (natDegree_X_sub_C r), fun h q hq hq1 ↦ ?_⟩ rw [hq.eq_X_add_C hq1, ← sub_neg_eq_add, ← C_neg] apply h end IsDomain section Field variable {K : Type*} [Field K] /-- A polynomial of degree 2 or 3 is irreducible iff it doesn't have roots. -/
Mathlib/Algebra/Polynomial/SpecificDegree.lean
43
51
theorem irreducible_iff_roots_eq_zero_of_degree_le_three {p : K[X]} (hp2 : 2 ≤ p.natDegree) (hp3 : p.natDegree ≤ 3) : Irreducible p ↔ p.roots = 0 := by
have hp0 : p ≠ 0 := by rintro rfl; rw [natDegree_zero] at hp2; cases hp2 rw [← irreducible_mul_leadingCoeff_inv, (monic_mul_leadingCoeff_inv hp0).irreducible_iff_roots_eq_zero_of_degree_le_three, mul_comm, roots_C_mul] · exact inv_ne_zero (leadingCoeff_ne_zero.mpr hp0) · rwa [natDegree_mul_leadingCoeff_inv _ hp0] · rwa [natDegree_mul_leadingCoeff_inv _ hp0]
/- Copyright (c) 2021 Heather Macbeth. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Heather Macbeth, Yury Kudryashov -/ import Mathlib.Topology.Order.Basic #align_import topology.algebra.order.monotone_convergence from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" /-! # Bounded monotone sequences converge In this file we prove a few theorems of the form “if the range of a monotone function `f : ι → α` admits a least upper bound `a`, then `f x` tends to `a` as `x → ∞`”, as well as version of this statement for (conditionally) complete lattices that use `⨆ x, f x` instead of `IsLUB`. These theorems work for linear orders with order topologies as well as their products (both in terms of `Prod` and in terms of function types). In order to reduce code duplication, we introduce two typeclasses (one for the property formulated above and one for the dual property), prove theorems assuming one of these typeclasses, and provide instances for linear orders and their products. We also prove some "inverse" results: if `f n` is a monotone sequence and `a` is its limit, then `f n ≤ a` for all `n`. ## Tags monotone convergence -/ open Filter Set Function open scoped Classical open Filter Topology variable {α β : Type*} /-- We say that `α` is a `SupConvergenceClass` if the following holds. Let `f : ι → α` be a monotone function, let `a : α` be a least upper bound of `Set.range f`. Then `f x` tends to `𝓝 a` as `x → ∞` (formally, at the filter `Filter.atTop`). We require this for `ι = (s : Set α)`, `f = CoeTC.coe` in the definition, then prove it for any `f` in `tendsto_atTop_isLUB`. This property holds for linear orders with order topology as well as their products. -/ class SupConvergenceClass (α : Type*) [Preorder α] [TopologicalSpace α] : Prop where /-- proof that a monotone function tends to `𝓝 a` as `x → ∞` -/ tendsto_coe_atTop_isLUB : ∀ (a : α) (s : Set α), IsLUB s a → Tendsto (CoeTC.coe : s → α) atTop (𝓝 a) #align Sup_convergence_class SupConvergenceClass /-- We say that `α` is an `InfConvergenceClass` if the following holds. Let `f : ι → α` be a monotone function, let `a : α` be a greatest lower bound of `Set.range f`. Then `f x` tends to `𝓝 a` as `x → -∞` (formally, at the filter `Filter.atBot`). We require this for `ι = (s : Set α)`, `f = CoeTC.coe` in the definition, then prove it for any `f` in `tendsto_atBot_isGLB`. This property holds for linear orders with order topology as well as their products. -/ class InfConvergenceClass (α : Type*) [Preorder α] [TopologicalSpace α] : Prop where /-- proof that a monotone function tends to `𝓝 a` as `x → -∞`-/ tendsto_coe_atBot_isGLB : ∀ (a : α) (s : Set α), IsGLB s a → Tendsto (CoeTC.coe : s → α) atBot (𝓝 a) #align Inf_convergence_class InfConvergenceClass instance OrderDual.supConvergenceClass [Preorder α] [TopologicalSpace α] [InfConvergenceClass α] : SupConvergenceClass αᵒᵈ := ⟨‹InfConvergenceClass α›.1⟩ #align order_dual.Sup_convergence_class OrderDual.supConvergenceClass instance OrderDual.infConvergenceClass [Preorder α] [TopologicalSpace α] [SupConvergenceClass α] : InfConvergenceClass αᵒᵈ := ⟨‹SupConvergenceClass α›.1⟩ #align order_dual.Inf_convergence_class OrderDual.infConvergenceClass -- see Note [lower instance priority] instance (priority := 100) LinearOrder.supConvergenceClass [TopologicalSpace α] [LinearOrder α] [OrderTopology α] : SupConvergenceClass α := by refine ⟨fun a s ha => tendsto_order.2 ⟨fun b hb => ?_, fun b hb => ?_⟩⟩ · rcases ha.exists_between hb with ⟨c, hcs, bc, bca⟩ lift c to s using hcs exact (eventually_ge_atTop c).mono fun x hx => bc.trans_le hx · exact eventually_of_forall fun x => (ha.1 x.2).trans_lt hb #align linear_order.Sup_convergence_class LinearOrder.supConvergenceClass -- see Note [lower instance priority] instance (priority := 100) LinearOrder.infConvergenceClass [TopologicalSpace α] [LinearOrder α] [OrderTopology α] : InfConvergenceClass α := show InfConvergenceClass αᵒᵈᵒᵈ from OrderDual.infConvergenceClass #align linear_order.Inf_convergence_class LinearOrder.infConvergenceClass section variable {ι : Type*} [Preorder ι] [TopologicalSpace α] section IsLUB variable [Preorder α] [SupConvergenceClass α] {f : ι → α} {a : α} theorem tendsto_atTop_isLUB (h_mono : Monotone f) (ha : IsLUB (Set.range f) a) : Tendsto f atTop (𝓝 a) := by suffices Tendsto (rangeFactorization f) atTop atTop from (SupConvergenceClass.tendsto_coe_atTop_isLUB _ _ ha).comp this exact h_mono.rangeFactorization.tendsto_atTop_atTop fun b => b.2.imp fun a ha => ha.ge #align tendsto_at_top_is_lub tendsto_atTop_isLUB theorem tendsto_atBot_isLUB (h_anti : Antitone f) (ha : IsLUB (Set.range f) a) : Tendsto f atBot (𝓝 a) := by convert tendsto_atTop_isLUB h_anti.dual_left ha using 1 #align tendsto_at_bot_is_lub tendsto_atBot_isLUB end IsLUB section IsGLB variable [Preorder α] [InfConvergenceClass α] {f : ι → α} {a : α} theorem tendsto_atBot_isGLB (h_mono : Monotone f) (ha : IsGLB (Set.range f) a) : Tendsto f atBot (𝓝 a) := by convert tendsto_atTop_isLUB h_mono.dual ha.dual using 1 #align tendsto_at_bot_is_glb tendsto_atBot_isGLB
Mathlib/Topology/Order/MonotoneConvergence.lean
117
118
theorem tendsto_atTop_isGLB (h_anti : Antitone f) (ha : IsGLB (Set.range f) a) : Tendsto f atTop (𝓝 a) := by
convert tendsto_atBot_isLUB h_anti.dual ha.dual using 1
/- Copyright (c) 2021 Stuart Presnell. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Stuart Presnell -/ import Mathlib.Data.Finsupp.Multiset import Mathlib.Data.Nat.GCD.BigOperators import Mathlib.Data.Nat.PrimeFin import Mathlib.NumberTheory.Padics.PadicVal import Mathlib.Order.Interval.Finset.Nat #align_import data.nat.factorization.basic from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" /-! # Prime factorizations `n.factorization` is the finitely supported function `ℕ →₀ ℕ` mapping each prime factor of `n` to its multiplicity in `n`. For example, since 2000 = 2^4 * 5^3, * `factorization 2000 2` is 4 * `factorization 2000 5` is 3 * `factorization 2000 k` is 0 for all other `k : ℕ`. ## TODO * As discussed in this Zulip thread: https://leanprover.zulipchat.com/#narrow/stream/217875/topic/Multiplicity.20in.20the.20naturals We have lots of disparate ways of talking about the multiplicity of a prime in a natural number, including `factors.count`, `padicValNat`, `multiplicity`, and the material in `Data/PNat/Factors`. Move some of this material to this file, prove results about the relationships between these definitions, and (where appropriate) choose a uniform canonical way of expressing these ideas. * Moreover, the results here should be generalised to an arbitrary unique factorization monoid with a normalization function, and then deduplicated. The basics of this have been started in `RingTheory/UniqueFactorizationDomain`. * Extend the inductions to any `NormalizationMonoid` with unique factorization. -/ -- Workaround for lean4#2038 attribute [-instance] instBEqNat open Nat Finset List Finsupp namespace Nat variable {a b m n p : ℕ} /-- `n.factorization` is the finitely supported function `ℕ →₀ ℕ` mapping each prime factor of `n` to its multiplicity in `n`. -/ def factorization (n : ℕ) : ℕ →₀ ℕ where support := n.primeFactors toFun p := if p.Prime then padicValNat p n else 0 mem_support_toFun := by simp [not_or]; aesop #align nat.factorization Nat.factorization /-- The support of `n.factorization` is exactly `n.primeFactors`. -/ @[simp] lemma support_factorization (n : ℕ) : (factorization n).support = n.primeFactors := rfl theorem factorization_def (n : ℕ) {p : ℕ} (pp : p.Prime) : n.factorization p = padicValNat p n := by simpa [factorization] using absurd pp #align nat.factorization_def Nat.factorization_def /-- We can write both `n.factorization p` and `n.factors.count p` to represent the power of `p` in the factorization of `n`: we declare the former to be the simp-normal form. -/ @[simp] theorem factors_count_eq {n p : ℕ} : n.factors.count p = n.factorization p := by rcases n.eq_zero_or_pos with (rfl | hn0) · simp [factorization, count] if pp : p.Prime then ?_ else rw [count_eq_zero_of_not_mem (mt prime_of_mem_factors pp)] simp [factorization, pp] simp only [factorization_def _ pp] apply _root_.le_antisymm · rw [le_padicValNat_iff_replicate_subperm_factors pp hn0.ne'] exact List.le_count_iff_replicate_sublist.mp le_rfl |>.subperm · rw [← lt_add_one_iff, lt_iff_not_ge, ge_iff_le, le_padicValNat_iff_replicate_subperm_factors pp hn0.ne'] intro h have := h.count_le p simp at this #align nat.factors_count_eq Nat.factors_count_eq theorem factorization_eq_factors_multiset (n : ℕ) : n.factorization = Multiset.toFinsupp (n.factors : Multiset ℕ) := by ext p simp #align nat.factorization_eq_factors_multiset Nat.factorization_eq_factors_multiset theorem multiplicity_eq_factorization {n p : ℕ} (pp : p.Prime) (hn : n ≠ 0) : multiplicity p n = n.factorization p := by simp [factorization, pp, padicValNat_def' pp.ne_one hn.bot_lt] #align nat.multiplicity_eq_factorization Nat.multiplicity_eq_factorization /-! ### Basic facts about factorization -/ @[simp]
Mathlib/Data/Nat/Factorization/Basic.lean
99
102
theorem factorization_prod_pow_eq_self {n : ℕ} (hn : n ≠ 0) : n.factorization.prod (· ^ ·) = n := by
rw [factorization_eq_factors_multiset n] simp only [← prod_toMultiset, factorization, Multiset.prod_coe, Multiset.toFinsupp_toMultiset] exact prod_factors hn
/- Copyright (c) 2022 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.AlgebraicTopology.DoldKan.FunctorN #align_import algebraic_topology.dold_kan.normalized from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504" /-! # Comparison with the normalized Moore complex functor In this file, we show that when the category `A` is abelian, there is an isomorphism `N₁_iso_normalizedMooreComplex_comp_toKaroubi` between the functor `N₁ : SimplicialObject A ⥤ Karoubi (ChainComplex A ℕ)` defined in `FunctorN.lean` and the composition of `normalizedMooreComplex A` with the inclusion `ChainComplex A ℕ ⥤ Karoubi (ChainComplex A ℕ)`. This isomorphism shall be used in `Equivalence.lean` in order to obtain the Dold-Kan equivalence `CategoryTheory.Abelian.DoldKan.equivalence : SimplicialObject A ≌ ChainComplex A ℕ` with a functor (definitionally) equal to `normalizedMooreComplex A`. (See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.) -/ open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Subobject CategoryTheory.Idempotents DoldKan noncomputable section namespace AlgebraicTopology namespace DoldKan universe v variable {A : Type*} [Category A] [Abelian A] {X : SimplicialObject A} theorem HigherFacesVanish.inclusionOfMooreComplexMap (n : ℕ) : HigherFacesVanish (n + 1) ((inclusionOfMooreComplexMap X).f (n + 1)) := fun j _ => by dsimp [AlgebraicTopology.inclusionOfMooreComplexMap, NormalizedMooreComplex.objX] rw [← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ j (by simp only [Finset.mem_univ])), assoc, kernelSubobject_arrow_comp, comp_zero] set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.higher_faces_vanish.inclusion_of_Moore_complex_map AlgebraicTopology.DoldKan.HigherFacesVanish.inclusionOfMooreComplexMap theorem factors_normalizedMooreComplex_PInfty (n : ℕ) : Subobject.Factors (NormalizedMooreComplex.objX X n) (PInfty.f n) := by rcases n with _|n · apply top_factors · rw [PInfty_f, NormalizedMooreComplex.objX, finset_inf_factors] intro i _ apply kernelSubobject_factors exact (HigherFacesVanish.of_P (n + 1) n) i le_add_self set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.factors_normalized_Moore_complex_P_infty AlgebraicTopology.DoldKan.factors_normalizedMooreComplex_PInfty /-- `PInfty` factors through the normalized Moore complex -/ @[simps!] def PInftyToNormalizedMooreComplex (X : SimplicialObject A) : K[X] ⟶ N[X] := ChainComplex.ofHom _ _ _ _ _ _ (fun n => factorThru _ _ (factors_normalizedMooreComplex_PInfty n)) fun n => by rw [← cancel_mono (NormalizedMooreComplex.objX X n).arrow, assoc, assoc, factorThru_arrow, ← inclusionOfMooreComplexMap_f, ← normalizedMooreComplex_objD, ← (inclusionOfMooreComplexMap X).comm (n + 1) n, inclusionOfMooreComplexMap_f, factorThru_arrow_assoc, ← alternatingFaceMapComplex_obj_d] exact PInfty.comm (n + 1) n set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.P_infty_to_normalized_Moore_complex AlgebraicTopology.DoldKan.PInftyToNormalizedMooreComplex @[reassoc (attr := simp)] theorem PInftyToNormalizedMooreComplex_comp_inclusionOfMooreComplexMap (X : SimplicialObject A) : PInftyToNormalizedMooreComplex X ≫ inclusionOfMooreComplexMap X = PInfty := by aesop_cat set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.P_infty_to_normalized_Moore_complex_comp_inclusion_of_Moore_complex_map AlgebraicTopology.DoldKan.PInftyToNormalizedMooreComplex_comp_inclusionOfMooreComplexMap @[reassoc (attr := simp)] theorem PInftyToNormalizedMooreComplex_naturality {X Y : SimplicialObject A} (f : X ⟶ Y) : AlternatingFaceMapComplex.map f ≫ PInftyToNormalizedMooreComplex Y = PInftyToNormalizedMooreComplex X ≫ NormalizedMooreComplex.map f := by aesop_cat set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.P_infty_to_normalized_Moore_complex_naturality AlgebraicTopology.DoldKan.PInftyToNormalizedMooreComplex_naturality @[reassoc (attr := simp)]
Mathlib/AlgebraicTopology/DoldKan/Normalized.lean
91
92
theorem PInfty_comp_PInftyToNormalizedMooreComplex (X : SimplicialObject A) : PInfty ≫ PInftyToNormalizedMooreComplex X = PInftyToNormalizedMooreComplex X := by
aesop_cat
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel, Scott Morrison -/ import Mathlib.CategoryTheory.Limits.Shapes.ZeroMorphisms import Mathlib.CategoryTheory.Limits.Shapes.Kernels import Mathlib.CategoryTheory.Abelian.Basic import Mathlib.CategoryTheory.Subobject.Lattice import Mathlib.Order.Atoms #align_import category_theory.simple from "leanprover-community/mathlib"@"4ed0bcaef698011b0692b93a042a2282f490f6b6" /-! # Simple objects We define simple objects in any category with zero morphisms. A simple object is an object `Y` such that any monomorphism `f : X ⟶ Y` is either an isomorphism or zero (but not both). This is formalized as a `Prop` valued typeclass `Simple X`. In some contexts, especially representation theory, simple objects are called "irreducibles". If a morphism `f` out of a simple object is nonzero and has a kernel, then that kernel is zero. (We state this as `kernel.ι f = 0`, but should add `kernel f ≅ 0`.) When the category is abelian, being simple is the same as being cosimple (although we do not state a separate typeclass for this). As a consequence, any nonzero epimorphism out of a simple object is an isomorphism, and any nonzero morphism into a simple object has trivial cokernel. We show that any simple object is indecomposable. -/ noncomputable section open CategoryTheory.Limits namespace CategoryTheory universe v u variable {C : Type u} [Category.{v} C] section variable [HasZeroMorphisms C] /-- An object is simple if monomorphisms into it are (exclusively) either isomorphisms or zero. -/ class Simple (X : C) : Prop where mono_isIso_iff_nonzero : ∀ {Y : C} (f : Y ⟶ X) [Mono f], IsIso f ↔ f ≠ 0 #align category_theory.simple CategoryTheory.Simple /-- A nonzero monomorphism to a simple object is an isomorphism. -/ theorem isIso_of_mono_of_nonzero {X Y : C} [Simple Y] {f : X ⟶ Y} [Mono f] (w : f ≠ 0) : IsIso f := (Simple.mono_isIso_iff_nonzero f).mpr w #align category_theory.is_iso_of_mono_of_nonzero CategoryTheory.isIso_of_mono_of_nonzero
Mathlib/CategoryTheory/Simple.lean
61
77
theorem Simple.of_iso {X Y : C} [Simple Y] (i : X ≅ Y) : Simple X := { mono_isIso_iff_nonzero := fun f m => by haveI : Mono (f ≫ i.hom) := mono_comp _ _ constructor · intro h w have j : IsIso (f ≫ i.hom) := by
infer_instance rw [Simple.mono_isIso_iff_nonzero] at j subst w simp at j · intro h have j : IsIso (f ≫ i.hom) := by apply isIso_of_mono_of_nonzero intro w apply h simpa using (cancel_mono i.inv).2 w rw [← Category.comp_id f, ← i.hom_inv_id, ← Category.assoc] infer_instance }
/- Copyright (c) 2022 Tian Chen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Tian Chen, Mantas Bakšys -/ import Mathlib.Algebra.GeomSum import Mathlib.Algebra.Order.Ring.Basic import Mathlib.Algebra.Ring.Int import Mathlib.NumberTheory.Padics.PadicVal import Mathlib.RingTheory.Ideal.Quotient #align_import number_theory.multiplicity from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" /-! # Multiplicity in Number Theory This file contains results in number theory relating to multiplicity. ## Main statements * `multiplicity.Int.pow_sub_pow` is the lifting the exponent lemma for odd primes. We also prove several variations of the lemma. ## References * [Wikipedia, *Lifting-the-exponent lemma*] (https://en.wikipedia.org/wiki/Lifting-the-exponent_lemma) -/ open Ideal Ideal.Quotient Finset variable {R : Type*} {n : ℕ} section CommRing variable [CommRing R] {a b x y : R} theorem dvd_geom_sum₂_iff_of_dvd_sub {x y p : R} (h : p ∣ x - y) : (p ∣ ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i)) ↔ p ∣ n * y ^ (n - 1) := by rw [← mem_span_singleton, ← Ideal.Quotient.eq] at h simp only [← mem_span_singleton, ← eq_zero_iff_mem, RingHom.map_geom_sum₂, h, geom_sum₂_self, _root_.map_mul, map_pow, map_natCast] #align dvd_geom_sum₂_iff_of_dvd_sub dvd_geom_sum₂_iff_of_dvd_sub
Mathlib/NumberTheory/Multiplicity.lean
46
48
theorem dvd_geom_sum₂_iff_of_dvd_sub' {x y p : R} (h : p ∣ x - y) : (p ∣ ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i)) ↔ p ∣ n * x ^ (n - 1) := by
rw [geom_sum₂_comm, dvd_geom_sum₂_iff_of_dvd_sub]; simpa using h.neg_right
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker -/ import Mathlib.Algebra.Polynomial.Degree.Definitions import Mathlib.Algebra.Polynomial.Induction #align_import data.polynomial.eval from "leanprover-community/mathlib"@"728baa2f54e6062c5879a3e397ac6bac323e506f" /-! # Theory of univariate polynomials The main defs here are `eval₂`, `eval`, and `map`. We give several lemmas about their interaction with each other and with module operations. -/ set_option linter.uppercaseLean3 false noncomputable section open Finset AddMonoidAlgebra open Polynomial namespace Polynomial universe u v w y variable {R : Type u} {S : Type v} {T : Type w} {ι : Type y} {a b : R} {m n : ℕ} section Semiring variable [Semiring R] {p q r : R[X]} section variable [Semiring S] variable (f : R →+* S) (x : S) /-- Evaluate a polynomial `p` given a ring hom `f` from the scalar ring to the target and a value `x` for the variable in the target -/ irreducible_def eval₂ (p : R[X]) : S := p.sum fun e a => f a * x ^ e #align polynomial.eval₂ Polynomial.eval₂ theorem eval₂_eq_sum {f : R →+* S} {x : S} : p.eval₂ f x = p.sum fun e a => f a * x ^ e := by rw [eval₂_def] #align polynomial.eval₂_eq_sum Polynomial.eval₂_eq_sum theorem eval₂_congr {R S : Type*} [Semiring R] [Semiring S] {f g : R →+* S} {s t : S} {φ ψ : R[X]} : f = g → s = t → φ = ψ → eval₂ f s φ = eval₂ g t ψ := by rintro rfl rfl rfl; rfl #align polynomial.eval₂_congr Polynomial.eval₂_congr @[simp] theorem eval₂_at_zero : p.eval₂ f 0 = f (coeff p 0) := by simp (config := { contextual := true }) only [eval₂_eq_sum, zero_pow_eq, mul_ite, mul_zero, mul_one, sum, Classical.not_not, mem_support_iff, sum_ite_eq', ite_eq_left_iff, RingHom.map_zero, imp_true_iff, eq_self_iff_true] #align polynomial.eval₂_at_zero Polynomial.eval₂_at_zero @[simp] theorem eval₂_zero : (0 : R[X]).eval₂ f x = 0 := by simp [eval₂_eq_sum] #align polynomial.eval₂_zero Polynomial.eval₂_zero @[simp] theorem eval₂_C : (C a).eval₂ f x = f a := by simp [eval₂_eq_sum] #align polynomial.eval₂_C Polynomial.eval₂_C @[simp] theorem eval₂_X : X.eval₂ f x = x := by simp [eval₂_eq_sum] #align polynomial.eval₂_X Polynomial.eval₂_X @[simp] theorem eval₂_monomial {n : ℕ} {r : R} : (monomial n r).eval₂ f x = f r * x ^ n := by simp [eval₂_eq_sum] #align polynomial.eval₂_monomial Polynomial.eval₂_monomial @[simp] theorem eval₂_X_pow {n : ℕ} : (X ^ n).eval₂ f x = x ^ n := by rw [X_pow_eq_monomial] convert eval₂_monomial f x (n := n) (r := 1) simp #align polynomial.eval₂_X_pow Polynomial.eval₂_X_pow @[simp] theorem eval₂_add : (p + q).eval₂ f x = p.eval₂ f x + q.eval₂ f x := by simp only [eval₂_eq_sum] apply sum_add_index <;> simp [add_mul] #align polynomial.eval₂_add Polynomial.eval₂_add @[simp] theorem eval₂_one : (1 : R[X]).eval₂ f x = 1 := by rw [← C_1, eval₂_C, f.map_one] #align polynomial.eval₂_one Polynomial.eval₂_one set_option linter.deprecated false in @[simp] theorem eval₂_bit0 : (bit0 p).eval₂ f x = bit0 (p.eval₂ f x) := by rw [bit0, eval₂_add, bit0] #align polynomial.eval₂_bit0 Polynomial.eval₂_bit0 set_option linter.deprecated false in @[simp] theorem eval₂_bit1 : (bit1 p).eval₂ f x = bit1 (p.eval₂ f x) := by rw [bit1, eval₂_add, eval₂_bit0, eval₂_one, bit1] #align polynomial.eval₂_bit1 Polynomial.eval₂_bit1 @[simp]
Mathlib/Algebra/Polynomial/Eval.lean
110
115
theorem eval₂_smul (g : R →+* S) (p : R[X]) (x : S) {s : R} : eval₂ g x (s • p) = g s * eval₂ g x p := by
have A : p.natDegree < p.natDegree.succ := Nat.lt_succ_self _ have B : (s • p).natDegree < p.natDegree.succ := (natDegree_smul_le _ _).trans_lt A rw [eval₂_eq_sum, eval₂_eq_sum, sum_over_range' _ _ _ A, sum_over_range' _ _ _ B] <;> simp [mul_sum, mul_assoc]
/- Copyright (c) 2020 Fox Thomson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Fox Thomson -/ import Mathlib.Computability.DFA import Mathlib.Data.Fintype.Powerset #align_import computability.NFA from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514" /-! # Nondeterministic Finite Automata This file contains the definition of a Nondeterministic Finite Automaton (NFA), a state machine which determines whether a string (implemented as a list over an arbitrary alphabet) is in a regular set by evaluating the string over every possible path. We show that DFA's are equivalent to NFA's however the construction from NFA to DFA uses an exponential number of states. Note that this definition allows for Automaton with infinite states; a `Fintype` instance must be supplied for true NFA's. -/ open Set open Computability universe u v -- Porting note: Required as `NFA` is used in mathlib3 set_option linter.uppercaseLean3 false /-- An NFA is a set of states (`σ`), a transition function from state to state labelled by the alphabet (`step`), a set of starting states (`start`) and a set of acceptance states (`accept`). Note the transition function sends a state to a `Set` of states. These are the states that it may be sent to. -/ structure NFA (α : Type u) (σ : Type v) where step : σ → α → Set σ start : Set σ accept : Set σ #align NFA NFA variable {α : Type u} {σ σ' : Type v} (M : NFA α σ) namespace NFA instance : Inhabited (NFA α σ) := ⟨NFA.mk (fun _ _ => ∅) ∅ ∅⟩ /-- `M.stepSet S a` is the union of `M.step s a` for all `s ∈ S`. -/ def stepSet (S : Set σ) (a : α) : Set σ := ⋃ s ∈ S, M.step s a #align NFA.step_set NFA.stepSet
Mathlib/Computability/NFA.lean
53
54
theorem mem_stepSet (s : σ) (S : Set σ) (a : α) : s ∈ M.stepSet S a ↔ ∃ t ∈ S, s ∈ M.step t a := by
simp [stepSet]
/- Copyright (c) 2021 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Topology.EMetricSpace.Basic #align_import topology.metric_space.metric_separated from "leanprover-community/mathlib"@"57ac39bd365c2f80589a700f9fbb664d3a1a30c2" /-! # Metric separated pairs of sets In this file we define the predicate `IsMetricSeparated`. We say that two sets in an (extended) metric space are *metric separated* if the (extended) distance between `x ∈ s` and `y ∈ t` is bounded from below by a positive constant. This notion is useful, e.g., to define metric outer measures. -/ open EMetric Set noncomputable section /-- Two sets in an (extended) metric space are called *metric separated* if the (extended) distance between `x ∈ s` and `y ∈ t` is bounded from below by a positive constant. -/ def IsMetricSeparated {X : Type*} [EMetricSpace X] (s t : Set X) := ∃ r, r ≠ 0 ∧ ∀ x ∈ s, ∀ y ∈ t, r ≤ edist x y #align is_metric_separated IsMetricSeparated namespace IsMetricSeparated variable {X : Type*} [EMetricSpace X] {s t : Set X} {x y : X} @[symm] theorem symm (h : IsMetricSeparated s t) : IsMetricSeparated t s := let ⟨r, r0, hr⟩ := h ⟨r, r0, fun y hy x hx => edist_comm x y ▸ hr x hx y hy⟩ #align is_metric_separated.symm IsMetricSeparated.symm theorem comm : IsMetricSeparated s t ↔ IsMetricSeparated t s := ⟨symm, symm⟩ #align is_metric_separated.comm IsMetricSeparated.comm @[simp] theorem empty_left (s : Set X) : IsMetricSeparated ∅ s := ⟨1, one_ne_zero, fun _x => False.elim⟩ #align is_metric_separated.empty_left IsMetricSeparated.empty_left @[simp] theorem empty_right (s : Set X) : IsMetricSeparated s ∅ := (empty_left s).symm #align is_metric_separated.empty_right IsMetricSeparated.empty_right protected theorem disjoint (h : IsMetricSeparated s t) : Disjoint s t := let ⟨r, r0, hr⟩ := h Set.disjoint_left.mpr fun x hx1 hx2 => r0 <| by simpa using hr x hx1 x hx2 #align is_metric_separated.disjoint IsMetricSeparated.disjoint theorem subset_compl_right (h : IsMetricSeparated s t) : s ⊆ tᶜ := fun _ hs ht => h.disjoint.le_bot ⟨hs, ht⟩ #align is_metric_separated.subset_compl_right IsMetricSeparated.subset_compl_right @[mono] theorem mono {s' t'} (hs : s ⊆ s') (ht : t ⊆ t') : IsMetricSeparated s' t' → IsMetricSeparated s t := fun ⟨r, r0, hr⟩ => ⟨r, r0, fun x hx y hy => hr x (hs hx) y (ht hy)⟩ #align is_metric_separated.mono IsMetricSeparated.mono theorem mono_left {s'} (h' : IsMetricSeparated s' t) (hs : s ⊆ s') : IsMetricSeparated s t := h'.mono hs Subset.rfl #align is_metric_separated.mono_left IsMetricSeparated.mono_left theorem mono_right {t'} (h' : IsMetricSeparated s t') (ht : t ⊆ t') : IsMetricSeparated s t := h'.mono Subset.rfl ht #align is_metric_separated.mono_right IsMetricSeparated.mono_right theorem union_left {s'} (h : IsMetricSeparated s t) (h' : IsMetricSeparated s' t) : IsMetricSeparated (s ∪ s') t := by rcases h, h' with ⟨⟨r, r0, hr⟩, ⟨r', r0', hr'⟩⟩ refine ⟨min r r', ?_, fun x hx y hy => hx.elim ?_ ?_⟩ · rw [← pos_iff_ne_zero] at r0 r0' ⊢ exact lt_min r0 r0' · exact fun hx => (min_le_left _ _).trans (hr _ hx _ hy) · exact fun hx => (min_le_right _ _).trans (hr' _ hx _ hy) #align is_metric_separated.union_left IsMetricSeparated.union_left @[simp] theorem union_left_iff {s'} : IsMetricSeparated (s ∪ s') t ↔ IsMetricSeparated s t ∧ IsMetricSeparated s' t := ⟨fun h => ⟨h.mono_left subset_union_left, h.mono_left subset_union_right⟩, fun h => h.1.union_left h.2⟩ #align is_metric_separated.union_left_iff IsMetricSeparated.union_left_iff theorem union_right {t'} (h : IsMetricSeparated s t) (h' : IsMetricSeparated s t') : IsMetricSeparated s (t ∪ t') := (h.symm.union_left h'.symm).symm #align is_metric_separated.union_right IsMetricSeparated.union_right @[simp] theorem union_right_iff {t'} : IsMetricSeparated s (t ∪ t') ↔ IsMetricSeparated s t ∧ IsMetricSeparated s t' := comm.trans <| union_left_iff.trans <| and_congr comm comm #align is_metric_separated.union_right_iff IsMetricSeparated.union_right_iff
Mathlib/Topology/MetricSpace/MetricSeparated.lean
106
109
theorem finite_iUnion_left_iff {ι : Type*} {I : Set ι} (hI : I.Finite) {s : ι → Set X} {t : Set X} : IsMetricSeparated (⋃ i ∈ I, s i) t ↔ ∀ i ∈ I, IsMetricSeparated (s i) t := by
refine Finite.induction_on hI (by simp) @fun i I _ _ hI => ?_ rw [biUnion_insert, forall_mem_insert, union_left_iff, hI]
/- Copyright (c) 2023 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Loeffler -/ import Mathlib.Analysis.Convolution import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup import Mathlib.Analysis.Analytic.IsolatedZeros import Mathlib.Analysis.Complex.CauchyIntegral #align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090" /-! # The Beta function, and further properties of the Gamma function In this file we define the Beta integral, relate Beta and Gamma functions, and prove some refined properties of the Gamma function using these relations. ## Results on the Beta function * `Complex.betaIntegral`: the Beta function `Β(u, v)`, where `u`, `v` are complex with positive real part. * `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula `Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`. ## Results on the Gamma function * `Complex.Gamma_ne_zero`: for all `s : ℂ` with `s ∉ {-n : n ∈ ℕ}` we have `Γ s ≠ 0`. * `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n → ∞` of the sequence `n ↦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Γ(s)`. * `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula `Gamma s * Gamma (1 - s) = π / sin π s`. * `Complex.differentiable_one_div_Gamma`: the function `1 / Γ(s)` is differentiable everywhere. * `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula `Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * √π`. * `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`, `Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above. -/ noncomputable section set_option linter.uppercaseLean3 false open Filter intervalIntegral Set Real MeasureTheory open scoped Nat Topology Real section BetaIntegral /-! ## The Beta function -/ namespace Complex /-- The Beta function `Β (u, v)`, defined as `∫ x:ℝ in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/ noncomputable def betaIntegral (u v : ℂ) : ℂ := ∫ x : ℝ in (0)..1, (x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ (v - 1) #align complex.beta_integral Complex.betaIntegral /-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/ theorem betaIntegral_convergent_left {u : ℂ} (hu : 0 < re u) (v : ℂ) : IntervalIntegrable (fun x => (x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ (v - 1) : ℝ → ℂ) volume 0 (1 / 2) := by apply IntervalIntegrable.mul_continuousOn · refine intervalIntegral.intervalIntegrable_cpow' ?_ rwa [sub_re, one_re, ← zero_sub, sub_lt_sub_iff_right] · apply ContinuousAt.continuousOn intro x hx rw [uIcc_of_le (by positivity : (0 : ℝ) ≤ 1 / 2)] at hx apply ContinuousAt.cpow · exact (continuous_const.sub continuous_ofReal).continuousAt · exact continuousAt_const · norm_cast exact ofReal_mem_slitPlane.2 <| by linarith only [hx.2] #align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left /-- The Beta integral is convergent for all `u, v` of positive real part. -/
Mathlib/Analysis/SpecialFunctions/Gamma/Beta.lean
80
90
theorem betaIntegral_convergent {u v : ℂ} (hu : 0 < re u) (hv : 0 < re v) : IntervalIntegrable (fun x => (x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ (v - 1) : ℝ → ℂ) volume 0 1 := by
refine (betaIntegral_convergent_left hu v).trans ?_ rw [IntervalIntegrable.iff_comp_neg] convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1 · ext1 x conv_lhs => rw [mul_comm] congr 2 <;> · push_cast; ring · norm_num · norm_num
/- Copyright (c) 2020 Heather Macbeth, Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Heather Macbeth, Patrick Massot -/ import Mathlib.Algebra.Group.Subgroup.Basic import Mathlib.Algebra.Order.Archimedean import Mathlib.Data.Set.Lattice #align_import group_theory.archimedean from "leanprover-community/mathlib"@"f93c11933efbc3c2f0299e47b8ff83e9b539cbf6" /-! # Archimedean groups This file proves a few facts about ordered groups which satisfy the `Archimedean` property, that is: `class Archimedean (α) [OrderedAddCommMonoid α] : Prop :=` `(arch : ∀ (x : α) {y}, 0 < y → ∃ n : ℕ, x ≤ n • y)` They are placed here in a separate file (rather than incorporated as a continuation of `Algebra.Order.Archimedean`) because they rely on some imports from `GroupTheory` -- bundled subgroups in particular. The main result is `AddSubgroup.cyclic_of_min`: a subgroup of a decidable archimedean abelian group is cyclic, if its set of positive elements has a minimal element. This result is used in this file to deduce `Int.subgroup_cyclic`, proving that every subgroup of `ℤ` is cyclic. (There are several other methods one could use to prove this fact, including more purely algebraic methods, but none seem to exist in mathlib as of writing. The closest is `Subgroup.is_cyclic`, but that has not been transferred to `AddSubgroup`.) The result is also used in `Topology.Instances.Real` as an ingredient in the classification of subgroups of `ℝ`. -/ open Set variable {G : Type*} [LinearOrderedAddCommGroup G] [Archimedean G] /-- Given a subgroup `H` of a decidable linearly ordered archimedean abelian group `G`, if there exists a minimal element `a` of `H ∩ G_{>0}` then `H` is generated by `a`. -/
Mathlib/GroupTheory/Archimedean.lean
40
54
theorem AddSubgroup.cyclic_of_min {H : AddSubgroup G} {a : G} (ha : IsLeast { g : G | g ∈ H ∧ 0 < g } a) : H = AddSubgroup.closure {a} := by
obtain ⟨⟨a_in, a_pos⟩, a_min⟩ := ha refine le_antisymm ?_ (H.closure_le.mpr <| by simp [a_in]) intro g g_in obtain ⟨k, ⟨nonneg, lt⟩, _⟩ := existsUnique_zsmul_near_of_pos' a_pos g have h_zero : g - k • a = 0 := by by_contra h have h : a ≤ g - k • a := by refine a_min ⟨?_, ?_⟩ · exact AddSubgroup.sub_mem H g_in (AddSubgroup.zsmul_mem H a_in k) · exact lt_of_le_of_ne nonneg (Ne.symm h) have h' : ¬a ≤ g - k • a := not_le.mpr lt contradiction simp [sub_eq_zero.mp h_zero, AddSubgroup.mem_closure_singleton]
/- Copyright (c) 2020 Frédéric Dupuis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Frédéric Dupuis -/ import Mathlib.Analysis.NormedSpace.FiniteDimension import Mathlib.Analysis.RCLike.Basic #align_import data.is_R_or_C.lemmas from "leanprover-community/mathlib"@"468b141b14016d54b479eb7a0fff1e360b7e3cf6" /-! # Further lemmas about `RCLike` -/ variable {K E : Type*} [RCLike K] namespace Polynomial open Polynomial theorem ofReal_eval (p : ℝ[X]) (x : ℝ) : (↑(p.eval x) : K) = aeval (↑x) p := (@aeval_algebraMap_apply_eq_algebraMap_eval ℝ K _ _ _ x p).symm #align polynomial.of_real_eval Polynomial.ofReal_eval end Polynomial namespace FiniteDimensional open scoped Classical open RCLike library_note "RCLike instance"/-- This instance generates a type-class problem with a metavariable `?m` that should satisfy `RCLike ?m`. Since this can only be satisfied by `ℝ` or `ℂ`, this does not cause problems. -/ /-- An `RCLike` field is finite-dimensional over `ℝ`, since it is spanned by `{1, I}`. -/ -- Porting note(#12094): removed nolint; dangerous_instance linter not ported yet -- @[nolint dangerous_instance] instance rclike_to_real : FiniteDimensional ℝ K := ⟨{1, I}, by suffices ∀ x : K, ∃ a b : ℝ, a • 1 + b • I = x by simpa [Submodule.eq_top_iff', Submodule.mem_span_pair] exact fun x ↦ ⟨re x, im x, by simp [real_smul_eq_coe_mul]⟩⟩ #align finite_dimensional.is_R_or_C_to_real FiniteDimensional.rclike_to_real variable (K E) variable [NormedAddCommGroup E] [NormedSpace K E] /-- A finite dimensional vector space over an `RCLike` is a proper metric space. This is not an instance because it would cause a search for `FiniteDimensional ?x E` before `RCLike ?x`. -/ theorem proper_rclike [FiniteDimensional K E] : ProperSpace E := by letI : NormedSpace ℝ E := RestrictScalars.normedSpace ℝ K E letI : FiniteDimensional ℝ E := FiniteDimensional.trans ℝ K E infer_instance #align finite_dimensional.proper_is_R_or_C FiniteDimensional.proper_rclike variable {E} instance RCLike.properSpace_submodule (S : Submodule K E) [FiniteDimensional K S] : ProperSpace S := proper_rclike K S #align finite_dimensional.is_R_or_C.proper_space_submodule FiniteDimensional.RCLike.properSpace_submodule end FiniteDimensional namespace RCLike @[simp, rclike_simps]
Mathlib/Analysis/RCLike/Lemmas.lean
71
74
theorem reCLM_norm : ‖(reCLM : K →L[ℝ] ℝ)‖ = 1 := by
apply le_antisymm (LinearMap.mkContinuous_norm_le _ zero_le_one _) convert ContinuousLinearMap.ratio_le_opNorm (reCLM : K →L[ℝ] ℝ) (1 : K) simp
/- Copyright (c) 2021 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Order.Interval.Finset.Nat #align_import data.fin.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29" /-! # Finite intervals in `Fin n` This file proves that `Fin n` is a `LocallyFiniteOrder` and calculates the cardinality of its intervals as Finsets and Fintypes. -/ assert_not_exists MonoidWithZero namespace Fin variable {n : ℕ} (a b : Fin n) @[simp, norm_cast] theorem coe_sup : ↑(a ⊔ b) = (a ⊔ b : ℕ) := rfl #align fin.coe_sup Fin.coe_sup @[simp, norm_cast] theorem coe_inf : ↑(a ⊓ b) = (a ⊓ b : ℕ) := rfl #align fin.coe_inf Fin.coe_inf @[simp, norm_cast] theorem coe_max : ↑(max a b) = (max a b : ℕ) := rfl #align fin.coe_max Fin.coe_max @[simp, norm_cast] theorem coe_min : ↑(min a b) = (min a b : ℕ) := rfl #align fin.coe_min Fin.coe_min end Fin open Finset Fin Function namespace Fin variable (n : ℕ) instance instLocallyFiniteOrder : LocallyFiniteOrder (Fin n) := OrderIso.locallyFiniteOrder Fin.orderIsoSubtype instance instLocallyFiniteOrderBot : LocallyFiniteOrderBot (Fin n) := OrderIso.locallyFiniteOrderBot Fin.orderIsoSubtype instance instLocallyFiniteOrderTop : ∀ n, LocallyFiniteOrderTop (Fin n) | 0 => IsEmpty.toLocallyFiniteOrderTop | _ + 1 => inferInstance variable {n} (a b : Fin n) theorem Icc_eq_finset_subtype : Icc a b = (Icc (a : ℕ) b).fin n := rfl #align fin.Icc_eq_finset_subtype Fin.Icc_eq_finset_subtype theorem Ico_eq_finset_subtype : Ico a b = (Ico (a : ℕ) b).fin n := rfl #align fin.Ico_eq_finset_subtype Fin.Ico_eq_finset_subtype theorem Ioc_eq_finset_subtype : Ioc a b = (Ioc (a : ℕ) b).fin n := rfl #align fin.Ioc_eq_finset_subtype Fin.Ioc_eq_finset_subtype theorem Ioo_eq_finset_subtype : Ioo a b = (Ioo (a : ℕ) b).fin n := rfl #align fin.Ioo_eq_finset_subtype Fin.Ioo_eq_finset_subtype theorem uIcc_eq_finset_subtype : uIcc a b = (uIcc (a : ℕ) b).fin n := rfl #align fin.uIcc_eq_finset_subtype Fin.uIcc_eq_finset_subtype @[simp] theorem map_valEmbedding_Icc : (Icc a b).map Fin.valEmbedding = Icc ↑a ↑b := by simp [Icc_eq_finset_subtype, Finset.fin, Finset.map_map, Icc_filter_lt_of_lt_right] #align fin.map_subtype_embedding_Icc Fin.map_valEmbedding_Icc @[simp] theorem map_valEmbedding_Ico : (Ico a b).map Fin.valEmbedding = Ico ↑a ↑b := by simp [Ico_eq_finset_subtype, Finset.fin, Finset.map_map] #align fin.map_subtype_embedding_Ico Fin.map_valEmbedding_Ico @[simp]
Mathlib/Order/Interval/Finset/Fin.lean
89
90
theorem map_valEmbedding_Ioc : (Ioc a b).map Fin.valEmbedding = Ioc ↑a ↑b := by
simp [Ioc_eq_finset_subtype, Finset.fin, Finset.map_map, Ioc_filter_lt_of_lt_right]
/- Copyright (c) 2015 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Leonardo de Moura, Jeremy Avigad -/ import Mathlib.Data.Finset.Image #align_import data.finset.card from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Cardinality of a finite set This defines the cardinality of a `Finset` and provides induction principles for finsets. ## Main declarations * `Finset.card`: `s.card : ℕ` returns the cardinality of `s : Finset α`. ### Induction principles * `Finset.strongInduction`: Strong induction * `Finset.strongInductionOn` * `Finset.strongDownwardInduction` * `Finset.strongDownwardInductionOn` * `Finset.case_strong_induction_on` * `Finset.Nonempty.strong_induction` -/ assert_not_exists MonoidWithZero -- TODO: After a lot more work, -- assert_not_exists OrderedCommMonoid open Function Multiset Nat variable {α β R : Type*} namespace Finset variable {s t : Finset α} {a b : α} /-- `s.card` is the number of elements of `s`, aka its cardinality. -/ def card (s : Finset α) : ℕ := Multiset.card s.1 #align finset.card Finset.card theorem card_def (s : Finset α) : s.card = Multiset.card s.1 := rfl #align finset.card_def Finset.card_def @[simp] lemma card_val (s : Finset α) : Multiset.card s.1 = s.card := rfl #align finset.card_val Finset.card_val @[simp] theorem card_mk {m nodup} : (⟨m, nodup⟩ : Finset α).card = Multiset.card m := rfl #align finset.card_mk Finset.card_mk @[simp] theorem card_empty : card (∅ : Finset α) = 0 := rfl #align finset.card_empty Finset.card_empty @[gcongr] theorem card_le_card : s ⊆ t → s.card ≤ t.card := Multiset.card_le_card ∘ val_le_iff.mpr #align finset.card_le_of_subset Finset.card_le_card @[mono] theorem card_mono : Monotone (@card α) := by apply card_le_card #align finset.card_mono Finset.card_mono @[simp] lemma card_eq_zero : s.card = 0 ↔ s = ∅ := card_eq_zero.trans val_eq_zero lemma card_ne_zero : s.card ≠ 0 ↔ s.Nonempty := card_eq_zero.ne.trans nonempty_iff_ne_empty.symm lemma card_pos : 0 < s.card ↔ s.Nonempty := Nat.pos_iff_ne_zero.trans card_ne_zero #align finset.card_eq_zero Finset.card_eq_zero #align finset.card_pos Finset.card_pos alias ⟨_, Nonempty.card_pos⟩ := card_pos alias ⟨_, Nonempty.card_ne_zero⟩ := card_ne_zero #align finset.nonempty.card_pos Finset.Nonempty.card_pos theorem card_ne_zero_of_mem (h : a ∈ s) : s.card ≠ 0 := (not_congr card_eq_zero).2 <| ne_empty_of_mem h #align finset.card_ne_zero_of_mem Finset.card_ne_zero_of_mem @[simp] theorem card_singleton (a : α) : card ({a} : Finset α) = 1 := Multiset.card_singleton _ #align finset.card_singleton Finset.card_singleton theorem card_singleton_inter [DecidableEq α] : ({a} ∩ s).card ≤ 1 := by cases' Finset.decidableMem a s with h h · simp [Finset.singleton_inter_of_not_mem h] · simp [Finset.singleton_inter_of_mem h] #align finset.card_singleton_inter Finset.card_singleton_inter @[simp] theorem card_cons (h : a ∉ s) : (s.cons a h).card = s.card + 1 := Multiset.card_cons _ _ #align finset.card_cons Finset.card_cons section InsertErase variable [DecidableEq α] @[simp] theorem card_insert_of_not_mem (h : a ∉ s) : (insert a s).card = s.card + 1 := by rw [← cons_eq_insert _ _ h, card_cons] #align finset.card_insert_of_not_mem Finset.card_insert_of_not_mem
Mathlib/Data/Finset/Card.lean
111
111
theorem card_insert_of_mem (h : a ∈ s) : card (insert a s) = s.card := by
rw [insert_eq_of_mem h]
/- Copyright (c) 2020 Robert Y. Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Y. Lewis -/ import Batteries.Tactic.Lint.Basic import Mathlib.Algebra.Order.Monoid.Unbundled.Basic import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Algebra.Order.ZeroLEOne import Mathlib.Data.Nat.Cast.Order import Mathlib.Init.Data.Int.Order /-! # Lemmas for `linarith`. Those in the `Linarith` namespace should stay here. Those outside the `Linarith` namespace may be deleted as they are ported to mathlib4. -/ set_option autoImplicit true namespace Linarith theorem lt_irrefl {α : Type u} [Preorder α] {a : α} : ¬a < a := _root_.lt_irrefl a
Mathlib/Tactic/Linarith/Lemmas.lean
27
28
theorem eq_of_eq_of_eq {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (hb : b = 0) : a + b = 0 := by
simp [*]
/- Copyright (c) 2021 Alena Gusakov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alena Gusakov, Jeremy Tan -/ import Mathlib.Combinatorics.Enumerative.DoubleCounting import Mathlib.Combinatorics.SimpleGraph.AdjMatrix import Mathlib.Combinatorics.SimpleGraph.Basic import Mathlib.Data.Set.Finite #align_import combinatorics.simple_graph.strongly_regular from "leanprover-community/mathlib"@"2b35fc7bea4640cb75e477e83f32fbd538920822" /-! # Strongly regular graphs ## Main definitions * `G.IsSRGWith n k ℓ μ` (see `SimpleGraph.IsSRGWith`) is a structure for a `SimpleGraph` satisfying the following conditions: * The cardinality of the vertex set is `n` * `G` is a regular graph with degree `k` * The number of common neighbors between any two adjacent vertices in `G` is `ℓ` * The number of common neighbors between any two nonadjacent vertices in `G` is `μ` ## Main theorems * `IsSRGWith.compl`: the complement of a strongly regular graph is strongly regular. * `IsSRGWith.param_eq`: `k * (k - ℓ - 1) = (n - k - 1) * μ` when `0 < n`. * `IsSRGWith.matrix_eq`: let `A` and `C` be `G`'s and `Gᶜ`'s adjacency matrices respectively and `I` be the identity matrix, then `A ^ 2 = k • I + ℓ • A + μ • C`. -/ open Finset universe u namespace SimpleGraph variable {V : Type u} [Fintype V] [DecidableEq V] variable (G : SimpleGraph V) [DecidableRel G.Adj] /-- A graph is strongly regular with parameters `n k ℓ μ` if * its vertex set has cardinality `n` * it is regular with degree `k` * every pair of adjacent vertices has `ℓ` common neighbors * every pair of nonadjacent vertices has `μ` common neighbors -/ structure IsSRGWith (n k ℓ μ : ℕ) : Prop where card : Fintype.card V = n regular : G.IsRegularOfDegree k of_adj : ∀ v w : V, G.Adj v w → Fintype.card (G.commonNeighbors v w) = ℓ of_not_adj : Pairwise fun v w => ¬G.Adj v w → Fintype.card (G.commonNeighbors v w) = μ set_option linter.uppercaseLean3 false in #align simple_graph.is_SRG_with SimpleGraph.IsSRGWith variable {G} {n k ℓ μ : ℕ} /-- Empty graphs are strongly regular. Note that `ℓ` can take any value for empty graphs, since there are no pairs of adjacent vertices. -/ theorem bot_strongly_regular : (⊥ : SimpleGraph V).IsSRGWith (Fintype.card V) 0 ℓ 0 where card := rfl regular := bot_degree of_adj := fun v w h => h.elim of_not_adj := fun v w _h => by simp only [card_eq_zero, Fintype.card_ofFinset, forall_true_left, not_false_iff, bot_adj] ext simp [mem_commonNeighbors] #align simple_graph.bot_strongly_regular SimpleGraph.bot_strongly_regular /-- Complete graphs are strongly regular. Note that `μ` can take any value for complete graphs, since there are no distinct pairs of non-adjacent vertices. -/ theorem IsSRGWith.top : (⊤ : SimpleGraph V).IsSRGWith (Fintype.card V) (Fintype.card V - 1) (Fintype.card V - 2) μ where card := rfl regular := IsRegularOfDegree.top of_adj := fun v w h => by rw [card_commonNeighbors_top] exact h of_not_adj := fun v w h h' => False.elim (h' ((top_adj v w).2 h)) set_option linter.uppercaseLean3 false in #align simple_graph.is_SRG_with.top SimpleGraph.IsSRGWith.top theorem IsSRGWith.card_neighborFinset_union_eq {v w : V} (h : G.IsSRGWith n k ℓ μ) : (G.neighborFinset v ∪ G.neighborFinset w).card = 2 * k - Fintype.card (G.commonNeighbors v w) := by apply Nat.add_right_cancel (m := Fintype.card (G.commonNeighbors v w)) rw [Nat.sub_add_cancel, ← Set.toFinset_card] -- Porting note: Set.toFinset_inter needs workaround to use unification to solve for one of the -- instance arguments: · simp [commonNeighbors, @Set.toFinset_inter _ _ _ _ _ _ (_), ← neighborFinset_def, Finset.card_union_add_card_inter, card_neighborFinset_eq_degree, h.regular.degree_eq, two_mul] · apply le_trans (card_commonNeighbors_le_degree_left _ _ _) simp [h.regular.degree_eq, two_mul] set_option linter.uppercaseLean3 false in #align simple_graph.is_SRG_with.card_neighbor_finset_union_eq SimpleGraph.IsSRGWith.card_neighborFinset_union_eq /-- Assuming `G` is strongly regular, `2*(k + 1) - m` in `G` is the number of vertices that are adjacent to either `v` or `w` when `¬G.Adj v w`. So it's the cardinality of `G.neighborSet v ∪ G.neighborSet w`. -/
Mathlib/Combinatorics/SimpleGraph/StronglyRegular.lean
102
106
theorem IsSRGWith.card_neighborFinset_union_of_not_adj {v w : V} (h : G.IsSRGWith n k ℓ μ) (hne : v ≠ w) (ha : ¬G.Adj v w) : (G.neighborFinset v ∪ G.neighborFinset w).card = 2 * k - μ := by
rw [← h.of_not_adj hne ha] apply h.card_neighborFinset_union_eq
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne -/ import Mathlib.Analysis.SpecialFunctions.Exp import Mathlib.Data.Nat.Factorization.Basic import Mathlib.Analysis.NormedSpace.Real #align_import analysis.special_functions.log.basic from "leanprover-community/mathlib"@"f23a09ce6d3f367220dc3cecad6b7eb69eb01690" /-! # Real logarithm In this file we define `Real.log` to be the logarithm of a real number. As usual, we extend it from its domain `(0, +∞)` to a globally defined function. We choose to do it so that `log 0 = 0` and `log (-x) = log x`. We prove some basic properties of this function and show that it is continuous. ## Tags logarithm, continuity -/ open Set Filter Function open Topology noncomputable section namespace Real variable {x y : ℝ} /-- The real logarithm function, equal to the inverse of the exponential for `x > 0`, to `log |x|` for `x < 0`, and to `0` for `0`. We use this unconventional extension to `(-∞, 0]` as it gives the formula `log (x * y) = log x + log y` for all nonzero `x` and `y`, and the derivative of `log` is `1/x` away from `0`. -/ -- @[pp_nodot] -- Porting note: removed noncomputable def log (x : ℝ) : ℝ := if hx : x = 0 then 0 else expOrderIso.symm ⟨|x|, abs_pos.2 hx⟩ #align real.log Real.log theorem log_of_ne_zero (hx : x ≠ 0) : log x = expOrderIso.symm ⟨|x|, abs_pos.2 hx⟩ := dif_neg hx #align real.log_of_ne_zero Real.log_of_ne_zero theorem log_of_pos (hx : 0 < x) : log x = expOrderIso.symm ⟨x, hx⟩ := by rw [log_of_ne_zero hx.ne'] congr exact abs_of_pos hx #align real.log_of_pos Real.log_of_pos theorem exp_log_eq_abs (hx : x ≠ 0) : exp (log x) = |x| := by rw [log_of_ne_zero hx, ← coe_expOrderIso_apply, OrderIso.apply_symm_apply, Subtype.coe_mk] #align real.exp_log_eq_abs Real.exp_log_eq_abs theorem exp_log (hx : 0 < x) : exp (log x) = x := by rw [exp_log_eq_abs hx.ne'] exact abs_of_pos hx #align real.exp_log Real.exp_log theorem exp_log_of_neg (hx : x < 0) : exp (log x) = -x := by rw [exp_log_eq_abs (ne_of_lt hx)] exact abs_of_neg hx #align real.exp_log_of_neg Real.exp_log_of_neg theorem le_exp_log (x : ℝ) : x ≤ exp (log x) := by by_cases h_zero : x = 0 · rw [h_zero, log, dif_pos rfl, exp_zero] exact zero_le_one · rw [exp_log_eq_abs h_zero] exact le_abs_self _ #align real.le_exp_log Real.le_exp_log @[simp] theorem log_exp (x : ℝ) : log (exp x) = x := exp_injective <| exp_log (exp_pos x) #align real.log_exp Real.log_exp theorem surjOn_log : SurjOn log (Ioi 0) univ := fun x _ => ⟨exp x, exp_pos x, log_exp x⟩ #align real.surj_on_log Real.surjOn_log theorem log_surjective : Surjective log := fun x => ⟨exp x, log_exp x⟩ #align real.log_surjective Real.log_surjective @[simp] theorem range_log : range log = univ := log_surjective.range_eq #align real.range_log Real.range_log @[simp] theorem log_zero : log 0 = 0 := dif_pos rfl #align real.log_zero Real.log_zero @[simp] theorem log_one : log 1 = 0 := exp_injective <| by rw [exp_log zero_lt_one, exp_zero] #align real.log_one Real.log_one @[simp] theorem log_abs (x : ℝ) : log |x| = log x := by by_cases h : x = 0 · simp [h] · rw [← exp_eq_exp, exp_log_eq_abs h, exp_log_eq_abs (abs_pos.2 h).ne', abs_abs] #align real.log_abs Real.log_abs @[simp] theorem log_neg_eq_log (x : ℝ) : log (-x) = log x := by rw [← log_abs x, ← log_abs (-x), abs_neg] #align real.log_neg_eq_log Real.log_neg_eq_log theorem sinh_log {x : ℝ} (hx : 0 < x) : sinh (log x) = (x - x⁻¹) / 2 := by rw [sinh_eq, exp_neg, exp_log hx] #align real.sinh_log Real.sinh_log
Mathlib/Analysis/SpecialFunctions/Log/Basic.lean
118
119
theorem cosh_log {x : ℝ} (hx : 0 < x) : cosh (log x) = (x + x⁻¹) / 2 := by
rw [cosh_eq, exp_neg, exp_log hx]
/- Copyright (c) 2021 Yaël Dillies, Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Bhavik Mehta -/ import Mathlib.Analysis.Convex.Hull import Mathlib.LinearAlgebra.AffineSpace.Independent #align_import analysis.convex.simplicial_complex.basic from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Simplicial complexes In this file, we define simplicial complexes in `𝕜`-modules. A simplicial complex is a collection of simplices closed by inclusion (of vertices) and intersection (of underlying sets). We model them by a downward-closed set of affine independent finite sets whose convex hulls "glue nicely", each finite set and its convex hull corresponding respectively to the vertices and the underlying set of a simplex. ## Main declarations * `SimplicialComplex 𝕜 E`: A simplicial complex in the `𝕜`-module `E`. * `SimplicialComplex.vertices`: The zero dimensional faces of a simplicial complex. * `SimplicialComplex.facets`: The maximal faces of a simplicial complex. ## Notation `s ∈ K` means that `s` is a face of `K`. `K ≤ L` means that the faces of `K` are faces of `L`. ## Implementation notes "glue nicely" usually means that the intersection of two faces (as sets in the ambient space) is a face. Given that we store the vertices, not the faces, this would be a bit awkward to spell. Instead, `SimplicialComplex.inter_subset_convexHull` is an equivalent condition which works on the vertices. ## TODO Simplicial complexes can be generalized to affine spaces once `ConvexHull` has been ported. -/ open Finset Set variable (𝕜 E : Type*) {ι : Type*} [OrderedRing 𝕜] [AddCommGroup E] [Module 𝕜 E] namespace Geometry -- TODO: update to new binder order? not sure what binder order is correct for `down_closed`. /-- A simplicial complex in a `𝕜`-module is a collection of simplices which glue nicely together. Note that the textbook meaning of "glue nicely" is given in `Geometry.SimplicialComplex.disjoint_or_exists_inter_eq_convexHull`. It is mostly useless, as `Geometry.SimplicialComplex.convexHull_inter_convexHull` is enough for all purposes. -/ @[ext] structure SimplicialComplex where /-- the faces of this simplicial complex: currently, given by their spanning vertices -/ faces : Set (Finset E) /-- the empty set is not a face: hence, all faces are non-empty -/ not_empty_mem : ∅ ∉ faces /-- the vertices in each face are affine independent: this is an implementation detail -/ indep : ∀ {s}, s ∈ faces → AffineIndependent 𝕜 ((↑) : s → E) /-- faces are downward closed: a non-empty subset of its spanning vertices spans another face -/ down_closed : ∀ {s t}, s ∈ faces → t ⊆ s → t ≠ ∅ → t ∈ faces inter_subset_convexHull : ∀ {s t}, s ∈ faces → t ∈ faces → convexHull 𝕜 ↑s ∩ convexHull 𝕜 ↑t ⊆ convexHull 𝕜 (s ∩ t : Set E) #align geometry.simplicial_complex Geometry.SimplicialComplex namespace SimplicialComplex variable {𝕜 E} variable {K : SimplicialComplex 𝕜 E} {s t : Finset E} {x : E} /-- A `Finset` belongs to a `SimplicialComplex` if it's a face of it. -/ instance : Membership (Finset E) (SimplicialComplex 𝕜 E) := ⟨fun s K => s ∈ K.faces⟩ /-- The underlying space of a simplicial complex is the union of its faces. -/ def space (K : SimplicialComplex 𝕜 E) : Set E := ⋃ s ∈ K.faces, convexHull 𝕜 (s : Set E) #align geometry.simplicial_complex.space Geometry.SimplicialComplex.space -- Porting note: Expanded `∃ s ∈ K.faces` to get the type to match more closely with Lean 3 theorem mem_space_iff : x ∈ K.space ↔ ∃ s ∈ K.faces, x ∈ convexHull 𝕜 (s : Set E) := by simp [space] #align geometry.simplicial_complex.mem_space_iff Geometry.SimplicialComplex.mem_space_iff -- Porting note: Original proof was `:= subset_biUnion_of_mem hs` theorem convexHull_subset_space (hs : s ∈ K.faces) : convexHull 𝕜 ↑s ⊆ K.space := by convert subset_biUnion_of_mem hs rfl #align geometry.simplicial_complex.convex_hull_subset_space Geometry.SimplicialComplex.convexHull_subset_space protected theorem subset_space (hs : s ∈ K.faces) : (s : Set E) ⊆ K.space := (subset_convexHull 𝕜 _).trans <| convexHull_subset_space hs #align geometry.simplicial_complex.subset_space Geometry.SimplicialComplex.subset_space theorem convexHull_inter_convexHull (hs : s ∈ K.faces) (ht : t ∈ K.faces) : convexHull 𝕜 ↑s ∩ convexHull 𝕜 ↑t = convexHull 𝕜 (s ∩ t : Set E) := (K.inter_subset_convexHull hs ht).antisymm <| subset_inter (convexHull_mono Set.inter_subset_left) <| convexHull_mono Set.inter_subset_right #align geometry.simplicial_complex.convex_hull_inter_convex_hull Geometry.SimplicialComplex.convexHull_inter_convexHull /-- The conclusion is the usual meaning of "glue nicely" in textbooks. It turns out to be quite unusable, as it's about faces as sets in space rather than simplices. Further, additional structure on `𝕜` means the only choice of `u` is `s ∩ t` (but it's hard to prove). -/
Mathlib/Analysis/Convex/SimplicialComplex/Basic.lean
110
119
theorem disjoint_or_exists_inter_eq_convexHull (hs : s ∈ K.faces) (ht : t ∈ K.faces) : Disjoint (convexHull 𝕜 (s : Set E)) (convexHull 𝕜 ↑t) ∨ ∃ u ∈ K.faces, convexHull 𝕜 (s : Set E) ∩ convexHull 𝕜 ↑t = convexHull 𝕜 ↑u := by
classical by_contra! h refine h.2 (s ∩ t) (K.down_closed hs inter_subset_left fun hst => h.1 <| disjoint_iff_inf_le.mpr <| (K.inter_subset_convexHull hs ht).trans ?_) ?_ · rw [← coe_inter, hst, coe_empty, convexHull_empty] rfl · rw [coe_inter, convexHull_inter_convexHull hs ht]
/- Copyright (c) 2019 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.Convex.Topology import Mathlib.Analysis.NormedSpace.Basic import Mathlib.Analysis.SpecificLimits.Basic #align_import analysis.calculus.tangent_cone from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Tangent cone In this file, we define two predicates `UniqueDiffWithinAt 𝕜 s x` and `UniqueDiffOn 𝕜 s` ensuring that, if a function has two derivatives, then they have to coincide. As a direct definition of this fact (quantifying on all target types and all functions) would depend on universes, we use a more intrinsic definition: if all the possible tangent directions to the set `s` at the point `x` span a dense subset of the whole subset, it is easy to check that the derivative has to be unique. Therefore, we introduce the set of all tangent directions, named `tangentConeAt`, and express `UniqueDiffWithinAt` and `UniqueDiffOn` in terms of it. One should however think of this definition as an implementation detail: the only reason to introduce the predicates `UniqueDiffWithinAt` and `UniqueDiffOn` is to ensure the uniqueness of the derivative. This is why their names reflect their uses, and not how they are defined. ## Implementation details Note that this file is imported by `Fderiv.Basic`. Hence, derivatives are not defined yet. The property of uniqueness of the derivative is therefore proved in `Fderiv.Basic`, but based on the properties of the tangent cone we prove here. -/ variable (𝕜 : Type*) [NontriviallyNormedField 𝕜] open Filter Set open Topology section TangentCone variable {E : Type*} [AddCommMonoid E] [Module 𝕜 E] [TopologicalSpace E] /-- The set of all tangent directions to the set `s` at the point `x`. -/ def tangentConeAt (s : Set E) (x : E) : Set E := { y : E | ∃ (c : ℕ → 𝕜) (d : ℕ → E), (∀ᶠ n in atTop, x + d n ∈ s) ∧ Tendsto (fun n => ‖c n‖) atTop atTop ∧ Tendsto (fun n => c n • d n) atTop (𝓝 y) } #align tangent_cone_at tangentConeAt /-- A property ensuring that the tangent cone to `s` at `x` spans a dense subset of the whole space. The main role of this property is to ensure that the differential within `s` at `x` is unique, hence this name. The uniqueness it asserts is proved in `UniqueDiffWithinAt.eq` in `Fderiv.Basic`. To avoid pathologies in dimension 0, we also require that `x` belongs to the closure of `s` (which is automatic when `E` is not `0`-dimensional). -/ @[mk_iff] structure UniqueDiffWithinAt (s : Set E) (x : E) : Prop where dense_tangentCone : Dense (Submodule.span 𝕜 (tangentConeAt 𝕜 s x) : Set E) mem_closure : x ∈ closure s #align unique_diff_within_at UniqueDiffWithinAt /-- A property ensuring that the tangent cone to `s` at any of its points spans a dense subset of the whole space. The main role of this property is to ensure that the differential along `s` is unique, hence this name. The uniqueness it asserts is proved in `UniqueDiffOn.eq` in `Fderiv.Basic`. -/ def UniqueDiffOn (s : Set E) : Prop := ∀ x ∈ s, UniqueDiffWithinAt 𝕜 s x #align unique_diff_on UniqueDiffOn end TangentCone variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {G : Type*} [NormedAddCommGroup G] [NormedSpace ℝ G] variable {𝕜} {x y : E} {s t : Set E} section TangentCone -- This section is devoted to the properties of the tangent cone. open NormedField theorem mem_tangentConeAt_of_pow_smul {r : 𝕜} (hr₀ : r ≠ 0) (hr : ‖r‖ < 1) (hs : ∀ᶠ n : ℕ in atTop, x + r ^ n • y ∈ s) : y ∈ tangentConeAt 𝕜 s x := by refine ⟨fun n ↦ (r ^ n)⁻¹, fun n ↦ r ^ n • y, hs, ?_, ?_⟩ · simp only [norm_inv, norm_pow, ← inv_pow] exact tendsto_pow_atTop_atTop_of_one_lt <| one_lt_inv (norm_pos_iff.2 hr₀) hr · simp only [inv_smul_smul₀ (pow_ne_zero _ hr₀), tendsto_const_nhds] theorem tangentCone_univ : tangentConeAt 𝕜 univ x = univ := let ⟨_r, hr₀, hr⟩ := exists_norm_lt_one 𝕜 eq_univ_of_forall fun _ ↦ mem_tangentConeAt_of_pow_smul (norm_pos_iff.1 hr₀) hr <| eventually_of_forall fun _ ↦ mem_univ _ #align tangent_cone_univ tangentCone_univ
Mathlib/Analysis/Calculus/TangentCone.lean
98
100
theorem tangentCone_mono (h : s ⊆ t) : tangentConeAt 𝕜 s x ⊆ tangentConeAt 𝕜 t x := by
rintro y ⟨c, d, ds, ctop, clim⟩ exact ⟨c, d, mem_of_superset ds fun n hn => h hn, ctop, clim⟩
/- Copyright (c) 2016 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Mario Carneiro -/ import Mathlib.Algebra.Order.Ring.Int #align_import data.int.least_greatest from "leanprover-community/mathlib"@"3342d1b2178381196f818146ff79bc0e7ccd9e2d" /-! # Least upper bound and greatest lower bound properties for integers In this file we prove that a bounded above nonempty set of integers has the greatest element, and a counterpart of this statement for the least element. ## Main definitions * `Int.leastOfBdd`: if `P : ℤ → Prop` is a decidable predicate, `b` is a lower bound of the set `{m | P m}`, and there exists `m : ℤ` such that `P m` (this time, no witness is required), then `Int.leastOfBdd` returns the least number `m` such that `P m`, together with proofs of `P m` and of the minimality. This definition is computable and does not rely on the axiom of choice. * `Int.greatestOfBdd`: a similar definition with all inequalities reversed. ## Main statements * `Int.exists_least_of_bdd`: if `P : ℤ → Prop` is a predicate such that the set `{m : P m}` is bounded below and nonempty, then this set has the least element. This lemma uses classical logic to avoid assumption `[DecidablePred P]`. See `Int.leastOfBdd` for a constructive counterpart. * `Int.coe_leastOfBdd_eq`: `(Int.leastOfBdd b Hb Hinh : ℤ)` does not depend on `b`. * `Int.exists_greatest_of_bdd`, `Int.coe_greatest_of_bdd_eq`: versions of the above lemmas with all inequalities reversed. ## Tags integer numbers, least element, greatest element -/ namespace Int /-- A computable version of `exists_least_of_bdd`: given a decidable predicate on the integers, with an explicit lower bound and a proof that it is somewhere true, return the least value for which the predicate is true. -/ def leastOfBdd {P : ℤ → Prop} [DecidablePred P] (b : ℤ) (Hb : ∀ z : ℤ, P z → b ≤ z) (Hinh : ∃ z : ℤ, P z) : { lb : ℤ // P lb ∧ ∀ z : ℤ, P z → lb ≤ z } := have EX : ∃ n : ℕ, P (b + n) := let ⟨elt, Helt⟩ := Hinh match elt, le.dest (Hb _ Helt), Helt with | _, ⟨n, rfl⟩, Hn => ⟨n, Hn⟩ ⟨b + (Nat.find EX : ℤ), Nat.find_spec EX, fun z h => match z, le.dest (Hb _ h), h with | _, ⟨_, rfl⟩, h => add_le_add_left (Int.ofNat_le.2 <| Nat.find_min' _ h) _⟩ #align int.least_of_bdd Int.leastOfBdd /-- If `P : ℤ → Prop` is a predicate such that the set `{m : P m}` is bounded below and nonempty, then this set has the least element. This lemma uses classical logic to avoid assumption `[DecidablePred P]`. See `Int.leastOfBdd` for a constructive counterpart. -/
Mathlib/Data/Int/LeastGreatest.lean
61
68
theorem exists_least_of_bdd {P : ℤ → Prop} (Hbdd : ∃ b : ℤ , ∀ z : ℤ , P z → b ≤ z) (Hinh : ∃ z : ℤ , P z) : ∃ lb : ℤ , P lb ∧ ∀ z : ℤ , P z → lb ≤ z := by
classical let ⟨b , Hb⟩ := Hbdd let ⟨lb , H⟩ := leastOfBdd b Hb Hinh exact ⟨lb , H⟩
/- Copyright (c) 2021 Kevin Buzzard. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Buzzard, Ines Wright, Joachim Breitner -/ import Mathlib.GroupTheory.QuotientGroup import Mathlib.GroupTheory.Solvable import Mathlib.GroupTheory.PGroup import Mathlib.GroupTheory.Sylow import Mathlib.Data.Nat.Factorization.Basic import Mathlib.Tactic.TFAE #align_import group_theory.nilpotent from "leanprover-community/mathlib"@"2bbc7e3884ba234309d2a43b19144105a753292e" /-! # Nilpotent groups An API for nilpotent groups, that is, groups for which the upper central series reaches `⊤`. ## Main definitions Recall that if `H K : Subgroup G` then `⁅H, K⁆ : Subgroup G` is the subgroup of `G` generated by the commutators `hkh⁻¹k⁻¹`. Recall also Lean's conventions that `⊤` denotes the subgroup `G` of `G`, and `⊥` denotes the trivial subgroup `{1}`. * `upperCentralSeries G : ℕ → Subgroup G` : the upper central series of a group `G`. This is an increasing sequence of normal subgroups `H n` of `G` with `H 0 = ⊥` and `H (n + 1) / H n` is the centre of `G / H n`. * `lowerCentralSeries G : ℕ → Subgroup G` : the lower central series of a group `G`. This is a decreasing sequence of normal subgroups `H n` of `G` with `H 0 = ⊤` and `H (n + 1) = ⁅H n, G⁆`. * `IsNilpotent` : A group G is nilpotent if its upper central series reaches `⊤`, or equivalently if its lower central series reaches `⊥`. * `nilpotency_class` : the length of the upper central series of a nilpotent group. * `IsAscendingCentralSeries (H : ℕ → Subgroup G) : Prop` and * `IsDescendingCentralSeries (H : ℕ → Subgroup G) : Prop` : Note that in the literature a "central series" for a group is usually defined to be a *finite* sequence of normal subgroups `H 0`, `H 1`, ..., starting at `⊤`, finishing at `⊥`, and with each `H n / H (n + 1)` central in `G / H (n + 1)`. In this formalisation it is convenient to have two weaker predicates on an infinite sequence of subgroups `H n` of `G`: we say a sequence is a *descending central series* if it starts at `G` and `⁅H n, ⊤⁆ ⊆ H (n + 1)` for all `n`. Note that this series may not terminate at `⊥`, and the `H i` need not be normal. Similarly a sequence is an *ascending central series* if `H 0 = ⊥` and `⁅H (n + 1), ⊤⁆ ⊆ H n` for all `n`, again with no requirement that the series reaches `⊤` or that the `H i` are normal. ## Main theorems `G` is *defined* to be nilpotent if the upper central series reaches `⊤`. * `nilpotent_iff_finite_ascending_central_series` : `G` is nilpotent iff some ascending central series reaches `⊤`. * `nilpotent_iff_finite_descending_central_series` : `G` is nilpotent iff some descending central series reaches `⊥`. * `nilpotent_iff_lower` : `G` is nilpotent iff the lower central series reaches `⊥`. * The `nilpotency_class` can likewise be obtained from these equivalent definitions, see `least_ascending_central_series_length_eq_nilpotencyClass`, `least_descending_central_series_length_eq_nilpotencyClass` and `lowerCentralSeries_length_eq_nilpotencyClass`. * If `G` is nilpotent, then so are its subgroups, images, quotients and preimages. Binary and finite products of nilpotent groups are nilpotent. Infinite products are nilpotent if their nilpotent class is bounded. Corresponding lemmas about the `nilpotency_class` are provided. * The `nilpotency_class` of `G ⧸ center G` is given explicitly, and an induction principle is derived from that. * `IsNilpotent.to_isSolvable`: If `G` is nilpotent, it is solvable. ## Warning A "central series" is usually defined to be a finite sequence of normal subgroups going from `⊥` to `⊤` with the property that each subquotient is contained within the centre of the associated quotient of `G`. This means that if `G` is not nilpotent, then none of what we have called `upperCentralSeries G`, `lowerCentralSeries G` or the sequences satisfying `IsAscendingCentralSeries` or `IsDescendingCentralSeries` are actually central series. Note that the fact that the upper and lower central series are not central series if `G` is not nilpotent is a standard abuse of notation. -/ open Subgroup section WithGroup variable {G : Type*} [Group G] (H : Subgroup G) [Normal H] /-- If `H` is a normal subgroup of `G`, then the set `{x : G | ∀ y : G, x*y*x⁻¹*y⁻¹ ∈ H}` is a subgroup of `G` (because it is the preimage in `G` of the centre of the quotient group `G/H`.) -/ def upperCentralSeriesStep : Subgroup G where carrier := { x : G | ∀ y : G, x * y * x⁻¹ * y⁻¹ ∈ H } one_mem' y := by simp [Subgroup.one_mem] mul_mem' {a b ha hb y} := by convert Subgroup.mul_mem _ (ha (b * y * b⁻¹)) (hb y) using 1 group inv_mem' {x hx y} := by specialize hx y⁻¹ rw [mul_assoc, inv_inv] at hx ⊢ exact Subgroup.Normal.mem_comm inferInstance hx #align upper_central_series_step upperCentralSeriesStep theorem mem_upperCentralSeriesStep (x : G) : x ∈ upperCentralSeriesStep H ↔ ∀ y, x * y * x⁻¹ * y⁻¹ ∈ H := Iff.rfl #align mem_upper_central_series_step mem_upperCentralSeriesStep open QuotientGroup /-- The proof that `upperCentralSeriesStep H` is the preimage of the centre of `G/H` under the canonical surjection. -/
Mathlib/GroupTheory/Nilpotent.lean
112
119
theorem upperCentralSeriesStep_eq_comap_center : upperCentralSeriesStep H = Subgroup.comap (mk' H) (center (G ⧸ H)) := by
ext rw [mem_comap, mem_center_iff, forall_mk] apply forall_congr' intro y rw [coe_mk', ← QuotientGroup.mk_mul, ← QuotientGroup.mk_mul, eq_comm, eq_iff_div_mem, div_eq_mul_inv, mul_inv_rev, mul_assoc]
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.AlgebraicGeometry.Morphisms.RingHomProperties import Mathlib.RingTheory.RingHom.FiniteType #align_import algebraic_geometry.morphisms.finite_type from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Morphisms of finite type A morphism of schemes `f : X ⟶ Y` is locally of finite type if for each affine `U ⊆ Y` and `V ⊆ f ⁻¹' U`, The induced map `Γ(Y, U) ⟶ Γ(X, V)` is of finite type. A morphism of schemes is of finite type if it is both locally of finite type and quasi-compact. We show that these properties are local, and are stable under compositions. -/ noncomputable section open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace universe v u namespace AlgebraicGeometry variable {X Y : Scheme.{u}} (f : X ⟶ Y) /-- A morphism of schemes `f : X ⟶ Y` is locally of finite type if for each affine `U ⊆ Y` and `V ⊆ f ⁻¹' U`, The induced map `Γ(Y, U) ⟶ Γ(X, V)` is of finite type. -/ @[mk_iff] class LocallyOfFiniteType (f : X ⟶ Y) : Prop where finiteType_of_affine_subset : ∀ (U : Y.affineOpens) (V : X.affineOpens) (e : V.1 ≤ (Opens.map f.1.base).obj U.1), (Scheme.Hom.appLe f e).FiniteType #align algebraic_geometry.locally_of_finite_type AlgebraicGeometry.LocallyOfFiniteType theorem locallyOfFiniteType_eq : @LocallyOfFiniteType = affineLocally @RingHom.FiniteType := by ext X Y f rw [locallyOfFiniteType_iff, affineLocally_iff_affineOpens_le] exact RingHom.finiteType_respectsIso #align algebraic_geometry.locally_of_finite_type_eq AlgebraicGeometry.locallyOfFiniteType_eq instance (priority := 900) locallyOfFiniteTypeOfIsOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [IsOpenImmersion f] : LocallyOfFiniteType f := locallyOfFiniteType_eq.symm ▸ RingHom.finiteType_is_local.affineLocally_of_isOpenImmersion f #align algebraic_geometry.locally_of_finite_type_of_is_open_immersion AlgebraicGeometry.locallyOfFiniteTypeOfIsOpenImmersion instance locallyOfFiniteType_isStableUnderComposition : MorphismProperty.IsStableUnderComposition @LocallyOfFiniteType := locallyOfFiniteType_eq.symm ▸ RingHom.finiteType_is_local.affineLocally_isStableUnderComposition #align algebraic_geometry.locally_of_finite_type_stable_under_composition AlgebraicGeometry.locallyOfFiniteType_isStableUnderComposition instance locallyOfFiniteTypeComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [hf : LocallyOfFiniteType f] [hg : LocallyOfFiniteType g] : LocallyOfFiniteType (f ≫ g) := MorphismProperty.comp_mem _ f g hf hg #align algebraic_geometry.locally_of_finite_type_comp AlgebraicGeometry.locallyOfFiniteTypeComp
Mathlib/AlgebraicGeometry/Morphisms/FiniteType.lean
65
71
theorem locallyOfFiniteTypeOfComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [hf : LocallyOfFiniteType (f ≫ g)] : LocallyOfFiniteType f := by
revert hf rw [locallyOfFiniteType_eq] apply RingHom.finiteType_is_local.affineLocally_of_comp introv H exact RingHom.FiniteType.of_comp_finiteType H
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Data.Finset.Finsupp import Mathlib.Data.Finsupp.Order import Mathlib.Order.Interval.Finset.Basic #align_import data.finsupp.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29" /-! # Finite intervals of finitely supported functions This file provides the `LocallyFiniteOrder` instance for `ι →₀ α` when `α` itself is locally finite and calculates the cardinality of its finite intervals. ## Main declarations * `Finsupp.rangeSingleton`: Postcomposition with `Singleton.singleton` on `Finset` as a `Finsupp`. * `Finsupp.rangeIcc`: Postcomposition with `Finset.Icc` as a `Finsupp`. Both these definitions use the fact that `0 = {0}` to ensure that the resulting function is finitely supported. -/ noncomputable section open Finset Finsupp Function open scoped Classical open Pointwise variable {ι α : Type*} namespace Finsupp section RangeSingleton variable [Zero α] {f : ι →₀ α} {i : ι} {a : α} /-- Pointwise `Singleton.singleton` bundled as a `Finsupp`. -/ @[simps] def rangeSingleton (f : ι →₀ α) : ι →₀ Finset α where toFun i := {f i} support := f.support mem_support_toFun i := by rw [← not_iff_not, not_mem_support_iff, not_ne_iff] exact singleton_injective.eq_iff.symm #align finsupp.range_singleton Finsupp.rangeSingleton theorem mem_rangeSingleton_apply_iff : a ∈ f.rangeSingleton i ↔ a = f i := mem_singleton #align finsupp.mem_range_singleton_apply_iff Finsupp.mem_rangeSingleton_apply_iff end RangeSingleton section RangeIcc variable [Zero α] [PartialOrder α] [LocallyFiniteOrder α] {f g : ι →₀ α} {i : ι} {a : α} /-- Pointwise `Finset.Icc` bundled as a `Finsupp`. -/ @[simps toFun] def rangeIcc (f g : ι →₀ α) : ι →₀ Finset α where toFun i := Icc (f i) (g i) support := -- Porting note: Not needed (due to open scoped Classical), in mathlib3 too -- haveI := Classical.decEq ι f.support ∪ g.support mem_support_toFun i := by rw [mem_union, ← not_iff_not, not_or, not_mem_support_iff, not_mem_support_iff, not_ne_iff] exact Icc_eq_singleton_iff.symm #align finsupp.range_Icc Finsupp.rangeIcc -- Porting note: Added as alternative to rangeIcc_toFun to be used in proof of card_Icc lemma coe_rangeIcc (f g : ι →₀ α) : rangeIcc f g i = Icc (f i) (g i) := rfl @[simp] theorem rangeIcc_support (f g : ι →₀ α) : (rangeIcc f g).support = f.support ∪ g.support := rfl #align finsupp.range_Icc_support Finsupp.rangeIcc_support theorem mem_rangeIcc_apply_iff : a ∈ f.rangeIcc g i ↔ f i ≤ a ∧ a ≤ g i := mem_Icc #align finsupp.mem_range_Icc_apply_iff Finsupp.mem_rangeIcc_apply_iff end RangeIcc section PartialOrder variable [PartialOrder α] [Zero α] [LocallyFiniteOrder α] (f g : ι →₀ α) instance instLocallyFiniteOrder : LocallyFiniteOrder (ι →₀ α) := -- Porting note: Not needed (due to open scoped Classical), in mathlib3 too -- haveI := Classical.decEq ι -- haveI := Classical.decEq α LocallyFiniteOrder.ofIcc (ι →₀ α) (fun f g => (f.support ∪ g.support).finsupp <| f.rangeIcc g) fun f g x => by refine (mem_finsupp_iff_of_support_subset <| Finset.subset_of_eq <| rangeIcc_support _ _).trans ?_ simp_rw [mem_rangeIcc_apply_iff] exact forall_and theorem Icc_eq : Icc f g = (f.support ∪ g.support).finsupp (f.rangeIcc g) := rfl #align finsupp.Icc_eq Finsupp.Icc_eq -- Porting note: removed [DecidableEq ι] theorem card_Icc : (Icc f g).card = ∏ i ∈ f.support ∪ g.support, (Icc (f i) (g i)).card := by simp_rw [Icc_eq, card_finsupp, coe_rangeIcc] #align finsupp.card_Icc Finsupp.card_Icc -- Porting note: removed [DecidableEq ι] theorem card_Ico : (Ico f g).card = (∏ i ∈ f.support ∪ g.support, (Icc (f i) (g i)).card) - 1 := by rw [card_Ico_eq_card_Icc_sub_one, card_Icc] #align finsupp.card_Ico Finsupp.card_Ico -- Porting note: removed [DecidableEq ι] theorem card_Ioc : (Ioc f g).card = (∏ i ∈ f.support ∪ g.support, (Icc (f i) (g i)).card) - 1 := by rw [card_Ioc_eq_card_Icc_sub_one, card_Icc] #align finsupp.card_Ioc Finsupp.card_Ioc -- Porting note: removed [DecidableEq ι] theorem card_Ioo : (Ioo f g).card = (∏ i ∈ f.support ∪ g.support, (Icc (f i) (g i)).card) - 2 := by rw [card_Ioo_eq_card_Icc_sub_two, card_Icc] #align finsupp.card_Ioo Finsupp.card_Ioo end PartialOrder section Lattice variable [Lattice α] [Zero α] [LocallyFiniteOrder α] (f g : ι →₀ α) -- Porting note: removed [DecidableEq ι] theorem card_uIcc : (uIcc f g).card = ∏ i ∈ f.support ∪ g.support, (uIcc (f i) (g i)).card := by rw [← support_inf_union_support_sup]; exact card_Icc (_ : ι →₀ α) _ #align finsupp.card_uIcc Finsupp.card_uIcc end Lattice section CanonicallyOrdered variable [CanonicallyOrderedAddCommMonoid α] [LocallyFiniteOrder α] variable (f : ι →₀ α)
Mathlib/Data/Finsupp/Interval.lean
145
147
theorem card_Iic : (Iic f).card = ∏ i ∈ f.support, (Iic (f i)).card := by
classical simp_rw [Iic_eq_Icc, card_Icc, Finsupp.bot_eq_zero, support_zero, empty_union, zero_apply, bot_eq_zero]
/- Copyright (c) 2022 Thomas Browning. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning -/ import Mathlib.GroupTheory.Abelianization import Mathlib.GroupTheory.Exponent import Mathlib.GroupTheory.Transfer #align_import group_theory.schreier from "leanprover-community/mathlib"@"8350c34a64b9bc3fc64335df8006bffcadc7baa6" /-! # Schreier's Lemma In this file we prove Schreier's lemma. ## Main results - `closure_mul_image_eq` : **Schreier's Lemma**: If `R : Set G` is a right_transversal of `H : Subgroup G` with `1 ∈ R`, and if `G` is generated by `S : Set G`, then `H` is generated by the `Set` `(R * S).image (fun g ↦ g * (toFun hR g)⁻¹)`. - `fg_of_index_ne_zero` : **Schreier's Lemma**: A finite index subgroup of a finitely generated group is finitely generated. - `card_commutator_le_of_finite_commutatorSet`: A theorem of Schur: The size of the commutator subgroup is bounded in terms of the number of commutators. -/ open scoped Pointwise namespace Subgroup open MemRightTransversals variable {G : Type*} [Group G] {H : Subgroup G} {R S : Set G} theorem closure_mul_image_mul_eq_top (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) : (closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by let f : G → R := fun g => toFun hR g let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹ change (closure U : Set G) * R = ⊤ refine top_le_iff.mp fun g _ => ?_ refine closure_induction_right ?_ ?_ ?_ (eq_top_iff.mp hS (mem_top g)) · exact ⟨1, (closure U).one_mem, 1, hR1, one_mul 1⟩ · rintro - - s hs ⟨u, hu, r, hr, rfl⟩ rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group] refine Set.mul_mem_mul ((closure U).mul_mem hu ?_) (f (r * s)).coe_prop exact subset_closure ⟨r * s, Set.mul_mem_mul hr hs, rfl⟩ · rintro - - s hs ⟨u, hu, r, hr, rfl⟩ rw [show u * r * s⁻¹ = u * (f (r * s⁻¹) * s * r⁻¹)⁻¹ * f (r * s⁻¹) by group] refine Set.mul_mem_mul ((closure U).mul_mem hu ((closure U).inv_mem ?_)) (f (r * s⁻¹)).2 refine subset_closure ⟨f (r * s⁻¹) * s, Set.mul_mem_mul (f (r * s⁻¹)).2 hs, ?_⟩ rw [mul_right_inj, inv_inj, ← Subtype.coe_mk r hr, ← Subtype.ext_iff, Subtype.coe_mk] apply (mem_rightTransversals_iff_existsUnique_mul_inv_mem.mp hR (f (r * s⁻¹) * s)).unique (mul_inv_toFun_mem hR (f (r * s⁻¹) * s)) rw [mul_assoc, ← inv_inv s, ← mul_inv_rev, inv_inv] exact toFun_mul_inv_mem hR (r * s⁻¹) #align subgroup.closure_mul_image_mul_eq_top Subgroup.closure_mul_image_mul_eq_top /-- **Schreier's Lemma**: If `R : Set G` is a `rightTransversal` of `H : Subgroup G` with `1 ∈ R`, and if `G` is generated by `S : Set G`, then `H` is generated by the `Set` `(R * S).image (fun g ↦ g * (toFun hR g)⁻¹)`. -/
Mathlib/GroupTheory/Schreier.lean
64
79
theorem closure_mul_image_eq (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) : closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹) = H := by
have hU : closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹) ≤ H := by rw [closure_le] rintro - ⟨g, -, rfl⟩ exact mul_inv_toFun_mem hR g refine le_antisymm hU fun h hh => ?_ obtain ⟨g, hg, r, hr, rfl⟩ := show h ∈ _ from eq_top_iff.mp (closure_mul_image_mul_eq_top hR hR1 hS) (mem_top h) suffices (⟨r, hr⟩ : R) = (⟨1, hR1⟩ : R) by simpa only [show r = 1 from Subtype.ext_iff.mp this, mul_one] apply (mem_rightTransversals_iff_existsUnique_mul_inv_mem.mp hR r).unique · rw [Subtype.coe_mk, mul_inv_self] exact H.one_mem · rw [Subtype.coe_mk, inv_one, mul_one] exact (H.mul_mem_cancel_left (hU hg)).mp hh
/- Copyright (c) 2023 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Loeffler -/ import Mathlib.Analysis.Convolution import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup import Mathlib.Analysis.Analytic.IsolatedZeros import Mathlib.Analysis.Complex.CauchyIntegral #align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090" /-! # The Beta function, and further properties of the Gamma function In this file we define the Beta integral, relate Beta and Gamma functions, and prove some refined properties of the Gamma function using these relations. ## Results on the Beta function * `Complex.betaIntegral`: the Beta function `Β(u, v)`, where `u`, `v` are complex with positive real part. * `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula `Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`. ## Results on the Gamma function * `Complex.Gamma_ne_zero`: for all `s : ℂ` with `s ∉ {-n : n ∈ ℕ}` we have `Γ s ≠ 0`. * `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n → ∞` of the sequence `n ↦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Γ(s)`. * `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula `Gamma s * Gamma (1 - s) = π / sin π s`. * `Complex.differentiable_one_div_Gamma`: the function `1 / Γ(s)` is differentiable everywhere. * `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula `Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * √π`. * `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`, `Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above. -/ noncomputable section set_option linter.uppercaseLean3 false open Filter intervalIntegral Set Real MeasureTheory open scoped Nat Topology Real section BetaIntegral /-! ## The Beta function -/ namespace Complex /-- The Beta function `Β (u, v)`, defined as `∫ x:ℝ in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/ noncomputable def betaIntegral (u v : ℂ) : ℂ := ∫ x : ℝ in (0)..1, (x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ (v - 1) #align complex.beta_integral Complex.betaIntegral /-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
Mathlib/Analysis/SpecialFunctions/Gamma/Beta.lean
63
76
theorem betaIntegral_convergent_left {u : ℂ} (hu : 0 < re u) (v : ℂ) : IntervalIntegrable (fun x => (x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ (v - 1) : ℝ → ℂ) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn · refine intervalIntegral.intervalIntegrable_cpow' ?_ rwa [sub_re, one_re, ← zero_sub, sub_lt_sub_iff_right] · apply ContinuousAt.continuousOn intro x hx rw [uIcc_of_le (by positivity : (0 : ℝ) ≤ 1 / 2)] at hx apply ContinuousAt.cpow · exact (continuous_const.sub continuous_ofReal).continuousAt · exact continuousAt_const · norm_cast exact ofReal_mem_slitPlane.2 <| by linarith only [hx.2]
/- Copyright (c) 2021 Shing Tak Lam. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Shing Tak Lam -/ import Mathlib.Topology.Homotopy.Basic import Mathlib.Topology.Connected.PathConnected import Mathlib.Analysis.Convex.Basic #align_import topology.homotopy.path from "leanprover-community/mathlib"@"bb9d1c5085e0b7ea619806a68c5021927cecb2a6" /-! # Homotopy between paths In this file, we define a `Homotopy` between two `Path`s. In addition, we define a relation `Homotopic` on `Path`s, and prove that it is an equivalence relation. ## Definitions * `Path.Homotopy p₀ p₁` is the type of homotopies between paths `p₀` and `p₁` * `Path.Homotopy.refl p` is the constant homotopy between `p` and itself * `Path.Homotopy.symm F` is the `Path.Homotopy p₁ p₀` defined by reversing the homotopy * `Path.Homotopy.trans F G`, where `F : Path.Homotopy p₀ p₁`, `G : Path.Homotopy p₁ p₂` is the `Path.Homotopy p₀ p₂` defined by putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]` * `Path.Homotopy.hcomp F G`, where `F : Path.Homotopy p₀ q₀` and `G : Path.Homotopy p₁ q₁` is a `Path.Homotopy (p₀.trans p₁) (q₀.trans q₁)` * `Path.Homotopic p₀ p₁` is the relation saying that there is a homotopy between `p₀` and `p₁` * `Path.Homotopic.setoid x₀ x₁` is the setoid on `Path`s from `Path.Homotopic` * `Path.Homotopic.Quotient x₀ x₁` is the quotient type from `Path x₀ x₀` by `Path.Homotopic.setoid` -/ universe u v variable {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y] variable {x₀ x₁ x₂ x₃ : X} noncomputable section open unitInterval namespace Path /-- The type of homotopies between two paths. -/ abbrev Homotopy (p₀ p₁ : Path x₀ x₁) := ContinuousMap.HomotopyRel p₀.toContinuousMap p₁.toContinuousMap {0, 1} #align path.homotopy Path.Homotopy namespace Homotopy section variable {p₀ p₁ : Path x₀ x₁} theorem coeFn_injective : @Function.Injective (Homotopy p₀ p₁) (I × I → X) (⇑) := DFunLike.coe_injective #align path.homotopy.coe_fn_injective Path.Homotopy.coeFn_injective @[simp] theorem source (F : Homotopy p₀ p₁) (t : I) : F (t, 0) = x₀ := calc F (t, 0) = p₀ 0 := ContinuousMap.HomotopyRel.eq_fst _ _ (.inl rfl) _ = x₀ := p₀.source #align path.homotopy.source Path.Homotopy.source @[simp] theorem target (F : Homotopy p₀ p₁) (t : I) : F (t, 1) = x₁ := calc F (t, 1) = p₀ 1 := ContinuousMap.HomotopyRel.eq_fst _ _ (.inr rfl) _ = x₁ := p₀.target #align path.homotopy.target Path.Homotopy.target /-- Evaluating a path homotopy at an intermediate point, giving us a `Path`. -/ def eval (F : Homotopy p₀ p₁) (t : I) : Path x₀ x₁ where toFun := F.toHomotopy.curry t source' := by simp target' := by simp #align path.homotopy.eval Path.Homotopy.eval @[simp] theorem eval_zero (F : Homotopy p₀ p₁) : F.eval 0 = p₀ := by ext t simp [eval] #align path.homotopy.eval_zero Path.Homotopy.eval_zero @[simp]
Mathlib/Topology/Homotopy/Path.lean
89
91
theorem eval_one (F : Homotopy p₀ p₁) : F.eval 1 = p₁ := by
ext t simp [eval]
/- Copyright (c) 2021 Yaël Dillies, Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Bhavik Mehta -/ import Mathlib.Analysis.Convex.Hull #align_import analysis.convex.extreme from "leanprover-community/mathlib"@"c5773405394e073885e2a144c9ca14637e8eb963" /-! # Extreme sets This file defines extreme sets and extreme points for sets in a module. An extreme set of `A` is a subset of `A` that is as far as it can get in any outward direction: If point `x` is in it and point `y ∈ A`, then the line passing through `x` and `y` leaves `A` at `x`. This is an analytic notion of "being on the side of". It is weaker than being exposed (see `IsExposed.isExtreme`). ## Main declarations * `IsExtreme 𝕜 A B`: States that `B` is an extreme set of `A` (in the literature, `A` is often implicit). * `Set.extremePoints 𝕜 A`: Set of extreme points of `A` (corresponding to extreme singletons). * `Convex.mem_extremePoints_iff_convex_diff`: A useful equivalent condition to being an extreme point: `x` is an extreme point iff `A \ {x}` is convex. ## Implementation notes The exact definition of extremeness has been carefully chosen so as to make as many lemmas unconditional (in particular, the Krein-Milman theorem doesn't need the set to be convex!). In practice, `A` is often assumed to be a convex set. ## References See chapter 8 of [Barry Simon, *Convexity*][simon2011] ## TODO Prove lemmas relating extreme sets and points to the intrinsic frontier. More not-yet-PRed stuff is available on the mathlib3 branch `sperner_again`. -/ open Function Set open scoped Classical open Affine variable {𝕜 E F ι : Type*} {π : ι → Type*} section SMul variable (𝕜) [OrderedSemiring 𝕜] [AddCommMonoid E] [SMul 𝕜 E] /-- A set `B` is an extreme subset of `A` if `B ⊆ A` and all points of `B` only belong to open segments whose ends are in `B`. -/ def IsExtreme (A B : Set E) : Prop := B ⊆ A ∧ ∀ ⦃x₁⦄, x₁ ∈ A → ∀ ⦃x₂⦄, x₂ ∈ A → ∀ ⦃x⦄, x ∈ B → x ∈ openSegment 𝕜 x₁ x₂ → x₁ ∈ B ∧ x₂ ∈ B #align is_extreme IsExtreme /-- A point `x` is an extreme point of a set `A` if `x` belongs to no open segment with ends in `A`, except for the obvious `openSegment x x`. -/ def Set.extremePoints (A : Set E) : Set E := { x ∈ A | ∀ ⦃x₁⦄, x₁ ∈ A → ∀ ⦃x₂⦄, x₂ ∈ A → x ∈ openSegment 𝕜 x₁ x₂ → x₁ = x ∧ x₂ = x } #align set.extreme_points Set.extremePoints @[refl] protected theorem IsExtreme.refl (A : Set E) : IsExtreme 𝕜 A A := ⟨Subset.rfl, fun _ hx₁A _ hx₂A _ _ _ ↦ ⟨hx₁A, hx₂A⟩⟩ #align is_extreme.refl IsExtreme.refl variable {𝕜} {A B C : Set E} {x : E} protected theorem IsExtreme.rfl : IsExtreme 𝕜 A A := IsExtreme.refl 𝕜 A #align is_extreme.rfl IsExtreme.rfl @[trans] protected theorem IsExtreme.trans (hAB : IsExtreme 𝕜 A B) (hBC : IsExtreme 𝕜 B C) : IsExtreme 𝕜 A C := by refine ⟨Subset.trans hBC.1 hAB.1, fun x₁ hx₁A x₂ hx₂A x hxC hx ↦ ?_⟩ obtain ⟨hx₁B, hx₂B⟩ := hAB.2 hx₁A hx₂A (hBC.1 hxC) hx exact hBC.2 hx₁B hx₂B hxC hx #align is_extreme.trans IsExtreme.trans protected theorem IsExtreme.antisymm : AntiSymmetric (IsExtreme 𝕜 : Set E → Set E → Prop) := fun _ _ hAB hBA ↦ Subset.antisymm hBA.1 hAB.1 #align is_extreme.antisymm IsExtreme.antisymm instance : IsPartialOrder (Set E) (IsExtreme 𝕜) where refl := IsExtreme.refl 𝕜 trans _ _ _ := IsExtreme.trans antisymm := IsExtreme.antisymm
Mathlib/Analysis/Convex/Extreme.lean
97
103
theorem IsExtreme.inter (hAB : IsExtreme 𝕜 A B) (hAC : IsExtreme 𝕜 A C) : IsExtreme 𝕜 A (B ∩ C) := by
use Subset.trans inter_subset_left hAB.1 rintro x₁ hx₁A x₂ hx₂A x ⟨hxB, hxC⟩ hx obtain ⟨hx₁B, hx₂B⟩ := hAB.2 hx₁A hx₂A hxB hx obtain ⟨hx₁C, hx₂C⟩ := hAC.2 hx₁A hx₂A hxC hx exact ⟨⟨hx₁B, hx₁C⟩, hx₂B, hx₂C⟩
/- Copyright (c) 2015 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ 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" /-! # Sums and products over multisets In this file we define products and sums indexed by multisets. This is later used to define products and sums indexed by finite sets. ## Main declarations * `Multiset.prod`: `s.prod f` is the product of `f i` over all `i ∈ s`. Not to be mistaken with the cartesian product `Multiset.product`. * `Multiset.sum`: `s.sum f` is the sum of `f i` over all `i ∈ s`. -/ assert_not_exists MonoidWithZero variable {F ι α β γ : Type*} namespace Multiset section CommMonoid variable [CommMonoid α] [CommMonoid β] {s t : Multiset α} {a : α} {m : Multiset ι} {f g : ι → α} /-- Product of a multiset given a commutative monoid structure on `α`. `prod {a, b, c} = a * b * c` -/ @[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)]
Mathlib/Algebra/BigOperators/Group/Multiset.lean
99
100
theorem prod_singleton (a : α) : prod {a} = a := by
simp only [mul_one, prod_cons, ← cons_zero, eq_self_iff_true, prod_zero]
/- Copyright (c) 2024 Michael Rothgang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Rothgang -/ import Mathlib.LinearAlgebra.AffineSpace.AffineEquiv import Mathlib.Topology.Algebra.Module.Basic /-! # Continuous affine equivalences In this file, we define continuous affine equivalences, affine equivalences which are continuous with continuous inverse. ## Main definitions * `ContinuousAffineEquiv.refl k P`: the identity map as a `ContinuousAffineEquiv`; * `e.symm`: the inverse map of a `ContinuousAffineEquiv` as a `ContinuousAffineEquiv`; * `e.trans e'`: composition of two `ContinuousAffineEquiv`s; note that the order follows `mathlib`'s `CategoryTheory` convention (apply `e`, then `e'`), not the convention used in function composition and compositions of bundled morphisms. * `e.toHomeomorph`: the continuous affine equivalence `e` as a homeomorphism * `ContinuousLinearEquiv.toContinuousAffineEquiv`: a continuous linear equivalence as a continuous affine equivalence * `ContinuousAffineEquiv.constVAdd`: `AffineEquiv.constVAdd` as a continuous affine equivalence ## TODO - equip `ContinuousAffineEquiv k P P` with a `Group` structure, with multiplication corresponding to composition in `AffineEquiv.group`. -/ open Function /-- A continuous affine equivalence, denoted `P₁ ≃ᵃL[k] P₂`, between two affine topological spaces is an affine equivalence such that forward and inverse maps are continuous. -/ structure ContinuousAffineEquiv (k P₁ P₂ : Type*) {V₁ V₂ : Type*} [Ring k] [AddCommGroup V₁] [Module k V₁] [AddTorsor V₁ P₁] [TopologicalSpace P₁] [AddCommGroup V₂] [Module k V₂] [AddTorsor V₂ P₂] [TopologicalSpace P₂] extends P₁ ≃ᵃ[k] P₂ where continuous_toFun : Continuous toFun := by continuity continuous_invFun : Continuous invFun := by continuity @[inherit_doc] notation:25 P₁ " ≃ᵃL[" k:25 "] " P₂:0 => ContinuousAffineEquiv k P₁ P₂ variable {k P₁ P₂ P₃ P₄ V₁ V₂ V₃ V₄ : Type*} [Ring k] [AddCommGroup V₁] [Module k V₁] [AddTorsor V₁ P₁] [AddCommGroup V₂] [Module k V₂] [AddTorsor V₂ P₂] [AddCommGroup V₃] [Module k V₃] [AddTorsor V₃ P₃] [AddCommGroup V₄] [Module k V₄] [AddTorsor V₄ P₄] [TopologicalSpace P₁] [AddCommMonoid P₁] [Module k P₁] [TopologicalSpace P₂] [AddCommMonoid P₂] [Module k P₂] [TopologicalSpace P₃] [TopologicalSpace P₄] namespace ContinuousAffineEquiv -- Basic set-up: standard fields, coercions and ext lemmas section Basic /-- A continuous affine equivalence is a homeomorphism. -/ def toHomeomorph (e : P₁ ≃ᵃL[k] P₂) : P₁ ≃ₜ P₂ where __ := e
Mathlib/LinearAlgebra/AffineSpace/ContinuousAffineEquiv.lean
65
67
theorem toAffineEquiv_injective : Injective (toAffineEquiv : (P₁ ≃ᵃL[k] P₂) → P₁ ≃ᵃ[k] P₂) := by
rintro ⟨e, econt, einv_cont⟩ ⟨e', e'cont, e'inv_cont⟩ H congr
/- Copyright (c) 2019 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Yaël Dillies -/ import Mathlib.Algebra.Module.BigOperators import Mathlib.Data.Finset.NoncommProd import Mathlib.Data.Fintype.Perm import Mathlib.Data.Int.ModEq import Mathlib.GroupTheory.Perm.List import Mathlib.GroupTheory.Perm.Sign import Mathlib.Logic.Equiv.Fintype import Mathlib.GroupTheory.Perm.Cycle.Basic #align_import group_theory.perm.cycle.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" /-! # Cycle factors of a permutation Let `β` be a `Fintype` and `f : Equiv.Perm β`. * `Equiv.Perm.cycleOf`: `f.cycleOf x` is the cycle of `f` that `x` belongs to. * `Equiv.Perm.cycleFactors`: `f.cycleFactors` is a list of disjoint cyclic permutations that multiply to `f`. -/ open Equiv Function Finset variable {ι α β : Type*} namespace Equiv.Perm /-! ### `cycleOf` -/ section CycleOf variable [DecidableEq α] [Fintype α] {f g : Perm α} {x y : α} /-- `f.cycleOf x` is the cycle of the permutation `f` to which `x` belongs. -/ def cycleOf (f : Perm α) (x : α) : Perm α := ofSubtype (subtypePerm f fun _ => sameCycle_apply_right.symm : Perm { y // SameCycle f x y }) #align equiv.perm.cycle_of Equiv.Perm.cycleOf theorem cycleOf_apply (f : Perm α) (x y : α) : cycleOf f x y = if SameCycle f x y then f y else y := by dsimp only [cycleOf] split_ifs with h · apply ofSubtype_apply_of_mem exact h · apply ofSubtype_apply_of_not_mem exact h #align equiv.perm.cycle_of_apply Equiv.Perm.cycleOf_apply theorem cycleOf_inv (f : Perm α) (x : α) : (cycleOf f x)⁻¹ = cycleOf f⁻¹ x := Equiv.ext fun y => by rw [inv_eq_iff_eq, cycleOf_apply, cycleOf_apply] split_ifs <;> simp_all [sameCycle_inv, sameCycle_inv_apply_right] #align equiv.perm.cycle_of_inv Equiv.Perm.cycleOf_inv @[simp] theorem cycleOf_pow_apply_self (f : Perm α) (x : α) : ∀ n : ℕ, (cycleOf f x ^ n) x = (f ^ n) x := by intro n induction' n with n hn · rfl · rw [pow_succ', mul_apply, cycleOf_apply, hn, if_pos, pow_succ', mul_apply] exact ⟨n, rfl⟩ #align equiv.perm.cycle_of_pow_apply_self Equiv.Perm.cycleOf_pow_apply_self @[simp] theorem cycleOf_zpow_apply_self (f : Perm α) (x : α) : ∀ n : ℤ, (cycleOf f x ^ n) x = (f ^ n) x := by intro z induction' z with z hz · exact cycleOf_pow_apply_self f x z · rw [zpow_negSucc, ← inv_pow, cycleOf_inv, zpow_negSucc, ← inv_pow, cycleOf_pow_apply_self] #align equiv.perm.cycle_of_zpow_apply_self Equiv.Perm.cycleOf_zpow_apply_self theorem SameCycle.cycleOf_apply : SameCycle f x y → cycleOf f x y = f y := ofSubtype_apply_of_mem _ #align equiv.perm.same_cycle.cycle_of_apply Equiv.Perm.SameCycle.cycleOf_apply theorem cycleOf_apply_of_not_sameCycle : ¬SameCycle f x y → cycleOf f x y = y := ofSubtype_apply_of_not_mem _ #align equiv.perm.cycle_of_apply_of_not_same_cycle Equiv.Perm.cycleOf_apply_of_not_sameCycle theorem SameCycle.cycleOf_eq (h : SameCycle f x y) : cycleOf f x = cycleOf f y := by ext z rw [Equiv.Perm.cycleOf_apply] split_ifs with hz · exact (h.symm.trans hz).cycleOf_apply.symm · exact (cycleOf_apply_of_not_sameCycle (mt h.trans hz)).symm #align equiv.perm.same_cycle.cycle_of_eq Equiv.Perm.SameCycle.cycleOf_eq @[simp] theorem cycleOf_apply_apply_zpow_self (f : Perm α) (x : α) (k : ℤ) : cycleOf f x ((f ^ k) x) = (f ^ (k + 1) : Perm α) x := by rw [SameCycle.cycleOf_apply] · rw [add_comm, zpow_add, zpow_one, mul_apply] · exact ⟨k, rfl⟩ #align equiv.perm.cycle_of_apply_apply_zpow_self Equiv.Perm.cycleOf_apply_apply_zpow_self @[simp]
Mathlib/GroupTheory/Perm/Cycle/Factors.lean
107
109
theorem cycleOf_apply_apply_pow_self (f : Perm α) (x : α) (k : ℕ) : cycleOf f x ((f ^ k) x) = (f ^ (k + 1) : Perm α) x := by
convert cycleOf_apply_apply_zpow_self f x k using 1
/- Copyright (c) 2020 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Topology.Algebra.Module.Basic import Mathlib.LinearAlgebra.Multilinear.Basic #align_import topology.algebra.module.multilinear from "leanprover-community/mathlib"@"f40476639bac089693a489c9e354ebd75dc0f886" /-! # Continuous multilinear maps We define continuous multilinear maps as maps from `(i : ι) → M₁ i` to `M₂` which are multilinear and continuous, by extending the space of multilinear maps with a continuity assumption. Here, `M₁ i` and `M₂` are modules over a ring `R`, and `ι` is an arbitrary type, and all these spaces are also topological spaces. ## Main definitions * `ContinuousMultilinearMap R M₁ M₂` is the space of continuous multilinear maps from `(i : ι) → M₁ i` to `M₂`. We show that it is an `R`-module. ## Implementation notes We mostly follow the API of multilinear maps. ## Notation We introduce the notation `M [×n]→L[R] M'` for the space of continuous `n`-multilinear maps from `M^n` to `M'`. This is a particular case of the general notion (where we allow varying dependent types as the arguments of our continuous multilinear maps), but arguably the most important one, especially when defining iterated derivatives. -/ open Function Fin Set universe u v w w₁ w₁' w₂ w₃ w₄ variable {R : Type u} {ι : Type v} {n : ℕ} {M : Fin n.succ → Type w} {M₁ : ι → Type w₁} {M₁' : ι → Type w₁'} {M₂ : Type w₂} {M₃ : Type w₃} {M₄ : Type w₄} /-- Continuous multilinear maps over the ring `R`, from `∀ i, M₁ i` to `M₂` where `M₁ i` and `M₂` are modules over `R` with a topological structure. In applications, there will be compatibility conditions between the algebraic and the topological structures, but this is not needed for the definition. -/ structure ContinuousMultilinearMap (R : Type u) {ι : Type v} (M₁ : ι → Type w₁) (M₂ : Type w₂) [Semiring R] [∀ i, AddCommMonoid (M₁ i)] [AddCommMonoid M₂] [∀ i, Module R (M₁ i)] [Module R M₂] [∀ i, TopologicalSpace (M₁ i)] [TopologicalSpace M₂] extends MultilinearMap R M₁ M₂ where cont : Continuous toFun #align continuous_multilinear_map ContinuousMultilinearMap attribute [inherit_doc ContinuousMultilinearMap] ContinuousMultilinearMap.cont @[inherit_doc] notation:25 M "[×" n "]→L[" R "] " M' => ContinuousMultilinearMap R (fun i : Fin n => M) M' namespace ContinuousMultilinearMap section Semiring variable [Semiring R] [∀ i, AddCommMonoid (M i)] [∀ i, AddCommMonoid (M₁ i)] [∀ i, AddCommMonoid (M₁' i)] [AddCommMonoid M₂] [AddCommMonoid M₃] [AddCommMonoid M₄] [∀ i, Module R (M i)] [∀ i, Module R (M₁ i)] [∀ i, Module R (M₁' i)] [Module R M₂] [Module R M₃] [Module R M₄] [∀ i, TopologicalSpace (M i)] [∀ i, TopologicalSpace (M₁ i)] [∀ i, TopologicalSpace (M₁' i)] [TopologicalSpace M₂] [TopologicalSpace M₃] [TopologicalSpace M₄] (f f' : ContinuousMultilinearMap R M₁ M₂) theorem toMultilinearMap_injective : Function.Injective (ContinuousMultilinearMap.toMultilinearMap : ContinuousMultilinearMap R M₁ M₂ → MultilinearMap R M₁ M₂) | ⟨f, hf⟩, ⟨g, hg⟩, h => by subst h; rfl #align continuous_multilinear_map.to_multilinear_map_injective ContinuousMultilinearMap.toMultilinearMap_injective instance funLike : FunLike (ContinuousMultilinearMap R M₁ M₂) (∀ i, M₁ i) M₂ where coe f := f.toFun coe_injective' _ _ h := toMultilinearMap_injective <| MultilinearMap.coe_injective h instance continuousMapClass : ContinuousMapClass (ContinuousMultilinearMap R M₁ M₂) (∀ i, M₁ i) M₂ where map_continuous := ContinuousMultilinearMap.cont #align continuous_multilinear_map.continuous_map_class ContinuousMultilinearMap.continuousMapClass instance : CoeFun (ContinuousMultilinearMap R M₁ M₂) fun _ => (∀ i, M₁ i) → M₂ := ⟨fun f => f⟩ /-- See Note [custom simps projection]. We need to specify this projection explicitly in this case, because it is a composition of multiple projections. -/ def Simps.apply (L₁ : ContinuousMultilinearMap R M₁ M₂) (v : ∀ i, M₁ i) : M₂ := L₁ v #align continuous_multilinear_map.simps.apply ContinuousMultilinearMap.Simps.apply initialize_simps_projections ContinuousMultilinearMap (-toMultilinearMap, toMultilinearMap_toFun → apply) @[continuity] theorem coe_continuous : Continuous (f : (∀ i, M₁ i) → M₂) := f.cont #align continuous_multilinear_map.coe_continuous ContinuousMultilinearMap.coe_continuous @[simp] theorem coe_coe : (f.toMultilinearMap : (∀ i, M₁ i) → M₂) = f := rfl #align continuous_multilinear_map.coe_coe ContinuousMultilinearMap.coe_coe @[ext] theorem ext {f f' : ContinuousMultilinearMap R M₁ M₂} (H : ∀ x, f x = f' x) : f = f' := DFunLike.ext _ _ H #align continuous_multilinear_map.ext ContinuousMultilinearMap.ext
Mathlib/Topology/Algebra/Module/Multilinear/Basic.lean
113
114
theorem ext_iff {f f' : ContinuousMultilinearMap R M₁ M₂} : f = f' ↔ ∀ x, f x = f' x := by
rw [← toMultilinearMap_injective.eq_iff, MultilinearMap.ext_iff]; rfl
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Eric Wieser -/ import Mathlib.LinearAlgebra.Matrix.DotProduct import Mathlib.LinearAlgebra.Determinant import Mathlib.LinearAlgebra.Matrix.Diagonal #align_import data.matrix.rank from "leanprover-community/mathlib"@"17219820a8aa8abe85adf5dfde19af1dd1bd8ae7" /-! # Rank of matrices The rank of a matrix `A` is defined to be the rank of range of the linear map corresponding to `A`. This definition does not depend on the choice of basis, see `Matrix.rank_eq_finrank_range_toLin`. ## Main declarations * `Matrix.rank`: the rank of a matrix ## TODO * Do a better job of generalizing over `ℚ`, `ℝ`, and `ℂ` in `Matrix.rank_transpose` and `Matrix.rank_conjTranspose`. See [this Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/row.20rank.20equals.20column.20rank/near/350462992). -/ open Matrix namespace Matrix open FiniteDimensional variable {l m n o R : Type*} [Fintype n] [Fintype o] section CommRing variable [CommRing R] /-- The rank of a matrix is the rank of its image. -/ 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
Mathlib/Data/Matrix/Rank.lean
71
74
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 _ _)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Topology.Order.IsLUB /-! # Order topology on a densely ordered set -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) variable {α β γ : Type*} section DenselyOrdered variable [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [DenselyOrdered α] {a b : α} {s : Set α} /-- The closure of the interval `(a, +∞)` is the closed interval `[a, +∞)`, unless `a` is a top element. -/ theorem closure_Ioi' {a : α} (h : (Ioi a).Nonempty) : closure (Ioi a) = Ici a := by apply Subset.antisymm · exact closure_minimal Ioi_subset_Ici_self isClosed_Ici · rw [← diff_subset_closure_iff, Ici_diff_Ioi_same, singleton_subset_iff] exact isGLB_Ioi.mem_closure h #align closure_Ioi' closure_Ioi' /-- The closure of the interval `(a, +∞)` is the closed interval `[a, +∞)`. -/ @[simp] theorem closure_Ioi (a : α) [NoMaxOrder α] : closure (Ioi a) = Ici a := closure_Ioi' nonempty_Ioi #align closure_Ioi closure_Ioi /-- The closure of the interval `(-∞, a)` is the closed interval `(-∞, a]`, unless `a` is a bottom element. -/ theorem closure_Iio' (h : (Iio a).Nonempty) : closure (Iio a) = Iic a := closure_Ioi' (α := αᵒᵈ) h #align closure_Iio' closure_Iio' /-- The closure of the interval `(-∞, a)` is the interval `(-∞, a]`. -/ @[simp] theorem closure_Iio (a : α) [NoMinOrder α] : closure (Iio a) = Iic a := closure_Iio' nonempty_Iio #align closure_Iio closure_Iio /-- The closure of the open interval `(a, b)` is the closed interval `[a, b]`. -/ @[simp] theorem closure_Ioo {a b : α} (hab : a ≠ b) : closure (Ioo a b) = Icc a b := by apply Subset.antisymm · exact closure_minimal Ioo_subset_Icc_self isClosed_Icc · cases' hab.lt_or_lt with hab hab · rw [← diff_subset_closure_iff, Icc_diff_Ioo_same hab.le] have hab' : (Ioo a b).Nonempty := nonempty_Ioo.2 hab simp only [insert_subset_iff, singleton_subset_iff] exact ⟨(isGLB_Ioo hab).mem_closure hab', (isLUB_Ioo hab).mem_closure hab'⟩ · rw [Icc_eq_empty_of_lt hab] exact empty_subset _ #align closure_Ioo closure_Ioo /-- The closure of the interval `(a, b]` is the closed interval `[a, b]`. -/ @[simp] theorem closure_Ioc {a b : α} (hab : a ≠ b) : closure (Ioc a b) = Icc a b := by apply Subset.antisymm · exact closure_minimal Ioc_subset_Icc_self isClosed_Icc · apply Subset.trans _ (closure_mono Ioo_subset_Ioc_self) rw [closure_Ioo hab] #align closure_Ioc closure_Ioc /-- The closure of the interval `[a, b)` is the closed interval `[a, b]`. -/ @[simp] theorem closure_Ico {a b : α} (hab : a ≠ b) : closure (Ico a b) = Icc a b := by apply Subset.antisymm · exact closure_minimal Ico_subset_Icc_self isClosed_Icc · apply Subset.trans _ (closure_mono Ioo_subset_Ico_self) rw [closure_Ioo hab] #align closure_Ico closure_Ico @[simp] theorem interior_Ici' {a : α} (ha : (Iio a).Nonempty) : interior (Ici a) = Ioi a := by rw [← compl_Iio, interior_compl, closure_Iio' ha, compl_Iic] #align interior_Ici' interior_Ici' theorem interior_Ici [NoMinOrder α] {a : α} : interior (Ici a) = Ioi a := interior_Ici' nonempty_Iio #align interior_Ici interior_Ici @[simp] theorem interior_Iic' {a : α} (ha : (Ioi a).Nonempty) : interior (Iic a) = Iio a := interior_Ici' (α := αᵒᵈ) ha #align interior_Iic' interior_Iic' theorem interior_Iic [NoMaxOrder α] {a : α} : interior (Iic a) = Iio a := interior_Iic' nonempty_Ioi #align interior_Iic interior_Iic @[simp] theorem interior_Icc [NoMinOrder α] [NoMaxOrder α] {a b : α} : interior (Icc a b) = Ioo a b := by rw [← Ici_inter_Iic, interior_inter, interior_Ici, interior_Iic, Ioi_inter_Iio] #align interior_Icc interior_Icc @[simp] theorem Icc_mem_nhds_iff [NoMinOrder α] [NoMaxOrder α] {a b x : α} : Icc a b ∈ 𝓝 x ↔ x ∈ Ioo a b := by rw [← interior_Icc, mem_interior_iff_mem_nhds] @[simp] theorem interior_Ico [NoMinOrder α] {a b : α} : interior (Ico a b) = Ioo a b := by rw [← Ici_inter_Iio, interior_inter, interior_Ici, interior_Iio, Ioi_inter_Iio] #align interior_Ico interior_Ico @[simp] theorem Ico_mem_nhds_iff [NoMinOrder α] {a b x : α} : Ico a b ∈ 𝓝 x ↔ x ∈ Ioo a b := by rw [← interior_Ico, mem_interior_iff_mem_nhds] @[simp] theorem interior_Ioc [NoMaxOrder α] {a b : α} : interior (Ioc a b) = Ioo a b := by rw [← Ioi_inter_Iic, interior_inter, interior_Ioi, interior_Iic, Ioi_inter_Iio] #align interior_Ioc interior_Ioc @[simp]
Mathlib/Topology/Order/DenselyOrdered.lean
125
126
theorem Ioc_mem_nhds_iff [NoMaxOrder α] {a b x : α} : Ioc a b ∈ 𝓝 x ↔ x ∈ Ioo a b := by
rw [← interior_Ioc, mem_interior_iff_mem_nhds]
/- Copyright (c) 2019 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou -/ import Mathlib.Order.Filter.AtTopBot import Mathlib.Tactic.FieldSimp import Mathlib.Tactic.LinearCombination import Mathlib.Tactic.Linarith.Frontend #align_import algebra.quadratic_discriminant from "leanprover-community/mathlib"@"e085d1df33274f4b32f611f483aae678ba0b42df" /-! # Quadratic discriminants and roots of a quadratic This file defines the discriminant of a quadratic and gives the solution to a quadratic equation. ## Main definition - `discrim a b c`: the discriminant of a quadratic `a * x * x + b * x + c` is `b * b - 4 * a * c`. ## Main statements - `quadratic_eq_zero_iff`: roots of a quadratic can be written as `(-b + s) / (2 * a)` or `(-b - s) / (2 * a)`, where `s` is a square root of the discriminant. - `quadratic_ne_zero_of_discrim_ne_sq`: if the discriminant has no square root, then the corresponding quadratic has no root. - `discrim_le_zero`: if a quadratic is always non-negative, then its discriminant is non-positive. - `discrim_le_zero_of_nonpos`, `discrim_lt_zero`, `discrim_lt_zero_of_neg`: versions of this statement with other inequalities. ## Tags polynomial, quadratic, discriminant, root -/ open Filter section Ring variable {R : Type*} /-- Discriminant of a quadratic -/ def discrim [Ring R] (a b c : R) : R := b ^ 2 - 4 * a * c #align discrim discrim @[simp] lemma discrim_neg [Ring R] (a b c : R) : discrim (-a) (-b) (-c) = discrim a b c := by simp [discrim] #align discrim_neg discrim_neg variable [CommRing R] {a b c : R} lemma discrim_eq_sq_of_quadratic_eq_zero {x : R} (h : a * x * x + b * x + c = 0) : discrim a b c = (2 * a * x + b) ^ 2 := by rw [discrim] linear_combination -4 * a * h #align discrim_eq_sq_of_quadratic_eq_zero discrim_eq_sq_of_quadratic_eq_zero /-- A quadratic has roots if and only if its discriminant equals some square. -/
Mathlib/Algebra/QuadraticDiscriminant.lean
63
70
theorem quadratic_eq_zero_iff_discrim_eq_sq [NeZero (2 : R)] [NoZeroDivisors R] (ha : a ≠ 0) (x : R) : a * x * x + b * x + c = 0 ↔ discrim a b c = (2 * a * x + b) ^ 2 := by
refine ⟨discrim_eq_sq_of_quadratic_eq_zero, fun h ↦ ?_⟩ rw [discrim] at h have ha : 2 * 2 * a ≠ 0 := mul_ne_zero (mul_ne_zero (NeZero.ne _) (NeZero.ne _)) ha apply mul_left_cancel₀ ha linear_combination -h
/- Copyright (c) 2019 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.Calculus.Deriv.Mul import Mathlib.Analysis.Calculus.Deriv.Comp #align_import analysis.calculus.deriv.pow from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Derivative of `(f x) ^ n`, `n : ℕ` In this file we prove that `(x ^ n)' = n * x ^ (n - 1)`, where `n` is a natural number. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `Analysis/Calculus/Deriv/Basic`. ## Keywords derivative, power -/ universe u v w open scoped Classical open Topology Filter ENNReal open Filter Asymptotics Set 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 L₁ L₂ : Filter 𝕜} /-! ### Derivative of `x ↦ x^n` for `n : ℕ` -/ variable {c : 𝕜 → 𝕜} {c' : 𝕜} variable (n : ℕ) theorem hasStrictDerivAt_pow : ∀ (n : ℕ) (x : 𝕜), HasStrictDerivAt (fun x : 𝕜 ↦ x ^ n) ((n : 𝕜) * x ^ (n - 1)) x | 0, x => by simp [hasStrictDerivAt_const] | 1, x => by simpa using hasStrictDerivAt_id x | n + 1 + 1, x => by simpa [pow_succ, add_mul, mul_assoc] using (hasStrictDerivAt_pow (n + 1) x).mul (hasStrictDerivAt_id x) #align has_strict_deriv_at_pow hasStrictDerivAt_pow theorem hasDerivAt_pow (n : ℕ) (x : 𝕜) : HasDerivAt (fun x : 𝕜 => x ^ n) ((n : 𝕜) * x ^ (n - 1)) x := (hasStrictDerivAt_pow n x).hasDerivAt #align has_deriv_at_pow hasDerivAt_pow theorem hasDerivWithinAt_pow (n : ℕ) (x : 𝕜) (s : Set 𝕜) : HasDerivWithinAt (fun x : 𝕜 => x ^ n) ((n : 𝕜) * x ^ (n - 1)) s x := (hasDerivAt_pow n x).hasDerivWithinAt #align has_deriv_within_at_pow hasDerivWithinAt_pow theorem differentiableAt_pow : DifferentiableAt 𝕜 (fun x : 𝕜 => x ^ n) x := (hasDerivAt_pow n x).differentiableAt #align differentiable_at_pow differentiableAt_pow theorem differentiableWithinAt_pow : DifferentiableWithinAt 𝕜 (fun x : 𝕜 => x ^ n) s x := (differentiableAt_pow n).differentiableWithinAt #align differentiable_within_at_pow differentiableWithinAt_pow theorem differentiable_pow : Differentiable 𝕜 fun x : 𝕜 => x ^ n := fun _ => differentiableAt_pow n #align differentiable_pow differentiable_pow theorem differentiableOn_pow : DifferentiableOn 𝕜 (fun x : 𝕜 => x ^ n) s := (differentiable_pow n).differentiableOn #align differentiable_on_pow differentiableOn_pow theorem deriv_pow : deriv (fun x : 𝕜 => x ^ n) x = (n : 𝕜) * x ^ (n - 1) := (hasDerivAt_pow n x).deriv #align deriv_pow deriv_pow @[simp] theorem deriv_pow' : (deriv fun x : 𝕜 => x ^ n) = fun x => (n : 𝕜) * x ^ (n - 1) := funext fun _ => deriv_pow n #align deriv_pow' deriv_pow' theorem derivWithin_pow (hxs : UniqueDiffWithinAt 𝕜 s x) : derivWithin (fun x : 𝕜 => x ^ n) s x = (n : 𝕜) * x ^ (n - 1) := (hasDerivWithinAt_pow n x s).derivWithin hxs #align deriv_within_pow derivWithin_pow theorem HasDerivWithinAt.pow (hc : HasDerivWithinAt c c' s x) : HasDerivWithinAt (fun y => c y ^ n) ((n : 𝕜) * c x ^ (n - 1) * c') s x := (hasDerivAt_pow n (c x)).comp_hasDerivWithinAt x hc #align has_deriv_within_at.pow HasDerivWithinAt.pow
Mathlib/Analysis/Calculus/Deriv/Pow.lean
99
102
theorem HasDerivAt.pow (hc : HasDerivAt c c' x) : HasDerivAt (fun y => c y ^ n) ((n : 𝕜) * c x ^ (n - 1) * c') x := by
rw [← hasDerivWithinAt_univ] at * exact hc.pow n
/- Copyright (c) 2021 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Degree.Lemmas import Mathlib.Algebra.Polynomial.HasseDeriv #align_import data.polynomial.taylor from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Taylor expansions of polynomials ## Main declarations * `Polynomial.taylor`: the Taylor expansion of the polynomial `f` at `r` * `Polynomial.taylor_coeff`: the `k`th coefficient of `taylor r f` is `(Polynomial.hasseDeriv k f).eval r` * `Polynomial.eq_zero_of_hasseDeriv_eq_zero`: the identity principle: a polynomial is 0 iff all its Hasse derivatives are zero -/ noncomputable section namespace Polynomial open Polynomial variable {R : Type*} [Semiring R] (r : R) (f : R[X]) /-- The Taylor expansion of a polynomial `f` at `r`. -/ def taylor (r : R) : R[X] →ₗ[R] R[X] where toFun f := f.comp (X + C r) map_add' f g := add_comp map_smul' c f := by simp only [smul_eq_C_mul, C_mul_comp, RingHom.id_apply] #align polynomial.taylor Polynomial.taylor theorem taylor_apply : taylor r f = f.comp (X + C r) := rfl #align polynomial.taylor_apply Polynomial.taylor_apply @[simp]
Mathlib/Algebra/Polynomial/Taylor.lean
46
46
theorem taylor_X : taylor r X = X + C r := by
simp only [taylor_apply, X_comp]
/- Copyright (c) 2020 Johan Commelin, Robert Y. Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Robert Y. Lewis -/ import Mathlib.NumberTheory.Padics.PadicIntegers import Mathlib.RingTheory.ZMod #align_import number_theory.padics.ring_homs from "leanprover-community/mathlib"@"565eb991e264d0db702722b4bde52ee5173c9950" /-! # Relating `ℤ_[p]` to `ZMod (p ^ n)` In this file we establish connections between the `p`-adic integers $\mathbb{Z}_p$ and the integers modulo powers of `p`, $\mathbb{Z}/p^n\mathbb{Z}$. ## Main declarations We show that $\mathbb{Z}_p$ has a ring hom to $\mathbb{Z}/p^n\mathbb{Z}$ for each `n`. The case for `n = 1` is handled separately, since it is used in the general construction and we may want to use it without the `^1` getting in the way. * `PadicInt.toZMod`: ring hom to `ZMod p` * `PadicInt.toZModPow`: ring hom to `ZMod (p^n)` * `PadicInt.ker_toZMod` / `PadicInt.ker_toZModPow`: the kernels of these maps are the ideals generated by `p^n` We also establish the universal property of $\mathbb{Z}_p$ as a projective limit. Given a family of compatible ring homs $f_k : R \to \mathbb{Z}/p^n\mathbb{Z}$, there is a unique limit $R \to \mathbb{Z}_p$. * `PadicInt.lift`: the limit function * `PadicInt.lift_spec` / `PadicInt.lift_unique`: the universal property ## Implementation notes The ring hom constructions go through an auxiliary constructor `PadicInt.toZModHom`, which removes some boilerplate code. -/ noncomputable section open scoped Classical open Nat LocalRing Padic namespace PadicInt variable {p : ℕ} [hp_prime : Fact p.Prime] section RingHoms /-! ### Ring homomorphisms to `ZMod p` and `ZMod (p ^ n)` -/ variable (p) (r : ℚ) /-- `modPart p r` is an integer that satisfies `‖(r - modPart p r : ℚ_[p])‖ < 1` when `‖(r : ℚ_[p])‖ ≤ 1`, see `PadicInt.norm_sub_modPart`. It is the unique non-negative integer that is `< p` with this property. (Note that this definition assumes `r : ℚ`. See `PadicInt.zmodRepr` for a version that takes values in `ℕ` and works for arbitrary `x : ℤ_[p]`.) -/ def modPart : ℤ := r.num * gcdA r.den p % p #align padic_int.mod_part PadicInt.modPart variable {p} theorem modPart_lt_p : modPart p r < p := by convert Int.emod_lt _ _ · simp · exact mod_cast hp_prime.1.ne_zero #align padic_int.mod_part_lt_p PadicInt.modPart_lt_p theorem modPart_nonneg : 0 ≤ modPart p r := Int.emod_nonneg _ <| mod_cast hp_prime.1.ne_zero #align padic_int.mod_part_nonneg PadicInt.modPart_nonneg
Mathlib/NumberTheory/Padics/RingHoms.lean
82
101
theorem isUnit_den (r : ℚ) (h : ‖(r : ℚ_[p])‖ ≤ 1) : IsUnit (r.den : ℤ_[p]) := by
rw [isUnit_iff] apply le_antisymm (r.den : ℤ_[p]).2 rw [← not_lt, coe_natCast] intro norm_denom_lt have hr : ‖(r * r.den : ℚ_[p])‖ = ‖(r.num : ℚ_[p])‖ := by congr rw_mod_cast [@Rat.mul_den_eq_num r] rw [padicNormE.mul] at hr have key : ‖(r.num : ℚ_[p])‖ < 1 := by calc _ = _ := hr.symm _ < 1 * 1 := mul_lt_mul' h norm_denom_lt (norm_nonneg _) zero_lt_one _ = 1 := mul_one 1 have : ↑p ∣ r.num ∧ (p : ℤ) ∣ r.den := by simp only [← norm_int_lt_one_iff_dvd, ← padic_norm_e_of_padicInt] exact ⟨key, norm_denom_lt⟩ apply hp_prime.1.not_dvd_one rwa [← r.reduced.gcd_eq_one, Nat.dvd_gcd_iff, ← Int.natCast_dvd, ← Int.natCast_dvd_natCast]
/- Copyright (c) 2021 David Wärn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Wärn -/ import Mathlib.Topology.Separation import Mathlib.Algebra.Group.Defs #align_import topology.algebra.semigroup from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" /-! # Idempotents in topological semigroups This file provides a sufficient condition for a semigroup `M` to contain an idempotent (i.e. an element `m` such that `m * m = m `), namely that `M` is a nonempty compact Hausdorff space where right-multiplication by constants is continuous. We also state a corresponding lemma guaranteeing that a subset of `M` contains an idempotent. -/ /-- Any nonempty compact Hausdorff semigroup where right-multiplication is continuous contains an idempotent, i.e. an `m` such that `m * m = m`. -/ @[to_additive "Any nonempty compact Hausdorff additive semigroup where right-addition is continuous contains an idempotent, i.e. an `m` such that `m + m = m`"] theorem exists_idempotent_of_compact_t2_of_continuous_mul_left {M} [Nonempty M] [Semigroup M] [TopologicalSpace M] [CompactSpace M] [T2Space M] (continuous_mul_left : ∀ r : M, Continuous (· * r)) : ∃ m : M, m * m = m := by /- We apply Zorn's lemma to the poset of nonempty closed subsemigroups of `M`. It will turn out that any minimal element is `{m}` for an idempotent `m : M`. -/ let S : Set (Set M) := { N | IsClosed N ∧ N.Nonempty ∧ ∀ (m) (_ : m ∈ N) (m') (_ : m' ∈ N), m * m' ∈ N } rsuffices ⟨N, ⟨N_closed, ⟨m, hm⟩, N_mul⟩, N_minimal⟩ : ∃ N ∈ S, ∀ N' ∈ S, N' ⊆ N → N' = N · use m /- We now have an element `m : M` of a minimal subsemigroup `N`, and want to show `m + m = m`. We first show that every element of `N` is of the form `m' + m`. -/ have scaling_eq_self : (· * m) '' N = N := by apply N_minimal · refine ⟨(continuous_mul_left m).isClosedMap _ N_closed, ⟨_, ⟨m, hm, rfl⟩⟩, ?_⟩ rintro _ ⟨m'', hm'', rfl⟩ _ ⟨m', hm', rfl⟩ exact ⟨m'' * m * m', N_mul _ (N_mul _ hm'' _ hm) _ hm', mul_assoc _ _ _⟩ · rintro _ ⟨m', hm', rfl⟩ exact N_mul _ hm' _ hm /- In particular, this means that `m' * m = m` for some `m'`. We now use minimality again to show that this holds for all `m' ∈ N`. -/ have absorbing_eq_self : N ∩ { m' | m' * m = m } = N := by apply N_minimal · refine ⟨N_closed.inter ((T1Space.t1 m).preimage (continuous_mul_left m)), ?_, ?_⟩ · rwa [← scaling_eq_self] at hm · rintro m'' ⟨mem'', eq'' : _ = m⟩ m' ⟨mem', eq' : _ = m⟩ refine ⟨N_mul _ mem'' _ mem', ?_⟩ rw [Set.mem_setOf_eq, mul_assoc, eq', eq''] apply Set.inter_subset_left -- Thus `m * m = m` as desired. rw [← absorbing_eq_self] at hm exact hm.2 refine zorn_superset _ fun c hcs hc => ?_ refine ⟨⋂₀ c, ⟨isClosed_sInter fun t ht => (hcs ht).1, ?_, fun m hm m' hm' => ?_⟩, fun s hs => Set.sInter_subset_of_mem hs⟩ · obtain rfl | hcnemp := c.eq_empty_or_nonempty · rw [Set.sInter_empty] apply Set.univ_nonempty convert @IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed _ _ _ hcnemp.coe_sort ((↑) : c → Set M) ?_ ?_ ?_ ?_ · exact Set.sInter_eq_iInter · refine DirectedOn.directed_val (IsChain.directedOn hc.symm) exacts [fun i => (hcs i.prop).2.1, fun i => (hcs i.prop).1.isCompact, fun i => (hcs i.prop).1] · rw [Set.mem_sInter] exact fun t ht => (hcs ht).2.2 m (Set.mem_sInter.mp hm t ht) m' (Set.mem_sInter.mp hm' t ht) #align exists_idempotent_of_compact_t2_of_continuous_mul_left exists_idempotent_of_compact_t2_of_continuous_mul_left #align exists_idempotent_of_compact_t2_of_continuous_add_left exists_idempotent_of_compact_t2_of_continuous_add_left /-- A version of `exists_idempotent_of_compact_t2_of_continuous_mul_left` where the idempotent lies in some specified nonempty compact subsemigroup. -/ @[to_additive exists_idempotent_in_compact_add_subsemigroup "A version of `exists_idempotent_of_compact_t2_of_continuous_add_left` where the idempotent lies in some specified nonempty compact additive subsemigroup."]
Mathlib/Topology/Algebra/Semigroup.lean
82
95
theorem exists_idempotent_in_compact_subsemigroup {M} [Semigroup M] [TopologicalSpace M] [T2Space M] (continuous_mul_left : ∀ r : M, Continuous (· * r)) (s : Set M) (snemp : s.Nonempty) (s_compact : IsCompact s) (s_add : ∀ᵉ (x ∈ s) (y ∈ s), x * y ∈ s) : ∃ m ∈ s, m * m = m := by
let M' := { m // m ∈ s } letI : Semigroup M' := { mul := fun p q => ⟨p.1 * q.1, s_add _ p.2 _ q.2⟩ mul_assoc := fun p q r => Subtype.eq (mul_assoc _ _ _) } haveI : CompactSpace M' := isCompact_iff_compactSpace.mp s_compact haveI : Nonempty M' := nonempty_subtype.mpr snemp have : ∀ p : M', Continuous (· * p) := fun p => ((continuous_mul_left p.1).comp continuous_subtype_val).subtype_mk _ obtain ⟨⟨m, hm⟩, idem⟩ := exists_idempotent_of_compact_t2_of_continuous_mul_left this exact ⟨m, hm, Subtype.ext_iff.mp idem⟩
/- Copyright (c) 2023 Joachim Breitner. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joachim Breitner -/ import Mathlib.Probability.ProbabilityMassFunction.Basic import Mathlib.Probability.ProbabilityMassFunction.Constructions import Mathlib.MeasureTheory.Integral.Bochner /-! # Integrals with a measure derived from probability mass functions. This files connects `PMF` with `integral`. The main result is that the integral (i.e. the expected value) with regard to a measure derived from a `PMF` is a sum weighted by the `PMF`. It also provides the expected value for specific probability mass functions. -/ namespace PMF open MeasureTheory ENNReal TopologicalSpace section General variable {α : Type*} [MeasurableSpace α] [MeasurableSingletonClass α] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] theorem integral_eq_tsum (p : PMF α) (f : α → E) (hf : Integrable f p.toMeasure) : ∫ a, f a ∂(p.toMeasure) = ∑' a, (p a).toReal • f a := calc _ = ∫ a in p.support, f a ∂(p.toMeasure) := by rw [restrict_toMeasure_support p] _ = ∑' (a : support p), (p.toMeasure {a.val}).toReal • f a := by apply integral_countable f p.support_countable rwa [restrict_toMeasure_support p] _ = ∑' (a : support p), (p a).toReal • f a := by congr with x; congr 2 apply PMF.toMeasure_apply_singleton p x (MeasurableSet.singleton _) _ = ∑' a, (p a).toReal • f a := tsum_subtype_eq_of_support_subset <| by calc (fun a ↦ (p a).toReal • f a).support ⊆ (fun a ↦ (p a).toReal).support := Function.support_smul_subset_left _ _ _ ⊆ support p := fun x h1 h2 => h1 (by simp [h2])
Mathlib/Probability/ProbabilityMassFunction/Integrals.lean
43
47
theorem integral_eq_sum [Fintype α] (p : PMF α) (f : α → E) : ∫ a, f a ∂(p.toMeasure) = ∑ a, (p a).toReal • f a := by
rw [integral_fintype _ (.of_finite _ f)] congr with x; congr 2 exact PMF.toMeasure_apply_singleton p x (MeasurableSet.singleton _)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Topology.Algebra.InfiniteSum.Basic import Mathlib.Topology.Algebra.UniformGroup /-! # Infinite sums and products in topological groups Lemmas on topological sums in groups (as opposed to monoids). -/ noncomputable section open Filter Finset Function open scoped Topology variable {α β γ δ : Type*} section TopologicalGroup variable [CommGroup α] [TopologicalSpace α] [TopologicalGroup α] variable {f g : β → α} {a a₁ a₂ : α} -- `by simpa using` speeds up elaboration. Why? @[to_additive] theorem HasProd.inv (h : HasProd f a) : HasProd (fun b ↦ (f b)⁻¹) a⁻¹ := by simpa only using h.map (MonoidHom.id α)⁻¹ continuous_inv #align has_sum.neg HasSum.neg @[to_additive] theorem Multipliable.inv (hf : Multipliable f) : Multipliable fun b ↦ (f b)⁻¹ := hf.hasProd.inv.multipliable #align summable.neg Summable.neg @[to_additive] theorem Multipliable.of_inv (hf : Multipliable fun b ↦ (f b)⁻¹) : Multipliable f := by simpa only [inv_inv] using hf.inv #align summable.of_neg Summable.of_neg @[to_additive] theorem multipliable_inv_iff : (Multipliable fun b ↦ (f b)⁻¹) ↔ Multipliable f := ⟨Multipliable.of_inv, Multipliable.inv⟩ #align summable_neg_iff summable_neg_iff @[to_additive] theorem HasProd.div (hf : HasProd f a₁) (hg : HasProd g a₂) : HasProd (fun b ↦ f b / g b) (a₁ / a₂) := by simp only [div_eq_mul_inv] exact hf.mul hg.inv #align has_sum.sub HasSum.sub @[to_additive] theorem Multipliable.div (hf : Multipliable f) (hg : Multipliable g) : Multipliable fun b ↦ f b / g b := (hf.hasProd.div hg.hasProd).multipliable #align summable.sub Summable.sub @[to_additive]
Mathlib/Topology/Algebra/InfiniteSum/Group.lean
63
65
theorem Multipliable.trans_div (hg : Multipliable g) (hfg : Multipliable fun b ↦ f b / g b) : Multipliable f := by
simpa only [div_mul_cancel] using hfg.mul hg
/- Copyright (c) 2022 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux -/ import Mathlib.Analysis.NormedSpace.Exponential #align_import analysis.normed_space.star.exponential from "leanprover-community/mathlib"@"1e3201306d4d9eb1fd54c60d7c4510ad5126f6f9" /-! # The exponential map from selfadjoint to unitary In this file, we establish various properties related to the map `fun a ↦ exp ℂ A (I • a)` between the subtypes `selfAdjoint A` and `unitary A`. ## TODO * Show that any exponential unitary is path-connected in `unitary A` to `1 : unitary A`. * Prove any unitary whose distance to `1 : unitary A` is less than `1` can be expressed as an exponential unitary. * A unitary is in the path component of `1` if and only if it is a finite product of exponential unitaries. -/ open NormedSpace -- For `NormedSpace.exp`. section Star variable {A : Type*} [NormedRing A] [NormedAlgebra ℂ A] [StarRing A] [ContinuousStar A] [CompleteSpace A] [StarModule ℂ A] open Complex /-- The map from the selfadjoint real subspace to the unitary group. This map only makes sense over ℂ. -/ @[simps] noncomputable def selfAdjoint.expUnitary (a : selfAdjoint A) : unitary A := ⟨exp ℂ ((I • a.val) : A), exp_mem_unitary_of_mem_skewAdjoint _ (a.prop.smul_mem_skewAdjoint conj_I)⟩ #align self_adjoint.exp_unitary selfAdjoint.expUnitary open selfAdjoint theorem Commute.expUnitary_add {a b : selfAdjoint A} (h : Commute (a : A) (b : A)) : expUnitary (a + b) = expUnitary a * expUnitary b := by ext have hcomm : Commute (I • (a : A)) (I • (b : A)) := by unfold Commute SemiconjBy simp only [h.eq, Algebra.smul_mul_assoc, Algebra.mul_smul_comm] simpa only [expUnitary_coe, AddSubgroup.coe_add, smul_add] using exp_add_of_commute hcomm #align commute.exp_unitary_add Commute.expUnitary_add
Mathlib/Analysis/NormedSpace/Star/Exponential.lean
51
56
theorem Commute.expUnitary {a b : selfAdjoint A} (h : Commute (a : A) (b : A)) : Commute (expUnitary a) (expUnitary b) := calc selfAdjoint.expUnitary a * selfAdjoint.expUnitary b = selfAdjoint.expUnitary b * selfAdjoint.expUnitary a := by
rw [← h.expUnitary_add, ← h.symm.expUnitary_add, add_comm]
/- Copyright (c) 2022 Xavier Roblot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Xavier Roblot -/ import Mathlib.Analysis.Complex.Basic import Mathlib.FieldTheory.IntermediateField import Mathlib.Topology.Algebra.Field import Mathlib.Topology.Algebra.UniformRing #align_import topology.instances.complex from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" /-! # Some results about the topology of ℂ -/ section ComplexSubfield open Complex Set open ComplexConjugate /-- The only closed subfields of `ℂ` are `ℝ` and `ℂ`. -/
Mathlib/Topology/Instances/Complex.lean
25
44
theorem Complex.subfield_eq_of_closed {K : Subfield ℂ} (hc : IsClosed (K : Set ℂ)) : K = ofReal.fieldRange ∨ K = ⊤ := by
suffices range (ofReal' : ℝ → ℂ) ⊆ K by rw [range_subset_iff, ← coe_algebraMap] at this have := (Subalgebra.isSimpleOrder_of_finrank finrank_real_complex).eq_bot_or_eq_top (Subfield.toIntermediateField K this).toSubalgebra simp_rw [← SetLike.coe_set_eq, IntermediateField.coe_toSubalgebra] at this ⊢ exact this suffices range (ofReal' : ℝ → ℂ) ⊆ closure (Set.range ((ofReal' : ℝ → ℂ) ∘ ((↑) : ℚ → ℝ))) by refine subset_trans this ?_ rw [← IsClosed.closure_eq hc] apply closure_mono rintro _ ⟨_, rfl⟩ simp only [Function.comp_apply, ofReal_ratCast, SetLike.mem_coe, SubfieldClass.ratCast_mem] nth_rw 1 [range_comp] refine subset_trans ?_ (image_closure_subset_closure_image continuous_ofReal) rw [DenseRange.closure_range Rat.denseEmbedding_coe_real.dense] simp only [image_univ] rfl
/- Copyright (c) 2021 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot -/ import Mathlib.RingTheory.Ideal.Maps import Mathlib.Topology.Algebra.Nonarchimedean.Bases import Mathlib.Topology.Algebra.UniformRing #align_import topology.algebra.nonarchimedean.adic_topology from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" /-! # Adic topology Given a commutative ring `R` and an ideal `I` in `R`, this file constructs the unique topology on `R` which is compatible with the ring structure and such that a set is a neighborhood of zero if and only if it contains a power of `I`. This topology is non-archimedean: every neighborhood of zero contains an open subgroup, namely a power of `I`. It also studies the predicate `IsAdic` which states that a given topological ring structure is adic, proving a characterization and showing that raising an ideal to a positive power does not change the associated topology. Finally, it defines `WithIdeal`, a class registering an ideal in a ring and providing the corresponding adic topology to the type class inference system. ## Main definitions and results * `Ideal.adic_basis`: the basis of submodules given by powers of an ideal. * `Ideal.adicTopology`: the adic topology associated to an ideal. It has the above basis for neighborhoods of zero. * `Ideal.nonarchimedean`: the adic topology is non-archimedean * `isAdic_iff`: A topological ring is `J`-adic if and only if it admits the powers of `J` as a basis of open neighborhoods of zero. * `WithIdeal`: a class registering an ideal in a ring. ## Implementation notes The `I`-adic topology on a ring `R` has a contrived definition using `I^n • ⊤` instead of `I` to make sure it is definitionally equal to the `I`-topology on `R` seen as an `R`-module. -/ variable {R : Type*} [CommRing R] open Set TopologicalAddGroup Submodule Filter open Topology Pointwise namespace Ideal theorem adic_basis (I : Ideal R) : SubmodulesRingBasis fun n : ℕ => (I ^ n • ⊤ : Ideal R) := { inter := by suffices ∀ i j : ℕ, ∃ k, I ^ k ≤ I ^ i ∧ I ^ k ≤ I ^ j by simpa only [smul_eq_mul, mul_top, Algebra.id.map_eq_id, map_id, le_inf_iff] using this intro i j exact ⟨max i j, pow_le_pow_right (le_max_left i j), pow_le_pow_right (le_max_right i j)⟩ leftMul := by suffices ∀ (a : R) (i : ℕ), ∃ j : ℕ, a • I ^ j ≤ I ^ i by simpa only [smul_top_eq_map, Algebra.id.map_eq_id, map_id] using this intro r n use n rintro a ⟨x, hx, rfl⟩ exact (I ^ n).smul_mem r hx mul := by suffices ∀ i : ℕ, ∃ j : ℕ, (↑(I ^ j) * ↑(I ^ j) : Set R) ⊆ (↑(I ^ i) : Set R) by simpa only [smul_top_eq_map, Algebra.id.map_eq_id, map_id] using this intro n use n rintro a ⟨x, _hx, b, hb, rfl⟩ exact (I ^ n).smul_mem x hb } #align ideal.adic_basis Ideal.adic_basis /-- The adic ring filter basis associated to an ideal `I` is made of powers of `I`. -/ def ringFilterBasis (I : Ideal R) := I.adic_basis.toRing_subgroups_basis.toRingFilterBasis #align ideal.ring_filter_basis Ideal.ringFilterBasis /-- The adic topology associated to an ideal `I`. This topology admits powers of `I` as a basis of neighborhoods of zero. It is compatible with the ring structure and is non-archimedean. -/ def adicTopology (I : Ideal R) : TopologicalSpace R := (adic_basis I).topology #align ideal.adic_topology Ideal.adicTopology theorem nonarchimedean (I : Ideal R) : @NonarchimedeanRing R _ I.adicTopology := I.adic_basis.toRing_subgroups_basis.nonarchimedean #align ideal.nonarchimedean Ideal.nonarchimedean /-- For the `I`-adic topology, the neighborhoods of zero has basis given by the powers of `I`. -/
Mathlib/Topology/Algebra/Nonarchimedean/AdicTopology.lean
92
103
theorem hasBasis_nhds_zero_adic (I : Ideal R) : HasBasis (@nhds R I.adicTopology (0 : R)) (fun _n : ℕ => True) fun n => ((I ^ n : Ideal R) : Set R) := ⟨by intro U rw [I.ringFilterBasis.toAddGroupFilterBasis.nhds_zero_hasBasis.mem_iff] constructor · rintro ⟨-, ⟨i, rfl⟩, h⟩ replace h : ↑(I ^ i) ⊆ U := by
simpa using h exact ⟨i, trivial, h⟩ · rintro ⟨i, -, h⟩ exact ⟨(I ^ i : Ideal R), ⟨i, by simp⟩, h⟩⟩
/- Copyright (c) 2020 Kevin Kappelmann. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Kappelmann -/ import Mathlib.Algebra.ContinuedFractions.Translations #align_import algebra.continued_fractions.terminated_stable from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" /-! # Stabilisation of gcf Computations Under Termination ## Summary We show that the continuants and convergents of a gcf stabilise once the gcf terminates. -/ namespace GeneralizedContinuedFraction variable {K : Type*} {g : GeneralizedContinuedFraction K} {n m : ℕ} /-- If a gcf terminated at position `n`, it also terminated at `m ≥ n`. -/ theorem terminated_stable (n_le_m : n ≤ m) (terminated_at_n : g.TerminatedAt n) : g.TerminatedAt m := g.s.terminated_stable n_le_m terminated_at_n #align generalized_continued_fraction.terminated_stable GeneralizedContinuedFraction.terminated_stable variable [DivisionRing K]
Mathlib/Algebra/ContinuedFractions/TerminatedStable.lean
31
34
theorem continuantsAux_stable_step_of_terminated (terminated_at_n : g.TerminatedAt n) : g.continuantsAux (n + 2) = g.continuantsAux (n + 1) := by
rw [terminatedAt_iff_s_none] at terminated_at_n simp only [continuantsAux, Nat.add_eq, Nat.add_zero, terminated_at_n]
/- Copyright (c) 2022 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Batteries.Data.RBMap.Alter import Batteries.Data.List.Lemmas /-! # Additional lemmas for Red-black trees -/ namespace Batteries namespace RBNode open RBColor attribute [simp] fold foldl foldr Any forM foldlM Ordered @[simp] theorem min?_reverse (t : RBNode α) : t.reverse.min? = t.max? := by unfold RBNode.max?; split <;> simp [RBNode.min?] unfold RBNode.min?; rw [min?.match_1.eq_3] · apply min?_reverse · simpa [reverse_eq_iff] @[simp] theorem max?_reverse (t : RBNode α) : t.reverse.max? = t.min? := by rw [← min?_reverse, reverse_reverse] @[simp] theorem mem_nil {x} : ¬x ∈ (.nil : RBNode α) := by simp [(·∈·), EMem] @[simp] theorem mem_node {y c a x b} : y ∈ (.node c a x b : RBNode α) ↔ y = x ∨ y ∈ a ∨ y ∈ b := by simp [(·∈·), EMem]
.lake/packages/batteries/Batteries/Data/RBMap/Lemmas.lean
32
33
theorem All_def {t : RBNode α} : t.All p ↔ ∀ x ∈ t, p x := by
induction t <;> simp [or_imp, forall_and, *]
/- Copyright (c) 2016 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl -/ import Mathlib.Algebra.CharZero.Defs import Mathlib.Algebra.Group.Hom.Defs import Mathlib.Algebra.Order.Monoid.Canonical.Defs import Mathlib.Algebra.Order.Monoid.OrderDual import Mathlib.Algebra.Order.ZeroLEOne import Mathlib.Data.Nat.Cast.Defs import Mathlib.Order.WithBot #align_import algebra.order.monoid.with_top from "leanprover-community/mathlib"@"0111834459f5d7400215223ea95ae38a1265a907" /-! # Adjoining top/bottom elements to ordered monoids. -/ universe u v variable {α : Type u} {β : Type v} open Function namespace WithTop section One variable [One α] {a : α} @[to_additive] instance one : One (WithTop α) := ⟨(1 : α)⟩ #align with_top.has_one WithTop.one #align with_top.has_zero WithTop.zero @[to_additive (attr := simp, norm_cast)] theorem coe_one : ((1 : α) : WithTop α) = 1 := rfl #align with_top.coe_one WithTop.coe_one #align with_top.coe_zero WithTop.coe_zero @[to_additive (attr := simp, norm_cast)] lemma coe_eq_one : (a : WithTop α) = 1 ↔ a = 1 := coe_eq_coe #align with_top.coe_eq_one WithTop.coe_eq_one #align with_top.coe_eq_zero WithTop.coe_eq_zero @[to_additive (attr := simp, norm_cast)] lemma one_eq_coe : 1 = (a : WithTop α) ↔ a = 1 := eq_comm.trans coe_eq_one #align with_top.one_eq_coe WithTop.one_eq_coe #align with_top.zero_eq_coe WithTop.zero_eq_coe @[to_additive (attr := simp)] lemma top_ne_one : (⊤ : WithTop α) ≠ 1 := top_ne_coe #align with_top.top_ne_one WithTop.top_ne_one #align with_top.top_ne_zero WithTop.top_ne_zero @[to_additive (attr := simp)] lemma one_ne_top : (1 : WithTop α) ≠ ⊤ := coe_ne_top #align with_top.one_ne_top WithTop.one_ne_top #align with_top.zero_ne_top WithTop.zero_ne_top @[to_additive (attr := simp)] theorem untop_one : (1 : WithTop α).untop coe_ne_top = 1 := rfl #align with_top.untop_one WithTop.untop_one #align with_top.untop_zero WithTop.untop_zero @[to_additive (attr := simp)] theorem untop_one' (d : α) : (1 : WithTop α).untop' d = 1 := rfl #align with_top.untop_one' WithTop.untop_one' #align with_top.untop_zero' WithTop.untop_zero' @[to_additive (attr := simp, norm_cast) coe_nonneg] theorem one_le_coe [LE α] {a : α} : 1 ≤ (a : WithTop α) ↔ 1 ≤ a := coe_le_coe #align with_top.one_le_coe WithTop.one_le_coe #align with_top.coe_nonneg WithTop.coe_nonneg @[to_additive (attr := simp, norm_cast) coe_le_zero] theorem coe_le_one [LE α] {a : α} : (a : WithTop α) ≤ 1 ↔ a ≤ 1 := coe_le_coe #align with_top.coe_le_one WithTop.coe_le_one #align with_top.coe_le_zero WithTop.coe_le_zero @[to_additive (attr := simp, norm_cast) coe_pos] theorem one_lt_coe [LT α] {a : α} : 1 < (a : WithTop α) ↔ 1 < a := coe_lt_coe #align with_top.one_lt_coe WithTop.one_lt_coe #align with_top.coe_pos WithTop.coe_pos @[to_additive (attr := simp, norm_cast) coe_lt_zero] theorem coe_lt_one [LT α] {a : α} : (a : WithTop α) < 1 ↔ a < 1 := coe_lt_coe #align with_top.coe_lt_one WithTop.coe_lt_one #align with_top.coe_lt_zero WithTop.coe_lt_zero @[to_additive (attr := simp)] protected theorem map_one {β} (f : α → β) : (1 : WithTop α).map f = (f 1 : WithTop β) := rfl #align with_top.map_one WithTop.map_one #align with_top.map_zero WithTop.map_zero instance zeroLEOneClass [Zero α] [LE α] [ZeroLEOneClass α] : ZeroLEOneClass (WithTop α) := ⟨coe_le_coe.2 zero_le_one⟩ end One section Add variable [Add α] {a b c d : WithTop α} {x y : α} instance add : Add (WithTop α) := ⟨Option.map₂ (· + ·)⟩ #align with_top.has_add WithTop.add @[simp, norm_cast] lemma coe_add (a b : α) : ↑(a + b) = (a + b : WithTop α) := rfl #align with_top.coe_add WithTop.coe_add #noalign with_top.coe_bit0 #noalign with_top.coe_bit1 @[simp] theorem top_add (a : WithTop α) : ⊤ + a = ⊤ := rfl #align with_top.top_add WithTop.top_add @[simp]
Mathlib/Algebra/Order/Monoid/WithTop.lean
128
128
theorem add_top (a : WithTop α) : a + ⊤ = ⊤ := by
cases a <;> rfl
/- Copyright (c) 2023 Andrew Yang, Patrick Lutz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.RingTheory.RootsOfUnity.Basic import Mathlib.RingTheory.AdjoinRoot import Mathlib.FieldTheory.Galois import Mathlib.LinearAlgebra.Eigenspace.Minpoly import Mathlib.RingTheory.Norm /-! # Kummer Extensions ## Main result - `isCyclic_tfae`: Suppose `L/K` is a finite extension of dimension `n`, and `K` contains all `n`-th roots of unity. Then `L/K` is cyclic iff `L` is a splitting field of some irreducible polynomial of the form `Xⁿ - a : K[X]` iff `L = K[α]` for some `αⁿ ∈ K`. - `autEquivRootsOfUnity`: Given an instance `IsSplittingField K L (X ^ n - C a)` (perhaps via `isSplittingField_X_pow_sub_C_of_root_adjoin_eq_top`), then the galois group is isomorphic to `rootsOfUnity n K`, by sending `σ ↦ σ α / α` for `α ^ n = a`, and the inverse is given by `μ ↦ (α ↦ μ • α)`. - `autEquivZmod`: Furthermore, given an explicit choice `ζ` of a primitive `n`-th root of unity, the galois group is then isomorphic to `Multiplicative (ZMod n)` whose inverse is given by `i ↦ (α ↦ ζⁱ • α)`. ## Other results Criteria for `X ^ n - C a` to be irreducible is given: - `X_pow_sub_C_irreducible_iff_of_prime`: For `n = p` a prime, `X ^ n - C a` is irreducible iff `a` is not a `p`-power. - `X_pow_sub_C_irreducible_iff_of_prime_pow`: For `n = p ^ k` an odd prime power, `X ^ n - C a` is irreducible iff `a` is not a `p`-power. - `X_pow_sub_C_irreducible_iff_forall_prime_of_odd`: For `n` odd, `X ^ n - C a` is irreducible iff `a` is not a `p`-power for all prime `p ∣ n`. - `X_pow_sub_C_irreducible_iff_of_odd`: For `n` odd, `X ^ n - C a` is irreducible iff `a` is not a `d`-power for `d ∣ n` and `d ≠ 1`. TODO: criteria for even `n`. See [serge_lang_algebra] VI,§9. -/ universe u variable {K : Type u} [Field K] open Polynomial IntermediateField AdjoinRoot section Splits lemma root_X_pow_sub_C_pow (n : ℕ) (a : K) : (AdjoinRoot.root (X ^ n - C a)) ^ n = AdjoinRoot.of _ a := by rw [← sub_eq_zero, ← AdjoinRoot.eval₂_root, eval₂_sub, eval₂_C, eval₂_pow, eval₂_X] lemma root_X_pow_sub_C_ne_zero {n : ℕ} (hn : 1 < n) (a : K) : (AdjoinRoot.root (X ^ n - C a)) ≠ 0 := mk_ne_zero_of_natDegree_lt (monic_X_pow_sub_C _ (Nat.not_eq_zero_of_lt hn)) X_ne_zero <| by rwa [natDegree_X_pow_sub_C, natDegree_X] lemma root_X_pow_sub_C_ne_zero' {n : ℕ} {a : K} (hn : 0 < n) (ha : a ≠ 0) : (AdjoinRoot.root (X ^ n - C a)) ≠ 0 := by obtain (rfl|hn) := (Nat.succ_le_iff.mpr hn).eq_or_lt · rw [← Nat.one_eq_succ_zero, pow_one] intro e refine mk_ne_zero_of_natDegree_lt (monic_X_sub_C a) (C_ne_zero.mpr ha) (by simp) ?_ trans AdjoinRoot.mk (X - C a) (X - (X - C a)) · rw [sub_sub_cancel] · rw [map_sub, mk_self, sub_zero, mk_X, e] · exact root_X_pow_sub_C_ne_zero hn a
Mathlib/FieldTheory/KummerExtension.lean
74
82
theorem X_pow_sub_C_splits_of_isPrimitiveRoot {n : ℕ} {ζ : K} (hζ : IsPrimitiveRoot ζ n) {α a : K} (e : α ^ n = a) : (X ^ n - C a).Splits (RingHom.id _) := by
cases n.eq_zero_or_pos with | inl hn => rw [hn, pow_zero, ← C.map_one, ← map_sub] exact splits_C _ _ | inr hn => rw [splits_iff_card_roots, ← nthRoots, hζ.card_nthRoots, natDegree_X_pow_sub_C, if_pos ⟨α, e⟩]
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Combinatorics.SetFamily.HarrisKleitman import Mathlib.Combinatorics.SetFamily.Intersecting #align_import combinatorics.set_family.kleitman from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" /-! # Kleitman's bound on the size of intersecting families An intersecting family on `n` elements has size at most `2ⁿ⁻¹`, so we could naïvely think that two intersecting families could cover all `2ⁿ` sets. But actually that's not case because for example none of them can contain the empty set. Intersecting families are in some sense correlated. Kleitman's bound stipulates that `k` intersecting families cover at most `2ⁿ - 2ⁿ⁻ᵏ` sets. ## Main declarations * `Finset.card_biUnion_le_of_intersecting`: Kleitman's theorem. ## References * [D. J. Kleitman, *Families of non-disjoint subsets*][kleitman1966] -/ open Finset open Fintype (card) variable {ι α : Type*} [Fintype α] [DecidableEq α] [Nonempty α] /-- **Kleitman's theorem**. An intersecting family on `n` elements contains at most `2ⁿ⁻¹` sets, and each further intersecting family takes at most half of the sets that are in no previous family. -/
Mathlib/Combinatorics/SetFamily/Kleitman.lean
37
85
theorem Finset.card_biUnion_le_of_intersecting (s : Finset ι) (f : ι → Finset (Finset α)) (hf : ∀ i ∈ s, (f i : Set (Finset α)).Intersecting) : (s.biUnion f).card ≤ 2 ^ Fintype.card α - 2 ^ (Fintype.card α - s.card) := by
have : DecidableEq ι := by classical infer_instance obtain hs | hs := le_total (Fintype.card α) s.card · rw [tsub_eq_zero_of_le hs, pow_zero] refine (card_le_card <| biUnion_subset.2 fun i hi a ha ↦ mem_compl.2 <| not_mem_singleton.2 <| (hf _ hi).ne_bot ha).trans_eq ?_ rw [card_compl, Fintype.card_finset, card_singleton] induction' s using Finset.cons_induction with i s hi ih generalizing f · simp set f' : ι → Finset (Finset α) := fun j ↦ if hj : j ∈ cons i s hi then (hf j hj).exists_card_eq.choose else ∅ have hf₁ : ∀ j, j ∈ cons i s hi → f j ⊆ f' j ∧ 2 * (f' j).card = 2 ^ Fintype.card α ∧ (f' j : Set (Finset α)).Intersecting := by rintro j hj simp_rw [f', dif_pos hj, ← Fintype.card_finset] exact Classical.choose_spec (hf j hj).exists_card_eq have hf₂ : ∀ j, j ∈ cons i s hi → IsUpperSet (f' j : Set (Finset α)) := by refine fun j hj ↦ (hf₁ _ hj).2.2.isUpperSet' ((hf₁ _ hj).2.2.is_max_iff_card_eq.2 ?_) rw [Fintype.card_finset] exact (hf₁ _ hj).2.1 refine (card_le_card <| biUnion_mono fun j hj ↦ (hf₁ _ hj).1).trans ?_ nth_rw 1 [cons_eq_insert i] rw [biUnion_insert] refine (card_mono <| @le_sup_sdiff _ _ _ <| f' i).trans ((card_union_le _ _).trans ?_) rw [union_sdiff_left, sdiff_eq_inter_compl] refine le_of_mul_le_mul_left ?_ (pow_pos (zero_lt_two' ℕ) <| Fintype.card α + 1) rw [pow_succ, mul_add, mul_assoc, mul_comm _ 2, mul_assoc] refine (add_le_add ((mul_le_mul_left <| pow_pos (zero_lt_two' ℕ) _).2 (hf₁ _ <| mem_cons_self _ _).2.2.card_le) <| (mul_le_mul_left <| zero_lt_two' ℕ).2 <| IsUpperSet.card_inter_le_finset ?_ ?_).trans ?_ · rw [coe_biUnion] exact isUpperSet_iUnion₂ fun i hi ↦ hf₂ _ <| subset_cons _ hi · rw [coe_compl] exact (hf₂ _ <| mem_cons_self _ _).compl rw [mul_tsub, card_compl, Fintype.card_finset, mul_left_comm, mul_tsub, (hf₁ _ <| mem_cons_self _ _).2.1, two_mul, add_tsub_cancel_left, ← mul_tsub, ← mul_two, mul_assoc, ← add_mul, mul_comm] refine mul_le_mul_left' ?_ _ refine (add_le_add_left (ih _ (fun i hi ↦ (hf₁ _ <| subset_cons _ hi).2.2) ((card_le_card <| subset_cons _).trans hs)) _).trans ?_ rw [mul_tsub, two_mul, ← pow_succ', ← add_tsub_assoc_of_le (pow_le_pow_right' (one_le_two : (1 : ℕ) ≤ 2) tsub_le_self), tsub_add_eq_add_tsub hs, card_cons, add_tsub_add_eq_tsub_right]
/- Copyright (c) 2023 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.Data.Finset.Basic /-! # Update a function on a set of values This file defines `Function.updateFinset`, the operation that updates a function on a (finite) set of values. This is a very specific function used for `MeasureTheory.marginal`, and possibly not that useful for other purposes. -/ variable {ι : Sort _} {π : ι → Sort _} {x : ∀ i, π i} [DecidableEq ι] namespace Function /-- `updateFinset x s y` is the vector `x` with the coordinates in `s` changed to the values of `y`. -/ def updateFinset (x : ∀ i, π i) (s : Finset ι) (y : ∀ i : ↥s, π i) (i : ι) : π i := if hi : i ∈ s then y ⟨i, hi⟩ else x i open Finset Equiv theorem updateFinset_def {s : Finset ι} {y} : updateFinset x s y = fun i ↦ if hi : i ∈ s then y ⟨i, hi⟩ else x i := rfl @[simp] theorem updateFinset_empty {y} : updateFinset x ∅ y = x := rfl theorem updateFinset_singleton {i y} : updateFinset x {i} y = Function.update x i (y ⟨i, mem_singleton_self i⟩) := by congr with j by_cases hj : j = i · cases hj simp only [dif_pos, Finset.mem_singleton, update_same, updateFinset] · simp [hj, updateFinset]
Mathlib/Data/Finset/Update.lean
43
50
theorem update_eq_updateFinset {i y} : Function.update x i y = updateFinset x {i} (uniqueElim y) := by
congr with j by_cases hj : j = i · cases hj simp only [dif_pos, Finset.mem_singleton, update_same, updateFinset] exact uniqueElim_default (α := fun j : ({i} : Finset ι) => π j) y · simp [hj, updateFinset]
/- Copyright (c) 2023 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.RingTheory.Localization.Module import Mathlib.RingTheory.Norm import Mathlib.RingTheory.Discriminant #align_import ring_theory.localization.norm from "leanprover-community/mathlib"@"2e59a6de168f95d16b16d217b808a36290398c0a" /-! # Field/algebra norm / trace and localization This file contains results on the combination of `IsLocalization` and `Algebra.norm`, `Algebra.trace` and `Algebra.discr`. ## Main results * `Algebra.norm_localization`: let `S` be an extension of `R` and `Rₘ Sₘ` be localizations at `M` of `R S` respectively. Then the norm of `a : Sₘ` over `Rₘ` is the norm of `a : S` over `R` if `S` is free as `R`-module. * `Algebra.trace_localization`: let `S` be an extension of `R` and `Rₘ Sₘ` be localizations at `M` of `R S` respectively. Then the trace of `a : Sₘ` over `Rₘ` is the trace of `a : S` over `R` if `S` is free as `R`-module. * `Algebra.discr_localizationLocalization`: let `S` be an extension of `R` and `Rₘ Sₘ` be localizations at `M` of `R S` respectively. Let `b` be a `R`-basis of `S`. Then discriminant of the `Rₘ`-basis of `Sₘ` induced by `b` is the discriminant of `b`. ## Tags field norm, algebra norm, localization -/ open scoped nonZeroDivisors variable (R : Type*) {S : Type*} [CommRing R] [CommRing S] [Algebra R S] variable {Rₘ Sₘ : Type*} [CommRing Rₘ] [Algebra R Rₘ] [CommRing Sₘ] [Algebra S Sₘ] variable (M : Submonoid R) variable [IsLocalization M Rₘ] [IsLocalization (Algebra.algebraMapSubmonoid S M) Sₘ] variable [Algebra Rₘ Sₘ] [Algebra R Sₘ] [IsScalarTower R Rₘ Sₘ] [IsScalarTower R S Sₘ] open Algebra theorem Algebra.map_leftMulMatrix_localization {ι : Type*} [Fintype ι] [DecidableEq ι] (b : Basis ι R S) (a : S) : (algebraMap R Rₘ).mapMatrix (leftMulMatrix b a) = leftMulMatrix (b.localizationLocalization Rₘ M Sₘ) (algebraMap S Sₘ a) := by ext i j simp only [Matrix.map_apply, RingHom.mapMatrix_apply, leftMulMatrix_eq_repr_mul, ← map_mul, Basis.localizationLocalization_apply, Basis.localizationLocalization_repr_algebraMap] /-- Let `S` be an extension of `R` and `Rₘ Sₘ` be localizations at `M` of `R S` respectively. Then the norm of `a : Sₘ` over `Rₘ` is the norm of `a : S` over `R` if `S` is free as `R`-module. -/ theorem Algebra.norm_localization [Module.Free R S] [Module.Finite R S] (a : S) : Algebra.norm Rₘ (algebraMap S Sₘ a) = algebraMap R Rₘ (Algebra.norm R a) := by cases subsingleton_or_nontrivial R · haveI : Subsingleton Rₘ := Module.subsingleton R Rₘ simp [eq_iff_true_of_subsingleton] let b := Module.Free.chooseBasis R S letI := Classical.decEq (Module.Free.ChooseBasisIndex R S) rw [Algebra.norm_eq_matrix_det (b.localizationLocalization Rₘ M Sₘ), Algebra.norm_eq_matrix_det b, RingHom.map_det, ← Algebra.map_leftMulMatrix_localization] #align algebra.norm_localization Algebra.norm_localization variable {M} in /-- The norm of `a : S` in `R` can be computed in `Sₘ`. -/ lemma Algebra.norm_eq_iff [Module.Free R S] [Module.Finite R S] {a : S} {b : R} (hM : M ≤ nonZeroDivisors R) : Algebra.norm R a = b ↔ (Algebra.norm Rₘ) ((algebraMap S Sₘ) a) = algebraMap R Rₘ b := ⟨fun h ↦ h.symm ▸ Algebra.norm_localization _ M _, fun h ↦ IsLocalization.injective Rₘ hM <| h.symm ▸ (Algebra.norm_localization R M a).symm⟩ /-- Let `S` be an extension of `R` and `Rₘ Sₘ` be localizations at `M` of `R S` respectively. Then the trace of `a : Sₘ` over `Rₘ` is the trace of `a : S` over `R` if `S` is free as `R`-module. -/ theorem Algebra.trace_localization [Module.Free R S] [Module.Finite R S] (a : S) : Algebra.trace Rₘ Sₘ (algebraMap S Sₘ a) = algebraMap R Rₘ (Algebra.trace R S a) := by cases subsingleton_or_nontrivial R · haveI : Subsingleton Rₘ := Module.subsingleton R Rₘ simp [eq_iff_true_of_subsingleton] let b := Module.Free.chooseBasis R S letI := Classical.decEq (Module.Free.ChooseBasisIndex R S) rw [Algebra.trace_eq_matrix_trace (b.localizationLocalization Rₘ M Sₘ), Algebra.trace_eq_matrix_trace b, ← Algebra.map_leftMulMatrix_localization] exact (AddMonoidHom.map_trace (algebraMap R Rₘ).toAddMonoidHom _).symm section LocalizationLocalization variable (Sₘ : Type*) [CommRing Sₘ] [Algebra S Sₘ] [Algebra Rₘ Sₘ] [Algebra R Sₘ] variable [IsScalarTower R Rₘ Sₘ] [IsScalarTower R S Sₘ] variable [IsLocalization (Algebra.algebraMapSubmonoid S M) Sₘ] variable {ι : Type*} [Fintype ι] [DecidableEq ι]
Mathlib/RingTheory/Localization/NormTrace.lean
101
109
theorem Algebra.traceMatrix_localizationLocalization (b : Basis ι R S) : Algebra.traceMatrix Rₘ (b.localizationLocalization Rₘ M Sₘ) = (algebraMap R Rₘ).mapMatrix (Algebra.traceMatrix R b) := by
have : Module.Finite R S := Module.Finite.of_basis b have : Module.Free R S := Module.Free.of_basis b ext i j : 2 simp_rw [RingHom.mapMatrix_apply, Matrix.map_apply, traceMatrix_apply, traceForm_apply, Basis.localizationLocalization_apply, ← map_mul] exact Algebra.trace_localization R M _
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson -/ import Mathlib.Analysis.SpecialFunctions.Complex.Arg import Mathlib.Analysis.SpecialFunctions.Log.Basic #align_import analysis.special_functions.complex.log from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # The complex `log` function Basic properties, relationship with `exp`. -/ noncomputable section namespace Complex open Set Filter Bornology open scoped Real Topology ComplexConjugate /-- Inverse of the `exp` function. Returns values such that `(log x).im > - π` and `(log x).im ≤ π`. `log 0 = 0`-/ -- Porting note: @[pp_nodot] does not exist in mathlib4 noncomputable def log (x : ℂ) : ℂ := x.abs.log + arg x * I #align complex.log Complex.log theorem log_re (x : ℂ) : x.log.re = x.abs.log := by simp [log] #align complex.log_re Complex.log_re theorem log_im (x : ℂ) : x.log.im = x.arg := by simp [log] #align complex.log_im Complex.log_im theorem neg_pi_lt_log_im (x : ℂ) : -π < (log x).im := by simp only [log_im, neg_pi_lt_arg] #align complex.neg_pi_lt_log_im Complex.neg_pi_lt_log_im theorem log_im_le_pi (x : ℂ) : (log x).im ≤ π := by simp only [log_im, arg_le_pi] #align complex.log_im_le_pi Complex.log_im_le_pi theorem exp_log {x : ℂ} (hx : x ≠ 0) : exp (log x) = x := by rw [log, exp_add_mul_I, ← ofReal_sin, sin_arg, ← ofReal_cos, cos_arg hx, ← ofReal_exp, Real.exp_log (abs.pos hx), mul_add, ofReal_div, ofReal_div, mul_div_cancel₀ _ (ofReal_ne_zero.2 <| abs.ne_zero hx), ← mul_assoc, mul_div_cancel₀ _ (ofReal_ne_zero.2 <| abs.ne_zero hx), re_add_im] #align complex.exp_log Complex.exp_log @[simp] theorem range_exp : Set.range exp = {0}ᶜ := Set.ext fun x => ⟨by rintro ⟨x, rfl⟩ exact exp_ne_zero x, fun hx => ⟨log x, exp_log hx⟩⟩ #align complex.range_exp Complex.range_exp theorem log_exp {x : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π) : log (exp x) = x := by rw [log, abs_exp, Real.log_exp, exp_eq_exp_re_mul_sin_add_cos, ← ofReal_exp, arg_mul_cos_add_sin_mul_I (Real.exp_pos _) ⟨hx₁, hx₂⟩, re_add_im] #align complex.log_exp Complex.log_exp theorem exp_inj_of_neg_pi_lt_of_le_pi {x y : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π) (hy₁ : -π < y.im) (hy₂ : y.im ≤ π) (hxy : exp x = exp y) : x = y := by rw [← log_exp hx₁ hx₂, ← log_exp hy₁ hy₂, hxy] #align complex.exp_inj_of_neg_pi_lt_of_le_pi Complex.exp_inj_of_neg_pi_lt_of_le_pi theorem ofReal_log {x : ℝ} (hx : 0 ≤ x) : (x.log : ℂ) = log x := Complex.ext (by rw [log_re, ofReal_re, abs_of_nonneg hx]) (by rw [ofReal_im, log_im, arg_ofReal_of_nonneg hx]) #align complex.of_real_log Complex.ofReal_log @[simp, norm_cast] lemma natCast_log {n : ℕ} : Real.log n = log n := ofReal_natCast n ▸ ofReal_log n.cast_nonneg @[simp] lemma ofNat_log {n : ℕ} [n.AtLeastTwo] : Real.log (no_index (OfNat.ofNat n)) = log (OfNat.ofNat n) := natCast_log theorem log_ofReal_re (x : ℝ) : (log (x : ℂ)).re = Real.log x := by simp [log_re] #align complex.log_of_real_re Complex.log_ofReal_re theorem log_ofReal_mul {r : ℝ} (hr : 0 < r) {x : ℂ} (hx : x ≠ 0) : log (r * x) = Real.log r + log x := by replace hx := Complex.abs.ne_zero_iff.mpr hx simp_rw [log, map_mul, abs_ofReal, arg_real_mul _ hr, abs_of_pos hr, Real.log_mul hr.ne' hx, ofReal_add, add_assoc] #align complex.log_of_real_mul Complex.log_ofReal_mul theorem log_mul_ofReal (r : ℝ) (hr : 0 < r) (x : ℂ) (hx : x ≠ 0) : log (x * r) = Real.log r + log x := by rw [mul_comm, log_ofReal_mul hr hx] #align complex.log_mul_of_real Complex.log_mul_ofReal lemma log_mul_eq_add_log_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) : log (x * y) = log x + log y ↔ arg x + arg y ∈ Set.Ioc (-π) π := by refine ext_iff.trans <| Iff.trans ?_ <| arg_mul_eq_add_arg_iff hx₀ hy₀ simp_rw [add_re, add_im, log_re, log_im, AbsoluteValue.map_mul, Real.log_mul (abs.ne_zero hx₀) (abs.ne_zero hy₀), true_and] alias ⟨_, log_mul⟩ := log_mul_eq_add_log_iff @[simp]
Mathlib/Analysis/SpecialFunctions/Complex/Log.lean
106
106
theorem log_zero : log 0 = 0 := by
simp [log]
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Group.Hom.Defs #align_import data.matrix.dmatrix from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Dependent-typed matrices -/ universe u u' v w z /-- `DMatrix m n` is the type of dependently typed matrices whose rows are indexed by the type `m` and whose columns are indexed by the type `n`. In most applications `m` and `n` are finite types. -/ def DMatrix (m : Type u) (n : Type u') (α : m → n → Type v) : Type max u u' v := ∀ i j, α i j #align dmatrix DMatrix variable {l m n o : Type*} variable {α : m → n → Type v} namespace DMatrix section Ext variable {M N : DMatrix m n α} theorem ext_iff : (∀ i j, M i j = N i j) ↔ M = N := ⟨fun h => funext fun i => funext <| h i, fun h => by simp [h]⟩ #align dmatrix.ext_iff DMatrix.ext_iff @[ext] theorem ext : (∀ i j, M i j = N i j) → M = N := ext_iff.mp #align dmatrix.ext DMatrix.ext end Ext /-- `M.map f` is the DMatrix obtained by applying `f` to each entry of the matrix `M`. -/ def map (M : DMatrix m n α) {β : m → n → Type w} (f : ∀ ⦃i j⦄, α i j → β i j) : DMatrix m n β := fun i j => f (M i j) #align dmatrix.map DMatrix.map @[simp] theorem map_apply {M : DMatrix m n α} {β : m → n → Type w} {f : ∀ ⦃i j⦄, α i j → β i j} {i : m} {j : n} : M.map f i j = f (M i j) := rfl #align dmatrix.map_apply DMatrix.map_apply @[simp]
Mathlib/Data/Matrix/DMatrix.lean
57
59
theorem map_map {M : DMatrix m n α} {β : m → n → Type w} {γ : m → n → Type z} {f : ∀ ⦃i j⦄, α i j → β i j} {g : ∀ ⦃i j⦄, β i j → γ i j} : (M.map f).map g = M.map fun i j x => g (f x) := by
ext; simp
/- Copyright (c) 2022 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Topology.Instances.Irrational import Mathlib.Topology.Instances.Rat import Mathlib.Topology.Compactification.OnePoint #align_import topology.instances.rat_lemmas from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7" /-! # Additional lemmas about the topology on rational numbers The structure of a metric space on `ℚ` (`Rat.MetricSpace`) is introduced elsewhere, induced from `ℝ`. In this file we prove some properties of this topological space and its one-point compactification. ## Main statements - `Rat.TotallyDisconnectedSpace`: `ℚ` is a totally disconnected space; - `Rat.not_countably_generated_nhds_infty_opc`: the filter of neighbourhoods of infinity in `OnePoint ℚ` is not countably generated. ## Notation - `ℚ∞` is used as a local notation for `OnePoint ℚ` -/ open Set Metric Filter TopologicalSpace open Topology OnePoint local notation "ℚ∞" => OnePoint ℚ namespace Rat variable {p q : ℚ} {s t : Set ℚ} theorem interior_compact_eq_empty (hs : IsCompact s) : interior s = ∅ := denseEmbedding_coe_real.toDenseInducing.interior_compact_eq_empty dense_irrational hs #align rat.interior_compact_eq_empty Rat.interior_compact_eq_empty theorem dense_compl_compact (hs : IsCompact s) : Dense sᶜ := interior_eq_empty_iff_dense_compl.1 (interior_compact_eq_empty hs) #align rat.dense_compl_compact Rat.dense_compl_compact instance cocompact_inf_nhds_neBot : NeBot (cocompact ℚ ⊓ 𝓝 p) := by refine (hasBasis_cocompact.inf (nhds_basis_opens _)).neBot_iff.2 ?_ rintro ⟨s, o⟩ ⟨hs, hpo, ho⟩; rw [inter_comm] exact (dense_compl_compact hs).inter_open_nonempty _ ho ⟨p, hpo⟩ #align rat.cocompact_inf_nhds_ne_bot Rat.cocompact_inf_nhds_neBot
Mathlib/Topology/Instances/RatLemmas.lean
56
62
theorem not_countably_generated_cocompact : ¬IsCountablyGenerated (cocompact ℚ) := by
intro H rcases exists_seq_tendsto (cocompact ℚ ⊓ 𝓝 0) with ⟨x, hx⟩ rw [tendsto_inf] at hx; rcases hx with ⟨hxc, hx0⟩ obtain ⟨n, hn⟩ : ∃ n : ℕ, x n ∉ insert (0 : ℚ) (range x) := (hxc.eventually hx0.isCompact_insert_range.compl_mem_cocompact).exists exact hn (Or.inr ⟨n, rfl⟩)
/- Copyright (c) 2018 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Simon Hudon -/ import Mathlib.Control.Functor.Multivariate import Mathlib.Data.PFunctor.Univariate.Basic #align_import data.pfunctor.multivariate.basic from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d" /-! # Multivariate polynomial functors. Multivariate polynomial functors are used for defining M-types and W-types. They map a type vector `α` to the type `Σ a : A, B a ⟹ α`, with `A : Type` and `B : A → TypeVec n`. They interact well with Lean's inductive definitions because they guarantee that occurrences of `α` are positive. -/ universe u v open MvFunctor /-- multivariate polynomial functors -/ @[pp_with_univ] structure MvPFunctor (n : ℕ) where /-- The head type -/ A : Type u /-- The child family of types -/ B : A → TypeVec.{u} n #align mvpfunctor MvPFunctor namespace MvPFunctor open MvFunctor (LiftP LiftR) variable {n m : ℕ} (P : MvPFunctor.{u} n) /-- Applying `P` to an object of `Type` -/ @[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 /-- Applying `P` to a morphism of `Type` -/ 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 /-- Constant functor where the input object does not affect the output -/ def const (n : ℕ) (A : Type u) : MvPFunctor n := { A B := fun _ _ => PEmpty } #align mvpfunctor.const MvPFunctor.const section Const variable (n) {A : Type u} {α β : TypeVec.{u} n} /-- Constructor for the constant functor -/ def const.mk (x : A) {α} : const n A α := ⟨x, fun _ a => PEmpty.elim a⟩ #align mvpfunctor.const.mk MvPFunctor.const.mk variable {n} /-- Destructor for the constant functor -/ def const.get (x : const n A α) : A := x.1 #align mvpfunctor.const.get MvPFunctor.const.get @[simp] theorem const.get_map (f : α ⟹ β) (x : const n A α) : const.get (f <$$> x) = const.get x := by cases x rfl #align mvpfunctor.const.get_map MvPFunctor.const.get_map @[simp] theorem const.get_mk (x : A) : const.get (const.mk n x : const n A α) = x := rfl #align mvpfunctor.const.get_mk MvPFunctor.const.get_mk @[simp]
Mathlib/Data/PFunctor/Multivariate/Basic.lean
116
119
theorem const.mk_get (x : const n A α) : const.mk n (const.get x) = x := by
cases x dsimp [const.get, const.mk] congr with (_⟨⟩)
/- Copyright (c) 2022 Pierre-Alexandre Bazin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Pierre-Alexandre Bazin -/ import Mathlib.Algebra.Module.Torsion import Mathlib.RingTheory.DedekindDomain.Ideal #align_import algebra.module.dedekind_domain from "leanprover-community/mathlib"@"cdc34484a07418af43daf8198beaf5c00324bca8" /-! # Modules over a Dedekind domain Over a Dedekind domain, an `I`-torsion module is the internal direct sum of its `p i ^ e i`-torsion submodules, where `I = ∏ i, p i ^ e i` is its unique decomposition in prime ideals. Therefore, as any finitely generated torsion module is `I`-torsion for some `I`, it is an internal direct sum of its `p i ^ e i`-torsion submodules for some prime ideals `p i` and numbers `e i`. -/ universe u v variable {R : Type u} [CommRing R] [IsDomain R] {M : Type v} [AddCommGroup M] [Module R M] open scoped DirectSum namespace Submodule variable [IsDedekindDomain R] open UniqueFactorizationMonoid open scoped Classical /-- Over a Dedekind domain, an `I`-torsion module is the internal direct sum of its `p i ^ e i`- torsion submodules, where `I = ∏ i, p i ^ e i` is its unique decomposition in prime ideals. -/ theorem isInternal_prime_power_torsion_of_is_torsion_by_ideal {I : Ideal R} (hI : I ≠ ⊥) (hM : Module.IsTorsionBySet R M I) : DirectSum.IsInternal fun p : (factors I).toFinset => torsionBySet R M (p ^ (factors I).count ↑p : Ideal R) := by let P := factors I have prime_of_mem := fun p (hp : p ∈ P.toFinset) => prime_of_factor p (Multiset.mem_toFinset.mp hp) apply torsionBySet_isInternal (p := fun p => p ^ P.count p) _ · convert hM rw [← Finset.inf_eq_iInf, IsDedekindDomain.inf_prime_pow_eq_prod, ← Finset.prod_multiset_count, ← associated_iff_eq] · exact factors_prod hI · exact prime_of_mem · exact fun _ _ _ _ ij => ij · intro p hp q hq pq; dsimp rw [irreducible_pow_sup] · suffices (normalizedFactors _).count p = 0 by rw [this, zero_min, pow_zero, Ideal.one_eq_top] rw [Multiset.count_eq_zero, normalizedFactors_of_irreducible_pow (prime_of_mem q hq).irreducible, Multiset.mem_replicate] exact fun H => pq <| H.2.trans <| normalize_eq q · rw [← Ideal.zero_eq_bot]; apply pow_ne_zero; exact (prime_of_mem q hq).ne_zero · exact (prime_of_mem p hp).irreducible #align submodule.is_internal_prime_power_torsion_of_is_torsion_by_ideal Submodule.isInternal_prime_power_torsion_of_is_torsion_by_ideal /-- A finitely generated torsion module over a Dedekind domain is an internal direct sum of its `p i ^ e i`-torsion submodules where `p i` are factors of `(⊤ : Submodule R M).annihilator` and `e i` are their multiplicities. -/
Mathlib/Algebra/Module/DedekindDomain.lean
65
72
theorem isInternal_prime_power_torsion [Module.Finite R M] (hM : Module.IsTorsion R M) : DirectSum.IsInternal fun p : (factors (⊤ : Submodule R M).annihilator).toFinset => torsionBySet R M (p ^ (factors (⊤ : Submodule R M).annihilator).count ↑p : Ideal R) := by
have hM' := Module.isTorsionBySet_annihilator_top R M have hI := Submodule.annihilator_top_inter_nonZeroDivisors hM refine isInternal_prime_power_torsion_of_is_torsion_by_ideal ?_ hM' rw [← Set.nonempty_iff_ne_empty] at hI; rw [Submodule.ne_bot_iff] obtain ⟨x, H, hx⟩ := hI; exact ⟨x, H, nonZeroDivisors.ne_zero hx⟩
/- Copyright (c) 2020 Aaron Anderson, Jalex Stark. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson, Jalex Stark -/ import Mathlib.Algebra.Polynomial.Expand import Mathlib.Algebra.Polynomial.Laurent import Mathlib.LinearAlgebra.Matrix.Charpoly.Basic import Mathlib.LinearAlgebra.Matrix.Reindex import Mathlib.RingTheory.Polynomial.Nilpotent #align_import linear_algebra.matrix.charpoly.coeff from "leanprover-community/mathlib"@"9745b093210e9dac443af24da9dba0f9e2b6c912" /-! # Characteristic polynomials We give methods for computing coefficients of the characteristic polynomial. ## Main definitions - `Matrix.charpoly_degree_eq_dim` proves that the degree of the characteristic polynomial over a nonzero ring is the dimension of the matrix - `Matrix.det_eq_sign_charpoly_coeff` proves that the determinant is the constant term of the characteristic polynomial, up to sign. - `Matrix.trace_eq_neg_charpoly_coeff` proves that the trace is the negative of the (d-1)th coefficient of the characteristic polynomial, where d is the dimension of the matrix. For a nonzero ring, this is the second-highest coefficient. - `Matrix.charpolyRev` the reverse of the characteristic polynomial. - `Matrix.reverse_charpoly` characterises the reverse of the characteristic polynomial. -/ noncomputable section -- porting note: whenever there was `∏ i : n, X - C (M i i)`, I replaced it with -- `∏ i : n, (X - C (M i i))`, since otherwise Lean would parse as `(∏ i : n, X) - C (M i i)` universe u v w z open Finset Matrix Polynomial variable {R : Type u} [CommRing R] variable {n G : Type v} [DecidableEq n] [Fintype n] variable {α β : Type v} [DecidableEq α] variable {M : Matrix n n R} namespace Matrix theorem charmatrix_apply_natDegree [Nontrivial R] (i j : n) : (charmatrix M i j).natDegree = ite (i = j) 1 0 := by by_cases h : i = j <;> simp [h, ← degree_eq_iff_natDegree_eq_of_pos (Nat.succ_pos 0)] #align charmatrix_apply_nat_degree Matrix.charmatrix_apply_natDegree theorem charmatrix_apply_natDegree_le (i j : n) : (charmatrix M i j).natDegree ≤ ite (i = j) 1 0 := by split_ifs with h <;> simp [h, natDegree_X_le] #align charmatrix_apply_nat_degree_le Matrix.charmatrix_apply_natDegree_le variable (M)
Mathlib/LinearAlgebra/Matrix/Charpoly/Coeff.lean
61
78
theorem charpoly_sub_diagonal_degree_lt : (M.charpoly - ∏ i : n, (X - C (M i i))).degree < ↑(Fintype.card n - 1) := by
rw [charpoly, det_apply', ← insert_erase (mem_univ (Equiv.refl n)), sum_insert (not_mem_erase (Equiv.refl n) univ), add_comm] simp only [charmatrix_apply_eq, one_mul, Equiv.Perm.sign_refl, id, Int.cast_one, Units.val_one, add_sub_cancel_right, Equiv.coe_refl] rw [← mem_degreeLT] apply Submodule.sum_mem (degreeLT R (Fintype.card n - 1)) intro c hc; rw [← C_eq_intCast, C_mul'] apply Submodule.smul_mem (degreeLT R (Fintype.card n - 1)) ↑↑(Equiv.Perm.sign c) rw [mem_degreeLT] apply lt_of_le_of_lt degree_le_natDegree _ rw [Nat.cast_lt] apply lt_of_le_of_lt _ (Equiv.Perm.fixed_point_card_lt_of_ne_one (ne_of_mem_erase hc)) apply le_trans (Polynomial.natDegree_prod_le univ fun i : n => charmatrix M (c i) i) _ rw [card_eq_sum_ones]; rw [sum_filter]; apply sum_le_sum intros apply charmatrix_apply_natDegree_le
/- Copyright (c) 2020 Thomas Browning, Patrick Lutz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning, Patrick Lutz -/ import Mathlib.FieldTheory.Galois #align_import field_theory.polynomial_galois_group from "leanprover-community/mathlib"@"e3f4be1fcb5376c4948d7f095bec45350bfb9d1a" /-! # Galois Groups of Polynomials In this file, we introduce the Galois group of a polynomial `p` over a field `F`, defined as the automorphism group of its splitting field. We also provide some results about some extension `E` above `p.SplittingField`. ## Main definitions - `Polynomial.Gal p`: the Galois group of a polynomial p. - `Polynomial.Gal.restrict p E`: the restriction homomorphism `(E ≃ₐ[F] E) → gal p`. - `Polynomial.Gal.galAction p E`: the action of `gal p` on the roots of `p` in `E`. ## Main results - `Polynomial.Gal.restrict_smul`: `restrict p E` is compatible with `gal_action p E`. - `Polynomial.Gal.galActionHom_injective`: `gal p` acting on the roots of `p` in `E` is faithful. - `Polynomial.Gal.restrictProd_injective`: `gal (p * q)` embeds as a subgroup of `gal p × gal q`. - `Polynomial.Gal.card_of_separable`: For a separable polynomial, its Galois group has cardinality equal to the dimension of its splitting field over `F`. - `Polynomial.Gal.galActionHom_bijective_of_prime_degree`: An irreducible polynomial of prime degree with two non-real roots has full Galois group. ## Other results - `Polynomial.Gal.card_complex_roots_eq_card_real_add_card_not_gal_inv`: The number of complex roots equals the number of real roots plus the number of roots not fixed by complex conjugation (i.e. with some imaginary component). -/ noncomputable section open scoped Polynomial open FiniteDimensional namespace Polynomial variable {F : Type*} [Field F] (p q : F[X]) (E : Type*) [Field E] [Algebra F E] /-- The Galois group of a polynomial. -/ def Gal := p.SplittingField ≃ₐ[F] p.SplittingField -- Porting note(https://github.com/leanprover-community/mathlib4/issues/5020): -- deriving Group, Fintype #align polynomial.gal Polynomial.Gal namespace Gal instance instGroup : Group (Gal p) := inferInstanceAs (Group (p.SplittingField ≃ₐ[F] p.SplittingField)) instance instFintype : Fintype (Gal p) := inferInstanceAs (Fintype (p.SplittingField ≃ₐ[F] p.SplittingField)) instance : CoeFun p.Gal fun _ => p.SplittingField → p.SplittingField := -- Porting note: was AlgEquiv.hasCoeToFun inferInstanceAs (CoeFun (p.SplittingField ≃ₐ[F] p.SplittingField) _) instance applyMulSemiringAction : MulSemiringAction p.Gal p.SplittingField := AlgEquiv.applyMulSemiringAction #align polynomial.gal.apply_mul_semiring_action Polynomial.Gal.applyMulSemiringAction @[ext]
Mathlib/FieldTheory/PolynomialGaloisGroup.lean
74
79
theorem ext {σ τ : p.Gal} (h : ∀ x ∈ p.rootSet p.SplittingField, σ x = τ x) : σ = τ := by
refine AlgEquiv.ext fun x => (AlgHom.mem_equalizer σ.toAlgHom τ.toAlgHom x).mp ((SetLike.ext_iff.mp ?_ x).mpr Algebra.mem_top) rwa [eq_top_iff, ← SplittingField.adjoin_rootSet, Algebra.adjoin_le_iff]
/- Copyright (c) 2021 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta -/ import Mathlib.CategoryTheory.Limits.Shapes.Pullbacks import Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Pullbacks #align_import category_theory.limits.constructions.epi_mono from "leanprover-community/mathlib"@"f7baecbb54bd0f24f228576f97b1752fc3c9b318" /-! # Relating monomorphisms and epimorphisms to limits and colimits If `F` preserves (resp. reflects) pullbacks, then it preserves (resp. reflects) monomorphisms. We also provide the dual version for epimorphisms. -/ universe v₁ v₂ u₁ u₂ namespace CategoryTheory open Category Limits variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D] variable (F : C ⥤ D) /-- If `F` preserves pullbacks, then it preserves monomorphisms. -/ theorem preserves_mono_of_preservesLimit {X Y : C} (f : X ⟶ Y) [PreservesLimit (cospan f f) F] [Mono f] : Mono (F.map f) := by have := isLimitPullbackConeMapOfIsLimit F _ (PullbackCone.isLimitMkIdId f) simp_rw [F.map_id] at this apply PullbackCone.mono_of_isLimitMkIdId _ this #align category_theory.preserves_mono_of_preserves_limit CategoryTheory.preserves_mono_of_preservesLimit instance (priority := 100) preservesMonomorphisms_of_preservesLimitsOfShape [PreservesLimitsOfShape WalkingCospan F] : F.PreservesMonomorphisms where preserves f _ := preserves_mono_of_preservesLimit F f #align category_theory.preserves_monomorphisms_of_preserves_limits_of_shape CategoryTheory.preservesMonomorphisms_of_preservesLimitsOfShape /-- If `F` reflects pullbacks, then it reflects monomorphisms. -/ theorem reflects_mono_of_reflectsLimit {X Y : C} (f : X ⟶ Y) [ReflectsLimit (cospan f f) F] [Mono (F.map f)] : Mono f := by have := PullbackCone.isLimitMkIdId (F.map f) simp_rw [← F.map_id] at this apply PullbackCone.mono_of_isLimitMkIdId _ (isLimitOfIsLimitPullbackConeMap F _ this) #align category_theory.reflects_mono_of_reflects_limit CategoryTheory.reflects_mono_of_reflectsLimit instance (priority := 100) reflectsMonomorphisms_of_reflectsLimitsOfShape [ReflectsLimitsOfShape WalkingCospan F] : F.ReflectsMonomorphisms where reflects f _ := reflects_mono_of_reflectsLimit F f #align category_theory.reflects_monomorphisms_of_reflects_limits_of_shape CategoryTheory.reflectsMonomorphisms_of_reflectsLimitsOfShape /-- If `F` preserves pushouts, then it preserves epimorphisms. -/
Mathlib/CategoryTheory/Limits/Constructions/EpiMono.lean
58
62
theorem preserves_epi_of_preservesColimit {X Y : C} (f : X ⟶ Y) [PreservesColimit (span f f) F] [Epi f] : Epi (F.map f) := by
have := isColimitPushoutCoconeMapOfIsColimit F _ (PushoutCocone.isColimitMkIdId f) simp_rw [F.map_id] at this apply PushoutCocone.epi_of_isColimitMkIdId _ this
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro -/ import Mathlib.Data.Int.Interval import Mathlib.Data.Int.SuccPred import Mathlib.Data.Int.ConditionallyCompleteOrder import Mathlib.Topology.Instances.Discrete import Mathlib.Topology.MetricSpace.Bounded import Mathlib.Order.Filter.Archimedean #align_import topology.instances.int from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Topology on the integers The structure of a metric space on `ℤ` is introduced in this file, induced from `ℝ`. -/ noncomputable section open Metric Set Filter namespace Int instance : Dist ℤ := ⟨fun x y => dist (x : ℝ) y⟩ theorem dist_eq (x y : ℤ) : dist x y = |(x : ℝ) - y| := rfl #align int.dist_eq Int.dist_eq theorem dist_eq' (m n : ℤ) : dist m n = |m - n| := by rw [dist_eq]; norm_cast @[norm_cast, simp] theorem dist_cast_real (x y : ℤ) : dist (x : ℝ) y = dist x y := rfl #align int.dist_cast_real Int.dist_cast_real theorem pairwise_one_le_dist : Pairwise fun m n : ℤ => 1 ≤ dist m n := by intro m n hne rw [dist_eq]; norm_cast; rwa [← zero_add (1 : ℤ), Int.add_one_le_iff, abs_pos, sub_ne_zero] #align int.pairwise_one_le_dist Int.pairwise_one_le_dist theorem uniformEmbedding_coe_real : UniformEmbedding ((↑) : ℤ → ℝ) := uniformEmbedding_bot_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist #align int.uniform_embedding_coe_real Int.uniformEmbedding_coe_real theorem closedEmbedding_coe_real : ClosedEmbedding ((↑) : ℤ → ℝ) := closedEmbedding_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist #align int.closed_embedding_coe_real Int.closedEmbedding_coe_real instance : MetricSpace ℤ := Int.uniformEmbedding_coe_real.comapMetricSpace _ theorem preimage_ball (x : ℤ) (r : ℝ) : (↑) ⁻¹' ball (x : ℝ) r = ball x r := rfl #align int.preimage_ball Int.preimage_ball theorem preimage_closedBall (x : ℤ) (r : ℝ) : (↑) ⁻¹' closedBall (x : ℝ) r = closedBall x r := rfl #align int.preimage_closed_ball Int.preimage_closedBall theorem ball_eq_Ioo (x : ℤ) (r : ℝ) : ball x r = Ioo ⌊↑x - r⌋ ⌈↑x + r⌉ := by rw [← preimage_ball, Real.ball_eq_Ioo, preimage_Ioo] #align int.ball_eq_Ioo Int.ball_eq_Ioo theorem closedBall_eq_Icc (x : ℤ) (r : ℝ) : closedBall x r = Icc ⌈↑x - r⌉ ⌊↑x + r⌋ := by rw [← preimage_closedBall, Real.closedBall_eq_Icc, preimage_Icc] #align int.closed_ball_eq_Icc Int.closedBall_eq_Icc instance : ProperSpace ℤ := ⟨fun x r => by rw [closedBall_eq_Icc] exact (Set.finite_Icc _ _).isCompact⟩ @[simp] theorem cobounded_eq : Bornology.cobounded ℤ = atBot ⊔ atTop := by simp_rw [← comap_dist_right_atTop (0 : ℤ), dist_eq', sub_zero, ← comap_abs_atTop, ← @Int.comap_cast_atTop ℝ, comap_comap]; rfl @[deprecated (since := "2024-02-07")] alias cocompact_eq := cocompact_eq_atBot_atTop #align int.cocompact_eq Int.cocompact_eq @[simp]
Mathlib/Topology/Instances/Int.lean
84
85
theorem cofinite_eq : (cofinite : Filter ℤ) = atBot ⊔ atTop := by
rw [← cocompact_eq_cofinite, cocompact_eq_atBot_atTop]
/- Copyright (c) 2022 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.AlgebraicTopology.DoldKan.PInfty #align_import algebraic_topology.dold_kan.decomposition from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504" /-! # Decomposition of the Q endomorphisms In this file, we obtain a lemma `decomposition_Q` which expresses explicitly the projection `(Q q).f (n+1) : X _[n+1] ⟶ X _[n+1]` (`X : SimplicialObject C` with `C` a preadditive category) as a sum of terms which are postcompositions with degeneracies. (TODO @joelriou: when `C` is abelian, define the degenerate subcomplex of the alternating face map complex of `X` and show that it is a complement to the normalized Moore complex.) Then, we introduce an ad hoc structure `MorphComponents X n Z` which can be used in order to define morphisms `X _[n+1] ⟶ Z` using the decomposition provided by `decomposition_Q`. This shall play a critical role in the proof that the functor `N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ))` reflects isomorphisms. (See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.) -/ open CategoryTheory CategoryTheory.Category CategoryTheory.Preadditive Opposite Simplicial noncomputable section namespace AlgebraicTopology namespace DoldKan variable {C : Type*} [Category C] [Preadditive C] {X X' : SimplicialObject C} /-- In each positive degree, this lemma decomposes the idempotent endomorphism `Q q` as a sum of morphisms which are postcompositions with suitable degeneracies. As `Q q` is the complement projection to `P q`, this implies that in the case of simplicial abelian groups, any $(n+1)$-simplex $x$ can be decomposed as $x = x' + \sum (i=0}^{q-1} σ_{n-i}(y_i)$ where $x'$ is in the image of `P q` and the $y_i$ are in degree $n$. -/ theorem decomposition_Q (n q : ℕ) : ((Q q).f (n + 1) : X _[n + 1] ⟶ X _[n + 1]) = ∑ i ∈ Finset.filter (fun i : Fin (n + 1) => (i : ℕ) < q) Finset.univ, (P i).f (n + 1) ≫ X.δ i.rev.succ ≫ X.σ (Fin.rev i) := by induction' q with q hq · simp only [Nat.zero_eq, Q_zero, HomologicalComplex.zero_f_apply, Nat.not_lt_zero, Finset.filter_False, Finset.sum_empty] · by_cases hqn : q + 1 ≤ n + 1 swap · rw [Q_is_eventually_constant (show n + 1 ≤ q by omega), hq] congr 1 ext ⟨x, hx⟩ simp only [Nat.succ_eq_add_one, Finset.mem_filter, Finset.mem_univ, true_and] omega · cases' Nat.le.dest (Nat.succ_le_succ_iff.mp hqn) with a ha rw [Q_succ, HomologicalComplex.sub_f_apply, HomologicalComplex.comp_f, hq] symm conv_rhs => rw [sub_eq_add_neg, add_comm] let q' : Fin (n + 1) := ⟨q, Nat.succ_le_iff.mp hqn⟩ rw [← @Finset.add_sum_erase _ _ _ _ _ _ q' (by simp)] congr · have hnaq' : n = a + q := by omega simp only [Fin.val_mk, (HigherFacesVanish.of_P q n).comp_Hσ_eq hnaq', q'.rev_eq hnaq', neg_neg] rfl · ext ⟨i, hi⟩ simp only [q', Nat.succ_eq_add_one, Nat.lt_succ_iff_lt_or_eq, Finset.mem_univ, forall_true_left, Finset.mem_filter, lt_self_iff_false, or_true, and_self, not_true, Finset.mem_erase, ne_eq, Fin.mk.injEq, true_and] aesop set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.decomposition_Q AlgebraicTopology.DoldKan.decomposition_Q variable (X) -- porting note (#5171): removed @[nolint has_nonempty_instance] /-- The structure `MorphComponents` is an ad hoc structure that is used in the proof that `N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ))` reflects isomorphisms. The fields are the data that are needed in order to construct a morphism `X _[n+1] ⟶ Z` (see `φ`) using the decomposition of the identity given by `decomposition_Q n (n+1)`. -/ @[ext] structure MorphComponents (n : ℕ) (Z : C) where a : X _[n + 1] ⟶ Z b : Fin (n + 1) → (X _[n] ⟶ Z) #align algebraic_topology.dold_kan.morph_components AlgebraicTopology.DoldKan.MorphComponents namespace MorphComponents variable {X} {n : ℕ} {Z Z' : C} (f : MorphComponents X n Z) (g : X' ⟶ X) (h : Z ⟶ Z') /-- The morphism `X _[n+1] ⟶ Z` associated to `f : MorphComponents X n Z`. -/ def φ {Z : C} (f : MorphComponents X n Z) : X _[n + 1] ⟶ Z := PInfty.f (n + 1) ≫ f.a + ∑ i : Fin (n + 1), (P i).f (n + 1) ≫ X.δ i.rev.succ ≫ f.b (Fin.rev i) #align algebraic_topology.dold_kan.morph_components.φ AlgebraicTopology.DoldKan.MorphComponents.φ variable (X n) /-- the canonical `MorphComponents` whose associated morphism is the identity (see `F_id`) thanks to `decomposition_Q n (n+1)` -/ @[simps] def id : MorphComponents X n (X _[n + 1]) where a := PInfty.f (n + 1) b i := X.σ i #align algebraic_topology.dold_kan.morph_components.id AlgebraicTopology.DoldKan.MorphComponents.id @[simp]
Mathlib/AlgebraicTopology/DoldKan/Decomposition.lean
120
124
theorem id_φ : (id X n).φ = 𝟙 _ := by
simp only [← P_add_Q_f (n + 1) (n + 1), φ] congr 1 · simp only [id, PInfty_f, P_f_idem] · exact Eq.trans (by congr; simp) (decomposition_Q n (n + 1)).symm
/- Copyright (c) 2023 Jon Eugster. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson, Boris Bolvig Kjær, Jon Eugster, Sina Hazratpour, Nima Rasekh -/ import Mathlib.CategoryTheory.Sites.Coherent.ReflectsPreregular import Mathlib.Topology.Category.CompHaus.EffectiveEpi import Mathlib.Topology.Category.Stonean.Limits import Mathlib.Topology.Category.CompHaus.EffectiveEpi /-! # Effective epimorphic families in `Stonean` This file proves that `Stonean` is `Preregular`. Together with the fact that it is `FinitaryPreExtensive`, this implies that `Stonean` is `Precoherent`. To do this, we need to characterise effective epimorphisms in `Stonean`. As a consequence, we also get a characterisation of finite effective epimorphic families. ## Main results * `Stonean.effectiveEpi_tfae`: For a morphism in `Stonean`, the conditions surjective, epimorphic, and effective epimorphic are all equivalent. * `Stonean.effectiveEpiFamily_tfae`: For a finite family of morphisms in `Stonean` with fixed target in `Stonean`, the conditions jointly surjective, jointly epimorphic and effective epimorphic are all equivalent. As a consequence, we obtain instances that `Stonean` is precoherent and preregular. -/ universe u open CategoryTheory Limits namespace Stonean /-- Implementation: If `π` is a surjective morphism in `Stonean`, then it is an effective epi. The theorem `Stonean.effectiveEpi_tfae` should be used instead. -/ noncomputable def struct {B X : Stonean.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) : EffectiveEpiStruct π where desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦ DFunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩ (by ext; exact hab)) a fac e h := ((QuotientMap.of_surjective_continuous hπ π.continuous).lift_comp e fun a b hab ↦ DFunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩ (by ext; exact hab)) a) uniq e h g hm := by suffices g = (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv ⟨e, fun a b hab ↦ DFunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩ (by ext; exact hab)) a⟩ by assumption rw [← Equiv.symm_apply_eq (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv] ext simp only [QuotientMap.liftEquiv_symm_apply_coe, ContinuousMap.comp_apply, ← hm] rfl open List in theorem effectiveEpi_tfae {B X : Stonean.{u}} (π : X ⟶ B) : TFAE [ EffectiveEpi π , Epi π , Function.Surjective π ] := by tfae_have 1 → 2 · intro; infer_instance tfae_have 2 ↔ 3 · exact epi_iff_surjective π tfae_have 3 → 1 · exact fun hπ ↦ ⟨⟨struct π hπ⟩⟩ tfae_finish instance : Stonean.toCompHaus.PreservesEffectiveEpis where preserves f h := ((CompHaus.effectiveEpi_tfae f).out 0 2).mpr (((Stonean.effectiveEpi_tfae f).out 0 2).mp h) instance : Stonean.toCompHaus.ReflectsEffectiveEpis where reflects f h := ((Stonean.effectiveEpi_tfae f).out 0 2).mpr (((CompHaus.effectiveEpi_tfae f).out 0 2).mp h) /-- An effective presentation of an `X : CompHaus` with respect to the inclusion functor from `Stonean` -/ noncomputable def stoneanToCompHausEffectivePresentation (X : CompHaus) : Stonean.toCompHaus.EffectivePresentation X where p := X.presentation f := CompHaus.presentation.π X effectiveEpi := ((CompHaus.effectiveEpi_tfae _).out 0 1).mpr (inferInstance : Epi _) instance : Stonean.toCompHaus.EffectivelyEnough where presentation X := ⟨stoneanToCompHausEffectivePresentation X⟩ instance : Preregular Stonean := Stonean.toCompHaus.reflects_preregular example : Precoherent Stonean.{u} := inferInstance -- TODO: prove this for `Type*` open List in
Mathlib/Topology/Category/Stonean/EffectiveEpi.lean
103
121
theorem effectiveEpiFamily_tfae {α : Type} [Finite α] {B : Stonean.{u}} (X : α → Stonean.{u}) (π : (a : α) → (X a ⟶ B)) : TFAE [ EffectiveEpiFamily X π , Epi (Sigma.desc π) , ∀ b : B, ∃ (a : α) (x : X a), π a x = b ] := by
tfae_have 2 → 1 · intro simpa [← effectiveEpi_desc_iff_effectiveEpiFamily, (effectiveEpi_tfae (Sigma.desc π)).out 0 1] tfae_have 1 → 2 · intro; infer_instance tfae_have 3 ↔ 1 · erw [((CompHaus.effectiveEpiFamily_tfae (fun a ↦ Stonean.toCompHaus.obj (X a)) (fun a ↦ Stonean.toCompHaus.map (π a))).out 2 0 : )] exact ⟨fun h ↦ Stonean.toCompHaus.finite_effectiveEpiFamily_of_map _ _ h, fun _ ↦ inferInstance⟩ tfae_finish
/- Copyright (c) 2022 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.Probability.Variance #align_import probability.moments from "leanprover-community/mathlib"@"85453a2a14be8da64caf15ca50930cf4c6e5d8de" /-! # Moments and moment generating function ## Main definitions * `ProbabilityTheory.moment X p μ`: `p`th moment of a real random variable `X` with respect to measure `μ`, `μ[X^p]` * `ProbabilityTheory.centralMoment X p μ`:`p`th central moment of `X` with respect to measure `μ`, `μ[(X - μ[X])^p]` * `ProbabilityTheory.mgf X μ t`: moment generating function of `X` with respect to measure `μ`, `μ[exp(t*X)]` * `ProbabilityTheory.cgf X μ t`: cumulant generating function, logarithm of the moment generating function ## Main results * `ProbabilityTheory.IndepFun.mgf_add`: if two real random variables `X` and `Y` are independent and their mgfs are defined at `t`, then `mgf (X + Y) μ t = mgf X μ t * mgf Y μ t` * `ProbabilityTheory.IndepFun.cgf_add`: if two real random variables `X` and `Y` are independent and their cgfs are defined at `t`, then `cgf (X + Y) μ t = cgf X μ t + cgf Y μ t` * `ProbabilityTheory.measure_ge_le_exp_cgf` and `ProbabilityTheory.measure_le_le_exp_cgf`: Chernoff bound on the upper (resp. lower) tail of a random variable. For `t` nonnegative such that the cgf exists, `ℙ(ε ≤ X) ≤ exp(- t*ε + cgf X ℙ t)`. See also `ProbabilityTheory.measure_ge_le_exp_mul_mgf` and `ProbabilityTheory.measure_le_le_exp_mul_mgf` for versions of these results using `mgf` instead of `cgf`. -/ open MeasureTheory Filter Finset Real noncomputable section open scoped MeasureTheory ProbabilityTheory ENNReal NNReal namespace ProbabilityTheory variable {Ω ι : Type*} {m : MeasurableSpace Ω} {X : Ω → ℝ} {p : ℕ} {μ : Measure Ω} /-- Moment of a real random variable, `μ[X ^ p]`. -/ def moment (X : Ω → ℝ) (p : ℕ) (μ : Measure Ω) : ℝ := μ[X ^ p] #align probability_theory.moment ProbabilityTheory.moment /-- Central moment of a real random variable, `μ[(X - μ[X]) ^ p]`. -/ def centralMoment (X : Ω → ℝ) (p : ℕ) (μ : Measure Ω) : ℝ := by have m := fun (x : Ω) => μ[X] -- Porting note: Lean deems `μ[(X - fun x => μ[X]) ^ p]` ambiguous exact μ[(X - m) ^ p] #align probability_theory.central_moment ProbabilityTheory.centralMoment @[simp] theorem moment_zero (hp : p ≠ 0) : moment 0 p μ = 0 := by simp only [moment, hp, zero_pow, Ne, not_false_iff, Pi.zero_apply, integral_const, smul_eq_mul, mul_zero, integral_zero] #align probability_theory.moment_zero ProbabilityTheory.moment_zero @[simp] theorem centralMoment_zero (hp : p ≠ 0) : centralMoment 0 p μ = 0 := by simp only [centralMoment, hp, Pi.zero_apply, integral_const, smul_eq_mul, mul_zero, zero_sub, Pi.pow_apply, Pi.neg_apply, neg_zero, zero_pow, Ne, not_false_iff] #align probability_theory.central_moment_zero ProbabilityTheory.centralMoment_zero
Mathlib/Probability/Moments.lean
73
77
theorem centralMoment_one' [IsFiniteMeasure μ] (h_int : Integrable X μ) : centralMoment X 1 μ = (1 - (μ Set.univ).toReal) * μ[X] := by
simp only [centralMoment, Pi.sub_apply, pow_one] rw [integral_sub h_int (integrable_const _)] simp only [sub_mul, integral_const, smul_eq_mul, one_mul]
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Shing Tak Lam, Mario Carneiro -/ import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Algebra.BigOperators.Ring.List import Mathlib.Data.Int.ModEq import Mathlib.Data.Nat.Bits import Mathlib.Data.Nat.Log import Mathlib.Data.List.Indexes import Mathlib.Data.List.Palindrome import Mathlib.Tactic.IntervalCases import Mathlib.Tactic.Linarith import Mathlib.Tactic.Ring #align_import data.nat.digits from "leanprover-community/mathlib"@"369525b73f229ccd76a6ec0e0e0bf2be57599768" /-! # Digits of a natural number This provides a basic API for extracting the digits of a natural number in a given base, and reconstructing numbers from their digits. We also prove some divisibility tests based on digits, in particular completing Theorem #85 from https://www.cs.ru.nl/~freek/100/. Also included is a bound on the length of `Nat.toDigits` from core. ## TODO A basic `norm_digits` tactic for proving goals of the form `Nat.digits a b = l` where `a` and `b` are numerals is not yet ported. -/ namespace Nat variable {n : ℕ} /-- (Impl.) An auxiliary definition for `digits`, to help get the desired definitional unfolding. -/ def digitsAux0 : ℕ → List ℕ | 0 => [] | n + 1 => [n + 1] #align nat.digits_aux_0 Nat.digitsAux0 /-- (Impl.) An auxiliary definition for `digits`, to help get the desired definitional unfolding. -/ def digitsAux1 (n : ℕ) : List ℕ := List.replicate n 1 #align nat.digits_aux_1 Nat.digitsAux1 /-- (Impl.) An auxiliary definition for `digits`, to help get the desired definitional unfolding. -/ def digitsAux (b : ℕ) (h : 2 ≤ b) : ℕ → List ℕ | 0 => [] | n + 1 => ((n + 1) % b) :: digitsAux b h ((n + 1) / b) decreasing_by exact Nat.div_lt_self (Nat.succ_pos _) h #align nat.digits_aux Nat.digitsAux @[simp] theorem digitsAux_zero (b : ℕ) (h : 2 ≤ b) : digitsAux b h 0 = [] := by rw [digitsAux] #align nat.digits_aux_zero Nat.digitsAux_zero
Mathlib/Data/Nat/Digits.lean
63
67
theorem digitsAux_def (b : ℕ) (h : 2 ≤ b) (n : ℕ) (w : 0 < n) : digitsAux b h n = (n % b) :: digitsAux b h (n / b) := by
cases n · cases w · rw [digitsAux]
/- Copyright (c) 2020 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import Mathlib.Data.Finset.Fold import Mathlib.Algebra.GCDMonoid.Multiset #align_import algebra.gcd_monoid.finset from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" #align_import algebra.gcd_monoid.div from "leanprover-community/mathlib"@"b537794f8409bc9598febb79cd510b1df5f4539d" /-! # GCD and LCM operations on finsets ## Main definitions - `Finset.gcd` - the greatest common denominator of a `Finset` of elements of a `GCDMonoid` - `Finset.lcm` - the least common multiple of a `Finset` of elements of a `GCDMonoid` ## Implementation notes Many of the proofs use the lemmas `gcd_def` and `lcm_def`, which relate `Finset.gcd` and `Finset.lcm` to `Multiset.gcd` and `Multiset.lcm`. TODO: simplify with a tactic and `Data.Finset.Lattice` ## Tags finset, gcd -/ variable {ι α β γ : Type*} namespace Finset open Multiset variable [CancelCommMonoidWithZero α] [NormalizedGCDMonoid α] /-! ### lcm -/ section lcm /-- Least common multiple of a finite set -/ def lcm (s : Finset β) (f : β → α) : α := s.fold GCDMonoid.lcm 1 f #align finset.lcm Finset.lcm variable {s s₁ s₂ : Finset β} {f : β → α} theorem lcm_def : s.lcm f = (s.1.map f).lcm := rfl #align finset.lcm_def Finset.lcm_def @[simp] theorem lcm_empty : (∅ : Finset β).lcm f = 1 := fold_empty #align finset.lcm_empty Finset.lcm_empty @[simp] theorem lcm_dvd_iff {a : α} : s.lcm f ∣ a ↔ ∀ b ∈ s, f b ∣ a := by apply Iff.trans Multiset.lcm_dvd simp only [Multiset.mem_map, and_imp, exists_imp] exact ⟨fun k b hb ↦ k _ _ hb rfl, fun k a' b hb h ↦ h ▸ k _ hb⟩ #align finset.lcm_dvd_iff Finset.lcm_dvd_iff theorem lcm_dvd {a : α} : (∀ b ∈ s, f b ∣ a) → s.lcm f ∣ a := lcm_dvd_iff.2 #align finset.lcm_dvd Finset.lcm_dvd theorem dvd_lcm {b : β} (hb : b ∈ s) : f b ∣ s.lcm f := lcm_dvd_iff.1 dvd_rfl _ hb #align finset.dvd_lcm Finset.dvd_lcm @[simp] theorem lcm_insert [DecidableEq β] {b : β} : (insert b s : Finset β).lcm f = GCDMonoid.lcm (f b) (s.lcm f) := by by_cases h : b ∈ s · rw [insert_eq_of_mem h, (lcm_eq_right_iff (f b) (s.lcm f) (Multiset.normalize_lcm (s.1.map f))).2 (dvd_lcm h)] apply fold_insert h #align finset.lcm_insert Finset.lcm_insert @[simp] theorem lcm_singleton {b : β} : ({b} : Finset β).lcm f = normalize (f b) := Multiset.lcm_singleton #align finset.lcm_singleton Finset.lcm_singleton -- Porting note: Priority changed for `simpNF` @[simp 1100] theorem normalize_lcm : normalize (s.lcm f) = s.lcm f := by simp [lcm_def] #align finset.normalize_lcm Finset.normalize_lcm theorem lcm_union [DecidableEq β] : (s₁ ∪ s₂).lcm f = GCDMonoid.lcm (s₁.lcm f) (s₂.lcm f) := Finset.induction_on s₁ (by rw [empty_union, lcm_empty, lcm_one_left, normalize_lcm]) fun a s _ ih ↦ by rw [insert_union, lcm_insert, lcm_insert, ih, lcm_assoc] #align finset.lcm_union Finset.lcm_union
Mathlib/Algebra/GCDMonoid/Finset.lean
100
103
theorem lcm_congr {f g : β → α} (hs : s₁ = s₂) (hfg : ∀ a ∈ s₂, f a = g a) : s₁.lcm f = s₂.lcm g := by
subst hs exact Finset.fold_congr hfg
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Data.Set.Pointwise.Basic #align_import data.set.pointwise.big_operators from "leanprover-community/mathlib"@"fa2cb8a9e2b987db233e4e6eb47645feafba8861" /-! # Results about pointwise operations on sets and big operators. -/ namespace Set open Pointwise Function variable {ι α β F : Type*} [FunLike F α β] section Monoid variable [Monoid α] [Monoid β] [MonoidHomClass F α β] @[to_additive] theorem image_list_prod (f : F) : ∀ l : List (Set α), (f : α → β) '' l.prod = (l.map fun s => f '' s).prod | [] => image_one.trans <| congr_arg singleton (map_one f) | a :: as => by rw [List.map_cons, List.prod_cons, List.prod_cons, image_mul, image_list_prod _ _] #align set.image_list_prod Set.image_list_prod #align set.image_list_sum Set.image_list_sum end Monoid section CommMonoid variable [CommMonoid α] [CommMonoid β] [MonoidHomClass F α β] @[to_additive] theorem image_multiset_prod (f : F) : ∀ m : Multiset (Set α), (f : α → β) '' m.prod = (m.map fun s => f '' s).prod := Quotient.ind <| by simpa only [Multiset.quot_mk_to_coe, Multiset.prod_coe, Multiset.map_coe] using image_list_prod f #align set.image_multiset_prod Set.image_multiset_prod #align set.image_multiset_sum Set.image_multiset_sum @[to_additive] theorem image_finset_prod (f : F) (m : Finset ι) (s : ι → Set α) : ((f : α → β) '' ∏ i ∈ m, s i) = ∏ i ∈ m, f '' s i := (image_multiset_prod f _).trans <| congr_arg Multiset.prod <| Multiset.map_map _ _ _ #align set.image_finset_prod Set.image_finset_prod #align set.image_finset_sum Set.image_finset_sum /-- The n-ary version of `Set.mem_mul`. -/ @[to_additive " The n-ary version of `Set.mem_add`. "] theorem mem_finset_prod (t : Finset ι) (f : ι → Set α) (a : α) : (a ∈ ∏ i ∈ t, f i) ↔ ∃ (g : ι → α) (_ : ∀ {i}, i ∈ t → g i ∈ f i), ∏ i ∈ t, g i = a := by classical induction' t using Finset.induction_on with i is hi ih generalizing a · simp_rw [Finset.prod_empty, Set.mem_one] exact ⟨fun h ↦ ⟨fun _ ↦ a, fun hi ↦ False.elim (Finset.not_mem_empty _ hi), h.symm⟩, fun ⟨_, _, hf⟩ ↦ hf.symm⟩ rw [Finset.prod_insert hi, Set.mem_mul] simp_rw [Finset.prod_insert hi] simp_rw [ih] constructor · rintro ⟨x, y, hx, ⟨g, hg, rfl⟩, rfl⟩ refine ⟨Function.update g i x, ?_, ?_⟩ · intro j hj obtain rfl | hj := Finset.mem_insert.mp hj · rwa [Function.update_same] · rw [update_noteq (ne_of_mem_of_not_mem hj hi)] exact hg hj · rw [Finset.prod_update_of_not_mem hi, Function.update_same] · rintro ⟨g, hg, rfl⟩ exact ⟨g i, hg (is.mem_insert_self _), is.prod g, ⟨⟨g, fun hi ↦ hg (Finset.mem_insert_of_mem hi), rfl⟩, rfl⟩⟩ #align set.mem_finset_prod Set.mem_finset_prod #align set.mem_finset_sum Set.mem_finset_sum /-- A version of `Set.mem_finset_prod` with a simpler RHS for products over a Fintype. -/ @[to_additive " A version of `Set.mem_finset_sum` with a simpler RHS for sums over a Fintype. "] theorem mem_fintype_prod [Fintype ι] (f : ι → Set α) (a : α) : (a ∈ ∏ i, f i) ↔ ∃ (g : ι → α) (_ : ∀ i, g i ∈ f i), ∏ i, g i = a := by rw [mem_finset_prod] simp #align set.mem_fintype_prod Set.mem_fintype_prod #align set.mem_fintype_sum Set.mem_fintype_sum /-- An n-ary version of `Set.mul_mem_mul`. -/ @[to_additive " An n-ary version of `Set.add_mem_add`. "]
Mathlib/Data/Set/Pointwise/BigOperators.lean
94
100
theorem list_prod_mem_list_prod (t : List ι) (f : ι → Set α) (g : ι → α) (hg : ∀ i ∈ t, g i ∈ f i) : (t.map g).prod ∈ (t.map f).prod := by
induction' t with h tl ih · simp_rw [List.map_nil, List.prod_nil, Set.mem_one] · simp_rw [List.map_cons, List.prod_cons] exact mul_mem_mul (hg h <| List.mem_cons_self _ _) (ih fun i hi ↦ hg i <| List.mem_cons_of_mem _ hi)
/- Copyright (c) 2019 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Bhavik Mehta -/ import Mathlib.CategoryTheory.Comma.StructuredArrow import Mathlib.CategoryTheory.PUnit import Mathlib.CategoryTheory.Functor.ReflectsIso import Mathlib.CategoryTheory.Functor.EpiMono #align_import category_theory.over from "leanprover-community/mathlib"@"8a318021995877a44630c898d0b2bc376fceef3b" /-! # Over and under categories Over (and under) categories are special cases of comma categories. * If `L` is the identity functor and `R` is a constant functor, then `Comma L R` is the "slice" or "over" category over the object `R` maps to. * Conversely, if `L` is a constant functor and `R` is the identity functor, then `Comma L R` is the "coslice" or "under" category under the object `L` maps to. ## Tags Comma, Slice, Coslice, Over, Under -/ namespace CategoryTheory universe v₁ v₂ u₁ u₂ -- morphism levels before object levels. See note [CategoryTheory universes]. variable {T : Type u₁} [Category.{v₁} T] /-- The over category has as objects arrows in `T` with codomain `X` and as morphisms commutative triangles. See <https://stacks.math.columbia.edu/tag/001G>. -/ def Over (X : T) := CostructuredArrow (𝟭 T) X #align category_theory.over CategoryTheory.Over instance (X : T) : Category (Over X) := commaCategory -- Satisfying the inhabited linter instance Over.inhabited [Inhabited T] : Inhabited (Over (default : T)) where default := { left := default right := default hom := 𝟙 _ } #align category_theory.over.inhabited CategoryTheory.Over.inhabited namespace Over variable {X : T} @[ext]
Mathlib/CategoryTheory/Comma/Over.lean
59
63
theorem OverMorphism.ext {X : T} {U V : Over X} {f g : U ⟶ V} (h : f.left = g.left) : f = g := by
let ⟨_,b,_⟩ := f let ⟨_,e,_⟩ := g congr simp only [eq_iff_true_of_subsingleton]
/- Copyright (c) 2022 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation #align_import linear_algebra.clifford_algebra.fold from "leanprover-community/mathlib"@"446eb51ce0a90f8385f260d2b52e760e2004246b" /-! # Recursive computation rules for the Clifford algebra This file provides API for a special case `CliffordAlgebra.foldr` of the universal property `CliffordAlgebra.lift` with `A = Module.End R N` for some arbitrary module `N`. This specialization resembles the `list.foldr` operation, allowing a bilinear map to be "folded" along the generators. For convenience, this file also provides `CliffordAlgebra.foldl`, implemented via `CliffordAlgebra.reverse` ## Main definitions * `CliffordAlgebra.foldr`: a computation rule for building linear maps out of the clifford algebra starting on the right, analogous to using `list.foldr` on the generators. * `CliffordAlgebra.foldl`: a computation rule for building linear maps out of the clifford algebra starting on the left, analogous to using `list.foldl` on the generators. ## Main statements * `CliffordAlgebra.right_induction`: an induction rule that adds generators from the right. * `CliffordAlgebra.left_induction`: an induction rule that adds generators from the left. -/ universe u1 u2 u3 variable {R M N : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] variable [Module R M] [Module R N] variable (Q : QuadraticForm R M) namespace CliffordAlgebra section Foldr /-- Fold a bilinear map along the generators of a term of the clifford algebra, with the rule given by `foldr Q f hf n (ι Q m * x) = f m (foldr Q f hf n x)`. For example, `foldr f hf n (r • ι R u + ι R v * ι R w) = r • f u n + f v (f w n)`. -/ def foldr (f : M →ₗ[R] N →ₗ[R] N) (hf : ∀ m x, f m (f m x) = Q m • x) : N →ₗ[R] CliffordAlgebra Q →ₗ[R] N := (CliffordAlgebra.lift Q ⟨f, fun v => LinearMap.ext <| hf v⟩).toLinearMap.flip #align clifford_algebra.foldr CliffordAlgebra.foldr @[simp] theorem foldr_ι (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (m : M) : foldr Q f hf n (ι Q m) = f m n := LinearMap.congr_fun (lift_ι_apply _ _ _) n #align clifford_algebra.foldr_ι CliffordAlgebra.foldr_ι @[simp] theorem foldr_algebraMap (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (r : R) : foldr Q f hf n (algebraMap R _ r) = r • n := LinearMap.congr_fun (AlgHom.commutes _ r) n #align clifford_algebra.foldr_algebra_map CliffordAlgebra.foldr_algebraMap @[simp] theorem foldr_one (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) : foldr Q f hf n 1 = n := LinearMap.congr_fun (AlgHom.map_one _) n #align clifford_algebra.foldr_one CliffordAlgebra.foldr_one @[simp] theorem foldr_mul (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (a b : CliffordAlgebra Q) : foldr Q f hf n (a * b) = foldr Q f hf (foldr Q f hf n b) a := LinearMap.congr_fun (AlgHom.map_mul _ _ _) n #align clifford_algebra.foldr_mul CliffordAlgebra.foldr_mul /-- This lemma demonstrates the origin of the `foldr` name. -/ theorem foldr_prod_map_ι (l : List M) (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) : foldr Q f hf n (l.map <| ι Q).prod = List.foldr (fun m n => f m n) n l := by induction' l with hd tl ih · rw [List.map_nil, List.prod_nil, List.foldr_nil, foldr_one] · rw [List.map_cons, List.prod_cons, List.foldr_cons, foldr_mul, foldr_ι, ih] #align clifford_algebra.foldr_prod_map_ι CliffordAlgebra.foldr_prod_map_ι end Foldr section Foldl /-- Fold a bilinear map along the generators of a term of the clifford algebra, with the rule given by `foldl Q f hf n (ι Q m * x) = f m (foldl Q f hf n x)`. For example, `foldl f hf n (r • ι R u + ι R v * ι R w) = r • f u n + f v (f w n)`. -/ def foldl (f : M →ₗ[R] N →ₗ[R] N) (hf : ∀ m x, f m (f m x) = Q m • x) : N →ₗ[R] CliffordAlgebra Q →ₗ[R] N := LinearMap.compl₂ (foldr Q f hf) reverse #align clifford_algebra.foldl CliffordAlgebra.foldl @[simp] theorem foldl_reverse (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (x : CliffordAlgebra Q) : foldl Q f hf n (reverse x) = foldr Q f hf n x := DFunLike.congr_arg (foldr Q f hf n) <| reverse_reverse _ #align clifford_algebra.foldl_reverse CliffordAlgebra.foldl_reverse @[simp] theorem foldr_reverse (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (x : CliffordAlgebra Q) : foldr Q f hf n (reverse x) = foldl Q f hf n x := rfl #align clifford_algebra.foldr_reverse CliffordAlgebra.foldr_reverse @[simp]
Mathlib/LinearAlgebra/CliffordAlgebra/Fold.lean
110
111
theorem foldl_ι (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (m : M) : foldl Q f hf n (ι Q m) = f m n := by
rw [← foldr_reverse, reverse_ι, foldr_ι]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Floris van Doorn, Sébastien Gouëzel, Alex J. Best -/ import Mathlib.Algebra.Divisibility.Basic import Mathlib.Algebra.Group.Int import Mathlib.Algebra.Group.Nat import Mathlib.Algebra.Group.Opposite import Mathlib.Algebra.Group.Units import Mathlib.Data.List.Perm import Mathlib.Data.List.ProdSigma import Mathlib.Data.List.Range import Mathlib.Data.List.Rotate #align_import data.list.big_operators.basic from "leanprover-community/mathlib"@"6c5f73fd6f6cc83122788a80a27cdd54663609f4" /-! # Sums and products from lists This file provides basic results about `List.prod`, `List.sum`, which calculate the product and sum of elements of a list and `List.alternatingProd`, `List.alternatingSum`, their alternating counterparts. -/ -- Make sure we haven't imported `Data.Nat.Order.Basic` assert_not_exists OrderedSub assert_not_exists Ring variable {ι α β M N P G : Type*} namespace List section Defs /-- Product of a list. `List.prod [a, b, c] = ((1 * a) * b) * c` -/ @[to_additive "Sum of a list.\n\n`List.sum [a, b, c] = ((0 + a) + b) + c`"] def prod {α} [Mul α] [One α] : List α → α := foldl (· * ·) 1 #align list.prod List.prod #align list.sum List.sum /-- The alternating sum of a list. -/ def alternatingSum {G : Type*} [Zero G] [Add G] [Neg G] : List G → G | [] => 0 | g :: [] => g | g :: h :: t => g + -h + alternatingSum t #align list.alternating_sum List.alternatingSum /-- The alternating product of a list. -/ @[to_additive existing] def alternatingProd {G : Type*} [One G] [Mul G] [Inv G] : List G → G | [] => 1 | g :: [] => g | g :: h :: t => g * h⁻¹ * alternatingProd t #align list.alternating_prod List.alternatingProd end Defs section MulOneClass variable [MulOneClass M] {l : List M} {a : M} @[to_additive (attr := simp)] theorem prod_nil : ([] : List M).prod = 1 := rfl #align list.prod_nil List.prod_nil #align list.sum_nil List.sum_nil @[to_additive] theorem prod_singleton : [a].prod = a := one_mul a #align list.prod_singleton List.prod_singleton #align list.sum_singleton List.sum_singleton @[to_additive (attr := simp)] theorem prod_one_cons : (1 :: l).prod = l.prod := by rw [prod, foldl, mul_one] @[to_additive] theorem prod_map_one {l : List ι} : (l.map fun _ => (1 : M)).prod = 1 := by induction l with | nil => rfl | cons hd tl ih => rw [map_cons, prod_one_cons, ih] end MulOneClass section Monoid variable [Monoid M] [Monoid N] [Monoid P] {l l₁ l₂ : List M} {a : M} @[to_additive (attr := simp)] theorem prod_cons : (a :: l).prod = a * l.prod := calc (a :: l).prod = foldl (· * ·) (a * 1) l := by simp only [List.prod, foldl_cons, one_mul, mul_one] _ = _ := foldl_assoc #align list.prod_cons List.prod_cons #align list.sum_cons List.sum_cons @[to_additive] lemma prod_induction (p : M → Prop) (hom : ∀ a b, p a → p b → p (a * b)) (unit : p 1) (base : ∀ x ∈ l, p x) : p l.prod := by induction' l with a l ih · simpa rw [List.prod_cons] simp only [Bool.not_eq_true, List.mem_cons, forall_eq_or_imp] at base exact hom _ _ (base.1) (ih base.2) @[to_additive (attr := simp)]
Mathlib/Algebra/BigOperators/Group/List.lean
114
117
theorem prod_append : (l₁ ++ l₂).prod = l₁.prod * l₂.prod := calc (l₁ ++ l₂).prod = foldl (· * ·) (foldl (· * ·) 1 l₁ * 1) l₂ := by
simp [List.prod] _ = l₁.prod * l₂.prod := foldl_assoc
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.Algebra.Category.Ring.Constructions import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Iso import Mathlib.RingTheory.Localization.Away.Basic import Mathlib.RingTheory.IsTensorProduct #align_import ring_theory.ring_hom_properties from "leanprover-community/mathlib"@"a7c017d750512a352b623b1824d75da5998457d0" /-! # Properties of ring homomorphisms We provide the basic framework for talking about properties of ring homomorphisms. The following meta-properties of predicates on ring homomorphisms are defined * `RingHom.RespectsIso`: `P` respects isomorphisms if `P f → P (e ≫ f)` and `P f → P (f ≫ e)`, where `e` is an isomorphism. * `RingHom.StableUnderComposition`: `P` is stable under composition if `P f → P g → P (f ≫ g)`. * `RingHom.StableUnderBaseChange`: `P` is stable under base change if `P (S ⟶ Y)` implies `P (X ⟶ X ⊗[S] Y)`. -/ universe u open CategoryTheory Opposite CategoryTheory.Limits namespace RingHom -- Porting Note: Deleted variable `f` here, since it wasn't used explicitly variable (P : ∀ {R S : Type u} [CommRing R] [CommRing S] (_ : R →+* S), Prop) section RespectsIso /-- A property `RespectsIso` if it still holds when composed with an isomorphism -/ def RespectsIso : Prop := (∀ {R S T : Type u} [CommRing R] [CommRing S] [CommRing T], ∀ (f : R →+* S) (e : S ≃+* T) (_ : P f), P (e.toRingHom.comp f)) ∧ ∀ {R S T : Type u} [CommRing R] [CommRing S] [CommRing T], ∀ (f : S →+* T) (e : R ≃+* S) (_ : P f), P (f.comp e.toRingHom) #align ring_hom.respects_iso RingHom.RespectsIso variable {P} theorem RespectsIso.cancel_left_isIso (hP : RespectsIso @P) {R S T : CommRingCat} (f : R ⟶ S) (g : S ⟶ T) [IsIso f] : P (f ≫ g) ↔ P g := ⟨fun H => by convert hP.2 (f ≫ g) (asIso f).symm.commRingCatIsoToRingEquiv H exact (IsIso.inv_hom_id_assoc _ _).symm, hP.2 g (asIso f).commRingCatIsoToRingEquiv⟩ #align ring_hom.respects_iso.cancel_left_is_iso RingHom.RespectsIso.cancel_left_isIso theorem RespectsIso.cancel_right_isIso (hP : RespectsIso @P) {R S T : CommRingCat} (f : R ⟶ S) (g : S ⟶ T) [IsIso g] : P (f ≫ g) ↔ P f := ⟨fun H => by convert hP.1 (f ≫ g) (asIso g).symm.commRingCatIsoToRingEquiv H change f = f ≫ g ≫ inv g simp, hP.1 f (asIso g).commRingCatIsoToRingEquiv⟩ #align ring_hom.respects_iso.cancel_right_is_iso RingHom.RespectsIso.cancel_right_isIso theorem RespectsIso.is_localization_away_iff (hP : RingHom.RespectsIso @P) {R S : Type u} (R' S' : Type u) [CommRing R] [CommRing S] [CommRing R'] [CommRing S'] [Algebra R R'] [Algebra S S'] (f : R →+* S) (r : R) [IsLocalization.Away r R'] [IsLocalization.Away (f r) S'] : P (Localization.awayMap f r) ↔ P (IsLocalization.Away.map R' S' f r) := by let e₁ : R' ≃+* Localization.Away r := (IsLocalization.algEquiv (Submonoid.powers r) _ _).toRingEquiv let e₂ : Localization.Away (f r) ≃+* S' := (IsLocalization.algEquiv (Submonoid.powers (f r)) _ _).toRingEquiv refine (hP.cancel_left_isIso e₁.toCommRingCatIso.hom (CommRingCat.ofHom _)).symm.trans ?_ refine (hP.cancel_right_isIso (CommRingCat.ofHom _) e₂.toCommRingCatIso.hom).symm.trans ?_ rw [← eq_iff_iff] congr 1 -- Porting note: Here, the proof used to have a huge `simp` involving `[anonymous]`, which didn't -- work out anymore. The issue seemed to be that it couldn't handle a term in which Ring -- homomorphisms were repeatedly casted to the bundled category and back. Here we resolve the -- problem by converting the goal to a more straightforward form. let e := (e₂ : Localization.Away (f r) →+* S').comp (((IsLocalization.map (Localization.Away (f r)) f (by rintro x ⟨n, rfl⟩; use n; simp : Submonoid.powers r ≤ Submonoid.comap f (Submonoid.powers (f r)))) : Localization.Away r →+* Localization.Away (f r)).comp (e₁: R' →+* Localization.Away r)) suffices e = IsLocalization.Away.map R' S' f r by convert this apply IsLocalization.ringHom_ext (Submonoid.powers r) _ ext1 x dsimp [e, e₁, e₂, IsLocalization.Away.map] simp only [IsLocalization.map_eq, id_apply, RingHomCompTriple.comp_apply] #align ring_hom.respects_iso.is_localization_away_iff RingHom.RespectsIso.is_localization_away_iff end RespectsIso section StableUnderComposition /-- A property is `StableUnderComposition` if the composition of two such morphisms still falls in the class. -/ def StableUnderComposition : Prop := ∀ ⦃R S T⦄ [CommRing R] [CommRing S] [CommRing T], ∀ (f : R →+* S) (g : S →+* T) (_ : P f) (_ : P g), P (g.comp f) #align ring_hom.stable_under_composition RingHom.StableUnderComposition variable {P}
Mathlib/RingTheory/RingHomProperties.lean
107
116
theorem StableUnderComposition.respectsIso (hP : RingHom.StableUnderComposition @P) (hP' : ∀ {R S : Type u} [CommRing R] [CommRing S] (e : R ≃+* S), P e.toRingHom) : RingHom.RespectsIso @P := by
constructor · introv H apply hP exacts [H, hP' e] · introv H apply hP exacts [hP' e, H]
/- Copyright (c) 2020 Kexing Ying. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying -/ import Mathlib.GroupTheory.Subgroup.Center import Mathlib.GroupTheory.Submonoid.Centralizer #align_import group_theory.subgroup.basic from "leanprover-community/mathlib"@"4be589053caf347b899a494da75410deb55fb3ef" /-! # Centralizers of subgroups -/ open Function open Int variable {G : Type*} [Group G] namespace Subgroup variable {H K : Subgroup G} /-- The `centralizer` of `H` is the subgroup of `g : G` commuting with every `h : H`. -/ @[to_additive "The `centralizer` of `H` is the additive subgroup of `g : G` commuting with every `h : H`."] def centralizer (s : Set G) : Subgroup G := { Submonoid.centralizer s with carrier := Set.centralizer s inv_mem' := Set.inv_mem_centralizer } #align subgroup.centralizer Subgroup.centralizer #align add_subgroup.centralizer AddSubgroup.centralizer @[to_additive] theorem mem_centralizer_iff {g : G} {s : Set G} : g ∈ centralizer s ↔ ∀ h ∈ s, h * g = g * h := Iff.rfl #align subgroup.mem_centralizer_iff Subgroup.mem_centralizer_iff #align add_subgroup.mem_centralizer_iff AddSubgroup.mem_centralizer_iff @[to_additive]
Mathlib/GroupTheory/Subgroup/Centralizer.lean
42
44
theorem mem_centralizer_iff_commutator_eq_one {g : G} {s : Set G} : g ∈ centralizer s ↔ ∀ h ∈ s, h * g * h⁻¹ * g⁻¹ = 1 := by
simp only [mem_centralizer_iff, mul_inv_eq_iff_eq_mul, one_mul]
/- Copyright (c) 2022 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.AlgebraicTopology.DoldKan.FunctorGamma import Mathlib.AlgebraicTopology.DoldKan.SplitSimplicialObject import Mathlib.CategoryTheory.Idempotents.HomologicalComplex #align_import algebraic_topology.dold_kan.gamma_comp_n from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504" /-! The counit isomorphism of the Dold-Kan equivalence The purpose of this file is to construct natural isomorphisms `N₁Γ₀ : Γ₀ ⋙ N₁ ≅ toKaroubi (ChainComplex C ℕ)` and `N₂Γ₂ : Γ₂ ⋙ N₂ ≅ 𝟭 (Karoubi (ChainComplex C ℕ))`. (See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.) -/ noncomputable section open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Idempotents Opposite SimplicialObject Simplicial namespace AlgebraicTopology namespace DoldKan variable {C : Type*} [Category C] [Preadditive C] [HasFiniteCoproducts C] /-- The isomorphism `(Γ₀.splitting K).nondegComplex ≅ K` for all `K : ChainComplex C ℕ`. -/ @[simps!] def Γ₀NondegComplexIso (K : ChainComplex C ℕ) : (Γ₀.splitting K).nondegComplex ≅ K := HomologicalComplex.Hom.isoOfComponents (fun n => Iso.refl _) (by rintro _ n (rfl : n + 1 = _) dsimp simp only [id_comp, comp_id, AlternatingFaceMapComplex.obj_d_eq, Preadditive.sum_comp, Preadditive.comp_sum] rw [Fintype.sum_eq_single (0 : Fin (n + 2))] · simp only [Fin.val_zero, pow_zero, one_zsmul] erw [Γ₀.Obj.mapMono_on_summand_id_assoc, Γ₀.Obj.Termwise.mapMono_δ₀, Splitting.cofan_inj_πSummand_eq_id, comp_id] · intro i hi dsimp simp only [Preadditive.zsmul_comp, Preadditive.comp_zsmul, assoc] erw [Γ₀.Obj.mapMono_on_summand_id_assoc, Γ₀.Obj.Termwise.mapMono_eq_zero, zero_comp, zsmul_zero] · intro h replace h := congr_arg SimplexCategory.len h change n + 1 = n at h omega · simpa only [Isδ₀.iff] using hi) #align algebraic_topology.dold_kan.Γ₀_nondeg_complex_iso AlgebraicTopology.DoldKan.Γ₀NondegComplexIso /-- The natural isomorphism `(Γ₀.splitting K).nondegComplex ≅ K` for `K : ChainComplex C ℕ`. -/ def Γ₀'CompNondegComplexFunctor : Γ₀' ⋙ Split.nondegComplexFunctor ≅ 𝟭 (ChainComplex C ℕ) := NatIso.ofComponents Γ₀NondegComplexIso #align algebraic_topology.dold_kan.Γ₀'_comp_nondeg_complex_functor AlgebraicTopology.DoldKan.Γ₀'CompNondegComplexFunctor /-- The natural isomorphism `Γ₀ ⋙ N₁ ≅ toKaroubi (ChainComplex C ℕ)`. -/ def N₁Γ₀ : Γ₀ ⋙ N₁ ≅ toKaroubi (ChainComplex C ℕ) := calc Γ₀ ⋙ N₁ ≅ Γ₀' ⋙ Split.forget C ⋙ N₁ := Functor.associator _ _ _ _ ≅ Γ₀' ⋙ Split.nondegComplexFunctor ⋙ toKaroubi _ := (isoWhiskerLeft Γ₀' Split.toKaroubiNondegComplexFunctorIsoN₁.symm) _ ≅ (Γ₀' ⋙ Split.nondegComplexFunctor) ⋙ toKaroubi _ := (Functor.associator _ _ _).symm _ ≅ 𝟭 _ ⋙ toKaroubi (ChainComplex C ℕ) := isoWhiskerRight Γ₀'CompNondegComplexFunctor _ _ ≅ toKaroubi (ChainComplex C ℕ) := Functor.leftUnitor _ set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.N₁Γ₀ AlgebraicTopology.DoldKan.N₁Γ₀ theorem N₁Γ₀_app (K : ChainComplex C ℕ) : N₁Γ₀.app K = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.symm ≪≫ (toKaroubi _).mapIso (Γ₀NondegComplexIso K) := by ext1 dsimp [N₁Γ₀] erw [id_comp, comp_id, comp_id] rfl set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.N₁Γ₀_app AlgebraicTopology.DoldKan.N₁Γ₀_app theorem N₁Γ₀_hom_app (K : ChainComplex C ℕ) : N₁Γ₀.hom.app K = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.inv ≫ (toKaroubi _).map (Γ₀NondegComplexIso K).hom := by change (N₁Γ₀.app K).hom = _ simp only [N₁Γ₀_app] rfl set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.N₁Γ₀_hom_app AlgebraicTopology.DoldKan.N₁Γ₀_hom_app theorem N₁Γ₀_inv_app (K : ChainComplex C ℕ) : N₁Γ₀.inv.app K = (toKaroubi _).map (Γ₀NondegComplexIso K).inv ≫ (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.hom := by change (N₁Γ₀.app K).inv = _ simp only [N₁Γ₀_app] rfl set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.N₁Γ₀_inv_app AlgebraicTopology.DoldKan.N₁Γ₀_inv_app @[simp]
Mathlib/AlgebraicTopology/DoldKan/GammaCompN.lean
105
108
theorem N₁Γ₀_hom_app_f_f (K : ChainComplex C ℕ) (n : ℕ) : (N₁Γ₀.hom.app K).f.f n = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.inv.f.f n := by
rw [N₁Γ₀_hom_app] apply comp_id
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.Topology.Sets.Opens #align_import topology.local_at_target from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Properties of maps that are local at the target. We show that the following properties of continuous maps are local at the target : - `Inducing` - `Embedding` - `OpenEmbedding` - `ClosedEmbedding` -/ open TopologicalSpace Set Filter open Topology Filter variable {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] {f : α → β} variable {s : Set β} {ι : Type*} {U : ι → Opens β} (hU : iSup U = ⊤) theorem Set.restrictPreimage_inducing (s : Set β) (h : Inducing f) : Inducing (s.restrictPreimage f) := by simp_rw [← inducing_subtype_val.of_comp_iff, inducing_iff_nhds, restrictPreimage, MapsTo.coe_restrict, restrict_eq, ← @Filter.comap_comap _ _ _ _ _ f, Function.comp_apply] at h ⊢ intro a rw [← h, ← inducing_subtype_val.nhds_eq_comap] #align set.restrict_preimage_inducing Set.restrictPreimage_inducing alias Inducing.restrictPreimage := Set.restrictPreimage_inducing #align inducing.restrict_preimage Inducing.restrictPreimage theorem Set.restrictPreimage_embedding (s : Set β) (h : Embedding f) : Embedding (s.restrictPreimage f) := ⟨h.1.restrictPreimage s, h.2.restrictPreimage s⟩ #align set.restrict_preimage_embedding Set.restrictPreimage_embedding alias Embedding.restrictPreimage := Set.restrictPreimage_embedding #align embedding.restrict_preimage Embedding.restrictPreimage theorem Set.restrictPreimage_openEmbedding (s : Set β) (h : OpenEmbedding f) : OpenEmbedding (s.restrictPreimage f) := ⟨h.1.restrictPreimage s, (s.range_restrictPreimage f).symm ▸ continuous_subtype_val.isOpen_preimage _ h.isOpen_range⟩ #align set.restrict_preimage_open_embedding Set.restrictPreimage_openEmbedding alias OpenEmbedding.restrictPreimage := Set.restrictPreimage_openEmbedding #align open_embedding.restrict_preimage OpenEmbedding.restrictPreimage theorem Set.restrictPreimage_closedEmbedding (s : Set β) (h : ClosedEmbedding f) : ClosedEmbedding (s.restrictPreimage f) := ⟨h.1.restrictPreimage s, (s.range_restrictPreimage f).symm ▸ inducing_subtype_val.isClosed_preimage _ h.isClosed_range⟩ #align set.restrict_preimage_closed_embedding Set.restrictPreimage_closedEmbedding alias ClosedEmbedding.restrictPreimage := Set.restrictPreimage_closedEmbedding #align closed_embedding.restrict_preimage ClosedEmbedding.restrictPreimage theorem IsClosedMap.restrictPreimage (H : IsClosedMap f) (s : Set β) : IsClosedMap (s.restrictPreimage f) := by intro t suffices ∀ u, IsClosed u → Subtype.val ⁻¹' u = t → ∃ v, IsClosed v ∧ Subtype.val ⁻¹' v = s.restrictPreimage f '' t by simpa [isClosed_induced_iff] exact fun u hu e => ⟨f '' u, H u hu, by simp [← e, image_restrictPreimage]⟩ @[deprecated (since := "2024-04-02")] theorem Set.restrictPreimage_isClosedMap (s : Set β) (H : IsClosedMap f) : IsClosedMap (s.restrictPreimage f) := H.restrictPreimage s
Mathlib/Topology/LocalAtTarget.lean
78
84
theorem IsOpenMap.restrictPreimage (H : IsOpenMap f) (s : Set β) : IsOpenMap (s.restrictPreimage f) := by
intro t suffices ∀ u, IsOpen u → Subtype.val ⁻¹' u = t → ∃ v, IsOpen v ∧ Subtype.val ⁻¹' v = s.restrictPreimage f '' t by simpa [isOpen_induced_iff] exact fun u hu e => ⟨f '' u, H u hu, by simp [← e, image_restrictPreimage]⟩
/- Copyright (c) 2021 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Data.Real.Irrational import Mathlib.Data.Rat.Encodable import Mathlib.Topology.GDelta #align_import topology.instances.irrational from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Topology of irrational numbers In this file we prove the following theorems: * `IsGδ.setOf_irrational`, `dense_irrational`, `eventually_residual_irrational`: irrational numbers form a dense Gδ set; * `Irrational.eventually_forall_le_dist_cast_div`, `Irrational.eventually_forall_le_dist_cast_div_of_denom_le`; `Irrational.eventually_forall_le_dist_cast_rat_of_denom_le`: a sufficiently small neighborhood of an irrational number is disjoint with the set of rational numbers with bounded denominator. We also provide `OrderTopology`, `NoMinOrder`, `NoMaxOrder`, and `DenselyOrdered` instances for `{x // Irrational x}`. ## Tags irrational, residual -/ open Set Filter Metric open Filter Topology protected theorem IsGδ.setOf_irrational : IsGδ { x | Irrational x } := (countable_range _).isGδ_compl set_option linter.uppercaseLean3 false in #align is_Gδ_irrational IsGδ.setOf_irrational @[deprecated (since := "2024-02-15")] alias isGδ_irrational := IsGδ.setOf_irrational theorem dense_irrational : Dense { x : ℝ | Irrational x } := by refine Real.isTopologicalBasis_Ioo_rat.dense_iff.2 ?_ simp only [gt_iff_lt, Rat.cast_lt, not_lt, ge_iff_le, Rat.cast_le, mem_iUnion, mem_singleton_iff, exists_prop, forall_exists_index, and_imp] rintro _ a b hlt rfl _ rw [inter_comm] exact exists_irrational_btwn (Rat.cast_lt.2 hlt) #align dense_irrational dense_irrational theorem eventually_residual_irrational : ∀ᶠ x in residual ℝ, Irrational x := residual_of_dense_Gδ .setOf_irrational dense_irrational #align eventually_residual_irrational eventually_residual_irrational namespace Irrational variable {x : ℝ} instance : OrderTopology { x // Irrational x } := induced_orderTopology _ Iff.rfl <| @fun _ _ hlt => let ⟨z, hz, hxz, hzy⟩ := exists_irrational_btwn hlt ⟨⟨z, hz⟩, hxz, hzy⟩ instance : NoMaxOrder { x // Irrational x } := ⟨fun ⟨x, hx⟩ => ⟨⟨x + (1 : ℕ), hx.add_nat 1⟩, by simp⟩⟩ instance : NoMinOrder { x // Irrational x } := ⟨fun ⟨x, hx⟩ => ⟨⟨x - (1 : ℕ), hx.sub_nat 1⟩, by simp⟩⟩ instance : DenselyOrdered { x // Irrational x } := ⟨fun _ _ hlt => let ⟨z, hz, hxz, hzy⟩ := exists_irrational_btwn hlt ⟨⟨z, hz⟩, hxz, hzy⟩⟩
Mathlib/Topology/Instances/Irrational.lean
78
89
theorem eventually_forall_le_dist_cast_div (hx : Irrational x) (n : ℕ) : ∀ᶠ ε : ℝ in 𝓝 0, ∀ m : ℤ, ε ≤ dist x (m / n) := by
have A : IsClosed (range (fun m => (n : ℝ)⁻¹ * m : ℤ → ℝ)) := ((isClosedMap_smul₀ (n⁻¹ : ℝ)).comp Int.closedEmbedding_coe_real.isClosedMap).isClosed_range have B : x ∉ range (fun m => (n : ℝ)⁻¹ * m : ℤ → ℝ) := by rintro ⟨m, rfl⟩ simp at hx rcases Metric.mem_nhds_iff.1 (A.isOpen_compl.mem_nhds B) with ⟨ε, ε0, hε⟩ refine (ge_mem_nhds ε0).mono fun δ hδ m => not_lt.1 fun hlt => ?_ rw [dist_comm] at hlt refine hε (ball_subset_ball hδ hlt) ⟨m, ?_⟩ simp [div_eq_inv_mul]
/- Copyright (c) 2022 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.Analytic.Linear import Mathlib.Analysis.Analytic.Composition import Mathlib.Analysis.NormedSpace.Completion #align_import analysis.analytic.uniqueness from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090" /-! # Uniqueness principle for analytic functions We show that two analytic functions which coincide around a point coincide on whole connected sets, in `AnalyticOn.eqOn_of_preconnected_of_eventuallyEq`. -/ variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] open Set open scoped Topology ENNReal namespace AnalyticOn /-- If an analytic function vanishes around a point, then it is uniformly zero along a connected set. Superseded by `eqOn_zero_of_preconnected_of_locally_zero` which does not assume completeness of the target space. -/
Mathlib/Analysis/Analytic/Uniqueness.lean
32
70
theorem eqOn_zero_of_preconnected_of_eventuallyEq_zero_aux [CompleteSpace F] {f : E → F} {U : Set E} (hf : AnalyticOn 𝕜 f U) (hU : IsPreconnected U) {z₀ : E} (h₀ : z₀ ∈ U) (hfz₀ : f =ᶠ[𝓝 z₀] 0) : EqOn f 0 U := by
/- Let `u` be the set of points around which `f` vanishes. It is clearly open. We have to show that its limit points in `U` still belong to it, from which the inclusion `U ⊆ u` will follow by connectedness. -/ let u := {x | f =ᶠ[𝓝 x] 0} suffices main : closure u ∩ U ⊆ u by have Uu : U ⊆ u := hU.subset_of_closure_inter_subset isOpen_setOf_eventually_nhds ⟨z₀, h₀, hfz₀⟩ main intro z hz simpa using mem_of_mem_nhds (Uu hz) /- Take a limit point `x`, then a ball `B (x, r)` on which it has a power series expansion, and then `y ∈ B (x, r/2) ∩ u`. Then `f` has a power series expansion on `B (y, r/2)` as it is contained in `B (x, r)`. All the coefficients in this series expansion vanish, as `f` is zero on a neighborhood of `y`. Therefore, `f` is zero on `B (y, r/2)`. As this ball contains `x`, it follows that `f` vanishes on a neighborhood of `x`, proving the claim. -/ rintro x ⟨xu, xU⟩ rcases hf x xU with ⟨p, r, hp⟩ obtain ⟨y, yu, hxy⟩ : ∃ y ∈ u, edist x y < r / 2 := EMetric.mem_closure_iff.1 xu (r / 2) (ENNReal.half_pos hp.r_pos.ne') let q := p.changeOrigin (y - x) have has_series : HasFPowerSeriesOnBall f q y (r / 2) := by have A : (‖y - x‖₊ : ℝ≥0∞) < r / 2 := by rwa [edist_comm, edist_eq_coe_nnnorm_sub] at hxy have := hp.changeOrigin (A.trans_le ENNReal.half_le_self) simp only [add_sub_cancel] at this apply this.mono (ENNReal.half_pos hp.r_pos.ne') apply ENNReal.le_sub_of_add_le_left ENNReal.coe_ne_top apply (add_le_add A.le (le_refl (r / 2))).trans (le_of_eq _) exact ENNReal.add_halves _ have M : EMetric.ball y (r / 2) ∈ 𝓝 x := EMetric.isOpen_ball.mem_nhds hxy filter_upwards [M] with z hz have A : HasSum (fun n : ℕ => q n fun _ : Fin n => z - y) (f z) := has_series.hasSum_sub hz have B : HasSum (fun n : ℕ => q n fun _ : Fin n => z - y) 0 := by have : HasFPowerSeriesAt 0 q y := has_series.hasFPowerSeriesAt.congr yu convert hasSum_zero (α := F) using 2 ext n exact this.apply_eq_zero n _ exact HasSum.unique A B