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 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
| Mathlib/RingTheory/Int/Basic.lean | 77 | 83 | 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
|
/-
Copyright (c) 2022 John Nicol. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: John Nicol
-/
import Mathlib.FieldTheory.Finite.Basic
#align_import number_theory.wilson from "leanprover-community/mathlib"@"c471da714c044131b90c133701e51b877c246677"
/-!
# Wilson's theorem.
This file contains a proof of Wilson's theorem.
The heavy lifting is mostly done by the previous `wilsons_lemma`,
but here we also prove the other logical direction.
This could be generalized to similar results about finite abelian groups.
## References
* [Wilson's Theorem](https://en.wikipedia.org/wiki/Wilson%27s_theorem)
## TODO
* Give `wilsons_lemma` a descriptive name.
-/
open Finset Nat FiniteField ZMod
open scoped Nat
namespace ZMod
variable (p : ℕ) [Fact p.Prime]
/-- **Wilson's Lemma**: the product of `1`, ..., `p-1` is `-1` modulo `p`. -/
@[simp]
theorem wilsons_lemma : ((p - 1)! : ZMod p) = -1 := by
refine
calc
((p - 1)! : ZMod p) = ∏ x ∈ Ico 1 (succ (p - 1)), (x : ZMod p) := by
rw [← Finset.prod_Ico_id_eq_factorial, prod_natCast]
_ = ∏ x : (ZMod p)ˣ, (x : ZMod p) := ?_
_ = -1 := by
-- Porting note: `simp` is less powerful.
-- simp_rw [← Units.coeHom_apply, ← (Units.coeHom (ZMod p)).map_prod,
-- prod_univ_units_id_eq_neg_one, Units.coeHom_apply, Units.val_neg, Units.val_one]
simp_rw [← Units.coeHom_apply]
rw [← map_prod (Units.coeHom (ZMod p))]
simp_rw [prod_univ_units_id_eq_neg_one, Units.coeHom_apply, Units.val_neg, Units.val_one]
have hp : 0 < p := (Fact.out (p := p.Prime)).pos
symm
refine prod_bij (fun a _ => (a : ZMod p).val) ?_ ?_ ?_ ?_
· intro a ha
rw [mem_Ico, ← Nat.succ_sub hp, Nat.add_one_sub_one]
constructor
· apply Nat.pos_of_ne_zero; rw [← @val_zero p]
intro h; apply Units.ne_zero a (val_injective p h)
· exact val_lt _
· intro _ _ _ _ h; rw [Units.ext_iff]; exact val_injective p h
· intro b hb
rw [mem_Ico, Nat.succ_le_iff, ← succ_sub hp, Nat.add_one_sub_one, pos_iff_ne_zero] at hb
refine ⟨Units.mk0 b ?_, Finset.mem_univ _, ?_⟩
· intro h; apply hb.1; apply_fun val at h
simpa only [val_cast_of_lt hb.right, val_zero] using h
· simp only [val_cast_of_lt hb.right, Units.val_mk0]
· rintro a -; simp only [cast_id, natCast_val]
#align zmod.wilsons_lemma ZMod.wilsons_lemma
@[simp]
| Mathlib/NumberTheory/Wilson.lean | 73 | 79 | theorem prod_Ico_one_prime : ∏ x ∈ Ico 1 p, (x : ZMod p) = -1 := by |
-- Porting note: was `conv in Ico 1 p =>`
conv =>
congr
congr
rw [← Nat.add_one_sub_one p, succ_sub (Fact.out (p := p.Prime)).pos]
rw [← prod_natCast, Finset.prod_Ico_id_eq_factorial, wilsons_lemma]
|
/-
Copyright (c) 2023 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import Mathlib.GroupTheory.CoprodI
import Mathlib.GroupTheory.Coprod.Basic
import Mathlib.GroupTheory.QuotientGroup
import Mathlib.GroupTheory.Complement
/-!
## Pushouts of Monoids and Groups
This file defines wide pushouts of monoids and groups and proves some properties
of the amalgamated product of groups (i.e. the special case where all the maps
in the diagram are injective).
## Main definitions
- `Monoid.PushoutI`: the pushout of a diagram of monoids indexed by a type `ι`
- `Monoid.PushoutI.base`: the map from the amalgamating monoid to the pushout
- `Monoid.PushoutI.of`: the map from each Monoid in the family to the pushout
- `Monoid.PushoutI.lift`: the universal property used to define homomorphisms out of the pushout.
- `Monoid.PushoutI.NormalWord`: a normal form for words in the pushout
- `Monoid.PushoutI.of_injective`: if all the maps in the diagram are injective in a pushout of
groups then so is `of`
- `Monoid.PushoutI.Reduced.eq_empty_of_mem_range`: For any word `w` in the coproduct,
if `w` is reduced (i.e none its letters are in the image of the base monoid), and nonempty, then
`w` itself is not in the image of the base monoid.
## References
* The normal form theorem follows these [notes](https://webspace.maths.qmul.ac.uk/i.m.chiswell/ggt/lecture_notes/lecture2.pdf)
from Queen Mary University
## Tags
amalgamated product, pushout, group
-/
namespace Monoid
open CoprodI Subgroup Coprod Function List
variable {ι : Type*} {G : ι → Type*} {H : Type*} {K : Type*} [Monoid K]
/-- The relation we quotient by to form the pushout -/
def PushoutI.con [∀ i, Monoid (G i)] [Monoid H] (φ : ∀ i, H →* G i) :
Con (Coprod (CoprodI G) H) :=
conGen (fun x y : Coprod (CoprodI G) H =>
∃ i x', x = inl (of (φ i x')) ∧ y = inr x')
/-- The indexed pushout of monoids, which is the pushout in the category of monoids,
or the category of groups. -/
def PushoutI [∀ i, Monoid (G i)] [Monoid H] (φ : ∀ i, H →* G i) : Type _ :=
(PushoutI.con φ).Quotient
namespace PushoutI
section Monoid
variable [∀ i, Monoid (G i)] [Monoid H] {φ : ∀ i, H →* G i}
protected instance mul : Mul (PushoutI φ) := by
delta PushoutI; infer_instance
protected instance one : One (PushoutI φ) := by
delta PushoutI; infer_instance
instance monoid : Monoid (PushoutI φ) :=
{ Con.monoid _ with
toMul := PushoutI.mul
toOne := PushoutI.one }
/-- The map from each indexing group into the pushout -/
def of (i : ι) : G i →* PushoutI φ :=
(Con.mk' _).comp <| inl.comp CoprodI.of
variable (φ) in
/-- The map from the base monoid into the pushout -/
def base : H →* PushoutI φ :=
(Con.mk' _).comp inr
theorem of_comp_eq_base (i : ι) : (of i).comp (φ i) = (base φ) := by
ext x
apply (Con.eq _).2
refine ConGen.Rel.of _ _ ?_
simp only [MonoidHom.comp_apply, Set.mem_iUnion, Set.mem_range]
exact ⟨_, _, rfl, rfl⟩
variable (φ) in
theorem of_apply_eq_base (i : ι) (x : H) : of i (φ i x) = base φ x := by
rw [← MonoidHom.comp_apply, of_comp_eq_base]
/-- Define a homomorphism out of the pushout of monoids be defining it on each object in the
diagram -/
def lift (f : ∀ i, G i →* K) (k : H →* K)
(hf : ∀ i, (f i).comp (φ i) = k) :
PushoutI φ →* K :=
Con.lift _ (Coprod.lift (CoprodI.lift f) k) <| by
apply Con.conGen_le fun x y => ?_
rintro ⟨i, x', rfl, rfl⟩
simp only [DFunLike.ext_iff, MonoidHom.coe_comp, comp_apply] at hf
simp [hf]
@[simp]
theorem lift_of (f : ∀ i, G i →* K) (k : H →* K)
(hf : ∀ i, (f i).comp (φ i) = k)
{i : ι} (g : G i) : (lift f k hf) (of i g : PushoutI φ) = f i g := by
delta PushoutI lift of
simp only [MonoidHom.coe_comp, Con.coe_mk', comp_apply, Con.lift_coe,
lift_apply_inl, CoprodI.lift_of]
@[simp]
| Mathlib/GroupTheory/PushoutI.lean | 119 | 123 | theorem lift_base (f : ∀ i, G i →* K) (k : H →* K)
(hf : ∀ i, (f i).comp (φ i) = k)
(g : H) : (lift f k hf) (base φ g : PushoutI φ) = k g := by |
delta PushoutI lift base
simp only [MonoidHom.coe_comp, Con.coe_mk', comp_apply, Con.lift_coe, lift_apply_inr]
|
/-
Copyright (c) 2020 Kevin Buzzard. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kevin Buzzard
-/
import Mathlib.RingTheory.PrincipalIdealDomain
import Mathlib.RingTheory.Ideal.LocalRing
import Mathlib.RingTheory.Valuation.PrimeMultiplicity
import Mathlib.RingTheory.AdicCompletion.Basic
#align_import ring_theory.discrete_valuation_ring.basic from "leanprover-community/mathlib"@"c163ec99dfc664628ca15d215fce0a5b9c265b68"
/-!
# Discrete valuation rings
This file defines discrete valuation rings (DVRs) and develops a basic interface
for them.
## Important definitions
There are various definitions of a DVR in the literature; we define a DVR to be a local PID
which is not a field (the first definition in Wikipedia) and prove that this is equivalent
to being a PID with a unique non-zero prime ideal (the definition in Serre's
book "Local Fields").
Let R be an integral domain, assumed to be a principal ideal ring and a local ring.
* `DiscreteValuationRing R` : a predicate expressing that R is a DVR.
### Definitions
* `addVal R : AddValuation R PartENat` : the additive valuation on a DVR.
## Implementation notes
It's a theorem that an element of a DVR is a uniformizer if and only if it's irreducible.
We do not hence define `Uniformizer` at all, because we can use `Irreducible` instead.
## Tags
discrete valuation ring
-/
open scoped Classical
universe u
open Ideal LocalRing
/-- An integral domain is a *discrete valuation ring* (DVR) if it's a local PID which
is not a field. -/
class DiscreteValuationRing (R : Type u) [CommRing R] [IsDomain R]
extends IsPrincipalIdealRing R, LocalRing R : Prop where
not_a_field' : maximalIdeal R ≠ ⊥
#align discrete_valuation_ring DiscreteValuationRing
namespace DiscreteValuationRing
variable (R : Type u) [CommRing R] [IsDomain R] [DiscreteValuationRing R]
theorem not_a_field : maximalIdeal R ≠ ⊥ :=
not_a_field'
#align discrete_valuation_ring.not_a_field DiscreteValuationRing.not_a_field
/-- A discrete valuation ring `R` is not a field. -/
theorem not_isField : ¬IsField R :=
LocalRing.isField_iff_maximalIdeal_eq.not.mpr (not_a_field R)
#align discrete_valuation_ring.not_is_field DiscreteValuationRing.not_isField
variable {R}
open PrincipalIdealRing
theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R]
(ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by
have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ
refine ⟨h2, ?_⟩
intro a b hab
by_contra! h
obtain ⟨ha : a ∈ maximalIdeal R, hb : b ∈ maximalIdeal R⟩ := h
rw [h, mem_span_singleton'] at ha hb
rcases ha with ⟨a, rfl⟩
rcases hb with ⟨b, rfl⟩
rw [show a * ϖ * (b * ϖ) = ϖ * (ϖ * (a * b)) by ring] at hab
apply hϖ
apply eq_zero_of_mul_eq_self_right _ hab.symm
exact fun hh => h2 (isUnit_of_dvd_one ⟨_, hh.symm⟩)
#align discrete_valuation_ring.irreducible_of_span_eq_maximal_ideal DiscreteValuationRing.irreducible_of_span_eq_maximalIdeal
/-- An element of a DVR is irreducible iff it is a uniformizer, that is, generates the
maximal ideal of `R`. -/
theorem irreducible_iff_uniformizer (ϖ : R) : Irreducible ϖ ↔ maximalIdeal R = Ideal.span {ϖ} :=
⟨fun hϖ => (eq_maximalIdeal (isMaximal_of_irreducible hϖ)).symm,
fun h => irreducible_of_span_eq_maximalIdeal ϖ
(fun e => not_a_field R <| by rwa [h, span_singleton_eq_bot]) h⟩
#align discrete_valuation_ring.irreducible_iff_uniformizer DiscreteValuationRing.irreducible_iff_uniformizer
theorem _root_.Irreducible.maximalIdeal_eq {ϖ : R} (h : Irreducible ϖ) :
maximalIdeal R = Ideal.span {ϖ} :=
(irreducible_iff_uniformizer _).mp h
#align irreducible.maximal_ideal_eq Irreducible.maximalIdeal_eq
variable (R)
/-- Uniformizers exist in a DVR. -/
theorem exists_irreducible : ∃ ϖ : R, Irreducible ϖ := by
simp_rw [irreducible_iff_uniformizer]
exact (IsPrincipalIdealRing.principal <| maximalIdeal R).principal
#align discrete_valuation_ring.exists_irreducible DiscreteValuationRing.exists_irreducible
/-- Uniformizers exist in a DVR. -/
theorem exists_prime : ∃ ϖ : R, Prime ϖ :=
(exists_irreducible R).imp fun _ => irreducible_iff_prime.1
#align discrete_valuation_ring.exists_prime DiscreteValuationRing.exists_prime
/-- An integral domain is a DVR iff it's a PID with a unique non-zero prime ideal. -/
| Mathlib/RingTheory/DiscreteValuationRing/Basic.lean | 118 | 145 | theorem iff_pid_with_one_nonzero_prime (R : Type u) [CommRing R] [IsDomain R] :
DiscreteValuationRing R ↔ IsPrincipalIdealRing R ∧ ∃! P : Ideal R, P ≠ ⊥ ∧ IsPrime P := by |
constructor
· intro RDVR
rcases id RDVR with ⟨Rlocal⟩
constructor
· assumption
use LocalRing.maximalIdeal R
constructor
· exact ⟨Rlocal, inferInstance⟩
· rintro Q ⟨hQ1, hQ2⟩
obtain ⟨q, rfl⟩ := (IsPrincipalIdealRing.principal Q).1
have hq : q ≠ 0 := by
rintro rfl
apply hQ1
simp
erw [span_singleton_prime hq] at hQ2
replace hQ2 := hQ2.irreducible
rw [irreducible_iff_uniformizer] at hQ2
exact hQ2.symm
· rintro ⟨RPID, Punique⟩
haveI : LocalRing R := LocalRing.of_unique_nonzero_prime Punique
refine { not_a_field' := ?_ }
rcases Punique with ⟨P, ⟨hP1, hP2⟩, _⟩
have hPM : P ≤ maximalIdeal R := le_maximalIdeal hP2.1
intro h
rw [h, le_bot_iff] at hPM
exact hP1 hPM
|
/-
Copyright (c) 2023 Ali Ramsey. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Ali Ramsey, Eric Wieser
-/
import Mathlib.LinearAlgebra.Finsupp
import Mathlib.LinearAlgebra.Prod
import Mathlib.LinearAlgebra.TensorProduct.Basic
/-!
# Coalgebras
In this file we define `Coalgebra`, and provide instances for:
* Commutative semirings: `CommSemiring.toCoalgebra`
* Binary products: `Prod.instCoalgebra`
* Finitely supported functions: `Finsupp.instCoalgebra`
## References
* <https://en.wikipedia.org/wiki/Coalgebra>
-/
suppress_compilation
universe u v w
open scoped TensorProduct
/-- Data fields for `Coalgebra`, to allow API to be constructed before proving `Coalgebra.coassoc`.
See `Coalgebra` for documentation. -/
class CoalgebraStruct (R : Type u) (A : Type v)
[CommSemiring R] [AddCommMonoid A] [Module R A] where
/-- The comultiplication of the coalgebra -/
comul : A →ₗ[R] A ⊗[R] A
/-- The counit of the coalgebra -/
counit : A →ₗ[R] R
namespace Coalgebra
export CoalgebraStruct (comul counit)
end Coalgebra
/-- A coalgebra over a commutative (semi)ring `R` is an `R`-module equipped with a coassociative
comultiplication `Δ` and a counit `ε` obeying the left and right counitality laws. -/
class Coalgebra (R : Type u) (A : Type v)
[CommSemiring R] [AddCommMonoid A] [Module R A] extends CoalgebraStruct R A where
/-- The comultiplication is coassociative -/
coassoc : TensorProduct.assoc R A A A ∘ₗ comul.rTensor A ∘ₗ comul = comul.lTensor A ∘ₗ comul
/-- The counit satisfies the left counitality law -/
rTensor_counit_comp_comul : counit.rTensor A ∘ₗ comul = TensorProduct.mk R _ _ 1
/-- The counit satisfies the right counitality law -/
lTensor_counit_comp_comul : counit.lTensor A ∘ₗ comul = (TensorProduct.mk R _ _).flip 1
namespace Coalgebra
variable {R : Type u} {A : Type v}
variable [CommSemiring R] [AddCommMonoid A] [Module R A] [Coalgebra R A]
@[simp]
theorem coassoc_apply (a : A) :
TensorProduct.assoc R A A A (comul.rTensor A (comul a)) = comul.lTensor A (comul a) :=
LinearMap.congr_fun coassoc a
@[simp]
theorem coassoc_symm_apply (a : A) :
(TensorProduct.assoc R A A A).symm (comul.lTensor A (comul a)) = comul.rTensor A (comul a) := by
rw [(TensorProduct.assoc R A A A).symm_apply_eq, coassoc_apply a]
@[simp]
theorem coassoc_symm :
(TensorProduct.assoc R A A A).symm ∘ₗ comul.lTensor A ∘ₗ comul =
comul.rTensor A ∘ₗ (comul (R := R)) :=
LinearMap.ext coassoc_symm_apply
@[simp]
theorem rTensor_counit_comul (a : A) : counit.rTensor A (comul a) = 1 ⊗ₜ[R] a :=
LinearMap.congr_fun rTensor_counit_comp_comul a
@[simp]
theorem lTensor_counit_comul (a : A) : counit.lTensor A (comul a) = a ⊗ₜ[R] 1 :=
LinearMap.congr_fun lTensor_counit_comp_comul a
end Coalgebra
section CommSemiring
open Coalgebra
namespace CommSemiring
variable (R : Type u) [CommSemiring R]
/-- Every commutative (semi)ring is a coalgebra over itself, with `Δ r = 1 ⊗ₜ r`. -/
instance toCoalgebra : Coalgebra R R where
comul := (TensorProduct.mk R R R) 1
counit := .id
coassoc := rfl
rTensor_counit_comp_comul := by ext; rfl
lTensor_counit_comp_comul := by ext; rfl
@[simp]
theorem comul_apply (r : R) : comul r = 1 ⊗ₜ[R] r := rfl
@[simp]
theorem counit_apply (r : R) : counit r = r := rfl
end CommSemiring
namespace Prod
variable (R : Type u) (A : Type v) (B : Type w)
variable [CommSemiring R] [AddCommMonoid A] [AddCommMonoid B] [Module R A] [Module R B]
variable [Coalgebra R A] [Coalgebra R B]
open LinearMap
instance instCoalgebraStruct : CoalgebraStruct R (A × B) where
comul := .coprod
(TensorProduct.map (.inl R A B) (.inl R A B) ∘ₗ comul)
(TensorProduct.map (.inr R A B) (.inr R A B) ∘ₗ comul)
counit := .coprod counit counit
@[simp]
theorem comul_apply (r : A × B) :
comul r =
TensorProduct.map (.inl R A B) (.inl R A B) (comul r.1) +
TensorProduct.map (.inr R A B) (.inr R A B) (comul r.2) := rfl
@[simp]
theorem counit_apply (r : A × B) : (counit r : R) = counit r.1 + counit r.2 := rfl
| Mathlib/RingTheory/Coalgebra/Basic.lean | 129 | 131 | theorem comul_comp_inl :
comul ∘ₗ inl R A B = TensorProduct.map (.inl R A B) (.inl R A B) ∘ₗ comul := by |
ext; simp
|
/-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Algebra.Order.Ring.Nat
import Mathlib.Combinatorics.SetFamily.Compression.Down
import Mathlib.Order.UpperLower.Basic
import Mathlib.Data.Fintype.Powerset
#align_import combinatorics.set_family.harris_kleitman from "leanprover-community/mathlib"@"b363547b3113d350d053abdf2884e9850a56b205"
/-!
# Harris-Kleitman inequality
This file proves the Harris-Kleitman inequality. This relates `𝒜.card * ℬ.card` and
`2 ^ card α * (𝒜 ∩ ℬ).card` where `𝒜` and `ℬ` are upward- or downcard-closed finite families of
finsets. This can be interpreted as saying that any two lower sets (resp. any two upper sets)
correlate in the uniform measure.
## Main declarations
* `IsLowerSet.le_card_inter_finset`: One form of the Harris-Kleitman inequality.
## References
* [D. J. Kleitman, *Families of non-disjoint subsets*][kleitman1966]
-/
open Finset
variable {α : Type*} [DecidableEq α] {𝒜 ℬ : Finset (Finset α)} {s : Finset α} {a : α}
theorem IsLowerSet.nonMemberSubfamily (h : IsLowerSet (𝒜 : Set (Finset α))) :
IsLowerSet (𝒜.nonMemberSubfamily a : Set (Finset α)) := fun s t hts => by
simp_rw [mem_coe, mem_nonMemberSubfamily]
exact And.imp (h hts) (mt <| @hts _)
#align is_lower_set.non_member_subfamily IsLowerSet.nonMemberSubfamily
| Mathlib/Combinatorics/SetFamily/HarrisKleitman.lean | 41 | 45 | theorem IsLowerSet.memberSubfamily (h : IsLowerSet (𝒜 : Set (Finset α))) :
IsLowerSet (𝒜.memberSubfamily a : Set (Finset α)) := by |
rintro s t hts
simp_rw [mem_coe, mem_memberSubfamily]
exact And.imp (h <| insert_subset_insert _ hts) (mt <| @hts _)
|
/-
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.Algebra.Polynomial.Taylor
import Mathlib.FieldTheory.RatFunc.AsPolynomial
#align_import field_theory.laurent from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
/-!
# Laurent expansions of rational functions
## Main declarations
* `RatFunc.laurent`: the Laurent expansion of the rational function `f` at `r`, as an `AlgHom`.
* `RatFunc.laurent_injective`: the Laurent expansion at `r` is unique
## Implementation details
Implemented as the quotient of two Taylor expansions, over domains.
An auxiliary definition is provided first to make the construction of the `AlgHom` easier,
which works on `CommRing` which are not necessarily domains.
-/
universe u
namespace RatFunc
noncomputable section
open Polynomial
open scoped Classical nonZeroDivisors Polynomial
variable {R : Type u} [CommRing R] [hdomain : IsDomain R] (r s : R) (p q : R[X]) (f : RatFunc R)
theorem taylor_mem_nonZeroDivisors (hp : p ∈ R[X]⁰) : taylor r p ∈ R[X]⁰ := by
rw [mem_nonZeroDivisors_iff]
intro x hx
have : x = taylor (r - r) x := by simp
rwa [this, sub_eq_add_neg, ← taylor_taylor, ← taylor_mul,
LinearMap.map_eq_zero_iff _ (taylor_injective _), mul_right_mem_nonZeroDivisors_eq_zero_iff hp,
LinearMap.map_eq_zero_iff _ (taylor_injective _)] at hx
#align ratfunc.taylor_mem_non_zero_divisors RatFunc.taylor_mem_nonZeroDivisors
/-- The Laurent expansion of rational functions about a value.
Auxiliary definition, usage when over integral domains should prefer `RatFunc.laurent`. -/
def laurentAux : RatFunc R →+* RatFunc R :=
RatFunc.mapRingHom
( { toFun := taylor r
map_add' := map_add (taylor r)
map_mul' := taylor_mul _
map_zero' := map_zero (taylor r)
map_one' := taylor_one r } : R[X] →+* R[X])
(taylor_mem_nonZeroDivisors _)
#align ratfunc.laurent_aux RatFunc.laurentAux
theorem laurentAux_ofFractionRing_mk (q : R[X]⁰) :
laurentAux r (ofFractionRing (Localization.mk p q)) =
ofFractionRing (.mk (taylor r p) ⟨taylor r q, taylor_mem_nonZeroDivisors r q q.prop⟩) :=
map_apply_ofFractionRing_mk _ _ _ _
#align ratfunc.laurent_aux_of_fraction_ring_mk RatFunc.laurentAux_ofFractionRing_mk
theorem laurentAux_div :
laurentAux r (algebraMap _ _ p / algebraMap _ _ q) =
algebraMap _ _ (taylor r p) / algebraMap _ _ (taylor r q) :=
-- Porting note: added `by exact taylor_mem_nonZeroDivisors r`
map_apply_div _ (by exact taylor_mem_nonZeroDivisors r) _ _
#align ratfunc.laurent_aux_div RatFunc.laurentAux_div
@[simp]
| Mathlib/FieldTheory/Laurent.lean | 74 | 75 | theorem laurentAux_algebraMap : laurentAux r (algebraMap _ _ p) = algebraMap _ _ (taylor r p) := by |
rw [← mk_one, ← mk_one, mk_eq_div, laurentAux_div, mk_eq_div, taylor_one, map_one, map_one]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Alexander Bentkamp
-/
import Mathlib.LinearAlgebra.Basis
import Mathlib.LinearAlgebra.FreeModule.Basic
import Mathlib.LinearAlgebra.LinearPMap
import Mathlib.LinearAlgebra.Projection
#align_import linear_algebra.basis from "leanprover-community/mathlib"@"13bce9a6b6c44f6b4c91ac1c1d2a816e2533d395"
/-!
# Bases in a vector space
This file provides results for bases of a vector space.
Some of these results should be merged with the results on free modules.
We state these results in a separate file to the results on modules to avoid an
import cycle.
## Main statements
* `Basis.ofVectorSpace` states that every vector space has a basis.
* `Module.Free.of_divisionRing` states that every vector space is a free module.
## Tags
basis, bases
-/
open Function Set Submodule
set_option autoImplicit false
variable {ι : Type*} {ι' : Type*} {K : Type*} {V : Type*} {V' : Type*}
section DivisionRing
variable [DivisionRing K] [AddCommGroup V] [AddCommGroup V'] [Module K V] [Module K V']
variable {v : ι → V} {s t : Set V} {x y z : V}
open Submodule
namespace Basis
section ExistsBasis
/-- If `s` is a linear independent set of vectors, we can extend it to a basis. -/
noncomputable def extend (hs : LinearIndependent K ((↑) : s → V)) :
Basis (hs.extend (subset_univ s)) K V :=
Basis.mk
(@LinearIndependent.restrict_of_comp_subtype _ _ _ id _ _ _ _ (hs.linearIndependent_extend _))
(SetLike.coe_subset_coe.mp <| by simpa using hs.subset_span_extend (subset_univ s))
#align basis.extend Basis.extend
theorem extend_apply_self (hs : LinearIndependent K ((↑) : s → V)) (x : hs.extend _) :
Basis.extend hs x = x :=
Basis.mk_apply _ _ _
#align basis.extend_apply_self Basis.extend_apply_self
@[simp]
theorem coe_extend (hs : LinearIndependent K ((↑) : s → V)) : ⇑(Basis.extend hs) = ((↑) : _ → _) :=
funext (extend_apply_self hs)
#align basis.coe_extend Basis.coe_extend
theorem range_extend (hs : LinearIndependent K ((↑) : s → V)) :
range (Basis.extend hs) = hs.extend (subset_univ _) := by
rw [coe_extend, Subtype.range_coe_subtype, setOf_mem_eq]
#align basis.range_extend Basis.range_extend
-- Porting note: adding this to make the statement of `subExtend` more readable
/-- Auxiliary definition: the index for the new basis vectors in `Basis.sumExtend`.
The specific value of this definition should be considered an implementation detail.
-/
def sumExtendIndex (hs : LinearIndependent K v) : Set V :=
LinearIndependent.extend hs.to_subtype_range (subset_univ _) \ range v
/-- If `v` is a linear independent family of vectors, extend it to a basis indexed by a sum type. -/
noncomputable def sumExtend (hs : LinearIndependent K v) : Basis (ι ⊕ sumExtendIndex hs) K V :=
let s := Set.range v
let e : ι ≃ s := Equiv.ofInjective v hs.injective
let b := hs.to_subtype_range.extend (subset_univ (Set.range v))
(Basis.extend hs.to_subtype_range).reindex <|
Equiv.symm <|
calc
Sum ι (b \ s : Set V) ≃ Sum s (b \ s : Set V) := Equiv.sumCongr e (Equiv.refl _)
_ ≃ b :=
haveI := Classical.decPred (· ∈ s)
Equiv.Set.sumDiffSubset (hs.to_subtype_range.subset_extend _)
#align basis.sum_extend Basis.sumExtend
theorem subset_extend {s : Set V} (hs : LinearIndependent K ((↑) : s → V)) :
s ⊆ hs.extend (Set.subset_univ _) :=
hs.subset_extend _
#align basis.subset_extend Basis.subset_extend
section
variable (K V)
/-- A set used to index `Basis.ofVectorSpace`. -/
noncomputable def ofVectorSpaceIndex : Set V :=
(linearIndependent_empty K V).extend (subset_univ _)
#align basis.of_vector_space_index Basis.ofVectorSpaceIndex
/-- Each vector space has a basis. -/
noncomputable def ofVectorSpace : Basis (ofVectorSpaceIndex K V) K V :=
Basis.extend (linearIndependent_empty K V)
#align basis.of_vector_space Basis.ofVectorSpace
instance (priority := 100) _root_.Module.Free.of_divisionRing : Module.Free K V :=
Module.Free.of_basis (ofVectorSpace K V)
#align module.free.of_division_ring Module.Free.of_divisionRing
theorem ofVectorSpace_apply_self (x : ofVectorSpaceIndex K V) : ofVectorSpace K V x = x := by
unfold ofVectorSpace
exact Basis.mk_apply _ _ _
#align basis.of_vector_space_apply_self Basis.ofVectorSpace_apply_self
@[simp]
theorem coe_ofVectorSpace : ⇑(ofVectorSpace K V) = ((↑) : _ → _ ) :=
funext fun x => ofVectorSpace_apply_self K V x
#align basis.coe_of_vector_space Basis.coe_ofVectorSpace
theorem ofVectorSpaceIndex.linearIndependent :
LinearIndependent K ((↑) : ofVectorSpaceIndex K V → V) := by
convert (ofVectorSpace K V).linearIndependent
ext x
rw [ofVectorSpace_apply_self]
#align basis.of_vector_space_index.linear_independent Basis.ofVectorSpaceIndex.linearIndependent
theorem range_ofVectorSpace : range (ofVectorSpace K V) = ofVectorSpaceIndex K V :=
range_extend _
#align basis.range_of_vector_space Basis.range_ofVectorSpace
theorem exists_basis : ∃ s : Set V, Nonempty (Basis s K V) :=
⟨ofVectorSpaceIndex K V, ⟨ofVectorSpace K V⟩⟩
#align basis.exists_basis Basis.exists_basis
end
end ExistsBasis
end Basis
open Fintype
variable (K V)
| Mathlib/LinearAlgebra/Basis/VectorSpace.lean | 152 | 154 | theorem VectorSpace.card_fintype [Fintype K] [Fintype V] : ∃ n : ℕ, card V = card K ^ n := by |
classical
exact ⟨card (Basis.ofVectorSpaceIndex K V), Module.card_fintype (Basis.ofVectorSpace K V)⟩
|
/-
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]
theorem card_Ico : (Ico a b).card = b - a := by
rw [← Nat.card_Ico, ← map_valEmbedding_Ico, card_map]
#align fin.card_Ico Fin.card_Ico
@[simp]
theorem card_Ioc : (Ioc a b).card = b - a := by
rw [← Nat.card_Ioc, ← map_valEmbedding_Ioc, card_map]
#align fin.card_Ioc Fin.card_Ioc
@[simp]
| Mathlib/Order/Interval/Finset/Fin.lean | 119 | 120 | theorem card_Ioo : (Ioo a b).card = b - a - 1 := by |
rw [← Nat.card_Ioo, ← map_valEmbedding_Ioo, card_map]
|
/-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.Data.Nat.Multiplicity
import Mathlib.Data.ZMod.Algebra
import Mathlib.RingTheory.WittVector.Basic
import Mathlib.RingTheory.WittVector.IsPoly
import Mathlib.FieldTheory.Perfect
#align_import ring_theory.witt_vector.frobenius from "leanprover-community/mathlib"@"0723536a0522d24fc2f159a096fb3304bef77472"
/-!
## The Frobenius operator
If `R` has characteristic `p`, then there is a ring endomorphism `frobenius R p`
that raises `r : R` to the power `p`.
By applying `WittVector.map` to `frobenius R p`, we obtain a ring endomorphism `𝕎 R →+* 𝕎 R`.
It turns out that this endomorphism can be described by polynomials over `ℤ`
that do not depend on `R` or the fact that it has characteristic `p`.
In this way, we obtain a Frobenius endomorphism `WittVector.frobeniusFun : 𝕎 R → 𝕎 R`
for every commutative ring `R`.
Unfortunately, the aforementioned polynomials can not be obtained using the machinery
of `wittStructureInt` that was developed in `StructurePolynomial.lean`.
We therefore have to define the polynomials by hand, and check that they have the required property.
In case `R` has characteristic `p`, we show in `frobenius_eq_map_frobenius`
that `WittVector.frobeniusFun` is equal to `WittVector.map (frobenius R p)`.
### Main definitions and results
* `frobeniusPoly`: the polynomials that describe the coefficients of `frobeniusFun`;
* `frobeniusFun`: the Frobenius endomorphism on Witt vectors;
* `frobeniusFun_isPoly`: the tautological assertion that Frobenius is a polynomial function;
* `frobenius_eq_map_frobenius`: the fact that in characteristic `p`, Frobenius is equal to
`WittVector.map (frobenius R p)`.
TODO: Show that `WittVector.frobeniusFun` is a ring homomorphism,
and bundle it into `WittVector.frobenius`.
## References
* [Hazewinkel, *Witt Vectors*][Haze09]
* [Commelin and Lewis, *Formalizing the Ring of Witt Vectors*][CL21]
-/
namespace WittVector
variable {p : ℕ} {R S : Type*} [hp : Fact p.Prime] [CommRing R] [CommRing S]
local notation "𝕎" => WittVector p -- type as `\bbW`
noncomputable section
open MvPolynomial Finset
variable (p)
/-- The rational polynomials that give the coefficients of `frobenius x`,
in terms of the coefficients of `x`.
These polynomials actually have integral coefficients,
see `frobeniusPoly` and `map_frobeniusPoly`. -/
def frobeniusPolyRat (n : ℕ) : MvPolynomial ℕ ℚ :=
bind₁ (wittPolynomial p ℚ ∘ fun n => n + 1) (xInTermsOfW p ℚ n)
#align witt_vector.frobenius_poly_rat WittVector.frobeniusPolyRat
| Mathlib/RingTheory/WittVector/Frobenius.lean | 71 | 74 | theorem bind₁_frobeniusPolyRat_wittPolynomial (n : ℕ) :
bind₁ (frobeniusPolyRat p) (wittPolynomial p ℚ n) = wittPolynomial p ℚ (n + 1) := by |
delta frobeniusPolyRat
rw [← bind₁_bind₁, bind₁_xInTermsOfW_wittPolynomial, bind₁_X_right, Function.comp_apply]
|
/-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Data.Matrix.Basis
import Mathlib.Data.Matrix.DMatrix
import Mathlib.RingTheory.MatrixAlgebra
#align_import ring_theory.polynomial_algebra from "leanprover-community/mathlib"@"565eb991e264d0db702722b4bde52ee5173c9950"
/-!
# Algebra isomorphism between matrices of polynomials and polynomials of matrices
Given `[CommRing R] [Ring A] [Algebra R A]`
we show `A[X] ≃ₐ[R] (A ⊗[R] R[X])`.
Combining this with the isomorphism `Matrix n n A ≃ₐ[R] (A ⊗[R] Matrix n n R)` proved earlier
in `RingTheory.MatrixAlgebra`, we obtain the algebra isomorphism
```
def matPolyEquiv :
Matrix n n R[X] ≃ₐ[R] (Matrix n n R)[X]
```
which is characterized by
```
coeff (matPolyEquiv m) k i j = coeff (m i j) k
```
We will use this algebra isomorphism to prove the Cayley-Hamilton theorem.
-/
universe u v w
open Polynomial TensorProduct
open Algebra.TensorProduct (algHomOfLinearMapTensorProduct includeLeft)
noncomputable section
variable (R A : Type*)
variable [CommSemiring R]
variable [Semiring A] [Algebra R A]
namespace PolyEquivTensor
/-- (Implementation detail).
The function underlying `A ⊗[R] R[X] →ₐ[R] A[X]`,
as a bilinear function of two arguments.
-/
-- Porting note: was `@[simps apply_apply]`
@[simps! apply_apply]
def toFunBilinear : A →ₗ[A] R[X] →ₗ[R] A[X] :=
LinearMap.toSpanSingleton A _ (aeval (Polynomial.X : A[X])).toLinearMap
#align poly_equiv_tensor.to_fun_bilinear PolyEquivTensor.toFunBilinear
| Mathlib/RingTheory/PolynomialAlgebra.lean | 56 | 61 | theorem toFunBilinear_apply_eq_sum (a : A) (p : R[X]) :
toFunBilinear R A a p = p.sum fun n r => monomial n (a * algebraMap R A r) := by |
simp only [toFunBilinear_apply_apply, aeval_def, eval₂_eq_sum, Polynomial.sum, Finset.smul_sum]
congr with i : 1
rw [← Algebra.smul_def, ← C_mul', mul_smul_comm, C_mul_X_pow_eq_monomial, ← Algebra.commutes,
← Algebra.smul_def, smul_monomial]
|
/-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Algebra.Order.Group.Instances
import Mathlib.Algebra.Order.Group.OrderIso
import Mathlib.Data.Set.Pointwise.SMul
import Mathlib.Order.UpperLower.Basic
#align_import algebra.order.upper_lower from "leanprover-community/mathlib"@"c0c52abb75074ed8b73a948341f50521fbf43b4c"
/-!
# Algebraic operations on upper/lower sets
Upper/lower sets are preserved under pointwise algebraic operations in ordered groups.
-/
open Function Set
open Pointwise
section OrderedCommMonoid
variable {α : Type*} [OrderedCommMonoid α] {s : Set α} {x : α}
@[to_additive]
theorem IsUpperSet.smul_subset (hs : IsUpperSet s) (hx : 1 ≤ x) : x • s ⊆ s :=
smul_set_subset_iff.2 fun _ ↦ hs <| le_mul_of_one_le_left' hx
#align is_upper_set.smul_subset IsUpperSet.smul_subset
#align is_upper_set.vadd_subset IsUpperSet.vadd_subset
@[to_additive]
theorem IsLowerSet.smul_subset (hs : IsLowerSet s) (hx : x ≤ 1) : x • s ⊆ s :=
smul_set_subset_iff.2 fun _ ↦ hs <| mul_le_of_le_one_left' hx
#align is_lower_set.smul_subset IsLowerSet.smul_subset
#align is_lower_set.vadd_subset IsLowerSet.vadd_subset
end OrderedCommMonoid
section OrderedCommGroup
variable {α : Type*} [OrderedCommGroup α] {s t : Set α} {a : α}
@[to_additive]
theorem IsUpperSet.smul (hs : IsUpperSet s) : IsUpperSet (a • s) := hs.image <| OrderIso.mulLeft _
#align is_upper_set.smul IsUpperSet.smul
#align is_upper_set.vadd IsUpperSet.vadd
@[to_additive]
theorem IsLowerSet.smul (hs : IsLowerSet s) : IsLowerSet (a • s) := hs.image <| OrderIso.mulLeft _
#align is_lower_set.smul IsLowerSet.smul
#align is_lower_set.vadd IsLowerSet.vadd
@[to_additive]
theorem Set.OrdConnected.smul (hs : s.OrdConnected) : (a • s).OrdConnected := by
rw [← hs.upperClosure_inter_lowerClosure, smul_set_inter]
exact (upperClosure _).upper.smul.ordConnected.inter (lowerClosure _).lower.smul.ordConnected
#align set.ord_connected.smul Set.OrdConnected.smul
#align set.ord_connected.vadd Set.OrdConnected.vadd
@[to_additive]
| Mathlib/Algebra/Order/UpperLower.lean | 63 | 65 | theorem IsUpperSet.mul_left (ht : IsUpperSet t) : IsUpperSet (s * t) := by |
rw [← smul_eq_mul, ← Set.iUnion_smul_set]
exact isUpperSet_iUnion₂ fun x _ ↦ ht.smul
|
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Yury G. Kudryashov
-/
import Batteries.Data.Sum.Basic
import Batteries.Logic
/-!
# Disjoint union of types
Theorems about the definitions introduced in `Batteries.Data.Sum.Basic`.
-/
open Function
namespace Sum
@[simp] protected theorem «forall» {p : α ⊕ β → Prop} :
(∀ x, p x) ↔ (∀ a, p (inl a)) ∧ ∀ b, p (inr b) :=
⟨fun h => ⟨fun _ => h _, fun _ => h _⟩, fun ⟨h₁, h₂⟩ => Sum.rec h₁ h₂⟩
@[simp] protected theorem «exists» {p : α ⊕ β → Prop} :
(∃ x, p x) ↔ (∃ a, p (inl a)) ∨ ∃ b, p (inr b) :=
⟨ fun
| ⟨inl a, h⟩ => Or.inl ⟨a, h⟩
| ⟨inr b, h⟩ => Or.inr ⟨b, h⟩,
fun
| Or.inl ⟨a, h⟩ => ⟨inl a, h⟩
| Or.inr ⟨b, h⟩ => ⟨inr b, h⟩⟩
theorem forall_sum {γ : α ⊕ β → Sort _} (p : (∀ ab, γ ab) → Prop) :
(∀ fab, p fab) ↔ (∀ fa fb, p (Sum.rec fa fb)) := by
refine ⟨fun h fa fb => h _, fun h fab => ?_⟩
have h1 : fab = Sum.rec (fun a => fab (Sum.inl a)) (fun b => fab (Sum.inr b)) := by
ext ab; cases ab <;> rfl
rw [h1]; exact h _ _
section get
@[simp] theorem inl_getLeft : ∀ (x : α ⊕ β) (h : x.isLeft), inl (x.getLeft h) = x
| inl _, _ => rfl
@[simp] theorem inr_getRight : ∀ (x : α ⊕ β) (h : x.isRight), inr (x.getRight h) = x
| inr _, _ => rfl
@[simp] theorem getLeft?_eq_none_iff {x : α ⊕ β} : x.getLeft? = none ↔ x.isRight := by
cases x <;> simp only [getLeft?, isRight, eq_self_iff_true]
@[simp] theorem getRight?_eq_none_iff {x : α ⊕ β} : x.getRight? = none ↔ x.isLeft := by
cases x <;> simp only [getRight?, isLeft, eq_self_iff_true]
theorem eq_left_getLeft_of_isLeft : ∀ {x : α ⊕ β} (h : x.isLeft), x = inl (x.getLeft h)
| inl _, _ => rfl
@[simp] theorem getLeft_eq_iff (h : x.isLeft) : x.getLeft h = a ↔ x = inl a := by
cases x <;> simp at h ⊢
theorem eq_right_getRight_of_isRight : ∀ {x : α ⊕ β} (h : x.isRight), x = inr (x.getRight h)
| inr _, _ => rfl
@[simp] theorem getRight_eq_iff (h : x.isRight) : x.getRight h = b ↔ x = inr b := by
cases x <;> simp at h ⊢
@[simp] theorem getLeft?_eq_some_iff : x.getLeft? = some a ↔ x = inl a := by
cases x <;> simp only [getLeft?, Option.some.injEq, inl.injEq]
@[simp] theorem getRight?_eq_some_iff : x.getRight? = some b ↔ x = inr b := by
cases x <;> simp only [getRight?, Option.some.injEq, inr.injEq]
@[simp] theorem bnot_isLeft (x : α ⊕ β) : !x.isLeft = x.isRight := by cases x <;> rfl
@[simp] theorem isLeft_eq_false {x : α ⊕ β} : x.isLeft = false ↔ x.isRight := by cases x <;> simp
theorem not_isLeft {x : α ⊕ β} : ¬x.isLeft ↔ x.isRight := by simp
@[simp] theorem bnot_isRight (x : α ⊕ β) : !x.isRight = x.isLeft := by cases x <;> rfl
@[simp] theorem isRight_eq_false {x : α ⊕ β} : x.isRight = false ↔ x.isLeft := by cases x <;> simp
theorem not_isRight {x : α ⊕ β} : ¬x.isRight ↔ x.isLeft := by simp
theorem isLeft_iff : x.isLeft ↔ ∃ y, x = Sum.inl y := by cases x <;> simp
theorem isRight_iff : x.isRight ↔ ∃ y, x = Sum.inr y := by cases x <;> simp
end get
theorem inl.inj_iff : (inl a : α ⊕ β) = inl b ↔ a = b := ⟨inl.inj, congrArg _⟩
theorem inr.inj_iff : (inr a : α ⊕ β) = inr b ↔ a = b := ⟨inr.inj, congrArg _⟩
theorem inl_ne_inr : inl a ≠ inr b := nofun
theorem inr_ne_inl : inr b ≠ inl a := nofun
/-! ### `Sum.elim` -/
@[simp] theorem elim_comp_inl (f : α → γ) (g : β → γ) : Sum.elim f g ∘ inl = f :=
rfl
@[simp] theorem elim_comp_inr (f : α → γ) (g : β → γ) : Sum.elim f g ∘ inr = g :=
rfl
@[simp] theorem elim_inl_inr : @Sum.elim α β _ inl inr = id :=
funext fun x => Sum.casesOn x (fun _ => rfl) fun _ => rfl
theorem comp_elim (f : γ → δ) (g : α → γ) (h : β → γ) :
f ∘ Sum.elim g h = Sum.elim (f ∘ g) (f ∘ h) :=
funext fun x => Sum.casesOn x (fun _ => rfl) fun _ => rfl
@[simp] theorem elim_comp_inl_inr (f : α ⊕ β → γ) :
Sum.elim (f ∘ inl) (f ∘ inr) = f :=
funext fun x => Sum.casesOn x (fun _ => rfl) fun _ => rfl
| .lake/packages/batteries/Batteries/Data/Sum/Lemmas.lean | 116 | 118 | theorem elim_eq_iff {u u' : α → γ} {v v' : β → γ} :
Sum.elim u v = Sum.elim u' v' ↔ u = u' ∧ v = v' := by |
simp [funext_iff]
|
/-
Copyright (c) 2019 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Mario Carneiro
-/
import Batteries.Data.List.Basic
namespace Batteries
/--
`AssocList α β` is "the same as" `List (α × β)`, but flattening the structure
leads to one fewer pointer indirection (in the current code generator).
It is mainly intended as a component of `HashMap`, but it can also be used as a plain
key-value map.
-/
inductive AssocList (α : Type u) (β : Type v) where
/-- An empty list -/
| nil
/-- Add a `key, value` pair to the list -/
| cons (key : α) (value : β) (tail : AssocList α β)
deriving Inhabited
namespace AssocList
/--
`O(n)`. Convert an `AssocList α β` into the equivalent `List (α × β)`.
This is used to give specifications for all the `AssocList` functions
in terms of corresponding list functions.
-/
@[simp] def toList : AssocList α β → List (α × β)
| nil => []
| cons a b es => (a, b) :: es.toList
instance : EmptyCollection (AssocList α β) := ⟨nil⟩
@[simp] theorem empty_eq : (∅ : AssocList α β) = nil := rfl
/-- `O(1)`. Is the list empty? -/
def isEmpty : AssocList α β → Bool
| nil => true
| _ => false
@[simp] theorem isEmpty_eq (l : AssocList α β) : isEmpty l = l.toList.isEmpty := by
cases l <;> simp [*, isEmpty, List.isEmpty]
/-- The number of entries in an `AssocList`. -/
def length (L : AssocList α β) : Nat :=
match L with
| .nil => 0
| .cons _ _ t => t.length + 1
@[simp] theorem length_nil : length (nil : AssocList α β) = 0 := rfl
@[simp] theorem length_cons : length (cons a b t) = length t + 1 := rfl
| .lake/packages/batteries/Batteries/Data/AssocList.lean | 55 | 56 | theorem length_toList (l : AssocList α β) : l.toList.length = l.length := by |
induction l <;> simp_all
|
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura
-/
import Mathlib.Data.Set.Basic
/-!
# Subsingleton
Defines the predicate `Subsingleton s : Prop`, saying that `s` has at most one element.
Also defines `Nontrivial s : Prop` : the predicate saying that `s` has at least two distinct
elements.
-/
open Function
universe u v
namespace Set
/-! ### Subsingleton -/
section Subsingleton
variable {α : Type u} {a : α} {s t : Set α}
/-- A set `s` is a `Subsingleton` if it has at most one element. -/
protected def Subsingleton (s : Set α) : Prop :=
∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s), x = y
#align set.subsingleton Set.Subsingleton
theorem Subsingleton.anti (ht : t.Subsingleton) (hst : s ⊆ t) : s.Subsingleton := fun _ hx _ hy =>
ht (hst hx) (hst hy)
#align set.subsingleton.anti Set.Subsingleton.anti
theorem Subsingleton.eq_singleton_of_mem (hs : s.Subsingleton) {x : α} (hx : x ∈ s) : s = {x} :=
ext fun _ => ⟨fun hy => hs hx hy ▸ mem_singleton _, fun hy => (eq_of_mem_singleton hy).symm ▸ hx⟩
#align set.subsingleton.eq_singleton_of_mem Set.Subsingleton.eq_singleton_of_mem
@[simp]
theorem subsingleton_empty : (∅ : Set α).Subsingleton := fun _ => False.elim
#align set.subsingleton_empty Set.subsingleton_empty
@[simp]
theorem subsingleton_singleton {a} : ({a} : Set α).Subsingleton := fun _ hx _ hy =>
(eq_of_mem_singleton hx).symm ▸ (eq_of_mem_singleton hy).symm ▸ rfl
#align set.subsingleton_singleton Set.subsingleton_singleton
theorem subsingleton_of_subset_singleton (h : s ⊆ {a}) : s.Subsingleton :=
subsingleton_singleton.anti h
#align set.subsingleton_of_subset_singleton Set.subsingleton_of_subset_singleton
theorem subsingleton_of_forall_eq (a : α) (h : ∀ b ∈ s, b = a) : s.Subsingleton := fun _ hb _ hc =>
(h _ hb).trans (h _ hc).symm
#align set.subsingleton_of_forall_eq Set.subsingleton_of_forall_eq
theorem subsingleton_iff_singleton {x} (hx : x ∈ s) : s.Subsingleton ↔ s = {x} :=
⟨fun h => h.eq_singleton_of_mem hx, fun h => h.symm ▸ subsingleton_singleton⟩
#align set.subsingleton_iff_singleton Set.subsingleton_iff_singleton
theorem Subsingleton.eq_empty_or_singleton (hs : s.Subsingleton) : s = ∅ ∨ ∃ x, s = {x} :=
s.eq_empty_or_nonempty.elim Or.inl fun ⟨x, hx⟩ => Or.inr ⟨x, hs.eq_singleton_of_mem hx⟩
#align set.subsingleton.eq_empty_or_singleton Set.Subsingleton.eq_empty_or_singleton
theorem Subsingleton.induction_on {p : Set α → Prop} (hs : s.Subsingleton) (he : p ∅)
(h₁ : ∀ x, p {x}) : p s := by
rcases hs.eq_empty_or_singleton with (rfl | ⟨x, rfl⟩)
exacts [he, h₁ _]
#align set.subsingleton.induction_on Set.Subsingleton.induction_on
theorem subsingleton_univ [Subsingleton α] : (univ : Set α).Subsingleton := fun x _ y _ =>
Subsingleton.elim x y
#align set.subsingleton_univ Set.subsingleton_univ
theorem subsingleton_of_univ_subsingleton (h : (univ : Set α).Subsingleton) : Subsingleton α :=
⟨fun a b => h (mem_univ a) (mem_univ b)⟩
#align set.subsingleton_of_univ_subsingleton Set.subsingleton_of_univ_subsingleton
@[simp]
theorem subsingleton_univ_iff : (univ : Set α).Subsingleton ↔ Subsingleton α :=
⟨subsingleton_of_univ_subsingleton, fun h => @subsingleton_univ _ h⟩
#align set.subsingleton_univ_iff Set.subsingleton_univ_iff
theorem subsingleton_of_subsingleton [Subsingleton α] {s : Set α} : Set.Subsingleton s :=
subsingleton_univ.anti (subset_univ s)
#align set.subsingleton_of_subsingleton Set.subsingleton_of_subsingleton
theorem subsingleton_isTop (α : Type*) [PartialOrder α] : Set.Subsingleton { x : α | IsTop x } :=
fun x hx _ hy => hx.isMax.eq_of_le (hy x)
#align set.subsingleton_is_top Set.subsingleton_isTop
theorem subsingleton_isBot (α : Type*) [PartialOrder α] : Set.Subsingleton { x : α | IsBot x } :=
fun x hx _ hy => hx.isMin.eq_of_ge (hy x)
#align set.subsingleton_is_bot Set.subsingleton_isBot
theorem exists_eq_singleton_iff_nonempty_subsingleton :
(∃ a : α, s = {a}) ↔ s.Nonempty ∧ s.Subsingleton := by
refine ⟨?_, fun h => ?_⟩
· rintro ⟨a, rfl⟩
exact ⟨singleton_nonempty a, subsingleton_singleton⟩
· exact h.2.eq_empty_or_singleton.resolve_left h.1.ne_empty
#align set.exists_eq_singleton_iff_nonempty_subsingleton Set.exists_eq_singleton_iff_nonempty_subsingleton
/-- `s`, coerced to a type, is a subsingleton type if and only if `s` is a subsingleton set. -/
@[simp, norm_cast]
| Mathlib/Data/Set/Subsingleton.lean | 109 | 113 | theorem subsingleton_coe (s : Set α) : Subsingleton s ↔ s.Subsingleton := by |
constructor
· refine fun h => fun a ha b hb => ?_
exact SetCoe.ext_iff.2 (@Subsingleton.elim s h ⟨a, ha⟩ ⟨b, hb⟩)
· exact fun h => Subsingleton.intro fun a b => SetCoe.ext (h a.property b.property)
|
/-
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.CategoryTheory.SingleObj
import Mathlib.CategoryTheory.Limits.Shapes.Products
import Mathlib.CategoryTheory.Pi.Basic
import Mathlib.CategoryTheory.Limits.IsLimit
#align_import category_theory.category.Groupoid from "leanprover-community/mathlib"@"c9c9fa15fec7ca18e9ec97306fb8764bfe988a7e"
/-!
# Category of groupoids
This file contains the definition of the category `Grpd` of all groupoids.
In this category objects are groupoids and morphisms are functors
between these groupoids.
We also provide two “forgetting” functors: `objects : Grpd ⥤ Type`
and `forgetToCat : Grpd ⥤ Cat`.
## Implementation notes
Though `Grpd` is not a concrete category, we use `Bundled` to define
its carrier type.
-/
universe v u
namespace CategoryTheory
-- intended to be used with explicit universe parameters
/-- Category of groupoids -/
@[nolint checkUnivs]
def Grpd :=
Bundled Groupoid.{v, u}
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid CategoryTheory.Grpd
namespace Grpd
instance : Inhabited Grpd :=
⟨Bundled.of (SingleObj PUnit)⟩
instance str' (C : Grpd.{v, u}) : Groupoid.{v, u} C.α :=
C.str
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid.str CategoryTheory.Grpd.str'
instance : CoeSort Grpd Type* :=
Bundled.coeSort
/-- Construct a bundled `Grpd` from the underlying type and the typeclass `Groupoid`. -/
def of (C : Type u) [Groupoid.{v} C] : Grpd.{v, u} :=
Bundled.of C
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid.of CategoryTheory.Grpd.of
@[simp]
theorem coe_of (C : Type u) [Groupoid C] : (of C : Type u) = C :=
rfl
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid.coe_of CategoryTheory.Grpd.coe_of
/-- Category structure on `Grpd` -/
instance category : LargeCategory.{max v u} Grpd.{v, u} where
Hom C D := C ⥤ D
id C := 𝟭 C
comp F G := F ⋙ G
id_comp _ := rfl
comp_id _ := rfl
assoc := by intros; rfl
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid.category CategoryTheory.Grpd.category
/-- Functor that gets the set of objects of a groupoid. It is not
called `forget`, because it is not a faithful functor. -/
def objects : Grpd.{v, u} ⥤ Type u where
obj := Bundled.α
map F := F.obj
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid.objects CategoryTheory.Grpd.objects
/-- Forgetting functor to `Cat` -/
def forgetToCat : Grpd.{v, u} ⥤ Cat.{v, u} where
obj C := Cat.of C
map := id
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid.forget_to_Cat CategoryTheory.Grpd.forgetToCat
instance forgetToCat_full : forgetToCat.Full where map_surjective f := ⟨f, rfl⟩
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid.forget_to_Cat_full CategoryTheory.Grpd.forgetToCat_full
instance forgetToCat_faithful : forgetToCat.Faithful where
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid.forget_to_Cat_faithful CategoryTheory.Grpd.forgetToCat_faithful
/-- Convert arrows in the category of groupoids to functors,
which sometimes helps in applying simp lemmas -/
theorem hom_to_functor {C D E : Grpd.{v, u}} (f : C ⟶ D) (g : D ⟶ E) : f ≫ g = f ⋙ g :=
rfl
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid.hom_to_functor CategoryTheory.Grpd.hom_to_functor
/-- Converts identity in the category of groupoids to the functor identity -/
theorem id_to_functor {C : Grpd.{v, u}} : 𝟭 C = 𝟙 C :=
rfl
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid.id_to_functor CategoryTheory.Grpd.id_to_functor
section Products
/-- Construct the product over an indexed family of groupoids, as a fan. -/
def piLimitFan ⦃J : Type u⦄ (F : J → Grpd.{u, u}) : Limits.Fan F :=
Limits.Fan.mk (@of (∀ j : J, F j) _) fun j => CategoryTheory.Pi.eval _ j
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid.pi_limit_fan CategoryTheory.Grpd.piLimitFan
/-- The product fan over an indexed family of groupoids, is a limit cone. -/
def piLimitFanIsLimit ⦃J : Type u⦄ (F : J → Grpd.{u, u}) : Limits.IsLimit (piLimitFan F) :=
Limits.mkFanLimit (piLimitFan F) (fun s => Functor.pi' fun j => s.proj j)
(by
intros
dsimp only [piLimitFan]
simp [hom_to_functor])
(by
intro s m w
apply Functor.pi_ext
intro j; specialize w j
simpa)
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid.pi_limit_fan_is_limit CategoryTheory.Grpd.piLimitFanIsLimit
instance has_pi : Limits.HasProducts Grpd.{u, u} :=
Limits.hasProducts_of_limit_fans (by apply piLimitFan) (by apply piLimitFanIsLimit)
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid.has_pi CategoryTheory.Grpd.has_pi
/-- The product of a family of groupoids is isomorphic
to the product object in the category of Groupoids -/
noncomputable def piIsoPi (J : Type u) (f : J → Grpd.{u, u}) : @of (∀ j, f j) _ ≅ ∏ᶜ f :=
Limits.IsLimit.conePointUniqueUpToIso (piLimitFanIsLimit f)
(Limits.limit.isLimit (Discrete.functor f))
set_option linter.uppercaseLean3 false in
#align category_theory.Groupoid.pi_iso_pi CategoryTheory.Grpd.piIsoPi
@[simp]
| Mathlib/CategoryTheory/Category/Grpd.lean | 152 | 155 | theorem piIsoPi_hom_π (J : Type u) (f : J → Grpd.{u, u}) (j : J) :
(piIsoPi J f).hom ≫ Limits.Pi.π f j = CategoryTheory.Pi.eval _ j := by |
simp [piIsoPi]
rfl
|
/-
Copyright (c) 2017 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot, Scott Morrison, Mario Carneiro, Andrew Yang
-/
import Mathlib.Topology.Category.TopCat.Limits.Products
#align_import topology.category.Top.limits.pullbacks from "leanprover-community/mathlib"@"178a32653e369dce2da68dc6b2694e385d484ef1"
/-!
# Pullbacks and pushouts in the category of topological spaces
-/
-- Porting note: every ML3 decl has an uppercase letter
set_option linter.uppercaseLean3 false
open TopologicalSpace
open CategoryTheory
open CategoryTheory.Limits
universe v u w
noncomputable section
namespace TopCat
variable {J : Type v} [SmallCategory J]
section Pullback
variable {X Y Z : TopCat.{u}}
/-- The first projection from the pullback. -/
abbrev pullbackFst (f : X ⟶ Z) (g : Y ⟶ Z) : TopCat.of { p : X × Y // f p.1 = g p.2 } ⟶ X :=
⟨Prod.fst ∘ Subtype.val, by
apply Continuous.comp <;> set_option tactic.skipAssignedInstances false in continuity⟩
#align Top.pullback_fst TopCat.pullbackFst
lemma pullbackFst_apply (f : X ⟶ Z) (g : Y ⟶ Z) (x) : pullbackFst f g x = x.1.1 := rfl
/-- The second projection from the pullback. -/
abbrev pullbackSnd (f : X ⟶ Z) (g : Y ⟶ Z) : TopCat.of { p : X × Y // f p.1 = g p.2 } ⟶ Y :=
⟨Prod.snd ∘ Subtype.val, by
apply Continuous.comp <;> set_option tactic.skipAssignedInstances false in continuity⟩
#align Top.pullback_snd TopCat.pullbackSnd
lemma pullbackSnd_apply (f : X ⟶ Z) (g : Y ⟶ Z) (x) : pullbackSnd f g x = x.1.2 := rfl
/-- The explicit pullback cone of `X, Y` given by `{ p : X × Y // f p.1 = g p.2 }`. -/
def pullbackCone (f : X ⟶ Z) (g : Y ⟶ Z) : PullbackCone f g :=
PullbackCone.mk (pullbackFst f g) (pullbackSnd f g)
(by
dsimp [pullbackFst, pullbackSnd, Function.comp_def]
ext ⟨x, h⟩
-- Next 2 lines were
-- `rw [comp_apply, ContinuousMap.coe_mk, comp_apply, ContinuousMap.coe_mk]`
-- `exact h` before leanprover/lean4#2644
rw [comp_apply, comp_apply]
congr!)
#align Top.pullback_cone TopCat.pullbackCone
/-- The constructed cone is a limit. -/
def pullbackConeIsLimit (f : X ⟶ Z) (g : Y ⟶ Z) : IsLimit (pullbackCone f g) :=
PullbackCone.isLimitAux' _
(by
intro S
constructor; swap
· exact
{ toFun := fun x =>
⟨⟨S.fst x, S.snd x⟩, by simpa using ConcreteCategory.congr_hom S.condition x⟩
continuous_toFun := by
apply Continuous.subtype_mk <| Continuous.prod_mk ?_ ?_
· exact (PullbackCone.fst S)|>.continuous_toFun
· exact (PullbackCone.snd S)|>.continuous_toFun
}
refine ⟨?_, ?_, ?_⟩
· delta pullbackCone
ext a
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [comp_apply, ContinuousMap.coe_mk]
· delta pullbackCone
ext a
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [comp_apply, ContinuousMap.coe_mk]
· intro m h₁ h₂
-- Porting note: used to be ext x
apply ContinuousMap.ext; intro x
apply Subtype.ext
apply Prod.ext
· simpa using ConcreteCategory.congr_hom h₁ x
· simpa using ConcreteCategory.congr_hom h₂ x)
#align Top.pullback_cone_is_limit TopCat.pullbackConeIsLimit
/-- The pullback of two maps can be identified as a subspace of `X × Y`. -/
def pullbackIsoProdSubtype (f : X ⟶ Z) (g : Y ⟶ Z) :
pullback f g ≅ TopCat.of { p : X × Y // f p.1 = g p.2 } :=
(limit.isLimit _).conePointUniqueUpToIso (pullbackConeIsLimit f g)
#align Top.pullback_iso_prod_subtype TopCat.pullbackIsoProdSubtype
@[reassoc (attr := simp)]
theorem pullbackIsoProdSubtype_inv_fst (f : X ⟶ Z) (g : Y ⟶ Z) :
(pullbackIsoProdSubtype f g).inv ≫ pullback.fst = pullbackFst f g := by
simp [pullbackCone, pullbackIsoProdSubtype]
#align Top.pullback_iso_prod_subtype_inv_fst TopCat.pullbackIsoProdSubtype_inv_fst
theorem pullbackIsoProdSubtype_inv_fst_apply (f : X ⟶ Z) (g : Y ⟶ Z)
(x : { p : X × Y // f p.1 = g p.2 }) :
(pullback.fst : pullback f g ⟶ _) ((pullbackIsoProdSubtype f g).inv x) = (x : X × Y).fst :=
ConcreteCategory.congr_hom (pullbackIsoProdSubtype_inv_fst f g) x
#align Top.pullback_iso_prod_subtype_inv_fst_apply TopCat.pullbackIsoProdSubtype_inv_fst_apply
@[reassoc (attr := simp)]
theorem pullbackIsoProdSubtype_inv_snd (f : X ⟶ Z) (g : Y ⟶ Z) :
(pullbackIsoProdSubtype f g).inv ≫ pullback.snd = pullbackSnd f g := by
simp [pullbackCone, pullbackIsoProdSubtype]
#align Top.pullback_iso_prod_subtype_inv_snd TopCat.pullbackIsoProdSubtype_inv_snd
theorem pullbackIsoProdSubtype_inv_snd_apply (f : X ⟶ Z) (g : Y ⟶ Z)
(x : { p : X × Y // f p.1 = g p.2 }) :
(pullback.snd : pullback f g ⟶ _) ((pullbackIsoProdSubtype f g).inv x) = (x : X × Y).snd :=
ConcreteCategory.congr_hom (pullbackIsoProdSubtype_inv_snd f g) x
#align Top.pullback_iso_prod_subtype_inv_snd_apply TopCat.pullbackIsoProdSubtype_inv_snd_apply
| Mathlib/Topology/Category/TopCat/Limits/Pullbacks.lean | 126 | 128 | theorem pullbackIsoProdSubtype_hom_fst (f : X ⟶ Z) (g : Y ⟶ Z) :
(pullbackIsoProdSubtype f g).hom ≫ pullbackFst f g = pullback.fst := by |
rw [← Iso.eq_inv_comp, pullbackIsoProdSubtype_inv_fst]
|
/-
Copyright (c) 2018 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Johannes Hölzl, Rémy Degenne
-/
import Mathlib.Order.Filter.Cofinite
import Mathlib.Order.Hom.CompleteLattice
#align_import order.liminf_limsup from "leanprover-community/mathlib"@"ffde2d8a6e689149e44fd95fa862c23a57f8c780"
/-!
# liminfs and limsups of functions and filters
Defines the liminf/limsup of a function taking values in a conditionally complete lattice, with
respect to an arbitrary filter.
We define `limsSup f` (`limsInf f`) where `f` is a filter taking values in a conditionally complete
lattice. `limsSup f` is the smallest element `a` such that, eventually, `u ≤ a` (and vice versa for
`limsInf f`). To work with the Limsup along a function `u` use `limsSup (map u f)`.
Usually, one defines the Limsup as `inf (sup s)` where the Inf is taken over all sets in the filter.
For instance, in ℕ along a function `u`, this is `inf_n (sup_{k ≥ n} u k)` (and the latter quantity
decreases with `n`, so this is in fact a limit.). There is however a difficulty: it is well possible
that `u` is not bounded on the whole space, only eventually (think of `limsup (fun x ↦ 1/x)` on ℝ.
Then there is no guarantee that the quantity above really decreases (the value of the `sup`
beforehand is not really well defined, as one can not use ∞), so that the Inf could be anything.
So one can not use this `inf sup ...` definition in conditionally complete lattices, and one has
to use a less tractable definition.
In conditionally complete lattices, the definition is only useful for filters which are eventually
bounded above (otherwise, the Limsup would morally be +∞, which does not belong to the space) and
which are frequently bounded below (otherwise, the Limsup would morally be -∞, which is not in the
space either). We start with definitions of these concepts for arbitrary filters, before turning to
the definitions of Limsup and Liminf.
In complete lattices, however, it coincides with the `Inf Sup` definition.
-/
set_option autoImplicit true
open Filter Set Function
variable {α β γ ι ι' : Type*}
namespace Filter
section Relation
/-- `f.IsBounded (≺)`: the filter `f` is eventually bounded w.r.t. the relation `≺`, i.e.
eventually, it is bounded by some uniform bound.
`r` will be usually instantiated with `≤` or `≥`. -/
def IsBounded (r : α → α → Prop) (f : Filter α) :=
∃ b, ∀ᶠ x in f, r x b
#align filter.is_bounded Filter.IsBounded
/-- `f.IsBoundedUnder (≺) u`: the image of the filter `f` under `u` is eventually bounded w.r.t.
the relation `≺`, i.e. eventually, it is bounded by some uniform bound. -/
def IsBoundedUnder (r : α → α → Prop) (f : Filter β) (u : β → α) :=
(map u f).IsBounded r
#align filter.is_bounded_under Filter.IsBoundedUnder
variable {r : α → α → Prop} {f g : Filter α}
/-- `f` is eventually bounded if and only if, there exists an admissible set on which it is
bounded. -/
theorem isBounded_iff : f.IsBounded r ↔ ∃ s ∈ f.sets, ∃ b, s ⊆ { x | r x b } :=
Iff.intro (fun ⟨b, hb⟩ => ⟨{ a | r a b }, hb, b, Subset.refl _⟩) fun ⟨_, hs, b, hb⟩ =>
⟨b, mem_of_superset hs hb⟩
#align filter.is_bounded_iff Filter.isBounded_iff
/-- A bounded function `u` is in particular eventually bounded. -/
theorem isBoundedUnder_of {f : Filter β} {u : β → α} : (∃ b, ∀ x, r (u x) b) → f.IsBoundedUnder r u
| ⟨b, hb⟩ => ⟨b, show ∀ᶠ x in f, r (u x) b from eventually_of_forall hb⟩
#align filter.is_bounded_under_of Filter.isBoundedUnder_of
theorem isBounded_bot : IsBounded r ⊥ ↔ Nonempty α := by simp [IsBounded, exists_true_iff_nonempty]
#align filter.is_bounded_bot Filter.isBounded_bot
theorem isBounded_top : IsBounded r ⊤ ↔ ∃ t, ∀ x, r x t := by simp [IsBounded, eq_univ_iff_forall]
#align filter.is_bounded_top Filter.isBounded_top
theorem isBounded_principal (s : Set α) : IsBounded r (𝓟 s) ↔ ∃ t, ∀ x ∈ s, r x t := by
simp [IsBounded, subset_def]
#align filter.is_bounded_principal Filter.isBounded_principal
theorem isBounded_sup [IsTrans α r] [IsDirected α r] :
IsBounded r f → IsBounded r g → IsBounded r (f ⊔ g)
| ⟨b₁, h₁⟩, ⟨b₂, h₂⟩ =>
let ⟨b, rb₁b, rb₂b⟩ := directed_of r b₁ b₂
⟨b, eventually_sup.mpr
⟨h₁.mono fun _ h => _root_.trans h rb₁b, h₂.mono fun _ h => _root_.trans h rb₂b⟩⟩
#align filter.is_bounded_sup Filter.isBounded_sup
theorem IsBounded.mono (h : f ≤ g) : IsBounded r g → IsBounded r f
| ⟨b, hb⟩ => ⟨b, h hb⟩
#align filter.is_bounded.mono Filter.IsBounded.mono
theorem IsBoundedUnder.mono {f g : Filter β} {u : β → α} (h : f ≤ g) :
g.IsBoundedUnder r u → f.IsBoundedUnder r u := fun hg => IsBounded.mono (map_mono h) hg
#align filter.is_bounded_under.mono Filter.IsBoundedUnder.mono
| Mathlib/Order/LiminfLimsup.lean | 103 | 106 | theorem IsBoundedUnder.mono_le [Preorder β] {l : Filter α} {u v : α → β}
(hu : IsBoundedUnder (· ≤ ·) l u) (hv : v ≤ᶠ[l] u) : IsBoundedUnder (· ≤ ·) l v := by |
apply hu.imp
exact fun b hb => (eventually_map.1 hb).mp <| hv.mono fun x => le_trans
|
/-
Copyright (c) 2022 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-/
import Mathlib.Order.ConditionallyCompleteLattice.Basic
import Mathlib.Order.LatticeIntervals
import Mathlib.Order.Interval.Set.OrdConnected
#align_import order.complete_lattice_intervals from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432"
/-! # Subtypes of conditionally complete linear orders
In this file we give conditions on a subset of a conditionally complete linear order, to ensure that
the subtype is itself conditionally complete.
We check that an `OrdConnected` set satisfies these conditions.
## TODO
Add appropriate instances for all `Set.Ixx`. This requires a refactor that will allow different
default values for `sSup` and `sInf`.
-/
open scoped Classical
open Set
variable {ι : Sort*} {α : Type*} (s : Set α)
section SupSet
variable [Preorder α] [SupSet α]
/-- `SupSet` structure on a nonempty subset `s` of a preorder with `SupSet`. This definition is
non-canonical (it uses `default s`); it should be used only as here, as an auxiliary instance in the
construction of the `ConditionallyCompleteLinearOrder` structure. -/
noncomputable def subsetSupSet [Inhabited s] : SupSet s where
sSup t :=
if ht : t.Nonempty ∧ BddAbove t ∧ sSup ((↑) '' t : Set α) ∈ s
then ⟨sSup ((↑) '' t : Set α), ht.2.2⟩
else default
#align subset_has_Sup subsetSupSet
attribute [local instance] subsetSupSet
@[simp]
theorem subset_sSup_def [Inhabited s] :
@sSup s _ = fun t =>
if ht : t.Nonempty ∧ BddAbove t ∧ sSup ((↑) '' t : Set α) ∈ s
then ⟨sSup ((↑) '' t : Set α), ht.2.2⟩
else default :=
rfl
#align subset_Sup_def subset_sSup_def
theorem subset_sSup_of_within [Inhabited s] {t : Set s}
(h' : t.Nonempty) (h'' : BddAbove t) (h : sSup ((↑) '' t : Set α) ∈ s) :
sSup ((↑) '' t : Set α) = (@sSup s _ t : α) := by simp [dif_pos, h, h', h'']
#align subset_Sup_of_within subset_sSup_of_within
theorem subset_sSup_emptyset [Inhabited s] :
sSup (∅ : Set s) = default := by
simp [sSup]
theorem subset_sSup_of_not_bddAbove [Inhabited s] {t : Set s} (ht : ¬BddAbove t) :
sSup t = default := by
simp [sSup, ht]
end SupSet
section InfSet
variable [Preorder α] [InfSet α]
/-- `InfSet` structure on a nonempty subset `s` of a preorder with `InfSet`. This definition is
non-canonical (it uses `default s`); it should be used only as here, as an auxiliary instance in the
construction of the `ConditionallyCompleteLinearOrder` structure. -/
noncomputable def subsetInfSet [Inhabited s] : InfSet s where
sInf t :=
if ht : t.Nonempty ∧ BddBelow t ∧ sInf ((↑) '' t : Set α) ∈ s
then ⟨sInf ((↑) '' t : Set α), ht.2.2⟩
else default
#align subset_has_Inf subsetInfSet
attribute [local instance] subsetInfSet
@[simp]
theorem subset_sInf_def [Inhabited s] :
@sInf s _ = fun t =>
if ht : t.Nonempty ∧ BddBelow t ∧ sInf ((↑) '' t : Set α) ∈ s
then ⟨sInf ((↑) '' t : Set α), ht.2.2⟩ else
default :=
rfl
#align subset_Inf_def subset_sInf_def
theorem subset_sInf_of_within [Inhabited s] {t : Set s}
(h' : t.Nonempty) (h'' : BddBelow t) (h : sInf ((↑) '' t : Set α) ∈ s) :
sInf ((↑) '' t : Set α) = (@sInf s _ t : α) := by simp [dif_pos, h, h', h'']
#align subset_Inf_of_within subset_sInf_of_within
| Mathlib/Order/CompleteLatticeIntervals.lean | 102 | 104 | theorem subset_sInf_emptyset [Inhabited s] :
sInf (∅ : Set s) = default := by |
simp [sInf]
|
/-
Copyright (c) 2024 Jz Pan. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jz Pan
-/
import Mathlib.LinearAlgebra.TensorProduct.Basic
import Mathlib.RingTheory.Finiteness
/-!
# Some finiteness results of tensor product
This file contains some finiteness results of tensor product.
- `TensorProduct.exists_multiset`, `TensorProduct.exists_finsupp_left`,
`TensorProduct.exists_finsupp_right`, `TensorProduct.exists_finset`:
any element of `M ⊗[R] N` can be written as a finite sum of pure tensors.
See also `TensorProduct.span_tmul_eq_top`.
- `TensorProduct.exists_finite_submodule_left_of_finite`,
`TensorProduct.exists_finite_submodule_right_of_finite`,
`TensorProduct.exists_finite_submodule_of_finite`:
any finite subset of `M ⊗[R] N` is contained in `M' ⊗[R] N`,
resp. `M ⊗[R] N'`, resp. `M' ⊗[R] N'`,
for some finitely generated submodules `M'` and `N'` of `M` and `N`, respectively.
- `TensorProduct.exists_finite_submodule_left_of_finite'`,
`TensorProduct.exists_finite_submodule_right_of_finite'`,
`TensorProduct.exists_finite_submodule_of_finite'`:
variation of the above results where `M` and `N` are already submodules.
## Tags
tensor product, finitely generated
-/
open scoped TensorProduct
open Submodule
variable {R M N : Type*}
variable [CommSemiring R] [AddCommMonoid M] [AddCommMonoid N] [Module R M] [Module R N]
variable {M₁ M₂ : Submodule R M} {N₁ N₂ : Submodule R N}
namespace TensorProduct
/-- For any element `x` of `M ⊗[R] N`, there exists a (finite) multiset `{ (m_i, n_i) }`
of `M × N`, such that `x` is equal to the sum of `m_i ⊗ₜ[R] n_i`. -/
theorem exists_multiset (x : M ⊗[R] N) :
∃ S : Multiset (M × N), x = (S.map fun i ↦ i.1 ⊗ₜ[R] i.2).sum := by
induction x using TensorProduct.induction_on with
| zero => exact ⟨0, by simp⟩
| tmul x y => exact ⟨{(x, y)}, by simp⟩
| add x y hx hy =>
obtain ⟨Sx, hx⟩ := hx
obtain ⟨Sy, hy⟩ := hy
exact ⟨Sx + Sy, by rw [Multiset.map_add, Multiset.sum_add, hx, hy]⟩
/-- For any element `x` of `M ⊗[R] N`, there exists a finite subset `{ (m_i, n_i) }`
of `M × N` such that each `m_i` is distinct (we represent it as an element of `M →₀ N`),
such that `x` is equal to the sum of `m_i ⊗ₜ[R] n_i`. -/
theorem exists_finsupp_left (x : M ⊗[R] N) :
∃ S : M →₀ N, x = S.sum fun m n ↦ m ⊗ₜ[R] n := by
induction x using TensorProduct.induction_on with
| zero => exact ⟨0, by simp⟩
| tmul x y => exact ⟨Finsupp.single x y, by simp⟩
| add x y hx hy =>
obtain ⟨Sx, hx⟩ := hx
obtain ⟨Sy, hy⟩ := hy
use Sx + Sy
rw [hx, hy]
exact (Finsupp.sum_add_index' (by simp) TensorProduct.tmul_add).symm
/-- For any element `x` of `M ⊗[R] N`, there exists a finite subset `{ (m_i, n_i) }`
of `M × N` such that each `n_i` is distinct (we represent it as an element of `N →₀ M`),
such that `x` is equal to the sum of `m_i ⊗ₜ[R] n_i`. -/
| Mathlib/LinearAlgebra/TensorProduct/Finiteness.lean | 80 | 84 | theorem exists_finsupp_right (x : M ⊗[R] N) :
∃ S : N →₀ M, x = S.sum fun n m ↦ m ⊗ₜ[R] n := by |
obtain ⟨S, h⟩ := exists_finsupp_left (TensorProduct.comm R M N x)
refine ⟨S, (TensorProduct.comm R M N).injective ?_⟩
simp_rw [h, Finsupp.sum, map_sum, comm_tmul]
|
/-
Copyright (c) 2021 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import Mathlib.Algebra.FreeNonUnitalNonAssocAlgebra
import Mathlib.Algebra.Lie.NonUnitalNonAssocAlgebra
import Mathlib.Algebra.Lie.UniversalEnveloping
import Mathlib.GroupTheory.GroupAction.Ring
#align_import algebra.lie.free from "leanprover-community/mathlib"@"841ac1a3d9162bf51c6327812ecb6e5e71883ac4"
/-!
# Free Lie algebras
Given a commutative ring `R` and a type `X` we construct the free Lie algebra on `X` with
coefficients in `R` together with its universal property.
## Main definitions
* `FreeLieAlgebra`
* `FreeLieAlgebra.lift`
* `FreeLieAlgebra.of`
* `FreeLieAlgebra.universalEnvelopingEquivFreeAlgebra`
## Implementation details
### Quotient of free non-unital, non-associative algebra
We follow [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 1--3*](bourbaki1975) and construct
the free Lie algebra as a quotient of the free non-unital, non-associative algebra. Since we do not
currently have definitions of ideals, lattices of ideals, and quotients for
`NonUnitalNonAssocSemiring`, we construct our quotient using the low-level `Quot` function on
an inductively-defined relation.
### Alternative construction (needs PBW)
An alternative construction of the free Lie algebra on `X` is to start with the free unital
associative algebra on `X`, regard it as a Lie algebra via the ring commutator, and take its
smallest Lie subalgebra containing `X`. I.e.:
`LieSubalgebra.lieSpan R (FreeAlgebra R X) (Set.range (FreeAlgebra.ι R))`.
However with this definition there does not seem to be an easy proof that the required universal
property holds, and I don't know of a proof that avoids invoking the Poincaré–Birkhoff–Witt theorem.
A related MathOverflow question is [this one](https://mathoverflow.net/questions/396680/).
## Tags
lie algebra, free algebra, non-unital, non-associative, universal property, forgetful functor,
adjoint functor
-/
universe u v w
noncomputable section
variable (R : Type u) (X : Type v) [CommRing R]
/- We save characters by using Bourbaki's name `lib` (as in «libre») for
`FreeNonUnitalNonAssocAlgebra` in this file. -/
local notation "lib" => FreeNonUnitalNonAssocAlgebra
local notation "lib.lift" => FreeNonUnitalNonAssocAlgebra.lift
local notation "lib.of" => FreeNonUnitalNonAssocAlgebra.of
local notation "lib.lift_of_apply" => FreeNonUnitalNonAssocAlgebra.lift_of_apply
local notation "lib.lift_comp_of" => FreeNonUnitalNonAssocAlgebra.lift_comp_of
namespace FreeLieAlgebra
/-- The quotient of `lib R X` by the equivalence relation generated by this relation will give us
the free Lie algebra. -/
inductive Rel : lib R X → lib R X → Prop
| lie_self (a : lib R X) : Rel (a * a) 0
| leibniz_lie (a b c : lib R X) : Rel (a * (b * c)) (a * b * c + b * (a * c))
| smul (t : R) {a b : lib R X} : Rel a b → Rel (t • a) (t • b)
| add_right {a b : lib R X} (c : lib R X) : Rel a b → Rel (a + c) (b + c)
| mul_left (a : lib R X) {b c : lib R X} : Rel b c → Rel (a * b) (a * c)
| mul_right {a b : lib R X} (c : lib R X) : Rel a b → Rel (a * c) (b * c)
#align free_lie_algebra.rel FreeLieAlgebra.Rel
variable {R X}
| Mathlib/Algebra/Lie/Free.lean | 87 | 88 | theorem Rel.addLeft (a : lib R X) {b c : lib R X} (h : Rel R X b c) : Rel R X (a + b) (a + c) := by |
rw [add_comm _ b, add_comm _ c]; exact h.add_right _
|
/-
Copyright (c) 2022 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Batteries.Tactic.SeqFocus
/-! ## Ordering -/
namespace Ordering
@[simp] theorem swap_swap {o : Ordering} : o.swap.swap = o := by cases o <;> rfl
@[simp] theorem swap_inj {o₁ o₂ : Ordering} : o₁.swap = o₂.swap ↔ o₁ = o₂ :=
⟨fun h => by simpa using congrArg swap h, congrArg _⟩
theorem swap_then (o₁ o₂ : Ordering) : (o₁.then o₂).swap = o₁.swap.then o₂.swap := by
cases o₁ <;> rfl
theorem then_eq_lt {o₁ o₂ : Ordering} : o₁.then o₂ = lt ↔ o₁ = lt ∨ o₁ = eq ∧ o₂ = lt := by
cases o₁ <;> cases o₂ <;> decide
theorem then_eq_eq {o₁ o₂ : Ordering} : o₁.then o₂ = eq ↔ o₁ = eq ∧ o₂ = eq := by
cases o₁ <;> simp [«then»]
theorem then_eq_gt {o₁ o₂ : Ordering} : o₁.then o₂ = gt ↔ o₁ = gt ∨ o₁ = eq ∧ o₂ = gt := by
cases o₁ <;> cases o₂ <;> decide
end Ordering
namespace Batteries
/-- `TotalBLE le` asserts that `le` has a total order, that is, `le a b ∨ le b a`. -/
class TotalBLE (le : α → α → Bool) : Prop where
/-- `le` is total: either `le a b` or `le b a`. -/
total : le a b ∨ le b a
/-- `OrientedCmp cmp` asserts that `cmp` is determined by the relation `cmp x y = .lt`. -/
class OrientedCmp (cmp : α → α → Ordering) : Prop where
/-- The comparator operation is symmetric, in the sense that if `cmp x y` equals `.lt` then
`cmp y x = .gt` and vice versa. -/
symm (x y) : (cmp x y).swap = cmp y x
namespace OrientedCmp
theorem cmp_eq_gt [OrientedCmp cmp] : cmp x y = .gt ↔ cmp y x = .lt := by
rw [← Ordering.swap_inj, symm]; exact .rfl
theorem cmp_ne_gt [OrientedCmp cmp] : cmp x y ≠ .gt ↔ cmp y x ≠ .lt := not_congr cmp_eq_gt
theorem cmp_eq_eq_symm [OrientedCmp cmp] : cmp x y = .eq ↔ cmp y x = .eq := by
rw [← Ordering.swap_inj, symm]; exact .rfl
theorem cmp_refl [OrientedCmp cmp] : cmp x x = .eq :=
match e : cmp x x with
| .lt => nomatch e.symm.trans (cmp_eq_gt.2 e)
| .eq => rfl
| .gt => nomatch (cmp_eq_gt.1 e).symm.trans e
end OrientedCmp
/-- `TransCmp cmp` asserts that `cmp` induces a transitive relation. -/
class TransCmp (cmp : α → α → Ordering) extends OrientedCmp cmp : Prop where
/-- The comparator operation is transitive. -/
le_trans : cmp x y ≠ .gt → cmp y z ≠ .gt → cmp x z ≠ .gt
namespace TransCmp
variable [TransCmp cmp]
open OrientedCmp Decidable
theorem ge_trans (h₁ : cmp x y ≠ .lt) (h₂ : cmp y z ≠ .lt) : cmp x z ≠ .lt := by
have := @TransCmp.le_trans _ cmp _ z y x
simp [cmp_eq_gt] at *; exact this h₂ h₁
theorem lt_asymm (h : cmp x y = .lt) : cmp y x ≠ .lt :=
fun h' => nomatch h.symm.trans (cmp_eq_gt.2 h')
theorem gt_asymm (h : cmp x y = .gt) : cmp y x ≠ .gt :=
mt cmp_eq_gt.1 <| lt_asymm <| cmp_eq_gt.1 h
theorem le_lt_trans (h₁ : cmp x y ≠ .gt) (h₂ : cmp y z = .lt) : cmp x z = .lt :=
byContradiction fun h₃ => ge_trans (mt cmp_eq_gt.2 h₁) h₃ h₂
theorem lt_le_trans (h₁ : cmp x y = .lt) (h₂ : cmp y z ≠ .gt) : cmp x z = .lt :=
byContradiction fun h₃ => ge_trans h₃ (mt cmp_eq_gt.2 h₂) h₁
theorem lt_trans (h₁ : cmp x y = .lt) (h₂ : cmp y z = .lt) : cmp x z = .lt :=
le_lt_trans (gt_asymm <| cmp_eq_gt.2 h₁) h₂
theorem gt_trans (h₁ : cmp x y = .gt) (h₂ : cmp y z = .gt) : cmp x z = .gt := by
rw [cmp_eq_gt] at h₁ h₂ ⊢; exact lt_trans h₂ h₁
theorem cmp_congr_left (xy : cmp x y = .eq) : cmp x z = cmp y z :=
match yz : cmp y z with
| .lt => byContradiction (ge_trans (nomatch ·.symm.trans (cmp_eq_eq_symm.1 xy)) · yz)
| .gt => byContradiction (le_trans (nomatch ·.symm.trans (cmp_eq_eq_symm.1 xy)) · yz)
| .eq => match xz : cmp x z with
| .lt => nomatch ge_trans (nomatch ·.symm.trans xy) (nomatch ·.symm.trans yz) xz
| .gt => nomatch le_trans (nomatch ·.symm.trans xy) (nomatch ·.symm.trans yz) xz
| .eq => rfl
theorem cmp_congr_left' (xy : cmp x y = .eq) : cmp x = cmp y :=
funext fun _ => cmp_congr_left xy
| .lake/packages/batteries/Batteries/Classes/Order.lean | 105 | 106 | theorem cmp_congr_right [TransCmp cmp] (yz : cmp y z = .eq) : cmp x y = cmp x z := by |
rw [← Ordering.swap_inj, symm, symm, cmp_congr_left yz]
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import Mathlib.FieldTheory.SplittingField.IsSplittingField
import Mathlib.Algebra.CharP.Algebra
#align_import field_theory.splitting_field.construction from "leanprover-community/mathlib"@"e3f4be1fcb5376c4948d7f095bec45350bfb9d1a"
/-!
# Splitting fields
In this file we prove the existence and uniqueness of splitting fields.
## Main definitions
* `Polynomial.SplittingField f`: A fixed splitting field of the polynomial `f`.
## Main statements
* `Polynomial.IsSplittingField.algEquiv`: Every splitting field of a polynomial `f` is isomorphic
to `SplittingField f` and thus, being a splitting field is unique up to isomorphism.
## Implementation details
We construct a `SplittingFieldAux` without worrying about whether the instances satisfy nice
definitional equalities. Then the actual `SplittingField` is defined to be a quotient of a
`MvPolynomial` ring by the kernel of the obvious map into `SplittingFieldAux`. Because the
actual `SplittingField` will be a quotient of a `MvPolynomial`, it has nice instances on it.
-/
noncomputable section
open scoped Classical Polynomial
universe u v w
variable {F : Type u} {K : Type v} {L : Type w}
namespace Polynomial
variable [Field K] [Field L] [Field F]
open Polynomial
section SplittingField
/-- Non-computably choose an irreducible factor from a polynomial. -/
def factor (f : K[X]) : K[X] :=
if H : ∃ g, Irreducible g ∧ g ∣ f then Classical.choose H else X
#align polynomial.factor Polynomial.factor
theorem irreducible_factor (f : K[X]) : Irreducible (factor f) := by
rw [factor]
split_ifs with H
· exact (Classical.choose_spec H).1
· exact irreducible_X
#align polynomial.irreducible_factor Polynomial.irreducible_factor
/-- See note [fact non-instances]. -/
theorem fact_irreducible_factor (f : K[X]) : Fact (Irreducible (factor f)) :=
⟨irreducible_factor f⟩
#align polynomial.fact_irreducible_factor Polynomial.fact_irreducible_factor
attribute [local instance] fact_irreducible_factor
theorem factor_dvd_of_not_isUnit {f : K[X]} (hf1 : ¬IsUnit f) : factor f ∣ f := by
by_cases hf2 : f = 0; · rw [hf2]; exact dvd_zero _
rw [factor, dif_pos (WfDvdMonoid.exists_irreducible_factor hf1 hf2)]
exact (Classical.choose_spec <| WfDvdMonoid.exists_irreducible_factor hf1 hf2).2
#align polynomial.factor_dvd_of_not_is_unit Polynomial.factor_dvd_of_not_isUnit
theorem factor_dvd_of_degree_ne_zero {f : K[X]} (hf : f.degree ≠ 0) : factor f ∣ f :=
factor_dvd_of_not_isUnit (mt degree_eq_zero_of_isUnit hf)
#align polynomial.factor_dvd_of_degree_ne_zero Polynomial.factor_dvd_of_degree_ne_zero
theorem factor_dvd_of_natDegree_ne_zero {f : K[X]} (hf : f.natDegree ≠ 0) : factor f ∣ f :=
factor_dvd_of_degree_ne_zero (mt natDegree_eq_of_degree_eq_some hf)
#align polynomial.factor_dvd_of_nat_degree_ne_zero Polynomial.factor_dvd_of_natDegree_ne_zero
/-- Divide a polynomial f by `X - C r` where `r` is a root of `f` in a bigger field extension. -/
def removeFactor (f : K[X]) : Polynomial (AdjoinRoot <| factor f) :=
map (AdjoinRoot.of f.factor) f /ₘ (X - C (AdjoinRoot.root f.factor))
#align polynomial.remove_factor Polynomial.removeFactor
theorem X_sub_C_mul_removeFactor (f : K[X]) (hf : f.natDegree ≠ 0) :
(X - C (AdjoinRoot.root f.factor)) * f.removeFactor = map (AdjoinRoot.of f.factor) f := by
let ⟨g, hg⟩ := factor_dvd_of_natDegree_ne_zero hf
apply (mul_divByMonic_eq_iff_isRoot
(R := AdjoinRoot f.factor) (a := AdjoinRoot.root f.factor)).mpr
rw [IsRoot.def, eval_map, hg, eval₂_mul, ← hg, AdjoinRoot.eval₂_root, zero_mul]
set_option linter.uppercaseLean3 false in
#align polynomial.X_sub_C_mul_remove_factor Polynomial.X_sub_C_mul_removeFactor
| Mathlib/FieldTheory/SplittingField/Construction.lean | 97 | 100 | theorem natDegree_removeFactor (f : K[X]) : f.removeFactor.natDegree = f.natDegree - 1 := by |
-- Porting note: `(map (AdjoinRoot.of f.factor) f)` was `_`
rw [removeFactor, natDegree_divByMonic (map (AdjoinRoot.of f.factor) f) (monic_X_sub_C _),
natDegree_map, natDegree_X_sub_C]
|
/-
Copyright (c) 2022 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.MeasureTheory.Measure.WithDensity
import Mathlib.Analysis.NormedSpace.Basic
#align_import measure_theory.integral.lebesgue_normed_space from "leanprover-community/mathlib"@"bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf"
/-! # A lemma about measurability with density under scalar multiplication in normed spaces -/
open MeasureTheory Filter ENNReal Set
open NNReal ENNReal
variable {α β γ δ : Type*} {m : MeasurableSpace α} {μ : MeasureTheory.Measure α}
| Mathlib/MeasureTheory/Integral/LebesgueNormedSpace.lean | 20 | 47 | theorem aemeasurable_withDensity_iff {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
[SecondCountableTopology E] [MeasurableSpace E] [BorelSpace E] {f : α → ℝ≥0}
(hf : Measurable f) {g : α → E} :
AEMeasurable g (μ.withDensity fun x => (f x : ℝ≥0∞)) ↔
AEMeasurable (fun x => (f x : ℝ) • g x) μ := by |
constructor
· rintro ⟨g', g'meas, hg'⟩
have A : MeasurableSet { x : α | f x ≠ 0 } := (hf (measurableSet_singleton 0)).compl
refine ⟨fun x => (f x : ℝ) • g' x, hf.coe_nnreal_real.smul g'meas, ?_⟩
apply @ae_of_ae_restrict_of_ae_restrict_compl _ _ _ { x | f x ≠ 0 }
· rw [EventuallyEq, ae_withDensity_iff hf.coe_nnreal_ennreal] at hg'
rw [ae_restrict_iff' A]
filter_upwards [hg']
intro a ha h'a
have : (f a : ℝ≥0∞) ≠ 0 := by simpa only [Ne, ENNReal.coe_eq_zero] using h'a
rw [ha this]
· filter_upwards [ae_restrict_mem A.compl]
intro x hx
simp only [Classical.not_not, mem_setOf_eq, mem_compl_iff] at hx
simp [hx]
· rintro ⟨g', g'meas, hg'⟩
refine ⟨fun x => (f x : ℝ)⁻¹ • g' x, hf.coe_nnreal_real.inv.smul g'meas, ?_⟩
rw [EventuallyEq, ae_withDensity_iff hf.coe_nnreal_ennreal]
filter_upwards [hg']
intro x hx h'x
rw [← hx, smul_smul, _root_.inv_mul_cancel, one_smul]
simp only [Ne, ENNReal.coe_eq_zero] at h'x
simpa only [NNReal.coe_eq_zero, Ne] using h'x
|
/-
Copyright (c) 2022 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Batteries.Data.Fin.Basic
namespace Fin
attribute [norm_cast] val_last
protected theorem le_antisymm_iff {x y : Fin n} : x = y ↔ x ≤ y ∧ y ≤ x :=
Fin.ext_iff.trans Nat.le_antisymm_iff
protected theorem le_antisymm {x y : Fin n} (h1 : x ≤ y) (h2 : y ≤ x) : x = y :=
Fin.le_antisymm_iff.2 ⟨h1, h2⟩
/-! ### clamp -/
@[simp] theorem coe_clamp (n m : Nat) : (clamp n m : Nat) = min n m := rfl
/-! ### enum/list -/
@[simp] theorem size_enum (n) : (enum n).size = n := Array.size_ofFn ..
@[simp] theorem enum_zero : (enum 0) = #[] := by simp [enum, Array.ofFn, Array.ofFn.go]
@[simp] theorem getElem_enum (i) (h : i < (enum n).size) : (enum n)[i] = ⟨i, size_enum n ▸ h⟩ :=
Array.getElem_ofFn ..
@[simp] theorem length_list (n) : (list n).length = n := by simp [list]
@[simp] theorem get_list (i : Fin (list n).length) : (list n).get i = i.cast (length_list n) := by
cases i; simp only [list]; rw [← Array.getElem_eq_data_get, getElem_enum, cast_mk]
@[simp] theorem list_zero : list 0 = [] := by simp [list]
theorem list_succ (n) : list (n+1) = 0 :: (list n).map Fin.succ := by
apply List.ext_get; simp; intro i; cases i <;> simp
theorem list_succ_last (n) : list (n+1) = (list n).map castSucc ++ [last n] := by
rw [list_succ]
induction n with
| zero => rfl
| succ n ih =>
rw [list_succ, List.map_cons castSucc, ih]
simp [Function.comp_def, succ_castSucc]
theorem list_reverse (n) : (list n).reverse = (list n).map rev := by
induction n with
| zero => rfl
| succ n ih =>
conv => lhs; rw [list_succ_last]
conv => rhs; rw [list_succ]
simp [List.reverse_map, ih, Function.comp_def, rev_succ]
/-! ### foldl -/
theorem foldl_loop_lt (f : α → Fin n → α) (x) (h : m < n) :
foldl.loop n f x m = foldl.loop n f (f x ⟨m, h⟩) (m+1) := by
rw [foldl.loop, dif_pos h]
theorem foldl_loop_eq (f : α → Fin n → α) (x) : foldl.loop n f x n = x := by
rw [foldl.loop, dif_neg (Nat.lt_irrefl _)]
theorem foldl_loop (f : α → Fin (n+1) → α) (x) (h : m < n+1) :
foldl.loop (n+1) f x m = foldl.loop n (fun x i => f x i.succ) (f x ⟨m, h⟩) m := by
if h' : m < n then
rw [foldl_loop_lt _ _ h, foldl_loop_lt _ _ h', foldl_loop]; rfl
else
cases Nat.le_antisymm (Nat.le_of_lt_succ h) (Nat.not_lt.1 h')
rw [foldl_loop_lt, foldl_loop_eq, foldl_loop_eq]
termination_by n - m
@[simp] theorem foldl_zero (f : α → Fin 0 → α) (x) : foldl 0 f x = x := by simp [foldl, foldl.loop]
theorem foldl_succ (f : α → Fin (n+1) → α) (x) :
foldl (n+1) f x = foldl n (fun x i => f x i.succ) (f x 0) := foldl_loop ..
theorem foldl_succ_last (f : α → Fin (n+1) → α) (x) :
foldl (n+1) f x = f (foldl n (f · ·.castSucc) x) (last n) := by
rw [foldl_succ]
induction n generalizing x with
| zero => simp [foldl_succ, Fin.last]
| succ n ih => rw [foldl_succ, ih (f · ·.succ), foldl_succ]; simp [succ_castSucc]
theorem foldl_eq_foldl_list (f : α → Fin n → α) (x) : foldl n f x = (list n).foldl f x := by
induction n generalizing x with
| zero => rw [foldl_zero, list_zero, List.foldl_nil]
| succ n ih => rw [foldl_succ, ih, list_succ, List.foldl_cons, List.foldl_map]
/-! ### foldr -/
unseal foldr.loop in
theorem foldr_loop_zero (f : Fin n → α → α) (x) : foldr.loop n f ⟨0, Nat.zero_le _⟩ x = x :=
rfl
unseal foldr.loop in
theorem foldr_loop_succ (f : Fin n → α → α) (x) (h : m < n) :
foldr.loop n f ⟨m+1, h⟩ x = foldr.loop n f ⟨m, Nat.le_of_lt h⟩ (f ⟨m, h⟩ x) :=
rfl
theorem foldr_loop (f : Fin (n+1) → α → α) (x) (h : m+1 ≤ n+1) :
foldr.loop (n+1) f ⟨m+1, h⟩ x =
f 0 (foldr.loop n (fun i => f i.succ) ⟨m, Nat.le_of_succ_le_succ h⟩ x) := by
induction m generalizing x with
| zero => simp [foldr_loop_zero, foldr_loop_succ]
| succ m ih => rw [foldr_loop_succ, ih, foldr_loop_succ, Fin.succ]
@[simp] theorem foldr_zero (f : Fin 0 → α → α) (x) :
foldr 0 f x = x := foldr_loop_zero ..
theorem foldr_succ (f : Fin (n+1) → α → α) (x) :
foldr (n+1) f x = f 0 (foldr n (fun i => f i.succ) x) := foldr_loop ..
| .lake/packages/batteries/Batteries/Data/Fin/Lemmas.lean | 116 | 120 | theorem foldr_succ_last (f : Fin (n+1) → α → α) (x) :
foldr (n+1) f x = foldr n (f ·.castSucc) (f (last n) x) := by |
induction n generalizing x with
| zero => simp [foldr_succ, Fin.last]
| succ n ih => rw [foldr_succ, ih (f ·.succ), foldr_succ]; simp [succ_castSucc]
|
/-
Copyright (c) 2014 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Yaël Dillies, Patrick Stevens
-/
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Data.Nat.Cast.Order
import Mathlib.Tactic.Common
#align_import data.nat.cast.field from "leanprover-community/mathlib"@"acee671f47b8e7972a1eb6f4eed74b4b3abce829"
/-!
# Cast of naturals into fields
This file concerns the canonical homomorphism `ℕ → F`, where `F` is a field.
## Main results
* `Nat.cast_div`: if `n` divides `m`, then `↑(m / n) = ↑m / ↑n`
* `Nat.cast_div_le`: in all cases, `↑(m / n) ≤ ↑m / ↑ n`
-/
namespace Nat
variable {α : Type*}
@[simp]
theorem cast_div [DivisionSemiring α] {m n : ℕ} (n_dvd : n ∣ m) (hn : (n : α) ≠ 0) :
((m / n : ℕ) : α) = m / n := by
rcases n_dvd with ⟨k, rfl⟩
have : n ≠ 0 := by rintro rfl; simp at hn
rw [Nat.mul_div_cancel_left _ this.bot_lt, mul_comm n, cast_mul, mul_div_cancel_right₀ _ hn]
#align nat.cast_div Nat.cast_div
theorem cast_div_div_div_cancel_right [DivisionSemiring α] [CharZero α] {m n d : ℕ}
(hn : d ∣ n) (hm : d ∣ m) :
(↑(m / d) : α) / (↑(n / d) : α) = (m : α) / n := by
rcases eq_or_ne d 0 with (rfl | hd); · simp [Nat.zero_dvd.1 hm]
replace hd : (d : α) ≠ 0 := by norm_cast
rw [cast_div hm, cast_div hn, div_div_div_cancel_right _ hd] <;> exact hd
#align nat.cast_div_div_div_cancel_right Nat.cast_div_div_div_cancel_right
section LinearOrderedSemifield
variable [LinearOrderedSemifield α]
lemma cast_inv_le_one : ∀ n : ℕ, (n⁻¹ : α) ≤ 1
| 0 => by simp
| n + 1 => inv_le_one $ by simp [Nat.cast_nonneg]
/-- Natural division is always less than division in the field. -/
theorem cast_div_le {m n : ℕ} : ((m / n : ℕ) : α) ≤ m / n := by
cases n
· rw [cast_zero, div_zero, Nat.div_zero, cast_zero]
rw [le_div_iff, ← Nat.cast_mul, @Nat.cast_le]
· exact Nat.div_mul_le_self m _
· exact Nat.cast_pos.2 (Nat.succ_pos _)
#align nat.cast_div_le Nat.cast_div_le
theorem inv_pos_of_nat {n : ℕ} : 0 < ((n : α) + 1)⁻¹ :=
inv_pos.2 <| add_pos_of_nonneg_of_pos n.cast_nonneg zero_lt_one
#align nat.inv_pos_of_nat Nat.inv_pos_of_nat
theorem one_div_pos_of_nat {n : ℕ} : 0 < 1 / ((n : α) + 1) := by
rw [one_div]
exact inv_pos_of_nat
#align nat.one_div_pos_of_nat Nat.one_div_pos_of_nat
| Mathlib/Data/Nat/Cast/Field.lean | 70 | 73 | theorem one_div_le_one_div {n m : ℕ} (h : n ≤ m) : 1 / ((m : α) + 1) ≤ 1 / ((n : α) + 1) := by |
refine one_div_le_one_div_of_le ?_ ?_
· exact Nat.cast_add_one_pos _
· simpa
|
/-
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.Computability.PartrecCode
import Mathlib.Data.Set.Subsingleton
#align_import computability.halting from "leanprover-community/mathlib"@"a50170a88a47570ed186b809ca754110590f9476"
/-!
# Computability theory and the halting problem
A universal partial recursive function, Rice's theorem, and the halting problem.
## References
* [Mario Carneiro, *Formalizing computability theory via partial recursive functions*][carneiro2019]
-/
open Encodable Denumerable
namespace Nat.Partrec
open Computable Part
| Mathlib/Computability/Halting.lean | 28 | 60 | theorem merge' {f g} (hf : Nat.Partrec f) (hg : Nat.Partrec g) :
∃ h, Nat.Partrec h ∧
∀ a, (∀ x ∈ h a, x ∈ f a ∨ x ∈ g a) ∧ ((h a).Dom ↔ (f a).Dom ∨ (g a).Dom) := by |
obtain ⟨cf, rfl⟩ := Code.exists_code.1 hf
obtain ⟨cg, rfl⟩ := Code.exists_code.1 hg
have : Nat.Partrec fun n => Nat.rfindOpt fun k => cf.evaln k n <|> cg.evaln k n :=
Partrec.nat_iff.1
(Partrec.rfindOpt <|
Primrec.option_orElse.to_comp.comp
(Code.evaln_prim.to_comp.comp <| (snd.pair (const cf)).pair fst)
(Code.evaln_prim.to_comp.comp <| (snd.pair (const cg)).pair fst))
refine ⟨_, this, fun n => ?_⟩
have : ∀ x ∈ rfindOpt fun k ↦ HOrElse.hOrElse (Code.evaln k cf n) fun _x ↦ Code.evaln k cg n,
x ∈ Code.eval cf n ∨ x ∈ Code.eval cg n := by
intro x h
obtain ⟨k, e⟩ := Nat.rfindOpt_spec h
revert e
simp only [Option.mem_def]
cases' e' : cf.evaln k n with y <;> simp <;> intro e
· exact Or.inr (Code.evaln_sound e)
· subst y
exact Or.inl (Code.evaln_sound e')
refine ⟨this, ⟨fun h => (this _ ⟨h, rfl⟩).imp Exists.fst Exists.fst, ?_⟩⟩
intro h
rw [Nat.rfindOpt_dom]
simp only [dom_iff_mem, Code.evaln_complete, Option.mem_def] at h
obtain ⟨x, k, e⟩ | ⟨x, k, e⟩ := h
· refine ⟨k, x, ?_⟩
simp only [e, Option.some_orElse, Option.mem_def]
· refine ⟨k, ?_⟩
cases' cf.evaln k n with y
· exact ⟨x, by simp only [e, Option.mem_def, Option.none_orElse]⟩
· exact ⟨y, by simp only [Option.some_orElse, Option.mem_def]⟩
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Exp
import Mathlib.Tactic.Positivity.Core
import Mathlib.Algebra.Ring.NegOnePow
#align_import analysis.special_functions.trigonometric.basic from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
/-!
# Trigonometric functions
## Main definitions
This file contains the definition of `π`.
See also `Analysis.SpecialFunctions.Trigonometric.Inverse` and
`Analysis.SpecialFunctions.Trigonometric.Arctan` for the inverse trigonometric functions.
See also `Analysis.SpecialFunctions.Complex.Arg` and
`Analysis.SpecialFunctions.Complex.Log` for the complex argument function
and the complex logarithm.
## Main statements
Many basic inequalities on the real trigonometric functions are established.
The continuity of the usual trigonometric functions is proved.
Several facts about the real trigonometric functions have the proofs deferred to
`Analysis.SpecialFunctions.Trigonometric.Complex`,
as they are most easily proved by appealing to the corresponding fact for
complex trigonometric functions.
See also `Analysis.SpecialFunctions.Trigonometric.Chebyshev` for the multiple angle formulas
in terms of Chebyshev polynomials.
## Tags
sin, cos, tan, angle
-/
noncomputable section
open scoped Classical
open Topology Filter Set
namespace Complex
@[continuity, fun_prop]
theorem continuous_sin : Continuous sin := by
change Continuous fun z => (exp (-z * I) - exp (z * I)) * I / 2
continuity
#align complex.continuous_sin Complex.continuous_sin
@[fun_prop]
theorem continuousOn_sin {s : Set ℂ} : ContinuousOn sin s :=
continuous_sin.continuousOn
#align complex.continuous_on_sin Complex.continuousOn_sin
@[continuity, fun_prop]
theorem continuous_cos : Continuous cos := by
change Continuous fun z => (exp (z * I) + exp (-z * I)) / 2
continuity
#align complex.continuous_cos Complex.continuous_cos
@[fun_prop]
theorem continuousOn_cos {s : Set ℂ} : ContinuousOn cos s :=
continuous_cos.continuousOn
#align complex.continuous_on_cos Complex.continuousOn_cos
@[continuity, fun_prop]
| Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean | 76 | 78 | theorem continuous_sinh : Continuous sinh := by |
change Continuous fun z => (exp z - exp (-z)) / 2
continuity
|
/-
Copyright (c) 2022 Wrenna Robson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Wrenna Robson
-/
import Mathlib.Topology.MetricSpace.Basic
#align_import topology.metric_space.infsep from "leanprover-community/mathlib"@"5316314b553dcf8c6716541851517c1a9715e22b"
/-!
# Infimum separation
This file defines the extended infimum separation of a set. This is approximately dual to the
diameter of a set, but where the extended diameter of a set is the supremum of the extended distance
between elements of the set, the extended infimum separation is the infimum of the (extended)
distance between *distinct* elements in the set.
We also define the infimum separation as the cast of the extended infimum separation to the reals.
This is the infimum of the distance between distinct elements of the set when in a pseudometric
space.
All lemmas and definitions are in the `Set` namespace to give access to dot notation.
## Main definitions
* `Set.einfsep`: Extended infimum separation of a set.
* `Set.infsep`: Infimum separation of a set (when in a pseudometric space).
!-/
variable {α β : Type*}
namespace Set
section Einfsep
open ENNReal
open Function
/-- The "extended infimum separation" of a set with an edist function. -/
noncomputable def einfsep [EDist α] (s : Set α) : ℝ≥0∞ :=
⨅ (x ∈ s) (y ∈ s) (_ : x ≠ y), edist x y
#align set.einfsep Set.einfsep
section EDist
variable [EDist α] {x y : α} {s t : Set α}
theorem le_einfsep_iff {d} :
d ≤ s.einfsep ↔ ∀ x ∈ s, ∀ y ∈ s, x ≠ y → d ≤ edist x y := by
simp_rw [einfsep, le_iInf_iff]
#align set.le_einfsep_iff Set.le_einfsep_iff
theorem einfsep_zero : s.einfsep = 0 ↔ ∀ C > 0, ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < C := by
simp_rw [einfsep, ← _root_.bot_eq_zero, iInf_eq_bot, iInf_lt_iff, exists_prop]
#align set.einfsep_zero Set.einfsep_zero
theorem einfsep_pos : 0 < s.einfsep ↔ ∃ C > 0, ∀ x ∈ s, ∀ y ∈ s, x ≠ y → C ≤ edist x y := by
rw [pos_iff_ne_zero, Ne, einfsep_zero]
simp only [not_forall, not_exists, not_lt, exists_prop, not_and]
#align set.einfsep_pos Set.einfsep_pos
theorem einfsep_top :
s.einfsep = ∞ ↔ ∀ x ∈ s, ∀ y ∈ s, x ≠ y → edist x y = ∞ := by
simp_rw [einfsep, iInf_eq_top]
#align set.einfsep_top Set.einfsep_top
theorem einfsep_lt_top :
s.einfsep < ∞ ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < ∞ := by
simp_rw [einfsep, iInf_lt_iff, exists_prop]
#align set.einfsep_lt_top Set.einfsep_lt_top
theorem einfsep_ne_top :
s.einfsep ≠ ∞ ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y ≠ ∞ := by
simp_rw [← lt_top_iff_ne_top, einfsep_lt_top]
#align set.einfsep_ne_top Set.einfsep_ne_top
theorem einfsep_lt_iff {d} :
s.einfsep < d ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < d := by
simp_rw [einfsep, iInf_lt_iff, exists_prop]
#align set.einfsep_lt_iff Set.einfsep_lt_iff
theorem nontrivial_of_einfsep_lt_top (hs : s.einfsep < ∞) : s.Nontrivial := by
rcases einfsep_lt_top.1 hs with ⟨_, hx, _, hy, hxy, _⟩
exact ⟨_, hx, _, hy, hxy⟩
#align set.nontrivial_of_einfsep_lt_top Set.nontrivial_of_einfsep_lt_top
theorem nontrivial_of_einfsep_ne_top (hs : s.einfsep ≠ ∞) : s.Nontrivial :=
nontrivial_of_einfsep_lt_top (lt_top_iff_ne_top.mpr hs)
#align set.nontrivial_of_einfsep_ne_top Set.nontrivial_of_einfsep_ne_top
| Mathlib/Topology/MetricSpace/Infsep.lean | 93 | 95 | theorem Subsingleton.einfsep (hs : s.Subsingleton) : s.einfsep = ∞ := by |
rw [einfsep_top]
exact fun _ hx _ hy hxy => (hxy <| hs hx hy).elim
|
/-
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
Some proofs and docs came from `algebra/commute` (c) Neil Strickland
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Init.Logic
import Mathlib.Tactic.Cases
#align_import algebra.group.semiconj from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64"
/-!
# Semiconjugate elements of a semigroup
## Main definitions
We say that `x` is semiconjugate to `y` by `a` (`SemiconjBy a x y`), if `a * x = y * a`.
In this file we provide operations on `SemiconjBy _ _ _`.
In the names of these operations, we treat `a` as the “left” argument, and both `x` and `y` as
“right” arguments. This way most names in this file agree with the names of the corresponding lemmas
for `Commute a b = SemiconjBy a b b`. As a side effect, some lemmas have only `_right` version.
Lean does not immediately recognise these terms as equations, so for rewriting we need syntax like
`rw [(h.pow_right 5).eq]` rather than just `rw [h.pow_right 5]`.
This file provides only basic operations (`mul_left`, `mul_right`, `inv_right` etc). Other
operations (`pow_right`, field inverse etc) are in the files that define corresponding notions.
-/
assert_not_exists MonoidWithZero
assert_not_exists DenselyOrdered
variable {S M G : Type*}
/-- `x` is semiconjugate to `y` by `a`, if `a * x = y * a`. -/
@[to_additive "`x` is additive semiconjugate to `y` by `a` if `a + x = y + a`"]
def SemiconjBy [Mul M] (a x y : M) : Prop :=
a * x = y * a
#align semiconj_by SemiconjBy
#align add_semiconj_by AddSemiconjBy
namespace SemiconjBy
/-- Equality behind `SemiconjBy a x y`; useful for rewriting. -/
@[to_additive "Equality behind `AddSemiconjBy a x y`; useful for rewriting."]
protected theorem eq [Mul S] {a x y : S} (h : SemiconjBy a x y) : a * x = y * a :=
h
#align semiconj_by.eq SemiconjBy.eq
#align add_semiconj_by.eq AddSemiconjBy.eq
section Semigroup
variable [Semigroup S] {a b x y z x' y' : S}
/-- If `a` semiconjugates `x` to `y` and `x'` to `y'`,
then it semiconjugates `x * x'` to `y * y'`. -/
@[to_additive (attr := simp) "If `a` semiconjugates `x` to `y` and `x'` to `y'`,
then it semiconjugates `x + x'` to `y + y'`."]
| Mathlib/Algebra/Group/Semiconj/Defs.lean | 62 | 66 | theorem mul_right (h : SemiconjBy a x y) (h' : SemiconjBy a x' y') :
SemiconjBy a (x * x') (y * y') := by |
unfold SemiconjBy
-- TODO this could be done using `assoc_rw` if/when this is ported to mathlib4
rw [← mul_assoc, h.eq, mul_assoc, h'.eq, ← mul_assoc]
|
/-
Copyright (c) 2023 Jon Eugster. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Asgeirsson, Boris Bolvig Kjær, Jon Eugster, Sina Hazratpour
-/
import Mathlib.CategoryTheory.Sites.Coherent.ReflectsPreregular
import Mathlib.Topology.Category.CompHaus.EffectiveEpi
import Mathlib.Topology.Category.Profinite.Limits
import Mathlib.Topology.Category.Stonean.Basic
/-!
# Effective epimorphisms and finite effective epimorphic families in `Profinite`
This file proves that `Profinite` is `Preregular`. Together with the fact that it is
`FinitaryPreExtensive`, this implies that `Profinite` is `Precoherent`.
To do this, we need to characterise effective epimorphisms in `Profinite`. As a consequence, we also
get a characterisation of finite effective epimorphic families.
## Main results
* `Profinite.effectiveEpi_tfae`: For a morphism in `Profinite`, the conditions surjective,
epimorphic, and effective epimorphic are all equivalent.
* `Profinite.effectiveEpiFamily_tfae`: For a finite family of morphisms in `Profinite` with fixed
target in `Profinite`, the conditions jointly surjective, jointly epimorphic and effective
epimorphic are all equivalent.
As a consequence, we obtain instances that `Profinite` is precoherent and preregular.
-/
universe u
/-
Previously, this had accidentally been made a global instance,
and we now turn it on locally when convenient.
-/
attribute [local instance] CategoryTheory.ConcreteCategory.instFunLike
open CategoryTheory Limits
namespace Profinite
/--
Implementation: If `π` is a surjective morphism in `Profinite`, then it is an effective epi.
The theorem `Profinite.effectiveEpi_tfae` should be used instead.
-/
noncomputable
def struct {B X : Profinite.{u}} (π : X ⟶ B) (hπ : Function.Surjective π) :
EffectiveEpiStruct π where
desc e h := (QuotientMap.of_surjective_continuous hπ π.continuous).lift e fun a b hab ↦
DFunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
(by ext; exact hab)) a
fac e h := ((QuotientMap.of_surjective_continuous hπ π.continuous).lift_comp e
fun a b hab ↦ DFunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩
(by ext; exact hab)) a)
uniq e h g hm := by
suffices g = (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv ⟨e,
fun a b hab ↦ DFunLike.congr_fun
(h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩ (by ext; exact hab))
a⟩ by assumption
rw [← Equiv.symm_apply_eq (QuotientMap.of_surjective_continuous hπ π.continuous).liftEquiv]
ext
simp only [QuotientMap.liftEquiv_symm_apply_coe, ContinuousMap.comp_apply, ← hm]
rfl
open List in
| Mathlib/Topology/Category/Profinite/EffectiveEpi.lean | 69 | 82 | theorem effectiveEpi_tfae
{B X : Profinite.{u}} (π : X ⟶ B) :
TFAE
[ EffectiveEpi π
, Epi π
, Function.Surjective π
] := by |
tfae_have 1 → 2
· intro; infer_instance
tfae_have 2 ↔ 3
· exact epi_iff_surjective π
tfae_have 3 → 1
· exact fun hπ ↦ ⟨⟨struct π hπ⟩⟩
tfae_finish
|
/-
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.Data.Set.Image
import Mathlib.Order.Interval.Set.Basic
#align_import data.set.intervals.with_bot_top from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105"
/-!
# Intervals in `WithTop α` and `WithBot α`
In this file we prove various lemmas about `Set.image`s and `Set.preimage`s of intervals under
`some : α → WithTop α` and `some : α → WithBot α`.
-/
open Set
variable {α : Type*}
/-! ### `WithTop` -/
namespace WithTop
@[simp]
theorem preimage_coe_top : (some : α → WithTop α) ⁻¹' {⊤} = (∅ : Set α) :=
eq_empty_of_subset_empty fun _ => coe_ne_top
#align with_top.preimage_coe_top WithTop.preimage_coe_top
variable [Preorder α] {a b : α}
theorem range_coe : range (some : α → WithTop α) = Iio ⊤ := by
ext x
rw [mem_Iio, WithTop.lt_top_iff_ne_top, mem_range, ne_top_iff_exists]
#align with_top.range_coe WithTop.range_coe
@[simp]
theorem preimage_coe_Ioi : (some : α → WithTop α) ⁻¹' Ioi a = Ioi a :=
ext fun _ => coe_lt_coe
#align with_top.preimage_coe_Ioi WithTop.preimage_coe_Ioi
@[simp]
theorem preimage_coe_Ici : (some : α → WithTop α) ⁻¹' Ici a = Ici a :=
ext fun _ => coe_le_coe
#align with_top.preimage_coe_Ici WithTop.preimage_coe_Ici
@[simp]
theorem preimage_coe_Iio : (some : α → WithTop α) ⁻¹' Iio a = Iio a :=
ext fun _ => coe_lt_coe
#align with_top.preimage_coe_Iio WithTop.preimage_coe_Iio
@[simp]
theorem preimage_coe_Iic : (some : α → WithTop α) ⁻¹' Iic a = Iic a :=
ext fun _ => coe_le_coe
#align with_top.preimage_coe_Iic WithTop.preimage_coe_Iic
@[simp]
theorem preimage_coe_Icc : (some : α → WithTop α) ⁻¹' Icc a b = Icc a b := by simp [← Ici_inter_Iic]
#align with_top.preimage_coe_Icc WithTop.preimage_coe_Icc
@[simp]
theorem preimage_coe_Ico : (some : α → WithTop α) ⁻¹' Ico a b = Ico a b := by simp [← Ici_inter_Iio]
#align with_top.preimage_coe_Ico WithTop.preimage_coe_Ico
@[simp]
theorem preimage_coe_Ioc : (some : α → WithTop α) ⁻¹' Ioc a b = Ioc a b := by simp [← Ioi_inter_Iic]
#align with_top.preimage_coe_Ioc WithTop.preimage_coe_Ioc
@[simp]
theorem preimage_coe_Ioo : (some : α → WithTop α) ⁻¹' Ioo a b = Ioo a b := by simp [← Ioi_inter_Iio]
#align with_top.preimage_coe_Ioo WithTop.preimage_coe_Ioo
@[simp]
theorem preimage_coe_Iio_top : (some : α → WithTop α) ⁻¹' Iio ⊤ = univ := by
rw [← range_coe, preimage_range]
#align with_top.preimage_coe_Iio_top WithTop.preimage_coe_Iio_top
@[simp]
theorem preimage_coe_Ico_top : (some : α → WithTop α) ⁻¹' Ico a ⊤ = Ici a := by
simp [← Ici_inter_Iio]
#align with_top.preimage_coe_Ico_top WithTop.preimage_coe_Ico_top
@[simp]
theorem preimage_coe_Ioo_top : (some : α → WithTop α) ⁻¹' Ioo a ⊤ = Ioi a := by
simp [← Ioi_inter_Iio]
#align with_top.preimage_coe_Ioo_top WithTop.preimage_coe_Ioo_top
theorem image_coe_Ioi : (some : α → WithTop α) '' Ioi a = Ioo (a : WithTop α) ⊤ := by
rw [← preimage_coe_Ioi, image_preimage_eq_inter_range, range_coe, Ioi_inter_Iio]
#align with_top.image_coe_Ioi WithTop.image_coe_Ioi
theorem image_coe_Ici : (some : α → WithTop α) '' Ici a = Ico (a : WithTop α) ⊤ := by
rw [← preimage_coe_Ici, image_preimage_eq_inter_range, range_coe, Ici_inter_Iio]
#align with_top.image_coe_Ici WithTop.image_coe_Ici
theorem image_coe_Iio : (some : α → WithTop α) '' Iio a = Iio (a : WithTop α) := by
rw [← preimage_coe_Iio, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left (Iio_subset_Iio le_top)]
#align with_top.image_coe_Iio WithTop.image_coe_Iio
theorem image_coe_Iic : (some : α → WithTop α) '' Iic a = Iic (a : WithTop α) := by
rw [← preimage_coe_Iic, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left (Iic_subset_Iio.2 <| coe_lt_top a)]
#align with_top.image_coe_Iic WithTop.image_coe_Iic
theorem image_coe_Icc : (some : α → WithTop α) '' Icc a b = Icc (a : WithTop α) b := by
rw [← preimage_coe_Icc, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left
(Subset.trans Icc_subset_Iic_self <| Iic_subset_Iio.2 <| coe_lt_top b)]
#align with_top.image_coe_Icc WithTop.image_coe_Icc
| Mathlib/Order/Interval/Set/WithBotTop.lean | 113 | 115 | theorem image_coe_Ico : (some : α → WithTop α) '' Ico a b = Ico (a : WithTop α) b := by |
rw [← preimage_coe_Ico, image_preimage_eq_inter_range, range_coe,
inter_eq_self_of_subset_left (Subset.trans Ico_subset_Iio_self <| Iio_subset_Iio le_top)]
|
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Finset.Lattice
import Mathlib.Data.Multiset.Powerset
#align_import data.finset.powerset from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
/-!
# The powerset of a finset
-/
namespace Finset
open Function Multiset
variable {α : Type*} {s t : Finset α}
/-! ### powerset -/
section Powerset
/-- When `s` is a finset, `s.powerset` is the finset of all subsets of `s` (seen as finsets). -/
def powerset (s : Finset α) : Finset (Finset α) :=
⟨(s.1.powerset.pmap Finset.mk) fun _t h => nodup_of_le (mem_powerset.1 h) s.nodup,
s.nodup.powerset.pmap fun _a _ha _b _hb => congr_arg Finset.val⟩
#align finset.powerset Finset.powerset
@[simp]
theorem mem_powerset {s t : Finset α} : s ∈ powerset t ↔ s ⊆ t := by
cases s
simp [powerset, mem_mk, mem_pmap, mk.injEq, mem_powerset, exists_prop, exists_eq_right,
← val_le_iff]
#align finset.mem_powerset Finset.mem_powerset
@[simp, norm_cast]
theorem coe_powerset (s : Finset α) :
(s.powerset : Set (Finset α)) = ((↑) : Finset α → Set α) ⁻¹' (s : Set α).powerset := by
ext
simp
#align finset.coe_powerset Finset.coe_powerset
-- Porting note: remove @[simp], simp can prove it
theorem empty_mem_powerset (s : Finset α) : ∅ ∈ powerset s :=
mem_powerset.2 (empty_subset _)
#align finset.empty_mem_powerset Finset.empty_mem_powerset
-- Porting note: remove @[simp], simp can prove it
theorem mem_powerset_self (s : Finset α) : s ∈ powerset s :=
mem_powerset.2 Subset.rfl
#align finset.mem_powerset_self Finset.mem_powerset_self
@[aesop safe apply (rule_sets := [finsetNonempty])]
theorem powerset_nonempty (s : Finset α) : s.powerset.Nonempty :=
⟨∅, empty_mem_powerset _⟩
#align finset.powerset_nonempty Finset.powerset_nonempty
@[simp]
theorem powerset_mono {s t : Finset α} : powerset s ⊆ powerset t ↔ s ⊆ t :=
⟨fun h => mem_powerset.1 <| h <| mem_powerset_self _, fun st _u h =>
mem_powerset.2 <| Subset.trans (mem_powerset.1 h) st⟩
#align finset.powerset_mono Finset.powerset_mono
theorem powerset_injective : Injective (powerset : Finset α → Finset (Finset α)) :=
(injective_of_le_imp_le _) powerset_mono.1
#align finset.powerset_injective Finset.powerset_injective
@[simp]
theorem powerset_inj : powerset s = powerset t ↔ s = t :=
powerset_injective.eq_iff
#align finset.powerset_inj Finset.powerset_inj
@[simp]
theorem powerset_empty : (∅ : Finset α).powerset = {∅} :=
rfl
#align finset.powerset_empty Finset.powerset_empty
@[simp]
| Mathlib/Data/Finset/Powerset.lean | 83 | 84 | theorem powerset_eq_singleton_empty : s.powerset = {∅} ↔ s = ∅ := by |
rw [← powerset_empty, powerset_inj]
|
/-
Copyright (c) 2021 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen
-/
import Mathlib.Data.Int.AbsoluteValue
import Mathlib.LinearAlgebra.Matrix.Determinant.Basic
#align_import linear_algebra.matrix.absolute_value from "leanprover-community/mathlib"@"ab0a2959c83b06280ef576bc830d4aa5fe8c8e61"
/-!
# Absolute values and matrices
This file proves some bounds on matrices involving absolute values.
## Main results
* `Matrix.det_le`: if the entries of an `n × n` matrix are bounded by `x`,
then the determinant is bounded by `n! x^n`
* `Matrix.det_sum_le`: if we have `s` `n × n` matrices and the entries of each
matrix are bounded by `x`, then the determinant of their sum is bounded by `n! (s * x)^n`
* `Matrix.det_sum_smul_le`: if we have `s` `n × n` matrices each multiplied by
a constant bounded by `y`, and the entries of each matrix are bounded by `x`,
then the determinant of the linear combination is bounded by `n! (s * y * x)^n`
-/
open Matrix
namespace Matrix
open Equiv Finset
variable {R S : Type*} [CommRing R] [Nontrivial R] [LinearOrderedCommRing S]
variable {n : Type*} [Fintype n] [DecidableEq n]
| Mathlib/LinearAlgebra/Matrix/AbsoluteValue.lean | 37 | 49 | theorem det_le {A : Matrix n n R} {abv : AbsoluteValue R S} {x : S} (hx : ∀ i j, abv (A i j) ≤ x) :
abv A.det ≤ Nat.factorial (Fintype.card n) • x ^ Fintype.card n :=
calc
abv A.det = abv (∑ σ : Perm n, Perm.sign σ • ∏ i, A (σ i) i) := congr_arg abv (det_apply _)
_ ≤ ∑ σ : Perm n, abv (Perm.sign σ • ∏ i, A (σ i) i) := abv.sum_le _ _
_ = ∑ σ : Perm n, ∏ i, abv (A (σ i) i) :=
(sum_congr rfl fun σ _ => by rw [abv.map_units_int_smul, abv.map_prod])
_ ≤ ∑ _σ : Perm n, ∏ _i : n, x :=
(sum_le_sum fun _ _ => prod_le_prod (fun _ _ => abv.nonneg _) fun _ _ => hx _ _)
_ = ∑ _σ : Perm n, x ^ Fintype.card n :=
(sum_congr rfl fun _ _ => by rw [prod_const, Finset.card_univ])
_ = Nat.factorial (Fintype.card n) • x ^ Fintype.card n := by |
rw [sum_const, Finset.card_univ, Fintype.card_perm]
|
/-
Copyright (c) 2022 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn
-/
import Mathlib.Analysis.Calculus.BumpFunction.Basic
import Mathlib.MeasureTheory.Integral.SetIntegral
import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar
#align_import analysis.calculus.bump_function_inner from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
/-!
# Normed bump function
In this file we define `ContDiffBump.normed f μ` to be the bump function `f` normalized so that
`∫ x, f.normed μ x ∂μ = 1` and prove some properties of this function.
-/
noncomputable section
open Function Filter Set Metric MeasureTheory FiniteDimensional Measure
open scoped Topology
namespace ContDiffBump
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [HasContDiffBump E]
[MeasurableSpace E] {c : E} (f : ContDiffBump c) {x : E} {n : ℕ∞} {μ : Measure E}
/-- A bump function normed so that `∫ x, f.normed μ x ∂μ = 1`. -/
protected def normed (μ : Measure E) : E → ℝ := fun x => f x / ∫ x, f x ∂μ
#align cont_diff_bump.normed ContDiffBump.normed
theorem normed_def {μ : Measure E} (x : E) : f.normed μ x = f x / ∫ x, f x ∂μ :=
rfl
#align cont_diff_bump.normed_def ContDiffBump.normed_def
theorem nonneg_normed (x : E) : 0 ≤ f.normed μ x :=
div_nonneg f.nonneg <| integral_nonneg f.nonneg'
#align cont_diff_bump.nonneg_normed ContDiffBump.nonneg_normed
theorem contDiff_normed {n : ℕ∞} : ContDiff ℝ n (f.normed μ) :=
f.contDiff.div_const _
#align cont_diff_bump.cont_diff_normed ContDiffBump.contDiff_normed
theorem continuous_normed : Continuous (f.normed μ) :=
f.continuous.div_const _
#align cont_diff_bump.continuous_normed ContDiffBump.continuous_normed
theorem normed_sub (x : E) : f.normed μ (c - x) = f.normed μ (c + x) := by
simp_rw [f.normed_def, f.sub]
#align cont_diff_bump.normed_sub ContDiffBump.normed_sub
theorem normed_neg (f : ContDiffBump (0 : E)) (x : E) : f.normed μ (-x) = f.normed μ x := by
simp_rw [f.normed_def, f.neg]
#align cont_diff_bump.normed_neg ContDiffBump.normed_neg
variable [BorelSpace E] [FiniteDimensional ℝ E] [IsLocallyFiniteMeasure μ]
protected theorem integrable : Integrable f μ :=
f.continuous.integrable_of_hasCompactSupport f.hasCompactSupport
#align cont_diff_bump.integrable ContDiffBump.integrable
protected theorem integrable_normed : Integrable (f.normed μ) μ :=
f.integrable.div_const _
#align cont_diff_bump.integrable_normed ContDiffBump.integrable_normed
variable [μ.IsOpenPosMeasure]
theorem integral_pos : 0 < ∫ x, f x ∂μ := by
refine (integral_pos_iff_support_of_nonneg f.nonneg' f.integrable).mpr ?_
rw [f.support_eq]
exact measure_ball_pos μ c f.rOut_pos
#align cont_diff_bump.integral_pos ContDiffBump.integral_pos
theorem integral_normed : ∫ x, f.normed μ x ∂μ = 1 := by
simp_rw [ContDiffBump.normed, div_eq_mul_inv, mul_comm (f _), ← smul_eq_mul, integral_smul]
exact inv_mul_cancel f.integral_pos.ne'
#align cont_diff_bump.integral_normed ContDiffBump.integral_normed
theorem support_normed_eq : Function.support (f.normed μ) = Metric.ball c f.rOut := by
unfold ContDiffBump.normed
rw [support_div, f.support_eq, support_const f.integral_pos.ne', inter_univ]
#align cont_diff_bump.support_normed_eq ContDiffBump.support_normed_eq
theorem tsupport_normed_eq : tsupport (f.normed μ) = Metric.closedBall c f.rOut := by
rw [tsupport, f.support_normed_eq, closure_ball _ f.rOut_pos.ne']
#align cont_diff_bump.tsupport_normed_eq ContDiffBump.tsupport_normed_eq
theorem hasCompactSupport_normed : HasCompactSupport (f.normed μ) := by
simp only [HasCompactSupport, f.tsupport_normed_eq (μ := μ), isCompact_closedBall]
#align cont_diff_bump.has_compact_support_normed ContDiffBump.hasCompactSupport_normed
| Mathlib/Analysis/Calculus/BumpFunction/Normed.lean | 93 | 101 | theorem tendsto_support_normed_smallSets {ι} {φ : ι → ContDiffBump c} {l : Filter ι}
(hφ : Tendsto (fun i => (φ i).rOut) l (𝓝 0)) :
Tendsto (fun i => Function.support fun x => (φ i).normed μ x) l (𝓝 c).smallSets := by |
simp_rw [NormedAddCommGroup.tendsto_nhds_zero, Real.norm_eq_abs,
abs_eq_self.mpr (φ _).rOut_pos.le] at hφ
rw [nhds_basis_ball.smallSets.tendsto_right_iff]
refine fun ε hε ↦ (hφ ε hε).mono fun i hi ↦ ?_
rw [(φ i).support_normed_eq]
exact ball_subset_ball hi.le
|
/-
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
theorem dist_ne_zero {x y : γ} : dist x y ≠ 0 ↔ x ≠ y := by
simpa only [not_iff_not] using dist_eq_zero
#align dist_ne_zero dist_ne_zero
@[simp]
theorem dist_le_zero {x y : γ} : dist x y ≤ 0 ↔ x = y := by
simpa [le_antisymm_iff, dist_nonneg] using @dist_eq_zero _ _ x y
#align dist_le_zero dist_le_zero
@[simp]
theorem dist_pos {x y : γ} : 0 < dist x y ↔ x ≠ y := by
simpa only [not_le] using not_congr dist_le_zero
#align dist_pos dist_pos
theorem eq_of_forall_dist_le {x y : γ} (h : ∀ ε > 0, dist x y ≤ ε) : x = y :=
eq_of_dist_eq_zero (eq_of_le_of_forall_le_of_dense dist_nonneg h)
#align eq_of_forall_dist_le eq_of_forall_dist_le
/-- Deduce the equality of points from the vanishing of the nonnegative distance-/
| Mathlib/Topology/MetricSpace/Basic.lean | 96 | 97 | theorem eq_of_nndist_eq_zero {x y : γ} : nndist x y = 0 → x = y := by |
simp only [← NNReal.eq_iff, ← dist_nndist, imp_self, NNReal.coe_zero, dist_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
-/
import Mathlib.Order.Interval.Set.UnorderedInterval
import Mathlib.Algebra.Order.Interval.Set.Monoid
import Mathlib.Data.Set.Pointwise.Basic
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Algebra.Order.Group.MinMax
#align_import data.set.pointwise.interval from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
/-!
# (Pre)images of intervals
In this file we prove a bunch of trivial lemmas like “if we add `a` to all points of `[b, c]`,
then we get `[a + b, a + c]`”. For the functions `x ↦ x ± a`, `x ↦ a ± x`, and `x ↦ -x` we prove
lemmas about preimages and images of all intervals. We also prove a few lemmas about images under
`x ↦ a * x`, `x ↦ x * a` and `x ↦ x⁻¹`.
-/
open Interval Pointwise
variable {α : Type*}
namespace Set
/-! ### Binary pointwise operations
Note that the subset operations below only cover the cases with the largest possible intervals on
the LHS: to conclude that `Ioo a b * Ioo c d ⊆ Ioo (a * c) (c * d)`, you can use monotonicity of `*`
and `Set.Ico_mul_Ioc_subset`.
TODO: repeat these lemmas for the generality of `mul_le_mul` (which assumes nonnegativity), which
the unprimed names have been reserved for
-/
section ContravariantLE
variable [Mul α] [Preorder α]
variable [CovariantClass α α (· * ·) (· ≤ ·)] [CovariantClass α α (Function.swap HMul.hMul) LE.le]
@[to_additive Icc_add_Icc_subset]
theorem Icc_mul_Icc_subset' (a b c d : α) : Icc a b * Icc c d ⊆ Icc (a * c) (b * d) := by
rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩
exact ⟨mul_le_mul' hya hzc, mul_le_mul' hyb hzd⟩
@[to_additive Iic_add_Iic_subset]
theorem Iic_mul_Iic_subset' (a b : α) : Iic a * Iic b ⊆ Iic (a * b) := by
rintro x ⟨y, hya, z, hzb, rfl⟩
exact mul_le_mul' hya hzb
@[to_additive Ici_add_Ici_subset]
theorem Ici_mul_Ici_subset' (a b : α) : Ici a * Ici b ⊆ Ici (a * b) := by
rintro x ⟨y, hya, z, hzb, rfl⟩
exact mul_le_mul' hya hzb
end ContravariantLE
section ContravariantLT
variable [Mul α] [PartialOrder α]
variable [CovariantClass α α (· * ·) (· < ·)] [CovariantClass α α (Function.swap HMul.hMul) LT.lt]
@[to_additive Icc_add_Ico_subset]
| Mathlib/Data/Set/Pointwise/Interval.lean | 68 | 71 | theorem Icc_mul_Ico_subset' (a b c d : α) : Icc a b * Ico c d ⊆ Ico (a * c) (b * d) := by |
haveI := covariantClass_le_of_lt
rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩
exact ⟨mul_le_mul' hya hzc, mul_lt_mul_of_le_of_lt hyb hzd⟩
|
/-
Copyright (c) 2019 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Yakov Pechersky
-/
import Mathlib.Data.List.Nodup
import Mathlib.Data.List.Zip
import Mathlib.Data.Nat.Defs
import Mathlib.Data.List.Infix
#align_import data.list.rotate from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
/-!
# List rotation
This file proves basic results about `List.rotate`, the list rotation.
## Main declarations
* `List.IsRotated l₁ l₂`: States that `l₁` is a rotated version of `l₂`.
* `List.cyclicPermutations l`: The list of all cyclic permutants of `l`, up to the length of `l`.
## Tags
rotated, rotation, permutation, cycle
-/
universe u
variable {α : Type u}
open Nat Function
namespace List
theorem rotate_mod (l : List α) (n : ℕ) : l.rotate (n % l.length) = l.rotate n := by simp [rotate]
#align list.rotate_mod List.rotate_mod
@[simp]
theorem rotate_nil (n : ℕ) : ([] : List α).rotate n = [] := by simp [rotate]
#align list.rotate_nil List.rotate_nil
@[simp]
theorem rotate_zero (l : List α) : l.rotate 0 = l := by simp [rotate]
#align list.rotate_zero List.rotate_zero
-- Porting note: removing simp, simp can prove it
theorem rotate'_nil (n : ℕ) : ([] : List α).rotate' n = [] := by cases n <;> rfl
#align list.rotate'_nil List.rotate'_nil
@[simp]
theorem rotate'_zero (l : List α) : l.rotate' 0 = l := by cases l <;> rfl
#align list.rotate'_zero List.rotate'_zero
theorem rotate'_cons_succ (l : List α) (a : α) (n : ℕ) :
(a :: l : List α).rotate' n.succ = (l ++ [a]).rotate' n := by simp [rotate']
#align list.rotate'_cons_succ List.rotate'_cons_succ
@[simp]
theorem length_rotate' : ∀ (l : List α) (n : ℕ), (l.rotate' n).length = l.length
| [], _ => by simp
| a :: l, 0 => rfl
| a :: l, n + 1 => by rw [List.rotate', length_rotate' (l ++ [a]) n]; simp
#align list.length_rotate' List.length_rotate'
theorem rotate'_eq_drop_append_take :
∀ {l : List α} {n : ℕ}, n ≤ l.length → l.rotate' n = l.drop n ++ l.take n
| [], n, h => by simp [drop_append_of_le_length h]
| l, 0, h => by simp [take_append_of_le_length h]
| a :: l, n + 1, h => by
have hnl : n ≤ l.length := le_of_succ_le_succ h
have hnl' : n ≤ (l ++ [a]).length := by
rw [length_append, length_cons, List.length]; exact le_of_succ_le h
rw [rotate'_cons_succ, rotate'_eq_drop_append_take hnl', drop, take,
drop_append_of_le_length hnl, take_append_of_le_length hnl]; simp
#align list.rotate'_eq_drop_append_take List.rotate'_eq_drop_append_take
theorem rotate'_rotate' : ∀ (l : List α) (n m : ℕ), (l.rotate' n).rotate' m = l.rotate' (n + m)
| a :: l, 0, m => by simp
| [], n, m => by simp
| a :: l, n + 1, m => by
rw [rotate'_cons_succ, rotate'_rotate' _ n, Nat.add_right_comm, ← rotate'_cons_succ,
Nat.succ_eq_add_one]
#align list.rotate'_rotate' List.rotate'_rotate'
@[simp]
theorem rotate'_length (l : List α) : rotate' l l.length = l := by
rw [rotate'_eq_drop_append_take le_rfl]; simp
#align list.rotate'_length List.rotate'_length
@[simp]
theorem rotate'_length_mul (l : List α) : ∀ n : ℕ, l.rotate' (l.length * n) = l
| 0 => by simp
| n + 1 =>
calc
l.rotate' (l.length * (n + 1)) =
(l.rotate' (l.length * n)).rotate' (l.rotate' (l.length * n)).length := by
simp [-rotate'_length, Nat.mul_succ, rotate'_rotate']
_ = l := by rw [rotate'_length, rotate'_length_mul l n]
#align list.rotate'_length_mul List.rotate'_length_mul
theorem rotate'_mod (l : List α) (n : ℕ) : l.rotate' (n % l.length) = l.rotate' n :=
calc
l.rotate' (n % l.length) =
(l.rotate' (n % l.length)).rotate' ((l.rotate' (n % l.length)).length * (n / l.length)) :=
by rw [rotate'_length_mul]
_ = l.rotate' n := by rw [rotate'_rotate', length_rotate', Nat.mod_add_div]
#align list.rotate'_mod List.rotate'_mod
theorem rotate_eq_rotate' (l : List α) (n : ℕ) : l.rotate n = l.rotate' n :=
if h : l.length = 0 then by simp_all [length_eq_zero]
else by
rw [← rotate'_mod,
rotate'_eq_drop_append_take (le_of_lt (Nat.mod_lt _ (Nat.pos_of_ne_zero h)))];
simp [rotate]
#align list.rotate_eq_rotate' List.rotate_eq_rotate'
theorem rotate_cons_succ (l : List α) (a : α) (n : ℕ) :
(a :: l : List α).rotate (n + 1) = (l ++ [a]).rotate n := by
rw [rotate_eq_rotate', rotate_eq_rotate', rotate'_cons_succ]
#align list.rotate_cons_succ List.rotate_cons_succ
@[simp]
theorem mem_rotate : ∀ {l : List α} {a : α} {n : ℕ}, a ∈ l.rotate n ↔ a ∈ l
| [], _, n => by simp
| a :: l, _, 0 => by simp
| a :: l, _, n + 1 => by simp [rotate_cons_succ, mem_rotate, or_comm]
#align list.mem_rotate List.mem_rotate
@[simp]
| Mathlib/Data/List/Rotate.lean | 132 | 133 | theorem length_rotate (l : List α) (n : ℕ) : (l.rotate n).length = l.length := by |
rw [rotate_eq_rotate', length_rotate']
|
/-
Copyright (c) 2020 Robert Y. Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Y. Lewis
-/
import Batteries.Tactic.Lint.Basic
import Mathlib.Algebra.Order.Monoid.Unbundled.Basic
import Mathlib.Algebra.Order.Ring.Defs
import Mathlib.Algebra.Order.ZeroLEOne
import Mathlib.Data.Nat.Cast.Order
import Mathlib.Init.Data.Int.Order
/-!
# Lemmas for `linarith`.
Those in the `Linarith` namespace should stay here.
Those outside the `Linarith` namespace may be deleted as they are ported to mathlib4.
-/
set_option autoImplicit true
namespace Linarith
theorem lt_irrefl {α : Type u} [Preorder α] {a : α} : ¬a < a := _root_.lt_irrefl a
theorem eq_of_eq_of_eq {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (hb : b = 0) : a + b = 0 := by
simp [*]
theorem le_of_eq_of_le {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (hb : b ≤ 0) : a + b ≤ 0 := by
simp [*]
theorem lt_of_eq_of_lt {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (hb : b < 0) : a + b < 0 := by
simp [*]
theorem le_of_le_of_eq {α} [OrderedSemiring α] {a b : α} (ha : a ≤ 0) (hb : b = 0) : a + b ≤ 0 := by
simp [*]
theorem lt_of_lt_of_eq {α} [OrderedSemiring α] {a b : α} (ha : a < 0) (hb : b = 0) : a + b < 0 := by
simp [*]
theorem mul_neg {α} [StrictOrderedRing α] {a b : α} (ha : a < 0) (hb : 0 < b) : b * a < 0 :=
have : (-b)*a > 0 := mul_pos_of_neg_of_neg (neg_neg_of_pos hb) ha
neg_of_neg_pos (by simpa)
theorem mul_nonpos {α} [OrderedRing α] {a b : α} (ha : a ≤ 0) (hb : 0 < b) : b * a ≤ 0 :=
have : (-b)*a ≥ 0 := mul_nonneg_of_nonpos_of_nonpos (le_of_lt (neg_neg_of_pos hb)) ha
by simpa
-- used alongside `mul_neg` and `mul_nonpos`, so has the same argument pattern for uniformity
@[nolint unusedArguments]
| Mathlib/Tactic/Linarith/Lemmas.lean | 52 | 53 | theorem mul_eq {α} [OrderedSemiring α] {a b : α} (ha : a = 0) (_ : 0 < b) : b * a = 0 := by |
simp [*]
|
/-
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]
theorem map_snoc : map f (xs.snoc x) = (map f xs).snoc (f x) := by
induction xs <;> simp_all
@[simp]
theorem mapAccumr_nil : mapAccumr f Vector.nil s = (s, Vector.nil) :=
rfl
@[simp]
theorem mapAccumr_snoc :
mapAccumr f (xs.snoc x) s
= let q := f x s
let r := mapAccumr f xs q.1
(r.1, r.2.snoc q.2) := by
induction xs
· rfl
· simp [*]
variable (ys : Vector β n)
@[simp]
| Mathlib/Data/Vector/Snoc.lean | 146 | 147 | theorem map₂_snoc : map₂ f (xs.snoc x) (ys.snoc y) = (map₂ f xs ys).snoc (f x y) := by |
induction xs, ys using Vector.inductionOn₂ <;> simp_all
|
/-
Copyright (c) 2023 Dagur Asgeirsson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Asgeirsson
-/
import Mathlib.CategoryTheory.Sites.InducedTopology
import Mathlib.CategoryTheory.Sites.LocallyBijective
import Mathlib.CategoryTheory.Sites.PreservesLocallyBijective
import Mathlib.CategoryTheory.Sites.Whiskering
/-!
# Equivalences of sheaf categories
Given a site `(C, J)` and a category `D` which is equivalent to `C`, with `C` and `D` possibly large
and possibly in different universes, we transport the Grothendieck topology `J` on `C` to `D` and
prove that the sheaf categories are equivalent.
We also prove that sheafification and the property `HasSheafCompose` transport nicely over this
equivalence, and apply it to essentially small sites. We also provide instances for existence of
sufficiently small limits in the sheaf category on the essentially small site.
## Main definitions
* `CategoryTheory.Equivalence.sheafCongr` is the equivalence of sheaf categories.
* `CategoryTheory.Equivalence.transportAndSheafify` is the functor which takes a presheaf on `C`,
transports it over the equivalence to `D`, sheafifies there and then transports back to `C`.
* `CategoryTheory.Equivalence.transportSheafificationAdjunction`: `transportAndSheafify` is
left adjoint to the functor taking a sheaf to its underlying presheaf.
* `CategoryTheory.smallSheafify` is the functor which takes a presheaf on an essentially small site
`(C, J)`, transports to a small model, sheafifies there and then transports back to `C`.
* `CategoryTheory.smallSheafificationAdjunction`: `smallSheafify` is left adjoint to the functor
taking a sheaf to its underlying presheaf.
-/
universe u
namespace CategoryTheory
open Functor Limits GrothendieckTopology
variable {C : Type*} [Category C] (J : GrothendieckTopology C)
variable {D : Type*} [Category D] (K : GrothendieckTopology D) (e : C ≌ D) (G : D ⥤ C)
variable (A : Type*) [Category A]
namespace Equivalence
theorem locallyCoverDense : LocallyCoverDense J e.inverse := by
intro X T
convert T.prop
ext Z f
constructor
· rintro ⟨_, _, g', hg, rfl⟩
exact T.val.downward_closed hg g'
· intro hf
refine ⟨e.functor.obj Z, (Adjunction.homEquiv e.toAdjunction _ _).symm f, e.unit.app Z, ?_, ?_⟩
· simp only [Adjunction.homEquiv_counit, Functor.id_obj, Equivalence.toAdjunction_counit,
Sieve.functorPullback_apply, Presieve.functorPullback_mem, Functor.map_comp,
Equivalence.inv_fun_map, Functor.comp_obj, Category.assoc, Equivalence.unit_inverse_comp,
Category.comp_id]
exact T.val.downward_closed hf _
· simp
| Mathlib/CategoryTheory/Sites/Equivalence.lean | 67 | 82 | theorem coverPreserving : CoverPreserving J (e.locallyCoverDense J).inducedTopology e.functor where
cover_preserve {U S} h := by |
change _ ∈ J.sieves (e.inverse.obj (e.functor.obj U))
convert J.pullback_stable (e.unitInv.app U) h
ext Z f
rw [← Sieve.functorPushforward_comp]
simp only [Sieve.functorPushforward_apply, Presieve.functorPushforward, exists_and_left, id_obj,
comp_obj, Sieve.pullback_apply]
constructor
· rintro ⟨W, g, hg, x, rfl⟩
rw [Category.assoc]
apply S.downward_closed
simpa using S.downward_closed hg _
· intro hf
exact ⟨_, e.unitInv.app Z ≫ f ≫ e.unitInv.app U, S.downward_closed hf _,
e.unit.app Z ≫ e.unit.app _, by simp⟩
|
/-
Copyright (c) 2019 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Patrick Massot, Casper Putz, Anne Baanen, Wen Yang
-/
import Mathlib.LinearAlgebra.Matrix.Transvection
import Mathlib.LinearAlgebra.Matrix.NonsingularInverse
import Mathlib.Tactic.FinCases
#align_import linear_algebra.matrix.block from "leanprover-community/mathlib"@"6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f"
/-!
# Block matrices and their determinant
This file defines a predicate `Matrix.BlockTriangular` saying a matrix
is block triangular, and proves the value of the determinant for various
matrices built out of blocks.
## Main definitions
* `Matrix.BlockTriangular` expresses that an `o` by `o` matrix is block triangular,
if the rows and columns are ordered according to some order `b : o → α`
## Main results
* `Matrix.det_of_blockTriangular`: the determinant of a block triangular matrix
is equal to the product of the determinants of all the blocks
* `Matrix.det_of_upperTriangular` and `Matrix.det_of_lowerTriangular`: the determinant of
a triangular matrix is the product of the entries along the diagonal
## Tags
matrix, diagonal, det, block triangular
-/
open Finset Function OrderDual
open Matrix
universe v
variable {α β m n o : Type*} {m' n' : α → Type*}
variable {R : Type v} [CommRing R] {M N : Matrix m m R} {b : m → α}
namespace Matrix
section LT
variable [LT α]
/-- Let `b` map rows and columns of a square matrix `M` to blocks indexed by `α`s. Then
`BlockTriangular M n b` says the matrix is block triangular. -/
def BlockTriangular (M : Matrix m m R) (b : m → α) : Prop :=
∀ ⦃i j⦄, b j < b i → M i j = 0
#align matrix.block_triangular Matrix.BlockTriangular
@[simp]
protected theorem BlockTriangular.submatrix {f : n → m} (h : M.BlockTriangular b) :
(M.submatrix f f).BlockTriangular (b ∘ f) := fun _ _ hij => h hij
#align matrix.block_triangular.submatrix Matrix.BlockTriangular.submatrix
| Mathlib/LinearAlgebra/Matrix/Block.lean | 63 | 69 | theorem blockTriangular_reindex_iff {b : n → α} {e : m ≃ n} :
(reindex e e M).BlockTriangular b ↔ M.BlockTriangular (b ∘ e) := by |
refine ⟨fun h => ?_, fun h => ?_⟩
· convert h.submatrix
simp only [reindex_apply, submatrix_submatrix, submatrix_id_id, Equiv.symm_comp_self]
· convert h.submatrix
simp only [comp.assoc b e e.symm, Equiv.self_comp_symm, comp_id]
|
/-
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.Init.Function
#align_import data.option.n_ary from "leanprover-community/mathlib"@"995b47e555f1b6297c7cf16855f1023e355219fb"
/-!
# Binary map of options
This file defines the binary map of `Option`. This is mostly useful to define pointwise operations
on intervals.
## Main declarations
* `Option.map₂`: Binary map of options.
## Notes
This file is very similar to the n-ary section of `Mathlib.Data.Set.Basic`, to
`Mathlib.Data.Finset.NAry` and to `Mathlib.Order.Filter.NAry`. Please keep them in sync.
(porting note - only some of these may exist right now!)
We do not define `Option.map₃` as its only purpose so far would be to prove properties of
`Option.map₂` and casing already fulfills this task.
-/
universe u
open Function
namespace Option
variable {α β γ δ : Type*} {f : α → β → γ} {a : Option α} {b : Option β} {c : Option γ}
/-- The image of a binary function `f : α → β → γ` as a function `Option α → Option β → Option γ`.
Mathematically this should be thought of as the image of the corresponding function `α × β → γ`. -/
def map₂ (f : α → β → γ) (a : Option α) (b : Option β) : Option γ :=
a.bind fun a => b.map <| f a
#align option.map₂ Option.map₂
/-- `Option.map₂` in terms of monadic operations. Note that this can't be taken as the definition
because of the lack of universe polymorphism. -/
theorem map₂_def {α β γ : Type u} (f : α → β → γ) (a : Option α) (b : Option β) :
map₂ f a b = f <$> a <*> b := by
cases a <;> rfl
#align option.map₂_def Option.map₂_def
-- Porting note (#10618): In Lean3, was `@[simp]` but now `simp` can prove it
theorem map₂_some_some (f : α → β → γ) (a : α) (b : β) : map₂ f (some a) (some b) = f a b := rfl
#align option.map₂_some_some Option.map₂_some_some
theorem map₂_coe_coe (f : α → β → γ) (a : α) (b : β) : map₂ f a b = f a b := rfl
#align option.map₂_coe_coe Option.map₂_coe_coe
@[simp]
theorem map₂_none_left (f : α → β → γ) (b : Option β) : map₂ f none b = none := rfl
#align option.map₂_none_left Option.map₂_none_left
@[simp]
theorem map₂_none_right (f : α → β → γ) (a : Option α) : map₂ f a none = none := by cases a <;> rfl
#align option.map₂_none_right Option.map₂_none_right
@[simp]
theorem map₂_coe_left (f : α → β → γ) (a : α) (b : Option β) : map₂ f a b = b.map fun b => f a b :=
rfl
#align option.map₂_coe_left Option.map₂_coe_left
-- Porting note: This proof was `rfl` in Lean3, but now is not.
@[simp]
theorem map₂_coe_right (f : α → β → γ) (a : Option α) (b : β) :
map₂ f a b = a.map fun a => f a b := by cases a <;> rfl
#align option.map₂_coe_right Option.map₂_coe_right
-- Porting note: Removed the `@[simp]` tag as membership of an `Option` is no-longer simp-normal.
theorem mem_map₂_iff {c : γ} : c ∈ map₂ f a b ↔ ∃ a' b', a' ∈ a ∧ b' ∈ b ∧ f a' b' = c := by
simp [map₂, bind_eq_some]
#align option.mem_map₂_iff Option.mem_map₂_iff
@[simp]
theorem map₂_eq_none_iff : map₂ f a b = none ↔ a = none ∨ b = none := by
cases a <;> cases b <;> simp
#align option.map₂_eq_none_iff Option.map₂_eq_none_iff
theorem map₂_swap (f : α → β → γ) (a : Option α) (b : Option β) :
map₂ f a b = map₂ (fun a b => f b a) b a := by cases a <;> cases b <;> rfl
#align option.map₂_swap Option.map₂_swap
theorem map_map₂ (f : α → β → γ) (g : γ → δ) :
(map₂ f a b).map g = map₂ (fun a b => g (f a b)) a b := by cases a <;> cases b <;> rfl
#align option.map_map₂ Option.map_map₂
| Mathlib/Data/Option/NAry.lean | 95 | 96 | theorem map₂_map_left (f : γ → β → δ) (g : α → γ) :
map₂ f (a.map g) b = map₂ (fun a b => f (g a) b) a b := by | cases a <;> rfl
|
/-
Copyright (c) 2021 Riccardo Brasca. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Riccardo Brasca
-/
import Mathlib.LinearAlgebra.Dimension.StrongRankCondition
import Mathlib.LinearAlgebra.FreeModule.Basic
import Mathlib.LinearAlgebra.FreeModule.Finite.Basic
#align_import linear_algebra.dimension from "leanprover-community/mathlib"@"47a5f8186becdbc826190ced4312f8199f9db6a5"
/-!
# Rank of free modules
## Main result
- `LinearEquiv.nonempty_equiv_iff_lift_rank_eq`:
Two free modules are isomorphic iff they have the same dimension.
- `FiniteDimensional.finBasis`:
An arbitrary basis of a finite free module indexed by `Fin n` given `finrank R M = n`.
-/
noncomputable section
universe u v v' w
open Cardinal Basis Submodule Function Set DirectSum FiniteDimensional
section Tower
variable (F : Type u) (K : Type v) (A : Type w)
variable [Ring F] [Ring K] [AddCommGroup A]
variable [Module F K] [Module K A] [Module F A] [IsScalarTower F K A]
variable [StrongRankCondition F] [StrongRankCondition K] [Module.Free F K] [Module.Free K A]
/-- Tower law: if `A` is a `K`-module and `K` is an extension of `F` then
$\operatorname{rank}_F(A) = \operatorname{rank}_F(K) * \operatorname{rank}_K(A)$.
The universe polymorphic version of `rank_mul_rank` below. -/
theorem lift_rank_mul_lift_rank :
Cardinal.lift.{w} (Module.rank F K) * Cardinal.lift.{v} (Module.rank K A) =
Cardinal.lift.{v} (Module.rank F A) := by
let b := Module.Free.chooseBasis F K
let c := Module.Free.chooseBasis K A
rw [← (Module.rank F K).lift_id, ← b.mk_eq_rank, ← (Module.rank K A).lift_id, ← c.mk_eq_rank,
← lift_umax.{w, v}, ← (b.smul c).mk_eq_rank, mk_prod, lift_mul, lift_lift, lift_lift, lift_lift,
lift_lift, lift_umax.{v, w}]
#align lift_rank_mul_lift_rank lift_rank_mul_lift_rank
/-- Tower law: if `A` is a `K`-module and `K` is an extension of `F` then
$\operatorname{rank}_F(A) = \operatorname{rank}_F(K) * \operatorname{rank}_K(A)$.
This is a simpler version of `lift_rank_mul_lift_rank` with `K` and `A` in the same universe. -/
theorem rank_mul_rank (A : Type v) [AddCommGroup A]
[Module K A] [Module F A] [IsScalarTower F K A] [Module.Free K A] :
Module.rank F K * Module.rank K A = Module.rank F A := by
convert lift_rank_mul_lift_rank F K A <;> rw [lift_id]
#align rank_mul_rank rank_mul_rank
/-- Tower law: if `A` is a `K`-module and `K` is an extension of `F` then
$\operatorname{rank}_F(A) = \operatorname{rank}_F(K) * \operatorname{rank}_K(A)$. -/
theorem FiniteDimensional.finrank_mul_finrank : finrank F K * finrank K A = finrank F A := by
simp_rw [finrank]
rw [← toNat_lift.{w} (Module.rank F K), ← toNat_lift.{v} (Module.rank K A), ← toNat_mul,
lift_rank_mul_lift_rank, toNat_lift]
#align finite_dimensional.finrank_mul_finrank FiniteDimensional.finrank_mul_finrank
#align finite_dimensional.finrank_mul_finrank' FiniteDimensional.finrank_mul_finrank
end Tower
variable {R : Type u} {M M₁ : Type v} {M' : Type v'}
variable [Ring R] [StrongRankCondition R]
variable [AddCommGroup M] [Module R M] [Module.Free R M]
variable [AddCommGroup M'] [Module R M'] [Module.Free R M']
variable [AddCommGroup M₁] [Module R M₁] [Module.Free R M₁]
namespace Module.Free
variable (R M)
/-- The rank of a free module `M` over `R` is the cardinality of `ChooseBasisIndex R M`. -/
theorem rank_eq_card_chooseBasisIndex : Module.rank R M = #(ChooseBasisIndex R M) :=
(chooseBasis R M).mk_eq_rank''.symm
#align module.free.rank_eq_card_choose_basis_index Module.Free.rank_eq_card_chooseBasisIndex
/-- The finrank of a free module `M` over `R` is the cardinality of `ChooseBasisIndex R M`. -/
theorem _root_.FiniteDimensional.finrank_eq_card_chooseBasisIndex [Module.Finite R M] :
finrank R M = Fintype.card (ChooseBasisIndex R M) := by
simp [finrank, rank_eq_card_chooseBasisIndex]
#align finite_dimensional.finrank_eq_card_choose_basis_index FiniteDimensional.finrank_eq_card_chooseBasisIndex
/-- The rank of a free module `M` over an infinite scalar ring `R` is the cardinality of `M`
whenever `#R < #M`. -/
lemma rank_eq_mk_of_infinite_lt [Infinite R] (h_lt : lift.{v} #R < lift.{u} #M) :
Module.rank R M = #M := by
have : Infinite M := infinite_iff.mpr <| lift_le.mp <| le_trans (by simp) h_lt.le
have h : lift #M = lift #(ChooseBasisIndex R M →₀ R) := lift_mk_eq'.mpr ⟨(chooseBasis R M).repr⟩
simp only [mk_finsupp_lift_of_infinite', lift_id', ← rank_eq_card_chooseBasisIndex, lift_max,
lift_lift] at h
refine lift_inj.mp ((max_eq_iff.mp h.symm).resolve_right <| not_and_of_not_left _ ?_).left
exact (lift_umax.{v, u}.symm ▸ h_lt).ne
end Module.Free
open Module.Free
open Cardinal
/-- Two vector spaces are isomorphic if they have the same dimension. -/
| Mathlib/LinearAlgebra/Dimension/Free.lean | 111 | 118 | theorem nonempty_linearEquiv_of_lift_rank_eq
(cnd : Cardinal.lift.{v'} (Module.rank R M) = Cardinal.lift.{v} (Module.rank R M')) :
Nonempty (M ≃ₗ[R] M') := by |
obtain ⟨⟨α, B⟩⟩ := Module.Free.exists_basis (R := R) (M := M)
obtain ⟨⟨β, B'⟩⟩ := Module.Free.exists_basis (R := R) (M := M')
have : Cardinal.lift.{v', v} #α = Cardinal.lift.{v, v'} #β := by
rw [B.mk_eq_rank'', cnd, B'.mk_eq_rank'']
exact (Cardinal.lift_mk_eq.{v, v', 0}.1 this).map (B.equiv B')
|
/-
Copyright (c) 2022 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Alex J. Best
-/
import Mathlib.LinearAlgebra.Pi
import Mathlib.LinearAlgebra.Quotient
#align_import linear_algebra.quotient_pi from "leanprover-community/mathlib"@"398f60f60b43ef42154bd2bdadf5133daf1577a4"
/-!
# Submodule quotients and direct sums
This file contains some results on the quotient of a module by a direct sum of submodules,
and the direct sum of quotients of modules by submodules.
# Main definitions
* `Submodule.piQuotientLift`: create a map out of the direct sum of quotients
* `Submodule.quotientPiLift`: create a map out of the quotient of a direct sum
* `Submodule.quotientPi`: the quotient of a direct sum is the direct sum of quotients.
-/
namespace Submodule
open LinearMap
variable {ι R : Type*} [CommRing R]
variable {Ms : ι → Type*} [∀ i, AddCommGroup (Ms i)] [∀ i, Module R (Ms i)]
variable {N : Type*} [AddCommGroup N] [Module R N]
variable {Ns : ι → Type*} [∀ i, AddCommGroup (Ns i)] [∀ i, Module R (Ns i)]
/-- Lift a family of maps to the direct sum of quotients. -/
def piQuotientLift [Fintype ι] [DecidableEq ι] (p : ∀ i, Submodule R (Ms i)) (q : Submodule R N)
(f : ∀ i, Ms i →ₗ[R] N) (hf : ∀ i, p i ≤ q.comap (f i)) : (∀ i, Ms i ⧸ p i) →ₗ[R] N ⧸ q :=
lsum R (fun i => Ms i ⧸ p i) R fun i => (p i).mapQ q (f i) (hf i)
#align submodule.pi_quotient_lift Submodule.piQuotientLift
@[simp]
| Mathlib/LinearAlgebra/QuotientPi.lean | 42 | 46 | theorem piQuotientLift_mk [Fintype ι] [DecidableEq ι] (p : ∀ i, Submodule R (Ms i))
(q : Submodule R N) (f : ∀ i, Ms i →ₗ[R] N) (hf : ∀ i, p i ≤ q.comap (f i)) (x : ∀ i, Ms i) :
(piQuotientLift p q f hf fun i => Quotient.mk (x i)) = Quotient.mk (lsum _ _ R f x) := by |
rw [piQuotientLift, lsum_apply, sum_apply, ← mkQ_apply, lsum_apply, sum_apply, _root_.map_sum]
simp only [coe_proj, mapQ_apply, mkQ_apply, comp_apply]
|
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura
-/
import Mathlib.Algebra.BigOperators.Group.Finset
#align_import data.nat.gcd.big_operators from "leanprover-community/mathlib"@"008205aa645b3f194c1da47025c5f110c8406eab"
/-! # Lemmas about coprimality with big products.
These lemmas are kept separate from `Data.Nat.GCD.Basic` in order to minimize imports.
-/
namespace Nat
variable {ι : Type*}
theorem coprime_list_prod_left_iff {l : List ℕ} {k : ℕ} :
Coprime l.prod k ↔ ∀ n ∈ l, Coprime n k := by
induction l <;> simp [Nat.coprime_mul_iff_left, *]
theorem coprime_list_prod_right_iff {k : ℕ} {l : List ℕ} :
Coprime k l.prod ↔ ∀ n ∈ l, Coprime k n := by
simp_rw [coprime_comm (n := k), coprime_list_prod_left_iff]
theorem coprime_multiset_prod_left_iff {m : Multiset ℕ} {k : ℕ} :
Coprime m.prod k ↔ ∀ n ∈ m, Coprime n k := by
induction m using Quotient.inductionOn; simpa using coprime_list_prod_left_iff
theorem coprime_multiset_prod_right_iff {k : ℕ} {m : Multiset ℕ} :
Coprime k m.prod ↔ ∀ n ∈ m, Coprime k n := by
induction m using Quotient.inductionOn; simpa using coprime_list_prod_right_iff
theorem coprime_prod_left_iff {t : Finset ι} {s : ι → ℕ} {x : ℕ} :
Coprime (∏ i ∈ t, s i) x ↔ ∀ i ∈ t, Coprime (s i) x := by
simpa using coprime_multiset_prod_left_iff (m := t.val.map s)
theorem coprime_prod_right_iff {x : ℕ} {t : Finset ι} {s : ι → ℕ} :
Coprime x (∏ i ∈ t, s i) ↔ ∀ i ∈ t, Coprime x (s i) := by
simpa using coprime_multiset_prod_right_iff (m := t.val.map s)
/-- See `IsCoprime.prod_left` for the corresponding lemma about `IsCoprime` -/
alias ⟨_, Coprime.prod_left⟩ := coprime_prod_left_iff
#align nat.coprime_prod_left Nat.Coprime.prod_left
/-- See `IsCoprime.prod_right` for the corresponding lemma about `IsCoprime` -/
alias ⟨_, Coprime.prod_right⟩ := coprime_prod_right_iff
#align nat.coprime_prod_right Nat.Coprime.prod_right
| Mathlib/Data/Nat/GCD/BigOperators.lean | 52 | 54 | theorem coprime_fintype_prod_left_iff [Fintype ι] {s : ι → ℕ} {x : ℕ} :
Coprime (∏ i, s i) x ↔ ∀ i, Coprime (s i) x := by |
simp [coprime_prod_left_iff]
|
/-
Copyright (c) 2023 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Patrick Massot
-/
import Mathlib.LinearAlgebra.Basis
import Mathlib.LinearAlgebra.Dual
import Mathlib.Data.Fin.FlagRange
/-!
# Flag of submodules defined by a basis
In this file we define `Basis.flag b k`, where `b : Basis (Fin n) R M`, `k : Fin (n + 1)`,
to be the subspace spanned by the first `k` vectors of the basis `b`.
We also prove some lemmas about this definition.
-/
open Set Submodule
namespace Basis
section Semiring
variable {R M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] {n : ℕ}
/-- The subspace spanned by the first `k` vectors of the basis `b`. -/
def flag (b : Basis (Fin n) R M) (k : Fin (n + 1)) : Submodule R M :=
.span R <| b '' {i | i.castSucc < k}
@[simp]
theorem flag_zero (b : Basis (Fin n) R M) : b.flag 0 = ⊥ := by simp [flag]
@[simp]
theorem flag_last (b : Basis (Fin n) R M) : b.flag (.last n) = ⊤ := by
simp [flag, Fin.castSucc_lt_last]
theorem flag_le_iff (b : Basis (Fin n) R M) {k p} :
b.flag k ≤ p ↔ ∀ i : Fin n, i.castSucc < k → b i ∈ p :=
span_le.trans forall_mem_image
theorem flag_succ (b : Basis (Fin n) R M) (k : Fin n) :
b.flag k.succ = (R ∙ b k) ⊔ b.flag k.castSucc := by
simp only [flag, Fin.castSucc_lt_castSucc_iff]
simp [Fin.castSucc_lt_iff_succ_le, le_iff_eq_or_lt, setOf_or, image_insert_eq, span_insert]
theorem self_mem_flag (b : Basis (Fin n) R M) {i : Fin n} {k : Fin (n + 1)} (h : i.castSucc < k) :
b i ∈ b.flag k :=
subset_span <| mem_image_of_mem _ h
@[simp]
theorem self_mem_flag_iff [Nontrivial R] (b : Basis (Fin n) R M) {i : Fin n} {k : Fin (n + 1)} :
b i ∈ b.flag k ↔ i.castSucc < k :=
b.self_mem_span_image
@[mono]
theorem flag_mono (b : Basis (Fin n) R M) : Monotone b.flag :=
Fin.monotone_iff_le_succ.2 fun k ↦ by rw [flag_succ]; exact le_sup_right
theorem isChain_range_flag (b : Basis (Fin n) R M) : IsChain (· ≤ ·) (range b.flag) :=
b.flag_mono.isChain_range
@[mono]
theorem flag_strictMono [Nontrivial R] (b : Basis (Fin n) R M) : StrictMono b.flag :=
Fin.strictMono_iff_lt_succ.2 fun _ ↦ by simp [flag_succ]
end Semiring
section CommRing
variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] {n : ℕ}
@[simp]
theorem flag_le_ker_coord_iff [Nontrivial R] (b : Basis (Fin n) R M) {k : Fin (n + 1)} {l : Fin n} :
b.flag k ≤ LinearMap.ker (b.coord l) ↔ k ≤ l.castSucc := by
simp [flag_le_iff, Finsupp.single_apply_eq_zero, imp_false, imp_not_comm]
| Mathlib/LinearAlgebra/Basis/Flag.lean | 78 | 81 | theorem flag_le_ker_coord (b : Basis (Fin n) R M) {k : Fin (n + 1)} {l : Fin n}
(h : k ≤ l.castSucc) : b.flag k ≤ LinearMap.ker (b.coord l) := by |
nontriviality R
exact b.flag_le_ker_coord_iff.2 h
|
/-
Copyright (c) 2020 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa, Alex Meiburg
-/
import Mathlib.Algebra.BigOperators.Fin
import Mathlib.Algebra.Polynomial.Degree.Lemmas
#align_import data.polynomial.erase_lead from "leanprover-community/mathlib"@"fa256f00ce018e7b40e1dc756e403c86680bf448"
/-!
# Erase the leading term of a univariate polynomial
## Definition
* `eraseLead f`: the polynomial `f - leading term of f`
`eraseLead` serves as reduction step in an induction, shaving off one monomial from a polynomial.
The definition is set up so that it does not mention subtraction in the definition,
and thus works for polynomials over semirings as well as rings.
-/
noncomputable section
open Polynomial
open Polynomial Finset
namespace Polynomial
variable {R : Type*} [Semiring R] {f : R[X]}
/-- `eraseLead f` for a polynomial `f` is the polynomial obtained by
subtracting from `f` the leading term of `f`. -/
def eraseLead (f : R[X]) : R[X] :=
Polynomial.erase f.natDegree f
#align polynomial.erase_lead Polynomial.eraseLead
section EraseLead
theorem eraseLead_support (f : R[X]) : f.eraseLead.support = f.support.erase f.natDegree := by
simp only [eraseLead, support_erase]
#align polynomial.erase_lead_support Polynomial.eraseLead_support
theorem eraseLead_coeff (i : ℕ) :
f.eraseLead.coeff i = if i = f.natDegree then 0 else f.coeff i := by
simp only [eraseLead, coeff_erase]
#align polynomial.erase_lead_coeff Polynomial.eraseLead_coeff
@[simp]
theorem eraseLead_coeff_natDegree : f.eraseLead.coeff f.natDegree = 0 := by simp [eraseLead_coeff]
#align polynomial.erase_lead_coeff_nat_degree Polynomial.eraseLead_coeff_natDegree
theorem eraseLead_coeff_of_ne (i : ℕ) (hi : i ≠ f.natDegree) : f.eraseLead.coeff i = f.coeff i := by
simp [eraseLead_coeff, hi]
#align polynomial.erase_lead_coeff_of_ne Polynomial.eraseLead_coeff_of_ne
@[simp]
theorem eraseLead_zero : eraseLead (0 : R[X]) = 0 := by simp only [eraseLead, erase_zero]
#align polynomial.erase_lead_zero Polynomial.eraseLead_zero
@[simp]
theorem eraseLead_add_monomial_natDegree_leadingCoeff (f : R[X]) :
f.eraseLead + monomial f.natDegree f.leadingCoeff = f :=
(add_comm _ _).trans (f.monomial_add_erase _)
#align polynomial.erase_lead_add_monomial_nat_degree_leading_coeff Polynomial.eraseLead_add_monomial_natDegree_leadingCoeff
@[simp]
theorem eraseLead_add_C_mul_X_pow (f : R[X]) :
f.eraseLead + C f.leadingCoeff * X ^ f.natDegree = f := by
rw [C_mul_X_pow_eq_monomial, eraseLead_add_monomial_natDegree_leadingCoeff]
set_option linter.uppercaseLean3 false in
#align polynomial.erase_lead_add_C_mul_X_pow Polynomial.eraseLead_add_C_mul_X_pow
@[simp]
theorem self_sub_monomial_natDegree_leadingCoeff {R : Type*} [Ring R] (f : R[X]) :
f - monomial f.natDegree f.leadingCoeff = f.eraseLead :=
(eq_sub_iff_add_eq.mpr (eraseLead_add_monomial_natDegree_leadingCoeff f)).symm
#align polynomial.self_sub_monomial_nat_degree_leading_coeff Polynomial.self_sub_monomial_natDegree_leadingCoeff
@[simp]
theorem self_sub_C_mul_X_pow {R : Type*} [Ring R] (f : R[X]) :
f - C f.leadingCoeff * X ^ f.natDegree = f.eraseLead := by
rw [C_mul_X_pow_eq_monomial, self_sub_monomial_natDegree_leadingCoeff]
set_option linter.uppercaseLean3 false in
#align polynomial.self_sub_C_mul_X_pow Polynomial.self_sub_C_mul_X_pow
theorem eraseLead_ne_zero (f0 : 2 ≤ f.support.card) : eraseLead f ≠ 0 := by
rw [Ne, ← card_support_eq_zero, eraseLead_support]
exact
(zero_lt_one.trans_le <| (tsub_le_tsub_right f0 1).trans Finset.pred_card_le_card_erase).ne.symm
#align polynomial.erase_lead_ne_zero Polynomial.eraseLead_ne_zero
theorem lt_natDegree_of_mem_eraseLead_support {a : ℕ} (h : a ∈ (eraseLead f).support) :
a < f.natDegree := by
rw [eraseLead_support, mem_erase] at h
exact (le_natDegree_of_mem_supp a h.2).lt_of_ne h.1
#align polynomial.lt_nat_degree_of_mem_erase_lead_support Polynomial.lt_natDegree_of_mem_eraseLead_support
theorem ne_natDegree_of_mem_eraseLead_support {a : ℕ} (h : a ∈ (eraseLead f).support) :
a ≠ f.natDegree :=
(lt_natDegree_of_mem_eraseLead_support h).ne
#align polynomial.ne_nat_degree_of_mem_erase_lead_support Polynomial.ne_natDegree_of_mem_eraseLead_support
theorem natDegree_not_mem_eraseLead_support : f.natDegree ∉ (eraseLead f).support := fun h =>
ne_natDegree_of_mem_eraseLead_support h rfl
#align polynomial.nat_degree_not_mem_erase_lead_support Polynomial.natDegree_not_mem_eraseLead_support
theorem eraseLead_support_card_lt (h : f ≠ 0) : (eraseLead f).support.card < f.support.card := by
rw [eraseLead_support]
exact card_lt_card (erase_ssubset <| natDegree_mem_support_of_nonzero h)
#align polynomial.erase_lead_support_card_lt Polynomial.eraseLead_support_card_lt
theorem card_support_eraseLead_add_one (h : f ≠ 0) :
f.eraseLead.support.card + 1 = f.support.card := by
set c := f.support.card with hc
cases h₁ : c
case zero =>
by_contra
exact h (card_support_eq_zero.mp h₁)
case succ =>
rw [eraseLead_support, card_erase_of_mem (natDegree_mem_support_of_nonzero h), ← hc, h₁]
rfl
@[simp]
theorem card_support_eraseLead : f.eraseLead.support.card = f.support.card - 1 := by
by_cases hf : f = 0
· rw [hf, eraseLead_zero, support_zero, card_empty]
· rw [← card_support_eraseLead_add_one hf, add_tsub_cancel_right]
| Mathlib/Algebra/Polynomial/EraseLead.lean | 132 | 134 | theorem card_support_eraseLead' {c : ℕ} (fc : f.support.card = c + 1) :
f.eraseLead.support.card = c := by |
rw [card_support_eraseLead, fc, add_tsub_cancel_right]
|
/-
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.Topology.MetricSpace.Algebra
import Mathlib.Analysis.Normed.Field.Basic
#align_import analysis.normed.mul_action from "leanprover-community/mathlib"@"bc91ed7093bf098d253401e69df601fc33dde156"
/-!
# Lemmas for `BoundedSMul` over normed additive groups
Lemmas which hold only in `NormedSpace α β` are provided in another file.
Notably we prove that `NonUnitalSeminormedRing`s have bounded actions by left- and right-
multiplication. This allows downstream files to write general results about `BoundedSMul`, and then
deduce `const_mul` and `mul_const` results as an immediate corollary.
-/
variable {α β : Type*}
section SeminormedAddGroup
variable [SeminormedAddGroup α] [SeminormedAddGroup β] [SMulZeroClass α β]
variable [BoundedSMul α β]
theorem norm_smul_le (r : α) (x : β) : ‖r • x‖ ≤ ‖r‖ * ‖x‖ := by
simpa [smul_zero] using dist_smul_pair r 0 x
#align norm_smul_le norm_smul_le
theorem nnnorm_smul_le (r : α) (x : β) : ‖r • x‖₊ ≤ ‖r‖₊ * ‖x‖₊ :=
norm_smul_le _ _
#align nnnorm_smul_le nnnorm_smul_le
| Mathlib/Analysis/Normed/MulAction.lean | 37 | 38 | theorem dist_smul_le (s : α) (x y : β) : dist (s • x) (s • y) ≤ ‖s‖ * dist x y := by |
simpa only [dist_eq_norm, sub_zero] using dist_smul_pair s x y
|
/-
Copyright (c) 2020 Kevin Kappelmann. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kevin Kappelmann
-/
import Mathlib.Algebra.ContinuedFractions.Computation.Approximations
import Mathlib.Algebra.ContinuedFractions.Computation.CorrectnessTerminating
import Mathlib.Data.Rat.Floor
#align_import algebra.continued_fractions.computation.terminates_iff_rat from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
/-!
# Termination of Continued Fraction Computations (`GeneralizedContinuedFraction.of`)
## Summary
We show that the continued fraction for a value `v`, as defined in
`Mathlib.Algebra.ContinuedFractions.Basic`, terminates if and only if `v` corresponds to a
rational number, that is `↑v = q` for some `q : ℚ`.
## Main Theorems
- `GeneralizedContinuedFraction.coe_of_rat_eq` shows that
`GeneralizedContinuedFraction.of v = GeneralizedContinuedFraction.of q` for `v : α` given that
`↑v = q` and `q : ℚ`.
- `GeneralizedContinuedFraction.terminates_iff_rat` shows that
`GeneralizedContinuedFraction.of v` terminates if and only if `↑v = q` for some `q : ℚ`.
## Tags
rational, continued fraction, termination
-/
namespace GeneralizedContinuedFraction
open GeneralizedContinuedFraction (of)
variable {K : Type*} [LinearOrderedField K] [FloorRing K]
/-
We will have to constantly coerce along our structures in the following proofs using their provided
map functions.
-/
attribute [local simp] Pair.map IntFractPair.mapFr
section RatOfTerminates
/-!
### Terminating Continued Fractions Are Rational
We want to show that the computation of a continued fraction `GeneralizedContinuedFraction.of v`
terminates if and only if `v ∈ ℚ`. In this section, we show the implication from left to right.
We first show that every finite convergent corresponds to a rational number `q` and then use the
finite correctness proof (`of_correctness_of_terminates`) of `GeneralizedContinuedFraction.of` to
show that `v = ↑q`.
-/
variable (v : K) (n : ℕ)
nonrec theorem exists_gcf_pair_rat_eq_of_nth_conts_aux :
∃ conts : Pair ℚ, (of v).continuantsAux n = (conts.map (↑) : Pair K) :=
Nat.strong_induction_on n
(by
clear n
let g := of v
intro n IH
rcases n with (_ | _ | n)
-- n = 0
· suffices ∃ gp : Pair ℚ, Pair.mk (1 : K) 0 = gp.map (↑) by simpa [continuantsAux]
use Pair.mk 1 0
simp
-- n = 1
· suffices ∃ conts : Pair ℚ, Pair.mk g.h 1 = conts.map (↑) by simpa [continuantsAux]
use Pair.mk ⌊v⌋ 1
simp [g]
-- 2 ≤ n
· cases' IH (n + 1) <| lt_add_one (n + 1) with pred_conts pred_conts_eq
-- invoke the IH
cases' s_ppred_nth_eq : g.s.get? n with gp_n
-- option.none
· use pred_conts
have : g.continuantsAux (n + 2) = g.continuantsAux (n + 1) :=
continuantsAux_stable_of_terminated (n + 1).le_succ s_ppred_nth_eq
simp only [this, pred_conts_eq]
-- option.some
· -- invoke the IH a second time
cases' IH n <| lt_of_le_of_lt n.le_succ <| lt_add_one <| n + 1 with ppred_conts
ppred_conts_eq
obtain ⟨a_eq_one, z, b_eq_z⟩ : gp_n.a = 1 ∧ ∃ z : ℤ, gp_n.b = (z : K) :=
of_part_num_eq_one_and_exists_int_part_denom_eq s_ppred_nth_eq
-- finally, unfold the recurrence to obtain the required rational value.
simp only [a_eq_one, b_eq_z,
continuantsAux_recurrence s_ppred_nth_eq ppred_conts_eq pred_conts_eq]
use nextContinuants 1 (z : ℚ) ppred_conts pred_conts
cases ppred_conts; cases pred_conts
simp [nextContinuants, nextNumerator, nextDenominator])
#align generalized_continued_fraction.exists_gcf_pair_rat_eq_of_nth_conts_aux GeneralizedContinuedFraction.exists_gcf_pair_rat_eq_of_nth_conts_aux
theorem exists_gcf_pair_rat_eq_nth_conts :
∃ conts : Pair ℚ, (of v).continuants n = (conts.map (↑) : Pair K) := by
rw [nth_cont_eq_succ_nth_cont_aux]; exact exists_gcf_pair_rat_eq_of_nth_conts_aux v <| n + 1
#align generalized_continued_fraction.exists_gcf_pair_rat_eq_nth_conts GeneralizedContinuedFraction.exists_gcf_pair_rat_eq_nth_conts
| Mathlib/Algebra/ContinuedFractions/Computation/TerminatesIffRat.lean | 106 | 109 | theorem exists_rat_eq_nth_numerator : ∃ q : ℚ, (of v).numerators n = (q : K) := by |
rcases exists_gcf_pair_rat_eq_nth_conts v n with ⟨⟨a, _⟩, nth_cont_eq⟩
use a
simp [num_eq_conts_a, nth_cont_eq]
|
/-
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.Array.Lemmas
import Batteries.Tactic.Lint.Misc
namespace Batteries
/-- Union-find node type -/
structure UFNode where
/-- Parent of node -/
parent : Nat
/-- Rank of node -/
rank : Nat
namespace UnionFind
/-- Panic with return value -/
def panicWith (v : α) (msg : String) : α := @panic α ⟨v⟩ msg
@[simp] theorem panicWith_eq (v : α) (msg) : panicWith v msg = v := rfl
/-- Parent of a union-find node, defaults to self when the node is a root -/
def parentD (arr : Array UFNode) (i : Nat) : Nat :=
if h : i < arr.size then (arr.get ⟨i, h⟩).parent else i
/-- Rank of a union-find node, defaults to 0 when the node is a root -/
def rankD (arr : Array UFNode) (i : Nat) : Nat :=
if h : i < arr.size then (arr.get ⟨i, h⟩).rank else 0
theorem parentD_eq {arr : Array UFNode} {i} : parentD arr i.1 = (arr.get i).parent := dif_pos _
theorem parentD_eq' {arr : Array UFNode} {i} (h) :
parentD arr i = (arr.get ⟨i, h⟩).parent := dif_pos _
theorem rankD_eq {arr : Array UFNode} {i} : rankD arr i.1 = (arr.get i).rank := dif_pos _
theorem rankD_eq' {arr : Array UFNode} {i} (h) : rankD arr i = (arr.get ⟨i, h⟩).rank := dif_pos _
theorem parentD_of_not_lt : ¬i < arr.size → parentD arr i = i := (dif_neg ·)
theorem lt_of_parentD : parentD arr i ≠ i → i < arr.size :=
Decidable.not_imp_comm.1 parentD_of_not_lt
| .lake/packages/batteries/Batteries/Data/UnionFind/Basic.lean | 47 | 50 | theorem parentD_set {arr : Array UFNode} {x v i} :
parentD (arr.set x v) i = if x.1 = i then v.parent else parentD arr i := by |
rw [parentD]; simp [Array.get_eq_getElem, parentD]
split <;> [split <;> simp [Array.get_set, *]; split <;> [(subst i; cases ‹¬_› x.2); rfl]]
|
/-
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.Fintype.Card
import Mathlib.GroupTheory.Perm.Basic
import Mathlib.Tactic.Ring
#align_import data.fintype.perm from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# `Fintype` instances for `Equiv` and `Perm`
Main declarations:
* `permsOfFinset s`: The finset of permutations of the finset `s`.
-/
open Function
open Nat
universe u v
variable {α β γ : Type*}
open Finset Function List Equiv Equiv.Perm
variable [DecidableEq α] [DecidableEq β]
/-- Given a list, produce a list of all permutations of its elements. -/
def permsOfList : List α → List (Perm α)
| [] => [1]
| a :: l => permsOfList l ++ l.bind fun b => (permsOfList l).map fun f => Equiv.swap a b * f
#align perms_of_list permsOfList
theorem length_permsOfList : ∀ l : List α, length (permsOfList l) = l.length !
| [] => rfl
| a :: l => by
rw [length_cons, Nat.factorial_succ]
simp only [permsOfList, length_append, length_permsOfList, length_bind, comp,
length_map, map_const', sum_replicate, smul_eq_mul, succ_mul]
ring
#align length_perms_of_list length_permsOfList
| Mathlib/Data/Fintype/Perm.lean | 47 | 74 | theorem mem_permsOfList_of_mem {l : List α} {f : Perm α} (h : ∀ x, f x ≠ x → x ∈ l) :
f ∈ permsOfList l := by |
induction l generalizing f with
| nil =>
-- Porting note: applied `not_mem_nil` because it is no longer true definitionally.
simp only [not_mem_nil] at h
exact List.mem_singleton.2 (Equiv.ext fun x => Decidable.by_contradiction <| h x)
| cons a l IH =>
by_cases hfa : f a = a
· refine mem_append_left _ (IH fun x hx => mem_of_ne_of_mem ?_ (h x hx))
rintro rfl
exact hx hfa
have hfa' : f (f a) ≠ f a := mt (fun h => f.injective h) hfa
have : ∀ x : α, (Equiv.swap a (f a) * f) x ≠ x → x ∈ l := by
intro x hx
have hxa : x ≠ a := by
rintro rfl
apply hx
simp only [mul_apply, swap_apply_right]
refine List.mem_of_ne_of_mem hxa (h x fun h => ?_)
simp only [mul_apply, swap_apply_def, mul_apply, Ne, apply_eq_iff_eq] at hx
split_ifs at hx with h_1
exacts [hxa (h.symm.trans h_1), hx h]
suffices f ∈ permsOfList l ∨ ∃ b ∈ l, ∃ g ∈ permsOfList l, Equiv.swap a b * g = f by
simpa only [permsOfList, exists_prop, List.mem_map, mem_append, List.mem_bind]
refine or_iff_not_imp_left.2 fun _hfl => ⟨f a, ?_, Equiv.swap a (f a) * f, IH this, ?_⟩
· exact mem_of_ne_of_mem hfa (h _ hfa')
· rw [← mul_assoc, mul_def (swap a (f a)) (swap a (f a)), swap_swap, ← Perm.one_def, one_mul]
|
/-
Copyright (c) 2021 Martin Dvorak. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Martin Dvorak, Kyle Miller, Eric Wieser
-/
import Mathlib.Data.Matrix.Notation
import Mathlib.LinearAlgebra.BilinearMap
import Mathlib.LinearAlgebra.Matrix.Determinant.Basic
import Mathlib.Algebra.Lie.Basic
#align_import linear_algebra.cross_product from "leanprover-community/mathlib"@"91288e351d51b3f0748f0a38faa7613fb0ae2ada"
/-!
# Cross products
This module defines the cross product of vectors in $R^3$ for $R$ a commutative ring,
as a bilinear map.
## Main definitions
* `crossProduct` is the cross product of pairs of vectors in $R^3$.
## Main results
* `triple_product_eq_det`
* `cross_dot_cross`
* `jacobi_cross`
## Notation
The locale `Matrix` gives the following notation:
* `×₃` for the cross product
## Tags
crossproduct
-/
open Matrix
open Matrix
variable {R : Type*} [CommRing R]
/-- The cross product of two vectors in $R^3$ for $R$ a commutative ring. -/
def crossProduct : (Fin 3 → R) →ₗ[R] (Fin 3 → R) →ₗ[R] Fin 3 → R := by
apply LinearMap.mk₂ R fun a b : Fin 3 → R =>
![a 1 * b 2 - a 2 * b 1, a 2 * b 0 - a 0 * b 2, a 0 * b 1 - a 1 * b 0]
· intros
simp_rw [vec3_add, Pi.add_apply]
apply vec3_eq <;> ring
· intros
simp_rw [smul_vec3, Pi.smul_apply, smul_sub, smul_mul_assoc]
· intros
simp_rw [vec3_add, Pi.add_apply]
apply vec3_eq <;> ring
· intros
simp_rw [smul_vec3, Pi.smul_apply, smul_sub, mul_smul_comm]
#align cross_product crossProduct
scoped[Matrix] infixl:74 " ×₃ " => crossProduct
theorem cross_apply (a b : Fin 3 → R) :
a ×₃ b = ![a 1 * b 2 - a 2 * b 1, a 2 * b 0 - a 0 * b 2, a 0 * b 1 - a 1 * b 0] := rfl
#align cross_apply cross_apply
section ProductsProperties
#adaptation_note /-- nightly-2024-04-01
The simpNF linter now times out on this lemma,
likely due to https://github.com/leanprover/lean4/pull/3807 -/
@[simp, nolint simpNF]
theorem cross_anticomm (v w : Fin 3 → R) : -(v ×₃ w) = w ×₃ v := by
simp [cross_apply, mul_comm]
#align cross_anticomm cross_anticomm
alias neg_cross := cross_anticomm
#align neg_cross neg_cross
#adaptation_note /-- nightly-2024-04-01
The simpNF linter now times out on this lemma,
likely due to https://github.com/leanprover/lean4/pull/3807 -/
@[simp, nolint simpNF]
theorem cross_anticomm' (v w : Fin 3 → R) : v ×₃ w + w ×₃ v = 0 := by
rw [add_eq_zero_iff_eq_neg, cross_anticomm]
#align cross_anticomm' cross_anticomm'
#adaptation_note /-- nightly-2024-04-01
The simpNF linter now times out on this lemma,
likely due to https://github.com/leanprover/lean4/pull/3807 -/
@[simp, nolint simpNF]
theorem cross_self (v : Fin 3 → R) : v ×₃ v = 0 := by
simp [cross_apply, mul_comm]
#align cross_self cross_self
#adaptation_note /-- nightly-2024-04-01
The simpNF linter now times out on this lemma,
likely due to https://github.com/leanprover/lean4/pull/3807 -/
/-- The cross product of two vectors is perpendicular to the first vector. -/
@[simp 1100, nolint simpNF] -- Porting note: increase priority so that the LHS doesn't simplify
theorem dot_self_cross (v w : Fin 3 → R) : v ⬝ᵥ v ×₃ w = 0 := by
rw [cross_apply, vec3_dotProduct]
set_option tactic.skipAssignedInstances false in norm_num
ring
#align dot_self_cross dot_self_cross
#adaptation_note /-- nightly-2024-04-01
The simpNF linter now times out on this lemma,
likely due to https://github.com/leanprover/lean4/pull/3807 -/
/-- The cross product of two vectors is perpendicular to the second vector. -/
@[simp 1100, nolint simpNF] -- Porting note: increase priority so that the LHS doesn't simplify
theorem dot_cross_self (v w : Fin 3 → R) : w ⬝ᵥ v ×₃ w = 0 := by
rw [← cross_anticomm, Matrix.dotProduct_neg, dot_self_cross, neg_zero]
#align dot_cross_self dot_cross_self
/-- Cyclic permutations preserve the triple product. See also `triple_product_eq_det`. -/
theorem triple_product_permutation (u v w : Fin 3 → R) : u ⬝ᵥ v ×₃ w = v ⬝ᵥ w ×₃ u := by
simp_rw [cross_apply, vec3_dotProduct]
norm_num
ring
#align triple_product_permutation triple_product_permutation
/-- The triple product of `u`, `v`, and `w` is equal to the determinant of the matrix
with those vectors as its rows. -/
theorem triple_product_eq_det (u v w : Fin 3 → R) : u ⬝ᵥ v ×₃ w = Matrix.det ![u, v, w] := by
rw [vec3_dotProduct, cross_apply, det_fin_three]
norm_num
ring
#align triple_product_eq_det triple_product_eq_det
/-- The scalar quadruple product identity, related to the Binet-Cauchy identity. -/
theorem cross_dot_cross (u v w x : Fin 3 → R) :
u ×₃ v ⬝ᵥ w ×₃ x = u ⬝ᵥ w * v ⬝ᵥ x - u ⬝ᵥ x * v ⬝ᵥ w := by
simp_rw [cross_apply, vec3_dotProduct]
norm_num
ring
#align cross_dot_cross cross_dot_cross
end ProductsProperties
section LeibnizProperties
/-- The cross product satisfies the Leibniz lie property. -/
| Mathlib/LinearAlgebra/CrossProduct.lean | 146 | 148 | theorem leibniz_cross (u v w : Fin 3 → R) : u ×₃ (v ×₃ w) = u ×₃ v ×₃ w + v ×₃ (u ×₃ w) := by |
simp_rw [cross_apply, vec3_add]
apply vec3_eq <;> norm_num <;> ring
|
/-
Copyright (c) 2022 Moritz Doll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Doll
-/
import Mathlib.Analysis.LocallyConvex.Basic
#align_import analysis.locally_convex.balanced_core_hull from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
/-!
# Balanced Core and Balanced Hull
## Main definitions
* `balancedCore`: The largest balanced subset of a set `s`.
* `balancedHull`: The smallest balanced superset of a set `s`.
## Main statements
* `balancedCore_eq_iInter`: Characterization of the balanced core as an intersection over subsets.
* `nhds_basis_closed_balanced`: The closed balanced sets form a basis of the neighborhood filter.
## Implementation details
The balanced core and hull are implemented differently: for the core we take the obvious definition
of the union over all balanced sets that are contained in `s`, whereas for the hull, we take the
union over `r • s`, for `r` the scalars with `‖r‖ ≤ 1`. We show that `balancedHull` has the
defining properties of a hull in `Balanced.balancedHull_subset_of_subset` and `subset_balancedHull`.
For the core we need slightly stronger assumptions to obtain a characterization as an intersection,
this is `balancedCore_eq_iInter`.
## References
* [Bourbaki, *Topological Vector Spaces*][bourbaki1987]
## Tags
balanced
-/
open Set Pointwise Topology Filter
variable {𝕜 E ι : Type*}
section balancedHull
section SeminormedRing
variable [SeminormedRing 𝕜]
section SMul
variable (𝕜) [SMul 𝕜 E] {s t : Set E} {x : E}
/-- The largest balanced subset of `s`. -/
def balancedCore (s : Set E) :=
⋃₀ { t : Set E | Balanced 𝕜 t ∧ t ⊆ s }
#align balanced_core balancedCore
/-- Helper definition to prove `balanced_core_eq_iInter`-/
def balancedCoreAux (s : Set E) :=
⋂ (r : 𝕜) (_ : 1 ≤ ‖r‖), r • s
#align balanced_core_aux balancedCoreAux
/-- The smallest balanced superset of `s`. -/
def balancedHull (s : Set E) :=
⋃ (r : 𝕜) (_ : ‖r‖ ≤ 1), r • s
#align balanced_hull balancedHull
variable {𝕜}
theorem balancedCore_subset (s : Set E) : balancedCore 𝕜 s ⊆ s :=
sUnion_subset fun _ ht => ht.2
#align balanced_core_subset balancedCore_subset
theorem balancedCore_empty : balancedCore 𝕜 (∅ : Set E) = ∅ :=
eq_empty_of_subset_empty (balancedCore_subset _)
#align balanced_core_empty balancedCore_empty
| Mathlib/Analysis/LocallyConvex/BalancedCoreHull.lean | 81 | 82 | theorem mem_balancedCore_iff : x ∈ balancedCore 𝕜 s ↔ ∃ t, Balanced 𝕜 t ∧ t ⊆ s ∧ x ∈ t := by |
simp_rw [balancedCore, mem_sUnion, mem_setOf_eq, and_assoc]
|
/-
Copyright (c) 2023 Kyle Miller. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller
-/
import Mathlib.Data.List.Sym
/-! # Unordered tuples of elements of a multiset
Defines `Multiset.sym` and the specialized `Multiset.sym2` for computing multisets of all
unordered n-tuples from a given multiset. These are multiset versions of `Nat.multichoose`.
## Main declarations
* `Multiset.sym2`: `xs.sym2` is the multiset of all unordered pairs of elements from `xs`,
with multiplicity. The multiset's values are in `Sym2 α`.
## TODO
* Once `List.Perm.sym` is defined, define
```lean
protected def sym (n : Nat) (m : Multiset α) : Multiset (Sym α n) :=
m.liftOn (fun xs => xs.sym n) (List.perm.sym n)
```
and then use this to remove the `DecidableEq` assumption from `Finset.sym`.
* `theorem injective_sym2 : Function.Injective (Multiset.sym2 : Multiset α → _)`
* `theorem strictMono_sym2 : StrictMono (Multiset.sym2 : Multiset α → _)`
-/
namespace Multiset
variable {α : Type*}
section Sym2
/-- `m.sym2` is the multiset of all unordered pairs of elements from `m`, with multiplicity.
If `m` has no duplicates then neither does `m.sym2`. -/
protected def sym2 (m : Multiset α) : Multiset (Sym2 α) :=
m.liftOn (fun xs => xs.sym2) fun _ _ h => by rw [coe_eq_coe]; exact h.sym2
@[simp] theorem sym2_coe (xs : List α) : (xs : Multiset α).sym2 = xs.sym2 := rfl
@[simp]
theorem sym2_eq_zero_iff {m : Multiset α} : m.sym2 = 0 ↔ m = 0 :=
m.inductionOn fun xs => by simp
theorem mk_mem_sym2_iff {m : Multiset α} {a b : α} :
s(a, b) ∈ m.sym2 ↔ a ∈ m ∧ b ∈ m :=
m.inductionOn fun xs => by simp [List.mk_mem_sym2_iff]
theorem mem_sym2_iff {m : Multiset α} {z : Sym2 α} :
z ∈ m.sym2 ↔ ∀ y ∈ z, y ∈ m :=
m.inductionOn fun xs => by simp [List.mem_sym2_iff]
protected theorem Nodup.sym2 {m : Multiset α} (h : m.Nodup) : m.sym2.Nodup :=
m.inductionOn (fun _ h => List.Nodup.sym2 h) h
open scoped List in
@[simp, mono]
| Mathlib/Data/Multiset/Sym.lean | 63 | 66 | theorem sym2_mono {m m' : Multiset α} (h : m ≤ m') : m.sym2 ≤ m'.sym2 := by |
refine Quotient.inductionOn₂ m m' (fun xs ys h => ?_) h
suffices xs <+~ ys from this.sym2
simpa only [quot_mk_to_coe, coe_le, sym2_coe] using h
|
/-
Copyright (c) 2018 Violeta Hernández Palacios, Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Violeta Hernández Palacios, Mario Carneiro
-/
import Mathlib.SetTheory.Ordinal.Arithmetic
import Mathlib.SetTheory.Ordinal.Exponential
#align_import set_theory.ordinal.fixed_point from "leanprover-community/mathlib"@"0dd4319a17376eda5763cd0a7e0d35bbaaa50e83"
/-!
# Fixed points of normal functions
We prove various statements about the fixed points of normal ordinal functions. We state them in
three forms: as statements about type-indexed families of normal functions, as statements about
ordinal-indexed families of normal functions, and as statements about a single normal function. For
the most part, the first case encompasses the others.
Moreover, we prove some lemmas about the fixed points of specific normal functions.
## Main definitions and results
* `nfpFamily`, `nfpBFamily`, `nfp`: the next fixed point of a (family of) normal function(s).
* `fp_family_unbounded`, `fp_bfamily_unbounded`, `fp_unbounded`: the (common) fixed points of a
(family of) normal function(s) are unbounded in the ordinals.
* `deriv_add_eq_mul_omega_add`: a characterization of the derivative of addition.
* `deriv_mul_eq_opow_omega_mul`: a characterization of the derivative of multiplication.
-/
noncomputable section
universe u v
open Function Order
namespace Ordinal
/-! ### Fixed points of type-indexed families of ordinals -/
section
variable {ι : Type u} {f : ι → Ordinal.{max u v} → Ordinal.{max u v}}
/-- The next common fixed point, at least `a`, for a family of normal functions.
This is defined for any family of functions, as the supremum of all values reachable by applying
finitely many functions in the family to `a`.
`Ordinal.nfpFamily_fp` shows this is a fixed point, `Ordinal.le_nfpFamily` shows it's at
least `a`, and `Ordinal.nfpFamily_le_fp` shows this is the least ordinal with these properties. -/
def nfpFamily (f : ι → Ordinal → Ordinal) (a : Ordinal) : Ordinal :=
sup (List.foldr f a)
#align ordinal.nfp_family Ordinal.nfpFamily
theorem nfpFamily_eq_sup (f : ι → Ordinal.{max u v} → Ordinal.{max u v}) (a : Ordinal.{max u v}) :
nfpFamily.{u, v} f a = sup.{u, v} (List.foldr f a) :=
rfl
#align ordinal.nfp_family_eq_sup Ordinal.nfpFamily_eq_sup
theorem foldr_le_nfpFamily (f : ι → Ordinal → Ordinal)
(a l) : List.foldr f a l ≤ nfpFamily.{u, v} f a :=
le_sup.{u, v} _ _
#align ordinal.foldr_le_nfp_family Ordinal.foldr_le_nfpFamily
theorem le_nfpFamily (f : ι → Ordinal → Ordinal) (a) : a ≤ nfpFamily f a :=
le_sup _ []
#align ordinal.le_nfp_family Ordinal.le_nfpFamily
theorem lt_nfpFamily {a b} : a < nfpFamily.{u, v} f b ↔ ∃ l, a < List.foldr f b l :=
lt_sup.{u, v}
#align ordinal.lt_nfp_family Ordinal.lt_nfpFamily
theorem nfpFamily_le_iff {a b} : nfpFamily.{u, v} f a ≤ b ↔ ∀ l, List.foldr f a l ≤ b :=
sup_le_iff
#align ordinal.nfp_family_le_iff Ordinal.nfpFamily_le_iff
theorem nfpFamily_le {a b} : (∀ l, List.foldr f a l ≤ b) → nfpFamily.{u, v} f a ≤ b :=
sup_le.{u, v}
#align ordinal.nfp_family_le Ordinal.nfpFamily_le
theorem nfpFamily_monotone (hf : ∀ i, Monotone (f i)) : Monotone (nfpFamily.{u, v} f) :=
fun _ _ h => sup_le.{u, v} fun l => (List.foldr_monotone hf l h).trans (le_sup.{u, v} _ l)
#align ordinal.nfp_family_monotone Ordinal.nfpFamily_monotone
theorem apply_lt_nfpFamily (H : ∀ i, IsNormal (f i)) {a b} (hb : b < nfpFamily.{u, v} f a) (i) :
f i b < nfpFamily.{u, v} f a :=
let ⟨l, hl⟩ := lt_nfpFamily.1 hb
lt_sup.2 ⟨i::l, (H i).strictMono hl⟩
#align ordinal.apply_lt_nfp_family Ordinal.apply_lt_nfpFamily
theorem apply_lt_nfpFamily_iff [Nonempty ι] (H : ∀ i, IsNormal (f i)) {a b} :
(∀ i, f i b < nfpFamily.{u, v} f a) ↔ b < nfpFamily.{u, v} f a :=
⟨fun h =>
lt_nfpFamily.2 <|
let ⟨l, hl⟩ := lt_sup.1 <| h <| Classical.arbitrary ι
⟨l, ((H _).self_le b).trans_lt hl⟩,
apply_lt_nfpFamily H⟩
#align ordinal.apply_lt_nfp_family_iff Ordinal.apply_lt_nfpFamily_iff
| Mathlib/SetTheory/Ordinal/FixedPoint.lean | 102 | 106 | theorem nfpFamily_le_apply [Nonempty ι] (H : ∀ i, IsNormal (f i)) {a b} :
(∃ i, nfpFamily.{u, v} f a ≤ f i b) ↔ nfpFamily.{u, v} f a ≤ b := by |
rw [← not_iff_not]
push_neg
exact apply_lt_nfpFamily_iff H
|
/-
Copyright (c) 2022 Michael Blyth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Blyth
-/
import Mathlib.LinearAlgebra.Projectivization.Basic
#align_import linear_algebra.projective_space.independence from "leanprover-community/mathlib"@"1e82f5ec4645f6a92bb9e02fce51e44e3bc3e1fe"
/-!
# Independence in Projective Space
In this file we define independence and dependence of families of elements in projective space.
## Implementation Details
We use an inductive definition to define the independence of points in projective
space, where the only constructor assumes an independent family of vectors from the
ambient vector space. Similarly for the definition of dependence.
## Results
- A family of elements is dependent if and only if it is not independent.
- Two elements are dependent if and only if they are equal.
# Future Work
- Define collinearity in projective space.
- Prove the axioms of a projective geometry are satisfied by the dependence relation.
- Define projective linear subspaces.
-/
open scoped LinearAlgebra.Projectivization
variable {ι K V : Type*} [DivisionRing K] [AddCommGroup V] [Module K V] {f : ι → ℙ K V}
namespace Projectivization
/-- A linearly independent family of nonzero vectors gives an independent family of points
in projective space. -/
inductive Independent : (ι → ℙ K V) → Prop
| mk (f : ι → V) (hf : ∀ i : ι, f i ≠ 0) (hl : LinearIndependent K f) :
Independent fun i => mk K (f i) (hf i)
#align projectivization.independent Projectivization.Independent
/-- A family of points in a projective space is independent if and only if the representative
vectors determined by the family are linearly independent. -/
theorem independent_iff : Independent f ↔ LinearIndependent K (Projectivization.rep ∘ f) := by
refine ⟨?_, fun h => ?_⟩
· rintro ⟨ff, hff, hh⟩
choose a ha using fun i : ι => exists_smul_eq_mk_rep K (ff i) (hff i)
convert hh.units_smul a
ext i
exact (ha i).symm
· convert Independent.mk _ _ h
· simp only [mk_rep, Function.comp_apply]
· intro i
apply rep_nonzero
#align projectivization.independent_iff Projectivization.independent_iff
/-- A family of points in projective space is independent if and only if the family of
submodules which the points determine is independent in the lattice-theoretic sense. -/
theorem independent_iff_completeLattice_independent :
Independent f ↔ CompleteLattice.Independent fun i => (f i).submodule := by
refine ⟨?_, fun h => ?_⟩
· rintro ⟨f, hf, hi⟩
simp only [submodule_mk]
exact (CompleteLattice.independent_iff_linearIndependent_of_ne_zero (R := K) hf).mpr hi
· rw [independent_iff]
refine h.linearIndependent (Projectivization.submodule ∘ f) (fun i => ?_) fun i => ?_
· simpa only [Function.comp_apply, submodule_eq] using Submodule.mem_span_singleton_self _
· exact rep_nonzero (f i)
#align projectivization.independent_iff_complete_lattice_independent Projectivization.independent_iff_completeLattice_independent
/-- A linearly dependent family of nonzero vectors gives a dependent family of points
in projective space. -/
inductive Dependent : (ι → ℙ K V) → Prop
| mk (f : ι → V) (hf : ∀ i : ι, f i ≠ 0) (h : ¬LinearIndependent K f) :
Dependent fun i => mk K (f i) (hf i)
#align projectivization.dependent Projectivization.Dependent
/-- A family of points in a projective space is dependent if and only if their
representatives are linearly dependent. -/
theorem dependent_iff : Dependent f ↔ ¬LinearIndependent K (Projectivization.rep ∘ f) := by
refine ⟨?_, fun h => ?_⟩
· rintro ⟨ff, hff, hh1⟩
contrapose! hh1
choose a ha using fun i : ι => exists_smul_eq_mk_rep K (ff i) (hff i)
convert hh1.units_smul a⁻¹
ext i
simp only [← ha, inv_smul_smul, Pi.smul_apply', Pi.inv_apply, Function.comp_apply]
· convert Dependent.mk _ _ h
· simp only [mk_rep, Function.comp_apply]
· exact fun i => rep_nonzero (f i)
#align projectivization.dependent_iff Projectivization.dependent_iff
/-- Dependence is the negation of independence. -/
theorem dependent_iff_not_independent : Dependent f ↔ ¬Independent f := by
rw [dependent_iff, independent_iff]
#align projectivization.dependent_iff_not_independent Projectivization.dependent_iff_not_independent
/-- Independence is the negation of dependence. -/
| Mathlib/LinearAlgebra/Projectivization/Independence.lean | 103 | 104 | theorem independent_iff_not_dependent : Independent f ↔ ¬Dependent f := by |
rw [dependent_iff_not_independent, Classical.not_not]
|
/-
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.Analysis.RCLike.Lemmas
import Mathlib.MeasureTheory.Function.StronglyMeasurable.Inner
import Mathlib.MeasureTheory.Integral.SetIntegral
#align_import measure_theory.function.l2_space from "leanprover-community/mathlib"@"83a66c8775fa14ee5180c85cab98e970956401ad"
/-! # `L^2` space
If `E` is an inner product space over `𝕜` (`ℝ` or `ℂ`), then `Lp E 2 μ`
(defined in `Mathlib.MeasureTheory.Function.LpSpace`)
is also an inner product space, with inner product defined as `inner f g = ∫ a, ⟪f a, g a⟫ ∂μ`.
### Main results
* `mem_L1_inner` : for `f` and `g` in `Lp E 2 μ`, the pointwise inner product `fun x ↦ ⟪f x, g x⟫`
belongs to `Lp 𝕜 1 μ`.
* `integrable_inner` : for `f` and `g` in `Lp E 2 μ`, the pointwise inner product
`fun x ↦ ⟪f x, g x⟫` is integrable.
* `L2.innerProductSpace` : `Lp E 2 μ` is an inner product space.
-/
set_option linter.uppercaseLean3 false
noncomputable section
open TopologicalSpace MeasureTheory MeasureTheory.Lp Filter
open scoped NNReal ENNReal MeasureTheory
namespace MeasureTheory
section
variable {α F : Type*} {m : MeasurableSpace α} {μ : Measure α} [NormedAddCommGroup F]
theorem Memℒp.integrable_sq {f : α → ℝ} (h : Memℒp f 2 μ) : Integrable (fun x => f x ^ 2) μ := by
simpa [← memℒp_one_iff_integrable] using h.norm_rpow two_ne_zero ENNReal.two_ne_top
#align measure_theory.mem_ℒp.integrable_sq MeasureTheory.Memℒp.integrable_sq
theorem memℒp_two_iff_integrable_sq_norm {f : α → F} (hf : AEStronglyMeasurable f μ) :
Memℒp f 2 μ ↔ Integrable (fun x => ‖f x‖ ^ 2) μ := by
rw [← memℒp_one_iff_integrable]
convert (memℒp_norm_rpow_iff hf two_ne_zero ENNReal.two_ne_top).symm
· simp
· rw [div_eq_mul_inv, ENNReal.mul_inv_cancel two_ne_zero ENNReal.two_ne_top]
#align measure_theory.mem_ℒp_two_iff_integrable_sq_norm MeasureTheory.memℒp_two_iff_integrable_sq_norm
theorem memℒp_two_iff_integrable_sq {f : α → ℝ} (hf : AEStronglyMeasurable f μ) :
Memℒp f 2 μ ↔ Integrable (fun x => f x ^ 2) μ := by
convert memℒp_two_iff_integrable_sq_norm hf using 3
simp
#align measure_theory.mem_ℒp_two_iff_integrable_sq MeasureTheory.memℒp_two_iff_integrable_sq
end
section InnerProductSpace
variable {α : Type*} {m : MeasurableSpace α} {p : ℝ≥0∞} {μ : Measure α}
variable {E 𝕜 : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => @inner 𝕜 E _ x y
theorem Memℒp.const_inner (c : E) {f : α → E} (hf : Memℒp f p μ) : Memℒp (fun a => ⟪c, f a⟫) p μ :=
hf.of_le_mul (AEStronglyMeasurable.inner aestronglyMeasurable_const hf.1)
(eventually_of_forall fun _ => norm_inner_le_norm _ _)
#align measure_theory.mem_ℒp.const_inner MeasureTheory.Memℒp.const_inner
theorem Memℒp.inner_const {f : α → E} (hf : Memℒp f p μ) (c : E) : Memℒp (fun a => ⟪f a, c⟫) p μ :=
hf.of_le_mul (AEStronglyMeasurable.inner hf.1 aestronglyMeasurable_const)
(eventually_of_forall fun x => by rw [mul_comm]; exact norm_inner_le_norm _ _)
#align measure_theory.mem_ℒp.inner_const MeasureTheory.Memℒp.inner_const
variable {f : α → E}
| Mathlib/MeasureTheory/Function/L2Space.lean | 81 | 83 | theorem Integrable.const_inner (c : E) (hf : Integrable f μ) :
Integrable (fun x => ⟪c, f x⟫) μ := by |
rw [← memℒp_one_iff_integrable] at hf ⊢; exact hf.const_inner c
|
/-
Copyright (c) 2022 Michael Stoll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Stoll
-/
import Mathlib.Data.Int.Range
import Mathlib.Data.ZMod.Basic
import Mathlib.NumberTheory.MulChar.Basic
#align_import number_theory.legendre_symbol.zmod_char from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
/-!
# Quadratic characters on ℤ/nℤ
This file defines some quadratic characters on the rings ℤ/4ℤ and ℤ/8ℤ.
We set them up to be of type `MulChar (ZMod n) ℤ`, where `n` is `4` or `8`.
## Tags
quadratic character, zmod
-/
/-!
### Quadratic characters mod 4 and 8
We define the primitive quadratic characters `χ₄`on `ZMod 4`
and `χ₈`, `χ₈'` on `ZMod 8`.
-/
namespace ZMod
section QuadCharModP
/-- Define the nontrivial quadratic character on `ZMod 4`, `χ₄`.
It corresponds to the extension `ℚ(√-1)/ℚ`. -/
@[simps]
def χ₄ : MulChar (ZMod 4) ℤ where
toFun := (![0, 1, 0, -1] : ZMod 4 → ℤ)
map_one' := rfl
map_mul' := by decide
map_nonunit' := by decide
#align zmod.χ₄ ZMod.χ₄
/-- `χ₄` takes values in `{0, 1, -1}` -/
theorem isQuadratic_χ₄ : χ₄.IsQuadratic := by
intro a
-- Porting note (#11043): was `decide!`
fin_cases a
all_goals decide
#align zmod.is_quadratic_χ₄ ZMod.isQuadratic_χ₄
/-- The value of `χ₄ n`, for `n : ℕ`, depends only on `n % 4`. -/
theorem χ₄_nat_mod_four (n : ℕ) : χ₄ n = χ₄ (n % 4 : ℕ) := by rw [← ZMod.natCast_mod n 4]
#align zmod.χ₄_nat_mod_four ZMod.χ₄_nat_mod_four
/-- The value of `χ₄ n`, for `n : ℤ`, depends only on `n % 4`. -/
theorem χ₄_int_mod_four (n : ℤ) : χ₄ n = χ₄ (n % 4 : ℤ) := by
rw [← ZMod.intCast_mod n 4]
norm_cast
#align zmod.χ₄_int_mod_four ZMod.χ₄_int_mod_four
/-- An explicit description of `χ₄` on integers / naturals -/
theorem χ₄_int_eq_if_mod_four (n : ℤ) :
χ₄ n = if n % 2 = 0 then 0 else if n % 4 = 1 then 1 else -1 := by
have help : ∀ m : ℤ, 0 ≤ m → m < 4 → χ₄ m = if m % 2 = 0 then 0 else if m = 1 then 1 else -1 := by
decide
rw [← Int.emod_emod_of_dvd n (by decide : (2 : ℤ) ∣ 4), ← ZMod.intCast_mod n 4]
exact help (n % 4) (Int.emod_nonneg n (by norm_num)) (Int.emod_lt n (by norm_num))
#align zmod.χ₄_int_eq_if_mod_four ZMod.χ₄_int_eq_if_mod_four
theorem χ₄_nat_eq_if_mod_four (n : ℕ) :
χ₄ n = if n % 2 = 0 then 0 else if n % 4 = 1 then 1 else -1 :=
mod_cast χ₄_int_eq_if_mod_four n
#align zmod.χ₄_nat_eq_if_mod_four ZMod.χ₄_nat_eq_if_mod_four
/-- Alternative description of `χ₄ n` for odd `n : ℕ` in terms of powers of `-1` -/
| Mathlib/NumberTheory/LegendreSymbol/ZModChar.lean | 80 | 91 | theorem χ₄_eq_neg_one_pow {n : ℕ} (hn : n % 2 = 1) : χ₄ n = (-1) ^ (n / 2) := by |
rw [χ₄_nat_eq_if_mod_four]
simp only [hn, Nat.one_ne_zero, if_false]
conv_rhs => -- Porting note: was `nth_rw`
arg 2; rw [← Nat.div_add_mod n 4]
enter [1, 1, 1]; rw [(by norm_num : 4 = 2 * 2)]
rw [mul_assoc, add_comm, Nat.add_mul_div_left _ _ (by norm_num : 0 < 2), pow_add, pow_mul,
neg_one_sq, one_pow, mul_one]
have help : ∀ m : ℕ, m < 4 → m % 2 = 1 → ite (m = 1) (1 : ℤ) (-1) = (-1) ^ (m / 2) := by decide
exact
help (n % 4) (Nat.mod_lt n (by norm_num))
((Nat.mod_mod_of_dvd n (by decide : 2 ∣ 4)).trans hn)
|
/-
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. -/
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 _)
/-- On a finite product space, a product of integrable functions depending on each coordinate is
integrable. -/
theorem Integrable.fintype_prod {ι : Type*} [Fintype ι] {E : Type*}
{f : ι → E → 𝕜} [MeasureSpace E] [SigmaFinite (volume : Measure E)]
(hf : ∀ i, Integrable (f i)) :
Integrable (fun (x : ι → E) ↦ ∏ i, f i (x i)) :=
Integrable.fintype_prod_dep hf
/-- A version of **Fubini's theorem** in `n` variables, for a natural number `n`. -/
theorem integral_fin_nat_prod_eq_prod {n : ℕ} {E : Fin n → Type*}
[∀ i, MeasureSpace (E i)] [∀ i, SigmaFinite (volume : Measure (E i))]
(f : (i : Fin n) → E i → 𝕜) :
∫ x : (i : Fin n) → E i, ∏ i, f i (x i) = ∏ i, ∫ x, f i x := by
induction n with
| zero =>
simp only [Nat.zero_eq, volume_pi, Finset.univ_eq_empty, Finset.prod_empty, integral_const,
pi_empty_univ, ENNReal.one_toReal, smul_eq_mul, mul_one, pow_zero, one_smul]
| succ n n_ih =>
calc
_ = ∫ x : E 0 × ((i : Fin n) → E (Fin.succ i)),
f 0 x.1 * ∏ i : Fin n, f (Fin.succ i) (x.2 i) := by
rw [volume_pi, ← ((measurePreserving_piFinSuccAbove
(fun i => (volume : Measure (E i))) 0).symm).integral_comp']
simp_rw [MeasurableEquiv.piFinSuccAbove_symm_apply,
Fin.prod_univ_succ, Fin.insertNth_zero, Fin.cons_succ, volume_eq_prod, volume_pi,
Fin.zero_succAbove, cast_eq, Fin.cons_zero]
_ = (∫ x, f 0 x) * ∏ i : Fin n, ∫ (x : E (Fin.succ i)), f (Fin.succ i) x := by
rw [← n_ih, ← integral_prod_mul, volume_eq_prod]
_ = ∏ i, ∫ x, f i x := by rw [Fin.prod_univ_succ]
/-- A version of **Fubini's theorem** with the variables indexed by a general finite type. -/
| Mathlib/MeasureTheory/Integral/Pi.lean | 87 | 93 | theorem integral_fintype_prod_eq_prod (ι : Type*) [Fintype ι] {E : ι → Type*}
(f : (i : ι) → E i → 𝕜) [∀ i, MeasureSpace (E i)] [∀ i, SigmaFinite (volume : Measure (E i))] :
∫ x : (i : ι) → E i, ∏ i, f i (x i) = ∏ i, ∫ x, f i x := by |
let e := (equivFin ι).symm
rw [← (volume_measurePreserving_piCongrLeft _ e).integral_comp']
simp_rw [← e.prod_comp, MeasurableEquiv.coe_piCongrLeft, Equiv.piCongrLeft_apply_apply,
MeasureTheory.integral_fin_nat_prod_eq_prod]
|
/-
Copyright (c) 2022 Michael Stoll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Stoll
-/
import Mathlib.Algebra.CharP.Basic
import Mathlib.Data.Fintype.Units
import Mathlib.GroupTheory.OrderOfElement
#align_import number_theory.legendre_symbol.mul_character from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
/-!
# Multiplicative characters of finite rings and fields
Let `R` and `R'` be a commutative rings.
A *multiplicative character* of `R` with values in `R'` is a morphism of
monoids from the multiplicative monoid of `R` into that of `R'`
that sends non-units to zero.
We use the namespace `MulChar` for the definitions and results.
## Main results
We show that the multiplicative characters form a group (if `R'` is commutative);
see `MulChar.commGroup`. We also provide an equivalence with the
homomorphisms `Rˣ →* R'ˣ`; see `MulChar.equivToUnitHom`.
We define a multiplicative character to be *quadratic* if its values
are among `0`, `1` and `-1`, and we prove some properties of quadratic characters.
Finally, we show that the sum of all values of a nontrivial multiplicative
character vanishes; see `MulChar.IsNontrivial.sum_eq_zero`.
## Tags
multiplicative character
-/
/-!
### Definitions related to multiplicative characters
Even though the intended use is when domain and target of the characters
are commutative rings, we define them in the more general setting when
the domain is a commutative monoid and the target is a commutative monoid
with zero. (We need a zero in the target, since non-units are supposed
to map to zero.)
In this setting, there is an equivalence between multiplicative characters
`R → R'` and group homomorphisms `Rˣ → R'ˣ`, and the multiplicative characters
have a natural structure as a commutative group.
-/
section Defi
-- The domain of our multiplicative characters
variable (R : Type*) [CommMonoid R]
-- The target
variable (R' : Type*) [CommMonoidWithZero R']
/-- Define a structure for multiplicative characters.
A multiplicative character from a commutative monoid `R` to a commutative monoid with zero `R'`
is a homomorphism of (multiplicative) monoids that sends non-units to zero. -/
structure MulChar extends MonoidHom R R' where
map_nonunit' : ∀ a : R, ¬IsUnit a → toFun a = 0
#align mul_char MulChar
instance MulChar.instFunLike : FunLike (MulChar R R') R R' :=
⟨fun χ => χ.toFun,
fun χ₀ χ₁ h => by cases χ₀; cases χ₁; congr; apply MonoidHom.ext (fun _ => congr_fun h _)⟩
/-- This is the corresponding extension of `MonoidHomClass`. -/
class MulCharClass (F : Type*) (R R' : outParam Type*) [CommMonoid R]
[CommMonoidWithZero R'] [FunLike F R R'] extends MonoidHomClass F R R' : Prop where
map_nonunit : ∀ (χ : F) {a : R} (_ : ¬IsUnit a), χ a = 0
#align mul_char_class MulCharClass
initialize_simps_projections MulChar (toFun → apply, -toMonoidHom)
attribute [simp] MulCharClass.map_nonunit
end Defi
namespace MulChar
section Group
-- The domain of our multiplicative characters
variable {R : Type*} [CommMonoid R]
-- The target
variable {R' : Type*} [CommMonoidWithZero R']
variable (R R') in
/-- The trivial multiplicative character. It takes the value `0` on non-units and
the value `1` on units. -/
@[simps]
noncomputable def trivial : MulChar R R' where
toFun := by classical exact fun x => if IsUnit x then 1 else 0
map_nonunit' := by
intro a ha
simp only [ha, if_false]
map_one' := by simp only [isUnit_one, if_true]
map_mul' := by
intro x y
classical
simp only [IsUnit.mul_iff, boole_mul]
split_ifs <;> tauto
#align mul_char.trivial MulChar.trivial
@[simp]
theorem coe_mk (f : R →* R') (hf) : (MulChar.mk f hf : R → R') = f :=
rfl
#align mul_char.coe_mk MulChar.coe_mk
/-- Extensionality. See `ext` below for the version that will actually be used. -/
theorem ext' {χ χ' : MulChar R R'} (h : ∀ a, χ a = χ' a) : χ = χ' := by
cases χ
cases χ'
congr
exact MonoidHom.ext h
#align mul_char.ext' MulChar.ext'
instance : MulCharClass (MulChar R R') R R' where
map_mul χ := χ.map_mul'
map_one χ := χ.map_one'
map_nonunit χ := χ.map_nonunit' _
theorem map_nonunit (χ : MulChar R R') {a : R} (ha : ¬IsUnit a) : χ a = 0 :=
χ.map_nonunit' a ha
#align mul_char.map_nonunit MulChar.map_nonunit
/-- Extensionality. Since `MulChar`s always take the value zero on non-units, it is sufficient
to compare the values on units. -/
@[ext]
| Mathlib/NumberTheory/MulChar/Basic.lean | 138 | 143 | theorem ext {χ χ' : MulChar R R'} (h : ∀ a : Rˣ, χ a = χ' a) : χ = χ' := by |
apply ext'
intro a
by_cases ha : IsUnit a
· exact h ha.unit
· rw [map_nonunit χ ha, map_nonunit χ' ha]
|
/-
Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-/
import Mathlib.Algebra.Squarefree.Basic
import Mathlib.Data.Nat.Factorization.PrimePow
#align_import data.nat.squarefree from "leanprover-community/mathlib"@"3c1368cac4abd5a5cbe44317ba7e87379d51ed88"
/-!
# Lemmas about squarefreeness of natural numbers
A number is squarefree when it is not divisible by any squares except the squares of units.
## Main Results
- `Nat.squarefree_iff_nodup_factors`: A positive natural number `x` is squarefree iff
the list `factors x` has no duplicate factors.
## Tags
squarefree, multiplicity
-/
open Finset
namespace Nat
| Mathlib/Data/Nat/Squarefree.lean | 28 | 30 | theorem squarefree_iff_nodup_factors {n : ℕ} (h0 : n ≠ 0) : Squarefree n ↔ n.factors.Nodup := by |
rw [UniqueFactorizationMonoid.squarefree_iff_nodup_normalizedFactors h0, Nat.factors_eq]
simp
|
/-
Copyright (c) 2018 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon
-/
import Mathlib.Control.Functor
import Mathlib.Tactic.Common
#align_import control.bifunctor from "leanprover-community/mathlib"@"dc1525fb3ef6eb4348fb1749c302d8abc303d34a"
/-!
# Functors with two arguments
This file defines bifunctors.
A bifunctor is a function `F : Type* → Type* → Type*` along with a bimap which turns `F α β`into
`F α' β'` given two functions `α → α'` and `β → β'`. It further
* respects the identity: `bimap id id = id`
* composes in the obvious way: `(bimap f' g') ∘ (bimap f g) = bimap (f' ∘ f) (g' ∘ g)`
## Main declarations
* `Bifunctor`: A typeclass for the bare bimap of a bifunctor.
* `LawfulBifunctor`: A typeclass asserting this bimap respects the bifunctor laws.
-/
universe u₀ u₁ u₂ v₀ v₁ v₂
open Function
/-- Lawless bifunctor. This typeclass only holds the data for the bimap. -/
class Bifunctor (F : Type u₀ → Type u₁ → Type u₂) where
bimap : ∀ {α α' β β'}, (α → α') → (β → β') → F α β → F α' β'
#align bifunctor Bifunctor
export Bifunctor (bimap)
/-- Bifunctor. This typeclass asserts that a lawless `Bifunctor` is lawful. -/
class LawfulBifunctor (F : Type u₀ → Type u₁ → Type u₂) [Bifunctor F] : Prop where
id_bimap : ∀ {α β} (x : F α β), bimap id id x = x
bimap_bimap :
∀ {α₀ α₁ α₂ β₀ β₁ β₂} (f : α₀ → α₁) (f' : α₁ → α₂) (g : β₀ → β₁) (g' : β₁ → β₂) (x : F α₀ β₀),
bimap f' g' (bimap f g x) = bimap (f' ∘ f) (g' ∘ g) x
#align is_lawful_bifunctor LawfulBifunctor
export LawfulBifunctor (id_bimap bimap_bimap)
attribute [higher_order bimap_id_id] id_bimap
#align is_lawful_bifunctor.bimap_id_id LawfulBifunctor.bimap_id_id
attribute [higher_order bimap_comp_bimap] bimap_bimap
#align is_lawful_bifunctor.bimap_comp_bimap LawfulBifunctor.bimap_comp_bimap
export LawfulBifunctor (bimap_id_id bimap_comp_bimap)
variable {F : Type u₀ → Type u₁ → Type u₂} [Bifunctor F]
namespace Bifunctor
/-- Left map of a bifunctor. -/
abbrev fst {α α' β} (f : α → α') : F α β → F α' β :=
bimap f id
#align bifunctor.fst Bifunctor.fst
/-- Right map of a bifunctor. -/
abbrev snd {α β β'} (f : β → β') : F α β → F α β' :=
bimap id f
#align bifunctor.snd Bifunctor.snd
variable [LawfulBifunctor F]
@[higher_order fst_id]
theorem id_fst : ∀ {α β} (x : F α β), fst id x = x :=
@id_bimap _ _ _
#align bifunctor.id_fst Bifunctor.id_fst
#align bifunctor.fst_id Bifunctor.fst_id
@[higher_order snd_id]
theorem id_snd : ∀ {α β} (x : F α β), snd id x = x :=
@id_bimap _ _ _
#align bifunctor.id_snd Bifunctor.id_snd
#align bifunctor.snd_id Bifunctor.snd_id
@[higher_order fst_comp_fst]
theorem comp_fst {α₀ α₁ α₂ β} (f : α₀ → α₁) (f' : α₁ → α₂) (x : F α₀ β) :
fst f' (fst f x) = fst (f' ∘ f) x := by simp [fst, bimap_bimap]
#align bifunctor.comp_fst Bifunctor.comp_fst
#align bifunctor.fst_comp_fst Bifunctor.fst_comp_fst
@[higher_order fst_comp_snd]
| Mathlib/Control/Bifunctor.lean | 92 | 93 | theorem fst_snd {α₀ α₁ β₀ β₁} (f : α₀ → α₁) (f' : β₀ → β₁) (x : F α₀ β₀) :
fst f (snd f' x) = bimap f f' x := by | simp [fst, bimap_bimap]
|
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.Algebra.Group.Subgroup.MulOpposite
import Mathlib.Algebra.Group.Submonoid.Pointwise
import Mathlib.GroupTheory.GroupAction.ConjAct
#align_import group_theory.subgroup.pointwise from "leanprover-community/mathlib"@"e655e4ea5c6d02854696f97494997ba4c31be802"
/-! # Pointwise instances on `Subgroup` and `AddSubgroup`s
This file provides the actions
* `Subgroup.pointwiseMulAction`
* `AddSubgroup.pointwiseMulAction`
which matches the action of `Set.mulActionSet`.
These actions are available in the `Pointwise` locale.
## Implementation notes
The pointwise section of this file is almost identical to
the file `Mathlib.Algebra.Group.Submonoid.Pointwise`.
Where possible, try to keep them in sync.
-/
open Set
open Pointwise
variable {α G A S : Type*}
@[to_additive (attr := simp, norm_cast)]
theorem inv_coe_set [InvolutiveInv G] [SetLike S G] [InvMemClass S G] {H : S} : (H : Set G)⁻¹ = H :=
Set.ext fun _ => inv_mem_iff
#align inv_coe_set inv_coe_set
#align neg_coe_set neg_coe_set
@[to_additive (attr := simp)]
lemma smul_coe_set [Group G] [SetLike S G] [SubgroupClass S G] {s : S} {a : G} (ha : a ∈ s) :
a • (s : Set G) = s := by
ext; simp [Set.mem_smul_set_iff_inv_smul_mem, mul_mem_cancel_left, ha]
@[to_additive (attr := simp)]
lemma op_smul_coe_set [Group G] [SetLike S G] [SubgroupClass S G] {s : S} {a : G} (ha : a ∈ s) :
MulOpposite.op a • (s : Set G) = s := by
ext; simp [Set.mem_smul_set_iff_inv_smul_mem, mul_mem_cancel_right, ha]
@[to_additive (attr := simp, norm_cast)]
lemma coe_mul_coe [SetLike S G] [DivInvMonoid G] [SubgroupClass S G] (H : S) :
H * H = (H : Set G) := by aesop (add simp mem_mul)
@[to_additive (attr := simp, norm_cast)]
lemma coe_div_coe [SetLike S G] [DivisionMonoid G] [SubgroupClass S G] (H : S) :
H / H = (H : Set G) := by simp [div_eq_mul_inv]
variable [Group G] [AddGroup A] {s : Set G}
namespace Subgroup
@[to_additive (attr := simp)]
theorem inv_subset_closure (S : Set G) : S⁻¹ ⊆ closure S := fun s hs => by
rw [SetLike.mem_coe, ← Subgroup.inv_mem_iff]
exact subset_closure (mem_inv.mp hs)
#align subgroup.inv_subset_closure Subgroup.inv_subset_closure
#align add_subgroup.neg_subset_closure AddSubgroup.neg_subset_closure
@[to_additive]
| Mathlib/Algebra/Group/Subgroup/Pointwise.lean | 73 | 81 | theorem closure_toSubmonoid (S : Set G) :
(closure S).toSubmonoid = Submonoid.closure (S ∪ S⁻¹) := by |
refine le_antisymm (fun x hx => ?_) (Submonoid.closure_le.2 ?_)
· refine
closure_induction hx
(fun x hx => Submonoid.closure_mono subset_union_left (Submonoid.subset_closure hx))
(Submonoid.one_mem _) (fun x y hx hy => Submonoid.mul_mem _ hx hy) fun x hx => ?_
rwa [← Submonoid.mem_closure_inv, Set.union_inv, inv_inv, Set.union_comm]
· simp only [true_and_iff, coe_toSubmonoid, union_subset_iff, subset_closure, inv_subset_closure]
|
/-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Joey van Langen, Casper Putz
-/
import Mathlib.Algebra.CharP.Defs
import Mathlib.Data.Nat.Multiplicity
import Mathlib.Data.Nat.Choose.Sum
#align_import algebra.char_p.basic from "leanprover-community/mathlib"@"47a1a73351de8dd6c8d3d32b569c8e434b03ca47"
/-!
# Characteristic of semirings
-/
assert_not_exists orderOf
universe u v
open Finset
variable {R : Type*}
namespace Commute
variable [Semiring R] {p : ℕ} {x y : R}
protected theorem add_pow_prime_pow_eq (hp : p.Prime) (h : Commute x y) (n : ℕ) :
(x + y) ^ p ^ n =
x ^ p ^ n + y ^ p ^ n +
p * ∑ k ∈ Ioo 0 (p ^ n), x ^ k * y ^ (p ^ n - k) * ↑((p ^ n).choose k / p) := by
trans x ^ p ^ n + y ^ p ^ n + ∑ k ∈ Ioo 0 (p ^ n), x ^ k * y ^ (p ^ n - k) * (p ^ n).choose k
· simp_rw [h.add_pow, ← Nat.Ico_zero_eq_range, Nat.Ico_succ_right, Icc_eq_cons_Ico (zero_le _),
Finset.sum_cons, Ico_eq_cons_Ioo (pow_pos hp.pos _), Finset.sum_cons, tsub_self, tsub_zero,
pow_zero, Nat.choose_zero_right, Nat.choose_self, Nat.cast_one, mul_one, one_mul, ← add_assoc]
· congr 1
simp_rw [Finset.mul_sum, Nat.cast_comm, mul_assoc _ _ (p : R), ← Nat.cast_mul]
refine Finset.sum_congr rfl fun i hi => ?_
rw [mem_Ioo] at hi
rw [Nat.div_mul_cancel (hp.dvd_choose_pow hi.1.ne' hi.2.ne)]
#align commute.add_pow_prime_pow_eq Commute.add_pow_prime_pow_eq
protected theorem add_pow_prime_eq (hp : p.Prime) (h : Commute x y) :
(x + y) ^ p =
x ^ p + y ^ p + p * ∑ k ∈ Finset.Ioo 0 p, x ^ k * y ^ (p - k) * ↑(p.choose k / p) := by
simpa using h.add_pow_prime_pow_eq hp 1
#align commute.add_pow_prime_eq Commute.add_pow_prime_eq
protected theorem exists_add_pow_prime_pow_eq (hp : p.Prime) (h : Commute x y) (n : ℕ) :
∃ r, (x + y) ^ p ^ n = x ^ p ^ n + y ^ p ^ n + p * r :=
⟨_, h.add_pow_prime_pow_eq hp n⟩
#align commute.exists_add_pow_prime_pow_eq Commute.exists_add_pow_prime_pow_eq
protected theorem exists_add_pow_prime_eq (hp : p.Prime) (h : Commute x y) :
∃ r, (x + y) ^ p = x ^ p + y ^ p + p * r :=
⟨_, h.add_pow_prime_eq hp⟩
#align commute.exists_add_pow_prime_eq Commute.exists_add_pow_prime_eq
end Commute
section CommSemiring
variable [CommSemiring R] {p : ℕ} {x y : R}
theorem add_pow_prime_pow_eq (hp : p.Prime) (x y : R) (n : ℕ) :
(x + y) ^ p ^ n =
x ^ p ^ n + y ^ p ^ n +
p * ∑ k ∈ Finset.Ioo 0 (p ^ n), x ^ k * y ^ (p ^ n - k) * ↑((p ^ n).choose k / p) :=
(Commute.all x y).add_pow_prime_pow_eq hp n
#align add_pow_prime_pow_eq add_pow_prime_pow_eq
theorem add_pow_prime_eq (hp : p.Prime) (x y : R) :
(x + y) ^ p =
x ^ p + y ^ p + p * ∑ k ∈ Finset.Ioo 0 p, x ^ k * y ^ (p - k) * ↑(p.choose k / p) :=
(Commute.all x y).add_pow_prime_eq hp
#align add_pow_prime_eq add_pow_prime_eq
theorem exists_add_pow_prime_pow_eq (hp : p.Prime) (x y : R) (n : ℕ) :
∃ r, (x + y) ^ p ^ n = x ^ p ^ n + y ^ p ^ n + p * r :=
(Commute.all x y).exists_add_pow_prime_pow_eq hp n
#align exists_add_pow_prime_pow_eq exists_add_pow_prime_pow_eq
theorem exists_add_pow_prime_eq (hp : p.Prime) (x y : R) :
∃ r, (x + y) ^ p = x ^ p + y ^ p + p * r :=
(Commute.all x y).exists_add_pow_prime_eq hp
#align exists_add_pow_prime_eq exists_add_pow_prime_eq
end CommSemiring
variable (R)
| Mathlib/Algebra/CharP/Basic.lean | 92 | 95 | theorem add_pow_char_of_commute [Semiring R] {p : ℕ} [hp : Fact p.Prime] [CharP R p] (x y : R)
(h : Commute x y) : (x + y) ^ p = x ^ p + y ^ p := by |
let ⟨r, hr⟩ := h.exists_add_pow_prime_eq hp.out
simp [hr]
|
/-
Copyright (c) 2023 Shogo Saito. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Shogo Saito. Adapted for mathlib by Hunter Monroe
-/
import Mathlib.Algebra.BigOperators.Ring.List
import Mathlib.Data.Nat.ModEq
import Mathlib.Data.Nat.GCD.BigOperators
/-!
# Chinese Remainder Theorem
This file provides definitions and theorems for the Chinese Remainder Theorem. These are used in
Gödel's Beta function, which is used in proving Gödel's incompleteness theorems.
## Main result
- `chineseRemainderOfList`: Definition of the Chinese remainder of a list
## Tags
Chinese Remainder Theorem, Gödel, beta function
-/
namespace Nat
variable {ι : Type*}
lemma modEq_list_prod_iff {a b} {l : List ℕ} (co : l.Pairwise Coprime) :
a ≡ b [MOD l.prod] ↔ ∀ i, a ≡ b [MOD l.get i] := by
induction' l with m l ih
· simp [modEq_one]
· have : Coprime m l.prod := coprime_list_prod_right_iff.mpr (List.pairwise_cons.mp co).1
simp only [List.prod_cons, ← modEq_and_modEq_iff_modEq_mul this, ih (List.Pairwise.of_cons co),
List.length_cons]
constructor
· rintro ⟨h0, hs⟩ i
cases i using Fin.cases <;> simp [h0, hs]
· intro h; exact ⟨h 0, fun i => h i.succ⟩
lemma modEq_list_prod_iff' {a b} {s : ι → ℕ} {l : List ι} (co : l.Pairwise (Coprime on s)) :
a ≡ b [MOD (l.map s).prod] ↔ ∀ i ∈ l, a ≡ b [MOD s i] := by
induction' l with i l ih
· simp [modEq_one]
· have : Coprime (s i) (l.map s).prod := by
simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂]
intro j hj
exact (List.pairwise_cons.mp co).1 j hj
simp [← modEq_and_modEq_iff_modEq_mul this, ih (List.Pairwise.of_cons co)]
variable (a s : ι → ℕ)
/-- The natural number less than `(l.map s).prod` congruent to
`a i` mod `s i` for all `i ∈ l`. -/
def chineseRemainderOfList : (l : List ι) → l.Pairwise (Coprime on s) →
{ k // ∀ i ∈ l, k ≡ a i [MOD s i] }
| [], _ => ⟨0, by simp⟩
| i :: l, co => by
have : Coprime (s i) (l.map s).prod := by
simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂]
intro j hj
exact (List.pairwise_cons.mp co).1 j hj
have ih := chineseRemainderOfList l co.of_cons
have k := chineseRemainder this (a i) ih
use k
simp only [List.mem_cons, forall_eq_or_imp, k.prop.1, true_and]
intro j hj
exact ((modEq_list_prod_iff' co.of_cons).mp k.prop.2 j hj).trans (ih.prop j hj)
@[simp] theorem chineseRemainderOfList_nil :
(chineseRemainderOfList a s [] List.Pairwise.nil : ℕ) = 0 := rfl
| Mathlib/Data/Nat/ChineseRemainder.lean | 75 | 91 | theorem chineseRemainderOfList_lt_prod (l : List ι)
(co : l.Pairwise (Coprime on s)) (hs : ∀ i ∈ l, s i ≠ 0) :
chineseRemainderOfList a s l co < (l.map s).prod := by |
cases l with
| nil => simp
| cons i l =>
simp only [chineseRemainderOfList, List.map_cons, List.prod_cons]
have : Coprime (s i) (l.map s).prod := by
simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂]
intro j hj
exact (List.pairwise_cons.mp co).1 j hj
refine chineseRemainder_lt_mul this (a i) (chineseRemainderOfList a s l co.of_cons)
(hs i (List.mem_cons_self _ l)) ?_
simp only [ne_eq, List.prod_eq_zero_iff, List.mem_map, not_exists, not_and]
intro j hj
exact hs j (List.mem_cons_of_mem _ hj)
|
/-
Copyright (c) 2020 Yury Kudryashov, Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Anne Baanen
-/
import Mathlib.Algebra.BigOperators.Ring
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Fintype.Fin
import Mathlib.GroupTheory.GroupAction.Pi
import Mathlib.Logic.Equiv.Fin
#align_import algebra.big_operators.fin from "leanprover-community/mathlib"@"cc5dd6244981976cc9da7afc4eee5682b037a013"
/-!
# Big operators and `Fin`
Some results about products and sums over the type `Fin`.
The most important results are the induction formulas `Fin.prod_univ_castSucc`
and `Fin.prod_univ_succ`, and the formula `Fin.prod_const` for the product of a
constant function. These results have variants for sums instead of products.
## Main declarations
* `finFunctionFinEquiv`: An explicit equivalence between `Fin n → Fin m` and `Fin (m ^ n)`.
-/
open Finset
variable {α : Type*} {β : Type*}
namespace Finset
@[to_additive]
theorem prod_range [CommMonoid β] {n : ℕ} (f : ℕ → β) :
∏ i ∈ Finset.range n, f i = ∏ i : Fin n, f i :=
(Fin.prod_univ_eq_prod_range _ _).symm
#align finset.prod_range Finset.prod_range
#align finset.sum_range Finset.sum_range
end Finset
namespace Fin
@[to_additive]
theorem prod_ofFn [CommMonoid β] {n : ℕ} (f : Fin n → β) : (List.ofFn f).prod = ∏ i, f i := by
simp [prod_eq_multiset_prod]
#align fin.prod_of_fn Fin.prod_ofFn
#align fin.sum_of_fn Fin.sum_ofFn
@[to_additive]
theorem prod_univ_def [CommMonoid β] {n : ℕ} (f : Fin n → β) :
∏ i, f i = ((List.finRange n).map f).prod := by
rw [← List.ofFn_eq_map, prod_ofFn]
#align fin.prod_univ_def Fin.prod_univ_def
#align fin.sum_univ_def Fin.sum_univ_def
/-- A product of a function `f : Fin 0 → β` is `1` because `Fin 0` is empty -/
@[to_additive "A sum of a function `f : Fin 0 → β` is `0` because `Fin 0` is empty"]
theorem prod_univ_zero [CommMonoid β] (f : Fin 0 → β) : ∏ i, f i = 1 :=
rfl
#align fin.prod_univ_zero Fin.prod_univ_zero
#align fin.sum_univ_zero Fin.sum_univ_zero
/-- A product of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)`
is the product of `f x`, for some `x : Fin (n + 1)` times the remaining product -/
@[to_additive "A sum of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)` is the sum of
`f x`, for some `x : Fin (n + 1)` plus the remaining product"]
theorem prod_univ_succAbove [CommMonoid β] {n : ℕ} (f : Fin (n + 1) → β) (x : Fin (n + 1)) :
∏ i, f i = f x * ∏ i : Fin n, f (x.succAbove i) := by
rw [univ_succAbove, prod_cons, Finset.prod_map _ x.succAboveEmb]
rfl
#align fin.prod_univ_succ_above Fin.prod_univ_succAbove
#align fin.sum_univ_succ_above Fin.sum_univ_succAbove
/-- A product of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)`
is the product of `f 0` plus the remaining product -/
@[to_additive "A sum of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)` is the sum of
`f 0` plus the remaining product"]
theorem prod_univ_succ [CommMonoid β] {n : ℕ} (f : Fin (n + 1) → β) :
∏ i, f i = f 0 * ∏ i : Fin n, f i.succ :=
prod_univ_succAbove f 0
#align fin.prod_univ_succ Fin.prod_univ_succ
#align fin.sum_univ_succ Fin.sum_univ_succ
/-- A product of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)`
is the product of `f (Fin.last n)` plus the remaining product -/
@[to_additive "A sum of a function `f : Fin (n + 1) → β` over all `Fin (n + 1)` is the sum of
`f (Fin.last n)` plus the remaining sum"]
theorem prod_univ_castSucc [CommMonoid β] {n : ℕ} (f : Fin (n + 1) → β) :
∏ i, f i = (∏ i : Fin n, f (Fin.castSucc i)) * f (last n) := by
simpa [mul_comm] using prod_univ_succAbove f (last n)
#align fin.prod_univ_cast_succ Fin.prod_univ_castSucc
#align fin.sum_univ_cast_succ Fin.sum_univ_castSucc
@[to_additive (attr := simp)]
| Mathlib/Algebra/BigOperators/Fin.lean | 97 | 98 | theorem prod_univ_get [CommMonoid α] (l : List α) : ∏ i, l.get i = l.prod := by |
simp [Finset.prod_eq_multiset_prod]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
import Mathlib.Topology.Algebra.InfiniteSum.Group
import Mathlib.Topology.Algebra.Star
/-!
# Topological sums and functorial constructions
Lemmas on the interaction of `tprod`, `tsum`, `HasProd`, `HasSum` etc with products, Sigma and Pi
types, `MulOpposite`, etc.
-/
noncomputable section
open Filter Finset Function
open scoped Topology
variable {α β γ δ : Type*}
/-! ## Product, Sigma and Pi types -/
section ProdDomain
variable [CommMonoid α] [TopologicalSpace α]
@[to_additive]
theorem hasProd_pi_single [DecidableEq β] (b : β) (a : α) : HasProd (Pi.mulSingle b a) a := by
convert hasProd_ite_eq b a
simp [Pi.mulSingle_apply]
#align has_sum_pi_single hasSum_pi_single
@[to_additive (attr := simp)]
theorem tprod_pi_single [DecidableEq β] (b : β) (a : α) : ∏' b', Pi.mulSingle b a b' = a := by
rw [tprod_eq_mulSingle b]
· simp
· intro b' hb'; simp [hb']
#align tsum_pi_single tsum_pi_single
@[to_additive tsum_setProd_singleton_left]
lemma tprod_setProd_singleton_left (b : β) (t : Set γ) (f : β × γ → α) :
(∏' x : {b} ×ˢ t, f x) = ∏' c : t, f (b, c) := by
rw [tprod_congr_set_coe _ Set.singleton_prod, tprod_image _ (Prod.mk.inj_left b).injOn]
@[to_additive tsum_setProd_singleton_right]
lemma tprod_setProd_singleton_right (s : Set β) (c : γ) (f : β × γ → α) :
(∏' x : s ×ˢ {c}, f x) = ∏' b : s, f (b, c) := by
rw [tprod_congr_set_coe _ Set.prod_singleton, tprod_image _ (Prod.mk.inj_right c).injOn]
@[to_additive Summable.prod_symm]
theorem Multipliable.prod_symm {f : β × γ → α} (hf : Multipliable f) :
Multipliable fun p : γ × β ↦ f p.swap :=
(Equiv.prodComm γ β).multipliable_iff.2 hf
#align summable.prod_symm Summable.prod_symm
end ProdDomain
section ProdCodomain
variable [CommMonoid α] [TopologicalSpace α] [CommMonoid γ] [TopologicalSpace γ]
@[to_additive HasSum.prod_mk]
theorem HasProd.prod_mk {f : β → α} {g : β → γ} {a : α} {b : γ}
(hf : HasProd f a) (hg : HasProd g b) : HasProd (fun x ↦ (⟨f x, g x⟩ : α × γ)) ⟨a, b⟩ := by
simp [HasProd, ← prod_mk_prod, Filter.Tendsto.prod_mk_nhds hf hg]
#align has_sum.prod_mk HasSum.prod_mk
end ProdCodomain
section ContinuousMul
variable [CommMonoid α] [TopologicalSpace α] [ContinuousMul α]
section RegularSpace
variable [RegularSpace α]
@[to_additive]
| Mathlib/Topology/Algebra/InfiniteSum/Constructions.lean | 84 | 101 | theorem HasProd.sigma {γ : β → Type*} {f : (Σ b : β, γ b) → α} {g : β → α} {a : α}
(ha : HasProd f a) (hf : ∀ b, HasProd (fun c ↦ f ⟨b, c⟩) (g b)) : HasProd g a := by |
classical
refine (atTop_basis.tendsto_iff (closed_nhds_basis a)).mpr ?_
rintro s ⟨hs, hsc⟩
rcases mem_atTop_sets.mp (ha hs) with ⟨u, hu⟩
use u.image Sigma.fst, trivial
intro bs hbs
simp only [Set.mem_preimage, ge_iff_le, Finset.le_iff_subset] at hu
have : Tendsto (fun t : Finset (Σb, γ b) ↦ ∏ p ∈ t.filter fun p ↦ p.1 ∈ bs, f p) atTop
(𝓝 <| ∏ b ∈ bs, g b) := by
simp only [← sigma_preimage_mk, prod_sigma]
refine tendsto_finset_prod _ fun b _ ↦ ?_
change
Tendsto (fun t ↦ (fun t ↦ ∏ s ∈ t, f ⟨b, s⟩) (preimage t (Sigma.mk b) _)) atTop (𝓝 (g b))
exact (hf b).comp (tendsto_finset_preimage_atTop_atTop (sigma_mk_injective))
refine hsc.mem_of_tendsto this (eventually_atTop.2 ⟨u, fun t ht ↦ hu _ fun x hx ↦ ?_⟩)
exact mem_filter.2 ⟨ht hx, hbs <| mem_image_of_mem _ hx⟩
|
/-
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.Init.Function
#align_import data.option.n_ary from "leanprover-community/mathlib"@"995b47e555f1b6297c7cf16855f1023e355219fb"
/-!
# Binary map of options
This file defines the binary map of `Option`. This is mostly useful to define pointwise operations
on intervals.
## Main declarations
* `Option.map₂`: Binary map of options.
## Notes
This file is very similar to the n-ary section of `Mathlib.Data.Set.Basic`, to
`Mathlib.Data.Finset.NAry` and to `Mathlib.Order.Filter.NAry`. Please keep them in sync.
(porting note - only some of these may exist right now!)
We do not define `Option.map₃` as its only purpose so far would be to prove properties of
`Option.map₂` and casing already fulfills this task.
-/
universe u
open Function
namespace Option
variable {α β γ δ : Type*} {f : α → β → γ} {a : Option α} {b : Option β} {c : Option γ}
/-- The image of a binary function `f : α → β → γ` as a function `Option α → Option β → Option γ`.
Mathematically this should be thought of as the image of the corresponding function `α × β → γ`. -/
def map₂ (f : α → β → γ) (a : Option α) (b : Option β) : Option γ :=
a.bind fun a => b.map <| f a
#align option.map₂ Option.map₂
/-- `Option.map₂` in terms of monadic operations. Note that this can't be taken as the definition
because of the lack of universe polymorphism. -/
theorem map₂_def {α β γ : Type u} (f : α → β → γ) (a : Option α) (b : Option β) :
map₂ f a b = f <$> a <*> b := by
cases a <;> rfl
#align option.map₂_def Option.map₂_def
-- Porting note (#10618): In Lean3, was `@[simp]` but now `simp` can prove it
theorem map₂_some_some (f : α → β → γ) (a : α) (b : β) : map₂ f (some a) (some b) = f a b := rfl
#align option.map₂_some_some Option.map₂_some_some
theorem map₂_coe_coe (f : α → β → γ) (a : α) (b : β) : map₂ f a b = f a b := rfl
#align option.map₂_coe_coe Option.map₂_coe_coe
@[simp]
theorem map₂_none_left (f : α → β → γ) (b : Option β) : map₂ f none b = none := rfl
#align option.map₂_none_left Option.map₂_none_left
@[simp]
theorem map₂_none_right (f : α → β → γ) (a : Option α) : map₂ f a none = none := by cases a <;> rfl
#align option.map₂_none_right Option.map₂_none_right
@[simp]
theorem map₂_coe_left (f : α → β → γ) (a : α) (b : Option β) : map₂ f a b = b.map fun b => f a b :=
rfl
#align option.map₂_coe_left Option.map₂_coe_left
-- Porting note: This proof was `rfl` in Lean3, but now is not.
@[simp]
theorem map₂_coe_right (f : α → β → γ) (a : Option α) (b : β) :
map₂ f a b = a.map fun a => f a b := by cases a <;> rfl
#align option.map₂_coe_right Option.map₂_coe_right
-- Porting note: Removed the `@[simp]` tag as membership of an `Option` is no-longer simp-normal.
theorem mem_map₂_iff {c : γ} : c ∈ map₂ f a b ↔ ∃ a' b', a' ∈ a ∧ b' ∈ b ∧ f a' b' = c := by
simp [map₂, bind_eq_some]
#align option.mem_map₂_iff Option.mem_map₂_iff
@[simp]
theorem map₂_eq_none_iff : map₂ f a b = none ↔ a = none ∨ b = none := by
cases a <;> cases b <;> simp
#align option.map₂_eq_none_iff Option.map₂_eq_none_iff
theorem map₂_swap (f : α → β → γ) (a : Option α) (b : Option β) :
map₂ f a b = map₂ (fun a b => f b a) b a := by cases a <;> cases b <;> rfl
#align option.map₂_swap Option.map₂_swap
theorem map_map₂ (f : α → β → γ) (g : γ → δ) :
(map₂ f a b).map g = map₂ (fun a b => g (f a b)) a b := by cases a <;> cases b <;> rfl
#align option.map_map₂ Option.map_map₂
theorem map₂_map_left (f : γ → β → δ) (g : α → γ) :
map₂ f (a.map g) b = map₂ (fun a b => f (g a) b) a b := by cases a <;> rfl
#align option.map₂_map_left Option.map₂_map_left
| Mathlib/Data/Option/NAry.lean | 99 | 100 | theorem map₂_map_right (f : α → γ → δ) (g : β → γ) :
map₂ f a (b.map g) = map₂ (fun a b => f a (g b)) a b := by | cases b <;> rfl
|
/-
Copyright (c) 2023 Josha Dekker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Josha Dekker
-/
import Mathlib.MeasureTheory.Constructions.Prod.Basic
import Mathlib.MeasureTheory.Measure.MeasureSpace
/-!
# The multiplicative and additive convolution of measures
In this file we define and prove properties about the convolutions of two measures.
## Main definitions
* `MeasureTheory.Measure.mconv`: The multiplicative convolution of two measures: the map of `*`
under the product measure.
* `MeasureTheory.Measure.conv`: The additive convolution of two measures: the map of `+`
under the product measure.
-/
namespace MeasureTheory
namespace Measure
variable {M : Type*} [Monoid M] [MeasurableSpace M]
/-- Multiplicative convolution of measures. -/
@[to_additive conv "Additive convolution of measures."]
noncomputable def mconv (μ : Measure M) (ν : Measure M) :
Measure M := Measure.map (fun x : M × M ↦ x.1 * x.2) (μ.prod ν)
/-- Scoped notation for the multiplicative convolution of measures. -/
scoped[MeasureTheory] infix:80 " ∗ " => MeasureTheory.Measure.mconv
/-- Scoped notation for the additive convolution of measures. -/
scoped[MeasureTheory] infix:80 " ∗ " => MeasureTheory.Measure.conv
/-- Convolution of the dirac measure at 1 with a measure μ returns μ. -/
@[to_additive (attr := simp)]
theorem dirac_one_mconv [MeasurableMul₂ M] (μ : Measure M) [SFinite μ] :
(Measure.dirac 1) ∗ μ = μ := by
unfold mconv
rw [MeasureTheory.Measure.dirac_prod, map_map]
· simp only [Function.comp_def, one_mul, map_id']
all_goals { measurability }
/-- Convolution of a measure μ with the dirac measure at 1 returns μ. -/
@[to_additive (attr := simp)]
theorem mconv_dirac_one [MeasurableMul₂ M]
(μ : Measure M) [SFinite μ] : μ ∗ (Measure.dirac 1) = μ := by
unfold mconv
rw [MeasureTheory.Measure.prod_dirac, map_map]
· simp only [Function.comp_def, mul_one, map_id']
all_goals { measurability }
/-- Convolution of the zero measure with a measure μ returns the zero measure. -/
@[to_additive (attr := simp) conv_zero]
theorem mconv_zero (μ : Measure M) : (0 : Measure M) ∗ μ = (0 : Measure M) := by
unfold mconv
simp
/-- Convolution of a measure μ with the zero measure returns the zero measure. -/
@[to_additive (attr := simp) zero_conv]
theorem zero_mconv (μ : Measure M) : μ ∗ (0 : Measure M) = (0 : Measure M) := by
unfold mconv
simp
@[to_additive conv_add]
| Mathlib/MeasureTheory/Group/Convolution.lean | 70 | 74 | theorem mconv_add [MeasurableMul₂ M] (μ : Measure M) (ν : Measure M) (ρ : Measure M) [SFinite μ]
[SFinite ν] [SFinite ρ] : μ ∗ (ν + ρ) = μ ∗ ν + μ ∗ ρ := by |
unfold mconv
rw [prod_add, map_add]
measurability
|
/-
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Algebra.BigOperators.Group.List
import Mathlib.Algebra.Group.Prod
import Mathlib.Data.Multiset.Basic
#align_import algebra.big_operators.multiset.basic from "leanprover-community/mathlib"@"6c5f73fd6f6cc83122788a80a27cdd54663609f4"
/-!
# Sums and products over multisets
In this file we define products and sums indexed by multisets. This is later used to define products
and sums indexed by finite sets.
## Main declarations
* `Multiset.prod`: `s.prod f` is the product of `f i` over all `i ∈ s`. Not to be mistaken with
the cartesian product `Multiset.product`.
* `Multiset.sum`: `s.sum f` is the sum of `f i` over all `i ∈ s`.
-/
assert_not_exists MonoidWithZero
variable {F ι α β γ : Type*}
namespace Multiset
section CommMonoid
variable [CommMonoid α] [CommMonoid β] {s t : Multiset α} {a : α} {m : Multiset ι} {f g : ι → α}
/-- Product of a multiset given a commutative monoid structure on `α`.
`prod {a, b, c} = a * b * c` -/
@[to_additive
"Sum of a multiset given a commutative additive monoid structure on `α`.
`sum {a, b, c} = a + b + c`"]
def prod : Multiset α → α :=
foldr (· * ·) (fun x y z => by simp [mul_left_comm]) 1
#align multiset.prod Multiset.prod
#align multiset.sum Multiset.sum
@[to_additive]
theorem prod_eq_foldr (s : Multiset α) :
prod s = foldr (· * ·) (fun x y z => by simp [mul_left_comm]) 1 s :=
rfl
#align multiset.prod_eq_foldr Multiset.prod_eq_foldr
#align multiset.sum_eq_foldr Multiset.sum_eq_foldr
@[to_additive]
theorem prod_eq_foldl (s : Multiset α) :
prod s = foldl (· * ·) (fun x y z => by simp [mul_right_comm]) 1 s :=
(foldr_swap _ _ _ _).trans (by simp [mul_comm])
#align multiset.prod_eq_foldl Multiset.prod_eq_foldl
#align multiset.sum_eq_foldl Multiset.sum_eq_foldl
@[to_additive (attr := simp, norm_cast)]
theorem prod_coe (l : List α) : prod ↑l = l.prod :=
prod_eq_foldl _
#align multiset.coe_prod Multiset.prod_coe
#align multiset.coe_sum Multiset.sum_coe
@[to_additive (attr := simp)]
theorem prod_toList (s : Multiset α) : s.toList.prod = s.prod := by
conv_rhs => rw [← coe_toList s]
rw [prod_coe]
#align multiset.prod_to_list Multiset.prod_toList
#align multiset.sum_to_list Multiset.sum_toList
@[to_additive (attr := simp)]
theorem prod_zero : @prod α _ 0 = 1 :=
rfl
#align multiset.prod_zero Multiset.prod_zero
#align multiset.sum_zero Multiset.sum_zero
@[to_additive (attr := simp)]
theorem prod_cons (a : α) (s) : prod (a ::ₘ s) = a * prod s :=
foldr_cons _ _ _ _ _
#align multiset.prod_cons Multiset.prod_cons
#align multiset.sum_cons Multiset.sum_cons
@[to_additive (attr := simp)]
theorem prod_erase [DecidableEq α] (h : a ∈ s) : a * (s.erase a).prod = s.prod := by
rw [← s.coe_toList, coe_erase, prod_coe, prod_coe, List.prod_erase (mem_toList.2 h)]
#align multiset.prod_erase Multiset.prod_erase
#align multiset.sum_erase Multiset.sum_erase
@[to_additive (attr := simp)]
theorem prod_map_erase [DecidableEq ι] {a : ι} (h : a ∈ m) :
f a * ((m.erase a).map f).prod = (m.map f).prod := by
rw [← m.coe_toList, coe_erase, map_coe, map_coe, prod_coe, prod_coe,
List.prod_map_erase f (mem_toList.2 h)]
#align multiset.prod_map_erase Multiset.prod_map_erase
#align multiset.sum_map_erase Multiset.sum_map_erase
@[to_additive (attr := simp)]
theorem prod_singleton (a : α) : prod {a} = a := by
simp only [mul_one, prod_cons, ← cons_zero, eq_self_iff_true, prod_zero]
#align multiset.prod_singleton Multiset.prod_singleton
#align multiset.sum_singleton Multiset.sum_singleton
@[to_additive]
theorem prod_pair (a b : α) : ({a, b} : Multiset α).prod = a * b := by
rw [insert_eq_cons, prod_cons, prod_singleton]
#align multiset.prod_pair Multiset.prod_pair
#align multiset.sum_pair Multiset.sum_pair
@[to_additive (attr := simp)]
theorem prod_add (s t : Multiset α) : prod (s + t) = prod s * prod t :=
Quotient.inductionOn₂ s t fun l₁ l₂ => by simp
#align multiset.prod_add Multiset.prod_add
#align multiset.sum_add Multiset.sum_add
@[to_additive]
theorem prod_nsmul (m : Multiset α) : ∀ n : ℕ, (n • m).prod = m.prod ^ n
| 0 => by
rw [zero_nsmul, pow_zero]
rfl
| n + 1 => by rw [add_nsmul, one_nsmul, pow_add, pow_one, prod_add, prod_nsmul m n]
#align multiset.prod_nsmul Multiset.prod_nsmul
@[to_additive]
theorem prod_filter_mul_prod_filter_not (p) [DecidablePred p] :
(s.filter p).prod * (s.filter (fun a ↦ ¬ p a)).prod = s.prod := by
rw [← prod_add, filter_add_not]
@[to_additive (attr := simp)]
| Mathlib/Algebra/BigOperators/Group/Multiset.lean | 130 | 131 | theorem prod_replicate (n : ℕ) (a : α) : (replicate n a).prod = a ^ n := by |
simp [replicate, List.prod_replicate]
|
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser, Kevin Buzzard, Jujian Zhang
-/
import Mathlib.Algebra.Algebra.Operations
import Mathlib.Algebra.Algebra.Subalgebra.Basic
import Mathlib.Algebra.DirectSum.Algebra
#align_import algebra.direct_sum.internal from "leanprover-community/mathlib"@"9936c3dfc04e5876f4368aeb2e60f8d8358d095a"
/-!
# Internally graded rings and algebras
This module provides `DirectSum.GSemiring` and `DirectSum.GCommSemiring` instances for a collection
of subobjects `A` when a `SetLike.GradedMonoid` instance is available:
* `SetLike.gnonUnitalNonAssocSemiring`
* `SetLike.gsemiring`
* `SetLike.gcommSemiring`
With these instances in place, it provides the bundled canonical maps out of a direct sum of
subobjects into their carrier type:
* `DirectSum.coeRingHom` (a `RingHom` version of `DirectSum.coeAddMonoidHom`)
* `DirectSum.coeAlgHom` (an `AlgHom` version of `DirectSum.coeLinearMap`)
Strictly the definitions in this file are not sufficient to fully define an "internal" direct sum;
to represent this case, `(h : DirectSum.IsInternal A) [SetLike.GradedMonoid A]` is
needed. In the future there will likely be a data-carrying, constructive, typeclass version of
`DirectSum.IsInternal` for providing an explicit decomposition function.
When `CompleteLattice.Independent (Set.range A)` (a weaker condition than
`DirectSum.IsInternal A`), these provide a grading of `⨆ i, A i`, and the
mapping `⨁ i, A i →+ ⨆ i, A i` can be obtained as
`DirectSum.toAddMonoid (fun i ↦ AddSubmonoid.inclusion <| le_iSup A i)`.
## Tags
internally graded ring
-/
open DirectSum
variable {ι : Type*} {σ S R : Type*}
instance AddCommMonoid.ofSubmonoidOnSemiring [Semiring R] [SetLike σ R] [AddSubmonoidClass σ R]
(A : ι → σ) : ∀ i, AddCommMonoid (A i) := fun i => by infer_instance
#align add_comm_monoid.of_submonoid_on_semiring AddCommMonoid.ofSubmonoidOnSemiring
instance AddCommGroup.ofSubgroupOnRing [Ring R] [SetLike σ R] [AddSubgroupClass σ R] (A : ι → σ) :
∀ i, AddCommGroup (A i) := fun i => by infer_instance
#align add_comm_group.of_subgroup_on_ring AddCommGroup.ofSubgroupOnRing
| Mathlib/Algebra/DirectSum/Internal.lean | 56 | 59 | theorem SetLike.algebraMap_mem_graded [Zero ι] [CommSemiring S] [Semiring R] [Algebra S R]
(A : ι → Submodule S R) [SetLike.GradedOne A] (s : S) : algebraMap S R s ∈ A 0 := by |
rw [Algebra.algebraMap_eq_smul_one]
exact (A 0).smul_mem s <| SetLike.one_mem_graded _
|
/-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau
-/
import Mathlib.Algebra.Algebra.Operations
import Mathlib.Data.Fintype.Lattice
import Mathlib.RingTheory.Coprime.Lemmas
#align_import ring_theory.ideal.operations from "leanprover-community/mathlib"@"e7f0ddbf65bd7181a85edb74b64bdc35ba4bdc74"
/-!
# More operations on modules and ideals
-/
assert_not_exists Basis -- See `RingTheory.Ideal.Basis`
assert_not_exists Submodule.hasQuotient -- See `RingTheory.Ideal.QuotientOperations`
universe u v w x
open Pointwise
namespace Submodule
variable {R : Type u} {M : Type v} {M' F G : Type*}
section CommSemiring
variable [CommSemiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid M'] [Module R M']
open Pointwise
instance hasSMul' : SMul (Ideal R) (Submodule R M) :=
⟨Submodule.map₂ (LinearMap.lsmul R M)⟩
#align submodule.has_smul' Submodule.hasSMul'
/-- This duplicates the global `smul_eq_mul`, but doesn't have to unfold anywhere near as much to
apply. -/
protected theorem _root_.Ideal.smul_eq_mul (I J : Ideal R) : I • J = I * J :=
rfl
#align ideal.smul_eq_mul Ideal.smul_eq_mul
variable (R M) in
/-- `Module.annihilator R M` is the ideal of all elements `r : R` such that `r • M = 0`. -/
def _root_.Module.annihilator : Ideal R := LinearMap.ker (LinearMap.lsmul R M)
theorem _root_.Module.mem_annihilator {r} : r ∈ Module.annihilator R M ↔ ∀ m : M, r • m = 0 :=
⟨fun h ↦ (congr($h ·)), (LinearMap.ext ·)⟩
theorem _root_.LinearMap.annihilator_le_of_injective (f : M →ₗ[R] M') (hf : Function.Injective f) :
Module.annihilator R M' ≤ Module.annihilator R M := fun x h ↦ by
rw [Module.mem_annihilator] at h ⊢; exact fun m ↦ hf (by rw [map_smul, h, f.map_zero])
theorem _root_.LinearMap.annihilator_le_of_surjective (f : M →ₗ[R] M')
(hf : Function.Surjective f) : Module.annihilator R M ≤ Module.annihilator R M' := fun x h ↦ by
rw [Module.mem_annihilator] at h ⊢
intro m; obtain ⟨m, rfl⟩ := hf m
rw [← map_smul, h, f.map_zero]
theorem _root_.LinearEquiv.annihilator_eq (e : M ≃ₗ[R] M') :
Module.annihilator R M = Module.annihilator R M' :=
(e.annihilator_le_of_surjective e.surjective).antisymm (e.annihilator_le_of_injective e.injective)
/-- `N.annihilator` is the ideal of all elements `r : R` such that `r • N = 0`. -/
abbrev annihilator (N : Submodule R M) : Ideal R :=
Module.annihilator R N
#align submodule.annihilator Submodule.annihilator
theorem annihilator_top : (⊤ : Submodule R M).annihilator = Module.annihilator R M :=
topEquiv.annihilator_eq
variable {I J : Ideal R} {N P : Submodule R M}
theorem mem_annihilator {r} : r ∈ N.annihilator ↔ ∀ n ∈ N, r • n = (0 : M) := by
simp_rw [annihilator, Module.mem_annihilator, Subtype.forall, Subtype.ext_iff]; rfl
#align submodule.mem_annihilator Submodule.mem_annihilator
theorem mem_annihilator' {r} : r ∈ N.annihilator ↔ N ≤ comap (r • (LinearMap.id : M →ₗ[R] M)) ⊥ :=
mem_annihilator.trans ⟨fun H n hn => (mem_bot R).2 <| H n hn, fun H _ hn => (mem_bot R).1 <| H hn⟩
#align submodule.mem_annihilator' Submodule.mem_annihilator'
theorem mem_annihilator_span (s : Set M) (r : R) :
r ∈ (Submodule.span R s).annihilator ↔ ∀ n : s, r • (n : M) = 0 := by
rw [Submodule.mem_annihilator]
constructor
· intro h n
exact h _ (Submodule.subset_span n.prop)
· intro h n hn
refine Submodule.span_induction hn ?_ ?_ ?_ ?_
· intro x hx
exact h ⟨x, hx⟩
· exact smul_zero _
· intro x y hx hy
rw [smul_add, hx, hy, zero_add]
· intro a x hx
rw [smul_comm, hx, smul_zero]
#align submodule.mem_annihilator_span Submodule.mem_annihilator_span
| Mathlib/RingTheory/Ideal/Operations.lean | 99 | 100 | theorem mem_annihilator_span_singleton (g : M) (r : R) :
r ∈ (Submodule.span R ({g} : Set M)).annihilator ↔ r • g = 0 := by | simp [mem_annihilator_span]
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker, Johan Commelin
-/
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.BigOperators
import Mathlib.Algebra.Polynomial.Degree.Lemmas
import Mathlib.Algebra.Polynomial.Div
#align_import data.polynomial.ring_division from "leanprover-community/mathlib"@"8efcf8022aac8e01df8d302dcebdbc25d6a886c8"
/-!
# Theory of univariate polynomials
We prove basic results about univariate polynomials.
-/
noncomputable section
open Polynomial
open Finset
namespace Polynomial
universe u v w z
variable {R : Type u} {S : Type v} {T : Type w} {a b : R} {n : ℕ}
section CommRing
variable [CommRing R] {p q : R[X]}
section
variable [Semiring S]
theorem natDegree_pos_of_aeval_root [Algebra R S] {p : R[X]} (hp : p ≠ 0) {z : S}
(hz : aeval z p = 0) (inj : ∀ x : R, algebraMap R S x = 0 → x = 0) : 0 < p.natDegree :=
natDegree_pos_of_eval₂_root hp (algebraMap R S) hz inj
#align polynomial.nat_degree_pos_of_aeval_root Polynomial.natDegree_pos_of_aeval_root
theorem degree_pos_of_aeval_root [Algebra R S] {p : R[X]} (hp : p ≠ 0) {z : S} (hz : aeval z p = 0)
(inj : ∀ x : R, algebraMap R S x = 0 → x = 0) : 0 < p.degree :=
natDegree_pos_iff_degree_pos.mp (natDegree_pos_of_aeval_root hp hz inj)
#align polynomial.degree_pos_of_aeval_root Polynomial.degree_pos_of_aeval_root
| Mathlib/Algebra/Polynomial/RingDivision.lean | 50 | 55 | theorem modByMonic_eq_of_dvd_sub (hq : q.Monic) {p₁ p₂ : R[X]} (h : q ∣ p₁ - p₂) :
p₁ %ₘ q = p₂ %ₘ q := by |
nontriviality R
obtain ⟨f, sub_eq⟩ := h
refine (div_modByMonic_unique (p₂ /ₘ q + f) _ hq ⟨?_, degree_modByMonic_lt _ hq⟩).2
rw [sub_eq_iff_eq_add.mp sub_eq, mul_add, ← add_assoc, modByMonic_add_div _ hq, add_comm]
|
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Finset.Image
import Mathlib.Data.List.FinRange
#align_import data.fintype.basic from "leanprover-community/mathlib"@"d78597269638367c3863d40d45108f52207e03cf"
/-!
# Finite types
This file defines a typeclass to state that a type is finite.
## Main declarations
* `Fintype α`: Typeclass saying that a type is finite. It takes as fields a `Finset` and a proof
that all terms of type `α` are in it.
* `Finset.univ`: The finset of all elements of a fintype.
See `Data.Fintype.Card` for the cardinality of a fintype,
the equivalence with `Fin (Fintype.card α)`, and pigeonhole principles.
## Instances
Instances for `Fintype` for
* `{x // p x}` are in this file as `Fintype.subtype`
* `Option α` are in `Data.Fintype.Option`
* `α × β` are in `Data.Fintype.Prod`
* `α ⊕ β` are in `Data.Fintype.Sum`
* `Σ (a : α), β a` are in `Data.Fintype.Sigma`
These files also contain appropriate `Infinite` instances for these types.
`Infinite` instances for `ℕ`, `ℤ`, `Multiset α`, and `List α` are in `Data.Fintype.Lattice`.
Types which have a surjection from/an injection to a `Fintype` are themselves fintypes.
See `Fintype.ofInjective` and `Fintype.ofSurjective`.
-/
assert_not_exists MonoidWithZero
assert_not_exists MulAction
open Function
open Nat
universe u v
variable {α β γ : Type*}
/-- `Fintype α` means that `α` is finite, i.e. there are only
finitely many distinct elements of type `α`. The evidence of this
is a finset `elems` (a list up to permutation without duplicates),
together with a proof that everything of type `α` is in the list. -/
class Fintype (α : Type*) where
/-- The `Finset` containing all elements of a `Fintype` -/
elems : Finset α
/-- A proof that `elems` contains every element of the type -/
complete : ∀ x : α, x ∈ elems
#align fintype Fintype
namespace Finset
variable [Fintype α] {s t : Finset α}
/-- `univ` is the universal finite set of type `Finset α` implied from
the assumption `Fintype α`. -/
def univ : Finset α :=
@Fintype.elems α _
#align finset.univ Finset.univ
@[simp]
theorem mem_univ (x : α) : x ∈ (univ : Finset α) :=
Fintype.complete x
#align finset.mem_univ Finset.mem_univ
-- Porting note: removing @[simp], simp can prove it
theorem mem_univ_val : ∀ x, x ∈ (univ : Finset α).1 :=
mem_univ
#align finset.mem_univ_val Finset.mem_univ_val
| Mathlib/Data/Fintype/Basic.lean | 84 | 84 | theorem eq_univ_iff_forall : s = univ ↔ ∀ x, x ∈ s := by | simp [ext_iff]
|
/-
Copyright (c) 2021 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
import Mathlib.Data.Int.Bitwise
import Mathlib.LinearAlgebra.Matrix.NonsingularInverse
import Mathlib.LinearAlgebra.Matrix.Symmetric
#align_import linear_algebra.matrix.zpow from "leanprover-community/mathlib"@"03fda9112aa6708947da13944a19310684bfdfcb"
/-!
# Integer powers of square matrices
In this file, we define integer power of matrices, relying on
the nonsingular inverse definition for negative powers.
## Implementation details
The main definition is a direct recursive call on the integer inductive type,
as provided by the `DivInvMonoid.Pow` default implementation.
The lemma names are taken from `Algebra.GroupWithZero.Power`.
## Tags
matrix inverse, matrix powers
-/
open Matrix
namespace Matrix
variable {n' : Type*} [DecidableEq n'] [Fintype n'] {R : Type*} [CommRing R]
local notation "M" => Matrix n' n' R
noncomputable instance : DivInvMonoid M :=
{ show Monoid M by infer_instance, show Inv M by infer_instance with }
section NatPow
@[simp]
theorem inv_pow' (A : M) (n : ℕ) : A⁻¹ ^ n = (A ^ n)⁻¹ := by
induction' n with n ih
· simp
· rw [pow_succ A, mul_inv_rev, ← ih, ← pow_succ']
#align matrix.inv_pow' Matrix.inv_pow'
theorem pow_sub' (A : M) {m n : ℕ} (ha : IsUnit A.det) (h : n ≤ m) :
A ^ (m - n) = A ^ m * (A ^ n)⁻¹ := by
rw [← tsub_add_cancel_of_le h, pow_add, Matrix.mul_assoc, mul_nonsing_inv,
tsub_add_cancel_of_le h, Matrix.mul_one]
simpa using ha.pow n
#align matrix.pow_sub' Matrix.pow_sub'
theorem pow_inv_comm' (A : M) (m n : ℕ) : A⁻¹ ^ m * A ^ n = A ^ n * A⁻¹ ^ m := by
induction' n with n IH generalizing m
· simp
cases' m with m m
· simp
rcases nonsing_inv_cancel_or_zero A with (⟨h, h'⟩ | h)
· calc
A⁻¹ ^ (m + 1) * A ^ (n + 1) = A⁻¹ ^ m * (A⁻¹ * A) * A ^ n := by
simp only [pow_succ A⁻¹, pow_succ' A, Matrix.mul_assoc]
_ = A ^ n * A⁻¹ ^ m := by simp only [h, Matrix.mul_one, Matrix.one_mul, IH m]
_ = A ^ n * (A * A⁻¹) * A⁻¹ ^ m := by simp only [h', Matrix.mul_one, Matrix.one_mul]
_ = A ^ (n + 1) * A⁻¹ ^ (m + 1) := by
simp only [pow_succ A, pow_succ' A⁻¹, Matrix.mul_assoc]
· simp [h]
#align matrix.pow_inv_comm' Matrix.pow_inv_comm'
end NatPow
section ZPow
open Int
@[simp]
theorem one_zpow : ∀ n : ℤ, (1 : M) ^ n = 1
| (n : ℕ) => by rw [zpow_natCast, one_pow]
| -[n+1] => by rw [zpow_negSucc, one_pow, inv_one]
#align matrix.one_zpow Matrix.one_zpow
theorem zero_zpow : ∀ z : ℤ, z ≠ 0 → (0 : M) ^ z = 0
| (n : ℕ), h => by
rw [zpow_natCast, zero_pow]
exact mod_cast h
| -[n+1], _ => by simp [zero_pow n.succ_ne_zero]
#align matrix.zero_zpow Matrix.zero_zpow
theorem zero_zpow_eq (n : ℤ) : (0 : M) ^ n = if n = 0 then 1 else 0 := by
split_ifs with h
· rw [h, zpow_zero]
· rw [zero_zpow _ h]
#align matrix.zero_zpow_eq Matrix.zero_zpow_eq
theorem inv_zpow (A : M) : ∀ n : ℤ, A⁻¹ ^ n = (A ^ n)⁻¹
| (n : ℕ) => by rw [zpow_natCast, zpow_natCast, inv_pow']
| -[n+1] => by rw [zpow_negSucc, zpow_negSucc, inv_pow']
#align matrix.inv_zpow Matrix.inv_zpow
@[simp]
theorem zpow_neg_one (A : M) : A ^ (-1 : ℤ) = A⁻¹ := by
convert DivInvMonoid.zpow_neg' 0 A
simp only [zpow_one, Int.ofNat_zero, Int.ofNat_succ, zpow_eq_pow, zero_add]
#align matrix.zpow_neg_one Matrix.zpow_neg_one
#align matrix.zpow_coe_nat zpow_natCast
@[simp]
theorem zpow_neg_natCast (A : M) (n : ℕ) : A ^ (-n : ℤ) = (A ^ n)⁻¹ := by
cases n
· simp
· exact DivInvMonoid.zpow_neg' _ _
#align matrix.zpow_neg_coe_nat Matrix.zpow_neg_natCast
@[deprecated (since := "2024-04-05")] alias zpow_neg_coe_nat := zpow_neg_natCast
| Mathlib/LinearAlgebra/Matrix/ZPow.lean | 120 | 123 | theorem _root_.IsUnit.det_zpow {A : M} (h : IsUnit A.det) (n : ℤ) : IsUnit (A ^ n).det := by |
cases' n with n n
· simpa using h.pow n
· simpa using h.pow n.succ
|
/-
Copyright (c) 2021 Frédéric Dupuis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Frédéric Dupuis
-/
import Mathlib.Algebra.Group.Subgroup.Basic
import Mathlib.Algebra.Module.Defs
import Mathlib.Algebra.Star.Pi
#align_import algebra.star.self_adjoint from "leanprover-community/mathlib"@"a6ece35404f60597c651689c1b46ead86de5ac1b"
/-!
# Self-adjoint, skew-adjoint and normal elements of a star additive group
This file defines `selfAdjoint R` (resp. `skewAdjoint R`), where `R` is a star additive group,
as the additive subgroup containing the elements that satisfy `star x = x` (resp. `star x = -x`).
This includes, for instance, (skew-)Hermitian operators on Hilbert spaces.
We also define `IsStarNormal R`, a `Prop` that states that an element `x` satisfies
`star x * x = x * star x`.
## Implementation notes
* When `R` is a `StarModule R₂ R`, then `selfAdjoint R` has a natural
`Module (selfAdjoint R₂) (selfAdjoint R)` structure. However, doing this literally would be
undesirable since in the main case of interest (`R₂ = ℂ`) we want `Module ℝ (selfAdjoint R)`
and not `Module (selfAdjoint ℂ) (selfAdjoint R)`. We solve this issue by adding the typeclass
`[TrivialStar R₃]`, of which `ℝ` is an instance (registered in `Data/Real/Basic`), and then
add a `[Module R₃ (selfAdjoint R)]` instance whenever we have
`[Module R₃ R] [TrivialStar R₃]`. (Another approach would have been to define
`[StarInvariantScalars R₃ R]` to express the fact that `star (x • v) = x • star v`, but
this typeclass would have the disadvantage of taking two type arguments.)
## TODO
* Define `IsSkewAdjoint` to match `IsSelfAdjoint`.
* Define `fun z x => z * x * star z` (i.e. conjugation by `z`) as a monoid action of `R` on `R`
(similar to the existing `ConjAct` for groups), and then state the fact that `selfAdjoint R` is
invariant under it.
-/
open Function
variable {R A : Type*}
/-- An element is self-adjoint if it is equal to its star. -/
def IsSelfAdjoint [Star R] (x : R) : Prop :=
star x = x
#align is_self_adjoint IsSelfAdjoint
/-- An element of a star monoid is normal if it commutes with its adjoint. -/
@[mk_iff]
class IsStarNormal [Mul R] [Star R] (x : R) : Prop where
/-- A normal element of a star monoid commutes with its adjoint. -/
star_comm_self : Commute (star x) x
#align is_star_normal IsStarNormal
export IsStarNormal (star_comm_self)
theorem star_comm_self' [Mul R] [Star R] (x : R) [IsStarNormal x] : star x * x = x * star x :=
IsStarNormal.star_comm_self
#align star_comm_self' star_comm_self'
namespace IsSelfAdjoint
-- named to match `Commute.allₓ`
/-- All elements are self-adjoint when `star` is trivial. -/
theorem all [Star R] [TrivialStar R] (r : R) : IsSelfAdjoint r :=
star_trivial _
#align is_self_adjoint.all IsSelfAdjoint.all
theorem star_eq [Star R] {x : R} (hx : IsSelfAdjoint x) : star x = x :=
hx
#align is_self_adjoint.star_eq IsSelfAdjoint.star_eq
theorem _root_.isSelfAdjoint_iff [Star R] {x : R} : IsSelfAdjoint x ↔ star x = x :=
Iff.rfl
#align is_self_adjoint_iff isSelfAdjoint_iff
@[simp]
theorem star_iff [InvolutiveStar R] {x : R} : IsSelfAdjoint (star x) ↔ IsSelfAdjoint x := by
simpa only [IsSelfAdjoint, star_star] using eq_comm
#align is_self_adjoint.star_iff IsSelfAdjoint.star_iff
@[simp]
theorem star_mul_self [Mul R] [StarMul R] (x : R) : IsSelfAdjoint (star x * x) := by
simp only [IsSelfAdjoint, star_mul, star_star]
#align is_self_adjoint.star_mul_self IsSelfAdjoint.star_mul_self
@[simp]
theorem mul_star_self [Mul R] [StarMul R] (x : R) : IsSelfAdjoint (x * star x) := by
simpa only [star_star] using star_mul_self (star x)
#align is_self_adjoint.mul_star_self IsSelfAdjoint.mul_star_self
/-- Self-adjoint elements commute if and only if their product is self-adjoint. -/
lemma commute_iff {R : Type*} [Mul R] [StarMul R] {x y : R}
(hx : IsSelfAdjoint x) (hy : IsSelfAdjoint y) : Commute x y ↔ IsSelfAdjoint (x * y) := by
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· rw [isSelfAdjoint_iff, star_mul, hx.star_eq, hy.star_eq, h.eq]
· simpa only [star_mul, hx.star_eq, hy.star_eq] using h.symm
/-- Functions in a `StarHomClass` preserve self-adjoint elements. -/
theorem starHom_apply {F R S : Type*} [Star R] [Star S] [FunLike F R S] [StarHomClass F R S]
{x : R} (hx : IsSelfAdjoint x) (f : F) : IsSelfAdjoint (f x) :=
show star (f x) = f x from map_star f x ▸ congr_arg f hx
#align is_self_adjoint.star_hom_apply IsSelfAdjoint.starHom_apply
/- note: this lemma is *not* marked as `simp` so that Lean doesn't look for a `[TrivialStar R]`
instance every time it sees `⊢ IsSelfAdjoint (f x)`, which will likely occur relatively often. -/
theorem _root_.isSelfAdjoint_starHom_apply {F R S : Type*} [Star R] [Star S] [FunLike F R S]
[StarHomClass F R S] [TrivialStar R] (f : F) (x : R) : IsSelfAdjoint (f x) :=
(IsSelfAdjoint.all x).starHom_apply f
section AddMonoid
variable [AddMonoid R] [StarAddMonoid R]
variable (R)
@[simp] theorem _root_.isSelfAdjoint_zero : IsSelfAdjoint (0 : R) := star_zero R
#align is_self_adjoint_zero isSelfAdjoint_zero
variable {R}
| Mathlib/Algebra/Star/SelfAdjoint.lean | 125 | 126 | theorem add {x y : R} (hx : IsSelfAdjoint x) (hy : IsSelfAdjoint y) : IsSelfAdjoint (x + y) := by |
simp only [isSelfAdjoint_iff, star_add, hx.star_eq, hy.star_eq]
|
/-
Copyright (c) 2022 Dagur Tómas Ásgeirsson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Tómas Ásgeirsson, Leonardo de Moura
-/
import Mathlib.Data.Set.Basic
#align_import data.set.bool_indicator from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e"
/-!
# Indicator function valued in bool
See also `Set.indicator` and `Set.piecewise`.
-/
open Bool
namespace Set
variable {α : Type*} (s : Set α)
/-- `boolIndicator` maps `x` to `true` if `x ∈ s`, else to `false` -/
noncomputable def boolIndicator (x : α) :=
@ite _ (x ∈ s) (Classical.propDecidable _) true false
#align set.bool_indicator Set.boolIndicator
| Mathlib/Data/Set/BoolIndicator.lean | 27 | 29 | theorem mem_iff_boolIndicator (x : α) : x ∈ s ↔ s.boolIndicator x = true := by |
unfold boolIndicator
split_ifs with h <;> simp [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, Sébastien Gouëzel,
Rémy Degenne, David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Complex
import Qq
#align_import analysis.special_functions.pow.real from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8"
/-! # Power function on `ℝ`
We construct the power functions `x ^ y`, where `x` and `y` are real numbers.
-/
noncomputable section
open scoped Classical
open Real ComplexConjugate
open Finset Set
/-
## Definitions
-/
namespace Real
variable {x y z : ℝ}
/-- The real power function `x ^ y`, defined as the real part of the complex power function.
For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`, one sets `0 ^ 0=1` and `0 ^ y=0` for
`y ≠ 0`. For `x < 0`, the definition is somewhat arbitrary as it depends on the choice of a complex
determination of the logarithm. With our conventions, it is equal to `exp (y log x) cos (π y)`. -/
noncomputable def rpow (x y : ℝ) :=
((x : ℂ) ^ (y : ℂ)).re
#align real.rpow Real.rpow
noncomputable instance : Pow ℝ ℝ := ⟨rpow⟩
@[simp]
theorem rpow_eq_pow (x y : ℝ) : rpow x y = x ^ y := rfl
#align real.rpow_eq_pow Real.rpow_eq_pow
theorem rpow_def (x y : ℝ) : x ^ y = ((x : ℂ) ^ (y : ℂ)).re := rfl
#align real.rpow_def Real.rpow_def
theorem rpow_def_of_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) :
x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) := by
simp only [rpow_def, Complex.cpow_def]; split_ifs <;>
simp_all [(Complex.ofReal_log hx).symm, -Complex.ofReal_mul, -RCLike.ofReal_mul,
(Complex.ofReal_mul _ _).symm, Complex.exp_ofReal_re, Complex.ofReal_eq_zero]
#align real.rpow_def_of_nonneg Real.rpow_def_of_nonneg
theorem rpow_def_of_pos {x : ℝ} (hx : 0 < x) (y : ℝ) : x ^ y = exp (log x * y) := by
rw [rpow_def_of_nonneg (le_of_lt hx), if_neg (ne_of_gt hx)]
#align real.rpow_def_of_pos Real.rpow_def_of_pos
theorem exp_mul (x y : ℝ) : exp (x * y) = exp x ^ y := by rw [rpow_def_of_pos (exp_pos _), log_exp]
#align real.exp_mul Real.exp_mul
@[simp, norm_cast]
theorem rpow_intCast (x : ℝ) (n : ℤ) : x ^ (n : ℝ) = x ^ n := by
simp only [rpow_def, ← Complex.ofReal_zpow, Complex.cpow_intCast, Complex.ofReal_intCast,
Complex.ofReal_re]
#align real.rpow_int_cast Real.rpow_intCast
@[deprecated (since := "2024-04-17")]
alias rpow_int_cast := rpow_intCast
@[simp, norm_cast]
theorem rpow_natCast (x : ℝ) (n : ℕ) : x ^ (n : ℝ) = x ^ n := by simpa using rpow_intCast x n
#align real.rpow_nat_cast Real.rpow_natCast
@[deprecated (since := "2024-04-17")]
alias rpow_nat_cast := rpow_natCast
@[simp]
| Mathlib/Analysis/SpecialFunctions/Pow/Real.lean | 80 | 80 | theorem exp_one_rpow (x : ℝ) : exp 1 ^ x = exp x := by | rw [← exp_mul, one_mul]
|
/-
Copyright (c) 2024 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel
-/
import Mathlib.CategoryTheory.Limits.FunctorCategory
import Mathlib.CategoryTheory.Limits.Types
/-!
# Concrete description of (co)limits in functor categories
Some of the concrete descriptions of (co)limits in `Type v` extend to (co)limits in the functor
category `K ⥤ Type v`.
-/
namespace CategoryTheory.FunctorToTypes
open CategoryTheory.Limits
universe w v₁ v₂ u₁ u₂
variable {J : Type u₁} [Category.{v₁} J] {K : Type u₂} [Category.{v₂} K]
variable (F : J ⥤ K ⥤ TypeMax.{u₁, w})
| Mathlib/CategoryTheory/Limits/FunctorToTypes.lean | 25 | 29 | theorem jointly_surjective (k : K) {t : Cocone F} (h : IsColimit t) (x : t.pt.obj k) :
∃ j y, x = (t.ι.app j).app k y := by |
let hev := isColimitOfPreserves ((evaluation _ _).obj k) h
obtain ⟨j, y, rfl⟩ := Types.jointly_surjective _ hev x
exact ⟨j, y, by simp⟩
|
/-
Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
-/
import Mathlib.Data.Int.Bitwise
import Mathlib.Data.Int.Order.Lemmas
import Mathlib.Data.Set.Function
import Mathlib.Order.Interval.Set.Basic
#align_import data.int.lemmas from "leanprover-community/mathlib"@"09597669f02422ed388036273d8848119699c22f"
/-!
# Miscellaneous lemmas about the integers
This file contains lemmas about integers, which require further imports than
`Data.Int.Basic` or `Data.Int.Order`.
-/
open Nat
namespace Int
theorem le_natCast_sub (m n : ℕ) : (m - n : ℤ) ≤ ↑(m - n : ℕ) := by
by_cases h : m ≥ n
· exact le_of_eq (Int.ofNat_sub h).symm
· simp [le_of_not_ge h, ofNat_le]
#align int.le_coe_nat_sub Int.le_natCast_sub
/-! ### `succ` and `pred` -/
-- Porting note (#10618): simp can prove this @[simp]
theorem succ_natCast_pos (n : ℕ) : 0 < (n : ℤ) + 1 :=
lt_add_one_iff.mpr (by simp)
#align int.succ_coe_nat_pos Int.succ_natCast_pos
/-! ### `natAbs` -/
variable {a b : ℤ} {n : ℕ}
theorem natAbs_eq_iff_sq_eq {a b : ℤ} : a.natAbs = b.natAbs ↔ a ^ 2 = b ^ 2 := by
rw [sq, sq]
exact natAbs_eq_iff_mul_self_eq
#align int.nat_abs_eq_iff_sq_eq Int.natAbs_eq_iff_sq_eq
theorem natAbs_lt_iff_sq_lt {a b : ℤ} : a.natAbs < b.natAbs ↔ a ^ 2 < b ^ 2 := by
rw [sq, sq]
exact natAbs_lt_iff_mul_self_lt
#align int.nat_abs_lt_iff_sq_lt Int.natAbs_lt_iff_sq_lt
theorem natAbs_le_iff_sq_le {a b : ℤ} : a.natAbs ≤ b.natAbs ↔ a ^ 2 ≤ b ^ 2 := by
rw [sq, sq]
exact natAbs_le_iff_mul_self_le
#align int.nat_abs_le_iff_sq_le Int.natAbs_le_iff_sq_le
| Mathlib/Data/Int/Lemmas.lean | 60 | 61 | theorem natAbs_inj_of_nonneg_of_nonneg {a b : ℤ} (ha : 0 ≤ a) (hb : 0 ≤ b) :
natAbs a = natAbs b ↔ a = b := by | rw [← sq_eq_sq ha hb, ← natAbs_eq_iff_sq_eq]
|
/-
Copyright (c) 2023 Dagur Asgeirsson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Asgeirsson
-/
import Mathlib.Algebra.Category.ModuleCat.Free
import Mathlib.Topology.Category.Profinite.CofilteredLimit
import Mathlib.Topology.Category.Profinite.Product
import Mathlib.Topology.LocallyConstant.Algebra
import Mathlib.Init.Data.Bool.Lemmas
/-!
# Nöbeling's theorem
This file proves Nöbeling's theorem.
## Main result
* `LocallyConstant.freeOfProfinite`: Nöbeling's theorem.
For `S : Profinite`, the `ℤ`-module `LocallyConstant S ℤ` is free.
## Proof idea
We follow the proof of theorem 5.4 in [scholze2019condensed], in which the idea is to embed `S` in
a product of `I` copies of `Bool` for some sufficiently large `I`, and then to choose a
well-ordering on `I` and use ordinal induction over that well-order. Here we can let `I` be
the set of clopen subsets of `S` since `S` is totally separated.
The above means it suffices to prove the following statement: For a closed subset `C` of `I → Bool`,
the `ℤ`-module `LocallyConstant C ℤ` is free.
For `i : I`, let `e C i : LocallyConstant C ℤ` denote the map `fun f ↦ (if f.val i then 1 else 0)`.
The basis will consist of products `e C iᵣ * ⋯ * e C i₁` with `iᵣ > ⋯ > i₁` which cannot be written
as linear combinations of lexicographically smaller products. We call this set `GoodProducts C`
What is proved by ordinal induction is that this set is linearly independent. The fact that it
spans can be proved directly.
## References
- [scholze2019condensed], Theorem 5.4.
-/
universe u
namespace Profinite
namespace NobelingProof
variable {I : Type u} [LinearOrder I] [IsWellOrder I (·<·)] (C : Set (I → Bool))
open Profinite ContinuousMap CategoryTheory Limits Opposite Submodule
section Projections
/-!
## Projection maps
The purpose of this section is twofold.
Firstly, in the proof that the set `GoodProducts C` spans the whole module `LocallyConstant C ℤ`,
we need to project `C` down to finite discrete subsets and write `C` as a cofiltered limit of those.
Secondly, in the inductive argument, we need to project `C` down to "smaller" sets satisfying the
inductive hypothesis.
In this section we define the relevant projection maps and prove some compatibility results.
### Main definitions
* Let `J : I → Prop`. Then `Proj J : (I → Bool) → (I → Bool)` is the projection mapping everything
that satisfies `J i` to itself, and everything else to `false`.
* The image of `C` under `Proj J` is denoted `π C J` and the corresponding map `C → π C J` is called
`ProjRestrict`. If `J` implies `K` we have a map `ProjRestricts : π C K → π C J`.
* `spanCone_isLimit` establishes that when `C` is compact, it can be written as a limit of its
images under the maps `Proj (· ∈ s)` where `s : Finset I`.
-/
variable (J K L : I → Prop) [∀ i, Decidable (J i)] [∀ i, Decidable (K i)] [∀ i, Decidable (L i)]
/--
The projection mapping everything that satisfies `J i` to itself, and everything else to `false`
-/
def Proj : (I → Bool) → (I → Bool) :=
fun c i ↦ if J i then c i else false
@[simp]
theorem continuous_proj :
Continuous (Proj J : (I → Bool) → (I → Bool)) := by
dsimp (config := { unfoldPartialApp := true }) [Proj]
apply continuous_pi
intro i
split
· apply continuous_apply
· apply continuous_const
/-- The image of `Proj π J` -/
def π : Set (I → Bool) := (Proj J) '' C
/-- The restriction of `Proj π J` to a subset, mapping to its image. -/
@[simps!]
def ProjRestrict : C → π C J :=
Set.MapsTo.restrict (Proj J) _ _ (Set.mapsTo_image _ _)
@[simp]
theorem continuous_projRestrict : Continuous (ProjRestrict C J) :=
Continuous.restrict _ (continuous_proj _)
theorem proj_eq_self {x : I → Bool} (h : ∀ i, x i ≠ false → J i) : Proj J x = x := by
ext i
simp only [Proj, ite_eq_left_iff]
contrapose!
simpa only [ne_comm] using h i
theorem proj_prop_eq_self (hh : ∀ i x, x ∈ C → x i ≠ false → J i) : π C J = C := by
ext x
refine ⟨fun ⟨y, hy, h⟩ ↦ ?_, fun h ↦ ⟨x, h, ?_⟩⟩
· rwa [← h, proj_eq_self]; exact (hh · y hy)
· rw [proj_eq_self]; exact (hh · x h)
theorem proj_comp_of_subset (h : ∀ i, J i → K i) : (Proj J ∘ Proj K) =
(Proj J : (I → Bool) → (I → Bool)) := by
ext x i; dsimp [Proj]; aesop
theorem proj_eq_of_subset (h : ∀ i, J i → K i) : π (π C K) J = π C J := by
ext x
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· obtain ⟨y, ⟨z, hz, rfl⟩, rfl⟩ := h
refine ⟨z, hz, (?_ : _ = (Proj J ∘ Proj K) z)⟩
rw [proj_comp_of_subset J K h]
· obtain ⟨y, hy, rfl⟩ := h
dsimp [π]
rw [← Set.image_comp]
refine ⟨y, hy, ?_⟩
rw [proj_comp_of_subset J K h]
variable {J K L}
/-- A variant of `ProjRestrict` with domain of the form `π C K` -/
@[simps!]
def ProjRestricts (h : ∀ i, J i → K i) : π C K → π C J :=
Homeomorph.setCongr (proj_eq_of_subset C J K h) ∘ ProjRestrict (π C K) J
@[simp]
theorem continuous_projRestricts (h : ∀ i, J i → K i) : Continuous (ProjRestricts C h) :=
Continuous.comp (Homeomorph.continuous _) (continuous_projRestrict _ _)
theorem surjective_projRestricts (h : ∀ i, J i → K i) : Function.Surjective (ProjRestricts C h) :=
(Homeomorph.surjective _).comp (Set.surjective_mapsTo_image_restrict _ _)
variable (J) in
| Mathlib/Topology/Category/Profinite/Nobeling.lean | 156 | 158 | theorem projRestricts_eq_id : ProjRestricts C (fun i (h : J i) ↦ h) = id := by |
ext ⟨x, y, hy, rfl⟩ i
simp (config := { contextual := true }) only [π, Proj, ProjRestricts_coe, id_eq, if_true]
|
/-
Copyright (c) 2021 Julian Kuelshammer. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Julian Kuelshammer
-/
import Mathlib.Algebra.CharP.Invertible
import Mathlib.Data.ZMod.Basic
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Polynomial.Chebyshev
import Mathlib.RingTheory.Ideal.LocalRing
#align_import ring_theory.polynomial.dickson from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
/-!
# Dickson polynomials
The (generalised) Dickson polynomials are a family of polynomials indexed by `ℕ × ℕ`,
with coefficients in a commutative ring `R` depending on an element `a∈R`. More precisely, the
they satisfy the recursion `dickson k a (n + 2) = X * (dickson k a n + 1) - a * (dickson k a n)`
with starting values `dickson k a 0 = 3 - k` and `dickson k a 1 = X`. In the literature,
`dickson k a n` is called the `n`-th Dickson polynomial of the `k`-th kind associated to the
parameter `a : R`. They are closely related to the Chebyshev polynomials in the case that `a=1`.
When `a=0` they are just the family of monomials `X ^ n`.
## Main definition
* `Polynomial.dickson`: the generalised Dickson polynomials.
## Main statements
* `Polynomial.dickson_one_one_mul`, the `(m * n)`-th Dickson polynomial of the first kind for
parameter `1 : R` is the composition of the `m`-th and `n`-th Dickson polynomials of the first
kind for `1 : R`.
* `Polynomial.dickson_one_one_charP`, for a prime number `p`, the `p`-th Dickson polynomial of the
first kind associated to parameter `1 : R` is congruent to `X ^ p` modulo `p`.
## References
* [R. Lidl, G. L. Mullen and G. Turnwald, _Dickson polynomials_][MR1237403]
## TODO
* Redefine `dickson` in terms of `LinearRecurrence`.
* Show that `dickson 2 1` is equal to the characteristic polynomial of the adjacency matrix of a
type A Dynkin diagram.
* Prove that the adjacency matrices of simply laced Dynkin diagrams are precisely the adjacency
matrices of simple connected graphs which annihilate `dickson 2 1`.
-/
noncomputable section
namespace Polynomial
open Polynomial
variable {R S : Type*} [CommRing R] [CommRing S] (k : ℕ) (a : R)
/-- `dickson` is the `n`-th (generalised) Dickson polynomial of the `k`-th kind associated to the
element `a ∈ R`. -/
noncomputable def dickson : ℕ → R[X]
| 0 => 3 - k
| 1 => X
| n + 2 => X * dickson (n + 1) - C a * dickson n
#align polynomial.dickson Polynomial.dickson
@[simp]
theorem dickson_zero : dickson k a 0 = 3 - k :=
rfl
#align polynomial.dickson_zero Polynomial.dickson_zero
@[simp]
theorem dickson_one : dickson k a 1 = X :=
rfl
#align polynomial.dickson_one Polynomial.dickson_one
| Mathlib/RingTheory/Polynomial/Dickson.lean | 77 | 78 | theorem dickson_two : dickson k a 2 = X ^ 2 - C a * (3 - k : R[X]) := by |
simp only [dickson, sq]
|
/-
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 _ _)
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
#align finset.sorted_zero_eq_min'_aux Finset.sorted_zero_eq_min'_aux
theorem sorted_zero_eq_min' {s : Finset α} {h : 0 < (s.sort (· ≤ ·)).length} :
(s.sort (· ≤ ·)).get ⟨0, h⟩ = s.min' (card_pos.1 <| by rwa [length_sort] at h) :=
sorted_zero_eq_min'_aux _ _ _
#align finset.sorted_zero_eq_min' Finset.sorted_zero_eq_min'
theorem min'_eq_sorted_zero {s : Finset α} {h : s.Nonempty} :
s.min' h = (s.sort (· ≤ ·)).get ⟨0, (by rw [length_sort]; exact card_pos.2 h)⟩ :=
(sorted_zero_eq_min'_aux _ _ _).symm
#align finset.min'_eq_sorted_zero Finset.min'_eq_sorted_zero
| Mathlib/Data/Finset/Sort.lean | 119 | 130 | theorem sorted_last_eq_max'_aux (s : Finset α)
(h : (s.sort (· ≤ ·)).length - 1 < (s.sort (· ≤ ·)).length) (H : s.Nonempty) :
(s.sort (· ≤ ·)).get ⟨(s.sort (· ≤ ·)).length - 1, h⟩ = s.max' H := by |
let l := s.sort (· ≤ ·)
apply le_antisymm
· have : l.get ⟨(s.sort (· ≤ ·)).length - 1, h⟩ ∈ s :=
(Finset.mem_sort (α := α) (· ≤ ·)).1 (List.get_mem l _ h)
exact s.le_max' _ this
· have : s.max' H ∈ l := (Finset.mem_sort (α := α) (· ≤ ·)).mpr (s.max'_mem H)
obtain ⟨i, hi⟩ : ∃ i, l.get i = s.max' H := List.mem_iff_get.1 this
rw [← hi]
exact (s.sort_sorted (· ≤ ·)).rel_get_of_le (Nat.le_sub_one_of_lt i.prop)
|
/-
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.GramSchmidtOrtho
import Mathlib.LinearAlgebra.Orientation
#align_import analysis.inner_product_space.orientation from "leanprover-community/mathlib"@"bd65478311e4dfd41f48bf38c7e3b02fb75d0163"
/-!
# Orientations of real inner product spaces.
This file provides definitions and proves lemmas about orientations of real inner product spaces.
## Main definitions
* `OrthonormalBasis.adjustToOrientation` takes an orthonormal basis and an orientation, and
returns an orthonormal basis with that orientation: either the original orthonormal basis, or one
constructed by negating a single (arbitrary) basis vector.
* `Orientation.finOrthonormalBasis` is an orthonormal basis, indexed by `Fin n`, with the given
orientation.
* `Orientation.volumeForm` is a nonvanishing top-dimensional alternating form on an oriented real
inner product space, uniquely defined by compatibility with the orientation and inner product
structure.
## Main theorems
* `Orientation.volumeForm_apply_le` states that the result of applying the volume form to a set of
`n` vectors, where `n` is the dimension the inner product space, is bounded by the product of the
lengths of the vectors.
* `Orientation.abs_volumeForm_apply_of_pairwise_orthogonal` states that the result of applying the
volume form to a set of `n` orthogonal vectors, where `n` is the dimension the inner product
space, is equal up to sign to the product of the lengths of the vectors.
-/
noncomputable section
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
open FiniteDimensional
open scoped RealInnerProductSpace
namespace OrthonormalBasis
variable {ι : Type*} [Fintype ι] [DecidableEq ι] [ne : Nonempty ι] (e f : OrthonormalBasis ι ℝ E)
(x : Orientation ℝ E ι)
/-- The change-of-basis matrix between two orthonormal bases with the same orientation has
determinant 1. -/
theorem det_to_matrix_orthonormalBasis_of_same_orientation
(h : e.toBasis.orientation = f.toBasis.orientation) : e.toBasis.det f = 1 := by
apply (e.det_to_matrix_orthonormalBasis_real f).resolve_right
have : 0 < e.toBasis.det f := by
rw [e.toBasis.orientation_eq_iff_det_pos] at h
simpa using h
linarith
#align orthonormal_basis.det_to_matrix_orthonormal_basis_of_same_orientation OrthonormalBasis.det_to_matrix_orthonormalBasis_of_same_orientation
/-- The change-of-basis matrix between two orthonormal bases with the opposite orientations has
determinant -1. -/
| Mathlib/Analysis/InnerProductSpace/Orientation.lean | 65 | 69 | theorem det_to_matrix_orthonormalBasis_of_opposite_orientation
(h : e.toBasis.orientation ≠ f.toBasis.orientation) : e.toBasis.det f = -1 := by |
contrapose! h
simp [e.toBasis.orientation_eq_iff_det_pos,
(e.det_to_matrix_orthonormalBasis_real f).resolve_right h]
|
/-
Copyright (c) 2022 Kevin H. Wilson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kevin H. Wilson
-/
import Mathlib.MeasureTheory.Integral.IntervalIntegral
import Mathlib.Data.Set.Function
#align_import analysis.sum_integral_comparisons from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
/-!
# Comparing sums and integrals
## Summary
It is often the case that error terms in analysis can be computed by comparing
an infinite sum to the improper integral of an antitone function. This file will eventually enable
that.
At the moment it contains four lemmas in this direction: `AntitoneOn.integral_le_sum`,
`AntitoneOn.sum_le_integral` and versions for monotone functions, which can all be paired
with a `Filter.Tendsto` to estimate some errors.
`TODO`: Add more lemmas to the API to directly address limiting issues
## Main Results
* `AntitoneOn.integral_le_sum`: The integral of an antitone function is at most the sum of its
values at integer steps aligning with the left-hand side of the interval
* `AntitoneOn.sum_le_integral`: The sum of an antitone function along integer steps aligning with
the right-hand side of the interval is at most the integral of the function along that interval
* `MonotoneOn.integral_le_sum`: The integral of a monotone function is at most the sum of its
values at integer steps aligning with the right-hand side of the interval
* `MonotoneOn.sum_le_integral`: The sum of a monotone function along integer steps aligning with
the left-hand side of the interval is at most the integral of the function along that interval
## Tags
analysis, comparison, asymptotics
-/
open Set MeasureTheory.MeasureSpace
variable {x₀ : ℝ} {a b : ℕ} {f : ℝ → ℝ}
theorem AntitoneOn.integral_le_sum (hf : AntitoneOn f (Icc x₀ (x₀ + a))) :
(∫ x in x₀..x₀ + a, f x) ≤ ∑ i ∈ Finset.range a, f (x₀ + i) := by
have hint : ∀ k : ℕ, k < a → IntervalIntegrable f volume (x₀ + k) (x₀ + (k + 1 : ℕ)) := by
intro k hk
refine (hf.mono ?_).intervalIntegrable
rw [uIcc_of_le]
· apply Icc_subset_Icc
· simp only [le_add_iff_nonneg_right, Nat.cast_nonneg]
· simp only [add_le_add_iff_left, Nat.cast_le, Nat.succ_le_of_lt hk]
· simp only [add_le_add_iff_left, Nat.cast_le, Nat.le_succ]
calc
∫ x in x₀..x₀ + a, f x = ∑ i ∈ Finset.range a, ∫ x in x₀ + i..x₀ + (i + 1 : ℕ), f x := by
convert (intervalIntegral.sum_integral_adjacent_intervals hint).symm
simp only [Nat.cast_zero, add_zero]
_ ≤ ∑ i ∈ Finset.range a, ∫ _ in x₀ + i..x₀ + (i + 1 : ℕ), f (x₀ + i) := by
apply Finset.sum_le_sum fun i hi => ?_
have ia : i < a := Finset.mem_range.1 hi
refine intervalIntegral.integral_mono_on (by simp) (hint _ ia) (by simp) fun x hx => ?_
apply hf _ _ hx.1
· simp only [ia.le, mem_Icc, le_add_iff_nonneg_right, Nat.cast_nonneg, add_le_add_iff_left,
Nat.cast_le, and_self_iff]
· refine mem_Icc.2 ⟨le_trans (by simp) hx.1, le_trans hx.2 ?_⟩
simp only [add_le_add_iff_left, Nat.cast_le, Nat.succ_le_of_lt ia]
_ = ∑ i ∈ Finset.range a, f (x₀ + i) := by simp
#align antitone_on.integral_le_sum AntitoneOn.integral_le_sum
| Mathlib/Analysis/SumIntegralComparisons.lean | 73 | 95 | theorem AntitoneOn.integral_le_sum_Ico (hab : a ≤ b) (hf : AntitoneOn f (Set.Icc a b)) :
(∫ x in a..b, f x) ≤ ∑ x ∈ Finset.Ico a b, f x := by |
rw [(Nat.sub_add_cancel hab).symm, Nat.cast_add]
conv =>
congr
congr
· skip
· skip
rw [add_comm]
· skip
· skip
congr
congr
rw [← zero_add a]
rw [← Finset.sum_Ico_add, Nat.Ico_zero_eq_range]
conv =>
rhs
congr
· skip
ext
rw [Nat.cast_add]
apply AntitoneOn.integral_le_sum
simp only [hf, hab, Nat.cast_sub, add_sub_cancel]
|
/-
Copyright (c) 2021 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Data.Matrix.Basis
import Mathlib.Data.Matrix.DMatrix
import Mathlib.LinearAlgebra.Matrix.Determinant.Basic
import Mathlib.LinearAlgebra.Matrix.Reindex
import Mathlib.Tactic.FieldSimp
#align_import linear_algebra.matrix.transvection from "leanprover-community/mathlib"@"0e2aab2b0d521f060f62a14d2cf2e2c54e8491d6"
/-!
# Transvections
Transvections are matrices of the form `1 + StdBasisMatrix i j c`, where `StdBasisMatrix i j c`
is the basic matrix with a `c` at position `(i, j)`. Multiplying by such a transvection on the left
(resp. on the right) amounts to adding `c` times the `j`-th row to the `i`-th row
(resp `c` times the `i`-th column to the `j`-th column). Therefore, they are useful to present
algorithms operating on rows and columns.
Transvections are a special case of *elementary matrices* (according to most references, these also
contain the matrices exchanging rows, and the matrices multiplying a row by a constant).
We show that, over a field, any matrix can be written as `L * D * L'`, where `L` and `L'` are
products of transvections and `D` is diagonal. In other words, one can reduce a matrix to diagonal
form by operations on its rows and columns, a variant of Gauss' pivot algorithm.
## Main definitions and results
* `Transvection i j c` is the matrix equal to `1 + StdBasisMatrix i j c`.
* `TransvectionStruct n R` is a structure containing the data of `i, j, c` and a proof that
`i ≠ j`. These are often easier to manipulate than straight matrices, especially in inductive
arguments.
* `exists_list_transvec_mul_diagonal_mul_list_transvec` states that any matrix `M` over a field can
be written in the form `t_1 * ... * t_k * D * t'_1 * ... * t'_l`, where `D` is diagonal and
the `t_i`, `t'_j` are transvections.
* `diagonal_transvection_induction` shows that a property which is true for diagonal matrices and
transvections, and invariant under product, is true for all matrices.
* `diagonal_transvection_induction_of_det_ne_zero` is the same statement over invertible matrices.
## Implementation details
The proof of the reduction results is done inductively on the size of the matrices, reducing an
`(r + 1) × (r + 1)` matrix to a matrix whose last row and column are zeroes, except possibly for
the last diagonal entry. This step is done as follows.
If all the coefficients on the last row and column are zero, there is nothing to do. Otherwise,
one can put a nonzero coefficient in the last diagonal entry by a row or column operation, and then
subtract this last diagonal entry from the other entries in the last row and column to make them
vanish.
This step is done in the type `Fin r ⊕ Unit`, where `Fin r` is useful to choose arbitrarily some
order in which we cancel the coefficients, and the sum structure is useful to use the formalism of
block matrices.
To proceed with the induction, we reindex our matrices to reduce to the above situation.
-/
universe u₁ u₂
namespace Matrix
open Matrix
variable (n p : Type*) (R : Type u₂) {𝕜 : Type*} [Field 𝕜]
variable [DecidableEq n] [DecidableEq p]
variable [CommRing R]
section Transvection
variable {R n} (i j : n)
/-- The transvection matrix `Transvection i j c` is equal to the identity plus `c` at position
`(i, j)`. Multiplying by it on the left (as in `Transvection i j c * M`) corresponds to adding
`c` times the `j`-th line of `M` to its `i`-th line. Multiplying by it on the right corresponds
to adding `c` times the `i`-th column to the `j`-th column. -/
def transvection (c : R) : Matrix n n R :=
1 + Matrix.stdBasisMatrix i j c
#align matrix.transvection Matrix.transvection
@[simp]
theorem transvection_zero : transvection i j (0 : R) = 1 := by simp [transvection]
#align matrix.transvection_zero Matrix.transvection_zero
section
/-- A transvection matrix is obtained from the identity by adding `c` times the `j`-th row to
the `i`-th row. -/
theorem updateRow_eq_transvection [Finite n] (c : R) :
updateRow (1 : Matrix n n R) i ((1 : Matrix n n R) i + c • (1 : Matrix n n R) j) =
transvection i j c := by
cases nonempty_fintype n
ext a b
by_cases ha : i = a
· by_cases hb : j = b
· simp only [updateRow_self, transvection, ha, hb, Pi.add_apply, StdBasisMatrix.apply_same,
one_apply_eq, Pi.smul_apply, mul_one, Algebra.id.smul_eq_mul, add_apply]
· simp only [updateRow_self, transvection, ha, hb, StdBasisMatrix.apply_of_ne, Pi.add_apply,
Ne, not_false_iff, Pi.smul_apply, and_false_iff, one_apply_ne, Algebra.id.smul_eq_mul,
mul_zero, add_apply]
· simp only [updateRow_ne, transvection, ha, Ne.symm ha, StdBasisMatrix.apply_of_ne, add_zero,
Algebra.id.smul_eq_mul, Ne, not_false_iff, DMatrix.add_apply, Pi.smul_apply,
mul_zero, false_and_iff, add_apply]
#align matrix.update_row_eq_transvection Matrix.updateRow_eq_transvection
variable [Fintype n]
theorem transvection_mul_transvection_same (h : i ≠ j) (c d : R) :
transvection i j c * transvection i j d = transvection i j (c + d) := by
simp [transvection, Matrix.add_mul, Matrix.mul_add, h, h.symm, add_smul, add_assoc,
stdBasisMatrix_add]
#align matrix.transvection_mul_transvection_same Matrix.transvection_mul_transvection_same
@[simp]
theorem transvection_mul_apply_same (b : n) (c : R) (M : Matrix n n R) :
(transvection i j c * M) i b = M i b + c * M j b := by simp [transvection, Matrix.add_mul]
#align matrix.transvection_mul_apply_same Matrix.transvection_mul_apply_same
@[simp]
| Mathlib/LinearAlgebra/Matrix/Transvection.lean | 125 | 127 | theorem mul_transvection_apply_same (a : n) (c : R) (M : Matrix n n R) :
(M * transvection i j c) a j = M a j + c * M a i := by |
simp [transvection, Matrix.mul_add, mul_comm]
|
/-
Copyright (c) 2021 Jordan Brown, Thomas Browning, Patrick Lutz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jordan Brown, Thomas Browning, Patrick Lutz
-/
import Mathlib.Algebra.Group.Commutator
import Mathlib.Algebra.Group.Subgroup.Finite
import Mathlib.Data.Bracket
import Mathlib.GroupTheory.Subgroup.Centralizer
import Mathlib.Tactic.Group
#align_import group_theory.commutator from "leanprover-community/mathlib"@"4be589053caf347b899a494da75410deb55fb3ef"
/-!
# Commutators of Subgroups
If `G` is a group and `H₁ H₂ : Subgroup G` then the commutator `⁅H₁, H₂⁆ : Subgroup G`
is the subgroup of `G` generated by the commutators `h₁ * h₂ * h₁⁻¹ * h₂⁻¹`.
## Main definitions
* `⁅g₁, g₂⁆` : the commutator of the elements `g₁` and `g₂`
(defined by `commutatorElement` elsewhere).
* `⁅H₁, H₂⁆` : the commutator of the subgroups `H₁` and `H₂`.
-/
variable {G G' F : Type*} [Group G] [Group G'] [FunLike F G G'] [MonoidHomClass F G G']
variable (f : F) {g₁ g₂ g₃ g : G}
theorem commutatorElement_eq_one_iff_mul_comm : ⁅g₁, g₂⁆ = 1 ↔ g₁ * g₂ = g₂ * g₁ := by
rw [commutatorElement_def, mul_inv_eq_one, mul_inv_eq_iff_eq_mul]
#align commutator_element_eq_one_iff_mul_comm commutatorElement_eq_one_iff_mul_comm
theorem commutatorElement_eq_one_iff_commute : ⁅g₁, g₂⁆ = 1 ↔ Commute g₁ g₂ :=
commutatorElement_eq_one_iff_mul_comm
#align commutator_element_eq_one_iff_commute commutatorElement_eq_one_iff_commute
theorem Commute.commutator_eq (h : Commute g₁ g₂) : ⁅g₁, g₂⁆ = 1 :=
commutatorElement_eq_one_iff_commute.mpr h
#align commute.commutator_eq Commute.commutator_eq
variable (g₁ g₂ g₃ g)
@[simp]
theorem commutatorElement_one_right : ⁅g, (1 : G)⁆ = 1 :=
(Commute.one_right g).commutator_eq
#align commutator_element_one_right commutatorElement_one_right
@[simp]
theorem commutatorElement_one_left : ⁅(1 : G), g⁆ = 1 :=
(Commute.one_left g).commutator_eq
#align commutator_element_one_left commutatorElement_one_left
@[simp]
theorem commutatorElement_self : ⁅g, g⁆ = 1 :=
(Commute.refl g).commutator_eq
#align commutator_element_self commutatorElement_self
@[simp]
theorem commutatorElement_inv : ⁅g₁, g₂⁆⁻¹ = ⁅g₂, g₁⁆ := by
simp_rw [commutatorElement_def, mul_inv_rev, inv_inv, mul_assoc]
#align commutator_element_inv commutatorElement_inv
theorem map_commutatorElement : (f ⁅g₁, g₂⁆ : G') = ⁅f g₁, f g₂⁆ := by
simp_rw [commutatorElement_def, map_mul f, map_inv f]
#align map_commutator_element map_commutatorElement
theorem conjugate_commutatorElement : g₃ * ⁅g₁, g₂⁆ * g₃⁻¹ = ⁅g₃ * g₁ * g₃⁻¹, g₃ * g₂ * g₃⁻¹⁆ :=
map_commutatorElement (MulAut.conj g₃).toMonoidHom g₁ g₂
#align conjugate_commutator_element conjugate_commutatorElement
namespace Subgroup
/-- The commutator of two subgroups `H₁` and `H₂`. -/
instance commutator : Bracket (Subgroup G) (Subgroup G) :=
⟨fun H₁ H₂ => closure { g | ∃ g₁ ∈ H₁, ∃ g₂ ∈ H₂, ⁅g₁, g₂⁆ = g }⟩
#align subgroup.commutator Subgroup.commutator
theorem commutator_def (H₁ H₂ : Subgroup G) :
⁅H₁, H₂⁆ = closure { g | ∃ g₁ ∈ H₁, ∃ g₂ ∈ H₂, ⁅g₁, g₂⁆ = g } :=
rfl
#align subgroup.commutator_def Subgroup.commutator_def
variable {g₁ g₂ g₃} {H₁ H₂ H₃ K₁ K₂ : Subgroup G}
theorem commutator_mem_commutator (h₁ : g₁ ∈ H₁) (h₂ : g₂ ∈ H₂) : ⁅g₁, g₂⁆ ∈ ⁅H₁, H₂⁆ :=
subset_closure ⟨g₁, h₁, g₂, h₂, rfl⟩
#align subgroup.commutator_mem_commutator Subgroup.commutator_mem_commutator
theorem commutator_le : ⁅H₁, H₂⁆ ≤ H₃ ↔ ∀ g₁ ∈ H₁, ∀ g₂ ∈ H₂, ⁅g₁, g₂⁆ ∈ H₃ :=
H₃.closure_le.trans
⟨fun h a b c d => h ⟨a, b, c, d, rfl⟩, fun h _g ⟨a, b, c, d, h_eq⟩ => h_eq ▸ h a b c d⟩
#align subgroup.commutator_le Subgroup.commutator_le
theorem commutator_mono (h₁ : H₁ ≤ K₁) (h₂ : H₂ ≤ K₂) : ⁅H₁, H₂⁆ ≤ ⁅K₁, K₂⁆ :=
commutator_le.mpr fun _g₁ hg₁ _g₂ hg₂ => commutator_mem_commutator (h₁ hg₁) (h₂ hg₂)
#align subgroup.commutator_mono Subgroup.commutator_mono
| Mathlib/GroupTheory/Commutator.lean | 100 | 104 | theorem commutator_eq_bot_iff_le_centralizer : ⁅H₁, H₂⁆ = ⊥ ↔ H₁ ≤ centralizer H₂ := by |
rw [eq_bot_iff, commutator_le]
refine forall_congr' fun p =>
forall_congr' fun _hp => forall_congr' fun q => forall_congr' fun hq => ?_
rw [mem_bot, commutatorElement_eq_one_iff_mul_comm, eq_comm]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Floris van Doorn, Sébastien Gouëzel, Alex J. Best
-/
import Mathlib.Algebra.Divisibility.Basic
import Mathlib.Algebra.Group.Int
import Mathlib.Algebra.Group.Nat
import Mathlib.Algebra.Group.Opposite
import Mathlib.Algebra.Group.Units
import Mathlib.Data.List.Perm
import Mathlib.Data.List.ProdSigma
import Mathlib.Data.List.Range
import Mathlib.Data.List.Rotate
#align_import data.list.big_operators.basic from "leanprover-community/mathlib"@"6c5f73fd6f6cc83122788a80a27cdd54663609f4"
/-!
# Sums and products from lists
This file provides basic results about `List.prod`, `List.sum`, which calculate the product and sum
of elements of a list and `List.alternatingProd`, `List.alternatingSum`, their alternating
counterparts.
-/
-- Make sure we haven't imported `Data.Nat.Order.Basic`
assert_not_exists OrderedSub
assert_not_exists Ring
variable {ι α β M N P G : Type*}
namespace List
section Defs
/-- Product of a list.
`List.prod [a, b, c] = ((1 * a) * b) * c` -/
@[to_additive "Sum of a list.\n\n`List.sum [a, b, c] = ((0 + a) + b) + c`"]
def prod {α} [Mul α] [One α] : List α → α :=
foldl (· * ·) 1
#align list.prod List.prod
#align list.sum List.sum
/-- The alternating sum of a list. -/
def alternatingSum {G : Type*} [Zero G] [Add G] [Neg G] : List G → G
| [] => 0
| g :: [] => g
| g :: h :: t => g + -h + alternatingSum t
#align list.alternating_sum List.alternatingSum
/-- The alternating product of a list. -/
@[to_additive existing]
def alternatingProd {G : Type*} [One G] [Mul G] [Inv G] : List G → G
| [] => 1
| g :: [] => g
| g :: h :: t => g * h⁻¹ * alternatingProd t
#align list.alternating_prod List.alternatingProd
end Defs
section MulOneClass
variable [MulOneClass M] {l : List M} {a : M}
@[to_additive (attr := simp)]
theorem prod_nil : ([] : List M).prod = 1 :=
rfl
#align list.prod_nil List.prod_nil
#align list.sum_nil List.sum_nil
@[to_additive]
theorem prod_singleton : [a].prod = a :=
one_mul a
#align list.prod_singleton List.prod_singleton
#align list.sum_singleton List.sum_singleton
@[to_additive (attr := simp)]
theorem prod_one_cons : (1 :: l).prod = l.prod := by
rw [prod, foldl, mul_one]
@[to_additive]
theorem prod_map_one {l : List ι} :
(l.map fun _ => (1 : M)).prod = 1 := by
induction l with
| nil => rfl
| cons hd tl ih => rw [map_cons, prod_one_cons, ih]
end MulOneClass
section Monoid
variable [Monoid M] [Monoid N] [Monoid P] {l l₁ l₂ : List M} {a : M}
@[to_additive (attr := simp)]
theorem prod_cons : (a :: l).prod = a * l.prod :=
calc
(a :: l).prod = foldl (· * ·) (a * 1) l := by
simp only [List.prod, foldl_cons, one_mul, mul_one]
_ = _ := foldl_assoc
#align list.prod_cons List.prod_cons
#align list.sum_cons List.sum_cons
@[to_additive]
lemma prod_induction
(p : M → Prop) (hom : ∀ a b, p a → p b → p (a * b)) (unit : p 1) (base : ∀ x ∈ l, p x) :
p l.prod := by
induction' l with a l ih
· simpa
rw [List.prod_cons]
simp only [Bool.not_eq_true, List.mem_cons, forall_eq_or_imp] at base
exact hom _ _ (base.1) (ih base.2)
@[to_additive (attr := simp)]
theorem prod_append : (l₁ ++ l₂).prod = l₁.prod * l₂.prod :=
calc
(l₁ ++ l₂).prod = foldl (· * ·) (foldl (· * ·) 1 l₁ * 1) l₂ := by simp [List.prod]
_ = l₁.prod * l₂.prod := foldl_assoc
#align list.prod_append List.prod_append
#align list.sum_append List.sum_append
@[to_additive]
| Mathlib/Algebra/BigOperators/Group/List.lean | 122 | 123 | theorem prod_concat : (l.concat a).prod = l.prod * a := by |
rw [concat_eq_append, prod_append, prod_singleton]
|
/-
Copyright (c) 2022 Moritz Doll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Doll
-/
import Mathlib.LinearAlgebra.Basis
import Mathlib.LinearAlgebra.BilinearMap
#align_import linear_algebra.basis.bilinear from "leanprover-community/mathlib"@"87c54600fe3cdc7d32ff5b50873ac724d86aef8d"
/-!
# Lemmas about bilinear maps with a basis over each argument
-/
namespace LinearMap
variable {ι₁ ι₂ : Type*}
variable {R R₂ S S₂ M N P Rₗ : Type*}
variable {Mₗ Nₗ Pₗ : Type*}
-- Could weaken [CommSemiring Rₗ] to [SMulCommClass Rₗ Rₗ Pₗ], but might impact performance
variable [Semiring R] [Semiring S] [Semiring R₂] [Semiring S₂] [CommSemiring Rₗ]
section AddCommMonoid
variable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P]
variable [AddCommMonoid Mₗ] [AddCommMonoid Nₗ] [AddCommMonoid Pₗ]
variable [Module R M] [Module S N] [Module R₂ P] [Module S₂ P]
variable [Module Rₗ Mₗ] [Module Rₗ Nₗ] [Module Rₗ Pₗ]
variable [SMulCommClass S₂ R₂ P]
variable {ρ₁₂ : R →+* R₂} {σ₁₂ : S →+* S₂}
variable (b₁ : Basis ι₁ R M) (b₂ : Basis ι₂ S N) (b₁' : Basis ι₁ Rₗ Mₗ) (b₂' : Basis ι₂ Rₗ Nₗ)
/-- Two bilinear maps are equal when they are equal on all basis vectors. -/
theorem ext_basis {B B' : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P} (h : ∀ i j, B (b₁ i) (b₂ j) = B' (b₁ i) (b₂ j)) :
B = B' :=
b₁.ext fun i => b₂.ext fun j => h i j
#align linear_map.ext_basis LinearMap.ext_basis
/-- Write out `B x y` as a sum over `B (b i) (b j)` if `b` is a basis.
Version for semi-bilinear maps, see `sum_repr_mul_repr_mul` for the bilinear version. -/
theorem sum_repr_mul_repr_mulₛₗ {B : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P} (x y) :
((b₁.repr x).sum fun i xi => (b₂.repr y).sum fun j yj => ρ₁₂ xi • σ₁₂ yj • B (b₁ i) (b₂ j)) =
B x y := by
conv_rhs => rw [← b₁.total_repr x, ← b₂.total_repr y]
simp_rw [Finsupp.total_apply, Finsupp.sum, map_sum₂, map_sum, LinearMap.map_smulₛₗ₂,
LinearMap.map_smulₛₗ]
#align linear_map.sum_repr_mul_repr_mulₛₗ LinearMap.sum_repr_mul_repr_mulₛₗ
/-- Write out `B x y` as a sum over `B (b i) (b j)` if `b` is a basis.
Version for bilinear maps, see `sum_repr_mul_repr_mulₛₗ` for the semi-bilinear version. -/
| Mathlib/LinearAlgebra/Basis/Bilinear.lean | 55 | 60 | theorem sum_repr_mul_repr_mul {B : Mₗ →ₗ[Rₗ] Nₗ →ₗ[Rₗ] Pₗ} (x y) :
((b₁'.repr x).sum fun i xi => (b₂'.repr y).sum fun j yj => xi • yj • B (b₁' i) (b₂' j)) =
B x y := by |
conv_rhs => rw [← b₁'.total_repr x, ← b₂'.total_repr y]
simp_rw [Finsupp.total_apply, Finsupp.sum, map_sum₂, map_sum, LinearMap.map_smul₂,
LinearMap.map_smul]
|
/-
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.MeasureTheory.Constructions.BorelSpace.Metric
import Mathlib.Topology.Metrizable.Basic
import Mathlib.Topology.IndicatorConstPointwise
#align_import measure_theory.constructions.borel_space.metrizable from "leanprover-community/mathlib"@"bf6a01357ff5684b1ebcd0f1a13be314fc82c0bf"
/-!
# Measurable functions in (pseudo-)metrizable Borel spaces
-/
open Filter MeasureTheory TopologicalSpace
open scoped Classical
open Topology NNReal ENNReal MeasureTheory
variable {α β : Type*} [MeasurableSpace α]
section Limits
variable [TopologicalSpace β] [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β]
open Metric
/-- A limit (over a general filter) of measurable functions valued in a (pseudo) metrizable space is
measurable. -/
theorem measurable_of_tendsto_metrizable' {ι} {f : ι → α → β} {g : α → β} (u : Filter ι) [NeBot u]
[IsCountablyGenerated u] (hf : ∀ i, Measurable (f i)) (lim : Tendsto f u (𝓝 g)) :
Measurable g := by
letI : PseudoMetricSpace β := pseudoMetrizableSpacePseudoMetric β
apply measurable_of_isClosed'
intro s h1s h2s h3s
have : Measurable fun x => infNndist (g x) s := by
suffices Tendsto (fun i x => infNndist (f i x) s) u (𝓝 fun x => infNndist (g x) s) from
NNReal.measurable_of_tendsto' u (fun i => (hf i).infNndist) this
rw [tendsto_pi_nhds] at lim ⊢
intro x
exact ((continuous_infNndist_pt s).tendsto (g x)).comp (lim x)
have h4s : g ⁻¹' s = (fun x => infNndist (g x) s) ⁻¹' {0} := by
ext x
simp [h1s, ← h1s.mem_iff_infDist_zero h2s, ← NNReal.coe_eq_zero]
rw [h4s]
exact this (measurableSet_singleton 0)
#align measurable_of_tendsto_metrizable' measurable_of_tendsto_metrizable'
/-- A sequential limit of measurable functions valued in a (pseudo) metrizable space is
measurable. -/
theorem measurable_of_tendsto_metrizable {f : ℕ → α → β} {g : α → β} (hf : ∀ i, Measurable (f i))
(lim : Tendsto f atTop (𝓝 g)) : Measurable g :=
measurable_of_tendsto_metrizable' atTop hf lim
#align measurable_of_tendsto_metrizable measurable_of_tendsto_metrizable
| Mathlib/MeasureTheory/Constructions/BorelSpace/Metrizable.lean | 57 | 78 | theorem aemeasurable_of_tendsto_metrizable_ae {ι} {μ : Measure α} {f : ι → α → β} {g : α → β}
(u : Filter ι) [hu : NeBot u] [IsCountablyGenerated u] (hf : ∀ n, AEMeasurable (f n) μ)
(h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) u (𝓝 (g x))) : AEMeasurable g μ := by |
rcases u.exists_seq_tendsto with ⟨v, hv⟩
have h'f : ∀ n, AEMeasurable (f (v n)) μ := fun n => hf (v n)
set p : α → (ℕ → β) → Prop := fun x f' => Tendsto (fun n => f' n) atTop (𝓝 (g x))
have hp : ∀ᵐ x ∂μ, p x fun n => f (v n) x := by
filter_upwards [h_tendsto] with x hx using hx.comp hv
set aeSeqLim := fun x => ite (x ∈ aeSeqSet h'f p) (g x) (⟨f (v 0) x⟩ : Nonempty β).some
refine
⟨aeSeqLim,
measurable_of_tendsto_metrizable' atTop (aeSeq.measurable h'f p)
(tendsto_pi_nhds.mpr fun x => ?_),
?_⟩
· simp_rw [aeSeqLim, aeSeq]
split_ifs with hx
· simp_rw [aeSeq.mk_eq_fun_of_mem_aeSeqSet h'f hx]
exact @aeSeq.fun_prop_of_mem_aeSeqSet _ α β _ _ _ _ _ h'f x hx
· exact tendsto_const_nhds
· exact
(ite_ae_eq_of_measure_compl_zero g (fun x => (⟨f (v 0) x⟩ : Nonempty β).some) (aeSeqSet h'f p)
(aeSeq.measure_compl_aeSeqSet_eq_zero h'f hp)).symm
|
/-
Copyright (c) 2020 Patrick Stevens. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Stevens, Yury Kudryashov
-/
import Mathlib.Algebra.BigOperators.Associated
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Data.Nat.Choose.Sum
import Mathlib.Data.Nat.Choose.Dvd
import Mathlib.Data.Nat.Prime
#align_import number_theory.primorial from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977"
/-!
# Primorial
This file defines the primorial function (the product of primes less than or equal to some bound),
and proves that `primorial n ≤ 4 ^ n`.
## Notations
We use the local notation `n#` for the primorial of `n`: that is, the product of the primes less
than or equal to `n`.
-/
open Finset
open Nat
open Nat
/-- The primorial `n#` of `n` is the product of the primes less than or equal to `n`.
-/
def primorial (n : ℕ) : ℕ :=
∏ p ∈ filter Nat.Prime (range (n + 1)), p
#align primorial primorial
local notation x "#" => primorial x
theorem primorial_pos (n : ℕ) : 0 < n# :=
prod_pos fun _p hp ↦ (mem_filter.1 hp).2.pos
#align primorial_pos primorial_pos
theorem primorial_succ {n : ℕ} (hn1 : n ≠ 1) (hn : Odd n) : (n + 1)# = n# := by
refine prod_congr ?_ fun _ _ ↦ rfl
rw [range_succ, filter_insert, if_neg fun h ↦ odd_iff_not_even.mp hn _]
exact fun h ↦ h.even_sub_one <| mt succ.inj hn1
#align primorial_succ primorial_succ
| Mathlib/NumberTheory/Primorial.lean | 51 | 55 | theorem primorial_add (m n : ℕ) :
(m + n)# = m# * ∏ p ∈ filter Nat.Prime (Ico (m + 1) (m + n + 1)), p := by |
rw [primorial, primorial, ← Ico_zero_eq_range, ← prod_union, ← filter_union, Ico_union_Ico_eq_Ico]
exacts [Nat.zero_le _, add_le_add_right (Nat.le_add_right _ _) _,
disjoint_filter_filter <| Ico_disjoint_Ico_consecutive _ _ _]
|
/-
Copyright (c) 2023 Rémi Bottinelli. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rémi Bottinelli
-/
import Mathlib.Data.Set.Function
import Mathlib.Analysis.BoundedVariation
#align_import analysis.constant_speed from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
/-!
# Constant speed
This file defines the notion of constant (and unit) speed for a function `f : ℝ → E` with
pseudo-emetric structure on `E` with respect to a set `s : Set ℝ` and "speed" `l : ℝ≥0`, and shows
that if `f` has locally bounded variation on `s`, it can be obtained (up to distance zero, on `s`),
as a composite `φ ∘ (variationOnFromTo f s a)`, where `φ` has unit speed and `a ∈ s`.
## Main definitions
* `HasConstantSpeedOnWith f s l`, stating that the speed of `f` on `s` is `l`.
* `HasUnitSpeedOn f s`, stating that the speed of `f` on `s` is `1`.
* `naturalParameterization f s a : ℝ → E`, the unit speed reparameterization of `f` on `s` relative
to `a`.
## Main statements
* `unique_unit_speed_on_Icc_zero` proves that if `f` and `f ∘ φ` are both naturally
parameterized on closed intervals starting at `0`, then `φ` must be the identity on
those intervals.
* `edist_naturalParameterization_eq_zero` proves that if `f` has locally bounded variation, then
precomposing `naturalParameterization f s a` with `variationOnFromTo f s a` yields a function
at distance zero from `f` on `s`.
* `has_unit_speed_naturalParameterization` proves that if `f` has locally bounded
variation, then `naturalParameterization f s a` has unit speed on `s`.
## Tags
arc-length, parameterization
-/
open scoped NNReal ENNReal
open Set MeasureTheory Classical
variable {α : Type*} [LinearOrder α] {E : Type*} [PseudoEMetricSpace E]
variable (f : ℝ → E) (s : Set ℝ) (l : ℝ≥0)
/-- `f` has constant speed `l` on `s` if the variation of `f` on `s ∩ Icc x y` is equal to
`l * (y - x)` for any `x y` in `s`.
-/
def HasConstantSpeedOnWith :=
∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s), eVariationOn f (s ∩ Icc x y) = ENNReal.ofReal (l * (y - x))
#align has_constant_speed_on_with HasConstantSpeedOnWith
variable {f s l}
theorem HasConstantSpeedOnWith.hasLocallyBoundedVariationOn (h : HasConstantSpeedOnWith f s l) :
LocallyBoundedVariationOn f s := fun x y hx hy => by
simp only [BoundedVariationOn, h hx hy, Ne, ENNReal.ofReal_ne_top, not_false_iff]
#align has_constant_speed_on_with.has_locally_bounded_variation_on HasConstantSpeedOnWith.hasLocallyBoundedVariationOn
theorem hasConstantSpeedOnWith_of_subsingleton (f : ℝ → E) {s : Set ℝ} (hs : s.Subsingleton)
(l : ℝ≥0) : HasConstantSpeedOnWith f s l := by
rintro x hx y hy; cases hs hx hy
rw [eVariationOn.subsingleton f (fun y hy z hz => hs hy.1 hz.1 : (s ∩ Icc x x).Subsingleton)]
simp only [sub_self, mul_zero, ENNReal.ofReal_zero]
#align has_constant_speed_on_with_of_subsingleton hasConstantSpeedOnWith_of_subsingleton
| Mathlib/Analysis/ConstantSpeed.lean | 71 | 82 | theorem hasConstantSpeedOnWith_iff_ordered :
HasConstantSpeedOnWith f s l ↔ ∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s),
x ≤ y → eVariationOn f (s ∩ Icc x y) = ENNReal.ofReal (l * (y - x)) := by |
refine ⟨fun h x xs y ys _ => h xs ys, fun h x xs y ys => ?_⟩
rcases le_total x y with (xy | yx)
· exact h xs ys xy
· rw [eVariationOn.subsingleton, ENNReal.ofReal_of_nonpos]
· exact mul_nonpos_of_nonneg_of_nonpos l.prop (sub_nonpos_of_le yx)
· rintro z ⟨zs, xz, zy⟩ w ⟨ws, xw, wy⟩
cases le_antisymm (zy.trans yx) xz
cases le_antisymm (wy.trans yx) xw
rfl
|
/-
Copyright (c) 2023 Richard M. Hill. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Richard M. Hill
-/
import Mathlib.RingTheory.PowerSeries.Trunc
import Mathlib.RingTheory.PowerSeries.Inverse
import Mathlib.RingTheory.Derivation.Basic
/-!
# Definitions
In this file we define an operation `derivative` (formal differentiation)
on the ring of formal power series in one variable (over an arbitrary commutative semiring).
Under suitable assumptions, we prove that two power series are equal if their derivatives
are equal and their constant terms are equal. This will give us a simple tool for proving
power series identities. For example, one can easily prove the power series identity
$\exp ( \log (1+X)) = 1+X$ by differentiating twice.
## Main Definition
- `PowerSeries.derivative R : Derivation R R⟦X⟧ R⟦X⟧` the formal derivative operation.
This is abbreviated `d⁄dX R`.
-/
namespace PowerSeries
open Polynomial Derivation Nat
section CommutativeSemiring
variable {R} [CommSemiring R]
/--
The formal derivative of a power series in one variable.
This is defined here as a function, but will be packaged as a
derivation `derivative` on `R⟦X⟧`.
-/
noncomputable def derivativeFun (f : R⟦X⟧) : R⟦X⟧ := mk fun n ↦ coeff R (n + 1) f * (n + 1)
theorem coeff_derivativeFun (f : R⟦X⟧) (n : ℕ) :
coeff R n f.derivativeFun = coeff R (n + 1) f * (n + 1) := by
rw [derivativeFun, coeff_mk]
| Mathlib/RingTheory/PowerSeries/Derivative.lean | 45 | 47 | theorem derivativeFun_coe (f : R[X]) : (f : R⟦X⟧).derivativeFun = derivative f := by |
ext
rw [coeff_derivativeFun, coeff_coe, coeff_coe, coeff_derivative]
|
/-
Copyright (c) 2021 Riccardo Brasca. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Riccardo Brasca
-/
import Mathlib.LinearAlgebra.Dimension.LinearMap
import Mathlib.LinearAlgebra.FreeModule.StrongRankCondition
#align_import linear_algebra.free_module.finite.matrix from "leanprover-community/mathlib"@"b1c23399f01266afe392a0d8f71f599a0dad4f7b"
/-!
# Finite and free modules using matrices
We provide some instances for finite and free modules involving matrices.
## Main results
* `Module.Free.linearMap` : if `M` and `N` are finite and free, then `M →ₗ[R] N` is free.
* `Module.Finite.ofBasis` : A free module with a basis indexed by a `Fintype` is finite.
* `Module.Finite.linearMap` : if `M` and `N` are finite and free, then `M →ₗ[R] N`
is finite.
-/
universe u u' v w
variable (R : Type u) (S : Type u') (M : Type v) (N : Type w)
open Module.Free (chooseBasis ChooseBasisIndex)
open FiniteDimensional (finrank)
section Ring
variable [Ring R] [Ring S] [AddCommGroup M] [Module R M] [Module.Free R M] [Module.Finite R M]
variable [AddCommGroup N] [Module R N] [Module S N] [SMulCommClass R S N]
private noncomputable def linearMapEquivFun : (M →ₗ[R] N) ≃ₗ[S] ChooseBasisIndex R M → N :=
(chooseBasis R M).repr.congrLeft N S ≪≫ₗ (Finsupp.lsum S).symm ≪≫ₗ
LinearEquiv.piCongrRight fun _ ↦ LinearMap.ringLmapEquivSelf R S N
instance Module.Free.linearMap [Module.Free S N] : Module.Free S (M →ₗ[R] N) :=
Module.Free.of_equiv (linearMapEquivFun R S M N).symm
#align module.free.linear_map Module.Free.linearMap
instance Module.Finite.linearMap [Module.Finite S N] : Module.Finite S (M →ₗ[R] N) :=
Module.Finite.equiv (linearMapEquivFun R S M N).symm
#align module.finite.linear_map Module.Finite.linearMap
variable [StrongRankCondition R] [StrongRankCondition S] [Module.Free S N]
open Cardinal
theorem FiniteDimensional.rank_linearMap :
Module.rank S (M →ₗ[R] N) = lift.{w} (Module.rank R M) * lift.{v} (Module.rank S N) := by
rw [(linearMapEquivFun R S M N).rank_eq, rank_fun_eq_lift_mul,
← finrank_eq_card_chooseBasisIndex, ← finrank_eq_rank R, lift_natCast]
/-- The finrank of `M →ₗ[R] N` as an `S`-module is `(finrank R M) * (finrank S N)`. -/
| Mathlib/LinearAlgebra/FreeModule/Finite/Matrix.lean | 59 | 61 | theorem FiniteDimensional.finrank_linearMap :
finrank S (M →ₗ[R] N) = finrank R M * finrank S N := by |
simp_rw [finrank, rank_linearMap, toNat_mul, toNat_lift]
|
/-
Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-/
import Mathlib.RingTheory.Nilpotent.Basic
import Mathlib.RingTheory.UniqueFactorizationDomain
#align_import algebra.squarefree from "leanprover-community/mathlib"@"00d163e35035c3577c1c79fa53b68de17781ffc1"
/-!
# Squarefree elements of monoids
An element of a monoid is squarefree when it is not divisible by any squares
except the squares of units.
Results about squarefree natural numbers are proved in `Data.Nat.Squarefree`.
## Main Definitions
- `Squarefree r` indicates that `r` is only divisible by `x * x` if `x` is a unit.
## Main Results
- `multiplicity.squarefree_iff_multiplicity_le_one`: `x` is `Squarefree` iff for every `y`, either
`multiplicity y x ≤ 1` or `IsUnit y`.
- `UniqueFactorizationMonoid.squarefree_iff_nodup_factors`: A nonzero element `x` of a unique
factorization monoid is squarefree iff `factors x` has no duplicate factors.
## Tags
squarefree, multiplicity
-/
variable {R : Type*}
/-- An element of a monoid is squarefree if the only squares that
divide it are the squares of units. -/
def Squarefree [Monoid R] (r : R) : Prop :=
∀ x : R, x * x ∣ r → IsUnit x
#align squarefree Squarefree
theorem IsRelPrime.of_squarefree_mul [CommMonoid R] {m n : R} (h : Squarefree (m * n)) :
IsRelPrime m n := fun c hca hcb ↦ h c (mul_dvd_mul hca hcb)
@[simp]
theorem IsUnit.squarefree [CommMonoid R] {x : R} (h : IsUnit x) : Squarefree x := fun _ hdvd =>
isUnit_of_mul_isUnit_left (isUnit_of_dvd_unit hdvd h)
#align is_unit.squarefree IsUnit.squarefree
-- @[simp] -- Porting note (#10618): simp can prove this
theorem squarefree_one [CommMonoid R] : Squarefree (1 : R) :=
isUnit_one.squarefree
#align squarefree_one squarefree_one
@[simp]
| Mathlib/Algebra/Squarefree/Basic.lean | 55 | 57 | theorem not_squarefree_zero [MonoidWithZero R] [Nontrivial R] : ¬Squarefree (0 : R) := by |
erw [not_forall]
exact ⟨0, by simp⟩
|
/-
Copyright (c) 2023 Kexing Ying. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying
-/
import Mathlib.Probability.Kernel.Composition
#align_import probability.kernel.invariance from "leanprover-community/mathlib"@"3b92d54a05ee592aa2c6181a4e76b1bb7cc45d0b"
/-!
# Invariance of measures along a kernel
We say that a measure `μ` is invariant with respect to a kernel `κ` if its push-forward along the
kernel `μ.bind κ` is the same measure.
## Main definitions
* `ProbabilityTheory.kernel.Invariant`: invariance of a given measure with respect to a kernel.
## Useful lemmas
* `ProbabilityTheory.kernel.const_bind_eq_comp_const`, and
`ProbabilityTheory.kernel.comp_const_apply_eq_bind` established the relationship between
the push-forward measure and the composition of kernels.
-/
open MeasureTheory
open scoped MeasureTheory ENNReal ProbabilityTheory
namespace ProbabilityTheory
variable {α β γ : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ}
namespace kernel
/-! ### Push-forward of measures along a kernel -/
@[simp]
| Mathlib/Probability/Kernel/Invariance.lean | 43 | 47 | theorem bind_add (μ ν : Measure α) (κ : kernel α β) : (μ + ν).bind κ = μ.bind κ + ν.bind κ := by |
ext1 s hs
rw [Measure.bind_apply hs (kernel.measurable _), lintegral_add_measure, Measure.coe_add,
Pi.add_apply, Measure.bind_apply hs (kernel.measurable _),
Measure.bind_apply hs (kernel.measurable _)]
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa, Junyan Xu
-/
import Mathlib.Data.DFinsupp.Basic
#align_import data.dfinsupp.ne_locus from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c"
/-!
# Locus of unequal values of finitely supported dependent functions
Let `N : α → Type*` be a type family, assume that `N a` has a `0` for all `a : α` and let
`f g : Π₀ a, N a` be finitely supported dependent functions.
## Main definition
* `DFinsupp.neLocus f g : Finset α`, the finite subset of `α` where `f` and `g` differ.
In the case in which `N a` is an additive group for all `a`, `DFinsupp.neLocus f g` coincides with
`DFinsupp.support (f - g)`.
-/
variable {α : Type*} {N : α → Type*}
namespace DFinsupp
variable [DecidableEq α]
section NHasZero
variable [∀ a, DecidableEq (N a)] [∀ a, Zero (N a)] (f g : Π₀ a, N a)
/-- Given two finitely supported functions `f g : α →₀ N`, `Finsupp.neLocus f g` is the `Finset`
where `f` and `g` differ. This generalizes `(f - g).support` to situations without subtraction. -/
def neLocus (f g : Π₀ a, N a) : Finset α :=
(f.support ∪ g.support).filter fun x ↦ f x ≠ g x
#align dfinsupp.ne_locus DFinsupp.neLocus
@[simp]
theorem mem_neLocus {f g : Π₀ a, N a} {a : α} : a ∈ f.neLocus g ↔ f a ≠ g a := by
simpa only [neLocus, Finset.mem_filter, Finset.mem_union, mem_support_iff,
and_iff_right_iff_imp] using Ne.ne_or_ne _
#align dfinsupp.mem_ne_locus DFinsupp.mem_neLocus
theorem not_mem_neLocus {f g : Π₀ a, N a} {a : α} : a ∉ f.neLocus g ↔ f a = g a :=
mem_neLocus.not.trans not_ne_iff
#align dfinsupp.not_mem_ne_locus DFinsupp.not_mem_neLocus
@[simp]
theorem coe_neLocus : ↑(f.neLocus g) = { x | f x ≠ g x } :=
Set.ext fun _x ↦ mem_neLocus
#align dfinsupp.coe_ne_locus DFinsupp.coe_neLocus
@[simp]
theorem neLocus_eq_empty {f g : Π₀ a, N a} : f.neLocus g = ∅ ↔ f = g :=
⟨fun h ↦
ext fun a ↦ not_not.mp (mem_neLocus.not.mp (Finset.eq_empty_iff_forall_not_mem.mp h a)),
fun h ↦ h ▸ by simp only [neLocus, Ne, eq_self_iff_true, not_true, Finset.filter_False]⟩
#align dfinsupp.ne_locus_eq_empty DFinsupp.neLocus_eq_empty
@[simp]
theorem nonempty_neLocus_iff {f g : Π₀ a, N a} : (f.neLocus g).Nonempty ↔ f ≠ g :=
Finset.nonempty_iff_ne_empty.trans neLocus_eq_empty.not
#align dfinsupp.nonempty_ne_locus_iff DFinsupp.nonempty_neLocus_iff
| Mathlib/Data/DFinsupp/NeLocus.lean | 67 | 68 | theorem neLocus_comm : f.neLocus g = g.neLocus f := by |
simp_rw [neLocus, Finset.union_comm, ne_comm]
|
/-
Copyright (c) 2022 Anatole Dedecker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker
-/
import Mathlib.Analysis.InnerProductSpace.Adjoint
#align_import analysis.inner_product_space.positive from "leanprover-community/mathlib"@"caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c"
/-!
# Positive operators
In this file we define positive operators in a Hilbert space. We follow Bourbaki's choice
of requiring self adjointness in the definition.
## Main definitions
* `IsPositive` : a continuous linear map is positive if it is self adjoint and
`∀ x, 0 ≤ re ⟪T x, x⟫`
## Main statements
* `ContinuousLinearMap.IsPositive.conj_adjoint` : if `T : E →L[𝕜] E` is positive,
then for any `S : E →L[𝕜] F`, `S ∘L T ∘L S†` is also positive.
* `ContinuousLinearMap.isPositive_iff_complex` : in a ***complex*** Hilbert space,
checking that `⟪T x, x⟫` is a nonnegative real number for all `x` suffices to prove that
`T` is positive
## References
* [Bourbaki, *Topological Vector Spaces*][bourbaki1987]
## Tags
Positive operator
-/
open InnerProductSpace RCLike ContinuousLinearMap
open scoped InnerProduct ComplexConjugate
namespace ContinuousLinearMap
variable {𝕜 E F : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup E] [NormedAddCommGroup F]
variable [InnerProductSpace 𝕜 E] [InnerProductSpace 𝕜 F]
variable [CompleteSpace E] [CompleteSpace F]
local notation "⟪" x ", " y "⟫" => @inner 𝕜 _ _ x y
/-- A continuous linear endomorphism `T` of a Hilbert space is **positive** if it is self adjoint
and `∀ x, 0 ≤ re ⟪T x, x⟫`. -/
def IsPositive (T : E →L[𝕜] E) : Prop :=
IsSelfAdjoint T ∧ ∀ x, 0 ≤ T.reApplyInnerSelf x
#align continuous_linear_map.is_positive ContinuousLinearMap.IsPositive
theorem IsPositive.isSelfAdjoint {T : E →L[𝕜] E} (hT : IsPositive T) : IsSelfAdjoint T :=
hT.1
#align continuous_linear_map.is_positive.is_self_adjoint ContinuousLinearMap.IsPositive.isSelfAdjoint
theorem IsPositive.inner_nonneg_left {T : E →L[𝕜] E} (hT : IsPositive T) (x : E) :
0 ≤ re ⟪T x, x⟫ :=
hT.2 x
#align continuous_linear_map.is_positive.inner_nonneg_left ContinuousLinearMap.IsPositive.inner_nonneg_left
theorem IsPositive.inner_nonneg_right {T : E →L[𝕜] E} (hT : IsPositive T) (x : E) :
0 ≤ re ⟪x, T x⟫ := by rw [inner_re_symm]; exact hT.inner_nonneg_left x
#align continuous_linear_map.is_positive.inner_nonneg_right ContinuousLinearMap.IsPositive.inner_nonneg_right
theorem isPositive_zero : IsPositive (0 : E →L[𝕜] E) := by
refine ⟨isSelfAdjoint_zero _, fun x => ?_⟩
change 0 ≤ re ⟪_, _⟫
rw [zero_apply, inner_zero_left, ZeroHomClass.map_zero]
#align continuous_linear_map.is_positive_zero ContinuousLinearMap.isPositive_zero
theorem isPositive_one : IsPositive (1 : E →L[𝕜] E) :=
⟨isSelfAdjoint_one _, fun _ => inner_self_nonneg⟩
#align continuous_linear_map.is_positive_one ContinuousLinearMap.isPositive_one
theorem IsPositive.add {T S : E →L[𝕜] E} (hT : T.IsPositive) (hS : S.IsPositive) :
(T + S).IsPositive := by
refine ⟨hT.isSelfAdjoint.add hS.isSelfAdjoint, fun x => ?_⟩
rw [reApplyInnerSelf, add_apply, inner_add_left, map_add]
exact add_nonneg (hT.inner_nonneg_left x) (hS.inner_nonneg_left x)
#align continuous_linear_map.is_positive.add ContinuousLinearMap.IsPositive.add
theorem IsPositive.conj_adjoint {T : E →L[𝕜] E} (hT : T.IsPositive) (S : E →L[𝕜] F) :
(S ∘L T ∘L S†).IsPositive := by
refine ⟨hT.isSelfAdjoint.conj_adjoint S, fun x => ?_⟩
rw [reApplyInnerSelf, comp_apply, ← adjoint_inner_right]
exact hT.inner_nonneg_left _
#align continuous_linear_map.is_positive.conj_adjoint ContinuousLinearMap.IsPositive.conj_adjoint
theorem IsPositive.adjoint_conj {T : E →L[𝕜] E} (hT : T.IsPositive) (S : F →L[𝕜] E) :
(S† ∘L T ∘L S).IsPositive := by
convert hT.conj_adjoint (S†)
rw [adjoint_adjoint]
#align continuous_linear_map.is_positive.adjoint_conj ContinuousLinearMap.IsPositive.adjoint_conj
theorem IsPositive.conj_orthogonalProjection (U : Submodule 𝕜 E) {T : E →L[𝕜] E} (hT : T.IsPositive)
[CompleteSpace U] :
(U.subtypeL ∘L
orthogonalProjection U ∘L T ∘L U.subtypeL ∘L orthogonalProjection U).IsPositive := by
have := hT.conj_adjoint (U.subtypeL ∘L orthogonalProjection U)
rwa [(orthogonalProjection_isSelfAdjoint U).adjoint_eq] at this
#align continuous_linear_map.is_positive.conj_orthogonal_projection ContinuousLinearMap.IsPositive.conj_orthogonalProjection
theorem IsPositive.orthogonalProjection_comp {T : E →L[𝕜] E} (hT : T.IsPositive) (U : Submodule 𝕜 E)
[CompleteSpace U] : (orthogonalProjection U ∘L T ∘L U.subtypeL).IsPositive := by
have := hT.conj_adjoint (orthogonalProjection U : E →L[𝕜] U)
rwa [U.adjoint_orthogonalProjection] at this
#align continuous_linear_map.is_positive.orthogonal_projection_comp ContinuousLinearMap.IsPositive.orthogonalProjection_comp
section Complex
variable {E' : Type*} [NormedAddCommGroup E'] [InnerProductSpace ℂ E'] [CompleteSpace E']
| Mathlib/Analysis/InnerProductSpace/Positive.lean | 119 | 123 | theorem isPositive_iff_complex (T : E' →L[ℂ] E') :
IsPositive T ↔ ∀ x, (re ⟪T x, x⟫_ℂ : ℂ) = ⟪T x, x⟫_ℂ ∧ 0 ≤ re ⟪T x, x⟫_ℂ := by |
simp_rw [IsPositive, forall_and, isSelfAdjoint_iff_isSymmetric,
LinearMap.isSymmetric_iff_inner_map_self_real, conj_eq_iff_re]
rfl
|
/-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Yury Kudryashov
-/
import Mathlib.Algebra.Algebra.Defs
import Mathlib.Algebra.CharZero.Lemmas
import Mathlib.Algebra.Module.Submodule.Ker
import Mathlib.Algebra.Module.Submodule.RestrictScalars
import Mathlib.Algebra.Module.ULift
import Mathlib.Algebra.Ring.Subring.Basic
import Mathlib.Data.Int.CharZero
import Mathlib.Data.Rat.Cast.CharZero
#align_import algebra.algebra.basic from "leanprover-community/mathlib"@"36b8aa61ea7c05727161f96a0532897bd72aedab"
/-!
# Further basic results about `Algebra`.
This file could usefully be split further.
-/
universe u v w u₁ v₁
namespace Algebra
variable {R : Type u} {S : Type v} {A : Type w} {B : Type*}
section Semiring
variable [CommSemiring R] [CommSemiring S]
variable [Semiring A] [Algebra R A] [Semiring B] [Algebra R B]
section PUnit
instance _root_.PUnit.algebra : Algebra R PUnit.{v + 1} where
toFun _ := PUnit.unit
map_one' := rfl
map_mul' _ _ := rfl
map_zero' := rfl
map_add' _ _ := rfl
commutes' _ _ := rfl
smul_def' _ _ := rfl
#align punit.algebra PUnit.algebra
@[simp]
theorem algebraMap_pUnit (r : R) : algebraMap R PUnit r = PUnit.unit :=
rfl
#align algebra.algebra_map_punit Algebra.algebraMap_pUnit
end PUnit
section ULift
instance _root_.ULift.algebra : Algebra R (ULift A) :=
{ ULift.module',
(ULift.ringEquiv : ULift A ≃+* A).symm.toRingHom.comp (algebraMap R A) with
toFun := fun r => ULift.up (algebraMap R A r)
commutes' := fun r x => ULift.down_injective <| Algebra.commutes r x.down
smul_def' := fun r x => ULift.down_injective <| Algebra.smul_def' r x.down }
#align ulift.algebra ULift.algebra
theorem _root_.ULift.algebraMap_eq (r : R) :
algebraMap R (ULift A) r = ULift.up (algebraMap R A r) :=
rfl
#align ulift.algebra_map_eq ULift.algebraMap_eq
@[simp]
theorem _root_.ULift.down_algebraMap (r : R) : (algebraMap R (ULift A) r).down = algebraMap R A r :=
rfl
#align ulift.down_algebra_map ULift.down_algebraMap
end ULift
/-- Algebra over a subsemiring. This builds upon `Subsemiring.module`. -/
instance ofSubsemiring (S : Subsemiring R) : Algebra S A where
toRingHom := (algebraMap R A).comp S.subtype
smul := (· • ·)
commutes' r x := Algebra.commutes (r : R) x
smul_def' r x := Algebra.smul_def (r : R) x
#align algebra.of_subsemiring Algebra.ofSubsemiring
theorem algebraMap_ofSubsemiring (S : Subsemiring R) :
(algebraMap S R : S →+* R) = Subsemiring.subtype S :=
rfl
#align algebra.algebra_map_of_subsemiring Algebra.algebraMap_ofSubsemiring
theorem coe_algebraMap_ofSubsemiring (S : Subsemiring R) : (algebraMap S R : S → R) = Subtype.val :=
rfl
#align algebra.coe_algebra_map_of_subsemiring Algebra.coe_algebraMap_ofSubsemiring
theorem algebraMap_ofSubsemiring_apply (S : Subsemiring R) (x : S) : algebraMap S R x = x :=
rfl
#align algebra.algebra_map_of_subsemiring_apply Algebra.algebraMap_ofSubsemiring_apply
/-- Algebra over a subring. This builds upon `Subring.module`. -/
instance ofSubring {R A : Type*} [CommRing R] [Ring A] [Algebra R A] (S : Subring R) :
Algebra S A where -- Porting note: don't use `toSubsemiring` because of a timeout
toRingHom := (algebraMap R A).comp S.subtype
smul := (· • ·)
commutes' r x := Algebra.commutes (r : R) x
smul_def' r x := Algebra.smul_def (r : R) x
#align algebra.of_subring Algebra.ofSubring
theorem algebraMap_ofSubring {R : Type*} [CommRing R] (S : Subring R) :
(algebraMap S R : S →+* R) = Subring.subtype S :=
rfl
#align algebra.algebra_map_of_subring Algebra.algebraMap_ofSubring
theorem coe_algebraMap_ofSubring {R : Type*} [CommRing R] (S : Subring R) :
(algebraMap S R : S → R) = Subtype.val :=
rfl
#align algebra.coe_algebra_map_of_subring Algebra.coe_algebraMap_ofSubring
theorem algebraMap_ofSubring_apply {R : Type*} [CommRing R] (S : Subring R) (x : S) :
algebraMap S R x = x :=
rfl
#align algebra.algebra_map_of_subring_apply Algebra.algebraMap_ofSubring_apply
/-- Explicit characterization of the submonoid map in the case of an algebra.
`S` is made explicit to help with type inference -/
def algebraMapSubmonoid (S : Type*) [Semiring S] [Algebra R S] (M : Submonoid R) : Submonoid S :=
M.map (algebraMap R S)
#align algebra.algebra_map_submonoid Algebra.algebraMapSubmonoid
theorem mem_algebraMapSubmonoid_of_mem {S : Type*} [Semiring S] [Algebra R S] {M : Submonoid R}
(x : M) : algebraMap R S x ∈ algebraMapSubmonoid S M :=
Set.mem_image_of_mem (algebraMap R S) x.2
#align algebra.mem_algebra_map_submonoid_of_mem Algebra.mem_algebraMapSubmonoid_of_mem
end Semiring
section CommSemiring
variable [CommSemiring R]
| Mathlib/Algebra/Algebra/Basic.lean | 137 | 138 | theorem mul_sub_algebraMap_commutes [Ring A] [Algebra R A] (x : A) (r : R) :
x * (x - algebraMap R A r) = (x - algebraMap R A r) * x := by | rw [mul_sub, ← commutes, sub_mul]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.