Context stringlengths 57 6.04k | file_name stringlengths 21 79 | start int64 14 1.49k | end int64 18 1.5k | theorem stringlengths 25 1.55k | proof stringlengths 5 7.36k | eval_complexity float64 0 1 |
|---|---|---|---|---|---|---|
import Mathlib.Analysis.Convex.Between
import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic
import Mathlib.MeasureTheory.Measure.Lebesgue.Basic
import Mathlib.Topology.MetricSpace.Holder
import Mathlib.Topology.MetricSpace.MetricSeparated
#align_import measure_theory.measure.hausdorff from "leanprover-community/mathlib"@"3d5c4a7a5fb0d982f97ed953161264f1dbd90ead"
open scoped NNReal ENNReal Topology
open EMetric Set Function Filter Encodable FiniteDimensional TopologicalSpace
noncomputable section
variable {ι X Y : Type*} [EMetricSpace X] [EMetricSpace Y]
namespace MeasureTheory
namespace OuterMeasure
def IsMetric (μ : OuterMeasure X) : Prop :=
∀ s t : Set X, IsMetricSeparated s t → μ (s ∪ t) = μ s + μ t
#align measure_theory.outer_measure.is_metric MeasureTheory.OuterMeasure.IsMetric
def mkMetric'.pre (m : Set X → ℝ≥0∞) (r : ℝ≥0∞) : OuterMeasure X :=
boundedBy <| extend fun s (_ : diam s ≤ r) => m s
#align measure_theory.outer_measure.mk_metric'.pre MeasureTheory.OuterMeasure.mkMetric'.pre
def mkMetric' (m : Set X → ℝ≥0∞) : OuterMeasure X :=
⨆ r > 0, mkMetric'.pre m r
#align measure_theory.outer_measure.mk_metric' MeasureTheory.OuterMeasure.mkMetric'
def mkMetric (m : ℝ≥0∞ → ℝ≥0∞) : OuterMeasure X :=
mkMetric' fun s => m (diam s)
#align measure_theory.outer_measure.mk_metric MeasureTheory.OuterMeasure.mkMetric
namespace mkMetric'
variable {m : Set X → ℝ≥0∞} {r : ℝ≥0∞} {μ : OuterMeasure X} {s : Set X}
theorem le_pre : μ ≤ pre m r ↔ ∀ s : Set X, diam s ≤ r → μ s ≤ m s := by
simp only [pre, le_boundedBy, extend, le_iInf_iff]
#align measure_theory.outer_measure.mk_metric'.le_pre MeasureTheory.OuterMeasure.mkMetric'.le_pre
theorem pre_le (hs : diam s ≤ r) : pre m r s ≤ m s :=
(boundedBy_le _).trans <| iInf_le _ hs
#align measure_theory.outer_measure.mk_metric'.pre_le MeasureTheory.OuterMeasure.mkMetric'.pre_le
theorem mono_pre (m : Set X → ℝ≥0∞) {r r' : ℝ≥0∞} (h : r ≤ r') : pre m r' ≤ pre m r :=
le_pre.2 fun _ hs => pre_le (hs.trans h)
#align measure_theory.outer_measure.mk_metric'.mono_pre MeasureTheory.OuterMeasure.mkMetric'.mono_pre
theorem mono_pre_nat (m : Set X → ℝ≥0∞) : Monotone fun k : ℕ => pre m k⁻¹ :=
fun k l h => le_pre.2 fun s hs => pre_le (hs.trans <| by simpa)
#align measure_theory.outer_measure.mk_metric'.mono_pre_nat MeasureTheory.OuterMeasure.mkMetric'.mono_pre_nat
theorem tendsto_pre (m : Set X → ℝ≥0∞) (s : Set X) :
Tendsto (fun r => pre m r s) (𝓝[>] 0) (𝓝 <| mkMetric' m s) := by
rw [← map_coe_Ioi_atBot, tendsto_map'_iff]
simp only [mkMetric', OuterMeasure.iSup_apply, iSup_subtype']
exact tendsto_atBot_iSup fun r r' hr => mono_pre _ hr _
#align measure_theory.outer_measure.mk_metric'.tendsto_pre MeasureTheory.OuterMeasure.mkMetric'.tendsto_pre
| Mathlib/MeasureTheory/Measure/Hausdorff.lean | 293 | 297 | theorem tendsto_pre_nat (m : Set X → ℝ≥0∞) (s : Set X) :
Tendsto (fun n : ℕ => pre m n⁻¹ s) atTop (𝓝 <| mkMetric' m s) := by |
refine (tendsto_pre m s).comp (tendsto_inf.2 ⟨ENNReal.tendsto_inv_nat_nhds_zero, ?_⟩)
refine tendsto_principal.2 (eventually_of_forall fun n => ?_)
simp
| 0 |
import Mathlib.LinearAlgebra.Quotient
import Mathlib.LinearAlgebra.Prod
#align_import linear_algebra.projection from "leanprover-community/mathlib"@"6d584f1709bedbed9175bd9350df46599bdd7213"
noncomputable section Ring
variable {R : Type*} [Ring R] {E : Type*} [AddCommGroup E] [Module R E]
variable {F : Type*} [AddCommGroup F] [Module R F] {G : Type*} [AddCommGroup G] [Module R G]
variable (p q : Submodule R E)
variable {S : Type*} [Semiring S] {M : Type*} [AddCommMonoid M] [Module S M] (m : Submodule S M)
namespace LinearMap
variable {p}
open Submodule
| Mathlib/LinearAlgebra/Projection.lean | 41 | 45 | theorem ker_id_sub_eq_of_proj {f : E →ₗ[R] p} (hf : ∀ x : p, f x = x) :
ker (id - p.subtype.comp f) = p := by |
ext x
simp only [comp_apply, mem_ker, subtype_apply, sub_apply, id_apply, sub_eq_zero]
exact ⟨fun h => h.symm ▸ Submodule.coe_mem _, fun hx => by erw [hf ⟨x, hx⟩, Subtype.coe_mk]⟩
| 0 |
import Mathlib.FieldTheory.Adjoin
open Polynomial
namespace IntermediateField
variable (F E K : Type*) [Field F] [Field E] [Field K] [Algebra F E] [Algebra F K] {S : Set E}
structure Lifts where
carrier : IntermediateField F E
emb : carrier →ₐ[F] K
#align intermediate_field.lifts IntermediateField.Lifts
variable {F E K}
instance : PartialOrder (Lifts F E K) where
le L₁ L₂ := ∃ h : L₁.carrier ≤ L₂.carrier, ∀ x, L₂.emb (inclusion h x) = L₁.emb x
le_refl L := ⟨le_rfl, by simp⟩
le_trans L₁ L₂ L₃ := by
rintro ⟨h₁₂, h₁₂'⟩ ⟨h₂₃, h₂₃'⟩
refine ⟨h₁₂.trans h₂₃, fun _ ↦ ?_⟩
rw [← inclusion_inclusion h₁₂ h₂₃, h₂₃', h₁₂']
le_antisymm := by
rintro ⟨L₁, e₁⟩ ⟨L₂, e₂⟩ ⟨h₁₂, h₁₂'⟩ ⟨h₂₁, h₂₁'⟩
obtain rfl : L₁ = L₂ := h₁₂.antisymm h₂₁
congr
exact AlgHom.ext h₂₁'
noncomputable instance : OrderBot (Lifts F E K) where
bot := ⟨⊥, (Algebra.ofId F K).comp (botEquiv F E)⟩
bot_le L := ⟨bot_le, fun x ↦ by
obtain ⟨x, rfl⟩ := (botEquiv F E).symm.surjective x
simp_rw [AlgHom.comp_apply, AlgHom.coe_coe, AlgEquiv.apply_symm_apply]
exact L.emb.commutes x⟩
noncomputable instance : Inhabited (Lifts F E K) :=
⟨⊥⟩
| Mathlib/FieldTheory/Extension.lean | 57 | 70 | theorem Lifts.exists_upper_bound (c : Set (Lifts F E K)) (hc : IsChain (· ≤ ·) c) :
∃ ub, ∀ a ∈ c, a ≤ ub := by |
let t (i : ↑(insert ⊥ c)) := i.val.carrier
let t' (i) := (t i).toSubalgebra
have hc := hc.insert fun _ _ _ ↦ .inl bot_le
have dir : Directed (· ≤ ·) t := hc.directedOn.directed_val.mono_comp _ fun _ _ h ↦ h.1
refine ⟨⟨iSup t, (Subalgebra.iSupLift t' dir (fun i ↦ i.val.emb) (fun i j h ↦ ?_) _ rfl).comp
(Subalgebra.equivOfEq _ _ <| toSubalgebra_iSup_of_directed dir)⟩,
fun L hL ↦ have hL := Set.mem_insert_of_mem ⊥ hL; ⟨le_iSup t ⟨L, hL⟩, fun x ↦ ?_⟩⟩
· refine AlgHom.ext fun x ↦ (hc.total i.2 j.2).elim (fun hij ↦ (hij.snd x).symm) fun hji ↦ ?_
erw [AlgHom.comp_apply, ← hji.snd (Subalgebra.inclusion h x),
inclusion_inclusion, inclusion_self, AlgHom.id_apply x]
· dsimp only [AlgHom.comp_apply]
exact Subalgebra.iSupLift_inclusion (K := t') (i := ⟨L, hL⟩) x (le_iSup t' ⟨L, hL⟩)
| 0 |
import Mathlib.Algebra.MonoidAlgebra.Degree
import Mathlib.Algebra.MvPolynomial.Rename
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
#align_import data.mv_polynomial.variables from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4"
noncomputable section
open Set Function Finsupp AddMonoidAlgebra
universe u v w
variable {R : Type u} {S : Type v}
namespace MvPolynomial
variable {σ τ : Type*} {r : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ}
section CommSemiring
variable [CommSemiring R] {p q : MvPolynomial σ R}
section Degrees
def degrees (p : MvPolynomial σ R) : Multiset σ :=
letI := Classical.decEq σ
p.support.sup fun s : σ →₀ ℕ => toMultiset s
#align mv_polynomial.degrees MvPolynomial.degrees
theorem degrees_def [DecidableEq σ] (p : MvPolynomial σ R) :
p.degrees = p.support.sup fun s : σ →₀ ℕ => Finsupp.toMultiset s := by rw [degrees]; convert rfl
#align mv_polynomial.degrees_def MvPolynomial.degrees_def
theorem degrees_monomial (s : σ →₀ ℕ) (a : R) : degrees (monomial s a) ≤ toMultiset s := by
classical
refine (supDegree_single s a).trans_le ?_
split_ifs
exacts [bot_le, le_rfl]
#align mv_polynomial.degrees_monomial MvPolynomial.degrees_monomial
theorem degrees_monomial_eq (s : σ →₀ ℕ) (a : R) (ha : a ≠ 0) :
degrees (monomial s a) = toMultiset s := by
classical
exact (supDegree_single s a).trans (if_neg ha)
#align mv_polynomial.degrees_monomial_eq MvPolynomial.degrees_monomial_eq
theorem degrees_C (a : R) : degrees (C a : MvPolynomial σ R) = 0 :=
Multiset.le_zero.1 <| degrees_monomial _ _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.degrees_C MvPolynomial.degrees_C
theorem degrees_X' (n : σ) : degrees (X n : MvPolynomial σ R) ≤ {n} :=
le_trans (degrees_monomial _ _) <| le_of_eq <| toMultiset_single _ _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.degrees_X' MvPolynomial.degrees_X'
@[simp]
theorem degrees_X [Nontrivial R] (n : σ) : degrees (X n : MvPolynomial σ R) = {n} :=
(degrees_monomial_eq _ (1 : R) one_ne_zero).trans (toMultiset_single _ _)
set_option linter.uppercaseLean3 false in
#align mv_polynomial.degrees_X MvPolynomial.degrees_X
@[simp]
theorem degrees_zero : degrees (0 : MvPolynomial σ R) = 0 := by
rw [← C_0]
exact degrees_C 0
#align mv_polynomial.degrees_zero MvPolynomial.degrees_zero
@[simp]
theorem degrees_one : degrees (1 : MvPolynomial σ R) = 0 :=
degrees_C 1
#align mv_polynomial.degrees_one MvPolynomial.degrees_one
theorem degrees_add [DecidableEq σ] (p q : MvPolynomial σ R) :
(p + q).degrees ≤ p.degrees ⊔ q.degrees := by
simp_rw [degrees_def]; exact supDegree_add_le
#align mv_polynomial.degrees_add MvPolynomial.degrees_add
theorem degrees_sum {ι : Type*} [DecidableEq σ] (s : Finset ι) (f : ι → MvPolynomial σ R) :
(∑ i ∈ s, f i).degrees ≤ s.sup fun i => (f i).degrees := by
simp_rw [degrees_def]; exact supDegree_sum_le
#align mv_polynomial.degrees_sum MvPolynomial.degrees_sum
theorem degrees_mul (p q : MvPolynomial σ R) : (p * q).degrees ≤ p.degrees + q.degrees := by
classical
simp_rw [degrees_def]
exact supDegree_mul_le (map_add _)
#align mv_polynomial.degrees_mul MvPolynomial.degrees_mul
theorem degrees_prod {ι : Type*} (s : Finset ι) (f : ι → MvPolynomial σ R) :
(∏ i ∈ s, f i).degrees ≤ ∑ i ∈ s, (f i).degrees := by
classical exact supDegree_prod_le (map_zero _) (map_add _)
#align mv_polynomial.degrees_prod MvPolynomial.degrees_prod
theorem degrees_pow (p : MvPolynomial σ R) (n : ℕ) : (p ^ n).degrees ≤ n • p.degrees := by
simpa using degrees_prod (Finset.range n) fun _ ↦ p
#align mv_polynomial.degrees_pow MvPolynomial.degrees_pow
theorem mem_degrees {p : MvPolynomial σ R} {i : σ} :
i ∈ p.degrees ↔ ∃ d, p.coeff d ≠ 0 ∧ i ∈ d.support := by
classical
simp only [degrees_def, Multiset.mem_sup, ← mem_support_iff, Finsupp.mem_toMultiset, exists_prop]
#align mv_polynomial.mem_degrees MvPolynomial.mem_degrees
theorem le_degrees_add {p q : MvPolynomial σ R} (h : p.degrees.Disjoint q.degrees) :
p.degrees ≤ (p + q).degrees := by
classical
apply Finset.sup_le
intro d hd
rw [Multiset.disjoint_iff_ne] at h
obtain rfl | h0 := eq_or_ne d 0
· rw [toMultiset_zero]; apply Multiset.zero_le
· refine Finset.le_sup_of_le (b := d) ?_ le_rfl
rw [mem_support_iff, coeff_add]
suffices q.coeff d = 0 by rwa [this, add_zero, coeff, ← Finsupp.mem_support_iff]
rw [Ne, ← Finsupp.support_eq_empty, ← Ne, ← Finset.nonempty_iff_ne_empty] at h0
obtain ⟨j, hj⟩ := h0
contrapose! h
rw [mem_support_iff] at hd
refine ⟨j, ?_, j, ?_, rfl⟩
all_goals rw [mem_degrees]; refine ⟨d, ?_, hj⟩; assumption
#align mv_polynomial.le_degrees_add MvPolynomial.le_degrees_add
| Mathlib/Algebra/MvPolynomial/Degrees.lean | 178 | 185 | theorem degrees_add_of_disjoint [DecidableEq σ] {p q : MvPolynomial σ R}
(h : Multiset.Disjoint p.degrees q.degrees) : (p + q).degrees = p.degrees ∪ q.degrees := by |
apply le_antisymm
· apply degrees_add
· apply Multiset.union_le
· apply le_degrees_add h
· rw [add_comm]
apply le_degrees_add h.symm
| 0 |
import Mathlib.Algebra.BigOperators.Ring
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Int.GCD
import Mathlib.RingTheory.Coprime.Basic
#align_import ring_theory.coprime.lemmas from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
universe u v
section IsCoprime
variable {R : Type u} {I : Type v} [CommSemiring R] {x y z : R} {s : I → R} {t : Finset I}
section
theorem Int.isCoprime_iff_gcd_eq_one {m n : ℤ} : IsCoprime m n ↔ Int.gcd m n = 1 := by
constructor
· rintro ⟨a, b, h⟩
have : 1 = m * a + n * b := by rwa [mul_comm m, mul_comm n, eq_comm]
exact Nat.dvd_one.mp (Int.gcd_dvd_iff.mpr ⟨a, b, this⟩)
· rw [← Int.ofNat_inj, IsCoprime, Int.gcd_eq_gcd_ab, mul_comm m, mul_comm n, Nat.cast_one]
intro h
exact ⟨_, _, h⟩
theorem Nat.isCoprime_iff_coprime {m n : ℕ} : IsCoprime (m : ℤ) n ↔ Nat.Coprime m n := by
rw [Int.isCoprime_iff_gcd_eq_one, Int.gcd_natCast_natCast]
#align nat.is_coprime_iff_coprime Nat.isCoprime_iff_coprime
alias ⟨IsCoprime.nat_coprime, Nat.Coprime.isCoprime⟩ := Nat.isCoprime_iff_coprime
#align is_coprime.nat_coprime IsCoprime.nat_coprime
#align nat.coprime.is_coprime Nat.Coprime.isCoprime
theorem Nat.Coprime.cast {R : Type*} [CommRing R] {a b : ℕ} (h : Nat.Coprime a b) :
IsCoprime (a : R) (b : R) := by
rw [← isCoprime_iff_coprime] at h
rw [← Int.cast_natCast a, ← Int.cast_natCast b]
exact IsCoprime.intCast h
theorem ne_zero_or_ne_zero_of_nat_coprime {A : Type u} [CommRing A] [Nontrivial A] {a b : ℕ}
(h : Nat.Coprime a b) : (a : A) ≠ 0 ∨ (b : A) ≠ 0 :=
IsCoprime.ne_zero_or_ne_zero (R := A) <| by
simpa only [map_natCast] using IsCoprime.map (Nat.Coprime.isCoprime h) (Int.castRingHom A)
theorem IsCoprime.prod_left : (∀ i ∈ t, IsCoprime (s i) x) → IsCoprime (∏ i ∈ t, s i) x := by
classical
refine Finset.induction_on t (fun _ ↦ isCoprime_one_left) fun b t hbt ih H ↦ ?_
rw [Finset.prod_insert hbt]
rw [Finset.forall_mem_insert] at H
exact H.1.mul_left (ih H.2)
#align is_coprime.prod_left IsCoprime.prod_left
theorem IsCoprime.prod_right : (∀ i ∈ t, IsCoprime x (s i)) → IsCoprime x (∏ i ∈ t, s i) := by
simpa only [isCoprime_comm] using IsCoprime.prod_left (R := R)
#align is_coprime.prod_right IsCoprime.prod_right
theorem IsCoprime.prod_left_iff : IsCoprime (∏ i ∈ t, s i) x ↔ ∀ i ∈ t, IsCoprime (s i) x := by
classical
refine Finset.induction_on t (iff_of_true isCoprime_one_left fun _ ↦ by simp) fun b t hbt ih ↦ ?_
rw [Finset.prod_insert hbt, IsCoprime.mul_left_iff, ih, Finset.forall_mem_insert]
#align is_coprime.prod_left_iff IsCoprime.prod_left_iff
theorem IsCoprime.prod_right_iff : IsCoprime x (∏ i ∈ t, s i) ↔ ∀ i ∈ t, IsCoprime x (s i) := by
simpa only [isCoprime_comm] using IsCoprime.prod_left_iff (R := R)
#align is_coprime.prod_right_iff IsCoprime.prod_right_iff
theorem IsCoprime.of_prod_left (H1 : IsCoprime (∏ i ∈ t, s i) x) (i : I) (hit : i ∈ t) :
IsCoprime (s i) x :=
IsCoprime.prod_left_iff.1 H1 i hit
#align is_coprime.of_prod_left IsCoprime.of_prod_left
theorem IsCoprime.of_prod_right (H1 : IsCoprime x (∏ i ∈ t, s i)) (i : I) (hit : i ∈ t) :
IsCoprime x (s i) :=
IsCoprime.prod_right_iff.1 H1 i hit
#align is_coprime.of_prod_right IsCoprime.of_prod_right
-- Porting note: removed names of things due to linter, but they seem helpful
theorem Finset.prod_dvd_of_coprime :
(t : Set I).Pairwise (IsCoprime on s) → (∀ i ∈ t, s i ∣ z) → (∏ x ∈ t, s x) ∣ z := by
classical
exact Finset.induction_on t (fun _ _ ↦ one_dvd z)
(by
intro a r har ih Hs Hs1
rw [Finset.prod_insert har]
have aux1 : a ∈ (↑(insert a r) : Set I) := Finset.mem_insert_self a r
refine
(IsCoprime.prod_right fun i hir ↦
Hs aux1 (Finset.mem_insert_of_mem hir) <| by
rintro rfl
exact har hir).mul_dvd
(Hs1 a aux1) (ih (Hs.mono ?_) fun i hi ↦ Hs1 i <| Finset.mem_insert_of_mem hi)
simp only [Finset.coe_insert, Set.subset_insert])
#align finset.prod_dvd_of_coprime Finset.prod_dvd_of_coprime
theorem Fintype.prod_dvd_of_coprime [Fintype I] (Hs : Pairwise (IsCoprime on s))
(Hs1 : ∀ i, s i ∣ z) : (∏ x, s x) ∣ z :=
Finset.prod_dvd_of_coprime (Hs.set_pairwise _) fun i _ ↦ Hs1 i
#align fintype.prod_dvd_of_coprime Fintype.prod_dvd_of_coprime
end
open Finset
| Mathlib/RingTheory/Coprime/Lemmas.lean | 120 | 175 | theorem exists_sum_eq_one_iff_pairwise_coprime [DecidableEq I] (h : t.Nonempty) :
(∃ μ : I → R, (∑ i ∈ t, μ i * ∏ j ∈ t \ {i}, s j) = 1) ↔
Pairwise (IsCoprime on fun i : t ↦ s i) := by |
induction h using Finset.Nonempty.cons_induction with
| singleton =>
simp [exists_apply_eq, Pairwise, Function.onFun]
| cons a t hat h ih =>
rw [pairwise_cons']
have mem : ∀ x ∈ t, a ∈ insert a t \ {x} := fun x hx ↦ by
rw [mem_sdiff, mem_singleton]
exact ⟨mem_insert_self _ _, fun ha ↦ hat (ha ▸ hx)⟩
constructor
· rintro ⟨μ, hμ⟩
rw [sum_cons, cons_eq_insert, sdiff_singleton_eq_erase, erase_insert hat] at hμ
refine ⟨ih.mp ⟨Pi.single h.choose (μ a * s h.choose) + μ * fun _ ↦ s a, ?_⟩, fun b hb ↦ ?_⟩
· rw [prod_eq_mul_prod_diff_singleton h.choose_spec, ← mul_assoc, ←
@if_pos _ _ h.choose_spec R (_ * _) 0, ← sum_pi_single', ← sum_add_distrib] at hμ
rw [← hμ, sum_congr rfl]
intro x hx
dsimp -- Porting note: terms were showing as sort of `HAdd.hadd` instead of `+`
-- this whole proof pretty much breaks and has to be rewritten from scratch
rw [add_mul]
congr 1
· by_cases hx : x = h.choose
· rw [hx, Pi.single_eq_same, Pi.single_eq_same]
· rw [Pi.single_eq_of_ne hx, Pi.single_eq_of_ne hx, zero_mul]
· rw [mul_assoc]
congr
rw [prod_eq_prod_diff_singleton_mul (mem x hx) _, mul_comm]
congr 2
rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]
· have : IsCoprime (s b) (s a) :=
⟨μ a * ∏ i ∈ t \ {b}, s i, ∑ i ∈ t, μ i * ∏ j ∈ t \ {i}, s j, ?_⟩
· exact ⟨this.symm, this⟩
rw [mul_assoc, ← prod_eq_prod_diff_singleton_mul hb, sum_mul, ← hμ, sum_congr rfl]
intro x hx
rw [mul_assoc]
congr
rw [prod_eq_prod_diff_singleton_mul (mem x hx) _]
congr 2
rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]
· rintro ⟨hs, Hb⟩
obtain ⟨μ, hμ⟩ := ih.mpr hs
obtain ⟨u, v, huv⟩ := IsCoprime.prod_left fun b hb ↦ (Hb b hb).right
use fun i ↦ if i = a then u else v * μ i
have hμ' : (∑ i ∈ t, v * ((μ i * ∏ j ∈ t \ {i}, s j) * s a)) = v * s a := by
rw [← mul_sum, ← sum_mul, hμ, one_mul]
rw [sum_cons, cons_eq_insert, sdiff_singleton_eq_erase, erase_insert hat, if_pos rfl,
← huv, ← hμ', sum_congr rfl]
intro x hx
rw [mul_assoc, if_neg fun ha : x = a ↦ hat (ha.casesOn hx)]
rw [mul_assoc]
congr
rw [prod_eq_prod_diff_singleton_mul (mem x hx) _]
congr 2
rw [sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat]
| 0 |
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"
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]
theorem le_rootMultiplicity_iff {p : R[X]} (p0 : p ≠ 0) {a : R} {n : ℕ} :
n ≤ rootMultiplicity a p ↔ (X - C a) ^ n ∣ p := by
classical
rw [rootMultiplicity_eq_nat_find_of_nonzero p0, @Nat.le_find_iff _ (_)]
simp_rw [Classical.not_not]
refine ⟨fun h => ?_, fun h m hm => (pow_dvd_pow _ hm).trans h⟩
cases' n with n;
· rw [pow_zero]
apply one_dvd;
· exact h n n.lt_succ_self
#align polynomial.le_root_multiplicity_iff Polynomial.le_rootMultiplicity_iff
theorem rootMultiplicity_le_iff {p : R[X]} (p0 : p ≠ 0) (a : R) (n : ℕ) :
rootMultiplicity a p ≤ n ↔ ¬(X - C a) ^ (n + 1) ∣ p := by
rw [← (le_rootMultiplicity_iff p0).not, not_le, Nat.lt_add_one_iff]
#align polynomial.root_multiplicity_le_iff Polynomial.rootMultiplicity_le_iff
theorem pow_rootMultiplicity_not_dvd {p : R[X]} (p0 : p ≠ 0) (a : R) :
¬(X - C a) ^ (rootMultiplicity a p + 1) ∣ p := by rw [← rootMultiplicity_le_iff p0]
#align polynomial.pow_root_multiplicity_not_dvd Polynomial.pow_rootMultiplicity_not_dvd
theorem X_sub_C_pow_dvd_iff {p : R[X]} {t : R} {n : ℕ} :
(X - C t) ^ n ∣ p ↔ X ^ n ∣ p.comp (X + C t) := by
convert (map_dvd_iff <| algEquivAevalXAddC t).symm using 2
simp [C_eq_algebraMap]
theorem comp_X_add_C_eq_zero_iff {p : R[X]} (t : R) :
p.comp (X + C t) = 0 ↔ p = 0 := AddEquivClass.map_eq_zero_iff (algEquivAevalXAddC t)
theorem comp_X_add_C_ne_zero_iff {p : R[X]} (t : R) :
p.comp (X + C t) ≠ 0 ↔ p ≠ 0 := Iff.not <| comp_X_add_C_eq_zero_iff t
theorem rootMultiplicity_eq_rootMultiplicity {p : R[X]} {t : R} :
p.rootMultiplicity t = (p.comp (X + C t)).rootMultiplicity 0 := by
classical
simp_rw [rootMultiplicity_eq_multiplicity, comp_X_add_C_eq_zero_iff]
congr; ext; congr 1
rw [C_0, sub_zero]
convert (multiplicity.multiplicity_map_eq <| algEquivAevalXAddC t).symm using 2
simp [C_eq_algebraMap]
theorem rootMultiplicity_eq_natTrailingDegree' {p : R[X]} :
p.rootMultiplicity 0 = p.natTrailingDegree := by
by_cases h : p = 0
· simp only [h, rootMultiplicity_zero, natTrailingDegree_zero]
refine le_antisymm ?_ ?_
· rw [rootMultiplicity_le_iff h, map_zero, sub_zero, X_pow_dvd_iff, not_forall]
exact ⟨p.natTrailingDegree,
fun h' ↦ trailingCoeff_nonzero_iff_nonzero.2 h <| h' <| Nat.lt.base _⟩
· rw [le_rootMultiplicity_iff h, map_zero, sub_zero, X_pow_dvd_iff]
exact fun _ ↦ coeff_eq_zero_of_lt_natTrailingDegree
theorem rootMultiplicity_eq_natTrailingDegree {p : R[X]} {t : R} :
p.rootMultiplicity t = (p.comp (X + C t)).natTrailingDegree :=
rootMultiplicity_eq_rootMultiplicity.trans rootMultiplicity_eq_natTrailingDegree'
| Mathlib/Algebra/Polynomial/RingDivision.lean | 483 | 495 | theorem eval_divByMonic_eq_trailingCoeff_comp {p : R[X]} {t : R} :
(p /ₘ (X - C t) ^ p.rootMultiplicity t).eval t = (p.comp (X + C t)).trailingCoeff := by |
obtain rfl | hp := eq_or_ne p 0
· rw [zero_divByMonic, eval_zero, zero_comp, trailingCoeff_zero]
have mul_eq := p.pow_mul_divByMonic_rootMultiplicity_eq t
set m := p.rootMultiplicity t
set g := p /ₘ (X - C t) ^ m
have : (g.comp (X + C t)).coeff 0 = g.eval t := by
rw [coeff_zero_eq_eval_zero, eval_comp, eval_add, eval_X, eval_C, zero_add]
rw [← congr_arg (comp · <| X + C t) mul_eq, mul_comp, pow_comp, sub_comp, X_comp, C_comp,
add_sub_cancel_right, ← reverse_leadingCoeff, reverse_X_pow_mul, reverse_leadingCoeff,
trailingCoeff, Nat.le_zero.1 (natTrailingDegree_le_of_ne_zero <|
this ▸ eval_divByMonic_pow_rootMultiplicity_ne_zero t hp), this]
| 0 |
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"
namespace ZMod
section QuadCharModP
@[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.χ₄
theorem isQuadratic_χ₄ : χ₄.IsQuadratic := by
intro a
-- Porting note (#11043): was `decide!`
fin_cases a
all_goals decide
#align zmod.is_quadratic_χ₄ ZMod.isQuadratic_χ₄
theorem χ₄_nat_mod_four (n : ℕ) : χ₄ n = χ₄ (n % 4 : ℕ) := by rw [← ZMod.natCast_mod n 4]
#align zmod.χ₄_nat_mod_four ZMod.χ₄_nat_mod_four
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
| Mathlib/NumberTheory/LegendreSymbol/ZModChar.lean | 66 | 71 | 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))
| 0 |
import Mathlib.Analysis.Calculus.FDeriv.Add
variable {𝕜 ι : Type*} [DecidableEq ι] [Fintype ι] [NontriviallyNormedField 𝕜]
variable {E : ι → Type*} [∀ i, NormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
@[fun_prop]
| Mathlib/Analysis/Calculus/FDeriv/Pi.lean | 17 | 29 | theorem hasFDerivAt_update (x : ∀ i, E i) {i : ι} (y : E i) :
HasFDerivAt (Function.update x i) (.pi (Pi.single i (.id 𝕜 (E i)))) y := by |
set l := (ContinuousLinearMap.pi (Pi.single i (.id 𝕜 (E i))))
have update_eq : Function.update x i = (fun _ ↦ x) + l ∘ (· - x i) := by
ext t j
dsimp [l, Pi.single, Function.update]
split_ifs with hji
· subst hji
simp
· simp
rw [update_eq]
convert (hasFDerivAt_const _ _).add (l.hasFDerivAt.comp y (hasFDerivAt_sub_const (x i)))
rw [zero_add, ContinuousLinearMap.comp_id]
| 0 |
import Mathlib.Algebra.Group.Subgroup.Pointwise
import Mathlib.Data.Set.Basic
import Mathlib.Data.Setoid.Basic
import Mathlib.GroupTheory.Coset
#align_import group_theory.double_coset from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514"
-- Porting note: removed import
-- import Mathlib.Tactic.Group
variable {G : Type*} [Group G] {α : Type*} [Mul α] (J : Subgroup G) (g : G)
open MulOpposite
open scoped Pointwise
namespace Doset
def doset (a : α) (s t : Set α) : Set α :=
s * {a} * t
#align doset Doset.doset
lemma doset_eq_image2 (a : α) (s t : Set α) : doset a s t = Set.image2 (· * a * ·) s t := by
simp_rw [doset, Set.mul_singleton, ← Set.image2_mul, Set.image2_image_left]
theorem mem_doset {s t : Set α} {a b : α} : b ∈ doset a s t ↔ ∃ x ∈ s, ∃ y ∈ t, b = x * a * y := by
simp only [doset_eq_image2, Set.mem_image2, eq_comm]
#align doset.mem_doset Doset.mem_doset
theorem mem_doset_self (H K : Subgroup G) (a : G) : a ∈ doset a H K :=
mem_doset.mpr ⟨1, H.one_mem, 1, K.one_mem, (one_mul a).symm.trans (mul_one (1 * a)).symm⟩
#align doset.mem_doset_self Doset.mem_doset_self
theorem doset_eq_of_mem {H K : Subgroup G} {a b : G} (hb : b ∈ doset a H K) :
doset b H K = doset a H K := by
obtain ⟨h, hh, k, hk, rfl⟩ := mem_doset.1 hb
rw [doset, doset, ← Set.singleton_mul_singleton, ← Set.singleton_mul_singleton, mul_assoc,
mul_assoc, Subgroup.singleton_mul_subgroup hk, ← mul_assoc, ← mul_assoc,
Subgroup.subgroup_mul_singleton hh]
#align doset.doset_eq_of_mem Doset.doset_eq_of_mem
theorem mem_doset_of_not_disjoint {H K : Subgroup G} {a b : G}
(h : ¬Disjoint (doset a H K) (doset b H K)) : b ∈ doset a H K := by
rw [Set.not_disjoint_iff] at h
simp only [mem_doset] at *
obtain ⟨x, ⟨l, hl, r, hr, hrx⟩, y, hy, ⟨r', hr', rfl⟩⟩ := h
refine ⟨y⁻¹ * l, H.mul_mem (H.inv_mem hy) hl, r * r'⁻¹, K.mul_mem hr (K.inv_mem hr'), ?_⟩
rwa [mul_assoc, mul_assoc, eq_inv_mul_iff_mul_eq, ← mul_assoc, ← mul_assoc, eq_mul_inv_iff_mul_eq]
#align doset.mem_doset_of_not_disjoint Doset.mem_doset_of_not_disjoint
theorem eq_of_not_disjoint {H K : Subgroup G} {a b : G}
(h : ¬Disjoint (doset a H K) (doset b H K)) : doset a H K = doset b H K := by
rw [disjoint_comm] at h
have ha : a ∈ doset b H K := mem_doset_of_not_disjoint h
apply doset_eq_of_mem ha
#align doset.eq_of_not_disjoint Doset.eq_of_not_disjoint
def setoid (H K : Set G) : Setoid G :=
Setoid.ker fun x => doset x H K
#align doset.setoid Doset.setoid
def Quotient (H K : Set G) : Type _ :=
_root_.Quotient (setoid H K)
#align doset.quotient Doset.Quotient
theorem rel_iff {H K : Subgroup G} {x y : G} :
(setoid ↑H ↑K).Rel x y ↔ ∃ a ∈ H, ∃ b ∈ K, y = a * x * b :=
Iff.trans
⟨fun hxy => (congr_arg _ hxy).mpr (mem_doset_self H K y), fun hxy => (doset_eq_of_mem hxy).symm⟩
mem_doset
#align doset.rel_iff Doset.rel_iff
| Mathlib/GroupTheory/DoubleCoset.lean | 93 | 102 | theorem bot_rel_eq_leftRel (H : Subgroup G) :
(setoid ↑(⊥ : Subgroup G) ↑H).Rel = (QuotientGroup.leftRel H).Rel := by |
ext a b
rw [rel_iff, Setoid.Rel, QuotientGroup.leftRel_apply]
constructor
· rintro ⟨a, rfl : a = 1, b, hb, rfl⟩
change a⁻¹ * (1 * a * b) ∈ H
rwa [one_mul, inv_mul_cancel_left]
· rintro (h : a⁻¹ * b ∈ H)
exact ⟨1, rfl, a⁻¹ * b, h, by rw [one_mul, mul_inv_cancel_left]⟩
| 0 |
import Mathlib.CategoryTheory.Limits.Types
import Mathlib.CategoryTheory.Functor.Currying
import Mathlib.CategoryTheory.Limits.FunctorCategory
#align_import category_theory.limits.colimit_limit from "leanprover-community/mathlib"@"59382264386afdbaf1727e617f5fdda511992eb9"
universe v₁ v₂ v u₁ u₂ u
open CategoryTheory
namespace CategoryTheory.Limits
variable {J : Type u₁} {K : Type u₂} [Category.{v₁} J] [Category.{v₂} K]
variable {C : Type u} [Category.{v} C]
variable (F : J × K ⥤ C)
open CategoryTheory.prod
theorem map_id_left_eq_curry_map {j : J} {k k' : K} {f : k ⟶ k'} :
F.map ((𝟙 j, f) : (j, k) ⟶ (j, k')) = ((curry.obj F).obj j).map f :=
rfl
#align category_theory.limits.map_id_left_eq_curry_map CategoryTheory.Limits.map_id_left_eq_curry_map
theorem map_id_right_eq_curry_swap_map {j j' : J} {f : j ⟶ j'} {k : K} :
F.map ((f, 𝟙 k) : (j, k) ⟶ (j', k)) = ((curry.obj (Prod.swap K J ⋙ F)).obj k).map f :=
rfl
#align category_theory.limits.map_id_right_eq_curry_swap_map CategoryTheory.Limits.map_id_right_eq_curry_swap_map
variable [HasLimitsOfShape J C]
variable [HasColimitsOfShape K C]
noncomputable def colimitLimitToLimitColimit :
colimit (curry.obj (Prod.swap K J ⋙ F) ⋙ lim) ⟶ limit (curry.obj F ⋙ colim) :=
limit.lift (curry.obj F ⋙ colim)
{ pt := _
π :=
{ app := fun j =>
colimit.desc (curry.obj (Prod.swap K J ⋙ F) ⋙ lim)
{ pt := _
ι :=
{ app := fun k =>
limit.π ((curry.obj (Prod.swap K J ⋙ F)).obj k) j ≫
colimit.ι ((curry.obj F).obj j) k
naturality := by
intro k k' f
simp only [Functor.comp_obj, lim_obj, colimit.cocone_x,
Functor.const_obj_obj, Functor.comp_map, lim_map,
curry_obj_obj_obj, Prod.swap_obj, limMap_π_assoc, curry_obj_map_app,
Prod.swap_map, Functor.const_obj_map, Category.comp_id]
rw [map_id_left_eq_curry_map, colimit.w] } }
naturality := by
intro j j' f
dsimp
ext k
simp only [Functor.comp_obj, lim_obj, Category.id_comp, colimit.ι_desc,
colimit.ι_desc_assoc, Category.assoc, ι_colimMap,
curry_obj_obj_obj, curry_obj_map_app]
rw [map_id_right_eq_curry_swap_map, limit.w_assoc] } }
#align category_theory.limits.colimit_limit_to_limit_colimit CategoryTheory.Limits.colimitLimitToLimitColimit
@[reassoc (attr := simp)]
theorem ι_colimitLimitToLimitColimit_π (j) (k) :
colimit.ι _ k ≫ colimitLimitToLimitColimit F ≫ limit.π _ j =
limit.π ((curry.obj (Prod.swap K J ⋙ F)).obj k) j ≫ colimit.ι ((curry.obj F).obj j) k := by
dsimp [colimitLimitToLimitColimit]
simp
#align category_theory.limits.ι_colimit_limit_to_limit_colimit_π CategoryTheory.Limits.ι_colimitLimitToLimitColimit_π
@[simp]
| Mathlib/CategoryTheory/Limits/ColimitLimit.lean | 97 | 105 | theorem ι_colimitLimitToLimitColimit_π_apply [Small.{v} J] [Small.{v} K] (F : J × K ⥤ Type v)
(j : J) (k : K) (f) : limit.π (curry.obj F ⋙ colim) j
(colimitLimitToLimitColimit F (colimit.ι (curry.obj (Prod.swap K J ⋙ F) ⋙ lim) k f)) =
colimit.ι ((curry.obj F).obj j) k (limit.π ((curry.obj (Prod.swap K J ⋙ F)).obj k) j f) := by |
dsimp [colimitLimitToLimitColimit]
rw [Types.Limit.lift_π_apply]
dsimp only
rw [Types.Colimit.ι_desc_apply]
dsimp
| 0 |
import Mathlib.Init.Core
import Mathlib.LinearAlgebra.AffineSpace.Basis
import Mathlib.LinearAlgebra.FiniteDimensional
#align_import linear_algebra.affine_space.finite_dimensional from "leanprover-community/mathlib"@"67e606eaea14c7854bdc556bd53d98aefdf76ec0"
noncomputable section
open Affine
section AffineSpace'
variable (k : Type*) {V : Type*} {P : Type*}
variable {ι : Type*}
open AffineSubspace FiniteDimensional Module
variable [DivisionRing k] [AddCommGroup V] [Module k V] [AffineSpace V P]
theorem finiteDimensional_vectorSpan_of_finite {s : Set P} (h : Set.Finite s) :
FiniteDimensional k (vectorSpan k s) :=
span_of_finite k <| h.vsub h
#align finite_dimensional_vector_span_of_finite finiteDimensional_vectorSpan_of_finite
instance finiteDimensional_vectorSpan_range [Finite ι] (p : ι → P) :
FiniteDimensional k (vectorSpan k (Set.range p)) :=
finiteDimensional_vectorSpan_of_finite k (Set.finite_range _)
#align finite_dimensional_vector_span_range finiteDimensional_vectorSpan_range
instance finiteDimensional_vectorSpan_image_of_finite [Finite ι] (p : ι → P) (s : Set ι) :
FiniteDimensional k (vectorSpan k (p '' s)) :=
finiteDimensional_vectorSpan_of_finite k (Set.toFinite _)
#align finite_dimensional_vector_span_image_of_finite finiteDimensional_vectorSpan_image_of_finite
theorem finiteDimensional_direction_affineSpan_of_finite {s : Set P} (h : Set.Finite s) :
FiniteDimensional k (affineSpan k s).direction :=
(direction_affineSpan k s).symm ▸ finiteDimensional_vectorSpan_of_finite k h
#align finite_dimensional_direction_affine_span_of_finite finiteDimensional_direction_affineSpan_of_finite
instance finiteDimensional_direction_affineSpan_range [Finite ι] (p : ι → P) :
FiniteDimensional k (affineSpan k (Set.range p)).direction :=
finiteDimensional_direction_affineSpan_of_finite k (Set.finite_range _)
#align finite_dimensional_direction_affine_span_range finiteDimensional_direction_affineSpan_range
instance finiteDimensional_direction_affineSpan_image_of_finite [Finite ι] (p : ι → P) (s : Set ι) :
FiniteDimensional k (affineSpan k (p '' s)).direction :=
finiteDimensional_direction_affineSpan_of_finite k (Set.toFinite _)
#align finite_dimensional_direction_affine_span_image_of_finite finiteDimensional_direction_affineSpan_image_of_finite
theorem finite_of_fin_dim_affineIndependent [FiniteDimensional k V] {p : ι → P}
(hi : AffineIndependent k p) : Finite ι := by
nontriviality ι; inhabit ι
rw [affineIndependent_iff_linearIndependent_vsub k p default] at hi
letI : IsNoetherian k V := IsNoetherian.iff_fg.2 inferInstance
exact
(Set.finite_singleton default).finite_of_compl (Set.finite_coe_iff.1 hi.finite_of_isNoetherian)
#align finite_of_fin_dim_affine_independent finite_of_fin_dim_affineIndependent
theorem finite_set_of_fin_dim_affineIndependent [FiniteDimensional k V] {s : Set ι} {f : s → P}
(hi : AffineIndependent k f) : s.Finite :=
@Set.toFinite _ s (finite_of_fin_dim_affineIndependent k hi)
#align finite_set_of_fin_dim_affine_independent finite_set_of_fin_dim_affineIndependent
variable {k}
| Mathlib/LinearAlgebra/AffineSpace/FiniteDimensional.lean | 100 | 115 | theorem AffineIndependent.finrank_vectorSpan_image_finset [DecidableEq P]
{p : ι → P} (hi : AffineIndependent k p) {s : Finset ι} {n : ℕ} (hc : Finset.card s = n + 1) :
finrank k (vectorSpan k (s.image p : Set P)) = n := by |
classical
have hi' := hi.range.mono (Set.image_subset_range p ↑s)
have hc' : (s.image p).card = n + 1 := by rwa [s.card_image_of_injective hi.injective]
have hn : (s.image p).Nonempty := by simp [hc', ← Finset.card_pos]
rcases hn with ⟨p₁, hp₁⟩
have hp₁' : p₁ ∈ p '' s := by simpa using hp₁
rw [affineIndependent_set_iff_linearIndependent_vsub k hp₁', ← Finset.coe_singleton,
← Finset.coe_image, ← Finset.coe_sdiff, Finset.sdiff_singleton_eq_erase, ← Finset.coe_image]
at hi'
have hc : (Finset.image (fun p : P => p -ᵥ p₁) ((Finset.image p s).erase p₁)).card = n := by
rw [Finset.card_image_of_injective _ (vsub_left_injective _), Finset.card_erase_of_mem hp₁]
exact Nat.pred_eq_of_eq_succ hc'
rwa [vectorSpan_eq_span_vsub_finset_right_ne k hp₁, finrank_span_finset_eq_card, hc]
| 0 |
import Mathlib.MeasureTheory.Covering.Differentiation
import Mathlib.MeasureTheory.Covering.VitaliFamily
import Mathlib.MeasureTheory.Integral.Lebesgue
import Mathlib.MeasureTheory.Measure.Regular
import Mathlib.SetTheory.Ordinal.Arithmetic
import Mathlib.Topology.MetricSpace.Basic
import Mathlib.Data.Set.Pairwise.Lattice
#align_import measure_theory.covering.besicovitch from "leanprover-community/mathlib"@"5f6e827d81dfbeb6151d7016586ceeb0099b9655"
noncomputable section
universe u
open Metric Set Filter Fin MeasureTheory TopologicalSpace
open scoped Topology Classical ENNReal MeasureTheory NNReal
structure Besicovitch.SatelliteConfig (α : Type*) [MetricSpace α] (N : ℕ) (τ : ℝ) where
c : Fin N.succ → α
r : Fin N.succ → ℝ
rpos : ∀ i, 0 < r i
h : Pairwise fun i j =>
r i ≤ dist (c i) (c j) ∧ r j ≤ τ * r i ∨ r j ≤ dist (c j) (c i) ∧ r i ≤ τ * r j
hlast : ∀ i < last N, r i ≤ dist (c i) (c (last N)) ∧ r (last N) ≤ τ * r i
inter : ∀ i < last N, dist (c i) (c (last N)) ≤ r i + r (last N)
#align besicovitch.satellite_config Besicovitch.SatelliteConfig
#align besicovitch.satellite_config.c Besicovitch.SatelliteConfig.c
#align besicovitch.satellite_config.r Besicovitch.SatelliteConfig.r
#align besicovitch.satellite_config.rpos Besicovitch.SatelliteConfig.rpos
#align besicovitch.satellite_config.h Besicovitch.SatelliteConfig.h
#align besicovitch.satellite_config.hlast Besicovitch.SatelliteConfig.hlast
#align besicovitch.satellite_config.inter Besicovitch.SatelliteConfig.inter
class HasBesicovitchCovering (α : Type*) [MetricSpace α] : Prop where
no_satelliteConfig : ∃ (N : ℕ) (τ : ℝ), 1 < τ ∧ IsEmpty (Besicovitch.SatelliteConfig α N τ)
#align has_besicovitch_covering HasBesicovitchCovering
#align has_besicovitch_covering.no_satellite_config HasBesicovitchCovering.no_satelliteConfig
instance Besicovitch.SatelliteConfig.instInhabited {α : Type*} {τ : ℝ}
[Inhabited α] [MetricSpace α] : Inhabited (Besicovitch.SatelliteConfig α 0 τ) :=
⟨{ c := default
r := fun _ => 1
rpos := fun _ => zero_lt_one
h := fun i j hij => (hij (Subsingleton.elim (α := Fin 1) i j)).elim
hlast := fun i hi => by
rw [Subsingleton.elim (α := Fin 1) i (last 0)] at hi; exact (lt_irrefl _ hi).elim
inter := fun i hi => by
rw [Subsingleton.elim (α := Fin 1) i (last 0)] at hi; exact (lt_irrefl _ hi).elim }⟩
#align besicovitch.satellite_config.inhabited Besicovitch.SatelliteConfig.instInhabited
namespace Besicovitch
namespace SatelliteConfig
variable {α : Type*} [MetricSpace α] {N : ℕ} {τ : ℝ} (a : SatelliteConfig α N τ)
theorem inter' (i : Fin N.succ) : dist (a.c i) (a.c (last N)) ≤ a.r i + a.r (last N) := by
rcases lt_or_le i (last N) with (H | H)
· exact a.inter i H
· have I : i = last N := top_le_iff.1 H
have := (a.rpos (last N)).le
simp only [I, add_nonneg this this, dist_self]
#align besicovitch.satellite_config.inter' Besicovitch.SatelliteConfig.inter'
| Mathlib/MeasureTheory/Covering/Besicovitch.lean | 195 | 200 | theorem hlast' (i : Fin N.succ) (h : 1 ≤ τ) : a.r (last N) ≤ τ * a.r i := by |
rcases lt_or_le i (last N) with (H | H)
· exact (a.hlast i H).2
· have : i = last N := top_le_iff.1 H
rw [this]
exact le_mul_of_one_le_left (a.rpos _).le h
| 0 |
import Mathlib.Order.Filter.Bases
import Mathlib.Order.Filter.Ultrafilter
open Set
variable {α β : Type*} {l : Filter α}
namespace Filter
protected def Subsingleton (l : Filter α) : Prop := ∃ s ∈ l, Set.Subsingleton s
theorem HasBasis.subsingleton_iff {ι : Sort*} {p : ι → Prop} {s : ι → Set α} (h : l.HasBasis p s) :
l.Subsingleton ↔ ∃ i, p i ∧ (s i).Subsingleton :=
h.exists_iff fun _ _ hsub h ↦ h.anti hsub
theorem Subsingleton.anti {l'} (hl : l.Subsingleton) (hl' : l' ≤ l) : l'.Subsingleton :=
let ⟨s, hsl, hs⟩ := hl; ⟨s, hl' hsl, hs⟩
@[nontriviality]
theorem Subsingleton.of_subsingleton [Subsingleton α] : l.Subsingleton :=
⟨univ, univ_mem, subsingleton_univ⟩
theorem Subsingleton.map (hl : l.Subsingleton) (f : α → β) : (map f l).Subsingleton :=
let ⟨s, hsl, hs⟩ := hl; ⟨f '' s, image_mem_map hsl, hs.image f⟩
theorem Subsingleton.prod (hl : l.Subsingleton) {l' : Filter β} (hl' : l'.Subsingleton) :
(l ×ˢ l').Subsingleton :=
let ⟨s, hsl, hs⟩ := hl; let ⟨t, htl', ht⟩ := hl'; ⟨s ×ˢ t, prod_mem_prod hsl htl', hs.prod ht⟩
@[simp]
theorem subsingleton_pure {a : α} : Filter.Subsingleton (pure a) :=
⟨{a}, rfl, subsingleton_singleton⟩
@[simp]
theorem subsingleton_bot : Filter.Subsingleton (⊥ : Filter α) :=
⟨∅, trivial, subsingleton_empty⟩
theorem Subsingleton.exists_eq_pure [l.NeBot] (hl : l.Subsingleton) : ∃ a, l = pure a := by
rcases hl with ⟨s, hsl, hs⟩
rcases exists_eq_singleton_iff_nonempty_subsingleton.2 ⟨nonempty_of_mem hsl, hs⟩ with ⟨a, rfl⟩
refine ⟨a, (NeBot.le_pure_iff ‹_›).1 ?_⟩
rwa [le_pure_iff]
| Mathlib/Order/Filter/Subsingleton.lean | 58 | 61 | theorem subsingleton_iff_bot_or_pure : l.Subsingleton ↔ l = ⊥ ∨ ∃ a, l = pure a := by |
refine ⟨fun hl ↦ ?_, ?_⟩
· exact (eq_or_neBot l).imp_right (@Subsingleton.exists_eq_pure _ _ · hl)
· rintro (rfl | ⟨a, rfl⟩) <;> simp
| 0 |
import Mathlib.LinearAlgebra.Matrix.ToLin
import Mathlib.LinearAlgebra.Quotient
import Mathlib.RingTheory.Ideal.Maps
import Mathlib.RingTheory.Nilpotent.Defs
#align_import ring_theory.nilpotent from "leanprover-community/mathlib"@"da420a8c6dd5bdfb85c4ced85c34388f633bc6ff"
universe u v
open Function Set
variable {R S : Type*} {x y : R}
| Mathlib/RingTheory/Nilpotent/Lemmas.lean | 25 | 29 | theorem RingHom.ker_isRadical_iff_reduced_of_surjective {S F} [CommSemiring R] [CommRing S]
[FunLike F R S] [RingHomClass F R S] {f : F} (hf : Function.Surjective f) :
(RingHom.ker f).IsRadical ↔ IsReduced S := by |
simp_rw [isReduced_iff, hf.forall, IsNilpotent, ← map_pow, ← RingHom.mem_ker]
rfl
| 0 |
import Mathlib.Data.List.Nodup
import Mathlib.Data.List.Range
#align_import data.list.nat_antidiagonal from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213"
open List Function Nat
namespace List
namespace Nat
def antidiagonal (n : ℕ) : List (ℕ × ℕ) :=
(range (n + 1)).map fun i ↦ (i, n - i)
#align list.nat.antidiagonal List.Nat.antidiagonal
@[simp]
theorem mem_antidiagonal {n : ℕ} {x : ℕ × ℕ} : x ∈ antidiagonal n ↔ x.1 + x.2 = n := by
rw [antidiagonal, mem_map]; constructor
· rintro ⟨i, hi, rfl⟩
rw [mem_range, Nat.lt_succ_iff] at hi
exact Nat.add_sub_cancel' hi
· rintro rfl
refine ⟨x.fst, ?_, ?_⟩
· rw [mem_range]
omega
· exact Prod.ext rfl (by simp only [Nat.add_sub_cancel_left])
#align list.nat.mem_antidiagonal List.Nat.mem_antidiagonal
@[simp]
theorem length_antidiagonal (n : ℕ) : (antidiagonal n).length = n + 1 := by
rw [antidiagonal, length_map, length_range]
#align list.nat.length_antidiagonal List.Nat.length_antidiagonal
@[simp]
theorem antidiagonal_zero : antidiagonal 0 = [(0, 0)] :=
rfl
#align list.nat.antidiagonal_zero List.Nat.antidiagonal_zero
theorem nodup_antidiagonal (n : ℕ) : Nodup (antidiagonal n) :=
(nodup_range _).map ((@LeftInverse.injective ℕ (ℕ × ℕ) Prod.fst fun i ↦ (i, n - i)) fun _ ↦ rfl)
#align list.nat.nodup_antidiagonal List.Nat.nodup_antidiagonal
@[simp]
theorem antidiagonal_succ {n : ℕ} :
antidiagonal (n + 1) = (0, n + 1) :: (antidiagonal n).map (Prod.map Nat.succ id) := by
simp only [antidiagonal, range_succ_eq_map, map_cons, true_and_iff, Nat.add_succ_sub_one,
Nat.add_zero, id, eq_self_iff_true, Nat.sub_zero, map_map, Prod.map_mk]
apply congr rfl (congr rfl _)
ext; simp
#align list.nat.antidiagonal_succ List.Nat.antidiagonal_succ
theorem antidiagonal_succ' {n : ℕ} :
antidiagonal (n + 1) = (antidiagonal n).map (Prod.map id Nat.succ) ++ [(n + 1, 0)] := by
simp only [antidiagonal, range_succ, Nat.add_sub_cancel_left, map_append, append_assoc,
Nat.sub_self, singleton_append, map_map, map]
congr 1
apply map_congr
simp (config := { contextual := true }) [le_of_lt, Nat.succ_eq_add_one, Nat.sub_add_comm]
#align list.nat.antidiagonal_succ' List.Nat.antidiagonal_succ'
theorem antidiagonal_succ_succ' {n : ℕ} :
antidiagonal (n + 2) =
(0, n + 2) :: (antidiagonal n).map (Prod.map Nat.succ Nat.succ) ++ [(n + 2, 0)] := by
rw [antidiagonal_succ']
simp only [antidiagonal_succ, map_cons, Prod.map_apply, id_eq, map_map, cons_append, cons.injEq,
append_cancel_right_eq, true_and]
ext
simp
#align list.nat.antidiagonal_succ_succ' List.Nat.antidiagonal_succ_succ'
| Mathlib/Data/List/NatAntidiagonal.lean | 95 | 100 | theorem map_swap_antidiagonal {n : ℕ} :
(antidiagonal n).map Prod.swap = (antidiagonal n).reverse := by |
rw [antidiagonal, map_map, ← List.map_reverse, range_eq_range', reverse_range', ←
range_eq_range', map_map]
apply map_congr
simp (config := { contextual := true }) [Nat.sub_sub_self, Nat.lt_succ_iff]
| 0 |
import Mathlib.MeasureTheory.Group.GeometryOfNumbers
import Mathlib.MeasureTheory.Measure.Lebesgue.VolumeOfBalls
import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic
#align_import number_theory.number_field.canonical_embedding from "leanprover-community/mathlib"@"60da01b41bbe4206f05d34fd70c8dd7498717a30"
variable (K : Type*) [Field K]
namespace NumberField.mixedEmbedding
open NumberField NumberField.InfinitePlace FiniteDimensional
local notation "E" K =>
({w : InfinitePlace K // IsReal w} → ℝ) × ({w : InfinitePlace K // IsComplex w} → ℂ)
section convexBodyLT
open Metric NNReal
variable (f : InfinitePlace K → ℝ≥0)
abbrev convexBodyLT : Set (E K) :=
(Set.univ.pi (fun w : { w : InfinitePlace K // IsReal w } => ball 0 (f w))) ×ˢ
(Set.univ.pi (fun w : { w : InfinitePlace K // IsComplex w } => ball 0 (f w)))
theorem convexBodyLT_mem {x : K} :
mixedEmbedding K x ∈ (convexBodyLT K f) ↔ ∀ w : InfinitePlace K, w x < f w := by
simp_rw [mixedEmbedding, RingHom.prod_apply, Set.mem_prod, Set.mem_pi, Set.mem_univ,
forall_true_left, mem_ball_zero_iff, Pi.ringHom_apply, ← Complex.norm_real,
embedding_of_isReal_apply, Subtype.forall, ← forall₂_or_left, ← not_isReal_iff_isComplex, em,
forall_true_left, norm_embedding_eq]
theorem convexBodyLT_neg_mem (x : E K) (hx : x ∈ (convexBodyLT K f)) :
-x ∈ (convexBodyLT K f) := by
simp only [Set.mem_prod, Prod.fst_neg, Set.mem_pi, Set.mem_univ, Pi.neg_apply,
mem_ball_zero_iff, norm_neg, Real.norm_eq_abs, forall_true_left, Subtype.forall,
Prod.snd_neg, Complex.norm_eq_abs] at hx ⊢
exact hx
theorem convexBodyLT_convex : Convex ℝ (convexBodyLT K f) :=
Convex.prod (convex_pi (fun _ _ => convex_ball _ _)) (convex_pi (fun _ _ => convex_ball _ _))
open Fintype MeasureTheory MeasureTheory.Measure ENNReal
open scoped Classical
variable [NumberField K]
instance : IsAddHaarMeasure (volume : Measure (E K)) := prod.instIsAddHaarMeasure volume volume
instance : NoAtoms (volume : Measure (E K)) := by
obtain ⟨w⟩ := (inferInstance : Nonempty (InfinitePlace K))
by_cases hw : IsReal w
· exact @prod.instNoAtoms_fst _ _ _ _ volume volume _ (pi_noAtoms ⟨w, hw⟩)
· exact @prod.instNoAtoms_snd _ _ _ _ volume volume _
(pi_noAtoms ⟨w, not_isReal_iff_isComplex.mp hw⟩)
noncomputable abbrev convexBodyLTFactor : ℝ≥0 :=
(2 : ℝ≥0) ^ NrRealPlaces K * NNReal.pi ^ NrComplexPlaces K
theorem convexBodyLTFactor_ne_zero : convexBodyLTFactor K ≠ 0 :=
mul_ne_zero (pow_ne_zero _ two_ne_zero) (pow_ne_zero _ pi_ne_zero)
theorem one_le_convexBodyLTFactor : 1 ≤ convexBodyLTFactor K :=
one_le_mul₀ (one_le_pow_of_one_le one_le_two _)
(one_le_pow_of_one_le (le_trans one_le_two Real.two_le_pi) _)
theorem convexBodyLT_volume :
volume (convexBodyLT K f) = (convexBodyLTFactor K) * ∏ w, (f w) ^ (mult w) := by
calc
_ = (∏ x : {w // InfinitePlace.IsReal w}, ENNReal.ofReal (2 * (f x.val))) *
∏ x : {w // InfinitePlace.IsComplex w}, ENNReal.ofReal (f x.val) ^ 2 * NNReal.pi := by
simp_rw [volume_eq_prod, prod_prod, volume_pi, pi_pi, Real.volume_ball, Complex.volume_ball]
_ = ((2:ℝ≥0) ^ NrRealPlaces K * (∏ x : {w // InfinitePlace.IsReal w}, ENNReal.ofReal (f x.val)))
* ((∏ x : {w // IsComplex w}, ENNReal.ofReal (f x.val) ^ 2) *
NNReal.pi ^ NrComplexPlaces K) := by
simp_rw [ofReal_mul (by norm_num : 0 ≤ (2 : ℝ)), Finset.prod_mul_distrib, Finset.prod_const,
Finset.card_univ, ofReal_ofNat, ofReal_coe_nnreal, coe_ofNat]
_ = (convexBodyLTFactor K) * ((∏ x : {w // InfinitePlace.IsReal w}, .ofReal (f x.val)) *
(∏ x : {w // IsComplex w}, ENNReal.ofReal (f x.val) ^ 2)) := by
simp_rw [convexBodyLTFactor, coe_mul, ENNReal.coe_pow]
ring
_ = (convexBodyLTFactor K) * ∏ w, (f w) ^ (mult w) := by
simp_rw [mult, pow_ite, pow_one, Finset.prod_ite, ofReal_coe_nnreal, not_isReal_iff_isComplex,
coe_mul, coe_finset_prod, ENNReal.coe_pow]
congr 2
· refine (Finset.prod_subtype (Finset.univ.filter _) ?_ (fun w => (f w : ℝ≥0∞))).symm
exact fun _ => by simp only [Finset.mem_univ, forall_true_left, Finset.mem_filter, true_and]
· refine (Finset.prod_subtype (Finset.univ.filter _) ?_ (fun w => (f w : ℝ≥0∞) ^ 2)).symm
exact fun _ => by simp only [Finset.mem_univ, forall_true_left, Finset.mem_filter, true_and]
variable {f}
| Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean | 137 | 148 | theorem adjust_f {w₁ : InfinitePlace K} (B : ℝ≥0) (hf : ∀ w, w ≠ w₁ → f w ≠ 0) :
∃ g : InfinitePlace K → ℝ≥0, (∀ w, w ≠ w₁ → g w = f w) ∧ ∏ w, (g w) ^ mult w = B := by |
let S := ∏ w ∈ Finset.univ.erase w₁, (f w) ^ mult w
refine ⟨Function.update f w₁ ((B * S⁻¹) ^ (mult w₁ : ℝ)⁻¹), ?_, ?_⟩
· exact fun w hw => Function.update_noteq hw _ f
· rw [← Finset.mul_prod_erase Finset.univ _ (Finset.mem_univ w₁), Function.update_same,
Finset.prod_congr rfl fun w hw => by rw [Function.update_noteq (Finset.ne_of_mem_erase hw)],
← NNReal.rpow_natCast, ← NNReal.rpow_mul, inv_mul_cancel, NNReal.rpow_one, mul_assoc,
inv_mul_cancel, mul_one]
· rw [Finset.prod_ne_zero_iff]
exact fun w hw => pow_ne_zero _ (hf w (Finset.ne_of_mem_erase hw))
· rw [mult]; split_ifs <;> norm_num
| 0 |
import Mathlib.Topology.UniformSpace.Cauchy
import Mathlib.Topology.UniformSpace.Separation
import Mathlib.Topology.DenseEmbedding
#align_import topology.uniform_space.uniform_embedding from "leanprover-community/mathlib"@"195fcd60ff2bfe392543bceb0ec2adcdb472db4c"
open Filter Function Set Uniformity Topology
section
universe u v w
variable {α : Type u} {β : Type v} {γ : Type w} [UniformSpace α] [UniformSpace β] [UniformSpace γ]
@[mk_iff]
structure UniformInducing (f : α → β) : Prop where
comap_uniformity : comap (fun x : α × α => (f x.1, f x.2)) (𝓤 β) = 𝓤 α
#align uniform_inducing UniformInducing
#align uniform_inducing_iff uniformInducing_iff
lemma uniformInducing_iff_uniformSpace {f : α → β} :
UniformInducing f ↔ ‹UniformSpace β›.comap f = ‹UniformSpace α› := by
rw [uniformInducing_iff, UniformSpace.ext_iff, Filter.ext_iff]
rfl
protected alias ⟨UniformInducing.comap_uniformSpace, _⟩ := uniformInducing_iff_uniformSpace
#align uniform_inducing.comap_uniform_space UniformInducing.comap_uniformSpace
lemma uniformInducing_iff' {f : α → β} :
UniformInducing f ↔ UniformContinuous f ∧ comap (Prod.map f f) (𝓤 β) ≤ 𝓤 α := by
rw [uniformInducing_iff, UniformContinuous, tendsto_iff_comap, le_antisymm_iff, and_comm]; rfl
#align uniform_inducing_iff' uniformInducing_iff'
protected lemma Filter.HasBasis.uniformInducing_iff {ι ι'} {p : ι → Prop} {p' : ι' → Prop} {s s'}
(h : (𝓤 α).HasBasis p s) (h' : (𝓤 β).HasBasis p' s') {f : α → β} :
UniformInducing f ↔
(∀ i, p' i → ∃ j, p j ∧ ∀ x y, (x, y) ∈ s j → (f x, f y) ∈ s' i) ∧
(∀ j, p j → ∃ i, p' i ∧ ∀ x y, (f x, f y) ∈ s' i → (x, y) ∈ s j) := by
simp [uniformInducing_iff', h.uniformContinuous_iff h', (h'.comap _).le_basis_iff h, subset_def]
#align filter.has_basis.uniform_inducing_iff Filter.HasBasis.uniformInducing_iff
theorem UniformInducing.mk' {f : α → β}
(h : ∀ s, s ∈ 𝓤 α ↔ ∃ t ∈ 𝓤 β, ∀ x y : α, (f x, f y) ∈ t → (x, y) ∈ s) : UniformInducing f :=
⟨by simp [eq_comm, Filter.ext_iff, subset_def, h]⟩
#align uniform_inducing.mk' UniformInducing.mk'
theorem uniformInducing_id : UniformInducing (@id α) :=
⟨by rw [← Prod.map_def, Prod.map_id, comap_id]⟩
#align uniform_inducing_id uniformInducing_id
theorem UniformInducing.comp {g : β → γ} (hg : UniformInducing g) {f : α → β}
(hf : UniformInducing f) : UniformInducing (g ∘ f) :=
⟨by rw [← hf.1, ← hg.1, comap_comap]; rfl⟩
#align uniform_inducing.comp UniformInducing.comp
theorem UniformInducing.of_comp_iff {g : β → γ} (hg : UniformInducing g) {f : α → β} :
UniformInducing (g ∘ f) ↔ UniformInducing f := by
refine ⟨fun h ↦ ?_, hg.comp⟩
rw [uniformInducing_iff, ← hg.comap_uniformity, comap_comap, ← h.comap_uniformity,
Function.comp, Function.comp]
theorem UniformInducing.basis_uniformity {f : α → β} (hf : UniformInducing f) {ι : Sort*}
{p : ι → Prop} {s : ι → Set (β × β)} (H : (𝓤 β).HasBasis p s) :
(𝓤 α).HasBasis p fun i => Prod.map f f ⁻¹' s i :=
hf.1 ▸ H.comap _
#align uniform_inducing.basis_uniformity UniformInducing.basis_uniformity
| Mathlib/Topology/UniformSpace/UniformEmbedding.lean | 88 | 90 | theorem UniformInducing.cauchy_map_iff {f : α → β} (hf : UniformInducing f) {F : Filter α} :
Cauchy (map f F) ↔ Cauchy F := by |
simp only [Cauchy, map_neBot_iff, prod_map_map_eq, map_le_iff_le_comap, ← hf.comap_uniformity]
| 0 |
import Mathlib.Control.Traversable.Equiv
import Mathlib.Control.Traversable.Instances
import Batteries.Data.LazyList
import Mathlib.Lean.Thunk
#align_import data.lazy_list.basic from "leanprover-community/mathlib"@"1f0096e6caa61e9c849ec2adbd227e960e9dff58"
universe u
namespace LazyList
open Function
def listEquivLazyList (α : Type*) : List α ≃ LazyList α where
toFun := LazyList.ofList
invFun := LazyList.toList
right_inv := by
intro xs
induction xs using toList.induct
· simp [toList, ofList]
· simp [toList, ofList, *]; rfl
left_inv := by
intro xs
induction xs
· simp [toList, ofList]
· simpa [ofList, toList]
#align lazy_list.list_equiv_lazy_list LazyList.listEquivLazyList
-- Porting note: Added a name to make the recursion work.
instance decidableEq {α : Type u} [DecidableEq α] : DecidableEq (LazyList α)
| nil, nil => isTrue rfl
| cons x xs, cons y ys =>
if h : x = y then
match decidableEq xs.get ys.get with
| isFalse h2 => by
apply isFalse; simp only [cons.injEq, not_and]; intro _ xs_ys; apply h2; rw [xs_ys]
| isTrue h2 => by apply isTrue; congr; ext; exact h2
else by apply isFalse; simp only [cons.injEq, not_and]; intro; contradiction
| nil, cons _ _ => by apply isFalse; simp
| cons _ _, nil => by apply isFalse; simp
protected def traverse {m : Type u → Type u} [Applicative m] {α β : Type u} (f : α → m β) :
LazyList α → m (LazyList β)
| LazyList.nil => pure LazyList.nil
| LazyList.cons x xs => LazyList.cons <$> f x <*> Thunk.pure <$> xs.get.traverse f
#align lazy_list.traverse LazyList.traverse
instance : Traversable LazyList where
map := @LazyList.traverse Id _
traverse := @LazyList.traverse
instance : LawfulTraversable LazyList := by
apply Equiv.isLawfulTraversable' listEquivLazyList <;> intros <;> ext <;> rename_i f xs
· induction' xs using LazyList.rec with _ _ _ _ ih
· simp only [Functor.map, LazyList.traverse, pure, Equiv.map, listEquivLazyList,
Equiv.coe_fn_symm_mk, toList, Equiv.coe_fn_mk, ofList]
· simpa only [Equiv.map, Functor.map, listEquivLazyList, Equiv.coe_fn_symm_mk, Equiv.coe_fn_mk,
LazyList.traverse, Seq.seq, toList, ofList, cons.injEq, true_and]
· ext; apply ih
· simp only [Equiv.map, listEquivLazyList, Equiv.coe_fn_symm_mk, Equiv.coe_fn_mk, comp,
Functor.mapConst]
induction' xs using LazyList.rec with _ _ _ _ ih
· simp only [LazyList.traverse, pure, Functor.map, toList, ofList]
· simpa only [toList, ofList, LazyList.traverse, Seq.seq, Functor.map, cons.injEq, true_and]
· congr; apply ih
· simp only [traverse, Equiv.traverse, listEquivLazyList, Equiv.coe_fn_mk, Equiv.coe_fn_symm_mk]
induction' xs using LazyList.rec with _ tl ih _ ih
· simp only [LazyList.traverse, toList, List.traverse, map_pure, ofList]
· replace ih : tl.get.traverse f = ofList <$> tl.get.toList.traverse f := ih
simp [traverse.eq_2, ih, Functor.map_map, seq_map_assoc, toList, List.traverse, map_seq,
Function.comp, Thunk.pure, ofList]
· apply ih
def init {α} : LazyList α → LazyList α
| LazyList.nil => LazyList.nil
| LazyList.cons x xs =>
let xs' := xs.get
match xs' with
| LazyList.nil => LazyList.nil
| LazyList.cons _ _ => LazyList.cons x (init xs')
#align lazy_list.init LazyList.init
def find {α} (p : α → Prop) [DecidablePred p] : LazyList α → Option α
| nil => none
| cons h t => if p h then some h else t.get.find p
#align lazy_list.find LazyList.find
def interleave {α} : LazyList α → LazyList α → LazyList α
| LazyList.nil, xs => xs
| a@(LazyList.cons _ _), LazyList.nil => a
| LazyList.cons x xs, LazyList.cons y ys =>
LazyList.cons x (LazyList.cons y (interleave xs.get ys.get))
#align lazy_list.interleave LazyList.interleave
def interleaveAll {α} : List (LazyList α) → LazyList α
| [] => LazyList.nil
| x :: xs => interleave x (interleaveAll xs)
#align lazy_list.interleave_all LazyList.interleaveAll
protected def bind {α β} : LazyList α → (α → LazyList β) → LazyList β
| LazyList.nil, _ => LazyList.nil
| LazyList.cons x xs, f => (f x).append (xs.get.bind f)
#align lazy_list.bind LazyList.bind
def reverse {α} (xs : LazyList α) : LazyList α :=
ofList xs.toList.reverse
#align lazy_list.reverse LazyList.reverse
instance : Monad LazyList where
pure := @LazyList.singleton
bind := @LazyList.bind
-- Porting note: Added `Thunk.pure` to definition.
| Mathlib/Data/LazyList/Basic.lean | 143 | 147 | theorem append_nil {α} (xs : LazyList α) : xs.append (Thunk.pure LazyList.nil) = xs := by |
induction' xs using LazyList.rec with _ _ _ _ ih
· simp only [Thunk.pure, append, Thunk.get]
· simpa only [append, cons.injEq, true_and]
· ext; apply ih
| 0 |
import Mathlib.Data.Set.Prod
import Mathlib.Logic.Function.Conjugate
#align_import data.set.function from "leanprover-community/mathlib"@"996b0ff959da753a555053a480f36e5f264d4207"
variable {α β γ : Type*} {ι : Sort*} {π : α → Type*}
open Equiv Equiv.Perm Function
namespace Set
section restrict
def restrict (s : Set α) (f : ∀ a : α, π a) : ∀ a : s, π a := fun x => f x
#align set.restrict Set.restrict
theorem restrict_eq (f : α → β) (s : Set α) : s.restrict f = f ∘ Subtype.val :=
rfl
#align set.restrict_eq Set.restrict_eq
@[simp]
theorem restrict_apply (f : α → β) (s : Set α) (x : s) : s.restrict f x = f x :=
rfl
#align set.restrict_apply Set.restrict_apply
theorem restrict_eq_iff {f : ∀ a, π a} {s : Set α} {g : ∀ a : s, π a} :
restrict s f = g ↔ ∀ (a) (ha : a ∈ s), f a = g ⟨a, ha⟩ :=
funext_iff.trans Subtype.forall
#align set.restrict_eq_iff Set.restrict_eq_iff
theorem eq_restrict_iff {s : Set α} {f : ∀ a : s, π a} {g : ∀ a, π a} :
f = restrict s g ↔ ∀ (a) (ha : a ∈ s), f ⟨a, ha⟩ = g a :=
funext_iff.trans Subtype.forall
#align set.eq_restrict_iff Set.eq_restrict_iff
@[simp]
theorem range_restrict (f : α → β) (s : Set α) : Set.range (s.restrict f) = f '' s :=
(range_comp _ _).trans <| congr_arg (f '' ·) Subtype.range_coe
#align set.range_restrict Set.range_restrict
theorem image_restrict (f : α → β) (s t : Set α) :
s.restrict f '' (Subtype.val ⁻¹' t) = f '' (t ∩ s) := by
rw [restrict_eq, image_comp, image_preimage_eq_inter_range, Subtype.range_coe]
#align set.image_restrict Set.image_restrict
@[simp]
theorem restrict_dite {s : Set α} [∀ x, Decidable (x ∈ s)] (f : ∀ a ∈ s, β)
(g : ∀ a ∉ s, β) :
(s.restrict fun a => if h : a ∈ s then f a h else g a h) = (fun a : s => f a a.2) :=
funext fun a => dif_pos a.2
#align set.restrict_dite Set.restrict_dite
@[simp]
theorem restrict_dite_compl {s : Set α} [∀ x, Decidable (x ∈ s)] (f : ∀ a ∈ s, β)
(g : ∀ a ∉ s, β) :
(sᶜ.restrict fun a => if h : a ∈ s then f a h else g a h) = (fun a : (sᶜ : Set α) => g a a.2) :=
funext fun a => dif_neg a.2
#align set.restrict_dite_compl Set.restrict_dite_compl
@[simp]
theorem restrict_ite (f g : α → β) (s : Set α) [∀ x, Decidable (x ∈ s)] :
(s.restrict fun a => if a ∈ s then f a else g a) = s.restrict f :=
restrict_dite _ _
#align set.restrict_ite Set.restrict_ite
@[simp]
theorem restrict_ite_compl (f g : α → β) (s : Set α) [∀ x, Decidable (x ∈ s)] :
(sᶜ.restrict fun a => if a ∈ s then f a else g a) = sᶜ.restrict g :=
restrict_dite_compl _ _
#align set.restrict_ite_compl Set.restrict_ite_compl
@[simp]
theorem restrict_piecewise (f g : α → β) (s : Set α) [∀ x, Decidable (x ∈ s)] :
s.restrict (piecewise s f g) = s.restrict f :=
restrict_ite _ _ _
#align set.restrict_piecewise Set.restrict_piecewise
@[simp]
theorem restrict_piecewise_compl (f g : α → β) (s : Set α) [∀ x, Decidable (x ∈ s)] :
sᶜ.restrict (piecewise s f g) = sᶜ.restrict g :=
restrict_ite_compl _ _ _
#align set.restrict_piecewise_compl Set.restrict_piecewise_compl
theorem restrict_extend_range (f : α → β) (g : α → γ) (g' : β → γ) :
(range f).restrict (extend f g g') = fun x => g x.coe_prop.choose := by
classical
exact restrict_dite _ _
#align set.restrict_extend_range Set.restrict_extend_range
@[simp]
theorem restrict_extend_compl_range (f : α → β) (g : α → γ) (g' : β → γ) :
(range f)ᶜ.restrict (extend f g g') = g' ∘ Subtype.val := by
classical
exact restrict_dite_compl _ _
#align set.restrict_extend_compl_range Set.restrict_extend_compl_range
| Mathlib/Data/Set/Function.lean | 130 | 136 | theorem range_extend_subset (f : α → β) (g : α → γ) (g' : β → γ) :
range (extend f g g') ⊆ range g ∪ g' '' (range f)ᶜ := by |
classical
rintro _ ⟨y, rfl⟩
rw [extend_def]
split_ifs with h
exacts [Or.inl (mem_range_self _), Or.inr (mem_image_of_mem _ h)]
| 0 |
import Mathlib.MeasureTheory.Integral.Periodic
import Mathlib.Data.ZMod.Quotient
#align_import measure_theory.group.add_circle from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
open Set Function Filter MeasureTheory MeasureTheory.Measure Metric
open scoped MeasureTheory Pointwise Topology ENNReal
namespace AddCircle
variable {T : ℝ} [hT : Fact (0 < T)]
theorem closedBall_ae_eq_ball {x : AddCircle T} {ε : ℝ} : closedBall x ε =ᵐ[volume] ball x ε := by
rcases le_or_lt ε 0 with hε | hε
· rw [ball_eq_empty.mpr hε, ae_eq_empty, volume_closedBall,
min_eq_right (by linarith [hT.out] : 2 * ε ≤ T), ENNReal.ofReal_eq_zero]
exact mul_nonpos_of_nonneg_of_nonpos zero_le_two hε
· suffices volume (closedBall x ε) ≤ volume (ball x ε) by
exact (ae_eq_of_subset_of_measure_ge ball_subset_closedBall this measurableSet_ball
(measure_ne_top _ _)).symm
have : Tendsto (fun δ => volume (closedBall x δ)) (𝓝[<] ε) (𝓝 <| volume (closedBall x ε)) := by
simp_rw [volume_closedBall]
refine ENNReal.tendsto_ofReal (Tendsto.min tendsto_const_nhds <| Tendsto.const_mul _ ?_)
convert (@monotone_id ℝ _).tendsto_nhdsWithin_Iio ε
simp
refine le_of_tendsto this (mem_nhdsWithin_Iio_iff_exists_Ioo_subset.mpr ⟨0, hε, fun r hr => ?_⟩)
exact measure_mono (closedBall_subset_ball hr.2)
#align add_circle.closed_ball_ae_eq_ball AddCircle.closedBall_ae_eq_ball
| Mathlib/MeasureTheory/Group/AddCircle.lean | 54 | 92 | theorem isAddFundamentalDomain_of_ae_ball (I : Set <| AddCircle T) (u x : AddCircle T)
(hu : IsOfFinAddOrder u) (hI : I =ᵐ[volume] ball x (T / (2 * addOrderOf u))) :
IsAddFundamentalDomain (AddSubgroup.zmultiples u) I := by |
set G := AddSubgroup.zmultiples u
set n := addOrderOf u
set B := ball x (T / (2 * n))
have hn : 1 ≤ (n : ℝ) := by norm_cast; linarith [hu.addOrderOf_pos]
refine IsAddFundamentalDomain.mk_of_measure_univ_le ?_ ?_ ?_ ?_
· -- `NullMeasurableSet I volume`
exact measurableSet_ball.nullMeasurableSet.congr hI.symm
· -- `∀ (g : G), g ≠ 0 → AEDisjoint volume (g +ᵥ I) I`
rintro ⟨g, hg⟩ hg'
replace hg' : g ≠ 0 := by simpa only [Ne, AddSubgroup.mk_eq_zero] using hg'
change AEDisjoint volume (g +ᵥ I) I
refine AEDisjoint.congr (Disjoint.aedisjoint ?_)
((quasiMeasurePreserving_add_left volume (-g)).vadd_ae_eq_of_ae_eq g hI) hI
have hBg : g +ᵥ B = ball (g + x) (T / (2 * n)) := by
rw [add_comm g x, ← singleton_add_ball _ x g, add_ball, thickening_singleton]
rw [hBg]
apply ball_disjoint_ball
rw [dist_eq_norm, add_sub_cancel_right, div_mul_eq_div_div, ← add_div, ← add_div,
add_self_div_two, div_le_iff' (by positivity : 0 < (n : ℝ)), ← nsmul_eq_mul]
refine (le_add_order_smul_norm_of_isOfFinAddOrder (hu.of_mem_zmultiples hg) hg').trans
(nsmul_le_nsmul_left (norm_nonneg g) ?_)
exact Nat.le_of_dvd (addOrderOf_pos_iff.mpr hu) (addOrderOf_dvd_of_mem_zmultiples hg)
· -- `∀ (g : G), QuasiMeasurePreserving (VAdd.vadd g) volume volume`
exact fun g => quasiMeasurePreserving_add_left (G := AddCircle T) volume g
· -- `volume univ ≤ ∑' (g : G), volume (g +ᵥ I)`
replace hI := hI.trans closedBall_ae_eq_ball.symm
haveI : Fintype G := @Fintype.ofFinite _ hu.finite_zmultiples.to_subtype
have hG_card : (Finset.univ : Finset G).card = n := by
show _ = addOrderOf u
rw [← Nat.card_zmultiples, Nat.card_eq_fintype_card]; rfl
simp_rw [measure_vadd]
rw [AddCircle.measure_univ, tsum_fintype, Finset.sum_const, measure_congr hI,
volume_closedBall, ← ENNReal.ofReal_nsmul, mul_div, mul_div_mul_comm,
div_self, one_mul, min_eq_right (div_le_self hT.out.le hn), hG_card,
nsmul_eq_mul, mul_div_cancel₀ T (lt_of_lt_of_le zero_lt_one hn).ne.symm]
exact two_ne_zero
| 0 |
import Mathlib.Algebra.Associated
import Mathlib.Algebra.Ring.Regular
import Mathlib.Tactic.Common
#align_import algebra.gcd_monoid.basic from "leanprover-community/mathlib"@"550b58538991c8977703fdeb7c9d51a5aa27df11"
variable {α : Type*}
-- Porting note: mathlib3 had a `@[protect_proj]` here, but adding `protected` to all the fields
-- adds unnecessary clutter to later code
class NormalizationMonoid (α : Type*) [CancelCommMonoidWithZero α] where
normUnit : α → αˣ
normUnit_zero : normUnit 0 = 1
normUnit_mul : ∀ {a b}, a ≠ 0 → b ≠ 0 → normUnit (a * b) = normUnit a * normUnit b
normUnit_coe_units : ∀ u : αˣ, normUnit u = u⁻¹
#align normalization_monoid NormalizationMonoid
export NormalizationMonoid (normUnit normUnit_zero normUnit_mul normUnit_coe_units)
attribute [simp] normUnit_coe_units normUnit_zero normUnit_mul
section NormalizationMonoid
variable [CancelCommMonoidWithZero α] [NormalizationMonoid α]
@[simp]
theorem normUnit_one : normUnit (1 : α) = 1 :=
normUnit_coe_units 1
#align norm_unit_one normUnit_one
-- Porting note (#11083): quite slow. Improve performance?
def normalize : α →*₀ α where
toFun x := x * normUnit x
map_zero' := by
simp only [normUnit_zero]
exact mul_one (0:α)
map_one' := by dsimp only; rw [normUnit_one, one_mul]; rfl
map_mul' x y :=
(by_cases fun hx : x = 0 => by dsimp only; rw [hx, zero_mul, zero_mul, zero_mul]) fun hx =>
(by_cases fun hy : y = 0 => by dsimp only; rw [hy, mul_zero, zero_mul, mul_zero]) fun hy => by
simp only [normUnit_mul hx hy, Units.val_mul]; simp only [mul_assoc, mul_left_comm y]
#align normalize normalize
theorem associated_normalize (x : α) : Associated x (normalize x) :=
⟨_, rfl⟩
#align associated_normalize associated_normalize
theorem normalize_associated (x : α) : Associated (normalize x) x :=
(associated_normalize _).symm
#align normalize_associated normalize_associated
theorem associated_normalize_iff {x y : α} : Associated x (normalize y) ↔ Associated x y :=
⟨fun h => h.trans (normalize_associated y), fun h => h.trans (associated_normalize y)⟩
#align associated_normalize_iff associated_normalize_iff
theorem normalize_associated_iff {x y : α} : Associated (normalize x) y ↔ Associated x y :=
⟨fun h => (associated_normalize _).trans h, fun h => (normalize_associated _).trans h⟩
#align normalize_associated_iff normalize_associated_iff
theorem Associates.mk_normalize (x : α) : Associates.mk (normalize x) = Associates.mk x :=
Associates.mk_eq_mk_iff_associated.2 (normalize_associated _)
#align associates.mk_normalize Associates.mk_normalize
@[simp]
theorem normalize_apply (x : α) : normalize x = x * normUnit x :=
rfl
#align normalize_apply normalize_apply
-- Porting note (#10618): `simp` can prove this
-- @[simp]
theorem normalize_zero : normalize (0 : α) = 0 :=
normalize.map_zero
#align normalize_zero normalize_zero
-- Porting note (#10618): `simp` can prove this
-- @[simp]
theorem normalize_one : normalize (1 : α) = 1 :=
normalize.map_one
#align normalize_one normalize_one
theorem normalize_coe_units (u : αˣ) : normalize (u : α) = 1 := by simp
#align normalize_coe_units normalize_coe_units
theorem normalize_eq_zero {x : α} : normalize x = 0 ↔ x = 0 :=
⟨fun hx => (associated_zero_iff_eq_zero x).1 <| hx ▸ associated_normalize _, by
rintro rfl; exact normalize_zero⟩
#align normalize_eq_zero normalize_eq_zero
theorem normalize_eq_one {x : α} : normalize x = 1 ↔ IsUnit x :=
⟨fun hx => isUnit_iff_exists_inv.2 ⟨_, hx⟩, fun ⟨u, hu⟩ => hu ▸ normalize_coe_units u⟩
#align normalize_eq_one normalize_eq_one
-- Porting note (#11083): quite slow. Improve performance?
@[simp]
theorem normUnit_mul_normUnit (a : α) : normUnit (a * normUnit a) = 1 := by
nontriviality α using Subsingleton.elim a 0
obtain rfl | h := eq_or_ne a 0
· rw [normUnit_zero, zero_mul, normUnit_zero]
· rw [normUnit_mul h (Units.ne_zero _), normUnit_coe_units, mul_inv_eq_one]
#align norm_unit_mul_norm_unit normUnit_mul_normUnit
theorem normalize_idem (x : α) : normalize (normalize x) = normalize x := by simp
#align normalize_idem normalize_idem
| Mathlib/Algebra/GCDMonoid/Basic.lean | 172 | 181 | theorem normalize_eq_normalize {a b : α} (hab : a ∣ b) (hba : b ∣ a) :
normalize a = normalize b := by |
nontriviality α
rcases associated_of_dvd_dvd hab hba with ⟨u, rfl⟩
refine by_cases (by rintro rfl; simp only [zero_mul]) fun ha : a ≠ 0 => ?_
suffices a * ↑(normUnit a) = a * ↑u * ↑(normUnit a) * ↑u⁻¹ by
simpa only [normalize_apply, mul_assoc, normUnit_mul ha u.ne_zero, normUnit_coe_units]
calc
a * ↑(normUnit a) = a * ↑(normUnit a) * ↑u * ↑u⁻¹ := (Units.mul_inv_cancel_right _ _).symm
_ = a * ↑u * ↑(normUnit a) * ↑u⁻¹ := by rw [mul_right_comm a]
| 0 |
import Mathlib.Data.List.Basic
#align_import data.list.count from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83"
assert_not_exists Set.range
assert_not_exists GroupWithZero
assert_not_exists Ring
open Nat
variable {α : Type*} {l : List α}
namespace List
section Count
variable [DecidableEq α]
#align list.count_nil List.count_nil
@[deprecated (since := "2023-08-23")]
| Mathlib/Data/List/Count.lean | 90 | 93 | theorem count_cons' (a b : α) (l : List α) :
count a (b :: l) = count a l + if a = b then 1 else 0 := by |
simp only [count, beq_iff_eq, countP_cons, Nat.add_right_inj]
simp only [eq_comm]
| 0 |
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
noncomputable section
open scoped Classical
@[ext]
structure ComplexShape (ι : Type*) where
Rel : ι → ι → Prop
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
congr
exact c.next_eq rij rik
instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
constructor
rintro ⟨i, rik⟩ ⟨j, rjk⟩
congr
exact c.prev_eq rik rjk
def next (c : ComplexShape ι) (i : ι) : ι :=
if h : ∃ j, c.Rel i j then h.choose else i
#align complex_shape.next ComplexShape.next
def prev (c : ComplexShape ι) (j : ι) : ι :=
if h : ∃ i, c.Rel i j then h.choose else j
#align complex_shape.prev ComplexShape.prev
| Mathlib/Algebra/Homology/ComplexShape.lean | 154 | 158 | theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j := by |
apply c.next_eq _ h
rw [next]
rw [dif_pos]
exact Exists.choose_spec ⟨j, h⟩
| 0 |
import Mathlib.Geometry.RingedSpace.PresheafedSpace.Gluing
import Mathlib.AlgebraicGeometry.OpenImmersion
#align_import algebraic_geometry.gluing from "leanprover-community/mathlib"@"533f62f4dd62a5aad24a04326e6e787c8f7e98b1"
set_option linter.uppercaseLean3 false
noncomputable section
universe u
open TopologicalSpace CategoryTheory Opposite
open CategoryTheory.Limits AlgebraicGeometry.PresheafedSpace
open CategoryTheory.GlueData
namespace AlgebraicGeometry
namespace Scheme
-- Porting note(#5171): @[nolint has_nonempty_instance]; linter not ported yet
structure GlueData extends CategoryTheory.GlueData Scheme where
f_open : ∀ i j, IsOpenImmersion (f i j)
#align algebraic_geometry.Scheme.glue_data AlgebraicGeometry.Scheme.GlueData
attribute [instance] GlueData.f_open
namespace OpenCover
variable {X : Scheme.{u}} (𝒰 : OpenCover.{u} X)
def gluedCoverT' (x y z : 𝒰.J) :
pullback (pullback.fst : pullback (𝒰.map x) (𝒰.map y) ⟶ _)
(pullback.fst : pullback (𝒰.map x) (𝒰.map z) ⟶ _) ⟶
pullback (pullback.fst : pullback (𝒰.map y) (𝒰.map z) ⟶ _)
(pullback.fst : pullback (𝒰.map y) (𝒰.map x) ⟶ _) := by
refine (pullbackRightPullbackFstIso _ _ _).hom ≫ ?_
refine ?_ ≫ (pullbackSymmetry _ _).hom
refine ?_ ≫ (pullbackRightPullbackFstIso _ _ _).inv
refine pullback.map _ _ _ _ (pullbackSymmetry _ _).hom (𝟙 _) (𝟙 _) ?_ ?_
· simp [pullback.condition]
· simp
#align algebraic_geometry.Scheme.open_cover.glued_cover_t' AlgebraicGeometry.Scheme.OpenCover.gluedCoverT'
@[simp, reassoc]
theorem gluedCoverT'_fst_fst (x y z : 𝒰.J) :
𝒰.gluedCoverT' x y z ≫ pullback.fst ≫ pullback.fst = pullback.fst ≫ pullback.snd := by
delta gluedCoverT'; simp
#align algebraic_geometry.Scheme.open_cover.glued_cover_t'_fst_fst AlgebraicGeometry.Scheme.OpenCover.gluedCoverT'_fst_fst
@[simp, reassoc]
theorem gluedCoverT'_fst_snd (x y z : 𝒰.J) :
gluedCoverT' 𝒰 x y z ≫ pullback.fst ≫ pullback.snd = pullback.snd ≫ pullback.snd := by
delta gluedCoverT'; simp
#align algebraic_geometry.Scheme.open_cover.glued_cover_t'_fst_snd AlgebraicGeometry.Scheme.OpenCover.gluedCoverT'_fst_snd
@[simp, reassoc]
theorem gluedCoverT'_snd_fst (x y z : 𝒰.J) :
gluedCoverT' 𝒰 x y z ≫ pullback.snd ≫ pullback.fst = pullback.fst ≫ pullback.snd := by
delta gluedCoverT'; simp
#align algebraic_geometry.Scheme.open_cover.glued_cover_t'_snd_fst AlgebraicGeometry.Scheme.OpenCover.gluedCoverT'_snd_fst
@[simp, reassoc]
theorem gluedCoverT'_snd_snd (x y z : 𝒰.J) :
gluedCoverT' 𝒰 x y z ≫ pullback.snd ≫ pullback.snd = pullback.fst ≫ pullback.fst := by
delta gluedCoverT'; simp
#align algebraic_geometry.Scheme.open_cover.glued_cover_t'_snd_snd AlgebraicGeometry.Scheme.OpenCover.gluedCoverT'_snd_snd
theorem glued_cover_cocycle_fst (x y z : 𝒰.J) :
gluedCoverT' 𝒰 x y z ≫ gluedCoverT' 𝒰 y z x ≫ gluedCoverT' 𝒰 z x y ≫ pullback.fst =
pullback.fst := by
apply pullback.hom_ext <;> simp
#align algebraic_geometry.Scheme.open_cover.glued_cover_cocycle_fst AlgebraicGeometry.Scheme.OpenCover.glued_cover_cocycle_fst
| Mathlib/AlgebraicGeometry/Gluing.lean | 325 | 328 | theorem glued_cover_cocycle_snd (x y z : 𝒰.J) :
gluedCoverT' 𝒰 x y z ≫ gluedCoverT' 𝒰 y z x ≫ gluedCoverT' 𝒰 z x y ≫ pullback.snd =
pullback.snd := by |
apply pullback.hom_ext <;> simp [pullback.condition]
| 0 |
import Mathlib.Data.Fintype.List
#align_import data.list.cycle from "leanprover-community/mathlib"@"7413128c3bcb3b0818e3e18720abc9ea3100fb49"
assert_not_exists MonoidWithZero
namespace List
variable {α : Type*} [DecidableEq α]
def nextOr : ∀ (_ : List α) (_ _ : α), α
| [], _, default => default
| [_], _, default => default
-- Handles the not-found and the wraparound case
| y :: z :: xs, x, default => if x = y then z else nextOr (z :: xs) x default
#align list.next_or List.nextOr
@[simp]
theorem nextOr_nil (x d : α) : nextOr [] x d = d :=
rfl
#align list.next_or_nil List.nextOr_nil
@[simp]
theorem nextOr_singleton (x y d : α) : nextOr [y] x d = d :=
rfl
#align list.next_or_singleton List.nextOr_singleton
@[simp]
theorem nextOr_self_cons_cons (xs : List α) (x y d : α) : nextOr (x :: y :: xs) x d = y :=
if_pos rfl
#align list.next_or_self_cons_cons List.nextOr_self_cons_cons
theorem nextOr_cons_of_ne (xs : List α) (y x d : α) (h : x ≠ y) :
nextOr (y :: xs) x d = nextOr xs x d := by
cases' xs with z zs
· rfl
· exact if_neg h
#align list.next_or_cons_of_ne List.nextOr_cons_of_ne
theorem nextOr_eq_nextOr_of_mem_of_ne (xs : List α) (x d d' : α) (x_mem : x ∈ xs)
(x_ne : x ≠ xs.getLast (ne_nil_of_mem x_mem)) : nextOr xs x d = nextOr xs x d' := by
induction' xs with y ys IH
· cases x_mem
cases' ys with z zs
· simp at x_mem x_ne
contradiction
by_cases h : x = y
· rw [h, nextOr_self_cons_cons, nextOr_self_cons_cons]
· rw [nextOr, nextOr, IH]
· simpa [h] using x_mem
· simpa using x_ne
#align list.next_or_eq_next_or_of_mem_of_ne List.nextOr_eq_nextOr_of_mem_of_ne
theorem mem_of_nextOr_ne {xs : List α} {x d : α} (h : nextOr xs x d ≠ d) : x ∈ xs := by
induction' xs with y ys IH
· simp at h
cases' ys with z zs
· simp at h
· by_cases hx : x = y
· simp [hx]
· rw [nextOr_cons_of_ne _ _ _ _ hx] at h
simpa [hx] using IH h
#align list.mem_of_next_or_ne List.mem_of_nextOr_ne
theorem nextOr_concat {xs : List α} {x : α} (d : α) (h : x ∉ xs) : nextOr (xs ++ [x]) x d = d := by
induction' xs with z zs IH
· simp
· obtain ⟨hz, hzs⟩ := not_or.mp (mt mem_cons.2 h)
rw [cons_append, nextOr_cons_of_ne _ _ _ _ hz, IH hzs]
#align list.next_or_concat List.nextOr_concat
| Mathlib/Data/List/Cycle.lean | 94 | 106 | theorem nextOr_mem {xs : List α} {x d : α} (hd : d ∈ xs) : nextOr xs x d ∈ xs := by |
revert hd
suffices ∀ xs' : List α, (∀ x ∈ xs, x ∈ xs') → d ∈ xs' → nextOr xs x d ∈ xs' by
exact this xs fun _ => id
intro xs' hxs' hd
induction' xs with y ys ih
· exact hd
cases' ys with z zs
· exact hd
rw [nextOr]
split_ifs with h
· exact hxs' _ (mem_cons_of_mem _ (mem_cons_self _ _))
· exact ih fun _ h => hxs' _ (mem_cons_of_mem _ h)
| 0 |
import Mathlib.Algebra.Polynomial.Derivative
import Mathlib.Algebra.Polynomial.Roots
import Mathlib.RingTheory.EuclideanDomain
#align_import data.polynomial.field_division from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821"
noncomputable section
open Polynomial
namespace Polynomial
universe u v w y z
variable {R : Type u} {S : Type v} {k : Type y} {A : Type z} {a b : R} {n : ℕ}
section CommRing
variable [CommRing R]
theorem rootMultiplicity_sub_one_le_derivative_rootMultiplicity_of_ne_zero
(p : R[X]) (t : R) (hnezero : derivative p ≠ 0) :
p.rootMultiplicity t - 1 ≤ p.derivative.rootMultiplicity t :=
(le_rootMultiplicity_iff hnezero).2 <|
pow_sub_one_dvd_derivative_of_pow_dvd (p.pow_rootMultiplicity_dvd t)
theorem derivative_rootMultiplicity_of_root_of_mem_nonZeroDivisors
{p : R[X]} {t : R} (hpt : Polynomial.IsRoot p t)
(hnzd : (p.rootMultiplicity t : R) ∈ nonZeroDivisors R) :
(derivative p).rootMultiplicity t = p.rootMultiplicity t - 1 := by
by_cases h : p = 0
· simp only [h, map_zero, rootMultiplicity_zero]
obtain ⟨g, hp, hndvd⟩ := p.exists_eq_pow_rootMultiplicity_mul_and_not_dvd h t
set m := p.rootMultiplicity t
have hm : m - 1 + 1 = m := Nat.sub_add_cancel <| (rootMultiplicity_pos h).2 hpt
have hndvd : ¬(X - C t) ^ m ∣ derivative p := by
rw [hp, derivative_mul, dvd_add_left (dvd_mul_right _ _),
derivative_X_sub_C_pow, ← hm, pow_succ, hm, mul_comm (C _), mul_assoc,
dvd_cancel_left_mem_nonZeroDivisors (monic_X_sub_C t |>.pow _ |>.mem_nonZeroDivisors)]
rw [dvd_iff_isRoot, IsRoot] at hndvd ⊢
rwa [eval_mul, eval_C, mul_left_mem_nonZeroDivisors_eq_zero_iff hnzd]
have hnezero : derivative p ≠ 0 := fun h ↦ hndvd (by rw [h]; exact dvd_zero _)
exact le_antisymm (by rwa [rootMultiplicity_le_iff hnezero, hm])
(rootMultiplicity_sub_one_le_derivative_rootMultiplicity_of_ne_zero _ t hnezero)
theorem isRoot_iterate_derivative_of_lt_rootMultiplicity {p : R[X]} {t : R} {n : ℕ}
(hn : n < p.rootMultiplicity t) : (derivative^[n] p).IsRoot t :=
dvd_iff_isRoot.mp <| (dvd_pow_self _ <| Nat.sub_ne_zero_of_lt hn).trans
(pow_sub_dvd_iterate_derivative_of_pow_dvd _ <| p.pow_rootMultiplicity_dvd t)
open Finset in
| Mathlib/Algebra/Polynomial/FieldDivision.lean | 65 | 76 | theorem eval_iterate_derivative_rootMultiplicity {p : R[X]} {t : R} :
(derivative^[p.rootMultiplicity t] p).eval t =
(p.rootMultiplicity t).factorial • (p /ₘ (X - C t) ^ p.rootMultiplicity t).eval t := by |
set m := p.rootMultiplicity t with hm
conv_lhs => rw [← p.pow_mul_divByMonic_rootMultiplicity_eq t, ← hm]
rw [iterate_derivative_mul, eval_finset_sum, sum_eq_single_of_mem _ (mem_range.mpr m.succ_pos)]
· rw [m.choose_zero_right, one_smul, eval_mul, m.sub_zero, iterate_derivative_X_sub_pow_self,
eval_natCast, nsmul_eq_mul]; rfl
· intro b hb hb0
rw [iterate_derivative_X_sub_pow, eval_smul, eval_mul, eval_smul, eval_pow,
Nat.sub_sub_self (mem_range_succ_iff.mp hb), eval_sub, eval_X, eval_C, sub_self,
zero_pow hb0, smul_zero, zero_mul, smul_zero]
| 0 |
import Mathlib.MeasureTheory.Decomposition.Lebesgue
import Mathlib.MeasureTheory.Measure.Complex
import Mathlib.MeasureTheory.Decomposition.Jordan
import Mathlib.MeasureTheory.Measure.WithDensityVectorMeasure
noncomputable section
open scoped Classical MeasureTheory NNReal ENNReal
open Set
variable {α β : Type*} {m : MeasurableSpace α} {μ ν : MeasureTheory.Measure α}
namespace MeasureTheory
namespace SignedMeasure
open Measure
class HaveLebesgueDecomposition (s : SignedMeasure α) (μ : Measure α) : Prop where
posPart : s.toJordanDecomposition.posPart.HaveLebesgueDecomposition μ
negPart : s.toJordanDecomposition.negPart.HaveLebesgueDecomposition μ
#align measure_theory.signed_measure.have_lebesgue_decomposition MeasureTheory.SignedMeasure.HaveLebesgueDecomposition
#align measure_theory.signed_measure.have_lebesgue_decomposition.pos_part MeasureTheory.SignedMeasure.HaveLebesgueDecomposition.posPart
#align measure_theory.signed_measure.have_lebesgue_decomposition.neg_part MeasureTheory.SignedMeasure.HaveLebesgueDecomposition.negPart
attribute [instance] HaveLebesgueDecomposition.posPart
attribute [instance] HaveLebesgueDecomposition.negPart
theorem not_haveLebesgueDecomposition_iff (s : SignedMeasure α) (μ : Measure α) :
¬s.HaveLebesgueDecomposition μ ↔
¬s.toJordanDecomposition.posPart.HaveLebesgueDecomposition μ ∨
¬s.toJordanDecomposition.negPart.HaveLebesgueDecomposition μ :=
⟨fun h => not_or_of_imp fun hp hn => h ⟨hp, hn⟩, fun h hl => (not_and_or.2 h) ⟨hl.1, hl.2⟩⟩
#align measure_theory.signed_measure.not_have_lebesgue_decomposition_iff MeasureTheory.SignedMeasure.not_haveLebesgueDecomposition_iff
-- `inferInstance` directly does not work
-- see Note [lower instance priority]
instance (priority := 100) haveLebesgueDecomposition_of_sigmaFinite (s : SignedMeasure α)
(μ : Measure α) [SigmaFinite μ] : s.HaveLebesgueDecomposition μ where
posPart := inferInstance
negPart := inferInstance
#align measure_theory.signed_measure.have_lebesgue_decomposition_of_sigma_finite MeasureTheory.SignedMeasure.haveLebesgueDecomposition_of_sigmaFinite
instance haveLebesgueDecomposition_neg (s : SignedMeasure α) (μ : Measure α)
[s.HaveLebesgueDecomposition μ] : (-s).HaveLebesgueDecomposition μ where
posPart := by
rw [toJordanDecomposition_neg, JordanDecomposition.neg_posPart]
infer_instance
negPart := by
rw [toJordanDecomposition_neg, JordanDecomposition.neg_negPart]
infer_instance
#align measure_theory.signed_measure.have_lebesgue_decomposition_neg MeasureTheory.SignedMeasure.haveLebesgueDecomposition_neg
instance haveLebesgueDecomposition_smul (s : SignedMeasure α) (μ : Measure α)
[s.HaveLebesgueDecomposition μ] (r : ℝ≥0) : (r • s).HaveLebesgueDecomposition μ where
posPart := by
rw [toJordanDecomposition_smul, JordanDecomposition.smul_posPart]
infer_instance
negPart := by
rw [toJordanDecomposition_smul, JordanDecomposition.smul_negPart]
infer_instance
#align measure_theory.signed_measure.have_lebesgue_decomposition_smul MeasureTheory.SignedMeasure.haveLebesgueDecomposition_smul
instance haveLebesgueDecomposition_smul_real (s : SignedMeasure α) (μ : Measure α)
[s.HaveLebesgueDecomposition μ] (r : ℝ) : (r • s).HaveLebesgueDecomposition μ := by
by_cases hr : 0 ≤ r
· lift r to ℝ≥0 using hr
exact s.haveLebesgueDecomposition_smul μ _
· rw [not_le] at hr
refine
{ posPart := by
rw [toJordanDecomposition_smul_real, JordanDecomposition.real_smul_posPart_neg _ _ hr]
infer_instance
negPart := by
rw [toJordanDecomposition_smul_real, JordanDecomposition.real_smul_negPart_neg _ _ hr]
infer_instance }
#align measure_theory.signed_measure.have_lebesgue_decomposition_smul_real MeasureTheory.SignedMeasure.haveLebesgueDecomposition_smul_real
def singularPart (s : SignedMeasure α) (μ : Measure α) : SignedMeasure α :=
(s.toJordanDecomposition.posPart.singularPart μ).toSignedMeasure -
(s.toJordanDecomposition.negPart.singularPart μ).toSignedMeasure
#align measure_theory.signed_measure.singular_part MeasureTheory.SignedMeasure.singularPart
section
| Mathlib/MeasureTheory/Decomposition/SignedLebesgue.lean | 131 | 145 | theorem singularPart_mutuallySingular (s : SignedMeasure α) (μ : Measure α) :
s.toJordanDecomposition.posPart.singularPart μ ⟂ₘ
s.toJordanDecomposition.negPart.singularPart μ := by |
by_cases hl : s.HaveLebesgueDecomposition μ
· obtain ⟨i, hi, hpos, hneg⟩ := s.toJordanDecomposition.mutuallySingular
rw [s.toJordanDecomposition.posPart.haveLebesgueDecomposition_add μ] at hpos
rw [s.toJordanDecomposition.negPart.haveLebesgueDecomposition_add μ] at hneg
rw [add_apply, add_eq_zero_iff] at hpos hneg
exact ⟨i, hi, hpos.1, hneg.1⟩
· rw [not_haveLebesgueDecomposition_iff] at hl
cases' hl with hp hn
· rw [Measure.singularPart, dif_neg hp]
exact MutuallySingular.zero_left
· rw [Measure.singularPart, Measure.singularPart, dif_neg hn]
exact MutuallySingular.zero_right
| 0 |
import Mathlib.Combinatorics.Quiver.Cast
import Mathlib.Combinatorics.Quiver.Symmetric
#align_import combinatorics.quiver.single_obj from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
namespace Quiver
-- Porting note: Removed `deriving Unique`.
@[nolint unusedArguments]
def SingleObj (_ : Type*) : Type :=
Unit
#align quiver.single_obj Quiver.SingleObj
-- Porting note: `deriving` from above has been moved to below.
instance {α : Type*} : Unique (SingleObj α) where
default := ⟨⟩
uniq := fun _ => rfl
namespace SingleObj
variable (α β γ : Type*)
instance : Quiver (SingleObj α) :=
⟨fun _ _ => α⟩
def star : SingleObj α :=
Unit.unit
#align quiver.single_obj.star Quiver.SingleObj.star
instance : Inhabited (SingleObj α) :=
⟨star α⟩
variable {α β γ}
lemma ext {x y : SingleObj α} : x = y := Unit.ext x y
-- See note [reducible non-instances]
abbrev hasReverse (rev : α → α) : HasReverse (SingleObj α) := ⟨rev⟩
#align quiver.single_obj.has_reverse Quiver.SingleObj.hasReverse
-- See note [reducible non-instances]
abbrev hasInvolutiveReverse (rev : α → α) (h : Function.Involutive rev) :
HasInvolutiveReverse (SingleObj α) where
toHasReverse := hasReverse rev
inv' := h
#align quiver.single_obj.has_involutive_reverse Quiver.SingleObj.hasInvolutiveReverse
@[simps!]
def toHom : α ≃ (star α ⟶ star α) :=
Equiv.refl _
#align quiver.single_obj.to_hom Quiver.SingleObj.toHom
#align quiver.single_obj.to_hom_apply Quiver.SingleObj.toHom_apply
#align quiver.single_obj.to_hom_symm_apply Quiver.SingleObj.toHom_symm_apply
@[simps]
def toPrefunctor : (α → β) ≃ SingleObj α ⥤q SingleObj β where
toFun f := ⟨id, f⟩
invFun f a := f.map (toHom a)
left_inv _ := rfl
right_inv _ := rfl
#align quiver.single_obj.to_prefunctor_symm_apply Quiver.SingleObj.toPrefunctor_symm_apply
#align quiver.single_obj.to_prefunctor_apply_map Quiver.SingleObj.toPrefunctor_apply_map
#align quiver.single_obj.to_prefunctor_apply_obj Quiver.SingleObj.toPrefunctor_apply_obj
#align quiver.single_obj.to_prefunctor Quiver.SingleObj.toPrefunctor
theorem toPrefunctor_id : toPrefunctor id = 𝟭q (SingleObj α) :=
rfl
#align quiver.single_obj.to_prefunctor_id Quiver.SingleObj.toPrefunctor_id
@[simp]
theorem toPrefunctor_symm_id : toPrefunctor.symm (𝟭q (SingleObj α)) = id :=
rfl
#align quiver.single_obj.to_prefunctor_symm_id Quiver.SingleObj.toPrefunctor_symm_id
theorem toPrefunctor_comp (f : α → β) (g : β → γ) :
toPrefunctor (g ∘ f) = toPrefunctor f ⋙q toPrefunctor g :=
rfl
#align quiver.single_obj.to_prefunctor_comp Quiver.SingleObj.toPrefunctor_comp
@[simp]
theorem toPrefunctor_symm_comp (f : SingleObj α ⥤q SingleObj β) (g : SingleObj β ⥤q SingleObj γ) :
toPrefunctor.symm (f ⋙q g) = toPrefunctor.symm g ∘ toPrefunctor.symm f := by
simp only [Equiv.symm_apply_eq, toPrefunctor_comp, Equiv.apply_symm_apply]
#align quiver.single_obj.to_prefunctor_symm_comp Quiver.SingleObj.toPrefunctor_symm_comp
def pathToList : ∀ {x : SingleObj α}, Path (star α) x → List α
| _, Path.nil => []
| _, Path.cons p a => a :: pathToList p
#align quiver.single_obj.path_to_list Quiver.SingleObj.pathToList
@[simp]
def listToPath : List α → Path (star α) (star α)
| [] => Path.nil
| a :: l => (listToPath l).cons a
#align quiver.single_obj.list_to_path Quiver.SingleObj.listToPath
theorem listToPath_pathToList {x : SingleObj α} (p : Path (star α) x) :
listToPath (pathToList p) = p.cast rfl ext := by
induction' p with y z p a ih
· rfl
· dsimp at *; rw [ih]
#align quiver.single_obj.path_to_list_to_path Quiver.SingleObj.listToPath_pathToList
| Mathlib/Combinatorics/Quiver/SingleObj.lean | 139 | 142 | theorem pathToList_listToPath (l : List α) : pathToList (listToPath l) = l := by |
induction' l with a l ih
· rfl
· change a :: pathToList (listToPath l) = a :: l; rw [ih]
| 0 |
import Mathlib.Topology.Algebra.InfiniteSum.Group
import Mathlib.Topology.Algebra.Nonarchimedean.Basic
open Filter Topology
namespace NonarchimedeanGroup
variable {α G : Type*}
variable [CommGroup G] [UniformSpace G] [UniformGroup G] [NonarchimedeanGroup G]
@[to_additive "Let `G` be a nonarchimedean additive abelian group, and let `f : α → G` be a function
that tends to zero on the filter of cofinite sets. For each finite subset of `α`, consider the
partial sum of `f` on that subset. These partial sums form a Cauchy filter."]
| Mathlib/Topology/Algebra/InfiniteSum/Nonarchimedean.lean | 31 | 48 | theorem cauchySeq_prod_of_tendsto_cofinite_one {f : α → G} (hf : Tendsto f cofinite (𝓝 1)) :
CauchySeq (fun s ↦ ∏ i ∈ s, f i) := by |
/- Let `U` be a neighborhood of `1`. It suffices to show that there exists `s : Finset α` such
that for any `t : Finset α` disjoint from `s`, we have `∏ i ∈ t, f i ∈ U`. -/
apply cauchySeq_finset_iff_prod_vanishing.mpr
intro U hU
-- Since `G` is nonarchimedean, `U` contains an open subgroup `V`.
rcases is_nonarchimedean U hU with ⟨V, hV⟩
/- Let `s` be the set of all indices `i : α` such that `f i ∉ V`. By our assumption `hf`, this is
finite. -/
use (tendsto_def.mp hf V V.mem_nhds_one).toFinset
/- For any `t : Finset α` disjoint from `s`, the product `∏ i ∈ t, f i` is a product of elements
of `V`, so it is an element of `V` too. Thus, `∏ i ∈ t, f i ∈ U`, as desired. -/
intro t ht
apply hV
apply Subgroup.prod_mem
intro i hi
simpa using Finset.disjoint_left.mp ht hi
| 0 |
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
#align_import analysis.ODE.gronwall from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} [NormedAddCommGroup F]
[NormedSpace ℝ F]
open Metric Set Asymptotics Filter Real
open scoped Classical Topology NNReal
noncomputable def gronwallBound (δ K ε x : ℝ) : ℝ :=
if K = 0 then δ + ε * x else δ * exp (K * x) + ε / K * (exp (K * x) - 1)
#align gronwall_bound gronwallBound
theorem gronwallBound_K0 (δ ε : ℝ) : gronwallBound δ 0 ε = fun x => δ + ε * x :=
funext fun _ => if_pos rfl
set_option linter.uppercaseLean3 false in
#align gronwall_bound_K0 gronwallBound_K0
theorem gronwallBound_of_K_ne_0 {δ K ε : ℝ} (hK : K ≠ 0) :
gronwallBound δ K ε = fun x => δ * exp (K * x) + ε / K * (exp (K * x) - 1) :=
funext fun _ => if_neg hK
set_option linter.uppercaseLean3 false in
#align gronwall_bound_of_K_ne_0 gronwallBound_of_K_ne_0
theorem hasDerivAt_gronwallBound (δ K ε x : ℝ) :
HasDerivAt (gronwallBound δ K ε) (K * gronwallBound δ K ε x + ε) x := by
by_cases hK : K = 0
· subst K
simp only [gronwallBound_K0, zero_mul, zero_add]
convert ((hasDerivAt_id x).const_mul ε).const_add δ
rw [mul_one]
· simp only [gronwallBound_of_K_ne_0 hK]
convert (((hasDerivAt_id x).const_mul K).exp.const_mul δ).add
((((hasDerivAt_id x).const_mul K).exp.sub_const 1).const_mul (ε / K)) using 1
simp only [id, mul_add, (mul_assoc _ _ _).symm, mul_comm _ K, mul_div_cancel₀ _ hK]
ring
#align has_deriv_at_gronwall_bound hasDerivAt_gronwallBound
theorem hasDerivAt_gronwallBound_shift (δ K ε x a : ℝ) :
HasDerivAt (fun y => gronwallBound δ K ε (y - a)) (K * gronwallBound δ K ε (x - a) + ε) x := by
convert (hasDerivAt_gronwallBound δ K ε _).comp x ((hasDerivAt_id x).sub_const a) using 1
rw [id, mul_one]
#align has_deriv_at_gronwall_bound_shift hasDerivAt_gronwallBound_shift
theorem gronwallBound_x0 (δ K ε : ℝ) : gronwallBound δ K ε 0 = δ := by
by_cases hK : K = 0
· simp only [gronwallBound, if_pos hK, mul_zero, add_zero]
· simp only [gronwallBound, if_neg hK, mul_zero, exp_zero, sub_self, mul_one,
add_zero]
#align gronwall_bound_x0 gronwallBound_x0
theorem gronwallBound_ε0 (δ K x : ℝ) : gronwallBound δ K 0 x = δ * exp (K * x) := by
by_cases hK : K = 0
· simp only [gronwallBound_K0, hK, zero_mul, exp_zero, add_zero, mul_one]
· simp only [gronwallBound_of_K_ne_0 hK, zero_div, zero_mul, add_zero]
#align gronwall_bound_ε0 gronwallBound_ε0
theorem gronwallBound_ε0_δ0 (K x : ℝ) : gronwallBound 0 K 0 x = 0 := by
simp only [gronwallBound_ε0, zero_mul]
#align gronwall_bound_ε0_δ0 gronwallBound_ε0_δ0
| Mathlib/Analysis/ODE/Gronwall.lean | 96 | 101 | theorem gronwallBound_continuous_ε (δ K x : ℝ) : Continuous fun ε => gronwallBound δ K ε x := by |
by_cases hK : K = 0
· simp only [gronwallBound_K0, hK]
exact continuous_const.add (continuous_id.mul continuous_const)
· simp only [gronwallBound_of_K_ne_0 hK]
exact continuous_const.add ((continuous_id.mul continuous_const).mul continuous_const)
| 0 |
import Mathlib.Data.Set.Finite
import Mathlib.GroupTheory.GroupAction.FixedPoints
import Mathlib.GroupTheory.Perm.Support
open Equiv List MulAction Pointwise Set Subgroup
variable {G α : Type*} [Group G] [MulAction G α] [DecidableEq α]
theorem finite_compl_fixedBy_closure_iff {S : Set G} :
(∀ g ∈ closure S, (fixedBy α g)ᶜ.Finite) ↔ ∀ g ∈ S, (fixedBy α g)ᶜ.Finite :=
⟨fun h g hg ↦ h g (subset_closure hg), fun h g hg ↦ by
refine closure_induction hg h (by simp) (fun g g' hg hg' ↦ (hg.union hg').subset ?_) (by simp)
simp_rw [← compl_inter, compl_subset_compl, fixedBy_mul]⟩
theorem finite_compl_fixedBy_swap {x y : α} : (fixedBy α (swap x y))ᶜ.Finite :=
Set.Finite.subset (s := {x, y}) (by simp)
(compl_subset_comm.mp fun z h ↦ by apply swap_apply_of_ne_of_ne <;> rintro rfl <;> simp at h)
theorem Equiv.Perm.IsSwap.finite_compl_fixedBy {σ : Perm α} (h : σ.IsSwap) :
(fixedBy α σ)ᶜ.Finite := by
obtain ⟨x, y, -, rfl⟩ := h
exact finite_compl_fixedBy_swap
-- this result cannot be moved to Perm/Basic since Perm/Basic is not allowed to import Submonoid
| Mathlib/GroupTheory/Perm/ClosureSwap.lean | 47 | 55 | theorem SubmonoidClass.swap_mem_trans {a b c : α} {C} [SetLike C (Perm α)]
[SubmonoidClass C (Perm α)] (M : C) (hab : swap a b ∈ M) (hbc : swap b c ∈ M) :
swap a c ∈ M := by |
obtain rfl | hab' := eq_or_ne a b
· exact hbc
obtain rfl | hac := eq_or_ne a c
· exact swap_self a ▸ one_mem M
rw [swap_comm, ← swap_mul_swap_mul_swap hab' hac]
exact mul_mem (mul_mem hbc hab) hbc
| 0 |
import Mathlib.MeasureTheory.Measure.MeasureSpace
open scoped ENNReal NNReal Topology
open Set MeasureTheory Measure Filter MeasurableSpace ENNReal Function
variable {R α β δ γ ι : Type*}
namespace MeasureTheory
variable {m0 : MeasurableSpace α} [MeasurableSpace β] [MeasurableSpace γ]
variable {μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α} {s s' t : Set α}
namespace Measure
noncomputable def restrictₗ {m0 : MeasurableSpace α} (s : Set α) : Measure α →ₗ[ℝ≥0∞] Measure α :=
liftLinear (OuterMeasure.restrict s) fun μ s' hs' t => by
suffices μ (s ∩ t) = μ (s ∩ t ∩ s') + μ ((s ∩ t) \ s') by
simpa [← Set.inter_assoc, Set.inter_comm _ s, ← inter_diff_assoc]
exact le_toOuterMeasure_caratheodory _ _ hs' _
#align measure_theory.measure.restrictₗ MeasureTheory.Measure.restrictₗ
noncomputable def restrict {_m0 : MeasurableSpace α} (μ : Measure α) (s : Set α) : Measure α :=
restrictₗ s μ
#align measure_theory.measure.restrict MeasureTheory.Measure.restrict
@[simp]
theorem restrictₗ_apply {_m0 : MeasurableSpace α} (s : Set α) (μ : Measure α) :
restrictₗ s μ = μ.restrict s :=
rfl
#align measure_theory.measure.restrictₗ_apply MeasureTheory.Measure.restrictₗ_apply
theorem restrict_toOuterMeasure_eq_toOuterMeasure_restrict (h : MeasurableSet s) :
(μ.restrict s).toOuterMeasure = OuterMeasure.restrict s μ.toOuterMeasure := by
simp_rw [restrict, restrictₗ, liftLinear, LinearMap.coe_mk, AddHom.coe_mk,
toMeasure_toOuterMeasure, OuterMeasure.restrict_trim h, μ.trimmed]
#align measure_theory.measure.restrict_to_outer_measure_eq_to_outer_measure_restrict MeasureTheory.Measure.restrict_toOuterMeasure_eq_toOuterMeasure_restrict
theorem restrict_apply₀ (ht : NullMeasurableSet t (μ.restrict s)) : μ.restrict s t = μ (t ∩ s) := by
rw [← restrictₗ_apply, restrictₗ, liftLinear_apply₀ _ ht, OuterMeasure.restrict_apply,
coe_toOuterMeasure]
#align measure_theory.measure.restrict_apply₀ MeasureTheory.Measure.restrict_apply₀
@[simp]
theorem restrict_apply (ht : MeasurableSet t) : μ.restrict s t = μ (t ∩ s) :=
restrict_apply₀ ht.nullMeasurableSet
#align measure_theory.measure.restrict_apply MeasureTheory.Measure.restrict_apply
theorem restrict_mono' {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ ⦃μ ν : Measure α⦄ (hs : s ≤ᵐ[μ] s')
(hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' :=
Measure.le_iff.2 fun t ht => calc
μ.restrict s t = μ (t ∩ s) := restrict_apply ht
_ ≤ μ (t ∩ s') := (measure_mono_ae <| hs.mono fun _x hx ⟨hxt, hxs⟩ => ⟨hxt, hx hxs⟩)
_ ≤ ν (t ∩ s') := le_iff'.1 hμν (t ∩ s')
_ = ν.restrict s' t := (restrict_apply ht).symm
#align measure_theory.measure.restrict_mono' MeasureTheory.Measure.restrict_mono'
@[mono]
theorem restrict_mono {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ (hs : s ⊆ s') ⦃μ ν : Measure α⦄
(hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' :=
restrict_mono' (ae_of_all _ hs) hμν
#align measure_theory.measure.restrict_mono MeasureTheory.Measure.restrict_mono
theorem restrict_mono_ae (h : s ≤ᵐ[μ] t) : μ.restrict s ≤ μ.restrict t :=
restrict_mono' h (le_refl μ)
#align measure_theory.measure.restrict_mono_ae MeasureTheory.Measure.restrict_mono_ae
theorem restrict_congr_set (h : s =ᵐ[μ] t) : μ.restrict s = μ.restrict t :=
le_antisymm (restrict_mono_ae h.le) (restrict_mono_ae h.symm.le)
#align measure_theory.measure.restrict_congr_set MeasureTheory.Measure.restrict_congr_set
@[simp]
| Mathlib/MeasureTheory/Measure/Restrict.lean | 104 | 107 | theorem restrict_apply' (hs : MeasurableSet s) : μ.restrict s t = μ (t ∩ s) := by |
rw [← toOuterMeasure_apply,
Measure.restrict_toOuterMeasure_eq_toOuterMeasure_restrict hs,
OuterMeasure.restrict_apply s t _, toOuterMeasure_apply]
| 0 |
import Mathlib.MeasureTheory.Constructions.Pi
import Mathlib.MeasureTheory.Integral.Lebesgue
open scoped Classical ENNReal
open Set Function Equiv Finset
noncomputable section
namespace MeasureTheory
section LMarginal
variable {δ δ' : Type*} {π : δ → Type*} [∀ x, MeasurableSpace (π x)]
variable {μ : ∀ i, Measure (π i)} [∀ i, SigmaFinite (μ i)] [DecidableEq δ]
variable {s t : Finset δ} {f g : (∀ i, π i) → ℝ≥0∞} {x y : ∀ i, π i} {i : δ}
def lmarginal (μ : ∀ i, Measure (π i)) (s : Finset δ) (f : (∀ i, π i) → ℝ≥0∞)
(x : ∀ i, π i) : ℝ≥0∞ :=
∫⁻ y : ∀ i : s, π i, f (updateFinset x s y) ∂Measure.pi fun i : s => μ i
-- Note: this notation is not a binder. This is more convenient since it returns a function.
@[inherit_doc]
notation "∫⋯∫⁻_" s ", " f " ∂" μ:70 => lmarginal μ s f
@[inherit_doc]
notation "∫⋯∫⁻_" s ", " f => lmarginal (fun _ ↦ volume) s f
variable (μ)
theorem _root_.Measurable.lmarginal (hf : Measurable f) : Measurable (∫⋯∫⁻_s, f ∂μ) := by
refine Measurable.lintegral_prod_right ?_
refine hf.comp ?_
rw [measurable_pi_iff]; intro i
by_cases hi : i ∈ s
· simp [hi, updateFinset]
exact measurable_pi_iff.1 measurable_snd _
· simp [hi, updateFinset]
exact measurable_pi_iff.1 measurable_fst _
@[simp] theorem lmarginal_empty (f : (∀ i, π i) → ℝ≥0∞) : ∫⋯∫⁻_∅, f ∂μ = f := by
ext1 x
simp_rw [lmarginal, Measure.pi_of_empty fun i : (∅ : Finset δ) => μ i]
apply lintegral_dirac'
exact Subsingleton.measurable
theorem lmarginal_congr {x y : ∀ i, π i} (f : (∀ i, π i) → ℝ≥0∞)
(h : ∀ i ∉ s, x i = y i) :
(∫⋯∫⁻_s, f ∂μ) x = (∫⋯∫⁻_s, f ∂μ) y := by
dsimp [lmarginal, updateFinset_def]; rcongr; exact h _ ‹_›
theorem lmarginal_update_of_mem {i : δ} (hi : i ∈ s)
(f : (∀ i, π i) → ℝ≥0∞) (x : ∀ i, π i) (y : π i) :
(∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∂μ) x := by
apply lmarginal_congr
intro j hj
have : j ≠ i := by rintro rfl; exact hj hi
apply update_noteq this
theorem lmarginal_union (f : (∀ i, π i) → ℝ≥0∞) (hf : Measurable f)
(hst : Disjoint s t) : ∫⋯∫⁻_s ∪ t, f ∂μ = ∫⋯∫⁻_s, ∫⋯∫⁻_t, f ∂μ ∂μ := by
ext1 x
let e := MeasurableEquiv.piFinsetUnion π hst
calc (∫⋯∫⁻_s ∪ t, f ∂μ) x
= ∫⁻ (y : (i : ↥(s ∪ t)) → π i), f (updateFinset x (s ∪ t) y)
∂.pi fun i' : ↥(s ∪ t) ↦ μ i' := rfl
_ = ∫⁻ (y : ((i : s) → π i) × ((j : t) → π j)), f (updateFinset x (s ∪ t) _)
∂(Measure.pi fun i : s ↦ μ i).prod (.pi fun j : t ↦ μ j) := by
rw [measurePreserving_piFinsetUnion hst μ |>.lintegral_map_equiv]
_ = ∫⁻ (y : (i : s) → π i), ∫⁻ (z : (j : t) → π j), f (updateFinset x (s ∪ t) (e (y, z)))
∂.pi fun j : t ↦ μ j ∂.pi fun i : s ↦ μ i := by
apply lintegral_prod
apply Measurable.aemeasurable
exact hf.comp <| measurable_updateFinset.comp e.measurable
_ = (∫⋯∫⁻_s, ∫⋯∫⁻_t, f ∂μ ∂μ) x := by
simp_rw [lmarginal, updateFinset_updateFinset hst]
rfl
theorem lmarginal_union' (f : (∀ i, π i) → ℝ≥0∞) (hf : Measurable f) {s t : Finset δ}
(hst : Disjoint s t) : ∫⋯∫⁻_s ∪ t, f ∂μ = ∫⋯∫⁻_t, ∫⋯∫⁻_s, f ∂μ ∂μ := by
rw [Finset.union_comm, lmarginal_union μ f hf hst.symm]
variable {μ}
set_option backward.synthInstance.canonInstances false in -- See https://github.com/leanprover-community/mathlib4/issues/12532
| Mathlib/MeasureTheory/Integral/Marginal.lean | 144 | 153 | theorem lmarginal_singleton (f : (∀ i, π i) → ℝ≥0∞) (i : δ) :
∫⋯∫⁻_{i}, f ∂μ = fun x => ∫⁻ xᵢ, f (Function.update x i xᵢ) ∂μ i := by |
let α : Type _ := ({i} : Finset δ)
let e := (MeasurableEquiv.piUnique fun j : α ↦ π j).symm
ext1 x
calc (∫⋯∫⁻_{i}, f ∂μ) x
= ∫⁻ (y : π (default : α)), f (updateFinset x {i} (e y)) ∂μ (default : α) := by
simp_rw [lmarginal, measurePreserving_piUnique (fun j : ({i} : Finset δ) ↦ μ j) |>.symm _
|>.lintegral_map_equiv]
_ = ∫⁻ xᵢ, f (Function.update x i xᵢ) ∂μ i := by simp [update_eq_updateFinset]; rfl
| 0 |
import Mathlib.LinearAlgebra.AffineSpace.AffineMap
import Mathlib.LinearAlgebra.Basic
import Mathlib.LinearAlgebra.GeneralLinearGroup
#align_import linear_algebra.affine_space.affine_equiv from "leanprover-community/mathlib"@"bd1fc183335ea95a9519a1630bcf901fe9326d83"
open Function Set
open Affine
-- Porting note(#5171): this linter isn't ported yet.
-- @[nolint has_nonempty_instance]
structure AffineEquiv (k P₁ P₂ : Type*) {V₁ V₂ : Type*} [Ring k] [AddCommGroup V₁] [Module k V₁]
[AddTorsor V₁ P₁] [AddCommGroup V₂] [Module k V₂] [AddTorsor V₂ P₂] extends P₁ ≃ P₂ where
linear : V₁ ≃ₗ[k] V₂
map_vadd' : ∀ (p : P₁) (v : V₁), toEquiv (v +ᵥ p) = linear v +ᵥ toEquiv p
#align affine_equiv AffineEquiv
@[inherit_doc]
notation:25 P₁ " ≃ᵃ[" k:25 "] " P₂:0 => AffineEquiv k P₁ P₂
variable {k P₁ P₂ P₃ P₄ V₁ V₂ V₃ V₄ : Type*} [Ring k] [AddCommGroup V₁] [Module k V₁]
[AddTorsor V₁ P₁] [AddCommGroup V₂] [Module k V₂] [AddTorsor V₂ P₂] [AddCommGroup V₃]
[Module k V₃] [AddTorsor V₃ P₃] [AddCommGroup V₄] [Module k V₄] [AddTorsor V₄ P₄]
namespace AffineEquiv
@[coe]
def toAffineMap (e : P₁ ≃ᵃ[k] P₂) : P₁ →ᵃ[k] P₂ :=
{ e with }
#align affine_equiv.to_affine_map AffineEquiv.toAffineMap
@[simp]
theorem toAffineMap_mk (f : P₁ ≃ P₂) (f' : V₁ ≃ₗ[k] V₂) (h) :
toAffineMap (mk f f' h) = ⟨f, f', h⟩ :=
rfl
#align affine_equiv.to_affine_map_mk AffineEquiv.toAffineMap_mk
@[simp]
theorem linear_toAffineMap (e : P₁ ≃ᵃ[k] P₂) : e.toAffineMap.linear = e.linear :=
rfl
#align affine_equiv.linear_to_affine_map AffineEquiv.linear_toAffineMap
| Mathlib/LinearAlgebra/AffineSpace/AffineEquiv.lean | 80 | 86 | theorem toAffineMap_injective : Injective (toAffineMap : (P₁ ≃ᵃ[k] P₂) → P₁ →ᵃ[k] P₂) := by |
rintro ⟨e, el, h⟩ ⟨e', el', h'⟩ H
-- Porting note: added `AffineMap.mk.injEq`
simp only [toAffineMap_mk, AffineMap.mk.injEq, Equiv.coe_inj,
LinearEquiv.toLinearMap_inj] at H
congr
exacts [H.1, H.2]
| 0 |
import Mathlib.Algebra.BigOperators.Group.Finset
import Mathlib.Data.Finset.NatAntidiagonal
import Mathlib.Data.Nat.GCD.Basic
import Mathlib.Init.Data.Nat.Lemmas
import Mathlib.Logic.Function.Iterate
import Mathlib.Tactic.Ring
import Mathlib.Tactic.Zify
#align_import data.nat.fib from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7"
namespace Nat
-- Porting note: Lean cannot find pp_nodot at the time of this port.
-- @[pp_nodot]
def fib (n : ℕ) : ℕ :=
((fun p : ℕ × ℕ => (p.snd, p.fst + p.snd))^[n] (0, 1)).fst
#align nat.fib Nat.fib
@[simp]
theorem fib_zero : fib 0 = 0 :=
rfl
#align nat.fib_zero Nat.fib_zero
@[simp]
theorem fib_one : fib 1 = 1 :=
rfl
#align nat.fib_one Nat.fib_one
@[simp]
theorem fib_two : fib 2 = 1 :=
rfl
#align nat.fib_two Nat.fib_two
theorem fib_add_two {n : ℕ} : fib (n + 2) = fib n + fib (n + 1) := by
simp [fib, Function.iterate_succ_apply']
#align nat.fib_add_two Nat.fib_add_two
lemma fib_add_one : ∀ {n}, n ≠ 0 → fib (n + 1) = fib (n - 1) + fib n
| _n + 1, _ => fib_add_two
theorem fib_le_fib_succ {n : ℕ} : fib n ≤ fib (n + 1) := by cases n <;> simp [fib_add_two]
#align nat.fib_le_fib_succ Nat.fib_le_fib_succ
@[mono]
theorem fib_mono : Monotone fib :=
monotone_nat_of_le_succ fun _ => fib_le_fib_succ
#align nat.fib_mono Nat.fib_mono
@[simp] lemma fib_eq_zero : ∀ {n}, fib n = 0 ↔ n = 0
| 0 => Iff.rfl
| 1 => Iff.rfl
| n + 2 => by simp [fib_add_two, fib_eq_zero]
@[simp] lemma fib_pos {n : ℕ} : 0 < fib n ↔ 0 < n := by simp [pos_iff_ne_zero]
#align nat.fib_pos Nat.fib_pos
theorem fib_add_two_sub_fib_add_one {n : ℕ} : fib (n + 2) - fib (n + 1) = fib n := by
rw [fib_add_two, add_tsub_cancel_right]
#align nat.fib_add_two_sub_fib_add_one Nat.fib_add_two_sub_fib_add_one
| Mathlib/Data/Nat/Fib/Basic.lean | 114 | 117 | theorem fib_lt_fib_succ {n : ℕ} (hn : 2 ≤ n) : fib n < fib (n + 1) := by |
rcases exists_add_of_le hn with ⟨n, rfl⟩
rw [← tsub_pos_iff_lt, add_comm 2, add_right_comm, fib_add_two, add_tsub_cancel_right, fib_pos]
exact succ_pos n
| 0 |
import Mathlib.CategoryTheory.Adjunction.Opposites
import Mathlib.CategoryTheory.Comma.Presheaf
import Mathlib.CategoryTheory.Elements
import Mathlib.CategoryTheory.Limits.ConeCategory
import Mathlib.CategoryTheory.Limits.Final
import Mathlib.CategoryTheory.Limits.KanExtension
import Mathlib.CategoryTheory.Limits.Over
#align_import category_theory.limits.presheaf from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
namespace CategoryTheory
open Category Limits
universe v₁ v₂ u₁ u₂
section SmallCategory
variable {C : Type u₁} [SmallCategory C]
variable {ℰ : Type u₂} [Category.{u₁} ℰ]
variable (A : C ⥤ ℰ)
namespace ColimitAdj
@[simps!]
def restrictedYoneda : ℰ ⥤ Cᵒᵖ ⥤ Type u₁ :=
yoneda ⋙ (whiskeringLeft _ _ (Type u₁)).obj (Functor.op A)
#align category_theory.colimit_adj.restricted_yoneda CategoryTheory.ColimitAdj.restrictedYoneda
def restrictedYonedaYoneda : restrictedYoneda (yoneda : C ⥤ Cᵒᵖ ⥤ Type u₁) ≅ 𝟭 _ :=
NatIso.ofComponents fun P =>
NatIso.ofComponents (fun X => Equiv.toIso yonedaEquiv) @ fun X Y f =>
funext fun x => by
dsimp [yonedaEquiv]
have : x.app X (CategoryStruct.id (Opposite.unop X)) =
(x.app X (𝟙 (Opposite.unop X))) := rfl
rw [this]
rw [← FunctorToTypes.naturality _ _ x f (𝟙 _)]
simp only [id_comp, Functor.op_obj, Opposite.unop_op, yoneda_obj_map, comp_id]
#align category_theory.colimit_adj.restricted_yoneda_yoneda CategoryTheory.ColimitAdj.restrictedYonedaYoneda
def restrictYonedaHomEquiv (P : Cᵒᵖ ⥤ Type u₁) (E : ℰ)
{c : Cocone ((CategoryOfElements.π P).leftOp ⋙ A)} (t : IsColimit c) :
(c.pt ⟶ E) ≃ (P ⟶ (restrictedYoneda A).obj E) :=
((uliftTrivial _).symm ≪≫ t.homIso' E).toEquiv.trans
{ toFun := fun k =>
{ app := fun c p => k.1 (Opposite.op ⟨_, p⟩)
naturality := fun c c' f =>
funext fun p =>
(k.2
(Quiver.Hom.op ⟨f, rfl⟩ :
(Opposite.op ⟨c', P.map f p⟩ : P.Elementsᵒᵖ) ⟶ Opposite.op ⟨c, p⟩)).symm }
invFun := fun τ =>
{ val := fun p => τ.app p.unop.1 p.unop.2
property := @fun p p' f => by
simp_rw [← f.unop.2]
apply (congr_fun (τ.naturality f.unop.1) p'.unop.2).symm }
left_inv := by
rintro ⟨k₁, k₂⟩
ext
dsimp
congr 1
right_inv := by
rintro ⟨_, _⟩
rfl }
#align category_theory.colimit_adj.restrict_yoneda_hom_equiv CategoryTheory.ColimitAdj.restrictYonedaHomEquiv
| Mathlib/CategoryTheory/Limits/Presheaf.lean | 121 | 126 | theorem restrictYonedaHomEquiv_natural (P : Cᵒᵖ ⥤ Type u₁) (E₁ E₂ : ℰ) (g : E₁ ⟶ E₂) {c : Cocone _}
(t : IsColimit c) (k : c.pt ⟶ E₁) :
restrictYonedaHomEquiv A P E₂ t (k ≫ g) =
restrictYonedaHomEquiv A P E₁ t k ≫ (restrictedYoneda A).map g := by |
ext x X
apply (assoc _ _ _).symm
| 0 |
import Mathlib.Algebra.MonoidAlgebra.Basic
import Mathlib.LinearAlgebra.Basis.VectorSpace
import Mathlib.RingTheory.SimpleModule
#align_import representation_theory.maschke from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
universe u v w
noncomputable section
open Module MonoidAlgebra
namespace LinearMap
-- At first we work with any `[CommRing k]`, and add the assumption that
-- `[Invertible (Fintype.card G : k)]` when it is required.
variable {k : Type u} [CommRing k] {G : Type u} [Group G]
variable {V : Type v} [AddCommGroup V] [Module k V] [Module (MonoidAlgebra k G) V]
variable [IsScalarTower k (MonoidAlgebra k G) V]
variable {W : Type w} [AddCommGroup W] [Module k W] [Module (MonoidAlgebra k G) W]
variable [IsScalarTower k (MonoidAlgebra k G) W]
variable (π : W →ₗ[k] V)
def conjugate (g : G) : W →ₗ[k] V :=
.comp (.comp (GroupSMul.linearMap k V g⁻¹) π) (GroupSMul.linearMap k W g)
#align linear_map.conjugate LinearMap.conjugate
theorem conjugate_apply (g : G) (v : W) :
π.conjugate g v = MonoidAlgebra.single g⁻¹ (1 : k) • π (MonoidAlgebra.single g (1 : k) • v) :=
rfl
variable (i : V →ₗ[MonoidAlgebra k G] W) (h : ∀ v : V, (π : W → V) (i v) = v)
section
theorem conjugate_i (g : G) (v : V) : (conjugate π g : W → V) (i v) = v := by
rw [conjugate_apply, ← i.map_smul, h, ← mul_smul, single_mul_single, mul_one, mul_left_inv,
← one_def, one_smul]
#align linear_map.conjugate_i LinearMap.conjugate_i
end
variable (G) [Fintype G]
def sumOfConjugates : W →ₗ[k] V :=
∑ g : G, π.conjugate g
#align linear_map.sum_of_conjugates LinearMap.sumOfConjugates
lemma sumOfConjugates_apply (v : W) : π.sumOfConjugates G v = ∑ g : G, π.conjugate g v :=
LinearMap.sum_apply _ _ _
def sumOfConjugatesEquivariant : W →ₗ[MonoidAlgebra k G] V :=
MonoidAlgebra.equivariantOfLinearOfComm (π.sumOfConjugates G) fun g v => by
simp only [sumOfConjugates_apply, Finset.smul_sum, conjugate_apply]
refine Fintype.sum_bijective (· * g) (Group.mulRight_bijective g) _ _ fun i ↦ ?_
simp only [smul_smul, single_mul_single, mul_inv_rev, mul_inv_cancel_left, one_mul]
#align linear_map.sum_of_conjugates_equivariant LinearMap.sumOfConjugatesEquivariant
theorem sumOfConjugatesEquivariant_apply (v : W) :
π.sumOfConjugatesEquivariant G v = ∑ g : G, π.conjugate g v :=
π.sumOfConjugates_apply G v
section
variable [Invertible (Fintype.card G : k)]
def equivariantProjection : W →ₗ[MonoidAlgebra k G] V :=
⅟(Fintype.card G : k) • π.sumOfConjugatesEquivariant G
#align linear_map.equivariant_projection LinearMap.equivariantProjection
theorem equivariantProjection_apply (v : W) :
π.equivariantProjection G v = ⅟(Fintype.card G : k) • ∑ g : G, π.conjugate g v := by
simp only [equivariantProjection, smul_apply, sumOfConjugatesEquivariant_apply]
| Mathlib/RepresentationTheory/Maschke.lean | 129 | 133 | theorem equivariantProjection_condition (v : V) : (π.equivariantProjection G) (i v) = v := by |
rw [equivariantProjection_apply]
simp only [conjugate_i π i h]
rw [Finset.sum_const, Finset.card_univ, nsmul_eq_smul_cast k, smul_smul,
Invertible.invOf_mul_self, one_smul]
| 0 |
import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.Algebra.Group.ConjFinite
import Mathlib.Algebra.Group.Subgroup.Finite
import Mathlib.Data.Set.Card
import Mathlib.GroupTheory.Subgroup.Center
open MulAction ConjClasses
variable (G : Type*) [Group G]
| Mathlib/GroupTheory/ClassEquation.lean | 31 | 35 | theorem sum_conjClasses_card_eq_card [Fintype <| ConjClasses G] [Fintype G]
[∀ x : ConjClasses G, Fintype x.carrier] :
∑ x : ConjClasses G, x.carrier.toFinset.card = Fintype.card G := by |
suffices (Σ x : ConjClasses G, x.carrier) ≃ G by simpa using (Fintype.card_congr this)
simpa [carrier_eq_preimage_mk] using Equiv.sigmaFiberEquiv ConjClasses.mk
| 0 |
import Mathlib.FieldTheory.Finite.Polynomial
import Mathlib.NumberTheory.Basic
import Mathlib.RingTheory.WittVector.WittPolynomial
#align_import ring_theory.witt_vector.structure_polynomial from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
open MvPolynomial Set
open Finset (range)
open Finsupp (single)
-- This lemma reduces a bundled morphism to a "mere" function,
-- and consequently the simplifier cannot use a lot of powerful simp-lemmas.
-- We disable this locally, and probably it should be disabled globally in mathlib.
attribute [-simp] coe_eval₂Hom
variable {p : ℕ} {R : Type*} {idx : Type*} [CommRing R]
open scoped Witt
section PPrime
variable (p) [hp : Fact p.Prime]
-- Notation with ring of coefficients explicit
set_option quotPrecheck false in
@[inherit_doc]
scoped[Witt] notation "W_" => wittPolynomial p
-- Notation with ring of coefficients implicit
set_option quotPrecheck false in
@[inherit_doc]
scoped[Witt] notation "W" => wittPolynomial p _
noncomputable def wittStructureRat (Φ : MvPolynomial idx ℚ) (n : ℕ) : MvPolynomial (idx × ℕ) ℚ :=
bind₁ (fun k => bind₁ (fun i => rename (Prod.mk i) (W_ ℚ k)) Φ) (xInTermsOfW p ℚ n)
#align witt_structure_rat wittStructureRat
theorem wittStructureRat_prop (Φ : MvPolynomial idx ℚ) (n : ℕ) :
bind₁ (wittStructureRat p Φ) (W_ ℚ n) = bind₁ (fun i => rename (Prod.mk i) (W_ ℚ n)) Φ :=
calc
bind₁ (wittStructureRat p Φ) (W_ ℚ n) =
bind₁ (fun k => bind₁ (fun i => (rename (Prod.mk i)) (W_ ℚ k)) Φ)
(bind₁ (xInTermsOfW p ℚ) (W_ ℚ n)) := by
rw [bind₁_bind₁]; exact eval₂Hom_congr (RingHom.ext_rat _ _) rfl rfl
_ = bind₁ (fun i => rename (Prod.mk i) (W_ ℚ n)) Φ := by
rw [bind₁_xInTermsOfW_wittPolynomial p _ n, bind₁_X_right]
#align witt_structure_rat_prop wittStructureRat_prop
theorem wittStructureRat_existsUnique (Φ : MvPolynomial idx ℚ) :
∃! φ : ℕ → MvPolynomial (idx × ℕ) ℚ,
∀ n : ℕ, bind₁ φ (W_ ℚ n) = bind₁ (fun i => rename (Prod.mk i) (W_ ℚ n)) Φ := by
refine ⟨wittStructureRat p Φ, ?_, ?_⟩
· intro n; apply wittStructureRat_prop
· intro φ H
funext n
rw [show φ n = bind₁ φ (bind₁ (W_ ℚ) (xInTermsOfW p ℚ n)) by
rw [bind₁_wittPolynomial_xInTermsOfW p, bind₁_X_right]]
rw [bind₁_bind₁]
exact eval₂Hom_congr (RingHom.ext_rat _ _) (funext H) rfl
#align witt_structure_rat_exists_unique wittStructureRat_existsUnique
| Mathlib/RingTheory/WittVector/StructurePolynomial.lean | 164 | 175 | theorem wittStructureRat_rec_aux (Φ : MvPolynomial idx ℚ) (n : ℕ) :
wittStructureRat p Φ n * C ((p : ℚ) ^ n) =
bind₁ (fun b => rename (fun i => (b, i)) (W_ ℚ n)) Φ -
∑ i ∈ range n, C ((p : ℚ) ^ i) * wittStructureRat p Φ i ^ p ^ (n - i) := by |
have := xInTermsOfW_aux p ℚ n
replace := congr_arg (bind₁ fun k : ℕ => bind₁ (fun i => rename (Prod.mk i) (W_ ℚ k)) Φ) this
rw [AlgHom.map_mul, bind₁_C_right] at this
rw [wittStructureRat, this]; clear this
conv_lhs => simp only [AlgHom.map_sub, bind₁_X_right]
rw [sub_right_inj]
simp only [AlgHom.map_sum, AlgHom.map_mul, bind₁_C_right, AlgHom.map_pow]
rfl
| 0 |
import Mathlib.LinearAlgebra.Contraction
import Mathlib.LinearAlgebra.Matrix.Charpoly.Coeff
#align_import linear_algebra.trace from "leanprover-community/mathlib"@"4cf7ca0e69e048b006674cf4499e5c7d296a89e0"
noncomputable section
universe u v w
namespace LinearMap
open Matrix
open FiniteDimensional
open TensorProduct
section
variable (R : Type u) [CommSemiring R] {M : Type v} [AddCommMonoid M] [Module R M]
variable {ι : Type w} [DecidableEq ι] [Fintype ι]
variable {κ : Type*} [DecidableEq κ] [Fintype κ]
variable (b : Basis ι R M) (c : Basis κ R M)
def traceAux : (M →ₗ[R] M) →ₗ[R] R :=
Matrix.traceLinearMap ι R R ∘ₗ ↑(LinearMap.toMatrix b b)
#align linear_map.trace_aux LinearMap.traceAux
-- Can't be `simp` because it would cause a loop.
theorem traceAux_def (b : Basis ι R M) (f : M →ₗ[R] M) :
traceAux R b f = Matrix.trace (LinearMap.toMatrix b b f) :=
rfl
#align linear_map.trace_aux_def LinearMap.traceAux_def
theorem traceAux_eq : traceAux R b = traceAux R c :=
LinearMap.ext fun f =>
calc
Matrix.trace (LinearMap.toMatrix b b f) =
Matrix.trace (LinearMap.toMatrix b b ((LinearMap.id.comp f).comp LinearMap.id)) := by
rw [LinearMap.id_comp, LinearMap.comp_id]
_ = Matrix.trace (LinearMap.toMatrix c b LinearMap.id * LinearMap.toMatrix c c f *
LinearMap.toMatrix b c LinearMap.id) := by
rw [LinearMap.toMatrix_comp _ c, LinearMap.toMatrix_comp _ c]
_ = Matrix.trace (LinearMap.toMatrix c c f * LinearMap.toMatrix b c LinearMap.id *
LinearMap.toMatrix c b LinearMap.id) := by
rw [Matrix.mul_assoc, Matrix.trace_mul_comm]
_ = Matrix.trace (LinearMap.toMatrix c c ((f.comp LinearMap.id).comp LinearMap.id)) := by
rw [LinearMap.toMatrix_comp _ b, LinearMap.toMatrix_comp _ c]
_ = Matrix.trace (LinearMap.toMatrix c c f) := by rw [LinearMap.comp_id, LinearMap.comp_id]
#align linear_map.trace_aux_eq LinearMap.traceAux_eq
open scoped Classical
variable (M)
def trace : (M →ₗ[R] M) →ₗ[R] R :=
if H : ∃ s : Finset M, Nonempty (Basis s R M) then traceAux R H.choose_spec.some else 0
#align linear_map.trace LinearMap.trace
variable {M}
theorem trace_eq_matrix_trace_of_finset {s : Finset M} (b : Basis s R M) (f : M →ₗ[R] M) :
trace R M f = Matrix.trace (LinearMap.toMatrix b b f) := by
have : ∃ s : Finset M, Nonempty (Basis s R M) := ⟨s, ⟨b⟩⟩
rw [trace, dif_pos this, ← traceAux_def]
congr 1
apply traceAux_eq
#align linear_map.trace_eq_matrix_trace_of_finset LinearMap.trace_eq_matrix_trace_of_finset
theorem trace_eq_matrix_trace (f : M →ₗ[R] M) :
trace R M f = Matrix.trace (LinearMap.toMatrix b b f) := by
rw [trace_eq_matrix_trace_of_finset R b.reindexFinsetRange, ← traceAux_def, ← traceAux_def,
traceAux_eq R b b.reindexFinsetRange]
#align linear_map.trace_eq_matrix_trace LinearMap.trace_eq_matrix_trace
theorem trace_mul_comm (f g : M →ₗ[R] M) : trace R M (f * g) = trace R M (g * f) :=
if H : ∃ s : Finset M, Nonempty (Basis s R M) then by
let ⟨s, ⟨b⟩⟩ := H
simp_rw [trace_eq_matrix_trace R b, LinearMap.toMatrix_mul]
apply Matrix.trace_mul_comm
else by rw [trace, dif_neg H, LinearMap.zero_apply, LinearMap.zero_apply]
#align linear_map.trace_mul_comm LinearMap.trace_mul_comm
lemma trace_mul_cycle (f g h : M →ₗ[R] M) :
trace R M (f * g * h) = trace R M (h * f * g) := by
rw [LinearMap.trace_mul_comm, ← mul_assoc]
lemma trace_mul_cycle' (f g h : M →ₗ[R] M) :
trace R M (f * (g * h)) = trace R M (h * (f * g)) := by
rw [← mul_assoc, LinearMap.trace_mul_comm]
@[simp]
theorem trace_conj (g : M →ₗ[R] M) (f : (M →ₗ[R] M)ˣ) :
trace R M (↑f * g * ↑f⁻¹) = trace R M g := by
rw [trace_mul_comm]
simp
#align linear_map.trace_conj LinearMap.trace_conj
@[simp]
lemma trace_lie {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] (f g : Module.End R M) :
trace R M ⁅f, g⁆ = 0 := by
rw [Ring.lie_def, map_sub, trace_mul_comm]
exact sub_self _
end
section
variable {R : Type*} [CommRing R] {M : Type*} [AddCommGroup M] [Module R M]
variable (N P : Type*) [AddCommGroup N] [Module R N] [AddCommGroup P] [Module R P]
variable {ι : Type*}
theorem trace_eq_contract_of_basis [Finite ι] (b : Basis ι R M) :
LinearMap.trace R M ∘ₗ dualTensorHom R M M = contractLeft R M := by
classical
cases nonempty_fintype ι
apply Basis.ext (Basis.tensorProduct (Basis.dualBasis b) b)
rintro ⟨i, j⟩
simp only [Function.comp_apply, Basis.tensorProduct_apply, Basis.coe_dualBasis, coe_comp]
rw [trace_eq_matrix_trace R b, toMatrix_dualTensorHom]
by_cases hij : i = j
· rw [hij]
simp
rw [Matrix.StdBasisMatrix.trace_zero j i (1 : R) hij]
simp [Finsupp.single_eq_pi_single, hij]
#align linear_map.trace_eq_contract_of_basis LinearMap.trace_eq_contract_of_basis
| Mathlib/LinearAlgebra/Trace.lean | 155 | 157 | theorem trace_eq_contract_of_basis' [Fintype ι] [DecidableEq ι] (b : Basis ι R M) :
LinearMap.trace R M = contractLeft R M ∘ₗ (dualTensorHomEquivOfBasis b).symm.toLinearMap := by |
simp [LinearEquiv.eq_comp_toLinearMap_symm, trace_eq_contract_of_basis b]
| 0 |
import Batteries.Data.HashMap.Basic
import Batteries.Data.Array.Lemmas
import Batteries.Data.Nat.Lemmas
namespace Batteries.HashMap
namespace Imp
attribute [-simp] Bool.not_eq_true
namespace Buckets
@[ext] protected theorem ext : ∀ {b₁ b₂ : Buckets α β}, b₁.1.data = b₂.1.data → b₁ = b₂
| ⟨⟨_⟩, _⟩, ⟨⟨_⟩, _⟩, rfl => rfl
theorem update_data (self : Buckets α β) (i d h) :
(self.update i d h).1.data = self.1.data.set i.toNat d := rfl
theorem exists_of_update (self : Buckets α β) (i d h) :
∃ l₁ l₂, self.1.data = l₁ ++ self.1[i] :: l₂ ∧ List.length l₁ = i.toNat ∧
(self.update i d h).1.data = l₁ ++ d :: l₂ := by
simp only [Array.data_length, Array.ugetElem_eq_getElem, Array.getElem_eq_data_get]
exact List.exists_of_set' h
| .lake/packages/batteries/Batteries/Data/HashMap/WF.lean | 29 | 33 | theorem update_update (self : Buckets α β) (i d d' h h') :
(self.update i d h).update i d' h' = self.update i d' h := by |
simp only [update, Array.uset, Array.data_length]
congr 1
rw [Array.set_set]
| 0 |
import Mathlib.Topology.MetricSpace.HausdorffDistance
#align_import topology.metric_space.pi_nat from "leanprover-community/mathlib"@"49b7f94aab3a3bdca1f9f34c5d818afb253b3993"
noncomputable section
open scoped Classical
open Topology Filter
open TopologicalSpace Set Metric Filter Function
attribute [local simp] pow_le_pow_iff_right one_lt_two inv_le_inv zero_le_two zero_lt_two
variable {E : ℕ → Type*}
namespace PiNat
irreducible_def firstDiff (x y : ∀ n, E n) : ℕ :=
if h : x ≠ y then Nat.find (ne_iff.1 h) else 0
#align pi_nat.first_diff PiNat.firstDiff
theorem apply_firstDiff_ne {x y : ∀ n, E n} (h : x ≠ y) :
x (firstDiff x y) ≠ y (firstDiff x y) := by
rw [firstDiff_def, dif_pos h]
exact Nat.find_spec (ne_iff.1 h)
#align pi_nat.apply_first_diff_ne PiNat.apply_firstDiff_ne
theorem apply_eq_of_lt_firstDiff {x y : ∀ n, E n} {n : ℕ} (hn : n < firstDiff x y) : x n = y n := by
rw [firstDiff_def] at hn
split_ifs at hn with h
· convert Nat.find_min (ne_iff.1 h) hn
simp
· exact (not_lt_zero' hn).elim
#align pi_nat.apply_eq_of_lt_first_diff PiNat.apply_eq_of_lt_firstDiff
theorem firstDiff_comm (x y : ∀ n, E n) : firstDiff x y = firstDiff y x := by
simp only [firstDiff_def, ne_comm]
#align pi_nat.first_diff_comm PiNat.firstDiff_comm
| Mathlib/Topology/MetricSpace/PiNat.lean | 92 | 99 | theorem min_firstDiff_le (x y z : ∀ n, E n) (h : x ≠ z) :
min (firstDiff x y) (firstDiff y z) ≤ firstDiff x z := by |
by_contra! H
rw [lt_min_iff] at H
refine apply_firstDiff_ne h ?_
calc
x (firstDiff x z) = y (firstDiff x z) := apply_eq_of_lt_firstDiff H.1
_ = z (firstDiff x z) := apply_eq_of_lt_firstDiff H.2
| 0 |
import Mathlib.Algebra.Module.PID
import Mathlib.Data.ZMod.Quotient
#align_import group_theory.finite_abelian from "leanprover-community/mathlib"@"879155bff5af618b9062cbb2915347dafd749ad6"
open scoped DirectSum
private def directSumNeZeroMulHom {ι : Type} [DecidableEq ι] (p : ι → ℕ) (n : ι → ℕ) :
(⨁ i : {i // n i ≠ 0}, ZMod (p i ^ n i)) →+ ⨁ i, ZMod (p i ^ n i) :=
DirectSum.toAddMonoid fun i ↦ DirectSum.of (fun i ↦ ZMod (p i ^ n i)) i
private def directSumNeZeroMulEquiv (ι : Type) [DecidableEq ι] (p : ι → ℕ) (n : ι → ℕ) :
(⨁ i : {i // n i ≠ 0}, ZMod (p i ^ n i)) ≃+ ⨁ i, ZMod (p i ^ n i) where
toFun := directSumNeZeroMulHom p n
invFun := DirectSum.toAddMonoid fun i ↦
if h : n i = 0 then 0 else DirectSum.of (fun j : {i // n i ≠ 0} ↦ ZMod (p j ^ n j)) ⟨i, h⟩
left_inv x := by
induction' x using DirectSum.induction_on with i x x y hx hy
· simp
· rw [directSumNeZeroMulHom, DirectSum.toAddMonoid_of, DirectSum.toAddMonoid_of,
dif_neg i.prop]
· rw [map_add, map_add, hx, hy]
right_inv x := by
induction' x using DirectSum.induction_on with i x x y hx hy
· rw [map_zero, map_zero]
· rw [DirectSum.toAddMonoid_of]
split_ifs with h
· simp [(ZMod.subsingleton_iff.2 $ by rw [h, pow_zero]).elim x 0]
· simp_rw [directSumNeZeroMulHom, DirectSum.toAddMonoid_of]
· rw [map_add, map_add, hx, hy]
map_add' := map_add (directSumNeZeroMulHom p n)
universe u
variable (G : Type u)
namespace AddCommGroup
variable [AddCommGroup G]
theorem equiv_free_prod_directSum_zmod [hG : AddGroup.FG G] :
∃ (n : ℕ) (ι : Type) (_ : Fintype ι) (p : ι → ℕ) (_ : ∀ i, Nat.Prime <| p i) (e : ι → ℕ),
Nonempty <| G ≃+ (Fin n →₀ ℤ) × ⨁ i : ι, ZMod (p i ^ e i) := by
obtain ⟨n, ι, fι, p, hp, e, ⟨f⟩⟩ :=
@Module.equiv_free_prod_directSum _ _ _ _ _ _ _ (Module.Finite.iff_addGroup_fg.mpr hG)
refine ⟨n, ι, fι, fun i => (p i).natAbs, fun i => ?_, e, ⟨?_⟩⟩
· rw [← Int.prime_iff_natAbs_prime, ← irreducible_iff_prime]; exact hp i
exact
f.toAddEquiv.trans
((AddEquiv.refl _).prodCongr <|
DFinsupp.mapRange.addEquiv fun i =>
((Int.quotientSpanEquivZMod _).trans <|
ZMod.ringEquivCongr <| (p i).natAbs_pow _).toAddEquiv)
#align add_comm_group.equiv_free_prod_direct_sum_zmod AddCommGroup.equiv_free_prod_directSum_zmod
| Mathlib/GroupTheory/FiniteAbelian.lean | 131 | 143 | theorem equiv_directSum_zmod_of_finite [Finite G] :
∃ (ι : Type) (_ : Fintype ι) (p : ι → ℕ) (_ : ∀ i, Nat.Prime <| p i) (e : ι → ℕ),
Nonempty <| G ≃+ ⨁ i : ι, ZMod (p i ^ e i) := by |
cases nonempty_fintype G
obtain ⟨n, ι, fι, p, hp, e, ⟨f⟩⟩ := equiv_free_prod_directSum_zmod G
cases' n with n
· have : Unique (Fin Nat.zero →₀ ℤ) :=
{ uniq := by simp only [Nat.zero_eq, eq_iff_true_of_subsingleton]; trivial }
exact ⟨ι, fι, p, hp, e, ⟨f.trans AddEquiv.uniqueProd⟩⟩
· haveI := @Fintype.prodLeft _ _ _ (Fintype.ofEquiv G f.toEquiv) _
exact
(Fintype.ofSurjective (fun f : Fin n.succ →₀ ℤ => f 0) fun a =>
⟨Finsupp.single 0 a, Finsupp.single_eq_same⟩).false.elim
| 0 |
import Mathlib.LinearAlgebra.Isomorphisms
import Mathlib.LinearAlgebra.Projection
import Mathlib.Order.JordanHolder
import Mathlib.Order.CompactlyGenerated.Intervals
import Mathlib.LinearAlgebra.FiniteDimensional
#align_import ring_theory.simple_module from "leanprover-community/mathlib"@"cce7f68a7eaadadf74c82bbac20721cdc03a1cc1"
variable {ι : Type*} (R S : Type*) [Ring R] [Ring S] (M : Type*) [AddCommGroup M] [Module R M]
abbrev IsSimpleModule :=
IsSimpleOrder (Submodule R M)
#align is_simple_module IsSimpleModule
abbrev IsSemisimpleModule :=
ComplementedLattice (Submodule R M)
#align is_semisimple_module IsSemisimpleModule
abbrev IsSemisimpleRing := IsSemisimpleModule R R
theorem RingEquiv.isSemisimpleRing (e : R ≃+* S) [IsSemisimpleRing R] : IsSemisimpleRing S :=
(Submodule.orderIsoMapComap e.toSemilinearEquiv).complementedLattice
-- Making this an instance causes the linter to complain of "dangerous instances"
theorem IsSimpleModule.nontrivial [IsSimpleModule R M] : Nontrivial M :=
⟨⟨0, by
have h : (⊥ : Submodule R M) ≠ ⊤ := bot_ne_top
contrapose! h
ext x
simp [Submodule.mem_bot, Submodule.mem_top, h x]⟩⟩
#align is_simple_module.nontrivial IsSimpleModule.nontrivial
variable {m : Submodule R M} {N : Type*} [AddCommGroup N] [Module R N] {R S M}
theorem LinearMap.isSimpleModule_iff_of_bijective [Module S N] {σ : R →+* S} [RingHomSurjective σ]
(l : M →ₛₗ[σ] N) (hl : Function.Bijective l) : IsSimpleModule R M ↔ IsSimpleModule S N :=
(Submodule.orderIsoMapComapOfBijective l hl).isSimpleOrder_iff
theorem IsSimpleModule.congr (l : M ≃ₗ[R] N) [IsSimpleModule R N] : IsSimpleModule R M :=
(Submodule.orderIsoMapComap l).isSimpleOrder
#align is_simple_module.congr IsSimpleModule.congr
theorem isSimpleModule_iff_isAtom : IsSimpleModule R m ↔ IsAtom m := by
rw [← Set.isSimpleOrder_Iic_iff_isAtom]
exact m.mapIic.isSimpleOrder_iff
#align is_simple_module_iff_is_atom isSimpleModule_iff_isAtom
theorem isSimpleModule_iff_isCoatom : IsSimpleModule R (M ⧸ m) ↔ IsCoatom m := by
rw [← Set.isSimpleOrder_Ici_iff_isCoatom]
apply OrderIso.isSimpleOrder_iff
exact Submodule.comapMkQRelIso m
#align is_simple_module_iff_is_coatom isSimpleModule_iff_isCoatom
theorem covBy_iff_quot_is_simple {A B : Submodule R M} (hAB : A ≤ B) :
A ⋖ B ↔ IsSimpleModule R (B ⧸ Submodule.comap B.subtype A) := by
set f : Submodule R B ≃o Set.Iic B := B.mapIic with hf
rw [covBy_iff_coatom_Iic hAB, isSimpleModule_iff_isCoatom, ← OrderIso.isCoatom_iff f, hf]
simp [-OrderIso.isCoatom_iff, Submodule.map_comap_subtype, inf_eq_right.2 hAB]
#align covby_iff_quot_is_simple covBy_iff_quot_is_simple
namespace IsSimpleModule
@[simp]
theorem isAtom [IsSimpleModule R m] : IsAtom m :=
isSimpleModule_iff_isAtom.1 ‹_›
#align is_simple_module.is_atom IsSimpleModule.isAtom
variable [IsSimpleModule R M] (R)
open LinearMap
theorem span_singleton_eq_top {m : M} (hm : m ≠ 0) : Submodule.span R {m} = ⊤ :=
(eq_bot_or_eq_top _).resolve_left fun h ↦ hm (h.le <| Submodule.mem_span_singleton_self m)
instance (S : Submodule R M) : S.IsPrincipal where
principal' := by
obtain rfl | rfl := eq_bot_or_eq_top S
· exact ⟨0, Submodule.span_zero.symm⟩
have := IsSimpleModule.nontrivial R M
have ⟨m, hm⟩ := exists_ne (0 : M)
exact ⟨m, (span_singleton_eq_top R hm).symm⟩
theorem toSpanSingleton_surjective {m : M} (hm : m ≠ 0) :
Function.Surjective (toSpanSingleton R M m) := by
rw [← range_eq_top, ← span_singleton_eq_range, span_singleton_eq_top R hm]
| Mathlib/RingTheory/SimpleModule.lean | 129 | 132 | theorem ker_toSpanSingleton_isMaximal {m : M} (hm : m ≠ 0) :
Ideal.IsMaximal (ker (toSpanSingleton R M m)) := by |
rw [Ideal.isMaximal_def, ← isSimpleModule_iff_isCoatom]
exact congr (quotKerEquivOfSurjective _ <| toSpanSingleton_surjective R hm)
| 0 |
import Mathlib.Combinatorics.SimpleGraph.Finite
import Mathlib.Data.Finset.Sym
import Mathlib.Data.Matrix.Basic
#align_import combinatorics.simple_graph.inc_matrix from "leanprover-community/mathlib"@"bb168510ef455e9280a152e7f31673cabd3d7496"
open Finset Matrix SimpleGraph Sym2
open Matrix
namespace SimpleGraph
variable (R : Type*) {α : Type*} (G : SimpleGraph α)
noncomputable def incMatrix [Zero R] [One R] : Matrix α (Sym2 α) R := fun a =>
(G.incidenceSet a).indicator 1
#align simple_graph.inc_matrix SimpleGraph.incMatrix
variable {R}
theorem incMatrix_apply [Zero R] [One R] {a : α} {e : Sym2 α} :
G.incMatrix R a e = (G.incidenceSet a).indicator 1 e :=
rfl
#align simple_graph.inc_matrix_apply SimpleGraph.incMatrix_apply
theorem incMatrix_apply' [Zero R] [One R] [DecidableEq α] [DecidableRel G.Adj] {a : α}
{e : Sym2 α} : G.incMatrix R a e = if e ∈ G.incidenceSet a then 1 else 0 := by
unfold incMatrix Set.indicator
convert rfl
#align simple_graph.inc_matrix_apply' SimpleGraph.incMatrix_apply'
section MulZeroOneClass
variable [MulZeroOneClass R] {a b : α} {e : Sym2 α}
| Mathlib/Combinatorics/SimpleGraph/IncMatrix.lean | 79 | 82 | theorem incMatrix_apply_mul_incMatrix_apply : G.incMatrix R a e * G.incMatrix R b e =
(G.incidenceSet a ∩ G.incidenceSet b).indicator 1 e := by |
classical simp only [incMatrix, Set.indicator_apply, ite_zero_mul_ite_zero, Pi.one_apply, mul_one,
Set.mem_inter_iff]
| 0 |
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.BinaryProducts
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Products
import Mathlib.CategoryTheory.Limits.ConcreteCategory
import Mathlib.CategoryTheory.Limits.Shapes.Types
import Mathlib.CategoryTheory.Limits.Shapes.Multiequalizer
import Mathlib.CategoryTheory.Limits.Shapes.Kernels
universe w v u t r
namespace CategoryTheory.Limits.Concrete
attribute [local instance] ConcreteCategory.instFunLike ConcreteCategory.hasCoeToSort
variable {C : Type u} [Category.{v} C]
section Products
section WidePushout
open WidePushout
open WidePushoutShape
variable [ConcreteCategory.{v} C]
theorem widePushout_exists_rep {B : C} {α : Type _} {X : α → C} (f : ∀ j : α, B ⟶ X j)
[HasWidePushout.{v} B X f] [PreservesColimit (wideSpan B X f) (forget C)]
(x : ↑(widePushout B X f)) : (∃ y : B, head f y = x) ∨ ∃ (i : α) (y : X i), ι f i y = x := by
obtain ⟨_ | j, y, rfl⟩ := Concrete.colimit_exists_rep _ x
· left
use y
rfl
· right
use j, y
rfl
#align category_theory.limits.concrete.wide_pushout_exists_rep CategoryTheory.Limits.Concrete.widePushout_exists_rep
| Mathlib/CategoryTheory/Limits/Shapes/ConcreteCategory.lean | 336 | 343 | theorem widePushout_exists_rep' {B : C} {α : Type _} [Nonempty α] {X : α → C}
(f : ∀ j : α, B ⟶ X j) [HasWidePushout.{v} B X f] [PreservesColimit (wideSpan B X f) (forget C)]
(x : ↑(widePushout B X f)) : ∃ (i : α) (y : X i), ι f i y = x := by |
rcases Concrete.widePushout_exists_rep f x with (⟨y, rfl⟩ | ⟨i, y, rfl⟩)
· inhabit α
use default, f _ y
simp only [← arrow_ι _ default, comp_apply]
· use i, y
| 0 |
import Mathlib.Data.Finset.Lattice
import Mathlib.Data.Set.Sigma
#align_import data.finset.sigma from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
open Function Multiset
variable {ι : Type*}
namespace Finset
section SigmaLift
variable {α β γ : ι → Type*} [DecidableEq ι]
def sigmaLift (f : ∀ ⦃i⦄, α i → β i → Finset (γ i)) (a : Sigma α) (b : Sigma β) :
Finset (Sigma γ) :=
dite (a.1 = b.1) (fun h => (f (h ▸ a.2) b.2).map <| Embedding.sigmaMk _) fun _ => ∅
#align finset.sigma_lift Finset.sigmaLift
| Mathlib/Data/Finset/Sigma.lean | 156 | 173 | theorem mem_sigmaLift (f : ∀ ⦃i⦄, α i → β i → Finset (γ i)) (a : Sigma α) (b : Sigma β)
(x : Sigma γ) :
x ∈ sigmaLift f a b ↔ ∃ (ha : a.1 = x.1) (hb : b.1 = x.1), x.2 ∈ f (ha ▸ a.2) (hb ▸ b.2) := by |
obtain ⟨⟨i, a⟩, j, b⟩ := a, b
obtain rfl | h := Decidable.eq_or_ne i j
· constructor
· simp_rw [sigmaLift]
simp only [dite_eq_ite, ite_true, mem_map, Embedding.sigmaMk_apply, forall_exists_index,
and_imp]
rintro x hx rfl
exact ⟨rfl, rfl, hx⟩
· rintro ⟨⟨⟩, ⟨⟩, hx⟩
rw [sigmaLift, dif_pos rfl, mem_map]
exact ⟨_, hx, by simp [Sigma.ext_iff]⟩
· rw [sigmaLift, dif_neg h]
refine iff_of_false (not_mem_empty _) ?_
rintro ⟨⟨⟩, ⟨⟩, _⟩
exact h rfl
| 0 |
import Mathlib.Algebra.IsPrimePow
import Mathlib.Data.Nat.Factorization.Basic
#align_import data.nat.factorization.prime_pow from "leanprover-community/mathlib"@"6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f"
variable {R : Type*} [CommMonoidWithZero R] (n p : R) (k : ℕ)
theorem IsPrimePow.minFac_pow_factorization_eq {n : ℕ} (hn : IsPrimePow n) :
n.minFac ^ n.factorization n.minFac = n := by
obtain ⟨p, k, hp, hk, rfl⟩ := hn
rw [← Nat.prime_iff] at hp
rw [hp.pow_minFac hk.ne', hp.factorization_pow, Finsupp.single_eq_same]
#align is_prime_pow.min_fac_pow_factorization_eq IsPrimePow.minFac_pow_factorization_eq
| Mathlib/Data/Nat/Factorization/PrimePow.lean | 27 | 33 | theorem isPrimePow_of_minFac_pow_factorization_eq {n : ℕ}
(h : n.minFac ^ n.factorization n.minFac = n) (hn : n ≠ 1) : IsPrimePow n := by |
rcases eq_or_ne n 0 with (rfl | hn')
· simp_all
refine ⟨_, _, (Nat.minFac_prime hn).prime, ?_, h⟩
simp [pos_iff_ne_zero, ← Finsupp.mem_support_iff, Nat.support_factorization, hn',
Nat.minFac_prime hn, Nat.minFac_dvd]
| 0 |
import Mathlib.NumberTheory.LegendreSymbol.Basic
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.GaussSum
#align_import number_theory.legendre_symbol.quadratic_reciprocity from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9"
open Nat
section Values
variable {p : ℕ} [Fact p.Prime]
open ZMod
section Reciprocity
variable {p q : ℕ} [Fact p.Prime] [Fact q.Prime]
namespace legendreSym
open ZMod
theorem quadratic_reciprocity (hp : p ≠ 2) (hq : q ≠ 2) (hpq : p ≠ q) :
legendreSym q p * legendreSym p q = (-1) ^ (p / 2 * (q / 2)) := by
have hp₁ := (Prime.eq_two_or_odd <| @Fact.out p.Prime _).resolve_left hp
have hq₁ := (Prime.eq_two_or_odd <| @Fact.out q.Prime _).resolve_left hq
have hq₂ : ringChar (ZMod q) ≠ 2 := (ringChar_zmod_n q).substr hq
have h :=
quadraticChar_odd_prime ((ringChar_zmod_n p).substr hp) hq ((ringChar_zmod_n p).substr hpq)
rw [card p] at h
have nc : ∀ n r : ℕ, ((n : ℤ) : ZMod r) = n := fun n r => by norm_cast
have nc' : (((-1) ^ (p / 2) : ℤ) : ZMod q) = (-1) ^ (p / 2) := by norm_cast
rw [legendreSym, legendreSym, nc, nc, h, map_mul, mul_rotate', mul_comm (p / 2), ← pow_two,
quadraticChar_sq_one (prime_ne_zero q p hpq.symm), mul_one, pow_mul, χ₄_eq_neg_one_pow hp₁, nc',
map_pow, quadraticChar_neg_one hq₂, card q, χ₄_eq_neg_one_pow hq₁]
#align legendre_sym.quadratic_reciprocity legendreSym.quadratic_reciprocity
theorem quadratic_reciprocity' (hp : p ≠ 2) (hq : q ≠ 2) :
legendreSym q p = (-1) ^ (p / 2 * (q / 2)) * legendreSym p q := by
rcases eq_or_ne p q with h | h
· subst p
rw [(eq_zero_iff q q).mpr (mod_cast natCast_self q), mul_zero]
· have qr := congr_arg (· * legendreSym p q) (quadratic_reciprocity hp hq h)
have : ((q : ℤ) : ZMod p) ≠ 0 := mod_cast prime_ne_zero p q h
simpa only [mul_assoc, ← pow_two, sq_one p this, mul_one] using qr
#align legendre_sym.quadratic_reciprocity' legendreSym.quadratic_reciprocity'
| Mathlib/NumberTheory/LegendreSymbol/QuadraticReciprocity.lean | 150 | 153 | theorem quadratic_reciprocity_one_mod_four (hp : p % 4 = 1) (hq : q ≠ 2) :
legendreSym q p = legendreSym p q := by |
rw [quadratic_reciprocity' (Prime.mod_two_eq_one_iff_ne_two.mp (odd_of_mod_four_eq_one hp)) hq,
pow_mul, neg_one_pow_div_two_of_one_mod_four hp, one_pow, one_mul]
| 0 |
import Mathlib.RingTheory.Ideal.IsPrimary
import Mathlib.RingTheory.Localization.AtPrime
import Mathlib.Order.Minimal
#align_import ring_theory.ideal.minimal_prime from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
section
variable {R S : Type*} [CommSemiring R] [CommSemiring S] (I J : Ideal R)
protected def Ideal.minimalPrimes : Set (Ideal R) :=
minimals (· ≤ ·) { p | p.IsPrime ∧ I ≤ p }
#align ideal.minimal_primes Ideal.minimalPrimes
variable (R) in
def minimalPrimes : Set (Ideal R) :=
Ideal.minimalPrimes ⊥
#align minimal_primes minimalPrimes
lemma minimalPrimes_eq_minimals : minimalPrimes R = minimals (· ≤ ·) (setOf Ideal.IsPrime) :=
congr_arg (minimals (· ≤ ·)) (by simp)
variable {I J}
theorem Ideal.exists_minimalPrimes_le [J.IsPrime] (e : I ≤ J) : ∃ p ∈ I.minimalPrimes, p ≤ J := by
suffices
∃ m ∈ { p : (Ideal R)ᵒᵈ | Ideal.IsPrime p ∧ I ≤ OrderDual.ofDual p },
OrderDual.toDual J ≤ m ∧ ∀ z ∈ { p : (Ideal R)ᵒᵈ | Ideal.IsPrime p ∧ I ≤ p }, m ≤ z → z = m by
obtain ⟨p, h₁, h₂, h₃⟩ := this
simp_rw [← @eq_comm _ p] at h₃
exact ⟨p, ⟨h₁, fun a b c => le_of_eq (h₃ a b c)⟩, h₂⟩
apply zorn_nonempty_partialOrder₀
swap
· refine ⟨show J.IsPrime by infer_instance, e⟩
rintro (c : Set (Ideal R)) hc hc' J' hJ'
refine
⟨OrderDual.toDual (sInf c),
⟨Ideal.sInf_isPrime_of_isChain ⟨J', hJ'⟩ hc'.symm fun x hx => (hc hx).1, ?_⟩, ?_⟩
· rw [OrderDual.ofDual_toDual, le_sInf_iff]
exact fun _ hx => (hc hx).2
· rintro z hz
rw [OrderDual.le_toDual]
exact sInf_le hz
#align ideal.exists_minimal_primes_le Ideal.exists_minimalPrimes_le
@[simp]
theorem Ideal.radical_minimalPrimes : I.radical.minimalPrimes = I.minimalPrimes := by
rw [Ideal.minimalPrimes, Ideal.minimalPrimes]
ext p
refine ⟨?_, ?_⟩ <;> rintro ⟨⟨a, ha⟩, b⟩
· refine ⟨⟨a, a.radical_le_iff.1 ha⟩, ?_⟩
simp only [Set.mem_setOf_eq, and_imp] at *
exact fun _ h2 h3 h4 => b h2 (h2.radical_le_iff.2 h3) h4
· refine ⟨⟨a, a.radical_le_iff.2 ha⟩, ?_⟩
simp only [Set.mem_setOf_eq, and_imp] at *
exact fun _ h2 h3 h4 => b h2 (h2.radical_le_iff.1 h3) h4
#align ideal.radical_minimal_primes Ideal.radical_minimalPrimes
@[simp]
theorem Ideal.sInf_minimalPrimes : sInf I.minimalPrimes = I.radical := by
rw [I.radical_eq_sInf]
apply le_antisymm
· intro x hx
rw [Ideal.mem_sInf] at hx ⊢
rintro J ⟨e, hJ⟩
obtain ⟨p, hp, hp'⟩ := Ideal.exists_minimalPrimes_le e
exact hp' (hx hp)
· apply sInf_le_sInf _
intro I hI
exact hI.1.symm
#align ideal.Inf_minimal_primes Ideal.sInf_minimalPrimes
theorem Ideal.exists_comap_eq_of_mem_minimalPrimes_of_injective {f : R →+* S}
(hf : Function.Injective f) (p) (H : p ∈ minimalPrimes R) :
∃ p' : Ideal S, p'.IsPrime ∧ p'.comap f = p := by
have := H.1.1
have : Nontrivial (Localization (Submonoid.map f p.primeCompl)) := by
refine ⟨⟨1, 0, ?_⟩⟩
convert (IsLocalization.map_injective_of_injective p.primeCompl (Localization.AtPrime p)
(Localization <| p.primeCompl.map f) hf).ne one_ne_zero
· rw [map_one]
· rw [map_zero]
obtain ⟨M, hM⟩ := Ideal.exists_maximal (Localization (Submonoid.map f p.primeCompl))
refine ⟨M.comap (algebraMap S <| Localization (Submonoid.map f p.primeCompl)), inferInstance, ?_⟩
rw [Ideal.comap_comap, ← @IsLocalization.map_comp _ _ _ _ _ _ _ _ Localization.isLocalization
_ _ _ _ p.primeCompl.le_comap_map _ Localization.isLocalization,
← Ideal.comap_comap]
suffices _ ≤ p by exact this.antisymm (H.2 ⟨inferInstance, bot_le⟩ this)
intro x hx
by_contra h
apply hM.ne_top
apply M.eq_top_of_isUnit_mem hx
apply IsUnit.map
apply IsLocalization.map_units _ (show p.primeCompl from ⟨x, h⟩)
#align ideal.exists_comap_eq_of_mem_minimal_primes_of_injective Ideal.exists_comap_eq_of_mem_minimalPrimes_of_injective
end
section
variable {R S : Type*} [CommRing R] [CommRing S] {I J : Ideal R}
| Mathlib/RingTheory/Ideal/MinimalPrime.lean | 134 | 164 | theorem Ideal.exists_comap_eq_of_mem_minimalPrimes {I : Ideal S} (f : R →+* S) (p)
(H : p ∈ (I.comap f).minimalPrimes) : ∃ p' : Ideal S, p'.IsPrime ∧ I ≤ p' ∧ p'.comap f = p := by |
have := H.1.1
let f' := (Ideal.Quotient.mk I).comp f
have e : RingHom.ker f' = I.comap f := by
ext1
exact Submodule.Quotient.mk_eq_zero _
have : RingHom.ker (Ideal.Quotient.mk <| RingHom.ker f') ≤ p := by
rw [Ideal.mk_ker, e]
exact H.1.2
suffices _ by
have ⟨p', hp₁, hp₂⟩ := Ideal.exists_comap_eq_of_mem_minimalPrimes_of_injective
(RingHom.kerLift_injective f') (p.map <| Ideal.Quotient.mk <| RingHom.ker f') this
refine ⟨p'.comap <| Ideal.Quotient.mk I, Ideal.IsPrime.comap _, ?_, ?_⟩
· exact Ideal.mk_ker.symm.trans_le (Ideal.comap_mono bot_le)
· convert congr_arg (Ideal.comap <| Ideal.Quotient.mk <| RingHom.ker f') hp₂
rwa [Ideal.comap_map_of_surjective (Ideal.Quotient.mk <| RingHom.ker f')
Ideal.Quotient.mk_surjective, eq_comm, sup_eq_left]
refine ⟨⟨?_, bot_le⟩, ?_⟩
· apply Ideal.map_isPrime_of_surjective _ this
exact Ideal.Quotient.mk_surjective
· rintro q ⟨hq, -⟩ hq'
rw [← Ideal.map_comap_of_surjective
(Ideal.Quotient.mk (RingHom.ker ((Ideal.Quotient.mk I).comp f)))
Ideal.Quotient.mk_surjective q]
apply Ideal.map_mono
apply H.2
· refine ⟨inferInstance, (Ideal.mk_ker.trans e).symm.trans_le (Ideal.comap_mono bot_le)⟩
· refine (Ideal.comap_mono hq').trans ?_
rw [Ideal.comap_map_of_surjective]
exacts [sup_le rfl.le this, Ideal.Quotient.mk_surjective]
| 0 |
import Mathlib.Topology.Connected.Basic
open Set Function
universe u v
variable {α : Type u} {β : Type v} {ι : Type*} {π : ι → Type*} [TopologicalSpace α]
{s t u v : Set α}
section TotallyDisconnected
def IsTotallyDisconnected (s : Set α) : Prop :=
∀ t, t ⊆ s → IsPreconnected t → t.Subsingleton
#align is_totally_disconnected IsTotallyDisconnected
theorem isTotallyDisconnected_empty : IsTotallyDisconnected (∅ : Set α) := fun _ ht _ _ x_in _ _ =>
(ht x_in).elim
#align is_totally_disconnected_empty isTotallyDisconnected_empty
theorem isTotallyDisconnected_singleton {x} : IsTotallyDisconnected ({x} : Set α) := fun _ ht _ =>
subsingleton_singleton.anti ht
#align is_totally_disconnected_singleton isTotallyDisconnected_singleton
@[mk_iff]
class TotallyDisconnectedSpace (α : Type u) [TopologicalSpace α] : Prop where
isTotallyDisconnected_univ : IsTotallyDisconnected (univ : Set α)
#align totally_disconnected_space TotallyDisconnectedSpace
theorem IsPreconnected.subsingleton [TotallyDisconnectedSpace α] {s : Set α}
(h : IsPreconnected s) : s.Subsingleton :=
TotallyDisconnectedSpace.isTotallyDisconnected_univ s (subset_univ s) h
#align is_preconnected.subsingleton IsPreconnected.subsingleton
instance Pi.totallyDisconnectedSpace {α : Type*} {β : α → Type*}
[∀ a, TopologicalSpace (β a)] [∀ a, TotallyDisconnectedSpace (β a)] :
TotallyDisconnectedSpace (∀ a : α, β a) :=
⟨fun t _ h2 =>
have this : ∀ a, IsPreconnected ((fun x : ∀ a, β a => x a) '' t) := fun a =>
h2.image (fun x => x a) (continuous_apply a).continuousOn
fun x x_in y y_in => funext fun a => (this a).subsingleton ⟨x, x_in, rfl⟩ ⟨y, y_in, rfl⟩⟩
#align pi.totally_disconnected_space Pi.totallyDisconnectedSpace
instance Prod.totallyDisconnectedSpace [TopologicalSpace β] [TotallyDisconnectedSpace α]
[TotallyDisconnectedSpace β] : TotallyDisconnectedSpace (α × β) :=
⟨fun t _ h2 =>
have H1 : IsPreconnected (Prod.fst '' t) := h2.image Prod.fst continuous_fst.continuousOn
have H2 : IsPreconnected (Prod.snd '' t) := h2.image Prod.snd continuous_snd.continuousOn
fun x hx y hy =>
Prod.ext (H1.subsingleton ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩)
(H2.subsingleton ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩)⟩
#align prod.totally_disconnected_space Prod.totallyDisconnectedSpace
instance [TopologicalSpace β] [TotallyDisconnectedSpace α] [TotallyDisconnectedSpace β] :
TotallyDisconnectedSpace (Sum α β) := by
refine ⟨fun s _ hs => ?_⟩
obtain ⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩ := Sum.isPreconnected_iff.1 hs
· exact ht.subsingleton.image _
· exact ht.subsingleton.image _
instance [∀ i, TopologicalSpace (π i)] [∀ i, TotallyDisconnectedSpace (π i)] :
TotallyDisconnectedSpace (Σi, π i) := by
refine ⟨fun s _ hs => ?_⟩
obtain rfl | h := s.eq_empty_or_nonempty
· exact subsingleton_empty
· obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩
exact ht.isPreconnected.subsingleton.image _
-- Porting note: reformulated using `Pairwise`
| Mathlib/Topology/Connected/TotallyDisconnected.lean | 93 | 104 | theorem isTotallyDisconnected_of_isClopen_set {X : Type*} [TopologicalSpace X]
(hX : Pairwise fun x y => ∃ (U : Set X), IsClopen U ∧ x ∈ U ∧ y ∉ U) :
IsTotallyDisconnected (Set.univ : Set X) := by |
rintro S - hS
unfold Set.Subsingleton
by_contra! h_contra
rcases h_contra with ⟨x, hx, y, hy, hxy⟩
obtain ⟨U, hU, hxU, hyU⟩ := hX hxy
specialize
hS U Uᶜ hU.2 hU.compl.2 (fun a _ => em (a ∈ U)) ⟨x, hx, hxU⟩ ⟨y, hy, hyU⟩
rw [inter_compl_self, Set.inter_empty] at hS
exact Set.not_nonempty_empty hS
| 0 |
import Mathlib.FieldTheory.PrimitiveElement
import Mathlib.LinearAlgebra.Determinant
import Mathlib.LinearAlgebra.FiniteDimensional
import Mathlib.LinearAlgebra.Matrix.Charpoly.Minpoly
import Mathlib.LinearAlgebra.Matrix.ToLinearEquiv
import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure
import Mathlib.FieldTheory.Galois
#align_import ring_theory.norm from "leanprover-community/mathlib"@"fecd3520d2a236856f254f27714b80dcfe28ea57"
universe u v w
variable {R S T : Type*} [CommRing R] [Ring S]
variable [Algebra R S]
variable {K L F : Type*} [Field K] [Field L] [Field F]
variable [Algebra K L] [Algebra K F]
variable {ι : Type w}
open FiniteDimensional
open LinearMap
open Matrix Polynomial
open scoped Matrix
namespace Algebra
variable (R)
noncomputable def norm : S →* R :=
LinearMap.det.comp (lmul R S).toRingHom.toMonoidHom
#align algebra.norm Algebra.norm
theorem norm_apply (x : S) : norm R x = LinearMap.det (lmul R S x) := rfl
#align algebra.norm_apply Algebra.norm_apply
theorem norm_eq_one_of_not_exists_basis (h : ¬∃ s : Finset S, Nonempty (Basis s R S)) (x : S) :
norm R x = 1 := by rw [norm_apply, LinearMap.det]; split_ifs <;> trivial
#align algebra.norm_eq_one_of_not_exists_basis Algebra.norm_eq_one_of_not_exists_basis
variable {R}
theorem norm_eq_one_of_not_module_finite (h : ¬Module.Finite R S) (x : S) : norm R x = 1 := by
refine norm_eq_one_of_not_exists_basis _ (mt ?_ h) _
rintro ⟨s, ⟨b⟩⟩
exact Module.Finite.of_basis b
#align algebra.norm_eq_one_of_not_module_finite Algebra.norm_eq_one_of_not_module_finite
-- Can't be a `simp` lemma because it depends on a choice of basis
theorem norm_eq_matrix_det [Fintype ι] [DecidableEq ι] (b : Basis ι R S) (s : S) :
norm R s = Matrix.det (Algebra.leftMulMatrix b s) := by
rw [norm_apply, ← LinearMap.det_toMatrix b, ← toMatrix_lmul_eq]; rfl
#align algebra.norm_eq_matrix_det Algebra.norm_eq_matrix_det
theorem norm_algebraMap_of_basis [Fintype ι] (b : Basis ι R S) (x : R) :
norm R (algebraMap R S x) = x ^ Fintype.card ι := by
haveI := Classical.decEq ι
rw [norm_apply, ← det_toMatrix b, lmul_algebraMap]
convert @det_diagonal _ _ _ _ _ fun _ : ι => x
· ext (i j); rw [toMatrix_lsmul]
· rw [Finset.prod_const, Finset.card_univ]
#align algebra.norm_algebra_map_of_basis Algebra.norm_algebraMap_of_basis
@[simp]
protected theorem norm_algebraMap {L : Type*} [Ring L] [Algebra K L] (x : K) :
norm K (algebraMap K L x) = x ^ finrank K L := by
by_cases H : ∃ s : Finset L, Nonempty (Basis s K L)
· rw [norm_algebraMap_of_basis H.choose_spec.some, finrank_eq_card_basis H.choose_spec.some]
· rw [norm_eq_one_of_not_exists_basis K H, finrank_eq_zero_of_not_exists_basis, pow_zero]
rintro ⟨s, ⟨b⟩⟩
exact H ⟨s, ⟨b⟩⟩
#align algebra.norm_algebra_map Algebra.norm_algebraMap
open IntermediateField
variable (K)
theorem norm_eq_norm_adjoin [FiniteDimensional K L] [IsSeparable K L] (x : L) :
norm K x = norm K (AdjoinSimple.gen K x) ^ finrank K⟮x⟯ L := by
letI := isSeparable_tower_top_of_isSeparable K K⟮x⟯ L
let pbL := Field.powerBasisOfFiniteOfSeparable K⟮x⟯ L
let pbx := IntermediateField.adjoin.powerBasis (IsSeparable.isIntegral K x)
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [← AdjoinSimple.algebraMap_gen K x, norm_eq_matrix_det (pbx.basis.smul pbL.basis) _,
smul_leftMulMatrix_algebraMap, det_blockDiagonal, norm_eq_matrix_det pbx.basis]
simp only [Finset.card_fin, Finset.prod_const]
congr
rw [← PowerBasis.finrank, AdjoinSimple.algebraMap_gen K x]
#align algebra.norm_eq_norm_adjoin Algebra.norm_eq_norm_adjoin
variable {K}
section IntermediateField
| Mathlib/RingTheory/Norm.lean | 214 | 221 | theorem _root_.IntermediateField.AdjoinSimple.norm_gen_eq_one {x : L} (hx : ¬IsIntegral K x) :
norm K (AdjoinSimple.gen K x) = 1 := by |
rw [norm_eq_one_of_not_exists_basis]
contrapose! hx
obtain ⟨s, ⟨b⟩⟩ := hx
refine .of_mem_of_fg K⟮x⟯.toSubalgebra ?_ x ?_
· exact (Submodule.fg_iff_finiteDimensional _).mpr (of_fintype_basis b)
· exact IntermediateField.subset_adjoin K _ (Set.mem_singleton x)
| 0 |
import Mathlib.Analysis.Fourier.FourierTransform
import Mathlib.Analysis.InnerProductSpace.Dual
import Mathlib.Analysis.InnerProductSpace.EuclideanDist
import Mathlib.MeasureTheory.Function.ContinuousMapDense
import Mathlib.MeasureTheory.Group.Integral
import Mathlib.MeasureTheory.Integral.SetIntegral
import Mathlib.MeasureTheory.Measure.Haar.NormedSpace
import Mathlib.Topology.EMetricSpace.Paracompact
import Mathlib.MeasureTheory.Measure.Haar.Unique
#align_import analysis.fourier.riemann_lebesgue_lemma from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
noncomputable section
open MeasureTheory Filter Complex Set FiniteDimensional
open scoped Filter Topology Real ENNReal FourierTransform RealInnerProductSpace NNReal
variable {E V : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {f : V → E}
section InnerProductSpace
variable [NormedAddCommGroup V] [MeasurableSpace V] [BorelSpace V] [InnerProductSpace ℝ V]
[FiniteDimensional ℝ V]
#align fourier_integrand_integrable Real.fourierIntegral_convergent_iff
variable [CompleteSpace E]
local notation3 "i" => fun (w : V) => (1 / (2 * ‖w‖ ^ 2) : ℝ) • w
| Mathlib/Analysis/Fourier/RiemannLebesgueLemma.lean | 68 | 92 | theorem fourierIntegral_half_period_translate {w : V} (hw : w ≠ 0) :
(∫ v : V, 𝐞 (-⟪v, w⟫) • f (v + i w)) = -∫ v : V, 𝐞 (-⟪v, w⟫) • f v := by |
have hiw : ⟪i w, w⟫ = 1 / 2 := by
rw [inner_smul_left, inner_self_eq_norm_sq_to_K, RCLike.ofReal_real_eq_id, id,
RCLike.conj_to_real, ← div_div, div_mul_cancel₀]
rwa [Ne, sq_eq_zero_iff, norm_eq_zero]
have :
(fun v : V => 𝐞 (-⟪v, w⟫) • f (v + i w)) =
fun v : V => (fun x : V => -(𝐞 (-⟪x, w⟫) • f x)) (v + i w) := by
ext1 v
simp_rw [inner_add_left, hiw, Submonoid.smul_def, Real.fourierChar_apply, neg_add, mul_add,
ofReal_add, add_mul, exp_add]
have : 2 * π * -(1 / 2) = -π := by field_simp; ring
rw [this, ofReal_neg, neg_mul, exp_neg, exp_pi_mul_I, inv_neg, inv_one, mul_neg_one, neg_smul,
neg_neg]
rw [this]
-- Porting note:
-- The next three lines had just been
-- rw [integral_add_right_eq_self (fun (x : V) ↦ -(𝐞[-⟪x, w⟫]) • f x)
-- ((fun w ↦ (1 / (2 * ‖w‖ ^ (2 : ℕ))) • w) w)]
-- Unfortunately now we need to specify `volume`.
have := integral_add_right_eq_self (μ := volume) (fun (x : V) ↦ -(𝐞 (-⟪x, w⟫) • f x))
((fun w ↦ (1 / (2 * ‖w‖ ^ (2 : ℕ))) • w) w)
rw [this]
simp only [neg_smul, integral_neg]
| 0 |
import Mathlib.AlgebraicTopology.DoldKan.Projections
import Mathlib.CategoryTheory.Idempotents.FunctorCategories
import Mathlib.CategoryTheory.Idempotents.FunctorExtension
#align_import algebraic_topology.dold_kan.p_infty from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504"
open CategoryTheory CategoryTheory.Category CategoryTheory.Preadditive
CategoryTheory.SimplicialObject CategoryTheory.Idempotents Opposite Simplicial DoldKan
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C] {X : SimplicialObject C}
| Mathlib/AlgebraicTopology/DoldKan/PInfty.lean | 36 | 42 | theorem P_is_eventually_constant {q n : ℕ} (hqn : n ≤ q) :
((P (q + 1)).f n : X _[n] ⟶ _) = (P q).f n := by |
rcases n with (_|n)
· simp only [Nat.zero_eq, P_f_0_eq]
· simp only [P_succ, add_right_eq_self, comp_add, HomologicalComplex.comp_f,
HomologicalComplex.add_f_apply, comp_id]
exact (HigherFacesVanish.of_P q n).comp_Hσ_eq_zero (Nat.succ_le_iff.mp hqn)
| 0 |
import Mathlib.Analysis.SpecialFunctions.Integrals
import Mathlib.MeasureTheory.Integral.PeakFunction
#align_import analysis.special_functions.trigonometric.euler_sine_prod from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
open scoped Real Topology
open Real Set Filter intervalIntegral MeasureTheory.MeasureSpace
namespace EulerSine
| Mathlib/Analysis/SpecialFunctions/Trigonometric/EulerSineProd.lean | 278 | 295 | theorem tendsto_integral_cos_pow_mul_div {f : ℝ → ℂ} (hf : ContinuousOn f (Icc 0 (π / 2))) :
Tendsto
(fun n : ℕ => (∫ x in (0 : ℝ)..π / 2, (cos x : ℂ) ^ n * f x) /
(∫ x in (0 : ℝ)..π / 2, cos x ^ n : ℝ))
atTop (𝓝 <| f 0) := by |
simp_rw [div_eq_inv_mul (α := ℂ), ← Complex.ofReal_inv, integral_of_le pi_div_two_pos.le,
← MeasureTheory.integral_Icc_eq_integral_Ioc, ← Complex.ofReal_pow, ← Complex.real_smul]
have c_lt : ∀ y : ℝ, y ∈ Icc 0 (π / 2) → y ≠ 0 → cos y < cos 0 := fun y hy hy' =>
cos_lt_cos_of_nonneg_of_le_pi_div_two (le_refl 0) hy.2 (lt_of_le_of_ne hy.1 hy'.symm)
have c_nonneg : ∀ x : ℝ, x ∈ Icc 0 (π / 2) → 0 ≤ cos x := fun x hx =>
cos_nonneg_of_mem_Icc ((Icc_subset_Icc_left (neg_nonpos_of_nonneg pi_div_two_pos.le)) hx)
have c_zero_pos : 0 < cos 0 := by rw [cos_zero]; exact zero_lt_one
have zero_mem : (0 : ℝ) ∈ closure (interior (Icc 0 (π / 2))) := by
rw [interior_Icc, closure_Ioo pi_div_two_pos.ne, left_mem_Icc]
exact pi_div_two_pos.le
exact
tendsto_setIntegral_pow_smul_of_unique_maximum_of_isCompact_of_continuousOn isCompact_Icc
continuousOn_cos c_lt c_nonneg c_zero_pos zero_mem hf
| 0 |
import Mathlib.Algebra.BigOperators.Finsupp
import Mathlib.Data.Finset.Pointwise
import Mathlib.Data.Finsupp.Indicator
import Mathlib.Data.Fintype.BigOperators
#align_import data.finset.finsupp from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf"
noncomputable section
open Finsupp
open scoped Classical
open Pointwise
variable {ι α : Type*} [Zero α] {s : Finset ι} {f : ι →₀ α}
namespace Finset
protected def finsupp (s : Finset ι) (t : ι → Finset α) : Finset (ι →₀ α) :=
(s.pi t).map ⟨indicator s, indicator_injective s⟩
#align finset.finsupp Finset.finsupp
theorem mem_finsupp_iff {t : ι → Finset α} :
f ∈ s.finsupp t ↔ f.support ⊆ s ∧ ∀ i ∈ s, f i ∈ t i := by
refine mem_map.trans ⟨?_, ?_⟩
· rintro ⟨f, hf, rfl⟩
refine ⟨support_indicator_subset _ _, fun i hi => ?_⟩
convert mem_pi.1 hf i hi
exact indicator_of_mem hi _
· refine fun h => ⟨fun i _ => f i, mem_pi.2 h.2, ?_⟩
ext i
exact ite_eq_left_iff.2 fun hi => (not_mem_support_iff.1 fun H => hi <| h.1 H).symm
#align finset.mem_finsupp_iff Finset.mem_finsupp_iff
@[simp]
| Mathlib/Data/Finset/Finsupp.lean | 62 | 74 | theorem mem_finsupp_iff_of_support_subset {t : ι →₀ Finset α} (ht : t.support ⊆ s) :
f ∈ s.finsupp t ↔ ∀ i, f i ∈ t i := by |
refine
mem_finsupp_iff.trans
(forall_and.symm.trans <|
forall_congr' fun i =>
⟨fun h => ?_, fun h =>
⟨fun hi => ht <| mem_support_iff.2 fun H => mem_support_iff.1 hi ?_, fun _ => h⟩⟩)
· by_cases hi : i ∈ s
· exact h.2 hi
· rw [not_mem_support_iff.1 (mt h.1 hi), not_mem_support_iff.1 fun H => hi <| ht H]
exact zero_mem_zero
· rwa [H, mem_zero] at h
| 0 |
import Mathlib.Analysis.NormedSpace.lpSpace
import Mathlib.Topology.Sets.Compacts
#align_import topology.metric_space.kuratowski from "leanprover-community/mathlib"@"95d4f6586d313c8c28e00f36621d2a6a66893aa6"
noncomputable section
set_option linter.uppercaseLean3 false
open Set Metric TopologicalSpace NNReal ENNReal lp Function
universe u v w
variable {α : Type u} {β : Type v} {γ : Type w}
namespace KuratowskiEmbedding
variable {f g : ℓ^∞(ℕ)} {n : ℕ} {C : ℝ} [MetricSpace α] (x : ℕ → α) (a b : α)
def embeddingOfSubset : ℓ^∞(ℕ) :=
⟨fun n => dist a (x n) - dist (x 0) (x n), by
apply memℓp_infty
use dist a (x 0)
rintro - ⟨n, rfl⟩
exact abs_dist_sub_le _ _ _⟩
#align Kuratowski_embedding.embedding_of_subset KuratowskiEmbedding.embeddingOfSubset
theorem embeddingOfSubset_coe : embeddingOfSubset x a n = dist a (x n) - dist (x 0) (x n) :=
rfl
#align Kuratowski_embedding.embedding_of_subset_coe KuratowskiEmbedding.embeddingOfSubset_coe
theorem embeddingOfSubset_dist_le (a b : α) :
dist (embeddingOfSubset x a) (embeddingOfSubset x b) ≤ dist a b := by
refine lp.norm_le_of_forall_le dist_nonneg fun n => ?_
simp only [lp.coeFn_sub, Pi.sub_apply, embeddingOfSubset_coe, Real.dist_eq]
convert abs_dist_sub_le a b (x n) using 2
ring
#align Kuratowski_embedding.embedding_of_subset_dist_le KuratowskiEmbedding.embeddingOfSubset_dist_le
| Mathlib/Topology/MetricSpace/Kuratowski.lean | 61 | 87 | theorem embeddingOfSubset_isometry (H : DenseRange x) : Isometry (embeddingOfSubset x) := by |
refine Isometry.of_dist_eq fun a b => ?_
refine (embeddingOfSubset_dist_le x a b).antisymm (le_of_forall_pos_le_add fun e epos => ?_)
-- First step: find n with dist a (x n) < e
rcases Metric.mem_closure_range_iff.1 (H a) (e / 2) (half_pos epos) with ⟨n, hn⟩
-- Second step: use the norm control at index n to conclude
have C : dist b (x n) - dist a (x n) = embeddingOfSubset x b n - embeddingOfSubset x a n := by
simp only [embeddingOfSubset_coe, sub_sub_sub_cancel_right]
have :=
calc
dist a b ≤ dist a (x n) + dist (x n) b := dist_triangle _ _ _
_ = 2 * dist a (x n) + (dist b (x n) - dist a (x n)) := by simp [dist_comm]; ring
_ ≤ 2 * dist a (x n) + |dist b (x n) - dist a (x n)| := by
apply_rules [add_le_add_left, le_abs_self]
_ ≤ 2 * (e / 2) + |embeddingOfSubset x b n - embeddingOfSubset x a n| := by
rw [C]
apply_rules [add_le_add, mul_le_mul_of_nonneg_left, hn.le, le_refl]
norm_num
_ ≤ 2 * (e / 2) + dist (embeddingOfSubset x b) (embeddingOfSubset x a) := by
have : |embeddingOfSubset x b n - embeddingOfSubset x a n| ≤
dist (embeddingOfSubset x b) (embeddingOfSubset x a) := by
simp only [dist_eq_norm]
exact lp.norm_apply_le_norm ENNReal.top_ne_zero
(embeddingOfSubset x b - embeddingOfSubset x a) n
nlinarith
_ = dist (embeddingOfSubset x b) (embeddingOfSubset x a) + e := by ring
simpa [dist_comm] using this
| 0 |
import Mathlib.LinearAlgebra.CliffordAlgebra.Fold
import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic
#align_import linear_algebra.exterior_algebra.of_alternating from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a"
variable {R M N N' : Type*}
variable [CommRing R] [AddCommGroup M] [AddCommGroup N] [AddCommGroup N']
variable [Module R M] [Module R N] [Module R N']
-- This instance can't be found where it's needed if we don't remind lean that it exists.
instance AlternatingMap.instModuleAddCommGroup {ι : Type*} :
Module R (M [⋀^ι]→ₗ[R] N) := by
infer_instance
#align alternating_map.module_add_comm_group AlternatingMap.instModuleAddCommGroup
namespace ExteriorAlgebra
open CliffordAlgebra hiding ι
def liftAlternating : (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] N := by
suffices
(∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R]
ExteriorAlgebra R M →ₗ[R] ∀ i, M [⋀^Fin i]→ₗ[R] N by
refine LinearMap.compr₂ this ?_
refine (LinearEquiv.toLinearMap ?_).comp (LinearMap.proj 0)
exact AlternatingMap.constLinearEquivOfIsEmpty.symm
refine CliffordAlgebra.foldl _ ?_ ?_
· refine
LinearMap.mk₂ R (fun m f i => (f i.succ).curryLeft m) (fun m₁ m₂ f => ?_) (fun c m f => ?_)
(fun m f₁ f₂ => ?_) fun c m f => ?_
all_goals
ext i : 1
simp only [map_smul, map_add, Pi.add_apply, Pi.smul_apply, AlternatingMap.curryLeft_add,
AlternatingMap.curryLeft_smul, map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply]
· -- when applied twice with the same `m`, this recursive step produces 0
intro m x
dsimp only [LinearMap.mk₂_apply, QuadraticForm.coeFn_zero, Pi.zero_apply]
simp_rw [zero_smul]
ext i : 1
exact AlternatingMap.curryLeft_same _ _
#align exterior_algebra.lift_alternating ExteriorAlgebra.liftAlternating
@[simp]
theorem liftAlternating_ι (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) :
liftAlternating (R := R) (M := M) (N := N) f (ι R m) = f 1 ![m] := by
dsimp [liftAlternating]
rw [foldl_ι, LinearMap.mk₂_apply, AlternatingMap.curryLeft_apply_apply]
congr
-- Porting note: In Lean 3, `congr` could use the `[Subsingleton (Fin 0 → M)]` instance to finish
-- the proof. Here, the instance can be synthesized but `congr` does not use it so the following
-- line is provided.
rw [Matrix.zero_empty]
#align exterior_algebra.lift_alternating_ι ExteriorAlgebra.liftAlternating_ι
| Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean | 79 | 85 | theorem liftAlternating_ι_mul (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M)
(x : ExteriorAlgebra R M) :
liftAlternating (R := R) (M := M) (N := N) f (ι R m * x) =
liftAlternating (R := R) (M := M) (N := N) (fun i => (f i.succ).curryLeft m) x := by |
dsimp [liftAlternating]
rw [foldl_mul, foldl_ι]
rfl
| 0 |
import Mathlib.LinearAlgebra.Dimension.Free
import Mathlib.Algebra.Module.Torsion
#align_import linear_algebra.dimension from "leanprover-community/mathlib"@"47a5f8186becdbc826190ced4312f8199f9db6a5"
noncomputable section
universe u v v' u₁' w w'
variable {R S : Type u} {M : Type v} {M' : Type v'} {M₁ : Type v}
variable {ι : Type w} {ι' : Type w'} {η : Type u₁'} {φ : η → Type*}
open Cardinal Basis Submodule Function Set FiniteDimensional DirectSum
variable [Ring R] [CommRing S] [AddCommGroup M] [AddCommGroup M'] [AddCommGroup M₁]
variable [Module R M] [Module R M'] [Module R M₁]
section Quotient
theorem LinearIndependent.sum_elim_of_quotient
{M' : Submodule R M} {ι₁ ι₂} {f : ι₁ → M'} (hf : LinearIndependent R f) (g : ι₂ → M)
(hg : LinearIndependent R (Submodule.Quotient.mk (p := M') ∘ g)) :
LinearIndependent R (Sum.elim (f · : ι₁ → M) g) := by
refine .sum_type (hf.map' M'.subtype M'.ker_subtype) (.of_comp M'.mkQ hg) ?_
refine disjoint_def.mpr fun x h₁ h₂ ↦ ?_
have : x ∈ M' := span_le.mpr (Set.range_subset_iff.mpr fun i ↦ (f i).prop) h₁
obtain ⟨c, rfl⟩ := Finsupp.mem_span_range_iff_exists_finsupp.mp h₂
simp_rw [← Quotient.mk_eq_zero, ← mkQ_apply, map_finsupp_sum, map_smul, mkQ_apply] at this
rw [linearIndependent_iff.mp hg _ this, Finsupp.sum_zero_index]
theorem LinearIndependent.union_of_quotient
{M' : Submodule R M} {s : Set M} (hs : s ⊆ M') (hs' : LinearIndependent (ι := s) R Subtype.val)
{t : Set M} (ht : LinearIndependent (ι := t) R (Submodule.Quotient.mk (p := M') ∘ Subtype.val)) :
LinearIndependent (ι := (s ∪ t : _)) R Subtype.val := by
refine (LinearIndependent.sum_elim_of_quotient (f := Set.embeddingOfSubset s M' hs)
(of_comp M'.subtype (by simpa using hs')) Subtype.val ht).to_subtype_range' ?_
simp only [embeddingOfSubset_apply_coe, Sum.elim_range, Subtype.range_val]
| Mathlib/LinearAlgebra/Dimension/Constructions.lean | 66 | 75 | theorem rank_quotient_add_rank_le [Nontrivial R] (M' : Submodule R M) :
Module.rank R (M ⧸ M') + Module.rank R M' ≤ Module.rank R M := by |
conv_lhs => simp only [Module.rank_def]
have := nonempty_linearIndependent_set R (M ⧸ M')
have := nonempty_linearIndependent_set R M'
rw [Cardinal.ciSup_add_ciSup _ (bddAbove_range.{v, v} _) _ (bddAbove_range.{v, v} _)]
refine ciSup_le fun ⟨s, hs⟩ ↦ ciSup_le fun ⟨t, ht⟩ ↦ ?_
choose f hf using Quotient.mk_surjective M'
simpa [add_comm] using (LinearIndependent.sum_elim_of_quotient ht (fun (i : s) ↦ f i)
(by simpa [Function.comp, hf] using hs)).cardinal_le_rank
| 0 |
import Mathlib.Algebra.Order.Monoid.Canonical.Defs
import Mathlib.Data.List.Infix
import Mathlib.Data.List.MinMax
import Mathlib.Data.List.EditDistance.Defs
set_option autoImplicit true
variable {C : Levenshtein.Cost α β δ} [CanonicallyLinearOrderedAddCommMonoid δ]
| Mathlib/Data/List/EditDistance/Bounds.lean | 26 | 56 | theorem suffixLevenshtein_minimum_le_levenshtein_cons (xs : List α) (y ys) :
(suffixLevenshtein C xs ys).1.minimum ≤ levenshtein C xs (y :: ys) := by |
induction xs with
| nil =>
simp only [suffixLevenshtein_nil', levenshtein_nil_cons,
List.minimum_singleton, WithTop.coe_le_coe]
exact le_add_of_nonneg_left (by simp)
| cons x xs ih =>
suffices
(suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.delete x + levenshtein C xs (y :: ys)) ∧
(suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.insert y + levenshtein C (x :: xs) ys) ∧
(suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.substitute x y + levenshtein C xs ys) by
simpa [suffixLevenshtein_eq_tails_map]
refine ⟨?_, ?_, ?_⟩
· calc
_ ≤ (suffixLevenshtein C xs ys).1.minimum := by
simp [suffixLevenshtein_cons₁_fst, List.minimum_cons]
_ ≤ ↑(levenshtein C xs (y :: ys)) := ih
_ ≤ _ := by simp
· calc
(suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C (x :: xs) ys) := by
simp [suffixLevenshtein_cons₁_fst, List.minimum_cons]
_ ≤ _ := by simp
· calc
(suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C xs ys) := by
simp only [suffixLevenshtein_cons₁_fst, List.minimum_cons]
apply min_le_of_right_le
cases xs
· simp [suffixLevenshtein_nil']
· simp [suffixLevenshtein_cons₁, List.minimum_cons]
_ ≤ _ := by simp
| 0 |
import Mathlib.Analysis.SpecialFunctions.Pow.Real
import Mathlib.Data.Int.Log
#align_import analysis.special_functions.log.base from "leanprover-community/mathlib"@"f23a09ce6d3f367220dc3cecad6b7eb69eb01690"
open Set Filter Function
open Topology
noncomputable section
namespace Real
variable {b x y : ℝ}
-- @[pp_nodot] -- Porting note: removed
noncomputable def logb (b x : ℝ) : ℝ :=
log x / log b
#align real.logb Real.logb
theorem log_div_log : log x / log b = logb b x :=
rfl
#align real.log_div_log Real.log_div_log
@[simp]
theorem logb_zero : logb b 0 = 0 := by simp [logb]
#align real.logb_zero Real.logb_zero
@[simp]
theorem logb_one : logb b 1 = 0 := by simp [logb]
#align real.logb_one Real.logb_one
@[simp]
lemma logb_self_eq_one (hb : 1 < b) : logb b b = 1 :=
div_self (log_pos hb).ne'
lemma logb_self_eq_one_iff : logb b b = 1 ↔ b ≠ 0 ∧ b ≠ 1 ∧ b ≠ -1 :=
Iff.trans ⟨fun h h' => by simp [logb, h'] at h, div_self⟩ log_ne_zero
@[simp]
theorem logb_abs (x : ℝ) : logb b |x| = logb b x := by rw [logb, logb, log_abs]
#align real.logb_abs Real.logb_abs
@[simp]
theorem logb_neg_eq_logb (x : ℝ) : logb b (-x) = logb b x := by
rw [← logb_abs x, ← logb_abs (-x), abs_neg]
#align real.logb_neg_eq_logb Real.logb_neg_eq_logb
theorem logb_mul (hx : x ≠ 0) (hy : y ≠ 0) : logb b (x * y) = logb b x + logb b y := by
simp_rw [logb, log_mul hx hy, add_div]
#align real.logb_mul Real.logb_mul
theorem logb_div (hx : x ≠ 0) (hy : y ≠ 0) : logb b (x / y) = logb b x - logb b y := by
simp_rw [logb, log_div hx hy, sub_div]
#align real.logb_div Real.logb_div
@[simp]
theorem logb_inv (x : ℝ) : logb b x⁻¹ = -logb b x := by simp [logb, neg_div]
#align real.logb_inv Real.logb_inv
theorem inv_logb (a b : ℝ) : (logb a b)⁻¹ = logb b a := by simp_rw [logb, inv_div]
#align real.inv_logb Real.inv_logb
theorem inv_logb_mul_base {a b : ℝ} (h₁ : a ≠ 0) (h₂ : b ≠ 0) (c : ℝ) :
(logb (a * b) c)⁻¹ = (logb a c)⁻¹ + (logb b c)⁻¹ := by
simp_rw [inv_logb]; exact logb_mul h₁ h₂
#align real.inv_logb_mul_base Real.inv_logb_mul_base
theorem inv_logb_div_base {a b : ℝ} (h₁ : a ≠ 0) (h₂ : b ≠ 0) (c : ℝ) :
(logb (a / b) c)⁻¹ = (logb a c)⁻¹ - (logb b c)⁻¹ := by
simp_rw [inv_logb]; exact logb_div h₁ h₂
#align real.inv_logb_div_base Real.inv_logb_div_base
theorem logb_mul_base {a b : ℝ} (h₁ : a ≠ 0) (h₂ : b ≠ 0) (c : ℝ) :
logb (a * b) c = ((logb a c)⁻¹ + (logb b c)⁻¹)⁻¹ := by rw [← inv_logb_mul_base h₁ h₂ c, inv_inv]
#align real.logb_mul_base Real.logb_mul_base
theorem logb_div_base {a b : ℝ} (h₁ : a ≠ 0) (h₂ : b ≠ 0) (c : ℝ) :
logb (a / b) c = ((logb a c)⁻¹ - (logb b c)⁻¹)⁻¹ := by rw [← inv_logb_div_base h₁ h₂ c, inv_inv]
#align real.logb_div_base Real.logb_div_base
theorem mul_logb {a b c : ℝ} (h₁ : b ≠ 0) (h₂ : b ≠ 1) (h₃ : b ≠ -1) :
logb a b * logb b c = logb a c := by
unfold logb
rw [mul_comm, div_mul_div_cancel _ (log_ne_zero.mpr ⟨h₁, h₂, h₃⟩)]
#align real.mul_logb Real.mul_logb
theorem div_logb {a b c : ℝ} (h₁ : c ≠ 0) (h₂ : c ≠ 1) (h₃ : c ≠ -1) :
logb a c / logb b c = logb a b :=
div_div_div_cancel_left' _ _ <| log_ne_zero.mpr ⟨h₁, h₂, h₃⟩
#align real.div_logb Real.div_logb
theorem logb_rpow_eq_mul_logb_of_pos (hx : 0 < x) : logb b (x ^ y) = y * logb b x := by
rw [logb, log_rpow hx, logb, mul_div_assoc]
theorem logb_pow {k : ℕ} (hx : 0 < x) : logb b (x ^ k) = k * logb b x := by
rw [← rpow_natCast, logb_rpow_eq_mul_logb_of_pos hx]
section BPosAndNeOne
variable (b_pos : 0 < b) (b_ne_one : b ≠ 1)
private theorem log_b_ne_zero : log b ≠ 0 := by
have b_ne_zero : b ≠ 0 := by linarith
have b_ne_minus_one : b ≠ -1 := by linarith
simp [b_ne_one, b_ne_zero, b_ne_minus_one]
@[simp]
theorem logb_rpow : logb b (b ^ x) = x := by
rw [logb, div_eq_iff, log_rpow b_pos]
exact log_b_ne_zero b_pos b_ne_one
#align real.logb_rpow Real.logb_rpow
| Mathlib/Analysis/SpecialFunctions/Log/Base.lean | 137 | 143 | theorem rpow_logb_eq_abs (hx : x ≠ 0) : b ^ logb b x = |x| := by |
apply log_injOn_pos
· simp only [Set.mem_Ioi]
apply rpow_pos_of_pos b_pos
· simp only [abs_pos, mem_Ioi, Ne, hx, not_false_iff]
rw [log_rpow b_pos, logb, log_abs]
field_simp [log_b_ne_zero b_pos b_ne_one]
| 0 |
import Mathlib.Algebra.MvPolynomial.Basic
#align_import data.mv_polynomial.rename from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4"
noncomputable section
open Set Function Finsupp AddMonoidAlgebra
variable {σ τ α R S : Type*} [CommSemiring R] [CommSemiring S]
namespace MvPolynomial
section Rename
def rename (f : σ → τ) : MvPolynomial σ R →ₐ[R] MvPolynomial τ R :=
aeval (X ∘ f)
#align mv_polynomial.rename MvPolynomial.rename
theorem rename_C (f : σ → τ) (r : R) : rename f (C r) = C r :=
eval₂_C _ _ _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.rename_C MvPolynomial.rename_C
@[simp]
theorem rename_X (f : σ → τ) (i : σ) : rename f (X i : MvPolynomial σ R) = X (f i) :=
eval₂_X _ _ _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.rename_X MvPolynomial.rename_X
theorem map_rename (f : R →+* S) (g : σ → τ) (p : MvPolynomial σ R) :
map f (rename g p) = rename g (map f p) := by
apply MvPolynomial.induction_on p
(fun a => by simp only [map_C, rename_C])
(fun p q hp hq => by simp only [hp, hq, AlgHom.map_add, RingHom.map_add]) fun p n hp => by
simp only [hp, rename_X, map_X, RingHom.map_mul, AlgHom.map_mul]
#align mv_polynomial.map_rename MvPolynomial.map_rename
@[simp]
theorem rename_rename (f : σ → τ) (g : τ → α) (p : MvPolynomial σ R) :
rename g (rename f p) = rename (g ∘ f) p :=
show rename g (eval₂ C (X ∘ f) p) = _ by
simp only [rename, aeval_eq_eval₂Hom]
-- Porting note: the Lean 3 proof of this was very fragile and included a nonterminal `simp`.
-- Hopefully this is less prone to breaking
rw [eval₂_comp_left (eval₂Hom (algebraMap R (MvPolynomial α R)) (X ∘ g)) C (X ∘ f) p]
simp only [(· ∘ ·), eval₂Hom_X']
refine eval₂Hom_congr ?_ rfl rfl
ext1; simp only [comp_apply, RingHom.coe_comp, eval₂Hom_C]
#align mv_polynomial.rename_rename MvPolynomial.rename_rename
@[simp]
theorem rename_id (p : MvPolynomial σ R) : rename id p = p :=
eval₂_eta p
#align mv_polynomial.rename_id MvPolynomial.rename_id
| Mathlib/Algebra/MvPolynomial/Rename.lean | 93 | 99 | theorem rename_monomial (f : σ → τ) (d : σ →₀ ℕ) (r : R) :
rename f (monomial d r) = monomial (d.mapDomain f) r := by |
rw [rename, aeval_monomial, monomial_eq (s := Finsupp.mapDomain f d),
Finsupp.prod_mapDomain_index]
· rfl
· exact fun n => pow_zero _
· exact fun n i₁ i₂ => pow_add _ _ _
| 0 |
import Mathlib.Data.List.Nodup
#align_import data.list.duplicate from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
variable {α : Type*}
namespace List
inductive Duplicate (x : α) : List α → Prop
| cons_mem {l : List α} : x ∈ l → Duplicate x (x :: l)
| cons_duplicate {y : α} {l : List α} : Duplicate x l → Duplicate x (y :: l)
#align list.duplicate List.Duplicate
local infixl:50 " ∈+ " => List.Duplicate
variable {l : List α} {x : α}
theorem Mem.duplicate_cons_self (h : x ∈ l) : x ∈+ x :: l :=
Duplicate.cons_mem h
#align list.mem.duplicate_cons_self List.Mem.duplicate_cons_self
theorem Duplicate.duplicate_cons (h : x ∈+ l) (y : α) : x ∈+ y :: l :=
Duplicate.cons_duplicate h
#align list.duplicate.duplicate_cons List.Duplicate.duplicate_cons
theorem Duplicate.mem (h : x ∈+ l) : x ∈ l := by
induction' h with l' _ y l' _ hm
· exact mem_cons_self _ _
· exact mem_cons_of_mem _ hm
#align list.duplicate.mem List.Duplicate.mem
theorem Duplicate.mem_cons_self (h : x ∈+ x :: l) : x ∈ l := by
cases' h with _ h _ _ h
· exact h
· exact h.mem
#align list.duplicate.mem_cons_self List.Duplicate.mem_cons_self
@[simp]
theorem duplicate_cons_self_iff : x ∈+ x :: l ↔ x ∈ l :=
⟨Duplicate.mem_cons_self, Mem.duplicate_cons_self⟩
#align list.duplicate_cons_self_iff List.duplicate_cons_self_iff
theorem Duplicate.ne_nil (h : x ∈+ l) : l ≠ [] := fun H => (mem_nil_iff x).mp (H ▸ h.mem)
#align list.duplicate.ne_nil List.Duplicate.ne_nil
@[simp]
theorem not_duplicate_nil (x : α) : ¬x ∈+ [] := fun H => H.ne_nil rfl
#align list.not_duplicate_nil List.not_duplicate_nil
theorem Duplicate.ne_singleton (h : x ∈+ l) (y : α) : l ≠ [y] := by
induction' h with l' h z l' h _
· simp [ne_nil_of_mem h]
· simp [ne_nil_of_mem h.mem]
#align list.duplicate.ne_singleton List.Duplicate.ne_singleton
@[simp]
theorem not_duplicate_singleton (x y : α) : ¬x ∈+ [y] := fun H => H.ne_singleton _ rfl
#align list.not_duplicate_singleton List.not_duplicate_singleton
theorem Duplicate.elim_nil (h : x ∈+ []) : False :=
not_duplicate_nil x h
#align list.duplicate.elim_nil List.Duplicate.elim_nil
theorem Duplicate.elim_singleton {y : α} (h : x ∈+ [y]) : False :=
not_duplicate_singleton x y h
#align list.duplicate.elim_singleton List.Duplicate.elim_singleton
theorem duplicate_cons_iff {y : α} : x ∈+ y :: l ↔ y = x ∧ x ∈ l ∨ x ∈+ l := by
refine ⟨fun h => ?_, fun h => ?_⟩
· cases' h with _ hm _ _ hm
· exact Or.inl ⟨rfl, hm⟩
· exact Or.inr hm
· rcases h with (⟨rfl | h⟩ | h)
· simpa
· exact h.cons_duplicate
#align list.duplicate_cons_iff List.duplicate_cons_iff
theorem Duplicate.of_duplicate_cons {y : α} (h : x ∈+ y :: l) (hx : x ≠ y) : x ∈+ l := by
simpa [duplicate_cons_iff, hx.symm] using h
#align list.duplicate.of_duplicate_cons List.Duplicate.of_duplicate_cons
theorem duplicate_cons_iff_of_ne {y : α} (hne : x ≠ y) : x ∈+ y :: l ↔ x ∈+ l := by
simp [duplicate_cons_iff, hne.symm]
#align list.duplicate_cons_iff_of_ne List.duplicate_cons_iff_of_ne
theorem Duplicate.mono_sublist {l' : List α} (hx : x ∈+ l) (h : l <+ l') : x ∈+ l' := by
induction' h with l₁ l₂ y _ IH l₁ l₂ y h IH
· exact hx
· exact (IH hx).duplicate_cons _
· rw [duplicate_cons_iff] at hx ⊢
rcases hx with (⟨rfl, hx⟩ | hx)
· simp [h.subset hx]
· simp [IH hx]
#align list.duplicate.mono_sublist List.Duplicate.mono_sublist
| Mathlib/Data/List/Duplicate.lean | 117 | 126 | theorem duplicate_iff_sublist : x ∈+ l ↔ [x, x] <+ l := by |
induction' l with y l IH
· simp
· by_cases hx : x = y
· simp [hx, cons_sublist_cons, singleton_sublist]
· rw [duplicate_cons_iff_of_ne hx, IH]
refine ⟨sublist_cons_of_sublist y, fun h => ?_⟩
cases h
· assumption
· contradiction
| 0 |
import Mathlib.Data.Set.Pairwise.Basic
import Mathlib.Data.Set.Lattice
import Mathlib.Order.SuccPred.Basic
#align_import order.succ_pred.interval_succ from "leanprover-community/mathlib"@"c227d107bbada5d0d9d20287e3282c0a7f1651a0"
open Set Order
variable {α β : Type*} [LinearOrder α]
namespace Monotone
| Mathlib/Order/SuccPred/IntervalSucc.lean | 38 | 48 | theorem biUnion_Ico_Ioc_map_succ [SuccOrder α] [IsSuccArchimedean α] [LinearOrder β] {f : α → β}
(hf : Monotone f) (m n : α) : ⋃ i ∈ Ico m n, Ioc (f i) (f (succ i)) = Ioc (f m) (f n) := by |
rcases le_total n m with hnm | hmn
· rw [Ico_eq_empty_of_le hnm, Ioc_eq_empty_of_le (hf hnm), biUnion_empty]
· refine Succ.rec ?_ ?_ hmn
· simp only [Ioc_self, Ico_self, biUnion_empty]
· intro k hmk ihk
rw [← Ioc_union_Ioc_eq_Ioc (hf hmk) (hf <| le_succ _), union_comm, ← ihk]
by_cases hk : IsMax k
· rw [hk.succ_eq, Ioc_self, empty_union]
· rw [Ico_succ_right_eq_insert_of_not_isMax hmk hk, biUnion_insert]
| 0 |
import Mathlib.Algebra.Ring.Prod
import Mathlib.GroupTheory.OrderOfElement
import Mathlib.Tactic.FinCases
#align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7"
assert_not_exists Submodule
open Function
namespace ZMod
instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ)
def val : ∀ {n : ℕ}, ZMod n → ℕ
| 0 => Int.natAbs
| n + 1 => ((↑) : Fin (n + 1) → ℕ)
#align zmod.val ZMod.val
theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by
cases n
· cases NeZero.ne 0 rfl
exact Fin.is_lt a
#align zmod.val_lt ZMod.val_lt
theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n :=
a.val_lt.le
#align zmod.val_le ZMod.val_le
@[simp]
theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0
| 0 => rfl
| _ + 1 => rfl
#align zmod.val_zero ZMod.val_zero
@[simp]
theorem val_one' : (1 : ZMod 0).val = 1 :=
rfl
#align zmod.val_one' ZMod.val_one'
@[simp]
theorem val_neg' {n : ZMod 0} : (-n).val = n.val :=
Int.natAbs_neg n
#align zmod.val_neg' ZMod.val_neg'
@[simp]
theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val :=
Int.natAbs_mul m n
#align zmod.val_mul' ZMod.val_mul'
@[simp]
theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by
cases n
· rw [Nat.mod_zero]
exact Int.natAbs_ofNat a
· apply Fin.val_natCast
#align zmod.val_nat_cast ZMod.val_natCast
@[deprecated (since := "2024-04-17")]
alias val_nat_cast := val_natCast
theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by
simp only [val]
rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one]
lemma eq_one_of_isUnit_natCast {n : ℕ} (h : IsUnit (n : ZMod 0)) : n = 1 := by
rw [← Nat.mod_zero n, ← val_natCast, val_unit'.mp h]
theorem val_natCast_of_lt {n a : ℕ} (h : a < n) : (a : ZMod n).val = a := by
rwa [val_natCast, Nat.mod_eq_of_lt]
@[deprecated (since := "2024-04-17")]
alias val_nat_cast_of_lt := val_natCast_of_lt
instance charP (n : ℕ) : CharP (ZMod n) n where
cast_eq_zero_iff' := by
intro k
cases' n with n
· simp [zero_dvd_iff, Int.natCast_eq_zero, Nat.zero_eq]
· exact Fin.natCast_eq_zero
@[simp]
theorem addOrderOf_one (n : ℕ) : addOrderOf (1 : ZMod n) = n :=
CharP.eq _ (CharP.addOrderOf_one _) (ZMod.charP n)
#align zmod.add_order_of_one ZMod.addOrderOf_one
@[simp]
theorem addOrderOf_coe (a : ℕ) {n : ℕ} (n0 : n ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by
cases' a with a
· simp only [Nat.zero_eq, Nat.cast_zero, addOrderOf_zero, Nat.gcd_zero_right,
Nat.pos_of_ne_zero n0, Nat.div_self]
rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a.succ_ne_zero, ZMod.addOrderOf_one]
#align zmod.add_order_of_coe ZMod.addOrderOf_coe
@[simp]
theorem addOrderOf_coe' {a : ℕ} (n : ℕ) (a0 : a ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by
rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a0, ZMod.addOrderOf_one]
#align zmod.add_order_of_coe' ZMod.addOrderOf_coe'
theorem ringChar_zmod_n (n : ℕ) : ringChar (ZMod n) = n := by
rw [ringChar.eq_iff]
exact ZMod.charP n
#align zmod.ring_char_zmod_n ZMod.ringChar_zmod_n
-- @[simp] -- Porting note (#10618): simp can prove this
theorem natCast_self (n : ℕ) : (n : ZMod n) = 0 :=
CharP.cast_eq_zero (ZMod n) n
#align zmod.nat_cast_self ZMod.natCast_self
@[deprecated (since := "2024-04-17")]
alias nat_cast_self := natCast_self
@[simp]
| Mathlib/Data/ZMod/Basic.lean | 151 | 152 | theorem natCast_self' (n : ℕ) : (n + 1 : ZMod (n + 1)) = 0 := by |
rw [← Nat.cast_add_one, natCast_self (n + 1)]
| 0 |
import Mathlib.FieldTheory.Finite.Basic
#align_import number_theory.wilson from "leanprover-community/mathlib"@"c471da714c044131b90c133701e51b877c246677"
open Finset Nat FiniteField ZMod
open scoped Nat
namespace ZMod
variable (p : ℕ) [Fact p.Prime]
@[simp]
| Mathlib/NumberTheory/Wilson.lean | 40 | 69 | 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]
| 0 |
import Mathlib.Algebra.Group.Basic
import Mathlib.Algebra.Group.Pi.Basic
import Mathlib.Order.Fin
import Mathlib.Order.PiLex
import Mathlib.Order.Interval.Set.Basic
#align_import data.fin.tuple.basic from "leanprover-community/mathlib"@"ef997baa41b5c428be3fb50089a7139bf4ee886b"
assert_not_exists MonoidWithZero
universe u v
namespace Fin
variable {m n : ℕ}
open Function
section Tuple
example (α : Fin 0 → Sort u) : Unique (∀ i : Fin 0, α i) := by infer_instance
theorem tuple0_le {α : Fin 0 → Type*} [∀ i, Preorder (α i)] (f g : ∀ i, α i) : f ≤ g :=
finZeroElim
#align fin.tuple0_le Fin.tuple0_le
variable {α : Fin (n + 1) → Type u} (x : α 0) (q : ∀ i, α i) (p : ∀ i : Fin n, α i.succ) (i : Fin n)
(y : α i.succ) (z : α 0)
def tail (q : ∀ i, α i) : ∀ i : Fin n, α i.succ := fun i ↦ q i.succ
#align fin.tail Fin.tail
theorem tail_def {n : ℕ} {α : Fin (n + 1) → Type*} {q : ∀ i, α i} :
(tail fun k : Fin (n + 1) ↦ q k) = fun k : Fin n ↦ q k.succ :=
rfl
#align fin.tail_def Fin.tail_def
def cons (x : α 0) (p : ∀ i : Fin n, α i.succ) : ∀ i, α i := fun j ↦ Fin.cases x p j
#align fin.cons Fin.cons
@[simp]
theorem tail_cons : tail (cons x p) = p := by
simp (config := { unfoldPartialApp := true }) [tail, cons]
#align fin.tail_cons Fin.tail_cons
@[simp]
theorem cons_succ : cons x p i.succ = p i := by simp [cons]
#align fin.cons_succ Fin.cons_succ
@[simp]
theorem cons_zero : cons x p 0 = x := by simp [cons]
#align fin.cons_zero Fin.cons_zero
@[simp]
theorem cons_one {α : Fin (n + 2) → Type*} (x : α 0) (p : ∀ i : Fin n.succ, α i.succ) :
cons x p 1 = p 0 := by
rw [← cons_succ x p]; rfl
@[simp]
theorem cons_update : cons x (update p i y) = update (cons x p) i.succ y := by
ext j
by_cases h : j = 0
· rw [h]
simp [Ne.symm (succ_ne_zero i)]
· let j' := pred j h
have : j'.succ = j := succ_pred j h
rw [← this, cons_succ]
by_cases h' : j' = i
· rw [h']
simp
· have : j'.succ ≠ i.succ := by rwa [Ne, succ_inj]
rw [update_noteq h', update_noteq this, cons_succ]
#align fin.cons_update Fin.cons_update
theorem cons_injective2 : Function.Injective2 (@cons n α) := fun x₀ y₀ x y h ↦
⟨congr_fun h 0, funext fun i ↦ by simpa using congr_fun h (Fin.succ i)⟩
#align fin.cons_injective2 Fin.cons_injective2
@[simp]
theorem cons_eq_cons {x₀ y₀ : α 0} {x y : ∀ i : Fin n, α i.succ} :
cons x₀ x = cons y₀ y ↔ x₀ = y₀ ∧ x = y :=
cons_injective2.eq_iff
#align fin.cons_eq_cons Fin.cons_eq_cons
theorem cons_left_injective (x : ∀ i : Fin n, α i.succ) : Function.Injective fun x₀ ↦ cons x₀ x :=
cons_injective2.left _
#align fin.cons_left_injective Fin.cons_left_injective
theorem cons_right_injective (x₀ : α 0) : Function.Injective (cons x₀) :=
cons_injective2.right _
#align fin.cons_right_injective Fin.cons_right_injective
theorem update_cons_zero : update (cons x p) 0 z = cons z p := by
ext j
by_cases h : j = 0
· rw [h]
simp
· simp only [h, update_noteq, Ne, not_false_iff]
let j' := pred j h
have : j'.succ = j := succ_pred j h
rw [← this, cons_succ, cons_succ]
#align fin.update_cons_zero Fin.update_cons_zero
@[simp, nolint simpNF] -- Porting note: linter claims LHS doesn't simplify
theorem cons_self_tail : cons (q 0) (tail q) = q := by
ext j
by_cases h : j = 0
· rw [h]
simp
· let j' := pred j h
have : j'.succ = j := succ_pred j h
rw [← this]
unfold tail
rw [cons_succ]
#align fin.cons_self_tail Fin.cons_self_tail
-- Porting note: Mathport removes `_root_`?
@[elab_as_elim]
def consCases {P : (∀ i : Fin n.succ, α i) → Sort v} (h : ∀ x₀ x, P (Fin.cons x₀ x))
(x : ∀ i : Fin n.succ, α i) : P x :=
_root_.cast (by rw [cons_self_tail]) <| h (x 0) (tail x)
#align fin.cons_cases Fin.consCases
@[simp]
| Mathlib/Data/Fin/Tuple/Basic.lean | 162 | 165 | theorem consCases_cons {P : (∀ i : Fin n.succ, α i) → Sort v} (h : ∀ x₀ x, P (Fin.cons x₀ x))
(x₀ : α 0) (x : ∀ i : Fin n, α i.succ) : @consCases _ _ _ h (cons x₀ x) = h x₀ x := by |
rw [consCases, cast_eq]
congr
| 0 |
import Mathlib.RingTheory.Polynomial.Cyclotomic.Basic
import Mathlib.RingTheory.RootsOfUnity.Minpoly
#align_import ring_theory.polynomial.cyclotomic.roots from "leanprover-community/mathlib"@"7fdeecc0d03cd40f7a165e6cf00a4d2286db599f"
namespace Polynomial
variable {R : Type*} [CommRing R] {n : ℕ}
theorem isRoot_of_unity_of_root_cyclotomic {ζ : R} {i : ℕ} (hi : i ∈ n.divisors)
(h : (cyclotomic i R).IsRoot ζ) : ζ ^ n = 1 := by
rcases n.eq_zero_or_pos with (rfl | hn)
· exact pow_zero _
have := congr_arg (eval ζ) (prod_cyclotomic_eq_X_pow_sub_one hn R).symm
rw [eval_sub, eval_pow, eval_X, eval_one] at this
convert eq_add_of_sub_eq' this
convert (add_zero (M := R) _).symm
apply eval_eq_zero_of_dvd_of_eval_eq_zero _ h
exact Finset.dvd_prod_of_mem _ hi
#align polynomial.is_root_of_unity_of_root_cyclotomic Polynomial.isRoot_of_unity_of_root_cyclotomic
section IsDomain
variable [IsDomain R]
| Mathlib/RingTheory/Polynomial/Cyclotomic/Roots.lean | 56 | 59 | theorem _root_.isRoot_of_unity_iff (h : 0 < n) (R : Type*) [CommRing R] [IsDomain R] {ζ : R} :
ζ ^ n = 1 ↔ ∃ i ∈ n.divisors, (cyclotomic i R).IsRoot ζ := by |
rw [← mem_nthRoots h, nthRoots, mem_roots <| X_pow_sub_C_ne_zero h _, C_1, ←
prod_cyclotomic_eq_X_pow_sub_one h, isRoot_prod]
| 0 |
import Mathlib.MeasureTheory.OuterMeasure.OfFunction
import Mathlib.MeasureTheory.PiSystem
#align_import measure_theory.measure.outer_measure from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55"
noncomputable section
open Set Function Filter
open scoped Classical NNReal Topology ENNReal
namespace MeasureTheory
namespace OuterMeasure
section CaratheodoryMeasurable
universe u
variable {α : Type u} (m : OuterMeasure α)
attribute [local simp] Set.inter_comm Set.inter_left_comm Set.inter_assoc
variable {s s₁ s₂ : Set α}
def IsCaratheodory (s : Set α) : Prop :=
∀ t, m t = m (t ∩ s) + m (t \ s)
#align measure_theory.outer_measure.is_caratheodory MeasureTheory.OuterMeasure.IsCaratheodory
theorem isCaratheodory_iff_le' {s : Set α} :
IsCaratheodory m s ↔ ∀ t, m (t ∩ s) + m (t \ s) ≤ m t :=
forall_congr' fun _ => le_antisymm_iff.trans <| and_iff_right <| measure_le_inter_add_diff _ _ _
#align measure_theory.outer_measure.is_caratheodory_iff_le' MeasureTheory.OuterMeasure.isCaratheodory_iff_le'
@[simp]
theorem isCaratheodory_empty : IsCaratheodory m ∅ := by simp [IsCaratheodory, m.empty, diff_empty]
#align measure_theory.outer_measure.is_caratheodory_empty MeasureTheory.OuterMeasure.isCaratheodory_empty
theorem isCaratheodory_compl : IsCaratheodory m s₁ → IsCaratheodory m s₁ᶜ := by
simp [IsCaratheodory, diff_eq, add_comm]
#align measure_theory.outer_measure.is_caratheodory_compl MeasureTheory.OuterMeasure.isCaratheodory_compl
@[simp]
theorem isCaratheodory_compl_iff : IsCaratheodory m sᶜ ↔ IsCaratheodory m s :=
⟨fun h => by simpa using isCaratheodory_compl m h, isCaratheodory_compl m⟩
#align measure_theory.outer_measure.is_caratheodory_compl_iff MeasureTheory.OuterMeasure.isCaratheodory_compl_iff
theorem isCaratheodory_union (h₁ : IsCaratheodory m s₁) (h₂ : IsCaratheodory m s₂) :
IsCaratheodory m (s₁ ∪ s₂) := fun t => by
rw [h₁ t, h₂ (t ∩ s₁), h₂ (t \ s₁), h₁ (t ∩ (s₁ ∪ s₂)), inter_diff_assoc _ _ s₁,
Set.inter_assoc _ _ s₁, inter_eq_self_of_subset_right Set.subset_union_left,
union_diff_left, h₂ (t ∩ s₁)]
simp [diff_eq, add_assoc]
#align measure_theory.outer_measure.is_caratheodory_union MeasureTheory.OuterMeasure.isCaratheodory_union
theorem measure_inter_union (h : s₁ ∩ s₂ ⊆ ∅) (h₁ : IsCaratheodory m s₁) {t : Set α} :
m (t ∩ (s₁ ∪ s₂)) = m (t ∩ s₁) + m (t ∩ s₂) := by
rw [h₁, Set.inter_assoc, Set.union_inter_cancel_left, inter_diff_assoc, union_diff_cancel_left h]
#align measure_theory.outer_measure.measure_inter_union MeasureTheory.OuterMeasure.measure_inter_union
theorem isCaratheodory_iUnion_lt {s : ℕ → Set α} :
∀ {n : ℕ}, (∀ i < n, IsCaratheodory m (s i)) → IsCaratheodory m (⋃ i < n, s i)
| 0, _ => by simp [Nat.not_lt_zero]
| n + 1, h => by
rw [biUnion_lt_succ]
exact isCaratheodory_union m
(isCaratheodory_iUnion_lt fun i hi => h i <| lt_of_lt_of_le hi <| Nat.le_succ _)
(h n (le_refl (n + 1)))
#align measure_theory.outer_measure.is_caratheodory_Union_lt MeasureTheory.OuterMeasure.isCaratheodory_iUnion_lt
| Mathlib/MeasureTheory/OuterMeasure/Caratheodory.lean | 97 | 100 | theorem isCaratheodory_inter (h₁ : IsCaratheodory m s₁) (h₂ : IsCaratheodory m s₂) :
IsCaratheodory m (s₁ ∩ s₂) := by |
rw [← isCaratheodory_compl_iff, Set.compl_inter]
exact isCaratheodory_union _ (isCaratheodory_compl _ h₁) (isCaratheodory_compl _ h₂)
| 0 |
import Mathlib.Analysis.Convex.Between
import Mathlib.Analysis.Convex.Jensen
import Mathlib.Analysis.Convex.Topology
import Mathlib.Analysis.Normed.Group.Pointwise
import Mathlib.Analysis.NormedSpace.AddTorsor
#align_import analysis.convex.normed from "leanprover-community/mathlib"@"a63928c34ec358b5edcda2bf7513c50052a5230f"
variable {ι : Type*} {E P : Type*}
open Metric Set
open scoped Convex
variable [SeminormedAddCommGroup E] [NormedSpace ℝ E] [PseudoMetricSpace P] [NormedAddTorsor E P]
variable {s t : Set E}
theorem convexOn_norm (hs : Convex ℝ s) : ConvexOn ℝ s norm :=
⟨hs, fun x _ y _ a b ha hb _ =>
calc
‖a • x + b • y‖ ≤ ‖a • x‖ + ‖b • y‖ := norm_add_le _ _
_ = a * ‖x‖ + b * ‖y‖ := by
rw [norm_smul, norm_smul, Real.norm_of_nonneg ha, Real.norm_of_nonneg hb]⟩
#align convex_on_norm convexOn_norm
theorem convexOn_univ_norm : ConvexOn ℝ univ (norm : E → ℝ) :=
convexOn_norm convex_univ
#align convex_on_univ_norm convexOn_univ_norm
theorem convexOn_dist (z : E) (hs : Convex ℝ s) : ConvexOn ℝ s fun z' => dist z' z := by
simpa [dist_eq_norm, preimage_preimage] using
(convexOn_norm (hs.translate (-z))).comp_affineMap (AffineMap.id ℝ E - AffineMap.const ℝ E z)
#align convex_on_dist convexOn_dist
theorem convexOn_univ_dist (z : E) : ConvexOn ℝ univ fun z' => dist z' z :=
convexOn_dist z convex_univ
#align convex_on_univ_dist convexOn_univ_dist
theorem convex_ball (a : E) (r : ℝ) : Convex ℝ (Metric.ball a r) := by
simpa only [Metric.ball, sep_univ] using (convexOn_univ_dist a).convex_lt r
#align convex_ball convex_ball
theorem convex_closedBall (a : E) (r : ℝ) : Convex ℝ (Metric.closedBall a r) := by
simpa only [Metric.closedBall, sep_univ] using (convexOn_univ_dist a).convex_le r
#align convex_closed_ball convex_closedBall
theorem Convex.thickening (hs : Convex ℝ s) (δ : ℝ) : Convex ℝ (thickening δ s) := by
rw [← add_ball_zero]
exact hs.add (convex_ball 0 _)
#align convex.thickening Convex.thickening
| Mathlib/Analysis/Convex/Normed.lean | 75 | 80 | theorem Convex.cthickening (hs : Convex ℝ s) (δ : ℝ) : Convex ℝ (cthickening δ s) := by |
obtain hδ | hδ := le_total 0 δ
· rw [cthickening_eq_iInter_thickening hδ]
exact convex_iInter₂ fun _ _ => hs.thickening _
· rw [cthickening_of_nonpos hδ]
exact hs.closure
| 0 |
import Mathlib.RingTheory.DedekindDomain.Dvr
import Mathlib.RingTheory.DedekindDomain.Ideal
#align_import ring_theory.dedekind_domain.pid from "leanprover-community/mathlib"@"6010cf523816335f7bae7f8584cb2edaace73940"
variable {R : Type*} [CommRing R]
open Ideal
open UniqueFactorizationMonoid
open scoped nonZeroDivisors
open UniqueFactorizationMonoid
| Mathlib/RingTheory/DedekindDomain/PID.lean | 38 | 74 | theorem Ideal.eq_span_singleton_of_mem_of_not_mem_sq_of_not_mem_prime_ne {P : Ideal R}
(hP : P.IsPrime) [IsDedekindDomain R] {x : R} (x_mem : x ∈ P) (hxP2 : x ∉ P ^ 2)
(hxQ : ∀ Q : Ideal R, IsPrime Q → Q ≠ P → x ∉ Q) : P = Ideal.span {x} := by |
letI := Classical.decEq (Ideal R)
have hx0 : x ≠ 0 := by
rintro rfl
exact hxP2 (zero_mem _)
by_cases hP0 : P = ⊥
· subst hP0
-- Porting note: was `simpa using hxP2` but that hypothesis didn't even seem relevant in Lean 3
rwa [eq_comm, span_singleton_eq_bot, ← mem_bot]
have hspan0 : span ({x} : Set R) ≠ ⊥ := mt Ideal.span_singleton_eq_bot.mp hx0
have span_le := (Ideal.span_singleton_le_iff_mem _).mpr x_mem
refine
associated_iff_eq.mp
((associated_iff_normalizedFactors_eq_normalizedFactors hP0 hspan0).mpr
(le_antisymm ((dvd_iff_normalizedFactors_le_normalizedFactors hP0 hspan0).mp ?_) ?_))
· rwa [Ideal.dvd_iff_le, Ideal.span_singleton_le_iff_mem]
simp only [normalizedFactors_irreducible (Ideal.prime_of_isPrime hP0 hP).irreducible,
normalize_eq, Multiset.le_iff_count, Multiset.count_singleton]
intro Q
split_ifs with hQ
· subst hQ
refine (Ideal.count_normalizedFactors_eq ?_ ?_).le <;>
simp only [Ideal.span_singleton_le_iff_mem, pow_one] <;>
assumption
by_cases hQp : IsPrime Q
· refine (Ideal.count_normalizedFactors_eq ?_ ?_).le <;>
-- Porting note: included `zero_add` in the simp arguments
simp only [Ideal.span_singleton_le_iff_mem, zero_add, pow_one, pow_zero, one_eq_top,
Submodule.mem_top]
exact hxQ _ hQp hQ
· exact
(Multiset.count_eq_zero.mpr fun hQi =>
hQp
(isPrime_of_prime
(irreducible_iff_prime.mp (irreducible_of_normalized_factor _ hQi)))).le
| 0 |
import Mathlib.CategoryTheory.Category.Grpd
import Mathlib.CategoryTheory.Groupoid
import Mathlib.Topology.Category.TopCat.Basic
import Mathlib.Topology.Homotopy.Path
import Mathlib.Data.Set.Subsingleton
#align_import algebraic_topology.fundamental_groupoid.basic from "leanprover-community/mathlib"@"3d7987cda72abc473c7cdbbb075170e9ac620042"
open CategoryTheory
universe u v
variable {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y]
variable {x₀ x₁ : X}
noncomputable section
open unitInterval
namespace Path
namespace Homotopy
section
def reflTransSymmAux (x : I × I) : ℝ :=
if (x.2 : ℝ) ≤ 1 / 2 then x.1 * 2 * x.2 else x.1 * (2 - 2 * x.2)
#align path.homotopy.refl_trans_symm_aux Path.Homotopy.reflTransSymmAux
@[continuity]
theorem continuous_reflTransSymmAux : Continuous reflTransSymmAux := by
refine continuous_if_le ?_ ?_ (Continuous.continuousOn ?_) (Continuous.continuousOn ?_) ?_
· continuity
· continuity
· continuity
· continuity
intro x hx
norm_num [hx, mul_assoc]
#align path.homotopy.continuous_refl_trans_symm_aux Path.Homotopy.continuous_reflTransSymmAux
theorem reflTransSymmAux_mem_I (x : I × I) : reflTransSymmAux x ∈ I := by
dsimp only [reflTransSymmAux]
split_ifs
· constructor
· apply mul_nonneg
· apply mul_nonneg
· unit_interval
· norm_num
· unit_interval
· rw [mul_assoc]
apply mul_le_one
· unit_interval
· apply mul_nonneg
· norm_num
· unit_interval
· linarith
· constructor
· apply mul_nonneg
· unit_interval
linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2]
· apply mul_le_one
· unit_interval
· linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2]
· linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2]
set_option linter.uppercaseLean3 false in
#align path.homotopy.refl_trans_symm_aux_mem_I Path.Homotopy.reflTransSymmAux_mem_I
def reflTransSymm (p : Path x₀ x₁) : Homotopy (Path.refl x₀) (p.trans p.symm) where
toFun x := p ⟨reflTransSymmAux x, reflTransSymmAux_mem_I x⟩
continuous_toFun := by continuity
map_zero_left := by simp [reflTransSymmAux]
map_one_left x := by
dsimp only [reflTransSymmAux, Path.coe_toContinuousMap, Path.trans]
change _ = ite _ _ _
split_ifs with h
· rw [Path.extend, Set.IccExtend_of_mem]
· norm_num
· rw [unitInterval.mul_pos_mem_iff zero_lt_two]
exact ⟨unitInterval.nonneg x, h⟩
· rw [Path.symm, Path.extend, Set.IccExtend_of_mem]
· simp only [Set.Icc.coe_one, one_mul, coe_mk_mk, Function.comp_apply]
congr 1
ext
norm_num [sub_sub_eq_add_sub]
· rw [unitInterval.two_mul_sub_one_mem_iff]
exact ⟨(not_le.1 h).le, unitInterval.le_one x⟩
prop' t x hx := by
simp only [Set.mem_singleton_iff, Set.mem_insert_iff] at hx
simp only [ContinuousMap.coe_mk, coe_toContinuousMap, Path.refl_apply]
cases hx with
| inl hx
| inr hx =>
set_option tactic.skipAssignedInstances false in
rw [hx]
norm_num [reflTransSymmAux]
#align path.homotopy.refl_trans_symm Path.Homotopy.reflTransSymm
def reflSymmTrans (p : Path x₀ x₁) : Homotopy (Path.refl x₁) (p.symm.trans p) :=
(reflTransSymm p.symm).cast rfl <| congr_arg _ (Path.symm_symm _)
#align path.homotopy.refl_symm_trans Path.Homotopy.reflSymmTrans
end
section Assoc
def transAssocReparamAux (t : I) : ℝ :=
if (t : ℝ) ≤ 1 / 4 then 2 * t else if (t : ℝ) ≤ 1 / 2 then t + 1 / 4 else 1 / 2 * (t + 1)
#align path.homotopy.trans_assoc_reparam_aux Path.Homotopy.transAssocReparamAux
@[continuity]
| Mathlib/AlgebraicTopology/FundamentalGroupoid/Basic.lean | 189 | 197 | theorem continuous_transAssocReparamAux : Continuous transAssocReparamAux := by |
refine continuous_if_le ?_ ?_ (Continuous.continuousOn ?_)
(continuous_if_le ?_ ?_
(Continuous.continuousOn ?_) (Continuous.continuousOn ?_) ?_).continuousOn
?_ <;>
[continuity; continuity; continuity; continuity; continuity; continuity; continuity; skip;
skip] <;>
· intro x hx
set_option tactic.skipAssignedInstances false in norm_num [hx]
| 0 |
import Mathlib.RingTheory.Ideal.Operations
import Mathlib.Algebra.Module.Torsion
import Mathlib.Algebra.Ring.Idempotents
import Mathlib.LinearAlgebra.FiniteDimensional
import Mathlib.RingTheory.Ideal.LocalRing
import Mathlib.RingTheory.Filtration
import Mathlib.RingTheory.Nakayama
#align_import ring_theory.ideal.cotangent from "leanprover-community/mathlib"@"4b92a463033b5587bb011657e25e4710bfca7364"
namespace Ideal
-- Porting note: universes need to be explicit to avoid bad universe levels in `quotCotangent`
universe u v w
variable {R : Type u} {S : Type v} {S' : Type w} [CommRing R] [CommSemiring S] [Algebra S R]
variable [CommSemiring S'] [Algebra S' R] [Algebra S S'] [IsScalarTower S S' R] (I : Ideal R)
-- Porting note: instances that were derived automatically need to be proved by hand (see below)
def Cotangent : Type _ := I ⧸ (I • ⊤ : Submodule R I)
#align ideal.cotangent Ideal.Cotangent
instance : AddCommGroup I.Cotangent := by delta Cotangent; infer_instance
instance cotangentModule : Module (R ⧸ I) I.Cotangent := by delta Cotangent; infer_instance
instance : Inhabited I.Cotangent := ⟨0⟩
instance Cotangent.moduleOfTower : Module S I.Cotangent :=
Submodule.Quotient.module' _
#align ideal.cotangent.module_of_tower Ideal.Cotangent.moduleOfTower
instance Cotangent.isScalarTower : IsScalarTower S S' I.Cotangent :=
Submodule.Quotient.isScalarTower _ _
#align ideal.cotangent.is_scalar_tower Ideal.Cotangent.isScalarTower
instance [IsNoetherian R I] : IsNoetherian R I.Cotangent :=
inferInstanceAs (IsNoetherian R (I ⧸ (I • ⊤ : Submodule R I)))
@[simps! (config := .lemmasOnly) apply]
def toCotangent : I →ₗ[R] I.Cotangent := Submodule.mkQ _
#align ideal.to_cotangent Ideal.toCotangent
theorem map_toCotangent_ker : I.toCotangent.ker.map I.subtype = I ^ 2 := by
rw [Ideal.toCotangent, Submodule.ker_mkQ, pow_two, Submodule.map_smul'' I ⊤ (Submodule.subtype I),
Algebra.id.smul_eq_mul, Submodule.map_subtype_top]
#align ideal.map_to_cotangent_ker Ideal.map_toCotangent_ker
theorem mem_toCotangent_ker {x : I} : x ∈ LinearMap.ker I.toCotangent ↔ (x : R) ∈ I ^ 2 := by
rw [← I.map_toCotangent_ker]
simp
#align ideal.mem_to_cotangent_ker Ideal.mem_toCotangent_ker
theorem toCotangent_eq {x y : I} : I.toCotangent x = I.toCotangent y ↔ (x - y : R) ∈ I ^ 2 := by
rw [← sub_eq_zero]
exact I.mem_toCotangent_ker
#align ideal.to_cotangent_eq Ideal.toCotangent_eq
theorem toCotangent_eq_zero (x : I) : I.toCotangent x = 0 ↔ (x : R) ∈ I ^ 2 := I.mem_toCotangent_ker
#align ideal.to_cotangent_eq_zero Ideal.toCotangent_eq_zero
theorem toCotangent_surjective : Function.Surjective I.toCotangent := Submodule.mkQ_surjective _
#align ideal.to_cotangent_surjective Ideal.toCotangent_surjective
theorem toCotangent_range : LinearMap.range I.toCotangent = ⊤ := Submodule.range_mkQ _
#align ideal.to_cotangent_range Ideal.toCotangent_range
theorem cotangent_subsingleton_iff : Subsingleton I.Cotangent ↔ IsIdempotentElem I := by
constructor
· intro H
refine (pow_two I).symm.trans (le_antisymm (Ideal.pow_le_self two_ne_zero) ?_)
exact fun x hx => (I.toCotangent_eq_zero ⟨x, hx⟩).mp (Subsingleton.elim _ _)
· exact fun e =>
⟨fun x y =>
Quotient.inductionOn₂' x y fun x y =>
I.toCotangent_eq.mpr <| ((pow_two I).trans e).symm ▸ I.sub_mem x.prop y.prop⟩
#align ideal.cotangent_subsingleton_iff Ideal.cotangent_subsingleton_iff
def cotangentToQuotientSquare : I.Cotangent →ₗ[R] R ⧸ I ^ 2 :=
Submodule.mapQ (I • ⊤) (I ^ 2) I.subtype
(by
rw [← Submodule.map_le_iff_le_comap, Submodule.map_smul'', Submodule.map_top,
Submodule.range_subtype, smul_eq_mul, pow_two] )
#align ideal.cotangent_to_quotient_square Ideal.cotangentToQuotientSquare
theorem to_quotient_square_comp_toCotangent :
I.cotangentToQuotientSquare.comp I.toCotangent = (I ^ 2).mkQ.comp (Submodule.subtype I) :=
LinearMap.ext fun _ => rfl
#align ideal.to_quotient_square_comp_to_cotangent Ideal.to_quotient_square_comp_toCotangent
@[simp]
theorem toCotangent_to_quotient_square (x : I) :
I.cotangentToQuotientSquare (I.toCotangent x) = (I ^ 2).mkQ x := rfl
#align ideal.to_cotangent_to_quotient_square Ideal.toCotangent_to_quotient_square
def cotangentIdeal (I : Ideal R) : Ideal (R ⧸ I ^ 2) :=
Submodule.map (Quotient.mk (I ^ 2)|>.toSemilinearMap) I
#align ideal.cotangent_ideal Ideal.cotangentIdeal
theorem cotangentIdeal_square (I : Ideal R) : I.cotangentIdeal ^ 2 = ⊥ := by
rw [eq_bot_iff, pow_two I.cotangentIdeal, ← smul_eq_mul]
intro x hx
refine Submodule.smul_induction_on hx ?_ ?_
· rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩; apply (Submodule.Quotient.eq _).mpr _
rw [sub_zero, pow_two]; exact Ideal.mul_mem_mul hx hy
· intro x y hx hy; exact add_mem hx hy
#align ideal.cotangent_ideal_square Ideal.cotangentIdeal_square
set_option backward.synthInstance.canonInstances false in -- See https://github.com/leanprover-community/mathlib4/issues/12532
| Mathlib/RingTheory/Ideal/Cotangent.lean | 132 | 136 | theorem to_quotient_square_range :
LinearMap.range I.cotangentToQuotientSquare = I.cotangentIdeal.restrictScalars R := by |
trans LinearMap.range (I.cotangentToQuotientSquare.comp I.toCotangent)
· rw [LinearMap.range_comp, I.toCotangent_range, Submodule.map_top]
· rw [to_quotient_square_comp_toCotangent, LinearMap.range_comp, I.range_subtype]; ext; rfl
| 0 |
import Mathlib.MeasureTheory.Function.StronglyMeasurable.Basic
#align_import measure_theory.function.egorov from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
noncomputable section
open scoped Classical
open MeasureTheory NNReal ENNReal Topology
namespace MeasureTheory
open Set Filter TopologicalSpace
variable {α β ι : Type*} {m : MeasurableSpace α} [MetricSpace β] {μ : Measure α}
namespace Egorov
def notConvergentSeq [Preorder ι] (f : ι → α → β) (g : α → β) (n : ℕ) (j : ι) : Set α :=
⋃ (k) (_ : j ≤ k), { x | 1 / (n + 1 : ℝ) < dist (f k x) (g x) }
#align measure_theory.egorov.not_convergent_seq MeasureTheory.Egorov.notConvergentSeq
variable {n : ℕ} {i j : ι} {s : Set α} {ε : ℝ} {f : ι → α → β} {g : α → β}
theorem mem_notConvergentSeq_iff [Preorder ι] {x : α} :
x ∈ notConvergentSeq f g n j ↔ ∃ k ≥ j, 1 / (n + 1 : ℝ) < dist (f k x) (g x) := by
simp_rw [notConvergentSeq, Set.mem_iUnion, exists_prop, mem_setOf]
#align measure_theory.egorov.mem_not_convergent_seq_iff MeasureTheory.Egorov.mem_notConvergentSeq_iff
theorem notConvergentSeq_antitone [Preorder ι] : Antitone (notConvergentSeq f g n) :=
fun _ _ hjk => Set.iUnion₂_mono' fun l hl => ⟨l, le_trans hjk hl, Set.Subset.rfl⟩
#align measure_theory.egorov.not_convergent_seq_antitone MeasureTheory.Egorov.notConvergentSeq_antitone
| Mathlib/MeasureTheory/Function/Egorov.lean | 59 | 70 | theorem measure_inter_notConvergentSeq_eq_zero [SemilatticeSup ι] [Nonempty ι]
(hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) :
μ (s ∩ ⋂ j, notConvergentSeq f g n j) = 0 := by |
simp_rw [Metric.tendsto_atTop, ae_iff] at hfg
rw [← nonpos_iff_eq_zero, ← hfg]
refine measure_mono fun x => ?_
simp only [Set.mem_inter_iff, Set.mem_iInter, ge_iff_le, mem_notConvergentSeq_iff]
push_neg
rintro ⟨hmem, hx⟩
refine ⟨hmem, 1 / (n + 1 : ℝ), Nat.one_div_pos_of_nat, fun N => ?_⟩
obtain ⟨n, hn₁, hn₂⟩ := hx N
exact ⟨n, hn₁, hn₂.le⟩
| 0 |
import Mathlib.CategoryTheory.Filtered.Basic
import Mathlib.Topology.Category.TopCat.Limits.Basic
#align_import topology.category.Top.limits.konig from "leanprover-community/mathlib"@"dbdf71cee7bb20367cb7e37279c08b0c218cf967"
-- Porting note: every ML3 decl has an uppercase letter
set_option linter.uppercaseLean3 false
open CategoryTheory
open CategoryTheory.Limits
-- Porting note: changed universe order as `v` is usually passed explicitly
universe v u w
noncomputable section
namespace TopCat
section TopologicalKonig
variable {J : Type u} [SmallCategory J]
-- Porting note: generalized `F` to land in `v` not `u`
variable (F : J ⥤ TopCat.{v})
private abbrev FiniteDiagramArrow {J : Type u} [SmallCategory J] (G : Finset J) :=
Σ' (X Y : J) (_ : X ∈ G) (_ : Y ∈ G), X ⟶ Y
private abbrev FiniteDiagram (J : Type u) [SmallCategory J] :=
Σ G : Finset J, Finset (FiniteDiagramArrow G)
-- Porting note: generalized `F` to land in `v` not `u`
def partialSections {J : Type u} [SmallCategory J] (F : J ⥤ TopCat.{v}) {G : Finset J}
(H : Finset (FiniteDiagramArrow G)) : Set (∀ j, F.obj j) :=
{u | ∀ {f : FiniteDiagramArrow G} (_ : f ∈ H), F.map f.2.2.2.2 (u f.1) = u f.2.1}
#align Top.partial_sections TopCat.partialSections
theorem partialSections.nonempty [IsCofilteredOrEmpty J] [h : ∀ j : J, Nonempty (F.obj j)]
{G : Finset J} (H : Finset (FiniteDiagramArrow G)) : (partialSections F H).Nonempty := by
classical
cases isEmpty_or_nonempty J
· exact ⟨isEmptyElim, fun {j} => IsEmpty.elim' inferInstance j.1⟩
haveI : IsCofiltered J := ⟨⟩
use fun j : J =>
if hj : j ∈ G then F.map (IsCofiltered.infTo G H hj) (h (IsCofiltered.inf G H)).some
else (h _).some
rintro ⟨X, Y, hX, hY, f⟩ hf
dsimp only
rwa [dif_pos hX, dif_pos hY, ← comp_app, ← F.map_comp, @IsCofiltered.infTo_commutes _ _ _ G H]
#align Top.partial_sections.nonempty TopCat.partialSections.nonempty
theorem partialSections.directed :
Directed Superset fun G : FiniteDiagram J => partialSections F G.2 := by
classical
intro A B
let ιA : FiniteDiagramArrow A.1 → FiniteDiagramArrow (A.1 ⊔ B.1) := fun f =>
⟨f.1, f.2.1, Finset.mem_union_left _ f.2.2.1, Finset.mem_union_left _ f.2.2.2.1, f.2.2.2.2⟩
let ιB : FiniteDiagramArrow B.1 → FiniteDiagramArrow (A.1 ⊔ B.1) := fun f =>
⟨f.1, f.2.1, Finset.mem_union_right _ f.2.2.1, Finset.mem_union_right _ f.2.2.2.1, f.2.2.2.2⟩
refine ⟨⟨A.1 ⊔ B.1, A.2.image ιA ⊔ B.2.image ιB⟩, ?_, ?_⟩
· rintro u hu f hf
have : ιA f ∈ A.2.image ιA ⊔ B.2.image ιB := by
apply Finset.mem_union_left
rw [Finset.mem_image]
exact ⟨f, hf, rfl⟩
exact hu this
· rintro u hu f hf
have : ιB f ∈ A.2.image ιA ⊔ B.2.image ιB := by
apply Finset.mem_union_right
rw [Finset.mem_image]
exact ⟨f, hf, rfl⟩
exact hu this
#align Top.partial_sections.directed TopCat.partialSections.directed
theorem partialSections.closed [∀ j : J, T2Space (F.obj j)] {G : Finset J}
(H : Finset (FiniteDiagramArrow G)) : IsClosed (partialSections F H) := by
have :
partialSections F H =
⋂ (f : FiniteDiagramArrow G) (_ : f ∈ H), {u | F.map f.2.2.2.2 (u f.1) = u f.2.1} := by
ext1
simp only [Set.mem_iInter, Set.mem_setOf_eq]
rfl
rw [this]
apply isClosed_biInter
intro f _
-- Porting note: can't see through forget
have : T2Space ((forget TopCat).obj (F.obj f.snd.fst)) :=
inferInstanceAs (T2Space (F.obj f.snd.fst))
apply isClosed_eq
-- Porting note: used to be a single `continuity` that closed both goals
· exact (F.map f.snd.snd.snd.snd).continuous.comp (continuous_apply f.fst)
· continuity
#align Top.partial_sections.closed TopCat.partialSections.closed
-- Porting note: generalized from `TopCat.{u}` to `TopCat.{max v u}`
| Mathlib/Topology/Category/TopCat/Limits/Konig.lean | 130 | 146 | theorem nonempty_limitCone_of_compact_t2_cofiltered_system (F : J ⥤ TopCat.{max v u})
[IsCofilteredOrEmpty J]
[∀ j : J, Nonempty (F.obj j)] [∀ j : J, CompactSpace (F.obj j)] [∀ j : J, T2Space (F.obj j)] :
Nonempty (TopCat.limitCone F).pt := by |
classical
obtain ⟨u, hu⟩ :=
IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed (fun G => partialSections F _)
(partialSections.directed F) (fun G => partialSections.nonempty F _)
(fun G => IsClosed.isCompact (partialSections.closed F _)) fun G =>
partialSections.closed F _
use u
intro X Y f
let G : FiniteDiagram J :=
⟨{X, Y},
{⟨X, Y, by simp only [true_or_iff, eq_self_iff_true, Finset.mem_insert], by
simp only [eq_self_iff_true, or_true_iff, Finset.mem_insert, Finset.mem_singleton], f⟩}⟩
exact hu _ ⟨G, rfl⟩ (Finset.mem_singleton_self _)
| 0 |
import Mathlib.SetTheory.Cardinal.Finite
#align_import data.set.ncard from "leanprover-community/mathlib"@"74c2af38a828107941029b03839882c5c6f87a04"
namespace Set
variable {α β : Type*} {s t : Set α}
noncomputable def encard (s : Set α) : ℕ∞ := PartENat.withTopEquiv (PartENat.card s)
@[simp] theorem encard_univ_coe (s : Set α) : encard (univ : Set s) = encard s := by
rw [encard, encard, PartENat.card_congr (Equiv.Set.univ ↑s)]
theorem encard_univ (α : Type*) :
encard (univ : Set α) = PartENat.withTopEquiv (PartENat.card α) := by
rw [encard, PartENat.card_congr (Equiv.Set.univ α)]
theorem Finite.encard_eq_coe_toFinset_card (h : s.Finite) : s.encard = h.toFinset.card := by
have := h.fintype
rw [encard, PartENat.card_eq_coe_fintype_card,
PartENat.withTopEquiv_natCast, toFinite_toFinset, toFinset_card]
theorem encard_eq_coe_toFinset_card (s : Set α) [Fintype s] : encard s = s.toFinset.card := by
have h := toFinite s
rw [h.encard_eq_coe_toFinset_card, toFinite_toFinset]
theorem encard_coe_eq_coe_finsetCard (s : Finset α) : encard (s : Set α) = s.card := by
rw [Finite.encard_eq_coe_toFinset_card (Finset.finite_toSet s)]; simp
theorem Infinite.encard_eq {s : Set α} (h : s.Infinite) : s.encard = ⊤ := by
have := h.to_subtype
rw [encard, ← PartENat.withTopEquiv.symm.injective.eq_iff, Equiv.symm_apply_apply,
PartENat.withTopEquiv_symm_top, PartENat.card_eq_top_of_infinite]
@[simp] theorem encard_eq_zero : s.encard = 0 ↔ s = ∅ := by
rw [encard, ← PartENat.withTopEquiv.symm.injective.eq_iff, Equiv.symm_apply_apply,
PartENat.withTopEquiv_symm_zero, PartENat.card_eq_zero_iff_empty, isEmpty_subtype,
eq_empty_iff_forall_not_mem]
@[simp] theorem encard_empty : (∅ : Set α).encard = 0 := by
rw [encard_eq_zero]
theorem nonempty_of_encard_ne_zero (h : s.encard ≠ 0) : s.Nonempty := by
rwa [nonempty_iff_ne_empty, Ne, ← encard_eq_zero]
theorem encard_ne_zero : s.encard ≠ 0 ↔ s.Nonempty := by
rw [ne_eq, encard_eq_zero, nonempty_iff_ne_empty]
@[simp] theorem encard_pos : 0 < s.encard ↔ s.Nonempty := by
rw [pos_iff_ne_zero, encard_ne_zero]
@[simp] theorem encard_singleton (e : α) : ({e} : Set α).encard = 1 := by
rw [encard, ← PartENat.withTopEquiv.symm.injective.eq_iff, Equiv.symm_apply_apply,
PartENat.card_eq_coe_fintype_card, Fintype.card_ofSubsingleton, Nat.cast_one]; rfl
| Mathlib/Data/Set/Card.lean | 111 | 114 | theorem encard_union_eq (h : Disjoint s t) : (s ∪ t).encard = s.encard + t.encard := by |
classical
have e := (Equiv.Set.union (by rwa [subset_empty_iff, ← disjoint_iff_inter_eq_empty])).symm
simp [encard, ← PartENat.card_congr e, PartENat.card_sum, PartENat.withTopEquiv]
| 0 |
import Mathlib.Analysis.Convex.Jensen
import Mathlib.Analysis.Convex.SpecificFunctions.Basic
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
import Mathlib.Data.Real.ConjExponents
#align_import analysis.mean_inequalities from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
universe u v
open scoped Classical
open Finset NNReal ENNReal
set_option linter.uppercaseLean3 false
noncomputable section
variable {ι : Type u} (s : Finset ι)
section GeomMeanLEArithMean
namespace Real
theorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :
∏ i ∈ s, z i ^ w i ≤ ∑ i ∈ s, w i * z i := by
-- If some number `z i` equals zero and has non-zero weight, then LHS is 0 and RHS is nonnegative.
by_cases A : ∃ i ∈ s, z i = 0 ∧ w i ≠ 0
· rcases A with ⟨i, his, hzi, hwi⟩
rw [prod_eq_zero his]
· exact sum_nonneg fun j hj => mul_nonneg (hw j hj) (hz j hj)
· rw [hzi]
exact zero_rpow hwi
-- If all numbers `z i` with non-zero weight are positive, then we apply Jensen's inequality
-- for `exp` and numbers `log (z i)` with weights `w i`.
· simp only [not_exists, not_and, Ne, Classical.not_not] at A
have := convexOn_exp.map_sum_le hw hw' fun i _ => Set.mem_univ <| log (z i)
simp only [exp_sum, (· ∘ ·), smul_eq_mul, mul_comm (w _) (log _)] at this
convert this using 1 <;> [apply prod_congr rfl;apply sum_congr rfl] <;> intro i hi
· cases' eq_or_lt_of_le (hz i hi) with hz hz
· simp [A i hi hz.symm]
· exact rpow_def_of_pos hz _
· cases' eq_or_lt_of_le (hz i hi) with hz hz
· simp [A i hi hz.symm]
· rw [exp_log hz]
#align real.geom_mean_le_arith_mean_weighted Real.geom_mean_le_arith_mean_weighted
theorem geom_mean_le_arith_mean {ι : Type*} (s : Finset ι) (w : ι → ℝ) (z : ι → ℝ)
(hw : ∀ i ∈ s, 0 ≤ w i) (hw' : 0 < ∑ i ∈ s, w i) (hz : ∀ i ∈ s, 0 ≤ z i) :
(∏ i ∈ s, z i ^ w i) ^ (∑ i ∈ s, w i)⁻¹ ≤ (∑ i ∈ s, w i * z i) / (∑ i ∈ s, w i) := by
convert geom_mean_le_arith_mean_weighted s (fun i => (w i) / ∑ i ∈ s, w i) z ?_ ?_ hz using 2
· rw [← finset_prod_rpow _ _ (fun i hi => rpow_nonneg (hz _ hi) _) _]
refine Finset.prod_congr rfl (fun _ ih => ?_)
rw [div_eq_mul_inv, rpow_mul (hz _ ih)]
· simp_rw [div_eq_mul_inv, mul_assoc, mul_comm, ← mul_assoc, ← Finset.sum_mul, mul_comm]
· exact fun _ hi => div_nonneg (hw _ hi) (le_of_lt hw')
· simp_rw [div_eq_mul_inv, ← Finset.sum_mul]
exact mul_inv_cancel (by linarith)
theorem geom_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) :
∏ i ∈ s, z i ^ w i = x :=
calc
∏ i ∈ s, z i ^ w i = ∏ i ∈ s, x ^ w i := by
refine prod_congr rfl fun i hi => ?_
rcases eq_or_ne (w i) 0 with h₀ | h₀
· rw [h₀, rpow_zero, rpow_zero]
· rw [hx i hi h₀]
_ = x := by
rw [← rpow_sum_of_nonneg _ hw, hw', rpow_one]
have : (∑ i ∈ s, w i) ≠ 0 := by
rw [hw']
exact one_ne_zero
obtain ⟨i, his, hi⟩ := exists_ne_zero_of_sum_ne_zero this
rw [← hx i his hi]
exact hz i his
#align real.geom_mean_weighted_of_constant Real.geom_mean_weighted_of_constant
theorem arith_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw' : ∑ i ∈ s, w i = 1)
(hx : ∀ i ∈ s, w i ≠ 0 → z i = x) : ∑ i ∈ s, w i * z i = x :=
calc
∑ i ∈ s, w i * z i = ∑ i ∈ s, w i * x := by
refine sum_congr rfl fun i hi => ?_
rcases eq_or_ne (w i) 0 with hwi | hwi
· rw [hwi, zero_mul, zero_mul]
· rw [hx i hi hwi]
_ = x := by rw [← sum_mul, hw', one_mul]
#align real.arith_mean_weighted_of_constant Real.arith_mean_weighted_of_constant
| Mathlib/Analysis/MeanInequalities.lean | 180 | 183 | theorem geom_mean_eq_arith_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) :
∏ i ∈ s, z i ^ w i = ∑ i ∈ s, w i * z i := by |
rw [geom_mean_weighted_of_constant, arith_mean_weighted_of_constant] <;> assumption
| 0 |
import Mathlib.Algebra.Lie.Abelian
import Mathlib.Algebra.Lie.Solvable
import Mathlib.LinearAlgebra.Dual
#align_import algebra.lie.character from "leanprover-community/mathlib"@"132328c4dd48da87adca5d408ca54f315282b719"
universe u v w w₁
namespace LieAlgebra
variable (R : Type u) (L : Type v) [CommRing R] [LieRing L] [LieAlgebra R L]
abbrev LieCharacter :=
L →ₗ⁅R⁆ R
#align lie_algebra.lie_character LieAlgebra.LieCharacter
variable {R L}
-- @[simp] -- Porting note: simp normal form is the LHS of `lieCharacter_apply_lie'`
theorem lieCharacter_apply_lie (χ : LieCharacter R L) (x y : L) : χ ⁅x, y⁆ = 0 := by
rw [LieHom.map_lie, LieRing.of_associative_ring_bracket, mul_comm, sub_self]
#align lie_algebra.lie_character_apply_lie LieAlgebra.lieCharacter_apply_lie
@[simp]
theorem lieCharacter_apply_lie' (χ : LieCharacter R L) (x y : L) : ⁅χ x, χ y⁆ = 0 := by
rw [LieRing.of_associative_ring_bracket, mul_comm, sub_self]
| Mathlib/Algebra/Lie/Character.lean | 52 | 60 | theorem lieCharacter_apply_of_mem_derived (χ : LieCharacter R L) {x : L}
(h : x ∈ derivedSeries R L 1) : χ x = 0 := by |
rw [derivedSeries_def, derivedSeriesOfIdeal_succ, derivedSeriesOfIdeal_zero, ←
LieSubmodule.mem_coeSubmodule, LieSubmodule.lieIdeal_oper_eq_linear_span] at h
refine Submodule.span_induction h ?_ ?_ ?_ ?_
· rintro y ⟨⟨z, hz⟩, ⟨⟨w, hw⟩, rfl⟩⟩; apply lieCharacter_apply_lie
· exact χ.map_zero
· intro y z hy hz; rw [LieHom.map_add, hy, hz, add_zero]
· intro t y hy; rw [LieHom.map_smul, hy, smul_zero]
| 0 |
import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.Deriv.Slope
import Mathlib.Analysis.NormedSpace.FiniteDimension
import Mathlib.MeasureTheory.Constructions.BorelSpace.ContinuousLinearMap
import Mathlib.MeasureTheory.Function.StronglyMeasurable.Basic
#align_import analysis.calculus.fderiv_measurable from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
set_option linter.uppercaseLean3 false -- A B D
noncomputable section
open Set Metric Asymptotics Filter ContinuousLinearMap MeasureTheory TopologicalSpace
open scoped Topology
section fderiv
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {f : E → F} (K : Set (E →L[𝕜] F))
namespace FDerivMeasurableAux
def A (f : E → F) (L : E →L[𝕜] F) (r ε : ℝ) : Set E :=
{ x | ∃ r' ∈ Ioc (r / 2) r, ∀ y ∈ ball x r', ∀ z ∈ ball x r', ‖f z - f y - L (z - y)‖ < ε * r }
#align fderiv_measurable_aux.A FDerivMeasurableAux.A
def B (f : E → F) (K : Set (E →L[𝕜] F)) (r s ε : ℝ) : Set E :=
⋃ L ∈ K, A f L r ε ∩ A f L s ε
#align fderiv_measurable_aux.B FDerivMeasurableAux.B
def D (f : E → F) (K : Set (E →L[𝕜] F)) : Set E :=
⋂ e : ℕ, ⋃ n : ℕ, ⋂ (p ≥ n) (q ≥ n), B f K ((1 / 2) ^ p) ((1 / 2) ^ q) ((1 / 2) ^ e)
#align fderiv_measurable_aux.D FDerivMeasurableAux.D
theorem isOpen_A (L : E →L[𝕜] F) (r ε : ℝ) : IsOpen (A f L r ε) := by
rw [Metric.isOpen_iff]
rintro x ⟨r', r'_mem, hr'⟩
obtain ⟨s, s_gt, s_lt⟩ : ∃ s : ℝ, r / 2 < s ∧ s < r' := exists_between r'_mem.1
have : s ∈ Ioc (r / 2) r := ⟨s_gt, le_of_lt (s_lt.trans_le r'_mem.2)⟩
refine ⟨r' - s, by linarith, fun x' hx' => ⟨s, this, ?_⟩⟩
have B : ball x' s ⊆ ball x r' := ball_subset (le_of_lt hx')
intro y hy z hz
exact hr' y (B hy) z (B hz)
#align fderiv_measurable_aux.is_open_A FDerivMeasurableAux.isOpen_A
theorem isOpen_B {K : Set (E →L[𝕜] F)} {r s ε : ℝ} : IsOpen (B f K r s ε) := by
simp [B, isOpen_biUnion, IsOpen.inter, isOpen_A]
#align fderiv_measurable_aux.is_open_B FDerivMeasurableAux.isOpen_B
| Mathlib/Analysis/Calculus/FDeriv/Measurable.lean | 148 | 151 | theorem A_mono (L : E →L[𝕜] F) (r : ℝ) {ε δ : ℝ} (h : ε ≤ δ) : A f L r ε ⊆ A f L r δ := by |
rintro x ⟨r', r'r, hr'⟩
refine ⟨r', r'r, fun y hy z hz => (hr' y hy z hz).trans_le (mul_le_mul_of_nonneg_right h ?_)⟩
linarith [mem_ball.1 hy, r'r.2, @dist_nonneg _ _ y x]
| 0 |
import Mathlib.Algebra.Order.Monoid.Unbundled.MinMax
import Mathlib.Algebra.Order.Monoid.WithTop
import Mathlib.Data.Finset.Image
import Mathlib.Data.Multiset.Fold
#align_import data.finset.fold from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
-- TODO:
-- assert_not_exists OrderedCommMonoid
assert_not_exists MonoidWithZero
namespace Finset
open Multiset
variable {α β γ : Type*}
section Fold
variable (op : β → β → β) [hc : Std.Commutative op] [ha : Std.Associative op]
local notation a " * " b => op a b
def fold (b : β) (f : α → β) (s : Finset α) : β :=
(s.1.map f).fold op b
#align finset.fold Finset.fold
variable {op} {f : α → β} {b : β} {s : Finset α} {a : α}
@[simp]
theorem fold_empty : (∅ : Finset α).fold op b f = b :=
rfl
#align finset.fold_empty Finset.fold_empty
@[simp]
theorem fold_cons (h : a ∉ s) : (cons a s h).fold op b f = f a * s.fold op b f := by
dsimp only [fold]
rw [cons_val, Multiset.map_cons, fold_cons_left]
#align finset.fold_cons Finset.fold_cons
@[simp]
theorem fold_insert [DecidableEq α] (h : a ∉ s) :
(insert a s).fold op b f = f a * s.fold op b f := by
unfold fold
rw [insert_val, ndinsert_of_not_mem h, Multiset.map_cons, fold_cons_left]
#align finset.fold_insert Finset.fold_insert
@[simp]
theorem fold_singleton : ({a} : Finset α).fold op b f = f a * b :=
rfl
#align finset.fold_singleton Finset.fold_singleton
@[simp]
theorem fold_map {g : γ ↪ α} {s : Finset γ} : (s.map g).fold op b f = s.fold op b (f ∘ g) := by
simp only [fold, map, Multiset.map_map]
#align finset.fold_map Finset.fold_map
@[simp]
theorem fold_image [DecidableEq α] {g : γ → α} {s : Finset γ}
(H : ∀ x ∈ s, ∀ y ∈ s, g x = g y → x = y) : (s.image g).fold op b f = s.fold op b (f ∘ g) := by
simp only [fold, image_val_of_injOn H, Multiset.map_map]
#align finset.fold_image Finset.fold_image
@[congr]
theorem fold_congr {g : α → β} (H : ∀ x ∈ s, f x = g x) : s.fold op b f = s.fold op b g := by
rw [fold, fold, map_congr rfl H]
#align finset.fold_congr Finset.fold_congr
theorem fold_op_distrib {f g : α → β} {b₁ b₂ : β} :
(s.fold op (b₁ * b₂) fun x => f x * g x) = s.fold op b₁ f * s.fold op b₂ g := by
simp only [fold, fold_distrib]
#align finset.fold_op_distrib Finset.fold_op_distrib
theorem fold_const [hd : Decidable (s = ∅)] (c : β) (h : op c (op b c) = op b c) :
Finset.fold op b (fun _ => c) s = if s = ∅ then b else op b c := by
classical
induction' s using Finset.induction_on with x s hx IH generalizing hd
· simp
· simp only [Finset.fold_insert hx, IH, if_false, Finset.insert_ne_empty]
split_ifs
· rw [hc.comm]
· exact h
#align finset.fold_const Finset.fold_const
theorem fold_hom {op' : γ → γ → γ} [Std.Commutative op'] [Std.Associative op'] {m : β → γ}
(hm : ∀ x y, m (op x y) = op' (m x) (m y)) :
(s.fold op' (m b) fun x => m (f x)) = m (s.fold op b f) := by
rw [fold, fold, ← Multiset.fold_hom op hm, Multiset.map_map]
simp only [Function.comp_apply]
#align finset.fold_hom Finset.fold_hom
theorem fold_disjUnion {s₁ s₂ : Finset α} {b₁ b₂ : β} (h) :
(s₁.disjUnion s₂ h).fold op (b₁ * b₂) f = s₁.fold op b₁ f * s₂.fold op b₂ f :=
(congr_arg _ <| Multiset.map_add _ _ _).trans (Multiset.fold_add _ _ _ _ _)
#align finset.fold_disj_union Finset.fold_disjUnion
theorem fold_disjiUnion {ι : Type*} {s : Finset ι} {t : ι → Finset α} {b : ι → β} {b₀ : β} (h) :
(s.disjiUnion t h).fold op (s.fold op b₀ b) f = s.fold op b₀ fun i => (t i).fold op (b i) f :=
(congr_arg _ <| Multiset.map_bind _ _ _).trans (Multiset.fold_bind _ _ _ _ _)
#align finset.fold_disj_Union Finset.fold_disjiUnion
| Mathlib/Data/Finset/Fold.lean | 116 | 120 | theorem fold_union_inter [DecidableEq α] {s₁ s₂ : Finset α} {b₁ b₂ : β} :
((s₁ ∪ s₂).fold op b₁ f * (s₁ ∩ s₂).fold op b₂ f) = s₁.fold op b₂ f * s₂.fold op b₁ f := by |
unfold fold
rw [← fold_add op, ← Multiset.map_add, union_val, inter_val, union_add_inter, Multiset.map_add,
hc.comm, fold_add]
| 0 |
import Mathlib.CategoryTheory.Adjunction.FullyFaithful
import Mathlib.CategoryTheory.Conj
import Mathlib.CategoryTheory.Functor.ReflectsIso
#align_import category_theory.adjunction.reflective from "leanprover-community/mathlib"@"239d882c4fb58361ee8b3b39fb2091320edef10a"
universe v₁ v₂ v₃ u₁ u₂ u₃
noncomputable section
namespace CategoryTheory
open Category Adjunction
variable {C : Type u₁} {D : Type u₂} {E : Type u₃}
variable [Category.{v₁} C] [Category.{v₂} D] [Category.{v₃} E]
class Reflective (R : D ⥤ C) extends R.Full, R.Faithful where
L : C ⥤ D
adj : L ⊣ R
#align category_theory.reflective CategoryTheory.Reflective
variable (i : D ⥤ C)
def reflector [Reflective i] : C ⥤ D := Reflective.L (R := i)
def reflectorAdjunction [Reflective i] : reflector i ⊣ i := Reflective.adj
instance [Reflective i] : i.IsRightAdjoint := ⟨_, ⟨reflectorAdjunction i⟩⟩
instance [Reflective i] : (reflector i).IsLeftAdjoint := ⟨_, ⟨reflectorAdjunction i⟩⟩
def Functor.fullyFaithfulOfReflective [Reflective i] : i.FullyFaithful :=
(reflectorAdjunction i).fullyFaithfulROfIsIsoCounit
-- TODO: This holds more generally for idempotent adjunctions, not just reflective adjunctions.
theorem unit_obj_eq_map_unit [Reflective i] (X : C) :
(reflectorAdjunction i).unit.app (i.obj ((reflector i).obj X)) =
i.map ((reflector i).map ((reflectorAdjunction i).unit.app X)) := by
rw [← cancel_mono (i.map ((reflectorAdjunction i).counit.app ((reflector i).obj X))),
← i.map_comp]
simp
#align category_theory.unit_obj_eq_map_unit CategoryTheory.unit_obj_eq_map_unit
example [Reflective i] {B : D} : IsIso ((reflectorAdjunction i).unit.app (i.obj B)) :=
inferInstance
variable {i}
| Mathlib/CategoryTheory/Adjunction/Reflective.lean | 87 | 89 | theorem Functor.essImage.unit_isIso [Reflective i] {A : C} (h : A ∈ i.essImage) :
IsIso ((reflectorAdjunction i).unit.app A) := by |
rwa [isIso_unit_app_iff_mem_essImage]
| 0 |
import Mathlib.RingTheory.Finiteness
import Mathlib.Logic.Equiv.TransferInstance
universe u v w
open Function
variable (R : Type u) [Semiring R]
@[mk_iff]
class OrzechProperty : Prop where
injective_of_surjective_of_submodule' : ∀ {M : Type u} [AddCommMonoid M] [Module R M]
[Module.Finite R M] {N : Submodule R M} (f : N →ₗ[R] M), Surjective f → Injective f
namespace OrzechProperty
variable {R}
variable [OrzechProperty R] {M : Type v} [AddCommMonoid M] [Module R M] [Module.Finite R M]
| Mathlib/RingTheory/OrzechProperty.lean | 69 | 82 | theorem injective_of_surjective_of_injective
{N : Type w} [AddCommMonoid N] [Module R N]
(i f : N →ₗ[R] M) (hi : Injective i) (hf : Surjective f) : Injective f := by |
obtain ⟨n, g, hg⟩ := Module.Finite.exists_fin' R M
haveI := small_of_surjective hg
letI := Equiv.addCommMonoid (equivShrink M).symm
letI := Equiv.module R (equivShrink M).symm
let j : Shrink.{u} M ≃ₗ[R] M := Equiv.linearEquiv R (equivShrink M).symm
haveI := Module.Finite.equiv j.symm
let i' := j.symm.toLinearMap ∘ₗ i
replace hi : Injective i' := by simpa [i'] using hi
let f' := j.symm.toLinearMap ∘ₗ f ∘ₗ (LinearEquiv.ofInjective i' hi).symm.toLinearMap
replace hf : Surjective f' := by simpa [f'] using hf
simpa [f'] using injective_of_surjective_of_submodule' f' hf
| 0 |
import Mathlib.Algebra.Polynomial.Module.Basic
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
import Mathlib.Analysis.Calculus.MeanValue
#align_import analysis.calculus.taylor from "leanprover-community/mathlib"@"3a69562db5a458db8322b190ec8d9a8bbd8a5b14"
open scoped Interval Topology Nat
open Set
variable {𝕜 E F : Type*}
variable [NormedAddCommGroup E] [NormedSpace ℝ E]
noncomputable def taylorCoeffWithin (f : ℝ → E) (k : ℕ) (s : Set ℝ) (x₀ : ℝ) : E :=
(k ! : ℝ)⁻¹ • iteratedDerivWithin k f s x₀
#align taylor_coeff_within taylorCoeffWithin
noncomputable def taylorWithin (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) : PolynomialModule ℝ E :=
(Finset.range (n + 1)).sum fun k =>
PolynomialModule.comp (Polynomial.X - Polynomial.C x₀)
(PolynomialModule.single ℝ k (taylorCoeffWithin f k s x₀))
#align taylor_within taylorWithin
noncomputable def taylorWithinEval (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) : E :=
PolynomialModule.eval x (taylorWithin f n s x₀)
#align taylor_within_eval taylorWithinEval
theorem taylorWithin_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) :
taylorWithin f (n + 1) s x₀ = taylorWithin f n s x₀ +
PolynomialModule.comp (Polynomial.X - Polynomial.C x₀)
(PolynomialModule.single ℝ (n + 1) (taylorCoeffWithin f (n + 1) s x₀)) := by
dsimp only [taylorWithin]
rw [Finset.sum_range_succ]
#align taylor_within_succ taylorWithin_succ
@[simp]
theorem taylorWithinEval_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) :
taylorWithinEval f (n + 1) s x₀ x = taylorWithinEval f n s x₀ x +
(((n + 1 : ℝ) * n !)⁻¹ * (x - x₀) ^ (n + 1)) • iteratedDerivWithin (n + 1) f s x₀ := by
simp_rw [taylorWithinEval, taylorWithin_succ, LinearMap.map_add, PolynomialModule.comp_eval]
congr
simp only [Polynomial.eval_sub, Polynomial.eval_X, Polynomial.eval_C,
PolynomialModule.eval_single, mul_inv_rev]
dsimp only [taylorCoeffWithin]
rw [← mul_smul, mul_comm, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one,
mul_inv_rev]
#align taylor_within_eval_succ taylorWithinEval_succ
@[simp]
theorem taylor_within_zero_eval (f : ℝ → E) (s : Set ℝ) (x₀ x : ℝ) :
taylorWithinEval f 0 s x₀ x = f x₀ := by
dsimp only [taylorWithinEval]
dsimp only [taylorWithin]
dsimp only [taylorCoeffWithin]
simp
#align taylor_within_zero_eval taylor_within_zero_eval
@[simp]
theorem taylorWithinEval_self (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) :
taylorWithinEval f n s x₀ x₀ = f x₀ := by
induction' n with k hk
· exact taylor_within_zero_eval _ _ _ _
simp [hk]
#align taylor_within_eval_self taylorWithinEval_self
theorem taylor_within_apply (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) :
taylorWithinEval f n s x₀ x =
∑ k ∈ Finset.range (n + 1), ((k ! : ℝ)⁻¹ * (x - x₀) ^ k) • iteratedDerivWithin k f s x₀ := by
induction' n with k hk
· simp
rw [taylorWithinEval_succ, Finset.sum_range_succ, hk]
simp [Nat.factorial]
#align taylor_within_apply taylor_within_apply
theorem continuousOn_taylorWithinEval {f : ℝ → E} {x : ℝ} {n : ℕ} {s : Set ℝ}
(hs : UniqueDiffOn ℝ s) (hf : ContDiffOn ℝ n f s) :
ContinuousOn (fun t => taylorWithinEval f n s t x) s := by
simp_rw [taylor_within_apply]
refine continuousOn_finset_sum (Finset.range (n + 1)) fun i hi => ?_
refine (continuousOn_const.mul ((continuousOn_const.sub continuousOn_id).pow _)).smul ?_
rw [contDiffOn_iff_continuousOn_differentiableOn_deriv hs] at hf
cases' hf with hf_left
specialize hf_left i
simp only [Finset.mem_range] at hi
refine hf_left ?_
simp only [WithTop.coe_le_coe, Nat.cast_le, Nat.lt_succ_iff.mp hi]
#align continuous_on_taylor_within_eval continuousOn_taylorWithinEval
| Mathlib/Analysis/Calculus/Taylor.lean | 141 | 146 | theorem monomial_has_deriv_aux (t x : ℝ) (n : ℕ) :
HasDerivAt (fun y => (x - y) ^ (n + 1)) (-(n + 1) * (x - t) ^ n) t := by |
simp_rw [sub_eq_neg_add]
rw [← neg_one_mul, mul_comm (-1 : ℝ), mul_assoc, mul_comm (-1 : ℝ), ← mul_assoc]
convert HasDerivAt.pow (n + 1) ((hasDerivAt_id t).neg.add_const x)
simp only [Nat.cast_add, Nat.cast_one]
| 0 |
import Mathlib.NumberTheory.BernoulliPolynomials
import Mathlib.MeasureTheory.Integral.IntervalIntegral
import Mathlib.Analysis.Calculus.Deriv.Polynomial
import Mathlib.Analysis.Fourier.AddCircle
import Mathlib.Analysis.PSeries
#align_import number_theory.zeta_values from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
noncomputable section
open scoped Nat Real Interval
open Complex MeasureTheory Set intervalIntegral
local notation "𝕌" => UnitAddCircle
section BernoulliFunProps
def bernoulliFun (k : ℕ) (x : ℝ) : ℝ :=
(Polynomial.map (algebraMap ℚ ℝ) (Polynomial.bernoulli k)).eval x
#align bernoulli_fun bernoulliFun
theorem bernoulliFun_eval_zero (k : ℕ) : bernoulliFun k 0 = bernoulli k := by
rw [bernoulliFun, Polynomial.eval_zero_map, Polynomial.bernoulli_eval_zero, eq_ratCast]
#align bernoulli_fun_eval_zero bernoulliFun_eval_zero
theorem bernoulliFun_endpoints_eq_of_ne_one {k : ℕ} (hk : k ≠ 1) :
bernoulliFun k 1 = bernoulliFun k 0 := by
rw [bernoulliFun_eval_zero, bernoulliFun, Polynomial.eval_one_map, Polynomial.bernoulli_eval_one,
bernoulli_eq_bernoulli'_of_ne_one hk, eq_ratCast]
#align bernoulli_fun_endpoints_eq_of_ne_one bernoulliFun_endpoints_eq_of_ne_one
theorem bernoulliFun_eval_one (k : ℕ) : bernoulliFun k 1 = bernoulliFun k 0 + ite (k = 1) 1 0 := by
rw [bernoulliFun, bernoulliFun_eval_zero, Polynomial.eval_one_map, Polynomial.bernoulli_eval_one]
split_ifs with h
· rw [h, bernoulli_one, bernoulli'_one, eq_ratCast]
push_cast; ring
· rw [bernoulli_eq_bernoulli'_of_ne_one h, add_zero, eq_ratCast]
#align bernoulli_fun_eval_one bernoulliFun_eval_one
theorem hasDerivAt_bernoulliFun (k : ℕ) (x : ℝ) :
HasDerivAt (bernoulliFun k) (k * bernoulliFun (k - 1) x) x := by
convert ((Polynomial.bernoulli k).map <| algebraMap ℚ ℝ).hasDerivAt x using 1
simp only [bernoulliFun, Polynomial.derivative_map, Polynomial.derivative_bernoulli k,
Polynomial.map_mul, Polynomial.map_natCast, Polynomial.eval_mul, Polynomial.eval_natCast]
#align has_deriv_at_bernoulli_fun hasDerivAt_bernoulliFun
theorem antideriv_bernoulliFun (k : ℕ) (x : ℝ) :
HasDerivAt (fun x => bernoulliFun (k + 1) x / (k + 1)) (bernoulliFun k x) x := by
convert (hasDerivAt_bernoulliFun (k + 1) x).div_const _ using 1
field_simp [Nat.cast_add_one_ne_zero k]
#align antideriv_bernoulli_fun antideriv_bernoulliFun
| Mathlib/NumberTheory/ZetaValues.lean | 80 | 87 | theorem integral_bernoulliFun_eq_zero {k : ℕ} (hk : k ≠ 0) :
∫ x : ℝ in (0)..1, bernoulliFun k x = 0 := by |
rw [integral_eq_sub_of_hasDerivAt (fun x _ => antideriv_bernoulliFun k x)
((Polynomial.continuous _).intervalIntegrable _ _)]
rw [bernoulliFun_eval_one]
split_ifs with h
· exfalso; exact hk (Nat.succ_inj'.mp h)
· simp
| 0 |
import Mathlib.Analysis.Calculus.FDeriv.Equiv
import Mathlib.Analysis.Calculus.FormalMultilinearSeries
#align_import analysis.calculus.cont_diff_def from "leanprover-community/mathlib"@"3a69562db5a458db8322b190ec8d9a8bbd8a5b14"
noncomputable section
open scoped Classical
open NNReal Topology Filter
local notation "∞" => (⊤ : ℕ∞)
open Set Fin Filter Function
universe u uE uF uG uX
variable {𝕜 : Type u} [NontriviallyNormedField 𝕜] {E : Type uE} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {F : Type uF} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type uG}
[NormedAddCommGroup G] [NormedSpace 𝕜 G] {X : Type uX} [NormedAddCommGroup X] [NormedSpace 𝕜 X]
{s s₁ t u : Set E} {f f₁ : E → F} {g : F → G} {x x₀ : E} {c : F} {m n : ℕ∞}
{p : E → FormalMultilinearSeries 𝕜 E F}
structure HasFTaylorSeriesUpToOn (n : ℕ∞) (f : E → F) (p : E → FormalMultilinearSeries 𝕜 E F)
(s : Set E) : Prop where
zero_eq : ∀ x ∈ s, (p x 0).uncurry0 = f x
protected fderivWithin : ∀ m : ℕ, (m : ℕ∞) < n → ∀ x ∈ s,
HasFDerivWithinAt (p · m) (p x m.succ).curryLeft s x
cont : ∀ m : ℕ, (m : ℕ∞) ≤ n → ContinuousOn (p · m) s
#align has_ftaylor_series_up_to_on HasFTaylorSeriesUpToOn
theorem HasFTaylorSeriesUpToOn.zero_eq' (h : HasFTaylorSeriesUpToOn n f p s) {x : E} (hx : x ∈ s) :
p x 0 = (continuousMultilinearCurryFin0 𝕜 E F).symm (f x) := by
rw [← h.zero_eq x hx]
exact (p x 0).uncurry0_curry0.symm
#align has_ftaylor_series_up_to_on.zero_eq' HasFTaylorSeriesUpToOn.zero_eq'
| Mathlib/Analysis/Calculus/ContDiff/Defs.lean | 204 | 208 | theorem HasFTaylorSeriesUpToOn.congr (h : HasFTaylorSeriesUpToOn n f p s)
(h₁ : ∀ x ∈ s, f₁ x = f x) : HasFTaylorSeriesUpToOn n f₁ p s := by |
refine ⟨fun x hx => ?_, h.fderivWithin, h.cont⟩
rw [h₁ x hx]
exact h.zero_eq x hx
| 0 |
import Mathlib.NumberTheory.Liouville.Basic
#align_import number_theory.liouville.liouville_number from "leanprover-community/mathlib"@"04e80bb7e8510958cd9aacd32fe2dc147af0b9f1"
noncomputable section
open scoped Nat
open Real Finset
def liouvilleNumber (m : ℝ) : ℝ :=
∑' i : ℕ, 1 / m ^ i !
#align liouville_number liouvilleNumber
namespace LiouvilleNumber
def partialSum (m : ℝ) (k : ℕ) : ℝ :=
∑ i ∈ range (k + 1), 1 / m ^ i !
#align liouville_number.partial_sum LiouvilleNumber.partialSum
def remainder (m : ℝ) (k : ℕ) : ℝ :=
∑' i, 1 / m ^ (i + (k + 1))!
#align liouville_number.remainder LiouvilleNumber.remainder
protected theorem summable {m : ℝ} (hm : 1 < m) : Summable fun i : ℕ => 1 / m ^ i ! :=
summable_one_div_pow_of_le hm Nat.self_le_factorial
#align liouville_number.summable LiouvilleNumber.summable
theorem remainder_summable {m : ℝ} (hm : 1 < m) (k : ℕ) :
Summable fun i : ℕ => 1 / m ^ (i + (k + 1))! := by
convert (summable_nat_add_iff (k + 1)).2 (LiouvilleNumber.summable hm)
#align liouville_number.remainder_summable LiouvilleNumber.remainder_summable
theorem remainder_pos {m : ℝ} (hm : 1 < m) (k : ℕ) : 0 < remainder m k :=
tsum_pos (remainder_summable hm k) (fun _ => by positivity) 0 (by positivity)
#align liouville_number.remainder_pos LiouvilleNumber.remainder_pos
theorem partialSum_succ (m : ℝ) (n : ℕ) :
partialSum m (n + 1) = partialSum m n + 1 / m ^ (n + 1)! :=
sum_range_succ _ _
#align liouville_number.partial_sum_succ LiouvilleNumber.partialSum_succ
theorem partialSum_add_remainder {m : ℝ} (hm : 1 < m) (k : ℕ) :
partialSum m k + remainder m k = liouvilleNumber m :=
sum_add_tsum_nat_add _ (LiouvilleNumber.summable hm)
#align liouville_number.partial_sum_add_remainder LiouvilleNumber.partialSum_add_remainder
| Mathlib/NumberTheory/Liouville/LiouvilleNumber.lean | 110 | 134 | theorem remainder_lt' (n : ℕ) {m : ℝ} (m1 : 1 < m) :
remainder m n < (1 - 1 / m)⁻¹ * (1 / m ^ (n + 1)!) :=
-- two useful inequalities
have m0 : 0 < m := zero_lt_one.trans m1
have mi : 1 / m < 1 := (div_lt_one m0).mpr m1
-- to show the strict inequality between these series, we prove that:
calc
(∑' i, 1 / m ^ (i + (n + 1))!) < ∑' i, 1 / m ^ (i + (n + 1)!) :=
-- 1. the second series dominates the first
tsum_lt_tsum (fun b => one_div_pow_le_one_div_pow_of_le m1.le
(b.add_factorial_succ_le_factorial_add_succ n))
-- 2. the term with index `i = 2` of the first series is strictly smaller than
-- the corresponding term of the second series
(one_div_pow_strictAnti m1 (n.add_factorial_succ_lt_factorial_add_succ (i := 2) le_rfl))
-- 3. the first series is summable
(remainder_summable m1 n)
-- 4. the second series is summable, since its terms grow quickly
(summable_one_div_pow_of_le m1 fun j => le_self_add)
-- split the sum in the exponent and massage
_ = ∑' i : ℕ, (1 / m) ^ i * (1 / m ^ (n + 1)!) := by |
simp only [pow_add, one_div, mul_inv, inv_pow]
-- factor the constant `(1 / m ^ (n + 1)!)` out of the series
_ = (∑' i, (1 / m) ^ i) * (1 / m ^ (n + 1)!) := tsum_mul_right
-- the series is the geometric series
_ = (1 - 1 / m)⁻¹ * (1 / m ^ (n + 1)!) := by rw [tsum_geometric_of_lt_one (by positivity) mi]
| 0 |
import Mathlib.LinearAlgebra.Basis
import Mathlib.LinearAlgebra.BilinearMap
#align_import linear_algebra.basis.bilinear from "leanprover-community/mathlib"@"87c54600fe3cdc7d32ff5b50873ac724d86aef8d"
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ₗ)
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
| Mathlib/LinearAlgebra/Basis/Bilinear.lean | 44 | 49 | 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ₛₗ]
| 0 |
import Mathlib.Analysis.SpecialFunctions.Complex.Arg
import Mathlib.Analysis.SpecialFunctions.Log.Basic
#align_import analysis.special_functions.complex.log from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
noncomputable section
namespace Complex
open Set Filter Bornology
open scoped Real Topology ComplexConjugate
-- Porting note: @[pp_nodot] does not exist in mathlib4
noncomputable def log (x : ℂ) : ℂ :=
x.abs.log + arg x * I
#align complex.log Complex.log
theorem log_re (x : ℂ) : x.log.re = x.abs.log := by simp [log]
#align complex.log_re Complex.log_re
theorem log_im (x : ℂ) : x.log.im = x.arg := by simp [log]
#align complex.log_im Complex.log_im
theorem neg_pi_lt_log_im (x : ℂ) : -π < (log x).im := by simp only [log_im, neg_pi_lt_arg]
#align complex.neg_pi_lt_log_im Complex.neg_pi_lt_log_im
theorem log_im_le_pi (x : ℂ) : (log x).im ≤ π := by simp only [log_im, arg_le_pi]
#align complex.log_im_le_pi Complex.log_im_le_pi
theorem exp_log {x : ℂ} (hx : x ≠ 0) : exp (log x) = x := by
rw [log, exp_add_mul_I, ← ofReal_sin, sin_arg, ← ofReal_cos, cos_arg hx, ← ofReal_exp,
Real.exp_log (abs.pos hx), mul_add, ofReal_div, ofReal_div,
mul_div_cancel₀ _ (ofReal_ne_zero.2 <| abs.ne_zero hx), ← mul_assoc,
mul_div_cancel₀ _ (ofReal_ne_zero.2 <| abs.ne_zero hx), re_add_im]
#align complex.exp_log Complex.exp_log
@[simp]
theorem range_exp : Set.range exp = {0}ᶜ :=
Set.ext fun x =>
⟨by
rintro ⟨x, rfl⟩
exact exp_ne_zero x, fun hx => ⟨log x, exp_log hx⟩⟩
#align complex.range_exp Complex.range_exp
theorem log_exp {x : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π) : log (exp x) = x := by
rw [log, abs_exp, Real.log_exp, exp_eq_exp_re_mul_sin_add_cos, ← ofReal_exp,
arg_mul_cos_add_sin_mul_I (Real.exp_pos _) ⟨hx₁, hx₂⟩, re_add_im]
#align complex.log_exp Complex.log_exp
theorem exp_inj_of_neg_pi_lt_of_le_pi {x y : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π) (hy₁ : -π < y.im)
(hy₂ : y.im ≤ π) (hxy : exp x = exp y) : x = y := by
rw [← log_exp hx₁ hx₂, ← log_exp hy₁ hy₂, hxy]
#align complex.exp_inj_of_neg_pi_lt_of_le_pi Complex.exp_inj_of_neg_pi_lt_of_le_pi
theorem ofReal_log {x : ℝ} (hx : 0 ≤ x) : (x.log : ℂ) = log x :=
Complex.ext (by rw [log_re, ofReal_re, abs_of_nonneg hx])
(by rw [ofReal_im, log_im, arg_ofReal_of_nonneg hx])
#align complex.of_real_log Complex.ofReal_log
@[simp, norm_cast]
lemma natCast_log {n : ℕ} : Real.log n = log n := ofReal_natCast n ▸ ofReal_log n.cast_nonneg
@[simp]
lemma ofNat_log {n : ℕ} [n.AtLeastTwo] :
Real.log (no_index (OfNat.ofNat n)) = log (OfNat.ofNat n) :=
natCast_log
theorem log_ofReal_re (x : ℝ) : (log (x : ℂ)).re = Real.log x := by simp [log_re]
#align complex.log_of_real_re Complex.log_ofReal_re
theorem log_ofReal_mul {r : ℝ} (hr : 0 < r) {x : ℂ} (hx : x ≠ 0) :
log (r * x) = Real.log r + log x := by
replace hx := Complex.abs.ne_zero_iff.mpr hx
simp_rw [log, map_mul, abs_ofReal, arg_real_mul _ hr, abs_of_pos hr, Real.log_mul hr.ne' hx,
ofReal_add, add_assoc]
#align complex.log_of_real_mul Complex.log_ofReal_mul
theorem log_mul_ofReal (r : ℝ) (hr : 0 < r) (x : ℂ) (hx : x ≠ 0) :
log (x * r) = Real.log r + log x := by rw [mul_comm, log_ofReal_mul hr hx]
#align complex.log_mul_of_real Complex.log_mul_ofReal
lemma log_mul_eq_add_log_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
log (x * y) = log x + log y ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
refine ext_iff.trans <| Iff.trans ?_ <| arg_mul_eq_add_arg_iff hx₀ hy₀
simp_rw [add_re, add_im, log_re, log_im, AbsoluteValue.map_mul,
Real.log_mul (abs.ne_zero hx₀) (abs.ne_zero hy₀), true_and]
alias ⟨_, log_mul⟩ := log_mul_eq_add_log_iff
@[simp]
theorem log_zero : log 0 = 0 := by simp [log]
#align complex.log_zero Complex.log_zero
@[simp]
theorem log_one : log 1 = 0 := by simp [log]
#align complex.log_one Complex.log_one
theorem log_neg_one : log (-1) = π * I := by simp [log]
#align complex.log_neg_one Complex.log_neg_one
theorem log_I : log I = π / 2 * I := by simp [log]
set_option linter.uppercaseLean3 false in
#align complex.log_I Complex.log_I
theorem log_neg_I : log (-I) = -(π / 2) * I := by simp [log]
set_option linter.uppercaseLean3 false in
#align complex.log_neg_I Complex.log_neg_I
| Mathlib/Analysis/SpecialFunctions/Complex/Log.lean | 124 | 128 | theorem log_conj_eq_ite (x : ℂ) : log (conj x) = if x.arg = π then log x else conj (log x) := by |
simp_rw [log, abs_conj, arg_conj, map_add, map_mul, conj_ofReal]
split_ifs with hx
· rw [hx]
simp_rw [ofReal_neg, conj_I, mul_neg, neg_mul]
| 0 |
import Mathlib.NumberTheory.FLT.Basic
import Mathlib.NumberTheory.PythagoreanTriples
import Mathlib.RingTheory.Coprime.Lemmas
import Mathlib.Tactic.LinearCombination
#align_import number_theory.fermat4 from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1"
noncomputable section
open scoped Classical
def Fermat42 (a b c : ℤ) : Prop :=
a ≠ 0 ∧ b ≠ 0 ∧ a ^ 4 + b ^ 4 = c ^ 2
#align fermat_42 Fermat42
namespace Fermat42
theorem comm {a b c : ℤ} : Fermat42 a b c ↔ Fermat42 b a c := by
delta Fermat42
rw [add_comm]
tauto
#align fermat_42.comm Fermat42.comm
theorem mul {a b c k : ℤ} (hk0 : k ≠ 0) :
Fermat42 a b c ↔ Fermat42 (k * a) (k * b) (k ^ 2 * c) := by
delta Fermat42
constructor
· intro f42
constructor
· exact mul_ne_zero hk0 f42.1
constructor
· exact mul_ne_zero hk0 f42.2.1
· have H : a ^ 4 + b ^ 4 = c ^ 2 := f42.2.2
linear_combination k ^ 4 * H
· intro f42
constructor
· exact right_ne_zero_of_mul f42.1
constructor
· exact right_ne_zero_of_mul f42.2.1
apply (mul_right_inj' (pow_ne_zero 4 hk0)).mp
linear_combination f42.2.2
#align fermat_42.mul Fermat42.mul
theorem ne_zero {a b c : ℤ} (h : Fermat42 a b c) : c ≠ 0 := by
apply ne_zero_pow two_ne_zero _; apply ne_of_gt
rw [← h.2.2, (by ring : a ^ 4 + b ^ 4 = (a ^ 2) ^ 2 + (b ^ 2) ^ 2)]
exact
add_pos (sq_pos_of_ne_zero (pow_ne_zero 2 h.1)) (sq_pos_of_ne_zero (pow_ne_zero 2 h.2.1))
#align fermat_42.ne_zero Fermat42.ne_zero
def Minimal (a b c : ℤ) : Prop :=
Fermat42 a b c ∧ ∀ a1 b1 c1 : ℤ, Fermat42 a1 b1 c1 → Int.natAbs c ≤ Int.natAbs c1
#align fermat_42.minimal Fermat42.Minimal
theorem exists_minimal {a b c : ℤ} (h : Fermat42 a b c) : ∃ a0 b0 c0, Minimal a0 b0 c0 := by
let S : Set ℕ := { n | ∃ s : ℤ × ℤ × ℤ, Fermat42 s.1 s.2.1 s.2.2 ∧ n = Int.natAbs s.2.2 }
have S_nonempty : S.Nonempty := by
use Int.natAbs c
rw [Set.mem_setOf_eq]
use ⟨a, ⟨b, c⟩⟩
let m : ℕ := Nat.find S_nonempty
have m_mem : m ∈ S := Nat.find_spec S_nonempty
rcases m_mem with ⟨s0, hs0, hs1⟩
use s0.1, s0.2.1, s0.2.2, hs0
intro a1 b1 c1 h1
rw [← hs1]
apply Nat.find_min'
use ⟨a1, ⟨b1, c1⟩⟩
#align fermat_42.exists_minimal Fermat42.exists_minimal
theorem coprime_of_minimal {a b c : ℤ} (h : Minimal a b c) : IsCoprime a b := by
apply Int.gcd_eq_one_iff_coprime.mp
by_contra hab
obtain ⟨p, hp, hpa, hpb⟩ := Nat.Prime.not_coprime_iff_dvd.mp hab
obtain ⟨a1, rfl⟩ := Int.natCast_dvd.mpr hpa
obtain ⟨b1, rfl⟩ := Int.natCast_dvd.mpr hpb
have hpc : (p : ℤ) ^ 2 ∣ c := by
rw [← Int.pow_dvd_pow_iff two_ne_zero, ← h.1.2.2]
apply Dvd.intro (a1 ^ 4 + b1 ^ 4)
ring
obtain ⟨c1, rfl⟩ := hpc
have hf : Fermat42 a1 b1 c1 :=
(Fermat42.mul (Int.natCast_ne_zero.mpr (Nat.Prime.ne_zero hp))).mpr h.1
apply Nat.le_lt_asymm (h.2 _ _ _ hf)
rw [Int.natAbs_mul, lt_mul_iff_one_lt_left, Int.natAbs_pow, Int.natAbs_ofNat]
· exact Nat.one_lt_pow two_ne_zero (Nat.Prime.one_lt hp)
· exact Nat.pos_of_ne_zero (Int.natAbs_ne_zero.2 (ne_zero hf))
#align fermat_42.coprime_of_minimal Fermat42.coprime_of_minimal
theorem minimal_comm {a b c : ℤ} : Minimal a b c → Minimal b a c := fun ⟨h1, h2⟩ =>
⟨Fermat42.comm.mp h1, h2⟩
#align fermat_42.minimal_comm Fermat42.minimal_comm
| Mathlib/NumberTheory/FLT/Four.lean | 114 | 120 | theorem neg_of_minimal {a b c : ℤ} : Minimal a b c → Minimal a b (-c) := by |
rintro ⟨⟨ha, hb, heq⟩, h2⟩
constructor
· apply And.intro ha (And.intro hb _)
rw [heq]
exact (neg_sq c).symm
rwa [Int.natAbs_neg c]
| 0 |
import Mathlib.Analysis.Calculus.LineDeriv.Basic
import Mathlib.MeasureTheory.Integral.IntegralEqImproper
open MeasureTheory Measure FiniteDimensional
variable {E F G W : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F]
[NormedSpace ℝ F] [NormedAddCommGroup G] [NormedSpace ℝ G] [NormedAddCommGroup W]
[NormedSpace ℝ W] [MeasurableSpace E] [BorelSpace E] {μ : Measure E}
lemma integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable_aux1 [SigmaFinite μ]
{f f' : E × ℝ → F} {g g' : E × ℝ → G} {B : F →L[ℝ] G →L[ℝ] W}
(hf'g : Integrable (fun x ↦ B (f' x) (g x)) (μ.prod volume))
(hfg' : Integrable (fun x ↦ B (f x) (g' x)) (μ.prod volume))
(hfg : Integrable (fun x ↦ B (f x) (g x)) (μ.prod volume))
(hf : ∀ x, HasLineDerivAt ℝ f (f' x) x (0, 1)) (hg : ∀ x, HasLineDerivAt ℝ g (g' x) x (0, 1)) :
∫ x, B (f x) (g' x) ∂(μ.prod volume) = - ∫ x, B (f' x) (g x) ∂(μ.prod volume) := calc
∫ x, B (f x) (g' x) ∂(μ.prod volume)
= ∫ x, (∫ t, B (f (x, t)) (g' (x, t))) ∂μ := integral_prod _ hfg'
_ = ∫ x, (- ∫ t, B (f' (x, t)) (g (x, t))) ∂μ := by
apply integral_congr_ae
filter_upwards [hf'g.prod_right_ae, hfg'.prod_right_ae, hfg.prod_right_ae]
with x hf'gx hfg'x hfgx
apply integral_bilinear_hasDerivAt_right_eq_neg_left_of_integrable ?_ ?_ hfg'x hf'gx hfgx
· intro t
convert (hf (x, t)).scomp_of_eq t ((hasDerivAt_id t).add (hasDerivAt_const t (-t))) (by simp)
<;> simp
· intro t
convert (hg (x, t)).scomp_of_eq t ((hasDerivAt_id t).add (hasDerivAt_const t (-t))) (by simp)
<;> simp
_ = - ∫ x, B (f' x) (g x) ∂(μ.prod volume) := by rw [integral_neg, integral_prod _ hf'g]
lemma integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable_aux2
[FiniteDimensional ℝ E] {μ : Measure (E × ℝ)} [IsAddHaarMeasure μ]
{f f' : E × ℝ → F} {g g' : E × ℝ → G} {B : F →L[ℝ] G →L[ℝ] W}
(hf'g : Integrable (fun x ↦ B (f' x) (g x)) μ)
(hfg' : Integrable (fun x ↦ B (f x) (g' x)) μ)
(hfg : Integrable (fun x ↦ B (f x) (g x)) μ)
(hf : ∀ x, HasLineDerivAt ℝ f (f' x) x (0, 1)) (hg : ∀ x, HasLineDerivAt ℝ g (g' x) x (0, 1)) :
∫ x, B (f x) (g' x) ∂μ = - ∫ x, B (f' x) (g x) ∂μ := by
let ν : Measure E := addHaar
have A : ν.prod volume = (addHaarScalarFactor (ν.prod volume) μ) • μ :=
isAddLeftInvariant_eq_smul _ _
have Hf'g : Integrable (fun x ↦ B (f' x) (g x)) (ν.prod volume) := by
rw [A]; exact hf'g.smul_measure_nnreal
have Hfg' : Integrable (fun x ↦ B (f x) (g' x)) (ν.prod volume) := by
rw [A]; exact hfg'.smul_measure_nnreal
have Hfg : Integrable (fun x ↦ B (f x) (g x)) (ν.prod volume) := by
rw [A]; exact hfg.smul_measure_nnreal
rw [isAddLeftInvariant_eq_smul μ (ν.prod volume)]
simp [integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable_aux1 Hf'g Hfg' Hfg hf hg]
variable [FiniteDimensional ℝ E] [IsAddHaarMeasure μ]
| Mathlib/Analysis/Calculus/LineDeriv/IntegrationByParts.lean | 101 | 151 | theorem integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable
{f f' : E → F} {g g' : E → G} {v : E} {B : F →L[ℝ] G →L[ℝ] W}
(hf'g : Integrable (fun x ↦ B (f' x) (g x)) μ) (hfg' : Integrable (fun x ↦ B (f x) (g' x)) μ)
(hfg : Integrable (fun x ↦ B (f x) (g x)) μ)
(hf : ∀ x, HasLineDerivAt ℝ f (f' x) x v) (hg : ∀ x, HasLineDerivAt ℝ g (g' x) x v) :
∫ x, B (f x) (g' x) ∂μ = - ∫ x, B (f' x) (g x) ∂μ := by |
by_cases hW : CompleteSpace W; swap
· simp [integral, hW]
rcases eq_or_ne v 0 with rfl|hv
· have Hf' x : f' x = 0 := by
simpa [(hasLineDerivAt_zero (f := f) (x := x)).lineDeriv] using (hf x).lineDeriv.symm
have Hg' x : g' x = 0 := by
simpa [(hasLineDerivAt_zero (f := g) (x := x)).lineDeriv] using (hg x).lineDeriv.symm
simp [Hf', Hg']
have : Nontrivial E := nontrivial_iff.2 ⟨v, 0, hv⟩
let n := finrank ℝ E
let E' := Fin (n - 1) → ℝ
obtain ⟨L, hL⟩ : ∃ L : E ≃L[ℝ] (E' × ℝ), L v = (0, 1) := by
have : finrank ℝ (E' × ℝ) = n := by simpa [this, E'] using Nat.sub_add_cancel finrank_pos
have L₀ : E ≃L[ℝ] (E' × ℝ) := (ContinuousLinearEquiv.ofFinrankEq this).symm
obtain ⟨M, hM⟩ : ∃ M : (E' × ℝ) ≃L[ℝ] (E' × ℝ), M (L₀ v) = (0, 1) := by
apply SeparatingDual.exists_continuousLinearEquiv_apply_eq
· simpa using hv
· simp
exact ⟨L₀.trans M, by simp [hM]⟩
let ν := Measure.map L μ
suffices H : ∫ (x : E' × ℝ), (B (f (L.symm x))) (g' (L.symm x)) ∂ν =
-∫ (x : E' × ℝ), (B (f' (L.symm x))) (g (L.symm x)) ∂ν by
have : μ = Measure.map L.symm ν := by
simp [Measure.map_map L.symm.continuous.measurable L.continuous.measurable]
have hL : ClosedEmbedding L.symm := L.symm.toHomeomorph.closedEmbedding
simpa [this, hL.integral_map] using H
have L_emb : MeasurableEmbedding L := L.toHomeomorph.measurableEmbedding
apply integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable_aux2
· simpa [L_emb.integrable_map_iff, Function.comp] using hf'g
· simpa [L_emb.integrable_map_iff, Function.comp] using hfg'
· simpa [L_emb.integrable_map_iff, Function.comp] using hfg
· intro x
have : f = (f ∘ L.symm) ∘ (L : E →ₗ[ℝ] (E' × ℝ)) := by ext y; simp
specialize hf (L.symm x)
rw [this] at hf
convert hf.of_comp using 1
· simp
· simp [← hL]
· intro x
have : g = (g ∘ L.symm) ∘ (L : E →ₗ[ℝ] (E' × ℝ)) := by ext y; simp
specialize hg (L.symm x)
rw [this] at hg
convert hg.of_comp using 1
· simp
· simp [← hL]
| 0 |
import Mathlib.GroupTheory.CoprodI
import Mathlib.GroupTheory.Coprod.Basic
import Mathlib.GroupTheory.QuotientGroup
import Mathlib.GroupTheory.Complement
namespace Monoid
open CoprodI Subgroup Coprod Function List
variable {ι : Type*} {G : ι → Type*} {H : Type*} {K : Type*} [Monoid K]
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')
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 }
def of (i : ι) : G i →* PushoutI φ :=
(Con.mk' _).comp <| inl.comp CoprodI.of
variable (φ) in
def base : H →* PushoutI φ :=
(Con.mk' _).comp inr
| Mathlib/GroupTheory/PushoutI.lean | 88 | 93 | 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⟩
| 0 |
import Mathlib.RingTheory.WittVector.Frobenius
import Mathlib.RingTheory.WittVector.Verschiebung
import Mathlib.RingTheory.WittVector.MulP
#align_import ring_theory.witt_vector.identities from "leanprover-community/mathlib"@"0798037604b2d91748f9b43925fb7570a5f3256c"
namespace WittVector
variable {p : ℕ} {R : Type*} [hp : Fact p.Prime] [CommRing R]
-- type as `\bbW`
local notation "𝕎" => WittVector p
noncomputable section
-- Porting note: `ghost_calc` failure: `simp only []` and the manual instances had to be added.
theorem frobenius_verschiebung (x : 𝕎 R) : frobenius (verschiebung x) = x * p := by
have : IsPoly p fun {R} [CommRing R] x ↦ frobenius (verschiebung x) :=
IsPoly.comp (hg := frobenius_isPoly p) (hf := verschiebung_isPoly)
have : IsPoly p fun {R} [CommRing R] x ↦ x * p := mulN_isPoly p p
ghost_calc x
ghost_simp [mul_comm]
#align witt_vector.frobenius_verschiebung WittVector.frobenius_verschiebung
theorem verschiebung_zmod (x : 𝕎 (ZMod p)) : verschiebung x = x * p := by
rw [← frobenius_verschiebung, frobenius_zmodp]
#align witt_vector.verschiebung_zmod WittVector.verschiebung_zmod
variable (p R)
theorem coeff_p_pow [CharP R p] (i : ℕ) : ((p : 𝕎 R) ^ i).coeff i = 1 := by
induction' i with i h
· simp only [Nat.zero_eq, one_coeff_zero, Ne, pow_zero]
· rw [pow_succ, ← frobenius_verschiebung, coeff_frobenius_charP,
verschiebung_coeff_succ, h, one_pow]
#align witt_vector.coeff_p_pow WittVector.coeff_p_pow
theorem coeff_p_pow_eq_zero [CharP R p] {i j : ℕ} (hj : j ≠ i) : ((p : 𝕎 R) ^ i).coeff j = 0 := by
induction' i with i hi generalizing j
· rw [pow_zero, one_coeff_eq_of_pos]
exact Nat.pos_of_ne_zero hj
· rw [pow_succ, ← frobenius_verschiebung, coeff_frobenius_charP]
cases j
· rw [verschiebung_coeff_zero, zero_pow hp.out.ne_zero]
· rw [verschiebung_coeff_succ, hi (ne_of_apply_ne _ hj), zero_pow hp.out.ne_zero]
#align witt_vector.coeff_p_pow_eq_zero WittVector.coeff_p_pow_eq_zero
theorem coeff_p [CharP R p] (i : ℕ) : (p : 𝕎 R).coeff i = if i = 1 then 1 else 0 := by
split_ifs with hi
· simpa only [hi, pow_one] using coeff_p_pow p R 1
· simpa only [pow_one] using coeff_p_pow_eq_zero p R hi
#align witt_vector.coeff_p WittVector.coeff_p
@[simp]
theorem coeff_p_zero [CharP R p] : (p : 𝕎 R).coeff 0 = 0 := by
rw [coeff_p, if_neg]
exact zero_ne_one
#align witt_vector.coeff_p_zero WittVector.coeff_p_zero
@[simp]
theorem coeff_p_one [CharP R p] : (p : 𝕎 R).coeff 1 = 1 := by rw [coeff_p, if_pos rfl]
#align witt_vector.coeff_p_one WittVector.coeff_p_one
theorem p_nonzero [Nontrivial R] [CharP R p] : (p : 𝕎 R) ≠ 0 := by
intro h
simpa only [h, zero_coeff, zero_ne_one] using coeff_p_one p R
#align witt_vector.p_nonzero WittVector.p_nonzero
theorem FractionRing.p_nonzero [Nontrivial R] [CharP R p] : (p : FractionRing (𝕎 R)) ≠ 0 := by
simpa using (IsFractionRing.injective (𝕎 R) (FractionRing (𝕎 R))).ne (WittVector.p_nonzero _ _)
#align witt_vector.fraction_ring.p_nonzero WittVector.FractionRing.p_nonzero
variable {p R}
-- Porting note: `ghost_calc` failure: `simp only []` and the manual instances had to be added.
theorem verschiebung_mul_frobenius (x y : 𝕎 R) :
verschiebung (x * frobenius y) = verschiebung x * y := by
have : IsPoly₂ p fun {R} [Rcr : CommRing R] x y ↦ verschiebung (x * frobenius y) :=
IsPoly.comp₂ (hg := verschiebung_isPoly)
(hf := IsPoly₂.comp (hh := mulIsPoly₂) (hf := idIsPolyI' p) (hg := frobenius_isPoly p))
have : IsPoly₂ p fun {R} [CommRing R] x y ↦ verschiebung x * y :=
IsPoly₂.comp (hh := mulIsPoly₂) (hf := verschiebung_isPoly) (hg := idIsPolyI' p)
ghost_calc x y
rintro ⟨⟩ <;> ghost_simp [mul_assoc]
#align witt_vector.verschiebung_mul_frobenius WittVector.verschiebung_mul_frobenius
theorem mul_charP_coeff_zero [CharP R p] (x : 𝕎 R) : (x * p).coeff 0 = 0 := by
rw [← frobenius_verschiebung, coeff_frobenius_charP, verschiebung_coeff_zero,
zero_pow hp.out.ne_zero]
#align witt_vector.mul_char_p_coeff_zero WittVector.mul_charP_coeff_zero
theorem mul_charP_coeff_succ [CharP R p] (x : 𝕎 R) (i : ℕ) :
(x * p).coeff (i + 1) = x.coeff i ^ p := by
rw [← frobenius_verschiebung, coeff_frobenius_charP, verschiebung_coeff_succ]
#align witt_vector.mul_char_p_coeff_succ WittVector.mul_charP_coeff_succ
| Mathlib/RingTheory/WittVector/Identities.lean | 124 | 127 | theorem verschiebung_frobenius [CharP R p] (x : 𝕎 R) : verschiebung (frobenius x) = x * p := by |
ext ⟨i⟩
· rw [mul_charP_coeff_zero, verschiebung_coeff_zero]
· rw [mul_charP_coeff_succ, verschiebung_coeff_succ, coeff_frobenius_charP]
| 0 |
import Mathlib.Probability.IdentDistrib
import Mathlib.MeasureTheory.Integral.DominatedConvergence
import Mathlib.Analysis.SpecificLimits.FloorPow
import Mathlib.Analysis.PSeries
import Mathlib.Analysis.Asymptotics.SpecificAsymptotics
#align_import probability.strong_law from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
noncomputable section
open MeasureTheory Filter Finset Asymptotics
open Set (indicator)
open scoped Topology MeasureTheory ProbabilityTheory ENNReal NNReal
namespace ProbabilityTheory
section Truncation
variable {α : Type*}
def truncation (f : α → ℝ) (A : ℝ) :=
indicator (Set.Ioc (-A) A) id ∘ f
#align probability_theory.truncation ProbabilityTheory.truncation
variable {m : MeasurableSpace α} {μ : Measure α} {f : α → ℝ}
theorem _root_.MeasureTheory.AEStronglyMeasurable.truncation (hf : AEStronglyMeasurable f μ)
{A : ℝ} : AEStronglyMeasurable (truncation f A) μ := by
apply AEStronglyMeasurable.comp_aemeasurable _ hf.aemeasurable
exact (stronglyMeasurable_id.indicator measurableSet_Ioc).aestronglyMeasurable
#align measure_theory.ae_strongly_measurable.truncation MeasureTheory.AEStronglyMeasurable.truncation
theorem abs_truncation_le_bound (f : α → ℝ) (A : ℝ) (x : α) : |truncation f A x| ≤ |A| := by
simp only [truncation, Set.indicator, Set.mem_Icc, id, Function.comp_apply]
split_ifs with h
· exact abs_le_abs h.2 (neg_le.2 h.1.le)
· simp [abs_nonneg]
#align probability_theory.abs_truncation_le_bound ProbabilityTheory.abs_truncation_le_bound
@[simp]
theorem truncation_zero (f : α → ℝ) : truncation f 0 = 0 := by simp [truncation]; rfl
#align probability_theory.truncation_zero ProbabilityTheory.truncation_zero
theorem abs_truncation_le_abs_self (f : α → ℝ) (A : ℝ) (x : α) : |truncation f A x| ≤ |f x| := by
simp only [truncation, indicator, Set.mem_Icc, id, Function.comp_apply]
split_ifs
· exact le_rfl
· simp [abs_nonneg]
#align probability_theory.abs_truncation_le_abs_self ProbabilityTheory.abs_truncation_le_abs_self
theorem truncation_eq_self {f : α → ℝ} {A : ℝ} {x : α} (h : |f x| < A) :
truncation f A x = f x := by
simp only [truncation, indicator, Set.mem_Icc, id, Function.comp_apply, ite_eq_left_iff]
intro H
apply H.elim
simp [(abs_lt.1 h).1, (abs_lt.1 h).2.le]
#align probability_theory.truncation_eq_self ProbabilityTheory.truncation_eq_self
| Mathlib/Probability/StrongLaw.lean | 114 | 123 | theorem truncation_eq_of_nonneg {f : α → ℝ} {A : ℝ} (h : ∀ x, 0 ≤ f x) :
truncation f A = indicator (Set.Ioc 0 A) id ∘ f := by |
ext x
rcases (h x).lt_or_eq with (hx | hx)
· simp only [truncation, indicator, hx, Set.mem_Ioc, id, Function.comp_apply, true_and_iff]
by_cases h'x : f x ≤ A
· have : -A < f x := by linarith [h x]
simp only [this, true_and_iff]
· simp only [h'x, and_false_iff]
· simp only [truncation, indicator, hx, id, Function.comp_apply, ite_self]
| 0 |
import Mathlib.Algebra.Module.Defs
import Mathlib.SetTheory.Cardinal.Basic
open Function
universe u v
namespace Cardinal
| Mathlib/Algebra/Module/Card.lean | 24 | 29 | theorem mk_le_of_module (R : Type u) (E : Type v)
[AddCommGroup E] [Ring R] [Module R E] [Nontrivial E] [NoZeroSMulDivisors R E] :
Cardinal.lift.{v} (#R) ≤ Cardinal.lift.{u} (#E) := by |
obtain ⟨x, hx⟩ : ∃ (x : E), x ≠ 0 := exists_ne 0
have : Injective (fun k ↦ k • x) := smul_left_injective R hx
exact lift_mk_le_lift_mk_of_injective this
| 0 |
import Mathlib.Combinatorics.SimpleGraph.Connectivity
import Mathlib.Tactic.Linarith
#align_import combinatorics.simple_graph.acyclic from "leanprover-community/mathlib"@"b07688016d62f81d14508ff339ea3415558d6353"
universe u v
namespace SimpleGraph
open Walk
variable {V : Type u} (G : SimpleGraph V)
def IsAcyclic : Prop := ∀ ⦃v : V⦄ (c : G.Walk v v), ¬c.IsCycle
#align simple_graph.is_acyclic SimpleGraph.IsAcyclic
@[mk_iff]
structure IsTree : Prop where
protected isConnected : G.Connected
protected IsAcyclic : G.IsAcyclic
#align simple_graph.is_tree SimpleGraph.IsTree
variable {G}
@[simp] lemma isAcyclic_bot : IsAcyclic (⊥ : SimpleGraph V) := fun _a _w hw ↦ hw.ne_bot rfl
| Mathlib/Combinatorics/SimpleGraph/Acyclic.lean | 68 | 80 | theorem isAcyclic_iff_forall_adj_isBridge :
G.IsAcyclic ↔ ∀ ⦃v w : V⦄, G.Adj v w → G.IsBridge s(v, w) := by |
simp_rw [isBridge_iff_adj_and_forall_cycle_not_mem]
constructor
· intro ha v w hvw
apply And.intro hvw
intro u p hp
cases ha p hp
· rintro hb v (_ | ⟨ha, p⟩) hp
· exact hp.not_of_nil
· apply (hb ha).2 _ hp
rw [Walk.edges_cons]
apply List.mem_cons_self
| 0 |
import Mathlib.SetTheory.Ordinal.Arithmetic
import Mathlib.Tactic.TFAE
import Mathlib.Topology.Order.Monotone
#align_import set_theory.ordinal.topology from "leanprover-community/mathlib"@"740acc0e6f9adf4423f92a485d0456fc271482da"
noncomputable section
universe u v
open Cardinal Order Topology
namespace Ordinal
variable {s : Set Ordinal.{u}} {a : Ordinal.{u}}
instance : TopologicalSpace Ordinal.{u} := Preorder.topology Ordinal.{u}
instance : OrderTopology Ordinal.{u} := ⟨rfl⟩
theorem isOpen_singleton_iff : IsOpen ({a} : Set Ordinal) ↔ ¬IsLimit a := by
refine ⟨fun h ⟨h₀, hsucc⟩ => ?_, fun ha => ?_⟩
· obtain ⟨b, c, hbc, hbc'⟩ :=
(mem_nhds_iff_exists_Ioo_subset' ⟨0, Ordinal.pos_iff_ne_zero.2 h₀⟩ ⟨_, lt_succ a⟩).1
(h.mem_nhds rfl)
have hba := hsucc b hbc.1
exact hba.ne (hbc' ⟨lt_succ b, hba.trans hbc.2⟩)
· rcases zero_or_succ_or_limit a with (rfl | ⟨b, rfl⟩ | ha')
· rw [← bot_eq_zero, ← Set.Iic_bot, ← Iio_succ]
exact isOpen_Iio
· rw [← Set.Icc_self, Icc_succ_left, ← Ioo_succ_right]
exact isOpen_Ioo
· exact (ha ha').elim
#align ordinal.is_open_singleton_iff Ordinal.isOpen_singleton_iff
-- Porting note (#11215): TODO: generalize to a `SuccOrder`
theorem nhds_right' (a : Ordinal) : 𝓝[>] a = ⊥ := (covBy_succ a).nhdsWithin_Ioi
-- todo: generalize to a `SuccOrder`
theorem nhds_left'_eq_nhds_ne (a : Ordinal) : 𝓝[<] a = 𝓝[≠] a := by
rw [← nhds_left'_sup_nhds_right', nhds_right', sup_bot_eq]
-- todo: generalize to a `SuccOrder`
theorem nhds_left_eq_nhds (a : Ordinal) : 𝓝[≤] a = 𝓝 a := by
rw [← nhds_left_sup_nhds_right', nhds_right', sup_bot_eq]
-- todo: generalize to a `SuccOrder`
theorem nhdsBasis_Ioc (h : a ≠ 0) : (𝓝 a).HasBasis (· < a) (Set.Ioc · a) :=
nhds_left_eq_nhds a ▸ nhdsWithin_Iic_basis' ⟨0, h.bot_lt⟩
-- todo: generalize to a `SuccOrder`
theorem nhds_eq_pure : 𝓝 a = pure a ↔ ¬IsLimit a :=
(isOpen_singleton_iff_nhds_eq_pure _).symm.trans isOpen_singleton_iff
-- todo: generalize `Ordinal.IsLimit` and this lemma to a `SuccOrder`
| Mathlib/SetTheory/Ordinal/Topology.lean | 76 | 82 | theorem isOpen_iff : IsOpen s ↔ ∀ o ∈ s, IsLimit o → ∃ a < o, Set.Ioo a o ⊆ s := by |
refine isOpen_iff_mem_nhds.trans <| forall₂_congr fun o ho => ?_
by_cases ho' : IsLimit o
· simp only [(nhdsBasis_Ioc ho'.1).mem_iff, ho', true_implies]
refine exists_congr fun a => and_congr_right fun ha => ?_
simp only [← Set.Ioo_insert_right ha, Set.insert_subset_iff, ho, true_and]
· simp [nhds_eq_pure.2 ho', ho, ho']
| 0 |
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Data.Rat.Denumerable
import Mathlib.Data.Set.Pointwise.Interval
import Mathlib.SetTheory.Cardinal.Continuum
#align_import data.real.cardinality from "leanprover-community/mathlib"@"7e7aaccf9b0182576cabdde36cf1b5ad3585b70d"
open Nat Set
open Cardinal
noncomputable section
namespace Cardinal
variable {c : ℝ} {f g : ℕ → Bool} {n : ℕ}
def cantorFunctionAux (c : ℝ) (f : ℕ → Bool) (n : ℕ) : ℝ :=
cond (f n) (c ^ n) 0
#align cardinal.cantor_function_aux Cardinal.cantorFunctionAux
@[simp]
theorem cantorFunctionAux_true (h : f n = true) : cantorFunctionAux c f n = c ^ n := by
simp [cantorFunctionAux, h]
#align cardinal.cantor_function_aux_tt Cardinal.cantorFunctionAux_true
@[simp]
theorem cantorFunctionAux_false (h : f n = false) : cantorFunctionAux c f n = 0 := by
simp [cantorFunctionAux, h]
#align cardinal.cantor_function_aux_ff Cardinal.cantorFunctionAux_false
theorem cantorFunctionAux_nonneg (h : 0 ≤ c) : 0 ≤ cantorFunctionAux c f n := by
cases h' : f n <;> simp [h']
apply pow_nonneg h
#align cardinal.cantor_function_aux_nonneg Cardinal.cantorFunctionAux_nonneg
theorem cantorFunctionAux_eq (h : f n = g n) :
cantorFunctionAux c f n = cantorFunctionAux c g n := by simp [cantorFunctionAux, h]
#align cardinal.cantor_function_aux_eq Cardinal.cantorFunctionAux_eq
theorem cantorFunctionAux_zero (f : ℕ → Bool) : cantorFunctionAux c f 0 = cond (f 0) 1 0 := by
cases h : f 0 <;> simp [h]
#align cardinal.cantor_function_aux_zero Cardinal.cantorFunctionAux_zero
theorem cantorFunctionAux_succ (f : ℕ → Bool) :
(fun n => cantorFunctionAux c f (n + 1)) = fun n =>
c * cantorFunctionAux c (fun n => f (n + 1)) n := by
ext n
cases h : f (n + 1) <;> simp [h, _root_.pow_succ']
#align cardinal.cantor_function_aux_succ Cardinal.cantorFunctionAux_succ
theorem summable_cantor_function (f : ℕ → Bool) (h1 : 0 ≤ c) (h2 : c < 1) :
Summable (cantorFunctionAux c f) := by
apply (summable_geometric_of_lt_one h1 h2).summable_of_eq_zero_or_self
intro n; cases h : f n <;> simp [h]
#align cardinal.summable_cantor_function Cardinal.summable_cantor_function
def cantorFunction (c : ℝ) (f : ℕ → Bool) : ℝ :=
∑' n, cantorFunctionAux c f n
#align cardinal.cantor_function Cardinal.cantorFunction
theorem cantorFunction_le (h1 : 0 ≤ c) (h2 : c < 1) (h3 : ∀ n, f n → g n) :
cantorFunction c f ≤ cantorFunction c g := by
apply tsum_le_tsum _ (summable_cantor_function f h1 h2) (summable_cantor_function g h1 h2)
intro n; cases h : f n
· simp [h, cantorFunctionAux_nonneg h1]
replace h3 : g n = true := h3 n h; simp [h, h3]
#align cardinal.cantor_function_le Cardinal.cantorFunction_le
theorem cantorFunction_succ (f : ℕ → Bool) (h1 : 0 ≤ c) (h2 : c < 1) :
cantorFunction c f = cond (f 0) 1 0 + c * cantorFunction c fun n => f (n + 1) := by
rw [cantorFunction, tsum_eq_zero_add (summable_cantor_function f h1 h2)]
rw [cantorFunctionAux_succ, tsum_mul_left, cantorFunctionAux, _root_.pow_zero]
rfl
#align cardinal.cantor_function_succ Cardinal.cantorFunction_succ
theorem increasing_cantorFunction (h1 : 0 < c) (h2 : c < 1 / 2) {n : ℕ} {f g : ℕ → Bool}
(hn : ∀ k < n, f k = g k) (fn : f n = false) (gn : g n = true) :
cantorFunction c f < cantorFunction c g := by
have h3 : c < 1 := by
apply h2.trans
norm_num
induction' n with n ih generalizing f g
· let f_max : ℕ → Bool := fun n => Nat.rec false (fun _ _ => true) n
have hf_max : ∀ n, f n → f_max n := by
intro n hn
cases n
· rw [fn] at hn
contradiction
apply rfl
let g_min : ℕ → Bool := fun n => Nat.rec true (fun _ _ => false) n
have hg_min : ∀ n, g_min n → g n := by
intro n hn
cases n
· rw [gn]
simp at hn
apply (cantorFunction_le (le_of_lt h1) h3 hf_max).trans_lt
refine lt_of_lt_of_le ?_ (cantorFunction_le (le_of_lt h1) h3 hg_min)
have : c / (1 - c) < 1 := by
rw [div_lt_one, lt_sub_iff_add_lt]
· convert _root_.add_lt_add h2 h2
norm_num
rwa [sub_pos]
convert this
· rw [cantorFunction_succ _ (le_of_lt h1) h3, div_eq_mul_inv, ←
tsum_geometric_of_lt_one (le_of_lt h1) h3]
apply zero_add
· refine (tsum_eq_single 0 ?_).trans ?_
· intro n hn
cases n
· contradiction
rfl
· exact cantorFunctionAux_zero _
rw [cantorFunction_succ f (le_of_lt h1) h3, cantorFunction_succ g (le_of_lt h1) h3]
rw [hn 0 <| zero_lt_succ n]
apply add_lt_add_left
rw [mul_lt_mul_left h1]
exact ih (fun k hk => hn _ <| Nat.succ_lt_succ hk) fn gn
#align cardinal.increasing_cantor_function Cardinal.increasing_cantorFunction
| Mathlib/Data/Real/Cardinality.lean | 168 | 197 | theorem cantorFunction_injective (h1 : 0 < c) (h2 : c < 1 / 2) :
Function.Injective (cantorFunction c) := by |
intro f g hfg
classical
by_contra h
revert hfg
have : ∃ n, f n ≠ g n := by
rw [← not_forall]
intro h'
apply h
ext
apply h'
let n := Nat.find this
have hn : ∀ k : ℕ, k < n → f k = g k := by
intro k hk
apply of_not_not
exact Nat.find_min this hk
cases fn : f n
· apply _root_.ne_of_lt
refine increasing_cantorFunction h1 h2 hn fn ?_
apply Bool.eq_true_of_not_eq_false
rw [← fn]
apply Ne.symm
exact Nat.find_spec this
· apply _root_.ne_of_gt
refine increasing_cantorFunction h1 h2 (fun k hk => (hn k hk).symm) ?_ fn
apply Bool.eq_false_of_not_eq_true
rw [← fn]
apply Ne.symm
exact Nat.find_spec this
| 0 |
import Mathlib.SetTheory.Ordinal.Arithmetic
#align_import set_theory.ordinal.exponential from "leanprover-community/mathlib"@"b67044ba53af18680e1dd246861d9584e968495d"
noncomputable section
open Function Cardinal Set Equiv Order
open scoped Classical
open Cardinal Ordinal
universe u v w
namespace Ordinal
instance pow : Pow Ordinal Ordinal :=
⟨fun a b => if a = 0 then 1 - b else limitRecOn b 1 (fun _ IH => IH * a) fun b _ => bsup.{u, u} b⟩
-- Porting note: Ambiguous notations.
-- local infixr:0 "^" => @Pow.pow Ordinal Ordinal Ordinal.instPowOrdinalOrdinal
theorem opow_def (a b : Ordinal) :
a ^ b = if a = 0 then 1 - b else limitRecOn b 1 (fun _ IH => IH * a) fun b _ => bsup.{u, u} b :=
rfl
#align ordinal.opow_def Ordinal.opow_def
-- Porting note: `if_pos rfl` → `if_true`
theorem zero_opow' (a : Ordinal) : 0 ^ a = 1 - a := by simp only [opow_def, if_true]
#align ordinal.zero_opow' Ordinal.zero_opow'
@[simp]
theorem zero_opow {a : Ordinal} (a0 : a ≠ 0) : (0 : Ordinal) ^ a = 0 := by
rwa [zero_opow', Ordinal.sub_eq_zero_iff_le, one_le_iff_ne_zero]
#align ordinal.zero_opow Ordinal.zero_opow
@[simp]
theorem opow_zero (a : Ordinal) : a ^ (0 : Ordinal) = 1 := by
by_cases h : a = 0
· simp only [opow_def, if_pos h, sub_zero]
· simp only [opow_def, if_neg h, limitRecOn_zero]
#align ordinal.opow_zero Ordinal.opow_zero
@[simp]
theorem opow_succ (a b : Ordinal) : a ^ succ b = a ^ b * a :=
if h : a = 0 then by subst a; simp only [zero_opow (succ_ne_zero _), mul_zero]
else by simp only [opow_def, limitRecOn_succ, if_neg h]
#align ordinal.opow_succ Ordinal.opow_succ
theorem opow_limit {a b : Ordinal} (a0 : a ≠ 0) (h : IsLimit b) :
a ^ b = bsup.{u, u} b fun c _ => a ^ c := by
simp only [opow_def, if_neg a0]; rw [limitRecOn_limit _ _ _ _ h]
#align ordinal.opow_limit Ordinal.opow_limit
theorem opow_le_of_limit {a b c : Ordinal} (a0 : a ≠ 0) (h : IsLimit b) :
a ^ b ≤ c ↔ ∀ b' < b, a ^ b' ≤ c := by rw [opow_limit a0 h, bsup_le_iff]
#align ordinal.opow_le_of_limit Ordinal.opow_le_of_limit
theorem lt_opow_of_limit {a b c : Ordinal} (b0 : b ≠ 0) (h : IsLimit c) :
a < b ^ c ↔ ∃ c' < c, a < b ^ c' := by
rw [← not_iff_not, not_exists]; simp only [not_lt, opow_le_of_limit b0 h, exists_prop, not_and]
#align ordinal.lt_opow_of_limit Ordinal.lt_opow_of_limit
@[simp]
theorem opow_one (a : Ordinal) : a ^ (1 : Ordinal) = a := by
rw [← succ_zero, opow_succ]; simp only [opow_zero, one_mul]
#align ordinal.opow_one Ordinal.opow_one
@[simp]
theorem one_opow (a : Ordinal) : (1 : Ordinal) ^ a = 1 := by
induction a using limitRecOn with
| H₁ => simp only [opow_zero]
| H₂ _ ih =>
simp only [opow_succ, ih, mul_one]
| H₃ b l IH =>
refine eq_of_forall_ge_iff fun c => ?_
rw [opow_le_of_limit Ordinal.one_ne_zero l]
exact ⟨fun H => by simpa only [opow_zero] using H 0 l.pos, fun H b' h => by rwa [IH _ h]⟩
#align ordinal.one_opow Ordinal.one_opow
| Mathlib/SetTheory/Ordinal/Exponential.lean | 94 | 102 | theorem opow_pos {a : Ordinal} (b : Ordinal) (a0 : 0 < a) : 0 < a ^ b := by |
have h0 : 0 < a ^ (0 : Ordinal) := by simp only [opow_zero, zero_lt_one]
induction b using limitRecOn with
| H₁ => exact h0
| H₂ b IH =>
rw [opow_succ]
exact mul_pos IH a0
| H₃ b l _ =>
exact (lt_opow_of_limit (Ordinal.pos_iff_ne_zero.1 a0) l).2 ⟨0, l.pos, h0⟩
| 0 |
import Mathlib.CategoryTheory.Abelian.Basic
import Mathlib.CategoryTheory.Preadditive.FunctorCategory
import Mathlib.CategoryTheory.Limits.Shapes.FunctorCategory
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Kernels
#align_import category_theory.abelian.functor_category from "leanprover-community/mathlib"@"8abfb3ba5e211d8376b855dab5d67f9eba9e0774"
noncomputable section
namespace CategoryTheory
open CategoryTheory.Limits
namespace Abelian
section
universe z w v u
-- Porting note: removed restrictions on universes
variable {C : Type u} [Category.{v} C]
variable {D : Type w} [Category.{z} D] [Abelian D]
namespace FunctorCategory
variable {F G : C ⥤ D} (α : F ⟶ G) (X : C)
@[simps!]
def coimageObjIso : (Abelian.coimage α).obj X ≅ Abelian.coimage (α.app X) :=
PreservesCokernel.iso ((evaluation C D).obj X) _ ≪≫
cokernel.mapIso _ _ (PreservesKernel.iso ((evaluation C D).obj X) _) (Iso.refl _)
(by
dsimp
simp only [Category.comp_id, PreservesKernel.iso_hom]
exact (kernelComparison_comp_ι _ ((evaluation C D).obj X)).symm)
#align category_theory.abelian.functor_category.coimage_obj_iso CategoryTheory.Abelian.FunctorCategory.coimageObjIso
@[simps!]
def imageObjIso : (Abelian.image α).obj X ≅ Abelian.image (α.app X) :=
PreservesKernel.iso ((evaluation C D).obj X) _ ≪≫
kernel.mapIso _ _ (Iso.refl _) (PreservesCokernel.iso ((evaluation C D).obj X) _)
(by
apply (cancel_mono (PreservesCokernel.iso ((evaluation C D).obj X) α).inv).1
simp only [Category.assoc, Iso.hom_inv_id]
dsimp
simp only [PreservesCokernel.iso_inv, Category.id_comp, Category.comp_id]
exact (π_comp_cokernelComparison _ ((evaluation C D).obj X)).symm)
#align category_theory.abelian.functor_category.image_obj_iso CategoryTheory.Abelian.FunctorCategory.imageObjIso
theorem coimageImageComparison_app :
coimageImageComparison (α.app X) =
(coimageObjIso α X).inv ≫ (coimageImageComparison α).app X ≫ (imageObjIso α X).hom := by
ext
dsimp
dsimp [imageObjIso, coimageObjIso, cokernel.map]
simp only [coimage_image_factorisation, PreservesKernel.iso_hom, Category.assoc,
kernel.lift_ι, Category.comp_id, PreservesCokernel.iso_inv,
cokernel.π_desc_assoc, Category.id_comp]
erw [kernelComparison_comp_ι _ ((evaluation C D).obj X),
π_comp_cokernelComparison_assoc _ ((evaluation C D).obj X)]
conv_lhs => rw [← coimage_image_factorisation α]
rfl
#align category_theory.abelian.functor_category.coimage_image_comparison_app CategoryTheory.Abelian.FunctorCategory.coimageImageComparison_app
| Mathlib/CategoryTheory/Abelian/FunctorCategory.lean | 79 | 83 | theorem coimageImageComparison_app' :
(coimageImageComparison α).app X =
(coimageObjIso α X).hom ≫ coimageImageComparison (α.app X) ≫ (imageObjIso α X).inv := by |
simp only [coimageImageComparison_app, Iso.hom_inv_id_assoc, Iso.hom_inv_id, Category.assoc,
Category.comp_id]
| 0 |
import Mathlib.Data.Complex.Module
import Mathlib.LinearAlgebra.Determinant
#align_import data.complex.determinant from "leanprover-community/mathlib"@"65ec59902eb17e4ab7da8d7e3d0bd9774d1b8b99"
namespace Complex
@[simp]
theorem det_conjAe : LinearMap.det conjAe.toLinearMap = -1 := by
rw [← LinearMap.det_toMatrix basisOneI, toMatrix_conjAe, Matrix.det_fin_two_of]
simp
#align complex.det_conj_ae Complex.det_conjAe
@[simp]
| Mathlib/Data/Complex/Determinant.lean | 31 | 33 | theorem linearEquiv_det_conjAe : LinearEquiv.det conjAe.toLinearEquiv = -1 := by |
rw [← Units.eq_iff, LinearEquiv.coe_det, AlgEquiv.toLinearEquiv_toLinearMap, det_conjAe,
Units.coe_neg_one]
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.