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) 2019 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import Mathlib.Data.Matrix.Basic
import Mathlib.Data.PEquiv
#align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1"
/-!
# partial equivalences for matrices
Using partial equivalences to represent matrices.
This file introduces the function `PEquiv.toMatrix`, which returns a matrix containing ones and
zeros. For any partial equivalence `f`, `f.toMatrix i j = 1 ↔ f i = some j`.
The following important properties of this function are proved
`toMatrix_trans : (f.trans g).toMatrix = f.toMatrix * g.toMatrix`
`toMatrix_symm : f.symm.toMatrix = f.toMatrixᵀ`
`toMatrix_refl : (PEquiv.refl n).toMatrix = 1`
`toMatrix_bot : ⊥.toMatrix = 0`
This theory gives the matrix representation of projection linear maps, and their right inverses.
For example, the matrix `(single (0 : Fin 1) (i : Fin n)).toMatrix` corresponds to the ith
projection map from R^n to R.
Any injective function `Fin m → Fin n` gives rise to a `PEquiv`, whose matrix is the projection
map from R^m → R^n represented by the same function. The transpose of this matrix is the right
inverse of this map, sending anything not in the image to zero.
## notations
This file uses `ᵀ` for `Matrix.transpose`.
-/
namespace PEquiv
open Matrix
universe u v
variable {k l m n : Type*}
variable {α : Type v}
open Matrix
/-- `toMatrix` returns a matrix containing ones and zeros. `f.toMatrix i j` is `1` if
`f i = some j` and `0` otherwise -/
def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α :=
of fun i j => if j ∈ f i then (1 : α) else 0
#align pequiv.to_matrix PEquiv.toMatrix
-- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024
@[simp]
theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) :
toMatrix f i j = if j ∈ f i then (1 : α) else 0 :=
rfl
#align pequiv.to_matrix_apply PEquiv.toMatrix_apply
theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α)
(i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by
dsimp [toMatrix, Matrix.mul_apply]
cases' h : f i with fi
· simp [h]
· rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm]
#align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply
theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) :
(f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by
ext
simp only [transpose, mem_iff_mem f, toMatrix_apply]
congr
#align pequiv.to_matrix_symm PEquiv.toMatrix_symm
@[simp]
theorem toMatrix_refl [DecidableEq n] [Zero α] [One α] :
((PEquiv.refl n).toMatrix : Matrix n n α) = 1 := by
ext
simp [toMatrix_apply, one_apply]
#align pequiv.to_matrix_refl PEquiv.toMatrix_refl
theorem matrix_mul_apply [Fintype m] [Semiring α] [DecidableEq n] (M : Matrix l m α) (f : m ≃. n)
(i j) : (M * f.toMatrix :) i j = Option.casesOn (f.symm j) 0 fun fj => M i fj := by
dsimp [toMatrix, Matrix.mul_apply]
cases' h : f.symm j with fj
· simp [h, ← f.eq_some_iff]
· rw [Finset.sum_eq_single fj]
· simp [h, ← f.eq_some_iff]
· rintro b - n
simp [h, ← f.eq_some_iff, n.symm]
· simp
#align pequiv.matrix_mul_apply PEquiv.matrix_mul_apply
theorem toPEquiv_mul_matrix [Fintype m] [DecidableEq m] [Semiring α] (f : m ≃ m)
(M : Matrix m n α) : f.toPEquiv.toMatrix * M = M.submatrix f id := by
ext i j
rw [mul_matrix_apply, Equiv.toPEquiv_apply, submatrix_apply, id]
#align pequiv.to_pequiv_mul_matrix PEquiv.toPEquiv_mul_matrix
theorem mul_toPEquiv_toMatrix {m n α : Type*} [Fintype n] [DecidableEq n] [Semiring α] (f : n ≃ n)
(M : Matrix m n α) : M * f.toPEquiv.toMatrix = M.submatrix id f.symm :=
Matrix.ext fun i j => by
rw [PEquiv.matrix_mul_apply, ← Equiv.toPEquiv_symm, Equiv.toPEquiv_apply,
Matrix.submatrix_apply, id]
#align pequiv.mul_to_pequiv_to_matrix PEquiv.mul_toPEquiv_toMatrix
| Mathlib/Data/Matrix/PEquiv.lean | 109 | 114 | theorem toMatrix_trans [Fintype m] [DecidableEq m] [DecidableEq n] [Semiring α] (f : l ≃. m)
(g : m ≃. n) : ((f.trans g).toMatrix : Matrix l n α) = f.toMatrix * g.toMatrix := by |
ext i j
rw [mul_matrix_apply]
dsimp [toMatrix, PEquiv.trans]
cases f i <;> simp
|
/-
Copyright (c) 2021 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Init.Data.Nat.Notation
import Mathlib.Init.Order.Defs
set_option autoImplicit true
structure UFModel (n) where
parent : Fin n → Fin n
rank : Nat → Nat
rank_lt : ∀ i, (parent i).1 ≠ i → rank i < rank (parent i)
namespace UFModel
def empty : UFModel 0 where
parent i := i.elim0
rank _ := 0
rank_lt i := i.elim0
def push {n} (m : UFModel n) (k) (le : n ≤ k) : UFModel k where
parent i :=
if h : i < n then
let ⟨a, h'⟩ := m.parent ⟨i, h⟩
⟨a, Nat.lt_of_lt_of_le h' le⟩
else i
rank i := if i < n then m.rank i else 0
rank_lt i := by
simp; split <;> rename_i h
· simp [(m.parent ⟨i, h⟩).2, h]; exact m.rank_lt _
· nofun
def setParent {n} (m : UFModel n) (x y : Fin n) (h : m.rank x < m.rank y) : UFModel n where
parent i := if x.1 = i then y else m.parent i
rank := m.rank
rank_lt i := by
simp; split <;> rename_i h'
· rw [← h']; exact fun _ ↦ h
· exact m.rank_lt i
def setParentBump {n} (m : UFModel n) (x y : Fin n)
(H : m.rank x ≤ m.rank y) (hroot : (m.parent y).1 = y) : UFModel n where
parent i := if x.1 = i then y else m.parent i
rank i := if y.1 = i ∧ m.rank x = m.rank y then m.rank y + 1 else m.rank i
rank_lt i := by
simp; split <;>
(rename_i h₁; (try simp [h₁]); split <;> rename_i h₂ <;>
(intro h; try simp [h] at h₂ <;> simp [h₁, h₂, h]))
· simp [← h₁]; split <;> rename_i h₃
· rw [h₃]; apply Nat.lt_succ_self
· exact Nat.lt_of_le_of_ne H h₃
· have := Fin.eq_of_val_eq h₂.1; subst this
simp [hroot] at h
· have := m.rank_lt i h
split <;> rename_i h₃
· rw [h₃.1]; exact Nat.lt_succ_of_lt this
· exact this
end UFModel
structure UFNode (α : Type*) where
parent : Nat
value : α
rank : Nat
inductive UFModel.Agrees (arr : Array α) (f : α → β) : ∀ {n}, (Fin n → β) → Prop
| mk : Agrees arr f fun i ↦ f (arr.get i)
namespace UFModel.Agrees
theorem mk' {arr : Array α} {f : α → β} {n} {g : Fin n → β} (e : n = arr.size)
(H : ∀ i h₁ h₂, f (arr.get ⟨i, h₁⟩) = g ⟨i, h₂⟩) : Agrees arr f g := by
cases e
have : (fun i ↦ f (arr.get i)) = g := by funext ⟨i, h⟩; apply H
cases this; constructor
theorem size_eq {arr : Array α} {m : Fin n → β} (H : Agrees arr f m) : n = arr.size := by
cases H; rfl
| Mathlib/Data/UnionFind.lean | 82 | 84 | theorem get_eq {arr : Array α} {n} {m : Fin n → β} (H : Agrees arr f m) :
∀ i h₁ h₂, f (arr.get ⟨i, h₁⟩) = m ⟨i, h₂⟩ := by |
cases H; exact fun i h _ ↦ rfl
|
/-
Copyright (c) 2020 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.Polynomial.Degree.TrailingDegree
import Mathlib.Algebra.Polynomial.EraseLead
import Mathlib.Algebra.Polynomial.Eval
#align_import data.polynomial.reverse from "leanprover-community/mathlib"@"44de64f183393284a16016dfb2a48ac97382f2bd"
/-!
# Reverse of a univariate polynomial
The main definition is `reverse`. Applying `reverse` to a polynomial `f : R[X]` produces
the polynomial with a reversed list of coefficients, equivalent to `X^f.natDegree * f(1/X)`.
The main result is that `reverse (f * g) = reverse f * reverse g`, provided the leading
coefficients of `f` and `g` do not multiply to zero.
-/
namespace Polynomial
open Polynomial Finsupp Finset
open Polynomial
section Semiring
variable {R : Type*} [Semiring R] {f : R[X]}
/-- If `i ≤ N`, then `revAtFun N i` returns `N - i`, otherwise it returns `i`.
This is the map used by the embedding `revAt`.
-/
def revAtFun (N i : ℕ) : ℕ :=
ite (i ≤ N) (N - i) i
#align polynomial.rev_at_fun Polynomial.revAtFun
| Mathlib/Algebra/Polynomial/Reverse.lean | 40 | 47 | theorem revAtFun_invol {N i : ℕ} : revAtFun N (revAtFun N i) = i := by |
unfold revAtFun
split_ifs with h j
· exact tsub_tsub_cancel_of_le h
· exfalso
apply j
exact Nat.sub_le N i
· rfl
|
/-
Copyright (c) 2020 Kyle Miller. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller
-/
import Mathlib.Algebra.BigOperators.Ring
import Mathlib.Combinatorics.SimpleGraph.Dart
import Mathlib.Combinatorics.SimpleGraph.Finite
import Mathlib.Data.ZMod.Parity
#align_import combinatorics.simple_graph.degree_sum from "leanprover-community/mathlib"@"90659cbe25e59ec302e2fb92b00e9732160cc620"
/-!
# Degree-sum formula and handshaking lemma
The degree-sum formula is that the sum of the degrees of the vertices in
a finite graph is equal to twice the number of edges. The handshaking lemma,
a corollary, is that the number of odd-degree vertices is even.
## Main definitions
- `SimpleGraph.sum_degrees_eq_twice_card_edges` is the degree-sum formula.
- `SimpleGraph.even_card_odd_degree_vertices` is the handshaking lemma.
- `SimpleGraph.odd_card_odd_degree_vertices_ne` is that the number of odd-degree
vertices different from a given odd-degree vertex is odd.
- `SimpleGraph.exists_ne_odd_degree_of_exists_odd_degree` is that the existence of an
odd-degree vertex implies the existence of another one.
## Implementation notes
We give a combinatorial proof by using the facts that (1) the map from
darts to vertices is such that each fiber has cardinality the degree
of the corresponding vertex and that (2) the map from darts to edges is 2-to-1.
## Tags
simple graphs, sums, degree-sum formula, handshaking lemma
-/
open Finset
namespace SimpleGraph
universe u
variable {V : Type u} (G : SimpleGraph V)
section DegreeSum
variable [Fintype V] [DecidableRel G.Adj]
-- Porting note: Changed to `Fintype (Sym2 V)` to match Combinatorics.SimpleGraph.Basic
variable [Fintype (Sym2 V)]
theorem dart_fst_fiber [DecidableEq V] (v : V) :
(univ.filter fun d : G.Dart => d.fst = v) = univ.image (G.dartOfNeighborSet v) := by
ext d
simp only [mem_image, true_and_iff, mem_filter, SetCoe.exists, mem_univ, exists_prop_of_true]
constructor
· rintro rfl
exact ⟨_, d.adj, by ext <;> rfl⟩
· rintro ⟨e, he, rfl⟩
rfl
#align simple_graph.dart_fst_fiber SimpleGraph.dart_fst_fiber
theorem dart_fst_fiber_card_eq_degree [DecidableEq V] (v : V) :
(univ.filter fun d : G.Dart => d.fst = v).card = G.degree v := by
simpa only [dart_fst_fiber, Finset.card_univ, card_neighborSet_eq_degree] using
card_image_of_injective univ (G.dartOfNeighborSet_injective v)
#align simple_graph.dart_fst_fiber_card_eq_degree SimpleGraph.dart_fst_fiber_card_eq_degree
theorem dart_card_eq_sum_degrees : Fintype.card G.Dart = ∑ v, G.degree v := by
haveI := Classical.decEq V
simp only [← card_univ, ← dart_fst_fiber_card_eq_degree]
exact card_eq_sum_card_fiberwise (by simp)
#align simple_graph.dart_card_eq_sum_degrees SimpleGraph.dart_card_eq_sum_degrees
variable {G}
theorem Dart.edge_fiber [DecidableEq V] (d : G.Dart) :
(univ.filter fun d' : G.Dart => d'.edge = d.edge) = {d, d.symm} :=
Finset.ext fun d' => by simpa using dart_edge_eq_iff d' d
#align simple_graph.dart.edge_fiber SimpleGraph.Dart.edge_fiber
variable (G)
| Mathlib/Combinatorics/SimpleGraph/DegreeSum.lean | 88 | 95 | theorem dart_edge_fiber_card [DecidableEq V] (e : Sym2 V) (h : e ∈ G.edgeSet) :
(univ.filter fun d : G.Dart => d.edge = e).card = 2 := by |
refine Sym2.ind (fun v w h => ?_) e h
let d : G.Dart := ⟨(v, w), h⟩
convert congr_arg card d.edge_fiber
rw [card_insert_of_not_mem, card_singleton]
rw [mem_singleton]
exact d.symm_ne.symm
|
/-
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.tagged from "leanprover-community/mathlib"@"6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f"
/-!
# Tagged partitions
A tagged (pre)partition is a (pre)partition `π` enriched with a tagged point for each box of
`π`. For simplicity we require that the function `BoxIntegral.TaggedPrepartition.tag` is defined
on all boxes `J : Box ι` but use its values only on boxes of the partition. Given
`π : BoxIntegral.TaggedPrepartition I`, we require that each `BoxIntegral.TaggedPrepartition π J`
belongs to `BoxIntegral.Box.Icc I`. If for every `J ∈ π`, `π.tag J` belongs to `J.Icc`, then `π` is
called a *Henstock* partition. We do not include this assumption into the definition of a tagged
(pre)partition because McShane integral is defined as a limit along tagged partitions without this
requirement.
## Tags
rectangular box, box partition
-/
noncomputable section
open scoped Classical
open ENNReal NNReal
open Set Function
namespace BoxIntegral
variable {ι : Type*}
/-- A tagged prepartition is a prepartition enriched with a tagged point for each box of the
prepartition. For simplicity we require that `tag` is defined for all boxes in `ι → ℝ` but
we will use only the values of `tag` on the boxes of the partition. -/
structure TaggedPrepartition (I : Box ι) extends Prepartition I where
/-- Choice of tagged point of each box in this prepartition:
we extend this to a total function, on all boxes in `ι → ℝ`. -/
tag : Box ι → ι → ℝ
/-- Each tagged point belongs to `I` -/
tag_mem_Icc : ∀ J, tag J ∈ Box.Icc I
#align box_integral.tagged_prepartition BoxIntegral.TaggedPrepartition
namespace TaggedPrepartition
variable {I J J₁ J₂ : Box ι} (π : TaggedPrepartition I) {x : ι → ℝ}
instance : Membership (Box ι) (TaggedPrepartition I) :=
⟨fun J π => J ∈ π.boxes⟩
@[simp]
theorem mem_toPrepartition {π : TaggedPrepartition I} : J ∈ π.toPrepartition ↔ J ∈ π := Iff.rfl
#align box_integral.tagged_prepartition.mem_to_prepartition BoxIntegral.TaggedPrepartition.mem_toPrepartition
@[simp]
theorem mem_mk (π : Prepartition I) (f h) : J ∈ mk π f h ↔ J ∈ π := Iff.rfl
#align box_integral.tagged_prepartition.mem_mk BoxIntegral.TaggedPrepartition.mem_mk
/-- Union of all boxes of a tagged prepartition. -/
def iUnion : Set (ι → ℝ) :=
π.toPrepartition.iUnion
#align box_integral.tagged_prepartition.Union BoxIntegral.TaggedPrepartition.iUnion
theorem iUnion_def : π.iUnion = ⋃ J ∈ π, ↑J := rfl
#align box_integral.tagged_prepartition.Union_def BoxIntegral.TaggedPrepartition.iUnion_def
@[simp]
theorem iUnion_mk (π : Prepartition I) (f h) : (mk π f h).iUnion = π.iUnion := rfl
#align box_integral.tagged_prepartition.Union_mk BoxIntegral.TaggedPrepartition.iUnion_mk
@[simp]
theorem iUnion_toPrepartition : π.toPrepartition.iUnion = π.iUnion := rfl
#align box_integral.tagged_prepartition.Union_to_prepartition BoxIntegral.TaggedPrepartition.iUnion_toPrepartition
-- Porting note: Previous proof was `:= Set.mem_iUnion₂`
@[simp]
| Mathlib/Analysis/BoxIntegral/Partition/Tagged.lean | 83 | 85 | theorem mem_iUnion : x ∈ π.iUnion ↔ ∃ J ∈ π, x ∈ J := by |
convert Set.mem_iUnion₂
rw [Box.mem_coe, mem_toPrepartition, exists_prop]
|
/-
Copyright (c) 2020 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Eric Wieser
-/
import Mathlib.GroupTheory.OrderOfElement
import Mathlib.RingTheory.Ideal.Maps
import Mathlib.RingTheory.Ideal.Quotient
#align_import algebra.char_p.quotient from "leanprover-community/mathlib"@"85e3c05a94b27c84dc6f234cf88326d5e0096ec3"
/-!
# Characteristic of quotients rings
-/
universe u v
namespace CharP
theorem quotient (R : Type u) [CommRing R] (p : ℕ) [hp1 : Fact p.Prime] (hp2 : ↑p ∈ nonunits R) :
CharP (R ⧸ (Ideal.span ({(p : R)} : Set R) : Ideal R)) p :=
have hp0 : (p : R ⧸ (Ideal.span {(p : R)} : Ideal R)) = 0 :=
map_natCast (Ideal.Quotient.mk (Ideal.span {(p : R)} : Ideal R)) p ▸
Ideal.Quotient.eq_zero_iff_mem.2 (Ideal.subset_span <| Set.mem_singleton _)
ringChar.of_eq <|
Or.resolve_left ((Nat.dvd_prime hp1.1).1 <| ringChar.dvd hp0) fun h1 =>
hp2 <|
isUnit_iff_dvd_one.2 <|
Ideal.mem_span_singleton.1 <|
Ideal.Quotient.eq_zero_iff_mem.1 <|
@Subsingleton.elim _ (@CharOne.subsingleton _ _ (ringChar.of_eq h1)) _ _
#align char_p.quotient CharP.quotient
/-- If an ideal does not contain any coercions of natural numbers other than zero, then its quotient
inherits the characteristic of the underlying ring. -/
theorem quotient' {R : Type*} [CommRing R] (p : ℕ) [CharP R p] (I : Ideal R)
(h : ∀ x : ℕ, (x : R) ∈ I → (x : R) = 0) : CharP (R ⧸ I) p :=
⟨fun x => by
rw [← cast_eq_zero_iff R p x, ← map_natCast (Ideal.Quotient.mk I)]
refine Ideal.Quotient.eq.trans (?_ : ↑x - 0 ∈ I ↔ _)
rw [sub_zero]
exact ⟨h x, fun h' => h'.symm ▸ I.zero_mem⟩⟩
#align char_p.quotient' CharP.quotient'
/-- `CharP.quotient'` as an `Iff`. -/
theorem quotient_iff {R : Type*} [CommRing R] (n : ℕ) [CharP R n] (I : Ideal R) :
CharP (R ⧸ I) n ↔ ∀ x : ℕ, ↑x ∈ I → (x : R) = 0 := by
refine ⟨fun _ x hx => ?_, CharP.quotient' n I⟩
rw [CharP.cast_eq_zero_iff R n, ← CharP.cast_eq_zero_iff (R ⧸ I) n _]
exact (Submodule.Quotient.mk_eq_zero I).mpr hx
/-- `CharP.quotient_iff`, but stated in terms of inclusions of ideals. -/
theorem quotient_iff_le_ker_natCast {R : Type*} [CommRing R] (n : ℕ) [CharP R n] (I : Ideal R) :
CharP (R ⧸ I) n ↔ I.comap (Nat.castRingHom R) ≤ RingHom.ker (Nat.castRingHom R) := by
rw [CharP.quotient_iff, RingHom.ker_eq_comap_bot]; rfl
end CharP
| Mathlib/Algebra/CharP/Quotient.lean | 60 | 66 | theorem Ideal.Quotient.index_eq_zero {R : Type*} [CommRing R] (I : Ideal R) :
(↑I.toAddSubgroup.index : R ⧸ I) = 0 := by |
rw [AddSubgroup.index, Nat.card_eq]
split_ifs with hq; swap
· simp
letI : Fintype (R ⧸ I) := @Fintype.ofFinite _ hq
exact Nat.cast_card_eq_zero (R ⧸ I)
|
/-
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alexander Bentkamp, Yury Kudryashov
-/
import Mathlib.Analysis.Convex.Between
import Mathlib.Analysis.Convex.Jensen
import Mathlib.Analysis.Convex.Topology
import Mathlib.Analysis.Normed.Group.Pointwise
import Mathlib.Analysis.NormedSpace.AddTorsor
#align_import analysis.convex.normed from "leanprover-community/mathlib"@"a63928c34ec358b5edcda2bf7513c50052a5230f"
/-!
# Topological and metric properties of convex sets in normed spaces
We prove the following facts:
* `convexOn_norm`, `convexOn_dist` : norm and distance to a fixed point is convex on any convex
set;
* `convexOn_univ_norm`, `convexOn_univ_dist` : norm and distance to a fixed point is convex on
the whole space;
* `convexHull_ediam`, `convexHull_diam` : convex hull of a set has the same (e)metric diameter
as the original set;
* `bounded_convexHull` : convex hull of a set is bounded if and only if the original set
is bounded.
-/
variable {ι : Type*} {E P : Type*}
open Metric Set
open scoped Convex
variable [SeminormedAddCommGroup E] [NormedSpace ℝ E] [PseudoMetricSpace P] [NormedAddTorsor E P]
variable {s t : Set E}
/-- The norm on a real normed space is convex on any convex set. See also `Seminorm.convexOn`
and `convexOn_univ_norm`. -/
| Mathlib/Analysis/Convex/Normed.lean | 39 | 44 | theorem convexOn_norm (hs : Convex ℝ s) : ConvexOn ℝ s norm :=
⟨hs, fun x _ y _ a b ha hb _ =>
calc
‖a • x + b • y‖ ≤ ‖a • x‖ + ‖b • y‖ := norm_add_le _ _
_ = a * ‖x‖ + b * ‖y‖ := by |
rw [norm_smul, norm_smul, Real.norm_of_nonneg ha, Real.norm_of_nonneg hb]⟩
|
/-
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
-/
import Mathlib.Control.Traversable.Instances
import Mathlib.Order.Filter.Basic
#align_import order.filter.basic from "leanprover-community/mathlib"@"d4f691b9e5f94cfc64639973f3544c95f8d5d494"
/-!
# Properties of `Traversable.traverse` on `List`s and `Filter`s
In this file we prove basic properties (monotonicity, membership)
for `Traversable.traverse f l`, where `f : β → Filter α` and `l : List β`.
-/
open Set List
namespace Filter
universe u
variable {α β γ : Type u} {f : β → Filter α} {s : γ → Set α}
theorem sequence_mono : ∀ as bs : List (Filter α), Forall₂ (· ≤ ·) as bs → sequence as ≤ sequence bs
| [], [], Forall₂.nil => le_rfl
| _::as, _::bs, Forall₂.cons h hs => seq_mono (map_mono h) (sequence_mono as bs hs)
#align filter.sequence_mono Filter.sequence_mono
theorem mem_traverse :
∀ (fs : List β) (us : List γ),
Forall₂ (fun b c => s c ∈ f b) fs us → traverse s us ∈ traverse f fs
| [], [], Forall₂.nil => mem_pure.2 <| mem_singleton _
| _::fs, _::us, Forall₂.cons h hs => seq_mem_seq (image_mem_map h) (mem_traverse fs us hs)
#align filter.mem_traverse Filter.mem_traverse
-- TODO: add a `Filter.HasBasis` statement
| Mathlib/Order/Filter/ListTraverse.lean | 38 | 53 | theorem mem_traverse_iff (fs : List β) (t : Set (List α)) :
t ∈ traverse f fs ↔
∃ us : List (Set α), Forall₂ (fun b (s : Set α) => s ∈ f b) fs us ∧ sequence us ⊆ t := by |
constructor
· induction fs generalizing t with
| nil =>
simp only [sequence, mem_pure, imp_self, forall₂_nil_left_iff, exists_eq_left, Set.pure_def,
singleton_subset_iff, traverse_nil]
| cons b fs ih =>
intro ht
rcases mem_seq_iff.1 ht with ⟨u, hu, v, hv, ht⟩
rcases mem_map_iff_exists_image.1 hu with ⟨w, hw, hwu⟩
rcases ih v hv with ⟨us, hus, hu⟩
exact ⟨w::us, Forall₂.cons hw hus, (Set.seq_mono hwu hu).trans ht⟩
· rintro ⟨us, hus, hs⟩
exact mem_of_superset (mem_traverse _ _ hus) hs
|
/-
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]
theorem op_mem_op {s : Set α} {a : α} : op a ∈ s.op ↔ a ∈ s := by rfl
#align set.op_mem_op Set.op_mem_op
@[simp]
theorem mem_unop {s : Set αᵒᵖ} {a : α} : a ∈ s.unop ↔ op a ∈ s :=
Iff.rfl
#align set.mem_unop Set.mem_unop
@[simp 1100]
theorem unop_mem_unop {s : Set αᵒᵖ} {a : αᵒᵖ} : unop a ∈ s.unop ↔ a ∈ s := by rfl
#align set.unop_mem_unop Set.unop_mem_unop
@[simp]
theorem op_unop (s : Set α) : s.op.unop = s := rfl
#align set.op_unop Set.op_unop
@[simp]
theorem unop_op (s : Set αᵒᵖ) : s.unop.op = s := rfl
#align set.unop_op Set.unop_op
/-- The members of the opposite of a set are in bijection with the members of the set itself. -/
@[simps]
def opEquiv_self (s : Set α) : s.op ≃ s :=
⟨fun x ↦ ⟨unop x, x.2⟩, fun x ↦ ⟨op x, x.2⟩, fun _ ↦ rfl, fun _ ↦ rfl⟩
#align set.op_equiv_self Set.opEquiv_self
#align set.op_equiv_self_apply_coe Set.opEquiv_self_apply_coe
#align set.op_equiv_self_symm_apply_coe Set.opEquiv_self_symm_apply_coe
/-- Taking opposites as an equivalence of powersets. -/
@[simps]
def opEquiv : Set α ≃ Set αᵒᵖ :=
⟨Set.op, Set.unop, op_unop, unop_op⟩
#align set.op_equiv Set.opEquiv
#align set.op_equiv_symm_apply Set.opEquiv_symm_apply
#align set.op_equiv_apply Set.opEquiv_apply
@[simp]
| Mathlib/Data/Set/Opposite.lean | 76 | 80 | theorem singleton_op (x : α) : ({x} : Set α).op = {op x} := by |
ext
constructor
· apply unop_injective
· apply op_injective
|
/-
Copyright (c) 2020 Alexander Bentkamp, Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alexander Bentkamp, Sébastien Gouëzel, Eric Wieser
-/
import Mathlib.Algebra.CharP.Invertible
import Mathlib.Algebra.Order.Module.OrderedSMul
import Mathlib.Data.Complex.Cardinality
import Mathlib.Data.Fin.VecNotation
import Mathlib.LinearAlgebra.FiniteDimensional
#align_import data.complex.module from "leanprover-community/mathlib"@"c7bce2818663f456335892ddbdd1809f111a5b72"
/-!
# Complex number as a vector space over `ℝ`
This file contains the following instances:
* Any `•`-structure (`SMul`, `MulAction`, `DistribMulAction`, `Module`, `Algebra`) on
`ℝ` imbues a corresponding structure on `ℂ`. This includes the statement that `ℂ` is an `ℝ`
algebra.
* any complex vector space is a real vector space;
* any finite dimensional complex vector space is a finite dimensional real vector space;
* the space of `ℝ`-linear maps from a real vector space to a complex vector space is a complex
vector space.
It also defines bundled versions of four standard maps (respectively, the real part, the imaginary
part, the embedding of `ℝ` in `ℂ`, and the complex conjugate):
* `Complex.reLm` (`ℝ`-linear map);
* `Complex.imLm` (`ℝ`-linear map);
* `Complex.ofRealAm` (`ℝ`-algebra (homo)morphism);
* `Complex.conjAe` (`ℝ`-algebra equivalence).
It also provides a universal property of the complex numbers `Complex.lift`, which constructs a
`ℂ →ₐ[ℝ] A` into any `ℝ`-algebra `A` given a square root of `-1`.
In addition, this file provides a decomposition into `realPart` and `imaginaryPart` for any
element of a `StarModule` over `ℂ`.
## Notation
* `ℜ` and `ℑ` for the `realPart` and `imaginaryPart`, respectively, in the locale
`ComplexStarModule`.
-/
namespace Complex
open ComplexConjugate
open scoped SMul
variable {R : Type*} {S : Type*}
attribute [local ext] Complex.ext
-- Test that the `SMul ℚ ℂ` instance is correct.
example : (Complex.SMul.instSMulRealComplex : SMul ℚ ℂ) = (Algebra.toSMul : SMul ℚ ℂ) := rfl
/- The priority of the following instances has been manually lowered, as when they don't apply
they lead Lean to a very costly path, and most often they don't apply (most actions on `ℂ` don't
come from actions on `ℝ`). See #11980-/
-- priority manually adjusted in #11980
instance (priority := 90) [SMul R ℝ] [SMul S ℝ] [SMulCommClass R S ℝ] : SMulCommClass R S ℂ where
smul_comm r s x := by ext <;> simp [smul_re, smul_im, smul_comm]
-- priority manually adjusted in #11980
instance (priority := 90) [SMul R S] [SMul R ℝ] [SMul S ℝ] [IsScalarTower R S ℝ] :
IsScalarTower R S ℂ where
smul_assoc r s x := by ext <;> simp [smul_re, smul_im, smul_assoc]
-- priority manually adjusted in #11980
instance (priority := 90) [SMul R ℝ] [SMul Rᵐᵒᵖ ℝ] [IsCentralScalar R ℝ] :
IsCentralScalar R ℂ where
op_smul_eq_smul r x := by ext <;> simp [smul_re, smul_im, op_smul_eq_smul]
-- priority manually adjusted in #11980
instance (priority := 90) mulAction [Monoid R] [MulAction R ℝ] : MulAction R ℂ where
one_smul x := by ext <;> simp [smul_re, smul_im, one_smul]
mul_smul r s x := by ext <;> simp [smul_re, smul_im, mul_smul]
-- priority manually adjusted in #11980
instance (priority := 90) distribSMul [DistribSMul R ℝ] : DistribSMul R ℂ where
smul_add r x y := by ext <;> simp [smul_re, smul_im, smul_add]
smul_zero r := by ext <;> simp [smul_re, smul_im, smul_zero]
-- priority manually adjusted in #11980
instance (priority := 90) [Semiring R] [DistribMulAction R ℝ] : DistribMulAction R ℂ :=
{ Complex.distribSMul, Complex.mulAction with }
-- priority manually adjusted in #11980
instance (priority := 100) instModule [Semiring R] [Module R ℝ] : Module R ℂ where
add_smul r s x := by ext <;> simp [smul_re, smul_im, add_smul]
zero_smul r := by ext <;> simp [smul_re, smul_im, zero_smul]
-- priority manually adjusted in #11980
instance (priority := 95) instAlgebraOfReal [CommSemiring R] [Algebra R ℝ] : Algebra R ℂ :=
{ Complex.ofReal.comp (algebraMap R ℝ) with
smul := (· • ·)
smul_def' := fun r x => by ext <;> simp [smul_re, smul_im, Algebra.smul_def]
commutes' := fun r ⟨xr, xi⟩ => by ext <;> simp [smul_re, smul_im, Algebra.commutes] }
instance : StarModule ℝ ℂ :=
⟨fun r x => by simp only [star_def, star_trivial, real_smul, map_mul, conj_ofReal]⟩
@[simp]
theorem coe_algebraMap : (algebraMap ℝ ℂ : ℝ → ℂ) = ((↑) : ℝ → ℂ) :=
rfl
#align complex.coe_algebra_map Complex.coe_algebraMap
section
variable {A : Type*} [Semiring A] [Algebra ℝ A]
/-- We need this lemma since `Complex.coe_algebraMap` diverts the simp-normal form away from
`AlgHom.commutes`. -/
@[simp]
theorem _root_.AlgHom.map_coe_real_complex (f : ℂ →ₐ[ℝ] A) (x : ℝ) : f x = algebraMap ℝ A x :=
f.commutes x
#align alg_hom.map_coe_real_complex AlgHom.map_coe_real_complex
/-- Two `ℝ`-algebra homomorphisms from `ℂ` are equal if they agree on `Complex.I`. -/
@[ext]
| Mathlib/Data/Complex/Module.lean | 125 | 127 | theorem algHom_ext ⦃f g : ℂ →ₐ[ℝ] A⦄ (h : f I = g I) : f = g := by |
ext ⟨x, y⟩
simp only [mk_eq_add_mul_I, AlgHom.map_add, AlgHom.map_coe_real_complex, AlgHom.map_mul, h]
|
/-
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.Classes.SatisfiesM
/-!
# Results about monadic operations on `Array`, in terms of `SatisfiesM`.
The pure versions of these theorems are proved in `Batteries.Data.Array.Lemmas` directly,
in order to minimize dependence on `SatisfiesM`.
-/
namespace Array
theorem SatisfiesM_foldlM [Monad m] [LawfulMonad m]
{as : Array α} (motive : Nat → β → Prop) {init : β} (h0 : motive 0 init) {f : β → α → m β}
(hf : ∀ i : Fin as.size, ∀ b, motive i.1 b → SatisfiesM (motive (i.1 + 1)) (f b as[i])) :
SatisfiesM (motive as.size) (as.foldlM f init) := by
let rec go {i j b} (h₁ : j ≤ as.size) (h₂ : as.size ≤ i + j) (H : motive j b) :
SatisfiesM (motive as.size) (foldlM.loop f as as.size (Nat.le_refl _) i j b) := by
unfold foldlM.loop; split
· next hj =>
split
· cases Nat.not_le_of_gt (by simp [hj]) h₂
· exact (hf ⟨j, hj⟩ b H).bind fun _ => go hj (by rwa [Nat.succ_add] at h₂)
· next hj => exact Nat.le_antisymm h₁ (Nat.ge_of_not_lt hj) ▸ .pure H
simp [foldlM]; exact go (Nat.zero_le _) (Nat.le_refl _) h0
theorem SatisfiesM_mapM [Monad m] [LawfulMonad m] (as : Array α) (f : α → m β)
(motive : Nat → Prop) (h0 : motive 0)
(p : Fin as.size → β → Prop)
(hs : ∀ i, motive i.1 → SatisfiesM (p i · ∧ motive (i + 1)) (f as[i])) :
SatisfiesM
(fun arr => motive as.size ∧ ∃ eq : arr.size = as.size, ∀ i h, p ⟨i, h⟩ arr[i])
(Array.mapM f as) := by
rw [mapM_eq_foldlM]
refine SatisfiesM_foldlM (m := m) (β := Array β)
(motive := fun i arr => motive i ∧ arr.size = i ∧ ∀ i h2, p i (arr[i.1]'h2)) ?z ?s
|>.imp fun ⟨h₁, eq, h₂⟩ => ⟨h₁, eq, fun _ _ => h₂ ..⟩
· case z => exact ⟨h0, rfl, nofun⟩
· case s =>
intro ⟨i, hi⟩ arr ⟨ih₁, eq, ih₂⟩
refine (hs _ ih₁).map fun ⟨h₁, h₂⟩ => ⟨h₂, by simp [eq], fun j hj => ?_⟩
simp [get_push] at hj ⊢; split; {apply ih₂}
cases j; cases (Nat.le_or_eq_of_le_succ hj).resolve_left ‹_›; cases eq; exact h₁
theorem SatisfiesM_mapM' [Monad m] [LawfulMonad m] (as : Array α) (f : α → m β)
(p : Fin as.size → β → Prop)
(hs : ∀ i, SatisfiesM (p i) (f as[i])) :
SatisfiesM
(fun arr => ∃ eq : arr.size = as.size, ∀ i h, p ⟨i, h⟩ arr[i])
(Array.mapM f as) :=
(SatisfiesM_mapM _ _ (fun _ => True) trivial _ (fun _ h => (hs _).imp (⟨·, h⟩))).imp (·.2)
theorem size_mapM [Monad m] [LawfulMonad m] (f : α → m β) (as : Array α) :
SatisfiesM (fun arr => arr.size = as.size) (Array.mapM f as) :=
(SatisfiesM_mapM' _ _ (fun _ _ => True) (fun _ => .trivial)).imp (·.1)
| .lake/packages/batteries/Batteries/Data/Array/Monadic.lean | 62 | 83 | theorem SatisfiesM_anyM [Monad m] [LawfulMonad m] (p : α → m Bool) (as : Array α) (start stop)
(hstart : start ≤ min stop as.size) (tru : Prop) (fal : Nat → Prop) (h0 : fal start)
(hp : ∀ i : Fin as.size, i.1 < stop → fal i.1 →
SatisfiesM (bif · then tru else fal (i + 1)) (p as[i])) :
SatisfiesM
(fun res => bif res then tru else fal (min stop as.size))
(anyM p as start stop) := by |
let rec go {stop j} (hj' : j ≤ stop) (hstop : stop ≤ as.size) (h0 : fal j)
(hp : ∀ i : Fin as.size, i.1 < stop → fal i.1 →
SatisfiesM (bif · then tru else fal (i + 1)) (p as[i])) :
SatisfiesM
(fun res => bif res then tru else fal stop)
(anyM.loop p as stop hstop j) := by
unfold anyM.loop; split
· next hj =>
exact (hp ⟨j, Nat.lt_of_lt_of_le hj hstop⟩ hj h0).bind fun
| true, h => .pure h
| false, h => go hj hstop h hp
· next hj => exact .pure <| Nat.le_antisymm hj' (Nat.ge_of_not_lt hj) ▸ h0
termination_by stop - j
simp only [Array.anyM_eq_anyM_loop]
exact go hstart _ h0 fun i hi => hp i <| Nat.lt_of_lt_of_le hi <| Nat.min_le_left ..
|
/-
Copyright (c) 2018 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Johannes Hölzl, Rémy Degenne
-/
import Mathlib.Order.Filter.Cofinite
import Mathlib.Order.Hom.CompleteLattice
#align_import order.liminf_limsup from "leanprover-community/mathlib"@"ffde2d8a6e689149e44fd95fa862c23a57f8c780"
/-!
# liminfs and limsups of functions and filters
Defines the liminf/limsup of a function taking values in a conditionally complete lattice, with
respect to an arbitrary filter.
We define `limsSup f` (`limsInf f`) where `f` is a filter taking values in a conditionally complete
lattice. `limsSup f` is the smallest element `a` such that, eventually, `u ≤ a` (and vice versa for
`limsInf f`). To work with the Limsup along a function `u` use `limsSup (map u f)`.
Usually, one defines the Limsup as `inf (sup s)` where the Inf is taken over all sets in the filter.
For instance, in ℕ along a function `u`, this is `inf_n (sup_{k ≥ n} u k)` (and the latter quantity
decreases with `n`, so this is in fact a limit.). There is however a difficulty: it is well possible
that `u` is not bounded on the whole space, only eventually (think of `limsup (fun x ↦ 1/x)` on ℝ.
Then there is no guarantee that the quantity above really decreases (the value of the `sup`
beforehand is not really well defined, as one can not use ∞), so that the Inf could be anything.
So one can not use this `inf sup ...` definition in conditionally complete lattices, and one has
to use a less tractable definition.
In conditionally complete lattices, the definition is only useful for filters which are eventually
bounded above (otherwise, the Limsup would morally be +∞, which does not belong to the space) and
which are frequently bounded below (otherwise, the Limsup would morally be -∞, which is not in the
space either). We start with definitions of these concepts for arbitrary filters, before turning to
the definitions of Limsup and Liminf.
In complete lattices, however, it coincides with the `Inf Sup` definition.
-/
set_option autoImplicit true
open Filter Set Function
variable {α β γ ι ι' : Type*}
namespace Filter
section Relation
/-- `f.IsBounded (≺)`: the filter `f` is eventually bounded w.r.t. the relation `≺`, i.e.
eventually, it is bounded by some uniform bound.
`r` will be usually instantiated with `≤` or `≥`. -/
def IsBounded (r : α → α → Prop) (f : Filter α) :=
∃ b, ∀ᶠ x in f, r x b
#align filter.is_bounded Filter.IsBounded
/-- `f.IsBoundedUnder (≺) u`: the image of the filter `f` under `u` is eventually bounded w.r.t.
the relation `≺`, i.e. eventually, it is bounded by some uniform bound. -/
def IsBoundedUnder (r : α → α → Prop) (f : Filter β) (u : β → α) :=
(map u f).IsBounded r
#align filter.is_bounded_under Filter.IsBoundedUnder
variable {r : α → α → Prop} {f g : Filter α}
/-- `f` is eventually bounded if and only if, there exists an admissible set on which it is
bounded. -/
theorem isBounded_iff : f.IsBounded r ↔ ∃ s ∈ f.sets, ∃ b, s ⊆ { x | r x b } :=
Iff.intro (fun ⟨b, hb⟩ => ⟨{ a | r a b }, hb, b, Subset.refl _⟩) fun ⟨_, hs, b, hb⟩ =>
⟨b, mem_of_superset hs hb⟩
#align filter.is_bounded_iff Filter.isBounded_iff
/-- A bounded function `u` is in particular eventually bounded. -/
theorem isBoundedUnder_of {f : Filter β} {u : β → α} : (∃ b, ∀ x, r (u x) b) → f.IsBoundedUnder r u
| ⟨b, hb⟩ => ⟨b, show ∀ᶠ x in f, r (u x) b from eventually_of_forall hb⟩
#align filter.is_bounded_under_of Filter.isBoundedUnder_of
theorem isBounded_bot : IsBounded r ⊥ ↔ Nonempty α := by simp [IsBounded, exists_true_iff_nonempty]
#align filter.is_bounded_bot Filter.isBounded_bot
| Mathlib/Order/LiminfLimsup.lean | 80 | 80 | theorem isBounded_top : IsBounded r ⊤ ↔ ∃ t, ∀ x, r x t := by | simp [IsBounded, eq_univ_iff_forall]
|
/-
Copyright (c) 2019 Zhouhang Zhou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou
-/
import Mathlib.Order.Filter.AtTopBot
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Linarith.Frontend
#align_import algebra.quadratic_discriminant from "leanprover-community/mathlib"@"e085d1df33274f4b32f611f483aae678ba0b42df"
/-!
# Quadratic discriminants and roots of a quadratic
This file defines the discriminant of a quadratic and gives the solution to a quadratic equation.
## Main definition
- `discrim a b c`: the discriminant of a quadratic `a * x * x + b * x + c` is `b * b - 4 * a * c`.
## Main statements
- `quadratic_eq_zero_iff`: roots of a quadratic can be written as
`(-b + s) / (2 * a)` or `(-b - s) / (2 * a)`, where `s` is a square root of the discriminant.
- `quadratic_ne_zero_of_discrim_ne_sq`: if the discriminant has no square root,
then the corresponding quadratic has no root.
- `discrim_le_zero`: if a quadratic is always non-negative, then its discriminant is non-positive.
- `discrim_le_zero_of_nonpos`, `discrim_lt_zero`, `discrim_lt_zero_of_neg`: versions of this
statement with other inequalities.
## Tags
polynomial, quadratic, discriminant, root
-/
open Filter
section Ring
variable {R : Type*}
/-- Discriminant of a quadratic -/
def discrim [Ring R] (a b c : R) : R :=
b ^ 2 - 4 * a * c
#align discrim discrim
@[simp] lemma discrim_neg [Ring R] (a b c : R) : discrim (-a) (-b) (-c) = discrim a b c := by
simp [discrim]
#align discrim_neg discrim_neg
variable [CommRing R] {a b c : R}
lemma discrim_eq_sq_of_quadratic_eq_zero {x : R} (h : a * x * x + b * x + c = 0) :
discrim a b c = (2 * a * x + b) ^ 2 := by
rw [discrim]
linear_combination -4 * a * h
#align discrim_eq_sq_of_quadratic_eq_zero discrim_eq_sq_of_quadratic_eq_zero
/-- A quadratic has roots if and only if its discriminant equals some square.
-/
theorem quadratic_eq_zero_iff_discrim_eq_sq [NeZero (2 : R)] [NoZeroDivisors R]
(ha : a ≠ 0) (x : R) :
a * x * x + b * x + c = 0 ↔ discrim a b c = (2 * a * x + b) ^ 2 := by
refine ⟨discrim_eq_sq_of_quadratic_eq_zero, fun h ↦ ?_⟩
rw [discrim] at h
have ha : 2 * 2 * a ≠ 0 := mul_ne_zero (mul_ne_zero (NeZero.ne _) (NeZero.ne _)) ha
apply mul_left_cancel₀ ha
linear_combination -h
#align quadratic_eq_zero_iff_discrim_eq_sq quadratic_eq_zero_iff_discrim_eq_sq
/-- A quadratic has no root if its discriminant has no square root. -/
theorem quadratic_ne_zero_of_discrim_ne_sq (h : ∀ s : R, discrim a b c ≠ s^2) (x : R) :
a * x * x + b * x + c ≠ 0 :=
mt discrim_eq_sq_of_quadratic_eq_zero (h _)
#align quadratic_ne_zero_of_discrim_ne_sq quadratic_ne_zero_of_discrim_ne_sq
end Ring
section Field
variable {K : Type*} [Field K] [NeZero (2 : K)] {a b c x : K}
/-- Roots of a quadratic equation. -/
theorem quadratic_eq_zero_iff (ha : a ≠ 0) {s : K} (h : discrim a b c = s * s) (x : K) :
a * x * x + b * x + c = 0 ↔ x = (-b + s) / (2 * a) ∨ x = (-b - s) / (2 * a) := by
rw [quadratic_eq_zero_iff_discrim_eq_sq ha, h, sq, mul_self_eq_mul_self_iff]
field_simp
apply or_congr
· constructor <;> intro h' <;> linear_combination -h'
· constructor <;> intro h' <;> linear_combination h'
#align quadratic_eq_zero_iff quadratic_eq_zero_iff
/-- A quadratic has roots if its discriminant has square roots -/
theorem exists_quadratic_eq_zero (ha : a ≠ 0) (h : ∃ s, discrim a b c = s * s) :
∃ x, a * x * x + b * x + c = 0 := by
rcases h with ⟨s, hs⟩
use (-b + s) / (2 * a)
rw [quadratic_eq_zero_iff ha hs]
simp
#align exists_quadratic_eq_zero exists_quadratic_eq_zero
/-- Root of a quadratic when its discriminant equals zero -/
| Mathlib/Algebra/QuadraticDiscriminant.lean | 105 | 108 | theorem quadratic_eq_zero_iff_of_discrim_eq_zero (ha : a ≠ 0) (h : discrim a b c = 0) (x : K) :
a * x * x + b * x + c = 0 ↔ x = -b / (2 * a) := by |
have : discrim a b c = 0 * 0 := by rw [h, mul_zero]
rw [quadratic_eq_zero_iff ha this, add_zero, sub_zero, or_self_iff]
|
/-
Copyright (c) 2019 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Yaël Dillies
-/
import Mathlib.Algebra.Module.BigOperators
import Mathlib.Data.Finset.NoncommProd
import Mathlib.Data.Fintype.Perm
import Mathlib.Data.Int.ModEq
import Mathlib.GroupTheory.Perm.List
import Mathlib.GroupTheory.Perm.Sign
import Mathlib.Logic.Equiv.Fintype
import Mathlib.GroupTheory.Perm.Cycle.Basic
#align_import group_theory.perm.cycle.basic from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
/-!
# Cycle factors of a permutation
Let `β` be a `Fintype` and `f : Equiv.Perm β`.
* `Equiv.Perm.cycleOf`: `f.cycleOf x` is the cycle of `f` that `x` belongs to.
* `Equiv.Perm.cycleFactors`: `f.cycleFactors` is a list of disjoint cyclic permutations
that multiply to `f`.
-/
open Equiv Function Finset
variable {ι α β : Type*}
namespace Equiv.Perm
/-!
### `cycleOf`
-/
section CycleOf
variable [DecidableEq α] [Fintype α] {f g : Perm α} {x y : α}
/-- `f.cycleOf x` is the cycle of the permutation `f` to which `x` belongs. -/
def cycleOf (f : Perm α) (x : α) : Perm α :=
ofSubtype (subtypePerm f fun _ => sameCycle_apply_right.symm : Perm { y // SameCycle f x y })
#align equiv.perm.cycle_of Equiv.Perm.cycleOf
theorem cycleOf_apply (f : Perm α) (x y : α) :
cycleOf f x y = if SameCycle f x y then f y else y := by
dsimp only [cycleOf]
split_ifs with h
· apply ofSubtype_apply_of_mem
exact h
· apply ofSubtype_apply_of_not_mem
exact h
#align equiv.perm.cycle_of_apply Equiv.Perm.cycleOf_apply
theorem cycleOf_inv (f : Perm α) (x : α) : (cycleOf f x)⁻¹ = cycleOf f⁻¹ x :=
Equiv.ext fun y => by
rw [inv_eq_iff_eq, cycleOf_apply, cycleOf_apply]
split_ifs <;> simp_all [sameCycle_inv, sameCycle_inv_apply_right]
#align equiv.perm.cycle_of_inv Equiv.Perm.cycleOf_inv
@[simp]
theorem cycleOf_pow_apply_self (f : Perm α) (x : α) : ∀ n : ℕ, (cycleOf f x ^ n) x = (f ^ n) x := by
intro n
induction' n with n hn
· rfl
· rw [pow_succ', mul_apply, cycleOf_apply, hn, if_pos, pow_succ', mul_apply]
exact ⟨n, rfl⟩
#align equiv.perm.cycle_of_pow_apply_self Equiv.Perm.cycleOf_pow_apply_self
@[simp]
theorem cycleOf_zpow_apply_self (f : Perm α) (x : α) :
∀ n : ℤ, (cycleOf f x ^ n) x = (f ^ n) x := by
intro z
induction' z with z hz
· exact cycleOf_pow_apply_self f x z
· rw [zpow_negSucc, ← inv_pow, cycleOf_inv, zpow_negSucc, ← inv_pow, cycleOf_pow_apply_self]
#align equiv.perm.cycle_of_zpow_apply_self Equiv.Perm.cycleOf_zpow_apply_self
theorem SameCycle.cycleOf_apply : SameCycle f x y → cycleOf f x y = f y :=
ofSubtype_apply_of_mem _
#align equiv.perm.same_cycle.cycle_of_apply Equiv.Perm.SameCycle.cycleOf_apply
theorem cycleOf_apply_of_not_sameCycle : ¬SameCycle f x y → cycleOf f x y = y :=
ofSubtype_apply_of_not_mem _
#align equiv.perm.cycle_of_apply_of_not_same_cycle Equiv.Perm.cycleOf_apply_of_not_sameCycle
theorem SameCycle.cycleOf_eq (h : SameCycle f x y) : cycleOf f x = cycleOf f y := by
ext z
rw [Equiv.Perm.cycleOf_apply]
split_ifs with hz
· exact (h.symm.trans hz).cycleOf_apply.symm
· exact (cycleOf_apply_of_not_sameCycle (mt h.trans hz)).symm
#align equiv.perm.same_cycle.cycle_of_eq Equiv.Perm.SameCycle.cycleOf_eq
@[simp]
theorem cycleOf_apply_apply_zpow_self (f : Perm α) (x : α) (k : ℤ) :
cycleOf f x ((f ^ k) x) = (f ^ (k + 1) : Perm α) x := by
rw [SameCycle.cycleOf_apply]
· rw [add_comm, zpow_add, zpow_one, mul_apply]
· exact ⟨k, rfl⟩
#align equiv.perm.cycle_of_apply_apply_zpow_self Equiv.Perm.cycleOf_apply_apply_zpow_self
@[simp]
theorem cycleOf_apply_apply_pow_self (f : Perm α) (x : α) (k : ℕ) :
cycleOf f x ((f ^ k) x) = (f ^ (k + 1) : Perm α) x := by
convert cycleOf_apply_apply_zpow_self f x k using 1
#align equiv.perm.cycle_of_apply_apply_pow_self Equiv.Perm.cycleOf_apply_apply_pow_self
@[simp]
theorem cycleOf_apply_apply_self (f : Perm α) (x : α) : cycleOf f x (f x) = f (f x) := by
convert cycleOf_apply_apply_pow_self f x 1 using 1
#align equiv.perm.cycle_of_apply_apply_self Equiv.Perm.cycleOf_apply_apply_self
@[simp]
theorem cycleOf_apply_self (f : Perm α) (x : α) : cycleOf f x x = f x :=
SameCycle.rfl.cycleOf_apply
#align equiv.perm.cycle_of_apply_self Equiv.Perm.cycleOf_apply_self
theorem IsCycle.cycleOf_eq (hf : IsCycle f) (hx : f x ≠ x) : cycleOf f x = f :=
Equiv.ext fun y =>
if h : SameCycle f x y then by rw [h.cycleOf_apply]
else by
rw [cycleOf_apply_of_not_sameCycle h,
Classical.not_not.1 (mt ((isCycle_iff_sameCycle hx).1 hf).2 h)]
#align equiv.perm.is_cycle.cycle_of_eq Equiv.Perm.IsCycle.cycleOf_eq
@[simp]
| Mathlib/GroupTheory/Perm/Cycle/Factors.lean | 131 | 136 | theorem cycleOf_eq_one_iff (f : Perm α) : cycleOf f x = 1 ↔ f x = x := by |
simp_rw [ext_iff, cycleOf_apply, one_apply]
refine ⟨fun h => (if_pos (SameCycle.refl f x)).symm.trans (h x), fun h y => ?_⟩
by_cases hy : f y = y
· rw [hy, ite_self]
· exact if_neg (mt SameCycle.apply_eq_self_iff (by tauto))
|
/-
Copyright (c) 2024 Jz Pan. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jz Pan
-/
import Mathlib.LinearAlgebra.Dimension.Free
import Mathlib.LinearAlgebra.Dimension.Finite
import Mathlib.LinearAlgebra.FreeModule.StrongRankCondition
/-!
# Some results on the ranks of subalgebras
This file contains some results on the ranks of subalgebras,
which are corollaries of `rank_mul_rank`.
Since their proof essentially depends on the fact that a non-trivial commutative ring
satisfies strong rank condition, we put them into a separate file.
-/
open FiniteDimensional
namespace Subalgebra
variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S]
(A B : Subalgebra R S) [Module.Free R A] [Module.Free R B]
[Module.Free A (Algebra.adjoin A (B : Set S))]
[Module.Free B (Algebra.adjoin B (A : Set S))]
theorem rank_sup_eq_rank_left_mul_rank_of_free :
Module.rank R ↥(A ⊔ B) = Module.rank R A * Module.rank A (Algebra.adjoin A (B : Set S)) := by
rcases subsingleton_or_nontrivial R with _ | _
· haveI := Module.subsingleton R S; simp
nontriviality S using rank_subsingleton'
letI : Algebra A (Algebra.adjoin A (B : Set S)) := Subalgebra.algebra _
letI : SMul A (Algebra.adjoin A (B : Set S)) := Algebra.toSMul
haveI : IsScalarTower R A (Algebra.adjoin A (B : Set S)) :=
IsScalarTower.of_algebraMap_eq (congrFun rfl)
rw [rank_mul_rank R A (Algebra.adjoin A (B : Set S))]
change _ = Module.rank R ((Algebra.adjoin A (B : Set S)).restrictScalars R)
rw [Algebra.restrictScalars_adjoin]; rfl
theorem rank_sup_eq_rank_right_mul_rank_of_free :
Module.rank R ↥(A ⊔ B) = Module.rank R B * Module.rank B (Algebra.adjoin B (A : Set S)) := by
rw [sup_comm, rank_sup_eq_rank_left_mul_rank_of_free]
| Mathlib/Algebra/Algebra/Subalgebra/Rank.lean | 47 | 49 | theorem finrank_sup_eq_finrank_left_mul_finrank_of_free :
finrank R ↥(A ⊔ B) = finrank R A * finrank A (Algebra.adjoin A (B : Set S)) := by |
simpa only [map_mul] using congr(Cardinal.toNat $(rank_sup_eq_rank_left_mul_rank_of_free A B))
|
/-
Copyright (c) 2021 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Heather Macbeth, Johannes Hölzl, Yury Kudryashov
-/
import Mathlib.Algebra.BigOperators.Intervals
import Mathlib.Analysis.Normed.Group.Basic
import Mathlib.Topology.Instances.NNReal
#align_import analysis.normed.group.infinite_sum from "leanprover-community/mathlib"@"9a59dcb7a2d06bf55da57b9030169219980660cd"
/-!
# Infinite sums in (semi)normed groups
In a complete (semi)normed group,
- `summable_iff_vanishing_norm`: a series `∑' i, f i` is summable if and only if for any `ε > 0`,
there exists a finite set `s` such that the sum `∑ i ∈ t, f i` over any finite set `t` disjoint
with `s` has norm less than `ε`;
- `summable_of_norm_bounded`, `Summable.of_norm_bounded_eventually`: if `‖f i‖` is bounded above by
a summable series `∑' i, g i`, then `∑' i, f i` is summable as well; the same is true if the
inequality hold only off some finite set.
- `tsum_of_norm_bounded`, `HasSum.norm_le_of_bounded`: if `‖f i‖ ≤ g i`, where `∑' i, g i` is a
summable series, then `‖∑' i, f i‖ ≤ ∑' i, g i`.
## Tags
infinite series, absolute convergence, normed group
-/
open Topology NNReal
open Finset Filter Metric
variable {ι α E F : Type*} [SeminormedAddCommGroup E] [SeminormedAddCommGroup F]
theorem cauchySeq_finset_iff_vanishing_norm {f : ι → E} :
(CauchySeq fun s : Finset ι => ∑ i ∈ s, f i) ↔
∀ ε > (0 : ℝ), ∃ s : Finset ι, ∀ t, Disjoint t s → ‖∑ i ∈ t, f i‖ < ε := by
rw [cauchySeq_finset_iff_sum_vanishing, nhds_basis_ball.forall_iff]
· simp only [ball_zero_eq, Set.mem_setOf_eq]
· rintro s t hst ⟨s', hs'⟩
exact ⟨s', fun t' ht' => hst <| hs' _ ht'⟩
#align cauchy_seq_finset_iff_vanishing_norm cauchySeq_finset_iff_vanishing_norm
| Mathlib/Analysis/Normed/Group/InfiniteSum.lean | 49 | 51 | theorem summable_iff_vanishing_norm [CompleteSpace E] {f : ι → E} :
Summable f ↔ ∀ ε > (0 : ℝ), ∃ s : Finset ι, ∀ t, Disjoint t s → ‖∑ i ∈ t, f i‖ < ε := by |
rw [summable_iff_cauchySeq_finset, cauchySeq_finset_iff_vanishing_norm]
|
/-
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
| Mathlib/Probability/Martingale/BorelCantelli.lean | 75 | 90 | 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₂⟩
|
/-
Copyright (c) 2020 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rémy Degenne, Eric Wieser
-/
import Mathlib.MeasureTheory.Function.LpSeminorm.Basic
import Mathlib.MeasureTheory.Integral.MeanInequalities
#align_import measure_theory.function.lp_seminorm from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9"
/-!
# Compare Lp seminorms for different values of `p`
In this file we compare `MeasureTheory.snorm'` and `MeasureTheory.snorm` for different exponents.
-/
open Filter
open scoped ENNReal Topology
namespace MeasureTheory
section SameSpace
variable {α E : Type*} {m : MeasurableSpace α} [NormedAddCommGroup E] {μ : Measure α} {f : α → E}
| Mathlib/MeasureTheory/Function/LpSeminorm/CompareExp.lean | 26 | 45 | theorem snorm'_le_snorm'_mul_rpow_measure_univ {p q : ℝ} (hp0_lt : 0 < p) (hpq : p ≤ q)
(hf : AEStronglyMeasurable f μ) :
snorm' f p μ ≤ snorm' f q μ * μ Set.univ ^ (1 / p - 1 / q) := by |
have hq0_lt : 0 < q := lt_of_lt_of_le hp0_lt hpq
by_cases hpq_eq : p = q
· rw [hpq_eq, sub_self, ENNReal.rpow_zero, mul_one]
have hpq : p < q := lt_of_le_of_ne hpq hpq_eq
let g := fun _ : α => (1 : ℝ≥0∞)
have h_rw : (∫⁻ a, (‖f a‖₊ : ℝ≥0∞) ^ p ∂μ) = ∫⁻ a, ((‖f a‖₊ : ℝ≥0∞) * g a) ^ p ∂μ :=
lintegral_congr fun a => by simp [g]
repeat' rw [snorm']
rw [h_rw]
let r := p * q / (q - p)
have hpqr : 1 / p = 1 / q + 1 / r := by field_simp [r, hp0_lt.ne', hq0_lt.ne']
calc
(∫⁻ a : α, (↑‖f a‖₊ * g a) ^ p ∂μ) ^ (1 / p) ≤
(∫⁻ a : α, ↑‖f a‖₊ ^ q ∂μ) ^ (1 / q) * (∫⁻ a : α, g a ^ r ∂μ) ^ (1 / r) :=
ENNReal.lintegral_Lp_mul_le_Lq_mul_Lr hp0_lt hpq hpqr μ hf.ennnorm aemeasurable_const
_ = (∫⁻ a : α, ↑‖f a‖₊ ^ q ∂μ) ^ (1 / q) * μ Set.univ ^ (1 / p - 1 / q) := by
rw [hpqr]; simp [r, g]
|
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Yury G. Kudryashov
-/
import Batteries.Data.Sum.Basic
import Batteries.Logic
/-!
# Disjoint union of types
Theorems about the definitions introduced in `Batteries.Data.Sum.Basic`.
-/
open Function
namespace Sum
@[simp] protected theorem «forall» {p : α ⊕ β → Prop} :
(∀ x, p x) ↔ (∀ a, p (inl a)) ∧ ∀ b, p (inr b) :=
⟨fun h => ⟨fun _ => h _, fun _ => h _⟩, fun ⟨h₁, h₂⟩ => Sum.rec h₁ h₂⟩
@[simp] protected theorem «exists» {p : α ⊕ β → Prop} :
(∃ x, p x) ↔ (∃ a, p (inl a)) ∨ ∃ b, p (inr b) :=
⟨ fun
| ⟨inl a, h⟩ => Or.inl ⟨a, h⟩
| ⟨inr b, h⟩ => Or.inr ⟨b, h⟩,
fun
| Or.inl ⟨a, h⟩ => ⟨inl a, h⟩
| Or.inr ⟨b, h⟩ => ⟨inr b, h⟩⟩
theorem forall_sum {γ : α ⊕ β → Sort _} (p : (∀ ab, γ ab) → Prop) :
(∀ fab, p fab) ↔ (∀ fa fb, p (Sum.rec fa fb)) := by
refine ⟨fun h fa fb => h _, fun h fab => ?_⟩
have h1 : fab = Sum.rec (fun a => fab (Sum.inl a)) (fun b => fab (Sum.inr b)) := by
ext ab; cases ab <;> rfl
rw [h1]; exact h _ _
section get
@[simp] theorem inl_getLeft : ∀ (x : α ⊕ β) (h : x.isLeft), inl (x.getLeft h) = x
| inl _, _ => rfl
@[simp] theorem inr_getRight : ∀ (x : α ⊕ β) (h : x.isRight), inr (x.getRight h) = x
| inr _, _ => rfl
@[simp] theorem getLeft?_eq_none_iff {x : α ⊕ β} : x.getLeft? = none ↔ x.isRight := by
cases x <;> simp only [getLeft?, isRight, eq_self_iff_true]
@[simp] theorem getRight?_eq_none_iff {x : α ⊕ β} : x.getRight? = none ↔ x.isLeft := by
cases x <;> simp only [getRight?, isLeft, eq_self_iff_true]
theorem eq_left_getLeft_of_isLeft : ∀ {x : α ⊕ β} (h : x.isLeft), x = inl (x.getLeft h)
| inl _, _ => rfl
@[simp] theorem getLeft_eq_iff (h : x.isLeft) : x.getLeft h = a ↔ x = inl a := by
cases x <;> simp at h ⊢
theorem eq_right_getRight_of_isRight : ∀ {x : α ⊕ β} (h : x.isRight), x = inr (x.getRight h)
| inr _, _ => rfl
@[simp] theorem getRight_eq_iff (h : x.isRight) : x.getRight h = b ↔ x = inr b := by
cases x <;> simp at h ⊢
@[simp] theorem getLeft?_eq_some_iff : x.getLeft? = some a ↔ x = inl a := by
cases x <;> simp only [getLeft?, Option.some.injEq, inl.injEq]
@[simp] theorem getRight?_eq_some_iff : x.getRight? = some b ↔ x = inr b := by
cases x <;> simp only [getRight?, Option.some.injEq, inr.injEq]
@[simp] theorem bnot_isLeft (x : α ⊕ β) : !x.isLeft = x.isRight := by cases x <;> rfl
@[simp] theorem isLeft_eq_false {x : α ⊕ β} : x.isLeft = false ↔ x.isRight := by cases x <;> simp
theorem not_isLeft {x : α ⊕ β} : ¬x.isLeft ↔ x.isRight := by simp
@[simp] theorem bnot_isRight (x : α ⊕ β) : !x.isRight = x.isLeft := by cases x <;> rfl
@[simp] theorem isRight_eq_false {x : α ⊕ β} : x.isRight = false ↔ x.isLeft := by cases x <;> simp
theorem not_isRight {x : α ⊕ β} : ¬x.isRight ↔ x.isLeft := by simp
theorem isLeft_iff : x.isLeft ↔ ∃ y, x = Sum.inl y := by cases x <;> simp
| .lake/packages/batteries/Batteries/Data/Sum/Lemmas.lean | 85 | 85 | theorem isRight_iff : x.isRight ↔ ∃ y, x = Sum.inr y := by | cases x <;> simp
|
/-
Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel
-/
import Mathlib.Data.ENNReal.Real
import Mathlib.Order.Interval.Finset.Nat
import Mathlib.Topology.UniformSpace.Pi
import Mathlib.Topology.UniformSpace.UniformConvergence
import Mathlib.Topology.UniformSpace.UniformEmbedding
#align_import topology.metric_space.emetric_space from "leanprover-community/mathlib"@"c8f305514e0d47dfaa710f5a52f0d21b588e6328"
/-!
# Extended metric spaces
This file is devoted to the definition and study of `EMetricSpace`s, i.e., metric
spaces in which the distance is allowed to take the value ∞. This extended distance is
called `edist`, and takes values in `ℝ≥0∞`.
Many definitions and theorems expected on emetric spaces are already introduced on uniform spaces
and topological spaces. For example: open and closed sets, compactness, completeness, continuity and
uniform continuity.
The class `EMetricSpace` therefore extends `UniformSpace` (and `TopologicalSpace`).
Since a lot of elementary properties don't require `eq_of_edist_eq_zero` we start setting up the
theory of `PseudoEMetricSpace`, where we don't require `edist x y = 0 → x = y` and we specialize
to `EMetricSpace` at the end.
-/
open Set Filter Classical
open scoped Uniformity Topology Filter NNReal ENNReal Pointwise
universe u v w
variable {α : Type u} {β : Type v} {X : Type*}
/-- Characterizing uniformities associated to a (generalized) distance function `D`
in terms of the elements of the uniformity. -/
theorem uniformity_dist_of_mem_uniformity [LinearOrder β] {U : Filter (α × α)} (z : β)
(D : α → α → β) (H : ∀ s, s ∈ U ↔ ∃ ε > z, ∀ {a b : α}, D a b < ε → (a, b) ∈ s) :
U = ⨅ ε > z, 𝓟 { p : α × α | D p.1 p.2 < ε } :=
HasBasis.eq_biInf ⟨fun s => by simp only [H, subset_def, Prod.forall, mem_setOf]⟩
#align uniformity_dist_of_mem_uniformity uniformity_dist_of_mem_uniformity
/-- `EDist α` means that `α` is equipped with an extended distance. -/
@[ext]
class EDist (α : Type*) where
edist : α → α → ℝ≥0∞
#align has_edist EDist
export EDist (edist)
/-- Creating a uniform space from an extended distance. -/
def uniformSpaceOfEDist (edist : α → α → ℝ≥0∞) (edist_self : ∀ x : α, edist x x = 0)
(edist_comm : ∀ x y : α, edist x y = edist y x)
(edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z) : UniformSpace α :=
.ofFun edist edist_self edist_comm edist_triangle fun ε ε0 =>
⟨ε / 2, ENNReal.half_pos ε0.ne', fun _ h₁ _ h₂ =>
(ENNReal.add_lt_add h₁ h₂).trans_eq (ENNReal.add_halves _)⟩
#align uniform_space_of_edist uniformSpaceOfEDist
-- the uniform structure is embedded in the emetric space structure
-- to avoid instance diamond issues. See Note [forgetful inheritance].
/-- Extended (pseudo) metric spaces, with an extended distance `edist` possibly taking the
value ∞
Each pseudo_emetric space induces a canonical `UniformSpace` and hence a canonical
`TopologicalSpace`.
This is enforced in the type class definition, by extending the `UniformSpace` structure. When
instantiating a `PseudoEMetricSpace` structure, the uniformity fields are not necessary, they
will be filled in by default. There is a default value for the uniformity, that can be substituted
in cases of interest, for instance when instantiating a `PseudoEMetricSpace` structure
on a product.
Continuity of `edist` is proved in `Topology.Instances.ENNReal`
-/
class PseudoEMetricSpace (α : Type u) extends EDist α : Type u where
edist_self : ∀ x : α, edist x x = 0
edist_comm : ∀ x y : α, edist x y = edist y x
edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z
toUniformSpace : UniformSpace α := uniformSpaceOfEDist edist edist_self edist_comm edist_triangle
uniformity_edist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | edist p.1 p.2 < ε } := by rfl
#align pseudo_emetric_space PseudoEMetricSpace
attribute [instance] PseudoEMetricSpace.toUniformSpace
/- Pseudoemetric spaces are less common than metric spaces. Therefore, we work in a dedicated
namespace, while notions associated to metric spaces are mostly in the root namespace. -/
/-- Two pseudo emetric space structures with the same edistance function coincide. -/
@[ext]
protected theorem PseudoEMetricSpace.ext {α : Type*} {m m' : PseudoEMetricSpace α}
(h : m.toEDist = m'.toEDist) : m = m' := by
cases' m with ed _ _ _ U hU
cases' m' with ed' _ _ _ U' hU'
congr 1
exact UniformSpace.ext (((show ed = ed' from h) ▸ hU).trans hU'.symm)
variable [PseudoEMetricSpace α]
export PseudoEMetricSpace (edist_self edist_comm edist_triangle)
attribute [simp] edist_self
/-- Triangle inequality for the extended distance -/
theorem edist_triangle_left (x y z : α) : edist x y ≤ edist z x + edist z y := by
rw [edist_comm z]; apply edist_triangle
#align edist_triangle_left edist_triangle_left
theorem edist_triangle_right (x y z : α) : edist x y ≤ edist x z + edist y z := by
rw [edist_comm y]; apply edist_triangle
#align edist_triangle_right edist_triangle_right
theorem edist_congr_right {x y z : α} (h : edist x y = 0) : edist x z = edist y z := by
apply le_antisymm
· rw [← zero_add (edist y z), ← h]
apply edist_triangle
· rw [edist_comm] at h
rw [← zero_add (edist x z), ← h]
apply edist_triangle
#align edist_congr_right edist_congr_right
| Mathlib/Topology/EMetricSpace/Basic.lean | 127 | 129 | theorem edist_congr_left {x y z : α} (h : edist x y = 0) : edist z x = edist z y := by |
rw [edist_comm z x, edist_comm z y]
apply edist_congr_right h
|
/-
Copyright (c) 2021 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import Mathlib.LinearAlgebra.AffineSpace.Independent
import Mathlib.LinearAlgebra.Basis
#align_import linear_algebra.affine_space.basis from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0"
/-!
# Affine bases and barycentric coordinates
Suppose `P` is an affine space modelled on the module `V` over the ring `k`, and `p : ι → P` is an
affine-independent family of points spanning `P`. Given this data, each point `q : P` may be written
uniquely as an affine combination: `q = w₀ p₀ + w₁ p₁ + ⋯` for some (finitely-supported) weights
`wᵢ`. For each `i : ι`, we thus have an affine map `P →ᵃ[k] k`, namely `q ↦ wᵢ`. This family of
maps is known as the family of barycentric coordinates. It is defined in this file.
## The construction
Fixing `i : ι`, and allowing `j : ι` to range over the values `j ≠ i`, we obtain a basis `bᵢ` of `V`
defined by `bᵢ j = p j -ᵥ p i`. Let `fᵢ j : V →ₗ[k] k` be the corresponding dual basis and let
`fᵢ = ∑ j, fᵢ j : V →ₗ[k] k` be the corresponding "sum of all coordinates" form. Then the `i`th
barycentric coordinate of `q : P` is `1 - fᵢ (q -ᵥ p i)`.
## Main definitions
* `AffineBasis`: a structure representing an affine basis of an affine space.
* `AffineBasis.coord`: the map `P →ᵃ[k] k` corresponding to `i : ι`.
* `AffineBasis.coord_apply_eq`: the behaviour of `AffineBasis.coord i` on `p i`.
* `AffineBasis.coord_apply_ne`: the behaviour of `AffineBasis.coord i` on `p j` when `j ≠ i`.
* `AffineBasis.coord_apply`: the behaviour of `AffineBasis.coord i` on `p j` for general `j`.
* `AffineBasis.coord_apply_combination`: the characterisation of `AffineBasis.coord i` in terms
of affine combinations, i.e., `AffineBasis.coord i (w₀ p₀ + w₁ p₁ + ⋯) = wᵢ`.
## TODO
* Construct the affine equivalence between `P` and `{ f : ι →₀ k | f.sum = 1 }`.
-/
open Affine
open Set
universe u₁ u₂ u₃ u₄
/-- An affine basis is a family of affine-independent points whose span is the top subspace. -/
structure AffineBasis (ι : Type u₁) (k : Type u₂) {V : Type u₃} (P : Type u₄) [AddCommGroup V]
[AffineSpace V P] [Ring k] [Module k V] where
protected toFun : ι → P
protected ind' : AffineIndependent k toFun
protected tot' : affineSpan k (range toFun) = ⊤
#align affine_basis AffineBasis
variable {ι ι' k V P : Type*} [AddCommGroup V] [AffineSpace V P]
namespace AffineBasis
section Ring
variable [Ring k] [Module k V] (b : AffineBasis ι k P) {s : Finset ι} {i j : ι} (e : ι ≃ ι')
/-- The unique point in a single-point space is the simplest example of an affine basis. -/
instance : Inhabited (AffineBasis PUnit k PUnit) :=
⟨⟨id, affineIndependent_of_subsingleton k id, by simp⟩⟩
instance instFunLike : FunLike (AffineBasis ι k P) ι P where
coe := AffineBasis.toFun
coe_injective' f g h := by cases f; cases g; congr
#align affine_basis.fun_like AffineBasis.instFunLike
@[ext]
theorem ext {b₁ b₂ : AffineBasis ι k P} (h : (b₁ : ι → P) = b₂) : b₁ = b₂ :=
DFunLike.coe_injective h
#align affine_basis.ext AffineBasis.ext
theorem ind : AffineIndependent k b :=
b.ind'
#align affine_basis.ind AffineBasis.ind
theorem tot : affineSpan k (range b) = ⊤ :=
b.tot'
#align affine_basis.tot AffineBasis.tot
protected theorem nonempty : Nonempty ι :=
not_isEmpty_iff.mp fun hι => by
simpa only [@range_eq_empty _ _ hι, AffineSubspace.span_empty, bot_ne_top] using b.tot
#align affine_basis.nonempty AffineBasis.nonempty
/-- Composition of an affine basis and an equivalence of index types. -/
def reindex (e : ι ≃ ι') : AffineBasis ι' k P :=
⟨b ∘ e.symm, b.ind.comp_embedding e.symm.toEmbedding, by
rw [e.symm.surjective.range_comp]
exact b.3⟩
#align affine_basis.reindex AffineBasis.reindex
@[simp, norm_cast]
theorem coe_reindex : ⇑(b.reindex e) = b ∘ e.symm :=
rfl
#align affine_basis.coe_reindex AffineBasis.coe_reindex
@[simp]
theorem reindex_apply (i' : ι') : b.reindex e i' = b (e.symm i') :=
rfl
#align affine_basis.reindex_apply AffineBasis.reindex_apply
@[simp]
theorem reindex_refl : b.reindex (Equiv.refl _) = b :=
ext rfl
#align affine_basis.reindex_refl AffineBasis.reindex_refl
/-- Given an affine basis for an affine space `P`, if we single out one member of the family, we
obtain a linear basis for the model space `V`.
The linear basis corresponding to the singled-out member `i : ι` is indexed by `{j : ι // j ≠ i}`
and its `j`th element is `b j -ᵥ b i`. (See `basisOf_apply`.) -/
noncomputable def basisOf (i : ι) : Basis { j : ι // j ≠ i } k V :=
Basis.mk ((affineIndependent_iff_linearIndependent_vsub k b i).mp b.ind)
(by
suffices
Submodule.span k (range fun j : { x // x ≠ i } => b ↑j -ᵥ b i) = vectorSpan k (range b) by
rw [this, ← direction_affineSpan, b.tot, AffineSubspace.direction_top]
conv_rhs => rw [← image_univ]
rw [vectorSpan_image_eq_span_vsub_set_right_ne k b (mem_univ i)]
congr
ext v
simp)
#align affine_basis.basis_of AffineBasis.basisOf
@[simp]
| Mathlib/LinearAlgebra/AffineSpace/Basis.lean | 134 | 135 | theorem basisOf_apply (i : ι) (j : { j : ι // j ≠ i }) : b.basisOf i j = b ↑j -ᵥ b i := by |
simp [basisOf]
|
/-
Copyright (c) 2022 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta, Yaël Dillies
-/
import Mathlib.Analysis.Convex.Cone.Extension
import Mathlib.Analysis.Convex.Gauge
import Mathlib.Topology.Algebra.Module.FiniteDimension
import Mathlib.Topology.Algebra.Module.LocallyConvex
#align_import analysis.normed_space.hahn_banach.separation from "leanprover-community/mathlib"@"915591b2bb3ea303648db07284a161a7f2a9e3d4"
/-!
# Separation Hahn-Banach theorem
In this file we prove the geometric Hahn-Banach theorem. For any two disjoint convex sets, there
exists a continuous linear functional separating them, geometrically meaning that we can intercalate
a plane between them.
We provide many variations to stricten the result under more assumptions on the convex sets:
* `geometric_hahn_banach_open`: One set is open. Weak separation.
* `geometric_hahn_banach_open_point`, `geometric_hahn_banach_point_open`: One set is open, the
other is a singleton. Weak separation.
* `geometric_hahn_banach_open_open`: Both sets are open. Semistrict separation.
* `geometric_hahn_banach_compact_closed`, `geometric_hahn_banach_closed_compact`: One set is closed,
the other one is compact. Strict separation.
* `geometric_hahn_banach_point_closed`, `geometric_hahn_banach_closed_point`: One set is closed, the
other one is a singleton. Strict separation.
* `geometric_hahn_banach_point_point`: Both sets are singletons. Strict separation.
## TODO
* Eidelheit's theorem
* `Convex ℝ s → interior (closure s) ⊆ s`
-/
open Set
open Pointwise
variable {𝕜 E : Type*}
/-- Given a set `s` which is a convex neighbourhood of `0` and a point `x₀` outside of it, there is
a continuous linear functional `f` separating `x₀` and `s`, in the sense that it sends `x₀` to 1 and
all of `s` to values strictly below `1`. -/
| Mathlib/Analysis/NormedSpace/HahnBanach/Separation.lean | 47 | 76 | theorem separate_convex_open_set [TopologicalSpace E] [AddCommGroup E] [TopologicalAddGroup E]
[Module ℝ E] [ContinuousSMul ℝ E] {s : Set E} (hs₀ : (0 : E) ∈ s) (hs₁ : Convex ℝ s)
(hs₂ : IsOpen s) {x₀ : E} (hx₀ : x₀ ∉ s) : ∃ f : E →L[ℝ] ℝ, f x₀ = 1 ∧ ∀ x ∈ s, f x < 1 := by |
let f : E →ₗ.[ℝ] ℝ := LinearPMap.mkSpanSingleton x₀ 1 (ne_of_mem_of_not_mem hs₀ hx₀).symm
have := exists_extension_of_le_sublinear f (gauge s) (fun c hc => gauge_smul_of_nonneg hc.le)
(gauge_add_le hs₁ <| absorbent_nhds_zero <| hs₂.mem_nhds hs₀) ?_
· obtain ⟨φ, hφ₁, hφ₂⟩ := this
have hφ₃ : φ x₀ = 1 := by
rw [← f.domain.coe_mk x₀ (Submodule.mem_span_singleton_self _), hφ₁,
LinearPMap.mkSpanSingleton'_apply_self]
have hφ₄ : ∀ x ∈ s, φ x < 1 := fun x hx =>
(hφ₂ x).trans_lt (gauge_lt_one_of_mem_of_isOpen hs₂ hx)
refine ⟨⟨φ, ?_⟩, hφ₃, hφ₄⟩
refine
φ.continuous_of_nonzero_on_open _ (hs₂.vadd (-x₀)) (Nonempty.vadd_set ⟨0, hs₀⟩)
(vadd_set_subset_iff.mpr fun x hx => ?_)
change φ (-x₀ + x) ≠ 0
rw [map_add, map_neg]
specialize hφ₄ x hx
linarith
rintro ⟨x, hx⟩
obtain ⟨y, rfl⟩ := Submodule.mem_span_singleton.1 hx
rw [LinearPMap.mkSpanSingleton'_apply]
simp only [mul_one, Algebra.id.smul_eq_mul, Submodule.coe_mk]
obtain h | h := le_or_lt y 0
· exact h.trans (gauge_nonneg _)
· rw [gauge_smul_of_nonneg h.le, smul_eq_mul, le_mul_iff_one_le_right h]
exact
one_le_gauge_of_not_mem (hs₁.starConvex hs₀)
(absorbent_nhds_zero <| hs₂.mem_nhds hs₀).absorbs hx₀
|
/-
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, Alexander Bentkamp
-/
import Mathlib.LinearAlgebra.Basis
import Mathlib.LinearAlgebra.FreeModule.Basic
import Mathlib.LinearAlgebra.LinearPMap
import Mathlib.LinearAlgebra.Projection
#align_import linear_algebra.basis from "leanprover-community/mathlib"@"13bce9a6b6c44f6b4c91ac1c1d2a816e2533d395"
/-!
# Bases in a vector space
This file provides results for bases of a vector space.
Some of these results should be merged with the results on free modules.
We state these results in a separate file to the results on modules to avoid an
import cycle.
## Main statements
* `Basis.ofVectorSpace` states that every vector space has a basis.
* `Module.Free.of_divisionRing` states that every vector space is a free module.
## Tags
basis, bases
-/
open Function Set Submodule
set_option autoImplicit false
variable {ι : Type*} {ι' : Type*} {K : Type*} {V : Type*} {V' : Type*}
section DivisionRing
variable [DivisionRing K] [AddCommGroup V] [AddCommGroup V'] [Module K V] [Module K V']
variable {v : ι → V} {s t : Set V} {x y z : V}
open Submodule
namespace Basis
section ExistsBasis
/-- If `s` is a linear independent set of vectors, we can extend it to a basis. -/
noncomputable def extend (hs : LinearIndependent K ((↑) : s → V)) :
Basis (hs.extend (subset_univ s)) K V :=
Basis.mk
(@LinearIndependent.restrict_of_comp_subtype _ _ _ id _ _ _ _ (hs.linearIndependent_extend _))
(SetLike.coe_subset_coe.mp <| by simpa using hs.subset_span_extend (subset_univ s))
#align basis.extend Basis.extend
theorem extend_apply_self (hs : LinearIndependent K ((↑) : s → V)) (x : hs.extend _) :
Basis.extend hs x = x :=
Basis.mk_apply _ _ _
#align basis.extend_apply_self Basis.extend_apply_self
@[simp]
theorem coe_extend (hs : LinearIndependent K ((↑) : s → V)) : ⇑(Basis.extend hs) = ((↑) : _ → _) :=
funext (extend_apply_self hs)
#align basis.coe_extend Basis.coe_extend
| Mathlib/LinearAlgebra/Basis/VectorSpace.lean | 67 | 69 | theorem range_extend (hs : LinearIndependent K ((↑) : s → V)) :
range (Basis.extend hs) = hs.extend (subset_univ _) := by |
rw [coe_extend, Subtype.range_coe_subtype, setOf_mem_eq]
|
/-
Copyright (c) 2021 François Sunatori. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: François Sunatori
-/
import Mathlib.Analysis.Complex.Circle
import Mathlib.LinearAlgebra.Determinant
import Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup
#align_import analysis.complex.isometry from "leanprover-community/mathlib"@"ae690b0c236e488a0043f6faa8ce3546e7f2f9c5"
/-!
# Isometries of the Complex Plane
The lemma `linear_isometry_complex` states the classification of isometries in the complex plane.
Specifically, isometries with rotations but without translation.
The proof involves:
1. creating a linear isometry `g` with two fixed points, `g(0) = 0`, `g(1) = 1`
2. applying `linear_isometry_complex_aux` to `g`
The proof of `linear_isometry_complex_aux` is separated in the following parts:
1. show that the real parts match up: `LinearIsometry.re_apply_eq_re`
2. show that I maps to either I or -I
3. every z is a linear combination of a + b * I
## References
* [Isometries of the Complex Plane](http://helmut.knaust.info/mediawiki/images/b/b5/Iso.pdf)
-/
noncomputable section
open Complex
open ComplexConjugate
local notation "|" x "|" => Complex.abs x
/-- An element of the unit circle defines a `LinearIsometryEquiv` from `ℂ` to itself, by
rotation. -/
def rotation : circle →* ℂ ≃ₗᵢ[ℝ] ℂ where
toFun a :=
{ DistribMulAction.toLinearEquiv ℝ ℂ a with
norm_map' := fun x => show |a * x| = |x| by rw [map_mul, abs_coe_circle, one_mul] }
map_one' := LinearIsometryEquiv.ext <| one_smul circle
map_mul' a b := LinearIsometryEquiv.ext <| mul_smul a b
#align rotation rotation
@[simp]
theorem rotation_apply (a : circle) (z : ℂ) : rotation a z = a * z :=
rfl
#align rotation_apply rotation_apply
@[simp]
theorem rotation_symm (a : circle) : (rotation a).symm = rotation a⁻¹ :=
LinearIsometryEquiv.ext fun _ => rfl
#align rotation_symm rotation_symm
@[simp]
theorem rotation_trans (a b : circle) : (rotation a).trans (rotation b) = rotation (b * a) := by
ext1
simp
#align rotation_trans rotation_trans
theorem rotation_ne_conjLIE (a : circle) : rotation a ≠ conjLIE := by
intro h
have h1 : rotation a 1 = conj 1 := LinearIsometryEquiv.congr_fun h 1
have hI : rotation a I = conj I := LinearIsometryEquiv.congr_fun h I
rw [rotation_apply, RingHom.map_one, mul_one] at h1
rw [rotation_apply, conj_I, ← neg_one_mul, mul_left_inj' I_ne_zero, h1, eq_neg_self_iff] at hI
exact one_ne_zero hI
#align rotation_ne_conj_lie rotation_ne_conjLIE
/-- Takes an element of `ℂ ≃ₗᵢ[ℝ] ℂ` and checks if it is a rotation, returns an element of the
unit circle. -/
@[simps]
def rotationOf (e : ℂ ≃ₗᵢ[ℝ] ℂ) : circle :=
⟨e 1 / Complex.abs (e 1), by simp⟩
#align rotation_of rotationOf
@[simp]
theorem rotationOf_rotation (a : circle) : rotationOf (rotation a) = a :=
Subtype.ext <| by simp
#align rotation_of_rotation rotationOf_rotation
theorem rotation_injective : Function.Injective rotation :=
Function.LeftInverse.injective rotationOf_rotation
#align rotation_injective rotation_injective
theorem LinearIsometry.re_apply_eq_re_of_add_conj_eq (f : ℂ →ₗᵢ[ℝ] ℂ)
(h₃ : ∀ z, z + conj z = f z + conj (f z)) (z : ℂ) : (f z).re = z.re := by
simpa [ext_iff, add_re, add_im, conj_re, conj_im, ← two_mul,
show (2 : ℝ) ≠ 0 by simp [two_ne_zero]] using (h₃ z).symm
#align linear_isometry.re_apply_eq_re_of_add_conj_eq LinearIsometry.re_apply_eq_re_of_add_conj_eq
theorem LinearIsometry.im_apply_eq_im_or_neg_of_re_apply_eq_re {f : ℂ →ₗᵢ[ℝ] ℂ}
(h₂ : ∀ z, (f z).re = z.re) (z : ℂ) : (f z).im = z.im ∨ (f z).im = -z.im := by
have h₁ := f.norm_map z
simp only [Complex.abs_def, norm_eq_abs] at h₁
rwa [Real.sqrt_inj (normSq_nonneg _) (normSq_nonneg _), normSq_apply (f z), normSq_apply z,
h₂, add_left_cancel_iff, mul_self_eq_mul_self_iff] at h₁
#align linear_isometry.im_apply_eq_im_or_neg_of_re_apply_eq_re LinearIsometry.im_apply_eq_im_or_neg_of_re_apply_eq_re
| Mathlib/Analysis/Complex/Isometry.lean | 104 | 116 | theorem LinearIsometry.im_apply_eq_im {f : ℂ →ₗᵢ[ℝ] ℂ} (h : f 1 = 1) (z : ℂ) :
z + conj z = f z + conj (f z) := by |
have : ‖f z - 1‖ = ‖z - 1‖ := by rw [← f.norm_map (z - 1), f.map_sub, h]
apply_fun fun x => x ^ 2 at this
simp only [norm_eq_abs, ← normSq_eq_abs] at this
rw [← ofReal_inj, ← mul_conj, ← mul_conj] at this
rw [RingHom.map_sub, RingHom.map_sub] at this
simp only [sub_mul, mul_sub, one_mul, mul_one] at this
rw [mul_conj, normSq_eq_abs, ← norm_eq_abs, LinearIsometry.norm_map] at this
rw [mul_conj, normSq_eq_abs, ← norm_eq_abs] at this
simp only [sub_sub, sub_right_inj, mul_one, ofReal_pow, RingHom.map_one, norm_eq_abs] at this
simp only [add_sub, sub_left_inj] at this
rw [add_comm, ← this, add_comm]
|
/-
Copyright (c) 2021 Noam Atar. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Noam Atar
-/
import Mathlib.Order.Ideal
import Mathlib.Order.PFilter
#align_import order.prime_ideal from "leanprover-community/mathlib"@"740acc0e6f9adf4423f92a485d0456fc271482da"
/-!
# Prime ideals
## Main definitions
Throughout this file, `P` is at least a preorder, but some sections require more
structure, such as a bottom element, a top element, or a join-semilattice structure.
- `Order.Ideal.PrimePair`: A pair of an `Order.Ideal` and an `Order.PFilter` which form a partition
of `P`. This is useful as giving the data of a prime ideal is the same as giving the data of a
prime filter.
- `Order.Ideal.IsPrime`: a predicate for prime ideals. Dual to the notion of a prime filter.
- `Order.PFilter.IsPrime`: a predicate for prime filters. Dual to the notion of a prime ideal.
## References
- <https://en.wikipedia.org/wiki/Ideal_(order_theory)>
## Tags
ideal, prime
-/
open Order.PFilter
namespace Order
variable {P : Type*}
namespace Ideal
/-- A pair of an `Order.Ideal` and an `Order.PFilter` which form a partition of `P`.
-/
-- Porting note(#5171): this linter isn't ported yet.
-- @[nolint has_nonempty_instance]
structure PrimePair (P : Type*) [Preorder P] where
I : Ideal P
F : PFilter P
isCompl_I_F : IsCompl (I : Set P) F
#align order.ideal.prime_pair Order.Ideal.PrimePair
namespace PrimePair
variable [Preorder P] (IF : PrimePair P)
theorem compl_I_eq_F : (IF.I : Set P)ᶜ = IF.F :=
IF.isCompl_I_F.compl_eq
set_option linter.uppercaseLean3 false in
#align order.ideal.prime_pair.compl_I_eq_F Order.Ideal.PrimePair.compl_I_eq_F
theorem compl_F_eq_I : (IF.F : Set P)ᶜ = IF.I :=
IF.isCompl_I_F.eq_compl.symm
set_option linter.uppercaseLean3 false in
#align order.ideal.prime_pair.compl_F_eq_I Order.Ideal.PrimePair.compl_F_eq_I
theorem I_isProper : IsProper IF.I := by
cases' IF.F.nonempty with w h
apply isProper_of_not_mem (_ : w ∉ IF.I)
rwa [← IF.compl_I_eq_F] at h
set_option linter.uppercaseLean3 false in
#align order.ideal.prime_pair.I_is_proper Order.Ideal.PrimePair.I_isProper
protected theorem disjoint : Disjoint (IF.I : Set P) IF.F :=
IF.isCompl_I_F.disjoint
#align order.ideal.prime_pair.disjoint Order.Ideal.PrimePair.disjoint
theorem I_union_F : (IF.I : Set P) ∪ IF.F = Set.univ :=
IF.isCompl_I_F.sup_eq_top
set_option linter.uppercaseLean3 false in
#align order.ideal.prime_pair.I_union_F Order.Ideal.PrimePair.I_union_F
theorem F_union_I : (IF.F : Set P) ∪ IF.I = Set.univ :=
IF.isCompl_I_F.symm.sup_eq_top
set_option linter.uppercaseLean3 false in
#align order.ideal.prime_pair.F_union_I Order.Ideal.PrimePair.F_union_I
end PrimePair
/-- An ideal `I` is prime if its complement is a filter.
-/
@[mk_iff]
class IsPrime [Preorder P] (I : Ideal P) extends IsProper I : Prop where
compl_filter : IsPFilter (I : Set P)ᶜ
#align order.ideal.is_prime Order.Ideal.IsPrime
section Preorder
variable [Preorder P]
/-- Create an element of type `Order.Ideal.PrimePair` from an ideal satisfying the predicate
`Order.Ideal.IsPrime`. -/
def IsPrime.toPrimePair {I : Ideal P} (h : IsPrime I) : PrimePair P :=
{ I
F := h.compl_filter.toPFilter
isCompl_I_F := isCompl_compl }
#align order.ideal.is_prime.to_prime_pair Order.Ideal.IsPrime.toPrimePair
theorem PrimePair.I_isPrime (IF : PrimePair P) : IsPrime IF.I :=
{ IF.I_isProper with
compl_filter := by
rw [IF.compl_I_eq_F]
exact IF.F.isPFilter }
set_option linter.uppercaseLean3 false in
#align order.ideal.prime_pair.I_is_prime Order.Ideal.PrimePair.I_isPrime
end Preorder
section SemilatticeInf
variable [SemilatticeInf P] {x y : P} {I : Ideal P}
| Mathlib/Order/PrimeIdeal.lean | 124 | 128 | theorem IsPrime.mem_or_mem (hI : IsPrime I) {x y : P} : x ⊓ y ∈ I → x ∈ I ∨ y ∈ I := by |
contrapose!
let F := hI.compl_filter.toPFilter
show x ∈ F ∧ y ∈ F → x ⊓ y ∈ F
exact fun h => inf_mem h.1 h.2
|
/-
Copyright (c) 2020 Riccardo Brasca. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Riccardo Brasca
-/
import Mathlib.Algebra.NeZero
import Mathlib.Algebra.Polynomial.BigOperators
import Mathlib.Algebra.Polynomial.Lifts
import Mathlib.Algebra.Polynomial.Splits
import Mathlib.RingTheory.RootsOfUnity.Complex
import Mathlib.NumberTheory.ArithmeticFunction
import Mathlib.RingTheory.RootsOfUnity.Basic
import Mathlib.FieldTheory.RatFunc.AsPolynomial
#align_import ring_theory.polynomial.cyclotomic.basic from "leanprover-community/mathlib"@"7fdeecc0d03cd40f7a165e6cf00a4d2286db599f"
/-!
# Cyclotomic polynomials.
For `n : ℕ` and an integral domain `R`, we define a modified version of the `n`-th cyclotomic
polynomial with coefficients in `R`, denoted `cyclotomic' n R`, as `∏ (X - μ)`, where `μ` varies
over the primitive `n`th roots of unity. If there is a primitive `n`th root of unity in `R` then
this the standard definition. We then define the standard cyclotomic polynomial `cyclotomic n R`
with coefficients in any ring `R`.
## Main definition
* `cyclotomic n R` : the `n`-th cyclotomic polynomial with coefficients in `R`.
## Main results
* `Polynomial.degree_cyclotomic` : The degree of `cyclotomic n` is `totient n`.
* `Polynomial.prod_cyclotomic_eq_X_pow_sub_one` : `X ^ n - 1 = ∏ (cyclotomic i)`, where `i`
divides `n`.
* `Polynomial.cyclotomic_eq_prod_X_pow_sub_one_pow_moebius` : The Möbius inversion formula for
`cyclotomic n R` over an abstract fraction field for `R[X]`.
## Implementation details
Our definition of `cyclotomic' n R` makes sense in any integral domain `R`, but the interesting
results hold if there is a primitive `n`-th root of unity in `R`. In particular, our definition is
not the standard one unless there is a primitive `n`th root of unity in `R`. For example,
`cyclotomic' 3 ℤ = 1`, since there are no primitive cube roots of unity in `ℤ`. The main example is
`R = ℂ`, we decided to work in general since the difficulties are essentially the same.
To get the standard cyclotomic polynomials, we use `unique_int_coeff_of_cycl`, with `R = ℂ`,
to get a polynomial with integer coefficients and then we map it to `R[X]`, for any ring `R`.
-/
open scoped Polynomial
noncomputable section
universe u
namespace Polynomial
section Cyclotomic'
section IsDomain
variable {R : Type*} [CommRing R] [IsDomain R]
/-- The modified `n`-th cyclotomic polynomial with coefficients in `R`, it is the usual cyclotomic
polynomial if there is a primitive `n`-th root of unity in `R`. -/
def cyclotomic' (n : ℕ) (R : Type*) [CommRing R] [IsDomain R] : R[X] :=
∏ μ ∈ primitiveRoots n R, (X - C μ)
#align polynomial.cyclotomic' Polynomial.cyclotomic'
/-- The zeroth modified cyclotomic polyomial is `1`. -/
@[simp]
theorem cyclotomic'_zero (R : Type*) [CommRing R] [IsDomain R] : cyclotomic' 0 R = 1 := by
simp only [cyclotomic', Finset.prod_empty, primitiveRoots_zero]
#align polynomial.cyclotomic'_zero Polynomial.cyclotomic'_zero
/-- The first modified cyclotomic polyomial is `X - 1`. -/
@[simp]
theorem cyclotomic'_one (R : Type*) [CommRing R] [IsDomain R] : cyclotomic' 1 R = X - 1 := by
simp only [cyclotomic', Finset.prod_singleton, RingHom.map_one,
IsPrimitiveRoot.primitiveRoots_one]
#align polynomial.cyclotomic'_one Polynomial.cyclotomic'_one
/-- The second modified cyclotomic polyomial is `X + 1` if the characteristic of `R` is not `2`. -/
@[simp]
| Mathlib/RingTheory/Polynomial/Cyclotomic/Basic.lean | 85 | 91 | theorem cyclotomic'_two (R : Type*) [CommRing R] [IsDomain R] (p : ℕ) [CharP R p] (hp : p ≠ 2) :
cyclotomic' 2 R = X + 1 := by |
rw [cyclotomic']
have prim_root_two : primitiveRoots 2 R = {(-1 : R)} := by
simp only [Finset.eq_singleton_iff_unique_mem, mem_primitiveRoots two_pos]
exact ⟨IsPrimitiveRoot.neg_one p hp, fun x => IsPrimitiveRoot.eq_neg_one_of_two_right⟩
simp only [prim_root_two, Finset.prod_singleton, RingHom.map_neg, RingHom.map_one, sub_neg_eq_add]
|
/-
Copyright (c) 2019 Reid Barton. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
import Mathlib.Topology.Constructions
import Mathlib.Topology.Algebra.Monoid
import Mathlib.Order.Filter.ListTraverse
import Mathlib.Tactic.AdaptationNote
#align_import topology.list from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Topology on lists and vectors
-/
open TopologicalSpace Set Filter
open Topology Filter
variable {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β]
instance : TopologicalSpace (List α) :=
TopologicalSpace.mkOfNhds (traverse nhds)
theorem nhds_list (as : List α) : 𝓝 as = traverse 𝓝 as := by
refine nhds_mkOfNhds _ _ ?_ ?_
· intro l
induction l with
| nil => exact le_rfl
| cons a l ih =>
suffices List.cons <$> pure a <*> pure l ≤ List.cons <$> 𝓝 a <*> traverse 𝓝 l by
simpa only [functor_norm] using this
exact Filter.seq_mono (Filter.map_mono <| pure_le_nhds a) ih
· intro l s hs
rcases (mem_traverse_iff _ _).1 hs with ⟨u, hu, hus⟩
clear as hs
have : ∃ v : List (Set α), l.Forall₂ (fun a s => IsOpen s ∧ a ∈ s) v ∧ sequence v ⊆ s := by
induction hu generalizing s with
| nil =>
exists []
simp only [List.forall₂_nil_left_iff, exists_eq_left]
exact ⟨trivial, hus⟩
-- porting note -- renamed reordered variables based on previous types
| cons ht _ ih =>
rcases mem_nhds_iff.1 ht with ⟨u, hut, hu⟩
rcases ih _ Subset.rfl with ⟨v, hv, hvss⟩
exact
⟨u::v, List.Forall₂.cons hu hv,
Subset.trans (Set.seq_mono (Set.image_subset _ hut) hvss) hus⟩
rcases this with ⟨v, hv, hvs⟩
have : sequence v ∈ traverse 𝓝 l :=
mem_traverse _ _ <| hv.imp fun a s ⟨hs, ha⟩ => IsOpen.mem_nhds hs ha
refine mem_of_superset this fun u hu ↦ ?_
have hu := (List.mem_traverse _ _).1 hu
have : List.Forall₂ (fun a s => IsOpen s ∧ a ∈ s) u v := by
refine List.Forall₂.flip ?_
replace hv := hv.flip
#adaptation_note /-- nightly-2024-03-16: simp was
simp only [List.forall₂_and_left, flip] at hv ⊢ -/
simp only [List.forall₂_and_left, Function.flip_def] at hv ⊢
exact ⟨hv.1, hu.flip⟩
refine mem_of_superset ?_ hvs
exact mem_traverse _ _ (this.imp fun a s ⟨hs, ha⟩ => IsOpen.mem_nhds hs ha)
#align nhds_list nhds_list
@[simp]
theorem nhds_nil : 𝓝 ([] : List α) = pure [] := by
rw [nhds_list, List.traverse_nil _]
#align nhds_nil nhds_nil
theorem nhds_cons (a : α) (l : List α) : 𝓝 (a::l) = List.cons <$> 𝓝 a <*> 𝓝 l := by
rw [nhds_list, List.traverse_cons _, ← nhds_list]
#align nhds_cons nhds_cons
theorem List.tendsto_cons {a : α} {l : List α} :
Tendsto (fun p : α × List α => List.cons p.1 p.2) (𝓝 a ×ˢ 𝓝 l) (𝓝 (a::l)) := by
rw [nhds_cons, Tendsto, Filter.map_prod]; exact le_rfl
#align list.tendsto_cons List.tendsto_cons
theorem Filter.Tendsto.cons {α : Type*} {f : α → β} {g : α → List β} {a : Filter α} {b : β}
{l : List β} (hf : Tendsto f a (𝓝 b)) (hg : Tendsto g a (𝓝 l)) :
Tendsto (fun a => List.cons (f a) (g a)) a (𝓝 (b::l)) :=
List.tendsto_cons.comp (Tendsto.prod_mk hf hg)
#align filter.tendsto.cons Filter.Tendsto.cons
namespace List
| Mathlib/Topology/List.lean | 91 | 97 | theorem tendsto_cons_iff {β : Type*} {f : List α → β} {b : Filter β} {a : α} {l : List α} :
Tendsto f (𝓝 (a::l)) b ↔ Tendsto (fun p : α × List α => f (p.1::p.2)) (𝓝 a ×ˢ 𝓝 l) b := by |
have : 𝓝 (a::l) = (𝓝 a ×ˢ 𝓝 l).map fun p : α × List α => p.1::p.2 := by
simp only [nhds_cons, Filter.prod_eq, (Filter.map_def _ _).symm,
(Filter.seq_eq_filter_seq _ _).symm]
simp [-Filter.map_def, (· ∘ ·), functor_norm]
rw [this, Filter.tendsto_map'_iff]; rfl
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel,
Rémy Degenne, David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Real
#align_import analysis.special_functions.pow.nnreal from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8"
/-!
# Power function on `ℝ≥0` and `ℝ≥0∞`
We construct the power functions `x ^ y` where
* `x` is a nonnegative real number and `y` is a real number;
* `x` is a number from `[0, +∞]` (a.k.a. `ℝ≥0∞`) and `y` is a real number.
We also prove basic properties of these functions.
-/
noncomputable section
open scoped Classical
open Real NNReal ENNReal ComplexConjugate
open Finset Function Set
namespace NNReal
variable {w x y z : ℝ}
/-- The nonnegative real power function `x^y`, defined for `x : ℝ≥0` and `y : ℝ` as the
restriction of the real power function. For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`,
one sets `0 ^ 0 = 1` and `0 ^ y = 0` for `y ≠ 0`. -/
noncomputable def rpow (x : ℝ≥0) (y : ℝ) : ℝ≥0 :=
⟨(x : ℝ) ^ y, Real.rpow_nonneg x.2 y⟩
#align nnreal.rpow NNReal.rpow
noncomputable instance : Pow ℝ≥0 ℝ :=
⟨rpow⟩
@[simp]
theorem rpow_eq_pow (x : ℝ≥0) (y : ℝ) : rpow x y = x ^ y :=
rfl
#align nnreal.rpow_eq_pow NNReal.rpow_eq_pow
@[simp, norm_cast]
theorem coe_rpow (x : ℝ≥0) (y : ℝ) : ((x ^ y : ℝ≥0) : ℝ) = (x : ℝ) ^ y :=
rfl
#align nnreal.coe_rpow NNReal.coe_rpow
@[simp]
theorem rpow_zero (x : ℝ≥0) : x ^ (0 : ℝ) = 1 :=
NNReal.eq <| Real.rpow_zero _
#align nnreal.rpow_zero NNReal.rpow_zero
@[simp]
theorem rpow_eq_zero_iff {x : ℝ≥0} {y : ℝ} : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by
rw [← NNReal.coe_inj, coe_rpow, ← NNReal.coe_eq_zero]
exact Real.rpow_eq_zero_iff_of_nonneg x.2
#align nnreal.rpow_eq_zero_iff NNReal.rpow_eq_zero_iff
@[simp]
theorem zero_rpow {x : ℝ} (h : x ≠ 0) : (0 : ℝ≥0) ^ x = 0 :=
NNReal.eq <| Real.zero_rpow h
#align nnreal.zero_rpow NNReal.zero_rpow
@[simp]
theorem rpow_one (x : ℝ≥0) : x ^ (1 : ℝ) = x :=
NNReal.eq <| Real.rpow_one _
#align nnreal.rpow_one NNReal.rpow_one
@[simp]
theorem one_rpow (x : ℝ) : (1 : ℝ≥0) ^ x = 1 :=
NNReal.eq <| Real.one_rpow _
#align nnreal.one_rpow NNReal.one_rpow
theorem rpow_add {x : ℝ≥0} (hx : x ≠ 0) (y z : ℝ) : x ^ (y + z) = x ^ y * x ^ z :=
NNReal.eq <| Real.rpow_add (pos_iff_ne_zero.2 hx) _ _
#align nnreal.rpow_add NNReal.rpow_add
theorem rpow_add' (x : ℝ≥0) {y z : ℝ} (h : y + z ≠ 0) : x ^ (y + z) = x ^ y * x ^ z :=
NNReal.eq <| Real.rpow_add' x.2 h
#align nnreal.rpow_add' NNReal.rpow_add'
/-- Variant of `NNReal.rpow_add'` that avoids having to prove `y + z = w` twice. -/
lemma rpow_of_add_eq (x : ℝ≥0) (hw : w ≠ 0) (h : y + z = w) : x ^ w = x ^ y * x ^ z := by
rw [← h, rpow_add']; rwa [h]
theorem rpow_mul (x : ℝ≥0) (y z : ℝ) : x ^ (y * z) = (x ^ y) ^ z :=
NNReal.eq <| Real.rpow_mul x.2 y z
#align nnreal.rpow_mul NNReal.rpow_mul
theorem rpow_neg (x : ℝ≥0) (y : ℝ) : x ^ (-y) = (x ^ y)⁻¹ :=
NNReal.eq <| Real.rpow_neg x.2 _
#align nnreal.rpow_neg NNReal.rpow_neg
| Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean | 97 | 97 | theorem rpow_neg_one (x : ℝ≥0) : x ^ (-1 : ℝ) = x⁻¹ := by | simp [rpow_neg]
|
/-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Analysis.SpecialFunctions.Bernstein
import Mathlib.Topology.Algebra.Algebra
#align_import topology.continuous_function.weierstrass from "leanprover-community/mathlib"@"17ef379e997badd73e5eabb4d38f11919ab3c4b3"
/-!
# The Weierstrass approximation theorem for continuous functions on `[a,b]`
We've already proved the Weierstrass approximation theorem
in the sense that we've shown that the Bernstein approximations
to a continuous function on `[0,1]` converge uniformly.
Here we rephrase this more abstractly as
`polynomialFunctions_closure_eq_top' : (polynomialFunctions I).topologicalClosure = ⊤`
and then, by precomposing with suitable affine functions,
`polynomialFunctions_closure_eq_top : (polynomialFunctions (Set.Icc a b)).topologicalClosure = ⊤`
-/
open ContinuousMap Filter
open scoped unitInterval
/-- The special case of the Weierstrass approximation theorem for the interval `[0,1]`.
This is just a matter of unravelling definitions and using the Bernstein approximations.
-/
theorem polynomialFunctions_closure_eq_top' : (polynomialFunctions I).topologicalClosure = ⊤ := by
rw [eq_top_iff]
rintro f -
refine Filter.Frequently.mem_closure ?_
refine Filter.Tendsto.frequently (bernsteinApproximation_uniform f) ?_
apply frequently_of_forall
intro n
simp only [SetLike.mem_coe]
apply Subalgebra.sum_mem
rintro n -
apply Subalgebra.smul_mem
dsimp [bernstein, polynomialFunctions]
simp
#align polynomial_functions_closure_eq_top' polynomialFunctions_closure_eq_top'
/-- The **Weierstrass Approximation Theorem**:
polynomials functions on `[a, b] ⊆ ℝ` are dense in `C([a,b],ℝ)`
(While we could deduce this as an application of the Stone-Weierstrass theorem,
our proof of that relies on the fact that `abs` is in the closure of polynomials on `[-M, M]`,
so we may as well get this done first.)
-/
| Mathlib/Topology/ContinuousFunction/Weierstrass.lean | 54 | 79 | theorem polynomialFunctions_closure_eq_top (a b : ℝ) :
(polynomialFunctions (Set.Icc a b)).topologicalClosure = ⊤ := by |
cases' lt_or_le a b with h h
-- (Otherwise it's easy; we'll deal with that later.)
· -- We can pullback continuous functions on `[a,b]` to continuous functions on `[0,1]`,
-- by precomposing with an affine map.
let W : C(Set.Icc a b, ℝ) →ₐ[ℝ] C(I, ℝ) :=
compRightAlgHom ℝ ℝ (iccHomeoI a b h).symm.toContinuousMap
-- This operation is itself a homeomorphism
-- (with respect to the norm topologies on continuous functions).
let W' : C(Set.Icc a b, ℝ) ≃ₜ C(I, ℝ) := compRightHomeomorph ℝ (iccHomeoI a b h).symm
have w : (W : C(Set.Icc a b, ℝ) → C(I, ℝ)) = W' := rfl
-- Thus we take the statement of the Weierstrass approximation theorem for `[0,1]`,
have p := polynomialFunctions_closure_eq_top'
-- and pullback both sides, obtaining an equation between subalgebras of `C([a,b], ℝ)`.
apply_fun fun s => s.comap W at p
simp only [Algebra.comap_top] at p
-- Since the pullback operation is continuous, it commutes with taking `topologicalClosure`,
rw [Subalgebra.topologicalClosure_comap_homeomorph _ W W' w] at p
-- and precomposing with an affine map takes polynomial functions to polynomial functions.
rw [polynomialFunctions.comap_compRightAlgHom_iccHomeoI] at p
-- 🎉
exact p
· -- Otherwise, `b ≤ a`, and the interval is a subsingleton,
have : Subsingleton (Set.Icc a b) := (Set.subsingleton_Icc_of_ge h).coe_sort
apply Subsingleton.elim
|
/-
Copyright (c) 2021 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn
-/
import Mathlib.Algebra.Group.Equiv.Basic
import Mathlib.Algebra.Ring.Basic
import Mathlib.Algebra.Order.Sub.Defs
import Mathlib.Order.Hom.Basic
#align_import algebra.order.sub.basic from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1"
/-!
# Additional results about ordered Subtraction
-/
variable {α β : Type*}
section Add
variable [Preorder α] [Add α] [Sub α] [OrderedSub α] {a b c d : α}
theorem AddHom.le_map_tsub [Preorder β] [Add β] [Sub β] [OrderedSub β] (f : AddHom α β)
(hf : Monotone f) (a b : α) : f a - f b ≤ f (a - b) := by
rw [tsub_le_iff_right, ← f.map_add]
exact hf le_tsub_add
#align add_hom.le_map_tsub AddHom.le_map_tsub
theorem le_mul_tsub {R : Type*} [Distrib R] [Preorder R] [Sub R] [OrderedSub R]
[CovariantClass R R (· * ·) (· ≤ ·)] {a b c : R} : a * b - a * c ≤ a * (b - c) :=
(AddHom.mulLeft a).le_map_tsub (monotone_id.const_mul' a) _ _
#align le_mul_tsub le_mul_tsub
| Mathlib/Algebra/Order/Sub/Basic.lean | 36 | 38 | theorem le_tsub_mul {R : Type*} [CommSemiring R] [Preorder R] [Sub R] [OrderedSub R]
[CovariantClass R R (· * ·) (· ≤ ·)] {a b c : R} : a * c - b * c ≤ (a - b) * c := by |
simpa only [mul_comm _ c] using le_mul_tsub
|
/-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Algebra.Homology.Linear
import Mathlib.Algebra.Homology.ShortComplex.HomologicalComplex
import Mathlib.Tactic.Abel
#align_import algebra.homology.homotopy from "leanprover-community/mathlib"@"618ea3d5c99240cd7000d8376924906a148bf9ff"
/-!
# Chain homotopies
We define chain homotopies, and prove that homotopic chain maps induce the same map on homology.
-/
universe v u
open scoped Classical
noncomputable section
open CategoryTheory Category Limits HomologicalComplex
variable {ι : Type*}
variable {V : Type u} [Category.{v} V] [Preadditive V]
variable {c : ComplexShape ι} {C D E : HomologicalComplex V c}
variable (f g : C ⟶ D) (h k : D ⟶ E) (i : ι)
section
/-- The composition of `C.d i (c.next i) ≫ f (c.next i) i`. -/
def dNext (i : ι) : (∀ i j, C.X i ⟶ D.X j) →+ (C.X i ⟶ D.X i) :=
AddMonoidHom.mk' (fun f => C.d i (c.next i) ≫ f (c.next i) i) fun _ _ =>
Preadditive.comp_add _ _ _ _ _ _
#align d_next dNext
/-- `f (c.next i) i`. -/
def fromNext (i : ι) : (∀ i j, C.X i ⟶ D.X j) →+ (C.xNext i ⟶ D.X i) :=
AddMonoidHom.mk' (fun f => f (c.next i) i) fun _ _ => rfl
#align from_next fromNext
@[simp]
theorem dNext_eq_dFrom_fromNext (f : ∀ i j, C.X i ⟶ D.X j) (i : ι) :
dNext i f = C.dFrom i ≫ fromNext i f :=
rfl
#align d_next_eq_d_from_from_next dNext_eq_dFrom_fromNext
theorem dNext_eq (f : ∀ i j, C.X i ⟶ D.X j) {i i' : ι} (w : c.Rel i i') :
dNext i f = C.d i i' ≫ f i' i := by
obtain rfl := c.next_eq' w
rfl
#align d_next_eq dNext_eq
lemma dNext_eq_zero (f : ∀ i j, C.X i ⟶ D.X j) (i : ι) (hi : ¬ c.Rel i (c.next i)) :
dNext i f = 0 := by
dsimp [dNext]
rw [shape _ _ _ hi, zero_comp]
@[simp 1100]
theorem dNext_comp_left (f : C ⟶ D) (g : ∀ i j, D.X i ⟶ E.X j) (i : ι) :
(dNext i fun i j => f.f i ≫ g i j) = f.f i ≫ dNext i g :=
(f.comm_assoc _ _ _).symm
#align d_next_comp_left dNext_comp_left
@[simp 1100]
theorem dNext_comp_right (f : ∀ i j, C.X i ⟶ D.X j) (g : D ⟶ E) (i : ι) :
(dNext i fun i j => f i j ≫ g.f j) = dNext i f ≫ g.f i :=
(assoc _ _ _).symm
#align d_next_comp_right dNext_comp_right
/-- The composition `f j (c.prev j) ≫ D.d (c.prev j) j`. -/
def prevD (j : ι) : (∀ i j, C.X i ⟶ D.X j) →+ (C.X j ⟶ D.X j) :=
AddMonoidHom.mk' (fun f => f j (c.prev j) ≫ D.d (c.prev j) j) fun _ _ =>
Preadditive.add_comp _ _ _ _ _ _
#align prev_d prevD
lemma prevD_eq_zero (f : ∀ i j, C.X i ⟶ D.X j) (i : ι) (hi : ¬ c.Rel (c.prev i) i) :
prevD i f = 0 := by
dsimp [prevD]
rw [shape _ _ _ hi, comp_zero]
/-- `f j (c.prev j)`. -/
def toPrev (j : ι) : (∀ i j, C.X i ⟶ D.X j) →+ (C.X j ⟶ D.xPrev j) :=
AddMonoidHom.mk' (fun f => f j (c.prev j)) fun _ _ => rfl
#align to_prev toPrev
@[simp]
theorem prevD_eq_toPrev_dTo (f : ∀ i j, C.X i ⟶ D.X j) (j : ι) :
prevD j f = toPrev j f ≫ D.dTo j :=
rfl
#align prev_d_eq_to_prev_d_to prevD_eq_toPrev_dTo
theorem prevD_eq (f : ∀ i j, C.X i ⟶ D.X j) {j j' : ι} (w : c.Rel j' j) :
prevD j f = f j j' ≫ D.d j' j := by
obtain rfl := c.prev_eq' w
rfl
#align prev_d_eq prevD_eq
@[simp 1100]
theorem prevD_comp_left (f : C ⟶ D) (g : ∀ i j, D.X i ⟶ E.X j) (j : ι) :
(prevD j fun i j => f.f i ≫ g i j) = f.f j ≫ prevD j g :=
assoc _ _ _
#align prev_d_comp_left prevD_comp_left
@[simp 1100]
| Mathlib/Algebra/Homology/Homotopy.lean | 109 | 112 | theorem prevD_comp_right (f : ∀ i j, C.X i ⟶ D.X j) (g : D ⟶ E) (j : ι) :
(prevD j fun i j => f i j ≫ g.f j) = prevD j f ≫ g.f j := by |
dsimp [prevD]
simp only [assoc, g.comm]
|
/-
Copyright (c) 2022 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers
-/
import Mathlib.Analysis.Convex.Between
import Mathlib.Analysis.Convex.Normed
import Mathlib.Analysis.Normed.Group.AddTorsor
#align_import analysis.convex.side from "leanprover-community/mathlib"@"a63928c34ec358b5edcda2bf7513c50052a5230f"
/-!
# Sides of affine subspaces
This file defines notions of two points being on the same or opposite sides of an affine subspace.
## Main definitions
* `s.WSameSide x y`: The points `x` and `y` are weakly on the same side of the affine
subspace `s`.
* `s.SSameSide x y`: The points `x` and `y` are strictly on the same side of the affine
subspace `s`.
* `s.WOppSide x y`: The points `x` and `y` are weakly on opposite sides of the affine
subspace `s`.
* `s.SOppSide x y`: The points `x` and `y` are strictly on opposite sides of the affine
subspace `s`.
-/
variable {R V V' P P' : Type*}
open AffineEquiv AffineMap
namespace AffineSubspace
section StrictOrderedCommRing
variable [StrictOrderedCommRing R] [AddCommGroup V] [Module R V] [AddTorsor V P]
variable [AddCommGroup V'] [Module R V'] [AddTorsor V' P']
/-- The points `x` and `y` are weakly on the same side of `s`. -/
def WSameSide (s : AffineSubspace R P) (x y : P) : Prop :=
∃ᵉ (p₁ ∈ s) (p₂ ∈ s), SameRay R (x -ᵥ p₁) (y -ᵥ p₂)
#align affine_subspace.w_same_side AffineSubspace.WSameSide
/-- The points `x` and `y` are strictly on the same side of `s`. -/
def SSameSide (s : AffineSubspace R P) (x y : P) : Prop :=
s.WSameSide x y ∧ x ∉ s ∧ y ∉ s
#align affine_subspace.s_same_side AffineSubspace.SSameSide
/-- The points `x` and `y` are weakly on opposite sides of `s`. -/
def WOppSide (s : AffineSubspace R P) (x y : P) : Prop :=
∃ᵉ (p₁ ∈ s) (p₂ ∈ s), SameRay R (x -ᵥ p₁) (p₂ -ᵥ y)
#align affine_subspace.w_opp_side AffineSubspace.WOppSide
/-- The points `x` and `y` are strictly on opposite sides of `s`. -/
def SOppSide (s : AffineSubspace R P) (x y : P) : Prop :=
s.WOppSide x y ∧ x ∉ s ∧ y ∉ s
#align affine_subspace.s_opp_side AffineSubspace.SOppSide
theorem WSameSide.map {s : AffineSubspace R P} {x y : P} (h : s.WSameSide x y) (f : P →ᵃ[R] P') :
(s.map f).WSameSide (f x) (f y) := by
rcases h with ⟨p₁, hp₁, p₂, hp₂, h⟩
refine ⟨f p₁, mem_map_of_mem f hp₁, f p₂, mem_map_of_mem f hp₂, ?_⟩
simp_rw [← linearMap_vsub]
exact h.map f.linear
#align affine_subspace.w_same_side.map AffineSubspace.WSameSide.map
| Mathlib/Analysis/Convex/Side.lean | 70 | 80 | theorem _root_.Function.Injective.wSameSide_map_iff {s : AffineSubspace R P} {x y : P}
{f : P →ᵃ[R] P'} (hf : Function.Injective f) :
(s.map f).WSameSide (f x) (f y) ↔ s.WSameSide x y := by |
refine ⟨fun h => ?_, fun h => h.map _⟩
rcases h with ⟨fp₁, hfp₁, fp₂, hfp₂, h⟩
rw [mem_map] at hfp₁ hfp₂
rcases hfp₁ with ⟨p₁, hp₁, rfl⟩
rcases hfp₂ with ⟨p₂, hp₂, rfl⟩
refine ⟨p₁, hp₁, p₂, hp₂, ?_⟩
simp_rw [← linearMap_vsub, (f.linear_injective_iff.2 hf).sameRay_map_iff] at h
exact h
|
/-
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, Yury Kudryashov
-/
import Mathlib.MeasureTheory.Constructions.BorelSpace.Order
#align_import measure_theory.constructions.borel_space.basic from "leanprover-community/mathlib"@"9f55d0d4363ae59948c33864cbc52e0b12e0e8ce"
/-!
# Borel (measurable) spaces ℝ, ℝ≥0, ℝ≥0∞
## Main statements
* `borel_eq_generateFrom_Ixx_rat` (where Ixx is one of {Ioo, Ioi, Iio, Ici, Iic):
the Borel sigma algebra on ℝ is generated by intervals with rational endpoints;
* `isPiSystem_Ixx_rat` (where Ixx is one of {Ioo, Ioi, Iio, Ici, Iic):
intervals with rational endpoints form a pi system on ℝ;
* `measurable_real_toNNReal`, `measurable_coe_nnreal_real`, `measurable_coe_nnreal_ennreal`,
`ENNReal.measurable_ofReal`, `ENNReal.measurable_toReal`:
measurability of various coercions between ℝ, ℝ≥0, and ℝ≥0∞;
* `Measurable.real_toNNReal`, `Measurable.coe_nnreal_real`, `Measurable.coe_nnreal_ennreal`,
`Measurable.ennreal_ofReal`, `Measurable.ennreal_toNNReal`, `Measurable.ennreal_toReal`:
measurability of functions composed with various coercions between ℝ, ℝ≥0, and ℝ≥0∞
(also similar results for a.e.-measurability);
* `Measurable.ennreal*` : measurability of special cases for arithmetic operations on `ℝ≥0∞`.
-/
open Set Filter MeasureTheory MeasurableSpace
open scoped Classical Topology NNReal ENNReal MeasureTheory
universe u v w x y
variable {α β γ δ : Type*} {ι : Sort y} {s t u : Set α}
namespace Real
theorem borel_eq_generateFrom_Ioo_rat :
borel ℝ = .generateFrom (⋃ (a : ℚ) (b : ℚ) (_ : a < b), {Ioo (a : ℝ) (b : ℝ)}) :=
isTopologicalBasis_Ioo_rat.borel_eq_generateFrom
#align real.borel_eq_generate_from_Ioo_rat Real.borel_eq_generateFrom_Ioo_rat
theorem borel_eq_generateFrom_Iio_rat : borel ℝ = .generateFrom (⋃ a : ℚ, {Iio (a : ℝ)}) := by
rw [borel_eq_generateFrom_Iio]
refine le_antisymm
(generateFrom_le ?_)
(generateFrom_mono <| iUnion_subset fun q ↦ singleton_subset_iff.mpr <| mem_range_self _)
rintro _ ⟨a, rfl⟩
have : IsLUB (range ((↑) : ℚ → ℝ) ∩ Iio a) a := by
simp [isLUB_iff_le_iff, mem_upperBounds, ← le_iff_forall_rat_lt_imp_le]
rw [← this.biUnion_Iio_eq, ← image_univ, ← image_inter_preimage, univ_inter, biUnion_image]
exact MeasurableSet.biUnion (to_countable _)
fun b _ => GenerateMeasurable.basic (Iio (b : ℝ)) (by simp)
theorem borel_eq_generateFrom_Ioi_rat : borel ℝ = .generateFrom (⋃ a : ℚ, {Ioi (a : ℝ)}) := by
rw [borel_eq_generateFrom_Ioi]
refine le_antisymm
(generateFrom_le ?_)
(generateFrom_mono <| iUnion_subset fun q ↦ singleton_subset_iff.mpr <| mem_range_self _)
rintro _ ⟨a, rfl⟩
have : IsGLB (range ((↑) : ℚ → ℝ) ∩ Ioi a) a := by
simp [isGLB_iff_le_iff, mem_lowerBounds, ← le_iff_forall_lt_rat_imp_le]
rw [← this.biUnion_Ioi_eq, ← image_univ, ← image_inter_preimage, univ_inter, biUnion_image]
exact MeasurableSet.biUnion (to_countable _)
fun b _ => GenerateMeasurable.basic (Ioi (b : ℝ)) (by simp)
theorem borel_eq_generateFrom_Iic_rat : borel ℝ = .generateFrom (⋃ a : ℚ, {Iic (a : ℝ)}) := by
rw [borel_eq_generateFrom_Ioi_rat, iUnion_singleton_eq_range, iUnion_singleton_eq_range]
refine le_antisymm (generateFrom_le ?_) (generateFrom_le ?_) <;>
rintro _ ⟨q, rfl⟩ <;>
dsimp only <;>
[rw [← compl_Iic]; rw [← compl_Ioi]] <;>
exact MeasurableSet.compl (GenerateMeasurable.basic _ (mem_range_self q))
theorem borel_eq_generateFrom_Ici_rat : borel ℝ = .generateFrom (⋃ a : ℚ, {Ici (a : ℝ)}) := by
rw [borel_eq_generateFrom_Iio_rat, iUnion_singleton_eq_range, iUnion_singleton_eq_range]
refine le_antisymm (generateFrom_le ?_) (generateFrom_le ?_) <;>
rintro _ ⟨q, rfl⟩ <;>
dsimp only <;>
[rw [← compl_Ici]; rw [← compl_Iio]] <;>
exact MeasurableSet.compl (GenerateMeasurable.basic _ (mem_range_self q))
theorem isPiSystem_Ioo_rat :
IsPiSystem (⋃ (a : ℚ) (b : ℚ) (_ : a < b), {Ioo (a : ℝ) (b : ℝ)}) := by
convert isPiSystem_Ioo ((↑) : ℚ → ℝ) ((↑) : ℚ → ℝ)
ext x
simp [eq_comm]
#align real.is_pi_system_Ioo_rat Real.isPiSystem_Ioo_rat
| Mathlib/MeasureTheory/Constructions/BorelSpace/Real.lean | 91 | 94 | theorem isPiSystem_Iio_rat : IsPiSystem (⋃ a : ℚ, {Iio (a : ℝ)}) := by |
convert isPiSystem_image_Iio (((↑) : ℚ → ℝ) '' univ)
ext x
simp only [iUnion_singleton_eq_range, mem_range, image_univ, mem_image, exists_exists_eq_and]
|
/-
Copyright (c) 2024 Jz Pan. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jz Pan
-/
import Mathlib.Algebra.Module.Submodule.Ker
/-!
# Iterate maps and comaps of submodules
Some preliminary work for establishing the strong rank condition for noetherian rings.
Given two linear maps `f i : N →ₗ[R] M` and a submodule `K : Submodule R N`, we can define
`LinearMap.iterateMapComap f i n K : Submodule R N` to be `f⁻¹(i(⋯(f⁻¹(i(K)))))` (`n` times).
If `f(K) ≤ i(K)`, then this sequence is non-decreasing (`LinearMap.iterateMapComap_le_succ`).
On the other hand, if `f` is surjective, `i` is injective, and there exists some `m` such that
`LinearMap.iterateMapComap f i m K = LinearMap.iterateMapComap f i (m + 1) K`,
then for any `n`,
`LinearMap.iterateMapComap f i n K = LinearMap.iterateMapComap f i (n + 1) K`.
In particular, by taking `n = 0`, the kernel of `f` is contained in `K`
(`LinearMap.ker_le_of_iterateMapComap_eq_succ`),
which is a consequence of `LinearMap.ker_le_comap`.
As a special case, if one can take `K` to be zero,
then `f` is injective. This is the key result for establishing the strong rank condition
for noetherian rings.
The construction here is adapted from the proof in Djoković's paper
*Epimorphisms of modules which must be isomorphisms* [djokovic1973].
-/
open Function Submodule
namespace LinearMap
variable {R N M : Type*} [Semiring R] [AddCommMonoid N] [Module R N]
[AddCommMonoid M] [Module R M] (f i : N →ₗ[R] M)
/-- The `LinearMap.iterateMapComap f i n K : Submodule R N` is
`f⁻¹(i(⋯(f⁻¹(i(K)))))` (`n` times). -/
def iterateMapComap (n : ℕ) := (fun K : Submodule R N ↦ (K.map i).comap f)^[n]
/-- If `f(K) ≤ i(K)`, then `LinearMap.iterateMapComap` is not decreasing. -/
theorem iterateMapComap_le_succ (K : Submodule R N) (h : K.map f ≤ K.map i) (n : ℕ) :
f.iterateMapComap i n K ≤ f.iterateMapComap i (n + 1) K := by
nth_rw 2 [iterateMapComap]
rw [iterate_succ', Function.comp_apply, ← iterateMapComap, ← map_le_iff_le_comap]
induction n with
| zero => exact h
| succ n ih =>
simp_rw [iterateMapComap, iterate_succ', Function.comp_apply]
calc
_ ≤ (f.iterateMapComap i n K).map i := map_comap_le _ _
_ ≤ (((f.iterateMapComap i n K).map f).comap f).map i := map_mono (le_comap_map _ _)
_ ≤ _ := map_mono (comap_mono ih)
/-- If `f` is surjective, `i` is injective, and there exists some `m` such that
`LinearMap.iterateMapComap f i m K = LinearMap.iterateMapComap f i (m + 1) K`,
then for any `n`,
`LinearMap.iterateMapComap f i n K = LinearMap.iterateMapComap f i (n + 1) K`.
In particular, by taking `n = 0`, the kernel of `f` is contained in `K`
(`LinearMap.ker_le_of_iterateMapComap_eq_succ`),
which is a consequence of `LinearMap.ker_le_comap`. -/
theorem iterateMapComap_eq_succ (K : Submodule R N)
(m : ℕ) (heq : f.iterateMapComap i m K = f.iterateMapComap i (m + 1) K)
(hf : Surjective f) (hi : Injective i) (n : ℕ) :
f.iterateMapComap i n K = f.iterateMapComap i (n + 1) K := by
induction n with
| zero =>
contrapose! heq
induction m with
| zero => exact heq
| succ m ih =>
rw [iterateMapComap, iterateMapComap, iterate_succ', iterate_succ']
exact fun H ↦ ih (map_injective_of_injective hi (comap_injective_of_surjective hf H))
| succ n ih =>
rw [iterateMapComap, iterateMapComap, iterate_succ', iterate_succ',
Function.comp_apply, Function.comp_apply, ← iterateMapComap, ← iterateMapComap, ih]
/-- If `f` is surjective, `i` is injective, and there exists some `m` such that
`LinearMap.iterateMapComap f i m K = LinearMap.iterateMapComap f i (m + 1) K`,
then the kernel of `f` is contained in `K`.
This is a corollary of `LinearMap.iterateMapComap_eq_succ` and `LinearMap.ker_le_comap`.
As a special case, if one can take `K` to be zero,
then `f` is injective. This is the key result for establishing the strong rank condition
for noetherian rings. -/
| Mathlib/Algebra/Module/Submodule/IterateMapComap.lean | 88 | 92 | theorem ker_le_of_iterateMapComap_eq_succ (K : Submodule R N)
(m : ℕ) (heq : f.iterateMapComap i m K = f.iterateMapComap i (m + 1) K)
(hf : Surjective f) (hi : Injective i) : LinearMap.ker f ≤ K := by |
rw [show K = _ from f.iterateMapComap_eq_succ i K m heq hf hi 0]
exact f.ker_le_comap
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov
-/
import Mathlib.Topology.Order.IsLUB
/-!
# Order topology on a densely ordered set
-/
open Set Filter TopologicalSpace Topology Function
open OrderDual (toDual ofDual)
variable {α β γ : Type*}
section DenselyOrdered
variable [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [DenselyOrdered α] {a b : α}
{s : Set α}
/-- The closure of the interval `(a, +∞)` is the closed interval `[a, +∞)`, unless `a` is a top
element. -/
| Mathlib/Topology/Order/DenselyOrdered.lean | 25 | 29 | theorem closure_Ioi' {a : α} (h : (Ioi a).Nonempty) : closure (Ioi a) = Ici a := by |
apply Subset.antisymm
· exact closure_minimal Ioi_subset_Ici_self isClosed_Ici
· rw [← diff_subset_closure_iff, Ici_diff_Ioi_same, singleton_subset_iff]
exact isGLB_Ioi.mem_closure h
|
/-
Copyright (c) 2022 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.MeasureTheory.Covering.DensityTheorem
import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar
#align_import measure_theory.covering.one_dim from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
/-!
# Covering theorems for Lebesgue measure in one dimension
We have a general theory of covering theorems for doubling measures, developed notably
in `DensityTheorem.lean`. In this file, we expand the API for this theory in one dimension,
by showing that intervals belong to the relevant Vitali family.
-/
open Set MeasureTheory IsUnifLocDoublingMeasure Filter
open scoped Topology
namespace Real
| Mathlib/MeasureTheory/Covering/OneDim.lean | 26 | 30 | theorem Icc_mem_vitaliFamily_at_right {x y : ℝ} (hxy : x < y) :
Icc x y ∈ (vitaliFamily (volume : Measure ℝ) 1).setsAt x := by |
rw [Icc_eq_closedBall]
refine closedBall_mem_vitaliFamily_of_dist_le_mul _ ?_ (by linarith)
rw [dist_comm, Real.dist_eq, abs_of_nonneg] <;> linarith
|
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Init.Control.Combinators
import Mathlib.Data.Option.Defs
import Mathlib.Logic.IsEmpty
import Mathlib.Logic.Relator
import Mathlib.Util.CompileInductive
import Aesop
#align_import data.option.basic from "leanprover-community/mathlib"@"f340f229b1f461aa1c8ee11e0a172d0a3b301a4a"
/-!
# Option of a type
This file develops the basic theory of option types.
If `α` is a type, then `Option α` can be understood as the type with one more element than `α`.
`Option α` has terms `some a`, where `a : α`, and `none`, which is the added element.
This is useful in multiple ways:
* It is the prototype of addition of terms to a type. See for example `WithBot α` which uses
`none` as an element smaller than all others.
* It can be used to define failsafe partial functions, which return `some the_result_we_expect`
if we can find `the_result_we_expect`, and `none` if there is no meaningful result. This forces
any subsequent use of the partial function to explicitly deal with the exceptions that make it
return `none`.
* `Option` is a monad. We love monads.
`Part` is an alternative to `Option` that can be seen as the type of `True`/`False` values
along with a term `a : α` if the value is `True`.
-/
universe u
namespace Option
variable {α β γ δ : Type*}
theorem coe_def : (fun a ↦ ↑a : α → Option α) = some :=
rfl
#align option.coe_def Option.coe_def
theorem mem_map {f : α → β} {y : β} {o : Option α} : y ∈ o.map f ↔ ∃ x ∈ o, f x = y := by simp
#align option.mem_map Option.mem_map
-- The simpNF linter says that the LHS can be simplified via `Option.mem_def`.
-- However this is a higher priority lemma.
-- https://github.com/leanprover/std4/issues/207
@[simp 1100, nolint simpNF]
theorem mem_map_of_injective {f : α → β} (H : Function.Injective f) {a : α} {o : Option α} :
f a ∈ o.map f ↔ a ∈ o := by
aesop
theorem forall_mem_map {f : α → β} {o : Option α} {p : β → Prop} :
(∀ y ∈ o.map f, p y) ↔ ∀ x ∈ o, p (f x) := by simp
#align option.forall_mem_map Option.forall_mem_map
| Mathlib/Data/Option/Basic.lean | 61 | 62 | theorem exists_mem_map {f : α → β} {o : Option α} {p : β → Prop} :
(∃ y ∈ o.map f, p y) ↔ ∃ x ∈ o, p (f x) := by | simp
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import Mathlib.MeasureTheory.Measure.NullMeasurable
import Mathlib.MeasureTheory.MeasurableSpace.Basic
import Mathlib.Topology.Algebra.Order.LiminfLimsup
#align_import measure_theory.measure.measure_space from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55"
/-!
# Measure spaces
The definition of a measure and a measure space are in `MeasureTheory.MeasureSpaceDef`, with
only a few basic properties. This file provides many more properties of these objects.
This separation allows the measurability tactic to import only the file `MeasureSpaceDef`, and to
be available in `MeasureSpace` (through `MeasurableSpace`).
Given a measurable space `α`, a measure on `α` is a function that sends measurable sets to the
extended nonnegative reals that satisfies the following conditions:
1. `μ ∅ = 0`;
2. `μ` is countably additive. This means that the measure of a countable union of pairwise disjoint
sets is equal to the measure of the individual sets.
Every measure can be canonically extended to an outer measure, so that it assigns values to
all subsets, not just the measurable subsets. On the other hand, a measure that is countably
additive on measurable sets can be restricted to measurable sets to obtain a measure.
In this file a measure is defined to be an outer measure that is countably additive on
measurable sets, with the additional assumption that the outer measure is the canonical
extension of the restricted measure.
Measures on `α` form a complete lattice, and are closed under scalar multiplication with `ℝ≥0∞`.
Given a measure, the null sets are the sets where `μ s = 0`, where `μ` denotes the corresponding
outer measure (so `s` might not be measurable). We can then define the completion of `μ` as the
measure on the least `σ`-algebra that also contains all null sets, by defining the measure to be `0`
on the null sets.
## Main statements
* `completion` is the completion of a measure to all null measurable sets.
* `Measure.ofMeasurable` and `OuterMeasure.toMeasure` are two important ways to define a measure.
## Implementation notes
Given `μ : Measure α`, `μ s` is the value of the *outer measure* applied to `s`.
This conveniently allows us to apply the measure to sets without proving that they are measurable.
We get countable subadditivity for all sets, but only countable additivity for measurable sets.
You often don't want to define a measure via its constructor.
Two ways that are sometimes more convenient:
* `Measure.ofMeasurable` is a way to define a measure by only giving its value on measurable sets
and proving the properties (1) and (2) mentioned above.
* `OuterMeasure.toMeasure` is a way of obtaining a measure from an outer measure by showing that
all measurable sets in the measurable space are Carathéodory measurable.
To prove that two measures are equal, there are multiple options:
* `ext`: two measures are equal if they are equal on all measurable sets.
* `ext_of_generateFrom_of_iUnion`: two measures are equal if they are equal on a π-system generating
the measurable sets, if the π-system contains a spanning increasing sequence of sets where the
measures take finite value (in particular the measures are σ-finite). This is a special case of
the more general `ext_of_generateFrom_of_cover`
* `ext_of_generate_finite`: two finite measures are equal if they are equal on a π-system
generating the measurable sets. This is a special case of `ext_of_generateFrom_of_iUnion` using
`C ∪ {univ}`, but is easier to work with.
A `MeasureSpace` is a class that is a measurable space with a canonical measure.
The measure is denoted `volume`.
## References
* <https://en.wikipedia.org/wiki/Measure_(mathematics)>
* <https://en.wikipedia.org/wiki/Complete_measure>
* <https://en.wikipedia.org/wiki/Almost_everywhere>
## Tags
measure, almost everywhere, measure space, completion, null set, null measurable set
-/
noncomputable section
open Set
open Filter hiding map
open Function MeasurableSpace
open scoped Classical symmDiff
open Topology Filter ENNReal NNReal Interval MeasureTheory
variable {α β γ δ ι R R' : Type*}
namespace MeasureTheory
section
variable {m : MeasurableSpace α} {μ μ₁ μ₂ : Measure α} {s s₁ s₂ t : Set α}
instance ae_isMeasurablyGenerated : IsMeasurablyGenerated (ae μ) :=
⟨fun _s hs =>
let ⟨t, hst, htm, htμ⟩ := exists_measurable_superset_of_null hs
⟨tᶜ, compl_mem_ae_iff.2 htμ, htm.compl, compl_subset_comm.1 hst⟩⟩
#align measure_theory.ae_is_measurably_generated MeasureTheory.ae_isMeasurablyGenerated
/-- See also `MeasureTheory.ae_restrict_uIoc_iff`. -/
| Mathlib/MeasureTheory/Measure/MeasureSpace.lean | 107 | 109 | theorem ae_uIoc_iff [LinearOrder α] {a b : α} {P : α → Prop} :
(∀ᵐ x ∂μ, x ∈ Ι a b → P x) ↔ (∀ᵐ x ∂μ, x ∈ Ioc a b → P x) ∧ ∀ᵐ x ∂μ, x ∈ Ioc b a → P x := by |
simp only [uIoc_eq_union, mem_union, or_imp, eventually_and]
|
/-
Copyright (c) 2023 Luke Mantle. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Luke Mantle
-/
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Algebra.Polynomial.Derivative
import Mathlib.Data.Nat.Factorial.DoubleFactorial
#align_import ring_theory.polynomial.hermite.basic from "leanprover-community/mathlib"@"938d3db9c278f8a52c0f964a405806f0f2b09b74"
/-!
# Hermite polynomials
This file defines `Polynomial.hermite n`, the `n`th probabilists' Hermite polynomial.
## Main definitions
* `Polynomial.hermite n`: the `n`th probabilists' Hermite polynomial,
defined recursively as a `Polynomial ℤ`
## Results
* `Polynomial.hermite_succ`: the recursion `hermite (n+1) = (x - d/dx) (hermite n)`
* `Polynomial.coeff_hermite_explicit`: a closed formula for (nonvanishing) coefficients in terms
of binomial coefficients and double factorials.
* `Polynomial.coeff_hermite_of_odd_add`: for `n`,`k` where `n+k` is odd, `(hermite n).coeff k` is
zero.
* `Polynomial.coeff_hermite_of_even_add`: a closed formula for `(hermite n).coeff k` when `n+k` is
even, equivalent to `Polynomial.coeff_hermite_explicit`.
* `Polynomial.monic_hermite`: for all `n`, `hermite n` is monic.
* `Polynomial.degree_hermite`: for all `n`, `hermite n` has degree `n`.
## References
* [Hermite Polynomials](https://en.wikipedia.org/wiki/Hermite_polynomials)
-/
noncomputable section
open Polynomial
namespace Polynomial
/-- the probabilists' Hermite polynomials. -/
noncomputable def hermite : ℕ → Polynomial ℤ
| 0 => 1
| n + 1 => X * hermite n - derivative (hermite n)
#align polynomial.hermite Polynomial.hermite
/-- The recursion `hermite (n+1) = (x - d/dx) (hermite n)` -/
@[simp]
theorem hermite_succ (n : ℕ) : hermite (n + 1) = X * hermite n - derivative (hermite n) := by
rw [hermite]
#align polynomial.hermite_succ Polynomial.hermite_succ
| Mathlib/RingTheory/Polynomial/Hermite/Basic.lean | 59 | 62 | theorem hermite_eq_iterate (n : ℕ) : hermite n = (fun p => X * p - derivative p)^[n] 1 := by |
induction' n with n ih
· rfl
· rw [Function.iterate_succ_apply', ← ih, hermite_succ]
|
/-
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.Module.Defs
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Algebra.Order.Ring.Basic
import Mathlib.Combinatorics.SimpleGraph.Density
import Mathlib.Data.Rat.BigOperators
#align_import combinatorics.simple_graph.regularity.energy from "leanprover-community/mathlib"@"bf7ef0e83e5b7e6c1169e97f055e58a2e4e9d52d"
/-!
# Energy of a partition
This file defines the energy of a partition.
The energy is the auxiliary quantity that drives the induction process in the proof of Szemerédi's
Regularity Lemma. As long as we do not have a suitable equipartition, we will find a new one that
has an energy greater than the previous one plus some fixed constant.
## References
[Yaël Dillies, Bhavik Mehta, *Formalising Szemerédi’s Regularity Lemma in Lean*][srl_itp]
-/
open Finset
variable {α : Type*} [DecidableEq α] {s : Finset α} (P : Finpartition s) (G : SimpleGraph α)
[DecidableRel G.Adj]
namespace Finpartition
/-- The energy of a partition, also known as index. Auxiliary quantity for Szemerédi's regularity
lemma. -/
def energy : ℚ :=
((∑ uv ∈ P.parts.offDiag, G.edgeDensity uv.1 uv.2 ^ 2) : ℚ) / (P.parts.card : ℚ) ^ 2
#align finpartition.energy Finpartition.energy
| Mathlib/Combinatorics/SimpleGraph/Regularity/Energy.lean | 42 | 43 | theorem energy_nonneg : 0 ≤ P.energy G := by |
exact div_nonneg (Finset.sum_nonneg fun _ _ => sq_nonneg _) <| sq_nonneg _
|
/-
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, Alex J. Best
-/
import Mathlib.MeasureTheory.Group.Arithmetic
#align_import measure_theory.group.pointwise from "leanprover-community/mathlib"@"66f7114a1d5cba41c47d417a034bbb2e96cf564a"
/-!
# Pointwise set operations on `MeasurableSet`s
In this file we prove several versions of the following fact: if `s` is a measurable set, then so is
`a • s`. Note that the pointwise product of two measurable sets need not be measurable, so there is
no `MeasurableSet.mul` etc.
-/
open Pointwise
open Set
@[to_additive]
theorem MeasurableSet.const_smul {G α : Type*} [Group G] [MulAction G α] [MeasurableSpace G]
[MeasurableSpace α] [MeasurableSMul G α] {s : Set α} (hs : MeasurableSet s) (a : G) :
MeasurableSet (a • s) := by
rw [← preimage_smul_inv]
exact measurable_const_smul _ hs
#align measurable_set.const_smul MeasurableSet.const_smul
#align measurable_set.const_vadd MeasurableSet.const_vadd
theorem MeasurableSet.const_smul_of_ne_zero {G₀ α : Type*} [GroupWithZero G₀] [MulAction G₀ α]
[MeasurableSpace G₀] [MeasurableSpace α] [MeasurableSMul G₀ α] {s : Set α}
(hs : MeasurableSet s) {a : G₀} (ha : a ≠ 0) : MeasurableSet (a • s) := by
rw [← preimage_smul_inv₀ ha]
exact measurable_const_smul _ hs
#align measurable_set.const_smul_of_ne_zero MeasurableSet.const_smul_of_ne_zero
| Mathlib/MeasureTheory/Group/Pointwise.lean | 39 | 44 | theorem MeasurableSet.const_smul₀ {G₀ α : Type*} [GroupWithZero G₀] [Zero α]
[MulActionWithZero G₀ α] [MeasurableSpace G₀] [MeasurableSpace α] [MeasurableSMul G₀ α]
[MeasurableSingletonClass α] {s : Set α} (hs : MeasurableSet s) (a : G₀) :
MeasurableSet (a • s) := by |
rcases eq_or_ne a 0 with (rfl | ha)
exacts [(subsingleton_zero_smul_set s).measurableSet, hs.const_smul_of_ne_zero ha]
|
/-
Copyright (c) 2020 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.Polynomial.Degree.TrailingDegree
import Mathlib.Algebra.Polynomial.EraseLead
import Mathlib.Algebra.Polynomial.Eval
#align_import data.polynomial.reverse from "leanprover-community/mathlib"@"44de64f183393284a16016dfb2a48ac97382f2bd"
/-!
# Reverse of a univariate polynomial
The main definition is `reverse`. Applying `reverse` to a polynomial `f : R[X]` produces
the polynomial with a reversed list of coefficients, equivalent to `X^f.natDegree * f(1/X)`.
The main result is that `reverse (f * g) = reverse f * reverse g`, provided the leading
coefficients of `f` and `g` do not multiply to zero.
-/
namespace Polynomial
open Polynomial Finsupp Finset
open Polynomial
section Semiring
variable {R : Type*} [Semiring R] {f : R[X]}
/-- If `i ≤ N`, then `revAtFun N i` returns `N - i`, otherwise it returns `i`.
This is the map used by the embedding `revAt`.
-/
def revAtFun (N i : ℕ) : ℕ :=
ite (i ≤ N) (N - i) i
#align polynomial.rev_at_fun Polynomial.revAtFun
theorem revAtFun_invol {N i : ℕ} : revAtFun N (revAtFun N i) = i := by
unfold revAtFun
split_ifs with h j
· exact tsub_tsub_cancel_of_le h
· exfalso
apply j
exact Nat.sub_le N i
· rfl
#align polynomial.rev_at_fun_invol Polynomial.revAtFun_invol
theorem revAtFun_inj {N : ℕ} : Function.Injective (revAtFun N) := by
intro a b hab
rw [← @revAtFun_invol N a, hab, revAtFun_invol]
#align polynomial.rev_at_fun_inj Polynomial.revAtFun_inj
/-- If `i ≤ N`, then `revAt N i` returns `N - i`, otherwise it returns `i`.
Essentially, this embedding is only used for `i ≤ N`.
The advantage of `revAt N i` over `N - i` is that `revAt` is an involution.
-/
def revAt (N : ℕ) : Function.Embedding ℕ ℕ where
toFun i := ite (i ≤ N) (N - i) i
inj' := revAtFun_inj
#align polynomial.rev_at Polynomial.revAt
/-- We prefer to use the bundled `revAt` over unbundled `revAtFun`. -/
@[simp]
theorem revAtFun_eq (N i : ℕ) : revAtFun N i = revAt N i :=
rfl
#align polynomial.rev_at_fun_eq Polynomial.revAtFun_eq
@[simp]
theorem revAt_invol {N i : ℕ} : (revAt N) (revAt N i) = i :=
revAtFun_invol
#align polynomial.rev_at_invol Polynomial.revAt_invol
@[simp]
theorem revAt_le {N i : ℕ} (H : i ≤ N) : revAt N i = N - i :=
if_pos H
#align polynomial.rev_at_le Polynomial.revAt_le
lemma revAt_eq_self_of_lt {N i : ℕ} (h : N < i) : revAt N i = i := by simp [revAt, Nat.not_le.mpr h]
theorem revAt_add {N O n o : ℕ} (hn : n ≤ N) (ho : o ≤ O) :
revAt (N + O) (n + o) = revAt N n + revAt O o := by
rcases Nat.le.dest hn with ⟨n', rfl⟩
rcases Nat.le.dest ho with ⟨o', rfl⟩
repeat' rw [revAt_le (le_add_right rfl.le)]
rw [add_assoc, add_left_comm n' o, ← add_assoc, revAt_le (le_add_right rfl.le)]
repeat' rw [add_tsub_cancel_left]
#align polynomial.rev_at_add Polynomial.revAt_add
-- @[simp] -- Porting note (#10618): simp can prove this
theorem revAt_zero (N : ℕ) : revAt N 0 = N := by simp
#align polynomial.rev_at_zero Polynomial.revAt_zero
/-- `reflect N f` is the polynomial such that `(reflect N f).coeff i = f.coeff (revAt N i)`.
In other words, the terms with exponent `[0, ..., N]` now have exponent `[N, ..., 0]`.
In practice, `reflect` is only used when `N` is at least as large as the degree of `f`.
Eventually, it will be used with `N` exactly equal to the degree of `f`. -/
noncomputable def reflect (N : ℕ) : R[X] → R[X]
| ⟨f⟩ => ⟨Finsupp.embDomain (revAt N) f⟩
#align polynomial.reflect Polynomial.reflect
theorem reflect_support (N : ℕ) (f : R[X]) :
(reflect N f).support = Finset.image (revAt N) f.support := by
rcases f with ⟨⟩
ext1
simp only [reflect, support_ofFinsupp, support_embDomain, Finset.mem_map, Finset.mem_image]
#align polynomial.reflect_support Polynomial.reflect_support
@[simp]
| Mathlib/Algebra/Polynomial/Reverse.lean | 113 | 119 | theorem coeff_reflect (N : ℕ) (f : R[X]) (i : ℕ) : coeff (reflect N f) i = f.coeff (revAt N i) := by |
rcases f with ⟨f⟩
simp only [reflect, coeff]
calc
Finsupp.embDomain (revAt N) f i = Finsupp.embDomain (revAt N) f (revAt N (revAt N i)) := by
rw [revAt_invol]
_ = f (revAt N i) := Finsupp.embDomain_apply _ _ _
|
/-
Copyright (c) 2023 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Yury Kudryashov
-/
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Comp
#align_import analysis.calculus.deriv.inv from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
/-!
# Derivatives of `x ↦ x⁻¹` and `f x / g x`
In this file we prove `(x⁻¹)' = -1 / x ^ 2`, `((f x)⁻¹)' = -f' x / (f x) ^ 2`, and
`(f x / g x)' = (f' x * g x - f x * g' x) / (g x) ^ 2` for different notions of derivative.
For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of
`Analysis/Calculus/Deriv/Basic`.
## Keywords
derivative
-/
universe u v w
open scoped Classical
open Topology Filter ENNReal
open Filter Asymptotics Set
open ContinuousLinearMap (smulRight smulRight_one_eq_iff)
variable {𝕜 : Type u} [NontriviallyNormedField 𝕜]
variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {f f₀ f₁ g : 𝕜 → F}
variable {f' f₀' f₁' g' : F}
variable {x : 𝕜}
variable {s t : Set 𝕜}
variable {L : Filter 𝕜}
section Inverse
/-! ### Derivative of `x ↦ x⁻¹` -/
| Mathlib/Analysis/Calculus/Deriv/Inv.lean | 48 | 61 | theorem hasStrictDerivAt_inv (hx : x ≠ 0) : HasStrictDerivAt Inv.inv (-(x ^ 2)⁻¹) x := by |
suffices
(fun p : 𝕜 × 𝕜 => (p.1 - p.2) * ((x * x)⁻¹ - (p.1 * p.2)⁻¹)) =o[𝓝 (x, x)] fun p =>
(p.1 - p.2) * 1 by
refine this.congr' ?_ (eventually_of_forall fun _ => mul_one _)
refine Eventually.mono ((isOpen_ne.prod isOpen_ne).mem_nhds ⟨hx, hx⟩) ?_
rintro ⟨y, z⟩ ⟨hy, hz⟩
simp only [mem_setOf_eq] at hy hz
-- hy : y ≠ 0, hz : z ≠ 0
field_simp [hx, hy, hz]
ring
refine (isBigO_refl (fun p : 𝕜 × 𝕜 => p.1 - p.2) _).mul_isLittleO ((isLittleO_one_iff 𝕜).2 ?_)
rw [← sub_self (x * x)⁻¹]
exact tendsto_const_nhds.sub ((continuous_mul.tendsto (x, x)).inv₀ <| mul_ne_zero hx hx)
|
/-
Copyright (c) 2019 Gabriel Ebner. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Gabriel Ebner, Anatole Dedecker, Yury Kudryashov
-/
import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.FDeriv.Mul
import Mathlib.Analysis.Calculus.FDeriv.Add
#align_import analysis.calculus.deriv.mul from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
/-!
# Derivative of `f x * g x`
In this file we prove formulas for `(f x * g x)'` and `(f x • g x)'`.
For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of
`Analysis/Calculus/Deriv/Basic`.
## Keywords
derivative, multiplication
-/
universe u v w
noncomputable section
open scoped Classical Topology Filter ENNReal
open Filter Asymptotics Set
open ContinuousLinearMap (smulRight smulRight_one_eq_iff)
variable {𝕜 : Type u} [NontriviallyNormedField 𝕜]
variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
variable {f f₀ f₁ g : 𝕜 → F}
variable {f' f₀' f₁' g' : F}
variable {x : 𝕜}
variable {s t : Set 𝕜}
variable {L L₁ L₂ : Filter 𝕜}
/-! ### Derivative of bilinear maps -/
namespace ContinuousLinearMap
variable {B : E →L[𝕜] F →L[𝕜] G} {u : 𝕜 → E} {v : 𝕜 → F} {u' : E} {v' : F}
| Mathlib/Analysis/Calculus/Deriv/Mul.lean | 52 | 56 | theorem hasDerivWithinAt_of_bilinear
(hu : HasDerivWithinAt u u' s x) (hv : HasDerivWithinAt v v' s x) :
HasDerivWithinAt (fun x ↦ B (u x) (v x)) (B (u x) v' + B u' (v x)) s x := by |
simpa using (B.hasFDerivWithinAt_of_bilinear
hu.hasFDerivWithinAt hv.hasFDerivWithinAt).hasDerivWithinAt
|
/-
Copyright (c) 2021 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import Mathlib.Algebra.Lie.Submodule
#align_import algebra.lie.ideal_operations from "leanprover-community/mathlib"@"8983bec7cdf6cb2dd1f21315c8a34ab00d7b2f6d"
/-!
# Ideal operations for Lie algebras
Given a Lie module `M` over a Lie algebra `L`, there is a natural action of the Lie ideals of `L`
on the Lie submodules of `M`. In the special case that `M = L` with the adjoint action, this
provides a pairing of Lie ideals which is especially important. For example, it can be used to
define solvability / nilpotency of a Lie algebra via the derived / lower-central series.
## Main definitions
* `LieSubmodule.hasBracket`
* `LieSubmodule.lieIdeal_oper_eq_linear_span`
* `LieIdeal.map_bracket_le`
* `LieIdeal.comap_bracket_le`
## Notation
Given a Lie module `M` over a Lie algebra `L`, together with a Lie submodule `N ⊆ M` and a Lie
ideal `I ⊆ L`, we introduce the notation `⁅I, N⁆` for the Lie submodule of `M` corresponding to
the action defined in this file.
## Tags
lie algebra, ideal operation
-/
universe u v w w₁ w₂
namespace LieSubmodule
variable {R : Type u} {L : Type v} {M : Type w} {M₂ : Type w₁}
variable [CommRing R] [LieRing L] [LieAlgebra R L]
variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M]
variable [AddCommGroup M₂] [Module R M₂] [LieRingModule L M₂] [LieModule R L M₂]
variable (N N' : LieSubmodule R L M) (I J : LieIdeal R L) (N₂ : LieSubmodule R L M₂)
section LieIdealOperations
/-- Given a Lie module `M` over a Lie algebra `L`, the set of Lie ideals of `L` acts on the set
of submodules of `M`. -/
instance hasBracket : Bracket (LieIdeal R L) (LieSubmodule R L M) :=
⟨fun I N => lieSpan R L { m | ∃ (x : I) (n : N), ⁅(x : L), (n : M)⁆ = m }⟩
#align lie_submodule.has_bracket LieSubmodule.hasBracket
theorem lieIdeal_oper_eq_span :
⁅I, N⁆ = lieSpan R L { m | ∃ (x : I) (n : N), ⁅(x : L), (n : M)⁆ = m } :=
rfl
#align lie_submodule.lie_ideal_oper_eq_span LieSubmodule.lieIdeal_oper_eq_span
/-- See also `LieSubmodule.lieIdeal_oper_eq_linear_span'` and
`LieSubmodule.lieIdeal_oper_eq_tensor_map_range`. -/
theorem lieIdeal_oper_eq_linear_span :
(↑⁅I, N⁆ : Submodule R M) =
Submodule.span R { m | ∃ (x : I) (n : N), ⁅(x : L), (n : M)⁆ = m } := by
apply le_antisymm
· let s := { m : M | ∃ (x : ↥I) (n : ↥N), ⁅(x : L), (n : M)⁆ = m }
have aux : ∀ (y : L), ∀ m' ∈ Submodule.span R s, ⁅y, m'⁆ ∈ Submodule.span R s := by
intro y m' hm'
refine Submodule.span_induction (R := R) (M := M) (s := s)
(p := fun m' ↦ ⁅y, m'⁆ ∈ Submodule.span R s) hm' ?_ ?_ ?_ ?_
· rintro m'' ⟨x, n, hm''⟩; rw [← hm'', leibniz_lie]
refine Submodule.add_mem _ ?_ ?_ <;> apply Submodule.subset_span
· use ⟨⁅y, ↑x⁆, I.lie_mem x.property⟩, n
· use x, ⟨⁅y, ↑n⁆, N.lie_mem n.property⟩
· simp only [lie_zero, Submodule.zero_mem]
· intro m₁ m₂ hm₁ hm₂; rw [lie_add]; exact Submodule.add_mem _ hm₁ hm₂
· intro t m'' hm''; rw [lie_smul]; exact Submodule.smul_mem _ t hm''
change _ ≤ ({ Submodule.span R s with lie_mem := fun hm' => aux _ _ hm' } : LieSubmodule R L M)
rw [lieIdeal_oper_eq_span, lieSpan_le]
exact Submodule.subset_span
· rw [lieIdeal_oper_eq_span]; apply submodule_span_le_lieSpan
#align lie_submodule.lie_ideal_oper_eq_linear_span LieSubmodule.lieIdeal_oper_eq_linear_span
theorem lieIdeal_oper_eq_linear_span' :
(↑⁅I, N⁆ : Submodule R M) = Submodule.span R { m | ∃ x ∈ I, ∃ n ∈ N, ⁅x, n⁆ = m } := by
rw [lieIdeal_oper_eq_linear_span]
congr
ext m
constructor
· rintro ⟨⟨x, hx⟩, ⟨n, hn⟩, rfl⟩
exact ⟨x, hx, n, hn, rfl⟩
· rintro ⟨x, hx, n, hn, rfl⟩
exact ⟨⟨x, hx⟩, ⟨n, hn⟩, rfl⟩
#align lie_submodule.lie_ideal_oper_eq_linear_span' LieSubmodule.lieIdeal_oper_eq_linear_span'
theorem lie_le_iff : ⁅I, N⁆ ≤ N' ↔ ∀ x ∈ I, ∀ m ∈ N, ⁅x, m⁆ ∈ N' := by
rw [lieIdeal_oper_eq_span, LieSubmodule.lieSpan_le]
refine ⟨fun h x hx m hm => h ⟨⟨x, hx⟩, ⟨m, hm⟩, rfl⟩, ?_⟩
rintro h _ ⟨⟨x, hx⟩, ⟨m, hm⟩, rfl⟩
exact h x hx m hm
#align lie_submodule.lie_le_iff LieSubmodule.lie_le_iff
| Mathlib/Algebra/Lie/IdealOperations.lean | 103 | 104 | theorem lie_coe_mem_lie (x : I) (m : N) : ⁅(x : L), (m : M)⁆ ∈ ⁅I, N⁆ := by |
rw [lieIdeal_oper_eq_span]; apply subset_lieSpan; use x, m
|
/-
Copyright (c) 2020 Aaron Anderson, Jalex Stark. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson, Jalex Stark
-/
import Mathlib.Algebra.Polynomial.Expand
import Mathlib.Algebra.Polynomial.Laurent
import Mathlib.LinearAlgebra.Matrix.Charpoly.Basic
import Mathlib.LinearAlgebra.Matrix.Reindex
import Mathlib.RingTheory.Polynomial.Nilpotent
#align_import linear_algebra.matrix.charpoly.coeff from "leanprover-community/mathlib"@"9745b093210e9dac443af24da9dba0f9e2b6c912"
/-!
# Characteristic polynomials
We give methods for computing coefficients of the characteristic polynomial.
## Main definitions
- `Matrix.charpoly_degree_eq_dim` proves that the degree of the characteristic polynomial
over a nonzero ring is the dimension of the matrix
- `Matrix.det_eq_sign_charpoly_coeff` proves that the determinant is the constant term of the
characteristic polynomial, up to sign.
- `Matrix.trace_eq_neg_charpoly_coeff` proves that the trace is the negative of the (d-1)th
coefficient of the characteristic polynomial, where d is the dimension of the matrix.
For a nonzero ring, this is the second-highest coefficient.
- `Matrix.charpolyRev` the reverse of the characteristic polynomial.
- `Matrix.reverse_charpoly` characterises the reverse of the characteristic polynomial.
-/
noncomputable section
-- porting note: whenever there was `∏ i : n, X - C (M i i)`, I replaced it with
-- `∏ i : n, (X - C (M i i))`, since otherwise Lean would parse as `(∏ i : n, X) - C (M i i)`
universe u v w z
open Finset Matrix Polynomial
variable {R : Type u} [CommRing R]
variable {n G : Type v} [DecidableEq n] [Fintype n]
variable {α β : Type v} [DecidableEq α]
variable {M : Matrix n n R}
namespace Matrix
theorem charmatrix_apply_natDegree [Nontrivial R] (i j : n) :
(charmatrix M i j).natDegree = ite (i = j) 1 0 := by
by_cases h : i = j <;> simp [h, ← degree_eq_iff_natDegree_eq_of_pos (Nat.succ_pos 0)]
#align charmatrix_apply_nat_degree Matrix.charmatrix_apply_natDegree
theorem charmatrix_apply_natDegree_le (i j : n) :
(charmatrix M i j).natDegree ≤ ite (i = j) 1 0 := by
split_ifs with h <;> simp [h, natDegree_X_le]
#align charmatrix_apply_nat_degree_le Matrix.charmatrix_apply_natDegree_le
variable (M)
theorem charpoly_sub_diagonal_degree_lt :
(M.charpoly - ∏ i : n, (X - C (M i i))).degree < ↑(Fintype.card n - 1) := by
rw [charpoly, det_apply', ← insert_erase (mem_univ (Equiv.refl n)),
sum_insert (not_mem_erase (Equiv.refl n) univ), add_comm]
simp only [charmatrix_apply_eq, one_mul, Equiv.Perm.sign_refl, id, Int.cast_one,
Units.val_one, add_sub_cancel_right, Equiv.coe_refl]
rw [← mem_degreeLT]
apply Submodule.sum_mem (degreeLT R (Fintype.card n - 1))
intro c hc; rw [← C_eq_intCast, C_mul']
apply Submodule.smul_mem (degreeLT R (Fintype.card n - 1)) ↑↑(Equiv.Perm.sign c)
rw [mem_degreeLT]
apply lt_of_le_of_lt degree_le_natDegree _
rw [Nat.cast_lt]
apply lt_of_le_of_lt _ (Equiv.Perm.fixed_point_card_lt_of_ne_one (ne_of_mem_erase hc))
apply le_trans (Polynomial.natDegree_prod_le univ fun i : n => charmatrix M (c i) i) _
rw [card_eq_sum_ones]; rw [sum_filter]; apply sum_le_sum
intros
apply charmatrix_apply_natDegree_le
#align matrix.charpoly_sub_diagonal_degree_lt Matrix.charpoly_sub_diagonal_degree_lt
theorem charpoly_coeff_eq_prod_coeff_of_le {k : ℕ} (h : Fintype.card n - 1 ≤ k) :
M.charpoly.coeff k = (∏ i : n, (X - C (M i i))).coeff k := by
apply eq_of_sub_eq_zero; rw [← coeff_sub]
apply Polynomial.coeff_eq_zero_of_degree_lt
apply lt_of_lt_of_le (charpoly_sub_diagonal_degree_lt M) ?_
rw [Nat.cast_le]; apply h
#align matrix.charpoly_coeff_eq_prod_coeff_of_le Matrix.charpoly_coeff_eq_prod_coeff_of_le
| Mathlib/LinearAlgebra/Matrix/Charpoly/Coeff.lean | 89 | 93 | theorem det_of_card_zero (h : Fintype.card n = 0) (M : Matrix n n R) : M.det = 1 := by |
rw [Fintype.card_eq_zero_iff] at h
suffices M = 1 by simp [this]
ext i
exact h.elim i
|
/-
Copyright (c) 2022 Benjamin Davidson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Benjamin Davidson, Devon Tuma, Eric Rodriguez, Oliver Nash
-/
import Mathlib.Data.Set.Pointwise.Interval
import Mathlib.Topology.Algebra.Field
import Mathlib.Topology.Algebra.Order.Group
#align_import topology.algebra.order.field from "leanprover-community/mathlib"@"9a59dcb7a2d06bf55da57b9030169219980660cd"
/-!
# Topologies on linear ordered fields
In this file we prove that a linear ordered field with order topology has continuous multiplication
and division (apart from zero in the denominator). We also prove theorems like
`Filter.Tendsto.mul_atTop`: if `f` tends to a positive number and `g` tends to positive infinity,
then `f * g` tends to positive infinity.
-/
open Set Filter TopologicalSpace Function
open scoped Pointwise Topology
open OrderDual (toDual ofDual)
/-- If a (possibly non-unital and/or non-associative) ring `R` admits a submultiplicative
nonnegative norm `norm : R → 𝕜`, where `𝕜` is a linear ordered field, and the open balls
`{ x | norm x < ε }`, `ε > 0`, form a basis of neighborhoods of zero, then `R` is a topological
ring. -/
theorem TopologicalRing.of_norm {R 𝕜 : Type*} [NonUnitalNonAssocRing R] [LinearOrderedField 𝕜]
[TopologicalSpace R] [TopologicalAddGroup R] (norm : R → 𝕜)
(norm_nonneg : ∀ x, 0 ≤ norm x) (norm_mul_le : ∀ x y, norm (x * y) ≤ norm x * norm y)
(nhds_basis : (𝓝 (0 : R)).HasBasis ((0 : 𝕜) < ·) (fun ε ↦ { x | norm x < ε })) :
TopologicalRing R := by
have h0 : ∀ f : R → R, ∀ c ≥ (0 : 𝕜), (∀ x, norm (f x) ≤ c * norm x) →
Tendsto f (𝓝 0) (𝓝 0) := by
refine fun f c c0 hf ↦ (nhds_basis.tendsto_iff nhds_basis).2 fun ε ε0 ↦ ?_
rcases exists_pos_mul_lt ε0 c with ⟨δ, δ0, hδ⟩
refine ⟨δ, δ0, fun x hx ↦ (hf _).trans_lt ?_⟩
exact (mul_le_mul_of_nonneg_left (le_of_lt hx) c0).trans_lt hδ
apply TopologicalRing.of_addGroup_of_nhds_zero
case hmul =>
refine ((nhds_basis.prod nhds_basis).tendsto_iff nhds_basis).2 fun ε ε0 ↦ ?_
refine ⟨(1, ε), ⟨one_pos, ε0⟩, fun (x, y) ⟨hx, hy⟩ => ?_⟩
simp only [sub_zero] at *
calc norm (x * y) ≤ norm x * norm y := norm_mul_le _ _
_ < ε := mul_lt_of_le_one_of_lt_of_nonneg hx.le hy (norm_nonneg _)
case hmul_left => exact fun x => h0 _ (norm x) (norm_nonneg _) (norm_mul_le x)
case hmul_right =>
exact fun y => h0 (· * y) (norm y) (norm_nonneg y) fun x =>
(norm_mul_le x y).trans_eq (mul_comm _ _)
variable {𝕜 α : Type*} [LinearOrderedField 𝕜] [TopologicalSpace 𝕜] [OrderTopology 𝕜]
{l : Filter α} {f g : α → 𝕜}
-- see Note [lower instance priority]
instance (priority := 100) LinearOrderedField.topologicalRing : TopologicalRing 𝕜 :=
.of_norm abs abs_nonneg (fun _ _ ↦ (abs_mul _ _).le) <| by
simpa using nhds_basis_abs_sub_lt (0 : 𝕜)
/-- In a linearly ordered field with the order topology, if `f` tends to `Filter.atTop` and `g`
tends to a positive constant `C` then `f * g` tends to `Filter.atTop`. -/
theorem Filter.Tendsto.atTop_mul {C : 𝕜} (hC : 0 < C) (hf : Tendsto f l atTop)
(hg : Tendsto g l (𝓝 C)) : Tendsto (fun x => f x * g x) l atTop := by
refine tendsto_atTop_mono' _ ?_ (hf.atTop_mul_const (half_pos hC))
filter_upwards [hg.eventually (lt_mem_nhds (half_lt_self hC)), hf.eventually_ge_atTop 0]
with x hg hf using mul_le_mul_of_nonneg_left hg.le hf
#align filter.tendsto.at_top_mul Filter.Tendsto.atTop_mul
/-- In a linearly ordered field with the order topology, if `f` tends to a positive constant `C` and
`g` tends to `Filter.atTop` then `f * g` tends to `Filter.atTop`. -/
| Mathlib/Topology/Algebra/Order/Field.lean | 72 | 74 | theorem Filter.Tendsto.mul_atTop {C : 𝕜} (hC : 0 < C) (hf : Tendsto f l (𝓝 C))
(hg : Tendsto g l atTop) : Tendsto (fun x => f x * g x) l atTop := by |
simpa only [mul_comm] using hg.atTop_mul hC hf
|
/-
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.Algebra.Order.Field.Pi
import Mathlib.Algebra.Order.UpperLower
import Mathlib.Analysis.Normed.Group.Pointwise
import Mathlib.Analysis.Normed.Order.Basic
import Mathlib.Data.Real.Sqrt
import Mathlib.Topology.Algebra.Order.UpperLower
import Mathlib.Topology.MetricSpace.Sequences
#align_import analysis.normed.order.upper_lower from "leanprover-community/mathlib"@"b1abe23ae96fef89ad30d9f4362c307f72a55010"
/-!
# Upper/lower/order-connected sets in normed groups
The topological closure and interior of an upper/lower/order-connected set is an
upper/lower/order-connected set (with the notable exception of the closure of an order-connected
set).
We also prove lemmas specific to `ℝⁿ`. Those are helpful to prove that order-connected sets in `ℝⁿ`
are measurable.
## TODO
Is there a way to generalise `IsClosed.upperClosure_pi`/`IsClosed.lowerClosure_pi` so that they also
apply to `ℝ`, `ℝ × ℝ`, `EuclideanSpace ι ℝ`? `_pi` has been appended to their names to disambiguate
from the other possible lemmas, but we will want there to be a single set of lemmas for all
situations.
-/
open Bornology Function Metric Set
open scoped Pointwise
variable {α ι : Type*}
section NormedOrderedGroup
variable [NormedOrderedGroup α] {s : Set α}
@[to_additive IsUpperSet.thickening]
protected theorem IsUpperSet.thickening' (hs : IsUpperSet s) (ε : ℝ) :
IsUpperSet (thickening ε s) := by
rw [← ball_mul_one]
exact hs.mul_left
#align is_upper_set.thickening' IsUpperSet.thickening'
#align is_upper_set.thickening IsUpperSet.thickening
@[to_additive IsLowerSet.thickening]
protected theorem IsLowerSet.thickening' (hs : IsLowerSet s) (ε : ℝ) :
IsLowerSet (thickening ε s) := by
rw [← ball_mul_one]
exact hs.mul_left
#align is_lower_set.thickening' IsLowerSet.thickening'
#align is_lower_set.thickening IsLowerSet.thickening
@[to_additive IsUpperSet.cthickening]
protected theorem IsUpperSet.cthickening' (hs : IsUpperSet s) (ε : ℝ) :
IsUpperSet (cthickening ε s) := by
rw [cthickening_eq_iInter_thickening'']
exact isUpperSet_iInter₂ fun δ _ => hs.thickening' _
#align is_upper_set.cthickening' IsUpperSet.cthickening'
#align is_upper_set.cthickening IsUpperSet.cthickening
@[to_additive IsLowerSet.cthickening]
protected theorem IsLowerSet.cthickening' (hs : IsLowerSet s) (ε : ℝ) :
IsLowerSet (cthickening ε s) := by
rw [cthickening_eq_iInter_thickening'']
exact isLowerSet_iInter₂ fun δ _ => hs.thickening' _
#align is_lower_set.cthickening' IsLowerSet.cthickening'
#align is_lower_set.cthickening IsLowerSet.cthickening
@[to_additive upperClosure_interior_subset] lemma upperClosure_interior_subset' (s : Set α) :
(upperClosure (interior s) : Set α) ⊆ interior (upperClosure s) :=
upperClosure_min (interior_mono subset_upperClosure) (upperClosure s).upper.interior
#align upper_closure_interior_subset' upperClosure_interior_subset'
#align upper_closure_interior_subset upperClosure_interior_subset
@[to_additive lowerClosure_interior_subset] lemma lowerClosure_interior_subset' (s : Set α) :
(lowerClosure (interior s) : Set α) ⊆ interior (lowerClosure s) :=
lowerClosure_min (interior_mono subset_lowerClosure) (lowerClosure s).lower.interior
#align lower_closure_interior_subset' lowerClosure_interior_subset'
#align lower_closure_interior_subset lowerClosure_interior_subset
end NormedOrderedGroup
/-! ### `ℝⁿ` -/
section Finite
variable [Finite ι] {s : Set (ι → ℝ)} {x y : ι → ℝ}
| Mathlib/Analysis/Normed/Order/UpperLower.lean | 94 | 109 | theorem IsUpperSet.mem_interior_of_forall_lt (hs : IsUpperSet s) (hx : x ∈ closure s)
(h : ∀ i, x i < y i) : y ∈ interior s := by |
cases nonempty_fintype ι
obtain ⟨ε, hε, hxy⟩ := Pi.exists_forall_pos_add_lt h
obtain ⟨z, hz, hxz⟩ := Metric.mem_closure_iff.1 hx _ hε
rw [dist_pi_lt_iff hε] at hxz
have hyz : ∀ i, z i < y i := by
refine fun i => (hxy _).trans_le' (sub_le_iff_le_add'.1 <| (le_abs_self _).trans ?_)
rw [← Real.norm_eq_abs, ← dist_eq_norm']
exact (hxz _).le
obtain ⟨δ, hδ, hyz⟩ := Pi.exists_forall_pos_add_lt hyz
refine mem_interior.2 ⟨ball y δ, ?_, isOpen_ball, mem_ball_self hδ⟩
rintro w hw
refine hs (fun i => ?_) hz
simp_rw [ball_pi _ hδ, Real.ball_eq_Ioo] at hw
exact ((lt_sub_iff_add_lt.2 <| hyz _).trans (hw _ <| mem_univ _).1).le
|
/-
Copyright (c) 2020 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel, Scott Morrison
-/
import Mathlib.CategoryTheory.Limits.Shapes.Kernels
#align_import category_theory.abelian.images from "leanprover-community/mathlib"@"9e7c80f638149bfb3504ba8ff48dfdbfc949fb1a"
/-!
# The abelian image and coimage.
In an abelian category we usually want the image of a morphism `f` to be defined as
`kernel (cokernel.π f)`, and the coimage to be defined as `cokernel (kernel.ι f)`.
We make these definitions here, as `Abelian.image f` and `Abelian.coimage f`
(without assuming the category is actually abelian),
and later relate these to the usual categorical notions when in an abelian category.
There is a canonical morphism `coimageImageComparison : Abelian.coimage f ⟶ Abelian.image f`.
Later we show that this is always an isomorphism in an abelian category,
and conversely a category with (co)kernels and finite products in which this morphism
is always an isomorphism is an abelian category.
-/
noncomputable section
universe v u
open CategoryTheory
open CategoryTheory.Limits
namespace CategoryTheory.Abelian
variable {C : Type u} [Category.{v} C] [HasZeroMorphisms C] [HasKernels C] [HasCokernels C]
variable {P Q : C} (f : P ⟶ Q)
section Image
/-- The kernel of the cokernel of `f` is called the (abelian) image of `f`. -/
protected abbrev image : C :=
kernel (cokernel.π f)
#align category_theory.abelian.image CategoryTheory.Abelian.image
/-- The inclusion of the image into the codomain. -/
protected abbrev image.ι : Abelian.image f ⟶ Q :=
kernel.ι (cokernel.π f)
#align category_theory.abelian.image.ι CategoryTheory.Abelian.image.ι
/-- There is a canonical epimorphism `p : P ⟶ image f` for every `f`. -/
protected abbrev factorThruImage : P ⟶ Abelian.image f :=
kernel.lift (cokernel.π f) f <| cokernel.condition f
#align category_theory.abelian.factor_thru_image CategoryTheory.Abelian.factorThruImage
-- Porting note (#10618): simp can prove this and reassoc version, removed tags
/-- `f` factors through its image via the canonical morphism `p`. -/
protected theorem image.fac : Abelian.factorThruImage f ≫ image.ι f = f :=
kernel.lift_ι _ _ _
#align category_theory.abelian.image.fac CategoryTheory.Abelian.image.fac
instance mono_factorThruImage [Mono f] : Mono (Abelian.factorThruImage f) :=
mono_of_mono_fac <| image.fac f
#align category_theory.abelian.mono_factor_thru_image CategoryTheory.Abelian.mono_factorThruImage
end Image
section Coimage
/-- The cokernel of the kernel of `f` is called the (abelian) coimage of `f`. -/
protected abbrev coimage : C :=
cokernel (kernel.ι f)
#align category_theory.abelian.coimage CategoryTheory.Abelian.coimage
/-- The projection onto the coimage. -/
protected abbrev coimage.π : P ⟶ Abelian.coimage f :=
cokernel.π (kernel.ι f)
#align category_theory.abelian.coimage.π CategoryTheory.Abelian.coimage.π
/-- There is a canonical monomorphism `i : coimage f ⟶ Q`. -/
protected abbrev factorThruCoimage : Abelian.coimage f ⟶ Q :=
cokernel.desc (kernel.ι f) f <| kernel.condition f
#align category_theory.abelian.factor_thru_coimage CategoryTheory.Abelian.factorThruCoimage
/-- `f` factors through its coimage via the canonical morphism `p`. -/
protected theorem coimage.fac : coimage.π f ≫ Abelian.factorThruCoimage f = f :=
cokernel.π_desc _ _ _
#align category_theory.abelian.coimage.fac CategoryTheory.Abelian.coimage.fac
instance epi_factorThruCoimage [Epi f] : Epi (Abelian.factorThruCoimage f) :=
epi_of_epi_fac <| coimage.fac f
#align category_theory.abelian.epi_factor_thru_coimage CategoryTheory.Abelian.epi_factorThruCoimage
end Coimage
/-- The canonical map from the abelian coimage to the abelian image.
In any abelian category this is an isomorphism.
Conversely, any additive category with kernels and cokernels and
in which this is always an isomorphism, is abelian.
See <https://stacks.math.columbia.edu/tag/0107>
-/
def coimageImageComparison : Abelian.coimage f ⟶ Abelian.image f :=
cokernel.desc (kernel.ι f) (kernel.lift (cokernel.π f) f (by simp)) (by ext; simp)
#align category_theory.abelian.coimage_image_comparison CategoryTheory.Abelian.coimageImageComparison
/-- An alternative formulation of the canonical map from the abelian coimage to the abelian image.
-/
def coimageImageComparison' : Abelian.coimage f ⟶ Abelian.image f :=
kernel.lift (cokernel.π f) (cokernel.desc (kernel.ι f) f (by simp)) (by ext; simp)
#align category_theory.abelian.coimage_image_comparison' CategoryTheory.Abelian.coimageImageComparison'
theorem coimageImageComparison_eq_coimageImageComparison' :
coimageImageComparison f = coimageImageComparison' f := by
ext
simp [coimageImageComparison, coimageImageComparison']
#align category_theory.abelian.coimage_image_comparison_eq_coimage_image_comparison' CategoryTheory.Abelian.coimageImageComparison_eq_coimageImageComparison'
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Abelian/Images.lean | 122 | 123 | theorem coimage_image_factorisation : coimage.π f ≫ coimageImageComparison f ≫ image.ι f = f := by |
simp [coimageImageComparison]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov
-/
import Mathlib.Topology.Order.IsLUB
/-!
# Monotone functions on an order topology
This file contains lemmas about limits and continuity for monotone / antitone functions on
linearly-ordered sets (with the order topology). For example, we prove that a monotone function
has left and right limits at any point (`Monotone.tendsto_nhdsWithin_Iio`,
`Monotone.tendsto_nhdsWithin_Ioi`).
-/
open Set Filter TopologicalSpace Topology Function
open OrderDual (toDual ofDual)
variable {α β γ : Type*}
section ConditionallyCompleteLinearOrder
variable [ConditionallyCompleteLinearOrder α] [TopologicalSpace α] [OrderTopology α]
[ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderClosedTopology β] [Nonempty γ]
/-- A monotone function continuous at the supremum of a nonempty set sends this supremum to
the supremum of the image of this set. -/
theorem Monotone.map_sSup_of_continuousAt' {f : α → β} {A : Set α} (Cf : ContinuousAt f (sSup A))
(Mf : Monotone f) (A_nonemp : A.Nonempty) (A_bdd : BddAbove A := by bddDefault) :
f (sSup A) = sSup (f '' A) :=
--This is a particular case of the more general `IsLUB.isLUB_of_tendsto`
.symm <| ((isLUB_csSup A_nonemp A_bdd).isLUB_of_tendsto (Mf.monotoneOn _) A_nonemp <|
Cf.mono_left inf_le_left).csSup_eq (A_nonemp.image f)
#align monotone.map_Sup_of_continuous_at' Monotone.map_sSup_of_continuousAt'
/-- A monotone function continuous at the indexed supremum over a nonempty `Sort` sends this indexed
supremum to the indexed supremum of the composition. -/
theorem Monotone.map_iSup_of_continuousAt' {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α}
(Cf : ContinuousAt f (iSup g)) (Mf : Monotone f)
(bdd : BddAbove (range g) := by bddDefault) : f (⨆ i, g i) = ⨆ i, f (g i) := by
rw [iSup, Monotone.map_sSup_of_continuousAt' Cf Mf (range_nonempty g) bdd, ← range_comp, iSup]
rfl
#align monotone.map_supr_of_continuous_at' Monotone.map_iSup_of_continuousAt'
/-- A monotone function continuous at the infimum of a nonempty set sends this infimum to
the infimum of the image of this set. -/
theorem Monotone.map_sInf_of_continuousAt' {f : α → β} {A : Set α} (Cf : ContinuousAt f (sInf A))
(Mf : Monotone f) (A_nonemp : A.Nonempty) (A_bdd : BddBelow A := by bddDefault) :
f (sInf A) = sInf (f '' A) :=
Monotone.map_sSup_of_continuousAt' (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual A_nonemp A_bdd
#align monotone.map_Inf_of_continuous_at' Monotone.map_sInf_of_continuousAt'
/-- A monotone function continuous at the indexed infimum over a nonempty `Sort` sends this indexed
infimum to the indexed infimum of the composition. -/
| Mathlib/Topology/Order/Monotone.lean | 58 | 62 | theorem Monotone.map_iInf_of_continuousAt' {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α}
(Cf : ContinuousAt f (iInf g)) (Mf : Monotone f)
(bdd : BddBelow (range g) := by | bddDefault) : f (⨅ i, g i) = ⨅ i, f (g i) := by
rw [iInf, Monotone.map_sInf_of_continuousAt' Cf Mf (range_nonempty g) bdd, ← range_comp, iInf]
rfl
|
/-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta
-/
import Mathlib.CategoryTheory.Closed.Cartesian
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.BinaryProducts
import Mathlib.CategoryTheory.Adjunction.FullyFaithful
#align_import category_theory.closed.functor from "leanprover-community/mathlib"@"cea27692b3fdeb328a2ddba6aabf181754543184"
/-!
# Cartesian closed functors
Define the exponential comparison morphisms for a functor which preserves binary products, and use
them to define a cartesian closed functor: one which (naturally) preserves exponentials.
Define the Frobenius morphism, and show it is an isomorphism iff the exponential comparison is an
isomorphism.
## TODO
Some of the results here are true more generally for closed objects and for closed monoidal
categories, and these could be generalised.
## References
https://ncatlab.org/nlab/show/cartesian+closed+functor
https://ncatlab.org/nlab/show/Frobenius+reciprocity
## Tags
Frobenius reciprocity, cartesian closed functor
-/
noncomputable section
namespace CategoryTheory
open Category Limits CartesianClosed
universe v u u'
variable {C : Type u} [Category.{v} C]
variable {D : Type u'} [Category.{v} D]
variable [HasFiniteProducts C] [HasFiniteProducts D]
variable (F : C ⥤ D) {L : D ⥤ C}
/-- The Frobenius morphism for an adjunction `L ⊣ F` at `A` is given by the morphism
L(FA ⨯ B) ⟶ LFA ⨯ LB ⟶ A ⨯ LB
natural in `B`, where the first morphism is the product comparison and the latter uses the counit
of the adjunction.
We will show that if `C` and `D` are cartesian closed, then this morphism is an isomorphism for all
`A` iff `F` is a cartesian closed functor, i.e. it preserves exponentials.
-/
def frobeniusMorphism (h : L ⊣ F) (A : C) :
prod.functor.obj (F.obj A) ⋙ L ⟶ L ⋙ prod.functor.obj A :=
prodComparisonNatTrans L (F.obj A) ≫ whiskerLeft _ (prod.functor.map (h.counit.app _))
#align category_theory.frobenius_morphism CategoryTheory.frobeniusMorphism
/-- If `F` is full and faithful and has a left adjoint `L` which preserves binary products, then the
Frobenius morphism is an isomorphism.
-/
instance frobeniusMorphism_iso_of_preserves_binary_products (h : L ⊣ F) (A : C)
[PreservesLimitsOfShape (Discrete WalkingPair) L] [F.Full] [F.Faithful] :
IsIso (frobeniusMorphism F h A) :=
suffices ∀ (X : D), IsIso ((frobeniusMorphism F h A).app X) from NatIso.isIso_of_isIso_app _
fun B ↦ by dsimp [frobeniusMorphism]; infer_instance
#align category_theory.frobenius_morphism_iso_of_preserves_binary_products CategoryTheory.frobeniusMorphism_iso_of_preserves_binary_products
variable [CartesianClosed C] [CartesianClosed D]
variable [PreservesLimitsOfShape (Discrete WalkingPair) F]
/-- The exponential comparison map.
`F` is a cartesian closed functor if this is an iso for all `A`.
-/
def expComparison (A : C) : exp A ⋙ F ⟶ F ⋙ exp (F.obj A) :=
transferNatTrans (exp.adjunction A) (exp.adjunction (F.obj A)) (prodComparisonNatIso F A).inv
#align category_theory.exp_comparison CategoryTheory.expComparison
theorem expComparison_ev (A B : C) :
Limits.prod.map (𝟙 (F.obj A)) ((expComparison F A).app B) ≫ (exp.ev (F.obj A)).app (F.obj B) =
inv (prodComparison F _ _) ≫ F.map ((exp.ev _).app _) := by
convert transferNatTrans_counit _ _ (prodComparisonNatIso F A).inv B using 2
apply IsIso.inv_eq_of_hom_inv_id -- Porting note: was `ext`
simp only [Limits.prodComparisonNatIso_inv, asIso_inv, NatIso.isIso_inv_app, IsIso.hom_inv_id]
#align category_theory.exp_comparison_ev CategoryTheory.expComparison_ev
| Mathlib/CategoryTheory/Closed/Functor.lean | 91 | 97 | theorem coev_expComparison (A B : C) :
F.map ((exp.coev A).app B) ≫ (expComparison F A).app (A ⨯ B) =
(exp.coev _).app (F.obj B) ≫ (exp (F.obj A)).map (inv (prodComparison F A B)) := by |
convert unit_transferNatTrans _ _ (prodComparisonNatIso F A).inv B using 3
apply IsIso.inv_eq_of_hom_inv_id -- Porting note: was `ext`
dsimp
simp
|
/-
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.NumberTheory.Liouville.Basic
import Mathlib.Topology.Baire.Lemmas
import Mathlib.Topology.Baire.LocallyCompactRegular
import Mathlib.Topology.Instances.Irrational
#align_import number_theory.liouville.residual from "leanprover-community/mathlib"@"32b08ef840dd25ca2e47e035c5da03ce16d2dc3c"
/-!
# Density of Liouville numbers
In this file we prove that the set of Liouville numbers form a dense `Gδ` set. We also prove a
similar statement about irrational numbers.
-/
open scoped Filter
open Filter Set Metric
| Mathlib/NumberTheory/Liouville/Residual.lean | 25 | 31 | theorem setOf_liouville_eq_iInter_iUnion :
{ x | Liouville x } =
⋂ n : ℕ, ⋃ (a : ℤ) (b : ℤ) (_ : 1 < b),
ball ((a : ℝ) / b) (1 / (b : ℝ) ^ n) \ {(a : ℝ) / b} := by |
ext x
simp only [mem_iInter, mem_iUnion, Liouville, mem_setOf_eq, exists_prop, mem_diff,
mem_singleton_iff, mem_ball, Real.dist_eq, and_comm]
|
/-
Copyright (c) 2022 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Batteries.Tactic.SeqFocus
import Batteries.Data.List.Lemmas
import Batteries.Data.List.Init.Attach
namespace Std.Range
/-- The number of elements contained in a `Std.Range`. -/
def numElems (r : Range) : Nat :=
if r.step = 0 then
-- This is a very weird choice, but it is chosen to coincide with the `forIn` impl
if r.stop ≤ r.start then 0 else r.stop
else
(r.stop - r.start + r.step - 1) / r.step
theorem numElems_stop_le_start : ∀ r : Range, r.stop ≤ r.start → r.numElems = 0
| ⟨start, stop, step⟩, h => by
simp [numElems]; split <;> simp_all
apply Nat.div_eq_of_lt; simp [Nat.sub_eq_zero_of_le h]
exact Nat.pred_lt ‹_›
theorem numElems_step_1 (start stop) : numElems ⟨start, stop, 1⟩ = stop - start := by
simp [numElems]
private theorem numElems_le_iff {start stop step i} (hstep : 0 < step) :
(stop - start + step - 1) / step ≤ i ↔ stop ≤ start + step * i :=
calc (stop - start + step - 1) / step ≤ i
_ ↔ stop - start + step - 1 < step * i + step := by
rw [← Nat.lt_succ (n := i), Nat.div_lt_iff_lt_mul hstep, Nat.mul_comm, ← Nat.mul_succ]
_ ↔ stop - start + step - 1 < step * i + 1 + (step - 1) := by
rw [Nat.add_right_comm, Nat.add_assoc, Nat.sub_add_cancel hstep]
_ ↔ stop ≤ start + step * i := by
rw [Nat.add_sub_assoc hstep, Nat.add_lt_add_iff_right, Nat.lt_succ,
Nat.sub_le_iff_le_add']
| .lake/packages/batteries/Batteries/Data/Range/Lemmas.lean | 40 | 47 | theorem mem_range'_elems (r : Range) (h : x ∈ List.range' r.start r.numElems r.step) : x ∈ r := by |
obtain ⟨i, h', rfl⟩ := List.mem_range'.1 h
refine ⟨Nat.le_add_right .., ?_⟩
unfold numElems at h'; split at h'
· split at h' <;> [cases h'; simp_all]
· next step0 =>
refine Nat.not_le.1 fun h =>
Nat.not_le.2 h' <| (numElems_le_iff (Nat.pos_of_ne_zero step0)).2 h
|
/-
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.BigOperators.Group.List
import Mathlib.Data.Vector.Defs
import Mathlib.Data.List.Nodup
import Mathlib.Data.List.OfFn
import Mathlib.Data.List.InsertNth
import Mathlib.Control.Applicative
import Mathlib.Control.Traversable.Basic
#align_import data.vector.basic from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
/-!
# Additional theorems and definitions about the `Vector` type
This file introduces the infix notation `::ᵥ` for `Vector.cons`.
-/
set_option autoImplicit true
universe u
variable {n : ℕ}
namespace Vector
variable {α : Type*}
@[inherit_doc]
infixr:67 " ::ᵥ " => Vector.cons
attribute [simp] head_cons tail_cons
instance [Inhabited α] : Inhabited (Vector α n) :=
⟨ofFn default⟩
theorem toList_injective : Function.Injective (@toList α n) :=
Subtype.val_injective
#align vector.to_list_injective Vector.toList_injective
/-- Two `v w : Vector α n` are equal iff they are equal at every single index. -/
@[ext]
theorem ext : ∀ {v w : Vector α n} (_ : ∀ m : Fin n, Vector.get v m = Vector.get w m), v = w
| ⟨v, hv⟩, ⟨w, hw⟩, h =>
Subtype.eq (List.ext_get (by rw [hv, hw]) fun m hm _ => h ⟨m, hv ▸ hm⟩)
#align vector.ext Vector.ext
/-- The empty `Vector` is a `Subsingleton`. -/
instance zero_subsingleton : Subsingleton (Vector α 0) :=
⟨fun _ _ => Vector.ext fun m => Fin.elim0 m⟩
#align vector.zero_subsingleton Vector.zero_subsingleton
@[simp]
theorem cons_val (a : α) : ∀ v : Vector α n, (a ::ᵥ v).val = a :: v.val
| ⟨_, _⟩ => rfl
#align vector.cons_val Vector.cons_val
#align vector.cons_head Vector.head_cons
#align vector.cons_tail Vector.tail_cons
theorem eq_cons_iff (a : α) (v : Vector α n.succ) (v' : Vector α n) :
v = a ::ᵥ v' ↔ v.head = a ∧ v.tail = v' :=
⟨fun h => h.symm ▸ ⟨head_cons a v', tail_cons a v'⟩, fun h =>
_root_.trans (cons_head_tail v).symm (by rw [h.1, h.2])⟩
#align vector.eq_cons_iff Vector.eq_cons_iff
theorem ne_cons_iff (a : α) (v : Vector α n.succ) (v' : Vector α n) :
v ≠ a ::ᵥ v' ↔ v.head ≠ a ∨ v.tail ≠ v' := by rw [Ne, eq_cons_iff a v v', not_and_or]
#align vector.ne_cons_iff Vector.ne_cons_iff
theorem exists_eq_cons (v : Vector α n.succ) : ∃ (a : α) (as : Vector α n), v = a ::ᵥ as :=
⟨v.head, v.tail, (eq_cons_iff v.head v v.tail).2 ⟨rfl, rfl⟩⟩
#align vector.exists_eq_cons Vector.exists_eq_cons
@[simp]
theorem toList_ofFn : ∀ {n} (f : Fin n → α), toList (ofFn f) = List.ofFn f
| 0, f => by rw [ofFn, List.ofFn_zero, toList, nil]
| n + 1, f => by rw [ofFn, List.ofFn_succ, toList_cons, toList_ofFn]
#align vector.to_list_of_fn Vector.toList_ofFn
@[simp]
theorem mk_toList : ∀ (v : Vector α n) (h), (⟨toList v, h⟩ : Vector α n) = v
| ⟨_, _⟩, _ => rfl
#align vector.mk_to_list Vector.mk_toList
@[simp] theorem length_val (v : Vector α n) : v.val.length = n := v.2
-- Porting note: not used in mathlib and coercions done differently in Lean 4
-- @[simp]
-- theorem length_coe (v : Vector α n) :
-- ((coe : { l : List α // l.length = n } → List α) v).length = n :=
-- v.2
#noalign vector.length_coe
@[simp]
theorem toList_map {β : Type*} (v : Vector α n) (f : α → β) :
(v.map f).toList = v.toList.map f := by cases v; rfl
#align vector.to_list_map Vector.toList_map
@[simp]
theorem head_map {β : Type*} (v : Vector α (n + 1)) (f : α → β) : (v.map f).head = f v.head := by
obtain ⟨a, v', h⟩ := Vector.exists_eq_cons v
rw [h, map_cons, head_cons, head_cons]
#align vector.head_map Vector.head_map
@[simp]
theorem tail_map {β : Type*} (v : Vector α (n + 1)) (f : α → β) :
(v.map f).tail = v.tail.map f := by
obtain ⟨a, v', h⟩ := Vector.exists_eq_cons v
rw [h, map_cons, tail_cons, tail_cons]
#align vector.tail_map Vector.tail_map
theorem get_eq_get (v : Vector α n) (i : Fin n) :
v.get i = v.toList.get (Fin.cast v.toList_length.symm i) :=
rfl
#align vector.nth_eq_nth_le Vector.get_eq_getₓ
@[simp]
theorem get_replicate (a : α) (i : Fin n) : (Vector.replicate n a).get i = a := by
apply List.get_replicate
#align vector.nth_repeat Vector.get_replicate
@[simp]
| Mathlib/Data/Vector/Basic.lean | 129 | 131 | theorem get_map {β : Type*} (v : Vector α n) (f : α → β) (i : Fin n) :
(v.map f).get i = f (v.get i) := by |
cases v; simp [Vector.map, get_eq_get]; rfl
|
/-
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.Topology.Algebra.Module.Multilinear.Bounded
import Mathlib.Topology.Algebra.UniformConvergence
/-!
# Topology on continuous multilinear maps
In this file we define `TopologicalSpace` and `UniformSpace` structures
on `ContinuousMultilinearMap 𝕜 E F`,
where `E i` is a family of vector spaces over `𝕜` with topologies
and `F` is a topological vector space.
-/
open Bornology Set
open scoped Topology UniformConvergence Filter
namespace ContinuousMultilinearMap
variable {𝕜 ι : Type*} {E : ι → Type*} {F : Type*}
[NormedField 𝕜]
[∀ i, TopologicalSpace (E i)] [∀ i, AddCommGroup (E i)] [∀ i, Module 𝕜 (E i)]
[AddCommGroup F] [Module 𝕜 F]
/-- An auxiliary definition used to define topology on `ContinuousMultilinearMap 𝕜 E F`. -/
def toUniformOnFun [TopologicalSpace F] (f : ContinuousMultilinearMap 𝕜 E F) :
(Π i, E i) →ᵤ[{s | IsVonNBounded 𝕜 s}] F :=
UniformOnFun.ofFun _ f
@[simp]
lemma toUniformOnFun_toFun [TopologicalSpace F] (f : ContinuousMultilinearMap 𝕜 E F) :
UniformOnFun.toFun _ f.toUniformOnFun = f :=
rfl
instance instTopologicalSpace [TopologicalSpace F] [TopologicalAddGroup F] :
TopologicalSpace (ContinuousMultilinearMap 𝕜 E F) :=
.induced toUniformOnFun <|
@UniformOnFun.topologicalSpace _ _ (TopologicalAddGroup.toUniformSpace F) _
instance instUniformSpace [UniformSpace F] [UniformAddGroup F] :
UniformSpace (ContinuousMultilinearMap 𝕜 E F) :=
.replaceTopology (.comap toUniformOnFun <| UniformOnFun.uniformSpace _ _ _) <| by
rw [instTopologicalSpace, UniformAddGroup.toUniformSpace_eq]; rfl
section UniformAddGroup
variable [UniformSpace F] [UniformAddGroup F]
lemma uniformEmbedding_toUniformOnFun :
UniformEmbedding (toUniformOnFun : ContinuousMultilinearMap 𝕜 E F → _) where
inj := DFunLike.coe_injective
comap_uniformity := rfl
lemma embedding_toUniformOnFun : Embedding (toUniformOnFun : ContinuousMultilinearMap 𝕜 E F → _) :=
uniformEmbedding_toUniformOnFun.embedding
theorem uniformContinuous_coe_fun [∀ i, ContinuousSMul 𝕜 (E i)] :
UniformContinuous (DFunLike.coe : ContinuousMultilinearMap 𝕜 E F → (Π i, E i) → F) :=
(UniformOnFun.uniformContinuous_toFun isVonNBounded_covers).comp
uniformEmbedding_toUniformOnFun.uniformContinuous
theorem uniformContinuous_eval_const [∀ i, ContinuousSMul 𝕜 (E i)] (x : Π i, E i) :
UniformContinuous fun f : ContinuousMultilinearMap 𝕜 E F ↦ f x :=
uniformContinuous_pi.1 uniformContinuous_coe_fun x
instance instUniformAddGroup : UniformAddGroup (ContinuousMultilinearMap 𝕜 E F) :=
let φ : ContinuousMultilinearMap 𝕜 E F →+ (Π i, E i) →ᵤ[{s | IsVonNBounded 𝕜 s}] F :=
{ toFun := toUniformOnFun, map_add' := fun _ _ ↦ rfl, map_zero' := rfl }
uniformEmbedding_toUniformOnFun.uniformAddGroup φ
instance instUniformContinuousConstSMul {M : Type*}
[Monoid M] [DistribMulAction M F] [SMulCommClass 𝕜 M F] [ContinuousConstSMul M F] :
UniformContinuousConstSMul M (ContinuousMultilinearMap 𝕜 E F) :=
haveI := uniformContinuousConstSMul_of_continuousConstSMul M F
uniformEmbedding_toUniformOnFun.uniformContinuousConstSMul fun _ _ ↦ rfl
end UniformAddGroup
variable [TopologicalSpace F] [TopologicalAddGroup F]
instance instContinuousConstSMul
{M : Type*} [Monoid M] [DistribMulAction M F] [SMulCommClass 𝕜 M F] [ContinuousConstSMul M F] :
ContinuousConstSMul M (ContinuousMultilinearMap 𝕜 E F) := by
letI := TopologicalAddGroup.toUniformSpace F
haveI := comm_topologicalAddGroup_is_uniform (G := F)
infer_instance
instance instContinuousSMul [ContinuousSMul 𝕜 F] :
ContinuousSMul 𝕜 (ContinuousMultilinearMap 𝕜 E F) :=
letI := TopologicalAddGroup.toUniformSpace F
haveI := comm_topologicalAddGroup_is_uniform (G := F)
let φ : ContinuousMultilinearMap 𝕜 E F →ₗ[𝕜] (Π i, E i) → F :=
{ toFun := (↑), map_add' := fun _ _ ↦ rfl, map_smul' := fun _ _ ↦ rfl }
UniformOnFun.continuousSMul_induced_of_image_bounded _ _ _ _ φ
embedding_toUniformOnFun.toInducing fun _ _ hu ↦ hu.image_multilinear _
theorem hasBasis_nhds_zero_of_basis {ι : Type*} {p : ι → Prop} {b : ι → Set F}
(h : (𝓝 (0 : F)).HasBasis p b) :
(𝓝 (0 : ContinuousMultilinearMap 𝕜 E F)).HasBasis
(fun Si : Set (Π i, E i) × ι => IsVonNBounded 𝕜 Si.1 ∧ p Si.2)
fun Si => { f | MapsTo f Si.1 (b Si.2) } := by
letI : UniformSpace F := TopologicalAddGroup.toUniformSpace F
haveI : UniformAddGroup F := comm_topologicalAddGroup_is_uniform
rw [nhds_induced]
refine (UniformOnFun.hasBasis_nhds_zero_of_basis _ ?_ ?_ h).comap DFunLike.coe
· exact ⟨∅, isVonNBounded_empty _ _⟩
· exact directedOn_of_sup_mem fun _ _ => Bornology.IsVonNBounded.union
theorem hasBasis_nhds_zero :
(𝓝 (0 : ContinuousMultilinearMap 𝕜 E F)).HasBasis
(fun SV : Set (Π i, E i) × Set F => IsVonNBounded 𝕜 SV.1 ∧ SV.2 ∈ 𝓝 0) fun SV =>
{ f | MapsTo f SV.1 SV.2 } :=
hasBasis_nhds_zero_of_basis (Filter.basis_sets _)
variable [∀ i, ContinuousSMul 𝕜 (E i)]
| Mathlib/Topology/Algebra/Module/Multilinear/Topology.lean | 119 | 123 | theorem continuous_eval_const (x : Π i, E i) :
Continuous fun p : ContinuousMultilinearMap 𝕜 E F ↦ p x := by |
letI := TopologicalAddGroup.toUniformSpace F
haveI := comm_topologicalAddGroup_is_uniform (G := F)
exact (uniformContinuous_eval_const x).continuous
|
/-
Copyright (c) 2015 Nathaniel Thomas. 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
-/
import Mathlib.Algebra.Group.Indicator
import Mathlib.Algebra.Module.Defs
import Mathlib.Algebra.Order.Field.Rat
import Mathlib.GroupTheory.GroupAction.Group
import Mathlib.GroupTheory.GroupAction.Pi
#align_import algebra.module.basic from "leanprover-community/mathlib"@"30413fc89f202a090a54d78e540963ed3de0056e"
/-!
# Further basic results about modules.
-/
open Function Set
universe u v
variable {α R M M₂ : Type*}
@[deprecated (since := "2024-04-17")]
alias map_nat_cast_smul := map_natCast_smul
theorem map_inv_natCast_smul [AddCommMonoid M] [AddCommMonoid M₂] {F : Type*} [FunLike F M M₂]
[AddMonoidHomClass F M M₂] (f : F) (R S : Type*)
[DivisionSemiring R] [DivisionSemiring S] [Module R M]
[Module S M₂] (n : ℕ) (x : M) : f ((n⁻¹ : R) • x) = (n⁻¹ : S) • f x := by
by_cases hR : (n : R) = 0 <;> by_cases hS : (n : S) = 0
· simp [hR, hS, map_zero f]
· suffices ∀ y, f y = 0 by rw [this, this, smul_zero]
clear x
intro x
rw [← inv_smul_smul₀ hS (f x), ← map_natCast_smul f R S]
simp [hR, map_zero f]
· suffices ∀ y, f y = 0 by simp [this]
clear x
intro x
rw [← smul_inv_smul₀ hR x, map_natCast_smul f R S, hS, zero_smul]
· rw [← inv_smul_smul₀ hS (f _), ← map_natCast_smul f R S, smul_inv_smul₀ hR]
#align map_inv_nat_cast_smul map_inv_natCast_smul
@[deprecated (since := "2024-04-17")]
alias map_inv_nat_cast_smul := map_inv_natCast_smul
theorem map_inv_intCast_smul [AddCommGroup M] [AddCommGroup M₂] {F : Type*} [FunLike F M M₂]
[AddMonoidHomClass F M M₂] (f : F) (R S : Type*) [DivisionRing R] [DivisionRing S] [Module R M]
[Module S M₂] (z : ℤ) (x : M) : f ((z⁻¹ : R) • x) = (z⁻¹ : S) • f x := by
obtain ⟨n, rfl | rfl⟩ := z.eq_nat_or_neg
· rw [Int.cast_natCast, Int.cast_natCast, map_inv_natCast_smul _ R S]
· simp_rw [Int.cast_neg, Int.cast_natCast, inv_neg, neg_smul, map_neg,
map_inv_natCast_smul _ R S]
#align map_inv_int_cast_smul map_inv_intCast_smul
@[deprecated (since := "2024-04-17")]
alias map_inv_int_cast_smul := map_inv_intCast_smul
| Mathlib/Algebra/Module/Basic.lean | 61 | 66 | theorem map_ratCast_smul [AddCommGroup M] [AddCommGroup M₂] {F : Type*} [FunLike F M M₂]
[AddMonoidHomClass F M M₂] (f : F) (R S : Type*) [DivisionRing R] [DivisionRing S] [Module R M]
[Module S M₂] (c : ℚ) (x : M) :
f ((c : R) • x) = (c : S) • f x := by |
rw [Rat.cast_def, Rat.cast_def, div_eq_mul_inv, div_eq_mul_inv, mul_smul, mul_smul,
map_intCast_smul f R S, map_inv_natCast_smul f R S]
|
/-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Algebra.Homology.Linear
import Mathlib.Algebra.Homology.ShortComplex.HomologicalComplex
import Mathlib.Tactic.Abel
#align_import algebra.homology.homotopy from "leanprover-community/mathlib"@"618ea3d5c99240cd7000d8376924906a148bf9ff"
/-!
# Chain homotopies
We define chain homotopies, and prove that homotopic chain maps induce the same map on homology.
-/
universe v u
open scoped Classical
noncomputable section
open CategoryTheory Category Limits HomologicalComplex
variable {ι : Type*}
variable {V : Type u} [Category.{v} V] [Preadditive V]
variable {c : ComplexShape ι} {C D E : HomologicalComplex V c}
variable (f g : C ⟶ D) (h k : D ⟶ E) (i : ι)
section
/-- The composition of `C.d i (c.next i) ≫ f (c.next i) i`. -/
def dNext (i : ι) : (∀ i j, C.X i ⟶ D.X j) →+ (C.X i ⟶ D.X i) :=
AddMonoidHom.mk' (fun f => C.d i (c.next i) ≫ f (c.next i) i) fun _ _ =>
Preadditive.comp_add _ _ _ _ _ _
#align d_next dNext
/-- `f (c.next i) i`. -/
def fromNext (i : ι) : (∀ i j, C.X i ⟶ D.X j) →+ (C.xNext i ⟶ D.X i) :=
AddMonoidHom.mk' (fun f => f (c.next i) i) fun _ _ => rfl
#align from_next fromNext
@[simp]
theorem dNext_eq_dFrom_fromNext (f : ∀ i j, C.X i ⟶ D.X j) (i : ι) :
dNext i f = C.dFrom i ≫ fromNext i f :=
rfl
#align d_next_eq_d_from_from_next dNext_eq_dFrom_fromNext
theorem dNext_eq (f : ∀ i j, C.X i ⟶ D.X j) {i i' : ι} (w : c.Rel i i') :
dNext i f = C.d i i' ≫ f i' i := by
obtain rfl := c.next_eq' w
rfl
#align d_next_eq dNext_eq
lemma dNext_eq_zero (f : ∀ i j, C.X i ⟶ D.X j) (i : ι) (hi : ¬ c.Rel i (c.next i)) :
dNext i f = 0 := by
dsimp [dNext]
rw [shape _ _ _ hi, zero_comp]
@[simp 1100]
theorem dNext_comp_left (f : C ⟶ D) (g : ∀ i j, D.X i ⟶ E.X j) (i : ι) :
(dNext i fun i j => f.f i ≫ g i j) = f.f i ≫ dNext i g :=
(f.comm_assoc _ _ _).symm
#align d_next_comp_left dNext_comp_left
@[simp 1100]
theorem dNext_comp_right (f : ∀ i j, C.X i ⟶ D.X j) (g : D ⟶ E) (i : ι) :
(dNext i fun i j => f i j ≫ g.f j) = dNext i f ≫ g.f i :=
(assoc _ _ _).symm
#align d_next_comp_right dNext_comp_right
/-- The composition `f j (c.prev j) ≫ D.d (c.prev j) j`. -/
def prevD (j : ι) : (∀ i j, C.X i ⟶ D.X j) →+ (C.X j ⟶ D.X j) :=
AddMonoidHom.mk' (fun f => f j (c.prev j) ≫ D.d (c.prev j) j) fun _ _ =>
Preadditive.add_comp _ _ _ _ _ _
#align prev_d prevD
lemma prevD_eq_zero (f : ∀ i j, C.X i ⟶ D.X j) (i : ι) (hi : ¬ c.Rel (c.prev i) i) :
prevD i f = 0 := by
dsimp [prevD]
rw [shape _ _ _ hi, comp_zero]
/-- `f j (c.prev j)`. -/
def toPrev (j : ι) : (∀ i j, C.X i ⟶ D.X j) →+ (C.X j ⟶ D.xPrev j) :=
AddMonoidHom.mk' (fun f => f j (c.prev j)) fun _ _ => rfl
#align to_prev toPrev
@[simp]
theorem prevD_eq_toPrev_dTo (f : ∀ i j, C.X i ⟶ D.X j) (j : ι) :
prevD j f = toPrev j f ≫ D.dTo j :=
rfl
#align prev_d_eq_to_prev_d_to prevD_eq_toPrev_dTo
| Mathlib/Algebra/Homology/Homotopy.lean | 96 | 99 | theorem prevD_eq (f : ∀ i j, C.X i ⟶ D.X j) {j j' : ι} (w : c.Rel j' j) :
prevD j f = f j j' ≫ D.d j' j := by |
obtain rfl := c.prev_eq' w
rfl
|
/-
Copyright (c) 2022 Anatole Dedecker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker
-/
import Mathlib.Analysis.InnerProductSpace.Adjoint
#align_import analysis.inner_product_space.positive from "leanprover-community/mathlib"@"caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c"
/-!
# Positive operators
In this file we define positive operators in a Hilbert space. We follow Bourbaki's choice
of requiring self adjointness in the definition.
## Main definitions
* `IsPositive` : a continuous linear map is positive if it is self adjoint and
`∀ x, 0 ≤ re ⟪T x, x⟫`
## Main statements
* `ContinuousLinearMap.IsPositive.conj_adjoint` : if `T : E →L[𝕜] E` is positive,
then for any `S : E →L[𝕜] F`, `S ∘L T ∘L S†` is also positive.
* `ContinuousLinearMap.isPositive_iff_complex` : in a ***complex*** Hilbert space,
checking that `⟪T x, x⟫` is a nonnegative real number for all `x` suffices to prove that
`T` is positive
## References
* [Bourbaki, *Topological Vector Spaces*][bourbaki1987]
## Tags
Positive operator
-/
open InnerProductSpace RCLike ContinuousLinearMap
open scoped InnerProduct ComplexConjugate
namespace ContinuousLinearMap
variable {𝕜 E F : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup E] [NormedAddCommGroup F]
variable [InnerProductSpace 𝕜 E] [InnerProductSpace 𝕜 F]
variable [CompleteSpace E] [CompleteSpace F]
local notation "⟪" x ", " y "⟫" => @inner 𝕜 _ _ x y
/-- A continuous linear endomorphism `T` of a Hilbert space is **positive** if it is self adjoint
and `∀ x, 0 ≤ re ⟪T x, x⟫`. -/
def IsPositive (T : E →L[𝕜] E) : Prop :=
IsSelfAdjoint T ∧ ∀ x, 0 ≤ T.reApplyInnerSelf x
#align continuous_linear_map.is_positive ContinuousLinearMap.IsPositive
theorem IsPositive.isSelfAdjoint {T : E →L[𝕜] E} (hT : IsPositive T) : IsSelfAdjoint T :=
hT.1
#align continuous_linear_map.is_positive.is_self_adjoint ContinuousLinearMap.IsPositive.isSelfAdjoint
theorem IsPositive.inner_nonneg_left {T : E →L[𝕜] E} (hT : IsPositive T) (x : E) :
0 ≤ re ⟪T x, x⟫ :=
hT.2 x
#align continuous_linear_map.is_positive.inner_nonneg_left ContinuousLinearMap.IsPositive.inner_nonneg_left
theorem IsPositive.inner_nonneg_right {T : E →L[𝕜] E} (hT : IsPositive T) (x : E) :
0 ≤ re ⟪x, T x⟫ := by rw [inner_re_symm]; exact hT.inner_nonneg_left x
#align continuous_linear_map.is_positive.inner_nonneg_right ContinuousLinearMap.IsPositive.inner_nonneg_right
theorem isPositive_zero : IsPositive (0 : E →L[𝕜] E) := by
refine ⟨isSelfAdjoint_zero _, fun x => ?_⟩
change 0 ≤ re ⟪_, _⟫
rw [zero_apply, inner_zero_left, ZeroHomClass.map_zero]
#align continuous_linear_map.is_positive_zero ContinuousLinearMap.isPositive_zero
theorem isPositive_one : IsPositive (1 : E →L[𝕜] E) :=
⟨isSelfAdjoint_one _, fun _ => inner_self_nonneg⟩
#align continuous_linear_map.is_positive_one ContinuousLinearMap.isPositive_one
theorem IsPositive.add {T S : E →L[𝕜] E} (hT : T.IsPositive) (hS : S.IsPositive) :
(T + S).IsPositive := by
refine ⟨hT.isSelfAdjoint.add hS.isSelfAdjoint, fun x => ?_⟩
rw [reApplyInnerSelf, add_apply, inner_add_left, map_add]
exact add_nonneg (hT.inner_nonneg_left x) (hS.inner_nonneg_left x)
#align continuous_linear_map.is_positive.add ContinuousLinearMap.IsPositive.add
theorem IsPositive.conj_adjoint {T : E →L[𝕜] E} (hT : T.IsPositive) (S : E →L[𝕜] F) :
(S ∘L T ∘L S†).IsPositive := by
refine ⟨hT.isSelfAdjoint.conj_adjoint S, fun x => ?_⟩
rw [reApplyInnerSelf, comp_apply, ← adjoint_inner_right]
exact hT.inner_nonneg_left _
#align continuous_linear_map.is_positive.conj_adjoint ContinuousLinearMap.IsPositive.conj_adjoint
theorem IsPositive.adjoint_conj {T : E →L[𝕜] E} (hT : T.IsPositive) (S : F →L[𝕜] E) :
(S† ∘L T ∘L S).IsPositive := by
convert hT.conj_adjoint (S†)
rw [adjoint_adjoint]
#align continuous_linear_map.is_positive.adjoint_conj ContinuousLinearMap.IsPositive.adjoint_conj
theorem IsPositive.conj_orthogonalProjection (U : Submodule 𝕜 E) {T : E →L[𝕜] E} (hT : T.IsPositive)
[CompleteSpace U] :
(U.subtypeL ∘L
orthogonalProjection U ∘L T ∘L U.subtypeL ∘L orthogonalProjection U).IsPositive := by
have := hT.conj_adjoint (U.subtypeL ∘L orthogonalProjection U)
rwa [(orthogonalProjection_isSelfAdjoint U).adjoint_eq] at this
#align continuous_linear_map.is_positive.conj_orthogonal_projection ContinuousLinearMap.IsPositive.conj_orthogonalProjection
| Mathlib/Analysis/InnerProductSpace/Positive.lean | 109 | 112 | theorem IsPositive.orthogonalProjection_comp {T : E →L[𝕜] E} (hT : T.IsPositive) (U : Submodule 𝕜 E)
[CompleteSpace U] : (orthogonalProjection U ∘L T ∘L U.subtypeL).IsPositive := by |
have := hT.conj_adjoint (orthogonalProjection U : E →L[𝕜] U)
rwa [U.adjoint_orthogonalProjection] at this
|
/-
Copyright (c) 2024 Mitchell Lee. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mitchell Lee
-/
import Mathlib.Data.ZMod.Basic
import Mathlib.GroupTheory.Coxeter.Basic
/-!
# The length function, reduced words, and descents
Throughout this file, `B` is a type and `M : CoxeterMatrix B` is a Coxeter matrix.
`cs : CoxeterSystem M W` is a Coxeter system; that is, `W` is a group, and `cs` holds the data
of a group isomorphism `W ≃* M.group`, where `M.group` refers to the quotient of the free group on
`B` by the Coxeter relations given by the matrix `M`. See `Mathlib/GroupTheory/Coxeter/Basic.lean`
for more details.
Given any element $w \in W$, its *length* (`CoxeterSystem.length`), denoted $\ell(w)$, is the
minimum number $\ell$ such that $w$ can be written as a product of a sequence of $\ell$ simple
reflections:
$$w = s_{i_1} \cdots s_{i_\ell}.$$
We prove for all $w_1, w_2 \in W$ that $\ell (w_1 w_2) \leq \ell (w_1) + \ell (w_2)$
and that $\ell (w_1 w_2)$ has the same parity as $\ell (w_1) + \ell (w_2)$.
We define a *reduced word* (`CoxeterSystem.IsReduced`) for an element $w \in W$ to be a way of
writing $w$ as a product of exactly $\ell(w)$ simple reflections. Every element of $W$ has a reduced
word.
We say that $i \in B$ is a *left descent* (`CoxeterSystem.IsLeftDescent`) of $w \in W$ if
$\ell(s_i w) < \ell(w)$. We show that if $i$ is a left descent of $w$, then
$\ell(s_i w) + 1 = \ell(w)$. On the other hand, if $i$ is not a left descent of $w$, then
$\ell(s_i w) = \ell(w) + 1$. We similarly define right descents (`CoxeterSystem.IsRightDescent`) and
prove analogous results.
## Main definitions
* `cs.length`
* `cs.IsReduced`
* `cs.IsLeftDescent`
* `cs.IsRightDescent`
## References
* [A. Björner and F. Brenti, *Combinatorics of Coxeter Groups*](bjorner2005)
-/
namespace CoxeterSystem
open List Matrix Function Classical
variable {B : Type*}
variable {W : Type*} [Group W]
variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W)
local prefix:100 "s" => cs.simple
local prefix:100 "π" => cs.wordProd
/-! ### Length -/
private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by
rcases cs.wordProd_surjective w with ⟨ω, rfl⟩
use ω.length, ω
/-- The length of `w`; i.e., the minimum number of simple reflections that
must be multiplied to form `w`. -/
noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w)
local prefix:100 "ℓ" => cs.length
| Mathlib/GroupTheory/Coxeter/Length.lean | 71 | 73 | theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by |
have := Nat.find_spec (cs.exists_word_with_prod w)
tauto
|
/-
Copyright (c) 2019 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon
-/
import Mathlib.Control.Bitraversable.Basic
#align_import control.bitraversable.lemmas from "leanprover-community/mathlib"@"58581d0fe523063f5651df0619be2bf65012a94a"
/-!
# Bitraversable Lemmas
## Main definitions
* tfst - traverse on first functor argument
* tsnd - traverse on second functor argument
## Lemmas
Combination of
* bitraverse
* tfst
* tsnd
with the applicatives `id` and `comp`
## References
* Hackage: <https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bitraversable.html>
## Tags
traversable bitraversable functor bifunctor applicative
-/
universe u
variable {t : Type u → Type u → Type u} [Bitraversable t]
variable {β : Type u}
namespace Bitraversable
open Functor LawfulApplicative
variable {F G : Type u → Type u} [Applicative F] [Applicative G]
/-- traverse on the first functor argument -/
abbrev tfst {α α'} (f : α → F α') : t α β → F (t α' β) :=
bitraverse f pure
#align bitraversable.tfst Bitraversable.tfst
/-- traverse on the second functor argument -/
abbrev tsnd {α α'} (f : α → F α') : t β α → F (t β α') :=
bitraverse pure f
#align bitraversable.tsnd Bitraversable.tsnd
variable [LawfulBitraversable t] [LawfulApplicative F] [LawfulApplicative G]
@[higher_order tfst_id]
theorem id_tfst : ∀ {α β} (x : t α β), tfst (F := Id) pure x = pure x :=
id_bitraverse
#align bitraversable.id_tfst Bitraversable.id_tfst
@[higher_order tsnd_id]
theorem id_tsnd : ∀ {α β} (x : t α β), tsnd (F := Id) pure x = pure x :=
id_bitraverse
#align bitraversable.id_tsnd Bitraversable.id_tsnd
@[higher_order tfst_comp_tfst]
theorem comp_tfst {α₀ α₁ α₂ β} (f : α₀ → F α₁) (f' : α₁ → G α₂) (x : t α₀ β) :
Comp.mk (tfst f' <$> tfst f x) = tfst (Comp.mk ∘ map f' ∘ f) x := by
rw [← comp_bitraverse]
simp only [Function.comp, tfst, map_pure, Pure.pure]
#align bitraversable.comp_tfst Bitraversable.comp_tfst
@[higher_order tfst_comp_tsnd]
| Mathlib/Control/Bitraversable/Lemmas.lean | 79 | 83 | theorem tfst_tsnd {α₀ α₁ β₀ β₁} (f : α₀ → F α₁) (f' : β₀ → G β₁) (x : t α₀ β₀) :
Comp.mk (tfst f <$> tsnd f' x)
= bitraverse (Comp.mk ∘ pure ∘ f) (Comp.mk ∘ map pure ∘ f') x := by |
rw [← comp_bitraverse]
simp only [Function.comp, map_pure]
|
/-
Copyright (c) 2020 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau
-/
import Mathlib.Algebra.Polynomial.Expand
import Mathlib.Algebra.Polynomial.Splits
import Mathlib.Algebra.Squarefree.Basic
import Mathlib.FieldTheory.Minpoly.Field
import Mathlib.RingTheory.PowerBasis
#align_import field_theory.separable from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7"
/-!
# Separable polynomials
We define a polynomial to be separable if it is coprime with its derivative. We prove basic
properties about separable polynomials here.
## Main definitions
* `Polynomial.Separable f`: a polynomial `f` is separable iff it is coprime with its derivative.
-/
universe u v w
open scoped Classical
open Polynomial Finset
namespace Polynomial
section CommSemiring
variable {R : Type u} [CommSemiring R] {S : Type v} [CommSemiring S]
/-- A polynomial is separable iff it is coprime with its derivative. -/
def Separable (f : R[X]) : Prop :=
IsCoprime f (derivative f)
#align polynomial.separable Polynomial.Separable
theorem separable_def (f : R[X]) : f.Separable ↔ IsCoprime f (derivative f) :=
Iff.rfl
#align polynomial.separable_def Polynomial.separable_def
theorem separable_def' (f : R[X]) : f.Separable ↔ ∃ a b : R[X], a * f + b * (derivative f) = 1 :=
Iff.rfl
#align polynomial.separable_def' Polynomial.separable_def'
theorem not_separable_zero [Nontrivial R] : ¬Separable (0 : R[X]) := by
rintro ⟨x, y, h⟩
simp only [derivative_zero, mul_zero, add_zero, zero_ne_one] at h
#align polynomial.not_separable_zero Polynomial.not_separable_zero
theorem Separable.ne_zero [Nontrivial R] {f : R[X]} (h : f.Separable) : f ≠ 0 :=
(not_separable_zero <| · ▸ h)
@[simp]
theorem separable_one : (1 : R[X]).Separable :=
isCoprime_one_left
#align polynomial.separable_one Polynomial.separable_one
@[nontriviality]
theorem separable_of_subsingleton [Subsingleton R] (f : R[X]) : f.Separable := by
simp [Separable, IsCoprime, eq_iff_true_of_subsingleton]
#align polynomial.separable_of_subsingleton Polynomial.separable_of_subsingleton
theorem separable_X_add_C (a : R) : (X + C a).Separable := by
rw [separable_def, derivative_add, derivative_X, derivative_C, add_zero]
exact isCoprime_one_right
set_option linter.uppercaseLean3 false in
#align polynomial.separable_X_add_C Polynomial.separable_X_add_C
| Mathlib/FieldTheory/Separable.lean | 76 | 78 | theorem separable_X : (X : R[X]).Separable := by |
rw [separable_def, derivative_X]
exact isCoprime_one_right
|
/-
Copyright (c) 2022 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov
-/
import Mathlib.Topology.Bornology.Basic
#align_import topology.bornology.constructions from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d"
/-!
# Bornology structure on products and subtypes
In this file we define `Bornology` and `BoundedSpace` instances on `α × β`, `Π i, π i`, and
`{x // p x}`. We also prove basic lemmas about `Bornology.cobounded` and `Bornology.IsBounded`
on these types.
-/
open Set Filter Bornology Function
open Filter
variable {α β ι : Type*} {π : ι → Type*} [Bornology α] [Bornology β]
[∀ i, Bornology (π i)]
instance Prod.instBornology : Bornology (α × β) where
cobounded' := (cobounded α).coprod (cobounded β)
le_cofinite' :=
@coprod_cofinite α β ▸ coprod_mono ‹Bornology α›.le_cofinite ‹Bornology β›.le_cofinite
#align prod.bornology Prod.instBornology
instance Pi.instBornology : Bornology (∀ i, π i) where
cobounded' := Filter.coprodᵢ fun i => cobounded (π i)
le_cofinite' := iSup_le fun _ ↦ (comap_mono (Bornology.le_cofinite _)).trans (comap_cofinite_le _)
#align pi.bornology Pi.instBornology
/-- Inverse image of a bornology. -/
abbrev Bornology.induced {α β : Type*} [Bornology β] (f : α → β) : Bornology α where
cobounded' := comap f (cobounded β)
le_cofinite' := (comap_mono (Bornology.le_cofinite β)).trans (comap_cofinite_le _)
#align bornology.induced Bornology.induced
instance {p : α → Prop} : Bornology (Subtype p) :=
Bornology.induced (Subtype.val : Subtype p → α)
namespace Bornology
/-!
### Bounded sets in `α × β`
-/
theorem cobounded_prod : cobounded (α × β) = (cobounded α).coprod (cobounded β) :=
rfl
#align bornology.cobounded_prod Bornology.cobounded_prod
theorem isBounded_image_fst_and_snd {s : Set (α × β)} :
IsBounded (Prod.fst '' s) ∧ IsBounded (Prod.snd '' s) ↔ IsBounded s :=
compl_mem_coprod.symm
#align bornology.is_bounded_image_fst_and_snd Bornology.isBounded_image_fst_and_snd
lemma IsBounded.image_fst {s : Set (α × β)} (hs : IsBounded s) : IsBounded (Prod.fst '' s) :=
(isBounded_image_fst_and_snd.2 hs).1
lemma IsBounded.image_snd {s : Set (α × β)} (hs : IsBounded s) : IsBounded (Prod.snd '' s) :=
(isBounded_image_fst_and_snd.2 hs).2
variable {s : Set α} {t : Set β} {S : ∀ i, Set (π i)}
theorem IsBounded.fst_of_prod (h : IsBounded (s ×ˢ t)) (ht : t.Nonempty) : IsBounded s :=
fst_image_prod s ht ▸ h.image_fst
#align bornology.is_bounded.fst_of_prod Bornology.IsBounded.fst_of_prod
theorem IsBounded.snd_of_prod (h : IsBounded (s ×ˢ t)) (hs : s.Nonempty) : IsBounded t :=
snd_image_prod hs t ▸ h.image_snd
#align bornology.is_bounded.snd_of_prod Bornology.IsBounded.snd_of_prod
theorem IsBounded.prod (hs : IsBounded s) (ht : IsBounded t) : IsBounded (s ×ˢ t) :=
isBounded_image_fst_and_snd.1
⟨hs.subset <| fst_image_prod_subset _ _, ht.subset <| snd_image_prod_subset _ _⟩
#align bornology.is_bounded.prod Bornology.IsBounded.prod
theorem isBounded_prod_of_nonempty (hne : Set.Nonempty (s ×ˢ t)) :
IsBounded (s ×ˢ t) ↔ IsBounded s ∧ IsBounded t :=
⟨fun h => ⟨h.fst_of_prod hne.snd, h.snd_of_prod hne.fst⟩, fun h => h.1.prod h.2⟩
#align bornology.is_bounded_prod_of_nonempty Bornology.isBounded_prod_of_nonempty
| Mathlib/Topology/Bornology/Constructions.lean | 88 | 91 | theorem isBounded_prod : IsBounded (s ×ˢ t) ↔ s = ∅ ∨ t = ∅ ∨ IsBounded s ∧ IsBounded t := by |
rcases s.eq_empty_or_nonempty with (rfl | hs); · simp
rcases t.eq_empty_or_nonempty with (rfl | ht); · simp
simp only [hs.ne_empty, ht.ne_empty, isBounded_prod_of_nonempty (hs.prod ht), false_or_iff]
|
/-
Copyright (c) 2021 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rémy Degenne
-/
import Mathlib.MeasureTheory.Function.LpSeminorm.Basic
import Mathlib.MeasureTheory.Integral.MeanInequalities
#align_import measure_theory.function.lp_seminorm from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9"
/-!
# Triangle inequality for `Lp`-seminorm
In this file we prove several versions of the triangle inequality for the `Lp` seminorm,
as well as simple corollaries.
-/
open Filter
open scoped ENNReal Topology
namespace MeasureTheory
variable {α E : Type*} {m : MeasurableSpace α} [NormedAddCommGroup E]
{p : ℝ≥0∞} {q : ℝ} {μ : Measure α} {f g : α → E}
theorem snorm'_add_le {f g : α → E} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ)
(hq1 : 1 ≤ q) : snorm' (f + g) q μ ≤ snorm' f q μ + snorm' g q μ :=
calc
(∫⁻ a, (‖(f + g) a‖₊ : ℝ≥0∞) ^ q ∂μ) ^ (1 / q) ≤
(∫⁻ a, ((fun a => (‖f a‖₊ : ℝ≥0∞)) + fun a => (‖g a‖₊ : ℝ≥0∞)) a ^ q ∂μ) ^ (1 / q) := by
gcongr with a
simp only [Pi.add_apply, ← ENNReal.coe_add, ENNReal.coe_le_coe, nnnorm_add_le]
_ ≤ snorm' f q μ + snorm' g q μ := ENNReal.lintegral_Lp_add_le hf.ennnorm hg.ennnorm hq1
#align measure_theory.snorm'_add_le MeasureTheory.snorm'_add_le
theorem snorm'_add_le_of_le_one {f g : α → E} (hf : AEStronglyMeasurable f μ) (hq0 : 0 ≤ q)
(hq1 : q ≤ 1) : snorm' (f + g) q μ ≤ (2 : ℝ≥0∞) ^ (1 / q - 1) * (snorm' f q μ + snorm' g q μ) :=
calc
(∫⁻ a, (‖(f + g) a‖₊ : ℝ≥0∞) ^ q ∂μ) ^ (1 / q) ≤
(∫⁻ a, ((fun a => (‖f a‖₊ : ℝ≥0∞)) + fun a => (‖g a‖₊ : ℝ≥0∞)) a ^ q ∂μ) ^ (1 / q) := by
gcongr with a
simp only [Pi.add_apply, ← ENNReal.coe_add, ENNReal.coe_le_coe, nnnorm_add_le]
_ ≤ (2 : ℝ≥0∞) ^ (1 / q - 1) * (snorm' f q μ + snorm' g q μ) :=
ENNReal.lintegral_Lp_add_le_of_le_one hf.ennnorm hq0 hq1
#align measure_theory.snorm'_add_le_of_le_one MeasureTheory.snorm'_add_le_of_le_one
theorem snormEssSup_add_le {f g : α → E} :
snormEssSup (f + g) μ ≤ snormEssSup f μ + snormEssSup g μ := by
refine le_trans (essSup_mono_ae (eventually_of_forall fun x => ?_)) (ENNReal.essSup_add_le _ _)
simp_rw [Pi.add_apply, ← ENNReal.coe_add, ENNReal.coe_le_coe]
exact nnnorm_add_le _ _
#align measure_theory.snorm_ess_sup_add_le MeasureTheory.snormEssSup_add_le
theorem snorm_add_le {f g : α → E} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ)
(hp1 : 1 ≤ p) : snorm (f + g) p μ ≤ snorm f p μ + snorm g p μ := by
by_cases hp0 : p = 0
· simp [hp0]
by_cases hp_top : p = ∞
· simp [hp_top, snormEssSup_add_le]
have hp1_real : 1 ≤ p.toReal := by
rwa [← ENNReal.one_toReal, ENNReal.toReal_le_toReal ENNReal.one_ne_top hp_top]
repeat rw [snorm_eq_snorm' hp0 hp_top]
exact snorm'_add_le hf hg hp1_real
#align measure_theory.snorm_add_le MeasureTheory.snorm_add_le
/-- A constant for the inequality `‖f + g‖_{L^p} ≤ C * (‖f‖_{L^p} + ‖g‖_{L^p})`. It is equal to `1`
for `p ≥ 1` or `p = 0`, and `2^(1/p-1)` in the more tricky interval `(0, 1)`. -/
noncomputable def LpAddConst (p : ℝ≥0∞) : ℝ≥0∞ :=
if p ∈ Set.Ioo (0 : ℝ≥0∞) 1 then (2 : ℝ≥0∞) ^ (1 / p.toReal - 1) else 1
set_option linter.uppercaseLean3 false in
#align measure_theory.Lp_add_const MeasureTheory.LpAddConst
theorem LpAddConst_of_one_le {p : ℝ≥0∞} (hp : 1 ≤ p) : LpAddConst p = 1 := by
rw [LpAddConst, if_neg]
intro h
exact lt_irrefl _ (h.2.trans_le hp)
set_option linter.uppercaseLean3 false in
#align measure_theory.Lp_add_const_of_one_le MeasureTheory.LpAddConst_of_one_le
theorem LpAddConst_zero : LpAddConst 0 = 1 := by
rw [LpAddConst, if_neg]
intro h
exact lt_irrefl _ h.1
set_option linter.uppercaseLean3 false in
#align measure_theory.Lp_add_const_zero MeasureTheory.LpAddConst_zero
| Mathlib/MeasureTheory/Function/LpSeminorm/TriangleInequality.lean | 87 | 94 | theorem LpAddConst_lt_top (p : ℝ≥0∞) : LpAddConst p < ∞ := by |
rw [LpAddConst]
split_ifs with h
· apply ENNReal.rpow_lt_top_of_nonneg _ ENNReal.two_ne_top
simp only [one_div, sub_nonneg]
apply one_le_inv (ENNReal.toReal_pos h.1.ne' (h.2.trans ENNReal.one_lt_top).ne)
simpa using ENNReal.toReal_mono ENNReal.one_ne_top h.2.le
· exact ENNReal.one_lt_top
|
/-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Chris Hughes, Mario Carneiro
-/
import Mathlib.Tactic.FinCases
import Mathlib.Data.Nat.Choose.Sum
import Mathlib.LinearAlgebra.Finsupp
import Mathlib.Algebra.Field.IsField
#align_import ring_theory.ideal.basic from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988"
/-!
# Ideals over a ring
This file defines `Ideal R`, the type of (left) ideals over a ring `R`.
Note that over commutative rings, left ideals and two-sided ideals are equivalent.
## Implementation notes
`Ideal R` is implemented using `Submodule R R`, where `•` is interpreted as `*`.
## TODO
Support right ideals, and two-sided ideals over non-commutative rings.
-/
universe u v w
variable {α : Type u} {β : Type v}
open Set Function
open Pointwise
/-- A (left) ideal in a semiring `R` is an additive submonoid `s` such that
`a * b ∈ s` whenever `b ∈ s`. If `R` is a ring, then `s` is an additive subgroup. -/
abbrev Ideal (R : Type u) [Semiring R] :=
Submodule R R
#align ideal Ideal
/-- A ring is a principal ideal ring if all (left) ideals are principal. -/
@[mk_iff]
class IsPrincipalIdealRing (R : Type u) [Semiring R] : Prop where
principal : ∀ S : Ideal R, S.IsPrincipal
#align is_principal_ideal_ring IsPrincipalIdealRing
attribute [instance] IsPrincipalIdealRing.principal
section Semiring
namespace Ideal
variable [Semiring α] (I : Ideal α) {a b : α}
protected theorem zero_mem : (0 : α) ∈ I :=
Submodule.zero_mem I
#align ideal.zero_mem Ideal.zero_mem
protected theorem add_mem : a ∈ I → b ∈ I → a + b ∈ I :=
Submodule.add_mem I
#align ideal.add_mem Ideal.add_mem
variable (a)
theorem mul_mem_left : b ∈ I → a * b ∈ I :=
Submodule.smul_mem I a
#align ideal.mul_mem_left Ideal.mul_mem_left
variable {a}
@[ext]
theorem ext {I J : Ideal α} (h : ∀ x, x ∈ I ↔ x ∈ J) : I = J :=
Submodule.ext h
#align ideal.ext Ideal.ext
theorem sum_mem (I : Ideal α) {ι : Type*} {t : Finset ι} {f : ι → α} :
(∀ c ∈ t, f c ∈ I) → (∑ i ∈ t, f i) ∈ I :=
Submodule.sum_mem I
#align ideal.sum_mem Ideal.sum_mem
theorem eq_top_of_unit_mem (x y : α) (hx : x ∈ I) (h : y * x = 1) : I = ⊤ :=
eq_top_iff.2 fun z _ =>
calc
z = z * (y * x) := by simp [h]
_ = z * y * x := Eq.symm <| mul_assoc z y x
_ ∈ I := I.mul_mem_left _ hx
#align ideal.eq_top_of_unit_mem Ideal.eq_top_of_unit_mem
theorem eq_top_of_isUnit_mem {x} (hx : x ∈ I) (h : IsUnit x) : I = ⊤ :=
let ⟨y, hy⟩ := h.exists_left_inv
eq_top_of_unit_mem I x y hx hy
#align ideal.eq_top_of_is_unit_mem Ideal.eq_top_of_isUnit_mem
theorem eq_top_iff_one : I = ⊤ ↔ (1 : α) ∈ I :=
⟨by rintro rfl; trivial, fun h => eq_top_of_unit_mem _ _ 1 h (by simp)⟩
#align ideal.eq_top_iff_one Ideal.eq_top_iff_one
theorem ne_top_iff_one : I ≠ ⊤ ↔ (1 : α) ∉ I :=
not_congr I.eq_top_iff_one
#align ideal.ne_top_iff_one Ideal.ne_top_iff_one
@[simp]
| Mathlib/RingTheory/Ideal/Basic.lean | 106 | 110 | theorem unit_mul_mem_iff_mem {x y : α} (hy : IsUnit y) : y * x ∈ I ↔ x ∈ I := by |
refine ⟨fun h => ?_, fun h => I.mul_mem_left y h⟩
obtain ⟨y', hy'⟩ := hy.exists_left_inv
have := I.mul_mem_left y' h
rwa [← mul_assoc, hy', one_mul] at this
|
/-
Copyright (c) 2015 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Robert Y. Lewis
-/
import Mathlib.Algebra.Order.Monoid.Unbundled.Pow
import Mathlib.Algebra.Order.Ring.Defs
import Mathlib.Algebra.Ring.Parity
#align_import algebra.group_power.order from "leanprover-community/mathlib"@"00f91228655eecdcd3ac97a7fd8dbcb139fe990a"
/-!
# Basic lemmas about ordered rings
-/
-- We should need only a minimal development of sets in order to get here.
assert_not_exists Set.Subsingleton
open Function Int
variable {α M R : Type*}
namespace MonoidHom
variable [Ring R] [Monoid M] [LinearOrder M] [CovariantClass M M (· * ·) (· ≤ ·)] (f : R →* M)
theorem map_neg_one : f (-1) = 1 :=
(pow_eq_one_iff (Nat.succ_ne_zero 1)).1 <| by rw [← map_pow, neg_one_sq, map_one]
#align monoid_hom.map_neg_one MonoidHom.map_neg_one
@[simp]
theorem map_neg (x : R) : f (-x) = f x := by rw [← neg_one_mul, map_mul, map_neg_one, one_mul]
#align monoid_hom.map_neg MonoidHom.map_neg
| Mathlib/Algebra/Order/Ring/Basic.lean | 35 | 35 | theorem map_sub_swap (x y : R) : f (x - y) = f (y - x) := by | rw [← map_neg, neg_sub]
|
/-
Copyright (c) 2022 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Batteries.Tactic.SeqFocus
/-! ## Ordering -/
namespace Ordering
@[simp] theorem swap_swap {o : Ordering} : o.swap.swap = o := by cases o <;> rfl
@[simp] theorem swap_inj {o₁ o₂ : Ordering} : o₁.swap = o₂.swap ↔ o₁ = o₂ :=
⟨fun h => by simpa using congrArg swap h, congrArg _⟩
theorem swap_then (o₁ o₂ : Ordering) : (o₁.then o₂).swap = o₁.swap.then o₂.swap := by
cases o₁ <;> rfl
theorem then_eq_lt {o₁ o₂ : Ordering} : o₁.then o₂ = lt ↔ o₁ = lt ∨ o₁ = eq ∧ o₂ = lt := by
cases o₁ <;> cases o₂ <;> decide
| .lake/packages/batteries/Batteries/Classes/Order.lean | 23 | 24 | theorem then_eq_eq {o₁ o₂ : Ordering} : o₁.then o₂ = eq ↔ o₁ = eq ∧ o₂ = eq := by |
cases o₁ <;> simp [«then»]
|
/-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Data.Vector.Basic
import Mathlib.Data.List.Zip
#align_import data.vector.zip from "leanprover-community/mathlib"@"1126441d6bccf98c81214a0780c73d499f6721fe"
/-!
# The `zipWith` operation on vectors.
-/
namespace Vector
section ZipWith
variable {α β γ : Type*} {n : ℕ} (f : α → β → γ)
/-- Apply the function `f : α → β → γ` to each corresponding pair of elements from two vectors. -/
def zipWith : Vector α n → Vector β n → Vector γ n := fun x y => ⟨List.zipWith f x.1 y.1, by simp⟩
#align vector.zip_with Vector.zipWith
@[simp]
theorem zipWith_toList (x : Vector α n) (y : Vector β n) :
(Vector.zipWith f x y).toList = List.zipWith f x.toList y.toList :=
rfl
#align vector.zip_with_to_list Vector.zipWith_toList
@[simp]
theorem zipWith_get (x : Vector α n) (y : Vector β n) (i) :
(Vector.zipWith f x y).get i = f (x.get i) (y.get i) := by
dsimp only [Vector.zipWith, Vector.get]
simp only [List.get_zipWith, Fin.cast]
#align vector.zip_with_nth Vector.zipWith_get
@[simp]
| Mathlib/Data/Vector/Zip.lean | 40 | 43 | theorem zipWith_tail (x : Vector α n) (y : Vector β n) :
(Vector.zipWith f x y).tail = Vector.zipWith f x.tail y.tail := by |
ext
simp [get_tail]
|
/-
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}
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⟩
#align finset.Icc_eq_image_powerset Finset.Icc_eq_image_powerset
theorem Ico_eq_image_ssubsets (h : s ⊆ t) : Ico s t = (t \ s).ssubsets.image (s ∪ ·) := by
ext u
simp_rw [mem_Ico, mem_image, mem_ssubsets]
constructor
· rintro ⟨hs, ht⟩
exact ⟨u \ s, sdiff_lt_sdiff_right ht hs, sup_sdiff_cancel_right hs⟩
· rintro ⟨v, hv, rfl⟩
exact ⟨le_sup_left, sup_lt_of_lt_sdiff_left hv h⟩
#align finset.Ico_eq_image_ssubsets Finset.Ico_eq_image_ssubsets
/-- Cardinality of a non-empty `Icc` of finsets. -/
theorem card_Icc_finset (h : s ⊆ t) : (Icc s t).card = 2 ^ (t.card - s.card) := by
rw [← card_sdiff h, ← card_powerset, Icc_eq_image_powerset h, Finset.card_image_iff]
rintro u hu v hv (huv : s ⊔ u = s ⊔ v)
rw [mem_coe, mem_powerset] at hu hv
rw [← (disjoint_sdiff.mono_right hu : Disjoint s u).sup_sdiff_cancel_left, ←
(disjoint_sdiff.mono_right hv : Disjoint s v).sup_sdiff_cancel_left, huv]
#align finset.card_Icc_finset Finset.card_Icc_finset
/-- Cardinality of an `Ico` of finsets. -/
theorem card_Ico_finset (h : s ⊆ t) : (Ico s t).card = 2 ^ (t.card - s.card) - 1 := by
rw [card_Ico_eq_card_Icc_sub_one, card_Icc_finset h]
#align finset.card_Ico_finset Finset.card_Ico_finset
/-- Cardinality of an `Ioc` of finsets. -/
| Mathlib/Data/Finset/Interval.lean | 115 | 116 | theorem card_Ioc_finset (h : s ⊆ t) : (Ioc s t).card = 2 ^ (t.card - s.card) - 1 := by |
rw [card_Ioc_eq_card_Icc_sub_one, card_Icc_finset h]
|
/-
Copyright (c) 2023 Dagur Asgeirsson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Asgeirsson, Filippo A. E. Nuccio, Riccardo Brasca
-/
import Mathlib.CategoryTheory.Limits.Preserves.Finite
import Mathlib.CategoryTheory.Sites.Canonical
import Mathlib.CategoryTheory.Sites.Coherent.Basic
import Mathlib.CategoryTheory.Sites.Preserves
/-!
# Sheaves for the extensive topology
This file characterises sheaves for the extensive topology.
## Main result
* `isSheaf_iff_preservesFiniteProducts`: In a finitary extensive category, the sheaves for the
extensive topology are precisely those preserving finite products.
-/
universe v u w
namespace CategoryTheory
open Limits
variable {C : Type u} [Category.{v} C]
variable [FinitaryPreExtensive C]
/-- A presieve is *extensive* if it is finite and its arrows induce an isomorphism from the
coproduct to the target. -/
class Presieve.Extensive {X : C} (R : Presieve X) : Prop where
/-- `R` consists of a finite collection of arrows that together induce an isomorphism from the
coproduct of their sources. -/
arrows_nonempty_isColimit : ∃ (α : Type) (_ : Finite α) (Z : α → C) (π : (a : α) → (Z a ⟶ X)),
R = Presieve.ofArrows Z π ∧ Nonempty (IsColimit (Cofan.mk X π))
instance {X : C} (S : Presieve X) [S.Extensive] : S.hasPullbacks where
has_pullbacks := by
obtain ⟨_, _, _, _, rfl, ⟨hc⟩⟩ := Presieve.Extensive.arrows_nonempty_isColimit (R := S)
intro _ _ _ _ _ hg
cases hg
apply FinitaryPreExtensive.hasPullbacks_of_is_coproduct hc
open Presieve Opposite
/--
A finite product preserving presheaf is a sheaf for the extensive topology on a category which is
`FinitaryPreExtensive`.
-/
theorem isSheafFor_extensive_of_preservesFiniteProducts {X : C} (S : Presieve X) [S.Extensive]
(F : Cᵒᵖ ⥤ Type w) [PreservesFiniteProducts F] : S.IsSheafFor F := by
obtain ⟨α, _, Z, π, rfl, ⟨hc⟩⟩ := Extensive.arrows_nonempty_isColimit (R := S)
have : (ofArrows Z (Cofan.mk X π).inj).hasPullbacks :=
(inferInstance : (ofArrows Z π).hasPullbacks)
cases nonempty_fintype α
exact isSheafFor_of_preservesProduct _ _ hc
instance {α : Type} [Finite α] (Z : α → C) : (ofArrows Z (fun i ↦ Sigma.ι Z i)).Extensive :=
⟨⟨α, inferInstance, Z, (fun i ↦ Sigma.ι Z i), rfl, ⟨coproductIsCoproduct _⟩⟩⟩
/-- Every Yoneda-presheaf is a sheaf for the extensive topology. -/
theorem extensiveTopology.isSheaf_yoneda_obj (W : C) : Presieve.IsSheaf (extensiveTopology C)
(yoneda.obj W) := by
erw [isSheaf_coverage]
intro X R ⟨Y, α, Z, π, hR, hi⟩
have : IsIso (Sigma.desc (Cofan.inj (Cofan.mk X π))) := hi
have : R.Extensive := ⟨Y, α, Z, π, hR, ⟨Cofan.isColimitOfIsIsoSigmaDesc (Cofan.mk X π)⟩⟩
exact isSheafFor_extensive_of_preservesFiniteProducts _ _
/-- The extensive topology on a finitary pre-extensive category is subcanonical. -/
theorem extensiveTopology.subcanonical : Sheaf.Subcanonical (extensiveTopology C) :=
Sheaf.Subcanonical.of_yoneda_isSheaf _ isSheaf_yoneda_obj
/--
A presheaf of sets on a category which is `FinitaryExtensive` is a sheaf iff it preserves finite
products.
-/
| Mathlib/CategoryTheory/Sites/Coherent/ExtensiveSheaves.lean | 80 | 110 | theorem Presieve.isSheaf_iff_preservesFiniteProducts [FinitaryExtensive C] (F : Cᵒᵖ ⥤ Type w) :
Presieve.IsSheaf (extensiveTopology C) F ↔
Nonempty (PreservesFiniteProducts F) := by |
refine ⟨fun hF ↦ ⟨⟨fun α _ ↦ ⟨fun {K} ↦ ?_⟩⟩⟩, fun hF ↦ ?_⟩
· erw [Presieve.isSheaf_coverage] at hF
let Z : α → C := fun i ↦ unop (K.obj ⟨i⟩)
have : (Presieve.ofArrows Z (Cofan.mk (∐ Z) (Sigma.ι Z)).inj).hasPullbacks :=
(inferInstance : (Presieve.ofArrows Z (Sigma.ι Z)).hasPullbacks)
have : ∀ (i : α), Mono (Cofan.inj (Cofan.mk (∐ Z) (Sigma.ι Z)) i) :=
(inferInstance : ∀ (i : α), Mono (Sigma.ι Z i))
let i : K ≅ Discrete.functor (fun i ↦ op (Z i)) := Discrete.natIsoFunctor
let _ : PreservesLimit (Discrete.functor (fun i ↦ op (Z i))) F :=
Presieve.preservesProductOfIsSheafFor F ?_ initialIsInitial _ (coproductIsCoproduct Z)
(FinitaryExtensive.isPullback_initial_to_sigma_ι Z)
(hF (Presieve.ofArrows Z (fun i ↦ Sigma.ι Z i)) ?_)
· exact preservesLimitOfIsoDiagram F i.symm
· apply hF
refine ⟨Empty, inferInstance, Empty.elim, IsEmpty.elim inferInstance, rfl, ⟨default,?_, ?_⟩⟩
· ext b
cases b
· simp only [eq_iff_true_of_subsingleton]
· refine ⟨α, inferInstance, Z, (fun i ↦ Sigma.ι Z i), rfl, ?_⟩
suffices Sigma.desc (fun i ↦ Sigma.ι Z i) = 𝟙 _ by rw [this]; infer_instance
ext
simp
· let _ := hF.some
erw [Presieve.isSheaf_coverage]
intro X R ⟨Y, α, Z, π, hR, hi⟩
have : IsIso (Sigma.desc (Cofan.inj (Cofan.mk X π))) := hi
have : R.Extensive := ⟨Y, α, Z, π, hR, ⟨Cofan.isColimitOfIsIsoSigmaDesc (Cofan.mk X π)⟩⟩
exact isSheafFor_extensive_of_preservesFiniteProducts R F
|
/-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Mario Carneiro, Johan Commelin, Amelia Livingston, Anne Baanen
-/
import Mathlib.RingTheory.Ideal.LocalRing
import Mathlib.RingTheory.Localization.Ideal
#align_import ring_theory.localization.at_prime from "leanprover-community/mathlib"@"b86c528d08a52a1fdb50d999232408e1c7e85d7d"
/-!
# Localizations of commutative rings at the complement of a prime ideal
## Main definitions
* `IsLocalization.AtPrime (P : Ideal R) [IsPrime P] (S : Type*)` expresses that `S` is a
localization at (the complement of) a prime ideal `P`, as an abbreviation of
`IsLocalization P.prime_compl S`
## Main results
* `IsLocalization.AtPrime.localRing`: a theorem (not an instance) stating a localization at the
complement of a prime ideal is a local ring
## Implementation notes
See `RingTheory.Localization.Basic` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
variable {R : Type*} [CommSemiring R] (M : Submonoid R) (S : Type*) [CommSemiring S]
variable [Algebra R S] {P : Type*} [CommSemiring P]
section AtPrime
variable (P : Ideal R) [hp : P.IsPrime]
namespace Ideal
/-- The complement of a prime ideal `P ⊆ R` is a submonoid of `R`. -/
def primeCompl : Submonoid R where
carrier := (Pᶜ : Set R)
one_mem' := by convert P.ne_top_iff_one.1 hp.1
mul_mem' {x y} hnx hny hxy := Or.casesOn (hp.mem_or_mem hxy) hnx hny
#align ideal.prime_compl Ideal.primeCompl
theorem primeCompl_le_nonZeroDivisors [NoZeroDivisors R] : P.primeCompl ≤ nonZeroDivisors R :=
le_nonZeroDivisors_of_noZeroDivisors <| not_not_intro P.zero_mem
#align ideal.prime_compl_le_non_zero_divisors Ideal.primeCompl_le_nonZeroDivisors
end Ideal
/-- Given a prime ideal `P`, the typeclass `IsLocalization.AtPrime S P` states that `S` is
isomorphic to the localization of `R` at the complement of `P`. -/
protected abbrev IsLocalization.AtPrime :=
IsLocalization P.primeCompl S
#align is_localization.at_prime IsLocalization.AtPrime
/-- Given a prime ideal `P`, `Localization.AtPrime P` is a localization of
`R` at the complement of `P`, as a quotient type. -/
protected abbrev Localization.AtPrime :=
Localization P.primeCompl
#align localization.at_prime Localization.AtPrime
namespace IsLocalization
| Mathlib/RingTheory/Localization/AtPrime.lean | 71 | 76 | theorem AtPrime.Nontrivial [IsLocalization.AtPrime S P] : Nontrivial S :=
nontrivial_of_ne (0 : S) 1 fun hze => by
rw [← (algebraMap R S).map_one, ← (algebraMap R S).map_zero] at hze
obtain ⟨t, ht⟩ := (eq_iff_exists P.primeCompl S).1 hze
have htz : (t : R) = 0 := by | simpa using ht.symm
exact t.2 (htz.symm ▸ P.zero_mem : ↑t ∈ P)
|
/-
Copyright (c) 2014 Parikshit Khanna. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro
-/
import Mathlib.Data.List.Basic
/-!
# insertNth
Proves various lemmas about `List.insertNth`.
-/
open Function
open Nat hiding one_pos
assert_not_exists Set.range
namespace List
universe u v w
variable {ι : Type*} {α : Type u} {β : Type v} {γ : Type w} {l₁ l₂ : List α}
section InsertNth
variable {a : α}
@[simp]
theorem insertNth_zero (s : List α) (x : α) : insertNth 0 x s = x :: s :=
rfl
#align list.insert_nth_zero List.insertNth_zero
@[simp]
theorem insertNth_succ_nil (n : ℕ) (a : α) : insertNth (n + 1) a [] = [] :=
rfl
#align list.insert_nth_succ_nil List.insertNth_succ_nil
@[simp]
theorem insertNth_succ_cons (s : List α) (hd x : α) (n : ℕ) :
insertNth (n + 1) x (hd :: s) = hd :: insertNth n x s :=
rfl
#align list.insert_nth_succ_cons List.insertNth_succ_cons
theorem length_insertNth : ∀ n as, n ≤ length as → length (insertNth n a as) = length as + 1
| 0, _, _ => rfl
| _ + 1, [], h => (Nat.not_succ_le_zero _ h).elim
| n + 1, _ :: as, h => congr_arg Nat.succ <| length_insertNth n as (Nat.le_of_succ_le_succ h)
#align list.length_insert_nth List.length_insertNth
theorem eraseIdx_insertNth (n : ℕ) (l : List α) : (l.insertNth n a).eraseIdx n = l := by
rw [eraseIdx_eq_modifyNthTail, insertNth, modifyNthTail_modifyNthTail_same]
exact modifyNthTail_id _ _
#align list.remove_nth_insert_nth List.eraseIdx_insertNth
@[deprecated (since := "2024-05-04")] alias removeNth_insertNth := eraseIdx_insertNth
theorem insertNth_eraseIdx_of_ge :
∀ n m as,
n < length as → n ≤ m → insertNth m a (as.eraseIdx n) = (as.insertNth (m + 1) a).eraseIdx n
| 0, 0, [], has, _ => (lt_irrefl _ has).elim
| 0, 0, _ :: as, _, _ => by simp [eraseIdx, insertNth]
| 0, m + 1, a :: as, _, _ => rfl
| n + 1, m + 1, a :: as, has, hmn =>
congr_arg (cons a) <|
insertNth_eraseIdx_of_ge n m as (Nat.lt_of_succ_lt_succ has) (Nat.le_of_succ_le_succ hmn)
#align list.insert_nth_remove_nth_of_ge List.insertNth_eraseIdx_of_ge
@[deprecated (since := "2024-05-04")] alias insertNth_removeNth_of_ge := insertNth_eraseIdx_of_ge
theorem insertNth_eraseIdx_of_le :
∀ n m as,
n < length as → m ≤ n → insertNth m a (as.eraseIdx n) = (as.insertNth m a).eraseIdx (n + 1)
| _, 0, _ :: _, _, _ => rfl
| n + 1, m + 1, a :: as, has, hmn =>
congr_arg (cons a) <|
insertNth_eraseIdx_of_le n m as (Nat.lt_of_succ_lt_succ has) (Nat.le_of_succ_le_succ hmn)
#align list.insert_nth_remove_nth_of_le List.insertNth_eraseIdx_of_le
@[deprecated (since := "2024-05-04")] alias insertNth_removeNth_of_le := insertNth_eraseIdx_of_le
theorem insertNth_comm (a b : α) :
∀ (i j : ℕ) (l : List α) (_ : i ≤ j) (_ : j ≤ length l),
(l.insertNth i a).insertNth (j + 1) b = (l.insertNth j b).insertNth i a
| 0, j, l => by simp [insertNth]
| i + 1, 0, l => fun h => (Nat.not_lt_zero _ h).elim
| i + 1, j + 1, [] => by simp
| i + 1, j + 1, c :: l => fun h₀ h₁ => by
simp only [insertNth_succ_cons, cons.injEq, true_and]
exact insertNth_comm a b i j l (Nat.le_of_succ_le_succ h₀) (Nat.le_of_succ_le_succ h₁)
#align list.insert_nth_comm List.insertNth_comm
theorem mem_insertNth {a b : α} :
∀ {n : ℕ} {l : List α} (_ : n ≤ l.length), a ∈ l.insertNth n b ↔ a = b ∨ a ∈ l
| 0, as, _ => by simp
| n + 1, [], h => (Nat.not_succ_le_zero _ h).elim
| n + 1, a' :: as, h => by
rw [List.insertNth_succ_cons, mem_cons, mem_insertNth (Nat.le_of_succ_le_succ h),
← or_assoc, @or_comm (a = a'), or_assoc, mem_cons]
#align list.mem_insert_nth List.mem_insertNth
theorem insertNth_of_length_lt (l : List α) (x : α) (n : ℕ) (h : l.length < n) :
insertNth n x l = l := by
induction' l with hd tl IH generalizing n
· cases n
· simp at h
· simp
· cases n
· simp at h
· simp only [Nat.succ_lt_succ_iff, length] at h
simpa using IH _ h
#align list.insert_nth_of_length_lt List.insertNth_of_length_lt
@[simp]
theorem insertNth_length_self (l : List α) (x : α) : insertNth l.length x l = l ++ [x] := by
induction' l with hd tl IH
· simp
· simpa using IH
#align list.insert_nth_length_self List.insertNth_length_self
| Mathlib/Data/List/InsertNth.lean | 122 | 127 | theorem length_le_length_insertNth (l : List α) (x : α) (n : ℕ) :
l.length ≤ (insertNth n x l).length := by |
rcases le_or_lt n l.length with hn | hn
· rw [length_insertNth _ _ hn]
exact (Nat.lt_succ_self _).le
· rw [insertNth_of_length_lt _ _ _ hn]
|
/-
Copyright (c) 2020 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov
-/
import Mathlib.Algebra.BigOperators.NatAntidiagonal
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Data.Nat.Choose.Sum
import Mathlib.RingTheory.PowerSeries.Basic
#align_import ring_theory.power_series.well_known from "leanprover-community/mathlib"@"8199f6717c150a7fe91c4534175f4cf99725978f"
/-!
# Definition of well-known power series
In this file we define the following power series:
* `PowerSeries.invUnitsSub`: given `u : Rˣ`, this is the series for `1 / (u - x)`.
It is given by `∑ n, x ^ n /ₚ u ^ (n + 1)`.
* `PowerSeries.invOneSubPow`: given a commutative ring `S` and a number `d : ℕ`,
`PowerSeries.invOneSubPow d : S⟦X⟧ˣ` is the power series `∑ n, Nat.choose (d + n) d`
whose multiplicative inverse is `(1 - X) ^ (d + 1)`.
* `PowerSeries.sin`, `PowerSeries.cos`, `PowerSeries.exp` : power series for sin, cosine, and
exponential functions.
-/
namespace PowerSeries
section Ring
variable {R S : Type*} [Ring R] [Ring S]
/-- The power series for `1 / (u - x)`. -/
def invUnitsSub (u : Rˣ) : PowerSeries R :=
mk fun n => 1 /ₚ u ^ (n + 1)
#align power_series.inv_units_sub PowerSeries.invUnitsSub
@[simp]
theorem coeff_invUnitsSub (u : Rˣ) (n : ℕ) : coeff R n (invUnitsSub u) = 1 /ₚ u ^ (n + 1) :=
coeff_mk _ _
#align power_series.coeff_inv_units_sub PowerSeries.coeff_invUnitsSub
@[simp]
theorem constantCoeff_invUnitsSub (u : Rˣ) : constantCoeff R (invUnitsSub u) = 1 /ₚ u := by
rw [← coeff_zero_eq_constantCoeff_apply, coeff_invUnitsSub, zero_add, pow_one]
#align power_series.constant_coeff_inv_units_sub PowerSeries.constantCoeff_invUnitsSub
@[simp]
theorem invUnitsSub_mul_X (u : Rˣ) : invUnitsSub u * X = invUnitsSub u * C R u - 1 := by
ext (_ | n)
· simp
· simp [n.succ_ne_zero, pow_succ']
set_option linter.uppercaseLean3 false in
#align power_series.inv_units_sub_mul_X PowerSeries.invUnitsSub_mul_X
@[simp]
theorem invUnitsSub_mul_sub (u : Rˣ) : invUnitsSub u * (C R u - X) = 1 := by
simp [mul_sub, sub_sub_cancel]
#align power_series.inv_units_sub_mul_sub PowerSeries.invUnitsSub_mul_sub
| Mathlib/RingTheory/PowerSeries/WellKnown.lean | 64 | 68 | theorem map_invUnitsSub (f : R →+* S) (u : Rˣ) :
map f (invUnitsSub u) = invUnitsSub (Units.map (f : R →* S) u) := by |
ext
simp only [← map_pow, coeff_map, coeff_invUnitsSub, one_divp]
rfl
|
/-
Copyright (c) 2022 Jujian Zhang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jujian Zhang
-/
import Mathlib.CategoryTheory.Preadditive.Injective
import Mathlib.Algebra.Category.ModuleCat.EpiMono
import Mathlib.RingTheory.Ideal.Basic
import Mathlib.LinearAlgebra.LinearPMap
import Mathlib.Logic.Equiv.TransferInstance
#align_import algebra.module.injective from "leanprover-community/mathlib"@"f8d8465c3c392a93b9ed226956e26dee00975946"
/-!
# Injective modules
## Main definitions
* `Module.Injective`: an `R`-module `Q` is injective if and only if every injective `R`-linear
map descends to a linear map to `Q`, i.e. in the following diagram, if `f` is injective then there
is an `R`-linear map `h : Y ⟶ Q` such that `g = h ∘ f`
```
X --- f ---> Y
|
| g
v
Q
```
* `Module.Baer`: an `R`-module `Q` satisfies Baer's criterion if any `R`-linear map from an
`Ideal R` extends to an `R`-linear map `R ⟶ Q`
## Main statements
* `Module.Baer.injective`: an `R`-module is injective if it is Baer.
-/
noncomputable section
universe u v v'
variable (R : Type u) [Ring R] (Q : Type v) [AddCommGroup Q] [Module R Q]
/--
An `R`-module `Q` is injective if and only if every injective `R`-linear map descends to a linear
map to `Q`, i.e. in the following diagram, if `f` is injective then there is an `R`-linear map
`h : Y ⟶ Q` such that `g = h ∘ f`
```
X --- f ---> Y
|
| g
v
Q
```
-/
@[mk_iff] class Module.Injective : Prop where
out : ∀ ⦃X Y : Type v⦄ [AddCommGroup X] [AddCommGroup Y] [Module R X] [Module R Y]
(f : X →ₗ[R] Y) (_ : Function.Injective f) (g : X →ₗ[R] Q),
∃ h : Y →ₗ[R] Q, ∀ x, h (f x) = g x
#align module.injective Module.Injective
theorem Module.injective_object_of_injective_module [inj : Module.Injective R Q] :
CategoryTheory.Injective (ModuleCat.of R Q) where
factors g f m :=
have ⟨l, h⟩ := inj.out f ((ModuleCat.mono_iff_injective f).mp m) g
⟨l, LinearMap.ext h⟩
#align module.injective_object_of_injective_module Module.injective_object_of_injective_module
| Mathlib/Algebra/Module/Injective.lean | 70 | 76 | theorem Module.injective_module_of_injective_object
[inj : CategoryTheory.Injective <| ModuleCat.of R Q] :
Module.Injective R Q where
out X Y _ _ _ _ f hf g := by |
have : CategoryTheory.Mono (ModuleCat.ofHom f) := (ModuleCat.mono_iff_injective _).mpr hf
obtain ⟨l, rfl⟩ := inj.factors (ModuleCat.ofHom g) (ModuleCat.ofHom f)
exact ⟨l, fun _ ↦ rfl⟩
|
/-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.RingTheory.Polynomial.Bernstein
import Mathlib.Topology.ContinuousFunction.Polynomial
import Mathlib.Topology.ContinuousFunction.Compact
#align_import analysis.special_functions.bernstein from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# Bernstein approximations and Weierstrass' theorem
We prove that the Bernstein approximations
```
∑ k : Fin (n+1), f (k/n : ℝ) * n.choose k * x^k * (1-x)^(n-k)
```
for a continuous function `f : C([0,1], ℝ)` converge uniformly to `f` as `n` tends to infinity.
Our proof follows [Richard Beals' *Analysis, an introduction*][beals-analysis], §7D.
The original proof, due to [Bernstein](bernstein1912) in 1912, is probabilistic,
and relies on Bernoulli's theorem,
which gives bounds for how quickly the observed frequencies in a
Bernoulli trial approach the underlying probability.
The proof here does not directly rely on Bernoulli's theorem,
but can also be given a probabilistic account.
* Consider a weighted coin which with probability `x` produces heads,
and with probability `1-x` produces tails.
* The value of `bernstein n k x` is the probability that
such a coin gives exactly `k` heads in a sequence of `n` tosses.
* If such an appearance of `k` heads results in a payoff of `f(k / n)`,
the `n`-th Bernstein approximation for `f` evaluated at `x` is the expected payoff.
* The main estimate in the proof bounds the probability that
the observed frequency of heads differs from `x` by more than some `δ`,
obtaining a bound of `(4 * n * δ^2)⁻¹`, irrespective of `x`.
* This ensures that for `n` large, the Bernstein approximation is (uniformly) close to the
payoff function `f`.
(You don't need to think in these terms to follow the proof below: it's a giant `calc` block!)
This result proves Weierstrass' theorem that polynomials are dense in `C([0,1], ℝ)`,
although we defer an abstract statement of this until later.
-/
set_option linter.uppercaseLean3 false -- S
noncomputable section
open scoped Classical BoundedContinuousFunction unitInterval
/-- The Bernstein polynomials, as continuous functions on `[0,1]`.
-/
def bernstein (n ν : ℕ) : C(I, ℝ) :=
(bernsteinPolynomial ℝ n ν).toContinuousMapOn I
#align bernstein bernstein
@[simp]
| Mathlib/Analysis/SpecialFunctions/Bernstein.lean | 61 | 64 | theorem bernstein_apply (n ν : ℕ) (x : I) :
bernstein n ν x = (n.choose ν : ℝ) * (x : ℝ) ^ ν * (1 - (x : ℝ)) ^ (n - ν) := by |
dsimp [bernstein, Polynomial.toContinuousMapOn, Polynomial.toContinuousMap, bernsteinPolynomial]
simp
|
/-
Copyright (c) 2020 Anatole Dedecker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker, Devon Tuma
-/
import Mathlib.Algebra.Polynomial.Roots
import Mathlib.Analysis.Asymptotics.AsymptoticEquivalent
import Mathlib.Analysis.Asymptotics.SpecificAsymptotics
#align_import analysis.special_functions.polynomials from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
/-!
# Limits related to polynomial and rational functions
This file proves basic facts about limits of polynomial and rationals functions.
The main result is `eval_is_equivalent_at_top_eval_lead`, which states that for
any polynomial `P` of degree `n` with leading coefficient `a`, the corresponding
polynomial function is equivalent to `a * x^n` as `x` goes to +∞.
We can then use this result to prove various limits for polynomial and rational
functions, depending on the degrees and leading coefficients of the considered
polynomials.
-/
open Filter Finset Asymptotics
open Asymptotics Polynomial Topology
namespace Polynomial
variable {𝕜 : Type*} [NormedLinearOrderedField 𝕜] (P Q : 𝕜[X])
theorem eventually_no_roots (hP : P ≠ 0) : ∀ᶠ x in atTop, ¬P.IsRoot x :=
atTop_le_cofinite <| (finite_setOf_isRoot hP).compl_mem_cofinite
#align polynomial.eventually_no_roots Polynomial.eventually_no_roots
variable [OrderTopology 𝕜]
section PolynomialAtTop
theorem isEquivalent_atTop_lead :
(fun x => eval x P) ~[atTop] fun x => P.leadingCoeff * x ^ P.natDegree := by
by_cases h : P = 0
· simp [h, IsEquivalent.refl]
· simp only [Polynomial.eval_eq_sum_range, sum_range_succ]
exact
IsLittleO.add_isEquivalent
(IsLittleO.sum fun i hi =>
IsLittleO.const_mul_left
((IsLittleO.const_mul_right fun hz => h <| leadingCoeff_eq_zero.mp hz) <|
isLittleO_pow_pow_atTop_of_lt (mem_range.mp hi))
_)
IsEquivalent.refl
#align polynomial.is_equivalent_at_top_lead Polynomial.isEquivalent_atTop_lead
theorem tendsto_atTop_of_leadingCoeff_nonneg (hdeg : 0 < P.degree) (hnng : 0 ≤ P.leadingCoeff) :
Tendsto (fun x => eval x P) atTop atTop :=
P.isEquivalent_atTop_lead.symm.tendsto_atTop <|
tendsto_const_mul_pow_atTop (natDegree_pos_iff_degree_pos.2 hdeg).ne' <|
hnng.lt_of_ne' <| leadingCoeff_ne_zero.mpr <| ne_zero_of_degree_gt hdeg
#align polynomial.tendsto_at_top_of_leading_coeff_nonneg Polynomial.tendsto_atTop_of_leadingCoeff_nonneg
| Mathlib/Analysis/SpecialFunctions/Polynomials.lean | 64 | 70 | theorem tendsto_atTop_iff_leadingCoeff_nonneg :
Tendsto (fun x => eval x P) atTop atTop ↔ 0 < P.degree ∧ 0 ≤ P.leadingCoeff := by |
refine ⟨fun h => ?_, fun h => tendsto_atTop_of_leadingCoeff_nonneg P h.1 h.2⟩
have : Tendsto (fun x => P.leadingCoeff * x ^ P.natDegree) atTop atTop :=
(isEquivalent_atTop_lead P).tendsto_atTop h
rw [tendsto_const_mul_pow_atTop_iff, ← pos_iff_ne_zero, natDegree_pos_iff_degree_pos] at this
exact ⟨this.1, this.2.le⟩
|
/-
Copyright (c) 2022 Jireh Loreaux. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jireh Loreaux
-/
import Mathlib.Algebra.Star.Subalgebra
import Mathlib.Topology.Algebra.Algebra
import Mathlib.Topology.Algebra.Star
#align_import topology.algebra.star_subalgebra from "leanprover-community/mathlib"@"b7f5a77fa29ad9a3ccc484109b0d7534178e7ecd"
/-!
# Topological star (sub)algebras
A topological star algebra over a topological semiring `R` is a topological semiring with a
compatible continuous scalar multiplication by elements of `R` and a continuous star operation.
We reuse typeclass `ContinuousSMul` for topological algebras.
## Results
This is just a minimal stub for now!
The topological closure of a star subalgebra is still a star subalgebra,
which as a star algebra is a topological star algebra.
-/
open scoped Classical
open Set TopologicalSpace
open scoped Classical
namespace StarSubalgebra
section TopologicalStarAlgebra
variable {R A B : Type*} [CommSemiring R] [StarRing R]
variable [TopologicalSpace A] [Semiring A] [Algebra R A] [StarRing A] [StarModule R A]
instance [TopologicalSemiring A] (s : StarSubalgebra R A) : TopologicalSemiring s :=
s.toSubalgebra.topologicalSemiring
/-- The `StarSubalgebra.inclusion` of a star subalgebra is an `Embedding`. -/
theorem embedding_inclusion {S₁ S₂ : StarSubalgebra R A} (h : S₁ ≤ S₂) : Embedding (inclusion h) :=
{ induced := Eq.symm induced_compose
inj := Subtype.map_injective h Function.injective_id }
#align star_subalgebra.embedding_inclusion StarSubalgebra.embedding_inclusion
/-- The `StarSubalgebra.inclusion` of a closed star subalgebra is a `ClosedEmbedding`. -/
theorem closedEmbedding_inclusion {S₁ S₂ : StarSubalgebra R A} (h : S₁ ≤ S₂)
(hS₁ : IsClosed (S₁ : Set A)) : ClosedEmbedding (inclusion h) :=
{ embedding_inclusion h with
isClosed_range := isClosed_induced_iff.2
⟨S₁, hS₁, by
convert (Set.range_subtype_map id _).symm
· rw [Set.image_id]; rfl
· intro _ h'
apply h h' ⟩ }
#align star_subalgebra.closed_embedding_inclusion StarSubalgebra.closedEmbedding_inclusion
variable [TopologicalSemiring A] [ContinuousStar A]
variable [TopologicalSpace B] [Semiring B] [Algebra R B] [StarRing B]
/-- The closure of a star subalgebra in a topological star algebra as a star subalgebra. -/
def topologicalClosure (s : StarSubalgebra R A) : StarSubalgebra R A :=
{
s.toSubalgebra.topologicalClosure with
carrier := closure (s : Set A)
star_mem' := fun ha =>
map_mem_closure continuous_star ha fun x => (star_mem : x ∈ s → star x ∈ s) }
#align star_subalgebra.topological_closure StarSubalgebra.topologicalClosure
theorem topologicalClosure_toSubalgebra_comm (s : StarSubalgebra R A) :
s.topologicalClosure.toSubalgebra = s.toSubalgebra.topologicalClosure :=
SetLike.coe_injective rfl
@[simp]
theorem topologicalClosure_coe (s : StarSubalgebra R A) :
(s.topologicalClosure : Set A) = closure (s : Set A) :=
rfl
#align star_subalgebra.topological_closure_coe StarSubalgebra.topologicalClosure_coe
theorem le_topologicalClosure (s : StarSubalgebra R A) : s ≤ s.topologicalClosure :=
subset_closure
#align star_subalgebra.le_topological_closure StarSubalgebra.le_topologicalClosure
theorem isClosed_topologicalClosure (s : StarSubalgebra R A) :
IsClosed (s.topologicalClosure : Set A) :=
isClosed_closure
#align star_subalgebra.is_closed_topological_closure StarSubalgebra.isClosed_topologicalClosure
instance {A : Type*} [UniformSpace A] [CompleteSpace A] [Semiring A] [StarRing A]
[TopologicalSemiring A] [ContinuousStar A] [Algebra R A] [StarModule R A]
{S : StarSubalgebra R A} : CompleteSpace S.topologicalClosure :=
isClosed_closure.completeSpace_coe
theorem topologicalClosure_minimal {s t : StarSubalgebra R A} (h : s ≤ t)
(ht : IsClosed (t : Set A)) : s.topologicalClosure ≤ t :=
closure_minimal h ht
#align star_subalgebra.topological_closure_minimal StarSubalgebra.topologicalClosure_minimal
theorem topologicalClosure_mono : Monotone (topologicalClosure : _ → StarSubalgebra R A) :=
fun _ S₂ h =>
topologicalClosure_minimal (h.trans <| le_topologicalClosure S₂) (isClosed_topologicalClosure S₂)
#align star_subalgebra.topological_closure_mono StarSubalgebra.topologicalClosure_mono
theorem topologicalClosure_map_le [StarModule R B] [TopologicalSemiring B] [ContinuousStar B]
(s : StarSubalgebra R A) (φ : A →⋆ₐ[R] B) (hφ : IsClosedMap φ) :
(map φ s).topologicalClosure ≤ map φ s.topologicalClosure :=
hφ.closure_image_subset _
theorem map_topologicalClosure_le [StarModule R B] [TopologicalSemiring B] [ContinuousStar B]
(s : StarSubalgebra R A) (φ : A →⋆ₐ[R] B) (hφ : Continuous φ) :
map φ s.topologicalClosure ≤ (map φ s).topologicalClosure :=
image_closure_subset_closure_image hφ
theorem topologicalClosure_map [StarModule R B] [TopologicalSemiring B] [ContinuousStar B]
(s : StarSubalgebra R A) (φ : A →⋆ₐ[R] B) (hφ : ClosedEmbedding φ) :
(map φ s).topologicalClosure = map φ s.topologicalClosure :=
SetLike.coe_injective <| hφ.closure_image_eq _
| Mathlib/Topology/Algebra/StarSubalgebra.lean | 122 | 127 | theorem _root_.Subalgebra.topologicalClosure_star_comm (s : Subalgebra R A) :
(star s).topologicalClosure = star s.topologicalClosure := by |
suffices ∀ t : Subalgebra R A, (star t).topologicalClosure ≤ star t.topologicalClosure from
le_antisymm (this s) (by simpa only [star_star] using Subalgebra.star_mono (this (star s)))
exact fun t => (star t).topologicalClosure_minimal (Subalgebra.star_mono subset_closure)
(isClosed_closure.preimage continuous_star)
|
/-
Copyright (c) 2024 Antoine Chambert-Loir. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Antoine Chambert-Loir
-/
import Mathlib.Data.Setoid.Partition
import Mathlib.GroupTheory.GroupAction.Basic
import Mathlib.GroupTheory.GroupAction.Pointwise
import Mathlib.GroupTheory.GroupAction.SubMulAction
/-! # Blocks
Given `SMul G X`, an action of a type `G` on a type `X`, we define
- the predicate `IsBlock G B` states that `B : Set X` is a block,
which means that the sets `g • B`, for `g ∈ G`, are equal or disjoint.
- a bunch of lemmas that give examples of “trivial” blocks : ⊥, ⊤, singletons,
and non trivial blocks: orbit of the group, orbit of a normal subgroup…
The non-existence of nontrivial blocks is the definition of primitive actions.
## References
We follow [wieland1964].
-/
open scoped BigOperators Pointwise
namespace MulAction
section orbits
variable {G : Type*} [Group G] {X : Type*} [MulAction G X]
theorem orbit.eq_or_disjoint (a b : X) :
orbit G a = orbit G b ∨ Disjoint (orbit G a) (orbit G b) := by
apply (em (Disjoint (orbit G a) (orbit G b))).symm.imp _ id
simp (config := { contextual := true })
only [Set.not_disjoint_iff, ← orbit_eq_iff, forall_exists_index, and_imp, eq_comm, implies_true]
theorem orbit.pairwiseDisjoint :
(Set.range fun x : X => orbit G x).PairwiseDisjoint id := by
rintro s ⟨x, rfl⟩ t ⟨y, rfl⟩ h
contrapose! h
exact (orbit.eq_or_disjoint x y).resolve_right h
/-- Orbits of an element form a partition -/
theorem IsPartition.of_orbits :
Setoid.IsPartition (Set.range fun a : X => orbit G a) := by
apply orbit.pairwiseDisjoint.isPartition_of_exists_of_ne_empty
· intro x
exact ⟨_, ⟨x, rfl⟩, mem_orbit_self x⟩
· rintro ⟨a, ha : orbit G a = ∅⟩
exact (MulAction.orbit_nonempty a).ne_empty ha
end orbits
section SMul
variable (G : Type*) {X : Type*} [SMul G X]
-- Change terminology : is_fully_invariant ?
/-- For `SMul G X`, a fixed block is a `Set X` which is fully invariant:
`g • B = B` for all `g : G` -/
def IsFixedBlock (B : Set X) := ∀ g : G, g • B = B
/-- For `SMul G X`, an invariant block is a `Set X` which is stable:
`g • B ⊆ B` for all `g : G` -/
def IsInvariantBlock (B : Set X) := ∀ g : G, g • B ⊆ B
/-- A trivial block is a `Set X` which is either a subsingleton or ⊤
(it is not necessarily a block…) -/
def IsTrivialBlock (B : Set X) := B.Subsingleton ∨ B = ⊤
/-- `For SMul G X`, a block is a `Set X` whose translates are pairwise disjoint -/
def IsBlock (B : Set X) := (Set.range fun g : G => g • B).PairwiseDisjoint id
variable {G}
/-- A set B is a block iff for all g, g',
the sets g • B and g' • B are either equal or disjoint -/
theorem IsBlock.def {B : Set X} :
IsBlock G B ↔ ∀ g g' : G, g • B = g' • B ∨ Disjoint (g • B) (g' • B) := by
apply Set.pairwiseDisjoint_range_iff
/-- Alternate definition of a block -/
theorem IsBlock.mk_notempty {B : Set X} :
IsBlock G B ↔ ∀ g g' : G, g • B ∩ g' • B ≠ ∅ → g • B = g' • B := by
simp_rw [IsBlock.def, or_iff_not_imp_right, Set.disjoint_iff_inter_eq_empty]
/-- A fixed block is a block -/
theorem IsFixedBlock.isBlock {B : Set X} (hfB : IsFixedBlock G B) :
IsBlock G B := by
simp [IsBlock.def, hfB _]
variable (X)
/-- The empty set is a block -/
theorem isBlock_empty : IsBlock G (⊥ : Set X) := by
simp [IsBlock.def, Set.bot_eq_empty, Set.smul_set_empty]
variable {X}
theorem isBlock_singleton (a : X) : IsBlock G ({a} : Set X) := by
simp [IsBlock.def, Classical.or_iff_not_imp_left]
/-- Subsingletons are (trivial) blocks -/
theorem isBlock_subsingleton {B : Set X} (hB : B.Subsingleton) :
IsBlock G B :=
hB.induction_on (isBlock_empty _) isBlock_singleton
end SMul
section Group
variable {G : Type*} [Group G] {X : Type*} [MulAction G X]
theorem IsBlock.smul_eq_or_disjoint {B : Set X} (hB : IsBlock G B) (g : G) :
g • B = B ∨ Disjoint (g • B) B := by
rw [IsBlock.def] at hB
simpa only [one_smul] using hB g 1
theorem IsBlock.def_one {B : Set X} :
IsBlock G B ↔ ∀ g : G, g • B = B ∨ Disjoint (g • B) B := by
refine ⟨IsBlock.smul_eq_or_disjoint, ?_⟩
rw [IsBlock.def]
intro hB g g'
apply (hB (g'⁻¹ * g)).imp
· rw [← smul_smul, ← eq_inv_smul_iff, inv_inv]
exact id
· intro h
rw [Set.disjoint_iff] at h ⊢
rintro x hx
suffices g'⁻¹ • x ∈ (g'⁻¹ * g) • B ∩ B by apply h this
simp only [Set.mem_inter_iff, ← Set.mem_smul_set_iff_inv_smul_mem, ← smul_smul, smul_inv_smul]
exact hx
| Mathlib/GroupTheory/GroupAction/Blocks.lean | 141 | 143 | theorem IsBlock.mk_notempty_one {B : Set X} :
IsBlock G B ↔ ∀ g : G, g • B ∩ B ≠ ∅ → g • B = B := by |
simp_rw [IsBlock.def_one, Set.disjoint_iff_inter_eq_empty, or_iff_not_imp_right]
|
/-
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.GCDMonoid.Basic
import Mathlib.Data.Multiset.FinsetOps
import Mathlib.Data.Multiset.Fold
#align_import algebra.gcd_monoid.multiset from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
/-!
# GCD and LCM operations on multisets
## Main definitions
- `Multiset.gcd` - the greatest common denominator of a `Multiset` of elements of a `GCDMonoid`
- `Multiset.lcm` - the least common multiple of a `Multiset` of elements of a `GCDMonoid`
## Implementation notes
TODO: simplify with a tactic and `Data.Multiset.Lattice`
## Tags
multiset, gcd
-/
namespace Multiset
variable {α : Type*} [CancelCommMonoidWithZero α] [NormalizedGCDMonoid α]
/-! ### LCM -/
section lcm
/-- Least common multiple of a multiset -/
def lcm (s : Multiset α) : α :=
s.fold GCDMonoid.lcm 1
#align multiset.lcm Multiset.lcm
@[simp]
theorem lcm_zero : (0 : Multiset α).lcm = 1 :=
fold_zero _ _
#align multiset.lcm_zero Multiset.lcm_zero
@[simp]
theorem lcm_cons (a : α) (s : Multiset α) : (a ::ₘ s).lcm = GCDMonoid.lcm a s.lcm :=
fold_cons_left _ _ _ _
#align multiset.lcm_cons Multiset.lcm_cons
@[simp]
theorem lcm_singleton {a : α} : ({a} : Multiset α).lcm = normalize a :=
(fold_singleton _ _ _).trans <| lcm_one_right _
#align multiset.lcm_singleton Multiset.lcm_singleton
@[simp]
theorem lcm_add (s₁ s₂ : Multiset α) : (s₁ + s₂).lcm = GCDMonoid.lcm s₁.lcm s₂.lcm :=
Eq.trans (by simp [lcm]) (fold_add _ _ _ _ _)
#align multiset.lcm_add Multiset.lcm_add
theorem lcm_dvd {s : Multiset α} {a : α} : s.lcm ∣ a ↔ ∀ b ∈ s, b ∣ a :=
Multiset.induction_on s (by simp)
(by simp (config := { contextual := true }) [or_imp, forall_and, lcm_dvd_iff])
#align multiset.lcm_dvd Multiset.lcm_dvd
theorem dvd_lcm {s : Multiset α} {a : α} (h : a ∈ s) : a ∣ s.lcm :=
lcm_dvd.1 dvd_rfl _ h
#align multiset.dvd_lcm Multiset.dvd_lcm
theorem lcm_mono {s₁ s₂ : Multiset α} (h : s₁ ⊆ s₂) : s₁.lcm ∣ s₂.lcm :=
lcm_dvd.2 fun _ hb ↦ dvd_lcm (h hb)
#align multiset.lcm_mono Multiset.lcm_mono
/- Porting note: Following `Algebra.GCDMonoid.Basic`'s version of `normalize_gcd`, I'm giving
this lower priority to avoid linter complaints about simp-normal form -/
/- Porting note: Mathport seems to be replacing `Multiset.induction_on s $` with
`(Multiset.induction_on s)`, when it should be `Multiset.induction_on s <|`. -/
@[simp 1100]
theorem normalize_lcm (s : Multiset α) : normalize s.lcm = s.lcm :=
Multiset.induction_on s (by simp) fun a s _ ↦ by simp
#align multiset.normalize_lcm Multiset.normalize_lcm
@[simp]
nonrec theorem lcm_eq_zero_iff [Nontrivial α] (s : Multiset α) : s.lcm = 0 ↔ (0 : α) ∈ s := by
induction' s using Multiset.induction_on with a s ihs
· simp only [lcm_zero, one_ne_zero, not_mem_zero]
· simp only [mem_cons, lcm_cons, lcm_eq_zero_iff, ihs, @eq_comm _ a]
#align multiset.lcm_eq_zero_iff Multiset.lcm_eq_zero_iff
variable [DecidableEq α]
@[simp]
theorem lcm_dedup (s : Multiset α) : (dedup s).lcm = s.lcm :=
Multiset.induction_on s (by simp) fun a s IH ↦ by
by_cases h : a ∈ s <;> simp [IH, h]
unfold lcm
rw [← cons_erase h, fold_cons_left, ← lcm_assoc, lcm_same]
apply lcm_eq_of_associated_left (associated_normalize _)
#align multiset.lcm_dedup Multiset.lcm_dedup
@[simp]
| Mathlib/Algebra/GCDMonoid/Multiset.lean | 104 | 106 | theorem lcm_ndunion (s₁ s₂ : Multiset α) : (ndunion s₁ s₂).lcm = GCDMonoid.lcm s₁.lcm s₂.lcm := by |
rw [← lcm_dedup, dedup_ext.2, lcm_dedup, lcm_add]
simp
|
/-
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.Algebra.CharP.Basic
import Mathlib.GroupTheory.Perm.Cycle.Type
import Mathlib.RingTheory.Coprime.Lemmas
#align_import algebra.char_p.char_and_card from "leanprover-community/mathlib"@"2fae5fd7f90711febdadf19c44dc60fae8834d1b"
/-!
# Characteristic and cardinality
We prove some results relating characteristic and cardinality of finite rings
## Tags
characteristic, cardinality, ring
-/
/-- A prime `p` is a unit in a commutative ring `R` of nonzero characteristic iff it does not divide
the characteristic. -/
theorem isUnit_iff_not_dvd_char_of_ringChar_ne_zero (R : Type*) [CommRing R] (p : ℕ) [Fact p.Prime]
(hR : ringChar R ≠ 0) : IsUnit (p : R) ↔ ¬p ∣ ringChar R := by
have hch := CharP.cast_eq_zero R (ringChar R)
have hp : p.Prime := Fact.out
constructor
· rintro h₁ ⟨q, hq⟩
rcases IsUnit.exists_left_inv h₁ with ⟨a, ha⟩
have h₃ : ¬ringChar R ∣ q := by
rintro ⟨r, hr⟩
rw [hr, ← mul_assoc, mul_comm p, mul_assoc] at hq
nth_rw 1 [← mul_one (ringChar R)] at hq
exact Nat.Prime.not_dvd_one hp ⟨r, mul_left_cancel₀ hR hq⟩
have h₄ := mt (CharP.intCast_eq_zero_iff R (ringChar R) q).mp
apply_fun ((↑) : ℕ → R) at hq
apply_fun (· * ·) a at hq
rw [Nat.cast_mul, hch, mul_zero, ← mul_assoc, ha, one_mul] at hq
norm_cast at h₄
exact h₄ h₃ hq.symm
· intro h
rcases (hp.coprime_iff_not_dvd.mpr h).isCoprime with ⟨a, b, hab⟩
apply_fun ((↑) : ℤ → R) at hab
push_cast at hab
rw [hch, mul_zero, add_zero, mul_comm] at hab
exact isUnit_of_mul_eq_one (p : R) a hab
#align is_unit_iff_not_dvd_char_of_ring_char_ne_zero isUnit_iff_not_dvd_char_of_ringChar_ne_zero
/-- A prime `p` is a unit in a finite commutative ring `R`
iff it does not divide the characteristic. -/
theorem isUnit_iff_not_dvd_char (R : Type*) [CommRing R] (p : ℕ) [Fact p.Prime] [Finite R] :
IsUnit (p : R) ↔ ¬p ∣ ringChar R :=
isUnit_iff_not_dvd_char_of_ringChar_ne_zero R p <| CharP.char_ne_zero_of_finite R (ringChar R)
#align is_unit_iff_not_dvd_char isUnit_iff_not_dvd_char
/-- The prime divisors of the characteristic of a finite commutative ring are exactly
the prime divisors of its cardinality. -/
| Mathlib/Algebra/CharP/CharAndCard.lean | 59 | 75 | theorem prime_dvd_char_iff_dvd_card {R : Type*} [CommRing R] [Fintype R] (p : ℕ) [Fact p.Prime] :
p ∣ ringChar R ↔ p ∣ Fintype.card R := by |
refine
⟨fun h =>
h.trans <|
Int.natCast_dvd_natCast.mp <|
(CharP.intCast_eq_zero_iff R (ringChar R) (Fintype.card R)).mp <|
mod_cast Nat.cast_card_eq_zero R,
fun h => ?_⟩
by_contra h₀
rcases exists_prime_addOrderOf_dvd_card p h with ⟨r, hr⟩
have hr₁ := addOrderOf_nsmul_eq_zero r
rw [hr, nsmul_eq_mul] at hr₁
rcases IsUnit.exists_left_inv ((isUnit_iff_not_dvd_char R p).mpr h₀) with ⟨u, hu⟩
apply_fun (· * ·) u at hr₁
rw [mul_zero, ← mul_assoc, hu, one_mul] at hr₁
exact mt AddMonoid.addOrderOf_eq_one_iff.mpr (ne_of_eq_of_ne hr (Nat.Prime.ne_one Fact.out)) hr₁
|
/-
Copyright (c) 2023 Koundinya Vajjha. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Koundinya Vajjha, Thomas Browning
-/
import Mathlib.NumberTheory.Harmonic.Defs
import Mathlib.NumberTheory.Padics.PadicNumbers
/-!
The nth Harmonic number is not an integer. We formalize the proof using
2-adic valuations. This proof is due to Kürschák.
Reference:
https://kconrad.math.uconn.edu/blurbs/gradnumthy/padicharmonicsum.pdf
-/
/-- The 2-adic valuation of the n-th harmonic number is the negative of the logarithm
of n. -/
| Mathlib/NumberTheory/Harmonic/Int.lean | 21 | 33 | theorem padicValRat_two_harmonic (n : ℕ) : padicValRat 2 (harmonic n) = -Nat.log 2 n := by |
induction' n with n ih
· simp
· rcases eq_or_ne n 0 with rfl | hn
· simp
rw [harmonic_succ]
have key : padicValRat 2 (harmonic n) ≠ padicValRat 2 (↑(n + 1))⁻¹ := by
rw [ih, padicValRat.inv, padicValRat.of_nat, Ne, neg_inj, Nat.cast_inj]
exact Nat.log_ne_padicValNat_succ hn
rw [padicValRat.add_eq_min (harmonic_succ n ▸ (harmonic_pos n.succ_ne_zero).ne')
(harmonic_pos hn).ne' (inv_ne_zero (Nat.cast_ne_zero.mpr n.succ_ne_zero)) key, ih,
padicValRat.inv, padicValRat.of_nat, min_neg_neg, neg_inj, ← Nat.cast_max, Nat.cast_inj]
exact Nat.max_log_padicValNat_succ_eq_log_succ n
|
/-
Copyright (c) 2020 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov, Patrick Massot, Sébastien Gouëzel
-/
import Mathlib.Order.Interval.Set.Disjoint
import Mathlib.MeasureTheory.Integral.SetIntegral
import Mathlib.MeasureTheory.Measure.Lebesgue.Basic
#align_import measure_theory.integral.interval_integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
/-!
# Integral over an interval
In this file we define `∫ x in a..b, f x ∂μ` to be `∫ x in Ioc a b, f x ∂μ` if `a ≤ b` and
`-∫ x in Ioc b a, f x ∂μ` if `b ≤ a`.
## Implementation notes
### Avoiding `if`, `min`, and `max`
In order to avoid `if`s in the definition, we define `IntervalIntegrable f μ a b` as
`integrable_on f (Ioc a b) μ ∧ integrable_on f (Ioc b a) μ`. For any `a`, `b` one of these
intervals is empty and the other coincides with `Set.uIoc a b = Set.Ioc (min a b) (max a b)`.
Similarly, we define `∫ x in a..b, f x ∂μ` to be `∫ x in Ioc a b, f x ∂μ - ∫ x in Ioc b a, f x ∂μ`.
Again, for any `a`, `b` one of these integrals is zero, and the other gives the expected result.
This way some properties can be translated from integrals over sets without dealing with
the cases `a ≤ b` and `b ≤ a` separately.
### Choice of the interval
We use integral over `Set.uIoc a b = Set.Ioc (min a b) (max a b)` instead of one of the other
three possible intervals with the same endpoints for two reasons:
* this way `∫ x in a..b, f x ∂μ + ∫ x in b..c, f x ∂μ = ∫ x in a..c, f x ∂μ` holds whenever
`f` is integrable on each interval; in particular, it works even if the measure `μ` has an atom
at `b`; this rules out `Set.Ioo` and `Set.Icc` intervals;
* with this definition for a probability measure `μ`, the integral `∫ x in a..b, 1 ∂μ` equals
the difference $F_μ(b)-F_μ(a)$, where $F_μ(a)=μ(-∞, a]$ is the
[cumulative distribution function](https://en.wikipedia.org/wiki/Cumulative_distribution_function)
of `μ`.
## Tags
integral
-/
noncomputable section
open scoped Classical
open MeasureTheory Set Filter Function
open scoped Classical Topology Filter ENNReal Interval NNReal
variable {ι 𝕜 E F A : Type*} [NormedAddCommGroup E]
/-!
### Integrability on an interval
-/
/-- A function `f` is called *interval integrable* with respect to a measure `μ` on an unordered
interval `a..b` if it is integrable on both intervals `(a, b]` and `(b, a]`. One of these
intervals is always empty, so this property is equivalent to `f` being integrable on
`(min a b, max a b]`. -/
def IntervalIntegrable (f : ℝ → E) (μ : Measure ℝ) (a b : ℝ) : Prop :=
IntegrableOn f (Ioc a b) μ ∧ IntegrableOn f (Ioc b a) μ
#align interval_integrable IntervalIntegrable
/-!
## Basic iff's for `IntervalIntegrable`
-/
section
variable {f : ℝ → E} {a b : ℝ} {μ : Measure ℝ}
/-- A function is interval integrable with respect to a given measure `μ` on `a..b` if and
only if it is integrable on `uIoc a b` with respect to `μ`. This is an equivalent
definition of `IntervalIntegrable`. -/
theorem intervalIntegrable_iff : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ι a b) μ := by
rw [uIoc_eq_union, integrableOn_union, IntervalIntegrable]
#align interval_integrable_iff intervalIntegrable_iff
/-- If a function is interval integrable with respect to a given measure `μ` on `a..b` then
it is integrable on `uIoc a b` with respect to `μ`. -/
theorem IntervalIntegrable.def' (h : IntervalIntegrable f μ a b) : IntegrableOn f (Ι a b) μ :=
intervalIntegrable_iff.mp h
#align interval_integrable.def IntervalIntegrable.def'
| Mathlib/MeasureTheory/Integral/IntervalIntegral.lean | 93 | 95 | theorem intervalIntegrable_iff_integrableOn_Ioc_of_le (hab : a ≤ b) :
IntervalIntegrable f μ a b ↔ IntegrableOn f (Ioc a b) μ := by |
rw [intervalIntegrable_iff, uIoc_of_le hab]
|
/-
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]
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 _ _
#align transpose_dual_tensor_hom transpose_dualTensorHom
@[simp]
| Mathlib/LinearAlgebra/Contraction.lean | 96 | 101 | theorem dualTensorHom_prodMap_zero (f : Module.Dual R M) (p : P) :
((dualTensorHom R M P) (f ⊗ₜ[R] p)).prodMap (0 : N →ₗ[R] Q) =
dualTensorHom R (M × N) (P × Q) ((f ∘ₗ fst R M N) ⊗ₜ inl R P Q p) := by |
ext <;>
simp only [coe_comp, coe_inl, Function.comp_apply, prodMap_apply, dualTensorHom_apply,
fst_apply, Prod.smul_mk, LinearMap.zero_apply, smul_zero]
|
/-
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.Fin.Tuple.Basic
import Mathlib.Data.List.Join
#align_import data.list.of_fn from "leanprover-community/mathlib"@"bf27744463e9620ca4e4ebe951fe83530ae6949b"
/-!
# Lists from functions
Theorems and lemmas for dealing with `List.ofFn`, which converts a function on `Fin n` to a list
of length `n`.
## Main Statements
The main statements pertain to lists generated using `List.ofFn`
- `List.length_ofFn`, which tells us the length of such a list
- `List.get?_ofFn`, which tells us the nth element of such a list
- `List.equivSigmaTuple`, which is an `Equiv` between lists and the functions that generate them
via `List.ofFn`.
-/
universe u
variable {α : Type u}
open Nat
namespace List
#noalign list.length_of_fn_aux
@[simp]
theorem length_ofFn_go {n} (f : Fin n → α) (i j h) : length (ofFn.go f i j h) = i := by
induction i generalizing j <;> simp_all [ofFn.go]
/-- The length of a list converted from a function is the size of the domain. -/
@[simp]
theorem length_ofFn {n} (f : Fin n → α) : length (ofFn f) = n := by
simp [ofFn, length_ofFn_go]
#align list.length_of_fn List.length_ofFn
#noalign list.nth_of_fn_aux
theorem get_ofFn_go {n} (f : Fin n → α) (i j h) (k) (hk) :
get (ofFn.go f i j h) ⟨k, hk⟩ = f ⟨j + k, by simp at hk; omega⟩ := by
let i+1 := i
cases k <;> simp [ofFn.go, get_ofFn_go (i := i)]
congr 2; omega
-- Porting note (#10756): new theorem
@[simp]
| Mathlib/Data/List/OfFn.lean | 58 | 59 | theorem get_ofFn {n} (f : Fin n → α) (i) : get (ofFn f) i = f (Fin.cast (by simp) i) := by |
cases i; simp [ofFn, get_ofFn_go]
|
/-
Copyright (c) 2024 Jz Pan. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jz Pan
-/
import Mathlib.LinearAlgebra.Dimension.Finite
import Mathlib.LinearAlgebra.Dimension.Constructions
/-!
# Some results on free modules over rings satisfying strong rank condition
This file contains some results on free modules over rings satisfying strong rank condition.
Most of them are generalized from the same result assuming the base ring being division ring,
and are moved from the files `Mathlib/LinearAlgebra/Dimension/DivisionRing.lean`
and `Mathlib/LinearAlgebra/FiniteDimensional.lean`.
-/
open Cardinal Submodule Set FiniteDimensional
universe u v
section Module
variable {K : Type u} {V : Type v} [Ring K] [StrongRankCondition K] [AddCommGroup V] [Module K V]
/-- The `ι` indexed basis on `V`, where `ι` is an empty type and `V` is zero-dimensional.
See also `FiniteDimensional.finBasis`.
-/
noncomputable def Basis.ofRankEqZero [Module.Free K V] {ι : Type*} [IsEmpty ι]
(hV : Module.rank K V = 0) : Basis ι K V :=
haveI : Subsingleton V := by
obtain ⟨_, b⟩ := Module.Free.exists_basis (R := K) (M := V)
haveI := mk_eq_zero_iff.1 (hV ▸ b.mk_eq_rank'')
exact b.repr.toEquiv.subsingleton
Basis.empty _
#align basis.of_rank_eq_zero Basis.ofRankEqZero
@[simp]
theorem Basis.ofRankEqZero_apply [Module.Free K V] {ι : Type*} [IsEmpty ι]
(hV : Module.rank K V = 0) (i : ι) : Basis.ofRankEqZero hV i = 0 := rfl
#align basis.of_rank_eq_zero_apply Basis.ofRankEqZero_apply
theorem le_rank_iff_exists_linearIndependent [Module.Free K V] {c : Cardinal} :
c ≤ Module.rank K V ↔ ∃ s : Set V, #s = c ∧ LinearIndependent K ((↑) : s → V) := by
haveI := nontrivial_of_invariantBasisNumber K
constructor
· intro h
obtain ⟨κ, t'⟩ := Module.Free.exists_basis (R := K) (M := V)
let t := t'.reindexRange
have : LinearIndependent K ((↑) : Set.range t' → V) := by
convert t.linearIndependent
ext; exact (Basis.reindexRange_apply _ _).symm
rw [← t.mk_eq_rank'', le_mk_iff_exists_subset] at h
rcases h with ⟨s, hst, hsc⟩
exact ⟨s, hsc, this.mono hst⟩
· rintro ⟨s, rfl, si⟩
exact si.cardinal_le_rank
#align le_rank_iff_exists_linear_independent le_rank_iff_exists_linearIndependent
| Mathlib/LinearAlgebra/Dimension/FreeAndStrongRankCondition.lean | 63 | 71 | theorem le_rank_iff_exists_linearIndependent_finset
[Module.Free K V] {n : ℕ} : ↑n ≤ Module.rank K V ↔
∃ s : Finset V, s.card = n ∧ LinearIndependent K ((↑) : ↥(s : Set V) → V) := by |
simp only [le_rank_iff_exists_linearIndependent, mk_set_eq_nat_iff_finset]
constructor
· rintro ⟨s, ⟨t, rfl, rfl⟩, si⟩
exact ⟨t, rfl, si⟩
· rintro ⟨s, rfl, si⟩
exact ⟨s, ⟨s, rfl, rfl⟩, si⟩
|
/-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.Topology.Separation
import Mathlib.Topology.NoetherianSpace
#align_import topology.quasi_separated from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8"
/-!
# Quasi-separated spaces
A topological space is quasi-separated if the intersections of any pairs of compact open subsets
are still compact.
Notable examples include spectral spaces, Noetherian spaces, and Hausdorff spaces.
A non-example is the interval `[0, 1]` with doubled origin: the two copies of `[0, 1]` are compact
open subsets, but their intersection `(0, 1]` is not.
## Main results
- `IsQuasiSeparated`: A subset `s` of a topological space is quasi-separated if the intersections
of any pairs of compact open subsets of `s` are still compact.
- `QuasiSeparatedSpace`: A topological space is quasi-separated if the intersections of any pairs
of compact open subsets are still compact.
- `QuasiSeparatedSpace.of_openEmbedding`: If `f : α → β` is an open embedding, and `β` is
a quasi-separated space, then so is `α`.
-/
open TopologicalSpace
variable {α β : Type*} [TopologicalSpace α] [TopologicalSpace β] {f : α → β}
/-- A subset `s` of a topological space is quasi-separated if the intersections of any pairs of
compact open subsets of `s` are still compact.
Note that this is equivalent to `s` being a `QuasiSeparatedSpace` only when `s` is open. -/
def IsQuasiSeparated (s : Set α) : Prop :=
∀ U V : Set α, U ⊆ s → IsOpen U → IsCompact U → V ⊆ s → IsOpen V → IsCompact V → IsCompact (U ∩ V)
#align is_quasi_separated IsQuasiSeparated
/-- A topological space is quasi-separated if the intersections of any pairs of compact open
subsets are still compact. -/
@[mk_iff]
class QuasiSeparatedSpace (α : Type*) [TopologicalSpace α] : Prop where
/-- The intersection of two open compact subsets of a quasi-separated space is compact. -/
inter_isCompact :
∀ U V : Set α, IsOpen U → IsCompact U → IsOpen V → IsCompact V → IsCompact (U ∩ V)
#align quasi_separated_space QuasiSeparatedSpace
theorem isQuasiSeparated_univ_iff {α : Type*} [TopologicalSpace α] :
IsQuasiSeparated (Set.univ : Set α) ↔ QuasiSeparatedSpace α := by
rw [quasiSeparatedSpace_iff]
simp [IsQuasiSeparated]
#align is_quasi_separated_univ_iff isQuasiSeparated_univ_iff
theorem isQuasiSeparated_univ {α : Type*} [TopologicalSpace α] [QuasiSeparatedSpace α] :
IsQuasiSeparated (Set.univ : Set α) :=
isQuasiSeparated_univ_iff.mpr inferInstance
#align is_quasi_separated_univ isQuasiSeparated_univ
theorem IsQuasiSeparated.image_of_embedding {s : Set α} (H : IsQuasiSeparated s) (h : Embedding f) :
IsQuasiSeparated (f '' s) := by
intro U V hU hU' hU'' hV hV' hV''
convert
(H (f ⁻¹' U) (f ⁻¹' V)
?_ (h.continuous.1 _ hU') ?_ ?_ (h.continuous.1 _ hV') ?_).image h.continuous
· symm
rw [← Set.preimage_inter, Set.image_preimage_eq_inter_range, Set.inter_eq_left]
exact Set.inter_subset_left.trans (hU.trans (Set.image_subset_range _ _))
· intro x hx
rw [← h.inj.injOn.mem_image_iff (Set.subset_univ _) trivial]
exact hU hx
· rw [h.isCompact_iff]
convert hU''
rw [Set.image_preimage_eq_inter_range, Set.inter_eq_left]
exact hU.trans (Set.image_subset_range _ _)
· intro x hx
rw [← h.inj.injOn.mem_image_iff (Set.subset_univ _) trivial]
exact hV hx
· rw [h.isCompact_iff]
convert hV''
rw [Set.image_preimage_eq_inter_range, Set.inter_eq_left]
exact hV.trans (Set.image_subset_range _ _)
#align is_quasi_separated.image_of_embedding IsQuasiSeparated.image_of_embedding
theorem OpenEmbedding.isQuasiSeparated_iff (h : OpenEmbedding f) {s : Set α} :
IsQuasiSeparated s ↔ IsQuasiSeparated (f '' s) := by
refine ⟨fun hs => hs.image_of_embedding h.toEmbedding, ?_⟩
intro H U V hU hU' hU'' hV hV' hV''
rw [h.toEmbedding.isCompact_iff, Set.image_inter h.inj]
exact
H (f '' U) (f '' V) (Set.image_subset _ hU) (h.isOpenMap _ hU') (hU''.image h.continuous)
(Set.image_subset _ hV) (h.isOpenMap _ hV') (hV''.image h.continuous)
#align open_embedding.is_quasi_separated_iff OpenEmbedding.isQuasiSeparated_iff
theorem isQuasiSeparated_iff_quasiSeparatedSpace (s : Set α) (hs : IsOpen s) :
IsQuasiSeparated s ↔ QuasiSeparatedSpace s := by
rw [← isQuasiSeparated_univ_iff]
convert (hs.openEmbedding_subtype_val.isQuasiSeparated_iff (s := Set.univ)).symm
simp
#align is_quasi_separated_iff_quasi_separated_space isQuasiSeparated_iff_quasiSeparatedSpace
| Mathlib/Topology/QuasiSeparated.lean | 106 | 109 | theorem IsQuasiSeparated.of_subset {s t : Set α} (ht : IsQuasiSeparated t) (h : s ⊆ t) :
IsQuasiSeparated s := by |
intro U V hU hU' hU'' hV hV' hV''
exact ht U V (hU.trans h) hU' hU'' (hV.trans h) hV' hV''
|
/-
Copyright (c) 2019 Rohan Mitta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rohan Mitta, Kevin Buzzard, Alistair Tucker, Johannes Hölzl, Yury Kudryashov
-/
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Data.Setoid.Basic
import Mathlib.Dynamics.FixedPoints.Topology
import Mathlib.Topology.MetricSpace.Lipschitz
#align_import topology.metric_space.contracting from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
/-!
# Contracting maps
A Lipschitz continuous self-map with Lipschitz constant `K < 1` is called a *contracting map*.
In this file we prove the Banach fixed point theorem, some explicit estimates on the rate
of convergence, and some properties of the map sending a contracting map to its fixed point.
## Main definitions
* `ContractingWith K f` : a Lipschitz continuous self-map with `K < 1`;
* `efixedPoint` : given a contracting map `f` on a complete emetric space and a point `x`
such that `edist x (f x) ≠ ∞`, `efixedPoint f hf x hx` is the unique fixed point of `f`
in `EMetric.ball x ∞`;
* `fixedPoint` : the unique fixed point of a contracting map on a complete nonempty metric space.
## Tags
contracting map, fixed point, Banach fixed point theorem
-/
open scoped Classical
open NNReal Topology ENNReal Filter Function
variable {α : Type*}
/-- A map is said to be `ContractingWith K`, if `K < 1` and `f` is `LipschitzWith K`. -/
def ContractingWith [EMetricSpace α] (K : ℝ≥0) (f : α → α) :=
K < 1 ∧ LipschitzWith K f
#align contracting_with ContractingWith
namespace ContractingWith
variable [EMetricSpace α] [cs : CompleteSpace α] {K : ℝ≥0} {f : α → α}
open EMetric Set
theorem toLipschitzWith (hf : ContractingWith K f) : LipschitzWith K f := hf.2
#align contracting_with.to_lipschitz_with ContractingWith.toLipschitzWith
theorem one_sub_K_pos' (hf : ContractingWith K f) : (0 : ℝ≥0∞) < 1 - K := by simp [hf.1]
set_option linter.uppercaseLean3 false in
#align contracting_with.one_sub_K_pos' ContractingWith.one_sub_K_pos'
theorem one_sub_K_ne_zero (hf : ContractingWith K f) : (1 : ℝ≥0∞) - K ≠ 0 :=
ne_of_gt hf.one_sub_K_pos'
set_option linter.uppercaseLean3 false in
#align contracting_with.one_sub_K_ne_zero ContractingWith.one_sub_K_ne_zero
theorem one_sub_K_ne_top : (1 : ℝ≥0∞) - K ≠ ∞ := by
norm_cast
exact ENNReal.coe_ne_top
set_option linter.uppercaseLean3 false in
#align contracting_with.one_sub_K_ne_top ContractingWith.one_sub_K_ne_top
theorem edist_inequality (hf : ContractingWith K f) {x y} (h : edist x y ≠ ∞) :
edist x y ≤ (edist x (f x) + edist y (f y)) / (1 - K) :=
suffices edist x y ≤ edist x (f x) + edist y (f y) + K * edist x y by
rwa [ENNReal.le_div_iff_mul_le (Or.inl hf.one_sub_K_ne_zero) (Or.inl one_sub_K_ne_top),
mul_comm, ENNReal.sub_mul fun _ _ ↦ h, one_mul, tsub_le_iff_right]
calc
edist x y ≤ edist x (f x) + edist (f x) (f y) + edist (f y) y := edist_triangle4 _ _ _ _
_ = edist x (f x) + edist y (f y) + edist (f x) (f y) := by rw [edist_comm y, add_right_comm]
_ ≤ edist x (f x) + edist y (f y) + K * edist x y := add_le_add le_rfl (hf.2 _ _)
#align contracting_with.edist_inequality ContractingWith.edist_inequality
theorem edist_le_of_fixedPoint (hf : ContractingWith K f) {x y} (h : edist x y ≠ ∞)
(hy : IsFixedPt f y) : edist x y ≤ edist x (f x) / (1 - K) := by
simpa only [hy.eq, edist_self, add_zero] using hf.edist_inequality h
#align contracting_with.edist_le_of_fixed_point ContractingWith.edist_le_of_fixedPoint
| Mathlib/Topology/MetricSpace/Contracting.lean | 84 | 87 | theorem eq_or_edist_eq_top_of_fixedPoints (hf : ContractingWith K f) {x y} (hx : IsFixedPt f x)
(hy : IsFixedPt f y) : x = y ∨ edist x y = ∞ := by |
refine or_iff_not_imp_right.2 fun h ↦ edist_le_zero.1 ?_
simpa only [hx.eq, edist_self, add_zero, ENNReal.zero_div] using hf.edist_le_of_fixedPoint h hy
|
/-
Copyright (c) 2021 Yourong Zang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yourong Zang
-/
import Mathlib.Analysis.NormedSpace.Basic
import Mathlib.Analysis.NormedSpace.LinearIsometry
#align_import analysis.normed_space.conformal_linear_map from "leanprover-community/mathlib"@"d1bd9c5df2867c1cb463bc6364446d57bdd9f7f1"
/-!
# Conformal Linear Maps
A continuous linear map between `R`-normed spaces `X` and `Y` `IsConformalMap` if it is
a nonzero multiple of a linear isometry.
## Main definitions
* `IsConformalMap`: the main definition of conformal linear maps
## Main results
* The conformality of the composition of two conformal linear maps, the identity map
and multiplications by nonzero constants as continuous linear maps
* `isConformalMap_of_subsingleton`: all continuous linear maps on singleton spaces are conformal
See `Analysis.InnerProductSpace.ConformalLinearMap` for
* `isConformalMap_iff`: a map between inner product spaces is conformal
iff it preserves inner products up to a fixed scalar factor.
## Tags
conformal
## Warning
The definition of conformality in this file does NOT require the maps to be orientation-preserving.
-/
noncomputable section
open Function LinearIsometry ContinuousLinearMap
/-- A continuous linear map `f'` is said to be conformal if it's
a nonzero multiple of a linear isometry. -/
def IsConformalMap {R : Type*} {X Y : Type*} [NormedField R] [SeminormedAddCommGroup X]
[SeminormedAddCommGroup Y] [NormedSpace R X] [NormedSpace R Y] (f' : X →L[R] Y) :=
∃ c ≠ (0 : R), ∃ li : X →ₗᵢ[R] Y, f' = c • li.toContinuousLinearMap
#align is_conformal_map IsConformalMap
variable {R M N G M' : Type*} [NormedField R] [SeminormedAddCommGroup M] [SeminormedAddCommGroup N]
[SeminormedAddCommGroup G] [NormedSpace R M] [NormedSpace R N] [NormedSpace R G]
[NormedAddCommGroup M'] [NormedSpace R M'] {f : M →L[R] N} {g : N →L[R] G} {c : R}
theorem isConformalMap_id : IsConformalMap (id R M) :=
⟨1, one_ne_zero, id, by simp⟩
#align is_conformal_map_id isConformalMap_id
| Mathlib/Analysis/NormedSpace/ConformalLinearMap.lean | 62 | 65 | theorem IsConformalMap.smul (hf : IsConformalMap f) {c : R} (hc : c ≠ 0) :
IsConformalMap (c • f) := by |
rcases hf with ⟨c', hc', li, rfl⟩
exact ⟨c * c', mul_ne_zero hc hc', li, smul_smul _ _ _⟩
|
/-
Copyright (c) 2022 Kexing Ying. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying, Bhavik Mehta
-/
import Mathlib.Probability.ConditionalProbability
import Mathlib.MeasureTheory.Measure.Count
#align_import probability.cond_count from "leanprover-community/mathlib"@"117e93f82b5f959f8193857370109935291f0cc4"
/-!
# Classical probability
The classical formulation of probability states that the probability of an event occurring in a
finite probability space is the ratio of that event to all possible events.
This notion can be expressed with measure theory using
the counting measure. In particular, given the sets `s` and `t`, we define the probability of `t`
occurring in `s` to be `|s|⁻¹ * |s ∩ t|`. With this definition, we recover the probability over
the entire sample space when `s = Set.univ`.
Classical probability is often used in combinatorics and we prove some useful lemmas in this file
for that purpose.
## Main definition
* `ProbabilityTheory.condCount`: given a set `s`, `condCount s` is the counting measure
conditioned on `s`. This is a probability measure when `s` is finite and nonempty.
## Notes
The original aim of this file is to provide a measure theoretic method of describing the
probability an element of a set `s` satisfies some predicate `P`. Our current formulation still
allow us to describe this by abusing the definitional equality of sets and predicates by simply
writing `condCount s P`. We should avoid this however as none of the lemmas are written for
predicates.
-/
noncomputable section
open ProbabilityTheory
open MeasureTheory MeasurableSpace
namespace ProbabilityTheory
variable {Ω : Type*} [MeasurableSpace Ω]
/-- Given a set `s`, `condCount s` is the counting measure conditioned on `s`. In particular,
`condCount s t` is the proportion of `s` that is contained in `t`.
This is a probability measure when `s` is finite and nonempty and is given by
`ProbabilityTheory.condCount_isProbabilityMeasure`. -/
def condCount (s : Set Ω) : Measure Ω :=
Measure.count[|s]
#align probability_theory.cond_count ProbabilityTheory.condCount
@[simp]
theorem condCount_empty_meas : (condCount ∅ : Measure Ω) = 0 := by simp [condCount]
#align probability_theory.cond_count_empty_meas ProbabilityTheory.condCount_empty_meas
theorem condCount_empty {s : Set Ω} : condCount s ∅ = 0 := by simp
#align probability_theory.cond_count_empty ProbabilityTheory.condCount_empty
theorem finite_of_condCount_ne_zero {s t : Set Ω} (h : condCount s t ≠ 0) : s.Finite := by
by_contra hs'
simp [condCount, cond, Measure.count_apply_infinite hs'] at h
#align probability_theory.finite_of_cond_count_ne_zero ProbabilityTheory.finite_of_condCount_ne_zero
theorem condCount_univ [Fintype Ω] {s : Set Ω} :
condCount Set.univ s = Measure.count s / Fintype.card Ω := by
rw [condCount, cond_apply _ MeasurableSet.univ, ← ENNReal.div_eq_inv_mul, Set.univ_inter]
congr
rw [← Finset.coe_univ, Measure.count_apply, Finset.univ.tsum_subtype' fun _ => (1 : ENNReal)]
· simp [Finset.card_univ]
· exact (@Finset.coe_univ Ω _).symm ▸ MeasurableSet.univ
#align probability_theory.cond_count_univ ProbabilityTheory.condCount_univ
variable [MeasurableSingletonClass Ω]
theorem condCount_isProbabilityMeasure {s : Set Ω} (hs : s.Finite) (hs' : s.Nonempty) :
IsProbabilityMeasure (condCount s) :=
{ measure_univ := by
rw [condCount, cond_apply _ hs.measurableSet, Set.inter_univ, ENNReal.inv_mul_cancel]
· exact fun h => hs'.ne_empty <| Measure.empty_of_count_eq_zero h
· exact (Measure.count_apply_lt_top.2 hs).ne }
#align probability_theory.cond_count_is_probability_measure ProbabilityTheory.condCount_isProbabilityMeasure
| Mathlib/Probability/CondCount.lean | 89 | 95 | theorem condCount_singleton (ω : Ω) (t : Set Ω) [Decidable (ω ∈ t)] :
condCount {ω} t = if ω ∈ t then 1 else 0 := by |
rw [condCount, cond_apply _ (measurableSet_singleton ω), Measure.count_singleton, inv_one,
one_mul]
split_ifs
· rw [(by simpa : ({ω} : Set Ω) ∩ t = {ω}), Measure.count_singleton]
· rw [(by simpa : ({ω} : Set Ω) ∩ t = ∅), Measure.count_empty]
|
/-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Gamma.Beta
import Mathlib.NumberTheory.LSeries.HurwitzZeta
import Mathlib.Analysis.Complex.RemovableSingularity
import Mathlib.Analysis.PSeriesComplex
#align_import number_theory.zeta_function from "leanprover-community/mathlib"@"57f9349f2fe19d2de7207e99b0341808d977cdcf"
/-!
# Definition of the Riemann zeta function
## Main definitions:
* `riemannZeta`: the Riemann zeta function `ζ : ℂ → ℂ`.
* `completedRiemannZeta`: the completed zeta function `Λ : ℂ → ℂ`, which satisfies
`Λ(s) = π ^ (-s / 2) Γ(s / 2) ζ(s)` (away from the poles of `Γ(s / 2)`).
* `completedRiemannZeta₀`: the entire function `Λ₀` satisfying
`Λ₀(s) = Λ(s) + 1 / (s - 1) - 1 / s` wherever the RHS is defined.
Note that mathematically `ζ(s)` is undefined at `s = 1`, while `Λ(s)` is undefined at both `s = 0`
and `s = 1`. Our construction assigns some values at these points; exact formulae involving the
Euler-Mascheroni constant will follow in a subsequent PR.
## Main results:
* `differentiable_completedZeta₀` : the function `Λ₀(s)` is entire.
* `differentiableAt_completedZeta` : the function `Λ(s)` is differentiable away from `s = 0` and
`s = 1`.
* `differentiableAt_riemannZeta` : the function `ζ(s)` is differentiable away from `s = 1`.
* `zeta_eq_tsum_one_div_nat_add_one_cpow` : for `1 < re s`, we have
`ζ(s) = ∑' (n : ℕ), 1 / (n + 1) ^ s`.
* `completedRiemannZeta₀_one_sub`, `completedRiemannZeta_one_sub`, and `riemannZeta_one_sub` :
functional equation relating values at `s` and `1 - s`
For special-value formulae expressing `ζ (2 * k)` and `ζ (1 - 2 * k)` in terms of Bernoulli numbers
see `Mathlib.NumberTheory.LSeries.HurwitzZetaValues`. For computation of the constant term as
`s → 1`, see `Mathlib.NumberTheory.Harmonic.ZetaAsymp`.
## Outline of proofs:
These results are mostly special cases of more general results for even Hurwitz zeta functions
proved in `Mathlib.NumberTheory.LSeries.HurwitzZetaEven`.
-/
open MeasureTheory Set Filter Asymptotics TopologicalSpace Real Asymptotics
Classical HurwitzZeta
open Complex hiding exp norm_eq_abs abs_of_nonneg abs_two continuous_exp
open scoped Topology Real Nat
noncomputable section
/-!
## Definition of the completed Riemann zeta
-/
/-- The completed Riemann zeta function with its poles removed, `Λ(s) + 1 / s - 1 / (s - 1)`. -/
def completedRiemannZeta₀ (s : ℂ) : ℂ := completedHurwitzZetaEven₀ 0 s
#align riemann_completed_zeta₀ completedRiemannZeta₀
/-- The completed Riemann zeta function, `Λ(s)`, which satisfies
`Λ(s) = π ^ (-s / 2) Γ(s / 2) ζ(s)` (up to a minor correction at `s = 0`). -/
def completedRiemannZeta (s : ℂ) : ℂ := completedHurwitzZetaEven 0 s
#align riemann_completed_zeta completedRiemannZeta
lemma HurwitzZeta.completedHurwitzZetaEven_zero (s : ℂ) :
completedHurwitzZetaEven 0 s = completedRiemannZeta s := rfl
lemma HurwitzZeta.completedHurwitzZetaEven₀_zero (s : ℂ) :
completedHurwitzZetaEven₀ 0 s = completedRiemannZeta₀ s := rfl
lemma HurwitzZeta.completedCosZeta_zero (s : ℂ) :
completedCosZeta 0 s = completedRiemannZeta s := by
rw [completedRiemannZeta, completedHurwitzZetaEven, completedCosZeta, hurwitzEvenFEPair_zero_symm]
lemma HurwitzZeta.completedCosZeta₀_zero (s : ℂ) :
completedCosZeta₀ 0 s = completedRiemannZeta₀ s := by
rw [completedRiemannZeta₀, completedHurwitzZetaEven₀, completedCosZeta₀,
hurwitzEvenFEPair_zero_symm]
lemma completedRiemannZeta_eq (s : ℂ) :
completedRiemannZeta s = completedRiemannZeta₀ s - 1 / s - 1 / (1 - s) := by
simp_rw [completedRiemannZeta, completedRiemannZeta₀, completedHurwitzZetaEven_eq, if_true]
/-- The modified completed Riemann zeta function `Λ(s) + 1 / s + 1 / (1 - s)` is entire. -/
theorem differentiable_completedZeta₀ : Differentiable ℂ completedRiemannZeta₀ :=
differentiable_completedHurwitzZetaEven₀ 0
#align differentiable_completed_zeta₀ differentiable_completedZeta₀
/-- The completed Riemann zeta function `Λ(s)` is differentiable away from `s = 0` and `s = 1`. -/
theorem differentiableAt_completedZeta {s : ℂ} (hs : s ≠ 0) (hs' : s ≠ 1) :
DifferentiableAt ℂ completedRiemannZeta s :=
differentiableAt_completedHurwitzZetaEven 0 (Or.inl hs) hs'
/-- Riemann zeta functional equation, formulated for `Λ₀`: for any complex `s` we have
`Λ₀(1 - s) = Λ₀ s`. -/
theorem completedRiemannZeta₀_one_sub (s : ℂ) :
completedRiemannZeta₀ (1 - s) = completedRiemannZeta₀ s := by
rw [← completedHurwitzZetaEven₀_zero, ← completedCosZeta₀_zero, completedHurwitzZetaEven₀_one_sub]
#align riemann_completed_zeta₀_one_sub completedRiemannZeta₀_one_sub
/-- Riemann zeta functional equation, formulated for `Λ`: for any complex `s` we have
`Λ (1 - s) = Λ s`. -/
| Mathlib/NumberTheory/LSeries/RiemannZeta.lean | 110 | 112 | theorem completedRiemannZeta_one_sub (s : ℂ) :
completedRiemannZeta (1 - s) = completedRiemannZeta s := by |
rw [← completedHurwitzZetaEven_zero, ← completedCosZeta_zero, completedHurwitzZetaEven_one_sub]
|
/-
Copyright (c) 2021 Benjamin Davidson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Benjamin Davidson, Yury Kudryashov
-/
import Mathlib.Analysis.Calculus.LocalExtr.Rolle
import Mathlib.Analysis.Calculus.Deriv.Polynomial
import Mathlib.Topology.Algebra.Polynomial
#align_import analysis.calculus.local_extr from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
/-!
# Rolle's Theorem for polynomials
In this file we use Rolle's Theorem
to relate the number of real roots of a real polynomial and its derivative.
Namely, we prove the following facts.
* `Polynomial.card_roots_toFinset_le_card_roots_derivative_diff_roots_succ`:
the number of roots of a real polynomial `p` is at most the number of roots of its derivative
that are not roots of `p` plus one.
* `Polynomial.card_roots_toFinset_le_derivative`, `Polynomial.card_rootSet_le_derivative`:
the number of roots of a real polynomial
is at most the number of roots of its derivative plus one.
* `Polynomial.card_roots_le_derivative`: same, but the roots are counted with multiplicities.
## Keywords
polynomial, Rolle's Theorem, root
-/
namespace Polynomial
/-- The number of roots of a real polynomial `p` is at most the number of roots of its derivative
that are not roots of `p` plus one. -/
| Mathlib/Analysis/Calculus/LocalExtr/Polynomial.lean | 36 | 46 | theorem card_roots_toFinset_le_card_roots_derivative_diff_roots_succ (p : ℝ[X]) :
p.roots.toFinset.card ≤ (p.derivative.roots.toFinset \ p.roots.toFinset).card + 1 := by |
rcases eq_or_ne (derivative p) 0 with hp' | hp'
· rw [eq_C_of_derivative_eq_zero hp', roots_C, Multiset.toFinset_zero, Finset.card_empty]
exact zero_le _
have hp : p ≠ 0 := ne_of_apply_ne derivative (by rwa [derivative_zero])
refine Finset.card_le_diff_of_interleaved fun x hx y hy hxy hxy' => ?_
rw [Multiset.mem_toFinset, mem_roots hp] at hx hy
obtain ⟨z, hz1, hz2⟩ := exists_deriv_eq_zero hxy p.continuousOn (hx.trans hy.symm)
refine ⟨z, ?_, hz1⟩
rwa [Multiset.mem_toFinset, mem_roots hp', IsRoot, ← p.deriv]
|
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Floris van Doorn, Violeta Hernández Palacios
-/
import Mathlib.SetTheory.Ordinal.Arithmetic
#align_import set_theory.ordinal.exponential from "leanprover-community/mathlib"@"b67044ba53af18680e1dd246861d9584e968495d"
/-! # Ordinal exponential
In this file we define the power function and the logarithm function on ordinals. The two are
related by the lemma `Ordinal.opow_le_iff_le_log : b ^ c ≤ x ↔ c ≤ log b x` for nontrivial inputs
`b`, `c`.
-/
noncomputable section
open Function Cardinal Set Equiv Order
open scoped Classical
open Cardinal Ordinal
universe u v w
namespace Ordinal
/-- The ordinal exponential, defined by transfinite recursion. -/
instance pow : Pow Ordinal Ordinal :=
⟨fun a b => if a = 0 then 1 - b else limitRecOn b 1 (fun _ IH => IH * a) fun b _ => bsup.{u, u} b⟩
-- Porting note: Ambiguous notations.
-- local infixr:0 "^" => @Pow.pow Ordinal Ordinal Ordinal.instPowOrdinalOrdinal
theorem opow_def (a b : Ordinal) :
a ^ b = if a = 0 then 1 - b else limitRecOn b 1 (fun _ IH => IH * a) fun b _ => bsup.{u, u} b :=
rfl
#align ordinal.opow_def Ordinal.opow_def
-- Porting note: `if_pos rfl` → `if_true`
| Mathlib/SetTheory/Ordinal/Exponential.lean | 42 | 42 | theorem zero_opow' (a : Ordinal) : 0 ^ a = 1 - a := by | simp only [opow_def, if_true]
|
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Yury Kudryashov, Neil Strickland
-/
import Mathlib.Algebra.Regular.Basic
import Mathlib.Algebra.Ring.Defs
#align_import algebra.ring.regular from "leanprover-community/mathlib"@"2f3994e1b117b1e1da49bcfb67334f33460c3ce4"
/-!
# Lemmas about regular elements in rings.
-/
variable {α : Type*}
/-- Left `Mul` by a `k : α` over `[Ring α]` is injective, if `k` is not a zero divisor.
The typeclass that restricts all terms of `α` to have this property is `NoZeroDivisors`. -/
| Mathlib/Algebra/Ring/Regular.lean | 20 | 23 | theorem isLeftRegular_of_non_zero_divisor [NonUnitalNonAssocRing α] (k : α)
(h : ∀ x : α, k * x = 0 → x = 0) : IsLeftRegular k := by |
refine fun x y (h' : k * x = k * y) => sub_eq_zero.mp (h _ ?_)
rw [mul_sub, sub_eq_zero, h']
|
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Amelia Livingston, Yury Kudryashov,
Neil Strickland, Aaron Anderson
-/
import Mathlib.Algebra.Divisibility.Basic
import Mathlib.Algebra.Group.Units
#align_import algebra.divisibility.units from "leanprover-community/mathlib"@"e574b1a4e891376b0ef974b926da39e05da12a06"
/-!
# Divisibility and units
## Main definition
* `IsRelPrime x y`: that `x` and `y` are relatively prime, defined to mean that the only common
divisors of `x` and `y` are the units.
-/
variable {α : Type*}
namespace Units
section Monoid
variable [Monoid α] {a b : α} {u : αˣ}
/-- Elements of the unit group of a monoid represented as elements of the monoid
divide any element of the monoid. -/
theorem coe_dvd : ↑u ∣ a :=
⟨↑u⁻¹ * a, by simp⟩
#align units.coe_dvd Units.coe_dvd
/-- In a monoid, an element `a` divides an element `b` iff `a` divides all
associates of `b`. -/
theorem dvd_mul_right : a ∣ b * u ↔ a ∣ b :=
Iff.intro (fun ⟨c, Eq⟩ ↦ ⟨c * ↑u⁻¹, by rw [← mul_assoc, ← Eq, Units.mul_inv_cancel_right]⟩)
fun ⟨c, Eq⟩ ↦ Eq.symm ▸ (_root_.dvd_mul_right _ _).mul_right _
#align units.dvd_mul_right Units.dvd_mul_right
/-- In a monoid, an element `a` divides an element `b` iff all associates of `a` divide `b`. -/
theorem mul_right_dvd : a * u ∣ b ↔ a ∣ b :=
Iff.intro (fun ⟨c, Eq⟩ => ⟨↑u * c, Eq.trans (mul_assoc _ _ _)⟩) fun h =>
dvd_trans (Dvd.intro (↑u⁻¹) (by rw [mul_assoc, u.mul_inv, mul_one])) h
#align units.mul_right_dvd Units.mul_right_dvd
end Monoid
section CommMonoid
variable [CommMonoid α] {a b : α} {u : αˣ}
/-- In a commutative monoid, an element `a` divides an element `b` iff `a` divides all left
associates of `b`. -/
theorem dvd_mul_left : a ∣ u * b ↔ a ∣ b := by
rw [mul_comm]
apply dvd_mul_right
#align units.dvd_mul_left Units.dvd_mul_left
/-- In a commutative monoid, an element `a` divides an element `b` iff all
left associates of `a` divide `b`. -/
theorem mul_left_dvd : ↑u * a ∣ b ↔ a ∣ b := by
rw [mul_comm]
apply mul_right_dvd
#align units.mul_left_dvd Units.mul_left_dvd
end CommMonoid
end Units
namespace IsUnit
section Monoid
variable [Monoid α] {a b u : α} (hu : IsUnit u)
/-- Units of a monoid divide any element of the monoid. -/
@[simp]
theorem dvd : u ∣ a := by
rcases hu with ⟨u, rfl⟩
apply Units.coe_dvd
#align is_unit.dvd IsUnit.dvd
@[simp]
theorem dvd_mul_right : a ∣ b * u ↔ a ∣ b := by
rcases hu with ⟨u, rfl⟩
apply Units.dvd_mul_right
#align is_unit.dvd_mul_right IsUnit.dvd_mul_right
/-- In a monoid, an element a divides an element b iff all associates of `a` divide `b`. -/
@[simp]
theorem mul_right_dvd : a * u ∣ b ↔ a ∣ b := by
rcases hu with ⟨u, rfl⟩
apply Units.mul_right_dvd
#align is_unit.mul_right_dvd IsUnit.mul_right_dvd
theorem isPrimal : IsPrimal u := fun _ _ _ ↦ ⟨u, 1, hu.dvd, one_dvd _, (mul_one u).symm⟩
end Monoid
section CommMonoid
variable [CommMonoid α] {a b u : α} (hu : IsUnit u)
/-- In a commutative monoid, an element `a` divides an element `b` iff `a` divides all left
associates of `b`. -/
@[simp]
theorem dvd_mul_left : a ∣ u * b ↔ a ∣ b := by
rcases hu with ⟨u, rfl⟩
apply Units.dvd_mul_left
#align is_unit.dvd_mul_left IsUnit.dvd_mul_left
/-- In a commutative monoid, an element `a` divides an element `b` iff all
left associates of `a` divide `b`. -/
@[simp]
| Mathlib/Algebra/Divisibility/Units.lean | 118 | 120 | theorem mul_left_dvd : u * a ∣ b ↔ a ∣ b := by |
rcases hu with ⟨u, rfl⟩
apply Units.mul_left_dvd
|
/-
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]
theorem card_disjSum : Multiset.card (s.disjSum t) = Multiset.card s + Multiset.card t := by
rw [disjSum, card_add, card_map, card_map]
#align multiset.card_disj_sum Multiset.card_disjSum
variable {s t} {s₁ s₂ : Multiset α} {t₁ t₂ : Multiset β} {a : α} {b : β} {x : Sum α β}
theorem mem_disjSum : x ∈ s.disjSum t ↔ (∃ a, a ∈ s ∧ inl a = x) ∨ ∃ b, b ∈ t ∧ inr b = x := by
simp_rw [disjSum, mem_add, mem_map]
#align multiset.mem_disj_sum Multiset.mem_disjSum
@[simp]
theorem inl_mem_disjSum : inl a ∈ s.disjSum t ↔ a ∈ s := by
rw [mem_disjSum, or_iff_left]
-- Porting note: Previous code for L62 was: simp only [exists_eq_right]
· simp only [inl.injEq, exists_eq_right]
rintro ⟨b, _, hb⟩
exact inr_ne_inl hb
#align multiset.inl_mem_disj_sum Multiset.inl_mem_disjSum
@[simp]
| Mathlib/Data/Multiset/Sum.lean | 64 | 69 | theorem inr_mem_disjSum : inr b ∈ s.disjSum t ↔ b ∈ t := by |
rw [mem_disjSum, or_iff_right]
-- Porting note: Previous code for L72 was: simp only [exists_eq_right]
· simp only [inr.injEq, exists_eq_right]
rintro ⟨a, _, ha⟩
exact inl_ne_inr ha
|
/-
Copyright (c) 2018 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
-/
import Mathlib.Order.CompleteLattice
import Mathlib.Order.GaloisConnection
import Mathlib.Data.Set.Lattice
import Mathlib.Tactic.AdaptationNote
#align_import data.rel from "leanprover-community/mathlib"@"706d88f2b8fdfeb0b22796433d7a6c1a010af9f2"
/-!
# Relations
This file defines bundled relations. A relation between `α` and `β` is a function `α → β → Prop`.
Relations are also known as set-valued functions, or partial multifunctions.
## Main declarations
* `Rel α β`: Relation between `α` and `β`.
* `Rel.inv`: `r.inv` is the `Rel β α` obtained by swapping the arguments of `r`.
* `Rel.dom`: Domain of a relation. `x ∈ r.dom` iff there exists `y` such that `r x y`.
* `Rel.codom`: Codomain, aka range, of a relation. `y ∈ r.codom` iff there exists `x` such that
`r x y`.
* `Rel.comp`: Relation composition. Note that the arguments order follows the `CategoryTheory/`
one, so `r.comp s x z ↔ ∃ y, r x y ∧ s y z`.
* `Rel.image`: Image of a set under a relation. `r.image s` is the set of `f x` over all `x ∈ s`.
* `Rel.preimage`: Preimage of a set under a relation. Note that `r.preimage = r.inv.image`.
* `Rel.core`: Core of a set. For `s : Set β`, `r.core s` is the set of `x : α` such that all `y`
related to `x` are in `s`.
* `Rel.restrict_domain`: Domain-restriction of a relation to a subtype.
* `Function.graph`: Graph of a function as a relation.
## TODOs
The `Rel.comp` function uses the notation `r • s`, rather than the more common `r ∘ s` for things
named `comp`. This is because the latter is already used for function composition, and causes a
clash. A better notation should be found, perhaps a variant of `r ∘r s` or `r; s`.
-/
variable {α β γ : Type*}
/-- A relation on `α` and `β`, aka a set-valued function, aka a partial multifunction -/
def Rel (α β : Type*) :=
α → β → Prop -- deriving CompleteLattice, Inhabited
#align rel Rel
-- Porting note: `deriving` above doesn't work.
instance : CompleteLattice (Rel α β) := show CompleteLattice (α → β → Prop) from inferInstance
instance : Inhabited (Rel α β) := show Inhabited (α → β → Prop) from inferInstance
namespace Rel
variable (r : Rel α β)
-- Porting note: required for later theorems.
@[ext] theorem ext {r s : Rel α β} : (∀ a, r a = s a) → r = s := funext
/-- The inverse relation : `r.inv x y ↔ r y x`. Note that this is *not* a groupoid inverse. -/
def inv : Rel β α :=
flip r
#align rel.inv Rel.inv
theorem inv_def (x : α) (y : β) : r.inv y x ↔ r x y :=
Iff.rfl
#align rel.inv_def Rel.inv_def
| Mathlib/Data/Rel.lean | 70 | 72 | theorem inv_inv : inv (inv r) = r := by |
ext x y
rfl
|
/-
Copyright (c) 2022 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen
-/
import Mathlib.RingTheory.DedekindDomain.Ideal
#align_import number_theory.ramification_inertia from "leanprover-community/mathlib"@"039a089d2a4b93c761b234f3e5f5aeb752bac60f"
/-!
# Ramification index and inertia degree
Given `P : Ideal S` lying over `p : Ideal R` for the ring extension `f : R →+* S`
(assuming `P` and `p` are prime or maximal where needed),
the **ramification index** `Ideal.ramificationIdx f p P` is the multiplicity of `P` in `map f p`,
and the **inertia degree** `Ideal.inertiaDeg f p P` is the degree of the field extension
`(S / P) : (R / p)`.
## Main results
The main theorem `Ideal.sum_ramification_inertia` states that for all coprime `P` lying over `p`,
`Σ P, ramification_idx f p P * inertia_deg f p P` equals the degree of the field extension
`Frac(S) : Frac(R)`.
## Implementation notes
Often the above theory is set up in the case where:
* `R` is the ring of integers of a number field `K`,
* `L` is a finite separable extension of `K`,
* `S` is the integral closure of `R` in `L`,
* `p` and `P` are maximal ideals,
* `P` is an ideal lying over `p`
We will try to relax the above hypotheses as much as possible.
## Notation
In this file, `e` stands for the ramification index and `f` for the inertia degree of `P` over `p`,
leaving `p` and `P` implicit.
-/
namespace Ideal
universe u v
variable {R : Type u} [CommRing R]
variable {S : Type v} [CommRing S] (f : R →+* S)
variable (p : Ideal R) (P : Ideal S)
open FiniteDimensional
open UniqueFactorizationMonoid
section DecEq
open scoped Classical
/-- The ramification index of `P` over `p` is the largest exponent `n` such that
`p` is contained in `P^n`.
In particular, if `p` is not contained in `P^n`, then the ramification index is 0.
If there is no largest such `n` (e.g. because `p = ⊥`), then `ramificationIdx` is
defined to be 0.
-/
noncomputable def ramificationIdx : ℕ := sSup {n | map f p ≤ P ^ n}
#align ideal.ramification_idx Ideal.ramificationIdx
variable {f p P}
theorem ramificationIdx_eq_find (h : ∃ n, ∀ k, map f p ≤ P ^ k → k ≤ n) :
ramificationIdx f p P = Nat.find h :=
Nat.sSup_def h
#align ideal.ramification_idx_eq_find Ideal.ramificationIdx_eq_find
theorem ramificationIdx_eq_zero (h : ∀ n : ℕ, ∃ k, map f p ≤ P ^ k ∧ n < k) :
ramificationIdx f p P = 0 :=
dif_neg (by push_neg; exact h)
#align ideal.ramification_idx_eq_zero Ideal.ramificationIdx_eq_zero
theorem ramificationIdx_spec {n : ℕ} (hle : map f p ≤ P ^ n) (hgt : ¬map f p ≤ P ^ (n + 1)) :
ramificationIdx f p P = n := by
let Q : ℕ → Prop := fun m => ∀ k : ℕ, map f p ≤ P ^ k → k ≤ m
have : Q n := by
intro k hk
refine le_of_not_lt fun hnk => ?_
exact hgt (hk.trans (Ideal.pow_le_pow_right hnk))
rw [ramificationIdx_eq_find ⟨n, this⟩]
refine le_antisymm (Nat.find_min' _ this) (le_of_not_gt fun h : Nat.find _ < n => ?_)
obtain this' := Nat.find_spec ⟨n, this⟩
exact h.not_le (this' _ hle)
#align ideal.ramification_idx_spec Ideal.ramificationIdx_spec
| Mathlib/NumberTheory/RamificationInertia.lean | 95 | 103 | theorem ramificationIdx_lt {n : ℕ} (hgt : ¬map f p ≤ P ^ n) : ramificationIdx f p P < n := by |
cases' n with n n
· simp at hgt
· rw [Nat.lt_succ_iff]
have : ∀ k, map f p ≤ P ^ k → k ≤ n := by
refine fun k hk => le_of_not_lt fun hnk => ?_
exact hgt (hk.trans (Ideal.pow_le_pow_right hnk))
rw [ramificationIdx_eq_find ⟨n, this⟩]
exact Nat.find_min' ⟨n, this⟩ this
|
/-
Copyright (c) 2020 Robert Y. Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Y. Lewis
-/
import Batteries.Tactic.Lint.Basic
import Mathlib.Algebra.Order.Monoid.Unbundled.Basic
import Mathlib.Algebra.Order.Ring.Defs
import Mathlib.Algebra.Order.ZeroLEOne
import Mathlib.Data.Nat.Cast.Order
import Mathlib.Init.Data.Int.Order
/-!
# Lemmas for `linarith`.
Those in the `Linarith` namespace should stay here.
Those outside the `Linarith` namespace may be deleted as they are ported to mathlib4.
-/
set_option autoImplicit true
namespace Linarith
theorem lt_irrefl {α : Type u} [Preorder α] {a : α} : ¬a < a := _root_.lt_irrefl a
theorem eq_of_eq_of_eq {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (hb : b = 0) : a + b = 0 := by
simp [*]
theorem le_of_eq_of_le {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (hb : b ≤ 0) : a + b ≤ 0 := by
simp [*]
| Mathlib/Tactic/Linarith/Lemmas.lean | 33 | 34 | theorem lt_of_eq_of_lt {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (hb : b < 0) : a + b < 0 := by |
simp [*]
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa, Junyan Xu
-/
import Mathlib.Data.DFinsupp.Basic
#align_import data.dfinsupp.ne_locus from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c"
/-!
# Locus of unequal values of finitely supported dependent functions
Let `N : α → Type*` be a type family, assume that `N a` has a `0` for all `a : α` and let
`f g : Π₀ a, N a` be finitely supported dependent functions.
## Main definition
* `DFinsupp.neLocus f g : Finset α`, the finite subset of `α` where `f` and `g` differ.
In the case in which `N a` is an additive group for all `a`, `DFinsupp.neLocus f g` coincides with
`DFinsupp.support (f - g)`.
-/
variable {α : Type*} {N : α → Type*}
namespace DFinsupp
variable [DecidableEq α]
section NHasZero
variable [∀ a, DecidableEq (N a)] [∀ a, Zero (N a)] (f g : Π₀ a, N a)
/-- Given two finitely supported functions `f g : α →₀ N`, `Finsupp.neLocus f g` is the `Finset`
where `f` and `g` differ. This generalizes `(f - g).support` to situations without subtraction. -/
def neLocus (f g : Π₀ a, N a) : Finset α :=
(f.support ∪ g.support).filter fun x ↦ f x ≠ g x
#align dfinsupp.ne_locus DFinsupp.neLocus
@[simp]
| Mathlib/Data/DFinsupp/NeLocus.lean | 41 | 43 | theorem mem_neLocus {f g : Π₀ a, N a} {a : α} : a ∈ f.neLocus g ↔ f a ≠ g a := by |
simpa only [neLocus, Finset.mem_filter, Finset.mem_union, mem_support_iff,
and_iff_right_iff_imp] using Ne.ne_or_ne _
|
/-
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]
| Mathlib/Data/List/Intervals.lean | 120 | 122 | theorem succ_singleton {n : ℕ} : Ico n (n + 1) = [n] := by |
dsimp [Ico]
simp [range', Nat.add_sub_cancel_left]
|
/-
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.Monoid.Unbundled.Pow
import Mathlib.Data.Finset.Fold
import Mathlib.Data.Finset.Option
import Mathlib.Data.Finset.Pi
import Mathlib.Data.Finset.Prod
import Mathlib.Data.Multiset.Lattice
import Mathlib.Data.Set.Lattice
import Mathlib.Order.Hom.Lattice
import Mathlib.Order.Nat
#align_import data.finset.lattice from "leanprover-community/mathlib"@"442a83d738cb208d3600056c489be16900ba701d"
/-!
# Lattice operations on finsets
-/
-- TODO:
-- assert_not_exists OrderedCommMonoid
assert_not_exists MonoidWithZero
open Function Multiset OrderDual
variable {F α β γ ι κ : Type*}
namespace Finset
/-! ### sup -/
section Sup
-- TODO: define with just `[Bot α]` where some lemmas hold without requiring `[OrderBot α]`
variable [SemilatticeSup α] [OrderBot α]
/-- Supremum of a finite set: `sup {a, b, c} f = f a ⊔ f b ⊔ f c` -/
def sup (s : Finset β) (f : β → α) : α :=
s.fold (· ⊔ ·) ⊥ f
#align finset.sup Finset.sup
variable {s s₁ s₂ : Finset β} {f g : β → α} {a : α}
theorem sup_def : s.sup f = (s.1.map f).sup :=
rfl
#align finset.sup_def Finset.sup_def
@[simp]
theorem sup_empty : (∅ : Finset β).sup f = ⊥ :=
fold_empty
#align finset.sup_empty Finset.sup_empty
@[simp]
theorem sup_cons {b : β} (h : b ∉ s) : (cons b s h).sup f = f b ⊔ s.sup f :=
fold_cons h
#align finset.sup_cons Finset.sup_cons
@[simp]
theorem sup_insert [DecidableEq β] {b : β} : (insert b s : Finset β).sup f = f b ⊔ s.sup f :=
fold_insert_idem
#align finset.sup_insert Finset.sup_insert
@[simp]
theorem sup_image [DecidableEq β] (s : Finset γ) (f : γ → β) (g : β → α) :
(s.image f).sup g = s.sup (g ∘ f) :=
fold_image_idem
#align finset.sup_image Finset.sup_image
@[simp]
theorem sup_map (s : Finset γ) (f : γ ↪ β) (g : β → α) : (s.map f).sup g = s.sup (g ∘ f) :=
fold_map
#align finset.sup_map Finset.sup_map
@[simp]
theorem sup_singleton {b : β} : ({b} : Finset β).sup f = f b :=
Multiset.sup_singleton
#align finset.sup_singleton Finset.sup_singleton
| Mathlib/Data/Finset/Lattice.lean | 82 | 87 | theorem sup_sup : s.sup (f ⊔ g) = s.sup f ⊔ s.sup g := by |
induction s using Finset.cons_induction with
| empty => rw [sup_empty, sup_empty, sup_empty, bot_sup_eq]
| cons _ _ _ ih =>
rw [sup_cons, sup_cons, sup_cons, ih]
exact sup_sup_sup_comm _ _ _ _
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.