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) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Michael Stoll
-/
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic
#align_import number_theory.legendre_symbol.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9"
/-!
# Legendre symbol
This file contains results about Legendre symbols.
We define the Legendre symbol $\Bigl(\frac{a}{p}\Bigr)$ as `legendreSym p a`.
Note the order of arguments! The advantage of this form is that then `legendreSym p`
is a multiplicative map.
The Legendre symbol is used to define the Jacobi symbol, `jacobiSym a b`, for integers `a`
and (odd) natural numbers `b`, which extends the Legendre symbol.
## Main results
We also prove the supplementary laws that give conditions for when `-1`
is a square modulo a prime `p`:
`legendreSym.at_neg_one` and `ZMod.exists_sq_eq_neg_one_iff` for `-1`.
See `NumberTheory.LegendreSymbol.QuadraticReciprocity` for the conditions when `2` and `-2`
are squares:
`legendreSym.at_two` and `ZMod.exists_sq_eq_two_iff` for `2`,
`legendreSym.at_neg_two` and `ZMod.exists_sq_eq_neg_two_iff` for `-2`.
## Tags
quadratic residue, quadratic nonresidue, Legendre symbol
-/
open Nat
section Euler
namespace ZMod
variable (p : ℕ) [Fact p.Prime]
/-- Euler's Criterion: A unit `x` of `ZMod p` is a square if and only if `x ^ (p / 2) = 1`. -/
| Mathlib/NumberTheory/LegendreSymbol/Basic.lean | 48 | 57 | theorem euler_criterion_units (x : (ZMod p)ˣ) : (∃ y : (ZMod p)ˣ, y ^ 2 = x) ↔ x ^ (p / 2) = 1 := by |
by_cases hc : p = 2
· subst hc
simp only [eq_iff_true_of_subsingleton, exists_const]
· have h₀ := FiniteField.unit_isSquare_iff (by rwa [ringChar_zmod_n]) x
have hs : (∃ y : (ZMod p)ˣ, y ^ 2 = x) ↔ IsSquare x := by
rw [isSquare_iff_exists_sq x]
simp_rw [eq_comm]
rw [hs]
rwa [card p] at h₀
|
/-
Copyright (c) 2024 Riccardo Brasca. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Riccardo Brasca
-/
import Mathlib.NumberTheory.NumberField.ClassNumber
import Mathlib.NumberTheory.Cyclotomic.Rat
import Mathlib.NumberTheory.Cyclotomic.Embeddings
/-!
# Cyclotomic fields whose ring of integers is a PID.
We prove that `ℤ [ζₚ]` is a PID for specific values of `p`. The result holds for `p ≤ 19`,
but the proof is more and more involved.
## Main results
* `three_pid`: If `IsCyclotomicExtension {3} ℚ K` then `𝓞 K` is a principal ideal domain.
* `five_pid`: If `IsCyclotomicExtension {5} ℚ K` then `𝓞 K` is a principal ideal domain.
-/
universe u
namespace IsCyclotomicExtension.Rat
open NumberField Polynomial InfinitePlace Nat Real cyclotomic
variable (K : Type u) [Field K] [NumberField K]
/-- If `IsCyclotomicExtension {3} ℚ K` then `𝓞 K` is a principal ideal domain. -/
theorem three_pid [IsCyclotomicExtension {3} ℚ K] : IsPrincipalIdealRing (𝓞 K) := by
apply RingOfIntegers.isPrincipalIdealRing_of_abs_discr_lt
rw [absdiscr_prime 3 K, IsCyclotomicExtension.finrank (n := 3) K
(irreducible_rat (by norm_num)), nrComplexPlaces_eq_totient_div_two 3, totient_prime
PNat.prime_three]
simp only [Int.reduceNeg, PNat.val_ofNat, succ_sub_succ_eq_sub, tsub_zero, zero_lt_two,
Nat.div_self, pow_one, cast_ofNat, neg_mul, one_mul, abs_neg, Int.cast_abs, Int.cast_ofNat,
factorial_two, gt_iff_lt, abs_of_pos (show (0 : ℝ) < 3 by norm_num)]
suffices (2 * (3 / 4) * (2 ^ 2 / 2)) ^ 2 < (2 * (π / 4) * (2 ^ 2 / 2)) ^ 2 from
lt_trans (by norm_num) this
gcongr
exact pi_gt_three
/-- If `IsCyclotomicExtension {5} ℚ K` then `𝓞 K` is a principal ideal domain. -/
| Mathlib/NumberTheory/Cyclotomic/PID.lean | 44 | 55 | theorem five_pid [IsCyclotomicExtension {5} ℚ K] : IsPrincipalIdealRing (𝓞 K) := by |
apply RingOfIntegers.isPrincipalIdealRing_of_abs_discr_lt
rw [absdiscr_prime 5 K, IsCyclotomicExtension.finrank (n := 5) K
(irreducible_rat (by norm_num)), nrComplexPlaces_eq_totient_div_two 5, totient_prime
PNat.prime_five]
simp only [Int.reduceNeg, PNat.val_ofNat, succ_sub_succ_eq_sub, tsub_zero, reduceDiv, even_two,
Even.neg_pow, one_pow, cast_ofNat, Int.reducePow, one_mul, Int.cast_abs, Int.cast_ofNat,
div_pow, gt_iff_lt, show 4! = 24 by rfl, abs_of_pos (show (0 : ℝ) < 125 by norm_num)]
suffices (2 * (3 ^ 2 / 4 ^ 2) * (4 ^ 4 / 24)) ^ 2 < (2 * (π ^ 2 / 4 ^ 2) * (4 ^ 4 / 24)) ^ 2 from
lt_trans (by norm_num) this
gcongr
exact pi_gt_three
|
/-
Copyright (c) 2021 Thomas Browning. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Thomas Browning
-/
import Mathlib.GroupTheory.Sylow
import Mathlib.GroupTheory.Transfer
#align_import group_theory.schur_zassenhaus from "leanprover-community/mathlib"@"d57133e49cf06508700ef69030cd099917e0f0de"
/-!
# The Schur-Zassenhaus Theorem
In this file we prove the Schur-Zassenhaus theorem.
## Main results
- `exists_right_complement'_of_coprime`: The **Schur-Zassenhaus** theorem:
If `H : Subgroup G` is normal and has order coprime to its index,
then there exists a subgroup `K` which is a (right) complement of `H`.
- `exists_left_complement'_of_coprime`: The **Schur-Zassenhaus** theorem:
If `H : Subgroup G` is normal and has order coprime to its index,
then there exists a subgroup `K` which is a (left) complement of `H`.
-/
namespace Subgroup
section SchurZassenhausAbelian
open MulOpposite MulAction Subgroup.leftTransversals MemLeftTransversals
variable {G : Type*} [Group G] (H : Subgroup G) [IsCommutative H] [FiniteIndex H]
(α β : leftTransversals (H : Set G))
/-- The quotient of the transversals of an abelian normal `N` by the `diff` relation. -/
def QuotientDiff :=
Quotient
(Setoid.mk (fun α β => diff (MonoidHom.id H) α β = 1)
⟨fun α => diff_self (MonoidHom.id H) α, fun h => by rw [← diff_inv, h, inv_one],
fun h h' => by rw [← diff_mul_diff, h, h', one_mul]⟩)
#align subgroup.quotient_diff Subgroup.QuotientDiff
instance : Inhabited H.QuotientDiff := by
dsimp [QuotientDiff] -- Porting note: Added `dsimp`
infer_instance
theorem smul_diff_smul' [hH : Normal H] (g : Gᵐᵒᵖ) :
diff (MonoidHom.id H) (g • α) (g • β) =
⟨g.unop⁻¹ * (diff (MonoidHom.id H) α β : H) * g.unop,
hH.mem_comm ((congr_arg (· ∈ H) (mul_inv_cancel_left _ _)).mpr (SetLike.coe_mem _))⟩ := by
letI := H.fintypeQuotientOfFiniteIndex
let ϕ : H →* H :=
{ toFun := fun h =>
⟨g.unop⁻¹ * h * g.unop,
hH.mem_comm ((congr_arg (· ∈ H) (mul_inv_cancel_left _ _)).mpr (SetLike.coe_mem _))⟩
map_one' := by rw [Subtype.ext_iff, coe_mk, coe_one, mul_one, inv_mul_self]
map_mul' := fun h₁ h₂ => by
simp only [Subtype.ext_iff, coe_mk, coe_mul, mul_assoc, mul_inv_cancel_left] }
refine (Fintype.prod_equiv (MulAction.toPerm g).symm _ _ fun x ↦ ?_).trans (map_prod ϕ _ _).symm
simp only [ϕ, smul_apply_eq_smul_apply_inv_smul, smul_eq_mul_unop, mul_inv_rev, mul_assoc,
MonoidHom.id_apply, toPerm_symm_apply, MonoidHom.coe_mk, OneHom.coe_mk]
#align subgroup.smul_diff_smul' Subgroup.smul_diff_smul'
variable {H} [Normal H]
noncomputable instance : MulAction G H.QuotientDiff where
smul g :=
Quotient.map' (fun α => op g⁻¹ • α) fun α β h =>
Subtype.ext
(by
rwa [smul_diff_smul', coe_mk, coe_one, mul_eq_one_iff_eq_inv, mul_right_eq_self, ←
coe_one, ← Subtype.ext_iff])
mul_smul g₁ g₂ q :=
Quotient.inductionOn' q fun T =>
congr_arg Quotient.mk'' (by rw [mul_inv_rev]; exact mul_smul (op g₁⁻¹) (op g₂⁻¹) T)
one_smul q :=
Quotient.inductionOn' q fun T =>
congr_arg Quotient.mk'' (by rw [inv_one]; apply one_smul Gᵐᵒᵖ T)
| Mathlib/GroupTheory/SchurZassenhaus.lean | 81 | 89 | theorem smul_diff' (h : H) :
diff (MonoidHom.id H) α (op (h : G) • β) = diff (MonoidHom.id H) α β * h ^ H.index := by |
letI := H.fintypeQuotientOfFiniteIndex
rw [diff, diff, index_eq_card, ← Finset.card_univ, ← Finset.prod_const, ← Finset.prod_mul_distrib]
refine Finset.prod_congr rfl fun q _ => ?_
simp_rw [Subtype.ext_iff, MonoidHom.id_apply, coe_mul, mul_assoc, mul_right_inj]
rw [smul_apply_eq_smul_apply_inv_smul, smul_eq_mul_unop, MulOpposite.unop_op, mul_left_inj,
← Subtype.ext_iff, Equiv.apply_eq_iff_eq, inv_smul_eq_iff]
exact self_eq_mul_right.mpr ((QuotientGroup.eq_one_iff _).mpr h.2)
|
/-
Copyright (c) 2019 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Anne Baanen
-/
import Mathlib.LinearAlgebra.Dimension.Basic
import Mathlib.SetTheory.Cardinal.ToNat
#align_import linear_algebra.finrank from "leanprover-community/mathlib"@"347636a7a80595d55bedf6e6fbd996a3c39da69a"
/-!
# Finite dimension of vector spaces
Definition of the rank of a module, or dimension of a vector space, as a natural number.
## Main definitions
Defined is `FiniteDimensional.finrank`, the dimension of a finite dimensional space, returning a
`Nat`, as opposed to `Module.rank`, which returns a `Cardinal`. When the space has infinite
dimension, its `finrank` is by convention set to `0`.
The definition of `finrank` does not assume a `FiniteDimensional` instance, but lemmas might.
Import `LinearAlgebra.FiniteDimensional` to get access to these additional lemmas.
Formulas for the dimension are given for linear equivs, in `LinearEquiv.finrank_eq`.
## Implementation notes
Most results are deduced from the corresponding results for the general dimension (as a cardinal),
in `Dimension.lean`. Not all results have been ported yet.
You should not assume that there has been any effort to state lemmas as generally as possible.
-/
universe u v w
open Cardinal Submodule Module Function
variable {R : Type u} {M : Type v} {N : Type w}
variable [Ring R] [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N]
namespace FiniteDimensional
section Ring
/-- The rank of a module as a natural number.
Defined by convention to be `0` if the space has infinite rank.
For a vector space `M` over a field `R`, this is the same as the finite dimension
of `M` over `R`.
-/
noncomputable def finrank (R M : Type*) [Semiring R] [AddCommGroup M] [Module R M] : ℕ :=
Cardinal.toNat (Module.rank R M)
#align finite_dimensional.finrank FiniteDimensional.finrank
theorem finrank_eq_of_rank_eq {n : ℕ} (h : Module.rank R M = ↑n) : finrank R M = n := by
apply_fun toNat at h
rw [toNat_natCast] at h
exact mod_cast h
#align finite_dimensional.finrank_eq_of_rank_eq FiniteDimensional.finrank_eq_of_rank_eq
lemma rank_eq_one_iff_finrank_eq_one : Module.rank R M = 1 ↔ finrank R M = 1 :=
Cardinal.toNat_eq_one.symm
/-- This is like `rank_eq_one_iff_finrank_eq_one` but works for `2`, `3`, `4`, ... -/
lemma rank_eq_ofNat_iff_finrank_eq_ofNat (n : ℕ) [Nat.AtLeastTwo n] :
Module.rank R M = OfNat.ofNat n ↔ finrank R M = OfNat.ofNat n :=
Cardinal.toNat_eq_ofNat.symm
theorem finrank_le_of_rank_le {n : ℕ} (h : Module.rank R M ≤ ↑n) : finrank R M ≤ n := by
rwa [← Cardinal.toNat_le_iff_le_of_lt_aleph0, toNat_natCast] at h
· exact h.trans_lt (nat_lt_aleph0 n)
· exact nat_lt_aleph0 n
#align finite_dimensional.finrank_le_of_rank_le FiniteDimensional.finrank_le_of_rank_le
theorem finrank_lt_of_rank_lt {n : ℕ} (h : Module.rank R M < ↑n) : finrank R M < n := by
rwa [← Cardinal.toNat_lt_iff_lt_of_lt_aleph0, toNat_natCast] at h
· exact h.trans (nat_lt_aleph0 n)
· exact nat_lt_aleph0 n
#align finite_dimensional.finrank_lt_of_rank_lt FiniteDimensional.finrank_lt_of_rank_lt
| Mathlib/LinearAlgebra/Dimension/Finrank.lean | 84 | 89 | theorem lt_rank_of_lt_finrank {n : ℕ} (h : n < finrank R M) : ↑n < Module.rank R M := by |
rwa [← Cardinal.toNat_lt_iff_lt_of_lt_aleph0, toNat_natCast]
· exact nat_lt_aleph0 n
· contrapose! h
rw [finrank, Cardinal.toNat_apply_of_aleph0_le h]
exact n.zero_le
|
/-
Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl
-/
import Mathlib.Algebra.Order.Group.Abs
import Mathlib.Algebra.Order.Monoid.Unbundled.MinMax
#align_import algebra.order.group.min_max from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1"
/-!
# `min` and `max` in linearly ordered groups.
-/
section
variable {α : Type*} [Group α] [LinearOrder α] [CovariantClass α α (· * ·) (· ≤ ·)]
-- TODO: This duplicates `oneLePart_div_leOnePart`
@[to_additive (attr := simp)]
theorem max_one_div_max_inv_one_eq_self (a : α) : max a 1 / max a⁻¹ 1 = a := by
rcases le_total a 1 with (h | h) <;> simp [h]
#align max_one_div_max_inv_one_eq_self max_one_div_max_inv_one_eq_self
#align max_zero_sub_max_neg_zero_eq_self max_zero_sub_max_neg_zero_eq_self
alias max_zero_sub_eq_self := max_zero_sub_max_neg_zero_eq_self
#align max_zero_sub_eq_self max_zero_sub_eq_self
@[to_additive]
lemma max_inv_one (a : α) : max a⁻¹ 1 = a⁻¹ * max a 1 := by
rw [eq_inv_mul_iff_mul_eq, ← eq_div_iff_mul_eq', max_one_div_max_inv_one_eq_self]
end
section LinearOrderedCommGroup
variable {α : Type*} [LinearOrderedCommGroup α] {a b c : α}
@[to_additive min_neg_neg]
theorem min_inv_inv' (a b : α) : min a⁻¹ b⁻¹ = (max a b)⁻¹ :=
Eq.symm <| (@Monotone.map_max α αᵒᵈ _ _ Inv.inv a b) fun _ _ =>
-- Porting note: Explicit `α` necessary to infer `CovariantClass` instance
(@inv_le_inv_iff α _ _ _).mpr
#align min_inv_inv' min_inv_inv'
#align min_neg_neg min_neg_neg
@[to_additive max_neg_neg]
theorem max_inv_inv' (a b : α) : max a⁻¹ b⁻¹ = (min a b)⁻¹ :=
Eq.symm <| (@Monotone.map_min α αᵒᵈ _ _ Inv.inv a b) fun _ _ =>
-- Porting note: Explicit `α` necessary to infer `CovariantClass` instance
(@inv_le_inv_iff α _ _ _).mpr
#align max_inv_inv' max_inv_inv'
#align max_neg_neg max_neg_neg
@[to_additive min_sub_sub_right]
theorem min_div_div_right' (a b c : α) : min (a / c) (b / c) = min a b / c := by
simpa only [div_eq_mul_inv] using min_mul_mul_right a b c⁻¹
#align min_div_div_right' min_div_div_right'
#align min_sub_sub_right min_sub_sub_right
@[to_additive max_sub_sub_right]
theorem max_div_div_right' (a b c : α) : max (a / c) (b / c) = max a b / c := by
simpa only [div_eq_mul_inv] using max_mul_mul_right a b c⁻¹
#align max_div_div_right' max_div_div_right'
#align max_sub_sub_right max_sub_sub_right
@[to_additive min_sub_sub_left]
theorem min_div_div_left' (a b c : α) : min (a / b) (a / c) = a / max b c := by
simp only [div_eq_mul_inv, min_mul_mul_left, min_inv_inv']
#align min_div_div_left' min_div_div_left'
#align min_sub_sub_left min_sub_sub_left
@[to_additive max_sub_sub_left]
theorem max_div_div_left' (a b c : α) : max (a / b) (a / c) = a / min b c := by
simp only [div_eq_mul_inv, max_mul_mul_left, max_inv_inv']
#align max_div_div_left' max_div_div_left'
#align max_sub_sub_left max_sub_sub_left
end LinearOrderedCommGroup
section LinearOrderedAddCommGroup
variable {α : Type*} [LinearOrderedAddCommGroup α] {a b c : α}
theorem max_sub_max_le_max (a b c d : α) : max a b - max c d ≤ max (a - c) (b - d) := by
simp only [sub_le_iff_le_add, max_le_iff]; constructor
· calc
a = a - c + c := (sub_add_cancel a c).symm
_ ≤ max (a - c) (b - d) + max c d := add_le_add (le_max_left _ _) (le_max_left _ _)
· calc
b = b - d + d := (sub_add_cancel b d).symm
_ ≤ max (a - c) (b - d) + max c d := add_le_add (le_max_right _ _) (le_max_right _ _)
#align max_sub_max_le_max max_sub_max_le_max
theorem abs_max_sub_max_le_max (a b c d : α) : |max a b - max c d| ≤ max |a - c| |b - d| := by
refine abs_sub_le_iff.2 ⟨?_, ?_⟩
· exact (max_sub_max_le_max _ _ _ _).trans (max_le_max (le_abs_self _) (le_abs_self _))
· rw [abs_sub_comm a c, abs_sub_comm b d]
exact (max_sub_max_le_max _ _ _ _).trans (max_le_max (le_abs_self _) (le_abs_self _))
#align abs_max_sub_max_le_max abs_max_sub_max_le_max
theorem abs_min_sub_min_le_max (a b c d : α) : |min a b - min c d| ≤ max |a - c| |b - d| := by
simpa only [max_neg_neg, neg_sub_neg, abs_sub_comm] using
abs_max_sub_max_le_max (-a) (-b) (-c) (-d)
#align abs_min_sub_min_le_max abs_min_sub_min_le_max
| Mathlib/Algebra/Order/Group/MinMax.lean | 108 | 110 | theorem abs_max_sub_max_le_abs (a b c : α) : |max a c - max b c| ≤ |a - b| := by |
simpa only [sub_self, abs_zero, max_eq_left (abs_nonneg (a - b))]
using abs_max_sub_max_le_max a c b c
|
/-
Copyright (c) 2022 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
import Mathlib.Data.List.Infix
#align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2"
/-!
# Dropping or taking from lists on the right
Taking or removing element from the tail end of a list
## Main definitions
- `rdrop n`: drop `n : ℕ` elements from the tail
- `rtake n`: take `n : ℕ` elements from the tail
- `rdropWhile p`: remove all the elements from the tail of a list until it finds the first element
for which `p : α → Bool` returns false. This element and everything before is returned.
- `rtakeWhile p`: Returns the longest terminal segment of a list for which `p : α → Bool` returns
true.
## Implementation detail
The two predicate-based methods operate by performing the regular "from-left" operation on
`List.reverse`, followed by another `List.reverse`, so they are not the most performant.
The other two rely on `List.length l` so they still traverse the list twice. One could construct
another function that takes a `L : ℕ` and use `L - n`. Under a proof condition that
`L = l.length`, the function would do the right thing.
-/
-- Make sure we don't import algebra
assert_not_exists Monoid
variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ)
namespace List
/-- Drop `n` elements from the tail end of a list. -/
def rdrop : List α :=
l.take (l.length - n)
#align list.rdrop List.rdrop
@[simp]
theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop]
#align list.rdrop_nil List.rdrop_nil
@[simp]
theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop]
#align list.rdrop_zero List.rdrop_zero
theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by
rw [rdrop]
induction' l using List.reverseRecOn with xs x IH generalizing n
· simp
· cases n
· simp [take_append]
· simp [take_append_eq_append_take, IH]
#align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse
@[simp]
theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by
simp [rdrop_eq_reverse_drop_reverse]
#align list.rdrop_concat_succ List.rdrop_concat_succ
/-- Take `n` elements from the tail end of a list. -/
def rtake : List α :=
l.drop (l.length - n)
#align list.rtake List.rtake
@[simp]
theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake]
#align list.rtake_nil List.rtake_nil
@[simp]
theorem rtake_zero : rtake l 0 = [] := by simp [rtake]
#align list.rtake_zero List.rtake_zero
theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by
rw [rtake]
induction' l using List.reverseRecOn with xs x IH generalizing n
· simp
· cases n
· exact drop_length _
· simp [drop_append_eq_append_drop, IH]
#align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse
@[simp]
theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by
simp [rtake_eq_reverse_take_reverse]
#align list.rtake_concat_succ List.rtake_concat_succ
/-- Drop elements from the tail end of a list that satisfy `p : α → Bool`.
Implemented naively via `List.reverse` -/
def rdropWhile : List α :=
reverse (l.reverse.dropWhile p)
#align list.rdrop_while List.rdropWhile
@[simp]
| Mathlib/Data/List/DropRight.lean | 102 | 102 | theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by | simp [rdropWhile, dropWhile]
|
/-
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Jeremy Avigad
-/
import Mathlib.Init.Function
import Mathlib.Init.Order.Defs
#align_import data.bool.basic from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Booleans
This file proves various trivial lemmas about booleans and their
relation to decidable propositions.
## Tags
bool, boolean, Bool, De Morgan
-/
namespace Bool
@[deprecated (since := "2024-06-07")] alias decide_True := decide_true_eq_true
#align bool.to_bool_true decide_true_eq_true
@[deprecated (since := "2024-06-07")] alias decide_False := decide_false_eq_false
#align bool.to_bool_false decide_false_eq_false
#align bool.to_bool_coe Bool.decide_coe
@[deprecated (since := "2024-06-07")] alias coe_decide := decide_eq_true_iff
#align bool.coe_to_bool decide_eq_true_iff
@[deprecated decide_eq_true_iff (since := "2024-06-07")]
alias of_decide_iff := decide_eq_true_iff
#align bool.of_to_bool_iff decide_eq_true_iff
#align bool.tt_eq_to_bool_iff true_eq_decide_iff
#align bool.ff_eq_to_bool_iff false_eq_decide_iff
@[deprecated (since := "2024-06-07")] alias decide_not := decide_not
#align bool.to_bool_not decide_not
#align bool.to_bool_and Bool.decide_and
#align bool.to_bool_or Bool.decide_or
#align bool.to_bool_eq decide_eq_decide
@[deprecated (since := "2024-06-07")] alias not_false' := false_ne_true
#align bool.not_ff Bool.false_ne_true
@[deprecated (since := "2024-06-07")] alias eq_iff_eq_true_iff := eq_iff_iff
#align bool.default_bool Bool.default_bool
theorem dichotomy (b : Bool) : b = false ∨ b = true := by cases b <;> simp
#align bool.dichotomy Bool.dichotomy
theorem forall_bool' {p : Bool → Prop} (b : Bool) : (∀ x, p x) ↔ p b ∧ p !b :=
⟨fun h ↦ ⟨h _, h _⟩, fun ⟨h₁, h₂⟩ x ↦ by cases b <;> cases x <;> assumption⟩
@[simp]
theorem forall_bool {p : Bool → Prop} : (∀ b, p b) ↔ p false ∧ p true :=
forall_bool' false
#align bool.forall_bool Bool.forall_bool
theorem exists_bool' {p : Bool → Prop} (b : Bool) : (∃ x, p x) ↔ p b ∨ p !b :=
⟨fun ⟨x, hx⟩ ↦ by cases x <;> cases b <;> first | exact .inl ‹_› | exact .inr ‹_›,
fun h ↦ by cases h <;> exact ⟨_, ‹_›⟩⟩
@[simp]
theorem exists_bool {p : Bool → Prop} : (∃ b, p b) ↔ p false ∨ p true :=
exists_bool' false
#align bool.exists_bool Bool.exists_bool
#align bool.decidable_forall_bool Bool.instDecidableForallOfDecidablePred
#align bool.decidable_exists_bool Bool.instDecidableExistsOfDecidablePred
#align bool.cond_eq_ite Bool.cond_eq_ite
#align bool.cond_to_bool Bool.cond_decide
#align bool.cond_bnot Bool.cond_not
theorem not_ne_id : not ≠ id := fun h ↦ false_ne_true <| congrFun h true
#align bool.bnot_ne_id Bool.not_ne_id
#align bool.coe_bool_iff Bool.coe_iff_coe
@[deprecated (since := "2024-06-07")] alias eq_true_of_ne_false := eq_true_of_ne_false
#align bool.eq_tt_of_ne_ff eq_true_of_ne_false
@[deprecated (since := "2024-06-07")] alias eq_false_of_ne_true := eq_false_of_ne_true
#align bool.eq_ff_of_ne_tt eq_true_of_ne_false
#align bool.bor_comm Bool.or_comm
#align bool.bor_assoc Bool.or_assoc
#align bool.bor_left_comm Bool.or_left_comm
| Mathlib/Data/Bool/Basic.lean | 99 | 99 | theorem or_inl {a b : Bool} (H : a) : a || b := by | simp [H]
|
/-
Copyright (c) 2021 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky, Chris Hughes
-/
import Mathlib.Data.List.Nodup
#align_import data.list.duplicate from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
/-!
# List duplicates
## Main definitions
* `List.Duplicate x l : Prop` is an inductive property that holds when `x` is a duplicate in `l`
## Implementation details
In this file, `x ∈+ l` notation is shorthand for `List.Duplicate x l`.
-/
variable {α : Type*}
namespace List
/-- Property that an element `x : α` of `l : List α` can be found in the list more than once. -/
inductive Duplicate (x : α) : List α → Prop
| cons_mem {l : List α} : x ∈ l → Duplicate x (x :: l)
| cons_duplicate {y : α} {l : List α} : Duplicate x l → Duplicate x (y :: l)
#align list.duplicate List.Duplicate
local infixl:50 " ∈+ " => List.Duplicate
variable {l : List α} {x : α}
theorem Mem.duplicate_cons_self (h : x ∈ l) : x ∈+ x :: l :=
Duplicate.cons_mem h
#align list.mem.duplicate_cons_self List.Mem.duplicate_cons_self
theorem Duplicate.duplicate_cons (h : x ∈+ l) (y : α) : x ∈+ y :: l :=
Duplicate.cons_duplicate h
#align list.duplicate.duplicate_cons List.Duplicate.duplicate_cons
theorem Duplicate.mem (h : x ∈+ l) : x ∈ l := by
induction' h with l' _ y l' _ hm
· exact mem_cons_self _ _
· exact mem_cons_of_mem _ hm
#align list.duplicate.mem List.Duplicate.mem
theorem Duplicate.mem_cons_self (h : x ∈+ x :: l) : x ∈ l := by
cases' h with _ h _ _ h
· exact h
· exact h.mem
#align list.duplicate.mem_cons_self List.Duplicate.mem_cons_self
@[simp]
theorem duplicate_cons_self_iff : x ∈+ x :: l ↔ x ∈ l :=
⟨Duplicate.mem_cons_self, Mem.duplicate_cons_self⟩
#align list.duplicate_cons_self_iff List.duplicate_cons_self_iff
theorem Duplicate.ne_nil (h : x ∈+ l) : l ≠ [] := fun H => (mem_nil_iff x).mp (H ▸ h.mem)
#align list.duplicate.ne_nil List.Duplicate.ne_nil
@[simp]
theorem not_duplicate_nil (x : α) : ¬x ∈+ [] := fun H => H.ne_nil rfl
#align list.not_duplicate_nil List.not_duplicate_nil
theorem Duplicate.ne_singleton (h : x ∈+ l) (y : α) : l ≠ [y] := by
induction' h with l' h z l' h _
· simp [ne_nil_of_mem h]
· simp [ne_nil_of_mem h.mem]
#align list.duplicate.ne_singleton List.Duplicate.ne_singleton
@[simp]
theorem not_duplicate_singleton (x y : α) : ¬x ∈+ [y] := fun H => H.ne_singleton _ rfl
#align list.not_duplicate_singleton List.not_duplicate_singleton
theorem Duplicate.elim_nil (h : x ∈+ []) : False :=
not_duplicate_nil x h
#align list.duplicate.elim_nil List.Duplicate.elim_nil
theorem Duplicate.elim_singleton {y : α} (h : x ∈+ [y]) : False :=
not_duplicate_singleton x y h
#align list.duplicate.elim_singleton List.Duplicate.elim_singleton
theorem duplicate_cons_iff {y : α} : x ∈+ y :: l ↔ y = x ∧ x ∈ l ∨ x ∈+ l := by
refine ⟨fun h => ?_, fun h => ?_⟩
· cases' h with _ hm _ _ hm
· exact Or.inl ⟨rfl, hm⟩
· exact Or.inr hm
· rcases h with (⟨rfl | h⟩ | h)
· simpa
· exact h.cons_duplicate
#align list.duplicate_cons_iff List.duplicate_cons_iff
theorem Duplicate.of_duplicate_cons {y : α} (h : x ∈+ y :: l) (hx : x ≠ y) : x ∈+ l := by
simpa [duplicate_cons_iff, hx.symm] using h
#align list.duplicate.of_duplicate_cons List.Duplicate.of_duplicate_cons
| Mathlib/Data/List/Duplicate.lean | 102 | 103 | theorem duplicate_cons_iff_of_ne {y : α} (hne : x ≠ y) : x ∈+ y :: l ↔ x ∈+ l := by |
simp [duplicate_cons_iff, hne.symm]
|
/-
Copyright (c) 2021 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.RingTheory.Ideal.Maps
import Mathlib.Tactic.NoncommRing
#align_import algebra.algebra.spectrum from "leanprover-community/mathlib"@"58a272265b5e05f258161260dd2c5d247213cbd3"
/-!
# Spectrum of an element in an algebra
This file develops the basic theory of the spectrum of an element of an algebra.
This theory will serve as the foundation for spectral theory in Banach algebras.
## Main definitions
* `resolventSet a : Set R`: the resolvent set of an element `a : A` where
`A` is an `R`-algebra.
* `spectrum a : Set R`: the spectrum of an element `a : A` where
`A` is an `R`-algebra.
* `resolvent : R → A`: the resolvent function is `fun r ↦ Ring.inverse (↑ₐr - a)`, and hence
when `r ∈ resolvent R A`, it is actually the inverse of the unit `(↑ₐr - a)`.
## Main statements
* `spectrum.unit_smul_eq_smul` and `spectrum.smul_eq_smul`: units in the scalar ring commute
(multiplication) with the spectrum, and over a field even `0` commutes with the spectrum.
* `spectrum.left_add_coset_eq`: elements of the scalar ring commute (addition) with the spectrum.
* `spectrum.unit_mem_mul_iff_mem_swap_mul` and `spectrum.preimage_units_mul_eq_swap_mul`: the
units (of `R`) in `σ (a*b)` coincide with those in `σ (b*a)`.
* `spectrum.scalar_eq`: in a nontrivial algebra over a field, the spectrum of a scalar is
a singleton.
## Notations
* `σ a` : `spectrum R a` of `a : A`
-/
open Set
open scoped Pointwise
universe u v
section Defs
variable (R : Type u) {A : Type v}
variable [CommSemiring R] [Ring A] [Algebra R A]
local notation "↑ₐ" => algebraMap R A
-- definition and basic properties
/-- Given a commutative ring `R` and an `R`-algebra `A`, the *resolvent set* of `a : A`
is the `Set R` consisting of those `r : R` for which `r•1 - a` is a unit of the
algebra `A`. -/
def resolventSet (a : A) : Set R :=
{r : R | IsUnit (↑ₐ r - a)}
#align resolvent_set resolventSet
/-- Given a commutative ring `R` and an `R`-algebra `A`, the *spectrum* of `a : A`
is the `Set R` consisting of those `r : R` for which `r•1 - a` is not a unit of the
algebra `A`.
The spectrum is simply the complement of the resolvent set. -/
def spectrum (a : A) : Set R :=
(resolventSet R a)ᶜ
#align spectrum spectrum
variable {R}
/-- Given an `a : A` where `A` is an `R`-algebra, the *resolvent* is
a map `R → A` which sends `r : R` to `(algebraMap R A r - a)⁻¹` when
`r ∈ resolvent R A` and `0` when `r ∈ spectrum R A`. -/
noncomputable def resolvent (a : A) (r : R) : A :=
Ring.inverse (↑ₐ r - a)
#align resolvent resolvent
/-- The unit `1 - r⁻¹ • a` constructed from `r • 1 - a` when the latter is a unit. -/
@[simps]
noncomputable def IsUnit.subInvSMul {r : Rˣ} {s : R} {a : A} (h : IsUnit <| r • ↑ₐ s - a) : Aˣ where
val := ↑ₐ s - r⁻¹ • a
inv := r • ↑h.unit⁻¹
val_inv := by rw [mul_smul_comm, ← smul_mul_assoc, smul_sub, smul_inv_smul, h.mul_val_inv]
inv_val := by rw [smul_mul_assoc, ← mul_smul_comm, smul_sub, smul_inv_smul, h.val_inv_mul]
#align is_unit.sub_inv_smul IsUnit.subInvSMul
#align is_unit.coe_sub_inv_smul IsUnit.val_subInvSMul
#align is_unit.coe_inv_sub_inv_smul IsUnit.val_inv_subInvSMul
end Defs
namespace spectrum
section ScalarSemiring
variable {R : Type u} {A : Type v}
variable [CommSemiring R] [Ring A] [Algebra R A]
local notation "σ" => spectrum R
local notation "↑ₐ" => algebraMap R A
theorem mem_iff {r : R} {a : A} : r ∈ σ a ↔ ¬IsUnit (↑ₐ r - a) :=
Iff.rfl
#align spectrum.mem_iff spectrum.mem_iff
| Mathlib/Algebra/Algebra/Spectrum.lean | 109 | 111 | theorem not_mem_iff {r : R} {a : A} : r ∉ σ a ↔ IsUnit (↑ₐ r - a) := by |
apply not_iff_not.mp
simp [Set.not_not_mem, mem_iff]
|
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.List.Sort
import Mathlib.Data.Multiset.Basic
#align_import data.multiset.sort from "leanprover-community/mathlib"@"008205aa645b3f194c1da47025c5f110c8406eab"
/-!
# Construct a sorted list from a multiset.
-/
namespace Multiset
open List
variable {α : Type*}
section sort
variable (r : α → α → Prop) [DecidableRel r] [IsTrans α r] [IsAntisymm α r] [IsTotal α r]
/-- `sort s` constructs a sorted list from the multiset `s`.
(Uses merge sort algorithm.) -/
def sort (s : Multiset α) : List α :=
Quot.liftOn s (mergeSort r) fun _ _ h =>
eq_of_perm_of_sorted ((perm_mergeSort _ _).trans <| h.trans (perm_mergeSort _ _).symm)
(sorted_mergeSort r _) (sorted_mergeSort r _)
#align multiset.sort Multiset.sort
@[simp]
theorem coe_sort (l : List α) : sort r l = mergeSort r l :=
rfl
#align multiset.coe_sort Multiset.coe_sort
@[simp]
theorem sort_sorted (s : Multiset α) : Sorted r (sort r s) :=
Quot.inductionOn s fun _l => sorted_mergeSort r _
#align multiset.sort_sorted Multiset.sort_sorted
@[simp]
theorem sort_eq (s : Multiset α) : ↑(sort r s) = s :=
Quot.inductionOn s fun _ => Quot.sound <| perm_mergeSort _ _
#align multiset.sort_eq Multiset.sort_eq
@[simp]
| Mathlib/Data/Multiset/Sort.lean | 50 | 50 | theorem mem_sort {s : Multiset α} {a : α} : a ∈ sort r s ↔ a ∈ s := by | rw [← mem_coe, sort_eq]
|
/-
Copyright (c) 2021 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
import Mathlib.Algebra.BigOperators.Group.Finset
import Mathlib.Data.List.MinMax
import Mathlib.Algebra.Tropical.Basic
import Mathlib.Order.ConditionallyCompleteLattice.Finset
#align_import algebra.tropical.big_operators from "leanprover-community/mathlib"@"d6fad0e5bf2d6f48da9175d25c3dc5706b3834ce"
/-!
# Tropicalization of finitary operations
This file provides the "big-op" or notation-based finitary operations on tropicalized types.
This allows easy conversion between sums to Infs and prods to sums. Results here are important
for expressing that evaluation of tropical polynomials are the minimum over a finite piecewise
collection of linear functions.
## Main declarations
* `untrop_sum`
## Implementation notes
No concrete (semi)ring is used here, only ones with inferrable order/lattice structure, to support
`Real`, `Rat`, `EReal`, and others (`ERat` is not yet defined).
Minima over `List α` are defined as producing a value in `WithTop α` so proofs about lists do not
directly transfer to minima over multisets or finsets.
-/
variable {R S : Type*}
open Tropical Finset
theorem List.trop_sum [AddMonoid R] (l : List R) : trop l.sum = List.prod (l.map trop) := by
induction' l with hd tl IH
· simp
· simp [← IH]
#align list.trop_sum List.trop_sum
theorem Multiset.trop_sum [AddCommMonoid R] (s : Multiset R) :
trop s.sum = Multiset.prod (s.map trop) :=
Quotient.inductionOn s (by simpa using List.trop_sum)
#align multiset.trop_sum Multiset.trop_sum
theorem trop_sum [AddCommMonoid R] (s : Finset S) (f : S → R) :
trop (∑ i ∈ s, f i) = ∏ i ∈ s, trop (f i) := by
convert Multiset.trop_sum (s.val.map f)
simp only [Multiset.map_map, Function.comp_apply]
rfl
#align trop_sum trop_sum
theorem List.untrop_prod [AddMonoid R] (l : List (Tropical R)) :
untrop l.prod = List.sum (l.map untrop) := by
induction' l with hd tl IH
· simp
· simp [← IH]
#align list.untrop_prod List.untrop_prod
theorem Multiset.untrop_prod [AddCommMonoid R] (s : Multiset (Tropical R)) :
untrop s.prod = Multiset.sum (s.map untrop) :=
Quotient.inductionOn s (by simpa using List.untrop_prod)
#align multiset.untrop_prod Multiset.untrop_prod
theorem untrop_prod [AddCommMonoid R] (s : Finset S) (f : S → Tropical R) :
untrop (∏ i ∈ s, f i) = ∑ i ∈ s, untrop (f i) := by
convert Multiset.untrop_prod (s.val.map f)
simp only [Multiset.map_map, Function.comp_apply]
rfl
#align untrop_prod untrop_prod
-- Porting note: replaced `coe` with `WithTop.some` in statement
theorem List.trop_minimum [LinearOrder R] (l : List R) :
trop l.minimum = List.sum (l.map (trop ∘ WithTop.some)) := by
induction' l with hd tl IH
· simp
· simp [List.minimum_cons, ← IH]
#align list.trop_minimum List.trop_minimum
| Mathlib/Algebra/Tropical/BigOperators.lean | 85 | 89 | theorem Multiset.trop_inf [LinearOrder R] [OrderTop R] (s : Multiset R) :
trop s.inf = Multiset.sum (s.map trop) := by |
induction' s using Multiset.induction with s x IH
· simp
· simp [← IH]
|
/-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.Analysis.SpecialFunctions.Complex.Log
import Mathlib.RingTheory.RootsOfUnity.Basic
#align_import ring_theory.roots_of_unity.complex from "leanprover-community/mathlib"@"7fdeecc0d03cd40f7a165e6cf00a4d2286db599f"
/-!
# Complex roots of unity
In this file we show that the `n`-th complex roots of unity
are exactly the complex numbers `exp (2 * π * I * (i / n))` for `i ∈ Finset.range n`.
## Main declarations
* `Complex.mem_rootsOfUnity`: the complex `n`-th roots of unity are exactly the
complex numbers of the form `exp (2 * π * I * (i / n))` for some `i < n`.
* `Complex.card_rootsOfUnity`: the number of `n`-th roots of unity is exactly `n`.
* `Complex.norm_rootOfUnity_eq_one`: A complex root of unity has norm `1`.
-/
namespace Complex
open Polynomial Real
open scoped Nat Real
theorem isPrimitiveRoot_exp_of_coprime (i n : ℕ) (h0 : n ≠ 0) (hi : i.Coprime n) :
IsPrimitiveRoot (exp (2 * π * I * (i / n))) n := by
rw [IsPrimitiveRoot.iff_def]
simp only [← exp_nat_mul, exp_eq_one_iff]
have hn0 : (n : ℂ) ≠ 0 := mod_cast h0
constructor
· use i
field_simp [hn0, mul_comm (i : ℂ), mul_comm (n : ℂ)]
· simp only [hn0, mul_right_comm _ _ ↑n, mul_left_inj' two_pi_I_ne_zero, Ne, not_false_iff,
mul_comm _ (i : ℂ), ← mul_assoc _ (i : ℂ), exists_imp, field_simps]
norm_cast
rintro l k hk
conv_rhs at hk => rw [mul_comm, ← mul_assoc]
have hz : 2 * ↑π * I ≠ 0 := by simp [pi_pos.ne.symm, I_ne_zero]
field_simp [hz] at hk
norm_cast at hk
have : n ∣ i * l := by rw [← Int.natCast_dvd_natCast, hk, mul_comm]; apply dvd_mul_left
exact hi.symm.dvd_of_dvd_mul_left this
#align complex.is_primitive_root_exp_of_coprime Complex.isPrimitiveRoot_exp_of_coprime
theorem isPrimitiveRoot_exp (n : ℕ) (h0 : n ≠ 0) : IsPrimitiveRoot (exp (2 * π * I / n)) n := by
simpa only [Nat.cast_one, one_div] using
isPrimitiveRoot_exp_of_coprime 1 n h0 n.coprime_one_left
#align complex.is_primitive_root_exp Complex.isPrimitiveRoot_exp
theorem isPrimitiveRoot_iff (ζ : ℂ) (n : ℕ) (hn : n ≠ 0) :
IsPrimitiveRoot ζ n ↔ ∃ i < (n : ℕ), ∃ _ : i.Coprime n, exp (2 * π * I * (i / n)) = ζ := by
have hn0 : (n : ℂ) ≠ 0 := mod_cast hn
constructor; swap
· rintro ⟨i, -, hi, rfl⟩; exact isPrimitiveRoot_exp_of_coprime i n hn hi
intro h
obtain ⟨i, hi, rfl⟩ :=
(isPrimitiveRoot_exp n hn).eq_pow_of_pow_eq_one h.pow_eq_one (Nat.pos_of_ne_zero hn)
refine ⟨i, hi, ((isPrimitiveRoot_exp n hn).pow_iff_coprime (Nat.pos_of_ne_zero hn) i).mp h, ?_⟩
rw [← exp_nat_mul]
congr 1
field_simp [hn0, mul_comm (i : ℂ)]
#align complex.is_primitive_root_iff Complex.isPrimitiveRoot_iff
/-- The complex `n`-th roots of unity are exactly the
complex numbers of the form `exp (2 * Real.pi * Complex.I * (i / n))` for some `i < n`. -/
nonrec theorem mem_rootsOfUnity (n : ℕ+) (x : Units ℂ) :
x ∈ rootsOfUnity n ℂ ↔ ∃ i < (n : ℕ), exp (2 * π * I * (i / n)) = x := by
rw [mem_rootsOfUnity, Units.ext_iff, Units.val_pow_eq_pow_val, Units.val_one]
have hn0 : (n : ℂ) ≠ 0 := mod_cast n.ne_zero
constructor
· intro h
obtain ⟨i, hi, H⟩ : ∃ i < (n : ℕ), exp (2 * π * I / n) ^ i = x := by
simpa only using (isPrimitiveRoot_exp n n.ne_zero).eq_pow_of_pow_eq_one h n.pos
refine ⟨i, hi, ?_⟩
rw [← H, ← exp_nat_mul]
congr 1
field_simp [hn0, mul_comm (i : ℂ)]
· rintro ⟨i, _, H⟩
rw [← H, ← exp_nat_mul, exp_eq_one_iff]
use i
field_simp [hn0, mul_comm ((n : ℕ) : ℂ), mul_comm (i : ℂ)]
#align complex.mem_roots_of_unity Complex.mem_rootsOfUnity
theorem card_rootsOfUnity (n : ℕ+) : Fintype.card (rootsOfUnity n ℂ) = n :=
(isPrimitiveRoot_exp n n.ne_zero).card_rootsOfUnity
#align complex.card_roots_of_unity Complex.card_rootsOfUnity
| Mathlib/RingTheory/RootsOfUnity/Complex.lean | 96 | 99 | theorem card_primitiveRoots (k : ℕ) : (primitiveRoots k ℂ).card = φ k := by |
by_cases h : k = 0
· simp [h]
exact (isPrimitiveRoot_exp k h).card_primitiveRoots
|
/-
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.NumberTheory.LegendreSymbol.QuadraticChar.Basic
import Mathlib.NumberTheory.GaussSum
#align_import number_theory.legendre_symbol.quadratic_char.gauss_sum from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9"
/-!
# Quadratic characters of finite fields
Further facts relying on Gauss sums.
-/
/-!
### Basic properties of the quadratic character
We prove some properties of the quadratic character.
We work with a finite field `F` here.
The interesting case is when the characteristic of `F` is odd.
-/
section SpecialValues
open ZMod MulChar
variable {F : Type*} [Field F] [Fintype F]
/-- The value of the quadratic character at `2` -/
theorem quadraticChar_two [DecidableEq F] (hF : ringChar F ≠ 2) :
quadraticChar F 2 = χ₈ (Fintype.card F) :=
IsQuadratic.eq_of_eq_coe (quadraticChar_isQuadratic F) isQuadratic_χ₈ hF
((quadraticChar_eq_pow_of_char_ne_two' hF 2).trans (FiniteField.two_pow_card hF))
#align quadratic_char_two quadraticChar_two
/-- `2` is a square in `F` iff `#F` is not congruent to `3` or `5` mod `8`. -/
theorem FiniteField.isSquare_two_iff :
IsSquare (2 : F) ↔ Fintype.card F % 8 ≠ 3 ∧ Fintype.card F % 8 ≠ 5 := by
classical
by_cases hF : ringChar F = 2
focus
have h := FiniteField.even_card_of_char_two hF
simp only [FiniteField.isSquare_of_char_two hF, true_iff_iff]
rotate_left
focus
have h := FiniteField.odd_card_of_char_ne_two hF
rw [← quadraticChar_one_iff_isSquare (Ring.two_ne_zero hF), quadraticChar_two hF,
χ₈_nat_eq_if_mod_eight]
simp only [h, Nat.one_ne_zero, if_false, ite_eq_left_iff, Ne, (by decide : (-1 : ℤ) ≠ 1),
imp_false, Classical.not_not]
all_goals
rw [← Nat.mod_mod_of_dvd _ (by decide : 2 ∣ 8)] at h
have h₁ := Nat.mod_lt (Fintype.card F) (by decide : 0 < 8)
revert h₁ h
generalize Fintype.card F % 8 = n
intros; interval_cases n <;> simp_all -- Porting note (#11043): was `decide!`
#align finite_field.is_square_two_iff FiniteField.isSquare_two_iff
/-- The value of the quadratic character at `-2` -/
theorem quadraticChar_neg_two [DecidableEq F] (hF : ringChar F ≠ 2) :
quadraticChar F (-2) = χ₈' (Fintype.card F) := by
rw [(by norm_num : (-2 : F) = -1 * 2), map_mul, χ₈'_eq_χ₄_mul_χ₈, quadraticChar_neg_one hF,
quadraticChar_two hF, @cast_natCast _ (ZMod 4) _ _ _ (by decide : 4 ∣ 8)]
#align quadratic_char_neg_two quadraticChar_neg_two
/-- `-2` is a square in `F` iff `#F` is not congruent to `5` or `7` mod `8`. -/
theorem FiniteField.isSquare_neg_two_iff :
IsSquare (-2 : F) ↔ Fintype.card F % 8 ≠ 5 ∧ Fintype.card F % 8 ≠ 7 := by
classical
by_cases hF : ringChar F = 2
focus
have h := FiniteField.even_card_of_char_two hF
simp only [FiniteField.isSquare_of_char_two hF, true_iff_iff]
rotate_left
focus
have h := FiniteField.odd_card_of_char_ne_two hF
rw [← quadraticChar_one_iff_isSquare (neg_ne_zero.mpr (Ring.two_ne_zero hF)),
quadraticChar_neg_two hF, χ₈'_nat_eq_if_mod_eight]
simp only [h, Nat.one_ne_zero, if_false, ite_eq_left_iff, Ne, (by decide : (-1 : ℤ) ≠ 1),
imp_false, Classical.not_not]
all_goals
rw [← Nat.mod_mod_of_dvd _ (by decide : 2 ∣ 8)] at h
have h₁ := Nat.mod_lt (Fintype.card F) (by decide : 0 < 8)
revert h₁ h
generalize Fintype.card F % 8 = n
intros; interval_cases n <;> simp_all -- Porting note (#11043): was `decide!`
#align finite_field.is_square_neg_two_iff FiniteField.isSquare_neg_two_iff
/-- The relation between the values of the quadratic character of one field `F` at the
cardinality of another field `F'` and of the quadratic character of `F'` at the cardinality
of `F`. -/
| Mathlib/NumberTheory/LegendreSymbol/QuadraticChar/GaussSum.lean | 97 | 115 | theorem quadraticChar_card_card [DecidableEq F] (hF : ringChar F ≠ 2) {F' : Type*} [Field F']
[Fintype F'] [DecidableEq F'] (hF' : ringChar F' ≠ 2) (h : ringChar F' ≠ ringChar F) :
quadraticChar F (Fintype.card F') =
quadraticChar F' (quadraticChar F (-1) * Fintype.card F) := by |
let χ := (quadraticChar F).ringHomComp (algebraMap ℤ F')
have hχ₁ : χ.IsNontrivial := by
obtain ⟨a, ha⟩ := quadraticChar_exists_neg_one hF
have hu : IsUnit a := by
contrapose ha
exact ne_of_eq_of_ne (map_nonunit (quadraticChar F) ha) (mt zero_eq_neg.mp one_ne_zero)
use hu.unit
simp only [χ, IsUnit.unit_spec, ringHomComp_apply, eq_intCast, Ne, ha]
rw [Int.cast_neg, Int.cast_one]
exact Ring.neg_one_ne_one_of_char_ne_two hF'
have hχ₂ : χ.IsQuadratic := IsQuadratic.comp (quadraticChar_isQuadratic F) _
have h := Char.card_pow_card hχ₁ hχ₂ h hF'
rw [← quadraticChar_eq_pow_of_char_ne_two' hF'] at h
exact (IsQuadratic.eq_of_eq_coe (quadraticChar_isQuadratic F')
(quadraticChar_isQuadratic F) hF' h).symm
|
/-
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.MeasurableSpace.Basic
import Mathlib.MeasureTheory.Measure.MeasureSpaceDef
#align_import measure_theory.function.ae_measurable_sequence from "leanprover-community/mathlib"@"d003c55042c3cd08aefd1ae9a42ef89441cdaaf3"
/-!
# Sequence of measurable functions associated to a sequence of a.e.-measurable functions
We define here tools to prove statements about limits (infi, supr...) of sequences of
`AEMeasurable` functions.
Given a sequence of a.e.-measurable functions `f : ι → α → β` with hypothesis
`hf : ∀ i, AEMeasurable (f i) μ`, and a pointwise property `p : α → (ι → β) → Prop` such that we
have `hp : ∀ᵐ x ∂μ, p x (fun n ↦ f n x)`, we define a sequence of measurable functions `aeSeq hf p`
and a measurable set `aeSeqSet hf p`, such that
* `μ (aeSeqSet hf p)ᶜ = 0`
* `x ∈ aeSeqSet hf p → ∀ i : ι, aeSeq hf hp i x = f i x`
* `x ∈ aeSeqSet hf p → p x (fun n ↦ f n x)`
-/
open MeasureTheory
open scoped Classical
variable {ι : Sort*} {α β γ : Type*} [MeasurableSpace α] [MeasurableSpace β] {f : ι → α → β}
{μ : Measure α} {p : α → (ι → β) → Prop}
/-- If we have the additional hypothesis `∀ᵐ x ∂μ, p x (fun n ↦ f n x)`, this is a measurable set
whose complement has measure 0 such that for all `x ∈ aeSeqSet`, `f i x` is equal to
`(hf i).mk (f i) x` for all `i` and we have the pointwise property `p x (fun n ↦ f n x)`. -/
def aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) (p : α → (ι → β) → Prop) : Set α :=
(toMeasurable μ { x | (∀ i, f i x = (hf i).mk (f i) x) ∧ p x fun n => f n x }ᶜ)ᶜ
#align ae_seq_set aeSeqSet
/-- A sequence of measurable functions that are equal to `f` and verify property `p` on the
measurable set `aeSeqSet hf p`. -/
noncomputable def aeSeq (hf : ∀ i, AEMeasurable (f i) μ) (p : α → (ι → β) → Prop) : ι → α → β :=
fun i x => ite (x ∈ aeSeqSet hf p) ((hf i).mk (f i) x) (⟨f i x⟩ : Nonempty β).some
#align ae_seq aeSeq
namespace aeSeq
section MemAESeqSet
theorem mk_eq_fun_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α} (hx : x ∈ aeSeqSet hf p)
(i : ι) : (hf i).mk (f i) x = f i x :=
haveI h_ss : aeSeqSet hf p ⊆ { x | ∀ i, f i x = (hf i).mk (f i) x } := by
rw [aeSeqSet, ← compl_compl { x | ∀ i, f i x = (hf i).mk (f i) x }, Set.compl_subset_compl]
refine Set.Subset.trans (Set.compl_subset_compl.mpr fun x h => ?_) (subset_toMeasurable _ _)
exact h.1
(h_ss hx i).symm
#align ae_seq.mk_eq_fun_of_mem_ae_seq_set aeSeq.mk_eq_fun_of_mem_aeSeqSet
| Mathlib/MeasureTheory/Function/AEMeasurableSequence.lean | 59 | 61 | theorem aeSeq_eq_mk_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α}
(hx : x ∈ aeSeqSet hf p) (i : ι) : aeSeq hf p i x = (hf i).mk (f i) x := by |
simp only [aeSeq, hx, if_true]
|
/-
Copyright (c) 2022 Devon Tuma. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Devon Tuma
-/
import Mathlib.Data.Vector.Basic
#align_import data.vector.mem from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# Theorems about membership of elements in vectors
This file contains theorems for membership in a `v.toList` for a vector `v`.
Having the length available in the type allows some of the lemmas to be
simpler and more general than the original version for lists.
In particular we can avoid some assumptions about types being `Inhabited`,
and make more general statements about `head` and `tail`.
-/
namespace Vector
variable {α β : Type*} {n : ℕ} (a a' : α)
@[simp]
theorem get_mem (i : Fin n) (v : Vector α n) : v.get i ∈ v.toList := by
rw [get_eq_get]
exact List.get_mem _ _ _
#align vector.nth_mem Vector.get_mem
theorem mem_iff_get (v : Vector α n) : a ∈ v.toList ↔ ∃ i, v.get i = a := by
simp only [List.mem_iff_get, Fin.exists_iff, Vector.get_eq_get]
exact
⟨fun ⟨i, hi, h⟩ => ⟨i, by rwa [toList_length] at hi, h⟩, fun ⟨i, hi, h⟩ =>
⟨i, by rwa [toList_length], h⟩⟩
#align vector.mem_iff_nth Vector.mem_iff_get
theorem not_mem_nil : a ∉ (Vector.nil : Vector α 0).toList := by
unfold Vector.nil
dsimp
simp
#align vector.not_mem_nil Vector.not_mem_nil
theorem not_mem_zero (v : Vector α 0) : a ∉ v.toList :=
(Vector.eq_nil v).symm ▸ not_mem_nil a
#align vector.not_mem_zero Vector.not_mem_zero
theorem mem_cons_iff (v : Vector α n) : a' ∈ (a ::ᵥ v).toList ↔ a' = a ∨ a' ∈ v.toList := by
rw [Vector.toList_cons, List.mem_cons]
#align vector.mem_cons_iff Vector.mem_cons_iff
theorem mem_succ_iff (v : Vector α (n + 1)) : a ∈ v.toList ↔ a = v.head ∨ a ∈ v.tail.toList := by
obtain ⟨a', v', h⟩ := exists_eq_cons v
simp_rw [h, Vector.mem_cons_iff, Vector.head_cons, Vector.tail_cons]
#align vector.mem_succ_iff Vector.mem_succ_iff
theorem mem_cons_self (v : Vector α n) : a ∈ (a ::ᵥ v).toList :=
(Vector.mem_iff_get a (a ::ᵥ v)).2 ⟨0, Vector.get_cons_zero a v⟩
#align vector.mem_cons_self Vector.mem_cons_self
@[simp]
theorem head_mem (v : Vector α (n + 1)) : v.head ∈ v.toList :=
(Vector.mem_iff_get v.head v).2 ⟨0, Vector.get_zero v⟩
#align vector.head_mem Vector.head_mem
theorem mem_cons_of_mem (v : Vector α n) (ha' : a' ∈ v.toList) : a' ∈ (a ::ᵥ v).toList :=
(Vector.mem_cons_iff a a' v).2 (Or.inr ha')
#align vector.mem_cons_of_mem Vector.mem_cons_of_mem
theorem mem_of_mem_tail (v : Vector α n) (ha : a ∈ v.tail.toList) : a ∈ v.toList := by
induction' n with n _
· exact False.elim (Vector.not_mem_zero a v.tail ha)
· exact (mem_succ_iff a v).2 (Or.inr ha)
#align vector.mem_of_mem_tail Vector.mem_of_mem_tail
| Mathlib/Data/Vector/Mem.lean | 76 | 78 | theorem mem_map_iff (b : β) (v : Vector α n) (f : α → β) :
b ∈ (v.map f).toList ↔ ∃ a : α, a ∈ v.toList ∧ f a = b := by |
rw [Vector.toList_map, List.mem_map]
|
/-
Copyright (c) 2022 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers, Heather Macbeth
-/
import Mathlib.Analysis.InnerProductSpace.TwoDim
import Mathlib.Geometry.Euclidean.Angle.Unoriented.Basic
#align_import geometry.euclidean.angle.oriented.basic from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
/-!
# Oriented angles.
This file defines oriented angles in real inner product spaces.
## Main definitions
* `Orientation.oangle` is the oriented angle between two vectors with respect to an orientation.
## Implementation notes
The definitions here use the `Real.angle` type, angles modulo `2 * π`. For some purposes,
angles modulo `π` are more convenient, because results are true for such angles with less
configuration dependence. Results that are only equalities modulo `π` can be represented
modulo `2 * π` as equalities of `(2 : ℤ) • θ`.
## References
* Evan Chen, Euclidean Geometry in Mathematical Olympiads.
-/
noncomputable section
open FiniteDimensional Complex
open scoped Real RealInnerProductSpace ComplexConjugate
namespace Orientation
attribute [local instance] Complex.finrank_real_complex_fact
variable {V V' : Type*}
variable [NormedAddCommGroup V] [NormedAddCommGroup V']
variable [InnerProductSpace ℝ V] [InnerProductSpace ℝ V']
variable [Fact (finrank ℝ V = 2)] [Fact (finrank ℝ V' = 2)] (o : Orientation ℝ V (Fin 2))
local notation "ω" => o.areaForm
/-- The oriented angle from `x` to `y`, modulo `2 * π`. If either vector is 0, this is 0.
See `InnerProductGeometry.angle` for the corresponding unoriented angle definition. -/
def oangle (x y : V) : Real.Angle :=
Complex.arg (o.kahler x y)
#align orientation.oangle Orientation.oangle
/-- Oriented angles are continuous when the vectors involved are nonzero. -/
| Mathlib/Geometry/Euclidean/Angle/Oriented/Basic.lean | 58 | 63 | theorem continuousAt_oangle {x : V × V} (hx1 : x.1 ≠ 0) (hx2 : x.2 ≠ 0) :
ContinuousAt (fun y : V × V => o.oangle y.1 y.2) x := by |
refine (Complex.continuousAt_arg_coe_angle ?_).comp ?_
· exact o.kahler_ne_zero hx1 hx2
exact ((continuous_ofReal.comp continuous_inner).add
((continuous_ofReal.comp o.areaForm'.continuous₂).mul continuous_const)).continuousAt
|
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Yakov Pechersky, Eric Wieser
-/
import Mathlib.Data.List.Basic
/-!
# Properties of `List.enum`
-/
namespace List
variable {α β : Type*}
#align list.length_enum_from List.enumFrom_length
#align list.length_enum List.enum_length
@[simp]
theorem get?_enumFrom :
∀ n (l : List α) m, get? (enumFrom n l) m = (get? l m).map fun a => (n + m, a)
| n, [], m => rfl
| n, a :: l, 0 => rfl
| n, a :: l, m + 1 => (get?_enumFrom (n + 1) l m).trans <| by rw [Nat.add_right_comm]; rfl
#align list.enum_from_nth List.get?_enumFrom
@[deprecated (since := "2024-04-06")] alias enumFrom_get? := get?_enumFrom
@[simp]
theorem get?_enum (l : List α) (n) : get? (enum l) n = (get? l n).map fun a => (n, a) := by
rw [enum, get?_enumFrom, Nat.zero_add]
#align list.enum_nth List.get?_enum
@[deprecated (since := "2024-04-06")] alias enum_get? := get?_enum
@[simp]
theorem enumFrom_map_snd : ∀ (n) (l : List α), map Prod.snd (enumFrom n l) = l
| _, [] => rfl
| _, _ :: _ => congr_arg (cons _) (enumFrom_map_snd _ _)
#align list.enum_from_map_snd List.enumFrom_map_snd
@[simp]
theorem enum_map_snd (l : List α) : map Prod.snd (enum l) = l :=
enumFrom_map_snd _ _
#align list.enum_map_snd List.enum_map_snd
@[simp]
theorem get_enumFrom (l : List α) (n) (i : Fin (l.enumFrom n).length) :
(l.enumFrom n).get i = (n + i, l.get (i.cast enumFrom_length)) := by
simp [get_eq_get?]
#align list.nth_le_enum_from List.get_enumFrom
@[simp]
theorem get_enum (l : List α) (i : Fin l.enum.length) :
l.enum.get i = (i.1, l.get (i.cast enum_length)) := by
simp [enum]
#align list.nth_le_enum List.get_enum
theorem mk_add_mem_enumFrom_iff_get? {n i : ℕ} {x : α} {l : List α} :
(n + i, x) ∈ enumFrom n l ↔ l.get? i = x := by
simp [mem_iff_get?]
theorem mk_mem_enumFrom_iff_le_and_get?_sub {n i : ℕ} {x : α} {l : List α} :
(i, x) ∈ enumFrom n l ↔ n ≤ i ∧ l.get? (i - n) = x := by
if h : n ≤ i then
rcases Nat.exists_eq_add_of_le h with ⟨i, rfl⟩
simp [mk_add_mem_enumFrom_iff_get?, Nat.add_sub_cancel_left]
else
have : ∀ k, n + k ≠ i := by rintro k rfl; simp at h
simp [h, mem_iff_get?, this]
| Mathlib/Data/List/Enum.lean | 72 | 73 | theorem mk_mem_enum_iff_get? {i : ℕ} {x : α} {l : List α} : (i, x) ∈ enum l ↔ l.get? i = x := by |
simp [enum, mk_mem_enumFrom_iff_le_and_get?_sub]
|
/-
Copyright (c) 2021 Justus Springer. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Justus Springer
-/
import Mathlib.Algebra.Category.MonCat.Limits
import Mathlib.CategoryTheory.Limits.Preserves.Filtered
import Mathlib.CategoryTheory.ConcreteCategory.Elementwise
import Mathlib.CategoryTheory.Limits.TypesFiltered
#align_import algebra.category.Mon.filtered_colimits from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
/-!
# The forgetful functor from (commutative) (additive) monoids preserves filtered colimits.
Forgetful functors from algebraic categories usually don't preserve colimits. However, they tend
to preserve _filtered_ colimits.
In this file, we start with a small filtered category `J` and a functor `F : J ⥤ MonCat`.
We then construct a monoid structure on the colimit of `F ⋙ forget MonCat` (in `Type`), thereby
showing that the forgetful functor `forget MonCat` preserves filtered colimits. Similarly for
`AddMonCat`, `CommMonCat` and `AddCommMonCat`.
-/
set_option linter.uppercaseLean3 false
universe v u
noncomputable section
open scoped Classical
open CategoryTheory
open CategoryTheory.Limits
open CategoryTheory.IsFiltered renaming max → max' -- avoid name collision with `_root_.max`.
namespace MonCat.FilteredColimits
section
-- Porting note: mathlib 3 used `parameters` here, mainly so we can have the abbreviations `M` and
-- `M.mk` below, without passing around `F` all the time.
variable {J : Type v} [SmallCategory J] (F : J ⥤ MonCatMax.{v, u})
/-- The colimit of `F ⋙ forget MonCat` in the category of types.
In the following, we will construct a monoid structure on `M`.
-/
@[to_additive
"The colimit of `F ⋙ forget AddMon` in the category of types.
In the following, we will construct an additive monoid structure on `M`."]
abbrev M :=
Types.Quot (F ⋙ forget MonCat)
#align Mon.filtered_colimits.M MonCat.FilteredColimits.M
#align AddMon.filtered_colimits.M AddMonCat.FilteredColimits.M
/-- The canonical projection into the colimit, as a quotient type. -/
@[to_additive "The canonical projection into the colimit, as a quotient type."]
noncomputable abbrev M.mk : (Σ j, F.obj j) → M.{v, u} F :=
Quot.mk _
#align Mon.filtered_colimits.M.mk MonCat.FilteredColimits.M.mk
#align AddMon.filtered_colimits.M.mk AddMonCat.FilteredColimits.M.mk
@[to_additive]
theorem M.mk_eq (x y : Σ j, F.obj j)
(h : ∃ (k : J) (f : x.1 ⟶ k) (g : y.1 ⟶ k), F.map f x.2 = F.map g y.2) :
M.mk.{v, u} F x = M.mk F y :=
Quot.EqvGen_sound (Types.FilteredColimit.eqvGen_quot_rel_of_rel (F ⋙ forget MonCat) x y h)
#align Mon.filtered_colimits.M.mk_eq MonCat.FilteredColimits.M.mk_eq
#align AddMon.filtered_colimits.M.mk_eq AddMonCat.FilteredColimits.M.mk_eq
variable [IsFiltered J]
/-- As `J` is nonempty, we can pick an arbitrary object `j₀ : J`. We use this object to define the
"one" in the colimit as the equivalence class of `⟨j₀, 1 : F.obj j₀⟩`.
-/
@[to_additive
"As `J` is nonempty, we can pick an arbitrary object `j₀ : J`. We use this object to
define the \"zero\" in the colimit as the equivalence class of `⟨j₀, 0 : F.obj j₀⟩`."]
noncomputable instance colimitOne :
One (M.{v, u} F) where one := M.mk F ⟨IsFiltered.nonempty.some,1⟩
#align Mon.filtered_colimits.colimit_has_one MonCat.FilteredColimits.colimitOne
#align AddMon.filtered_colimits.colimit_has_zero AddMonCat.FilteredColimits.colimitZero
/-- The definition of the "one" in the colimit is independent of the chosen object of `J`.
In particular, this lemma allows us to "unfold" the definition of `colimit_one` at a custom chosen
object `j`.
-/
@[to_additive
"The definition of the \"zero\" in the colimit is independent of the chosen object
of `J`. In particular, this lemma allows us to \"unfold\" the definition of `colimit_zero` at
a custom chosen object `j`."]
| Mathlib/Algebra/Category/MonCat/FilteredColimits.lean | 95 | 98 | theorem colimit_one_eq (j : J) : (1 : M.{v, u} F) = M.mk F ⟨j, 1⟩ := by |
apply M.mk_eq
refine ⟨max' _ j, IsFiltered.leftToMax _ j, IsFiltered.rightToMax _ j, ?_⟩
simp
|
/-
Copyright (c) 2024 Emilie Burgun. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Emilie Burgun
-/
import Mathlib.Algebra.Group.Commute.Basic
import Mathlib.GroupTheory.GroupAction.Basic
import Mathlib.Dynamics.PeriodicPts
import Mathlib.Data.Set.Pointwise.SMul
/-!
# Properties of `fixedPoints` and `fixedBy`
This module contains some useful properties of `MulAction.fixedPoints` and `MulAction.fixedBy`
that don't directly belong to `Mathlib.GroupTheory.GroupAction.Basic`.
## Main theorems
* `MulAction.fixedBy_mul`: `fixedBy α (g * h) ⊆ fixedBy α g ∪ fixedBy α h`
* `MulAction.fixedBy_conj` and `MulAction.smul_fixedBy`: the pointwise group action of `h` on
`fixedBy α g` is equal to the `fixedBy` set of the conjugation of `h` with `g`
(`fixedBy α (h * g * h⁻¹)`).
* `MulAction.set_mem_fixedBy_of_movedBy_subset` shows that if a set `s` is a superset of
`(fixedBy α g)ᶜ`, then the group action of `g` cannot send elements of `s` outside of `s`.
This is expressed as `s ∈ fixedBy (Set α) g`, and `MulAction.set_mem_fixedBy_iff` allows one
to convert the relationship back to `g • x ∈ s ↔ x ∈ s`.
* `MulAction.not_commute_of_disjoint_smul_movedBy` allows one to prove that `g` and `h`
do not commute from the disjointness of the `(fixedBy α g)ᶜ` set and `h • (fixedBy α g)ᶜ`,
which is a property used in the proof of Rubin's theorem.
The theorems above are also available for `AddAction`.
## Pointwise group action and `fixedBy (Set α) g`
Since `fixedBy α g = { x | g • x = x }` by definition, properties about the pointwise action of
a set `s : Set α` can be expressed using `fixedBy (Set α) g`.
To properly use theorems using `fixedBy (Set α) g`, you should `open Pointwise` in your file.
`s ∈ fixedBy (Set α) g` means that `g • s = s`, which is equivalent to say that
`∀ x, g • x ∈ s ↔ x ∈ s` (the translation can be done using `MulAction.set_mem_fixedBy_iff`).
`s ∈ fixedBy (Set α) g` is a weaker statement than `s ⊆ fixedBy α g`: the latter requires that
all points in `s` are fixed by `g`, whereas the former only requires that `g • x ∈ s`.
-/
namespace MulAction
open Pointwise
variable {α : Type*}
variable {G : Type*} [Group G] [MulAction G α]
variable {M : Type*} [Monoid M] [MulAction M α]
section FixedPoints
variable (α) in
/-- In a multiplicative group action, the points fixed by `g` are also fixed by `g⁻¹` -/
@[to_additive (attr := simp)
"In an additive group action, the points fixed by `g` are also fixed by `g⁻¹`"]
| Mathlib/GroupTheory/GroupAction/FixedPoints.lean | 60 | 62 | theorem fixedBy_inv (g : G) : fixedBy α g⁻¹ = fixedBy α g := by |
ext
rw [mem_fixedBy, mem_fixedBy, inv_smul_eq_iff, eq_comm]
|
/-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Robert Y. Lewis
-/
import Mathlib.Algebra.CharP.Invertible
import Mathlib.Algebra.MvPolynomial.Variables
import Mathlib.Algebra.MvPolynomial.CommRing
import Mathlib.Algebra.MvPolynomial.Expand
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.ZMod.Basic
#align_import ring_theory.witt_vector.witt_polynomial from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395"
/-!
# Witt polynomials
To endow `WittVector p R` with a ring structure,
we need to study the so-called Witt polynomials.
Fix a base value `p : ℕ`.
The `p`-adic Witt polynomials are an infinite family of polynomials
indexed by a natural number `n`, taking values in an arbitrary ring `R`.
The variables of these polynomials are represented by natural numbers.
The variable set of the `n`th Witt polynomial contains at most `n+1` elements `{0, ..., n}`,
with exactly these variables when `R` has characteristic `0`.
These polynomials are used to define the addition and multiplication operators
on the type of Witt vectors. (While this type itself is not complicated,
the ring operations are what make it interesting.)
When the base `p` is invertible in `R`, the `p`-adic Witt polynomials
form a basis for `MvPolynomial ℕ R`, equivalent to the standard basis.
## Main declarations
* `WittPolynomial p R n`: the `n`-th Witt polynomial, viewed as polynomial over the ring `R`
* `xInTermsOfW p R n`: if `p` is invertible, the polynomial `X n` is contained in the subalgebra
generated by the Witt polynomials. `xInTermsOfW p R n` is the explicit polynomial,
which upon being bound to the Witt polynomials yields `X n`.
* `bind₁_wittPolynomial_xInTermsOfW`: the proof of the claim that
`bind₁ (xInTermsOfW p R) (W_ R n) = X n`
* `bind₁_xInTermsOfW_wittPolynomial`: the converse of the above statement
## Notation
In this file we use the following notation
* `p` is a natural number, typically assumed to be prime.
* `R` and `S` are commutative rings
* `W n` (and `W_ R n` when the ring needs to be explicit) denotes the `n`th Witt polynomial
## References
* [Hazewinkel, *Witt Vectors*][Haze09]
* [Commelin and Lewis, *Formalizing the Ring of Witt Vectors*][CL21]
-/
open MvPolynomial
open Finset hiding map
open Finsupp (single)
--attribute [-simp] coe_eval₂_hom
variable (p : ℕ)
variable (R : Type*) [CommRing R] [DecidableEq R]
/-- `wittPolynomial p R n` is the `n`-th Witt polynomial
with respect to a prime `p` with coefficients in a commutative ring `R`.
It is defined as:
`∑_{i ≤ n} p^i X_i^{p^{n-i}} ∈ R[X_0, X_1, X_2, …]`. -/
noncomputable def wittPolynomial (n : ℕ) : MvPolynomial ℕ R :=
∑ i ∈ range (n + 1), monomial (single i (p ^ (n - i))) ((p : R) ^ i)
#align witt_polynomial wittPolynomial
theorem wittPolynomial_eq_sum_C_mul_X_pow (n : ℕ) :
wittPolynomial p R n = ∑ i ∈ range (n + 1), C ((p : R) ^ i) * X i ^ p ^ (n - i) := by
apply sum_congr rfl
rintro i -
rw [monomial_eq, Finsupp.prod_single_index]
rw [pow_zero]
set_option linter.uppercaseLean3 false in
#align witt_polynomial_eq_sum_C_mul_X_pow wittPolynomial_eq_sum_C_mul_X_pow
/-! We set up notation locally to this file, to keep statements short and comprehensible.
This allows us to simply write `W n` or `W_ ℤ n`. -/
-- Notation with ring of coefficients explicit
set_option quotPrecheck false in
@[inherit_doc]
scoped[Witt] notation "W_" => wittPolynomial p
-- Notation with ring of coefficients implicit
set_option quotPrecheck false in
@[inherit_doc]
scoped[Witt] notation "W" => wittPolynomial p _
open Witt
open MvPolynomial
/-! The first observation is that the Witt polynomial doesn't really depend on the coefficient ring.
If we map the coefficients through a ring homomorphism, we obtain the corresponding Witt polynomial
over the target ring. -/
section
variable {R} {S : Type*} [CommRing S]
@[simp]
theorem map_wittPolynomial (f : R →+* S) (n : ℕ) : map f (W n) = W n := by
rw [wittPolynomial, map_sum, wittPolynomial]
refine sum_congr rfl fun i _ => ?_
rw [map_monomial, RingHom.map_pow, map_natCast]
#align map_witt_polynomial map_wittPolynomial
variable (R)
@[simp]
theorem constantCoeff_wittPolynomial [hp : Fact p.Prime] (n : ℕ) :
constantCoeff (wittPolynomial p R n) = 0 := by
simp only [wittPolynomial, map_sum, constantCoeff_monomial]
rw [sum_eq_zero]
rintro i _
rw [if_neg]
rw [Finsupp.single_eq_zero]
exact ne_of_gt (pow_pos hp.1.pos _)
#align constant_coeff_witt_polynomial constantCoeff_wittPolynomial
@[simp]
theorem wittPolynomial_zero : wittPolynomial p R 0 = X 0 := by
simp only [wittPolynomial, X, sum_singleton, range_one, pow_zero, zero_add, tsub_self]
#align witt_polynomial_zero wittPolynomial_zero
@[simp]
| Mathlib/RingTheory/WittVector/WittPolynomial.lean | 141 | 143 | theorem wittPolynomial_one : wittPolynomial p R 1 = C (p : R) * X 1 + X 0 ^ p := by |
simp only [wittPolynomial_eq_sum_C_mul_X_pow, sum_range_succ_comm, range_one, sum_singleton,
one_mul, pow_one, C_1, pow_zero, tsub_self, tsub_zero]
|
/-
Copyright (c) 2023 Joachim Breitner. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joachim Breitner
-/
import Mathlib.Probability.ProbabilityMassFunction.Constructions
import Mathlib.Tactic.FinCases
/-!
# The binomial distribution
This file defines the probability mass function of the binomial distribution.
## Main results
* `binomial_one_eq_bernoulli`: For `n = 1`, it is equal to `PMF.bernoulli`.
-/
namespace PMF
open ENNReal
/-- The binomial `PMF`: the probability of observing exactly `i` “heads” in a sequence of `n`
independent coin tosses, each having probability `p` of coming up “heads”. -/
noncomputable
def binomial (p : ℝ≥0∞) (h : p ≤ 1) (n : ℕ) : PMF (Fin (n + 1)) :=
.ofFintype (fun i => p^(i : ℕ) * (1-p)^((Fin.last n - i) : ℕ) * (n.choose i : ℕ)) (by
convert (add_pow p (1-p) n).symm
· rw [Finset.sum_fin_eq_sum_range]
apply Finset.sum_congr rfl
intro i hi
rw [Finset.mem_range] at hi
rw [dif_pos hi, Fin.last]
· simp [h])
theorem binomial_apply (p : ℝ≥0∞) (h : p ≤ 1) (n : ℕ) (i : Fin (n + 1)) :
binomial p h n i = p^(i : ℕ) * (1-p)^((Fin.last n - i) : ℕ) * (n.choose i : ℕ) := rfl
@[simp]
theorem binomial_apply_zero (p : ℝ≥0∞) (h : p ≤ 1) (n : ℕ) :
binomial p h n 0 = (1-p)^n := by
simp [binomial_apply]
@[simp]
theorem binomial_apply_last (p : ℝ≥0∞) (h : p ≤ 1) (n : ℕ) :
binomial p h n (.last n) = p^n := by
simp [binomial_apply]
| Mathlib/Probability/ProbabilityMassFunction/Binomial.lean | 49 | 50 | theorem binomial_apply_self (p : ℝ≥0∞) (h : p ≤ 1) (n : ℕ) :
binomial p h n n = p^n := by | 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.Data.Finset.Option
import Mathlib.Data.PFun
import Mathlib.Data.Part
#align_import data.finset.pimage from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c"
/-!
# Image of a `Finset α` under a partially defined function
In this file we define `Part.toFinset` and `Finset.pimage`. We also prove some trivial lemmas about
these definitions.
## Tags
finite set, image, partial function
-/
variable {α β : Type*}
namespace Part
/-- Convert an `o : Part α` with decidable `Part.Dom o` to `Finset α`. -/
def toFinset (o : Part α) [Decidable o.Dom] : Finset α :=
o.toOption.toFinset
#align part.to_finset Part.toFinset
@[simp]
theorem mem_toFinset {o : Part α} [Decidable o.Dom] {x : α} : x ∈ o.toFinset ↔ x ∈ o := by
simp [toFinset]
#align part.mem_to_finset Part.mem_toFinset
@[simp]
theorem toFinset_none [Decidable (none : Part α).Dom] : none.toFinset = (∅ : Finset α) := by
simp [toFinset]
#align part.to_finset_none Part.toFinset_none
@[simp]
theorem toFinset_some {a : α} [Decidable (some a).Dom] : (some a).toFinset = {a} := by
simp [toFinset]
#align part.to_finset_some Part.toFinset_some
@[simp]
theorem coe_toFinset (o : Part α) [Decidable o.Dom] : (o.toFinset : Set α) = { x | x ∈ o } :=
Set.ext fun _ => mem_toFinset
#align part.coe_to_finset Part.coe_toFinset
end Part
namespace Finset
variable [DecidableEq β] {f g : α →. β} [∀ x, Decidable (f x).Dom] [∀ x, Decidable (g x).Dom]
{s t : Finset α} {b : β}
/-- Image of `s : Finset α` under a partially defined function `f : α →. β`. -/
def pimage (f : α →. β) [∀ x, Decidable (f x).Dom] (s : Finset α) : Finset β :=
s.biUnion fun x => (f x).toFinset
#align finset.pimage Finset.pimage
@[simp]
theorem mem_pimage : b ∈ s.pimage f ↔ ∃ a ∈ s, b ∈ f a := by
simp [pimage]
#align finset.mem_pimage Finset.mem_pimage
@[simp, norm_cast]
theorem coe_pimage : (s.pimage f : Set β) = f.image s :=
Set.ext fun _ => mem_pimage
#align finset.coe_pimage Finset.coe_pimage
@[simp]
| Mathlib/Data/Finset/PImage.lean | 76 | 79 | theorem pimage_some (s : Finset α) (f : α → β) [∀ x, Decidable (Part.some <| f x).Dom] :
(s.pimage fun x => Part.some (f x)) = s.image f := by |
ext
simp [eq_comm]
|
/-
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.Monad.Basic
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.List.ProdSigma
#align_import data.fin_enum from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
/-!
Type class for finitely enumerable types. The property is stronger
than `Fintype` in that it assigns each element a rank in a finite
enumeration.
-/
universe u v
open Finset
/-- `FinEnum α` means that `α` is finite and can be enumerated in some order,
i.e. `α` has an explicit bijection with `Fin n` for some n. -/
class FinEnum (α : Sort*) where
/-- `FinEnum.card` is the cardinality of the `FinEnum` -/
card : ℕ
/-- `FinEnum.Equiv` states that type `α` is in bijection with `Fin card`,
the size of the `FinEnum` -/
equiv : α ≃ Fin card
[decEq : DecidableEq α]
#align fin_enum FinEnum
attribute [instance 100] FinEnum.decEq
namespace FinEnum
variable {α : Type u} {β : α → Type v}
/-- transport a `FinEnum` instance across an equivalence -/
def ofEquiv (α) {β} [FinEnum α] (h : β ≃ α) : FinEnum β where
card := card α
equiv := h.trans (equiv)
decEq := (h.trans (equiv)).decidableEq
#align fin_enum.of_equiv FinEnum.ofEquiv
/-- create a `FinEnum` instance from an exhaustive list without duplicates -/
def ofNodupList [DecidableEq α] (xs : List α) (h : ∀ x : α, x ∈ xs) (h' : List.Nodup xs) :
FinEnum α where
card := xs.length
equiv :=
⟨fun x => ⟨xs.indexOf x, by rw [List.indexOf_lt_length]; apply h⟩, xs.get, fun x => by simp,
fun i => by ext; simp [List.get_indexOf h']⟩
#align fin_enum.of_nodup_list FinEnum.ofNodupList
/-- create a `FinEnum` instance from an exhaustive list; duplicates are removed -/
def ofList [DecidableEq α] (xs : List α) (h : ∀ x : α, x ∈ xs) : FinEnum α :=
ofNodupList xs.dedup (by simp [*]) (List.nodup_dedup _)
#align fin_enum.of_list FinEnum.ofList
/-- create an exhaustive list of the values of a given type -/
def toList (α) [FinEnum α] : List α :=
(List.finRange (card α)).map (equiv).symm
#align fin_enum.to_list FinEnum.toList
open Function
@[simp]
theorem mem_toList [FinEnum α] (x : α) : x ∈ toList α := by
simp [toList]; exists equiv x; simp
#align fin_enum.mem_to_list FinEnum.mem_toList
@[simp]
| Mathlib/Data/FinEnum.lean | 74 | 75 | theorem nodup_toList [FinEnum α] : List.Nodup (toList α) := by |
simp [toList]; apply List.Nodup.map <;> [apply Equiv.injective; apply List.nodup_finRange]
|
/-
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 ‹_›
| .lake/packages/batteries/Batteries/Data/Range/Lemmas.lean | 26 | 27 | theorem numElems_step_1 (start stop) : numElems ⟨start, stop, 1⟩ = stop - start := by |
simp [numElems]
|
/-
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.Order.RelIso.Set
import Mathlib.Data.Multiset.Sort
import Mathlib.Data.List.NodupEquivFin
import Mathlib.Data.Finset.Lattice
import Mathlib.Data.Fintype.Card
#align_import data.finset.sort from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# Construct a sorted list from a finset.
-/
namespace Finset
open Multiset Nat
variable {α β : Type*}
/-! ### sort -/
section sort
variable (r : α → α → Prop) [DecidableRel r] [IsTrans α r] [IsAntisymm α r] [IsTotal α r]
/-- `sort s` constructs a sorted list from the unordered set `s`.
(Uses merge sort algorithm.) -/
def sort (s : Finset α) : List α :=
Multiset.sort r s.1
#align finset.sort Finset.sort
@[simp]
theorem sort_sorted (s : Finset α) : List.Sorted r (sort r s) :=
Multiset.sort_sorted _ _
#align finset.sort_sorted Finset.sort_sorted
@[simp]
theorem sort_eq (s : Finset α) : ↑(sort r s) = s.1 :=
Multiset.sort_eq _ _
#align finset.sort_eq Finset.sort_eq
@[simp]
theorem sort_nodup (s : Finset α) : (sort r s).Nodup :=
(by rw [sort_eq]; exact s.2 : @Multiset.Nodup α (sort r s))
#align finset.sort_nodup Finset.sort_nodup
@[simp]
theorem sort_toFinset [DecidableEq α] (s : Finset α) : (sort r s).toFinset = s :=
List.toFinset_eq (sort_nodup r s) ▸ eq_of_veq (sort_eq r s)
#align finset.sort_to_finset Finset.sort_toFinset
@[simp]
theorem mem_sort {s : Finset α} {a : α} : a ∈ sort r s ↔ a ∈ s :=
Multiset.mem_sort _
#align finset.mem_sort Finset.mem_sort
@[simp]
theorem length_sort {s : Finset α} : (sort r s).length = s.card :=
Multiset.length_sort _
#align finset.length_sort Finset.length_sort
@[simp]
theorem sort_empty : sort r ∅ = [] :=
Multiset.sort_zero r
#align finset.sort_empty Finset.sort_empty
@[simp]
theorem sort_singleton (a : α) : sort r {a} = [a] :=
Multiset.sort_singleton r a
#align finset.sort_singleton Finset.sort_singleton
open scoped List in
theorem sort_perm_toList (s : Finset α) : sort r s ~ s.toList := by
rw [← Multiset.coe_eq_coe]
simp only [coe_toList, sort_eq]
#align finset.sort_perm_to_list Finset.sort_perm_toList
end sort
section SortLinearOrder
variable [LinearOrder α]
theorem sort_sorted_lt (s : Finset α) : List.Sorted (· < ·) (sort (· ≤ ·) s) :=
(sort_sorted _ _).lt_of_le (sort_nodup _ _)
#align finset.sort_sorted_lt Finset.sort_sorted_lt
theorem sort_sorted_gt (s : Finset α) : List.Sorted (· > ·) (sort (· ≥ ·) s) :=
(sort_sorted _ _).gt_of_ge (sort_nodup _ _)
| Mathlib/Data/Finset/Sort.lean | 97 | 106 | theorem sorted_zero_eq_min'_aux (s : Finset α) (h : 0 < (s.sort (· ≤ ·)).length) (H : s.Nonempty) :
(s.sort (· ≤ ·)).get ⟨0, h⟩ = s.min' H := by |
let l := s.sort (· ≤ ·)
apply le_antisymm
· have : s.min' H ∈ l := (Finset.mem_sort (α := α) (· ≤ ·)).mpr (s.min'_mem H)
obtain ⟨i, hi⟩ : ∃ i, l.get i = s.min' H := List.mem_iff_get.1 this
rw [← hi]
exact (s.sort_sorted (· ≤ ·)).rel_get_of_le (Nat.zero_le i)
· have : l.get ⟨0, h⟩ ∈ s := (Finset.mem_sort (α := α) (· ≤ ·)).1 (List.get_mem l 0 h)
exact s.min'_le _ this
|
/-
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
| Mathlib/FieldTheory/Separable.lean | 70 | 72 | 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
|
/-
Copyright (c) 2023 Xavier Roblot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Xavier Roblot
-/
import Mathlib.MeasureTheory.Constructions.Pi
import Mathlib.MeasureTheory.Constructions.Prod.Integral
/-!
# Integration with respect to a finite product of measures
On a finite product of measure spaces, we show that a product of integrable functions each
depending on a single coordinate is integrable, in `MeasureTheory.integrable_fintype_prod`, and
that its integral is the product of the individual integrals,
in `MeasureTheory.integral_fintype_prod_eq_prod`.
-/
open Fintype MeasureTheory MeasureTheory.Measure
variable {𝕜 : Type*} [RCLike 𝕜]
namespace MeasureTheory
/-- On a finite product space in `n` variables, for a natural number `n`, a product of integrable
functions depending on each coordinate is integrable. -/
theorem Integrable.fin_nat_prod {n : ℕ} {E : Fin n → Type*}
[∀ i, MeasureSpace (E i)] [∀ i, SigmaFinite (volume : Measure (E i))]
{f : (i : Fin n) → E i → 𝕜} (hf : ∀ i, Integrable (f i)) :
Integrable (fun (x : (i : Fin n) → E i) ↦ ∏ i, f i (x i)) := by
induction n with
| zero => simp only [Nat.zero_eq, Finset.univ_eq_empty, Finset.prod_empty, volume_pi,
integrable_const_iff, one_ne_zero, pi_empty_univ, ENNReal.one_lt_top, or_true]
| succ n n_ih =>
have := ((measurePreserving_piFinSuccAbove (fun i => (volume : Measure (E i))) 0).symm)
rw [volume_pi, ← this.integrable_comp_emb (MeasurableEquiv.measurableEmbedding _)]
simp_rw [MeasurableEquiv.piFinSuccAbove_symm_apply,
Fin.prod_univ_succ, Fin.insertNth_zero]
simp only [Fin.zero_succAbove, cast_eq, Function.comp_def, Fin.cons_zero, Fin.cons_succ]
have : Integrable (fun (x : (j : Fin n) → E (Fin.succ j)) ↦ ∏ j, f (Fin.succ j) (x j)) :=
n_ih (fun i ↦ hf _)
exact Integrable.prod_mul (hf 0) this
/-- On a finite product space, a product of integrable functions depending on each coordinate is
integrable. Version with dependent target. -/
| Mathlib/MeasureTheory/Integral/Pi.lean | 45 | 54 | theorem Integrable.fintype_prod_dep {ι : Type*} [Fintype ι] {E : ι → Type*}
{f : (i : ι) → E i → 𝕜} [∀ i, MeasureSpace (E i)] [∀ i, SigmaFinite (volume : Measure (E i))]
(hf : ∀ i, Integrable (f i)) :
Integrable (fun (x : (i : ι) → E i) ↦ ∏ i, f i (x i)) := by |
let e := (equivFin ι).symm
simp_rw [← (volume_measurePreserving_piCongrLeft _ e).integrable_comp_emb
(MeasurableEquiv.measurableEmbedding _),
← e.prod_comp, MeasurableEquiv.coe_piCongrLeft, Function.comp_def,
Equiv.piCongrLeft_apply_apply]
exact .fin_nat_prod (fun i ↦ hf _)
|
/-
Copyright (c) 2021 Kexing Ying. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying
-/
import Mathlib.MeasureTheory.Measure.VectorMeasure
import Mathlib.MeasureTheory.Function.AEEqOfIntegral
#align_import measure_theory.measure.with_density_vector_measure from "leanprover-community/mathlib"@"d1bd9c5df2867c1cb463bc6364446d57bdd9f7f1"
/-!
# Vector measure defined by an integral
Given a measure `μ` and an integrable function `f : α → E`, we can define a vector measure `v` such
that for all measurable set `s`, `v i = ∫ x in s, f x ∂μ`. This definition is useful for
the Radon-Nikodym theorem for signed measures.
## Main definitions
* `MeasureTheory.Measure.withDensityᵥ`: the vector measure formed by integrating a function `f`
with respect to a measure `μ` on some set if `f` is integrable, and `0` otherwise.
-/
noncomputable section
open scoped Classical MeasureTheory NNReal ENNReal
variable {α β : Type*} {m : MeasurableSpace α}
namespace MeasureTheory
open TopologicalSpace
variable {μ ν : Measure α}
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
/-- Given a measure `μ` and an integrable function `f`, `μ.withDensityᵥ f` is
the vector measure which maps the set `s` to `∫ₛ f ∂μ`. -/
def Measure.withDensityᵥ {m : MeasurableSpace α} (μ : Measure α) (f : α → E) : VectorMeasure α E :=
if hf : Integrable f μ then
{ measureOf' := fun s => if MeasurableSet s then ∫ x in s, f x ∂μ else 0
empty' := by simp
not_measurable' := fun s hs => if_neg hs
m_iUnion' := fun s hs₁ hs₂ => by
dsimp only
convert hasSum_integral_iUnion hs₁ hs₂ hf.integrableOn with n
· rw [if_pos (hs₁ n)]
· rw [if_pos (MeasurableSet.iUnion hs₁)] }
else 0
#align measure_theory.measure.with_densityᵥ MeasureTheory.Measure.withDensityᵥ
open Measure
variable {f g : α → E}
theorem withDensityᵥ_apply (hf : Integrable f μ) {s : Set α} (hs : MeasurableSet s) :
μ.withDensityᵥ f s = ∫ x in s, f x ∂μ := by rw [withDensityᵥ, dif_pos hf]; exact dif_pos hs
#align measure_theory.with_densityᵥ_apply MeasureTheory.withDensityᵥ_apply
@[simp]
theorem withDensityᵥ_zero : μ.withDensityᵥ (0 : α → E) = 0 := by
ext1 s hs; erw [withDensityᵥ_apply (integrable_zero α E μ) hs]; simp
#align measure_theory.with_densityᵥ_zero MeasureTheory.withDensityᵥ_zero
@[simp]
theorem withDensityᵥ_neg : μ.withDensityᵥ (-f) = -μ.withDensityᵥ f := by
by_cases hf : Integrable f μ
· ext1 i hi
rw [VectorMeasure.neg_apply, withDensityᵥ_apply hf hi, ← integral_neg,
withDensityᵥ_apply hf.neg hi]
rfl
· rw [withDensityᵥ, withDensityᵥ, dif_neg hf, dif_neg, neg_zero]
rwa [integrable_neg_iff]
#align measure_theory.with_densityᵥ_neg MeasureTheory.withDensityᵥ_neg
theorem withDensityᵥ_neg' : (μ.withDensityᵥ fun x => -f x) = -μ.withDensityᵥ f :=
withDensityᵥ_neg
#align measure_theory.with_densityᵥ_neg' MeasureTheory.withDensityᵥ_neg'
@[simp]
| Mathlib/MeasureTheory/Measure/WithDensityVectorMeasure.lean | 84 | 92 | theorem withDensityᵥ_add (hf : Integrable f μ) (hg : Integrable g μ) :
μ.withDensityᵥ (f + g) = μ.withDensityᵥ f + μ.withDensityᵥ g := by |
ext1 i hi
rw [withDensityᵥ_apply (hf.add hg) hi, VectorMeasure.add_apply, withDensityᵥ_apply hf hi,
withDensityᵥ_apply hg hi]
simp_rw [Pi.add_apply]
rw [integral_add] <;> rw [← integrableOn_univ]
· exact hf.integrableOn.restrict MeasurableSet.univ
· exact hg.integrableOn.restrict MeasurableSet.univ
|
/-
Copyright (c) 2023 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Joseph Myers
-/
import Mathlib.Analysis.InnerProductSpace.Orthogonal
import Mathlib.Analysis.Normed.Group.AddTorsor
#align_import geometry.euclidean.basic from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0"
/-!
# Perpendicular bisector of a segment
We define `AffineSubspace.perpBisector p₁ p₂` to be the perpendicular bisector of the segment
`[p₁, p₂]`, as a bundled affine subspace. We also prove that a point belongs to the perpendicular
bisector if and only if it is equidistant from `p₁` and `p₂`, as well as a few linear equations that
define this subspace.
## Keywords
euclidean geometry, perpendicular, perpendicular bisector, line segment bisector, equidistant
-/
open Set
open scoped RealInnerProductSpace
variable {V P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
variable [NormedAddTorsor V P]
noncomputable section
namespace AffineSubspace
variable {c c₁ c₂ p₁ p₂ : P}
/-- Perpendicular bisector of a segment in a Euclidean affine space. -/
def perpBisector (p₁ p₂ : P) : AffineSubspace ℝ P :=
.comap ((AffineEquiv.vaddConst ℝ (midpoint ℝ p₁ p₂)).symm : P →ᵃ[ℝ] V) <|
(LinearMap.ker (innerₛₗ ℝ (p₂ -ᵥ p₁))).toAffineSubspace
/-- A point `c` belongs the perpendicular bisector of `[p₁, p₂] iff `p₂ -ᵥ p₁` is orthogonal to
`c -ᵥ midpoint ℝ p₁ p₂`. -/
theorem mem_perpBisector_iff_inner_eq_zero' :
c ∈ perpBisector p₁ p₂ ↔ ⟪p₂ -ᵥ p₁, c -ᵥ midpoint ℝ p₁ p₂⟫ = 0 :=
Iff.rfl
/-- A point `c` belongs the perpendicular bisector of `[p₁, p₂] iff `c -ᵥ midpoint ℝ p₁ p₂` is
orthogonal to `p₂ -ᵥ p₁`. -/
theorem mem_perpBisector_iff_inner_eq_zero :
c ∈ perpBisector p₁ p₂ ↔ ⟪c -ᵥ midpoint ℝ p₁ p₂, p₂ -ᵥ p₁⟫ = 0 :=
inner_eq_zero_symm
theorem mem_perpBisector_iff_inner_pointReflection_vsub_eq_zero :
c ∈ perpBisector p₁ p₂ ↔ ⟪Equiv.pointReflection c p₁ -ᵥ p₂, p₂ -ᵥ p₁⟫ = 0 := by
rw [mem_perpBisector_iff_inner_eq_zero, Equiv.pointReflection_apply,
vsub_midpoint, invOf_eq_inv, ← smul_add, real_inner_smul_left, vadd_vsub_assoc]
simp
theorem mem_perpBisector_pointReflection_iff_inner_eq_zero :
c ∈ perpBisector p₁ (Equiv.pointReflection p₂ p₁) ↔ ⟪c -ᵥ p₂, p₁ -ᵥ p₂⟫ = 0 := by
rw [mem_perpBisector_iff_inner_eq_zero, midpoint_pointReflection_right,
Equiv.pointReflection_apply, vadd_vsub_assoc, inner_add_right, add_self_eq_zero,
← neg_eq_zero, ← inner_neg_right, neg_vsub_eq_vsub_rev]
theorem midpoint_mem_perpBisector (p₁ p₂ : P) :
midpoint ℝ p₁ p₂ ∈ perpBisector p₁ p₂ := by
simp [mem_perpBisector_iff_inner_eq_zero]
theorem perpBisector_nonempty : (perpBisector p₁ p₂ : Set P).Nonempty :=
⟨_, midpoint_mem_perpBisector _ _⟩
@[simp]
theorem direction_perpBisector (p₁ p₂ : P) :
(perpBisector p₁ p₂).direction = (ℝ ∙ (p₂ -ᵥ p₁))ᗮ := by
erw [perpBisector, comap_symm, map_direction, Submodule.map_id,
Submodule.toAffineSubspace_direction]
ext x
exact Submodule.mem_orthogonal_singleton_iff_inner_right.symm
theorem mem_perpBisector_iff_inner_eq_inner :
c ∈ perpBisector p₁ p₂ ↔ ⟪c -ᵥ p₁, p₂ -ᵥ p₁⟫ = ⟪c -ᵥ p₂, p₁ -ᵥ p₂⟫ := by
rw [Iff.comm, mem_perpBisector_iff_inner_eq_zero, ← add_neg_eq_zero, ← inner_neg_right,
neg_vsub_eq_vsub_rev, ← inner_add_left, vsub_midpoint, invOf_eq_inv, ← smul_add,
real_inner_smul_left]; simp
| Mathlib/Geometry/Euclidean/PerpBisector.lean | 86 | 90 | theorem mem_perpBisector_iff_inner_eq :
c ∈ perpBisector p₁ p₂ ↔ ⟪c -ᵥ p₁, p₂ -ᵥ p₁⟫ = (dist p₁ p₂) ^ 2 / 2 := by |
rw [mem_perpBisector_iff_inner_eq_zero, ← vsub_sub_vsub_cancel_right _ _ p₁, inner_sub_left,
sub_eq_zero, midpoint_vsub_left, invOf_eq_inv, real_inner_smul_left, real_inner_self_eq_norm_sq,
dist_eq_norm_vsub' V, div_eq_inv_mul]
|
/-
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.Sites.Pretopology
import Mathlib.CategoryTheory.Sites.IsSheafFor
#align_import category_theory.sites.sheaf_of_types from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
/-!
# Sheaves of types on a Grothendieck topology
Defines the notion of a sheaf of types (usually called a sheaf of sets by mathematicians)
on a category equipped with a Grothendieck topology, as well as a range of equivalent
conditions useful in different situations.
In `Mathlib/CategoryTheory/Sites/IsSheafFor.lean` it is defined what it means for a presheaf to be a
sheaf *for* a particular sieve. Given a Grothendieck topology `J`, `P` is a sheaf if it is a sheaf
for every sieve in the topology. See `IsSheaf`.
In the case where the topology is generated by a basis, it suffices to check `P` is a sheaf for
every presieve in the pretopology. See `isSheaf_pretopology`.
We also provide equivalent conditions to satisfy alternate definitions given in the literature.
* Stacks: In `Equalizer.Presieve.sheaf_condition`, the sheaf condition at a presieve is shown to be
equivalent to that of https://stacks.math.columbia.edu/tag/00VM (and combined with
`isSheaf_pretopology`, this shows the notions of `IsSheaf` are exactly equivalent.)
The condition of https://stacks.math.columbia.edu/tag/00Z8 is virtually identical to the
statement of `isSheafFor_iff_yonedaSheafCondition` (since the bijection described there carries
the same information as the unique existence.)
* Maclane-Moerdijk [MM92]: Using `compatible_iff_sieveCompatible`, the definitions of `IsSheaf`
are equivalent. There are also alternate definitions given:
- Sheaf for a pretopology (Prop 1): `isSheaf_pretopology` combined with `pullbackCompatible_iff`.
- Sheaf for a pretopology as equalizer (Prop 1, bis): `Equalizer.Presieve.sheaf_condition`
combined with the previous.
## References
* [MM92]: *Sheaves in geometry and logic*, Saunders MacLane, and Ieke Moerdijk:
Chapter III, Section 4.
* [Elephant]: *Sketches of an Elephant*, P. T. Johnstone: C2.1.
* https://stacks.math.columbia.edu/tag/00VL (sheaves on a pretopology or site)
* https://stacks.math.columbia.edu/tag/00ZB (sheaves on a topology)
-/
universe w v u
namespace CategoryTheory
open Opposite CategoryTheory Category Limits Sieve
namespace Presieve
variable {C : Type u} [Category.{v} C]
variable {P : Cᵒᵖ ⥤ Type w}
variable {X : C}
variable (J J₂ : GrothendieckTopology C)
/-- A presheaf is separated for a topology if it is separated for every sieve in the topology. -/
def IsSeparated (P : Cᵒᵖ ⥤ Type w) : Prop :=
∀ {X} (S : Sieve X), S ∈ J X → IsSeparatedFor P (S : Presieve X)
#align category_theory.presieve.is_separated CategoryTheory.Presieve.IsSeparated
/-- A presheaf is a sheaf for a topology if it is a sheaf for every sieve in the topology.
If the given topology is given by a pretopology, `isSheaf_pretopology` shows it suffices to
check the sheaf condition at presieves in the pretopology.
-/
def IsSheaf (P : Cᵒᵖ ⥤ Type w) : Prop :=
∀ ⦃X⦄ (S : Sieve X), S ∈ J X → IsSheafFor P (S : Presieve X)
#align category_theory.presieve.is_sheaf CategoryTheory.Presieve.IsSheaf
theorem IsSheaf.isSheafFor {P : Cᵒᵖ ⥤ Type w} (hp : IsSheaf J P) (R : Presieve X)
(hr : generate R ∈ J X) : IsSheafFor P R :=
(isSheafFor_iff_generate R).2 <| hp _ hr
#align category_theory.presieve.is_sheaf.is_sheaf_for CategoryTheory.Presieve.IsSheaf.isSheafFor
theorem isSheaf_of_le (P : Cᵒᵖ ⥤ Type w) {J₁ J₂ : GrothendieckTopology C} :
J₁ ≤ J₂ → IsSheaf J₂ P → IsSheaf J₁ P := fun h t _ S hS => t S (h _ hS)
#align category_theory.presieve.is_sheaf_of_le CategoryTheory.Presieve.isSheaf_of_le
theorem isSeparated_of_isSheaf (P : Cᵒᵖ ⥤ Type w) (h : IsSheaf J P) : IsSeparated J P :=
fun S hS => (h S hS).isSeparatedFor
#align category_theory.presieve.is_separated_of_is_sheaf CategoryTheory.Presieve.isSeparated_of_isSheaf
/-- The property of being a sheaf is preserved by isomorphism. -/
theorem isSheaf_iso {P' : Cᵒᵖ ⥤ Type w} (i : P ≅ P') (h : IsSheaf J P) : IsSheaf J P' :=
fun _ S hS => isSheafFor_iso i (h S hS)
#align category_theory.presieve.is_sheaf_iso CategoryTheory.Presieve.isSheaf_iso
theorem isSheaf_of_yoneda {P : Cᵒᵖ ⥤ Type v}
(h : ∀ {X} (S : Sieve X), S ∈ J X → YonedaSheafCondition P S) : IsSheaf J P := fun _ _ hS =>
isSheafFor_iff_yonedaSheafCondition.2 (h _ hS)
#align category_theory.presieve.is_sheaf_of_yoneda CategoryTheory.Presieve.isSheaf_of_yoneda
/-- For a topology generated by a basis, it suffices to check the sheaf condition on the basis
presieves only.
-/
| Mathlib/CategoryTheory/Sites/SheafOfTypes.lean | 105 | 118 | theorem isSheaf_pretopology [HasPullbacks C] (K : Pretopology C) :
IsSheaf (K.toGrothendieck C) P ↔ ∀ {X : C} (R : Presieve X), R ∈ K X → IsSheafFor P R := by |
constructor
· intro PJ X R hR
rw [isSheafFor_iff_generate]
apply PJ (Sieve.generate R) ⟨_, hR, le_generate R⟩
· rintro PK X S ⟨R, hR, RS⟩
have gRS : ⇑(generate R) ≤ S := by
apply giGenerate.gc.monotone_u
rwa [sets_iff_generate]
apply isSheafFor_subsieve P gRS _
intro Y f
rw [← pullbackArrows_comm, ← isSheafFor_iff_generate]
exact PK (pullbackArrows f R) (K.pullbacks f R hR)
|
/-
Copyright (c) 2020 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers
-/
import Mathlib.Algebra.Module.BigOperators
import Mathlib.Data.Fintype.BigOperators
import Mathlib.LinearAlgebra.AffineSpace.AffineMap
import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace
import Mathlib.LinearAlgebra.Finsupp
import Mathlib.Tactic.FinCases
#align_import linear_algebra.affine_space.combination from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0"
/-!
# Affine combinations of points
This file defines affine combinations of points.
## Main definitions
* `weightedVSubOfPoint` is a general weighted combination of
subtractions with an explicit base point, yielding a vector.
* `weightedVSub` uses an arbitrary choice of base point and is intended
to be used when the sum of weights is 0, in which case the result is
independent of the choice of base point.
* `affineCombination` adds the weighted combination to the arbitrary
base point, yielding a point rather than a vector, and is intended
to be used when the sum of weights is 1, in which case the result is
independent of the choice of base point.
These definitions are for sums over a `Finset`; versions for a
`Fintype` may be obtained using `Finset.univ`, while versions for a
`Finsupp` may be obtained using `Finsupp.support`.
## References
* https://en.wikipedia.org/wiki/Affine_space
-/
noncomputable section
open Affine
namespace Finset
theorem univ_fin2 : (univ : Finset (Fin 2)) = {0, 1} := by
ext x
fin_cases x <;> simp
#align finset.univ_fin2 Finset.univ_fin2
variable {k : Type*} {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V]
variable [S : AffineSpace V P]
variable {ι : Type*} (s : Finset ι)
variable {ι₂ : Type*} (s₂ : Finset ι₂)
/-- A weighted sum of the results of subtracting a base point from the
given points, as a linear map on the weights. The main cases of
interest are where the sum of the weights is 0, in which case the sum
is independent of the choice of base point, and where the sum of the
weights is 1, in which case the sum added to the base point is
independent of the choice of base point. -/
def weightedVSubOfPoint (p : ι → P) (b : P) : (ι → k) →ₗ[k] V :=
∑ i ∈ s, (LinearMap.proj i : (ι → k) →ₗ[k] k).smulRight (p i -ᵥ b)
#align finset.weighted_vsub_of_point Finset.weightedVSubOfPoint
@[simp]
| Mathlib/LinearAlgebra/AffineSpace/Combination.lean | 72 | 74 | theorem weightedVSubOfPoint_apply (w : ι → k) (p : ι → P) (b : P) :
s.weightedVSubOfPoint p b w = ∑ i ∈ s, w i • (p i -ᵥ b) := by |
simp [weightedVSubOfPoint, LinearMap.sum_apply]
|
/-
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.Data.Finset.Option
import Mathlib.Data.PFun
import Mathlib.Data.Part
#align_import data.finset.pimage from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c"
/-!
# Image of a `Finset α` under a partially defined function
In this file we define `Part.toFinset` and `Finset.pimage`. We also prove some trivial lemmas about
these definitions.
## Tags
finite set, image, partial function
-/
variable {α β : Type*}
namespace Part
/-- Convert an `o : Part α` with decidable `Part.Dom o` to `Finset α`. -/
def toFinset (o : Part α) [Decidable o.Dom] : Finset α :=
o.toOption.toFinset
#align part.to_finset Part.toFinset
@[simp]
theorem mem_toFinset {o : Part α} [Decidable o.Dom] {x : α} : x ∈ o.toFinset ↔ x ∈ o := by
simp [toFinset]
#align part.mem_to_finset Part.mem_toFinset
@[simp]
theorem toFinset_none [Decidable (none : Part α).Dom] : none.toFinset = (∅ : Finset α) := by
simp [toFinset]
#align part.to_finset_none Part.toFinset_none
@[simp]
theorem toFinset_some {a : α} [Decidable (some a).Dom] : (some a).toFinset = {a} := by
simp [toFinset]
#align part.to_finset_some Part.toFinset_some
@[simp]
theorem coe_toFinset (o : Part α) [Decidable o.Dom] : (o.toFinset : Set α) = { x | x ∈ o } :=
Set.ext fun _ => mem_toFinset
#align part.coe_to_finset Part.coe_toFinset
end Part
namespace Finset
variable [DecidableEq β] {f g : α →. β} [∀ x, Decidable (f x).Dom] [∀ x, Decidable (g x).Dom]
{s t : Finset α} {b : β}
/-- Image of `s : Finset α` under a partially defined function `f : α →. β`. -/
def pimage (f : α →. β) [∀ x, Decidable (f x).Dom] (s : Finset α) : Finset β :=
s.biUnion fun x => (f x).toFinset
#align finset.pimage Finset.pimage
@[simp]
theorem mem_pimage : b ∈ s.pimage f ↔ ∃ a ∈ s, b ∈ f a := by
simp [pimage]
#align finset.mem_pimage Finset.mem_pimage
@[simp, norm_cast]
theorem coe_pimage : (s.pimage f : Set β) = f.image s :=
Set.ext fun _ => mem_pimage
#align finset.coe_pimage Finset.coe_pimage
@[simp]
theorem pimage_some (s : Finset α) (f : α → β) [∀ x, Decidable (Part.some <| f x).Dom] :
(s.pimage fun x => Part.some (f x)) = s.image f := by
ext
simp [eq_comm]
#align finset.pimage_some Finset.pimage_some
theorem pimage_congr (h₁ : s = t) (h₂ : ∀ x ∈ t, f x = g x) : s.pimage f = t.pimage g := by
subst s
ext y
-- Porting note: `← exists_prop` required because `∃ x ∈ s, p x` is defined differently
simp (config := { contextual := true }) only [mem_pimage, ← exists_prop, h₂]
#align finset.pimage_congr Finset.pimage_congr
/-- Rewrite `s.pimage f` in terms of `Finset.filter`, `Finset.attach`, and `Finset.image`. -/
| Mathlib/Data/Finset/PImage.lean | 90 | 97 | theorem pimage_eq_image_filter : s.pimage f =
(filter (fun x => (f x).Dom) s).attach.image
fun x : { x // x ∈ filter (fun x => (f x).Dom) s } =>
(f x).get (mem_filter.mp x.coe_prop).2 := by |
ext x
simp [Part.mem_eq, And.exists]
-- Porting note: `← exists_prop` required because `∃ x ∈ s, p x` is defined differently
simp only [← exists_prop]
|
/-
Copyright (c) 2019 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Data.Complex.Module
import Mathlib.Data.Complex.Order
import Mathlib.Data.Complex.Exponential
import Mathlib.Analysis.RCLike.Basic
import Mathlib.Topology.Algebra.InfiniteSum.Module
import Mathlib.Topology.Instances.RealVectorSpace
#align_import analysis.complex.basic from "leanprover-community/mathlib"@"3f655f5297b030a87d641ad4e825af8d9679eb0b"
/-!
# Normed space structure on `ℂ`.
This file gathers basic facts on complex numbers of an analytic nature.
## Main results
This file registers `ℂ` as a normed field, expresses basic properties of the norm, and gives
tools on the real vector space structure of `ℂ`. Notably, in the namespace `Complex`,
it defines functions:
* `reCLM`
* `imCLM`
* `ofRealCLM`
* `conjCLE`
They are bundled versions of the real part, the imaginary part, the embedding of `ℝ` in `ℂ`, and
the complex conjugate as continuous `ℝ`-linear maps. The last two are also bundled as linear
isometries in `ofRealLI` and `conjLIE`.
We also register the fact that `ℂ` is an `RCLike` field.
-/
assert_not_exists Absorbs
noncomputable section
namespace Complex
variable {z : ℂ}
open ComplexConjugate Topology Filter
instance : Norm ℂ :=
⟨abs⟩
@[simp]
theorem norm_eq_abs (z : ℂ) : ‖z‖ = abs z :=
rfl
#align complex.norm_eq_abs Complex.norm_eq_abs
lemma norm_I : ‖I‖ = 1 := abs_I
theorem norm_exp_ofReal_mul_I (t : ℝ) : ‖exp (t * I)‖ = 1 := by
simp only [norm_eq_abs, abs_exp_ofReal_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.norm_exp_of_real_mul_I Complex.norm_exp_ofReal_mul_I
instance instNormedAddCommGroup : NormedAddCommGroup ℂ :=
AddGroupNorm.toNormedAddCommGroup
{ abs with
map_zero' := map_zero abs
neg' := abs.map_neg
eq_zero_of_map_eq_zero' := fun _ => abs.eq_zero.1 }
instance : NormedField ℂ where
dist_eq _ _ := rfl
norm_mul' := map_mul abs
instance : DenselyNormedField ℂ where
lt_norm_lt r₁ r₂ h₀ hr :=
let ⟨x, h⟩ := exists_between hr
⟨x, by rwa [norm_eq_abs, abs_ofReal, abs_of_pos (h₀.trans_lt h.1)]⟩
instance {R : Type*} [NormedField R] [NormedAlgebra R ℝ] : NormedAlgebra R ℂ where
norm_smul_le r x := by
rw [← algebraMap_smul ℝ r x, real_smul, norm_mul, norm_eq_abs, abs_ofReal, ← Real.norm_eq_abs,
norm_algebraMap']
variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ℂ E]
-- see Note [lower instance priority]
/-- The module structure from `Module.complexToReal` is a normed space. -/
instance (priority := 900) _root_.NormedSpace.complexToReal : NormedSpace ℝ E :=
NormedSpace.restrictScalars ℝ ℂ E
#align normed_space.complex_to_real NormedSpace.complexToReal
-- see Note [lower instance priority]
/-- The algebra structure from `Algebra.complexToReal` is a normed algebra. -/
instance (priority := 900) _root_.NormedAlgebra.complexToReal {A : Type*} [SeminormedRing A]
[NormedAlgebra ℂ A] : NormedAlgebra ℝ A :=
NormedAlgebra.restrictScalars ℝ ℂ A
theorem dist_eq (z w : ℂ) : dist z w = abs (z - w) :=
rfl
#align complex.dist_eq Complex.dist_eq
theorem dist_eq_re_im (z w : ℂ) : dist z w = √((z.re - w.re) ^ 2 + (z.im - w.im) ^ 2) := by
rw [sq, sq]
rfl
#align complex.dist_eq_re_im Complex.dist_eq_re_im
@[simp]
theorem dist_mk (x₁ y₁ x₂ y₂ : ℝ) :
dist (mk x₁ y₁) (mk x₂ y₂) = √((x₁ - x₂) ^ 2 + (y₁ - y₂) ^ 2) :=
dist_eq_re_im _ _
#align complex.dist_mk Complex.dist_mk
theorem dist_of_re_eq {z w : ℂ} (h : z.re = w.re) : dist z w = dist z.im w.im := by
rw [dist_eq_re_im, h, sub_self, zero_pow two_ne_zero, zero_add, Real.sqrt_sq_eq_abs, Real.dist_eq]
#align complex.dist_of_re_eq Complex.dist_of_re_eq
theorem nndist_of_re_eq {z w : ℂ} (h : z.re = w.re) : nndist z w = nndist z.im w.im :=
NNReal.eq <| dist_of_re_eq h
#align complex.nndist_of_re_eq Complex.nndist_of_re_eq
theorem edist_of_re_eq {z w : ℂ} (h : z.re = w.re) : edist z w = edist z.im w.im := by
rw [edist_nndist, edist_nndist, nndist_of_re_eq h]
#align complex.edist_of_re_eq Complex.edist_of_re_eq
theorem dist_of_im_eq {z w : ℂ} (h : z.im = w.im) : dist z w = dist z.re w.re := by
rw [dist_eq_re_im, h, sub_self, zero_pow two_ne_zero, add_zero, Real.sqrt_sq_eq_abs, Real.dist_eq]
#align complex.dist_of_im_eq Complex.dist_of_im_eq
theorem nndist_of_im_eq {z w : ℂ} (h : z.im = w.im) : nndist z w = nndist z.re w.re :=
NNReal.eq <| dist_of_im_eq h
#align complex.nndist_of_im_eq Complex.nndist_of_im_eq
| Mathlib/Analysis/Complex/Basic.lean | 133 | 134 | theorem edist_of_im_eq {z w : ℂ} (h : z.im = w.im) : edist z w = edist z.re w.re := by |
rw [edist_nndist, edist_nndist, nndist_of_im_eq h]
|
/-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.CategoryTheory.Limits.Types
import Mathlib.CategoryTheory.Limits.Shapes.Products
import Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts
import Mathlib.CategoryTheory.Limits.Shapes.Terminal
import Mathlib.CategoryTheory.ConcreteCategory.Basic
import Mathlib.Tactic.CategoryTheory.Elementwise
import Mathlib.Data.Set.Subsingleton
#align_import category_theory.limits.shapes.types from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8"
/-!
# Special shapes for limits in `Type`.
The general shape (co)limits defined in `CategoryTheory.Limits.Types`
are intended for use through the limits API,
and the actual implementation should mostly be considered "sealed".
In this file, we provide definitions of the "standard" special shapes of limits in `Type`,
giving the expected definitional implementation:
* the terminal object is `PUnit`
* the binary product of `X` and `Y` is `X × Y`
* the product of a family `f : J → Type` is `Π j, f j`
* the coproduct of a family `f : J → Type` is `Σ j, f j`
* the binary coproduct of `X` and `Y` is the sum type `X ⊕ Y`
* the equalizer of a pair of maps `(g, h)` is the subtype `{x : Y // g x = h x}`
* the coequalizer of a pair of maps `(f, g)` is the quotient of `Y` by `∀ x : Y, f x ~ g x`
* the pullback of `f : X ⟶ Z` and `g : Y ⟶ Z` is the subtype `{ p : X × Y // f p.1 = g p.2 }`
of the product
We first construct terms of `IsLimit` and `LimitCone`, and then provide isomorphisms with the
types generated by the `HasLimit` API.
As an example, when setting up the monoidal category structure on `Type`
we use the `Types.terminalLimitCone` and `Types.binaryProductLimitCone` definitions.
-/
universe v u
open CategoryTheory Limits
namespace CategoryTheory.Limits.Types
example : HasProducts.{v} (Type v) := inferInstance
example [UnivLE.{v, u}] : HasProducts.{v} (Type u) := inferInstance
-- This shortcut instance is required in `Mathlib.CategoryTheory.Closed.Types`,
-- although I don't understand why, and wish it wasn't.
instance : HasProducts.{v} (Type v) := inferInstance
/-- A restatement of `Types.Limit.lift_π_apply` that uses `Pi.π` and `Pi.lift`. -/
@[simp 1001]
theorem pi_lift_π_apply {β : Type v} [Small.{u} β] (f : β → Type u) {P : Type u}
(s : ∀ b, P ⟶ f b) (b : β) (x : P) :
(Pi.π f b : (piObj f) → f b) (@Pi.lift β _ _ f _ P s x) = s b x :=
congr_fun (limit.lift_π (Fan.mk P s) ⟨b⟩) x
#align category_theory.limits.types.pi_lift_π_apply CategoryTheory.Limits.Types.pi_lift_π_apply
/-- A restatement of `Types.Limit.lift_π_apply` that uses `Pi.π` and `Pi.lift`,
with specialized universes. -/
theorem pi_lift_π_apply' {β : Type v} (f : β → Type v) {P : Type v}
(s : ∀ b, P ⟶ f b) (b : β) (x : P) :
(Pi.π f b : (piObj f) → f b) (@Pi.lift β _ _ f _ P s x) = s b x := by
simp
#align category_theory.limits.types.pi_lift_π_apply' CategoryTheory.Limits.Types.pi_lift_π_apply'
/-- A restatement of `Types.Limit.map_π_apply` that uses `Pi.π` and `Pi.map`. -/
@[simp 1001]
theorem pi_map_π_apply {β : Type v} [Small.{u} β] {f g : β → Type u}
(α : ∀ j, f j ⟶ g j) (b : β) (x) :
(Pi.π g b : ∏ᶜ g → g b) (Pi.map α x) = α b ((Pi.π f b : ∏ᶜ f → f b) x) :=
Limit.map_π_apply.{v, u} _ _ _
#align category_theory.limits.types.pi_map_π_apply CategoryTheory.Limits.Types.pi_map_π_apply
/-- A restatement of `Types.Limit.map_π_apply` that uses `Pi.π` and `Pi.map`,
with specialized universes. -/
| Mathlib/CategoryTheory/Limits/Shapes/Types.lean | 82 | 84 | theorem pi_map_π_apply' {β : Type v} {f g : β → Type v} (α : ∀ j, f j ⟶ g j) (b : β) (x) :
(Pi.π g b : ∏ᶜ g → g b) (Pi.map α x) = α b ((Pi.π f b : ∏ᶜ f → f b) x) := by |
simp
|
/-
Copyright (c) 2023 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn
-/
import Mathlib.Data.Finset.Basic
/-!
# Update a function on a set of values
This file defines `Function.updateFinset`, the operation that updates a function on a
(finite) set of values.
This is a very specific function used for `MeasureTheory.marginal`, and possibly not that useful
for other purposes.
-/
variable {ι : Sort _} {π : ι → Sort _} {x : ∀ i, π i} [DecidableEq ι]
namespace Function
/-- `updateFinset x s y` is the vector `x` with the coordinates in `s` changed to the values of `y`.
-/
def updateFinset (x : ∀ i, π i) (s : Finset ι) (y : ∀ i : ↥s, π i) (i : ι) : π i :=
if hi : i ∈ s then y ⟨i, hi⟩ else x i
open Finset Equiv
theorem updateFinset_def {s : Finset ι} {y} :
updateFinset x s y = fun i ↦ if hi : i ∈ s then y ⟨i, hi⟩ else x i :=
rfl
@[simp] theorem updateFinset_empty {y} : updateFinset x ∅ y = x :=
rfl
theorem updateFinset_singleton {i y} :
updateFinset x {i} y = Function.update x i (y ⟨i, mem_singleton_self i⟩) := by
congr with j
by_cases hj : j = i
· cases hj
simp only [dif_pos, Finset.mem_singleton, update_same, updateFinset]
· simp [hj, updateFinset]
theorem update_eq_updateFinset {i y} :
Function.update x i y = updateFinset x {i} (uniqueElim y) := by
congr with j
by_cases hj : j = i
· cases hj
simp only [dif_pos, Finset.mem_singleton, update_same, updateFinset]
exact uniqueElim_default (α := fun j : ({i} : Finset ι) => π j) y
· simp [hj, updateFinset]
| Mathlib/Data/Finset/Update.lean | 52 | 63 | theorem updateFinset_updateFinset {s t : Finset ι} (hst : Disjoint s t)
{y : ∀ i : ↥s, π i} {z : ∀ i : ↥t, π i} :
updateFinset (updateFinset x s y) t z =
updateFinset x (s ∪ t) (Equiv.piFinsetUnion π hst ⟨y, z⟩) := by |
set e := Equiv.Finset.union s t hst
congr with i
by_cases his : i ∈ s <;> by_cases hit : i ∈ t <;>
simp only [updateFinset, his, hit, dif_pos, dif_neg, Finset.mem_union, true_or_iff,
false_or_iff, not_false_iff]
· exfalso; exact Finset.disjoint_left.mp hst his hit
· exact piCongrLeft_sum_inl (fun b : ↥(s ∪ t) => π b) e y z ⟨i, his⟩ |>.symm
· exact piCongrLeft_sum_inr (fun b : ↥(s ∪ t) => π b) e y z ⟨i, hit⟩ |>.symm
|
/-
Copyright (c) 2022 Xavier Roblot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Xavier Roblot
-/
import Mathlib.Algebra.Module.Zlattice.Basic
import Mathlib.NumberTheory.NumberField.Embeddings
import Mathlib.NumberTheory.NumberField.FractionalIdeal
#align_import number_theory.number_field.canonical_embedding from "leanprover-community/mathlib"@"60da01b41bbe4206f05d34fd70c8dd7498717a30"
/-!
# Canonical embedding of a number field
The canonical embedding of a number field `K` of degree `n` is the ring homomorphism
`K →+* ℂ^n` that sends `x ∈ K` to `(φ_₁(x),...,φ_n(x))` where the `φ_i`'s are the complex
embeddings of `K`. Note that we do not choose an ordering of the embeddings, but instead map `K`
into the type `(K →+* ℂ) → ℂ` of `ℂ`-vectors indexed by the complex embeddings.
## Main definitions and results
* `NumberField.canonicalEmbedding`: the ring homomorphism `K →+* ((K →+* ℂ) → ℂ)` defined by
sending `x : K` to the vector `(φ x)` indexed by `φ : K →+* ℂ`.
* `NumberField.canonicalEmbedding.integerLattice.inter_ball_finite`: the intersection of the
image of the ring of integers by the canonical embedding and any ball centered at `0` of finite
radius is finite.
* `NumberField.mixedEmbedding`: the ring homomorphism from `K →+* ({ w // IsReal w } → ℝ) ×
({ w // IsComplex w } → ℂ)` that sends `x ∈ K` to `(φ_w x)_w` where `φ_w` is the embedding
associated to the infinite place `w`. In particular, if `w` is real then `φ_w : K →+* ℝ` and, if
`w` is complex, `φ_w` is an arbitrary choice between the two complex embeddings defining the place
`w`.
## Tags
number field, infinite places
-/
variable (K : Type*) [Field K]
namespace NumberField.canonicalEmbedding
open NumberField
/-- The canonical embedding of a number field `K` of degree `n` into `ℂ^n`. -/
def _root_.NumberField.canonicalEmbedding : K →+* ((K →+* ℂ) → ℂ) := Pi.ringHom fun φ => φ
theorem _root_.NumberField.canonicalEmbedding_injective [NumberField K] :
Function.Injective (NumberField.canonicalEmbedding K) := RingHom.injective _
variable {K}
@[simp]
theorem apply_at (φ : K →+* ℂ) (x : K) : (NumberField.canonicalEmbedding K x) φ = φ x := rfl
open scoped ComplexConjugate
/-- The image of `canonicalEmbedding` lives in the `ℝ`-submodule of the `x ∈ ((K →+* ℂ) → ℂ)` such
that `conj x_φ = x_(conj φ)` for all `∀ φ : K →+* ℂ`. -/
| Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean | 61 | 70 | theorem conj_apply {x : ((K →+* ℂ) → ℂ)} (φ : K →+* ℂ)
(hx : x ∈ Submodule.span ℝ (Set.range (canonicalEmbedding K))) :
conj (x φ) = x (ComplexEmbedding.conjugate φ) := by |
refine Submodule.span_induction hx ?_ ?_ (fun _ _ hx hy => ?_) (fun a _ hx => ?_)
· rintro _ ⟨x, rfl⟩
rw [apply_at, apply_at, ComplexEmbedding.conjugate_coe_eq]
· rw [Pi.zero_apply, Pi.zero_apply, map_zero]
· rw [Pi.add_apply, Pi.add_apply, map_add, hx, hy]
· rw [Pi.smul_apply, Complex.real_smul, map_mul, Complex.conj_ofReal]
exact congrArg ((a : ℂ) * ·) hx
|
/-
Copyright (c) 2020 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-/
import Mathlib.Topology.Algebra.Ring.Ideal
import Mathlib.Analysis.SpecificLimits.Normed
#align_import analysis.normed_space.units from "leanprover-community/mathlib"@"9a59dcb7a2d06bf55da57b9030169219980660cd"
/-!
# The group of units of a complete normed ring
This file contains the basic theory for the group of units (invertible elements) of a complete
normed ring (Banach algebras being a notable special case).
## Main results
The constructions `Units.oneSub`, `Units.add`, and `Units.ofNearby` state, in varying forms, that
perturbations of a unit are units. The latter two are not stated in their optimal form; more precise
versions would use the spectral radius.
The first main result is `Units.isOpen`: the group of units of a complete normed ring is an open
subset of the ring.
The function `Ring.inverse` (defined elsewhere), for a ring `R`, sends `a : R` to `a⁻¹` if `a` is a
unit and `0` if not. The other major results of this file (notably `NormedRing.inverse_add`,
`NormedRing.inverse_add_norm` and `NormedRing.inverse_add_norm_diff_nth_order`) cover the asymptotic
properties of `Ring.inverse (x + t)` as `t → 0`.
-/
noncomputable section
open Topology
variable {R : Type*} [NormedRing R] [CompleteSpace R]
namespace Units
/-- In a complete normed ring, a perturbation of `1` by an element `t` of distance less than `1`
from `1` is a unit. Here we construct its `Units` structure. -/
@[simps val]
def oneSub (t : R) (h : ‖t‖ < 1) : Rˣ where
val := 1 - t
inv := ∑' n : ℕ, t ^ n
val_inv := mul_neg_geom_series t h
inv_val := geom_series_mul_neg t h
#align units.one_sub Units.oneSub
#align units.coe_one_sub Units.val_oneSub
/-- In a complete normed ring, a perturbation of a unit `x` by an element `t` of distance less than
`‖x⁻¹‖⁻¹` from `x` is a unit. Here we construct its `Units` structure. -/
@[simps! val]
def add (x : Rˣ) (t : R) (h : ‖t‖ < ‖(↑x⁻¹ : R)‖⁻¹) : Rˣ :=
Units.copy -- to make `add_val` true definitionally, for convenience
(x * Units.oneSub (-((x⁻¹).1 * t)) (by
nontriviality R using zero_lt_one
have hpos : 0 < ‖(↑x⁻¹ : R)‖ := Units.norm_pos x⁻¹
calc
‖-(↑x⁻¹ * t)‖ = ‖↑x⁻¹ * t‖ := by rw [norm_neg]
_ ≤ ‖(↑x⁻¹ : R)‖ * ‖t‖ := norm_mul_le (x⁻¹).1 _
_ < ‖(↑x⁻¹ : R)‖ * ‖(↑x⁻¹ : R)‖⁻¹ := by nlinarith only [h, hpos]
_ = 1 := mul_inv_cancel (ne_of_gt hpos)))
(x + t) (by simp [mul_add]) _ rfl
#align units.add Units.add
#align units.coe_add Units.val_add
/-- In a complete normed ring, an element `y` of distance less than `‖x⁻¹‖⁻¹` from `x` is a unit.
Here we construct its `Units` structure. -/
@[simps! val]
def ofNearby (x : Rˣ) (y : R) (h : ‖y - x‖ < ‖(↑x⁻¹ : R)‖⁻¹) : Rˣ :=
(x.add (y - x : R) h).copy y (by simp) _ rfl
#align units.unit_of_nearby Units.ofNearby
#align units.coe_unit_of_nearby Units.val_ofNearby
/-- The group of units of a complete normed ring is an open subset of the ring. -/
protected theorem isOpen : IsOpen { x : R | IsUnit x } := by
nontriviality R
rw [Metric.isOpen_iff]
rintro _ ⟨x, rfl⟩
refine ⟨‖(↑x⁻¹ : R)‖⁻¹, _root_.inv_pos.mpr (Units.norm_pos x⁻¹), fun y hy ↦ ?_⟩
rw [mem_ball_iff_norm] at hy
exact (x.ofNearby y hy).isUnit
#align units.is_open Units.isOpen
protected theorem nhds (x : Rˣ) : { x : R | IsUnit x } ∈ 𝓝 (x : R) :=
IsOpen.mem_nhds Units.isOpen x.isUnit
#align units.nhds Units.nhds
end Units
namespace nonunits
/-- The `nonunits` in a complete normed ring are contained in the complement of the ball of radius
`1` centered at `1 : R`. -/
theorem subset_compl_ball : nonunits R ⊆ (Metric.ball (1 : R) 1)ᶜ := fun x hx h₁ ↦ hx <|
sub_sub_self 1 x ▸ (Units.oneSub (1 - x) (by rwa [mem_ball_iff_norm'] at h₁)).isUnit
#align nonunits.subset_compl_ball nonunits.subset_compl_ball
-- The `nonunits` in a complete normed ring are a closed set
protected theorem isClosed : IsClosed (nonunits R) :=
Units.isOpen.isClosed_compl
#align nonunits.is_closed nonunits.isClosed
end nonunits
namespace NormedRing
open scoped Classical
open Asymptotics Filter Metric Finset Ring
| Mathlib/Analysis/NormedSpace/Units.lean | 113 | 114 | theorem inverse_one_sub (t : R) (h : ‖t‖ < 1) : inverse (1 - t) = ↑(Units.oneSub t h)⁻¹ := by |
rw [← inverse_unit (Units.oneSub t h), Units.val_oneSub]
|
/-
Copyright (c) 2024 Riccardo Brasca. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Riccardo Brasca
-/
import Mathlib.NumberTheory.Cyclotomic.PrimitiveRoots
import Mathlib.NumberTheory.NumberField.Embeddings
/-!
# Cyclotomic extensions of `ℚ` are totally complex number fields.
We prove that cyclotomic extensions of `ℚ` are totally complex, meaning that
`NrRealPlaces K = 0` if `IsCyclotomicExtension {n} ℚ K` and `2 < n`.
## Main results
* `nrRealPlaces_eq_zero`: If `K` is a `n`-th cyclotomic extension of `ℚ`, where `2 < n`,
then there are no real places of `K`.
-/
universe u
namespace IsCyclotomicExtension.Rat
open NumberField InfinitePlace FiniteDimensional Complex Nat Polynomial
variable {n : ℕ+} (K : Type u) [Field K] [CharZero K]
/-- If `K` is a `n`-th cyclotomic extension of `ℚ`, where `2 < n`, then there are no real places
of `K`. -/
| Mathlib/NumberTheory/Cyclotomic/Embeddings.lean | 30 | 35 | theorem nrRealPlaces_eq_zero [IsCyclotomicExtension {n} ℚ K]
(hn : 2 < n) :
haveI := IsCyclotomicExtension.numberField {n} ℚ K
NrRealPlaces K = 0 := by |
have := IsCyclotomicExtension.numberField {n} ℚ K
apply (IsCyclotomicExtension.zeta_spec n ℚ K).nrRealPlaces_eq_zero_of_two_lt hn
|
/-
Copyright (c) 2021 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Order.Interval.Finset.Nat
#align_import data.fin.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29"
/-!
# Finite intervals in `Fin n`
This file proves that `Fin n` is a `LocallyFiniteOrder` and calculates the cardinality of its
intervals as Finsets and Fintypes.
-/
assert_not_exists MonoidWithZero
namespace Fin
variable {n : ℕ} (a b : Fin n)
@[simp, norm_cast]
theorem coe_sup : ↑(a ⊔ b) = (a ⊔ b : ℕ) := rfl
#align fin.coe_sup Fin.coe_sup
@[simp, norm_cast]
theorem coe_inf : ↑(a ⊓ b) = (a ⊓ b : ℕ) := rfl
#align fin.coe_inf Fin.coe_inf
@[simp, norm_cast]
theorem coe_max : ↑(max a b) = (max a b : ℕ) := rfl
#align fin.coe_max Fin.coe_max
@[simp, norm_cast]
theorem coe_min : ↑(min a b) = (min a b : ℕ) := rfl
#align fin.coe_min Fin.coe_min
end Fin
open Finset Fin Function
namespace Fin
variable (n : ℕ)
instance instLocallyFiniteOrder : LocallyFiniteOrder (Fin n) :=
OrderIso.locallyFiniteOrder Fin.orderIsoSubtype
instance instLocallyFiniteOrderBot : LocallyFiniteOrderBot (Fin n) :=
OrderIso.locallyFiniteOrderBot Fin.orderIsoSubtype
instance instLocallyFiniteOrderTop : ∀ n, LocallyFiniteOrderTop (Fin n)
| 0 => IsEmpty.toLocallyFiniteOrderTop
| _ + 1 => inferInstance
variable {n} (a b : Fin n)
theorem Icc_eq_finset_subtype : Icc a b = (Icc (a : ℕ) b).fin n :=
rfl
#align fin.Icc_eq_finset_subtype Fin.Icc_eq_finset_subtype
theorem Ico_eq_finset_subtype : Ico a b = (Ico (a : ℕ) b).fin n :=
rfl
#align fin.Ico_eq_finset_subtype Fin.Ico_eq_finset_subtype
theorem Ioc_eq_finset_subtype : Ioc a b = (Ioc (a : ℕ) b).fin n :=
rfl
#align fin.Ioc_eq_finset_subtype Fin.Ioc_eq_finset_subtype
theorem Ioo_eq_finset_subtype : Ioo a b = (Ioo (a : ℕ) b).fin n :=
rfl
#align fin.Ioo_eq_finset_subtype Fin.Ioo_eq_finset_subtype
theorem uIcc_eq_finset_subtype : uIcc a b = (uIcc (a : ℕ) b).fin n := rfl
#align fin.uIcc_eq_finset_subtype Fin.uIcc_eq_finset_subtype
@[simp]
theorem map_valEmbedding_Icc : (Icc a b).map Fin.valEmbedding = Icc ↑a ↑b := by
simp [Icc_eq_finset_subtype, Finset.fin, Finset.map_map, Icc_filter_lt_of_lt_right]
#align fin.map_subtype_embedding_Icc Fin.map_valEmbedding_Icc
@[simp]
theorem map_valEmbedding_Ico : (Ico a b).map Fin.valEmbedding = Ico ↑a ↑b := by
simp [Ico_eq_finset_subtype, Finset.fin, Finset.map_map]
#align fin.map_subtype_embedding_Ico Fin.map_valEmbedding_Ico
@[simp]
theorem map_valEmbedding_Ioc : (Ioc a b).map Fin.valEmbedding = Ioc ↑a ↑b := by
simp [Ioc_eq_finset_subtype, Finset.fin, Finset.map_map, Ioc_filter_lt_of_lt_right]
#align fin.map_subtype_embedding_Ioc Fin.map_valEmbedding_Ioc
@[simp]
theorem map_valEmbedding_Ioo : (Ioo a b).map Fin.valEmbedding = Ioo ↑a ↑b := by
simp [Ioo_eq_finset_subtype, Finset.fin, Finset.map_map]
#align fin.map_subtype_embedding_Ioo Fin.map_valEmbedding_Ioo
@[simp]
theorem map_subtype_embedding_uIcc : (uIcc a b).map valEmbedding = uIcc ↑a ↑b :=
map_valEmbedding_Icc _ _
#align fin.map_subtype_embedding_uIcc Fin.map_subtype_embedding_uIcc
@[simp]
theorem card_Icc : (Icc a b).card = b + 1 - a := by
rw [← Nat.card_Icc, ← map_valEmbedding_Icc, card_map]
#align fin.card_Icc Fin.card_Icc
@[simp]
| Mathlib/Order/Interval/Finset/Fin.lean | 109 | 110 | theorem card_Ico : (Ico a b).card = b - a := by |
rw [← Nat.card_Ico, ← map_valEmbedding_Ico, card_map]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import Mathlib.Data.Set.Finite
#align_import data.finset.preimage from "leanprover-community/mathlib"@"3365b20c2ffa7c35e47e5209b89ba9abdddf3ffe"
/-!
# Preimage of a `Finset` under an injective map.
-/
assert_not_exists Finset.sum
open Set Function
universe u v w x
variable {α : Type u} {β : Type v} {ι : Sort w} {γ : Type x}
namespace Finset
section Preimage
/-- Preimage of `s : Finset β` under a map `f` injective on `f ⁻¹' s` as a `Finset`. -/
noncomputable def preimage (s : Finset β) (f : α → β) (hf : Set.InjOn f (f ⁻¹' ↑s)) : Finset α :=
(s.finite_toSet.preimage hf).toFinset
#align finset.preimage Finset.preimage
@[simp]
theorem mem_preimage {f : α → β} {s : Finset β} {hf : Set.InjOn f (f ⁻¹' ↑s)} {x : α} :
x ∈ preimage s f hf ↔ f x ∈ s :=
Set.Finite.mem_toFinset _
#align finset.mem_preimage Finset.mem_preimage
@[simp, norm_cast]
theorem coe_preimage {f : α → β} (s : Finset β) (hf : Set.InjOn f (f ⁻¹' ↑s)) :
(↑(preimage s f hf) : Set α) = f ⁻¹' ↑s :=
Set.Finite.coe_toFinset _
#align finset.coe_preimage Finset.coe_preimage
@[simp]
theorem preimage_empty {f : α → β} : preimage ∅ f (by simp [InjOn]) = ∅ :=
Finset.coe_injective (by simp)
#align finset.preimage_empty Finset.preimage_empty
@[simp]
theorem preimage_univ {f : α → β} [Fintype α] [Fintype β] (hf) : preimage univ f hf = univ :=
Finset.coe_injective (by simp)
#align finset.preimage_univ Finset.preimage_univ
@[simp]
theorem preimage_inter [DecidableEq α] [DecidableEq β] {f : α → β} {s t : Finset β}
(hs : Set.InjOn f (f ⁻¹' ↑s)) (ht : Set.InjOn f (f ⁻¹' ↑t)) :
(preimage (s ∩ t) f fun x₁ hx₁ x₂ hx₂ =>
hs (mem_of_mem_inter_left hx₁) (mem_of_mem_inter_left hx₂)) =
preimage s f hs ∩ preimage t f ht :=
Finset.coe_injective (by simp)
#align finset.preimage_inter Finset.preimage_inter
@[simp]
theorem preimage_union [DecidableEq α] [DecidableEq β] {f : α → β} {s t : Finset β} (hst) :
preimage (s ∪ t) f hst =
(preimage s f fun x₁ hx₁ x₂ hx₂ => hst (mem_union_left _ hx₁) (mem_union_left _ hx₂)) ∪
preimage t f fun x₁ hx₁ x₂ hx₂ => hst (mem_union_right _ hx₁) (mem_union_right _ hx₂) :=
Finset.coe_injective (by simp)
#align finset.preimage_union Finset.preimage_union
@[simp, nolint simpNF] -- Porting note: linter complains that LHS doesn't simplify
theorem preimage_compl [DecidableEq α] [DecidableEq β] [Fintype α] [Fintype β] {f : α → β}
(s : Finset β) (hf : Function.Injective f) :
preimage sᶜ f hf.injOn = (preimage s f hf.injOn)ᶜ :=
Finset.coe_injective (by simp)
#align finset.preimage_compl Finset.preimage_compl
@[simp]
lemma preimage_map (f : α ↪ β) (s : Finset α) : (s.map f).preimage f f.injective.injOn = s :=
coe_injective <| by simp only [coe_preimage, coe_map, Set.preimage_image_eq _ f.injective]
#align finset.preimage_map Finset.preimage_map
theorem monotone_preimage {f : α → β} (h : Injective f) :
Monotone fun s => preimage s f h.injOn := fun _ _ H _ hx =>
mem_preimage.2 (H <| mem_preimage.1 hx)
#align finset.monotone_preimage Finset.monotone_preimage
theorem image_subset_iff_subset_preimage [DecidableEq β] {f : α → β} {s : Finset α} {t : Finset β}
(hf : Set.InjOn f (f ⁻¹' ↑t)) : s.image f ⊆ t ↔ s ⊆ t.preimage f hf :=
image_subset_iff.trans <| by simp only [subset_iff, mem_preimage]
#align finset.image_subset_iff_subset_preimage Finset.image_subset_iff_subset_preimage
| Mathlib/Data/Finset/Preimage.lean | 92 | 94 | theorem map_subset_iff_subset_preimage {f : α ↪ β} {s : Finset α} {t : Finset β} :
s.map f ⊆ t ↔ s ⊆ t.preimage f f.injective.injOn := by |
classical rw [map_eq_image, image_subset_iff_subset_preimage]
|
/-
Copyright (c) 2018 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Jens Wagemaker, Aaron Anderson
-/
import Mathlib.Algebra.EuclideanDomain.Basic
import Mathlib.RingTheory.PrincipalIdealDomain
import Mathlib.Algebra.GCDMonoid.Nat
#align_import ring_theory.int.basic from "leanprover-community/mathlib"@"e655e4ea5c6d02854696f97494997ba4c31be802"
/-!
# Divisibility over ℕ and ℤ
This file collects results for the integers and natural numbers that use ring theory in
their proofs or cases of ℕ and ℤ being examples of structures in ring theory.
## Main statements
* `Nat.factors_eq`: the multiset of elements of `Nat.factors` is equal to the factors
given by the `UniqueFactorizationMonoid` instance
## Tags
prime, irreducible, natural numbers, integers, normalization monoid, gcd monoid,
greatest common divisor, prime factorization, prime factors, unique factorization,
unique factors
-/
namespace Int
theorem gcd_eq_one_iff_coprime {a b : ℤ} : Int.gcd a b = 1 ↔ IsCoprime a b := by
constructor
· intro hg
obtain ⟨ua, -, ha⟩ := exists_unit_of_abs a
obtain ⟨ub, -, hb⟩ := exists_unit_of_abs b
use Nat.gcdA (Int.natAbs a) (Int.natAbs b) * ua, Nat.gcdB (Int.natAbs a) (Int.natAbs b) * ub
rw [mul_assoc, ← ha, mul_assoc, ← hb, mul_comm, mul_comm _ (Int.natAbs b : ℤ), ←
Nat.gcd_eq_gcd_ab, ← gcd_eq_natAbs, hg, Int.ofNat_one]
· rintro ⟨r, s, h⟩
by_contra hg
obtain ⟨p, ⟨hp, ha, hb⟩⟩ := Nat.Prime.not_coprime_iff_dvd.mp hg
apply Nat.Prime.not_dvd_one hp
rw [← natCast_dvd_natCast, Int.ofNat_one, ← h]
exact dvd_add ((natCast_dvd.mpr ha).mul_left _) ((natCast_dvd.mpr hb).mul_left _)
#align int.gcd_eq_one_iff_coprime Int.gcd_eq_one_iff_coprime
theorem coprime_iff_nat_coprime {a b : ℤ} : IsCoprime a b ↔ Nat.Coprime a.natAbs b.natAbs := by
rw [← gcd_eq_one_iff_coprime, Nat.coprime_iff_gcd_eq_one, gcd_eq_natAbs]
#align int.coprime_iff_nat_coprime Int.coprime_iff_nat_coprime
/-- If `gcd a (m * n) ≠ 1`, then `gcd a m ≠ 1` or `gcd a n ≠ 1`. -/
theorem gcd_ne_one_iff_gcd_mul_right_ne_one {a : ℤ} {m n : ℕ} :
a.gcd (m * n) ≠ 1 ↔ a.gcd m ≠ 1 ∨ a.gcd n ≠ 1 := by
simp only [gcd_eq_one_iff_coprime, ← not_and_or, not_iff_not, IsCoprime.mul_right_iff]
#align int.gcd_ne_one_iff_gcd_mul_right_ne_one Int.gcd_ne_one_iff_gcd_mul_right_ne_one
theorem sq_of_gcd_eq_one {a b c : ℤ} (h : Int.gcd a b = 1) (heq : a * b = c ^ 2) :
∃ a0 : ℤ, a = a0 ^ 2 ∨ a = -a0 ^ 2 := by
have h' : IsUnit (GCDMonoid.gcd a b) := by
rw [← coe_gcd, h, Int.ofNat_one]
exact isUnit_one
obtain ⟨d, ⟨u, hu⟩⟩ := exists_associated_pow_of_mul_eq_pow h' heq
use d
rw [← hu]
cases' Int.units_eq_one_or u with hu' hu' <;>
· rw [hu']
simp
#align int.sq_of_gcd_eq_one Int.sq_of_gcd_eq_one
theorem sq_of_coprime {a b c : ℤ} (h : IsCoprime a b) (heq : a * b = c ^ 2) :
∃ a0 : ℤ, a = a0 ^ 2 ∨ a = -a0 ^ 2 :=
sq_of_gcd_eq_one (gcd_eq_one_iff_coprime.mpr h) heq
#align int.sq_of_coprime Int.sq_of_coprime
theorem natAbs_euclideanDomain_gcd (a b : ℤ) :
Int.natAbs (EuclideanDomain.gcd a b) = Int.gcd a b := by
apply Nat.dvd_antisymm <;> rw [← Int.natCast_dvd_natCast]
· rw [Int.natAbs_dvd]
exact Int.dvd_gcd (EuclideanDomain.gcd_dvd_left _ _) (EuclideanDomain.gcd_dvd_right _ _)
· rw [Int.dvd_natAbs]
exact EuclideanDomain.dvd_gcd Int.gcd_dvd_left Int.gcd_dvd_right
#align int.nat_abs_euclidean_domain_gcd Int.natAbs_euclideanDomain_gcd
end Int
theorem Int.Prime.dvd_mul {m n : ℤ} {p : ℕ} (hp : Nat.Prime p) (h : (p : ℤ) ∣ m * n) :
p ∣ m.natAbs ∨ p ∣ n.natAbs := by
rwa [← hp.dvd_mul, ← Int.natAbs_mul, ← Int.natCast_dvd]
#align int.prime.dvd_mul Int.Prime.dvd_mul
theorem Int.Prime.dvd_mul' {m n : ℤ} {p : ℕ} (hp : Nat.Prime p) (h : (p : ℤ) ∣ m * n) :
(p : ℤ) ∣ m ∨ (p : ℤ) ∣ n := by
rw [Int.natCast_dvd, Int.natCast_dvd]
exact Int.Prime.dvd_mul hp h
#align int.prime.dvd_mul' Int.Prime.dvd_mul'
theorem Int.Prime.dvd_pow {n : ℤ} {k p : ℕ} (hp : Nat.Prime p) (h : (p : ℤ) ∣ n ^ k) :
p ∣ n.natAbs := by
rw [Int.natCast_dvd, Int.natAbs_pow] at h
exact hp.dvd_of_dvd_pow h
#align int.prime.dvd_pow Int.Prime.dvd_pow
| Mathlib/RingTheory/Int/Basic.lean | 105 | 108 | theorem Int.Prime.dvd_pow' {n : ℤ} {k p : ℕ} (hp : Nat.Prime p) (h : (p : ℤ) ∣ n ^ k) :
(p : ℤ) ∣ n := by |
rw [Int.natCast_dvd]
exact Int.Prime.dvd_pow hp 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, Sébastien Gouëzel, Yury Kudryashov
-/
import Mathlib.Dynamics.Ergodic.MeasurePreserving
import Mathlib.LinearAlgebra.Determinant
import Mathlib.LinearAlgebra.Matrix.Diagonal
import Mathlib.LinearAlgebra.Matrix.Transvection
import Mathlib.MeasureTheory.Group.LIntegral
import Mathlib.MeasureTheory.Integral.Marginal
import Mathlib.MeasureTheory.Measure.Stieltjes
import Mathlib.MeasureTheory.Measure.Haar.OfBasis
#align_import measure_theory.measure.lebesgue.basic from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
/-!
# Lebesgue measure on the real line and on `ℝⁿ`
We show that the Lebesgue measure on the real line (constructed as a particular case of additive
Haar measure on inner product spaces) coincides with the Stieltjes measure associated
to the function `x ↦ x`. We deduce properties of this measure on `ℝ`, and then of the product
Lebesgue measure on `ℝⁿ`. In particular, we prove that they are translation invariant.
We show that, on `ℝⁿ`, a linear map acts on Lebesgue measure by rescaling it through the absolute
value of its determinant, in `Real.map_linearMap_volume_pi_eq_smul_volume_pi`.
More properties of the Lebesgue measure are deduced from this in
`Mathlib/MeasureTheory/Measure/Lebesgue/EqHaar.lean`, where they are proved more generally for any
additive Haar measure on a finite-dimensional real vector space.
-/
assert_not_exists MeasureTheory.integral
noncomputable section
open scoped Classical
open Set Filter MeasureTheory MeasureTheory.Measure TopologicalSpace
open ENNReal (ofReal)
open scoped ENNReal NNReal Topology
/-!
### Definition of the Lebesgue measure and lengths of intervals
-/
namespace Real
variable {ι : Type*} [Fintype ι]
/-- The volume on the real line (as a particular case of the volume on a finite-dimensional
inner product space) coincides with the Stieltjes measure coming from the identity function. -/
| Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean | 56 | 72 | theorem volume_eq_stieltjes_id : (volume : Measure ℝ) = StieltjesFunction.id.measure := by |
haveI : IsAddLeftInvariant StieltjesFunction.id.measure :=
⟨fun a =>
Eq.symm <|
Real.measure_ext_Ioo_rat fun p q => by
simp only [Measure.map_apply (measurable_const_add a) measurableSet_Ioo,
sub_sub_sub_cancel_right, StieltjesFunction.measure_Ioo, StieltjesFunction.id_leftLim,
StieltjesFunction.id_apply, id, preimage_const_add_Ioo]⟩
have A : StieltjesFunction.id.measure (stdOrthonormalBasis ℝ ℝ).toBasis.parallelepiped = 1 := by
change StieltjesFunction.id.measure (parallelepiped (stdOrthonormalBasis ℝ ℝ)) = 1
rcases parallelepiped_orthonormalBasis_one_dim (stdOrthonormalBasis ℝ ℝ) with (H | H) <;>
simp only [H, StieltjesFunction.measure_Icc, StieltjesFunction.id_apply, id, tsub_zero,
StieltjesFunction.id_leftLim, sub_neg_eq_add, zero_add, ENNReal.ofReal_one]
conv_rhs =>
rw [addHaarMeasure_unique StieltjesFunction.id.measure
(stdOrthonormalBasis ℝ ℝ).toBasis.parallelepiped, A]
simp only [volume, Basis.addHaar, one_smul]
|
/-
Copyright (c) 2018 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Johannes Hölzl, Simon Hudon, Kenny Lau
-/
import Mathlib.Data.Multiset.Bind
import Mathlib.Control.Traversable.Lemmas
import Mathlib.Control.Traversable.Instances
#align_import data.multiset.functor from "leanprover-community/mathlib"@"1f0096e6caa61e9c849ec2adbd227e960e9dff58"
/-!
# Functoriality of `Multiset`.
-/
universe u
namespace Multiset
open List
instance functor : Functor Multiset where map := @map
@[simp]
theorem fmap_def {α' β'} {s : Multiset α'} (f : α' → β') : f <$> s = s.map f :=
rfl
#align multiset.fmap_def Multiset.fmap_def
instance : LawfulFunctor Multiset where
id_map := by simp
comp_map := by simp
map_const {_ _} := rfl
open LawfulTraversable CommApplicative
variable {F : Type u → Type u} [Applicative F] [CommApplicative F]
variable {α' β' : Type u} (f : α' → F β')
/-- Map each element of a `Multiset` to an action, evaluate these actions in order,
and collect the results.
-/
def traverse : Multiset α' → F (Multiset β') := by
refine Quotient.lift (Functor.map Coe.coe ∘ Traversable.traverse f) ?_
introv p; unfold Function.comp
induction p with
| nil => rfl
| @cons x l₁ l₂ _ h =>
have :
Multiset.cons <$> f x <*> Coe.coe <$> Traversable.traverse f l₁ =
Multiset.cons <$> f x <*> Coe.coe <$> Traversable.traverse f l₂ := by rw [h]
simpa [functor_norm] using this
| swap x y l =>
have :
(fun a b (l : List β') ↦ (↑(a :: b :: l) : Multiset β')) <$> f y <*> f x =
(fun a b l ↦ ↑(a :: b :: l)) <$> f x <*> f y := by
rw [CommApplicative.commutative_map]
congr
funext a b l
simpa [flip] using Perm.swap a b l
simp [(· ∘ ·), this, functor_norm, Coe.coe]
| trans => simp [*]
#align multiset.traverse Multiset.traverse
instance : Monad Multiset :=
{ Multiset.functor with
pure := fun x ↦ {x}
bind := @bind }
@[simp]
theorem pure_def {α} : (pure : α → Multiset α) = singleton :=
rfl
#align multiset.pure_def Multiset.pure_def
@[simp]
theorem bind_def {α β} : (· >>= ·) = @bind α β :=
rfl
#align multiset.bind_def Multiset.bind_def
instance : LawfulMonad Multiset := LawfulMonad.mk'
(bind_pure_comp := fun _ _ ↦ by simp only [pure_def, bind_def, bind_singleton, fmap_def])
(id_map := fun _ ↦ by simp only [fmap_def, id_eq, map_id'])
(pure_bind := fun _ _ ↦ by simp only [pure_def, bind_def, singleton_bind])
(bind_assoc := @bind_assoc)
open Functor
open Traversable LawfulTraversable
@[simp]
theorem lift_coe {α β : Type*} (x : List α) (f : List α → β)
(h : ∀ a b : List α, a ≈ b → f a = f b) : Quotient.lift f h (x : Multiset α) = f x :=
Quotient.lift_mk _ _ _
#align multiset.lift_coe Multiset.lift_coe
@[simp]
theorem map_comp_coe {α β} (h : α → β) :
Functor.map h ∘ Coe.coe = (Coe.coe ∘ Functor.map h : List α → Multiset β) := by
funext; simp only [Function.comp_apply, Coe.coe, fmap_def, map_coe, List.map_eq_map]
#align multiset.map_comp_coe Multiset.map_comp_coe
theorem id_traverse {α : Type*} (x : Multiset α) : traverse (pure : α → Id α) x = x := by
refine Quotient.inductionOn x ?_
intro
simp [traverse, Coe.coe]
#align multiset.id_traverse Multiset.id_traverse
theorem comp_traverse {G H : Type _ → Type _} [Applicative G] [Applicative H] [CommApplicative G]
[CommApplicative H] {α β γ : Type _} (g : α → G β) (h : β → H γ) (x : Multiset α) :
traverse (Comp.mk ∘ Functor.map h ∘ g) x =
Comp.mk (Functor.map (traverse h) (traverse g x)) := by
refine Quotient.inductionOn x ?_
intro
simp only [traverse, quot_mk_to_coe, lift_coe, Coe.coe, Function.comp_apply, Functor.map_map,
functor_norm]
simp only [Function.comp, lift_coe]
#align multiset.comp_traverse Multiset.comp_traverse
| Mathlib/Data/Multiset/Functor.lean | 119 | 126 | theorem map_traverse {G : Type* → Type _} [Applicative G] [CommApplicative G] {α β γ : Type _}
(g : α → G β) (h : β → γ) (x : Multiset α) :
Functor.map (Functor.map h) (traverse g x) = traverse (Functor.map h ∘ g) x := by |
refine Quotient.inductionOn x ?_
intro
simp only [traverse, quot_mk_to_coe, lift_coe, Function.comp_apply, Functor.map_map, map_comp_coe]
rw [LawfulFunctor.comp_map, Traversable.map_traverse']
rfl
|
/-
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.LinearAlgebra.Span
import Mathlib.RingTheory.Ideal.IsPrimary
import Mathlib.RingTheory.Ideal.QuotientOperations
import Mathlib.RingTheory.Noetherian
#align_import ring_theory.ideal.associated_prime from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
/-!
# Associated primes of a module
We provide the definition and related lemmas about associated primes of modules.
## Main definition
- `IsAssociatedPrime`: `IsAssociatedPrime I M` if the prime ideal `I` is the
annihilator of some `x : M`.
- `associatedPrimes`: The set of associated primes of a module.
## Main results
- `exists_le_isAssociatedPrime_of_isNoetherianRing`: In a noetherian ring, any `ann(x)` is
contained in an associated prime for `x ≠ 0`.
- `associatedPrimes.eq_singleton_of_isPrimary`: In a noetherian ring, `I.radical` is the only
associated prime of `R ⧸ I` when `I` is primary.
## Todo
Generalize this to a non-commutative setting once there are annihilator for non-commutative rings.
-/
variable {R : Type*} [CommRing R] (I J : Ideal R) (M : Type*) [AddCommGroup M] [Module R M]
/-- `IsAssociatedPrime I M` if the prime ideal `I` is the annihilator of some `x : M`. -/
def IsAssociatedPrime : Prop :=
I.IsPrime ∧ ∃ x : M, I = (R ∙ x).annihilator
#align is_associated_prime IsAssociatedPrime
variable (R)
/-- The set of associated primes of a module. -/
def associatedPrimes : Set (Ideal R) :=
{ I | IsAssociatedPrime I M }
#align associated_primes associatedPrimes
variable {I J M R}
variable {M' : Type*} [AddCommGroup M'] [Module R M'] (f : M →ₗ[R] M')
theorem AssociatePrimes.mem_iff : I ∈ associatedPrimes R M ↔ IsAssociatedPrime I M := Iff.rfl
#align associate_primes.mem_iff AssociatePrimes.mem_iff
theorem IsAssociatedPrime.isPrime (h : IsAssociatedPrime I M) : I.IsPrime := h.1
#align is_associated_prime.is_prime IsAssociatedPrime.isPrime
| Mathlib/RingTheory/Ideal/AssociatedPrime.lean | 59 | 65 | theorem IsAssociatedPrime.map_of_injective (h : IsAssociatedPrime I M) (hf : Function.Injective f) :
IsAssociatedPrime I M' := by |
obtain ⟨x, rfl⟩ := h.2
refine ⟨h.1, ⟨f x, ?_⟩⟩
ext r
rw [Submodule.mem_annihilator_span_singleton, Submodule.mem_annihilator_span_singleton, ←
map_smul, ← f.map_zero, hf.eq_iff]
|
/-
Copyright (c) 2022 Martin Zinkevich. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Martin Zinkevich
-/
import Mathlib.MeasureTheory.Measure.Typeclasses
#align_import measure_theory.measure.sub from "leanprover-community/mathlib"@"562bbf524c595c153470e53d36c57b6f891cc480"
/-!
# Subtraction of measures
In this file we define `μ - ν` to be the least measure `τ` such that `μ ≤ τ + ν`.
It is the equivalent of `(μ - ν) ⊔ 0` if `μ` and `ν` were signed measures.
Compare with `ENNReal.instSub`.
Specifically, note that if you have `α = {1,2}`, and `μ {1} = 2`, `μ {2} = 0`, and
`ν {2} = 2`, `ν {1} = 0`, then `(μ - ν) {1, 2} = 2`. However, if `μ ≤ ν`, and
`ν univ ≠ ∞`, then `(μ - ν) + ν = μ`.
-/
open Set
namespace MeasureTheory
namespace Measure
/-- The measure `μ - ν` is defined to be the least measure `τ` such that `μ ≤ τ + ν`.
It is the equivalent of `(μ - ν) ⊔ 0` if `μ` and `ν` were signed measures.
Compare with `ENNReal.instSub`.
Specifically, note that if you have `α = {1,2}`, and `μ {1} = 2`, `μ {2} = 0`, and
`ν {2} = 2`, `ν {1} = 0`, then `(μ - ν) {1, 2} = 2`. However, if `μ ≤ ν`, and
`ν univ ≠ ∞`, then `(μ - ν) + ν = μ`. -/
noncomputable instance instSub {α : Type*} [MeasurableSpace α] : Sub (Measure α) :=
⟨fun μ ν => sInf { τ | μ ≤ τ + ν }⟩
#align measure_theory.measure.has_sub MeasureTheory.Measure.instSub
variable {α : Type*} {m : MeasurableSpace α} {μ ν : Measure α} {s : Set α}
theorem sub_def : μ - ν = sInf { d | μ ≤ d + ν } := rfl
#align measure_theory.measure.sub_def MeasureTheory.Measure.sub_def
theorem sub_le_of_le_add {d} (h : μ ≤ d + ν) : μ - ν ≤ d :=
sInf_le h
#align measure_theory.measure.sub_le_of_le_add MeasureTheory.Measure.sub_le_of_le_add
theorem sub_eq_zero_of_le (h : μ ≤ ν) : μ - ν = 0 :=
nonpos_iff_eq_zero'.1 <| sub_le_of_le_add <| by rwa [zero_add]
#align measure_theory.measure.sub_eq_zero_of_le MeasureTheory.Measure.sub_eq_zero_of_le
theorem sub_le : μ - ν ≤ μ :=
sub_le_of_le_add <| Measure.le_add_right le_rfl
#align measure_theory.measure.sub_le MeasureTheory.Measure.sub_le
@[simp]
theorem sub_top : μ - ⊤ = 0 :=
sub_eq_zero_of_le le_top
#align measure_theory.measure.sub_top MeasureTheory.Measure.sub_top
@[simp]
theorem zero_sub : 0 - μ = 0 :=
sub_eq_zero_of_le μ.zero_le
#align measure_theory.measure.zero_sub MeasureTheory.Measure.zero_sub
@[simp]
theorem sub_self : μ - μ = 0 :=
sub_eq_zero_of_le le_rfl
#align measure_theory.measure.sub_self MeasureTheory.Measure.sub_self
/-- This application lemma only works in special circumstances. Given knowledge of
when `μ ≤ ν` and `ν ≤ μ`, a more general application lemma can be written. -/
| Mathlib/MeasureTheory/Measure/Sub.lean | 71 | 97 | theorem sub_apply [IsFiniteMeasure ν] (h₁ : MeasurableSet s) (h₂ : ν ≤ μ) :
(μ - ν) s = μ s - ν s := by |
-- We begin by defining `measure_sub`, which will be equal to `(μ - ν)`.
let measure_sub : Measure α := MeasureTheory.Measure.ofMeasurable
(fun (t : Set α) (_ : MeasurableSet t) => μ t - ν t) (by simp)
(fun g h_meas h_disj ↦ by
simp only [measure_iUnion h_disj h_meas]
rw [ENNReal.tsum_sub _ (h₂ <| g ·)]
rw [← measure_iUnion h_disj h_meas]
apply measure_ne_top)
-- Now, we demonstrate `μ - ν = measure_sub`, and apply it.
have h_measure_sub_add : ν + measure_sub = μ := by
ext1 t h_t_measurable_set
simp only [Pi.add_apply, coe_add]
rw [MeasureTheory.Measure.ofMeasurable_apply _ h_t_measurable_set, add_comm,
tsub_add_cancel_of_le (h₂ t)]
have h_measure_sub_eq : μ - ν = measure_sub := by
rw [MeasureTheory.Measure.sub_def]
apply le_antisymm
· apply sInf_le
simp [le_refl, add_comm, h_measure_sub_add]
apply le_sInf
intro d h_d
rw [← h_measure_sub_add, mem_setOf_eq, add_comm d] at h_d
apply Measure.le_of_add_le_add_left h_d
rw [h_measure_sub_eq]
apply Measure.ofMeasurable_apply _ 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, Mitchell Lee
-/
import Mathlib.Topology.Algebra.InfiniteSum.Defs
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Topology.Algebra.Monoid
/-!
# Lemmas on infinite sums and products in topological monoids
This file contains many simple lemmas on `tsum`, `HasSum` etc, which are placed here in order to
keep the basic file of definitions as short as possible.
Results requiring a group (rather than monoid) structure on the target should go in `Group.lean`.
-/
noncomputable section
open Filter Finset Function
open scoped Topology
variable {α β γ δ : Type*}
section HasProd
variable [CommMonoid α] [TopologicalSpace α]
variable {f g : β → α} {a b : α} {s : Finset β}
/-- Constant one function has product `1` -/
@[to_additive "Constant zero function has sum `0`"]
theorem hasProd_one : HasProd (fun _ ↦ 1 : β → α) 1 := by simp [HasProd, tendsto_const_nhds]
#align has_sum_zero hasSum_zero
@[to_additive]
| Mathlib/Topology/Algebra/InfiniteSum/Basic.lean | 39 | 40 | theorem hasProd_empty [IsEmpty β] : HasProd f 1 := by |
convert @hasProd_one α β _ _
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Bhavik Mehta, Stuart Presnell
-/
import Mathlib.Data.Nat.Factorial.Basic
import Mathlib.Order.Monotone.Basic
#align_import data.nat.choose.basic from "leanprover-community/mathlib"@"2f3994e1b117b1e1da49bcfb67334f33460c3ce4"
/-!
# Binomial coefficients
This file defines binomial coefficients and proves simple lemmas (i.e. those not
requiring more imports).
## Main definition and results
* `Nat.choose`: binomial coefficients, defined inductively
* `Nat.choose_eq_factorial_div_factorial`: a proof that `choose n k = n! / (k! * (n - k)!)`
* `Nat.choose_symm`: symmetry of binomial coefficients
* `Nat.choose_le_succ_of_lt_half_left`: `choose n k` is increasing for small values of `k`
* `Nat.choose_le_middle`: `choose n r` is maximised when `r` is `n/2`
* `Nat.descFactorial_eq_factorial_mul_choose`: Relates binomial coefficients to the descending
factorial. This is used to prove `Nat.choose_le_pow` and variants. We provide similar statements
for the ascending factorial.
* `Nat.multichoose`: whereas `choose` counts combinations, `multichoose` counts multicombinations.
The fact that this is indeed the correct counting function for multisets is proved in
`Sym.card_sym_eq_multichoose` in `Data.Sym.Card`.
* `Nat.multichoose_eq` : a proof that `multichoose n k = (n + k - 1).choose k`.
This is central to the "stars and bars" technique in informal mathematics, where we switch between
counting multisets of size `k` over an alphabet of size `n` to counting strings of `k` elements
("stars") separated by `n-1` dividers ("bars"). See `Data.Sym.Card` for more detail.
## Tags
binomial coefficient, combination, multicombination, stars and bars
-/
open Nat
namespace Nat
/-- `choose n k` is the number of `k`-element subsets in an `n`-element set. Also known as binomial
coefficients. -/
def choose : ℕ → ℕ → ℕ
| _, 0 => 1
| 0, _ + 1 => 0
| n + 1, k + 1 => choose n k + choose n (k + 1)
#align nat.choose Nat.choose
@[simp]
theorem choose_zero_right (n : ℕ) : choose n 0 = 1 := by cases n <;> rfl
#align nat.choose_zero_right Nat.choose_zero_right
@[simp]
theorem choose_zero_succ (k : ℕ) : choose 0 (succ k) = 0 :=
rfl
#align nat.choose_zero_succ Nat.choose_zero_succ
theorem choose_succ_succ (n k : ℕ) : choose (succ n) (succ k) = choose n k + choose n (succ k) :=
rfl
#align nat.choose_succ_succ Nat.choose_succ_succ
theorem choose_succ_succ' (n k : ℕ) : choose (n + 1) (k + 1) = choose n k + choose n (k + 1) :=
rfl
theorem choose_eq_zero_of_lt : ∀ {n k}, n < k → choose n k = 0
| _, 0, hk => absurd hk (Nat.not_lt_zero _)
| 0, k + 1, _ => choose_zero_succ _
| n + 1, k + 1, hk => by
have hnk : n < k := lt_of_succ_lt_succ hk
have hnk1 : n < k + 1 := lt_of_succ_lt hk
rw [choose_succ_succ, choose_eq_zero_of_lt hnk, choose_eq_zero_of_lt hnk1]
#align nat.choose_eq_zero_of_lt Nat.choose_eq_zero_of_lt
@[simp]
| Mathlib/Data/Nat/Choose/Basic.lean | 79 | 80 | theorem choose_self (n : ℕ) : choose n n = 1 := by |
induction n <;> simp [*, choose, choose_eq_zero_of_lt (lt_succ_self _)]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
import Mathlib.Algebra.Order.Archimedean
import Mathlib.Topology.Algebra.InfiniteSum.NatInt
import Mathlib.Topology.Algebra.Order.Field
import Mathlib.Topology.Order.MonotoneConvergence
#align_import topology.algebra.infinite_sum.order from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514"
/-!
# Infinite sum or product in an order
This file provides lemmas about the interaction of infinite sums and products and order operations.
-/
open Finset Filter Function
open scoped Classical
variable {ι κ α : Type*}
section Preorder
variable [Preorder α] [CommMonoid α] [TopologicalSpace α] [OrderClosedTopology α] [T2Space α]
{f : ℕ → α} {c : α}
@[to_additive]
theorem tprod_le_of_prod_range_le (hf : Multipliable f) (h : ∀ n, ∏ i ∈ range n, f i ≤ c) :
∏' n, f n ≤ c :=
let ⟨_l, hl⟩ := hf
hl.tprod_eq.symm ▸ le_of_tendsto' hl.tendsto_prod_nat h
#align tsum_le_of_sum_range_le tsum_le_of_sum_range_le
end Preorder
section OrderedCommMonoid
variable [OrderedCommMonoid α] [TopologicalSpace α] [OrderClosedTopology α] {f g : ι → α}
{a a₁ a₂ : α}
@[to_additive]
theorem hasProd_le (h : ∀ i, f i ≤ g i) (hf : HasProd f a₁) (hg : HasProd g a₂) : a₁ ≤ a₂ :=
le_of_tendsto_of_tendsto' hf hg fun _ ↦ prod_le_prod' fun i _ ↦ h i
#align has_sum_le hasSum_le
@[to_additive (attr := mono)]
theorem hasProd_mono (hf : HasProd f a₁) (hg : HasProd g a₂) (h : f ≤ g) : a₁ ≤ a₂ :=
hasProd_le h hf hg
#align has_sum_mono hasSum_mono
@[to_additive]
theorem hasProd_le_of_prod_le (hf : HasProd f a) (h : ∀ s, ∏ i ∈ s, f i ≤ a₂) : a ≤ a₂ :=
le_of_tendsto' hf h
#align has_sum_le_of_sum_le hasSum_le_of_sum_le
@[to_additive]
theorem le_hasProd_of_le_prod (hf : HasProd f a) (h : ∀ s, a₂ ≤ ∏ i ∈ s, f i) : a₂ ≤ a :=
ge_of_tendsto' hf h
#align le_has_sum_of_le_sum le_hasSum_of_le_sum
@[to_additive]
| Mathlib/Topology/Algebra/InfiniteSum/Order.lean | 65 | 74 | theorem hasProd_le_inj {g : κ → α} (e : ι → κ) (he : Injective e)
(hs : ∀ c, c ∉ Set.range e → 1 ≤ g c) (h : ∀ i, f i ≤ g (e i)) (hf : HasProd f a₁)
(hg : HasProd g a₂) : a₁ ≤ a₂ := by |
rw [← hasProd_extend_one he] at hf
refine hasProd_le (fun c ↦ ?_) hf hg
obtain ⟨i, rfl⟩ | h := em (c ∈ Set.range e)
· rw [he.extend_apply]
exact h _
· rw [extend_apply' _ _ _ h]
exact hs _ h
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
import Mathlib.Analysis.SpecialFunctions.Pow.Complex
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
| Mathlib/Analysis/SpecialFunctions/Trigonometric/Complex.lean | 32 | 40 | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by |
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine exists_congr fun x => ?_
refine (iff_of_eq <| congr_arg _ ?_).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
|
/-
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.OuterMeasure.Caratheodory
/-!
# Induced Outer Measure
We can extend a function defined on a subset of `Set α` to an outer measure.
The underlying function is called `extend`, and the measure it induces is called
`inducedOuterMeasure`.
Some lemmas below are proven twice, once in the general case, and one where the function `m`
is only defined on measurable sets (i.e. when `P = MeasurableSet`). In the latter cases, we can
remove some hypotheses in the statement. The general version has the same name, but with a prime
at the end.
## Tags
outer measure
-/
#align_import measure_theory.measure.outer_measure from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55"
noncomputable section
open Set Function Filter
open scoped Classical NNReal Topology ENNReal
namespace MeasureTheory
open OuterMeasure
section Extend
variable {α : Type*} {P : α → Prop}
variable (m : ∀ s : α, P s → ℝ≥0∞)
/-- We can trivially extend a function defined on a subclass of objects (with codomain `ℝ≥0∞`)
to all objects by defining it to be `∞` on the objects not in the class. -/
def extend (s : α) : ℝ≥0∞ :=
⨅ h : P s, m s h
#align measure_theory.extend MeasureTheory.extend
theorem extend_eq {s : α} (h : P s) : extend m s = m s h := by simp [extend, h]
#align measure_theory.extend_eq MeasureTheory.extend_eq
theorem extend_eq_top {s : α} (h : ¬P s) : extend m s = ∞ := by simp [extend, h]
#align measure_theory.extend_eq_top MeasureTheory.extend_eq_top
theorem smul_extend {R} [Zero R] [SMulWithZero R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
[NoZeroSMulDivisors R ℝ≥0∞] {c : R} (hc : c ≠ 0) :
c • extend m = extend fun s h => c • m s h := by
ext1 s
dsimp [extend]
by_cases h : P s
· simp [h]
· simp [h, ENNReal.smul_top, hc]
#align measure_theory.smul_extend MeasureTheory.smul_extend
theorem le_extend {s : α} (h : P s) : m s h ≤ extend m s := by
simp only [extend, le_iInf_iff]
intro
rfl
#align measure_theory.le_extend MeasureTheory.le_extend
-- TODO: why this is a bad `congr` lemma?
theorem extend_congr {β : Type*} {Pb : β → Prop} {mb : ∀ s : β, Pb s → ℝ≥0∞} {sa : α} {sb : β}
(hP : P sa ↔ Pb sb) (hm : ∀ (ha : P sa) (hb : Pb sb), m sa ha = mb sb hb) :
extend m sa = extend mb sb :=
iInf_congr_Prop hP fun _h => hm _ _
#align measure_theory.extend_congr MeasureTheory.extend_congr
@[simp]
theorem extend_top {α : Type*} {P : α → Prop} : extend (fun _ _ => ∞ : ∀ s : α, P s → ℝ≥0∞) = ⊤ :=
funext fun _ => iInf_eq_top.mpr fun _ => rfl
#align measure_theory.extend_top MeasureTheory.extend_top
end Extend
section ExtendSet
variable {α : Type*} {P : Set α → Prop}
variable {m : ∀ s : Set α, P s → ℝ≥0∞}
variable (P0 : P ∅) (m0 : m ∅ P0 = 0)
variable (PU : ∀ ⦃f : ℕ → Set α⦄ (_hm : ∀ i, P (f i)), P (⋃ i, f i))
variable
(mU :
∀ ⦃f : ℕ → Set α⦄ (hm : ∀ i, P (f i)),
Pairwise (Disjoint on f) → m (⋃ i, f i) (PU hm) = ∑' i, m (f i) (hm i))
variable (msU : ∀ ⦃f : ℕ → Set α⦄ (hm : ∀ i, P (f i)), m (⋃ i, f i) (PU hm) ≤ ∑' i, m (f i) (hm i))
variable (m_mono : ∀ ⦃s₁ s₂ : Set α⦄ (hs₁ : P s₁) (hs₂ : P s₂), s₁ ⊆ s₂ → m s₁ hs₁ ≤ m s₂ hs₂)
theorem extend_empty : extend m ∅ = 0 :=
(extend_eq _ P0).trans m0
#align measure_theory.extend_empty MeasureTheory.extend_empty
theorem extend_iUnion_nat {f : ℕ → Set α} (hm : ∀ i, P (f i))
(mU : m (⋃ i, f i) (PU hm) = ∑' i, m (f i) (hm i)) :
extend m (⋃ i, f i) = ∑' i, extend m (f i) :=
(extend_eq _ _).trans <|
mU.trans <| by
congr with i
rw [extend_eq]
#align measure_theory.extend_Union_nat MeasureTheory.extend_iUnion_nat
section Subadditive
| Mathlib/MeasureTheory/OuterMeasure/Induced.lean | 114 | 122 | theorem extend_iUnion_le_tsum_nat' (s : ℕ → Set α) :
extend m (⋃ i, s i) ≤ ∑' i, extend m (s i) := by |
by_cases h : ∀ i, P (s i)
· rw [extend_eq _ (PU h), congr_arg tsum _]
· apply msU h
funext i
apply extend_eq _ (h i)
· cases' not_forall.1 h with i hi
exact le_trans (le_iInf fun h => hi.elim h) (ENNReal.le_tsum i)
|
/-
Copyright (c) 2020 Bryan Gin-ge Chen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bryan Gin-ge Chen, Kevin Lacker
-/
import Mathlib.Tactic.Ring
#align_import algebra.group_power.identities from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Identities
This file contains some "named" commutative ring identities.
-/
variable {R : Type*} [CommRing R] {a b x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ y₁ y₂ y₃ y₄ y₅ y₆ y₇ y₈ n : R}
/-- Brahmagupta-Fibonacci identity or Diophantus identity, see
<https://en.wikipedia.org/wiki/Brahmagupta%E2%80%93Fibonacci_identity>.
This sign choice here corresponds to the signs obtained by multiplying two complex numbers.
-/
theorem sq_add_sq_mul_sq_add_sq :
(x₁ ^ 2 + x₂ ^ 2) * (y₁ ^ 2 + y₂ ^ 2) = (x₁ * y₁ - x₂ * y₂) ^ 2 + (x₁ * y₂ + x₂ * y₁) ^ 2 := by
ring
#align sq_add_sq_mul_sq_add_sq sq_add_sq_mul_sq_add_sq
/-- Brahmagupta's identity, see <https://en.wikipedia.org/wiki/Brahmagupta%27s_identity>
-/
theorem sq_add_mul_sq_mul_sq_add_mul_sq :
(x₁ ^ 2 + n * x₂ ^ 2) * (y₁ ^ 2 + n * y₂ ^ 2) =
(x₁ * y₁ - n * x₂ * y₂) ^ 2 + n * (x₁ * y₂ + x₂ * y₁) ^ 2 := by
ring
#align sq_add_mul_sq_mul_sq_add_mul_sq sq_add_mul_sq_mul_sq_add_mul_sq
/-- Sophie Germain's identity, see <https://www.cut-the-knot.org/blue/SophieGermainIdentity.shtml>.
-/
theorem pow_four_add_four_mul_pow_four :
a ^ 4 + 4 * b ^ 4 = ((a - b) ^ 2 + b ^ 2) * ((a + b) ^ 2 + b ^ 2) := by
ring
#align pow_four_add_four_mul_pow_four pow_four_add_four_mul_pow_four
/-- Sophie Germain's identity, see <https://www.cut-the-knot.org/blue/SophieGermainIdentity.shtml>.
-/
theorem pow_four_add_four_mul_pow_four' :
a ^ 4 + 4 * b ^ 4 = (a ^ 2 - 2 * a * b + 2 * b ^ 2) * (a ^ 2 + 2 * a * b + 2 * b ^ 2) := by
ring
#align pow_four_add_four_mul_pow_four' pow_four_add_four_mul_pow_four'
/-- Euler's four-square identity, see <https://en.wikipedia.org/wiki/Euler%27s_four-square_identity>.
This sign choice here corresponds to the signs obtained by multiplying two quaternions.
-/
theorem sum_four_sq_mul_sum_four_sq :
(x₁ ^ 2 + x₂ ^ 2 + x₃ ^ 2 + x₄ ^ 2) * (y₁ ^ 2 + y₂ ^ 2 + y₃ ^ 2 + y₄ ^ 2) =
(x₁ * y₁ - x₂ * y₂ - x₃ * y₃ - x₄ * y₄) ^ 2 + (x₁ * y₂ + x₂ * y₁ + x₃ * y₄ - x₄ * y₃) ^ 2 +
(x₁ * y₃ - x₂ * y₄ + x₃ * y₁ + x₄ * y₂) ^ 2 +
(x₁ * y₄ + x₂ * y₃ - x₃ * y₂ + x₄ * y₁) ^ 2 := by
ring
#align sum_four_sq_mul_sum_four_sq sum_four_sq_mul_sum_four_sq
/-- Degen's eight squares identity, see <https://en.wikipedia.org/wiki/Degen%27s_eight-square_identity>.
This sign choice here corresponds to the signs obtained by multiplying two octonions.
-/
| Mathlib/Algebra/Ring/Identities.lean | 67 | 78 | theorem sum_eight_sq_mul_sum_eight_sq :
(x₁ ^ 2 + x₂ ^ 2 + x₃ ^ 2 + x₄ ^ 2 + x₅ ^ 2 + x₆ ^ 2 + x₇ ^ 2 + x₈ ^ 2) *
(y₁ ^ 2 + y₂ ^ 2 + y₃ ^ 2 + y₄ ^ 2 + y₅ ^ 2 + y₆ ^ 2 + y₇ ^ 2 + y₈ ^ 2) =
(x₁ * y₁ - x₂ * y₂ - x₃ * y₃ - x₄ * y₄ - x₅ * y₅ - x₆ * y₆ - x₇ * y₇ - x₈ * y₈) ^ 2 +
(x₁ * y₂ + x₂ * y₁ + x₃ * y₄ - x₄ * y₃ + x₅ * y₆ - x₆ * y₅ - x₇ * y₈ + x₈ * y₇) ^ 2 +
(x₁ * y₃ - x₂ * y₄ + x₃ * y₁ + x₄ * y₂ + x₅ * y₇ + x₆ * y₈ - x₇ * y₅ - x₈ * y₆) ^ 2 +
(x₁ * y₄ + x₂ * y₃ - x₃ * y₂ + x₄ * y₁ + x₅ * y₈ - x₆ * y₇ + x₇ * y₆ - x₈ * y₅) ^ 2 +
(x₁ * y₅ - x₂ * y₆ - x₃ * y₇ - x₄ * y₈ + x₅ * y₁ + x₆ * y₂ + x₇ * y₃ + x₈ * y₄) ^ 2 +
(x₁ * y₆ + x₂ * y₅ - x₃ * y₈ + x₄ * y₇ - x₅ * y₂ + x₆ * y₁ - x₇ * y₄ + x₈ * y₃) ^ 2 +
(x₁ * y₇ + x₂ * y₈ + x₃ * y₅ - x₄ * y₆ - x₅ * y₃ + x₆ * y₄ + x₇ * y₁ - x₈ * y₂) ^ 2 +
(x₁ * y₈ - x₂ * y₇ + x₃ * y₆ + x₄ * y₅ - x₅ * y₄ - x₆ * y₃ + x₇ * y₂ + x₈ * y₁) ^ 2 := by |
ring
|
/-
Copyright (c) 2021 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import Mathlib.RingTheory.JacobsonIdeal
#align_import ring_theory.nakayama from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
/-!
# Nakayama's lemma
This file contains some alternative statements of Nakayama's Lemma as found in
[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV).
## Main statements
* `Submodule.eq_smul_of_le_smul_of_le_jacobson` - A version of (2) in
[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV).,
generalising to the Jacobson of any ideal.
* `Submodule.eq_bot_of_le_smul_of_le_jacobson_bot` - Statement (2) in
[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV).
* `Submodule.sup_smul_eq_sup_smul_of_le_smul_of_le_jacobson` - A version of (4) in
[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV).,
generalising to the Jacobson of any ideal.
* `Submodule.smul_le_of_le_smul_of_le_jacobson_bot` - Statement (4) in
[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV).
Note that a version of Statement (1) in
[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV) can be found in
`RingTheory.Finiteness` under the name
`Submodule.exists_sub_one_mem_and_smul_eq_zero_of_fg_of_le_smul`
## References
* [Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV)
## Tags
Nakayama, Jacobson
-/
variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M]
open Ideal
namespace Submodule
/-- **Nakayama's Lemma** - A slightly more general version of (2) in
[Stacks 00DV](https://stacks.math.columbia.edu/tag/00DV).
See also `eq_bot_of_le_smul_of_le_jacobson_bot` for the special case when `J = ⊥`. -/
| Mathlib/RingTheory/Nakayama.lean | 52 | 61 | theorem eq_smul_of_le_smul_of_le_jacobson {I J : Ideal R} {N : Submodule R M} (hN : N.FG)
(hIN : N ≤ I • N) (hIjac : I ≤ jacobson J) : N = J • N := by |
refine le_antisymm ?_ (Submodule.smul_le.2 fun _ _ _ => Submodule.smul_mem _ _)
intro n hn
cases' Submodule.exists_sub_one_mem_and_smul_eq_zero_of_fg_of_le_smul I N hN hIN with r hr
cases' exists_mul_sub_mem_of_sub_one_mem_jacobson r (hIjac hr.1) with s hs
have : n = -(s * r - 1) • n := by
rw [neg_sub, sub_smul, mul_smul, hr.2 n hn, one_smul, smul_zero, sub_zero]
rw [this]
exact Submodule.smul_mem_smul (Submodule.neg_mem _ hs) hn
|
/-
Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen
-/
import Mathlib.FieldTheory.Minpoly.Field
#align_import ring_theory.power_basis from "leanprover-community/mathlib"@"d1d69e99ed34c95266668af4e288fc1c598b9a7f"
/-!
# Power basis
This file defines a structure `PowerBasis R S`, giving a basis of the
`R`-algebra `S` as a finite list of powers `1, x, ..., x^n`.
For example, if `x` is algebraic over a ring/field, adjoining `x`
gives a `PowerBasis` structure generated by `x`.
## Definitions
* `PowerBasis R A`: a structure containing an `x` and an `n` such that
`1, x, ..., x^n` is a basis for the `R`-algebra `A` (viewed as an `R`-module).
* `finrank (hf : f ≠ 0) : FiniteDimensional.finrank K (AdjoinRoot f) = f.natDegree`,
the dimension of `AdjoinRoot f` equals the degree of `f`
* `PowerBasis.lift (pb : PowerBasis R S)`: if `y : S'` satisfies the same
equations as `pb.gen`, this is the map `S →ₐ[R] S'` sending `pb.gen` to `y`
* `PowerBasis.equiv`: if two power bases satisfy the same equations, they are
equivalent as algebras
## Implementation notes
Throughout this file, `R`, `S`, `A`, `B` ... are `CommRing`s, and `K`, `L`, ... are `Field`s.
`S` is an `R`-algebra, `B` is an `A`-algebra, `L` is a `K`-algebra.
## Tags
power basis, powerbasis
-/
open Polynomial
open Polynomial
variable {R S T : Type*} [CommRing R] [Ring S] [Algebra R S]
variable {A B : Type*} [CommRing A] [CommRing B] [IsDomain B] [Algebra A B]
variable {K : Type*} [Field K]
/-- `pb : PowerBasis R S` states that `1, pb.gen, ..., pb.gen ^ (pb.dim - 1)`
is a basis for the `R`-algebra `S` (viewed as `R`-module).
This is a structure, not a class, since the same algebra can have many power bases.
For the common case where `S` is defined by adjoining an integral element to `R`,
the canonical power basis is given by `{Algebra,IntermediateField}.adjoin.powerBasis`.
-/
-- Porting note(#5171): this linter isn't ported yet.
-- @[nolint has_nonempty_instance]
structure PowerBasis (R S : Type*) [CommRing R] [Ring S] [Algebra R S] where
gen : S
dim : ℕ
basis : Basis (Fin dim) R S
basis_eq_pow : ∀ (i), basis i = gen ^ (i : ℕ)
#align power_basis PowerBasis
-- this is usually not needed because of `basis_eq_pow` but can be needed in some cases;
-- in such circumstances, add it manually using `@[simps dim gen basis]`.
initialize_simps_projections PowerBasis (-basis)
namespace PowerBasis
@[simp]
theorem coe_basis (pb : PowerBasis R S) : ⇑pb.basis = fun i : Fin pb.dim => pb.gen ^ (i : ℕ) :=
funext pb.basis_eq_pow
#align power_basis.coe_basis PowerBasis.coe_basis
/-- Cannot be an instance because `PowerBasis` cannot be a class. -/
theorem finite (pb : PowerBasis R S) : Module.Finite R S := .of_basis pb.basis
#align power_basis.finite_dimensional PowerBasis.finite
@[deprecated] alias finiteDimensional := PowerBasis.finite
| Mathlib/RingTheory/PowerBasis.lean | 84 | 86 | theorem finrank [StrongRankCondition R] (pb : PowerBasis R S) :
FiniteDimensional.finrank R S = pb.dim := by |
rw [FiniteDimensional.finrank_eq_card_basis pb.basis, Fintype.card_fin]
|
/-
Copyright (c) 2022 Antoine Labelle, Rémi Bottinelli. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Antoine Labelle, Rémi Bottinelli
-/
import Mathlib.Combinatorics.Quiver.Cast
import Mathlib.Combinatorics.Quiver.Symmetric
import Mathlib.Data.Sigma.Basic
import Mathlib.Logic.Equiv.Basic
import Mathlib.Tactic.Common
#align_import combinatorics.quiver.covering from "leanprover-community/mathlib"@"188a411e916e1119e502dbe35b8b475716362401"
/-!
# Covering
This file defines coverings of quivers as prefunctors that are bijective on the
so-called stars and costars at each vertex of the domain.
## Main definitions
* `Quiver.Star u` is the type of all arrows with source `u`;
* `Quiver.Costar u` is the type of all arrows with target `u`;
* `Prefunctor.star φ u` is the obvious function `star u → star (φ.obj u)`;
* `Prefunctor.costar φ u` is the obvious function `costar u → costar (φ.obj u)`;
* `Prefunctor.IsCovering φ` means that `φ.star u` and `φ.costar u` are bijections for all `u`;
* `Quiver.PathStar u` is the type of all paths with source `u`;
* `Prefunctor.pathStar u` is the obvious function `PathStar u → PathStar (φ.obj u)`.
## Main statements
* `Prefunctor.IsCovering.pathStar_bijective` states that if `φ` is a covering,
then `φ.pathStar u` is a bijection for all `u`.
In other words, every path in the codomain of `φ` lifts uniquely to its domain.
## TODO
Clean up the namespaces by renaming `Prefunctor` to `Quiver.Prefunctor`.
## Tags
Cover, covering, quiver, path, lift
-/
open Function Quiver
universe u v w
variable {U : Type _} [Quiver.{u + 1} U] {V : Type _} [Quiver.{v + 1} V] (φ : U ⥤q V) {W : Type _}
[Quiver.{w + 1} W] (ψ : V ⥤q W)
/-- The `Quiver.Star` at a vertex is the collection of arrows whose source is the vertex.
The type `Quiver.Star u` is defined to be `Σ (v : U), (u ⟶ v)`. -/
abbrev Quiver.Star (u : U) :=
Σ v : U, u ⟶ v
#align quiver.star Quiver.Star
/-- Constructor for `Quiver.Star`. Defined to be `Sigma.mk`. -/
protected abbrev Quiver.Star.mk {u v : U} (f : u ⟶ v) : Quiver.Star u :=
⟨_, f⟩
#align quiver.star.mk Quiver.Star.mk
/-- The `Quiver.Costar` at a vertex is the collection of arrows whose target is the vertex.
The type `Quiver.Costar v` is defined to be `Σ (u : U), (u ⟶ v)`. -/
abbrev Quiver.Costar (v : U) :=
Σ u : U, u ⟶ v
#align quiver.costar Quiver.Costar
/-- Constructor for `Quiver.Costar`. Defined to be `Sigma.mk`. -/
protected abbrev Quiver.Costar.mk {u v : U} (f : u ⟶ v) : Quiver.Costar v :=
⟨_, f⟩
#align quiver.costar.mk Quiver.Costar.mk
/-- A prefunctor induces a map of `Quiver.Star` at every vertex. -/
@[simps]
def Prefunctor.star (u : U) : Quiver.Star u → Quiver.Star (φ.obj u) := fun F =>
Quiver.Star.mk (φ.map F.2)
#align prefunctor.star Prefunctor.star
/-- A prefunctor induces a map of `Quiver.Costar` at every vertex. -/
@[simps]
def Prefunctor.costar (u : U) : Quiver.Costar u → Quiver.Costar (φ.obj u) := fun F =>
Quiver.Costar.mk (φ.map F.2)
#align prefunctor.costar Prefunctor.costar
@[simp]
theorem Prefunctor.star_apply {u v : U} (e : u ⟶ v) :
φ.star u (Quiver.Star.mk e) = Quiver.Star.mk (φ.map e) :=
rfl
#align prefunctor.star_apply Prefunctor.star_apply
@[simp]
theorem Prefunctor.costar_apply {u v : U} (e : u ⟶ v) :
φ.costar v (Quiver.Costar.mk e) = Quiver.Costar.mk (φ.map e) :=
rfl
#align prefunctor.costar_apply Prefunctor.costar_apply
theorem Prefunctor.star_comp (u : U) : (φ ⋙q ψ).star u = ψ.star (φ.obj u) ∘ φ.star u :=
rfl
#align prefunctor.star_comp Prefunctor.star_comp
theorem Prefunctor.costar_comp (u : U) : (φ ⋙q ψ).costar u = ψ.costar (φ.obj u) ∘ φ.costar u :=
rfl
#align prefunctor.costar_comp Prefunctor.costar_comp
/-- A prefunctor is a covering of quivers if it defines bijections on all stars and costars. -/
protected structure Prefunctor.IsCovering : Prop where
star_bijective : ∀ u, Bijective (φ.star u)
costar_bijective : ∀ u, Bijective (φ.costar u)
#align prefunctor.is_covering Prefunctor.IsCovering
@[simp]
| Mathlib/Combinatorics/Quiver/Covering.lean | 114 | 118 | theorem Prefunctor.IsCovering.map_injective (hφ : φ.IsCovering) {u v : U} :
Injective fun f : u ⟶ v => φ.map f := by |
rintro f g he
have : φ.star u (Quiver.Star.mk f) = φ.star u (Quiver.Star.mk g) := by simpa using he
simpa using (hφ.star_bijective u).left this
|
/-
Copyright (c) 2021 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Batteries.Data.UnionFind.Basic
namespace Batteries.UnionFind
@[simp] theorem arr_empty : empty.arr = #[] := rfl
@[simp] theorem parent_empty : empty.parent a = a := rfl
@[simp] theorem rank_empty : empty.rank a = 0 := rfl
@[simp] theorem rootD_empty : empty.rootD a = a := rfl
@[simp] theorem arr_push {m : UnionFind} : m.push.arr = m.arr.push ⟨m.arr.size, 0⟩ := rfl
@[simp] theorem parentD_push {arr : Array UFNode} :
parentD (arr.push ⟨arr.size, 0⟩) a = parentD arr a := by
simp [parentD]; split <;> split <;> try simp [Array.get_push, *]
· next h1 h2 =>
simp [Nat.lt_succ] at h1 h2
exact Nat.le_antisymm h2 h1
· next h1 h2 => cases h1 (Nat.lt_succ_of_lt h2)
@[simp] theorem parent_push {m : UnionFind} : m.push.parent a = m.parent a := by simp [parent]
@[simp] theorem rankD_push {arr : Array UFNode} :
rankD (arr.push ⟨arr.size, 0⟩) a = rankD arr a := by
simp [rankD]; split <;> split <;> try simp [Array.get_push, *]
next h1 h2 => cases h1 (Nat.lt_succ_of_lt h2)
@[simp] theorem rank_push {m : UnionFind} : m.push.rank a = m.rank a := by simp [rank]
@[simp] theorem rankMax_push {m : UnionFind} : m.push.rankMax = m.rankMax := by simp [rankMax]
@[simp] theorem root_push {self : UnionFind} : self.push.rootD x = self.rootD x :=
rootD_ext fun _ => parent_push
@[simp] theorem arr_link : (link self x y yroot).arr = linkAux self.arr x y := rfl
| .lake/packages/batteries/Batteries/Data/UnionFind/Lemmas.lean | 41 | 51 | theorem parentD_linkAux {self} {x y : Fin self.size} :
parentD (linkAux self x y) i =
if x.1 = y then
parentD self i
else
if (self.get y).rank < (self.get x).rank then
if y = i then x else parentD self i
else
if x = i then y else parentD self i := by |
dsimp only [linkAux]; split <;> [rfl; split] <;> [rw [parentD_set]; split] <;> rw [parentD_set]
split <;> [(subst i; rwa [if_neg, parentD_eq]); rw [parentD_set]]
|
/-
Copyright (c) 2022 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.Algebra.Module.Submodule.Ker
#align_import linear_algebra.basic from "leanprover-community/mathlib"@"9d684a893c52e1d6692a504a118bfccbae04feeb"
/-!
# The submodule of elements `x : M` such that `f x = g x`
## Main declarations
* `LinearMap.eqLocus`: the submodule of elements `x : M` such that `f x = g x`
## Tags
linear algebra, vector space, module
-/
variable {R : Type*} {R₂ : Type*}
variable {M : Type*} {M₂ : Type*}
/-! ### Properties of linear maps -/
namespace LinearMap
section AddCommMonoid
variable [Semiring R] [Semiring R₂]
variable [AddCommMonoid M] [AddCommMonoid M₂]
variable [Module R M] [Module R₂ M₂]
open Submodule
variable {τ₁₂ : R →+* R₂}
section
variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F τ₁₂ M M₂]
/-- A linear map version of `AddMonoidHom.eqLocusM` -/
def eqLocus (f g : F) : Submodule R M :=
{ (f : M →+ M₂).eqLocusM g with
carrier := { x | f x = g x }
smul_mem' := fun {r} {x} (hx : _ = _) => show _ = _ by
-- Note: #8386 changed `map_smulₛₗ` into `map_smulₛₗ _`
simpa only [map_smulₛₗ _] using congr_arg (τ₁₂ r • ·) hx }
#align linear_map.eq_locus LinearMap.eqLocus
@[simp]
theorem mem_eqLocus {x : M} {f g : F} : x ∈ eqLocus f g ↔ f x = g x :=
Iff.rfl
#align linear_map.mem_eq_locus LinearMap.mem_eqLocus
theorem eqLocus_toAddSubmonoid (f g : F) :
(eqLocus f g).toAddSubmonoid = (f : M →+ M₂).eqLocusM g :=
rfl
#align linear_map.eq_locus_to_add_submonoid LinearMap.eqLocus_toAddSubmonoid
@[simp]
| Mathlib/Algebra/Module/Submodule/EqLocus.lean | 64 | 65 | theorem eqLocus_eq_top {f g : F} : eqLocus f g = ⊤ ↔ f = g := by |
simp [SetLike.ext_iff, DFunLike.ext_iff]
|
/-
Copyright (c) 2023 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.Analysis.Quaternion
import Mathlib.Analysis.NormedSpace.Exponential
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Series
#align_import analysis.normed_space.quaternion_exponential from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
/-!
# Lemmas about `NormedSpace.exp` on `Quaternion`s
This file contains results about `NormedSpace.exp` on `Quaternion ℝ`.
## Main results
* `Quaternion.exp_eq`: the general expansion of the quaternion exponential in terms of `Real.cos`
and `Real.sin`.
* `Quaternion.exp_of_re_eq_zero`: the special case when the quaternion has a zero real part.
* `Quaternion.norm_exp`: the norm of the quaternion exponential is the norm of the exponential of
the real part.
-/
open scoped Quaternion Nat
open NormedSpace
namespace Quaternion
@[simp, norm_cast]
theorem exp_coe (r : ℝ) : exp ℝ (r : ℍ[ℝ]) = ↑(exp ℝ r) :=
(map_exp ℝ (algebraMap ℝ ℍ[ℝ]) (continuous_algebraMap _ _) _).symm
#align quaternion.exp_coe Quaternion.exp_coe
/-- The even terms of `expSeries` are real, and correspond to the series for $\cos ‖q‖$. -/
| Mathlib/Analysis/NormedSpace/QuaternionExponential.lean | 39 | 55 | theorem expSeries_even_of_imaginary {q : Quaternion ℝ} (hq : q.re = 0) (n : ℕ) :
expSeries ℝ (Quaternion ℝ) (2 * n) (fun _ => q) =
↑((-1 : ℝ) ^ n * ‖q‖ ^ (2 * n) / (2 * n)!) := by |
rw [expSeries_apply_eq]
have hq2 : q ^ 2 = -normSq q := sq_eq_neg_normSq.mpr hq
letI k : ℝ := ↑(2 * n)!
calc
k⁻¹ • q ^ (2 * n) = k⁻¹ • (-normSq q) ^ n := by rw [pow_mul, hq2]
_ = k⁻¹ • ↑((-1 : ℝ) ^ n * ‖q‖ ^ (2 * n)) := ?_
_ = ↑((-1 : ℝ) ^ n * ‖q‖ ^ (2 * n) / k) := ?_
· congr 1
rw [neg_pow, normSq_eq_norm_mul_self, pow_mul, sq]
push_cast
rfl
· rw [← coe_mul_eq_smul, div_eq_mul_inv]
norm_cast
ring_nf
|
/-
Copyright (c) 2021 Kalle Kytölä. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kalle Kytölä
-/
import Mathlib.Analysis.RCLike.Basic
import Mathlib.Analysis.NormedSpace.OperatorNorm.Basic
import Mathlib.Analysis.NormedSpace.Pointwise
#align_import analysis.normed_space.is_R_or_C from "leanprover-community/mathlib"@"3f655f5297b030a87d641ad4e825af8d9679eb0b"
/-!
# Normed spaces over R or C
This file is about results on normed spaces over the fields `ℝ` and `ℂ`.
## Main definitions
None.
## Main theorems
* `ContinuousLinearMap.opNorm_bound_of_ball_bound`: A bound on the norms of values of a linear
map in a ball yields a bound on the operator norm.
## Notes
This file exists mainly to avoid importing `RCLike` in the main normed space theory files.
-/
open Metric
variable {𝕜 : Type*} [RCLike 𝕜] {E : Type*} [NormedAddCommGroup E]
theorem RCLike.norm_coe_norm {z : E} : ‖(‖z‖ : 𝕜)‖ = ‖z‖ := by simp
#align is_R_or_C.norm_coe_norm RCLike.norm_coe_norm
variable [NormedSpace 𝕜 E]
/-- Lemma to normalize a vector in a normed space `E` over either `ℂ` or `ℝ` to unit length. -/
@[simp]
| Mathlib/Analysis/NormedSpace/RCLike.lean | 43 | 45 | theorem norm_smul_inv_norm {x : E} (hx : x ≠ 0) : ‖(‖x‖⁻¹ : 𝕜) • x‖ = 1 := by |
have : ‖x‖ ≠ 0 := by simp [hx]
field_simp [norm_smul]
|
/-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Geometry.RingedSpace.PresheafedSpace
import Mathlib.Topology.Category.TopCat.Limits.Basic
import Mathlib.Topology.Sheaves.Limits
import Mathlib.CategoryTheory.ConcreteCategory.Elementwise
#align_import algebraic_geometry.presheafed_space.has_colimits from "leanprover-community/mathlib"@"178a32653e369dce2da68dc6b2694e385d484ef1"
/-!
# `PresheafedSpace C` has colimits.
If `C` has limits, then the category `PresheafedSpace C` has colimits,
and the forgetful functor to `TopCat` preserves these colimits.
When restricted to a diagram where the underlying continuous maps are open embeddings,
this says that we can glue presheaved spaces.
Given a diagram `F : J ⥤ PresheafedSpace C`,
we first build the colimit of the underlying topological spaces,
as `colimit (F ⋙ PresheafedSpace.forget C)`. Call that colimit space `X`.
Our strategy is to push each of the presheaves `F.obj j`
forward along the continuous map `colimit.ι (F ⋙ PresheafedSpace.forget C) j` to `X`.
Since pushforward is functorial, we obtain a diagram `J ⥤ (presheaf C X)ᵒᵖ`
of presheaves on a single space `X`.
(Note that the arrows now point the other direction,
because this is the way `PresheafedSpace C` is set up.)
The limit of this diagram then constitutes the colimit presheaf.
-/
noncomputable section
universe v' u' v u
open CategoryTheory Opposite CategoryTheory.Category CategoryTheory.Functor CategoryTheory.Limits
TopCat TopCat.Presheaf TopologicalSpace
variable {J : Type u'} [Category.{v'} J] {C : Type u} [Category.{v} C]
namespace AlgebraicGeometry
namespace PresheafedSpace
attribute [local simp] eqToHom_map
-- Porting note: we used to have:
-- local attribute [tidy] tactic.auto_cases_opens
-- We would replace this by:
-- attribute [local aesop safe cases (rule_sets := [CategoryTheory])] Opens
-- although it doesn't appear to help in this file, in any case.
@[simp]
| Mathlib/Geometry/RingedSpace/PresheafedSpace/HasColimits.lean | 59 | 65 | theorem map_id_c_app (F : J ⥤ PresheafedSpace.{_, _, v} C) (j) (U) :
(F.map (𝟙 j)).c.app (op U) =
(Pushforward.id (F.obj j).presheaf).inv.app (op U) ≫
(pushforwardEq (by simp) (F.obj j).presheaf).hom.app
(op U) := by |
cases U
simp [PresheafedSpace.congr_app (F.map_id j)]
|
/-
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Mario Carneiro
-/
import Mathlib.Algebra.Group.Prod
import Mathlib.Data.Set.Lattice
#align_import data.nat.pairing from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432"
/-!
# Naturals pairing function
This file defines a pairing function for the naturals as follows:
```text
0 1 4 9 16
2 3 5 10 17
6 7 8 11 18
12 13 14 15 19
20 21 22 23 24
```
It has the advantage of being monotone in both directions and sending `⟦0, n^2 - 1⟧` to
`⟦0, n - 1⟧²`.
-/
assert_not_exists MonoidWithZero
open Prod Decidable Function
namespace Nat
/-- Pairing function for the natural numbers. -/
-- Porting note: no pp_nodot
--@[pp_nodot]
def pair (a b : ℕ) : ℕ :=
if a < b then b * b + a else a * a + a + b
#align nat.mkpair Nat.pair
/-- Unpairing function for the natural numbers. -/
-- Porting note: no pp_nodot
--@[pp_nodot]
def unpair (n : ℕ) : ℕ × ℕ :=
let s := sqrt n
if n - s * s < s then (n - s * s, s) else (s, n - s * s - s)
#align nat.unpair Nat.unpair
@[simp]
theorem pair_unpair (n : ℕ) : pair (unpair n).1 (unpair n).2 = n := by
dsimp only [unpair]; let s := sqrt n
have sm : s * s + (n - s * s) = n := Nat.add_sub_cancel' (sqrt_le _)
split_ifs with h
· simp [pair, h, sm]
· have hl : n - s * s - s ≤ s := Nat.sub_le_iff_le_add.2
(Nat.sub_le_iff_le_add'.2 <| by rw [← Nat.add_assoc]; apply sqrt_le_add)
simp [pair, hl.not_lt, Nat.add_assoc, Nat.add_sub_cancel' (le_of_not_gt h), sm]
#align nat.mkpair_unpair Nat.pair_unpair
theorem pair_unpair' {n a b} (H : unpair n = (a, b)) : pair a b = n := by
simpa [H] using pair_unpair n
#align nat.mkpair_unpair' Nat.pair_unpair'
@[simp]
theorem unpair_pair (a b : ℕ) : unpair (pair a b) = (a, b) := by
dsimp only [pair]; split_ifs with h
· show unpair (b * b + a) = (a, b)
have be : sqrt (b * b + a) = b := sqrt_add_eq _ (le_trans (le_of_lt h) (Nat.le_add_left _ _))
simp [unpair, be, Nat.add_sub_cancel_left, h]
· show unpair (a * a + a + b) = (a, b)
have ae : sqrt (a * a + (a + b)) = a := by
rw [sqrt_add_eq]
exact Nat.add_le_add_left (le_of_not_gt h) _
simp [unpair, ae, Nat.not_lt_zero, Nat.add_assoc, Nat.add_sub_cancel_left]
#align nat.unpair_mkpair Nat.unpair_pair
/-- An equivalence between `ℕ × ℕ` and `ℕ`. -/
@[simps (config := .asFn)]
def pairEquiv : ℕ × ℕ ≃ ℕ :=
⟨uncurry pair, unpair, fun ⟨a, b⟩ => unpair_pair a b, pair_unpair⟩
#align nat.mkpair_equiv Nat.pairEquiv
#align nat.mkpair_equiv_apply Nat.pairEquiv_apply
#align nat.mkpair_equiv_symm_apply Nat.pairEquiv_symm_apply
theorem surjective_unpair : Surjective unpair :=
pairEquiv.symm.surjective
#align nat.surjective_unpair Nat.surjective_unpair
@[simp]
theorem pair_eq_pair {a b c d : ℕ} : pair a b = pair c d ↔ a = c ∧ b = d :=
pairEquiv.injective.eq_iff.trans (@Prod.ext_iff ℕ ℕ (a, b) (c, d))
#align nat.mkpair_eq_mkpair Nat.pair_eq_pair
theorem unpair_lt {n : ℕ} (n1 : 1 ≤ n) : (unpair n).1 < n := by
let s := sqrt n
simp only [unpair, ge_iff_le, Nat.sub_le_iff_le_add]
by_cases h : n - s * s < s <;> simp [h]
· exact lt_of_lt_of_le h (sqrt_le_self _)
· simp at h
have s0 : 0 < s := sqrt_pos.2 n1
exact lt_of_le_of_lt h (Nat.sub_lt n1 (Nat.mul_pos s0 s0))
#align nat.unpair_lt Nat.unpair_lt
@[simp]
theorem unpair_zero : unpair 0 = 0 := by
rw [unpair]
simp
#align nat.unpair_zero Nat.unpair_zero
theorem unpair_left_le : ∀ n : ℕ, (unpair n).1 ≤ n
| 0 => by simp
| n + 1 => le_of_lt (unpair_lt (Nat.succ_pos _))
#align nat.unpair_left_le Nat.unpair_left_le
theorem left_le_pair (a b : ℕ) : a ≤ pair a b := by simpa using unpair_left_le (pair a b)
#align nat.left_le_mkpair Nat.left_le_pair
| Mathlib/Data/Nat/Pairing.lean | 117 | 119 | theorem right_le_pair (a b : ℕ) : b ≤ pair a b := by |
by_cases h : a < b <;> simp [pair, h]
exact le_trans (le_mul_self _) (Nat.le_add_right _ _)
|
/-
Copyright (c) 2018 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon, Patrick Massot
-/
import Mathlib.Algebra.BigOperators.Group.Finset
import Mathlib.Algebra.Ring.Pi
import Mathlib.GroupTheory.GroupAction.Pi
#align_import algebra.big_operators.pi from "leanprover-community/mathlib"@"fa2309577c7009ea243cffdf990cd6c84f0ad497"
/-!
# Big operators for Pi Types
This file contains theorems relevant to big operators in binary and arbitrary product
of monoids and groups
-/
namespace Pi
@[to_additive]
theorem list_prod_apply {α : Type*} {β : α → Type*} [∀ a, Monoid (β a)] (a : α)
(l : List (∀ a, β a)) : l.prod a = (l.map fun f : ∀ a, β a ↦ f a).prod :=
map_list_prod (evalMonoidHom β a) _
#align pi.list_prod_apply Pi.list_prod_apply
#align pi.list_sum_apply Pi.list_sum_apply
@[to_additive]
theorem multiset_prod_apply {α : Type*} {β : α → Type*} [∀ a, CommMonoid (β a)] (a : α)
(s : Multiset (∀ a, β a)) : s.prod a = (s.map fun f : ∀ a, β a ↦ f a).prod :=
(evalMonoidHom β a).map_multiset_prod _
#align pi.multiset_prod_apply Pi.multiset_prod_apply
#align pi.multiset_sum_apply Pi.multiset_sum_apply
end Pi
@[to_additive (attr := simp)]
theorem Finset.prod_apply {α : Type*} {β : α → Type*} {γ} [∀ a, CommMonoid (β a)] (a : α)
(s : Finset γ) (g : γ → ∀ a, β a) : (∏ c ∈ s, g c) a = ∏ c ∈ s, g c a :=
map_prod (Pi.evalMonoidHom β a) _ _
#align finset.prod_apply Finset.prod_apply
#align finset.sum_apply Finset.sum_apply
/-- An 'unapplied' analogue of `Finset.prod_apply`. -/
@[to_additive "An 'unapplied' analogue of `Finset.sum_apply`."]
theorem Finset.prod_fn {α : Type*} {β : α → Type*} {γ} [∀ a, CommMonoid (β a)] (s : Finset γ)
(g : γ → ∀ a, β a) : ∏ c ∈ s, g c = fun a ↦ ∏ c ∈ s, g c a :=
funext fun _ ↦ Finset.prod_apply _ _ _
#align finset.prod_fn Finset.prod_fn
#align finset.sum_fn Finset.sum_fn
@[to_additive]
theorem Fintype.prod_apply {α : Type*} {β : α → Type*} {γ : Type*} [Fintype γ]
[∀ a, CommMonoid (β a)] (a : α) (g : γ → ∀ a, β a) : (∏ c, g c) a = ∏ c, g c a :=
Finset.prod_apply a Finset.univ g
#align fintype.prod_apply Fintype.prod_apply
#align fintype.sum_apply Fintype.sum_apply
@[to_additive prod_mk_sum]
theorem prod_mk_prod {α β γ : Type*} [CommMonoid α] [CommMonoid β] (s : Finset γ) (f : γ → α)
(g : γ → β) : (∏ x ∈ s, f x, ∏ x ∈ s, g x) = ∏ x ∈ s, (f x, g x) :=
haveI := Classical.decEq γ
Finset.induction_on s rfl (by simp (config := { contextual := true }) [Prod.ext_iff])
#align prod_mk_prod prod_mk_prod
#align prod_mk_sum prod_mk_sum
/-- decomposing `x : ι → R` as a sum along the canonical basis -/
theorem pi_eq_sum_univ {ι : Type*} [Fintype ι] [DecidableEq ι] {R : Type*} [Semiring R]
(x : ι → R) : x = ∑ i, (x i) • fun j => if i = j then (1 : R) else 0 := by
ext
simp
#align pi_eq_sum_univ pi_eq_sum_univ
section MulSingle
variable {I : Type*} [DecidableEq I] {Z : I → Type*}
variable [∀ i, CommMonoid (Z i)]
@[to_additive]
| Mathlib/Algebra/BigOperators/Pi.lean | 81 | 84 | theorem Finset.univ_prod_mulSingle [Fintype I] (f : ∀ i, Z i) :
(∏ i, Pi.mulSingle i (f i)) = f := by |
ext a
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, Sébastien Gouëzel, Yury Kudryashov
-/
import Mathlib.Dynamics.Ergodic.MeasurePreserving
import Mathlib.LinearAlgebra.Determinant
import Mathlib.LinearAlgebra.Matrix.Diagonal
import Mathlib.LinearAlgebra.Matrix.Transvection
import Mathlib.MeasureTheory.Group.LIntegral
import Mathlib.MeasureTheory.Integral.Marginal
import Mathlib.MeasureTheory.Measure.Stieltjes
import Mathlib.MeasureTheory.Measure.Haar.OfBasis
#align_import measure_theory.measure.lebesgue.basic from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
/-!
# Lebesgue measure on the real line and on `ℝⁿ`
We show that the Lebesgue measure on the real line (constructed as a particular case of additive
Haar measure on inner product spaces) coincides with the Stieltjes measure associated
to the function `x ↦ x`. We deduce properties of this measure on `ℝ`, and then of the product
Lebesgue measure on `ℝⁿ`. In particular, we prove that they are translation invariant.
We show that, on `ℝⁿ`, a linear map acts on Lebesgue measure by rescaling it through the absolute
value of its determinant, in `Real.map_linearMap_volume_pi_eq_smul_volume_pi`.
More properties of the Lebesgue measure are deduced from this in
`Mathlib/MeasureTheory/Measure/Lebesgue/EqHaar.lean`, where they are proved more generally for any
additive Haar measure on a finite-dimensional real vector space.
-/
assert_not_exists MeasureTheory.integral
noncomputable section
open scoped Classical
open Set Filter MeasureTheory MeasureTheory.Measure TopologicalSpace
open ENNReal (ofReal)
open scoped ENNReal NNReal Topology
/-!
### Definition of the Lebesgue measure and lengths of intervals
-/
namespace Real
variable {ι : Type*} [Fintype ι]
/-- The volume on the real line (as a particular case of the volume on a finite-dimensional
inner product space) coincides with the Stieltjes measure coming from the identity function. -/
theorem volume_eq_stieltjes_id : (volume : Measure ℝ) = StieltjesFunction.id.measure := by
haveI : IsAddLeftInvariant StieltjesFunction.id.measure :=
⟨fun a =>
Eq.symm <|
Real.measure_ext_Ioo_rat fun p q => by
simp only [Measure.map_apply (measurable_const_add a) measurableSet_Ioo,
sub_sub_sub_cancel_right, StieltjesFunction.measure_Ioo, StieltjesFunction.id_leftLim,
StieltjesFunction.id_apply, id, preimage_const_add_Ioo]⟩
have A : StieltjesFunction.id.measure (stdOrthonormalBasis ℝ ℝ).toBasis.parallelepiped = 1 := by
change StieltjesFunction.id.measure (parallelepiped (stdOrthonormalBasis ℝ ℝ)) = 1
rcases parallelepiped_orthonormalBasis_one_dim (stdOrthonormalBasis ℝ ℝ) with (H | H) <;>
simp only [H, StieltjesFunction.measure_Icc, StieltjesFunction.id_apply, id, tsub_zero,
StieltjesFunction.id_leftLim, sub_neg_eq_add, zero_add, ENNReal.ofReal_one]
conv_rhs =>
rw [addHaarMeasure_unique StieltjesFunction.id.measure
(stdOrthonormalBasis ℝ ℝ).toBasis.parallelepiped, A]
simp only [volume, Basis.addHaar, one_smul]
#align real.volume_eq_stieltjes_id Real.volume_eq_stieltjes_id
theorem volume_val (s) : volume s = StieltjesFunction.id.measure s := by
simp [volume_eq_stieltjes_id]
#align real.volume_val Real.volume_val
@[simp]
theorem volume_Ico {a b : ℝ} : volume (Ico a b) = ofReal (b - a) := by simp [volume_val]
#align real.volume_Ico Real.volume_Ico
@[simp]
theorem volume_Icc {a b : ℝ} : volume (Icc a b) = ofReal (b - a) := by simp [volume_val]
#align real.volume_Icc Real.volume_Icc
@[simp]
theorem volume_Ioo {a b : ℝ} : volume (Ioo a b) = ofReal (b - a) := by simp [volume_val]
#align real.volume_Ioo Real.volume_Ioo
@[simp]
theorem volume_Ioc {a b : ℝ} : volume (Ioc a b) = ofReal (b - a) := by simp [volume_val]
#align real.volume_Ioc Real.volume_Ioc
-- @[simp] -- Porting note (#10618): simp can prove this
theorem volume_singleton {a : ℝ} : volume ({a} : Set ℝ) = 0 := by simp [volume_val]
#align real.volume_singleton Real.volume_singleton
-- @[simp] -- Porting note (#10618): simp can prove this, after mathlib4#4628
theorem volume_univ : volume (univ : Set ℝ) = ∞ :=
ENNReal.eq_top_of_forall_nnreal_le fun r =>
calc
(r : ℝ≥0∞) = volume (Icc (0 : ℝ) r) := by simp
_ ≤ volume univ := measure_mono (subset_univ _)
#align real.volume_univ Real.volume_univ
@[simp]
theorem volume_ball (a r : ℝ) : volume (Metric.ball a r) = ofReal (2 * r) := by
rw [ball_eq_Ioo, volume_Ioo, ← sub_add, add_sub_cancel_left, two_mul]
#align real.volume_ball Real.volume_ball
@[simp]
| Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean | 113 | 114 | theorem volume_closedBall (a r : ℝ) : volume (Metric.closedBall a r) = ofReal (2 * r) := by |
rw [closedBall_eq_Icc, volume_Icc, ← sub_add, add_sub_cancel_left, two_mul]
|
/-
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.Order.ConditionallyCompleteLattice.Basic
import Mathlib.Data.Int.LeastGreatest
#align_import data.int.conditionally_complete_order from "leanprover-community/mathlib"@"1e05171a5e8cf18d98d9cf7b207540acb044acae"
/-!
## `ℤ` forms a conditionally complete linear order
The integers form a conditionally complete linear order.
-/
open Int
noncomputable section
open scoped Classical
instance instConditionallyCompleteLinearOrder : ConditionallyCompleteLinearOrder ℤ where
__ := instLinearOrder
__ := LinearOrder.toLattice
sSup s :=
if h : s.Nonempty ∧ BddAbove s then
greatestOfBdd (Classical.choose h.2) (Classical.choose_spec h.2) h.1
else 0
sInf s :=
if h : s.Nonempty ∧ BddBelow s then
leastOfBdd (Classical.choose h.2) (Classical.choose_spec h.2) h.1
else 0
le_csSup s n hs hns := by
have : s.Nonempty ∧ BddAbove s := ⟨⟨n, hns⟩, hs⟩
-- Porting note: this was `rw [dif_pos this]`
simp only [this, and_self, dite_true, ge_iff_le]
exact (greatestOfBdd _ _ _).2.2 n hns
csSup_le s n hs hns := by
have : s.Nonempty ∧ BddAbove s := ⟨hs, ⟨n, hns⟩⟩
-- Porting note: this was `rw [dif_pos this]`
simp only [this, and_self, dite_true, ge_iff_le]
exact hns (greatestOfBdd _ (Classical.choose_spec this.2) _).2.1
csInf_le s n hs hns := by
have : s.Nonempty ∧ BddBelow s := ⟨⟨n, hns⟩, hs⟩
-- Porting note: this was `rw [dif_pos this]`
simp only [this, and_self, dite_true, ge_iff_le]
exact (leastOfBdd _ _ _).2.2 n hns
le_csInf s n hs hns := by
have : s.Nonempty ∧ BddBelow s := ⟨hs, ⟨n, hns⟩⟩
-- Porting note: this was `rw [dif_pos this]`
simp only [this, and_self, dite_true, ge_iff_le]
exact hns (leastOfBdd _ (Classical.choose_spec this.2) _).2.1
csSup_of_not_bddAbove := fun s hs ↦ by simp [hs]
csInf_of_not_bddBelow := fun s hs ↦ by simp [hs]
namespace Int
-- Porting note: mathlib3 proof uses `convert dif_pos _ using 1`
theorem csSup_eq_greatest_of_bdd {s : Set ℤ} [DecidablePred (· ∈ s)] (b : ℤ) (Hb : ∀ z ∈ s, z ≤ b)
(Hinh : ∃ z : ℤ, z ∈ s) : sSup s = greatestOfBdd b Hb Hinh := by
have : s.Nonempty ∧ BddAbove s := ⟨Hinh, b, Hb⟩
simp only [sSup, this, and_self, dite_true]
convert (coe_greatestOfBdd_eq Hb (Classical.choose_spec (⟨b, Hb⟩ : BddAbove s)) Hinh).symm
#align int.cSup_eq_greatest_of_bdd Int.csSup_eq_greatest_of_bdd
@[simp]
theorem csSup_empty : sSup (∅ : Set ℤ) = 0 :=
dif_neg (by simp)
#align int.cSup_empty Int.csSup_empty
theorem csSup_of_not_bdd_above {s : Set ℤ} (h : ¬BddAbove s) : sSup s = 0 :=
dif_neg (by simp [h])
#align int.cSup_of_not_bdd_above Int.csSup_of_not_bdd_above
-- Porting note: mathlib3 proof uses `convert dif_pos _ using 1`
| Mathlib/Data/Int/ConditionallyCompleteOrder.lean | 78 | 82 | theorem csInf_eq_least_of_bdd {s : Set ℤ} [DecidablePred (· ∈ s)] (b : ℤ) (Hb : ∀ z ∈ s, b ≤ z)
(Hinh : ∃ z : ℤ, z ∈ s) : sInf s = leastOfBdd b Hb Hinh := by |
have : s.Nonempty ∧ BddBelow s := ⟨Hinh, b, Hb⟩
simp only [sInf, this, and_self, dite_true]
convert (coe_leastOfBdd_eq Hb (Classical.choose_spec (⟨b, Hb⟩ : BddBelow s)) Hinh).symm
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
import Mathlib.Data.Set.Function
import Mathlib.Logic.Relation
import Mathlib.Logic.Pairwise
#align_import data.set.pairwise.basic from "leanprover-community/mathlib"@"c4c2ed622f43768eff32608d4a0f8a6cec1c047d"
/-!
# Relations holding pairwise
This file develops pairwise relations and defines pairwise disjoint indexed sets.
We also prove many basic facts about `Pairwise`. It is possible that an intermediate file,
with more imports than `Logic.Pairwise` but not importing `Data.Set.Function` would be appropriate
to hold many of these basic facts.
## Main declarations
* `Set.PairwiseDisjoint`: `s.PairwiseDisjoint f` states that images under `f` of distinct elements
of `s` are either equal or `Disjoint`.
## Notes
The spelling `s.PairwiseDisjoint id` is preferred over `s.Pairwise Disjoint` to permit dot notation
on `Set.PairwiseDisjoint`, even though the latter unfolds to something nicer.
-/
open Function Order Set
variable {α β γ ι ι' : Type*} {r p q : α → α → Prop}
section Pairwise
variable {f g : ι → α} {s t u : Set α} {a b : α}
theorem pairwise_on_bool (hr : Symmetric r) {a b : α} :
Pairwise (r on fun c => cond c a b) ↔ r a b := by simpa [Pairwise, Function.onFun] using @hr a b
#align pairwise_on_bool pairwise_on_bool
theorem pairwise_disjoint_on_bool [SemilatticeInf α] [OrderBot α] {a b : α} :
Pairwise (Disjoint on fun c => cond c a b) ↔ Disjoint a b :=
pairwise_on_bool Disjoint.symm
#align pairwise_disjoint_on_bool pairwise_disjoint_on_bool
theorem Symmetric.pairwise_on [LinearOrder ι] (hr : Symmetric r) (f : ι → α) :
Pairwise (r on f) ↔ ∀ ⦃m n⦄, m < n → r (f m) (f n) :=
⟨fun h _m _n hmn => h hmn.ne, fun h _m _n hmn => hmn.lt_or_lt.elim (@h _ _) fun h' => hr (h h')⟩
#align symmetric.pairwise_on Symmetric.pairwise_on
theorem pairwise_disjoint_on [SemilatticeInf α] [OrderBot α] [LinearOrder ι] (f : ι → α) :
Pairwise (Disjoint on f) ↔ ∀ ⦃m n⦄, m < n → Disjoint (f m) (f n) :=
Symmetric.pairwise_on Disjoint.symm f
#align pairwise_disjoint_on pairwise_disjoint_on
theorem pairwise_disjoint_mono [SemilatticeInf α] [OrderBot α] (hs : Pairwise (Disjoint on f))
(h : g ≤ f) : Pairwise (Disjoint on g) :=
hs.mono fun i j hij => Disjoint.mono (h i) (h j) hij
#align pairwise_disjoint.mono pairwise_disjoint_mono
namespace Set
theorem Pairwise.mono (h : t ⊆ s) (hs : s.Pairwise r) : t.Pairwise r :=
fun _x xt _y yt => hs (h xt) (h yt)
#align set.pairwise.mono Set.Pairwise.mono
theorem Pairwise.mono' (H : r ≤ p) (hr : s.Pairwise r) : s.Pairwise p :=
hr.imp H
#align set.pairwise.mono' Set.Pairwise.mono'
theorem pairwise_top (s : Set α) : s.Pairwise ⊤ :=
pairwise_of_forall s _ fun _ _ => trivial
#align set.pairwise_top Set.pairwise_top
protected theorem Subsingleton.pairwise (h : s.Subsingleton) (r : α → α → Prop) : s.Pairwise r :=
fun _x hx _y hy hne => (hne (h hx hy)).elim
#align set.subsingleton.pairwise Set.Subsingleton.pairwise
@[simp]
theorem pairwise_empty (r : α → α → Prop) : (∅ : Set α).Pairwise r :=
subsingleton_empty.pairwise r
#align set.pairwise_empty Set.pairwise_empty
@[simp]
theorem pairwise_singleton (a : α) (r : α → α → Prop) : Set.Pairwise {a} r :=
subsingleton_singleton.pairwise r
#align set.pairwise_singleton Set.pairwise_singleton
theorem pairwise_iff_of_refl [IsRefl α r] : s.Pairwise r ↔ ∀ ⦃a⦄, a ∈ s → ∀ ⦃b⦄, b ∈ s → r a b :=
forall₄_congr fun _ _ _ _ => or_iff_not_imp_left.symm.trans <| or_iff_right_of_imp of_eq
#align set.pairwise_iff_of_refl Set.pairwise_iff_of_refl
alias ⟨Pairwise.of_refl, _⟩ := pairwise_iff_of_refl
#align set.pairwise.of_refl Set.Pairwise.of_refl
| Mathlib/Data/Set/Pairwise/Basic.lean | 100 | 109 | theorem Nonempty.pairwise_iff_exists_forall [IsEquiv α r] {s : Set ι} (hs : s.Nonempty) :
s.Pairwise (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z := by |
constructor
· rcases hs with ⟨y, hy⟩
refine fun H => ⟨f y, fun x hx => ?_⟩
rcases eq_or_ne x y with (rfl | hne)
· apply IsRefl.refl
· exact H hx hy hne
· rintro ⟨z, hz⟩ x hx y hy _
exact @IsTrans.trans α r _ (f x) z (f y) (hz _ hx) (IsSymm.symm _ _ <| hz _ hy)
|
/-
Copyright (c) 2024 Paul Reichert. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Paul Reichert
-/
import Mathlib.CategoryTheory.Limits.Types
import Mathlib.CategoryTheory.IsConnected
import Mathlib.CategoryTheory.Limits.Final
import Mathlib.CategoryTheory.Conj
/-!
# Colimits of connected index categories
This file proves two characterizations of connected categories by means of colimits.
## Characterization of connected categories by means of the unit-valued functor
First, it is proved that a category `C` is connected if and only if `colim F` is a singleton,
where `F : C ⥤ Type w` and `F.obj _ = PUnit` (for arbitrary `w`).
See `isConnected_iff_colimit_constPUnitFunctor_iso_pUnit` for the proof of this characterization and
`constPUnitFunctor` for the definition of the constant functor used in the statement. A formulation
based on `IsColimit` instead of `colimit` is given in `isConnected_iff_isColimit_pUnitCocone`.
The `if` direction is also available directly in several formulations:
For connected index categories `C`, `PUnit.{w}` is a colimit of the `constPUnitFunctor`, where `w`
is arbitrary. See `instHasColimitConstPUnitFunctor`, `isColimitPUnitCocone` and
`colimitConstPUnitIsoPUnit`.
## Final functors preserve connectedness of categories (in both directions)
`isConnected_iff_of_final` proves that the domain of a final functor is connected if and only if
its codomain is connected.
## Tags
unit-valued, singleton, colimit
-/
universe w v u
namespace CategoryTheory.Limits.Types
variable (C : Type u) [Category.{v} C]
/-- The functor mapping every object to `PUnit`. -/
def constPUnitFunctor : C ⥤ Type w := (Functor.const C).obj PUnit.{w + 1}
/-- The cocone on `constPUnitFunctor` with cone point `PUnit`. -/
@[simps]
def pUnitCocone : Cocone (constPUnitFunctor.{w} C) where
pt := PUnit
ι := { app := fun X => id }
/-- If `C` is connected, the cocone on `constPUnitFunctor` with cone point `PUnit` is a colimit
cocone. -/
noncomputable def isColimitPUnitCocone [IsConnected C] : IsColimit (pUnitCocone.{w} C) where
desc s := s.ι.app Classical.ofNonempty
fac s j := by
ext ⟨⟩
apply constant_of_preserves_morphisms (s.ι.app · PUnit.unit)
intros X Y f
exact congrFun (s.ι.naturality f).symm PUnit.unit
uniq s m h := by
ext ⟨⟩
simp [← h Classical.ofNonempty]
instance instHasColimitConstPUnitFunctor [IsConnected C] : HasColimit (constPUnitFunctor.{w} C) :=
⟨_, isColimitPUnitCocone _⟩
instance instSubsingletonColimitPUnit
[IsPreconnected C] [HasColimit (constPUnitFunctor.{w} C)] :
Subsingleton (colimit (constPUnitFunctor.{w} C)) where
allEq a b := by
obtain ⟨c, ⟨⟩, rfl⟩ := jointly_surjective' a
obtain ⟨d, ⟨⟩, rfl⟩ := jointly_surjective' b
apply constant_of_preserves_morphisms (colimit.ι (constPUnitFunctor C) · PUnit.unit)
exact fun c d f => colimit_sound f rfl
/-- Given a connected index category, the colimit of the constant unit-valued functor is `PUnit`. -/
noncomputable def colimitConstPUnitIsoPUnit [IsConnected C] :
colimit (constPUnitFunctor.{w} C) ≅ PUnit.{w + 1} :=
IsColimit.coconePointUniqueUpToIso (colimit.isColimit _) (isColimitPUnitCocone.{w} C)
/-- Let `F` be a `Type`-valued functor. If two elements `a : F c` and `b : F d` represent the same
element of `colimit F`, then `c` and `d` are related by a `Zigzag`. -/
theorem zigzag_of_eqvGen_quot_rel (F : C ⥤ Type w) (c d : Σ j, F.obj j)
(h : EqvGen (Quot.Rel F) c d) : Zigzag c.1 d.1 := by
induction h with
| rel _ _ h => exact Zigzag.of_hom <| Exists.choose h
| refl _ => exact Zigzag.refl _
| symm _ _ _ ih => exact zigzag_symmetric ih
| trans _ _ _ _ _ ih₁ ih₂ => exact ih₁.trans ih₂
/-- An index category is connected iff the colimit of the constant singleton-valued functor is a
singleton. -/
| Mathlib/CategoryTheory/Limits/IsConnected.lean | 97 | 104 | theorem isConnected_iff_colimit_constPUnitFunctor_iso_pUnit
[HasColimit (constPUnitFunctor.{w} C)] :
IsConnected C ↔ Nonempty (colimit (constPUnitFunctor.{w} C) ≅ PUnit) := by |
refine ⟨fun _ => ⟨colimitConstPUnitIsoPUnit.{w} C⟩, fun ⟨h⟩ => ?_⟩
have : Nonempty C := nonempty_of_nonempty_colimit <| Nonempty.map h.inv inferInstance
refine zigzag_isConnected <| fun c d => ?_
refine zigzag_of_eqvGen_quot_rel _ (constPUnitFunctor C) ⟨c, PUnit.unit⟩ ⟨d, PUnit.unit⟩ ?_
exact colimit_eq <| h.toEquiv.injective rfl
|
/-
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]
| Mathlib/Data/Vector/Basic.lean | 106 | 108 | 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]
|
/-
Copyright (c) 2018 Mario Carneiro, Kevin Buzzard. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Kevin Buzzard
-/
import Mathlib.Algebra.Ring.Idempotents
import Mathlib.RingTheory.Finiteness
import Mathlib.Order.Basic
#align_import ring_theory.ideal.idempotent_fg from "leanprover-community/mathlib"@"25cf7631da8ddc2d5f957c388bf5e4b25a77d8dc"
/-!
## Lemmas on idempotent finitely generated ideals
-/
namespace Ideal
/-- A finitely generated idempotent ideal is generated by an idempotent element -/
| Mathlib/RingTheory/Ideal/IdempotentFG.lean | 20 | 35 | theorem isIdempotentElem_iff_of_fg {R : Type*} [CommRing R] (I : Ideal R) (h : I.FG) :
IsIdempotentElem I ↔ ∃ e : R, IsIdempotentElem e ∧ I = R ∙ e := by |
constructor
· intro e
obtain ⟨r, hr, hr'⟩ :=
Submodule.exists_mem_and_smul_eq_self_of_fg_of_le_smul I I h
(by
rw [smul_eq_mul]
exact e.ge)
simp_rw [smul_eq_mul] at hr'
refine ⟨r, hr' r hr, antisymm ?_ ((Submodule.span_singleton_le_iff_mem _ _).mpr hr)⟩
intro x hx
rw [← hr' x hx]
exact Ideal.mem_span_singleton'.mpr ⟨_, mul_comm _ _⟩
· rintro ⟨e, he, rfl⟩
simp [IsIdempotentElem, Ideal.span_singleton_mul_span_singleton, he.eq]
|
/-
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, Floris van Doorn
-/
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.Bounded
import Mathlib.SetTheory.Cardinal.PartENat
import Mathlib.SetTheory.Ordinal.Principal
import Mathlib.Tactic.Linarith
#align_import set_theory.cardinal.ordinal from "leanprover-community/mathlib"@"7c2ce0c2da15516b4e65d0c9e254bb6dc93abd1f"
/-!
# Cardinals and ordinals
Relationships between cardinals and ordinals, properties of cardinals that are proved
using ordinals.
## Main definitions
* The function `Cardinal.aleph'` gives the cardinals listed by their ordinal
index, and is the inverse of `Cardinal.aleph/idx`.
`aleph' n = n`, `aleph' ω = ℵ₀`, `aleph' (ω + 1) = succ ℵ₀`, etc.
It is an order isomorphism between ordinals and cardinals.
* The function `Cardinal.aleph` gives the infinite cardinals listed by their
ordinal index. `aleph 0 = ℵ₀`, `aleph 1 = succ ℵ₀` is the first
uncountable cardinal, and so on. The notation `ω_` combines the latter with `Cardinal.ord`,
giving an enumeration of (infinite) initial ordinals.
Thus `ω_ 0 = ω` and `ω₁ = ω_ 1` is the first uncountable ordinal.
* The function `Cardinal.beth` enumerates the Beth cardinals. `beth 0 = ℵ₀`,
`beth (succ o) = 2 ^ beth o`, and for a limit ordinal `o`, `beth o` is the supremum of `beth a`
for `a < o`.
## Main Statements
* `Cardinal.mul_eq_max` and `Cardinal.add_eq_max` state that the product (resp. sum) of two infinite
cardinals is just their maximum. Several variations around this fact are also given.
* `Cardinal.mk_list_eq_mk` : when `α` is infinite, `α` and `List α` have the same cardinality.
* simp lemmas for inequalities between `bit0 a` and `bit1 b` are registered, making `simp`
able to prove inequalities about numeral cardinals.
## Tags
cardinal arithmetic (for infinite cardinals)
-/
noncomputable section
open Function Set Cardinal Equiv Order Ordinal
open scoped Classical
universe u v w
namespace Cardinal
section UsingOrdinals
theorem ord_isLimit {c} (co : ℵ₀ ≤ c) : (ord c).IsLimit := by
refine ⟨fun h => aleph0_ne_zero ?_, fun a => lt_imp_lt_of_le_imp_le fun h => ?_⟩
· rw [← Ordinal.le_zero, ord_le] at h
simpa only [card_zero, nonpos_iff_eq_zero] using co.trans h
· rw [ord_le] at h ⊢
rwa [← @add_one_of_aleph0_le (card a), ← card_succ]
rw [← ord_le, ← le_succ_of_isLimit, ord_le]
· exact co.trans h
· rw [ord_aleph0]
exact omega_isLimit
#align cardinal.ord_is_limit Cardinal.ord_isLimit
theorem noMaxOrder {c} (h : ℵ₀ ≤ c) : NoMaxOrder c.ord.out.α :=
Ordinal.out_no_max_of_succ_lt (ord_isLimit h).2
/-! ### Aleph cardinals -/
section aleph
/-- The `aleph'` index function, which gives the ordinal index of a cardinal.
(The `aleph'` part is because unlike `aleph` this counts also the
finite stages. So `alephIdx n = n`, `alephIdx ω = ω`,
`alephIdx ℵ₁ = ω + 1` and so on.)
In this definition, we register additionally that this function is an initial segment,
i.e., it is order preserving and its range is an initial segment of the ordinals.
For the basic function version, see `alephIdx`.
For an upgraded version stating that the range is everything, see `AlephIdx.rel_iso`. -/
def alephIdx.initialSeg : @InitialSeg Cardinal Ordinal (· < ·) (· < ·) :=
@RelEmbedding.collapse Cardinal Ordinal (· < ·) (· < ·) _ Cardinal.ord.orderEmbedding.ltEmbedding
#align cardinal.aleph_idx.initial_seg Cardinal.alephIdx.initialSeg
/-- The `aleph'` index function, which gives the ordinal index of a cardinal.
(The `aleph'` part is because unlike `aleph` this counts also the
finite stages. So `alephIdx n = n`, `alephIdx ω = ω`,
`alephIdx ℵ₁ = ω + 1` and so on.)
For an upgraded version stating that the range is everything, see `AlephIdx.rel_iso`. -/
def alephIdx : Cardinal → Ordinal :=
alephIdx.initialSeg
#align cardinal.aleph_idx Cardinal.alephIdx
@[simp]
theorem alephIdx.initialSeg_coe : (alephIdx.initialSeg : Cardinal → Ordinal) = alephIdx :=
rfl
#align cardinal.aleph_idx.initial_seg_coe Cardinal.alephIdx.initialSeg_coe
@[simp]
theorem alephIdx_lt {a b} : alephIdx a < alephIdx b ↔ a < b :=
alephIdx.initialSeg.toRelEmbedding.map_rel_iff
#align cardinal.aleph_idx_lt Cardinal.alephIdx_lt
@[simp]
| Mathlib/SetTheory/Cardinal/Ordinal.lean | 111 | 112 | theorem alephIdx_le {a b} : alephIdx a ≤ alephIdx b ↔ a ≤ b := by |
rw [← not_lt, ← not_lt, alephIdx_lt]
|
/-
Copyright (c) 2023 Alex Keizer. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alex Keizer
-/
import Mathlib.Data.Vector.Basic
/-!
This file establishes a `snoc : Vector α n → α → Vector α (n+1)` operation, that appends a single
element to the back of a vector.
It provides a collection of lemmas that show how different `Vector` operations reduce when their
argument is `snoc xs x`.
Also, an alternative, reverse, induction principle is added, that breaks down a vector into
`snoc xs x` for its inductive case. Effectively doing induction from right-to-left
-/
set_option autoImplicit true
namespace Vector
/-- Append a single element to the end of a vector -/
def snoc : Vector α n → α → Vector α (n+1) :=
fun xs x => append xs (x ::ᵥ Vector.nil)
/-!
## Simplification lemmas
-/
section Simp
variable (xs : Vector α n)
@[simp]
theorem snoc_cons : (x ::ᵥ xs).snoc y = x ::ᵥ (xs.snoc y) :=
rfl
@[simp]
theorem snoc_nil : (nil.snoc x) = x ::ᵥ nil :=
rfl
@[simp]
theorem reverse_cons : reverse (x ::ᵥ xs) = (reverse xs).snoc x := by
cases xs
simp only [reverse, cons, toList_mk, List.reverse_cons, snoc]
congr
@[simp]
theorem reverse_snoc : reverse (xs.snoc x) = x ::ᵥ (reverse xs) := by
cases xs
simp only [reverse, snoc, cons, toList_mk]
congr
simp [toList, Vector.append, Append.append]
theorem replicate_succ_to_snoc (val : α) :
replicate (n+1) val = (replicate n val).snoc val := by
clear xs
induction n with
| zero => rfl
| succ n ih =>
rw [replicate_succ]
conv => rhs; rw [replicate_succ]
rw [snoc_cons, ih]
end Simp
/-!
## Reverse induction principle
-/
section Induction
/-- Define `C v` by *reverse* induction on `v : Vector α n`.
That is, break the vector down starting from the right-most element, using `snoc`
This function has two arguments: `nil` handles the base case on `C nil`,
and `snoc` defines the inductive step using `∀ x : α, C xs → C (xs.snoc x)`.
This can be used as `induction v using Vector.revInductionOn`. -/
@[elab_as_elim]
def revInductionOn {C : ∀ {n : ℕ}, Vector α n → Sort*} {n : ℕ} (v : Vector α n)
(nil : C nil)
(snoc : ∀ {n : ℕ} (xs : Vector α n) (x : α), C xs → C (xs.snoc x)) :
C v :=
cast (by simp) <| inductionOn
(C := fun v => C v.reverse)
v.reverse
nil
(@fun n x xs (r : C xs.reverse) => cast (by simp) <| snoc xs.reverse x r)
/-- Define `C v w` by *reverse* induction on a pair of vectors `v : Vector α n` and
`w : Vector β n`. -/
@[elab_as_elim]
def revInductionOn₂ {C : ∀ {n : ℕ}, Vector α n → Vector β n → Sort*} {n : ℕ}
(v : Vector α n) (w : Vector β n)
(nil : C nil nil)
(snoc : ∀ {n : ℕ} (xs : Vector α n) (ys : Vector β n) (x : α) (y : β),
C xs ys → C (xs.snoc x) (ys.snoc y)) :
C v w :=
cast (by simp) <| inductionOn₂
(C := fun v w => C v.reverse w.reverse)
v.reverse
w.reverse
nil
(@fun n x y xs ys (r : C xs.reverse ys.reverse) =>
cast (by simp) <| snoc xs.reverse ys.reverse x y r)
/-- Define `C v` by *reverse* case analysis, i.e. by handling the cases `nil` and `xs.snoc x`
separately -/
@[elab_as_elim]
def revCasesOn {C : ∀ {n : ℕ}, Vector α n → Sort*} {n : ℕ} (v : Vector α n)
(nil : C nil)
(snoc : ∀ {n : ℕ} (xs : Vector α n) (x : α), C (xs.snoc x)) :
C v :=
revInductionOn v nil fun xs x _ => snoc xs x
end Induction
/-!
## More simplification lemmas
-/
section Simp
variable (xs : Vector α n)
@[simp]
| Mathlib/Data/Vector/Snoc.lean | 126 | 127 | theorem map_snoc : map f (xs.snoc x) = (map f xs).snoc (f x) := by |
induction xs <;> simp_all
|
/-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Algebra.Polynomial.Degree.Definitions
import Mathlib.Algebra.Polynomial.Eval
import Mathlib.Algebra.Polynomial.Monic
import Mathlib.Algebra.Polynomial.RingDivision
import Mathlib.Tactic.Abel
#align_import ring_theory.polynomial.pochhammer from "leanprover-community/mathlib"@"53b216bcc1146df1c4a0a86877890ea9f1f01589"
/-!
# The Pochhammer polynomials
We define and prove some basic relations about
`ascPochhammer S n : S[X] := X * (X + 1) * ... * (X + n - 1)`
which is also known as the rising factorial and about
`descPochhammer R n : R[X] := X * (X - 1) * ... * (X - n + 1)`
which is also known as the falling factorial. Versions of this definition
that are focused on `Nat` can be found in `Data.Nat.Factorial` as `Nat.ascFactorial` and
`Nat.descFactorial`.
## Implementation
As with many other families of polynomials, even though the coefficients are always in `ℕ` or `ℤ` ,
we define the polynomial with coefficients in any `[Semiring S]` or `[Ring R]`.
## TODO
There is lots more in this direction:
* q-factorials, q-binomials, q-Pochhammer.
-/
universe u v
open Polynomial
open Polynomial
section Semiring
variable (S : Type u) [Semiring S]
/-- `ascPochhammer S n` is the polynomial `X * (X + 1) * ... * (X + n - 1)`,
with coefficients in the semiring `S`.
-/
noncomputable def ascPochhammer : ℕ → S[X]
| 0 => 1
| n + 1 => X * (ascPochhammer n).comp (X + 1)
#align pochhammer ascPochhammer
@[simp]
theorem ascPochhammer_zero : ascPochhammer S 0 = 1 :=
rfl
#align pochhammer_zero ascPochhammer_zero
@[simp]
theorem ascPochhammer_one : ascPochhammer S 1 = X := by simp [ascPochhammer]
#align pochhammer_one ascPochhammer_one
theorem ascPochhammer_succ_left (n : ℕ) :
ascPochhammer S (n + 1) = X * (ascPochhammer S n).comp (X + 1) := by
rw [ascPochhammer]
#align pochhammer_succ_left ascPochhammer_succ_left
theorem monic_ascPochhammer (n : ℕ) [Nontrivial S] [NoZeroDivisors S] :
Monic <| ascPochhammer S n := by
induction' n with n hn
· simp
· have : leadingCoeff (X + 1 : S[X]) = 1 := leadingCoeff_X_add_C 1
rw [ascPochhammer_succ_left, Monic.def, leadingCoeff_mul,
leadingCoeff_comp (ne_zero_of_eq_one <| natDegree_X_add_C 1 : natDegree (X + 1) ≠ 0), hn,
monic_X, one_mul, one_mul, this, one_pow]
section
variable {S} {T : Type v} [Semiring T]
@[simp]
| Mathlib/RingTheory/Polynomial/Pochhammer.lean | 83 | 87 | theorem ascPochhammer_map (f : S →+* T) (n : ℕ) :
(ascPochhammer S n).map f = ascPochhammer T n := by |
induction' n with n ih
· simp
· simp [ih, ascPochhammer_succ_left, map_comp]
|
/-
Copyright (c) 2020 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn
-/
import Mathlib.Data.Set.Prod
#align_import data.set.n_ary from "leanprover-community/mathlib"@"5e526d18cea33550268dcbbddcb822d5cde40654"
/-!
# N-ary images of sets
This file defines `Set.image2`, the binary image of sets.
This is mostly useful to define pointwise operations and `Set.seq`.
## Notes
This file is very similar to `Data.Finset.NAry`, to `Order.Filter.NAry`, and to
`Data.Option.NAry`. Please keep them in sync.
-/
open Function
namespace Set
variable {α α' β β' γ γ' δ δ' ε ε' ζ ζ' ν : Type*} {f f' : α → β → γ} {g g' : α → β → γ → δ}
variable {s s' : Set α} {t t' : Set β} {u u' : Set γ} {v : Set δ} {a a' : α} {b b' : β} {c c' : γ}
{d d' : δ}
theorem mem_image2_iff (hf : Injective2 f) : f a b ∈ image2 f s t ↔ a ∈ s ∧ b ∈ t :=
⟨by
rintro ⟨a', ha', b', hb', h⟩
rcases hf h with ⟨rfl, rfl⟩
exact ⟨ha', hb'⟩, fun ⟨ha, hb⟩ => mem_image2_of_mem ha hb⟩
#align set.mem_image2_iff Set.mem_image2_iff
/-- image2 is monotone with respect to `⊆`. -/
theorem image2_subset (hs : s ⊆ s') (ht : t ⊆ t') : image2 f s t ⊆ image2 f s' t' := by
rintro _ ⟨a, ha, b, hb, rfl⟩
exact mem_image2_of_mem (hs ha) (ht hb)
#align set.image2_subset Set.image2_subset
theorem image2_subset_left (ht : t ⊆ t') : image2 f s t ⊆ image2 f s t' :=
image2_subset Subset.rfl ht
#align set.image2_subset_left Set.image2_subset_left
theorem image2_subset_right (hs : s ⊆ s') : image2 f s t ⊆ image2 f s' t :=
image2_subset hs Subset.rfl
#align set.image2_subset_right Set.image2_subset_right
theorem image_subset_image2_left (hb : b ∈ t) : (fun a => f a b) '' s ⊆ image2 f s t :=
forall_mem_image.2 fun _ ha => mem_image2_of_mem ha hb
#align set.image_subset_image2_left Set.image_subset_image2_left
theorem image_subset_image2_right (ha : a ∈ s) : f a '' t ⊆ image2 f s t :=
forall_mem_image.2 fun _ => mem_image2_of_mem ha
#align set.image_subset_image2_right Set.image_subset_image2_right
theorem forall_image2_iff {p : γ → Prop} :
(∀ z ∈ image2 f s t, p z) ↔ ∀ x ∈ s, ∀ y ∈ t, p (f x y) :=
⟨fun h x hx y hy => h _ ⟨x, hx, y, hy, rfl⟩, fun h _ ⟨x, hx, y, hy, hz⟩ => hz ▸ h x hx y hy⟩
#align set.forall_image2_iff Set.forall_image2_iff
@[simp]
theorem image2_subset_iff {u : Set γ} : image2 f s t ⊆ u ↔ ∀ x ∈ s, ∀ y ∈ t, f x y ∈ u :=
forall_image2_iff
#align set.image2_subset_iff Set.image2_subset_iff
theorem image2_subset_iff_left : image2 f s t ⊆ u ↔ ∀ a ∈ s, (fun b => f a b) '' t ⊆ u := by
simp_rw [image2_subset_iff, image_subset_iff, subset_def, mem_preimage]
#align set.image2_subset_iff_left Set.image2_subset_iff_left
theorem image2_subset_iff_right : image2 f s t ⊆ u ↔ ∀ b ∈ t, (fun a => f a b) '' s ⊆ u := by
simp_rw [image2_subset_iff, image_subset_iff, subset_def, mem_preimage, @forall₂_swap α]
#align set.image2_subset_iff_right Set.image2_subset_iff_right
variable (f)
-- Porting note: Removing `simp` - LHS does not simplify
lemma image_prod : (fun x : α × β ↦ f x.1 x.2) '' s ×ˢ t = image2 f s t :=
ext fun _ ↦ by simp [and_assoc]
#align set.image_prod Set.image_prod
@[simp] lemma image_uncurry_prod (s : Set α) (t : Set β) : uncurry f '' s ×ˢ t = image2 f s t :=
image_prod _
#align set.image_uncurry_prod Set.image_uncurry_prod
@[simp] lemma image2_mk_eq_prod : image2 Prod.mk s t = s ×ˢ t := ext <| by simp
#align set.image2_mk_eq_prod Set.image2_mk_eq_prod
-- Porting note: Removing `simp` - LHS does not simplify
lemma image2_curry (f : α × β → γ) (s : Set α) (t : Set β) :
image2 (fun a b ↦ f (a, b)) s t = f '' s ×ˢ t := by
simp [← image_uncurry_prod, uncurry]
#align set.image2_curry Set.image2_curry
theorem image2_swap (s : Set α) (t : Set β) : image2 f s t = image2 (fun a b => f b a) t s := by
ext
constructor <;> rintro ⟨a, ha, b, hb, rfl⟩ <;> exact ⟨b, hb, a, ha, rfl⟩
#align set.image2_swap Set.image2_swap
variable {f}
| Mathlib/Data/Set/NAry.lean | 103 | 104 | theorem image2_union_left : image2 f (s ∪ s') t = image2 f s t ∪ image2 f s' t := by |
simp_rw [← image_prod, union_prod, image_union]
|
/-
Copyright (c) 2021 Kexing Ying. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying
-/
import Mathlib.MeasureTheory.Measure.VectorMeasure
import Mathlib.MeasureTheory.Function.AEEqOfIntegral
#align_import measure_theory.measure.with_density_vector_measure from "leanprover-community/mathlib"@"d1bd9c5df2867c1cb463bc6364446d57bdd9f7f1"
/-!
# Vector measure defined by an integral
Given a measure `μ` and an integrable function `f : α → E`, we can define a vector measure `v` such
that for all measurable set `s`, `v i = ∫ x in s, f x ∂μ`. This definition is useful for
the Radon-Nikodym theorem for signed measures.
## Main definitions
* `MeasureTheory.Measure.withDensityᵥ`: the vector measure formed by integrating a function `f`
with respect to a measure `μ` on some set if `f` is integrable, and `0` otherwise.
-/
noncomputable section
open scoped Classical MeasureTheory NNReal ENNReal
variable {α β : Type*} {m : MeasurableSpace α}
namespace MeasureTheory
open TopologicalSpace
variable {μ ν : Measure α}
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
/-- Given a measure `μ` and an integrable function `f`, `μ.withDensityᵥ f` is
the vector measure which maps the set `s` to `∫ₛ f ∂μ`. -/
def Measure.withDensityᵥ {m : MeasurableSpace α} (μ : Measure α) (f : α → E) : VectorMeasure α E :=
if hf : Integrable f μ then
{ measureOf' := fun s => if MeasurableSet s then ∫ x in s, f x ∂μ else 0
empty' := by simp
not_measurable' := fun s hs => if_neg hs
m_iUnion' := fun s hs₁ hs₂ => by
dsimp only
convert hasSum_integral_iUnion hs₁ hs₂ hf.integrableOn with n
· rw [if_pos (hs₁ n)]
· rw [if_pos (MeasurableSet.iUnion hs₁)] }
else 0
#align measure_theory.measure.with_densityᵥ MeasureTheory.Measure.withDensityᵥ
open Measure
variable {f g : α → E}
theorem withDensityᵥ_apply (hf : Integrable f μ) {s : Set α} (hs : MeasurableSet s) :
μ.withDensityᵥ f s = ∫ x in s, f x ∂μ := by rw [withDensityᵥ, dif_pos hf]; exact dif_pos hs
#align measure_theory.with_densityᵥ_apply MeasureTheory.withDensityᵥ_apply
@[simp]
theorem withDensityᵥ_zero : μ.withDensityᵥ (0 : α → E) = 0 := by
ext1 s hs; erw [withDensityᵥ_apply (integrable_zero α E μ) hs]; simp
#align measure_theory.with_densityᵥ_zero MeasureTheory.withDensityᵥ_zero
@[simp]
| Mathlib/MeasureTheory/Measure/WithDensityVectorMeasure.lean | 69 | 76 | theorem withDensityᵥ_neg : μ.withDensityᵥ (-f) = -μ.withDensityᵥ f := by |
by_cases hf : Integrable f μ
· ext1 i hi
rw [VectorMeasure.neg_apply, withDensityᵥ_apply hf hi, ← integral_neg,
withDensityᵥ_apply hf.neg hi]
rfl
· rw [withDensityᵥ, withDensityᵥ, dif_neg hf, dif_neg, neg_zero]
rwa [integrable_neg_iff]
|
/-
Copyright (c) 2022 Riccardo Brasca. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Riccardo Brasca, Eric Rodriguez
-/
import Mathlib.NumberTheory.NumberField.Basic
import Mathlib.RingTheory.Localization.NormTrace
#align_import number_theory.number_field.norm from "leanprover-community/mathlib"@"00f91228655eecdcd3ac97a7fd8dbcb139fe990a"
/-!
# Norm in number fields
Given a finite extension of number fields, we define the norm morphism as a function between the
rings of integers.
## Main definitions
* `RingOfIntegers.norm K` : `Algebra.norm` as a morphism `(𝓞 L) →* (𝓞 K)`.
## Main results
* `RingOfIntegers.dvd_norm` : if `L/K` is a finite Galois extension of fields, then, for all
`(x : 𝓞 L)` we have that `x ∣ algebraMap (𝓞 K) (𝓞 L) (norm K x)`.
-/
open scoped NumberField
open Finset NumberField Algebra FiniteDimensional
section Rat
variable {K : Type*} [Field K] [NumberField K] (x : 𝓞 K)
theorem Algebra.coe_norm_int : (Algebra.norm ℤ x : ℚ) = Algebra.norm ℚ (x : K) :=
(Algebra.norm_localization (R := ℤ) (Rₘ := ℚ) (S := 𝓞 K) (Sₘ := K) (nonZeroDivisors ℤ) x).symm
theorem Algebra.coe_trace_int : (Algebra.trace ℤ _ x : ℚ) = Algebra.trace ℚ K (x : K) :=
(Algebra.trace_localization (R := ℤ) (Rₘ := ℚ) (S := 𝓞 K) (Sₘ := K) (nonZeroDivisors ℤ) x).symm
end Rat
namespace RingOfIntegers
variable {L : Type*} (K : Type*) [Field K] [Field L] [Algebra K L] [FiniteDimensional K L]
/-- `Algebra.norm` as a morphism betwen the rings of integers. -/
noncomputable def norm [IsSeparable K L] : 𝓞 L →* 𝓞 K :=
RingOfIntegers.restrict_monoidHom
((Algebra.norm K).comp (algebraMap (𝓞 L) L : (𝓞 L) →* L))
fun x => isIntegral_norm K x.2
#align ring_of_integers.norm RingOfIntegers.norm
@[simp] lemma coe_norm [IsSeparable K L] (x : 𝓞 L) :
norm K x = Algebra.norm K (x : L) := rfl
theorem coe_algebraMap_norm [IsSeparable K L] (x : 𝓞 L) :
(algebraMap (𝓞 K) (𝓞 L) (norm K x) : L) = algebraMap K L (Algebra.norm K (x : L)) :=
rfl
#align ring_of_integers.coe_algebra_map_norm RingOfIntegers.coe_algebraMap_norm
theorem algebraMap_norm_algebraMap [IsSeparable K L] (x : 𝓞 K) :
algebraMap _ K (norm K (algebraMap (𝓞 K) (𝓞 L) x)) =
Algebra.norm K (algebraMap K L (algebraMap _ _ x)) := rfl
#align ring_of_integers.coe_norm_algebra_map RingOfIntegers.algebraMap_norm_algebraMap
theorem norm_algebraMap [IsSeparable K L] (x : 𝓞 K) :
norm K (algebraMap (𝓞 K) (𝓞 L) x) = x ^ finrank K L := by
rw [RingOfIntegers.ext_iff, RingOfIntegers.coe_eq_algebraMap,
RingOfIntegers.algebraMap_norm_algebraMap, Algebra.norm_algebraMap,
RingOfIntegers.coe_eq_algebraMap, map_pow]
#align ring_of_integers.norm_algebra_map RingOfIntegers.norm_algebraMap
| Mathlib/NumberTheory/NumberField/Norm.lean | 72 | 85 | theorem isUnit_norm_of_isGalois [IsGalois K L] {x : 𝓞 L} : IsUnit (norm K x) ↔ IsUnit x := by |
classical
refine ⟨fun hx => ?_, IsUnit.map _⟩
replace hx : IsUnit (algebraMap (𝓞 K) (𝓞 L) <| norm K x) := hx.map (algebraMap (𝓞 K) <| 𝓞 L)
refine @isUnit_of_mul_isUnit_right (𝓞 L) _
⟨(univ \ {AlgEquiv.refl}).prod fun σ : L ≃ₐ[K] L => σ x,
prod_mem fun σ _ => x.2.map (σ : L →+* L).toIntAlgHom⟩ _ ?_
convert hx using 1
ext
convert_to ((univ \ {AlgEquiv.refl}).prod fun σ : L ≃ₐ[K] L => σ x) *
∏ σ ∈ {(AlgEquiv.refl : L ≃ₐ[K] L)}, σ x = _
· rw [prod_singleton, AlgEquiv.coe_refl, _root_.id, RingOfIntegers.coe_eq_algebraMap, map_mul,
RingOfIntegers.map_mk]
· rw [prod_sdiff <| subset_univ _, ← norm_eq_prod_automorphisms, coe_algebraMap_norm]
|
/-
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.Logic.Equiv.Defs
#align_import data.erased from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1"
/-!
# A type for VM-erased data
This file defines a type `Erased α` which is classically isomorphic to `α`,
but erased in the VM. That is, at runtime every value of `Erased α` is
represented as `0`, just like types and proofs.
-/
universe u
/-- `Erased α` is the same as `α`, except that the elements
of `Erased α` are erased in the VM in the same way as types
and proofs. This can be used to track data without storing it
literally. -/
def Erased (α : Sort u) : Sort max 1 u :=
Σ's : α → Prop, ∃ a, (fun b => a = b) = s
#align erased Erased
namespace Erased
/-- Erase a value. -/
@[inline]
def mk {α} (a : α) : Erased α :=
⟨fun b => a = b, a, rfl⟩
#align erased.mk Erased.mk
/-- Extracts the erased value, noncomputably. -/
noncomputable def out {α} : Erased α → α
| ⟨_, h⟩ => Classical.choose h
#align erased.out Erased.out
/-- Extracts the erased value, if it is a type.
Note: `(mk a).OutType` is not definitionally equal to `a`.
-/
abbrev OutType (a : Erased (Sort u)) : Sort u :=
out a
#align erased.out_type Erased.OutType
/-- Extracts the erased value, if it is a proof. -/
theorem out_proof {p : Prop} (a : Erased p) : p :=
out a
#align erased.out_proof Erased.out_proof
@[simp]
theorem out_mk {α} (a : α) : (mk a).out = a := by
let h := (mk a).2; show Classical.choose h = a
have := Classical.choose_spec h
exact cast (congr_fun this a).symm rfl
#align erased.out_mk Erased.out_mk
@[simp]
theorem mk_out {α} : ∀ a : Erased α, mk (out a) = a
| ⟨s, h⟩ => by simp only [mk]; congr; exact Classical.choose_spec h
#align erased.mk_out Erased.mk_out
@[ext]
theorem out_inj {α} (a b : Erased α) (h : a.out = b.out) : a = b := by simpa using congr_arg mk h
#align erased.out_inj Erased.out_inj
/-- Equivalence between `Erased α` and `α`. -/
noncomputable def equiv (α) : Erased α ≃ α :=
⟨out, mk, mk_out, out_mk⟩
#align erased.equiv Erased.equiv
instance (α : Type u) : Repr (Erased α) :=
⟨fun _ _ => "Erased"⟩
instance (α : Type u) : ToString (Erased α) :=
⟨fun _ => "Erased"⟩
-- Porting note: Deleted `has_to_format`
/-- Computably produce an erased value from a proof of nonemptiness. -/
def choice {α} (h : Nonempty α) : Erased α :=
mk (Classical.choice h)
#align erased.choice Erased.choice
@[simp]
theorem nonempty_iff {α} : Nonempty (Erased α) ↔ Nonempty α :=
⟨fun ⟨a⟩ => ⟨a.out⟩, fun ⟨a⟩ => ⟨mk a⟩⟩
#align erased.nonempty_iff Erased.nonempty_iff
instance {α} [h : Nonempty α] : Inhabited (Erased α) :=
⟨choice h⟩
/-- `(>>=)` operation on `Erased`.
This is a separate definition because `α` and `β` can live in different
universes (the universe is fixed in `Monad`).
-/
def bind {α β} (a : Erased α) (f : α → Erased β) : Erased β :=
⟨fun b => (f a.out).1 b, (f a.out).2⟩
#align erased.bind Erased.bind
@[simp]
theorem bind_eq_out {α β} (a f) : @bind α β a f = f a.out := rfl
#align erased.bind_eq_out Erased.bind_eq_out
/-- Collapses two levels of erasure.
-/
def join {α} (a : Erased (Erased α)) : Erased α :=
bind a id
#align erased.join Erased.join
@[simp]
theorem join_eq_out {α} (a) : @join α a = a.out :=
bind_eq_out _ _
#align erased.join_eq_out Erased.join_eq_out
/-- `(<$>)` operation on `Erased`.
This is a separate definition because `α` and `β` can live in different
universes (the universe is fixed in `Functor`).
-/
def map {α β} (f : α → β) (a : Erased α) : Erased β :=
bind a (mk ∘ f)
#align erased.map Erased.map
@[simp]
| Mathlib/Data/Erased.lean | 131 | 131 | theorem map_out {α β} {f : α → β} (a : Erased α) : (a.map f).out = f a.out := by | simp [map]
|
/-
Copyright (c) 2022 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-/
import Mathlib.ModelTheory.Satisfiability
import Mathlib.Combinatorics.SimpleGraph.Basic
#align_import model_theory.graph from "leanprover-community/mathlib"@"e56b8fea84d60fe434632b9d3b829ee685fb0c8f"
/-!
# First-Order Structures in Graph Theory
This file defines first-order languages, structures, and theories in graph theory.
## Main Definitions
* `FirstOrder.Language.graph` is the language consisting of a single relation representing
adjacency.
* `SimpleGraph.structure` is the first-order structure corresponding to a given simple graph.
* `FirstOrder.Language.Theory.simpleGraph` is the theory of simple graphs.
* `FirstOrder.Language.simpleGraphOfStructure` gives the simple graph corresponding to a model
of the theory of simple graphs.
-/
set_option linter.uppercaseLean3 false
universe u v w w'
namespace FirstOrder
namespace Language
open FirstOrder
open Structure
variable {L : Language.{u, v}} {α : Type w} {V : Type w'} {n : ℕ}
/-! ### Simple Graphs -/
/-- The language consisting of a single relation representing adjacency. -/
protected def graph : Language :=
Language.mk₂ Empty Empty Empty Empty Unit
#align first_order.language.graph FirstOrder.Language.graph
/-- The symbol representing the adjacency relation. -/
def adj : Language.graph.Relations 2 :=
Unit.unit
#align first_order.language.adj FirstOrder.Language.adj
/-- Any simple graph can be thought of as a structure in the language of graphs. -/
def _root_.SimpleGraph.structure (G : SimpleGraph V) : Language.graph.Structure V :=
Structure.mk₂ Empty.elim Empty.elim Empty.elim Empty.elim fun _ => G.Adj
#align simple_graph.Structure SimpleGraph.structure
namespace graph
instance instIsRelational : IsRelational Language.graph :=
Language.isRelational_mk₂
#align first_order.language.graph.first_order.language.is_relational FirstOrder.Language.graph.instIsRelational
instance instSubsingleton : Subsingleton (Language.graph.Relations n) :=
Language.subsingleton_mk₂_relations
#align first_order.language.graph.relations.subsingleton FirstOrder.Language.graph.instSubsingleton
end graph
/-- The theory of simple graphs. -/
protected def Theory.simpleGraph : Language.graph.Theory :=
{adj.irreflexive, adj.symmetric}
#align first_order.language.Theory.simple_graph FirstOrder.Language.Theory.simpleGraph
@[simp]
theorem Theory.simpleGraph_model_iff [Language.graph.Structure V] :
V ⊨ Theory.simpleGraph ↔
(Irreflexive fun x y : V => RelMap adj ![x, y]) ∧
Symmetric fun x y : V => RelMap adj ![x, y] := by
simp [Theory.simpleGraph]
#align first_order.language.Theory.simple_graph_model_iff FirstOrder.Language.Theory.simpleGraph_model_iff
instance simpleGraph_model (G : SimpleGraph V) :
@Theory.Model _ V G.structure Theory.simpleGraph := by
simp only [@Theory.simpleGraph_model_iff _ G.structure, relMap_apply₂]
exact ⟨G.loopless, G.symm⟩
#align first_order.language.simple_graph_model FirstOrder.Language.simpleGraph_model
variable (V)
/-- Any model of the theory of simple graphs represents a simple graph. -/
@[simps]
def simpleGraphOfStructure [Language.graph.Structure V] [V ⊨ Theory.simpleGraph] :
SimpleGraph V where
Adj x y := RelMap adj ![x, y]
symm :=
Relations.realize_symmetric.1
(Theory.realize_sentence_of_mem Theory.simpleGraph
(Set.mem_insert_of_mem _ (Set.mem_singleton _)))
loopless :=
Relations.realize_irreflexive.1
(Theory.realize_sentence_of_mem Theory.simpleGraph (Set.mem_insert _ _))
#align first_order.language.simple_graph_of_structure FirstOrder.Language.simpleGraphOfStructure
variable {V}
@[simp]
theorem _root_.SimpleGraph.simpleGraphOfStructure (G : SimpleGraph V) :
@simpleGraphOfStructure V G.structure _ = G := by
ext
rfl
#align simple_graph.simple_graph_of_structure SimpleGraph.simpleGraphOfStructure
@[simp]
| Mathlib/ModelTheory/Graph.lean | 114 | 130 | theorem structure_simpleGraphOfStructure [S : Language.graph.Structure V] [V ⊨ Theory.simpleGraph] :
(simpleGraphOfStructure V).structure = S := by |
ext
case funMap n f xs =>
exact (IsRelational.empty_functions n).elim f
case RelMap n r xs =>
rw [iff_eq_eq]
cases' n with n
· exact r.elim
· cases' n with n
· exact r.elim
· cases' n with n
· cases r
change RelMap adj ![xs 0, xs 1] = _
refine congr rfl (funext ?_)
simp [Fin.forall_fin_two]
· exact r.elim
|
/-
Copyright (c) 2022 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser, Jujian Zhang
-/
import Mathlib.Algebra.DirectSum.Module
import Mathlib.Algebra.Module.Submodule.Basic
#align_import algebra.direct_sum.decomposition from "leanprover-community/mathlib"@"4e861f25ba5ceef42ba0712d8ffeb32f38ad6441"
/-!
# Decompositions of additive monoids, groups, and modules into direct sums
## Main definitions
* `DirectSum.Decomposition ℳ`: A typeclass to provide a constructive decomposition from
an additive monoid `M` into a family of additive submonoids `ℳ`
* `DirectSum.decompose ℳ`: The canonical equivalence provided by the above typeclass
## Main statements
* `DirectSum.Decomposition.isInternal`: The link to `DirectSum.IsInternal`.
## Implementation details
As we want to talk about different types of decomposition (additive monoids, modules, rings, ...),
we choose to avoid heavily bundling `DirectSum.decompose`, instead making copies for the
`AddEquiv`, `LinearEquiv`, etc. This means we have to repeat statements that follow from these
bundled homs, but means we don't have to repeat statements for different types of decomposition.
-/
variable {ι R M σ : Type*}
open DirectSum
namespace DirectSum
section AddCommMonoid
variable [DecidableEq ι] [AddCommMonoid M]
variable [SetLike σ M] [AddSubmonoidClass σ M] (ℳ : ι → σ)
/-- A decomposition is an equivalence between an additive monoid `M` and a direct sum of additive
submonoids `ℳ i` of that `M`, such that the "recomposition" is canonical. This definition also
works for additive groups and modules.
This is a version of `DirectSum.IsInternal` which comes with a constructive inverse to the
canonical "recomposition" rather than just a proof that the "recomposition" is bijective.
Often it is easier to construct a term of this type via `Decomposition.ofAddHom` or
`Decomposition.ofLinearMap`. -/
class Decomposition where
decompose' : M → ⨁ i, ℳ i
left_inv : Function.LeftInverse (DirectSum.coeAddMonoidHom ℳ) decompose'
right_inv : Function.RightInverse (DirectSum.coeAddMonoidHom ℳ) decompose'
#align direct_sum.decomposition DirectSum.Decomposition
/-- `DirectSum.Decomposition` instances, while carrying data, are always equal. -/
instance : Subsingleton (Decomposition ℳ) :=
⟨fun x y ↦ by
cases' x with x xl xr
cases' y with y yl yr
congr
exact Function.LeftInverse.eq_rightInverse xr yl⟩
/-- A convenience method to construct a decomposition from an `AddMonoidHom`, such that the proofs
of left and right inverse can be constructed via `ext`. -/
abbrev Decomposition.ofAddHom (decompose : M →+ ⨁ i, ℳ i)
(h_left_inv : (DirectSum.coeAddMonoidHom ℳ).comp decompose = .id _)
(h_right_inv : decompose.comp (DirectSum.coeAddMonoidHom ℳ) = .id _) : Decomposition ℳ where
decompose' := decompose
left_inv := DFunLike.congr_fun h_left_inv
right_inv := DFunLike.congr_fun h_right_inv
/-- Noncomputably conjure a decomposition instance from a `DirectSum.IsInternal` proof. -/
noncomputable def IsInternal.chooseDecomposition (h : IsInternal ℳ) :
DirectSum.Decomposition ℳ where
decompose' := (Equiv.ofBijective _ h).symm
left_inv := (Equiv.ofBijective _ h).right_inv
right_inv := (Equiv.ofBijective _ h).left_inv
variable [Decomposition ℳ]
protected theorem Decomposition.isInternal : DirectSum.IsInternal ℳ :=
⟨Decomposition.right_inv.injective, Decomposition.left_inv.surjective⟩
#align direct_sum.decomposition.is_internal DirectSum.Decomposition.isInternal
/-- If `M` is graded by `ι` with degree `i` component `ℳ i`, then it is isomorphic as
to a direct sum of components. This is the canonical spelling of the `decompose'` field. -/
def decompose : M ≃ ⨁ i, ℳ i where
toFun := Decomposition.decompose'
invFun := DirectSum.coeAddMonoidHom ℳ
left_inv := Decomposition.left_inv
right_inv := Decomposition.right_inv
#align direct_sum.decompose DirectSum.decompose
protected theorem Decomposition.inductionOn {p : M → Prop} (h_zero : p 0)
(h_homogeneous : ∀ {i} (m : ℳ i), p (m : M)) (h_add : ∀ m m' : M, p m → p m' → p (m + m')) :
∀ m, p m := by
let ℳ' : ι → AddSubmonoid M := fun i ↦
(⟨⟨ℳ i, fun x y ↦ AddMemClass.add_mem x y⟩, (ZeroMemClass.zero_mem _)⟩ : AddSubmonoid M)
haveI t : DirectSum.Decomposition ℳ' :=
{ decompose' := DirectSum.decompose ℳ
left_inv := fun _ ↦ (decompose ℳ).left_inv _
right_inv := fun _ ↦ (decompose ℳ).right_inv _ }
have mem : ∀ m, m ∈ iSup ℳ' := fun _m ↦
(DirectSum.IsInternal.addSubmonoid_iSup_eq_top ℳ' (Decomposition.isInternal ℳ')).symm ▸ trivial
-- Porting note: needs to use @ even though no implicit argument is provided
exact fun m ↦ @AddSubmonoid.iSup_induction _ _ _ ℳ' _ _ (mem m)
(fun i m h ↦ h_homogeneous ⟨m, h⟩) h_zero h_add
-- exact fun m ↦
-- AddSubmonoid.iSup_induction ℳ' (mem m) (fun i m h ↦ h_homogeneous ⟨m, h⟩) h_zero h_add
#align direct_sum.decomposition.induction_on DirectSum.Decomposition.inductionOn
@[simp]
theorem Decomposition.decompose'_eq : Decomposition.decompose' = decompose ℳ := rfl
#align direct_sum.decomposition.decompose'_eq DirectSum.Decomposition.decompose'_eq
@[simp]
theorem decompose_symm_of {i : ι} (x : ℳ i) : (decompose ℳ).symm (DirectSum.of _ i x) = x :=
DirectSum.coeAddMonoidHom_of ℳ _ _
#align direct_sum.decompose_symm_of DirectSum.decompose_symm_of
@[simp]
| Mathlib/Algebra/DirectSum/Decomposition.lean | 127 | 128 | theorem decompose_coe {i : ι} (x : ℳ i) : decompose ℳ (x : M) = DirectSum.of _ i x := by |
rw [← decompose_symm_of _, Equiv.apply_symm_apply]
|
/-
Copyright (c) 2020 Kenji Nakagawa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenji Nakagawa, Anne Baanen, Filippo A. E. Nuccio
-/
import Mathlib.LinearAlgebra.FreeModule.PID
import Mathlib.LinearAlgebra.FreeModule.Finite.Basic
import Mathlib.LinearAlgebra.BilinearForm.DualLattice
import Mathlib.RingTheory.DedekindDomain.Basic
import Mathlib.RingTheory.Localization.Module
import Mathlib.RingTheory.Trace
#align_import ring_theory.dedekind_domain.integral_closure from "leanprover-community/mathlib"@"4cf7ca0e69e048b006674cf4499e5c7d296a89e0"
/-!
# Integral closure of Dedekind domains
This file shows the integral closure of a Dedekind domain (in particular, the ring of integers
of a number field) is a Dedekind domain.
## Implementation notes
The definitions that involve a field of fractions choose a canonical field of fractions,
but are independent of that choice. The `..._iff` lemmas express this independence.
Often, definitions assume that Dedekind domains are not fields. We found it more practical
to add a `(h : ¬IsField A)` assumption whenever this is explicitly needed.
## References
* [D. Marcus, *Number Fields*][marcus1977number]
* [J.W.S. Cassels, A. Frölich, *Algebraic Number Theory*][cassels1967algebraic]
* [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]
## Tags
dedekind domain, dedekind ring
-/
variable (R A K : Type*) [CommRing R] [CommRing A] [Field K]
open scoped nonZeroDivisors Polynomial
variable [IsDomain A]
section IsIntegralClosure
/-! ### `IsIntegralClosure` section
We show that an integral closure of a Dedekind domain in a finite separable
field extension is again a Dedekind domain. This implies the ring of integers
of a number field is a Dedekind domain. -/
open Algebra
variable [Algebra A K] [IsFractionRing A K]
variable (L : Type*) [Field L] (C : Type*) [CommRing C]
variable [Algebra K L] [Algebra A L] [IsScalarTower A K L]
variable [Algebra C L] [IsIntegralClosure C A L] [Algebra A C] [IsScalarTower A C L]
/-- If `L` is an algebraic extension of `K = Frac(A)` and `L` has no zero smul divisors by `A`,
then `L` is the localization of the integral closure `C` of `A` in `L` at `A⁰`. -/
| Mathlib/RingTheory/DedekindDomain/IntegralClosure.lean | 65 | 83 | theorem IsIntegralClosure.isLocalization [Algebra.IsAlgebraic K L] :
IsLocalization (Algebra.algebraMapSubmonoid C A⁰) L := by |
haveI : IsDomain C :=
(IsIntegralClosure.equiv A C L (integralClosure A L)).toMulEquiv.isDomain (integralClosure A L)
haveI : NoZeroSMulDivisors A L := NoZeroSMulDivisors.trans A K L
haveI : NoZeroSMulDivisors A C := IsIntegralClosure.noZeroSMulDivisors A L
refine ⟨?_, fun z => ?_, fun {x y} h => ⟨1, ?_⟩⟩
· rintro ⟨_, x, hx, rfl⟩
rw [isUnit_iff_ne_zero, map_ne_zero_iff _ (IsIntegralClosure.algebraMap_injective C A L),
Subtype.coe_mk, map_ne_zero_iff _ (NoZeroSMulDivisors.algebraMap_injective A C)]
exact mem_nonZeroDivisors_iff_ne_zero.mp hx
· obtain ⟨m, hm⟩ :=
IsIntegral.exists_multiple_integral_of_isLocalization A⁰ z
(Algebra.IsIntegral.isIntegral (R := K) z)
obtain ⟨x, hx⟩ : ∃ x, algebraMap C L x = m • z := IsIntegralClosure.isIntegral_iff.mp hm
refine ⟨⟨x, algebraMap A C m, m, SetLike.coe_mem m, rfl⟩, ?_⟩
rw [Subtype.coe_mk, ← IsScalarTower.algebraMap_apply, hx, mul_comm, Submonoid.smul_def,
smul_def]
· simp only [IsIntegralClosure.algebraMap_injective C A L h]
|
/-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Algebra.BigOperators.Finsupp
import Mathlib.Data.Finset.Pointwise
import Mathlib.Data.Finsupp.Indicator
import Mathlib.Data.Fintype.BigOperators
#align_import data.finset.finsupp from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf"
/-!
# Finitely supported product of finsets
This file defines the finitely supported product of finsets as a `Finset (ι →₀ α)`.
## Main declarations
* `Finset.finsupp`: Finitely supported product of finsets. `s.finset t` is the product of the `t i`
over all `i ∈ s`.
* `Finsupp.pi`: `f.pi` is the finset of `Finsupp`s whose `i`-th value lies in `f i`. This is the
special case of `Finset.finsupp` where we take the product of the `f i` over the support of `f`.
## Implementation notes
We make heavy use of the fact that `0 : Finset α` is `{0}`. This scalar actions convention turns out
to be precisely what we want here too.
-/
noncomputable section
open Finsupp
open scoped Classical
open Pointwise
variable {ι α : Type*} [Zero α] {s : Finset ι} {f : ι →₀ α}
namespace Finset
/-- Finitely supported product of finsets. -/
protected def finsupp (s : Finset ι) (t : ι → Finset α) : Finset (ι →₀ α) :=
(s.pi t).map ⟨indicator s, indicator_injective s⟩
#align finset.finsupp Finset.finsupp
theorem mem_finsupp_iff {t : ι → Finset α} :
f ∈ s.finsupp t ↔ f.support ⊆ s ∧ ∀ i ∈ s, f i ∈ t i := by
refine mem_map.trans ⟨?_, ?_⟩
· rintro ⟨f, hf, rfl⟩
refine ⟨support_indicator_subset _ _, fun i hi => ?_⟩
convert mem_pi.1 hf i hi
exact indicator_of_mem hi _
· refine fun h => ⟨fun i _ => f i, mem_pi.2 h.2, ?_⟩
ext i
exact ite_eq_left_iff.2 fun hi => (not_mem_support_iff.1 fun H => hi <| h.1 H).symm
#align finset.mem_finsupp_iff Finset.mem_finsupp_iff
/-- When `t` is supported on `s`, `f ∈ s.finsupp t` precisely means that `f` is pointwise in `t`. -/
@[simp]
theorem mem_finsupp_iff_of_support_subset {t : ι →₀ Finset α} (ht : t.support ⊆ s) :
f ∈ s.finsupp t ↔ ∀ i, f i ∈ t i := by
refine
mem_finsupp_iff.trans
(forall_and.symm.trans <|
forall_congr' fun i =>
⟨fun h => ?_, fun h =>
⟨fun hi => ht <| mem_support_iff.2 fun H => mem_support_iff.1 hi ?_, fun _ => h⟩⟩)
· by_cases hi : i ∈ s
· exact h.2 hi
· rw [not_mem_support_iff.1 (mt h.1 hi), not_mem_support_iff.1 fun H => hi <| ht H]
exact zero_mem_zero
· rwa [H, mem_zero] at h
#align finset.mem_finsupp_iff_of_support_subset Finset.mem_finsupp_iff_of_support_subset
@[simp]
theorem card_finsupp (s : Finset ι) (t : ι → Finset α) :
(s.finsupp t).card = ∏ i ∈ s, (t i).card :=
(card_map _).trans <| card_pi _ _
#align finset.card_finsupp Finset.card_finsupp
end Finset
open Finset
namespace Finsupp
/-- Given a finitely supported function `f : ι →₀ Finset α`, one can define the finset
`f.pi` of all finitely supported functions whose value at `i` is in `f i` for all `i`. -/
def pi (f : ι →₀ Finset α) : Finset (ι →₀ α) :=
f.support.finsupp f
#align finsupp.pi Finsupp.pi
@[simp]
theorem mem_pi {f : ι →₀ Finset α} {g : ι →₀ α} : g ∈ f.pi ↔ ∀ i, g i ∈ f i :=
mem_finsupp_iff_of_support_subset <| Subset.refl _
#align finsupp.mem_pi Finsupp.mem_pi
@[simp]
| Mathlib/Data/Finset/Finsupp.lean | 101 | 103 | theorem card_pi (f : ι →₀ Finset α) : f.pi.card = f.prod fun i => (f i).card := by |
rw [pi, card_finsupp]
exact Finset.prod_congr rfl fun i _ => by simp only [Pi.natCast_apply, Nat.cast_id]
|
/-
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.Dynamics.BirkhoffSum.Basic
import Mathlib.Algebra.Module.Basic
/-!
# Birkhoff average
In this file we define `birkhoffAverage f g n x` to be
$$
\frac{1}{n}\sum_{k=0}^{n-1}g(f^{[k]}(x)),
$$
where `f : α → α` is a self-map on some type `α`,
`g : α → M` is a function from `α` to a module over a division semiring `R`,
and `R` is used to formalize division by `n` as `(n : R)⁻¹ • _`.
While we need an auxiliary division semiring `R` to define `birkhoffAverage`,
the definition does not depend on the choice of `R`,
see `birkhoffAverage_congr_ring`.
-/
open Finset
section birkhoffAverage
variable (R : Type*) {α M : Type*} [DivisionSemiring R] [AddCommMonoid M] [Module R M]
/-- The average value of `g` on the first `n` points of the orbit of `x` under `f`,
i.e. the Birkhoff sum `∑ k ∈ Finset.range n, g (f^[k] x)` divided by `n`.
This average appears in many ergodic theorems
which say that `(birkhoffAverage R f g · x)`
converges to the "space average" `⨍ x, g x ∂μ` as `n → ∞`.
We use an auxiliary `[DivisionSemiring R]` to define division by `n`.
However, the definition does not depend on the choice of `R`,
see `birkhoffAverage_congr_ring`. -/
def birkhoffAverage (f : α → α) (g : α → M) (n : ℕ) (x : α) : M := (n : R)⁻¹ • birkhoffSum f g n x
theorem birkhoffAverage_zero (f : α → α) (g : α → M) (x : α) :
birkhoffAverage R f g 0 x = 0 := by simp [birkhoffAverage]
@[simp] theorem birkhoffAverage_zero' (f : α → α) (g : α → M) : birkhoffAverage R f g 0 = 0 :=
funext <| birkhoffAverage_zero _ _ _
theorem birkhoffAverage_one (f : α → α) (g : α → M) (x : α) :
birkhoffAverage R f g 1 x = g x := by simp [birkhoffAverage]
@[simp]
theorem birkhoffAverage_one' (f : α → α) (g : α → M) : birkhoffAverage R f g 1 = g :=
funext <| birkhoffAverage_one R f g
theorem map_birkhoffAverage (S : Type*) {F N : Type*}
[DivisionSemiring S] [AddCommMonoid N] [Module S N] [FunLike F M N]
[AddMonoidHomClass F M N] (g' : F) (f : α → α) (g : α → M) (n : ℕ) (x : α) :
g' (birkhoffAverage R f g n x) = birkhoffAverage S f (g' ∘ g) n x := by
simp only [birkhoffAverage, map_inv_natCast_smul g' R S, map_birkhoffSum]
theorem birkhoffAverage_congr_ring (S : Type*) [DivisionSemiring S] [Module S M]
(f : α → α) (g : α → M) (n : ℕ) (x : α) :
birkhoffAverage R f g n x = birkhoffAverage S f g n x :=
map_birkhoffAverage R S (AddMonoidHom.id M) f g n x
theorem birkhoffAverage_congr_ring' (S : Type*) [DivisionSemiring S] [Module S M] :
birkhoffAverage (α := α) (M := M) R = birkhoffAverage S := by
ext; apply birkhoffAverage_congr_ring
theorem Function.IsFixedPt.birkhoffAverage_eq [CharZero R] {f : α → α} {x : α} (h : IsFixedPt f x)
(g : α → M) {n : ℕ} (hn : n ≠ 0) : birkhoffAverage R f g n x = g x := by
rw [birkhoffAverage, h.birkhoffSum_eq, nsmul_eq_smul_cast R, inv_smul_smul₀]
rwa [Nat.cast_ne_zero]
end birkhoffAverage
/-- Birkhoff average is "almost invariant" under `f`:
the difference between `birkhoffAverage R f g n (f x)` and `birkhoffAverage R f g n x`
is equal to `(n : R)⁻¹ • (g (f^[n] x) - g x)`. -/
| Mathlib/Dynamics/BirkhoffSum/Average.lean | 82 | 86 | theorem birkhoffAverage_apply_sub_birkhoffAverage {α M : Type*} (R : Type*) [DivisionRing R]
[AddCommGroup M] [Module R M] (f : α → α) (g : α → M) (n : ℕ) (x : α) :
birkhoffAverage R f g n (f x) - birkhoffAverage R f g n x =
(n : R)⁻¹ • (g (f^[n] x) - g x) := by |
simp only [birkhoffAverage, birkhoffSum_apply_sub_birkhoffSum, ← smul_sub]
|
/-
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.LinearAlgebra.Span
import Mathlib.RingTheory.Ideal.IsPrimary
import Mathlib.RingTheory.Ideal.QuotientOperations
import Mathlib.RingTheory.Noetherian
#align_import ring_theory.ideal.associated_prime from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
/-!
# Associated primes of a module
We provide the definition and related lemmas about associated primes of modules.
## Main definition
- `IsAssociatedPrime`: `IsAssociatedPrime I M` if the prime ideal `I` is the
annihilator of some `x : M`.
- `associatedPrimes`: The set of associated primes of a module.
## Main results
- `exists_le_isAssociatedPrime_of_isNoetherianRing`: In a noetherian ring, any `ann(x)` is
contained in an associated prime for `x ≠ 0`.
- `associatedPrimes.eq_singleton_of_isPrimary`: In a noetherian ring, `I.radical` is the only
associated prime of `R ⧸ I` when `I` is primary.
## Todo
Generalize this to a non-commutative setting once there are annihilator for non-commutative rings.
-/
variable {R : Type*} [CommRing R] (I J : Ideal R) (M : Type*) [AddCommGroup M] [Module R M]
/-- `IsAssociatedPrime I M` if the prime ideal `I` is the annihilator of some `x : M`. -/
def IsAssociatedPrime : Prop :=
I.IsPrime ∧ ∃ x : M, I = (R ∙ x).annihilator
#align is_associated_prime IsAssociatedPrime
variable (R)
/-- The set of associated primes of a module. -/
def associatedPrimes : Set (Ideal R) :=
{ I | IsAssociatedPrime I M }
#align associated_primes associatedPrimes
variable {I J M R}
variable {M' : Type*} [AddCommGroup M'] [Module R M'] (f : M →ₗ[R] M')
theorem AssociatePrimes.mem_iff : I ∈ associatedPrimes R M ↔ IsAssociatedPrime I M := Iff.rfl
#align associate_primes.mem_iff AssociatePrimes.mem_iff
theorem IsAssociatedPrime.isPrime (h : IsAssociatedPrime I M) : I.IsPrime := h.1
#align is_associated_prime.is_prime IsAssociatedPrime.isPrime
theorem IsAssociatedPrime.map_of_injective (h : IsAssociatedPrime I M) (hf : Function.Injective f) :
IsAssociatedPrime I M' := by
obtain ⟨x, rfl⟩ := h.2
refine ⟨h.1, ⟨f x, ?_⟩⟩
ext r
rw [Submodule.mem_annihilator_span_singleton, Submodule.mem_annihilator_span_singleton, ←
map_smul, ← f.map_zero, hf.eq_iff]
#align is_associated_prime.map_of_injective IsAssociatedPrime.map_of_injective
theorem LinearEquiv.isAssociatedPrime_iff (l : M ≃ₗ[R] M') :
IsAssociatedPrime I M ↔ IsAssociatedPrime I M' :=
⟨fun h => h.map_of_injective l l.injective,
fun h => h.map_of_injective l.symm l.symm.injective⟩
#align linear_equiv.is_associated_prime_iff LinearEquiv.isAssociatedPrime_iff
| Mathlib/RingTheory/Ideal/AssociatedPrime.lean | 74 | 78 | theorem not_isAssociatedPrime_of_subsingleton [Subsingleton M] : ¬IsAssociatedPrime I M := by |
rintro ⟨hI, x, hx⟩
apply hI.ne_top
rwa [Subsingleton.elim x 0, Submodule.span_singleton_eq_bot.mpr rfl, Submodule.annihilator_bot]
at hx
|
/-
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.MeasureTheory.Measure.Typeclasses
import Mathlib.MeasureTheory.Measure.MutuallySingular
import Mathlib.MeasureTheory.MeasurableSpace.CountablyGenerated
/-!
# Dirac measure
In this file we define the Dirac measure `MeasureTheory.Measure.dirac a`
and prove some basic facts about it.
-/
open Function Set
open scoped ENNReal Classical
noncomputable section
variable {α β δ : Type*} [MeasurableSpace α] [MeasurableSpace β] {s : Set α} {a : α}
namespace MeasureTheory
namespace Measure
/-- The dirac measure. -/
def dirac (a : α) : Measure α := (OuterMeasure.dirac a).toMeasure (by simp)
#align measure_theory.measure.dirac MeasureTheory.Measure.dirac
instance : MeasureSpace PUnit :=
⟨dirac PUnit.unit⟩
theorem le_dirac_apply {a} : s.indicator 1 a ≤ dirac a s :=
OuterMeasure.dirac_apply a s ▸ le_toMeasure_apply _ _ _
#align measure_theory.measure.le_dirac_apply MeasureTheory.Measure.le_dirac_apply
@[simp]
theorem dirac_apply' (a : α) (hs : MeasurableSet s) : dirac a s = s.indicator 1 a :=
toMeasure_apply _ _ hs
#align measure_theory.measure.dirac_apply' MeasureTheory.Measure.dirac_apply'
@[simp]
| Mathlib/MeasureTheory/Measure/Dirac.lean | 45 | 49 | theorem dirac_apply_of_mem {a : α} (h : a ∈ s) : dirac a s = 1 := by |
have : ∀ t : Set α, a ∈ t → t.indicator (1 : α → ℝ≥0∞) a = 1 := fun t ht => indicator_of_mem ht 1
refine le_antisymm (this univ trivial ▸ ?_) (this s h ▸ le_dirac_apply)
rw [← dirac_apply' a MeasurableSet.univ]
exact measure_mono (subset_univ s)
|
/-
Copyright (c) 2024 Ira Fesefeldt. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Ira Fesefeldt
-/
import Mathlib.SetTheory.Ordinal.Arithmetic
/-!
# Ordinal Approximants for the Fixed points on complete lattices
This file sets up the ordinal approximation theory of fixed points
of a monotone function in a complete lattice [Cousot1979].
The proof follows loosely the one from [Echenique2005].
However, the proof given here is not constructive as we use the non-constructive axiomatization of
ordinals from mathlib. It still allows an approximation scheme indexed over the ordinals.
## Main definitions
* `OrdinalApprox.lfpApprox`: The ordinal approximation of the least fixed point
greater or equal then an initial value of a bundled monotone function.
* `OrdinalApprox.gfpApprox`: The ordinal approximation of the greatest fixed point
less or equal then an initial value of a bundled monotone function.
## Main theorems
* `OrdinalApprox.lfp_mem_range_lfpApprox`: The approximation of
the least fixed point eventually reaches the least fixed point
* `OrdinalApprox.gfp_mem_range_gfpApprox`: The approximation of
the greatest fixed point eventually reaches the greatest fixed point
## References
* [F. Echenique, *A short and constructive proof of Tarski’s fixed-point theorem*][Echenique2005]
* [P. Cousot & R. Cousot, *Constructive Versions of Tarski's Fixed Point Theorems*][Cousot1979]
## Tags
fixed point, complete lattice, monotone function, ordinals, approximation
-/
namespace Cardinal
universe u
variable {α : Type u}
variable (g : Ordinal → α)
open Cardinal Ordinal SuccOrder Function Set
theorem not_injective_limitation_set : ¬ InjOn g (Iio (ord <| succ #α)) := by
intro h_inj
have h := lift_mk_le_lift_mk_of_injective <| injOn_iff_injective.1 h_inj
have mk_initialSeg_subtype :
#(Iio (ord <| succ #α)) = lift.{u + 1} (succ #α) := by
simpa only [coe_setOf, card_typein, card_ord] using mk_initialSeg (ord <| succ #α)
rw [mk_initialSeg_subtype, lift_lift, lift_le] at h
exact not_le_of_lt (Order.lt_succ #α) h
end Cardinal
namespace OrdinalApprox
universe u
variable {α : Type u}
variable [CompleteLattice α] (f : α →o α) (x : α)
open Function fixedPoints Cardinal Order OrderHom
set_option linter.unusedVariables false in
/-- Ordinal approximants of the least fixed point greater then an initial value x -/
def lfpApprox (a : Ordinal.{u}) : α :=
sSup ({ f (lfpApprox b) | (b : Ordinal) (h : b < a) } ∪ {x})
termination_by a
decreasing_by exact h
| Mathlib/SetTheory/Ordinal/FixedPointApproximants.lean | 77 | 85 | theorem lfpApprox_monotone : Monotone (lfpApprox f x) := by |
unfold Monotone; intros a b h; unfold lfpApprox
refine sSup_le_sSup ?h
apply sup_le_sup_right
simp only [exists_prop, Set.le_eq_subset, Set.setOf_subset_setOf, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂]
intros a' h'
use a'
exact ⟨lt_of_lt_of_le h' h, rfl⟩
|
/-
Copyright (c) 2022 Rémi Bottinelli. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rémi Bottinelli
-/
import Mathlib.CategoryTheory.Category.Basic
import Mathlib.CategoryTheory.Functor.Basic
import Mathlib.CategoryTheory.Groupoid
import Mathlib.Tactic.NthRewrite
import Mathlib.CategoryTheory.PathCategory
import Mathlib.CategoryTheory.Quotient
import Mathlib.Combinatorics.Quiver.Symmetric
#align_import category_theory.groupoid.free_groupoid from "leanprover-community/mathlib"@"706d88f2b8fdfeb0b22796433d7a6c1a010af9f2"
/-!
# Free groupoid on a quiver
This file defines the free groupoid on a quiver, the lifting of a prefunctor to its unique
extension as a functor from the free groupoid, and proves uniqueness of this extension.
## Main results
Given the type `V` and a quiver instance on `V`:
- `FreeGroupoid V`: a type synonym for `V`.
- `FreeGroupoid.instGroupoid`: the `Groupoid` instance on `FreeGroupoid V`.
- `lift`: the lifting of a prefunctor from `V` to `V'` where `V'` is a groupoid, to a functor.
`FreeGroupoid V ⥤ V'`.
- `lift_spec` and `lift_unique`: the proofs that, respectively, `lift` indeed is a lifting
and is the unique one.
## Implementation notes
The free groupoid is first defined by symmetrifying the quiver, taking the induced path category
and finally quotienting by the reducibility relation.
-/
open Set Classical Function
attribute [local instance] propDecidable
namespace CategoryTheory
namespace Groupoid
namespace Free
universe u v u' v' u'' v''
variable {V : Type u} [Quiver.{v + 1} V]
/-- Shorthand for the "forward" arrow corresponding to `f` in `paths <| symmetrify V` -/
abbrev _root_.Quiver.Hom.toPosPath {X Y : V} (f : X ⟶ Y) :
(CategoryTheory.Paths.categoryPaths <| Quiver.Symmetrify V).Hom X Y :=
f.toPos.toPath
#align category_theory.groupoid.free.quiver.hom.to_pos_path Quiver.Hom.toPosPath
/-- Shorthand for the "forward" arrow corresponding to `f` in `paths <| symmetrify V` -/
abbrev _root_.Quiver.Hom.toNegPath {X Y : V} (f : X ⟶ Y) :
(CategoryTheory.Paths.categoryPaths <| Quiver.Symmetrify V).Hom Y X :=
f.toNeg.toPath
#align category_theory.groupoid.free.quiver.hom.to_neg_path Quiver.Hom.toNegPath
/-- The "reduction" relation -/
inductive redStep : HomRel (Paths (Quiver.Symmetrify V))
| step (X Z : Quiver.Symmetrify V) (f : X ⟶ Z) :
redStep (𝟙 (Paths.of.obj X)) (f.toPath ≫ (Quiver.reverse f).toPath)
#align category_theory.groupoid.free.red_step CategoryTheory.Groupoid.Free.redStep
/-- The underlying vertices of the free groupoid -/
def _root_.CategoryTheory.FreeGroupoid (V) [Q : Quiver V] :=
Quotient (@redStep V Q)
#align category_theory.free_groupoid CategoryTheory.FreeGroupoid
instance {V} [Quiver V] [Nonempty V] : Nonempty (FreeGroupoid V) := by
inhabit V; exact ⟨⟨@default V _⟩⟩
theorem congr_reverse {X Y : Paths <| Quiver.Symmetrify V} (p q : X ⟶ Y) :
Quotient.CompClosure redStep p q → Quotient.CompClosure redStep p.reverse q.reverse := by
rintro ⟨XW, pp, qq, WY, _, Z, f⟩
have : Quotient.CompClosure redStep (WY.reverse ≫ 𝟙 _ ≫ XW.reverse)
(WY.reverse ≫ (f.toPath ≫ (Quiver.reverse f).toPath) ≫ XW.reverse) := by
constructor
constructor
simpa only [CategoryStruct.comp, CategoryStruct.id, Quiver.Path.reverse, Quiver.Path.nil_comp,
Quiver.Path.reverse_comp, Quiver.reverse_reverse, Quiver.Path.reverse_toPath,
Quiver.Path.comp_assoc] using this
#align category_theory.groupoid.free.congr_reverse CategoryTheory.Groupoid.Free.congr_reverse
theorem congr_comp_reverse {X Y : Paths <| Quiver.Symmetrify V} (p : X ⟶ Y) :
Quot.mk (@Quotient.CompClosure _ _ redStep _ _) (p ≫ p.reverse) =
Quot.mk (@Quotient.CompClosure _ _ redStep _ _) (𝟙 X) := by
apply Quot.EqvGen_sound
induction' p with a b q f ih
· apply EqvGen.refl
· simp only [Quiver.Path.reverse]
fapply EqvGen.trans
-- Porting note: `Quiver.Path.*` and `Quiver.Hom.*` notation not working
· exact q ≫ Quiver.Path.reverse q
· apply EqvGen.symm
apply EqvGen.rel
have : Quotient.CompClosure redStep (q ≫ 𝟙 _ ≫ Quiver.Path.reverse q)
(q ≫ (Quiver.Hom.toPath f ≫ Quiver.Hom.toPath (Quiver.reverse f)) ≫
Quiver.Path.reverse q) := by
apply Quotient.CompClosure.intro
apply redStep.step
simp only [Category.assoc, Category.id_comp] at this ⊢
-- Porting note: `simp` cannot see how `Quiver.Path.comp_assoc` is relevant, so change to
-- category notation
change Quotient.CompClosure redStep (q ≫ Quiver.Path.reverse q)
(Quiver.Path.cons q f ≫ (Quiver.Hom.toPath (Quiver.reverse f)) ≫ (Quiver.Path.reverse q))
simp only [← Category.assoc] at this ⊢
exact this
· exact ih
#align category_theory.groupoid.free.congr_comp_reverse CategoryTheory.Groupoid.Free.congr_comp_reverse
| Mathlib/CategoryTheory/Groupoid/FreeGroupoid.lean | 120 | 124 | theorem congr_reverse_comp {X Y : Paths <| Quiver.Symmetrify V} (p : X ⟶ Y) :
Quot.mk (@Quotient.CompClosure _ _ redStep _ _) (p.reverse ≫ p) =
Quot.mk (@Quotient.CompClosure _ _ redStep _ _) (𝟙 Y) := by |
nth_rw 2 [← Quiver.Path.reverse_reverse p]
apply congr_comp_reverse
|
/-
Copyright (c) 2021 Bryan Gin-ge Chen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Adam Topaz, Bryan Gin-ge Chen, Yaël Dillies
-/
import Mathlib.Order.BooleanAlgebra
import Mathlib.Logic.Equiv.Basic
#align_import order.symm_diff from "leanprover-community/mathlib"@"6eb334bd8f3433d5b08ba156b8ec3e6af47e1904"
/-!
# Symmetric difference and bi-implication
This file defines the symmetric difference and bi-implication operators in (co-)Heyting algebras.
## Examples
Some examples are
* The symmetric difference of two sets is the set of elements that are in either but not both.
* The symmetric difference on propositions is `Xor'`.
* The symmetric difference on `Bool` is `Bool.xor`.
* The equivalence of propositions. Two propositions are equivalent if they imply each other.
* The symmetric difference translates to addition when considering a Boolean algebra as a Boolean
ring.
## Main declarations
* `symmDiff`: The symmetric difference operator, defined as `(a \ b) ⊔ (b \ a)`
* `bihimp`: The bi-implication operator, defined as `(b ⇨ a) ⊓ (a ⇨ b)`
In generalized Boolean algebras, the symmetric difference operator is:
* `symmDiff_comm`: commutative, and
* `symmDiff_assoc`: associative.
## Notations
* `a ∆ b`: `symmDiff a b`
* `a ⇔ b`: `bihimp a b`
## References
The proof of associativity follows the note "Associativity of the Symmetric Difference of Sets: A
Proof from the Book" by John McCuan:
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
## Tags
boolean ring, generalized boolean algebra, boolean algebra, symmetric difference, bi-implication,
Heyting
-/
open Function OrderDual
variable {ι α β : Type*} {π : ι → Type*}
/-- The symmetric difference operator on a type with `⊔` and `\` is `(A \ B) ⊔ (B \ A)`. -/
def symmDiff [Sup α] [SDiff α] (a b : α) : α :=
a \ b ⊔ b \ a
#align symm_diff symmDiff
/-- The Heyting bi-implication is `(b ⇨ a) ⊓ (a ⇨ b)`. This generalizes equivalence of
propositions. -/
def bihimp [Inf α] [HImp α] (a b : α) : α :=
(b ⇨ a) ⊓ (a ⇨ b)
#align bihimp bihimp
/-- Notation for symmDiff -/
scoped[symmDiff] infixl:100 " ∆ " => symmDiff
/-- Notation for bihimp -/
scoped[symmDiff] infixl:100 " ⇔ " => bihimp
open scoped symmDiff
theorem symmDiff_def [Sup α] [SDiff α] (a b : α) : a ∆ b = a \ b ⊔ b \ a :=
rfl
#align symm_diff_def symmDiff_def
theorem bihimp_def [Inf α] [HImp α] (a b : α) : a ⇔ b = (b ⇨ a) ⊓ (a ⇨ b) :=
rfl
#align bihimp_def bihimp_def
theorem symmDiff_eq_Xor' (p q : Prop) : p ∆ q = Xor' p q :=
rfl
#align symm_diff_eq_xor symmDiff_eq_Xor'
@[simp]
theorem bihimp_iff_iff {p q : Prop} : p ⇔ q ↔ (p ↔ q) :=
(iff_iff_implies_and_implies _ _).symm.trans Iff.comm
#align bihimp_iff_iff bihimp_iff_iff
@[simp]
theorem Bool.symmDiff_eq_xor : ∀ p q : Bool, p ∆ q = xor p q := by decide
#align bool.symm_diff_eq_bxor Bool.symmDiff_eq_xor
section GeneralizedCoheytingAlgebra
variable [GeneralizedCoheytingAlgebra α] (a b c d : α)
@[simp]
theorem toDual_symmDiff : toDual (a ∆ b) = toDual a ⇔ toDual b :=
rfl
#align to_dual_symm_diff toDual_symmDiff
@[simp]
theorem ofDual_bihimp (a b : αᵒᵈ) : ofDual (a ⇔ b) = ofDual a ∆ ofDual b :=
rfl
#align of_dual_bihimp ofDual_bihimp
theorem symmDiff_comm : a ∆ b = b ∆ a := by simp only [symmDiff, sup_comm]
#align symm_diff_comm symmDiff_comm
instance symmDiff_isCommutative : Std.Commutative (α := α) (· ∆ ·) :=
⟨symmDiff_comm⟩
#align symm_diff_is_comm symmDiff_isCommutative
@[simp]
theorem symmDiff_self : a ∆ a = ⊥ := by rw [symmDiff, sup_idem, sdiff_self]
#align symm_diff_self symmDiff_self
@[simp]
theorem symmDiff_bot : a ∆ ⊥ = a := by rw [symmDiff, sdiff_bot, bot_sdiff, sup_bot_eq]
#align symm_diff_bot symmDiff_bot
@[simp]
theorem bot_symmDiff : ⊥ ∆ a = a := by rw [symmDiff_comm, symmDiff_bot]
#align bot_symm_diff bot_symmDiff
@[simp]
theorem symmDiff_eq_bot {a b : α} : a ∆ b = ⊥ ↔ a = b := by
simp_rw [symmDiff, sup_eq_bot_iff, sdiff_eq_bot_iff, le_antisymm_iff]
#align symm_diff_eq_bot symmDiff_eq_bot
| Mathlib/Order/SymmDiff.lean | 137 | 138 | theorem symmDiff_of_le {a b : α} (h : a ≤ b) : a ∆ b = b \ a := by |
rw [symmDiff, sdiff_eq_bot_iff.2 h, bot_sup_eq]
|
/-
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.LinearAlgebra.Dimension.Finrank
import Mathlib.LinearAlgebra.InvariantBasisNumber
#align_import linear_algebra.dimension from "leanprover-community/mathlib"@"47a5f8186becdbc826190ced4312f8199f9db6a5"
/-!
# Lemmas about rank and finrank in rings satisfying strong rank condition.
## Main statements
For modules over rings satisfying the rank condition
* `Basis.le_span`:
the cardinality of a basis is bounded by the cardinality of any spanning set
For modules over rings satisfying the strong rank condition
* `linearIndependent_le_span`:
For any linearly independent family `v : ι → M`
and any finite spanning set `w : Set M`,
the cardinality of `ι` is bounded by the cardinality of `w`.
* `linearIndependent_le_basis`:
If `b` is a basis for a module `M`,
and `s` is a linearly independent set,
then the cardinality of `s` is bounded by the cardinality of `b`.
For modules over rings with invariant basis number
(including all commutative rings and all noetherian rings)
* `mk_eq_mk_of_basis`: the dimension theorem, any two bases of the same vector space have the same
cardinality.
-/
noncomputable section
universe u v w w'
variable {R : Type u} {M : Type v} [Ring R] [AddCommGroup M] [Module R M]
variable {ι : Type w} {ι' : Type w'}
open Cardinal Basis Submodule Function Set
attribute [local instance] nontrivial_of_invariantBasisNumber
section InvariantBasisNumber
variable [InvariantBasisNumber R]
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : Basis ι R M) (v' : Basis ι' R M) :
Cardinal.lift.{w'} #ι = Cardinal.lift.{w} #ι' := by
classical
haveI := nontrivial_of_invariantBasisNumber R
cases fintypeOrInfinite ι
· -- `v` is a finite basis, so by `basis_finite_of_finite_spans` so is `v'`.
-- haveI : Finite (range v) := Set.finite_range v
haveI := basis_finite_of_finite_spans _ (Set.finite_range v) v.span_eq v'
cases nonempty_fintype ι'
-- We clean up a little:
rw [Cardinal.mk_fintype, Cardinal.mk_fintype]
simp only [Cardinal.lift_natCast, Cardinal.natCast_inj]
-- Now we can use invariant basis number to show they have the same cardinality.
apply card_eq_of_linearEquiv R
exact
(Finsupp.linearEquivFunOnFinite R R ι).symm.trans v.repr.symm ≪≫ₗ v'.repr ≪≫ₗ
Finsupp.linearEquivFunOnFinite R R ι'
· -- `v` is an infinite basis,
-- so by `infinite_basis_le_maximal_linearIndependent`, `v'` is at least as big,
-- and then applying `infinite_basis_le_maximal_linearIndependent` again
-- we see they have the same cardinality.
have w₁ := infinite_basis_le_maximal_linearIndependent' v _ v'.linearIndependent v'.maximal
rcases Cardinal.lift_mk_le'.mp w₁ with ⟨f⟩
haveI : Infinite ι' := Infinite.of_injective f f.2
have w₂ := infinite_basis_le_maximal_linearIndependent' v' _ v.linearIndependent v.maximal
exact le_antisymm w₁ w₂
#align mk_eq_mk_of_basis mk_eq_mk_of_basis
/-- Given two bases indexed by `ι` and `ι'` of an `R`-module, where `R` satisfies the invariant
basis number property, an equiv `ι ≃ ι'`. -/
def Basis.indexEquiv (v : Basis ι R M) (v' : Basis ι' R M) : ι ≃ ι' :=
(Cardinal.lift_mk_eq'.1 <| mk_eq_mk_of_basis v v').some
#align basis.index_equiv Basis.indexEquiv
theorem mk_eq_mk_of_basis' {ι' : Type w} (v : Basis ι R M) (v' : Basis ι' R M) : #ι = #ι' :=
Cardinal.lift_inj.1 <| mk_eq_mk_of_basis v v'
#align mk_eq_mk_of_basis' mk_eq_mk_of_basis'
end InvariantBasisNumber
section RankCondition
variable [RankCondition R]
/-- An auxiliary lemma for `Basis.le_span`.
If `R` satisfies the rank condition,
then for any finite basis `b : Basis ι R M`,
and any finite spanning set `w : Set M`,
the cardinality of `ι` is bounded by the cardinality of `w`.
-/
| Mathlib/LinearAlgebra/Dimension/StrongRankCondition.lean | 109 | 118 | theorem Basis.le_span'' {ι : Type*} [Fintype ι] (b : Basis ι R M) {w : Set M} [Fintype w]
(s : span R w = ⊤) : Fintype.card ι ≤ Fintype.card w := by |
-- We construct a surjective linear map `(w → R) →ₗ[R] (ι → R)`,
-- by expressing a linear combination in `w` as a linear combination in `ι`.
fapply card_le_of_surjective' R
· exact b.repr.toLinearMap.comp (Finsupp.total w M R (↑))
· apply Surjective.comp (g := b.repr.toLinearMap)
· apply LinearEquiv.surjective
rw [← LinearMap.range_eq_top, Finsupp.range_total]
simpa using s
|
/-
Copyright (c) 2024 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Algebra.Order.Ring.Int
import Mathlib.Data.Nat.Cast.Order
import Mathlib.Order.UpperLower.Basic
/-!
# Images of intervals under `Nat.cast : ℕ → ℤ`
In this file we prove that the image of each `Set.Ixx` interval under `Nat.cast : ℕ → ℤ`
is the corresponding interval in `ℤ`.
-/
open Set
namespace Nat
@[simp]
theorem range_cast_int : range ((↑) : ℕ → ℤ) = Ici 0 :=
Subset.antisymm (range_subset_iff.2 Int.ofNat_nonneg) CanLift.prf
theorem image_cast_int_Icc (a b : ℕ) : (↑) '' Icc a b = Icc (a : ℤ) b :=
(castOrderEmbedding (α := ℤ)).image_Icc (by simp [ordConnected_Ici]) a b
theorem image_cast_int_Ico (a b : ℕ) : (↑) '' Ico a b = Ico (a : ℤ) b :=
(castOrderEmbedding (α := ℤ)).image_Ico (by simp [ordConnected_Ici]) a b
theorem image_cast_int_Ioc (a b : ℕ) : (↑) '' Ioc a b = Ioc (a : ℤ) b :=
(castOrderEmbedding (α := ℤ)).image_Ioc (by simp [ordConnected_Ici]) a b
theorem image_cast_int_Ioo (a b : ℕ) : (↑) '' Ioo a b = Ioo (a : ℤ) b :=
(castOrderEmbedding (α := ℤ)).image_Ioo (by simp [ordConnected_Ici]) a b
theorem image_cast_int_Iic (a : ℕ) : (↑) '' Iic a = Icc (0 : ℤ) a := by
rw [← Icc_bot, image_cast_int_Icc]; rfl
| Mathlib/Data/Nat/Cast/SetInterval.lean | 40 | 41 | theorem image_cast_int_Iio (a : ℕ) : (↑) '' Iio a = Ico (0 : ℤ) a := by |
rw [← Ico_bot, image_cast_int_Ico]; rfl
|
/-
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.Topology.MetricSpace.PseudoMetric
#align_import topology.metric_space.basic from "leanprover-community/mathlib"@"c8f305514e0d47dfaa710f5a52f0d21b588e6328"
/-!
# Metric spaces
This file defines metric spaces and shows some of their basic properties.
Many definitions and theorems expected on metric spaces are already introduced on uniform spaces and
topological spaces. This includes open and closed sets, compactness, completeness, continuity
and uniform continuity.
TODO (anyone): Add "Main results" section.
## Implementation notes
A lot of elementary properties don't require `eq_of_dist_eq_zero`, hence are stated and proven
for `PseudoMetricSpace`s in `PseudoMetric.lean`.
## Tags
metric, pseudo_metric, dist
-/
open Set Filter Bornology
open scoped NNReal Uniformity
universe u v w
variable {α : Type u} {β : Type v} {X ι : Type*}
variable [PseudoMetricSpace α]
/-- We now define `MetricSpace`, extending `PseudoMetricSpace`. -/
class MetricSpace (α : Type u) extends PseudoMetricSpace α : Type u where
eq_of_dist_eq_zero : ∀ {x y : α}, dist x y = 0 → x = y
#align metric_space MetricSpace
/-- Two metric space structures with the same distance coincide. -/
@[ext]
theorem MetricSpace.ext {α : Type*} {m m' : MetricSpace α} (h : m.toDist = m'.toDist) :
m = m' := by
cases m; cases m'; congr; ext1; assumption
#align metric_space.ext MetricSpace.ext
/-- Construct a metric space structure whose underlying topological space structure
(definitionally) agrees which a pre-existing topology which is compatible with a given distance
function. -/
def MetricSpace.ofDistTopology {α : Type u} [TopologicalSpace α] (dist : α → α → ℝ)
(dist_self : ∀ x : α, dist x x = 0) (dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z)
(H : ∀ s : Set α, IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, ∀ y, dist x y < ε → y ∈ s)
(eq_of_dist_eq_zero : ∀ x y : α, dist x y = 0 → x = y) : MetricSpace α :=
{ PseudoMetricSpace.ofDistTopology dist dist_self dist_comm dist_triangle H with
eq_of_dist_eq_zero := eq_of_dist_eq_zero _ _ }
#align metric_space.of_dist_topology MetricSpace.ofDistTopology
variable {γ : Type w} [MetricSpace γ]
theorem eq_of_dist_eq_zero {x y : γ} : dist x y = 0 → x = y :=
MetricSpace.eq_of_dist_eq_zero
#align eq_of_dist_eq_zero eq_of_dist_eq_zero
@[simp]
theorem dist_eq_zero {x y : γ} : dist x y = 0 ↔ x = y :=
Iff.intro eq_of_dist_eq_zero fun this => this ▸ dist_self _
#align dist_eq_zero dist_eq_zero
@[simp]
theorem zero_eq_dist {x y : γ} : 0 = dist x y ↔ x = y := by rw [eq_comm, dist_eq_zero]
#align zero_eq_dist zero_eq_dist
| Mathlib/Topology/MetricSpace/Basic.lean | 77 | 78 | theorem dist_ne_zero {x y : γ} : dist x y ≠ 0 ↔ x ≠ y := by |
simpa only [not_iff_not] using dist_eq_zero
|
/-
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.Analysis.Normed.Group.AddTorsor
import Mathlib.Analysis.InnerProductSpace.Basic
import Mathlib.Tactic.AdaptationNote
#align_import geometry.euclidean.inversion from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
/-!
# Inversion in an affine space
In this file we define inversion in a sphere in an affine space. This map sends each point `x` to
the point `y` such that `y -ᵥ c = (R / dist x c) ^ 2 • (x -ᵥ c)`, where `c` and `R` are the center
and the radius the sphere.
In many applications, it is convenient to assume that the inversions swaps the center and the point
at infinity. In order to stay in the original affine space, we define the map so that it sends
center to itself.
Currently, we prove only a few basic lemmas needed to prove Ptolemy's inequality, see
`EuclideanGeometry.mul_dist_le_mul_dist_add_mul_dist`.
-/
noncomputable section
open Metric Function AffineMap Set AffineSubspace
open scoped Topology
variable {V P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
[NormedAddTorsor V P]
namespace EuclideanGeometry
variable {a b c d x y z : P} {r R : ℝ}
/-- Inversion in a sphere in an affine space. This map sends each point `x` to the point `y` such
that `y -ᵥ c = (R / dist x c) ^ 2 • (x -ᵥ c)`, where `c` and `R` are the center and the radius the
sphere. -/
def inversion (c : P) (R : ℝ) (x : P) : P :=
(R / dist x c) ^ 2 • (x -ᵥ c) +ᵥ c
#align euclidean_geometry.inversion EuclideanGeometry.inversion
#adaptation_note /-- nightly-2024-03-16: added to replace simp [inversion] -/
theorem inversion_def :
inversion = fun (c : P) (R : ℝ) (x : P) => (R / dist x c) ^ 2 • (x -ᵥ c) +ᵥ c :=
rfl
/-!
### Basic properties
In this section we prove that `EuclideanGeometry.inversion c R` is involutive and preserves the
sphere `Metric.sphere c R`. We also prove that the distance to the center of the image of `x` under
this inversion is given by `R ^ 2 / dist x c`.
-/
theorem inversion_eq_lineMap (c : P) (R : ℝ) (x : P) :
inversion c R x = lineMap c x ((R / dist x c) ^ 2) :=
rfl
theorem inversion_vsub_center (c : P) (R : ℝ) (x : P) :
inversion c R x -ᵥ c = (R / dist x c) ^ 2 • (x -ᵥ c) :=
vadd_vsub _ _
#align euclidean_geometry.inversion_vsub_center EuclideanGeometry.inversion_vsub_center
@[simp]
theorem inversion_self (c : P) (R : ℝ) : inversion c R c = c := by simp [inversion]
#align euclidean_geometry.inversion_self EuclideanGeometry.inversion_self
@[simp]
theorem inversion_zero_radius (c x : P) : inversion c 0 x = c := by simp [inversion]
theorem inversion_mul (c : P) (a R : ℝ) (x : P) :
inversion c (a * R) x = homothety c (a ^ 2) (inversion c R x) := by
simp only [inversion_eq_lineMap, ← homothety_eq_lineMap, ← homothety_mul_apply, mul_div_assoc,
mul_pow]
@[simp]
| Mathlib/Geometry/Euclidean/Inversion/Basic.lean | 81 | 85 | theorem inversion_dist_center (c x : P) : inversion c (dist x c) x = x := by |
rcases eq_or_ne x c with (rfl | hne)
· apply inversion_self
· rw [inversion, div_self, one_pow, one_smul, vsub_vadd]
rwa [dist_ne_zero]
|
/-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Order.Filter.Lift
import Mathlib.Topology.Separation
import Mathlib.Order.Interval.Set.Monotone
#align_import topology.filter from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514"
/-!
# Topology on the set of filters on a type
This file introduces a topology on `Filter α`. It is generated by the sets
`Set.Iic (𝓟 s) = {l : Filter α | s ∈ l}`, `s : Set α`. A set `s : Set (Filter α)` is open if and
only if it is a union of a family of these basic open sets, see `Filter.isOpen_iff`.
This topology has the following important properties.
* If `X` is a topological space, then the map `𝓝 : X → Filter X` is a topology inducing map.
* In particular, it is a continuous map, so `𝓝 ∘ f` tends to `𝓝 (𝓝 a)` whenever `f` tends to `𝓝 a`.
* If `X` is an ordered topological space with order topology and no max element, then `𝓝 ∘ f` tends
to `𝓝 Filter.atTop` whenever `f` tends to `Filter.atTop`.
* It turns `Filter X` into a T₀ space and the order on `Filter X` is the dual of the
`specializationOrder (Filter X)`.
## Tags
filter, topological space
-/
open Set Filter TopologicalSpace
open Filter Topology
variable {ι : Sort*} {α β X Y : Type*}
namespace Filter
/-- The topology on `Filter α` is generated by the sets `Set.Iic (𝓟 s) = {l : Filter α | s ∈ l}`,
`s : Set α`. A set `s : Set (Filter α)` is open if and only if it is a union of a family of these
basic open sets, see `Filter.isOpen_iff`. -/
instance : TopologicalSpace (Filter α) :=
generateFrom <| range <| Iic ∘ 𝓟
theorem isOpen_Iic_principal {s : Set α} : IsOpen (Iic (𝓟 s)) :=
GenerateOpen.basic _ (mem_range_self _)
#align filter.is_open_Iic_principal Filter.isOpen_Iic_principal
theorem isOpen_setOf_mem {s : Set α} : IsOpen { l : Filter α | s ∈ l } := by
simpa only [Iic_principal] using isOpen_Iic_principal
#align filter.is_open_set_of_mem Filter.isOpen_setOf_mem
theorem isTopologicalBasis_Iic_principal :
IsTopologicalBasis (range (Iic ∘ 𝓟 : Set α → Set (Filter α))) :=
{ exists_subset_inter := by
rintro _ ⟨s, rfl⟩ _ ⟨t, rfl⟩ l hl
exact ⟨Iic (𝓟 s) ∩ Iic (𝓟 t), ⟨s ∩ t, by simp⟩, hl, Subset.rfl⟩
sUnion_eq := sUnion_eq_univ_iff.2 fun l => ⟨Iic ⊤, ⟨univ, congr_arg Iic principal_univ⟩,
mem_Iic.2 le_top⟩
eq_generateFrom := rfl }
#align filter.is_topological_basis_Iic_principal Filter.isTopologicalBasis_Iic_principal
theorem isOpen_iff {s : Set (Filter α)} : IsOpen s ↔ ∃ T : Set (Set α), s = ⋃ t ∈ T, Iic (𝓟 t) :=
isTopologicalBasis_Iic_principal.open_iff_eq_sUnion.trans <| by
simp only [exists_subset_range_and_iff, sUnion_image, (· ∘ ·)]
#align filter.is_open_iff Filter.isOpen_iff
theorem nhds_eq (l : Filter α) : 𝓝 l = l.lift' (Iic ∘ 𝓟) :=
nhds_generateFrom.trans <| by
simp only [mem_setOf_eq, @and_comm (l ∈ _), iInf_and, iInf_range, Filter.lift', Filter.lift,
(· ∘ ·), mem_Iic, le_principal_iff]
#align filter.nhds_eq Filter.nhds_eq
theorem nhds_eq' (l : Filter α) : 𝓝 l = l.lift' fun s => { l' | s ∈ l' } := by
simpa only [(· ∘ ·), Iic_principal] using nhds_eq l
#align filter.nhds_eq' Filter.nhds_eq'
protected theorem tendsto_nhds {la : Filter α} {lb : Filter β} {f : α → Filter β} :
Tendsto f la (𝓝 lb) ↔ ∀ s ∈ lb, ∀ᶠ a in la, s ∈ f a := by
simp only [nhds_eq', tendsto_lift', mem_setOf_eq]
#align filter.tendsto_nhds Filter.tendsto_nhds
protected theorem HasBasis.nhds {l : Filter α} {p : ι → Prop} {s : ι → Set α} (h : HasBasis l p s) :
HasBasis (𝓝 l) p fun i => Iic (𝓟 (s i)) := by
rw [nhds_eq]
exact h.lift' monotone_principal.Iic
#align filter.has_basis.nhds Filter.HasBasis.nhds
protected theorem tendsto_pure_self (l : Filter X) :
Tendsto (pure : X → Filter X) l (𝓝 l) := by
rw [Filter.tendsto_nhds]
exact fun s hs ↦ Eventually.mono hs fun x ↦ id
/-- Neighborhoods of a countably generated filter is a countably generated filter. -/
instance {l : Filter α} [IsCountablyGenerated l] : IsCountablyGenerated (𝓝 l) :=
let ⟨_b, hb⟩ := l.exists_antitone_basis
HasCountableBasis.isCountablyGenerated <| ⟨hb.nhds, Set.to_countable _⟩
| Mathlib/Topology/Filter.lean | 105 | 106 | theorem HasBasis.nhds' {l : Filter α} {p : ι → Prop} {s : ι → Set α} (h : HasBasis l p s) :
HasBasis (𝓝 l) p fun i => { l' | s i ∈ l' } := by | simpa only [Iic_principal] using h.nhds
|
/-
Copyright (c) 2020 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Floris van Doorn
-/
import Mathlib.Geometry.Manifold.MFDeriv.Atlas
/-!
# Unique derivative sets in manifolds
In this file, we prove various properties of unique derivative sets in manifolds.
* `image_denseRange`: suppose `f` is differentiable on `s` and its derivative at every point of `s`
has dense range. If `s` has the unique differential property, then so does `f '' s`.
* `uniqueMDiffOn_preimage`: the unique differential property is preserved by local diffeomorphisms
* `uniqueDiffOn_target_inter`: the unique differential property is preserved by
pullbacks of extended charts
* `tangentBundle_proj_preimage`: if `s` has the unique differential property,
its preimage under the tangent bundle projection also has
-/
noncomputable section
open scoped Manifold
open Set
/-! ### Unique derivative sets in manifolds -/
section UniqueMDiff
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {H : Type*} [TopologicalSpace H] {I : ModelWithCorners 𝕜 E H} {M : Type*}
[TopologicalSpace M] [ChartedSpace H M] [SmoothManifoldWithCorners I M] {E' : Type*}
[NormedAddCommGroup E'] [NormedSpace 𝕜 E'] {H' : Type*} [TopologicalSpace H']
{I' : ModelWithCorners 𝕜 E' H'} {M' : Type*} [TopologicalSpace M'] [ChartedSpace H' M']
[SmoothManifoldWithCorners I' M'] {s : Set M} {x : M}
/-- If `s` has the unique differential property at `x`, `f` is differentiable within `s` at x` and
its derivative has dense range, then `f '' s` has the unique differential property at `f x`. -/
theorem UniqueMDiffWithinAt.image_denseRange (hs : UniqueMDiffWithinAt I s x)
{f : M → M'} {f' : E →L[𝕜] E'} (hf : HasMFDerivWithinAt I I' f s x f')
(hd : DenseRange f') : UniqueMDiffWithinAt I' (f '' s) (f x) := by
/- Rewrite in coordinates, apply `HasFDerivWithinAt.uniqueDiffWithinAt`. -/
have := hs.inter' <| hf.1 (extChartAt_source_mem_nhds I' (f x))
refine (((hf.2.mono ?sub1).uniqueDiffWithinAt this hd).mono ?sub2).congr_pt ?pt
case pt => simp only [mfld_simps]
case sub1 => mfld_set_tac
case sub2 =>
rintro _ ⟨y, ⟨⟨hys, hfy⟩, -⟩, rfl⟩
exact ⟨⟨_, hys, ((extChartAt I' (f x)).left_inv hfy).symm⟩, mem_range_self _⟩
/-- If `s` has the unique differential property, `f` is differentiable on `s` and its derivative
at every point of `s` has dense range, then `f '' s` has the unique differential property.
This version uses the `HasMFDerivWithinAt` predicate. -/
theorem UniqueMDiffOn.image_denseRange' (hs : UniqueMDiffOn I s) {f : M → M'}
{f' : M → E →L[𝕜] E'} (hf : ∀ x ∈ s, HasMFDerivWithinAt I I' f s x (f' x))
(hd : ∀ x ∈ s, DenseRange (f' x)) :
UniqueMDiffOn I' (f '' s) :=
forall_mem_image.2 fun x hx ↦ (hs x hx).image_denseRange (hf x hx) (hd x hx)
/-- If `s` has the unique differential property, `f` is differentiable on `s` and its derivative
at every point of `s` has dense range, then `f '' s` has the unique differential property. -/
theorem UniqueMDiffOn.image_denseRange (hs : UniqueMDiffOn I s) {f : M → M'}
(hf : MDifferentiableOn I I' f s) (hd : ∀ x ∈ s, DenseRange (mfderivWithin I I' f s x)) :
UniqueMDiffOn I' (f '' s) :=
hs.image_denseRange' (fun x hx ↦ (hf x hx).hasMFDerivWithinAt) hd
protected theorem UniqueMDiffWithinAt.preimage_partialHomeomorph (hs : UniqueMDiffWithinAt I s x)
{e : PartialHomeomorph M M'} (he : e.MDifferentiable I I') (hx : x ∈ e.source) :
UniqueMDiffWithinAt I' (e.target ∩ e.symm ⁻¹' s) (e x) := by
rw [← e.image_source_inter_eq', inter_comm]
exact (hs.inter (e.open_source.mem_nhds hx)).image_denseRange
(he.mdifferentiableAt hx).hasMFDerivAt.hasMFDerivWithinAt
(he.mfderiv_surjective hx).denseRange
/-- If a set has the unique differential property, then its image under a local
diffeomorphism also has the unique differential property. -/
theorem UniqueMDiffOn.uniqueMDiffOn_preimage (hs : UniqueMDiffOn I s) {e : PartialHomeomorph M M'}
(he : e.MDifferentiable I I') : UniqueMDiffOn I' (e.target ∩ e.symm ⁻¹' s) := fun _x hx ↦
e.right_inv hx.1 ▸ (hs _ hx.2).preimage_partialHomeomorph he (e.map_target hx.1)
#align unique_mdiff_on.unique_mdiff_on_preimage UniqueMDiffOn.uniqueMDiffOn_preimage
/-- If a set in a manifold has the unique derivative property, then its pullback by any extended
chart, in the vector space, also has the unique derivative property. -/
| Mathlib/Geometry/Manifold/MFDeriv/UniqueDifferential.lean | 84 | 92 | theorem UniqueMDiffOn.uniqueDiffOn_target_inter (hs : UniqueMDiffOn I s) (x : M) :
UniqueDiffOn 𝕜 ((extChartAt I x).target ∩ (extChartAt I x).symm ⁻¹' s) := by |
-- this is just a reformulation of `UniqueMDiffOn.uniqueMDiffOn_preimage`, using as `e`
-- the local chart at `x`.
apply UniqueMDiffOn.uniqueDiffOn
rw [← PartialEquiv.image_source_inter_eq', inter_comm, extChartAt_source]
exact (hs.inter (chartAt H x).open_source).image_denseRange'
(fun y hy ↦ hasMFDerivWithinAt_extChartAt I hy.2)
fun y hy ↦ ((mdifferentiable_chart _ _).mfderiv_surjective hy.2).denseRange
|
/-
Copyright (c) 2023 Luke Mantle. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Luke Mantle, Jake Levinson
-/
import Mathlib.RingTheory.Polynomial.Hermite.Basic
import Mathlib.Analysis.Calculus.Deriv.Add
import Mathlib.Analysis.Calculus.Deriv.Polynomial
import Mathlib.Analysis.SpecialFunctions.Exp
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
#align_import ring_theory.polynomial.hermite.gaussian from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
/-!
# Hermite polynomials and Gaussians
This file shows that the Hermite polynomial `hermite n` is (up to sign) the
polynomial factor occurring in the `n`th derivative of a gaussian.
## Results
* `Polynomial.deriv_gaussian_eq_hermite_mul_gaussian`:
The Hermite polynomial is (up to sign) the polynomial factor occurring in the
`n`th derivative of a gaussian.
## References
* [Hermite Polynomials](https://en.wikipedia.org/wiki/Hermite_polynomials)
-/
noncomputable section
open Polynomial
namespace Polynomial
/-- `hermite n` is (up to sign) the factor appearing in `deriv^[n]` of a gaussian -/
| Mathlib/RingTheory/Polynomial/Hermite/Gaussian.lean | 40 | 55 | theorem deriv_gaussian_eq_hermite_mul_gaussian (n : ℕ) (x : ℝ) :
deriv^[n] (fun y => Real.exp (-(y ^ 2 / 2))) x =
(-1 : ℝ) ^ n * aeval x (hermite n) * Real.exp (-(x ^ 2 / 2)) := by |
rw [mul_assoc]
induction' n with n ih generalizing x
· rw [Function.iterate_zero_apply, pow_zero, one_mul, hermite_zero, C_1, map_one, one_mul]
· replace ih : deriv^[n] _ = _ := _root_.funext ih
have deriv_gaussian :
deriv (fun y => Real.exp (-(y ^ 2 / 2))) x = -x * Real.exp (-(x ^ 2 / 2)) := by
-- porting note (#10745): was `simp [mul_comm, ← neg_mul]`
rw [deriv_exp (by simp)]; simp; ring
rw [Function.iterate_succ_apply', ih, deriv_const_mul_field, deriv_mul, pow_succ (-1 : ℝ),
deriv_gaussian, hermite_succ, map_sub, map_mul, aeval_X, Polynomial.deriv_aeval]
· ring
· apply Polynomial.differentiable_aeval
· apply DifferentiableAt.exp; simp -- Porting note: was just `simp`
|
/-
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.Topology.Algebra.Polynomial
import Mathlib.Topology.ContinuousFunction.Algebra
import Mathlib.Topology.UnitInterval
import Mathlib.Algebra.Star.Subalgebra
#align_import topology.continuous_function.polynomial from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64"
/-!
# Constructions relating polynomial functions and continuous functions.
## Main definitions
* `Polynomial.toContinuousMapOn p X`: for `X : Set R`, interprets a polynomial `p`
as a bundled continuous function in `C(X, R)`.
* `Polynomial.toContinuousMapOnAlgHom`: the same, as an `R`-algebra homomorphism.
* `polynomialFunctions (X : Set R) : Subalgebra R C(X, R)`: polynomial functions as a subalgebra.
* `polynomialFunctions_separatesPoints (X : Set R) : (polynomialFunctions X).SeparatesPoints`:
the polynomial functions separate points.
-/
variable {R : Type*}
open Polynomial
namespace Polynomial
section
variable [Semiring R] [TopologicalSpace R] [TopologicalSemiring R]
/--
Every polynomial with coefficients in a topological semiring gives a (bundled) continuous function.
-/
@[simps]
def toContinuousMap (p : R[X]) : C(R, R) :=
⟨fun x : R => p.eval x, by fun_prop⟩
#align polynomial.to_continuous_map Polynomial.toContinuousMap
open ContinuousMap in
lemma toContinuousMap_X_eq_id : X.toContinuousMap = .id R := by
ext; simp
/-- A polynomial as a continuous function,
with domain restricted to some subset of the semiring of coefficients.
(This is particularly useful when restricting to compact sets, e.g. `[0,1]`.)
-/
@[simps]
def toContinuousMapOn (p : R[X]) (X : Set R) : C(X, R) :=
-- Porting note: Old proof was `⟨fun x : X => p.toContinuousMap x, by continuity⟩`
⟨fun x : X => p.toContinuousMap x, Continuous.comp (by continuity) (by continuity)⟩
#align polynomial.to_continuous_map_on Polynomial.toContinuousMapOn
open ContinuousMap in
lemma toContinuousMapOn_X_eq_restrict_id (s : Set R) :
X.toContinuousMapOn s = restrict s (.id R) := by
ext; simp
-- TODO some lemmas about when `toContinuousMapOn` is injective?
end
section
variable {α : Type*} [TopologicalSpace α] [CommSemiring R] [TopologicalSpace R]
[TopologicalSemiring R]
@[simp]
| Mathlib/Topology/ContinuousFunction/Polynomial.lean | 76 | 82 | theorem aeval_continuousMap_apply (g : R[X]) (f : C(α, R)) (x : α) :
((Polynomial.aeval f) g) x = g.eval (f x) := by |
refine Polynomial.induction_on' g ?_ ?_
· intro p q hp hq
simp [hp, hq]
· intro n a
simp [Pi.pow_apply]
|
/-
Copyright (c) 2020 Fox Thomson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Fox Thomson
-/
import Mathlib.Computability.DFA
import Mathlib.Data.Fintype.Powerset
#align_import computability.NFA from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514"
/-!
# Nondeterministic Finite Automata
This file contains the definition of a Nondeterministic Finite Automaton (NFA), a state machine
which determines whether a string (implemented as a list over an arbitrary alphabet) is in a regular
set by evaluating the string over every possible path.
We show that DFA's are equivalent to NFA's however the construction from NFA to DFA uses an
exponential number of states.
Note that this definition allows for Automaton with infinite states; a `Fintype` instance must be
supplied for true NFA's.
-/
open Set
open Computability
universe u v
-- Porting note: Required as `NFA` is used in mathlib3
set_option linter.uppercaseLean3 false
/-- An NFA is a set of states (`σ`), a transition function from state to state labelled by the
alphabet (`step`), a set of starting states (`start`) and a set of acceptance states (`accept`).
Note the transition function sends a state to a `Set` of states. These are the states that it
may be sent to. -/
structure NFA (α : Type u) (σ : Type v) where
step : σ → α → Set σ
start : Set σ
accept : Set σ
#align NFA NFA
variable {α : Type u} {σ σ' : Type v} (M : NFA α σ)
namespace NFA
instance : Inhabited (NFA α σ) :=
⟨NFA.mk (fun _ _ => ∅) ∅ ∅⟩
/-- `M.stepSet S a` is the union of `M.step s a` for all `s ∈ S`. -/
def stepSet (S : Set σ) (a : α) : Set σ :=
⋃ s ∈ S, M.step s a
#align NFA.step_set NFA.stepSet
theorem mem_stepSet (s : σ) (S : Set σ) (a : α) : s ∈ M.stepSet S a ↔ ∃ t ∈ S, s ∈ M.step t a := by
simp [stepSet]
#align NFA.mem_step_set NFA.mem_stepSet
@[simp]
| Mathlib/Computability/NFA.lean | 58 | 58 | theorem stepSet_empty (a : α) : M.stepSet ∅ a = ∅ := by | simp [stepSet]
|
/-
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.Analysis.SpecialFunctions.Pow.NNReal
import Mathlib.Analysis.SpecialFunctions.Pow.Continuity
import Mathlib.Analysis.SumOverResidueClass
#align_import analysis.p_series from "leanprover-community/mathlib"@"0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8"
/-!
# Convergence of `p`-series
In this file we prove that the series `∑' k in ℕ, 1 / k ^ p` converges if and only if `p > 1`.
The proof is based on the
[Cauchy condensation test](https://en.wikipedia.org/wiki/Cauchy_condensation_test): `∑ k, f k`
converges if and only if so does `∑ k, 2 ^ k f (2 ^ k)`. We prove this test in
`NNReal.summable_condensed_iff` and `summable_condensed_iff_of_nonneg`, then use it to prove
`summable_one_div_rpow`. After this transformation, a `p`-series turns into a geometric series.
## Tags
p-series, Cauchy condensation test
-/
/-!
### Schlömilch's generalization of the Cauchy condensation test
In this section we prove the Schlömilch's generalization of the Cauchy condensation test:
for a strictly increasing `u : ℕ → ℕ` with ratio of successive differences bounded and an
antitone `f : ℕ → ℝ≥0` or `f : ℕ → ℝ`, `∑ k, f k` converges if and only if
so does `∑ k, (u (k + 1) - u k) * f (u k)`. Instead of giving a monolithic proof, we split it
into a series of lemmas with explicit estimates of partial sums of each series in terms of the
partial sums of the other series.
-/
/--
A sequence `u` has the property that its ratio of successive differences is bounded
when there is a positive real number `C` such that, for all n ∈ ℕ,
(u (n + 2) - u (n + 1)) ≤ C * (u (n + 1) - u n)
-/
def SuccDiffBounded (C : ℕ) (u : ℕ → ℕ) : Prop :=
∀ n : ℕ, u (n + 2) - u (n + 1) ≤ C • (u (n + 1) - u n)
namespace Finset
variable {M : Type*} [OrderedAddCommMonoid M] {f : ℕ → M} {u : ℕ → ℕ}
| Mathlib/Analysis/PSeries.lean | 50 | 62 | theorem le_sum_schlomilch' (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(hu : Monotone u) (n : ℕ) :
(∑ k ∈ Ico (u 0) (u n), f k) ≤ ∑ k ∈ range n, (u (k + 1) - u k) • f (u k) := by |
induction' n with n ihn
· simp
suffices (∑ k ∈ Ico (u n) (u (n + 1)), f k) ≤ (u (n + 1) - u n) • f (u n) by
rw [sum_range_succ, ← sum_Ico_consecutive]
· exact add_le_add ihn this
exacts [hu n.zero_le, hu n.le_succ]
have : ∀ k ∈ Ico (u n) (u (n + 1)), f k ≤ f (u n) := fun k hk =>
hf (Nat.succ_le_of_lt (h_pos n)) (mem_Ico.mp hk).1
convert sum_le_sum this
simp [pow_succ, mul_two]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro
-/
import Mathlib.Algebra.MvPolynomial.Degrees
#align_import data.mv_polynomial.variables from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4"
/-!
# Variables of polynomials
This file establishes many results about the variable sets of a multivariate polynomial.
The *variable set* of a polynomial $P \in R[X]$ is a `Finset` containing each $x \in X$
that appears in a monomial in $P$.
## Main declarations
* `MvPolynomial.vars p` : the finset of variables occurring in `p`.
For example if `p = x⁴y+yz` then `vars p = {x, y, z}`
## Notation
As in other polynomial files, we typically use the notation:
+ `σ τ : Type*` (indexing the variables)
+ `R : Type*` `[CommSemiring R]` (the coefficients)
+ `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set.
This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s`
+ `r : R`
+ `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians
+ `p : MvPolynomial σ R`
-/
noncomputable section
open Set Function Finsupp AddMonoidAlgebra
universe u v w
variable {R : Type u} {S : Type v}
namespace MvPolynomial
variable {σ τ : Type*} {r : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ}
section CommSemiring
variable [CommSemiring R] {p q : MvPolynomial σ R}
section Vars
/-! ### `vars` -/
/-- `vars p` is the set of variables appearing in the polynomial `p` -/
def vars (p : MvPolynomial σ R) : Finset σ :=
letI := Classical.decEq σ
p.degrees.toFinset
#align mv_polynomial.vars MvPolynomial.vars
theorem vars_def [DecidableEq σ] (p : MvPolynomial σ R) : p.vars = p.degrees.toFinset := by
rw [vars]
convert rfl
#align mv_polynomial.vars_def MvPolynomial.vars_def
@[simp]
theorem vars_0 : (0 : MvPolynomial σ R).vars = ∅ := by
classical rw [vars_def, degrees_zero, Multiset.toFinset_zero]
#align mv_polynomial.vars_0 MvPolynomial.vars_0
@[simp]
theorem vars_monomial (h : r ≠ 0) : (monomial s r).vars = s.support := by
classical rw [vars_def, degrees_monomial_eq _ _ h, Finsupp.toFinset_toMultiset]
#align mv_polynomial.vars_monomial MvPolynomial.vars_monomial
@[simp]
theorem vars_C : (C r : MvPolynomial σ R).vars = ∅ := by
classical rw [vars_def, degrees_C, Multiset.toFinset_zero]
set_option linter.uppercaseLean3 false in
#align mv_polynomial.vars_C MvPolynomial.vars_C
@[simp]
| Mathlib/Algebra/MvPolynomial/Variables.lean | 93 | 94 | theorem vars_X [Nontrivial R] : (X n : MvPolynomial σ R).vars = {n} := by |
rw [X, vars_monomial (one_ne_zero' R), Finsupp.support_single_ne_zero _ (one_ne_zero' ℕ)]
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker, Johan Commelin
-/
import Mathlib.Algebra.Polynomial.RingDivision
import Mathlib.RingTheory.Localization.FractionRing
#align_import data.polynomial.ring_division from "leanprover-community/mathlib"@"8efcf8022aac8e01df8d302dcebdbc25d6a886c8"
/-!
# Theory of univariate polynomials
We define the multiset of roots of a polynomial, and prove basic results about it.
## Main definitions
* `Polynomial.roots p`: The multiset containing all the roots of `p`, including their
multiplicities.
* `Polynomial.rootSet p E`: The set of distinct roots of `p` in an algebra `E`.
## Main statements
* `Polynomial.C_leadingCoeff_mul_prod_multiset_X_sub_C`: If a polynomial has as many roots as its
degree, it can be written as the product of its leading coefficient with `∏ (X - a)` where `a`
ranges through its roots.
-/
noncomputable section
namespace Polynomial
universe u v w z
variable {R : Type u} {S : Type v} {T : Type w} {a b : R} {n : ℕ}
section CommRing
variable [CommRing R] [IsDomain R] {p q : R[X]}
section Roots
open Multiset Finset
/-- `roots p` noncomputably gives a multiset containing all the roots of `p`,
including their multiplicities. -/
noncomputable def roots (p : R[X]) : Multiset R :=
haveI := Classical.decEq R
haveI := Classical.dec (p = 0)
if h : p = 0 then ∅ else Classical.choose (exists_multiset_roots h)
#align polynomial.roots Polynomial.roots
theorem roots_def [DecidableEq R] (p : R[X]) [Decidable (p = 0)] :
p.roots = if h : p = 0 then ∅ else Classical.choose (exists_multiset_roots h) := by
-- porting noteL `‹_›` doesn't work for instance arguments
rename_i iR ip0
obtain rfl := Subsingleton.elim iR (Classical.decEq R)
obtain rfl := Subsingleton.elim ip0 (Classical.dec (p = 0))
rfl
#align polynomial.roots_def Polynomial.roots_def
@[simp]
theorem roots_zero : (0 : R[X]).roots = 0 :=
dif_pos rfl
#align polynomial.roots_zero Polynomial.roots_zero
theorem card_roots (hp0 : p ≠ 0) : (Multiset.card (roots p) : WithBot ℕ) ≤ degree p := by
classical
unfold roots
rw [dif_neg hp0]
exact (Classical.choose_spec (exists_multiset_roots hp0)).1
#align polynomial.card_roots Polynomial.card_roots
theorem card_roots' (p : R[X]) : Multiset.card p.roots ≤ natDegree p := by
by_cases hp0 : p = 0
· simp [hp0]
exact WithBot.coe_le_coe.1 (le_trans (card_roots hp0) (le_of_eq <| degree_eq_natDegree hp0))
#align polynomial.card_roots' Polynomial.card_roots'
theorem card_roots_sub_C {p : R[X]} {a : R} (hp0 : 0 < degree p) :
(Multiset.card (p - C a).roots : WithBot ℕ) ≤ degree p :=
calc
(Multiset.card (p - C a).roots : WithBot ℕ) ≤ degree (p - C a) :=
card_roots <| mt sub_eq_zero.1 fun h => not_le_of_gt hp0 <| h.symm ▸ degree_C_le
_ = degree p := by rw [sub_eq_add_neg, ← C_neg]; exact degree_add_C hp0
set_option linter.uppercaseLean3 false in
#align polynomial.card_roots_sub_C Polynomial.card_roots_sub_C
theorem card_roots_sub_C' {p : R[X]} {a : R} (hp0 : 0 < degree p) :
Multiset.card (p - C a).roots ≤ natDegree p :=
WithBot.coe_le_coe.1
(le_trans (card_roots_sub_C hp0)
(le_of_eq <| degree_eq_natDegree fun h => by simp_all [lt_irrefl]))
set_option linter.uppercaseLean3 false in
#align polynomial.card_roots_sub_C' Polynomial.card_roots_sub_C'
@[simp]
theorem count_roots [DecidableEq R] (p : R[X]) : p.roots.count a = rootMultiplicity a p := by
classical
by_cases hp : p = 0
· simp [hp]
rw [roots_def, dif_neg hp]
exact (Classical.choose_spec (exists_multiset_roots hp)).2 a
#align polynomial.count_roots Polynomial.count_roots
@[simp]
theorem mem_roots' : a ∈ p.roots ↔ p ≠ 0 ∧ IsRoot p a := by
classical
rw [← count_pos, count_roots p, rootMultiplicity_pos']
#align polynomial.mem_roots' Polynomial.mem_roots'
theorem mem_roots (hp : p ≠ 0) : a ∈ p.roots ↔ IsRoot p a :=
mem_roots'.trans <| and_iff_right hp
#align polynomial.mem_roots Polynomial.mem_roots
theorem ne_zero_of_mem_roots (h : a ∈ p.roots) : p ≠ 0 :=
(mem_roots'.1 h).1
#align polynomial.ne_zero_of_mem_roots Polynomial.ne_zero_of_mem_roots
theorem isRoot_of_mem_roots (h : a ∈ p.roots) : IsRoot p a :=
(mem_roots'.1 h).2
#align polynomial.is_root_of_mem_roots Polynomial.isRoot_of_mem_roots
-- Porting note: added during port.
lemma mem_roots_iff_aeval_eq_zero {x : R} (w : p ≠ 0) : x ∈ roots p ↔ aeval x p = 0 := by
rw [mem_roots w, IsRoot.def, aeval_def, eval₂_eq_eval_map]
simp
theorem card_le_degree_of_subset_roots {p : R[X]} {Z : Finset R} (h : Z.val ⊆ p.roots) :
Z.card ≤ p.natDegree :=
(Multiset.card_le_card (Finset.val_le_iff_val_subset.2 h)).trans (Polynomial.card_roots' p)
#align polynomial.card_le_degree_of_subset_roots Polynomial.card_le_degree_of_subset_roots
| Mathlib/Algebra/Polynomial/Roots.lean | 136 | 139 | theorem finite_setOf_isRoot {p : R[X]} (hp : p ≠ 0) : Set.Finite { x | IsRoot p x } := by |
classical
simpa only [← Finset.setOf_mem, Multiset.mem_toFinset, mem_roots hp]
using p.roots.toFinset.finite_toSet
|
/-
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.Geometry.Euclidean.Sphere.Basic
#align_import geometry.euclidean.sphere.second_inter from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
/-!
# Second intersection of a sphere and a line
This file defines and proves basic results about the second intersection of a sphere with a line
through a point on that sphere.
## Main definitions
* `EuclideanGeometry.Sphere.secondInter` is the second intersection of a sphere with a line
through a point on that sphere.
-/
noncomputable section
open RealInnerProductSpace
namespace EuclideanGeometry
variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
[NormedAddTorsor V P]
/-- The second intersection of a sphere with a line through a point on that sphere; that point
if it is the only point of intersection of the line with the sphere. The intended use of this
definition is when `p ∈ s`; the definition does not use `s.radius`, so in general it returns
the second intersection with the sphere through `p` and with center `s.center`. -/
def Sphere.secondInter (s : Sphere P) (p : P) (v : V) : P :=
(-2 * ⟪v, p -ᵥ s.center⟫ / ⟪v, v⟫) • v +ᵥ p
#align euclidean_geometry.sphere.second_inter EuclideanGeometry.Sphere.secondInter
/-- The distance between `secondInter` and the center equals the distance between the original
point and the center. -/
@[simp]
theorem Sphere.secondInter_dist (s : Sphere P) (p : P) (v : V) :
dist (s.secondInter p v) s.center = dist p s.center := by
rw [Sphere.secondInter]
by_cases hv : v = 0; · simp [hv]
rw [dist_smul_vadd_eq_dist _ _ hv]
exact Or.inr rfl
#align euclidean_geometry.sphere.second_inter_dist EuclideanGeometry.Sphere.secondInter_dist
/-- The point given by `secondInter` lies on the sphere. -/
@[simp]
theorem Sphere.secondInter_mem {s : Sphere P} {p : P} (v : V) : s.secondInter p v ∈ s ↔ p ∈ s := by
simp_rw [mem_sphere, Sphere.secondInter_dist]
#align euclidean_geometry.sphere.second_inter_mem EuclideanGeometry.Sphere.secondInter_mem
variable (V)
/-- If the vector is zero, `secondInter` gives the original point. -/
@[simp]
theorem Sphere.secondInter_zero (s : Sphere P) (p : P) : s.secondInter p (0 : V) = p := by
simp [Sphere.secondInter]
#align euclidean_geometry.sphere.second_inter_zero EuclideanGeometry.Sphere.secondInter_zero
variable {V}
/-- The point given by `secondInter` equals the original point if and only if the line is
orthogonal to the radius vector. -/
theorem Sphere.secondInter_eq_self_iff {s : Sphere P} {p : P} {v : V} :
s.secondInter p v = p ↔ ⟪v, p -ᵥ s.center⟫ = 0 := by
refine ⟨fun hp => ?_, fun hp => ?_⟩
· by_cases hv : v = 0
· simp [hv]
rwa [Sphere.secondInter, eq_comm, eq_vadd_iff_vsub_eq, vsub_self, eq_comm, smul_eq_zero,
or_iff_left hv, div_eq_zero_iff, inner_self_eq_zero, or_iff_left hv, mul_eq_zero,
or_iff_right (by norm_num : (-2 : ℝ) ≠ 0)] at hp
· rw [Sphere.secondInter, hp, mul_zero, zero_div, zero_smul, zero_vadd]
#align euclidean_geometry.sphere.second_inter_eq_self_iff EuclideanGeometry.Sphere.secondInter_eq_self_iff
/-- A point on a line through a point on a sphere equals that point or `secondInter`. -/
| Mathlib/Geometry/Euclidean/Sphere/SecondInter.lean | 82 | 98 | theorem Sphere.eq_or_eq_secondInter_of_mem_mk'_span_singleton_iff_mem {s : Sphere P} {p : P}
(hp : p ∈ s) {v : V} {p' : P} (hp' : p' ∈ AffineSubspace.mk' p (ℝ ∙ v)) :
p' = p ∨ p' = s.secondInter p v ↔ p' ∈ s := by |
refine ⟨fun h => ?_, fun h => ?_⟩
· rcases h with (h | h)
· rwa [h]
· rwa [h, Sphere.secondInter_mem]
· rw [AffineSubspace.mem_mk'_iff_vsub_mem, Submodule.mem_span_singleton] at hp'
rcases hp' with ⟨r, hr⟩
rw [eq_comm, ← eq_vadd_iff_vsub_eq] at hr
subst hr
by_cases hv : v = 0
· simp [hv]
rw [Sphere.secondInter]
rw [mem_sphere] at h hp
rw [← hp, dist_smul_vadd_eq_dist _ _ hv] at h
rcases h with (h | h) <;> simp [h]
|
/-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.Algebra.MvPolynomial.Expand
import Mathlib.FieldTheory.Finite.Basic
import Mathlib.RingTheory.MvPolynomial.Basic
#align_import field_theory.finite.polynomial from "leanprover-community/mathlib"@"5aa3c1de9f3c642eac76e11071c852766f220fd0"
/-!
## Polynomials over finite fields
-/
namespace MvPolynomial
variable {σ : Type*}
/-- A polynomial over the integers is divisible by `n : ℕ`
if and only if it is zero over `ZMod n`. -/
theorem C_dvd_iff_zmod (n : ℕ) (φ : MvPolynomial σ ℤ) :
C (n : ℤ) ∣ φ ↔ map (Int.castRingHom (ZMod n)) φ = 0 :=
C_dvd_iff_map_hom_eq_zero _ _ (CharP.intCast_eq_zero_iff (ZMod n) n) _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.C_dvd_iff_zmod MvPolynomial.C_dvd_iff_zmod
section frobenius
variable {p : ℕ} [Fact p.Prime]
theorem frobenius_zmod (f : MvPolynomial σ (ZMod p)) : frobenius _ p f = expand p f := by
apply induction_on f
· intro a; rw [expand_C, frobenius_def, ← C_pow, ZMod.pow_card]
· simp only [AlgHom.map_add, RingHom.map_add]; intro _ _ hf hg; rw [hf, hg]
· simp only [expand_X, RingHom.map_mul, AlgHom.map_mul]
intro _ _ hf; rw [hf, frobenius_def]
#align mv_polynomial.frobenius_zmod MvPolynomial.frobenius_zmod
theorem expand_zmod (f : MvPolynomial σ (ZMod p)) : expand p f = f ^ p :=
(frobenius_zmod _).symm
#align mv_polynomial.expand_zmod MvPolynomial.expand_zmod
end frobenius
end MvPolynomial
namespace MvPolynomial
noncomputable section
open scoped Classical
open Set LinearMap Submodule
variable {K : Type*} {σ : Type*}
section Indicator
variable [Fintype K] [Fintype σ]
/-- Over a field, this is the indicator function as an `MvPolynomial`. -/
def indicator [CommRing K] (a : σ → K) : MvPolynomial σ K :=
∏ n, (1 - (X n - C (a n)) ^ (Fintype.card K - 1))
#align mv_polynomial.indicator MvPolynomial.indicator
section CommRing
variable [CommRing K]
theorem eval_indicator_apply_eq_one (a : σ → K) : eval a (indicator a) = 1 := by
nontriviality
have : 0 < Fintype.card K - 1 := tsub_pos_of_lt Fintype.one_lt_card
simp only [indicator, map_prod, map_sub, map_one, map_pow, eval_X, eval_C, sub_self,
zero_pow this.ne', sub_zero, Finset.prod_const_one]
#align mv_polynomial.eval_indicator_apply_eq_one MvPolynomial.eval_indicator_apply_eq_one
theorem degrees_indicator (c : σ → K) :
degrees (indicator c) ≤ ∑ s : σ, (Fintype.card K - 1) • {s} := by
rw [indicator]
refine le_trans (degrees_prod _ _) (Finset.sum_le_sum fun s _ => ?_)
refine le_trans (degrees_sub _ _) ?_
rw [degrees_one, ← bot_eq_zero, bot_sup_eq]
refine le_trans (degrees_pow _ _) (nsmul_le_nsmul_right ?_ _)
refine le_trans (degrees_sub _ _) ?_
rw [degrees_C, ← bot_eq_zero, sup_bot_eq]
exact degrees_X' _
#align mv_polynomial.degrees_indicator MvPolynomial.degrees_indicator
theorem indicator_mem_restrictDegree (c : σ → K) :
indicator c ∈ restrictDegree σ K (Fintype.card K - 1) := by
rw [mem_restrictDegree_iff_sup, indicator]
intro n
refine le_trans (Multiset.count_le_of_le _ <| degrees_indicator _) (le_of_eq ?_)
simp_rw [← Multiset.coe_countAddMonoidHom, map_sum,
AddMonoidHom.map_nsmul, Multiset.coe_countAddMonoidHom, nsmul_eq_mul, Nat.cast_id]
trans
· refine Finset.sum_eq_single n ?_ ?_
· intro b _ ne
simp [Multiset.count_singleton, ne, if_neg (Ne.symm _)]
· intro h; exact (h <| Finset.mem_univ _).elim
· rw [Multiset.count_singleton_self, mul_one]
#align mv_polynomial.indicator_mem_restrict_degree MvPolynomial.indicator_mem_restrictDegree
end CommRing
variable [Field K]
| Mathlib/FieldTheory/Finite/Polynomial.lean | 110 | 116 | theorem eval_indicator_apply_eq_zero (a b : σ → K) (h : a ≠ b) : eval a (indicator b) = 0 := by |
obtain ⟨i, hi⟩ : ∃ i, a i ≠ b i := by rwa [Ne, Function.funext_iff, not_forall] at h
simp only [indicator, map_prod, map_sub, map_one, map_pow, eval_X, eval_C, sub_self,
Finset.prod_eq_zero_iff]
refine ⟨i, Finset.mem_univ _, ?_⟩
rw [FiniteField.pow_card_sub_one_eq_one, sub_self]
rwa [Ne, sub_eq_zero]
|
/-
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'
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]
#align interval_integrable_iff_integrable_Ioc_of_le intervalIntegrable_iff_integrableOn_Ioc_of_le
theorem intervalIntegrable_iff' [NoAtoms μ] :
IntervalIntegrable f μ a b ↔ IntegrableOn f (uIcc a b) μ := by
rw [intervalIntegrable_iff, ← Icc_min_max, uIoc, integrableOn_Icc_iff_integrableOn_Ioc]
#align interval_integrable_iff' intervalIntegrable_iff'
| Mathlib/MeasureTheory/Integral/IntervalIntegral.lean | 103 | 105 | theorem intervalIntegrable_iff_integrableOn_Icc_of_le {f : ℝ → E} {a b : ℝ} (hab : a ≤ b)
{μ : Measure ℝ} [NoAtoms μ] : IntervalIntegrable f μ a b ↔ IntegrableOn f (Icc a b) μ := by |
rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hab, integrableOn_Icc_iff_integrableOn_Ioc]
|
/-
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.CategoryTheory.Preadditive.AdditiveFunctor
import Mathlib.CategoryTheory.Monoidal.Functor
#align_import category_theory.monoidal.preadditive from "leanprover-community/mathlib"@"986c4d5761f938b2e1c43c01f001b6d9d88c2055"
/-!
# Preadditive monoidal categories
A monoidal category is `MonoidalPreadditive` if it is preadditive and tensor product of morphisms
is linear in both factors.
-/
noncomputable section
open scoped Classical
namespace CategoryTheory
open CategoryTheory.Limits
open CategoryTheory.MonoidalCategory
variable (C : Type*) [Category C] [Preadditive C] [MonoidalCategory C]
/-- A category is `MonoidalPreadditive` if tensoring is additive in both factors.
Note we don't `extend Preadditive C` here, as `Abelian C` already extends it,
and we'll need to have both typeclasses sometimes.
-/
class MonoidalPreadditive : Prop where
whiskerLeft_zero : ∀ {X Y Z : C}, X ◁ (0 : Y ⟶ Z) = 0 := by aesop_cat
zero_whiskerRight : ∀ {X Y Z : C}, (0 : Y ⟶ Z) ▷ X = 0 := by aesop_cat
whiskerLeft_add : ∀ {X Y Z : C} (f g : Y ⟶ Z), X ◁ (f + g) = X ◁ f + X ◁ g := by aesop_cat
add_whiskerRight : ∀ {X Y Z : C} (f g : Y ⟶ Z), (f + g) ▷ X = f ▷ X + g ▷ X := by aesop_cat
#align category_theory.monoidal_preadditive CategoryTheory.MonoidalPreadditive
attribute [simp] MonoidalPreadditive.whiskerLeft_zero MonoidalPreadditive.zero_whiskerRight
attribute [simp] MonoidalPreadditive.whiskerLeft_add MonoidalPreadditive.add_whiskerRight
variable {C}
variable [MonoidalPreadditive C]
namespace MonoidalPreadditive
-- The priority setting will not be needed when we replace `𝟙 X ⊗ f` by `X ◁ f`.
@[simp (low)]
theorem tensor_zero {W X Y Z : C} (f : W ⟶ X) : f ⊗ (0 : Y ⟶ Z) = 0 := by
simp [tensorHom_def]
-- The priority setting will not be needed when we replace `f ⊗ 𝟙 X` by `f ▷ X`.
@[simp (low)]
theorem zero_tensor {W X Y Z : C} (f : Y ⟶ Z) : (0 : W ⟶ X) ⊗ f = 0 := by
simp [tensorHom_def]
| Mathlib/CategoryTheory/Monoidal/Preadditive.lean | 60 | 61 | theorem tensor_add {W X Y Z : C} (f : W ⟶ X) (g h : Y ⟶ Z) : f ⊗ (g + h) = f ⊗ g + f ⊗ h := by |
simp [tensorHom_def]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.