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) 2022 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import Mathlib.ModelTheory.Substructures #align_import model_theory.finitely_generated from "leanprover-community/mathlib"@"0602c59878ff3d5f71dea69c2d32ccf2e93e5398" /-! # Finitely Generated First-Order Structures This file defines what it means for a first-order (sub)structure to be finitely or countably generated, similarly to other finitely-generated objects in the algebra library. ## Main Definitions * `FirstOrder.Language.Substructure.FG` indicates that a substructure is finitely generated. * `FirstOrder.Language.Structure.FG` indicates that a structure is finitely generated. * `FirstOrder.Language.Substructure.CG` indicates that a substructure is countably generated. * `FirstOrder.Language.Structure.CG` indicates that a structure is countably generated. ## TODO Develop a more unified definition of finite generation using the theory of closure operators, or use this definition of finite generation to define the others. -/ open FirstOrder Set namespace FirstOrder namespace Language open Structure variable {L : Language} {M : Type*} [L.Structure M] namespace Substructure /-- A substructure of `M` is finitely generated if it is the closure of a finite subset of `M`. -/ def FG (N : L.Substructure M) : Prop := ∃ S : Finset M, closure L S = N #align first_order.language.substructure.fg FirstOrder.Language.Substructure.FG theorem fg_def {N : L.Substructure M} : N.FG ↔ ∃ S : Set M, S.Finite ∧ closure L S = N := ⟨fun ⟨t, h⟩ => ⟨_, Finset.finite_toSet t, h⟩, by rintro ⟨t', h, rfl⟩ rcases Finite.exists_finset_coe h with ⟨t, rfl⟩ exact ⟨t, rfl⟩⟩ #align first_order.language.substructure.fg_def FirstOrder.Language.Substructure.fg_def theorem fg_iff_exists_fin_generating_family {N : L.Substructure M} : N.FG ↔ ∃ (n : ℕ) (s : Fin n → M), closure L (range s) = N := by rw [fg_def] constructor · rintro ⟨S, Sfin, hS⟩ obtain ⟨n, f, rfl⟩ := Sfin.fin_embedding exact ⟨n, f, hS⟩ · rintro ⟨n, s, hs⟩ exact ⟨range s, finite_range s, hs⟩ #align first_order.language.substructure.fg_iff_exists_fin_generating_family FirstOrder.Language.Substructure.fg_iff_exists_fin_generating_family theorem fg_bot : (⊥ : L.Substructure M).FG := ⟨∅, by rw [Finset.coe_empty, closure_empty]⟩ #align first_order.language.substructure.fg_bot FirstOrder.Language.Substructure.fg_bot theorem fg_closure {s : Set M} (hs : s.Finite) : FG (closure L s) := ⟨hs.toFinset, by rw [hs.coe_toFinset]⟩ #align first_order.language.substructure.fg_closure FirstOrder.Language.Substructure.fg_closure theorem fg_closure_singleton (x : M) : FG (closure L ({x} : Set M)) := fg_closure (finite_singleton x) #align first_order.language.substructure.fg_closure_singleton FirstOrder.Language.Substructure.fg_closure_singleton theorem FG.sup {N₁ N₂ : L.Substructure M} (hN₁ : N₁.FG) (hN₂ : N₂.FG) : (N₁ ⊔ N₂).FG := let ⟨t₁, ht₁⟩ := fg_def.1 hN₁ let ⟨t₂, ht₂⟩ := fg_def.1 hN₂ fg_def.2 ⟨t₁ ∪ t₂, ht₁.1.union ht₂.1, by rw [closure_union, ht₁.2, ht₂.2]⟩ #align first_order.language.substructure.fg.sup FirstOrder.Language.Substructure.FG.sup theorem FG.map {N : Type*} [L.Structure N] (f : M →[L] N) {s : L.Substructure M} (hs : s.FG) : (s.map f).FG := let ⟨t, ht⟩ := fg_def.1 hs fg_def.2 ⟨f '' t, ht.1.image _, by rw [closure_image, ht.2]⟩ #align first_order.language.substructure.fg.map FirstOrder.Language.Substructure.FG.map theorem FG.of_map_embedding {N : Type*} [L.Structure N] (f : M ↪[L] N) {s : L.Substructure M} (hs : (s.map f.toHom).FG) : s.FG := by rcases hs with ⟨t, h⟩ rw [fg_def] refine ⟨f ⁻¹' t, t.finite_toSet.preimage f.injective.injOn, ?_⟩ have hf : Function.Injective f.toHom := f.injective refine map_injective_of_injective hf ?_ rw [← h, map_closure, Embedding.coe_toHom, image_preimage_eq_of_subset] intro x hx have h' := subset_closure (L := L) hx rw [h] at h' exact Hom.map_le_range h' #align first_order.language.substructure.fg.of_map_embedding FirstOrder.Language.Substructure.FG.of_map_embedding /-- A substructure of `M` is countably generated if it is the closure of a countable subset of `M`. -/ def CG (N : L.Substructure M) : Prop := ∃ S : Set M, S.Countable ∧ closure L S = N #align first_order.language.substructure.cg FirstOrder.Language.Substructure.CG theorem cg_def {N : L.Substructure M} : N.CG ↔ ∃ S : Set M, S.Countable ∧ closure L S = N := Iff.refl _ #align first_order.language.substructure.cg_def FirstOrder.Language.Substructure.cg_def
Mathlib/ModelTheory/FinitelyGenerated.lean
111
113
theorem FG.cg {N : L.Substructure M} (h : N.FG) : N.CG := by
obtain ⟨s, hf, rfl⟩ := fg_def.1 h exact ⟨s, hf.countable, rfl⟩
/- Copyright (c) 2022 Riccardo Brasca. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Riccardo Brasca -/ import Mathlib.NumberTheory.Cyclotomic.Discriminant import Mathlib.RingTheory.Polynomial.Eisenstein.IsIntegral import Mathlib.RingTheory.Ideal.Norm #align_import number_theory.cyclotomic.rat from "leanprover-community/mathlib"@"b353176c24d96c23f0ce1cc63efc3f55019702d9" /-! # Ring of integers of `p ^ n`-th cyclotomic fields We gather results about cyclotomic extensions of `ℚ`. In particular, we compute the ring of integers of a `p ^ n`-th cyclotomic extension of `ℚ`. ## Main results * `IsCyclotomicExtension.Rat.isIntegralClosure_adjoin_singleton_of_prime_pow`: if `K` is a `p ^ k`-th cyclotomic extension of `ℚ`, then `(adjoin ℤ {ζ})` is the integral closure of `ℤ` in `K`. * `IsCyclotomicExtension.Rat.cyclotomicRing_isIntegralClosure_of_prime_pow`: the integral closure of `ℤ` inside `CyclotomicField (p ^ k) ℚ` is `CyclotomicRing (p ^ k) ℤ ℚ`. * `IsCyclotomicExtension.Rat.absdiscr_prime_pow` and related results: the absolute discriminant of cyclotomic fields. -/ universe u open Algebra IsCyclotomicExtension Polynomial NumberField open scoped Cyclotomic Nat variable {p : ℕ+} {k : ℕ} {K : Type u} [Field K] [CharZero K] {ζ : K} [hp : Fact (p : ℕ).Prime] namespace IsCyclotomicExtension.Rat /-- The discriminant of the power basis given by `ζ - 1`. -/ theorem discr_prime_pow_ne_two' [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] (hζ : IsPrimitiveRoot ζ ↑(p ^ (k + 1))) (hk : p ^ (k + 1) ≠ 2) : discr ℚ (hζ.subOnePowerBasis ℚ).basis = (-1) ^ ((p ^ (k + 1) : ℕ).totient / 2) * p ^ ((p : ℕ) ^ k * ((p - 1) * (k + 1) - 1)) := by rw [← discr_prime_pow_ne_two hζ (cyclotomic.irreducible_rat (p ^ (k + 1)).pos) hk] exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm #align is_cyclotomic_extension.rat.discr_prime_pow_ne_two' IsCyclotomicExtension.Rat.discr_prime_pow_ne_two' theorem discr_odd_prime' [IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) (hodd : p ≠ 2) : discr ℚ (hζ.subOnePowerBasis ℚ).basis = (-1) ^ (((p : ℕ) - 1) / 2) * p ^ ((p : ℕ) - 2) := by rw [← discr_odd_prime hζ (cyclotomic.irreducible_rat hp.out.pos) hodd] exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm #align is_cyclotomic_extension.rat.discr_odd_prime' IsCyclotomicExtension.Rat.discr_odd_prime' /-- The discriminant of the power basis given by `ζ - 1`. Beware that in the cases `p ^ k = 1` and `p ^ k = 2` the formula uses `1 / 2 = 0` and `0 - 1 = 0`. It is useful only to have a uniform result. See also `IsCyclotomicExtension.Rat.discr_prime_pow_eq_unit_mul_pow'`. -/
Mathlib/NumberTheory/Cyclotomic/Rat.lean
55
59
theorem discr_prime_pow' [IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ ↑(p ^ k)) : discr ℚ (hζ.subOnePowerBasis ℚ).basis = (-1) ^ ((p ^ k : ℕ).totient / 2) * p ^ ((p : ℕ) ^ (k - 1) * ((p - 1) * k - 1)) := by
rw [← discr_prime_pow hζ (cyclotomic.irreducible_rat (p ^ k).pos)] exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm
/- 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.Countable.Basic import Mathlib.Data.Fin.VecNotation import Mathlib.Order.Disjointed import Mathlib.MeasureTheory.OuterMeasure.Defs #align_import measure_theory.measure.outer_measure from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55" /-! # Outer Measures An outer measure is a function `μ : Set α → ℝ≥0∞`, from the powerset of a type to the extended nonnegative real numbers that satisfies the following conditions: 1. `μ ∅ = 0`; 2. `μ` is monotone; 3. `μ` is countably subadditive. This means that the outer measure of a countable union is at most the sum of the outer measure on the individual sets. Note that we do not need `α` to be measurable to define an outer measure. ## References <https://en.wikipedia.org/wiki/Outer_measure> ## Tags outer measure -/ noncomputable section open Set Function Filter open scoped Classical NNReal Topology ENNReal namespace MeasureTheory section OuterMeasureClass variable {α ι F : Type*} [FunLike F (Set α) ℝ≥0∞] [OuterMeasureClass F α] {μ : F} {s t : Set α} @[simp] theorem measure_empty : μ ∅ = 0 := OuterMeasureClass.measure_empty μ #align measure_theory.measure_empty MeasureTheory.measure_empty @[mono, gcongr] theorem measure_mono (h : s ⊆ t) : μ s ≤ μ t := OuterMeasureClass.measure_mono μ h #align measure_theory.measure_mono MeasureTheory.measure_mono theorem measure_mono_null (h : s ⊆ t) (ht : μ t = 0) : μ s = 0 := eq_bot_mono (measure_mono h) ht #align measure_theory.measure_mono_null MeasureTheory.measure_mono_null theorem measure_pos_of_superset (h : s ⊆ t) (hs : μ s ≠ 0) : 0 < μ t := hs.bot_lt.trans_le (measure_mono h)
Mathlib/MeasureTheory/OuterMeasure/Basic.lean
63
69
theorem measure_iUnion_le [Countable ι] (s : ι → Set α) : μ (⋃ i, s i) ≤ ∑' i, μ (s i) := by
refine rel_iSup_tsum μ measure_empty (· ≤ ·) (fun t ↦ ?_) _ calc μ (⋃ i, t i) = μ (⋃ i, disjointed t i) := by rw [iUnion_disjointed] _ ≤ ∑' i, μ (disjointed t i) := OuterMeasureClass.measure_iUnion_nat_le _ _ (disjoint_disjointed _) _ ≤ ∑' i, μ (t i) := by gcongr; apply disjointed_subset
/- Copyright (c) 2022 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jujian Zhang -/ import Mathlib.Algebra.Category.GroupCat.EquivalenceGroupAddGroup import Mathlib.GroupTheory.QuotientGroup #align_import algebra.category.Group.epi_mono from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Monomorphisms and epimorphisms in `Group` In this file, we prove monomorphisms in the category of groups are injective homomorphisms and epimorphisms are surjective homomorphisms. -/ noncomputable section open scoped Pointwise universe u v namespace MonoidHom open QuotientGroup variable {A : Type u} {B : Type v} section variable [Group A] [Group B] @[to_additive]
Mathlib/Algebra/Category/GroupCat/EpiMono.lean
35
36
theorem ker_eq_bot_of_cancel {f : A →* B} (h : ∀ u v : f.ker →* A, f.comp u = f.comp v → u = v) : f.ker = ⊥ := by
simpa using _root_.congr_arg range (h f.ker.subtype 1 (by aesop_cat))
/- Copyright (c) 2023 Paul Reichert. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Paul Reichert, Yaël Dillies -/ import Mathlib.Analysis.NormedSpace.AddTorsorBases #align_import analysis.convex.intrinsic from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" /-! # Intrinsic frontier and interior This file defines the intrinsic frontier, interior and closure of a set in a normed additive torsor. These are also known as relative frontier, interior, closure. The intrinsic frontier/interior/closure of a set `s` is the frontier/interior/closure of `s` considered as a set in its affine span. The intrinsic interior is in general greater than the topological interior, the intrinsic frontier in general less than the topological frontier, and the intrinsic closure in cases of interest the same as the topological closure. ## Definitions * `intrinsicInterior`: Intrinsic interior * `intrinsicFrontier`: Intrinsic frontier * `intrinsicClosure`: Intrinsic closure ## Results The main results are: * `AffineIsometry.image_intrinsicInterior`/`AffineIsometry.image_intrinsicFrontier`/ `AffineIsometry.image_intrinsicClosure`: Intrinsic interiors/frontiers/closures commute with taking the image under an affine isometry. * `Set.Nonempty.intrinsicInterior`: The intrinsic interior of a nonempty convex set is nonempty. ## References * Chapter 8 of [Barry Simon, *Convexity*][simon2011] * Chapter 1 of [Rolf Schneider, *Convex Bodies: The Brunn-Minkowski theory*][schneider2013]. ## TODO * `IsClosed s → IsExtreme 𝕜 s (intrinsicFrontier 𝕜 s)` * `x ∈ s → y ∈ intrinsicInterior 𝕜 s → openSegment 𝕜 x y ⊆ intrinsicInterior 𝕜 s` -/ open AffineSubspace Set open scoped Pointwise variable {𝕜 V W Q P : Type*} section AddTorsor variable (𝕜) [Ring 𝕜] [AddCommGroup V] [Module 𝕜 V] [TopologicalSpace P] [AddTorsor V P] {s t : Set P} {x : P} /-- The intrinsic interior of a set is its interior considered as a set in its affine span. -/ def intrinsicInterior (s : Set P) : Set P := (↑) '' interior ((↑) ⁻¹' s : Set <| affineSpan 𝕜 s) #align intrinsic_interior intrinsicInterior /-- The intrinsic frontier of a set is its frontier considered as a set in its affine span. -/ def intrinsicFrontier (s : Set P) : Set P := (↑) '' frontier ((↑) ⁻¹' s : Set <| affineSpan 𝕜 s) #align intrinsic_frontier intrinsicFrontier /-- The intrinsic closure of a set is its closure considered as a set in its affine span. -/ def intrinsicClosure (s : Set P) : Set P := (↑) '' closure ((↑) ⁻¹' s : Set <| affineSpan 𝕜 s) #align intrinsic_closure intrinsicClosure variable {𝕜} @[simp] theorem mem_intrinsicInterior : x ∈ intrinsicInterior 𝕜 s ↔ ∃ y, y ∈ interior ((↑) ⁻¹' s : Set <| affineSpan 𝕜 s) ∧ ↑y = x := mem_image _ _ _ #align mem_intrinsic_interior mem_intrinsicInterior @[simp] theorem mem_intrinsicFrontier : x ∈ intrinsicFrontier 𝕜 s ↔ ∃ y, y ∈ frontier ((↑) ⁻¹' s : Set <| affineSpan 𝕜 s) ∧ ↑y = x := mem_image _ _ _ #align mem_intrinsic_frontier mem_intrinsicFrontier @[simp] theorem mem_intrinsicClosure : x ∈ intrinsicClosure 𝕜 s ↔ ∃ y, y ∈ closure ((↑) ⁻¹' s : Set <| affineSpan 𝕜 s) ∧ ↑y = x := mem_image _ _ _ #align mem_intrinsic_closure mem_intrinsicClosure theorem intrinsicInterior_subset : intrinsicInterior 𝕜 s ⊆ s := image_subset_iff.2 interior_subset #align intrinsic_interior_subset intrinsicInterior_subset theorem intrinsicFrontier_subset (hs : IsClosed s) : intrinsicFrontier 𝕜 s ⊆ s := image_subset_iff.2 (hs.preimage continuous_induced_dom).frontier_subset #align intrinsic_frontier_subset intrinsicFrontier_subset theorem intrinsicFrontier_subset_intrinsicClosure : intrinsicFrontier 𝕜 s ⊆ intrinsicClosure 𝕜 s := image_subset _ frontier_subset_closure #align intrinsic_frontier_subset_intrinsic_closure intrinsicFrontier_subset_intrinsicClosure theorem subset_intrinsicClosure : s ⊆ intrinsicClosure 𝕜 s := fun x hx => ⟨⟨x, subset_affineSpan _ _ hx⟩, subset_closure hx, rfl⟩ #align subset_intrinsic_closure subset_intrinsicClosure @[simp] theorem intrinsicInterior_empty : intrinsicInterior 𝕜 (∅ : Set P) = ∅ := by simp [intrinsicInterior] #align intrinsic_interior_empty intrinsicInterior_empty @[simp] theorem intrinsicFrontier_empty : intrinsicFrontier 𝕜 (∅ : Set P) = ∅ := by simp [intrinsicFrontier] #align intrinsic_frontier_empty intrinsicFrontier_empty @[simp] theorem intrinsicClosure_empty : intrinsicClosure 𝕜 (∅ : Set P) = ∅ := by simp [intrinsicClosure] #align intrinsic_closure_empty intrinsicClosure_empty @[simp] theorem intrinsicClosure_nonempty : (intrinsicClosure 𝕜 s).Nonempty ↔ s.Nonempty := ⟨by simp_rw [nonempty_iff_ne_empty]; rintro h rfl; exact h intrinsicClosure_empty, Nonempty.mono subset_intrinsicClosure⟩ #align intrinsic_closure_nonempty intrinsicClosure_nonempty alias ⟨Set.Nonempty.ofIntrinsicClosure, Set.Nonempty.intrinsicClosure⟩ := intrinsicClosure_nonempty #align set.nonempty.of_intrinsic_closure Set.Nonempty.ofIntrinsicClosure #align set.nonempty.intrinsic_closure Set.Nonempty.intrinsicClosure --attribute [protected] Set.Nonempty.intrinsicClosure -- Porting note: removed @[simp] theorem intrinsicInterior_singleton (x : P) : intrinsicInterior 𝕜 ({x} : Set P) = {x} := by simpa only [intrinsicInterior, preimage_coe_affineSpan_singleton, interior_univ, image_univ, Subtype.range_coe] using coe_affineSpan_singleton _ _ _ #align intrinsic_interior_singleton intrinsicInterior_singleton @[simp]
Mathlib/Analysis/Convex/Intrinsic.lean
142
143
theorem intrinsicFrontier_singleton (x : P) : intrinsicFrontier 𝕜 ({x} : Set P) = ∅ := by
rw [intrinsicFrontier, preimage_coe_affineSpan_singleton, frontier_univ, image_empty]
/- Copyright (c) 2023 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Yury Kudryashov -/ import Mathlib.Analysis.Calculus.Deriv.Mul import Mathlib.Analysis.Calculus.Deriv.Comp #align_import analysis.calculus.deriv.inv from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Derivatives of `x ↦ x⁻¹` and `f x / g x` In this file we prove `(x⁻¹)' = -1 / x ^ 2`, `((f x)⁻¹)' = -f' x / (f x) ^ 2`, and `(f x / g x)' = (f' x * g x - f x * g' x) / (g x) ^ 2` for different notions of derivative. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `Analysis/Calculus/Deriv/Basic`. ## Keywords derivative -/ universe u v w open scoped Classical open Topology Filter ENNReal open Filter Asymptotics Set open ContinuousLinearMap (smulRight smulRight_one_eq_iff) variable {𝕜 : Type u} [NontriviallyNormedField 𝕜] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {f f₀ f₁ g : 𝕜 → F} variable {f' f₀' f₁' g' : F} variable {x : 𝕜} variable {s t : Set 𝕜} variable {L : Filter 𝕜} section Inverse /-! ### Derivative of `x ↦ x⁻¹` -/ theorem hasStrictDerivAt_inv (hx : x ≠ 0) : HasStrictDerivAt Inv.inv (-(x ^ 2)⁻¹) x := by suffices (fun p : 𝕜 × 𝕜 => (p.1 - p.2) * ((x * x)⁻¹ - (p.1 * p.2)⁻¹)) =o[𝓝 (x, x)] fun p => (p.1 - p.2) * 1 by refine this.congr' ?_ (eventually_of_forall fun _ => mul_one _) refine Eventually.mono ((isOpen_ne.prod isOpen_ne).mem_nhds ⟨hx, hx⟩) ?_ rintro ⟨y, z⟩ ⟨hy, hz⟩ simp only [mem_setOf_eq] at hy hz -- hy : y ≠ 0, hz : z ≠ 0 field_simp [hx, hy, hz] ring refine (isBigO_refl (fun p : 𝕜 × 𝕜 => p.1 - p.2) _).mul_isLittleO ((isLittleO_one_iff 𝕜).2 ?_) rw [← sub_self (x * x)⁻¹] exact tendsto_const_nhds.sub ((continuous_mul.tendsto (x, x)).inv₀ <| mul_ne_zero hx hx) #align has_strict_deriv_at_inv hasStrictDerivAt_inv theorem hasDerivAt_inv (x_ne_zero : x ≠ 0) : HasDerivAt (fun y => y⁻¹) (-(x ^ 2)⁻¹) x := (hasStrictDerivAt_inv x_ne_zero).hasDerivAt #align has_deriv_at_inv hasDerivAt_inv theorem hasDerivWithinAt_inv (x_ne_zero : x ≠ 0) (s : Set 𝕜) : HasDerivWithinAt (fun x => x⁻¹) (-(x ^ 2)⁻¹) s x := (hasDerivAt_inv x_ne_zero).hasDerivWithinAt #align has_deriv_within_at_inv hasDerivWithinAt_inv theorem differentiableAt_inv : DifferentiableAt 𝕜 (fun x => x⁻¹) x ↔ x ≠ 0 := ⟨fun H => NormedField.continuousAt_inv.1 H.continuousAt, fun H => (hasDerivAt_inv H).differentiableAt⟩ #align differentiable_at_inv differentiableAt_inv theorem differentiableWithinAt_inv (x_ne_zero : x ≠ 0) : DifferentiableWithinAt 𝕜 (fun x => x⁻¹) s x := (differentiableAt_inv.2 x_ne_zero).differentiableWithinAt #align differentiable_within_at_inv differentiableWithinAt_inv theorem differentiableOn_inv : DifferentiableOn 𝕜 (fun x : 𝕜 => x⁻¹) { x | x ≠ 0 } := fun _x hx => differentiableWithinAt_inv hx #align differentiable_on_inv differentiableOn_inv theorem deriv_inv : deriv (fun x => x⁻¹) x = -(x ^ 2)⁻¹ := by rcases eq_or_ne x 0 with (rfl | hne) · simp [deriv_zero_of_not_differentiableAt (mt differentiableAt_inv.1 (not_not.2 rfl))] · exact (hasDerivAt_inv hne).deriv #align deriv_inv deriv_inv @[simp] theorem deriv_inv' : (deriv fun x : 𝕜 => x⁻¹) = fun x => -(x ^ 2)⁻¹ := funext fun _ => deriv_inv #align deriv_inv' deriv_inv' theorem derivWithin_inv (x_ne_zero : x ≠ 0) (hxs : UniqueDiffWithinAt 𝕜 s x) : derivWithin (fun x => x⁻¹) s x = -(x ^ 2)⁻¹ := by rw [DifferentiableAt.derivWithin (differentiableAt_inv.2 x_ne_zero) hxs] exact deriv_inv #align deriv_within_inv derivWithin_inv theorem hasFDerivAt_inv (x_ne_zero : x ≠ 0) : HasFDerivAt (fun x => x⁻¹) (smulRight (1 : 𝕜 →L[𝕜] 𝕜) (-(x ^ 2)⁻¹) : 𝕜 →L[𝕜] 𝕜) x := hasDerivAt_inv x_ne_zero #align has_fderiv_at_inv hasFDerivAt_inv theorem hasFDerivWithinAt_inv (x_ne_zero : x ≠ 0) : HasFDerivWithinAt (fun x => x⁻¹) (smulRight (1 : 𝕜 →L[𝕜] 𝕜) (-(x ^ 2)⁻¹) : 𝕜 →L[𝕜] 𝕜) s x := (hasFDerivAt_inv x_ne_zero).hasFDerivWithinAt #align has_fderiv_within_at_inv hasFDerivWithinAt_inv
Mathlib/Analysis/Calculus/Deriv/Inv.lean
114
115
theorem fderiv_inv : fderiv 𝕜 (fun x => x⁻¹) x = smulRight (1 : 𝕜 →L[𝕜] 𝕜) (-(x ^ 2)⁻¹) := by
rw [← deriv_fderiv, deriv_inv]
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.BaseChange import Mathlib.Algebra.Lie.Solvable import Mathlib.Algebra.Lie.Quotient import Mathlib.Algebra.Lie.Normalizer import Mathlib.LinearAlgebra.Eigenspace.Basic import Mathlib.Order.Filter.AtTopBot import Mathlib.RingTheory.Artinian import Mathlib.RingTheory.Nilpotent.Lemmas import Mathlib.Tactic.Monotonicity #align_import algebra.lie.nilpotent from "leanprover-community/mathlib"@"6b0169218d01f2837d79ea2784882009a0da1aa1" /-! # Nilpotent Lie algebras Like groups, Lie algebras admit a natural concept of nilpotency. More generally, any Lie module carries a natural concept of nilpotency. We define these here via the lower central series. ## Main definitions * `LieModule.lowerCentralSeries` * `LieModule.IsNilpotent` ## Tags lie algebra, lower central series, nilpotent -/ universe u v w w₁ w₂ section NilpotentModules variable {R : Type u} {L : Type v} {M : Type w} variable [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] variable [LieRingModule L M] [LieModule R L M] variable (k : ℕ) (N : LieSubmodule R L M) namespace LieSubmodule /-- A generalisation of the lower central series. The zeroth term is a specified Lie submodule of a Lie module. In the case when we specify the top ideal `⊤` of the Lie algebra, regarded as a Lie module over itself, we get the usual lower central series of a Lie algebra. It can be more convenient to work with this generalisation when considering the lower central series of a Lie submodule, regarded as a Lie module in its own right, since it provides a type-theoretic expression of the fact that the terms of the Lie submodule's lower central series are also Lie submodules of the enclosing Lie module. See also `LieSubmodule.lowerCentralSeries_eq_lcs_comap` and `LieSubmodule.lowerCentralSeries_map_eq_lcs` below, as well as `LieSubmodule.ucs`. -/ def lcs : LieSubmodule R L M → LieSubmodule R L M := (fun N => ⁅(⊤ : LieIdeal R L), N⁆)^[k] #align lie_submodule.lcs LieSubmodule.lcs @[simp] theorem lcs_zero (N : LieSubmodule R L M) : N.lcs 0 = N := rfl #align lie_submodule.lcs_zero LieSubmodule.lcs_zero @[simp] theorem lcs_succ : N.lcs (k + 1) = ⁅(⊤ : LieIdeal R L), N.lcs k⁆ := Function.iterate_succ_apply' (fun N' => ⁅⊤, N'⁆) k N #align lie_submodule.lcs_succ LieSubmodule.lcs_succ @[simp] lemma lcs_sup {N₁ N₂ : LieSubmodule R L M} {k : ℕ} : (N₁ ⊔ N₂).lcs k = N₁.lcs k ⊔ N₂.lcs k := by induction' k with k ih · simp · simp only [LieSubmodule.lcs_succ, ih, LieSubmodule.lie_sup] end LieSubmodule namespace LieModule variable (R L M) /-- The lower central series of Lie submodules of a Lie module. -/ def lowerCentralSeries : LieSubmodule R L M := (⊤ : LieSubmodule R L M).lcs k #align lie_module.lower_central_series LieModule.lowerCentralSeries @[simp] theorem lowerCentralSeries_zero : lowerCentralSeries R L M 0 = ⊤ := rfl #align lie_module.lower_central_series_zero LieModule.lowerCentralSeries_zero @[simp] theorem lowerCentralSeries_succ : lowerCentralSeries R L M (k + 1) = ⁅(⊤ : LieIdeal R L), lowerCentralSeries R L M k⁆ := (⊤ : LieSubmodule R L M).lcs_succ k #align lie_module.lower_central_series_succ LieModule.lowerCentralSeries_succ end LieModule namespace LieSubmodule open LieModule theorem lcs_le_self : N.lcs k ≤ N := by induction' k with k ih · simp · simp only [lcs_succ] exact (LieSubmodule.mono_lie_right _ _ ⊤ ih).trans (N.lie_le_right ⊤) #align lie_submodule.lcs_le_self LieSubmodule.lcs_le_self theorem lowerCentralSeries_eq_lcs_comap : lowerCentralSeries R L N k = (N.lcs k).comap N.incl := by induction' k with k ih · simp · simp only [lcs_succ, lowerCentralSeries_succ] at ih ⊢ have : N.lcs k ≤ N.incl.range := by rw [N.range_incl] apply lcs_le_self rw [ih, LieSubmodule.comap_bracket_eq _ _ N.incl N.ker_incl this] #align lie_submodule.lower_central_series_eq_lcs_comap LieSubmodule.lowerCentralSeries_eq_lcs_comap theorem lowerCentralSeries_map_eq_lcs : (lowerCentralSeries R L N k).map N.incl = N.lcs k := by rw [lowerCentralSeries_eq_lcs_comap, LieSubmodule.map_comap_incl, inf_eq_right] apply lcs_le_self #align lie_submodule.lower_central_series_map_eq_lcs LieSubmodule.lowerCentralSeries_map_eq_lcs end LieSubmodule namespace LieModule variable {M₂ : Type w₁} [AddCommGroup M₂] [Module R M₂] [LieRingModule L M₂] [LieModule R L M₂] variable (R L M)
Mathlib/Algebra/Lie/Nilpotent.lean
134
141
theorem antitone_lowerCentralSeries : Antitone <| lowerCentralSeries R L M := by
intro l k induction' k with k ih generalizing l <;> intro h · exact (Nat.le_zero.mp h).symm ▸ le_rfl · rcases Nat.of_le_succ h with (hk | hk) · rw [lowerCentralSeries_succ] exact (LieSubmodule.mono_lie_right _ _ ⊤ (ih hk)).trans (LieSubmodule.lie_le_right _ _) · exact hk.symm ▸ le_rfl
/- Copyright (c) 2019 Gabriel Ebner. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Gabriel Ebner, Sébastien Gouëzel, Yury Kudryashov, Anatole Dedecker -/ import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.FDeriv.Add #align_import analysis.calculus.deriv.add from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # One-dimensional derivatives of sums etc In this file we prove formulas about derivatives of `f + g`, `-f`, `f - g`, and `∑ i, f i x` for functions from the base field to a normed space over this field. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `Analysis/Calculus/Deriv/Basic`. ## Keywords derivative -/ 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 : Filter 𝕜} section Add /-! ### Derivative of the sum of two functions -/ nonrec theorem HasDerivAtFilter.add (hf : HasDerivAtFilter f f' x L) (hg : HasDerivAtFilter g g' x L) : HasDerivAtFilter (fun y => f y + g y) (f' + g') x L := by simpa using (hf.add hg).hasDerivAtFilter #align has_deriv_at_filter.add HasDerivAtFilter.add nonrec theorem HasStrictDerivAt.add (hf : HasStrictDerivAt f f' x) (hg : HasStrictDerivAt g g' x) : HasStrictDerivAt (fun y => f y + g y) (f' + g') x := by simpa using (hf.add hg).hasStrictDerivAt #align has_strict_deriv_at.add HasStrictDerivAt.add nonrec theorem HasDerivWithinAt.add (hf : HasDerivWithinAt f f' s x) (hg : HasDerivWithinAt g g' s x) : HasDerivWithinAt (fun y => f y + g y) (f' + g') s x := hf.add hg #align has_deriv_within_at.add HasDerivWithinAt.add nonrec theorem HasDerivAt.add (hf : HasDerivAt f f' x) (hg : HasDerivAt g g' x) : HasDerivAt (fun x => f x + g x) (f' + g') x := hf.add hg #align has_deriv_at.add HasDerivAt.add theorem derivWithin_add (hxs : UniqueDiffWithinAt 𝕜 s x) (hf : DifferentiableWithinAt 𝕜 f s x) (hg : DifferentiableWithinAt 𝕜 g s x) : derivWithin (fun y => f y + g y) s x = derivWithin f s x + derivWithin g s x := (hf.hasDerivWithinAt.add hg.hasDerivWithinAt).derivWithin hxs #align deriv_within_add derivWithin_add @[simp] theorem deriv_add (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) : deriv (fun y => f y + g y) x = deriv f x + deriv g x := (hf.hasDerivAt.add hg.hasDerivAt).deriv #align deriv_add deriv_add -- Porting note (#10756): new theorem theorem HasStrictDerivAt.add_const (c : F) (hf : HasStrictDerivAt f f' x) : HasStrictDerivAt (fun y ↦ f y + c) f' x := add_zero f' ▸ hf.add (hasStrictDerivAt_const x c) theorem HasDerivAtFilter.add_const (hf : HasDerivAtFilter f f' x L) (c : F) : HasDerivAtFilter (fun y => f y + c) f' x L := add_zero f' ▸ hf.add (hasDerivAtFilter_const x L c) #align has_deriv_at_filter.add_const HasDerivAtFilter.add_const nonrec theorem HasDerivWithinAt.add_const (hf : HasDerivWithinAt f f' s x) (c : F) : HasDerivWithinAt (fun y => f y + c) f' s x := hf.add_const c #align has_deriv_within_at.add_const HasDerivWithinAt.add_const nonrec theorem HasDerivAt.add_const (hf : HasDerivAt f f' x) (c : F) : HasDerivAt (fun x => f x + c) f' x := hf.add_const c #align has_deriv_at.add_const HasDerivAt.add_const
Mathlib/Analysis/Calculus/Deriv/Add.lean
97
99
theorem derivWithin_add_const (hxs : UniqueDiffWithinAt 𝕜 s x) (c : F) : derivWithin (fun y => f y + c) s x = derivWithin f s x := by
simp only [derivWithin, fderivWithin_add_const hxs]
/- Copyright (c) 2020 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau -/ import Mathlib.Algebra.BigOperators.Pi import Mathlib.Algebra.BigOperators.Ring import Mathlib.Algebra.Order.BigOperators.Ring.Finset import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.Group.Submonoid.Membership import Mathlib.Data.Finsupp.Fin import Mathlib.Data.Finsupp.Indicator #align_import algebra.big_operators.finsupp from "leanprover-community/mathlib"@"842328d9df7e96fd90fc424e115679c15fb23a71" /-! # Big operators for finsupps This file contains theorems relevant to big operators in finitely supported functions. -/ noncomputable section open Finset Function variable {α ι γ A B C : Type*} [AddCommMonoid A] [AddCommMonoid B] [AddCommMonoid C] variable {t : ι → A → C} (h0 : ∀ i, t i 0 = 0) (h1 : ∀ i x y, t i (x + y) = t i x + t i y) variable {s : Finset α} {f : α → ι →₀ A} (i : ι) variable (g : ι →₀ A) (k : ι → A → γ → B) (x : γ) variable {β M M' N P G H R S : Type*} namespace Finsupp /-! ### Declarations about `Finsupp.sum` and `Finsupp.prod` In most of this section, the domain `β` is assumed to be an `AddMonoid`. -/ section SumProd /-- `prod f g` is the product of `g a (f a)` over the support of `f`. -/ @[to_additive "`sum f g` is the sum of `g a (f a)` over the support of `f`. "] def prod [Zero M] [CommMonoid N] (f : α →₀ M) (g : α → M → N) : N := ∏ a ∈ f.support, g a (f a) #align finsupp.prod Finsupp.prod #align finsupp.sum Finsupp.sum variable [Zero M] [Zero M'] [CommMonoid N] @[to_additive]
Mathlib/Algebra/BigOperators/Finsupp.lean
54
57
theorem prod_of_support_subset (f : α →₀ M) {s : Finset α} (hs : f.support ⊆ s) (g : α → M → N) (h : ∀ i ∈ s, g i 0 = 1) : f.prod g = ∏ x ∈ s, g x (f x) := by
refine Finset.prod_subset hs fun x hxs hx => h x hxs ▸ (congr_arg (g x) ?_) exact not_mem_support_iff.1 hx
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.List.Sublists import Mathlib.Data.Multiset.Bind #align_import data.multiset.powerset from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # The powerset of a multiset -/ namespace Multiset open List variable {α : Type*} /-! ### powerset -/ -- Porting note (#11215): TODO: Write a more efficient version /-- A helper function for the powerset of a multiset. Given a list `l`, returns a list of sublists of `l` as multisets. -/ def powersetAux (l : List α) : List (Multiset α) := (sublists l).map (↑) #align multiset.powerset_aux Multiset.powersetAux theorem powersetAux_eq_map_coe {l : List α} : powersetAux l = (sublists l).map (↑) := rfl #align multiset.powerset_aux_eq_map_coe Multiset.powersetAux_eq_map_coe @[simp] theorem mem_powersetAux {l : List α} {s} : s ∈ powersetAux l ↔ s ≤ ↑l := Quotient.inductionOn s <| by simp [powersetAux_eq_map_coe, Subperm, and_comm] #align multiset.mem_powerset_aux Multiset.mem_powersetAux /-- Helper function for the powerset of a multiset. Given a list `l`, returns a list of sublists of `l` (using `sublists'`), as multisets. -/ def powersetAux' (l : List α) : List (Multiset α) := (sublists' l).map (↑) #align multiset.powerset_aux' Multiset.powersetAux' theorem powersetAux_perm_powersetAux' {l : List α} : powersetAux l ~ powersetAux' l := by rw [powersetAux_eq_map_coe]; exact (sublists_perm_sublists' _).map _ #align multiset.powerset_aux_perm_powerset_aux' Multiset.powersetAux_perm_powersetAux' @[simp] theorem powersetAux'_nil : powersetAux' (@nil α) = [0] := rfl #align multiset.powerset_aux'_nil Multiset.powersetAux'_nil @[simp]
Mathlib/Data/Multiset/Powerset.lean
55
57
theorem powersetAux'_cons (a : α) (l : List α) : powersetAux' (a :: l) = powersetAux' l ++ List.map (cons a) (powersetAux' l) := by
simp only [powersetAux', sublists'_cons, map_append, List.map_map, append_cancel_left_eq]; rfl
/- Copyright (c) 2024 Xavier Roblot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Xavier Roblot -/ import Mathlib.NumberTheory.NumberField.Basic import Mathlib.RingTheory.FractionalIdeal.Norm import Mathlib.RingTheory.FractionalIdeal.Operations /-! # Fractional ideals of number fields Prove some results on the fractional ideals of number fields. ## Main definitions and results * `NumberField.basisOfFractionalIdeal`: A `ℚ`-basis of `K` that spans `I` over `ℤ` where `I` is a fractional ideal of a number field `K`. * `NumberField.det_basisOfFractionalIdeal_eq_absNorm`: for `I` a fractional ideal of a number field `K`, the absolute value of the determinant of the base change from `integralBasis` to `basisOfFractionalIdeal I` is equal to the norm of `I`. -/ variable (K : Type*) [Field K] [NumberField K] namespace NumberField open scoped nonZeroDivisors section Basis open Module -- This is necessary to avoid several timeouts attribute [local instance 2000] Submodule.module instance (I : FractionalIdeal (𝓞 K)⁰ K) : Module.Free ℤ I := by refine Free.of_equiv (LinearEquiv.restrictScalars ℤ (I.equivNum ?_)).symm exact nonZeroDivisors.coe_ne_zero I.den instance (I : FractionalIdeal (𝓞 K)⁰ K) : Module.Finite ℤ I := by refine Module.Finite.of_surjective (LinearEquiv.restrictScalars ℤ (I.equivNum ?_)).symm.toLinearMap (LinearEquiv.surjective _) exact nonZeroDivisors.coe_ne_zero I.den instance (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) : IsLocalizedModule ℤ⁰ ((Submodule.subtype (I : Submodule (𝓞 K) K)).restrictScalars ℤ) where map_units x := by rw [← (Algebra.lmul _ _).commutes, Algebra.lmul_isUnit_iff, isUnit_iff_ne_zero, eq_intCast, Int.cast_ne_zero] exact nonZeroDivisors.coe_ne_zero x surj' x := by obtain ⟨⟨a, _, d, hd, rfl⟩, h⟩ := IsLocalization.surj (Algebra.algebraMapSubmonoid (𝓞 K) ℤ⁰) x refine ⟨⟨⟨Ideal.absNorm I.1.num * (algebraMap _ K a), I.1.num_le ?_⟩, d * Ideal.absNorm I.1.num, ?_⟩ , ?_⟩ · simp_rw [FractionalIdeal.val_eq_coe, FractionalIdeal.coe_coeIdeal] refine (IsLocalization.mem_coeSubmodule _ _).mpr ⟨Ideal.absNorm I.1.num * a, ?_, ?_⟩ · exact Ideal.mul_mem_right _ _ I.1.num.absNorm_mem · rw [map_mul, map_natCast] · refine Submonoid.mul_mem _ hd (mem_nonZeroDivisors_of_ne_zero ?_) rw [Nat.cast_ne_zero, ne_eq, Ideal.absNorm_eq_zero_iff] exact FractionalIdeal.num_eq_zero_iff.not.mpr <| Units.ne_zero I · simp_rw [LinearMap.coe_restrictScalars, Submodule.coeSubtype] at h ⊢ rw [← h] simp only [Submonoid.mk_smul, zsmul_eq_mul, Int.cast_mul, Int.cast_natCast, algebraMap_int_eq, eq_intCast, map_intCast] ring exists_of_eq h := ⟨1, by rwa [one_smul, one_smul, ← (Submodule.injective_subtype I.1.coeToSubmodule).eq_iff]⟩ /-- A `ℤ`-basis of a fractional ideal. -/ noncomputable def fractionalIdealBasis (I : FractionalIdeal (𝓞 K)⁰ K) : Basis (Free.ChooseBasisIndex ℤ I) ℤ I := Free.chooseBasis ℤ I /-- A `ℚ`-basis of `K` that spans `I` over `ℤ`, see `mem_span_basisOfFractionalIdeal` below. -/ noncomputable def basisOfFractionalIdeal (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) : Basis (Free.ChooseBasisIndex ℤ I) ℚ K := (fractionalIdealBasis K I.1).ofIsLocalizedModule ℚ ℤ⁰ ((Submodule.subtype (I : Submodule (𝓞 K) K)).restrictScalars ℤ) theorem basisOfFractionalIdeal_apply (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) (i : Free.ChooseBasisIndex ℤ I) : basisOfFractionalIdeal K I i = fractionalIdealBasis K I.1 i := (fractionalIdealBasis K I.1).ofIsLocalizedModule_apply ℚ ℤ⁰ _ i theorem mem_span_basisOfFractionalIdeal {I : (FractionalIdeal (𝓞 K)⁰ K)ˣ} {x : K} : x ∈ Submodule.span ℤ (Set.range (basisOfFractionalIdeal K I)) ↔ x ∈ (I : Set K) := by rw [basisOfFractionalIdeal, (fractionalIdealBasis K I.1).ofIsLocalizedModule_span ℚ ℤ⁰ _] simp open FiniteDimensional in theorem fractionalIdeal_rank (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) : finrank ℤ I = finrank ℤ (𝓞 K) := by rw [finrank_eq_card_chooseBasisIndex, RingOfIntegers.rank, finrank_eq_card_basis (basisOfFractionalIdeal K I)] end Basis section Norm open Module /-- The absolute value of the determinant of the base change from `integralBasis` to `basisOfFractionalIdeal I` is equal to the norm of `I`. -/
Mathlib/NumberTheory/NumberField/FractionalIdeal.lean
106
114
theorem det_basisOfFractionalIdeal_eq_absNorm (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) (e : (Free.ChooseBasisIndex ℤ (𝓞 K)) ≃ (Free.ChooseBasisIndex ℤ I)) : |(integralBasis K).det ((basisOfFractionalIdeal K I).reindex e.symm)| = FractionalIdeal.absNorm I.1 := by
rw [← FractionalIdeal.abs_det_basis_change (RingOfIntegers.basis K) I.1 ((fractionalIdealBasis K I.1).reindex e.symm)] congr ext simpa using basisOfFractionalIdeal_apply K I _
/- 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.FieldTheory.RatFunc.Basic import Mathlib.RingTheory.EuclideanDomain import Mathlib.RingTheory.Localization.FractionRing import Mathlib.RingTheory.Polynomial.Content /-! # Generalities on the polynomial structure of rational functions ## Main definitions - `RatFunc.C` is the constant polynomial - `RatFunc.X` is the indeterminate - `RatFunc.eval` evaluates a rational function given a value for the indeterminate -/ noncomputable section universe u variable {K : Type u} namespace RatFunc section Eval open scoped Classical open scoped nonZeroDivisors Polynomial open RatFunc /-! ### Polynomial structure: `C`, `X`, `eval` -/ section Domain variable [CommRing K] [IsDomain K] /-- `RatFunc.C a` is the constant rational function `a`. -/ def C : K →+* RatFunc K := algebraMap _ _ set_option linter.uppercaseLean3 false in #align ratfunc.C RatFunc.C @[simp] theorem algebraMap_eq_C : algebraMap K (RatFunc K) = C := rfl set_option linter.uppercaseLean3 false in #align ratfunc.algebra_map_eq_C RatFunc.algebraMap_eq_C @[simp] theorem algebraMap_C (a : K) : algebraMap K[X] (RatFunc K) (Polynomial.C a) = C a := rfl set_option linter.uppercaseLean3 false in #align ratfunc.algebra_map_C RatFunc.algebraMap_C @[simp] theorem algebraMap_comp_C : (algebraMap K[X] (RatFunc K)).comp Polynomial.C = C := rfl set_option linter.uppercaseLean3 false in #align ratfunc.algebra_map_comp_C RatFunc.algebraMap_comp_C theorem smul_eq_C_mul (r : K) (x : RatFunc K) : r • x = C r * x := by rw [Algebra.smul_def, algebraMap_eq_C] set_option linter.uppercaseLean3 false in #align ratfunc.smul_eq_C_mul RatFunc.smul_eq_C_mul /-- `RatFunc.X` is the polynomial variable (aka indeterminate). -/ def X : RatFunc K := algebraMap K[X] (RatFunc K) Polynomial.X set_option linter.uppercaseLean3 false in #align ratfunc.X RatFunc.X @[simp] theorem algebraMap_X : algebraMap K[X] (RatFunc K) Polynomial.X = X := rfl set_option linter.uppercaseLean3 false in #align ratfunc.algebra_map_X RatFunc.algebraMap_X end Domain section Field variable [Field K] @[simp] theorem num_C (c : K) : num (C c) = Polynomial.C c := num_algebraMap _ set_option linter.uppercaseLean3 false in #align ratfunc.num_C RatFunc.num_C @[simp] theorem denom_C (c : K) : denom (C c) = 1 := denom_algebraMap _ set_option linter.uppercaseLean3 false in #align ratfunc.denom_C RatFunc.denom_C @[simp] theorem num_X : num (X : RatFunc K) = Polynomial.X := num_algebraMap _ set_option linter.uppercaseLean3 false in #align ratfunc.num_X RatFunc.num_X @[simp] theorem denom_X : denom (X : RatFunc K) = 1 := denom_algebraMap _ set_option linter.uppercaseLean3 false in #align ratfunc.denom_X RatFunc.denom_X theorem X_ne_zero : (X : RatFunc K) ≠ 0 := RatFunc.algebraMap_ne_zero Polynomial.X_ne_zero set_option linter.uppercaseLean3 false in #align ratfunc.X_ne_zero RatFunc.X_ne_zero variable {L : Type u} [Field L] /-- Evaluate a rational function `p` given a ring hom `f` from the scalar field to the target and a value `x` for the variable in the target. Fractions are reduced by clearing common denominators before evaluating: `eval id 1 ((X^2 - 1) / (X - 1)) = eval id 1 (X + 1) = 2`, not `0 / 0 = 0`. -/ def eval (f : K →+* L) (a : L) (p : RatFunc K) : L := (num p).eval₂ f a / (denom p).eval₂ f a #align ratfunc.eval RatFunc.eval variable {f : K →+* L} {a : L}
Mathlib/FieldTheory/RatFunc/AsPolynomial.lean
119
120
theorem eval_eq_zero_of_eval₂_denom_eq_zero {x : RatFunc K} (h : Polynomial.eval₂ f a (denom x) = 0) : eval f a x = 0 := by
rw [eval, h, div_zero]
/- Copyright (c) 2021 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou, Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne -/ import Mathlib.MeasureTheory.Function.SimpleFuncDenseLp #align_import measure_theory.integral.set_to_l1 from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Extension of a linear function from indicators to L1 Let `T : Set α → E →L[ℝ] F` be additive for measurable sets with finite measure, in the sense that for `s, t` two such sets, `s ∩ t = ∅ → T (s ∪ t) = T s + T t`. `T` is akin to a bilinear map on `Set α × E`, or a linear map on indicator functions. This file constructs an extension of `T` to integrable simple functions, which are finite sums of indicators of measurable sets with finite measure, then to integrable functions, which are limits of integrable simple functions. The main result is a continuous linear map `(α →₁[μ] E) →L[ℝ] F`. This extension process is used to define the Bochner integral in the `MeasureTheory.Integral.Bochner` file and the conditional expectation of an integrable function in `MeasureTheory.Function.ConditionalExpectation`. ## Main Definitions - `FinMeasAdditive μ T`: the property that `T` is additive on measurable sets with finite measure. For two such sets, `s ∩ t = ∅ → T (s ∪ t) = T s + T t`. - `DominatedFinMeasAdditive μ T C`: `FinMeasAdditive μ T ∧ ∀ s, ‖T s‖ ≤ C * (μ s).toReal`. This is the property needed to perform the extension from indicators to L1. - `setToL1 (hT : DominatedFinMeasAdditive μ T C) : (α →₁[μ] E) →L[ℝ] F`: the extension of `T` from indicators to L1. - `setToFun μ T (hT : DominatedFinMeasAdditive μ T C) (f : α → E) : F`: a version of the extension which applies to functions (with value 0 if the function is not integrable). ## Properties For most properties of `setToFun`, we provide two lemmas. One version uses hypotheses valid on all sets, like `T = T'`, and a second version which uses a primed name uses hypotheses on measurable sets with finite measure, like `∀ s, MeasurableSet s → μ s < ∞ → T s = T' s`. The lemmas listed here don't show all hypotheses. Refer to the actual lemmas for details. Linearity: - `setToFun_zero_left : setToFun μ 0 hT f = 0` - `setToFun_add_left : setToFun μ (T + T') _ f = setToFun μ T hT f + setToFun μ T' hT' f` - `setToFun_smul_left : setToFun μ (fun s ↦ c • (T s)) (hT.smul c) f = c • setToFun μ T hT f` - `setToFun_zero : setToFun μ T hT (0 : α → E) = 0` - `setToFun_neg : setToFun μ T hT (-f) = - setToFun μ T hT f` If `f` and `g` are integrable: - `setToFun_add : setToFun μ T hT (f + g) = setToFun μ T hT f + setToFun μ T hT g` - `setToFun_sub : setToFun μ T hT (f - g) = setToFun μ T hT f - setToFun μ T hT g` If `T` is verifies `∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x`: - `setToFun_smul : setToFun μ T hT (c • f) = c • setToFun μ T hT f` Other: - `setToFun_congr_ae (h : f =ᵐ[μ] g) : setToFun μ T hT f = setToFun μ T hT g` - `setToFun_measure_zero (h : μ = 0) : setToFun μ T hT f = 0` If the space is a `NormedLatticeAddCommGroup` and `T` is such that `0 ≤ T s x` for `0 ≤ x`, we also prove order-related properties: - `setToFun_mono_left (h : ∀ s x, T s x ≤ T' s x) : setToFun μ T hT f ≤ setToFun μ T' hT' f` - `setToFun_nonneg (hf : 0 ≤ᵐ[μ] f) : 0 ≤ setToFun μ T hT f` - `setToFun_mono (hfg : f ≤ᵐ[μ] g) : setToFun μ T hT f ≤ setToFun μ T hT g` ## Implementation notes The starting object `T : Set α → E →L[ℝ] F` matters only through its restriction on measurable sets with finite measure. Its value on other sets is ignored. -/ noncomputable section open scoped Classical Topology NNReal ENNReal MeasureTheory Pointwise open Set Filter TopologicalSpace ENNReal EMetric namespace MeasureTheory variable {α E F F' G 𝕜 : Type*} {p : ℝ≥0∞} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] [NormedAddCommGroup F'] [NormedSpace ℝ F'] [NormedAddCommGroup G] {m : MeasurableSpace α} {μ : Measure α} local infixr:25 " →ₛ " => SimpleFunc open Finset section FinMeasAdditive /-- A set function is `FinMeasAdditive` if its value on the union of two disjoint measurable sets with finite measure is the sum of its values on each set. -/ def FinMeasAdditive {β} [AddMonoid β] {_ : MeasurableSpace α} (μ : Measure α) (T : Set α → β) : Prop := ∀ s t, MeasurableSet s → MeasurableSet t → μ s ≠ ∞ → μ t ≠ ∞ → s ∩ t = ∅ → T (s ∪ t) = T s + T t #align measure_theory.fin_meas_additive MeasureTheory.FinMeasAdditive namespace FinMeasAdditive variable {β : Type*} [AddCommMonoid β] {T T' : Set α → β} theorem zero : FinMeasAdditive μ (0 : Set α → β) := fun s t _ _ _ _ _ => by simp #align measure_theory.fin_meas_additive.zero MeasureTheory.FinMeasAdditive.zero
Mathlib/MeasureTheory/Integral/SetToL1.lean
105
109
theorem add (hT : FinMeasAdditive μ T) (hT' : FinMeasAdditive μ T') : FinMeasAdditive μ (T + T') := by
intro s t hs ht hμs hμt hst simp only [hT s t hs ht hμs hμt hst, hT' s t hs ht hμs hμt hst, Pi.add_apply] abel
/- Copyright (c) 2021 Henry Swanson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Henry Swanson -/ import Mathlib.Algebra.BigOperators.Ring import Mathlib.Combinatorics.Derangements.Basic import Mathlib.Data.Fintype.BigOperators import Mathlib.Tactic.Ring #align_import combinatorics.derangements.finite from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395" /-! # Derangements on fintypes This file contains lemmas that describe the cardinality of `derangements α` when `α` is a fintype. # Main definitions * `card_derangements_invariant`: A lemma stating that the number of derangements on a type `α` depends only on the cardinality of `α`. * `numDerangements n`: The number of derangements on an n-element set, defined in a computation- friendly way. * `card_derangements_eq_numDerangements`: Proof that `numDerangements` really does compute the number of derangements. * `numDerangements_sum`: A lemma giving an expression for `numDerangements n` in terms of factorials. -/ open derangements Equiv Fintype variable {α : Type*} [DecidableEq α] [Fintype α] instance : DecidablePred (derangements α) := fun _ => Fintype.decidableForallFintype -- Porting note: used to use the tactic delta_instance instance : Fintype (derangements α) := Subtype.fintype (fun (_ : Perm α) => ∀ (x_1 : α), ¬_ = x_1) theorem card_derangements_invariant {α β : Type*} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] (h : card α = card β) : card (derangements α) = card (derangements β) := Fintype.card_congr (Equiv.derangementsCongr <| equivOfCardEq h) #align card_derangements_invariant card_derangements_invariant theorem card_derangements_fin_add_two (n : ℕ) : card (derangements (Fin (n + 2))) = (n + 1) * card (derangements (Fin n)) + (n + 1) * card (derangements (Fin (n + 1))) := by -- get some basic results about the size of fin (n+1) plus or minus an element have h1 : ∀ a : Fin (n + 1), card ({a}ᶜ : Set (Fin (n + 1))) = card (Fin n) := by intro a simp only [Fintype.card_fin, Finset.card_fin, Fintype.card_ofFinset, Finset.filter_ne' _ a, Set.mem_compl_singleton_iff, Finset.card_erase_of_mem (Finset.mem_univ a), add_tsub_cancel_right] have h2 : card (Fin (n + 2)) = card (Option (Fin (n + 1))) := by simp only [card_fin, card_option] -- rewrite the LHS and substitute in our fintype-level equivalence simp only [card_derangements_invariant h2, card_congr (@derangementsRecursionEquiv (Fin (n + 1)) _),-- push the cardinality through the Σ and ⊕ so that we can use `card_n` card_sigma, card_sum, card_derangements_invariant (h1 _), Finset.sum_const, nsmul_eq_mul, Finset.card_fin, mul_add, Nat.cast_id] #align card_derangements_fin_add_two card_derangements_fin_add_two /-- The number of derangements of an `n`-element set. -/ def numDerangements : ℕ → ℕ | 0 => 1 | 1 => 0 | n + 2 => (n + 1) * (numDerangements n + numDerangements (n + 1)) #align num_derangements numDerangements @[simp] theorem numDerangements_zero : numDerangements 0 = 1 := rfl #align num_derangements_zero numDerangements_zero @[simp] theorem numDerangements_one : numDerangements 1 = 0 := rfl #align num_derangements_one numDerangements_one theorem numDerangements_add_two (n : ℕ) : numDerangements (n + 2) = (n + 1) * (numDerangements n + numDerangements (n + 1)) := rfl #align num_derangements_add_two numDerangements_add_two
Mathlib/Combinatorics/Derangements/Finite.lean
87
92
theorem numDerangements_succ (n : ℕ) : (numDerangements (n + 1) : ℤ) = (n + 1) * (numDerangements n : ℤ) - (-1) ^ n := by
induction' n with n hn · rfl · simp only [numDerangements_add_two, hn, pow_succ, Int.ofNat_mul, Int.ofNat_add, Int.ofNat_succ] ring
/- 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.Star.GelfandDuality import Mathlib.Topology.Algebra.StarSubalgebra #align_import analysis.normed_space.star.continuous_functional_calculus from "leanprover-community/mathlib"@"31c24aa72e7b3e5ed97a8412470e904f82b81004" /-! # Continuous functional calculus In this file we construct the `continuousFunctionalCalculus` for a normal element `a` of a (unital) C⋆-algebra over `ℂ`. This is a star algebra equivalence `C(spectrum ℂ a, ℂ) ≃⋆ₐ[ℂ] elementalStarAlgebra ℂ a` which sends the (restriction of) the identity map `ContinuousMap.id ℂ` to the (unique) preimage of `a` under the coercion of `elementalStarAlgebra ℂ a` to `A`. Being a star algebra equivalence between C⋆-algebras, this map is continuous (even an isometry), and by the Stone-Weierstrass theorem it is the unique star algebra equivalence which extends the polynomial functional calculus (i.e., `Polynomial.aeval`). For any continuous function `f : spectrum ℂ a → ℂ`, this makes it possible to define an element `f a` (not valid notation) in the original algebra, which heuristically has the same eigenspaces as `a` and acts on eigenvector of `a` for an eigenvalue `λ` as multiplication by `f λ`. This description is perfectly accurate in finite dimension, but only heuristic in infinite dimension as there might be no genuine eigenvector. In particular, when `f` is a polynomial `∑ cᵢ Xⁱ`, then `f a` is `∑ cᵢ aⁱ`. Also, `id a = a`. This file also includes a proof of the **spectral permanence** theorem for (unital) C⋆-algebras (see `StarSubalgebra.spectrum_eq`) ## Main definitions * `continuousFunctionalCalculus : C(spectrum ℂ a, ℂ) ≃⋆ₐ[ℂ] elementalStarAlgebra ℂ a`: this is the composition of the inverse of the `gelfandStarTransform` with the natural isomorphism induced by the homeomorphism `elementalStarAlgebra.characterSpaceHomeo`. * `elementalStarAlgebra.characterSpaceHomeo` : `characterSpace ℂ (elementalStarAlgebra ℂ a) ≃ₜ spectrum ℂ a`: this homeomorphism is defined by evaluating a character `φ` at `a`, and noting that `φ a ∈ spectrum ℂ a` since `φ` is an algebra homomorphism. Moreover, this map is continuous and bijective and since the spaces involved are compact Hausdorff, it is a homeomorphism. ## Main statements * `StarSubalgebra.coe_isUnit`: for `x : S` in a C⋆-Subalgebra `S` of `A`, then `↑x : A` is a Unit if and only if `x` is a unit. * `StarSubalgebra.spectrum_eq`: **spectral_permanence** for `x : S`, where `S` is a C⋆-Subalgebra of `A`, `spectrum ℂ x = spectrum ℂ (x : A)`. ## Notes The result we have established here is the strongest possible, but it is likely not the version which will be most useful in practice. Future work will include developing an appropriate API for the continuous functional calculus (including one for real-valued functions with real argument that applies to self-adjoint elements of the algebra). -/ open scoped Pointwise ENNReal NNReal ComplexOrder open WeakDual WeakDual.CharacterSpace elementalStarAlgebra variable {A : Type*} [NormedRing A] [NormedAlgebra ℂ A] variable [StarRing A] [CstarRing A] [StarModule ℂ A] instance {R A : Type*} [CommRing R] [StarRing R] [NormedRing A] [Algebra R A] [StarRing A] [ContinuousStar A] [StarModule R A] (a : A) [IsStarNormal a] : NormedCommRing (elementalStarAlgebra R a) := { SubringClass.toNormedRing (elementalStarAlgebra R a) with mul_comm := mul_comm } -- Porting note: these hack instances no longer seem to be necessary #noalign elemental_star_algebra.complex.normed_algebra variable [CompleteSpace A] (a : A) [IsStarNormal a] (S : StarSubalgebra ℂ A) /-- This lemma is used in the proof of `elementalStarAlgebra.isUnit_of_isUnit_of_isStarNormal`, which in turn is the key to spectral permanence `StarSubalgebra.spectrum_eq`, which is itself necessary for the continuous functional calculus. Using the continuous functional calculus, this lemma can be superseded by one that omits the `IsStarNormal` hypothesis. -/
Mathlib/Analysis/NormedSpace/Star/ContinuousFunctionalCalculus.lean
81
94
theorem spectrum_star_mul_self_of_isStarNormal : spectrum ℂ (star a * a) ⊆ Set.Icc (0 : ℂ) ‖star a * a‖ := by
-- this instance should be found automatically, but without providing it Lean goes on a wild -- goose chase when trying to apply `spectrum.gelfandTransform_eq`. --letI := elementalStarAlgebra.Complex.normedAlgebra a rcases subsingleton_or_nontrivial A with ⟨⟩ · simp only [spectrum.of_subsingleton, Set.empty_subset] · set a' : elementalStarAlgebra ℂ a := ⟨a, self_mem ℂ a⟩ refine (spectrum.subset_starSubalgebra (star a' * a')).trans ?_ rw [← spectrum.gelfandTransform_eq (star a' * a'), ContinuousMap.spectrum_eq_range] rintro - ⟨φ, rfl⟩ rw [gelfandTransform_apply_apply ℂ _ (star a' * a') φ, map_mul φ, map_star φ] rw [Complex.eq_coe_norm_of_nonneg (star_mul_self_nonneg _), ← map_star, ← map_mul] exact ⟨by positivity, Complex.real_le_real.2 (AlgHom.norm_apply_le_self φ (star a' * a'))⟩
/- Copyright (c) 2020 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Ken Lee, Chris Hughes -/ import Mathlib.Algebra.BigOperators.Ring import Mathlib.Data.Fintype.Basic import Mathlib.Data.Int.GCD import Mathlib.RingTheory.Coprime.Basic #align_import ring_theory.coprime.lemmas from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226" /-! # Additional lemmas about elements of a ring satisfying `IsCoprime` and elements of a monoid satisfying `IsRelPrime` These lemmas are in a separate file to the definition of `IsCoprime` or `IsRelPrime` as they require more imports. Notably, this includes lemmas about `Finset.prod` as this requires importing BigOperators, and lemmas about `Pow` since these are easiest to prove via `Finset.prod`. -/ universe u v section IsCoprime variable {R : Type u} {I : Type v} [CommSemiring R] {x y z : R} {s : I → R} {t : Finset I} section theorem Int.isCoprime_iff_gcd_eq_one {m n : ℤ} : IsCoprime m n ↔ Int.gcd m n = 1 := by constructor · rintro ⟨a, b, h⟩ have : 1 = m * a + n * b := by rwa [mul_comm m, mul_comm n, eq_comm] exact Nat.dvd_one.mp (Int.gcd_dvd_iff.mpr ⟨a, b, this⟩) · rw [← Int.ofNat_inj, IsCoprime, Int.gcd_eq_gcd_ab, mul_comm m, mul_comm n, Nat.cast_one] intro h exact ⟨_, _, h⟩ theorem Nat.isCoprime_iff_coprime {m n : ℕ} : IsCoprime (m : ℤ) n ↔ Nat.Coprime m n := by rw [Int.isCoprime_iff_gcd_eq_one, Int.gcd_natCast_natCast] #align nat.is_coprime_iff_coprime Nat.isCoprime_iff_coprime alias ⟨IsCoprime.nat_coprime, Nat.Coprime.isCoprime⟩ := Nat.isCoprime_iff_coprime #align is_coprime.nat_coprime IsCoprime.nat_coprime #align nat.coprime.is_coprime Nat.Coprime.isCoprime theorem Nat.Coprime.cast {R : Type*} [CommRing R] {a b : ℕ} (h : Nat.Coprime a b) : IsCoprime (a : R) (b : R) := by rw [← isCoprime_iff_coprime] at h rw [← Int.cast_natCast a, ← Int.cast_natCast b] exact IsCoprime.intCast h theorem ne_zero_or_ne_zero_of_nat_coprime {A : Type u} [CommRing A] [Nontrivial A] {a b : ℕ} (h : Nat.Coprime a b) : (a : A) ≠ 0 ∨ (b : A) ≠ 0 := IsCoprime.ne_zero_or_ne_zero (R := A) <| by simpa only [map_natCast] using IsCoprime.map (Nat.Coprime.isCoprime h) (Int.castRingHom A) theorem IsCoprime.prod_left : (∀ i ∈ t, IsCoprime (s i) x) → IsCoprime (∏ i ∈ t, s i) x := by classical refine Finset.induction_on t (fun _ ↦ isCoprime_one_left) fun b t hbt ih H ↦ ?_ rw [Finset.prod_insert hbt] rw [Finset.forall_mem_insert] at H exact H.1.mul_left (ih H.2) #align is_coprime.prod_left IsCoprime.prod_left theorem IsCoprime.prod_right : (∀ i ∈ t, IsCoprime x (s i)) → IsCoprime x (∏ i ∈ t, s i) := by simpa only [isCoprime_comm] using IsCoprime.prod_left (R := R) #align is_coprime.prod_right IsCoprime.prod_right theorem IsCoprime.prod_left_iff : IsCoprime (∏ i ∈ t, s i) x ↔ ∀ i ∈ t, IsCoprime (s i) x := by classical refine Finset.induction_on t (iff_of_true isCoprime_one_left fun _ ↦ by simp) fun b t hbt ih ↦ ?_ rw [Finset.prod_insert hbt, IsCoprime.mul_left_iff, ih, Finset.forall_mem_insert] #align is_coprime.prod_left_iff IsCoprime.prod_left_iff
Mathlib/RingTheory/Coprime/Lemmas.lean
79
80
theorem IsCoprime.prod_right_iff : IsCoprime x (∏ i ∈ t, s i) ↔ ∀ i ∈ t, IsCoprime x (s i) := by
simpa only [isCoprime_comm] using IsCoprime.prod_left_iff (R := R)
/- 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.SetTheory.Game.Basic import Mathlib.SetTheory.Ordinal.NaturalOps #align_import set_theory.game.ordinal from "leanprover-community/mathlib"@"b90e72c7eebbe8de7c8293a80208ea2ba135c834" /-! # Ordinals as games We define the canonical map `Ordinal → SetTheory.PGame`, where every ordinal is mapped to the game whose left set consists of all previous ordinals. The map to surreals is defined in `Ordinal.toSurreal`. # Main declarations - `Ordinal.toPGame`: The canonical map between ordinals and pre-games. - `Ordinal.toPGameEmbedding`: The order embedding version of the previous map. -/ universe u open SetTheory PGame open scoped NaturalOps PGame namespace Ordinal /-- Converts an ordinal into the corresponding pre-game. -/ noncomputable def toPGame : Ordinal.{u} → PGame.{u} | o => have : IsWellOrder o.out.α (· < ·) := isWellOrder_out_lt o ⟨o.out.α, PEmpty, fun x => have := Ordinal.typein_lt_self x (typein (· < ·) x).toPGame, PEmpty.elim⟩ termination_by x => x #align ordinal.to_pgame Ordinal.toPGame @[nolint unusedHavesSuffices] theorem toPGame_def (o : Ordinal) : have : IsWellOrder o.out.α (· < ·) := isWellOrder_out_lt o o.toPGame = ⟨o.out.α, PEmpty, fun x => (typein (· < ·) x).toPGame, PEmpty.elim⟩ := by rw [toPGame] #align ordinal.to_pgame_def Ordinal.toPGame_def @[simp, nolint unusedHavesSuffices] theorem toPGame_leftMoves (o : Ordinal) : o.toPGame.LeftMoves = o.out.α := by rw [toPGame, LeftMoves] #align ordinal.to_pgame_left_moves Ordinal.toPGame_leftMoves @[simp, nolint unusedHavesSuffices] theorem toPGame_rightMoves (o : Ordinal) : o.toPGame.RightMoves = PEmpty := by rw [toPGame, RightMoves] #align ordinal.to_pgame_right_moves Ordinal.toPGame_rightMoves instance isEmpty_zero_toPGame_leftMoves : IsEmpty (toPGame 0).LeftMoves := by rw [toPGame_leftMoves]; infer_instance #align ordinal.is_empty_zero_to_pgame_left_moves Ordinal.isEmpty_zero_toPGame_leftMoves instance isEmpty_toPGame_rightMoves (o : Ordinal) : IsEmpty o.toPGame.RightMoves := by rw [toPGame_rightMoves]; infer_instance #align ordinal.is_empty_to_pgame_right_moves Ordinal.isEmpty_toPGame_rightMoves /-- Converts an ordinal less than `o` into a move for the `PGame` corresponding to `o`, and vice versa. -/ noncomputable def toLeftMovesToPGame {o : Ordinal} : Set.Iio o ≃ o.toPGame.LeftMoves := (enumIsoOut o).toEquiv.trans (Equiv.cast (toPGame_leftMoves o).symm) #align ordinal.to_left_moves_to_pgame Ordinal.toLeftMovesToPGame @[simp] theorem toLeftMovesToPGame_symm_lt {o : Ordinal} (i : o.toPGame.LeftMoves) : ↑(toLeftMovesToPGame.symm i) < o := (toLeftMovesToPGame.symm i).prop #align ordinal.to_left_moves_to_pgame_symm_lt Ordinal.toLeftMovesToPGame_symm_lt @[nolint unusedHavesSuffices] theorem toPGame_moveLeft_hEq {o : Ordinal} : have : IsWellOrder o.out.α (· < ·) := isWellOrder_out_lt o HEq o.toPGame.moveLeft fun x : o.out.α => (typein (· < ·) x).toPGame := by rw [toPGame] rfl #align ordinal.to_pgame_move_left_heq Ordinal.toPGame_moveLeft_hEq @[simp] theorem toPGame_moveLeft' {o : Ordinal} (i) : o.toPGame.moveLeft i = (toLeftMovesToPGame.symm i).val.toPGame := (congr_heq toPGame_moveLeft_hEq.symm (cast_heq _ i)).symm #align ordinal.to_pgame_move_left' Ordinal.toPGame_moveLeft'
Mathlib/SetTheory/Game/Ordinal.lean
96
97
theorem toPGame_moveLeft {o : Ordinal} (i) : o.toPGame.moveLeft (toLeftMovesToPGame i) = i.val.toPGame := by
simp
/- Copyright (c) 2019 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Sébastien Gouëzel, Yury Kudryashov -/ import Mathlib.Analysis.Asymptotics.AsymptoticEquivalent import Mathlib.Analysis.Calculus.FDeriv.Linear import Mathlib.Analysis.Calculus.FDeriv.Comp #align_import analysis.calculus.fderiv.equiv from "leanprover-community/mathlib"@"e3fb84046afd187b710170887195d50bada934ee" /-! # The derivative of a linear equivalence For detailed documentation of the Fréchet derivative, see the module docstring of `Analysis/Calculus/FDeriv/Basic.lean`. This file contains the usual formulas (and existence assertions) for the derivative of continuous linear equivalences. We also prove the usual formula for the derivative of the inverse function, assuming it exists. The inverse function theorem is in `Mathlib/Analysis/Calculus/InverseFunctionTheorem/FDeriv.lean`. -/ open Filter Asymptotics ContinuousLinearMap Set Metric open scoped Classical open Topology NNReal Filter Asymptotics ENNReal noncomputable section section variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] variable {G' : Type*} [NormedAddCommGroup G'] [NormedSpace 𝕜 G'] variable {f f₀ f₁ g : E → F} variable {f' f₀' f₁' g' : E →L[𝕜] F} variable (e : E →L[𝕜] F) variable {x : E} variable {s t : Set E} variable {L L₁ L₂ : Filter E} namespace ContinuousLinearEquiv /-! ### Differentiability of linear equivs, and invariance of differentiability -/ variable (iso : E ≃L[𝕜] F) @[fun_prop] protected theorem hasStrictFDerivAt : HasStrictFDerivAt iso (iso : E →L[𝕜] F) x := iso.toContinuousLinearMap.hasStrictFDerivAt #align continuous_linear_equiv.has_strict_fderiv_at ContinuousLinearEquiv.hasStrictFDerivAt @[fun_prop] protected theorem hasFDerivWithinAt : HasFDerivWithinAt iso (iso : E →L[𝕜] F) s x := iso.toContinuousLinearMap.hasFDerivWithinAt #align continuous_linear_equiv.has_fderiv_within_at ContinuousLinearEquiv.hasFDerivWithinAt @[fun_prop] protected theorem hasFDerivAt : HasFDerivAt iso (iso : E →L[𝕜] F) x := iso.toContinuousLinearMap.hasFDerivAtFilter #align continuous_linear_equiv.has_fderiv_at ContinuousLinearEquiv.hasFDerivAt @[fun_prop] protected theorem differentiableAt : DifferentiableAt 𝕜 iso x := iso.hasFDerivAt.differentiableAt #align continuous_linear_equiv.differentiable_at ContinuousLinearEquiv.differentiableAt @[fun_prop] protected theorem differentiableWithinAt : DifferentiableWithinAt 𝕜 iso s x := iso.differentiableAt.differentiableWithinAt #align continuous_linear_equiv.differentiable_within_at ContinuousLinearEquiv.differentiableWithinAt protected theorem fderiv : fderiv 𝕜 iso x = iso := iso.hasFDerivAt.fderiv #align continuous_linear_equiv.fderiv ContinuousLinearEquiv.fderiv protected theorem fderivWithin (hxs : UniqueDiffWithinAt 𝕜 s x) : fderivWithin 𝕜 iso s x = iso := iso.toContinuousLinearMap.fderivWithin hxs #align continuous_linear_equiv.fderiv_within ContinuousLinearEquiv.fderivWithin @[fun_prop] protected theorem differentiable : Differentiable 𝕜 iso := fun _ => iso.differentiableAt #align continuous_linear_equiv.differentiable ContinuousLinearEquiv.differentiable @[fun_prop] protected theorem differentiableOn : DifferentiableOn 𝕜 iso s := iso.differentiable.differentiableOn #align continuous_linear_equiv.differentiable_on ContinuousLinearEquiv.differentiableOn theorem comp_differentiableWithinAt_iff {f : G → E} {s : Set G} {x : G} : DifferentiableWithinAt 𝕜 (iso ∘ f) s x ↔ DifferentiableWithinAt 𝕜 f s x := by refine ⟨fun H => ?_, fun H => iso.differentiable.differentiableAt.comp_differentiableWithinAt x H⟩ have : DifferentiableWithinAt 𝕜 (iso.symm ∘ iso ∘ f) s x := iso.symm.differentiable.differentiableAt.comp_differentiableWithinAt x H rwa [← Function.comp.assoc iso.symm iso f, iso.symm_comp_self] at this #align continuous_linear_equiv.comp_differentiable_within_at_iff ContinuousLinearEquiv.comp_differentiableWithinAt_iff theorem comp_differentiableAt_iff {f : G → E} {x : G} : DifferentiableAt 𝕜 (iso ∘ f) x ↔ DifferentiableAt 𝕜 f x := by rw [← differentiableWithinAt_univ, ← differentiableWithinAt_univ, iso.comp_differentiableWithinAt_iff] #align continuous_linear_equiv.comp_differentiable_at_iff ContinuousLinearEquiv.comp_differentiableAt_iff theorem comp_differentiableOn_iff {f : G → E} {s : Set G} : DifferentiableOn 𝕜 (iso ∘ f) s ↔ DifferentiableOn 𝕜 f s := by rw [DifferentiableOn, DifferentiableOn] simp only [iso.comp_differentiableWithinAt_iff] #align continuous_linear_equiv.comp_differentiable_on_iff ContinuousLinearEquiv.comp_differentiableOn_iff theorem comp_differentiable_iff {f : G → E} : Differentiable 𝕜 (iso ∘ f) ↔ Differentiable 𝕜 f := by rw [← differentiableOn_univ, ← differentiableOn_univ] exact iso.comp_differentiableOn_iff #align continuous_linear_equiv.comp_differentiable_iff ContinuousLinearEquiv.comp_differentiable_iff
Mathlib/Analysis/Calculus/FDeriv/Equiv.lean
121
130
theorem comp_hasFDerivWithinAt_iff {f : G → E} {s : Set G} {x : G} {f' : G →L[𝕜] E} : HasFDerivWithinAt (iso ∘ f) ((iso : E →L[𝕜] F).comp f') s x ↔ HasFDerivWithinAt f f' s x := by
refine ⟨fun H => ?_, fun H => iso.hasFDerivAt.comp_hasFDerivWithinAt x H⟩ have A : f = iso.symm ∘ iso ∘ f := by rw [← Function.comp.assoc, iso.symm_comp_self] rfl have B : f' = (iso.symm : F →L[𝕜] E).comp ((iso : E →L[𝕜] F).comp f') := by rw [← ContinuousLinearMap.comp_assoc, iso.coe_symm_comp_coe, ContinuousLinearMap.id_comp] rw [A, B] exact iso.symm.hasFDerivAt.comp_hasFDerivWithinAt x H
/- Copyright (c) 2016 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura -/ import Mathlib.Init.Order.Defs #align_import init.algebra.functions from "leanprover-community/lean"@"c2bcdbcbe741ed37c361a30d38e179182b989f76" /-! # Basic lemmas about linear orders. The contents of this file came from `init.algebra.functions` in Lean 3, and it would be good to find everything a better home. -/ universe u section open Decidable variable {α : Type u} [LinearOrder α] theorem min_def (a b : α) : min a b = if a ≤ b then a else b := by rw [LinearOrder.min_def a] #align min_def min_def theorem max_def (a b : α) : max a b = if a ≤ b then b else a := by rw [LinearOrder.max_def a] #align max_def max_def theorem min_le_left (a b : α) : min a b ≤ a := by -- Porting note: no `min_tac` tactic if h : a ≤ b then simp [min_def, if_pos h, le_refl] else simp [min_def, if_neg h]; exact le_of_not_le h #align min_le_left min_le_left
Mathlib/Init/Order/LinearOrder.lean
40
44
theorem min_le_right (a b : α) : min a b ≤ b := by
-- Porting note: no `min_tac` tactic if h : a ≤ b then simp [min_def, if_pos h]; exact h else simp [min_def, if_neg h, le_refl]
/- Copyright (c) 2018 Robert Y. Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Y. Lewis, Chris Hughes -/ import Mathlib.Algebra.Associated import Mathlib.Algebra.BigOperators.Group.Finset import Mathlib.Algebra.SMulWithZero import Mathlib.Data.Nat.PartENat import Mathlib.Tactic.Linarith #align_import ring_theory.multiplicity from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" /-! # Multiplicity of a divisor For a commutative monoid, this file introduces the notion of multiplicity of a divisor and proves several basic results on it. ## Main definitions * `multiplicity a b`: for two elements `a` and `b` of a commutative monoid returns the largest number `n` such that `a ^ n ∣ b` or infinity, written `⊤`, if `a ^ n ∣ b` for all natural numbers `n`. * `multiplicity.Finite a b`: a predicate denoting that the multiplicity of `a` in `b` is finite. -/ variable {α β : Type*} open Nat Part /-- `multiplicity a b` returns the largest natural number `n` such that `a ^ n ∣ b`, as a `PartENat` or natural with infinity. If `∀ n, a ^ n ∣ b`, then it returns `⊤`-/ def multiplicity [Monoid α] [DecidableRel ((· ∣ ·) : α → α → Prop)] (a b : α) : PartENat := PartENat.find fun n => ¬a ^ (n + 1) ∣ b #align multiplicity multiplicity namespace multiplicity section Monoid variable [Monoid α] [Monoid β] /-- `multiplicity.Finite a b` indicates that the multiplicity of `a` in `b` is finite. -/ abbrev Finite (a b : α) : Prop := ∃ n : ℕ, ¬a ^ (n + 1) ∣ b #align multiplicity.finite multiplicity.Finite theorem finite_iff_dom [DecidableRel ((· ∣ ·) : α → α → Prop)] {a b : α} : Finite a b ↔ (multiplicity a b).Dom := Iff.rfl #align multiplicity.finite_iff_dom multiplicity.finite_iff_dom theorem finite_def {a b : α} : Finite a b ↔ ∃ n : ℕ, ¬a ^ (n + 1) ∣ b := Iff.rfl #align multiplicity.finite_def multiplicity.finite_def theorem not_dvd_one_of_finite_one_right {a : α} : Finite a 1 → ¬a ∣ 1 := fun ⟨n, hn⟩ ⟨d, hd⟩ => hn ⟨d ^ (n + 1), (pow_mul_pow_eq_one (n + 1) hd.symm).symm⟩ #align multiplicity.not_dvd_one_of_finite_one_right multiplicity.not_dvd_one_of_finite_one_right @[norm_cast] theorem Int.natCast_multiplicity (a b : ℕ) : multiplicity (a : ℤ) (b : ℤ) = multiplicity a b := by apply Part.ext' · rw [← @finite_iff_dom ℕ, @finite_def ℕ, ← @finite_iff_dom ℤ, @finite_def ℤ] norm_cast · intro h1 h2 apply _root_.le_antisymm <;> · apply Nat.find_mono norm_cast simp #align multiplicity.int.coe_nat_multiplicity multiplicity.Int.natCast_multiplicity @[deprecated (since := "2024-04-05")] alias Int.coe_nat_multiplicity := Int.natCast_multiplicity theorem not_finite_iff_forall {a b : α} : ¬Finite a b ↔ ∀ n : ℕ, a ^ n ∣ b := ⟨fun h n => Nat.casesOn n (by rw [_root_.pow_zero] exact one_dvd _) (by simpa [Finite, Classical.not_not] using h), by simp [Finite, multiplicity, Classical.not_not]; tauto⟩ #align multiplicity.not_finite_iff_forall multiplicity.not_finite_iff_forall theorem not_unit_of_finite {a b : α} (h : Finite a b) : ¬IsUnit a := let ⟨n, hn⟩ := h hn ∘ IsUnit.dvd ∘ IsUnit.pow (n + 1) #align multiplicity.not_unit_of_finite multiplicity.not_unit_of_finite theorem finite_of_finite_mul_right {a b c : α} : Finite a (b * c) → Finite a b := fun ⟨n, hn⟩ => ⟨n, fun h => hn (h.trans (dvd_mul_right _ _))⟩ #align multiplicity.finite_of_finite_mul_right multiplicity.finite_of_finite_mul_right variable [DecidableRel ((· ∣ ·) : α → α → Prop)] [DecidableRel ((· ∣ ·) : β → β → Prop)]
Mathlib/RingTheory/Multiplicity.lean
99
107
theorem pow_dvd_of_le_multiplicity {a b : α} {k : ℕ} : (k : PartENat) ≤ multiplicity a b → a ^ k ∣ b := by
rw [← PartENat.some_eq_natCast] exact Nat.casesOn k (fun _ => by rw [_root_.pow_zero] exact one_dvd _) fun k ⟨_, h₂⟩ => by_contradiction fun hk => Nat.find_min _ (lt_of_succ_le (h₂ ⟨k, hk⟩)) hk
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Robert Y. Lewis -/ import Mathlib.Algebra.CharP.Invertible import Mathlib.Algebra.MvPolynomial.Variables import Mathlib.Algebra.MvPolynomial.CommRing import Mathlib.Algebra.MvPolynomial.Expand import Mathlib.Data.Fintype.BigOperators import Mathlib.Data.ZMod.Basic #align_import ring_theory.witt_vector.witt_polynomial from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395" /-! # Witt polynomials To endow `WittVector p R` with a ring structure, we need to study the so-called Witt polynomials. Fix a base value `p : ℕ`. The `p`-adic Witt polynomials are an infinite family of polynomials indexed by a natural number `n`, taking values in an arbitrary ring `R`. The variables of these polynomials are represented by natural numbers. The variable set of the `n`th Witt polynomial contains at most `n+1` elements `{0, ..., n}`, with exactly these variables when `R` has characteristic `0`. These polynomials are used to define the addition and multiplication operators on the type of Witt vectors. (While this type itself is not complicated, the ring operations are what make it interesting.) When the base `p` is invertible in `R`, the `p`-adic Witt polynomials form a basis for `MvPolynomial ℕ R`, equivalent to the standard basis. ## Main declarations * `WittPolynomial p R n`: the `n`-th Witt polynomial, viewed as polynomial over the ring `R` * `xInTermsOfW p R n`: if `p` is invertible, the polynomial `X n` is contained in the subalgebra generated by the Witt polynomials. `xInTermsOfW p R n` is the explicit polynomial, which upon being bound to the Witt polynomials yields `X n`. * `bind₁_wittPolynomial_xInTermsOfW`: the proof of the claim that `bind₁ (xInTermsOfW p R) (W_ R n) = X n` * `bind₁_xInTermsOfW_wittPolynomial`: the converse of the above statement ## Notation In this file we use the following notation * `p` is a natural number, typically assumed to be prime. * `R` and `S` are commutative rings * `W n` (and `W_ R n` when the ring needs to be explicit) denotes the `n`th Witt polynomial ## References * [Hazewinkel, *Witt Vectors*][Haze09] * [Commelin and Lewis, *Formalizing the Ring of Witt Vectors*][CL21] -/ open MvPolynomial open Finset hiding map open Finsupp (single) --attribute [-simp] coe_eval₂_hom variable (p : ℕ) variable (R : Type*) [CommRing R] [DecidableEq R] /-- `wittPolynomial p R n` is the `n`-th Witt polynomial with respect to a prime `p` with coefficients in a commutative ring `R`. It is defined as: `∑_{i ≤ n} p^i X_i^{p^{n-i}} ∈ R[X_0, X_1, X_2, …]`. -/ noncomputable def wittPolynomial (n : ℕ) : MvPolynomial ℕ R := ∑ i ∈ range (n + 1), monomial (single i (p ^ (n - i))) ((p : R) ^ i) #align witt_polynomial wittPolynomial theorem wittPolynomial_eq_sum_C_mul_X_pow (n : ℕ) : wittPolynomial p R n = ∑ i ∈ range (n + 1), C ((p : R) ^ i) * X i ^ p ^ (n - i) := by apply sum_congr rfl rintro i - rw [monomial_eq, Finsupp.prod_single_index] rw [pow_zero] set_option linter.uppercaseLean3 false in #align witt_polynomial_eq_sum_C_mul_X_pow wittPolynomial_eq_sum_C_mul_X_pow /-! We set up notation locally to this file, to keep statements short and comprehensible. This allows us to simply write `W n` or `W_ ℤ n`. -/ -- Notation with ring of coefficients explicit set_option quotPrecheck false in @[inherit_doc] scoped[Witt] notation "W_" => wittPolynomial p -- Notation with ring of coefficients implicit set_option quotPrecheck false in @[inherit_doc] scoped[Witt] notation "W" => wittPolynomial p _ open Witt open MvPolynomial /-! The first observation is that the Witt polynomial doesn't really depend on the coefficient ring. If we map the coefficients through a ring homomorphism, we obtain the corresponding Witt polynomial over the target ring. -/ section variable {R} {S : Type*} [CommRing S] @[simp] theorem map_wittPolynomial (f : R →+* S) (n : ℕ) : map f (W n) = W n := by rw [wittPolynomial, map_sum, wittPolynomial] refine sum_congr rfl fun i _ => ?_ rw [map_monomial, RingHom.map_pow, map_natCast] #align map_witt_polynomial map_wittPolynomial variable (R) @[simp] theorem constantCoeff_wittPolynomial [hp : Fact p.Prime] (n : ℕ) : constantCoeff (wittPolynomial p R n) = 0 := by simp only [wittPolynomial, map_sum, constantCoeff_monomial] rw [sum_eq_zero] rintro i _ rw [if_neg] rw [Finsupp.single_eq_zero] exact ne_of_gt (pow_pos hp.1.pos _) #align constant_coeff_witt_polynomial constantCoeff_wittPolynomial @[simp]
Mathlib/RingTheory/WittVector/WittPolynomial.lean
136
137
theorem wittPolynomial_zero : wittPolynomial p R 0 = X 0 := by
simp only [wittPolynomial, X, sum_singleton, range_one, pow_zero, zero_add, tsub_self]
/- Copyright (c) 2022 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa -/ import Mathlib.Algebra.MonoidAlgebra.Basic import Mathlib.Data.Finset.Pointwise #align_import algebra.monoid_algebra.support from "leanprover-community/mathlib"@"16749fc4661828cba18cd0f4e3c5eb66a8e80598" /-! # Lemmas about the support of a finitely supported function -/ open scoped Pointwise universe u₁ u₂ u₃ namespace MonoidAlgebra open Finset Finsupp variable {k : Type u₁} {G : Type u₂} [Semiring k] theorem support_mul [Mul G] [DecidableEq G] (a b : MonoidAlgebra k G) : (a * b).support ⊆ a.support * b.support := by rw [MonoidAlgebra.mul_def] exact support_sum.trans <| biUnion_subset.2 fun _x hx ↦ support_sum.trans <| biUnion_subset.2 fun _y hy ↦ support_single_subset.trans <| singleton_subset_iff.2 <| mem_image₂_of_mem hx hy #align monoid_algebra.support_mul MonoidAlgebra.support_mul theorem support_single_mul_subset [DecidableEq G] [Mul G] (f : MonoidAlgebra k G) (r : k) (a : G) : (single a r * f : MonoidAlgebra k G).support ⊆ Finset.image (a * ·) f.support := (support_mul _ _).trans <| (Finset.image₂_subset_right support_single_subset).trans <| by rw [Finset.image₂_singleton_left] #align monoid_algebra.support_single_mul_subset MonoidAlgebra.support_single_mul_subset theorem support_mul_single_subset [DecidableEq G] [Mul G] (f : MonoidAlgebra k G) (r : k) (a : G) : (f * single a r).support ⊆ Finset.image (· * a) f.support := (support_mul _ _).trans <| (Finset.image₂_subset_left support_single_subset).trans <| by rw [Finset.image₂_singleton_right] #align monoid_algebra.support_mul_single_subset MonoidAlgebra.support_mul_single_subset
Mathlib/Algebra/MonoidAlgebra/Support.lean
45
52
theorem support_single_mul_eq_image [DecidableEq G] [Mul G] (f : MonoidAlgebra k G) {r : k} (hr : ∀ y, r * y = 0 ↔ y = 0) {x : G} (lx : IsLeftRegular x) : (single x r * f : MonoidAlgebra k G).support = Finset.image (x * ·) f.support := by
refine subset_antisymm (support_single_mul_subset f _ _) fun y hy => ?_ obtain ⟨y, yf, rfl⟩ : ∃ a : G, a ∈ f.support ∧ x * a = y := by simpa only [Finset.mem_image, exists_prop] using hy simp only [mul_apply, mem_support_iff.mp yf, hr, mem_support_iff, sum_single_index, Finsupp.sum_ite_eq', Ne, not_false_iff, if_true, zero_mul, ite_self, sum_zero, lx.eq_iff]
/- 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 theorem gal_C_isSolvable (x : F) : IsSolvable (C x).Gal := by infer_instance set_option linter.uppercaseLean3 false in #align gal_C_is_solvable gal_C_isSolvable theorem gal_X_isSolvable : IsSolvable (X : F[X]).Gal := by infer_instance set_option linter.uppercaseLean3 false in #align gal_X_is_solvable gal_X_isSolvable theorem gal_X_sub_C_isSolvable (x : F) : IsSolvable (X - C x).Gal := by infer_instance set_option linter.uppercaseLean3 false in #align gal_X_sub_C_is_solvable gal_X_sub_C_isSolvable theorem gal_X_pow_isSolvable (n : ℕ) : IsSolvable (X ^ n : F[X]).Gal := by infer_instance set_option linter.uppercaseLean3 false in #align gal_X_pow_is_solvable gal_X_pow_isSolvable theorem gal_mul_isSolvable {p q : F[X]} (_ : IsSolvable p.Gal) (_ : IsSolvable q.Gal) : IsSolvable (p * q).Gal := solvable_of_solvable_injective (Gal.restrictProd_injective p q) #align gal_mul_is_solvable gal_mul_isSolvable
Mathlib/FieldTheory/AbelRuffini.lean
66
72
theorem gal_prod_isSolvable {s : Multiset F[X]} (hs : ∀ p ∈ s, IsSolvable (Gal p)) : IsSolvable s.prod.Gal := by
apply Multiset.induction_on' s · exact gal_one_isSolvable · intro p t hps _ ht rw [Multiset.insert_eq_cons, Multiset.prod_cons] exact gal_mul_isSolvable (hs p hps) ht
/- 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.RingTheory.Polynomial.Pochhammer #align_import data.nat.factorial.cast from "leanprover-community/mathlib"@"d50b12ae8e2bd910d08a94823976adae9825718b" /-! # Cast of factorials This file allows calculating factorials (including ascending and descending ones) as elements of a semiring. This is particularly crucial for `Nat.descFactorial` as subtraction on `ℕ` does **not** correspond to subtraction on a general semiring. For example, we can't rely on existing cast lemmas to prove `↑(a.descFactorial 2) = ↑a * (↑a - 1)`. We must use the fact that, whenever `↑(a - 1)` is not equal to `↑a - 1`, the other factor is `0` anyway. -/ open Nat variable (S : Type*) namespace Nat section Semiring variable [Semiring S] (a b : ℕ) -- Porting note: added type ascription around a + 1 theorem cast_ascFactorial : (a.ascFactorial b : S) = (ascPochhammer S b).eval (a : S) := by rw [← ascPochhammer_nat_eq_ascFactorial, ascPochhammer_eval_cast] #align nat.cast_asc_factorial Nat.cast_ascFactorial -- Porting note: added type ascription around a - (b - 1)
Mathlib/Data/Nat/Factorial/Cast.lean
39
48
theorem cast_descFactorial : (a.descFactorial b : S) = (ascPochhammer S b).eval (a - (b - 1) : S) := by
rw [← ascPochhammer_eval_cast, ascPochhammer_nat_eq_descFactorial] induction' b with b · simp · simp_rw [add_succ, Nat.add_one_sub_one] obtain h | h := le_total a b · rw [descFactorial_of_lt (lt_succ_of_le h), descFactorial_of_lt (lt_succ_of_le _)] rw [tsub_eq_zero_iff_le.mpr h, zero_add] · rw [tsub_add_cancel_of_le h]
/- 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 _ _ _ _
Mathlib/Analysis/InnerProductSpace/LaxMilgram.lean
51
62
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]
/- 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.Exp import Mathlib.Tactic.Positivity.Core import Mathlib.Algebra.Ring.NegOnePow #align_import analysis.special_functions.trigonometric.basic from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" /-! # Trigonometric functions ## Main definitions This file contains the definition of `π`. See also `Analysis.SpecialFunctions.Trigonometric.Inverse` and `Analysis.SpecialFunctions.Trigonometric.Arctan` for the inverse trigonometric functions. See also `Analysis.SpecialFunctions.Complex.Arg` and `Analysis.SpecialFunctions.Complex.Log` for the complex argument function and the complex logarithm. ## Main statements Many basic inequalities on the real trigonometric functions are established. The continuity of the usual trigonometric functions is proved. Several facts about the real trigonometric functions have the proofs deferred to `Analysis.SpecialFunctions.Trigonometric.Complex`, as they are most easily proved by appealing to the corresponding fact for complex trigonometric functions. See also `Analysis.SpecialFunctions.Trigonometric.Chebyshev` for the multiple angle formulas in terms of Chebyshev polynomials. ## Tags sin, cos, tan, angle -/ noncomputable section open scoped Classical open Topology Filter Set namespace Complex @[continuity, fun_prop] theorem continuous_sin : Continuous sin := by change Continuous fun z => (exp (-z * I) - exp (z * I)) * I / 2 continuity #align complex.continuous_sin Complex.continuous_sin @[fun_prop] theorem continuousOn_sin {s : Set ℂ} : ContinuousOn sin s := continuous_sin.continuousOn #align complex.continuous_on_sin Complex.continuousOn_sin @[continuity, fun_prop] theorem continuous_cos : Continuous cos := by change Continuous fun z => (exp (z * I) + exp (-z * I)) / 2 continuity #align complex.continuous_cos Complex.continuous_cos @[fun_prop] theorem continuousOn_cos {s : Set ℂ} : ContinuousOn cos s := continuous_cos.continuousOn #align complex.continuous_on_cos Complex.continuousOn_cos @[continuity, fun_prop] theorem continuous_sinh : Continuous sinh := by change Continuous fun z => (exp z - exp (-z)) / 2 continuity #align complex.continuous_sinh Complex.continuous_sinh @[continuity, fun_prop] theorem continuous_cosh : Continuous cosh := by change Continuous fun z => (exp z + exp (-z)) / 2 continuity #align complex.continuous_cosh Complex.continuous_cosh end Complex namespace Real variable {x y z : ℝ} @[continuity, fun_prop] theorem continuous_sin : Continuous sin := Complex.continuous_re.comp (Complex.continuous_sin.comp Complex.continuous_ofReal) #align real.continuous_sin Real.continuous_sin @[fun_prop] theorem continuousOn_sin {s} : ContinuousOn sin s := continuous_sin.continuousOn #align real.continuous_on_sin Real.continuousOn_sin @[continuity, fun_prop] theorem continuous_cos : Continuous cos := Complex.continuous_re.comp (Complex.continuous_cos.comp Complex.continuous_ofReal) #align real.continuous_cos Real.continuous_cos @[fun_prop] theorem continuousOn_cos {s} : ContinuousOn cos s := continuous_cos.continuousOn #align real.continuous_on_cos Real.continuousOn_cos @[continuity, fun_prop] theorem continuous_sinh : Continuous sinh := Complex.continuous_re.comp (Complex.continuous_sinh.comp Complex.continuous_ofReal) #align real.continuous_sinh Real.continuous_sinh @[continuity, fun_prop] theorem continuous_cosh : Continuous cosh := Complex.continuous_re.comp (Complex.continuous_cosh.comp Complex.continuous_ofReal) #align real.continuous_cosh Real.continuous_cosh end Real namespace Real theorem exists_cos_eq_zero : 0 ∈ cos '' Icc (1 : ℝ) 2 := intermediate_value_Icc' (by norm_num) continuousOn_cos ⟨le_of_lt cos_two_neg, le_of_lt cos_one_pos⟩ #align real.exists_cos_eq_zero Real.exists_cos_eq_zero /-- The number π = 3.14159265... Defined here using choice as twice a zero of cos in [1,2], from which one can derive all its properties. For explicit bounds on π, see `Data.Real.Pi.Bounds`. -/ protected noncomputable def pi : ℝ := 2 * Classical.choose exists_cos_eq_zero #align real.pi Real.pi @[inherit_doc] scoped notation "π" => Real.pi @[simp] theorem cos_pi_div_two : cos (π / 2) = 0 := by rw [Real.pi, mul_div_cancel_left₀ _ (two_ne_zero' ℝ)] exact (Classical.choose_spec exists_cos_eq_zero).2 #align real.cos_pi_div_two Real.cos_pi_div_two
Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean
147
149
theorem one_le_pi_div_two : (1 : ℝ) ≤ π / 2 := by
rw [Real.pi, mul_div_cancel_left₀ _ (two_ne_zero' ℝ)] exact (Classical.choose_spec exists_cos_eq_zero).1.1
/- Copyright (c) 2022 Junyan Xu. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Junyan Xu -/ import Mathlib.Data.Finsupp.Lex import Mathlib.Data.Finsupp.Multiset import Mathlib.Order.GameAdd #align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded" /-! # Termination of a hydra game This file deals with the following version of the hydra game: each head of the hydra is labelled by an element in a type `α`, and when you cut off one head with label `a`, it grows back an arbitrary but finite number of heads, all labelled by elements smaller than `a` with respect to a well-founded relation `r` on `α`. We show that no matter how (in what order) you choose cut off the heads, the game always terminates, i.e. all heads will eventually be cut off (but of course it can last arbitrarily long, i.e. takes an arbitrary finite number of steps). This result is stated as the well-foundedness of the `CutExpand` relation defined in this file: we model the heads of the hydra as a multiset of elements of `α`, and the valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset α`: `CutExpand r s' s` is true iff `s'` is obtained by removing one head `a ∈ s` and adding back an arbitrary multiset `t` of heads such that all `a' ∈ t` satisfy `r a' a`. We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332. TODO: formalize the relations corresponding to more powerful (e.g. Kirby–Paris and Buchholz) hydras, and prove their well-foundedness. -/ namespace Relation open Multiset Prod variable {α : Type*} /-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s` means that `s'` is obtained by removing one head `a ∈ s` and adding back an arbitrary multiset `t` of heads such that all `a' ∈ t` satisfy `r a' a`. This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires `DecidableEq α`, so we use the equivalent condition `s' + {a} = s + t` instead, which is also easier to verify for explicit multisets `s'`, `s` and `t`. We also don't include the condition `a ∈ s` because `s' + {a} = s + t` already guarantees `a ∈ s + t`, and if `r` is irreflexive then `a ∉ t`, which is the case when `r` is well-founded, the case we are primarily interested in. The lemma `Relation.cutExpand_iff` below converts between this convenient definition and the direct translation when `r` is irreflexive. -/ def CutExpand (r : α → α → Prop) (s' s : Multiset α) : Prop := ∃ (t : Multiset α) (a : α), (∀ a' ∈ t, r a' a) ∧ s' + {a} = s + t #align relation.cut_expand Relation.CutExpand variable {r : α → α → Prop}
Mathlib/Logic/Hydra.lean
62
74
theorem cutExpand_le_invImage_lex [DecidableEq α] [IsIrrefl α r] : CutExpand r ≤ InvImage (Finsupp.Lex (rᶜ ⊓ (· ≠ ·)) (· < ·)) toFinsupp := by
rintro s t ⟨u, a, hr, he⟩ replace hr := fun a' ↦ mt (hr a') classical refine ⟨a, fun b h ↦ ?_, ?_⟩ <;> simp_rw [toFinsupp_apply] · apply_fun count b at he simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)] using he · apply_fun count a at he simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)), add_zero] at he exact he ▸ Nat.lt_succ_self _
/- 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] theorem log_zero : log 0 = 0 := by simp [log] #align complex.log_zero Complex.log_zero @[simp] theorem log_one : log 1 = 0 := by simp [log] #align complex.log_one Complex.log_one theorem log_neg_one : log (-1) = π * I := by simp [log] #align complex.log_neg_one Complex.log_neg_one
Mathlib/Analysis/SpecialFunctions/Complex/Log.lean
116
116
theorem log_I : log I = π / 2 * I := by
simp [log]
/- 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.Martingale.Basic #align_import probability.martingale.centering from "leanprover-community/mathlib"@"bea6c853b6edbd15e9d0941825abd04d77933ed0" /-! # Centering lemma for stochastic processes Any `ℕ`-indexed stochastic process which is adapted and integrable can be written as the sum of a martingale and a predictable process. This result is also known as **Doob's decomposition theorem**. From a process `f`, a filtration `ℱ` and a measure `μ`, we define two processes `martingalePart f ℱ μ` and `predictablePart f ℱ μ`. ## Main definitions * `MeasureTheory.predictablePart f ℱ μ`: a predictable process such that `f = predictablePart f ℱ μ + martingalePart f ℱ μ` * `MeasureTheory.martingalePart f ℱ μ`: a martingale such that `f = predictablePart f ℱ μ + martingalePart f ℱ μ` ## Main statements * `MeasureTheory.adapted_predictablePart`: `(fun n => predictablePart f ℱ μ (n+1))` is adapted. That is, `predictablePart` is predictable. * `MeasureTheory.martingale_martingalePart`: `martingalePart f ℱ μ` is a martingale. -/ open TopologicalSpace Filter open scoped NNReal ENNReal MeasureTheory ProbabilityTheory namespace MeasureTheory variable {Ω E : Type*} {m0 : MeasurableSpace Ω} {μ : Measure Ω} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] {f : ℕ → Ω → E} {ℱ : Filtration ℕ m0} {n : ℕ} /-- Any `ℕ`-indexed stochastic process can be written as the sum of a martingale and a predictable process. This is the predictable process. See `martingalePart` for the martingale. -/ noncomputable def predictablePart {m0 : MeasurableSpace Ω} (f : ℕ → Ω → E) (ℱ : Filtration ℕ m0) (μ : Measure Ω) : ℕ → Ω → E := fun n => ∑ i ∈ Finset.range n, μ[f (i + 1) - f i|ℱ i] #align measure_theory.predictable_part MeasureTheory.predictablePart @[simp]
Mathlib/Probability/Martingale/Centering.lean
50
51
theorem predictablePart_zero : predictablePart f ℱ μ 0 = 0 := by
simp_rw [predictablePart, Finset.range_zero, Finset.sum_empty]
/- 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.Preserves.Shapes.BinaryProducts import Mathlib.CategoryTheory.Limits.Constructions.FiniteProductsOfBinaryProducts import Mathlib.CategoryTheory.Monad.Limits import Mathlib.CategoryTheory.Adjunction.FullyFaithful import Mathlib.CategoryTheory.Adjunction.Limits import Mathlib.CategoryTheory.Adjunction.Reflective import Mathlib.CategoryTheory.Closed.Cartesian import Mathlib.CategoryTheory.Subterminal #align_import category_theory.closed.ideal from "leanprover-community/mathlib"@"ac3ae212f394f508df43e37aa093722fa9b65d31" /-! # Exponential ideals An exponential ideal of a cartesian closed category `C` is a subcategory `D ⊆ C` such that for any `B : D` and `A : C`, the exponential `A ⟹ B` is in `D`: resembling ring theoretic ideals. We define the notion here for inclusion functors `i : D ⥤ C` rather than explicit subcategories to preserve the principle of equivalence. We additionally show that if `C` is cartesian closed and `i : D ⥤ C` is a reflective functor, the following are equivalent. * The left adjoint to `i` preserves binary (equivalently, finite) products. * `i` is an exponential ideal. -/ universe v₁ v₂ u₁ u₂ noncomputable section namespace CategoryTheory open Limits Category section Ideal variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₁} D] {i : D ⥤ C} variable (i) [HasFiniteProducts C] [CartesianClosed C] /-- The subcategory `D` of `C` expressed as an inclusion functor is an *exponential ideal* if `B ∈ D` implies `A ⟹ B ∈ D` for all `A`. -/ class ExponentialIdeal : Prop where exp_closed : ∀ {B}, B ∈ i.essImage → ∀ A, (A ⟹ B) ∈ i.essImage #align category_theory.exponential_ideal CategoryTheory.ExponentialIdeal attribute [nolint docBlame] ExponentialIdeal.exp_closed /-- To show `i` is an exponential ideal it suffices to show that `A ⟹ iB` is "in" `D` for any `A` in `C` and `B` in `D`. -/ theorem ExponentialIdeal.mk' (h : ∀ (B : D) (A : C), (A ⟹ i.obj B) ∈ i.essImage) : ExponentialIdeal i := ⟨fun hB A => by rcases hB with ⟨B', ⟨iB'⟩⟩ exact Functor.essImage.ofIso ((exp A).mapIso iB') (h B' A)⟩ #align category_theory.exponential_ideal.mk' CategoryTheory.ExponentialIdeal.mk' /-- The entire category viewed as a subcategory is an exponential ideal. -/ instance : ExponentialIdeal (𝟭 C) := ExponentialIdeal.mk' _ fun _ _ => ⟨_, ⟨Iso.refl _⟩⟩ open CartesianClosed /-- The subcategory of subterminal objects is an exponential ideal. -/ instance : ExponentialIdeal (subterminalInclusion C) := by apply ExponentialIdeal.mk' intro B A refine ⟨⟨A ⟹ B.1, fun Z g h => ?_⟩, ⟨Iso.refl _⟩⟩ exact uncurry_injective (B.2 (CartesianClosed.uncurry g) (CartesianClosed.uncurry h)) /-- If `D` is a reflective subcategory, the property of being an exponential ideal is equivalent to the presence of a natural isomorphism `i ⋙ exp A ⋙ leftAdjoint i ⋙ i ≅ i ⋙ exp A`, that is: `(A ⟹ iB) ≅ i L (A ⟹ iB)`, naturally in `B`. The converse is given in `ExponentialIdeal.mk_of_iso`. -/ def exponentialIdealReflective (A : C) [Reflective i] [ExponentialIdeal i] : i ⋙ exp A ⋙ reflector i ⋙ i ≅ i ⋙ exp A := by symm apply NatIso.ofComponents _ _ · intro X haveI := Functor.essImage.unit_isIso (ExponentialIdeal.exp_closed (i.obj_mem_essImage X) A) apply asIso ((reflectorAdjunction i).unit.app (A ⟹ i.obj X)) · simp [asIso] #align category_theory.exponential_ideal_reflective CategoryTheory.exponentialIdealReflective /-- Given a natural isomorphism `i ⋙ exp A ⋙ leftAdjoint i ⋙ i ≅ i ⋙ exp A`, we can show `i` is an exponential ideal. -/
Mathlib/CategoryTheory/Closed/Ideal.lean
94
98
theorem ExponentialIdeal.mk_of_iso [Reflective i] (h : ∀ A : C, i ⋙ exp A ⋙ reflector i ⋙ i ≅ i ⋙ exp A) : ExponentialIdeal i := by
apply ExponentialIdeal.mk' intro B A exact ⟨_, ⟨(h A).app B⟩⟩
/- Copyright (c) 2014 Floris van Doorn (c) 2016 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn, Leonardo de Moura, Jeremy Avigad, Mario Carneiro -/ import Mathlib.Data.Nat.Bits import Mathlib.Order.Lattice #align_import data.nat.size from "leanprover-community/mathlib"@"18a5306c091183ac90884daa9373fa3b178e8607" /-! Lemmas about `size`. -/ namespace Nat /-! ### `shiftLeft` and `shiftRight` -/ section set_option linter.deprecated false theorem shiftLeft_eq_mul_pow (m) : ∀ n, m <<< n = m * 2 ^ n := shiftLeft_eq _ #align nat.shiftl_eq_mul_pow Nat.shiftLeft_eq_mul_pow theorem shiftLeft'_tt_eq_mul_pow (m) : ∀ n, shiftLeft' true m n + 1 = (m + 1) * 2 ^ n | 0 => by simp [shiftLeft', pow_zero, Nat.one_mul] | k + 1 => by change bit1 (shiftLeft' true m k) + 1 = (m + 1) * (2 ^ k * 2) rw [bit1_val] change 2 * (shiftLeft' true m k + 1) = _ rw [shiftLeft'_tt_eq_mul_pow m k, mul_left_comm, mul_comm 2] #align nat.shiftl'_tt_eq_mul_pow Nat.shiftLeft'_tt_eq_mul_pow end #align nat.one_shiftl Nat.one_shiftLeft #align nat.zero_shiftl Nat.zero_shiftLeft #align nat.shiftr_eq_div_pow Nat.shiftRight_eq_div_pow theorem shiftLeft'_ne_zero_left (b) {m} (h : m ≠ 0) (n) : shiftLeft' b m n ≠ 0 := by induction n <;> simp [bit_ne_zero, shiftLeft', *] #align nat.shiftl'_ne_zero_left Nat.shiftLeft'_ne_zero_left theorem shiftLeft'_tt_ne_zero (m) : ∀ {n}, (n ≠ 0) → shiftLeft' true m n ≠ 0 | 0, h => absurd rfl h | succ _, _ => Nat.bit1_ne_zero _ #align nat.shiftl'_tt_ne_zero Nat.shiftLeft'_tt_ne_zero /-! ### `size` -/ @[simp] theorem size_zero : size 0 = 0 := by simp [size] #align nat.size_zero Nat.size_zero @[simp] theorem size_bit {b n} (h : bit b n ≠ 0) : size (bit b n) = succ (size n) := by rw [size] conv => lhs rw [binaryRec] simp [h] rw [div2_bit] #align nat.size_bit Nat.size_bit section set_option linter.deprecated false @[simp] theorem size_bit0 {n} (h : n ≠ 0) : size (bit0 n) = succ (size n) := @size_bit false n (Nat.bit0_ne_zero h) #align nat.size_bit0 Nat.size_bit0 @[simp] theorem size_bit1 (n) : size (bit1 n) = succ (size n) := @size_bit true n (Nat.bit1_ne_zero n) #align nat.size_bit1 Nat.size_bit1 @[simp] theorem size_one : size 1 = 1 := show size (bit1 0) = 1 by rw [size_bit1, size_zero] #align nat.size_one Nat.size_one end @[simp] theorem size_shiftLeft' {b m n} (h : shiftLeft' b m n ≠ 0) : size (shiftLeft' b m n) = size m + n := by induction' n with n IH <;> simp [shiftLeft'] at h ⊢ rw [size_bit h, Nat.add_succ] by_cases s0 : shiftLeft' b m n = 0 <;> [skip; rw [IH s0]] rw [s0] at h ⊢ cases b; · exact absurd rfl h have : shiftLeft' true m n + 1 = 1 := congr_arg (· + 1) s0 rw [shiftLeft'_tt_eq_mul_pow] at this obtain rfl := succ.inj (eq_one_of_dvd_one ⟨_, this.symm⟩) simp only [zero_add, one_mul] at this obtain rfl : n = 0 := not_ne_iff.1 fun hn ↦ ne_of_gt (Nat.one_lt_pow hn (by decide)) this rfl #align nat.size_shiftl' Nat.size_shiftLeft' -- TODO: decide whether `Nat.shiftLeft_eq` (which rewrites the LHS into a power) should be a simp -- lemma; it was not in mathlib3. Until then, tell the simpNF linter to ignore the issue. @[simp, nolint simpNF] theorem size_shiftLeft {m} (h : m ≠ 0) (n) : size (m <<< n) = size m + n := by simp only [size_shiftLeft' (shiftLeft'_ne_zero_left _ h _), ← shiftLeft'_false] #align nat.size_shiftl Nat.size_shiftLeft
Mathlib/Data/Nat/Size.lean
107
116
theorem lt_size_self (n : ℕ) : n < 2 ^ size n := by
rw [← one_shiftLeft] have : ∀ {n}, n = 0 → n < 1 <<< (size n) := by simp apply binaryRec _ _ n · apply this rfl intro b n IH by_cases h : bit b n = 0 · apply this h rw [size_bit h, shiftLeft_succ, shiftLeft_eq, one_mul, ← bit0_val] exact bit_lt_bit0 _ (by simpa [shiftLeft_eq, shiftRight_eq_div_pow] using IH)
/- 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.Separation import Mathlib.Topology.NoetherianSpace #align_import topology.quasi_separated from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Quasi-separated spaces A topological space is quasi-separated if the intersections of any pairs of compact open subsets are still compact. Notable examples include spectral spaces, Noetherian spaces, and Hausdorff spaces. A non-example is the interval `[0, 1]` with doubled origin: the two copies of `[0, 1]` are compact open subsets, but their intersection `(0, 1]` is not. ## Main results - `IsQuasiSeparated`: A subset `s` of a topological space is quasi-separated if the intersections of any pairs of compact open subsets of `s` are still compact. - `QuasiSeparatedSpace`: A topological space is quasi-separated if the intersections of any pairs of compact open subsets are still compact. - `QuasiSeparatedSpace.of_openEmbedding`: If `f : α → β` is an open embedding, and `β` is a quasi-separated space, then so is `α`. -/ open TopologicalSpace variable {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] {f : α → β} /-- A subset `s` of a topological space is quasi-separated if the intersections of any pairs of compact open subsets of `s` are still compact. Note that this is equivalent to `s` being a `QuasiSeparatedSpace` only when `s` is open. -/ def IsQuasiSeparated (s : Set α) : Prop := ∀ U V : Set α, U ⊆ s → IsOpen U → IsCompact U → V ⊆ s → IsOpen V → IsCompact V → IsCompact (U ∩ V) #align is_quasi_separated IsQuasiSeparated /-- A topological space is quasi-separated if the intersections of any pairs of compact open subsets are still compact. -/ @[mk_iff] class QuasiSeparatedSpace (α : Type*) [TopologicalSpace α] : Prop where /-- The intersection of two open compact subsets of a quasi-separated space is compact. -/ inter_isCompact : ∀ U V : Set α, IsOpen U → IsCompact U → IsOpen V → IsCompact V → IsCompact (U ∩ V) #align quasi_separated_space QuasiSeparatedSpace
Mathlib/Topology/QuasiSeparated.lean
53
56
theorem isQuasiSeparated_univ_iff {α : Type*} [TopologicalSpace α] : IsQuasiSeparated (Set.univ : Set α) ↔ QuasiSeparatedSpace α := by
rw [quasiSeparatedSpace_iff] simp [IsQuasiSeparated]
/- Copyright (c) 2017 Kevin Buzzard. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Buzzard, Mario Carneiro -/ import Mathlib.Data.Complex.Basic import Mathlib.Data.Real.Sqrt #align_import data.complex.basic from "leanprover-community/mathlib"@"31c24aa72e7b3e5ed97a8412470e904f82b81004" /-! # Absolute values of complex numbers -/ open Set ComplexConjugate namespace Complex /-! ### Absolute value -/ namespace AbsTheory -- We develop enough theory to bundle `abs` into an `AbsoluteValue` before making things public; -- this is so there's not two versions of it hanging around. local notation "abs" z => Real.sqrt (normSq z) private theorem mul_self_abs (z : ℂ) : ((abs z) * abs z) = normSq z := Real.mul_self_sqrt (normSq_nonneg _) private theorem abs_nonneg' (z : ℂ) : 0 ≤ abs z := Real.sqrt_nonneg _ theorem abs_conj (z : ℂ) : (abs conj z) = abs z := by simp #align complex.abs_theory.abs_conj Complex.AbsTheory.abs_conj private theorem abs_re_le_abs (z : ℂ) : |z.re| ≤ abs z := by rw [mul_self_le_mul_self_iff (abs_nonneg z.re) (abs_nonneg' _), abs_mul_abs_self, mul_self_abs] apply re_sq_le_normSq private theorem re_le_abs (z : ℂ) : z.re ≤ abs z := (abs_le.1 (abs_re_le_abs _)).2 private theorem abs_mul (z w : ℂ) : (abs z * w) = (abs z) * abs w := by rw [normSq_mul, Real.sqrt_mul (normSq_nonneg _)] private theorem abs_add (z w : ℂ) : (abs z + w) ≤ (abs z) + abs w := (mul_self_le_mul_self_iff (abs_nonneg' (z + w)) (add_nonneg (abs_nonneg' z) (abs_nonneg' w))).2 <| by rw [mul_self_abs, add_mul_self_eq, mul_self_abs, mul_self_abs, add_right_comm, normSq_add, add_le_add_iff_left, mul_assoc, mul_le_mul_left (zero_lt_two' ℝ), ← Real.sqrt_mul <| normSq_nonneg z, ← normSq_conj w, ← map_mul] exact re_le_abs (z * conj w) /-- The complex absolute value function, defined as the square root of the norm squared. -/ noncomputable def _root_.Complex.abs : AbsoluteValue ℂ ℝ where toFun x := abs x map_mul' := abs_mul nonneg' := abs_nonneg' eq_zero' _ := (Real.sqrt_eq_zero <| normSq_nonneg _).trans normSq_eq_zero add_le' := abs_add #align complex.abs Complex.abs end AbsTheory theorem abs_def : (Complex.abs : ℂ → ℝ) = fun z => (normSq z).sqrt := rfl #align complex.abs_def Complex.abs_def theorem abs_apply {z : ℂ} : Complex.abs z = (normSq z).sqrt := rfl #align complex.abs_apply Complex.abs_apply @[simp, norm_cast] theorem abs_ofReal (r : ℝ) : Complex.abs r = |r| := by simp [Complex.abs, normSq_ofReal, Real.sqrt_mul_self_eq_abs] #align complex.abs_of_real Complex.abs_ofReal nonrec theorem abs_of_nonneg {r : ℝ} (h : 0 ≤ r) : Complex.abs r = r := (Complex.abs_ofReal _).trans (abs_of_nonneg h) #align complex.abs_of_nonneg Complex.abs_of_nonneg -- Porting note: removed `norm_cast` attribute because the RHS can't start with `↑` @[simp] theorem abs_natCast (n : ℕ) : Complex.abs n = n := Complex.abs_of_nonneg (Nat.cast_nonneg n) #align complex.abs_of_nat Complex.abs_natCast #align complex.abs_cast_nat Complex.abs_natCast -- See note [no_index around OfNat.ofNat] @[simp] theorem abs_ofNat (n : ℕ) [n.AtLeastTwo] : Complex.abs (no_index (OfNat.ofNat n : ℂ)) = OfNat.ofNat n := abs_natCast n theorem mul_self_abs (z : ℂ) : Complex.abs z * Complex.abs z = normSq z := Real.mul_self_sqrt (normSq_nonneg _) #align complex.mul_self_abs Complex.mul_self_abs theorem sq_abs (z : ℂ) : Complex.abs z ^ 2 = normSq z := Real.sq_sqrt (normSq_nonneg _) #align complex.sq_abs Complex.sq_abs @[simp] theorem sq_abs_sub_sq_re (z : ℂ) : Complex.abs z ^ 2 - z.re ^ 2 = z.im ^ 2 := by rw [sq_abs, normSq_apply, ← sq, ← sq, add_sub_cancel_left] #align complex.sq_abs_sub_sq_re Complex.sq_abs_sub_sq_re @[simp] theorem sq_abs_sub_sq_im (z : ℂ) : Complex.abs z ^ 2 - z.im ^ 2 = z.re ^ 2 := by rw [← sq_abs_sub_sq_re, sub_sub_cancel] #align complex.sq_abs_sub_sq_im Complex.sq_abs_sub_sq_im lemma abs_add_mul_I (x y : ℝ) : abs (x + y * I) = (x ^ 2 + y ^ 2).sqrt := by rw [← normSq_add_mul_I]; rfl lemma abs_eq_sqrt_sq_add_sq (z : ℂ) : abs z = (z.re ^ 2 + z.im ^ 2).sqrt := by rw [abs_apply, normSq_apply, sq, sq] @[simp]
Mathlib/Data/Complex/Abs.lean
120
120
theorem abs_I : Complex.abs I = 1 := by
simp [Complex.abs]
/- Copyright (c) 2019 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.Algebra.GroupWithZero.Divisibility import Mathlib.Algebra.Order.Group.Int import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Algebra.Ring.Rat import Mathlib.Data.PNat.Defs #align_import data.rat.lemmas from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11" /-! # Further lemmas for the Rational Numbers -/ namespace Rat open Rat theorem num_dvd (a) {b : ℤ} (b0 : b ≠ 0) : (a /. b).num ∣ a := by cases' e : a /. b with n d h c rw [Rat.mk'_eq_divInt, divInt_eq_iff b0 (mod_cast h)] at e refine Int.natAbs_dvd.1 <| Int.dvd_natAbs.1 <| Int.natCast_dvd_natCast.2 <| c.dvd_of_dvd_mul_right ?_ have := congr_arg Int.natAbs e simp only [Int.natAbs_mul, Int.natAbs_ofNat] at this; simp [this] #align rat.num_dvd Rat.num_dvd theorem den_dvd (a b : ℤ) : ((a /. b).den : ℤ) ∣ b := by by_cases b0 : b = 0; · simp [b0] cases' e : a /. b with n d h c rw [mk'_eq_divInt, divInt_eq_iff b0 (ne_of_gt (Int.natCast_pos.2 (Nat.pos_of_ne_zero h)))] at e refine Int.dvd_natAbs.1 <| Int.natCast_dvd_natCast.2 <| c.symm.dvd_of_dvd_mul_left ?_ rw [← Int.natAbs_mul, ← Int.natCast_dvd_natCast, Int.dvd_natAbs, ← e]; simp #align rat.denom_dvd Rat.den_dvd theorem num_den_mk {q : ℚ} {n d : ℤ} (hd : d ≠ 0) (qdf : q = n /. d) : ∃ c : ℤ, n = c * q.num ∧ d = c * q.den := by obtain rfl | hn := eq_or_ne n 0 · simp [qdf] have : q.num * d = n * ↑q.den := by refine (divInt_eq_iff ?_ hd).mp ?_ · exact Int.natCast_ne_zero.mpr (Rat.den_nz _) · rwa [num_divInt_den] have hqdn : q.num ∣ n := by rw [qdf] exact Rat.num_dvd _ hd refine ⟨n / q.num, ?_, ?_⟩ · rw [Int.ediv_mul_cancel hqdn] · refine Int.eq_mul_div_of_mul_eq_mul_of_dvd_left ?_ hqdn this rw [qdf] exact Rat.num_ne_zero.2 ((divInt_ne_zero hd).mpr hn) #align rat.num_denom_mk Rat.num_den_mk #noalign rat.mk_pnat_num #noalign rat.mk_pnat_denom theorem num_mk (n d : ℤ) : (n /. d).num = d.sign * n / n.gcd d := by have (m : ℕ) : Int.natAbs (m + 1) = m + 1 := by rw [← Nat.cast_one, ← Nat.cast_add, Int.natAbs_cast] rcases d with ((_ | _) | _) <;> rw [← Int.div_eq_ediv_of_dvd] <;> simp [divInt, mkRat, Rat.normalize, Nat.succPNat, Int.sign, Int.gcd, Int.zero_ediv, Int.ofNat_dvd_left, Nat.gcd_dvd_left, this] #align rat.num_mk Rat.num_mk theorem den_mk (n d : ℤ) : (n /. d).den = if d = 0 then 1 else d.natAbs / n.gcd d := by have (m : ℕ) : Int.natAbs (m + 1) = m + 1 := by rw [← Nat.cast_one, ← Nat.cast_add, Int.natAbs_cast] rcases d with ((_ | _) | _) <;> simp [divInt, mkRat, Rat.normalize, Nat.succPNat, Int.sign, Int.gcd, if_neg (Nat.cast_add_one_ne_zero _), this] #align rat.denom_mk Rat.den_mk #noalign rat.mk_pnat_denom_dvd theorem add_den_dvd (q₁ q₂ : ℚ) : (q₁ + q₂).den ∣ q₁.den * q₂.den := by rw [add_def, normalize_eq] apply Nat.div_dvd_of_dvd apply Nat.gcd_dvd_right #align rat.add_denom_dvd Rat.add_den_dvd theorem mul_den_dvd (q₁ q₂ : ℚ) : (q₁ * q₂).den ∣ q₁.den * q₂.den := by rw [mul_def, normalize_eq] apply Nat.div_dvd_of_dvd apply Nat.gcd_dvd_right #align rat.mul_denom_dvd Rat.mul_den_dvd theorem mul_num (q₁ q₂ : ℚ) : (q₁ * q₂).num = q₁.num * q₂.num / Nat.gcd (q₁.num * q₂.num).natAbs (q₁.den * q₂.den) := by rw [mul_def, normalize_eq] #align rat.mul_num Rat.mul_num theorem mul_den (q₁ q₂ : ℚ) : (q₁ * q₂).den = q₁.den * q₂.den / Nat.gcd (q₁.num * q₂.num).natAbs (q₁.den * q₂.den) := by rw [mul_def, normalize_eq] #align rat.mul_denom Rat.mul_den theorem mul_self_num (q : ℚ) : (q * q).num = q.num * q.num := by rw [mul_num, Int.natAbs_mul, Nat.Coprime.gcd_eq_one, Int.ofNat_one, Int.ediv_one] exact (q.reduced.mul_right q.reduced).mul (q.reduced.mul_right q.reduced) #align rat.mul_self_num Rat.mul_self_num
Mathlib/Data/Rat/Lemmas.lean
109
111
theorem mul_self_den (q : ℚ) : (q * q).den = q.den * q.den := by
rw [Rat.mul_den, Int.natAbs_mul, Nat.Coprime.gcd_eq_one, Nat.div_one] exact (q.reduced.mul_right q.reduced).mul (q.reduced.mul_right q.reduced)
/- 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.CategoryTheory.Category.Cat import Mathlib.CategoryTheory.Elements #align_import category_theory.grothendieck from "leanprover-community/mathlib"@"14b69e9f3c16630440a2cbd46f1ddad0d561dee7" /-! # The Grothendieck construction Given a functor `F : C ⥤ Cat`, the objects of `Grothendieck F` consist of dependent pairs `(b, f)`, where `b : C` and `f : F.obj c`, and a morphism `(b, f) ⟶ (b', f')` is a pair `β : b ⟶ b'` in `C`, and `φ : (F.map β).obj f ⟶ f'` Categories such as `PresheafedSpace` are in fact examples of this construction, and it may be interesting to try to generalize some of the development there. ## Implementation notes Really we should treat `Cat` as a 2-category, and allow `F` to be a 2-functor. There is also a closely related construction starting with `G : Cᵒᵖ ⥤ Cat`, where morphisms consists again of `β : b ⟶ b'` and `φ : f ⟶ (F.map (op β)).obj f'`. ## References See also `CategoryTheory.Functor.Elements` for the category of elements of functor `F : C ⥤ Type`. * https://stacks.math.columbia.edu/tag/02XV * https://ncatlab.org/nlab/show/Grothendieck+construction -/ universe u namespace CategoryTheory variable {C D : Type*} [Category C] [Category D] variable (F : C ⥤ Cat) /-- The Grothendieck construction (often written as `∫ F` in mathematics) for a functor `F : C ⥤ Cat` gives a category whose * objects `X` consist of `X.base : C` and `X.fiber : F.obj base` * morphisms `f : X ⟶ Y` consist of `base : X.base ⟶ Y.base` and `f.fiber : (F.map base).obj X.fiber ⟶ Y.fiber` -/ -- Porting note(#5171): no such linter yet -- @[nolint has_nonempty_instance] structure Grothendieck where /-- The underlying object in `C` -/ base : C /-- The object in the fiber of the base object. -/ fiber : F.obj base #align category_theory.grothendieck CategoryTheory.Grothendieck namespace Grothendieck variable {F} /-- A morphism in the Grothendieck category `F : C ⥤ Cat` consists of `base : X.base ⟶ Y.base` and `f.fiber : (F.map base).obj X.fiber ⟶ Y.fiber`. -/ structure Hom (X Y : Grothendieck F) where /-- The morphism between base objects. -/ base : X.base ⟶ Y.base /-- The morphism from the pushforward to the source fiber object to the target fiber object. -/ fiber : (F.map base).obj X.fiber ⟶ Y.fiber #align category_theory.grothendieck.hom CategoryTheory.Grothendieck.Hom @[ext]
Mathlib/CategoryTheory/Grothendieck.lean
78
83
theorem ext {X Y : Grothendieck F} (f g : Hom X Y) (w_base : f.base = g.base) (w_fiber : eqToHom (by rw [w_base]) ≫ f.fiber = g.fiber) : f = g := by
cases f; cases g congr dsimp at w_base aesop_cat
/- Copyright (c) 2020 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta -/ import Mathlib.CategoryTheory.Adjunction.Basic import Mathlib.CategoryTheory.Category.Preorder import Mathlib.CategoryTheory.IsomorphismClasses import Mathlib.CategoryTheory.Thin #align_import category_theory.skeletal from "leanprover-community/mathlib"@"28aa996fc6fb4317f0083c4e6daf79878d81be33" /-! # Skeleton of a category Define skeletal categories as categories in which any two isomorphic objects are equal. Construct the skeleton of an arbitrary category by taking isomorphism classes, and show it is a skeleton of the original category. In addition, construct the skeleton of a thin category as a partial ordering, and (noncomputably) show it is a skeleton of the original category. The advantage of this special case being handled separately is that lemmas and definitions about orderings can be used directly, for example for the subobject lattice. In addition, some of the commutative diagrams about the functors commute definitionally on the nose which is convenient in practice. -/ universe v₁ v₂ v₃ u₁ u₂ u₃ namespace CategoryTheory open Category variable (C : Type u₁) [Category.{v₁} C] variable (D : Type u₂) [Category.{v₂} D] variable {E : Type u₃} [Category.{v₃} E] /-- A category is skeletal if isomorphic objects are equal. -/ def Skeletal : Prop := ∀ ⦃X Y : C⦄, IsIsomorphic X Y → X = Y #align category_theory.skeletal CategoryTheory.Skeletal /-- `IsSkeletonOf C D F` says that `F : D ⥤ C` exhibits `D` as a skeletal full subcategory of `C`, in particular `F` is a (strong) equivalence and `D` is skeletal. -/ structure IsSkeletonOf (F : D ⥤ C) : Prop where /-- The category `D` has isomorphic objects equal -/ skel : Skeletal D /-- The functor `F` is an equivalence -/ eqv : F.IsEquivalence := by infer_instance #align category_theory.is_skeleton_of CategoryTheory.IsSkeletonOf attribute [local instance] isIsomorphicSetoid variable {C D} /-- If `C` is thin and skeletal, then any naturally isomorphic functors to `C` are equal. -/ theorem Functor.eq_of_iso {F₁ F₂ : D ⥤ C} [Quiver.IsThin C] (hC : Skeletal C) (hF : F₁ ≅ F₂) : F₁ = F₂ := Functor.ext (fun X => hC ⟨hF.app X⟩) fun _ _ _ => Subsingleton.elim _ _ #align category_theory.functor.eq_of_iso CategoryTheory.Functor.eq_of_iso /-- If `C` is thin and skeletal, `D ⥤ C` is skeletal. `CategoryTheory.functor_thin` shows it is thin also. -/ theorem functor_skeletal [Quiver.IsThin C] (hC : Skeletal C) : Skeletal (D ⥤ C) := fun _ _ h => h.elim (Functor.eq_of_iso hC) #align category_theory.functor_skeletal CategoryTheory.functor_skeletal variable (C D) /-- Construct the skeleton category as the induced category on the isomorphism classes, and derive its category structure. -/ def Skeleton : Type u₁ := InducedCategory C Quotient.out #align category_theory.skeleton CategoryTheory.Skeleton instance [Inhabited C] : Inhabited (Skeleton C) := ⟨⟦default⟧⟩ -- Porting note: previously `Skeleton` used `deriving Category` noncomputable instance : Category (Skeleton C) := by apply InducedCategory.category /-- The functor from the skeleton of `C` to `C`. -/ @[simps!] noncomputable def fromSkeleton : Skeleton C ⥤ C := inducedFunctor _ #align category_theory.from_skeleton CategoryTheory.fromSkeleton -- Porting note: previously `fromSkeleton` used `deriving Faithful, Full` noncomputable instance : (fromSkeleton C).Full := by apply InducedCategory.full noncomputable instance : (fromSkeleton C).Faithful := by apply InducedCategory.faithful instance : (fromSkeleton C).EssSurj where mem_essImage X := ⟨Quotient.mk' X, Quotient.mk_out X⟩ -- Porting note: named this instance noncomputable instance fromSkeleton.isEquivalence : (fromSkeleton C).IsEquivalence where /-- The equivalence between the skeleton and the category itself. -/ noncomputable def skeletonEquivalence : Skeleton C ≌ C := (fromSkeleton C).asEquivalence #align category_theory.skeleton_equivalence CategoryTheory.skeletonEquivalence
Mathlib/CategoryTheory/Skeletal.lean
108
111
theorem skeleton_skeletal : Skeletal (Skeleton C) := by
rintro X Y ⟨h⟩ have : X.out ≈ Y.out := ⟨(fromSkeleton C).mapIso h⟩ simpa using Quotient.sound this
/- Copyright (c) 2020 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa, Alex Meiburg -/ import Mathlib.Algebra.BigOperators.Fin import Mathlib.Algebra.Polynomial.Degree.Lemmas #align_import data.polynomial.erase_lead from "leanprover-community/mathlib"@"fa256f00ce018e7b40e1dc756e403c86680bf448" /-! # Erase the leading term of a univariate polynomial ## Definition * `eraseLead f`: the polynomial `f - leading term of f` `eraseLead` serves as reduction step in an induction, shaving off one monomial from a polynomial. The definition is set up so that it does not mention subtraction in the definition, and thus works for polynomials over semirings as well as rings. -/ noncomputable section open Polynomial open Polynomial Finset namespace Polynomial variable {R : Type*} [Semiring R] {f : R[X]} /-- `eraseLead f` for a polynomial `f` is the polynomial obtained by subtracting from `f` the leading term of `f`. -/ def eraseLead (f : R[X]) : R[X] := Polynomial.erase f.natDegree f #align polynomial.erase_lead Polynomial.eraseLead section EraseLead theorem eraseLead_support (f : R[X]) : f.eraseLead.support = f.support.erase f.natDegree := by simp only [eraseLead, support_erase] #align polynomial.erase_lead_support Polynomial.eraseLead_support theorem eraseLead_coeff (i : ℕ) : f.eraseLead.coeff i = if i = f.natDegree then 0 else f.coeff i := by simp only [eraseLead, coeff_erase] #align polynomial.erase_lead_coeff Polynomial.eraseLead_coeff @[simp] theorem eraseLead_coeff_natDegree : f.eraseLead.coeff f.natDegree = 0 := by simp [eraseLead_coeff] #align polynomial.erase_lead_coeff_nat_degree Polynomial.eraseLead_coeff_natDegree
Mathlib/Algebra/Polynomial/EraseLead.lean
55
56
theorem eraseLead_coeff_of_ne (i : ℕ) (hi : i ≠ f.natDegree) : f.eraseLead.coeff i = f.coeff i := by
simp [eraseLead_coeff, hi]
/- Copyright (c) 2023 Shogo Saito. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Shogo Saito. Adapted for mathlib by Hunter Monroe -/ import Mathlib.Algebra.BigOperators.Ring.List import Mathlib.Data.Nat.ModEq import Mathlib.Data.Nat.GCD.BigOperators /-! # Chinese Remainder Theorem This file provides definitions and theorems for the Chinese Remainder Theorem. These are used in Gödel's Beta function, which is used in proving Gödel's incompleteness theorems. ## Main result - `chineseRemainderOfList`: Definition of the Chinese remainder of a list ## Tags Chinese Remainder Theorem, Gödel, beta function -/ namespace Nat variable {ι : Type*} lemma modEq_list_prod_iff {a b} {l : List ℕ} (co : l.Pairwise Coprime) : a ≡ b [MOD l.prod] ↔ ∀ i, a ≡ b [MOD l.get i] := by induction' l with m l ih · simp [modEq_one] · have : Coprime m l.prod := coprime_list_prod_right_iff.mpr (List.pairwise_cons.mp co).1 simp only [List.prod_cons, ← modEq_and_modEq_iff_modEq_mul this, ih (List.Pairwise.of_cons co), List.length_cons] constructor · rintro ⟨h0, hs⟩ i cases i using Fin.cases <;> simp [h0, hs] · intro h; exact ⟨h 0, fun i => h i.succ⟩ lemma modEq_list_prod_iff' {a b} {s : ι → ℕ} {l : List ι} (co : l.Pairwise (Coprime on s)) : a ≡ b [MOD (l.map s).prod] ↔ ∀ i ∈ l, a ≡ b [MOD s i] := by induction' l with i l ih · simp [modEq_one] · have : Coprime (s i) (l.map s).prod := by simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro j hj exact (List.pairwise_cons.mp co).1 j hj simp [← modEq_and_modEq_iff_modEq_mul this, ih (List.Pairwise.of_cons co)] variable (a s : ι → ℕ) /-- The natural number less than `(l.map s).prod` congruent to `a i` mod `s i` for all `i ∈ l`. -/ def chineseRemainderOfList : (l : List ι) → l.Pairwise (Coprime on s) → { k // ∀ i ∈ l, k ≡ a i [MOD s i] } | [], _ => ⟨0, by simp⟩ | i :: l, co => by have : Coprime (s i) (l.map s).prod := by simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro j hj exact (List.pairwise_cons.mp co).1 j hj have ih := chineseRemainderOfList l co.of_cons have k := chineseRemainder this (a i) ih use k simp only [List.mem_cons, forall_eq_or_imp, k.prop.1, true_and] intro j hj exact ((modEq_list_prod_iff' co.of_cons).mp k.prop.2 j hj).trans (ih.prop j hj) @[simp] theorem chineseRemainderOfList_nil : (chineseRemainderOfList a s [] List.Pairwise.nil : ℕ) = 0 := rfl theorem chineseRemainderOfList_lt_prod (l : List ι) (co : l.Pairwise (Coprime on s)) (hs : ∀ i ∈ l, s i ≠ 0) : chineseRemainderOfList a s l co < (l.map s).prod := by cases l with | nil => simp | cons i l => simp only [chineseRemainderOfList, List.map_cons, List.prod_cons] have : Coprime (s i) (l.map s).prod := by simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro j hj exact (List.pairwise_cons.mp co).1 j hj refine chineseRemainder_lt_mul this (a i) (chineseRemainderOfList a s l co.of_cons) (hs i (List.mem_cons_self _ l)) ?_ simp only [ne_eq, List.prod_eq_zero_iff, List.mem_map, not_exists, not_and] intro j hj exact hs j (List.mem_cons_of_mem _ hj) theorem chineseRemainderOfList_modEq_unique (l : List ι) (co : l.Pairwise (Coprime on s)) {z} (hz : ∀ i ∈ l, z ≡ a i [MOD s i]) : z ≡ chineseRemainderOfList a s l co [MOD (l.map s).prod] := by induction' l with i l ih · simp [modEq_one] · simp only [List.map_cons, List.prod_cons, chineseRemainderOfList] have : Coprime (s i) (l.map s).prod := by simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro j hj exact (List.pairwise_cons.mp co).1 j hj exact chineseRemainder_modEq_unique this (hz i (List.mem_cons_self _ _)) (ih co.of_cons (fun j hj => hz j (List.mem_cons_of_mem _ hj)))
Mathlib/Data/Nat/ChineseRemainder.lean
107
118
theorem chineseRemainderOfList_perm {l l' : List ι} (hl : l.Perm l') (hs : ∀ i ∈ l, s i ≠ 0) (co : l.Pairwise (Coprime on s)) : (chineseRemainderOfList a s l co : ℕ) = chineseRemainderOfList a s l' (co.perm hl coprime_comm.mpr) := by
let z := chineseRemainderOfList a s l' (co.perm hl coprime_comm.mpr) have hlp : (l.map s).prod = (l'.map s).prod := List.Perm.prod_eq (List.Perm.map s hl) exact (chineseRemainderOfList_modEq_unique a s l co (z := z) (fun i hi => z.prop i (hl.symm.mem_iff.mpr hi))).symm.eq_of_lt_of_lt (chineseRemainderOfList_lt_prod _ _ _ _ hs) (by rw [hlp] exact chineseRemainderOfList_lt_prod _ _ _ _ (by simpa [List.Perm.mem_iff hl.symm] using hs))
/- 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.LinearAlgebra.Matrix.Charpoly.Coeff import Mathlib.FieldTheory.Finite.Basic import Mathlib.Data.Matrix.CharP #align_import linear_algebra.matrix.charpoly.finite_field from "leanprover-community/mathlib"@"b95b8c7a484a298228805c72c142f6b062eb0d70" /-! # Results on characteristic polynomials and traces over finite fields. -/ noncomputable section open Polynomial Matrix open scoped Polynomial variable {n : Type*} [DecidableEq n] [Fintype n] @[simp] theorem FiniteField.Matrix.charpoly_pow_card {K : Type*} [Field K] [Fintype K] (M : Matrix n n K) : (M ^ Fintype.card K).charpoly = M.charpoly := by cases (isEmpty_or_nonempty n).symm · cases' CharP.exists K with p hp; letI := hp rcases FiniteField.card K p with ⟨⟨k, kpos⟩, ⟨hp, hk⟩⟩ haveI : Fact p.Prime := ⟨hp⟩ dsimp at hk; rw [hk] apply (frobenius_inj K[X] p).iterate k repeat' rw [iterate_frobenius (R := K[X])]; rw [← hk] rw [← FiniteField.expand_card] unfold charpoly rw [AlgHom.map_det, ← coe_detMonoidHom, ← (detMonoidHom : Matrix n n K[X] →* K[X]).map_pow] apply congr_arg det refine matPolyEquiv.injective ?_ rw [AlgEquiv.map_pow, matPolyEquiv_charmatrix, hk, sub_pow_char_pow_of_commute, ← C_pow] · exact (id (matPolyEquiv_eq_X_pow_sub_C (p ^ k) M) : _) · exact (C M).commute_X · exact congr_arg _ (Subsingleton.elim _ _) #align finite_field.matrix.charpoly_pow_card FiniteField.Matrix.charpoly_pow_card @[simp] theorem ZMod.charpoly_pow_card {p : ℕ} [Fact p.Prime] (M : Matrix n n (ZMod p)) : (M ^ p).charpoly = M.charpoly := by have h := FiniteField.Matrix.charpoly_pow_card M rwa [ZMod.card] at h #align zmod.charpoly_pow_card ZMod.charpoly_pow_card
Mathlib/LinearAlgebra/Matrix/Charpoly/FiniteField.lean
53
58
theorem FiniteField.trace_pow_card {K : Type*} [Field K] [Fintype K] (M : Matrix n n K) : trace (M ^ Fintype.card K) = trace M ^ Fintype.card K := by
cases isEmpty_or_nonempty n · simp [Matrix.trace] rw [Matrix.trace_eq_neg_charpoly_coeff, Matrix.trace_eq_neg_charpoly_coeff, FiniteField.Matrix.charpoly_pow_card, FiniteField.pow_card]
/- Copyright (c) 2020 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers -/ import Mathlib.Analysis.Convex.StrictConvexBetween import Mathlib.Geometry.Euclidean.Basic #align_import geometry.euclidean.sphere.basic from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Spheres This file defines and proves basic results about spheres and cospherical sets of points in Euclidean affine spaces. ## Main definitions * `EuclideanGeometry.Sphere` bundles a `center` and a `radius`. * `EuclideanGeometry.Cospherical` is the property of a set of points being equidistant from some point. * `EuclideanGeometry.Concyclic` is the property of a set of points being cospherical and coplanar. -/ noncomputable section open RealInnerProductSpace namespace EuclideanGeometry variable {V : Type*} (P : Type*) open FiniteDimensional /-- A `Sphere P` bundles a `center` and `radius`. This definition does not require the radius to be positive; that should be given as a hypothesis to lemmas that require it. -/ @[ext] structure Sphere [MetricSpace P] where /-- center of this sphere -/ center : P /-- radius of the sphere: not required to be positive -/ radius : ℝ #align euclidean_geometry.sphere EuclideanGeometry.Sphere variable {P} section MetricSpace variable [MetricSpace P] instance [Nonempty P] : Nonempty (Sphere P) := ⟨⟨Classical.arbitrary P, 0⟩⟩ instance : Coe (Sphere P) (Set P) := ⟨fun s => Metric.sphere s.center s.radius⟩ instance : Membership P (Sphere P) := ⟨fun p s => p ∈ (s : Set P)⟩ theorem Sphere.mk_center (c : P) (r : ℝ) : (⟨c, r⟩ : Sphere P).center = c := rfl #align euclidean_geometry.sphere.mk_center EuclideanGeometry.Sphere.mk_center theorem Sphere.mk_radius (c : P) (r : ℝ) : (⟨c, r⟩ : Sphere P).radius = r := rfl #align euclidean_geometry.sphere.mk_radius EuclideanGeometry.Sphere.mk_radius @[simp]
Mathlib/Geometry/Euclidean/Sphere/Basic.lean
74
75
theorem Sphere.mk_center_radius (s : Sphere P) : (⟨s.center, s.radius⟩ : Sphere P) = s := by
ext <;> rfl
/- Copyright (c) 2019 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn, Mario Carneiro -/ import Mathlib.Analysis.SpecialFunctions.Trigonometric.Bounds #align_import data.real.pi.bounds from "leanprover-community/mathlib"@"402f8982dddc1864bd703da2d6e2ee304a866973" /-! # Pi This file contains lemmas which establish bounds on `real.pi`. Notably, these include `pi_gt_sqrtTwoAddSeries` and `pi_lt_sqrtTwoAddSeries`, which bound `π` using series; numerical bounds on `π` such as `pi_gt_314`and `pi_lt_315` (more precise versions are given, too). See also `Mathlib/Data/Real/Pi/Leibniz.lean` and `Mathlib/Data/Real/Pi/Wallis.lean` for infinite formulas for `π`. -/ -- Porting note: needed to add a lot of type ascriptions for lean to interpret numbers as reals. open scoped Real namespace Real theorem pi_gt_sqrtTwoAddSeries (n : ℕ) : (2 : ℝ) ^ (n + 1) * √(2 - sqrtTwoAddSeries 0 n) < π := by have : √(2 - sqrtTwoAddSeries 0 n) / (2 : ℝ) * (2 : ℝ) ^ (n + 2) < π := by rw [← lt_div_iff, ← sin_pi_over_two_pow_succ] focus apply sin_lt apply div_pos pi_pos all_goals apply pow_pos; norm_num apply lt_of_le_of_lt (le_of_eq _) this rw [pow_succ' _ (n + 1), ← mul_assoc, div_mul_cancel₀, mul_comm]; norm_num #align real.pi_gt_sqrt_two_add_series Real.pi_gt_sqrtTwoAddSeries
Mathlib/Data/Real/Pi/Bounds.lean
40
71
theorem pi_lt_sqrtTwoAddSeries (n : ℕ) : π < (2 : ℝ) ^ (n + 1) * √(2 - sqrtTwoAddSeries 0 n) + 1 / (4 : ℝ) ^ n := by
have : π < (√(2 - sqrtTwoAddSeries 0 n) / (2 : ℝ) + (1 : ℝ) / ((2 : ℝ) ^ n) ^ 3 / 4) * (2 : ℝ) ^ (n + 2) := by rw [← div_lt_iff (by norm_num), ← sin_pi_over_two_pow_succ] refine lt_of_lt_of_le (lt_add_of_sub_right_lt (sin_gt_sub_cube ?_ ?_)) ?_ · apply div_pos pi_pos; apply pow_pos; norm_num · rw [div_le_iff'] · refine le_trans pi_le_four ?_ simp only [show (4 : ℝ) = (2 : ℝ) ^ 2 by norm_num, mul_one] apply pow_le_pow_right (by norm_num) apply le_add_of_nonneg_left; apply Nat.zero_le · apply pow_pos; norm_num apply add_le_add_left; rw [div_le_div_right (by norm_num)] rw [le_div_iff (by norm_num), ← mul_pow] refine le_trans ?_ (le_of_eq (one_pow 3)); apply pow_le_pow_left · apply le_of_lt; apply mul_pos · apply div_pos pi_pos; apply pow_pos; norm_num · apply pow_pos; norm_num · rw [← le_div_iff (by norm_num)] refine le_trans ((div_le_div_right ?_).mpr pi_le_four) ?_ · apply pow_pos; norm_num · simp only [pow_succ', ← div_div, one_div] -- Porting note: removed `convert le_rfl` norm_num apply lt_of_lt_of_le this (le_of_eq _); rw [add_mul]; congr 1 · ring simp only [show (4 : ℝ) = 2 ^ 2 by norm_num, ← pow_mul, div_div, ← pow_add] rw [one_div, one_div, inv_mul_eq_iff_eq_mul₀, eq_comm, mul_inv_eq_iff_eq_mul₀, ← pow_add] · rw [add_assoc, Nat.mul_succ, add_comm, add_comm n, add_assoc, mul_comm n] all_goals norm_num
/- Copyright (c) 2014 Robert Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro -/ import Mathlib.Algebra.Field.Defs import Mathlib.Algebra.Ring.Int #align_import algebra.field.power from "leanprover-community/mathlib"@"1e05171a5e8cf18d98d9cf7b207540acb044acae" /-! # Results about powers in fields or division rings. This file exists to ensure we can define `Field` with minimal imports, so contains some lemmas about powers of elements which need imports beyond those needed for the basic definition. -/ variable {α : Type*} section DivisionRing variable [DivisionRing α] {n : ℤ}
Mathlib/Algebra/Field/Power.lean
26
30
theorem Odd.neg_zpow (h : Odd n) (a : α) : (-a) ^ n = -a ^ n := by
have hn : n ≠ 0 := by rintro rfl; exact Int.odd_iff_not_even.1 h even_zero obtain ⟨k, rfl⟩ := h simp_rw [zpow_add' (.inr (.inl hn)), zpow_one, zpow_mul, zpow_two, neg_mul_neg, neg_mul_eq_mul_neg]
/- Copyright (c) 2021 Martin Zinkevich. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Martin Zinkevich, Rémy Degenne -/ import Mathlib.Logic.Encodable.Lattice import Mathlib.MeasureTheory.MeasurableSpace.Defs #align_import measure_theory.pi_system from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90" /-! # Induction principles for measurable sets, related to π-systems and λ-systems. ## Main statements * The main theorem of this file is Dynkin's π-λ theorem, which appears here as an induction principle `induction_on_inter`. Suppose `s` is a collection of subsets of `α` such that the intersection of two members of `s` belongs to `s` whenever it is nonempty. Let `m` be the σ-algebra generated by `s`. In order to check that a predicate `C` holds on every member of `m`, it suffices to check that `C` holds on the members of `s` and that `C` is preserved by complementation and *disjoint* countable unions. * The proof of this theorem relies on the notion of `IsPiSystem`, i.e., a collection of sets which is closed under binary non-empty intersections. Note that this is a small variation around the usual notion in the literature, which often requires that a π-system is non-empty, and closed also under disjoint intersections. This variation turns out to be convenient for the formalization. * The proof of Dynkin's π-λ theorem also requires the notion of `DynkinSystem`, i.e., a collection of sets which contains the empty set, is closed under complementation and under countable union of pairwise disjoint sets. The disjointness condition is the only difference with `σ`-algebras. * `generatePiSystem g` gives the minimal π-system containing `g`. This can be considered a Galois insertion into both measurable spaces and sets. * `generateFrom_generatePiSystem_eq` proves that if you start from a collection of sets `g`, take the generated π-system, and then the generated σ-algebra, you get the same result as the σ-algebra generated from `g`. This is useful because there are connections between independent sets that are π-systems and the generated independent spaces. * `mem_generatePiSystem_iUnion_elim` and `mem_generatePiSystem_iUnion_elim'` show that any element of the π-system generated from the union of a set of π-systems can be represented as the intersection of a finite number of elements from these sets. * `piiUnionInter` defines a new π-system from a family of π-systems `π : ι → Set (Set α)` and a set of indices `S : Set ι`. `piiUnionInter π S` is the set of sets that can be written as `⋂ x ∈ t, f x` for some finset `t ∈ S` and sets `f x ∈ π x`. ## Implementation details * `IsPiSystem` is a predicate, not a type. Thus, we don't explicitly define the galois insertion, nor do we define a complete lattice. In theory, we could define a complete lattice and galois insertion on the subtype corresponding to `IsPiSystem`. -/ open MeasurableSpace Set open scoped Classical open MeasureTheory /-- A π-system is a collection of subsets of `α` that is closed under binary intersection of non-disjoint sets. Usually it is also required that the collection is nonempty, but we don't do that here. -/ def IsPiSystem {α} (C : Set (Set α)) : Prop := ∀ᵉ (s ∈ C) (t ∈ C), (s ∩ t : Set α).Nonempty → s ∩ t ∈ C #align is_pi_system IsPiSystem namespace MeasurableSpace theorem isPiSystem_measurableSet {α : Type*} [MeasurableSpace α] : IsPiSystem { s : Set α | MeasurableSet s } := fun _ hs _ ht _ => hs.inter ht #align measurable_space.is_pi_system_measurable_set MeasurableSpace.isPiSystem_measurableSet end MeasurableSpace theorem IsPiSystem.singleton {α} (S : Set α) : IsPiSystem ({S} : Set (Set α)) := by intro s h_s t h_t _ rw [Set.mem_singleton_iff.1 h_s, Set.mem_singleton_iff.1 h_t, Set.inter_self, Set.mem_singleton_iff] #align is_pi_system.singleton IsPiSystem.singleton theorem IsPiSystem.insert_empty {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert ∅ S) := by intro s hs t ht hst cases' hs with hs hs · simp [hs] · cases' ht with ht ht · simp [ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_empty IsPiSystem.insert_empty theorem IsPiSystem.insert_univ {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert Set.univ S) := by intro s hs t ht hst cases' hs with hs hs · cases' ht with ht ht <;> simp [hs, ht] · cases' ht with ht ht · simp [hs, ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) #align is_pi_system.insert_univ IsPiSystem.insert_univ
Mathlib/MeasureTheory/PiSystem.lean
105
109
theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) : IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by
rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst rw [← Set.preimage_inter] at hst ⊢ exact ⟨s ∩ t, h_pi s hs_mem t ht_mem (nonempty_of_nonempty_preimage hst), rfl⟩
/- 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, Johan Commelin -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.BigOperators import Mathlib.Algebra.Polynomial.Degree.Lemmas import Mathlib.Algebra.Polynomial.Div #align_import data.polynomial.ring_division from "leanprover-community/mathlib"@"8efcf8022aac8e01df8d302dcebdbc25d6a886c8" /-! # Theory of univariate polynomials We prove basic results about univariate polynomials. -/ noncomputable section open Polynomial open Finset namespace Polynomial universe u v w z variable {R : Type u} {S : Type v} {T : Type w} {a b : R} {n : ℕ} section CommRing variable [CommRing R] {p q : R[X]} section variable [Semiring S] theorem natDegree_pos_of_aeval_root [Algebra R S] {p : R[X]} (hp : p ≠ 0) {z : S} (hz : aeval z p = 0) (inj : ∀ x : R, algebraMap R S x = 0 → x = 0) : 0 < p.natDegree := natDegree_pos_of_eval₂_root hp (algebraMap R S) hz inj #align polynomial.nat_degree_pos_of_aeval_root Polynomial.natDegree_pos_of_aeval_root theorem degree_pos_of_aeval_root [Algebra R S] {p : R[X]} (hp : p ≠ 0) {z : S} (hz : aeval z p = 0) (inj : ∀ x : R, algebraMap R S x = 0 → x = 0) : 0 < p.degree := natDegree_pos_iff_degree_pos.mp (natDegree_pos_of_aeval_root hp hz inj) #align polynomial.degree_pos_of_aeval_root Polynomial.degree_pos_of_aeval_root theorem modByMonic_eq_of_dvd_sub (hq : q.Monic) {p₁ p₂ : R[X]} (h : q ∣ p₁ - p₂) : p₁ %ₘ q = p₂ %ₘ q := by nontriviality R obtain ⟨f, sub_eq⟩ := h refine (div_modByMonic_unique (p₂ /ₘ q + f) _ hq ⟨?_, degree_modByMonic_lt _ hq⟩).2 rw [sub_eq_iff_eq_add.mp sub_eq, mul_add, ← add_assoc, modByMonic_add_div _ hq, add_comm] #align polynomial.mod_by_monic_eq_of_dvd_sub Polynomial.modByMonic_eq_of_dvd_sub theorem add_modByMonic (p₁ p₂ : R[X]) : (p₁ + p₂) %ₘ q = p₁ %ₘ q + p₂ %ₘ q := by by_cases hq : q.Monic · cases' subsingleton_or_nontrivial R with hR hR · simp only [eq_iff_true_of_subsingleton] · exact (div_modByMonic_unique (p₁ /ₘ q + p₂ /ₘ q) _ hq ⟨by rw [mul_add, add_left_comm, add_assoc, modByMonic_add_div _ hq, ← add_assoc, add_comm (q * _), modByMonic_add_div _ hq], (degree_add_le _ _).trans_lt (max_lt (degree_modByMonic_lt _ hq) (degree_modByMonic_lt _ hq))⟩).2 · simp_rw [modByMonic_eq_of_not_monic _ hq] #align polynomial.add_mod_by_monic Polynomial.add_modByMonic
Mathlib/Algebra/Polynomial/RingDivision.lean
72
80
theorem smul_modByMonic (c : R) (p : R[X]) : c • p %ₘ q = c • (p %ₘ q) := by
by_cases hq : q.Monic · cases' subsingleton_or_nontrivial R with hR hR · simp only [eq_iff_true_of_subsingleton] · exact (div_modByMonic_unique (c • (p /ₘ q)) (c • (p %ₘ q)) hq ⟨by rw [mul_smul_comm, ← smul_add, modByMonic_add_div p hq], (degree_smul_le _ _).trans_lt (degree_modByMonic_lt _ hq)⟩).2 · simp_rw [modByMonic_eq_of_not_monic _ hq]
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Johannes Hölzl, Patrick Massot -/ import Mathlib.Data.Set.Image import Mathlib.Data.SProd #align_import data.set.prod from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" /-! # Sets in product and pi types This file defines the product of sets in `α × β` and in `Π i, α i` along with the diagonal of a type. ## Main declarations * `Set.prod`: Binary product of sets. For `s : Set α`, `t : Set β`, we have `s.prod t : Set (α × β)`. * `Set.diagonal`: Diagonal of a type. `Set.diagonal α = {(x, x) | x : α}`. * `Set.offDiag`: Off-diagonal. `s ×ˢ s` without the diagonal. * `Set.pi`: Arbitrary product of sets. -/ open Function namespace Set /-! ### Cartesian binary product of sets -/ section Prod variable {α β γ δ : Type*} {s s₁ s₂ : Set α} {t t₁ t₂ : Set β} {a : α} {b : β} theorem Subsingleton.prod (hs : s.Subsingleton) (ht : t.Subsingleton) : (s ×ˢ t).Subsingleton := fun _x hx _y hy ↦ Prod.ext (hs hx.1 hy.1) (ht hx.2 hy.2) noncomputable instance decidableMemProd [DecidablePred (· ∈ s)] [DecidablePred (· ∈ t)] : DecidablePred (· ∈ s ×ˢ t) := fun _ => And.decidable #align set.decidable_mem_prod Set.decidableMemProd @[gcongr] theorem prod_mono (hs : s₁ ⊆ s₂) (ht : t₁ ⊆ t₂) : s₁ ×ˢ t₁ ⊆ s₂ ×ˢ t₂ := fun _ ⟨h₁, h₂⟩ => ⟨hs h₁, ht h₂⟩ #align set.prod_mono Set.prod_mono @[gcongr] theorem prod_mono_left (hs : s₁ ⊆ s₂) : s₁ ×ˢ t ⊆ s₂ ×ˢ t := prod_mono hs Subset.rfl #align set.prod_mono_left Set.prod_mono_left @[gcongr] theorem prod_mono_right (ht : t₁ ⊆ t₂) : s ×ˢ t₁ ⊆ s ×ˢ t₂ := prod_mono Subset.rfl ht #align set.prod_mono_right Set.prod_mono_right @[simp] theorem prod_self_subset_prod_self : s₁ ×ˢ s₁ ⊆ s₂ ×ˢ s₂ ↔ s₁ ⊆ s₂ := ⟨fun h _ hx => (h (mk_mem_prod hx hx)).1, fun h _ hx => ⟨h hx.1, h hx.2⟩⟩ #align set.prod_self_subset_prod_self Set.prod_self_subset_prod_self @[simp] theorem prod_self_ssubset_prod_self : s₁ ×ˢ s₁ ⊂ s₂ ×ˢ s₂ ↔ s₁ ⊂ s₂ := and_congr prod_self_subset_prod_self <| not_congr prod_self_subset_prod_self #align set.prod_self_ssubset_prod_self Set.prod_self_ssubset_prod_self theorem prod_subset_iff {P : Set (α × β)} : s ×ˢ t ⊆ P ↔ ∀ x ∈ s, ∀ y ∈ t, (x, y) ∈ P := ⟨fun h _ hx _ hy => h (mk_mem_prod hx hy), fun h ⟨_, _⟩ hp => h _ hp.1 _ hp.2⟩ #align set.prod_subset_iff Set.prod_subset_iff theorem forall_prod_set {p : α × β → Prop} : (∀ x ∈ s ×ˢ t, p x) ↔ ∀ x ∈ s, ∀ y ∈ t, p (x, y) := prod_subset_iff #align set.forall_prod_set Set.forall_prod_set theorem exists_prod_set {p : α × β → Prop} : (∃ x ∈ s ×ˢ t, p x) ↔ ∃ x ∈ s, ∃ y ∈ t, p (x, y) := by simp [and_assoc] #align set.exists_prod_set Set.exists_prod_set @[simp] theorem prod_empty : s ×ˢ (∅ : Set β) = ∅ := by ext exact and_false_iff _ #align set.prod_empty Set.prod_empty @[simp] theorem empty_prod : (∅ : Set α) ×ˢ t = ∅ := by ext exact false_and_iff _ #align set.empty_prod Set.empty_prod @[simp, mfld_simps] theorem univ_prod_univ : @univ α ×ˢ @univ β = univ := by ext exact true_and_iff _ #align set.univ_prod_univ Set.univ_prod_univ theorem univ_prod {t : Set β} : (univ : Set α) ×ˢ t = Prod.snd ⁻¹' t := by simp [prod_eq] #align set.univ_prod Set.univ_prod theorem prod_univ {s : Set α} : s ×ˢ (univ : Set β) = Prod.fst ⁻¹' s := by simp [prod_eq] #align set.prod_univ Set.prod_univ @[simp] lemma prod_eq_univ [Nonempty α] [Nonempty β] : s ×ˢ t = univ ↔ s = univ ∧ t = univ := by simp [eq_univ_iff_forall, forall_and] @[simp] theorem singleton_prod : ({a} : Set α) ×ˢ t = Prod.mk a '' t := by ext ⟨x, y⟩ simp [and_left_comm, eq_comm] #align set.singleton_prod Set.singleton_prod @[simp] theorem prod_singleton : s ×ˢ ({b} : Set β) = (fun a => (a, b)) '' s := by ext ⟨x, y⟩ simp [and_left_comm, eq_comm] #align set.prod_singleton Set.prod_singleton
Mathlib/Data/Set/Prod.lean
122
122
theorem singleton_prod_singleton : ({a} : Set α) ×ˢ ({b} : Set β) = {(a, b)} := by
simp
/- Copyright (c) 2014 Robert Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro -/ import Mathlib.Algebra.Field.Defs import Mathlib.Algebra.GroupWithZero.Units.Lemmas import Mathlib.Algebra.Ring.Commute import Mathlib.Algebra.Ring.Invertible import Mathlib.Order.Synonym #align_import algebra.field.basic from "leanprover-community/mathlib"@"05101c3df9d9cfe9430edc205860c79b6d660102" /-! # Lemmas about division (semi)rings and (semi)fields -/ open Function OrderDual Set universe u variable {α β K : Type*} section DivisionSemiring variable [DivisionSemiring α] {a b c d : α} theorem add_div (a b c : α) : (a + b) / c = a / c + b / c := by simp_rw [div_eq_mul_inv, add_mul] #align add_div add_div @[field_simps] theorem div_add_div_same (a b c : α) : a / c + b / c = (a + b) / c := (add_div _ _ _).symm #align div_add_div_same div_add_div_same theorem same_add_div (h : b ≠ 0) : (b + a) / b = 1 + a / b := by rw [← div_self h, add_div] #align same_add_div same_add_div theorem div_add_same (h : b ≠ 0) : (a + b) / b = a / b + 1 := by rw [← div_self h, add_div] #align div_add_same div_add_same theorem one_add_div (h : b ≠ 0) : 1 + a / b = (b + a) / b := (same_add_div h).symm #align one_add_div one_add_div theorem div_add_one (h : b ≠ 0) : a / b + 1 = (a + b) / b := (div_add_same h).symm #align div_add_one div_add_one /-- See `inv_add_inv` for the more convenient version when `K` is commutative. -/ theorem inv_add_inv' (ha : a ≠ 0) (hb : b ≠ 0) : a⁻¹ + b⁻¹ = a⁻¹ * (a + b) * b⁻¹ := let _ := invertibleOfNonzero ha; let _ := invertibleOfNonzero hb; invOf_add_invOf a b
Mathlib/Algebra/Field/Basic.lean
56
58
theorem one_div_mul_add_mul_one_div_eq_one_div_add_one_div (ha : a ≠ 0) (hb : b ≠ 0) : 1 / a * (a + b) * (1 / b) = 1 / a + 1 / b := by
simpa only [one_div] using (inv_add_inv' ha hb).symm
/- 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.Algebra.Order.Floor import Mathlib.Algebra.Order.Field.Power import Mathlib.Data.Nat.Log #align_import data.int.log from "leanprover-community/mathlib"@"1f0096e6caa61e9c849ec2adbd227e960e9dff58" /-! # Integer logarithms in a field with respect to a natural base This file defines two `ℤ`-valued analogs of the logarithm of `r : R` with base `b : ℕ`: * `Int.log b r`: Lower logarithm, or floor **log**. Greatest `k` such that `↑b^k ≤ r`. * `Int.clog b r`: Upper logarithm, or **c**eil **log**. Least `k` such that `r ≤ ↑b^k`. Note that `Int.log` gives the position of the left-most non-zero digit: ```lean #eval (Int.log 10 (0.09 : ℚ), Int.log 10 (0.10 : ℚ), Int.log 10 (0.11 : ℚ)) -- (-2, -1, -1) #eval (Int.log 10 (9 : ℚ), Int.log 10 (10 : ℚ), Int.log 10 (11 : ℚ)) -- (0, 1, 1) ``` which means it can be used for computing digit expansions ```lean import Data.Fin.VecNotation import Mathlib.Data.Rat.Floor def digits (b : ℕ) (q : ℚ) (n : ℕ) : ℕ := ⌊q * ((b : ℚ) ^ (n - Int.log b q))⌋₊ % b #eval digits 10 (1/7) ∘ ((↑) : Fin 8 → ℕ) -- ![1, 4, 2, 8, 5, 7, 1, 4] ``` ## Main results * For `Int.log`: * `Int.zpow_log_le_self`, `Int.lt_zpow_succ_log_self`: the bounds formed by `Int.log`, `(b : R) ^ log b r ≤ r < (b : R) ^ (log b r + 1)`. * `Int.zpow_log_gi`: the galois coinsertion between `zpow` and `Int.log`. * For `Int.clog`: * `Int.zpow_pred_clog_lt_self`, `Int.self_le_zpow_clog`: the bounds formed by `Int.clog`, `(b : R) ^ (clog b r - 1) < r ≤ (b : R) ^ clog b r`. * `Int.clog_zpow_gi`: the galois insertion between `Int.clog` and `zpow`. * `Int.neg_log_inv_eq_clog`, `Int.neg_clog_inv_eq_log`: the link between the two definitions. -/ variable {R : Type*} [LinearOrderedSemifield R] [FloorSemiring R] namespace Int /-- The greatest power of `b` such that `b ^ log b r ≤ r`. -/ def log (b : ℕ) (r : R) : ℤ := if 1 ≤ r then Nat.log b ⌊r⌋₊ else -Nat.clog b ⌈r⁻¹⌉₊ #align int.log Int.log theorem log_of_one_le_right (b : ℕ) {r : R} (hr : 1 ≤ r) : log b r = Nat.log b ⌊r⌋₊ := if_pos hr #align int.log_of_one_le_right Int.log_of_one_le_right
Mathlib/Data/Int/Log.lean
66
70
theorem log_of_right_le_one (b : ℕ) {r : R} (hr : r ≤ 1) : log b r = -Nat.clog b ⌈r⁻¹⌉₊ := by
obtain rfl | hr := hr.eq_or_lt · rw [log, if_pos hr, inv_one, Nat.ceil_one, Nat.floor_one, Nat.log_one_right, Nat.clog_one_right, Int.ofNat_zero, neg_zero] · exact if_neg hr.not_le
/- 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`. -/ theorem IsSRGWith.card_neighborFinset_union_of_not_adj {v w : V} (h : G.IsSRGWith n k ℓ μ) (hne : v ≠ w) (ha : ¬G.Adj v w) : (G.neighborFinset v ∪ G.neighborFinset w).card = 2 * k - μ := by rw [← h.of_not_adj hne ha] apply h.card_neighborFinset_union_eq set_option linter.uppercaseLean3 false in #align simple_graph.is_SRG_with.card_neighbor_finset_union_of_not_adj SimpleGraph.IsSRGWith.card_neighborFinset_union_of_not_adj
Mathlib/Combinatorics/SimpleGraph/StronglyRegular.lean
110
113
theorem IsSRGWith.card_neighborFinset_union_of_adj {v w : V} (h : G.IsSRGWith n k ℓ μ) (ha : G.Adj v w) : (G.neighborFinset v ∪ G.neighborFinset w).card = 2 * k - ℓ := by
rw [← h.of_adj v w ha] apply h.card_neighborFinset_union_eq
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.LinearAlgebra.AffineSpace.Basis import Mathlib.LinearAlgebra.Matrix.NonsingularInverse #align_import linear_algebra.affine_space.matrix from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0" /-! # Matrix results for barycentric co-ordinates Results about the matrix of barycentric co-ordinates for a family of points in an affine space, with respect to some affine basis. -/ open Affine Matrix open Set universe u₁ u₂ u₃ u₄ variable {ι : Type u₁} {k : Type u₂} {V : Type u₃} {P : Type u₄} variable [AddCommGroup V] [AffineSpace V P] namespace AffineBasis section Ring variable [Ring k] [Module k V] (b : AffineBasis ι k P) /-- Given an affine basis `p`, and a family of points `q : ι' → P`, this is the matrix whose rows are the barycentric coordinates of `q` with respect to `p`. It is an affine equivalent of `Basis.toMatrix`. -/ noncomputable def toMatrix {ι' : Type*} (q : ι' → P) : Matrix ι' ι k := fun i j => b.coord j (q i) #align affine_basis.to_matrix AffineBasis.toMatrix @[simp] theorem toMatrix_apply {ι' : Type*} (q : ι' → P) (i : ι') (j : ι) : b.toMatrix q i j = b.coord j (q i) := rfl #align affine_basis.to_matrix_apply AffineBasis.toMatrix_apply @[simp] theorem toMatrix_self [DecidableEq ι] : b.toMatrix b = (1 : Matrix ι ι k) := by ext i j rw [toMatrix_apply, coord_apply, Matrix.one_eq_pi_single, Pi.single_apply] #align affine_basis.to_matrix_self AffineBasis.toMatrix_self variable {ι' : Type*} theorem toMatrix_row_sum_one [Fintype ι] (q : ι' → P) (i : ι') : ∑ j, b.toMatrix q i j = 1 := by simp #align affine_basis.to_matrix_row_sum_one AffineBasis.toMatrix_row_sum_one /-- Given a family of points `p : ι' → P` and an affine basis `b`, if the matrix whose rows are the coordinates of `p` with respect `b` has a right inverse, then `p` is affine independent. -/ theorem affineIndependent_of_toMatrix_right_inv [Fintype ι] [Finite ι'] [DecidableEq ι'] (p : ι' → P) {A : Matrix ι ι' k} (hA : b.toMatrix p * A = 1) : AffineIndependent k p := by cases nonempty_fintype ι' rw [affineIndependent_iff_eq_of_fintype_affineCombination_eq] intro w₁ w₂ hw₁ hw₂ hweq have hweq' : w₁ ᵥ* b.toMatrix p = w₂ ᵥ* b.toMatrix p := by ext j change (∑ i, w₁ i • b.coord j (p i)) = ∑ i, w₂ i • b.coord j (p i) -- Porting note: Added `u` because `∘` was causing trouble have u : (fun i => b.coord j (p i)) = b.coord j ∘ p := by simp only [(· ∘ ·)] rw [← Finset.univ.affineCombination_eq_linear_combination _ _ hw₁, ← Finset.univ.affineCombination_eq_linear_combination _ _ hw₂, u, ← Finset.univ.map_affineCombination p w₁ hw₁, ← Finset.univ.map_affineCombination p w₂ hw₂, hweq] replace hweq' := congr_arg (fun w => w ᵥ* A) hweq' simpa only [Matrix.vecMul_vecMul, hA, Matrix.vecMul_one] using hweq' #align affine_basis.affine_independent_of_to_matrix_right_inv AffineBasis.affineIndependent_of_toMatrix_right_inv /-- Given a family of points `p : ι' → P` and an affine basis `b`, if the matrix whose rows are the coordinates of `p` with respect `b` has a left inverse, then `p` spans the entire space. -/ theorem affineSpan_eq_top_of_toMatrix_left_inv [Finite ι] [Fintype ι'] [DecidableEq ι] [Nontrivial k] (p : ι' → P) {A : Matrix ι ι' k} (hA : A * b.toMatrix p = 1) : affineSpan k (range p) = ⊤ := by cases nonempty_fintype ι suffices ∀ i, b i ∈ affineSpan k (range p) by rw [eq_top_iff, ← b.tot, affineSpan_le] rintro q ⟨i, rfl⟩ exact this i intro i have hAi : ∑ j, A i j = 1 := by calc ∑ j, A i j = ∑ j, A i j * ∑ l, b.toMatrix p j l := by simp _ = ∑ j, ∑ l, A i j * b.toMatrix p j l := by simp_rw [Finset.mul_sum] _ = ∑ l, ∑ j, A i j * b.toMatrix p j l := by rw [Finset.sum_comm] _ = ∑ l, (A * b.toMatrix p) i l := rfl _ = 1 := by simp [hA, Matrix.one_apply, Finset.filter_eq] have hbi : b i = Finset.univ.affineCombination k p (A i) := by apply b.ext_elem intro j rw [b.coord_apply, Finset.univ.map_affineCombination _ _ hAi, Finset.univ.affineCombination_eq_linear_combination _ _ hAi] change _ = (A * b.toMatrix p) i j simp_rw [hA, Matrix.one_apply, @eq_comm _ i j] rw [hbi] exact affineCombination_mem_affineSpan hAi p #align affine_basis.affine_span_eq_top_of_to_matrix_left_inv AffineBasis.affineSpan_eq_top_of_toMatrix_left_inv variable [Fintype ι] (b₂ : AffineBasis ι k P) /-- A change of basis formula for barycentric coordinates. See also `AffineBasis.toMatrix_inv_vecMul_toMatrix`. -/ @[simp]
Mathlib/LinearAlgebra/AffineSpace/Matrix.lean
114
119
theorem toMatrix_vecMul_coords (x : P) : b₂.coords x ᵥ* b.toMatrix b₂ = b.coords x := by
ext j change _ = b.coord j x conv_rhs => rw [← b₂.affineCombination_coord_eq_self x] rw [Finset.map_affineCombination _ _ _ (b₂.sum_coord_apply_eq_one x)] simp [Matrix.vecMul, Matrix.dotProduct, toMatrix_apply, coords]
/- Copyright (c) 2019 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Kenny Lau -/ import Mathlib.Algebra.CharP.Defs import Mathlib.RingTheory.Multiplicity import Mathlib.RingTheory.PowerSeries.Basic #align_import ring_theory.power_series.basic from "leanprover-community/mathlib"@"2d5739b61641ee4e7e53eca5688a08f66f2e6a60" /-! # Formal power series (in one variable) - Order The `PowerSeries.order` of a formal power series `φ` is the multiplicity of the variable `X` in `φ`. If the coefficients form an integral domain, then `PowerSeries.order` is an additive valuation (`PowerSeries.order_mul`, `PowerSeries.le_order_add`). We prove that if the commutative ring `R` of coefficients is an integral domain, then the ring `R⟦X⟧` of formal power series in one variable over `R` is an integral domain. Given a non-zero power series `f`, `divided_by_X_pow_order f` is the power series obtained by dividing out the largest power of X that divides `f`, that is its order. This is useful when proving that `R⟦X⟧` is a normalization monoid, which is done in `PowerSeries.Inverse`. -/ noncomputable section open Polynomial open Finset (antidiagonal mem_antidiagonal) namespace PowerSeries open Finsupp (single) variable {R : Type*} section OrderBasic open multiplicity variable [Semiring R] {φ : R⟦X⟧} theorem exists_coeff_ne_zero_iff_ne_zero : (∃ n : ℕ, coeff R n φ ≠ 0) ↔ φ ≠ 0 := by refine not_iff_not.mp ?_ push_neg -- FIXME: the `FunLike.coe` doesn't seem to be picked up in the expression after #8386? simp [PowerSeries.ext_iff, (coeff R _).map_zero] #align power_series.exists_coeff_ne_zero_iff_ne_zero PowerSeries.exists_coeff_ne_zero_iff_ne_zero /-- The order of a formal power series `φ` is the greatest `n : PartENat` such that `X^n` divides `φ`. The order is `⊤` if and only if `φ = 0`. -/ def order (φ : R⟦X⟧) : PartENat := letI := Classical.decEq R letI := Classical.decEq R⟦X⟧ if h : φ = 0 then ⊤ else Nat.find (exists_coeff_ne_zero_iff_ne_zero.mpr h) #align power_series.order PowerSeries.order /-- The order of the `0` power series is infinite. -/ @[simp] theorem order_zero : order (0 : R⟦X⟧) = ⊤ := dif_pos rfl #align power_series.order_zero PowerSeries.order_zero theorem order_finite_iff_ne_zero : (order φ).Dom ↔ φ ≠ 0 := by simp only [order] constructor · split_ifs with h <;> intro H · simp only [PartENat.top_eq_none, Part.not_none_dom] at H · exact h · intro h simp [h] #align power_series.order_finite_iff_ne_zero PowerSeries.order_finite_iff_ne_zero /-- If the order of a formal power series is finite, then the coefficient indexed by the order is nonzero. -/ theorem coeff_order (h : (order φ).Dom) : coeff R (φ.order.get h) φ ≠ 0 := by classical simp only [order, order_finite_iff_ne_zero.mp h, not_false_iff, dif_neg, PartENat.get_natCast'] generalize_proofs h exact Nat.find_spec h #align power_series.coeff_order PowerSeries.coeff_order /-- If the `n`th coefficient of a formal power series is nonzero, then the order of the power series is less than or equal to `n`. -/ theorem order_le (n : ℕ) (h : coeff R n φ ≠ 0) : order φ ≤ n := by classical rw [order, dif_neg] · simp only [PartENat.coe_le_coe] exact Nat.find_le h · exact exists_coeff_ne_zero_iff_ne_zero.mp ⟨n, h⟩ #align power_series.order_le PowerSeries.order_le /-- The `n`th coefficient of a formal power series is `0` if `n` is strictly smaller than the order of the power series. -/ theorem coeff_of_lt_order (n : ℕ) (h : ↑n < order φ) : coeff R n φ = 0 := by contrapose! h exact order_le _ h #align power_series.coeff_of_lt_order PowerSeries.coeff_of_lt_order /-- The `0` power series is the unique power series with infinite order. -/ @[simp] theorem order_eq_top {φ : R⟦X⟧} : φ.order = ⊤ ↔ φ = 0 := PartENat.not_dom_iff_eq_top.symm.trans order_finite_iff_ne_zero.not_left #align power_series.order_eq_top PowerSeries.order_eq_top /-- The order of a formal power series is at least `n` if the `i`th coefficient is `0` for all `i < n`. -/ theorem nat_le_order (φ : R⟦X⟧) (n : ℕ) (h : ∀ i < n, coeff R i φ = 0) : ↑n ≤ order φ := by by_contra H; rw [not_le] at H have : (order φ).Dom := PartENat.dom_of_le_natCast H.le rw [← PartENat.natCast_get this, PartENat.coe_lt_coe] at H exact coeff_order this (h _ H) #align power_series.nat_le_order PowerSeries.nat_le_order /-- The order of a formal power series is at least `n` if the `i`th coefficient is `0` for all `i < n`. -/ theorem le_order (φ : R⟦X⟧) (n : PartENat) (h : ∀ i : ℕ, ↑i < n → coeff R i φ = 0) : n ≤ order φ := by induction n using PartENat.casesOn · show _ ≤ _ rw [top_le_iff, order_eq_top] ext i exact h _ (PartENat.natCast_lt_top i) · apply nat_le_order simpa only [PartENat.coe_lt_coe] using h #align power_series.le_order PowerSeries.le_order /-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero, and the `i`th coefficient is `0` for all `i < n`. -/
Mathlib/RingTheory/PowerSeries/Order.lean
134
139
theorem order_eq_nat {φ : R⟦X⟧} {n : ℕ} : order φ = n ↔ coeff R n φ ≠ 0 ∧ ∀ i, i < n → coeff R i φ = 0 := by
classical rcases eq_or_ne φ 0 with (rfl | hφ) · simpa [(coeff R _).map_zero] using (PartENat.natCast_ne_top _).symm simp [order, dif_neg hφ, Nat.find_eq_iff]
/- Copyright (c) 2020 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker -/ import Mathlib.Algebra.Polynomial.Eval import Mathlib.LinearAlgebra.Dimension.Constructions #align_import algebra.linear_recurrence from "leanprover-community/mathlib"@"039a089d2a4b93c761b234f3e5f5aeb752bac60f" /-! # Linear recurrence Informally, a "linear recurrence" is an assertion of the form `∀ n : ℕ, u (n + d) = a 0 * u n + a 1 * u (n+1) + ... + a (d-1) * u (n+d-1)`, where `u` is a sequence, `d` is the *order* of the recurrence and the `a i` are its *coefficients*. In this file, we define the structure `LinearRecurrence` so that `LinearRecurrence.mk d a` represents the above relation, and we call a sequence `u` which verifies it a *solution* of the linear recurrence. We prove a few basic lemmas about this concept, such as : * the space of solutions is a submodule of `(ℕ → α)` (i.e a vector space if `α` is a field) * the function that maps a solution `u` to its first `d` terms builds a `LinearEquiv` between the solution space and `Fin d → α`, aka `α ^ d`. As a consequence, two solutions are equal if and only if their first `d` terms are equals. * a geometric sequence `q ^ n` is solution iff `q` is a root of a particular polynomial, which we call the *characteristic polynomial* of the recurrence Of course, although we can inductively generate solutions (cf `mkSol`), the interesting part would be to determinate closed-forms for the solutions. This is currently *not implemented*, as we are waiting for definition and properties of eigenvalues and eigenvectors. -/ noncomputable section open Finset open Polynomial /-- A "linear recurrence relation" over a commutative semiring is given by its order `n` and `n` coefficients. -/ structure LinearRecurrence (α : Type*) [CommSemiring α] where order : ℕ coeffs : Fin order → α #align linear_recurrence LinearRecurrence instance (α : Type*) [CommSemiring α] : Inhabited (LinearRecurrence α) := ⟨⟨0, default⟩⟩ namespace LinearRecurrence section CommSemiring variable {α : Type*} [CommSemiring α] (E : LinearRecurrence α) /-- We say that a sequence `u` is solution of `LinearRecurrence order coeffs` when we have `u (n + order) = ∑ i : Fin order, coeffs i * u (n + i)` for any `n`. -/ def IsSolution (u : ℕ → α) := ∀ n, u (n + E.order) = ∑ i, E.coeffs i * u (n + i) #align linear_recurrence.is_solution LinearRecurrence.IsSolution /-- A solution of a `LinearRecurrence` which satisfies certain initial conditions. We will prove this is the only such solution. -/ def mkSol (init : Fin E.order → α) : ℕ → α | n => if h : n < E.order then init ⟨n, h⟩ else ∑ k : Fin E.order, have _ : n - E.order + k < n := by rw [add_comm, ← add_tsub_assoc_of_le (not_lt.mp h), tsub_lt_iff_left] · exact add_lt_add_right k.is_lt n · convert add_le_add (zero_le (k : ℕ)) (not_lt.mp h) simp only [zero_add] E.coeffs k * mkSol init (n - E.order + k) #align linear_recurrence.mk_sol LinearRecurrence.mkSol /-- `E.mkSol` indeed gives solutions to `E`. -/ theorem is_sol_mkSol (init : Fin E.order → α) : E.IsSolution (E.mkSol init) := by intro n rw [mkSol] simp #align linear_recurrence.is_sol_mk_sol LinearRecurrence.is_sol_mkSol /-- `E.mkSol init`'s first `E.order` terms are `init`. -/
Mathlib/Algebra/LinearRecurrence.lean
92
95
theorem mkSol_eq_init (init : Fin E.order → α) : ∀ n : Fin E.order, E.mkSol init n = init n := by
intro n rw [mkSol] simp only [n.is_lt, dif_pos, Fin.mk_val, Fin.eta]
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Scott Morrison, Adam Topaz -/ import Mathlib.AlgebraicTopology.SimplexCategory import Mathlib.CategoryTheory.Comma.Arrow import Mathlib.CategoryTheory.Limits.FunctorCategory import Mathlib.CategoryTheory.Opposites #align_import algebraic_topology.simplicial_object from "leanprover-community/mathlib"@"5ed51dc37c6b891b79314ee11a50adc2b1df6fd6" /-! # Simplicial objects in a category. A simplicial object in a category `C` is a `C`-valued presheaf on `SimplexCategory`. (Similarly a cosimplicial object is functor `SimplexCategory ⥤ C`.) Use the notation `X _[n]` in the `Simplicial` locale to obtain the `n`-th term of a (co)simplicial object `X`, where `n` is a natural number. -/ open Opposite open CategoryTheory open CategoryTheory.Limits universe v u v' u' namespace CategoryTheory variable (C : Type u) [Category.{v} C] -- porting note (#5171): removed @[nolint has_nonempty_instance] /-- The category of simplicial objects valued in a category `C`. This is the category of contravariant functors from `SimplexCategory` to `C`. -/ def SimplicialObject := SimplexCategoryᵒᵖ ⥤ C #align category_theory.simplicial_object CategoryTheory.SimplicialObject @[simps!] instance : Category (SimplicialObject C) := by dsimp only [SimplicialObject] infer_instance namespace SimplicialObject set_option quotPrecheck false in /-- `X _[n]` denotes the `n`th-term of the simplicial object X -/ scoped[Simplicial] notation3:1000 X " _[" n "]" => (X : CategoryTheory.SimplicialObject _).obj (Opposite.op (SimplexCategory.mk n)) open Simplicial instance {J : Type v} [SmallCategory J] [HasLimitsOfShape J C] : HasLimitsOfShape J (SimplicialObject C) := by dsimp [SimplicialObject] infer_instance instance [HasLimits C] : HasLimits (SimplicialObject C) := ⟨inferInstance⟩ instance {J : Type v} [SmallCategory J] [HasColimitsOfShape J C] : HasColimitsOfShape J (SimplicialObject C) := by dsimp [SimplicialObject] infer_instance instance [HasColimits C] : HasColimits (SimplicialObject C) := ⟨inferInstance⟩ variable {C} -- Porting note (#10688): added to ease automation @[ext] lemma hom_ext {X Y : SimplicialObject C} (f g : X ⟶ Y) (h : ∀ (n : SimplexCategoryᵒᵖ), f.app n = g.app n) : f = g := NatTrans.ext _ _ (by ext; apply h) variable (X : SimplicialObject C) /-- Face maps for a simplicial object. -/ def δ {n} (i : Fin (n + 2)) : X _[n + 1] ⟶ X _[n] := X.map (SimplexCategory.δ i).op #align category_theory.simplicial_object.δ CategoryTheory.SimplicialObject.δ /-- Degeneracy maps for a simplicial object. -/ def σ {n} (i : Fin (n + 1)) : X _[n] ⟶ X _[n + 1] := X.map (SimplexCategory.σ i).op #align category_theory.simplicial_object.σ CategoryTheory.SimplicialObject.σ /-- Isomorphisms from identities in ℕ. -/ def eqToIso {n m : ℕ} (h : n = m) : X _[n] ≅ X _[m] := X.mapIso (CategoryTheory.eqToIso (by congr)) #align category_theory.simplicial_object.eq_to_iso CategoryTheory.SimplicialObject.eqToIso @[simp] theorem eqToIso_refl {n : ℕ} (h : n = n) : X.eqToIso h = Iso.refl _ := by ext simp [eqToIso] #align category_theory.simplicial_object.eq_to_iso_refl CategoryTheory.SimplicialObject.eqToIso_refl /-- The generic case of the first simplicial identity -/ @[reassoc] theorem δ_comp_δ {n} {i j : Fin (n + 2)} (H : i ≤ j) : X.δ j.succ ≫ X.δ i = X.δ (Fin.castSucc i) ≫ X.δ j := by dsimp [δ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ H] #align category_theory.simplicial_object.δ_comp_δ CategoryTheory.SimplicialObject.δ_comp_δ @[reassoc] theorem δ_comp_δ' {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : Fin.castSucc i < j) : X.δ j ≫ X.δ i = X.δ (Fin.castSucc i) ≫ X.δ (j.pred fun (hj : j = 0) => by simp [hj, Fin.not_lt_zero] at H) := by dsimp [δ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ' H] #align category_theory.simplicial_object.δ_comp_δ' CategoryTheory.SimplicialObject.δ_comp_δ' @[reassoc] theorem δ_comp_δ'' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : i ≤ Fin.castSucc j) : X.δ j.succ ≫ X.δ (i.castLT (Nat.lt_of_le_of_lt (Fin.le_iff_val_le_val.mp H) j.is_lt)) = X.δ i ≫ X.δ j := by dsimp [δ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ'' H] #align category_theory.simplicial_object.δ_comp_δ'' CategoryTheory.SimplicialObject.δ_comp_δ'' /-- The special case of the first simplicial identity -/ @[reassoc]
Mathlib/AlgebraicTopology/SimplicialObject.lean
131
134
theorem δ_comp_δ_self {n} {i : Fin (n + 2)} : X.δ (Fin.castSucc i) ≫ X.δ i = X.δ i.succ ≫ X.δ i := by
dsimp [δ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ_self]
/- Copyright (c) 2019 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.Algebra.Order.Ring.Int import Mathlib.Algebra.Ring.Rat #align_import data.rat.order from "leanprover-community/mathlib"@"a59dad53320b73ef180174aae867addd707ef00e" /-! # The rational numbers form a linear ordered field This file constructs the order on `ℚ` and proves that `ℚ` is a discrete, linearly ordered commutative ring. `ℚ` is in fact a linearly ordered field, but this fact is located in `Data.Rat.Field` instead of here because we need the order on `ℚ` to define `ℚ≥0`, which we itself need to define `Field`. ## Tags rat, rationals, field, ℚ, numerator, denominator, num, denom, order, ordering -/ assert_not_exists Field assert_not_exists Finset assert_not_exists Set.Icc assert_not_exists GaloisConnection namespace Rat variable {a b c p q : ℚ} @[simp] lemma divInt_nonneg_iff_of_pos_right {a b : ℤ} (hb : 0 < b) : 0 ≤ a /. b ↔ 0 ≤ a := by cases' hab : a /. b with n d hd hnd rw [mk'_eq_divInt, divInt_eq_iff hb.ne' (mod_cast hd)] at hab rw [← num_nonneg, ← mul_nonneg_iff_of_pos_right hb, ← hab, mul_nonneg_iff_of_pos_right (mod_cast Nat.pos_of_ne_zero hd)] #align rat.mk_nonneg Rat.divInt_nonneg_iff_of_pos_right @[simp] lemma divInt_nonneg {a b : ℤ} (ha : 0 ≤ a) (hb : 0 ≤ b) : 0 ≤ a /. b := by obtain rfl | hb := hb.eq_or_lt · simp rfl rwa [divInt_nonneg_iff_of_pos_right hb] @[simp] lemma mkRat_nonneg {a : ℤ} (ha : 0 ≤ a) (b : ℕ) : 0 ≤ mkRat a b := by simpa using divInt_nonneg ha (Int.natCast_nonneg _)
Mathlib/Algebra/Order/Ring/Rat.lean
50
59
theorem ofScientific_nonneg (m : ℕ) (s : Bool) (e : ℕ) : 0 ≤ Rat.ofScientific m s e := by
rw [Rat.ofScientific] cases s · rw [if_neg (by decide)] refine num_nonneg.mp ?_ rw [num_natCast] exact Int.natCast_nonneg _ · rw [if_pos rfl, normalize_eq_mkRat] exact Rat.mkRat_nonneg (Int.natCast_nonneg _) _
/- 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.Data.Multiset.Nodup import Mathlib.Data.List.NatAntidiagonal #align_import data.multiset.nat_antidiagonal from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Antidiagonals in ℕ × ℕ as multisets This file defines the antidiagonals of ℕ × ℕ as multisets: the `n`-th antidiagonal is the multiset of pairs `(i, j)` such that `i + j = n`. This is useful for polynomial multiplication and more generally for sums going from `0` to `n`. ## Notes This refines file `Data.List.NatAntidiagonal` and is further refined by file `Data.Finset.NatAntidiagonal`. -/ namespace Multiset namespace Nat /-- The antidiagonal of a natural number `n` is the multiset of pairs `(i, j)` such that `i + j = n`. -/ def antidiagonal (n : ℕ) : Multiset (ℕ × ℕ) := List.Nat.antidiagonal n #align multiset.nat.antidiagonal Multiset.Nat.antidiagonal /-- A pair (i, j) is contained in the antidiagonal of `n` if and only if `i + j = n`. -/ @[simp]
Mathlib/Data/Multiset/NatAntidiagonal.lean
36
37
theorem mem_antidiagonal {n : ℕ} {x : ℕ × ℕ} : x ∈ antidiagonal n ↔ x.1 + x.2 = n := by
rw [antidiagonal, mem_coe, List.Nat.mem_antidiagonal]
/- Copyright (c) 2021 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky, Chris Hughes -/ import Mathlib.Data.List.Nodup #align_import data.list.duplicate from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" /-! # List duplicates ## Main definitions * `List.Duplicate x l : Prop` is an inductive property that holds when `x` is a duplicate in `l` ## Implementation details In this file, `x ∈+ l` notation is shorthand for `List.Duplicate x l`. -/ variable {α : Type*} namespace List /-- Property that an element `x : α` of `l : List α` can be found in the list more than once. -/ inductive Duplicate (x : α) : List α → Prop | cons_mem {l : List α} : x ∈ l → Duplicate x (x :: l) | cons_duplicate {y : α} {l : List α} : Duplicate x l → Duplicate x (y :: l) #align list.duplicate List.Duplicate local infixl:50 " ∈+ " => List.Duplicate variable {l : List α} {x : α} theorem Mem.duplicate_cons_self (h : x ∈ l) : x ∈+ x :: l := Duplicate.cons_mem h #align list.mem.duplicate_cons_self List.Mem.duplicate_cons_self theorem Duplicate.duplicate_cons (h : x ∈+ l) (y : α) : x ∈+ y :: l := Duplicate.cons_duplicate h #align list.duplicate.duplicate_cons List.Duplicate.duplicate_cons theorem Duplicate.mem (h : x ∈+ l) : x ∈ l := by induction' h with l' _ y l' _ hm · exact mem_cons_self _ _ · exact mem_cons_of_mem _ hm #align list.duplicate.mem List.Duplicate.mem theorem Duplicate.mem_cons_self (h : x ∈+ x :: l) : x ∈ l := by cases' h with _ h _ _ h · exact h · exact h.mem #align list.duplicate.mem_cons_self List.Duplicate.mem_cons_self @[simp] theorem duplicate_cons_self_iff : x ∈+ x :: l ↔ x ∈ l := ⟨Duplicate.mem_cons_self, Mem.duplicate_cons_self⟩ #align list.duplicate_cons_self_iff List.duplicate_cons_self_iff theorem Duplicate.ne_nil (h : x ∈+ l) : l ≠ [] := fun H => (mem_nil_iff x).mp (H ▸ h.mem) #align list.duplicate.ne_nil List.Duplicate.ne_nil @[simp] theorem not_duplicate_nil (x : α) : ¬x ∈+ [] := fun H => H.ne_nil rfl #align list.not_duplicate_nil List.not_duplicate_nil theorem Duplicate.ne_singleton (h : x ∈+ l) (y : α) : l ≠ [y] := by induction' h with l' h z l' h _ · simp [ne_nil_of_mem h] · simp [ne_nil_of_mem h.mem] #align list.duplicate.ne_singleton List.Duplicate.ne_singleton @[simp] theorem not_duplicate_singleton (x y : α) : ¬x ∈+ [y] := fun H => H.ne_singleton _ rfl #align list.not_duplicate_singleton List.not_duplicate_singleton theorem Duplicate.elim_nil (h : x ∈+ []) : False := not_duplicate_nil x h #align list.duplicate.elim_nil List.Duplicate.elim_nil theorem Duplicate.elim_singleton {y : α} (h : x ∈+ [y]) : False := not_duplicate_singleton x y h #align list.duplicate.elim_singleton List.Duplicate.elim_singleton theorem duplicate_cons_iff {y : α} : x ∈+ y :: l ↔ y = x ∧ x ∈ l ∨ x ∈+ l := by refine ⟨fun h => ?_, fun h => ?_⟩ · cases' h with _ hm _ _ hm · exact Or.inl ⟨rfl, hm⟩ · exact Or.inr hm · rcases h with (⟨rfl | h⟩ | h) · simpa · exact h.cons_duplicate #align list.duplicate_cons_iff List.duplicate_cons_iff theorem Duplicate.of_duplicate_cons {y : α} (h : x ∈+ y :: l) (hx : x ≠ y) : x ∈+ l := by simpa [duplicate_cons_iff, hx.symm] using h #align list.duplicate.of_duplicate_cons List.Duplicate.of_duplicate_cons theorem duplicate_cons_iff_of_ne {y : α} (hne : x ≠ y) : x ∈+ y :: l ↔ x ∈+ l := by simp [duplicate_cons_iff, hne.symm] #align list.duplicate_cons_iff_of_ne List.duplicate_cons_iff_of_ne
Mathlib/Data/List/Duplicate.lean
106
113
theorem Duplicate.mono_sublist {l' : List α} (hx : x ∈+ l) (h : l <+ l') : x ∈+ l' := by
induction' h with l₁ l₂ y _ IH l₁ l₂ y h IH · exact hx · exact (IH hx).duplicate_cons _ · rw [duplicate_cons_iff] at hx ⊢ rcases hx with (⟨rfl, hx⟩ | hx) · simp [h.subset hx] · simp [IH hx]
/- 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.Algebra.Polynomial.Cardinal import Mathlib.RingTheory.Algebraic #align_import algebra.algebraic_card from "leanprover-community/mathlib"@"40494fe75ecbd6d2ec61711baa630cf0a7b7d064" /-! ### Cardinality of algebraic numbers In this file, we prove variants of the following result: the cardinality of algebraic numbers under an R-algebra is at most `# R[X] * ℵ₀`. Although this can be used to prove that real or complex transcendental numbers exist, a more direct proof is given by `Liouville.is_transcendental`. -/ universe u v open Cardinal Polynomial Set open Cardinal Polynomial namespace Algebraic theorem infinite_of_charZero (R A : Type*) [CommRing R] [IsDomain R] [Ring A] [Algebra R A] [CharZero A] : { x : A | IsAlgebraic R x }.Infinite := infinite_of_injective_forall_mem Nat.cast_injective isAlgebraic_nat #align algebraic.infinite_of_char_zero Algebraic.infinite_of_charZero theorem aleph0_le_cardinal_mk_of_charZero (R A : Type*) [CommRing R] [IsDomain R] [Ring A] [Algebra R A] [CharZero A] : ℵ₀ ≤ #{ x : A // IsAlgebraic R x } := infinite_iff.1 (Set.infinite_coe_iff.2 <| infinite_of_charZero R A) #align algebraic.aleph_0_le_cardinal_mk_of_char_zero Algebraic.aleph0_le_cardinal_mk_of_charZero section lift variable (R : Type u) (A : Type v) [CommRing R] [CommRing A] [IsDomain A] [Algebra R A] [NoZeroSMulDivisors R A]
Mathlib/Algebra/AlgebraicCard.lean
45
54
theorem cardinal_mk_lift_le_mul : Cardinal.lift.{u} #{ x : A // IsAlgebraic R x } ≤ Cardinal.lift.{v} #R[X] * ℵ₀ := by
rw [← mk_uLift, ← mk_uLift] choose g hg₁ hg₂ using fun x : { x : A | IsAlgebraic R x } => x.coe_prop refine lift_mk_le_lift_mk_mul_of_lift_mk_preimage_le g fun f => ?_ rw [lift_le_aleph0, le_aleph0_iff_set_countable] suffices MapsTo (↑) (g ⁻¹' {f}) (f.rootSet A) from this.countable_of_injOn Subtype.coe_injective.injOn (f.rootSet_finite A).countable rintro x (rfl : g x = f) exact mem_rootSet.2 ⟨hg₁ x, hg₂ x⟩
/- Copyright (c) 2022 Violeta Hernández. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Violeta Hernández -/ import Mathlib.Data.Finsupp.Basic import Mathlib.Data.List.AList #align_import data.finsupp.alist from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf" /-! # Connections between `Finsupp` and `AList` ## Main definitions * `Finsupp.toAList` * `AList.lookupFinsupp`: converts an association list into a finitely supported function via `AList.lookup`, sending absent keys to zero. -/ namespace Finsupp variable {α M : Type*} [Zero M] /-- Produce an association list for the finsupp over its support using choice. -/ @[simps] noncomputable def toAList (f : α →₀ M) : AList fun _x : α => M := ⟨f.graph.toList.map Prod.toSigma, by rw [List.NodupKeys, List.keys, List.map_map, Prod.fst_comp_toSigma, List.nodup_map_iff_inj_on] · rintro ⟨b, m⟩ hb ⟨c, n⟩ hc (rfl : b = c) rw [Finset.mem_toList, Finsupp.mem_graph_iff] at hb hc dsimp at hb hc rw [← hc.1, hb.1] · apply Finset.nodup_toList⟩ #align finsupp.to_alist Finsupp.toAList @[simp] theorem toAList_keys_toFinset [DecidableEq α] (f : α →₀ M) : f.toAList.keys.toFinset = f.support := by ext simp [toAList, AList.mem_keys, AList.keys, List.keys] #align finsupp.to_alist_keys_to_finset Finsupp.toAList_keys_toFinset @[simp] theorem mem_toAlist {f : α →₀ M} {x : α} : x ∈ f.toAList ↔ f x ≠ 0 := by classical rw [AList.mem_keys, ← List.mem_toFinset, toAList_keys_toFinset, mem_support_iff] #align finsupp.mem_to_alist Finsupp.mem_toAlist end Finsupp namespace AList variable {α M : Type*} [Zero M] open List /-- Converts an association list into a finitely supported function via `AList.lookup`, sending absent keys to zero. -/ noncomputable def lookupFinsupp (l : AList fun _x : α => M) : α →₀ M where support := by haveI := Classical.decEq α; haveI := Classical.decEq M exact (l.1.filter fun x => Sigma.snd x ≠ 0).keys.toFinset toFun a := haveI := Classical.decEq α (l.lookup a).getD 0 mem_support_toFun a := by classical simp_rw [@mem_toFinset _ _, List.mem_keys, List.mem_filter, ← mem_lookup_iff] cases lookup a l <;> simp #align alist.lookup_finsupp AList.lookupFinsupp @[simp] theorem lookupFinsupp_apply [DecidableEq α] (l : AList fun _x : α => M) (a : α) : l.lookupFinsupp a = (l.lookup a).getD 0 := by convert rfl; congr #align alist.lookup_finsupp_apply AList.lookupFinsupp_apply @[simp] theorem lookupFinsupp_support [DecidableEq α] [DecidableEq M] (l : AList fun _x : α => M) : l.lookupFinsupp.support = (l.1.filter fun x => Sigma.snd x ≠ 0).keys.toFinset := by convert rfl; congr · apply Subsingleton.elim · funext; congr #align alist.lookup_finsupp_support AList.lookupFinsupp_support theorem lookupFinsupp_eq_iff_of_ne_zero [DecidableEq α] {l : AList fun _x : α => M} {a : α} {x : M} (hx : x ≠ 0) : l.lookupFinsupp a = x ↔ x ∈ l.lookup a := by rw [lookupFinsupp_apply] cases' lookup a l with m <;> simp [hx.symm] #align alist.lookup_finsupp_eq_iff_of_ne_zero AList.lookupFinsupp_eq_iff_of_ne_zero theorem lookupFinsupp_eq_zero_iff [DecidableEq α] {l : AList fun _x : α => M} {a : α} : l.lookupFinsupp a = 0 ↔ a ∉ l ∨ (0 : M) ∈ l.lookup a := by rw [lookupFinsupp_apply, ← lookup_eq_none] cases' lookup a l with m <;> simp #align alist.lookup_finsupp_eq_zero_iff AList.lookupFinsupp_eq_zero_iff @[simp] theorem empty_lookupFinsupp : lookupFinsupp (∅ : AList fun _x : α => M) = 0 := by classical ext simp #align alist.empty_lookup_finsupp AList.empty_lookupFinsupp @[simp] theorem insert_lookupFinsupp [DecidableEq α] (l : AList fun _x : α => M) (a : α) (m : M) : (l.insert a m).lookupFinsupp = l.lookupFinsupp.update a m := by ext b by_cases h : b = a <;> simp [h] #align alist.insert_lookup_finsupp AList.insert_lookupFinsupp @[simp] theorem singleton_lookupFinsupp (a : α) (m : M) : (singleton a m).lookupFinsupp = Finsupp.single a m := by classical -- porting note (#10745): was `simp [← AList.insert_empty]` but timeout issues simp only [← AList.insert_empty, insert_lookupFinsupp, empty_lookupFinsupp, Finsupp.zero_update] #align alist.singleton_lookup_finsupp AList.singleton_lookupFinsupp @[simp]
Mathlib/Data/Finsupp/AList.lean
124
132
theorem _root_.Finsupp.toAList_lookupFinsupp (f : α →₀ M) : f.toAList.lookupFinsupp = f := by
ext a classical by_cases h : f a = 0 · suffices f.toAList.lookup a = none by simp [h, this] simp [lookup_eq_none, h] · suffices f.toAList.lookup a = some (f a) by simp [h, this] apply mem_lookup_iff.2 simpa using h
/- Copyright (c) 2022 Antoine Labelle, Rémi Bottinelli. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Antoine Labelle, Rémi Bottinelli -/ import Mathlib.Combinatorics.Quiver.Basic import Mathlib.Combinatorics.Quiver.Path #align_import combinatorics.quiver.cast from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" /-! # Rewriting arrows and paths along vertex equalities This files defines `Hom.cast` and `Path.cast` (and associated lemmas) in order to allow rewriting arrows and paths along equalities of their endpoints. -/ universe v v₁ v₂ u u₁ u₂ variable {U : Type*} [Quiver.{u + 1} U] namespace Quiver /-! ### Rewriting arrows along equalities of vertices -/ /-- Change the endpoints of an arrow using equalities. -/ def Hom.cast {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) : u' ⟶ v' := Eq.ndrec (motive := (· ⟶ v')) (Eq.ndrec e hv) hu #align quiver.hom.cast Quiver.Hom.cast theorem Hom.cast_eq_cast {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) : e.cast hu hv = _root_.cast (by {rw [hu, hv]}) e := by subst_vars rfl #align quiver.hom.cast_eq_cast Quiver.Hom.cast_eq_cast @[simp] theorem Hom.cast_rfl_rfl {u v : U} (e : u ⟶ v) : e.cast rfl rfl = e := rfl #align quiver.hom.cast_rfl_rfl Quiver.Hom.cast_rfl_rfl @[simp] theorem Hom.cast_cast {u v u' v' u'' v'' : U} (e : u ⟶ v) (hu : u = u') (hv : v = v') (hu' : u' = u'') (hv' : v' = v'') : (e.cast hu hv).cast hu' hv' = e.cast (hu.trans hu') (hv.trans hv') := by subst_vars rfl #align quiver.hom.cast_cast Quiver.Hom.cast_cast theorem Hom.cast_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) : HEq (e.cast hu hv) e := by subst_vars rfl #align quiver.hom.cast_heq Quiver.Hom.cast_heq
Mathlib/Combinatorics/Quiver/Cast.lean
63
66
theorem Hom.cast_eq_iff_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) (e' : u' ⟶ v') : e.cast hu hv = e' ↔ HEq e e' := by
rw [Hom.cast_eq_cast] exact _root_.cast_eq_iff_heq
/- Copyright (c) 2019 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo, Yury Kudryashov, Frédéric Dupuis, Heather Macbeth -/ import Mathlib.Topology.Algebra.Ring.Basic import Mathlib.Topology.Algebra.MulAction import Mathlib.Topology.Algebra.UniformGroup import Mathlib.Topology.ContinuousFunction.Basic import Mathlib.Topology.UniformSpace.UniformEmbedding import Mathlib.Algebra.Algebra.Defs import Mathlib.LinearAlgebra.Projection import Mathlib.LinearAlgebra.Pi import Mathlib.LinearAlgebra.Finsupp #align_import topology.algebra.module.basic from "leanprover-community/mathlib"@"6285167a053ad0990fc88e56c48ccd9fae6550eb" /-! # Theory of topological modules and continuous linear maps. We use the class `ContinuousSMul` for topological (semi) modules and topological vector spaces. In this file we define continuous (semi-)linear maps, as semilinear maps between topological modules which are continuous. The set of continuous semilinear maps between the topological `R₁`-module `M` and `R₂`-module `M₂` with respect to the `RingHom` `σ` is denoted by `M →SL[σ] M₂`. Plain linear maps are denoted by `M →L[R] M₂` and star-linear maps by `M →L⋆[R] M₂`. The corresponding notation for equivalences is `M ≃SL[σ] M₂`, `M ≃L[R] M₂` and `M ≃L⋆[R] M₂`. -/ open LinearMap (ker range) open Topology Filter Pointwise universe u v w u' section variable {R : Type*} {M : Type*} [Ring R] [TopologicalSpace R] [TopologicalSpace M] [AddCommGroup M] [Module R M] theorem ContinuousSMul.of_nhds_zero [TopologicalRing R] [TopologicalAddGroup M] (hmul : Tendsto (fun p : R × M => p.1 • p.2) (𝓝 0 ×ˢ 𝓝 0) (𝓝 0)) (hmulleft : ∀ m : M, Tendsto (fun a : R => a • m) (𝓝 0) (𝓝 0)) (hmulright : ∀ a : R, Tendsto (fun m : M => a • m) (𝓝 0) (𝓝 0)) : ContinuousSMul R M where continuous_smul := by refine continuous_of_continuousAt_zero₂ (AddMonoidHom.smul : R →+ M →+ M) ?_ ?_ ?_ <;> simpa [ContinuousAt, nhds_prod_eq] #align has_continuous_smul.of_nhds_zero ContinuousSMul.of_nhds_zero end section variable {R : Type*} {M : Type*} [Ring R] [TopologicalSpace R] [TopologicalSpace M] [AddCommGroup M] [ContinuousAdd M] [Module R M] [ContinuousSMul R M] /-- If `M` is a topological module over `R` and `0` is a limit of invertible elements of `R`, then `⊤` is the only submodule of `M` with a nonempty interior. This is the case, e.g., if `R` is a nontrivially normed field. -/
Mathlib/Topology/Algebra/Module/Basic.lean
61
72
theorem Submodule.eq_top_of_nonempty_interior' [NeBot (𝓝[{ x : R | IsUnit x }] 0)] (s : Submodule R M) (hs : (interior (s : Set M)).Nonempty) : s = ⊤ := by
rcases hs with ⟨y, hy⟩ refine Submodule.eq_top_iff'.2 fun x => ?_ rw [mem_interior_iff_mem_nhds] at hy have : Tendsto (fun c : R => y + c • x) (𝓝[{ x : R | IsUnit x }] 0) (𝓝 (y + (0 : R) • x)) := tendsto_const_nhds.add ((tendsto_nhdsWithin_of_tendsto_nhds tendsto_id).smul tendsto_const_nhds) rw [zero_smul, add_zero] at this obtain ⟨_, hu : y + _ • _ ∈ s, u, rfl⟩ := nonempty_of_mem (inter_mem (Filter.mem_map.1 (this hy)) self_mem_nhdsWithin) have hy' : y ∈ ↑s := mem_of_mem_nhds hy rwa [s.add_mem_iff_right hy', ← Units.smul_def, s.smul_mem_iff' u] at hu
/- 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, Kevin Buzzard, Yury Kudryashov, Frédéric Dupuis, Heather Macbeth -/ import Mathlib.Algebra.Module.Submodule.Map #align_import linear_algebra.basic from "leanprover-community/mathlib"@"9d684a893c52e1d6692a504a118bfccbae04feeb" /-! # Kernel of a linear map This file defines the kernel of a linear map. ## Main definitions * `LinearMap.ker`: the kernel of a linear map as a submodule of the domain ## Notations * We continue to use the notations `M →ₛₗ[σ] M₂` and `M →ₗ[R] M₂` for the type of semilinear (resp. linear) maps from `M` to `M₂` over the ring homomorphism `σ` (resp. over the ring `R`). ## Tags linear algebra, vector space, module -/ open Function open Pointwise variable {R : Type*} {R₁ : Type*} {R₂ : Type*} {R₃ : Type*} variable {K : Type*} variable {M : Type*} {M₁ : Type*} {M₂ : Type*} {M₃ : Type*} variable {V : Type*} {V₂ : Type*} /-! ### Properties of linear maps -/ namespace LinearMap section AddCommMonoid variable [Semiring R] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable {σ₁₂ : R →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃} variable [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] variable [Module R M] [Module R₂ M₂] [Module R₃ M₃] open Submodule variable {σ₂₁ : R₂ →+* R} {τ₁₂ : R →+* R₂} {τ₂₃ : R₂ →+* R₃} {τ₁₃ : R →+* R₃} variable [RingHomCompTriple τ₁₂ τ₂₃ τ₁₃] variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F τ₁₂ M M₂] /-- The kernel of a linear map `f : M → M₂` is defined to be `comap f ⊥`. This is equivalent to the set of `x : M` such that `f x = 0`. The kernel is a submodule of `M`. -/ def ker (f : F) : Submodule R M := comap f ⊥ #align linear_map.ker LinearMap.ker @[simp] theorem mem_ker {f : F} {y} : y ∈ ker f ↔ f y = 0 := mem_bot R₂ #align linear_map.mem_ker LinearMap.mem_ker @[simp] theorem ker_id : ker (LinearMap.id : M →ₗ[R] M) = ⊥ := rfl #align linear_map.ker_id LinearMap.ker_id @[simp] theorem map_coe_ker (f : F) (x : ker f) : f x = 0 := mem_ker.1 x.2 #align linear_map.map_coe_ker LinearMap.map_coe_ker theorem ker_toAddSubmonoid (f : M →ₛₗ[τ₁₂] M₂) : f.ker.toAddSubmonoid = (AddMonoidHom.mker f) := rfl #align linear_map.ker_to_add_submonoid LinearMap.ker_toAddSubmonoid theorem comp_ker_subtype (f : M →ₛₗ[τ₁₂] M₂) : f.comp f.ker.subtype = 0 := LinearMap.ext fun x => mem_ker.1 x.2 #align linear_map.comp_ker_subtype LinearMap.comp_ker_subtype theorem ker_comp (f : M →ₛₗ[τ₁₂] M₂) (g : M₂ →ₛₗ[τ₂₃] M₃) : ker (g.comp f : M →ₛₗ[τ₁₃] M₃) = comap f (ker g) := rfl #align linear_map.ker_comp LinearMap.ker_comp theorem ker_le_ker_comp (f : M →ₛₗ[τ₁₂] M₂) (g : M₂ →ₛₗ[τ₂₃] M₃) : ker f ≤ ker (g.comp f : M →ₛₗ[τ₁₃] M₃) := by rw [ker_comp]; exact comap_mono bot_le #align linear_map.ker_le_ker_comp LinearMap.ker_le_ker_comp theorem ker_sup_ker_le_ker_comp_of_commute {f g : M →ₗ[R] M} (h : Commute f g) : ker f ⊔ ker g ≤ ker (f ∘ₗ g) := by refine sup_le_iff.mpr ⟨?_, ker_le_ker_comp g f⟩ rw [← mul_eq_comp, h.eq, mul_eq_comp] exact ker_le_ker_comp f g @[simp] theorem ker_le_comap {p : Submodule R₂ M₂} (f : M →ₛₗ[τ₁₂] M₂) : ker f ≤ p.comap f := fun x hx ↦ by simp [mem_ker.mp hx]
Mathlib/Algebra/Module/Submodule/Ker.lean
107
109
theorem disjoint_ker {f : F} {p : Submodule R M} : Disjoint p (ker f) ↔ ∀ x ∈ p, f x = 0 → x = 0 := by
simp [disjoint_def]
/- Copyright (c) 2020 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel, Joël Riou -/ import Mathlib.Algebra.Homology.ExactSequence import Mathlib.CategoryTheory.Abelian.Refinements #align_import category_theory.abelian.diagram_lemmas.four from "leanprover-community/mathlib"@"d34cbcf6c94953e965448c933cd9cc485115ebbd" /-! # The four and five lemmas Consider the following commutative diagram with exact rows in an abelian category `C`: ``` A ---f--> B ---g--> C ---h--> D ---i--> E | | | | | α β γ δ ε | | | | | v v v v v A' --f'-> B' --g'-> C' --h'-> D' --i'-> E' ``` We show: - the "mono" version of the four lemma: if `α` is an epimorphism and `β` and `δ` are monomorphisms, then `γ` is a monomorphism, - the "epi" version of the four lemma: if `β` and `δ` are epimorphisms and `ε` is a monomorphism, then `γ` is an epimorphism, - the five lemma: if `α`, `β`, `δ` and `ε` are isomorphisms, then `γ` is an isomorphism. ## Implementation details The diagram of the five lemmas is given by a morphism in the category `ComposableArrows C 4` between two objects which satisfy `ComposableArrows.Exact`. Similarly, the two versions of the four lemma are stated in terms of the category `ComposableArrows C 3`. The five lemmas is deduced from the two versions of the four lemma. Both of these versions are proved separately. It would be easy to deduce the epi version from the mono version using duality, but this would require lengthy API developments for `ComposableArrows` (TODO). ## Tags four lemma, five lemma, diagram lemma, diagram chase -/ namespace CategoryTheory open Category Limits Preadditive namespace Abelian variable {C : Type*} [Category C] [Abelian C] open ComposableArrows section Four variable {R₁ R₂ : ComposableArrows C 3} (φ : R₁ ⟶ R₂)
Mathlib/CategoryTheory/Abelian/DiagramLemmas/Four.lean
62
83
theorem mono_of_epi_of_mono_of_mono' (hR₁ : R₁.map' 0 2 = 0) (hR₁' : (mk₂ (R₁.map' 1 2) (R₁.map' 2 3)).Exact) (hR₂ : (mk₂ (R₂.map' 0 1) (R₂.map' 1 2)).Exact) (h₀ : Epi (app' φ 0)) (h₁ : Mono (app' φ 1)) (h₃ : Mono (app' φ 3)) : Mono (app' φ 2) := by
apply mono_of_cancel_zero intro A f₂ h₁ have h₂ : f₂ ≫ R₁.map' 2 3 = 0 := by rw [← cancel_mono (app' φ 3 _), assoc, NatTrans.naturality, reassoc_of% h₁, zero_comp, zero_comp] obtain ⟨A₁, π₁, _, f₁, hf₁⟩ := (hR₁'.exact 0).exact_up_to_refinements f₂ h₂ dsimp at hf₁ have h₃ : (f₁ ≫ app' φ 1) ≫ R₂.map' 1 2 = 0 := by rw [assoc, ← NatTrans.naturality, ← reassoc_of% hf₁, h₁, comp_zero] obtain ⟨A₂, π₂, _, g₀, hg₀⟩ := (hR₂.exact 0).exact_up_to_refinements _ h₃ obtain ⟨A₃, π₃, _, f₀, hf₀⟩ := surjective_up_to_refinements_of_epi (app' φ 0 _) g₀ have h₄ : f₀ ≫ R₁.map' 0 1 = π₃ ≫ π₂ ≫ f₁ := by rw [← cancel_mono (app' φ 1 _), assoc, assoc, assoc, NatTrans.naturality, ← reassoc_of% hf₀, hg₀] rfl rw [← cancel_epi π₁, comp_zero, hf₁, ← cancel_epi π₂, ← cancel_epi π₃, comp_zero, comp_zero, ← reassoc_of% h₄, ← R₁.map'_comp 0 1 2, hR₁, comp_zero]
/- 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.MeasureTheory.Measure.MeasureSpaceDef #align_import measure_theory.measure.ae_disjoint from "leanprover-community/mathlib"@"bc7d81beddb3d6c66f71449c5bc76c38cb77cf9e" /-! # Almost everywhere disjoint sets We say that sets `s` and `t` are `μ`-a.e. disjoint (see `MeasureTheory.AEDisjoint`) if their intersection has measure zero. This assumption can be used instead of `Disjoint` in most theorems in measure theory. -/ open Set Function namespace MeasureTheory variable {ι α : Type*} {m : MeasurableSpace α} (μ : Measure α) /-- Two sets are said to be `μ`-a.e. disjoint if their intersection has measure zero. -/ def AEDisjoint (s t : Set α) := μ (s ∩ t) = 0 #align measure_theory.ae_disjoint MeasureTheory.AEDisjoint variable {μ} {s t u v : Set α} /-- If `s : ι → Set α` is a countable family of pairwise a.e. disjoint sets, then there exists a family of measurable null sets `t i` such that `s i \ t i` are pairwise disjoint. -/ theorem exists_null_pairwise_disjoint_diff [Countable ι] {s : ι → Set α} (hd : Pairwise (AEDisjoint μ on s)) : ∃ t : ι → Set α, (∀ i, MeasurableSet (t i)) ∧ (∀ i, μ (t i) = 0) ∧ Pairwise (Disjoint on fun i => s i \ t i) := by refine ⟨fun i => toMeasurable μ (s i ∩ ⋃ j ∈ ({i}ᶜ : Set ι), s j), fun i => measurableSet_toMeasurable _ _, fun i => ?_, ?_⟩ · simp only [measure_toMeasurable, inter_iUnion] exact (measure_biUnion_null_iff <| to_countable _).2 fun j hj => hd (Ne.symm hj) · simp only [Pairwise, disjoint_left, onFun, mem_diff, not_and, and_imp, Classical.not_not] intro i j hne x hi hU hj replace hU : x ∉ s i ∩ iUnion fun j ↦ iUnion fun _ ↦ s j := fun h ↦ hU (subset_toMeasurable _ _ h) simp only [mem_inter_iff, mem_iUnion, not_and, not_exists] at hU exact (hU hi j hne.symm hj).elim #align measure_theory.exists_null_pairwise_disjoint_diff MeasureTheory.exists_null_pairwise_disjoint_diff namespace AEDisjoint protected theorem eq (h : AEDisjoint μ s t) : μ (s ∩ t) = 0 := h #align measure_theory.ae_disjoint.eq MeasureTheory.AEDisjoint.eq @[symm] protected theorem symm (h : AEDisjoint μ s t) : AEDisjoint μ t s := by rwa [AEDisjoint, inter_comm] #align measure_theory.ae_disjoint.symm MeasureTheory.AEDisjoint.symm protected theorem symmetric : Symmetric (AEDisjoint μ) := fun _ _ => AEDisjoint.symm #align measure_theory.ae_disjoint.symmetric MeasureTheory.AEDisjoint.symmetric protected theorem comm : AEDisjoint μ s t ↔ AEDisjoint μ t s := ⟨AEDisjoint.symm, AEDisjoint.symm⟩ #align measure_theory.ae_disjoint.comm MeasureTheory.AEDisjoint.comm protected theorem _root_.Disjoint.aedisjoint (h : Disjoint s t) : AEDisjoint μ s t := by rw [AEDisjoint, disjoint_iff_inter_eq_empty.1 h, measure_empty] #align disjoint.ae_disjoint Disjoint.aedisjoint protected theorem _root_.Pairwise.aedisjoint {f : ι → Set α} (hf : Pairwise (Disjoint on f)) : Pairwise (AEDisjoint μ on f) := hf.mono fun _i _j h => h.aedisjoint #align pairwise.ae_disjoint Pairwise.aedisjoint protected theorem _root_.Set.PairwiseDisjoint.aedisjoint {f : ι → Set α} {s : Set ι} (hf : s.PairwiseDisjoint f) : s.Pairwise (AEDisjoint μ on f) := hf.mono' fun _i _j h => h.aedisjoint #align set.pairwise_disjoint.ae_disjoint Set.PairwiseDisjoint.aedisjoint theorem mono_ae (h : AEDisjoint μ s t) (hu : u ≤ᵐ[μ] s) (hv : v ≤ᵐ[μ] t) : AEDisjoint μ u v := measure_mono_null_ae (hu.inter hv) h #align measure_theory.ae_disjoint.mono_ae MeasureTheory.AEDisjoint.mono_ae protected theorem mono (h : AEDisjoint μ s t) (hu : u ⊆ s) (hv : v ⊆ t) : AEDisjoint μ u v := mono_ae h (HasSubset.Subset.eventuallyLE hu) (HasSubset.Subset.eventuallyLE hv) #align measure_theory.ae_disjoint.mono MeasureTheory.AEDisjoint.mono protected theorem congr (h : AEDisjoint μ s t) (hu : u =ᵐ[μ] s) (hv : v =ᵐ[μ] t) : AEDisjoint μ u v := mono_ae h (Filter.EventuallyEq.le hu) (Filter.EventuallyEq.le hv) #align measure_theory.ae_disjoint.congr MeasureTheory.AEDisjoint.congr @[simp] theorem iUnion_left_iff [Countable ι] {s : ι → Set α} : AEDisjoint μ (⋃ i, s i) t ↔ ∀ i, AEDisjoint μ (s i) t := by simp only [AEDisjoint, iUnion_inter, measure_iUnion_null_iff] #align measure_theory.ae_disjoint.Union_left_iff MeasureTheory.AEDisjoint.iUnion_left_iff @[simp]
Mathlib/MeasureTheory/Measure/AEDisjoint.lean
100
102
theorem iUnion_right_iff [Countable ι] {t : ι → Set α} : AEDisjoint μ s (⋃ i, t i) ↔ ∀ i, AEDisjoint μ s (t i) := by
simp only [AEDisjoint, inter_iUnion, measure_iUnion_null_iff]
/- Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel -/ import Mathlib.Data.ENNReal.Real import Mathlib.Order.Interval.Finset.Nat import Mathlib.Topology.UniformSpace.Pi import Mathlib.Topology.UniformSpace.UniformConvergence import Mathlib.Topology.UniformSpace.UniformEmbedding #align_import topology.metric_space.emetric_space from "leanprover-community/mathlib"@"c8f305514e0d47dfaa710f5a52f0d21b588e6328" /-! # Extended metric spaces This file is devoted to the definition and study of `EMetricSpace`s, i.e., metric spaces in which the distance is allowed to take the value ∞. This extended distance is called `edist`, and takes values in `ℝ≥0∞`. Many definitions and theorems expected on emetric spaces are already introduced on uniform spaces and topological spaces. For example: open and closed sets, compactness, completeness, continuity and uniform continuity. The class `EMetricSpace` therefore extends `UniformSpace` (and `TopologicalSpace`). Since a lot of elementary properties don't require `eq_of_edist_eq_zero` we start setting up the theory of `PseudoEMetricSpace`, where we don't require `edist x y = 0 → x = y` and we specialize to `EMetricSpace` at the end. -/ open Set Filter Classical open scoped Uniformity Topology Filter NNReal ENNReal Pointwise universe u v w variable {α : Type u} {β : Type v} {X : Type*} /-- Characterizing uniformities associated to a (generalized) distance function `D` in terms of the elements of the uniformity. -/ theorem uniformity_dist_of_mem_uniformity [LinearOrder β] {U : Filter (α × α)} (z : β) (D : α → α → β) (H : ∀ s, s ∈ U ↔ ∃ ε > z, ∀ {a b : α}, D a b < ε → (a, b) ∈ s) : U = ⨅ ε > z, 𝓟 { p : α × α | D p.1 p.2 < ε } := HasBasis.eq_biInf ⟨fun s => by simp only [H, subset_def, Prod.forall, mem_setOf]⟩ #align uniformity_dist_of_mem_uniformity uniformity_dist_of_mem_uniformity /-- `EDist α` means that `α` is equipped with an extended distance. -/ @[ext] class EDist (α : Type*) where edist : α → α → ℝ≥0∞ #align has_edist EDist export EDist (edist) /-- Creating a uniform space from an extended distance. -/ def uniformSpaceOfEDist (edist : α → α → ℝ≥0∞) (edist_self : ∀ x : α, edist x x = 0) (edist_comm : ∀ x y : α, edist x y = edist y x) (edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z) : UniformSpace α := .ofFun edist edist_self edist_comm edist_triangle fun ε ε0 => ⟨ε / 2, ENNReal.half_pos ε0.ne', fun _ h₁ _ h₂ => (ENNReal.add_lt_add h₁ h₂).trans_eq (ENNReal.add_halves _)⟩ #align uniform_space_of_edist uniformSpaceOfEDist -- the uniform structure is embedded in the emetric space structure -- to avoid instance diamond issues. See Note [forgetful inheritance]. /-- Extended (pseudo) metric spaces, with an extended distance `edist` possibly taking the value ∞ Each pseudo_emetric space induces a canonical `UniformSpace` and hence a canonical `TopologicalSpace`. This is enforced in the type class definition, by extending the `UniformSpace` structure. When instantiating a `PseudoEMetricSpace` structure, the uniformity fields are not necessary, they will be filled in by default. There is a default value for the uniformity, that can be substituted in cases of interest, for instance when instantiating a `PseudoEMetricSpace` structure on a product. Continuity of `edist` is proved in `Topology.Instances.ENNReal` -/ class PseudoEMetricSpace (α : Type u) extends EDist α : Type u where edist_self : ∀ x : α, edist x x = 0 edist_comm : ∀ x y : α, edist x y = edist y x edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z toUniformSpace : UniformSpace α := uniformSpaceOfEDist edist edist_self edist_comm edist_triangle uniformity_edist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | edist p.1 p.2 < ε } := by rfl #align pseudo_emetric_space PseudoEMetricSpace attribute [instance] PseudoEMetricSpace.toUniformSpace /- Pseudoemetric spaces are less common than metric spaces. Therefore, we work in a dedicated namespace, while notions associated to metric spaces are mostly in the root namespace. -/ /-- Two pseudo emetric space structures with the same edistance function coincide. -/ @[ext] protected theorem PseudoEMetricSpace.ext {α : Type*} {m m' : PseudoEMetricSpace α} (h : m.toEDist = m'.toEDist) : m = m' := by cases' m with ed _ _ _ U hU cases' m' with ed' _ _ _ U' hU' congr 1 exact UniformSpace.ext (((show ed = ed' from h) ▸ hU).trans hU'.symm) variable [PseudoEMetricSpace α] export PseudoEMetricSpace (edist_self edist_comm edist_triangle) attribute [simp] edist_self /-- Triangle inequality for the extended distance -/ theorem edist_triangle_left (x y z : α) : edist x y ≤ edist z x + edist z y := by rw [edist_comm z]; apply edist_triangle #align edist_triangle_left edist_triangle_left theorem edist_triangle_right (x y z : α) : edist x y ≤ edist x z + edist y z := by rw [edist_comm y]; apply edist_triangle #align edist_triangle_right edist_triangle_right
Mathlib/Topology/EMetricSpace/Basic.lean
118
124
theorem edist_congr_right {x y z : α} (h : edist x y = 0) : edist x z = edist y z := by
apply le_antisymm · rw [← zero_add (edist y z), ← h] apply edist_triangle · rw [edist_comm] at h rw [← zero_add (edist x z), ← h] apply edist_triangle
/- 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.LinearAlgebra.GeneralLinearGroup import Mathlib.LinearAlgebra.Matrix.ToLin import Mathlib.LinearAlgebra.Matrix.NonsingularInverse import Mathlib.Algebra.Star.Unitary #align_import linear_algebra.unitary_group from "leanprover-community/mathlib"@"2705404e701abc6b3127da906f40bae062a169c9" /-! # The Unitary Group This file defines elements of the unitary group `Matrix.unitaryGroup n α`, where `α` is a `StarRing`. This consists of all `n` by `n` matrices with entries in `α` such that the star-transpose is its inverse. In addition, we define the group structure on `Matrix.unitaryGroup n α`, and the embedding into the general linear group `LinearMap.GeneralLinearGroup α (n → α)`. We also define the orthogonal group `Matrix.orthogonalGroup n β`, where `β` is a `CommRing`. ## Main Definitions * `Matrix.unitaryGroup` is the submonoid of matrices where the star-transpose is the inverse; the group structure (under multiplication) is inherited from a more general `unitary` construction. * `Matrix.UnitaryGroup.embeddingGL` is the embedding `Matrix.unitaryGroup n α → GLₙ(α)`, where `GLₙ(α)` is `LinearMap.GeneralLinearGroup α (n → α)`. * `Matrix.orthogonalGroup` is the submonoid of matrices where the transpose is the inverse. ## References * https://en.wikipedia.org/wiki/Unitary_group ## Tags matrix group, group, unitary group, orthogonal group -/ universe u v namespace Matrix open LinearMap Matrix section variable (n : Type u) [DecidableEq n] [Fintype n] variable (α : Type v) [CommRing α] [StarRing α] /-- `Matrix.unitaryGroup n` is the group of `n` by `n` matrices where the star-transpose is the inverse. -/ abbrev unitaryGroup := unitary (Matrix n n α) #align matrix.unitary_group Matrix.unitaryGroup end variable {n : Type u} [DecidableEq n] [Fintype n] variable {α : Type v} [CommRing α] [StarRing α] {A : Matrix n n α}
Mathlib/LinearAlgebra/UnitaryGroup.lean
66
68
theorem mem_unitaryGroup_iff : A ∈ Matrix.unitaryGroup n α ↔ A * star A = 1 := by
refine ⟨And.right, fun hA => ⟨?_, hA⟩⟩ simpa only [mul_eq_one_comm] using hA
/- 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.Analysis.InnerProductSpace.Calculus import Mathlib.Analysis.InnerProductSpace.PiL2 #align_import analysis.inner_product_space.euclidean_dist from "leanprover-community/mathlib"@"9425b6f8220e53b059f5a4904786c3c4b50fc057" /-! # Euclidean distance on a finite dimensional space When we define a smooth bump function on a normed space, it is useful to have a smooth distance on the space. Since the default distance is not guaranteed to be smooth, we define `toEuclidean` to be an equivalence between a finite dimensional topological vector space and the standard Euclidean space of the same dimension. Then we define `Euclidean.dist x y = dist (toEuclidean x) (toEuclidean y)` and provide some definitions (`Euclidean.ball`, `Euclidean.closedBall`) and simple lemmas about this distance. This way we hide the usage of `toEuclidean` behind an API. -/ open scoped Topology open Set variable {E : Type*} [AddCommGroup E] [TopologicalSpace E] [TopologicalAddGroup E] [T2Space E] [Module ℝ E] [ContinuousSMul ℝ E] [FiniteDimensional ℝ E] noncomputable section open FiniteDimensional /-- If `E` is a finite dimensional space over `ℝ`, then `toEuclidean` is a continuous `ℝ`-linear equivalence between `E` and the Euclidean space of the same dimension. -/ def toEuclidean : E ≃L[ℝ] EuclideanSpace ℝ (Fin <| finrank ℝ E) := ContinuousLinearEquiv.ofFinrankEq finrank_euclideanSpace_fin.symm #align to_euclidean toEuclidean namespace Euclidean /-- If `x` and `y` are two points in a finite dimensional space over `ℝ`, then `Euclidean.dist x y` is the distance between these points in the metric defined by some inner product space structure on `E`. -/ nonrec def dist (x y : E) : ℝ := dist (toEuclidean x) (toEuclidean y) #align euclidean.dist Euclidean.dist /-- Closed ball w.r.t. the euclidean distance. -/ def closedBall (x : E) (r : ℝ) : Set E := {y | dist y x ≤ r} #align euclidean.closed_ball Euclidean.closedBall /-- Open ball w.r.t. the euclidean distance. -/ def ball (x : E) (r : ℝ) : Set E := {y | dist y x < r} #align euclidean.ball Euclidean.ball theorem ball_eq_preimage (x : E) (r : ℝ) : ball x r = toEuclidean ⁻¹' Metric.ball (toEuclidean x) r := rfl #align euclidean.ball_eq_preimage Euclidean.ball_eq_preimage theorem closedBall_eq_preimage (x : E) (r : ℝ) : closedBall x r = toEuclidean ⁻¹' Metric.closedBall (toEuclidean x) r := rfl #align euclidean.closed_ball_eq_preimage Euclidean.closedBall_eq_preimage theorem ball_subset_closedBall {x : E} {r : ℝ} : ball x r ⊆ closedBall x r := fun _ (hy : _ < r) => le_of_lt hy #align euclidean.ball_subset_closed_ball Euclidean.ball_subset_closedBall theorem isOpen_ball {x : E} {r : ℝ} : IsOpen (ball x r) := Metric.isOpen_ball.preimage toEuclidean.continuous #align euclidean.is_open_ball Euclidean.isOpen_ball theorem mem_ball_self {x : E} {r : ℝ} (hr : 0 < r) : x ∈ ball x r := Metric.mem_ball_self hr #align euclidean.mem_ball_self Euclidean.mem_ball_self theorem closedBall_eq_image (x : E) (r : ℝ) : closedBall x r = toEuclidean.symm '' Metric.closedBall (toEuclidean x) r := by rw [toEuclidean.image_symm_eq_preimage, closedBall_eq_preimage] #align euclidean.closed_ball_eq_image Euclidean.closedBall_eq_image nonrec theorem isCompact_closedBall {x : E} {r : ℝ} : IsCompact (closedBall x r) := by rw [closedBall_eq_image] exact (isCompact_closedBall _ _).image toEuclidean.symm.continuous #align euclidean.is_compact_closed_ball Euclidean.isCompact_closedBall theorem isClosed_closedBall {x : E} {r : ℝ} : IsClosed (closedBall x r) := isCompact_closedBall.isClosed #align euclidean.is_closed_closed_ball Euclidean.isClosed_closedBall nonrec theorem closure_ball (x : E) {r : ℝ} (h : r ≠ 0) : closure (ball x r) = closedBall x r := by rw [ball_eq_preimage, ← toEuclidean.preimage_closure, closure_ball (toEuclidean x) h, closedBall_eq_preimage] #align euclidean.closure_ball Euclidean.closure_ball nonrec theorem exists_pos_lt_subset_ball {R : ℝ} {s : Set E} {x : E} (hR : 0 < R) (hs : IsClosed s) (h : s ⊆ ball x R) : ∃ r ∈ Ioo 0 R, s ⊆ ball x r := by rw [ball_eq_preimage, ← image_subset_iff] at h rcases exists_pos_lt_subset_ball hR (toEuclidean.isClosed_image.2 hs) h with ⟨r, hr, hsr⟩ exact ⟨r, hr, image_subset_iff.1 hsr⟩ #align euclidean.exists_pos_lt_subset_ball Euclidean.exists_pos_lt_subset_ball theorem nhds_basis_closedBall {x : E} : (𝓝 x).HasBasis (fun r : ℝ => 0 < r) (closedBall x) := by rw [toEuclidean.toHomeomorph.nhds_eq_comap x] exact Metric.nhds_basis_closedBall.comap _ #align euclidean.nhds_basis_closed_ball Euclidean.nhds_basis_closedBall theorem closedBall_mem_nhds {x : E} {r : ℝ} (hr : 0 < r) : closedBall x r ∈ 𝓝 x := nhds_basis_closedBall.mem_of_mem hr #align euclidean.closed_ball_mem_nhds Euclidean.closedBall_mem_nhds
Mathlib/Analysis/InnerProductSpace/EuclideanDist.lean
117
119
theorem nhds_basis_ball {x : E} : (𝓝 x).HasBasis (fun r : ℝ => 0 < r) (ball x) := by
rw [toEuclidean.toHomeomorph.nhds_eq_comap x] exact Metric.nhds_basis_ball.comap _
/- Copyright (c) 2022 Rishikesh Vaishnav. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rishikesh Vaishnav -/ import Mathlib.MeasureTheory.Measure.Typeclasses #align_import probability.conditional_probability from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # Conditional Probability This file defines conditional probability and includes basic results relating to it. Given some measure `μ` defined on a measure space on some type `Ω` and some `s : Set Ω`, we define the measure of `μ` conditioned on `s` as the restricted measure scaled by the inverse of the measure of `s`: `cond μ s = (μ s)⁻¹ • μ.restrict s`. The scaling ensures that this is a probability measure (when `μ` is a finite measure). From this definition, we derive the "axiomatic" definition of conditional probability based on application: for any `s t : Set Ω`, we have `μ[t|s] = (μ s)⁻¹ * μ (s ∩ t)`. ## Main Statements * `cond_cond_eq_cond_inter`: conditioning on one set and then another is equivalent to conditioning on their intersection. * `cond_eq_inv_mul_cond_mul`: Bayes' Theorem, `μ[t|s] = (μ s)⁻¹ * μ[s|t] * (μ t)`. ## Notations This file uses the notation `μ[|s]` the measure of `μ` conditioned on `s`, and `μ[t|s]` for the probability of `t` given `s` under `μ` (equivalent to the application `μ[|s] t`). These notations are contained in the locale `ProbabilityTheory`. ## Implementation notes Because we have the alternative measure restriction application principles `Measure.restrict_apply` and `Measure.restrict_apply'`, which require measurability of the restricted and restricting sets, respectively, many of the theorems here will have corresponding alternatives as well. For the sake of brevity, we've chosen to only go with `Measure.restrict_apply'` for now, but the alternative theorems can be added if needed. Use of `@[simp]` generally follows the rule of removing conditions on a measure when possible. Hypotheses that are used to "define" a conditional distribution by requiring that the conditioning set has non-zero measure should be named using the abbreviation "c" (which stands for "conditionable") rather than "nz". For example `(hci : μ (s ∩ t) ≠ 0)` (rather than `hnzi`) should be used for a hypothesis ensuring that `μ[|s ∩ t]` is defined. ## Tags conditional, conditioned, bayes -/ noncomputable section open ENNReal MeasureTheory MeasureTheory.Measure MeasurableSpace Set variable {Ω Ω' α : Type*} {m : MeasurableSpace Ω} {m' : MeasurableSpace Ω'} (μ : Measure Ω) {s t : Set Ω} namespace ProbabilityTheory section Definitions /-- The conditional probability measure of measure `μ` on set `s` is `μ` restricted to `s` and scaled by the inverse of `μ s` (to make it a probability measure): `(μ s)⁻¹ • μ.restrict s`. -/ def cond (s : Set Ω) : Measure Ω := (μ s)⁻¹ • μ.restrict s #align probability_theory.cond ProbabilityTheory.cond end Definitions @[inherit_doc] scoped notation μ "[" s "|" t "]" => ProbabilityTheory.cond μ t s @[inherit_doc] scoped notation:max μ "[|" t "]" => ProbabilityTheory.cond μ t /-- The conditional probability measure of measure `μ` on `{ω | X ω = x}`. It is `μ` restricted to `{ω | X ω = x}` and scaled by the inverse of `μ {ω | X ω = x}` (to make it a probability measure): `(μ {ω | X ω = x})⁻¹ • μ.restrict {ω | X ω = x}`. -/ scoped notation:max μ "[|" X " ← " x "]" => μ[|X ⁻¹' {x}] /-- The conditional probability measure of any measure on any set of finite positive measure is a probability measure. -/ theorem cond_isProbabilityMeasure_of_finite (hcs : μ s ≠ 0) (hs : μ s ≠ ∞) : IsProbabilityMeasure μ[|s] := ⟨by unfold ProbabilityTheory.cond simp only [Measure.coe_smul, Pi.smul_apply, MeasurableSet.univ, Measure.restrict_apply, Set.univ_inter, smul_eq_mul] exact ENNReal.inv_mul_cancel hcs hs⟩ /-- The conditional probability measure of any finite measure on any set of positive measure is a probability measure. -/ theorem cond_isProbabilityMeasure [IsFiniteMeasure μ] (hcs : μ s ≠ 0) : IsProbabilityMeasure μ[|s] := cond_isProbabilityMeasure_of_finite μ hcs (measure_ne_top μ s) #align probability_theory.cond_is_probability_measure ProbabilityTheory.cond_isProbabilityMeasure instance cond_isFiniteMeasure : IsFiniteMeasure μ[|s] := by constructor simp only [Measure.coe_smul, Pi.smul_apply, MeasurableSet.univ, Measure.restrict_apply, Set.univ_inter, smul_eq_mul, ProbabilityTheory.cond, ← ENNReal.div_eq_inv_mul] exact ENNReal.div_self_le_one.trans_lt ENNReal.one_lt_top theorem cond_toMeasurable_eq : μ[|(toMeasurable μ s)] = μ[|s] := by unfold cond by_cases hnt : μ s = ∞ · simp [hnt] · simp [Measure.restrict_toMeasurable hnt] variable {μ} in lemma cond_absolutelyContinuous : μ[|s] ≪ μ := smul_absolutelyContinuous.trans restrict_le_self.absolutelyContinuous variable {μ} in lemma absolutelyContinuous_cond_univ [IsFiniteMeasure μ] : μ ≪ μ[|univ] := by rw [cond, restrict_univ] refine absolutelyContinuous_smul ?_ simp [measure_ne_top] section Bayes @[simp] theorem cond_empty : μ[|∅] = 0 := by simp [cond] #align probability_theory.cond_empty ProbabilityTheory.cond_empty @[simp]
Mathlib/Probability/ConditionalProbability.lean
134
135
theorem cond_univ [IsProbabilityMeasure μ] : μ[|Set.univ] = μ := by
simp [cond, measure_univ, Measure.restrict_univ]
/- Copyright (c) 2021 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.Data.Set.Lattice import Mathlib.Order.Directed #align_import data.set.Union_lift from "leanprover-community/mathlib"@"5a4ea8453f128345f73cc656e80a49de2a54f481" /-! # Union lift This file defines `Set.iUnionLift` to glue together functions defined on each of a collection of sets to make a function on the Union of those sets. ## Main definitions * `Set.iUnionLift` - Given a Union of sets `iUnion S`, define a function on any subset of the Union by defining it on each component, and proving that it agrees on the intersections. * `Set.liftCover` - Version of `Set.iUnionLift` for the special case that the sets cover the entire type. ## Main statements There are proofs of the obvious properties of `iUnionLift`, i.e. what it does to elements of each of the sets in the `iUnion`, stated in different ways. There are also three lemmas about `iUnionLift` intended to aid with proving that `iUnionLift` is a homomorphism when defined on a Union of substructures. There is one lemma each to show that constants, unary functions, or binary functions are preserved. These lemmas are: *`Set.iUnionLift_const` *`Set.iUnionLift_unary` *`Set.iUnionLift_binary` ## Tags directed union, directed supremum, glue, gluing -/ variable {α : Type*} {ι β : Sort _} namespace Set section UnionLift /- The unused argument is left in the definition so that the `simp` lemmas `iUnionLift_inclusion` will work without the user having to provide it explicitly to simplify terms involving `iUnionLift`. -/ /-- Given a union of sets `iUnion S`, define a function on the Union by defining it on each component, and proving that it agrees on the intersections. -/ @[nolint unusedArguments] noncomputable def iUnionLift (S : ι → Set α) (f : ∀ i, S i → β) (_ : ∀ (i j) (x : α) (hxi : x ∈ S i) (hxj : x ∈ S j), f i ⟨x, hxi⟩ = f j ⟨x, hxj⟩) (T : Set α) (hT : T ⊆ iUnion S) (x : T) : β := let i := Classical.indefiniteDescription _ (mem_iUnion.1 (hT x.prop)) f i ⟨x, i.prop⟩ #align set.Union_lift Set.iUnionLift variable {S : ι → Set α} {f : ∀ i, S i → β} {hf : ∀ (i j) (x : α) (hxi : x ∈ S i) (hxj : x ∈ S j), f i ⟨x, hxi⟩ = f j ⟨x, hxj⟩} {T : Set α} {hT : T ⊆ iUnion S} (hT' : T = iUnion S) @[simp] theorem iUnionLift_mk {i : ι} (x : S i) (hx : (x : α) ∈ T) : iUnionLift S f hf T hT ⟨x, hx⟩ = f i x := hf _ i x _ _ #align set.Union_lift_mk Set.iUnionLift_mk @[simp] theorem iUnionLift_inclusion {i : ι} (x : S i) (h : S i ⊆ T) : iUnionLift S f hf T hT (Set.inclusion h x) = f i x := iUnionLift_mk x _ #align set.Union_lift_inclusion Set.iUnionLift_inclusion theorem iUnionLift_of_mem (x : T) {i : ι} (hx : (x : α) ∈ S i) : iUnionLift S f hf T hT x = f i ⟨x, hx⟩ := by cases' x with x hx; exact hf _ _ _ _ _ #align set.Union_lift_of_mem Set.iUnionLift_of_mem
Mathlib/Data/Set/UnionLift.lean
79
90
theorem preimage_iUnionLift (t : Set β) : iUnionLift S f hf T hT ⁻¹' t = inclusion hT ⁻¹' (⋃ i, inclusion (subset_iUnion S i) '' (f i ⁻¹' t)) := by
ext x simp only [mem_preimage, mem_iUnion, mem_image] constructor · rcases mem_iUnion.1 (hT x.prop) with ⟨i, hi⟩ refine fun h => ⟨i, ⟨x, hi⟩, ?_, rfl⟩ rwa [iUnionLift_of_mem x hi] at h · rintro ⟨i, ⟨y, hi⟩, h, hxy⟩ obtain rfl : y = x := congr_arg Subtype.val hxy rwa [iUnionLift_of_mem x hi]
/- Copyright (c) 2021 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.MeasureTheory.Function.ConditionalExpectation.CondexpL2 #align_import measure_theory.function.conditional_expectation.condexp_L1 from "leanprover-community/mathlib"@"d8bbb04e2d2a44596798a9207ceefc0fb236e41e" /-! # Conditional expectation in L1 This file contains two more steps of the construction of the conditional expectation, which is completed in `MeasureTheory.Function.ConditionalExpectation.Basic`. See that file for a description of the full process. The contitional expectation of an `L²` function is defined in `MeasureTheory.Function.ConditionalExpectation.CondexpL2`. In this file, we perform two steps. * Show that the conditional expectation of the indicator of a measurable set with finite measure is integrable and define a map `Set α → (E →L[ℝ] (α →₁[μ] E))` which to a set associates a linear map. That linear map sends `x ∈ E` to the conditional expectation of the indicator of the set with value `x`. * Extend that map to `condexpL1CLM : (α →₁[μ] E) →L[ℝ] (α →₁[μ] E)`. This is done using the same construction as the Bochner integral (see the file `MeasureTheory/Integral/SetToL1`). ## Main definitions * `condexpL1`: Conditional expectation of a function as a linear map from `L1` to itself. -/ noncomputable section open TopologicalSpace MeasureTheory.Lp Filter ContinuousLinearMap open scoped NNReal ENNReal Topology MeasureTheory namespace MeasureTheory variable {α β F F' G G' 𝕜 : Type*} {p : ℝ≥0∞} [RCLike 𝕜] -- 𝕜 for ℝ or ℂ -- F for a Lp submodule [NormedAddCommGroup F] [NormedSpace 𝕜 F] -- F' for integrals on a Lp submodule [NormedAddCommGroup F'] [NormedSpace 𝕜 F'] [NormedSpace ℝ F'] [CompleteSpace F'] -- G for a Lp add_subgroup [NormedAddCommGroup G] -- G' for integrals on a Lp add_subgroup [NormedAddCommGroup G'] [NormedSpace ℝ G'] [CompleteSpace G'] section CondexpInd /-! ## Conditional expectation of an indicator as a continuous linear map. The goal of this section is to build `condexpInd (hm : m ≤ m0) (μ : Measure α) (s : Set s) : G →L[ℝ] α →₁[μ] G`, which takes `x : G` to the conditional expectation of the indicator of the set `s` with value `x`, seen as an element of `α →₁[μ] G`. -/ variable {m m0 : MeasurableSpace α} {μ : Measure α} {s t : Set α} [NormedSpace ℝ G] section CondexpIndL1Fin set_option linter.uppercaseLean3 false /-- Conditional expectation of the indicator of a measurable set with finite measure, as a function in L1. -/ def condexpIndL1Fin (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) : α →₁[μ] G := (integrable_condexpIndSMul hm hs hμs x).toL1 _ #align measure_theory.condexp_ind_L1_fin MeasureTheory.condexpIndL1Fin theorem condexpIndL1Fin_ae_eq_condexpIndSMul (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) : condexpIndL1Fin hm hs hμs x =ᵐ[μ] condexpIndSMul hm hs hμs x := (integrable_condexpIndSMul hm hs hμs x).coeFn_toL1 #align measure_theory.condexp_ind_L1_fin_ae_eq_condexp_ind_smul MeasureTheory.condexpIndL1Fin_ae_eq_condexpIndSMul variable {hm : m ≤ m0} [SigmaFinite (μ.trim hm)] -- Porting note: this lemma fills the hole in `refine' (Memℒp.coeFn_toLp _) ...` -- which is not automatically filled in Lean 4 private theorem q {hs : MeasurableSet s} {hμs : μ s ≠ ∞} {x : G} : Memℒp (condexpIndSMul hm hs hμs x) 1 μ := by rw [memℒp_one_iff_integrable]; apply integrable_condexpIndSMul
Mathlib/MeasureTheory/Function/ConditionalExpectation/CondexpL1.lean
92
102
theorem condexpIndL1Fin_add (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x y : G) : condexpIndL1Fin hm hs hμs (x + y) = condexpIndL1Fin hm hs hμs x + condexpIndL1Fin hm hs hμs y := by
ext1 refine (Memℒp.coeFn_toLp q).trans ?_ refine EventuallyEq.trans ?_ (Lp.coeFn_add _ _).symm refine EventuallyEq.trans ?_ (EventuallyEq.add (Memℒp.coeFn_toLp q).symm (Memℒp.coeFn_toLp q).symm) rw [condexpIndSMul_add] refine (Lp.coeFn_add _ _).trans (eventually_of_forall fun a => ?_) rfl
/- Copyright (c) 2019 Michael Howes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Howes, Newell Jensen -/ import Mathlib.GroupTheory.FreeGroup.Basic import Mathlib.GroupTheory.QuotientGroup #align_import group_theory.presented_group from "leanprover-community/mathlib"@"d90e4e186f1d18e375dcd4e5b5f6364b01cb3e46" /-! # Defining a group given by generators and relations Given a subset `rels` of relations of the free group on a type `α`, this file constructs the group given by generators `x : α` and relations `r ∈ rels`. ## Main definitions * `PresentedGroup rels`: the quotient group of the free group on a type `α` by a subset `rels` of relations of the free group on `α`. * `of`: The canonical map from `α` to a presented group with generators `α`. * `toGroup f`: the canonical group homomorphism `PresentedGroup rels → G`, given a function `f : α → G` from a type `α` to a group `G` which satisfies the relations `rels`. ## Tags generators, relations, group presentations -/ variable {α : Type*} /-- Given a set of relations, `rels`, over a type `α`, `PresentedGroup` constructs the group with generators `x : α` and relations `rels` as a quotient of `FreeGroup α`. -/ def PresentedGroup (rels : Set (FreeGroup α)) := FreeGroup α ⧸ Subgroup.normalClosure rels #align presented_group PresentedGroup namespace PresentedGroup instance (rels : Set (FreeGroup α)) : Group (PresentedGroup rels) := QuotientGroup.Quotient.group _ /-- `of` is the canonical map from `α` to a presented group with generators `x : α`. The term `x` is mapped to the equivalence class of the image of `x` in `FreeGroup α`. -/ def of {rels : Set (FreeGroup α)} (x : α) : PresentedGroup rels := QuotientGroup.mk (FreeGroup.of x) #align presented_group.of PresentedGroup.of /-- The generators of a presented group generate the presented group. That is, the subgroup closure of the set of generators equals `⊤`. -/ @[simp] theorem closure_range_of (rels : Set (FreeGroup α)) : Subgroup.closure (Set.range (PresentedGroup.of : α → PresentedGroup rels)) = ⊤ := by have : (PresentedGroup.of : α → PresentedGroup rels) = QuotientGroup.mk' _ ∘ FreeGroup.of := rfl rw [this, Set.range_comp, ← MonoidHom.map_closure (QuotientGroup.mk' _), FreeGroup.closure_range_of, ← MonoidHom.range_eq_map] exact MonoidHom.range_top_of_surjective _ (QuotientGroup.mk'_surjective _) section ToGroup /- Presented groups satisfy a universal property. If `G` is a group and `f : α → G` is a map such that the images of `f` satisfy all the given relations, then `f` extends uniquely to a group homomorphism from `PresentedGroup rels` to `G`. -/ variable {G : Type*} [Group G] {f : α → G} {rels : Set (FreeGroup α)} local notation "F" => FreeGroup.lift f -- Porting note: `F` has been expanded, because `F r = 1` produces a sorry. variable (h : ∀ r ∈ rels, FreeGroup.lift f r = 1) theorem closure_rels_subset_ker : Subgroup.normalClosure rels ≤ MonoidHom.ker F := Subgroup.normalClosure_le_normal fun x w ↦ (MonoidHom.mem_ker _).2 (h x w) #align presented_group.closure_rels_subset_ker PresentedGroup.closure_rels_subset_ker theorem to_group_eq_one_of_mem_closure : ∀ x ∈ Subgroup.normalClosure rels, F x = 1 := fun _ w ↦ (MonoidHom.mem_ker _).1 <| closure_rels_subset_ker h w #align presented_group.to_group_eq_one_of_mem_closure PresentedGroup.to_group_eq_one_of_mem_closure /-- The extension of a map `f : α → G` that satisfies the given relations to a group homomorphism from `PresentedGroup rels → G`. -/ def toGroup : PresentedGroup rels →* G := QuotientGroup.lift (Subgroup.normalClosure rels) F (to_group_eq_one_of_mem_closure h) #align presented_group.to_group PresentedGroup.toGroup @[simp] theorem toGroup.of {x : α} : toGroup h (of x) = f x := FreeGroup.lift.of #align presented_group.to_group.of PresentedGroup.toGroup.of theorem toGroup.unique (g : PresentedGroup rels →* G) (hg : ∀ x : α, g (PresentedGroup.of x) = f x) : ∀ {x}, g x = toGroup h x := by intro x refine QuotientGroup.induction_on x ?_ exact fun _ ↦ FreeGroup.lift.unique (g.comp (QuotientGroup.mk' _)) hg #align presented_group.to_group.unique PresentedGroup.toGroup.unique @[ext]
Mathlib/GroupTheory/PresentedGroup.lean
101
104
theorem ext {φ ψ : PresentedGroup rels →* G} (hx : ∀ (x : α), φ (.of x) = ψ (.of x)) : φ = ψ := by
unfold PresentedGroup ext apply hx
/- Copyright (c) 2021 Chris Hughes, Junyan Xu. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Junyan Xu -/ import Mathlib.Algebra.Polynomial.Basic import Mathlib.SetTheory.Cardinal.Ordinal #align_import data.polynomial.cardinal from "leanprover-community/mathlib"@"62c0a4ef1441edb463095ea02a06e87f3dfe135c" /-! # Cardinality of Polynomial Ring The result in this file is that the cardinality of `R[X]` is at most the maximum of `#R` and `ℵ₀`. -/ universe u open Cardinal Polynomial open Cardinal namespace Polynomial @[simp] theorem cardinal_mk_eq_max {R : Type u} [Semiring R] [Nontrivial R] : #(R[X]) = max #R ℵ₀ := (toFinsuppIso R).toEquiv.cardinal_eq.trans <| by rw [AddMonoidAlgebra, mk_finsupp_lift_of_infinite, lift_uzero, max_comm] rfl #align polynomial.cardinal_mk_eq_max Polynomial.cardinal_mk_eq_max
Mathlib/Algebra/Polynomial/Cardinal.lean
34
37
theorem cardinal_mk_le_max {R : Type u} [Semiring R] : #(R[X]) ≤ max #R ℵ₀ := by
cases subsingleton_or_nontrivial R · exact (mk_eq_one _).trans_le (le_max_of_le_right one_le_aleph0) · exact cardinal_mk_eq_max.le
/- 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 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 #align finset.lcm_congr Finset.lcm_congr theorem lcm_mono_fun {g : β → α} (h : ∀ b ∈ s, f b ∣ g b) : s.lcm f ∣ s.lcm g := lcm_dvd fun b hb ↦ (h b hb).trans (dvd_lcm hb) #align finset.lcm_mono_fun Finset.lcm_mono_fun theorem lcm_mono (h : s₁ ⊆ s₂) : s₁.lcm f ∣ s₂.lcm f := lcm_dvd fun _ hb ↦ dvd_lcm (h hb) #align finset.lcm_mono Finset.lcm_mono theorem lcm_image [DecidableEq β] {g : γ → β} (s : Finset γ) : (s.image g).lcm f = s.lcm (f ∘ g) := by classical induction' s using Finset.induction with c s _ ih <;> simp [*] #align finset.lcm_image Finset.lcm_image theorem lcm_eq_lcm_image [DecidableEq α] : s.lcm f = (s.image f).lcm id := Eq.symm <| lcm_image _ #align finset.lcm_eq_lcm_image Finset.lcm_eq_lcm_image
Mathlib/Algebra/GCDMonoid/Finset.lean
123
125
theorem lcm_eq_zero_iff [Nontrivial α] : s.lcm f = 0 ↔ 0 ∈ f '' s := by
simp only [Multiset.mem_map, lcm_def, Multiset.lcm_eq_zero_iff, Set.mem_image, mem_coe, ← Finset.mem_def]
/- Copyright (c) 2020 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Algebra.BigOperators.NatAntidiagonal import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Data.Nat.Choose.Sum import Mathlib.RingTheory.PowerSeries.Basic #align_import ring_theory.power_series.well_known from "leanprover-community/mathlib"@"8199f6717c150a7fe91c4534175f4cf99725978f" /-! # Definition of well-known power series In this file we define the following power series: * `PowerSeries.invUnitsSub`: given `u : Rˣ`, this is the series for `1 / (u - x)`. It is given by `∑ n, x ^ n /ₚ u ^ (n + 1)`. * `PowerSeries.invOneSubPow`: given a commutative ring `S` and a number `d : ℕ`, `PowerSeries.invOneSubPow d : S⟦X⟧ˣ` is the power series `∑ n, Nat.choose (d + n) d` whose multiplicative inverse is `(1 - X) ^ (d + 1)`. * `PowerSeries.sin`, `PowerSeries.cos`, `PowerSeries.exp` : power series for sin, cosine, and exponential functions. -/ namespace PowerSeries section Ring variable {R S : Type*} [Ring R] [Ring S] /-- The power series for `1 / (u - x)`. -/ def invUnitsSub (u : Rˣ) : PowerSeries R := mk fun n => 1 /ₚ u ^ (n + 1) #align power_series.inv_units_sub PowerSeries.invUnitsSub @[simp] theorem coeff_invUnitsSub (u : Rˣ) (n : ℕ) : coeff R n (invUnitsSub u) = 1 /ₚ u ^ (n + 1) := coeff_mk _ _ #align power_series.coeff_inv_units_sub PowerSeries.coeff_invUnitsSub @[simp] theorem constantCoeff_invUnitsSub (u : Rˣ) : constantCoeff R (invUnitsSub u) = 1 /ₚ u := by rw [← coeff_zero_eq_constantCoeff_apply, coeff_invUnitsSub, zero_add, pow_one] #align power_series.constant_coeff_inv_units_sub PowerSeries.constantCoeff_invUnitsSub @[simp]
Mathlib/RingTheory/PowerSeries/WellKnown.lean
52
55
theorem invUnitsSub_mul_X (u : Rˣ) : invUnitsSub u * X = invUnitsSub u * C R u - 1 := by
ext (_ | n) · simp · simp [n.succ_ne_zero, pow_succ']
/- Copyright (c) 2020 Alena Gusakov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alena Gusakov, Arthur Paulino, Kyle Miller -/ import Mathlib.Combinatorics.SimpleGraph.DegreeSum import Mathlib.Combinatorics.SimpleGraph.Subgraph #align_import combinatorics.simple_graph.matching from "leanprover-community/mathlib"@"138448ae98f529ef34eeb61114191975ee2ca508" /-! # Matchings A *matching* for a simple graph is a set of disjoint pairs of adjacent vertices, and the set of all the vertices in a matching is called its *support* (and sometimes the vertices in the support are said to be *saturated* by the matching). A *perfect matching* is a matching whose support contains every vertex of the graph. In this module, we represent a matching as a subgraph whose vertices are each incident to at most one edge, and the edges of the subgraph represent the paired vertices. ## Main definitions * `SimpleGraph.Subgraph.IsMatching`: `M.IsMatching` means that `M` is a matching of its underlying graph. denoted `M.is_matching`. * `SimpleGraph.Subgraph.IsPerfectMatching` defines when a subgraph `M` of a simple graph is a perfect matching, denoted `M.IsPerfectMatching`. ## TODO * Define an `other` function and prove useful results about it (https://leanprover.zulipchat.com/#narrow/stream/252551-graph-theory/topic/matchings/near/266205863) * Provide a bicoloring for matchings (https://leanprover.zulipchat.com/#narrow/stream/252551-graph-theory/topic/matchings/near/265495120) * Tutte's Theorem * Hall's Marriage Theorem (see combinatorics.hall) -/ universe u namespace SimpleGraph variable {V : Type u} {G : SimpleGraph V} (M : Subgraph G) namespace Subgraph /-- The subgraph `M` of `G` is a matching if every vertex of `M` is incident to exactly one edge in `M`. We say that the vertices in `M.support` are *matched* or *saturated*. -/ def IsMatching : Prop := ∀ ⦃v⦄, v ∈ M.verts → ∃! w, M.Adj v w #align simple_graph.subgraph.is_matching SimpleGraph.Subgraph.IsMatching /-- Given a vertex, returns the unique edge of the matching it is incident to. -/ noncomputable def IsMatching.toEdge {M : Subgraph G} (h : M.IsMatching) (v : M.verts) : M.edgeSet := ⟨s(v, (h v.property).choose), (h v.property).choose_spec.1⟩ #align simple_graph.subgraph.is_matching.to_edge SimpleGraph.Subgraph.IsMatching.toEdge theorem IsMatching.toEdge_eq_of_adj {M : Subgraph G} (h : M.IsMatching) {v w : V} (hv : v ∈ M.verts) (hvw : M.Adj v w) : h.toEdge ⟨v, hv⟩ = ⟨s(v, w), hvw⟩ := by simp only [IsMatching.toEdge, Subtype.mk_eq_mk] congr exact ((h (M.edge_vert hvw)).choose_spec.2 w hvw).symm #align simple_graph.subgraph.is_matching.to_edge_eq_of_adj SimpleGraph.Subgraph.IsMatching.toEdge_eq_of_adj theorem IsMatching.toEdge.surjective {M : Subgraph G} (h : M.IsMatching) : Function.Surjective h.toEdge := by rintro ⟨e, he⟩ refine Sym2.ind (fun x y he => ?_) e he exact ⟨⟨x, M.edge_vert he⟩, h.toEdge_eq_of_adj _ he⟩ #align simple_graph.subgraph.is_matching.to_edge.surjective SimpleGraph.Subgraph.IsMatching.toEdge.surjective
Mathlib/Combinatorics/SimpleGraph/Matching.lean
77
80
theorem IsMatching.toEdge_eq_toEdge_of_adj {M : Subgraph G} {v w : V} (h : M.IsMatching) (hv : v ∈ M.verts) (hw : w ∈ M.verts) (ha : M.Adj v w) : h.toEdge ⟨v, hv⟩ = h.toEdge ⟨w, hw⟩ := by
rw [h.toEdge_eq_of_adj hv ha, h.toEdge_eq_of_adj hw (M.symm ha), Subtype.mk_eq_mk, Sym2.eq_swap]
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.SetTheory.Ordinal.Arithmetic import Mathlib.SetTheory.Ordinal.Exponential #align_import set_theory.ordinal.cantor_normal_form from "leanprover-community/mathlib"@"991ff3b5269848f6dd942ae8e9dd3c946035dc8b" /-! # Cantor Normal Form The Cantor normal form of an ordinal is generally defined as its base `ω` expansion, with its non-zero exponents in decreasing order. Here, we more generally define a base `b` expansion `Ordinal.CNF` in this manner, which is well-behaved for any `b ≥ 2`. # Implementation notes We implement `Ordinal.CNF` as an association list, where keys are exponents and values are coefficients. This is because this structure intrinsically reflects two key properties of the Cantor normal form: - It is ordered. - It has finitely many entries. # Todo - Add API for the coefficients of the Cantor normal form. - Prove the basic results relating the CNF to the arithmetic operations on ordinals. -/ noncomputable section universe u open List namespace Ordinal /-- Inducts on the base `b` expansion of an ordinal. -/ @[elab_as_elim] noncomputable def CNFRec (b : Ordinal) {C : Ordinal → Sort*} (H0 : C 0) (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : ∀ o, C o := fun o ↦ by by_cases h : o = 0 · rw [h]; exact H0 · exact H o h (CNFRec _ H0 H (o % b ^ log b o)) termination_by o => o decreasing_by exact mod_opow_log_lt_self b h set_option linter.uppercaseLean3 false in #align ordinal.CNF_rec Ordinal.CNFRec @[simp] theorem CNFRec_zero {C : Ordinal → Sort*} (b : Ordinal) (H0 : C 0) (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : @CNFRec b C H0 H 0 = H0 := by rw [CNFRec, dif_pos rfl] rfl set_option linter.uppercaseLean3 false in #align ordinal.CNF_rec_zero Ordinal.CNFRec_zero theorem CNFRec_pos (b : Ordinal) {o : Ordinal} {C : Ordinal → Sort*} (ho : o ≠ 0) (H0 : C 0) (H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : @CNFRec b C H0 H o = H o ho (@CNFRec b C H0 H _) := by rw [CNFRec, dif_neg ho] set_option linter.uppercaseLean3 false in #align ordinal.CNF_rec_pos Ordinal.CNFRec_pos -- Porting note: unknown attribute @[pp_nodot] /-- The Cantor normal form of an ordinal `o` is the list of coefficients and exponents in the base-`b` expansion of `o`. We special-case `CNF 0 o = CNF 1 o = [(0, o)]` for `o ≠ 0`. `CNF b (b ^ u₁ * v₁ + b ^ u₂ * v₂) = [(u₁, v₁), (u₂, v₂)]` -/ def CNF (b o : Ordinal) : List (Ordinal × Ordinal) := CNFRec b [] (fun o _ho IH ↦ (log b o, o / b ^ log b o)::IH) o set_option linter.uppercaseLean3 false in #align ordinal.CNF Ordinal.CNF @[simp] theorem CNF_zero (b : Ordinal) : CNF b 0 = [] := CNFRec_zero b _ _ set_option linter.uppercaseLean3 false in #align ordinal.CNF_zero Ordinal.CNF_zero /-- Recursive definition for the Cantor normal form. -/ theorem CNF_ne_zero {b o : Ordinal} (ho : o ≠ 0) : CNF b o = (log b o, o / b ^ log b o)::CNF b (o % b ^ log b o) := CNFRec_pos b ho _ _ set_option linter.uppercaseLean3 false in #align ordinal.CNF_ne_zero Ordinal.CNF_ne_zero theorem zero_CNF {o : Ordinal} (ho : o ≠ 0) : CNF 0 o = [⟨0, o⟩] := by simp [CNF_ne_zero ho] set_option linter.uppercaseLean3 false in #align ordinal.zero_CNF Ordinal.zero_CNF theorem one_CNF {o : Ordinal} (ho : o ≠ 0) : CNF 1 o = [⟨0, o⟩] := by simp [CNF_ne_zero ho] set_option linter.uppercaseLean3 false in #align ordinal.one_CNF Ordinal.one_CNF theorem CNF_of_le_one {b o : Ordinal} (hb : b ≤ 1) (ho : o ≠ 0) : CNF b o = [⟨0, o⟩] := by rcases le_one_iff.1 hb with (rfl | rfl) · exact zero_CNF ho · exact one_CNF ho set_option linter.uppercaseLean3 false in #align ordinal.CNF_of_le_one Ordinal.CNF_of_le_one
Mathlib/SetTheory/Ordinal/CantorNormalForm.lean
108
109
theorem CNF_of_lt {b o : Ordinal} (ho : o ≠ 0) (hb : o < b) : CNF b o = [⟨0, o⟩] := by
simp only [CNF_ne_zero ho, log_eq_zero hb, opow_zero, div_one, mod_one, CNF_zero]
/- Copyright (c) 2022 Alexander Bentkamp. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp -/ import Mathlib.Analysis.InnerProductSpace.GramSchmidtOrtho import Mathlib.LinearAlgebra.Matrix.PosDef #align_import linear_algebra.matrix.ldl from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # LDL decomposition This file proves the LDL-decomposition of matrices: Any positive definite matrix `S` can be decomposed as `S = LDLᴴ` where `L` is a lower-triangular matrix and `D` is a diagonal matrix. ## Main definitions * `LDL.lower` is the lower triangular matrix `L`. * `LDL.lowerInv` is the inverse of the lower triangular matrix `L`. * `LDL.diag` is the diagonal matrix `D`. ## Main result * `LDL.lower_conj_diag` states that any positive definite matrix can be decomposed as `LDLᴴ`. ## TODO * Prove that `LDL.lower` is lower triangular from `LDL.lowerInv_triangular`. -/ variable {𝕜 : Type*} [RCLike 𝕜] variable {n : Type*} [LinearOrder n] [IsWellOrder n (· < ·)] [LocallyFiniteOrderBot n] section set_options set_option linter.uppercaseLean3 false set_option quotPrecheck false local notation "⟪" x ", " y "⟫ₑ" => @inner 𝕜 _ _ ((WithLp.equiv 2 _).symm x) ((WithLp.equiv _ _).symm y) open Matrix open scoped Matrix ComplexOrder variable {S : Matrix n n 𝕜} [Fintype n] (hS : S.PosDef) /-- The inverse of the lower triangular matrix `L` of the LDL-decomposition. It is obtained by applying Gram-Schmidt-Orthogonalization w.r.t. the inner product induced by `Sᵀ` on the standard basis vectors `Pi.basisFun`. -/ noncomputable def LDL.lowerInv : Matrix n n 𝕜 := @gramSchmidt 𝕜 (n → 𝕜) _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _ (Pi.basisFun 𝕜 n) #align LDL.lower_inv LDL.lowerInv theorem LDL.lowerInv_eq_gramSchmidtBasis : LDL.lowerInv hS = ((Pi.basisFun 𝕜 n).toMatrix (@gramSchmidtBasis 𝕜 (n → 𝕜) _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _ (Pi.basisFun 𝕜 n)))ᵀ := by letI := NormedAddCommGroup.ofMatrix hS.transpose letI := InnerProductSpace.ofMatrix hS.transpose ext i j rw [LDL.lowerInv, Basis.coePiBasisFun.toMatrix_eq_transpose, coe_gramSchmidtBasis] rfl #align LDL.lower_inv_eq_gram_schmidt_basis LDL.lowerInv_eq_gramSchmidtBasis noncomputable instance LDL.invertibleLowerInv : Invertible (LDL.lowerInv hS) := by rw [LDL.lowerInv_eq_gramSchmidtBasis] haveI := Basis.invertibleToMatrix (Pi.basisFun 𝕜 n) (@gramSchmidtBasis 𝕜 (n → 𝕜) _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _ (Pi.basisFun 𝕜 n)) infer_instance #align LDL.invertible_lower_inv LDL.invertibleLowerInv theorem LDL.lowerInv_orthogonal {i j : n} (h₀ : i ≠ j) : ⟪LDL.lowerInv hS i, Sᵀ *ᵥ LDL.lowerInv hS j⟫ₑ = 0 := @gramSchmidt_orthogonal 𝕜 _ _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) _ _ _ _ _ _ _ h₀ #align LDL.lower_inv_orthogonal LDL.lowerInv_orthogonal /-- The entries of the diagonal matrix `D` of the LDL decomposition. -/ noncomputable def LDL.diagEntries : n → 𝕜 := fun i => ⟪star (LDL.lowerInv hS i), S *ᵥ star (LDL.lowerInv hS i)⟫ₑ #align LDL.diag_entries LDL.diagEntries /-- The diagonal matrix `D` of the LDL decomposition. -/ noncomputable def LDL.diag : Matrix n n 𝕜 := Matrix.diagonal (LDL.diagEntries hS) #align LDL.diag LDL.diag theorem LDL.lowerInv_triangular {i j : n} (hij : i < j) : LDL.lowerInv hS i j = 0 := by rw [← @gramSchmidt_triangular 𝕜 (n → 𝕜) _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _ i j hij (Pi.basisFun 𝕜 n), Pi.basisFun_repr, LDL.lowerInv] #align LDL.lower_inv_triangular LDL.lowerInv_triangular /-- Inverse statement of **LDL decomposition**: we can conjugate a positive definite matrix by some lower triangular matrix and get a diagonal matrix. -/ theorem LDL.diag_eq_lowerInv_conj : LDL.diag hS = LDL.lowerInv hS * S * (LDL.lowerInv hS)ᴴ := by ext i j by_cases hij : i = j · simp only [diag, diagEntries, EuclideanSpace.inner_piLp_equiv_symm, star_star, hij, diagonal_apply_eq, Matrix.mul_assoc] rfl · simp only [LDL.diag, hij, diagonal_apply_ne, Ne, not_false_iff, mul_mul_apply] rw [conjTranspose, transpose_map, transpose_transpose, dotProduct_mulVec, (LDL.lowerInv_orthogonal hS fun h : j = i => hij h.symm).symm, ← inner_conj_symm, mulVec_transpose, EuclideanSpace.inner_piLp_equiv_symm, ← RCLike.star_def, ← star_dotProduct_star, dotProduct_comm, star_star] rfl #align LDL.diag_eq_lower_inv_conj LDL.diag_eq_lowerInv_conj /-- The lower triangular matrix `L` of the LDL decomposition. -/ noncomputable def LDL.lower := (LDL.lowerInv hS)⁻¹ #align LDL.lower LDL.lower /-- **LDL decomposition**: any positive definite matrix `S` can be decomposed as `S = LDLᴴ` where `L` is a lower-triangular matrix and `D` is a diagonal matrix. -/
Mathlib/LinearAlgebra/Matrix/LDL.lean
123
127
theorem LDL.lower_conj_diag : LDL.lower hS * LDL.diag hS * (LDL.lower hS)ᴴ = S := by
rw [LDL.lower, conjTranspose_nonsing_inv, Matrix.mul_assoc, Matrix.inv_mul_eq_iff_eq_mul_of_invertible (LDL.lowerInv hS), Matrix.mul_inv_eq_iff_eq_mul_of_invertible] exact LDL.diag_eq_lowerInv_conj hS
/- Copyright (c) 2022 Alexander Bentkamp. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp -/ import Mathlib.Analysis.InnerProductSpace.GramSchmidtOrtho import Mathlib.LinearAlgebra.Matrix.PosDef #align_import linear_algebra.matrix.ldl from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # LDL decomposition This file proves the LDL-decomposition of matrices: Any positive definite matrix `S` can be decomposed as `S = LDLᴴ` where `L` is a lower-triangular matrix and `D` is a diagonal matrix. ## Main definitions * `LDL.lower` is the lower triangular matrix `L`. * `LDL.lowerInv` is the inverse of the lower triangular matrix `L`. * `LDL.diag` is the diagonal matrix `D`. ## Main result * `LDL.lower_conj_diag` states that any positive definite matrix can be decomposed as `LDLᴴ`. ## TODO * Prove that `LDL.lower` is lower triangular from `LDL.lowerInv_triangular`. -/ variable {𝕜 : Type*} [RCLike 𝕜] variable {n : Type*} [LinearOrder n] [IsWellOrder n (· < ·)] [LocallyFiniteOrderBot n] section set_options set_option linter.uppercaseLean3 false set_option quotPrecheck false local notation "⟪" x ", " y "⟫ₑ" => @inner 𝕜 _ _ ((WithLp.equiv 2 _).symm x) ((WithLp.equiv _ _).symm y) open Matrix open scoped Matrix ComplexOrder variable {S : Matrix n n 𝕜} [Fintype n] (hS : S.PosDef) /-- The inverse of the lower triangular matrix `L` of the LDL-decomposition. It is obtained by applying Gram-Schmidt-Orthogonalization w.r.t. the inner product induced by `Sᵀ` on the standard basis vectors `Pi.basisFun`. -/ noncomputable def LDL.lowerInv : Matrix n n 𝕜 := @gramSchmidt 𝕜 (n → 𝕜) _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _ (Pi.basisFun 𝕜 n) #align LDL.lower_inv LDL.lowerInv
Mathlib/LinearAlgebra/Matrix/LDL.lean
57
66
theorem LDL.lowerInv_eq_gramSchmidtBasis : LDL.lowerInv hS = ((Pi.basisFun 𝕜 n).toMatrix (@gramSchmidtBasis 𝕜 (n → 𝕜) _ (_ : _) (InnerProductSpace.ofMatrix hS.transpose) n _ _ _ (Pi.basisFun 𝕜 n)))ᵀ := by
letI := NormedAddCommGroup.ofMatrix hS.transpose letI := InnerProductSpace.ofMatrix hS.transpose ext i j rw [LDL.lowerInv, Basis.coePiBasisFun.toMatrix_eq_transpose, coe_gramSchmidtBasis] rfl
/- Copyright (c) 2022 Chris Birkbeck. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Birkbeck -/ import Mathlib.Data.Complex.Basic import Mathlib.MeasureTheory.Integral.CircleIntegral #align_import measure_theory.integral.circle_transform from "leanprover-community/mathlib"@"d11893b411025250c8e61ff2f12ccbd7ee35ab15" /-! # Circle integral transform In this file we define the circle integral transform of a function `f` with complex domain. This is defined as $(2πi)^{-1}\frac{f(x)}{x-w}$ where `x` moves along a circle. We then prove some basic facts about these functions. These results are useful for proving that the uniform limit of a sequence of holomorphic functions is holomorphic. -/ open Set MeasureTheory Metric Filter Function open scoped Interval Real noncomputable section variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] (R : ℝ) (z w : ℂ) namespace Complex /-- Given a function `f : ℂ → E`, `circleTransform R z w f` is the function mapping `θ` to `(2 * ↑π * I)⁻¹ • deriv (circleMap z R) θ • ((circleMap z R θ) - w)⁻¹ • f (circleMap z R θ)`. If `f` is differentiable and `w` is in the interior of the ball, then the integral from `0` to `2 * π` of this gives the value `f(w)`. -/ def circleTransform (f : ℂ → E) (θ : ℝ) : E := (2 * ↑π * I)⁻¹ • deriv (circleMap z R) θ • (circleMap z R θ - w)⁻¹ • f (circleMap z R θ) #align complex.circle_transform Complex.circleTransform /-- The derivative of `circleTransform` w.r.t `w`. -/ def circleTransformDeriv (f : ℂ → E) (θ : ℝ) : E := (2 * ↑π * I)⁻¹ • deriv (circleMap z R) θ • ((circleMap z R θ - w) ^ 2)⁻¹ • f (circleMap z R θ) #align complex.circle_transform_deriv Complex.circleTransformDeriv
Mathlib/MeasureTheory/Integral/CircleTransform.lean
48
55
theorem circleTransformDeriv_periodic (f : ℂ → E) : Periodic (circleTransformDeriv R z w f) (2 * π) := by
have := periodic_circleMap simp_rw [Periodic] at * intro x simp_rw [circleTransformDeriv, this] congr 2 simp [this]
/- 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, Mario Carneiro -/ import Mathlib.Algebra.BigOperators.Ring.List import Mathlib.Data.Nat.Prime import Mathlib.Data.List.Prime import Mathlib.Data.List.Sort import Mathlib.Data.List.Chain #align_import data.nat.factors from "leanprover-community/mathlib"@"008205aa645b3f194c1da47025c5f110c8406eab" /-! # Prime numbers This file deals with the factors of natural numbers. ## Important declarations - `Nat.factors n`: the prime factorization of `n` - `Nat.factors_unique`: uniqueness of the prime factorisation -/ open Bool Subtype open Nat namespace Nat attribute [instance 0] instBEqNat /-- `factors n` is the prime factorization of `n`, listed in increasing order. -/ def factors : ℕ → List ℕ | 0 => [] | 1 => [] | k + 2 => let m := minFac (k + 2) m :: factors ((k + 2) / m) decreasing_by show (k + 2) / m < (k + 2); exact factors_lemma #align nat.factors Nat.factors @[simp]
Mathlib/Data/Nat/Factors.lean
45
45
theorem factors_zero : factors 0 = [] := by
rw [factors]
/- 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, Sébastien Gouëzel, Rémy Degenne, David Loeffler -/ import Mathlib.Analysis.SpecialFunctions.Pow.Real #align_import analysis.special_functions.pow.nnreal from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" /-! # Power function on `ℝ≥0` and `ℝ≥0∞` We construct the power functions `x ^ y` where * `x` is a nonnegative real number and `y` is a real number; * `x` is a number from `[0, +∞]` (a.k.a. `ℝ≥0∞`) and `y` is a real number. We also prove basic properties of these functions. -/ noncomputable section open scoped Classical open Real NNReal ENNReal ComplexConjugate open Finset Function Set namespace NNReal variable {w x y z : ℝ} /-- The nonnegative real power function `x^y`, defined for `x : ℝ≥0` and `y : ℝ` as the restriction of the real power function. For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`, one sets `0 ^ 0 = 1` and `0 ^ y = 0` for `y ≠ 0`. -/ noncomputable def rpow (x : ℝ≥0) (y : ℝ) : ℝ≥0 := ⟨(x : ℝ) ^ y, Real.rpow_nonneg x.2 y⟩ #align nnreal.rpow NNReal.rpow noncomputable instance : Pow ℝ≥0 ℝ := ⟨rpow⟩ @[simp] theorem rpow_eq_pow (x : ℝ≥0) (y : ℝ) : rpow x y = x ^ y := rfl #align nnreal.rpow_eq_pow NNReal.rpow_eq_pow @[simp, norm_cast] theorem coe_rpow (x : ℝ≥0) (y : ℝ) : ((x ^ y : ℝ≥0) : ℝ) = (x : ℝ) ^ y := rfl #align nnreal.coe_rpow NNReal.coe_rpow @[simp] theorem rpow_zero (x : ℝ≥0) : x ^ (0 : ℝ) = 1 := NNReal.eq <| Real.rpow_zero _ #align nnreal.rpow_zero NNReal.rpow_zero @[simp] theorem rpow_eq_zero_iff {x : ℝ≥0} {y : ℝ} : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by rw [← NNReal.coe_inj, coe_rpow, ← NNReal.coe_eq_zero] exact Real.rpow_eq_zero_iff_of_nonneg x.2 #align nnreal.rpow_eq_zero_iff NNReal.rpow_eq_zero_iff @[simp] theorem zero_rpow {x : ℝ} (h : x ≠ 0) : (0 : ℝ≥0) ^ x = 0 := NNReal.eq <| Real.zero_rpow h #align nnreal.zero_rpow NNReal.zero_rpow @[simp] theorem rpow_one (x : ℝ≥0) : x ^ (1 : ℝ) = x := NNReal.eq <| Real.rpow_one _ #align nnreal.rpow_one NNReal.rpow_one @[simp] theorem one_rpow (x : ℝ) : (1 : ℝ≥0) ^ x = 1 := NNReal.eq <| Real.one_rpow _ #align nnreal.one_rpow NNReal.one_rpow theorem rpow_add {x : ℝ≥0} (hx : x ≠ 0) (y z : ℝ) : x ^ (y + z) = x ^ y * x ^ z := NNReal.eq <| Real.rpow_add (pos_iff_ne_zero.2 hx) _ _ #align nnreal.rpow_add NNReal.rpow_add theorem rpow_add' (x : ℝ≥0) {y z : ℝ} (h : y + z ≠ 0) : x ^ (y + z) = x ^ y * x ^ z := NNReal.eq <| Real.rpow_add' x.2 h #align nnreal.rpow_add' NNReal.rpow_add' /-- Variant of `NNReal.rpow_add'` that avoids having to prove `y + z = w` twice. -/ lemma rpow_of_add_eq (x : ℝ≥0) (hw : w ≠ 0) (h : y + z = w) : x ^ w = x ^ y * x ^ z := by rw [← h, rpow_add']; rwa [h] theorem rpow_mul (x : ℝ≥0) (y z : ℝ) : x ^ (y * z) = (x ^ y) ^ z := NNReal.eq <| Real.rpow_mul x.2 y z #align nnreal.rpow_mul NNReal.rpow_mul theorem rpow_neg (x : ℝ≥0) (y : ℝ) : x ^ (-y) = (x ^ y)⁻¹ := NNReal.eq <| Real.rpow_neg x.2 _ #align nnreal.rpow_neg NNReal.rpow_neg theorem rpow_neg_one (x : ℝ≥0) : x ^ (-1 : ℝ) = x⁻¹ := by simp [rpow_neg] #align nnreal.rpow_neg_one NNReal.rpow_neg_one theorem rpow_sub {x : ℝ≥0} (hx : x ≠ 0) (y z : ℝ) : x ^ (y - z) = x ^ y / x ^ z := NNReal.eq <| Real.rpow_sub (pos_iff_ne_zero.2 hx) y z #align nnreal.rpow_sub NNReal.rpow_sub theorem rpow_sub' (x : ℝ≥0) {y z : ℝ} (h : y - z ≠ 0) : x ^ (y - z) = x ^ y / x ^ z := NNReal.eq <| Real.rpow_sub' x.2 h #align nnreal.rpow_sub' NNReal.rpow_sub' theorem rpow_inv_rpow_self {y : ℝ} (hy : y ≠ 0) (x : ℝ≥0) : (x ^ y) ^ (1 / y) = x := by field_simp [← rpow_mul] #align nnreal.rpow_inv_rpow_self NNReal.rpow_inv_rpow_self
Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean
112
113
theorem rpow_self_rpow_inv {y : ℝ} (hy : y ≠ 0) (x : ℝ≥0) : (x ^ (1 / y)) ^ y = x := by
field_simp [← rpow_mul]
/- 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.Algebra.MonoidAlgebra.Basic #align_import algebra.monoid_algebra.division from "leanprover-community/mathlib"@"72c366d0475675f1309d3027d3d7d47ee4423951" /-! # Division of `AddMonoidAlgebra` by monomials This file is most important for when `G = ℕ` (polynomials) or `G = σ →₀ ℕ` (multivariate polynomials). In order to apply in maximal generality (such as for `LaurentPolynomial`s), this uses `∃ d, g' = g + d` in many places instead of `g ≤ g'`. ## Main definitions * `AddMonoidAlgebra.divOf x g`: divides `x` by the monomial `AddMonoidAlgebra.of k G g` * `AddMonoidAlgebra.modOf x g`: the remainder upon dividing `x` by the monomial `AddMonoidAlgebra.of k G g`. ## Main results * `AddMonoidAlgebra.divOf_add_modOf`, `AddMonoidAlgebra.modOf_add_divOf`: `divOf` and `modOf` are well-behaved as quotient and remainder operators. ## Implementation notes `∃ d, g' = g + d` is used as opposed to some other permutation up to commutativity in order to match the definition of `semigroupDvd`. The results in this file could be duplicated for `MonoidAlgebra` by using `g ∣ g'`, but this can't be done automatically, and in any case is not likely to be very useful. -/ variable {k G : Type*} [Semiring k] namespace AddMonoidAlgebra section variable [AddCancelCommMonoid G] /-- Divide by `of' k G g`, discarding terms not divisible by this. -/ noncomputable def divOf (x : k[G]) (g : G) : k[G] := -- note: comapping by `+ g` has the effect of subtracting `g` from every element in -- the support, and discarding the elements of the support from which `g` can't be subtracted. -- If `G` is an additive group, such as `ℤ` when used for `LaurentPolynomial`, -- then no discarding occurs. @Finsupp.comapDomain.addMonoidHom _ _ _ _ (g + ·) (add_right_injective g) x #align add_monoid_algebra.div_of AddMonoidAlgebra.divOf local infixl:70 " /ᵒᶠ " => divOf @[simp] theorem divOf_apply (g : G) (x : k[G]) (g' : G) : (x /ᵒᶠ g) g' = x (g + g') := rfl #align add_monoid_algebra.div_of_apply AddMonoidAlgebra.divOf_apply @[simp] theorem support_divOf (g : G) (x : k[G]) : (x /ᵒᶠ g).support = x.support.preimage (g + ·) (Function.Injective.injOn (add_right_injective g)) := rfl #align add_monoid_algebra.support_div_of AddMonoidAlgebra.support_divOf @[simp] theorem zero_divOf (g : G) : (0 : k[G]) /ᵒᶠ g = 0 := map_zero (Finsupp.comapDomain.addMonoidHom _) #align add_monoid_algebra.zero_div_of AddMonoidAlgebra.zero_divOf @[simp] theorem divOf_zero (x : k[G]) : x /ᵒᶠ 0 = x := by refine Finsupp.ext fun _ => ?_ -- Porting note: `ext` doesn't work simp only [AddMonoidAlgebra.divOf_apply, zero_add] #align add_monoid_algebra.div_of_zero AddMonoidAlgebra.divOf_zero theorem add_divOf (x y : k[G]) (g : G) : (x + y) /ᵒᶠ g = x /ᵒᶠ g + y /ᵒᶠ g := map_add (Finsupp.comapDomain.addMonoidHom _) _ _ #align add_monoid_algebra.add_div_of AddMonoidAlgebra.add_divOf theorem divOf_add (x : k[G]) (a b : G) : x /ᵒᶠ (a + b) = x /ᵒᶠ a /ᵒᶠ b := by refine Finsupp.ext fun _ => ?_ -- Porting note: `ext` doesn't work simp only [AddMonoidAlgebra.divOf_apply, add_assoc] #align add_monoid_algebra.div_of_add AddMonoidAlgebra.divOf_add /-- A bundled version of `AddMonoidAlgebra.divOf`. -/ @[simps] noncomputable def divOfHom : Multiplicative G →* AddMonoid.End k[G] where toFun g := { toFun := fun x => divOf x (Multiplicative.toAdd g) map_zero' := zero_divOf _ map_add' := fun x y => add_divOf x y (Multiplicative.toAdd g) } map_one' := AddMonoidHom.ext divOf_zero map_mul' g₁ g₂ := AddMonoidHom.ext fun _x => (congr_arg _ (add_comm (Multiplicative.toAdd g₁) (Multiplicative.toAdd g₂))).trans (divOf_add _ _ _) #align add_monoid_algebra.div_of_hom AddMonoidAlgebra.divOfHom
Mathlib/Algebra/MonoidAlgebra/Division.lean
105
109
theorem of'_mul_divOf (a : G) (x : k[G]) : of' k G a * x /ᵒᶠ a = x := by
refine Finsupp.ext fun _ => ?_ -- Porting note: `ext` doesn't work rw [AddMonoidAlgebra.divOf_apply, of'_apply, single_mul_apply_aux, one_mul] intro c exact add_right_inj _
/- Copyright (c) 2023 Xavier Roblot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Xavier Roblot -/ import Mathlib.Data.Real.Pi.Bounds import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.ConvexBody /-! # Number field discriminant This file defines the discriminant of a number field. ## Main definitions * `NumberField.discr`: the absolute discriminant of a number field. ## Main result * `NumberField.abs_discr_gt_two`: **Hermite-Minkowski Theorem**. A nontrivial number field has discriminant greater than `2`. * `NumberField.finite_of_discr_bdd`: **Hermite Theorem**. Let `N` be an integer. There are only finitely many number fields (in some fixed extension of `ℚ`) of discriminant bounded by `N`. ## Tags number field, discriminant -/ -- TODO. Rewrite some of the FLT results on the disciminant using the definitions and results of -- this file namespace NumberField open FiniteDimensional NumberField NumberField.InfinitePlace Matrix open scoped Classical Real nonZeroDivisors variable (K : Type*) [Field K] [NumberField K] /-- The absolute discriminant of a number field. -/ noncomputable abbrev discr : ℤ := Algebra.discr ℤ (RingOfIntegers.basis K) theorem coe_discr : (discr K : ℚ) = Algebra.discr ℚ (integralBasis K) := (Algebra.discr_localizationLocalization ℤ _ K (RingOfIntegers.basis K)).symm
Mathlib/NumberTheory/NumberField/Discriminant.lean
46
48
theorem discr_ne_zero : discr K ≠ 0 := by
rw [← (Int.cast_injective (α := ℚ)).ne_iff, coe_discr] exact Algebra.discr_not_zero_of_basis ℚ (integralBasis K)
/- 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 -/ import Mathlib.Algebra.BigOperators.Group.Finset #align_import data.nat.gcd.big_operators from "leanprover-community/mathlib"@"008205aa645b3f194c1da47025c5f110c8406eab" /-! # Lemmas about coprimality with big products. These lemmas are kept separate from `Data.Nat.GCD.Basic` in order to minimize imports. -/ namespace Nat variable {ι : Type*} theorem coprime_list_prod_left_iff {l : List ℕ} {k : ℕ} : Coprime l.prod k ↔ ∀ n ∈ l, Coprime n k := by induction l <;> simp [Nat.coprime_mul_iff_left, *] theorem coprime_list_prod_right_iff {k : ℕ} {l : List ℕ} : Coprime k l.prod ↔ ∀ n ∈ l, Coprime k n := by simp_rw [coprime_comm (n := k), coprime_list_prod_left_iff]
Mathlib/Data/Nat/GCD/BigOperators.lean
28
30
theorem coprime_multiset_prod_left_iff {m : Multiset ℕ} {k : ℕ} : Coprime m.prod k ↔ ∀ n ∈ m, Coprime n k := by
induction m using Quotient.inductionOn; simpa using coprime_list_prod_left_iff
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.RingTheory.Nilpotent.Lemmas import Mathlib.RingTheory.Ideal.QuotientOperations #align_import ring_theory.quotient_nilpotent from "leanprover-community/mathlib"@"da420a8c6dd5bdfb85c4ced85c34388f633bc6ff" /-! # Nilpotent elements in quotient rings -/ theorem Ideal.isRadical_iff_quotient_reduced {R : Type*} [CommRing R] (I : Ideal R) : I.IsRadical ↔ IsReduced (R ⧸ I) := by conv_lhs => rw [← @Ideal.mk_ker R _ I] exact RingHom.ker_isRadical_iff_reduced_of_surjective (@Ideal.Quotient.mk_surjective R _ I) #align ideal.is_radical_iff_quotient_reduced Ideal.isRadical_iff_quotient_reduced variable {R S : Type*} [CommSemiring R] [CommRing S] [Algebra R S] (I : Ideal S) /-- Let `P` be a property on ideals. If `P` holds for square-zero ideals, and if `P I → P (J ⧸ I) → P J`, then `P` holds for all nilpotent ideals. -/
Mathlib/RingTheory/QuotientNilpotent.lean
26
51
theorem Ideal.IsNilpotent.induction_on (hI : IsNilpotent I) {P : ∀ ⦃S : Type _⦄ [CommRing S], Ideal S → Prop} (h₁ : ∀ ⦃S : Type _⦄ [CommRing S], ∀ I : Ideal S, I ^ 2 = ⊥ → P I) (h₂ : ∀ ⦃S : Type _⦄ [CommRing S], ∀ I J : Ideal S, I ≤ J → P I → P (J.map (Ideal.Quotient.mk I)) → P J) : P I := by
obtain ⟨n, hI : I ^ n = ⊥⟩ := hI induction' n using Nat.strong_induction_on with n H generalizing S by_cases hI' : I = ⊥ · subst hI' apply h₁ rw [← Ideal.zero_eq_bot, zero_pow two_ne_zero] cases' n with n · rw [pow_zero, Ideal.one_eq_top] at hI haveI := subsingleton_of_bot_eq_top hI.symm exact (hI' (Subsingleton.elim _ _)).elim cases' n with n · rw [pow_one] at hI exact (hI' hI).elim apply h₂ (I ^ 2) _ (Ideal.pow_le_self two_ne_zero) · apply H n.succ _ (I ^ 2) · rw [← pow_mul, eq_bot_iff, ← hI, Nat.succ_eq_add_one] apply Ideal.pow_le_pow_right (by omega) · exact n.succ.lt_succ_self · apply h₁ rw [← Ideal.map_pow, Ideal.map_quotient_self]
/- Copyright (c) 2016 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad -/ import Mathlib.Algebra.Order.Ring.Abs #align_import data.int.order.lemmas from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" /-! # Further lemmas about the integers The distinction between this file and `Data.Int.Order.Basic` is not particularly clear. They are separated by now to minimize the porting requirements for tactics during the transition to mathlib4. Now that `Algebra.Order.Ring.Rat` has been ported, please feel free to reorganize these two files. -/ open Function Nat namespace Int /-! ### nat abs -/ variable {a b : ℤ} {n : ℕ} theorem natAbs_eq_iff_mul_self_eq {a b : ℤ} : a.natAbs = b.natAbs ↔ a * a = b * b := by rw [← abs_eq_iff_mul_self_eq, abs_eq_natAbs, abs_eq_natAbs] exact Int.natCast_inj.symm #align int.nat_abs_eq_iff_mul_self_eq Int.natAbs_eq_iff_mul_self_eq #align int.eq_nat_abs_iff_mul_eq_zero Int.eq_natAbs_iff_mul_eq_zero theorem natAbs_lt_iff_mul_self_lt {a b : ℤ} : a.natAbs < b.natAbs ↔ a * a < b * b := by rw [← abs_lt_iff_mul_self_lt, abs_eq_natAbs, abs_eq_natAbs] exact Int.ofNat_lt.symm #align int.nat_abs_lt_iff_mul_self_lt Int.natAbs_lt_iff_mul_self_lt theorem natAbs_le_iff_mul_self_le {a b : ℤ} : a.natAbs ≤ b.natAbs ↔ a * a ≤ b * b := by rw [← abs_le_iff_mul_self_le, abs_eq_natAbs, abs_eq_natAbs] exact Int.ofNat_le.symm #align int.nat_abs_le_iff_mul_self_le Int.natAbs_le_iff_mul_self_le
Mathlib/Data/Int/Order/Lemmas.lean
45
50
theorem dvd_div_of_mul_dvd {a b c : ℤ} (h : a * b ∣ c) : b ∣ c / a := by
rcases eq_or_ne a 0 with (rfl | ha) · simp only [Int.ediv_zero, Int.dvd_zero] rcases h with ⟨d, rfl⟩ refine ⟨d, ?_⟩ rw [mul_assoc, Int.mul_ediv_cancel_left _ ha]
/- Copyright (c) 2020 Jannis Limperg. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jannis Limperg -/ import Mathlib.Data.List.OfFn import Mathlib.Data.List.Range #align_import data.list.indexes from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" /-! # Lemmas about List.*Idx functions. Some specification lemmas for `List.mapIdx`, `List.mapIdxM`, `List.foldlIdx` and `List.foldrIdx`. -/ assert_not_exists MonoidWithZero universe u v open Function namespace List variable {α : Type u} {β : Type v} section MapIdx -- Porting note: Add back old definition because it's easier for writing proofs. /-- Lean3 `map_with_index` helper function -/ protected def oldMapIdxCore (f : ℕ → α → β) : ℕ → List α → List β | _, [] => [] | k, a :: as => f k a :: List.oldMapIdxCore f (k + 1) as /-- Given a function `f : ℕ → α → β` and `as : List α`, `as = [a₀, a₁, ...]`, returns the list `[f 0 a₀, f 1 a₁, ...]`. -/ protected def oldMapIdx (f : ℕ → α → β) (as : List α) : List β := List.oldMapIdxCore f 0 as @[simp] theorem mapIdx_nil {α β} (f : ℕ → α → β) : mapIdx f [] = [] := rfl #align list.map_with_index_nil List.mapIdx_nil -- Porting note (#10756): new theorem. protected theorem oldMapIdxCore_eq (l : List α) (f : ℕ → α → β) (n : ℕ) : l.oldMapIdxCore f n = l.oldMapIdx fun i a ↦ f (i + n) a := by induction' l with hd tl hl generalizing f n · rfl · rw [List.oldMapIdx] simp only [List.oldMapIdxCore, hl, Nat.add_left_comm, Nat.add_comm, Nat.add_zero] #noalign list.map_with_index_core_eq -- Porting note: convert new definition to old definition. -- A few new theorems are added to achieve this -- 1. Prove that `oldMapIdxCore f (l ++ [e]) = oldMapIdxCore f l ++ [f l.length e]` -- 2. Prove that `oldMapIdx f (l ++ [e]) = oldMapIdx f l ++ [f l.length e]` -- 3. Prove list induction using `∀ l e, p [] → (p l → p (l ++ [e])) → p l` -- Porting note (#10756): new theorem.
Mathlib/Data/List/Indexes.lean
61
71
theorem list_reverse_induction (p : List α → Prop) (base : p []) (ind : ∀ (l : List α) (e : α), p l → p (l ++ [e])) : (∀ (l : List α), p l) := by
let q := fun l ↦ p (reverse l) have pq : ∀ l, p (reverse l) → q l := by simp only [q, reverse_reverse]; intro; exact id have qp : ∀ l, q (reverse l) → p l := by simp only [q, reverse_reverse]; intro; exact id intro l apply qp generalize (reverse l) = l induction' l with head tail ih · apply pq; simp only [reverse_nil, base] · apply pq; simp only [reverse_cons]; apply ind; apply qp; rw [reverse_reverse]; exact ih
/- Copyright (c) 2020 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne, Sébastien Gouëzel -/ import Mathlib.Analysis.NormedSpace.IndicatorFunction import Mathlib.MeasureTheory.Function.EssSup import Mathlib.MeasureTheory.Function.AEEqFun import Mathlib.MeasureTheory.Function.SpecialFunctions.Basic #align_import measure_theory.function.lp_seminorm from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9" /-! # ℒp space This file describes properties of almost everywhere strongly measurable functions with finite `p`-seminorm, denoted by `snorm f p μ` and defined for `p:ℝ≥0∞` as `0` if `p=0`, `(∫ ‖f a‖^p ∂μ) ^ (1/p)` for `0 < p < ∞` and `essSup ‖f‖ μ` for `p=∞`. The Prop-valued `Memℒp f p μ` states that a function `f : α → E` has finite `p`-seminorm and is almost everywhere strongly measurable. ## Main definitions * `snorm' f p μ` : `(∫ ‖f a‖^p ∂μ) ^ (1/p)` for `f : α → F` and `p : ℝ`, where `α` is a measurable space and `F` is a normed group. * `snormEssSup f μ` : seminorm in `ℒ∞`, equal to the essential supremum `ess_sup ‖f‖ μ`. * `snorm f p μ` : for `p : ℝ≥0∞`, seminorm in `ℒp`, equal to `0` for `p=0`, to `snorm' f p μ` for `0 < p < ∞` and to `snormEssSup f μ` for `p = ∞`. * `Memℒp f p μ` : property that the function `f` is almost everywhere strongly measurable and has finite `p`-seminorm for the measure `μ` (`snorm f p μ < ∞`) -/ noncomputable section set_option linter.uppercaseLean3 false open TopologicalSpace MeasureTheory Filter open scoped NNReal ENNReal Topology variable {α E F G : Type*} {m m0 : MeasurableSpace α} {p : ℝ≥0∞} {q : ℝ} {μ ν : Measure α} [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedAddCommGroup G] namespace MeasureTheory section ℒp /-! ### ℒp seminorm We define the ℒp seminorm, denoted by `snorm f p μ`. For real `p`, it is given by an integral formula (for which we use the notation `snorm' f p μ`), and for `p = ∞` it is the essential supremum (for which we use the notation `snormEssSup f μ`). We also define a predicate `Memℒp f p μ`, requesting that a function is almost everywhere measurable and has finite `snorm f p μ`. This paragraph is devoted to the basic properties of these definitions. It is constructed as follows: for a given property, we prove it for `snorm'` and `snormEssSup` when it makes sense, deduce it for `snorm`, and translate it in terms of `Memℒp`. -/ section ℒpSpaceDefinition /-- `(∫ ‖f a‖^q ∂μ) ^ (1/q)`, which is a seminorm on the space of measurable functions for which this quantity is finite -/ def snorm' {_ : MeasurableSpace α} (f : α → F) (q : ℝ) (μ : Measure α) : ℝ≥0∞ := (∫⁻ a, (‖f a‖₊ : ℝ≥0∞) ^ q ∂μ) ^ (1 / q) #align measure_theory.snorm' MeasureTheory.snorm' /-- seminorm for `ℒ∞`, equal to the essential supremum of `‖f‖`. -/ def snormEssSup {_ : MeasurableSpace α} (f : α → F) (μ : Measure α) := essSup (fun x => (‖f x‖₊ : ℝ≥0∞)) μ #align measure_theory.snorm_ess_sup MeasureTheory.snormEssSup /-- `ℒp` seminorm, equal to `0` for `p=0`, to `(∫ ‖f a‖^p ∂μ) ^ (1/p)` for `0 < p < ∞` and to `essSup ‖f‖ μ` for `p = ∞`. -/ def snorm {_ : MeasurableSpace α} (f : α → F) (p : ℝ≥0∞) (μ : Measure α) : ℝ≥0∞ := if p = 0 then 0 else if p = ∞ then snormEssSup f μ else snorm' f (ENNReal.toReal p) μ #align measure_theory.snorm MeasureTheory.snorm theorem snorm_eq_snorm' (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {f : α → F} : snorm f p μ = snorm' f (ENNReal.toReal p) μ := by simp [snorm, hp_ne_zero, hp_ne_top] #align measure_theory.snorm_eq_snorm' MeasureTheory.snorm_eq_snorm' theorem snorm_eq_lintegral_rpow_nnnorm (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {f : α → F} : snorm f p μ = (∫⁻ x, (‖f x‖₊ : ℝ≥0∞) ^ p.toReal ∂μ) ^ (1 / p.toReal) := by rw [snorm_eq_snorm' hp_ne_zero hp_ne_top, snorm'] #align measure_theory.snorm_eq_lintegral_rpow_nnnorm MeasureTheory.snorm_eq_lintegral_rpow_nnnorm theorem snorm_one_eq_lintegral_nnnorm {f : α → F} : snorm f 1 μ = ∫⁻ x, ‖f x‖₊ ∂μ := by simp_rw [snorm_eq_lintegral_rpow_nnnorm one_ne_zero ENNReal.coe_ne_top, ENNReal.one_toReal, one_div_one, ENNReal.rpow_one] #align measure_theory.snorm_one_eq_lintegral_nnnorm MeasureTheory.snorm_one_eq_lintegral_nnnorm @[simp]
Mathlib/MeasureTheory/Function/LpSeminorm/Basic.lean
102
102
theorem snorm_exponent_top {f : α → F} : snorm f ∞ μ = snormEssSup f μ := by
simp [snorm]
/- Copyright (c) 2021 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.Independence.Basic import Mathlib.Probability.Independence.Conditional #align_import probability.independence.zero_one from "leanprover-community/mathlib"@"2f8347015b12b0864dfaf366ec4909eb70c78740" /-! # Kolmogorov's 0-1 law Let `s : ι → MeasurableSpace Ω` be an independent sequence of sub-σ-algebras. Then any set which is measurable with respect to the tail σ-algebra `limsup s atTop` has probability 0 or 1. ## Main statements * `measure_zero_or_one_of_measurableSet_limsup_atTop`: Kolmogorov's 0-1 law. Any set which is measurable with respect to the tail σ-algebra `limsup s atTop` of an independent sequence of σ-algebras `s` has probability 0 or 1. -/ open MeasureTheory MeasurableSpace open scoped MeasureTheory ENNReal namespace ProbabilityTheory variable {α Ω ι : Type*} {_mα : MeasurableSpace α} {s : ι → MeasurableSpace Ω} {m m0 : MeasurableSpace Ω} {κ : kernel α Ω} {μα : Measure α} {μ : Measure Ω} theorem kernel.measure_eq_zero_or_one_or_top_of_indepSet_self {t : Set Ω} (h_indep : kernel.IndepSet t t κ μα) : ∀ᵐ a ∂μα, κ a t = 0 ∨ κ a t = 1 ∨ κ a t = ∞ := by specialize h_indep t t (measurableSet_generateFrom (Set.mem_singleton t)) (measurableSet_generateFrom (Set.mem_singleton t)) filter_upwards [h_indep] with a ha by_cases h0 : κ a t = 0 · exact Or.inl h0 by_cases h_top : κ a t = ∞ · exact Or.inr (Or.inr h_top) rw [← one_mul (κ a (t ∩ t)), Set.inter_self, ENNReal.mul_eq_mul_right h0 h_top] at ha exact Or.inr (Or.inl ha.symm) theorem measure_eq_zero_or_one_or_top_of_indepSet_self {t : Set Ω} (h_indep : IndepSet t t μ) : μ t = 0 ∨ μ t = 1 ∨ μ t = ∞ := by simpa only [ae_dirac_eq, Filter.eventually_pure] using kernel.measure_eq_zero_or_one_or_top_of_indepSet_self h_indep #align probability_theory.measure_eq_zero_or_one_or_top_of_indep_set_self ProbabilityTheory.measure_eq_zero_or_one_or_top_of_indepSet_self theorem kernel.measure_eq_zero_or_one_of_indepSet_self [∀ a, IsFiniteMeasure (κ a)] {t : Set Ω} (h_indep : IndepSet t t κ μα) : ∀ᵐ a ∂μα, κ a t = 0 ∨ κ a t = 1 := by filter_upwards [measure_eq_zero_or_one_or_top_of_indepSet_self h_indep] with a h_0_1_top simpa only [measure_ne_top (κ a), or_false] using h_0_1_top theorem measure_eq_zero_or_one_of_indepSet_self [IsFiniteMeasure μ] {t : Set Ω} (h_indep : IndepSet t t μ) : μ t = 0 ∨ μ t = 1 := by simpa only [ae_dirac_eq, Filter.eventually_pure] using kernel.measure_eq_zero_or_one_of_indepSet_self h_indep #align probability_theory.measure_eq_zero_or_one_of_indep_set_self ProbabilityTheory.measure_eq_zero_or_one_of_indepSet_self
Mathlib/Probability/Independence/ZeroOne.lean
64
74
theorem condexp_eq_zero_or_one_of_condIndepSet_self [StandardBorelSpace Ω] [Nonempty Ω] (hm : m ≤ m0) [hμ : IsFiniteMeasure μ] {t : Set Ω} (ht : MeasurableSet t) (h_indep : CondIndepSet m hm t t μ) : ∀ᵐ ω ∂μ, (μ⟦t | m⟧) ω = 0 ∨ (μ⟦t | m⟧) ω = 1 := by
have h := ae_of_ae_trim hm (kernel.measure_eq_zero_or_one_of_indepSet_self h_indep) filter_upwards [condexpKernel_ae_eq_condexp hm ht, h] with ω hω_eq hω rw [← hω_eq, ENNReal.toReal_eq_zero_iff, ENNReal.toReal_eq_one_iff] cases hω with | inl h => exact Or.inl (Or.inl h) | inr h => exact Or.inr h
/- Copyright (c) 2023 Adrian Wüthrich. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adrian Wüthrich -/ import Mathlib.Combinatorics.SimpleGraph.AdjMatrix import Mathlib.LinearAlgebra.Matrix.PosDef /-! # Laplacian Matrix This module defines the Laplacian matrix of a graph, and proves some of its elementary properties. ## Main definitions & Results * `SimpleGraph.degMatrix`: The degree matrix of a simple graph * `SimpleGraph.lapMatrix`: The Laplacian matrix of a simple graph, defined as the difference between the degree matrix and the adjacency matrix. * `isPosSemidef_lapMatrix`: The Laplacian matrix is positive semidefinite. * `rank_ker_lapMatrix_eq_card_ConnectedComponent`: The number of connected components in `G` is the dimension of the nullspace of its Laplacian matrix. -/ open Finset Matrix namespace SimpleGraph variable {V : Type*} (R : Type*) variable [Fintype V] [DecidableEq V] (G : SimpleGraph V) [DecidableRel G.Adj] /-- The diagonal matrix consisting of the degrees of the vertices in the graph. -/ def degMatrix [AddMonoidWithOne R] : Matrix V V R := Matrix.diagonal (G.degree ·) /-- The *Laplacian matrix* `lapMatrix G R` of a graph `G` is the matrix `L = D - A` where `D` is the degree and `A` the adjacency matrix of `G`. -/ def lapMatrix [AddGroupWithOne R] : Matrix V V R := G.degMatrix R - G.adjMatrix R variable {R} theorem isSymm_degMatrix [AddMonoidWithOne R] : (G.degMatrix R).IsSymm := isSymm_diagonal _ theorem isSymm_lapMatrix [AddGroupWithOne R] : (G.lapMatrix R).IsSymm := (isSymm_degMatrix _).sub (isSymm_adjMatrix _) theorem degMatrix_mulVec_apply [NonAssocSemiring R] (v : V) (vec : V → R) : (G.degMatrix R *ᵥ vec) v = G.degree v * vec v := by rw [degMatrix, mulVec_diagonal] theorem lapMatrix_mulVec_apply [NonAssocRing R] (v : V) (vec : V → R) : (G.lapMatrix R *ᵥ vec) v = G.degree v * vec v - ∑ u ∈ G.neighborFinset v, vec u := by simp_rw [lapMatrix, sub_mulVec, Pi.sub_apply, degMatrix_mulVec_apply, adjMatrix_mulVec_apply] theorem lapMatrix_mulVec_const_eq_zero [Ring R] : mulVec (G.lapMatrix R) (fun _ ↦ 1) = 0 := by ext1 i rw [lapMatrix_mulVec_apply] simp theorem dotProduct_mulVec_degMatrix [CommRing R] (x : V → R) : x ⬝ᵥ (G.degMatrix R *ᵥ x) = ∑ i : V, G.degree i * x i * x i := by simp only [dotProduct, degMatrix, mulVec_diagonal, ← mul_assoc, mul_comm] variable (R) theorem degree_eq_sum_if_adj [AddCommMonoidWithOne R] (i : V) : (G.degree i : R) = ∑ j : V, if G.Adj i j then 1 else 0 := by unfold degree neighborFinset neighborSet rw [sum_boole, Set.toFinset_setOf] /-- Let $L$ be the graph Laplacian and let $x \in \mathbb{R}$, then $$x^{\top} L x = \sum_{i \sim j} (x_{i}-x_{j})^{2}$$, where $\sim$ denotes the adjacency relation -/ theorem lapMatrix_toLinearMap₂' [Field R] [CharZero R] (x : V → R) : toLinearMap₂' (G.lapMatrix R) x x = (∑ i : V, ∑ j : V, if G.Adj i j then (x i - x j)^2 else 0) / 2 := by simp_rw [toLinearMap₂'_apply', lapMatrix, sub_mulVec, dotProduct_sub, dotProduct_mulVec_degMatrix, dotProduct_mulVec_adjMatrix, ← sum_sub_distrib, degree_eq_sum_if_adj, sum_mul, ite_mul, one_mul, zero_mul, ← sum_sub_distrib, ite_sub_ite, sub_zero] rw [← half_add_self (∑ x_1 : V, ∑ x_2 : V, _)] conv_lhs => enter [1,2,2,i,2,j]; rw [if_congr (adj_comm G i j) rfl rfl] conv_lhs => enter [1,2]; rw [Finset.sum_comm] simp_rw [← sum_add_distrib, ite_add_ite] congr 2 with i congr 2 with j ring_nf /-- The Laplacian matrix is positive semidefinite -/ theorem posSemidef_lapMatrix [LinearOrderedField R] [StarRing R] [StarOrderedRing R] [TrivialStar R] : PosSemidef (G.lapMatrix R) := by constructor · rw [IsHermitian, conjTranspose_eq_transpose_of_trivial, isSymm_lapMatrix] · intro x rw [star_trivial, ← toLinearMap₂'_apply', lapMatrix_toLinearMap₂'] positivity theorem lapMatrix_toLinearMap₂'_apply'_eq_zero_iff_forall_adj [LinearOrderedField R] (x : V → R) : Matrix.toLinearMap₂' (G.lapMatrix R) x x = 0 ↔ ∀ i j : V, G.Adj i j → x i = x j := by simp (disch := intros; positivity) [lapMatrix_toLinearMap₂', sum_eq_zero_iff_of_nonneg, sub_eq_zero]
Mathlib/Combinatorics/SimpleGraph/LapMatrix.lean
103
106
theorem lapMatrix_toLin'_apply_eq_zero_iff_forall_adj (x : V → ℝ) : Matrix.toLin' (G.lapMatrix ℝ) x = 0 ↔ ∀ i j : V, G.Adj i j → x i = x j := by
rw [← (posSemidef_lapMatrix ℝ G).toLinearMap₂'_zero_iff, star_trivial, lapMatrix_toLinearMap₂'_apply'_eq_zero_iff_forall_adj]
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Johannes Hölzl -/ import Mathlib.MeasureTheory.Constructions.BorelSpace.Order #align_import measure_theory.function.simple_func from "leanprover-community/mathlib"@"bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf" /-! # Simple functions A function `f` from a measurable space to any type is called *simple*, if every preimage `f ⁻¹' {x}` is measurable, and the range is finite. In this file, we define simple functions and establish their basic properties; and we construct a sequence of simple functions approximating an arbitrary Borel measurable function `f : α → ℝ≥0∞`. The theorem `Measurable.ennreal_induction` shows that in order to prove something for an arbitrary measurable function into `ℝ≥0∞`, it is sufficient to show that the property holds for (multiples of) characteristic functions and is closed under addition and supremum of increasing sequences of functions. -/ noncomputable section open Set hiding restrict restrict_apply open Filter ENNReal open Function (support) open scoped Classical open Topology NNReal ENNReal MeasureTheory namespace MeasureTheory variable {α β γ δ : Type*} /-- A function `f` from a measurable space to any type is called *simple*, if every preimage `f ⁻¹' {x}` is measurable, and the range is finite. This structure bundles a function with these properties. -/ structure SimpleFunc.{u, v} (α : Type u) [MeasurableSpace α] (β : Type v) where toFun : α → β measurableSet_fiber' : ∀ x, MeasurableSet (toFun ⁻¹' {x}) finite_range' : (Set.range toFun).Finite #align measure_theory.simple_func MeasureTheory.SimpleFunc #align measure_theory.simple_func.to_fun MeasureTheory.SimpleFunc.toFun #align measure_theory.simple_func.measurable_set_fiber' MeasureTheory.SimpleFunc.measurableSet_fiber' #align measure_theory.simple_func.finite_range' MeasureTheory.SimpleFunc.finite_range' local infixr:25 " →ₛ " => SimpleFunc namespace SimpleFunc section Measurable variable [MeasurableSpace α] attribute [coe] toFun instance instCoeFun : CoeFun (α →ₛ β) fun _ => α → β := ⟨toFun⟩ #align measure_theory.simple_func.has_coe_to_fun MeasureTheory.SimpleFunc.instCoeFun
Mathlib/MeasureTheory/Function/SimpleFunc.lean
66
67
theorem coe_injective ⦃f g : α →ₛ β⦄ (H : (f : α → β) = g) : f = g := by
cases f; cases g; congr
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.RingTheory.Algebraic import Mathlib.RingTheory.Localization.AtPrime import Mathlib.RingTheory.Localization.Integral #align_import ring_theory.ideal.over from "leanprover-community/mathlib"@"198cb64d5c961e1a8d0d3e219feb7058d5353861" /-! # Ideals over/under ideals This file concerns ideals lying over other ideals. Let `f : R →+* S` be a ring homomorphism (typically a ring extension), `I` an ideal of `R` and `J` an ideal of `S`. We say `J` lies over `I` (and `I` under `J`) if `I` is the `f`-preimage of `J`. This is expressed here by writing `I = J.comap f`. ## Implementation notes The proofs of the `comap_ne_bot` and `comap_lt_comap` families use an approach specific for their situation: we construct an element in `I.comap f` from the coefficients of a minimal polynomial. Once mathlib has more material on the localization at a prime ideal, the results can be proven using more general going-up/going-down theory. -/ variable {R : Type*} [CommRing R] namespace Ideal open Polynomial open Polynomial open Submodule section CommRing variable {S : Type*} [CommRing S] {f : R →+* S} {I J : Ideal S} theorem coeff_zero_mem_comap_of_root_mem_of_eval_mem {r : S} (hr : r ∈ I) {p : R[X]} (hp : p.eval₂ f r ∈ I) : p.coeff 0 ∈ I.comap f := by rw [← p.divX_mul_X_add, eval₂_add, eval₂_C, eval₂_mul, eval₂_X] at hp refine mem_comap.mpr ((I.add_mem_iff_right ?_).mp hp) exact I.mul_mem_left _ hr #align ideal.coeff_zero_mem_comap_of_root_mem_of_eval_mem Ideal.coeff_zero_mem_comap_of_root_mem_of_eval_mem theorem coeff_zero_mem_comap_of_root_mem {r : S} (hr : r ∈ I) {p : R[X]} (hp : p.eval₂ f r = 0) : p.coeff 0 ∈ I.comap f := coeff_zero_mem_comap_of_root_mem_of_eval_mem hr (hp.symm ▸ I.zero_mem) #align ideal.coeff_zero_mem_comap_of_root_mem Ideal.coeff_zero_mem_comap_of_root_mem
Mathlib/RingTheory/Ideal/Over.lean
56
70
theorem exists_coeff_ne_zero_mem_comap_of_non_zero_divisor_root_mem {r : S} (r_non_zero_divisor : ∀ {x}, x * r = 0 → x = 0) (hr : r ∈ I) {p : R[X]} : p ≠ 0 → p.eval₂ f r = 0 → ∃ i, p.coeff i ≠ 0 ∧ p.coeff i ∈ I.comap f := by
refine p.recOnHorner ?_ ?_ ?_ · intro h contradiction · intro p a coeff_eq_zero a_ne_zero _ _ hp refine ⟨0, ?_, coeff_zero_mem_comap_of_root_mem hr hp⟩ simp [coeff_eq_zero, a_ne_zero] · intro p p_nonzero ih _ hp rw [eval₂_mul, eval₂_X] at hp obtain ⟨i, hi, mem⟩ := ih p_nonzero (r_non_zero_divisor hp) refine ⟨i + 1, ?_, ?_⟩ · simp [hi, mem] · simpa [hi] using mem
/- 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.MeanValue #align_import analysis.calculus.extend_deriv from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Extending differentiability to the boundary We investigate how differentiable functions inside a set extend to differentiable functions on the boundary. For this, it suffices that the function and its derivative admit limits there. A general version of this statement is given in `has_fderiv_at_boundary_of_tendsto_fderiv`. One-dimensional versions, in which one wants to obtain differentiability at the left endpoint or the right endpoint of an interval, are given in `has_deriv_at_interval_left_endpoint_of_tendsto_deriv` and `has_deriv_at_interval_right_endpoint_of_tendsto_deriv`. These versions are formulated in terms of the one-dimensional derivative `deriv ℝ f`. -/ variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] open Filter Set Metric ContinuousLinearMap open scoped Topology attribute [local mono] Set.prod_mono /-- If a function `f` is differentiable in a convex open set and continuous on its closure, and its derivative converges to a limit `f'` at a point on the boundary, then `f` is differentiable there with derivative `f'`. -/
Mathlib/Analysis/Calculus/FDeriv/Extend.lean
37
106
theorem has_fderiv_at_boundary_of_tendsto_fderiv {f : E → F} {s : Set E} {x : E} {f' : E →L[ℝ] F} (f_diff : DifferentiableOn ℝ f s) (s_conv : Convex ℝ s) (s_open : IsOpen s) (f_cont : ∀ y ∈ closure s, ContinuousWithinAt f s y) (h : Tendsto (fun y => fderiv ℝ f y) (𝓝[s] x) (𝓝 f')) : HasFDerivWithinAt f f' (closure s) x := by
classical -- one can assume without loss of generality that `x` belongs to the closure of `s`, as the -- statement is empty otherwise by_cases hx : x ∉ closure s · rw [← closure_closure] at hx; exact hasFDerivWithinAt_of_nmem_closure hx push_neg at hx rw [HasFDerivWithinAt, hasFDerivAtFilter_iff_isLittleO, Asymptotics.isLittleO_iff] /- One needs to show that `‖f y - f x - f' (y - x)‖ ≤ ε ‖y - x‖` for `y` close to `x` in `closure s`, where `ε` is an arbitrary positive constant. By continuity of the functions, it suffices to prove this for nearby points inside `s`. In a neighborhood of `x`, the derivative of `f` is arbitrarily close to `f'` by assumption. The mean value inequality completes the proof. -/ intro ε ε_pos obtain ⟨δ, δ_pos, hδ⟩ : ∃ δ > 0, ∀ y ∈ s, dist y x < δ → ‖fderiv ℝ f y - f'‖ < ε := by simpa [dist_zero_right] using tendsto_nhdsWithin_nhds.1 h ε ε_pos set B := ball x δ suffices ∀ y ∈ B ∩ closure s, ‖f y - f x - (f' y - f' x)‖ ≤ ε * ‖y - x‖ from mem_nhdsWithin_iff.2 ⟨δ, δ_pos, fun y hy => by simpa using this y hy⟩ suffices ∀ p : E × E, p ∈ closure ((B ∩ s) ×ˢ (B ∩ s)) → ‖f p.2 - f p.1 - (f' p.2 - f' p.1)‖ ≤ ε * ‖p.2 - p.1‖ by rw [closure_prod_eq] at this intro y y_in apply this ⟨x, y⟩ have : B ∩ closure s ⊆ closure (B ∩ s) := isOpen_ball.inter_closure exact ⟨this ⟨mem_ball_self δ_pos, hx⟩, this y_in⟩ have key : ∀ p : E × E, p ∈ (B ∩ s) ×ˢ (B ∩ s) → ‖f p.2 - f p.1 - (f' p.2 - f' p.1)‖ ≤ ε * ‖p.2 - p.1‖ := by rintro ⟨u, v⟩ ⟨u_in, v_in⟩ have conv : Convex ℝ (B ∩ s) := (convex_ball _ _).inter s_conv have diff : DifferentiableOn ℝ f (B ∩ s) := f_diff.mono inter_subset_right have bound : ∀ z ∈ B ∩ s, ‖fderivWithin ℝ f (B ∩ s) z - f'‖ ≤ ε := by intro z z_in have h := hδ z have : fderivWithin ℝ f (B ∩ s) z = fderiv ℝ f z := by have op : IsOpen (B ∩ s) := isOpen_ball.inter s_open rw [DifferentiableAt.fderivWithin _ (op.uniqueDiffOn z z_in)] exact (diff z z_in).differentiableAt (IsOpen.mem_nhds op z_in) rw [← this] at h exact le_of_lt (h z_in.2 z_in.1) simpa using conv.norm_image_sub_le_of_norm_fderivWithin_le' diff bound u_in v_in rintro ⟨u, v⟩ uv_in have f_cont' : ∀ y ∈ closure s, ContinuousWithinAt (f - ⇑f') s y := by intro y y_in exact Tendsto.sub (f_cont y y_in) f'.cont.continuousWithinAt refine ContinuousWithinAt.closure_le uv_in ?_ ?_ key all_goals -- common start for both continuity proofs have : (B ∩ s) ×ˢ (B ∩ s) ⊆ s ×ˢ s := by mono <;> exact inter_subset_right obtain ⟨u_in, v_in⟩ : u ∈ closure s ∧ v ∈ closure s := by simpa [closure_prod_eq] using closure_mono this uv_in apply ContinuousWithinAt.mono _ this simp only [ContinuousWithinAt] · rw [nhdsWithin_prod_eq] have : ∀ u v, f v - f u - (f' v - f' u) = f v - f' v - (f u - f' u) := by intros; abel simp only [this] exact Tendsto.comp continuous_norm.continuousAt ((Tendsto.comp (f_cont' v v_in) tendsto_snd).sub <| Tendsto.comp (f_cont' u u_in) tendsto_fst) · apply tendsto_nhdsWithin_of_tendsto_nhds rw [nhds_prod_eq] exact tendsto_const_nhds.mul (Tendsto.comp continuous_norm.continuousAt <| tendsto_snd.sub tendsto_fst)
/- 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, Johan Commelin, Mario Carneiro -/ import Mathlib.Algebra.MvPolynomial.Degrees #align_import data.mv_polynomial.variables from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Variables of polynomials This file establishes many results about the variable sets of a multivariate polynomial. The *variable set* of a polynomial $P \in R[X]$ is a `Finset` containing each $x \in X$ that appears in a monomial in $P$. ## Main declarations * `MvPolynomial.vars p` : the finset of variables occurring in `p`. For example if `p = x⁴y+yz` then `vars p = {x, y, z}` ## Notation As in other polynomial files, we typically use the notation: + `σ τ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `r : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` -/ noncomputable section open Set Function Finsupp AddMonoidAlgebra universe u v w variable {R : Type u} {S : Type v} namespace MvPolynomial variable {σ τ : Type*} {r : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ} section CommSemiring variable [CommSemiring R] {p q : MvPolynomial σ R} section Vars /-! ### `vars` -/ /-- `vars p` is the set of variables appearing in the polynomial `p` -/ def vars (p : MvPolynomial σ R) : Finset σ := letI := Classical.decEq σ p.degrees.toFinset #align mv_polynomial.vars MvPolynomial.vars theorem vars_def [DecidableEq σ] (p : MvPolynomial σ R) : p.vars = p.degrees.toFinset := by rw [vars] convert rfl #align mv_polynomial.vars_def MvPolynomial.vars_def @[simp] theorem vars_0 : (0 : MvPolynomial σ R).vars = ∅ := by classical rw [vars_def, degrees_zero, Multiset.toFinset_zero] #align mv_polynomial.vars_0 MvPolynomial.vars_0 @[simp] theorem vars_monomial (h : r ≠ 0) : (monomial s r).vars = s.support := by classical rw [vars_def, degrees_monomial_eq _ _ h, Finsupp.toFinset_toMultiset] #align mv_polynomial.vars_monomial MvPolynomial.vars_monomial @[simp] theorem vars_C : (C r : MvPolynomial σ R).vars = ∅ := by classical rw [vars_def, degrees_C, Multiset.toFinset_zero] set_option linter.uppercaseLean3 false in #align mv_polynomial.vars_C MvPolynomial.vars_C @[simp] theorem vars_X [Nontrivial R] : (X n : MvPolynomial σ R).vars = {n} := by rw [X, vars_monomial (one_ne_zero' R), Finsupp.support_single_ne_zero _ (one_ne_zero' ℕ)] set_option linter.uppercaseLean3 false in #align mv_polynomial.vars_X MvPolynomial.vars_X theorem mem_vars (i : σ) : i ∈ p.vars ↔ ∃ d ∈ p.support, i ∈ d.support := by classical simp only [vars_def, Multiset.mem_toFinset, mem_degrees, mem_support_iff, exists_prop] #align mv_polynomial.mem_vars MvPolynomial.mem_vars theorem mem_support_not_mem_vars_zero {f : MvPolynomial σ R} {x : σ →₀ ℕ} (H : x ∈ f.support) {v : σ} (h : v ∉ vars f) : x v = 0 := by contrapose! h exact (mem_vars v).mpr ⟨x, H, Finsupp.mem_support_iff.mpr h⟩ #align mv_polynomial.mem_support_not_mem_vars_zero MvPolynomial.mem_support_not_mem_vars_zero theorem vars_add_subset [DecidableEq σ] (p q : MvPolynomial σ R) : (p + q).vars ⊆ p.vars ∪ q.vars := by intro x hx simp only [vars_def, Finset.mem_union, Multiset.mem_toFinset] at hx ⊢ simpa using Multiset.mem_of_le (degrees_add _ _) hx #align mv_polynomial.vars_add_subset MvPolynomial.vars_add_subset theorem vars_add_of_disjoint [DecidableEq σ] (h : Disjoint p.vars q.vars) : (p + q).vars = p.vars ∪ q.vars := by refine (vars_add_subset p q).antisymm fun x hx => ?_ simp only [vars_def, Multiset.disjoint_toFinset] at h hx ⊢ rwa [degrees_add_of_disjoint h, Multiset.toFinset_union] #align mv_polynomial.vars_add_of_disjoint MvPolynomial.vars_add_of_disjoint section Mul
Mathlib/Algebra/MvPolynomial/Variables.lean
124
126
theorem vars_mul [DecidableEq σ] (φ ψ : MvPolynomial σ R) : (φ * ψ).vars ⊆ φ.vars ∪ ψ.vars := by
simp_rw [vars_def, ← Multiset.toFinset_add, Multiset.toFinset_subset] exact Multiset.subset_of_le (degrees_mul φ ψ)
/- Copyright (c) 2018 Andreas Swerdlow. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andreas Swerdlow, Kexing Ying -/ import Mathlib.Algebra.GroupWithZero.NonZeroDivisors import Mathlib.LinearAlgebra.BilinearForm.Properties /-! # Bilinear form This file defines orthogonal bilinear forms. ## Notations Given any term `B` of type `BilinForm`, due to a coercion, can use the notation `B x y` to refer to the function field, ie. `B x y = B.bilin x y`. In this file we use the following type variables: - `M`, `M'`, ... are modules over the commutative semiring `R`, - `M₁`, `M₁'`, ... are modules over the commutative ring `R₁`, - `V`, ... is a vector space over the field `K`. ## References * <https://en.wikipedia.org/wiki/Bilinear_form> ## Tags Bilinear form, -/ open LinearMap (BilinForm) universe u v w variable {R : Type*} {M : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M] variable {R₁ : Type*} {M₁ : Type*} [CommRing R₁] [AddCommGroup M₁] [Module R₁ M₁] variable {V : Type*} {K : Type*} [Field K] [AddCommGroup V] [Module K V] variable {B : BilinForm R M} {B₁ : BilinForm R₁ M₁} namespace LinearMap namespace BilinForm /-- The proposition that two elements of a bilinear form space are orthogonal. For orthogonality of an indexed set of elements, use `BilinForm.iIsOrtho`. -/ def IsOrtho (B : BilinForm R M) (x y : M) : Prop := B x y = 0 #align bilin_form.is_ortho LinearMap.BilinForm.IsOrtho theorem isOrtho_def {B : BilinForm R M} {x y : M} : B.IsOrtho x y ↔ B x y = 0 := Iff.rfl #align bilin_form.is_ortho_def LinearMap.BilinForm.isOrtho_def theorem isOrtho_zero_left (x : M) : IsOrtho B (0 : M) x := LinearMap.isOrtho_zero_left B x #align bilin_form.is_ortho_zero_left LinearMap.BilinForm.isOrtho_zero_left theorem isOrtho_zero_right (x : M) : IsOrtho B x (0 : M) := zero_right x #align bilin_form.is_ortho_zero_right LinearMap.BilinForm.isOrtho_zero_right theorem ne_zero_of_not_isOrtho_self {B : BilinForm K V} (x : V) (hx₁ : ¬B.IsOrtho x x) : x ≠ 0 := fun hx₂ => hx₁ (hx₂.symm ▸ isOrtho_zero_left _) #align bilin_form.ne_zero_of_not_is_ortho_self LinearMap.BilinForm.ne_zero_of_not_isOrtho_self theorem IsRefl.ortho_comm (H : B.IsRefl) {x y : M} : IsOrtho B x y ↔ IsOrtho B y x := ⟨eq_zero H, eq_zero H⟩ #align bilin_form.is_refl.ortho_comm LinearMap.BilinForm.IsRefl.ortho_comm theorem IsAlt.ortho_comm (H : B₁.IsAlt) {x y : M₁} : IsOrtho B₁ x y ↔ IsOrtho B₁ y x := LinearMap.IsAlt.ortho_comm H #align bilin_form.is_alt.ortho_comm LinearMap.BilinForm.IsAlt.ortho_comm theorem IsSymm.ortho_comm (H : B.IsSymm) {x y : M} : IsOrtho B x y ↔ IsOrtho B y x := LinearMap.IsSymm.ortho_comm H #align bilin_form.is_symm.ortho_comm LinearMap.BilinForm.IsSymm.ortho_comm /-- A set of vectors `v` is orthogonal with respect to some bilinear form `B` if and only if for all `i ≠ j`, `B (v i) (v j) = 0`. For orthogonality between two elements, use `BilinForm.IsOrtho` -/ def iIsOrtho {n : Type w} (B : BilinForm R M) (v : n → M) : Prop := B.IsOrthoᵢ v set_option linter.uppercaseLean3 false in #align bilin_form.is_Ortho LinearMap.BilinForm.iIsOrtho theorem iIsOrtho_def {n : Type w} {B : BilinForm R M} {v : n → M} : B.iIsOrtho v ↔ ∀ i j : n, i ≠ j → B (v i) (v j) = 0 := Iff.rfl set_option linter.uppercaseLean3 false in #align bilin_form.is_Ortho_def LinearMap.BilinForm.iIsOrtho_def section variable {R₄ M₄ : Type*} [CommRing R₄] [IsDomain R₄] variable [AddCommGroup M₄] [Module R₄ M₄] {G : BilinForm R₄ M₄} @[simp]
Mathlib/LinearAlgebra/BilinearForm/Orthogonal.lean
100
105
theorem isOrtho_smul_left {x y : M₄} {a : R₄} (ha : a ≠ 0) : IsOrtho G (a • x) y ↔ IsOrtho G x y := by
dsimp only [IsOrtho] rw [map_smul] simp only [LinearMap.smul_apply, smul_eq_mul, mul_eq_zero, or_iff_right_iff_imp] exact fun a ↦ (ha a).elim
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.Finset.Pi import Mathlib.Data.Fintype.Basic #align_import data.fintype.pi from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Fintype instances for pi types -/ variable {α : Type*} open Finset namespace Fintype variable [DecidableEq α] [Fintype α] {γ δ : α → Type*} {s : ∀ a, Finset (γ a)} /-- Given for all `a : α` a finset `t a` of `δ a`, then one can define the finset `Fintype.piFinset t` of all functions taking values in `t a` for all `a`. This is the analogue of `Finset.pi` where the base finset is `univ` (but formally they are not the same, as there is an additional condition `i ∈ Finset.univ` in the `Finset.pi` definition). -/ def piFinset (t : ∀ a, Finset (δ a)) : Finset (∀ a, δ a) := (Finset.univ.pi t).map ⟨fun f a => f a (mem_univ a), fun _ _ => by simp (config := {contextual := true}) [Function.funext_iff]⟩ #align fintype.pi_finset Fintype.piFinset @[simp]
Mathlib/Data/Fintype/Pi.lean
34
42
theorem mem_piFinset {t : ∀ a, Finset (δ a)} {f : ∀ a, δ a} : f ∈ piFinset t ↔ ∀ a, f a ∈ t a := by
constructor · simp only [piFinset, mem_map, and_imp, forall_prop_of_true, exists_prop, mem_univ, exists_imp, mem_pi] rintro g hg hgf a rw [← hgf] exact hg a · simp only [piFinset, mem_map, forall_prop_of_true, exists_prop, mem_univ, mem_pi] exact fun hf => ⟨fun a _ => f a, hf, rfl⟩
/- 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.Algebra.Squarefree.Basic import Mathlib.Data.Nat.Factorization.PrimePow #align_import data.nat.squarefree from "leanprover-community/mathlib"@"3c1368cac4abd5a5cbe44317ba7e87379d51ed88" /-! # Lemmas about squarefreeness of natural numbers A number is squarefree when it is not divisible by any squares except the squares of units. ## Main Results - `Nat.squarefree_iff_nodup_factors`: A positive natural number `x` is squarefree iff the list `factors x` has no duplicate factors. ## Tags squarefree, multiplicity -/ open Finset namespace Nat theorem squarefree_iff_nodup_factors {n : ℕ} (h0 : n ≠ 0) : Squarefree n ↔ n.factors.Nodup := by rw [UniqueFactorizationMonoid.squarefree_iff_nodup_normalizedFactors h0, Nat.factors_eq] simp #align nat.squarefree_iff_nodup_factors Nat.squarefree_iff_nodup_factors end Nat theorem Squarefree.nodup_factors {n : ℕ} (hn : Squarefree n) : n.factors.Nodup := (Nat.squarefree_iff_nodup_factors hn.ne_zero).mp hn namespace Nat variable {s : Finset ℕ} {m n p : ℕ} theorem squarefree_iff_prime_squarefree {n : ℕ} : Squarefree n ↔ ∀ x, Prime x → ¬x * x ∣ n := squarefree_iff_irreducible_sq_not_dvd_of_exists_irreducible ⟨_, prime_two⟩ #align nat.squarefree_iff_prime_squarefree Nat.squarefree_iff_prime_squarefree theorem _root_.Squarefree.natFactorization_le_one {n : ℕ} (p : ℕ) (hn : Squarefree n) : n.factorization p ≤ 1 := by rcases eq_or_ne n 0 with (rfl | hn') · simp rw [multiplicity.squarefree_iff_multiplicity_le_one] at hn by_cases hp : p.Prime · have := hn p simp only [multiplicity_eq_factorization hp hn', Nat.isUnit_iff, hp.ne_one, or_false_iff] at this exact mod_cast this · rw [factorization_eq_zero_of_non_prime _ hp] exact zero_le_one #align nat.squarefree.factorization_le_one Squarefree.natFactorization_le_one lemma factorization_eq_one_of_squarefree (hn : Squarefree n) (hp : p.Prime) (hpn : p ∣ n) : factorization n p = 1 := (hn.natFactorization_le_one _).antisymm <| (hp.dvd_iff_one_le_factorization hn.ne_zero).1 hpn theorem squarefree_of_factorization_le_one {n : ℕ} (hn : n ≠ 0) (hn' : ∀ p, n.factorization p ≤ 1) : Squarefree n := by rw [squarefree_iff_nodup_factors hn, List.nodup_iff_count_le_one] intro a rw [factors_count_eq] apply hn' #align nat.squarefree_of_factorization_le_one Nat.squarefree_of_factorization_le_one theorem squarefree_iff_factorization_le_one {n : ℕ} (hn : n ≠ 0) : Squarefree n ↔ ∀ p, n.factorization p ≤ 1 := ⟨fun hn => hn.natFactorization_le_one, squarefree_of_factorization_le_one hn⟩ #align nat.squarefree_iff_factorization_le_one Nat.squarefree_iff_factorization_le_one
Mathlib/Data/Nat/Squarefree.lean
76
91
theorem Squarefree.ext_iff {n m : ℕ} (hn : Squarefree n) (hm : Squarefree m) : n = m ↔ ∀ p, Prime p → (p ∣ n ↔ p ∣ m) := by
refine ⟨by rintro rfl; simp, fun h => eq_of_factorization_eq hn.ne_zero hm.ne_zero fun p => ?_⟩ by_cases hp : p.Prime · have h₁ := h _ hp rw [← not_iff_not, hp.dvd_iff_one_le_factorization hn.ne_zero, not_le, lt_one_iff, hp.dvd_iff_one_le_factorization hm.ne_zero, not_le, lt_one_iff] at h₁ have h₂ := hn.natFactorization_le_one p have h₃ := hm.natFactorization_le_one p rw [Nat.le_add_one_iff, Nat.le_zero] at h₂ h₃ cases' h₂ with h₂ h₂ · rwa [h₂, eq_comm, ← h₁] · rw [h₂, h₃.resolve_left] rw [← h₁, h₂] simp only [Nat.one_ne_zero, not_false_iff] rw [factorization_eq_zero_of_non_prime _ hp, factorization_eq_zero_of_non_prime _ hp]
/- 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, Johan Commelin, Mario Carneiro -/ import Mathlib.Algebra.MvPolynomial.Variables #align_import data.mv_polynomial.comm_ring from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Multivariate polynomials over a ring Many results about polynomials hold when the coefficient ring is a commutative semiring. Some stronger results can be derived when we assume this semiring is a ring. This file does not define any new operations, but proves some of these stronger results. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommRing R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` -/ noncomputable section open Set Function Finsupp AddMonoidAlgebra universe u v variable {R : Type u} {S : Type v} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ} section CommRing variable [CommRing R] variable {p q : MvPolynomial σ R} instance instCommRingMvPolynomial : CommRing (MvPolynomial σ R) := AddMonoidAlgebra.commRing variable (σ a a') -- @[simp] -- Porting note (#10618): simp can prove this theorem C_sub : (C (a - a') : MvPolynomial σ R) = C a - C a' := RingHom.map_sub _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.C_sub MvPolynomial.C_sub -- @[simp] -- Porting note (#10618): simp can prove this theorem C_neg : (C (-a) : MvPolynomial σ R) = -C a := RingHom.map_neg _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.C_neg MvPolynomial.C_neg @[simp] theorem coeff_neg (m : σ →₀ ℕ) (p : MvPolynomial σ R) : coeff m (-p) = -coeff m p := Finsupp.neg_apply _ _ #align mv_polynomial.coeff_neg MvPolynomial.coeff_neg @[simp] theorem coeff_sub (m : σ →₀ ℕ) (p q : MvPolynomial σ R) : coeff m (p - q) = coeff m p - coeff m q := Finsupp.sub_apply _ _ _ #align mv_polynomial.coeff_sub MvPolynomial.coeff_sub @[simp] theorem support_neg : (-p).support = p.support := Finsupp.support_neg p #align mv_polynomial.support_neg MvPolynomial.support_neg theorem support_sub [DecidableEq σ] (p q : MvPolynomial σ R) : (p - q).support ⊆ p.support ∪ q.support := Finsupp.support_sub #align mv_polynomial.support_sub MvPolynomial.support_sub variable {σ} (p) section Degrees
Mathlib/Algebra/MvPolynomial/CommRing.lean
96
97
theorem degrees_neg (p : MvPolynomial σ R) : (-p).degrees = p.degrees := by
rw [degrees, support_neg]; rfl
/- Copyright (c) 2022 David Kurniadi Angdinata. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Kurniadi Angdinata -/ import Mathlib.Algebra.Polynomial.Splits #align_import algebra.cubic_discriminant from "leanprover-community/mathlib"@"930133160e24036d5242039fe4972407cd4f1222" /-! # Cubics and discriminants This file defines cubic polynomials over a semiring and their discriminants over a splitting field. ## Main definitions * `Cubic`: the structure representing a cubic polynomial. * `Cubic.disc`: the discriminant of a cubic polynomial. ## Main statements * `Cubic.disc_ne_zero_iff_roots_nodup`: the cubic discriminant is not equal to zero if and only if the cubic has no duplicate roots. ## References * https://en.wikipedia.org/wiki/Cubic_equation * https://en.wikipedia.org/wiki/Discriminant ## Tags cubic, discriminant, polynomial, root -/ noncomputable section /-- The structure representing a cubic polynomial. -/ @[ext] structure Cubic (R : Type*) where (a b c d : R) #align cubic Cubic namespace Cubic open Cubic Polynomial open Polynomial variable {R S F K : Type*} instance [Inhabited R] : Inhabited (Cubic R) := ⟨⟨default, default, default, default⟩⟩ instance [Zero R] : Zero (Cubic R) := ⟨⟨0, 0, 0, 0⟩⟩ section Basic variable {P Q : Cubic R} {a b c d a' b' c' d' : R} [Semiring R] /-- Convert a cubic polynomial to a polynomial. -/ def toPoly (P : Cubic R) : R[X] := C P.a * X ^ 3 + C P.b * X ^ 2 + C P.c * X + C P.d #align cubic.to_poly Cubic.toPoly theorem C_mul_prod_X_sub_C_eq [CommRing S] {w x y z : S} : C w * (X - C x) * (X - C y) * (X - C z) = toPoly ⟨w, w * -(x + y + z), w * (x * y + x * z + y * z), w * -(x * y * z)⟩ := by simp only [toPoly, C_neg, C_add, C_mul] ring1 set_option linter.uppercaseLean3 false in #align cubic.C_mul_prod_X_sub_C_eq Cubic.C_mul_prod_X_sub_C_eq
Mathlib/Algebra/CubicDiscriminant.lean
75
78
theorem prod_X_sub_C_eq [CommRing S] {x y z : S} : (X - C x) * (X - C y) * (X - C z) = toPoly ⟨1, -(x + y + z), x * y + x * z + y * z, -(x * y * z)⟩ := by
rw [← one_mul <| X - C x, ← C_1, C_mul_prod_X_sub_C_eq, one_mul, one_mul, one_mul]
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov, Heather Macbeth -/ import Mathlib.Analysis.Convex.Cone.Extension import Mathlib.Analysis.NormedSpace.RCLike import Mathlib.Analysis.NormedSpace.Extend import Mathlib.Analysis.RCLike.Lemmas #align_import analysis.normed_space.hahn_banach.extension from "leanprover-community/mathlib"@"915591b2bb3ea303648db07284a161a7f2a9e3d4" /-! # Extension Hahn-Banach theorem In this file we prove the analytic Hahn-Banach theorem. For any continuous linear function on a subspace, we can extend it to a function on the entire space without changing its norm. We prove * `Real.exists_extension_norm_eq`: Hahn-Banach theorem for continuous linear functions on normed spaces over `ℝ`. * `exists_extension_norm_eq`: Hahn-Banach theorem for continuous linear functions on normed spaces over `ℝ` or `ℂ`. In order to state and prove the corollaries uniformly, we prove the statements for a field `𝕜` satisfying `RCLike 𝕜`. In this setting, `exists_dual_vector` states that, for any nonzero `x`, there exists a continuous linear form `g` of norm `1` with `g x = ‖x‖` (where the norm has to be interpreted as an element of `𝕜`). -/ universe u v namespace Real variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ℝ E] /-- **Hahn-Banach theorem** for continuous linear functions over `ℝ`. See also `exists_extension_norm_eq` in the root namespace for a more general version that works both for `ℝ` and `ℂ`. -/
Mathlib/Analysis/NormedSpace/HahnBanach/Extension.lean
44
59
theorem exists_extension_norm_eq (p : Subspace ℝ E) (f : p →L[ℝ] ℝ) : ∃ g : E →L[ℝ] ℝ, (∀ x : p, g x = f x) ∧ ‖g‖ = ‖f‖ := by
rcases exists_extension_of_le_sublinear ⟨p, f⟩ (fun x => ‖f‖ * ‖x‖) (fun c hc x => by simp only [norm_smul c x, Real.norm_eq_abs, abs_of_pos hc, mul_left_comm]) (fun x y => by -- Porting note: placeholder filled here rw [← left_distrib] exact mul_le_mul_of_nonneg_left (norm_add_le x y) (@norm_nonneg _ _ f)) fun x => le_trans (le_abs_self _) (f.le_opNorm _) with ⟨g, g_eq, g_le⟩ set g' := g.mkContinuous ‖f‖ fun x => abs_le.2 ⟨neg_le.1 <| g.map_neg x ▸ norm_neg x ▸ g_le (-x), g_le x⟩ refine ⟨g', g_eq, ?_⟩ apply le_antisymm (g.mkContinuous_norm_le (norm_nonneg f) _) refine f.opNorm_le_bound (norm_nonneg _) fun x => ?_ dsimp at g_eq rw [← g_eq] apply g'.le_opNorm
/- Copyright (c) 2024 Lean FRO LLC. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kim Morrison -/ import Mathlib.CategoryTheory.Monoidal.Mon_ import Mathlib.CategoryTheory.Monoidal.Braided.Opposite import Mathlib.CategoryTheory.Monoidal.Transport import Mathlib.CategoryTheory.Monoidal.CoherenceLemmas import Mathlib.CategoryTheory.Limits.Shapes.Terminal /-! # The category of comonoids in a monoidal category. We define comonoids in a monoidal category `C`, and show that they are equivalently monoid objects in the opposite category. We construct the monoidal structure on `Comon_ C`, when `C` is braided. An oplax monoidal functor takes comonoid objects to comonoid objects. That is, a oplax monoidal functor `F : C ⥤ D` induces a functor `Comon_ C ⥤ Comon_ D`. ## TODO * Comonoid objects in `C` are "just" oplax monoidal functors from the trivial monoidal category to `C`. -/ universe v₁ v₂ u₁ u₂ u open CategoryTheory MonoidalCategory variable (C : Type u₁) [Category.{v₁} C] [MonoidalCategory.{v₁} C] /-- A comonoid object internal to a monoidal category. When the monoidal category is preadditive, this is also sometimes called a "coalgebra object". -/ structure Comon_ where /-- The underlying object of a comonoid object. -/ X : C /-- The counit of a comonoid object. -/ counit : X ⟶ 𝟙_ C /-- The comultiplication morphism of a comonoid object. -/ comul : X ⟶ X ⊗ X counit_comul : comul ≫ (counit ▷ X) = (λ_ X).inv := by aesop_cat comul_counit : comul ≫ (X ◁ counit) = (ρ_ X).inv := by aesop_cat comul_assoc : comul ≫ (X ◁ comul) ≫ (α_ X X X).inv = comul ≫ (comul ▷ X) := by aesop_cat attribute [reassoc (attr := simp)] Comon_.counit_comul Comon_.comul_counit attribute [reassoc (attr := simp)] Comon_.comul_assoc namespace Comon_ /-- The trivial comonoid object. We later show this is terminal in `Comon_ C`. -/ @[simps] def trivial : Comon_ C where X := 𝟙_ C counit := 𝟙 _ comul := (λ_ _).inv comul_assoc := by coherence counit_comul := by coherence comul_counit := by coherence instance : Inhabited (Comon_ C) := ⟨trivial C⟩ variable {C} variable {M : Comon_ C} @[reassoc (attr := simp)]
Mathlib/CategoryTheory/Monoidal/Comon_.lean
73
74
theorem counit_comul_hom {Z : C} (f : M.X ⟶ Z) : M.comul ≫ (M.counit ⊗ f) = f ≫ (λ_ Z).inv := by
rw [leftUnitor_inv_naturality, tensorHom_def, counit_comul_assoc]
/- 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]
Mathlib/Algebra/Polynomial/Eval.lean
65
65
theorem eval₂_zero : (0 : R[X]).eval₂ f x = 0 := by
simp [eval₂_eq_sum]