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
num_lines
int64
1
150
import Mathlib.RingTheory.IntegrallyClosed import Mathlib.RingTheory.Trace import Mathlib.RingTheory.Norm #align_import ring_theory.discriminant from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" universe u v w z open scoped Matrix open Matrix FiniteDimensional Fintype Polynomial Finset IntermediateField namespace Algebra variable (A : Type u) {B : Type v} (C : Type z) {ι : Type w} [DecidableEq ι] variable [CommRing A] [CommRing B] [Algebra A B] [CommRing C] [Algebra A C] section Discr -- Porting note: using `[DecidableEq ι]` instead of `by classical...` did not work in -- mathlib3. noncomputable def discr (A : Type u) {B : Type v} [CommRing A] [CommRing B] [Algebra A B] [Fintype ι] (b : ι → B) := (traceMatrix A b).det #align algebra.discr Algebra.discr theorem discr_def [Fintype ι] (b : ι → B) : discr A b = (traceMatrix A b).det := rfl variable {A C} in theorem discr_eq_discr_of_algEquiv [Fintype ι] (b : ι → B) (f : B ≃ₐ[A] C) : Algebra.discr A b = Algebra.discr A (f ∘ b) := by rw [discr_def]; congr; ext simp_rw [traceMatrix_apply, traceForm_apply, Function.comp, ← map_mul f, trace_eq_of_algEquiv] #align algebra.discr_def Algebra.discr_def variable {ι' : Type*} [Fintype ι'] [Fintype ι] [DecidableEq ι'] section Field variable (K : Type u) {L : Type v} (E : Type z) [Field K] [Field L] [Field E] variable [Algebra K L] [Algebra K E] variable [Module.Finite K L] [IsAlgClosed E] theorem discr_not_zero_of_basis [IsSeparable K L] (b : Basis ι K L) : discr K b ≠ 0 := by rw [discr_def, traceMatrix_of_basis, ← LinearMap.BilinForm.nondegenerate_iff_det_ne_zero] exact traceForm_nondegenerate _ _ #align algebra.discr_not_zero_of_basis Algebra.discr_not_zero_of_basis theorem discr_isUnit_of_basis [IsSeparable K L] (b : Basis ι K L) : IsUnit (discr K b) := IsUnit.mk0 _ (discr_not_zero_of_basis _ _) #align algebra.discr_is_unit_of_basis Algebra.discr_isUnit_of_basis variable (b : ι → L) (pb : PowerBasis K L) theorem discr_eq_det_embeddingsMatrixReindex_pow_two [IsSeparable K L] (e : ι ≃ (L →ₐ[K] E)) : algebraMap K E (discr K b) = (embeddingsMatrixReindex K E b e).det ^ 2 := by rw [discr_def, RingHom.map_det, RingHom.mapMatrix_apply, traceMatrix_eq_embeddingsMatrixReindex_mul_trans, det_mul, det_transpose, pow_two] #align algebra.discr_eq_det_embeddings_matrix_reindex_pow_two Algebra.discr_eq_det_embeddingsMatrixReindex_pow_two theorem discr_powerBasis_eq_prod (e : Fin pb.dim ≃ (L →ₐ[K] E)) [IsSeparable K L] : algebraMap K E (discr K pb.basis) = ∏ i : Fin pb.dim, ∏ j ∈ Ioi i, (e j pb.gen - e i pb.gen) ^ 2 := by rw [discr_eq_det_embeddingsMatrixReindex_pow_two K E pb.basis e, embeddingsMatrixReindex_eq_vandermonde, det_transpose, det_vandermonde, ← prod_pow] congr; ext i rw [← prod_pow] #align algebra.discr_power_basis_eq_prod Algebra.discr_powerBasis_eq_prod theorem discr_powerBasis_eq_prod' [IsSeparable K L] (e : Fin pb.dim ≃ (L →ₐ[K] E)) : algebraMap K E (discr K pb.basis) = ∏ i : Fin pb.dim, ∏ j ∈ Ioi i, -((e j pb.gen - e i pb.gen) * (e i pb.gen - e j pb.gen)) := by rw [discr_powerBasis_eq_prod _ _ _ e] congr; ext i; congr; ext j ring #align algebra.discr_power_basis_eq_prod' Algebra.discr_powerBasis_eq_prod' local notation "n" => finrank K L
Mathlib/RingTheory/Discriminant.lean
182
210
theorem discr_powerBasis_eq_prod'' [IsSeparable K L] (e : Fin pb.dim ≃ (L →ₐ[K] E)) : algebraMap K E (discr K pb.basis) = (-1) ^ (n * (n - 1) / 2) * ∏ i : Fin pb.dim, ∏ j ∈ Ioi i, (e j pb.gen - e i pb.gen) * (e i pb.gen - e j pb.gen) := by
rw [discr_powerBasis_eq_prod' _ _ _ e] simp_rw [fun i j => neg_eq_neg_one_mul ((e j pb.gen - e i pb.gen) * (e i pb.gen - e j pb.gen)), prod_mul_distrib] congr simp only [prod_pow_eq_pow_sum, prod_const] congr rw [← @Nat.cast_inj ℚ, Nat.cast_sum] have : ∀ x : Fin pb.dim, ↑x + 1 ≤ pb.dim := by simp [Nat.succ_le_iff, Fin.is_lt] simp_rw [Fin.card_Ioi, Nat.sub_sub, add_comm 1] simp only [Nat.cast_sub, this, Finset.card_fin, nsmul_eq_mul, sum_const, sum_sub_distrib, Nat.cast_add, Nat.cast_one, sum_add_distrib, mul_one] rw [← Nat.cast_sum, ← @Finset.sum_range ℕ _ pb.dim fun i => i, sum_range_id] have hn : n = pb.dim := by rw [← AlgHom.card K L E, ← Fintype.card_fin pb.dim] -- FIXME: Without the `Fintype` namespace, why does it complain about `Finset.card_congr` being -- deprecated? exact Fintype.card_congr e.symm have h₂ : 2 ∣ pb.dim * (pb.dim - 1) := pb.dim.even_mul_pred_self.two_dvd have hne : ((2 : ℕ) : ℚ) ≠ 0 := by simp have hle : 1 ≤ pb.dim := by rw [← hn, Nat.one_le_iff_ne_zero, ← zero_lt_iff, FiniteDimensional.finrank_pos_iff] infer_instance rw [hn, Nat.cast_div h₂ hne, Nat.cast_mul, Nat.cast_sub hle] field_simp ring
25
import Mathlib.AlgebraicGeometry.Morphisms.QuasiCompact import Mathlib.Topology.QuasiSeparated #align_import algebraic_geometry.morphisms.quasi_separated from "leanprover-community/mathlib"@"1a51edf13debfcbe223fa06b1cb353b9ed9751cc" noncomputable section open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace universe u open scoped AlgebraicGeometry namespace AlgebraicGeometry variable {X Y : Scheme.{u}} (f : X ⟶ Y) @[mk_iff] class QuasiSeparated (f : X ⟶ Y) : Prop where diagonalQuasiCompact : QuasiCompact (pullback.diagonal f) := by infer_instance #align algebraic_geometry.quasi_separated AlgebraicGeometry.QuasiSeparated def QuasiSeparated.affineProperty : AffineTargetMorphismProperty := fun X _ _ _ => QuasiSeparatedSpace X.carrier #align algebraic_geometry.quasi_separated.affine_property AlgebraicGeometry.QuasiSeparated.affineProperty
Mathlib/AlgebraicGeometry/Morphisms/QuasiSeparated.lean
57
83
theorem quasiSeparatedSpace_iff_affine (X : Scheme) : QuasiSeparatedSpace X.carrier ↔ ∀ U V : X.affineOpens, IsCompact (U ∩ V : Set X.carrier) := by
rw [quasiSeparatedSpace_iff] constructor · intro H U V; exact H U V U.1.2 U.2.isCompact V.1.2 V.2.isCompact · intro H suffices ∀ (U : Opens X.carrier) (_ : IsCompact U.1) (V : Opens X.carrier) (_ : IsCompact V.1), IsCompact (U ⊓ V).1 by intro U V hU hU' hV hV'; exact this ⟨U, hU⟩ hU' ⟨V, hV⟩ hV' intro U hU V hV -- Porting note: it complains "unable to find motive", but telling Lean that motive is -- underscore is actually sufficient, weird apply compact_open_induction_on (P := _) V hV · simp · intro S _ V hV change IsCompact (U.1 ∩ (S.1 ∪ V.1)) rw [Set.inter_union_distrib_left] apply hV.union clear hV apply compact_open_induction_on (P := _) U hU · simp · intro S _ W hW change IsCompact ((S.1 ∪ W.1) ∩ V.1) rw [Set.union_inter_distrib_right] apply hW.union apply H
25
import Mathlib.Data.Fintype.Basic import Mathlib.ModelTheory.Substructures #align_import model_theory.elementary_maps from "leanprover-community/mathlib"@"d11893b411025250c8e61ff2f12ccbd7ee35ab15" open FirstOrder namespace FirstOrder namespace Language open Structure variable (L : Language) (M : Type*) (N : Type*) {P : Type*} {Q : Type*} variable [L.Structure M] [L.Structure N] [L.Structure P] [L.Structure Q] structure ElementaryEmbedding where toFun : M → N -- Porting note: -- The autoparam here used to be `obviously`. We would like to replace it with `aesop` -- but that isn't currently sufficient. -- See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Aesop.20and.20cases -- If that can be improved, we should change this to `by aesop` and remove the proofs below. map_formula' : ∀ ⦃n⦄ (φ : L.Formula (Fin n)) (x : Fin n → M), φ.Realize (toFun ∘ x) ↔ φ.Realize x := by intros; trivial #align first_order.language.elementary_embedding FirstOrder.Language.ElementaryEmbedding #align first_order.language.elementary_embedding.to_fun FirstOrder.Language.ElementaryEmbedding.toFun #align first_order.language.elementary_embedding.map_formula' FirstOrder.Language.ElementaryEmbedding.map_formula' @[inherit_doc FirstOrder.Language.ElementaryEmbedding] scoped[FirstOrder] notation:25 A " ↪ₑ[" L "] " B => FirstOrder.Language.ElementaryEmbedding L A B variable {L} {M} {N} variable (L) (M) abbrev elementaryDiagram : L[[M]].Theory := L[[M]].completeTheory M #align first_order.language.elementary_diagram FirstOrder.Language.elementaryDiagram @[simps] def ElementaryEmbedding.ofModelsElementaryDiagram (N : Type*) [L.Structure N] [L[[M]].Structure N] [(lhomWithConstants L M).IsExpansionOn N] [N ⊨ L.elementaryDiagram M] : M ↪ₑ[L] N := ⟨((↑) : L[[M]].Constants → N) ∘ Sum.inr, fun n φ x => by refine _root_.trans ?_ ((realize_iff_of_model_completeTheory M N (((L.lhomWithConstants M).onBoundedFormula φ).subst (Constants.term ∘ Sum.inr ∘ x)).alls).trans ?_) · simp_rw [Sentence.Realize, BoundedFormula.realize_alls, BoundedFormula.realize_subst, LHom.realize_onBoundedFormula, Formula.Realize, Unique.forall_iff, Function.comp, Term.realize_constants] · simp_rw [Sentence.Realize, BoundedFormula.realize_alls, BoundedFormula.realize_subst, LHom.realize_onBoundedFormula, Formula.Realize, Unique.forall_iff] rfl⟩ #align first_order.language.elementary_embedding.of_models_elementary_diagram FirstOrder.Language.ElementaryEmbedding.ofModelsElementaryDiagram variable {L M} namespace Embedding
Mathlib/ModelTheory/ElementaryMaps.lean
272
302
theorem isElementary_of_exists (f : M ↪[L] N) (htv : ∀ (n : ℕ) (φ : L.BoundedFormula Empty (n + 1)) (x : Fin n → M) (a : N), φ.Realize default (Fin.snoc (f ∘ x) a : _ → N) → ∃ b : M, φ.Realize default (Fin.snoc (f ∘ x) (f b) : _ → N)) : ∀ {n} (φ : L.Formula (Fin n)) (x : Fin n → M), φ.Realize (f ∘ x) ↔ φ.Realize x := by
suffices h : ∀ (n : ℕ) (φ : L.BoundedFormula Empty n) (xs : Fin n → M), φ.Realize (f ∘ default) (f ∘ xs) ↔ φ.Realize default xs by intro n φ x exact φ.realize_relabel_sum_inr.symm.trans (_root_.trans (h n _ _) φ.realize_relabel_sum_inr) refine fun n φ => φ.recOn ?_ ?_ ?_ ?_ ?_ · exact fun {_} _ => Iff.rfl · intros simp [BoundedFormula.Realize, ← Sum.comp_elim, Embedding.realize_term] · intros simp only [BoundedFormula.Realize, ← Sum.comp_elim, realize_term] erw [map_rel f] · intro _ _ _ ih1 ih2 _ simp [ih1, ih2] · intro n φ ih xs simp only [BoundedFormula.realize_all] refine ⟨fun h a => ?_, ?_⟩ · rw [← ih, Fin.comp_snoc] exact h (f a) · contrapose! rintro ⟨a, ha⟩ obtain ⟨b, hb⟩ := htv n φ.not xs a (by rw [BoundedFormula.realize_not, ← Unique.eq_default (f ∘ default)] exact ha) refine ⟨b, fun h => hb (Eq.mp ?_ ((ih _).2 h))⟩ rw [Unique.eq_default (f ∘ default), Fin.comp_snoc]
25
import Mathlib.Algebra.ContinuedFractions.ContinuantsRecurrence import Mathlib.Algebra.ContinuedFractions.TerminatedStable import Mathlib.Tactic.FieldSimp import Mathlib.Tactic.Ring #align_import algebra.continued_fractions.convergents_equiv from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" variable {K : Type*} {n : ℕ} namespace GeneralizedContinuedFraction variable {g : GeneralizedContinuedFraction K} {s : Stream'.Seq <| Pair K} section Squash section WithDivisionRing variable [DivisionRing K] def squashSeq (s : Stream'.Seq <| Pair K) (n : ℕ) : Stream'.Seq (Pair K) := match Prod.mk (s.get? n) (s.get? (n + 1)) with | ⟨some gp_n, some gp_succ_n⟩ => Stream'.Seq.nats.zipWith -- return the squashed value at position `n`; otherwise, do nothing. (fun n' gp => if n' = n then ⟨gp_n.a, gp_n.b + gp_succ_n.a / gp_succ_n.b⟩ else gp) s | _ => s #align generalized_continued_fraction.squash_seq GeneralizedContinuedFraction.squashSeq theorem squashSeq_eq_self_of_terminated (terminated_at_succ_n : s.TerminatedAt (n + 1)) : squashSeq s n = s := by change s.get? (n + 1) = none at terminated_at_succ_n cases s_nth_eq : s.get? n <;> simp only [*, squashSeq] #align generalized_continued_fraction.squash_seq_eq_self_of_terminated GeneralizedContinuedFraction.squashSeq_eq_self_of_terminated theorem squashSeq_nth_of_not_terminated {gp_n gp_succ_n : Pair K} (s_nth_eq : s.get? n = some gp_n) (s_succ_nth_eq : s.get? (n + 1) = some gp_succ_n) : (squashSeq s n).get? n = some ⟨gp_n.a, gp_n.b + gp_succ_n.a / gp_succ_n.b⟩ := by simp [*, squashSeq] #align generalized_continued_fraction.squash_seq_nth_of_not_terminated GeneralizedContinuedFraction.squashSeq_nth_of_not_terminated theorem squashSeq_nth_of_lt {m : ℕ} (m_lt_n : m < n) : (squashSeq s n).get? m = s.get? m := by cases s_succ_nth_eq : s.get? (n + 1) with | none => rw [squashSeq_eq_self_of_terminated s_succ_nth_eq] | some => obtain ⟨gp_n, s_nth_eq⟩ : ∃ gp_n, s.get? n = some gp_n := s.ge_stable n.le_succ s_succ_nth_eq obtain ⟨gp_m, s_mth_eq⟩ : ∃ gp_m, s.get? m = some gp_m := s.ge_stable (le_of_lt m_lt_n) s_nth_eq simp [*, squashSeq, m_lt_n.ne] #align generalized_continued_fraction.squash_seq_nth_of_lt GeneralizedContinuedFraction.squashSeq_nth_of_lt theorem squashSeq_succ_n_tail_eq_squashSeq_tail_n : (squashSeq s (n + 1)).tail = squashSeq s.tail n := by cases s_succ_succ_nth_eq : s.get? (n + 2) with | none => cases s_succ_nth_eq : s.get? (n + 1) <;> simp only [squashSeq, Stream'.Seq.get?_tail, s_succ_nth_eq, s_succ_succ_nth_eq] | some gp_succ_succ_n => obtain ⟨gp_succ_n, s_succ_nth_eq⟩ : ∃ gp_succ_n, s.get? (n + 1) = some gp_succ_n := s.ge_stable (n + 1).le_succ s_succ_succ_nth_eq -- apply extensionality with `m` and continue by cases `m = n`. ext1 m cases' Decidable.em (m = n) with m_eq_n m_ne_n · simp [*, squashSeq] · cases s_succ_mth_eq : s.get? (m + 1) · simp only [*, squashSeq, Stream'.Seq.get?_tail, Stream'.Seq.get?_zipWith, Option.map₂_none_right] · simp [*, squashSeq] #align generalized_continued_fraction.squash_seq_succ_n_tail_eq_squash_seq_tail_n GeneralizedContinuedFraction.squashSeq_succ_n_tail_eq_squashSeq_tail_n
Mathlib/Algebra/ContinuedFractions/ConvergentsEquiv.lean
155
181
theorem succ_succ_nth_convergent'_aux_eq_succ_nth_convergent'_aux_squashSeq : convergents'Aux s (n + 2) = convergents'Aux (squashSeq s n) (n + 1) := by
cases s_succ_nth_eq : s.get? <| n + 1 with | none => rw [squashSeq_eq_self_of_terminated s_succ_nth_eq, convergents'Aux_stable_step_of_terminated s_succ_nth_eq] | some gp_succ_n => induction n generalizing s gp_succ_n with | zero => obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head := s.ge_stable zero_le_one s_succ_nth_eq have : (squashSeq s 0).head = some ⟨gp_head.a, gp_head.b + gp_succ_n.a / gp_succ_n.b⟩ := squashSeq_nth_of_not_terminated s_head_eq s_succ_nth_eq simp_all [convergents'Aux, Stream'.Seq.head, Stream'.Seq.get?_tail] | succ m IH => obtain ⟨gp_head, s_head_eq⟩ : ∃ gp_head, s.head = some gp_head := s.ge_stable (m + 2).zero_le s_succ_nth_eq suffices gp_head.a / (gp_head.b + convergents'Aux s.tail (m + 2)) = convergents'Aux (squashSeq s (m + 1)) (m + 2) by simpa only [convergents'Aux, s_head_eq] have : convergents'Aux s.tail (m + 2) = convergents'Aux (squashSeq s.tail m) (m + 1) := by refine IH gp_succ_n ?_ simpa [Stream'.Seq.get?_tail] using s_succ_nth_eq have : (squashSeq s (m + 1)).head = some gp_head := (squashSeq_nth_of_lt m.succ_pos).trans s_head_eq simp_all [convergents'Aux, squashSeq_succ_n_tail_eq_squashSeq_tail_n]
25
import Mathlib.Analysis.Convolution import Mathlib.Analysis.Calculus.BumpFunction.Normed import Mathlib.MeasureTheory.Integral.Average import Mathlib.MeasureTheory.Covering.Differentiation import Mathlib.MeasureTheory.Covering.BesicovitchVectorSpace import Mathlib.MeasureTheory.Measure.Haar.Unique #align_import analysis.convolution from "leanprover-community/mathlib"@"8905e5ed90859939681a725b00f6063e65096d95" universe uG uE' open ContinuousLinearMap Metric MeasureTheory Filter Function Measure Set open scoped Convolution Topology namespace ContDiffBump variable {G : Type uG} {E' : Type uE'} [NormedAddCommGroup E'] {g : G → E'} [MeasurableSpace G] {μ : MeasureTheory.Measure G} [NormedSpace ℝ E'] [NormedAddCommGroup G] [NormedSpace ℝ G] [HasContDiffBump G] [CompleteSpace E'] {φ : ContDiffBump (0 : G)} {x₀ : G} theorem convolution_eq_right {x₀ : G} (hg : ∀ x ∈ ball x₀ φ.rOut, g x = g x₀) : (φ ⋆[lsmul ℝ ℝ, μ] g : G → E') x₀ = integral μ φ • g x₀ := by simp_rw [convolution_eq_right' _ φ.support_eq.subset hg, lsmul_apply, integral_smul_const] #align cont_diff_bump.convolution_eq_right ContDiffBump.convolution_eq_right variable [BorelSpace G] variable [IsLocallyFiniteMeasure μ] [μ.IsOpenPosMeasure] variable [FiniteDimensional ℝ G] theorem normed_convolution_eq_right {x₀ : G} (hg : ∀ x ∈ ball x₀ φ.rOut, g x = g x₀) : (φ.normed μ ⋆[lsmul ℝ ℝ, μ] g : G → E') x₀ = g x₀ := by rw [convolution_eq_right' _ φ.support_normed_eq.subset hg] exact integral_normed_smul φ μ (g x₀) #align cont_diff_bump.normed_convolution_eq_right ContDiffBump.normed_convolution_eq_right variable [μ.IsAddLeftInvariant] theorem dist_normed_convolution_le {x₀ : G} {ε : ℝ} (hmg : AEStronglyMeasurable g μ) (hg : ∀ x ∈ ball x₀ φ.rOut, dist (g x) (g x₀) ≤ ε) : dist ((φ.normed μ ⋆[lsmul ℝ ℝ, μ] g : G → E') x₀) (g x₀) ≤ ε := dist_convolution_le (by simp_rw [← dist_self (g x₀), hg x₀ (mem_ball_self φ.rOut_pos)]) φ.support_normed_eq.subset φ.nonneg_normed φ.integral_normed hmg hg #align cont_diff_bump.dist_normed_convolution_le ContDiffBump.dist_normed_convolution_le nonrec theorem convolution_tendsto_right {ι} {φ : ι → ContDiffBump (0 : G)} {g : ι → G → E'} {k : ι → G} {x₀ : G} {z₀ : E'} {l : Filter ι} (hφ : Tendsto (fun i => (φ i).rOut) l (𝓝 0)) (hig : ∀ᶠ i in l, AEStronglyMeasurable (g i) μ) (hcg : Tendsto (uncurry g) (l ×ˢ 𝓝 x₀) (𝓝 z₀)) (hk : Tendsto k l (𝓝 x₀)) : Tendsto (fun i => ((φ i).normed μ ⋆[lsmul ℝ ℝ, μ] g i) (k i)) l (𝓝 z₀) := convolution_tendsto_right (eventually_of_forall fun i => (φ i).nonneg_normed) (eventually_of_forall fun i => (φ i).integral_normed) (tendsto_support_normed_smallSets hφ) hig hcg hk #align cont_diff_bump.convolution_tendsto_right ContDiffBump.convolution_tendsto_right theorem convolution_tendsto_right_of_continuous {ι} {φ : ι → ContDiffBump (0 : G)} {l : Filter ι} (hφ : Tendsto (fun i => (φ i).rOut) l (𝓝 0)) (hg : Continuous g) (x₀ : G) : Tendsto (fun i => ((φ i).normed μ ⋆[lsmul ℝ ℝ, μ] g) x₀) l (𝓝 (g x₀)) := convolution_tendsto_right hφ (eventually_of_forall fun _ => hg.aestronglyMeasurable) ((hg.tendsto x₀).comp tendsto_snd) tendsto_const_nhds #align cont_diff_bump.convolution_tendsto_right_of_continuous ContDiffBump.convolution_tendsto_right_of_continuous
Mathlib/Analysis/Calculus/BumpFunction/Convolution.lean
110
139
theorem ae_convolution_tendsto_right_of_locallyIntegrable {ι} {φ : ι → ContDiffBump (0 : G)} {l : Filter ι} {K : ℝ} (hφ : Tendsto (fun i ↦ (φ i).rOut) l (𝓝 0)) (h'φ : ∀ᶠ i in l, (φ i).rOut ≤ K * (φ i).rIn) (hg : LocallyIntegrable g μ) : ∀ᵐ x₀ ∂μ, Tendsto (fun i ↦ ((φ i).normed μ ⋆[lsmul ℝ ℝ, μ] g) x₀) l (𝓝 (g x₀)) := by
have : IsAddHaarMeasure μ := ⟨⟩ -- By Lebesgue differentiation theorem, the average of `g` on a small ball converges -- almost everywhere to the value of `g` as the radius shrinks to zero. -- We will see that this set of points satisfies the desired conclusion. filter_upwards [(Besicovitch.vitaliFamily μ).ae_tendsto_average_norm_sub hg] with x₀ h₀ simp only [convolution_eq_swap, lsmul_apply] have hφ' : Tendsto (fun i ↦ (φ i).rOut) l (𝓝[>] 0) := tendsto_nhdsWithin_iff.2 ⟨hφ, eventually_of_forall (fun i ↦ (φ i).rOut_pos)⟩ have := (h₀.comp (Besicovitch.tendsto_filterAt μ x₀)).comp hφ' simp only [Function.comp] at this apply tendsto_integral_smul_of_tendsto_average_norm_sub (K ^ (FiniteDimensional.finrank ℝ G)) this · filter_upwards with i using hg.integrableOn_isCompact (isCompact_closedBall _ _) · apply tendsto_const_nhds.congr (fun i ↦ ?_) rw [← integral_neg_eq_self] simp only [sub_neg_eq_add, integral_add_left_eq_self, integral_normed] · filter_upwards with i change support ((ContDiffBump.normed (φ i) μ) ∘ (fun y ↦ x₀ - y)) ⊆ closedBall x₀ (φ i).rOut simp only [support_comp_eq_preimage, support_normed_eq] intro x hx simp only [mem_preimage, mem_ball, dist_zero_right] at hx simpa [dist_eq_norm_sub'] using hx.le · filter_upwards [h'φ] with i hi x rw [abs_of_nonneg (nonneg_normed _ _), addHaar_closedBall_center] exact (φ i).normed_le_div_measure_closedBall_rOut _ _ hi _
25
import Mathlib.Algebra.Algebra.Subalgebra.Basic import Mathlib.RingTheory.Ideal.Maps #align_import algebra.algebra.subalgebra.basic from "leanprover-community/mathlib"@"b915e9392ecb2a861e1e766f0e1df6ac481188ca" namespace Subalgebra open Algebra variable {R S : Type*} [CommSemiring R] [CommRing S] [Algebra R S] variable (S' : Subalgebra R S)
Mathlib/Algebra/Algebra/Subalgebra/Operations.lean
40
68
theorem mem_of_finset_sum_eq_one_of_pow_smul_mem {ι : Type*} (ι' : Finset ι) (s : ι → S) (l : ι → S) (e : ∑ i ∈ ι', l i * s i = 1) (hs : ∀ i, s i ∈ S') (hl : ∀ i, l i ∈ S') (x : S) (H : ∀ i, ∃ n : ℕ, (s i ^ n : S) • x ∈ S') : x ∈ S' := by
-- Porting note: needed to add this instance let _i : Algebra { x // x ∈ S' } { x // x ∈ S' } := Algebra.id _ suffices x ∈ Subalgebra.toSubmodule (Algebra.ofId S' S).range by obtain ⟨x, rfl⟩ := this exact x.2 choose n hn using H let s' : ι → S' := fun x => ⟨s x, hs x⟩ let l' : ι → S' := fun x => ⟨l x, hl x⟩ have e' : ∑ i ∈ ι', l' i * s' i = 1 := by ext show S'.subtype (∑ i ∈ ι', l' i * s' i) = 1 simpa only [map_sum, map_mul] using e have : Ideal.span (s' '' ι') = ⊤ := by rw [Ideal.eq_top_iff_one, ← e'] apply sum_mem intros i hi exact Ideal.mul_mem_left _ _ <| Ideal.subset_span <| Set.mem_image_of_mem s' hi let N := ι'.sup n have hN := Ideal.span_pow_eq_top _ this N apply (Algebra.ofId S' S).range.toSubmodule.mem_of_span_top_of_smul_mem _ hN rintro ⟨_, _, ⟨i, hi, rfl⟩, rfl⟩ change s' i ^ N • x ∈ _ rw [← tsub_add_cancel_of_le (show n i ≤ N from Finset.le_sup hi), pow_add, mul_smul] refine Submodule.smul_mem _ (⟨_, pow_mem (hs i) _⟩ : S') ?_ exact ⟨⟨_, hn i⟩, rfl⟩
25
import Mathlib.MeasureTheory.Measure.Typeclasses #align_import measure_theory.measure.sub from "leanprover-community/mathlib"@"562bbf524c595c153470e53d36c57b6f891cc480" open Set namespace MeasureTheory namespace Measure noncomputable instance instSub {α : Type*} [MeasurableSpace α] : Sub (Measure α) := ⟨fun μ ν => sInf { τ | μ ≤ τ + ν }⟩ #align measure_theory.measure.has_sub MeasureTheory.Measure.instSub variable {α : Type*} {m : MeasurableSpace α} {μ ν : Measure α} {s : Set α} theorem sub_def : μ - ν = sInf { d | μ ≤ d + ν } := rfl #align measure_theory.measure.sub_def MeasureTheory.Measure.sub_def theorem sub_le_of_le_add {d} (h : μ ≤ d + ν) : μ - ν ≤ d := sInf_le h #align measure_theory.measure.sub_le_of_le_add MeasureTheory.Measure.sub_le_of_le_add theorem sub_eq_zero_of_le (h : μ ≤ ν) : μ - ν = 0 := nonpos_iff_eq_zero'.1 <| sub_le_of_le_add <| by rwa [zero_add] #align measure_theory.measure.sub_eq_zero_of_le MeasureTheory.Measure.sub_eq_zero_of_le theorem sub_le : μ - ν ≤ μ := sub_le_of_le_add <| Measure.le_add_right le_rfl #align measure_theory.measure.sub_le MeasureTheory.Measure.sub_le @[simp] theorem sub_top : μ - ⊤ = 0 := sub_eq_zero_of_le le_top #align measure_theory.measure.sub_top MeasureTheory.Measure.sub_top @[simp] theorem zero_sub : 0 - μ = 0 := sub_eq_zero_of_le μ.zero_le #align measure_theory.measure.zero_sub MeasureTheory.Measure.zero_sub @[simp] theorem sub_self : μ - μ = 0 := sub_eq_zero_of_le le_rfl #align measure_theory.measure.sub_self MeasureTheory.Measure.sub_self
Mathlib/MeasureTheory/Measure/Sub.lean
71
97
theorem sub_apply [IsFiniteMeasure ν] (h₁ : MeasurableSet s) (h₂ : ν ≤ μ) : (μ - ν) s = μ s - ν s := by
-- We begin by defining `measure_sub`, which will be equal to `(μ - ν)`. let measure_sub : Measure α := MeasureTheory.Measure.ofMeasurable (fun (t : Set α) (_ : MeasurableSet t) => μ t - ν t) (by simp) (fun g h_meas h_disj ↦ by simp only [measure_iUnion h_disj h_meas] rw [ENNReal.tsum_sub _ (h₂ <| g ·)] rw [← measure_iUnion h_disj h_meas] apply measure_ne_top) -- Now, we demonstrate `μ - ν = measure_sub`, and apply it. have h_measure_sub_add : ν + measure_sub = μ := by ext1 t h_t_measurable_set simp only [Pi.add_apply, coe_add] rw [MeasureTheory.Measure.ofMeasurable_apply _ h_t_measurable_set, add_comm, tsub_add_cancel_of_le (h₂ t)] have h_measure_sub_eq : μ - ν = measure_sub := by rw [MeasureTheory.Measure.sub_def] apply le_antisymm · apply sInf_le simp [le_refl, add_comm, h_measure_sub_add] apply le_sInf intro d h_d rw [← h_measure_sub_add, mem_setOf_eq, add_comm d] at h_d apply Measure.le_of_add_le_add_left h_d rw [h_measure_sub_eq] apply Measure.ofMeasurable_apply _ h₁
25
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 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 #align simple_graph.is_acyclic_iff_forall_adj_is_bridge SimpleGraph.isAcyclic_iff_forall_adj_isBridge theorem isAcyclic_iff_forall_edge_isBridge : G.IsAcyclic ↔ ∀ ⦃e⦄, e ∈ (G.edgeSet) → G.IsBridge e := by simp [isAcyclic_iff_forall_adj_isBridge, Sym2.forall] #align simple_graph.is_acyclic_iff_forall_edge_is_bridge SimpleGraph.isAcyclic_iff_forall_edge_isBridge
Mathlib/Combinatorics/SimpleGraph/Acyclic.lean
88
115
theorem IsAcyclic.path_unique {G : SimpleGraph V} (h : G.IsAcyclic) {v w : V} (p q : G.Path v w) : p = q := by
obtain ⟨p, hp⟩ := p obtain ⟨q, hq⟩ := q rw [Subtype.mk.injEq] induction p with | nil => cases (Walk.isPath_iff_eq_nil _).mp hq rfl | cons ph p ih => rw [isAcyclic_iff_forall_adj_isBridge] at h specialize h ph rw [isBridge_iff_adj_and_forall_walk_mem_edges] at h replace h := h.2 (q.append p.reverse) simp only [Walk.edges_append, Walk.edges_reverse, List.mem_append, List.mem_reverse] at h cases' h with h h · cases q with | nil => simp [Walk.isPath_def] at hp | cons _ q => rw [Walk.cons_isPath_iff] at hp hq simp only [Walk.edges_cons, List.mem_cons, Sym2.eq_iff, true_and] at h rcases h with (⟨h, rfl⟩ | ⟨rfl, rfl⟩) | h · cases ih hp.1 q hq.1 rfl · simp at hq · exact absurd (Walk.fst_mem_support_of_mem_edges _ h) hq.2 · rw [Walk.cons_isPath_iff] at hp exact absurd (Walk.fst_mem_support_of_mem_edges _ h) hp.2
26
import Mathlib.Analysis.Calculus.Deriv.AffineMap import Mathlib.Analysis.Calculus.Deriv.Slope import Mathlib.Analysis.Calculus.Deriv.Mul import Mathlib.Analysis.Calculus.Deriv.Comp import Mathlib.Analysis.Calculus.LocalExtr.Rolle import Mathlib.Analysis.Convex.Normed import Mathlib.Analysis.RCLike.Basic #align_import analysis.calculus.mean_value from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] open Metric Set Asymptotics ContinuousLinearMap Filter open scoped Classical Topology NNReal
Mathlib/Analysis/Calculus/MeanValue.lean
92
124
theorem image_le_of_liminf_slope_right_lt_deriv_boundary' {f f' : ℝ → ℝ} {a b : ℝ} (hf : ContinuousOn f (Icc a b)) -- `hf'` actually says `liminf (f z - f x) / (z - x) ≤ f' x` (hf' : ∀ x ∈ Ico a b, ∀ r, f' x < r → ∃ᶠ z in 𝓝[>] x, slope f x z < r) {B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : ContinuousOn B (Icc a b)) (hB' : ∀ x ∈ Ico a b, HasDerivWithinAt B (B' x) (Ici x) x) (bound : ∀ x ∈ Ico a b, f x = B x → f' x < B' x) : ∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x := by
change Icc a b ⊆ { x | f x ≤ B x } set s := { x | f x ≤ B x } ∩ Icc a b have A : ContinuousOn (fun x => (f x, B x)) (Icc a b) := hf.prod hB have : IsClosed s := by simp only [s, inter_comm] exact A.preimage_isClosed_of_isClosed isClosed_Icc OrderClosedTopology.isClosed_le' apply this.Icc_subset_of_forall_exists_gt ha rintro x ⟨hxB : f x ≤ B x, xab⟩ y hy cases' hxB.lt_or_eq with hxB hxB · -- If `f x < B x`, then all we need is continuity of both sides refine nonempty_of_mem (inter_mem ?_ (Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, hy⟩)) have : ∀ᶠ x in 𝓝[Icc a b] x, f x < B x := A x (Ico_subset_Icc_self xab) (IsOpen.mem_nhds (isOpen_lt continuous_fst continuous_snd) hxB) have : ∀ᶠ x in 𝓝[>] x, f x < B x := nhdsWithin_le_of_mem (Icc_mem_nhdsWithin_Ioi xab) this exact this.mono fun y => le_of_lt · rcases exists_between (bound x xab hxB) with ⟨r, hfr, hrB⟩ specialize hf' x xab r hfr have HB : ∀ᶠ z in 𝓝[>] x, r < slope B x z := (hasDerivWithinAt_iff_tendsto_slope' <| lt_irrefl x).1 (hB' x xab).Ioi_of_Ici (Ioi_mem_nhds hrB) obtain ⟨z, hfz, hzB, hz⟩ : ∃ z, slope f x z < r ∧ r < slope B x z ∧ z ∈ Ioc x y := (hf'.and_eventually (HB.and (Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, hy⟩))).exists refine ⟨z, ?_, hz⟩ have := (hfz.trans hzB).le rwa [slope_def_field, slope_def_field, div_le_div_right (sub_pos.2 hz.1), hxB, sub_le_sub_iff_right] at this
26
import Mathlib.Algebra.Group.Submonoid.Membership import Mathlib.Data.Nat.ModEq import Mathlib.Tactic.Ring import Mathlib.Tactic.Zify #align_import number_theory.frobenius_number from "leanprover-community/mathlib"@"1126441d6bccf98c81214a0780c73d499f6721fe" open Nat def FrobeniusNumber (n : ℕ) (s : Set ℕ) : Prop := IsGreatest { k | k ∉ AddSubmonoid.closure s } n #align is_frobenius_number FrobeniusNumber variable {m n : ℕ}
Mathlib/NumberTheory/FrobeniusNumber.lean
55
82
theorem frobeniusNumber_pair (cop : Coprime m n) (hm : 1 < m) (hn : 1 < n) : FrobeniusNumber (m * n - m - n) {m, n} := by
simp_rw [FrobeniusNumber, AddSubmonoid.mem_closure_pair] have hmn : m + n ≤ m * n := add_le_mul hm hn constructor · push_neg intro a b h apply cop.mul_add_mul_ne_mul (add_one_ne_zero a) (add_one_ne_zero b) simp only [Nat.sub_sub, smul_eq_mul] at h zify [hmn] at h ⊢ rw [← sub_eq_zero] at h ⊢ rw [← h] ring · intro k hk dsimp at hk contrapose! hk let x := chineseRemainder cop 0 k have hx : x.val < m * n := chineseRemainder_lt_mul cop 0 k (ne_bot_of_gt hm) (ne_bot_of_gt hn) suffices key : x.1 ≤ k by obtain ⟨a, ha⟩ := modEq_zero_iff_dvd.mp x.2.1 obtain ⟨b, hb⟩ := (modEq_iff_dvd' key).mp x.2.2 exact ⟨a, b, by rw [mul_comm, ← ha, mul_comm, ← hb, Nat.add_sub_of_le key]⟩ refine ModEq.le_of_lt_add x.2.2 (lt_of_le_of_lt ?_ (add_lt_add_right hk n)) rw [Nat.sub_add_cancel (le_tsub_of_add_le_left hmn)] exact ModEq.le_of_lt_add (x.2.1.trans (modEq_zero_iff_dvd.mpr (Nat.dvd_sub' (dvd_mul_right m n) dvd_rfl)).symm) (lt_of_lt_of_le hx le_tsub_add)
26
import Mathlib.Order.Ideal import Mathlib.Data.Finset.Lattice #align_import order.countable_dense_linear_order from "leanprover-community/mathlib"@"2705404e701abc6b3127da906f40bae062a169c9" noncomputable section open scoped Classical namespace Order theorem exists_between_finsets {α : Type*} [LinearOrder α] [DenselyOrdered α] [NoMinOrder α] [NoMaxOrder α] [nonem : Nonempty α] (lo hi : Finset α) (lo_lt_hi : ∀ x ∈ lo, ∀ y ∈ hi, x < y) : ∃ m : α, (∀ x ∈ lo, x < m) ∧ ∀ y ∈ hi, m < y := if nlo : lo.Nonempty then if nhi : hi.Nonempty then -- both sets are nonempty, use `DenselyOrdered` Exists.elim (exists_between (lo_lt_hi _ (Finset.max'_mem _ nlo) _ (Finset.min'_mem _ nhi))) fun m hm ↦ ⟨m, fun x hx ↦ lt_of_le_of_lt (Finset.le_max' lo x hx) hm.1, fun y hy ↦ lt_of_lt_of_le hm.2 (Finset.min'_le hi y hy)⟩ else-- upper set is empty, use `NoMaxOrder` Exists.elim (exists_gt (Finset.max' lo nlo)) fun m hm ↦ ⟨m, fun x hx ↦ lt_of_le_of_lt (Finset.le_max' lo x hx) hm, fun y hy ↦ (nhi ⟨y, hy⟩).elim⟩ else if nhi : hi.Nonempty then -- lower set is empty, use `NoMinOrder` Exists.elim (exists_lt (Finset.min' hi nhi)) fun m hm ↦ ⟨m, fun x hx ↦ (nlo ⟨x, hx⟩).elim, fun y hy ↦ lt_of_lt_of_le hm (Finset.min'_le hi y hy)⟩ else -- both sets are empty, use `Nonempty` nonem.elim fun m ↦ ⟨m, fun x hx ↦ (nlo ⟨x, hx⟩).elim, fun y hy ↦ (nhi ⟨y, hy⟩).elim⟩ #align order.exists_between_finsets Order.exists_between_finsets variable (α β : Type*) [LinearOrder α] [LinearOrder β] -- Porting note: Mathport warning: expanding binder collection (p q «expr ∈ » f) def PartialIso : Type _ := { f : Finset (α × β) // ∀ p ∈ f, ∀ q ∈ f, cmp (Prod.fst p) (Prod.fst q) = cmp (Prod.snd p) (Prod.snd q) } #align order.partial_iso Order.PartialIso namespace PartialIso instance : Inhabited (PartialIso α β) := ⟨⟨∅, fun _p h _q ↦ (Finset.not_mem_empty _ h).elim⟩⟩ instance : Preorder (PartialIso α β) := Subtype.preorder _ variable {α β}
Mathlib/Order/CountableDenseLinearOrder.lean
94
122
theorem exists_across [DenselyOrdered β] [NoMinOrder β] [NoMaxOrder β] [Nonempty β] (f : PartialIso α β) (a : α) : ∃ b : β, ∀ p ∈ f.val, cmp (Prod.fst p) a = cmp (Prod.snd p) b := by
by_cases h : ∃ b, (a, b) ∈ f.val · cases' h with b hb exact ⟨b, fun p hp ↦ f.prop _ hp _ hb⟩ have : ∀ x ∈ (f.val.filter fun p : α × β ↦ p.fst < a).image Prod.snd, ∀ y ∈ (f.val.filter fun p : α × β ↦ a < p.fst).image Prod.snd, x < y := by intro x hx y hy rw [Finset.mem_image] at hx hy rcases hx with ⟨p, hp1, rfl⟩ rcases hy with ⟨q, hq1, rfl⟩ rw [Finset.mem_filter] at hp1 hq1 rw [← lt_iff_lt_of_cmp_eq_cmp (f.prop _ hp1.1 _ hq1.1)] exact lt_trans hp1.right hq1.right cases' exists_between_finsets _ _ this with b hb use b rintro ⟨p1, p2⟩ hp have : p1 ≠ a := fun he ↦ h ⟨p2, he ▸ hp⟩ cases' lt_or_gt_of_ne this with hl hr · have : p1 < a ∧ p2 < b := ⟨hl, hb.1 _ (Finset.mem_image.mpr ⟨(p1, p2), Finset.mem_filter.mpr ⟨hp, hl⟩, rfl⟩)⟩ rw [← cmp_eq_lt_iff, ← cmp_eq_lt_iff] at this exact this.1.trans this.2.symm · have : a < p1 ∧ b < p2 := ⟨hr, hb.2 _ (Finset.mem_image.mpr ⟨(p1, p2), Finset.mem_filter.mpr ⟨hp, hr⟩, rfl⟩)⟩ rw [← cmp_eq_gt_iff, ← cmp_eq_gt_iff] at this exact this.1.trans this.2.symm
26
import Mathlib.Data.Real.Cardinality import Mathlib.Topology.Separation import Mathlib.Topology.TietzeExtension open Set Function Cardinal Topology TopologicalSpace universe u variable {X : Type u} [TopologicalSpace X] [SeparableSpace X]
Mathlib/Topology/Separation/NotNormal.lean
26
53
theorem IsClosed.mk_lt_continuum [NormalSpace X] {s : Set X} (hs : IsClosed s) [DiscreteTopology s] : #s < 𝔠 := by
-- Proof by contradiction: assume `𝔠 ≤ #s` by_contra! h -- Choose a countable dense set `t : Set X` rcases exists_countable_dense X with ⟨t, htc, htd⟩ haveI := htc.to_subtype -- To obtain a contradiction, we will prove `2 ^ 𝔠 ≤ 𝔠`. refine (Cardinal.cantor 𝔠).not_le ?_ calc -- Any function `s → ℝ` is continuous, hence `2 ^ 𝔠 ≤ #C(s, ℝ)` 2 ^ 𝔠 ≤ #C(s, ℝ) := by rw [(ContinuousMap.equivFnOfDiscrete _ _).cardinal_eq, mk_arrow, mk_real, lift_continuum, lift_uzero] exact (power_le_power_left two_ne_zero h).trans (power_le_power_right (nat_lt_continuum 2).le) -- By the Tietze Extension Theorem, any function `f : C(s, ℝ)` can be extended to `C(X, ℝ)`, -- hence `#C(s, ℝ) ≤ #C(X, ℝ)` _ ≤ #C(X, ℝ) := by choose f hf using ContinuousMap.exists_restrict_eq (Y := ℝ) hs have hfi : Injective f := LeftInverse.injective hf exact mk_le_of_injective hfi -- Since `t` is dense, restriction `C(X, ℝ) → C(t, ℝ)` is injective, hence `#C(X, ℝ) ≤ #C(t, ℝ)` _ ≤ #C(t, ℝ) := mk_le_of_injective <| ContinuousMap.injective_restrict htd _ ≤ #(t → ℝ) := mk_le_of_injective DFunLike.coe_injective -- Since `t` is countable, we have `#(t → ℝ) ≤ 𝔠` _ ≤ 𝔠 := by rw [mk_arrow, mk_real, lift_uzero, lift_continuum, continuum, ← power_mul] exact power_le_power_left two_ne_zero mk_le_aleph0
26
import Mathlib.AlgebraicTopology.DoldKan.PInfty #align_import algebraic_topology.dold_kan.decomposition from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504" open CategoryTheory CategoryTheory.Category CategoryTheory.Preadditive Opposite Simplicial noncomputable section namespace AlgebraicTopology namespace DoldKan variable {C : Type*} [Category C] [Preadditive C] {X X' : SimplicialObject C}
Mathlib/AlgebraicTopology/DoldKan/Decomposition.lean
52
81
theorem decomposition_Q (n q : ℕ) : ((Q q).f (n + 1) : X _[n + 1] ⟶ X _[n + 1]) = ∑ i ∈ Finset.filter (fun i : Fin (n + 1) => (i : ℕ) < q) Finset.univ, (P i).f (n + 1) ≫ X.δ i.rev.succ ≫ X.σ (Fin.rev i) := by
induction' q with q hq · simp only [Nat.zero_eq, Q_zero, HomologicalComplex.zero_f_apply, Nat.not_lt_zero, Finset.filter_False, Finset.sum_empty] · by_cases hqn : q + 1 ≤ n + 1 swap · rw [Q_is_eventually_constant (show n + 1 ≤ q by omega), hq] congr 1 ext ⟨x, hx⟩ simp only [Nat.succ_eq_add_one, Finset.mem_filter, Finset.mem_univ, true_and] omega · cases' Nat.le.dest (Nat.succ_le_succ_iff.mp hqn) with a ha rw [Q_succ, HomologicalComplex.sub_f_apply, HomologicalComplex.comp_f, hq] symm conv_rhs => rw [sub_eq_add_neg, add_comm] let q' : Fin (n + 1) := ⟨q, Nat.succ_le_iff.mp hqn⟩ rw [← @Finset.add_sum_erase _ _ _ _ _ _ q' (by simp)] congr · have hnaq' : n = a + q := by omega simp only [Fin.val_mk, (HigherFacesVanish.of_P q n).comp_Hσ_eq hnaq', q'.rev_eq hnaq', neg_neg] rfl · ext ⟨i, hi⟩ simp only [q', Nat.succ_eq_add_one, Nat.lt_succ_iff_lt_or_eq, Finset.mem_univ, forall_true_left, Finset.mem_filter, lt_self_iff_false, or_true, and_self, not_true, Finset.mem_erase, ne_eq, Fin.mk.injEq, true_and] aesop
26
import Mathlib.MeasureTheory.Integral.IntegralEqImproper #align_import measure_theory.integral.peak_function from "leanprover-community/mathlib"@"13b0d72fd8533ba459ac66e9a885e35ffabb32b2" open Set Filter MeasureTheory MeasureTheory.Measure TopologicalSpace Metric open scoped Topology ENNReal open Set variable {α E ι : Type*} {hm : MeasurableSpace α} {μ : Measure α} [TopologicalSpace α] [BorelSpace α] [NormedAddCommGroup E] [NormedSpace ℝ E] {g : α → E} {l : Filter ι} {x₀ : α} {s t : Set α} {φ : ι → α → ℝ} {a : E}
Mathlib/MeasureTheory/Integral/PeakFunction.lean
54
86
theorem integrableOn_peak_smul_of_integrableOn_of_tendsto (hs : MeasurableSet s) (h'st : t ∈ 𝓝[s] x₀) (hlφ : ∀ u : Set α, IsOpen u → x₀ ∈ u → TendstoUniformlyOn φ 0 l (s \ u)) (hiφ : Tendsto (fun i ↦ ∫ x in t, φ i x ∂μ) l (𝓝 1)) (h'iφ : ∀ᶠ i in l, AEStronglyMeasurable (φ i) (μ.restrict s)) (hmg : IntegrableOn g s μ) (hcg : Tendsto g (𝓝[s] x₀) (𝓝 a)) : ∀ᶠ i in l, IntegrableOn (fun x => φ i x • g x) s μ := by
obtain ⟨u, u_open, x₀u, ut, hu⟩ : ∃ u, IsOpen u ∧ x₀ ∈ u ∧ s ∩ u ⊆ t ∧ ∀ x ∈ u ∩ s, g x ∈ ball a 1 := by rcases mem_nhdsWithin.1 (Filter.inter_mem h'st (hcg (ball_mem_nhds _ zero_lt_one))) with ⟨u, u_open, x₀u, hu⟩ refine ⟨u, u_open, x₀u, ?_, hu.trans inter_subset_right⟩ rw [inter_comm] exact hu.trans inter_subset_left rw [tendsto_iff_norm_sub_tendsto_zero] at hiφ filter_upwards [tendstoUniformlyOn_iff.1 (hlφ u u_open x₀u) 1 zero_lt_one, (tendsto_order.1 hiφ).2 1 zero_lt_one, h'iφ] with i hi h'i h''i have I : IntegrableOn (φ i) t μ := .of_integral_ne_zero (fun h ↦ by simp [h] at h'i) have A : IntegrableOn (fun x => φ i x • g x) (s \ u) μ := by refine Integrable.smul_of_top_right (hmg.mono diff_subset le_rfl) ?_ apply memℒp_top_of_bound (h''i.mono_set diff_subset) 1 filter_upwards [self_mem_ae_restrict (hs.diff u_open.measurableSet)] with x hx simpa only [Pi.zero_apply, dist_zero_left] using (hi x hx).le have B : IntegrableOn (fun x => φ i x • g x) (s ∩ u) μ := by apply Integrable.smul_of_top_left · exact IntegrableOn.mono_set I ut · apply memℒp_top_of_bound (hmg.mono_set inter_subset_left).aestronglyMeasurable (‖a‖ + 1) filter_upwards [self_mem_ae_restrict (hs.inter u_open.measurableSet)] with x hx rw [inter_comm] at hx exact (norm_lt_of_mem_ball (hu x hx)).le convert A.union B simp only [diff_union_inter]
26
import Mathlib.Algebra.Group.Subgroup.Basic import Mathlib.Algebra.Order.Archimedean import Mathlib.Data.Set.Lattice #align_import group_theory.archimedean from "leanprover-community/mathlib"@"f93c11933efbc3c2f0299e47b8ff83e9b539cbf6" open Set variable {G : Type*} [LinearOrderedAddCommGroup G] [Archimedean G] theorem AddSubgroup.cyclic_of_min {H : AddSubgroup G} {a : G} (ha : IsLeast { g : G | g ∈ H ∧ 0 < g } a) : H = AddSubgroup.closure {a} := by obtain ⟨⟨a_in, a_pos⟩, a_min⟩ := ha refine le_antisymm ?_ (H.closure_le.mpr <| by simp [a_in]) intro g g_in obtain ⟨k, ⟨nonneg, lt⟩, _⟩ := existsUnique_zsmul_near_of_pos' a_pos g have h_zero : g - k • a = 0 := by by_contra h have h : a ≤ g - k • a := by refine a_min ⟨?_, ?_⟩ · exact AddSubgroup.sub_mem H g_in (AddSubgroup.zsmul_mem H a_in k) · exact lt_of_le_of_ne nonneg (Ne.symm h) have h' : ¬a ≤ g - k • a := not_le.mpr lt contradiction simp [sub_eq_zero.mp h_zero, AddSubgroup.mem_closure_singleton] #align add_subgroup.cyclic_of_min AddSubgroup.cyclic_of_min
Mathlib/GroupTheory/Archimedean.lean
60
87
theorem AddSubgroup.exists_isLeast_pos {H : AddSubgroup G} (hbot : H ≠ ⊥) {a : G} (h₀ : 0 < a) (hd : Disjoint (H : Set G) (Ioo 0 a)) : ∃ b, IsLeast { g : G | g ∈ H ∧ 0 < g } b := by
-- todo: move to a lemma? have hex : ∀ g > 0, ∃ n : ℕ, g ∈ Ioc (n • a) ((n + 1) • a) := fun g hg => by rcases existsUnique_add_zsmul_mem_Ico h₀ 0 (g - a) with ⟨m, ⟨hm, hm'⟩, -⟩ simp only [zero_add, sub_le_iff_le_add, sub_add_cancel, ← add_one_zsmul] at hm hm' lift m to ℕ · rw [← Int.lt_add_one_iff, ← zsmul_lt_zsmul_iff h₀, zero_zsmul] exact hg.trans_le hm · simp only [← Nat.cast_succ, natCast_zsmul] at hm hm' exact ⟨m, hm', hm⟩ have : ∃ n : ℕ, Set.Nonempty (H ∩ Ioc (n • a) ((n + 1) • a)) := by rcases (bot_or_exists_ne_zero H).resolve_left hbot with ⟨g, hgH, hg₀⟩ rcases hex |g| (abs_pos.2 hg₀) with ⟨n, hn⟩ exact ⟨n, _, (@abs_mem_iff (AddSubgroup G) G _ _).2 hgH, hn⟩ classical rcases Nat.findX this with ⟨n, ⟨x, hxH, hnx, hxn⟩, hmin⟩ by_contra hxmin simp only [IsLeast, not_and, mem_setOf_eq, mem_lowerBounds, not_exists, not_forall, not_le] at hxmin rcases hxmin x ⟨hxH, (nsmul_nonneg h₀.le _).trans_lt hnx⟩ with ⟨y, ⟨hyH, hy₀⟩, hxy⟩ rcases hex y hy₀ with ⟨m, hm⟩ cases' lt_or_le m n with hmn hnm · exact hmin m hmn ⟨y, hyH, hm⟩ · refine disjoint_left.1 hd (sub_mem hxH hyH) ⟨sub_pos.2 hxy, sub_lt_iff_lt_add'.2 ?_⟩ calc x ≤ (n + 1) • a := hxn _ ≤ (m + 1) • a := nsmul_le_nsmul_left h₀.le (add_le_add_right hnm _) _ = m • a + a := succ_nsmul _ _ _ < y + a := add_lt_add_right hm.1 _
26
import Mathlib.Data.Nat.Choose.Central import Mathlib.Data.Nat.Factorization.Basic import Mathlib.Data.Nat.Multiplicity #align_import data.nat.choose.factorization from "leanprover-community/mathlib"@"dc9db541168768af03fe228703e758e649afdbfc" namespace Nat variable {p n k : ℕ} theorem factorization_choose_le_log : (choose n k).factorization p ≤ log p n := by by_cases h : (choose n k).factorization p = 0 · simp [h] have hp : p.Prime := Not.imp_symm (choose n k).factorization_eq_zero_of_non_prime h have hkn : k ≤ n := by refine le_of_not_lt fun hnk => h ?_ simp [choose_eq_zero_of_lt hnk] rw [factorization_def _ hp, @padicValNat_def _ ⟨hp⟩ _ (choose_pos hkn)] simp only [hp.multiplicity_choose hkn (lt_add_one _), PartENat.get_natCast] exact (Finset.card_filter_le _ _).trans (le_of_eq (Nat.card_Ico _ _)) #align nat.factorization_choose_le_log Nat.factorization_choose_le_log theorem pow_factorization_choose_le (hn : 0 < n) : p ^ (choose n k).factorization p ≤ n := pow_le_of_le_log hn.ne' factorization_choose_le_log #align nat.pow_factorization_choose_le Nat.pow_factorization_choose_le theorem factorization_choose_le_one (p_large : n < p ^ 2) : (choose n k).factorization p ≤ 1 := by apply factorization_choose_le_log.trans rcases eq_or_ne n 0 with (rfl | hn0); · simp exact Nat.lt_succ_iff.1 (log_lt_of_lt_pow hn0 p_large) #align nat.factorization_choose_le_one Nat.factorization_choose_le_one
Mathlib/Data/Nat/Choose/Factorization.lean
61
88
theorem factorization_choose_of_lt_three_mul (hp' : p ≠ 2) (hk : p ≤ k) (hk' : p ≤ n - k) (hn : n < 3 * p) : (choose n k).factorization p = 0 := by
cases' em' p.Prime with hp hp · exact factorization_eq_zero_of_non_prime (choose n k) hp cases' lt_or_le n k with hnk hkn · simp [choose_eq_zero_of_lt hnk] rw [factorization_def _ hp, @padicValNat_def _ ⟨hp⟩ _ (choose_pos hkn)] simp only [hp.multiplicity_choose hkn (lt_add_one _), PartENat.get_natCast, Finset.card_eq_zero, Finset.filter_eq_empty_iff, not_le] intro i hi rcases eq_or_lt_of_le (Finset.mem_Ico.mp hi).1 with (rfl | hi) · rw [pow_one, ← add_lt_add_iff_left (2 * p), ← succ_mul, two_mul, add_add_add_comm] exact lt_of_le_of_lt (add_le_add (add_le_add_right (le_mul_of_one_le_right' ((one_le_div_iff hp.pos).mpr hk)) (k % p)) (add_le_add_right (le_mul_of_one_le_right' ((one_le_div_iff hp.pos).mpr hk')) ((n - k) % p))) (by rwa [div_add_mod, div_add_mod, add_tsub_cancel_of_le hkn]) · replace hn : n < p ^ i := by have : 3 ≤ p := lt_of_le_of_ne hp.two_le hp'.symm calc n < 3 * p := hn _ ≤ p * p := mul_le_mul_right' this p _ = p ^ 2 := (sq p).symm _ ≤ p ^ i := pow_le_pow_right hp.one_lt.le hi rwa [mod_eq_of_lt (lt_of_le_of_lt hkn hn), mod_eq_of_lt (lt_of_le_of_lt tsub_le_self hn), add_tsub_cancel_of_le hkn]
26
import Mathlib.Probability.Kernel.MeasurableIntegral #align_import probability.kernel.composition from "leanprover-community/mathlib"@"3b92d54a05ee592aa2c6181a4e76b1bb7cc45d0b" open MeasureTheory open scoped ENNReal namespace ProbabilityTheory namespace kernel variable {α β ι : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} section CompositionProduct variable {γ : Type*} {mγ : MeasurableSpace γ} {s : Set (β × γ)} noncomputable def compProdFun (κ : kernel α β) (η : kernel (α × β) γ) (a : α) (s : Set (β × γ)) : ℝ≥0∞ := ∫⁻ b, η (a, b) {c | (b, c) ∈ s} ∂κ a #align probability_theory.kernel.comp_prod_fun ProbabilityTheory.kernel.compProdFun theorem compProdFun_empty (κ : kernel α β) (η : kernel (α × β) γ) (a : α) : compProdFun κ η a ∅ = 0 := by simp only [compProdFun, Set.mem_empty_iff_false, Set.setOf_false, measure_empty, MeasureTheory.lintegral_const, zero_mul] #align probability_theory.kernel.comp_prod_fun_empty ProbabilityTheory.kernel.compProdFun_empty
Mathlib/Probability/Kernel/Composition.lean
99
128
theorem compProdFun_iUnion (κ : kernel α β) (η : kernel (α × β) γ) [IsSFiniteKernel η] (a : α) (f : ℕ → Set (β × γ)) (hf_meas : ∀ i, MeasurableSet (f i)) (hf_disj : Pairwise (Disjoint on f)) : compProdFun κ η a (⋃ i, f i) = ∑' i, compProdFun κ η a (f i) := by
have h_Union : (fun b => η (a, b) {c : γ | (b, c) ∈ ⋃ i, f i}) = fun b => η (a, b) (⋃ i, {c : γ | (b, c) ∈ f i}) := by ext1 b congr with c simp only [Set.mem_iUnion, Set.iSup_eq_iUnion, Set.mem_setOf_eq] rw [compProdFun, h_Union] have h_tsum : (fun b => η (a, b) (⋃ i, {c : γ | (b, c) ∈ f i})) = fun b => ∑' i, η (a, b) {c : γ | (b, c) ∈ f i} := by ext1 b rw [measure_iUnion] · intro i j hij s hsi hsj c hcs have hbci : {(b, c)} ⊆ f i := by rw [Set.singleton_subset_iff]; exact hsi hcs have hbcj : {(b, c)} ⊆ f j := by rw [Set.singleton_subset_iff]; exact hsj hcs simpa only [Set.bot_eq_empty, Set.le_eq_subset, Set.singleton_subset_iff, Set.mem_empty_iff_false] using hf_disj hij hbci hbcj · -- Porting note: behavior of `@` changed relative to lean 3, was -- exact fun i => (@measurable_prod_mk_left β γ _ _ b) _ (hf_meas i) exact fun i => (@measurable_prod_mk_left β γ _ _ b) (hf_meas i) rw [h_tsum, lintegral_tsum] · rfl · intro i have hm : MeasurableSet {p : (α × β) × γ | (p.1.2, p.2) ∈ f i} := measurable_fst.snd.prod_mk measurable_snd (hf_meas i) exact ((measurable_kernel_prod_mk_left hm).comp measurable_prod_mk_left).aemeasurable
26
import Mathlib.Probability.Martingale.Upcrossing import Mathlib.MeasureTheory.Function.UniformIntegrable import Mathlib.MeasureTheory.Constructions.Polish #align_import probability.martingale.convergence from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open TopologicalSpace Filter MeasureTheory.Filtration open scoped NNReal ENNReal MeasureTheory ProbabilityTheory Topology namespace MeasureTheory variable {Ω ι : Type*} {m0 : MeasurableSpace Ω} {μ : Measure Ω} {ℱ : Filtration ℕ m0} variable {a b : ℝ} {f : ℕ → Ω → ℝ} {ω : Ω} {R : ℝ≥0} section AeConvergence theorem not_frequently_of_upcrossings_lt_top (hab : a < b) (hω : upcrossings a b f ω ≠ ∞) : ¬((∃ᶠ n in atTop, f n ω < a) ∧ ∃ᶠ n in atTop, b < f n ω) := by rw [← lt_top_iff_ne_top, upcrossings_lt_top_iff] at hω replace hω : ∃ k, ∀ N, upcrossingsBefore a b f N ω < k := by obtain ⟨k, hk⟩ := hω exact ⟨k + 1, fun N => lt_of_le_of_lt (hk N) k.lt_succ_self⟩ rintro ⟨h₁, h₂⟩ rw [frequently_atTop] at h₁ h₂ refine Classical.not_not.2 hω ?_ push_neg intro k induction' k with k ih · simp only [Nat.zero_eq, zero_le, exists_const] · obtain ⟨N, hN⟩ := ih obtain ⟨N₁, hN₁, hN₁'⟩ := h₁ N obtain ⟨N₂, hN₂, hN₂'⟩ := h₂ N₁ exact ⟨N₂ + 1, Nat.succ_le_of_lt <| lt_of_le_of_lt hN (upcrossingsBefore_lt_of_exists_upcrossing hab hN₁ hN₁' hN₂ hN₂')⟩ #align measure_theory.not_frequently_of_upcrossings_lt_top MeasureTheory.not_frequently_of_upcrossings_lt_top theorem upcrossings_eq_top_of_frequently_lt (hab : a < b) (h₁ : ∃ᶠ n in atTop, f n ω < a) (h₂ : ∃ᶠ n in atTop, b < f n ω) : upcrossings a b f ω = ∞ := by_contradiction fun h => not_frequently_of_upcrossings_lt_top hab h ⟨h₁, h₂⟩ #align measure_theory.upcrossings_eq_top_of_frequently_lt MeasureTheory.upcrossings_eq_top_of_frequently_lt theorem tendsto_of_uncrossing_lt_top (hf₁ : liminf (fun n => (‖f n ω‖₊ : ℝ≥0∞)) atTop < ∞) (hf₂ : ∀ a b : ℚ, a < b → upcrossings a b f ω < ∞) : ∃ c, Tendsto (fun n => f n ω) atTop (𝓝 c) := by by_cases h : IsBoundedUnder (· ≤ ·) atTop fun n => |f n ω| · rw [isBoundedUnder_le_abs] at h refine tendsto_of_no_upcrossings Rat.denseRange_cast ?_ h.1 h.2 intro a ha b hb hab obtain ⟨⟨a, rfl⟩, ⟨b, rfl⟩⟩ := ha, hb exact not_frequently_of_upcrossings_lt_top hab (hf₂ a b (Rat.cast_lt.1 hab)).ne · obtain ⟨a, b, hab, h₁, h₂⟩ := ENNReal.exists_upcrossings_of_not_bounded_under hf₁.ne h exact False.elim ((hf₂ a b hab).ne (upcrossings_eq_top_of_frequently_lt (Rat.cast_lt.2 hab) h₁ h₂)) #align measure_theory.tendsto_of_uncrossing_lt_top MeasureTheory.tendsto_of_uncrossing_lt_top
Mathlib/Probability/Martingale/Convergence.lean
156
183
theorem Submartingale.upcrossings_ae_lt_top' [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ) (hbdd : ∀ n, snorm (f n) 1 μ ≤ R) (hab : a < b) : ∀ᵐ ω ∂μ, upcrossings a b f ω < ∞ := by
refine ae_lt_top (hf.adapted.measurable_upcrossings hab) ?_ have := hf.mul_lintegral_upcrossings_le_lintegral_pos_part a b rw [mul_comm, ← ENNReal.le_div_iff_mul_le] at this · refine (lt_of_le_of_lt this (ENNReal.div_lt_top ?_ ?_)).ne · have hR' : ∀ n, ∫⁻ ω, ‖f n ω - a‖₊ ∂μ ≤ R + ‖a‖₊ * μ Set.univ := by simp_rw [snorm_one_eq_lintegral_nnnorm] at hbdd intro n refine (lintegral_mono ?_ : ∫⁻ ω, ‖f n ω - a‖₊ ∂μ ≤ ∫⁻ ω, ‖f n ω‖₊ + ‖a‖₊ ∂μ).trans ?_ · intro ω simp_rw [sub_eq_add_neg, ← nnnorm_neg a, ← ENNReal.coe_add, ENNReal.coe_le_coe] exact nnnorm_add_le _ _ · simp_rw [lintegral_add_right _ measurable_const, lintegral_const] exact add_le_add (hbdd _) le_rfl refine ne_of_lt (iSup_lt_iff.2 ⟨R + ‖a‖₊ * μ Set.univ, ENNReal.add_lt_top.2 ⟨ENNReal.coe_lt_top, ENNReal.mul_lt_top ENNReal.coe_lt_top.ne (measure_ne_top _ _)⟩, fun n => le_trans ?_ (hR' n)⟩) refine lintegral_mono fun ω => ?_ rw [ENNReal.ofReal_le_iff_le_toReal, ENNReal.coe_toReal, coe_nnnorm] · by_cases hnonneg : 0 ≤ f n ω - a · rw [posPart_eq_self.2 hnonneg, Real.norm_eq_abs, abs_of_nonneg hnonneg] · rw [posPart_eq_zero.2 (not_le.1 hnonneg).le] exact norm_nonneg _ · simp only [Ne, ENNReal.coe_ne_top, not_false_iff] · simp only [hab, Ne, ENNReal.ofReal_eq_zero, sub_nonpos, not_le] · simp only [hab, Ne, ENNReal.ofReal_eq_zero, sub_nonpos, not_le, true_or_iff] · simp only [Ne, ENNReal.ofReal_ne_top, not_false_iff, true_or_iff]
26
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
26
import Mathlib.MeasureTheory.Measure.Haar.Basic import Mathlib.Analysis.InnerProductSpace.PiL2 #align_import measure_theory.measure.haar.of_basis from "leanprover-community/mathlib"@"92bd7b1ffeb306a89f450bee126ddd8a284c259d" open Set TopologicalSpace MeasureTheory MeasureTheory.Measure FiniteDimensional open scoped Pointwise noncomputable section variable {ι ι' E F : Type*} section Fintype variable [Fintype ι] [Fintype ι'] section AddCommGroup variable [AddCommGroup E] [Module ℝ E] [AddCommGroup F] [Module ℝ F] def parallelepiped (v : ι → E) : Set E := (fun t : ι → ℝ => ∑ i, t i • v i) '' Icc 0 1 #align parallelepiped parallelepiped theorem mem_parallelepiped_iff (v : ι → E) (x : E) : x ∈ parallelepiped v ↔ ∃ t ∈ Icc (0 : ι → ℝ) 1, x = ∑ i, t i • v i := by simp [parallelepiped, eq_comm] #align mem_parallelepiped_iff mem_parallelepiped_iff theorem parallelepiped_basis_eq (b : Basis ι ℝ E) : parallelepiped b = {x | ∀ i, b.repr x i ∈ Set.Icc 0 1} := by classical ext x simp_rw [mem_parallelepiped_iff, mem_setOf_eq, b.ext_elem_iff, _root_.map_sum, _root_.map_smul, Finset.sum_apply', Basis.repr_self, Finsupp.smul_single, smul_eq_mul, mul_one, Finsupp.single_apply, Finset.sum_ite_eq', Finset.mem_univ, ite_true, mem_Icc, Pi.le_def, Pi.zero_apply, Pi.one_apply, ← forall_and] aesop theorem image_parallelepiped (f : E →ₗ[ℝ] F) (v : ι → E) : f '' parallelepiped v = parallelepiped (f ∘ v) := by simp only [parallelepiped, ← image_comp] congr 1 with t simp only [Function.comp_apply, _root_.map_sum, LinearMap.map_smulₛₗ, RingHom.id_apply] #align image_parallelepiped image_parallelepiped @[simp] theorem parallelepiped_comp_equiv (v : ι → E) (e : ι' ≃ ι) : parallelepiped (v ∘ e) = parallelepiped v := by simp only [parallelepiped] let K : (ι' → ℝ) ≃ (ι → ℝ) := Equiv.piCongrLeft' (fun _a : ι' => ℝ) e have : Icc (0 : ι → ℝ) 1 = K '' Icc (0 : ι' → ℝ) 1 := by rw [← Equiv.preimage_eq_iff_eq_image] ext x simp only [K, mem_preimage, mem_Icc, Pi.le_def, Pi.zero_apply, Equiv.piCongrLeft'_apply, Pi.one_apply] refine ⟨fun h => ⟨fun i => ?_, fun i => ?_⟩, fun h => ⟨fun i => h.1 (e.symm i), fun i => h.2 (e.symm i)⟩⟩ · simpa only [Equiv.symm_apply_apply] using h.1 (e i) · simpa only [Equiv.symm_apply_apply] using h.2 (e i) rw [this, ← image_comp] congr 1 with x have := fun z : ι' → ℝ => e.symm.sum_comp fun i => z i • v (e i) simp_rw [Equiv.apply_symm_apply] at this simp_rw [Function.comp_apply, mem_image, mem_Icc, K, Equiv.piCongrLeft'_apply, this] #align parallelepiped_comp_equiv parallelepiped_comp_equiv -- The parallelepiped associated to an orthonormal basis of `ℝ` is either `[0, 1]` or `[-1, 0]`.
Mathlib/MeasureTheory/Measure/Haar/OfBasis.lean
98
125
theorem parallelepiped_orthonormalBasis_one_dim (b : OrthonormalBasis ι ℝ ℝ) : parallelepiped b = Icc 0 1 ∨ parallelepiped b = Icc (-1) 0 := by
have e : ι ≃ Fin 1 := by apply Fintype.equivFinOfCardEq simp only [← finrank_eq_card_basis b.toBasis, finrank_self] have B : parallelepiped (b.reindex e) = parallelepiped b := by convert parallelepiped_comp_equiv b e.symm ext i simp only [OrthonormalBasis.coe_reindex] rw [← B] let F : ℝ → Fin 1 → ℝ := fun t => fun _i => t have A : Icc (0 : Fin 1 → ℝ) 1 = F '' Icc (0 : ℝ) 1 := by apply Subset.antisymm · intro x hx refine ⟨x 0, ⟨hx.1 0, hx.2 0⟩, ?_⟩ ext j simp only [Subsingleton.elim j 0] · rintro x ⟨y, hy, rfl⟩ exact ⟨fun _j => hy.1, fun _j => hy.2⟩ rcases orthonormalBasis_one_dim (b.reindex e) with (H | H) · left simp_rw [parallelepiped, H, A, Algebra.id.smul_eq_mul, mul_one] simp only [Finset.univ_unique, Fin.default_eq_zero, smul_eq_mul, mul_one, Finset.sum_singleton, ← image_comp, Function.comp_apply, image_id', ge_iff_le, zero_le_one, not_true, gt_iff_lt] · right simp_rw [H, parallelepiped, Algebra.id.smul_eq_mul, A] simp only [F, Finset.univ_unique, Fin.default_eq_zero, mul_neg, mul_one, Finset.sum_neg_distrib, Finset.sum_singleton, ← image_comp, Function.comp, image_neg, preimage_neg_Icc, neg_zero]
26
import Mathlib.AlgebraicGeometry.PrimeSpectrum.Basic import Mathlib.Topology.NoetherianSpace #align_import algebraic_geometry.prime_spectrum.noetherian from "leanprover-community/mathlib"@"052f6013363326d50cb99c6939814a4b8eb7b301" universe u v namespace PrimeSpectrum open Submodule variable (R : Type u) [CommRing R] [IsNoetherianRing R] variable {A : Type u} [CommRing A] [IsDomain A] [IsNoetherianRing A]
Mathlib/AlgebraicGeometry/PrimeSpectrum/Noetherian.lean
27
54
theorem exists_primeSpectrum_prod_le (I : Ideal R) : ∃ Z : Multiset (PrimeSpectrum R), Multiset.prod (Z.map asIdeal) ≤ I := by
-- Porting note: Need to specify `P` explicitly refine IsNoetherian.induction (P := fun I => ∃ Z : Multiset (PrimeSpectrum R), Multiset.prod (Z.map asIdeal) ≤ I) (fun (M : Ideal R) hgt => ?_) I by_cases h_prM : M.IsPrime · use {⟨M, h_prM⟩} rw [Multiset.map_singleton, Multiset.prod_singleton] by_cases htop : M = ⊤ · rw [htop] exact ⟨0, le_top⟩ have lt_add : ∀ z ∉ M, M < M + span R {z} := by intro z hz refine lt_of_le_of_ne le_sup_left fun m_eq => hz ?_ rw [m_eq] exact Ideal.mem_sup_right (mem_span_singleton_self z) obtain ⟨x, hx, y, hy, hxy⟩ := (Ideal.not_isPrime_iff.mp h_prM).resolve_left htop obtain ⟨Wx, h_Wx⟩ := hgt (M + span R {x}) (lt_add _ hx) obtain ⟨Wy, h_Wy⟩ := hgt (M + span R {y}) (lt_add _ hy) use Wx + Wy rw [Multiset.map_add, Multiset.prod_add] apply le_trans (Submodule.mul_le_mul h_Wx h_Wy) rw [add_mul] apply sup_le (show M * (M + span R {y}) ≤ M from Ideal.mul_le_right) rw [mul_add] apply sup_le (show span R {x} * M ≤ M from Ideal.mul_le_left) rwa [span_mul_span, Set.singleton_mul_singleton, span_singleton_le_iff_mem]
26
import Mathlib.RingTheory.PrincipalIdealDomain import Mathlib.RingTheory.Ideal.LocalRing import Mathlib.RingTheory.Valuation.PrimeMultiplicity import Mathlib.RingTheory.AdicCompletion.Basic #align_import ring_theory.discrete_valuation_ring.basic from "leanprover-community/mathlib"@"c163ec99dfc664628ca15d215fce0a5b9c265b68" open scoped Classical universe u open Ideal LocalRing class DiscreteValuationRing (R : Type u) [CommRing R] [IsDomain R] extends IsPrincipalIdealRing R, LocalRing R : Prop where not_a_field' : maximalIdeal R ≠ ⊥ #align discrete_valuation_ring DiscreteValuationRing namespace DiscreteValuationRing variable (R : Type u) [CommRing R] [IsDomain R] [DiscreteValuationRing R] theorem not_a_field : maximalIdeal R ≠ ⊥ := not_a_field' #align discrete_valuation_ring.not_a_field DiscreteValuationRing.not_a_field theorem not_isField : ¬IsField R := LocalRing.isField_iff_maximalIdeal_eq.not.mpr (not_a_field R) #align discrete_valuation_ring.not_is_field DiscreteValuationRing.not_isField variable {R} open PrincipalIdealRing theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R] (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ refine ⟨h2, ?_⟩ intro a b hab by_contra! h obtain ⟨ha : a ∈ maximalIdeal R, hb : b ∈ maximalIdeal R⟩ := h rw [h, mem_span_singleton'] at ha hb rcases ha with ⟨a, rfl⟩ rcases hb with ⟨b, rfl⟩ rw [show a * ϖ * (b * ϖ) = ϖ * (ϖ * (a * b)) by ring] at hab apply hϖ apply eq_zero_of_mul_eq_self_right _ hab.symm exact fun hh => h2 (isUnit_of_dvd_one ⟨_, hh.symm⟩) #align discrete_valuation_ring.irreducible_of_span_eq_maximal_ideal DiscreteValuationRing.irreducible_of_span_eq_maximalIdeal theorem irreducible_iff_uniformizer (ϖ : R) : Irreducible ϖ ↔ maximalIdeal R = Ideal.span {ϖ} := ⟨fun hϖ => (eq_maximalIdeal (isMaximal_of_irreducible hϖ)).symm, fun h => irreducible_of_span_eq_maximalIdeal ϖ (fun e => not_a_field R <| by rwa [h, span_singleton_eq_bot]) h⟩ #align discrete_valuation_ring.irreducible_iff_uniformizer DiscreteValuationRing.irreducible_iff_uniformizer theorem _root_.Irreducible.maximalIdeal_eq {ϖ : R} (h : Irreducible ϖ) : maximalIdeal R = Ideal.span {ϖ} := (irreducible_iff_uniformizer _).mp h #align irreducible.maximal_ideal_eq Irreducible.maximalIdeal_eq variable (R) theorem exists_irreducible : ∃ ϖ : R, Irreducible ϖ := by simp_rw [irreducible_iff_uniformizer] exact (IsPrincipalIdealRing.principal <| maximalIdeal R).principal #align discrete_valuation_ring.exists_irreducible DiscreteValuationRing.exists_irreducible theorem exists_prime : ∃ ϖ : R, Prime ϖ := (exists_irreducible R).imp fun _ => irreducible_iff_prime.1 #align discrete_valuation_ring.exists_prime DiscreteValuationRing.exists_prime
Mathlib/RingTheory/DiscreteValuationRing/Basic.lean
118
145
theorem iff_pid_with_one_nonzero_prime (R : Type u) [CommRing R] [IsDomain R] : DiscreteValuationRing R ↔ IsPrincipalIdealRing R ∧ ∃! P : Ideal R, P ≠ ⊥ ∧ IsPrime P := by
constructor · intro RDVR rcases id RDVR with ⟨Rlocal⟩ constructor · assumption use LocalRing.maximalIdeal R constructor · exact ⟨Rlocal, inferInstance⟩ · rintro Q ⟨hQ1, hQ2⟩ obtain ⟨q, rfl⟩ := (IsPrincipalIdealRing.principal Q).1 have hq : q ≠ 0 := by rintro rfl apply hQ1 simp erw [span_singleton_prime hq] at hQ2 replace hQ2 := hQ2.irreducible rw [irreducible_iff_uniformizer] at hQ2 exact hQ2.symm · rintro ⟨RPID, Punique⟩ haveI : LocalRing R := LocalRing.of_unique_nonzero_prime Punique refine { not_a_field' := ?_ } rcases Punique with ⟨P, ⟨hP1, hP2⟩, _⟩ have hPM : P ≤ maximalIdeal R := le_maximalIdeal hP2.1 intro h rw [h, le_bot_iff] at hPM exact hP1 hPM
26
import Mathlib.Data.Fintype.Card import Mathlib.GroupTheory.Perm.Basic import Mathlib.Tactic.Ring #align_import data.fintype.perm from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226" open Function open Nat universe u v variable {α β γ : Type*} open Finset Function List Equiv Equiv.Perm variable [DecidableEq α] [DecidableEq β] def permsOfList : List α → List (Perm α) | [] => [1] | a :: l => permsOfList l ++ l.bind fun b => (permsOfList l).map fun f => Equiv.swap a b * f #align perms_of_list permsOfList theorem length_permsOfList : ∀ l : List α, length (permsOfList l) = l.length ! | [] => rfl | a :: l => by rw [length_cons, Nat.factorial_succ] simp only [permsOfList, length_append, length_permsOfList, length_bind, comp, length_map, map_const', sum_replicate, smul_eq_mul, succ_mul] ring #align length_perms_of_list length_permsOfList
Mathlib/Data/Fintype/Perm.lean
47
74
theorem mem_permsOfList_of_mem {l : List α} {f : Perm α} (h : ∀ x, f x ≠ x → x ∈ l) : f ∈ permsOfList l := by
induction l generalizing f with | nil => -- Porting note: applied `not_mem_nil` because it is no longer true definitionally. simp only [not_mem_nil] at h exact List.mem_singleton.2 (Equiv.ext fun x => Decidable.by_contradiction <| h x) | cons a l IH => by_cases hfa : f a = a · refine mem_append_left _ (IH fun x hx => mem_of_ne_of_mem ?_ (h x hx)) rintro rfl exact hx hfa have hfa' : f (f a) ≠ f a := mt (fun h => f.injective h) hfa have : ∀ x : α, (Equiv.swap a (f a) * f) x ≠ x → x ∈ l := by intro x hx have hxa : x ≠ a := by rintro rfl apply hx simp only [mul_apply, swap_apply_right] refine List.mem_of_ne_of_mem hxa (h x fun h => ?_) simp only [mul_apply, swap_apply_def, mul_apply, Ne, apply_eq_iff_eq] at hx split_ifs at hx with h_1 exacts [hxa (h.symm.trans h_1), hx h] suffices f ∈ permsOfList l ∨ ∃ b ∈ l, ∃ g ∈ permsOfList l, Equiv.swap a b * g = f by simpa only [permsOfList, exists_prop, List.mem_map, mem_append, List.mem_bind] refine or_iff_not_imp_left.2 fun _hfl => ⟨f a, ?_, Equiv.swap a (f a) * f, IH this, ?_⟩ · exact mem_of_ne_of_mem hfa (h _ hfa') · rw [← mul_assoc, mul_def (swap a (f a)) (swap a (f a)), swap_swap, ← Perm.one_def, one_mul]
26
import Mathlib.Topology.StoneCech import Mathlib.Topology.Algebra.Semigroup import Mathlib.Data.Stream.Init #align_import combinatorics.hindman from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" open Filter @[to_additive "Addition of ultrafilters given by `∀ᶠ m in U+V, p m ↔ ∀ᶠ m in U, ∀ᶠ m' in V, p (m+m')`."] def Ultrafilter.mul {M} [Mul M] : Mul (Ultrafilter M) where mul U V := (· * ·) <$> U <*> V #align ultrafilter.has_mul Ultrafilter.mul #align ultrafilter.has_add Ultrafilter.add attribute [local instance] Ultrafilter.mul Ultrafilter.add @[to_additive] theorem Ultrafilter.eventually_mul {M} [Mul M] (U V : Ultrafilter M) (p : M → Prop) : (∀ᶠ m in ↑(U * V), p m) ↔ ∀ᶠ m in U, ∀ᶠ m' in V, p (m * m') := Iff.rfl #align ultrafilter.eventually_mul Ultrafilter.eventually_mul #align ultrafilter.eventually_add Ultrafilter.eventually_add @[to_additive "Additive semigroup structure on `Ultrafilter M` induced by an additive semigroup structure on `M`."] def Ultrafilter.semigroup {M} [Semigroup M] : Semigroup (Ultrafilter M) := { Ultrafilter.mul with mul_assoc := fun U V W => Ultrafilter.coe_inj.mp <| -- porting note (#11083): `simp` was slow to typecheck, replaced by `simp_rw` Filter.ext' fun p => by simp_rw [Ultrafilter.eventually_mul, mul_assoc] } #align ultrafilter.semigroup Ultrafilter.semigroup #align ultrafilter.add_semigroup Ultrafilter.addSemigroup attribute [local instance] Ultrafilter.semigroup Ultrafilter.addSemigroup -- We don't prove `continuous_mul_right`, because in general it is false! @[to_additive] theorem Ultrafilter.continuous_mul_left {M} [Semigroup M] (V : Ultrafilter M) : Continuous (· * V) := ultrafilterBasis_is_basis.continuous_iff.2 <| Set.forall_mem_range.mpr fun s ↦ ultrafilter_isOpen_basic { m : M | ∀ᶠ m' in V, m * m' ∈ s } #align ultrafilter.continuous_mul_left Ultrafilter.continuous_mul_left #align ultrafilter.continuous_add_left Ultrafilter.continuous_add_left namespace Hindman -- Porting note: mathport wants these names to be `fS`, `fP`, etc, but this does violence to -- mathematical naming conventions, as does `fs`, `fp`, so we just followed `mathlib` 3 here inductive FS {M} [AddSemigroup M] : Stream' M → Set M | head (a : Stream' M) : FS a a.head | tail (a : Stream' M) (m : M) (h : FS a.tail m) : FS a m | cons (a : Stream' M) (m : M) (h : FS a.tail m) : FS a (a.head + m) set_option linter.uppercaseLean3 false in #align hindman.FS Hindman.FS @[to_additive FS] inductive FP {M} [Semigroup M] : Stream' M → Set M | head (a : Stream' M) : FP a a.head | tail (a : Stream' M) (m : M) (h : FP a.tail m) : FP a m | cons (a : Stream' M) (m : M) (h : FP a.tail m) : FP a (a.head * m) set_option linter.uppercaseLean3 false in #align hindman.FP Hindman.FP @[to_additive "If `m` and `m'` are finite sums in `M`, then so is `m + m'`, provided that `m'` is obtained from a subsequence of `M` starting sufficiently late."] theorem FP.mul {M} [Semigroup M] {a : Stream' M} {m : M} (hm : m ∈ FP a) : ∃ n, ∀ m' ∈ FP (a.drop n), m * m' ∈ FP a := by induction' hm with a a m hm ih a m hm ih · exact ⟨1, fun m hm => FP.cons a m hm⟩ · cases' ih with n hn use n + 1 intro m' hm' exact FP.tail _ _ (hn _ hm') · cases' ih with n hn use n + 1 intro m' hm' rw [mul_assoc] exact FP.cons _ _ (hn _ hm') set_option linter.uppercaseLean3 false in #align hindman.FP.mul Hindman.FP.mul set_option linter.uppercaseLean3 false in #align hindman.FS.add Hindman.FS.add @[to_additive exists_idempotent_ultrafilter_le_FS]
Mathlib/Combinatorics/Hindman.lean
138
165
theorem exists_idempotent_ultrafilter_le_FP {M} [Semigroup M] (a : Stream' M) : ∃ U : Ultrafilter M, U * U = U ∧ ∀ᶠ m in U, m ∈ FP a := by
let S : Set (Ultrafilter M) := ⋂ n, { U | ∀ᶠ m in U, m ∈ FP (a.drop n) } have h := exists_idempotent_in_compact_subsemigroup ?_ S ?_ ?_ ?_ · rcases h with ⟨U, hU, U_idem⟩ refine ⟨U, U_idem, ?_⟩ convert Set.mem_iInter.mp hU 0 · exact Ultrafilter.continuous_mul_left · apply IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed · intro n U hU filter_upwards [hU] rw [add_comm, ← Stream'.drop_drop, ← Stream'.tail_eq_drop] exact FP.tail _ · intro n exact ⟨pure _, mem_pure.mpr <| FP.head _⟩ · exact (ultrafilter_isClosed_basic _).isCompact · intro n apply ultrafilter_isClosed_basic · exact IsClosed.isCompact (isClosed_iInter fun i => ultrafilter_isClosed_basic _) · intro U hU V hV rw [Set.mem_iInter] at * intro n rw [Set.mem_setOf_eq, Ultrafilter.eventually_mul] filter_upwards [hU n] with m hm obtain ⟨n', hn⟩ := FP.mul hm filter_upwards [hV (n' + n)] with m' hm' apply hn simpa only [Stream'.drop_drop] using hm'
26
import Mathlib.RingTheory.DedekindDomain.Ideal import Mathlib.RingTheory.IsAdjoinRoot #align_import number_theory.kummer_dedekind from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" variable (R : Type*) {S : Type*} [CommRing R] [CommRing S] [Algebra R S] open Ideal Polynomial DoubleQuot UniqueFactorizationMonoid Algebra RingHom local notation:max R "<" x:max ">" => adjoin R ({x} : Set S) def conductor (x : S) : Ideal S where carrier := {a | ∀ b : S, a * b ∈ R<x>} zero_mem' b := by simpa only [zero_mul] using Subalgebra.zero_mem _ add_mem' ha hb c := by simpa only [add_mul] using Subalgebra.add_mem _ (ha c) (hb c) smul_mem' c a ha b := by simpa only [smul_eq_mul, mul_left_comm, mul_assoc] using ha (c * b) #align conductor conductor variable {R} {x : S} theorem conductor_eq_of_eq {y : S} (h : (R<x> : Set S) = R<y>) : conductor R x = conductor R y := Ideal.ext fun _ => forall_congr' fun _ => Set.ext_iff.mp h _ #align conductor_eq_of_eq conductor_eq_of_eq theorem conductor_subset_adjoin : (conductor R x : Set S) ⊆ R<x> := fun y hy => by simpa only [mul_one] using hy 1 #align conductor_subset_adjoin conductor_subset_adjoin theorem mem_conductor_iff {y : S} : y ∈ conductor R x ↔ ∀ b : S, y * b ∈ R<x> := ⟨fun h => h, fun h => h⟩ #align mem_conductor_iff mem_conductor_iff theorem conductor_eq_top_of_adjoin_eq_top (h : R<x> = ⊤) : conductor R x = ⊤ := by simp only [Ideal.eq_top_iff_one, mem_conductor_iff, h, mem_top, forall_const] #align conductor_eq_top_of_adjoin_eq_top conductor_eq_top_of_adjoin_eq_top theorem conductor_eq_top_of_powerBasis (pb : PowerBasis R S) : conductor R pb.gen = ⊤ := conductor_eq_top_of_adjoin_eq_top pb.adjoin_gen_eq_top #align conductor_eq_top_of_power_basis conductor_eq_top_of_powerBasis open IsLocalization in lemma mem_coeSubmodule_conductor {L} [CommRing L] [Algebra S L] [Algebra R L] [IsScalarTower R S L] [NoZeroSMulDivisors S L] {x : S} {y : L} : y ∈ coeSubmodule L (conductor R x) ↔ ∀ z : S, y * (algebraMap S L) z ∈ Algebra.adjoin R {algebraMap S L x} := by cases subsingleton_or_nontrivial L · rw [Subsingleton.elim (coeSubmodule L _) ⊤, Subsingleton.elim (Algebra.adjoin R _) ⊤]; simp trans ∀ z, y * (algebraMap S L) z ∈ (Algebra.adjoin R {x}).map (IsScalarTower.toAlgHom R S L) · simp only [coeSubmodule, Submodule.mem_map, Algebra.linearMap_apply, Subalgebra.mem_map, IsScalarTower.coe_toAlgHom'] constructor · rintro ⟨y, hy, rfl⟩ z exact ⟨_, hy z, map_mul _ _ _⟩ · intro H obtain ⟨y, _, e⟩ := H 1 rw [_root_.map_one, mul_one] at e subst e simp only [← _root_.map_mul, (NoZeroSMulDivisors.algebraMap_injective S L).eq_iff, exists_eq_right] at H exact ⟨_, H, rfl⟩ · rw [AlgHom.map_adjoin, Set.image_singleton]; rfl variable {I : Ideal R}
Mathlib/NumberTheory/KummerDedekind.lean
119
148
theorem prod_mem_ideal_map_of_mem_conductor {p : R} {z : S} (hp : p ∈ Ideal.comap (algebraMap R S) (conductor R x)) (hz' : z ∈ I.map (algebraMap R S)) : algebraMap R S p * z ∈ algebraMap R<x> S '' ↑(I.map (algebraMap R R<x>)) := by
rw [Ideal.map, Ideal.span, Finsupp.mem_span_image_iff_total] at hz' obtain ⟨l, H, H'⟩ := hz' rw [Finsupp.total_apply] at H' rw [← H', mul_comm, Finsupp.sum_mul] have lem : ∀ {a : R}, a ∈ I → l a • algebraMap R S a * algebraMap R S p ∈ algebraMap R<x> S '' I.map (algebraMap R R<x>) := by intro a ha rw [Algebra.id.smul_eq_mul, mul_assoc, mul_comm, mul_assoc, Set.mem_image] refine Exists.intro (algebraMap R R<x> a * ⟨l a * algebraMap R S p, show l a * algebraMap R S p ∈ R<x> from ?h⟩) ?_ case h => rw [mul_comm] exact mem_conductor_iff.mp (Ideal.mem_comap.mp hp) _ · refine ⟨?_, ?_⟩ · rw [mul_comm] apply Ideal.mul_mem_left (I.map (algebraMap R R<x>)) _ (Ideal.mem_map_of_mem _ ha) · simp only [RingHom.map_mul, mul_comm (algebraMap R S p) (l a)] rfl refine Finset.sum_induction _ (fun u => u ∈ algebraMap R<x> S '' I.map (algebraMap R R<x>)) (fun a b => ?_) ?_ ?_ · rintro ⟨z, hz, rfl⟩ ⟨y, hy, rfl⟩ rw [← RingHom.map_add] exact ⟨z + y, Ideal.add_mem _ (SetLike.mem_coe.mp hz) hy, rfl⟩ · exact ⟨0, SetLike.mem_coe.mpr <| Ideal.zero_mem _, RingHom.map_zero _⟩ · intro y hy exact lem ((Finsupp.mem_supported _ l).mp H hy)
27
import Mathlib.Analysis.Convex.Cone.Extension import Mathlib.Analysis.Convex.Gauge import Mathlib.Topology.Algebra.Module.FiniteDimension import Mathlib.Topology.Algebra.Module.LocallyConvex #align_import analysis.normed_space.hahn_banach.separation from "leanprover-community/mathlib"@"915591b2bb3ea303648db07284a161a7f2a9e3d4" open Set open Pointwise variable {𝕜 E : Type*} theorem separate_convex_open_set [TopologicalSpace E] [AddCommGroup E] [TopologicalAddGroup E] [Module ℝ E] [ContinuousSMul ℝ E] {s : Set E} (hs₀ : (0 : E) ∈ s) (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) {x₀ : E} (hx₀ : x₀ ∉ s) : ∃ f : E →L[ℝ] ℝ, f x₀ = 1 ∧ ∀ x ∈ s, f x < 1 := by let f : E →ₗ.[ℝ] ℝ := LinearPMap.mkSpanSingleton x₀ 1 (ne_of_mem_of_not_mem hs₀ hx₀).symm have := exists_extension_of_le_sublinear f (gauge s) (fun c hc => gauge_smul_of_nonneg hc.le) (gauge_add_le hs₁ <| absorbent_nhds_zero <| hs₂.mem_nhds hs₀) ?_ · obtain ⟨φ, hφ₁, hφ₂⟩ := this have hφ₃ : φ x₀ = 1 := by rw [← f.domain.coe_mk x₀ (Submodule.mem_span_singleton_self _), hφ₁, LinearPMap.mkSpanSingleton'_apply_self] have hφ₄ : ∀ x ∈ s, φ x < 1 := fun x hx => (hφ₂ x).trans_lt (gauge_lt_one_of_mem_of_isOpen hs₂ hx) refine ⟨⟨φ, ?_⟩, hφ₃, hφ₄⟩ refine φ.continuous_of_nonzero_on_open _ (hs₂.vadd (-x₀)) (Nonempty.vadd_set ⟨0, hs₀⟩) (vadd_set_subset_iff.mpr fun x hx => ?_) change φ (-x₀ + x) ≠ 0 rw [map_add, map_neg] specialize hφ₄ x hx linarith rintro ⟨x, hx⟩ obtain ⟨y, rfl⟩ := Submodule.mem_span_singleton.1 hx rw [LinearPMap.mkSpanSingleton'_apply] simp only [mul_one, Algebra.id.smul_eq_mul, Submodule.coe_mk] obtain h | h := le_or_lt y 0 · exact h.trans (gauge_nonneg _) · rw [gauge_smul_of_nonneg h.le, smul_eq_mul, le_mul_iff_one_le_right h] exact one_le_gauge_of_not_mem (hs₁.starConvex hs₀) (absorbent_nhds_zero <| hs₂.mem_nhds hs₀).absorbs hx₀ #align separate_convex_open_set separate_convex_open_set variable [TopologicalSpace E] [AddCommGroup E] [TopologicalAddGroup E] [Module ℝ E] [ContinuousSMul ℝ E] {s t : Set E} {x y : E}
Mathlib/Analysis/NormedSpace/HahnBanach/Separation.lean
84
112
theorem geometric_hahn_banach_open (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) (ht : Convex ℝ t) (disj : Disjoint s t) : ∃ (f : E →L[ℝ] ℝ) (u : ℝ), (∀ a ∈ s, f a < u) ∧ ∀ b ∈ t, u ≤ f b := by
obtain rfl | ⟨a₀, ha₀⟩ := s.eq_empty_or_nonempty · exact ⟨0, 0, by simp, fun b _hb => le_rfl⟩ obtain rfl | ⟨b₀, hb₀⟩ := t.eq_empty_or_nonempty · exact ⟨0, 1, fun a _ha => zero_lt_one, by simp⟩ let x₀ := b₀ - a₀ let C := x₀ +ᵥ (s - t) have : (0 : E) ∈ C := ⟨a₀ - b₀, sub_mem_sub ha₀ hb₀, by simp_rw [x₀, vadd_eq_add, sub_add_sub_cancel', sub_self]⟩ have : Convex ℝ C := (hs₁.sub ht).vadd _ have : x₀ ∉ C := by intro hx₀ rw [← add_zero x₀] at hx₀ exact disj.zero_not_mem_sub_set (vadd_mem_vadd_set_iff.1 hx₀) obtain ⟨f, hf₁, hf₂⟩ := separate_convex_open_set ‹0 ∈ C› ‹_› (hs₂.sub_right.vadd _) ‹x₀ ∉ C› have : f b₀ = f a₀ + 1 := by simp [x₀, ← hf₁] have forall_le : ∀ a ∈ s, ∀ b ∈ t, f a ≤ f b := by intro a ha b hb have := hf₂ (x₀ + (a - b)) (vadd_mem_vadd_set <| sub_mem_sub ha hb) simp only [f.map_add, f.map_sub, hf₁] at this linarith refine ⟨f, sInf (f '' t), image_subset_iff.1 (?_ : f '' s ⊆ Iio (sInf (f '' t))), fun b hb => ?_⟩ · rw [← interior_Iic] refine interior_maximal (image_subset_iff.2 fun a ha => ?_) (f.isOpenMap_of_ne_zero ?_ _ hs₂) · exact le_csInf (Nonempty.image _ ⟨_, hb₀⟩) (forall_mem_image.2 <| forall_le _ ha) · rintro rfl simp at hf₁ · exact csInf_le ⟨f a₀, forall_mem_image.2 <| forall_le _ ha₀⟩ (mem_image_of_mem _ hb)
27
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 DivisionRing variable {k : Type*} {V : Type*} {P : Type*} open AffineSubspace FiniteDimensional Module variable [DivisionRing k] [AddCommGroup V] [Module k V] [AffineSpace V P]
Mathlib/LinearAlgebra/AffineSpace/FiniteDimensional.lean
747
775
theorem finrank_vectorSpan_insert_le (s : AffineSubspace k P) (p : P) : finrank k (vectorSpan k (insert p (s : Set P))) ≤ finrank k s.direction + 1 := by
by_cases hf : FiniteDimensional k s.direction; swap · have hf' : ¬FiniteDimensional k (vectorSpan k (insert p (s : Set P))) := by intro h have h' : s.direction ≤ vectorSpan k (insert p (s : Set P)) := by conv_lhs => rw [← affineSpan_coe s, direction_affineSpan] exact vectorSpan_mono k (Set.subset_insert _ _) exact hf (Submodule.finiteDimensional_of_le h') rw [finrank_of_infinite_dimensional hf, finrank_of_infinite_dimensional hf', zero_add] exact zero_le_one have : FiniteDimensional k s.direction := hf rw [← direction_affineSpan, ← affineSpan_insert_affineSpan] rcases (s : Set P).eq_empty_or_nonempty with (hs | ⟨p₀, hp₀⟩) · rw [coe_eq_bot_iff] at hs rw [hs, bot_coe, span_empty, bot_coe, direction_affineSpan, direction_bot, finrank_bot, zero_add] convert zero_le_one' ℕ rw [← finrank_bot k V] convert rfl <;> simp · rw [affineSpan_coe, direction_affineSpan_insert hp₀, add_comm] refine (Submodule.finrank_add_le_finrank_add_finrank _ _).trans (add_le_add_right ?_ _) refine finrank_le_one ⟨p -ᵥ p₀, Submodule.mem_span_singleton_self _⟩ fun v => ?_ have h := v.property rw [Submodule.mem_span_singleton] at h rcases h with ⟨c, hc⟩ refine ⟨c, ?_⟩ ext exact hc
27
import Mathlib.Analysis.Convex.Slope import Mathlib.Analysis.SpecialFunctions.Pow.Real import Mathlib.Tactic.LinearCombination #align_import analysis.convex.specific_functions.basic from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92" open Real Set NNReal theorem strictConvexOn_exp : StrictConvexOn ℝ univ exp := by apply strictConvexOn_of_slope_strict_mono_adjacent convex_univ rintro x y z - - hxy hyz trans exp y · have h1 : 0 < y - x := by linarith have h2 : x - y < 0 := by linarith rw [div_lt_iff h1] calc exp y - exp x = exp y - exp y * exp (x - y) := by rw [← exp_add]; ring_nf _ = exp y * (1 - exp (x - y)) := by ring _ < exp y * -(x - y) := by gcongr; linarith [add_one_lt_exp h2.ne] _ = exp y * (y - x) := by ring · have h1 : 0 < z - y := by linarith rw [lt_div_iff h1] calc exp y * (z - y) < exp y * (exp (z - y) - 1) := by gcongr _ * ?_ linarith [add_one_lt_exp h1.ne'] _ = exp (z - y) * exp y - exp y := by ring _ ≤ exp z - exp y := by rw [← exp_add]; ring_nf; rfl #align strict_convex_on_exp strictConvexOn_exp theorem convexOn_exp : ConvexOn ℝ univ exp := strictConvexOn_exp.convexOn #align convex_on_exp convexOn_exp
Mathlib/Analysis/Convex/SpecificFunctions/Basic.lean
67
94
theorem strictConcaveOn_log_Ioi : StrictConcaveOn ℝ (Ioi 0) log := by
apply strictConcaveOn_of_slope_strict_anti_adjacent (convex_Ioi (0 : ℝ)) intro x y z (hx : 0 < x) (hz : 0 < z) hxy hyz have hy : 0 < y := hx.trans hxy trans y⁻¹ · have h : 0 < z - y := by linarith rw [div_lt_iff h] have hyz' : 0 < z / y := by positivity have hyz'' : z / y ≠ 1 := by contrapose! h rw [div_eq_one_iff_eq hy.ne'] at h simp [h] calc log z - log y = log (z / y) := by rw [← log_div hz.ne' hy.ne'] _ < z / y - 1 := log_lt_sub_one_of_pos hyz' hyz'' _ = y⁻¹ * (z - y) := by field_simp · have h : 0 < y - x := by linarith rw [lt_div_iff h] have hxy' : 0 < x / y := by positivity have hxy'' : x / y ≠ 1 := by contrapose! h rw [div_eq_one_iff_eq hy.ne'] at h simp [h] calc y⁻¹ * (y - x) = 1 - x / y := by field_simp _ < -log (x / y) := by linarith [log_lt_sub_one_of_pos hxy' hxy''] _ = -(log x - log y) := by rw [log_div hx.ne' hy.ne'] _ = log y - log x := by ring
27
import Mathlib.Analysis.InnerProductSpace.Adjoint import Mathlib.Analysis.Matrix import Mathlib.Analysis.RCLike.Basic import Mathlib.LinearAlgebra.UnitaryGroup import Mathlib.Topology.UniformSpace.Matrix #align_import analysis.normed_space.star.matrix from "leanprover-community/mathlib"@"468b141b14016d54b479eb7a0fff1e360b7e3cf6" open scoped Matrix variable {𝕜 m n l E : Type*} section EntrywiseSupNorm variable [RCLike 𝕜] [Fintype n] [DecidableEq n]
Mathlib/Analysis/NormedSpace/Star/Matrix.lean
49
77
theorem entry_norm_bound_of_unitary {U : Matrix n n 𝕜} (hU : U ∈ Matrix.unitaryGroup n 𝕜) (i j : n) : ‖U i j‖ ≤ 1 := by
-- The norm squared of an entry is at most the L2 norm of its row. have norm_sum : ‖U i j‖ ^ 2 ≤ ∑ x, ‖U i x‖ ^ 2 := by apply Multiset.single_le_sum · intro x h_x rw [Multiset.mem_map] at h_x cases' h_x with a h_a rw [← h_a.2] apply sq_nonneg · rw [Multiset.mem_map] use j simp only [eq_self_iff_true, Finset.mem_univ_val, and_self_iff, sq_eq_sq] -- The L2 norm of a row is a diagonal entry of U * Uᴴ have diag_eq_norm_sum : (U * Uᴴ) i i = (∑ x : n, ‖U i x‖ ^ 2 : ℝ) := by simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, ← starRingEnd_apply, RCLike.mul_conj, RCLike.normSq_eq_def', RCLike.ofReal_pow]; norm_cast -- The L2 norm of a row is a diagonal entry of U * Uᴴ, real part have re_diag_eq_norm_sum : RCLike.re ((U * Uᴴ) i i) = ∑ x : n, ‖U i x‖ ^ 2 := by rw [RCLike.ext_iff] at diag_eq_norm_sum rw [diag_eq_norm_sum.1] norm_cast -- Since U is unitary, the diagonal entries of U * Uᴴ are all 1 have mul_eq_one : U * Uᴴ = 1 := unitary.mul_star_self_of_mem hU have diag_eq_one : RCLike.re ((U * Uᴴ) i i) = 1 := by simp only [mul_eq_one, eq_self_iff_true, Matrix.one_apply_eq, RCLike.one_re] -- Putting it all together rw [← sq_le_one_iff (norm_nonneg (U i j)), ← diag_eq_one, re_diag_eq_norm_sum] exact norm_sum
27
import Mathlib.Analysis.Convex.Cone.Extension import Mathlib.Analysis.Convex.Gauge import Mathlib.Topology.Algebra.Module.FiniteDimension import Mathlib.Topology.Algebra.Module.LocallyConvex #align_import analysis.normed_space.hahn_banach.separation from "leanprover-community/mathlib"@"915591b2bb3ea303648db07284a161a7f2a9e3d4" open Set open Pointwise variable {𝕜 E : Type*}
Mathlib/Analysis/NormedSpace/HahnBanach/Separation.lean
47
76
theorem separate_convex_open_set [TopologicalSpace E] [AddCommGroup E] [TopologicalAddGroup E] [Module ℝ E] [ContinuousSMul ℝ E] {s : Set E} (hs₀ : (0 : E) ∈ s) (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) {x₀ : E} (hx₀ : x₀ ∉ s) : ∃ f : E →L[ℝ] ℝ, f x₀ = 1 ∧ ∀ x ∈ s, f x < 1 := by
let f : E →ₗ.[ℝ] ℝ := LinearPMap.mkSpanSingleton x₀ 1 (ne_of_mem_of_not_mem hs₀ hx₀).symm have := exists_extension_of_le_sublinear f (gauge s) (fun c hc => gauge_smul_of_nonneg hc.le) (gauge_add_le hs₁ <| absorbent_nhds_zero <| hs₂.mem_nhds hs₀) ?_ · obtain ⟨φ, hφ₁, hφ₂⟩ := this have hφ₃ : φ x₀ = 1 := by rw [← f.domain.coe_mk x₀ (Submodule.mem_span_singleton_self _), hφ₁, LinearPMap.mkSpanSingleton'_apply_self] have hφ₄ : ∀ x ∈ s, φ x < 1 := fun x hx => (hφ₂ x).trans_lt (gauge_lt_one_of_mem_of_isOpen hs₂ hx) refine ⟨⟨φ, ?_⟩, hφ₃, hφ₄⟩ refine φ.continuous_of_nonzero_on_open _ (hs₂.vadd (-x₀)) (Nonempty.vadd_set ⟨0, hs₀⟩) (vadd_set_subset_iff.mpr fun x hx => ?_) change φ (-x₀ + x) ≠ 0 rw [map_add, map_neg] specialize hφ₄ x hx linarith rintro ⟨x, hx⟩ obtain ⟨y, rfl⟩ := Submodule.mem_span_singleton.1 hx rw [LinearPMap.mkSpanSingleton'_apply] simp only [mul_one, Algebra.id.smul_eq_mul, Submodule.coe_mk] obtain h | h := le_or_lt y 0 · exact h.trans (gauge_nonneg _) · rw [gauge_smul_of_nonneg h.le, smul_eq_mul, le_mul_iff_one_le_right h] exact one_le_gauge_of_not_mem (hs₁.starConvex hs₀) (absorbent_nhds_zero <| hs₂.mem_nhds hs₀).absorbs hx₀
27
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 CommSemiring variable [CommSemiring R] theorem Monic.C_dvd_iff_isUnit {p : R[X]} (hp : Monic p) {a : R} : C a ∣ p ↔ IsUnit a := ⟨fun h => isUnit_iff_dvd_one.mpr <| hp.coeff_natDegree ▸ (C_dvd_iff_dvd_coeff _ _).mp h p.natDegree, fun ha => (ha.map C).dvd⟩ theorem degree_pos_of_not_isUnit_of_dvd_monic {a p : R[X]} (ha : ¬ IsUnit a) (hap : a ∣ p) (hp : Monic p) : 0 < degree a := lt_of_not_ge <| fun h => ha <| by rw [Polynomial.eq_C_of_degree_le_zero h] at hap ⊢ simpa [hp.C_dvd_iff_isUnit, isUnit_C] using hap theorem natDegree_pos_of_not_isUnit_of_dvd_monic {a p : R[X]} (ha : ¬ IsUnit a) (hap : a ∣ p) (hp : Monic p) : 0 < natDegree a := natDegree_pos_iff_degree_pos.mpr <| degree_pos_of_not_isUnit_of_dvd_monic ha hap hp theorem degree_pos_of_monic_of_not_isUnit {a : R[X]} (hu : ¬ IsUnit a) (ha : Monic a) : 0 < degree a := degree_pos_of_not_isUnit_of_dvd_monic hu dvd_rfl ha theorem natDegree_pos_of_monic_of_not_isUnit {a : R[X]} (hu : ¬ IsUnit a) (ha : Monic a) : 0 < natDegree a := natDegree_pos_iff_degree_pos.mpr <| degree_pos_of_monic_of_not_isUnit hu ha
Mathlib/Algebra/Polynomial/RingDivision.lean
368
396
theorem eq_zero_of_mul_eq_zero_of_smul (P : R[X]) (h : ∀ r : R, r • P = 0 → r = 0) : ∀ (Q : R[X]), P * Q = 0 → Q = 0 := by
intro Q hQ suffices ∀ i, P.coeff i • Q = 0 by rw [← leadingCoeff_eq_zero] apply h simpa [ext_iff, mul_comm Q.leadingCoeff] using fun i ↦ congr_arg (·.coeff Q.natDegree) (this i) apply Nat.strong_decreasing_induction · use P.natDegree intro i hi rw [coeff_eq_zero_of_natDegree_lt hi, zero_smul] intro l IH obtain _|hl := (natDegree_smul_le (P.coeff l) Q).lt_or_eq · apply eq_zero_of_mul_eq_zero_of_smul _ h (P.coeff l • Q) rw [smul_eq_C_mul, mul_left_comm, hQ, mul_zero] suffices P.coeff l * Q.leadingCoeff = 0 by rwa [← leadingCoeff_eq_zero, ← coeff_natDegree, coeff_smul, hl, coeff_natDegree, smul_eq_mul] let m := Q.natDegree suffices (P * Q).coeff (l + m) = P.coeff l * Q.leadingCoeff by rw [← this, hQ, coeff_zero] rw [coeff_mul] apply Finset.sum_eq_single (l, m) _ (by simp) simp only [Finset.mem_antidiagonal, ne_eq, Prod.forall, Prod.mk.injEq, not_and] intro i j hij H obtain hi|rfl|hi := lt_trichotomy i l · have hj : m < j := by omega rw [coeff_eq_zero_of_natDegree_lt hj, mul_zero] · omega · rw [← coeff_C_mul, ← smul_eq_C_mul, IH _ hi, coeff_zero] termination_by Q => Q.natDegree
27
import Mathlib.Algebra.MvPolynomial.Supported import Mathlib.RingTheory.WittVector.Truncated #align_import ring_theory.witt_vector.mul_coeff from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" noncomputable section namespace WittVector variable (p : ℕ) [hp : Fact p.Prime] variable {k : Type*} [CommRing k] local notation "𝕎" => WittVector p -- Porting note: new notation local notation "𝕄" => MvPolynomial (Fin 2 × ℕ) ℤ open Finset MvPolynomial def wittPolyProd (n : ℕ) : 𝕄 := rename (Prod.mk (0 : Fin 2)) (wittPolynomial p ℤ n) * rename (Prod.mk (1 : Fin 2)) (wittPolynomial p ℤ n) #align witt_vector.witt_poly_prod WittVector.wittPolyProd theorem wittPolyProd_vars (n : ℕ) : (wittPolyProd p n).vars ⊆ univ ×ˢ range (n + 1) := by rw [wittPolyProd] apply Subset.trans (vars_mul _ _) refine union_subset ?_ ?_ <;> · refine Subset.trans (vars_rename _ _) ?_ simp [wittPolynomial_vars, image_subset_iff] #align witt_vector.witt_poly_prod_vars WittVector.wittPolyProd_vars def wittPolyProdRemainder (n : ℕ) : 𝕄 := ∑ i ∈ range n, (p : 𝕄) ^ i * wittMul p i ^ p ^ (n - i) #align witt_vector.witt_poly_prod_remainder WittVector.wittPolyProdRemainder theorem wittPolyProdRemainder_vars (n : ℕ) : (wittPolyProdRemainder p n).vars ⊆ univ ×ˢ range n := by rw [wittPolyProdRemainder] refine Subset.trans (vars_sum_subset _ _) ?_ rw [biUnion_subset] intro x hx apply Subset.trans (vars_mul _ _) refine union_subset ?_ ?_ · apply Subset.trans (vars_pow _ _) have : (p : 𝕄) = C (p : ℤ) := by simp only [Int.cast_natCast, eq_intCast] rw [this, vars_C] apply empty_subset · apply Subset.trans (vars_pow _ _) apply Subset.trans (wittMul_vars _ _) apply product_subset_product (Subset.refl _) simp only [mem_range, range_subset] at hx ⊢ exact hx #align witt_vector.witt_poly_prod_remainder_vars WittVector.wittPolyProdRemainder_vars def remainder (n : ℕ) : 𝕄 := (∑ x ∈ range (n + 1), (rename (Prod.mk 0)) ((monomial (Finsupp.single x (p ^ (n + 1 - x)))) ((p : ℤ) ^ x))) * ∑ x ∈ range (n + 1), (rename (Prod.mk 1)) ((monomial (Finsupp.single x (p ^ (n + 1 - x)))) ((p : ℤ) ^ x)) #align witt_vector.remainder WittVector.remainder theorem remainder_vars (n : ℕ) : (remainder p n).vars ⊆ univ ×ˢ range (n + 1) := by rw [remainder] apply Subset.trans (vars_mul _ _) refine union_subset ?_ ?_ <;> · refine Subset.trans (vars_sum_subset _ _) ?_ rw [biUnion_subset] intro x hx rw [rename_monomial, vars_monomial, Finsupp.mapDomain_single] · apply Subset.trans Finsupp.support_single_subset simpa using mem_range.mp hx · apply pow_ne_zero exact mod_cast hp.out.ne_zero #align witt_vector.remainder_vars WittVector.remainder_vars def polyOfInterest (n : ℕ) : 𝕄 := wittMul p (n + 1) + (p : 𝕄) ^ (n + 1) * X (0, n + 1) * X (1, n + 1) - X (0, n + 1) * rename (Prod.mk (1 : Fin 2)) (wittPolynomial p ℤ (n + 1)) - X (1, n + 1) * rename (Prod.mk (0 : Fin 2)) (wittPolynomial p ℤ (n + 1)) #align witt_vector.poly_of_interest WittVector.polyOfInterest theorem mul_polyOfInterest_aux1 (n : ℕ) : ∑ i ∈ range (n + 1), (p : 𝕄) ^ i * wittMul p i ^ p ^ (n - i) = wittPolyProd p n := by simp only [wittPolyProd] convert wittStructureInt_prop p (X (0 : Fin 2) * X 1) n using 1 · simp only [wittPolynomial, wittMul] rw [AlgHom.map_sum] congr 1 with i congr 1 have hsupp : (Finsupp.single i (p ^ (n - i))).support = {i} := by rw [Finsupp.support_eq_singleton] simp only [and_true_iff, Finsupp.single_eq_same, eq_self_iff_true, Ne] exact pow_ne_zero _ hp.out.ne_zero simp only [bind₁_monomial, hsupp, Int.cast_natCast, prod_singleton, eq_intCast, Finsupp.single_eq_same, C_pow, mul_eq_mul_left_iff, true_or_iff, eq_self_iff_true, Int.cast_pow] · simp only [map_mul, bind₁_X_right] #align witt_vector.mul_poly_of_interest_aux1 WittVector.mul_polyOfInterest_aux1 theorem mul_polyOfInterest_aux2 (n : ℕ) : (p : 𝕄) ^ n * wittMul p n + wittPolyProdRemainder p n = wittPolyProd p n := by convert mul_polyOfInterest_aux1 p n rw [sum_range_succ, add_comm, Nat.sub_self, pow_zero, pow_one] rfl #align witt_vector.mul_poly_of_interest_aux2 WittVector.mul_polyOfInterest_aux2
Mathlib/RingTheory/WittVector/MulCoeff.lean
145
176
theorem mul_polyOfInterest_aux3 (n : ℕ) : wittPolyProd p (n + 1) = -((p : 𝕄) ^ (n + 1) * X (0, n + 1)) * ((p : 𝕄) ^ (n + 1) * X (1, n + 1)) + (p : 𝕄) ^ (n + 1) * X (0, n + 1) * rename (Prod.mk (1 : Fin 2)) (wittPolynomial p ℤ (n + 1)) + (p : 𝕄) ^ (n + 1) * X (1, n + 1) * rename (Prod.mk (0 : Fin 2)) (wittPolynomial p ℤ (n + 1)) + remainder p n := by
-- a useful auxiliary fact have mvpz : (p : 𝕄) ^ (n + 1) = MvPolynomial.C ((p : ℤ) ^ (n + 1)) := by norm_cast -- Porting note: the original proof applies `sum_range_succ` through a non-`conv` rewrite, -- but this does not work in Lean 4; the whole proof also times out very badly. The proof has been -- nearly totally rewritten here and now finishes quite fast. rw [wittPolyProd, wittPolynomial, AlgHom.map_sum, AlgHom.map_sum] conv_lhs => arg 1 rw [sum_range_succ, ← C_mul_X_pow_eq_monomial, tsub_self, pow_zero, pow_one, map_mul, rename_C, rename_X, ← mvpz] conv_lhs => arg 2 rw [sum_range_succ, ← C_mul_X_pow_eq_monomial, tsub_self, pow_zero, pow_one, map_mul, rename_C, rename_X, ← mvpz] conv_rhs => enter [1, 1, 2, 2] rw [sum_range_succ, ← C_mul_X_pow_eq_monomial, tsub_self, pow_zero, pow_one, map_mul, rename_C, rename_X, ← mvpz] conv_rhs => enter [1, 2, 2] rw [sum_range_succ, ← C_mul_X_pow_eq_monomial, tsub_self, pow_zero, pow_one, map_mul, rename_C, rename_X, ← mvpz] simp only [add_mul, mul_add] rw [add_comm _ (remainder p n)] simp only [add_assoc] apply congrArg (Add.add _) ring
27
import Mathlib.Algebra.Polynomial.Taylor import Mathlib.RingTheory.Ideal.LocalRing import Mathlib.RingTheory.AdicCompletion.Basic #align_import ring_theory.henselian from "leanprover-community/mathlib"@"d1accf4f9cddb3666c6e8e4da0ac2d19c4ed73f0" noncomputable section universe u v open Polynomial LocalRing Polynomial Function List theorem isLocalRingHom_of_le_jacobson_bot {R : Type*} [CommRing R] (I : Ideal R) (h : I ≤ Ideal.jacobson ⊥) : IsLocalRingHom (Ideal.Quotient.mk I) := by constructor intro a h have : IsUnit (Ideal.Quotient.mk (Ideal.jacobson ⊥) a) := by rw [isUnit_iff_exists_inv] at * obtain ⟨b, hb⟩ := h obtain ⟨b, rfl⟩ := Ideal.Quotient.mk_surjective b use Ideal.Quotient.mk _ b rw [← (Ideal.Quotient.mk _).map_one, ← (Ideal.Quotient.mk _).map_mul, Ideal.Quotient.eq] at hb ⊢ exact h hb obtain ⟨⟨x, y, h1, h2⟩, rfl : x = _⟩ := this obtain ⟨y, rfl⟩ := Ideal.Quotient.mk_surjective y rw [← (Ideal.Quotient.mk _).map_mul, ← (Ideal.Quotient.mk _).map_one, Ideal.Quotient.eq, Ideal.mem_jacobson_bot] at h1 h2 specialize h1 1 simp? at h1 says simp only [mul_one, sub_add_cancel, IsUnit.mul_iff] at h1 exact h1.1 #align is_local_ring_hom_of_le_jacobson_bot isLocalRingHom_of_le_jacobson_bot class HenselianRing (R : Type*) [CommRing R] (I : Ideal R) : Prop where jac : I ≤ Ideal.jacobson ⊥ is_henselian : ∀ (f : R[X]) (_ : f.Monic) (a₀ : R) (_ : f.eval a₀ ∈ I) (_ : IsUnit (Ideal.Quotient.mk I (f.derivative.eval a₀))), ∃ a : R, f.IsRoot a ∧ a - a₀ ∈ I #align henselian_ring HenselianRing class HenselianLocalRing (R : Type*) [CommRing R] extends LocalRing R : Prop where is_henselian : ∀ (f : R[X]) (_ : f.Monic) (a₀ : R) (_ : f.eval a₀ ∈ maximalIdeal R) (_ : IsUnit (f.derivative.eval a₀)), ∃ a : R, f.IsRoot a ∧ a - a₀ ∈ maximalIdeal R #align henselian_local_ring HenselianLocalRing -- see Note [lower instance priority] instance (priority := 100) Field.henselian (K : Type*) [Field K] : HenselianLocalRing K where is_henselian f _ a₀ h₁ _ := by simp only [(maximalIdeal K).eq_bot_of_prime, Ideal.mem_bot] at h₁ ⊢ exact ⟨a₀, h₁, sub_self _⟩ #align field.henselian Field.henselian
Mathlib/RingTheory/Henselian.lean
121
155
theorem HenselianLocalRing.TFAE (R : Type u) [CommRing R] [LocalRing R] : TFAE [HenselianLocalRing R, ∀ f : R[X], f.Monic → ∀ a₀ : ResidueField R, aeval a₀ f = 0 → aeval a₀ (derivative f) ≠ 0 → ∃ a : R, f.IsRoot a ∧ residue R a = a₀, ∀ {K : Type u} [Field K], ∀ (φ : R →+* K), Surjective φ → ∀ f : R[X], f.Monic → ∀ a₀ : K, f.eval₂ φ a₀ = 0 → f.derivative.eval₂ φ a₀ ≠ 0 → ∃ a : R, f.IsRoot a ∧ φ a = a₀] := by
tfae_have 3 → 2 · intro H exact H (residue R) Ideal.Quotient.mk_surjective tfae_have 2 → 1 · intro H constructor intro f hf a₀ h₁ h₂ specialize H f hf (residue R a₀) have aux := flip mem_nonunits_iff.mp h₂ simp only [aeval_def, ResidueField.algebraMap_eq, eval₂_at_apply, ← Ideal.Quotient.eq_zero_iff_mem, ← LocalRing.mem_maximalIdeal] at H h₁ aux obtain ⟨a, ha₁, ha₂⟩ := H h₁ aux refine ⟨a, ha₁, ?_⟩ rw [← Ideal.Quotient.eq_zero_iff_mem] rwa [← sub_eq_zero, ← RingHom.map_sub] at ha₂ tfae_have 1 → 3 · intro hR K _K φ hφ f hf a₀ h₁ h₂ obtain ⟨a₀, rfl⟩ := hφ a₀ have H := HenselianLocalRing.is_henselian f hf a₀ simp only [← ker_eq_maximalIdeal φ hφ, eval₂_at_apply, RingHom.mem_ker φ] at H h₁ h₂ obtain ⟨a, ha₁, ha₂⟩ := H h₁ (by contrapose! h₂ rwa [← mem_nonunits_iff, ← LocalRing.mem_maximalIdeal, ← LocalRing.ker_eq_maximalIdeal φ hφ, RingHom.mem_ker] at h₂) refine ⟨a, ha₁, ?_⟩ rwa [φ.map_sub, sub_eq_zero] at ha₂ tfae_finish
27
import Mathlib.Analysis.Convex.Combination import Mathlib.Analysis.Convex.Join #align_import analysis.convex.stone_separation from "leanprover-community/mathlib"@"6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f" open Set variable {𝕜 E ι : Type*} [LinearOrderedField 𝕜] [AddCommGroup E] [Module 𝕜 E] {s t : Set E} theorem not_disjoint_segment_convexHull_triple {p q u v x y z : E} (hz : z ∈ segment 𝕜 x y) (hu : u ∈ segment 𝕜 x p) (hv : v ∈ segment 𝕜 y q) : ¬Disjoint (segment 𝕜 u v) (convexHull 𝕜 {p, q, z}) := by rw [not_disjoint_iff] obtain ⟨az, bz, haz, hbz, habz, rfl⟩ := hz obtain rfl | haz' := haz.eq_or_lt · rw [zero_add] at habz rw [zero_smul, zero_add, habz, one_smul] refine ⟨v, by apply right_mem_segment, segment_subset_convexHull ?_ ?_ hv⟩ <;> simp obtain ⟨av, bv, hav, hbv, habv, rfl⟩ := hv obtain rfl | hav' := hav.eq_or_lt · rw [zero_add] at habv rw [zero_smul, zero_add, habv, one_smul] exact ⟨q, right_mem_segment _ _ _, subset_convexHull _ _ <| by simp⟩ obtain ⟨au, bu, hau, hbu, habu, rfl⟩ := hu have hab : 0 < az * av + bz * au := by positivity refine ⟨(az * av / (az * av + bz * au)) • (au • x + bu • p) + (bz * au / (az * av + bz * au)) • (av • y + bv • q), ⟨_, _, ?_, ?_, ?_, rfl⟩, ?_⟩ · positivity · positivity · rw [← add_div, div_self]; positivity rw [smul_add, smul_add, add_add_add_comm, add_comm, ← mul_smul, ← mul_smul] classical let w : Fin 3 → 𝕜 := ![az * av * bu, bz * au * bv, au * av] let z : Fin 3 → E := ![p, q, az • x + bz • y] have hw₀ : ∀ i, 0 ≤ w i := by rintro i fin_cases i · exact mul_nonneg (mul_nonneg haz hav) hbu · exact mul_nonneg (mul_nonneg hbz hau) hbv · exact mul_nonneg hau hav have hw : ∑ i, w i = az * av + bz * au := by trans az * av * bu + (bz * au * bv + au * av) · simp [w, Fin.sum_univ_succ, Fin.sum_univ_zero] rw [← one_mul (au * av), ← habz, add_mul, ← add_assoc, add_add_add_comm, mul_assoc, ← mul_add, mul_assoc, ← mul_add, mul_comm av, ← add_mul, ← mul_add, add_comm bu, add_comm bv, habu, habv, one_mul, mul_one] have hz : ∀ i, z i ∈ ({p, q, az • x + bz • y} : Set E) := fun i => by fin_cases i <;> simp [z] convert Finset.centerMass_mem_convexHull (Finset.univ : Finset (Fin 3)) (fun i _ => hw₀ i) (by rwa [hw]) fun i _ => hz i rw [Finset.centerMass] simp_rw [div_eq_inv_mul, hw, mul_assoc, mul_smul (az * av + bz * au)⁻¹, ← smul_add, add_assoc, ← mul_assoc] congr 3 rw [← mul_smul, ← mul_rotate, mul_right_comm, mul_smul, ← mul_smul _ av, mul_rotate, mul_smul _ bz, ← smul_add] simp only [w, z, smul_add, List.foldr, Matrix.cons_val_succ', Fin.mk_one, Matrix.cons_val_one, Matrix.head_cons, add_zero] #align not_disjoint_segment_convex_hull_triple not_disjoint_segment_convexHull_triple
Mathlib/Analysis/Convex/StoneSeparation.lean
81
109
theorem exists_convex_convex_compl_subset (hs : Convex 𝕜 s) (ht : Convex 𝕜 t) (hst : Disjoint s t) : ∃ C : Set E, Convex 𝕜 C ∧ Convex 𝕜 Cᶜ ∧ s ⊆ C ∧ t ⊆ Cᶜ := by
let S : Set (Set E) := { C | Convex 𝕜 C ∧ Disjoint C t } obtain ⟨C, hC, hsC, hCmax⟩ := zorn_subset_nonempty S (fun c hcS hc ⟨_, _⟩ => ⟨⋃₀ c, ⟨hc.directedOn.convex_sUnion fun s hs => (hcS hs).1, disjoint_sUnion_left.2 fun c hc => (hcS hc).2⟩, fun s => subset_sUnion_of_mem⟩) s ⟨hs, hst⟩ refine ⟨C, hC.1, convex_iff_segment_subset.2 fun x hx y hy z hz hzC => ?_, hsC, hC.2.subset_compl_left⟩ suffices h : ∀ c ∈ Cᶜ, ∃ a ∈ C, (segment 𝕜 c a ∩ t).Nonempty by obtain ⟨p, hp, u, hu, hut⟩ := h x hx obtain ⟨q, hq, v, hv, hvt⟩ := h y hy refine not_disjoint_segment_convexHull_triple hz hu hv (hC.2.symm.mono (ht.segment_subset hut hvt) <| convexHull_min ?_ hC.1) simp [insert_subset_iff, hp, hq, singleton_subset_iff.2 hzC] rintro c hc by_contra! h suffices h : Disjoint (convexHull 𝕜 (insert c C)) t by rw [← hCmax _ ⟨convex_convexHull _ _, h⟩ ((subset_insert _ _).trans <| subset_convexHull _ _)] at hc exact hc (subset_convexHull _ _ <| mem_insert _ _) rw [convexHull_insert ⟨z, hzC⟩, convexJoin_singleton_left] refine disjoint_iUnion₂_left.2 fun a ha => disjoint_iff_inter_eq_empty.2 (h a ?_) rwa [← hC.1.convexHull_eq]
27
import Mathlib.Algebra.MvPolynomial.PDeriv import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Data.Nat.Choose.Sum import Mathlib.LinearAlgebra.LinearIndependent import Mathlib.RingTheory.Polynomial.Pochhammer #align_import ring_theory.polynomial.bernstein from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821" noncomputable section open Nat (choose) open Polynomial (X) open scoped Polynomial variable (R : Type*) [CommRing R] def bernsteinPolynomial (n ν : ℕ) : R[X] := (choose n ν : R[X]) * X ^ ν * (1 - X) ^ (n - ν) #align bernstein_polynomial bernsteinPolynomial example : bernsteinPolynomial ℤ 3 2 = 3 * X ^ 2 - 3 * X ^ 3 := by norm_num [bernsteinPolynomial, choose] ring namespace bernsteinPolynomial theorem eq_zero_of_lt {n ν : ℕ} (h : n < ν) : bernsteinPolynomial R n ν = 0 := by simp [bernsteinPolynomial, Nat.choose_eq_zero_of_lt h] #align bernstein_polynomial.eq_zero_of_lt bernsteinPolynomial.eq_zero_of_lt section variable {R} {S : Type*} [CommRing S] @[simp] theorem map (f : R →+* S) (n ν : ℕ) : (bernsteinPolynomial R n ν).map f = bernsteinPolynomial S n ν := by simp [bernsteinPolynomial] #align bernstein_polynomial.map bernsteinPolynomial.map end theorem flip (n ν : ℕ) (h : ν ≤ n) : (bernsteinPolynomial R n ν).comp (1 - X) = bernsteinPolynomial R n (n - ν) := by simp [bernsteinPolynomial, h, tsub_tsub_assoc, mul_right_comm] #align bernstein_polynomial.flip bernsteinPolynomial.flip theorem flip' (n ν : ℕ) (h : ν ≤ n) : bernsteinPolynomial R n ν = (bernsteinPolynomial R n (n - ν)).comp (1 - X) := by simp [← flip _ _ _ h, Polynomial.comp_assoc] #align bernstein_polynomial.flip' bernsteinPolynomial.flip' theorem eval_at_0 (n ν : ℕ) : (bernsteinPolynomial R n ν).eval 0 = if ν = 0 then 1 else 0 := by rw [bernsteinPolynomial] split_ifs with h · subst h; simp · simp [zero_pow h] #align bernstein_polynomial.eval_at_0 bernsteinPolynomial.eval_at_0 theorem eval_at_1 (n ν : ℕ) : (bernsteinPolynomial R n ν).eval 1 = if ν = n then 1 else 0 := by rw [bernsteinPolynomial] split_ifs with h · subst h; simp · obtain hνn | hnν := Ne.lt_or_lt h · simp [zero_pow $ Nat.sub_ne_zero_of_lt hνn] · simp [Nat.choose_eq_zero_of_lt hnν] #align bernstein_polynomial.eval_at_1 bernsteinPolynomial.eval_at_1
Mathlib/RingTheory/Polynomial/Bernstein.lean
102
131
theorem derivative_succ_aux (n ν : ℕ) : Polynomial.derivative (bernsteinPolynomial R (n + 1) (ν + 1)) = (n + 1) * (bernsteinPolynomial R n ν - bernsteinPolynomial R n (ν + 1)) := by
rw [bernsteinPolynomial] suffices ((n + 1).choose (ν + 1) : R[X]) * ((↑(ν + 1 : ℕ) : R[X]) * X ^ ν) * (1 - X) ^ (n - ν) - ((n + 1).choose (ν + 1) : R[X]) * X ^ (ν + 1) * ((↑(n - ν) : R[X]) * (1 - X) ^ (n - ν - 1)) = (↑(n + 1) : R[X]) * ((n.choose ν : R[X]) * X ^ ν * (1 - X) ^ (n - ν) - (n.choose (ν + 1) : R[X]) * X ^ (ν + 1) * (1 - X) ^ (n - (ν + 1))) by simpa [Polynomial.derivative_pow, ← sub_eq_add_neg, Nat.succ_sub_succ_eq_sub, Polynomial.derivative_mul, Polynomial.derivative_natCast, zero_mul, Nat.cast_add, algebraMap.coe_one, Polynomial.derivative_X, mul_one, zero_add, Polynomial.derivative_sub, Polynomial.derivative_one, zero_sub, mul_neg, Nat.sub_zero, bernsteinPolynomial, map_add, map_natCast, Nat.cast_one] conv_rhs => rw [mul_sub] -- We'll prove the two terms match up separately. refine congr (congr_arg Sub.sub ?_) ?_ · simp only [← mul_assoc] apply congr (congr_arg (· * ·) (congr (congr_arg (· * ·) _) rfl)) rfl -- Now it's just about binomial coefficients exact mod_cast congr_arg (fun m : ℕ => (m : R[X])) (Nat.succ_mul_choose_eq n ν).symm · rw [← tsub_add_eq_tsub_tsub, ← mul_assoc, ← mul_assoc]; congr 1 rw [mul_comm, ← mul_assoc, ← mul_assoc]; congr 1 norm_cast congr 1 convert (Nat.choose_mul_succ_eq n (ν + 1)).symm using 1 · -- Porting note: was -- convert mul_comm _ _ using 2 -- simp rw [mul_comm, Nat.succ_sub_succ_eq_sub] · apply mul_comm
27
import Mathlib.Analysis.Calculus.TangentCone import Mathlib.Analysis.NormedSpace.OperatorNorm.Asymptotics #align_import analysis.calculus.fderiv.basic from "leanprover-community/mathlib"@"41bef4ae1254365bc190aee63b947674d2977f01" open Filter Asymptotics ContinuousLinearMap Set Metric open scoped Classical open Topology NNReal Filter Asymptotics ENNReal noncomputable section section variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] variable {G' : Type*} [NormedAddCommGroup G'] [NormedSpace 𝕜 G'] @[mk_iff hasFDerivAtFilter_iff_isLittleO] structure HasFDerivAtFilter (f : E → F) (f' : E →L[𝕜] F) (x : E) (L : Filter E) : Prop where of_isLittleO :: isLittleO : (fun x' => f x' - f x - f' (x' - x)) =o[L] fun x' => x' - x #align has_fderiv_at_filter HasFDerivAtFilter @[fun_prop] def HasFDerivWithinAt (f : E → F) (f' : E →L[𝕜] F) (s : Set E) (x : E) := HasFDerivAtFilter f f' x (𝓝[s] x) #align has_fderiv_within_at HasFDerivWithinAt @[fun_prop] def HasFDerivAt (f : E → F) (f' : E →L[𝕜] F) (x : E) := HasFDerivAtFilter f f' x (𝓝 x) #align has_fderiv_at HasFDerivAt @[fun_prop] def HasStrictFDerivAt (f : E → F) (f' : E →L[𝕜] F) (x : E) := (fun p : E × E => f p.1 - f p.2 - f' (p.1 - p.2)) =o[𝓝 (x, x)] fun p : E × E => p.1 - p.2 #align has_strict_fderiv_at HasStrictFDerivAt variable (𝕜) @[fun_prop] def DifferentiableWithinAt (f : E → F) (s : Set E) (x : E) := ∃ f' : E →L[𝕜] F, HasFDerivWithinAt f f' s x #align differentiable_within_at DifferentiableWithinAt @[fun_prop] def DifferentiableAt (f : E → F) (x : E) := ∃ f' : E →L[𝕜] F, HasFDerivAt f f' x #align differentiable_at DifferentiableAt irreducible_def fderivWithin (f : E → F) (s : Set E) (x : E) : E →L[𝕜] F := if 𝓝[s \ {x}] x = ⊥ then 0 else if h : ∃ f', HasFDerivWithinAt f f' s x then Classical.choose h else 0 #align fderiv_within fderivWithin irreducible_def fderiv (f : E → F) (x : E) : E →L[𝕜] F := if h : ∃ f', HasFDerivAt f f' x then Classical.choose h else 0 #align fderiv fderiv @[fun_prop] def DifferentiableOn (f : E → F) (s : Set E) := ∀ x ∈ s, DifferentiableWithinAt 𝕜 f s x #align differentiable_on DifferentiableOn @[fun_prop] def Differentiable (f : E → F) := ∀ x, DifferentiableAt 𝕜 f x #align differentiable Differentiable variable {𝕜} variable {f f₀ f₁ g : E → F} variable {f' f₀' f₁' g' : E →L[𝕜] F} variable (e : E →L[𝕜] F) variable {x : E} variable {s t : Set E} variable {L L₁ L₂ : Filter E} theorem fderivWithin_zero_of_isolated (h : 𝓝[s \ {x}] x = ⊥) : fderivWithin 𝕜 f s x = 0 := by rw [fderivWithin, if_pos h] theorem fderivWithin_zero_of_nmem_closure (h : x ∉ closure s) : fderivWithin 𝕜 f s x = 0 := by apply fderivWithin_zero_of_isolated simp only [mem_closure_iff_nhdsWithin_neBot, neBot_iff, Ne, Classical.not_not] at h rw [eq_bot_iff, ← h] exact nhdsWithin_mono _ diff_subset theorem fderivWithin_zero_of_not_differentiableWithinAt (h : ¬DifferentiableWithinAt 𝕜 f s x) : fderivWithin 𝕜 f s x = 0 := by have : ¬∃ f', HasFDerivWithinAt f f' s x := h simp [fderivWithin, this] #align fderiv_within_zero_of_not_differentiable_within_at fderivWithin_zero_of_not_differentiableWithinAt theorem fderiv_zero_of_not_differentiableAt (h : ¬DifferentiableAt 𝕜 f x) : fderiv 𝕜 f x = 0 := by have : ¬∃ f', HasFDerivAt f f' x := h simp [fderiv, this] #align fderiv_zero_of_not_differentiable_at fderiv_zero_of_not_differentiableAt section DerivativeUniqueness
Mathlib/Analysis/Calculus/FDeriv/Basic.lean
246
276
theorem HasFDerivWithinAt.lim (h : HasFDerivWithinAt f f' s x) {α : Type*} (l : Filter α) {c : α → 𝕜} {d : α → E} {v : E} (dtop : ∀ᶠ n in l, x + d n ∈ s) (clim : Tendsto (fun n => ‖c n‖) l atTop) (cdlim : Tendsto (fun n => c n • d n) l (𝓝 v)) : Tendsto (fun n => c n • (f (x + d n) - f x)) l (𝓝 (f' v)) := by
have tendsto_arg : Tendsto (fun n => x + d n) l (𝓝[s] x) := by conv in 𝓝[s] x => rw [← add_zero x] rw [nhdsWithin, tendsto_inf] constructor · apply tendsto_const_nhds.add (tangentConeAt.lim_zero l clim cdlim) · rwa [tendsto_principal] have : (fun y => f y - f x - f' (y - x)) =o[𝓝[s] x] fun y => y - x := h.isLittleO have : (fun n => f (x + d n) - f x - f' (x + d n - x)) =o[l] fun n => x + d n - x := this.comp_tendsto tendsto_arg have : (fun n => f (x + d n) - f x - f' (d n)) =o[l] d := by simpa only [add_sub_cancel_left] have : (fun n => c n • (f (x + d n) - f x - f' (d n))) =o[l] fun n => c n • d n := (isBigO_refl c l).smul_isLittleO this have : (fun n => c n • (f (x + d n) - f x - f' (d n))) =o[l] fun _ => (1 : ℝ) := this.trans_isBigO (cdlim.isBigO_one ℝ) have L1 : Tendsto (fun n => c n • (f (x + d n) - f x - f' (d n))) l (𝓝 0) := (isLittleO_one_iff ℝ).1 this have L2 : Tendsto (fun n => f' (c n • d n)) l (𝓝 (f' v)) := Tendsto.comp f'.cont.continuousAt cdlim have L3 : Tendsto (fun n => c n • (f (x + d n) - f x - f' (d n)) + f' (c n • d n)) l (𝓝 (0 + f' v)) := L1.add L2 have : (fun n => c n • (f (x + d n) - f x - f' (d n)) + f' (c n • d n)) = fun n => c n • (f (x + d n) - f x) := by ext n simp [smul_add, smul_sub] rwa [this, zero_add] at L3
27
import Mathlib.Geometry.Manifold.MFDeriv.UniqueDifferential import Mathlib.Geometry.Manifold.ContMDiffMap #align_import geometry.manifold.cont_mdiff_mfderiv from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833" open Set Function Filter ChartedSpace SmoothManifoldWithCorners Bundle open scoped Topology Manifold Bundle variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] -- declare a smooth manifold `M` over the pair `(E, H)`. {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {H : Type*} [TopologicalSpace H] {I : ModelWithCorners 𝕜 E H} {M : Type*} [TopologicalSpace M] [ChartedSpace H M] [Is : SmoothManifoldWithCorners I M] -- declare a smooth manifold `M'` over the pair `(E', H')`. {E' : Type*} [NormedAddCommGroup E'] [NormedSpace 𝕜 E'] {H' : Type*} [TopologicalSpace H'] {I' : ModelWithCorners 𝕜 E' H'} {M' : Type*} [TopologicalSpace M'] [ChartedSpace H' M'] [I's : SmoothManifoldWithCorners I' M'] -- declare a smooth manifold `N` over the pair `(F, G)`. {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type*} [TopologicalSpace G] {J : ModelWithCorners 𝕜 F G} {N : Type*} [TopologicalSpace N] [ChartedSpace G N] [Js : SmoothManifoldWithCorners J N] -- declare a smooth manifold `N'` over the pair `(F', G')`. {F' : Type*} [NormedAddCommGroup F'] [NormedSpace 𝕜 F'] {G' : Type*} [TopologicalSpace G'] {J' : ModelWithCorners 𝕜 F' G'} {N' : Type*} [TopologicalSpace N'] [ChartedSpace G' N'] [J's : SmoothManifoldWithCorners J' N'] -- declare some additional normed spaces, used for fibers of vector bundles {F₁ : Type*} [NormedAddCommGroup F₁] [NormedSpace 𝕜 F₁] {F₂ : Type*} [NormedAddCommGroup F₂] [NormedSpace 𝕜 F₂] -- declare functions, sets, points and smoothness indices {f f₁ : M → M'} {s s₁ t : Set M} {x : M} {m n : ℕ∞} -- Porting note: section about deducing differentiability from smoothness moved to -- `Geometry.Manifold.MFDeriv.Basic` namespace TangentBundle variable (I M) open Bundle
Mathlib/Geometry/Manifold/ContMDiffMFDeriv.lean
571
599
theorem tangentMap_tangentBundle_pure (p : TangentBundle I M) : tangentMap I I.tangent (zeroSection E (TangentSpace I)) p = ⟨⟨p.proj, 0⟩, ⟨p.2, 0⟩⟩ := by
rcases p with ⟨x, v⟩ have N : I.symm ⁻¹' (chartAt H x).target ∈ 𝓝 (I ((chartAt H x) x)) := by apply IsOpen.mem_nhds · apply (PartialHomeomorph.open_target _).preimage I.continuous_invFun · simp only [mfld_simps] have A : MDifferentiableAt I I.tangent (fun x => @TotalSpace.mk M E (TangentSpace I) x 0) x := haveI : Smooth I (I.prod 𝓘(𝕜, E)) (zeroSection E (TangentSpace I : M → Type _)) := Bundle.smooth_zeroSection 𝕜 (TangentSpace I : M → Type _) this.mdifferentiableAt have B : fderivWithin 𝕜 (fun x' : E ↦ (x', (0 : E))) (Set.range I) (I ((chartAt H x) x)) v = (v, 0) := by rw [fderivWithin_eq_fderiv, DifferentiableAt.fderiv_prod] · simp · exact differentiableAt_id' · exact differentiableAt_const _ · exact ModelWithCorners.unique_diff_at_image I · exact differentiableAt_id'.prod (differentiableAt_const _) simp (config := { unfoldPartialApp := true }) only [Bundle.zeroSection, tangentMap, mfderiv, A, if_pos, chartAt, FiberBundle.chartedSpace_chartAt, TangentBundle.trivializationAt_apply, tangentBundleCore, Function.comp_def, ContinuousLinearMap.map_zero, mfld_simps] rw [← fderivWithin_inter N] at B rw [← fderivWithin_inter N, ← B] congr 1 refine fderivWithin_congr (fun y hy => ?_) ?_ · simp only [mfld_simps] at hy simp only [hy, Prod.mk.inj_iff, mfld_simps] · simp only [Prod.mk.inj_iff, mfld_simps]
27
import Mathlib.NumberTheory.Cyclotomic.Embeddings import Mathlib.NumberTheory.Cyclotomic.Rat import Mathlib.NumberTheory.NumberField.Units.DirichletTheorem open NumberField Units InfinitePlace nonZeroDivisors Polynomial namespace IsCyclotomicExtension.Rat.Three variable {K : Type*} [Field K] [NumberField K] [IsCyclotomicExtension {3} ℚ K] variable {ζ : K} (hζ : IsPrimitiveRoot ζ ↑(3 : ℕ+)) (u : (𝓞 K)ˣ) local notation3 "η" => (IsPrimitiveRoot.isUnit (hζ.toInteger_isPrimitiveRoot) (by decide)).unit local notation3 "λ" => (η : 𝓞 K) - 1 -- Here `List` is more convenient than `Finset`, even if further from the informal statement. -- For example, `fin_cases` below does not work with a `Finset`.
Mathlib/NumberTheory/Cyclotomic/Three.lean
41
68
theorem Units.mem : u ∈ [1, -1, η, -η, η ^ 2, -η ^ 2] := by
have hrank : rank K = 0 := by dsimp only [rank] rw [card_eq_nrRealPlaces_add_nrComplexPlaces, nrRealPlaces_eq_zero (n := 3) K (by decide), zero_add, nrComplexPlaces_eq_totient_div_two (n := 3)] rfl obtain ⟨⟨x, e⟩, hxu, -⟩ := exist_unique_eq_mul_prod _ u replace hxu : u = x := by rw [← mul_one x.1, hxu] apply congr_arg rw [← Finset.prod_empty] congr rw [Finset.univ_eq_empty_iff, hrank] infer_instance obtain ⟨n, hnpos, hn⟩ := isOfFinOrder_iff_pow_eq_one.1 <| (CommGroup.mem_torsion _ _).1 x.2 replace hn : (↑u : K) ^ ((⟨n, hnpos⟩ : ℕ+) : ℕ) = 1 := by rw [← map_pow] convert map_one (algebraMap (𝓞 K) K) rw_mod_cast [hxu, hn] simp obtain ⟨r, hr3, hru⟩ := hζ.exists_pow_or_neg_mul_pow_of_isOfFinOrder (by decide) (isOfFinOrder_iff_pow_eq_one.2 ⟨n, hnpos, hn⟩) replace hr : r ∈ Finset.Ico 0 3 := Finset.mem_Ico.2 ⟨by simp, hr3⟩ replace hru : ↑u = η ^ r ∨ ↑u = -η ^ r := by rcases hru with (h | h) · left; ext; exact h · right; ext; exact h fin_cases hr <;> rcases hru with (h | h) <;> simp [h]
27
import Mathlib.Analysis.Calculus.MeanValue #align_import analysis.calculus.extend_deriv from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] open Filter Set Metric ContinuousLinearMap open scoped Topology attribute [local mono] Set.prod_mono theorem has_fderiv_at_boundary_of_tendsto_fderiv {f : E → F} {s : Set E} {x : E} {f' : E →L[ℝ] F} (f_diff : DifferentiableOn ℝ f s) (s_conv : Convex ℝ s) (s_open : IsOpen s) (f_cont : ∀ y ∈ closure s, ContinuousWithinAt f s y) (h : Tendsto (fun y => fderiv ℝ f y) (𝓝[s] x) (𝓝 f')) : HasFDerivWithinAt f f' (closure s) x := by classical -- one can assume without loss of generality that `x` belongs to the closure of `s`, as the -- statement is empty otherwise by_cases hx : x ∉ closure s · rw [← closure_closure] at hx; exact hasFDerivWithinAt_of_nmem_closure hx push_neg at hx rw [HasFDerivWithinAt, hasFDerivAtFilter_iff_isLittleO, Asymptotics.isLittleO_iff] intro ε ε_pos obtain ⟨δ, δ_pos, hδ⟩ : ∃ δ > 0, ∀ y ∈ s, dist y x < δ → ‖fderiv ℝ f y - f'‖ < ε := by simpa [dist_zero_right] using tendsto_nhdsWithin_nhds.1 h ε ε_pos set B := ball x δ suffices ∀ y ∈ B ∩ closure s, ‖f y - f x - (f' y - f' x)‖ ≤ ε * ‖y - x‖ from mem_nhdsWithin_iff.2 ⟨δ, δ_pos, fun y hy => by simpa using this y hy⟩ suffices ∀ p : E × E, p ∈ closure ((B ∩ s) ×ˢ (B ∩ s)) → ‖f p.2 - f p.1 - (f' p.2 - f' p.1)‖ ≤ ε * ‖p.2 - p.1‖ by rw [closure_prod_eq] at this intro y y_in apply this ⟨x, y⟩ have : B ∩ closure s ⊆ closure (B ∩ s) := isOpen_ball.inter_closure exact ⟨this ⟨mem_ball_self δ_pos, hx⟩, this y_in⟩ have key : ∀ p : E × E, p ∈ (B ∩ s) ×ˢ (B ∩ s) → ‖f p.2 - f p.1 - (f' p.2 - f' p.1)‖ ≤ ε * ‖p.2 - p.1‖ := by rintro ⟨u, v⟩ ⟨u_in, v_in⟩ have conv : Convex ℝ (B ∩ s) := (convex_ball _ _).inter s_conv have diff : DifferentiableOn ℝ f (B ∩ s) := f_diff.mono inter_subset_right have bound : ∀ z ∈ B ∩ s, ‖fderivWithin ℝ f (B ∩ s) z - f'‖ ≤ ε := by intro z z_in have h := hδ z have : fderivWithin ℝ f (B ∩ s) z = fderiv ℝ f z := by have op : IsOpen (B ∩ s) := isOpen_ball.inter s_open rw [DifferentiableAt.fderivWithin _ (op.uniqueDiffOn z z_in)] exact (diff z z_in).differentiableAt (IsOpen.mem_nhds op z_in) rw [← this] at h exact le_of_lt (h z_in.2 z_in.1) simpa using conv.norm_image_sub_le_of_norm_fderivWithin_le' diff bound u_in v_in rintro ⟨u, v⟩ uv_in have f_cont' : ∀ y ∈ closure s, ContinuousWithinAt (f - ⇑f') s y := by intro y y_in exact Tendsto.sub (f_cont y y_in) f'.cont.continuousWithinAt refine ContinuousWithinAt.closure_le uv_in ?_ ?_ key all_goals -- common start for both continuity proofs have : (B ∩ s) ×ˢ (B ∩ s) ⊆ s ×ˢ s := by mono <;> exact inter_subset_right obtain ⟨u_in, v_in⟩ : u ∈ closure s ∧ v ∈ closure s := by simpa [closure_prod_eq] using closure_mono this uv_in apply ContinuousWithinAt.mono _ this simp only [ContinuousWithinAt] · rw [nhdsWithin_prod_eq] have : ∀ u v, f v - f u - (f' v - f' u) = f v - f' v - (f u - f' u) := by intros; abel simp only [this] exact Tendsto.comp continuous_norm.continuousAt ((Tendsto.comp (f_cont' v v_in) tendsto_snd).sub <| Tendsto.comp (f_cont' u u_in) tendsto_fst) · apply tendsto_nhdsWithin_of_tendsto_nhds rw [nhds_prod_eq] exact tendsto_const_nhds.mul (Tendsto.comp continuous_norm.continuousAt <| tendsto_snd.sub tendsto_fst) #align has_fderiv_at_boundary_of_tendsto_fderiv has_fderiv_at_boundary_of_tendsto_fderiv
Mathlib/Analysis/Calculus/FDeriv/Extend.lean
111
140
theorem has_deriv_at_interval_left_endpoint_of_tendsto_deriv {s : Set ℝ} {e : E} {a : ℝ} {f : ℝ → E} (f_diff : DifferentiableOn ℝ f s) (f_lim : ContinuousWithinAt f s a) (hs : s ∈ 𝓝[>] a) (f_lim' : Tendsto (fun x => deriv f x) (𝓝[>] a) (𝓝 e)) : HasDerivWithinAt f e (Ici a) a := by
/- This is a specialization of `has_fderiv_at_boundary_of_tendsto_fderiv`. To be in the setting of this theorem, we need to work on an open interval with closure contained in `s ∪ {a}`, that we call `t = (a, b)`. Then, we check all the assumptions of this theorem and we apply it. -/ obtain ⟨b, ab : a < b, sab : Ioc a b ⊆ s⟩ := mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 hs let t := Ioo a b have ts : t ⊆ s := Subset.trans Ioo_subset_Ioc_self sab have t_diff : DifferentiableOn ℝ f t := f_diff.mono ts have t_conv : Convex ℝ t := convex_Ioo a b have t_open : IsOpen t := isOpen_Ioo have t_closure : closure t = Icc a b := closure_Ioo ab.ne have t_cont : ∀ y ∈ closure t, ContinuousWithinAt f t y := by rw [t_closure] intro y hy by_cases h : y = a · rw [h]; exact f_lim.mono ts · have : y ∈ s := sab ⟨lt_of_le_of_ne hy.1 (Ne.symm h), hy.2⟩ exact (f_diff.continuousOn y this).mono ts have t_diff' : Tendsto (fun x => fderiv ℝ f x) (𝓝[t] a) (𝓝 (smulRight (1 : ℝ →L[ℝ] ℝ) e)) := by simp only [deriv_fderiv.symm] exact Tendsto.comp (isBoundedBilinearMap_smulRight : IsBoundedBilinearMap ℝ _).continuous_right.continuousAt (tendsto_nhdsWithin_mono_left Ioo_subset_Ioi_self f_lim') -- now we can apply `has_fderiv_at_boundary_of_differentiable` have : HasDerivWithinAt f e (Icc a b) a := by rw [hasDerivWithinAt_iff_hasFDerivWithinAt, ← t_closure] exact has_fderiv_at_boundary_of_tendsto_fderiv t_diff t_conv t_open t_cont t_diff' exact this.mono_of_mem (Icc_mem_nhdsWithin_Ici <| left_mem_Ico.2 ab)
27
import Mathlib.CategoryTheory.GlueData import Mathlib.Topology.Category.TopCat.Limits.Pullbacks import Mathlib.Topology.Category.TopCat.Opens import Mathlib.Tactic.Generalize import Mathlib.CategoryTheory.Elementwise #align_import topology.gluing from "leanprover-community/mathlib"@"178a32653e369dce2da68dc6b2694e385d484ef1" noncomputable section open TopologicalSpace CategoryTheory universe v u open CategoryTheory.Limits namespace TopCat -- porting note (#5171): removed @[nolint has_nonempty_instance] structure GlueData extends GlueData TopCat where f_open : ∀ i j, OpenEmbedding (f i j) f_mono := fun i j => (TopCat.mono_iff_injective _).mpr (f_open i j).toEmbedding.inj set_option linter.uppercaseLean3 false in #align Top.glue_data TopCat.GlueData namespace GlueData variable (D : GlueData.{u}) local notation "𝖣" => D.toGlueData theorem π_surjective : Function.Surjective 𝖣.π := (TopCat.epi_iff_surjective 𝖣.π).mp inferInstance set_option linter.uppercaseLean3 false in #align Top.glue_data.π_surjective TopCat.GlueData.π_surjective theorem isOpen_iff (U : Set 𝖣.glued) : IsOpen U ↔ ∀ i, IsOpen (𝖣.ι i ⁻¹' U) := by delta CategoryTheory.GlueData.ι simp_rw [← Multicoequalizer.ι_sigmaπ 𝖣.diagram] rw [← (homeoOfIso (Multicoequalizer.isoCoequalizer 𝖣.diagram).symm).isOpen_preimage] rw [coequalizer_isOpen_iff] dsimp only [GlueData.diagram_l, GlueData.diagram_left, GlueData.diagram_r, GlueData.diagram_right, parallelPair_obj_one] rw [colimit_isOpen_iff.{_,u}] -- Porting note: changed `.{u}` to `.{_,u}`. fun fact: the proof -- breaks down if this `rw` is merged with the `rw` above. constructor · intro h j; exact h ⟨j⟩ · intro h j; cases j; apply h set_option linter.uppercaseLean3 false in #align Top.glue_data.is_open_iff TopCat.GlueData.isOpen_iff theorem ι_jointly_surjective (x : 𝖣.glued) : ∃ (i : _) (y : D.U i), 𝖣.ι i y = x := 𝖣.ι_jointly_surjective (forget TopCat) x set_option linter.uppercaseLean3 false in #align Top.glue_data.ι_jointly_surjective TopCat.GlueData.ι_jointly_surjective def Rel (a b : Σ i, ((D.U i : TopCat) : Type _)) : Prop := a = b ∨ ∃ x : D.V (a.1, b.1), D.f _ _ x = a.2 ∧ D.f _ _ (D.t _ _ x) = b.2 set_option linter.uppercaseLean3 false in #align Top.glue_data.rel TopCat.GlueData.Rel theorem rel_equiv : Equivalence D.Rel := ⟨fun x => Or.inl (refl x), by rintro a b (⟨⟨⟩⟩ | ⟨x, e₁, e₂⟩) exacts [Or.inl rfl, Or.inr ⟨D.t _ _ x, e₂, by erw [← e₁, D.t_inv_apply]⟩], by -- previous line now `erw` after #13170 rintro ⟨i, a⟩ ⟨j, b⟩ ⟨k, c⟩ (⟨⟨⟩⟩ | ⟨x, e₁, e₂⟩) · exact id rintro (⟨⟨⟩⟩ | ⟨y, e₃, e₄⟩) · exact Or.inr ⟨x, e₁, e₂⟩ let z := (pullbackIsoProdSubtype (D.f j i) (D.f j k)).inv ⟨⟨_, _⟩, e₂.trans e₃.symm⟩ have eq₁ : (D.t j i) ((pullback.fst : _ ⟶ D.V (j, i)) z) = x := by dsimp only [coe_of, z] erw [pullbackIsoProdSubtype_inv_fst_apply, D.t_inv_apply]-- now `erw` after #13170 have eq₂ : (pullback.snd : _ ⟶ D.V _) z = y := pullbackIsoProdSubtype_inv_snd_apply _ _ _ clear_value z right use (pullback.fst : _ ⟶ D.V (i, k)) (D.t' _ _ _ z) dsimp only at * substs eq₁ eq₂ e₁ e₃ e₄ have h₁ : D.t' j i k ≫ pullback.fst ≫ D.f i k = pullback.fst ≫ D.t j i ≫ D.f i j := by rw [← 𝖣.t_fac_assoc]; congr 1; exact pullback.condition have h₂ : D.t' j i k ≫ pullback.fst ≫ D.t i k ≫ D.f k i = pullback.snd ≫ D.t j k ≫ D.f k j := by rw [← 𝖣.t_fac_assoc] apply @Epi.left_cancellation _ _ _ _ (D.t' k j i) rw [𝖣.cocycle_assoc, 𝖣.t_fac_assoc, 𝖣.t_inv_assoc] exact pullback.condition.symm exact ⟨ContinuousMap.congr_fun h₁ z, ContinuousMap.congr_fun h₂ z⟩⟩ set_option linter.uppercaseLean3 false in #align Top.glue_data.rel_equiv TopCat.GlueData.rel_equiv open CategoryTheory.Limits.WalkingParallelPair
Mathlib/Topology/Gluing.lean
164
201
theorem eqvGen_of_π_eq -- Porting note: was `{x y : ∐ D.U} (h : 𝖣.π x = 𝖣.π y)` {x y : sigmaObj (β := D.toGlueData.J) (C := TopCat) D.toGlueData.U} (h : 𝖣.π x = 𝖣.π y) : EqvGen -- Porting note: was (Types.CoequalizerRel 𝖣.diagram.fstSigmaMap 𝖣.diagram.sndSigmaMap) (Types.CoequalizerRel (X := sigmaObj (β := D.toGlueData.diagram.L) (C := TopCat) (D.toGlueData.diagram).left) (Y := sigmaObj (β := D.toGlueData.diagram.R) (C := TopCat) (D.toGlueData.diagram).right) 𝖣.diagram.fstSigmaMap 𝖣.diagram.sndSigmaMap) x y := by
delta GlueData.π Multicoequalizer.sigmaπ at h -- Porting note: inlined `inferInstance` instead of leaving as a side goal. replace h := (TopCat.mono_iff_injective (Multicoequalizer.isoCoequalizer 𝖣.diagram).inv).mp inferInstance h let diagram := parallelPair 𝖣.diagram.fstSigmaMap 𝖣.diagram.sndSigmaMap ⋙ forget _ have : colimit.ι diagram one x = colimit.ι diagram one y := by dsimp only [coequalizer.π, ContinuousMap.toFun_eq_coe] at h -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [← ι_preservesColimitsIso_hom, forget_map_eq_coe, types_comp_apply, h] simp rfl have : (colimit.ι diagram _ ≫ colim.map _ ≫ (colimit.isoColimitCocone _).hom) _ = (colimit.ι diagram _ ≫ colim.map _ ≫ (colimit.isoColimitCocone _).hom) _ := (congr_arg (colim.map (diagramIsoParallelPair diagram).hom ≫ (colimit.isoColimitCocone (Types.coequalizerColimit _ _)).hom) this : _) -- Porting note: was -- simp only [eqToHom_refl, types_comp_apply, colimit.ι_map_assoc, -- diagramIsoParallelPair_hom_app, colimit.isoColimitCocone_ι_hom, types_id_apply] at this -- See https://github.com/leanprover-community/mathlib4/issues/5026 rw [colimit.ι_map_assoc, diagramIsoParallelPair_hom_app, eqToHom_refl, colimit.isoColimitCocone_ι_hom, types_comp_apply, types_id_apply, types_comp_apply, types_id_apply] at this exact Quot.eq.1 this
27
import Mathlib.Analysis.SpecialFunctions.Exponential import Mathlib.Combinatorics.Derangements.Finite import Mathlib.Order.Filter.Basic #align_import combinatorics.derangements.exponential from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open Filter NormedSpace open scoped Topology
Mathlib/Combinatorics/Derangements/Exponential.lean
24
52
theorem numDerangements_tendsto_inv_e : Tendsto (fun n => (numDerangements n : ℝ) / n.factorial) atTop (𝓝 (Real.exp (-1))) := by
-- we show that d(n)/n! is the partial sum of exp(-1), but offset by 1. -- this isn't entirely obvious, since we have to ensure that asc_factorial and -- factorial interact in the right way, e.g., that k ≤ n always let s : ℕ → ℝ := fun n => ∑ k ∈ Finset.range n, (-1 : ℝ) ^ k / k.factorial suffices ∀ n : ℕ, (numDerangements n : ℝ) / n.factorial = s (n + 1) by simp_rw [this] -- shift the function by 1, and then use the fact that the partial sums -- converge to the infinite sum rw [tendsto_add_atTop_iff_nat (f := fun n => ∑ k ∈ Finset.range n, (-1 : ℝ) ^ k / k.factorial) 1] apply HasSum.tendsto_sum_nat -- there's no specific lemma for ℝ that ∑ x^k/k! sums to exp(x), but it's -- true in more general fields, so use that lemma rw [Real.exp_eq_exp_ℝ] exact expSeries_div_hasSum_exp ℝ (-1 : ℝ) intro n rw [← Int.cast_natCast, numDerangements_sum] push_cast rw [Finset.sum_div] -- get down to individual terms refine Finset.sum_congr (refl _) ?_ intro k hk have h_le : k ≤ n := Finset.mem_range_succ_iff.mp hk rw [Nat.ascFactorial_eq_div, add_tsub_cancel_of_le h_le] push_cast [Nat.factorial_dvd_factorial h_le] field_simp [Nat.factorial_ne_zero] ring
27
import Mathlib.Dynamics.Ergodic.MeasurePreserving import Mathlib.LinearAlgebra.Determinant import Mathlib.LinearAlgebra.Matrix.Diagonal import Mathlib.LinearAlgebra.Matrix.Transvection import Mathlib.MeasureTheory.Group.LIntegral import Mathlib.MeasureTheory.Integral.Marginal import Mathlib.MeasureTheory.Measure.Stieltjes import Mathlib.MeasureTheory.Measure.Haar.OfBasis #align_import measure_theory.measure.lebesgue.basic from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" assert_not_exists MeasureTheory.integral noncomputable section open scoped Classical open Set Filter MeasureTheory MeasureTheory.Measure TopologicalSpace open ENNReal (ofReal) open scoped ENNReal NNReal Topology
Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean
624
653
theorem ae_restrict_of_ae_restrict_inter_Ioo {μ : Measure ℝ} [NoAtoms μ] {s : Set ℝ} {p : ℝ → Prop} (h : ∀ a b, a ∈ s → b ∈ s → a < b → ∀ᵐ x ∂μ.restrict (s ∩ Ioo a b), p x) : ∀ᵐ x ∂μ.restrict s, p x := by
/- By second-countability, we cover `s` by countably many intervals `(a, b)` (except maybe for two endpoints, which don't matter since `μ` does not have any atom). -/ let T : s × s → Set ℝ := fun p => Ioo p.1 p.2 let u := ⋃ i : ↥s × ↥s, T i have hfinite : (s \ u).Finite := s.finite_diff_iUnion_Ioo' obtain ⟨A, A_count, hA⟩ : ∃ A : Set (↥s × ↥s), A.Countable ∧ ⋃ i ∈ A, T i = ⋃ i : ↥s × ↥s, T i := isOpen_iUnion_countable _ fun p => isOpen_Ioo have : s ⊆ s \ u ∪ ⋃ p ∈ A, s ∩ T p := by intro x hx by_cases h'x : x ∈ ⋃ i : ↥s × ↥s, T i · rw [← hA] at h'x obtain ⟨p, pA, xp⟩ : ∃ p : ↥s × ↥s, p ∈ A ∧ x ∈ T p := by simpa only [mem_iUnion, exists_prop, SetCoe.exists, exists_and_right] using h'x right exact mem_biUnion pA ⟨hx, xp⟩ · exact Or.inl ⟨hx, h'x⟩ apply ae_restrict_of_ae_restrict_of_subset this rw [ae_restrict_union_iff, ae_restrict_biUnion_iff _ A_count] constructor · have : μ.restrict (s \ u) = 0 := by simp only [restrict_eq_zero, hfinite.measure_zero] simp only [this, ae_zero, eventually_bot] · rintro ⟨⟨a, as⟩, ⟨b, bs⟩⟩ - dsimp [T] rcases le_or_lt b a with (hba | hab) · simp only [Ioo_eq_empty_of_le hba, inter_empty, restrict_empty, ae_zero, eventually_bot] · exact h a b as bs hab
27
import Mathlib.Algebra.Field.Subfield import Mathlib.Topology.Algebra.Field import Mathlib.Topology.Algebra.UniformRing #align_import topology.algebra.uniform_field from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" noncomputable section open scoped Classical open uniformity Topology open Set UniformSpace UniformSpace.Completion Filter variable (K : Type*) [Field K] [UniformSpace K] local notation "hat" => Completion class CompletableTopField extends T0Space K : Prop where nice : ∀ F : Filter K, Cauchy F → 𝓝 0 ⊓ F = ⊥ → Cauchy (map (fun x => x⁻¹) F) #align completable_top_field CompletableTopField namespace UniformSpace namespace Completion instance (priority := 100) [T0Space K] : Nontrivial (hat K) := ⟨⟨0, 1, fun h => zero_ne_one <| (uniformEmbedding_coe K).inj h⟩⟩ variable {K} def hatInv : hat K → hat K := denseInducing_coe.extend fun x : K => (↑x⁻¹ : hat K) #align uniform_space.completion.hat_inv UniformSpace.Completion.hatInv theorem continuous_hatInv [CompletableTopField K] {x : hat K} (h : x ≠ 0) : ContinuousAt hatInv x := by refine denseInducing_coe.continuousAt_extend ?_ apply mem_of_superset (compl_singleton_mem_nhds h) intro y y_ne rw [mem_compl_singleton_iff] at y_ne apply CompleteSpace.complete have : (fun (x : K) => (↑x⁻¹: hat K)) = ((fun (y : K) => (↑y: hat K))∘(fun (x : K) => (x⁻¹ : K))) := by unfold Function.comp simp rw [this, ← Filter.map_map] apply Cauchy.map _ (Completion.uniformContinuous_coe K) apply CompletableTopField.nice · haveI := denseInducing_coe.comap_nhds_neBot y apply cauchy_nhds.comap rw [Completion.comap_coe_eq_uniformity] · have eq_bot : 𝓝 (0 : hat K) ⊓ 𝓝 y = ⊥ := by by_contra h exact y_ne (eq_of_nhds_neBot <| neBot_iff.mpr h).symm erw [denseInducing_coe.nhds_eq_comap (0 : K), ← Filter.comap_inf, eq_bot] exact comap_bot #align uniform_space.completion.continuous_hat_inv UniformSpace.Completion.continuous_hatInv instance instInvCompletion : Inv (hat K) := ⟨fun x => if x = 0 then 0 else hatInv x⟩ variable [TopologicalDivisionRing K] theorem hatInv_extends {x : K} (h : x ≠ 0) : hatInv (x : hat K) = ↑(x⁻¹ : K) := denseInducing_coe.extend_eq_at ((continuous_coe K).continuousAt.comp (continuousAt_inv₀ h)) #align uniform_space.completion.hat_inv_extends UniformSpace.Completion.hatInv_extends variable [CompletableTopField K] @[norm_cast] theorem coe_inv (x : K) : (x : hat K)⁻¹ = ((x⁻¹ : K) : hat K) := by by_cases h : x = 0 · rw [h, inv_zero] dsimp [Inv.inv] norm_cast simp · conv_lhs => dsimp [Inv.inv] rw [if_neg] · exact hatInv_extends h · exact fun H => h (denseEmbedding_coe.inj H) #align uniform_space.completion.coe_inv UniformSpace.Completion.coe_inv variable [UniformAddGroup K]
Mathlib/Topology/Algebra/UniformField.lean
126
153
theorem mul_hatInv_cancel {x : hat K} (x_ne : x ≠ 0) : x * hatInv x = 1 := by
haveI : T1Space (hat K) := T2Space.t1Space let f := fun x : hat K => x * hatInv x let c := (fun (x : K) => (x : hat K)) change f x = 1 have cont : ContinuousAt f x := by letI : TopologicalSpace (hat K × hat K) := instTopologicalSpaceProd have : ContinuousAt (fun y : hat K => ((y, hatInv y) : hat K × hat K)) x := continuous_id.continuousAt.prod (continuous_hatInv x_ne) exact (_root_.continuous_mul.continuousAt.comp this : _) have clo : x ∈ closure (c '' {0}ᶜ) := by have := denseInducing_coe.dense x rw [← image_univ, show (univ : Set K) = {0} ∪ {0}ᶜ from (union_compl_self _).symm, image_union] at this apply mem_closure_of_mem_closure_union this rw [image_singleton] exact compl_singleton_mem_nhds x_ne have fxclo : f x ∈ closure (f '' (c '' {0}ᶜ)) := mem_closure_image cont clo have : f '' (c '' {0}ᶜ) ⊆ {1} := by rw [image_image] rintro _ ⟨z, z_ne, rfl⟩ rw [mem_singleton_iff] rw [mem_compl_singleton_iff] at z_ne dsimp [f] rw [hatInv_extends z_ne, ← coe_mul] rw [mul_inv_cancel z_ne, coe_one] replace fxclo := closure_mono this fxclo rwa [closure_singleton, mem_singleton_iff] at fxclo
27
import Mathlib.Data.DFinsupp.Lex import Mathlib.Order.GameAdd import Mathlib.Order.Antisymmetrization import Mathlib.SetTheory.Ordinal.Basic import Mathlib.Tactic.AdaptationNote #align_import data.dfinsupp.well_founded from "leanprover-community/mathlib"@"e9b8651eb1ad354f4de6be35a38ef31efcd2cfaa" variable {ι : Type*} {α : ι → Type*} namespace DFinsupp open Relation Prod section Zero variable [∀ i, Zero (α i)] (r : ι → ι → Prop) (s : ∀ i, α i → α i → Prop)
Mathlib/Data/DFinsupp/WellFounded.lean
69
98
theorem lex_fibration [∀ (i) (s : Set ι), Decidable (i ∈ s)] : Fibration (InvImage (GameAdd (DFinsupp.Lex r s) (DFinsupp.Lex r s)) snd) (DFinsupp.Lex r s) fun x => piecewise x.2.1 x.2.2 x.1 := by
rintro ⟨p, x₁, x₂⟩ x ⟨i, hr, hs⟩ simp_rw [piecewise_apply] at hs hr split_ifs at hs with hp · refine ⟨⟨{ j | r j i → j ∈ p }, piecewise x₁ x { j | r j i }, x₂⟩, .fst ⟨i, fun j hj ↦ ?_, ?_⟩, ?_⟩ <;> simp only [piecewise_apply, Set.mem_setOf_eq] · simp only [if_pos hj] · split_ifs with hi · rwa [hr i hi, if_pos hp] at hs · assumption · ext1 j simp only [piecewise_apply, Set.mem_setOf_eq] split_ifs with h₁ h₂ <;> try rfl · rw [hr j h₂, if_pos (h₁ h₂)] · rw [Classical.not_imp] at h₁ rw [hr j h₁.1, if_neg h₁.2] · refine ⟨⟨{ j | r j i ∧ j ∈ p }, x₁, piecewise x₂ x { j | r j i }⟩, .snd ⟨i, fun j hj ↦ ?_, ?_⟩, ?_⟩ <;> simp only [piecewise_apply, Set.mem_setOf_eq] · exact if_pos hj · split_ifs with hi · rwa [hr i hi, if_neg hp] at hs · assumption · ext1 j simp only [piecewise_apply, Set.mem_setOf_eq] split_ifs with h₁ h₂ <;> try rfl · rw [hr j h₁.1, if_pos h₁.2] · rw [hr j h₂, if_neg] simpa [h₂] using h₁
27
import Mathlib.AlgebraicGeometry.Morphisms.QuasiCompact import Mathlib.Topology.QuasiSeparated #align_import algebraic_geometry.morphisms.quasi_separated from "leanprover-community/mathlib"@"1a51edf13debfcbe223fa06b1cb353b9ed9751cc" noncomputable section open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace universe u open scoped AlgebraicGeometry namespace AlgebraicGeometry variable {X Y : Scheme.{u}} (f : X ⟶ Y) @[mk_iff] class QuasiSeparated (f : X ⟶ Y) : Prop where diagonalQuasiCompact : QuasiCompact (pullback.diagonal f) := by infer_instance #align algebraic_geometry.quasi_separated AlgebraicGeometry.QuasiSeparated def QuasiSeparated.affineProperty : AffineTargetMorphismProperty := fun X _ _ _ => QuasiSeparatedSpace X.carrier #align algebraic_geometry.quasi_separated.affine_property AlgebraicGeometry.QuasiSeparated.affineProperty theorem quasiSeparatedSpace_iff_affine (X : Scheme) : QuasiSeparatedSpace X.carrier ↔ ∀ U V : X.affineOpens, IsCompact (U ∩ V : Set X.carrier) := by rw [quasiSeparatedSpace_iff] constructor · intro H U V; exact H U V U.1.2 U.2.isCompact V.1.2 V.2.isCompact · intro H suffices ∀ (U : Opens X.carrier) (_ : IsCompact U.1) (V : Opens X.carrier) (_ : IsCompact V.1), IsCompact (U ⊓ V).1 by intro U V hU hU' hV hV'; exact this ⟨U, hU⟩ hU' ⟨V, hV⟩ hV' intro U hU V hV -- Porting note: it complains "unable to find motive", but telling Lean that motive is -- underscore is actually sufficient, weird apply compact_open_induction_on (P := _) V hV · simp · intro S _ V hV change IsCompact (U.1 ∩ (S.1 ∪ V.1)) rw [Set.inter_union_distrib_left] apply hV.union clear hV apply compact_open_induction_on (P := _) U hU · simp · intro S _ W hW change IsCompact ((S.1 ∪ W.1) ∩ V.1) rw [Set.union_inter_distrib_right] apply hW.union apply H #align algebraic_geometry.quasi_separated_space_iff_affine AlgebraicGeometry.quasiSeparatedSpace_iff_affine
Mathlib/AlgebraicGeometry/Morphisms/QuasiSeparated.lean
86
114
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y] (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
delta AffineTargetMorphismProperty.diagonal rw [quasiSeparatedSpace_iff_affine] constructor · intro H U V haveI : IsAffine _ := U.2 haveI : IsAffine _ := V.2 let g : pullback (X.ofRestrict U.1.openEmbedding) (X.ofRestrict V.1.openEmbedding) ⟶ X := pullback.fst ≫ X.ofRestrict _ -- Porting note: `inferInstance` does not work here have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _ have e := Homeomorph.ofEmbedding _ this.base_open.toEmbedding rw [IsOpenImmersion.range_pullback_to_base_of_left] at e erw [Subtype.range_coe, Subtype.range_coe] at e rw [isCompact_iff_compactSpace] exact @Homeomorph.compactSpace _ _ _ _ (H _ _) e · introv H h₁ h₂ let g : pullback f₁ f₂ ⟶ X := pullback.fst ≫ f₁ -- Porting note: `inferInstance` does not work here have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _ have e := Homeomorph.ofEmbedding _ this.base_open.toEmbedding rw [IsOpenImmersion.range_pullback_to_base_of_left] at e simp_rw [isCompact_iff_compactSpace] at H exact @Homeomorph.compactSpace _ _ _ _ (H ⟨⟨_, h₁.base_open.isOpen_range⟩, rangeIsAffineOpenOfOpenImmersion _⟩ ⟨⟨_, h₂.base_open.isOpen_range⟩, rangeIsAffineOpenOfOpenImmersion _⟩) e.symm
27
import Mathlib.Order.SuccPred.Basic import Mathlib.Topology.Order.Basic import Mathlib.Topology.Metrizable.Uniformity #align_import topology.instances.discrete from "leanprover-community/mathlib"@"bcfa726826abd57587355b4b5b7e78ad6527b7e4" open Order Set TopologicalSpace Filter variable {α : Type*} [TopologicalSpace α] instance (priority := 100) DiscreteTopology.firstCountableTopology [DiscreteTopology α] : FirstCountableTopology α where nhds_generated_countable := by rw [nhds_discrete]; exact isCountablyGenerated_pure #align discrete_topology.first_countable_topology DiscreteTopology.firstCountableTopology instance (priority := 100) DiscreteTopology.secondCountableTopology_of_countable [hd : DiscreteTopology α] [Countable α] : SecondCountableTopology α := haveI : ∀ i : α, SecondCountableTopology (↥({i} : Set α)) := fun i => { is_open_generated_countable := ⟨{univ}, countable_singleton _, by simp only [eq_iff_true_of_subsingleton]⟩ } secondCountableTopology_of_countable_cover (singletons_open_iff_discrete.mpr hd) (iUnion_of_singleton α) #align discrete_topology.second_countable_topology_of_encodable DiscreteTopology.secondCountableTopology_of_countable @[deprecated DiscreteTopology.secondCountableTopology_of_countable (since := "2024-03-11")] theorem DiscreteTopology.secondCountableTopology_of_encodable {α : Type*} [TopologicalSpace α] [DiscreteTopology α] [Countable α] : SecondCountableTopology α := DiscreteTopology.secondCountableTopology_of_countable #align discrete_topology.second_countable_topology_of_countable DiscreteTopology.secondCountableTopology_of_countable theorem bot_topologicalSpace_eq_generateFrom_of_pred_succOrder [PartialOrder α] [PredOrder α] [SuccOrder α] [NoMinOrder α] [NoMaxOrder α] : (⊥ : TopologicalSpace α) = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } := by refine (eq_bot_of_singletons_open fun a => ?_).symm have h_singleton_eq_inter : {a} = Iio (succ a) ∩ Ioi (pred a) := by suffices h_singleton_eq_inter' : {a} = Iic a ∩ Ici a by rw [h_singleton_eq_inter', ← Ioi_pred, ← Iio_succ] rw [inter_comm, Ici_inter_Iic, Icc_self a] rw [h_singleton_eq_inter] letI := Preorder.topology α apply IsOpen.inter · exact isOpen_generateFrom_of_mem ⟨succ a, Or.inr rfl⟩ · exact isOpen_generateFrom_of_mem ⟨pred a, Or.inl rfl⟩ #align bot_topological_space_eq_generate_from_of_pred_succ_order bot_topologicalSpace_eq_generateFrom_of_pred_succOrder theorem discreteTopology_iff_orderTopology_of_pred_succ' [PartialOrder α] [PredOrder α] [SuccOrder α] [NoMinOrder α] [NoMaxOrder α] : DiscreteTopology α ↔ OrderTopology α := by refine ⟨fun h => ⟨?_⟩, fun h => ⟨?_⟩⟩ · rw [h.eq_bot] exact bot_topologicalSpace_eq_generateFrom_of_pred_succOrder · rw [h.topology_eq_generate_intervals] exact bot_topologicalSpace_eq_generateFrom_of_pred_succOrder.symm #align discrete_topology_iff_order_topology_of_pred_succ' discreteTopology_iff_orderTopology_of_pred_succ' instance (priority := 100) DiscreteTopology.orderTopology_of_pred_succ' [h : DiscreteTopology α] [PartialOrder α] [PredOrder α] [SuccOrder α] [NoMinOrder α] [NoMaxOrder α] : OrderTopology α := discreteTopology_iff_orderTopology_of_pred_succ'.1 h #align discrete_topology.order_topology_of_pred_succ' DiscreteTopology.orderTopology_of_pred_succ'
Mathlib/Topology/Instances/Discrete.lean
80
108
theorem LinearOrder.bot_topologicalSpace_eq_generateFrom [LinearOrder α] [PredOrder α] [SuccOrder α] : (⊥ : TopologicalSpace α) = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } := by
refine (eq_bot_of_singletons_open fun a => ?_).symm have h_singleton_eq_inter : {a} = Iic a ∩ Ici a := by rw [inter_comm, Ici_inter_Iic, Icc_self a] by_cases ha_top : IsTop a · rw [ha_top.Iic_eq, inter_comm, inter_univ] at h_singleton_eq_inter by_cases ha_bot : IsBot a · rw [ha_bot.Ici_eq] at h_singleton_eq_inter rw [h_singleton_eq_inter] -- Porting note: Specified instance for `isOpen_univ` explicitly to fix an error. apply @isOpen_univ _ (generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a }) · rw [isBot_iff_isMin] at ha_bot rw [← Ioi_pred_of_not_isMin ha_bot] at h_singleton_eq_inter rw [h_singleton_eq_inter] exact isOpen_generateFrom_of_mem ⟨pred a, Or.inl rfl⟩ · rw [isTop_iff_isMax] at ha_top rw [← Iio_succ_of_not_isMax ha_top] at h_singleton_eq_inter by_cases ha_bot : IsBot a · rw [ha_bot.Ici_eq, inter_univ] at h_singleton_eq_inter rw [h_singleton_eq_inter] exact isOpen_generateFrom_of_mem ⟨succ a, Or.inr rfl⟩ · rw [isBot_iff_isMin] at ha_bot rw [← Ioi_pred_of_not_isMin ha_bot] at h_singleton_eq_inter rw [h_singleton_eq_inter] -- Porting note: Specified instance for `IsOpen.inter` explicitly to fix an error. letI := Preorder.topology α apply IsOpen.inter · exact isOpen_generateFrom_of_mem ⟨succ a, Or.inr rfl⟩ · exact isOpen_generateFrom_of_mem ⟨pred a, Or.inl rfl⟩
27
import Mathlib.Analysis.Analytic.IsolatedZeros import Mathlib.Analysis.Complex.CauchyIntegral import Mathlib.Analysis.Complex.AbsMax #align_import analysis.complex.open_mapping from "leanprover-community/mathlib"@"f9dd3204df14a0749cd456fac1e6849dfe7d2b88" open Set Filter Metric Complex open scoped Topology variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {U : Set E} {f : ℂ → ℂ} {g : E → ℂ} {z₀ w : ℂ} {ε r m : ℝ} theorem DiffContOnCl.ball_subset_image_closedBall (h : DiffContOnCl ℂ f (ball z₀ r)) (hr : 0 < r) (hf : ∀ z ∈ sphere z₀ r, ε ≤ ‖f z - f z₀‖) (hz₀ : ∃ᶠ z in 𝓝 z₀, f z ≠ f z₀) : ball (f z₀) (ε / 2) ⊆ f '' closedBall z₀ r := by rintro v hv have h1 : DiffContOnCl ℂ (fun z => f z - v) (ball z₀ r) := h.sub_const v have h2 : ContinuousOn (fun z => ‖f z - v‖) (closedBall z₀ r) := continuous_norm.comp_continuousOn (closure_ball z₀ hr.ne.symm ▸ h1.continuousOn) have h3 : AnalyticOn ℂ f (ball z₀ r) := h.differentiableOn.analyticOn isOpen_ball have h4 : ∀ z ∈ sphere z₀ r, ε / 2 ≤ ‖f z - v‖ := fun z hz => by linarith [hf z hz, show ‖v - f z₀‖ < ε / 2 from mem_ball.mp hv, norm_sub_sub_norm_sub_le_norm_sub (f z) v (f z₀)] have h5 : ‖f z₀ - v‖ < ε / 2 := by simpa [← dist_eq_norm, dist_comm] using mem_ball.mp hv obtain ⟨z, hz1, hz2⟩ : ∃ z ∈ ball z₀ r, IsLocalMin (fun z => ‖f z - v‖) z := exists_isLocalMin_mem_ball h2 (mem_closedBall_self hr.le) fun z hz => h5.trans_le (h4 z hz) refine ⟨z, ball_subset_closedBall hz1, sub_eq_zero.mp ?_⟩ have h6 := h1.differentiableOn.eventually_differentiableAt (isOpen_ball.mem_nhds hz1) refine (eventually_eq_or_eq_zero_of_isLocalMin_norm h6 hz2).resolve_left fun key => ?_ have h7 : ∀ᶠ w in 𝓝 z, f w = f z := by filter_upwards [key] with h; field_simp replace h7 : ∃ᶠ w in 𝓝[≠] z, f w = f z := (h7.filter_mono nhdsWithin_le_nhds).frequently have h8 : IsPreconnected (ball z₀ r) := (convex_ball z₀ r).isPreconnected have h9 := h3.eqOn_of_preconnected_of_frequently_eq analyticOn_const h8 hz1 h7 have h10 : f z = f z₀ := (h9 (mem_ball_self hr)).symm exact not_eventually.mpr hz₀ (mem_of_superset (ball_mem_nhds z₀ hr) (h10 ▸ h9)) #align diff_cont_on_cl.ball_subset_image_closed_ball DiffContOnCl.ball_subset_image_closedBall
Mathlib/Analysis/Complex/OpenMapping.lean
77
106
theorem AnalyticAt.eventually_constant_or_nhds_le_map_nhds_aux (hf : AnalyticAt ℂ f z₀) : (∀ᶠ z in 𝓝 z₀, f z = f z₀) ∨ 𝓝 (f z₀) ≤ map f (𝓝 z₀) := by
/- The function `f` is analytic in a neighborhood of `z₀`; by the isolated zeros principle, if `f` is not constant in a neighborhood of `z₀`, then it is nonzero, and therefore bounded below, on every small enough circle around `z₀` and then `DiffContOnCl.ball_subset_image_closedBall` provides an explicit ball centered at `f z₀` contained in the range of `f`. -/ refine or_iff_not_imp_left.mpr fun h => ?_ refine (nhds_basis_ball.le_basis_iff (nhds_basis_closedBall.map f)).mpr fun R hR => ?_ have h1 := (hf.eventually_eq_or_eventually_ne analyticAt_const).resolve_left h have h2 : ∀ᶠ z in 𝓝 z₀, AnalyticAt ℂ f z := (isOpen_analyticAt ℂ f).eventually_mem hf obtain ⟨ρ, hρ, h3, h4⟩ : ∃ ρ > 0, AnalyticOn ℂ f (closedBall z₀ ρ) ∧ ∀ z ∈ closedBall z₀ ρ, z ≠ z₀ → f z ≠ f z₀ := by simpa only [setOf_and, subset_inter_iff] using nhds_basis_closedBall.mem_iff.mp (h2.and (eventually_nhdsWithin_iff.mp h1)) replace h3 : DiffContOnCl ℂ f (ball z₀ ρ) := ⟨h3.differentiableOn.mono ball_subset_closedBall, (closure_ball z₀ hρ.lt.ne.symm).symm ▸ h3.continuousOn⟩ let r := ρ ⊓ R have hr : 0 < r := lt_inf_iff.mpr ⟨hρ, hR⟩ have h5 : closedBall z₀ r ⊆ closedBall z₀ ρ := closedBall_subset_closedBall inf_le_left have h6 : DiffContOnCl ℂ f (ball z₀ r) := h3.mono (ball_subset_ball inf_le_left) have h7 : ∀ z ∈ sphere z₀ r, f z ≠ f z₀ := fun z hz => h4 z (h5 (sphere_subset_closedBall hz)) (ne_of_mem_sphere hz hr.ne.symm) have h8 : (sphere z₀ r).Nonempty := NormedSpace.sphere_nonempty.mpr hr.le have h9 : ContinuousOn (fun x => ‖f x - f z₀‖) (sphere z₀ r) := continuous_norm.comp_continuousOn ((h6.sub_const (f z₀)).continuousOn_ball.mono sphere_subset_closedBall) obtain ⟨x, hx, hfx⟩ := (isCompact_sphere z₀ r).exists_isMinOn h8 h9 refine ⟨‖f x - f z₀‖ / 2, half_pos (norm_sub_pos_iff.mpr (h7 x hx)), ?_⟩ exact (h6.ball_subset_image_closedBall hr (fun z hz => hfx hz) (not_eventually.mp h)).trans (image_subset f (closedBall_subset_closedBall inf_le_right))
28
import Mathlib.Data.Nat.Choose.Dvd import Mathlib.RingTheory.IntegrallyClosed import Mathlib.RingTheory.Norm import Mathlib.RingTheory.Polynomial.Cyclotomic.Expand #align_import ring_theory.polynomial.eisenstein.is_integral from "leanprover-community/mathlib"@"5bfbcca0a7ffdd21cf1682e59106d6c942434a32" universe u v w z variable {R : Type u} open Ideal Algebra Finset open scoped Polynomial section Cyclotomic variable (p : ℕ) local notation "𝓟" => Submodule.span ℤ {(p : ℤ)} open Polynomial
Mathlib/RingTheory/Polynomial/Eisenstein/IsIntegral.lean
44
73
theorem cyclotomic_comp_X_add_one_isEisensteinAt [hp : Fact p.Prime] : ((cyclotomic p ℤ).comp (X + 1)).IsEisensteinAt 𝓟 := by
refine Monic.isEisensteinAt_of_mem_of_not_mem ?_ (Ideal.IsPrime.ne_top <| (Ideal.span_singleton_prime (mod_cast hp.out.ne_zero)).2 <| Nat.prime_iff_prime_int.1 hp.out) (fun {i hi} => ?_) ?_ · rw [show (X + 1 : ℤ[X]) = X + C 1 by simp] refine (cyclotomic.monic p ℤ).comp (monic_X_add_C 1) fun h => ?_ rw [natDegree_X_add_C] at h exact zero_ne_one h.symm · rw [cyclotomic_prime, geom_sum_X_comp_X_add_one_eq_sum, ← lcoeff_apply, map_sum] conv => congr congr next => skip ext rw [lcoeff_apply, ← C_eq_natCast, C_mul_X_pow_eq_monomial, coeff_monomial] rw [natDegree_comp, show (X + 1 : ℤ[X]) = X + C 1 by simp, natDegree_X_add_C, mul_one, natDegree_cyclotomic, Nat.totient_prime hp.out] at hi simp only [hi.trans_le (Nat.sub_le _ _), sum_ite_eq', mem_range, if_true, Ideal.submodule_span_eq, Ideal.mem_span_singleton, Int.natCast_dvd_natCast] exact hp.out.dvd_choose_self i.succ_ne_zero (lt_tsub_iff_right.1 hi) · rw [coeff_zero_eq_eval_zero, eval_comp, cyclotomic_prime, eval_add, eval_X, eval_one, zero_add, eval_geom_sum, one_geom_sum, Ideal.submodule_span_eq, Ideal.span_singleton_pow, Ideal.mem_span_singleton] intro h obtain ⟨k, hk⟩ := Int.natCast_dvd_natCast.1 h rw [mul_assoc, mul_comm 1, mul_one] at hk nth_rw 1 [← Nat.mul_one p] at hk rw [mul_right_inj' hp.out.ne_zero] at hk exact Nat.Prime.not_dvd_one hp.out (Dvd.intro k hk.symm)
28
import Mathlib.MeasureTheory.Measure.Regular import Mathlib.Topology.Semicontinuous import Mathlib.MeasureTheory.Integral.Bochner import Mathlib.Topology.Instances.EReal #align_import measure_theory.integral.vitali_caratheodory from "leanprover-community/mathlib"@"57ac39bd365c2f80589a700f9fbb664d3a1a30c2" open scoped ENNReal NNReal open MeasureTheory MeasureTheory.Measure variable {α : Type*} [TopologicalSpace α] [MeasurableSpace α] [BorelSpace α] (μ : Measure α) [WeaklyRegular μ] namespace MeasureTheory local infixr:25 " →ₛ " => SimpleFunc theorem SimpleFunc.exists_le_lowerSemicontinuous_lintegral_ge (f : α →ₛ ℝ≥0) {ε : ℝ≥0∞} (ε0 : ε ≠ 0) : ∃ g : α → ℝ≥0, (∀ x, f x ≤ g x) ∧ LowerSemicontinuous g ∧ (∫⁻ x, g x ∂μ) ≤ (∫⁻ x, f x ∂μ) + ε := by induction' f using MeasureTheory.SimpleFunc.induction with c s hs f₁ f₂ _ h₁ h₂ generalizing ε · let f := SimpleFunc.piecewise s hs (SimpleFunc.const α c) (SimpleFunc.const α 0) by_cases h : ∫⁻ x, f x ∂μ = ⊤ · refine ⟨fun _ => c, fun x => ?_, lowerSemicontinuous_const, by simp only [_root_.top_add, le_top, h]⟩ simp only [SimpleFunc.coe_const, SimpleFunc.const_zero, SimpleFunc.coe_zero, Set.piecewise_eq_indicator, SimpleFunc.coe_piecewise] exact Set.indicator_le_self _ _ _ by_cases hc : c = 0 · refine ⟨fun _ => 0, ?_, lowerSemicontinuous_const, ?_⟩ · classical simp only [hc, Set.indicator_zero', Pi.zero_apply, SimpleFunc.const_zero, imp_true_iff, eq_self_iff_true, SimpleFunc.coe_zero, Set.piecewise_eq_indicator, SimpleFunc.coe_piecewise, le_zero_iff] · simp only [lintegral_const, zero_mul, zero_le, ENNReal.coe_zero] have ne_top : μ s ≠ ⊤ := by classical simpa [f, hs, hc, lt_top_iff_ne_top, true_and_iff, SimpleFunc.coe_const, Function.const_apply, lintegral_const, ENNReal.coe_indicator, Set.univ_inter, ENNReal.coe_ne_top, MeasurableSet.univ, ENNReal.mul_eq_top, SimpleFunc.const_zero, or_false_iff, lintegral_indicator, ENNReal.coe_eq_zero, Ne, not_false_iff, SimpleFunc.coe_zero, Set.piecewise_eq_indicator, SimpleFunc.coe_piecewise, false_and_iff, restrict_apply] using h have : μ s < μ s + ε / c := by have : (0 : ℝ≥0∞) < ε / c := ENNReal.div_pos_iff.2 ⟨ε0, ENNReal.coe_ne_top⟩ simpa using ENNReal.add_lt_add_left ne_top this obtain ⟨u, su, u_open, μu⟩ : ∃ (u : _), u ⊇ s ∧ IsOpen u ∧ μ u < μ s + ε / c := s.exists_isOpen_lt_of_lt _ this refine ⟨Set.indicator u fun _ => c, fun x => ?_, u_open.lowerSemicontinuous_indicator (zero_le _), ?_⟩ · simp only [SimpleFunc.coe_const, SimpleFunc.const_zero, SimpleFunc.coe_zero, Set.piecewise_eq_indicator, SimpleFunc.coe_piecewise] exact Set.indicator_le_indicator_of_subset su (fun x => zero_le _) _ · suffices (c : ℝ≥0∞) * μ u ≤ c * μ s + ε by classical simpa only [ENNReal.coe_indicator, u_open.measurableSet, lintegral_indicator, lintegral_const, MeasurableSet.univ, Measure.restrict_apply, Set.univ_inter, const_zero, coe_piecewise, coe_const, coe_zero, Set.piecewise_eq_indicator, Function.const_apply, hs] calc (c : ℝ≥0∞) * μ u ≤ c * (μ s + ε / c) := mul_le_mul_left' μu.le _ _ = c * μ s + ε := by simp_rw [mul_add] rw [ENNReal.mul_div_cancel' _ ENNReal.coe_ne_top] simpa using hc · rcases h₁ (ENNReal.half_pos ε0).ne' with ⟨g₁, f₁_le_g₁, g₁cont, g₁int⟩ rcases h₂ (ENNReal.half_pos ε0).ne' with ⟨g₂, f₂_le_g₂, g₂cont, g₂int⟩ refine ⟨fun x => g₁ x + g₂ x, fun x => add_le_add (f₁_le_g₁ x) (f₂_le_g₂ x), g₁cont.add g₂cont, ?_⟩ simp only [SimpleFunc.coe_add, ENNReal.coe_add, Pi.add_apply] rw [lintegral_add_left f₁.measurable.coe_nnreal_ennreal, lintegral_add_left g₁cont.measurable.coe_nnreal_ennreal] convert add_le_add g₁int g₂int using 1 conv_lhs => rw [← ENNReal.add_halves ε] abel #align measure_theory.simple_func.exists_le_lower_semicontinuous_lintegral_ge MeasureTheory.SimpleFunc.exists_le_lowerSemicontinuous_lintegral_ge -- Porting note: errors with -- `ambiguous identifier 'eapproxDiff', possible interpretations:` -- `[SimpleFunc.eapproxDiff, SimpleFunc.eapproxDiff]` -- open SimpleFunc (eapproxDiff tsum_eapproxDiff)
Mathlib/MeasureTheory/Integral/VitaliCaratheodory.lean
164
195
theorem exists_le_lowerSemicontinuous_lintegral_ge (f : α → ℝ≥0∞) (hf : Measurable f) {ε : ℝ≥0∞} (εpos : ε ≠ 0) : ∃ g : α → ℝ≥0∞, (∀ x, f x ≤ g x) ∧ LowerSemicontinuous g ∧ (∫⁻ x, g x ∂μ) ≤ (∫⁻ x, f x ∂μ) + ε := by
rcases ENNReal.exists_pos_sum_of_countable' εpos ℕ with ⟨δ, δpos, hδ⟩ have : ∀ n, ∃ g : α → ℝ≥0, (∀ x, SimpleFunc.eapproxDiff f n x ≤ g x) ∧ LowerSemicontinuous g ∧ (∫⁻ x, g x ∂μ) ≤ (∫⁻ x, SimpleFunc.eapproxDiff f n x ∂μ) + δ n := fun n => SimpleFunc.exists_le_lowerSemicontinuous_lintegral_ge μ (SimpleFunc.eapproxDiff f n) (δpos n).ne' choose g f_le_g gcont hg using this refine ⟨fun x => ∑' n, g n x, fun x => ?_, ?_, ?_⟩ · rw [← SimpleFunc.tsum_eapproxDiff f hf] exact ENNReal.tsum_le_tsum fun n => ENNReal.coe_le_coe.2 (f_le_g n x) · refine lowerSemicontinuous_tsum fun n => ?_ exact ENNReal.continuous_coe.comp_lowerSemicontinuous (gcont n) fun x y hxy => ENNReal.coe_le_coe.2 hxy · calc ∫⁻ x, ∑' n : ℕ, g n x ∂μ = ∑' n, ∫⁻ x, g n x ∂μ := by rw [lintegral_tsum fun n => (gcont n).measurable.coe_nnreal_ennreal.aemeasurable] _ ≤ ∑' n, ((∫⁻ x, SimpleFunc.eapproxDiff f n x ∂μ) + δ n) := ENNReal.tsum_le_tsum hg _ = ∑' n, ∫⁻ x, SimpleFunc.eapproxDiff f n x ∂μ + ∑' n, δ n := ENNReal.tsum_add _ ≤ (∫⁻ x : α, f x ∂μ) + ε := by refine add_le_add ?_ hδ.le rw [← lintegral_tsum] · simp_rw [SimpleFunc.tsum_eapproxDiff f hf, le_refl] · intro n; exact (SimpleFunc.measurable _).coe_nnreal_ennreal.aemeasurable
28
import Mathlib.Analysis.Calculus.SmoothSeries import Mathlib.Analysis.Calculus.BumpFunction.InnerProduct import Mathlib.Analysis.Convolution import Mathlib.Analysis.InnerProductSpace.EuclideanDist import Mathlib.Data.Set.Pointwise.Support import Mathlib.MeasureTheory.Measure.Haar.NormedSpace import Mathlib.MeasureTheory.Measure.Haar.Unique #align_import analysis.calculus.bump_function_findim from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" noncomputable section open Set Metric TopologicalSpace Function Asymptotics MeasureTheory FiniteDimensional ContinuousLinearMap Filter MeasureTheory.Measure Bornology open scoped Pointwise Topology NNReal Convolution variable {E : Type*} [NormedAddCommGroup E] section variable [NormedSpace ℝ E] [FiniteDimensional ℝ E]
Mathlib/Analysis/Calculus/BumpFunction/FiniteDimension.lean
43
73
theorem exists_smooth_tsupport_subset {s : Set E} {x : E} (hs : s ∈ 𝓝 x) : ∃ f : E → ℝ, tsupport f ⊆ s ∧ HasCompactSupport f ∧ ContDiff ℝ ⊤ f ∧ range f ⊆ Icc 0 1 ∧ f x = 1 := by
obtain ⟨d : ℝ, d_pos : 0 < d, hd : Euclidean.closedBall x d ⊆ s⟩ := Euclidean.nhds_basis_closedBall.mem_iff.1 hs let c : ContDiffBump (toEuclidean x) := { rIn := d / 2 rOut := d rIn_pos := half_pos d_pos rIn_lt_rOut := half_lt_self d_pos } let f : E → ℝ := c ∘ toEuclidean have f_supp : f.support ⊆ Euclidean.ball x d := by intro y hy have : toEuclidean y ∈ Function.support c := by simpa only [Function.mem_support, Function.comp_apply, Ne] using hy rwa [c.support_eq] at this have f_tsupp : tsupport f ⊆ Euclidean.closedBall x d := by rw [tsupport, ← Euclidean.closure_ball _ d_pos.ne'] exact closure_mono f_supp refine ⟨f, f_tsupp.trans hd, ?_, ?_, ?_, ?_⟩ · refine isCompact_of_isClosed_isBounded isClosed_closure ?_ have : IsBounded (Euclidean.closedBall x d) := Euclidean.isCompact_closedBall.isBounded refine this.subset (Euclidean.isClosed_closedBall.closure_subset_iff.2 ?_) exact f_supp.trans Euclidean.ball_subset_closedBall · apply c.contDiff.comp exact ContinuousLinearEquiv.contDiff _ · rintro t ⟨y, rfl⟩ exact ⟨c.nonneg, c.le_one⟩ · apply c.one_of_mem_closedBall apply mem_closedBall_self exact (half_pos d_pos).le
28
import Mathlib.MeasureTheory.Integral.IntervalIntegral import Mathlib.Order.Filter.IndicatorFunction open MeasureTheory section DominatedConvergenceTheorem open Set Filter TopologicalSpace ENNReal open scoped Topology namespace MeasureTheory variable {α E G: Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] [NormedAddCommGroup G] [NormedSpace ℝ G] {f g : α → E} {m : MeasurableSpace α} {μ : Measure α} theorem tendsto_integral_of_dominated_convergence {F : ℕ → α → G} {f : α → G} (bound : α → ℝ) (F_measurable : ∀ n, AEStronglyMeasurable (F n) μ) (bound_integrable : Integrable bound μ) (h_bound : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop (𝓝 (f a))) : Tendsto (fun n => ∫ a, F n a ∂μ) atTop (𝓝 <| ∫ a, f a ∂μ) := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact tendsto_setToFun_of_dominated_convergence (dominatedFinMeasAdditive_weightedSMul μ) bound F_measurable bound_integrable h_bound h_lim · simp [integral, hG] #align measure_theory.tendsto_integral_of_dominated_convergence MeasureTheory.tendsto_integral_of_dominated_convergence theorem tendsto_integral_filter_of_dominated_convergence {ι} {l : Filter ι} [l.IsCountablyGenerated] {F : ι → α → G} {f : α → G} (bound : α → ℝ) (hF_meas : ∀ᶠ n in l, AEStronglyMeasurable (F n) μ) (h_bound : ∀ᶠ n in l, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) l (𝓝 (f a))) : Tendsto (fun n => ∫ a, F n a ∂μ) l (𝓝 <| ∫ a, f a ∂μ) := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact tendsto_setToFun_filter_of_dominated_convergence (dominatedFinMeasAdditive_weightedSMul μ) bound hF_meas h_bound bound_integrable h_lim · simp [integral, hG, tendsto_const_nhds] #align measure_theory.tendsto_integral_filter_of_dominated_convergence MeasureTheory.tendsto_integral_filter_of_dominated_convergence theorem hasSum_integral_of_dominated_convergence {ι} [Countable ι] {F : ι → α → G} {f : α → G} (bound : ι → α → ℝ) (hF_meas : ∀ n, AEStronglyMeasurable (F n) μ) (h_bound : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound n a) (bound_summable : ∀ᵐ a ∂μ, Summable fun n => bound n a) (bound_integrable : Integrable (fun a => ∑' n, bound n a) μ) (h_lim : ∀ᵐ a ∂μ, HasSum (fun n => F n a) (f a)) : HasSum (fun n => ∫ a, F n a ∂μ) (∫ a, f a ∂μ) := by have hb_nonneg : ∀ᵐ a ∂μ, ∀ n, 0 ≤ bound n a := eventually_countable_forall.2 fun n => (h_bound n).mono fun a => (norm_nonneg _).trans have hb_le_tsum : ∀ n, bound n ≤ᵐ[μ] fun a => ∑' n, bound n a := by intro n filter_upwards [hb_nonneg, bound_summable] with _ ha0 ha_sum using le_tsum ha_sum _ fun i _ => ha0 i have hF_integrable : ∀ n, Integrable (F n) μ := by refine fun n => bound_integrable.mono' (hF_meas n) ?_ exact EventuallyLE.trans (h_bound n) (hb_le_tsum n) simp only [HasSum, ← integral_finset_sum _ fun n _ => hF_integrable n] refine tendsto_integral_filter_of_dominated_convergence (fun a => ∑' n, bound n a) ?_ ?_ bound_integrable h_lim · exact eventually_of_forall fun s => s.aestronglyMeasurable_sum fun n _ => hF_meas n · filter_upwards with s filter_upwards [eventually_countable_forall.2 h_bound, hb_nonneg, bound_summable] with a hFa ha0 has calc ‖∑ n ∈ s, F n a‖ ≤ ∑ n ∈ s, bound n a := norm_sum_le_of_le _ fun n _ => hFa n _ ≤ ∑' n, bound n a := sum_le_tsum _ (fun n _ => ha0 n) has #align measure_theory.has_sum_integral_of_dominated_convergence MeasureTheory.hasSum_integral_of_dominated_convergence
Mathlib/MeasureTheory/Integral/DominatedConvergence.lean
107
137
theorem integral_tsum {ι} [Countable ι] {f : ι → α → G} (hf : ∀ i, AEStronglyMeasurable (f i) μ) (hf' : ∑' i, ∫⁻ a : α, ‖f i a‖₊ ∂μ ≠ ∞) : ∫ a : α, ∑' i, f i a ∂μ = ∑' i, ∫ a : α, f i a ∂μ := by
by_cases hG : CompleteSpace G; swap · simp [integral, hG] have hf'' : ∀ i, AEMeasurable (fun x => (‖f i x‖₊ : ℝ≥0∞)) μ := fun i => (hf i).ennnorm have hhh : ∀ᵐ a : α ∂μ, Summable fun n => (‖f n a‖₊ : ℝ) := by rw [← lintegral_tsum hf''] at hf' refine (ae_lt_top' (AEMeasurable.ennreal_tsum hf'') hf').mono ?_ intro x hx rw [← ENNReal.tsum_coe_ne_top_iff_summable_coe] exact hx.ne convert (MeasureTheory.hasSum_integral_of_dominated_convergence (fun i a => ‖f i a‖₊) hf _ hhh ⟨_, _⟩ _).tsum_eq.symm · intro n filter_upwards with x rfl · simp_rw [← NNReal.coe_tsum] rw [aestronglyMeasurable_iff_aemeasurable] apply AEMeasurable.coe_nnreal_real apply AEMeasurable.nnreal_tsum exact fun i => (hf i).nnnorm.aemeasurable · dsimp [HasFiniteIntegral] have : ∫⁻ a, ∑' n, ‖f n a‖₊ ∂μ < ⊤ := by rwa [lintegral_tsum hf'', lt_top_iff_ne_top] convert this using 1 apply lintegral_congr_ae simp_rw [← coe_nnnorm, ← NNReal.coe_tsum, NNReal.nnnorm_eq] filter_upwards [hhh] with a ha exact ENNReal.coe_tsum (NNReal.summable_coe.mp ha) · filter_upwards [hhh] with x hx exact hx.of_norm.hasSum
28
import Mathlib.CategoryTheory.Limits.Preserves.Finite import Mathlib.CategoryTheory.Sites.Canonical import Mathlib.CategoryTheory.Sites.Coherent.Basic import Mathlib.CategoryTheory.Sites.Preserves universe v u w namespace CategoryTheory open Limits variable {C : Type u} [Category.{v} C] variable [FinitaryPreExtensive C] class Presieve.Extensive {X : C} (R : Presieve X) : Prop where arrows_nonempty_isColimit : ∃ (α : Type) (_ : Finite α) (Z : α → C) (π : (a : α) → (Z a ⟶ X)), R = Presieve.ofArrows Z π ∧ Nonempty (IsColimit (Cofan.mk X π)) instance {X : C} (S : Presieve X) [S.Extensive] : S.hasPullbacks where has_pullbacks := by obtain ⟨_, _, _, _, rfl, ⟨hc⟩⟩ := Presieve.Extensive.arrows_nonempty_isColimit (R := S) intro _ _ _ _ _ hg cases hg apply FinitaryPreExtensive.hasPullbacks_of_is_coproduct hc open Presieve Opposite theorem isSheafFor_extensive_of_preservesFiniteProducts {X : C} (S : Presieve X) [S.Extensive] (F : Cᵒᵖ ⥤ Type w) [PreservesFiniteProducts F] : S.IsSheafFor F := by obtain ⟨α, _, Z, π, rfl, ⟨hc⟩⟩ := Extensive.arrows_nonempty_isColimit (R := S) have : (ofArrows Z (Cofan.mk X π).inj).hasPullbacks := (inferInstance : (ofArrows Z π).hasPullbacks) cases nonempty_fintype α exact isSheafFor_of_preservesProduct _ _ hc instance {α : Type} [Finite α] (Z : α → C) : (ofArrows Z (fun i ↦ Sigma.ι Z i)).Extensive := ⟨⟨α, inferInstance, Z, (fun i ↦ Sigma.ι Z i), rfl, ⟨coproductIsCoproduct _⟩⟩⟩ theorem extensiveTopology.isSheaf_yoneda_obj (W : C) : Presieve.IsSheaf (extensiveTopology C) (yoneda.obj W) := by erw [isSheaf_coverage] intro X R ⟨Y, α, Z, π, hR, hi⟩ have : IsIso (Sigma.desc (Cofan.inj (Cofan.mk X π))) := hi have : R.Extensive := ⟨Y, α, Z, π, hR, ⟨Cofan.isColimitOfIsIsoSigmaDesc (Cofan.mk X π)⟩⟩ exact isSheafFor_extensive_of_preservesFiniteProducts _ _ theorem extensiveTopology.subcanonical : Sheaf.Subcanonical (extensiveTopology C) := Sheaf.Subcanonical.of_yoneda_isSheaf _ isSheaf_yoneda_obj
Mathlib/CategoryTheory/Sites/Coherent/ExtensiveSheaves.lean
80
110
theorem Presieve.isSheaf_iff_preservesFiniteProducts [FinitaryExtensive C] (F : Cᵒᵖ ⥤ Type w) : Presieve.IsSheaf (extensiveTopology C) F ↔ Nonempty (PreservesFiniteProducts F) := by
refine ⟨fun hF ↦ ⟨⟨fun α _ ↦ ⟨fun {K} ↦ ?_⟩⟩⟩, fun hF ↦ ?_⟩ · erw [Presieve.isSheaf_coverage] at hF let Z : α → C := fun i ↦ unop (K.obj ⟨i⟩) have : (Presieve.ofArrows Z (Cofan.mk (∐ Z) (Sigma.ι Z)).inj).hasPullbacks := (inferInstance : (Presieve.ofArrows Z (Sigma.ι Z)).hasPullbacks) have : ∀ (i : α), Mono (Cofan.inj (Cofan.mk (∐ Z) (Sigma.ι Z)) i) := (inferInstance : ∀ (i : α), Mono (Sigma.ι Z i)) let i : K ≅ Discrete.functor (fun i ↦ op (Z i)) := Discrete.natIsoFunctor let _ : PreservesLimit (Discrete.functor (fun i ↦ op (Z i))) F := Presieve.preservesProductOfIsSheafFor F ?_ initialIsInitial _ (coproductIsCoproduct Z) (FinitaryExtensive.isPullback_initial_to_sigma_ι Z) (hF (Presieve.ofArrows Z (fun i ↦ Sigma.ι Z i)) ?_) · exact preservesLimitOfIsoDiagram F i.symm · apply hF refine ⟨Empty, inferInstance, Empty.elim, IsEmpty.elim inferInstance, rfl, ⟨default,?_, ?_⟩⟩ · ext b cases b · simp only [eq_iff_true_of_subsingleton] · refine ⟨α, inferInstance, Z, (fun i ↦ Sigma.ι Z i), rfl, ?_⟩ suffices Sigma.desc (fun i ↦ Sigma.ι Z i) = 𝟙 _ by rw [this]; infer_instance ext simp · let _ := hF.some erw [Presieve.isSheaf_coverage] intro X R ⟨Y, α, Z, π, hR, hi⟩ have : IsIso (Sigma.desc (Cofan.inj (Cofan.mk X π))) := hi have : R.Extensive := ⟨Y, α, Z, π, hR, ⟨Cofan.isColimitOfIsIsoSigmaDesc (Cofan.mk X π)⟩⟩ exact isSheafFor_extensive_of_preservesFiniteProducts R F
28
import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure import Mathlib.RingTheory.IntegralDomain #align_import field_theory.primitive_element from "leanprover-community/mathlib"@"df76f43357840485b9d04ed5dee5ab115d420e87" noncomputable section open scoped Classical Polynomial open FiniteDimensional Polynomial IntermediateField namespace Field variable (F E : Type*) [Field F] [Field E] variable [Algebra F E] section FiniteIntermediateField -- TODO: show a more generalized result: [F⟮α⟯ : F⟮α ^ m⟯] = m if m > 0 and α transcendental.
Mathlib/FieldTheory/PrimitiveElement.lean
246
275
theorem isAlgebraic_of_adjoin_eq_adjoin {α : E} {m n : ℕ} (hneq : m ≠ n) (heq : F⟮α ^ m⟯ = F⟮α ^ n⟯) : IsAlgebraic F α := by
wlog hmn : m < n · exact this F E hneq.symm heq.symm (hneq.lt_or_lt.resolve_left hmn) by_cases hm : m = 0 · rw [hm] at heq hmn simp only [pow_zero, adjoin_one] at heq obtain ⟨y, h⟩ := mem_bot.1 (heq.symm ▸ mem_adjoin_simple_self F (α ^ n)) refine ⟨X ^ n - C y, X_pow_sub_C_ne_zero hmn y, ?_⟩ simp only [map_sub, map_pow, aeval_X, aeval_C, h, sub_self] obtain ⟨r, s, h⟩ := (mem_adjoin_simple_iff F _).1 (heq ▸ mem_adjoin_simple_self F (α ^ m)) by_cases hzero : aeval (α ^ n) s = 0 · simp only [hzero, div_zero, pow_eq_zero_iff hm] at h exact h.symm ▸ isAlgebraic_zero replace hm : 0 < m := Nat.pos_of_ne_zero hm rw [eq_div_iff hzero, ← sub_eq_zero] at h replace hzero : s ≠ 0 := by rintro rfl; simp only [map_zero, not_true_eq_false] at hzero let f : F[X] := X ^ m * expand F n s - expand F n r refine ⟨f, ?_, ?_⟩ · have : f.coeff (n * s.natDegree + m) ≠ 0 := by have hn : 0 < n := by linarith only [hm, hmn] have hndvd : ¬ n ∣ n * s.natDegree + m := by rw [← Nat.dvd_add_iff_right (n.dvd_mul_right s.natDegree)] exact Nat.not_dvd_of_pos_of_lt hm hmn simp only [f, coeff_sub, coeff_X_pow_mul, s.coeff_expand_mul' hn, coeff_natDegree, coeff_expand hn r, hndvd, ite_false, sub_zero] exact leadingCoeff_ne_zero.2 hzero intro h simp only [h, coeff_zero, ne_eq, not_true_eq_false] at this · simp only [f, map_sub, map_mul, map_pow, aeval_X, expand_aeval, h]
28
import Mathlib.AlgebraicGeometry.Morphisms.Basic import Mathlib.Topology.Spectral.Hom import Mathlib.AlgebraicGeometry.Limits #align_import algebraic_geometry.morphisms.quasi_compact from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" noncomputable section open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace universe u open scoped AlgebraicGeometry namespace AlgebraicGeometry variable {X Y : Scheme.{u}} (f : X ⟶ Y) @[mk_iff] class QuasiCompact (f : X ⟶ Y) : Prop where isCompact_preimage : ∀ U : Set Y.carrier, IsOpen U → IsCompact U → IsCompact (f.1.base ⁻¹' U) #align algebraic_geometry.quasi_compact AlgebraicGeometry.QuasiCompact theorem quasiCompact_iff_spectral : QuasiCompact f ↔ IsSpectralMap f.1.base := ⟨fun ⟨h⟩ => ⟨by continuity, h⟩, fun h => ⟨h.2⟩⟩ #align algebraic_geometry.quasi_compact_iff_spectral AlgebraicGeometry.quasiCompact_iff_spectral def QuasiCompact.affineProperty : AffineTargetMorphismProperty := fun X _ _ _ => CompactSpace X.carrier #align algebraic_geometry.quasi_compact.affine_property AlgebraicGeometry.QuasiCompact.affineProperty instance (priority := 900) quasiCompactOfIsIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] : QuasiCompact f := by constructor intro U _ hU' convert hU'.image (inv f.1.base).continuous_toFun using 1 rw [Set.image_eq_preimage_of_inverse] · delta Function.LeftInverse exact IsIso.inv_hom_id_apply f.1.base · exact IsIso.hom_inv_id_apply f.1.base #align algebraic_geometry.quasi_compact_of_is_iso AlgebraicGeometry.quasiCompactOfIsIso instance quasiCompactComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f] [QuasiCompact g] : QuasiCompact (f ≫ g) := by constructor intro U hU hU' rw [Scheme.comp_val_base, TopCat.coe_comp, Set.preimage_comp] apply QuasiCompact.isCompact_preimage · exact Continuous.isOpen_preimage (by -- Porting note: `continuity` failed -- see https://github.com/leanprover-community/mathlib4/issues/5030 exact Scheme.Hom.continuous g) _ hU apply QuasiCompact.isCompact_preimage <;> assumption #align algebraic_geometry.quasi_compact_comp AlgebraicGeometry.quasiCompactComp theorem isCompact_open_iff_eq_finset_affine_union {X : Scheme} (U : Set X.carrier) : IsCompact U ∧ IsOpen U ↔ ∃ s : Set X.affineOpens, s.Finite ∧ U = ⋃ (i : X.affineOpens) (_ : i ∈ s), i := by apply Opens.IsBasis.isCompact_open_iff_eq_finite_iUnion (fun (U : X.affineOpens) => (U : Opens X.carrier)) · rw [Subtype.range_coe]; exact isBasis_affine_open X · exact fun i => i.2.isCompact #align algebraic_geometry.is_compact_open_iff_eq_finset_affine_union AlgebraicGeometry.isCompact_open_iff_eq_finset_affine_union theorem isCompact_open_iff_eq_basicOpen_union {X : Scheme} [IsAffine X] (U : Set X.carrier) : IsCompact U ∧ IsOpen U ↔ ∃ s : Set (X.presheaf.obj (op ⊤)), s.Finite ∧ U = ⋃ (i : X.presheaf.obj (op ⊤)) (_ : i ∈ s), X.basicOpen i := (isBasis_basicOpen X).isCompact_open_iff_eq_finite_iUnion _ (fun _ => ((topIsAffineOpen _).basicOpenIsAffine _).isCompact) _ #align algebraic_geometry.is_compact_open_iff_eq_basic_open_union AlgebraicGeometry.isCompact_open_iff_eq_basicOpen_union theorem quasiCompact_iff_forall_affine : QuasiCompact f ↔ ∀ U : Opens Y.carrier, IsAffineOpen U → IsCompact (f.1.base ⁻¹' (U : Set Y.carrier)) := by rw [quasiCompact_iff] refine ⟨fun H U hU => H U U.isOpen hU.isCompact, ?_⟩ intro H U hU hU' obtain ⟨S, hS, rfl⟩ := (isCompact_open_iff_eq_finset_affine_union U).mp ⟨hU', hU⟩ simp only [Set.preimage_iUnion] exact Set.Finite.isCompact_biUnion hS (fun i _ => H i i.prop) #align algebraic_geometry.quasi_compact_iff_forall_affine AlgebraicGeometry.quasiCompact_iff_forall_affine @[simp] theorem QuasiCompact.affineProperty_toProperty {X Y : Scheme} (f : X ⟶ Y) : (QuasiCompact.affineProperty : _).toProperty f ↔ IsAffine Y ∧ CompactSpace X.carrier := by delta AffineTargetMorphismProperty.toProperty QuasiCompact.affineProperty; simp #align algebraic_geometry.quasi_compact.affine_property_to_property AlgebraicGeometry.QuasiCompact.affineProperty_toProperty theorem quasiCompact_iff_affineProperty : QuasiCompact f ↔ targetAffineLocally QuasiCompact.affineProperty f := by rw [quasiCompact_iff_forall_affine] trans ∀ U : Y.affineOpens, IsCompact (f.1.base ⁻¹' (U : Set Y.carrier)) · exact ⟨fun h U => h U U.prop, fun h U hU => h ⟨U, hU⟩⟩ apply forall_congr' exact fun _ => isCompact_iff_compactSpace #align algebraic_geometry.quasi_compact_iff_affine_property AlgebraicGeometry.quasiCompact_iff_affineProperty theorem quasiCompact_eq_affineProperty : @QuasiCompact = targetAffineLocally QuasiCompact.affineProperty := by ext exact quasiCompact_iff_affineProperty _ #align algebraic_geometry.quasi_compact_eq_affine_property AlgebraicGeometry.quasiCompact_eq_affineProperty
Mathlib/AlgebraicGeometry/Morphisms/QuasiCompact.lean
129
158
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier)) (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
classical refine ((isCompact_open_iff_eq_finset_affine_union _).mpr ?_).1 obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩ let g : s → X.affineOpens := by intro V use V.1 ⊓ X.basicOpen f have : V.1.1 ⟶ U := by apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e] convert Set.subset_iUnion₂ (s := fun (U : X.affineOpens) (_ : U ∈ s) => (U : Set X.carrier)) V V.prop using 1 erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op] exact IsAffineOpen.basicOpenIsAffine V.1.prop _ haveI : Finite s := hs.to_subtype refine ⟨Set.range g, Set.finite_range g, ?_⟩ refine (Set.inter_eq_right.mpr (SetLike.coe_subset_coe.2 <| RingedSpace.basicOpen_le _ _)).symm.trans ?_ rw [e, Set.iUnion₂_inter] apply le_antisymm <;> apply Set.iUnion₂_subset · intro i hi -- Porting note: had to make explicit the first given parameter to `Set.subset_iUnion₂` exact Set.Subset.trans (Set.Subset.rfl : _ ≤ g ⟨i, hi⟩) (@Set.subset_iUnion₂ _ _ _ (fun (i : Scheme.affineOpens X) (_ : i ∈ Set.range g) => (i : Set X.toPresheafedSpace)) _ (Set.mem_range_self ⟨i, hi⟩)) · rintro ⟨i, hi⟩ ⟨⟨j, hj⟩, hj'⟩ rw [← hj'] refine Set.Subset.trans ?_ (Set.subset_iUnion₂ j hj) exact Set.Subset.rfl
28
import Mathlib.MeasureTheory.Measure.Typeclasses #align_import measure_theory.measure.sub from "leanprover-community/mathlib"@"562bbf524c595c153470e53d36c57b6f891cc480" open Set namespace MeasureTheory namespace Measure noncomputable instance instSub {α : Type*} [MeasurableSpace α] : Sub (Measure α) := ⟨fun μ ν => sInf { τ | μ ≤ τ + ν }⟩ #align measure_theory.measure.has_sub MeasureTheory.Measure.instSub variable {α : Type*} {m : MeasurableSpace α} {μ ν : Measure α} {s : Set α} theorem sub_def : μ - ν = sInf { d | μ ≤ d + ν } := rfl #align measure_theory.measure.sub_def MeasureTheory.Measure.sub_def theorem sub_le_of_le_add {d} (h : μ ≤ d + ν) : μ - ν ≤ d := sInf_le h #align measure_theory.measure.sub_le_of_le_add MeasureTheory.Measure.sub_le_of_le_add theorem sub_eq_zero_of_le (h : μ ≤ ν) : μ - ν = 0 := nonpos_iff_eq_zero'.1 <| sub_le_of_le_add <| by rwa [zero_add] #align measure_theory.measure.sub_eq_zero_of_le MeasureTheory.Measure.sub_eq_zero_of_le theorem sub_le : μ - ν ≤ μ := sub_le_of_le_add <| Measure.le_add_right le_rfl #align measure_theory.measure.sub_le MeasureTheory.Measure.sub_le @[simp] theorem sub_top : μ - ⊤ = 0 := sub_eq_zero_of_le le_top #align measure_theory.measure.sub_top MeasureTheory.Measure.sub_top @[simp] theorem zero_sub : 0 - μ = 0 := sub_eq_zero_of_le μ.zero_le #align measure_theory.measure.zero_sub MeasureTheory.Measure.zero_sub @[simp] theorem sub_self : μ - μ = 0 := sub_eq_zero_of_le le_rfl #align measure_theory.measure.sub_self MeasureTheory.Measure.sub_self theorem sub_apply [IsFiniteMeasure ν] (h₁ : MeasurableSet s) (h₂ : ν ≤ μ) : (μ - ν) s = μ s - ν s := by -- We begin by defining `measure_sub`, which will be equal to `(μ - ν)`. let measure_sub : Measure α := MeasureTheory.Measure.ofMeasurable (fun (t : Set α) (_ : MeasurableSet t) => μ t - ν t) (by simp) (fun g h_meas h_disj ↦ by simp only [measure_iUnion h_disj h_meas] rw [ENNReal.tsum_sub _ (h₂ <| g ·)] rw [← measure_iUnion h_disj h_meas] apply measure_ne_top) -- Now, we demonstrate `μ - ν = measure_sub`, and apply it. have h_measure_sub_add : ν + measure_sub = μ := by ext1 t h_t_measurable_set simp only [Pi.add_apply, coe_add] rw [MeasureTheory.Measure.ofMeasurable_apply _ h_t_measurable_set, add_comm, tsub_add_cancel_of_le (h₂ t)] have h_measure_sub_eq : μ - ν = measure_sub := by rw [MeasureTheory.Measure.sub_def] apply le_antisymm · apply sInf_le simp [le_refl, add_comm, h_measure_sub_add] apply le_sInf intro d h_d rw [← h_measure_sub_add, mem_setOf_eq, add_comm d] at h_d apply Measure.le_of_add_le_add_left h_d rw [h_measure_sub_eq] apply Measure.ofMeasurable_apply _ h₁ #align measure_theory.measure.sub_apply MeasureTheory.Measure.sub_apply theorem sub_add_cancel_of_le [IsFiniteMeasure ν] (h₁ : ν ≤ μ) : μ - ν + ν = μ := by ext1 s h_s_meas rw [add_apply, sub_apply h_s_meas h₁, tsub_add_cancel_of_le (h₁ s)] #align measure_theory.measure.sub_add_cancel_of_le MeasureTheory.Measure.sub_add_cancel_of_le
Mathlib/MeasureTheory/Measure/Sub.lean
105
134
theorem restrict_sub_eq_restrict_sub_restrict (h_meas_s : MeasurableSet s) : (μ - ν).restrict s = μ.restrict s - ν.restrict s := by
repeat rw [sub_def] have h_nonempty : { d | μ ≤ d + ν }.Nonempty := ⟨μ, Measure.le_add_right le_rfl⟩ rw [restrict_sInf_eq_sInf_restrict h_nonempty h_meas_s] apply le_antisymm · refine sInf_le_sInf_of_forall_exists_le ?_ intro ν' h_ν'_in rw [mem_setOf_eq] at h_ν'_in refine ⟨ν'.restrict s, ?_, restrict_le_self⟩ refine ⟨ν' + (⊤ : Measure α).restrict sᶜ, ?_, ?_⟩ · rw [mem_setOf_eq, add_right_comm, Measure.le_iff] intro t h_meas_t repeat rw [← measure_inter_add_diff t h_meas_s] refine add_le_add ?_ ?_ · rw [add_apply, add_apply] apply le_add_right _ rw [← restrict_eq_self μ inter_subset_right, ← restrict_eq_self ν inter_subset_right] apply h_ν'_in · rw [add_apply, restrict_apply (h_meas_t.diff h_meas_s), diff_eq, inter_assoc, inter_self, ← add_apply] have h_mu_le_add_top : μ ≤ ν' + ν + ⊤ := by simp only [add_top, le_top] exact Measure.le_iff'.1 h_mu_le_add_top _ · ext1 t h_meas_t simp [restrict_apply h_meas_t, restrict_apply (h_meas_t.inter h_meas_s), inter_assoc] · refine sInf_le_sInf_of_forall_exists_le ?_ refine forall_mem_image.2 fun t h_t_in => ⟨t.restrict s, ?_, le_rfl⟩ rw [Set.mem_setOf_eq, ← restrict_add] exact restrict_mono Subset.rfl h_t_in
28
import Mathlib.Init.Classical import Mathlib.Order.FixedPoints import Mathlib.Order.Zorn #align_import set_theory.cardinal.schroeder_bernstein from "leanprover-community/mathlib"@"1e05171a5e8cf18d98d9cf7b207540acb044acae" open Set Function open scoped Classical universe u v namespace Function namespace Embedding section antisymm variable {α : Type u} {β : Type v}
Mathlib/SetTheory/Cardinal/SchroederBernstein.lean
47
76
theorem schroeder_bernstein {f : α → β} {g : β → α} (hf : Function.Injective f) (hg : Function.Injective g) : ∃ h : α → β, Bijective h := by
cases' isEmpty_or_nonempty β with hβ hβ · have : IsEmpty α := Function.isEmpty f exact ⟨_, ((Equiv.equivEmpty α).trans (Equiv.equivEmpty β).symm).bijective⟩ set F : Set α →o Set α := { toFun := fun s => (g '' (f '' s)ᶜ)ᶜ monotone' := fun s t hst => compl_subset_compl.mpr <| image_subset _ <| compl_subset_compl.mpr <| image_subset _ hst } -- Porting note: dot notation `F.lfp` doesn't work here set s : Set α := OrderHom.lfp F have hs : (g '' (f '' s)ᶜ)ᶜ = s := F.map_lfp have hns : g '' (f '' s)ᶜ = sᶜ := compl_injective (by simp [hs]) set g' := invFun g have g'g : LeftInverse g' g := leftInverse_invFun hg have hg'ns : g' '' sᶜ = (f '' s)ᶜ := by rw [← hns, g'g.image_image] set h : α → β := s.piecewise f g' have : Surjective h := by rw [← range_iff_surjective, range_piecewise, hg'ns, union_compl_self] have : Injective h := by refine (injective_piecewise_iff _).2 ⟨hf.injOn, ?_, ?_⟩ · intro x hx y hy hxy obtain ⟨x', _, rfl⟩ : x ∈ g '' (f '' s)ᶜ := by rwa [hns] obtain ⟨y', _, rfl⟩ : y ∈ g '' (f '' s)ᶜ := by rwa [hns] rw [g'g _, g'g _] at hxy rw [hxy] · intro x hx y hy hxy obtain ⟨y', hy', rfl⟩ : y ∈ g '' (f '' s)ᶜ := by rwa [hns] rw [g'g _] at hxy exact hy' ⟨x, hx, hxy⟩ exact ⟨h, ‹Injective h›, ‹Surjective h›⟩
28
import Mathlib.MeasureTheory.Measure.Lebesgue.Basic import Mathlib.NumberTheory.Liouville.Residual import Mathlib.NumberTheory.Liouville.LiouvilleWith import Mathlib.Analysis.PSeries #align_import number_theory.liouville.measure from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" open scoped Filter ENNReal Topology NNReal open Filter Set Metric MeasureTheory Real theorem setOf_liouvilleWith_subset_aux : { x : ℝ | ∃ p > 2, LiouvilleWith p x } ⊆ ⋃ m : ℤ, (· + (m : ℝ)) ⁻¹' ⋃ n > (0 : ℕ), { x : ℝ | ∃ᶠ b : ℕ in atTop, ∃ a ∈ Finset.Icc (0 : ℤ) b, |x - (a : ℤ) / b| < 1 / (b : ℝ) ^ (2 + 1 / n : ℝ) } := by rintro x ⟨p, hp, hxp⟩ rcases exists_nat_one_div_lt (sub_pos.2 hp) with ⟨n, hn⟩ rw [lt_sub_iff_add_lt'] at hn suffices ∀ y : ℝ, LiouvilleWith p y → y ∈ Ico (0 : ℝ) 1 → ∃ᶠ b : ℕ in atTop, ∃ a ∈ Finset.Icc (0 : ℤ) b, |y - a / b| < 1 / (b : ℝ) ^ (2 + 1 / (n + 1 : ℕ) : ℝ) by simp only [mem_iUnion, mem_preimage] have hx : x + ↑(-⌊x⌋) ∈ Ico (0 : ℝ) 1 := by simp only [Int.floor_le, Int.lt_floor_add_one, add_neg_lt_iff_le_add', zero_add, and_self_iff, mem_Ico, Int.cast_neg, le_add_neg_iff_add_le] exact ⟨-⌊x⌋, n + 1, n.succ_pos, this _ (hxp.add_int _) hx⟩ clear hxp x; intro x hxp hx01 refine ((hxp.frequently_lt_rpow_neg hn).and_eventually (eventually_ge_atTop 1)).mono ?_ rintro b ⟨⟨a, -, hlt⟩, hb⟩ rw [rpow_neg b.cast_nonneg, ← one_div, ← Nat.cast_succ] at hlt refine ⟨a, ?_, hlt⟩ replace hb : (1 : ℝ) ≤ b := Nat.one_le_cast.2 hb have hb0 : (0 : ℝ) < b := zero_lt_one.trans_le hb replace hlt : |x - a / b| < 1 / b := by refine hlt.trans_le (one_div_le_one_div_of_le hb0 ?_) calc (b : ℝ) = (b : ℝ) ^ (1 : ℝ) := (rpow_one _).symm _ ≤ (b : ℝ) ^ (2 + 1 / (n + 1 : ℕ) : ℝ) := rpow_le_rpow_of_exponent_le hb (one_le_two.trans ?_) simpa using n.cast_add_one_pos.le rw [sub_div' _ _ _ hb0.ne', abs_div, abs_of_pos hb0, div_lt_div_right hb0, abs_sub_lt_iff, sub_lt_iff_lt_add, sub_lt_iff_lt_add, ← sub_lt_iff_lt_add'] at hlt rw [Finset.mem_Icc, ← Int.lt_add_one_iff, ← Int.lt_add_one_iff, ← neg_lt_iff_pos_add, add_comm, ← @Int.cast_lt ℝ, ← @Int.cast_lt ℝ] push_cast refine ⟨lt_of_le_of_lt ?_ hlt.1, hlt.2.trans_le ?_⟩ · simp only [mul_nonneg hx01.left b.cast_nonneg, neg_le_sub_iff_le_add, le_add_iff_nonneg_left] · rw [add_le_add_iff_left] exact mul_le_of_le_one_left hb0.le hx01.2.le #align set_of_liouville_with_subset_aux setOf_liouvilleWith_subset_aux @[simp]
Mathlib/NumberTheory/Liouville/Measure.lean
77
106
theorem volume_iUnion_setOf_liouvilleWith : volume (⋃ (p : ℝ) (_hp : 2 < p), { x : ℝ | LiouvilleWith p x }) = 0 := by
simp only [← setOf_exists, exists_prop] refine measure_mono_null setOf_liouvilleWith_subset_aux ?_ rw [measure_iUnion_null_iff]; intro m; rw [measure_preimage_add_right]; clear m refine (measure_biUnion_null_iff <| to_countable _).2 fun n (hn : 1 ≤ n) => ?_ generalize hr : (2 + 1 / n : ℝ) = r replace hr : 2 < r := by simp [← hr, zero_lt_one.trans_le hn] clear hn n refine measure_setOf_frequently_eq_zero ?_ simp only [setOf_exists, ← exists_prop, ← Real.dist_eq, ← mem_ball, setOf_mem_eq] set B : ℤ → ℕ → Set ℝ := fun a b => ball (a / b) (1 / (b : ℝ) ^ r) have hB : ∀ a b, volume (B a b) = ↑((2 : ℝ≥0) / (b : ℝ≥0) ^ r) := fun a b ↦ by rw [Real.volume_ball, mul_one_div, ← NNReal.coe_two, ← NNReal.coe_natCast, ← NNReal.coe_rpow, ← NNReal.coe_div, ENNReal.ofReal_coe_nnreal] have : ∀ b : ℕ, volume (⋃ a ∈ Finset.Icc (0 : ℤ) b, B a b) ≤ ↑(2 * ((b : ℝ≥0) ^ (1 - r) + (b : ℝ≥0) ^ (-r))) := fun b ↦ calc volume (⋃ a ∈ Finset.Icc (0 : ℤ) b, B a b) ≤ ∑ a ∈ Finset.Icc (0 : ℤ) b, volume (B a b) := measure_biUnion_finset_le _ _ _ = ↑((b + 1) * (2 / (b : ℝ≥0) ^ r)) := by simp only [hB, Int.card_Icc, Finset.sum_const, nsmul_eq_mul, sub_zero, ← Int.ofNat_succ, Int.toNat_natCast, ← Nat.cast_succ, ENNReal.coe_mul, ENNReal.coe_natCast] _ = _ := by have : 1 - r ≠ 0 := by linarith rw [ENNReal.coe_inj] simp [add_mul, div_eq_mul_inv, NNReal.rpow_neg, NNReal.rpow_sub' _ this, mul_add, mul_left_comm] refine ne_top_of_le_ne_top (ENNReal.tsum_coe_ne_top_iff_summable.2 ?_) (ENNReal.tsum_le_tsum this) refine (Summable.add ?_ ?_).mul_left _ <;> simp only [NNReal.summable_rpow] <;> linarith
28
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
28
import Mathlib.LinearAlgebra.CliffordAlgebra.Basic import Mathlib.Data.ZMod.Basic import Mathlib.RingTheory.GradedAlgebra.Basic #align_import linear_algebra.clifford_algebra.grading from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0" namespace CliffordAlgebra variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} open scoped DirectSum variable (Q) def evenOdd (i : ZMod 2) : Submodule R (CliffordAlgebra Q) := ⨆ j : { n : ℕ // ↑n = i }, LinearMap.range (ι Q) ^ (j : ℕ) #align clifford_algebra.even_odd CliffordAlgebra.evenOdd theorem one_le_evenOdd_zero : 1 ≤ evenOdd Q 0 := by refine le_trans ?_ (le_iSup _ ⟨0, Nat.cast_zero⟩) exact (pow_zero _).ge #align clifford_algebra.one_le_even_odd_zero CliffordAlgebra.one_le_evenOdd_zero theorem range_ι_le_evenOdd_one : LinearMap.range (ι Q) ≤ evenOdd Q 1 := by refine le_trans ?_ (le_iSup _ ⟨1, Nat.cast_one⟩) exact (pow_one _).ge #align clifford_algebra.range_ι_le_even_odd_one CliffordAlgebra.range_ι_le_evenOdd_one theorem ι_mem_evenOdd_one (m : M) : ι Q m ∈ evenOdd Q 1 := range_ι_le_evenOdd_one Q <| LinearMap.mem_range_self _ m #align clifford_algebra.ι_mem_even_odd_one CliffordAlgebra.ι_mem_evenOdd_one theorem ι_mul_ι_mem_evenOdd_zero (m₁ m₂ : M) : ι Q m₁ * ι Q m₂ ∈ evenOdd Q 0 := Submodule.mem_iSup_of_mem ⟨2, rfl⟩ (by rw [Subtype.coe_mk, pow_two] exact Submodule.mul_mem_mul (LinearMap.mem_range_self (ι Q) m₁) (LinearMap.mem_range_self (ι Q) m₂)) #align clifford_algebra.ι_mul_ι_mem_even_odd_zero CliffordAlgebra.ι_mul_ι_mem_evenOdd_zero theorem evenOdd_mul_le (i j : ZMod 2) : evenOdd Q i * evenOdd Q j ≤ evenOdd Q (i + j) := by simp_rw [evenOdd, Submodule.iSup_eq_span, Submodule.span_mul_span] apply Submodule.span_mono simp_rw [Set.iUnion_mul, Set.mul_iUnion, Set.iUnion_subset_iff, Set.mul_subset_iff] rintro ⟨xi, rfl⟩ ⟨yi, rfl⟩ x hx y hy refine Set.mem_iUnion.mpr ⟨⟨xi + yi, Nat.cast_add _ _⟩, ?_⟩ simp only [Subtype.coe_mk, Nat.cast_add, pow_add] exact Submodule.mul_mem_mul hx hy #align clifford_algebra.even_odd_mul_le CliffordAlgebra.evenOdd_mul_le instance evenOdd.gradedMonoid : SetLike.GradedMonoid (evenOdd Q) where one_mem := Submodule.one_le.mp (one_le_evenOdd_zero Q) mul_mem _i _j _p _q hp hq := Submodule.mul_le.mp (evenOdd_mul_le Q _ _) _ hp _ hq #align clifford_algebra.even_odd.graded_monoid CliffordAlgebra.evenOdd.gradedMonoid -- Porting note: added `protected` protected def GradedAlgebra.ι : M →ₗ[R] ⨁ i : ZMod 2, evenOdd Q i := DirectSum.lof R (ZMod 2) (fun i => ↥(evenOdd Q i)) 1 ∘ₗ (ι Q).codRestrict _ (ι_mem_evenOdd_one Q) #align clifford_algebra.graded_algebra.ι CliffordAlgebra.GradedAlgebra.ι theorem GradedAlgebra.ι_apply (m : M) : GradedAlgebra.ι Q m = DirectSum.of (fun i => ↥(evenOdd Q i)) 1 ⟨ι Q m, ι_mem_evenOdd_one Q m⟩ := rfl #align clifford_algebra.graded_algebra.ι_apply CliffordAlgebra.GradedAlgebra.ι_apply nonrec theorem GradedAlgebra.ι_sq_scalar (m : M) : GradedAlgebra.ι Q m * GradedAlgebra.ι Q m = algebraMap R _ (Q m) := by rw [GradedAlgebra.ι_apply Q, DirectSum.of_mul_of, DirectSum.algebraMap_apply] exact DirectSum.of_eq_of_gradedMonoid_eq (Sigma.subtype_ext rfl <| ι_sq_scalar _ _) #align clifford_algebra.graded_algebra.ι_sq_scalar CliffordAlgebra.GradedAlgebra.ι_sq_scalar
Mathlib/LinearAlgebra/CliffordAlgebra/Grading.lean
91
122
theorem GradedAlgebra.lift_ι_eq (i' : ZMod 2) (x' : evenOdd Q i') : -- Porting note: added a second `by apply` lift Q ⟨by apply GradedAlgebra.ι Q, by apply GradedAlgebra.ι_sq_scalar Q⟩ x' = DirectSum.of (fun i => evenOdd Q i) i' x' := by
cases' x' with x' hx' dsimp only [Subtype.coe_mk, DirectSum.lof_eq_of] induction hx' using Submodule.iSup_induction' with | mem i x hx => obtain ⟨i, rfl⟩ := i -- Porting note: `dsimp only [Subtype.coe_mk] at hx` doesn't work, use `change` instead change x ∈ LinearMap.range (ι Q) ^ i at hx induction hx using Submodule.pow_induction_on_left' with | algebraMap r => rw [AlgHom.commutes, DirectSum.algebraMap_apply]; rfl | add x y i hx hy ihx ihy => -- Note: in #8386 `map_add` had to be specialized to avoid a timeout -- (the definition was already very slow) rw [AlgHom.map_add, ihx, ihy, ← AddMonoidHom.map_add] rfl | mem_mul m hm i x hx ih => obtain ⟨_, rfl⟩ := hm rw [AlgHom.map_mul, ih, lift_ι_apply, GradedAlgebra.ι_apply Q, DirectSum.of_mul_of] refine DirectSum.of_eq_of_gradedMonoid_eq (Sigma.subtype_ext ?_ ?_) <;> dsimp only [GradedMonoid.mk, Subtype.coe_mk] · rw [Nat.succ_eq_add_one, add_comm, Nat.cast_add, Nat.cast_one] rfl | zero => rw [AlgHom.map_zero] apply Eq.symm apply DFinsupp.single_eq_zero.mpr; rfl | add x y hx hy ihx ihy => rw [AlgHom.map_add, ihx, ihy, ← AddMonoidHom.map_add]; rfl
28
import Mathlib.CategoryTheory.Abelian.Basic #align_import category_theory.idempotents.basic from "leanprover-community/mathlib"@"3a061790136d13594ec10c7c90d202335ac5d854" open CategoryTheory open CategoryTheory.Category open CategoryTheory.Limits open CategoryTheory.Preadditive open Opposite namespace CategoryTheory variable (C : Type*) [Category C] class IsIdempotentComplete : Prop where idempotents_split : ∀ (X : C) (p : X ⟶ X), p ≫ p = p → ∃ (Y : C) (i : Y ⟶ X) (e : X ⟶ Y), i ≫ e = 𝟙 Y ∧ e ≫ i = p #align category_theory.is_idempotent_complete CategoryTheory.IsIdempotentComplete namespace Idempotents
Mathlib/CategoryTheory/Idempotents/Basic.lean
63
92
theorem isIdempotentComplete_iff_hasEqualizer_of_id_and_idempotent : IsIdempotentComplete C ↔ ∀ (X : C) (p : X ⟶ X), p ≫ p = p → HasEqualizer (𝟙 X) p := by
constructor · intro intro X p hp rcases IsIdempotentComplete.idempotents_split X p hp with ⟨Y, i, e, ⟨h₁, h₂⟩⟩ exact ⟨Nonempty.intro { cone := Fork.ofι i (show i ≫ 𝟙 X = i ≫ p by rw [comp_id, ← h₂, ← assoc, h₁, id_comp]) isLimit := by apply Fork.IsLimit.mk' intro s refine ⟨s.ι ≫ e, ?_⟩ constructor · erw [assoc, h₂, ← Limits.Fork.condition s, comp_id] · intro m hm rw [Fork.ι_ofι] at hm rw [← hm] simp only [← hm, assoc, h₁] exact (comp_id m).symm }⟩ · intro h refine ⟨?_⟩ intro X p hp haveI : HasEqualizer (𝟙 X) p := h X p hp refine ⟨equalizer (𝟙 X) p, equalizer.ι (𝟙 X) p, equalizer.lift p (show p ≫ 𝟙 X = p ≫ p by rw [hp, comp_id]), ?_, equalizer.lift_ι _ _⟩ ext simp only [assoc, limit.lift_π, Eq.ndrec, id_eq, eq_mpr_eq_cast, Fork.ofι_pt, Fork.ofι_π_app, id_comp] rw [← equalizer.condition, comp_id]
28
import Mathlib.Algebra.Field.Basic import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Basic import Mathlib.RingTheory.Int.Basic import Mathlib.Tactic.Ring import Mathlib.Tactic.FieldSimp import Mathlib.Data.Int.NatPrime import Mathlib.Data.ZMod.Basic #align_import number_theory.pythagorean_triples from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3" theorem sq_ne_two_fin_zmod_four (z : ZMod 4) : z * z ≠ 2 := by change Fin 4 at z fin_cases z <;> decide #align sq_ne_two_fin_zmod_four sq_ne_two_fin_zmod_four theorem Int.sq_ne_two_mod_four (z : ℤ) : z * z % 4 ≠ 2 := by suffices ¬z * z % (4 : ℕ) = 2 % (4 : ℕ) by exact this rw [← ZMod.intCast_eq_intCast_iff'] simpa using sq_ne_two_fin_zmod_four _ #align int.sq_ne_two_mod_four Int.sq_ne_two_mod_four noncomputable section open scoped Classical def PythagoreanTriple (x y z : ℤ) : Prop := x * x + y * y = z * z #align pythagorean_triple PythagoreanTriple theorem pythagoreanTriple_comm {x y z : ℤ} : PythagoreanTriple x y z ↔ PythagoreanTriple y x z := by delta PythagoreanTriple rw [add_comm] #align pythagorean_triple_comm pythagoreanTriple_comm theorem PythagoreanTriple.zero : PythagoreanTriple 0 0 0 := by simp only [PythagoreanTriple, zero_mul, zero_add] #align pythagorean_triple.zero PythagoreanTriple.zero namespace PythagoreanTriple variable {x y z : ℤ} (h : PythagoreanTriple x y z) theorem eq : x * x + y * y = z * z := h #align pythagorean_triple.eq PythagoreanTriple.eq @[symm] theorem symm : PythagoreanTriple y x z := by rwa [pythagoreanTriple_comm] #align pythagorean_triple.symm PythagoreanTriple.symm theorem mul (k : ℤ) : PythagoreanTriple (k * x) (k * y) (k * z) := calc k * x * (k * x) + k * y * (k * y) = k ^ 2 * (x * x + y * y) := by ring _ = k ^ 2 * (z * z) := by rw [h.eq] _ = k * z * (k * z) := by ring #align pythagorean_triple.mul PythagoreanTriple.mul theorem mul_iff (k : ℤ) (hk : k ≠ 0) : PythagoreanTriple (k * x) (k * y) (k * z) ↔ PythagoreanTriple x y z := by refine ⟨?_, fun h => h.mul k⟩ simp only [PythagoreanTriple] intro h rw [← mul_left_inj' (mul_ne_zero hk hk)] convert h using 1 <;> ring #align pythagorean_triple.mul_iff PythagoreanTriple.mul_iff @[nolint unusedArguments] def IsClassified (_ : PythagoreanTriple x y z) := ∃ k m n : ℤ, (x = k * (m ^ 2 - n ^ 2) ∧ y = k * (2 * m * n) ∨ x = k * (2 * m * n) ∧ y = k * (m ^ 2 - n ^ 2)) ∧ Int.gcd m n = 1 #align pythagorean_triple.is_classified PythagoreanTriple.IsClassified @[nolint unusedArguments] def IsPrimitiveClassified (_ : PythagoreanTriple x y z) := ∃ m n : ℤ, (x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n ∨ x = 2 * m * n ∧ y = m ^ 2 - n ^ 2) ∧ Int.gcd m n = 1 ∧ (m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0) #align pythagorean_triple.is_primitive_classified PythagoreanTriple.IsPrimitiveClassified theorem mul_isClassified (k : ℤ) (hc : h.IsClassified) : (h.mul k).IsClassified := by obtain ⟨l, m, n, ⟨⟨rfl, rfl⟩ | ⟨rfl, rfl⟩, co⟩⟩ := hc · use k * l, m, n apply And.intro _ co left constructor <;> ring · use k * l, m, n apply And.intro _ co right constructor <;> ring #align pythagorean_triple.mul_is_classified PythagoreanTriple.mul_isClassified
Mathlib/NumberTheory/PythagoreanTriples.lean
132
161
theorem even_odd_of_coprime (hc : Int.gcd x y = 1) : x % 2 = 0 ∧ y % 2 = 1 ∨ x % 2 = 1 ∧ y % 2 = 0 := by
cases' Int.emod_two_eq_zero_or_one x with hx hx <;> cases' Int.emod_two_eq_zero_or_one y with hy hy -- x even, y even · exfalso apply Nat.not_coprime_of_dvd_of_dvd (by decide : 1 < 2) _ _ hc · apply Int.natCast_dvd.1 apply Int.dvd_of_emod_eq_zero hx · apply Int.natCast_dvd.1 apply Int.dvd_of_emod_eq_zero hy -- x even, y odd · left exact ⟨hx, hy⟩ -- x odd, y even · right exact ⟨hx, hy⟩ -- x odd, y odd · exfalso obtain ⟨x0, y0, rfl, rfl⟩ : ∃ x0 y0, x = x0 * 2 + 1 ∧ y = y0 * 2 + 1 := by cases' exists_eq_mul_left_of_dvd (Int.dvd_sub_of_emod_eq hx) with x0 hx2 cases' exists_eq_mul_left_of_dvd (Int.dvd_sub_of_emod_eq hy) with y0 hy2 rw [sub_eq_iff_eq_add] at hx2 hy2 exact ⟨x0, y0, hx2, hy2⟩ apply Int.sq_ne_two_mod_four z rw [show z * z = 4 * (x0 * x0 + x0 + y0 * y0 + y0) + 2 by rw [← h.eq] ring] simp only [Int.add_emod, Int.mul_emod_right, zero_add] decide
28
import Mathlib.CategoryTheory.Extensive import Mathlib.CategoryTheory.Limits.Shapes.KernelPair #align_import category_theory.adhesive from "leanprover-community/mathlib"@"afff1f24a6b68d0077c9d63782a1d093e337758c" namespace CategoryTheory open Limits universe v' u' v u variable {J : Type v'} [Category.{u'} J] {C : Type u} [Category.{v} C] variable {W X Y Z : C} {f : W ⟶ X} {g : W ⟶ Y} {h : X ⟶ Z} {i : Y ⟶ Z} -- This only makes sense when the original diagram is a pushout. @[nolint unusedArguments] def IsPushout.IsVanKampen (_ : IsPushout f g h i) : Prop := ∀ ⦃W' X' Y' Z' : C⦄ (f' : W' ⟶ X') (g' : W' ⟶ Y') (h' : X' ⟶ Z') (i' : Y' ⟶ Z') (αW : W' ⟶ W) (αX : X' ⟶ X) (αY : Y' ⟶ Y) (αZ : Z' ⟶ Z) (_ : IsPullback f' αW αX f) (_ : IsPullback g' αW αY g) (_ : CommSq h' αX αZ h) (_ : CommSq i' αY αZ i) (_ : CommSq f' g' h' i'), IsPushout f' g' h' i' ↔ IsPullback h' αX αZ h ∧ IsPullback i' αY αZ i #align category_theory.is_pushout.is_van_kampen CategoryTheory.IsPushout.IsVanKampen theorem IsPushout.IsVanKampen.flip {H : IsPushout f g h i} (H' : H.IsVanKampen) : H.flip.IsVanKampen := by introv W' hf hg hh hi w simpa only [IsPushout.flip_iff, IsPullback.flip_iff, and_comm] using H' g' f' i' h' αW αY αX αZ hg hf hi hh w.flip #align category_theory.is_pushout.is_van_kampen.flip CategoryTheory.IsPushout.IsVanKampen.flip theorem IsPushout.isVanKampen_iff (H : IsPushout f g h i) : H.IsVanKampen ↔ IsVanKampenColimit (PushoutCocone.mk h i H.w) := by constructor · intro H F' c' α fα eα hα refine Iff.trans ?_ ((H (F'.map WalkingSpan.Hom.fst) (F'.map WalkingSpan.Hom.snd) (c'.ι.app _) (c'.ι.app _) (α.app _) (α.app _) (α.app _) fα (by convert hα WalkingSpan.Hom.fst) (by convert hα WalkingSpan.Hom.snd) ?_ ?_ ?_).trans ?_) · have : F'.map WalkingSpan.Hom.fst ≫ c'.ι.app WalkingSpan.left = F'.map WalkingSpan.Hom.snd ≫ c'.ι.app WalkingSpan.right := by simp only [Cocone.w] rw [(IsColimit.equivOfNatIsoOfIso (diagramIsoSpan F') c' (PushoutCocone.mk _ _ this) _).nonempty_congr] · exact ⟨fun h => ⟨⟨this⟩, h⟩, fun h => h.2⟩ · refine Cocones.ext (Iso.refl c'.pt) ?_ rintro (_ | _ | _) <;> dsimp <;> simp only [c'.w, Category.assoc, Category.id_comp, Category.comp_id] · exact ⟨NatTrans.congr_app eα.symm _⟩ · exact ⟨NatTrans.congr_app eα.symm _⟩ · exact ⟨by simp⟩ constructor · rintro ⟨h₁, h₂⟩ (_ | _ | _) · rw [← c'.w WalkingSpan.Hom.fst]; exact (hα WalkingSpan.Hom.fst).paste_horiz h₁ exacts [h₁, h₂] · intro h; exact ⟨h _, h _⟩ · introv H W' hf hg hh hi w refine Iff.trans ?_ ((H w.cocone ⟨by rintro (_ | _ | _); exacts [αW, αX, αY], ?_⟩ αZ ?_ ?_).trans ?_) rotate_left · rintro i _ (_ | _ | _) · dsimp; simp only [Functor.map_id, Category.comp_id, Category.id_comp] exacts [hf.w, hg.w] · ext (_ | _ | _) · dsimp; rw [PushoutCocone.condition_zero]; erw [Category.assoc, hh.w, hf.w_assoc] exacts [hh.w.symm, hi.w.symm] · rintro i _ (_ | _ | _) · dsimp; simp_rw [Functor.map_id] exact IsPullback.of_horiz_isIso ⟨by rw [Category.comp_id, Category.id_comp]⟩ exacts [hf, hg] · constructor · intro h; exact ⟨h WalkingCospan.left, h WalkingCospan.right⟩ · rintro ⟨h₁, h₂⟩ (_ | _ | _) · dsimp; rw [PushoutCocone.condition_zero]; exact hf.paste_horiz h₁ exacts [h₁, h₂] · exact ⟨fun h => h.2, fun h => ⟨w, h⟩⟩ #align category_theory.is_pushout.is_van_kampen_iff CategoryTheory.IsPushout.isVanKampen_iff
Mathlib/CategoryTheory/Adhesive.lean
113
143
theorem is_coprod_iff_isPushout {X E Y YE : C} (c : BinaryCofan X E) (hc : IsColimit c) {f : X ⟶ Y} {iY : Y ⟶ YE} {fE : c.pt ⟶ YE} (H : CommSq f c.inl iY fE) : Nonempty (IsColimit (BinaryCofan.mk (c.inr ≫ fE) iY)) ↔ IsPushout f c.inl iY fE := by
constructor · rintro ⟨h⟩ refine ⟨H, ⟨Limits.PushoutCocone.isColimitAux' _ ?_⟩⟩ intro s dsimp only [PushoutCocone.inr, PushoutCocone.mk] -- Porting note: Originally `dsimp` refine ⟨h.desc (BinaryCofan.mk (c.inr ≫ s.inr) s.inl), h.fac _ ⟨WalkingPair.right⟩, ?_, ?_⟩ · apply BinaryCofan.IsColimit.hom_ext hc · rw [← H.w_assoc]; erw [h.fac _ ⟨WalkingPair.right⟩]; exact s.condition · rw [← Category.assoc]; exact h.fac _ ⟨WalkingPair.left⟩ · intro m e₁ e₂ apply BinaryCofan.IsColimit.hom_ext h · dsimp only [BinaryCofan.mk, id] -- Porting note: Originally `dsimp` rw [Category.assoc, e₂, eq_comm]; exact h.fac _ ⟨WalkingPair.left⟩ · refine e₁.trans (Eq.symm ?_); exact h.fac _ _ · refine fun H => ⟨?_⟩ fapply Limits.BinaryCofan.isColimitMk · exact fun s => H.isColimit.desc (PushoutCocone.mk s.inr _ <| (hc.fac (BinaryCofan.mk (f ≫ s.inr) s.inl) ⟨WalkingPair.left⟩).symm) · intro s erw [Category.assoc, H.isColimit.fac _ WalkingSpan.right, hc.fac]; rfl · intro s; exact H.isColimit.fac _ WalkingSpan.left · intro s m e₁ e₂ apply PushoutCocone.IsColimit.hom_ext H.isColimit · symm; exact (H.isColimit.fac _ WalkingSpan.left).trans e₂.symm · erw [H.isColimit.fac _ WalkingSpan.right] apply BinaryCofan.IsColimit.hom_ext hc · erw [hc.fac, ← H.w_assoc, e₂]; rfl · refine ((Category.assoc _ _ _).symm.trans e₁).trans ?_; symm; exact hc.fac _ _
28
import Mathlib.Analysis.LocallyConvex.Bounded import Mathlib.Topology.Algebra.Module.StrongTopology #align_import analysis.normed_space.compact_operator from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" open Function Set Filter Bornology Metric Pointwise Topology def IsCompactOperator {M₁ M₂ : Type*} [Zero M₁] [TopologicalSpace M₁] [TopologicalSpace M₂] (f : M₁ → M₂) : Prop := ∃ K, IsCompact K ∧ f ⁻¹' K ∈ (𝓝 0 : Filter M₁) #align is_compact_operator IsCompactOperator theorem isCompactOperator_zero {M₁ M₂ : Type*} [Zero M₁] [TopologicalSpace M₁] [TopologicalSpace M₂] [Zero M₂] : IsCompactOperator (0 : M₁ → M₂) := ⟨{0}, isCompact_singleton, mem_of_superset univ_mem fun _ _ => rfl⟩ #align is_compact_operator_zero isCompactOperator_zero section Characterizations section variable {R₁ R₂ : Type*} [Semiring R₁] [Semiring R₂] {σ₁₂ : R₁ →+* R₂} {M₁ M₂ : Type*} [TopologicalSpace M₁] [AddCommMonoid M₁] [TopologicalSpace M₂] theorem isCompactOperator_iff_exists_mem_nhds_image_subset_compact (f : M₁ → M₂) : IsCompactOperator f ↔ ∃ V ∈ (𝓝 0 : Filter M₁), ∃ K : Set M₂, IsCompact K ∧ f '' V ⊆ K := ⟨fun ⟨K, hK, hKf⟩ => ⟨f ⁻¹' K, hKf, K, hK, image_preimage_subset _ _⟩, fun ⟨_, hV, K, hK, hVK⟩ => ⟨K, hK, mem_of_superset hV (image_subset_iff.mp hVK)⟩⟩ #align is_compact_operator_iff_exists_mem_nhds_image_subset_compact isCompactOperator_iff_exists_mem_nhds_image_subset_compact theorem isCompactOperator_iff_exists_mem_nhds_isCompact_closure_image [T2Space M₂] (f : M₁ → M₂) : IsCompactOperator f ↔ ∃ V ∈ (𝓝 0 : Filter M₁), IsCompact (closure <| f '' V) := by rw [isCompactOperator_iff_exists_mem_nhds_image_subset_compact] exact ⟨fun ⟨V, hV, K, hK, hKV⟩ => ⟨V, hV, hK.closure_of_subset hKV⟩, fun ⟨V, hV, hVc⟩ => ⟨V, hV, closure (f '' V), hVc, subset_closure⟩⟩ #align is_compact_operator_iff_exists_mem_nhds_is_compact_closure_image isCompactOperator_iff_exists_mem_nhds_isCompact_closure_image end section Continuous variable {𝕜₁ 𝕜₂ : Type*} [NontriviallyNormedField 𝕜₁] [NontriviallyNormedField 𝕜₂] {σ₁₂ : 𝕜₁ →+* 𝕜₂} [RingHomIsometric σ₁₂] {M₁ M₂ : Type*} [TopologicalSpace M₁] [AddCommGroup M₁] [TopologicalSpace M₂] [AddCommGroup M₂] [Module 𝕜₁ M₁] [Module 𝕜₂ M₂] [TopologicalAddGroup M₁] [ContinuousConstSMul 𝕜₁ M₁] [TopologicalAddGroup M₂] [ContinuousSMul 𝕜₂ M₂] @[continuity]
Mathlib/Analysis/NormedSpace/CompactOperator.lean
336
365
theorem IsCompactOperator.continuous {f : M₁ →ₛₗ[σ₁₂] M₂} (hf : IsCompactOperator f) : Continuous f := by
letI : UniformSpace M₂ := TopologicalAddGroup.toUniformSpace _ haveI : UniformAddGroup M₂ := comm_topologicalAddGroup_is_uniform -- Since `f` is linear, we only need to show that it is continuous at zero. -- Let `U` be a neighborhood of `0` in `M₂`. refine continuous_of_continuousAt_zero f fun U hU => ?_ rw [map_zero] at hU -- The compactness of `f` gives us a compact set `K : Set M₂` such that `f ⁻¹' K` is a -- neighborhood of `0` in `M₁`. rcases hf with ⟨K, hK, hKf⟩ -- But any compact set is totally bounded, hence Von-Neumann bounded. Thus, `K` absorbs `U`. -- This gives `r > 0` such that `∀ a : 𝕜₂, r ≤ ‖a‖ → K ⊆ a • U`. rcases (hK.totallyBounded.isVonNBounded 𝕜₂ hU).exists_pos with ⟨r, hr, hrU⟩ -- Choose `c : 𝕜₂` with `r < ‖c‖`. rcases NormedField.exists_lt_norm 𝕜₁ r with ⟨c, hc⟩ have hcnz : c ≠ 0 := ne_zero_of_norm_ne_zero (hr.trans hc).ne.symm -- We have `f ⁻¹' ((σ₁₂ c⁻¹) • K) = c⁻¹ • f ⁻¹' K ∈ 𝓝 0`. Thus, showing that -- `(σ₁₂ c⁻¹) • K ⊆ U` is enough to deduce that `f ⁻¹' U ∈ 𝓝 0`. suffices (σ₁₂ <| c⁻¹) • K ⊆ U by refine mem_of_superset ?_ this have : IsUnit c⁻¹ := hcnz.isUnit.inv rwa [mem_map, preimage_smul_setₛₗ _ _ _ f this, set_smul_mem_nhds_zero_iff (inv_ne_zero hcnz)] -- Since `σ₁₂ c⁻¹` = `(σ₁₂ c)⁻¹`, we have to prove that `K ⊆ σ₁₂ c • U`. rw [map_inv₀, ← subset_set_smul_iff₀ ((map_ne_zero σ₁₂).mpr hcnz)] -- But `σ₁₂` is isometric, so `‖σ₁₂ c‖ = ‖c‖ > r`, which concludes the argument since -- `∀ a : 𝕜₂, r ≤ ‖a‖ → K ⊆ a • U`. refine hrU (σ₁₂ c) ?_ rw [RingHomIsometric.is_iso] exact hc.le
28
import Mathlib.Data.Fintype.Card import Mathlib.Computability.Language import Mathlib.Tactic.NormNum #align_import computability.DFA from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514" open Computability universe u v -- Porting note: Required as `DFA` is used in mathlib3 set_option linter.uppercaseLean3 false structure DFA (α : Type u) (σ : Type v) where step : σ → α → σ start : σ accept : Set σ #align DFA DFA namespace DFA variable {α : Type u} {σ : Type v} (M : DFA α σ) instance [Inhabited σ] : Inhabited (DFA α σ) := ⟨DFA.mk (fun _ _ => default) default ∅⟩ def evalFrom (start : σ) : List α → σ := List.foldl M.step start #align DFA.eval_from DFA.evalFrom @[simp] theorem evalFrom_nil (s : σ) : M.evalFrom s [] = s := rfl #align DFA.eval_from_nil DFA.evalFrom_nil @[simp] theorem evalFrom_singleton (s : σ) (a : α) : M.evalFrom s [a] = M.step s a := rfl #align DFA.eval_from_singleton DFA.evalFrom_singleton @[simp] theorem evalFrom_append_singleton (s : σ) (x : List α) (a : α) : M.evalFrom s (x ++ [a]) = M.step (M.evalFrom s x) a := by simp only [evalFrom, List.foldl_append, List.foldl_cons, List.foldl_nil] #align DFA.eval_from_append_singleton DFA.evalFrom_append_singleton def eval : List α → σ := M.evalFrom M.start #align DFA.eval DFA.eval @[simp] theorem eval_nil : M.eval [] = M.start := rfl #align DFA.eval_nil DFA.eval_nil @[simp] theorem eval_singleton (a : α) : M.eval [a] = M.step M.start a := rfl #align DFA.eval_singleton DFA.eval_singleton @[simp] theorem eval_append_singleton (x : List α) (a : α) : M.eval (x ++ [a]) = M.step (M.eval x) a := evalFrom_append_singleton _ _ _ _ #align DFA.eval_append_singleton DFA.eval_append_singleton theorem evalFrom_of_append (start : σ) (x y : List α) : M.evalFrom start (x ++ y) = M.evalFrom (M.evalFrom start x) y := x.foldl_append _ _ y #align DFA.eval_from_of_append DFA.evalFrom_of_append def accepts : Language α := {x | M.eval x ∈ M.accept} #align DFA.accepts DFA.accepts theorem mem_accepts (x : List α) : x ∈ M.accepts ↔ M.evalFrom M.start x ∈ M.accept := by rfl #align DFA.mem_accepts DFA.mem_accepts
Mathlib/Computability/DFA.lean
101
134
theorem evalFrom_split [Fintype σ] {x : List α} {s t : σ} (hlen : Fintype.card σ ≤ x.length) (hx : M.evalFrom s x = t) : ∃ q a b c, x = a ++ b ++ c ∧ a.length + b.length ≤ Fintype.card σ ∧ b ≠ [] ∧ M.evalFrom s a = q ∧ M.evalFrom q b = q ∧ M.evalFrom q c = t := by
obtain ⟨n, m, hneq, heq⟩ := Fintype.exists_ne_map_eq_of_card_lt (fun n : Fin (Fintype.card σ + 1) => M.evalFrom s (x.take n)) (by norm_num) wlog hle : (n : ℕ) ≤ m · exact this _ hlen hx _ _ hneq.symm heq.symm (le_of_not_le hle) have hm : (m : ℕ) ≤ Fintype.card σ := Fin.is_le m refine ⟨M.evalFrom s ((x.take m).take n), (x.take m).take n, (x.take m).drop n, x.drop m, ?_, ?_, ?_, by rfl, ?_⟩ · rw [List.take_append_drop, List.take_append_drop] · simp only [List.length_drop, List.length_take] rw [min_eq_left (hm.trans hlen), min_eq_left hle, add_tsub_cancel_of_le hle] exact hm · intro h have hlen' := congr_arg List.length h simp only [List.length_drop, List.length, List.length_take] at hlen' rw [min_eq_left, tsub_eq_zero_iff_le] at hlen' · apply hneq apply le_antisymm assumption' exact hm.trans hlen have hq : M.evalFrom (M.evalFrom s ((x.take m).take n)) ((x.take m).drop n) = M.evalFrom s ((x.take m).take n) := by rw [List.take_take, min_eq_left hle, ← evalFrom_of_append, heq, ← min_eq_left hle, ← List.take_take, min_eq_left hle, List.take_append_drop] use hq rwa [← hq, ← evalFrom_of_append, ← evalFrom_of_append, ← List.append_assoc, List.take_append_drop, List.take_append_drop]
28
import Mathlib.NumberTheory.LegendreSymbol.Basic import Mathlib.Analysis.Normed.Field.Basic #align_import number_theory.legendre_symbol.gauss_eisenstein_lemmas from "leanprover-community/mathlib"@"8818fdefc78642a7e6afcd20be5c184f3c7d9699" open Finset Nat open scoped Nat section GaussEisenstein namespace ZMod
Mathlib/NumberTheory/LegendreSymbol/GaussEisensteinLemmas.lean
30
60
theorem Ico_map_valMinAbs_natAbs_eq_Ico_map_id (p : ℕ) [hp : Fact p.Prime] (a : ZMod p) (hap : a ≠ 0) : ((Ico 1 (p / 2).succ).1.map fun (x : ℕ) => (a * x).valMinAbs.natAbs) = (Ico 1 (p / 2).succ).1.map fun a => a := by
have he : ∀ {x}, x ∈ Ico 1 (p / 2).succ → x ≠ 0 ∧ x ≤ p / 2 := by simp (config := { contextual := true }) [Nat.lt_succ_iff, Nat.succ_le_iff, pos_iff_ne_zero] have hep : ∀ {x}, x ∈ Ico 1 (p / 2).succ → x < p := fun hx => lt_of_le_of_lt (he hx).2 (Nat.div_lt_self hp.1.pos (by decide)) have hpe : ∀ {x}, x ∈ Ico 1 (p / 2).succ → ¬p ∣ x := fun hx hpx => not_lt_of_ge (le_of_dvd (Nat.pos_of_ne_zero (he hx).1) hpx) (hep hx) have hmem : ∀ (x : ℕ) (hx : x ∈ Ico 1 (p / 2).succ), (a * x : ZMod p).valMinAbs.natAbs ∈ Ico 1 (p / 2).succ := by intro x hx simp [hap, CharP.cast_eq_zero_iff (ZMod p) p, hpe hx, Nat.lt_succ_iff, succ_le_iff, pos_iff_ne_zero, natAbs_valMinAbs_le _] have hsurj : ∀ (b : ℕ) (hb : b ∈ Ico 1 (p / 2).succ), ∃ x, ∃ _ : x ∈ Ico 1 (p / 2).succ, (a * x : ZMod p).valMinAbs.natAbs = b := by intro b hb refine ⟨(b / a : ZMod p).valMinAbs.natAbs, mem_Ico.mpr ⟨?_, ?_⟩, ?_⟩ · apply Nat.pos_of_ne_zero simp only [div_eq_mul_inv, hap, CharP.cast_eq_zero_iff (ZMod p) p, hpe hb, not_false_iff, valMinAbs_eq_zero, inv_eq_zero, Int.natAbs_eq_zero, Ne, _root_.mul_eq_zero, or_self_iff] · apply lt_succ_of_le; apply natAbs_valMinAbs_le · rw [natCast_natAbs_valMinAbs] split_ifs · erw [mul_div_cancel₀ _ hap, valMinAbs_def_pos, val_cast_of_lt (hep hb), if_pos (le_of_lt_succ (mem_Ico.1 hb).2), Int.natAbs_ofNat] · erw [mul_neg, mul_div_cancel₀ _ hap, natAbs_valMinAbs_neg, valMinAbs_def_pos, val_cast_of_lt (hep hb), if_pos (le_of_lt_succ (mem_Ico.1 hb).2), Int.natAbs_ofNat] exact Multiset.map_eq_map_of_bij_of_nodup _ _ (Finset.nodup _) (Finset.nodup _) (fun x _ => (a * x : ZMod p).valMinAbs.natAbs) hmem (inj_on_of_surj_on_of_card_le _ hmem hsurj le_rfl) hsurj (fun _ _ => rfl)
28
import Mathlib.MeasureTheory.Measure.Lebesgue.Complex import Mathlib.MeasureTheory.Integral.DivergenceTheorem import Mathlib.MeasureTheory.Integral.CircleIntegral import Mathlib.Analysis.Calculus.Dslope import Mathlib.Analysis.Analytic.Basic import Mathlib.Analysis.Complex.ReImTopology import Mathlib.Analysis.Calculus.DiffContOnCl import Mathlib.Analysis.Calculus.FDeriv.Analytic import Mathlib.Data.Real.Cardinality #align_import analysis.complex.cauchy_integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" open TopologicalSpace Set MeasureTheory intervalIntegral Metric Filter Function open scoped Interval Real NNReal ENNReal Topology noncomputable section universe u variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℂ E] [CompleteSpace E] namespace Complex
Mathlib/Analysis/Complex/CauchyIntegral.lean
166
203
theorem integral_boundary_rect_of_hasFDerivAt_real_off_countable (f : ℂ → E) (f' : ℂ → ℂ →L[ℝ] E) (z w : ℂ) (s : Set ℂ) (hs : s.Countable) (Hc : ContinuousOn f ([[z.re, w.re]] ×ℂ [[z.im, w.im]])) (Hd : ∀ x ∈ Ioo (min z.re w.re) (max z.re w.re) ×ℂ Ioo (min z.im w.im) (max z.im w.im) \ s, HasFDerivAt f (f' x) x) (Hi : IntegrableOn (fun z => I • f' z 1 - f' z I) ([[z.re, w.re]] ×ℂ [[z.im, w.im]])) : (∫ x : ℝ in z.re..w.re, f (x + z.im * I)) - (∫ x : ℝ in z.re..w.re, f (x + w.im * I)) + I • (∫ y : ℝ in z.im..w.im, f (re w + y * I)) - I • ∫ y : ℝ in z.im..w.im, f (re z + y * I) = ∫ x : ℝ in z.re..w.re, ∫ y : ℝ in z.im..w.im, I • f' (x + y * I) 1 - f' (x + y * I) I := by
set e : (ℝ × ℝ) ≃L[ℝ] ℂ := equivRealProdCLM.symm have he : ∀ x y : ℝ, ↑x + ↑y * I = e (x, y) := fun x y => (mk_eq_add_mul_I x y).symm have he₁ : e (1, 0) = 1 := rfl; have he₂ : e (0, 1) = I := rfl simp only [he] at * set F : ℝ × ℝ → E := f ∘ e set F' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E := fun p => (f' (e p)).comp (e : ℝ × ℝ →L[ℝ] ℂ) have hF' : ∀ p : ℝ × ℝ, (-(I • F' p)) (1, 0) + F' p (0, 1) = -(I • f' (e p) 1 - f' (e p) I) := by rintro ⟨x, y⟩ simp only [F', ContinuousLinearMap.neg_apply, ContinuousLinearMap.smul_apply, ContinuousLinearMap.comp_apply, ContinuousLinearEquiv.coe_coe, he₁, he₂, neg_add_eq_sub, neg_sub] set R : Set (ℝ × ℝ) := [[z.re, w.re]] ×ˢ [[w.im, z.im]] set t : Set (ℝ × ℝ) := e ⁻¹' s rw [uIcc_comm z.im] at Hc Hi; rw [min_comm z.im, max_comm z.im] at Hd have hR : e ⁻¹' ([[z.re, w.re]] ×ℂ [[w.im, z.im]]) = R := rfl have htc : ContinuousOn F R := Hc.comp e.continuousOn hR.ge have htd : ∀ p ∈ Ioo (min z.re w.re) (max z.re w.re) ×ˢ Ioo (min w.im z.im) (max w.im z.im) \ t, HasFDerivAt F (F' p) p := fun p hp => (Hd (e p) hp).comp p e.hasFDerivAt simp_rw [← intervalIntegral.integral_smul, intervalIntegral.integral_symm w.im z.im, ← intervalIntegral.integral_neg, ← hF'] refine (integral2_divergence_prod_of_hasFDerivWithinAt_off_countable (fun p => -(I • F p)) F (fun p => -(I • F' p)) F' z.re w.im w.re z.im t (hs.preimage e.injective) (htc.const_smul _).neg htc (fun p hp => ((htd p hp).const_smul I).neg) htd ?_).symm rw [← (volume_preserving_equiv_real_prod.symm _).integrableOn_comp_preimage (MeasurableEquiv.measurableEmbedding _)] at Hi simpa only [hF'] using Hi.neg
28
import Mathlib.Analysis.NormedSpace.Real import Mathlib.Analysis.Seminorm import Mathlib.Topology.MetricSpace.HausdorffDistance #align_import analysis.normed_space.riesz_lemma from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open Set Metric open Topology variable {𝕜 : Type*} [NormedField 𝕜] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {F : Type*} [SeminormedAddCommGroup F] [NormedSpace ℝ F]
Mathlib/Analysis/NormedSpace/RieszLemma.lean
41
70
theorem riesz_lemma {F : Subspace 𝕜 E} (hFc : IsClosed (F : Set E)) (hF : ∃ x : E, x ∉ F) {r : ℝ} (hr : r < 1) : ∃ x₀ : E, x₀ ∉ F ∧ ∀ y ∈ F, r * ‖x₀‖ ≤ ‖x₀ - y‖ := by
classical obtain ⟨x, hx⟩ : ∃ x : E, x ∉ F := hF let d := Metric.infDist x F have hFn : (F : Set E).Nonempty := ⟨_, F.zero_mem⟩ have hdp : 0 < d := lt_of_le_of_ne Metric.infDist_nonneg fun heq => hx ((hFc.mem_iff_infDist_zero hFn).2 heq.symm) let r' := max r 2⁻¹ have hr' : r' < 1 := by simp only [r', ge_iff_le, max_lt_iff, hr, true_and] norm_num have hlt : 0 < r' := lt_of_lt_of_le (by norm_num) (le_max_right r 2⁻¹) have hdlt : d < d / r' := (lt_div_iff hlt).mpr ((mul_lt_iff_lt_one_right hdp).2 hr') obtain ⟨y₀, hy₀F, hxy₀⟩ : ∃ y ∈ F, dist x y < d / r' := (Metric.infDist_lt_iff hFn).mp hdlt have x_ne_y₀ : x - y₀ ∉ F := by by_contra h have : x - y₀ + y₀ ∈ F := F.add_mem h hy₀F simp only [neg_add_cancel_right, sub_eq_add_neg] at this exact hx this refine ⟨x - y₀, x_ne_y₀, fun y hy => le_of_lt ?_⟩ have hy₀y : y₀ + y ∈ F := F.add_mem hy₀F hy calc r * ‖x - y₀‖ ≤ r' * ‖x - y₀‖ := by gcongr; apply le_max_left _ < d := by rw [← dist_eq_norm] exact (lt_div_iff' hlt).1 hxy₀ _ ≤ dist x (y₀ + y) := Metric.infDist_le_dist_of_mem hy₀y _ = ‖x - y₀ - y‖ := by rw [sub_sub, dist_eq_norm]
28
import Mathlib.Analysis.Normed.Order.Basic import Mathlib.Analysis.Asymptotics.Asymptotics import Mathlib.Analysis.NormedSpace.Basic #align_import analysis.asymptotics.specific_asymptotics from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open Filter Asymptotics open Topology section Real open Finset
Mathlib/Analysis/Asymptotics/SpecificAsymptotics.lean
98
128
theorem Asymptotics.IsLittleO.sum_range {α : Type*} [NormedAddCommGroup α] {f : ℕ → α} {g : ℕ → ℝ} (h : f =o[atTop] g) (hg : 0 ≤ g) (h'g : Tendsto (fun n => ∑ i ∈ range n, g i) atTop atTop) : (fun n => ∑ i ∈ range n, f i) =o[atTop] fun n => ∑ i ∈ range n, g i := by
have A : ∀ i, ‖g i‖ = g i := fun i => Real.norm_of_nonneg (hg i) have B : ∀ n, ‖∑ i ∈ range n, g i‖ = ∑ i ∈ range n, g i := fun n => by rwa [Real.norm_eq_abs, abs_sum_of_nonneg'] apply isLittleO_iff.2 fun ε εpos => _ intro ε εpos obtain ⟨N, hN⟩ : ∃ N : ℕ, ∀ b : ℕ, N ≤ b → ‖f b‖ ≤ ε / 2 * g b := by simpa only [A, eventually_atTop] using isLittleO_iff.mp h (half_pos εpos) have : (fun _ : ℕ => ∑ i ∈ range N, f i) =o[atTop] fun n : ℕ => ∑ i ∈ range n, g i := by apply isLittleO_const_left.2 exact Or.inr (h'g.congr fun n => (B n).symm) filter_upwards [isLittleO_iff.1 this (half_pos εpos), Ici_mem_atTop N] with n hn Nn calc ‖∑ i ∈ range n, f i‖ = ‖(∑ i ∈ range N, f i) + ∑ i ∈ Ico N n, f i‖ := by rw [sum_range_add_sum_Ico _ Nn] _ ≤ ‖∑ i ∈ range N, f i‖ + ‖∑ i ∈ Ico N n, f i‖ := norm_add_le _ _ _ ≤ ‖∑ i ∈ range N, f i‖ + ∑ i ∈ Ico N n, ε / 2 * g i := (add_le_add le_rfl (norm_sum_le_of_le _ fun i hi => hN _ (mem_Ico.1 hi).1)) _ ≤ ‖∑ i ∈ range N, f i‖ + ∑ i ∈ range n, ε / 2 * g i := by gcongr apply sum_le_sum_of_subset_of_nonneg · rw [range_eq_Ico] exact Ico_subset_Ico (zero_le _) le_rfl · intro i _ _ exact mul_nonneg (half_pos εpos).le (hg i) _ ≤ ε / 2 * ‖∑ i ∈ range n, g i‖ + ε / 2 * ∑ i ∈ range n, g i := by rw [← mul_sum]; gcongr _ = ε * ‖∑ i ∈ range n, g i‖ := by simp only [B] ring
28
import Mathlib.LinearAlgebra.Dimension.Free import Mathlib.Algebra.Homology.ShortComplex.ModuleCat open CategoryTheory namespace ModuleCat variable {ι ι' R : Type*} [Ring R] {S : ShortComplex (ModuleCat R)} (hS : S.Exact) (hS' : S.ShortExact) {v : ι → S.X₁} open CategoryTheory Submodule Set section Span
Mathlib/Algebra/Category/ModuleCat/Free.lean
94
125
theorem span_exact {β : Type*} {u : ι ⊕ β → S.X₂} (huv : u ∘ Sum.inl = S.f ∘ v) (hv : ⊤ ≤ span R (range v)) (hw : ⊤ ≤ span R (range (S.g ∘ u ∘ Sum.inr))) : ⊤ ≤ span R (range u) := by
intro m _ have hgm : S.g m ∈ span R (range (S.g ∘ u ∘ Sum.inr)) := hw mem_top rw [Finsupp.mem_span_range_iff_exists_finsupp] at hgm obtain ⟨cm, hm⟩ := hgm let m' : S.X₂ := Finsupp.sum cm fun j a ↦ a • (u (Sum.inr j)) have hsub : m - m' ∈ LinearMap.range S.f := by rw [hS.moduleCat_range_eq_ker] simp only [LinearMap.mem_ker, map_sub, sub_eq_zero] rw [← hm, map_finsupp_sum] simp only [Function.comp_apply, map_smul] obtain ⟨n, hnm⟩ := hsub have hn : n ∈ span R (range v) := hv mem_top rw [Finsupp.mem_span_range_iff_exists_finsupp] at hn obtain ⟨cn, hn⟩ := hn rw [← hn, map_finsupp_sum] at hnm rw [← sub_add_cancel m m', ← hnm,] simp only [map_smul] have hn' : (Finsupp.sum cn fun a b ↦ b • S.f (v a)) = (Finsupp.sum cn fun a b ↦ b • u (Sum.inl a)) := by congr; ext a b; rw [← Function.comp_apply (f := S.f), ← huv, Function.comp_apply] rw [hn'] apply add_mem · rw [Finsupp.mem_span_range_iff_exists_finsupp] use cn.mapDomain (Sum.inl) rw [Finsupp.sum_mapDomain_index_inj Sum.inl_injective] · rw [Finsupp.mem_span_range_iff_exists_finsupp] use cm.mapDomain (Sum.inr) rw [Finsupp.sum_mapDomain_index_inj Sum.inr_injective]
28
import Mathlib.FieldTheory.Separable import Mathlib.RingTheory.IntegralDomain import Mathlib.Algebra.CharP.Reduced import Mathlib.Tactic.ApplyFun #align_import field_theory.finite.basic from "leanprover-community/mathlib"@"12a85fac627bea918960da036049d611b1a3ee43" variable {K : Type*} {R : Type*} local notation "q" => Fintype.card K open Finset open scoped Polynomial namespace FiniteField theorem prod_univ_units_id_eq_neg_one [CommRing K] [IsDomain K] [Fintype Kˣ] : ∏ x : Kˣ, x = (-1 : Kˣ) := by classical have : (∏ x ∈ (@univ Kˣ _).erase (-1), x) = 1 := prod_involution (fun x _ => x⁻¹) (by simp) (fun a => by simp (config := { contextual := true }) [Units.inv_eq_self_iff]) (fun a => by simp [@inv_eq_iff_eq_inv _ _ a]) (by simp) rw [← insert_erase (mem_univ (-1 : Kˣ)), prod_insert (not_mem_erase _ _), this, mul_one] #align finite_field.prod_univ_units_id_eq_neg_one FiniteField.prod_univ_units_id_eq_neg_one set_option backward.synthInstance.canonInstances false in -- See https://github.com/leanprover-community/mathlib4/issues/12532 theorem card_cast_subgroup_card_ne_zero [Ring K] [NoZeroDivisors K] [Nontrivial K] (G : Subgroup Kˣ) [Fintype G] : (Fintype.card G : K) ≠ 0 := by let n := Fintype.card G intro nzero have ⟨p, char_p⟩ := CharP.exists K have hd : p ∣ n := (CharP.cast_eq_zero_iff K p n).mp nzero cases CharP.char_is_prime_or_zero K p with | inr pzero => exact (Fintype.card_pos).ne' <| Nat.eq_zero_of_zero_dvd <| pzero ▸ hd | inl pprime => have fact_pprime := Fact.mk pprime -- G has an element x of order p by Cauchy's theorem have ⟨x, hx⟩ := exists_prime_orderOf_dvd_card p hd -- F has an element u (= ↑↑x) of order p let u := ((x : Kˣ) : K) have hu : orderOf u = p := by rwa [orderOf_units, Subgroup.orderOf_coe] -- u ^ p = 1 implies (u - 1) ^ p = 0 and hence u = 1 ... have h : u = 1 := by rw [← sub_left_inj, sub_self 1] apply pow_eq_zero (n := p) rw [sub_pow_char_of_commute, one_pow, ← hu, pow_orderOf_eq_one, sub_self] exact Commute.one_right u -- ... meaning x didn't have order p after all, contradiction apply pprime.one_lt.ne rw [← hu, h, orderOf_one] theorem sum_subgroup_units_eq_zero [Ring K] [NoZeroDivisors K] {G : Subgroup Kˣ} [Fintype G] (hg : G ≠ ⊥) : ∑ x : G, (x.val : K) = 0 := by rw [Subgroup.ne_bot_iff_exists_ne_one] at hg rcases hg with ⟨a, ha⟩ -- The action of a on G as an embedding let a_mul_emb : G ↪ G := mulLeftEmbedding a -- ... and leaves G unchanged have h_unchanged : Finset.univ.map a_mul_emb = Finset.univ := by simp -- Therefore the sum of x over a G is the sum of a x over G have h_sum_map := Finset.univ.sum_map a_mul_emb fun x => ((x : Kˣ) : K) -- ... and the former is the sum of x over G. -- By algebraic manipulation, we have Σ G, x = ∑ G, a x = a ∑ G, x simp only [a_mul_emb, h_unchanged, Function.Embedding.coeFn_mk, Function.Embedding.toFun_eq_coe, mulLeftEmbedding_apply, Submonoid.coe_mul, Subgroup.coe_toSubmonoid, Units.val_mul, ← Finset.mul_sum] at h_sum_map -- thus one of (a - 1) or ∑ G, x is zero have hzero : (((a : Kˣ) : K) - 1) = 0 ∨ ∑ x : ↥G, ((x : Kˣ) : K) = 0 := by rw [← mul_eq_zero, sub_mul, ← h_sum_map, one_mul, sub_self] apply Or.resolve_left hzero contrapose! ha ext rwa [← sub_eq_zero] @[simp] theorem sum_subgroup_units [Ring K] [NoZeroDivisors K] {G : Subgroup Kˣ} [Fintype G] [Decidable (G = ⊥)] : ∑ x : G, (x.val : K) = if G = ⊥ then 1 else 0 := by by_cases G_bot : G = ⊥ · subst G_bot simp only [ite_true, Subgroup.mem_bot, Fintype.card_ofSubsingleton, Nat.cast_ite, Nat.cast_one, Nat.cast_zero, univ_unique, Set.default_coe_singleton, sum_singleton, Units.val_one] · simp only [G_bot, ite_false] exact sum_subgroup_units_eq_zero G_bot @[simp]
Mathlib/FieldTheory/Finite/Basic.lean
179
210
theorem sum_subgroup_pow_eq_zero [CommRing K] [NoZeroDivisors K] {G : Subgroup Kˣ} [Fintype G] {k : ℕ} (k_pos : k ≠ 0) (k_lt_card_G : k < Fintype.card G) : ∑ x : G, ((x : Kˣ) : K) ^ k = 0 := by
nontriviality K have := NoZeroDivisors.to_isDomain K rcases (exists_pow_ne_one_of_isCyclic k_pos k_lt_card_G) with ⟨a, ha⟩ rw [Finset.sum_eq_multiset_sum] have h_multiset_map : Finset.univ.val.map (fun x : G => ((x : Kˣ) : K) ^ k) = Finset.univ.val.map (fun x : G => ((x : Kˣ) : K) ^ k * ((a : Kˣ) : K) ^ k) := by simp_rw [← mul_pow] have as_comp : (fun x : ↥G => (((x : Kˣ) : K) * ((a : Kˣ) : K)) ^ k) = (fun x : ↥G => ((x : Kˣ) : K) ^ k) ∘ fun x : ↥G => x * a := by funext x simp only [Function.comp_apply, Submonoid.coe_mul, Subgroup.coe_toSubmonoid, Units.val_mul] rw [as_comp, ← Multiset.map_map] congr rw [eq_comm] exact Multiset.map_univ_val_equiv (Equiv.mulRight a) have h_multiset_map_sum : (Multiset.map (fun x : G => ((x : Kˣ) : K) ^ k) Finset.univ.val).sum = (Multiset.map (fun x : G => ((x : Kˣ) : K) ^ k * ((a : Kˣ) : K) ^ k) Finset.univ.val).sum := by rw [h_multiset_map] rw [Multiset.sum_map_mul_right] at h_multiset_map_sum have hzero : (((a : Kˣ) : K) ^ k - 1 : K) * (Multiset.map (fun i : G => (i.val : K) ^ k) Finset.univ.val).sum = 0 := by rw [sub_mul, mul_comm, ← h_multiset_map_sum, one_mul, sub_self] rw [mul_eq_zero] at hzero refine hzero.resolve_left fun h => ha ?_ ext rw [← sub_eq_zero] simp_rw [SubmonoidClass.coe_pow, Units.val_pow_eq_pow_val, OneMemClass.coe_one, Units.val_one, h]
29
import Mathlib.Order.Interval.Set.OrdConnectedComponent import Mathlib.Topology.Order.Basic #align_import topology.algebra.order.t5 from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" open Filter Set Function OrderDual Topology Interval variable {X : Type*} [LinearOrder X] [TopologicalSpace X] [OrderTopology X] {a b c : X} {s t : Set X} namespace Set @[simp] theorem ordConnectedComponent_mem_nhds : ordConnectedComponent s a ∈ 𝓝 a ↔ s ∈ 𝓝 a := by refine ⟨fun h => mem_of_superset h ordConnectedComponent_subset, fun h => ?_⟩ rcases exists_Icc_mem_subset_of_mem_nhds h with ⟨b, c, ha, ha', hs⟩ exact mem_of_superset ha' (subset_ordConnectedComponent ha hs) #align set.ord_connected_component_mem_nhds Set.ordConnectedComponent_mem_nhds
Mathlib/Topology/Order/T5.lean
33
63
theorem compl_section_ordSeparatingSet_mem_nhdsWithin_Ici (hd : Disjoint s (closure t)) (ha : a ∈ s) : (ordConnectedSection (ordSeparatingSet s t))ᶜ ∈ 𝓝[≥] a := by
have hmem : tᶜ ∈ 𝓝[≥] a := by refine mem_nhdsWithin_of_mem_nhds ?_ rw [← mem_interior_iff_mem_nhds, interior_compl] exact disjoint_left.1 hd ha rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici hmem with ⟨b, hab, hmem', hsub⟩ by_cases H : Disjoint (Icc a b) (ordConnectedSection <| ordSeparatingSet s t) · exact mem_of_superset hmem' (disjoint_left.1 H) · simp only [Set.disjoint_left, not_forall, Classical.not_not] at H rcases H with ⟨c, ⟨hac, hcb⟩, hc⟩ have hsub' : Icc a b ⊆ ordConnectedComponent tᶜ a := subset_ordConnectedComponent (left_mem_Icc.2 hab) hsub have hd : Disjoint s (ordConnectedSection (ordSeparatingSet s t)) := disjoint_left_ordSeparatingSet.mono_right ordConnectedSection_subset replace hac : a < c := hac.lt_of_ne <| Ne.symm <| ne_of_mem_of_not_mem hc <| disjoint_left.1 hd ha refine mem_of_superset (Ico_mem_nhdsWithin_Ici (left_mem_Ico.2 hac)) fun x hx hx' => ?_ refine hx.2.ne (eq_of_mem_ordConnectedSection_of_uIcc_subset hx' hc ?_) refine subset_inter (subset_iUnion₂_of_subset a ha ?_) ?_ · exact OrdConnected.uIcc_subset inferInstance (hsub' ⟨hx.1, hx.2.le.trans hcb⟩) (hsub' ⟨hac.le, hcb⟩) · rcases mem_iUnion₂.1 (ordConnectedSection_subset hx').2 with ⟨y, hyt, hxy⟩ refine subset_iUnion₂_of_subset y hyt (OrdConnected.uIcc_subset inferInstance hxy ?_) refine subset_ordConnectedComponent left_mem_uIcc hxy ?_ suffices c < y by rw [uIcc_of_ge (hx.2.trans this).le] exact ⟨hx.2.le, this.le⟩ refine lt_of_not_le fun hyc => ?_ have hya : y < a := not_le.1 fun hay => hsub ⟨hay, hyc.trans hcb⟩ hyt exact hxy (Icc_subset_uIcc ⟨hya.le, hx.1⟩) ha
29
import Mathlib.Algebra.Group.Subgroup.Basic import Mathlib.Algebra.Group.Submonoid.Membership import Mathlib.Data.Finite.Card #align_import group_theory.subgroup.finite from "leanprover-community/mathlib"@"f93c11933efbc3c2f0299e47b8ff83e9b539cbf6" variable {G : Type*} [Group G] variable {A : Type*} [AddGroup A] namespace Subgroup section Pi open Set variable {η : Type*} {f : η → Type*} [∀ i, Group (f i)] @[to_additive]
Mathlib/Algebra/Group/Subgroup/Finite.lean
195
226
theorem pi_mem_of_mulSingle_mem_aux [DecidableEq η] (I : Finset η) {H : Subgroup (∀ i, f i)} (x : ∀ i, f i) (h1 : ∀ i, i ∉ I → x i = 1) (h2 : ∀ i, i ∈ I → Pi.mulSingle i (x i) ∈ H) : x ∈ H := by
induction' I using Finset.induction_on with i I hnmem ih generalizing x · convert one_mem H ext i exact h1 i (Finset.not_mem_empty i) · have : x = Function.update x i 1 * Pi.mulSingle i (x i) := by ext j by_cases heq : j = i · subst heq simp · simp [heq] rw [this] clear this apply mul_mem · apply ih <;> clear ih · intro j hj by_cases heq : j = i · subst heq simp · simp [heq] apply h1 j simpa [heq] using hj · intro j hj have : j ≠ i := by rintro rfl contradiction simp only [ne_eq, this, not_false_eq_true, Function.update_noteq] exact h2 _ (Finset.mem_insert_of_mem hj) · apply h2 simp
29
import Mathlib.Data.Finset.Fin import Mathlib.Data.Int.Order.Units import Mathlib.GroupTheory.OrderOfElement import Mathlib.GroupTheory.Perm.Support import Mathlib.Logic.Equiv.Fintype #align_import group_theory.perm.sign from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" universe u v open Equiv Function Fintype Finset variable {α : Type u} {β : Type v} -- An example on how to determine the order of an element of a finite group. example : orderOf (-1 : ℤˣ) = 2 := orderOf_eq_prime (Int.units_sq _) (by decide) namespace Equiv.Perm theorem perm_inv_on_of_perm_on_finset {s : Finset α} {f : Perm α} (h : ∀ x ∈ s, f x ∈ s) {y : α} (hy : y ∈ s) : f⁻¹ y ∈ s := by have h0 : ∀ y ∈ s, ∃ (x : _) (hx : x ∈ s), y = (fun i (_ : i ∈ s) => f i) x hx := Finset.surj_on_of_inj_on_of_card_le (fun x hx => (fun i _ => f i) x hx) (fun a ha => h a ha) (fun a₁ a₂ ha₁ ha₂ heq => (Equiv.apply_eq_iff_eq f).mp heq) rfl.ge obtain ⟨y2, hy2, heq⟩ := h0 y hy convert hy2 rw [heq] simp only [inv_apply_self] #align equiv.perm.perm_inv_on_of_perm_on_finset Equiv.Perm.perm_inv_on_of_perm_on_finset theorem perm_inv_mapsTo_of_mapsTo (f : Perm α) {s : Set α} [Finite s] (h : Set.MapsTo f s s) : Set.MapsTo (f⁻¹ : _) s s := by cases nonempty_fintype s exact fun x hx => Set.mem_toFinset.mp <| perm_inv_on_of_perm_on_finset (fun a ha => Set.mem_toFinset.mpr (h (Set.mem_toFinset.mp ha))) (Set.mem_toFinset.mpr hx) #align equiv.perm.perm_inv_maps_to_of_maps_to Equiv.Perm.perm_inv_mapsTo_of_mapsTo @[simp] theorem perm_inv_mapsTo_iff_mapsTo {f : Perm α} {s : Set α} [Finite s] : Set.MapsTo (f⁻¹ : _) s s ↔ Set.MapsTo f s s := ⟨perm_inv_mapsTo_of_mapsTo f⁻¹, perm_inv_mapsTo_of_mapsTo f⟩ #align equiv.perm.perm_inv_maps_to_iff_maps_to Equiv.Perm.perm_inv_mapsTo_iff_mapsTo theorem perm_inv_on_of_perm_on_finite {f : Perm α} {p : α → Prop} [Finite { x // p x }] (h : ∀ x, p x → p (f x)) {x : α} (hx : p x) : p (f⁻¹ x) := -- Porting note: relies heavily on the definitions of `Subtype` and `setOf` unfolding to their -- underlying predicate. have : Finite { x | p x } := ‹_› perm_inv_mapsTo_of_mapsTo (s := {x | p x}) f h hx #align equiv.perm.perm_inv_on_of_perm_on_finite Equiv.Perm.perm_inv_on_of_perm_on_finite abbrev subtypePermOfFintype (f : Perm α) {p : α → Prop} [Finite { x // p x }] (h : ∀ x, p x → p (f x)) : Perm { x // p x } := f.subtypePerm fun x => ⟨h x, fun h₂ => f.inv_apply_self x ▸ perm_inv_on_of_perm_on_finite h h₂⟩ #align equiv.perm.subtype_perm_of_fintype Equiv.Perm.subtypePermOfFintype @[simp] theorem subtypePermOfFintype_apply (f : Perm α) {p : α → Prop} [Finite { x // p x }] (h : ∀ x, p x → p (f x)) (x : { x // p x }) : subtypePermOfFintype f h x = ⟨f x, h x x.2⟩ := rfl #align equiv.perm.subtype_perm_of_fintype_apply Equiv.Perm.subtypePermOfFintype_apply theorem subtypePermOfFintype_one (p : α → Prop) [Finite { x // p x }] (h : ∀ x, p x → p ((1 : Perm α) x)) : @subtypePermOfFintype α 1 p _ h = 1 := rfl #align equiv.perm.subtype_perm_of_fintype_one Equiv.Perm.subtypePermOfFintype_one theorem perm_mapsTo_inl_iff_mapsTo_inr {m n : Type*} [Finite m] [Finite n] (σ : Perm (Sum m n)) : Set.MapsTo σ (Set.range Sum.inl) (Set.range Sum.inl) ↔ Set.MapsTo σ (Set.range Sum.inr) (Set.range Sum.inr) := by constructor <;> ( intro h classical rw [← perm_inv_mapsTo_iff_mapsTo] at h intro x cases' hx : σ x with l r) · rintro ⟨a, rfl⟩ obtain ⟨y, hy⟩ := h ⟨l, rfl⟩ rw [← hx, σ.inv_apply_self] at hy exact absurd hy Sum.inl_ne_inr · rintro _; exact ⟨r, rfl⟩ · rintro _; exact ⟨l, rfl⟩ · rintro ⟨a, rfl⟩ obtain ⟨y, hy⟩ := h ⟨r, rfl⟩ rw [← hx, σ.inv_apply_self] at hy exact absurd hy Sum.inr_ne_inl #align equiv.perm.perm_maps_to_inl_iff_maps_to_inr Equiv.Perm.perm_mapsTo_inl_iff_mapsTo_inr
Mathlib/GroupTheory/Perm/Finite.lean
132
163
theorem mem_sumCongrHom_range_of_perm_mapsTo_inl {m n : Type*} [Finite m] [Finite n] {σ : Perm (Sum m n)} (h : Set.MapsTo σ (Set.range Sum.inl) (Set.range Sum.inl)) : σ ∈ (sumCongrHom m n).range := by
classical have h1 : ∀ x : Sum m n, (∃ a : m, Sum.inl a = x) → ∃ a : m, Sum.inl a = σ x := by rintro x ⟨a, ha⟩ apply h rw [← ha] exact ⟨a, rfl⟩ have h3 : ∀ x : Sum m n, (∃ b : n, Sum.inr b = x) → ∃ b : n, Sum.inr b = σ x := by rintro x ⟨b, hb⟩ apply (perm_mapsTo_inl_iff_mapsTo_inr σ).mp h rw [← hb] exact ⟨b, rfl⟩ let σ₁' := subtypePermOfFintype σ h1 let σ₂' := subtypePermOfFintype σ h3 let σ₁ := permCongr (Equiv.ofInjective _ Sum.inl_injective).symm σ₁' let σ₂ := permCongr (Equiv.ofInjective _ Sum.inr_injective).symm σ₂' rw [MonoidHom.mem_range, Prod.exists] use σ₁, σ₂ rw [Perm.sumCongrHom_apply] ext x cases' x with a b · rw [Equiv.sumCongr_apply, Sum.map_inl, permCongr_apply, Equiv.symm_symm, apply_ofInjective_symm Sum.inl_injective] rw [ofInjective_apply, Subtype.coe_mk, Subtype.coe_mk] -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [subtypePerm_apply] · rw [Equiv.sumCongr_apply, Sum.map_inr, permCongr_apply, Equiv.symm_symm, apply_ofInjective_symm Sum.inr_injective] erw [subtypePerm_apply] rw [ofInjective_apply, Subtype.coe_mk, Subtype.coe_mk]
29
import Batteries.Data.UnionFind.Basic namespace Batteries.UnionFind @[simp] theorem arr_empty : empty.arr = #[] := rfl @[simp] theorem parent_empty : empty.parent a = a := rfl @[simp] theorem rank_empty : empty.rank a = 0 := rfl @[simp] theorem rootD_empty : empty.rootD a = a := rfl @[simp] theorem arr_push {m : UnionFind} : m.push.arr = m.arr.push ⟨m.arr.size, 0⟩ := rfl @[simp] theorem parentD_push {arr : Array UFNode} : parentD (arr.push ⟨arr.size, 0⟩) a = parentD arr a := by simp [parentD]; split <;> split <;> try simp [Array.get_push, *] · next h1 h2 => simp [Nat.lt_succ] at h1 h2 exact Nat.le_antisymm h2 h1 · next h1 h2 => cases h1 (Nat.lt_succ_of_lt h2) @[simp] theorem parent_push {m : UnionFind} : m.push.parent a = m.parent a := by simp [parent] @[simp] theorem rankD_push {arr : Array UFNode} : rankD (arr.push ⟨arr.size, 0⟩) a = rankD arr a := by simp [rankD]; split <;> split <;> try simp [Array.get_push, *] next h1 h2 => cases h1 (Nat.lt_succ_of_lt h2) @[simp] theorem rank_push {m : UnionFind} : m.push.rank a = m.rank a := by simp [rank] @[simp] theorem rankMax_push {m : UnionFind} : m.push.rankMax = m.rankMax := by simp [rankMax] @[simp] theorem root_push {self : UnionFind} : self.push.rootD x = self.rootD x := rootD_ext fun _ => parent_push @[simp] theorem arr_link : (link self x y yroot).arr = linkAux self.arr x y := rfl theorem parentD_linkAux {self} {x y : Fin self.size} : parentD (linkAux self x y) i = if x.1 = y then parentD self i else if (self.get y).rank < (self.get x).rank then if y = i then x else parentD self i else if x = i then y else parentD self i := by dsimp only [linkAux]; split <;> [rfl; split] <;> [rw [parentD_set]; split] <;> rw [parentD_set] split <;> [(subst i; rwa [if_neg, parentD_eq]); rw [parentD_set]] theorem parent_link {self} {x y : Fin self.size} (yroot) {i} : (link self x y yroot).parent i = if x.1 = y then self.parent i else if self.rank y < self.rank x then if y = i then x else self.parent i else if x = i then y else self.parent i := by simp [rankD_eq]; exact parentD_linkAux
.lake/packages/batteries/Batteries/Data/UnionFind/Lemmas.lean
64
97
theorem root_link {self : UnionFind} {x y : Fin self.size} (xroot : self.parent x = x) (yroot : self.parent y = y) : ∃ r, (r = x ∨ r = y) ∧ ∀ i, (link self x y yroot).rootD i = if self.rootD i = x ∨ self.rootD i = y then r.1 else self.rootD i := by
if h : x.1 = y then refine ⟨x, .inl rfl, fun i => ?_⟩ rw [rootD_ext (m2 := self) (fun _ => by rw [parent_link, if_pos h])] split <;> [obtain _ | _ := ‹_› <;> simp [*]; rfl] else have {x y : Fin self.size} (xroot : self.parent x = x) (yroot : self.parent y = y) {m : UnionFind} (hm : ∀ i, m.parent i = if y = i then x.1 else self.parent i) : ∃ r, (r = x ∨ r = y) ∧ ∀ i, m.rootD i = if self.rootD i = x ∨ self.rootD i = y then r.1 else self.rootD i := by let rec go (i) : m.rootD i = if self.rootD i = x ∨ self.rootD i = y then x.1 else self.rootD i := by if h : m.parent i = i then rw [rootD_eq_self.2 h]; rw [hm i] at h; split at h · rw [if_pos, h]; simp [← h, rootD_eq_self, xroot] · rw [rootD_eq_self.2 ‹_›]; split <;> [skip; rfl] next h' => exact h'.resolve_right (Ne.symm ‹_›) else have _ := Nat.sub_lt_sub_left (m.lt_rankMax i) (m.rank_lt h) rw [← rootD_parent, go (m.parent i)] rw [hm i]; split <;> [subst i; rw [rootD_parent]] simp [rootD_eq_self.2 xroot, rootD_eq_self.2 yroot] termination_by m.rankMax - m.rank i exact ⟨x, .inl rfl, go⟩ if hr : self.rank y < self.rank x then exact this xroot yroot fun i => by simp [parent_link, h, hr] else simpa (config := {singlePass := true}) [or_comm] using this yroot xroot fun i => by simp [parent_link, h, hr]
29
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]
29
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
29
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]
29
import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Algebra.BigOperators.NatAntidiagonal import Mathlib.Algebra.BigOperators.Ring import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Data.Nat.Choose.Basic import Mathlib.Tactic.Linarith import Mathlib.Tactic.Ring #align_import data.nat.choose.sum from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" open Nat open Finset variable {R : Type*} namespace Commute variable [Semiring R] {x y : R}
Mathlib/Data/Nat/Choose/Sum.lean
37
67
theorem add_pow (h : Commute x y) (n : ℕ) : (x + y) ^ n = ∑ m ∈ range (n + 1), x ^ m * y ^ (n - m) * choose n m := by
let t : ℕ → ℕ → R := fun n m ↦ x ^ m * y ^ (n - m) * choose n m change (x + y) ^ n = ∑ m ∈ range (n + 1), t n m have h_first : ∀ n, t n 0 = y ^ n := fun n ↦ by simp only [t, choose_zero_right, _root_.pow_zero, Nat.cast_one, mul_one, one_mul, tsub_zero] have h_last : ∀ n, t n n.succ = 0 := fun n ↦ by simp only [t, ge_iff_le, choose_succ_self, cast_zero, mul_zero] have h_middle : ∀ n i : ℕ, i ∈ range n.succ → (t n.succ ∘ Nat.succ) i = x * t n i + y * t n i.succ := by intro n i h_mem have h_le : i ≤ n := Nat.le_of_lt_succ (mem_range.mp h_mem) dsimp only [t] rw [Function.comp_apply, choose_succ_succ, Nat.cast_add, mul_add] congr 1 · rw [pow_succ' x, succ_sub_succ, mul_assoc, mul_assoc, mul_assoc] · rw [← mul_assoc y, ← mul_assoc y, (h.symm.pow_right i.succ).eq] by_cases h_eq : i = n · rw [h_eq, choose_succ_self, Nat.cast_zero, mul_zero, mul_zero] · rw [succ_sub (lt_of_le_of_ne h_le h_eq)] rw [pow_succ' y, mul_assoc, mul_assoc, mul_assoc, mul_assoc] induction' n with n ih · rw [_root_.pow_zero, sum_range_succ, range_zero, sum_empty, zero_add] dsimp only [t] rw [_root_.pow_zero, _root_.pow_zero, choose_self, Nat.cast_one, mul_one, mul_one] · rw [sum_range_succ', h_first] erw [sum_congr rfl (h_middle n), sum_add_distrib, add_assoc] rw [pow_succ' (x + y), ih, add_mul, mul_sum, mul_sum] congr 1 rw [sum_range_succ', sum_range_succ, h_first, h_last, mul_zero, add_zero, _root_.pow_succ']
29
import Mathlib.Computability.Encoding import Mathlib.Logic.Small.List import Mathlib.ModelTheory.Syntax import Mathlib.SetTheory.Cardinal.Ordinal #align_import model_theory.encoding from "leanprover-community/mathlib"@"91288e351d51b3f0748f0a38faa7613fb0ae2ada" universe u v w u' v' namespace FirstOrder namespace Language variable {L : Language.{u, v}} variable {M : Type w} {N P : Type*} [L.Structure M] [L.Structure N] [L.Structure P] variable {α : Type u'} {β : Type v'} open FirstOrder Cardinal open Computability List Structure Cardinal Fin namespace Term def listEncode : L.Term α → List (Sum α (Σi, L.Functions i)) | var i => [Sum.inl i] | func f ts => Sum.inr (⟨_, f⟩ : Σi, L.Functions i)::(List.finRange _).bind fun i => (ts i).listEncode #align first_order.language.term.list_encode FirstOrder.Language.Term.listEncode def listDecode : List (Sum α (Σi, L.Functions i)) → List (Option (L.Term α)) | [] => [] | Sum.inl a::l => some (var a)::listDecode l | Sum.inr ⟨n, f⟩::l => if h : ∀ i : Fin n, ((listDecode l).get? i).join.isSome then (func f fun i => Option.get _ (h i))::(listDecode l).drop n else [none] #align first_order.language.term.list_decode FirstOrder.Language.Term.listDecode theorem listDecode_encode_list (l : List (L.Term α)) : listDecode (l.bind listEncode) = l.map Option.some := by suffices h : ∀ (t : L.Term α) (l : List (Sum α (Σi, L.Functions i))), listDecode (t.listEncode ++ l) = some t::listDecode l by induction' l with t l lih · rfl · rw [cons_bind, h t (l.bind listEncode), lih, List.map] intro t induction' t with a n f ts ih <;> intro l · rw [listEncode, singleton_append, listDecode] · rw [listEncode, cons_append, listDecode] have h : listDecode (((finRange n).bind fun i : Fin n => (ts i).listEncode) ++ l) = (finRange n).map (Option.some ∘ ts) ++ listDecode l := by induction' finRange n with i l' l'ih · rfl · rw [cons_bind, List.append_assoc, ih, map_cons, l'ih, cons_append, Function.comp] have h' : ∀ i : Fin n, (listDecode (((finRange n).bind fun i : Fin n => (ts i).listEncode) ++ l)).get? ↑i = some (some (ts i)) := by intro i rw [h, get?_append, get?_map] · simp only [Option.map_eq_some', Function.comp_apply, get?_eq_some] refine ⟨i, ⟨lt_of_lt_of_le i.2 (ge_of_eq (length_finRange _)), ?_⟩, rfl⟩ rw [get_finRange, Fin.eta] · refine lt_of_lt_of_le i.2 ?_ simp refine (dif_pos fun i => Option.isSome_iff_exists.2 ⟨ts i, ?_⟩).trans ?_ · rw [Option.join_eq_some, h'] refine congr (congr rfl (congr rfl (congr rfl (funext fun i => Option.get_of_mem _ ?_)))) ?_ · simp [h'] · rw [h, drop_left'] rw [length_map, length_finRange] #align first_order.language.term.list_decode_encode_list FirstOrder.Language.Term.listDecode_encode_list @[simps] protected def encoding : Encoding (L.Term α) where Γ := Sum α (Σi, L.Functions i) encode := listEncode decode l := (listDecode l).head?.join decode_encode t := by have h := listDecode_encode_list [t] rw [bind_singleton] at h simp only [h, Option.join, head?, List.map, Option.some_bind, id] #align first_order.language.term.encoding FirstOrder.Language.Term.encoding theorem listEncode_injective : Function.Injective (listEncode : L.Term α → List (Sum α (Σi, L.Functions i))) := Term.encoding.encode_injective #align first_order.language.term.list_encode_injective FirstOrder.Language.Term.listEncode_injective theorem card_le : #(L.Term α) ≤ max ℵ₀ #(Sum α (Σi, L.Functions i)) := lift_le.1 (_root_.trans Term.encoding.card_le_card_list (lift_le.2 (mk_list_le_max _))) #align first_order.language.term.card_le FirstOrder.Language.Term.card_le
Mathlib/ModelTheory/Encoding.lean
122
151
theorem card_sigma : #(Σn, L.Term (Sum α (Fin n))) = max ℵ₀ #(Sum α (Σi, L.Functions i)) := by
refine le_antisymm ?_ ?_ · rw [mk_sigma] refine (sum_le_iSup_lift _).trans ?_ rw [mk_nat, lift_aleph0, mul_eq_max_of_aleph0_le_left le_rfl, max_le_iff, ciSup_le_iff' (bddAbove_range _)] · refine ⟨le_max_left _ _, fun i => card_le.trans ?_⟩ refine max_le (le_max_left _ _) ?_ rw [← add_eq_max le_rfl, mk_sum, mk_sum, mk_sum, add_comm (Cardinal.lift #α), lift_add, add_assoc, lift_lift, lift_lift, mk_fin, lift_natCast] exact add_le_add_right (nat_lt_aleph0 _).le _ · rw [← one_le_iff_ne_zero] refine _root_.trans ?_ (le_ciSup (bddAbove_range _) 1) rw [one_le_iff_ne_zero, mk_ne_zero_iff] exact ⟨var (Sum.inr 0)⟩ · rw [max_le_iff, ← infinite_iff] refine ⟨Infinite.of_injective (fun i => ⟨i + 1, var (Sum.inr i)⟩) fun i j ij => ?_, ?_⟩ · cases ij rfl · rw [Cardinal.le_def] refine ⟨⟨Sum.elim (fun i => ⟨0, var (Sum.inl i)⟩) fun F => ⟨1, func F.2 fun _ => var (Sum.inr 0)⟩, ?_⟩⟩ rintro (a | a) (b | b) h · simp only [Sum.elim_inl, Sigma.mk.inj_iff, heq_eq_eq, var.injEq, Sum.inl.injEq, true_and] at h rw [h] · simp only [Sum.elim_inl, Sum.elim_inr, Sigma.mk.inj_iff, false_and] at h · simp only [Sum.elim_inr, Sum.elim_inl, Sigma.mk.inj_iff, false_and] at h · simp only [Sum.elim_inr, Sigma.mk.inj_iff, heq_eq_eq, func.injEq, true_and] at h rw [Sigma.ext_iff.2 ⟨h.1, h.2.1⟩]
29
import Mathlib.Analysis.Normed.Field.Basic import Mathlib.LinearAlgebra.Eigenspace.Basic import Mathlib.LinearAlgebra.Determinant variable {K n : Type*} [NormedField K] [Fintype n] [DecidableEq n] {A : Matrix n n K}
Mathlib/LinearAlgebra/Matrix/Gershgorin.lean
26
56
theorem eigenvalue_mem_ball {μ : K} (hμ : Module.End.HasEigenvalue (Matrix.toLin' A) μ) : ∃ k, μ ∈ Metric.closedBall (A k k) (∑ j ∈ Finset.univ.erase k, ‖A k j‖) := by
cases isEmpty_or_nonempty n · exfalso exact hμ Submodule.eq_bot_of_subsingleton · obtain ⟨v, h_eg, h_nz⟩ := hμ.exists_hasEigenvector obtain ⟨i, -, h_i⟩ := Finset.exists_mem_eq_sup' Finset.univ_nonempty (fun i => ‖v i‖) have h_nz : v i ≠ 0 := by contrapose! h_nz ext j rw [Pi.zero_apply, ← norm_le_zero_iff] refine (h_i ▸ Finset.le_sup' (fun i => ‖v i‖) (Finset.mem_univ j)).trans ?_ exact norm_le_zero_iff.mpr h_nz have h_le : ∀ j, ‖v j * (v i)⁻¹‖ ≤ 1 := fun j => by rw [norm_mul, norm_inv, mul_inv_le_iff' (norm_pos_iff.mpr h_nz), one_mul] exact h_i ▸ Finset.le_sup' (fun i => ‖v i‖) (Finset.mem_univ j) simp_rw [mem_closedBall_iff_norm'] refine ⟨i, ?_⟩ calc _ = ‖(A i i * v i - μ * v i) * (v i)⁻¹‖ := by congr; field_simp [h_nz]; ring _ = ‖(A i i * v i - ∑ j, A i j * v j) * (v i)⁻¹‖ := by rw [show μ * v i = ∑ x : n, A i x * v x by rw [← Matrix.dotProduct, ← Matrix.mulVec] exact (congrFun (Module.End.mem_eigenspace_iff.mp h_eg) i).symm] _ = ‖(∑ j ∈ Finset.univ.erase i, A i j * v j) * (v i)⁻¹‖ := by rw [Finset.sum_erase_eq_sub (Finset.mem_univ i), ← neg_sub, neg_mul, norm_neg] _ ≤ ∑ j ∈ Finset.univ.erase i, ‖A i j‖ * ‖v j * (v i)⁻¹‖ := by rw [Finset.sum_mul] exact (norm_sum_le _ _).trans (le_of_eq (by simp_rw [mul_assoc, norm_mul])) _ ≤ ∑ j ∈ Finset.univ.erase i, ‖A i j‖ := (Finset.sum_le_sum fun j _ => mul_le_of_le_one_right (norm_nonneg _) (h_le j))
29
import Mathlib.Analysis.SpecialFunctions.Log.Base import Mathlib.MeasureTheory.Measure.MeasureSpaceDef #align_import measure_theory.measure.doubling from "leanprover-community/mathlib"@"5f6e827d81dfbeb6151d7016586ceeb0099b9655" noncomputable section open Set Filter Metric MeasureTheory TopologicalSpace ENNReal NNReal Topology class IsUnifLocDoublingMeasure {α : Type*} [MetricSpace α] [MeasurableSpace α] (μ : Measure α) : Prop where exists_measure_closedBall_le_mul'' : ∃ C : ℝ≥0, ∀ᶠ ε in 𝓝[>] 0, ∀ x, μ (closedBall x (2 * ε)) ≤ C * μ (closedBall x ε) #align is_unif_loc_doubling_measure IsUnifLocDoublingMeasure namespace IsUnifLocDoublingMeasure variable {α : Type*} [MetricSpace α] [MeasurableSpace α] (μ : Measure α) [IsUnifLocDoublingMeasure μ] -- Porting note: added for missing infer kinds theorem exists_measure_closedBall_le_mul : ∃ C : ℝ≥0, ∀ᶠ ε in 𝓝[>] 0, ∀ x, μ (closedBall x (2 * ε)) ≤ C * μ (closedBall x ε) := exists_measure_closedBall_le_mul'' def doublingConstant : ℝ≥0 := Classical.choose <| exists_measure_closedBall_le_mul μ #align is_unif_loc_doubling_measure.doubling_constant IsUnifLocDoublingMeasure.doublingConstant theorem exists_measure_closedBall_le_mul' : ∀ᶠ ε in 𝓝[>] 0, ∀ x, μ (closedBall x (2 * ε)) ≤ doublingConstant μ * μ (closedBall x ε) := Classical.choose_spec <| exists_measure_closedBall_le_mul μ #align is_unif_loc_doubling_measure.exists_measure_closed_ball_le_mul' IsUnifLocDoublingMeasure.exists_measure_closedBall_le_mul'
Mathlib/MeasureTheory/Measure/Doubling.lean
69
99
theorem exists_eventually_forall_measure_closedBall_le_mul (K : ℝ) : ∃ C : ℝ≥0, ∀ᶠ ε in 𝓝[>] 0, ∀ x, ∀ t ≤ K, μ (closedBall x (t * ε)) ≤ C * μ (closedBall x ε) := by
let C := doublingConstant μ have hμ : ∀ n : ℕ, ∀ᶠ ε in 𝓝[>] 0, ∀ x, μ (closedBall x ((2 : ℝ) ^ n * ε)) ≤ ↑(C ^ n) * μ (closedBall x ε) := by intro n induction' n with n ih · simp replace ih := eventually_nhdsWithin_pos_mul_left (two_pos : 0 < (2 : ℝ)) ih refine (ih.and (exists_measure_closedBall_le_mul' μ)).mono fun ε hε x => ?_ calc μ (closedBall x ((2 : ℝ) ^ (n + 1) * ε)) = μ (closedBall x ((2 : ℝ) ^ n * (2 * ε))) := by rw [pow_succ, mul_assoc] _ ≤ ↑(C ^ n) * μ (closedBall x (2 * ε)) := hε.1 x _ ≤ ↑(C ^ n) * (C * μ (closedBall x ε)) := by gcongr; exact hε.2 x _ = ↑(C ^ (n + 1)) * μ (closedBall x ε) := by rw [← mul_assoc, pow_succ, ENNReal.coe_mul] rcases lt_or_le K 1 with (hK | hK) · refine ⟨1, ?_⟩ simp only [ENNReal.coe_one, one_mul] refine eventually_mem_nhdsWithin.mono fun ε hε x t ht ↦ ?_ gcongr nlinarith [mem_Ioi.mp hε] · use C ^ ⌈Real.logb 2 K⌉₊ filter_upwards [hμ ⌈Real.logb 2 K⌉₊, eventually_mem_nhdsWithin] with ε hε hε₀ x t ht refine le_trans ?_ (hε x) gcongr · exact (mem_Ioi.mp hε₀).le · refine ht.trans ?_ rw [← Real.rpow_natCast, ← Real.logb_le_iff_le_rpow] exacts [Nat.le_ceil _, by norm_num, by linarith]
29
import Mathlib.Analysis.Complex.CauchyIntegral import Mathlib.Analysis.NormedSpace.Completion import Mathlib.Analysis.NormedSpace.Extr import Mathlib.Topology.Order.ExtrClosure #align_import analysis.complex.abs_max from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open TopologicalSpace Metric Set Filter Asymptotics Function MeasureTheory AffineMap Bornology open scoped Topology Filter NNReal Real universe u v w variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℂ E] {F : Type v} [NormedAddCommGroup F] [NormedSpace ℂ F] local postfix:100 "̂" => UniformSpace.Completion namespace Complex
Mathlib/Analysis/Complex/AbsMax.lean
106
137
theorem norm_max_aux₁ [CompleteSpace F] {f : ℂ → F} {z w : ℂ} (hd : DiffContOnCl ℂ f (ball z (dist w z))) (hz : IsMaxOn (norm ∘ f) (closedBall z (dist w z)) z) : ‖f w‖ = ‖f z‖ := by
-- Consider a circle of radius `r = dist w z`. set r : ℝ := dist w z have hw : w ∈ closedBall z r := mem_closedBall.2 le_rfl -- Assume the converse. Since `‖f w‖ ≤ ‖f z‖`, we have `‖f w‖ < ‖f z‖`. refine (isMaxOn_iff.1 hz _ hw).antisymm (not_lt.1 ?_) rintro hw_lt : ‖f w‖ < ‖f z‖ have hr : 0 < r := dist_pos.2 (ne_of_apply_ne (norm ∘ f) hw_lt.ne) -- Due to Cauchy integral formula, it suffices to prove the following inequality. suffices ‖∮ ζ in C(z, r), (ζ - z)⁻¹ • f ζ‖ < 2 * π * ‖f z‖ by refine this.ne ?_ have A : (∮ ζ in C(z, r), (ζ - z)⁻¹ • f ζ) = (2 * π * I : ℂ) • f z := hd.circleIntegral_sub_inv_smul (mem_ball_self hr) simp [A, norm_smul, Real.pi_pos.le] suffices ‖∮ ζ in C(z, r), (ζ - z)⁻¹ • f ζ‖ < 2 * π * r * (‖f z‖ / r) by rwa [mul_assoc, mul_div_cancel₀ _ hr.ne'] at this /- This inequality is true because `‖(ζ - z)⁻¹ • f ζ‖ ≤ ‖f z‖ / r` for all `ζ` on the circle and this inequality is strict at `ζ = w`. -/ have hsub : sphere z r ⊆ closedBall z r := sphere_subset_closedBall refine circleIntegral.norm_integral_lt_of_norm_le_const_of_lt hr ?_ ?_ ⟨w, rfl, ?_⟩ · show ContinuousOn (fun ζ : ℂ => (ζ - z)⁻¹ • f ζ) (sphere z r) refine ((continuousOn_id.sub continuousOn_const).inv₀ ?_).smul (hd.continuousOn_ball.mono hsub) exact fun ζ hζ => sub_ne_zero.2 (ne_of_mem_sphere hζ hr.ne') · show ∀ ζ ∈ sphere z r, ‖(ζ - z)⁻¹ • f ζ‖ ≤ ‖f z‖ / r rintro ζ (hζ : abs (ζ - z) = r) rw [le_div_iff hr, norm_smul, norm_inv, norm_eq_abs, hζ, mul_comm, mul_inv_cancel_left₀ hr.ne'] exact hz (hsub hζ) show ‖(w - z)⁻¹ • f w‖ < ‖f z‖ / r rw [norm_smul, norm_inv, norm_eq_abs, ← div_eq_inv_mul] exact (div_lt_div_right hr).2 hw_lt
29
import Mathlib.RingTheory.Polynomial.Cyclotomic.Eval #align_import number_theory.primes_congruent_one from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" namespace Nat open Polynomial Nat Filter open scoped Nat
Mathlib/NumberTheory/PrimesCongruentOne.lean
26
57
theorem exists_prime_gt_modEq_one {k : ℕ} (n : ℕ) (hk0 : k ≠ 0) : ∃ p : ℕ, Nat.Prime p ∧ n < p ∧ p ≡ 1 [MOD k] := by
rcases (one_le_iff_ne_zero.2 hk0).eq_or_lt with (rfl | hk1) · rcases exists_infinite_primes (n + 1) with ⟨p, hnp, hp⟩ exact ⟨p, hp, hnp, modEq_one⟩ let b := k * (n !) have hgt : 1 < (eval (↑b) (cyclotomic k ℤ)).natAbs := by rcases le_iff_exists_add'.1 hk1.le with ⟨k, rfl⟩ have hb : 2 ≤ b := le_mul_of_le_of_one_le hk1 n.factorial_pos calc 1 ≤ b - 1 := le_tsub_of_add_le_left hb _ < (eval (b : ℤ) (cyclotomic (k + 1) ℤ)).natAbs := sub_one_lt_natAbs_cyclotomic_eval hk1 (succ_le_iff.1 hb).ne' let p := minFac (eval (↑b) (cyclotomic k ℤ)).natAbs haveI hprime : Fact p.Prime := ⟨minFac_prime (ne_of_lt hgt).symm⟩ have hroot : IsRoot (cyclotomic k (ZMod p)) (castRingHom (ZMod p) b) := by have : ((b : ℤ) : ZMod p) = ↑(Int.castRingHom (ZMod p) b) := by simp rw [IsRoot.def, ← map_cyclotomic_int k (ZMod p), eval_map, coe_castRingHom, ← Int.cast_natCast, this, eval₂_hom, Int.coe_castRingHom, ZMod.intCast_zmod_eq_zero_iff_dvd] apply Int.dvd_natAbs.1 exact mod_cast minFac_dvd (eval (↑b) (cyclotomic k ℤ)).natAbs have hpb : ¬p ∣ b := hprime.1.coprime_iff_not_dvd.1 (coprime_of_root_cyclotomic hk0.bot_lt hroot).symm refine ⟨p, hprime.1, not_le.1 fun habs => ?_, ?_⟩ · exact hpb (dvd_mul_of_dvd_right (dvd_factorial (minFac_pos _) habs) _) · have hdiv : orderOf (b : ZMod p) ∣ p - 1 := ZMod.orderOf_dvd_card_sub_one (mt (CharP.cast_eq_zero_iff _ _ _).1 hpb) haveI : NeZero (k : ZMod p) := NeZero.of_not_dvd (ZMod p) fun hpk => hpb (dvd_mul_of_dvd_left hpk _) have : k = orderOf (b : ZMod p) := (isRoot_cyclotomic_iff.mp hroot).eq_orderOf rw [← this] at hdiv exact ((modEq_iff_dvd' hprime.1.pos).2 hdiv).symm
30
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Bounds #align_import data.real.pi.bounds from "leanprover-community/mathlib"@"402f8982dddc1864bd703da2d6e2ee304a866973" -- Porting note: needed to add a lot of type ascriptions for lean to interpret numbers as reals. open scoped Real namespace Real theorem pi_gt_sqrtTwoAddSeries (n : ℕ) : (2 : ℝ) ^ (n + 1) * √(2 - sqrtTwoAddSeries 0 n) < π := by have : √(2 - sqrtTwoAddSeries 0 n) / (2 : ℝ) * (2 : ℝ) ^ (n + 2) < π := by rw [← lt_div_iff, ← sin_pi_over_two_pow_succ] focus apply sin_lt apply div_pos pi_pos all_goals apply pow_pos; norm_num apply lt_of_le_of_lt (le_of_eq _) this rw [pow_succ' _ (n + 1), ← mul_assoc, div_mul_cancel₀, mul_comm]; norm_num #align real.pi_gt_sqrt_two_add_series Real.pi_gt_sqrtTwoAddSeries
Mathlib/Data/Real/Pi/Bounds.lean
40
71
theorem pi_lt_sqrtTwoAddSeries (n : ℕ) : π < (2 : ℝ) ^ (n + 1) * √(2 - sqrtTwoAddSeries 0 n) + 1 / (4 : ℝ) ^ n := by
have : π < (√(2 - sqrtTwoAddSeries 0 n) / (2 : ℝ) + (1 : ℝ) / ((2 : ℝ) ^ n) ^ 3 / 4) * (2 : ℝ) ^ (n + 2) := by rw [← div_lt_iff (by norm_num), ← sin_pi_over_two_pow_succ] refine lt_of_lt_of_le (lt_add_of_sub_right_lt (sin_gt_sub_cube ?_ ?_)) ?_ · apply div_pos pi_pos; apply pow_pos; norm_num · rw [div_le_iff'] · refine le_trans pi_le_four ?_ simp only [show (4 : ℝ) = (2 : ℝ) ^ 2 by norm_num, mul_one] apply pow_le_pow_right (by norm_num) apply le_add_of_nonneg_left; apply Nat.zero_le · apply pow_pos; norm_num apply add_le_add_left; rw [div_le_div_right (by norm_num)] rw [le_div_iff (by norm_num), ← mul_pow] refine le_trans ?_ (le_of_eq (one_pow 3)); apply pow_le_pow_left · apply le_of_lt; apply mul_pos · apply div_pos pi_pos; apply pow_pos; norm_num · apply pow_pos; norm_num · rw [← le_div_iff (by norm_num)] refine le_trans ((div_le_div_right ?_).mpr pi_le_four) ?_ · apply pow_pos; norm_num · simp only [pow_succ', ← div_div, one_div] -- Porting note: removed `convert le_rfl` norm_num apply lt_of_lt_of_le this (le_of_eq _); rw [add_mul]; congr 1 · ring simp only [show (4 : ℝ) = 2 ^ 2 by norm_num, ← pow_mul, div_div, ← pow_add] rw [one_div, one_div, inv_mul_eq_iff_eq_mul₀, eq_comm, mul_inv_eq_iff_eq_mul₀, ← pow_add] · rw [add_assoc, Nat.mul_succ, add_comm, add_comm n, add_assoc, mul_comm n] all_goals norm_num
30
import Mathlib.Computability.Encoding import Mathlib.Logic.Small.List import Mathlib.ModelTheory.Syntax import Mathlib.SetTheory.Cardinal.Ordinal #align_import model_theory.encoding from "leanprover-community/mathlib"@"91288e351d51b3f0748f0a38faa7613fb0ae2ada" universe u v w u' v' namespace FirstOrder namespace Language variable {L : Language.{u, v}} variable {M : Type w} {N P : Type*} [L.Structure M] [L.Structure N] [L.Structure P] variable {α : Type u'} {β : Type v'} open FirstOrder Cardinal open Computability List Structure Cardinal Fin namespace Term def listEncode : L.Term α → List (Sum α (Σi, L.Functions i)) | var i => [Sum.inl i] | func f ts => Sum.inr (⟨_, f⟩ : Σi, L.Functions i)::(List.finRange _).bind fun i => (ts i).listEncode #align first_order.language.term.list_encode FirstOrder.Language.Term.listEncode def listDecode : List (Sum α (Σi, L.Functions i)) → List (Option (L.Term α)) | [] => [] | Sum.inl a::l => some (var a)::listDecode l | Sum.inr ⟨n, f⟩::l => if h : ∀ i : Fin n, ((listDecode l).get? i).join.isSome then (func f fun i => Option.get _ (h i))::(listDecode l).drop n else [none] #align first_order.language.term.list_decode FirstOrder.Language.Term.listDecode
Mathlib/ModelTheory/Encoding.lean
67
98
theorem listDecode_encode_list (l : List (L.Term α)) : listDecode (l.bind listEncode) = l.map Option.some := by
suffices h : ∀ (t : L.Term α) (l : List (Sum α (Σi, L.Functions i))), listDecode (t.listEncode ++ l) = some t::listDecode l by induction' l with t l lih · rfl · rw [cons_bind, h t (l.bind listEncode), lih, List.map] intro t induction' t with a n f ts ih <;> intro l · rw [listEncode, singleton_append, listDecode] · rw [listEncode, cons_append, listDecode] have h : listDecode (((finRange n).bind fun i : Fin n => (ts i).listEncode) ++ l) = (finRange n).map (Option.some ∘ ts) ++ listDecode l := by induction' finRange n with i l' l'ih · rfl · rw [cons_bind, List.append_assoc, ih, map_cons, l'ih, cons_append, Function.comp] have h' : ∀ i : Fin n, (listDecode (((finRange n).bind fun i : Fin n => (ts i).listEncode) ++ l)).get? ↑i = some (some (ts i)) := by intro i rw [h, get?_append, get?_map] · simp only [Option.map_eq_some', Function.comp_apply, get?_eq_some] refine ⟨i, ⟨lt_of_lt_of_le i.2 (ge_of_eq (length_finRange _)), ?_⟩, rfl⟩ rw [get_finRange, Fin.eta] · refine lt_of_lt_of_le i.2 ?_ simp refine (dif_pos fun i => Option.isSome_iff_exists.2 ⟨ts i, ?_⟩).trans ?_ · rw [Option.join_eq_some, h'] refine congr (congr rfl (congr rfl (congr rfl (funext fun i => Option.get_of_mem _ ?_)))) ?_ · simp [h'] · rw [h, drop_left'] rw [length_map, length_finRange]
30
import Mathlib.Data.Real.Pi.Bounds import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.ConvexBody -- TODO. Rewrite some of the FLT results on the disciminant using the definitions and results of -- this file namespace NumberField open FiniteDimensional NumberField NumberField.InfinitePlace Matrix open scoped Classical Real nonZeroDivisors variable (K : Type*) [Field K] [NumberField K] noncomputable abbrev discr : ℤ := Algebra.discr ℤ (RingOfIntegers.basis K) theorem coe_discr : (discr K : ℚ) = Algebra.discr ℚ (integralBasis K) := (Algebra.discr_localizationLocalization ℤ _ K (RingOfIntegers.basis K)).symm theorem discr_ne_zero : discr K ≠ 0 := by rw [← (Int.cast_injective (α := ℚ)).ne_iff, coe_discr] exact Algebra.discr_not_zero_of_basis ℚ (integralBasis K) theorem discr_eq_discr {ι : Type*} [Fintype ι] [DecidableEq ι] (b : Basis ι ℤ (𝓞 K)) : Algebra.discr ℤ b = discr K := by let b₀ := Basis.reindex (RingOfIntegers.basis K) (Basis.indexEquiv (RingOfIntegers.basis K) b) rw [Algebra.discr_eq_discr (𝓞 K) b b₀, Basis.coe_reindex, Algebra.discr_reindex] theorem discr_eq_discr_of_algEquiv {L : Type*} [Field L] [NumberField L] (f : K ≃ₐ[ℚ] L) : discr K = discr L := by let f₀ : 𝓞 K ≃ₗ[ℤ] 𝓞 L := (f.restrictScalars ℤ).mapIntegralClosure.toLinearEquiv rw [← Rat.intCast_inj, coe_discr, Algebra.discr_eq_discr_of_algEquiv (integralBasis K) f, ← discr_eq_discr L ((RingOfIntegers.basis K).map f₀)] change _ = algebraMap ℤ ℚ _ rw [← Algebra.discr_localizationLocalization ℤ (nonZeroDivisors ℤ) L] congr ext simp only [Function.comp_apply, integralBasis_apply, Basis.localizationLocalization_apply, Basis.map_apply] rfl open MeasureTheory MeasureTheory.Measure Zspan NumberField.mixedEmbedding NumberField.InfinitePlace ENNReal NNReal Complex
Mathlib/NumberTheory/NumberField/Discriminant.lean
71
103
theorem _root_.NumberField.mixedEmbedding.volume_fundamentalDomain_latticeBasis : volume (fundamentalDomain (latticeBasis K)) = (2 : ℝ≥0∞)⁻¹ ^ NrComplexPlaces K * sqrt ‖discr K‖₊ := by
let f : Module.Free.ChooseBasisIndex ℤ (𝓞 K) ≃ (K →+* ℂ) := (canonicalEmbedding.latticeBasis K).indexEquiv (Pi.basisFun ℂ _) let e : (index K) ≃ Module.Free.ChooseBasisIndex ℤ (𝓞 K) := (indexEquiv K).trans f.symm let M := (mixedEmbedding.stdBasis K).toMatrix ((latticeBasis K).reindex e.symm) let N := Algebra.embeddingsMatrixReindex ℚ ℂ (integralBasis K ∘ f.symm) RingHom.equivRatAlgHom suffices M.map Complex.ofReal = (matrixToStdBasis K) * (Matrix.reindex (indexEquiv K).symm (indexEquiv K).symm N).transpose by calc volume (fundamentalDomain (latticeBasis K)) _ = ‖((mixedEmbedding.stdBasis K).toMatrix ((latticeBasis K).reindex e.symm)).det‖₊ := by rw [← fundamentalDomain_reindex _ e.symm, ← norm_toNNReal, measure_fundamentalDomain ((latticeBasis K).reindex e.symm), volume_fundamentalDomain_stdBasis, mul_one] rfl _ = ‖(matrixToStdBasis K).det * N.det‖₊ := by rw [← nnnorm_real, ← ofReal_eq_coe, RingHom.map_det, RingHom.mapMatrix_apply, this, det_mul, det_transpose, det_reindex_self] _ = (2 : ℝ≥0∞)⁻¹ ^ Fintype.card {w : InfinitePlace K // IsComplex w} * sqrt ‖N.det ^ 2‖₊ := by have : ‖Complex.I‖₊ = 1 := by rw [← norm_toNNReal, norm_eq_abs, abs_I, Real.toNNReal_one] rw [det_matrixToStdBasis, nnnorm_mul, nnnorm_pow, nnnorm_mul, this, mul_one, nnnorm_inv, coe_mul, ENNReal.coe_pow, ← norm_toNNReal, RCLike.norm_two, Real.toNNReal_ofNat, coe_inv two_ne_zero, coe_ofNat, nnnorm_pow, NNReal.sqrt_sq] _ = (2 : ℝ≥0∞)⁻¹ ^ Fintype.card { w // IsComplex w } * NNReal.sqrt ‖discr K‖₊ := by rw [← Algebra.discr_eq_det_embeddingsMatrixReindex_pow_two, Algebra.discr_reindex, ← coe_discr, map_intCast, ← Complex.nnnorm_int] ext : 2 dsimp only [M] rw [Matrix.map_apply, Basis.toMatrix_apply, Basis.coe_reindex, Function.comp_apply, Equiv.symm_symm, latticeBasis_apply, ← commMap_canonical_eq_mixed, Complex.ofReal_eq_coe, stdBasis_repr_eq_matrixToStdBasis_mul K _ (fun _ => rfl)] rfl
30
import Mathlib.Analysis.InnerProductSpace.Basic import Mathlib.Analysis.NormedSpace.Dual import Mathlib.MeasureTheory.Function.StronglyMeasurable.Lp import Mathlib.MeasureTheory.Integral.SetIntegral #align_import measure_theory.function.ae_eq_of_integral from "leanprover-community/mathlib"@"915591b2bb3ea303648db07284a161a7f2a9e3d4" open MeasureTheory TopologicalSpace NormedSpace Filter open scoped ENNReal NNReal MeasureTheory Topology namespace MeasureTheory variable {α E : Type*} {m m0 : MeasurableSpace α} {μ : Measure α} {s t : Set α} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] {p : ℝ≥0∞} section AeEqOfForallSetIntegralEq
Mathlib/MeasureTheory/Function/AEEqOfIntegral.lean
125
157
theorem ae_const_le_iff_forall_lt_measure_zero {β} [LinearOrder β] [TopologicalSpace β] [OrderTopology β] [FirstCountableTopology β] (f : α → β) (c : β) : (∀ᵐ x ∂μ, c ≤ f x) ↔ ∀ b < c, μ {x | f x ≤ b} = 0 := by
rw [ae_iff] push_neg constructor · intro h b hb exact measure_mono_null (fun y hy => (lt_of_le_of_lt hy hb : _)) h intro hc by_cases h : ∀ b, c ≤ b · have : {a : α | f a < c} = ∅ := by apply Set.eq_empty_iff_forall_not_mem.2 fun x hx => ?_ exact (lt_irrefl _ (lt_of_lt_of_le hx (h (f x)))).elim simp [this] by_cases H : ¬IsLUB (Set.Iio c) c · have : c ∈ upperBounds (Set.Iio c) := fun y hy => le_of_lt hy obtain ⟨b, b_up, bc⟩ : ∃ b : β, b ∈ upperBounds (Set.Iio c) ∧ b < c := by simpa [IsLUB, IsLeast, this, lowerBounds] using H exact measure_mono_null (fun x hx => b_up hx) (hc b bc) push_neg at H h obtain ⟨u, _, u_lt, u_lim, -⟩ : ∃ u : ℕ → β, StrictMono u ∧ (∀ n : ℕ, u n < c) ∧ Tendsto u atTop (𝓝 c) ∧ ∀ n : ℕ, u n ∈ Set.Iio c := H.exists_seq_strictMono_tendsto_of_not_mem (lt_irrefl c) h have h_Union : {x | f x < c} = ⋃ n : ℕ, {x | f x ≤ u n} := by ext1 x simp_rw [Set.mem_iUnion, Set.mem_setOf_eq] constructor <;> intro h · obtain ⟨n, hn⟩ := ((tendsto_order.1 u_lim).1 _ h).exists; exact ⟨n, hn.le⟩ · obtain ⟨n, hn⟩ := h; exact hn.trans_lt (u_lt _) rw [h_Union, measure_iUnion_null_iff] intro n exact hc _ (u_lt n)
30
import Mathlib.MeasureTheory.Function.ConditionalExpectation.Indicator import Mathlib.MeasureTheory.Function.UniformIntegrable import Mathlib.MeasureTheory.Decomposition.RadonNikodym #align_import measure_theory.function.conditional_expectation.real from "leanprover-community/mathlib"@"b2ff9a3d7a15fd5b0f060b135421d6a89a999c2f" noncomputable section open TopologicalSpace MeasureTheory.Lp Filter ContinuousLinearMap open scoped NNReal ENNReal Topology MeasureTheory namespace MeasureTheory variable {α : Type*} {m m0 : MeasurableSpace α} {μ : Measure α} theorem rnDeriv_ae_eq_condexp {hm : m ≤ m0} [hμm : SigmaFinite (μ.trim hm)] {f : α → ℝ} (hf : Integrable f μ) : SignedMeasure.rnDeriv ((μ.withDensityᵥ f).trim hm) (μ.trim hm) =ᵐ[μ] μ[f|m] := by refine ae_eq_condexp_of_forall_setIntegral_eq hm hf ?_ ?_ ?_ · exact fun _ _ _ => (integrable_of_integrable_trim hm (SignedMeasure.integrable_rnDeriv ((μ.withDensityᵥ f).trim hm) (μ.trim hm))).integrableOn · intro s hs _ conv_rhs => rw [← hf.withDensityᵥ_trim_eq_integral hm hs, ← SignedMeasure.withDensityᵥ_rnDeriv_eq ((μ.withDensityᵥ f).trim hm) (μ.trim hm) (hf.withDensityᵥ_trim_absolutelyContinuous hm)] rw [withDensityᵥ_apply (SignedMeasure.integrable_rnDeriv ((μ.withDensityᵥ f).trim hm) (μ.trim hm)) hs, ← setIntegral_trim hm _ hs] exact (SignedMeasure.measurable_rnDeriv _ _).stronglyMeasurable · exact (SignedMeasure.measurable_rnDeriv _ _).stronglyMeasurable.aeStronglyMeasurable' #align measure_theory.rn_deriv_ae_eq_condexp MeasureTheory.rnDeriv_ae_eq_condexp -- TODO: the following couple of lemmas should be generalized and proved using Jensen's inequality -- for the conditional expectation (not in mathlib yet) .
Mathlib/MeasureTheory/Function/ConditionalExpectation/Real.lean
59
89
theorem snorm_one_condexp_le_snorm (f : α → ℝ) : snorm (μ[f|m]) 1 μ ≤ snorm f 1 μ := by
by_cases hf : Integrable f μ swap; · rw [condexp_undef hf, snorm_zero]; exact zero_le _ by_cases hm : m ≤ m0 swap; · rw [condexp_of_not_le hm, snorm_zero]; exact zero_le _ by_cases hsig : SigmaFinite (μ.trim hm) swap; · rw [condexp_of_not_sigmaFinite hm hsig, snorm_zero]; exact zero_le _ calc snorm (μ[f|m]) 1 μ ≤ snorm (μ[(|f|)|m]) 1 μ := by refine snorm_mono_ae ?_ filter_upwards [condexp_mono hf hf.abs (ae_of_all μ (fun x => le_abs_self (f x) : ∀ x, f x ≤ |f x|)), EventuallyLE.trans (condexp_neg f).symm.le (condexp_mono hf.neg hf.abs (ae_of_all μ (fun x => neg_le_abs (f x): ∀ x, -f x ≤ |f x|)))] with x hx₁ hx₂ exact abs_le_abs hx₁ hx₂ _ = snorm f 1 μ := by rw [snorm_one_eq_lintegral_nnnorm, snorm_one_eq_lintegral_nnnorm, ← ENNReal.toReal_eq_toReal (ne_of_lt integrable_condexp.2) (ne_of_lt hf.2), ← integral_norm_eq_lintegral_nnnorm (stronglyMeasurable_condexp.mono hm).aestronglyMeasurable, ← integral_norm_eq_lintegral_nnnorm hf.1] simp_rw [Real.norm_eq_abs] rw [← integral_condexp hm hf.abs] refine integral_congr_ae ?_ have : 0 ≤ᵐ[μ] μ[(|f|)|m] := by rw [← condexp_zero] exact condexp_mono (integrable_zero _ _ _) hf.abs (ae_of_all μ (fun x => abs_nonneg (f x) : ∀ x, 0 ≤ |f x|)) filter_upwards [this] with x hx exact abs_eq_self.2 hx
30
import Mathlib.Data.List.Cycle import Mathlib.GroupTheory.Perm.Cycle.Type import Mathlib.GroupTheory.Perm.List #align_import group_theory.perm.cycle.concrete from "leanprover-community/mathlib"@"00638177efd1b2534fc5269363ebf42a7871df9a" open Equiv Equiv.Perm List variable {α : Type*} namespace Equiv.Perm section Fintype variable [Fintype α] [DecidableEq α] (p : Equiv.Perm α) (x : α) def toList : List α := (List.range (cycleOf p x).support.card).map fun k => (p ^ k) x #align equiv.perm.to_list Equiv.Perm.toList @[simp] theorem toList_one : toList (1 : Perm α) x = [] := by simp [toList, cycleOf_one] #align equiv.perm.to_list_one Equiv.Perm.toList_one @[simp] theorem toList_eq_nil_iff {p : Perm α} {x} : toList p x = [] ↔ x ∉ p.support := by simp [toList] #align equiv.perm.to_list_eq_nil_iff Equiv.Perm.toList_eq_nil_iff @[simp] theorem length_toList : length (toList p x) = (cycleOf p x).support.card := by simp [toList] #align equiv.perm.length_to_list Equiv.Perm.length_toList theorem toList_ne_singleton (y : α) : toList p x ≠ [y] := by intro H simpa [card_support_ne_one] using congr_arg length H #align equiv.perm.to_list_ne_singleton Equiv.Perm.toList_ne_singleton theorem two_le_length_toList_iff_mem_support {p : Perm α} {x : α} : 2 ≤ length (toList p x) ↔ x ∈ p.support := by simp #align equiv.perm.two_le_length_to_list_iff_mem_support Equiv.Perm.two_le_length_toList_iff_mem_support theorem length_toList_pos_of_mem_support (h : x ∈ p.support) : 0 < length (toList p x) := zero_lt_two.trans_le (two_le_length_toList_iff_mem_support.mpr h) #align equiv.perm.length_to_list_pos_of_mem_support Equiv.Perm.length_toList_pos_of_mem_support theorem get_toList (n : ℕ) (hn : n < length (toList p x)) : (toList p x).get ⟨n, hn⟩ = (p ^ n) x := by simp [toList] theorem toList_get_zero (h : x ∈ p.support) : (toList p x).get ⟨0, (length_toList_pos_of_mem_support _ _ h)⟩ = x := by simp [toList] set_option linter.deprecated false in @[deprecated get_toList (since := "2024-05-08")] theorem nthLe_toList (n : ℕ) (hn : n < length (toList p x)) : (toList p x).nthLe n hn = (p ^ n) x := by simp [toList] #align equiv.perm.nth_le_to_list Equiv.Perm.nthLe_toList set_option linter.deprecated false in @[deprecated toList_get_zero (since := "2024-05-08")] theorem toList_nthLe_zero (h : x ∈ p.support) : (toList p x).nthLe 0 (length_toList_pos_of_mem_support _ _ h) = x := by simp [toList] #align equiv.perm.to_list_nth_le_zero Equiv.Perm.toList_nthLe_zero variable {p} {x} theorem mem_toList_iff {y : α} : y ∈ toList p x ↔ SameCycle p x y ∧ x ∈ p.support := by simp only [toList, mem_range, mem_map] constructor · rintro ⟨n, hx, rfl⟩ refine ⟨⟨n, rfl⟩, ?_⟩ contrapose! hx rw [← support_cycleOf_eq_nil_iff] at hx simp [hx] · rintro ⟨h, hx⟩ simpa using h.exists_pow_eq_of_mem_support hx #align equiv.perm.mem_to_list_iff Equiv.Perm.mem_toList_iff set_option linter.deprecated false in
Mathlib/GroupTheory/Perm/Cycle/Concrete.lean
278
308
theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by
by_cases hx : p x = x · rw [← not_mem_support, ← toList_eq_nil_iff] at hx simp [hx] have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx rw [nodup_iff_nthLe_inj] rintro n m hn hm rw [length_toList, ← hc.orderOf] at hm hn rw [← cycleOf_apply_self, ← Ne, ← mem_support] at hx rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ← cycleOf_pow_apply_self p x m] cases' n with n <;> cases' m with m · simp · rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support, cycleOf_pow_apply_self] at hx simp [hx.symm] · rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support, cycleOf_pow_apply_self] at hx simp [hx] intro h have hn' : ¬orderOf (p.cycleOf x) ∣ n.succ := Nat.not_dvd_of_pos_of_lt n.zero_lt_succ hn have hm' : ¬orderOf (p.cycleOf x) ∣ m.succ := Nat.not_dvd_of_pos_of_lt m.zero_lt_succ hm rw [← hc.support_pow_eq_iff] at hn' hm' rw [← Nat.mod_eq_of_lt hn, ← Nat.mod_eq_of_lt hm, ← pow_inj_mod] refine support_congr ?_ ?_ · rw [hm', hn'] · rw [hm'] intro y hy obtain ⟨k, rfl⟩ := hc.exists_pow_eq (mem_support.mp hx) (mem_support.mp hy) rw [← mul_apply, (Commute.pow_pow_self _ _ _).eq, mul_apply, h, ← mul_apply, ← mul_apply, (Commute.pow_pow_self _ _ _).eq]
30
import Mathlib.Probability.Martingale.BorelCantelli import Mathlib.Probability.ConditionalExpectation import Mathlib.Probability.Independence.Basic #align_import probability.borel_cantelli from "leanprover-community/mathlib"@"2f8347015b12b0864dfaf366ec4909eb70c78740" open scoped MeasureTheory ProbabilityTheory ENNReal Topology open MeasureTheory ProbabilityTheory MeasurableSpace TopologicalSpace namespace ProbabilityTheory variable {Ω : Type*} {m0 : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ] section BorelCantelli variable {ι β : Type*} [LinearOrder ι] [mβ : MeasurableSpace β] [NormedAddCommGroup β] [BorelSpace β] {f : ι → Ω → β} {i j : ι} {s : ι → Set Ω} theorem iIndepFun.indep_comap_natural_of_lt (hf : ∀ i, StronglyMeasurable (f i)) (hfi : iIndepFun (fun _ => mβ) f μ) (hij : i < j) : Indep (MeasurableSpace.comap (f j) mβ) (Filtration.natural f hf i) μ := by suffices Indep (⨆ k ∈ ({j} : Set ι), MeasurableSpace.comap (f k) mβ) (⨆ k ∈ {k | k ≤ i}, MeasurableSpace.comap (f k) mβ) μ by rwa [iSup_singleton] at this exact indep_iSup_of_disjoint (fun k => (hf k).measurable.comap_le) hfi (by simpa) set_option linter.uppercaseLean3 false in #align probability_theory.Indep_fun.indep_comap_natural_of_lt ProbabilityTheory.iIndepFun.indep_comap_natural_of_lt theorem iIndepFun.condexp_natural_ae_eq_of_lt [SecondCountableTopology β] [CompleteSpace β] [NormedSpace ℝ β] (hf : ∀ i, StronglyMeasurable (f i)) (hfi : iIndepFun (fun _ => mβ) f μ) (hij : i < j) : μ[f j|Filtration.natural f hf i] =ᵐ[μ] fun _ => μ[f j] := condexp_indep_eq (hf j).measurable.comap_le (Filtration.le _ _) (comap_measurable <| f j).stronglyMeasurable (hfi.indep_comap_natural_of_lt hf hij) set_option linter.uppercaseLean3 false in #align probability_theory.Indep_fun.condexp_natural_ae_eq_of_lt ProbabilityTheory.iIndepFun.condexp_natural_ae_eq_of_lt theorem iIndepSet.condexp_indicator_filtrationOfSet_ae_eq (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (hij : i < j) : μ[(s j).indicator (fun _ => 1 : Ω → ℝ)|filtrationOfSet hsm i] =ᵐ[μ] fun _ => (μ (s j)).toReal := by rw [Filtration.filtrationOfSet_eq_natural (β := ℝ) hsm] refine (iIndepFun.condexp_natural_ae_eq_of_lt _ hs.iIndepFun_indicator hij).trans ?_ simp only [integral_indicator_const _ (hsm _), Algebra.id.smul_eq_mul, mul_one]; rfl set_option linter.uppercaseLean3 false in #align probability_theory.Indep_set.condexp_indicator_filtration_of_set_ae_eq ProbabilityTheory.iIndepSet.condexp_indicator_filtrationOfSet_ae_eq open Filter
Mathlib/Probability/BorelCantelli.lean
74
105
theorem measure_limsup_eq_one {s : ℕ → Set Ω} (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s μ) (hs' : (∑' n, μ (s n)) = ∞) : μ (limsup s atTop) = 1 := by
rw [measure_congr (eventuallyEq_set.2 (ae_mem_limsup_atTop_iff μ <| measurableSet_filtrationOfSet' hsm) : (limsup s atTop : Set Ω) =ᵐ[μ] {ω | Tendsto (fun n => ∑ k ∈ Finset.range n, (μ[(s (k + 1)).indicator (1 : Ω → ℝ)|filtrationOfSet hsm k]) ω) atTop atTop})] suffices {ω | Tendsto (fun n => ∑ k ∈ Finset.range n, (μ[(s (k + 1)).indicator (1 : Ω → ℝ)|filtrationOfSet hsm k]) ω) atTop atTop} =ᵐ[μ] Set.univ by rw [measure_congr this, measure_univ] have : ∀ᵐ ω ∂μ, ∀ n, (μ[(s (n + 1)).indicator (1 : Ω → ℝ)|filtrationOfSet hsm n]) ω = _ := ae_all_iff.2 fun n => hs.condexp_indicator_filtrationOfSet_ae_eq hsm n.lt_succ_self filter_upwards [this] with ω hω refine eq_true (?_ : Tendsto _ _ _) simp_rw [hω] have htends : Tendsto (fun n => ∑ k ∈ Finset.range n, μ (s (k + 1))) atTop (𝓝 ∞) := by rw [← ENNReal.tsum_add_one_eq_top hs' (measure_ne_top _ _)] exact ENNReal.tendsto_nat_tsum _ rw [ENNReal.tendsto_nhds_top_iff_nnreal] at htends refine tendsto_atTop_atTop_of_monotone' ?_ ?_ · refine monotone_nat_of_le_succ fun n => ?_ rw [← sub_nonneg, Finset.sum_range_succ_sub_sum] exact ENNReal.toReal_nonneg · rintro ⟨B, hB⟩ refine not_eventually.2 (frequently_of_forall fun n => ?_) (htends B.toNNReal) rw [mem_upperBounds] at hB specialize hB (∑ k ∈ Finset.range n, μ (s (k + 1))).toReal _ · refine ⟨n, ?_⟩ rw [ENNReal.toReal_sum] exact fun _ _ => measure_ne_top _ _ · rw [not_lt, ← ENNReal.toReal_le_toReal (ENNReal.sum_lt_top _).ne ENNReal.coe_ne_top] · exact hB.trans (by simp) · exact fun _ _ => measure_ne_top _ _
30
import Mathlib.CategoryTheory.Limits.Shapes.Terminal import Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts #align_import category_theory.limits.shapes.strict_initial from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe v u namespace CategoryTheory namespace Limits open Category variable (C : Type u) [Category.{v} C] section StrictTerminal class HasStrictTerminalObjects : Prop where out : ∀ {I A : C} (f : I ⟶ A), IsTerminal I → IsIso f #align category_theory.limits.has_strict_terminal_objects CategoryTheory.Limits.HasStrictTerminalObjects variable {C} section variable [HasStrictTerminalObjects C] {I : C} theorem IsTerminal.isIso_from (hI : IsTerminal I) {A : C} (f : I ⟶ A) : IsIso f := HasStrictTerminalObjects.out f hI #align category_theory.limits.is_terminal.is_iso_from CategoryTheory.Limits.IsTerminal.isIso_from theorem IsTerminal.strict_hom_ext (hI : IsTerminal I) {A : C} (f g : I ⟶ A) : f = g := by haveI := hI.isIso_from f haveI := hI.isIso_from g exact eq_of_inv_eq_inv (hI.hom_ext (inv f) (inv g)) #align category_theory.limits.is_terminal.strict_hom_ext CategoryTheory.Limits.IsTerminal.strict_hom_ext theorem IsTerminal.subsingleton_to (hI : IsTerminal I) {A : C} : Subsingleton (I ⟶ A) := ⟨hI.strict_hom_ext⟩ #align category_theory.limits.is_terminal.subsingleton_to CategoryTheory.Limits.IsTerminal.subsingleton_to variable {J : Type v} [SmallCategory J]
Mathlib/CategoryTheory/Limits/Shapes/StrictInitial.lean
206
237
theorem limit_π_isIso_of_is_strict_terminal (F : J ⥤ C) [HasLimit F] (i : J) (H : ∀ (j) (_ : j ≠ i), IsTerminal (F.obj j)) [Subsingleton (i ⟶ i)] : IsIso (limit.π F i) := by
classical refine ⟨⟨limit.lift _ ⟨_, ⟨?_, ?_⟩⟩, ?_, ?_⟩⟩ · exact fun j => dite (j = i) (fun h => eqToHom (by cases h; rfl)) fun h => (H _ h).from _ · intro j k f split_ifs with h h_1 h_1 · cases h cases h_1 obtain rfl : f = 𝟙 _ := Subsingleton.elim _ _ simp · cases h erw [Category.comp_id] haveI : IsIso (F.map f) := (H _ h_1).isIso_from _ rw [← IsIso.comp_inv_eq] apply (H _ h_1).hom_ext · cases h_1 apply (H _ h).hom_ext · apply (H _ h).hom_ext · ext rw [assoc, limit.lift_π] dsimp only split_ifs with h · cases h rw [id_comp, eqToHom_refl] exact comp_id _ · apply (H _ h).hom_ext · rw [limit.lift_π] simp
30
import Mathlib.Algebra.MvPolynomial.Basic import Mathlib.Data.Fintype.Card import Mathlib.RingTheory.Algebraic #align_import field_theory.ax_grothendieck from "leanprover-community/mathlib"@"4e529b03dd62b7b7d13806c3fb974d9d4848910e" noncomputable section open MvPolynomial Finset Function
Mathlib/FieldTheory/AxGrothendieck.lean
33
66
theorem ax_grothendieck_of_locally_finite {ι K R : Type*} [Field K] [Finite K] [CommRing R] [Finite ι] [Algebra K R] [Algebra.IsAlgebraic K R] (ps : ι → MvPolynomial ι R) (hinj : Injective fun v i => MvPolynomial.eval v (ps i)) : Surjective fun v i => MvPolynomial.eval v (ps i) := by
classical intro v cases nonempty_fintype ι /- `s` is the set of all coefficients of the polynomial, as well as all of the coordinates of `v`, the point I am trying to find the preimage of. -/ let s : Finset R := (Finset.biUnion (univ : Finset ι) fun i => (ps i).support.image fun x => coeff x (ps i)) ∪ (univ : Finset ι).image v have hv : ∀ i, v i ∈ Algebra.adjoin K (s : Set R) := fun j => Algebra.subset_adjoin (mem_union_right _ (mem_image.2 ⟨j, mem_univ _, rfl⟩)) have hs₁ : ∀ (i : ι) (k : ι →₀ ℕ), k ∈ (ps i).support → coeff k (ps i) ∈ Algebra.adjoin K (s : Set R) := fun i k hk => Algebra.subset_adjoin (mem_union_left _ (mem_biUnion.2 ⟨i, mem_univ _, mem_image_of_mem _ hk⟩)) letI := isNoetherian_adjoin_finset s fun x _ => Algebra.IsIntegral.isIntegral (R := K) x letI := Module.IsNoetherian.finite K (Algebra.adjoin K (s : Set R)) letI : Finite (Algebra.adjoin K (s : Set R)) := FiniteDimensional.finite_of_finite K (Algebra.adjoin K (s : Set R)) -- The restriction of the polynomial map, `ps`, to the subalgebra generated by `s` let res : (ι → Algebra.adjoin K (s : Set R)) → ι → Algebra.adjoin K (s : Set R) := fun x i => ⟨eval (fun j : ι => (x j : R)) (ps i), eval_mem (hs₁ _) fun i => (x i).2⟩ have hres_inj : Injective res := by intro x y hxy ext i simp only [Subtype.ext_iff, funext_iff] at hxy exact congr_fun (hinj (funext hxy)) i have hres_surj : Surjective res := Finite.injective_iff_surjective.1 hres_inj cases' hres_surj fun i => ⟨v i, hv i⟩ with w hw use fun i => w i simpa only [Subtype.ext_iff, funext_iff] using hw
30
import Mathlib.Data.Matrix.Block import Mathlib.Data.Matrix.Notation import Mathlib.Data.Matrix.RowCol import Mathlib.GroupTheory.GroupAction.Ring import Mathlib.GroupTheory.Perm.Fin import Mathlib.LinearAlgebra.Alternating.Basic #align_import linear_algebra.matrix.determinant from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395" universe u v w z open Equiv Equiv.Perm Finset Function namespace Matrix open Matrix variable {m n : Type*} [DecidableEq n] [Fintype n] [DecidableEq m] [Fintype m] variable {R : Type v} [CommRing R] local notation "ε " σ:arg => ((sign σ : ℤ) : R) def detRowAlternating : (n → R) [⋀^n]→ₗ[R] R := MultilinearMap.alternatization ((MultilinearMap.mkPiAlgebra R n R).compLinearMap LinearMap.proj) #align matrix.det_row_alternating Matrix.detRowAlternating abbrev det (M : Matrix n n R) : R := detRowAlternating M #align matrix.det Matrix.det theorem det_apply (M : Matrix n n R) : M.det = ∑ σ : Perm n, Equiv.Perm.sign σ • ∏ i, M (σ i) i := MultilinearMap.alternatization_apply _ M #align matrix.det_apply Matrix.det_apply -- This is what the old definition was. We use it to avoid having to change the old proofs below theorem det_apply' (M : Matrix n n R) : M.det = ∑ σ : Perm n, ε σ * ∏ i, M (σ i) i := by simp [det_apply, Units.smul_def] #align matrix.det_apply' Matrix.det_apply' @[simp] theorem det_diagonal {d : n → R} : det (diagonal d) = ∏ i, d i := by rw [det_apply'] refine (Finset.sum_eq_single 1 ?_ ?_).trans ?_ · rintro σ - h2 cases' not_forall.1 (mt Equiv.ext h2) with x h3 convert mul_zero (ε σ) apply Finset.prod_eq_zero (mem_univ x) exact if_neg h3 · simp · simp #align matrix.det_diagonal Matrix.det_diagonal -- @[simp] -- Porting note (#10618): simp can prove this theorem det_zero (_ : Nonempty n) : det (0 : Matrix n n R) = 0 := (detRowAlternating : (n → R) [⋀^n]→ₗ[R] R).map_zero #align matrix.det_zero Matrix.det_zero @[simp] theorem det_one : det (1 : Matrix n n R) = 1 := by rw [← diagonal_one]; simp [-diagonal_one] #align matrix.det_one Matrix.det_one theorem det_isEmpty [IsEmpty n] {A : Matrix n n R} : det A = 1 := by simp [det_apply] #align matrix.det_is_empty Matrix.det_isEmpty @[simp] theorem coe_det_isEmpty [IsEmpty n] : (det : Matrix n n R → R) = Function.const _ 1 := by ext exact det_isEmpty #align matrix.coe_det_is_empty Matrix.coe_det_isEmpty theorem det_eq_one_of_card_eq_zero {A : Matrix n n R} (h : Fintype.card n = 0) : det A = 1 := haveI : IsEmpty n := Fintype.card_eq_zero_iff.mp h det_isEmpty #align matrix.det_eq_one_of_card_eq_zero Matrix.det_eq_one_of_card_eq_zero @[simp] theorem det_unique {n : Type*} [Unique n] [DecidableEq n] [Fintype n] (A : Matrix n n R) : det A = A default default := by simp [det_apply, univ_unique] #align matrix.det_unique Matrix.det_unique theorem det_eq_elem_of_subsingleton [Subsingleton n] (A : Matrix n n R) (k : n) : det A = A k k := by have := uniqueOfSubsingleton k convert det_unique A #align matrix.det_eq_elem_of_subsingleton Matrix.det_eq_elem_of_subsingleton theorem det_eq_elem_of_card_eq_one {A : Matrix n n R} (h : Fintype.card n = 1) (k : n) : det A = A k k := haveI : Subsingleton n := Fintype.card_le_one_iff_subsingleton.mp h.le det_eq_elem_of_subsingleton _ _ #align matrix.det_eq_elem_of_card_eq_one Matrix.det_eq_elem_of_card_eq_one theorem det_mul_aux {M N : Matrix n n R} {p : n → n} (H : ¬Bijective p) : (∑ σ : Perm n, ε σ * ∏ x, M (σ x) (p x) * N (p x) x) = 0 := by obtain ⟨i, j, hpij, hij⟩ : ∃ i j, p i = p j ∧ i ≠ j := by rw [← Finite.injective_iff_bijective, Injective] at H push_neg at H exact H exact sum_involution (fun σ _ => σ * Equiv.swap i j) (fun σ _ => by have : (∏ x, M (σ x) (p x)) = ∏ x, M ((σ * Equiv.swap i j) x) (p x) := Fintype.prod_equiv (swap i j) _ _ (by simp [apply_swap_eq_self hpij]) simp [this, sign_swap hij, -sign_swap', prod_mul_distrib]) (fun σ _ _ => (not_congr mul_swap_eq_iff).mpr hij) (fun _ _ => mem_univ _) fun σ _ => mul_swap_involutive i j σ #align matrix.det_mul_aux Matrix.det_mul_aux @[simp]
Mathlib/LinearAlgebra/Matrix/Determinant/Basic.lean
145
178
theorem det_mul (M N : Matrix n n R) : det (M * N) = det M * det N := calc det (M * N) = ∑ p : n → n, ∑ σ : Perm n, ε σ * ∏ i, M (σ i) (p i) * N (p i) i := by
simp only [det_apply', mul_apply, prod_univ_sum, mul_sum, Fintype.piFinset_univ] rw [Finset.sum_comm] _ = ∑ p ∈ (@univ (n → n) _).filter Bijective, ∑ σ : Perm n, ε σ * ∏ i, M (σ i) (p i) * N (p i) i := (Eq.symm <| sum_subset (filter_subset _ _) fun f _ hbij => det_mul_aux <| by simpa only [true_and_iff, mem_filter, mem_univ] using hbij) _ = ∑ τ : Perm n, ∑ σ : Perm n, ε σ * ∏ i, M (σ i) (τ i) * N (τ i) i := sum_bij (fun p h ↦ Equiv.ofBijective p (mem_filter.1 h).2) (fun _ _ ↦ mem_univ _) (fun _ _ _ _ h ↦ by injection h) (fun b _ ↦ ⟨b, mem_filter.2 ⟨mem_univ _, b.bijective⟩, coe_fn_injective rfl⟩) fun _ _ ↦ rfl _ = ∑ σ : Perm n, ∑ τ : Perm n, (∏ i, N (σ i) i) * ε τ * ∏ j, M (τ j) (σ j) := by simp only [mul_comm, mul_left_comm, prod_mul_distrib, mul_assoc] _ = ∑ σ : Perm n, ∑ τ : Perm n, (∏ i, N (σ i) i) * (ε σ * ε τ) * ∏ i, M (τ i) i := (sum_congr rfl fun σ _ => Fintype.sum_equiv (Equiv.mulRight σ⁻¹) _ _ fun τ => by have : (∏ j, M (τ j) (σ j)) = ∏ j, M ((τ * σ⁻¹) j) j := by rw [← (σ⁻¹ : _ ≃ _).prod_comp] simp only [Equiv.Perm.coe_mul, apply_inv_self, Function.comp_apply] have h : ε σ * ε (τ * σ⁻¹) = ε τ := calc ε σ * ε (τ * σ⁻¹) = ε (τ * σ⁻¹ * σ) := by rw [mul_comm, sign_mul (τ * σ⁻¹)] simp only [Int.cast_mul, Units.val_mul] _ = ε τ := by simp only [inv_mul_cancel_right] simp_rw [Equiv.coe_mulRight, h] simp only [this]) _ = det M * det N := by simp only [det_apply', Finset.mul_sum, mul_comm, mul_left_comm, mul_assoc]
30
import Mathlib.LinearAlgebra.FiniteDimensional import Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup import Mathlib.LinearAlgebra.Matrix.Nondegenerate import Mathlib.LinearAlgebra.Matrix.NonsingularInverse import Mathlib.LinearAlgebra.Matrix.ToLin import Mathlib.RingTheory.Localization.FractionRing import Mathlib.RingTheory.Localization.Integer #align_import linear_algebra.matrix.to_linear_equiv from "leanprover-community/mathlib"@"e42cfdb03b7902f8787a1eb552cb8f77766b45b9" variable {n : Type*} [Fintype n] namespace Matrix section LinearEquiv open LinearMap variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] section Nondegenerate open Matrix theorem exists_mulVec_eq_zero_iff_aux {K : Type*} [DecidableEq n] [Field K] {M : Matrix n n K} : (∃ v ≠ 0, M *ᵥ v = 0) ↔ M.det = 0 := by constructor · rintro ⟨v, hv, mul_eq⟩ contrapose! hv exact eq_zero_of_mulVec_eq_zero hv mul_eq · contrapose! intro h have : Function.Injective (Matrix.toLin' M) := by simpa only [← LinearMap.ker_eq_bot, ker_toLin'_eq_bot_iff, not_imp_not] using h have : M * LinearMap.toMatrix' ((LinearEquiv.ofInjectiveEndo (Matrix.toLin' M) this).symm : (n → K) →ₗ[K] n → K) = 1 := by refine Matrix.toLin'.injective (LinearMap.ext fun v => ?_) rw [Matrix.toLin'_mul, Matrix.toLin'_one, Matrix.toLin'_toMatrix', LinearMap.comp_apply] exact (LinearEquiv.ofInjectiveEndo (Matrix.toLin' M) this).apply_symm_apply v exact Matrix.det_ne_zero_of_right_inverse this #align matrix.exists_mul_vec_eq_zero_iff_aux Matrix.exists_mulVec_eq_zero_iff_aux
Mathlib/LinearAlgebra/Matrix/ToLinearEquiv.lean
135
167
theorem exists_mulVec_eq_zero_iff' {A : Type*} (K : Type*) [DecidableEq n] [CommRing A] [Nontrivial A] [Field K] [Algebra A K] [IsFractionRing A K] {M : Matrix n n A} : (∃ v ≠ 0, M *ᵥ v = 0) ↔ M.det = 0 := by
have : (∃ v ≠ 0, (algebraMap A K).mapMatrix M *ᵥ v = 0) ↔ _ := exists_mulVec_eq_zero_iff_aux rw [← RingHom.map_det, IsFractionRing.to_map_eq_zero_iff] at this refine Iff.trans ?_ this; constructor <;> rintro ⟨v, hv, mul_eq⟩ · refine ⟨fun i => algebraMap _ _ (v i), mt (fun h => funext fun i => ?_) hv, ?_⟩ · exact IsFractionRing.to_map_eq_zero_iff.mp (congr_fun h i) · ext i refine (RingHom.map_mulVec _ _ _ i).symm.trans ?_ rw [mul_eq, Pi.zero_apply, RingHom.map_zero, Pi.zero_apply] · letI := Classical.decEq K obtain ⟨⟨b, hb⟩, ba_eq⟩ := IsLocalization.exist_integer_multiples_of_finset (nonZeroDivisors A) (Finset.univ.image v) choose f hf using ba_eq refine ⟨fun i => f _ (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩), mt (fun h => funext fun i => ?_) hv, ?_⟩ · have := congr_arg (algebraMap A K) (congr_fun h i) rw [hf, Subtype.coe_mk, Pi.zero_apply, RingHom.map_zero, Algebra.smul_def, mul_eq_zero, IsFractionRing.to_map_eq_zero_iff] at this exact this.resolve_left (nonZeroDivisors.ne_zero hb) · ext i refine IsFractionRing.injective A K ?_ calc algebraMap A K ((M *ᵥ (fun i : n => f (v i) _)) i) = ((algebraMap A K).mapMatrix M *ᵥ algebraMap _ K b • v) i := ?_ _ = 0 := ?_ _ = algebraMap A K 0 := (RingHom.map_zero _).symm · simp_rw [RingHom.map_mulVec, mulVec, dotProduct, Function.comp_apply, hf, RingHom.mapMatrix_apply, Pi.smul_apply, smul_eq_mul, Algebra.smul_def] · rw [mulVec_smul, mul_eq, Pi.smul_apply, Pi.zero_apply, smul_zero]
30
import Mathlib.Analysis.Fourier.Inversion open Real Complex Set MeasureTheory variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] open scoped FourierTransform private theorem rexp_neg_deriv_aux : ∀ x ∈ univ, HasDerivWithinAt (rexp ∘ Neg.neg) (-rexp (-x)) univ x := fun x _ ↦ mul_neg_one (rexp (-x)) ▸ ((Real.hasDerivAt_exp (-x)).comp x (hasDerivAt_neg x)).hasDerivWithinAt private theorem rexp_neg_image_aux : rexp ∘ Neg.neg '' univ = Ioi 0 := by rw [Set.image_comp, Set.image_univ_of_surjective neg_surjective, Set.image_univ, Real.range_exp] private theorem rexp_neg_injOn_aux : univ.InjOn (rexp ∘ Neg.neg) := Real.exp_injective.injOn.comp neg_injective.injOn (univ.mapsTo_univ _) private theorem rexp_cexp_aux (x : ℝ) (s : ℂ) (f : E) : rexp (-x) • cexp (-↑x) ^ (s - 1) • f = cexp (-s * ↑x) • f := by show (rexp (-x) : ℂ) • _ = _ • f rw [← smul_assoc, smul_eq_mul] push_cast conv in cexp _ * _ => lhs; rw [← cpow_one (cexp _)] rw [← cpow_add _ _ (Complex.exp_ne_zero _), cpow_def_of_ne_zero (Complex.exp_ne_zero _), Complex.log_exp (by norm_num; exact pi_pos) (by simpa using pi_nonneg)] ring_nf theorem mellin_eq_fourierIntegral (f : ℝ → E) {s : ℂ} : mellin f s = 𝓕 (fun (u : ℝ) ↦ (Real.exp (-s.re * u) • f (Real.exp (-u)))) (s.im / (2 * π)) := calc mellin f s = ∫ (u : ℝ), Complex.exp (-s * u) • f (Real.exp (-u)) := by rw [mellin, ← rexp_neg_image_aux, integral_image_eq_integral_abs_deriv_smul MeasurableSet.univ rexp_neg_deriv_aux rexp_neg_injOn_aux] simp [rexp_cexp_aux] _ = ∫ (u : ℝ), Complex.exp (↑(-2 * π * (u * (s.im / (2 * π)))) * I) • (Real.exp (-s.re * u) • f (Real.exp (-u))) := by congr ext u trans Complex.exp (-s.im * u * I) • (Real.exp (-s.re * u) • f (Real.exp (-u))) · conv => lhs; rw [← re_add_im s] rw [neg_add, add_mul, Complex.exp_add, mul_comm, ← smul_eq_mul, smul_assoc] norm_cast push_cast ring_nf congr rw [mul_comm (-s.im : ℂ) (u : ℂ), mul_comm (-2 * π)] have : 2 * (π : ℂ) ≠ 0 := by norm_num; exact pi_ne_zero field_simp _ = 𝓕 (fun (u : ℝ) ↦ (Real.exp (-s.re * u) • f (Real.exp (-u)))) (s.im / (2 * π)) := by simp [fourierIntegral_eq'] theorem mellinInv_eq_fourierIntegralInv (σ : ℝ) (f : ℂ → E) {x : ℝ} (hx : 0 < x) : mellinInv σ f x = (x : ℂ) ^ (-σ : ℂ) • 𝓕⁻ (fun (y : ℝ) ↦ f (σ + 2 * π * y * I)) (-Real.log x) := calc mellinInv σ f x = (x : ℂ) ^ (-σ : ℂ) • (∫ (y : ℝ), Complex.exp (2 * π * (y * (-Real.log x)) * I) • f (σ + 2 * π * y * I)) := by rw [mellinInv, one_div, ← abs_of_pos (show 0 < (2 * π)⁻¹ by norm_num; exact pi_pos)] have hx0 : (x : ℂ) ≠ 0 := ofReal_ne_zero.mpr (ne_of_gt hx) simp_rw [neg_add, cpow_add _ _ hx0, mul_smul, integral_smul] rw [smul_comm, ← Measure.integral_comp_mul_left] congr! 3 rw [cpow_def_of_ne_zero hx0, ← Complex.ofReal_log hx.le] push_cast ring_nf _ = (x : ℂ) ^ (-σ : ℂ) • 𝓕⁻ (fun (y : ℝ) ↦ f (σ + 2 * π * y * I)) (-Real.log x) := by simp [fourierIntegralInv_eq'] variable [CompleteSpace E]
Mathlib/Analysis/MellinInversion.lean
89
121
theorem mellin_inversion (σ : ℝ) (f : ℝ → E) {x : ℝ} (hx : 0 < x) (hf : MellinConvergent f σ) (hFf : VerticalIntegrable (mellin f) σ) (hfx : ContinuousAt f x) : mellinInv σ (mellin f) x = f x := by
let g := fun (u : ℝ) => Real.exp (-σ * u) • f (Real.exp (-u)) replace hf : Integrable g := by rw [MellinConvergent, ← rexp_neg_image_aux, integrableOn_image_iff_integrableOn_abs_deriv_smul MeasurableSet.univ rexp_neg_deriv_aux rexp_neg_injOn_aux] at hf replace hf : Integrable fun (x : ℝ) ↦ cexp (-↑σ * ↑x) • f (rexp (-x)) := by simpa [rexp_cexp_aux] using hf norm_cast at hf replace hFf : Integrable (𝓕 g) := by have h2π : 2 * π ≠ 0 := by norm_num; exact pi_ne_zero have : Integrable (𝓕 (fun u ↦ rexp (-(σ * u)) • f (rexp (-u)))) := by simpa [mellin_eq_fourierIntegral, mul_div_cancel_right₀ _ h2π] using hFf.comp_mul_right' h2π simp_rw [neg_mul_eq_neg_mul] at this exact this replace hfx : ContinuousAt g (-Real.log x) := by refine ContinuousAt.smul (by fun_prop) (ContinuousAt.comp ?_ (by fun_prop)) simpa [Real.exp_log hx] using hfx calc mellinInv σ (mellin f) x = mellinInv σ (fun s ↦ 𝓕 g (s.im / (2 * π))) x := by simp [g, mellinInv, mellin_eq_fourierIntegral] _ = (x : ℂ) ^ (-σ : ℂ) • g (-Real.log x) := by rw [mellinInv_eq_fourierIntegralInv _ _ hx, ← hf.fourier_inversion hFf hfx] simp [mul_div_cancel_left₀ _ (show 2 * π ≠ 0 by norm_num; exact pi_ne_zero)] _ = (x : ℂ) ^ (-σ : ℂ) • rexp (σ * Real.log x) • f (rexp (Real.log x)) := by simp [g] _ = f x := by norm_cast rw [mul_comm σ, ← rpow_def_of_pos hx, Real.exp_log hx, ← Complex.ofReal_cpow hx.le] norm_cast rw [← smul_assoc, smul_eq_mul, Real.rpow_neg hx.le, inv_mul_cancel (ne_of_gt (rpow_pos_of_pos hx σ)), one_smul]
30
import Mathlib.Control.Monad.Basic import Mathlib.Data.Fintype.Basic import Mathlib.Data.List.ProdSigma #align_import data.fin_enum from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" universe u v open Finset class FinEnum (α : Sort*) where card : ℕ equiv : α ≃ Fin card [decEq : DecidableEq α] #align fin_enum FinEnum attribute [instance 100] FinEnum.decEq namespace FinEnum variable {α : Type u} {β : α → Type v} def ofEquiv (α) {β} [FinEnum α] (h : β ≃ α) : FinEnum β where card := card α equiv := h.trans (equiv) decEq := (h.trans (equiv)).decidableEq #align fin_enum.of_equiv FinEnum.ofEquiv def ofNodupList [DecidableEq α] (xs : List α) (h : ∀ x : α, x ∈ xs) (h' : List.Nodup xs) : FinEnum α where card := xs.length equiv := ⟨fun x => ⟨xs.indexOf x, by rw [List.indexOf_lt_length]; apply h⟩, xs.get, fun x => by simp, fun i => by ext; simp [List.get_indexOf h']⟩ #align fin_enum.of_nodup_list FinEnum.ofNodupList def ofList [DecidableEq α] (xs : List α) (h : ∀ x : α, x ∈ xs) : FinEnum α := ofNodupList xs.dedup (by simp [*]) (List.nodup_dedup _) #align fin_enum.of_list FinEnum.ofList def toList (α) [FinEnum α] : List α := (List.finRange (card α)).map (equiv).symm #align fin_enum.to_list FinEnum.toList open Function @[simp] theorem mem_toList [FinEnum α] (x : α) : x ∈ toList α := by simp [toList]; exists equiv x; simp #align fin_enum.mem_to_list FinEnum.mem_toList @[simp] theorem nodup_toList [FinEnum α] : List.Nodup (toList α) := by simp [toList]; apply List.Nodup.map <;> [apply Equiv.injective; apply List.nodup_finRange] #align fin_enum.nodup_to_list FinEnum.nodup_toList def ofSurjective {β} (f : β → α) [DecidableEq α] [FinEnum β] (h : Surjective f) : FinEnum α := ofList ((toList β).map f) (by intro; simp; exact h _) #align fin_enum.of_surjective FinEnum.ofSurjective noncomputable def ofInjective {α β} (f : α → β) [DecidableEq α] [FinEnum β] (h : Injective f) : FinEnum α := ofList ((toList β).filterMap (partialInv f)) (by intro x simp only [mem_toList, true_and_iff, List.mem_filterMap] use f x simp only [h, Function.partialInv_left]) #align fin_enum.of_injective FinEnum.ofInjective instance pempty : FinEnum PEmpty := ofList [] fun x => PEmpty.elim x #align fin_enum.pempty FinEnum.pempty instance empty : FinEnum Empty := ofList [] fun x => Empty.elim x #align fin_enum.empty FinEnum.empty instance punit : FinEnum PUnit := ofList [PUnit.unit] fun x => by cases x; simp #align fin_enum.punit FinEnum.punit instance prod {β} [FinEnum α] [FinEnum β] : FinEnum (α × β) := ofList (toList α ×ˢ toList β) fun x => by cases x; simp #align fin_enum.prod FinEnum.prod instance sum {β} [FinEnum α] [FinEnum β] : FinEnum (Sum α β) := ofList ((toList α).map Sum.inl ++ (toList β).map Sum.inr) fun x => by cases x <;> simp #align fin_enum.sum FinEnum.sum instance fin {n} : FinEnum (Fin n) := ofList (List.finRange _) (by simp) #align fin_enum.fin FinEnum.fin instance Quotient.enum [FinEnum α] (s : Setoid α) [DecidableRel ((· ≈ ·) : α → α → Prop)] : FinEnum (Quotient s) := FinEnum.ofSurjective Quotient.mk'' fun x => Quotient.inductionOn x fun x => ⟨x, rfl⟩ #align fin_enum.quotient.enum FinEnum.Quotient.enum def Finset.enum [DecidableEq α] : List α → List (Finset α) | [] => [∅] | x :: xs => do let r ← Finset.enum xs [r, {x} ∪ r] #align fin_enum.finset.enum FinEnum.Finset.enum @[simp]
Mathlib/Data/FinEnum.lean
132
163
theorem Finset.mem_enum [DecidableEq α] (s : Finset α) (xs : List α) : s ∈ Finset.enum xs ↔ ∀ x ∈ s, x ∈ xs := by
induction' xs with xs_hd generalizing s <;> simp [*, Finset.enum] · simp [Finset.eq_empty_iff_forall_not_mem] · constructor · rintro ⟨a, h, h'⟩ x hx cases' h' with _ h' a b · right apply h subst a exact hx · simp only [h', mem_union, mem_singleton] at hx ⊢ cases' hx with hx hx' · exact Or.inl hx · exact Or.inr (h _ hx') · intro h exists s \ ({xs_hd} : Finset α) simp only [and_imp, mem_sdiff, mem_singleton] simp only [or_iff_not_imp_left] at h exists h by_cases h : xs_hd ∈ s · have : {xs_hd} ⊆ s := by simp only [HasSubset.Subset, *, forall_eq, mem_singleton] simp only [union_sdiff_of_subset this, or_true_iff, Finset.union_sdiff_of_subset, eq_self_iff_true] · left symm simp only [sdiff_eq_self] intro a simp only [and_imp, mem_inter, mem_singleton] rintro h₀ rfl exact (h h₀).elim
30
import Mathlib.Analysis.Calculus.Deriv.Add import Mathlib.Analysis.Calculus.Deriv.Mul import Mathlib.Analysis.Calculus.LocalExtr.Basic #align_import analysis.calculus.darboux from "leanprover-community/mathlib"@"61b5e2755ccb464b68d05a9acf891ae04992d09d" open Filter Set open scoped Topology Classical variable {a b : ℝ} {f f' : ℝ → ℝ}
Mathlib/Analysis/Calculus/Darboux.lean
28
60
theorem exists_hasDerivWithinAt_eq_of_gt_of_lt (hab : a ≤ b) (hf : ∀ x ∈ Icc a b, HasDerivWithinAt f (f' x) (Icc a b) x) {m : ℝ} (hma : f' a < m) (hmb : m < f' b) : m ∈ f' '' Ioo a b := by
rcases hab.eq_or_lt with (rfl | hab') · exact (lt_asymm hma hmb).elim set g : ℝ → ℝ := fun x => f x - m * x have hg : ∀ x ∈ Icc a b, HasDerivWithinAt g (f' x - m) (Icc a b) x := by intro x hx simpa using (hf x hx).sub ((hasDerivWithinAt_id x _).const_mul m) obtain ⟨c, cmem, hc⟩ : ∃ c ∈ Icc a b, IsMinOn g (Icc a b) c := isCompact_Icc.exists_isMinOn (nonempty_Icc.2 <| hab) fun x hx => (hg x hx).continuousWithinAt have cmem' : c ∈ Ioo a b := by rcases cmem.1.eq_or_lt with (rfl | hac) -- Show that `c` can't be equal to `a` · refine absurd (sub_nonneg.1 <| nonneg_of_mul_nonneg_right ?_ (sub_pos.2 hab')) (not_le_of_lt hma) have : b - a ∈ posTangentConeAt (Icc a b) a := mem_posTangentConeAt_of_segment_subset (segment_eq_Icc hab ▸ Subset.refl _) simpa only [ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply] using hc.localize.hasFDerivWithinAt_nonneg (hg a (left_mem_Icc.2 hab)) this rcases cmem.2.eq_or_gt with (rfl | hcb) -- Show that `c` can't be equal to `b` · refine absurd (sub_nonpos.1 <| nonpos_of_mul_nonneg_right ?_ (sub_lt_zero.2 hab')) (not_le_of_lt hmb) have : a - b ∈ posTangentConeAt (Icc a b) b := mem_posTangentConeAt_of_segment_subset (by rw [segment_symm, segment_eq_Icc hab]) simpa only [ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply] using hc.localize.hasFDerivWithinAt_nonneg (hg b (right_mem_Icc.2 hab)) this exact ⟨hac, hcb⟩ use c, cmem' rw [← sub_eq_zero] have : Icc a b ∈ 𝓝 c := by rwa [← mem_interior_iff_mem_nhds, interior_Icc] exact (hc.isLocalMin this).hasDerivAt_eq_zero ((hg c cmem).hasDerivAt this)
30
import Mathlib.Analysis.InnerProductSpace.Basic import Mathlib.Analysis.NormedSpace.Dual import Mathlib.MeasureTheory.Function.StronglyMeasurable.Lp import Mathlib.MeasureTheory.Integral.SetIntegral #align_import measure_theory.function.ae_eq_of_integral from "leanprover-community/mathlib"@"915591b2bb3ea303648db07284a161a7f2a9e3d4" open MeasureTheory TopologicalSpace NormedSpace Filter open scoped ENNReal NNReal MeasureTheory Topology namespace MeasureTheory section AeEqOfForall variable {α E 𝕜 : Type*} {m : MeasurableSpace α} {μ : Measure α} [RCLike 𝕜] theorem ae_eq_zero_of_forall_inner [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [SecondCountableTopology E] {f : α → E} (hf : ∀ c : E, (fun x => (inner c (f x) : 𝕜)) =ᵐ[μ] 0) : f =ᵐ[μ] 0 := by let s := denseSeq E have hs : DenseRange s := denseRange_denseSeq E have hf' : ∀ᵐ x ∂μ, ∀ n : ℕ, inner (s n) (f x) = (0 : 𝕜) := ae_all_iff.mpr fun n => hf (s n) refine hf'.mono fun x hx => ?_ rw [Pi.zero_apply, ← @inner_self_eq_zero 𝕜] have h_closed : IsClosed {c : E | inner c (f x) = (0 : 𝕜)} := isClosed_eq (continuous_id.inner continuous_const) continuous_const exact @isClosed_property ℕ E _ s (fun c => inner c (f x) = (0 : 𝕜)) hs h_closed (fun n => hx n) _ #align measure_theory.ae_eq_zero_of_forall_inner MeasureTheory.ae_eq_zero_of_forall_inner local notation "⟪" x ", " y "⟫" => y x variable (𝕜)
Mathlib/MeasureTheory/Function/AEEqOfIntegral.lean
74
106
theorem ae_eq_zero_of_forall_dual_of_isSeparable [NormedAddCommGroup E] [NormedSpace 𝕜 E] {t : Set E} (ht : TopologicalSpace.IsSeparable t) {f : α → E} (hf : ∀ c : Dual 𝕜 E, (fun x => ⟪f x, c⟫) =ᵐ[μ] 0) (h't : ∀ᵐ x ∂μ, f x ∈ t) : f =ᵐ[μ] 0 := by
rcases ht with ⟨d, d_count, hd⟩ haveI : Encodable d := d_count.toEncodable have : ∀ x : d, ∃ g : E →L[𝕜] 𝕜, ‖g‖ ≤ 1 ∧ g x = ‖(x : E)‖ := fun x => exists_dual_vector'' 𝕜 (x : E) choose s hs using this have A : ∀ a : E, a ∈ t → (∀ x, ⟪a, s x⟫ = (0 : 𝕜)) → a = 0 := by intro a hat ha contrapose! ha have a_pos : 0 < ‖a‖ := by simp only [ha, norm_pos_iff, Ne, not_false_iff] have a_mem : a ∈ closure d := hd hat obtain ⟨x, hx⟩ : ∃ x : d, dist a x < ‖a‖ / 2 := by rcases Metric.mem_closure_iff.1 a_mem (‖a‖ / 2) (half_pos a_pos) with ⟨x, h'x, hx⟩ exact ⟨⟨x, h'x⟩, hx⟩ use x have I : ‖a‖ / 2 < ‖(x : E)‖ := by have : ‖a‖ ≤ ‖(x : E)‖ + ‖a - x‖ := norm_le_insert' _ _ have : ‖a - x‖ < ‖a‖ / 2 := by rwa [dist_eq_norm] at hx linarith intro h apply lt_irrefl ‖s x x‖ calc ‖s x x‖ = ‖s x (x - a)‖ := by simp only [h, sub_zero, ContinuousLinearMap.map_sub] _ ≤ 1 * ‖(x : E) - a‖ := ContinuousLinearMap.le_of_opNorm_le _ (hs x).1 _ _ < ‖a‖ / 2 := by rw [one_mul]; rwa [dist_eq_norm'] at hx _ < ‖(x : E)‖ := I _ = ‖s x x‖ := by rw [(hs x).2, RCLike.norm_coe_norm] have hfs : ∀ y : d, ∀ᵐ x ∂μ, ⟪f x, s y⟫ = (0 : 𝕜) := fun y => hf (s y) have hf' : ∀ᵐ x ∂μ, ∀ y : d, ⟪f x, s y⟫ = (0 : 𝕜) := by rwa [ae_all_iff] filter_upwards [hf', h't] with x hx h'x exact A (f x) h'x hx
30
import Mathlib.Analysis.Analytic.Basic import Mathlib.Analysis.Analytic.CPolynomial import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.ContDiff.Defs import Mathlib.Analysis.Calculus.FDeriv.Add #align_import analysis.calculus.fderiv_analytic from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" open Filter Asymptotics open scoped ENNReal universe u v variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {E : Type u} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F] namespace ContinuousMultilinearMap variable {ι : Type*} {E : ι → Type*} [∀ i, NormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)] [Fintype ι] (f : ContinuousMultilinearMap 𝕜 E F) open FormalMultilinearSeries protected theorem hasFiniteFPowerSeriesOnBall : HasFiniteFPowerSeriesOnBall f f.toFormalMultilinearSeries 0 (Fintype.card ι + 1) ⊤ := .mk' (fun m hm ↦ dif_neg (Nat.succ_le_iff.mp hm).ne) ENNReal.zero_lt_top fun y _ ↦ by rw [Finset.sum_eq_single_of_mem _ (Finset.self_mem_range_succ _), zero_add] · rw [toFormalMultilinearSeries, dif_pos rfl]; rfl · intro m _ ne; rw [toFormalMultilinearSeries, dif_neg ne.symm]; rfl theorem changeOriginSeries_support {k l : ℕ} (h : k + l ≠ Fintype.card ι) : f.toFormalMultilinearSeries.changeOriginSeries k l = 0 := Finset.sum_eq_zero fun _ _ ↦ by simp_rw [FormalMultilinearSeries.changeOriginSeriesTerm, toFormalMultilinearSeries, dif_neg h.symm, LinearIsometryEquiv.map_zero] variable {n : ℕ∞} (x : ∀ i, E i) open Finset in
Mathlib/Analysis/Calculus/FDeriv/Analytic.lean
314
346
theorem changeOrigin_toFormalMultilinearSeries [DecidableEq ι] : continuousMultilinearCurryFin1 𝕜 (∀ i, E i) F (f.toFormalMultilinearSeries.changeOrigin x 1) = f.linearDeriv x := by
ext y rw [continuousMultilinearCurryFin1_apply, linearDeriv_apply, changeOrigin, FormalMultilinearSeries.sum] cases isEmpty_or_nonempty ι · have (l) : 1 + l ≠ Fintype.card ι := by rw [add_comm, Fintype.card_eq_zero]; exact Nat.succ_ne_zero _ simp_rw [Fintype.sum_empty, changeOriginSeries_support _ (this _), zero_apply _, tsum_zero]; rfl rw [tsum_eq_single (Fintype.card ι - 1), changeOriginSeries]; swap · intro m hm rw [Ne, eq_tsub_iff_add_eq_of_le (by exact Fintype.card_pos), add_comm] at hm rw [f.changeOriginSeries_support hm, zero_apply] rw [sum_apply, ContinuousMultilinearMap.sum_apply, Fin.snoc_zero] simp_rw [changeOriginSeriesTerm_apply] refine (Fintype.sum_bijective (?_ ∘ Fintype.equivFinOfCardEq (Nat.add_sub_of_le Fintype.card_pos).symm) (.comp ?_ <| Equiv.bijective _) _ _ fun i ↦ ?_).symm · exact (⟨{·}ᶜ, by rw [card_compl, Fintype.card_fin, card_singleton, Nat.add_sub_cancel_left]⟩) · use fun _ _ ↦ (singleton_injective <| compl_injective <| Subtype.ext_iff.mp ·) intro ⟨s, hs⟩ have h : sᶜ.card = 1 := by rw [card_compl, hs, Fintype.card_fin, Nat.add_sub_cancel] obtain ⟨a, ha⟩ := card_eq_one.mp h exact ⟨a, Subtype.ext (compl_eq_comm.mp ha)⟩ rw [Function.comp_apply, Subtype.coe_mk, compl_singleton, piecewise_erase_univ, toFormalMultilinearSeries, dif_pos (Nat.add_sub_of_le Fintype.card_pos).symm] simp_rw [domDomCongr_apply, compContinuousLinearMap_apply, ContinuousLinearMap.proj_apply, Function.update_apply, (Equiv.injective _).eq_iff, ite_apply] congr; ext j obtain rfl | hj := eq_or_ne j i · rw [Function.update_same, if_pos rfl] · rw [Function.update_noteq hj, if_neg hj]
30
import Mathlib.Computability.PartrecCode import Mathlib.Data.Set.Subsingleton #align_import computability.halting from "leanprover-community/mathlib"@"a50170a88a47570ed186b809ca754110590f9476" open Encodable Denumerable namespace Nat.Partrec open Computable Part
Mathlib/Computability/Halting.lean
28
60
theorem merge' {f g} (hf : Nat.Partrec f) (hg : Nat.Partrec g) : ∃ h, Nat.Partrec h ∧ ∀ a, (∀ x ∈ h a, x ∈ f a ∨ x ∈ g a) ∧ ((h a).Dom ↔ (f a).Dom ∨ (g a).Dom) := by
obtain ⟨cf, rfl⟩ := Code.exists_code.1 hf obtain ⟨cg, rfl⟩ := Code.exists_code.1 hg have : Nat.Partrec fun n => Nat.rfindOpt fun k => cf.evaln k n <|> cg.evaln k n := Partrec.nat_iff.1 (Partrec.rfindOpt <| Primrec.option_orElse.to_comp.comp (Code.evaln_prim.to_comp.comp <| (snd.pair (const cf)).pair fst) (Code.evaln_prim.to_comp.comp <| (snd.pair (const cg)).pair fst)) refine ⟨_, this, fun n => ?_⟩ have : ∀ x ∈ rfindOpt fun k ↦ HOrElse.hOrElse (Code.evaln k cf n) fun _x ↦ Code.evaln k cg n, x ∈ Code.eval cf n ∨ x ∈ Code.eval cg n := by intro x h obtain ⟨k, e⟩ := Nat.rfindOpt_spec h revert e simp only [Option.mem_def] cases' e' : cf.evaln k n with y <;> simp <;> intro e · exact Or.inr (Code.evaln_sound e) · subst y exact Or.inl (Code.evaln_sound e') refine ⟨this, ⟨fun h => (this _ ⟨h, rfl⟩).imp Exists.fst Exists.fst, ?_⟩⟩ intro h rw [Nat.rfindOpt_dom] simp only [dom_iff_mem, Code.evaln_complete, Option.mem_def] at h obtain ⟨x, k, e⟩ | ⟨x, k, e⟩ := h · refine ⟨k, x, ?_⟩ simp only [e, Option.some_orElse, Option.mem_def] · refine ⟨k, ?_⟩ cases' cf.evaln k n with y · exact ⟨x, by simp only [e, Option.mem_def, Option.none_orElse]⟩ · exact ⟨y, by simp only [Option.some_orElse, Option.mem_def]⟩
30