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) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
import Mathlib.Data.Matrix.Basis
import Mathlib.LinearAlgebra.Basis
import Mathlib.LinearAlgebra.Pi
#align_import linear_algebra.std_basis from "leanprover-community/mathlib"@"13bce9a6b6c44f6b4c91ac1c1d2a816e2533d395"
/-!
# The standard basis
This file defines the standard basis `Pi.basis (s : ∀ j, Basis (ι j) R (M j))`,
which is the `Σ j, ι j`-indexed basis of `Π j, M j`. The basis vectors are given by
`Pi.basis s ⟨j, i⟩ j' = LinearMap.stdBasis R M j' (s j) i = if j = j' then s i else 0`.
The standard basis on `R^η`, i.e. `η → R` is called `Pi.basisFun`.
To give a concrete example, `LinearMap.stdBasis R (fun (i : Fin 3) ↦ R) i 1`
gives the `i`th unit basis vector in `R³`, and `Pi.basisFun R (Fin 3)` proves
this is a basis over `Fin 3 → R`.
## Main definitions
- `LinearMap.stdBasis R M`: if `x` is a basis vector of `M i`, then
`LinearMap.stdBasis R M i x` is the `i`th standard basis vector of `Π i, M i`.
- `Pi.basis s`: given a basis `s i` for each `M i`, the standard basis on `Π i, M i`
- `Pi.basisFun R η`: the standard basis on `R^η`, i.e. `η → R`, given by
`Pi.basisFun R η i j = if i = j then 1 else 0`.
- `Matrix.stdBasis R n m`: the standard basis on `Matrix n m R`, given by
`Matrix.stdBasis R n m (i, j) i' j' = if (i, j) = (i', j') then 1 else 0`.
-/
open Function Set Submodule
namespace LinearMap
variable (R : Type*) {ι : Type*} [Semiring R] (φ : ι → Type*) [∀ i, AddCommMonoid (φ i)]
[∀ i, Module R (φ i)] [DecidableEq ι]
/-- The standard basis of the product of `φ`. -/
def stdBasis : ∀ i : ι, φ i →ₗ[R] ∀ i, φ i :=
single
#align linear_map.std_basis LinearMap.stdBasis
theorem stdBasis_apply (i : ι) (b : φ i) : stdBasis R φ i b = update (0 : (a : ι) → φ a) i b :=
rfl
#align linear_map.std_basis_apply LinearMap.stdBasis_apply
@[simp]
theorem stdBasis_apply' (i i' : ι) : (stdBasis R (fun _x : ι => R) i) 1 i' = ite (i = i') 1 0 := by
rw [LinearMap.stdBasis_apply, Function.update_apply, Pi.zero_apply]
congr 1; rw [eq_iff_iff, eq_comm]
#align linear_map.std_basis_apply' LinearMap.stdBasis_apply'
theorem coe_stdBasis (i : ι) : ⇑(stdBasis R φ i) = Pi.single i :=
rfl
#align linear_map.coe_std_basis LinearMap.coe_stdBasis
@[simp]
theorem stdBasis_same (i : ι) (b : φ i) : stdBasis R φ i b i = b :=
Pi.single_eq_same i b
#align linear_map.std_basis_same LinearMap.stdBasis_same
theorem stdBasis_ne (i j : ι) (h : j ≠ i) (b : φ i) : stdBasis R φ i b j = 0 :=
Pi.single_eq_of_ne h b
#align linear_map.std_basis_ne LinearMap.stdBasis_ne
theorem stdBasis_eq_pi_diag (i : ι) : stdBasis R φ i = pi (diag i) := by
ext x j
-- Porting note: made types explicit
convert (update_apply (R := R) (φ := φ) (ι := ι) 0 x i j _).symm
rfl
#align linear_map.std_basis_eq_pi_diag LinearMap.stdBasis_eq_pi_diag
theorem ker_stdBasis (i : ι) : ker (stdBasis R φ i) = ⊥ :=
ker_eq_bot_of_injective <| Pi.single_injective _ _
#align linear_map.ker_std_basis LinearMap.ker_stdBasis
theorem proj_comp_stdBasis (i j : ι) : (proj i).comp (stdBasis R φ j) = diag j i := by
rw [stdBasis_eq_pi_diag, proj_pi]
#align linear_map.proj_comp_std_basis LinearMap.proj_comp_stdBasis
theorem proj_stdBasis_same (i : ι) : (proj i).comp (stdBasis R φ i) = id :=
LinearMap.ext <| stdBasis_same R φ i
#align linear_map.proj_std_basis_same LinearMap.proj_stdBasis_same
theorem proj_stdBasis_ne (i j : ι) (h : i ≠ j) : (proj i).comp (stdBasis R φ j) = 0 :=
LinearMap.ext <| stdBasis_ne R φ _ _ h
#align linear_map.proj_std_basis_ne LinearMap.proj_stdBasis_ne
| Mathlib/LinearAlgebra/StdBasis.lean | 96 | 103 | theorem iSup_range_stdBasis_le_iInf_ker_proj (I J : Set ι) (h : Disjoint I J) :
⨆ i ∈ I, range (stdBasis R φ i) ≤ ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) := by |
refine iSup_le fun i => iSup_le fun hi => range_le_iff_comap.2 ?_
simp only [← ker_comp, eq_top_iff, SetLike.le_def, mem_ker, comap_iInf, mem_iInf]
rintro b - j hj
rw [proj_stdBasis_ne R φ j i, zero_apply]
rintro rfl
exact h.le_bot ⟨hi, hj⟩
|
/-
Copyright (c) 2022 María Inés de Frutos-Fernández. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: María Inés de Frutos-Fernández
-/
import Mathlib.RingTheory.DedekindDomain.Ideal
#align_import ring_theory.dedekind_domain.factorization from "leanprover-community/mathlib"@"2f588be38bb5bec02f218ba14f82fc82eb663f87"
/-!
# Factorization of ideals and fractional ideals of Dedekind domains
Every nonzero ideal `I` of a Dedekind domain `R` can be factored as a product `∏_v v^{n_v}` over the
maximal ideals of `R`, where the exponents `n_v` are natural numbers.
Similarly, every nonzero fractional ideal `I` of a Dedekind domain `R` can be factored as a product
`∏_v v^{n_v}` over the maximal ideals of `R`, where the exponents `n_v` are integers. We define
`FractionalIdeal.count K v I` (abbreviated as `val_v(I)` in the documentation) to be `n_v`, and we
prove some of its properties. If `I = 0`, we define `val_v(I) = 0`.
## Main definitions
- `FractionalIdeal.count` : If `I` is a nonzero fractional ideal, `a ∈ R`, and `J` is an ideal of
`R` such that `I = a⁻¹J`, then we define `val_v(I)` as `(val_v(J) - val_v(a))`. If `I = 0`, we
set `val_v(I) = 0`.
## Main results
- `Ideal.finite_factors` : Only finitely many maximal ideals of `R` divide a given nonzero ideal.
- `Ideal.finprod_heightOneSpectrum_factorization` : The ideal `I` equals the finprod
`∏_v v^(val_v(I))`, where `val_v(I)` denotes the multiplicity of `v` in the factorization of `I`
and `v` runs over the maximal ideals of `R`.
- `FractionalIdeal.finprod_heightOneSpectrum_factorization` : If `I` is a nonzero fractional ideal,
`a ∈ R`, and `J` is an ideal of `R` such that `I = a⁻¹J`, then `I` is equal to the product
`∏_v v^(val_v(J) - val_v(a))`.
- `FractionalIdeal.finprod_heightOneSpectrum_factorization'` : If `I` is a nonzero fractional
ideal, then `I` is equal to the product `∏_v v^(val_v(I))`.
- `FractionalIdeal.finprod_heightOneSpectrum_factorization_principal` : For a nonzero `k = r/s ∈ K`,
the fractional ideal `(k)` is equal to the product `∏_v v^(val_v(r) - val_v(s))`.
- `FractionalIdeal.finite_factors` : If `I ≠ 0`, then `val_v(I) = 0` for all but finitely many
maximal ideals of `R`.
## Implementation notes
Since we are only interested in the factorization of nonzero fractional ideals, we define
`val_v(0) = 0` so that every `val_v` is in `ℤ` and we can avoid having to use `WithTop ℤ`.
## Tags
dedekind domain, fractional ideal, ideal, factorization
-/
noncomputable section
open scoped Classical nonZeroDivisors
open Set Function UniqueFactorizationMonoid IsDedekindDomain IsDedekindDomain.HeightOneSpectrum
Classical
variable {R : Type*} [CommRing R] {K : Type*} [Field K] [Algebra R K] [IsFractionRing R K]
/-! ### Factorization of ideals of Dedekind domains -/
variable [IsDedekindDomain R] (v : HeightOneSpectrum R)
/-- Given a maximal ideal `v` and an ideal `I` of `R`, `maxPowDividing` returns the maximal
power of `v` dividing `I`. -/
def IsDedekindDomain.HeightOneSpectrum.maxPowDividing (I : Ideal R) : Ideal R :=
v.asIdeal ^ (Associates.mk v.asIdeal).count (Associates.mk I).factors
#align is_dedekind_domain.height_one_spectrum.max_pow_dividing IsDedekindDomain.HeightOneSpectrum.maxPowDividing
/-- Only finitely many maximal ideals of `R` divide a given nonzero ideal. -/
| Mathlib/RingTheory/DedekindDomain/Factorization.lean | 68 | 76 | theorem Ideal.finite_factors {I : Ideal R} (hI : I ≠ 0) :
{v : HeightOneSpectrum R | v.asIdeal ∣ I}.Finite := by |
rw [← Set.finite_coe_iff, Set.coe_setOf]
haveI h_fin := fintypeSubtypeDvd I hI
refine
Finite.of_injective (fun v => (⟨(v : HeightOneSpectrum R).asIdeal, v.2⟩ : { x // x ∣ I })) ?_
intro v w hvw
simp? at hvw says simp only [Subtype.mk.injEq] at hvw
exact Subtype.coe_injective ((HeightOneSpectrum.ext_iff (R := R) ↑v ↑w).mpr hvw)
|
/-
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, Patrick Massot, Casper Putz, Anne Baanen
-/
import Mathlib.LinearAlgebra.Dual
import Mathlib.LinearAlgebra.Matrix.ToLin
#align_import linear_algebra.matrix.dual from "leanprover-community/mathlib"@"738c19f572805cff525a93aa4ffbdf232df05aa8"
/-!
# Dual space, linear maps and matrices.
This file contains some results on the matrix corresponding to the
transpose of a linear map (in the dual space).
## Tags
matrix, linear_map, transpose, dual
-/
open Matrix
section Transpose
variable {K V₁ V₂ ι₁ ι₂ : Type*} [Field K] [AddCommGroup V₁] [Module K V₁] [AddCommGroup V₂]
[Module K V₂] [Fintype ι₁] [Fintype ι₂] [DecidableEq ι₁] [DecidableEq ι₂] {B₁ : Basis ι₁ K V₁}
{B₂ : Basis ι₂ K V₂}
@[simp]
| Mathlib/LinearAlgebra/Matrix/Dual.lean | 32 | 37 | theorem LinearMap.toMatrix_transpose (u : V₁ →ₗ[K] V₂) :
LinearMap.toMatrix B₂.dualBasis B₁.dualBasis (Module.Dual.transpose (R := K) u) =
(LinearMap.toMatrix B₁ B₂ u)ᵀ := by |
ext i j
simp only [LinearMap.toMatrix_apply, Module.Dual.transpose_apply, B₁.dualBasis_repr,
B₂.dualBasis_apply, Matrix.transpose_apply, LinearMap.comp_apply]
|
/-
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
| Mathlib/Algebra/Module/Submodule/Ker.lean | 92 | 93 | 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
|
/-
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, Patrick Massot, Yury Kudryashov, Rémy Degenne
-/
import Mathlib.Order.Interval.Set.Basic
import Mathlib.Order.Hom.Set
#align_import data.set.intervals.order_iso from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105"
/-!
# Lemmas about images of intervals under order isomorphisms.
-/
open Set
namespace OrderIso
section Preorder
variable {α β : Type*} [Preorder α] [Preorder β]
@[simp]
theorem preimage_Iic (e : α ≃o β) (b : β) : e ⁻¹' Iic b = Iic (e.symm b) := by
ext x
simp [← e.le_iff_le]
#align order_iso.preimage_Iic OrderIso.preimage_Iic
@[simp]
theorem preimage_Ici (e : α ≃o β) (b : β) : e ⁻¹' Ici b = Ici (e.symm b) := by
ext x
simp [← e.le_iff_le]
#align order_iso.preimage_Ici OrderIso.preimage_Ici
@[simp]
theorem preimage_Iio (e : α ≃o β) (b : β) : e ⁻¹' Iio b = Iio (e.symm b) := by
ext x
simp [← e.lt_iff_lt]
#align order_iso.preimage_Iio OrderIso.preimage_Iio
@[simp]
theorem preimage_Ioi (e : α ≃o β) (b : β) : e ⁻¹' Ioi b = Ioi (e.symm b) := by
ext x
simp [← e.lt_iff_lt]
#align order_iso.preimage_Ioi OrderIso.preimage_Ioi
@[simp]
theorem preimage_Icc (e : α ≃o β) (a b : β) : e ⁻¹' Icc a b = Icc (e.symm a) (e.symm b) := by
simp [← Ici_inter_Iic]
#align order_iso.preimage_Icc OrderIso.preimage_Icc
@[simp]
theorem preimage_Ico (e : α ≃o β) (a b : β) : e ⁻¹' Ico a b = Ico (e.symm a) (e.symm b) := by
simp [← Ici_inter_Iio]
#align order_iso.preimage_Ico OrderIso.preimage_Ico
@[simp]
theorem preimage_Ioc (e : α ≃o β) (a b : β) : e ⁻¹' Ioc a b = Ioc (e.symm a) (e.symm b) := by
simp [← Ioi_inter_Iic]
#align order_iso.preimage_Ioc OrderIso.preimage_Ioc
@[simp]
| Mathlib/Order/Interval/Set/OrderIso.lean | 63 | 64 | theorem preimage_Ioo (e : α ≃o β) (a b : β) : e ⁻¹' Ioo a b = Ioo (e.symm a) (e.symm b) := by |
simp [← Ioi_inter_Iio]
|
/-
Copyright (c) 2021 Thomas Browning. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Thomas Browning, Jireh Loreaux
-/
import Mathlib.Algebra.Group.Center
#align_import group_theory.subsemigroup.centralizer from "leanprover-community/mathlib"@"cc67cd75b4e54191e13c2e8d722289a89e67e4fa"
/-!
# Centralizers of magmas and semigroups
## Main definitions
* `Set.centralizer`: the centralizer of a subset of a magma
* `Set.addCentralizer`: the centralizer of a subset of an additive magma
See `Mathlib.GroupTheory.Subsemigroup.Centralizer` for the definition of the centralizer
as a subsemigroup:
* `Subsemigroup.centralizer`: the centralizer of a subset of a semigroup
* `AddSubsemigroup.centralizer`: the centralizer of a subset of an additive semigroup
We provide `Monoid.centralizer`, `AddMonoid.centralizer`, `Subgroup.centralizer`, and
`AddSubgroup.centralizer` in other files.
-/
variable {M : Type*} {S T : Set M}
namespace Set
variable (S)
/-- The centralizer of a subset of a magma. -/
@[to_additive addCentralizer " The centralizer of a subset of an additive magma. "]
def centralizer [Mul M] : Set M :=
{ c | ∀ m ∈ S, m * c = c * m }
#align set.centralizer Set.centralizer
#align set.add_centralizer Set.addCentralizer
variable {S}
@[to_additive mem_addCentralizer]
theorem mem_centralizer_iff [Mul M] {c : M} : c ∈ centralizer S ↔ ∀ m ∈ S, m * c = c * m :=
Iff.rfl
#align set.mem_centralizer_iff Set.mem_centralizer_iff
#align set.mem_add_centralizer Set.mem_addCentralizer
@[to_additive decidableMemAddCentralizer]
instance decidableMemCentralizer [Mul M] [∀ a : M, Decidable <| ∀ b ∈ S, b * a = a * b] :
DecidablePred (· ∈ centralizer S) := fun _ => decidable_of_iff' _ mem_centralizer_iff
#align set.decidable_mem_centralizer Set.decidableMemCentralizer
#align set.decidable_mem_add_centralizer Set.decidableMemAddCentralizer
variable (S)
@[to_additive (attr := simp) zero_mem_addCentralizer]
| Mathlib/Algebra/Group/Centralizer.lean | 58 | 59 | theorem one_mem_centralizer [MulOneClass M] : (1 : M) ∈ centralizer S := by |
simp [mem_centralizer_iff]
|
/-
Copyright (c) 2022 Yaël Dillies, Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies, Bhavik Mehta
-/
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Combinatorics.SimpleGraph.Basic
import Mathlib.Data.Rat.Cast.Order
import Mathlib.Order.Partition.Finpartition
import Mathlib.Tactic.GCongr
import Mathlib.Tactic.NormNum
import Mathlib.Tactic.Positivity
import Mathlib.Tactic.Ring
#align_import combinatorics.simple_graph.density from "leanprover-community/mathlib"@"a4ec43f53b0bd44c697bcc3f5a62edd56f269ef1"
/-!
# Edge density
This file defines the number and density of edges of a relation/graph.
## Main declarations
Between two finsets of vertices,
* `Rel.interedges`: Finset of edges of a relation.
* `Rel.edgeDensity`: Edge density of a relation.
* `SimpleGraph.interedges`: Finset of edges of a graph.
* `SimpleGraph.edgeDensity`: Edge density of a graph.
-/
open Finset
variable {𝕜 ι κ α β : Type*}
/-! ### Density of a relation -/
namespace Rel
section Asymmetric
variable [LinearOrderedField 𝕜] (r : α → β → Prop) [∀ a, DecidablePred (r a)] {s s₁ s₂ : Finset α}
{t t₁ t₂ : Finset β} {a : α} {b : β} {δ : 𝕜}
/-- Finset of edges of a relation between two finsets of vertices. -/
def interedges (s : Finset α) (t : Finset β) : Finset (α × β) :=
(s ×ˢ t).filter fun e ↦ r e.1 e.2
#align rel.interedges Rel.interedges
/-- Edge density of a relation between two finsets of vertices. -/
def edgeDensity (s : Finset α) (t : Finset β) : ℚ :=
(interedges r s t).card / (s.card * t.card)
#align rel.edge_density Rel.edgeDensity
variable {r}
theorem mem_interedges_iff {x : α × β} : x ∈ interedges r s t ↔ x.1 ∈ s ∧ x.2 ∈ t ∧ r x.1 x.2 := by
rw [interedges, mem_filter, Finset.mem_product, and_assoc]
#align rel.mem_interedges_iff Rel.mem_interedges_iff
theorem mk_mem_interedges_iff : (a, b) ∈ interedges r s t ↔ a ∈ s ∧ b ∈ t ∧ r a b :=
mem_interedges_iff
#align rel.mk_mem_interedges_iff Rel.mk_mem_interedges_iff
@[simp]
theorem interedges_empty_left (t : Finset β) : interedges r ∅ t = ∅ := by
rw [interedges, Finset.empty_product, filter_empty]
#align rel.interedges_empty_left Rel.interedges_empty_left
theorem interedges_mono (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁) : interedges r s₂ t₂ ⊆ interedges r s₁ t₁ :=
fun x ↦ by
simp_rw [mem_interedges_iff]
exact fun h ↦ ⟨hs h.1, ht h.2.1, h.2.2⟩
#align rel.interedges_mono Rel.interedges_mono
variable (r)
theorem card_interedges_add_card_interedges_compl (s : Finset α) (t : Finset β) :
(interedges r s t).card + (interedges (fun x y ↦ ¬r x y) s t).card = s.card * t.card := by
classical
rw [← card_product, interedges, interedges, ← card_union_of_disjoint, filter_union_filter_neg_eq]
exact disjoint_filter.2 fun _ _ ↦ Classical.not_not.2
#align rel.card_interedges_add_card_interedges_compl Rel.card_interedges_add_card_interedges_compl
theorem interedges_disjoint_left {s s' : Finset α} (hs : Disjoint s s') (t : Finset β) :
Disjoint (interedges r s t) (interedges r s' t) := by
rw [Finset.disjoint_left] at hs ⊢
intro _ hx hy
rw [mem_interedges_iff] at hx hy
exact hs hx.1 hy.1
#align rel.interedges_disjoint_left Rel.interedges_disjoint_left
theorem interedges_disjoint_right (s : Finset α) {t t' : Finset β} (ht : Disjoint t t') :
Disjoint (interedges r s t) (interedges r s t') := by
rw [Finset.disjoint_left] at ht ⊢
intro _ hx hy
rw [mem_interedges_iff] at hx hy
exact ht hx.2.1 hy.2.1
#align rel.interedges_disjoint_right Rel.interedges_disjoint_right
section DecidableEq
variable [DecidableEq α] [DecidableEq β]
lemma interedges_eq_biUnion :
interedges r s t = s.biUnion (fun x ↦ (t.filter (r x)).map ⟨(x, ·), Prod.mk.inj_left x⟩) := by
ext ⟨x, y⟩; simp [mem_interedges_iff]
| Mathlib/Combinatorics/SimpleGraph/Density.lean | 109 | 112 | theorem interedges_biUnion_left (s : Finset ι) (t : Finset β) (f : ι → Finset α) :
interedges r (s.biUnion f) t = s.biUnion fun a ↦ interedges r (f a) t := by |
ext
simp only [mem_biUnion, mem_interedges_iff, exists_and_right, ← and_assoc]
|
/-
Copyright (c) 2024 Jiecheng Zhao. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jiecheng Zhao
-/
/-!
# Lemmas about `Array.extract`
Some useful lemmas about Array.extract
-/
set_option autoImplicit true
namespace Array
@[simp]
| Mathlib/Data/Array/ExtractLemmas.lean | 16 | 19 | theorem extract_eq_nil_of_start_eq_end {a : Array α} :
a.extract i i = #[] := by |
refine extract_empty_of_stop_le_start a ?h
exact Nat.le_refl i
|
/-
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.Data.List.OfFn
import Mathlib.Data.List.Nodup
import Mathlib.Data.List.Infix
#align_import data.list.sort from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
/-!
# Sorting algorithms on lists
In this file we define `List.Sorted r l` to be an alias for `List.Pairwise r l`.
This alias is preferred in the case that `r` is a `<` or `≤`-like relation.
Then we define two sorting algorithms:
`List.insertionSort` and `List.mergeSort`, and prove their correctness.
-/
open List.Perm
universe u
namespace List
/-!
### The predicate `List.Sorted`
-/
section Sorted
variable {α : Type u} {r : α → α → Prop} {a : α} {l : List α}
/-- `Sorted r l` is the same as `List.Pairwise r l`, preferred in the case that `r`
is a `<` or `≤`-like relation (transitive and antisymmetric or asymmetric) -/
def Sorted :=
@Pairwise
#align list.sorted List.Sorted
instance decidableSorted [DecidableRel r] (l : List α) : Decidable (Sorted r l) :=
List.instDecidablePairwise _
#align list.decidable_sorted List.decidableSorted
protected theorem Sorted.le_of_lt [Preorder α] {l : List α} (h : l.Sorted (· < ·)) :
l.Sorted (· ≤ ·) :=
h.imp le_of_lt
protected theorem Sorted.lt_of_le [PartialOrder α] {l : List α} (h₁ : l.Sorted (· ≤ ·))
(h₂ : l.Nodup) : l.Sorted (· < ·) :=
h₁.imp₂ (fun _ _ => lt_of_le_of_ne) h₂
protected theorem Sorted.ge_of_gt [Preorder α] {l : List α} (h : l.Sorted (· > ·)) :
l.Sorted (· ≥ ·) :=
h.imp le_of_lt
protected theorem Sorted.gt_of_ge [PartialOrder α] {l : List α} (h₁ : l.Sorted (· ≥ ·))
(h₂ : l.Nodup) : l.Sorted (· > ·) :=
h₁.imp₂ (fun _ _ => lt_of_le_of_ne) <| by simp_rw [ne_comm]; exact h₂
@[simp]
theorem sorted_nil : Sorted r [] :=
Pairwise.nil
#align list.sorted_nil List.sorted_nil
theorem Sorted.of_cons : Sorted r (a :: l) → Sorted r l :=
Pairwise.of_cons
#align list.sorted.of_cons List.Sorted.of_cons
theorem Sorted.tail {r : α → α → Prop} {l : List α} (h : Sorted r l) : Sorted r l.tail :=
Pairwise.tail h
#align list.sorted.tail List.Sorted.tail
theorem rel_of_sorted_cons {a : α} {l : List α} : Sorted r (a :: l) → ∀ b ∈ l, r a b :=
rel_of_pairwise_cons
#align list.rel_of_sorted_cons List.rel_of_sorted_cons
| Mathlib/Data/List/Sort.lean | 80 | 85 | theorem Sorted.head!_le [Inhabited α] [Preorder α] {a : α} {l : List α} (h : Sorted (· < ·) l)
(ha : a ∈ l) : l.head! ≤ a := by |
rw [← List.cons_head!_tail (List.ne_nil_of_mem ha)] at h ha
cases ha
· exact le_rfl
· exact le_of_lt (rel_of_sorted_cons h a (by assumption))
|
/-
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, Kevin Kappelmann
-/
import Mathlib.Algebra.Order.Floor
import Mathlib.Data.Rat.Cast.Order
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring
#align_import data.rat.floor from "leanprover-community/mathlib"@"e1bccd6e40ae78370f01659715d3c948716e3b7e"
/-!
# Floor Function for Rational Numbers
## Summary
We define the `FloorRing` instance on `ℚ`. Some technical lemmas relating `floor` to integer
division and modulo arithmetic are derived as well as some simple inequalities.
## Tags
rat, rationals, ℚ, floor
-/
open Int
namespace Rat
variable {α : Type*} [LinearOrderedField α] [FloorRing α]
protected theorem floor_def' (a : ℚ) : a.floor = a.num / a.den := by
rw [Rat.floor]
split
· next h => simp [h]
· next => rfl
protected theorem le_floor {z : ℤ} : ∀ {r : ℚ}, z ≤ Rat.floor r ↔ (z : ℚ) ≤ r
| ⟨n, d, h, c⟩ => by
simp only [Rat.floor_def']
rw [mk'_eq_divInt]
have h' := Int.ofNat_lt.2 (Nat.pos_of_ne_zero h)
conv =>
rhs
rw [intCast_eq_divInt, Rat.divInt_le_divInt zero_lt_one h', mul_one]
exact Int.le_ediv_iff_mul_le h'
#align rat.le_floor Rat.le_floor
instance : FloorRing ℚ :=
(FloorRing.ofFloor ℚ Rat.floor) fun _ _ => Rat.le_floor.symm
protected theorem floor_def {q : ℚ} : ⌊q⌋ = q.num / q.den := Rat.floor_def' q
#align rat.floor_def Rat.floor_def
theorem floor_int_div_nat_eq_div {n : ℤ} {d : ℕ} : ⌊(↑n : ℚ) / (↑d : ℚ)⌋ = n / (↑d : ℤ) := by
rw [Rat.floor_def]
obtain rfl | hd := @eq_zero_or_pos _ _ d
· simp
set q := (n : ℚ) / d with q_eq
obtain ⟨c, n_eq_c_mul_num, d_eq_c_mul_denom⟩ : ∃ c, n = c * q.num ∧ (d : ℤ) = c * q.den := by
rw [q_eq]
exact mod_cast @Rat.exists_eq_mul_div_num_and_eq_mul_div_den n d (mod_cast hd.ne')
rw [n_eq_c_mul_num, d_eq_c_mul_denom]
refine (Int.mul_ediv_mul_of_pos _ _ <| pos_of_mul_pos_left ?_ <| Int.natCast_nonneg q.den).symm
rwa [← d_eq_c_mul_denom, Int.natCast_pos]
#align rat.floor_int_div_nat_eq_div Rat.floor_int_div_nat_eq_div
@[simp, norm_cast]
theorem floor_cast (x : ℚ) : ⌊(x : α)⌋ = ⌊x⌋ :=
floor_eq_iff.2 (mod_cast floor_eq_iff.1 (Eq.refl ⌊x⌋))
#align rat.floor_cast Rat.floor_cast
@[simp, norm_cast]
theorem ceil_cast (x : ℚ) : ⌈(x : α)⌉ = ⌈x⌉ := by
rw [← neg_inj, ← floor_neg, ← floor_neg, ← Rat.cast_neg, Rat.floor_cast]
#align rat.ceil_cast Rat.ceil_cast
@[simp, norm_cast]
theorem round_cast (x : ℚ) : round (x : α) = round x := by
have : ((x + 1 / 2 : ℚ) : α) = x + 1 / 2 := by simp
rw [round_eq, round_eq, ← this, floor_cast]
#align rat.round_cast Rat.round_cast
@[simp, norm_cast]
theorem cast_fract (x : ℚ) : (↑(fract x) : α) = fract (x : α) := by
simp only [fract, cast_sub, cast_intCast, floor_cast]
#align rat.cast_fract Rat.cast_fract
end Rat
| Mathlib/Data/Rat/Floor.lean | 92 | 93 | theorem Int.mod_nat_eq_sub_mul_floor_rat_div {n : ℤ} {d : ℕ} : n % d = n - d * ⌊(n : ℚ) / d⌋ := by |
rw [eq_sub_of_add_eq <| Int.emod_add_ediv n d, Rat.floor_int_div_nat_eq_div]
|
/-
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.GroupPower.IterateHom
import Mathlib.Algebra.Polynomial.Eval
import Mathlib.GroupTheory.GroupAction.Ring
#align_import data.polynomial.derivative from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821"
/-!
# The derivative map on polynomials
## Main definitions
* `Polynomial.derivative`: The formal derivative of polynomials, expressed as a linear map.
-/
noncomputable section
open Finset
open Polynomial
namespace Polynomial
universe u v w y z
variable {R : Type u} {S : Type v} {T : Type w} {ι : Type y} {A : Type z} {a b : R} {n : ℕ}
section Derivative
section Semiring
variable [Semiring R]
/-- `derivative p` is the formal derivative of the polynomial `p` -/
def derivative : R[X] →ₗ[R] R[X] where
toFun p := p.sum fun n a => C (a * n) * X ^ (n - 1)
map_add' p q := by
dsimp only
rw [sum_add_index] <;>
simp only [add_mul, forall_const, RingHom.map_add, eq_self_iff_true, zero_mul,
RingHom.map_zero]
map_smul' a p := by
dsimp; rw [sum_smul_index] <;>
simp only [mul_sum, ← C_mul', mul_assoc, coeff_C_mul, RingHom.map_mul, forall_const, zero_mul,
RingHom.map_zero, sum]
#align polynomial.derivative Polynomial.derivative
theorem derivative_apply (p : R[X]) : derivative p = p.sum fun n a => C (a * n) * X ^ (n - 1) :=
rfl
#align polynomial.derivative_apply Polynomial.derivative_apply
theorem coeff_derivative (p : R[X]) (n : ℕ) :
coeff (derivative p) n = coeff p (n + 1) * (n + 1) := by
rw [derivative_apply]
simp only [coeff_X_pow, coeff_sum, coeff_C_mul]
rw [sum, Finset.sum_eq_single (n + 1)]
· simp only [Nat.add_succ_sub_one, add_zero, mul_one, if_true, eq_self_iff_true]; norm_cast
· intro b
cases b
· intros
rw [Nat.cast_zero, mul_zero, zero_mul]
· intro _ H
rw [Nat.add_one_sub_one, if_neg (mt (congr_arg Nat.succ) H.symm), mul_zero]
· rw [if_pos (add_tsub_cancel_right n 1).symm, mul_one, Nat.cast_add, Nat.cast_one,
mem_support_iff]
intro h
push_neg at h
simp [h]
#align polynomial.coeff_derivative Polynomial.coeff_derivative
-- Porting note (#10618): removed `simp`: `simp` can prove it.
theorem derivative_zero : derivative (0 : R[X]) = 0 :=
derivative.map_zero
#align polynomial.derivative_zero Polynomial.derivative_zero
theorem iterate_derivative_zero {k : ℕ} : derivative^[k] (0 : R[X]) = 0 :=
iterate_map_zero derivative k
#align polynomial.iterate_derivative_zero Polynomial.iterate_derivative_zero
@[simp]
theorem derivative_monomial (a : R) (n : ℕ) :
derivative (monomial n a) = monomial (n - 1) (a * n) := by
rw [derivative_apply, sum_monomial_index, C_mul_X_pow_eq_monomial]
simp
#align polynomial.derivative_monomial Polynomial.derivative_monomial
theorem derivative_C_mul_X (a : R) : derivative (C a * X) = C a := by
simp [C_mul_X_eq_monomial, derivative_monomial, Nat.cast_one, mul_one]
set_option linter.uppercaseLean3 false in
#align polynomial.derivative_C_mul_X Polynomial.derivative_C_mul_X
theorem derivative_C_mul_X_pow (a : R) (n : ℕ) :
derivative (C a * X ^ n) = C (a * n) * X ^ (n - 1) := by
rw [C_mul_X_pow_eq_monomial, C_mul_X_pow_eq_monomial, derivative_monomial]
set_option linter.uppercaseLean3 false in
#align polynomial.derivative_C_mul_X_pow Polynomial.derivative_C_mul_X_pow
theorem derivative_C_mul_X_sq (a : R) : derivative (C a * X ^ 2) = C (a * 2) * X := by
rw [derivative_C_mul_X_pow, Nat.cast_two, pow_one]
set_option linter.uppercaseLean3 false in
#align polynomial.derivative_C_mul_X_sq Polynomial.derivative_C_mul_X_sq
@[simp]
theorem derivative_X_pow (n : ℕ) : derivative (X ^ n : R[X]) = C (n : R) * X ^ (n - 1) := by
convert derivative_C_mul_X_pow (1 : R) n <;> simp
set_option linter.uppercaseLean3 false in
#align polynomial.derivative_X_pow Polynomial.derivative_X_pow
-- Porting note (#10618): removed `simp`: `simp` can prove it.
theorem derivative_X_sq : derivative (X ^ 2 : R[X]) = C 2 * X := by
rw [derivative_X_pow, Nat.cast_two, pow_one]
set_option linter.uppercaseLean3 false in
#align polynomial.derivative_X_sq Polynomial.derivative_X_sq
@[simp]
| Mathlib/Algebra/Polynomial/Derivative.lean | 121 | 121 | theorem derivative_C {a : R} : derivative (C a) = 0 := by | simp [derivative_apply]
|
/-
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.Data.Fintype.Basic
import Mathlib.ModelTheory.Substructures
#align_import model_theory.elementary_maps from "leanprover-community/mathlib"@"d11893b411025250c8e61ff2f12ccbd7ee35ab15"
/-!
# Elementary Maps Between First-Order Structures
## Main Definitions
* A `FirstOrder.Language.ElementaryEmbedding` is an embedding that commutes with the
realizations of formulas.
* The `FirstOrder.Language.elementaryDiagram` of a structure is the set of all sentences with
parameters that the structure satisfies.
* `FirstOrder.Language.ElementaryEmbedding.ofModelsElementaryDiagram` is the canonical
elementary embedding of any structure into a model of its elementary diagram.
## Main Results
* The Tarski-Vaught Test for embeddings: `FirstOrder.Language.Embedding.isElementary_of_exists`
gives a simple criterion for an embedding to be elementary.
-/
open FirstOrder
namespace FirstOrder
namespace Language
open Structure
variable (L : Language) (M : Type*) (N : Type*) {P : Type*} {Q : Type*}
variable [L.Structure M] [L.Structure N] [L.Structure P] [L.Structure Q]
/-- An elementary embedding of first-order structures is an embedding that commutes with the
realizations of formulas. -/
structure ElementaryEmbedding where
toFun : M → N
-- Porting note:
-- The autoparam here used to be `obviously`. We would like to replace it with `aesop`
-- but that isn't currently sufficient.
-- See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Aesop.20and.20cases
-- If that can be improved, we should change this to `by aesop` and remove the proofs below.
map_formula' :
∀ ⦃n⦄ (φ : L.Formula (Fin n)) (x : Fin n → M), φ.Realize (toFun ∘ x) ↔ φ.Realize x := by
intros; trivial
#align first_order.language.elementary_embedding FirstOrder.Language.ElementaryEmbedding
#align first_order.language.elementary_embedding.to_fun FirstOrder.Language.ElementaryEmbedding.toFun
#align first_order.language.elementary_embedding.map_formula' FirstOrder.Language.ElementaryEmbedding.map_formula'
@[inherit_doc FirstOrder.Language.ElementaryEmbedding]
scoped[FirstOrder] notation:25 A " ↪ₑ[" L "] " B => FirstOrder.Language.ElementaryEmbedding L A B
variable {L} {M} {N}
namespace ElementaryEmbedding
attribute [coe] toFun
instance instFunLike : FunLike (M ↪ₑ[L] N) M N where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
simp only [ElementaryEmbedding.mk.injEq]
ext x
exact Function.funext_iff.1 h x
#align first_order.language.elementary_embedding.fun_like FirstOrder.Language.ElementaryEmbedding.instFunLike
instance : CoeFun (M ↪ₑ[L] N) fun _ => M → N :=
DFunLike.hasCoeToFun
@[simp]
theorem map_boundedFormula (f : M ↪ₑ[L] N) {α : Type*} {n : ℕ} (φ : L.BoundedFormula α n)
(v : α → M) (xs : Fin n → M) : φ.Realize (f ∘ v) (f ∘ xs) ↔ φ.Realize v xs := by
classical
rw [← BoundedFormula.realize_restrictFreeVar Set.Subset.rfl, Set.inclusion_eq_id, iff_eq_eq]
have h :=
f.map_formula' ((φ.restrictFreeVar id).toFormula.relabel (Fintype.equivFin _))
(Sum.elim (v ∘ (↑)) xs ∘ (Fintype.equivFin _).symm)
simp only [Formula.realize_relabel, BoundedFormula.realize_toFormula, iff_eq_eq] at h
rw [← Function.comp.assoc _ _ (Fintype.equivFin _).symm,
Function.comp.assoc _ (Fintype.equivFin _).symm (Fintype.equivFin _),
_root_.Equiv.symm_comp_self, Function.comp_id, Function.comp.assoc, Sum.elim_comp_inl,
Function.comp.assoc _ _ Sum.inr, Sum.elim_comp_inr, ← Function.comp.assoc] at h
refine h.trans ?_
erw [Function.comp.assoc _ _ (Fintype.equivFin _), _root_.Equiv.symm_comp_self,
Function.comp_id, Sum.elim_comp_inl, Sum.elim_comp_inr (v ∘ Subtype.val) xs,
← Set.inclusion_eq_id (s := (BoundedFormula.freeVarFinset φ : Set α)) Set.Subset.rfl,
BoundedFormula.realize_restrictFreeVar Set.Subset.rfl]
#align first_order.language.elementary_embedding.map_bounded_formula FirstOrder.Language.ElementaryEmbedding.map_boundedFormula
@[simp]
theorem map_formula (f : M ↪ₑ[L] N) {α : Type*} (φ : L.Formula α) (x : α → M) :
φ.Realize (f ∘ x) ↔ φ.Realize x := by
rw [Formula.Realize, Formula.Realize, ← f.map_boundedFormula, Unique.eq_default (f ∘ default)]
#align first_order.language.elementary_embedding.map_formula FirstOrder.Language.ElementaryEmbedding.map_formula
theorem map_sentence (f : M ↪ₑ[L] N) (φ : L.Sentence) : M ⊨ φ ↔ N ⊨ φ := by
rw [Sentence.Realize, Sentence.Realize, ← f.map_formula, Unique.eq_default (f ∘ default)]
#align first_order.language.elementary_embedding.map_sentence FirstOrder.Language.ElementaryEmbedding.map_sentence
theorem theory_model_iff (f : M ↪ₑ[L] N) (T : L.Theory) : M ⊨ T ↔ N ⊨ T := by
simp only [Theory.model_iff, f.map_sentence]
set_option linter.uppercaseLean3 false in
#align first_order.language.elementary_embedding.Theory_model_iff FirstOrder.Language.ElementaryEmbedding.theory_model_iff
theorem elementarilyEquivalent (f : M ↪ₑ[L] N) : M ≅[L] N :=
elementarilyEquivalent_iff.2 f.map_sentence
#align first_order.language.elementary_embedding.elementarily_equivalent FirstOrder.Language.ElementaryEmbedding.elementarilyEquivalent
@[simp]
| Mathlib/ModelTheory/ElementaryMaps.lean | 117 | 124 | theorem injective (φ : M ↪ₑ[L] N) : Function.Injective φ := by |
intro x y
have h :=
φ.map_formula ((var 0).equal (var 1) : L.Formula (Fin 2)) fun i => if i = 0 then x else y
rw [Formula.realize_equal, Formula.realize_equal] at h
simp only [Nat.one_ne_zero, Term.realize, Fin.one_eq_zero_iff, if_true, eq_self_iff_true,
Function.comp_apply, if_false] at h
exact h.1
|
/-
Copyright (c) 2021 Frédéric Dupuis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Frédéric Dupuis
-/
import Mathlib.Analysis.Normed.Group.Hom
import Mathlib.Analysis.NormedSpace.Basic
import Mathlib.Analysis.NormedSpace.LinearIsometry
import Mathlib.Algebra.Star.SelfAdjoint
import Mathlib.Algebra.Star.Subalgebra
import Mathlib.Algebra.Star.Unitary
import Mathlib.Topology.Algebra.Module.Star
#align_import analysis.normed_space.star.basic from "leanprover-community/mathlib"@"aa6669832974f87406a3d9d70fc5707a60546207"
/-!
# Normed star rings and algebras
A normed star group is a normed group with a compatible `star` which is isometric.
A C⋆-ring is a normed star group that is also a ring and that verifies the stronger
condition `‖x⋆ * x‖ = ‖x‖^2` for all `x`. If a C⋆-ring is also a star algebra, then it is a
C⋆-algebra.
To get a C⋆-algebra `E` over field `𝕜`, use
`[NormedField 𝕜] [StarRing 𝕜] [NormedRing E] [StarRing E] [CstarRing E]
[NormedAlgebra 𝕜 E] [StarModule 𝕜 E]`.
## TODO
- Show that `‖x⋆ * x‖ = ‖x‖^2` is equivalent to `‖x⋆ * x‖ = ‖x⋆‖ * ‖x‖`, which is used as the
definition of C*-algebras in some sources (e.g. Wikipedia).
-/
open Topology
local postfix:max "⋆" => star
/-- A normed star group is a normed group with a compatible `star` which is isometric. -/
class NormedStarGroup (E : Type*) [SeminormedAddCommGroup E] [StarAddMonoid E] : Prop where
norm_star : ∀ x : E, ‖x⋆‖ = ‖x‖
#align normed_star_group NormedStarGroup
export NormedStarGroup (norm_star)
attribute [simp] norm_star
variable {𝕜 E α : Type*}
section NormedStarGroup
variable [SeminormedAddCommGroup E] [StarAddMonoid E] [NormedStarGroup E]
@[simp]
theorem nnnorm_star (x : E) : ‖star x‖₊ = ‖x‖₊ :=
Subtype.ext <| norm_star _
#align nnnorm_star nnnorm_star
/-- The `star` map in a normed star group is a normed group homomorphism. -/
def starNormedAddGroupHom : NormedAddGroupHom E E :=
{ starAddEquiv with bound' := ⟨1, fun _ => le_trans (norm_star _).le (one_mul _).symm.le⟩ }
#align star_normed_add_group_hom starNormedAddGroupHom
/-- The `star` map in a normed star group is an isometry -/
theorem star_isometry : Isometry (star : E → E) :=
show Isometry starAddEquiv from
AddMonoidHomClass.isometry_of_norm starAddEquiv (show ∀ x, ‖x⋆‖ = ‖x‖ from norm_star)
#align star_isometry star_isometry
instance (priority := 100) NormedStarGroup.to_continuousStar : ContinuousStar E :=
⟨star_isometry.continuous⟩
#align normed_star_group.to_has_continuous_star NormedStarGroup.to_continuousStar
end NormedStarGroup
instance RingHomIsometric.starRingEnd [NormedCommRing E] [StarRing E] [NormedStarGroup E] :
RingHomIsometric (starRingEnd E) :=
⟨@norm_star _ _ _ _⟩
#align ring_hom_isometric.star_ring_end RingHomIsometric.starRingEnd
/-- A C*-ring is a normed star ring that satisfies the stronger condition `‖x⋆ * x‖ = ‖x‖^2`
for every `x`. -/
class CstarRing (E : Type*) [NonUnitalNormedRing E] [StarRing E] : Prop where
norm_star_mul_self : ∀ {x : E}, ‖x⋆ * x‖ = ‖x‖ * ‖x‖
#align cstar_ring CstarRing
instance : CstarRing ℝ where norm_star_mul_self {x} := by simp only [star, id, norm_mul]
namespace CstarRing
section NonUnital
variable [NonUnitalNormedRing E] [StarRing E] [CstarRing E]
-- see Note [lower instance priority]
/-- In a C*-ring, star preserves the norm. -/
instance (priority := 100) to_normedStarGroup : NormedStarGroup E :=
⟨by
intro x
by_cases htriv : x = 0
· simp only [htriv, star_zero]
· have hnt : 0 < ‖x‖ := norm_pos_iff.mpr htriv
have hnt_star : 0 < ‖x⋆‖ :=
norm_pos_iff.mpr ((AddEquiv.map_ne_zero_iff starAddEquiv (M := E)).mpr htriv)
have h₁ :=
calc
‖x‖ * ‖x‖ = ‖x⋆ * x‖ := norm_star_mul_self.symm
_ ≤ ‖x⋆‖ * ‖x‖ := norm_mul_le _ _
have h₂ :=
calc
‖x⋆‖ * ‖x⋆‖ = ‖x * x⋆‖ := by rw [← norm_star_mul_self, star_star]
_ ≤ ‖x‖ * ‖x⋆‖ := norm_mul_le _ _
exact le_antisymm (le_of_mul_le_mul_right h₂ hnt_star) (le_of_mul_le_mul_right h₁ hnt)⟩
#align cstar_ring.to_normed_star_group CstarRing.to_normedStarGroup
theorem norm_self_mul_star {x : E} : ‖x * x⋆‖ = ‖x‖ * ‖x‖ := by
nth_rw 1 [← star_star x]
simp only [norm_star_mul_self, norm_star]
#align cstar_ring.norm_self_mul_star CstarRing.norm_self_mul_star
| Mathlib/Analysis/NormedSpace/Star/Basic.lean | 123 | 123 | theorem norm_star_mul_self' {x : E} : ‖x⋆ * x‖ = ‖x⋆‖ * ‖x‖ := by | rw [norm_star_mul_self, norm_star]
|
/-
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.Data.List.OfFn
import Mathlib.Data.List.Nodup
import Mathlib.Data.List.Infix
#align_import data.list.sort from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
/-!
# Sorting algorithms on lists
In this file we define `List.Sorted r l` to be an alias for `List.Pairwise r l`.
This alias is preferred in the case that `r` is a `<` or `≤`-like relation.
Then we define two sorting algorithms:
`List.insertionSort` and `List.mergeSort`, and prove their correctness.
-/
open List.Perm
universe u
namespace List
/-!
### The predicate `List.Sorted`
-/
section Sorted
variable {α : Type u} {r : α → α → Prop} {a : α} {l : List α}
/-- `Sorted r l` is the same as `List.Pairwise r l`, preferred in the case that `r`
is a `<` or `≤`-like relation (transitive and antisymmetric or asymmetric) -/
def Sorted :=
@Pairwise
#align list.sorted List.Sorted
instance decidableSorted [DecidableRel r] (l : List α) : Decidable (Sorted r l) :=
List.instDecidablePairwise _
#align list.decidable_sorted List.decidableSorted
protected theorem Sorted.le_of_lt [Preorder α] {l : List α} (h : l.Sorted (· < ·)) :
l.Sorted (· ≤ ·) :=
h.imp le_of_lt
protected theorem Sorted.lt_of_le [PartialOrder α] {l : List α} (h₁ : l.Sorted (· ≤ ·))
(h₂ : l.Nodup) : l.Sorted (· < ·) :=
h₁.imp₂ (fun _ _ => lt_of_le_of_ne) h₂
protected theorem Sorted.ge_of_gt [Preorder α] {l : List α} (h : l.Sorted (· > ·)) :
l.Sorted (· ≥ ·) :=
h.imp le_of_lt
protected theorem Sorted.gt_of_ge [PartialOrder α] {l : List α} (h₁ : l.Sorted (· ≥ ·))
(h₂ : l.Nodup) : l.Sorted (· > ·) :=
h₁.imp₂ (fun _ _ => lt_of_le_of_ne) <| by simp_rw [ne_comm]; exact h₂
@[simp]
theorem sorted_nil : Sorted r [] :=
Pairwise.nil
#align list.sorted_nil List.sorted_nil
theorem Sorted.of_cons : Sorted r (a :: l) → Sorted r l :=
Pairwise.of_cons
#align list.sorted.of_cons List.Sorted.of_cons
theorem Sorted.tail {r : α → α → Prop} {l : List α} (h : Sorted r l) : Sorted r l.tail :=
Pairwise.tail h
#align list.sorted.tail List.Sorted.tail
theorem rel_of_sorted_cons {a : α} {l : List α} : Sorted r (a :: l) → ∀ b ∈ l, r a b :=
rel_of_pairwise_cons
#align list.rel_of_sorted_cons List.rel_of_sorted_cons
theorem Sorted.head!_le [Inhabited α] [Preorder α] {a : α} {l : List α} (h : Sorted (· < ·) l)
(ha : a ∈ l) : l.head! ≤ a := by
rw [← List.cons_head!_tail (List.ne_nil_of_mem ha)] at h ha
cases ha
· exact le_rfl
· exact le_of_lt (rel_of_sorted_cons h a (by assumption))
theorem Sorted.le_head! [Inhabited α] [Preorder α] {a : α} {l : List α} (h : Sorted (· > ·) l)
(ha : a ∈ l) : a ≤ l.head! := by
rw [← List.cons_head!_tail (List.ne_nil_of_mem ha)] at h ha
cases ha
· exact le_rfl
· exact le_of_lt (rel_of_sorted_cons h a (by assumption))
@[simp]
theorem sorted_cons {a : α} {l : List α} : Sorted r (a :: l) ↔ (∀ b ∈ l, r a b) ∧ Sorted r l :=
pairwise_cons
#align list.sorted_cons List.sorted_cons
protected theorem Sorted.nodup {r : α → α → Prop} [IsIrrefl α r] {l : List α} (h : Sorted r l) :
Nodup l :=
Pairwise.nodup h
#align list.sorted.nodup List.Sorted.nodup
theorem eq_of_perm_of_sorted [IsAntisymm α r] {l₁ l₂ : List α} (hp : l₁ ~ l₂) (hs₁ : Sorted r l₁)
(hs₂ : Sorted r l₂) : l₁ = l₂ := by
induction' hs₁ with a l₁ h₁ hs₁ IH generalizing l₂
· exact hp.nil_eq
· have : a ∈ l₂ := hp.subset (mem_cons_self _ _)
rcases append_of_mem this with ⟨u₂, v₂, rfl⟩
have hp' := (perm_cons a).1 (hp.trans perm_middle)
obtain rfl := IH hp' (hs₂.sublist <| by simp)
change a :: u₂ ++ v₂ = u₂ ++ ([a] ++ v₂)
rw [← append_assoc]
congr
have : ∀ x ∈ u₂, x = a := fun x m =>
antisymm ((pairwise_append.1 hs₂).2.2 _ m a (mem_cons_self _ _)) (h₁ _ (by simp [m]))
rw [(@eq_replicate _ a (length u₂ + 1) (a :: u₂)).2,
(@eq_replicate _ a (length u₂ + 1) (u₂ ++ [a])).2] <;>
constructor <;>
simp [iff_true_intro this, or_comm]
#align list.eq_of_perm_of_sorted List.eq_of_perm_of_sorted
| Mathlib/Data/List/Sort.lean | 123 | 126 | theorem sublist_of_subperm_of_sorted [IsAntisymm α r] {l₁ l₂ : List α} (hp : l₁ <+~ l₂)
(hs₁ : l₁.Sorted r) (hs₂ : l₂.Sorted r) : l₁ <+ l₂ := by |
let ⟨_, h, h'⟩ := hp
rwa [← eq_of_perm_of_sorted h (hs₂.sublist h') hs₁]
|
/-
Copyright (c) 2020 Adam Topaz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Adam Topaz
-/
import Mathlib.Data.Finset.Basic
import Mathlib.Data.Set.Lattice
#align_import data.set.constructions from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
/-!
# Constructions involving sets of sets.
## Finite Intersections
We define a structure `FiniteInter` which asserts that a set `S` of subsets of `α` is
closed under finite intersections.
We define `finiteInterClosure` which, given a set `S` of subsets of `α`, is the smallest
set of subsets of `α` which is closed under finite intersections.
`finiteInterClosure S` is endowed with a term of type `FiniteInter` using
`finiteInterClosure_finiteInter`.
-/
variable {α : Type*} (S : Set (Set α))
/-- A structure encapsulating the fact that a set of sets is closed under finite intersection. -/
structure FiniteInter : Prop where
/-- `univ_mem` states that `Set.univ` is in `S`. -/
univ_mem : Set.univ ∈ S
/-- `inter_mem` states that any two intersections of sets in `S` is also in `S`. -/
inter_mem : ∀ ⦃s⦄, s ∈ S → ∀ ⦃t⦄, t ∈ S → s ∩ t ∈ S
#align has_finite_inter FiniteInter
namespace FiniteInter
/-- The smallest set of sets containing `S` which is closed under finite intersections. -/
inductive finiteInterClosure : Set (Set α)
| basic {s} : s ∈ S → finiteInterClosure s
| univ : finiteInterClosure Set.univ
| inter {s t} : finiteInterClosure s → finiteInterClosure t → finiteInterClosure (s ∩ t)
#align has_finite_inter.finite_inter_closure FiniteInter.finiteInterClosure
theorem finiteInterClosure_finiteInter : FiniteInter (finiteInterClosure S) :=
{ univ_mem := finiteInterClosure.univ
inter_mem := fun _ h _ => finiteInterClosure.inter h }
#align has_finite_inter.finite_inter_closure_has_finite_inter FiniteInter.finiteInterClosure_finiteInter
variable {S}
theorem finiteInter_mem (cond : FiniteInter S) (F : Finset (Set α)) :
↑F ⊆ S → ⋂₀ (↑F : Set (Set α)) ∈ S := by
classical
refine Finset.induction_on F (fun _ => ?_) ?_
· simp [cond.univ_mem]
· intro a s _ h1 h2
suffices a ∩ ⋂₀ ↑s ∈ S by simpa
exact
cond.inter_mem (h2 (Finset.mem_insert_self a s))
(h1 fun x hx => h2 <| Finset.mem_insert_of_mem hx)
#align has_finite_inter.finite_inter_mem FiniteInter.finiteInter_mem
| Mathlib/Data/Set/Constructions.lean | 66 | 82 | theorem finiteInterClosure_insert {A : Set α} (cond : FiniteInter S) (P)
(H : P ∈ finiteInterClosure (insert A S)) : P ∈ S ∨ ∃ Q ∈ S, P = A ∩ Q := by |
induction' H with S h T1 T2 _ _ h1 h2
· cases h
· exact Or.inr ⟨Set.univ, cond.univ_mem, by simpa⟩
· exact Or.inl (by assumption)
· exact Or.inl cond.univ_mem
· rcases h1 with (h | ⟨Q, hQ, rfl⟩) <;> rcases h2 with (i | ⟨R, hR, rfl⟩)
· exact Or.inl (cond.inter_mem h i)
· exact
Or.inr ⟨T1 ∩ R, cond.inter_mem h hR, by simp only [← Set.inter_assoc, Set.inter_comm _ A]⟩
· exact Or.inr ⟨Q ∩ T2, cond.inter_mem hQ i, by simp only [Set.inter_assoc]⟩
· exact
Or.inr
⟨Q ∩ R, cond.inter_mem hQ hR, by
ext x
constructor <;> simp (config := { contextual := true })⟩
|
/-
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.BoxIntegral.Partition.Basic
#align_import analysis.box_integral.partition.split from "leanprover-community/mathlib"@"6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f"
/-!
# Split a box along one or more hyperplanes
## Main definitions
A hyperplane `{x : ι → ℝ | x i = a}` splits a rectangular box `I : BoxIntegral.Box ι` into two
smaller boxes. If `a ∉ Ioo (I.lower i, I.upper i)`, then one of these boxes is empty, so it is not a
box in the sense of `BoxIntegral.Box`.
We introduce the following definitions.
* `BoxIntegral.Box.splitLower I i a` and `BoxIntegral.Box.splitUpper I i a` are these boxes (as
`WithBot (BoxIntegral.Box ι)`);
* `BoxIntegral.Prepartition.split I i a` is the partition of `I` made of these two boxes (or of one
box `I` if one of these boxes is empty);
* `BoxIntegral.Prepartition.splitMany I s`, where `s : Finset (ι × ℝ)` is a finite set of
hyperplanes `{x : ι → ℝ | x i = a}` encoded as pairs `(i, a)`, is the partition of `I` made by
cutting it along all the hyperplanes in `s`.
## Main results
The main result `BoxIntegral.Prepartition.exists_iUnion_eq_diff` says that any prepartition `π` of
`I` admits a prepartition `π'` of `I` that covers exactly `I \ π.iUnion`. One of these prepartitions
is available as `BoxIntegral.Prepartition.compl`.
## Tags
rectangular box, partition, hyperplane
-/
noncomputable section
open scoped Classical
open Filter
open Function Set Filter
namespace BoxIntegral
variable {ι M : Type*} {n : ℕ}
namespace Box
variable {I : Box ι} {i : ι} {x : ℝ} {y : ι → ℝ}
/-- Given a box `I` and `x ∈ (I.lower i, I.upper i)`, the hyperplane `{y : ι → ℝ | y i = x}` splits
`I` into two boxes. `BoxIntegral.Box.splitLower I i x` is the box `I ∩ {y | y i ≤ x}`
(if it is nonempty). As usual, we represent a box that may be empty as
`WithBot (BoxIntegral.Box ι)`. -/
def splitLower (I : Box ι) (i : ι) (x : ℝ) : WithBot (Box ι) :=
mk' I.lower (update I.upper i (min x (I.upper i)))
#align box_integral.box.split_lower BoxIntegral.Box.splitLower
@[simp]
theorem coe_splitLower : (splitLower I i x : Set (ι → ℝ)) = ↑I ∩ { y | y i ≤ x } := by
rw [splitLower, coe_mk']
ext y
simp only [mem_univ_pi, mem_Ioc, mem_inter_iff, mem_coe, mem_setOf_eq, forall_and, ← Pi.le_def,
le_update_iff, le_min_iff, and_assoc, and_forall_ne (p := fun j => y j ≤ upper I j) i, mem_def]
rw [and_comm (a := y i ≤ x)]
#align box_integral.box.coe_split_lower BoxIntegral.Box.coe_splitLower
theorem splitLower_le : I.splitLower i x ≤ I :=
withBotCoe_subset_iff.1 <| by simp
#align box_integral.box.split_lower_le BoxIntegral.Box.splitLower_le
@[simp]
theorem splitLower_eq_bot {i x} : I.splitLower i x = ⊥ ↔ x ≤ I.lower i := by
rw [splitLower, mk'_eq_bot, exists_update_iff I.upper fun j y => y ≤ I.lower j]
simp [(I.lower_lt_upper _).not_le]
#align box_integral.box.split_lower_eq_bot BoxIntegral.Box.splitLower_eq_bot
@[simp]
theorem splitLower_eq_self : I.splitLower i x = I ↔ I.upper i ≤ x := by
simp [splitLower, update_eq_iff]
#align box_integral.box.split_lower_eq_self BoxIntegral.Box.splitLower_eq_self
theorem splitLower_def [DecidableEq ι] {i x} (h : x ∈ Ioo (I.lower i) (I.upper i))
(h' : ∀ j, I.lower j < update I.upper i x j :=
(forall_update_iff I.upper fun j y => I.lower j < y).2
⟨h.1, fun j _ => I.lower_lt_upper _⟩) :
I.splitLower i x = (⟨I.lower, update I.upper i x, h'⟩ : Box ι) := by
simp (config := { unfoldPartialApp := true }) only [splitLower, mk'_eq_coe, min_eq_left h.2.le,
update, and_self]
#align box_integral.box.split_lower_def BoxIntegral.Box.splitLower_def
/-- Given a box `I` and `x ∈ (I.lower i, I.upper i)`, the hyperplane `{y : ι → ℝ | y i = x}` splits
`I` into two boxes. `BoxIntegral.Box.splitUpper I i x` is the box `I ∩ {y | x < y i}`
(if it is nonempty). As usual, we represent a box that may be empty as
`WithBot (BoxIntegral.Box ι)`. -/
def splitUpper (I : Box ι) (i : ι) (x : ℝ) : WithBot (Box ι) :=
mk' (update I.lower i (max x (I.lower i))) I.upper
#align box_integral.box.split_upper BoxIntegral.Box.splitUpper
@[simp]
| Mathlib/Analysis/BoxIntegral/Partition/Split.lean | 106 | 112 | theorem coe_splitUpper : (splitUpper I i x : Set (ι → ℝ)) = ↑I ∩ { y | x < y i } := by |
rw [splitUpper, coe_mk']
ext y
simp only [mem_univ_pi, mem_Ioc, mem_inter_iff, mem_coe, mem_setOf_eq, forall_and,
forall_update_iff I.lower fun j z => z < y j, max_lt_iff, and_assoc (a := x < y i),
and_forall_ne (p := fun j => lower I j < y j) i, mem_def]
exact and_comm
|
/-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau
-/
import Mathlib.Data.Int.Defs
import Mathlib.Data.Nat.Defs
import Mathlib.Tactic.Common
#align_import data.int.sqrt from "leanprover-community/mathlib"@"ba2245edf0c8bb155f1569fd9b9492a9b384cde6"
/-!
# Square root of integers
This file defines the square root function on integers. `Int.sqrt z` is the greatest integer `r`
such that `r * r ≤ z`. If `z ≤ 0`, then `Int.sqrt z = 0`.
-/
namespace Int
/-- `sqrt z` is the square root of an integer `z`. If `z` is positive, it returns the largest
integer `r` such that `r * r ≤ n`. If it is negative, it returns `0`. For example, `sqrt (-1) = 0`,
`sqrt 1 = 1`, `sqrt 2 = 1` -/
-- @[pp_nodot] porting note: unknown attribute
def sqrt (z : ℤ) : ℤ :=
Nat.sqrt <| Int.toNat z
#align int.sqrt Int.sqrt
| Mathlib/Data/Int/Sqrt.lean | 30 | 31 | theorem sqrt_eq (n : ℤ) : sqrt (n * n) = n.natAbs := by |
rw [sqrt, ← natAbs_mul_self, toNat_natCast, Nat.sqrt_eq]
|
/-
Copyright (c) 2023 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Algebra.BigOperators.Group.Finset
import Mathlib.Dynamics.FixedPoints.Basic
/-!
# Birkhoff sums
In this file we define `birkhoffSum f g n x` to be the sum `∑ k ∈ Finset.range n, g (f^[k] x)`.
This sum (more precisely, the corresponding average `n⁻¹ • birkhoffSum f g n x`)
appears in various ergodic theorems
saying that these averages converge to the "space average" `⨍ x, g x ∂μ` in some sense.
See also `birkhoffAverage` defined in `Dynamics/BirkhoffSum/Average`.
-/
open Finset Function
section AddCommMonoid
variable {α M : Type*} [AddCommMonoid M]
/-- The sum of values of `g` on the first `n` points of the orbit of `x` under `f`. -/
def birkhoffSum (f : α → α) (g : α → M) (n : ℕ) (x : α) : M := ∑ k ∈ range n, g (f^[k] x)
theorem birkhoffSum_zero (f : α → α) (g : α → M) (x : α) : birkhoffSum f g 0 x = 0 :=
sum_range_zero _
@[simp]
theorem birkhoffSum_zero' (f : α → α) (g : α → M) : birkhoffSum f g 0 = 0 :=
funext <| birkhoffSum_zero _ _
theorem birkhoffSum_one (f : α → α) (g : α → M) (x : α) : birkhoffSum f g 1 x = g x :=
sum_range_one _
@[simp]
theorem birkhoffSum_one' (f : α → α) (g : α → M) : birkhoffSum f g 1 = g :=
funext <| birkhoffSum_one f g
theorem birkhoffSum_succ (f : α → α) (g : α → M) (n : ℕ) (x : α) :
birkhoffSum f g (n + 1) x = birkhoffSum f g n x + g (f^[n] x) :=
sum_range_succ _ _
theorem birkhoffSum_succ' (f : α → α) (g : α → M) (n : ℕ) (x : α) :
birkhoffSum f g (n + 1) x = g x + birkhoffSum f g n (f x) :=
(sum_range_succ' _ _).trans (add_comm _ _)
theorem birkhoffSum_add (f : α → α) (g : α → M) (m n : ℕ) (x : α) :
birkhoffSum f g (m + n) x = birkhoffSum f g m x + birkhoffSum f g n (f^[m] x) := by
simp_rw [birkhoffSum, sum_range_add, add_comm m, iterate_add_apply]
| Mathlib/Dynamics/BirkhoffSum/Basic.lean | 55 | 57 | theorem Function.IsFixedPt.birkhoffSum_eq {f : α → α} {x : α} (h : IsFixedPt f x) (g : α → M)
(n : ℕ) : birkhoffSum f g n x = n • g x := by |
simp [birkhoffSum, (h.iterate _).eq]
|
/-
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, Floris van Doorn
-/
import Mathlib.Analysis.Calculus.ContDiff.Basic
import Mathlib.Analysis.NormedSpace.FiniteDimension
#align_import analysis.calculus.cont_diff from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
/-!
# Higher differentiability in finite dimensions.
-/
noncomputable section
universe uD uE uF uG
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {D : Type uD} [NormedAddCommGroup D]
[NormedSpace 𝕜 D] {E : Type uE} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type uF}
[NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type uG} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
/-! ### Finite dimensional results -/
section FiniteDimensional
open Function FiniteDimensional
variable [CompleteSpace 𝕜]
/-- A family of continuous linear maps is `C^n` on `s` if all its applications are. -/
theorem contDiffOn_clm_apply {n : ℕ∞} {f : E → F →L[𝕜] G} {s : Set E} [FiniteDimensional 𝕜 F] :
ContDiffOn 𝕜 n f s ↔ ∀ y, ContDiffOn 𝕜 n (fun x => f x y) s := by
refine ⟨fun h y => h.clm_apply contDiffOn_const, fun h => ?_⟩
let d := finrank 𝕜 F
have hd : d = finrank 𝕜 (Fin d → 𝕜) := (finrank_fin_fun 𝕜).symm
let e₁ := ContinuousLinearEquiv.ofFinrankEq hd
let e₂ := (e₁.arrowCongr (1 : G ≃L[𝕜] G)).trans (ContinuousLinearEquiv.piRing (Fin d))
rw [← id_comp f, ← e₂.symm_comp_self]
exact e₂.symm.contDiff.comp_contDiffOn (contDiffOn_pi.mpr fun i => h _)
#align cont_diff_on_clm_apply contDiffOn_clm_apply
theorem contDiff_clm_apply_iff {n : ℕ∞} {f : E → F →L[𝕜] G} [FiniteDimensional 𝕜 F] :
ContDiff 𝕜 n f ↔ ∀ y, ContDiff 𝕜 n fun x => f x y := by
simp_rw [← contDiffOn_univ, contDiffOn_clm_apply]
#align cont_diff_clm_apply_iff contDiff_clm_apply_iff
/-- This is a useful lemma to prove that a certain operation preserves functions being `C^n`.
When you do induction on `n`, this gives a useful characterization of a function being `C^(n+1)`,
assuming you have already computed the derivative. The advantage of this version over
`contDiff_succ_iff_fderiv` is that both occurrences of `ContDiff` are for functions with the same
domain and codomain (`E` and `F`). This is not the case for `contDiff_succ_iff_fderiv`, which
often requires an inconvenient need to generalize `F`, which results in universe issues
(see the discussion in the section of `ContDiff.comp`).
This lemma avoids these universe issues, but only applies for finite dimensional `E`. -/
theorem contDiff_succ_iff_fderiv_apply [FiniteDimensional 𝕜 E] {n : ℕ} {f : E → F} :
ContDiff 𝕜 (n + 1 : ℕ) f ↔ Differentiable 𝕜 f ∧ ∀ y, ContDiff 𝕜 n fun x => fderiv 𝕜 f x y := by
rw [contDiff_succ_iff_fderiv, contDiff_clm_apply_iff]
#align cont_diff_succ_iff_fderiv_apply contDiff_succ_iff_fderiv_apply
theorem contDiffOn_succ_of_fderiv_apply [FiniteDimensional 𝕜 E] {n : ℕ} {f : E → F} {s : Set E}
(hf : DifferentiableOn 𝕜 f s) (h : ∀ y, ContDiffOn 𝕜 n (fun x => fderivWithin 𝕜 f s x y) s) :
ContDiffOn 𝕜 (n + 1 : ℕ) f s :=
contDiffOn_succ_of_fderivWithin hf <| contDiffOn_clm_apply.mpr h
#align cont_diff_on_succ_of_fderiv_apply contDiffOn_succ_of_fderiv_apply
| Mathlib/Analysis/Calculus/ContDiff/FiniteDimension.lean | 71 | 75 | theorem contDiffOn_succ_iff_fderiv_apply [FiniteDimensional 𝕜 E] {n : ℕ} {f : E → F} {s : Set E}
(hs : UniqueDiffOn 𝕜 s) :
ContDiffOn 𝕜 (n + 1 : ℕ) f s ↔
DifferentiableOn 𝕜 f s ∧ ∀ y, ContDiffOn 𝕜 n (fun x => fderivWithin 𝕜 f s x y) s := by |
rw [contDiffOn_succ_iff_fderivWithin hs, contDiffOn_clm_apply]
|
/-
Copyright (c) 2021 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.Analysis.Normed.Group.Basic
#align_import analysis.normed.group.hom from "leanprover-community/mathlib"@"3c4225288b55380a90df078ebae0991080b12393"
/-!
# Normed groups homomorphisms
This file gathers definitions and elementary constructions about bounded group homomorphisms
between normed (abelian) groups (abbreviated to "normed group homs").
The main lemmas relate the boundedness condition to continuity and Lipschitzness.
The main construction is to endow the type of normed group homs between two given normed groups
with a group structure and a norm, giving rise to a normed group structure. We provide several
simple constructions for normed group homs, like kernel, range and equalizer.
Some easy other constructions are related to subgroups of normed groups.
Since a lot of elementary properties don't require `‖x‖ = 0 → x = 0` we start setting up the
theory of `SeminormedAddGroupHom` and we specialize to `NormedAddGroupHom` when needed.
-/
noncomputable section
open NNReal
-- TODO: migrate to the new morphism / morphism_class style
/-- A morphism of seminormed abelian groups is a bounded group homomorphism. -/
structure NormedAddGroupHom (V W : Type*) [SeminormedAddCommGroup V]
[SeminormedAddCommGroup W] where
/-- The function underlying a `NormedAddGroupHom` -/
toFun : V → W
/-- A `NormedAddGroupHom` is additive. -/
map_add' : ∀ v₁ v₂, toFun (v₁ + v₂) = toFun v₁ + toFun v₂
/-- A `NormedAddGroupHom` is bounded. -/
bound' : ∃ C, ∀ v, ‖toFun v‖ ≤ C * ‖v‖
#align normed_add_group_hom NormedAddGroupHom
namespace AddMonoidHom
variable {V W : Type*} [SeminormedAddCommGroup V] [SeminormedAddCommGroup W]
{f g : NormedAddGroupHom V W}
/-- Associate to a group homomorphism a bounded group homomorphism under a norm control condition.
See `AddMonoidHom.mkNormedAddGroupHom'` for a version that uses `ℝ≥0` for the bound. -/
def mkNormedAddGroupHom (f : V →+ W) (C : ℝ) (h : ∀ v, ‖f v‖ ≤ C * ‖v‖) : NormedAddGroupHom V W :=
{ f with bound' := ⟨C, h⟩ }
#align add_monoid_hom.mk_normed_add_group_hom AddMonoidHom.mkNormedAddGroupHom
/-- Associate to a group homomorphism a bounded group homomorphism under a norm control condition.
See `AddMonoidHom.mkNormedAddGroupHom` for a version that uses `ℝ` for the bound. -/
def mkNormedAddGroupHom' (f : V →+ W) (C : ℝ≥0) (hC : ∀ x, ‖f x‖₊ ≤ C * ‖x‖₊) :
NormedAddGroupHom V W :=
{ f with bound' := ⟨C, hC⟩ }
#align add_monoid_hom.mk_normed_add_group_hom' AddMonoidHom.mkNormedAddGroupHom'
end AddMonoidHom
theorem exists_pos_bound_of_bound {V W : Type*} [SeminormedAddCommGroup V]
[SeminormedAddCommGroup W] {f : V → W} (M : ℝ) (h : ∀ x, ‖f x‖ ≤ M * ‖x‖) :
∃ N, 0 < N ∧ ∀ x, ‖f x‖ ≤ N * ‖x‖ :=
⟨max M 1, lt_of_lt_of_le zero_lt_one (le_max_right _ _), fun x =>
calc
‖f x‖ ≤ M * ‖x‖ := h x
_ ≤ max M 1 * ‖x‖ := by gcongr; apply le_max_left
⟩
#align exists_pos_bound_of_bound exists_pos_bound_of_bound
namespace NormedAddGroupHom
variable {V V₁ V₂ V₃ : Type*} [SeminormedAddCommGroup V] [SeminormedAddCommGroup V₁]
[SeminormedAddCommGroup V₂] [SeminormedAddCommGroup V₃]
variable {f g : NormedAddGroupHom V₁ V₂}
/-- A Lipschitz continuous additive homomorphism is a normed additive group homomorphism. -/
def ofLipschitz (f : V₁ →+ V₂) {K : ℝ≥0} (h : LipschitzWith K f) : NormedAddGroupHom V₁ V₂ :=
f.mkNormedAddGroupHom K fun x ↦ by simpa only [map_zero, dist_zero_right] using h.dist_le_mul x 0
instance funLike : FunLike (NormedAddGroupHom V₁ V₂) V₁ V₂ where
coe := toFun
coe_injective' := fun f g h => by cases f; cases g; congr
-- Porting note: moved this declaration up so we could get a `FunLike` instance sooner.
instance toAddMonoidHomClass : AddMonoidHomClass (NormedAddGroupHom V₁ V₂) V₁ V₂ where
map_add f := f.map_add'
map_zero f := (AddMonoidHom.mk' f.toFun f.map_add').map_zero
initialize_simps_projections NormedAddGroupHom (toFun → apply)
| Mathlib/Analysis/Normed/Group/Hom.lean | 99 | 100 | theorem coe_inj (H : (f : V₁ → V₂) = g) : f = g := by |
cases f; cases g; congr
|
/-
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.Analysis.Complex.Basic
import Mathlib.Topology.FiberBundle.IsHomeomorphicTrivialBundle
#align_import analysis.complex.re_im_topology from "leanprover-community/mathlib"@"468b141b14016d54b479eb7a0fff1e360b7e3cf6"
/-!
# Closure, interior, and frontier of preimages under `re` and `im`
In this fact we use the fact that `ℂ` is naturally homeomorphic to `ℝ × ℝ` to deduce some
topological properties of `Complex.re` and `Complex.im`.
## Main statements
Each statement about `Complex.re` listed below has a counterpart about `Complex.im`.
* `Complex.isHomeomorphicTrivialFiberBundle_re`: `Complex.re` turns `ℂ` into a trivial
topological fiber bundle over `ℝ`;
* `Complex.isOpenMap_re`, `Complex.quotientMap_re`: in particular, `Complex.re` is an open map
and is a quotient map;
* `Complex.interior_preimage_re`, `Complex.closure_preimage_re`, `Complex.frontier_preimage_re`:
formulas for `interior (Complex.re ⁻¹' s)` etc;
* `Complex.interior_setOf_re_le` etc: particular cases of the above formulas in the cases when `s`
is one of the infinite intervals `Set.Ioi a`, `Set.Ici a`, `Set.Iio a`, and `Set.Iic a`,
formulated as `interior {z : ℂ | z.re ≤ a} = {z | z.re < a}` etc.
## Tags
complex, real part, imaginary part, closure, interior, frontier
-/
open Set
noncomputable section
namespace Complex
/-- `Complex.re` turns `ℂ` into a trivial topological fiber bundle over `ℝ`. -/
theorem isHomeomorphicTrivialFiberBundle_re : IsHomeomorphicTrivialFiberBundle ℝ re :=
⟨equivRealProdCLM.toHomeomorph, fun _ => rfl⟩
#align complex.is_homeomorphic_trivial_fiber_bundle_re Complex.isHomeomorphicTrivialFiberBundle_re
/-- `Complex.im` turns `ℂ` into a trivial topological fiber bundle over `ℝ`. -/
theorem isHomeomorphicTrivialFiberBundle_im : IsHomeomorphicTrivialFiberBundle ℝ im :=
⟨equivRealProdCLM.toHomeomorph.trans (Homeomorph.prodComm ℝ ℝ), fun _ => rfl⟩
#align complex.is_homeomorphic_trivial_fiber_bundle_im Complex.isHomeomorphicTrivialFiberBundle_im
theorem isOpenMap_re : IsOpenMap re :=
isHomeomorphicTrivialFiberBundle_re.isOpenMap_proj
#align complex.is_open_map_re Complex.isOpenMap_re
theorem isOpenMap_im : IsOpenMap im :=
isHomeomorphicTrivialFiberBundle_im.isOpenMap_proj
#align complex.is_open_map_im Complex.isOpenMap_im
theorem quotientMap_re : QuotientMap re :=
isHomeomorphicTrivialFiberBundle_re.quotientMap_proj
#align complex.quotient_map_re Complex.quotientMap_re
theorem quotientMap_im : QuotientMap im :=
isHomeomorphicTrivialFiberBundle_im.quotientMap_proj
#align complex.quotient_map_im Complex.quotientMap_im
theorem interior_preimage_re (s : Set ℝ) : interior (re ⁻¹' s) = re ⁻¹' interior s :=
(isOpenMap_re.preimage_interior_eq_interior_preimage continuous_re _).symm
#align complex.interior_preimage_re Complex.interior_preimage_re
theorem interior_preimage_im (s : Set ℝ) : interior (im ⁻¹' s) = im ⁻¹' interior s :=
(isOpenMap_im.preimage_interior_eq_interior_preimage continuous_im _).symm
#align complex.interior_preimage_im Complex.interior_preimage_im
theorem closure_preimage_re (s : Set ℝ) : closure (re ⁻¹' s) = re ⁻¹' closure s :=
(isOpenMap_re.preimage_closure_eq_closure_preimage continuous_re _).symm
#align complex.closure_preimage_re Complex.closure_preimage_re
theorem closure_preimage_im (s : Set ℝ) : closure (im ⁻¹' s) = im ⁻¹' closure s :=
(isOpenMap_im.preimage_closure_eq_closure_preimage continuous_im _).symm
#align complex.closure_preimage_im Complex.closure_preimage_im
theorem frontier_preimage_re (s : Set ℝ) : frontier (re ⁻¹' s) = re ⁻¹' frontier s :=
(isOpenMap_re.preimage_frontier_eq_frontier_preimage continuous_re _).symm
#align complex.frontier_preimage_re Complex.frontier_preimage_re
theorem frontier_preimage_im (s : Set ℝ) : frontier (im ⁻¹' s) = im ⁻¹' frontier s :=
(isOpenMap_im.preimage_frontier_eq_frontier_preimage continuous_im _).symm
#align complex.frontier_preimage_im Complex.frontier_preimage_im
@[simp]
theorem interior_setOf_re_le (a : ℝ) : interior { z : ℂ | z.re ≤ a } = { z | z.re < a } := by
simpa only [interior_Iic] using interior_preimage_re (Iic a)
#align complex.interior_set_of_re_le Complex.interior_setOf_re_le
@[simp]
theorem interior_setOf_im_le (a : ℝ) : interior { z : ℂ | z.im ≤ a } = { z | z.im < a } := by
simpa only [interior_Iic] using interior_preimage_im (Iic a)
#align complex.interior_set_of_im_le Complex.interior_setOf_im_le
@[simp]
| Mathlib/Analysis/Complex/ReImTopology.lean | 104 | 105 | theorem interior_setOf_le_re (a : ℝ) : interior { z : ℂ | a ≤ z.re } = { z | a < z.re } := by |
simpa only [interior_Ici] using interior_preimage_re (Ici a)
|
/-
Copyright (c) 2021 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.AlgebraicGeometry.AffineScheme
import Mathlib.RingTheory.Nilpotent.Lemmas
import Mathlib.Topology.Sheaves.SheafCondition.Sites
import Mathlib.Algebra.Category.Ring.Constructions
import Mathlib.RingTheory.LocalProperties
#align_import algebraic_geometry.properties from "leanprover-community/mathlib"@"88474d1b5af6d37c2ab728b757771bced7f5194c"
/-!
# Basic properties of schemes
We provide some basic properties of schemes
## Main definition
* `AlgebraicGeometry.IsIntegral`: A scheme is integral if it is nontrivial and all nontrivial
components of the structure sheaf are integral domains.
* `AlgebraicGeometry.IsReduced`: A scheme is reduced if all the components of the structure sheaf
are reduced.
-/
-- Explicit universe annotations were used in this file to improve perfomance #12737
universe u
open TopologicalSpace Opposite CategoryTheory CategoryTheory.Limits TopCat
namespace AlgebraicGeometry
variable (X : Scheme)
instance : T0Space X.carrier := by
refine T0Space.of_open_cover fun x => ?_
obtain ⟨U, R, ⟨e⟩⟩ := X.local_affine x
let e' : U.1 ≃ₜ PrimeSpectrum R :=
homeoOfIso ((LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _).mapIso e)
exact ⟨U.1.1, U.2, U.1.2, e'.embedding.t0Space⟩
instance : QuasiSober X.carrier := by
apply (config := { allowSynthFailures := true })
quasiSober_of_open_cover (Set.range fun x => Set.range <| (X.affineCover.map x).1.base)
· rintro ⟨_, i, rfl⟩; exact (X.affineCover.IsOpen i).base_open.isOpen_range
· rintro ⟨_, i, rfl⟩
exact @OpenEmbedding.quasiSober _ _ _ _ _ (Homeomorph.ofEmbedding _
(X.affineCover.IsOpen i).base_open.toEmbedding).symm.openEmbedding PrimeSpectrum.quasiSober
· rw [Set.top_eq_univ, Set.sUnion_range, Set.eq_univ_iff_forall]
intro x; exact ⟨_, ⟨_, rfl⟩, X.affineCover.Covers x⟩
/-- A scheme `X` is reduced if all `𝒪ₓ(U)` are reduced. -/
class IsReduced : Prop where
component_reduced : ∀ U, IsReduced (X.presheaf.obj (op U)) := by infer_instance
#align algebraic_geometry.is_reduced AlgebraicGeometry.IsReduced
attribute [instance] IsReduced.component_reduced
theorem isReducedOfStalkIsReduced [∀ x : X.carrier, _root_.IsReduced (X.presheaf.stalk x)] :
IsReduced X := by
refine ⟨fun U => ⟨fun s hs => ?_⟩⟩
apply Presheaf.section_ext X.sheaf U s 0
intro x
rw [RingHom.map_zero]
change X.presheaf.germ x s = 0
exact (hs.map _).eq_zero
#align algebraic_geometry.is_reduced_of_stalk_is_reduced AlgebraicGeometry.isReducedOfStalkIsReduced
instance stalk_isReduced_of_reduced [IsReduced X] (x : X.carrier) :
_root_.IsReduced (X.presheaf.stalk x) := by
constructor
rintro g ⟨n, e⟩
obtain ⟨U, hxU, s, rfl⟩ := X.presheaf.germ_exist x g
rw [← map_pow, ← map_zero (X.presheaf.germ ⟨x, hxU⟩)] at e
obtain ⟨V, hxV, iU, iV, e'⟩ := X.presheaf.germ_eq x hxU hxU _ 0 e
rw [map_pow, map_zero] at e'
replace e' := (IsNilpotent.mk _ _ e').eq_zero (R := X.presheaf.obj <| op V)
erw [← ConcreteCategory.congr_hom (X.presheaf.germ_res iU ⟨x, hxV⟩) s]
rw [comp_apply, e', map_zero]
#align algebraic_geometry.stalk_is_reduced_of_reduced AlgebraicGeometry.stalk_isReduced_of_reduced
theorem isReducedOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
[IsReduced Y] : IsReduced X := by
constructor
intro U
have : U = (Opens.map f.1.base).obj (H.base_open.isOpenMap.functor.obj U) := by
ext1; exact (Set.preimage_image_eq _ H.base_open.inj).symm
rw [this]
exact isReduced_of_injective (inv <| f.1.c.app (op <| H.base_open.isOpenMap.functor.obj U))
(asIso <| f.1.c.app (op <| H.base_open.isOpenMap.functor.obj U) :
Y.presheaf.obj _ ≅ _).symm.commRingCatIsoToRingEquiv.injective
#align algebraic_geometry.is_reduced_of_open_immersion AlgebraicGeometry.isReducedOfOpenImmersion
instance {R : CommRingCat.{u}} [H : _root_.IsReduced R] : IsReduced (Scheme.Spec.obj <| op R) := by
apply (config := { allowSynthFailures := true }) isReducedOfStalkIsReduced
intro x; dsimp
have : _root_.IsReduced (CommRingCat.of <| Localization.AtPrime (PrimeSpectrum.asIdeal x)) := by
dsimp; infer_instance
rw [show (Scheme.Spec.obj <| op R).presheaf = (Spec.structureSheaf R).presheaf from rfl]
exact isReduced_of_injective (StructureSheaf.stalkIso R x).hom
(StructureSheaf.stalkIso R x).commRingCatIsoToRingEquiv.injective
| Mathlib/AlgebraicGeometry/Properties.lean | 105 | 112 | theorem affine_isReduced_iff (R : CommRingCat) :
IsReduced (Scheme.Spec.obj <| op R) ↔ _root_.IsReduced R := by |
refine ⟨?_, fun h => inferInstance⟩
intro h
have : _root_.IsReduced
(LocallyRingedSpace.Γ.obj (op <| Spec.toLocallyRingedSpace.obj <| op R)) := by
change _root_.IsReduced ((Scheme.Spec.obj <| op R).presheaf.obj <| op ⊤); infer_instance
exact isReduced_of_injective (toSpecΓ R) (asIso <| toSpecΓ R).commRingCatIsoToRingEquiv.injective
|
/-
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]
| Mathlib/RingTheory/Multiplicity.lean | 65 | 73 | 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
|
/-
Copyright (c) 2021 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics
import Mathlib.NumberTheory.Liouville.Basic
import Mathlib.Topology.Instances.Irrational
#align_import number_theory.liouville.liouville_with from "leanprover-community/mathlib"@"0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8"
/-!
# Liouville numbers with a given exponent
We say that a real number `x` is a Liouville number with exponent `p : ℝ` if there exists a real
number `C` such that for infinitely many denominators `n` there exists a numerator `m` such that
`x ≠ m / n` and `|x - m / n| < C / n ^ p`. A number is a Liouville number in the sense of
`Liouville` if it is `LiouvilleWith` any real exponent, see `forall_liouvilleWith_iff`.
* If `p ≤ 1`, then this condition is trivial.
* If `1 < p ≤ 2`, then this condition is equivalent to `Irrational x`. The forward implication
does not require `p ≤ 2` and is formalized as `LiouvilleWith.irrational`; the other implication
follows from approximations by continued fractions and is not formalized yet.
* If `p > 2`, then this is a non-trivial condition on irrational numbers. In particular,
[Thue–Siegel–Roth theorem](https://en.wikipedia.org/wiki/Roth's_theorem) states that such numbers
must be transcendental.
In this file we define the predicate `LiouvilleWith` and prove some basic facts about this
predicate.
## Tags
Liouville number, irrational, irrationality exponent
-/
open Filter Metric Real Set
open scoped Filter Topology
/-- We say that a real number `x` is a Liouville number with exponent `p : ℝ` if there exists a real
number `C` such that for infinitely many denominators `n` there exists a numerator `m` such that
`x ≠ m / n` and `|x - m / n| < C / n ^ p`.
A number is a Liouville number in the sense of `Liouville` if it is `LiouvilleWith` any real
exponent. -/
def LiouvilleWith (p x : ℝ) : Prop :=
∃ C, ∃ᶠ n : ℕ in atTop, ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < C / n ^ p
#align liouville_with LiouvilleWith
/-- For `p = 1` (hence, for any `p ≤ 1`), the condition `LiouvilleWith p x` is trivial. -/
| Mathlib/NumberTheory/Liouville/LiouvilleWith.lean | 54 | 66 | theorem liouvilleWith_one (x : ℝ) : LiouvilleWith 1 x := by |
use 2
refine ((eventually_gt_atTop 0).mono fun n hn => ?_).frequently
have hn' : (0 : ℝ) < n := by simpa
have : x < ↑(⌊x * ↑n⌋ + 1) / ↑n := by
rw [lt_div_iff hn', Int.cast_add, Int.cast_one];
exact Int.lt_floor_add_one _
refine ⟨⌊x * n⌋ + 1, this.ne, ?_⟩
rw [abs_sub_comm, abs_of_pos (sub_pos.2 this), rpow_one, sub_lt_iff_lt_add',
add_div_eq_mul_add_div _ _ hn'.ne']
gcongr
calc _ ≤ x * n + 1 := by push_cast; gcongr; apply Int.floor_le
_ < x * n + 2 := by linarith
|
/-
Copyright (c) 2022 Kexing Ying. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying
-/
import Mathlib.Probability.Martingale.Convergence
import Mathlib.Probability.Martingale.OptionalStopping
import Mathlib.Probability.Martingale.Centering
#align_import probability.martingale.borel_cantelli from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
/-!
# Generalized Borel-Cantelli lemma
This file proves Lévy's generalized Borel-Cantelli lemma which is a generalization of the
Borel-Cantelli lemmas. With this generalization, one can easily deduce the Borel-Cantelli lemmas
by choosing appropriate filtrations. This file also contains the one sided martingale bound which
is required to prove the generalized Borel-Cantelli.
**Note**: the usual Borel-Cantelli lemmas are not in this file. See
`MeasureTheory.measure_limsup_eq_zero` for the first (which does not depend on the results here),
and `ProbabilityTheory.measure_limsup_eq_one` for the second (which does).
## Main results
- `MeasureTheory.Submartingale.bddAbove_iff_exists_tendsto`: the one sided martingale bound: given
a submartingale `f` with uniformly bounded differences, the set for which `f` converges is almost
everywhere equal to the set for which it is bounded.
- `MeasureTheory.ae_mem_limsup_atTop_iff`: Lévy's generalized Borel-Cantelli:
given a filtration `ℱ` and a sequence of sets `s` such that `s n ∈ ℱ n` for all `n`,
`limsup atTop s` is almost everywhere equal to the set for which `∑ ℙ[s (n + 1)∣ℱ n] = ∞`.
-/
open Filter
open scoped NNReal ENNReal MeasureTheory ProbabilityTheory BigOperators Topology
namespace MeasureTheory
variable {Ω : Type*} {m0 : MeasurableSpace Ω} {μ : Measure Ω} {ℱ : Filtration ℕ m0} {f : ℕ → Ω → ℝ}
{ω : Ω}
/-!
### One sided martingale bound
-/
-- TODO: `leastGE` should be defined taking values in `WithTop ℕ` once the `stoppedProcess`
-- refactor is complete
/-- `leastGE f r n` is the stopping time corresponding to the first time `f ≥ r`. -/
noncomputable def leastGE (f : ℕ → Ω → ℝ) (r : ℝ) (n : ℕ) :=
hitting f (Set.Ici r) 0 n
#align measure_theory.least_ge MeasureTheory.leastGE
theorem Adapted.isStoppingTime_leastGE (r : ℝ) (n : ℕ) (hf : Adapted ℱ f) :
IsStoppingTime ℱ (leastGE f r n) :=
hitting_isStoppingTime hf measurableSet_Ici
#align measure_theory.adapted.is_stopping_time_least_ge MeasureTheory.Adapted.isStoppingTime_leastGE
theorem leastGE_le {i : ℕ} {r : ℝ} (ω : Ω) : leastGE f r i ω ≤ i :=
hitting_le ω
#align measure_theory.least_ge_le MeasureTheory.leastGE_le
-- The following four lemmas shows `leastGE` behaves like a stopped process. Ideally we should
-- define `leastGE` as a stopping time and take its stopped process. However, we can't do that
-- with our current definition since a stopping time takes only finite indicies. An upcomming
-- refactor should hopefully make it possible to have stopping times taking infinity as a value
theorem leastGE_mono {n m : ℕ} (hnm : n ≤ m) (r : ℝ) (ω : Ω) : leastGE f r n ω ≤ leastGE f r m ω :=
hitting_mono hnm
#align measure_theory.least_ge_mono MeasureTheory.leastGE_mono
theorem leastGE_eq_min (π : Ω → ℕ) (r : ℝ) (ω : Ω) {n : ℕ} (hπn : ∀ ω, π ω ≤ n) :
leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω) := by
classical
refine le_antisymm (le_min (leastGE_le _) (leastGE_mono (hπn ω) r ω)) ?_
by_cases hle : π ω ≤ leastGE f r n ω
· rw [min_eq_left hle, leastGE]
by_cases h : ∃ j ∈ Set.Icc 0 (π ω), f j ω ∈ Set.Ici r
· refine hle.trans (Eq.le ?_)
rw [leastGE, ← hitting_eq_hitting_of_exists (hπn ω) h]
· simp only [hitting, if_neg h, le_rfl]
· rw [min_eq_right (not_le.1 hle).le, leastGE, leastGE, ←
hitting_eq_hitting_of_exists (hπn ω) _]
rw [not_le, leastGE, hitting_lt_iff _ (hπn ω)] at hle
exact
let ⟨j, hj₁, hj₂⟩ := hle
⟨j, ⟨hj₁.1, hj₁.2.le⟩, hj₂⟩
#align measure_theory.least_ge_eq_min MeasureTheory.leastGE_eq_min
| Mathlib/Probability/Martingale/BorelCantelli.lean | 93 | 98 | theorem stoppedValue_stoppedValue_leastGE (f : ℕ → Ω → ℝ) (π : Ω → ℕ) (r : ℝ) {n : ℕ}
(hπn : ∀ ω, π ω ≤ n) : stoppedValue (fun i => stoppedValue f (leastGE f r i)) π =
stoppedValue (stoppedProcess f (leastGE f r n)) π := by |
ext1 ω
simp (config := { unfoldPartialApp := true }) only [stoppedProcess, stoppedValue]
rw [leastGE_eq_min _ _ _ hπn]
|
/-
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.MeasureTheory.Constructions.BorelSpace.Basic
import Mathlib.Dynamics.Ergodic.MeasurePreserving
import Mathlib.Combinatorics.Pigeonhole
#align_import dynamics.ergodic.conservative from "leanprover-community/mathlib"@"bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf"
/-!
# Conservative systems
In this file we define `f : α → α` to be a *conservative* system w.r.t a measure `μ` if `f` is
non-singular (`MeasureTheory.QuasiMeasurePreserving`) and for every measurable set `s` of
positive measure at least one point `x ∈ s` returns back to `s` after some number of iterations of
`f`. There are several properties that look like they are stronger than this one but actually follow
from it:
* `MeasureTheory.Conservative.frequently_measure_inter_ne_zero`,
`MeasureTheory.Conservative.exists_gt_measure_inter_ne_zero`: if `μ s ≠ 0`, then for infinitely
many `n`, the measure of `s ∩ f^[n] ⁻¹' s` is positive.
* `MeasureTheory.Conservative.measure_mem_forall_ge_image_not_mem_eq_zero`,
`MeasureTheory.Conservative.ae_mem_imp_frequently_image_mem`: a.e. every point of `s` visits `s`
infinitely many times (Poincaré recurrence theorem).
We also prove the topological Poincaré recurrence theorem
`MeasureTheory.Conservative.ae_frequently_mem_of_mem_nhds`. Let `f : α → α` be a conservative
dynamical system on a topological space with second countable topology and measurable open
sets. Then almost every point `x : α` is recurrent: it visits every neighborhood `s ∈ 𝓝 x`
infinitely many times.
## Tags
conservative dynamical system, Poincare recurrence theorem
-/
noncomputable section
open scoped Classical
open Set Filter MeasureTheory Finset Function TopologicalSpace
open scoped Classical
open Topology
variable {ι : Type*} {α : Type*} [MeasurableSpace α] {f : α → α} {s : Set α} {μ : Measure α}
namespace MeasureTheory
open Measure
/-- We say that a non-singular (`MeasureTheory.QuasiMeasurePreserving`) self-map is
*conservative* if for any measurable set `s` of positive measure there exists `x ∈ s` such that `x`
returns back to `s` under some iteration of `f`. -/
structure Conservative (f : α → α) (μ : Measure α) extends QuasiMeasurePreserving f μ μ : Prop where
/-- If `f` is a conservative self-map and `s` is a measurable set of nonzero measure,
then there exists a point `x ∈ s` that returns to `s` under a non-zero iteration of `f`. -/
exists_mem_iterate_mem : ∀ ⦃s⦄, MeasurableSet s → μ s ≠ 0 → ∃ x ∈ s, ∃ m ≠ 0, f^[m] x ∈ s
#align measure_theory.conservative MeasureTheory.Conservative
/-- A self-map preserving a finite measure is conservative. -/
protected theorem MeasurePreserving.conservative [IsFiniteMeasure μ] (h : MeasurePreserving f μ μ) :
Conservative f μ :=
⟨h.quasiMeasurePreserving, fun _ hsm h0 => h.exists_mem_iterate_mem hsm h0⟩
#align measure_theory.measure_preserving.conservative MeasureTheory.MeasurePreserving.conservative
namespace Conservative
/-- The identity map is conservative w.r.t. any measure. -/
protected theorem id (μ : Measure α) : Conservative id μ :=
{ toQuasiMeasurePreserving := QuasiMeasurePreserving.id μ
exists_mem_iterate_mem := fun _ _ h0 =>
let ⟨x, hx⟩ := nonempty_of_measure_ne_zero h0
⟨x, hx, 1, one_ne_zero, hx⟩ }
#align measure_theory.conservative.id MeasureTheory.Conservative.id
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
| Mathlib/Dynamics/Ergodic/Conservative.lean | 83 | 106 | theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
(h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by |
by_contra H
simp only [not_frequently, eventually_atTop, Ne, Classical.not_not] at H
rcases H with ⟨N, hN⟩
induction' N with N ihN
· apply h0
simpa using hN 0 le_rfl
rw [imp_false] at ihN
push_neg at ihN
rcases ihN with ⟨n, hn, hμn⟩
set T := s ∩ ⋃ n ≥ N + 1, f^[n] ⁻¹' s
have hT : MeasurableSet T :=
hs.inter (MeasurableSet.biUnion (to_countable _) fun _ _ => hf.measurable.iterate _ hs)
have hμT : μ T = 0 := by
convert (measure_biUnion_null_iff <| to_countable _).2 hN
rw [← inter_iUnion₂]
rfl
have : μ ((s ∩ f^[n] ⁻¹' s) \ T) ≠ 0 := by rwa [measure_diff_null hμT]
rcases hf.exists_mem_iterate_mem ((hs.inter (hf.measurable.iterate n hs)).diff hT) this with
⟨x, ⟨⟨hxs, _⟩, hxT⟩, m, hm0, ⟨_, hxm⟩, _⟩
refine hxT ⟨hxs, mem_iUnion₂.2 ⟨n + m, ?_, ?_⟩⟩
· exact add_le_add hn (Nat.one_le_of_lt <| pos_iff_ne_zero.2 hm0)
· rwa [Set.mem_preimage, ← iterate_add_apply] at hxm
|
/-
Copyright (c) 2019 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen
-/
import Mathlib.Algebra.Regular.Basic
import Mathlib.LinearAlgebra.Matrix.MvPolynomial
import Mathlib.LinearAlgebra.Matrix.Polynomial
import Mathlib.RingTheory.Polynomial.Basic
#align_import linear_algebra.matrix.adjugate from "leanprover-community/mathlib"@"a99f85220eaf38f14f94e04699943e185a5e1d1a"
/-!
# Cramer's rule and adjugate matrices
The adjugate matrix is the transpose of the cofactor matrix.
It is calculated with Cramer's rule, which we introduce first.
The vectors returned by Cramer's rule are given by the linear map `cramer`,
which sends a matrix `A` and vector `b` to the vector consisting of the
determinant of replacing the `i`th column of `A` with `b` at index `i`
(written as `(A.update_column i b).det`).
Using Cramer's rule, we can compute for each matrix `A` the matrix `adjugate A`.
The entries of the adjugate are the minors of `A`.
Instead of defining a minor by deleting row `i` and column `j` of `A`, we
replace the `i`th row of `A` with the `j`th basis vector; the resulting matrix
has the same determinant but more importantly equals Cramer's rule applied
to `A` and the `j`th basis vector, simplifying the subsequent proofs.
We prove the adjugate behaves like `det A • A⁻¹`.
## Main definitions
* `Matrix.cramer A b`: the vector output by Cramer's rule on `A` and `b`.
* `Matrix.adjugate A`: the adjugate (or classical adjoint) of the matrix `A`.
## References
* https://en.wikipedia.org/wiki/Cramer's_rule#Finding_inverse_matrix
## Tags
cramer, cramer's rule, adjugate
-/
namespace Matrix
universe u v w
variable {m : Type u} {n : Type v} {α : Type w}
variable [DecidableEq n] [Fintype n] [DecidableEq m] [Fintype m] [CommRing α]
open Matrix Polynomial Equiv Equiv.Perm Finset
section Cramer
/-!
### `cramer` section
Introduce the linear map `cramer` with values defined by `cramerMap`.
After defining `cramerMap` and showing it is linear,
we will restrict our proofs to using `cramer`.
-/
variable (A : Matrix n n α) (b : n → α)
/-- `cramerMap A b i` is the determinant of the matrix `A` with column `i` replaced with `b`,
and thus `cramerMap A b` is the vector output by Cramer's rule on `A` and `b`.
If `A * x = b` has a unique solution in `x`, `cramerMap A` sends the vector `b` to `A.det • x`.
Otherwise, the outcome of `cramerMap` is well-defined but not necessarily useful.
-/
def cramerMap (i : n) : α :=
(A.updateColumn i b).det
#align matrix.cramer_map Matrix.cramerMap
theorem cramerMap_is_linear (i : n) : IsLinearMap α fun b => cramerMap A b i :=
{ map_add := det_updateColumn_add _ _
map_smul := det_updateColumn_smul _ _ }
#align matrix.cramer_map_is_linear Matrix.cramerMap_is_linear
theorem cramer_is_linear : IsLinearMap α (cramerMap A) := by
constructor <;> intros <;> ext i
· apply (cramerMap_is_linear A i).1
· apply (cramerMap_is_linear A i).2
#align matrix.cramer_is_linear Matrix.cramer_is_linear
/-- `cramer A b i` is the determinant of the matrix `A` with column `i` replaced with `b`,
and thus `cramer A b` is the vector output by Cramer's rule on `A` and `b`.
If `A * x = b` has a unique solution in `x`, `cramer A` sends the vector `b` to `A.det • x`.
Otherwise, the outcome of `cramer` is well-defined but not necessarily useful.
-/
def cramer (A : Matrix n n α) : (n → α) →ₗ[α] (n → α) :=
IsLinearMap.mk' (cramerMap A) (cramer_is_linear A)
#align matrix.cramer Matrix.cramer
theorem cramer_apply (i : n) : cramer A b i = (A.updateColumn i b).det :=
rfl
#align matrix.cramer_apply Matrix.cramer_apply
theorem cramer_transpose_apply (i : n) : cramer Aᵀ b i = (A.updateRow i b).det := by
rw [cramer_apply, updateColumn_transpose, det_transpose]
#align matrix.cramer_transpose_apply Matrix.cramer_transpose_apply
| Mathlib/LinearAlgebra/Matrix/Adjugate.lean | 106 | 116 | theorem cramer_transpose_row_self (i : n) : Aᵀ.cramer (A i) = Pi.single i A.det := by |
ext j
rw [cramer_apply, Pi.single_apply]
split_ifs with h
· -- i = j: this entry should be `A.det`
subst h
simp only [updateColumn_transpose, det_transpose, updateRow_eq_self]
· -- i ≠ j: this entry should be 0
rw [updateColumn_transpose, det_transpose]
apply det_zero_of_row_eq h
rw [updateRow_self, updateRow_ne (Ne.symm h)]
|
/-
Copyright (c) 2021 Kexing Ying. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying, Eric Wieser
-/
import Mathlib.Data.Real.Basic
#align_import data.real.sign from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
/-!
# Real sign function
This file introduces and contains some results about `Real.sign` which maps negative
real numbers to -1, positive real numbers to 1, and 0 to 0.
## Main definitions
* `Real.sign r` is $\begin{cases} -1 & \text{if } r < 0, \\
~~\, 0 & \text{if } r = 0, \\
~~\, 1 & \text{if } r > 0. \end{cases}$
## Tags
sign function
-/
namespace Real
/-- The sign function that maps negative real numbers to -1, positive numbers to 1, and 0
otherwise. -/
noncomputable def sign (r : ℝ) : ℝ :=
if r < 0 then -1 else if 0 < r then 1 else 0
#align real.sign Real.sign
| Mathlib/Data/Real/Sign.lean | 36 | 36 | theorem sign_of_neg {r : ℝ} (hr : r < 0) : sign r = -1 := by | rw [sign, if_pos hr]
|
/-
Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl
-/
import Mathlib.Algebra.Order.Monoid.Unbundled.Basic
#align_import algebra.order.monoid.min_max from "leanprover-community/mathlib"@"de87d5053a9fe5cbde723172c0fb7e27e7436473"
/-!
# Lemmas about `min` and `max` in an ordered monoid.
-/
open Function
variable {α β : Type*}
/-! Some lemmas about types that have an ordering and a binary operation, with no
rules relating them. -/
section CommSemigroup
variable [LinearOrder α] [CommSemigroup α] [CommSemigroup β]
@[to_additive]
lemma fn_min_mul_fn_max (f : α → β) (a b : α) : f (min a b) * f (max a b) = f a * f b := by
obtain h | h := le_total a b <;> simp [h, mul_comm]
#align fn_min_mul_fn_max fn_min_mul_fn_max
#align fn_min_add_fn_max fn_min_add_fn_max
@[to_additive]
lemma fn_max_mul_fn_min (f : α → β) (a b : α) : f (max a b) * f (min a b) = f a * f b := by
obtain h | h := le_total a b <;> simp [h, mul_comm]
@[to_additive (attr := simp)]
lemma min_mul_max (a b : α) : min a b * max a b = a * b := fn_min_mul_fn_max id _ _
#align min_mul_max min_mul_max
#align min_add_max min_add_max
@[to_additive (attr := simp)]
lemma max_mul_min (a b : α) : max a b * min a b = a * b := fn_max_mul_fn_min id _ _
end CommSemigroup
section CovariantClassMulLe
variable [LinearOrder α]
section Mul
variable [Mul α]
section Left
variable [CovariantClass α α (· * ·) (· ≤ ·)]
@[to_additive]
theorem min_mul_mul_left (a b c : α) : min (a * b) (a * c) = a * min b c :=
(monotone_id.const_mul' a).map_min.symm
#align min_mul_mul_left min_mul_mul_left
#align min_add_add_left min_add_add_left
@[to_additive]
theorem max_mul_mul_left (a b c : α) : max (a * b) (a * c) = a * max b c :=
(monotone_id.const_mul' a).map_max.symm
#align max_mul_mul_left max_mul_mul_left
#align max_add_add_left max_add_add_left
end Left
section Right
variable [CovariantClass α α (Function.swap (· * ·)) (· ≤ ·)]
@[to_additive]
theorem min_mul_mul_right (a b c : α) : min (a * c) (b * c) = min a b * c :=
(monotone_id.mul_const' c).map_min.symm
#align min_mul_mul_right min_mul_mul_right
#align min_add_add_right min_add_add_right
@[to_additive]
theorem max_mul_mul_right (a b c : α) : max (a * c) (b * c) = max a b * c :=
(monotone_id.mul_const' c).map_max.symm
#align max_mul_mul_right max_mul_mul_right
#align max_add_add_right max_add_add_right
end Right
@[to_additive]
| Mathlib/Algebra/Order/Monoid/Unbundled/MinMax.lean | 90 | 94 | theorem lt_or_lt_of_mul_lt_mul [CovariantClass α α (· * ·) (· ≤ ·)]
[CovariantClass α α (Function.swap (· * ·)) (· ≤ ·)] {a₁ a₂ b₁ b₂ : α} :
a₁ * b₁ < a₂ * b₂ → a₁ < a₂ ∨ b₁ < b₂ := by |
contrapose!
exact fun h => mul_le_mul' h.1 h.2
|
/-
Copyright (c) 2022 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta
-/
import Mathlib.Algebra.IsPrimePow
import Mathlib.Data.Nat.Factorization.Basic
#align_import data.nat.factorization.prime_pow from "leanprover-community/mathlib"@"6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f"
/-!
# Prime powers and factorizations
This file deals with factorizations of prime powers.
-/
variable {R : Type*} [CommMonoidWithZero R] (n p : R) (k : ℕ)
theorem IsPrimePow.minFac_pow_factorization_eq {n : ℕ} (hn : IsPrimePow n) :
n.minFac ^ n.factorization n.minFac = n := by
obtain ⟨p, k, hp, hk, rfl⟩ := hn
rw [← Nat.prime_iff] at hp
rw [hp.pow_minFac hk.ne', hp.factorization_pow, Finsupp.single_eq_same]
#align is_prime_pow.min_fac_pow_factorization_eq IsPrimePow.minFac_pow_factorization_eq
theorem isPrimePow_of_minFac_pow_factorization_eq {n : ℕ}
(h : n.minFac ^ n.factorization n.minFac = n) (hn : n ≠ 1) : IsPrimePow n := by
rcases eq_or_ne n 0 with (rfl | hn')
· simp_all
refine ⟨_, _, (Nat.minFac_prime hn).prime, ?_, h⟩
simp [pos_iff_ne_zero, ← Finsupp.mem_support_iff, Nat.support_factorization, hn',
Nat.minFac_prime hn, Nat.minFac_dvd]
#align is_prime_pow_of_min_fac_pow_factorization_eq isPrimePow_of_minFac_pow_factorization_eq
theorem isPrimePow_iff_minFac_pow_factorization_eq {n : ℕ} (hn : n ≠ 1) :
IsPrimePow n ↔ n.minFac ^ n.factorization n.minFac = n :=
⟨fun h => h.minFac_pow_factorization_eq, fun h => isPrimePow_of_minFac_pow_factorization_eq h hn⟩
#align is_prime_pow_iff_min_fac_pow_factorization_eq isPrimePow_iff_minFac_pow_factorization_eq
theorem isPrimePow_iff_factorization_eq_single {n : ℕ} :
IsPrimePow n ↔ ∃ p k : ℕ, 0 < k ∧ n.factorization = Finsupp.single p k := by
rw [isPrimePow_nat_iff]
refine exists₂_congr fun p k => ?_
constructor
· rintro ⟨hp, hk, hn⟩
exact ⟨hk, by rw [← hn, Nat.Prime.factorization_pow hp]⟩
· rintro ⟨hk, hn⟩
have hn0 : n ≠ 0 := by
rintro rfl
simp_all only [Finsupp.single_eq_zero, eq_comm, Nat.factorization_zero, hk.ne']
rw [Nat.eq_pow_of_factorization_eq_single hn0 hn]
exact ⟨Nat.prime_of_mem_primeFactors <|
Finsupp.mem_support_iff.2 (by simp [hn, hk.ne'] : n.factorization p ≠ 0), hk, rfl⟩
#align is_prime_pow_iff_factorization_eq_single isPrimePow_iff_factorization_eq_single
theorem isPrimePow_iff_card_primeFactors_eq_one {n : ℕ} :
IsPrimePow n ↔ n.primeFactors.card = 1 := by
simp_rw [isPrimePow_iff_factorization_eq_single, ← Nat.support_factorization,
Finsupp.card_support_eq_one', pos_iff_ne_zero]
#align is_prime_pow_iff_card_support_factorization_eq_one isPrimePow_iff_card_primeFactors_eq_one
theorem IsPrimePow.exists_ord_compl_eq_one {n : ℕ} (h : IsPrimePow n) :
∃ p : ℕ, p.Prime ∧ ord_compl[p] n = 1 := by
rcases eq_or_ne n 0 with (rfl | hn0); · cases not_isPrimePow_zero h
rcases isPrimePow_iff_factorization_eq_single.mp h with ⟨p, k, hk0, h1⟩
rcases em' p.Prime with (pp | pp)
· refine absurd ?_ hk0.ne'
simp [← Nat.factorization_eq_zero_of_non_prime n pp, h1]
refine ⟨p, pp, ?_⟩
refine Nat.eq_of_factorization_eq (Nat.ord_compl_pos p hn0).ne' (by simp) fun q => ?_
rw [Nat.factorization_ord_compl n p, h1]
simp
#align is_prime_pow.exists_ord_compl_eq_one IsPrimePow.exists_ord_compl_eq_one
| Mathlib/Data/Nat/Factorization/PrimePow.lean | 76 | 84 | theorem exists_ord_compl_eq_one_iff_isPrimePow {n : ℕ} (hn : n ≠ 1) :
IsPrimePow n ↔ ∃ p : ℕ, p.Prime ∧ ord_compl[p] n = 1 := by |
refine ⟨fun h => IsPrimePow.exists_ord_compl_eq_one h, fun h => ?_⟩
rcases h with ⟨p, pp, h⟩
rw [isPrimePow_nat_iff]
rw [← Nat.eq_of_dvd_of_div_eq_one (Nat.ord_proj_dvd n p) h] at hn ⊢
refine ⟨p, n.factorization p, pp, ?_, by simp⟩
contrapose! hn
simp [Nat.le_zero.1 hn]
|
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.Algebra.TrivSqZeroExt
#align_import algebra.dual_number from "leanprover-community/mathlib"@"b8d2eaa69d69ce8f03179a5cda774fc0cde984e4"
/-!
# Dual numbers
The dual numbers over `R` are of the form `a + bε`, where `a` and `b` are typically elements of a
commutative ring `R`, and `ε` is a symbol satisfying `ε^2 = 0` that commutes with every other
element. They are a special case of `TrivSqZeroExt R M` with `M = R`.
## Notation
In the `DualNumber` locale:
* `R[ε]` is a shorthand for `DualNumber R`
* `ε` is a shorthand for `DualNumber.eps`
## Main definitions
* `DualNumber`
* `DualNumber.eps`
* `DualNumber.lift`
## Implementation notes
Rather than duplicating the API of `TrivSqZeroExt`, this file reuses the functions there.
## References
* https://en.wikipedia.org/wiki/Dual_number
-/
variable {R A B : Type*}
/-- The type of dual numbers, numbers of the form $a + bε$ where $ε^2 = 0$.
`R[ε]` is notation for `DualNumber R`. -/
abbrev DualNumber (R : Type*) : Type _ :=
TrivSqZeroExt R R
#align dual_number DualNumber
/-- The unit element $ε$ that squares to zero, with notation `ε`. -/
def DualNumber.eps [Zero R] [One R] : DualNumber R :=
TrivSqZeroExt.inr 1
#align dual_number.eps DualNumber.eps
@[inherit_doc]
scoped[DualNumber] notation "ε" => DualNumber.eps
@[inherit_doc]
scoped[DualNumber] postfix:1024 "[ε]" => DualNumber
open DualNumber
namespace DualNumber
open TrivSqZeroExt
@[simp]
theorem fst_eps [Zero R] [One R] : fst ε = (0 : R) :=
fst_inr _ _
#align dual_number.fst_eps DualNumber.fst_eps
@[simp]
theorem snd_eps [Zero R] [One R] : snd ε = (1 : R) :=
snd_inr _ _
#align dual_number.snd_eps DualNumber.snd_eps
/-- A version of `TrivSqZeroExt.snd_mul` with `*` instead of `•`. -/
@[simp]
theorem snd_mul [Semiring R] (x y : R[ε]) : snd (x * y) = fst x * snd y + snd x * fst y :=
TrivSqZeroExt.snd_mul _ _
#align dual_number.snd_mul DualNumber.snd_mul
@[simp]
theorem eps_mul_eps [Semiring R] : (ε * ε : R[ε]) = 0 :=
inr_mul_inr _ _ _
#align dual_number.eps_mul_eps DualNumber.eps_mul_eps
@[simp]
theorem inv_eps [DivisionRing R] : (ε : R[ε])⁻¹ = 0 :=
TrivSqZeroExt.inv_inr 1
@[simp]
theorem inr_eq_smul_eps [MulZeroOneClass R] (r : R) : inr r = (r • ε : R[ε]) :=
ext (mul_zero r).symm (mul_one r).symm
#align dual_number.inr_eq_smul_eps DualNumber.inr_eq_smul_eps
/-- `ε` commutes with every element of the algebra. -/
| Mathlib/Algebra/DualNumber.lean | 96 | 97 | theorem commute_eps_left [Semiring R] (x : DualNumber R) : Commute ε x := by |
ext <;> simp
|
/-
Copyright (c) 2022 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
-/
import Mathlib.Data.Vector.Basic
#align_import data.vector.mem from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# Theorems about membership of elements in vectors
This file contains theorems for membership in a `v.toList` for a vector `v`.
Having the length available in the type allows some of the lemmas to be
simpler and more general than the original version for lists.
In particular we can avoid some assumptions about types being `Inhabited`,
and make more general statements about `head` and `tail`.
-/
namespace Vector
variable {α β : Type*} {n : ℕ} (a a' : α)
@[simp]
theorem get_mem (i : Fin n) (v : Vector α n) : v.get i ∈ v.toList := by
rw [get_eq_get]
exact List.get_mem _ _ _
#align vector.nth_mem Vector.get_mem
theorem mem_iff_get (v : Vector α n) : a ∈ v.toList ↔ ∃ i, v.get i = a := by
simp only [List.mem_iff_get, Fin.exists_iff, Vector.get_eq_get]
exact
⟨fun ⟨i, hi, h⟩ => ⟨i, by rwa [toList_length] at hi, h⟩, fun ⟨i, hi, h⟩ =>
⟨i, by rwa [toList_length], h⟩⟩
#align vector.mem_iff_nth Vector.mem_iff_get
| Mathlib/Data/Vector/Mem.lean | 38 | 41 | theorem not_mem_nil : a ∉ (Vector.nil : Vector α 0).toList := by |
unfold Vector.nil
dsimp
simp
|
/-
Copyright (c) 2021 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Kyle Miller
-/
import Mathlib.Data.Int.GCD
import Mathlib.Tactic.NormNum
/-! # `norm_num` extensions for GCD-adjacent functions
This module defines some `norm_num` extensions for functions such as
`Nat.gcd`, `Nat.lcm`, `Int.gcd`, and `Int.lcm`.
Note that `Nat.coprime` is reducible and defined in terms of `Nat.gcd`, so the `Nat.gcd` extension
also indirectly provides a `Nat.coprime` extension.
-/
namespace Tactic
namespace NormNum
theorem int_gcd_helper' {d : ℕ} {x y : ℤ} (a b : ℤ) (h₁ : (d : ℤ) ∣ x) (h₂ : (d : ℤ) ∣ y)
(h₃ : x * a + y * b = d) : Int.gcd x y = d := by
refine Nat.dvd_antisymm ?_ (Int.natCast_dvd_natCast.1 (Int.dvd_gcd h₁ h₂))
rw [← Int.natCast_dvd_natCast, ← h₃]
apply dvd_add
· exact Int.gcd_dvd_left.mul_right _
· exact Int.gcd_dvd_right.mul_right _
theorem nat_gcd_helper_dvd_left (x y : ℕ) (h : y % x = 0) : Nat.gcd x y = x :=
Nat.gcd_eq_left (Nat.dvd_of_mod_eq_zero h)
theorem nat_gcd_helper_dvd_right (x y : ℕ) (h : x % y = 0) : Nat.gcd x y = y :=
Nat.gcd_eq_right (Nat.dvd_of_mod_eq_zero h)
| Mathlib/Tactic/NormNum/GCD.lean | 36 | 43 | theorem nat_gcd_helper_2 (d x y a b : ℕ) (hu : x % d = 0) (hv : y % d = 0)
(h : x * a = y * b + d) : Nat.gcd x y = d := by |
rw [← Int.gcd_natCast_natCast]
apply int_gcd_helper' a (-b)
(Int.natCast_dvd_natCast.mpr (Nat.dvd_of_mod_eq_zero hu))
(Int.natCast_dvd_natCast.mpr (Nat.dvd_of_mod_eq_zero hv))
rw [mul_neg, ← sub_eq_add_neg, sub_eq_iff_eq_add']
exact mod_cast h
|
/-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.EquivalenceAdditive
import Mathlib.AlgebraicTopology.DoldKan.Compatibility
import Mathlib.CategoryTheory.Idempotents.SimplicialObject
#align_import algebraic_topology.dold_kan.equivalence_pseudoabelian from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504"
/-!
# The Dold-Kan correspondence for pseudoabelian categories
In this file, for any idempotent complete additive category `C`,
the Dold-Kan equivalence
`Idempotents.DoldKan.Equivalence C : SimplicialObject C ≌ ChainComplex C ℕ`
is obtained. It is deduced from the equivalence
`Preadditive.DoldKan.Equivalence` between the respective idempotent
completions of these categories using the fact that when `C` is idempotent complete,
then both `SimplicialObject C` and `ChainComplex C ℕ` are idempotent complete.
The construction of `Idempotents.DoldKan.Equivalence` uses the tools
introduced in the file `Compatibility.lean`. Doing so, the functor
`Idempotents.DoldKan.N` of the equivalence is
the composition of `N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)`
(defined in `FunctorN.lean`) and the inverse of the equivalence
`ChainComplex C ℕ ≌ Karoubi (ChainComplex C ℕ)`. The functor
`Idempotents.DoldKan.Γ` of the equivalence is by definition the functor
`Γ₀` introduced in `FunctorGamma.lean`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Idempotents
variable {C : Type*} [Category C] [Preadditive C]
namespace CategoryTheory
namespace Idempotents
namespace DoldKan
open AlgebraicTopology.DoldKan
/-- The functor `N` for the equivalence is obtained by composing
`N' : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)` and the inverse
of the equivalence `ChainComplex C ℕ ≌ Karoubi (ChainComplex C ℕ)`. -/
@[simps!, nolint unusedArguments]
def N [IsIdempotentComplete C] [HasFiniteCoproducts C] : SimplicialObject C ⥤ ChainComplex C ℕ :=
N₁ ⋙ (toKaroubiEquivalence _).inverse
set_option linter.uppercaseLean3 false in
#align category_theory.idempotents.dold_kan.N CategoryTheory.Idempotents.DoldKan.N
/-- The functor `Γ` for the equivalence is `Γ'`. -/
@[simps!, nolint unusedArguments]
def Γ [IsIdempotentComplete C] [HasFiniteCoproducts C] : ChainComplex C ℕ ⥤ SimplicialObject C :=
Γ₀
#align category_theory.idempotents.dold_kan.Γ CategoryTheory.Idempotents.DoldKan.Γ
variable [IsIdempotentComplete C] [HasFiniteCoproducts C]
/-- A reformulation of the isomorphism `toKaroubi (SimplicialObject C) ⋙ N₂ ≅ N₁` -/
def isoN₁ :
(toKaroubiEquivalence (SimplicialObject C)).functor ⋙
Preadditive.DoldKan.equivalence.functor ≅ N₁ := toKaroubiCompN₂IsoN₁
@[simp]
lemma isoN₁_hom_app_f (X : SimplicialObject C) :
(isoN₁.hom.app X).f = PInfty := rfl
/-- A reformulation of the canonical isomorphism
`toKaroubi (ChainComplex C ℕ) ⋙ Γ₂ ≅ Γ ⋙ toKaroubi (SimplicialObject C)`. -/
def isoΓ₀ :
(toKaroubiEquivalence (ChainComplex C ℕ)).functor ⋙ Preadditive.DoldKan.equivalence.inverse ≅
Γ ⋙ (toKaroubiEquivalence _).functor :=
(functorExtension₂CompWhiskeringLeftToKaroubiIso _ _).app Γ₀
@[simp]
lemma N₂_map_isoΓ₀_hom_app_f (X : ChainComplex C ℕ) :
(N₂.map (isoΓ₀.hom.app X)).f = PInfty := by
ext
apply comp_id
/-- The Dold-Kan equivalence for pseudoabelian categories given
by the functors `N` and `Γ`. It is obtained by applying the results in
`Compatibility.lean` to the equivalence `Preadditive.DoldKan.Equivalence`. -/
def equivalence : SimplicialObject C ≌ ChainComplex C ℕ :=
Compatibility.equivalence isoN₁ isoΓ₀
#align category_theory.idempotents.dold_kan.equivalence CategoryTheory.Idempotents.DoldKan.equivalence
theorem equivalence_functor : (equivalence : SimplicialObject C ≌ _).functor = N :=
rfl
#align category_theory.idempotents.dold_kan.equivalence_functor CategoryTheory.Idempotents.DoldKan.equivalence_functor
theorem equivalence_inverse : (equivalence : SimplicialObject C ≌ _).inverse = Γ :=
rfl
#align category_theory.idempotents.dold_kan.equivalence_inverse CategoryTheory.Idempotents.DoldKan.equivalence_inverse
/-- The natural isomorphism `NΓ' satisfies the compatibility that is needed
for the construction of our counit isomorphism `η` -/
| Mathlib/AlgebraicTopology/DoldKan/EquivalencePseudoabelian.lean | 108 | 114 | theorem hη :
Compatibility.τ₀ =
Compatibility.τ₁ isoN₁ isoΓ₀
(N₁Γ₀ : Γ ⋙ N₁ ≅ (toKaroubiEquivalence (ChainComplex C ℕ)).functor) := by |
ext K : 3
simp only [Compatibility.τ₀_hom_app, Compatibility.τ₁_hom_app]
exact (N₂Γ₂_compatible_with_N₁Γ₀ K).trans (by simp )
|
/-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Algebra.Group.Pi.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Products
import Mathlib.CategoryTheory.Limits.Shapes.Images
import Mathlib.CategoryTheory.IsomorphismClasses
import Mathlib.CategoryTheory.Limits.Shapes.ZeroObjects
#align_import category_theory.limits.shapes.zero_morphisms from "leanprover-community/mathlib"@"f7707875544ef1f81b32cb68c79e0e24e45a0e76"
/-!
# Zero morphisms and zero objects
A category "has zero morphisms" if there is a designated "zero morphism" in each morphism space,
and compositions of zero morphisms with anything give the zero morphism. (Notice this is extra
structure, not merely a property.)
A category "has a zero object" if it has an object which is both initial and terminal. Having a
zero object provides zero morphisms, as the unique morphisms factoring through the zero object.
## References
* https://en.wikipedia.org/wiki/Zero_morphism
* [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2]
-/
noncomputable section
universe v u
universe v' u'
open CategoryTheory
open CategoryTheory.Category
open scoped Classical
namespace CategoryTheory.Limits
variable (C : Type u) [Category.{v} C]
variable (D : Type u') [Category.{v'} D]
/-- A category "has zero morphisms" if there is a designated "zero morphism" in each morphism space,
and compositions of zero morphisms with anything give the zero morphism. -/
class HasZeroMorphisms where
/-- Every morphism space has zero -/
[zero : ∀ X Y : C, Zero (X ⟶ Y)]
/-- `f` composed with `0` is `0` -/
comp_zero : ∀ {X Y : C} (f : X ⟶ Y) (Z : C), f ≫ (0 : Y ⟶ Z) = (0 : X ⟶ Z) := by aesop_cat
/-- `0` composed with `f` is `0` -/
zero_comp : ∀ (X : C) {Y Z : C} (f : Y ⟶ Z), (0 : X ⟶ Y) ≫ f = (0 : X ⟶ Z) := by aesop_cat
#align category_theory.limits.has_zero_morphisms CategoryTheory.Limits.HasZeroMorphisms
#align category_theory.limits.has_zero_morphisms.comp_zero' CategoryTheory.Limits.HasZeroMorphisms.comp_zero
#align category_theory.limits.has_zero_morphisms.zero_comp' CategoryTheory.Limits.HasZeroMorphisms.zero_comp
attribute [instance] HasZeroMorphisms.zero
variable {C}
@[simp]
theorem comp_zero [HasZeroMorphisms C] {X Y : C} {f : X ⟶ Y} {Z : C} :
f ≫ (0 : Y ⟶ Z) = (0 : X ⟶ Z) :=
HasZeroMorphisms.comp_zero f Z
#align category_theory.limits.comp_zero CategoryTheory.Limits.comp_zero
@[simp]
theorem zero_comp [HasZeroMorphisms C] {X : C} {Y Z : C} {f : Y ⟶ Z} :
(0 : X ⟶ Y) ≫ f = (0 : X ⟶ Z) :=
HasZeroMorphisms.zero_comp X f
#align category_theory.limits.zero_comp CategoryTheory.Limits.zero_comp
instance hasZeroMorphismsPEmpty : HasZeroMorphisms (Discrete PEmpty) where
zero := by aesop_cat
#align category_theory.limits.has_zero_morphisms_pempty CategoryTheory.Limits.hasZeroMorphismsPEmpty
instance hasZeroMorphismsPUnit : HasZeroMorphisms (Discrete PUnit) where
zero X Y := by repeat (constructor)
#align category_theory.limits.has_zero_morphisms_punit CategoryTheory.Limits.hasZeroMorphismsPUnit
namespace HasZeroMorphisms
/-- This lemma will be immediately superseded by `ext`, below. -/
private theorem ext_aux (I J : HasZeroMorphisms C)
(w : ∀ X Y : C, (I.zero X Y).zero = (J.zero X Y).zero) : I = J := by
have : I.zero = J.zero := by
funext X Y
specialize w X Y
apply congrArg Zero.mk w
cases I; cases J
congr
· apply proof_irrel_heq
· apply proof_irrel_heq
-- Porting note: private def; no align
/-- If you're tempted to use this lemma "in the wild", you should probably
carefully consider whether you've made a mistake in allowing two
instances of `HasZeroMorphisms` to exist at all.
See, particularly, the note on `zeroMorphismsOfZeroObject` below.
-/
theorem ext (I J : HasZeroMorphisms C) : I = J := by
apply ext_aux
intro X Y
have : (I.zero X Y).zero ≫ (J.zero Y Y).zero = (I.zero X Y).zero := by
apply I.zero_comp X (J.zero Y Y).zero
have that : (I.zero X Y).zero ≫ (J.zero Y Y).zero = (J.zero X Y).zero := by
apply J.comp_zero (I.zero X Y).zero Y
rw [← this, ← that]
#align category_theory.limits.has_zero_morphisms.ext CategoryTheory.Limits.HasZeroMorphisms.ext
instance : Subsingleton (HasZeroMorphisms C) :=
⟨ext⟩
end HasZeroMorphisms
open Opposite HasZeroMorphisms
instance hasZeroMorphismsOpposite [HasZeroMorphisms C] : HasZeroMorphisms Cᵒᵖ where
zero X Y := ⟨(0 : unop Y ⟶ unop X).op⟩
comp_zero f Z := congr_arg Quiver.Hom.op (HasZeroMorphisms.zero_comp (unop Z) f.unop)
zero_comp X {Y Z} (f : Y ⟶ Z) :=
congrArg Quiver.Hom.op (HasZeroMorphisms.comp_zero f.unop (unop X))
#align category_theory.limits.has_zero_morphisms_opposite CategoryTheory.Limits.hasZeroMorphismsOpposite
section
variable [HasZeroMorphisms C]
@[simp] lemma op_zero (X Y : C) : (0 : X ⟶ Y).op = 0 := rfl
#align category_theory.op_zero CategoryTheory.Limits.op_zero
@[simp] lemma unop_zero (X Y : Cᵒᵖ) : (0 : X ⟶ Y).unop = 0 := rfl
#align category_theory.unop_zero CategoryTheory.Limits.unop_zero
| Mathlib/CategoryTheory/Limits/Shapes/ZeroMorphisms.lean | 140 | 142 | theorem zero_of_comp_mono {X Y Z : C} {f : X ⟶ Y} (g : Y ⟶ Z) [Mono g] (h : f ≫ g = 0) : f = 0 := by |
rw [← zero_comp, cancel_mono] at h
exact h
|
/-
Copyright (c) 2020 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker, Sébastien Gouëzel, Yury G. Kudryashov, Dylan MacKenzie, Patrick Massot
-/
import Mathlib.Algebra.BigOperators.Module
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Order.Filter.ModEq
import Mathlib.Analysis.Asymptotics.Asymptotics
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Data.List.TFAE
import Mathlib.Analysis.NormedSpace.Basic
#align_import analysis.specific_limits.normed from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
/-!
# A collection of specific limit computations
This file contains important specific limit computations in (semi-)normed groups/rings/spaces, as
well as such computations in `ℝ` when the natural proof passes through a fact about normed spaces.
-/
noncomputable section
open scoped Classical
open Set Function Filter Finset Metric Asymptotics
open scoped Classical
open Topology Nat uniformity NNReal ENNReal
variable {α : Type*} {β : Type*} {ι : Type*}
theorem tendsto_norm_atTop_atTop : Tendsto (norm : ℝ → ℝ) atTop atTop :=
tendsto_abs_atTop_atTop
#align tendsto_norm_at_top_at_top tendsto_norm_atTop_atTop
theorem summable_of_absolute_convergence_real {f : ℕ → ℝ} :
(∃ r, Tendsto (fun n ↦ ∑ i ∈ range n, |f i|) atTop (𝓝 r)) → Summable f
| ⟨r, hr⟩ => by
refine .of_norm ⟨r, (hasSum_iff_tendsto_nat_of_nonneg ?_ _).2 ?_⟩
· exact fun i ↦ norm_nonneg _
· simpa only using hr
#align summable_of_absolute_convergence_real summable_of_absolute_convergence_real
/-! ### Powers -/
theorem tendsto_norm_zero' {𝕜 : Type*} [NormedAddCommGroup 𝕜] :
Tendsto (norm : 𝕜 → ℝ) (𝓝[≠] 0) (𝓝[>] 0) :=
tendsto_norm_zero.inf <| tendsto_principal_principal.2 fun _ hx ↦ norm_pos_iff.2 hx
#align tendsto_norm_zero' tendsto_norm_zero'
namespace NormedField
theorem tendsto_norm_inverse_nhdsWithin_0_atTop {𝕜 : Type*} [NormedDivisionRing 𝕜] :
Tendsto (fun x : 𝕜 ↦ ‖x⁻¹‖) (𝓝[≠] 0) atTop :=
(tendsto_inv_zero_atTop.comp tendsto_norm_zero').congr fun x ↦ (norm_inv x).symm
#align normed_field.tendsto_norm_inverse_nhds_within_0_at_top NormedField.tendsto_norm_inverse_nhdsWithin_0_atTop
| Mathlib/Analysis/SpecificLimits/Normed.lean | 62 | 68 | theorem tendsto_norm_zpow_nhdsWithin_0_atTop {𝕜 : Type*} [NormedDivisionRing 𝕜] {m : ℤ}
(hm : m < 0) :
Tendsto (fun x : 𝕜 ↦ ‖x ^ m‖) (𝓝[≠] 0) atTop := by |
rcases neg_surjective m with ⟨m, rfl⟩
rw [neg_lt_zero] at hm; lift m to ℕ using hm.le; rw [Int.natCast_pos] at hm
simp only [norm_pow, zpow_neg, zpow_natCast, ← inv_pow]
exact (tendsto_pow_atTop hm.ne').comp NormedField.tendsto_norm_inverse_nhdsWithin_0_atTop
|
/-
Copyright (c) 2021 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Degree.Lemmas
import Mathlib.Algebra.Polynomial.HasseDeriv
#align_import data.polynomial.taylor from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
/-!
# Taylor expansions of polynomials
## Main declarations
* `Polynomial.taylor`: the Taylor expansion of the polynomial `f` at `r`
* `Polynomial.taylor_coeff`: the `k`th coefficient of `taylor r f` is
`(Polynomial.hasseDeriv k f).eval r`
* `Polynomial.eq_zero_of_hasseDeriv_eq_zero`:
the identity principle: a polynomial is 0 iff all its Hasse derivatives are zero
-/
noncomputable section
namespace Polynomial
open Polynomial
variable {R : Type*} [Semiring R] (r : R) (f : R[X])
/-- The Taylor expansion of a polynomial `f` at `r`. -/
def taylor (r : R) : R[X] →ₗ[R] R[X] where
toFun f := f.comp (X + C r)
map_add' f g := add_comp
map_smul' c f := by simp only [smul_eq_C_mul, C_mul_comp, RingHom.id_apply]
#align polynomial.taylor Polynomial.taylor
theorem taylor_apply : taylor r f = f.comp (X + C r) :=
rfl
#align polynomial.taylor_apply Polynomial.taylor_apply
@[simp]
theorem taylor_X : taylor r X = X + C r := by simp only [taylor_apply, X_comp]
set_option linter.uppercaseLean3 false in
#align polynomial.taylor_X Polynomial.taylor_X
@[simp]
theorem taylor_C (x : R) : taylor r (C x) = C x := by simp only [taylor_apply, C_comp]
set_option linter.uppercaseLean3 false in
#align polynomial.taylor_C Polynomial.taylor_C
@[simp]
theorem taylor_zero' : taylor (0 : R) = LinearMap.id := by
ext
simp only [taylor_apply, add_zero, comp_X, _root_.map_zero, LinearMap.id_comp,
Function.comp_apply, LinearMap.coe_comp]
#align polynomial.taylor_zero' Polynomial.taylor_zero'
theorem taylor_zero (f : R[X]) : taylor 0 f = f := by rw [taylor_zero', LinearMap.id_apply]
#align polynomial.taylor_zero Polynomial.taylor_zero
@[simp]
theorem taylor_one : taylor r (1 : R[X]) = C 1 := by rw [← C_1, taylor_C]
#align polynomial.taylor_one Polynomial.taylor_one
@[simp]
theorem taylor_monomial (i : ℕ) (k : R) : taylor r (monomial i k) = C k * (X + C r) ^ i := by
simp [taylor_apply]
#align polynomial.taylor_monomial Polynomial.taylor_monomial
/-- The `k`th coefficient of `Polynomial.taylor r f` is `(Polynomial.hasseDeriv k f).eval r`. -/
theorem taylor_coeff (n : ℕ) : (taylor r f).coeff n = (hasseDeriv n f).eval r :=
show (lcoeff R n).comp (taylor r) f = (leval r).comp (hasseDeriv n) f by
congr 1; clear! f; ext i
simp only [leval_apply, mul_one, one_mul, eval_monomial, LinearMap.comp_apply, coeff_C_mul,
hasseDeriv_monomial, taylor_apply, monomial_comp, C_1, (commute_X (C r)).add_pow i,
map_sum]
simp only [lcoeff_apply, ← C_eq_natCast, mul_assoc, ← C_pow, ← C_mul, coeff_mul_C,
(Nat.cast_commute _ _).eq, coeff_X_pow, boole_mul, Finset.sum_ite_eq, Finset.mem_range]
split_ifs with h; · rfl
push_neg at h; rw [Nat.choose_eq_zero_of_lt h, Nat.cast_zero, mul_zero]
#align polynomial.taylor_coeff Polynomial.taylor_coeff
@[simp]
theorem taylor_coeff_zero : (taylor r f).coeff 0 = f.eval r := by
rw [taylor_coeff, hasseDeriv_zero, LinearMap.id_apply]
#align polynomial.taylor_coeff_zero Polynomial.taylor_coeff_zero
@[simp]
theorem taylor_coeff_one : (taylor r f).coeff 1 = f.derivative.eval r := by
rw [taylor_coeff, hasseDeriv_one]
#align polynomial.taylor_coeff_one Polynomial.taylor_coeff_one
@[simp]
theorem natDegree_taylor (p : R[X]) (r : R) : natDegree (taylor r p) = natDegree p := by
refine map_natDegree_eq_natDegree _ ?_
nontriviality R
intro n c c0
simp [taylor_monomial, natDegree_C_mul_eq_of_mul_ne_zero, natDegree_pow_X_add_C, c0]
#align polynomial.nat_degree_taylor Polynomial.natDegree_taylor
@[simp]
| Mathlib/Algebra/Polynomial/Taylor.lean | 106 | 107 | theorem taylor_mul {R} [CommSemiring R] (r : R) (p q : R[X]) :
taylor r (p * q) = taylor r p * taylor r q := by | simp only [taylor_apply, mul_comp]
|
/-
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
Some proofs and docs came from `algebra/commute` (c) Neil Strickland
-/
import Mathlib.Algebra.Group.Semiconj.Defs
import Mathlib.Algebra.Group.Units
#align_import algebra.group.semiconj from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64"
/-!
# Semiconjugate elements of a semigroup
## Main definitions
We say that `x` is semiconjugate to `y` by `a` (`SemiconjBy a x y`), if `a * x = y * a`.
In this file we provide operations on `SemiconjBy _ _ _`.
In the names of these operations, we treat `a` as the “left” argument, and both `x` and `y` as
“right” arguments. This way most names in this file agree with the names of the corresponding lemmas
for `Commute a b = SemiconjBy a b b`. As a side effect, some lemmas have only `_right` version.
Lean does not immediately recognise these terms as equations, so for rewriting we need syntax like
`rw [(h.pow_right 5).eq]` rather than just `rw [h.pow_right 5]`.
This file provides only basic operations (`mul_left`, `mul_right`, `inv_right` etc). Other
operations (`pow_right`, field inverse etc) are in the files that define corresponding notions.
-/
assert_not_exists MonoidWithZero
assert_not_exists DenselyOrdered
open scoped Int
variable {M G : Type*}
namespace SemiconjBy
section Monoid
variable [Monoid M]
/-- If `a` semiconjugates a unit `x` to a unit `y`, then it semiconjugates `x⁻¹` to `y⁻¹`. -/
@[to_additive "If `a` semiconjugates an additive unit `x` to an additive unit `y`, then it
semiconjugates `-x` to `-y`."]
theorem units_inv_right {a : M} {x y : Mˣ} (h : SemiconjBy a x y) : SemiconjBy a ↑x⁻¹ ↑y⁻¹ :=
calc
a * ↑x⁻¹ = ↑y⁻¹ * (y * a) * ↑x⁻¹ := by rw [Units.inv_mul_cancel_left]
_ = ↑y⁻¹ * a := by rw [← h.eq, mul_assoc, Units.mul_inv_cancel_right]
#align semiconj_by.units_inv_right SemiconjBy.units_inv_right
#align add_semiconj_by.add_units_neg_right AddSemiconjBy.addUnits_neg_right
@[to_additive (attr := simp)]
theorem units_inv_right_iff {a : M} {x y : Mˣ} : SemiconjBy a ↑x⁻¹ ↑y⁻¹ ↔ SemiconjBy a x y :=
⟨units_inv_right, units_inv_right⟩
#align semiconj_by.units_inv_right_iff SemiconjBy.units_inv_right_iff
#align add_semiconj_by.add_units_neg_right_iff AddSemiconjBy.addUnits_neg_right_iff
/-- If a unit `a` semiconjugates `x` to `y`, then `a⁻¹` semiconjugates `y` to `x`. -/
@[to_additive "If an additive unit `a` semiconjugates `x` to `y`, then `-a` semiconjugates `y` to
`x`."]
| Mathlib/Algebra/Group/Semiconj/Units.lean | 64 | 67 | theorem units_inv_symm_left {a : Mˣ} {x y : M} (h : SemiconjBy (↑a) x y) : SemiconjBy (↑a⁻¹) y x :=
calc
↑a⁻¹ * y = ↑a⁻¹ * (y * a * ↑a⁻¹) := by | rw [Units.mul_inv_cancel_right]
_ = x * ↑a⁻¹ := by rw [← h.eq, ← mul_assoc, Units.inv_mul_cancel_left]
|
/-
Copyright (c) 2021 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies, Bhavik Mehta
-/
import Mathlib.Combinatorics.SetFamily.Shadow
#align_import combinatorics.set_family.compression.uv from "leanprover-community/mathlib"@"6f8ab7de1c4b78a68ab8cf7dd83d549eb78a68a1"
/-!
# UV-compressions
This file defines UV-compression. It is an operation on a set family that reduces its shadow.
UV-compressing `a : α` along `u v : α` means replacing `a` by `(a ⊔ u) \ v` if `a` and `u` are
disjoint and `v ≤ a`. In some sense, it's moving `a` from `v` to `u`.
UV-compressions are immensely useful to prove the Kruskal-Katona theorem. The idea is that
compressing a set family might decrease the size of its shadow, so iterated compressions hopefully
minimise the shadow.
## Main declarations
* `UV.compress`: `compress u v a` is `a` compressed along `u` and `v`.
* `UV.compression`: `compression u v s` is the compression of the set family `s` along `u` and `v`.
It is the compressions of the elements of `s` whose compression is not already in `s` along with
the element whose compression is already in `s`. This way of splitting into what moves and what
does not ensures the compression doesn't squash the set family, which is proved by
`UV.card_compression`.
* `UV.card_shadow_compression_le`: Compressing reduces the size of the shadow. This is a key fact in
the proof of Kruskal-Katona.
## Notation
`𝓒` (typed with `\MCC`) is notation for `UV.compression` in locale `FinsetFamily`.
## Notes
Even though our emphasis is on `Finset α`, we define UV-compressions more generally in a generalized
boolean algebra, so that one can use it for `Set α`.
## References
* https://github.com/b-mehta/maths-notes/blob/master/iii/mich/combinatorics.pdf
## Tags
compression, UV-compression, shadow
-/
open Finset
variable {α : Type*}
/-- UV-compression is injective on the elements it moves. See `UV.compress`. -/
theorem sup_sdiff_injOn [GeneralizedBooleanAlgebra α] (u v : α) :
{ x | Disjoint u x ∧ v ≤ x }.InjOn fun x => (x ⊔ u) \ v := by
rintro a ha b hb hab
have h : ((a ⊔ u) \ v) \ u ⊔ v = ((b ⊔ u) \ v) \ u ⊔ v := by
dsimp at hab
rw [hab]
rwa [sdiff_sdiff_comm, ha.1.symm.sup_sdiff_cancel_right, sdiff_sdiff_comm,
hb.1.symm.sup_sdiff_cancel_right, sdiff_sup_cancel ha.2, sdiff_sup_cancel hb.2] at h
#align sup_sdiff_inj_on sup_sdiff_injOn
-- The namespace is here to distinguish from other compressions.
namespace UV
/-! ### UV-compression in generalized boolean algebras -/
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α] [DecidableRel (@Disjoint α _ _)]
[DecidableRel ((· ≤ ·) : α → α → Prop)] {s : Finset α} {u v a b : α}
/-- UV-compressing `a` means removing `v` from it and adding `u` if `a` and `u` are disjoint and
`v ≤ a` (it replaces the `v` part of `a` by the `u` part). Else, UV-compressing `a` doesn't do
anything. This is most useful when `u` and `v` are disjoint finsets of the same size. -/
def compress (u v a : α) : α :=
if Disjoint u a ∧ v ≤ a then (a ⊔ u) \ v else a
#align uv.compress UV.compress
theorem compress_of_disjoint_of_le (hua : Disjoint u a) (hva : v ≤ a) :
compress u v a = (a ⊔ u) \ v :=
if_pos ⟨hua, hva⟩
#align uv.compress_of_disjoint_of_le UV.compress_of_disjoint_of_le
theorem compress_of_disjoint_of_le' (hva : Disjoint v a) (hua : u ≤ a) :
compress u v ((a ⊔ v) \ u) = a := by
rw [compress_of_disjoint_of_le disjoint_sdiff_self_right
(le_sdiff.2 ⟨(le_sup_right : v ≤ a ⊔ v), hva.mono_right hua⟩),
sdiff_sup_cancel (le_sup_of_le_left hua), hva.symm.sup_sdiff_cancel_right]
#align uv.compress_of_disjoint_of_le' UV.compress_of_disjoint_of_le'
@[simp]
theorem compress_self (u a : α) : compress u u a = a := by
unfold compress
split_ifs with h
· exact h.1.symm.sup_sdiff_cancel_right
· rfl
#align uv.compress_self UV.compress_self
/-- An element can be compressed to any other element by removing/adding the differences. -/
@[simp]
theorem compress_sdiff_sdiff (a b : α) : compress (a \ b) (b \ a) b = a := by
refine (compress_of_disjoint_of_le disjoint_sdiff_self_left sdiff_le).trans ?_
rw [sup_sdiff_self_right, sup_sdiff, disjoint_sdiff_self_right.sdiff_eq_left, sup_eq_right]
exact sdiff_sdiff_le
#align uv.compress_sdiff_sdiff UV.compress_sdiff_sdiff
/-- Compressing an element is idempotent. -/
@[simp]
| Mathlib/Combinatorics/SetFamily/Compression/UV.lean | 115 | 120 | theorem compress_idem (u v a : α) : compress u v (compress u v a) = compress u v a := by |
unfold compress
split_ifs with h h'
· rw [le_sdiff_iff.1 h'.2, sdiff_bot, sdiff_bot, sup_assoc, sup_idem]
· rfl
· 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.Order.BigOperators.Group.Finset
import Mathlib.Data.Nat.Factors
import Mathlib.Order.Interval.Finset.Nat
#align_import number_theory.divisors from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
/-!
# Divisor Finsets
This file defines sets of divisors of a natural number. This is particularly useful as background
for defining Dirichlet convolution.
## Main Definitions
Let `n : ℕ`. All of the following definitions are in the `Nat` namespace:
* `divisors n` is the `Finset` of natural numbers that divide `n`.
* `properDivisors n` is the `Finset` of natural numbers that divide `n`, other than `n`.
* `divisorsAntidiagonal n` is the `Finset` of pairs `(x,y)` such that `x * y = n`.
* `Perfect n` is true when `n` is positive and the sum of `properDivisors n` is `n`.
## Implementation details
* `divisors 0`, `properDivisors 0`, and `divisorsAntidiagonal 0` are defined to be `∅`.
## Tags
divisors, perfect numbers
-/
open scoped Classical
open Finset
namespace Nat
variable (n : ℕ)
/-- `divisors n` is the `Finset` of divisors of `n`. As a special case, `divisors 0 = ∅`. -/
def divisors : Finset ℕ :=
Finset.filter (fun x : ℕ => x ∣ n) (Finset.Ico 1 (n + 1))
#align nat.divisors Nat.divisors
/-- `properDivisors n` is the `Finset` of divisors of `n`, other than `n`.
As a special case, `properDivisors 0 = ∅`. -/
def properDivisors : Finset ℕ :=
Finset.filter (fun x : ℕ => x ∣ n) (Finset.Ico 1 n)
#align nat.proper_divisors Nat.properDivisors
/-- `divisorsAntidiagonal n` is the `Finset` of pairs `(x,y)` such that `x * y = n`.
As a special case, `divisorsAntidiagonal 0 = ∅`. -/
def divisorsAntidiagonal : Finset (ℕ × ℕ) :=
Finset.filter (fun x => x.fst * x.snd = n) (Ico 1 (n + 1) ×ˢ Ico 1 (n + 1))
#align nat.divisors_antidiagonal Nat.divisorsAntidiagonal
variable {n}
@[simp]
theorem filter_dvd_eq_divisors (h : n ≠ 0) : (Finset.range n.succ).filter (· ∣ n) = n.divisors := by
ext
simp only [divisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self]
exact fun ha _ => succ_le_iff.mpr (pos_of_dvd_of_pos ha h.bot_lt)
#align nat.filter_dvd_eq_divisors Nat.filter_dvd_eq_divisors
@[simp]
theorem filter_dvd_eq_properDivisors (h : n ≠ 0) :
(Finset.range n).filter (· ∣ n) = n.properDivisors := by
ext
simp only [properDivisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self]
exact fun ha _ => succ_le_iff.mpr (pos_of_dvd_of_pos ha h.bot_lt)
#align nat.filter_dvd_eq_proper_divisors Nat.filter_dvd_eq_properDivisors
theorem properDivisors.not_self_mem : ¬n ∈ properDivisors n := by simp [properDivisors]
#align nat.proper_divisors.not_self_mem Nat.properDivisors.not_self_mem
@[simp]
theorem mem_properDivisors {m : ℕ} : n ∈ properDivisors m ↔ n ∣ m ∧ n < m := by
rcases eq_or_ne m 0 with (rfl | hm); · simp [properDivisors]
simp only [and_comm, ← filter_dvd_eq_properDivisors hm, mem_filter, mem_range]
#align nat.mem_proper_divisors Nat.mem_properDivisors
| Mathlib/NumberTheory/Divisors.lean | 84 | 86 | theorem insert_self_properDivisors (h : n ≠ 0) : insert n (properDivisors n) = divisors n := by |
rw [divisors, properDivisors, Ico_succ_right_eq_insert_Ico (one_le_iff_ne_zero.2 h),
Finset.filter_insert, if_pos (dvd_refl n)]
|
/-
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]
| Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean | 142 | 144 | 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
|
/-
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.RingTheory.Polynomial.Basic
import Mathlib.RingTheory.Ideal.LocalRing
#align_import data.polynomial.expand from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821"
/-!
# Expand a polynomial by a factor of p, so `∑ aₙ xⁿ` becomes `∑ aₙ xⁿᵖ`.
## Main definitions
* `Polynomial.expand R p f`: expand the polynomial `f` with coefficients in a
commutative semiring `R` by a factor of p, so `expand R p (∑ aₙ xⁿ)` is `∑ aₙ xⁿᵖ`.
* `Polynomial.contract p f`: the opposite of `expand`, so it sends `∑ aₙ xⁿᵖ` to `∑ aₙ xⁿ`.
-/
universe u v w
open Polynomial
open Finset
namespace Polynomial
section CommSemiring
variable (R : Type u) [CommSemiring R] {S : Type v} [CommSemiring S] (p q : ℕ)
/-- Expand the polynomial by a factor of p, so `∑ aₙ xⁿ` becomes `∑ aₙ xⁿᵖ`. -/
noncomputable def expand : R[X] →ₐ[R] R[X] :=
{ (eval₂RingHom C (X ^ p) : R[X] →+* R[X]) with commutes' := fun _ => eval₂_C _ _ }
#align polynomial.expand Polynomial.expand
theorem coe_expand : (expand R p : R[X] → R[X]) = eval₂ C (X ^ p) :=
rfl
#align polynomial.coe_expand Polynomial.coe_expand
variable {R}
theorem expand_eq_comp_X_pow {f : R[X]} : expand R p f = f.comp (X ^ p) := rfl
theorem expand_eq_sum {f : R[X]} : expand R p f = f.sum fun e a => C a * (X ^ p) ^ e := by
simp [expand, eval₂]
#align polynomial.expand_eq_sum Polynomial.expand_eq_sum
@[simp]
theorem expand_C (r : R) : expand R p (C r) = C r :=
eval₂_C _ _
set_option linter.uppercaseLean3 false in
#align polynomial.expand_C Polynomial.expand_C
@[simp]
theorem expand_X : expand R p X = X ^ p :=
eval₂_X _ _
set_option linter.uppercaseLean3 false in
#align polynomial.expand_X Polynomial.expand_X
@[simp]
theorem expand_monomial (r : R) : expand R p (monomial q r) = monomial (q * p) r := by
simp_rw [← smul_X_eq_monomial, AlgHom.map_smul, AlgHom.map_pow, expand_X, mul_comm, pow_mul]
#align polynomial.expand_monomial Polynomial.expand_monomial
theorem expand_expand (f : R[X]) : expand R p (expand R q f) = expand R (p * q) f :=
Polynomial.induction_on f (fun r => by simp_rw [expand_C])
(fun f g ihf ihg => by simp_rw [AlgHom.map_add, ihf, ihg]) fun n r _ => by
simp_rw [AlgHom.map_mul, expand_C, AlgHom.map_pow, expand_X, AlgHom.map_pow, expand_X, pow_mul]
#align polynomial.expand_expand Polynomial.expand_expand
theorem expand_mul (f : R[X]) : expand R (p * q) f = expand R p (expand R q f) :=
(expand_expand p q f).symm
#align polynomial.expand_mul Polynomial.expand_mul
@[simp]
theorem expand_zero (f : R[X]) : expand R 0 f = C (eval 1 f) := by simp [expand]
#align polynomial.expand_zero Polynomial.expand_zero
@[simp]
theorem expand_one (f : R[X]) : expand R 1 f = f :=
Polynomial.induction_on f (fun r => by rw [expand_C])
(fun f g ihf ihg => by rw [AlgHom.map_add, ihf, ihg]) fun n r _ => by
rw [AlgHom.map_mul, expand_C, AlgHom.map_pow, expand_X, pow_one]
#align polynomial.expand_one Polynomial.expand_one
theorem expand_pow (f : R[X]) : expand R (p ^ q) f = (expand R p)^[q] f :=
Nat.recOn q (by rw [pow_zero, expand_one, Function.iterate_zero, id]) fun n ih => by
rw [Function.iterate_succ_apply', pow_succ', expand_mul, ih]
#align polynomial.expand_pow Polynomial.expand_pow
theorem derivative_expand (f : R[X]) : Polynomial.derivative (expand R p f) =
expand R p (Polynomial.derivative f) * (p * (X ^ (p - 1) : R[X])) := by
rw [coe_expand, derivative_eval₂_C, derivative_pow, C_eq_natCast, derivative_X, mul_one]
#align polynomial.derivative_expand Polynomial.derivative_expand
theorem coeff_expand {p : ℕ} (hp : 0 < p) (f : R[X]) (n : ℕ) :
(expand R p f).coeff n = if p ∣ n then f.coeff (n / p) else 0 := by
simp only [expand_eq_sum]
simp_rw [coeff_sum, ← pow_mul, C_mul_X_pow_eq_monomial, coeff_monomial, sum]
split_ifs with h
· rw [Finset.sum_eq_single (n / p), Nat.mul_div_cancel' h, if_pos rfl]
· intro b _ hb2
rw [if_neg]
intro hb3
apply hb2
rw [← hb3, Nat.mul_div_cancel_left b hp]
· intro hn
rw [not_mem_support_iff.1 hn]
split_ifs <;> rfl
· rw [Finset.sum_eq_zero]
intro k _
rw [if_neg]
exact fun hkn => h ⟨k, hkn.symm⟩
#align polynomial.coeff_expand Polynomial.coeff_expand
@[simp]
| Mathlib/Algebra/Polynomial/Expand.lean | 121 | 123 | theorem coeff_expand_mul {p : ℕ} (hp : 0 < p) (f : R[X]) (n : ℕ) :
(expand R p f).coeff (n * p) = f.coeff n := by |
rw [coeff_expand hp, if_pos (dvd_mul_left _ _), Nat.mul_div_cancel _ hp]
|
/-
Copyright (c) 2020 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash, Antoine Labelle
-/
import Mathlib.LinearAlgebra.Dual
import Mathlib.LinearAlgebra.Matrix.ToLin
#align_import linear_algebra.contraction from "leanprover-community/mathlib"@"657df4339ae6ceada048c8a2980fb10e393143ec"
/-!
# Contractions
Given modules $M, N$ over a commutative ring $R$, this file defines the natural linear maps:
$M^* \otimes M \to R$, $M \otimes M^* \to R$, and $M^* \otimes N → Hom(M, N)$, as well as proving
some basic properties of these maps.
## Tags
contraction, dual module, tensor product
-/
suppress_compilation
-- Porting note: universe metavariables behave oddly
universe w u v₁ v₂ v₃ v₄
variable {ι : Type w} (R : Type u) (M : Type v₁) (N : Type v₂)
(P : Type v₃) (Q : Type v₄)
-- Porting note: we need high priority for this to fire first; not the case in ML3
attribute [local ext high] TensorProduct.ext
section Contraction
open TensorProduct LinearMap Matrix Module
open TensorProduct
section CommSemiring
variable [CommSemiring R]
variable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] [AddCommMonoid Q]
variable [Module R M] [Module R N] [Module R P] [Module R Q]
variable [DecidableEq ι] [Fintype ι] (b : Basis ι R M)
-- Porting note: doesn't like implicit ring in the tensor product
/-- The natural left-handed pairing between a module and its dual. -/
def contractLeft : Module.Dual R M ⊗[R] M →ₗ[R] R :=
(uncurry _ _ _ _).toFun LinearMap.id
#align contract_left contractLeft
-- Porting note: doesn't like implicit ring in the tensor product
/-- The natural right-handed pairing between a module and its dual. -/
def contractRight : M ⊗[R] Module.Dual R M →ₗ[R] R :=
(uncurry _ _ _ _).toFun (LinearMap.flip LinearMap.id)
#align contract_right contractRight
-- Porting note: doesn't like implicit ring in the tensor product
/-- The natural map associating a linear map to the tensor product of two modules. -/
def dualTensorHom : Module.Dual R M ⊗[R] N →ₗ[R] M →ₗ[R] N :=
let M' := Module.Dual R M
(uncurry R M' N (M →ₗ[R] N) : _ → M' ⊗ N →ₗ[R] M →ₗ[R] N) LinearMap.smulRightₗ
#align dual_tensor_hom dualTensorHom
variable {R M N P Q}
@[simp]
theorem contractLeft_apply (f : Module.Dual R M) (m : M) : contractLeft R M (f ⊗ₜ m) = f m :=
rfl
#align contract_left_apply contractLeft_apply
@[simp]
theorem contractRight_apply (f : Module.Dual R M) (m : M) : contractRight R M (m ⊗ₜ f) = f m :=
rfl
#align contract_right_apply contractRight_apply
@[simp]
theorem dualTensorHom_apply (f : Module.Dual R M) (m : M) (n : N) :
dualTensorHom R M N (f ⊗ₜ n) m = f m • n :=
rfl
#align dual_tensor_hom_apply dualTensorHom_apply
@[simp]
| Mathlib/LinearAlgebra/Contraction.lean | 85 | 92 | theorem transpose_dualTensorHom (f : Module.Dual R M) (m : M) :
Dual.transpose (R := R) (dualTensorHom R M M (f ⊗ₜ m)) =
dualTensorHom R _ _ (Dual.eval R M m ⊗ₜ f) := by |
ext f' m'
simp only [Dual.transpose_apply, coe_comp, Function.comp_apply, dualTensorHom_apply,
LinearMap.map_smulₛₗ, RingHom.id_apply, Algebra.id.smul_eq_mul, Dual.eval_apply,
LinearMap.smul_apply]
exact mul_comm _ _
|
/-
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.Algebra.Polynomial.AlgebraMap
import Mathlib.Data.Matrix.Basis
import Mathlib.Data.Matrix.DMatrix
import Mathlib.RingTheory.MatrixAlgebra
#align_import ring_theory.polynomial_algebra from "leanprover-community/mathlib"@"565eb991e264d0db702722b4bde52ee5173c9950"
/-!
# Algebra isomorphism between matrices of polynomials and polynomials of matrices
Given `[CommRing R] [Ring A] [Algebra R A]`
we show `A[X] ≃ₐ[R] (A ⊗[R] R[X])`.
Combining this with the isomorphism `Matrix n n A ≃ₐ[R] (A ⊗[R] Matrix n n R)` proved earlier
in `RingTheory.MatrixAlgebra`, we obtain the algebra isomorphism
```
def matPolyEquiv :
Matrix n n R[X] ≃ₐ[R] (Matrix n n R)[X]
```
which is characterized by
```
coeff (matPolyEquiv m) k i j = coeff (m i j) k
```
We will use this algebra isomorphism to prove the Cayley-Hamilton theorem.
-/
universe u v w
open Polynomial TensorProduct
open Algebra.TensorProduct (algHomOfLinearMapTensorProduct includeLeft)
noncomputable section
variable (R A : Type*)
variable [CommSemiring R]
variable [Semiring A] [Algebra R A]
namespace PolyEquivTensor
/-- (Implementation detail).
The function underlying `A ⊗[R] R[X] →ₐ[R] A[X]`,
as a bilinear function of two arguments.
-/
-- Porting note: was `@[simps apply_apply]`
@[simps! apply_apply]
def toFunBilinear : A →ₗ[A] R[X] →ₗ[R] A[X] :=
LinearMap.toSpanSingleton A _ (aeval (Polynomial.X : A[X])).toLinearMap
#align poly_equiv_tensor.to_fun_bilinear PolyEquivTensor.toFunBilinear
theorem toFunBilinear_apply_eq_sum (a : A) (p : R[X]) :
toFunBilinear R A a p = p.sum fun n r => monomial n (a * algebraMap R A r) := by
simp only [toFunBilinear_apply_apply, aeval_def, eval₂_eq_sum, Polynomial.sum, Finset.smul_sum]
congr with i : 1
rw [← Algebra.smul_def, ← C_mul', mul_smul_comm, C_mul_X_pow_eq_monomial, ← Algebra.commutes,
← Algebra.smul_def, smul_monomial]
#align poly_equiv_tensor.to_fun_bilinear_apply_eq_sum PolyEquivTensor.toFunBilinear_apply_eq_sum
/-- (Implementation detail).
The function underlying `A ⊗[R] R[X] →ₐ[R] A[X]`,
as a linear map.
-/
def toFunLinear : A ⊗[R] R[X] →ₗ[R] A[X] :=
TensorProduct.lift (toFunBilinear R A)
#align poly_equiv_tensor.to_fun_linear PolyEquivTensor.toFunLinear
@[simp]
theorem toFunLinear_tmul_apply (a : A) (p : R[X]) :
toFunLinear R A (a ⊗ₜ[R] p) = toFunBilinear R A a p :=
rfl
#align poly_equiv_tensor.to_fun_linear_tmul_apply PolyEquivTensor.toFunLinear_tmul_apply
-- We apparently need to provide the decidable instance here
-- in order to successfully rewrite by this lemma.
theorem toFunLinear_mul_tmul_mul_aux_1 (p : R[X]) (k : ℕ) (h : Decidable ¬p.coeff k = 0) (a : A) :
ite (¬coeff p k = 0) (a * (algebraMap R A) (coeff p k)) 0 =
a * (algebraMap R A) (coeff p k) := by classical split_ifs <;> simp [*]
#align poly_equiv_tensor.to_fun_linear_mul_tmul_mul_aux_1 PolyEquivTensor.toFunLinear_mul_tmul_mul_aux_1
| Mathlib/RingTheory/PolynomialAlgebra.lean | 85 | 91 | theorem toFunLinear_mul_tmul_mul_aux_2 (k : ℕ) (a₁ a₂ : A) (p₁ p₂ : R[X]) :
a₁ * a₂ * (algebraMap R A) ((p₁ * p₂).coeff k) =
(Finset.antidiagonal k).sum fun x =>
a₁ * (algebraMap R A) (coeff p₁ x.1) * (a₂ * (algebraMap R A) (coeff p₂ x.2)) := by |
simp_rw [mul_assoc, Algebra.commutes, ← Finset.mul_sum, mul_assoc, ← Finset.mul_sum]
congr
simp_rw [Algebra.commutes (coeff p₂ _), coeff_mul, map_sum, RingHom.map_mul]
|
/-
Copyright (c) 2023 Chris Birkbeck. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Birkbeck, Ruben Van de Velde
-/
import Mathlib.Analysis.Calculus.ContDiff.Basic
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Shift
import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
/-!
# One-dimensional iterated derivatives
This file contains a number of further results on `iteratedDerivWithin` that need more imports
than are available in `Mathlib/Analysis/Calculus/IteratedDeriv/Defs.lean`.
-/
variable
{𝕜 : Type*} [NontriviallyNormedField 𝕜]
{F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
{R : Type*} [Semiring R] [Module R F] [SMulCommClass 𝕜 R F] [ContinuousConstSMul R F]
{n : ℕ} {x : 𝕜} {s : Set 𝕜} (hx : x ∈ s) (h : UniqueDiffOn 𝕜 s) {f g : 𝕜 → F}
theorem iteratedDerivWithin_add (hf : ContDiffOn 𝕜 n f s) (hg : ContDiffOn 𝕜 n g s) :
iteratedDerivWithin n (f + g) s x =
iteratedDerivWithin n f s x + iteratedDerivWithin n g s x := by
simp_rw [iteratedDerivWithin, iteratedFDerivWithin_add_apply hf hg h hx,
ContinuousMultilinearMap.add_apply]
| Mathlib/Analysis/Calculus/IteratedDeriv/Lemmas.lean | 30 | 38 | theorem iteratedDerivWithin_congr (hfg : Set.EqOn f g s) :
Set.EqOn (iteratedDerivWithin n f s) (iteratedDerivWithin n g s) s := by |
induction n generalizing f g with
| zero => rwa [iteratedDerivWithin_zero]
| succ n IH =>
intro y hy
have : UniqueDiffWithinAt 𝕜 s y := h.uniqueDiffWithinAt hy
rw [iteratedDerivWithin_succ this, iteratedDerivWithin_succ this]
exact derivWithin_congr (IH hfg) (IH hfg hy)
|
/-
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.Analytic.Basic
import Mathlib.Analysis.Analytic.CPolynomial
import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.ContDiff.Defs
import Mathlib.Analysis.Calculus.FDeriv.Add
#align_import analysis.calculus.fderiv_analytic from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
/-!
# Frechet derivatives of analytic functions.
A function expressible as a power series at a point has a Frechet derivative there.
Also the special case in terms of `deriv` when the domain is 1-dimensional.
As an application, we show that continuous multilinear maps are smooth. We also compute their
iterated derivatives, in `ContinuousMultilinearMap.iteratedFDeriv_eq`.
-/
open Filter Asymptotics
open scoped ENNReal
universe u v
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type u} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
section fderiv
variable {p : FormalMultilinearSeries 𝕜 E F} {r : ℝ≥0∞}
variable {f : E → F} {x : E} {s : Set E}
theorem HasFPowerSeriesAt.hasStrictFDerivAt (h : HasFPowerSeriesAt f p x) :
HasStrictFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p 1)) x := by
refine h.isBigO_image_sub_norm_mul_norm_sub.trans_isLittleO (IsLittleO.of_norm_right ?_)
refine isLittleO_iff_exists_eq_mul.2 ⟨fun y => ‖y - (x, x)‖, ?_, EventuallyEq.rfl⟩
refine (continuous_id.sub continuous_const).norm.tendsto' _ _ ?_
rw [_root_.id, sub_self, norm_zero]
#align has_fpower_series_at.has_strict_fderiv_at HasFPowerSeriesAt.hasStrictFDerivAt
theorem HasFPowerSeriesAt.hasFDerivAt (h : HasFPowerSeriesAt f p x) :
HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p 1)) x :=
h.hasStrictFDerivAt.hasFDerivAt
#align has_fpower_series_at.has_fderiv_at HasFPowerSeriesAt.hasFDerivAt
theorem HasFPowerSeriesAt.differentiableAt (h : HasFPowerSeriesAt f p x) : DifferentiableAt 𝕜 f x :=
h.hasFDerivAt.differentiableAt
#align has_fpower_series_at.differentiable_at HasFPowerSeriesAt.differentiableAt
theorem AnalyticAt.differentiableAt : AnalyticAt 𝕜 f x → DifferentiableAt 𝕜 f x
| ⟨_, hp⟩ => hp.differentiableAt
#align analytic_at.differentiable_at AnalyticAt.differentiableAt
theorem AnalyticAt.differentiableWithinAt (h : AnalyticAt 𝕜 f x) : DifferentiableWithinAt 𝕜 f s x :=
h.differentiableAt.differentiableWithinAt
#align analytic_at.differentiable_within_at AnalyticAt.differentiableWithinAt
theorem HasFPowerSeriesAt.fderiv_eq (h : HasFPowerSeriesAt f p x) :
fderiv 𝕜 f x = continuousMultilinearCurryFin1 𝕜 E F (p 1) :=
h.hasFDerivAt.fderiv
#align has_fpower_series_at.fderiv_eq HasFPowerSeriesAt.fderiv_eq
theorem HasFPowerSeriesOnBall.differentiableOn [CompleteSpace F]
(h : HasFPowerSeriesOnBall f p x r) : DifferentiableOn 𝕜 f (EMetric.ball x r) := fun _ hy =>
(h.analyticAt_of_mem hy).differentiableWithinAt
#align has_fpower_series_on_ball.differentiable_on HasFPowerSeriesOnBall.differentiableOn
theorem AnalyticOn.differentiableOn (h : AnalyticOn 𝕜 f s) : DifferentiableOn 𝕜 f s := fun y hy =>
(h y hy).differentiableWithinAt
#align analytic_on.differentiable_on AnalyticOn.differentiableOn
theorem HasFPowerSeriesOnBall.hasFDerivAt [CompleteSpace F] (h : HasFPowerSeriesOnBall f p x r)
{y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) :
HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1)) (x + y) :=
(h.changeOrigin hy).hasFPowerSeriesAt.hasFDerivAt
#align has_fpower_series_on_ball.has_fderiv_at HasFPowerSeriesOnBall.hasFDerivAt
theorem HasFPowerSeriesOnBall.fderiv_eq [CompleteSpace F] (h : HasFPowerSeriesOnBall f p x r)
{y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) :
fderiv 𝕜 f (x + y) = continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1) :=
(h.hasFDerivAt hy).fderiv
#align has_fpower_series_on_ball.fderiv_eq HasFPowerSeriesOnBall.fderiv_eq
/-- If a function has a power series on a ball, then so does its derivative. -/
| Mathlib/Analysis/Calculus/FDeriv/Analytic.lean | 91 | 101 | theorem HasFPowerSeriesOnBall.fderiv [CompleteSpace F] (h : HasFPowerSeriesOnBall f p x r) :
HasFPowerSeriesOnBall (fderiv 𝕜 f) p.derivSeries x r := by |
refine .congr (f := fun z ↦ continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin (z - x) 1)) ?_
fun z hz ↦ ?_
· refine continuousMultilinearCurryFin1 𝕜 E F
|>.toContinuousLinearEquiv.toContinuousLinearMap.comp_hasFPowerSeriesOnBall ?_
simpa using ((p.hasFPowerSeriesOnBall_changeOrigin 1
(h.r_pos.trans_le h.r_le)).mono h.r_pos h.r_le).comp_sub x
dsimp only
rw [← h.fderiv_eq, add_sub_cancel]
simpa only [edist_eq_coe_nnnorm_sub, EMetric.mem_ball] using hz
|
/-
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.Algebra.Order.Field.Power
import Mathlib.Data.Int.LeastGreatest
import Mathlib.Data.Rat.Floor
import Mathlib.Data.NNRat.Defs
#align_import algebra.order.archimedean from "leanprover-community/mathlib"@"6f413f3f7330b94c92a5a27488fdc74e6d483a78"
/-!
# Archimedean groups and fields.
This file defines the archimedean property for ordered groups and proves several results connected
to this notion. Being archimedean means that for all elements `x` and `y>0` there exists a natural
number `n` such that `x ≤ n • y`.
## Main definitions
* `Archimedean` is a typeclass for an ordered additive commutative monoid to have the archimedean
property.
* `Archimedean.floorRing` defines a floor function on an archimedean linearly ordered ring making
it into a `floorRing`.
## Main statements
* `ℕ`, `ℤ`, and `ℚ` are archimedean.
-/
open Int Set
variable {α : Type*}
/-- An ordered additive commutative monoid is called `Archimedean` if for any two elements `x`, `y`
such that `0 < y`, there exists a natural number `n` such that `x ≤ n • y`. -/
class Archimedean (α) [OrderedAddCommMonoid α] : Prop where
/-- For any two elements `x`, `y` such that `0 < y`, there exists a natural number `n`
such that `x ≤ n • y`. -/
arch : ∀ (x : α) {y : α}, 0 < y → ∃ n : ℕ, x ≤ n • y
#align archimedean Archimedean
instance OrderDual.archimedean [OrderedAddCommGroup α] [Archimedean α] : Archimedean αᵒᵈ :=
⟨fun x y hy =>
let ⟨n, hn⟩ := Archimedean.arch (-ofDual x) (neg_pos.2 hy)
⟨n, by rwa [neg_nsmul, neg_le_neg_iff] at hn⟩⟩
#align order_dual.archimedean OrderDual.archimedean
variable {M : Type*}
theorem exists_lt_nsmul [OrderedAddCommMonoid M] [Archimedean M]
[CovariantClass M M (· + ·) (· < ·)] {a : M} (ha : 0 < a) (b : M) :
∃ n : ℕ, b < n • a :=
let ⟨k, hk⟩ := Archimedean.arch b ha
⟨k + 1, hk.trans_lt <| nsmul_lt_nsmul_left ha k.lt_succ_self⟩
section LinearOrderedAddCommGroup
variable [LinearOrderedAddCommGroup α] [Archimedean α]
/-- An archimedean decidable linearly ordered `AddCommGroup` has a version of the floor: for
`a > 0`, any `g` in the group lies between some two consecutive multiples of `a`. -/
theorem existsUnique_zsmul_near_of_pos {a : α} (ha : 0 < a) (g : α) :
∃! k : ℤ, k • a ≤ g ∧ g < (k + 1) • a := by
let s : Set ℤ := { n : ℤ | n • a ≤ g }
obtain ⟨k, hk : -g ≤ k • a⟩ := Archimedean.arch (-g) ha
have h_ne : s.Nonempty := ⟨-k, by simpa [s] using neg_le_neg hk⟩
obtain ⟨k, hk⟩ := Archimedean.arch g ha
have h_bdd : ∀ n ∈ s, n ≤ (k : ℤ) := by
intro n hn
apply (zsmul_le_zsmul_iff ha).mp
rw [← natCast_zsmul] at hk
exact le_trans hn hk
obtain ⟨m, hm, hm'⟩ := Int.exists_greatest_of_bdd ⟨k, h_bdd⟩ h_ne
have hm'' : g < (m + 1) • a := by
contrapose! hm'
exact ⟨m + 1, hm', lt_add_one _⟩
refine ⟨m, ⟨hm, hm''⟩, fun n hn => (hm' n hn.1).antisymm <| Int.le_of_lt_add_one ?_⟩
rw [← zsmul_lt_zsmul_iff ha]
exact lt_of_le_of_lt hm hn.2
#align exists_unique_zsmul_near_of_pos existsUnique_zsmul_near_of_pos
| Mathlib/Algebra/Order/Archimedean.lean | 84 | 87 | theorem existsUnique_zsmul_near_of_pos' {a : α} (ha : 0 < a) (g : α) :
∃! k : ℤ, 0 ≤ g - k • a ∧ g - k • a < a := by |
simpa only [sub_nonneg, add_zsmul, one_zsmul, sub_lt_iff_lt_add'] using
existsUnique_zsmul_near_of_pos ha g
|
/-
Copyright (c) 2021 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-/
import Mathlib.Analysis.InnerProductSpace.Rayleigh
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Algebra.DirectSum.Decomposition
import Mathlib.LinearAlgebra.Eigenspace.Minpoly
#align_import analysis.inner_product_space.spectrum from "leanprover-community/mathlib"@"6b0169218d01f2837d79ea2784882009a0da1aa1"
/-! # Spectral theory of self-adjoint operators
This file covers the spectral theory of self-adjoint operators on an inner product space.
The first part of the file covers general properties, true without any condition on boundedness or
compactness of the operator or finite-dimensionality of the underlying space, notably:
* `LinearMap.IsSymmetric.conj_eigenvalue_eq_self`: the eigenvalues are real
* `LinearMap.IsSymmetric.orthogonalFamily_eigenspaces`: the eigenspaces are orthogonal
* `LinearMap.IsSymmetric.orthogonalComplement_iSup_eigenspaces`: the restriction of the operator to
the mutual orthogonal complement of the eigenspaces has, itself, no eigenvectors
The second part of the file covers properties of self-adjoint operators in finite dimension.
Letting `T` be a self-adjoint operator on a finite-dimensional inner product space `T`,
* The definition `LinearMap.IsSymmetric.diagonalization` provides a linear isometry equivalence `E`
to the direct sum of the eigenspaces of `T`. The theorem
`LinearMap.IsSymmetric.diagonalization_apply_self_apply` states that, when `T` is transferred via
this equivalence to an operator on the direct sum, it acts diagonally.
* The definition `LinearMap.IsSymmetric.eigenvectorBasis` provides an orthonormal basis for `E`
consisting of eigenvectors of `T`, with `LinearMap.IsSymmetric.eigenvalues` giving the
corresponding list of eigenvalues, as real numbers. The definition
`LinearMap.IsSymmetric.eigenvectorBasis` gives the associated linear isometry equivalence
from `E` to Euclidean space, and the theorem
`LinearMap.IsSymmetric.eigenvectorBasis_apply_self_apply` states that, when `T` is
transferred via this equivalence to an operator on Euclidean space, it acts diagonally.
These are forms of the *diagonalization theorem* for self-adjoint operators on finite-dimensional
inner product spaces.
## TODO
Spectral theory for compact self-adjoint operators, bounded self-adjoint operators.
## Tags
self-adjoint operator, spectral theorem, diagonalization theorem
-/
variable {𝕜 : Type*} [RCLike 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => @inner 𝕜 E _ x y
open scoped ComplexConjugate
open Module.End
namespace LinearMap
namespace IsSymmetric
variable {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric)
/-- A self-adjoint operator preserves orthogonal complements of its eigenspaces. -/
theorem invariant_orthogonalComplement_eigenspace (μ : 𝕜) (v : E) (hv : v ∈ (eigenspace T μ)ᗮ) :
T v ∈ (eigenspace T μ)ᗮ := by
intro w hw
have : T w = (μ : 𝕜) • w := by rwa [mem_eigenspace_iff] at hw
simp [← hT w, this, inner_smul_left, hv w hw]
#align linear_map.is_symmetric.invariant_orthogonal_eigenspace LinearMap.IsSymmetric.invariant_orthogonalComplement_eigenspace
/-- The eigenvalues of a self-adjoint operator are real. -/
theorem conj_eigenvalue_eq_self {μ : 𝕜} (hμ : HasEigenvalue T μ) : conj μ = μ := by
obtain ⟨v, hv₁, hv₂⟩ := hμ.exists_hasEigenvector
rw [mem_eigenspace_iff] at hv₁
simpa [hv₂, inner_smul_left, inner_smul_right, hv₁] using hT v v
#align linear_map.is_symmetric.conj_eigenvalue_eq_self LinearMap.IsSymmetric.conj_eigenvalue_eq_self
/-- The eigenspaces of a self-adjoint operator are mutually orthogonal. -/
theorem orthogonalFamily_eigenspaces :
OrthogonalFamily 𝕜 (fun μ => eigenspace T μ) fun μ => (eigenspace T μ).subtypeₗᵢ := by
rintro μ ν hμν ⟨v, hv⟩ ⟨w, hw⟩
by_cases hv' : v = 0
· simp [hv']
have H := hT.conj_eigenvalue_eq_self (hasEigenvalue_of_hasEigenvector ⟨hv, hv'⟩)
rw [mem_eigenspace_iff] at hv hw
refine Or.resolve_left ?_ hμν.symm
simpa [inner_smul_left, inner_smul_right, hv, hw, H] using (hT v w).symm
#align linear_map.is_symmetric.orthogonal_family_eigenspaces LinearMap.IsSymmetric.orthogonalFamily_eigenspaces
theorem orthogonalFamily_eigenspaces' :
OrthogonalFamily 𝕜 (fun μ : Eigenvalues T => eigenspace T μ) fun μ =>
(eigenspace T μ).subtypeₗᵢ :=
hT.orthogonalFamily_eigenspaces.comp Subtype.coe_injective
#align linear_map.is_symmetric.orthogonal_family_eigenspaces' LinearMap.IsSymmetric.orthogonalFamily_eigenspaces'
/-- The mutual orthogonal complement of the eigenspaces of a self-adjoint operator on an inner
product space is an invariant subspace of the operator. -/
| Mathlib/Analysis/InnerProductSpace/Spectrum.lean | 102 | 105 | theorem orthogonalComplement_iSup_eigenspaces_invariant ⦃v : E⦄ (hv : v ∈ (⨆ μ, eigenspace T μ)ᗮ) :
T v ∈ (⨆ μ, eigenspace T μ)ᗮ := by |
rw [← Submodule.iInf_orthogonal] at hv ⊢
exact T.iInf_invariant hT.invariant_orthogonalComplement_eigenspace v hv
|
/-
Copyright (c) 2020 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Anne Baanen
-/
import Mathlib.Algebra.Algebra.Equiv
import Mathlib.LinearAlgebra.Span
#align_import algebra.algebra.tower from "leanprover-community/mathlib"@"71150516f28d9826c7341f8815b31f7d8770c212"
/-!
# Towers of algebras
In this file we prove basic facts about towers of algebra.
An algebra tower A/S/R is expressed by having instances of `Algebra A S`,
`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the
compatibility condition `(r • s) • a = r • (s • a)`.
An important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.
-/
open Pointwise
universe u v w u₁ v₁
variable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)
namespace Algebra
variable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]
variable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]
variable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]
variable {A}
/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`
on the `B`-module `M`.
This is a stronger version of `DistribMulAction.toLinearMap`, and could also have been
called `Algebra.toModuleEnd`.
The typeclasses correspond to the situation where the types act on each other as
```
R ----→ B
| ⟍ |
| ⟍ |
↓ ↘ ↓
A ----→ M
```
where the diagram commutes, the action by `R` commutes with everything, and the action by `A` and
`B` on `M` commute.
Typically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.
However this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and
vice versa, as
```lean
example : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A
example : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A
```
respectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.
-/
def lsmul : A →ₐ[R] Module.End B M where
toFun := DistribMulAction.toLinearMap B M
map_one' := LinearMap.ext fun _ => one_smul A _
map_mul' a b := LinearMap.ext <| smul_assoc a b
map_zero' := LinearMap.ext fun _ => zero_smul A _
map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _
commutes' r := LinearMap.ext <| algebraMap_smul A r
#align algebra.lsmul Algebra.lsmulₓ
@[simp]
theorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl
#align algebra.lsmul_coe Algebra.lsmul_coe
end Algebra
namespace IsScalarTower
section Module
variable [CommSemiring R] [Semiring A] [Algebra R A]
variable [MulAction A M]
variable {R} {M}
theorem algebraMap_smul [SMul R M] [IsScalarTower R A M] (r : R) (x : M) :
algebraMap R A r • x = r • x := by
rw [Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]
#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul
variable {A} in
| Mathlib/Algebra/Algebra/Tower.lean | 94 | 96 | theorem of_algebraMap_smul [SMul R M] (h : ∀ (r : R) (x : M), algebraMap R A r • x = r • x) :
IsScalarTower R A M where
smul_assoc r a x := by | rw [Algebra.smul_def, mul_smul, h]
|
/-
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.RingTheory.Adjoin.FG
#align_import ring_theory.adjoin.tower from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
/-!
# Adjoining elements and being finitely generated in an algebra tower
## Main results
* `Algebra.fg_trans'`: if `S` is finitely generated as `R`-algebra and `A` as `S`-algebra,
then `A` is finitely generated as `R`-algebra
* `fg_of_fg_of_fg`: **Artin--Tate lemma**: if C/B/A is a tower of rings, and A is noetherian, and
C is algebra-finite over A, and C is module-finite over B, then B is algebra-finite over A.
-/
open Pointwise
universe u v w u₁
variable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁)
namespace Algebra
theorem adjoin_restrictScalars (C D E : Type*) [CommSemiring C] [CommSemiring D] [CommSemiring E]
[Algebra C D] [Algebra C E] [Algebra D E] [IsScalarTower C D E] (S : Set E) :
(Algebra.adjoin D S).restrictScalars C =
(Algebra.adjoin ((⊤ : Subalgebra C D).map (IsScalarTower.toAlgHom C D E)) S).restrictScalars
C := by
suffices
Set.range (algebraMap D E) =
Set.range (algebraMap ((⊤ : Subalgebra C D).map (IsScalarTower.toAlgHom C D E)) E) by
ext x
change x ∈ Subsemiring.closure (_ ∪ S) ↔ x ∈ Subsemiring.closure (_ ∪ S)
rw [this]
ext x
constructor
· rintro ⟨y, hy⟩
exact ⟨⟨algebraMap D E y, ⟨y, ⟨Algebra.mem_top, rfl⟩⟩⟩, hy⟩
· rintro ⟨⟨y, ⟨z, ⟨h0, h1⟩⟩⟩, h2⟩
exact ⟨z, Eq.trans h1 h2⟩
#align algebra.adjoin_restrict_scalars Algebra.adjoin_restrictScalars
| Mathlib/RingTheory/Adjoin/Tower.lean | 49 | 58 | theorem adjoin_res_eq_adjoin_res (C D E F : Type*) [CommSemiring C] [CommSemiring D]
[CommSemiring E] [CommSemiring F] [Algebra C D] [Algebra C E] [Algebra C F] [Algebra D F]
[Algebra E F] [IsScalarTower C D F] [IsScalarTower C E F] {S : Set D} {T : Set E}
(hS : Algebra.adjoin C S = ⊤) (hT : Algebra.adjoin C T = ⊤) :
(Algebra.adjoin E (algebraMap D F '' S)).restrictScalars C =
(Algebra.adjoin D (algebraMap E F '' T)).restrictScalars C := by |
rw [adjoin_restrictScalars C E, adjoin_restrictScalars C D, ← hS, ← hT, ← Algebra.adjoin_image,
← Algebra.adjoin_image, ← AlgHom.coe_toRingHom, ← AlgHom.coe_toRingHom,
IsScalarTower.coe_toAlgHom, IsScalarTower.coe_toAlgHom, ← adjoin_union_eq_adjoin_adjoin, ←
adjoin_union_eq_adjoin_adjoin, Set.union_comm]
|
/-
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.Data.Finset.Grade
import Mathlib.Order.Interval.Finset.Basic
#align_import data.finset.interval from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90"
/-!
# Intervals of finsets as finsets
This file provides the `LocallyFiniteOrder` instance for `Finset α` and calculates the cardinality
of finite intervals of finsets.
If `s t : Finset α`, then `Finset.Icc s t` is the finset of finsets which include `s` and are
included in `t`. For example,
`Finset.Icc {0, 1} {0, 1, 2, 3} = {{0, 1}, {0, 1, 2}, {0, 1, 3}, {0, 1, 2, 3}}`
and
`Finset.Icc {0, 1, 2} {0, 1, 3} = {}`.
In addition, this file gives characterizations of monotone and strictly monotone functions
out of `Finset α` in terms of `Finset.insert`
-/
variable {α β : Type*}
namespace Finset
section Decidable
variable [DecidableEq α] (s t : Finset α)
instance instLocallyFiniteOrder : LocallyFiniteOrder (Finset α) where
finsetIcc s t := t.powerset.filter (s ⊆ ·)
finsetIco s t := t.ssubsets.filter (s ⊆ ·)
finsetIoc s t := t.powerset.filter (s ⊂ ·)
finsetIoo s t := t.ssubsets.filter (s ⊂ ·)
finset_mem_Icc s t u := by
rw [mem_filter, mem_powerset]
exact and_comm
finset_mem_Ico s t u := by
rw [mem_filter, mem_ssubsets]
exact and_comm
finset_mem_Ioc s t u := by
rw [mem_filter, mem_powerset]
exact and_comm
finset_mem_Ioo s t u := by
rw [mem_filter, mem_ssubsets]
exact and_comm
theorem Icc_eq_filter_powerset : Icc s t = t.powerset.filter (s ⊆ ·) :=
rfl
#align finset.Icc_eq_filter_powerset Finset.Icc_eq_filter_powerset
theorem Ico_eq_filter_ssubsets : Ico s t = t.ssubsets.filter (s ⊆ ·) :=
rfl
#align finset.Ico_eq_filter_ssubsets Finset.Ico_eq_filter_ssubsets
theorem Ioc_eq_filter_powerset : Ioc s t = t.powerset.filter (s ⊂ ·) :=
rfl
#align finset.Ioc_eq_filter_powerset Finset.Ioc_eq_filter_powerset
theorem Ioo_eq_filter_ssubsets : Ioo s t = t.ssubsets.filter (s ⊂ ·) :=
rfl
#align finset.Ioo_eq_filter_ssubsets Finset.Ioo_eq_filter_ssubsets
theorem Iic_eq_powerset : Iic s = s.powerset :=
filter_true_of_mem fun t _ => empty_subset t
#align finset.Iic_eq_powerset Finset.Iic_eq_powerset
theorem Iio_eq_ssubsets : Iio s = s.ssubsets :=
filter_true_of_mem fun t _ => empty_subset t
#align finset.Iio_eq_ssubsets Finset.Iio_eq_ssubsets
variable {s t}
| Mathlib/Data/Finset/Interval.lean | 80 | 87 | theorem Icc_eq_image_powerset (h : s ⊆ t) : Icc s t = (t \ s).powerset.image (s ∪ ·) := by |
ext u
simp_rw [mem_Icc, mem_image, mem_powerset]
constructor
· rintro ⟨hs, ht⟩
exact ⟨u \ s, sdiff_le_sdiff_right ht, sup_sdiff_cancel_right hs⟩
· rintro ⟨v, hv, rfl⟩
exact ⟨le_sup_left, union_subset h <| hv.trans sdiff_subset⟩
|
/-
Copyright (c) 2014 Robert Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Data.Finset.Lattice
import Mathlib.Data.Fintype.Card
#align_import algebra.order.field.pi from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# Lemmas about (finite domain) functions into fields.
We split this from `Algebra.Order.Field.Basic` to avoid importing the finiteness hierarchy there.
-/
variable {α ι : Type*} [LinearOrderedSemifield α]
| Mathlib/Algebra/Order/Field/Pi.lean | 21 | 31 | theorem Pi.exists_forall_pos_add_lt [ExistsAddOfLE α] [Finite ι] {x y : ι → α}
(h : ∀ i, x i < y i) : ∃ ε, 0 < ε ∧ ∀ i, x i + ε < y i := by |
cases nonempty_fintype ι
cases isEmpty_or_nonempty ι
· exact ⟨1, zero_lt_one, isEmptyElim⟩
choose ε hε hxε using fun i => exists_pos_add_of_lt' (h i)
obtain rfl : x + ε = y := funext hxε
have hε : 0 < Finset.univ.inf' Finset.univ_nonempty ε := (Finset.lt_inf'_iff _).2 fun i _ => hε _
exact
⟨_, half_pos hε, fun i =>
add_lt_add_left ((half_lt_self hε).trans_le <| Finset.inf'_le _ <| Finset.mem_univ _) _⟩
|
/-
Copyright (c) 2019 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Scott Morrison
-/
import Mathlib.Algebra.Order.Hom.Monoid
import Mathlib.SetTheory.Game.Ordinal
#align_import set_theory.surreal.basic from "leanprover-community/mathlib"@"8900d545017cd21961daa2a1734bb658ef52c618"
/-!
# Surreal numbers
The basic theory of surreal numbers, built on top of the theory of combinatorial (pre-)games.
A pregame is `Numeric` if all the Left options are strictly smaller than all the Right options, and
all those options are themselves numeric. In terms of combinatorial games, the numeric games have
"frozen"; you can only make your position worse by playing, and Left is some definite "number" of
moves ahead (or behind) Right.
A surreal number is an equivalence class of numeric pregames.
In fact, the surreals form a complete ordered field, containing a copy of the reals (and much else
besides!) but we do not yet have a complete development.
## Order properties
Surreal numbers inherit the relations `≤` and `<` from games (`Surreal.instLE` and
`Surreal.instLT`), and these relations satisfy the axioms of a partial order.
## Algebraic operations
We show that the surreals form a linear ordered commutative group.
One can also map all the ordinals into the surreals!
### Multiplication of surreal numbers
The proof that multiplication lifts to surreal numbers is surprisingly difficult and is currently
missing in the library. A sample proof can be found in Theorem 3.8 in the second reference below.
The difficulty lies in the length of the proof and the number of theorems that need to proven
simultaneously. This will make for a fun and challenging project.
The branch `surreal_mul` contains some progress on this proof.
### Todo
- Define the field structure on the surreals.
## References
* [Conway, *On numbers and games*][conway2001]
* [Schleicher, Stoll, *An introduction to Conway's games and numbers*][schleicher_stoll]
-/
universe u
namespace SetTheory
open scoped PGame
namespace PGame
/-- A pre-game is numeric if everything in the L set is less than everything in the R set,
and all the elements of L and R are also numeric. -/
def Numeric : PGame → Prop
| ⟨_, _, L, R⟩ => (∀ i j, L i < R j) ∧ (∀ i, Numeric (L i)) ∧ ∀ j, Numeric (R j)
#align pgame.numeric SetTheory.PGame.Numeric
theorem numeric_def {x : PGame} :
Numeric x ↔
(∀ i j, x.moveLeft i < x.moveRight j) ∧
(∀ i, Numeric (x.moveLeft i)) ∧ ∀ j, Numeric (x.moveRight j) := by
cases x; rfl
#align pgame.numeric_def SetTheory.PGame.numeric_def
namespace Numeric
theorem mk {x : PGame} (h₁ : ∀ i j, x.moveLeft i < x.moveRight j) (h₂ : ∀ i, Numeric (x.moveLeft i))
(h₃ : ∀ j, Numeric (x.moveRight j)) : Numeric x :=
numeric_def.2 ⟨h₁, h₂, h₃⟩
#align pgame.numeric.mk SetTheory.PGame.Numeric.mk
| Mathlib/SetTheory/Surreal/Basic.lean | 85 | 86 | theorem left_lt_right {x : PGame} (o : Numeric x) (i : x.LeftMoves) (j : x.RightMoves) :
x.moveLeft i < x.moveRight j := by | cases x; exact o.1 i j
|
/-
Copyright (c) 2021 Ashwin Iyengar. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kevin Buzzard, Johan Commelin, Ashwin Iyengar, Patrick Massot
-/
import Mathlib.Algebra.Group.Subgroup.Basic
import Mathlib.Topology.Algebra.OpenSubgroup
import Mathlib.Topology.Algebra.Ring.Basic
#align_import topology.algebra.nonarchimedean.basic from "leanprover-community/mathlib"@"83f81aea33931a1edb94ce0f32b9a5d484de6978"
/-!
# Nonarchimedean Topology
In this file we set up the theory of nonarchimedean topological groups and rings.
A nonarchimedean group is a topological group whose topology admits a basis of
open neighborhoods of the identity element in the group consisting of open subgroups.
A nonarchimedean ring is a topological ring whose underlying topological (additive)
group is nonarchimedean.
## Definitions
- `NonarchimedeanAddGroup`: nonarchimedean additive group.
- `NonarchimedeanGroup`: nonarchimedean multiplicative group.
- `NonarchimedeanRing`: nonarchimedean ring.
-/
open scoped Pointwise Topology
/-- A topological additive group is nonarchimedean if every neighborhood of 0
contains an open subgroup. -/
class NonarchimedeanAddGroup (G : Type*) [AddGroup G] [TopologicalSpace G] extends
TopologicalAddGroup G : Prop where
is_nonarchimedean : ∀ U ∈ 𝓝 (0 : G), ∃ V : OpenAddSubgroup G, (V : Set G) ⊆ U
#align nonarchimedean_add_group NonarchimedeanAddGroup
/-- A topological group is nonarchimedean if every neighborhood of 1 contains an open subgroup. -/
@[to_additive]
class NonarchimedeanGroup (G : Type*) [Group G] [TopologicalSpace G] extends TopologicalGroup G :
Prop where
is_nonarchimedean : ∀ U ∈ 𝓝 (1 : G), ∃ V : OpenSubgroup G, (V : Set G) ⊆ U
#align nonarchimedean_group NonarchimedeanGroup
/-- A topological ring is nonarchimedean if its underlying topological additive
group is nonarchimedean. -/
class NonarchimedeanRing (R : Type*) [Ring R] [TopologicalSpace R] extends TopologicalRing R :
Prop where
is_nonarchimedean : ∀ U ∈ 𝓝 (0 : R), ∃ V : OpenAddSubgroup R, (V : Set R) ⊆ U
#align nonarchimedean_ring NonarchimedeanRing
-- see Note [lower instance priority]
/-- Every nonarchimedean ring is naturally a nonarchimedean additive group. -/
instance (priority := 100) NonarchimedeanRing.to_nonarchimedeanAddGroup (R : Type*) [Ring R]
[TopologicalSpace R] [t : NonarchimedeanRing R] : NonarchimedeanAddGroup R :=
{ t with }
#align nonarchimedean_ring.to_nonarchimedean_add_group NonarchimedeanRing.to_nonarchimedeanAddGroup
namespace NonarchimedeanGroup
variable {G : Type*} [Group G] [TopologicalSpace G] [NonarchimedeanGroup G]
variable {H : Type*} [Group H] [TopologicalSpace H] [TopologicalGroup H]
variable {K : Type*} [Group K] [TopologicalSpace K] [NonarchimedeanGroup K]
/-- If a topological group embeds into a nonarchimedean group, then it is nonarchimedean. -/
@[to_additive]
theorem nonarchimedean_of_emb (f : G →* H) (emb : OpenEmbedding f) : NonarchimedeanGroup H :=
{ is_nonarchimedean := fun U hU =>
have h₁ : f ⁻¹' U ∈ 𝓝 (1 : G) := by
apply emb.continuous.tendsto
rwa [f.map_one]
let ⟨V, hV⟩ := is_nonarchimedean (f ⁻¹' U) h₁
⟨{ Subgroup.map f V with isOpen' := emb.isOpenMap _ V.isOpen }, Set.image_subset_iff.2 hV⟩ }
#align nonarchimedean_group.nonarchimedean_of_emb NonarchimedeanGroup.nonarchimedean_of_emb
#align nonarchimedean_add_group.nonarchimedean_of_emb NonarchimedeanAddGroup.nonarchimedean_of_emb
/-- An open neighborhood of the identity in the cartesian product of two nonarchimedean groups
contains the cartesian product of an open neighborhood in each group. -/
@[to_additive NonarchimedeanAddGroup.prod_subset "An open neighborhood of the identity in
the cartesian product of two nonarchimedean groups contains the cartesian product of
an open neighborhood in each group."]
| Mathlib/Topology/Algebra/Nonarchimedean/Basic.lean | 84 | 93 | theorem prod_subset {U} (hU : U ∈ 𝓝 (1 : G × K)) :
∃ (V : OpenSubgroup G) (W : OpenSubgroup K), (V : Set G) ×ˢ (W : Set K) ⊆ U := by |
erw [nhds_prod_eq, Filter.mem_prod_iff] at hU
rcases hU with ⟨U₁, hU₁, U₂, hU₂, h⟩
cases' is_nonarchimedean _ hU₁ with V hV
cases' is_nonarchimedean _ hU₂ with W hW
use V; use W
rw [Set.prod_subset_iff]
intro x hX y hY
exact Set.Subset.trans (Set.prod_mono hV hW) h (Set.mem_sep hX hY)
|
/-
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.SetTheory.Cardinal.Ordinal
#align_import set_theory.cardinal.continuum from "leanprover-community/mathlib"@"e08a42b2dd544cf11eba72e5fc7bf199d4349925"
/-!
# Cardinality of continuum
In this file we define `Cardinal.continuum` (notation: `𝔠`, localized in `Cardinal`) to be `2 ^ ℵ₀`.
We also prove some `simp` lemmas about cardinal arithmetic involving `𝔠`.
## Notation
- `𝔠` : notation for `Cardinal.continuum` in locale `Cardinal`.
-/
namespace Cardinal
universe u v
open Cardinal
/-- Cardinality of continuum. -/
def continuum : Cardinal.{u} :=
2 ^ ℵ₀
#align cardinal.continuum Cardinal.continuum
scoped notation "𝔠" => Cardinal.continuum
@[simp]
theorem two_power_aleph0 : 2 ^ aleph0.{u} = continuum.{u} :=
rfl
#align cardinal.two_power_aleph_0 Cardinal.two_power_aleph0
@[simp]
theorem lift_continuum : lift.{v} 𝔠 = 𝔠 := by
rw [← two_power_aleph0, lift_two_power, lift_aleph0, two_power_aleph0]
#align cardinal.lift_continuum Cardinal.lift_continuum
@[simp]
theorem continuum_le_lift {c : Cardinal.{u}} : 𝔠 ≤ lift.{v} c ↔ 𝔠 ≤ c := by
-- Porting note: added explicit universes
rw [← lift_continuum.{u,v}, lift_le]
#align cardinal.continuum_le_lift Cardinal.continuum_le_lift
@[simp]
theorem lift_le_continuum {c : Cardinal.{u}} : lift.{v} c ≤ 𝔠 ↔ c ≤ 𝔠 := by
-- Porting note: added explicit universes
rw [← lift_continuum.{u,v}, lift_le]
#align cardinal.lift_le_continuum Cardinal.lift_le_continuum
@[simp]
| Mathlib/SetTheory/Cardinal/Continuum.lean | 58 | 60 | theorem continuum_lt_lift {c : Cardinal.{u}} : 𝔠 < lift.{v} c ↔ 𝔠 < c := by |
-- Porting note: added explicit universes
rw [← lift_continuum.{u,v}, lift_lt]
|
/-
Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Kexing Ying, Eric Wieser
-/
import Mathlib.LinearAlgebra.Matrix.Determinant.Basic
import Mathlib.LinearAlgebra.Matrix.SesquilinearForm
import Mathlib.LinearAlgebra.Matrix.Symmetric
#align_import linear_algebra.quadratic_form.basic from "leanprover-community/mathlib"@"d11f435d4e34a6cea0a1797d6b625b0c170be845"
/-!
# Quadratic forms
This file defines quadratic forms over a `R`-module `M`.
A quadratic form on a commutative ring `R` is a map `Q : M → R` such that:
* `QuadraticForm.map_smul`: `Q (a • x) = a * a * Q x`
* `QuadraticForm.polar_add_left`, `QuadraticForm.polar_add_right`,
`QuadraticForm.polar_smul_left`, `QuadraticForm.polar_smul_right`:
the map `QuadraticForm.polar Q := fun x y ↦ Q (x + y) - Q x - Q y` is bilinear.
This notion generalizes to commutative semirings using the approach in [izhakian2016][] which
requires that there be a (possibly non-unique) companion bilinear form `B` such that
`∀ x y, Q (x + y) = Q x + Q y + B x y`. Over a ring, this `B` is precisely `QuadraticForm.polar Q`.
To build a `QuadraticForm` from the `polar` axioms, use `QuadraticForm.ofPolar`.
Quadratic forms come with a scalar multiplication, `(a • Q) x = Q (a • x) = a * a * Q x`,
and composition with linear maps `f`, `Q.comp f x = Q (f x)`.
## Main definitions
* `QuadraticForm.ofPolar`: a more familiar constructor that works on rings
* `QuadraticForm.associated`: associated bilinear form
* `QuadraticForm.PosDef`: positive definite quadratic forms
* `QuadraticForm.Anisotropic`: anisotropic quadratic forms
* `QuadraticForm.discr`: discriminant of a quadratic form
* `QuadraticForm.IsOrtho`: orthogonality of vectors with respect to a quadratic form.
## Main statements
* `QuadraticForm.associated_left_inverse`,
* `QuadraticForm.associated_rightInverse`: in a commutative ring where 2 has
an inverse, there is a correspondence between quadratic forms and symmetric
bilinear forms
* `LinearMap.BilinForm.exists_orthogonal_basis`: There exists an orthogonal basis with
respect to any nondegenerate, symmetric bilinear form `B`.
## Notation
In this file, the variable `R` is used when a `CommSemiring` structure is available.
The variable `S` is used when `R` itself has a `•` action.
## Implementation notes
While the definition and many results make sense if we drop commutativity assumptions,
the correct definition of a quadratic form in the noncommutative setting would require
substantial refactors from the current version, such that $Q(rm) = rQ(m)r^*$ for some
suitable conjugation $r^*$.
The [Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/Quadratic.20Maps/near/395529867)
has some further discusion.
## References
* https://en.wikipedia.org/wiki/Quadratic_form
* https://en.wikipedia.org/wiki/Discriminant#Quadratic_forms
## Tags
quadratic form, homogeneous polynomial, quadratic polynomial
-/
universe u v w
variable {S T : Type*}
variable {R : Type*} {M N : Type*}
open LinearMap (BilinForm)
section Polar
variable [CommRing R] [AddCommGroup M]
namespace QuadraticForm
/-- Up to a factor 2, `Q.polar` is the associated bilinear form for a quadratic form `Q`.
Source of this name: https://en.wikipedia.org/wiki/Quadratic_form#Generalization
-/
def polar (f : M → R) (x y : M) :=
f (x + y) - f x - f y
#align quadratic_form.polar QuadraticForm.polar
theorem polar_add (f g : M → R) (x y : M) : polar (f + g) x y = polar f x y + polar g x y := by
simp only [polar, Pi.add_apply]
abel
#align quadratic_form.polar_add QuadraticForm.polar_add
theorem polar_neg (f : M → R) (x y : M) : polar (-f) x y = -polar f x y := by
simp only [polar, Pi.neg_apply, sub_eq_add_neg, neg_add]
#align quadratic_form.polar_neg QuadraticForm.polar_neg
theorem polar_smul [Monoid S] [DistribMulAction S R] (f : M → R) (s : S) (x y : M) :
polar (s • f) x y = s • polar f x y := by simp only [polar, Pi.smul_apply, smul_sub]
#align quadratic_form.polar_smul QuadraticForm.polar_smul
theorem polar_comm (f : M → R) (x y : M) : polar f x y = polar f y x := by
rw [polar, polar, add_comm, sub_sub, sub_sub, add_comm (f x) (f y)]
#align quadratic_form.polar_comm QuadraticForm.polar_comm
/-- Auxiliary lemma to express bilinearity of `QuadraticForm.polar` without subtraction. -/
theorem polar_add_left_iff {f : M → R} {x x' y : M} :
polar f (x + x') y = polar f x y + polar f x' y ↔
f (x + x' + y) + (f x + f x' + f y) = f (x + x') + f (x' + y) + f (y + x) := by
simp only [← add_assoc]
simp only [polar, sub_eq_iff_eq_add, eq_sub_iff_add_eq, sub_add_eq_add_sub, add_sub]
simp only [add_right_comm _ (f y) _, add_right_comm _ (f x') (f x)]
rw [add_comm y x, add_right_comm _ _ (f (x + y)), add_comm _ (f (x + y)),
add_right_comm (f (x + y)), add_left_inj]
#align quadratic_form.polar_add_left_iff QuadraticForm.polar_add_left_iff
| Mathlib/LinearAlgebra/QuadraticForm/Basic.lean | 126 | 129 | theorem polar_comp {F : Type*} [CommRing S] [FunLike F R S] [AddMonoidHomClass F R S]
(f : M → R) (g : F) (x y : M) :
polar (g ∘ f) x y = g (polar f x y) := by |
simp only [polar, Pi.smul_apply, Function.comp_apply, map_sub]
|
/-
Copyright (c) 2024 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro, Andrew Yang,
Johannes Hölzl, Kevin Buzzard, Yury Kudryashov
-/
import Mathlib.Algebra.Module.Submodule.Lattice
import Mathlib.Order.Hom.CompleteLattice
/-!
# Restriction of scalars for submodules
If semiring `S` acts on a semiring `R` and `M` is a module over both (compatibly with this action)
then we can turn an `R`-submodule into an `S`-submodule by forgetting the action of `R`. We call
this restriction of scalars for submodules.
## Main definitions:
* `Submodule.restrictScalars`: regard an `R`-submodule as an `S`-submodule if `S` acts on `R`
-/
namespace Submodule
variable (S : Type*) {R M : Type*} [Semiring R] [AddCommMonoid M] [Semiring S]
[Module S M] [Module R M] [SMul S R] [IsScalarTower S R M]
/-- `V.restrictScalars S` is the `S`-submodule of the `S`-module given by restriction of scalars,
corresponding to `V`, an `R`-submodule of the original `R`-module.
-/
def restrictScalars (V : Submodule R M) : Submodule S M where
carrier := V
zero_mem' := V.zero_mem
smul_mem' c _ h := V.smul_of_tower_mem c h
add_mem' hx hy := V.add_mem hx hy
#align submodule.restrict_scalars Submodule.restrictScalars
@[simp]
theorem coe_restrictScalars (V : Submodule R M) : (V.restrictScalars S : Set M) = V :=
rfl
#align submodule.coe_restrict_scalars Submodule.coe_restrictScalars
@[simp]
theorem toAddSubmonoid_restrictScalars (V : Submodule R M) :
(V.restrictScalars S).toAddSubmonoid = V.toAddSubmonoid :=
rfl
@[simp]
theorem restrictScalars_mem (V : Submodule R M) (m : M) : m ∈ V.restrictScalars S ↔ m ∈ V :=
Iff.refl _
#align submodule.restrict_scalars_mem Submodule.restrictScalars_mem
@[simp]
theorem restrictScalars_self (V : Submodule R M) : V.restrictScalars R = V :=
SetLike.coe_injective rfl
#align submodule.restrict_scalars_self Submodule.restrictScalars_self
variable (R M)
theorem restrictScalars_injective :
Function.Injective (restrictScalars S : Submodule R M → Submodule S M) := fun _ _ h =>
ext <| Set.ext_iff.1 (SetLike.ext'_iff.1 h : _)
#align submodule.restrict_scalars_injective Submodule.restrictScalars_injective
@[simp]
theorem restrictScalars_inj {V₁ V₂ : Submodule R M} :
restrictScalars S V₁ = restrictScalars S V₂ ↔ V₁ = V₂ :=
(restrictScalars_injective S _ _).eq_iff
#align submodule.restrict_scalars_inj Submodule.restrictScalars_inj
/-- Even though `p.restrictScalars S` has type `Submodule S M`, it is still an `R`-module. -/
instance restrictScalars.origModule (p : Submodule R M) : Module R (p.restrictScalars S) :=
(by infer_instance : Module R p)
#align submodule.restrict_scalars.orig_module Submodule.restrictScalars.origModule
instance restrictScalars.isScalarTower (p : Submodule R M) :
IsScalarTower S R (p.restrictScalars S) where
smul_assoc r s x := Subtype.ext <| smul_assoc r s (x : M)
#align submodule.restrict_scalars.is_scalar_tower Submodule.restrictScalars.isScalarTower
/-- `restrictScalars S` is an embedding of the lattice of `R`-submodules into
the lattice of `S`-submodules. -/
@[simps]
def restrictScalarsEmbedding : Submodule R M ↪o Submodule S M where
toFun := restrictScalars S
inj' := restrictScalars_injective S R M
map_rel_iff' := by simp [SetLike.le_def]
#align submodule.restrict_scalars_embedding Submodule.restrictScalarsEmbedding
#align submodule.restrict_scalars_embedding_apply Submodule.restrictScalarsEmbedding_apply
/-- Turning `p : Submodule R M` into an `S`-submodule gives the same module structure
as turning it into a type and adding a module structure. -/
@[simps (config := { simpRhs := true })]
def restrictScalarsEquiv (p : Submodule R M) : p.restrictScalars S ≃ₗ[R] p :=
{ AddEquiv.refl p with
map_smul' := fun _ _ => rfl }
#align submodule.restrict_scalars_equiv Submodule.restrictScalarsEquiv
#align submodule.restrict_scalars_equiv_symm_apply Submodule.restrictScalarsEquiv_symm_apply
@[simp]
theorem restrictScalars_bot : restrictScalars S (⊥ : Submodule R M) = ⊥ :=
rfl
#align submodule.restrict_scalars_bot Submodule.restrictScalars_bot
@[simp]
| Mathlib/Algebra/Module/Submodule/RestrictScalars.lean | 106 | 107 | theorem restrictScalars_eq_bot_iff {p : Submodule R M} : restrictScalars S p = ⊥ ↔ p = ⊥ := by |
simp [SetLike.ext_iff]
|
/-
Copyright (c) 2017 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
import Batteries.Data.DList
import Mathlib.Mathport.Rename
import Mathlib.Tactic.Cases
#align_import data.dlist from "leanprover-community/lean"@"855e5b74e3a52a40552e8f067169d747d48743fd"
/-!
# Difference list
This file provides a few results about `DList`, which is defined in `Batteries`.
A difference list is a function that, given a list, returns the original content of the
difference list prepended to the given list. It is useful to represent elements of a given type
as `a₁ + ... + aₙ` where `+ : α → α → α` is any operation, without actually computing.
This structure supports `O(1)` `append` and `push` operations on lists, making it
useful for append-heavy uses such as logging and pretty printing.
-/
universe u
#align dlist Batteries.DList
namespace Batteries.DList
open Function
variable {α : Type u}
#align dlist.of_list Batteries.DList.ofList
/-- Convert a lazily-evaluated `List` to a `DList` -/
def lazy_ofList (l : Thunk (List α)) : DList α :=
⟨fun xs => l.get ++ xs, fun t => by simp⟩
#align dlist.lazy_of_list Batteries.DList.lazy_ofList
#align dlist.to_list Batteries.DList.toList
#align dlist.empty Batteries.DList.empty
#align dlist.singleton Batteries.DList.singleton
attribute [local simp] Function.comp
#align dlist.cons Batteries.DList.cons
#align dlist.concat Batteries.DList.push
#align dlist.append Batteries.DList.append
attribute [local simp] ofList toList empty singleton cons push append
theorem toList_ofList (l : List α) : DList.toList (DList.ofList l) = l := by
cases l; rfl; simp only [DList.toList, DList.ofList, List.cons_append, List.append_nil]
#align dlist.to_list_of_list Batteries.DList.toList_ofList
theorem ofList_toList (l : DList α) : DList.ofList (DList.toList l) = l := by
cases' l with app inv
simp only [ofList, toList, mk.injEq]
funext x
rw [(inv x)]
#align dlist.of_list_to_list Batteries.DList.ofList_toList
theorem toList_empty : toList (@empty α) = [] := by simp
#align dlist.to_list_empty Batteries.DList.toList_empty
| Mathlib/Data/DList/Defs.lean | 72 | 72 | theorem toList_singleton (x : α) : toList (singleton x) = [x] := by | simp
|
/-
Copyright (c) 2021 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Gabriel Ebner
-/
import Batteries.Data.List.Lemmas
import Batteries.Data.Array.Basic
import Batteries.Tactic.SeqFocus
import Batteries.Util.ProofWanted
namespace Array
| .lake/packages/batteries/Batteries/Data/Array/Lemmas.lean | 14 | 29 | theorem forIn_eq_data_forIn [Monad m]
(as : Array α) (b : β) (f : α → β → m (ForInStep β)) :
forIn as b f = forIn as.data b f := by |
let rec loop : ∀ {i h b j}, j + i = as.size →
Array.forIn.loop as f i h b = forIn (as.data.drop j) b f
| 0, _, _, _, rfl => by rw [List.drop_length]; rfl
| i+1, _, _, j, ij => by
simp only [forIn.loop, Nat.add]
have j_eq : j = size as - 1 - i := by simp [← ij, ← Nat.add_assoc]
have : as.size - 1 - i < as.size := j_eq ▸ ij ▸ Nat.lt_succ_of_le (Nat.le_add_right ..)
have : as[size as - 1 - i] :: as.data.drop (j + 1) = as.data.drop j := by
rw [j_eq]; exact List.get_cons_drop _ ⟨_, this⟩
simp only [← this, List.forIn_cons]; congr; funext x; congr; funext b
rw [loop (i := i)]; rw [← ij, Nat.succ_add]; rfl
conv => lhs; simp only [forIn, Array.forIn]
rw [loop (Nat.zero_add _)]; rfl
|
/-
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.GroupWithZero.Divisibility
import Mathlib.Algebra.Order.Ring.Nat
import Mathlib.Tactic.NthRewrite
#align_import data.nat.gcd.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
/-!
# Definitions and properties of `Nat.gcd`, `Nat.lcm`, and `Nat.coprime`
Generalizations of these are provided in a later file as `GCDMonoid.gcd` and
`GCDMonoid.lcm`.
Note that the global `IsCoprime` is not a straightforward generalization of `Nat.coprime`, see
`Nat.isCoprime_iff_coprime` for the connection between the two.
-/
namespace Nat
/-! ### `gcd` -/
theorem gcd_greatest {a b d : ℕ} (hda : d ∣ a) (hdb : d ∣ b) (hd : ∀ e : ℕ, e ∣ a → e ∣ b → e ∣ d) :
d = a.gcd b :=
(dvd_antisymm (hd _ (gcd_dvd_left a b) (gcd_dvd_right a b)) (dvd_gcd hda hdb)).symm
#align nat.gcd_greatest Nat.gcd_greatest
/-! Lemmas where one argument consists of addition of a multiple of the other -/
@[simp]
theorem gcd_add_mul_right_right (m n k : ℕ) : gcd m (n + k * m) = gcd m n := by
simp [gcd_rec m (n + k * m), gcd_rec m n]
#align nat.gcd_add_mul_right_right Nat.gcd_add_mul_right_right
@[simp]
theorem gcd_add_mul_left_right (m n k : ℕ) : gcd m (n + m * k) = gcd m n := by
simp [gcd_rec m (n + m * k), gcd_rec m n]
#align nat.gcd_add_mul_left_right Nat.gcd_add_mul_left_right
@[simp]
theorem gcd_mul_right_add_right (m n k : ℕ) : gcd m (k * m + n) = gcd m n := by simp [add_comm _ n]
#align nat.gcd_mul_right_add_right Nat.gcd_mul_right_add_right
@[simp]
theorem gcd_mul_left_add_right (m n k : ℕ) : gcd m (m * k + n) = gcd m n := by simp [add_comm _ n]
#align nat.gcd_mul_left_add_right Nat.gcd_mul_left_add_right
@[simp]
theorem gcd_add_mul_right_left (m n k : ℕ) : gcd (m + k * n) n = gcd m n := by
rw [gcd_comm, gcd_add_mul_right_right, gcd_comm]
#align nat.gcd_add_mul_right_left Nat.gcd_add_mul_right_left
@[simp]
theorem gcd_add_mul_left_left (m n k : ℕ) : gcd (m + n * k) n = gcd m n := by
rw [gcd_comm, gcd_add_mul_left_right, gcd_comm]
#align nat.gcd_add_mul_left_left Nat.gcd_add_mul_left_left
@[simp]
theorem gcd_mul_right_add_left (m n k : ℕ) : gcd (k * n + m) n = gcd m n := by
rw [gcd_comm, gcd_mul_right_add_right, gcd_comm]
#align nat.gcd_mul_right_add_left Nat.gcd_mul_right_add_left
@[simp]
theorem gcd_mul_left_add_left (m n k : ℕ) : gcd (n * k + m) n = gcd m n := by
rw [gcd_comm, gcd_mul_left_add_right, gcd_comm]
#align nat.gcd_mul_left_add_left Nat.gcd_mul_left_add_left
/-! Lemmas where one argument consists of an addition of the other -/
@[simp]
theorem gcd_add_self_right (m n : ℕ) : gcd m (n + m) = gcd m n :=
Eq.trans (by rw [one_mul]) (gcd_add_mul_right_right m n 1)
#align nat.gcd_add_self_right Nat.gcd_add_self_right
@[simp]
theorem gcd_add_self_left (m n : ℕ) : gcd (m + n) n = gcd m n := by
rw [gcd_comm, gcd_add_self_right, gcd_comm]
#align nat.gcd_add_self_left Nat.gcd_add_self_left
@[simp]
theorem gcd_self_add_left (m n : ℕ) : gcd (m + n) m = gcd n m := by rw [add_comm, gcd_add_self_left]
#align nat.gcd_self_add_left Nat.gcd_self_add_left
@[simp]
theorem gcd_self_add_right (m n : ℕ) : gcd m (m + n) = gcd m n := by
rw [add_comm, gcd_add_self_right]
#align nat.gcd_self_add_right Nat.gcd_self_add_right
/-! Lemmas where one argument consists of a subtraction of the other -/
@[simp]
theorem gcd_sub_self_left {m n : ℕ} (h : m ≤ n) : gcd (n - m) m = gcd n m := by
calc
gcd (n - m) m = gcd (n - m + m) m := by rw [← gcd_add_self_left (n - m) m]
_ = gcd n m := by rw [Nat.sub_add_cancel h]
@[simp]
theorem gcd_sub_self_right {m n : ℕ} (h : m ≤ n) : gcd m (n - m) = gcd m n := by
rw [gcd_comm, gcd_sub_self_left h, gcd_comm]
@[simp]
| Mathlib/Data/Nat/GCD/Basic.lean | 106 | 112 | theorem gcd_self_sub_left {m n : ℕ} (h : m ≤ n) : gcd (n - m) n = gcd m n := by |
have := Nat.sub_add_cancel h
rw [gcd_comm m n, ← this, gcd_add_self_left (n - m) m]
have : gcd (n - m) n = gcd (n - m) m := by
nth_rw 2 [← Nat.add_sub_cancel' h]
rw [gcd_add_self_right, gcd_comm]
convert this
|
/-
Copyright (c) 2022 Antoine Labelle. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Antoine Labelle
-/
import Mathlib.Algebra.Group.Equiv.TypeTags
import Mathlib.Algebra.Module.Defs
import Mathlib.Algebra.Module.LinearMap.Basic
import Mathlib.Algebra.MonoidAlgebra.Basic
import Mathlib.LinearAlgebra.Dual
import Mathlib.LinearAlgebra.Contraction
import Mathlib.RingTheory.TensorProduct.Basic
#align_import representation_theory.basic from "leanprover-community/mathlib"@"c04bc6e93e23aa0182aba53661a2211e80b6feac"
/-!
# Monoid representations
This file introduces monoid representations and their characters and defines a few ways to construct
representations.
## Main definitions
* Representation.Representation
* Representation.character
* Representation.tprod
* Representation.linHom
* Representation.dual
## Implementation notes
Representations of a monoid `G` on a `k`-module `V` are implemented as
homomorphisms `G →* (V →ₗ[k] V)`. We use the abbreviation `Representation` for this hom space.
The theorem `asAlgebraHom_def` constructs a module over the group `k`-algebra of `G` (implemented
as `MonoidAlgebra k G`) corresponding to a representation. If `ρ : Representation k G V`, this
module can be accessed via `ρ.asModule`. Conversely, given a `MonoidAlgebra k G-module `M`
`M.ofModule` is the associociated representation seen as a homomorphism.
-/
open MonoidAlgebra (lift of)
open LinearMap
section
variable (k G V : Type*) [CommSemiring k] [Monoid G] [AddCommMonoid V] [Module k V]
/-- A representation of `G` on the `k`-module `V` is a homomorphism `G →* (V →ₗ[k] V)`.
-/
abbrev Representation :=
G →* V →ₗ[k] V
#align representation Representation
end
namespace Representation
section trivial
variable (k : Type*) {G V : Type*} [CommSemiring k] [Monoid G] [AddCommMonoid V] [Module k V]
/-- The trivial representation of `G` on a `k`-module V.
-/
def trivial : Representation k G V :=
1
#align representation.trivial Representation.trivial
-- Porting note: why is `V` implicit
theorem trivial_def (g : G) (v : V) : trivial k (V := V) g v = v :=
rfl
#align representation.trivial_def Representation.trivial_def
variable {k}
/-- A predicate for representations that fix every element. -/
class IsTrivial (ρ : Representation k G V) : Prop where
out : ∀ g x, ρ g x = x := by aesop
instance : IsTrivial (trivial k (G := G) (V := V)) where
@[simp] theorem apply_eq_self
(ρ : Representation k G V) (g : G) (x : V) [h : IsTrivial ρ] :
ρ g x = x := h.out g x
end trivial
section MonoidAlgebra
variable {k G V : Type*} [CommSemiring k] [Monoid G] [AddCommMonoid V] [Module k V]
variable (ρ : Representation k G V)
/-- A `k`-linear representation of `G` on `V` can be thought of as
an algebra map from `MonoidAlgebra k G` into the `k`-linear endomorphisms of `V`.
-/
noncomputable def asAlgebraHom : MonoidAlgebra k G →ₐ[k] Module.End k V :=
(lift k G _) ρ
#align representation.as_algebra_hom Representation.asAlgebraHom
theorem asAlgebraHom_def : asAlgebraHom ρ = (lift k G _) ρ :=
rfl
#align representation.as_algebra_hom_def Representation.asAlgebraHom_def
@[simp]
theorem asAlgebraHom_single (g : G) (r : k) : asAlgebraHom ρ (Finsupp.single g r) = r • ρ g := by
simp only [asAlgebraHom_def, MonoidAlgebra.lift_single]
#align representation.as_algebra_hom_single Representation.asAlgebraHom_single
theorem asAlgebraHom_single_one (g : G) : asAlgebraHom ρ (Finsupp.single g 1) = ρ g := by simp
#align representation.as_algebra_hom_single_one Representation.asAlgebraHom_single_one
theorem asAlgebraHom_of (g : G) : asAlgebraHom ρ (of k G g) = ρ g := by
simp only [MonoidAlgebra.of_apply, asAlgebraHom_single, one_smul]
#align representation.as_algebra_hom_of Representation.asAlgebraHom_of
/-- If `ρ : Representation k G V`, then `ρ.asModule` is a type synonym for `V`,
which we equip with an instance `Module (MonoidAlgebra k G) ρ.asModule`.
You should use `asModuleEquiv : ρ.asModule ≃+ V` to translate terms.
-/
@[nolint unusedArguments]
def asModule (_ : Representation k G V) :=
V
#align representation.as_module Representation.asModule
-- Porting note: no derive handler
instance : AddCommMonoid (ρ.asModule) := inferInstanceAs <| AddCommMonoid V
instance : Inhabited ρ.asModule where
default := 0
/-- A `k`-linear representation of `G` on `V` can be thought of as
a module over `MonoidAlgebra k G`.
-/
noncomputable instance asModuleModule : Module (MonoidAlgebra k G) ρ.asModule :=
Module.compHom V (asAlgebraHom ρ).toRingHom
#align representation.as_module_module Representation.asModuleModule
-- Porting note: ρ.asModule doesn't unfold now
instance : Module k ρ.asModule := inferInstanceAs <| Module k V
/-- The additive equivalence from the `Module (MonoidAlgebra k G)` to the original vector space
of the representative.
This is just the identity, but it is helpful for typechecking and keeping track of instances.
-/
def asModuleEquiv : ρ.asModule ≃+ V :=
AddEquiv.refl _
#align representation.as_module_equiv Representation.asModuleEquiv
@[simp]
theorem asModuleEquiv_map_smul (r : MonoidAlgebra k G) (x : ρ.asModule) :
ρ.asModuleEquiv (r • x) = ρ.asAlgebraHom r (ρ.asModuleEquiv x) :=
rfl
#align representation.as_module_equiv_map_smul Representation.asModuleEquiv_map_smul
@[simp]
| Mathlib/RepresentationTheory/Basic.lean | 159 | 162 | theorem asModuleEquiv_symm_map_smul (r : k) (x : V) :
ρ.asModuleEquiv.symm (r • x) = algebraMap k (MonoidAlgebra k G) r • ρ.asModuleEquiv.symm x := by |
apply_fun ρ.asModuleEquiv
simp
|
/-
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.Forall2
#align_import data.list.sections from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2"
/-!
# List sections
This file proves some stuff about `List.sections` (definition in `Data.List.Defs`). A section of a
list of lists `[l₁, ..., lₙ]` is a list whose `i`-th element comes from the `i`-th list.
-/
open Nat Function
namespace List
variable {α β : Type*}
| Mathlib/Data/List/Sections.lean | 23 | 34 | theorem mem_sections {L : List (List α)} {f} : f ∈ sections L ↔ Forall₂ (· ∈ ·) f L := by |
refine ⟨fun h => ?_, fun h => ?_⟩
· induction L generalizing f
· cases mem_singleton.1 h
exact Forall₂.nil
simp only [sections, bind_eq_bind, mem_bind, mem_map] at h
rcases h with ⟨_, _, _, _, rfl⟩
simp only [*, forall₂_cons, true_and_iff]
· induction' h with a l f L al fL fs
· simp only [sections, mem_singleton]
simp only [sections, bind_eq_bind, mem_bind, mem_map]
exact ⟨f, fs, a, al, rfl⟩
|
/-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Mario Carneiro, Sean Leather
-/
import Mathlib.Data.Finset.Card
#align_import data.finset.option from "leanprover-community/mathlib"@"c227d107bbada5d0d9d20287e3282c0a7f1651a0"
/-!
# Finite sets in `Option α`
In this file we define
* `Option.toFinset`: construct an empty or singleton `Finset α` from an `Option α`;
* `Finset.insertNone`: given `s : Finset α`, lift it to a finset on `Option α` using `Option.some`
and then insert `Option.none`;
* `Finset.eraseNone`: given `s : Finset (Option α)`, returns `t : Finset α` such that
`x ∈ t ↔ some x ∈ s`.
Then we prove some basic lemmas about these definitions.
## Tags
finset, option
-/
variable {α β : Type*}
open Function
namespace Option
/-- Construct an empty or singleton finset from an `Option` -/
def toFinset (o : Option α) : Finset α :=
o.elim ∅ singleton
#align option.to_finset Option.toFinset
@[simp]
theorem toFinset_none : none.toFinset = (∅ : Finset α) :=
rfl
#align option.to_finset_none Option.toFinset_none
@[simp]
theorem toFinset_some {a : α} : (some a).toFinset = {a} :=
rfl
#align option.to_finset_some Option.toFinset_some
@[simp]
theorem mem_toFinset {a : α} {o : Option α} : a ∈ o.toFinset ↔ a ∈ o := by
cases o <;> simp [eq_comm]
#align option.mem_to_finset Option.mem_toFinset
theorem card_toFinset (o : Option α) : o.toFinset.card = o.elim 0 1 := by cases o <;> rfl
#align option.card_to_finset Option.card_toFinset
end Option
namespace Finset
/-- Given a finset on `α`, lift it to being a finset on `Option α`
using `Option.some` and then insert `Option.none`. -/
def insertNone : Finset α ↪o Finset (Option α) :=
(OrderEmbedding.ofMapLEIff fun s => cons none (s.map Embedding.some) <| by simp) fun s t => by
rw [le_iff_subset, cons_subset_cons, map_subset_map, le_iff_subset]
#align finset.insert_none Finset.insertNone
@[simp]
theorem mem_insertNone {s : Finset α} : ∀ {o : Option α}, o ∈ insertNone s ↔ ∀ a ∈ o, a ∈ s
| none => iff_of_true (Multiset.mem_cons_self _ _) fun a h => by cases h
| some a => Multiset.mem_cons.trans <| by simp
#align finset.mem_insert_none Finset.mem_insertNone
lemma forall_mem_insertNone {s : Finset α} {p : Option α → Prop} :
(∀ a ∈ insertNone s, p a) ↔ p none ∧ ∀ a ∈ s, p a := by simp [Option.forall]
theorem some_mem_insertNone {s : Finset α} {a : α} : some a ∈ insertNone s ↔ a ∈ s := by simp
#align finset.some_mem_insert_none Finset.some_mem_insertNone
lemma none_mem_insertNone {s : Finset α} : none ∈ insertNone s := by simp
@[aesop safe apply (rule_sets := [finsetNonempty])]
lemma insertNone_nonempty {s : Finset α} : insertNone s |>.Nonempty := ⟨none, none_mem_insertNone⟩
@[simp]
theorem card_insertNone (s : Finset α) : s.insertNone.card = s.card + 1 := by simp [insertNone]
#align finset.card_insert_none Finset.card_insertNone
/-- Given `s : Finset (Option α)`, `eraseNone s : Finset α` is the set of `x : α` such that
`some x ∈ s`. -/
def eraseNone : Finset (Option α) →o Finset α :=
(Finset.mapEmbedding (Equiv.optionIsSomeEquiv α).toEmbedding).toOrderHom.comp
⟨Finset.subtype _, subtype_mono⟩
#align finset.erase_none Finset.eraseNone
@[simp]
theorem mem_eraseNone {s : Finset (Option α)} {x : α} : x ∈ eraseNone s ↔ some x ∈ s := by
simp [eraseNone]
#align finset.mem_erase_none Finset.mem_eraseNone
lemma forall_mem_eraseNone {s : Finset (Option α)} {p : Option α → Prop} :
(∀ a ∈ eraseNone s, p a) ↔ ∀ a : α, (a : Option α) ∈ s → p a := by simp [Option.forall]
theorem eraseNone_eq_biUnion [DecidableEq α] (s : Finset (Option α)) :
eraseNone s = s.biUnion Option.toFinset := by
ext
simp
#align finset.erase_none_eq_bUnion Finset.eraseNone_eq_biUnion
@[simp]
theorem eraseNone_map_some (s : Finset α) : eraseNone (s.map Embedding.some) = s := by
ext
simp
#align finset.erase_none_map_some Finset.eraseNone_map_some
@[simp]
theorem eraseNone_image_some [DecidableEq (Option α)] (s : Finset α) :
eraseNone (s.image some) = s := by simpa only [map_eq_image] using eraseNone_map_some s
#align finset.erase_none_image_some Finset.eraseNone_image_some
@[simp]
theorem coe_eraseNone (s : Finset (Option α)) : (eraseNone s : Set α) = some ⁻¹' s :=
Set.ext fun _ => mem_eraseNone
#align finset.coe_erase_none Finset.coe_eraseNone
@[simp]
| Mathlib/Data/Finset/Option.lean | 128 | 131 | theorem eraseNone_union [DecidableEq (Option α)] [DecidableEq α] (s t : Finset (Option α)) :
eraseNone (s ∪ t) = eraseNone s ∪ eraseNone t := by |
ext
simp
|
/-
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.Monoidal.Free.Coherence
import Mathlib.CategoryTheory.Monoidal.Discrete
import Mathlib.CategoryTheory.Monoidal.NaturalTransformation
import Mathlib.CategoryTheory.Monoidal.Opposite
import Mathlib.Tactic.CategoryTheory.Coherence
import Mathlib.CategoryTheory.CommSq
#align_import category_theory.monoidal.braided from "leanprover-community/mathlib"@"2efd2423f8d25fa57cf7a179f5d8652ab4d0df44"
/-!
# Braided and symmetric monoidal categories
The basic definitions of braided monoidal categories, and symmetric monoidal categories,
as well as braided functors.
## Implementation note
We make `BraidedCategory` another typeclass, but then have `SymmetricCategory` extend this.
The rationale is that we are not carrying any additional data, just requiring a property.
## Future work
* Construct the Drinfeld center of a monoidal category as a braided monoidal category.
* Say something about pseudo-natural transformations.
## References
* [Pavel Etingof, Shlomo Gelaki, Dmitri Nikshych, Victor Ostrik, *Tensor categories*][egno15]
-/
open CategoryTheory MonoidalCategory
universe v v₁ v₂ v₃ u u₁ u₂ u₃
namespace CategoryTheory
/-- A braided monoidal category is a monoidal category equipped with a braiding isomorphism
`β_ X Y : X ⊗ Y ≅ Y ⊗ X`
which is natural in both arguments,
and also satisfies the two hexagon identities.
-/
class BraidedCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C] where
/-- The braiding natural isomorphism. -/
braiding : ∀ X Y : C, X ⊗ Y ≅ Y ⊗ X
braiding_naturality_right :
∀ (X : C) {Y Z : C} (f : Y ⟶ Z),
X ◁ f ≫ (braiding X Z).hom = (braiding X Y).hom ≫ f ▷ X := by
aesop_cat
braiding_naturality_left :
∀ {X Y : C} (f : X ⟶ Y) (Z : C),
f ▷ Z ≫ (braiding Y Z).hom = (braiding X Z).hom ≫ Z ◁ f := by
aesop_cat
/-- The first hexagon identity. -/
hexagon_forward :
∀ X Y Z : C,
(α_ X Y Z).hom ≫ (braiding X (Y ⊗ Z)).hom ≫ (α_ Y Z X).hom =
((braiding X Y).hom ▷ Z) ≫ (α_ Y X Z).hom ≫ (Y ◁ (braiding X Z).hom) := by
aesop_cat
/-- The second hexagon identity. -/
hexagon_reverse :
∀ X Y Z : C,
(α_ X Y Z).inv ≫ (braiding (X ⊗ Y) Z).hom ≫ (α_ Z X Y).inv =
(X ◁ (braiding Y Z).hom) ≫ (α_ X Z Y).inv ≫ ((braiding X Z).hom ▷ Y) := by
aesop_cat
#align category_theory.braided_category CategoryTheory.BraidedCategory
attribute [reassoc (attr := simp)]
BraidedCategory.braiding_naturality_left
BraidedCategory.braiding_naturality_right
attribute [reassoc] BraidedCategory.hexagon_forward BraidedCategory.hexagon_reverse
open Category
open MonoidalCategory
open BraidedCategory
@[inherit_doc]
notation "β_" => BraidedCategory.braiding
namespace BraidedCategory
variable {C : Type u} [Category.{v} C] [MonoidalCategory.{v} C] [BraidedCategory.{v} C]
@[simp, reassoc]
theorem braiding_tensor_left (X Y Z : C) :
(β_ (X ⊗ Y) Z).hom =
(α_ X Y Z).hom ≫ X ◁ (β_ Y Z).hom ≫ (α_ X Z Y).inv ≫
(β_ X Z).hom ▷ Y ≫ (α_ Z X Y).hom := by
apply (cancel_epi (α_ X Y Z).inv).1
apply (cancel_mono (α_ Z X Y).inv).1
simp [hexagon_reverse]
@[simp, reassoc]
theorem braiding_tensor_right (X Y Z : C) :
(β_ X (Y ⊗ Z)).hom =
(α_ X Y Z).inv ≫ (β_ X Y).hom ▷ Z ≫ (α_ Y X Z).hom ≫
Y ◁ (β_ X Z).hom ≫ (α_ Y Z X).inv := by
apply (cancel_epi (α_ X Y Z).hom).1
apply (cancel_mono (α_ Y Z X).hom).1
simp [hexagon_forward]
@[simp, reassoc]
theorem braiding_inv_tensor_left (X Y Z : C) :
(β_ (X ⊗ Y) Z).inv =
(α_ Z X Y).inv ≫ (β_ X Z).inv ▷ Y ≫ (α_ X Z Y).hom ≫
X ◁ (β_ Y Z).inv ≫ (α_ X Y Z).inv :=
eq_of_inv_eq_inv (by simp)
@[simp, reassoc]
theorem braiding_inv_tensor_right (X Y Z : C) :
(β_ X (Y ⊗ Z)).inv =
(α_ Y Z X).hom ≫ Y ◁ (β_ X Z).inv ≫ (α_ Y X Z).inv ≫
(β_ X Y).inv ▷ Z ≫ (α_ X Y Z).hom :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Monoidal/Braided/Basic.lean | 125 | 128 | theorem braiding_naturality {X X' Y Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y') :
(f ⊗ g) ≫ (braiding Y Y').hom = (braiding X X').hom ≫ (g ⊗ f) := by |
rw [tensorHom_def' f g, tensorHom_def g f]
simp_rw [Category.assoc, braiding_naturality_left, braiding_naturality_right_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.Algebra.Pi
import Mathlib.Algebra.Polynomial.Eval
import Mathlib.RingTheory.Adjoin.Basic
#align_import data.polynomial.algebra_map from "leanprover-community/mathlib"@"e064a7bf82ad94c3c17b5128bbd860d1ec34874e"
/-!
# Theory of univariate polynomials
We show that `A[X]` is an R-algebra when `A` is an R-algebra.
We promote `eval₂` to an algebra hom in `aeval`.
-/
noncomputable section
open Finset
open Polynomial
namespace Polynomial
universe u v w z
variable {R : Type u} {S : Type v} {T : Type w} {A : Type z} {A' B : Type*} {a b : R} {n : ℕ}
section CommSemiring
variable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]
variable {p q r : R[X]}
/-- Note that this instance also provides `Algebra R R[X]`. -/
instance algebraOfAlgebra : Algebra R A[X] where
smul_def' r p :=
toFinsupp_injective <| by
dsimp only [RingHom.toFun_eq_coe, RingHom.comp_apply]
rw [toFinsupp_smul, toFinsupp_mul, toFinsupp_C]
exact Algebra.smul_def' _ _
commutes' r p :=
toFinsupp_injective <| by
dsimp only [RingHom.toFun_eq_coe, RingHom.comp_apply]
simp_rw [toFinsupp_mul, toFinsupp_C]
convert Algebra.commutes' r p.toFinsupp
toRingHom := C.comp (algebraMap R A)
#align polynomial.algebra_of_algebra Polynomial.algebraOfAlgebra
@[simp]
theorem algebraMap_apply (r : R) : algebraMap R A[X] r = C (algebraMap R A r) :=
rfl
#align polynomial.algebra_map_apply Polynomial.algebraMap_apply
@[simp]
theorem toFinsupp_algebraMap (r : R) : (algebraMap R A[X] r).toFinsupp = algebraMap R _ r :=
show toFinsupp (C (algebraMap _ _ r)) = _ by
rw [toFinsupp_C]
rfl
#align polynomial.to_finsupp_algebra_map Polynomial.toFinsupp_algebraMap
theorem ofFinsupp_algebraMap (r : R) : (⟨algebraMap R _ r⟩ : A[X]) = algebraMap R A[X] r :=
toFinsupp_injective (toFinsupp_algebraMap _).symm
#align polynomial.of_finsupp_algebra_map Polynomial.ofFinsupp_algebraMap
/-- When we have `[CommSemiring R]`, the function `C` is the same as `algebraMap R R[X]`.
(But note that `C` is defined when `R` is not necessarily commutative, in which case
`algebraMap` is not available.)
-/
theorem C_eq_algebraMap (r : R) : C r = algebraMap R R[X] r :=
rfl
set_option linter.uppercaseLean3 false in
#align polynomial.C_eq_algebra_map Polynomial.C_eq_algebraMap
@[simp]
theorem algebraMap_eq : algebraMap R R[X] = C :=
rfl
/-- `Polynomial.C` as an `AlgHom`. -/
@[simps! apply]
def CAlgHom : A →ₐ[R] A[X] where
toRingHom := C
commutes' _ := rfl
/-- Extensionality lemma for algebra maps out of `A'[X]` over a smaller base ring than `A'`
-/
@[ext 1100]
theorem algHom_ext' {f g : A[X] →ₐ[R] B}
(hC : f.comp CAlgHom = g.comp CAlgHom)
(hX : f X = g X) : f = g :=
AlgHom.coe_ringHom_injective (ringHom_ext' (congr_arg AlgHom.toRingHom hC) hX)
#align polynomial.alg_hom_ext' Polynomial.algHom_ext'
variable (R)
open AddMonoidAlgebra in
/-- Algebra isomorphism between `R[X]` and `R[ℕ]`. This is just an
implementation detail, but it can be useful to transfer results from `Finsupp` to polynomials. -/
@[simps!]
def toFinsuppIsoAlg : R[X] ≃ₐ[R] R[ℕ] :=
{ toFinsuppIso R with
commutes' := fun r => by
dsimp }
#align polynomial.to_finsupp_iso_alg Polynomial.toFinsuppIsoAlg
variable {R}
instance subalgebraNontrivial [Nontrivial A] : Nontrivial (Subalgebra R A[X]) :=
⟨⟨⊥, ⊤, by
rw [Ne, SetLike.ext_iff, not_forall]
refine ⟨X, ?_⟩
simp only [Algebra.mem_bot, not_exists, Set.mem_range, iff_true_iff, Algebra.mem_top,
algebraMap_apply, not_forall]
intro x
rw [ext_iff, not_forall]
refine ⟨1, ?_⟩
simp [coeff_C]⟩⟩
@[simp]
theorem algHom_eval₂_algebraMap {R A B : Type*} [CommSemiring R] [Semiring A] [Semiring B]
[Algebra R A] [Algebra R B] (p : R[X]) (f : A →ₐ[R] B) (a : A) :
f (eval₂ (algebraMap R A) a p) = eval₂ (algebraMap R B) (f a) p := by
simp only [eval₂_eq_sum, sum_def]
simp only [f.map_sum, f.map_mul, f.map_pow, eq_intCast, map_intCast, AlgHom.commutes]
#align polynomial.alg_hom_eval₂_algebra_map Polynomial.algHom_eval₂_algebraMap
@[simp]
| Mathlib/Algebra/Polynomial/AlgebraMap.lean | 131 | 136 | theorem eval₂_algebraMap_X {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] (p : R[X])
(f : R[X] →ₐ[R] A) : eval₂ (algebraMap R A) (f X) p = f p := by |
conv_rhs => rw [← Polynomial.sum_C_mul_X_pow_eq p]
simp only [eval₂_eq_sum, sum_def]
simp only [f.map_sum, f.map_mul, f.map_pow, eq_intCast, map_intCast]
simp [Polynomial.C_eq_algebraMap]
|
/-
Copyright (c) 2022 Michael Stoll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Stoll
-/
import Mathlib.Data.Fin.Tuple.Sort
import Mathlib.Order.WellFounded
#align_import data.fin.tuple.bubble_sort_induction from "leanprover-community/mathlib"@"bf2428c9486c407ca38b5b3fb10b87dad0bc99fa"
/-!
# "Bubble sort" induction
We implement the following induction principle `Tuple.bubble_sort_induction`
on tuples with values in a linear order `α`.
Let `f : Fin n → α` and let `P` be a predicate on `Fin n → α`. Then we can show that
`f ∘ sort f` satisfies `P` if `f` satisfies `P`, and whenever some `g : Fin n → α`
satisfies `P` and `g i > g j` for some `i < j`, then `g ∘ swap i j` also satisfies `P`.
We deduce it from a stronger variant `Tuple.bubble_sort_induction'`, which
requires the assumption only for `g` that are permutations of `f`.
The latter is proved by well-founded induction via `WellFounded.induction_bot'`
with respect to the lexicographic ordering on the finite set of all permutations of `f`.
-/
namespace Tuple
/-- *Bubble sort induction*: Prove that the sorted version of `f` has some property `P`
if `f` satisfies `P` and `P` is preserved on permutations of `f` when swapping two
antitone values. -/
| Mathlib/Data/Fin/Tuple/BubbleSortInduction.lean | 34 | 44 | theorem bubble_sort_induction' {n : ℕ} {α : Type*} [LinearOrder α] {f : Fin n → α}
{P : (Fin n → α) → Prop} (hf : P f)
(h : ∀ (σ : Equiv.Perm (Fin n)) (i j : Fin n),
i < j → (f ∘ σ) j < (f ∘ σ) i → P (f ∘ σ) → P (f ∘ σ ∘ Equiv.swap i j)) :
P (f ∘ sort f) := by |
letI := @Preorder.lift _ (Lex (Fin n → α)) _ fun σ : Equiv.Perm (Fin n) => toLex (f ∘ σ)
refine
@WellFounded.induction_bot' _ _ _ (IsWellFounded.wf : WellFounded (· < ·))
(Equiv.refl _) (sort f) P (fun σ => f ∘ σ) (fun σ hσ hfσ => ?_) hf
obtain ⟨i, j, hij₁, hij₂⟩ := antitone_pair_of_not_sorted' hσ
exact ⟨σ * Equiv.swap i j, Pi.lex_desc hij₁.le hij₂, h σ i j hij₁ hij₂ hfσ⟩
|
/-
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, Sébastien Gouëzel, Yury Kudryashov
-/
import Mathlib.Dynamics.Ergodic.MeasurePreserving
import Mathlib.LinearAlgebra.Determinant
import Mathlib.LinearAlgebra.Matrix.Diagonal
import Mathlib.LinearAlgebra.Matrix.Transvection
import Mathlib.MeasureTheory.Group.LIntegral
import Mathlib.MeasureTheory.Integral.Marginal
import Mathlib.MeasureTheory.Measure.Stieltjes
import Mathlib.MeasureTheory.Measure.Haar.OfBasis
#align_import measure_theory.measure.lebesgue.basic from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
/-!
# Lebesgue measure on the real line and on `ℝⁿ`
We show that the Lebesgue measure on the real line (constructed as a particular case of additive
Haar measure on inner product spaces) coincides with the Stieltjes measure associated
to the function `x ↦ x`. We deduce properties of this measure on `ℝ`, and then of the product
Lebesgue measure on `ℝⁿ`. In particular, we prove that they are translation invariant.
We show that, on `ℝⁿ`, a linear map acts on Lebesgue measure by rescaling it through the absolute
value of its determinant, in `Real.map_linearMap_volume_pi_eq_smul_volume_pi`.
More properties of the Lebesgue measure are deduced from this in
`Mathlib/MeasureTheory/Measure/Lebesgue/EqHaar.lean`, where they are proved more generally for any
additive Haar measure on a finite-dimensional real vector space.
-/
assert_not_exists MeasureTheory.integral
noncomputable section
open scoped Classical
open Set Filter MeasureTheory MeasureTheory.Measure TopologicalSpace
open ENNReal (ofReal)
open scoped ENNReal NNReal Topology
/-!
### Definition of the Lebesgue measure and lengths of intervals
-/
namespace Real
variable {ι : Type*} [Fintype ι]
/-- The volume on the real line (as a particular case of the volume on a finite-dimensional
inner product space) coincides with the Stieltjes measure coming from the identity function. -/
theorem volume_eq_stieltjes_id : (volume : Measure ℝ) = StieltjesFunction.id.measure := by
haveI : IsAddLeftInvariant StieltjesFunction.id.measure :=
⟨fun a =>
Eq.symm <|
Real.measure_ext_Ioo_rat fun p q => by
simp only [Measure.map_apply (measurable_const_add a) measurableSet_Ioo,
sub_sub_sub_cancel_right, StieltjesFunction.measure_Ioo, StieltjesFunction.id_leftLim,
StieltjesFunction.id_apply, id, preimage_const_add_Ioo]⟩
have A : StieltjesFunction.id.measure (stdOrthonormalBasis ℝ ℝ).toBasis.parallelepiped = 1 := by
change StieltjesFunction.id.measure (parallelepiped (stdOrthonormalBasis ℝ ℝ)) = 1
rcases parallelepiped_orthonormalBasis_one_dim (stdOrthonormalBasis ℝ ℝ) with (H | H) <;>
simp only [H, StieltjesFunction.measure_Icc, StieltjesFunction.id_apply, id, tsub_zero,
StieltjesFunction.id_leftLim, sub_neg_eq_add, zero_add, ENNReal.ofReal_one]
conv_rhs =>
rw [addHaarMeasure_unique StieltjesFunction.id.measure
(stdOrthonormalBasis ℝ ℝ).toBasis.parallelepiped, A]
simp only [volume, Basis.addHaar, one_smul]
#align real.volume_eq_stieltjes_id Real.volume_eq_stieltjes_id
| Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean | 75 | 76 | theorem volume_val (s) : volume s = StieltjesFunction.id.measure s := by |
simp [volume_eq_stieltjes_id]
|
/-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Johan Commelin
-/
import Mathlib.LinearAlgebra.FiniteDimensional
import Mathlib.LinearAlgebra.TensorProduct.Tower
import Mathlib.RingTheory.Adjoin.Basic
import Mathlib.LinearAlgebra.DirectSum.Finsupp
#align_import ring_theory.tensor_product from "leanprover-community/mathlib"@"88fcdc3da43943f5b01925deddaa5bf0c0e85e4e"
/-!
# The tensor product of R-algebras
This file provides results about the multiplicative structure on `A ⊗[R] B` when `R` is a
commutative (semi)ring and `A` and `B` are both `R`-algebras. On these tensor products,
multiplication is characterized by `(a₁ ⊗ₜ b₁) * (a₂ ⊗ₜ b₂) = (a₁ * a₂) ⊗ₜ (b₁ * b₂)`.
## Main declarations
- `LinearMap.baseChange A f` is the `A`-linear map `A ⊗ f`, for an `R`-linear map `f`.
- `Algebra.TensorProduct.semiring`: the ring structure on `A ⊗[R] B` for two `R`-algebras `A`, `B`.
- `Algebra.TensorProduct.leftAlgebra`: the `S`-algebra structure on `A ⊗[R] B`, for when `A` is
additionally an `S` algebra.
- the structure isomorphisms
* `Algebra.TensorProduct.lid : R ⊗[R] A ≃ₐ[R] A`
* `Algebra.TensorProduct.rid : A ⊗[R] R ≃ₐ[S] A` (usually used with `S = R` or `S = A`)
* `Algebra.TensorProduct.comm : A ⊗[R] B ≃ₐ[R] B ⊗[R] A`
* `Algebra.TensorProduct.assoc : ((A ⊗[R] B) ⊗[R] C) ≃ₐ[R] (A ⊗[R] (B ⊗[R] C))`
- `Algebra.TensorProduct.liftEquiv`: a universal property for the tensor product of algebras.
## References
* [C. Kassel, *Quantum Groups* (§II.4)][Kassel1995]
-/
suppress_compilation
open scoped TensorProduct
open TensorProduct
namespace LinearMap
open TensorProduct
/-!
### The base-change of a linear map of `R`-modules to a linear map of `A`-modules
-/
section Semiring
variable {R A B M N P : Type*} [CommSemiring R]
variable [Semiring A] [Algebra R A] [Semiring B] [Algebra R B]
variable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P]
variable [Module R M] [Module R N] [Module R P]
variable (r : R) (f g : M →ₗ[R] N)
variable (A)
/-- `baseChange A f` for `f : M →ₗ[R] N` is the `A`-linear map `A ⊗[R] M →ₗ[A] A ⊗[R] N`.
This "base change" operation is also known as "extension of scalars". -/
def baseChange (f : M →ₗ[R] N) : A ⊗[R] M →ₗ[A] A ⊗[R] N :=
AlgebraTensorModule.map (LinearMap.id : A →ₗ[A] A) f
#align linear_map.base_change LinearMap.baseChange
variable {A}
@[simp]
theorem baseChange_tmul (a : A) (x : M) : f.baseChange A (a ⊗ₜ x) = a ⊗ₜ f x :=
rfl
#align linear_map.base_change_tmul LinearMap.baseChange_tmul
theorem baseChange_eq_ltensor : (f.baseChange A : A ⊗ M → A ⊗ N) = f.lTensor A :=
rfl
#align linear_map.base_change_eq_ltensor LinearMap.baseChange_eq_ltensor
@[simp]
theorem baseChange_add : (f + g).baseChange A = f.baseChange A + g.baseChange A := by
ext
-- Porting note: added `-baseChange_tmul`
simp [baseChange_eq_ltensor, -baseChange_tmul]
#align linear_map.base_change_add LinearMap.baseChange_add
@[simp]
| Mathlib/RingTheory/TensorProduct/Basic.lean | 90 | 92 | theorem baseChange_zero : baseChange A (0 : M →ₗ[R] N) = 0 := by |
ext
simp [baseChange_eq_ltensor]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
import Mathlib.Topology.Algebra.InfiniteSum.Group
import Mathlib.Logic.Encodable.Lattice
/-!
# Infinite sums and products over `ℕ` and `ℤ`
This file contains lemmas about `HasSum`, `Summable`, `tsum`, `HasProd`, `Multipliable`, and `tprod`
applied to the important special cases where the domain is `ℕ` or `ℤ`. For instance, we prove the
formula `∑ i ∈ range k, f i + ∑' i, f (i + k) = ∑' i, f i`, ∈ `sum_add_tsum_nat_add`, as well as
several results relating sums and products on `ℕ` to sums and products on `ℤ`.
-/
noncomputable section
open Filter Finset Function Encodable
open scoped Topology
variable {M : Type*} [CommMonoid M] [TopologicalSpace M] {m m' : M}
variable {G : Type*} [CommGroup G] {g g' : G}
-- don't declare [TopologicalAddGroup G] here as some results require [UniformAddGroup G] instead
/-!
## Sums over `ℕ`
-/
section Nat
section Monoid
namespace HasProd
/-- If `f : ℕ → M` has product `m`, then the partial products `∏ i ∈ range n, f i` converge
to `m`. -/
@[to_additive "If `f : ℕ → M` has sum `m`, then the partial sums `∑ i ∈ range n, f i` converge
to `m`."]
theorem tendsto_prod_nat {f : ℕ → M} (h : HasProd f m) :
Tendsto (fun n ↦ ∏ i ∈ range n, f i) atTop (𝓝 m) :=
h.comp tendsto_finset_range
#align has_sum.tendsto_sum_nat HasSum.tendsto_sum_nat
/-- If `f : ℕ → M` is multipliable, then the partial products `∏ i ∈ range n, f i` converge
to `∏' i, f i`. -/
@[to_additive "If `f : ℕ → M` is summable, then the partial sums `∑ i ∈ range n, f i` converge
to `∑' i, f i`."]
theorem Multipliable.tendsto_prod_tprod_nat {f : ℕ → M} (h : Multipliable f) :
Tendsto (fun n ↦ ∏ i ∈ range n, f i) atTop (𝓝 (∏' i, f i)) :=
tendsto_prod_nat h.hasProd
section ContinuousMul
variable [ContinuousMul M]
@[to_additive]
theorem prod_range_mul {f : ℕ → M} {k : ℕ} (h : HasProd (fun n ↦ f (n + k)) m) :
HasProd f ((∏ i ∈ range k, f i) * m) := by
refine ((range k).hasProd f).mul_compl ?_
rwa [← (notMemRangeEquiv k).symm.hasProd_iff]
@[to_additive]
theorem zero_mul {f : ℕ → M} (h : HasProd (fun n ↦ f (n + 1)) m) :
HasProd f (f 0 * m) := by
simpa only [prod_range_one] using h.prod_range_mul
@[to_additive]
theorem even_mul_odd {f : ℕ → M} (he : HasProd (fun k ↦ f (2 * k)) m)
(ho : HasProd (fun k ↦ f (2 * k + 1)) m') : HasProd f (m * m') := by
have := mul_right_injective₀ (two_ne_zero' ℕ)
replace ho := ((add_left_injective 1).comp this).hasProd_range_iff.2 ho
refine (this.hasProd_range_iff.2 he).mul_isCompl ?_ ho
simpa [(· ∘ ·)] using Nat.isCompl_even_odd
#align has_sum.even_add_odd HasSum.even_add_odd
end ContinuousMul
end HasProd
namespace Multipliable
@[to_additive]
theorem hasProd_iff_tendsto_nat [T2Space M] {f : ℕ → M} (hf : Multipliable f) :
HasProd f m ↔ Tendsto (fun n : ℕ ↦ ∏ i ∈ range n, f i) atTop (𝓝 m) := by
refine ⟨fun h ↦ h.tendsto_prod_nat, fun h ↦ ?_⟩
rw [tendsto_nhds_unique h hf.hasProd.tendsto_prod_nat]
exact hf.hasProd
#align summable.has_sum_iff_tendsto_nat Summable.hasSum_iff_tendsto_nat
section ContinuousMul
variable [ContinuousMul M]
@[to_additive]
theorem comp_nat_add {f : ℕ → M} {k : ℕ} (h : Multipliable fun n ↦ f (n + k)) : Multipliable f :=
h.hasProd.prod_range_mul.multipliable
@[to_additive]
theorem even_mul_odd {f : ℕ → M} (he : Multipliable fun k ↦ f (2 * k))
(ho : Multipliable fun k ↦ f (2 * k + 1)) : Multipliable f :=
(he.hasProd.even_mul_odd ho.hasProd).multipliable
end ContinuousMul
end Multipliable
section tprod
variable [T2Space M] {α β γ : Type*}
section Encodable
variable [Encodable β]
/-- You can compute a product over an encodable type by multiplying over the natural numbers and
taking a supremum. -/
@[to_additive "You can compute a sum over an encodable type by summing over the natural numbers and
taking a supremum. This is useful for outer measures."]
| Mathlib/Topology/Algebra/InfiniteSum/NatInt.lean | 124 | 132 | theorem tprod_iSup_decode₂ [CompleteLattice α] (m : α → M) (m0 : m ⊥ = 1) (s : β → α) :
∏' i : ℕ, m (⨆ b ∈ decode₂ β i, s b) = ∏' b : β, m (s b) := by |
rw [← tprod_extend_one (@encode_injective β _)]
refine tprod_congr fun n ↦ ?_
rcases em (n ∈ Set.range (encode : β → ℕ)) with ⟨a, rfl⟩ | hn
· simp [encode_injective.extend_apply]
· rw [extend_apply' _ _ _ hn]
rw [← decode₂_ne_none_iff, ne_eq, not_not] at hn
simp [hn, m0]
|
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Kenny Lau, Scott Morrison, Alex Keizer
-/
import Mathlib.Data.List.OfFn
import Mathlib.Data.List.Range
#align_import data.list.fin_range from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
/-!
# Lists of elements of `Fin n`
This file develops some results on `finRange n`.
-/
universe u
namespace List
variable {α : Type u}
@[simp]
theorem map_coe_finRange (n : ℕ) : ((finRange n) : List (Fin n)).map (Fin.val) = List.range n := by
simp_rw [finRange, map_pmap, pmap_eq_map]
exact List.map_id _
#align list.map_coe_fin_range List.map_coe_finRange
theorem finRange_succ_eq_map (n : ℕ) : finRange n.succ = 0 :: (finRange n).map Fin.succ := by
apply map_injective_iff.mpr Fin.val_injective
rw [map_cons, map_coe_finRange, range_succ_eq_map, Fin.val_zero, ← map_coe_finRange, map_map,
map_map]
simp only [Function.comp, Fin.val_succ]
#align list.fin_range_succ_eq_map List.finRange_succ_eq_map
theorem finRange_succ (n : ℕ) :
finRange n.succ = (finRange n |>.map Fin.castSucc |>.concat (.last _)) := by
apply map_injective_iff.mpr Fin.val_injective
simp [range_succ, Function.comp_def]
-- Porting note: `map_nth_le` moved to `List.finRange_map_get` in Data.List.Range
theorem ofFn_eq_pmap {n} {f : Fin n → α} :
ofFn f = pmap (fun i hi => f ⟨i, hi⟩) (range n) fun _ => mem_range.1 := by
rw [pmap_eq_map_attach]
exact ext_get (by simp) fun i hi1 hi2 => by simp [get_ofFn f ⟨i, hi1⟩]
#align list.of_fn_eq_pmap List.ofFn_eq_pmap
theorem ofFn_id (n) : ofFn id = finRange n :=
ofFn_eq_pmap
#align list.of_fn_id List.ofFn_id
| Mathlib/Data/List/FinRange.lean | 54 | 55 | theorem ofFn_eq_map {n} {f : Fin n → α} : ofFn f = (finRange n).map f := by |
rw [← ofFn_id, map_ofFn, Function.comp_id]
|
/-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.LinearAlgebra.Finsupp
import Mathlib.RingTheory.Ideal.Over
import Mathlib.RingTheory.Ideal.Prod
import Mathlib.RingTheory.Ideal.MinimalPrime
import Mathlib.RingTheory.Localization.Away.Basic
import Mathlib.RingTheory.Nilpotent.Lemmas
import Mathlib.Topology.Sets.Closeds
import Mathlib.Topology.Sober
#align_import algebraic_geometry.prime_spectrum.basic from "leanprover-community/mathlib"@"a7c017d750512a352b623b1824d75da5998457d0"
/-!
# Prime spectrum of a commutative (semi)ring
The prime spectrum of a commutative (semi)ring is the type of all prime ideals.
It is naturally endowed with a topology: the Zariski topology.
(It is also naturally endowed with a sheaf of rings,
which is constructed in `AlgebraicGeometry.StructureSheaf`.)
## Main definitions
* `PrimeSpectrum R`: The prime spectrum of a commutative (semi)ring `R`,
i.e., the set of all prime ideals of `R`.
* `zeroLocus s`: The zero locus of a subset `s` of `R`
is the subset of `PrimeSpectrum R` consisting of all prime ideals that contain `s`.
* `vanishingIdeal t`: The vanishing ideal of a subset `t` of `PrimeSpectrum R`
is the intersection of points in `t` (viewed as prime ideals).
## Conventions
We denote subsets of (semi)rings with `s`, `s'`, etc...
whereas we denote subsets of prime spectra with `t`, `t'`, etc...
## Inspiration/contributors
The contents of this file draw inspiration from <https://github.com/ramonfmir/lean-scheme>
which has contributions from Ramon Fernandez Mir, Kevin Buzzard, Kenny Lau,
and Chris Hughes (on an earlier repository).
-/
noncomputable section
open scoped Classical
universe u v
variable (R : Type u) (S : Type v)
/-- The prime spectrum of a commutative (semi)ring `R` is the type of all prime ideals of `R`.
It is naturally endowed with a topology (the Zariski topology),
and a sheaf of commutative rings (see `AlgebraicGeometry.StructureSheaf`).
It is a fundamental building block in algebraic geometry. -/
@[ext]
structure PrimeSpectrum [CommSemiring R] where
asIdeal : Ideal R
IsPrime : asIdeal.IsPrime
#align prime_spectrum PrimeSpectrum
attribute [instance] PrimeSpectrum.IsPrime
namespace PrimeSpectrum
section CommSemiRing
variable [CommSemiring R] [CommSemiring S]
variable {R S}
instance [Nontrivial R] : Nonempty <| PrimeSpectrum R :=
let ⟨I, hI⟩ := Ideal.exists_maximal R
⟨⟨I, hI.isPrime⟩⟩
/-- The prime spectrum of the zero ring is empty. -/
instance [Subsingleton R] : IsEmpty (PrimeSpectrum R) :=
⟨fun x ↦ x.IsPrime.ne_top <| SetLike.ext' <| Subsingleton.eq_univ_of_nonempty x.asIdeal.nonempty⟩
#noalign prime_spectrum.punit
variable (R S)
/-- The map from the direct sum of prime spectra to the prime spectrum of a direct product. -/
@[simp]
def primeSpectrumProdOfSum : Sum (PrimeSpectrum R) (PrimeSpectrum S) → PrimeSpectrum (R × S)
| Sum.inl ⟨I, _⟩ => ⟨Ideal.prod I ⊤, Ideal.isPrime_ideal_prod_top⟩
| Sum.inr ⟨J, _⟩ => ⟨Ideal.prod ⊤ J, Ideal.isPrime_ideal_prod_top'⟩
#align prime_spectrum.prime_spectrum_prod_of_sum PrimeSpectrum.primeSpectrumProdOfSum
/-- The prime spectrum of `R × S` is in bijection with the disjoint unions of the prime spectrum of
`R` and the prime spectrum of `S`. -/
noncomputable def primeSpectrumProd :
PrimeSpectrum (R × S) ≃ Sum (PrimeSpectrum R) (PrimeSpectrum S) :=
Equiv.symm <|
Equiv.ofBijective (primeSpectrumProdOfSum R S) (by
constructor
· rintro (⟨I, hI⟩ | ⟨J, hJ⟩) (⟨I', hI'⟩ | ⟨J', hJ'⟩) h <;>
simp only [mk.injEq, Ideal.prod.ext_iff, primeSpectrumProdOfSum] at h
· simp only [h]
· exact False.elim (hI.ne_top h.left)
· exact False.elim (hJ.ne_top h.right)
· simp only [h]
· rintro ⟨I, hI⟩
rcases (Ideal.ideal_prod_prime I).mp hI with (⟨p, ⟨hp, rfl⟩⟩ | ⟨p, ⟨hp, rfl⟩⟩)
· exact ⟨Sum.inl ⟨p, hp⟩, rfl⟩
· exact ⟨Sum.inr ⟨p, hp⟩, rfl⟩)
#align prime_spectrum.prime_spectrum_prod PrimeSpectrum.primeSpectrumProd
variable {R S}
@[simp]
| Mathlib/AlgebraicGeometry/PrimeSpectrum/Basic.lean | 116 | 119 | theorem primeSpectrumProd_symm_inl_asIdeal (x : PrimeSpectrum R) :
((primeSpectrumProd R S).symm <| Sum.inl x).asIdeal = Ideal.prod x.asIdeal ⊤ := by |
cases x
rfl
|
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Kenny Lau, Scott Morrison, Alex Keizer
-/
import Mathlib.Data.List.OfFn
import Mathlib.Data.List.Range
#align_import data.list.fin_range from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
/-!
# Lists of elements of `Fin n`
This file develops some results on `finRange n`.
-/
universe u
namespace List
variable {α : Type u}
@[simp]
theorem map_coe_finRange (n : ℕ) : ((finRange n) : List (Fin n)).map (Fin.val) = List.range n := by
simp_rw [finRange, map_pmap, pmap_eq_map]
exact List.map_id _
#align list.map_coe_fin_range List.map_coe_finRange
| Mathlib/Data/List/FinRange.lean | 30 | 34 | theorem finRange_succ_eq_map (n : ℕ) : finRange n.succ = 0 :: (finRange n).map Fin.succ := by |
apply map_injective_iff.mpr Fin.val_injective
rw [map_cons, map_coe_finRange, range_succ_eq_map, Fin.val_zero, ← map_coe_finRange, map_map,
map_map]
simp only [Function.comp, Fin.val_succ]
|
/-
Copyright (c) 2019 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Yakov Pechersky
-/
import Mathlib.Data.List.Nodup
import Mathlib.Data.List.Zip
import Mathlib.Data.Nat.Defs
import Mathlib.Data.List.Infix
#align_import data.list.rotate from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
/-!
# List rotation
This file proves basic results about `List.rotate`, the list rotation.
## Main declarations
* `List.IsRotated l₁ l₂`: States that `l₁` is a rotated version of `l₂`.
* `List.cyclicPermutations l`: The list of all cyclic permutants of `l`, up to the length of `l`.
## Tags
rotated, rotation, permutation, cycle
-/
universe u
variable {α : Type u}
open Nat Function
namespace List
theorem rotate_mod (l : List α) (n : ℕ) : l.rotate (n % l.length) = l.rotate n := by simp [rotate]
#align list.rotate_mod List.rotate_mod
@[simp]
theorem rotate_nil (n : ℕ) : ([] : List α).rotate n = [] := by simp [rotate]
#align list.rotate_nil List.rotate_nil
@[simp]
theorem rotate_zero (l : List α) : l.rotate 0 = l := by simp [rotate]
#align list.rotate_zero List.rotate_zero
-- Porting note: removing simp, simp can prove it
theorem rotate'_nil (n : ℕ) : ([] : List α).rotate' n = [] := by cases n <;> rfl
#align list.rotate'_nil List.rotate'_nil
@[simp]
| Mathlib/Data/List/Rotate.lean | 53 | 53 | theorem rotate'_zero (l : List α) : l.rotate' 0 = l := by | cases l <;> rfl
|
/-
Copyright (c) 2018 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Simon Hudon
-/
import Batteries.Data.List.Lemmas
import Batteries.Tactic.Classical
import Mathlib.Tactic.TypeStar
import Mathlib.Mathport.Rename
#align_import data.list.tfae from "leanprover-community/mathlib"@"5a3e819569b0f12cbec59d740a2613018e7b8eec"
/-!
# The Following Are Equivalent
This file allows to state that all propositions in a list are equivalent. It is used by
`Mathlib.Tactic.Tfae`.
`TFAE l` means `∀ x ∈ l, ∀ y ∈ l, x ↔ y`. This is equivalent to `Pairwise (↔) l`.
-/
namespace List
/-- TFAE: The Following (propositions) Are Equivalent.
The `tfae_have` and `tfae_finish` tactics can be useful in proofs with `TFAE` goals.
-/
def TFAE (l : List Prop) : Prop :=
∀ x ∈ l, ∀ y ∈ l, x ↔ y
#align list.tfae List.TFAE
theorem tfae_nil : TFAE [] :=
forall_mem_nil _
#align list.tfae_nil List.tfae_nil
@[simp]
theorem tfae_singleton (p) : TFAE [p] := by simp [TFAE, -eq_iff_iff]
#align list.tfae_singleton List.tfae_singleton
theorem tfae_cons_of_mem {a b} {l : List Prop} (h : b ∈ l) : TFAE (a :: l) ↔ (a ↔ b) ∧ TFAE l :=
⟨fun H => ⟨H a (by simp) b (Mem.tail a h),
fun p hp q hq => H _ (Mem.tail a hp) _ (Mem.tail a hq)⟩,
by
rintro ⟨ab, H⟩ p (_ | ⟨_, hp⟩) q (_ | ⟨_, hq⟩)
· rfl
· exact ab.trans (H _ h _ hq)
· exact (ab.trans (H _ h _ hp)).symm
· exact H _ hp _ hq⟩
#align list.tfae_cons_of_mem List.tfae_cons_of_mem
theorem tfae_cons_cons {a b} {l : List Prop} : TFAE (a :: b :: l) ↔ (a ↔ b) ∧ TFAE (b :: l) :=
tfae_cons_of_mem (Mem.head _)
#align list.tfae_cons_cons List.tfae_cons_cons
@[simp]
theorem tfae_cons_self {a} {l : List Prop} : TFAE (a :: a :: l) ↔ TFAE (a :: l) := by
simp [tfae_cons_cons]
theorem tfae_of_forall (b : Prop) (l : List Prop) (h : ∀ a ∈ l, a ↔ b) : TFAE l :=
fun _a₁ h₁ _a₂ h₂ => (h _ h₁).trans (h _ h₂).symm
#align list.tfae_of_forall List.tfae_of_forall
| Mathlib/Data/List/TFAE.lean | 63 | 71 | theorem tfae_of_cycle {a b} {l : List Prop} (h_chain : List.Chain (· → ·) a (b :: l))
(h_last : getLastD l b → a) : TFAE (a :: b :: l) := by |
induction l generalizing a b with
| nil => simp_all [tfae_cons_cons, iff_def]
| cons c l IH =>
simp only [tfae_cons_cons, getLastD_cons, tfae_singleton, and_true, chain_cons, Chain.nil] at *
rcases h_chain with ⟨ab, ⟨bc, ch⟩⟩
have := IH ⟨bc, ch⟩ (ab ∘ h_last)
exact ⟨⟨ab, h_last ∘ (this.2 c (.head _) _ (getLastD_mem_cons _ _)).1 ∘ bc⟩, this⟩
|
/-
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.IntegrallyClosed
import Mathlib.RingTheory.Localization.NumDen
import Mathlib.RingTheory.Polynomial.ScaleRoots
#align_import ring_theory.polynomial.rational_root from "leanprover-community/mathlib"@"62c0a4ef1441edb463095ea02a06e87f3dfe135c"
/-!
# Rational root theorem and integral root theorem
This file contains the rational root theorem and integral root theorem.
The rational root theorem for a unique factorization domain `A`
with localization `S`, states that the roots of `p : A[X]` in `A`'s
field of fractions are of the form `x / y` with `x y : A`, `x ∣ p.coeff 0` and
`y ∣ p.leadingCoeff`.
The corollary is the integral root theorem `isInteger_of_is_root_of_monic`:
if `p` is monic, its roots must be integers.
Finally, we use this to show unique factorization domains are integrally closed.
## References
* https://en.wikipedia.org/wiki/Rational_root_theorem
-/
open scoped Polynomial
section ScaleRoots
variable {A K R S : Type*} [CommRing A] [Field K] [CommRing R] [CommRing S]
variable {M : Submonoid A} [Algebra A S] [IsLocalization M S] [Algebra A K] [IsFractionRing A K]
open Finsupp IsFractionRing IsLocalization Polynomial
theorem scaleRoots_aeval_eq_zero_of_aeval_mk'_eq_zero {p : A[X]} {r : A} {s : M}
(hr : aeval (mk' S r s) p = 0) : aeval (algebraMap A S r) (scaleRoots p s) = 0 := by
convert scaleRoots_eval₂_eq_zero (algebraMap A S) hr
-- Porting note: added
funext
rw [aeval_def, mk'_spec' _ r s]
#align scale_roots_aeval_eq_zero_of_aeval_mk'_eq_zero scaleRoots_aeval_eq_zero_of_aeval_mk'_eq_zero
variable [IsDomain A]
| Mathlib/RingTheory/Polynomial/RationalRoot.lean | 49 | 54 | theorem num_isRoot_scaleRoots_of_aeval_eq_zero [UniqueFactorizationMonoid A] {p : A[X]} {x : K}
(hr : aeval x p = 0) : IsRoot (scaleRoots p (den A x)) (num A x) := by |
apply isRoot_of_eval₂_map_eq_zero (IsFractionRing.injective A K)
refine scaleRoots_aeval_eq_zero_of_aeval_mk'_eq_zero ?_
rw [mk'_num_den]
exact hr
|
/-
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.Algebra.Group.Subgroup.Pointwise
import Mathlib.Data.ZMod.Basic
import Mathlib.GroupTheory.GroupAction.ConjAct
import Mathlib.LinearAlgebra.Matrix.SpecialLinearGroup
#align_import number_theory.modular_forms.congruence_subgroups from "leanprover-community/mathlib"@"ae690b0c236e488a0043f6faa8ce3546e7f2f9c5"
/-!
# Congruence subgroups
This defines congruence subgroups of `SL(2, ℤ)` such as `Γ(N)`, `Γ₀(N)` and `Γ₁(N)` for `N` a
natural number.
It also contains basic results about congruence subgroups.
-/
local notation "SL(" n ", " R ")" => Matrix.SpecialLinearGroup (Fin n) R
attribute [-instance] Matrix.SpecialLinearGroup.instCoeFun
local notation:1024 "↑ₘ" A:1024 => ((A : SL(2, ℤ)) : Matrix (Fin 2) (Fin 2) ℤ)
open Matrix.SpecialLinearGroup Matrix
variable (N : ℕ)
local notation "SLMOD(" N ")" =>
@Matrix.SpecialLinearGroup.map (Fin 2) _ _ _ _ _ _ (Int.castRingHom (ZMod N))
set_option linter.uppercaseLean3 false
@[simp]
theorem SL_reduction_mod_hom_val (N : ℕ) (γ : SL(2, ℤ)) :
∀ i j : Fin 2, (SLMOD(N) γ : Matrix (Fin 2) (Fin 2) (ZMod N)) i j = ((↑ₘγ i j : ℤ) : ZMod N) :=
fun _ _ => rfl
#align SL_reduction_mod_hom_val SL_reduction_mod_hom_val
/-- The full level `N` congruence subgroup of `SL(2, ℤ)` of matrices that reduce to the identity
modulo `N`. -/
def Gamma (N : ℕ) : Subgroup SL(2, ℤ) :=
SLMOD(N).ker
#align Gamma Gamma
theorem Gamma_mem' (N : ℕ) (γ : SL(2, ℤ)) : γ ∈ Gamma N ↔ SLMOD(N) γ = 1 :=
Iff.rfl
#align Gamma_mem' Gamma_mem'
@[simp]
| Mathlib/NumberTheory/ModularForms/CongruenceSubgroups.lean | 56 | 66 | theorem Gamma_mem (N : ℕ) (γ : SL(2, ℤ)) : γ ∈ Gamma N ↔ ((↑ₘγ 0 0 : ℤ) : ZMod N) = 1 ∧
((↑ₘγ 0 1 : ℤ) : ZMod N) = 0 ∧ ((↑ₘγ 1 0 : ℤ) : ZMod N) = 0 ∧ ((↑ₘγ 1 1 : ℤ) : ZMod N) = 1 := by |
rw [Gamma_mem']
constructor
· intro h
simp [← SL_reduction_mod_hom_val N γ, h]
· intro h
ext i j
rw [SL_reduction_mod_hom_val N γ]
fin_cases i <;> fin_cases j <;> simp only [h]
exacts [h.1, h.2.1, h.2.2.1, h.2.2.2]
|
/-
Copyright (c) 2021 Vladimir Goryachev. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies, Vladimir Goryachev, Kyle Miller, Scott Morrison, Eric Rodriguez
-/
import Mathlib.SetTheory.Cardinal.Basic
import Mathlib.Tactic.Ring
#align_import data.nat.count from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988"
/-!
# Counting on ℕ
This file defines the `count` function, which gives, for any predicate on the natural numbers,
"how many numbers under `k` satisfy this predicate?".
We then prove several expected lemmas about `count`, relating it to the cardinality of other
objects, and helping to evaluate it for specific `k`.
-/
open Finset
namespace Nat
variable (p : ℕ → Prop)
section Count
variable [DecidablePred p]
/-- Count the number of naturals `k < n` satisfying `p k`. -/
def count (n : ℕ) : ℕ :=
(List.range n).countP p
#align nat.count Nat.count
@[simp]
theorem count_zero : count p 0 = 0 := by
rw [count, List.range_zero, List.countP, List.countP.go]
#align nat.count_zero Nat.count_zero
/-- A fintype instance for the set relevant to `Nat.count`. Locally an instance in locale `count` -/
def CountSet.fintype (n : ℕ) : Fintype { i // i < n ∧ p i } := by
apply Fintype.ofFinset ((Finset.range n).filter p)
intro x
rw [mem_filter, mem_range]
rfl
#align nat.count_set.fintype Nat.CountSet.fintype
scoped[Count] attribute [instance] Nat.CountSet.fintype
open Count
theorem count_eq_card_filter_range (n : ℕ) : count p n = ((range n).filter p).card := by
rw [count, List.countP_eq_length_filter]
rfl
#align nat.count_eq_card_filter_range Nat.count_eq_card_filter_range
/-- `count p n` can be expressed as the cardinality of `{k // k < n ∧ p k}`. -/
theorem count_eq_card_fintype (n : ℕ) : count p n = Fintype.card { k : ℕ // k < n ∧ p k } := by
rw [count_eq_card_filter_range, ← Fintype.card_ofFinset, ← CountSet.fintype]
rfl
#align nat.count_eq_card_fintype Nat.count_eq_card_fintype
theorem count_succ (n : ℕ) : count p (n + 1) = count p n + if p n then 1 else 0 := by
split_ifs with h <;> simp [count, List.range_succ, h]
#align nat.count_succ Nat.count_succ
@[mono]
theorem count_monotone : Monotone (count p) :=
monotone_nat_of_le_succ fun n ↦ by by_cases h : p n <;> simp [count_succ, h]
#align nat.count_monotone Nat.count_monotone
theorem count_add (a b : ℕ) : count p (a + b) = count p a + count (fun k ↦ p (a + k)) b := by
have : Disjoint ((range a).filter p) (((range b).map <| addLeftEmbedding a).filter p) := by
apply disjoint_filter_filter
rw [Finset.disjoint_left]
simp_rw [mem_map, mem_range, addLeftEmbedding_apply]
rintro x hx ⟨c, _, rfl⟩
exact (self_le_add_right _ _).not_lt hx
simp_rw [count_eq_card_filter_range, range_add, filter_union, card_union_of_disjoint this,
filter_map, addLeftEmbedding, card_map]
rfl
#align nat.count_add Nat.count_add
theorem count_add' (a b : ℕ) : count p (a + b) = count (fun k ↦ p (k + b)) a + count p b := by
rw [add_comm, count_add, add_comm]
simp_rw [add_comm b]
#align nat.count_add' Nat.count_add'
| Mathlib/Data/Nat/Count.lean | 91 | 91 | theorem count_one : count p 1 = if p 0 then 1 else 0 := by | simp [count_succ]
|
/-
Copyright (c) 2024 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro, Andrew Yang,
Johannes Hölzl, Kevin Buzzard, Yury Kudryashov
-/
import Mathlib.Algebra.Module.Submodule.Lattice
import Mathlib.Order.Hom.CompleteLattice
/-!
# Restriction of scalars for submodules
If semiring `S` acts on a semiring `R` and `M` is a module over both (compatibly with this action)
then we can turn an `R`-submodule into an `S`-submodule by forgetting the action of `R`. We call
this restriction of scalars for submodules.
## Main definitions:
* `Submodule.restrictScalars`: regard an `R`-submodule as an `S`-submodule if `S` acts on `R`
-/
namespace Submodule
variable (S : Type*) {R M : Type*} [Semiring R] [AddCommMonoid M] [Semiring S]
[Module S M] [Module R M] [SMul S R] [IsScalarTower S R M]
/-- `V.restrictScalars S` is the `S`-submodule of the `S`-module given by restriction of scalars,
corresponding to `V`, an `R`-submodule of the original `R`-module.
-/
def restrictScalars (V : Submodule R M) : Submodule S M where
carrier := V
zero_mem' := V.zero_mem
smul_mem' c _ h := V.smul_of_tower_mem c h
add_mem' hx hy := V.add_mem hx hy
#align submodule.restrict_scalars Submodule.restrictScalars
@[simp]
theorem coe_restrictScalars (V : Submodule R M) : (V.restrictScalars S : Set M) = V :=
rfl
#align submodule.coe_restrict_scalars Submodule.coe_restrictScalars
@[simp]
theorem toAddSubmonoid_restrictScalars (V : Submodule R M) :
(V.restrictScalars S).toAddSubmonoid = V.toAddSubmonoid :=
rfl
@[simp]
theorem restrictScalars_mem (V : Submodule R M) (m : M) : m ∈ V.restrictScalars S ↔ m ∈ V :=
Iff.refl _
#align submodule.restrict_scalars_mem Submodule.restrictScalars_mem
@[simp]
theorem restrictScalars_self (V : Submodule R M) : V.restrictScalars R = V :=
SetLike.coe_injective rfl
#align submodule.restrict_scalars_self Submodule.restrictScalars_self
variable (R M)
theorem restrictScalars_injective :
Function.Injective (restrictScalars S : Submodule R M → Submodule S M) := fun _ _ h =>
ext <| Set.ext_iff.1 (SetLike.ext'_iff.1 h : _)
#align submodule.restrict_scalars_injective Submodule.restrictScalars_injective
@[simp]
theorem restrictScalars_inj {V₁ V₂ : Submodule R M} :
restrictScalars S V₁ = restrictScalars S V₂ ↔ V₁ = V₂ :=
(restrictScalars_injective S _ _).eq_iff
#align submodule.restrict_scalars_inj Submodule.restrictScalars_inj
/-- Even though `p.restrictScalars S` has type `Submodule S M`, it is still an `R`-module. -/
instance restrictScalars.origModule (p : Submodule R M) : Module R (p.restrictScalars S) :=
(by infer_instance : Module R p)
#align submodule.restrict_scalars.orig_module Submodule.restrictScalars.origModule
instance restrictScalars.isScalarTower (p : Submodule R M) :
IsScalarTower S R (p.restrictScalars S) where
smul_assoc r s x := Subtype.ext <| smul_assoc r s (x : M)
#align submodule.restrict_scalars.is_scalar_tower Submodule.restrictScalars.isScalarTower
/-- `restrictScalars S` is an embedding of the lattice of `R`-submodules into
the lattice of `S`-submodules. -/
@[simps]
def restrictScalarsEmbedding : Submodule R M ↪o Submodule S M where
toFun := restrictScalars S
inj' := restrictScalars_injective S R M
map_rel_iff' := by simp [SetLike.le_def]
#align submodule.restrict_scalars_embedding Submodule.restrictScalarsEmbedding
#align submodule.restrict_scalars_embedding_apply Submodule.restrictScalarsEmbedding_apply
/-- Turning `p : Submodule R M` into an `S`-submodule gives the same module structure
as turning it into a type and adding a module structure. -/
@[simps (config := { simpRhs := true })]
def restrictScalarsEquiv (p : Submodule R M) : p.restrictScalars S ≃ₗ[R] p :=
{ AddEquiv.refl p with
map_smul' := fun _ _ => rfl }
#align submodule.restrict_scalars_equiv Submodule.restrictScalarsEquiv
#align submodule.restrict_scalars_equiv_symm_apply Submodule.restrictScalarsEquiv_symm_apply
@[simp]
theorem restrictScalars_bot : restrictScalars S (⊥ : Submodule R M) = ⊥ :=
rfl
#align submodule.restrict_scalars_bot Submodule.restrictScalars_bot
@[simp]
theorem restrictScalars_eq_bot_iff {p : Submodule R M} : restrictScalars S p = ⊥ ↔ p = ⊥ := by
simp [SetLike.ext_iff]
#align submodule.restrict_scalars_eq_bot_iff Submodule.restrictScalars_eq_bot_iff
@[simp]
theorem restrictScalars_top : restrictScalars S (⊤ : Submodule R M) = ⊤ :=
rfl
#align submodule.restrict_scalars_top Submodule.restrictScalars_top
@[simp]
| Mathlib/Algebra/Module/Submodule/RestrictScalars.lean | 116 | 117 | theorem restrictScalars_eq_top_iff {p : Submodule R M} : restrictScalars S p = ⊤ ↔ p = ⊤ := by |
simp [SetLike.ext_iff]
|
/-
Copyright (c) 2024 Chris Birkbeck. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Birkbeck
-/
import Mathlib.NumberTheory.ModularForms.EisensteinSeries.UniformConvergence
import Mathlib.Analysis.Complex.UpperHalfPlane.Manifold
import Mathlib.Analysis.Complex.LocallyUniformLimit
import Mathlib.Geometry.Manifold.MFDeriv.FDeriv
/-!
# Holomorphicity of Eisenstein series
We show that Eisenstein series of weight `k` and level `Γ(N)` with congruence condition
`a : Fin 2 → ZMod N` are holomorphic on the upper half plane, which is stated as being
MDifferentiable.
-/
noncomputable section
open ModularForm EisensteinSeries UpperHalfPlane Set Filter Function Complex Manifold
open scoped Topology BigOperators Nat Classical UpperHalfPlane
namespace EisensteinSeries
/-- Auxilary lemma showing that for any `k : ℤ` the function `z → 1/(c*z+d)^k` is
differentiable on `{z : ℂ | 0 < z.im}`. -/
lemma div_linear_zpow_differentiableOn (k : ℤ) (a : Fin 2 → ℤ) :
DifferentiableOn ℂ (fun z : ℂ => 1 / (a 0 * z + a 1) ^ k) {z : ℂ | 0 < z.im} := by
rcases ne_or_eq a 0 with ha | rfl
· apply DifferentiableOn.div (differentiableOn_const 1)
· apply DifferentiableOn.zpow
· fun_prop
· left
exact fun z hz ↦ linear_ne_zero _ ⟨z, hz⟩
((comp_ne_zero_iff _ Int.cast_injective Int.cast_zero).mpr ha)
· exact fun z hz ↦ zpow_ne_zero k (linear_ne_zero (a ·)
⟨z, hz⟩ ((comp_ne_zero_iff _ Int.cast_injective Int.cast_zero).mpr ha))
· simp only [ Fin.isValue, Pi.zero_apply, Int.cast_zero, zero_mul, add_zero, one_div]
apply differentiableOn_const
/-- Auxilary lemma showing that for any `k : ℤ` and `(a : Fin 2 → ℤ)`
the extension of `eisSummand` is differentiable on `{z : ℂ | 0 < z.im}`.-/
lemma eisSummand_extension_differentiableOn (k : ℤ) (a : Fin 2 → ℤ) :
DifferentiableOn ℂ (↑ₕeisSummand k a) {z : ℂ | 0 < z.im} := by
apply DifferentiableOn.congr (div_linear_zpow_differentiableOn k a)
intro z hz
lift z to ℍ using hz
apply comp_ofComplex
/-- Eisenstein series are MDifferentiable (i.e. holomorphic functions from `ℍ → ℂ`). -/
| Mathlib/NumberTheory/ModularForms/EisensteinSeries/MDifferentiable.lean | 54 | 65 | theorem eisensteinSeries_SIF_MDifferentiable {k : ℤ} {N : ℕ} (hk : 3 ≤ k) (a : Fin 2 → ZMod N) :
MDifferentiable 𝓘(ℂ) 𝓘(ℂ) (eisensteinSeries_SIF a k) := by |
intro τ
suffices DifferentiableAt ℂ (↑ₕeisensteinSeries_SIF a k) τ.1 by
convert MDifferentiableAt.comp τ (DifferentiableAt.mdifferentiableAt this) τ.mdifferentiable_coe
exact funext fun z ↦ (comp_ofComplex (eisensteinSeries_SIF a k) z).symm
refine DifferentiableOn.differentiableAt ?_
((isOpen_lt continuous_const Complex.continuous_im).mem_nhds τ.2)
exact (eisensteinSeries_tendstoLocallyUniformlyOn hk a).differentiableOn
(eventually_of_forall fun s ↦ DifferentiableOn.sum
fun _ _ ↦ eisSummand_extension_differentiableOn _ _)
(isOpen_lt continuous_const continuous_im)
|
/-
Copyright (c) 2022 Thomas Browning. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Thomas Browning
-/
import Mathlib.GroupTheory.Abelianization
import Mathlib.GroupTheory.Exponent
import Mathlib.GroupTheory.Transfer
#align_import group_theory.schreier from "leanprover-community/mathlib"@"8350c34a64b9bc3fc64335df8006bffcadc7baa6"
/-!
# Schreier's Lemma
In this file we prove Schreier's lemma.
## Main results
- `closure_mul_image_eq` : **Schreier's Lemma**: If `R : Set G` is a right_transversal
of `H : Subgroup G` with `1 ∈ R`, and if `G` is generated by `S : Set G`,
then `H` is generated by the `Set` `(R * S).image (fun g ↦ g * (toFun hR g)⁻¹)`.
- `fg_of_index_ne_zero` : **Schreier's Lemma**: A finite index subgroup of a finitely generated
group is finitely generated.
- `card_commutator_le_of_finite_commutatorSet`: A theorem of Schur: The size of the commutator
subgroup is bounded in terms of the number of commutators.
-/
open scoped Pointwise
namespace Subgroup
open MemRightTransversals
variable {G : Type*} [Group G] {H : Subgroup G} {R S : Set G}
theorem closure_mul_image_mul_eq_top
(hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
(closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
let f : G → R := fun g => toFun hR g
let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
change (closure U : Set G) * R = ⊤
refine top_le_iff.mp fun g _ => ?_
refine closure_induction_right ?_ ?_ ?_ (eq_top_iff.mp hS (mem_top g))
· exact ⟨1, (closure U).one_mem, 1, hR1, one_mul 1⟩
· rintro - - s hs ⟨u, hu, r, hr, rfl⟩
rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
refine Set.mul_mem_mul ((closure U).mul_mem hu ?_) (f (r * s)).coe_prop
exact subset_closure ⟨r * s, Set.mul_mem_mul hr hs, rfl⟩
· rintro - - s hs ⟨u, hu, r, hr, rfl⟩
rw [show u * r * s⁻¹ = u * (f (r * s⁻¹) * s * r⁻¹)⁻¹ * f (r * s⁻¹) by group]
refine Set.mul_mem_mul ((closure U).mul_mem hu ((closure U).inv_mem ?_)) (f (r * s⁻¹)).2
refine subset_closure ⟨f (r * s⁻¹) * s, Set.mul_mem_mul (f (r * s⁻¹)).2 hs, ?_⟩
rw [mul_right_inj, inv_inj, ← Subtype.coe_mk r hr, ← Subtype.ext_iff, Subtype.coe_mk]
apply (mem_rightTransversals_iff_existsUnique_mul_inv_mem.mp hR (f (r * s⁻¹) * s)).unique
(mul_inv_toFun_mem hR (f (r * s⁻¹) * s))
rw [mul_assoc, ← inv_inv s, ← mul_inv_rev, inv_inv]
exact toFun_mul_inv_mem hR (r * s⁻¹)
#align subgroup.closure_mul_image_mul_eq_top Subgroup.closure_mul_image_mul_eq_top
/-- **Schreier's Lemma**: If `R : Set G` is a `rightTransversal` of `H : Subgroup G`
with `1 ∈ R`, and if `G` is generated by `S : Set G`, then `H` is generated by the `Set`
`(R * S).image (fun g ↦ g * (toFun hR g)⁻¹)`. -/
theorem closure_mul_image_eq (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R)
(hS : closure S = ⊤) : closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹) = H := by
have hU : closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹) ≤ H := by
rw [closure_le]
rintro - ⟨g, -, rfl⟩
exact mul_inv_toFun_mem hR g
refine le_antisymm hU fun h hh => ?_
obtain ⟨g, hg, r, hr, rfl⟩ :=
show h ∈ _ from eq_top_iff.mp (closure_mul_image_mul_eq_top hR hR1 hS) (mem_top h)
suffices (⟨r, hr⟩ : R) = (⟨1, hR1⟩ : R) by
simpa only [show r = 1 from Subtype.ext_iff.mp this, mul_one]
apply (mem_rightTransversals_iff_existsUnique_mul_inv_mem.mp hR r).unique
· rw [Subtype.coe_mk, mul_inv_self]
exact H.one_mem
· rw [Subtype.coe_mk, inv_one, mul_one]
exact (H.mul_mem_cancel_left (hU hg)).mp hh
#align subgroup.closure_mul_image_eq Subgroup.closure_mul_image_eq
/-- **Schreier's Lemma**: If `R : Set G` is a `rightTransversal` of `H : Subgroup G`
with `1 ∈ R`, and if `G` is generated by `S : Set G`, then `H` is generated by the `Set`
`(R * S).image (fun g ↦ g * (toFun hR g)⁻¹)`. -/
| Mathlib/GroupTheory/Schreier.lean | 85 | 89 | theorem closure_mul_image_eq_top (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R)
(hS : closure S = ⊤) : closure ((R * S).image fun g =>
⟨g * (toFun hR g : G)⁻¹, mul_inv_toFun_mem hR g⟩ : Set H) = ⊤ := by |
rw [eq_top_iff, ← map_subtype_le_map_subtype, MonoidHom.map_closure, Set.image_image]
exact (map_subtype_le ⊤).trans (ge_of_eq (closure_mul_image_eq hR hR1 hS))
|
/-
Copyright (c) 2018 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Reid Barton, Mario Carneiro, Scott Morrison, Floris van Doorn
-/
import Mathlib.CategoryTheory.Adjunction.Basic
import Mathlib.CategoryTheory.Limits.Cones
#align_import category_theory.limits.is_limit from "leanprover-community/mathlib"@"740acc0e6f9adf4423f92a485d0456fc271482da"
/-!
# Limits and colimits
We set up the general theory of limits and colimits in a category.
In this introduction we only describe the setup for limits;
it is repeated, with slightly different names, for colimits.
The main structures defined in this file is
* `IsLimit c`, for `c : Cone F`, `F : J ⥤ C`, expressing that `c` is a limit cone,
See also `CategoryTheory.Limits.HasLimits` which further builds:
* `LimitCone F`, which consists of a choice of cone for `F` and the fact it is a limit cone, and
* `HasLimit F`, asserting the mere existence of some limit cone for `F`.
## Implementation
At present we simply say everything twice, in order to handle both limits and colimits.
It would be highly desirable to have some automation support,
e.g. a `@[dualize]` attribute that behaves similarly to `@[to_additive]`.
## References
* [Stacks: Limits and colimits](https://stacks.math.columbia.edu/tag/002D)
-/
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Functor Opposite
namespace CategoryTheory.Limits
-- declare the `v`'s first; see `CategoryTheory.Category` for an explanation
universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄
variable {J : Type u₁} [Category.{v₁} J] {K : Type u₂} [Category.{v₂} K]
variable {C : Type u₃} [Category.{v₃} C]
variable {F : J ⥤ C}
/-- A cone `t` on `F` is a limit cone if each cone on `F` admits a unique
cone morphism to `t`.
See <https://stacks.math.columbia.edu/tag/002E>.
-/
-- porting note (#5171): removed @[nolint has_nonempty_instance]
structure IsLimit (t : Cone F) where
/-- There is a morphism from any cone point to `t.pt` -/
lift : ∀ s : Cone F, s.pt ⟶ t.pt
/-- The map makes the triangle with the two natural transformations commute -/
fac : ∀ (s : Cone F) (j : J), lift s ≫ t.π.app j = s.π.app j := by aesop_cat
/-- It is the unique such map to do this -/
uniq : ∀ (s : Cone F) (m : s.pt ⟶ t.pt) (_ : ∀ j : J, m ≫ t.π.app j = s.π.app j), m = lift s := by
aesop_cat
#align category_theory.limits.is_limit CategoryTheory.Limits.IsLimit
#align category_theory.limits.is_limit.fac' CategoryTheory.Limits.IsLimit.fac
#align category_theory.limits.is_limit.uniq' CategoryTheory.Limits.IsLimit.uniq
-- Porting note (#10618): simp can prove this. Linter complains it still exists
attribute [-simp, nolint simpNF] IsLimit.mk.injEq
attribute [reassoc (attr := simp)] IsLimit.fac
namespace IsLimit
instance subsingleton {t : Cone F} : Subsingleton (IsLimit t) :=
⟨by intro P Q; cases P; cases Q; congr; aesop_cat⟩
#align category_theory.limits.is_limit.subsingleton CategoryTheory.Limits.IsLimit.subsingleton
/-- Given a natural transformation `α : F ⟶ G`, we give a morphism from the cone point
of any cone over `F` to the cone point of a limit cone over `G`. -/
def map {F G : J ⥤ C} (s : Cone F) {t : Cone G} (P : IsLimit t) (α : F ⟶ G) : s.pt ⟶ t.pt :=
P.lift ((Cones.postcompose α).obj s)
#align category_theory.limits.is_limit.map CategoryTheory.Limits.IsLimit.map
@[reassoc (attr := simp)]
theorem map_π {F G : J ⥤ C} (c : Cone F) {d : Cone G} (hd : IsLimit d) (α : F ⟶ G) (j : J) :
hd.map c α ≫ d.π.app j = c.π.app j ≫ α.app j :=
fac _ _ _
#align category_theory.limits.is_limit.map_π CategoryTheory.Limits.IsLimit.map_π
@[simp]
theorem lift_self {c : Cone F} (t : IsLimit c) : t.lift c = 𝟙 c.pt :=
(t.uniq _ _ fun _ => id_comp _).symm
#align category_theory.limits.is_limit.lift_self CategoryTheory.Limits.IsLimit.lift_self
-- Repackaging the definition in terms of cone morphisms.
/-- The universal morphism from any other cone to a limit cone. -/
@[simps]
def liftConeMorphism {t : Cone F} (h : IsLimit t) (s : Cone F) : s ⟶ t where hom := h.lift s
#align category_theory.limits.is_limit.lift_cone_morphism CategoryTheory.Limits.IsLimit.liftConeMorphism
| Mathlib/CategoryTheory/Limits/IsLimit.lean | 101 | 104 | theorem uniq_cone_morphism {s t : Cone F} (h : IsLimit t) {f f' : s ⟶ t} : f = f' :=
have : ∀ {g : s ⟶ t}, g = h.liftConeMorphism s := by |
intro g; apply ConeMorphism.ext; exact h.uniq _ _ g.w
this.trans this.symm
|
/-
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, *]
| Mathlib/Data/Nat/GCD/BigOperators.lean | 24 | 26 | 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]
|
/-
Copyright (c) 2023 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Data.Set.Image
import Mathlib.Data.List.GetD
#align_import data.set.list from "leanprover-community/mathlib"@"2ec920d35348cb2d13ac0e1a2ad9df0fdf1a76b4"
/-!
# Lemmas about `List`s and `Set.range`
In this file we prove lemmas about range of some operations on lists.
-/
open List
variable {α β : Type*} (l : List α)
namespace Set
| Mathlib/Data/Set/List.lean | 24 | 30 | theorem range_list_map (f : α → β) : range (map f) = { l | ∀ x ∈ l, x ∈ range f } := by |
refine antisymm (range_subset_iff.2 fun l => forall_mem_map_iff.2 fun y _ => mem_range_self _)
fun l hl => ?_
induction' l with a l ihl; · exact ⟨[], rfl⟩
rcases ihl fun x hx => hl x <| subset_cons _ _ hx with ⟨l, rfl⟩
rcases hl a (mem_cons_self _ _) with ⟨a, rfl⟩
exact ⟨a :: l, map_cons _ _ _⟩
|
/-
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
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]
set_option linter.uppercaseLean3 false in
#align cubic.prod_X_sub_C_eq Cubic.prod_X_sub_C_eq
/-! ### Coefficients -/
section Coeff
private theorem coeffs : (∀ n > 3, P.toPoly.coeff n = 0) ∧ P.toPoly.coeff 3 = P.a ∧
P.toPoly.coeff 2 = P.b ∧ P.toPoly.coeff 1 = P.c ∧ P.toPoly.coeff 0 = P.d := by
simp only [toPoly, coeff_add, coeff_C, coeff_C_mul_X, coeff_C_mul_X_pow]
set_option tactic.skipAssignedInstances false in norm_num
intro n hn
repeat' rw [if_neg]
any_goals linarith only [hn]
repeat' rw [zero_add]
@[simp]
theorem coeff_eq_zero {n : ℕ} (hn : 3 < n) : P.toPoly.coeff n = 0 :=
coeffs.1 n hn
#align cubic.coeff_eq_zero Cubic.coeff_eq_zero
@[simp]
theorem coeff_eq_a : P.toPoly.coeff 3 = P.a :=
coeffs.2.1
#align cubic.coeff_eq_a Cubic.coeff_eq_a
@[simp]
theorem coeff_eq_b : P.toPoly.coeff 2 = P.b :=
coeffs.2.2.1
#align cubic.coeff_eq_b Cubic.coeff_eq_b
@[simp]
theorem coeff_eq_c : P.toPoly.coeff 1 = P.c :=
coeffs.2.2.2.1
#align cubic.coeff_eq_c Cubic.coeff_eq_c
@[simp]
theorem coeff_eq_d : P.toPoly.coeff 0 = P.d :=
coeffs.2.2.2.2
#align cubic.coeff_eq_d Cubic.coeff_eq_d
theorem a_of_eq (h : P.toPoly = Q.toPoly) : P.a = Q.a := by rw [← coeff_eq_a, h, coeff_eq_a]
#align cubic.a_of_eq Cubic.a_of_eq
| Mathlib/Algebra/CubicDiscriminant.lean | 124 | 124 | theorem b_of_eq (h : P.toPoly = Q.toPoly) : P.b = Q.b := by | rw [← coeff_eq_b, h, coeff_eq_b]
|
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Robert Y. Lewis
-/
import Mathlib.Algebra.Order.CauSeq.Basic
#align_import data.real.cau_seq_completion from "leanprover-community/mathlib"@"cf4c49c445991489058260d75dae0ff2b1abca28"
/-!
# Cauchy completion
This file generalizes the Cauchy completion of `(ℚ, abs)` to the completion of a ring
with absolute value.
-/
namespace CauSeq.Completion
open CauSeq
section
variable {α : Type*} [LinearOrderedField α]
variable {β : Type*} [Ring β] (abv : β → α) [IsAbsoluteValue abv]
-- TODO: rename this to `CauSeq.Completion` instead of `CauSeq.Completion.Cauchy`.
/-- The Cauchy completion of a ring with absolute value. -/
def Cauchy :=
@Quotient (CauSeq _ abv) CauSeq.equiv
set_option linter.uppercaseLean3 false in
#align cau_seq.completion.Cauchy CauSeq.Completion.Cauchy
variable {abv}
/-- The map from Cauchy sequences into the Cauchy completion. -/
def mk : CauSeq _ abv → Cauchy abv :=
Quotient.mk''
#align cau_seq.completion.mk CauSeq.Completion.mk
@[simp]
theorem mk_eq_mk (f : CauSeq _ abv) : @Eq (Cauchy abv) ⟦f⟧ (mk f) :=
rfl
#align cau_seq.completion.mk_eq_mk CauSeq.Completion.mk_eq_mk
theorem mk_eq {f g : CauSeq _ abv} : mk f = mk g ↔ f ≈ g :=
Quotient.eq
#align cau_seq.completion.mk_eq CauSeq.Completion.mk_eq
/-- The map from the original ring into the Cauchy completion. -/
def ofRat (x : β) : Cauchy abv :=
mk (const abv x)
#align cau_seq.completion.of_rat CauSeq.Completion.ofRat
instance : Zero (Cauchy abv) :=
⟨ofRat 0⟩
instance : One (Cauchy abv) :=
⟨ofRat 1⟩
instance : Inhabited (Cauchy abv) :=
⟨0⟩
theorem ofRat_zero : (ofRat 0 : Cauchy abv) = 0 :=
rfl
#align cau_seq.completion.of_rat_zero CauSeq.Completion.ofRat_zero
theorem ofRat_one : (ofRat 1 : Cauchy abv) = 1 :=
rfl
#align cau_seq.completion.of_rat_one CauSeq.Completion.ofRat_one
@[simp]
| Mathlib/Algebra/Order/CauSeq/Completion.lean | 73 | 75 | theorem mk_eq_zero {f : CauSeq _ abv} : mk f = 0 ↔ LimZero f := by |
have : mk f = 0 ↔ LimZero (f - 0) := Quotient.eq
rwa [sub_zero] at this
|
/-
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Eric Wieser
-/
import Mathlib.Algebra.Quaternion
import Mathlib.Analysis.InnerProductSpace.Basic
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Topology.Algebra.Algebra
#align_import analysis.quaternion from "leanprover-community/mathlib"@"07992a1d1f7a4176c6d3f160209608be4e198566"
/-!
# Quaternions as a normed algebra
In this file we define the following structures on the space `ℍ := ℍ[ℝ]` of quaternions:
* inner product space;
* normed ring;
* normed space over `ℝ`.
We show that the norm on `ℍ[ℝ]` agrees with the euclidean norm of its components.
## Notation
The following notation is available with `open Quaternion` or `open scoped Quaternion`:
* `ℍ` : quaternions
## Tags
quaternion, normed ring, normed space, normed algebra
-/
@[inherit_doc] scoped[Quaternion] notation "ℍ" => Quaternion ℝ
open scoped RealInnerProductSpace
namespace Quaternion
instance : Inner ℝ ℍ :=
⟨fun a b => (a * star b).re⟩
theorem inner_self (a : ℍ) : ⟪a, a⟫ = normSq a :=
rfl
#align quaternion.inner_self Quaternion.inner_self
theorem inner_def (a b : ℍ) : ⟪a, b⟫ = (a * star b).re :=
rfl
#align quaternion.inner_def Quaternion.inner_def
noncomputable instance : NormedAddCommGroup ℍ :=
@InnerProductSpace.Core.toNormedAddCommGroup ℝ ℍ _ _ _
{ toInner := inferInstance
conj_symm := fun x y => by simp [inner_def, mul_comm]
nonneg_re := fun x => normSq_nonneg
definite := fun x => normSq_eq_zero.1
add_left := fun x y z => by simp only [inner_def, add_mul, add_re]
smul_left := fun x y r => by simp [inner_def] }
noncomputable instance : InnerProductSpace ℝ ℍ :=
InnerProductSpace.ofCore _
theorem normSq_eq_norm_mul_self (a : ℍ) : normSq a = ‖a‖ * ‖a‖ := by
rw [← inner_self, real_inner_self_eq_norm_mul_norm]
#align quaternion.norm_sq_eq_norm_sq Quaternion.normSq_eq_norm_mul_self
instance : NormOneClass ℍ :=
⟨by rw [norm_eq_sqrt_real_inner, inner_self, normSq.map_one, Real.sqrt_one]⟩
@[simp, norm_cast]
theorem norm_coe (a : ℝ) : ‖(a : ℍ)‖ = ‖a‖ := by
rw [norm_eq_sqrt_real_inner, inner_self, normSq_coe, Real.sqrt_sq_eq_abs, Real.norm_eq_abs]
#align quaternion.norm_coe Quaternion.norm_coe
@[simp, norm_cast]
theorem nnnorm_coe (a : ℝ) : ‖(a : ℍ)‖₊ = ‖a‖₊ :=
Subtype.ext <| norm_coe a
#align quaternion.nnnorm_coe Quaternion.nnnorm_coe
@[simp, nolint simpNF] -- Porting note (#10959): simp cannot prove this
| Mathlib/Analysis/Quaternion.lean | 83 | 84 | theorem norm_star (a : ℍ) : ‖star a‖ = ‖a‖ := by |
simp_rw [norm_eq_sqrt_real_inner, inner_self, normSq_star]
|
/-
Copyright (c) 2022 Eric Rodriguez. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Rodriguez, Eric Wieser
-/
import Mathlib.Data.List.Chain
#align_import data.list.destutter from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213"
/-!
# Destuttering of Lists
This file proves theorems about `List.destutter` (in `Data.List.Defs`), which greedily removes all
non-related items that are adjacent in a list, e.g. `[2, 2, 3, 3, 2].destutter (≠) = [2, 3, 2]`.
Note that we make no guarantees of being the longest sublist with this property; e.g.,
`[123, 1, 2, 5, 543, 1000].destutter (<) = [123, 543, 1000]`, but a longer ascending chain could be
`[1, 2, 5, 543, 1000]`.
## Main statements
* `List.destutter_sublist`: `l.destutter` is a sublist of `l`.
* `List.destutter_is_chain'`: `l.destutter` satisfies `Chain' R`.
* Analogies of these theorems for `List.destutter'`, which is the `destutter` equivalent of `Chain`.
## Tags
adjacent, chain, duplicates, remove, list, stutter, destutter
-/
variable {α : Type*} (l : List α) (R : α → α → Prop) [DecidableRel R] {a b : α}
namespace List
@[simp]
theorem destutter'_nil : destutter' R a [] = [a] :=
rfl
#align list.destutter'_nil List.destutter'_nil
theorem destutter'_cons :
(b :: l).destutter' R a = if R a b then a :: destutter' R b l else destutter' R a l :=
rfl
#align list.destutter'_cons List.destutter'_cons
variable {R}
@[simp]
theorem destutter'_cons_pos (h : R b a) : (a :: l).destutter' R b = b :: l.destutter' R a := by
rw [destutter', if_pos h]
#align list.destutter'_cons_pos List.destutter'_cons_pos
@[simp]
theorem destutter'_cons_neg (h : ¬R b a) : (a :: l).destutter' R b = l.destutter' R b := by
rw [destutter', if_neg h]
#align list.destutter'_cons_neg List.destutter'_cons_neg
variable (R)
@[simp]
theorem destutter'_singleton : [b].destutter' R a = if R a b then [a, b] else [a] := by
split_ifs with h <;> simp! [h]
#align list.destutter'_singleton List.destutter'_singleton
theorem destutter'_sublist (a) : l.destutter' R a <+ a :: l := by
induction' l with b l hl generalizing a
· simp
rw [destutter']
split_ifs
· exact Sublist.cons₂ a (hl b)
· exact (hl a).trans ((l.sublist_cons b).cons_cons a)
#align list.destutter'_sublist List.destutter'_sublist
| Mathlib/Data/List/Destutter.lean | 73 | 79 | theorem mem_destutter' (a) : a ∈ l.destutter' R a := by |
induction' l with b l hl
· simp
rw [destutter']
split_ifs
· simp
· assumption
|
/-
Copyright (c) 2022 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel
-/
import Mathlib.Data.Opposite
import Mathlib.Data.Set.Defs
#align_import data.set.opposite from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e"
/-!
# The opposite of a set
The opposite of a set `s` is simply the set obtained by taking the opposite of each member of `s`.
-/
variable {α : Type*}
open Opposite
namespace Set
/-- The opposite of a set `s` is the set obtained by taking the opposite of each member of `s`. -/
protected def op (s : Set α) : Set αᵒᵖ :=
unop ⁻¹' s
#align set.op Set.op
/-- The unop of a set `s` is the set obtained by taking the unop of each member of `s`. -/
protected def unop (s : Set αᵒᵖ) : Set α :=
op ⁻¹' s
#align set.unop Set.unop
@[simp]
theorem mem_op {s : Set α} {a : αᵒᵖ} : a ∈ s.op ↔ unop a ∈ s :=
Iff.rfl
#align set.mem_op Set.mem_op
@[simp 1100]
| Mathlib/Data/Set/Opposite.lean | 39 | 39 | theorem op_mem_op {s : Set α} {a : α} : op a ∈ s.op ↔ a ∈ s := by | rfl
|
/-
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Algebra.Group.Nat
import Mathlib.Algebra.Order.Sub.Canonical
import Mathlib.Data.List.Perm
import Mathlib.Data.Set.List
import Mathlib.Init.Quot
import Mathlib.Order.Hom.Basic
#align_import data.multiset.basic from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83"
/-!
# Multisets
These are implemented as the quotient of a list by permutations.
## Notation
We define the global infix notation `::ₘ` for `Multiset.cons`.
-/
universe v
open List Subtype Nat Function
variable {α : Type*} {β : Type v} {γ : Type*}
/-- `Multiset α` is the quotient of `List α` by list permutation. The result
is a type of finite sets with duplicates allowed. -/
def Multiset.{u} (α : Type u) : Type u :=
Quotient (List.isSetoid α)
#align multiset Multiset
namespace Multiset
-- Porting note: new
/-- The quotient map from `List α` to `Multiset α`. -/
@[coe]
def ofList : List α → Multiset α :=
Quot.mk _
instance : Coe (List α) (Multiset α) :=
⟨ofList⟩
@[simp]
theorem quot_mk_to_coe (l : List α) : @Eq (Multiset α) ⟦l⟧ l :=
rfl
#align multiset.quot_mk_to_coe Multiset.quot_mk_to_coe
@[simp]
theorem quot_mk_to_coe' (l : List α) : @Eq (Multiset α) (Quot.mk (· ≈ ·) l) l :=
rfl
#align multiset.quot_mk_to_coe' Multiset.quot_mk_to_coe'
@[simp]
theorem quot_mk_to_coe'' (l : List α) : @Eq (Multiset α) (Quot.mk Setoid.r l) l :=
rfl
#align multiset.quot_mk_to_coe'' Multiset.quot_mk_to_coe''
@[simp]
theorem coe_eq_coe {l₁ l₂ : List α} : (l₁ : Multiset α) = l₂ ↔ l₁ ~ l₂ :=
Quotient.eq
#align multiset.coe_eq_coe Multiset.coe_eq_coe
-- Porting note: new instance;
-- Porting note (#11215): TODO: move to better place
instance [DecidableEq α] (l₁ l₂ : List α) : Decidable (l₁ ≈ l₂) :=
inferInstanceAs (Decidable (l₁ ~ l₂))
-- Porting note: `Quotient.recOnSubsingleton₂ s₁ s₂` was in parens which broke elaboration
instance decidableEq [DecidableEq α] : DecidableEq (Multiset α)
| s₁, s₂ => Quotient.recOnSubsingleton₂ s₁ s₂ fun _ _ => decidable_of_iff' _ Quotient.eq
#align multiset.has_decidable_eq Multiset.decidableEq
/-- defines a size for a multiset by referring to the size of the underlying list -/
protected
def sizeOf [SizeOf α] (s : Multiset α) : ℕ :=
(Quot.liftOn s SizeOf.sizeOf) fun _ _ => Perm.sizeOf_eq_sizeOf
#align multiset.sizeof Multiset.sizeOf
instance [SizeOf α] : SizeOf (Multiset α) :=
⟨Multiset.sizeOf⟩
/-! ### Empty multiset -/
/-- `0 : Multiset α` is the empty set -/
protected def zero : Multiset α :=
@nil α
#align multiset.zero Multiset.zero
instance : Zero (Multiset α) :=
⟨Multiset.zero⟩
instance : EmptyCollection (Multiset α) :=
⟨0⟩
instance inhabitedMultiset : Inhabited (Multiset α) :=
⟨0⟩
#align multiset.inhabited_multiset Multiset.inhabitedMultiset
instance [IsEmpty α] : Unique (Multiset α) where
default := 0
uniq := by rintro ⟨_ | ⟨a, l⟩⟩; exacts [rfl, isEmptyElim a]
@[simp]
theorem coe_nil : (@nil α : Multiset α) = 0 :=
rfl
#align multiset.coe_nil Multiset.coe_nil
@[simp]
theorem empty_eq_zero : (∅ : Multiset α) = 0 :=
rfl
#align multiset.empty_eq_zero Multiset.empty_eq_zero
@[simp]
theorem coe_eq_zero (l : List α) : (l : Multiset α) = 0 ↔ l = [] :=
Iff.trans coe_eq_coe perm_nil
#align multiset.coe_eq_zero Multiset.coe_eq_zero
theorem coe_eq_zero_iff_isEmpty (l : List α) : (l : Multiset α) = 0 ↔ l.isEmpty :=
Iff.trans (coe_eq_zero l) isEmpty_iff_eq_nil.symm
#align multiset.coe_eq_zero_iff_empty Multiset.coe_eq_zero_iff_isEmpty
/-! ### `Multiset.cons` -/
/-- `cons a s` is the multiset which contains `s` plus one more instance of `a`. -/
def cons (a : α) (s : Multiset α) : Multiset α :=
Quot.liftOn s (fun l => (a :: l : Multiset α)) fun _ _ p => Quot.sound (p.cons a)
#align multiset.cons Multiset.cons
@[inherit_doc Multiset.cons]
infixr:67 " ::ₘ " => Multiset.cons
instance : Insert α (Multiset α) :=
⟨cons⟩
@[simp]
theorem insert_eq_cons (a : α) (s : Multiset α) : insert a s = a ::ₘ s :=
rfl
#align multiset.insert_eq_cons Multiset.insert_eq_cons
@[simp]
theorem cons_coe (a : α) (l : List α) : (a ::ₘ l : Multiset α) = (a :: l : List α) :=
rfl
#align multiset.cons_coe Multiset.cons_coe
@[simp]
theorem cons_inj_left {a b : α} (s : Multiset α) : a ::ₘ s = b ::ₘ s ↔ a = b :=
⟨Quot.inductionOn s fun l e =>
have : [a] ++ l ~ [b] ++ l := Quotient.exact e
singleton_perm_singleton.1 <| (perm_append_right_iff _).1 this,
congr_arg (· ::ₘ _)⟩
#align multiset.cons_inj_left Multiset.cons_inj_left
@[simp]
| Mathlib/Data/Multiset/Basic.lean | 157 | 158 | theorem cons_inj_right (a : α) : ∀ {s t : Multiset α}, a ::ₘ s = a ::ₘ t ↔ s = t := by |
rintro ⟨l₁⟩ ⟨l₂⟩; simp
|
/-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Data.List.Lattice
import Mathlib.Data.List.Range
import Mathlib.Data.Bool.Basic
#align_import data.list.intervals from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213"
/-!
# Intervals in ℕ
This file defines intervals of naturals. `List.Ico m n` is the list of integers greater than `m`
and strictly less than `n`.
## TODO
- Define `Ioo` and `Icc`, state basic lemmas about them.
- Also do the versions for integers?
- One could generalise even further, defining 'locally finite partial orders', for which
`Set.Ico a b` is `[Finite]`, and 'locally finite total orders', for which there is a list model.
- Once the above is done, get rid of `Data.Int.range` (and maybe `List.range'`?).
-/
open Nat
namespace List
/-- `Ico n m` is the list of natural numbers `n ≤ x < m`.
(Ico stands for "interval, closed-open".)
See also `Data/Set/Intervals.lean` for `Set.Ico`, modelling intervals in general preorders, and
`Multiset.Ico` and `Finset.Ico` for `n ≤ x < m` as a multiset or as a finset.
-/
def Ico (n m : ℕ) : List ℕ :=
range' n (m - n)
#align list.Ico List.Ico
namespace Ico
theorem zero_bot (n : ℕ) : Ico 0 n = range n := by rw [Ico, Nat.sub_zero, range_eq_range']
#align list.Ico.zero_bot List.Ico.zero_bot
@[simp]
theorem length (n m : ℕ) : length (Ico n m) = m - n := by
dsimp [Ico]
simp [length_range', autoParam]
#align list.Ico.length List.Ico.length
theorem pairwise_lt (n m : ℕ) : Pairwise (· < ·) (Ico n m) := by
dsimp [Ico]
simp [pairwise_lt_range', autoParam]
#align list.Ico.pairwise_lt List.Ico.pairwise_lt
theorem nodup (n m : ℕ) : Nodup (Ico n m) := by
dsimp [Ico]
simp [nodup_range', autoParam]
#align list.Ico.nodup List.Ico.nodup
@[simp]
theorem mem {n m l : ℕ} : l ∈ Ico n m ↔ n ≤ l ∧ l < m := by
suffices n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m by simp [Ico, this]
rcases le_total n m with hnm | hmn
· rw [Nat.add_sub_cancel' hnm]
· rw [Nat.sub_eq_zero_iff_le.mpr hmn, Nat.add_zero]
exact
and_congr_right fun hnl =>
Iff.intro (fun hln => (not_le_of_gt hln hnl).elim) fun hlm => lt_of_lt_of_le hlm hmn
#align list.Ico.mem List.Ico.mem
theorem eq_nil_of_le {n m : ℕ} (h : m ≤ n) : Ico n m = [] := by
simp [Ico, Nat.sub_eq_zero_iff_le.mpr h]
#align list.Ico.eq_nil_of_le List.Ico.eq_nil_of_le
theorem map_add (n m k : ℕ) : (Ico n m).map (k + ·) = Ico (n + k) (m + k) := by
rw [Ico, Ico, map_add_range', Nat.add_sub_add_right m k, Nat.add_comm n k]
#align list.Ico.map_add List.Ico.map_add
theorem map_sub (n m k : ℕ) (h₁ : k ≤ n) :
((Ico n m).map fun x => x - k) = Ico (n - k) (m - k) := by
rw [Ico, Ico, Nat.sub_sub_sub_cancel_right h₁, map_sub_range' _ _ _ h₁]
#align list.Ico.map_sub List.Ico.map_sub
@[simp]
theorem self_empty {n : ℕ} : Ico n n = [] :=
eq_nil_of_le (le_refl n)
#align list.Ico.self_empty List.Ico.self_empty
@[simp]
theorem eq_empty_iff {n m : ℕ} : Ico n m = [] ↔ m ≤ n :=
Iff.intro (fun h => Nat.sub_eq_zero_iff_le.mp <| by rw [← length, h, List.length]) eq_nil_of_le
#align list.Ico.eq_empty_iff List.Ico.eq_empty_iff
theorem append_consecutive {n m l : ℕ} (hnm : n ≤ m) (hml : m ≤ l) :
Ico n m ++ Ico m l = Ico n l := by
dsimp only [Ico]
convert range'_append n (m-n) (l-m) 1 using 2
· rw [Nat.one_mul, Nat.add_sub_cancel' hnm]
· rw [Nat.sub_add_sub_cancel hml hnm]
#align list.Ico.append_consecutive List.Ico.append_consecutive
@[simp]
theorem inter_consecutive (n m l : ℕ) : Ico n m ∩ Ico m l = [] := by
apply eq_nil_iff_forall_not_mem.2
intro a
simp only [and_imp, not_and, not_lt, List.mem_inter_iff, List.Ico.mem]
intro _ h₂ h₃
exfalso
exact not_lt_of_ge h₃ h₂
#align list.Ico.inter_consecutive List.Ico.inter_consecutive
@[simp]
theorem bagInter_consecutive (n m l : Nat) :
@List.bagInter ℕ instBEqOfDecidableEq (Ico n m) (Ico m l) = [] :=
(bagInter_nil_iff_inter_nil _ _).2 (by convert inter_consecutive n m l)
#align list.Ico.bag_inter_consecutive List.Ico.bagInter_consecutive
@[simp]
theorem succ_singleton {n : ℕ} : Ico n (n + 1) = [n] := by
dsimp [Ico]
simp [range', Nat.add_sub_cancel_left]
#align list.Ico.succ_singleton List.Ico.succ_singleton
theorem succ_top {n m : ℕ} (h : n ≤ m) : Ico n (m + 1) = Ico n m ++ [m] := by
rwa [← succ_singleton, append_consecutive]
exact Nat.le_succ _
#align list.Ico.succ_top List.Ico.succ_top
| Mathlib/Data/List/Intervals.lean | 130 | 132 | theorem eq_cons {n m : ℕ} (h : n < m) : Ico n m = n :: Ico (n + 1) m := by |
rw [← append_consecutive (Nat.le_succ n) h, succ_singleton]
rfl
|
/-
Copyright (c) 2022 Matej Penciak. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Matej Penciak, Moritz Doll, Fabien Clery
-/
import Mathlib.LinearAlgebra.Matrix.NonsingularInverse
#align_import linear_algebra.symplectic_group from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
/-!
# The Symplectic Group
This file defines the symplectic group and proves elementary properties.
## Main Definitions
* `Matrix.J`: the canonical `2n × 2n` skew-symmetric matrix
* `symplecticGroup`: the group of symplectic matrices
## TODO
* Every symplectic matrix has determinant 1.
* For `n = 1` the symplectic group coincides with the special linear group.
-/
open Matrix
variable {l R : Type*}
namespace Matrix
variable (l) [DecidableEq l] (R) [CommRing R]
section JMatrixLemmas
/-- The matrix defining the canonical skew-symmetric bilinear form. -/
def J : Matrix (Sum l l) (Sum l l) R :=
Matrix.fromBlocks 0 (-1) 1 0
set_option linter.uppercaseLean3 false in
#align matrix.J Matrix.J
@[simp]
theorem J_transpose : (J l R)ᵀ = -J l R := by
rw [J, fromBlocks_transpose, ← neg_one_smul R (fromBlocks _ _ _ _ : Matrix (l ⊕ l) (l ⊕ l) R),
fromBlocks_smul, Matrix.transpose_zero, Matrix.transpose_one, transpose_neg]
simp [fromBlocks]
set_option linter.uppercaseLean3 false in
#align matrix.J_transpose Matrix.J_transpose
variable [Fintype l]
theorem J_squared : J l R * J l R = -1 := by
rw [J, fromBlocks_multiply]
simp only [Matrix.zero_mul, Matrix.neg_mul, zero_add, neg_zero, Matrix.one_mul, add_zero]
rw [← neg_zero, ← Matrix.fromBlocks_neg, ← fromBlocks_one]
set_option linter.uppercaseLean3 false in
#align matrix.J_squared Matrix.J_squared
theorem J_inv : (J l R)⁻¹ = -J l R := by
refine Matrix.inv_eq_right_inv ?_
rw [Matrix.mul_neg, J_squared]
exact neg_neg 1
set_option linter.uppercaseLean3 false in
#align matrix.J_inv Matrix.J_inv
theorem J_det_mul_J_det : det (J l R) * det (J l R) = 1 := by
rw [← det_mul, J_squared, ← one_smul R (-1 : Matrix _ _ R), smul_neg, ← neg_smul, det_smul,
Fintype.card_sum, det_one, mul_one]
apply Even.neg_one_pow
exact even_add_self _
set_option linter.uppercaseLean3 false in
#align matrix.J_det_mul_J_det Matrix.J_det_mul_J_det
theorem isUnit_det_J : IsUnit (det (J l R)) :=
isUnit_iff_exists_inv.mpr ⟨det (J l R), J_det_mul_J_det _ _⟩
set_option linter.uppercaseLean3 false in
#align matrix.is_unit_det_J Matrix.isUnit_det_J
end JMatrixLemmas
variable [Fintype l]
/-- The group of symplectic matrices over a ring `R`. -/
def symplecticGroup : Submonoid (Matrix (Sum l l) (Sum l l) R) where
carrier := { A | A * J l R * Aᵀ = J l R }
mul_mem' {a b} ha hb := by
simp only [Set.mem_setOf_eq, transpose_mul] at *
rw [← Matrix.mul_assoc, a.mul_assoc, a.mul_assoc, hb]
exact ha
one_mem' := by simp
#align matrix.symplectic_group Matrix.symplecticGroup
end Matrix
namespace SymplecticGroup
variable [DecidableEq l] [Fintype l] [CommRing R]
open Matrix
theorem mem_iff {A : Matrix (Sum l l) (Sum l l) R} :
A ∈ symplecticGroup l R ↔ A * J l R * Aᵀ = J l R := by simp [symplecticGroup]
#align symplectic_group.mem_iff SymplecticGroup.mem_iff
-- Porting note: Previous proof was `by infer_instance`
instance coeMatrix : Coe (symplecticGroup l R) (Matrix (Sum l l) (Sum l l) R) :=
⟨Subtype.val⟩
#align symplectic_group.coe_matrix SymplecticGroup.coeMatrix
section SymplecticJ
variable (l) (R)
| Mathlib/LinearAlgebra/SymplecticGroup.lean | 114 | 116 | theorem J_mem : J l R ∈ symplecticGroup l R := by |
rw [mem_iff, J, fromBlocks_multiply, fromBlocks_transpose, fromBlocks_multiply]
simp
|
/-
Copyright (c) 2022 Robert Y. Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Y. Lewis, Heather Macbeth, Johan Commelin
-/
import Mathlib.RingTheory.WittVector.Domain
import Mathlib.RingTheory.WittVector.MulCoeff
import Mathlib.RingTheory.DiscreteValuationRing.Basic
import Mathlib.Tactic.LinearCombination
#align_import ring_theory.witt_vector.discrete_valuation_ring from "leanprover-community/mathlib"@"c163ec99dfc664628ca15d215fce0a5b9c265b68"
/-!
# Witt vectors over a perfect ring
This file establishes that Witt vectors over a perfect field are a discrete valuation ring.
When `k` is a perfect ring, a nonzero `a : 𝕎 k` can be written as `p^m * b` for some `m : ℕ` and
`b : 𝕎 k` with nonzero 0th coefficient.
When `k` is also a field, this `b` can be chosen to be a unit of `𝕎 k`.
## Main declarations
* `WittVector.exists_eq_pow_p_mul`: the existence of this element `b` over a perfect ring
* `WittVector.exists_eq_pow_p_mul'`: the existence of this unit `b` over a perfect field
* `WittVector.discreteValuationRing`: `𝕎 k` is a discrete valuation ring if `k` is a perfect field
-/
noncomputable section
namespace WittVector
variable {p : ℕ} [hp : Fact p.Prime]
local notation "𝕎" => WittVector p
section CommRing
variable {k : Type*} [CommRing k] [CharP k p]
/-- This is the `n+1`st coefficient of our inverse. -/
def succNthValUnits (n : ℕ) (a : Units k) (A : 𝕎 k) (bs : Fin (n + 1) → k) : k :=
-↑(a⁻¹ ^ p ^ (n + 1)) *
(A.coeff (n + 1) * ↑(a⁻¹ ^ p ^ (n + 1)) + nthRemainder p n (truncateFun (n + 1) A) bs)
#align witt_vector.succ_nth_val_units WittVector.succNthValUnits
/--
Recursively defines the sequence of coefficients for the inverse to a Witt vector whose first entry
is a unit.
-/
noncomputable def inverseCoeff (a : Units k) (A : 𝕎 k) : ℕ → k
| 0 => ↑a⁻¹
| n + 1 => succNthValUnits n a A fun i => inverseCoeff a A i.val
#align witt_vector.inverse_coeff WittVector.inverseCoeff
/--
Upgrade a Witt vector `A` whose first entry `A.coeff 0` is a unit to be, itself, a unit in `𝕎 k`.
-/
def mkUnit {a : Units k} {A : 𝕎 k} (hA : A.coeff 0 = a) : Units (𝕎 k) :=
Units.mkOfMulEqOne A (@WittVector.mk' p _ (inverseCoeff a A)) (by
ext n
induction' n with n _
· simp [WittVector.mul_coeff_zero, inverseCoeff, hA]
let H_coeff := A.coeff (n + 1) * ↑(a⁻¹ ^ p ^ (n + 1)) +
nthRemainder p n (truncateFun (n + 1) A) fun i : Fin (n + 1) => inverseCoeff a A i
have H := Units.mul_inv (a ^ p ^ (n + 1))
linear_combination (norm := skip) -H_coeff * H
have ha : (a : k) ^ p ^ (n + 1) = ↑(a ^ p ^ (n + 1)) := by norm_cast
have ha_inv : (↑a⁻¹ : k) ^ p ^ (n + 1) = ↑(a ^ p ^ (n + 1))⁻¹ := by norm_cast
simp only [nthRemainder_spec, inverseCoeff, succNthValUnits, hA,
one_coeff_eq_of_pos, Nat.succ_pos', ha_inv, ha, inv_pow]
ring!)
#align witt_vector.mk_unit WittVector.mkUnit
@[simp]
theorem coe_mkUnit {a : Units k} {A : 𝕎 k} (hA : A.coeff 0 = a) : (mkUnit hA : 𝕎 k) = A :=
rfl
#align witt_vector.coe_mk_unit WittVector.coe_mkUnit
end CommRing
section Field
variable {k : Type*} [Field k] [CharP k p]
| Mathlib/RingTheory/WittVector/DiscreteValuationRing.lean | 88 | 91 | theorem isUnit_of_coeff_zero_ne_zero (x : 𝕎 k) (hx : x.coeff 0 ≠ 0) : IsUnit x := by |
let y : kˣ := Units.mk0 (x.coeff 0) hx
have hy : x.coeff 0 = y := rfl
exact (mkUnit hy).isUnit
|
/-
Copyright (c) 2021 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.Tactic.CategoryTheory.Elementwise
import Mathlib.CategoryTheory.Limits.Shapes.Multiequalizer
import Mathlib.CategoryTheory.Limits.Constructions.EpiMono
import Mathlib.CategoryTheory.Limits.Preserves.Limits
import Mathlib.CategoryTheory.Limits.Shapes.Types
#align_import category_theory.glue_data from "leanprover-community/mathlib"@"14b69e9f3c16630440a2cbd46f1ddad0d561dee7"
/-!
# Gluing data
We define `GlueData` as a family of data needed to glue topological spaces, schemes, etc. We
provide the API to realize it as a multispan diagram, and also state lemmas about its
interaction with a functor that preserves certain pullbacks.
-/
noncomputable section
open CategoryTheory.Limits
namespace CategoryTheory
universe v u₁ u₂
variable (C : Type u₁) [Category.{v} C] {C' : Type u₂} [Category.{v} C']
/-- A gluing datum consists of
1. An index type `J`
2. An object `U i` for each `i : J`.
3. An object `V i j` for each `i j : J`.
4. A monomorphism `f i j : V i j ⟶ U i` for each `i j : J`.
5. A transition map `t i j : V i j ⟶ V j i` for each `i j : J`.
such that
6. `f i i` is an isomorphism.
7. `t i i` is the identity.
8. The pullback for `f i j` and `f i k` exists.
9. `V i j ×[U i] V i k ⟶ V i j ⟶ V j i` factors through `V j k ×[U j] V j i ⟶ V j i` via some
`t' : V i j ×[U i] V i k ⟶ V j k ×[U j] V j i`.
10. `t' i j k ≫ t' j k i ≫ t' k i j = 𝟙 _`.
-/
-- Porting note(#5171): linter not ported yet
-- @[nolint has_nonempty_instance]
structure GlueData where
J : Type v
U : J → C
V : J × J → C
f : ∀ i j, V (i, j) ⟶ U i
f_mono : ∀ i j, Mono (f i j) := by infer_instance
f_hasPullback : ∀ i j k, HasPullback (f i j) (f i k) := by infer_instance
f_id : ∀ i, IsIso (f i i) := by infer_instance
t : ∀ i j, V (i, j) ⟶ V (j, i)
t_id : ∀ i, t i i = 𝟙 _
t' : ∀ i j k, pullback (f i j) (f i k) ⟶ pullback (f j k) (f j i)
t_fac : ∀ i j k, t' i j k ≫ pullback.snd = pullback.fst ≫ t i j
cocycle : ∀ i j k, t' i j k ≫ t' j k i ≫ t' k i j = 𝟙 _
#align category_theory.glue_data CategoryTheory.GlueData
attribute [simp] GlueData.t_id
attribute [instance] GlueData.f_id GlueData.f_mono GlueData.f_hasPullback
attribute [reassoc] GlueData.t_fac GlueData.cocycle
namespace GlueData
variable {C}
variable (D : GlueData C)
@[simp]
theorem t'_iij (i j : D.J) : D.t' i i j = (pullbackSymmetry _ _).hom := by
have eq₁ := D.t_fac i i j
have eq₂ := (IsIso.eq_comp_inv (D.f i i)).mpr (@pullback.condition _ _ _ _ _ _ (D.f i j) _)
rw [D.t_id, Category.comp_id, eq₂] at eq₁
have eq₃ := (IsIso.eq_comp_inv (D.f i i)).mp eq₁
rw [Category.assoc, ← pullback.condition, ← Category.assoc] at eq₃
exact
Mono.right_cancellation _ _
((Mono.right_cancellation _ _ eq₃).trans (pullbackSymmetry_hom_comp_fst _ _).symm)
#align category_theory.glue_data.t'_iij CategoryTheory.GlueData.t'_iij
theorem t'_jii (i j : D.J) : D.t' j i i = pullback.fst ≫ D.t j i ≫ inv pullback.snd := by
rw [← Category.assoc, ← D.t_fac]
simp
#align category_theory.glue_data.t'_jii CategoryTheory.GlueData.t'_jii
theorem t'_iji (i j : D.J) : D.t' i j i = pullback.fst ≫ D.t i j ≫ inv pullback.snd := by
rw [← Category.assoc, ← D.t_fac]
simp
#align category_theory.glue_data.t'_iji CategoryTheory.GlueData.t'_iji
@[reassoc, elementwise (attr := simp)]
theorem t_inv (i j : D.J) : D.t i j ≫ D.t j i = 𝟙 _ := by
have eq : (pullbackSymmetry (D.f i i) (D.f i j)).hom = pullback.snd ≫ inv pullback.fst := by simp
have := D.cocycle i j i
rw [D.t'_iij, D.t'_jii, D.t'_iji, fst_eq_snd_of_mono_eq, eq] at this
simp only [Category.assoc, IsIso.inv_hom_id_assoc] at this
rw [← IsIso.eq_inv_comp, ← Category.assoc, IsIso.comp_inv_eq] at this
simpa using this
#align category_theory.glue_data.t_inv CategoryTheory.GlueData.t_inv
| Mathlib/CategoryTheory/GlueData.lean | 108 | 111 | theorem t'_inv (i j k : D.J) :
D.t' i j k ≫ (pullbackSymmetry _ _).hom ≫ D.t' j i k ≫ (pullbackSymmetry _ _).hom = 𝟙 _ := by |
rw [← cancel_mono (pullback.fst : pullback (D.f i j) (D.f i k) ⟶ _)]
simp [t_fac, t_fac_assoc]
|
/-
Copyright (c) 2021 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
import Mathlib.Data.Int.Bitwise
import Mathlib.LinearAlgebra.Matrix.NonsingularInverse
import Mathlib.LinearAlgebra.Matrix.Symmetric
#align_import linear_algebra.matrix.zpow from "leanprover-community/mathlib"@"03fda9112aa6708947da13944a19310684bfdfcb"
/-!
# Integer powers of square matrices
In this file, we define integer power of matrices, relying on
the nonsingular inverse definition for negative powers.
## Implementation details
The main definition is a direct recursive call on the integer inductive type,
as provided by the `DivInvMonoid.Pow` default implementation.
The lemma names are taken from `Algebra.GroupWithZero.Power`.
## Tags
matrix inverse, matrix powers
-/
open Matrix
namespace Matrix
variable {n' : Type*} [DecidableEq n'] [Fintype n'] {R : Type*} [CommRing R]
local notation "M" => Matrix n' n' R
noncomputable instance : DivInvMonoid M :=
{ show Monoid M by infer_instance, show Inv M by infer_instance with }
section NatPow
@[simp]
theorem inv_pow' (A : M) (n : ℕ) : A⁻¹ ^ n = (A ^ n)⁻¹ := by
induction' n with n ih
· simp
· rw [pow_succ A, mul_inv_rev, ← ih, ← pow_succ']
#align matrix.inv_pow' Matrix.inv_pow'
theorem pow_sub' (A : M) {m n : ℕ} (ha : IsUnit A.det) (h : n ≤ m) :
A ^ (m - n) = A ^ m * (A ^ n)⁻¹ := by
rw [← tsub_add_cancel_of_le h, pow_add, Matrix.mul_assoc, mul_nonsing_inv,
tsub_add_cancel_of_le h, Matrix.mul_one]
simpa using ha.pow n
#align matrix.pow_sub' Matrix.pow_sub'
theorem pow_inv_comm' (A : M) (m n : ℕ) : A⁻¹ ^ m * A ^ n = A ^ n * A⁻¹ ^ m := by
induction' n with n IH generalizing m
· simp
cases' m with m m
· simp
rcases nonsing_inv_cancel_or_zero A with (⟨h, h'⟩ | h)
· calc
A⁻¹ ^ (m + 1) * A ^ (n + 1) = A⁻¹ ^ m * (A⁻¹ * A) * A ^ n := by
simp only [pow_succ A⁻¹, pow_succ' A, Matrix.mul_assoc]
_ = A ^ n * A⁻¹ ^ m := by simp only [h, Matrix.mul_one, Matrix.one_mul, IH m]
_ = A ^ n * (A * A⁻¹) * A⁻¹ ^ m := by simp only [h', Matrix.mul_one, Matrix.one_mul]
_ = A ^ (n + 1) * A⁻¹ ^ (m + 1) := by
simp only [pow_succ A, pow_succ' A⁻¹, Matrix.mul_assoc]
· simp [h]
#align matrix.pow_inv_comm' Matrix.pow_inv_comm'
end NatPow
section ZPow
open Int
@[simp]
theorem one_zpow : ∀ n : ℤ, (1 : M) ^ n = 1
| (n : ℕ) => by rw [zpow_natCast, one_pow]
| -[n+1] => by rw [zpow_negSucc, one_pow, inv_one]
#align matrix.one_zpow Matrix.one_zpow
theorem zero_zpow : ∀ z : ℤ, z ≠ 0 → (0 : M) ^ z = 0
| (n : ℕ), h => by
rw [zpow_natCast, zero_pow]
exact mod_cast h
| -[n+1], _ => by simp [zero_pow n.succ_ne_zero]
#align matrix.zero_zpow Matrix.zero_zpow
| Mathlib/LinearAlgebra/Matrix/ZPow.lean | 92 | 95 | theorem zero_zpow_eq (n : ℤ) : (0 : M) ^ n = if n = 0 then 1 else 0 := by |
split_ifs with h
· rw [h, zpow_zero]
· rw [zero_zpow _ h]
|
/-
Copyright (c) 2018 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Jens Wagemaker
-/
import Mathlib.Algebra.Group.Even
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Algebra.GroupWithZero.Hom
import Mathlib.Algebra.Group.Commute.Units
import Mathlib.Algebra.Group.Units.Hom
import Mathlib.Algebra.Order.Monoid.Canonical.Defs
import Mathlib.Algebra.Ring.Units
#align_import algebra.associated from "leanprover-community/mathlib"@"2f3994e1b117b1e1da49bcfb67334f33460c3ce4"
/-!
# Associated, prime, and irreducible elements.
In this file we define the predicate `Prime p`
saying that an element of a commutative monoid with zero is prime.
Namely, `Prime p` means that `p` isn't zero, it isn't a unit,
and `p ∣ a * b → p ∣ a ∨ p ∣ b` for all `a`, `b`;
In decomposition monoids (e.g., `ℕ`, `ℤ`), this predicate is equivalent to `Irreducible`,
however this is not true in general.
We also define an equivalence relation `Associated`
saying that two elements of a monoid differ by a multiplication by a unit.
Then we show that the quotient type `Associates` is a monoid
and prove basic properties of this quotient.
-/
variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}
section Prime
variable [CommMonoidWithZero α]
/-- An element `p` of a commutative monoid with zero (e.g., a ring) is called *prime*,
if it's not zero, not a unit, and `p ∣ a * b → p ∣ a ∨ p ∣ b` for all `a`, `b`. -/
def Prime (p : α) : Prop :=
p ≠ 0 ∧ ¬IsUnit p ∧ ∀ a b, p ∣ a * b → p ∣ a ∨ p ∣ b
#align prime Prime
namespace Prime
variable {p : α} (hp : Prime p)
theorem ne_zero : p ≠ 0 :=
hp.1
#align prime.ne_zero Prime.ne_zero
theorem not_unit : ¬IsUnit p :=
hp.2.1
#align prime.not_unit Prime.not_unit
theorem not_dvd_one : ¬p ∣ 1 :=
mt (isUnit_of_dvd_one ·) hp.not_unit
#align prime.not_dvd_one Prime.not_dvd_one
theorem ne_one : p ≠ 1 := fun h => hp.2.1 (h.symm ▸ isUnit_one)
#align prime.ne_one Prime.ne_one
theorem dvd_or_dvd (hp : Prime p) {a b : α} (h : p ∣ a * b) : p ∣ a ∨ p ∣ b :=
hp.2.2 a b h
#align prime.dvd_or_dvd Prime.dvd_or_dvd
theorem dvd_mul {a b : α} : p ∣ a * b ↔ p ∣ a ∨ p ∣ b :=
⟨hp.dvd_or_dvd, (Or.elim · (dvd_mul_of_dvd_left · _) (dvd_mul_of_dvd_right · _))⟩
theorem isPrimal (hp : Prime p) : IsPrimal p := fun _a _b dvd ↦ (hp.dvd_or_dvd dvd).elim
(fun h ↦ ⟨p, 1, h, one_dvd _, (mul_one p).symm⟩) fun h ↦ ⟨1, p, one_dvd _, h, (one_mul p).symm⟩
theorem not_dvd_mul {a b : α} (ha : ¬ p ∣ a) (hb : ¬ p ∣ b) : ¬ p ∣ a * b :=
hp.dvd_mul.not.mpr <| not_or.mpr ⟨ha, hb⟩
| Mathlib/Algebra/Associated.lean | 77 | 86 | theorem dvd_of_dvd_pow (hp : Prime p) {a : α} {n : ℕ} (h : p ∣ a ^ n) : p ∣ a := by |
induction' n with n ih
· rw [pow_zero] at h
have := isUnit_of_dvd_one h
have := not_unit hp
contradiction
rw [pow_succ'] at h
cases' dvd_or_dvd hp h with dvd_a dvd_pow
· assumption
exact ih dvd_pow
|
/-
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, Mitchell Lee
-/
import Mathlib.Topology.Algebra.InfiniteSum.Defs
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Topology.Algebra.Monoid
/-!
# Lemmas on infinite sums and products in topological monoids
This file contains many simple lemmas on `tsum`, `HasSum` etc, which are placed here in order to
keep the basic file of definitions as short as possible.
Results requiring a group (rather than monoid) structure on the target should go in `Group.lean`.
-/
noncomputable section
open Filter Finset Function
open scoped Topology
variable {α β γ δ : Type*}
section HasProd
variable [CommMonoid α] [TopologicalSpace α]
variable {f g : β → α} {a b : α} {s : Finset β}
/-- Constant one function has product `1` -/
@[to_additive "Constant zero function has sum `0`"]
theorem hasProd_one : HasProd (fun _ ↦ 1 : β → α) 1 := by simp [HasProd, tendsto_const_nhds]
#align has_sum_zero hasSum_zero
@[to_additive]
theorem hasProd_empty [IsEmpty β] : HasProd f 1 := by
convert @hasProd_one α β _ _
#align has_sum_empty hasSum_empty
@[to_additive]
theorem multipliable_one : Multipliable (fun _ ↦ 1 : β → α) :=
hasProd_one.multipliable
#align summable_zero summable_zero
@[to_additive]
theorem multipliable_empty [IsEmpty β] : Multipliable f :=
hasProd_empty.multipliable
#align summable_empty summable_empty
@[to_additive]
theorem multipliable_congr (hfg : ∀ b, f b = g b) : Multipliable f ↔ Multipliable g :=
iff_of_eq (congr_arg Multipliable <| funext hfg)
#align summable_congr summable_congr
@[to_additive]
theorem Multipliable.congr (hf : Multipliable f) (hfg : ∀ b, f b = g b) : Multipliable g :=
(multipliable_congr hfg).mp hf
#align summable.congr Summable.congr
@[to_additive]
lemma HasProd.congr_fun (hf : HasProd f a) (h : ∀ x : β, g x = f x) : HasProd g a :=
(funext h : g = f) ▸ hf
@[to_additive]
theorem HasProd.hasProd_of_prod_eq {g : γ → α}
(h_eq : ∀ u : Finset γ, ∃ v : Finset β, ∀ v', v ⊆ v' →
∃ u', u ⊆ u' ∧ ∏ x ∈ u', g x = ∏ b ∈ v', f b)
(hf : HasProd g a) : HasProd f a :=
le_trans (map_atTop_finset_prod_le_of_prod_eq h_eq) hf
#align has_sum.has_sum_of_sum_eq HasSum.hasSum_of_sum_eq
@[to_additive]
theorem hasProd_iff_hasProd {g : γ → α}
(h₁ : ∀ u : Finset γ, ∃ v : Finset β, ∀ v', v ⊆ v' →
∃ u', u ⊆ u' ∧ ∏ x ∈ u', g x = ∏ b ∈ v', f b)
(h₂ : ∀ v : Finset β, ∃ u : Finset γ, ∀ u', u ⊆ u' →
∃ v', v ⊆ v' ∧ ∏ b ∈ v', f b = ∏ x ∈ u', g x) :
HasProd f a ↔ HasProd g a :=
⟨HasProd.hasProd_of_prod_eq h₂, HasProd.hasProd_of_prod_eq h₁⟩
#align has_sum_iff_has_sum hasSum_iff_hasSum
@[to_additive]
theorem Function.Injective.multipliable_iff {g : γ → β} (hg : Injective g)
(hf : ∀ x ∉ Set.range g, f x = 1) : Multipliable (f ∘ g) ↔ Multipliable f :=
exists_congr fun _ ↦ hg.hasProd_iff hf
#align function.injective.summable_iff Function.Injective.summable_iff
@[to_additive (attr := simp)] theorem hasProd_extend_one {g : β → γ} (hg : Injective g) :
HasProd (extend g f 1) a ↔ HasProd f a := by
rw [← hg.hasProd_iff, extend_comp hg]
exact extend_apply' _ _
@[to_additive (attr := simp)] theorem multipliable_extend_one {g : β → γ} (hg : Injective g) :
Multipliable (extend g f 1) ↔ Multipliable f :=
exists_congr fun _ ↦ hasProd_extend_one hg
@[to_additive]
| Mathlib/Topology/Algebra/InfiniteSum/Basic.lean | 101 | 104 | theorem hasProd_subtype_iff_mulIndicator {s : Set β} :
HasProd (f ∘ (↑) : s → α) a ↔ HasProd (s.mulIndicator f) a := by |
rw [← Set.mulIndicator_range_comp, Subtype.range_coe,
hasProd_subtype_iff_of_mulSupport_subset Set.mulSupport_mulIndicator_subset]
|
/-
Copyright (c) 2020 Yury Kudryashov, Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Anne Baanen
-/
import Mathlib.Algebra.BigOperators.Ring
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Fintype.Fin
import Mathlib.GroupTheory.GroupAction.Pi
import Mathlib.Logic.Equiv.Fin
#align_import algebra.big_operators.fin from "leanprover-community/mathlib"@"cc5dd6244981976cc9da7afc4eee5682b037a013"
/-!
# Big operators and `Fin`
Some results about products and sums over the type `Fin`.
The most important results are the induction formulas `Fin.prod_univ_castSucc`
and `Fin.prod_univ_succ`, and the formula `Fin.prod_const` for the product of a
constant function. These results have variants for sums instead of products.
## Main declarations
* `finFunctionFinEquiv`: An explicit equivalence between `Fin n → Fin m` and `Fin (m ^ n)`.
-/
open Finset
variable {α : Type*} {β : Type*}
namespace Finset
@[to_additive]
theorem prod_range [CommMonoid β] {n : ℕ} (f : ℕ → β) :
∏ i ∈ Finset.range n, f i = ∏ i : Fin n, f i :=
(Fin.prod_univ_eq_prod_range _ _).symm
#align finset.prod_range Finset.prod_range
#align finset.sum_range Finset.sum_range
end Finset
namespace Fin
@[to_additive]
theorem prod_ofFn [CommMonoid β] {n : ℕ} (f : Fin n → β) : (List.ofFn f).prod = ∏ i, f i := by
simp [prod_eq_multiset_prod]
#align fin.prod_of_fn Fin.prod_ofFn
#align fin.sum_of_fn Fin.sum_ofFn
@[to_additive]
theorem prod_univ_def [CommMonoid β] {n : ℕ} (f : Fin n → β) :
∏ i, f i = ((List.finRange n).map f).prod := by
rw [← List.ofFn_eq_map, prod_ofFn]
#align fin.prod_univ_def Fin.prod_univ_def
#align fin.sum_univ_def Fin.sum_univ_def
/-- A product of a function `f : Fin 0 → β` is `1` because `Fin 0` is empty -/
@[to_additive "A sum of a function `f : Fin 0 → β` is `0` because `Fin 0` is empty"]
theorem prod_univ_zero [CommMonoid β] (f : Fin 0 → β) : ∏ i, f i = 1 :=
rfl
#align fin.prod_univ_zero Fin.prod_univ_zero
#align fin.sum_univ_zero Fin.sum_univ_zero
/-- A product of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)`
is the product of `f x`, for some `x : Fin (n + 1)` times the remaining product -/
@[to_additive "A sum of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)` is the sum of
`f x`, for some `x : Fin (n + 1)` plus the remaining product"]
theorem prod_univ_succAbove [CommMonoid β] {n : ℕ} (f : Fin (n + 1) → β) (x : Fin (n + 1)) :
∏ i, f i = f x * ∏ i : Fin n, f (x.succAbove i) := by
rw [univ_succAbove, prod_cons, Finset.prod_map _ x.succAboveEmb]
rfl
#align fin.prod_univ_succ_above Fin.prod_univ_succAbove
#align fin.sum_univ_succ_above Fin.sum_univ_succAbove
/-- A product of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)`
is the product of `f 0` plus the remaining product -/
@[to_additive "A sum of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)` is the sum of
`f 0` plus the remaining product"]
theorem prod_univ_succ [CommMonoid β] {n : ℕ} (f : Fin (n + 1) → β) :
∏ i, f i = f 0 * ∏ i : Fin n, f i.succ :=
prod_univ_succAbove f 0
#align fin.prod_univ_succ Fin.prod_univ_succ
#align fin.sum_univ_succ Fin.sum_univ_succ
/-- A product of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)`
is the product of `f (Fin.last n)` plus the remaining product -/
@[to_additive "A sum of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)` is the sum of
`f (Fin.last n)` plus the remaining sum"]
theorem prod_univ_castSucc [CommMonoid β] {n : ℕ} (f : Fin (n + 1) → β) :
∏ i, f i = (∏ i : Fin n, f (Fin.castSucc i)) * f (last n) := by
simpa [mul_comm] using prod_univ_succAbove f (last n)
#align fin.prod_univ_cast_succ Fin.prod_univ_castSucc
#align fin.sum_univ_cast_succ Fin.sum_univ_castSucc
@[to_additive (attr := simp)]
theorem prod_univ_get [CommMonoid α] (l : List α) : ∏ i, l.get i = l.prod := by
simp [Finset.prod_eq_multiset_prod]
@[to_additive (attr := simp)]
| Mathlib/Algebra/BigOperators/Fin.lean | 101 | 103 | theorem prod_univ_get' [CommMonoid β] (l : List α) (f : α → β) :
∏ i, f (l.get i) = (l.map f).prod := by |
simp [Finset.prod_eq_multiset_prod]
|
/-
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
Some proofs and docs came from `algebra/commute` (c) Neil Strickland
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Init.Logic
import Mathlib.Tactic.Cases
#align_import algebra.group.semiconj from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64"
/-!
# Semiconjugate elements of a semigroup
## Main definitions
We say that `x` is semiconjugate to `y` by `a` (`SemiconjBy a x y`), if `a * x = y * a`.
In this file we provide operations on `SemiconjBy _ _ _`.
In the names of these operations, we treat `a` as the “left” argument, and both `x` and `y` as
“right” arguments. This way most names in this file agree with the names of the corresponding lemmas
for `Commute a b = SemiconjBy a b b`. As a side effect, some lemmas have only `_right` version.
Lean does not immediately recognise these terms as equations, so for rewriting we need syntax like
`rw [(h.pow_right 5).eq]` rather than just `rw [h.pow_right 5]`.
This file provides only basic operations (`mul_left`, `mul_right`, `inv_right` etc). Other
operations (`pow_right`, field inverse etc) are in the files that define corresponding notions.
-/
assert_not_exists MonoidWithZero
assert_not_exists DenselyOrdered
variable {S M G : Type*}
/-- `x` is semiconjugate to `y` by `a`, if `a * x = y * a`. -/
@[to_additive "`x` is additive semiconjugate to `y` by `a` if `a + x = y + a`"]
def SemiconjBy [Mul M] (a x y : M) : Prop :=
a * x = y * a
#align semiconj_by SemiconjBy
#align add_semiconj_by AddSemiconjBy
namespace SemiconjBy
/-- Equality behind `SemiconjBy a x y`; useful for rewriting. -/
@[to_additive "Equality behind `AddSemiconjBy a x y`; useful for rewriting."]
protected theorem eq [Mul S] {a x y : S} (h : SemiconjBy a x y) : a * x = y * a :=
h
#align semiconj_by.eq SemiconjBy.eq
#align add_semiconj_by.eq AddSemiconjBy.eq
section Semigroup
variable [Semigroup S] {a b x y z x' y' : S}
/-- If `a` semiconjugates `x` to `y` and `x'` to `y'`,
then it semiconjugates `x * x'` to `y * y'`. -/
@[to_additive (attr := simp) "If `a` semiconjugates `x` to `y` and `x'` to `y'`,
then it semiconjugates `x + x'` to `y + y'`."]
theorem mul_right (h : SemiconjBy a x y) (h' : SemiconjBy a x' y') :
SemiconjBy a (x * x') (y * y') := by
unfold SemiconjBy
-- TODO this could be done using `assoc_rw` if/when this is ported to mathlib4
rw [← mul_assoc, h.eq, mul_assoc, h'.eq, ← mul_assoc]
#align semiconj_by.mul_right SemiconjBy.mul_right
#align add_semiconj_by.add_right AddSemiconjBy.add_right
/-- If `b` semiconjugates `x` to `y` and `a` semiconjugates `y` to `z`, then `a * b`
semiconjugates `x` to `z`. -/
@[to_additive "If `b` semiconjugates `x` to `y` and `a` semiconjugates `y` to `z`, then `a + b`
semiconjugates `x` to `z`."]
| Mathlib/Algebra/Group/Semiconj/Defs.lean | 74 | 76 | theorem mul_left (ha : SemiconjBy a y z) (hb : SemiconjBy b x y) : SemiconjBy (a * b) x z := by |
unfold SemiconjBy
rw [mul_assoc, hb.eq, ← mul_assoc, ha.eq, mul_assoc]
|
/-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Data.Multiset.Nodup
#align_import data.multiset.sum from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
/-!
# Disjoint sum of multisets
This file defines the disjoint sum of two multisets as `Multiset (α ⊕ β)`. Beware not to confuse
with the `Multiset.sum` operation which computes the additive sum.
## Main declarations
* `Multiset.disjSum`: `s.disjSum t` is the disjoint sum of `s` and `t`.
-/
open Sum
namespace Multiset
variable {α β : Type*} (s : Multiset α) (t : Multiset β)
/-- Disjoint sum of multisets. -/
def disjSum : Multiset (Sum α β) :=
s.map inl + t.map inr
#align multiset.disj_sum Multiset.disjSum
@[simp]
theorem zero_disjSum : (0 : Multiset α).disjSum t = t.map inr :=
zero_add _
#align multiset.zero_disj_sum Multiset.zero_disjSum
@[simp]
theorem disjSum_zero : s.disjSum (0 : Multiset β) = s.map inl :=
add_zero _
#align multiset.disj_sum_zero Multiset.disjSum_zero
@[simp]
| Mathlib/Data/Multiset/Sum.lean | 44 | 45 | theorem card_disjSum : Multiset.card (s.disjSum t) = Multiset.card s + Multiset.card t := by |
rw [disjSum, card_add, card_map, card_map]
|
/-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Julian Kuelshammer, Heather Macbeth, Mitchell Lee
-/
import Mathlib.Algebra.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
#align_import ring_theory.polynomial.chebyshev from "leanprover-community/mathlib"@"d774451114d6045faeb6751c396bea1eb9058946"
/-!
# Chebyshev polynomials
The Chebyshev polynomials are families of polynomials indexed by `ℤ`,
with integral coefficients.
## Main definitions
* `Polynomial.Chebyshev.T`: the Chebyshev polynomials of the first kind.
* `Polynomial.Chebyshev.U`: the Chebyshev polynomials of the second kind.
## Main statements
* The formal derivative of the Chebyshev polynomials of the first kind is a scalar multiple of the
Chebyshev polynomials of the second kind.
* `Polynomial.Chebyshev.mul_T`, twice the product of the `m`-th and `k`-th Chebyshev polynomials of
the first kind is the sum of the `m + k`-th and `m - k`-th Chebyshev polynomials of the first
kind.
* `Polynomial.Chebyshev.T_mul`, the `(m * n)`-th Chebyshev polynomial of the first kind is the
composition of the `m`-th and `n`-th Chebyshev polynomials of the first kind.
## Implementation details
Since Chebyshev polynomials have interesting behaviour over the complex numbers and modulo `p`,
we define them to have coefficients in an arbitrary commutative ring, even though
technically `ℤ` would suffice.
The benefit of allowing arbitrary coefficient rings, is that the statements afterwards are clean,
and do not have `map (Int.castRingHom R)` interfering all the time.
## References
[Lionel Ponton, _Roots of the Chebyshev polynomials: A purely algebraic approach_]
[ponton2020chebyshev]
## TODO
* Redefine and/or relate the definition of Chebyshev polynomials to `LinearRecurrence`.
* Add explicit formula involving square roots for Chebyshev polynomials
* Compute zeroes and extrema of Chebyshev polynomials.
* Prove that the roots of the Chebyshev polynomials (except 0) are irrational.
* Prove minimax properties of Chebyshev polynomials.
-/
namespace Polynomial.Chebyshev
set_option linter.uppercaseLean3 false -- `T` `U` `X`
open Polynomial
variable (R S : Type*) [CommRing R] [CommRing S]
/-- `T n` is the `n`-th Chebyshev polynomial of the first kind. -/
-- Well-founded definitions are now irreducible by default;
-- as this was implemented before this change,
-- we just set it back to semireducible to avoid needing to change any proofs.
@[semireducible] noncomputable def T : ℤ → R[X]
| 0 => 1
| 1 => X
| (n : ℕ) + 2 => 2 * X * T (n + 1) - T n
| -((n : ℕ) + 1) => 2 * X * T (-n) - T (-n + 1)
termination_by n => Int.natAbs n + Int.natAbs (n - 1)
#align polynomial.chebyshev.T Polynomial.Chebyshev.T
/-- Induction principle used for proving facts about Chebyshev polynomials. -/
@[elab_as_elim]
protected theorem induct (motive : ℤ → Prop)
(zero : motive 0)
(one : motive 1)
(add_two : ∀ (n : ℕ), motive (↑n + 1) → motive ↑n → motive (↑n + 2))
(neg_add_one : ∀ (n : ℕ), motive (-↑n) → motive (-↑n + 1) → motive (-↑n - 1)) :
∀ (a : ℤ), motive a :=
T.induct Unit motive zero one add_two fun n hn hnm => by
simpa only [Int.negSucc_eq, neg_add] using neg_add_one n hn hnm
@[simp]
theorem T_add_two : ∀ n, T R (n + 2) = 2 * X * T R (n + 1) - T R n
| (k : ℕ) => T.eq_3 R k
| -(k + 1 : ℕ) => by linear_combination (norm := (simp [Int.negSucc_eq]; ring_nf)) T.eq_4 R k
#align polynomial.chebyshev.T_add_two Polynomial.Chebyshev.T_add_two
theorem T_add_one (n : ℤ) : T R (n + 1) = 2 * X * T R n - T R (n - 1) := by
linear_combination (norm := ring_nf) T_add_two R (n - 1)
theorem T_sub_two (n : ℤ) : T R (n - 2) = 2 * X * T R (n - 1) - T R n := by
linear_combination (norm := ring_nf) T_add_two R (n - 2)
theorem T_sub_one (n : ℤ) : T R (n - 1) = 2 * X * T R n - T R (n + 1) := by
linear_combination (norm := ring_nf) T_add_two R (n - 1)
theorem T_eq (n : ℤ) : T R n = 2 * X * T R (n - 1) - T R (n - 2) := by
linear_combination (norm := ring_nf) T_add_two R (n - 2)
#align polynomial.chebyshev.T_of_two_le Polynomial.Chebyshev.T_eq
@[simp]
theorem T_zero : T R 0 = 1 := rfl
#align polynomial.chebyshev.T_zero Polynomial.Chebyshev.T_zero
@[simp]
theorem T_one : T R 1 = X := rfl
#align polynomial.chebyshev.T_one Polynomial.Chebyshev.T_one
theorem T_neg_one : T R (-1) = X := (by ring : 2 * X * 1 - X = X)
theorem T_two : T R 2 = 2 * X ^ 2 - 1 := by
simpa [pow_two, mul_assoc] using T_add_two R 0
#align polynomial.chebyshev.T_two Polynomial.Chebyshev.T_two
@[simp]
theorem T_neg (n : ℤ) : T R (-n) = T R n := by
induction n using Polynomial.Chebyshev.induct with
| zero => rfl
| one => show 2 * X * 1 - X = X; ring
| add_two n ih1 ih2 =>
have h₁ := T_add_two R n
have h₂ := T_sub_two R (-n)
linear_combination (norm := ring_nf) (2 * (X:R[X])) * ih1 - ih2 - h₁ + h₂
| neg_add_one n ih1 ih2 =>
have h₁ := T_add_one R n
have h₂ := T_sub_one R (-n)
linear_combination (norm := ring_nf) (2 * (X:R[X])) * ih1 - ih2 + h₁ - h₂
| Mathlib/RingTheory/Polynomial/Chebyshev.lean | 131 | 132 | theorem T_natAbs (n : ℤ) : T R n.natAbs = T R n := by |
obtain h | h := Int.natAbs_eq n <;> nth_rw 2 [h]; simp
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.