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 | goals listlengths 0 224 | goals_before listlengths 0 221 |
|---|---|---|---|---|---|---|---|
import Batteries.Data.RBMap.Basic
import Batteries.Tactic.SeqFocus
namespace Batteries
namespace RBNode
open RBColor
attribute [simp] All
theorem All.trivial (H : ∀ {x : α}, p x) : ∀ {t : RBNode α}, t.All p
| nil => _root_.trivial
| node .. => ⟨H, All.trivial H, All.trivial H⟩
| .lake/packages/batteries/Batteries/Data/RBMap/WF.lean | 27 | 28 | theorem All_and {t : RBNode α} : t.All (fun a => p a ∧ q a) ↔ t.All p ∧ t.All q := by |
induction t <;> simp [*, and_assoc, and_left_comm]
| [
" All (fun a => p a ∧ q a) t ↔ All p t ∧ All q t",
" All (fun a => p a ∧ q a) nil ↔ All p nil ∧ All q nil",
" All (fun a => p a ∧ q a) (node c✝ l✝ v✝ r✝) ↔ All p (node c✝ l✝ v✝ r✝) ∧ All q (node c✝ l✝ v✝ r✝)"
] | [
" All (fun a => p a ∧ q a) t ↔ All p t ∧ All q t"
] |
import Mathlib.Init.Algebra.Classes
import Mathlib.Init.Data.Ordering.Basic
#align_import init.data.ordering.lemmas from "leanprover-community/lean"@"4bd314f7bd5e0c9e813fc201f1279a23f13f9f1d"
universe u
namespace Ordering
@[simp]
theorem ite_eq_lt_distrib (c : Prop) [Decidable c] (a b : Ordering) :
((if c then a else b) = Ordering.lt) = if c then a = Ordering.lt else b = Ordering.lt := by
by_cases c <;> simp [*]
#align ordering.ite_eq_lt_distrib Ordering.ite_eq_lt_distrib
@[simp]
theorem ite_eq_eq_distrib (c : Prop) [Decidable c] (a b : Ordering) :
((if c then a else b) = Ordering.eq) = if c then a = Ordering.eq else b = Ordering.eq := by
by_cases c <;> simp [*]
#align ordering.ite_eq_eq_distrib Ordering.ite_eq_eq_distrib
@[simp]
| Mathlib/Init/Data/Ordering/Lemmas.lean | 32 | 34 | theorem ite_eq_gt_distrib (c : Prop) [Decidable c] (a b : Ordering) :
((if c then a else b) = Ordering.gt) = if c then a = Ordering.gt else b = Ordering.gt := by |
by_cases c <;> simp [*]
| [
" ((if c then a else b) = lt) = if c then a = lt else b = lt",
" ((if c then a else b) = eq) = if c then a = eq else b = eq",
" ((if c then a else b) = gt) = if c then a = gt else b = gt"
] | [
" ((if c then a else b) = lt) = if c then a = lt else b = lt",
" ((if c then a else b) = eq) = if c then a = eq else b = eq",
" ((if c then a else b) = gt) = if c then a = gt else b = gt"
] |
import Mathlib.Algebra.ContinuedFractions.Computation.Basic
import Mathlib.Algebra.ContinuedFractions.Translations
#align_import algebra.continued_fractions.computation.translations from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
namespace GeneralizedContinuedFraction
open GeneralizedContinuedFraction (of)
-- Fix a discrete linear ordered floor field and a value `v`.
variable {K : Type*} [LinearOrderedField K] [FloorRing K] {v : K}
namespace IntFractPair
theorem stream_zero (v : K) : IntFractPair.stream v 0 = some (IntFractPair.of v) :=
rfl
#align generalized_continued_fraction.int_fract_pair.stream_zero GeneralizedContinuedFraction.IntFractPair.stream_zero
variable {n : ℕ}
theorem stream_eq_none_of_fr_eq_zero {ifp_n : IntFractPair K}
(stream_nth_eq : IntFractPair.stream v n = some ifp_n) (nth_fr_eq_zero : ifp_n.fr = 0) :
IntFractPair.stream v (n + 1) = none := by
cases' ifp_n with _ fr
change fr = 0 at nth_fr_eq_zero
simp [IntFractPair.stream, stream_nth_eq, nth_fr_eq_zero]
#align generalized_continued_fraction.int_fract_pair.stream_eq_none_of_fr_eq_zero GeneralizedContinuedFraction.IntFractPair.stream_eq_none_of_fr_eq_zero
theorem succ_nth_stream_eq_none_iff :
IntFractPair.stream v (n + 1) = none ↔
IntFractPair.stream v n = none ∨ ∃ ifp, IntFractPair.stream v n = some ifp ∧ ifp.fr = 0 := by
rw [IntFractPair.stream]
cases IntFractPair.stream v n <;> simp [imp_false]
#align generalized_continued_fraction.int_fract_pair.succ_nth_stream_eq_none_iff GeneralizedContinuedFraction.IntFractPair.succ_nth_stream_eq_none_iff
theorem succ_nth_stream_eq_some_iff {ifp_succ_n : IntFractPair K} :
IntFractPair.stream v (n + 1) = some ifp_succ_n ↔
∃ ifp_n : IntFractPair K,
IntFractPair.stream v n = some ifp_n ∧
ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n := by
simp [IntFractPair.stream, ite_eq_iff, Option.bind_eq_some]
#align generalized_continued_fraction.int_fract_pair.succ_nth_stream_eq_some_iff GeneralizedContinuedFraction.IntFractPair.succ_nth_stream_eq_some_iff
theorem stream_succ_of_some {p : IntFractPair K} (h : IntFractPair.stream v n = some p)
(h' : p.fr ≠ 0) : IntFractPair.stream v (n + 1) = some (IntFractPair.of p.fr⁻¹) :=
succ_nth_stream_eq_some_iff.mpr ⟨p, h, h', rfl⟩
#align generalized_continued_fraction.int_fract_pair.stream_succ_of_some GeneralizedContinuedFraction.IntFractPair.stream_succ_of_some
theorem stream_succ_of_int (a : ℤ) (n : ℕ) : IntFractPair.stream (a : K) (n + 1) = none := by
induction' n with n ih
· refine IntFractPair.stream_eq_none_of_fr_eq_zero (IntFractPair.stream_zero (a : K)) ?_
simp only [IntFractPair.of, Int.fract_intCast]
· exact IntFractPair.succ_nth_stream_eq_none_iff.mpr (Or.inl ih)
#align generalized_continued_fraction.int_fract_pair.stream_succ_of_int GeneralizedContinuedFraction.IntFractPair.stream_succ_of_int
theorem exists_succ_nth_stream_of_fr_zero {ifp_succ_n : IntFractPair K}
(stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp_succ_n)
(succ_nth_fr_eq_zero : ifp_succ_n.fr = 0) :
∃ ifp_n : IntFractPair K, IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr⁻¹ = ⌊ifp_n.fr⁻¹⌋ := by
-- get the witness from `succ_nth_stream_eq_some_iff` and prove that it has the additional
-- properties
rcases succ_nth_stream_eq_some_iff.mp stream_succ_nth_eq with
⟨ifp_n, seq_nth_eq, _, rfl⟩
refine ⟨ifp_n, seq_nth_eq, ?_⟩
simpa only [IntFractPair.of, Int.fract, sub_eq_zero] using succ_nth_fr_eq_zero
#align generalized_continued_fraction.int_fract_pair.exists_succ_nth_stream_of_fr_zero GeneralizedContinuedFraction.IntFractPair.exists_succ_nth_stream_of_fr_zero
| Mathlib/Algebra/ContinuedFractions/Computation/Translations.lean | 128 | 141 | theorem stream_succ (h : Int.fract v ≠ 0) (n : ℕ) :
IntFractPair.stream v (n + 1) = IntFractPair.stream (Int.fract v)⁻¹ n := by |
induction' n with n ih
· have H : (IntFractPair.of v).fr = Int.fract v := rfl
rw [stream_zero, stream_succ_of_some (stream_zero v) (ne_of_eq_of_ne H h), H]
· rcases eq_or_ne (IntFractPair.stream (Int.fract v)⁻¹ n) none with hnone | hsome
· rw [hnone] at ih
rw [succ_nth_stream_eq_none_iff.mpr (Or.inl hnone),
succ_nth_stream_eq_none_iff.mpr (Or.inl ih)]
· obtain ⟨p, hp⟩ := Option.ne_none_iff_exists'.mp hsome
rw [hp] at ih
rcases eq_or_ne p.fr 0 with hz | hnz
· rw [stream_eq_none_of_fr_eq_zero hp hz, stream_eq_none_of_fr_eq_zero ih hz]
· rw [stream_succ_of_some hp hnz, stream_succ_of_some ih hnz]
| [
" IntFractPair.stream v (n + 1) = none",
" IntFractPair.stream v (n + 1) = none ↔\n IntFractPair.stream v n = none ∨ ∃ ifp, IntFractPair.stream v n = some ifp ∧ ifp.fr = 0",
" ((IntFractPair.stream v n).bind fun ap_n => if ap_n.fr = 0 then none else some (IntFractPair.of ap_n.fr⁻¹)) = none ↔\n IntFractPai... | [
" IntFractPair.stream v (n + 1) = none",
" IntFractPair.stream v (n + 1) = none ↔\n IntFractPair.stream v n = none ∨ ∃ ifp, IntFractPair.stream v n = some ifp ∧ ifp.fr = 0",
" ((IntFractPair.stream v n).bind fun ap_n => if ap_n.fr = 0 then none else some (IntFractPair.of ap_n.fr⁻¹)) = none ↔\n IntFractPai... |
import Mathlib.RingTheory.WittVector.Basic
import Mathlib.RingTheory.WittVector.IsPoly
#align_import ring_theory.witt_vector.verschiebung from "leanprover-community/mathlib"@"32b08ef840dd25ca2e47e035c5da03ce16d2dc3c"
namespace WittVector
open MvPolynomial
variable {p : ℕ} {R S : Type*} [hp : Fact p.Prime] [CommRing R] [CommRing S]
local notation "𝕎" => WittVector p -- type as `\bbW`
noncomputable section
def verschiebungFun (x : 𝕎 R) : 𝕎 R :=
@mk' p _ fun n => if n = 0 then 0 else x.coeff (n - 1)
#align witt_vector.verschiebung_fun WittVector.verschiebungFun
theorem verschiebungFun_coeff (x : 𝕎 R) (n : ℕ) :
(verschiebungFun x).coeff n = if n = 0 then 0 else x.coeff (n - 1) := by
simp only [verschiebungFun, ge_iff_le]
#align witt_vector.verschiebung_fun_coeff WittVector.verschiebungFun_coeff
theorem verschiebungFun_coeff_zero (x : 𝕎 R) : (verschiebungFun x).coeff 0 = 0 := by
rw [verschiebungFun_coeff, if_pos rfl]
#align witt_vector.verschiebung_fun_coeff_zero WittVector.verschiebungFun_coeff_zero
@[simp]
theorem verschiebungFun_coeff_succ (x : 𝕎 R) (n : ℕ) :
(verschiebungFun x).coeff n.succ = x.coeff n :=
rfl
#align witt_vector.verschiebung_fun_coeff_succ WittVector.verschiebungFun_coeff_succ
@[ghost_simps]
theorem ghostComponent_zero_verschiebungFun (x : 𝕎 R) :
ghostComponent 0 (verschiebungFun x) = 0 := by
rw [ghostComponent_apply, aeval_wittPolynomial, Finset.range_one, Finset.sum_singleton,
verschiebungFun_coeff_zero, pow_zero, pow_zero, pow_one, one_mul]
#align witt_vector.ghost_component_zero_verschiebung_fun WittVector.ghostComponent_zero_verschiebungFun
@[ghost_simps]
theorem ghostComponent_verschiebungFun (x : 𝕎 R) (n : ℕ) :
ghostComponent (n + 1) (verschiebungFun x) = p * ghostComponent n x := by
simp only [ghostComponent_apply, aeval_wittPolynomial]
rw [Finset.sum_range_succ', verschiebungFun_coeff, if_pos rfl,
zero_pow (pow_ne_zero _ hp.1.ne_zero), mul_zero, add_zero, Finset.mul_sum, Finset.sum_congr rfl]
rintro i -
simp only [pow_succ', verschiebungFun_coeff_succ, Nat.succ_sub_succ_eq_sub, mul_assoc]
#align witt_vector.ghost_component_verschiebung_fun WittVector.ghostComponent_verschiebungFun
def verschiebungPoly (n : ℕ) : MvPolynomial ℕ ℤ :=
if n = 0 then 0 else X (n - 1)
#align witt_vector.verschiebung_poly WittVector.verschiebungPoly
@[simp]
theorem verschiebungPoly_zero : verschiebungPoly 0 = 0 :=
rfl
#align witt_vector.verschiebung_poly_zero WittVector.verschiebungPoly_zero
theorem aeval_verschiebung_poly' (x : 𝕎 R) (n : ℕ) :
aeval x.coeff (verschiebungPoly n) = (verschiebungFun x).coeff n := by
cases' n with n
· simp only [verschiebungPoly, Nat.zero_eq, ge_iff_le, tsub_eq_zero_of_le, ite_true, map_zero,
verschiebungFun_coeff_zero]
· rw [verschiebungPoly, verschiebungFun_coeff_succ, if_neg n.succ_ne_zero, aeval_X,
add_tsub_cancel_right]
#align witt_vector.aeval_verschiebung_poly' WittVector.aeval_verschiebung_poly'
variable (p)
-- Porting note: replaced `@[is_poly]` with `instance`.
instance verschiebungFun_isPoly : IsPoly p fun R _Rcr => @verschiebungFun p R _Rcr := by
use verschiebungPoly
simp only [aeval_verschiebung_poly', eq_self_iff_true, forall₃_true_iff]
#align witt_vector.verschiebung_fun_is_poly WittVector.verschiebungFun_isPoly
-- Porting note: we add this example as a verification that Lean 4's instance resolution
-- can handle what in Lean 3 we needed the `@[is_poly]` attribute to help with.
example (p : ℕ) (f : ⦃R : Type _⦄ → [CommRing R] → WittVector p R → WittVector p R) [IsPoly p f] :
IsPoly p (fun (R : Type*) (I : CommRing R) ↦ verschiebungFun ∘ (@f R I)) :=
inferInstance
variable {p}
noncomputable def verschiebung : 𝕎 R →+ 𝕎 R where
toFun := verschiebungFun
map_zero' := by
ext ⟨⟩ <;> rw [verschiebungFun_coeff] <;>
simp only [if_true, eq_self_iff_true, zero_coeff, ite_self]
map_add' := by
dsimp
ghost_calc _ _
rintro ⟨⟩ <;> -- Uses the dumb induction principle, hence adding `Nat.zero_eq` to ghost_simps.
ghost_simp
#align witt_vector.verschiebung WittVector.verschiebung
@[is_poly]
theorem verschiebung_isPoly : IsPoly p fun R _Rcr => @verschiebung p R hp _Rcr :=
verschiebungFun_isPoly p
#align witt_vector.verschiebung_is_poly WittVector.verschiebung_isPoly
@[simp]
| Mathlib/RingTheory/WittVector/Verschiebung.lean | 139 | 143 | theorem map_verschiebung (f : R →+* S) (x : 𝕎 R) :
map f (verschiebung x) = verschiebung (map f x) := by |
ext ⟨-, -⟩
· exact f.map_zero
· rfl
| [
" x.verschiebungFun.coeff n = if n = 0 then 0 else x.coeff (n - 1)",
" x.verschiebungFun.coeff 0 = 0",
" (ghostComponent 0) x.verschiebungFun = 0",
" (ghostComponent (n + 1)) x.verschiebungFun = ↑p * (ghostComponent n) x",
" ∑ i ∈ Finset.range (n + 1 + 1), ↑p ^ i * x.verschiebungFun.coeff i ^ p ^ (n + 1 - i... | [
" x.verschiebungFun.coeff n = if n = 0 then 0 else x.coeff (n - 1)",
" x.verschiebungFun.coeff 0 = 0",
" (ghostComponent 0) x.verschiebungFun = 0",
" (ghostComponent (n + 1)) x.verschiebungFun = ↑p * (ghostComponent n) x",
" ∑ i ∈ Finset.range (n + 1 + 1), ↑p ^ i * x.verschiebungFun.coeff i ^ p ^ (n + 1 - i... |
import Mathlib.Algebra.Order.Group.Abs
import Mathlib.Algebra.Order.Monoid.Unbundled.MinMax
#align_import algebra.order.group.min_max from "leanprover-community/mathlib"@"10b4e499f43088dd3bb7b5796184ad5216648ab1"
section
variable {α : Type*} [Group α] [LinearOrder α] [CovariantClass α α (· * ·) (· ≤ ·)]
-- TODO: This duplicates `oneLePart_div_leOnePart`
@[to_additive (attr := simp)]
theorem max_one_div_max_inv_one_eq_self (a : α) : max a 1 / max a⁻¹ 1 = a := by
rcases le_total a 1 with (h | h) <;> simp [h]
#align max_one_div_max_inv_one_eq_self max_one_div_max_inv_one_eq_self
#align max_zero_sub_max_neg_zero_eq_self max_zero_sub_max_neg_zero_eq_self
alias max_zero_sub_eq_self := max_zero_sub_max_neg_zero_eq_self
#align max_zero_sub_eq_self max_zero_sub_eq_self
@[to_additive]
lemma max_inv_one (a : α) : max a⁻¹ 1 = a⁻¹ * max a 1 := by
rw [eq_inv_mul_iff_mul_eq, ← eq_div_iff_mul_eq', max_one_div_max_inv_one_eq_self]
end
section LinearOrderedAddCommGroup
variable {α : Type*} [LinearOrderedAddCommGroup α] {a b c : α}
theorem max_sub_max_le_max (a b c d : α) : max a b - max c d ≤ max (a - c) (b - d) := by
simp only [sub_le_iff_le_add, max_le_iff]; constructor
· calc
a = a - c + c := (sub_add_cancel a c).symm
_ ≤ max (a - c) (b - d) + max c d := add_le_add (le_max_left _ _) (le_max_left _ _)
· calc
b = b - d + d := (sub_add_cancel b d).symm
_ ≤ max (a - c) (b - d) + max c d := add_le_add (le_max_right _ _) (le_max_right _ _)
#align max_sub_max_le_max max_sub_max_le_max
| Mathlib/Algebra/Order/Group/MinMax.lean | 96 | 100 | theorem abs_max_sub_max_le_max (a b c d : α) : |max a b - max c d| ≤ max |a - c| |b - d| := by |
refine abs_sub_le_iff.2 ⟨?_, ?_⟩
· exact (max_sub_max_le_max _ _ _ _).trans (max_le_max (le_abs_self _) (le_abs_self _))
· rw [abs_sub_comm a c, abs_sub_comm b d]
exact (max_sub_max_le_max _ _ _ _).trans (max_le_max (le_abs_self _) (le_abs_self _))
| [
" max a 1 / max a⁻¹ 1 = a",
" max a⁻¹ 1 = a⁻¹ * max a 1",
" max a b - max c d ≤ max (a - c) (b - d)",
" a ≤ max (a - c) (b - d) + max c d ∧ b ≤ max (a - c) (b - d) + max c d",
" a ≤ max (a - c) (b - d) + max c d",
" b ≤ max (a - c) (b - d) + max c d",
" |max a b - max c d| ≤ max |a - c| |b - d|",
" ma... | [
" max a 1 / max a⁻¹ 1 = a",
" max a⁻¹ 1 = a⁻¹ * max a 1",
" max a b - max c d ≤ max (a - c) (b - d)",
" a ≤ max (a - c) (b - d) + max c d ∧ b ≤ max (a - c) (b - d) + max c d",
" a ≤ max (a - c) (b - d) + max c d",
" b ≤ max (a - c) (b - d) + max c d",
" |max a b - max c d| ≤ max |a - c| |b - d|"
] |
import Mathlib.SetTheory.Ordinal.Arithmetic
import Mathlib.SetTheory.Ordinal.Exponential
#align_import set_theory.ordinal.cantor_normal_form from "leanprover-community/mathlib"@"991ff3b5269848f6dd942ae8e9dd3c946035dc8b"
noncomputable section
universe u
open List
namespace Ordinal
@[elab_as_elim]
noncomputable def CNFRec (b : Ordinal) {C : Ordinal → Sort*} (H0 : C 0)
(H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : ∀ o, C o := fun o ↦ by
by_cases h : o = 0
· rw [h]; exact H0
· exact H o h (CNFRec _ H0 H (o % b ^ log b o))
termination_by o => o
decreasing_by exact mod_opow_log_lt_self b h
set_option linter.uppercaseLean3 false in
#align ordinal.CNF_rec Ordinal.CNFRec
@[simp]
| Mathlib/SetTheory/Ordinal/CantorNormalForm.lean | 55 | 58 | theorem CNFRec_zero {C : Ordinal → Sort*} (b : Ordinal) (H0 : C 0)
(H : ∀ o, o ≠ 0 → C (o % b ^ log b o) → C o) : @CNFRec b C H0 H 0 = H0 := by |
rw [CNFRec, dif_pos rfl]
rfl
| [
" C o",
" C 0",
" (invImage (fun x => x) wellFoundedRelation).1 (o % b ^ b.log o) o",
" b.CNFRec H0 H 0 = H0",
" ⋯.mpr H0 = H0"
] | [
" C o",
" C 0",
" (invImage (fun x => x) wellFoundedRelation).1 (o % b ^ b.log o) o",
" b.CNFRec H0 H 0 = H0"
] |
import Mathlib.Analysis.Calculus.LocalExtr.Rolle
import Mathlib.Analysis.Calculus.Deriv.Polynomial
import Mathlib.Topology.Algebra.Polynomial
#align_import analysis.calculus.local_extr from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
namespace Polynomial
theorem card_roots_toFinset_le_card_roots_derivative_diff_roots_succ (p : ℝ[X]) :
p.roots.toFinset.card ≤ (p.derivative.roots.toFinset \ p.roots.toFinset).card + 1 := by
rcases eq_or_ne (derivative p) 0 with hp' | hp'
· rw [eq_C_of_derivative_eq_zero hp', roots_C, Multiset.toFinset_zero, Finset.card_empty]
exact zero_le _
have hp : p ≠ 0 := ne_of_apply_ne derivative (by rwa [derivative_zero])
refine Finset.card_le_diff_of_interleaved fun x hx y hy hxy hxy' => ?_
rw [Multiset.mem_toFinset, mem_roots hp] at hx hy
obtain ⟨z, hz1, hz2⟩ := exists_deriv_eq_zero hxy p.continuousOn (hx.trans hy.symm)
refine ⟨z, ?_, hz1⟩
rwa [Multiset.mem_toFinset, mem_roots hp', IsRoot, ← p.deriv]
#align polynomial.card_roots_to_finset_le_card_roots_derivative_diff_roots_succ Polynomial.card_roots_toFinset_le_card_roots_derivative_diff_roots_succ
theorem card_roots_toFinset_le_derivative (p : ℝ[X]) :
p.roots.toFinset.card ≤ p.derivative.roots.toFinset.card + 1 :=
p.card_roots_toFinset_le_card_roots_derivative_diff_roots_succ.trans <|
add_le_add_right (Finset.card_mono Finset.sdiff_subset) _
#align polynomial.card_roots_to_finset_le_derivative Polynomial.card_roots_toFinset_le_derivative
| Mathlib/Analysis/Calculus/LocalExtr/Polynomial.lean | 59 | 86 | theorem card_roots_le_derivative (p : ℝ[X]) :
Multiset.card p.roots ≤ Multiset.card (derivative p).roots + 1 :=
calc
Multiset.card p.roots = ∑ x ∈ p.roots.toFinset, p.roots.count x :=
(Multiset.toFinset_sum_count_eq _).symm
_ = ∑ x ∈ p.roots.toFinset, (p.roots.count x - 1 + 1) :=
(Eq.symm <| Finset.sum_congr rfl fun x hx => tsub_add_cancel_of_le <|
Nat.succ_le_iff.2 <| Multiset.count_pos.2 <| Multiset.mem_toFinset.1 hx)
_ = (∑ x ∈ p.roots.toFinset, (p.rootMultiplicity x - 1)) + p.roots.toFinset.card := by |
simp only [Finset.sum_add_distrib, Finset.card_eq_sum_ones, count_roots]
_ ≤ (∑ x ∈ p.roots.toFinset, p.derivative.rootMultiplicity x) +
((p.derivative.roots.toFinset \ p.roots.toFinset).card + 1) :=
(add_le_add
(Finset.sum_le_sum fun x _ => rootMultiplicity_sub_one_le_derivative_rootMultiplicity _ _)
p.card_roots_toFinset_le_card_roots_derivative_diff_roots_succ)
_ ≤ (∑ x ∈ p.roots.toFinset, p.derivative.roots.count x) +
((∑ x ∈ p.derivative.roots.toFinset \ p.roots.toFinset,
p.derivative.roots.count x) + 1) := by
simp only [← count_roots]
refine add_le_add_left (add_le_add_right ((Finset.card_eq_sum_ones _).trans_le ?_) _) _
refine Finset.sum_le_sum fun x hx => Nat.succ_le_iff.2 <| ?_
rw [Multiset.count_pos, ← Multiset.mem_toFinset]
exact (Finset.mem_sdiff.1 hx).1
_ = Multiset.card (derivative p).roots + 1 := by
rw [← add_assoc, ← Finset.sum_union Finset.disjoint_sdiff, Finset.union_sdiff_self_eq_union, ←
Multiset.toFinset_sum_count_eq, ← Finset.sum_subset Finset.subset_union_right]
intro x _ hx₂
simpa only [Multiset.mem_toFinset, Multiset.count_eq_zero] using hx₂
| [
" p.roots.toFinset.card ≤ ((derivative p).roots.toFinset \\ p.roots.toFinset).card + 1",
" 0 ≤ ((derivative (C (p.coeff 0))).roots.toFinset \\ ∅).card + 1",
" derivative p ≠ derivative 0",
" ∃ z ∈ (derivative p).roots.toFinset, x < z ∧ z < y",
" z ∈ (derivative p).roots.toFinset",
" ∑ x ∈ p.roots.toFinset... | [
" p.roots.toFinset.card ≤ ((derivative p).roots.toFinset \\ p.roots.toFinset).card + 1",
" 0 ≤ ((derivative (C (p.coeff 0))).roots.toFinset \\ ∅).card + 1",
" derivative p ≠ derivative 0",
" ∃ z ∈ (derivative p).roots.toFinset, x < z ∧ z < y",
" z ∈ (derivative p).roots.toFinset",
" ∑ x ∈ p.roots.toFinset... |
import Mathlib.Algebra.Quaternion
import Mathlib.Tactic.Ring
#align_import algebra.quaternion_basis from "leanprover-community/mathlib"@"3aa5b8a9ed7a7cabd36e6e1d022c9858ab8a8c2d"
open Quaternion
namespace QuaternionAlgebra
structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (c₁ c₂ : R) where
(i j k : A)
i_mul_i : i * i = c₁ • (1 : A)
j_mul_j : j * j = c₂ • (1 : A)
i_mul_j : i * j = k
j_mul_i : j * i = -k
#align quaternion_algebra.basis QuaternionAlgebra.Basis
variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B]
variable {c₁ c₂ : R}
namespace Basis
@[ext]
protected theorem ext ⦃q₁ q₂ : Basis A c₁ c₂⦄ (hi : q₁.i = q₂.i) (hj : q₁.j = q₂.j) : q₁ = q₂ := by
cases q₁; rename_i q₁_i_mul_j _
cases q₂; rename_i q₂_i_mul_j _
congr
rw [← q₁_i_mul_j, ← q₂_i_mul_j]
congr
#align quaternion_algebra.basis.ext QuaternionAlgebra.Basis.ext
variable (R)
@[simps i j k]
protected def self : Basis ℍ[R,c₁,c₂] c₁ c₂ where
i := ⟨0, 1, 0, 0⟩
i_mul_i := by ext <;> simp
j := ⟨0, 0, 1, 0⟩
j_mul_j := by ext <;> simp
k := ⟨0, 0, 0, 1⟩
i_mul_j := by ext <;> simp
j_mul_i := by ext <;> simp
#align quaternion_algebra.basis.self QuaternionAlgebra.Basis.self
variable {R}
instance : Inhabited (Basis ℍ[R,c₁,c₂] c₁ c₂) :=
⟨Basis.self R⟩
variable (q : Basis A c₁ c₂)
attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i
@[simp]
theorem i_mul_k : q.i * q.k = c₁ • q.j := by
rw [← i_mul_j, ← mul_assoc, i_mul_i, smul_mul_assoc, one_mul]
#align quaternion_algebra.basis.i_mul_k QuaternionAlgebra.Basis.i_mul_k
@[simp]
theorem k_mul_i : q.k * q.i = -c₁ • q.j := by
rw [← i_mul_j, mul_assoc, j_mul_i, mul_neg, i_mul_k, neg_smul]
#align quaternion_algebra.basis.k_mul_i QuaternionAlgebra.Basis.k_mul_i
@[simp]
| Mathlib/Algebra/QuaternionBasis.lean | 94 | 95 | theorem k_mul_j : q.k * q.j = c₂ • q.i := by |
rw [← i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one]
| [
" q₁ = q₂",
" { i := i✝, j := j✝, k := k✝, i_mul_i := i_mul_i✝, j_mul_j := j_mul_j✝, i_mul_j := i_mul_j✝, j_mul_i := j_mul_i✝ } = q₂",
" { i := i✝, j := j✝, k := k✝, i_mul_i := i_mul_i✝, j_mul_j := j_mul_j✝, i_mul_j := q₁_i_mul_j, j_mul_i := j_mul_i✝ } =\n q₂",
" { i := i✝¹, j := j✝¹, k := k✝¹, i_mul_i := ... | [
" q₁ = q₂",
" { i := i✝, j := j✝, k := k✝, i_mul_i := i_mul_i✝, j_mul_j := j_mul_j✝, i_mul_j := i_mul_j✝, j_mul_i := j_mul_i✝ } = q₂",
" { i := i✝, j := j✝, k := k✝, i_mul_i := i_mul_i✝, j_mul_j := j_mul_j✝, i_mul_j := q₁_i_mul_j, j_mul_i := j_mul_i✝ } =\n q₂",
" { i := i✝¹, j := j✝¹, k := k✝¹, i_mul_i := ... |
import Mathlib.Probability.Martingale.Convergence
import Mathlib.Probability.Martingale.OptionalStopping
import Mathlib.Probability.Martingale.Centering
#align_import probability.martingale.borel_cantelli from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
open Filter
open scoped NNReal ENNReal MeasureTheory ProbabilityTheory BigOperators Topology
namespace MeasureTheory
variable {Ω : Type*} {m0 : MeasurableSpace Ω} {μ : Measure Ω} {ℱ : Filtration ℕ m0} {f : ℕ → Ω → ℝ}
{ω : Ω}
-- TODO: `leastGE` should be defined taking values in `WithTop ℕ` once the `stoppedProcess`
-- refactor is complete
noncomputable def leastGE (f : ℕ → Ω → ℝ) (r : ℝ) (n : ℕ) :=
hitting f (Set.Ici r) 0 n
#align measure_theory.least_ge MeasureTheory.leastGE
theorem Adapted.isStoppingTime_leastGE (r : ℝ) (n : ℕ) (hf : Adapted ℱ f) :
IsStoppingTime ℱ (leastGE f r n) :=
hitting_isStoppingTime hf measurableSet_Ici
#align measure_theory.adapted.is_stopping_time_least_ge MeasureTheory.Adapted.isStoppingTime_leastGE
theorem leastGE_le {i : ℕ} {r : ℝ} (ω : Ω) : leastGE f r i ω ≤ i :=
hitting_le ω
#align measure_theory.least_ge_le MeasureTheory.leastGE_le
-- The following four lemmas shows `leastGE` behaves like a stopped process. Ideally we should
-- define `leastGE` as a stopping time and take its stopped process. However, we can't do that
-- with our current definition since a stopping time takes only finite indicies. An upcomming
-- refactor should hopefully make it possible to have stopping times taking infinity as a value
theorem leastGE_mono {n m : ℕ} (hnm : n ≤ m) (r : ℝ) (ω : Ω) : leastGE f r n ω ≤ leastGE f r m ω :=
hitting_mono hnm
#align measure_theory.least_ge_mono MeasureTheory.leastGE_mono
theorem leastGE_eq_min (π : Ω → ℕ) (r : ℝ) (ω : Ω) {n : ℕ} (hπn : ∀ ω, π ω ≤ n) :
leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω) := by
classical
refine le_antisymm (le_min (leastGE_le _) (leastGE_mono (hπn ω) r ω)) ?_
by_cases hle : π ω ≤ leastGE f r n ω
· rw [min_eq_left hle, leastGE]
by_cases h : ∃ j ∈ Set.Icc 0 (π ω), f j ω ∈ Set.Ici r
· refine hle.trans (Eq.le ?_)
rw [leastGE, ← hitting_eq_hitting_of_exists (hπn ω) h]
· simp only [hitting, if_neg h, le_rfl]
· rw [min_eq_right (not_le.1 hle).le, leastGE, leastGE, ←
hitting_eq_hitting_of_exists (hπn ω) _]
rw [not_le, leastGE, hitting_lt_iff _ (hπn ω)] at hle
exact
let ⟨j, hj₁, hj₂⟩ := hle
⟨j, ⟨hj₁.1, hj₁.2.le⟩, hj₂⟩
#align measure_theory.least_ge_eq_min MeasureTheory.leastGE_eq_min
theorem stoppedValue_stoppedValue_leastGE (f : ℕ → Ω → ℝ) (π : Ω → ℕ) (r : ℝ) {n : ℕ}
(hπn : ∀ ω, π ω ≤ n) : stoppedValue (fun i => stoppedValue f (leastGE f r i)) π =
stoppedValue (stoppedProcess f (leastGE f r n)) π := by
ext1 ω
simp (config := { unfoldPartialApp := true }) only [stoppedProcess, stoppedValue]
rw [leastGE_eq_min _ _ _ hπn]
#align measure_theory.stopped_value_stopped_value_least_ge MeasureTheory.stoppedValue_stoppedValue_leastGE
theorem Submartingale.stoppedValue_leastGE [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ) (r : ℝ) :
Submartingale (fun i => stoppedValue f (leastGE f r i)) ℱ μ := by
rw [submartingale_iff_expected_stoppedValue_mono]
· intro σ π hσ hπ hσ_le_π hπ_bdd
obtain ⟨n, hπ_le_n⟩ := hπ_bdd
simp_rw [stoppedValue_stoppedValue_leastGE f σ r fun i => (hσ_le_π i).trans (hπ_le_n i)]
simp_rw [stoppedValue_stoppedValue_leastGE f π r hπ_le_n]
refine hf.expected_stoppedValue_mono ?_ ?_ ?_ fun ω => (min_le_left _ _).trans (hπ_le_n ω)
· exact hσ.min (hf.adapted.isStoppingTime_leastGE _ _)
· exact hπ.min (hf.adapted.isStoppingTime_leastGE _ _)
· exact fun ω => min_le_min (hσ_le_π ω) le_rfl
· exact fun i => stronglyMeasurable_stoppedValue_of_le hf.adapted.progMeasurable_of_discrete
(hf.adapted.isStoppingTime_leastGE _ _) leastGE_le
· exact fun i => integrable_stoppedValue _ (hf.adapted.isStoppingTime_leastGE _ _) hf.integrable
leastGE_le
#align measure_theory.submartingale.stopped_value_least_ge MeasureTheory.Submartingale.stoppedValue_leastGE
variable {r : ℝ} {R : ℝ≥0}
| Mathlib/Probability/Martingale/BorelCantelli.lean | 120 | 132 | theorem norm_stoppedValue_leastGE_le (hr : 0 ≤ r) (hf0 : f 0 = 0)
(hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) (i : ℕ) :
∀ᵐ ω ∂μ, stoppedValue f (leastGE f r i) ω ≤ r + R := by |
filter_upwards [hbdd] with ω hbddω
change f (leastGE f r i ω) ω ≤ r + R
by_cases heq : leastGE f r i ω = 0
· rw [heq, hf0, Pi.zero_apply]
exact add_nonneg hr R.coe_nonneg
· obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero heq
rw [hk, add_comm, ← sub_le_iff_le_add]
have := not_mem_of_lt_hitting (hk.symm ▸ k.lt_succ_self : k < leastGE f r i ω) (zero_le _)
simp only [Set.mem_union, Set.mem_Iic, Set.mem_Ici, not_or, not_le] at this
exact (sub_lt_sub_left this _).le.trans ((le_abs_self _).trans (hbddω _))
| [
" leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω)",
" min (π ω) (leastGE f r n ω) ≤ leastGE f r (π ω) ω",
" π ω ≤ hitting f (Set.Ici r) 0 (π ω) ω",
" leastGE f r n ω = hitting f (Set.Ici r) 0 (π ω) ω",
" ∃ j ∈ Set.Icc 0 (π ω), f j ω ∈ Set.Ici r",
" stoppedValue (fun i => stoppedValue f (leastGE f r i)) ... | [
" leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω)",
" min (π ω) (leastGE f r n ω) ≤ leastGE f r (π ω) ω",
" π ω ≤ hitting f (Set.Ici r) 0 (π ω) ω",
" leastGE f r n ω = hitting f (Set.Ici r) 0 (π ω) ω",
" ∃ j ∈ Set.Icc 0 (π ω), f j ω ∈ Set.Ici r",
" stoppedValue (fun i => stoppedValue f (leastGE f r i)) ... |
import Mathlib.Analysis.InnerProductSpace.GramSchmidtOrtho
import Mathlib.LinearAlgebra.Orientation
#align_import analysis.inner_product_space.orientation from "leanprover-community/mathlib"@"bd65478311e4dfd41f48bf38c7e3b02fb75d0163"
noncomputable section
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
open FiniteDimensional
open scoped RealInnerProductSpace
namespace OrthonormalBasis
variable {ι : Type*} [Fintype ι] [DecidableEq ι] [ne : Nonempty ι] (e f : OrthonormalBasis ι ℝ E)
(x : Orientation ℝ E ι)
theorem det_to_matrix_orthonormalBasis_of_same_orientation
(h : e.toBasis.orientation = f.toBasis.orientation) : e.toBasis.det f = 1 := by
apply (e.det_to_matrix_orthonormalBasis_real f).resolve_right
have : 0 < e.toBasis.det f := by
rw [e.toBasis.orientation_eq_iff_det_pos] at h
simpa using h
linarith
#align orthonormal_basis.det_to_matrix_orthonormal_basis_of_same_orientation OrthonormalBasis.det_to_matrix_orthonormalBasis_of_same_orientation
theorem det_to_matrix_orthonormalBasis_of_opposite_orientation
(h : e.toBasis.orientation ≠ f.toBasis.orientation) : e.toBasis.det f = -1 := by
contrapose! h
simp [e.toBasis.orientation_eq_iff_det_pos,
(e.det_to_matrix_orthonormalBasis_real f).resolve_right h]
#align orthonormal_basis.det_to_matrix_orthonormal_basis_of_opposite_orientation OrthonormalBasis.det_to_matrix_orthonormalBasis_of_opposite_orientation
variable {e f}
theorem same_orientation_iff_det_eq_det :
e.toBasis.det = f.toBasis.det ↔ e.toBasis.orientation = f.toBasis.orientation := by
constructor
· intro h
dsimp [Basis.orientation]
congr
· intro h
rw [e.toBasis.det.eq_smul_basis_det f.toBasis]
simp [e.det_to_matrix_orthonormalBasis_of_same_orientation f h]
#align orthonormal_basis.same_orientation_iff_det_eq_det OrthonormalBasis.same_orientation_iff_det_eq_det
variable (e f)
theorem det_eq_neg_det_of_opposite_orientation (h : e.toBasis.orientation ≠ f.toBasis.orientation) :
e.toBasis.det = -f.toBasis.det := by
rw [e.toBasis.det.eq_smul_basis_det f.toBasis]
-- Porting note: added `neg_one_smul` with explicit type
simp [e.det_to_matrix_orthonormalBasis_of_opposite_orientation f h,
neg_one_smul ℝ (M := E [⋀^ι]→ₗ[ℝ] ℝ)]
#align orthonormal_basis.det_eq_neg_det_of_opposite_orientation OrthonormalBasis.det_eq_neg_det_of_opposite_orientation
section AdjustToOrientation
| Mathlib/Analysis/InnerProductSpace/Orientation.lean | 103 | 105 | theorem orthonormal_adjustToOrientation : Orthonormal ℝ (e.toBasis.adjustToOrientation x) := by |
apply e.orthonormal.orthonormal_of_forall_eq_or_eq_neg
simpa using e.toBasis.adjustToOrientation_apply_eq_or_eq_neg x
| [
" e.toBasis.det ⇑f = 1",
" ¬e.toBasis.det ⇑f = -1",
" 0 < e.toBasis.det ⇑f",
" e.toBasis.det ⇑f = -1",
" e.toBasis.orientation = f.toBasis.orientation",
" e.toBasis.det = f.toBasis.det ↔ e.toBasis.orientation = f.toBasis.orientation",
" e.toBasis.det = f.toBasis.det → e.toBasis.orientation = f.toBasis.o... | [
" e.toBasis.det ⇑f = 1",
" ¬e.toBasis.det ⇑f = -1",
" 0 < e.toBasis.det ⇑f",
" e.toBasis.det ⇑f = -1",
" e.toBasis.orientation = f.toBasis.orientation",
" e.toBasis.det = f.toBasis.det ↔ e.toBasis.orientation = f.toBasis.orientation",
" e.toBasis.det = f.toBasis.det → e.toBasis.orientation = f.toBasis.o... |
import Mathlib.Algebra.Module.Equiv
#align_import linear_algebra.general_linear_group from "leanprover-community/mathlib"@"2705404e701abc6b3127da906f40bae062a169c9"
variable (R M : Type*)
namespace LinearMap
variable [Semiring R] [AddCommMonoid M] [Module R M]
abbrev GeneralLinearGroup :=
(M →ₗ[R] M)ˣ
#align linear_map.general_linear_group LinearMap.GeneralLinearGroup
namespace GeneralLinearGroup
variable {R M}
def toLinearEquiv (f : GeneralLinearGroup R M) : M ≃ₗ[R] M :=
{ f.val with
invFun := f.inv.toFun
left_inv := fun m ↦ show (f.inv * f.val) m = m by erw [f.inv_val]; simp
right_inv := fun m ↦ show (f.val * f.inv) m = m by erw [f.val_inv]; simp }
#align linear_map.general_linear_group.to_linear_equiv LinearMap.GeneralLinearGroup.toLinearEquiv
def ofLinearEquiv (f : M ≃ₗ[R] M) : GeneralLinearGroup R M where
val := f
inv := (f.symm : M →ₗ[R] M)
val_inv := LinearMap.ext fun _ ↦ f.apply_symm_apply _
inv_val := LinearMap.ext fun _ ↦ f.symm_apply_apply _
#align linear_map.general_linear_group.of_linear_equiv LinearMap.GeneralLinearGroup.ofLinearEquiv
variable (R M)
def generalLinearEquiv : GeneralLinearGroup R M ≃* M ≃ₗ[R] M where
toFun := toLinearEquiv
invFun := ofLinearEquiv
left_inv f := by ext; rfl
right_inv f := by ext; rfl
map_mul' x y := by ext; rfl
#align linear_map.general_linear_group.general_linear_equiv LinearMap.GeneralLinearGroup.generalLinearEquiv
@[simp]
| Mathlib/LinearAlgebra/GeneralLinearGroup.lean | 68 | 69 | theorem generalLinearEquiv_to_linearMap (f : GeneralLinearGroup R M) :
(generalLinearEquiv R M f : M →ₗ[R] M) = f := by | ext; rfl
| [
" (f.inv * ↑f) m = m",
" 1 m = m",
" (↑f * f.inv) m = m",
" ofLinearEquiv f.toLinearEquiv = f",
" ↑(ofLinearEquiv f.toLinearEquiv) x✝ = ↑f x✝",
" (ofLinearEquiv f).toLinearEquiv = f",
" (ofLinearEquiv f).toLinearEquiv x✝ = f x✝",
" { toFun := toLinearEquiv, invFun := ofLinearEquiv, left_inv := ⋯, righ... | [
" (f.inv * ↑f) m = m",
" 1 m = m",
" (↑f * f.inv) m = m",
" ofLinearEquiv f.toLinearEquiv = f",
" ↑(ofLinearEquiv f.toLinearEquiv) x✝ = ↑f x✝",
" (ofLinearEquiv f).toLinearEquiv = f",
" (ofLinearEquiv f).toLinearEquiv x✝ = f x✝",
" { toFun := toLinearEquiv, invFun := ofLinearEquiv, left_inv := ⋯, righ... |
import Mathlib.MeasureTheory.Constructions.Prod.Basic
import Mathlib.MeasureTheory.Group.Measure
import Mathlib.Topology.Constructions
#align_import measure_theory.constructions.pi from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
noncomputable section
open Function Set MeasureTheory.OuterMeasure Filter MeasurableSpace Encodable
open scoped Classical Topology ENNReal
universe u v
variable {ι ι' : Type*} {α : ι → Type*}
theorem IsPiSystem.pi {C : ∀ i, Set (Set (α i))} (hC : ∀ i, IsPiSystem (C i)) :
IsPiSystem (pi univ '' pi univ C) := by
rintro _ ⟨s₁, hs₁, rfl⟩ _ ⟨s₂, hs₂, rfl⟩ hst
rw [← pi_inter_distrib] at hst ⊢; rw [univ_pi_nonempty_iff] at hst
exact mem_image_of_mem _ fun i _ => hC i _ (hs₁ i (mem_univ i)) _ (hs₂ i (mem_univ i)) (hst i)
#align is_pi_system.pi IsPiSystem.pi
theorem isPiSystem_pi [∀ i, MeasurableSpace (α i)] :
IsPiSystem (pi univ '' pi univ fun i => { s : Set (α i) | MeasurableSet s }) :=
IsPiSystem.pi fun _ => isPiSystem_measurableSet
#align is_pi_system_pi isPiSystem_pi
section Finite
variable [Finite ι] [Finite ι']
theorem IsCountablySpanning.pi {C : ∀ i, Set (Set (α i))} (hC : ∀ i, IsCountablySpanning (C i)) :
IsCountablySpanning (pi univ '' pi univ C) := by
choose s h1s h2s using hC
cases nonempty_encodable (ι → ℕ)
let e : ℕ → ι → ℕ := fun n => (@decode (ι → ℕ) _ n).iget
refine ⟨fun n => Set.pi univ fun i => s i (e n i), fun n =>
mem_image_of_mem _ fun i _ => h1s i _, ?_⟩
simp_rw [(surjective_decode_iget (ι → ℕ)).iUnion_comp fun x => Set.pi univ fun i => s i (x i),
iUnion_univ_pi s, h2s, pi_univ]
#align is_countably_spanning.pi IsCountablySpanning.pi
| Mathlib/MeasureTheory/Constructions/Pi.lean | 100 | 127 | theorem generateFrom_pi_eq {C : ∀ i, Set (Set (α i))} (hC : ∀ i, IsCountablySpanning (C i)) :
(@MeasurableSpace.pi _ _ fun i => generateFrom (C i)) =
generateFrom (pi univ '' pi univ C) := by |
cases nonempty_encodable ι
apply le_antisymm
· refine iSup_le ?_; intro i; rw [comap_generateFrom]
apply generateFrom_le; rintro _ ⟨s, hs, rfl⟩; dsimp
choose t h1t h2t using hC
simp_rw [eval_preimage, ← h2t]
rw [← @iUnion_const _ ℕ _ s]
have : Set.pi univ (update (fun i' : ι => iUnion (t i')) i (⋃ _ : ℕ, s)) =
Set.pi univ fun k => ⋃ j : ℕ,
@update ι (fun i' => Set (α i')) _ (fun i' => t i' j) i s k := by
ext; simp_rw [mem_univ_pi]; apply forall_congr'; intro i'
by_cases h : i' = i
· subst h; simp
· rw [← Ne] at h; simp [h]
rw [this, ← iUnion_univ_pi]
apply MeasurableSet.iUnion
intro n; apply measurableSet_generateFrom
apply mem_image_of_mem; intro j _; dsimp only
by_cases h : j = i
· subst h; rwa [update_same]
· rw [update_noteq h]; apply h1t
· apply generateFrom_le; rintro _ ⟨s, hs, rfl⟩
rw [univ_pi_eq_iInter]; apply MeasurableSet.iInter; intro i
apply @measurable_pi_apply _ _ (fun i => generateFrom (C i))
exact measurableSet_generateFrom (hs i (mem_univ i))
| [
" IsPiSystem (univ.pi '' univ.pi C)",
" univ.pi s₁ ∩ univ.pi s₂ ∈ univ.pi '' univ.pi C",
" (univ.pi fun i => s₁ i ∩ s₂ i) ∈ univ.pi '' univ.pi C",
" IsCountablySpanning (univ.pi '' univ.pi C)",
" ⋃ n, (fun n => univ.pi fun i => s i (e n i)) n = univ",
" MeasurableSpace.pi = generateFrom (univ.pi '' univ.p... | [
" IsPiSystem (univ.pi '' univ.pi C)",
" univ.pi s₁ ∩ univ.pi s₂ ∈ univ.pi '' univ.pi C",
" (univ.pi fun i => s₁ i ∩ s₂ i) ∈ univ.pi '' univ.pi C",
" IsCountablySpanning (univ.pi '' univ.pi C)",
" ⋃ n, (fun n => univ.pi fun i => s i (e n i)) n = univ",
" MeasurableSpace.pi = generateFrom (univ.pi '' univ.p... |
import Mathlib.Algebra.Order.Ring.Nat
import Mathlib.Algebra.Order.Monoid.WithTop
#align_import data.nat.with_bot from "leanprover-community/mathlib"@"966e0cf0685c9cedf8a3283ac69eef4d5f2eaca2"
namespace Nat
namespace WithBot
instance : WellFoundedRelation (WithBot ℕ) where
rel := (· < ·)
wf := IsWellFounded.wf
theorem add_eq_zero_iff {n m : WithBot ℕ} : n + m = 0 ↔ n = 0 ∧ m = 0 := by
rcases n, m with ⟨_ | _, _ | _⟩
repeat (· exact ⟨fun h => Option.noConfusion h, fun h => Option.noConfusion h.1⟩)
· exact ⟨fun h => Option.noConfusion h, fun h => Option.noConfusion h.2⟩
repeat erw [WithBot.coe_eq_coe]
exact add_eq_zero_iff' (zero_le _) (zero_le _)
#align nat.with_bot.add_eq_zero_iff Nat.WithBot.add_eq_zero_iff
theorem add_eq_one_iff {n m : WithBot ℕ} : n + m = 1 ↔ n = 0 ∧ m = 1 ∨ n = 1 ∧ m = 0 := by
rcases n, m with ⟨_ | _, _ | _⟩
repeat refine ⟨fun h => Option.noConfusion h, fun h => ?_⟩;
aesop (simp_config := { decide := true })
repeat erw [WithBot.coe_eq_coe]
exact Nat.add_eq_one_iff
#align nat.with_bot.add_eq_one_iff Nat.WithBot.add_eq_one_iff
theorem add_eq_two_iff {n m : WithBot ℕ} :
n + m = 2 ↔ n = 0 ∧ m = 2 ∨ n = 1 ∧ m = 1 ∨ n = 2 ∧ m = 0 := by
rcases n, m with ⟨_ | _, _ | _⟩
repeat refine ⟨fun h => Option.noConfusion h, fun h => ?_⟩;
aesop (simp_config := { decide := true })
repeat erw [WithBot.coe_eq_coe]
exact Nat.add_eq_two_iff
#align nat.with_bot.add_eq_two_iff Nat.WithBot.add_eq_two_iff
theorem add_eq_three_iff {n m : WithBot ℕ} :
n + m = 3 ↔ n = 0 ∧ m = 3 ∨ n = 1 ∧ m = 2 ∨ n = 2 ∧ m = 1 ∨ n = 3 ∧ m = 0 := by
rcases n, m with ⟨_ | _, _ | _⟩
repeat refine ⟨fun h => Option.noConfusion h, fun h => ?_⟩;
aesop (simp_config := { decide := true })
repeat erw [WithBot.coe_eq_coe]
exact Nat.add_eq_three_iff
#align nat.with_bot.add_eq_three_iff Nat.WithBot.add_eq_three_iff
theorem coe_nonneg {n : ℕ} : 0 ≤ (n : WithBot ℕ) := by
rw [← WithBot.coe_zero]
exact WithBot.coe_le_coe.mpr (Nat.zero_le n)
#align nat.with_bot.coe_nonneg Nat.WithBot.coe_nonneg
@[simp]
theorem lt_zero_iff {n : WithBot ℕ} : n < 0 ↔ n = ⊥ := WithBot.lt_coe_bot
#align nat.with_bot.lt_zero_iff Nat.WithBot.lt_zero_iff
| Mathlib/Data/Nat/WithBot.lean | 70 | 74 | theorem one_le_iff_zero_lt {x : WithBot ℕ} : 1 ≤ x ↔ 0 < x := by |
refine ⟨fun h => lt_of_lt_of_le (WithBot.coe_lt_coe.mpr zero_lt_one) h, fun h => ?_⟩
induction x
· exact (not_lt_bot h).elim
· exact WithBot.coe_le_coe.mpr (Nat.succ_le_iff.mpr (WithBot.coe_lt_coe.mp h))
| [
" n + m = 0 ↔ n = 0 ∧ m = 0",
" some val✝¹ + some val✝ = 0 ↔ some val✝¹ = 0 ∧ some val✝ = 0",
" none + none = 0 ↔ none = 0 ∧ none = 0",
" none + some val✝ = 0 ↔ none = 0 ∧ some val✝ = 0",
" some val✝ + none = 0 ↔ some val✝ = 0 ∧ none = 0",
" (fun x x_1 => x + x_1) val✝¹ val✝ = 0 ↔ some val✝¹ = 0 ∧ some va... | [
" n + m = 0 ↔ n = 0 ∧ m = 0",
" some val✝¹ + some val✝ = 0 ↔ some val✝¹ = 0 ∧ some val✝ = 0",
" none + none = 0 ↔ none = 0 ∧ none = 0",
" none + some val✝ = 0 ↔ none = 0 ∧ some val✝ = 0",
" some val✝ + none = 0 ↔ some val✝ = 0 ∧ none = 0",
" (fun x x_1 => x + x_1) val✝¹ val✝ = 0 ↔ some val✝¹ = 0 ∧ some va... |
import Lean.Elab.Tactic.Location
import Mathlib.Logic.Basic
import Mathlib.Init.Order.Defs
import Mathlib.Tactic.Conv
import Mathlib.Init.Set
import Lean.Elab.Tactic.Location
set_option autoImplicit true
namespace Mathlib.Tactic.PushNeg
open Lean Meta Elab.Tactic Parser.Tactic
variable (p q : Prop) (s : α → Prop)
theorem not_not_eq : (¬ ¬ p) = p := propext not_not
theorem not_and_eq : (¬ (p ∧ q)) = (p → ¬ q) := propext not_and
theorem not_and_or_eq : (¬ (p ∧ q)) = (¬ p ∨ ¬ q) := propext not_and_or
theorem not_or_eq : (¬ (p ∨ q)) = (¬ p ∧ ¬ q) := propext not_or
theorem not_forall_eq : (¬ ∀ x, s x) = (∃ x, ¬ s x) := propext not_forall
theorem not_exists_eq : (¬ ∃ x, s x) = (∀ x, ¬ s x) := propext not_exists
theorem not_implies_eq : (¬ (p → q)) = (p ∧ ¬ q) := propext Classical.not_imp
theorem not_ne_eq (x y : α) : (¬ (x ≠ y)) = (x = y) := ne_eq x y ▸ not_not_eq _
theorem not_iff : (¬ (p ↔ q)) = ((p ∧ ¬ q) ∨ (¬ p ∧ q)) := propext <|
_root_.not_iff.trans <| iff_iff_and_or_not_and_not.trans <| by rw [not_not, or_comm]
variable {β : Type u} [LinearOrder β]
theorem not_le_eq (a b : β) : (¬ (a ≤ b)) = (b < a) := propext not_le
theorem not_lt_eq (a b : β) : (¬ (a < b)) = (b ≤ a) := propext not_lt
theorem not_ge_eq (a b : β) : (¬ (a ≥ b)) = (a < b) := propext not_le
theorem not_gt_eq (a b : β) : (¬ (a > b)) = (a ≤ b) := propext not_lt
theorem not_nonempty_eq (s : Set γ) : (¬ s.Nonempty) = (s = ∅) := by
have A : ∀ (x : γ), ¬(x ∈ (∅ : Set γ)) := fun x ↦ id
simp only [Set.Nonempty, not_exists, eq_iff_iff]
exact ⟨fun h ↦ Set.ext (fun x ↦ by simp only [h x, false_iff, A]), fun h ↦ by rwa [h]⟩
| Mathlib/Tactic/PushNeg.lean | 44 | 45 | theorem ne_empty_eq_nonempty (s : Set γ) : (s ≠ ∅) = s.Nonempty := by |
rw [ne_eq, ← not_nonempty_eq s, not_not]
| [
" ¬p ∧ q ∨ ¬¬p ∧ ¬q ↔ p ∧ ¬q ∨ ¬p ∧ q",
" (¬s.Nonempty) = (s = ∅)",
" (∀ (x : γ), ¬x ∈ s) ↔ s = ∅",
" x ∈ s ↔ x ∈ ∅",
" ∀ (x : γ), ¬x ∈ s",
" (s ≠ ∅) = s.Nonempty"
] | [
" ¬p ∧ q ∨ ¬¬p ∧ ¬q ↔ p ∧ ¬q ∨ ¬p ∧ q",
" (¬s.Nonempty) = (s = ∅)",
" (∀ (x : γ), ¬x ∈ s) ↔ s = ∅",
" x ∈ s ↔ x ∈ ∅",
" ∀ (x : γ), ¬x ∈ s",
" (s ≠ ∅) = s.Nonempty"
] |
import Mathlib.SetTheory.Cardinal.Finite
#align_import data.set.ncard from "leanprover-community/mathlib"@"74c2af38a828107941029b03839882c5c6f87a04"
namespace Set
variable {α β : Type*} {s t : Set α}
noncomputable def encard (s : Set α) : ℕ∞ := PartENat.withTopEquiv (PartENat.card s)
@[simp] theorem encard_univ_coe (s : Set α) : encard (univ : Set s) = encard s := by
rw [encard, encard, PartENat.card_congr (Equiv.Set.univ ↑s)]
theorem encard_univ (α : Type*) :
encard (univ : Set α) = PartENat.withTopEquiv (PartENat.card α) := by
rw [encard, PartENat.card_congr (Equiv.Set.univ α)]
theorem Finite.encard_eq_coe_toFinset_card (h : s.Finite) : s.encard = h.toFinset.card := by
have := h.fintype
rw [encard, PartENat.card_eq_coe_fintype_card,
PartENat.withTopEquiv_natCast, toFinite_toFinset, toFinset_card]
theorem encard_eq_coe_toFinset_card (s : Set α) [Fintype s] : encard s = s.toFinset.card := by
have h := toFinite s
rw [h.encard_eq_coe_toFinset_card, toFinite_toFinset]
theorem encard_coe_eq_coe_finsetCard (s : Finset α) : encard (s : Set α) = s.card := by
rw [Finite.encard_eq_coe_toFinset_card (Finset.finite_toSet s)]; simp
theorem Infinite.encard_eq {s : Set α} (h : s.Infinite) : s.encard = ⊤ := by
have := h.to_subtype
rw [encard, ← PartENat.withTopEquiv.symm.injective.eq_iff, Equiv.symm_apply_apply,
PartENat.withTopEquiv_symm_top, PartENat.card_eq_top_of_infinite]
@[simp] theorem encard_eq_zero : s.encard = 0 ↔ s = ∅ := by
rw [encard, ← PartENat.withTopEquiv.symm.injective.eq_iff, Equiv.symm_apply_apply,
PartENat.withTopEquiv_symm_zero, PartENat.card_eq_zero_iff_empty, isEmpty_subtype,
eq_empty_iff_forall_not_mem]
@[simp] theorem encard_empty : (∅ : Set α).encard = 0 := by
rw [encard_eq_zero]
| Mathlib/Data/Set/Card.lean | 98 | 99 | theorem nonempty_of_encard_ne_zero (h : s.encard ≠ 0) : s.Nonempty := by |
rwa [nonempty_iff_ne_empty, Ne, ← encard_eq_zero]
| [
" univ.encard = s.encard",
" univ.encard = PartENat.withTopEquiv (PartENat.card α)",
" s.encard = ↑h.toFinset.card",
" s.encard = ↑s.toFinset.card",
" (↑s).encard = ↑s.card",
" ↑⋯.toFinset.card = ↑s.card",
" s.encard = ⊤",
" s.encard = 0 ↔ s = ∅",
" ∅.encard = 0",
" s.Nonempty"
] | [
" univ.encard = s.encard",
" univ.encard = PartENat.withTopEquiv (PartENat.card α)",
" s.encard = ↑h.toFinset.card",
" s.encard = ↑s.toFinset.card",
" (↑s).encard = ↑s.card",
" ↑⋯.toFinset.card = ↑s.card",
" s.encard = ⊤",
" s.encard = 0 ↔ s = ∅",
" ∅.encard = 0",
" s.Nonempty"
] |
import Mathlib.Data.Fintype.List
#align_import data.list.cycle from "leanprover-community/mathlib"@"7413128c3bcb3b0818e3e18720abc9ea3100fb49"
assert_not_exists MonoidWithZero
namespace List
variable {α : Type*} [DecidableEq α]
def nextOr : ∀ (_ : List α) (_ _ : α), α
| [], _, default => default
| [_], _, default => default
-- Handles the not-found and the wraparound case
| y :: z :: xs, x, default => if x = y then z else nextOr (z :: xs) x default
#align list.next_or List.nextOr
@[simp]
theorem nextOr_nil (x d : α) : nextOr [] x d = d :=
rfl
#align list.next_or_nil List.nextOr_nil
@[simp]
theorem nextOr_singleton (x y d : α) : nextOr [y] x d = d :=
rfl
#align list.next_or_singleton List.nextOr_singleton
@[simp]
theorem nextOr_self_cons_cons (xs : List α) (x y d : α) : nextOr (x :: y :: xs) x d = y :=
if_pos rfl
#align list.next_or_self_cons_cons List.nextOr_self_cons_cons
| Mathlib/Data/List/Cycle.lean | 54 | 58 | theorem nextOr_cons_of_ne (xs : List α) (y x d : α) (h : x ≠ y) :
nextOr (y :: xs) x d = nextOr xs x d := by |
cases' xs with z zs
· rfl
· exact if_neg h
| [
" (y :: xs).nextOr x d = xs.nextOr x d",
" [y].nextOr x d = [].nextOr x d",
" (y :: z :: zs).nextOr x d = (z :: zs).nextOr x d"
] | [
" (y :: xs).nextOr x d = xs.nextOr x d"
] |
import Mathlib.Algebra.Algebra.Bilinear
import Mathlib.RingTheory.Localization.Basic
#align_import algebra.module.localized_module from "leanprover-community/mathlib"@"831c494092374cfe9f50591ed0ac81a25efc5b86"
namespace LocalizedModule
universe u v
variable {R : Type u} [CommSemiring R] (S : Submonoid R)
variable (M : Type v) [AddCommMonoid M] [Module R M]
variable (T : Type*) [CommSemiring T] [Algebra R T] [IsLocalization S T]
def r (a b : M × S) : Prop :=
∃ u : S, u • b.2 • a.1 = u • a.2 • b.1
#align localized_module.r LocalizedModule.r
theorem r.isEquiv : IsEquiv _ (r S M) :=
{ refl := fun ⟨m, s⟩ => ⟨1, by rw [one_smul]⟩
trans := fun ⟨m1, s1⟩ ⟨m2, s2⟩ ⟨m3, s3⟩ ⟨u1, hu1⟩ ⟨u2, hu2⟩ => by
use u1 * u2 * s2
-- Put everything in the same shape, sorting the terms using `simp`
have hu1' := congr_arg ((u2 * s3) • ·) hu1.symm
have hu2' := congr_arg ((u1 * s1) • ·) hu2.symm
simp only [← mul_smul, smul_assoc, mul_assoc, mul_comm, mul_left_comm] at hu1' hu2' ⊢
rw [hu2', hu1']
symm := fun ⟨m1, s1⟩ ⟨m2, s2⟩ ⟨u, hu⟩ => ⟨u, hu.symm⟩ }
#align localized_module.r.is_equiv LocalizedModule.r.isEquiv
instance r.setoid : Setoid (M × S) where
r := r S M
iseqv := ⟨(r.isEquiv S M).refl, (r.isEquiv S M).symm _ _, (r.isEquiv S M).trans _ _ _⟩
#align localized_module.r.setoid LocalizedModule.r.setoid
-- TODO: change `Localization` to use `r'` instead of `r` so that the two types are also defeq,
-- `Localization S = LocalizedModule S R`.
example {R} [CommSemiring R] (S : Submonoid R) : ⇑(Localization.r' S) = LocalizedModule.r S R :=
rfl
-- Porting note(#5171): @[nolint has_nonempty_instance]
def _root_.LocalizedModule : Type max u v :=
Quotient (r.setoid S M)
#align localized_module LocalizedModule
section
variable {M S}
def mk (m : M) (s : S) : LocalizedModule S M :=
Quotient.mk' ⟨m, s⟩
#align localized_module.mk LocalizedModule.mk
theorem mk_eq {m m' : M} {s s' : S} : mk m s = mk m' s' ↔ ∃ u : S, u • s' • m = u • s • m' :=
Quotient.eq'
#align localized_module.mk_eq LocalizedModule.mk_eq
@[elab_as_elim]
| Mathlib/Algebra/Module/LocalizedModule.lean | 99 | 102 | theorem induction_on {β : LocalizedModule S M → Prop} (h : ∀ (m : M) (s : S), β (mk m s)) :
∀ x : LocalizedModule S M, β x := by |
rintro ⟨⟨m, s⟩⟩
exact h m s
| [
" 1 • (m, s).2 • (m, s).1 = 1 • (m, s).2 • (m, s).1",
" r S M (m1, s1) (m3, s3)",
" (u1 * u2 * s2) • (m3, s3).2 • (m1, s1).1 = (u1 * u2 * s2) • (m1, s1).2 • (m3, s3).1",
" (s2 * (s3 * (u1 * u2))) • m1 = (s1 * (s2 * (u1 * u2))) • m3",
" ∀ (x : LocalizedModule S M), β x",
" β (Quot.mk Setoid.r (m, s))"
] | [
" 1 • (m, s).2 • (m, s).1 = 1 • (m, s).2 • (m, s).1",
" r S M (m1, s1) (m3, s3)",
" (u1 * u2 * s2) • (m3, s3).2 • (m1, s1).1 = (u1 * u2 * s2) • (m1, s1).2 • (m3, s3).1",
" (s2 * (s3 * (u1 * u2))) • m1 = (s1 * (s2 * (u1 * u2))) • m3",
" ∀ (x : LocalizedModule S M), β x"
] |
import Mathlib.Algebra.GeomSum
import Mathlib.Algebra.Polynomial.Roots
import Mathlib.GroupTheory.SpecificGroups.Cyclic
#align_import ring_theory.integral_domain from "leanprover-community/mathlib"@"6e70e0d419bf686784937d64ed4bfde866ff229e"
section
open Finset Polynomial Function Nat
variable {R : Type*} {G : Type*}
variable [CommRing R] [IsDomain R] [Group G]
-- Porting note: Finset doesn't seem to have `{g ∈ univ | g^n = g₀}` notation anymore,
-- so we have to use `Finset.filter` instead
theorem card_nthRoots_subgroup_units [Fintype G] [DecidableEq G] (f : G →* R) (hf : Injective f)
{n : ℕ} (hn : 0 < n) (g₀ : G) :
Finset.card (Finset.univ.filter (fun g ↦ g^n = g₀)) ≤ Multiset.card (nthRoots n (f g₀)) := by
haveI : DecidableEq R := Classical.decEq _
refine le_trans ?_ (nthRoots n (f g₀)).toFinset_card_le
apply card_le_card_of_inj_on f
· intro g hg
rw [mem_filter] at hg
rw [Multiset.mem_toFinset, mem_nthRoots hn, ← f.map_pow, hg.2]
· intros
apply hf
assumption
#align card_nth_roots_subgroup_units card_nthRoots_subgroup_units
| Mathlib/RingTheory/IntegralDomain.lean | 137 | 142 | theorem isCyclic_of_subgroup_isDomain [Finite G] (f : G →* R) (hf : Injective f) : IsCyclic G := by |
classical
cases nonempty_fintype G
apply isCyclic_of_card_pow_eq_one_le
intro n hn
exact le_trans (card_nthRoots_subgroup_units f hf hn 1) (card_nthRoots n (f 1))
| [
" (filter (fun g => g ^ n = g₀) univ).card ≤ Multiset.card (nthRoots n (f g₀))",
" (filter (fun g => g ^ n = g₀) univ).card ≤ (nthRoots n (f g₀)).toFinset.card",
" ∀ a ∈ filter (fun g => g ^ n = g₀) univ, f a ∈ (nthRoots n (f g₀)).toFinset",
" f g ∈ (nthRoots n (f g₀)).toFinset",
" ∀ a₁ ∈ filter (fun g => g... | [
" (filter (fun g => g ^ n = g₀) univ).card ≤ Multiset.card (nthRoots n (f g₀))",
" (filter (fun g => g ^ n = g₀) univ).card ≤ (nthRoots n (f g₀)).toFinset.card",
" ∀ a ∈ filter (fun g => g ^ n = g₀) univ, f a ∈ (nthRoots n (f g₀)).toFinset",
" f g ∈ (nthRoots n (f g₀)).toFinset",
" ∀ a₁ ∈ filter (fun g => g... |
import Mathlib.Data.Set.Image
import Mathlib.Data.List.InsertNth
import Mathlib.Init.Data.List.Lemmas
#align_import data.list.lemmas from "leanprover-community/mathlib"@"2ec920d35348cb2d13ac0e1a2ad9df0fdf1a76b4"
open List
variable {α β γ : Type*}
namespace List
theorem injOn_insertNth_index_of_not_mem (l : List α) (x : α) (hx : x ∉ l) :
Set.InjOn (fun k => insertNth k x l) { n | n ≤ l.length } := by
induction' l with hd tl IH
· intro n hn m hm _
simp only [Set.mem_singleton_iff, Set.setOf_eq_eq_singleton,
length] at hn hm
simp_all [hn, hm]
· intro n hn m hm h
simp only [length, Set.mem_setOf_eq] at hn hm
simp only [mem_cons, not_or] at hx
cases n <;> cases m
· rfl
· simp [hx.left] at h
· simp [Ne.symm hx.left] at h
· simp only [true_and_iff, eq_self_iff_true, insertNth_succ_cons] at h
rw [Nat.succ_inj']
refine IH hx.right ?_ ?_ (by injection h)
· simpa [Nat.succ_le_succ_iff] using hn
· simpa [Nat.succ_le_succ_iff] using hm
#align list.inj_on_insert_nth_index_of_not_mem List.injOn_insertNth_index_of_not_mem
theorem foldr_range_subset_of_range_subset {f : β → α → α} {g : γ → α → α}
(hfg : Set.range f ⊆ Set.range g) (a : α) : Set.range (foldr f a) ⊆ Set.range (foldr g a) := by
rintro _ ⟨l, rfl⟩
induction' l with b l H
· exact ⟨[], rfl⟩
· cases' hfg (Set.mem_range_self b) with c hgf
cases' H with m hgf'
rw [foldr_cons, ← hgf, ← hgf']
exact ⟨c :: m, rfl⟩
#align list.foldr_range_subset_of_range_subset List.foldr_range_subset_of_range_subset
| Mathlib/Data/List/Lemmas.lean | 55 | 66 | theorem foldl_range_subset_of_range_subset {f : α → β → α} {g : α → γ → α}
(hfg : (Set.range fun a c => f c a) ⊆ Set.range fun b c => g c b) (a : α) :
Set.range (foldl f a) ⊆ Set.range (foldl g a) := by |
change (Set.range fun l => _) ⊆ Set.range fun l => _
-- Porting note: This was simply `simp_rw [← foldr_reverse]`
simp_rw [← foldr_reverse _ (fun z w => g w z), ← foldr_reverse _ (fun z w => f w z)]
-- Porting note: This `change` was not necessary in mathlib3
change (Set.range (foldr (fun z w => f w z) a ∘ reverse)) ⊆
Set.range (foldr (fun z w => g w z) a ∘ reverse)
simp_rw [Set.range_comp _ reverse, reverse_involutive.bijective.surjective.range_eq,
Set.image_univ]
exact foldr_range_subset_of_range_subset hfg a
| [
" Set.InjOn (fun k => insertNth k x l) {n | n ≤ l.length}",
" Set.InjOn (fun k => insertNth k x []) {n | n ≤ [].length}",
" n = m",
" Set.InjOn (fun k => insertNth k x (hd :: tl)) {n | n ≤ (hd :: tl).length}",
" 0 = m",
" n✝ + 1 = m",
" 0 = 0",
" 0 = n✝ + 1",
" n✝ + 1 = 0",
" n✝¹ + 1 = n✝ + 1",
... | [
" Set.InjOn (fun k => insertNth k x l) {n | n ≤ l.length}",
" Set.InjOn (fun k => insertNth k x []) {n | n ≤ [].length}",
" n = m",
" Set.InjOn (fun k => insertNth k x (hd :: tl)) {n | n ≤ (hd :: tl).length}",
" 0 = m",
" n✝ + 1 = m",
" 0 = 0",
" 0 = n✝ + 1",
" n✝ + 1 = 0",
" n✝¹ + 1 = n✝ + 1",
... |
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Monic
#align_import data.polynomial.lifts from "leanprover-community/mathlib"@"63417e01fbc711beaf25fa73b6edb395c0cfddd0"
open Polynomial
noncomputable section
namespace Polynomial
universe u v w
section Semiring
variable {R : Type u} [Semiring R] {S : Type v} [Semiring S] {f : R →+* S}
def lifts (f : R →+* S) : Subsemiring S[X] :=
RingHom.rangeS (mapRingHom f)
#align polynomial.lifts Polynomial.lifts
theorem mem_lifts (p : S[X]) : p ∈ lifts f ↔ ∃ q : R[X], map f q = p := by
simp only [coe_mapRingHom, lifts, RingHom.mem_rangeS]
#align polynomial.mem_lifts Polynomial.mem_lifts
theorem lifts_iff_set_range (p : S[X]) : p ∈ lifts f ↔ p ∈ Set.range (map f) := by
simp only [coe_mapRingHom, lifts, Set.mem_range, RingHom.mem_rangeS]
#align polynomial.lifts_iff_set_range Polynomial.lifts_iff_set_range
theorem lifts_iff_ringHom_rangeS (p : S[X]) : p ∈ lifts f ↔ p ∈ (mapRingHom f).rangeS := by
simp only [coe_mapRingHom, lifts, Set.mem_range, RingHom.mem_rangeS]
#align polynomial.lifts_iff_ring_hom_srange Polynomial.lifts_iff_ringHom_rangeS
theorem lifts_iff_coeff_lifts (p : S[X]) : p ∈ lifts f ↔ ∀ n : ℕ, p.coeff n ∈ Set.range f := by
rw [lifts_iff_ringHom_rangeS, mem_map_rangeS f]
rfl
#align polynomial.lifts_iff_coeff_lifts Polynomial.lifts_iff_coeff_lifts
theorem C_mem_lifts (f : R →+* S) (r : R) : C (f r) ∈ lifts f :=
⟨C r, by
simp only [coe_mapRingHom, map_C, Set.mem_univ, Subsemiring.coe_top, eq_self_iff_true,
and_self_iff]⟩
set_option linter.uppercaseLean3 false in
#align polynomial.C_mem_lifts Polynomial.C_mem_lifts
theorem C'_mem_lifts {f : R →+* S} {s : S} (h : s ∈ Set.range f) : C s ∈ lifts f := by
obtain ⟨r, rfl⟩ := Set.mem_range.1 h
use C r
simp only [coe_mapRingHom, map_C, Set.mem_univ, Subsemiring.coe_top, eq_self_iff_true,
and_self_iff]
set_option linter.uppercaseLean3 false in
#align polynomial.C'_mem_lifts Polynomial.C'_mem_lifts
theorem X_mem_lifts (f : R →+* S) : (X : S[X]) ∈ lifts f :=
⟨X, by
simp only [coe_mapRingHom, Set.mem_univ, Subsemiring.coe_top, eq_self_iff_true, map_X,
and_self_iff]⟩
set_option linter.uppercaseLean3 false in
#align polynomial.X_mem_lifts Polynomial.X_mem_lifts
theorem X_pow_mem_lifts (f : R →+* S) (n : ℕ) : (X ^ n : S[X]) ∈ lifts f :=
⟨X ^ n, by
simp only [coe_mapRingHom, map_pow, Set.mem_univ, Subsemiring.coe_top, eq_self_iff_true,
map_X, and_self_iff]⟩
set_option linter.uppercaseLean3 false in
#align polynomial.X_pow_mem_lifts Polynomial.X_pow_mem_lifts
theorem base_mul_mem_lifts {p : S[X]} (r : R) (hp : p ∈ lifts f) : C (f r) * p ∈ lifts f := by
simp only [lifts, RingHom.mem_rangeS] at hp ⊢
obtain ⟨p₁, rfl⟩ := hp
use C r * p₁
simp only [coe_mapRingHom, map_C, map_mul]
#align polynomial.base_mul_mem_lifts Polynomial.base_mul_mem_lifts
| Mathlib/Algebra/Polynomial/Lifts.lean | 120 | 124 | theorem monomial_mem_lifts {s : S} (n : ℕ) (h : s ∈ Set.range f) : monomial n s ∈ lifts f := by |
obtain ⟨r, rfl⟩ := Set.mem_range.1 h
use monomial n r
simp only [coe_mapRingHom, Set.mem_univ, map_monomial, Subsemiring.coe_top, eq_self_iff_true,
and_self_iff]
| [
" p ∈ lifts f ↔ ∃ q, map f q = p",
" p ∈ lifts f ↔ p ∈ Set.range (map f)",
" p ∈ lifts f ↔ p ∈ (mapRingHom f).rangeS",
" p ∈ lifts f ↔ ∀ (n : ℕ), p.coeff n ∈ Set.range ⇑f",
" (∀ (n : ℕ), p.coeff n ∈ f.rangeS) ↔ ∀ (n : ℕ), p.coeff n ∈ Set.range ⇑f",
" (mapRingHom f) (C r) = C (f r)",
" C s ∈ lifts f",
... | [
" p ∈ lifts f ↔ ∃ q, map f q = p",
" p ∈ lifts f ↔ p ∈ Set.range (map f)",
" p ∈ lifts f ↔ p ∈ (mapRingHom f).rangeS",
" p ∈ lifts f ↔ ∀ (n : ℕ), p.coeff n ∈ Set.range ⇑f",
" (∀ (n : ℕ), p.coeff n ∈ f.rangeS) ↔ ∀ (n : ℕ), p.coeff n ∈ Set.range ⇑f",
" (mapRingHom f) (C r) = C (f r)",
" C s ∈ lifts f",
... |
import Mathlib.Data.Matrix.Basic
import Mathlib.Data.Matrix.RowCol
import Mathlib.Data.Fin.VecNotation
import Mathlib.Tactic.FinCases
#align_import data.matrix.notation from "leanprover-community/mathlib"@"a99f85220eaf38f14f94e04699943e185a5e1d1a"
namespace Matrix
universe u uₘ uₙ uₒ
variable {α : Type u} {o n m : ℕ} {m' : Type uₘ} {n' : Type uₙ} {o' : Type uₒ}
open Matrix
variable (a b : ℕ)
instance repr [Repr α] : Repr (Matrix (Fin m) (Fin n) α) where
reprPrec f _p :=
(Std.Format.bracket "!![" · "]") <|
(Std.Format.joinSep · (";" ++ Std.Format.line)) <|
(List.finRange m).map fun i =>
Std.Format.fill <| -- wrap line in a single place rather than all at once
(Std.Format.joinSep · ("," ++ Std.Format.line)) <|
(List.finRange n).map fun j => _root_.repr (f i j)
#align matrix.has_repr Matrix.repr
@[simp]
theorem cons_val' (v : n' → α) (B : Fin m → n' → α) (i j) :
vecCons v B i j = vecCons (v j) (fun i => B i j) i := by refine Fin.cases ?_ ?_ i <;> simp
#align matrix.cons_val' Matrix.cons_val'
@[simp, nolint simpNF] -- Porting note: LHS does not simplify.
theorem head_val' (B : Fin m.succ → n' → α) (j : n') : (vecHead fun i => B i j) = vecHead B j :=
rfl
#align matrix.head_val' Matrix.head_val'
@[simp, nolint simpNF] -- Porting note: LHS does not simplify.
theorem tail_val' (B : Fin m.succ → n' → α) (j : n') :
(vecTail fun i => B i j) = fun i => vecTail B i j := rfl
#align matrix.tail_val' Matrix.tail_val'
section DotProduct
variable [AddCommMonoid α] [Mul α]
@[simp]
theorem dotProduct_empty (v w : Fin 0 → α) : dotProduct v w = 0 :=
Finset.sum_empty
#align matrix.dot_product_empty Matrix.dotProduct_empty
@[simp]
| Mathlib/Data/Matrix/Notation.lean | 162 | 164 | theorem cons_dotProduct (x : α) (v : Fin n → α) (w : Fin n.succ → α) :
dotProduct (vecCons x v) w = x * vecHead w + dotProduct v (vecTail w) := by |
simp [dotProduct, Fin.sum_univ_succ, vecHead, vecTail]
| [
" vecCons v B i j = vecCons (v j) (fun i => B i j) i",
" vecCons v B 0 j = vecCons (v j) (fun i => B i j) 0",
" ∀ (i : Fin m), vecCons v B i.succ j = vecCons (v j) (fun i => B i j) i.succ",
" vecCons x v ⬝ᵥ w = x * vecHead w + v ⬝ᵥ vecTail w"
] | [
" vecCons v B i j = vecCons (v j) (fun i => B i j) i",
" vecCons v B 0 j = vecCons (v j) (fun i => B i j) 0",
" ∀ (i : Fin m), vecCons v B i.succ j = vecCons (v j) (fun i => B i j) i.succ",
" vecCons x v ⬝ᵥ w = x * vecHead w + v ⬝ᵥ vecTail w"
] |
import Mathlib.Analysis.NormedSpace.Basic
import Mathlib.Analysis.Normed.Group.Hom
import Mathlib.Data.Real.Sqrt
import Mathlib.RingTheory.Ideal.QuotientOperations
import Mathlib.Topology.MetricSpace.HausdorffDistance
#align_import analysis.normed.group.quotient from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
noncomputable section
open QuotientAddGroup Metric Set Topology NNReal
variable {M N : Type*} [SeminormedAddCommGroup M] [SeminormedAddCommGroup N]
noncomputable instance normOnQuotient (S : AddSubgroup M) : Norm (M ⧸ S) where
norm x := sInf (norm '' { m | mk' S m = x })
#align norm_on_quotient normOnQuotient
theorem AddSubgroup.quotient_norm_eq {S : AddSubgroup M} (x : M ⧸ S) :
‖x‖ = sInf (norm '' { m : M | (m : M ⧸ S) = x }) :=
rfl
#align add_subgroup.quotient_norm_eq AddSubgroup.quotient_norm_eq
| Mathlib/Analysis/Normed/Group/Quotient.lean | 113 | 115 | theorem QuotientAddGroup.norm_eq_infDist {S : AddSubgroup M} (x : M ⧸ S) :
‖x‖ = infDist 0 { m : M | (m : M ⧸ S) = x } := by |
simp only [AddSubgroup.quotient_norm_eq, infDist_eq_iInf, sInf_image', dist_zero_left]
| [
" ‖x‖ = infDist 0 {m | ↑m = x}"
] | [
" ‖x‖ = infDist 0 {m | ↑m = x}"
] |
import Mathlib.Algebra.Polynomial.DenomsClearable
import Mathlib.Analysis.Calculus.MeanValue
import Mathlib.Analysis.Calculus.Deriv.Polynomial
import Mathlib.Data.Real.Irrational
import Mathlib.Topology.Algebra.Polynomial
#align_import number_theory.liouville.basic from "leanprover-community/mathlib"@"04e80bb7e8510958cd9aacd32fe2dc147af0b9f1"
def Liouville (x : ℝ) :=
∀ n : ℕ, ∃ a b : ℤ, 1 < b ∧ x ≠ a / b ∧ |x - a / b| < 1 / (b : ℝ) ^ n
#align liouville Liouville
namespace Liouville
protected theorem irrational {x : ℝ} (h : Liouville x) : Irrational x := by
-- By contradiction, `x = a / b`, with `a ∈ ℤ`, `0 < b ∈ ℕ` is a Liouville number,
rintro ⟨⟨a, b, bN0, cop⟩, rfl⟩
-- clear up the mess of constructions of rationals
rw [Rat.cast_mk'] at h
-- Since `a / b` is a Liouville number, there are `p, q ∈ ℤ`, with `q1 : 1 < q`,∈
-- `a0 : a / b ≠ p / q` and `a1 : |a / b - p / q| < 1 / q ^ (b + 1)`
rcases h (b + 1) with ⟨p, q, q1, a0, a1⟩
-- A few useful inequalities
have qR0 : (0 : ℝ) < q := Int.cast_pos.mpr (zero_lt_one.trans q1)
have b0 : (b : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr bN0
have bq0 : (0 : ℝ) < b * q := mul_pos (Nat.cast_pos.mpr bN0.bot_lt) qR0
-- At a1, clear denominators...
replace a1 : |a * q - b * p| * q ^ (b + 1) < b * q := by
rw [div_sub_div _ _ b0 qR0.ne', abs_div, div_lt_div_iff (abs_pos.mpr bq0.ne') (pow_pos qR0 _),
abs_of_pos bq0, one_mul] at a1
exact mod_cast a1
-- At a0, clear denominators...
replace a0 : a * q - ↑b * p ≠ 0 := by
rw [Ne, div_eq_div_iff b0 qR0.ne', mul_comm (p : ℝ), ← sub_eq_zero] at a0
exact mod_cast a0
-- Actually, `q` is a natural number
lift q to ℕ using (zero_lt_one.trans q1).le
-- Looks innocuous, but we now have an integer with non-zero absolute value: this is at
-- least one away from zero. The gain here is what gets the proof going.
have ap : 0 < |a * ↑q - ↑b * p| := abs_pos.mpr a0
-- Actually, the absolute value of an integer is a natural number
-- FIXME: This `lift` call duplicates the hypotheses `a1` and `ap`
lift |a * ↑q - ↑b * p| to ℕ using abs_nonneg (a * ↑q - ↑b * p) with e he
norm_cast at a1 ap q1
-- Recall this is by contradiction: we obtained the inequality `b * q ≤ x * q ^ (b + 1)`, so
-- we are done.
exact not_le.mpr a1 (Nat.mul_lt_mul_pow_succ ap q1).le
#align liouville.irrational Liouville.irrational
open Polynomial Metric Set Real RingHom
open scoped Polynomial
| Mathlib/NumberTheory/Liouville/Basic.lean | 95 | 120 | theorem exists_one_le_pow_mul_dist {Z N R : Type*} [PseudoMetricSpace R] {d : N → ℝ}
{j : Z → N → R} {f : R → R} {α : R} {ε M : ℝ}
-- denominators are positive
(d0 : ∀ a : N, 1 ≤ d a)
(e0 : 0 < ε)
-- function is Lipschitz at α
(B : ∀ ⦃y : R⦄, y ∈ closedBall α ε → dist (f α) (f y) ≤ dist α y * M)
-- clear denominators
(L : ∀ ⦃z : Z⦄, ∀ ⦃a : N⦄, j z a ∈ closedBall α ε → 1 ≤ d a * dist (f α) (f (j z a))) :
∃ A : ℝ, 0 < A ∧ ∀ z : Z, ∀ a : N, 1 ≤ d a * (dist α (j z a) * A) := by |
-- A useful inequality to keep at hand
have me0 : 0 < max (1 / ε) M := lt_max_iff.mpr (Or.inl (one_div_pos.mpr e0))
-- The maximum between `1 / ε` and `M` works
refine ⟨max (1 / ε) M, me0, fun z a => ?_⟩
-- First, let's deal with the easy case in which we are far away from `α`
by_cases dm1 : 1 ≤ dist α (j z a) * max (1 / ε) M
· exact one_le_mul_of_one_le_of_one_le (d0 a) dm1
· -- `j z a = z / (a + 1)`: we prove that this ratio is close to `α`
have : j z a ∈ closedBall α ε := by
refine mem_closedBall'.mp (le_trans ?_ ((one_div_le me0 e0).mpr (le_max_left _ _)))
exact (le_div_iff me0).mpr (not_le.mp dm1).le
-- use the "separation from `1`" (assumption `L`) for numerators,
refine (L this).trans ?_
-- remove a common factor and use the Lipschitz assumption `B`
refine mul_le_mul_of_nonneg_left ((B this).trans ?_) (zero_le_one.trans (d0 a))
exact mul_le_mul_of_nonneg_left (le_max_right _ M) dist_nonneg
| [
" Irrational x",
" False",
" |a * q - ↑b * p| * q ^ (b + 1) < ↑b * q",
" a * q - ↑b * p ≠ 0",
" ∃ A, 0 < A ∧ ∀ (z : Z) (a : N), 1 ≤ d a * (dist α (j z a) * A)",
" 1 ≤ d a * (dist α (j z a) * max (1 / ε) M)",
" j z a ∈ closedBall α ε",
" dist α (j z a) ≤ 1 / max (1 / ε) M",
" d a * dist (f α) (f (j z... | [
" Irrational x",
" False",
" |a * q - ↑b * p| * q ^ (b + 1) < ↑b * q",
" a * q - ↑b * p ≠ 0",
" ∃ A, 0 < A ∧ ∀ (z : Z) (a : N), 1 ≤ d a * (dist α (j z a) * A)"
] |
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
| Mathlib/RingTheory/Polynomial/Bernstein.lean | 81 | 83 | theorem flip' (n ν : ℕ) (h : ν ≤ n) :
bernsteinPolynomial R n ν = (bernsteinPolynomial R n (n - ν)).comp (1 - X) := by |
simp [← flip _ _ _ h, Polynomial.comp_assoc]
| [
" bernsteinPolynomial ℤ 3 2 = 3 * X ^ 2 - 3 * X ^ 3",
" 3 * X ^ 2 * (1 - X) = 3 * X ^ 2 - 3 * X ^ 3",
" bernsteinPolynomial R n ν = 0",
" Polynomial.map f (bernsteinPolynomial R n ν) = bernsteinPolynomial S n ν",
" (bernsteinPolynomial R n ν).comp (1 - X) = bernsteinPolynomial R n (n - ν)",
" bernsteinPol... | [
" bernsteinPolynomial ℤ 3 2 = 3 * X ^ 2 - 3 * X ^ 3",
" 3 * X ^ 2 * (1 - X) = 3 * X ^ 2 - 3 * X ^ 3",
" bernsteinPolynomial R n ν = 0",
" Polynomial.map f (bernsteinPolynomial R n ν) = bernsteinPolynomial S n ν",
" (bernsteinPolynomial R n ν).comp (1 - X) = bernsteinPolynomial R n (n - ν)",
" bernsteinPol... |
import Mathlib.Algebra.Polynomial.Basic
import Mathlib.FieldTheory.IsAlgClosed.Basic
#align_import linear_algebra.matrix.charpoly.eigs from "leanprover-community/mathlib"@"48dc6abe71248bd6f4bffc9703dc87bdd4e37d0b"
variable {n : Type*} [Fintype n] [DecidableEq n]
variable {R : Type*} [Field R]
variable {A : Matrix n n R}
open Matrix Polynomial
open scoped Matrix
namespace Matrix
| Mathlib/LinearAlgebra/Matrix/Charpoly/Eigs.lean | 60 | 64 | theorem det_eq_prod_roots_charpoly_of_splits (hAps : A.charpoly.Splits (RingHom.id R)) :
A.det = (Matrix.charpoly A).roots.prod := by |
rw [det_eq_sign_charpoly_coeff, ← charpoly_natDegree_eq_dim A,
Polynomial.prod_roots_eq_coeff_zero_of_monic_of_split A.charpoly_monic hAps, ← mul_assoc,
← pow_two, pow_right_comm, neg_one_sq, one_pow, one_mul]
| [
" A.det = A.charpoly.roots.prod"
] | [
" A.det = A.charpoly.roots.prod"
] |
import Mathlib.Analysis.Convex.Jensen
import Mathlib.Analysis.Convex.SpecificFunctions.Basic
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
import Mathlib.Data.Real.ConjExponents
#align_import analysis.mean_inequalities from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
universe u v
open scoped Classical
open Finset NNReal ENNReal
set_option linter.uppercaseLean3 false
noncomputable section
variable {ι : Type u} (s : Finset ι)
section GeomMeanLEArithMean
namespace Real
theorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :
∏ i ∈ s, z i ^ w i ≤ ∑ i ∈ s, w i * z i := by
-- If some number `z i` equals zero and has non-zero weight, then LHS is 0 and RHS is nonnegative.
by_cases A : ∃ i ∈ s, z i = 0 ∧ w i ≠ 0
· rcases A with ⟨i, his, hzi, hwi⟩
rw [prod_eq_zero his]
· exact sum_nonneg fun j hj => mul_nonneg (hw j hj) (hz j hj)
· rw [hzi]
exact zero_rpow hwi
-- If all numbers `z i` with non-zero weight are positive, then we apply Jensen's inequality
-- for `exp` and numbers `log (z i)` with weights `w i`.
· simp only [not_exists, not_and, Ne, Classical.not_not] at A
have := convexOn_exp.map_sum_le hw hw' fun i _ => Set.mem_univ <| log (z i)
simp only [exp_sum, (· ∘ ·), smul_eq_mul, mul_comm (w _) (log _)] at this
convert this using 1 <;> [apply prod_congr rfl;apply sum_congr rfl] <;> intro i hi
· cases' eq_or_lt_of_le (hz i hi) with hz hz
· simp [A i hi hz.symm]
· exact rpow_def_of_pos hz _
· cases' eq_or_lt_of_le (hz i hi) with hz hz
· simp [A i hi hz.symm]
· rw [exp_log hz]
#align real.geom_mean_le_arith_mean_weighted Real.geom_mean_le_arith_mean_weighted
theorem geom_mean_le_arith_mean {ι : Type*} (s : Finset ι) (w : ι → ℝ) (z : ι → ℝ)
(hw : ∀ i ∈ s, 0 ≤ w i) (hw' : 0 < ∑ i ∈ s, w i) (hz : ∀ i ∈ s, 0 ≤ z i) :
(∏ i ∈ s, z i ^ w i) ^ (∑ i ∈ s, w i)⁻¹ ≤ (∑ i ∈ s, w i * z i) / (∑ i ∈ s, w i) := by
convert geom_mean_le_arith_mean_weighted s (fun i => (w i) / ∑ i ∈ s, w i) z ?_ ?_ hz using 2
· rw [← finset_prod_rpow _ _ (fun i hi => rpow_nonneg (hz _ hi) _) _]
refine Finset.prod_congr rfl (fun _ ih => ?_)
rw [div_eq_mul_inv, rpow_mul (hz _ ih)]
· simp_rw [div_eq_mul_inv, mul_assoc, mul_comm, ← mul_assoc, ← Finset.sum_mul, mul_comm]
· exact fun _ hi => div_nonneg (hw _ hi) (le_of_lt hw')
· simp_rw [div_eq_mul_inv, ← Finset.sum_mul]
exact mul_inv_cancel (by linarith)
theorem geom_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) :
∏ i ∈ s, z i ^ w i = x :=
calc
∏ i ∈ s, z i ^ w i = ∏ i ∈ s, x ^ w i := by
refine prod_congr rfl fun i hi => ?_
rcases eq_or_ne (w i) 0 with h₀ | h₀
· rw [h₀, rpow_zero, rpow_zero]
· rw [hx i hi h₀]
_ = x := by
rw [← rpow_sum_of_nonneg _ hw, hw', rpow_one]
have : (∑ i ∈ s, w i) ≠ 0 := by
rw [hw']
exact one_ne_zero
obtain ⟨i, his, hi⟩ := exists_ne_zero_of_sum_ne_zero this
rw [← hx i his hi]
exact hz i his
#align real.geom_mean_weighted_of_constant Real.geom_mean_weighted_of_constant
| Mathlib/Analysis/MeanInequalities.lean | 169 | 177 | theorem arith_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw' : ∑ i ∈ s, w i = 1)
(hx : ∀ i ∈ s, w i ≠ 0 → z i = x) : ∑ i ∈ s, w i * z i = x :=
calc
∑ i ∈ s, w i * z i = ∑ i ∈ s, w i * x := by |
refine sum_congr rfl fun i hi => ?_
rcases eq_or_ne (w i) 0 with hwi | hwi
· rw [hwi, zero_mul, zero_mul]
· rw [hx i hi hwi]
_ = x := by rw [← sum_mul, hw', one_mul]
| [
" ∏ i ∈ s, z i ^ w i ≤ ∑ i ∈ s, w i * z i",
" 0 ≤ ∑ i ∈ s, w i * z i",
" z i ^ w i = 0",
" 0 ^ w i = 0",
" ∏ i ∈ s, z i ^ w i = ∏ x ∈ s, rexp ((z x).log * w x)",
" ∑ i ∈ s, w i * z i = ∑ x ∈ s, w x * rexp (z x).log",
" ∀ x ∈ s, z x ^ w x = rexp ((z x).log * w x)",
" ∀ x ∈ s, w x * z x = w x * rexp (z ... | [
" ∏ i ∈ s, z i ^ w i ≤ ∑ i ∈ s, w i * z i",
" 0 ≤ ∑ i ∈ s, w i * z i",
" z i ^ w i = 0",
" 0 ^ w i = 0",
" ∏ i ∈ s, z i ^ w i = ∏ x ∈ s, rexp ((z x).log * w x)",
" ∑ i ∈ s, w i * z i = ∑ x ∈ s, w x * rexp (z x).log",
" ∀ x ∈ s, z x ^ w x = rexp ((z x).log * w x)",
" ∀ x ∈ s, w x * z x = w x * rexp (z ... |
import Mathlib.Algebra.CharP.Two
import Mathlib.Algebra.CharP.Reduced
import Mathlib.Algebra.NeZero
import Mathlib.Algebra.Polynomial.RingDivision
import Mathlib.GroupTheory.SpecificGroups.Cyclic
import Mathlib.NumberTheory.Divisors
import Mathlib.RingTheory.IntegralDomain
import Mathlib.Tactic.Zify
#align_import ring_theory.roots_of_unity.basic from "leanprover-community/mathlib"@"7fdeecc0d03cd40f7a165e6cf00a4d2286db599f"
open scoped Classical Polynomial
noncomputable section
open Polynomial
open Finset
variable {M N G R S F : Type*}
variable [CommMonoid M] [CommMonoid N] [DivisionCommMonoid G]
section rootsOfUnity
variable {k l : ℕ+}
def rootsOfUnity (k : ℕ+) (M : Type*) [CommMonoid M] : Subgroup Mˣ where
carrier := {ζ | ζ ^ (k : ℕ) = 1}
one_mem' := one_pow _
mul_mem' _ _ := by simp_all only [Set.mem_setOf_eq, mul_pow, one_mul]
inv_mem' _ := by simp_all only [Set.mem_setOf_eq, inv_pow, inv_one]
#align roots_of_unity rootsOfUnity
@[simp]
theorem mem_rootsOfUnity (k : ℕ+) (ζ : Mˣ) : ζ ∈ rootsOfUnity k M ↔ ζ ^ (k : ℕ) = 1 :=
Iff.rfl
#align mem_roots_of_unity mem_rootsOfUnity
theorem mem_rootsOfUnity' (k : ℕ+) (ζ : Mˣ) : ζ ∈ rootsOfUnity k M ↔ (ζ : M) ^ (k : ℕ) = 1 := by
rw [mem_rootsOfUnity]; norm_cast
#align mem_roots_of_unity' mem_rootsOfUnity'
@[simp]
theorem rootsOfUnity_one (M : Type*) [CommMonoid M] : rootsOfUnity 1 M = ⊥ := by ext; simp
theorem rootsOfUnity.coe_injective {n : ℕ+} :
Function.Injective (fun x : rootsOfUnity n M ↦ x.val.val) :=
Units.ext.comp fun _ _ => Subtype.eq
#align roots_of_unity.coe_injective rootsOfUnity.coe_injective
@[simps! coe_val]
def rootsOfUnity.mkOfPowEq (ζ : M) {n : ℕ+} (h : ζ ^ (n : ℕ) = 1) : rootsOfUnity n M :=
⟨Units.ofPowEqOne ζ n h n.ne_zero, Units.pow_ofPowEqOne _ _⟩
#align roots_of_unity.mk_of_pow_eq rootsOfUnity.mkOfPowEq
#align roots_of_unity.mk_of_pow_eq_coe_coe rootsOfUnity.val_mkOfPowEq_coe
@[simp]
theorem rootsOfUnity.coe_mkOfPowEq {ζ : M} {n : ℕ+} (h : ζ ^ (n : ℕ) = 1) :
((rootsOfUnity.mkOfPowEq _ h : Mˣ) : M) = ζ :=
rfl
#align roots_of_unity.coe_mk_of_pow_eq rootsOfUnity.coe_mkOfPowEq
theorem rootsOfUnity_le_of_dvd (h : k ∣ l) : rootsOfUnity k M ≤ rootsOfUnity l M := by
obtain ⟨d, rfl⟩ := h
intro ζ h
simp_all only [mem_rootsOfUnity, PNat.mul_coe, pow_mul, one_pow]
#align roots_of_unity_le_of_dvd rootsOfUnity_le_of_dvd
theorem map_rootsOfUnity (f : Mˣ →* Nˣ) (k : ℕ+) : (rootsOfUnity k M).map f ≤ rootsOfUnity k N := by
rintro _ ⟨ζ, h, rfl⟩
simp_all only [← map_pow, mem_rootsOfUnity, SetLike.mem_coe, MonoidHom.map_one]
#align map_roots_of_unity map_rootsOfUnity
@[norm_cast]
theorem rootsOfUnity.coe_pow [CommMonoid R] (ζ : rootsOfUnity k R) (m : ℕ) :
(((ζ ^ m :) : Rˣ) : R) = ((ζ : Rˣ) : R) ^ m := by
rw [Subgroup.coe_pow, Units.val_pow_eq_pow_val]
#align roots_of_unity.coe_pow rootsOfUnity.coe_pow
@[mk_iff IsPrimitiveRoot.iff_def]
structure IsPrimitiveRoot (ζ : M) (k : ℕ) : Prop where
pow_eq_one : ζ ^ (k : ℕ) = 1
dvd_of_pow_eq_one : ∀ l : ℕ, ζ ^ l = 1 → k ∣ l
#align is_primitive_root IsPrimitiveRoot
#align is_primitive_root.iff_def IsPrimitiveRoot.iff_def
@[simps!]
def IsPrimitiveRoot.toRootsOfUnity {μ : M} {n : ℕ+} (h : IsPrimitiveRoot μ n) : rootsOfUnity n M :=
rootsOfUnity.mkOfPowEq μ h.pow_eq_one
#align is_primitive_root.to_roots_of_unity IsPrimitiveRoot.toRootsOfUnity
#align is_primitive_root.coe_to_roots_of_unity_coe IsPrimitiveRoot.val_toRootsOfUnity_coe
#align is_primitive_root.coe_inv_to_roots_of_unity_coe IsPrimitiveRoot.val_inv_toRootsOfUnity_coe
section primitiveRoots
variable {k : ℕ}
def primitiveRoots (k : ℕ) (R : Type*) [CommRing R] [IsDomain R] : Finset R :=
(nthRoots k (1 : R)).toFinset.filter fun ζ => IsPrimitiveRoot ζ k
#align primitive_roots primitiveRoots
variable [CommRing R] [IsDomain R]
@[simp]
theorem mem_primitiveRoots {ζ : R} (h0 : 0 < k) : ζ ∈ primitiveRoots k R ↔ IsPrimitiveRoot ζ k := by
rw [primitiveRoots, mem_filter, Multiset.mem_toFinset, mem_nthRoots h0, and_iff_right_iff_imp]
exact IsPrimitiveRoot.pow_eq_one
#align mem_primitive_roots mem_primitiveRoots
@[simp]
| Mathlib/RingTheory/RootsOfUnity/Basic.lean | 320 | 321 | theorem primitiveRoots_zero : primitiveRoots 0 R = ∅ := by |
rw [primitiveRoots, nthRoots_zero, Multiset.toFinset_zero, Finset.filter_empty]
| [
" a✝ * b✝ ∈ {ζ | ζ ^ ↑k = 1}",
" x✝¹⁻¹ ∈ { carrier := {ζ | ζ ^ ↑k = 1}, mul_mem' := ⋯, one_mem' := ⋯ }.carrier",
" ζ ∈ rootsOfUnity k M ↔ ↑ζ ^ ↑k = 1",
" ζ ^ ↑k = 1 ↔ ↑ζ ^ ↑k = 1",
" rootsOfUnity 1 M = ⊥",
" x✝ ∈ rootsOfUnity 1 M ↔ x✝ ∈ ⊥",
" rootsOfUnity k M ≤ rootsOfUnity l M",
" rootsOfUnity k M ≤ ... | [
" a✝ * b✝ ∈ {ζ | ζ ^ ↑k = 1}",
" x✝¹⁻¹ ∈ { carrier := {ζ | ζ ^ ↑k = 1}, mul_mem' := ⋯, one_mem' := ⋯ }.carrier",
" ζ ∈ rootsOfUnity k M ↔ ↑ζ ^ ↑k = 1",
" ζ ^ ↑k = 1 ↔ ↑ζ ^ ↑k = 1",
" rootsOfUnity 1 M = ⊥",
" x✝ ∈ rootsOfUnity 1 M ↔ x✝ ∈ ⊥",
" rootsOfUnity k M ≤ rootsOfUnity l M",
" rootsOfUnity k M ≤ ... |
import Mathlib.Logic.Function.Iterate
import Mathlib.Order.Monotone.Basic
#align_import order.iterate from "leanprover-community/mathlib"@"2258b40dacd2942571c8ce136215350c702dc78f"
open Function
open Function (Commute)
namespace Monotone
variable {α : Type*} [Preorder α] {f : α → α} {x y : ℕ → α}
theorem seq_le_seq (hf : Monotone f) (n : ℕ) (h₀ : x 0 ≤ y 0) (hx : ∀ k < n, x (k + 1) ≤ f (x k))
(hy : ∀ k < n, f (y k) ≤ y (k + 1)) : x n ≤ y n := by
induction' n with n ihn
· exact h₀
· refine (hx _ n.lt_succ_self).trans ((hf <| ihn ?_ ?_).trans (hy _ n.lt_succ_self))
· exact fun k hk => hx _ (hk.trans n.lt_succ_self)
· exact fun k hk => hy _ (hk.trans n.lt_succ_self)
#align monotone.seq_le_seq Monotone.seq_le_seq
| Mathlib/Order/Iterate.lean | 51 | 60 | theorem seq_pos_lt_seq_of_lt_of_le (hf : Monotone f) {n : ℕ} (hn : 0 < n) (h₀ : x 0 ≤ y 0)
(hx : ∀ k < n, x (k + 1) < f (x k)) (hy : ∀ k < n, f (y k) ≤ y (k + 1)) : x n < y n := by |
induction' n with n ihn
· exact hn.false.elim
suffices x n ≤ y n from (hx n n.lt_succ_self).trans_le ((hf this).trans <| hy n n.lt_succ_self)
cases n with
| zero => exact h₀
| succ n =>
refine (ihn n.zero_lt_succ (fun k hk => hx _ ?_) fun k hk => hy _ ?_).le <;>
exact hk.trans n.succ.lt_succ_self
| [
" x n ≤ y n",
" x 0 ≤ y 0",
" x (n + 1) ≤ y (n + 1)",
" ∀ (k : ℕ), k < n → x (k + 1) ≤ f (x k)",
" ∀ (k : ℕ), k < n → f (y k) ≤ y (k + 1)",
" x n < y n",
" x 0 < y 0",
" x (n + 1) < y (n + 1)",
" k < n + 1 + 1"
] | [
" x n ≤ y n",
" x 0 ≤ y 0",
" x (n + 1) ≤ y (n + 1)",
" ∀ (k : ℕ), k < n → x (k + 1) ≤ f (x k)",
" ∀ (k : ℕ), k < n → f (y k) ≤ y (k + 1)",
" x n < y n"
] |
import Mathlib.Algebra.CharP.Invertible
import Mathlib.Algebra.Order.Interval.Set.Group
import Mathlib.Analysis.Convex.Segment
import Mathlib.LinearAlgebra.AffineSpace.FiniteDimensional
import Mathlib.Tactic.FieldSimp
#align_import analysis.convex.between from "leanprover-community/mathlib"@"571e13cacbed7bf042fd3058ce27157101433842"
variable (R : Type*) {V V' P P' : Type*}
open AffineEquiv AffineMap
section OrderedRing
variable [OrderedRing R] [AddCommGroup V] [Module R V] [AddTorsor V P]
variable [AddCommGroup V'] [Module R V'] [AddTorsor V' P']
def affineSegment (x y : P) :=
lineMap x y '' Set.Icc (0 : R) 1
#align affine_segment affineSegment
theorem affineSegment_eq_segment (x y : V) : affineSegment R x y = segment R x y := by
rw [segment_eq_image_lineMap, affineSegment]
#align affine_segment_eq_segment affineSegment_eq_segment
theorem affineSegment_comm (x y : P) : affineSegment R x y = affineSegment R y x := by
refine Set.ext fun z => ?_
constructor <;>
· rintro ⟨t, ht, hxy⟩
refine ⟨1 - t, ?_, ?_⟩
· rwa [Set.sub_mem_Icc_iff_right, sub_self, sub_zero]
· rwa [lineMap_apply_one_sub]
#align affine_segment_comm affineSegment_comm
theorem left_mem_affineSegment (x y : P) : x ∈ affineSegment R x y :=
⟨0, Set.left_mem_Icc.2 zero_le_one, lineMap_apply_zero _ _⟩
#align left_mem_affine_segment left_mem_affineSegment
theorem right_mem_affineSegment (x y : P) : y ∈ affineSegment R x y :=
⟨1, Set.right_mem_Icc.2 zero_le_one, lineMap_apply_one _ _⟩
#align right_mem_affine_segment right_mem_affineSegment
@[simp]
theorem affineSegment_same (x : P) : affineSegment R x x = {x} := by
-- Porting note: added as this doesn't do anything in `simp_rw` any more
rw [affineSegment]
-- Note: when adding "simp made no progress" in lean4#2336,
-- had to change `lineMap_same` to `lineMap_same _`. Not sure why?
-- Porting note: added `_ _` and `Function.const`
simp_rw [lineMap_same _, AffineMap.coe_const _ _, Function.const,
(Set.nonempty_Icc.mpr zero_le_one).image_const]
#align affine_segment_same affineSegment_same
variable {R}
@[simp]
theorem affineSegment_image (f : P →ᵃ[R] P') (x y : P) :
f '' affineSegment R x y = affineSegment R (f x) (f y) := by
rw [affineSegment, affineSegment, Set.image_image, ← comp_lineMap]
rfl
#align affine_segment_image affineSegment_image
variable (R)
@[simp]
theorem affineSegment_const_vadd_image (x y : P) (v : V) :
(v +ᵥ ·) '' affineSegment R x y = affineSegment R (v +ᵥ x) (v +ᵥ y) :=
affineSegment_image (AffineEquiv.constVAdd R P v : P →ᵃ[R] P) x y
#align affine_segment_const_vadd_image affineSegment_const_vadd_image
@[simp]
theorem affineSegment_vadd_const_image (x y : V) (p : P) :
(· +ᵥ p) '' affineSegment R x y = affineSegment R (x +ᵥ p) (y +ᵥ p) :=
affineSegment_image (AffineEquiv.vaddConst R p : V →ᵃ[R] P) x y
#align affine_segment_vadd_const_image affineSegment_vadd_const_image
@[simp]
theorem affineSegment_const_vsub_image (x y p : P) :
(p -ᵥ ·) '' affineSegment R x y = affineSegment R (p -ᵥ x) (p -ᵥ y) :=
affineSegment_image (AffineEquiv.constVSub R p : P →ᵃ[R] V) x y
#align affine_segment_const_vsub_image affineSegment_const_vsub_image
@[simp]
theorem affineSegment_vsub_const_image (x y p : P) :
(· -ᵥ p) '' affineSegment R x y = affineSegment R (x -ᵥ p) (y -ᵥ p) :=
affineSegment_image ((AffineEquiv.vaddConst R p).symm : P →ᵃ[R] V) x y
#align affine_segment_vsub_const_image affineSegment_vsub_const_image
variable {R}
@[simp]
| Mathlib/Analysis/Convex/Between.lean | 115 | 117 | theorem mem_const_vadd_affineSegment {x y z : P} (v : V) :
v +ᵥ z ∈ affineSegment R (v +ᵥ x) (v +ᵥ y) ↔ z ∈ affineSegment R x y := by |
rw [← affineSegment_const_vadd_image, (AddAction.injective v).mem_set_image]
| [
" affineSegment R x y = segment R x y",
" affineSegment R x y = affineSegment R y x",
" z ∈ affineSegment R x y ↔ z ∈ affineSegment R y x",
" z ∈ affineSegment R x y → z ∈ affineSegment R y x",
" z ∈ affineSegment R y x",
" 1 - t ∈ Set.Icc 0 1",
" (lineMap y x) (1 - t) = z",
" z ∈ affineSegment R y x ... | [
" affineSegment R x y = segment R x y",
" affineSegment R x y = affineSegment R y x",
" z ∈ affineSegment R x y ↔ z ∈ affineSegment R y x",
" z ∈ affineSegment R x y → z ∈ affineSegment R y x",
" z ∈ affineSegment R y x",
" 1 - t ∈ Set.Icc 0 1",
" (lineMap y x) (1 - t) = z",
" z ∈ affineSegment R y x ... |
import Mathlib.Algebra.BigOperators.NatAntidiagonal
import Mathlib.Algebra.Polynomial.RingDivision
#align_import data.polynomial.mirror from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
namespace Polynomial
open Polynomial
section Semiring
variable {R : Type*} [Semiring R] (p q : R[X])
noncomputable def mirror :=
p.reverse * X ^ p.natTrailingDegree
#align polynomial.mirror Polynomial.mirror
@[simp]
theorem mirror_zero : (0 : R[X]).mirror = 0 := by simp [mirror]
#align polynomial.mirror_zero Polynomial.mirror_zero
| Mathlib/Algebra/Polynomial/Mirror.lean | 47 | 53 | theorem mirror_monomial (n : ℕ) (a : R) : (monomial n a).mirror = monomial n a := by |
classical
by_cases ha : a = 0
· rw [ha, monomial_zero_right, mirror_zero]
· rw [mirror, reverse, natDegree_monomial n a, if_neg ha, natTrailingDegree_monomial ha, ←
C_mul_X_pow_eq_monomial, reflect_C_mul_X_pow, revAt_le (le_refl n), tsub_self, pow_zero,
mul_one]
| [
" mirror 0 = 0",
" ((monomial n) a).mirror = (monomial n) a"
] | [
" mirror 0 = 0",
" ((monomial n) a).mirror = (monomial n) a"
] |
import Mathlib.Data.Finset.Image
import Mathlib.Data.List.FinRange
#align_import data.fintype.basic from "leanprover-community/mathlib"@"d78597269638367c3863d40d45108f52207e03cf"
assert_not_exists MonoidWithZero
assert_not_exists MulAction
open Function
open Nat
universe u v
variable {α β γ : Type*}
class Fintype (α : Type*) where
elems : Finset α
complete : ∀ x : α, x ∈ elems
#align fintype Fintype
namespace Finset
variable [Fintype α] {s t : Finset α}
def univ : Finset α :=
@Fintype.elems α _
#align finset.univ Finset.univ
@[simp]
theorem mem_univ (x : α) : x ∈ (univ : Finset α) :=
Fintype.complete x
#align finset.mem_univ Finset.mem_univ
-- Porting note: removing @[simp], simp can prove it
theorem mem_univ_val : ∀ x, x ∈ (univ : Finset α).1 :=
mem_univ
#align finset.mem_univ_val Finset.mem_univ_val
theorem eq_univ_iff_forall : s = univ ↔ ∀ x, x ∈ s := by simp [ext_iff]
#align finset.eq_univ_iff_forall Finset.eq_univ_iff_forall
theorem eq_univ_of_forall : (∀ x, x ∈ s) → s = univ :=
eq_univ_iff_forall.2
#align finset.eq_univ_of_forall Finset.eq_univ_of_forall
@[simp, norm_cast]
theorem coe_univ : ↑(univ : Finset α) = (Set.univ : Set α) := by ext; simp
#align finset.coe_univ Finset.coe_univ
@[simp, norm_cast]
theorem coe_eq_univ : (s : Set α) = Set.univ ↔ s = univ := by rw [← coe_univ, coe_inj]
#align finset.coe_eq_univ Finset.coe_eq_univ
theorem Nonempty.eq_univ [Subsingleton α] : s.Nonempty → s = univ := by
rintro ⟨x, hx⟩
exact eq_univ_of_forall fun y => by rwa [Subsingleton.elim y x]
#align finset.nonempty.eq_univ Finset.Nonempty.eq_univ
theorem univ_nonempty_iff : (univ : Finset α).Nonempty ↔ Nonempty α := by
rw [← coe_nonempty, coe_univ, Set.nonempty_iff_univ_nonempty]
#align finset.univ_nonempty_iff Finset.univ_nonempty_iff
@[aesop unsafe apply (rule_sets := [finsetNonempty])]
theorem univ_nonempty [Nonempty α] : (univ : Finset α).Nonempty :=
univ_nonempty_iff.2 ‹_›
#align finset.univ_nonempty Finset.univ_nonempty
theorem univ_eq_empty_iff : (univ : Finset α) = ∅ ↔ IsEmpty α := by
rw [← not_nonempty_iff, ← univ_nonempty_iff, not_nonempty_iff_eq_empty]
#align finset.univ_eq_empty_iff Finset.univ_eq_empty_iff
@[simp]
theorem univ_eq_empty [IsEmpty α] : (univ : Finset α) = ∅ :=
univ_eq_empty_iff.2 ‹_›
#align finset.univ_eq_empty Finset.univ_eq_empty
@[simp]
theorem univ_unique [Unique α] : (univ : Finset α) = {default} :=
Finset.ext fun x => iff_of_true (mem_univ _) <| mem_singleton.2 <| Subsingleton.elim x default
#align finset.univ_unique Finset.univ_unique
@[simp]
theorem subset_univ (s : Finset α) : s ⊆ univ := fun a _ => mem_univ a
#align finset.subset_univ Finset.subset_univ
instance boundedOrder : BoundedOrder (Finset α) :=
{ inferInstanceAs (OrderBot (Finset α)) with
top := univ
le_top := subset_univ }
#align finset.bounded_order Finset.boundedOrder
@[simp]
theorem top_eq_univ : (⊤ : Finset α) = univ :=
rfl
#align finset.top_eq_univ Finset.top_eq_univ
theorem ssubset_univ_iff {s : Finset α} : s ⊂ univ ↔ s ≠ univ :=
@lt_top_iff_ne_top _ _ _ s
#align finset.ssubset_univ_iff Finset.ssubset_univ_iff
@[simp]
theorem univ_subset_iff {s : Finset α} : univ ⊆ s ↔ s = univ :=
@top_le_iff _ _ _ s
theorem codisjoint_left : Codisjoint s t ↔ ∀ ⦃a⦄, a ∉ s → a ∈ t := by
classical simp [codisjoint_iff, eq_univ_iff_forall, or_iff_not_imp_left]
#align finset.codisjoint_left Finset.codisjoint_left
theorem codisjoint_right : Codisjoint s t ↔ ∀ ⦃a⦄, a ∉ t → a ∈ s :=
Codisjoint_comm.trans codisjoint_left
#align finset.codisjoint_right Finset.codisjoint_right
section BooleanAlgebra
variable [DecidableEq α] {a : α}
instance booleanAlgebra : BooleanAlgebra (Finset α) :=
GeneralizedBooleanAlgebra.toBooleanAlgebra
#align finset.boolean_algebra Finset.booleanAlgebra
theorem sdiff_eq_inter_compl (s t : Finset α) : s \ t = s ∩ tᶜ :=
sdiff_eq
#align finset.sdiff_eq_inter_compl Finset.sdiff_eq_inter_compl
theorem compl_eq_univ_sdiff (s : Finset α) : sᶜ = univ \ s :=
rfl
#align finset.compl_eq_univ_sdiff Finset.compl_eq_univ_sdiff
@[simp]
| Mathlib/Data/Fintype/Basic.lean | 175 | 175 | theorem mem_compl : a ∈ sᶜ ↔ a ∉ s := by | simp [compl_eq_univ_sdiff]
| [
" s = univ ↔ ∀ (x : α), x ∈ s",
" ↑univ = Set.univ",
" x✝ ∈ ↑univ ↔ x✝ ∈ Set.univ",
" ↑s = Set.univ ↔ s = univ",
" s.Nonempty → s = univ",
" s = univ",
" y ∈ s",
" univ.Nonempty ↔ Nonempty α",
" univ = ∅ ↔ IsEmpty α",
" Codisjoint s t ↔ ∀ ⦃a : α⦄, a ∉ s → a ∈ t",
" a ∈ sᶜ ↔ a ∉ s"
] | [
" s = univ ↔ ∀ (x : α), x ∈ s",
" ↑univ = Set.univ",
" x✝ ∈ ↑univ ↔ x✝ ∈ Set.univ",
" ↑s = Set.univ ↔ s = univ",
" s.Nonempty → s = univ",
" s = univ",
" y ∈ s",
" univ.Nonempty ↔ Nonempty α",
" univ = ∅ ↔ IsEmpty α",
" Codisjoint s t ↔ ∀ ⦃a : α⦄, a ∉ s → a ∈ t",
" a ∈ sᶜ ↔ a ∉ s"
] |
import Mathlib.CategoryTheory.Comma.Basic
import Mathlib.CategoryTheory.PUnit
import Mathlib.CategoryTheory.Limits.Shapes.Terminal
import Mathlib.CategoryTheory.EssentiallySmall
import Mathlib.Logic.Small.Set
#align_import category_theory.structured_arrow from "leanprover-community/mathlib"@"8a318021995877a44630c898d0b2bc376fceef3b"
namespace CategoryTheory
-- morphism levels before object levels. See note [CategoryTheory universes].
universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
-- We explicitly come from `PUnit.{1}` here to obtain the correct universe for morphisms of
-- structured arrows.
-- Porting note(#5171): linter not ported yet
-- @[nolint has_nonempty_instance]
def StructuredArrow (S : D) (T : C ⥤ D) :=
Comma (Functor.fromPUnit.{0} S) T
#align category_theory.structured_arrow CategoryTheory.StructuredArrow
-- Porting note: not found by inferInstance
instance (S : D) (T : C ⥤ D) : Category (StructuredArrow S T) := commaCategory
namespace StructuredArrow
@[simps!]
def proj (S : D) (T : C ⥤ D) : StructuredArrow S T ⥤ C :=
Comma.snd _ _
#align category_theory.structured_arrow.proj CategoryTheory.StructuredArrow.proj
variable {S S' S'' : D} {Y Y' Y'' : C} {T T' : C ⥤ D}
-- Porting note: this lemma was added because `Comma.hom_ext`
-- was not triggered automatically
-- See https://github.com/leanprover-community/mathlib4/issues/5229
@[ext]
lemma hom_ext {X Y : StructuredArrow S T} (f g : X ⟶ Y) (h : f.right = g.right) : f = g :=
CommaMorphism.ext _ _ (Subsingleton.elim _ _) h
@[simp]
theorem hom_eq_iff {X Y : StructuredArrow S T} (f g : X ⟶ Y) : f = g ↔ f.right = g.right :=
⟨fun h ↦ by rw [h], hom_ext _ _⟩
def mk (f : S ⟶ T.obj Y) : StructuredArrow S T :=
⟨⟨⟨⟩⟩, Y, f⟩
#align category_theory.structured_arrow.mk CategoryTheory.StructuredArrow.mk
@[simp]
theorem mk_left (f : S ⟶ T.obj Y) : (mk f).left = ⟨⟨⟩⟩ :=
rfl
#align category_theory.structured_arrow.mk_left CategoryTheory.StructuredArrow.mk_left
@[simp]
theorem mk_right (f : S ⟶ T.obj Y) : (mk f).right = Y :=
rfl
#align category_theory.structured_arrow.mk_right CategoryTheory.StructuredArrow.mk_right
@[simp]
theorem mk_hom_eq_self (f : S ⟶ T.obj Y) : (mk f).hom = f :=
rfl
#align category_theory.structured_arrow.mk_hom_eq_self CategoryTheory.StructuredArrow.mk_hom_eq_self
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Comma/StructuredArrow.lean | 90 | 91 | theorem w {A B : StructuredArrow S T} (f : A ⟶ B) : A.hom ≫ T.map f.right = B.hom := by |
have := f.w; aesop_cat
| [
" f.right = g.right",
" A.hom ≫ T.map f.right = B.hom"
] | [
" f.right = g.right",
" A.hom ≫ T.map f.right = B.hom"
] |
import Mathlib.Analysis.SpecialFunctions.JapaneseBracket
import Mathlib.Analysis.SpecialFunctions.Integrals
import Mathlib.MeasureTheory.Group.Integral
import Mathlib.MeasureTheory.Integral.IntegralEqImproper
import Mathlib.MeasureTheory.Measure.Lebesgue.Integral
#align_import analysis.special_functions.improper_integrals from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
open Real Set Filter MeasureTheory intervalIntegral
open scoped Topology
theorem integrableOn_exp_Iic (c : ℝ) : IntegrableOn exp (Iic c) := by
refine
integrableOn_Iic_of_intervalIntegral_norm_bounded (exp c) c
(fun y => intervalIntegrable_exp.1) tendsto_id
(eventually_of_mem (Iic_mem_atBot 0) fun y _ => ?_)
simp_rw [norm_of_nonneg (exp_pos _).le, integral_exp, sub_le_self_iff]
exact (exp_pos _).le
#align integrable_on_exp_Iic integrableOn_exp_Iic
theorem integral_exp_Iic (c : ℝ) : ∫ x : ℝ in Iic c, exp x = exp c := by
refine
tendsto_nhds_unique
(intervalIntegral_tendsto_integral_Iic _ (integrableOn_exp_Iic _) tendsto_id) ?_
simp_rw [integral_exp, show 𝓝 (exp c) = 𝓝 (exp c - 0) by rw [sub_zero]]
exact tendsto_exp_atBot.const_sub _
#align integral_exp_Iic integral_exp_Iic
theorem integral_exp_Iic_zero : ∫ x : ℝ in Iic 0, exp x = 1 :=
exp_zero ▸ integral_exp_Iic 0
#align integral_exp_Iic_zero integral_exp_Iic_zero
theorem integral_exp_neg_Ioi (c : ℝ) : (∫ x : ℝ in Ioi c, exp (-x)) = exp (-c) := by
simpa only [integral_comp_neg_Ioi] using integral_exp_Iic (-c)
#align integral_exp_neg_Ioi integral_exp_neg_Ioi
theorem integral_exp_neg_Ioi_zero : (∫ x : ℝ in Ioi 0, exp (-x)) = 1 := by
simpa only [neg_zero, exp_zero] using integral_exp_neg_Ioi 0
#align integral_exp_neg_Ioi_zero integral_exp_neg_Ioi_zero
theorem integrableOn_Ioi_rpow_of_lt {a : ℝ} (ha : a < -1) {c : ℝ} (hc : 0 < c) :
IntegrableOn (fun t : ℝ => t ^ a) (Ioi c) := by
have hd : ∀ x ∈ Ici c, HasDerivAt (fun t => t ^ (a + 1) / (a + 1)) (x ^ a) x := by
intro x hx
-- Porting note: helped `convert` with explicit arguments
convert (hasDerivAt_rpow_const (p := a + 1) (Or.inl (hc.trans_le hx).ne')).div_const _ using 1
field_simp [show a + 1 ≠ 0 from ne_of_lt (by linarith), mul_comm]
have ht : Tendsto (fun t => t ^ (a + 1) / (a + 1)) atTop (𝓝 (0 / (a + 1))) := by
apply Tendsto.div_const
simpa only [neg_neg] using tendsto_rpow_neg_atTop (by linarith : 0 < -(a + 1))
exact
integrableOn_Ioi_deriv_of_nonneg' hd (fun t ht => rpow_nonneg (hc.trans ht).le a) ht
#align integrable_on_Ioi_rpow_of_lt integrableOn_Ioi_rpow_of_lt
theorem integrableOn_Ioi_rpow_iff {s t : ℝ} (ht : 0 < t) :
IntegrableOn (fun x ↦ x ^ s) (Ioi t) ↔ s < -1 := by
refine ⟨fun h ↦ ?_, fun h ↦ integrableOn_Ioi_rpow_of_lt h ht⟩
contrapose! h
intro H
have H' : IntegrableOn (fun x ↦ x ^ s) (Ioi (max 1 t)) :=
H.mono (Set.Ioi_subset_Ioi (le_max_right _ _)) le_rfl
have : IntegrableOn (fun x ↦ x⁻¹) (Ioi (max 1 t)) := by
apply H'.mono' measurable_inv.aestronglyMeasurable
filter_upwards [ae_restrict_mem measurableSet_Ioi] with x hx
have x_one : 1 ≤ x := ((le_max_left _ _).trans_lt (mem_Ioi.1 hx)).le
simp only [norm_inv, Real.norm_eq_abs, abs_of_nonneg (zero_le_one.trans x_one)]
rw [← Real.rpow_neg_one x]
exact Real.rpow_le_rpow_of_exponent_le x_one h
exact not_IntegrableOn_Ioi_inv this
| Mathlib/Analysis/SpecialFunctions/ImproperIntegrals.lean | 93 | 101 | theorem not_integrableOn_Ioi_rpow (s : ℝ) : ¬ IntegrableOn (fun x ↦ x ^ s) (Ioi (0 : ℝ)) := by |
intro h
rcases le_or_lt s (-1) with hs|hs
· have : IntegrableOn (fun x ↦ x ^ s) (Ioo (0 : ℝ) 1) := h.mono Ioo_subset_Ioi_self le_rfl
rw [integrableOn_Ioo_rpow_iff zero_lt_one] at this
exact hs.not_lt this
· have : IntegrableOn (fun x ↦ x ^ s) (Ioi (1 : ℝ)) := h.mono (Ioi_subset_Ioi zero_le_one) le_rfl
rw [integrableOn_Ioi_rpow_iff zero_lt_one] at this
exact hs.not_lt this
| [
" IntegrableOn rexp (Iic c) volume",
" ∫ (x : ℝ) in id y..c, ‖rexp x‖ ≤ rexp c",
" 0 ≤ rexp (id y)",
" ∫ (x : ℝ) in Iic c, rexp x = rexp c",
" Tendsto (fun i => ∫ (x : ℝ) in id i..c, rexp x) atBot (𝓝 (rexp c))",
" 𝓝 (rexp c) = 𝓝 (rexp c - 0)",
" Tendsto (fun i => rexp c - rexp (id i)) atBot (𝓝 (rexp... | [
" IntegrableOn rexp (Iic c) volume",
" ∫ (x : ℝ) in id y..c, ‖rexp x‖ ≤ rexp c",
" 0 ≤ rexp (id y)",
" ∫ (x : ℝ) in Iic c, rexp x = rexp c",
" Tendsto (fun i => ∫ (x : ℝ) in id i..c, rexp x) atBot (𝓝 (rexp c))",
" 𝓝 (rexp c) = 𝓝 (rexp c - 0)",
" Tendsto (fun i => rexp c - rexp (id i)) atBot (𝓝 (rexp... |
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
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
#align algebraic_geometry.quasi_compact_affine_property_iff_quasi_separated_space AlgebraicGeometry.quasi_compact_affineProperty_iff_quasiSeparatedSpace
theorem quasiSeparated_eq_diagonal_is_quasiCompact :
@QuasiSeparated = MorphismProperty.diagonal @QuasiCompact := by ext; exact quasiSeparated_iff _
#align algebraic_geometry.quasi_separated_eq_diagonal_is_quasi_compact AlgebraicGeometry.quasiSeparated_eq_diagonal_is_quasiCompact
theorem quasi_compact_affineProperty_diagonal_eq :
QuasiCompact.affineProperty.diagonal = QuasiSeparated.affineProperty := by
funext; rw [quasi_compact_affineProperty_iff_quasiSeparatedSpace]; rfl
#align algebraic_geometry.quasi_compact_affine_property_diagonal_eq AlgebraicGeometry.quasi_compact_affineProperty_diagonal_eq
| Mathlib/AlgebraicGeometry/Morphisms/QuasiSeparated.lean | 126 | 130 | theorem quasiSeparated_eq_affineProperty_diagonal :
@QuasiSeparated = targetAffineLocally QuasiCompact.affineProperty.diagonal := by |
rw [quasiSeparated_eq_diagonal_is_quasiCompact, quasiCompact_eq_affineProperty]
exact
diagonal_targetAffineLocally_eq_targetAffineLocally _ QuasiCompact.affineProperty_isLocal
| [
" QuasiSeparatedSpace ↑↑X.toPresheafedSpace ↔ ∀ (U V : ↑X.affineOpens), IsCompact (↑↑U ∩ ↑↑V)",
" (∀ (U V : Set ↑↑X.toPresheafedSpace), IsOpen U → IsCompact U → IsOpen V → IsCompact V → IsCompact (U ∩ V)) ↔\n ∀ (U V : ↑X.affineOpens), IsCompact (↑↑U ∩ ↑↑V)",
" (∀ (U V : Set ↑↑X.toPresheafedSpace), IsOpen U →... | [
" QuasiSeparatedSpace ↑↑X.toPresheafedSpace ↔ ∀ (U V : ↑X.affineOpens), IsCompact (↑↑U ∩ ↑↑V)",
" (∀ (U V : Set ↑↑X.toPresheafedSpace), IsOpen U → IsCompact U → IsOpen V → IsCompact V → IsCompact (U ∩ V)) ↔\n ∀ (U V : ↑X.affineOpens), IsCompact (↑↑U ∩ ↑↑V)",
" (∀ (U V : Set ↑↑X.toPresheafedSpace), IsOpen U →... |
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import set_theory.cardinal.continuum from "leanprover-community/mathlib"@"e08a42b2dd544cf11eba72e5fc7bf199d4349925"
namespace Cardinal
universe u v
open Cardinal
def continuum : Cardinal.{u} :=
2 ^ ℵ₀
#align cardinal.continuum Cardinal.continuum
scoped notation "𝔠" => Cardinal.continuum
@[simp]
theorem two_power_aleph0 : 2 ^ aleph0.{u} = continuum.{u} :=
rfl
#align cardinal.two_power_aleph_0 Cardinal.two_power_aleph0
@[simp]
theorem lift_continuum : lift.{v} 𝔠 = 𝔠 := by
rw [← two_power_aleph0, lift_two_power, lift_aleph0, two_power_aleph0]
#align cardinal.lift_continuum Cardinal.lift_continuum
@[simp]
| Mathlib/SetTheory/Cardinal/Continuum.lean | 46 | 48 | theorem continuum_le_lift {c : Cardinal.{u}} : 𝔠 ≤ lift.{v} c ↔ 𝔠 ≤ c := by |
-- Porting note: added explicit universes
rw [← lift_continuum.{u,v}, lift_le]
| [
" lift.{v, u_1} 𝔠 = 𝔠",
" 𝔠 ≤ lift.{v, u} c ↔ 𝔠 ≤ c"
] | [
" lift.{v, u_1} 𝔠 = 𝔠",
" 𝔠 ≤ lift.{v, u} c ↔ 𝔠 ≤ c"
] |
import Mathlib.Probability.Kernel.MeasurableIntegral
import Mathlib.MeasureTheory.Integral.SetIntegral
#align_import probability.kernel.with_density from "leanprover-community/mathlib"@"c0d694db494dd4f9aa57f2714b6e4c82b4ebc113"
open MeasureTheory ProbabilityTheory
open scoped MeasureTheory ENNReal NNReal
namespace ProbabilityTheory.kernel
variable {α β ι : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β}
variable {κ : kernel α β} {f : α → β → ℝ≥0∞}
noncomputable def withDensity (κ : kernel α β) [IsSFiniteKernel κ] (f : α → β → ℝ≥0∞) :
kernel α β :=
@dite _ (Measurable (Function.uncurry f)) (Classical.dec _) (fun hf =>
(⟨fun a => (κ a).withDensity (f a),
by
refine Measure.measurable_of_measurable_coe _ fun s hs => ?_
simp_rw [withDensity_apply _ hs]
exact hf.set_lintegral_kernel_prod_right hs⟩ : kernel α β)) fun _ => 0
#align probability_theory.kernel.with_density ProbabilityTheory.kernel.withDensity
theorem withDensity_of_not_measurable (κ : kernel α β) [IsSFiniteKernel κ]
(hf : ¬Measurable (Function.uncurry f)) : withDensity κ f = 0 := by classical exact dif_neg hf
#align probability_theory.kernel.with_density_of_not_measurable ProbabilityTheory.kernel.withDensity_of_not_measurable
protected theorem withDensity_apply (κ : kernel α β) [IsSFiniteKernel κ]
(hf : Measurable (Function.uncurry f)) (a : α) :
withDensity κ f a = (κ a).withDensity (f a) := by
classical
rw [withDensity, dif_pos hf]
rfl
#align probability_theory.kernel.with_density_apply ProbabilityTheory.kernel.withDensity_apply
protected theorem withDensity_apply' (κ : kernel α β) [IsSFiniteKernel κ]
(hf : Measurable (Function.uncurry f)) (a : α) (s : Set β) :
withDensity κ f a s = ∫⁻ b in s, f a b ∂κ a := by
rw [kernel.withDensity_apply κ hf, withDensity_apply' _ s]
#align probability_theory.kernel.with_density_apply' ProbabilityTheory.kernel.withDensity_apply'
nonrec lemma withDensity_congr_ae (κ : kernel α β) [IsSFiniteKernel κ] {f g : α → β → ℝ≥0∞}
(hf : Measurable (Function.uncurry f)) (hg : Measurable (Function.uncurry g))
(hfg : ∀ a, f a =ᵐ[κ a] g a) :
withDensity κ f = withDensity κ g := by
ext a
rw [kernel.withDensity_apply _ hf,kernel.withDensity_apply _ hg, withDensity_congr_ae (hfg a)]
nonrec lemma withDensity_absolutelyContinuous [IsSFiniteKernel κ]
(f : α → β → ℝ≥0∞) (a : α) :
kernel.withDensity κ f a ≪ κ a := by
by_cases hf : Measurable (Function.uncurry f)
· rw [kernel.withDensity_apply _ hf]
exact withDensity_absolutelyContinuous _ _
· rw [withDensity_of_not_measurable _ hf]
simp [Measure.AbsolutelyContinuous.zero]
@[simp]
lemma withDensity_one (κ : kernel α β) [IsSFiniteKernel κ] :
kernel.withDensity κ 1 = κ := by
ext; rw [kernel.withDensity_apply _ measurable_const]; simp
@[simp]
lemma withDensity_one' (κ : kernel α β) [IsSFiniteKernel κ] :
kernel.withDensity κ (fun _ _ ↦ 1) = κ := kernel.withDensity_one _
@[simp]
lemma withDensity_zero (κ : kernel α β) [IsSFiniteKernel κ] :
kernel.withDensity κ 0 = 0 := by
ext; rw [kernel.withDensity_apply _ measurable_const]; simp
@[simp]
lemma withDensity_zero' (κ : kernel α β) [IsSFiniteKernel κ] :
kernel.withDensity κ (fun _ _ ↦ 0) = 0 := kernel.withDensity_zero _
theorem lintegral_withDensity (κ : kernel α β) [IsSFiniteKernel κ]
(hf : Measurable (Function.uncurry f)) (a : α) {g : β → ℝ≥0∞} (hg : Measurable g) :
∫⁻ b, g b ∂withDensity κ f a = ∫⁻ b, f a b * g b ∂κ a := by
rw [kernel.withDensity_apply _ hf,
lintegral_withDensity_eq_lintegral_mul _ (Measurable.of_uncurry_left hf) hg]
simp_rw [Pi.mul_apply]
#align probability_theory.kernel.lintegral_with_density ProbabilityTheory.kernel.lintegral_withDensity
| Mathlib/Probability/Kernel/WithDensity.lean | 116 | 122 | theorem integral_withDensity {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
{f : β → E} [IsSFiniteKernel κ] {a : α} {g : α → β → ℝ≥0}
(hg : Measurable (Function.uncurry g)) :
∫ b, f b ∂withDensity κ (fun a b => g a b) a = ∫ b, g a b • f b ∂κ a := by |
rw [kernel.withDensity_apply, integral_withDensity_eq_integral_smul]
· exact Measurable.of_uncurry_left hg
· exact measurable_coe_nnreal_ennreal.comp hg
| [
" (fun a => (κ a).withDensity (f a)) ∈ kernel α β",
" Measurable fun b => ((κ b).withDensity (f b)) s",
" Measurable fun b => ∫⁻ (a : β) in s, f b a ∂κ b",
" withDensity κ f = 0",
" (withDensity κ f) a = (κ a).withDensity (f a)",
" ⟨fun a => (κ a).withDensity (f a), ⋯⟩ a = (κ a).withDensity (f a)",
" ((... | [
" (fun a => (κ a).withDensity (f a)) ∈ kernel α β",
" Measurable fun b => ((κ b).withDensity (f b)) s",
" Measurable fun b => ∫⁻ (a : β) in s, f b a ∂κ b",
" withDensity κ f = 0",
" (withDensity κ f) a = (κ a).withDensity (f a)",
" ⟨fun a => (κ a).withDensity (f a), ⋯⟩ a = (κ a).withDensity (f a)",
" ((... |
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 NormedField
| Mathlib/Analysis/Asymptotics/SpecificAsymptotics.lean | 28 | 33 | theorem Filter.IsBoundedUnder.isLittleO_sub_self_inv {𝕜 E : Type*} [NormedField 𝕜] [Norm E] {a : 𝕜}
{f : 𝕜 → E} (h : IsBoundedUnder (· ≤ ·) (𝓝[≠] a) (norm ∘ f)) :
f =o[𝓝[≠] a] fun x => (x - a)⁻¹ := by |
refine (h.isBigO_const (one_ne_zero' ℝ)).trans_isLittleO (isLittleO_const_left.2 <| Or.inr ?_)
simp only [(· ∘ ·), norm_inv]
exact (tendsto_norm_sub_self_punctured_nhds a).inv_tendsto_zero
| [
" f =o[𝓝[≠] a] fun x => (x - a)⁻¹",
" Tendsto (norm ∘ fun x => (x - a)⁻¹) (𝓝[≠] a) atTop",
" Tendsto (fun x => ‖x - a‖⁻¹) (𝓝[≠] a) atTop"
] | [
" f =o[𝓝[≠] a] fun x => (x - a)⁻¹"
] |
import Mathlib.Data.Vector.Basic
import Mathlib.Data.Vector.Snoc
set_option autoImplicit true
namespace Vector
section Fold
section UnusedInput
variable {xs : Vector α n} {ys : Vector β n}
@[simp]
theorem mapAccumr₂_unused_input_left [Inhabited α] (f : α → β → σ → σ × γ)
(h : ∀ a b s, f default b s = f a b s) :
mapAccumr₂ f xs ys s = mapAccumr (fun b s => f default b s) ys s := by
induction xs, ys using Vector.revInductionOn₂ generalizing s with
| nil => rfl
| snoc xs ys x y ih => simp [h x y s, ih]
@[simp]
| Mathlib/Data/Vector/MapLemmas.lean | 354 | 359 | theorem mapAccumr₂_unused_input_right [Inhabited β] (f : α → β → σ → σ × γ)
(h : ∀ a b s, f a default s = f a b s) :
mapAccumr₂ f xs ys s = mapAccumr (fun a s => f a default s) xs s := by |
induction xs, ys using Vector.revInductionOn₂ generalizing s with
| nil => rfl
| snoc xs ys x y ih => simp [h x y s, ih]
| [
" mapAccumr₂ f xs ys s = mapAccumr (fun b s => f default b s) ys s",
" mapAccumr₂ f nil nil s = mapAccumr (fun b s => f default b s) nil s",
" mapAccumr₂ f (xs.snoc x) (ys.snoc y) s = mapAccumr (fun b s => f default b s) (ys.snoc y) s",
" mapAccumr₂ f xs ys s = mapAccumr (fun a s => f a default s) xs s",
" ... | [
" mapAccumr₂ f xs ys s = mapAccumr (fun b s => f default b s) ys s",
" mapAccumr₂ f nil nil s = mapAccumr (fun b s => f default b s) nil s",
" mapAccumr₂ f (xs.snoc x) (ys.snoc y) s = mapAccumr (fun b s => f default b s) (ys.snoc y) s",
" mapAccumr₂ f xs ys s = mapAccumr (fun a s => f a default s) xs s"
] |
import Mathlib.Algebra.CharP.LocalRing
import Mathlib.RingTheory.Ideal.Quotient
import Mathlib.Tactic.FieldSimp
#align_import algebra.char_p.mixed_char_zero from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
variable (R : Type*) [CommRing R]
class MixedCharZero (p : ℕ) : Prop where
[toCharZero : CharZero R]
charP_quotient : ∃ I : Ideal R, I ≠ ⊤ ∧ CharP (R ⧸ I) p
#align mixed_char_zero MixedCharZero
namespace EqualCharZero
theorem of_algebraRat [Algebra ℚ R] : ∀ I : Ideal R, I ≠ ⊤ → CharZero (R ⧸ I) := by
intro I hI
constructor
intro a b h_ab
contrapose! hI
-- `↑a - ↑b` is a unit contained in `I`, which contradicts `I ≠ ⊤`.
refine I.eq_top_of_isUnit_mem ?_ (IsUnit.map (algebraMap ℚ R) (IsUnit.mk0 (a - b : ℚ) ?_))
· simpa only [← Ideal.Quotient.eq_zero_iff_mem, map_sub, sub_eq_zero, map_natCast]
simpa only [Ne, sub_eq_zero] using (@Nat.cast_injective ℚ _ _).ne hI
set_option linter.uppercaseLean3 false in
#align Q_algebra_to_equal_char_zero EqualCharZero.of_algebraRat
section ConstructionAlgebraRat
variable {R}
theorem PNat.isUnit_natCast [h : Fact (∀ I : Ideal R, I ≠ ⊤ → CharZero (R ⧸ I))]
(n : ℕ+) : IsUnit (n : R) := by
-- `n : R` is a unit iff `(n)` is not a proper ideal in `R`.
rw [← Ideal.span_singleton_eq_top]
-- So by contrapositive, we should show the quotient does not have characteristic zero.
apply not_imp_comm.mp (h.elim (Ideal.span {↑n}))
intro h_char_zero
-- In particular, the image of `n` in the quotient should be nonzero.
apply h_char_zero.cast_injective.ne n.ne_zero
-- But `n` generates the ideal, so its image is clearly zero.
rw [← map_natCast (Ideal.Quotient.mk _), Nat.cast_zero, Ideal.Quotient.eq_zero_iff_mem]
exact Ideal.subset_span (Set.mem_singleton _)
#align equal_char_zero.pnat_coe_is_unit EqualCharZero.PNat.isUnit_natCast
@[coe]
noncomputable def pnatCast [Fact (∀ I : Ideal R, I ≠ ⊤ → CharZero (R ⧸ I))] : ℕ+ → Rˣ :=
fun n => (PNat.isUnit_natCast n).unit
noncomputable instance coePNatUnits
[Fact (∀ I : Ideal R, I ≠ ⊤ → CharZero (R ⧸ I))] : Coe ℕ+ Rˣ :=
⟨EqualCharZero.pnatCast⟩
#align equal_char_zero.pnat_has_coe_units EqualCharZero.coePNatUnits
@[simp]
| Mathlib/Algebra/CharP/MixedCharZero.lean | 204 | 209 | theorem pnatCast_one [Fact (∀ I : Ideal R, I ≠ ⊤ → CharZero (R ⧸ I))] : ((1 : ℕ+) : Rˣ) = 1 := by |
apply Units.ext
rw [Units.val_one]
change ((PNat.isUnit_natCast (R := R) 1).unit : R) = 1
rw [IsUnit.unit_spec (PNat.isUnit_natCast 1)]
rw [PNat.one_coe, Nat.cast_one]
| [
" ∀ (I : Ideal R), I ≠ ⊤ → CharZero (R ⧸ I)",
" CharZero (R ⧸ I)",
" Function.Injective Nat.cast",
" a = b",
" I = ⊤",
" (algebraMap ℚ R) (↑a - ↑b) ∈ I",
" ↑a - ↑b ≠ 0",
" IsUnit ↑↑n",
" Ideal.span {↑↑n} = ⊤",
" ¬CharZero (R ⧸ Ideal.span {↑↑n})",
" False",
" ↑↑n = ↑0",
" ↑↑n ∈ Ideal.span {↑↑... | [
" ∀ (I : Ideal R), I ≠ ⊤ → CharZero (R ⧸ I)",
" CharZero (R ⧸ I)",
" Function.Injective Nat.cast",
" a = b",
" I = ⊤",
" (algebraMap ℚ R) (↑a - ↑b) ∈ I",
" ↑a - ↑b ≠ 0",
" IsUnit ↑↑n",
" Ideal.span {↑↑n} = ⊤",
" ¬CharZero (R ⧸ Ideal.span {↑↑n})",
" False",
" ↑↑n = ↑0",
" ↑↑n ∈ Ideal.span {↑↑... |
import Mathlib.RingTheory.Nilpotent.Basic
import Mathlib.RingTheory.UniqueFactorizationDomain
#align_import algebra.squarefree from "leanprover-community/mathlib"@"00d163e35035c3577c1c79fa53b68de17781ffc1"
variable {R : Type*}
def Squarefree [Monoid R] (r : R) : Prop :=
∀ x : R, x * x ∣ r → IsUnit x
#align squarefree Squarefree
theorem IsRelPrime.of_squarefree_mul [CommMonoid R] {m n : R} (h : Squarefree (m * n)) :
IsRelPrime m n := fun c hca hcb ↦ h c (mul_dvd_mul hca hcb)
@[simp]
theorem IsUnit.squarefree [CommMonoid R] {x : R} (h : IsUnit x) : Squarefree x := fun _ hdvd =>
isUnit_of_mul_isUnit_left (isUnit_of_dvd_unit hdvd h)
#align is_unit.squarefree IsUnit.squarefree
-- @[simp] -- Porting note (#10618): simp can prove this
theorem squarefree_one [CommMonoid R] : Squarefree (1 : R) :=
isUnit_one.squarefree
#align squarefree_one squarefree_one
@[simp]
theorem not_squarefree_zero [MonoidWithZero R] [Nontrivial R] : ¬Squarefree (0 : R) := by
erw [not_forall]
exact ⟨0, by simp⟩
#align not_squarefree_zero not_squarefree_zero
| Mathlib/Algebra/Squarefree/Basic.lean | 60 | 63 | theorem Squarefree.ne_zero [MonoidWithZero R] [Nontrivial R] {m : R} (hm : Squarefree (m : R)) :
m ≠ 0 := by |
rintro rfl
exact not_squarefree_zero hm
| [
" ¬Squarefree 0",
" ∃ x, ¬(x * x ∣ 0 → IsUnit x)",
" ¬(0 * 0 ∣ 0 → IsUnit 0)",
" m ≠ 0",
" False"
] | [
" ¬Squarefree 0",
" ∃ x, ¬(x * x ∣ 0 → IsUnit x)",
" ¬(0 * 0 ∣ 0 → IsUnit 0)",
" m ≠ 0"
] |
import Mathlib.Data.Set.Image
import Mathlib.Data.Set.Lattice
#align_import data.set.sigma from "leanprover-community/mathlib"@"2258b40dacd2942571c8ce136215350c702dc78f"
namespace Set
variable {ι ι' : Type*} {α β : ι → Type*} {s s₁ s₂ : Set ι} {t t₁ t₂ : ∀ i, Set (α i)}
{u : Set (Σ i, α i)} {x : Σ i, α i} {i j : ι} {a : α i}
@[simp]
theorem range_sigmaMk (i : ι) : range (Sigma.mk i : α i → Sigma α) = Sigma.fst ⁻¹' {i} := by
apply Subset.antisymm
· rintro _ ⟨b, rfl⟩
simp
· rintro ⟨x, y⟩ (rfl | _)
exact mem_range_self y
#align set.range_sigma_mk Set.range_sigmaMk
| Mathlib/Data/Set/Sigma.lean | 31 | 34 | theorem preimage_image_sigmaMk_of_ne (h : i ≠ j) (s : Set (α j)) :
Sigma.mk i ⁻¹' (Sigma.mk j '' s) = ∅ := by |
ext x
simp [h.symm]
| [
" range (Sigma.mk i) = Sigma.fst ⁻¹' {i}",
" range (Sigma.mk i) ⊆ Sigma.fst ⁻¹' {i}",
" ⟨i, b⟩ ∈ Sigma.fst ⁻¹' {i}",
" Sigma.fst ⁻¹' {i} ⊆ range (Sigma.mk i)",
" ⟨x, y⟩ ∈ range (Sigma.mk ⟨x, y⟩.fst)",
" Sigma.mk i ⁻¹' (Sigma.mk j '' s) = ∅",
" x ∈ Sigma.mk i ⁻¹' (Sigma.mk j '' s) ↔ x ∈ ∅"
] | [
" range (Sigma.mk i) = Sigma.fst ⁻¹' {i}",
" range (Sigma.mk i) ⊆ Sigma.fst ⁻¹' {i}",
" ⟨i, b⟩ ∈ Sigma.fst ⁻¹' {i}",
" Sigma.fst ⁻¹' {i} ⊆ range (Sigma.mk i)",
" ⟨x, y⟩ ∈ range (Sigma.mk ⟨x, y⟩.fst)",
" Sigma.mk i ⁻¹' (Sigma.mk j '' s) = ∅"
] |
import Mathlib.RingTheory.Ideal.Maps
#align_import ring_theory.ideal.prod from "leanprover-community/mathlib"@"052f6013363326d50cb99c6939814a4b8eb7b301"
universe u v
variable {R : Type u} {S : Type v} [Semiring R] [Semiring S] (I I' : Ideal R) (J J' : Ideal S)
namespace Ideal
def prod : Ideal (R × S) where
carrier := { x | x.fst ∈ I ∧ x.snd ∈ J }
zero_mem' := by simp
add_mem' := by
rintro ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ⟨ha₁, ha₂⟩ ⟨hb₁, hb₂⟩
exact ⟨I.add_mem ha₁ hb₁, J.add_mem ha₂ hb₂⟩
smul_mem' := by
rintro ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ⟨hb₁, hb₂⟩
exact ⟨I.mul_mem_left _ hb₁, J.mul_mem_left _ hb₂⟩
#align ideal.prod Ideal.prod
@[simp]
theorem mem_prod {r : R} {s : S} : (⟨r, s⟩ : R × S) ∈ prod I J ↔ r ∈ I ∧ s ∈ J :=
Iff.rfl
#align ideal.mem_prod Ideal.mem_prod
@[simp]
theorem prod_top_top : prod (⊤ : Ideal R) (⊤ : Ideal S) = ⊤ :=
Ideal.ext <| by simp
#align ideal.prod_top_top Ideal.prod_top_top
theorem ideal_prod_eq (I : Ideal (R × S)) :
I = Ideal.prod (map (RingHom.fst R S) I : Ideal R) (map (RingHom.snd R S) I) := by
apply Ideal.ext
rintro ⟨r, s⟩
rw [mem_prod, mem_map_iff_of_surjective (RingHom.fst R S) Prod.fst_surjective,
mem_map_iff_of_surjective (RingHom.snd R S) Prod.snd_surjective]
refine ⟨fun h => ⟨⟨_, ⟨h, rfl⟩⟩, ⟨_, ⟨h, rfl⟩⟩⟩, ?_⟩
rintro ⟨⟨⟨r, s'⟩, ⟨h₁, rfl⟩⟩, ⟨⟨r', s⟩, ⟨h₂, rfl⟩⟩⟩
simpa using I.add_mem (I.mul_mem_left (1, 0) h₁) (I.mul_mem_left (0, 1) h₂)
#align ideal.ideal_prod_eq Ideal.ideal_prod_eq
@[simp]
theorem map_fst_prod (I : Ideal R) (J : Ideal S) : map (RingHom.fst R S) (prod I J) = I := by
ext x
rw [mem_map_iff_of_surjective (RingHom.fst R S) Prod.fst_surjective]
exact
⟨by
rintro ⟨x, ⟨h, rfl⟩⟩
exact h.1, fun h => ⟨⟨x, 0⟩, ⟨⟨h, Ideal.zero_mem _⟩, rfl⟩⟩⟩
#align ideal.map_fst_prod Ideal.map_fst_prod
@[simp]
theorem map_snd_prod (I : Ideal R) (J : Ideal S) : map (RingHom.snd R S) (prod I J) = J := by
ext x
rw [mem_map_iff_of_surjective (RingHom.snd R S) Prod.snd_surjective]
exact
⟨by
rintro ⟨x, ⟨h, rfl⟩⟩
exact h.2, fun h => ⟨⟨0, x⟩, ⟨⟨Ideal.zero_mem _, h⟩, rfl⟩⟩⟩
#align ideal.map_snd_prod Ideal.map_snd_prod
@[simp]
theorem map_prodComm_prod :
map ((RingEquiv.prodComm : R × S ≃+* S × R) : R × S →+* S × R) (prod I J) = prod J I := by
refine Trans.trans (ideal_prod_eq _) ?_
simp [map_map]
#align ideal.map_prod_comm_prod Ideal.map_prodComm_prod
def idealProdEquiv : Ideal (R × S) ≃ Ideal R × Ideal S where
toFun I := ⟨map (RingHom.fst R S) I, map (RingHom.snd R S) I⟩
invFun I := prod I.1 I.2
left_inv I := (ideal_prod_eq I).symm
right_inv := fun ⟨I, J⟩ => by simp
#align ideal.ideal_prod_equiv Ideal.idealProdEquiv
@[simp]
theorem idealProdEquiv_symm_apply (I : Ideal R) (J : Ideal S) :
idealProdEquiv.symm ⟨I, J⟩ = prod I J :=
rfl
#align ideal.ideal_prod_equiv_symm_apply Ideal.idealProdEquiv_symm_apply
theorem prod.ext_iff {I I' : Ideal R} {J J' : Ideal S} :
prod I J = prod I' J' ↔ I = I' ∧ J = J' := by
simp only [← idealProdEquiv_symm_apply, idealProdEquiv.symm.injective.eq_iff, Prod.mk.inj_iff]
#align ideal.prod.ext_iff Ideal.prod.ext_iff
theorem isPrime_of_isPrime_prod_top {I : Ideal R} (h : (Ideal.prod I (⊤ : Ideal S)).IsPrime) :
I.IsPrime := by
constructor
· contrapose! h
rw [h, prod_top_top, isPrime_iff]
simp [isPrime_iff, h]
· intro x y hxy
have : (⟨x, 1⟩ : R × S) * ⟨y, 1⟩ ∈ prod I ⊤ := by
rw [Prod.mk_mul_mk, mul_one, mem_prod]
exact ⟨hxy, trivial⟩
simpa using h.mem_or_mem this
#align ideal.is_prime_of_is_prime_prod_top Ideal.isPrime_of_isPrime_prod_top
| Mathlib/RingTheory/Ideal/Prod.lean | 121 | 126 | theorem isPrime_of_isPrime_prod_top' {I : Ideal S} (h : (Ideal.prod (⊤ : Ideal R) I).IsPrime) :
I.IsPrime := by |
apply isPrime_of_isPrime_prod_top (S := R)
rw [← map_prodComm_prod]
-- Note: couldn't synthesize the right instances without the `R` and `S` hints
exact map_isPrime_of_equiv (RingEquiv.prodComm (R := R) (S := S))
| [
" ∀ {a b : R × S}, a ∈ {x | x.1 ∈ I ∧ x.2 ∈ J} → b ∈ {x | x.1 ∈ I ∧ x.2 ∈ J} → a + b ∈ {x | x.1 ∈ I ∧ x.2 ∈ J}",
" (a₁, a₂) + (b₁, b₂) ∈ {x | x.1 ∈ I ∧ x.2 ∈ J}",
" 0 ∈ { carrier := {x | x.1 ∈ I ∧ x.2 ∈ J}, add_mem' := ⋯ }.carrier",
" ∀ (c : R × S) {x : R × S},\n x ∈ { carrier := {x | x.1 ∈ I ∧ x.2 ∈ J}, a... | [
" ∀ {a b : R × S}, a ∈ {x | x.1 ∈ I ∧ x.2 ∈ J} → b ∈ {x | x.1 ∈ I ∧ x.2 ∈ J} → a + b ∈ {x | x.1 ∈ I ∧ x.2 ∈ J}",
" (a₁, a₂) + (b₁, b₂) ∈ {x | x.1 ∈ I ∧ x.2 ∈ J}",
" 0 ∈ { carrier := {x | x.1 ∈ I ∧ x.2 ∈ J}, add_mem' := ⋯ }.carrier",
" ∀ (c : R × S) {x : R × S},\n x ∈ { carrier := {x | x.1 ∈ I ∧ x.2 ∈ J}, a... |
import Mathlib.Analysis.SpecialFunctions.Integrals
import Mathlib.Topology.MetricSpace.Contracting
#align_import analysis.ODE.picard_lindelof from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
open Filter Function Set Metric TopologicalSpace intervalIntegral MeasureTheory
open MeasureTheory.MeasureSpace (volume)
open scoped Filter Topology NNReal ENNReal Nat Interval
noncomputable section
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
structure IsPicardLindelof {E : Type*} [NormedAddCommGroup E] (v : ℝ → E → E) (tMin t₀ tMax : ℝ)
(x₀ : E) (L : ℝ≥0) (R C : ℝ) : Prop where
ht₀ : t₀ ∈ Icc tMin tMax
hR : 0 ≤ R
lipschitz : ∀ t ∈ Icc tMin tMax, LipschitzOnWith L (v t) (closedBall x₀ R)
cont : ∀ x ∈ closedBall x₀ R, ContinuousOn (fun t : ℝ => v t x) (Icc tMin tMax)
norm_le : ∀ t ∈ Icc tMin tMax, ∀ x ∈ closedBall x₀ R, ‖v t x‖ ≤ C
C_mul_le_R : (C : ℝ) * max (tMax - t₀) (t₀ - tMin) ≤ R
#align is_picard_lindelof IsPicardLindelof
structure PicardLindelof (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] where
toFun : ℝ → E → E
(tMin tMax : ℝ)
t₀ : Icc tMin tMax
x₀ : E
(C R L : ℝ≥0)
isPicardLindelof : IsPicardLindelof toFun tMin t₀ tMax x₀ L R C
#align picard_lindelof PicardLindelof
namespace PicardLindelof
variable (v : PicardLindelof E)
instance : CoeFun (PicardLindelof E) fun _ => ℝ → E → E :=
⟨toFun⟩
instance : Inhabited (PicardLindelof E) :=
⟨⟨0, 0, 0, ⟨0, le_rfl, le_rfl⟩, 0, 0, 0, 0,
{ ht₀ := by rw [Subtype.coe_mk, Icc_self]; exact mem_singleton _
hR := le_rfl
lipschitz := fun t _ => (LipschitzWith.const 0).lipschitzOnWith _
cont := fun _ _ => by simpa only [Pi.zero_apply] using continuousOn_const
norm_le := fun t _ x _ => norm_zero.le
C_mul_le_R := (zero_mul _).le }⟩⟩
theorem tMin_le_tMax : v.tMin ≤ v.tMax :=
v.t₀.2.1.trans v.t₀.2.2
#align picard_lindelof.t_min_le_t_max PicardLindelof.tMin_le_tMax
protected theorem nonempty_Icc : (Icc v.tMin v.tMax).Nonempty :=
nonempty_Icc.2 v.tMin_le_tMax
#align picard_lindelof.nonempty_Icc PicardLindelof.nonempty_Icc
protected theorem lipschitzOnWith {t} (ht : t ∈ Icc v.tMin v.tMax) :
LipschitzOnWith v.L (v t) (closedBall v.x₀ v.R) :=
v.isPicardLindelof.lipschitz t ht
#align picard_lindelof.lipschitz_on_with PicardLindelof.lipschitzOnWith
protected theorem continuousOn :
ContinuousOn (uncurry v) (Icc v.tMin v.tMax ×ˢ closedBall v.x₀ v.R) :=
have : ContinuousOn (uncurry (flip v)) (closedBall v.x₀ v.R ×ˢ Icc v.tMin v.tMax) :=
continuousOn_prod_of_continuousOn_lipschitzOnWith _ v.L v.isPicardLindelof.cont
v.isPicardLindelof.lipschitz
this.comp continuous_swap.continuousOn (preimage_swap_prod _ _).symm.subset
#align picard_lindelof.continuous_on PicardLindelof.continuousOn
theorem norm_le {t : ℝ} (ht : t ∈ Icc v.tMin v.tMax) {x : E} (hx : x ∈ closedBall v.x₀ v.R) :
‖v t x‖ ≤ v.C :=
v.isPicardLindelof.norm_le _ ht _ hx
#align picard_lindelof.norm_le PicardLindelof.norm_le
def tDist : ℝ :=
max (v.tMax - v.t₀) (v.t₀ - v.tMin)
#align picard_lindelof.t_dist PicardLindelof.tDist
theorem tDist_nonneg : 0 ≤ v.tDist :=
le_max_iff.2 <| Or.inl <| sub_nonneg.2 v.t₀.2.2
#align picard_lindelof.t_dist_nonneg PicardLindelof.tDist_nonneg
theorem dist_t₀_le (t : Icc v.tMin v.tMax) : dist t v.t₀ ≤ v.tDist := by
rw [Subtype.dist_eq, Real.dist_eq]
rcases le_total t v.t₀ with ht | ht
· rw [abs_of_nonpos (sub_nonpos.2 <| Subtype.coe_le_coe.2 ht), neg_sub]
exact (sub_le_sub_left t.2.1 _).trans (le_max_right _ _)
· rw [abs_of_nonneg (sub_nonneg.2 <| Subtype.coe_le_coe.2 ht)]
exact (sub_le_sub_right t.2.2 _).trans (le_max_left _ _)
#align picard_lindelof.dist_t₀_le PicardLindelof.dist_t₀_le
def proj : ℝ → Icc v.tMin v.tMax :=
projIcc v.tMin v.tMax v.tMin_le_tMax
#align picard_lindelof.proj PicardLindelof.proj
theorem proj_coe (t : Icc v.tMin v.tMax) : v.proj t = t :=
projIcc_val _ _
#align picard_lindelof.proj_coe PicardLindelof.proj_coe
| Mathlib/Analysis/ODE/PicardLindelof.lean | 146 | 147 | theorem proj_of_mem {t : ℝ} (ht : t ∈ Icc v.tMin v.tMax) : ↑(v.proj t) = t := by |
simp only [proj, projIcc_of_mem v.tMin_le_tMax ht]
| [
" ↑⟨0, ⋯⟩ ∈ Icc 0 0",
" 0 ∈ {0}",
" ContinuousOn (fun t => 0 t x✝¹) (Icc 0 0)",
" dist t v.t₀ ≤ v.tDist",
" |↑t - ↑v.t₀| ≤ v.tDist",
" ↑v.t₀ - ↑t ≤ v.tDist",
" ↑t - ↑v.t₀ ≤ v.tDist",
" ↑(v.proj t) = t"
] | [
" ↑⟨0, ⋯⟩ ∈ Icc 0 0",
" 0 ∈ {0}",
" ContinuousOn (fun t => 0 t x✝¹) (Icc 0 0)",
" dist t v.t₀ ≤ v.tDist",
" |↑t - ↑v.t₀| ≤ v.tDist",
" ↑v.t₀ - ↑t ≤ v.tDist",
" ↑t - ↑v.t₀ ≤ v.tDist",
" ↑(v.proj t) = t"
] |
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
import Mathlib.Analysis.SpecialFunctions.Complex.Circle
import Mathlib.Analysis.InnerProductSpace.l2Space
import Mathlib.MeasureTheory.Function.ContinuousMapDense
import Mathlib.MeasureTheory.Function.L2Space
import Mathlib.MeasureTheory.Group.Integral
import Mathlib.MeasureTheory.Integral.Periodic
import Mathlib.Topology.ContinuousFunction.StoneWeierstrass
import Mathlib.MeasureTheory.Integral.FundThmCalculus
#align_import analysis.fourier.add_circle from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
noncomputable section
open scoped ENNReal ComplexConjugate Real
open TopologicalSpace ContinuousMap MeasureTheory MeasureTheory.Measure Algebra Submodule Set
variable {T : ℝ}
open AddCircle
section Monomials
def fourier (n : ℤ) : C(AddCircle T, ℂ) where
toFun x := toCircle (n • x :)
continuous_toFun := continuous_induced_dom.comp <| continuous_toCircle.comp <| continuous_zsmul _
#align fourier fourier
@[simp]
theorem fourier_apply {n : ℤ} {x : AddCircle T} : fourier n x = toCircle (n • x :) :=
rfl
#align fourier_apply fourier_apply
-- @[simp] -- Porting note: simp normal form is `fourier_coe_apply'`
theorem fourier_coe_apply {n : ℤ} {x : ℝ} :
fourier n (x : AddCircle T) = Complex.exp (2 * π * Complex.I * n * x / T) := by
rw [fourier_apply, ← QuotientAddGroup.mk_zsmul, toCircle, Function.Periodic.lift_coe,
expMapCircle_apply, Complex.ofReal_mul, Complex.ofReal_div, Complex.ofReal_mul, zsmul_eq_mul,
Complex.ofReal_mul, Complex.ofReal_intCast]
norm_num
congr 1; ring
#align fourier_coe_apply fourier_coe_apply
@[simp]
theorem fourier_coe_apply' {n : ℤ} {x : ℝ} :
toCircle (n • (x : AddCircle T) :) = Complex.exp (2 * π * Complex.I * n * x / T) := by
rw [← fourier_apply]; exact fourier_coe_apply
-- @[simp] -- Porting note: simp normal form is `fourier_zero'`
theorem fourier_zero {x : AddCircle T} : fourier 0 x = 1 := by
induction x using QuotientAddGroup.induction_on'
simp only [fourier_coe_apply]
norm_num
#align fourier_zero fourier_zero
@[simp]
| Mathlib/Analysis/Fourier/AddCircle.lean | 139 | 141 | theorem fourier_zero' {x : AddCircle T} : @toCircle T 0 = (1 : ℂ) := by |
have : fourier 0 x = @toCircle T 0 := by rw [fourier_apply, zero_smul]
rw [← this]; exact fourier_zero
| [
" (fourier n) ↑x = (2 * ↑π * Complex.I * ↑n * ↑x / ↑T).exp",
" (↑2 * ↑π / ↑T * (↑n * ↑x) * Complex.I).exp = (2 * ↑π * Complex.I * ↑n * ↑x / ↑T).exp",
" (2 * ↑π / ↑T * (↑n * ↑x) * Complex.I).exp = (2 * ↑π * Complex.I * ↑n * ↑x / ↑T).exp",
" 2 * ↑π / ↑T * (↑n * ↑x) * Complex.I = 2 * ↑π * Complex.I * ↑n * ↑x / ↑... | [
" (fourier n) ↑x = (2 * ↑π * Complex.I * ↑n * ↑x / ↑T).exp",
" (↑2 * ↑π / ↑T * (↑n * ↑x) * Complex.I).exp = (2 * ↑π * Complex.I * ↑n * ↑x / ↑T).exp",
" (2 * ↑π / ↑T * (↑n * ↑x) * Complex.I).exp = (2 * ↑π * Complex.I * ↑n * ↑x / ↑T).exp",
" 2 * ↑π / ↑T * (↑n * ↑x) * Complex.I = 2 * ↑π * Complex.I * ↑n * ↑x / ↑... |
import Mathlib.Analysis.Calculus.FDeriv.Basic
#align_import analysis.calculus.fderiv.comp from "leanprover-community/mathlib"@"e3fb84046afd187b710170887195d50bada934ee"
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']
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}
section Composition
variable (x)
| Mathlib/Analysis/Calculus/FDeriv/Comp.lean | 53 | 59 | theorem HasFDerivAtFilter.comp {g : F → G} {g' : F →L[𝕜] G} {L' : Filter F}
(hg : HasFDerivAtFilter g g' (f x) L') (hf : HasFDerivAtFilter f f' x L) (hL : Tendsto f L L') :
HasFDerivAtFilter (g ∘ f) (g'.comp f') x L := by |
let eq₁ := (g'.isBigO_comp _ _).trans_isLittleO hf.isLittleO
let eq₂ := (hg.isLittleO.comp_tendsto hL).trans_isBigO hf.isBigO_sub
refine .of_isLittleO <| eq₂.triangle <| eq₁.congr_left fun x' => ?_
simp
| [
" HasFDerivAtFilter (g ∘ f) (g'.comp f') x L",
" g' (f x' - f x - f' (x' - x)) = g' (f x' - f x) - (g'.comp f') (x' - x)"
] | [
" HasFDerivAtFilter (g ∘ f) (g'.comp f') x L"
] |
import Mathlib.GroupTheory.Abelianization
import Mathlib.GroupTheory.Exponent
import Mathlib.GroupTheory.Transfer
#align_import group_theory.schreier from "leanprover-community/mathlib"@"8350c34a64b9bc3fc64335df8006bffcadc7baa6"
open scoped Pointwise
namespace Subgroup
open MemRightTransversals
variable {G : Type*} [Group G] {H : Subgroup G} {R S : Set G}
theorem closure_mul_image_mul_eq_top
(hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
(closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹)) * R = ⊤ := by
let f : G → R := fun g => toFun hR g
let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
change (closure U : Set G) * R = ⊤
refine top_le_iff.mp fun g _ => ?_
refine closure_induction_right ?_ ?_ ?_ (eq_top_iff.mp hS (mem_top g))
· exact ⟨1, (closure U).one_mem, 1, hR1, one_mul 1⟩
· rintro - - s hs ⟨u, hu, r, hr, rfl⟩
rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
refine Set.mul_mem_mul ((closure U).mul_mem hu ?_) (f (r * s)).coe_prop
exact subset_closure ⟨r * s, Set.mul_mem_mul hr hs, rfl⟩
· rintro - - s hs ⟨u, hu, r, hr, rfl⟩
rw [show u * r * s⁻¹ = u * (f (r * s⁻¹) * s * r⁻¹)⁻¹ * f (r * s⁻¹) by group]
refine Set.mul_mem_mul ((closure U).mul_mem hu ((closure U).inv_mem ?_)) (f (r * s⁻¹)).2
refine subset_closure ⟨f (r * s⁻¹) * s, Set.mul_mem_mul (f (r * s⁻¹)).2 hs, ?_⟩
rw [mul_right_inj, inv_inj, ← Subtype.coe_mk r hr, ← Subtype.ext_iff, Subtype.coe_mk]
apply (mem_rightTransversals_iff_existsUnique_mul_inv_mem.mp hR (f (r * s⁻¹) * s)).unique
(mul_inv_toFun_mem hR (f (r * s⁻¹) * s))
rw [mul_assoc, ← inv_inv s, ← mul_inv_rev, inv_inv]
exact toFun_mul_inv_mem hR (r * s⁻¹)
#align subgroup.closure_mul_image_mul_eq_top Subgroup.closure_mul_image_mul_eq_top
theorem closure_mul_image_eq (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R)
(hS : closure S = ⊤) : closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹) = H := by
have hU : closure ((R * S).image fun g => g * (toFun hR g : G)⁻¹) ≤ H := by
rw [closure_le]
rintro - ⟨g, -, rfl⟩
exact mul_inv_toFun_mem hR g
refine le_antisymm hU fun h hh => ?_
obtain ⟨g, hg, r, hr, rfl⟩ :=
show h ∈ _ from eq_top_iff.mp (closure_mul_image_mul_eq_top hR hR1 hS) (mem_top h)
suffices (⟨r, hr⟩ : R) = (⟨1, hR1⟩ : R) by
simpa only [show r = 1 from Subtype.ext_iff.mp this, mul_one]
apply (mem_rightTransversals_iff_existsUnique_mul_inv_mem.mp hR r).unique
· rw [Subtype.coe_mk, mul_inv_self]
exact H.one_mem
· rw [Subtype.coe_mk, inv_one, mul_one]
exact (H.mul_mem_cancel_left (hU hg)).mp hh
#align subgroup.closure_mul_image_eq Subgroup.closure_mul_image_eq
theorem closure_mul_image_eq_top (hR : R ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R)
(hS : closure S = ⊤) : closure ((R * S).image fun g =>
⟨g * (toFun hR g : G)⁻¹, mul_inv_toFun_mem hR g⟩ : Set H) = ⊤ := by
rw [eq_top_iff, ← map_subtype_le_map_subtype, MonoidHom.map_closure, Set.image_image]
exact (map_subtype_le ⊤).trans (ge_of_eq (closure_mul_image_eq hR hR1 hS))
#align subgroup.closure_mul_image_eq_top Subgroup.closure_mul_image_eq_top
theorem closure_mul_image_eq_top' [DecidableEq G] {R S : Finset G}
(hR : (R : Set G) ∈ rightTransversals (H : Set G)) (hR1 : (1 : G) ∈ R)
(hS : closure (S : Set G) = ⊤) :
closure (((R * S).image fun g => ⟨_, mul_inv_toFun_mem hR g⟩ : Finset H) : Set H) = ⊤ := by
rw [Finset.coe_image, Finset.coe_mul]
exact closure_mul_image_eq_top hR hR1 hS
#align subgroup.closure_mul_image_eq_top' Subgroup.closure_mul_image_eq_top'
variable (H)
| Mathlib/GroupTheory/Schreier.lean | 105 | 124 | theorem exists_finset_card_le_mul [FiniteIndex H] {S : Finset G} (hS : closure (S : Set G) = ⊤) :
∃ T : Finset H, T.card ≤ H.index * S.card ∧ closure (T : Set H) = ⊤ := by |
letI := H.fintypeQuotientOfFiniteIndex
haveI : DecidableEq G := Classical.decEq G
obtain ⟨R₀, hR, hR1⟩ := H.exists_right_transversal 1
haveI : Fintype R₀ := Fintype.ofEquiv _ (toEquiv hR)
let R : Finset G := Set.toFinset R₀
replace hR : (R : Set G) ∈ rightTransversals (H : Set G) := by rwa [Set.coe_toFinset]
replace hR1 : (1 : G) ∈ R := by rwa [Set.mem_toFinset]
refine ⟨_, ?_, closure_mul_image_eq_top' hR hR1 hS⟩
calc
_ ≤ (R * S).card := Finset.card_image_le
_ ≤ (R ×ˢ S).card := Finset.card_image_le
_ = R.card * S.card := R.card_product S
_ = H.index * S.card := congr_arg (· * S.card) ?_
calc
R.card = Fintype.card R := (Fintype.card_coe R).symm
_ = _ := (Fintype.card_congr (toEquiv hR)).symm
_ = Fintype.card (G ⧸ H) := QuotientGroup.card_quotient_rightRel H
_ = H.index := H.index_eq_card.symm
| [
" ↑(closure ((fun g => g * (↑(toFun hR g))⁻¹) '' (R * S))) * R = ⊤",
" ↑(closure U) * R = ⊤",
" g ∈ ↑(closure U) * R",
" 1 ∈ ↑(closure U) * R",
" ∀ x ∈ closure S, ∀ y ∈ S, x ∈ ↑(closure U) * R → x * y ∈ ↑(closure U) * R",
" (fun x x_1 => x * x_1) u r * s ∈ ↑(closure U) * R",
" u * r * s = u * (r * s * (... | [
" ↑(closure ((fun g => g * (↑(toFun hR g))⁻¹) '' (R * S))) * R = ⊤",
" ↑(closure U) * R = ⊤",
" g ∈ ↑(closure U) * R",
" 1 ∈ ↑(closure U) * R",
" ∀ x ∈ closure S, ∀ y ∈ S, x ∈ ↑(closure U) * R → x * y ∈ ↑(closure U) * R",
" (fun x x_1 => x * x_1) u r * s ∈ ↑(closure U) * R",
" u * r * s = u * (r * s * (... |
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.BigOperators
import Mathlib.Algebra.Polynomial.Degree.Lemmas
import Mathlib.Algebra.Polynomial.Div
#align_import data.polynomial.ring_division from "leanprover-community/mathlib"@"8efcf8022aac8e01df8d302dcebdbc25d6a886c8"
noncomputable section
open Polynomial
open Finset
namespace Polynomial
universe u v w z
variable {R : Type u} {S : Type v} {T : Type w} {a b : R} {n : ℕ}
section CommRing
variable [CommRing R] {p q : R[X]}
section
variable [Semiring S]
theorem natDegree_pos_of_aeval_root [Algebra R S] {p : R[X]} (hp : p ≠ 0) {z : S}
(hz : aeval z p = 0) (inj : ∀ x : R, algebraMap R S x = 0 → x = 0) : 0 < p.natDegree :=
natDegree_pos_of_eval₂_root hp (algebraMap R S) hz inj
#align polynomial.nat_degree_pos_of_aeval_root Polynomial.natDegree_pos_of_aeval_root
theorem degree_pos_of_aeval_root [Algebra R S] {p : R[X]} (hp : p ≠ 0) {z : S} (hz : aeval z p = 0)
(inj : ∀ x : R, algebraMap R S x = 0 → x = 0) : 0 < p.degree :=
natDegree_pos_iff_degree_pos.mp (natDegree_pos_of_aeval_root hp hz inj)
#align polynomial.degree_pos_of_aeval_root Polynomial.degree_pos_of_aeval_root
theorem modByMonic_eq_of_dvd_sub (hq : q.Monic) {p₁ p₂ : R[X]} (h : q ∣ p₁ - p₂) :
p₁ %ₘ q = p₂ %ₘ q := by
nontriviality R
obtain ⟨f, sub_eq⟩ := h
refine (div_modByMonic_unique (p₂ /ₘ q + f) _ hq ⟨?_, degree_modByMonic_lt _ hq⟩).2
rw [sub_eq_iff_eq_add.mp sub_eq, mul_add, ← add_assoc, modByMonic_add_div _ hq, add_comm]
#align polynomial.mod_by_monic_eq_of_dvd_sub Polynomial.modByMonic_eq_of_dvd_sub
| Mathlib/Algebra/Polynomial/RingDivision.lean | 58 | 69 | theorem add_modByMonic (p₁ p₂ : R[X]) : (p₁ + p₂) %ₘ q = p₁ %ₘ q + p₂ %ₘ q := by |
by_cases hq : q.Monic
· cases' subsingleton_or_nontrivial R with hR hR
· simp only [eq_iff_true_of_subsingleton]
· exact
(div_modByMonic_unique (p₁ /ₘ q + p₂ /ₘ q) _ hq
⟨by
rw [mul_add, add_left_comm, add_assoc, modByMonic_add_div _ hq, ← add_assoc,
add_comm (q * _), modByMonic_add_div _ hq],
(degree_add_le _ _).trans_lt
(max_lt (degree_modByMonic_lt _ hq) (degree_modByMonic_lt _ hq))⟩).2
· simp_rw [modByMonic_eq_of_not_monic _ hq]
| [
" p₁ %ₘ q = p₂ %ₘ q",
" p₂ %ₘ q + q * (p₂ /ₘ q + f) = p₁",
" (p₁ + p₂) %ₘ q = p₁ %ₘ q + p₂ %ₘ q",
" p₁ %ₘ q + p₂ %ₘ q + q * (p₁ /ₘ q + p₂ /ₘ q) = p₁ + p₂"
] | [
" p₁ %ₘ q = p₂ %ₘ q",
" p₂ %ₘ q + q * (p₂ /ₘ q + f) = p₁",
" (p₁ + p₂) %ₘ q = p₁ %ₘ q + p₂ %ₘ q"
] |
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Analysis.SpecialFunctions.Sqrt
import Mathlib.Analysis.NormedSpace.HomeomorphBall
#align_import analysis.inner_product_space.calculus from "leanprover-community/mathlib"@"f9dd3204df14a0749cd456fac1e6849dfe7d2b88"
noncomputable section
open RCLike Real Filter
open scoped Classical Topology
section PiLike
open ContinuousLinearMap
variable {𝕜 ι H : Type*} [RCLike 𝕜] [NormedAddCommGroup H] [NormedSpace 𝕜 H] [Fintype ι]
{f : H → EuclideanSpace 𝕜 ι} {f' : H →L[𝕜] EuclideanSpace 𝕜 ι} {t : Set H} {y : H}
theorem differentiableWithinAt_euclidean :
DifferentiableWithinAt 𝕜 f t y ↔ ∀ i, DifferentiableWithinAt 𝕜 (fun x => f x i) t y := by
rw [← (EuclideanSpace.equiv ι 𝕜).comp_differentiableWithinAt_iff, differentiableWithinAt_pi]
rfl
#align differentiable_within_at_euclidean differentiableWithinAt_euclidean
theorem differentiableAt_euclidean :
DifferentiableAt 𝕜 f y ↔ ∀ i, DifferentiableAt 𝕜 (fun x => f x i) y := by
rw [← (EuclideanSpace.equiv ι 𝕜).comp_differentiableAt_iff, differentiableAt_pi]
rfl
#align differentiable_at_euclidean differentiableAt_euclidean
theorem differentiableOn_euclidean :
DifferentiableOn 𝕜 f t ↔ ∀ i, DifferentiableOn 𝕜 (fun x => f x i) t := by
rw [← (EuclideanSpace.equiv ι 𝕜).comp_differentiableOn_iff, differentiableOn_pi]
rfl
#align differentiable_on_euclidean differentiableOn_euclidean
theorem differentiable_euclidean : Differentiable 𝕜 f ↔ ∀ i, Differentiable 𝕜 fun x => f x i := by
rw [← (EuclideanSpace.equiv ι 𝕜).comp_differentiable_iff, differentiable_pi]
rfl
#align differentiable_euclidean differentiable_euclidean
theorem hasStrictFDerivAt_euclidean :
HasStrictFDerivAt f f' y ↔
∀ i, HasStrictFDerivAt (fun x => f x i) (EuclideanSpace.proj i ∘L f') y := by
rw [← (EuclideanSpace.equiv ι 𝕜).comp_hasStrictFDerivAt_iff, hasStrictFDerivAt_pi']
rfl
#align has_strict_fderiv_at_euclidean hasStrictFDerivAt_euclidean
| Mathlib/Analysis/InnerProductSpace/Calculus.lean | 340 | 344 | theorem hasFDerivWithinAt_euclidean :
HasFDerivWithinAt f f' t y ↔
∀ i, HasFDerivWithinAt (fun x => f x i) (EuclideanSpace.proj i ∘L f') t y := by |
rw [← (EuclideanSpace.equiv ι 𝕜).comp_hasFDerivWithinAt_iff, hasFDerivWithinAt_pi']
rfl
| [
" DifferentiableWithinAt 𝕜 f t y ↔ ∀ (i : ι), DifferentiableWithinAt 𝕜 (fun x => f x i) t y",
" (∀ (i : ι), DifferentiableWithinAt 𝕜 (fun x => (⇑(EuclideanSpace.equiv ι 𝕜) ∘ f) x i) t y) ↔\n ∀ (i : ι), DifferentiableWithinAt 𝕜 (fun x => f x i) t y",
" DifferentiableAt 𝕜 f y ↔ ∀ (i : ι), DifferentiableA... | [
" DifferentiableWithinAt 𝕜 f t y ↔ ∀ (i : ι), DifferentiableWithinAt 𝕜 (fun x => f x i) t y",
" (∀ (i : ι), DifferentiableWithinAt 𝕜 (fun x => (⇑(EuclideanSpace.equiv ι 𝕜) ∘ f) x i) t y) ↔\n ∀ (i : ι), DifferentiableWithinAt 𝕜 (fun x => f x i) t y",
" DifferentiableAt 𝕜 f y ↔ ∀ (i : ι), DifferentiableA... |
import Mathlib.Geometry.Manifold.MFDeriv.Atlas
noncomputable section
open scoped Manifold
open Set
section UniqueMDiff
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {H : Type*} [TopologicalSpace H] {I : ModelWithCorners 𝕜 E H} {M : Type*}
[TopologicalSpace M] [ChartedSpace H M] [SmoothManifoldWithCorners I M] {E' : Type*}
[NormedAddCommGroup E'] [NormedSpace 𝕜 E'] {H' : Type*} [TopologicalSpace H']
{I' : ModelWithCorners 𝕜 E' H'} {M' : Type*} [TopologicalSpace M'] [ChartedSpace H' M']
[SmoothManifoldWithCorners I' M'] {s : Set M} {x : M}
theorem UniqueMDiffWithinAt.image_denseRange (hs : UniqueMDiffWithinAt I s x)
{f : M → M'} {f' : E →L[𝕜] E'} (hf : HasMFDerivWithinAt I I' f s x f')
(hd : DenseRange f') : UniqueMDiffWithinAt I' (f '' s) (f x) := by
have := hs.inter' <| hf.1 (extChartAt_source_mem_nhds I' (f x))
refine (((hf.2.mono ?sub1).uniqueDiffWithinAt this hd).mono ?sub2).congr_pt ?pt
case pt => simp only [mfld_simps]
case sub1 => mfld_set_tac
case sub2 =>
rintro _ ⟨y, ⟨⟨hys, hfy⟩, -⟩, rfl⟩
exact ⟨⟨_, hys, ((extChartAt I' (f x)).left_inv hfy).symm⟩, mem_range_self _⟩
theorem UniqueMDiffOn.image_denseRange' (hs : UniqueMDiffOn I s) {f : M → M'}
{f' : M → E →L[𝕜] E'} (hf : ∀ x ∈ s, HasMFDerivWithinAt I I' f s x (f' x))
(hd : ∀ x ∈ s, DenseRange (f' x)) :
UniqueMDiffOn I' (f '' s) :=
forall_mem_image.2 fun x hx ↦ (hs x hx).image_denseRange (hf x hx) (hd x hx)
theorem UniqueMDiffOn.image_denseRange (hs : UniqueMDiffOn I s) {f : M → M'}
(hf : MDifferentiableOn I I' f s) (hd : ∀ x ∈ s, DenseRange (mfderivWithin I I' f s x)) :
UniqueMDiffOn I' (f '' s) :=
hs.image_denseRange' (fun x hx ↦ (hf x hx).hasMFDerivWithinAt) hd
protected theorem UniqueMDiffWithinAt.preimage_partialHomeomorph (hs : UniqueMDiffWithinAt I s x)
{e : PartialHomeomorph M M'} (he : e.MDifferentiable I I') (hx : x ∈ e.source) :
UniqueMDiffWithinAt I' (e.target ∩ e.symm ⁻¹' s) (e x) := by
rw [← e.image_source_inter_eq', inter_comm]
exact (hs.inter (e.open_source.mem_nhds hx)).image_denseRange
(he.mdifferentiableAt hx).hasMFDerivAt.hasMFDerivWithinAt
(he.mfderiv_surjective hx).denseRange
theorem UniqueMDiffOn.uniqueMDiffOn_preimage (hs : UniqueMDiffOn I s) {e : PartialHomeomorph M M'}
(he : e.MDifferentiable I I') : UniqueMDiffOn I' (e.target ∩ e.symm ⁻¹' s) := fun _x hx ↦
e.right_inv hx.1 ▸ (hs _ hx.2).preimage_partialHomeomorph he (e.map_target hx.1)
#align unique_mdiff_on.unique_mdiff_on_preimage UniqueMDiffOn.uniqueMDiffOn_preimage
theorem UniqueMDiffOn.uniqueDiffOn_target_inter (hs : UniqueMDiffOn I s) (x : M) :
UniqueDiffOn 𝕜 ((extChartAt I x).target ∩ (extChartAt I x).symm ⁻¹' s) := by
-- this is just a reformulation of `UniqueMDiffOn.uniqueMDiffOn_preimage`, using as `e`
-- the local chart at `x`.
apply UniqueMDiffOn.uniqueDiffOn
rw [← PartialEquiv.image_source_inter_eq', inter_comm, extChartAt_source]
exact (hs.inter (chartAt H x).open_source).image_denseRange'
(fun y hy ↦ hasMFDerivWithinAt_extChartAt I hy.2)
fun y hy ↦ ((mdifferentiable_chart _ _).mfderiv_surjective hy.2).denseRange
#align unique_mdiff_on.unique_diff_on_target_inter UniqueMDiffOn.uniqueDiffOn_target_inter
| Mathlib/Geometry/Manifold/MFDeriv/UniqueDifferential.lean | 98 | 107 | theorem UniqueMDiffOn.uniqueDiffOn_inter_preimage (hs : UniqueMDiffOn I s) (x : M) (y : M')
{f : M → M'} (hf : ContinuousOn f s) :
UniqueDiffOn 𝕜
((extChartAt I x).target ∩ (extChartAt I x).symm ⁻¹' (s ∩ f ⁻¹' (extChartAt I' y).source)) :=
haveI : UniqueMDiffOn I (s ∩ f ⁻¹' (extChartAt I' y).source) := by |
intro z hz
apply (hs z hz.1).inter'
apply (hf z hz.1).preimage_mem_nhdsWithin
exact (isOpen_extChartAt_source I' y).mem_nhds hz.2
this.uniqueDiffOn_target_inter _
| [
" UniqueMDiffWithinAt I' (f '' s) (f x)",
" writtenInExtChartAt I I' x f (↑(extChartAt I x) x) = ↑(extChartAt I' (f x)) (f x)",
" writtenInExtChartAt I I' x f '' (↑(extChartAt I x).symm ⁻¹' (s ∩ f ⁻¹' (extChartAt I' (f x)).source) ∩ range ↑I) ⊆\n ↑(extChartAt I' (f x)).symm ⁻¹' (f '' s) ∩ range ↑I'",
" ↑(e... | [
" UniqueMDiffWithinAt I' (f '' s) (f x)",
" writtenInExtChartAt I I' x f (↑(extChartAt I x) x) = ↑(extChartAt I' (f x)) (f x)",
" writtenInExtChartAt I I' x f '' (↑(extChartAt I x).symm ⁻¹' (s ∩ f ⁻¹' (extChartAt I' (f x)).source) ∩ range ↑I) ⊆\n ↑(extChartAt I' (f x)).symm ⁻¹' (f '' s) ∩ range ↑I'",
" ↑(e... |
import Mathlib.CategoryTheory.Sites.Sieves
#align_import category_theory.sites.sheaf_of_types from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
universe w v₁ v₂ u₁ u₂
namespace CategoryTheory
open Opposite CategoryTheory Category Limits Sieve
namespace Presieve
variable {C : Type u₁} [Category.{v₁} C]
variable {P Q U : Cᵒᵖ ⥤ Type w}
variable {X Y : C} {S : Sieve X} {R : Presieve X}
def FamilyOfElements (P : Cᵒᵖ ⥤ Type w) (R : Presieve X) :=
∀ ⦃Y : C⦄ (f : Y ⟶ X), R f → P.obj (op Y)
#align category_theory.presieve.family_of_elements CategoryTheory.Presieve.FamilyOfElements
instance : Inhabited (FamilyOfElements P (⊥ : Presieve X)) :=
⟨fun _ _ => False.elim⟩
def FamilyOfElements.restrict {R₁ R₂ : Presieve X} (h : R₁ ≤ R₂) :
FamilyOfElements P R₂ → FamilyOfElements P R₁ := fun x _ f hf => x f (h _ hf)
#align category_theory.presieve.family_of_elements.restrict CategoryTheory.Presieve.FamilyOfElements.restrict
def FamilyOfElements.map (p : FamilyOfElements P R) (φ : P ⟶ Q) :
FamilyOfElements Q R :=
fun _ f hf => φ.app _ (p f hf)
@[simp]
lemma FamilyOfElements.map_apply
(p : FamilyOfElements P R) (φ : P ⟶ Q) {Y : C} (f : Y ⟶ X) (hf : R f) :
p.map φ f hf = φ.app _ (p f hf) := rfl
lemma FamilyOfElements.restrict_map
(p : FamilyOfElements P R) (φ : P ⟶ Q) {R' : Presieve X} (h : R' ≤ R) :
(p.restrict h).map φ = (p.map φ).restrict h := rfl
def FamilyOfElements.Compatible (x : FamilyOfElements P R) : Prop :=
∀ ⦃Y₁ Y₂ Z⦄ (g₁ : Z ⟶ Y₁) (g₂ : Z ⟶ Y₂) ⦃f₁ : Y₁ ⟶ X⦄ ⦃f₂ : Y₂ ⟶ X⦄ (h₁ : R f₁) (h₂ : R f₂),
g₁ ≫ f₁ = g₂ ≫ f₂ → P.map g₁.op (x f₁ h₁) = P.map g₂.op (x f₂ h₂)
#align category_theory.presieve.family_of_elements.compatible CategoryTheory.Presieve.FamilyOfElements.Compatible
def FamilyOfElements.PullbackCompatible (x : FamilyOfElements P R) [R.hasPullbacks] : Prop :=
∀ ⦃Y₁ Y₂⦄ ⦃f₁ : Y₁ ⟶ X⦄ ⦃f₂ : Y₂ ⟶ X⦄ (h₁ : R f₁) (h₂ : R f₂),
haveI := hasPullbacks.has_pullbacks h₁ h₂
P.map (pullback.fst : Limits.pullback f₁ f₂ ⟶ _).op (x f₁ h₁) = P.map pullback.snd.op (x f₂ h₂)
#align category_theory.presieve.family_of_elements.pullback_compatible CategoryTheory.Presieve.FamilyOfElements.PullbackCompatible
| Mathlib/CategoryTheory/Sites/IsSheafFor.lean | 158 | 168 | theorem pullbackCompatible_iff (x : FamilyOfElements P R) [R.hasPullbacks] :
x.Compatible ↔ x.PullbackCompatible := by |
constructor
· intro t Y₁ Y₂ f₁ f₂ hf₁ hf₂
apply t
haveI := hasPullbacks.has_pullbacks hf₁ hf₂
apply pullback.condition
· intro t Y₁ Y₂ Z g₁ g₂ f₁ f₂ hf₁ hf₂ comm
haveI := hasPullbacks.has_pullbacks hf₁ hf₂
rw [← pullback.lift_fst _ _ comm, op_comp, FunctorToTypes.map_comp_apply, t hf₁ hf₂,
← FunctorToTypes.map_comp_apply, ← op_comp, pullback.lift_snd]
| [
" x.Compatible ↔ x.PullbackCompatible",
" x.Compatible → x.PullbackCompatible",
" P.map pullback.fst.op (x f₁ hf₁) = P.map pullback.snd.op (x f₂ hf₂)",
" pullback.fst ≫ f₁ = pullback.snd ≫ f₂",
" x.PullbackCompatible → x.Compatible",
" P.map g₁.op (x f₁ hf₁) = P.map g₂.op (x f₂ hf₂)"
] | [
" x.Compatible ↔ x.PullbackCompatible"
] |
import Mathlib.ModelTheory.Quotients
import Mathlib.Order.Filter.Germ
import Mathlib.Order.Filter.Ultrafilter
#align_import model_theory.ultraproducts from "leanprover-community/mathlib"@"f1ae620609496a37534c2ab3640b641d5be8b6f0"
universe u v
variable {α : Type*} (M : α → Type*) (u : Ultrafilter α)
open FirstOrder Filter
open Filter
namespace FirstOrder
namespace Language
open Structure
variable {L : Language.{u, v}} [∀ a, L.Structure (M a)]
namespace Ultraproduct
instance setoidPrestructure : L.Prestructure ((u : Filter α).productSetoid M) :=
{ (u : Filter α).productSetoid M with
toStructure :=
{ funMap := fun {n} f x a => funMap f fun i => x i a
RelMap := fun {n} r x => ∀ᶠ a : α in u, RelMap r fun i => x i a }
fun_equiv := fun {n} f x y xy => by
refine mem_of_superset (iInter_mem.2 xy) fun a ha => ?_
simp only [Set.mem_iInter, Set.mem_setOf_eq] at ha
simp only [Set.mem_setOf_eq, ha]
rel_equiv := fun {n} r x y xy => by
rw [← iff_eq_eq]
refine ⟨fun hx => ?_, fun hy => ?_⟩
· refine mem_of_superset (inter_mem hx (iInter_mem.2 xy)) ?_
rintro a ⟨ha1, ha2⟩
simp only [Set.mem_iInter, Set.mem_setOf_eq] at *
rw [← funext ha2]
exact ha1
· refine mem_of_superset (inter_mem hy (iInter_mem.2 xy)) ?_
rintro a ⟨ha1, ha2⟩
simp only [Set.mem_iInter, Set.mem_setOf_eq] at *
rw [funext ha2]
exact ha1 }
#align first_order.language.ultraproduct.setoid_prestructure FirstOrder.Language.Ultraproduct.setoidPrestructure
variable {M} {u}
instance «structure» : L.Structure ((u : Filter α).Product M) :=
Language.quotientStructure
set_option linter.uppercaseLean3 false in
#align first_order.language.ultraproduct.Structure FirstOrder.Language.Ultraproduct.structure
| Mathlib/ModelTheory/Ultraproducts.lean | 77 | 80 | theorem funMap_cast {n : ℕ} (f : L.Functions n) (x : Fin n → ∀ a, M a) :
(funMap f fun i => (x i : (u : Filter α).Product M)) =
(fun a => funMap f fun i => x i a : (u : Filter α).Product M) := by |
apply funMap_quotient_mk'
| [
" funMap f x ≈ funMap f y",
" a ∈ {x_1 | (fun a => funMap f x a = funMap f y a) x_1}",
" RelMap r x = RelMap r y",
" RelMap r x ↔ RelMap r y",
" RelMap r y",
" {x_1 | (fun a => RelMap r fun i => x i a) x_1} ∩ ⋂ i, {x_1 | (fun a => x i a = y i a) x_1} ⊆\n {x | (fun a => RelMap r fun i => y i a) x}",
"... | [
" funMap f x ≈ funMap f y",
" a ∈ {x_1 | (fun a => funMap f x a = funMap f y a) x_1}",
" RelMap r x = RelMap r y",
" RelMap r x ↔ RelMap r y",
" RelMap r y",
" {x_1 | (fun a => RelMap r fun i => x i a) x_1} ∩ ⋂ i, {x_1 | (fun a => x i a = y i a) x_1} ⊆\n {x | (fun a => RelMap r fun i => y i a) x}",
"... |
import Mathlib.Geometry.Euclidean.Sphere.Basic
#align_import geometry.euclidean.sphere.second_inter from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
noncomputable section
open RealInnerProductSpace
namespace EuclideanGeometry
variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
[NormedAddTorsor V P]
def Sphere.secondInter (s : Sphere P) (p : P) (v : V) : P :=
(-2 * ⟪v, p -ᵥ s.center⟫ / ⟪v, v⟫) • v +ᵥ p
#align euclidean_geometry.sphere.second_inter EuclideanGeometry.Sphere.secondInter
@[simp]
theorem Sphere.secondInter_dist (s : Sphere P) (p : P) (v : V) :
dist (s.secondInter p v) s.center = dist p s.center := by
rw [Sphere.secondInter]
by_cases hv : v = 0; · simp [hv]
rw [dist_smul_vadd_eq_dist _ _ hv]
exact Or.inr rfl
#align euclidean_geometry.sphere.second_inter_dist EuclideanGeometry.Sphere.secondInter_dist
@[simp]
theorem Sphere.secondInter_mem {s : Sphere P} {p : P} (v : V) : s.secondInter p v ∈ s ↔ p ∈ s := by
simp_rw [mem_sphere, Sphere.secondInter_dist]
#align euclidean_geometry.sphere.second_inter_mem EuclideanGeometry.Sphere.secondInter_mem
variable (V)
@[simp]
theorem Sphere.secondInter_zero (s : Sphere P) (p : P) : s.secondInter p (0 : V) = p := by
simp [Sphere.secondInter]
#align euclidean_geometry.sphere.second_inter_zero EuclideanGeometry.Sphere.secondInter_zero
variable {V}
| Mathlib/Geometry/Euclidean/Sphere/SecondInter.lean | 70 | 78 | theorem Sphere.secondInter_eq_self_iff {s : Sphere P} {p : P} {v : V} :
s.secondInter p v = p ↔ ⟪v, p -ᵥ s.center⟫ = 0 := by |
refine ⟨fun hp => ?_, fun hp => ?_⟩
· by_cases hv : v = 0
· simp [hv]
rwa [Sphere.secondInter, eq_comm, eq_vadd_iff_vsub_eq, vsub_self, eq_comm, smul_eq_zero,
or_iff_left hv, div_eq_zero_iff, inner_self_eq_zero, or_iff_left hv, mul_eq_zero,
or_iff_right (by norm_num : (-2 : ℝ) ≠ 0)] at hp
· rw [Sphere.secondInter, hp, mul_zero, zero_div, zero_smul, zero_vadd]
| [
" dist (s.secondInter p v) s.center = dist p s.center",
" dist ((-2 * ⟪v, p -ᵥ s.center⟫_ℝ / ⟪v, v⟫_ℝ) • v +ᵥ p) s.center = dist p s.center",
" -2 * ⟪v, p -ᵥ s.center⟫_ℝ / ⟪v, v⟫_ℝ = 0 ∨ -2 * ⟪v, p -ᵥ s.center⟫_ℝ / ⟪v, v⟫_ℝ = -2 * ⟪v, p -ᵥ s.center⟫_ℝ / ⟪v, v⟫_ℝ",
" s.secondInter p v ∈ s ↔ p ∈ s",
" s.secon... | [
" dist (s.secondInter p v) s.center = dist p s.center",
" dist ((-2 * ⟪v, p -ᵥ s.center⟫_ℝ / ⟪v, v⟫_ℝ) • v +ᵥ p) s.center = dist p s.center",
" -2 * ⟪v, p -ᵥ s.center⟫_ℝ / ⟪v, v⟫_ℝ = 0 ∨ -2 * ⟪v, p -ᵥ s.center⟫_ℝ / ⟪v, v⟫_ℝ = -2 * ⟪v, p -ᵥ s.center⟫_ℝ / ⟪v, v⟫_ℝ",
" s.secondInter p v ∈ s ↔ p ∈ s",
" s.secon... |
import Mathlib.Algebra.Polynomial.Expand
import Mathlib.Algebra.Polynomial.Laurent
import Mathlib.LinearAlgebra.Matrix.Charpoly.Basic
import Mathlib.LinearAlgebra.Matrix.Reindex
import Mathlib.RingTheory.Polynomial.Nilpotent
#align_import linear_algebra.matrix.charpoly.coeff from "leanprover-community/mathlib"@"9745b093210e9dac443af24da9dba0f9e2b6c912"
noncomputable section
-- porting note: whenever there was `∏ i : n, X - C (M i i)`, I replaced it with
-- `∏ i : n, (X - C (M i i))`, since otherwise Lean would parse as `(∏ i : n, X) - C (M i i)`
universe u v w z
open Finset Matrix Polynomial
variable {R : Type u} [CommRing R]
variable {n G : Type v} [DecidableEq n] [Fintype n]
variable {α β : Type v} [DecidableEq α]
variable {M : Matrix n n R}
namespace Matrix
theorem charmatrix_apply_natDegree [Nontrivial R] (i j : n) :
(charmatrix M i j).natDegree = ite (i = j) 1 0 := by
by_cases h : i = j <;> simp [h, ← degree_eq_iff_natDegree_eq_of_pos (Nat.succ_pos 0)]
#align charmatrix_apply_nat_degree Matrix.charmatrix_apply_natDegree
| Mathlib/LinearAlgebra/Matrix/Charpoly/Coeff.lean | 54 | 56 | theorem charmatrix_apply_natDegree_le (i j : n) :
(charmatrix M i j).natDegree ≤ ite (i = j) 1 0 := by |
split_ifs with h <;> simp [h, natDegree_X_le]
| [
" (M.charmatrix i j).natDegree = if i = j then 1 else 0",
" (M.charmatrix i j).natDegree ≤ if i = j then 1 else 0",
" (M.charmatrix i j).natDegree ≤ 1",
" (M.charmatrix i j).natDegree ≤ 0"
] | [
" (M.charmatrix i j).natDegree = if i = j then 1 else 0",
" (M.charmatrix i j).natDegree ≤ if i = j then 1 else 0"
] |
import Mathlib.Algebra.Polynomial.Degree.Definitions
#align_import ring_theory.polynomial.opposites from "leanprover-community/mathlib"@"63417e01fbc711beaf25fa73b6edb395c0cfddd0"
open Polynomial
open Polynomial MulOpposite
variable {R : Type*} [Semiring R]
noncomputable section
namespace Polynomial
def opRingEquiv (R : Type*) [Semiring R] : R[X]ᵐᵒᵖ ≃+* Rᵐᵒᵖ[X] :=
((toFinsuppIso R).op.trans AddMonoidAlgebra.opRingEquiv).trans (toFinsuppIso _).symm
#align polynomial.op_ring_equiv Polynomial.opRingEquiv
@[simp]
theorem opRingEquiv_op_monomial (n : ℕ) (r : R) :
opRingEquiv R (op (monomial n r : R[X])) = monomial n (op r) := by
simp only [opRingEquiv, RingEquiv.coe_trans, Function.comp_apply,
AddMonoidAlgebra.opRingEquiv_apply, RingEquiv.op_apply_apply, toFinsuppIso_apply, unop_op,
toFinsupp_monomial, Finsupp.mapRange_single, toFinsuppIso_symm_apply, ofFinsupp_single]
#align polynomial.op_ring_equiv_op_monomial Polynomial.opRingEquiv_op_monomial
@[simp]
theorem opRingEquiv_op_C (a : R) : opRingEquiv R (op (C a)) = C (op a) :=
opRingEquiv_op_monomial 0 a
set_option linter.uppercaseLean3 false in
#align polynomial.op_ring_equiv_op_C Polynomial.opRingEquiv_op_C
@[simp]
theorem opRingEquiv_op_X : opRingEquiv R (op (X : R[X])) = X :=
opRingEquiv_op_monomial 1 1
set_option linter.uppercaseLean3 false in
#align polynomial.op_ring_equiv_op_X Polynomial.opRingEquiv_op_X
theorem opRingEquiv_op_C_mul_X_pow (r : R) (n : ℕ) :
opRingEquiv R (op (C r * X ^ n : R[X])) = C (op r) * X ^ n := by
simp only [X_pow_mul, op_mul, op_pow, map_mul, map_pow, opRingEquiv_op_X, opRingEquiv_op_C]
set_option linter.uppercaseLean3 false in
#align polynomial.op_ring_equiv_op_C_mul_X_pow Polynomial.opRingEquiv_op_C_mul_X_pow
@[simp]
theorem opRingEquiv_symm_monomial (n : ℕ) (r : Rᵐᵒᵖ) :
(opRingEquiv R).symm (monomial n r) = op (monomial n (unop r)) :=
(opRingEquiv R).injective (by simp)
#align polynomial.op_ring_equiv_symm_monomial Polynomial.opRingEquiv_symm_monomial
@[simp]
theorem opRingEquiv_symm_C (a : Rᵐᵒᵖ) : (opRingEquiv R).symm (C a) = op (C (unop a)) :=
opRingEquiv_symm_monomial 0 a
set_option linter.uppercaseLean3 false in
#align polynomial.op_ring_equiv_symm_C Polynomial.opRingEquiv_symm_C
@[simp]
theorem opRingEquiv_symm_X : (opRingEquiv R).symm (X : Rᵐᵒᵖ[X]) = op X :=
opRingEquiv_symm_monomial 1 1
set_option linter.uppercaseLean3 false in
#align polynomial.op_ring_equiv_symm_X Polynomial.opRingEquiv_symm_X
theorem opRingEquiv_symm_C_mul_X_pow (r : Rᵐᵒᵖ) (n : ℕ) :
(opRingEquiv R).symm (C r * X ^ n : Rᵐᵒᵖ[X]) = op (C (unop r) * X ^ n) := by
rw [C_mul_X_pow_eq_monomial, opRingEquiv_symm_monomial, C_mul_X_pow_eq_monomial]
set_option linter.uppercaseLean3 false in
#align polynomial.op_ring_equiv_symm_C_mul_X_pow Polynomial.opRingEquiv_symm_C_mul_X_pow
@[simp]
theorem coeff_opRingEquiv (p : R[X]ᵐᵒᵖ) (n : ℕ) :
(opRingEquiv R p).coeff n = op ((unop p).coeff n) := by
induction' p using MulOpposite.rec' with p
cases p
rfl
#align polynomial.coeff_op_ring_equiv Polynomial.coeff_opRingEquiv
@[simp]
theorem support_opRingEquiv (p : R[X]ᵐᵒᵖ) : (opRingEquiv R p).support = (unop p).support := by
induction' p using MulOpposite.rec' with p
cases p
exact Finsupp.support_mapRange_of_injective (map_zero _) _ op_injective
#align polynomial.support_op_ring_equiv Polynomial.support_opRingEquiv
@[simp]
theorem natDegree_opRingEquiv (p : R[X]ᵐᵒᵖ) : (opRingEquiv R p).natDegree = (unop p).natDegree := by
by_cases p0 : p = 0
· simp only [p0, _root_.map_zero, natDegree_zero, unop_zero]
· simp only [p0, natDegree_eq_support_max', Ne, AddEquivClass.map_eq_zero_iff, not_false_iff,
support_opRingEquiv, unop_eq_zero_iff]
#align polynomial.nat_degree_op_ring_equiv Polynomial.natDegree_opRingEquiv
@[simp]
| Mathlib/RingTheory/Polynomial/Opposites.lean | 118 | 120 | theorem leadingCoeff_opRingEquiv (p : R[X]ᵐᵒᵖ) :
(opRingEquiv R p).leadingCoeff = op (unop p).leadingCoeff := by |
rw [leadingCoeff, coeff_opRingEquiv, natDegree_opRingEquiv, leadingCoeff]
| [
" (opRingEquiv R) (op ((monomial n) r)) = (monomial n) (op r)",
" (opRingEquiv R) (op (C r * X ^ n)) = C (op r) * X ^ n",
" (opRingEquiv R) ((opRingEquiv R).symm ((monomial n) r)) = (opRingEquiv R) (op ((monomial n) r.unop))",
" (opRingEquiv R).symm (C r * X ^ n) = op (C r.unop * X ^ n)",
" ((opRingEquiv R)... | [
" (opRingEquiv R) (op ((monomial n) r)) = (monomial n) (op r)",
" (opRingEquiv R) (op (C r * X ^ n)) = C (op r) * X ^ n",
" (opRingEquiv R) ((opRingEquiv R).symm ((monomial n) r)) = (opRingEquiv R) (op ((monomial n) r.unop))",
" (opRingEquiv R).symm (C r * X ^ n) = op (C r.unop * X ^ n)",
" ((opRingEquiv R)... |
import Mathlib.RepresentationTheory.FdRep
import Mathlib.LinearAlgebra.Trace
import Mathlib.RepresentationTheory.Invariants
#align_import representation_theory.character from "leanprover-community/mathlib"@"55b3f8206b8596db8bb1804d8a92814a0b6670c9"
noncomputable section
universe u
open CategoryTheory LinearMap CategoryTheory.MonoidalCategory Representation FiniteDimensional
variable {k : Type u} [Field k]
namespace FdRep
set_option linter.uppercaseLean3 false -- `FdRep`
section Monoid
variable {G : Type u} [Monoid G]
def character (V : FdRep k G) (g : G) :=
LinearMap.trace k V (V.ρ g)
#align fdRep.character FdRep.character
theorem char_mul_comm (V : FdRep k G) (g : G) (h : G) :
V.character (h * g) = V.character (g * h) := by simp only [trace_mul_comm, character, map_mul]
#align fdRep.char_mul_comm FdRep.char_mul_comm
@[simp]
theorem char_one (V : FdRep k G) : V.character 1 = FiniteDimensional.finrank k V := by
simp only [character, map_one, trace_one]
#align fdRep.char_one FdRep.char_one
theorem char_tensor (V W : FdRep k G) : (V ⊗ W).character = V.character * W.character := by
ext g; convert trace_tensorProduct' (V.ρ g) (W.ρ g)
#align fdRep.char_tensor FdRep.char_tensor
-- Porting note: adding variant of `char_tensor` to make the simp-set confluent
@[simp]
| Mathlib/RepresentationTheory/Character.lean | 70 | 74 | theorem char_tensor' (V W : FdRep k G) :
character (Action.FunctorCategoryEquivalence.inverse.obj
(Action.FunctorCategoryEquivalence.functor.obj V ⊗
Action.FunctorCategoryEquivalence.functor.obj W)) = V.character * W.character := by |
simp [← char_tensor]
| [
" V.character (h * g) = V.character (g * h)",
" V.character 1 = ↑(finrank k (CoeSort.coe V))",
" (V ⊗ W).character = V.character * W.character",
" (V ⊗ W).character g = (V.character * W.character) g",
" character\n (Action.FunctorCategoryEquivalence.inverse.obj\n (Action.FunctorCategoryEquivalen... | [
" V.character (h * g) = V.character (g * h)",
" V.character 1 = ↑(finrank k (CoeSort.coe V))",
" (V ⊗ W).character = V.character * W.character",
" (V ⊗ W).character g = (V.character * W.character) g",
" character\n (Action.FunctorCategoryEquivalence.inverse.obj\n (Action.FunctorCategoryEquivalen... |
import Mathlib.Data.Finsupp.Basic
import Mathlib.Data.List.AList
#align_import data.finsupp.alist from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf"
namespace AList
variable {α M : Type*} [Zero M]
open List
noncomputable def lookupFinsupp (l : AList fun _x : α => M) : α →₀ M where
support := by
haveI := Classical.decEq α; haveI := Classical.decEq M
exact (l.1.filter fun x => Sigma.snd x ≠ 0).keys.toFinset
toFun a :=
haveI := Classical.decEq α
(l.lookup a).getD 0
mem_support_toFun a := by
classical
simp_rw [@mem_toFinset _ _, List.mem_keys, List.mem_filter, ← mem_lookup_iff]
cases lookup a l <;> simp
#align alist.lookup_finsupp AList.lookupFinsupp
@[simp]
theorem lookupFinsupp_apply [DecidableEq α] (l : AList fun _x : α => M) (a : α) :
l.lookupFinsupp a = (l.lookup a).getD 0 := by
convert rfl; congr
#align alist.lookup_finsupp_apply AList.lookupFinsupp_apply
@[simp]
theorem lookupFinsupp_support [DecidableEq α] [DecidableEq M] (l : AList fun _x : α => M) :
l.lookupFinsupp.support = (l.1.filter fun x => Sigma.snd x ≠ 0).keys.toFinset := by
convert rfl; congr
· apply Subsingleton.elim
· funext; congr
#align alist.lookup_finsupp_support AList.lookupFinsupp_support
theorem lookupFinsupp_eq_iff_of_ne_zero [DecidableEq α] {l : AList fun _x : α => M} {a : α} {x : M}
(hx : x ≠ 0) : l.lookupFinsupp a = x ↔ x ∈ l.lookup a := by
rw [lookupFinsupp_apply]
cases' lookup a l with m <;> simp [hx.symm]
#align alist.lookup_finsupp_eq_iff_of_ne_zero AList.lookupFinsupp_eq_iff_of_ne_zero
theorem lookupFinsupp_eq_zero_iff [DecidableEq α] {l : AList fun _x : α => M} {a : α} :
l.lookupFinsupp a = 0 ↔ a ∉ l ∨ (0 : M) ∈ l.lookup a := by
rw [lookupFinsupp_apply, ← lookup_eq_none]
cases' lookup a l with m <;> simp
#align alist.lookup_finsupp_eq_zero_iff AList.lookupFinsupp_eq_zero_iff
@[simp]
theorem empty_lookupFinsupp : lookupFinsupp (∅ : AList fun _x : α => M) = 0 := by
classical
ext
simp
#align alist.empty_lookup_finsupp AList.empty_lookupFinsupp
@[simp]
theorem insert_lookupFinsupp [DecidableEq α] (l : AList fun _x : α => M) (a : α) (m : M) :
(l.insert a m).lookupFinsupp = l.lookupFinsupp.update a m := by
ext b
by_cases h : b = a <;> simp [h]
#align alist.insert_lookup_finsupp AList.insert_lookupFinsupp
@[simp]
| Mathlib/Data/Finsupp/AList.lean | 116 | 120 | theorem singleton_lookupFinsupp (a : α) (m : M) :
(singleton a m).lookupFinsupp = Finsupp.single a m := by |
classical
-- porting note (#10745): was `simp [← AList.insert_empty]` but timeout issues
simp only [← AList.insert_empty, insert_lookupFinsupp, empty_lookupFinsupp, Finsupp.zero_update]
| [
" Finset α",
" a ∈ (filter (fun x => decide (x.snd ≠ 0)) l.entries).keys.toFinset ↔ (fun a => (lookup a l).getD 0) a ≠ 0",
" (∃ b ∈ lookup a l, decide (b ≠ 0) = true) ↔ (lookup a l).getD 0 ≠ 0",
" (∃ b ∈ none, decide (b ≠ 0) = true) ↔ none.getD 0 ≠ 0",
" (∃ b ∈ some val✝, decide (b ≠ 0) = true) ↔ (some val✝... | [
" Finset α",
" a ∈ (filter (fun x => decide (x.snd ≠ 0)) l.entries).keys.toFinset ↔ (fun a => (lookup a l).getD 0) a ≠ 0",
" (∃ b ∈ lookup a l, decide (b ≠ 0) = true) ↔ (lookup a l).getD 0 ≠ 0",
" (∃ b ∈ none, decide (b ≠ 0) = true) ↔ none.getD 0 ≠ 0",
" (∃ b ∈ some val✝, decide (b ≠ 0) = true) ↔ (some val✝... |
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)
| [
" FrobeniusNumber (m * n - m - n) {m, n}",
" IsGreatest {k | ¬∃ m_1 n_1, m_1 • m + n_1 • n = k} (m * n - m - n)",
" m * n - m - n ∈ {k | ¬∃ m_1 n_1, m_1 • m + n_1 • n = k}",
" m * n - m - n ∈ {k | ∀ (m_1 n_1 : ℕ), m_1 • m + n_1 • n ≠ k}",
" False",
" (a + 1) * m + (b + 1) * n = m * n",
" (↑a + 1) * ↑m +... | [
" FrobeniusNumber (m * n - m - n) {m, n}"
] |
import Mathlib.Data.Vector.Basic
import Mathlib.Data.Vector.Snoc
set_option autoImplicit true
namespace Vector
section Fold
section Binary
variable (xs : Vector α n) (ys : Vector β n)
@[simp]
| Mathlib/Data/Vector/MapLemmas.lean | 60 | 68 | theorem mapAccumr₂_mapAccumr_left (f₁ : γ → β → σ₁ → σ₁ × ζ) (f₂ : α → σ₂ → σ₂ × γ) :
(mapAccumr₂ f₁ (mapAccumr f₂ xs s₂).snd ys s₁)
= let m := (mapAccumr₂ (fun x y s =>
let r₂ := f₂ x s.snd
let r₁ := f₁ r₂.snd y s.fst
((r₁.fst, r₂.fst), r₁.snd)
) xs ys (s₁, s₂))
(m.fst.fst, m.snd) := by |
induction xs, ys using Vector.revInductionOn₂ generalizing s₁ s₂ <;> simp_all
| [
" mapAccumr₂ f₁ (mapAccumr f₂ xs s₂).2 ys s₁ =\n let m :=\n mapAccumr₂\n (fun x y s =>\n let r₂ := f₂ x s.2;\n let r₁ := f₁ r₂.2 y s.1;\n ((r₁.1, r₂.1), r₁.2))\n xs ys (s₁, s₂);\n (m.1.1, m.2)",
" mapAccumr₂ f₁ (mapAccumr f₂ nil s₂).2 nil s₁ =\n let m :=\n ... | [
" mapAccumr₂ f₁ (mapAccumr f₂ xs s₂).2 ys s₁ =\n let m :=\n mapAccumr₂\n (fun x y s =>\n let r₂ := f₂ x s.2;\n let r₁ := f₁ r₂.2 y s.1;\n ((r₁.1, r₂.1), r₁.2))\n xs ys (s₁, s₂);\n (m.1.1, m.2)"
] |
import Mathlib.Data.List.Basic
#align_import data.list.join from "leanprover-community/mathlib"@"18a5306c091183ac90884daa9373fa3b178e8607"
-- Make sure we don't import algebra
assert_not_exists Monoid
variable {α β : Type*}
namespace List
attribute [simp] join
-- Porting note (#10618): simp can prove this
-- @[simp]
theorem join_singleton (l : List α) : [l].join = l := by rw [join, join, append_nil]
#align list.join_singleton List.join_singleton
@[simp]
theorem join_eq_nil : ∀ {L : List (List α)}, join L = [] ↔ ∀ l ∈ L, l = []
| [] => iff_of_true rfl (forall_mem_nil _)
| l :: L => by simp only [join, append_eq_nil, join_eq_nil, forall_mem_cons]
#align list.join_eq_nil List.join_eq_nil
@[simp]
theorem join_append (L₁ L₂ : List (List α)) : join (L₁ ++ L₂) = join L₁ ++ join L₂ := by
induction L₁
· rfl
· simp [*]
#align list.join_append List.join_append
theorem join_concat (L : List (List α)) (l : List α) : join (L.concat l) = join L ++ l := by simp
#align list.join_concat List.join_concat
@[simp]
theorem join_filter_not_isEmpty :
∀ {L : List (List α)}, join (L.filter fun l => !l.isEmpty) = L.join
| [] => rfl
| [] :: L => by
simp [join_filter_not_isEmpty (L := L), isEmpty_iff_eq_nil]
| (a :: l) :: L => by
simp [join_filter_not_isEmpty (L := L)]
#align list.join_filter_empty_eq_ff List.join_filter_not_isEmpty
@[deprecated (since := "2024-02-25")] alias join_filter_isEmpty_eq_false := join_filter_not_isEmpty
@[simp]
theorem join_filter_ne_nil [DecidablePred fun l : List α => l ≠ []] {L : List (List α)} :
join (L.filter fun l => l ≠ []) = L.join := by
simp [join_filter_not_isEmpty, ← isEmpty_iff_eq_nil]
#align list.join_filter_ne_nil List.join_filter_ne_nil
theorem join_join (l : List (List (List α))) : l.join.join = (l.map join).join := by
induction l <;> simp [*]
#align list.join_join List.join_join
lemma length_join' (L : List (List α)) : length (join L) = Nat.sum (map length L) := by
induction L <;> [rfl; simp only [*, join, map, Nat.sum_cons, length_append]]
lemma countP_join' (p : α → Bool) :
∀ L : List (List α), countP p L.join = Nat.sum (L.map (countP p))
| [] => rfl
| a :: l => by rw [join, countP_append, map_cons, Nat.sum_cons, countP_join' _ l]
lemma count_join' [BEq α] (L : List (List α)) (a : α) :
L.join.count a = Nat.sum (L.map (count a)) := countP_join' _ _
lemma length_bind' (l : List α) (f : α → List β) :
length (l.bind f) = Nat.sum (map (length ∘ f) l) := by rw [List.bind, length_join', map_map]
lemma countP_bind' (p : β → Bool) (l : List α) (f : α → List β) :
countP p (l.bind f) = Nat.sum (map (countP p ∘ f) l) := by rw [List.bind, countP_join', map_map]
lemma count_bind' [BEq β] (l : List α) (f : α → List β) (x : β) :
count x (l.bind f) = Nat.sum (map (count x ∘ f) l) := countP_bind' _ _ _
@[simp]
theorem bind_eq_nil {l : List α} {f : α → List β} : List.bind l f = [] ↔ ∀ x ∈ l, f x = [] :=
join_eq_nil.trans <| by
simp only [mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂]
#align list.bind_eq_nil List.bind_eq_nil
theorem take_sum_join' (L : List (List α)) (i : ℕ) :
L.join.take (Nat.sum ((L.map length).take i)) = (L.take i).join := by
induction L generalizing i
· simp
· cases i <;> simp [take_append, *]
theorem drop_sum_join' (L : List (List α)) (i : ℕ) :
L.join.drop (Nat.sum ((L.map length).take i)) = (L.drop i).join := by
induction L generalizing i
· simp
· cases i <;> simp [drop_append, *]
theorem drop_take_succ_eq_cons_get (L : List α) (i : Fin L.length) :
(L.take (i + 1)).drop i = [get L i] := by
induction' L with head tail ih
· exact (Nat.not_succ_le_zero i i.isLt).elim
rcases i with ⟨_ | i, hi⟩
· simp
· simpa using ih ⟨i, Nat.lt_of_succ_lt_succ hi⟩
set_option linter.deprecated false in
@[deprecated drop_take_succ_eq_cons_get (since := "2023-01-10")]
theorem drop_take_succ_eq_cons_nthLe (L : List α) {i : ℕ} (hi : i < L.length) :
(L.take (i + 1)).drop i = [nthLe L i hi] := by
induction' L with head tail generalizing i
· simp only [length] at hi
exact (Nat.not_succ_le_zero i hi).elim
cases' i with i hi
· simp
rfl
have : i < tail.length := by simpa using hi
simp [*]
rfl
#align list.drop_take_succ_eq_cons_nth_le List.drop_take_succ_eq_cons_nthLe
| Mathlib/Data/List/Join.lean | 153 | 159 | theorem drop_take_succ_join_eq_get' (L : List (List α)) (i : Fin L.length) :
(L.join.take (Nat.sum ((L.map length).take (i + 1)))).drop (Nat.sum ((L.map length).take i)) =
get L i := by |
have : (L.map length).take i = ((L.take (i + 1)).map length).take i := by
simp [map_take, take_take, Nat.min_eq_left]
simp only [this, length_map, take_sum_join', drop_sum_join', drop_take_succ_eq_cons_get,
join, append_nil]
| [
" [l].join = l",
" (l :: L).join = [] ↔ ∀ (l_1 : List α), l_1 ∈ l :: L → l_1 = []",
" (L₁ ++ L₂).join = L₁.join ++ L₂.join",
" ([] ++ L₂).join = [].join ++ L₂.join",
" (head✝ :: tail✝ ++ L₂).join = (head✝ :: tail✝).join ++ L₂.join",
" (L.concat l).join = L.join ++ l",
" (filter (fun l => !l.isEmpty) ([]... | [
" [l].join = l",
" (l :: L).join = [] ↔ ∀ (l_1 : List α), l_1 ∈ l :: L → l_1 = []",
" (L₁ ++ L₂).join = L₁.join ++ L₂.join",
" ([] ++ L₂).join = [].join ++ L₂.join",
" (head✝ :: tail✝ ++ L₂).join = (head✝ :: tail✝).join ++ L₂.join",
" (L.concat l).join = L.join ++ l",
" (filter (fun l => !l.isEmpty) ([]... |
import Mathlib.Mathport.Rename
import Mathlib.Tactic.Basic
#align_import init.control.lawful from "leanprover-community/lean"@"9af482290ef68e8aaa5ead01aa7b09b7be7019fd"
set_option autoImplicit true
universe u v
#align is_lawful_functor LawfulFunctor
#align is_lawful_functor.map_const_eq LawfulFunctor.map_const
#align is_lawful_functor.id_map LawfulFunctor.id_map
#align is_lawful_functor.comp_map LawfulFunctor.comp_map
#align is_lawful_applicative LawfulApplicative
#align is_lawful_applicative.seq_left_eq LawfulApplicative.seqLeft_eq
#align is_lawful_applicative.seq_right_eq LawfulApplicative.seqRight_eq
#align is_lawful_applicative.pure_seq_eq_map LawfulApplicative.pure_seq
#align is_lawful_applicative.map_pure LawfulApplicative.map_pure
#align is_lawful_applicative.seq_pure LawfulApplicative.seq_pure
#align is_lawful_applicative.seq_assoc LawfulApplicative.seq_assoc
#align pure_id_seq pure_id_seq
#align is_lawful_monad LawfulMonad
#align is_lawful_monad.bind_pure_comp_eq_map LawfulMonad.bind_pure_comp
#align is_lawful_monad.bind_map_eq_seq LawfulMonad.bind_map
#align is_lawful_monad.pure_bind LawfulMonad.pure_bind
#align is_lawful_monad.bind_assoc LawfulMonad.bind_assoc
#align bind_pure bind_pure
#align bind_ext_congr bind_congr
#align map_ext_congr map_congr
#align id.map_eq Id.map_eq
#align id.bind_eq Id.bind_eq
#align id.pure_eq Id.pure_eq
namespace OptionT
variable {α β : Type u} {m : Type u → Type v} (x : OptionT m α)
@[ext] theorem ext {x x' : OptionT m α} (h : x.run = x'.run) : x = x' :=
h
#align option_t.ext OptionTₓ.ext
-- Porting note: This is proven by proj reduction in Lean 3.
@[simp]
theorem run_mk (x : m (Option α)) : OptionT.run (OptionT.mk x) = x :=
rfl
variable [Monad m]
@[simp]
theorem run_pure (a) : (pure a : OptionT m α).run = pure (some a) :=
rfl
#align option_t.run_pure OptionTₓ.run_pure
@[simp]
theorem run_bind (f : α → OptionT m β) :
(x >>= f).run = x.run >>= fun
| some a => OptionT.run (f a)
| none => pure none :=
rfl
#align option_t.run_bind OptionTₓ.run_bind
@[simp]
| Mathlib/Init/Control/Lawful.lean | 213 | 219 | theorem run_map (f : α → β) [LawfulMonad m] : (f <$> x).run = Option.map f <$> x.run := by |
rw [← bind_pure_comp _ x.run]
change x.run >>= (fun
| some a => OptionT.run (pure (f a))
| none => pure none) = _
apply bind_congr
intro a; cases a <;> simp [Option.map, Option.bind]
| [
" (f <$> x).run = Option.map f <$> x.run",
" (f <$> x).run = do\n let a ← x.run\n pure (Option.map f a)",
" (do\n let x ← x.run\n match x with\n | some a => (pure (f a)).run\n | none => pure none) =\n do\n let a ← x.run\n pure (Option.map f a)",
" ∀ (a : Option α),\n ... | [
" (f <$> x).run = Option.map f <$> x.run"
] |
import Mathlib.CategoryTheory.Sites.Sieves
import Mathlib.CategoryTheory.Limits.Shapes.Pullbacks
import Mathlib.CategoryTheory.Limits.Shapes.Multiequalizer
import Mathlib.CategoryTheory.Category.Preorder
import Mathlib.Order.Copy
import Mathlib.Data.Set.Subsingleton
#align_import category_theory.sites.grothendieck from "leanprover-community/mathlib"@"14b69e9f3c16630440a2cbd46f1ddad0d561dee7"
universe v₁ u₁ v u
namespace CategoryTheory
open CategoryTheory Category
variable (C : Type u) [Category.{v} C]
structure GrothendieckTopology where
sieves : ∀ X : C, Set (Sieve X)
top_mem' : ∀ X, ⊤ ∈ sieves X
pullback_stable' : ∀ ⦃X Y : C⦄ ⦃S : Sieve X⦄ (f : Y ⟶ X), S ∈ sieves X → S.pullback f ∈ sieves Y
transitive' :
∀ ⦃X⦄ ⦃S : Sieve X⦄ (_ : S ∈ sieves X) (R : Sieve X),
(∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄, S f → R.pullback f ∈ sieves Y) → R ∈ sieves X
#align category_theory.grothendieck_topology CategoryTheory.GrothendieckTopology
namespace GrothendieckTopology
instance : CoeFun (GrothendieckTopology C) fun _ => ∀ X : C, Set (Sieve X) :=
⟨sieves⟩
variable {C}
variable {X Y : C} {S R : Sieve X}
variable (J : GrothendieckTopology C)
@[ext]
theorem ext {J₁ J₂ : GrothendieckTopology C} (h : (J₁ : ∀ X : C, Set (Sieve X)) = J₂) :
J₁ = J₂ := by
cases J₁
cases J₂
congr
#align category_theory.grothendieck_topology.ext CategoryTheory.GrothendieckTopology.ext
@[simp]
theorem top_mem (X : C) : ⊤ ∈ J X :=
J.top_mem' X
#align category_theory.grothendieck_topology.top_mem CategoryTheory.GrothendieckTopology.top_mem
@[simp]
theorem pullback_stable (f : Y ⟶ X) (hS : S ∈ J X) : S.pullback f ∈ J Y :=
J.pullback_stable' f hS
#align category_theory.grothendieck_topology.pullback_stable CategoryTheory.GrothendieckTopology.pullback_stable
theorem transitive (hS : S ∈ J X) (R : Sieve X) (h : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄, S f → R.pullback f ∈ J Y) :
R ∈ J X :=
J.transitive' hS R h
#align category_theory.grothendieck_topology.transitive CategoryTheory.GrothendieckTopology.transitive
theorem covering_of_eq_top : S = ⊤ → S ∈ J X := fun h => h.symm ▸ J.top_mem X
#align category_theory.grothendieck_topology.covering_of_eq_top CategoryTheory.GrothendieckTopology.covering_of_eq_top
theorem superset_covering (Hss : S ≤ R) (sjx : S ∈ J X) : R ∈ J X := by
apply J.transitive sjx R fun Y f hf => _
intros Y f hf
apply covering_of_eq_top
rw [← top_le_iff, ← S.pullback_eq_top_of_mem hf]
apply Sieve.pullback_monotone _ Hss
#align category_theory.grothendieck_topology.superset_covering CategoryTheory.GrothendieckTopology.superset_covering
| Mathlib/CategoryTheory/Sites/Grothendieck.lean | 158 | 162 | theorem intersection_covering (rj : R ∈ J X) (sj : S ∈ J X) : R ⊓ S ∈ J X := by |
apply J.transitive rj _ fun Y f Hf => _
intros Y f hf
rw [Sieve.pullback_inter, R.pullback_eq_top_of_mem hf]
simp [sj]
| [
" J₁ = J₂",
" { sieves := sieves✝, top_mem' := top_mem'✝, pullback_stable' := pullback_stable'✝, transitive' := transitive'✝ } = J₂",
" { sieves := sieves✝¹, top_mem' := top_mem'✝¹, pullback_stable' := pullback_stable'✝¹, transitive' := transitive'✝¹ } =\n { sieves := sieves✝, top_mem' := top_mem'✝, pullback... | [
" J₁ = J₂",
" { sieves := sieves✝, top_mem' := top_mem'✝, pullback_stable' := pullback_stable'✝, transitive' := transitive'✝ } = J₂",
" { sieves := sieves✝¹, top_mem' := top_mem'✝¹, pullback_stable' := pullback_stable'✝¹, transitive' := transitive'✝¹ } =\n { sieves := sieves✝, top_mem' := top_mem'✝, pullback... |
import Mathlib.Order.Interval.Finset.Nat
import Mathlib.Data.PNat.Defs
#align_import data.pnat.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29"
open Finset Function PNat
namespace PNat
variable (a b : ℕ+)
instance instLocallyFiniteOrder : LocallyFiniteOrder ℕ+ := Subtype.instLocallyFiniteOrder _
theorem Icc_eq_finset_subtype : Icc a b = (Icc (a : ℕ) b).subtype fun n : ℕ => 0 < n :=
rfl
#align pnat.Icc_eq_finset_subtype PNat.Icc_eq_finset_subtype
theorem Ico_eq_finset_subtype : Ico a b = (Ico (a : ℕ) b).subtype fun n : ℕ => 0 < n :=
rfl
#align pnat.Ico_eq_finset_subtype PNat.Ico_eq_finset_subtype
theorem Ioc_eq_finset_subtype : Ioc a b = (Ioc (a : ℕ) b).subtype fun n : ℕ => 0 < n :=
rfl
#align pnat.Ioc_eq_finset_subtype PNat.Ioc_eq_finset_subtype
theorem Ioo_eq_finset_subtype : Ioo a b = (Ioo (a : ℕ) b).subtype fun n : ℕ => 0 < n :=
rfl
#align pnat.Ioo_eq_finset_subtype PNat.Ioo_eq_finset_subtype
theorem uIcc_eq_finset_subtype : uIcc a b = (uIcc (a : ℕ) b).subtype fun n : ℕ => 0 < n := rfl
#align pnat.uIcc_eq_finset_subtype PNat.uIcc_eq_finset_subtype
theorem map_subtype_embedding_Icc : (Icc a b).map (Embedding.subtype _) = Icc ↑a ↑b :=
Finset.map_subtype_embedding_Icc _ _ _ fun _c _ _x hx _ hc _ => hc.trans_le hx
#align pnat.map_subtype_embedding_Icc PNat.map_subtype_embedding_Icc
theorem map_subtype_embedding_Ico : (Ico a b).map (Embedding.subtype _) = Ico ↑a ↑b :=
Finset.map_subtype_embedding_Ico _ _ _ fun _c _ _x hx _ hc _ => hc.trans_le hx
#align pnat.map_subtype_embedding_Ico PNat.map_subtype_embedding_Ico
theorem map_subtype_embedding_Ioc : (Ioc a b).map (Embedding.subtype _) = Ioc ↑a ↑b :=
Finset.map_subtype_embedding_Ioc _ _ _ fun _c _ _x hx _ hc _ => hc.trans_le hx
#align pnat.map_subtype_embedding_Ioc PNat.map_subtype_embedding_Ioc
theorem map_subtype_embedding_Ioo : (Ioo a b).map (Embedding.subtype _) = Ioo ↑a ↑b :=
Finset.map_subtype_embedding_Ioo _ _ _ fun _c _ _x hx _ hc _ => hc.trans_le hx
#align pnat.map_subtype_embedding_Ioo PNat.map_subtype_embedding_Ioo
theorem map_subtype_embedding_uIcc : (uIcc a b).map (Embedding.subtype _) = uIcc ↑a ↑b :=
map_subtype_embedding_Icc _ _
#align pnat.map_subtype_embedding_uIcc PNat.map_subtype_embedding_uIcc
@[simp]
theorem card_Icc : (Icc a b).card = b + 1 - a := by
rw [← Nat.card_Icc]
-- Porting note: I had to change this to `erw` *and* provide the proof, yuck.
-- https://github.com/leanprover-community/mathlib4/issues/5164
erw [← Finset.map_subtype_embedding_Icc _ a b (fun c x _ hx _ hc _ => hc.trans_le hx)]
rw [card_map]
#align pnat.card_Icc PNat.card_Icc
@[simp]
theorem card_Ico : (Ico a b).card = b - a := by
rw [← Nat.card_Ico]
-- Porting note: I had to change this to `erw` *and* provide the proof, yuck.
-- https://github.com/leanprover-community/mathlib4/issues/5164
erw [← Finset.map_subtype_embedding_Ico _ a b (fun c x _ hx _ hc _ => hc.trans_le hx)]
rw [card_map]
#align pnat.card_Ico PNat.card_Ico
@[simp]
theorem card_Ioc : (Ioc a b).card = b - a := by
rw [← Nat.card_Ioc]
-- Porting note: I had to change this to `erw` *and* provide the proof, yuck.
-- https://github.com/leanprover-community/mathlib4/issues/5164
erw [← Finset.map_subtype_embedding_Ioc _ a b (fun c x _ hx _ hc _ => hc.trans_le hx)]
rw [card_map]
#align pnat.card_Ioc PNat.card_Ioc
@[simp]
theorem card_Ioo : (Ioo a b).card = b - a - 1 := by
rw [← Nat.card_Ioo]
-- Porting note: I had to change this to `erw` *and* provide the proof, yuck.
-- https://github.com/leanprover-community/mathlib4/issues/5164
erw [← Finset.map_subtype_embedding_Ioo _ a b (fun c x _ hx _ hc _ => hc.trans_le hx)]
rw [card_map]
#align pnat.card_Ioo PNat.card_Ioo
@[simp]
theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 := by
rw [← Nat.card_uIcc, ← map_subtype_embedding_uIcc, card_map]
#align pnat.card_uIcc PNat.card_uIcc
-- Porting note: `simpNF` says `simp` can prove this
theorem card_fintype_Icc : Fintype.card (Set.Icc a b) = b + 1 - a := by
rw [← card_Icc, Fintype.card_ofFinset]
#align pnat.card_fintype_Icc PNat.card_fintype_Icc
-- Porting note: `simpNF` says `simp` can prove this
theorem card_fintype_Ico : Fintype.card (Set.Ico a b) = b - a := by
rw [← card_Ico, Fintype.card_ofFinset]
#align pnat.card_fintype_Ico PNat.card_fintype_Ico
-- Porting note: `simpNF` says `simp` can prove this
| Mathlib/Data/PNat/Interval.lean | 118 | 119 | theorem card_fintype_Ioc : Fintype.card (Set.Ioc a b) = b - a := by |
rw [← card_Ioc, Fintype.card_ofFinset]
| [
" (Icc a b).card = ↑b + 1 - ↑a",
" (Icc a b).card = (Icc ↑a ↑b).card",
" (Icc a b).card = (map (Embedding.subtype fun n => 0 < n) (Icc a b)).card",
" (Ico a b).card = ↑b - ↑a",
" (Ico a b).card = (Ico ↑a ↑b).card",
" (Ico a b).card = (map (Embedding.subtype fun n => 0 < n) (Ico a b)).card",
" (Ioc a b).... | [
" (Icc a b).card = ↑b + 1 - ↑a",
" (Icc a b).card = (Icc ↑a ↑b).card",
" (Icc a b).card = (map (Embedding.subtype fun n => 0 < n) (Icc a b)).card",
" (Ico a b).card = ↑b - ↑a",
" (Ico a b).card = (Ico ↑a ↑b).card",
" (Ico a b).card = (map (Embedding.subtype fun n => 0 < n) (Ico a b)).card",
" (Ioc a b).... |
import Mathlib.Algebra.BigOperators.WithTop
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Data.ENNReal.Basic
#align_import data.real.ennreal from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"
open Set NNReal ENNReal
namespace ENNReal
variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0}
section Mul
-- Porting note (#11215): TODO: generalize to `WithTop`
@[mono, gcongr]
theorem mul_lt_mul (ac : a < c) (bd : b < d) : a * b < c * d := by
rcases lt_iff_exists_nnreal_btwn.1 ac with ⟨a', aa', a'c⟩
lift a to ℝ≥0 using ne_top_of_lt aa'
rcases lt_iff_exists_nnreal_btwn.1 bd with ⟨b', bb', b'd⟩
lift b to ℝ≥0 using ne_top_of_lt bb'
norm_cast at *
calc
↑(a * b) < ↑(a' * b') := coe_lt_coe.2 (mul_lt_mul₀ aa' bb')
_ ≤ c * d := mul_le_mul' a'c.le b'd.le
#align ennreal.mul_lt_mul ENNReal.mul_lt_mul
-- TODO: generalize to `CovariantClass α α (· * ·) (· ≤ ·)`
theorem mul_left_mono : Monotone (a * ·) := fun _ _ => mul_le_mul' le_rfl
#align ennreal.mul_left_mono ENNReal.mul_left_mono
-- TODO: generalize to `CovariantClass α α (swap (· * ·)) (· ≤ ·)`
theorem mul_right_mono : Monotone (· * a) := fun _ _ h => mul_le_mul' h le_rfl
#align ennreal.mul_right_mono ENNReal.mul_right_mono
-- Porting note (#11215): TODO: generalize to `WithTop`
theorem pow_strictMono : ∀ {n : ℕ}, n ≠ 0 → StrictMono fun x : ℝ≥0∞ => x ^ n
| 0, h => absurd rfl h
| 1, _ => by simpa only [pow_one] using strictMono_id
| n + 2, _ => fun x y h ↦ by
simp_rw [pow_succ _ (n + 1)]; exact mul_lt_mul (pow_strictMono n.succ_ne_zero h) h
#align ennreal.pow_strict_mono ENNReal.pow_strictMono
@[gcongr] protected theorem pow_lt_pow_left (h : a < b) {n : ℕ} (hn : n ≠ 0) :
a ^ n < b ^ n :=
ENNReal.pow_strictMono hn h
theorem max_mul : max a b * c = max (a * c) (b * c) := mul_right_mono.map_max
#align ennreal.max_mul ENNReal.max_mul
theorem mul_max : a * max b c = max (a * b) (a * c) := mul_left_mono.map_max
#align ennreal.mul_max ENNReal.mul_max
-- Porting note (#11215): TODO: generalize to `WithTop`
| Mathlib/Data/ENNReal/Operations.lean | 71 | 77 | theorem mul_left_strictMono (h0 : a ≠ 0) (hinf : a ≠ ∞) : StrictMono (a * ·) := by |
lift a to ℝ≥0 using hinf
rw [coe_ne_zero] at h0
intro x y h
contrapose! h
simpa only [← mul_assoc, ← coe_mul, inv_mul_cancel h0, coe_one, one_mul]
using mul_le_mul_left' h (↑a⁻¹)
| [
" a * b < c * d",
" ↑a * b < c * d",
" ↑a * ↑b < c * d",
" ↑(a * b) < c * d",
" StrictMono fun x => x ^ 1",
" (fun x => x ^ (n + 2)) x < (fun x => x ^ (n + 2)) y",
" x ^ (n + 1) * x < y ^ (n + 1) * y",
" StrictMono fun x => a * x",
" StrictMono fun x => ↑a * x",
" (fun x => ↑a * x) x < (fun x => ↑... | [
" a * b < c * d",
" ↑a * b < c * d",
" ↑a * ↑b < c * d",
" ↑(a * b) < c * d",
" StrictMono fun x => x ^ 1",
" (fun x => x ^ (n + 2)) x < (fun x => x ^ (n + 2)) y",
" x ^ (n + 1) * x < y ^ (n + 1) * y",
" StrictMono fun x => a * x"
] |
import Mathlib.Topology.Bases
import Mathlib.Topology.DenseEmbedding
#align_import topology.stone_cech from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977"
noncomputable section
open Filter Set
open Topology
universe u v
section Ultrafilter
def ultrafilterBasis (α : Type u) : Set (Set (Ultrafilter α)) :=
range fun s : Set α => { u | s ∈ u }
#align ultrafilter_basis ultrafilterBasis
variable {α : Type u}
instance Ultrafilter.topologicalSpace : TopologicalSpace (Ultrafilter α) :=
TopologicalSpace.generateFrom (ultrafilterBasis α)
#align ultrafilter.topological_space Ultrafilter.topologicalSpace
theorem ultrafilterBasis_is_basis : TopologicalSpace.IsTopologicalBasis (ultrafilterBasis α) :=
⟨by
rintro _ ⟨a, rfl⟩ _ ⟨b, rfl⟩ u ⟨ua, ub⟩
refine ⟨_, ⟨a ∩ b, rfl⟩, inter_mem ua ub, fun v hv => ⟨?_, ?_⟩⟩ <;> apply mem_of_superset hv <;>
simp [inter_subset_right],
eq_univ_of_univ_subset <| subset_sUnion_of_mem <| ⟨univ, eq_univ_of_forall fun u => univ_mem⟩,
rfl⟩
#align ultrafilter_basis_is_basis ultrafilterBasis_is_basis
theorem ultrafilter_isOpen_basic (s : Set α) : IsOpen { u : Ultrafilter α | s ∈ u } :=
ultrafilterBasis_is_basis.isOpen ⟨s, rfl⟩
#align ultrafilter_is_open_basic ultrafilter_isOpen_basic
theorem ultrafilter_isClosed_basic (s : Set α) : IsClosed { u : Ultrafilter α | s ∈ u } := by
rw [← isOpen_compl_iff]
convert ultrafilter_isOpen_basic sᶜ using 1
ext u
exact Ultrafilter.compl_mem_iff_not_mem.symm
#align ultrafilter_is_closed_basic ultrafilter_isClosed_basic
theorem ultrafilter_converges_iff {u : Ultrafilter (Ultrafilter α)} {x : Ultrafilter α} :
↑u ≤ 𝓝 x ↔ x = joinM u := by
rw [eq_comm, ← Ultrafilter.coe_le_coe]
change ↑u ≤ 𝓝 x ↔ ∀ s ∈ x, { v : Ultrafilter α | s ∈ v } ∈ u
simp only [TopologicalSpace.nhds_generateFrom, le_iInf_iff, ultrafilterBasis, le_principal_iff,
mem_setOf_eq]
constructor
· intro h a ha
exact h _ ⟨ha, a, rfl⟩
· rintro h a ⟨xi, a, rfl⟩
exact h _ xi
#align ultrafilter_converges_iff ultrafilter_converges_iff
instance ultrafilter_compact : CompactSpace (Ultrafilter α) :=
⟨isCompact_iff_ultrafilter_le_nhds.mpr fun f _ =>
⟨joinM f, trivial, ultrafilter_converges_iff.mpr rfl⟩⟩
#align ultrafilter_compact ultrafilter_compact
instance Ultrafilter.t2Space : T2Space (Ultrafilter α) :=
t2_iff_ultrafilter.mpr @fun x y f fx fy =>
have hx : x = joinM f := ultrafilter_converges_iff.mp fx
have hy : y = joinM f := ultrafilter_converges_iff.mp fy
hx.trans hy.symm
#align ultrafilter.t2_space Ultrafilter.t2Space
instance : TotallyDisconnectedSpace (Ultrafilter α) := by
rw [totallyDisconnectedSpace_iff_connectedComponent_singleton]
intro A
simp only [Set.eq_singleton_iff_unique_mem, mem_connectedComponent, true_and_iff]
intro B hB
rw [← Ultrafilter.coe_le_coe]
intro s hs
rw [connectedComponent_eq_iInter_isClopen, Set.mem_iInter] at hB
let Z := { F : Ultrafilter α | s ∈ F }
have hZ : IsClopen Z := ⟨ultrafilter_isClosed_basic s, ultrafilter_isOpen_basic s⟩
exact hB ⟨Z, hZ, hs⟩
@[simp] theorem Ultrafilter.tendsto_pure_self (b : Ultrafilter α) : Tendsto pure b (𝓝 b) := by
rw [Tendsto, ← coe_map, ultrafilter_converges_iff]
ext s
change s ∈ b ↔ {t | s ∈ t} ∈ map pure b
simp_rw [mem_map, preimage_setOf_eq, mem_pure, setOf_mem_eq]
| Mathlib/Topology/StoneCech.lean | 110 | 117 | theorem ultrafilter_comap_pure_nhds (b : Ultrafilter α) : comap pure (𝓝 b) ≤ b := by |
rw [TopologicalSpace.nhds_generateFrom]
simp only [comap_iInf, comap_principal]
intro s hs
rw [← le_principal_iff]
refine iInf_le_of_le { u | s ∈ u } ?_
refine iInf_le_of_le ⟨hs, ⟨s, rfl⟩⟩ ?_
exact principal_mono.2 fun a => id
| [
" ∀ t₁ ∈ ultrafilterBasis α, ∀ t₂ ∈ ultrafilterBasis α, ∀ x ∈ t₁ ∩ t₂, ∃ t₃ ∈ ultrafilterBasis α, x ∈ t₃ ∧ t₃ ⊆ t₁ ∩ t₂",
" ∃ t₃ ∈ ultrafilterBasis α, u ∈ t₃ ∧ t₃ ⊆ (fun s => {u | s ∈ u}) a ∩ (fun s => {u | s ∈ u}) b",
" v ∈ (fun s => {u | s ∈ u}) a",
" v ∈ (fun s => {u | s ∈ u}) b",
" a ∩ b ⊆ a",
" a ∩ b... | [
" ∀ t₁ ∈ ultrafilterBasis α, ∀ t₂ ∈ ultrafilterBasis α, ∀ x ∈ t₁ ∩ t₂, ∃ t₃ ∈ ultrafilterBasis α, x ∈ t₃ ∧ t₃ ⊆ t₁ ∩ t₂",
" ∃ t₃ ∈ ultrafilterBasis α, u ∈ t₃ ∧ t₃ ⊆ (fun s => {u | s ∈ u}) a ∩ (fun s => {u | s ∈ u}) b",
" v ∈ (fun s => {u | s ∈ u}) a",
" v ∈ (fun s => {u | s ∈ u}) b",
" a ∩ b ⊆ a",
" a ∩ b... |
import Mathlib.LinearAlgebra.Basis
import Mathlib.LinearAlgebra.Dual
import Mathlib.Data.Fin.FlagRange
open Set Submodule
namespace Basis
section Semiring
variable {R M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] {n : ℕ}
def flag (b : Basis (Fin n) R M) (k : Fin (n + 1)) : Submodule R M :=
.span R <| b '' {i | i.castSucc < k}
@[simp]
theorem flag_zero (b : Basis (Fin n) R M) : b.flag 0 = ⊥ := by simp [flag]
@[simp]
| Mathlib/LinearAlgebra/Basis/Flag.lean | 35 | 36 | theorem flag_last (b : Basis (Fin n) R M) : b.flag (.last n) = ⊤ := by |
simp [flag, Fin.castSucc_lt_last]
| [
" b.flag 0 = ⊥",
" b.flag (Fin.last n) = ⊤"
] | [
" b.flag 0 = ⊥",
" b.flag (Fin.last n) = ⊤"
] |
import Mathlib.Data.List.Chain
#align_import data.list.destutter from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213"
variable {α : Type*} (l : List α) (R : α → α → Prop) [DecidableRel R] {a b : α}
namespace List
@[simp]
theorem destutter'_nil : destutter' R a [] = [a] :=
rfl
#align list.destutter'_nil List.destutter'_nil
theorem destutter'_cons :
(b :: l).destutter' R a = if R a b then a :: destutter' R b l else destutter' R a l :=
rfl
#align list.destutter'_cons List.destutter'_cons
variable {R}
@[simp]
| Mathlib/Data/List/Destutter.lean | 48 | 49 | theorem destutter'_cons_pos (h : R b a) : (a :: l).destutter' R b = b :: l.destutter' R a := by |
rw [destutter', if_pos h]
| [
" destutter' R b (a :: l) = b :: destutter' R a l"
] | [
" destutter' R b (a :: l) = b :: destutter' R a l"
] |
import Mathlib.LinearAlgebra.Finsupp
import Mathlib.RingTheory.Ideal.Over
import Mathlib.RingTheory.Ideal.Prod
import Mathlib.RingTheory.Ideal.MinimalPrime
import Mathlib.RingTheory.Localization.Away.Basic
import Mathlib.RingTheory.Nilpotent.Lemmas
import Mathlib.Topology.Sets.Closeds
import Mathlib.Topology.Sober
#align_import algebraic_geometry.prime_spectrum.basic from "leanprover-community/mathlib"@"a7c017d750512a352b623b1824d75da5998457d0"
noncomputable section
open scoped Classical
universe u v
variable (R : Type u) (S : Type v)
@[ext]
structure PrimeSpectrum [CommSemiring R] where
asIdeal : Ideal R
IsPrime : asIdeal.IsPrime
#align prime_spectrum PrimeSpectrum
attribute [instance] PrimeSpectrum.IsPrime
namespace PrimeSpectrum
section CommSemiRing
variable [CommSemiring R] [CommSemiring S]
variable {R S}
instance [Nontrivial R] : Nonempty <| PrimeSpectrum R :=
let ⟨I, hI⟩ := Ideal.exists_maximal R
⟨⟨I, hI.isPrime⟩⟩
instance [Subsingleton R] : IsEmpty (PrimeSpectrum R) :=
⟨fun x ↦ x.IsPrime.ne_top <| SetLike.ext' <| Subsingleton.eq_univ_of_nonempty x.asIdeal.nonempty⟩
#noalign prime_spectrum.punit
variable (R S)
@[simp]
def primeSpectrumProdOfSum : Sum (PrimeSpectrum R) (PrimeSpectrum S) → PrimeSpectrum (R × S)
| Sum.inl ⟨I, _⟩ => ⟨Ideal.prod I ⊤, Ideal.isPrime_ideal_prod_top⟩
| Sum.inr ⟨J, _⟩ => ⟨Ideal.prod ⊤ J, Ideal.isPrime_ideal_prod_top'⟩
#align prime_spectrum.prime_spectrum_prod_of_sum PrimeSpectrum.primeSpectrumProdOfSum
noncomputable def primeSpectrumProd :
PrimeSpectrum (R × S) ≃ Sum (PrimeSpectrum R) (PrimeSpectrum S) :=
Equiv.symm <|
Equiv.ofBijective (primeSpectrumProdOfSum R S) (by
constructor
· rintro (⟨I, hI⟩ | ⟨J, hJ⟩) (⟨I', hI'⟩ | ⟨J', hJ'⟩) h <;>
simp only [mk.injEq, Ideal.prod.ext_iff, primeSpectrumProdOfSum] at h
· simp only [h]
· exact False.elim (hI.ne_top h.left)
· exact False.elim (hJ.ne_top h.right)
· simp only [h]
· rintro ⟨I, hI⟩
rcases (Ideal.ideal_prod_prime I).mp hI with (⟨p, ⟨hp, rfl⟩⟩ | ⟨p, ⟨hp, rfl⟩⟩)
· exact ⟨Sum.inl ⟨p, hp⟩, rfl⟩
· exact ⟨Sum.inr ⟨p, hp⟩, rfl⟩)
#align prime_spectrum.prime_spectrum_prod PrimeSpectrum.primeSpectrumProd
variable {R S}
@[simp]
theorem primeSpectrumProd_symm_inl_asIdeal (x : PrimeSpectrum R) :
((primeSpectrumProd R S).symm <| Sum.inl x).asIdeal = Ideal.prod x.asIdeal ⊤ := by
cases x
rfl
#align prime_spectrum.prime_spectrum_prod_symm_inl_as_ideal PrimeSpectrum.primeSpectrumProd_symm_inl_asIdeal
@[simp]
theorem primeSpectrumProd_symm_inr_asIdeal (x : PrimeSpectrum S) :
((primeSpectrumProd R S).symm <| Sum.inr x).asIdeal = Ideal.prod ⊤ x.asIdeal := by
cases x
rfl
#align prime_spectrum.prime_spectrum_prod_symm_inr_as_ideal PrimeSpectrum.primeSpectrumProd_symm_inr_asIdeal
def zeroLocus (s : Set R) : Set (PrimeSpectrum R) :=
{ x | s ⊆ x.asIdeal }
#align prime_spectrum.zero_locus PrimeSpectrum.zeroLocus
@[simp]
theorem mem_zeroLocus (x : PrimeSpectrum R) (s : Set R) : x ∈ zeroLocus s ↔ s ⊆ x.asIdeal :=
Iff.rfl
#align prime_spectrum.mem_zero_locus PrimeSpectrum.mem_zeroLocus
@[simp]
theorem zeroLocus_span (s : Set R) : zeroLocus (Ideal.span s : Set R) = zeroLocus s := by
ext x
exact (Submodule.gi R R).gc s x.asIdeal
#align prime_spectrum.zero_locus_span PrimeSpectrum.zeroLocus_span
def vanishingIdeal (t : Set (PrimeSpectrum R)) : Ideal R :=
⨅ (x : PrimeSpectrum R) (_ : x ∈ t), x.asIdeal
#align prime_spectrum.vanishing_ideal PrimeSpectrum.vanishingIdeal
| Mathlib/AlgebraicGeometry/PrimeSpectrum/Basic.lean | 164 | 169 | theorem coe_vanishingIdeal (t : Set (PrimeSpectrum R)) :
(vanishingIdeal t : Set R) = { f : R | ∀ x : PrimeSpectrum R, x ∈ t → f ∈ x.asIdeal } := by |
ext f
rw [vanishingIdeal, SetLike.mem_coe, Submodule.mem_iInf]
apply forall_congr'; intro x
rw [Submodule.mem_iInf]
| [
" Function.Bijective (primeSpectrumProdOfSum R S)",
" Function.Injective (primeSpectrumProdOfSum R S)",
" Sum.inl { asIdeal := I, IsPrime := hI } = Sum.inl { asIdeal := I', IsPrime := hI' }",
" Sum.inl { asIdeal := I, IsPrime := hI } = Sum.inr { asIdeal := J', IsPrime := hJ' }",
" Sum.inr { asIdeal := J, Is... | [
" Function.Bijective (primeSpectrumProdOfSum R S)",
" Function.Injective (primeSpectrumProdOfSum R S)",
" Sum.inl { asIdeal := I, IsPrime := hI } = Sum.inl { asIdeal := I', IsPrime := hI' }",
" Sum.inl { asIdeal := I, IsPrime := hI } = Sum.inr { asIdeal := J', IsPrime := hJ' }",
" Sum.inr { asIdeal := J, Is... |
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv
import Mathlib.Analysis.SpecialFunctions.Log.Basic
#align_import analysis.special_functions.arsinh from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
noncomputable section
open Function Filter Set
open scoped Topology
namespace Real
variable {x y : ℝ}
-- @[pp_nodot] is no longer needed
def arsinh (x : ℝ) :=
log (x + √(1 + x ^ 2))
#align real.arsinh Real.arsinh
theorem exp_arsinh (x : ℝ) : exp (arsinh x) = x + √(1 + x ^ 2) := by
apply exp_log
rw [← neg_lt_iff_pos_add']
apply lt_sqrt_of_sq_lt
simp
#align real.exp_arsinh Real.exp_arsinh
@[simp]
theorem arsinh_zero : arsinh 0 = 0 := by simp [arsinh]
#align real.arsinh_zero Real.arsinh_zero
@[simp]
theorem arsinh_neg (x : ℝ) : arsinh (-x) = -arsinh x := by
rw [← exp_eq_exp, exp_arsinh, exp_neg, exp_arsinh]
apply eq_inv_of_mul_eq_one_left
rw [neg_sq, neg_add_eq_sub, add_comm x, mul_comm, ← sq_sub_sq, sq_sqrt, add_sub_cancel_right]
exact add_nonneg zero_le_one (sq_nonneg _)
#align real.arsinh_neg Real.arsinh_neg
@[simp]
theorem sinh_arsinh (x : ℝ) : sinh (arsinh x) = x := by
rw [sinh_eq, ← arsinh_neg, exp_arsinh, exp_arsinh, neg_sq]; field_simp
#align real.sinh_arsinh Real.sinh_arsinh
@[simp]
theorem cosh_arsinh (x : ℝ) : cosh (arsinh x) = √(1 + x ^ 2) := by
rw [← sqrt_sq (cosh_pos _).le, cosh_sq', sinh_arsinh]
#align real.cosh_arsinh Real.cosh_arsinh
theorem sinh_surjective : Surjective sinh :=
LeftInverse.surjective sinh_arsinh
#align real.sinh_surjective Real.sinh_surjective
theorem sinh_bijective : Bijective sinh :=
⟨sinh_injective, sinh_surjective⟩
#align real.sinh_bijective Real.sinh_bijective
@[simp]
theorem arsinh_sinh (x : ℝ) : arsinh (sinh x) = x :=
rightInverse_of_injective_of_leftInverse sinh_injective sinh_arsinh x
#align real.arsinh_sinh Real.arsinh_sinh
@[simps]
def sinhEquiv : ℝ ≃ ℝ where
toFun := sinh
invFun := arsinh
left_inv := arsinh_sinh
right_inv := sinh_arsinh
#align real.sinh_equiv Real.sinhEquiv
@[simps! (config := .asFn)]
def sinhOrderIso : ℝ ≃o ℝ where
toEquiv := sinhEquiv
map_rel_iff' := @sinh_le_sinh
#align real.sinh_order_iso Real.sinhOrderIso
@[simps! (config := .asFn)]
def sinhHomeomorph : ℝ ≃ₜ ℝ :=
sinhOrderIso.toHomeomorph
#align real.sinh_homeomorph Real.sinhHomeomorph
theorem arsinh_bijective : Bijective arsinh :=
sinhEquiv.symm.bijective
#align real.arsinh_bijective Real.arsinh_bijective
theorem arsinh_injective : Injective arsinh :=
sinhEquiv.symm.injective
#align real.arsinh_injective Real.arsinh_injective
theorem arsinh_surjective : Surjective arsinh :=
sinhEquiv.symm.surjective
#align real.arsinh_surjective Real.arsinh_surjective
theorem arsinh_strictMono : StrictMono arsinh :=
sinhOrderIso.symm.strictMono
#align real.arsinh_strict_mono Real.arsinh_strictMono
@[simp]
theorem arsinh_inj : arsinh x = arsinh y ↔ x = y :=
arsinh_injective.eq_iff
#align real.arsinh_inj Real.arsinh_inj
@[simp]
theorem arsinh_le_arsinh : arsinh x ≤ arsinh y ↔ x ≤ y :=
sinhOrderIso.symm.le_iff_le
#align real.arsinh_le_arsinh Real.arsinh_le_arsinh
@[gcongr] protected alias ⟨_, GCongr.arsinh_le_arsinh⟩ := arsinh_le_arsinh
@[simp]
theorem arsinh_lt_arsinh : arsinh x < arsinh y ↔ x < y :=
sinhOrderIso.symm.lt_iff_lt
#align real.arsinh_lt_arsinh Real.arsinh_lt_arsinh
@[simp]
theorem arsinh_eq_zero_iff : arsinh x = 0 ↔ x = 0 :=
arsinh_injective.eq_iff' arsinh_zero
#align real.arsinh_eq_zero_iff Real.arsinh_eq_zero_iff
@[simp]
theorem arsinh_nonneg_iff : 0 ≤ arsinh x ↔ 0 ≤ x := by rw [← sinh_le_sinh, sinh_zero, sinh_arsinh]
#align real.arsinh_nonneg_iff Real.arsinh_nonneg_iff
@[simp]
theorem arsinh_nonpos_iff : arsinh x ≤ 0 ↔ x ≤ 0 := by rw [← sinh_le_sinh, sinh_zero, sinh_arsinh]
#align real.arsinh_nonpos_iff Real.arsinh_nonpos_iff
@[simp]
theorem arsinh_pos_iff : 0 < arsinh x ↔ 0 < x :=
lt_iff_lt_of_le_iff_le arsinh_nonpos_iff
#align real.arsinh_pos_iff Real.arsinh_pos_iff
@[simp]
theorem arsinh_neg_iff : arsinh x < 0 ↔ x < 0 :=
lt_iff_lt_of_le_iff_le arsinh_nonneg_iff
#align real.arsinh_neg_iff Real.arsinh_neg_iff
| Mathlib/Analysis/SpecialFunctions/Arsinh.lean | 181 | 184 | theorem hasStrictDerivAt_arsinh (x : ℝ) : HasStrictDerivAt arsinh (√(1 + x ^ 2))⁻¹ x := by |
convert sinhHomeomorph.toPartialHomeomorph.hasStrictDerivAt_symm (mem_univ x) (cosh_pos _).ne'
(hasStrictDerivAt_sinh _) using 2
exact (cosh_arsinh _).symm
| [
" rexp x.arsinh = x + √(1 + x ^ 2)",
" 0 < x + √(1 + x ^ 2)",
" -x < √(1 + x ^ 2)",
" (-x) ^ 2 < 1 + x ^ 2",
" arsinh 0 = 0",
" (-x).arsinh = -x.arsinh",
" -x + √(1 + (-x) ^ 2) = (x + √(1 + x ^ 2))⁻¹",
" (-x + √(1 + (-x) ^ 2)) * (x + √(1 + x ^ 2)) = 1",
" 0 ≤ 1 + x ^ 2",
" x.arsinh.sinh = x",
" ... | [
" rexp x.arsinh = x + √(1 + x ^ 2)",
" 0 < x + √(1 + x ^ 2)",
" -x < √(1 + x ^ 2)",
" (-x) ^ 2 < 1 + x ^ 2",
" arsinh 0 = 0",
" (-x).arsinh = -x.arsinh",
" -x + √(1 + (-x) ^ 2) = (x + √(1 + x ^ 2))⁻¹",
" (-x + √(1 + (-x) ^ 2)) * (x + √(1 + x ^ 2)) = 1",
" 0 ≤ 1 + x ^ 2",
" x.arsinh.sinh = x",
" ... |
import Mathlib.Data.Nat.Choose.Basic
import Mathlib.Data.Nat.GCD.Basic
import Mathlib.Tactic.Ring
import Mathlib.Tactic.Linarith
#align_import data.nat.choose.central from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977"
namespace Nat
def centralBinom (n : ℕ) :=
(2 * n).choose n
#align nat.central_binom Nat.centralBinom
theorem centralBinom_eq_two_mul_choose (n : ℕ) : centralBinom n = (2 * n).choose n :=
rfl
#align nat.central_binom_eq_two_mul_choose Nat.centralBinom_eq_two_mul_choose
theorem centralBinom_pos (n : ℕ) : 0 < centralBinom n :=
choose_pos (Nat.le_mul_of_pos_left _ zero_lt_two)
#align nat.central_binom_pos Nat.centralBinom_pos
theorem centralBinom_ne_zero (n : ℕ) : centralBinom n ≠ 0 :=
(centralBinom_pos n).ne'
#align nat.central_binom_ne_zero Nat.centralBinom_ne_zero
@[simp]
theorem centralBinom_zero : centralBinom 0 = 1 :=
choose_zero_right _
#align nat.central_binom_zero Nat.centralBinom_zero
theorem choose_le_centralBinom (r n : ℕ) : choose (2 * n) r ≤ centralBinom n :=
calc
(2 * n).choose r ≤ (2 * n).choose (2 * n / 2) := choose_le_middle r (2 * n)
_ = (2 * n).choose n := by rw [Nat.mul_div_cancel_left n zero_lt_two]
#align nat.choose_le_central_binom Nat.choose_le_centralBinom
theorem two_le_centralBinom (n : ℕ) (n_pos : 0 < n) : 2 ≤ centralBinom n :=
calc
2 ≤ 2 * n := Nat.le_mul_of_pos_right _ n_pos
_ = (2 * n).choose 1 := (choose_one_right (2 * n)).symm
_ ≤ centralBinom n := choose_le_centralBinom 1 n
#align nat.two_le_central_binom Nat.two_le_centralBinom
theorem succ_mul_centralBinom_succ (n : ℕ) :
(n + 1) * centralBinom (n + 1) = 2 * (2 * n + 1) * centralBinom n :=
calc
(n + 1) * (2 * (n + 1)).choose (n + 1) = (2 * n + 2).choose (n + 1) * (n + 1) := mul_comm _ _
_ = (2 * n + 1).choose n * (2 * n + 2) := by rw [choose_succ_right_eq, choose_mul_succ_eq]
_ = 2 * ((2 * n + 1).choose n * (n + 1)) := by ring
_ = 2 * ((2 * n + 1).choose n * (2 * n + 1 - n)) := by rw [two_mul n, add_assoc,
Nat.add_sub_cancel_left]
_ = 2 * ((2 * n).choose n * (2 * n + 1)) := by rw [choose_mul_succ_eq]
_ = 2 * (2 * n + 1) * (2 * n).choose n := by rw [mul_assoc, mul_comm (2 * n + 1)]
#align nat.succ_mul_central_binom_succ Nat.succ_mul_centralBinom_succ
theorem four_pow_lt_mul_centralBinom (n : ℕ) (n_big : 4 ≤ n) : 4 ^ n < n * centralBinom n := by
induction' n using Nat.strong_induction_on with n IH
rcases lt_trichotomy n 4 with (hn | rfl | hn)
· clear IH; exact False.elim ((not_lt.2 n_big) hn)
· norm_num [centralBinom, choose]
obtain ⟨n, rfl⟩ : ∃ m, n = m + 1 := Nat.exists_eq_succ_of_ne_zero (Nat.not_eq_zero_of_lt hn)
calc
4 ^ (n + 1) < 4 * (n * centralBinom n) := lt_of_eq_of_lt pow_succ' <|
(mul_lt_mul_left <| zero_lt_four' ℕ).mpr (IH n n.lt_succ_self (Nat.le_of_lt_succ hn))
_ ≤ 2 * (2 * n + 1) * centralBinom n := by rw [← mul_assoc]; linarith
_ = (n + 1) * centralBinom (n + 1) := (succ_mul_centralBinom_succ n).symm
#align nat.four_pow_lt_mul_central_binom Nat.four_pow_lt_mul_centralBinom
theorem four_pow_le_two_mul_self_mul_centralBinom :
∀ (n : ℕ) (_ : 0 < n), 4 ^ n ≤ 2 * n * centralBinom n
| 0, pr => (Nat.not_lt_zero _ pr).elim
| 1, _ => by norm_num [centralBinom, choose]
| 2, _ => by norm_num [centralBinom, choose]
| 3, _ => by norm_num [centralBinom, choose]
| n + 4, _ =>
calc
4 ^ (n+4) ≤ (n+4) * centralBinom (n+4) := (four_pow_lt_mul_centralBinom _ le_add_self).le
_ ≤ 2 * (n+4) * centralBinom (n+4) := by
rw [mul_assoc]; refine Nat.le_mul_of_pos_left _ zero_lt_two
#align nat.four_pow_le_two_mul_self_mul_central_binom Nat.four_pow_le_two_mul_self_mul_centralBinom
theorem two_dvd_centralBinom_succ (n : ℕ) : 2 ∣ centralBinom (n + 1) := by
use (n + 1 + n).choose n
rw [centralBinom_eq_two_mul_choose, two_mul, ← add_assoc,
choose_succ_succ' (n + 1 + n) n, choose_symm_add, ← two_mul]
#align nat.two_dvd_central_binom_succ Nat.two_dvd_centralBinom_succ
| Mathlib/Data/Nat/Choose/Central.lean | 124 | 126 | theorem two_dvd_centralBinom_of_one_le {n : ℕ} (h : 0 < n) : 2 ∣ centralBinom n := by |
rw [← Nat.succ_pred_eq_of_pos h]
exact two_dvd_centralBinom_succ n.pred
| [
" (2 * n).choose (2 * n / 2) = (2 * n).choose n",
" (2 * n + 2).choose (n + 1) * (n + 1) = (2 * n + 1).choose n * (2 * n + 2)",
" (2 * n + 1).choose n * (2 * n + 2) = 2 * ((2 * n + 1).choose n * (n + 1))",
" 2 * ((2 * n + 1).choose n * (n + 1)) = 2 * ((2 * n + 1).choose n * (2 * n + 1 - n))",
" 2 * ((2 * n ... | [
" (2 * n).choose (2 * n / 2) = (2 * n).choose n",
" (2 * n + 2).choose (n + 1) * (n + 1) = (2 * n + 1).choose n * (2 * n + 2)",
" (2 * n + 1).choose n * (2 * n + 2) = 2 * ((2 * n + 1).choose n * (n + 1))",
" 2 * ((2 * n + 1).choose n * (n + 1)) = 2 * ((2 * n + 1).choose n * (2 * n + 1 - n))",
" 2 * ((2 * n ... |
import Mathlib.Algebra.CharP.Invertible
import Mathlib.Algebra.Order.Invertible
import Mathlib.Algebra.Order.Module.OrderedSMul
import Mathlib.Algebra.Order.Group.Instances
import Mathlib.LinearAlgebra.AffineSpace.Slope
import Mathlib.LinearAlgebra.AffineSpace.Midpoint
import Mathlib.Tactic.FieldSimp
#align_import linear_algebra.affine_space.ordered from "leanprover-community/mathlib"@"78261225eb5cedc61c5c74ecb44e5b385d13b733"
open AffineMap
variable {k E PE : Type*}
section LinearOrderedField
variable [LinearOrderedField k] [OrderedAddCommGroup E]
variable [Module k E] [OrderedSMul k E]
section
variable {a b : E} {r r' : k}
theorem lineMap_le_lineMap_iff_of_lt (h : r < r') : lineMap a b r ≤ lineMap a b r' ↔ a ≤ b := by
simp only [lineMap_apply_module]
rw [← le_sub_iff_add_le, add_sub_assoc, ← sub_le_iff_le_add', ← sub_smul, ← sub_smul,
sub_sub_sub_cancel_left, smul_le_smul_iff_of_pos_left (sub_pos.2 h)]
#align line_map_le_line_map_iff_of_lt lineMap_le_lineMap_iff_of_lt
theorem left_le_lineMap_iff_le (h : 0 < r) : a ≤ lineMap a b r ↔ a ≤ b :=
Iff.trans (by rw [lineMap_apply_zero]) (lineMap_le_lineMap_iff_of_lt h)
#align left_le_line_map_iff_le left_le_lineMap_iff_le
@[simp]
theorem left_le_midpoint : a ≤ midpoint k a b ↔ a ≤ b :=
left_le_lineMap_iff_le <| inv_pos.2 zero_lt_two
#align left_le_midpoint left_le_midpoint
theorem lineMap_le_left_iff_le (h : 0 < r) : lineMap a b r ≤ a ↔ b ≤ a :=
left_le_lineMap_iff_le (E := Eᵒᵈ) h
#align line_map_le_left_iff_le lineMap_le_left_iff_le
@[simp]
theorem midpoint_le_left : midpoint k a b ≤ a ↔ b ≤ a :=
lineMap_le_left_iff_le <| inv_pos.2 zero_lt_two
#align midpoint_le_left midpoint_le_left
theorem lineMap_le_right_iff_le (h : r < 1) : lineMap a b r ≤ b ↔ a ≤ b :=
Iff.trans (by rw [lineMap_apply_one]) (lineMap_le_lineMap_iff_of_lt h)
#align line_map_le_right_iff_le lineMap_le_right_iff_le
@[simp]
theorem midpoint_le_right : midpoint k a b ≤ b ↔ a ≤ b :=
lineMap_le_right_iff_le <| inv_lt_one one_lt_two
#align midpoint_le_right midpoint_le_right
theorem right_le_lineMap_iff_le (h : r < 1) : b ≤ lineMap a b r ↔ b ≤ a :=
lineMap_le_right_iff_le (E := Eᵒᵈ) h
#align right_le_line_map_iff_le right_le_lineMap_iff_le
@[simp]
theorem right_le_midpoint : b ≤ midpoint k a b ↔ b ≤ a :=
right_le_lineMap_iff_le <| inv_lt_one one_lt_two
#align right_le_midpoint right_le_midpoint
end
variable {f : k → E} {a b r : k}
local notation "c" => lineMap a b r
theorem map_le_lineMap_iff_slope_le_slope_left (h : 0 < r * (b - a)) :
f c ≤ lineMap (f a) (f b) r ↔ slope f a c ≤ slope f a b := by
rw [lineMap_apply, lineMap_apply, slope, slope, vsub_eq_sub, vsub_eq_sub, vsub_eq_sub,
vadd_eq_add, vadd_eq_add, smul_eq_mul, add_sub_cancel_right, smul_sub, smul_sub, smul_sub,
sub_le_iff_le_add, mul_inv_rev, mul_smul, mul_smul, ← smul_sub, ← smul_sub, ← smul_add,
smul_smul, ← mul_inv_rev, inv_smul_le_iff_of_pos h, smul_smul,
mul_inv_cancel_right₀ (right_ne_zero_of_mul h.ne'), smul_add,
smul_inv_smul₀ (left_ne_zero_of_mul h.ne')]
#align map_le_line_map_iff_slope_le_slope_left map_le_lineMap_iff_slope_le_slope_left
theorem lineMap_le_map_iff_slope_le_slope_left (h : 0 < r * (b - a)) :
lineMap (f a) (f b) r ≤ f c ↔ slope f a b ≤ slope f a c :=
map_le_lineMap_iff_slope_le_slope_left (E := Eᵒᵈ) (f := f) (a := a) (b := b) (r := r) h
#align line_map_le_map_iff_slope_le_slope_left lineMap_le_map_iff_slope_le_slope_left
theorem map_lt_lineMap_iff_slope_lt_slope_left (h : 0 < r * (b - a)) :
f c < lineMap (f a) (f b) r ↔ slope f a c < slope f a b :=
lt_iff_lt_of_le_iff_le' (lineMap_le_map_iff_slope_le_slope_left h)
(map_le_lineMap_iff_slope_le_slope_left h)
#align map_lt_line_map_iff_slope_lt_slope_left map_lt_lineMap_iff_slope_lt_slope_left
theorem lineMap_lt_map_iff_slope_lt_slope_left (h : 0 < r * (b - a)) :
lineMap (f a) (f b) r < f c ↔ slope f a b < slope f a c :=
map_lt_lineMap_iff_slope_lt_slope_left (E := Eᵒᵈ) (f := f) (a := a) (b := b) (r := r) h
#align line_map_lt_map_iff_slope_lt_slope_left lineMap_lt_map_iff_slope_lt_slope_left
| Mathlib/LinearAlgebra/AffineSpace/Ordered.lean | 240 | 248 | theorem map_le_lineMap_iff_slope_le_slope_right (h : 0 < (1 - r) * (b - a)) :
f c ≤ lineMap (f a) (f b) r ↔ slope f a b ≤ slope f c b := by |
rw [← lineMap_apply_one_sub, ← lineMap_apply_one_sub _ _ r]
revert h; generalize 1 - r = r'; clear! r; intro h
simp_rw [lineMap_apply, slope, vsub_eq_sub, vadd_eq_add, smul_eq_mul]
rw [sub_add_eq_sub_sub_swap, sub_self, zero_sub, neg_mul_eq_mul_neg, neg_sub,
le_inv_smul_iff_of_pos h, smul_smul, mul_inv_cancel_right₀, le_sub_comm, ← neg_sub (f b),
smul_neg, neg_add_eq_sub]
· exact right_ne_zero_of_mul h.ne'
| [
" (lineMap a b) r ≤ (lineMap a b) r' ↔ a ≤ b",
" (1 - r) • a + r • b ≤ (1 - r') • a + r' • b ↔ a ≤ b",
" a ≤ (lineMap a b) r ↔ (lineMap a b) 0 ≤ (lineMap a b) r",
" (lineMap a b) r ≤ b ↔ (lineMap a b) r ≤ (lineMap a b) 1",
" f ((lineMap a b) r) ≤ (lineMap (f a) (f b)) r ↔ slope f a ((lineMap a b) r) ≤ slope... | [
" (lineMap a b) r ≤ (lineMap a b) r' ↔ a ≤ b",
" (1 - r) • a + r • b ≤ (1 - r') • a + r' • b ↔ a ≤ b",
" a ≤ (lineMap a b) r ↔ (lineMap a b) 0 ≤ (lineMap a b) r",
" (lineMap a b) r ≤ b ↔ (lineMap a b) r ≤ (lineMap a b) 1",
" f ((lineMap a b) r) ≤ (lineMap (f a) (f b)) r ↔ slope f a ((lineMap a b) r) ≤ slope... |
import Mathlib.Algebra.CharP.Two
import Mathlib.Algebra.CharP.Reduced
import Mathlib.Algebra.NeZero
import Mathlib.Algebra.Polynomial.RingDivision
import Mathlib.GroupTheory.SpecificGroups.Cyclic
import Mathlib.NumberTheory.Divisors
import Mathlib.RingTheory.IntegralDomain
import Mathlib.Tactic.Zify
#align_import ring_theory.roots_of_unity.basic from "leanprover-community/mathlib"@"7fdeecc0d03cd40f7a165e6cf00a4d2286db599f"
open scoped Classical Polynomial
noncomputable section
open Polynomial
open Finset
variable {M N G R S F : Type*}
variable [CommMonoid M] [CommMonoid N] [DivisionCommMonoid G]
section rootsOfUnity
variable {k l : ℕ+}
def rootsOfUnity (k : ℕ+) (M : Type*) [CommMonoid M] : Subgroup Mˣ where
carrier := {ζ | ζ ^ (k : ℕ) = 1}
one_mem' := one_pow _
mul_mem' _ _ := by simp_all only [Set.mem_setOf_eq, mul_pow, one_mul]
inv_mem' _ := by simp_all only [Set.mem_setOf_eq, inv_pow, inv_one]
#align roots_of_unity rootsOfUnity
@[simp]
theorem mem_rootsOfUnity (k : ℕ+) (ζ : Mˣ) : ζ ∈ rootsOfUnity k M ↔ ζ ^ (k : ℕ) = 1 :=
Iff.rfl
#align mem_roots_of_unity mem_rootsOfUnity
| Mathlib/RingTheory/RootsOfUnity/Basic.lean | 93 | 94 | theorem mem_rootsOfUnity' (k : ℕ+) (ζ : Mˣ) : ζ ∈ rootsOfUnity k M ↔ (ζ : M) ^ (k : ℕ) = 1 := by |
rw [mem_rootsOfUnity]; norm_cast
| [
" a✝ * b✝ ∈ {ζ | ζ ^ ↑k = 1}",
" x✝¹⁻¹ ∈ { carrier := {ζ | ζ ^ ↑k = 1}, mul_mem' := ⋯, one_mem' := ⋯ }.carrier",
" ζ ∈ rootsOfUnity k M ↔ ↑ζ ^ ↑k = 1",
" ζ ^ ↑k = 1 ↔ ↑ζ ^ ↑k = 1"
] | [
" a✝ * b✝ ∈ {ζ | ζ ^ ↑k = 1}",
" x✝¹⁻¹ ∈ { carrier := {ζ | ζ ^ ↑k = 1}, mul_mem' := ⋯, one_mem' := ⋯ }.carrier",
" ζ ∈ rootsOfUnity k M ↔ ↑ζ ^ ↑k = 1"
] |
import Mathlib.Algebra.IsPrimePow
import Mathlib.SetTheory.Cardinal.Ordinal
import Mathlib.Tactic.WLOG
#align_import set_theory.cardinal.divisibility from "leanprover-community/mathlib"@"ea050b44c0f9aba9d16a948c7cc7d2e7c8493567"
namespace Cardinal
open Cardinal
universe u
variable {a b : Cardinal.{u}} {n m : ℕ}
@[simp]
theorem isUnit_iff : IsUnit a ↔ a = 1 := by
refine
⟨fun h => ?_, by
rintro rfl
exact isUnit_one⟩
rcases eq_or_ne a 0 with (rfl | ha)
· exact (not_isUnit_zero h).elim
rw [isUnit_iff_forall_dvd] at h
cases' h 1 with t ht
rw [eq_comm, mul_eq_one_iff'] at ht
· exact ht.1
· exact one_le_iff_ne_zero.mpr ha
· apply one_le_iff_ne_zero.mpr
intro h
rw [h, mul_zero] at ht
exact zero_ne_one ht
#align cardinal.is_unit_iff Cardinal.isUnit_iff
instance : Unique Cardinal.{u}ˣ where
default := 1
uniq a := Units.val_eq_one.mp <| isUnit_iff.mp a.isUnit
theorem le_of_dvd : ∀ {a b : Cardinal}, b ≠ 0 → a ∣ b → a ≤ b
| a, x, b0, ⟨b, hab⟩ => by
simpa only [hab, mul_one] using
mul_le_mul_left' (one_le_iff_ne_zero.2 fun h : b = 0 => b0 (by rwa [h, mul_zero] at hab)) a
#align cardinal.le_of_dvd Cardinal.le_of_dvd
theorem dvd_of_le_of_aleph0_le (ha : a ≠ 0) (h : a ≤ b) (hb : ℵ₀ ≤ b) : a ∣ b :=
⟨b, (mul_eq_right hb h ha).symm⟩
#align cardinal.dvd_of_le_of_aleph_0_le Cardinal.dvd_of_le_of_aleph0_le
@[simp]
theorem prime_of_aleph0_le (ha : ℵ₀ ≤ a) : Prime a := by
refine ⟨(aleph0_pos.trans_le ha).ne', ?_, fun b c hbc => ?_⟩
· rw [isUnit_iff]
exact (one_lt_aleph0.trans_le ha).ne'
rcases eq_or_ne (b * c) 0 with hz | hz
· rcases mul_eq_zero.mp hz with (rfl | rfl) <;> simp
wlog h : c ≤ b
· cases le_total c b <;> [solve_by_elim; rw [or_comm]]
apply_assumption
assumption'
all_goals rwa [mul_comm]
left
have habc := le_of_dvd hz hbc
rwa [mul_eq_max' <| ha.trans <| habc, max_def', if_pos h] at hbc
#align cardinal.prime_of_aleph_0_le Cardinal.prime_of_aleph0_le
theorem not_irreducible_of_aleph0_le (ha : ℵ₀ ≤ a) : ¬Irreducible a := by
rw [irreducible_iff, not_and_or]
refine Or.inr fun h => ?_
simpa [mul_aleph0_eq ha, isUnit_iff, (one_lt_aleph0.trans_le ha).ne', one_lt_aleph0.ne'] using
h a ℵ₀
#align cardinal.not_irreducible_of_aleph_0_le Cardinal.not_irreducible_of_aleph0_le
@[simp, norm_cast]
| Mathlib/SetTheory/Cardinal/Divisibility.lean | 100 | 108 | theorem nat_coe_dvd_iff : (n : Cardinal) ∣ m ↔ n ∣ m := by |
refine ⟨?_, fun ⟨h, ht⟩ => ⟨h, mod_cast ht⟩⟩
rintro ⟨k, hk⟩
have : ↑m < ℵ₀ := nat_lt_aleph0 m
rw [hk, mul_lt_aleph0_iff] at this
rcases this with (h | h | ⟨-, hk'⟩)
iterate 2 simp only [h, mul_zero, zero_mul, Nat.cast_eq_zero] at hk; simp [hk]
lift k to ℕ using hk'
exact ⟨k, mod_cast hk⟩
| [
" IsUnit a ↔ a = 1",
" a = 1 → IsUnit a",
" IsUnit 1",
" a = 1",
" 0 = 1",
" 1 ≤ a",
" 1 ≤ t",
" t ≠ 0",
" False",
" a ≤ x",
" x = 0",
" Prime a",
" ¬IsUnit a",
" ¬a = 1",
" a ∣ b ∨ a ∣ c",
" a ∣ 0 ∨ a ∣ c",
" a ∣ b ∨ a ∣ 0",
" a ∣ c ∨ a ∣ b",
" b ≤ c",
" c * b ≠ 0",
" a ∣ c ... | [
" IsUnit a ↔ a = 1",
" a = 1 → IsUnit a",
" IsUnit 1",
" a = 1",
" 0 = 1",
" 1 ≤ a",
" 1 ≤ t",
" t ≠ 0",
" False",
" a ≤ x",
" x = 0",
" Prime a",
" ¬IsUnit a",
" ¬a = 1",
" a ∣ b ∨ a ∣ c",
" a ∣ 0 ∨ a ∣ c",
" a ∣ b ∨ a ∣ 0",
" a ∣ c ∨ a ∣ b",
" b ≤ c",
" c * b ≠ 0",
" a ∣ c ... |
import Mathlib.Data.List.Join
#align_import data.list.permutation from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734"
-- Make sure we don't import algebra
assert_not_exists Monoid
open Nat
variable {α β : Type*}
namespace List
theorem permutationsAux2_fst (t : α) (ts : List α) (r : List β) :
∀ (ys : List α) (f : List α → β), (permutationsAux2 t ts r ys f).1 = ys ++ ts
| [], f => rfl
| y :: ys, f => by simp [permutationsAux2, permutationsAux2_fst t _ _ ys]
#align list.permutations_aux2_fst List.permutationsAux2_fst
@[simp]
theorem permutationsAux2_snd_nil (t : α) (ts : List α) (r : List β) (f : List α → β) :
(permutationsAux2 t ts r [] f).2 = r :=
rfl
#align list.permutations_aux2_snd_nil List.permutationsAux2_snd_nil
@[simp]
theorem permutationsAux2_snd_cons (t : α) (ts : List α) (r : List β) (y : α) (ys : List α)
(f : List α → β) :
(permutationsAux2 t ts r (y :: ys) f).2 =
f (t :: y :: ys ++ ts) :: (permutationsAux2 t ts r ys fun x : List α => f (y :: x)).2 := by
simp [permutationsAux2, permutationsAux2_fst t _ _ ys]
#align list.permutations_aux2_snd_cons List.permutationsAux2_snd_cons
theorem permutationsAux2_append (t : α) (ts : List α) (r : List β) (ys : List α) (f : List α → β) :
(permutationsAux2 t ts nil ys f).2 ++ r = (permutationsAux2 t ts r ys f).2 := by
induction ys generalizing f <;> simp [*]
#align list.permutations_aux2_append List.permutationsAux2_append
theorem permutationsAux2_comp_append {t : α} {ts ys : List α} {r : List β} (f : List α → β) :
((permutationsAux2 t [] r ys) fun x => f (x ++ ts)).2 = (permutationsAux2 t ts r ys f).2 := by
induction' ys with ys_hd _ ys_ih generalizing f
· simp
· simp [ys_ih fun xs => f (ys_hd :: xs)]
#align list.permutations_aux2_comp_append List.permutationsAux2_comp_append
theorem map_permutationsAux2' {α' β'} (g : α → α') (g' : β → β') (t : α) (ts ys : List α)
(r : List β) (f : List α → β) (f' : List α' → β') (H : ∀ a, g' (f a) = f' (map g a)) :
map g' (permutationsAux2 t ts r ys f).2 =
(permutationsAux2 (g t) (map g ts) (map g' r) (map g ys) f').2 := by
induction' ys with ys_hd _ ys_ih generalizing f f'
· simp
· simp only [map, permutationsAux2_snd_cons, cons_append, cons.injEq]
rw [ys_ih, permutationsAux2_fst]
· refine ⟨?_, rfl⟩
simp only [← map_cons, ← map_append]; apply H
· intro a; apply H
#align list.map_permutations_aux2' List.map_permutationsAux2'
| Mathlib/Data/List/Permutation.lean | 104 | 108 | theorem map_permutationsAux2 (t : α) (ts : List α) (ys : List α) (f : List α → β) :
(permutationsAux2 t ts [] ys id).2.map f = (permutationsAux2 t ts [] ys f).2 := by |
rw [map_permutationsAux2' id, map_id, map_id]
· rfl
simp
| [
" (permutationsAux2 t ts r (y :: ys) f).1 = y :: ys ++ ts",
" (permutationsAux2 t ts r (y :: ys) f).2 = f (t :: y :: ys ++ ts) :: (permutationsAux2 t ts r ys fun x => f (y :: x)).2",
" (permutationsAux2 t ts [] ys f).2 ++ r = (permutationsAux2 t ts r ys f).2",
" (permutationsAux2 t ts [] [] f).2 ++ r = (permu... | [
" (permutationsAux2 t ts r (y :: ys) f).1 = y :: ys ++ ts",
" (permutationsAux2 t ts r (y :: ys) f).2 = f (t :: y :: ys ++ ts) :: (permutationsAux2 t ts r ys fun x => f (y :: x)).2",
" (permutationsAux2 t ts [] ys f).2 ++ r = (permutationsAux2 t ts r ys f).2",
" (permutationsAux2 t ts [] [] f).2 ++ r = (permu... |
import Mathlib.Computability.Halting
import Mathlib.Computability.TuringMachine
import Mathlib.Data.Num.Lemmas
import Mathlib.Tactic.DeriveFintype
#align_import computability.tm_to_partrec from "leanprover-community/mathlib"@"6155d4351090a6fad236e3d2e4e0e4e7342668e8"
open Function (update)
open Relation
namespace Turing
namespace ToPartrec
inductive Code
| zero'
| succ
| tail
| cons : Code → Code → Code
| comp : Code → Code → Code
| case : Code → Code → Code
| fix : Code → Code
deriving DecidableEq, Inhabited
#align turing.to_partrec.code Turing.ToPartrec.Code
#align turing.to_partrec.code.zero' Turing.ToPartrec.Code.zero'
#align turing.to_partrec.code.succ Turing.ToPartrec.Code.succ
#align turing.to_partrec.code.tail Turing.ToPartrec.Code.tail
#align turing.to_partrec.code.cons Turing.ToPartrec.Code.cons
#align turing.to_partrec.code.comp Turing.ToPartrec.Code.comp
#align turing.to_partrec.code.case Turing.ToPartrec.Code.case
#align turing.to_partrec.code.fix Turing.ToPartrec.Code.fix
def Code.eval : Code → List ℕ →. List ℕ
| Code.zero' => fun v => pure (0 :: v)
| Code.succ => fun v => pure [v.headI.succ]
| Code.tail => fun v => pure v.tail
| Code.cons f fs => fun v => do
let n ← Code.eval f v
let ns ← Code.eval fs v
pure (n.headI :: ns)
| Code.comp f g => fun v => g.eval v >>= f.eval
| Code.case f g => fun v => v.headI.rec (f.eval v.tail) fun y _ => g.eval (y::v.tail)
| Code.fix f =>
PFun.fix fun v => (f.eval v).map fun v => if v.headI = 0 then Sum.inl v.tail else Sum.inr v.tail
#align turing.to_partrec.code.eval Turing.ToPartrec.Code.eval
namespace Code
@[simp]
theorem zero'_eval : zero'.eval = fun v => pure (0 :: v) := by simp [eval]
@[simp]
theorem succ_eval : succ.eval = fun v => pure [v.headI.succ] := by simp [eval]
@[simp]
theorem tail_eval : tail.eval = fun v => pure v.tail := by simp [eval]
@[simp]
theorem cons_eval (f fs) : (cons f fs).eval = fun v => do {
let n ← Code.eval f v
let ns ← Code.eval fs v
pure (n.headI :: ns) } := by simp [eval]
@[simp]
theorem comp_eval (f g) : (comp f g).eval = fun v => g.eval v >>= f.eval := by simp [eval]
@[simp]
theorem case_eval (f g) :
(case f g).eval = fun v => v.headI.rec (f.eval v.tail) fun y _ => g.eval (y::v.tail) := by
simp [eval]
@[simp]
theorem fix_eval (f) : (fix f).eval =
PFun.fix fun v => (f.eval v).map fun v =>
if v.headI = 0 then Sum.inl v.tail else Sum.inr v.tail := by
simp [eval]
def nil : Code :=
tail.comp succ
#align turing.to_partrec.code.nil Turing.ToPartrec.Code.nil
@[simp]
theorem nil_eval (v) : nil.eval v = pure [] := by simp [nil]
#align turing.to_partrec.code.nil_eval Turing.ToPartrec.Code.nil_eval
def id : Code :=
tail.comp zero'
#align turing.to_partrec.code.id Turing.ToPartrec.Code.id
@[simp]
theorem id_eval (v) : id.eval v = pure v := by simp [id]
#align turing.to_partrec.code.id_eval Turing.ToPartrec.Code.id_eval
def head : Code :=
cons id nil
#align turing.to_partrec.code.head Turing.ToPartrec.Code.head
@[simp]
theorem head_eval (v) : head.eval v = pure [v.headI] := by simp [head]
#align turing.to_partrec.code.head_eval Turing.ToPartrec.Code.head_eval
def zero : Code :=
cons zero' nil
#align turing.to_partrec.code.zero Turing.ToPartrec.Code.zero
@[simp]
theorem zero_eval (v) : zero.eval v = pure [0] := by simp [zero]
#align turing.to_partrec.code.zero_eval Turing.ToPartrec.Code.zero_eval
def pred : Code :=
case zero head
#align turing.to_partrec.code.pred Turing.ToPartrec.Code.pred
@[simp]
| Mathlib/Computability/TMToPartrec.lean | 211 | 212 | theorem pred_eval (v) : pred.eval v = pure [v.headI.pred] := by |
simp [pred]; cases v.headI <;> simp
| [
" zero'.eval = fun v => pure (0 :: v)",
" succ.eval = fun v => pure [v.headI.succ]",
" tail.eval = fun v => pure v.tail",
" (f.cons fs).eval = fun v => do\n let n ← f.eval v\n let ns ← fs.eval v\n pure (n.headI :: ns)",
" (f.comp g).eval = fun v => g.eval v >>= f.eval",
" (f.case g).eval = fun v ... | [
" zero'.eval = fun v => pure (0 :: v)",
" succ.eval = fun v => pure [v.headI.succ]",
" tail.eval = fun v => pure v.tail",
" (f.cons fs).eval = fun v => do\n let n ← f.eval v\n let ns ← fs.eval v\n pure (n.headI :: ns)",
" (f.comp g).eval = fun v => g.eval v >>= f.eval",
" (f.case g).eval = fun v ... |
import Mathlib.Algebra.Group.NatPowAssoc
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Induction
import Mathlib.Algebra.Polynomial.Eval
namespace Polynomial
section MulActionWithZero
variable {R : Type*} [Semiring R] (r : R) (p : R[X]) {S : Type*} [AddCommMonoid S] [Pow S ℕ]
[MulActionWithZero R S] (x : S)
def smul_pow : ℕ → R → S := fun n r => r • x^n
irreducible_def smeval : S := p.sum (smul_pow x)
theorem smeval_eq_sum : p.smeval x = p.sum (smul_pow x) := by rw [smeval_def]
@[simp]
theorem smeval_C : (C r).smeval x = r • x ^ 0 := by
simp only [smeval_eq_sum, smul_pow, zero_smul, sum_C_index]
@[simp]
theorem smeval_monomial (n : ℕ) :
(monomial n r).smeval x = r • x ^ n := by
simp only [smeval_eq_sum, smul_pow, zero_smul, sum_monomial_index]
theorem eval_eq_smeval : p.eval r = p.smeval r := by
rw [eval_eq_sum, smeval_eq_sum]
rfl
theorem eval₂_eq_smeval (R : Type*) [Semiring R] {S : Type*} [Semiring S] (f : R →+* S) (p : R[X])
(x: S) : letI : Module R S := RingHom.toModule f
p.eval₂ f x = p.smeval x := by
letI : Module R S := RingHom.toModule f
rw [smeval_eq_sum, eval₂_eq_sum]
rfl
variable (R)
@[simp]
theorem smeval_zero : (0 : R[X]).smeval x = 0 := by
simp only [smeval_eq_sum, smul_pow, sum_zero_index]
@[simp]
theorem smeval_one : (1 : R[X]).smeval x = 1 • x ^ 0 := by
rw [← C_1, smeval_C]
simp only [Nat.cast_one, one_smul]
@[simp]
| Mathlib/Algebra/Polynomial/Smeval.lean | 88 | 90 | theorem smeval_X :
(X : R[X]).smeval x = x ^ 1 := by |
simp only [smeval_eq_sum, smul_pow, zero_smul, sum_X_index, one_smul]
| [
" p.smeval x = p.sum (smul_pow x)",
" (C r).smeval x = r • x ^ 0",
" ((monomial n) r).smeval x = r • x ^ n",
" eval r p = p.smeval r",
" (p.sum fun e a => a * r ^ e) = p.sum (smul_pow r)",
" eval₂ f x p = p.smeval x",
" (p.sum fun e a => f a * x ^ e) = p.sum (smul_pow x)",
" smeval 0 x = 0",
" smeva... | [
" p.smeval x = p.sum (smul_pow x)",
" (C r).smeval x = r • x ^ 0",
" ((monomial n) r).smeval x = r • x ^ n",
" eval r p = p.smeval r",
" (p.sum fun e a => a * r ^ e) = p.sum (smul_pow r)",
" eval₂ f x p = p.smeval x",
" (p.sum fun e a => f a * x ^ e) = p.sum (smul_pow x)",
" smeval 0 x = 0",
" smeva... |
import Mathlib.Tactic.CategoryTheory.Coherence
import Mathlib.CategoryTheory.Bicategory.Coherence
namespace CategoryTheory
namespace Bicategory
open Category
open scoped Bicategory
open Mathlib.Tactic.BicategoryCoherence (bicategoricalComp bicategoricalIsoComp)
universe w v u
variable {B : Type u} [Bicategory.{w, v} B] {a b c : B} {f : a ⟶ b} {g : b ⟶ a}
def leftZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) :=
η ▷ f ⊗≫ f ◁ ε
def rightZigzag (η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) :=
g ◁ η ⊗≫ ε ▷ g
| Mathlib/CategoryTheory/Bicategory/Adjunction.lean | 79 | 91 | theorem rightZigzag_idempotent_of_left_triangle
(η : 𝟙 a ⟶ f ≫ g) (ε : g ≫ f ⟶ 𝟙 b) (h : leftZigzag η ε = (λ_ _).hom ≫ (ρ_ _).inv) :
rightZigzag η ε ⊗≫ rightZigzag η ε = rightZigzag η ε := by |
dsimp only [rightZigzag]
calc
_ = g ◁ η ⊗≫ ((ε ▷ g ▷ 𝟙 a) ≫ (𝟙 b ≫ g) ◁ η) ⊗≫ ε ▷ g := by
simp [bicategoricalComp]; coherence
_ = 𝟙 _ ⊗≫ g ◁ (η ▷ 𝟙 a ≫ (f ≫ g) ◁ η) ⊗≫ (ε ▷ (g ≫ f) ≫ 𝟙 b ◁ ε) ▷ g ⊗≫ 𝟙 _ := by
rw [← whisker_exchange]; simp [bicategoricalComp]; coherence
_ = g ◁ η ⊗≫ g ◁ leftZigzag η ε ▷ g ⊗≫ ε ▷ g := by
rw [← whisker_exchange, ← whisker_exchange]; simp [leftZigzag, bicategoricalComp]; coherence
_ = g ◁ η ⊗≫ ε ▷ g := by
rw [h]; simp [bicategoricalComp]; coherence
| [
" rightZigzag η ε ⊗≫ rightZigzag η ε = rightZigzag η ε",
" (g ◁ η ⊗≫ ε ▷ g) ⊗≫ g ◁ η ⊗≫ ε ▷ g = g ◁ η ⊗≫ ε ▷ g",
" (g ◁ η ⊗≫ ε ▷ g) ⊗≫ g ◁ η ⊗≫ ε ▷ g = g ◁ η ⊗≫ (ε ▷ g ▷ 𝟙 a ≫ (𝟙 b ≫ g) ◁ η) ⊗≫ ε ▷ g",
" g ◁ η ≫ (α_ g f g).inv ≫ ε ▷ g ≫ (λ_ g).hom ≫ (ρ_ g).inv ≫ g ◁ η ≫ (α_ g f g).inv ≫ ε ▷ g =\n g ◁ η ≫... | [
" rightZigzag η ε ⊗≫ rightZigzag η ε = rightZigzag η ε"
] |
import Mathlib.Data.Set.Lattice
#align_import data.semiquot from "leanprover-community/mathlib"@"09597669f02422ed388036273d8848119699c22f"
-- Porting note: removed universe parameter
structure Semiquot (α : Type*) where mk' ::
s : Set α
val : Trunc s
#align semiquot Semiquot
namespace Semiquot
variable {α : Type*} {β : Type*}
instance : Membership α (Semiquot α) :=
⟨fun a q => a ∈ q.s⟩
def mk {a : α} {s : Set α} (h : a ∈ s) : Semiquot α :=
⟨s, Trunc.mk ⟨a, h⟩⟩
#align semiquot.mk Semiquot.mk
| Mathlib/Data/Semiquot.lean | 47 | 50 | theorem ext_s {q₁ q₂ : Semiquot α} : q₁ = q₂ ↔ q₁.s = q₂.s := by |
refine ⟨congr_arg _, fun h => ?_⟩
cases' q₁ with _ v₁; cases' q₂ with _ v₂; congr
exact Subsingleton.helim (congrArg Trunc (congrArg Set.Elem h)) v₁ v₂
| [
" q₁ = q₂ ↔ q₁.s = q₂.s",
" q₁ = q₂",
" { s := s✝, val := v₁ } = q₂",
" { s := s✝¹, val := v₁ } = { s := s✝, val := v₂ }",
" HEq v₁ v₂"
] | [
" q₁ = q₂ ↔ q₁.s = q₂.s"
] |
import Mathlib.Data.Multiset.Dedup
#align_import data.multiset.finset_ops from "leanprover-community/mathlib"@"c227d107bbada5d0d9d20287e3282c0a7f1651a0"
namespace Multiset
open List
variable {α : Type*} [DecidableEq α] {s : Multiset α}
def ndinsert (a : α) (s : Multiset α) : Multiset α :=
Quot.liftOn s (fun l => (l.insert a : Multiset α)) fun _ _ p => Quot.sound (p.insert a)
#align multiset.ndinsert Multiset.ndinsert
@[simp]
theorem coe_ndinsert (a : α) (l : List α) : ndinsert a l = (insert a l : List α) :=
rfl
#align multiset.coe_ndinsert Multiset.coe_ndinsert
@[simp, nolint simpNF] -- Porting note (#10675): dsimp can not prove this
theorem ndinsert_zero (a : α) : ndinsert a 0 = {a} :=
rfl
#align multiset.ndinsert_zero Multiset.ndinsert_zero
@[simp]
theorem ndinsert_of_mem {a : α} {s : Multiset α} : a ∈ s → ndinsert a s = s :=
Quot.inductionOn s fun _ h => congr_arg ((↑) : List α → Multiset α) <| insert_of_mem h
#align multiset.ndinsert_of_mem Multiset.ndinsert_of_mem
@[simp]
theorem ndinsert_of_not_mem {a : α} {s : Multiset α} : a ∉ s → ndinsert a s = a ::ₘ s :=
Quot.inductionOn s fun _ h => congr_arg ((↑) : List α → Multiset α) <| insert_of_not_mem h
#align multiset.ndinsert_of_not_mem Multiset.ndinsert_of_not_mem
@[simp]
theorem mem_ndinsert {a b : α} {s : Multiset α} : a ∈ ndinsert b s ↔ a = b ∨ a ∈ s :=
Quot.inductionOn s fun _ => mem_insert_iff
#align multiset.mem_ndinsert Multiset.mem_ndinsert
@[simp]
theorem le_ndinsert_self (a : α) (s : Multiset α) : s ≤ ndinsert a s :=
Quot.inductionOn s fun _ => (sublist_insert _ _).subperm
#align multiset.le_ndinsert_self Multiset.le_ndinsert_self
-- Porting note: removing @[simp], simp can prove it
theorem mem_ndinsert_self (a : α) (s : Multiset α) : a ∈ ndinsert a s :=
mem_ndinsert.2 (Or.inl rfl)
#align multiset.mem_ndinsert_self Multiset.mem_ndinsert_self
theorem mem_ndinsert_of_mem {a b : α} {s : Multiset α} (h : a ∈ s) : a ∈ ndinsert b s :=
mem_ndinsert.2 (Or.inr h)
#align multiset.mem_ndinsert_of_mem Multiset.mem_ndinsert_of_mem
@[simp]
theorem length_ndinsert_of_mem {a : α} {s : Multiset α} (h : a ∈ s) :
card (ndinsert a s) = card s := by simp [h]
#align multiset.length_ndinsert_of_mem Multiset.length_ndinsert_of_mem
@[simp]
| Mathlib/Data/Multiset/FinsetOps.lean | 79 | 80 | theorem length_ndinsert_of_not_mem {a : α} {s : Multiset α} (h : a ∉ s) :
card (ndinsert a s) = card s + 1 := by | simp [h]
| [
" card (ndinsert a s) = card s",
" card (ndinsert a s) = card s + 1"
] | [
" card (ndinsert a s) = card s",
" card (ndinsert a s) = card s + 1"
] |
import Mathlib.Analysis.Convex.Topology
import Mathlib.Analysis.NormedSpace.Pointwise
import Mathlib.Analysis.Seminorm
import Mathlib.Analysis.LocallyConvex.Bounded
import Mathlib.Analysis.RCLike.Basic
#align_import analysis.convex.gauge from "leanprover-community/mathlib"@"373b03b5b9d0486534edbe94747f23cb3712f93d"
open NormedField Set
open scoped Pointwise Topology NNReal
noncomputable section
variable {𝕜 E F : Type*}
section AddCommGroup
variable [AddCommGroup E] [Module ℝ E]
def gauge (s : Set E) (x : E) : ℝ :=
sInf { r : ℝ | 0 < r ∧ x ∈ r • s }
#align gauge gauge
variable {s t : Set E} {x : E} {a : ℝ}
theorem gauge_def : gauge s x = sInf ({ r ∈ Set.Ioi (0 : ℝ) | x ∈ r • s }) :=
rfl
#align gauge_def gauge_def
theorem gauge_def' : gauge s x = sInf {r ∈ Set.Ioi (0 : ℝ) | r⁻¹ • x ∈ s} := by
congrm sInf {r | ?_}
exact and_congr_right fun hr => mem_smul_set_iff_inv_smul_mem₀ hr.ne' _ _
#align gauge_def' gauge_def'
private theorem gauge_set_bddBelow : BddBelow { r : ℝ | 0 < r ∧ x ∈ r • s } :=
⟨0, fun _ hr => hr.1.le⟩
theorem Absorbent.gauge_set_nonempty (absorbs : Absorbent ℝ s) :
{ r : ℝ | 0 < r ∧ x ∈ r • s }.Nonempty :=
let ⟨r, hr₁, hr₂⟩ := (absorbs x).exists_pos
⟨r, hr₁, hr₂ r (Real.norm_of_nonneg hr₁.le).ge rfl⟩
#align absorbent.gauge_set_nonempty Absorbent.gauge_set_nonempty
theorem gauge_mono (hs : Absorbent ℝ s) (h : s ⊆ t) : gauge t ≤ gauge s := fun _ =>
csInf_le_csInf gauge_set_bddBelow hs.gauge_set_nonempty fun _ hr => ⟨hr.1, smul_set_mono h hr.2⟩
#align gauge_mono gauge_mono
theorem exists_lt_of_gauge_lt (absorbs : Absorbent ℝ s) (h : gauge s x < a) :
∃ b, 0 < b ∧ b < a ∧ x ∈ b • s := by
obtain ⟨b, ⟨hb, hx⟩, hba⟩ := exists_lt_of_csInf_lt absorbs.gauge_set_nonempty h
exact ⟨b, hb, hba, hx⟩
#align exists_lt_of_gauge_lt exists_lt_of_gauge_lt
@[simp]
theorem gauge_zero : gauge s 0 = 0 := by
rw [gauge_def']
by_cases h : (0 : E) ∈ s
· simp only [smul_zero, sep_true, h, csInf_Ioi]
· simp only [smul_zero, sep_false, h, Real.sInf_empty]
#align gauge_zero gauge_zero
@[simp]
theorem gauge_zero' : gauge (0 : Set E) = 0 := by
ext x
rw [gauge_def']
obtain rfl | hx := eq_or_ne x 0
· simp only [csInf_Ioi, mem_zero, Pi.zero_apply, eq_self_iff_true, sep_true, smul_zero]
· simp only [mem_zero, Pi.zero_apply, inv_eq_zero, smul_eq_zero]
convert Real.sInf_empty
exact eq_empty_iff_forall_not_mem.2 fun r hr => hr.2.elim (ne_of_gt hr.1) hx
#align gauge_zero' gauge_zero'
@[simp]
theorem gauge_empty : gauge (∅ : Set E) = 0 := by
ext
simp only [gauge_def', Real.sInf_empty, mem_empty_iff_false, Pi.zero_apply, sep_false]
#align gauge_empty gauge_empty
| Mathlib/Analysis/Convex/Gauge.lean | 119 | 121 | theorem gauge_of_subset_zero (h : s ⊆ 0) : gauge s = 0 := by |
obtain rfl | rfl := subset_singleton_iff_eq.1 h
exacts [gauge_empty, gauge_zero']
| [
" gauge s x = sInf {r | r ∈ Ioi 0 ∧ r⁻¹ • x ∈ s}",
" 0 < r ∧ x ∈ r • s ↔ r ∈ Ioi 0 ∧ r⁻¹ • x ∈ s",
" ∃ b, 0 < b ∧ b < a ∧ x ∈ b • s",
" gauge s 0 = 0",
" sInf {r | r ∈ Ioi 0 ∧ r⁻¹ • 0 ∈ s} = 0",
" gauge 0 = 0",
" gauge 0 x = 0 x",
" sInf {r | r ∈ Ioi 0 ∧ r⁻¹ • x ∈ 0} = 0 x",
" sInf {r | r ∈ Ioi 0 ∧ ... | [
" gauge s x = sInf {r | r ∈ Ioi 0 ∧ r⁻¹ • x ∈ s}",
" 0 < r ∧ x ∈ r • s ↔ r ∈ Ioi 0 ∧ r⁻¹ • x ∈ s",
" ∃ b, 0 < b ∧ b < a ∧ x ∈ b • s",
" gauge s 0 = 0",
" sInf {r | r ∈ Ioi 0 ∧ r⁻¹ • 0 ∈ s} = 0",
" gauge 0 = 0",
" gauge 0 x = 0 x",
" sInf {r | r ∈ Ioi 0 ∧ r⁻¹ • x ∈ 0} = 0 x",
" sInf {r | r ∈ Ioi 0 ∧ ... |
import Mathlib.Algebra.Field.Defs
import Mathlib.Algebra.GroupWithZero.Units.Lemmas
import Mathlib.Algebra.Ring.Commute
import Mathlib.Algebra.Ring.Invertible
import Mathlib.Order.Synonym
#align_import algebra.field.basic from "leanprover-community/mathlib"@"05101c3df9d9cfe9430edc205860c79b6d660102"
open Function OrderDual Set
universe u
variable {α β K : Type*}
section DivisionMonoid
variable [DivisionMonoid K] [HasDistribNeg K] {a b : K}
theorem one_div_neg_one_eq_neg_one : (1 : K) / -1 = -1 :=
have : -1 * -1 = (1 : K) := by rw [neg_mul_neg, one_mul]
Eq.symm (eq_one_div_of_mul_eq_one_right this)
#align one_div_neg_one_eq_neg_one one_div_neg_one_eq_neg_one
theorem one_div_neg_eq_neg_one_div (a : K) : 1 / -a = -(1 / a) :=
calc
1 / -a = 1 / (-1 * a) := by rw [neg_eq_neg_one_mul]
_ = 1 / a * (1 / -1) := by rw [one_div_mul_one_div_rev]
_ = 1 / a * -1 := by rw [one_div_neg_one_eq_neg_one]
_ = -(1 / a) := by rw [mul_neg, mul_one]
#align one_div_neg_eq_neg_one_div one_div_neg_eq_neg_one_div
| Mathlib/Algebra/Field/Basic.lean | 109 | 114 | theorem div_neg_eq_neg_div (a b : K) : b / -a = -(b / a) :=
calc
b / -a = b * (1 / -a) := by | rw [← inv_eq_one_div, division_def]
_ = b * -(1 / a) := by rw [one_div_neg_eq_neg_one_div]
_ = -(b * (1 / a)) := by rw [neg_mul_eq_mul_neg]
_ = -(b / a) := by rw [mul_one_div]
| [
" -1 * -1 = 1",
" 1 / -a = 1 / (-1 * a)",
" 1 / (-1 * a) = 1 / a * (1 / -1)",
" 1 / a * (1 / -1) = 1 / a * -1",
" 1 / a * -1 = -(1 / a)",
" b / -a = b * (1 / -a)",
" b * (1 / -a) = b * -(1 / a)",
" b * -(1 / a) = -(b * (1 / a))",
" -(b * (1 / a)) = -(b / a)"
] | [
" -1 * -1 = 1",
" 1 / -a = 1 / (-1 * a)",
" 1 / (-1 * a) = 1 / a * (1 / -1)",
" 1 / a * (1 / -1) = 1 / a * -1",
" 1 / a * -1 = -(1 / a)",
" b / -a = b * (1 / -a)"
] |
import Mathlib.MeasureTheory.Constructions.Pi
import Mathlib.MeasureTheory.Integral.Lebesgue
open scoped Classical ENNReal
open Set Function Equiv Finset
noncomputable section
namespace MeasureTheory
section LMarginal
variable {δ δ' : Type*} {π : δ → Type*} [∀ x, MeasurableSpace (π x)]
variable {μ : ∀ i, Measure (π i)} [∀ i, SigmaFinite (μ i)] [DecidableEq δ]
variable {s t : Finset δ} {f g : (∀ i, π i) → ℝ≥0∞} {x y : ∀ i, π i} {i : δ}
def lmarginal (μ : ∀ i, Measure (π i)) (s : Finset δ) (f : (∀ i, π i) → ℝ≥0∞)
(x : ∀ i, π i) : ℝ≥0∞ :=
∫⁻ y : ∀ i : s, π i, f (updateFinset x s y) ∂Measure.pi fun i : s => μ i
-- Note: this notation is not a binder. This is more convenient since it returns a function.
@[inherit_doc]
notation "∫⋯∫⁻_" s ", " f " ∂" μ:70 => lmarginal μ s f
@[inherit_doc]
notation "∫⋯∫⁻_" s ", " f => lmarginal (fun _ ↦ volume) s f
variable (μ)
theorem _root_.Measurable.lmarginal (hf : Measurable f) : Measurable (∫⋯∫⁻_s, f ∂μ) := by
refine Measurable.lintegral_prod_right ?_
refine hf.comp ?_
rw [measurable_pi_iff]; intro i
by_cases hi : i ∈ s
· simp [hi, updateFinset]
exact measurable_pi_iff.1 measurable_snd _
· simp [hi, updateFinset]
exact measurable_pi_iff.1 measurable_fst _
@[simp] theorem lmarginal_empty (f : (∀ i, π i) → ℝ≥0∞) : ∫⋯∫⁻_∅, f ∂μ = f := by
ext1 x
simp_rw [lmarginal, Measure.pi_of_empty fun i : (∅ : Finset δ) => μ i]
apply lintegral_dirac'
exact Subsingleton.measurable
theorem lmarginal_congr {x y : ∀ i, π i} (f : (∀ i, π i) → ℝ≥0∞)
(h : ∀ i ∉ s, x i = y i) :
(∫⋯∫⁻_s, f ∂μ) x = (∫⋯∫⁻_s, f ∂μ) y := by
dsimp [lmarginal, updateFinset_def]; rcongr; exact h _ ‹_›
| Mathlib/MeasureTheory/Integral/Marginal.lean | 110 | 116 | theorem lmarginal_update_of_mem {i : δ} (hi : i ∈ s)
(f : (∀ i, π i) → ℝ≥0∞) (x : ∀ i, π i) (y : π i) :
(∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∂μ) x := by |
apply lmarginal_congr
intro j hj
have : j ≠ i := by rintro rfl; exact hj hi
apply update_noteq this
| [
" Measurable (∫⋯∫⁻_s, f ∂μ)",
" Measurable (uncurry fun x y => f (updateFinset x s y))",
" Measurable fun a => updateFinset a.1 s a.2",
" ∀ (a : δ), Measurable fun x => updateFinset x.1 s x.2 a",
" Measurable fun x => updateFinset x.1 s x.2 i",
" Measurable fun x => x.2 ⟨i, ⋯⟩",
" Measurable fun x => x.... | [
" Measurable (∫⋯∫⁻_s, f ∂μ)",
" Measurable (uncurry fun x y => f (updateFinset x s y))",
" Measurable fun a => updateFinset a.1 s a.2",
" ∀ (a : δ), Measurable fun x => updateFinset x.1 s x.2 a",
" Measurable fun x => updateFinset x.1 s x.2 i",
" Measurable fun x => x.2 ⟨i, ⋯⟩",
" Measurable fun x => x.... |
import Mathlib.LinearAlgebra.Dimension.Basic
import Mathlib.SetTheory.Cardinal.ToNat
#align_import linear_algebra.finrank from "leanprover-community/mathlib"@"347636a7a80595d55bedf6e6fbd996a3c39da69a"
universe u v w
open Cardinal Submodule Module Function
variable {R : Type u} {M : Type v} {N : Type w}
variable [Ring R] [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N]
namespace FiniteDimensional
section Ring
noncomputable def finrank (R M : Type*) [Semiring R] [AddCommGroup M] [Module R M] : ℕ :=
Cardinal.toNat (Module.rank R M)
#align finite_dimensional.finrank FiniteDimensional.finrank
theorem finrank_eq_of_rank_eq {n : ℕ} (h : Module.rank R M = ↑n) : finrank R M = n := by
apply_fun toNat at h
rw [toNat_natCast] at h
exact mod_cast h
#align finite_dimensional.finrank_eq_of_rank_eq FiniteDimensional.finrank_eq_of_rank_eq
lemma rank_eq_one_iff_finrank_eq_one : Module.rank R M = 1 ↔ finrank R M = 1 :=
Cardinal.toNat_eq_one.symm
lemma rank_eq_ofNat_iff_finrank_eq_ofNat (n : ℕ) [Nat.AtLeastTwo n] :
Module.rank R M = OfNat.ofNat n ↔ finrank R M = OfNat.ofNat n :=
Cardinal.toNat_eq_ofNat.symm
theorem finrank_le_of_rank_le {n : ℕ} (h : Module.rank R M ≤ ↑n) : finrank R M ≤ n := by
rwa [← Cardinal.toNat_le_iff_le_of_lt_aleph0, toNat_natCast] at h
· exact h.trans_lt (nat_lt_aleph0 n)
· exact nat_lt_aleph0 n
#align finite_dimensional.finrank_le_of_rank_le FiniteDimensional.finrank_le_of_rank_le
theorem finrank_lt_of_rank_lt {n : ℕ} (h : Module.rank R M < ↑n) : finrank R M < n := by
rwa [← Cardinal.toNat_lt_iff_lt_of_lt_aleph0, toNat_natCast] at h
· exact h.trans (nat_lt_aleph0 n)
· exact nat_lt_aleph0 n
#align finite_dimensional.finrank_lt_of_rank_lt FiniteDimensional.finrank_lt_of_rank_lt
theorem lt_rank_of_lt_finrank {n : ℕ} (h : n < finrank R M) : ↑n < Module.rank R M := by
rwa [← Cardinal.toNat_lt_iff_lt_of_lt_aleph0, toNat_natCast]
· exact nat_lt_aleph0 n
· contrapose! h
rw [finrank, Cardinal.toNat_apply_of_aleph0_le h]
exact n.zero_le
#align finite_dimensional.rank_lt_of_finrank_lt FiniteDimensional.lt_rank_of_lt_finrank
| Mathlib/LinearAlgebra/Dimension/Finrank.lean | 92 | 93 | theorem one_lt_rank_of_one_lt_finrank (h : 1 < finrank R M) : 1 < Module.rank R M := by |
simpa using lt_rank_of_lt_finrank h
| [
" finrank R M = n",
" finrank R M ≤ n",
" Module.rank R M < ℵ₀",
" ↑n < ℵ₀",
" finrank R M < n",
" ↑n < Module.rank R M",
" 0 ≤ n",
" 1 < Module.rank R M"
] | [
" finrank R M = n",
" finrank R M ≤ n",
" Module.rank R M < ℵ₀",
" ↑n < ℵ₀",
" finrank R M < n",
" ↑n < Module.rank R M",
" 0 ≤ n",
" 1 < Module.rank R M"
] |
import Mathlib.Algebra.Module.BigOperators
import Mathlib.Data.Fintype.BigOperators
import Mathlib.LinearAlgebra.AffineSpace.AffineMap
import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace
import Mathlib.LinearAlgebra.Finsupp
import Mathlib.Tactic.FinCases
#align_import linear_algebra.affine_space.combination from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0"
noncomputable section
open Affine
namespace Finset
theorem univ_fin2 : (univ : Finset (Fin 2)) = {0, 1} := by
ext x
fin_cases x <;> simp
#align finset.univ_fin2 Finset.univ_fin2
variable {k : Type*} {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V]
variable [S : AffineSpace V P]
variable {ι : Type*} (s : Finset ι)
variable {ι₂ : Type*} (s₂ : Finset ι₂)
def weightedVSubOfPoint (p : ι → P) (b : P) : (ι → k) →ₗ[k] V :=
∑ i ∈ s, (LinearMap.proj i : (ι → k) →ₗ[k] k).smulRight (p i -ᵥ b)
#align finset.weighted_vsub_of_point Finset.weightedVSubOfPoint
@[simp]
theorem weightedVSubOfPoint_apply (w : ι → k) (p : ι → P) (b : P) :
s.weightedVSubOfPoint p b w = ∑ i ∈ s, w i • (p i -ᵥ b) := by
simp [weightedVSubOfPoint, LinearMap.sum_apply]
#align finset.weighted_vsub_of_point_apply Finset.weightedVSubOfPoint_apply
@[simp (high)]
theorem weightedVSubOfPoint_apply_const (w : ι → k) (p : P) (b : P) :
s.weightedVSubOfPoint (fun _ => p) b w = (∑ i ∈ s, w i) • (p -ᵥ b) := by
rw [weightedVSubOfPoint_apply, sum_smul]
#align finset.weighted_vsub_of_point_apply_const Finset.weightedVSubOfPoint_apply_const
theorem weightedVSubOfPoint_congr {w₁ w₂ : ι → k} (hw : ∀ i ∈ s, w₁ i = w₂ i) {p₁ p₂ : ι → P}
(hp : ∀ i ∈ s, p₁ i = p₂ i) (b : P) :
s.weightedVSubOfPoint p₁ b w₁ = s.weightedVSubOfPoint p₂ b w₂ := by
simp_rw [weightedVSubOfPoint_apply]
refine sum_congr rfl fun i hi => ?_
rw [hw i hi, hp i hi]
#align finset.weighted_vsub_of_point_congr Finset.weightedVSubOfPoint_congr
theorem weightedVSubOfPoint_eq_of_weights_eq (p : ι → P) (j : ι) (w₁ w₂ : ι → k)
(hw : ∀ i, i ≠ j → w₁ i = w₂ i) :
s.weightedVSubOfPoint p (p j) w₁ = s.weightedVSubOfPoint p (p j) w₂ := by
simp only [Finset.weightedVSubOfPoint_apply]
congr
ext i
rcases eq_or_ne i j with h | h
· simp [h]
· simp [hw i h]
#align finset.weighted_vsub_of_point_eq_of_weights_eq Finset.weightedVSubOfPoint_eq_of_weights_eq
| Mathlib/LinearAlgebra/AffineSpace/Combination.lean | 109 | 118 | theorem weightedVSubOfPoint_eq_of_sum_eq_zero (w : ι → k) (p : ι → P) (h : ∑ i ∈ s, w i = 0)
(b₁ b₂ : P) : s.weightedVSubOfPoint p b₁ w = s.weightedVSubOfPoint p b₂ w := by |
apply eq_of_sub_eq_zero
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← sum_sub_distrib]
conv_lhs =>
congr
· skip
· ext
rw [← smul_sub, vsub_sub_vsub_cancel_left]
rw [← sum_smul, h, zero_smul]
| [
" univ = {0, 1}",
" x ∈ univ ↔ x ∈ {0, 1}",
" ⟨0, ⋯⟩ ∈ univ ↔ ⟨0, ⋯⟩ ∈ {0, 1}",
" ⟨1, ⋯⟩ ∈ univ ↔ ⟨1, ⋯⟩ ∈ {0, 1}",
" (s.weightedVSubOfPoint p b) w = ∑ i ∈ s, w i • (p i -ᵥ b)",
" (s.weightedVSubOfPoint (fun x => p) b) w = (∑ i ∈ s, w i) • (p -ᵥ b)",
" (s.weightedVSubOfPoint p₁ b) w₁ = (s.weightedVSubOf... | [
" univ = {0, 1}",
" x ∈ univ ↔ x ∈ {0, 1}",
" ⟨0, ⋯⟩ ∈ univ ↔ ⟨0, ⋯⟩ ∈ {0, 1}",
" ⟨1, ⋯⟩ ∈ univ ↔ ⟨1, ⋯⟩ ∈ {0, 1}",
" (s.weightedVSubOfPoint p b) w = ∑ i ∈ s, w i • (p i -ᵥ b)",
" (s.weightedVSubOfPoint (fun x => p) b) w = (∑ i ∈ s, w i) • (p -ᵥ b)",
" (s.weightedVSubOfPoint p₁ b) w₁ = (s.weightedVSubOf... |
import Mathlib.Algebra.Lie.Nilpotent
import Mathlib.Algebra.Lie.Normalizer
#align_import algebra.lie.engel from "leanprover-community/mathlib"@"210657c4ea4a4a7b234392f70a3a2a83346dfa90"
universe u₁ u₂ u₃ u₄
variable {R : Type u₁} {L : Type u₂} {L₂ : Type u₃} {M : Type u₄}
variable [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L₂] [LieAlgebra R L₂]
variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M]
section LieAlgebra
-- Porting note: somehow this doesn't hide `LieModule.IsNilpotent`, so `_root_.IsNilpotent` is used
-- a number of times below.
open LieModule hiding IsNilpotent
variable (R L)
def LieAlgebra.IsEngelian : Prop :=
∀ (M : Type u₄) [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M],
(∀ x : L, _root_.IsNilpotent (toEnd R L M x)) → LieModule.IsNilpotent R L M
#align lie_algebra.is_engelian LieAlgebra.IsEngelian
variable {R L}
| Mathlib/Algebra/Lie/Engel.lean | 165 | 170 | theorem LieAlgebra.isEngelian_of_subsingleton [Subsingleton L] : LieAlgebra.IsEngelian R L := by |
intro M _i1 _i2 _i3 _i4 _h
use 1
suffices (⊤ : LieIdeal R L) = ⊥ by simp [this]
haveI := (LieSubmodule.subsingleton_iff R L L).mpr inferInstance
apply Subsingleton.elim
| [
" IsEngelian R L",
" LieModule.IsNilpotent R L M",
" lowerCentralSeries R L M 1 = ⊥",
" ⊤ = ⊥"
] | [
" IsEngelian R L"
] |
import Mathlib.RingTheory.DiscreteValuationRing.Basic
import Mathlib.RingTheory.MvPowerSeries.Inverse
import Mathlib.RingTheory.PowerSeries.Basic
import Mathlib.RingTheory.PowerSeries.Order
#align_import ring_theory.power_series.basic from "leanprover-community/mathlib"@"2d5739b61641ee4e7e53eca5688a08f66f2e6a60"
noncomputable section
open Polynomial
open Finset (antidiagonal mem_antidiagonal)
namespace PowerSeries
open Finsupp (single)
variable {R : Type*}
section Ring
variable [Ring R]
protected def inv.aux : R → R⟦X⟧ → R⟦X⟧ :=
MvPowerSeries.inv.aux
#align power_series.inv.aux PowerSeries.inv.aux
| Mathlib/RingTheory/PowerSeries/Inverse.lean | 54 | 81 | theorem coeff_inv_aux (n : ℕ) (a : R) (φ : R⟦X⟧) :
coeff R n (inv.aux a φ) =
if n = 0 then a
else
-a *
∑ x ∈ antidiagonal n,
if x.2 < n then coeff R x.1 φ * coeff R x.2 (inv.aux a φ) else 0 := by |
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [coeff, inv.aux, MvPowerSeries.coeff_inv_aux]
simp only [Finsupp.single_eq_zero]
split_ifs; · rfl
congr 1
symm
apply Finset.sum_nbij' (fun (a, b) ↦ (single () a, single () b))
fun (f, g) ↦ (f (), g ())
· aesop
· aesop
· aesop
· aesop
· rintro ⟨i, j⟩ _hij
obtain H | H := le_or_lt n j
· aesop
rw [if_pos H, if_pos]
· rfl
refine ⟨?_, fun hh ↦ H.not_le ?_⟩
· rintro ⟨⟩
simpa [Finsupp.single_eq_same] using le_of_lt H
· simpa [Finsupp.single_eq_same] using hh ()
| [
" (coeff R n) (inv.aux a φ) =\n if n = 0 then a else -a * ∑ x ∈ antidiagonal n, if x.2 < n then (coeff R x.1) φ * (coeff R x.2) (inv.aux a φ) else 0",
" (if single () n = 0 then a\n else\n -a *\n ∑ x ∈ antidiagonal (single () n),\n if x.2 < single () n then\n (MvPowerSeries.c... | [
" (coeff R n) (inv.aux a φ) =\n if n = 0 then a else -a * ∑ x ∈ antidiagonal n, if x.2 < n then (coeff R x.1) φ * (coeff R x.2) (inv.aux a φ) else 0"
] |
import Mathlib.Topology.MetricSpace.Isometry
#align_import topology.metric_space.gluing from "leanprover-community/mathlib"@"e1a7bdeb4fd826b7e71d130d34988f0a2d26a177"
noncomputable section
universe u v w
open Function Set Uniformity Topology
namespace Metric
namespace Sigma
variable {ι : Type*} {E : ι → Type*} [∀ i, MetricSpace (E i)]
open scoped Classical
protected def dist : (Σ i, E i) → (Σ i, E i) → ℝ
| ⟨i, x⟩, ⟨j, y⟩ =>
if h : i = j then
haveI : E j = E i := by rw [h]
Dist.dist x (cast this y)
else Dist.dist x (Nonempty.some ⟨x⟩) + 1 + Dist.dist (Nonempty.some ⟨y⟩) y
#align metric.sigma.dist Metric.Sigma.dist
def instDist : Dist (Σi, E i) :=
⟨Sigma.dist⟩
#align metric.sigma.has_dist Metric.Sigma.instDist
attribute [local instance] Sigma.instDist
@[simp]
| Mathlib/Topology/MetricSpace/Gluing.lean | 342 | 343 | theorem dist_same (i : ι) (x y : E i) : dist (Sigma.mk i x) ⟨i, y⟩ = dist x y := by |
simp [Dist.dist, Sigma.dist]
| [
" E j = E i",
" dist ⟨i, x⟩ ⟨i, y⟩ = dist x y"
] | [
" E j = E i",
" dist ⟨i, x⟩ ⟨i, y⟩ = dist x y"
] |
import Mathlib.SetTheory.Game.Ordinal
import Mathlib.SetTheory.Ordinal.NaturalOps
#align_import set_theory.game.birthday from "leanprover-community/mathlib"@"a347076985674932c0e91da09b9961ed0a79508c"
universe u
open Ordinal
namespace SetTheory
open scoped NaturalOps PGame
namespace PGame
noncomputable def birthday : PGame.{u} → Ordinal.{u}
| ⟨_, _, xL, xR⟩ =>
max (lsub.{u, u} fun i => birthday (xL i)) (lsub.{u, u} fun i => birthday (xR i))
#align pgame.birthday SetTheory.PGame.birthday
theorem birthday_def (x : PGame) :
birthday x =
max (lsub.{u, u} fun i => birthday (x.moveLeft i))
(lsub.{u, u} fun i => birthday (x.moveRight i)) := by
cases x; rw [birthday]; rfl
#align pgame.birthday_def SetTheory.PGame.birthday_def
theorem birthday_moveLeft_lt {x : PGame} (i : x.LeftMoves) :
(x.moveLeft i).birthday < x.birthday := by
cases x; rw [birthday]; exact lt_max_of_lt_left (lt_lsub _ i)
#align pgame.birthday_move_left_lt SetTheory.PGame.birthday_moveLeft_lt
theorem birthday_moveRight_lt {x : PGame} (i : x.RightMoves) :
(x.moveRight i).birthday < x.birthday := by
cases x; rw [birthday]; exact lt_max_of_lt_right (lt_lsub _ i)
#align pgame.birthday_move_right_lt SetTheory.PGame.birthday_moveRight_lt
theorem lt_birthday_iff {x : PGame} {o : Ordinal} :
o < x.birthday ↔
(∃ i : x.LeftMoves, o ≤ (x.moveLeft i).birthday) ∨
∃ i : x.RightMoves, o ≤ (x.moveRight i).birthday := by
constructor
· rw [birthday_def]
intro h
cases' lt_max_iff.1 h with h' h'
· left
rwa [lt_lsub_iff] at h'
· right
rwa [lt_lsub_iff] at h'
· rintro (⟨i, hi⟩ | ⟨i, hi⟩)
· exact hi.trans_lt (birthday_moveLeft_lt i)
· exact hi.trans_lt (birthday_moveRight_lt i)
#align pgame.lt_birthday_iff SetTheory.PGame.lt_birthday_iff
theorem Relabelling.birthday_congr : ∀ {x y : PGame.{u}}, x ≡r y → birthday x = birthday y
| ⟨xl, xr, xL, xR⟩, ⟨yl, yr, yL, yR⟩, r => by
unfold birthday
congr 1
all_goals
apply lsub_eq_of_range_eq.{u, u, u}
ext i; constructor
all_goals rintro ⟨j, rfl⟩
· exact ⟨_, (r.moveLeft j).birthday_congr.symm⟩
· exact ⟨_, (r.moveLeftSymm j).birthday_congr⟩
· exact ⟨_, (r.moveRight j).birthday_congr.symm⟩
· exact ⟨_, (r.moveRightSymm j).birthday_congr⟩
termination_by x y => (x, y)
#align pgame.relabelling.birthday_congr SetTheory.PGame.Relabelling.birthday_congr
@[simp]
theorem birthday_eq_zero {x : PGame} :
birthday x = 0 ↔ IsEmpty x.LeftMoves ∧ IsEmpty x.RightMoves := by
rw [birthday_def, max_eq_zero, lsub_eq_zero_iff, lsub_eq_zero_iff]
#align pgame.birthday_eq_zero SetTheory.PGame.birthday_eq_zero
@[simp]
theorem birthday_zero : birthday 0 = 0 := by simp [inferInstanceAs (IsEmpty PEmpty)]
#align pgame.birthday_zero SetTheory.PGame.birthday_zero
@[simp]
theorem birthday_one : birthday 1 = 1 := by rw [birthday_def]; simp
#align pgame.birthday_one SetTheory.PGame.birthday_one
@[simp]
| Mathlib/SetTheory/Game/Birthday.lean | 111 | 111 | theorem birthday_star : birthday star = 1 := by | rw [birthday_def]; simp
| [
" x.birthday = max (lsub fun i => (x.moveLeft i).birthday) (lsub fun i => (x.moveRight i).birthday)",
" (mk α✝ β✝ a✝¹ a✝).birthday =\n max (lsub fun i => ((mk α✝ β✝ a✝¹ a✝).moveLeft i).birthday) (lsub fun i => ((mk α✝ β✝ a✝¹ a✝).moveRight i).birthday)",
" max (lsub fun i => (a✝¹ i).birthday) (lsub fun i => (... | [
" x.birthday = max (lsub fun i => (x.moveLeft i).birthday) (lsub fun i => (x.moveRight i).birthday)",
" (mk α✝ β✝ a✝¹ a✝).birthday =\n max (lsub fun i => ((mk α✝ β✝ a✝¹ a✝).moveLeft i).birthday) (lsub fun i => ((mk α✝ β✝ a✝¹ a✝).moveRight i).birthday)",
" max (lsub fun i => (a✝¹ i).birthday) (lsub fun i => (... |
import Mathlib.Data.List.Lattice
import Mathlib.Data.List.Range
import Mathlib.Data.Bool.Basic
#align_import data.list.intervals from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213"
open Nat
namespace List
def Ico (n m : ℕ) : List ℕ :=
range' n (m - n)
#align list.Ico List.Ico
namespace Ico
theorem zero_bot (n : ℕ) : Ico 0 n = range n := by rw [Ico, Nat.sub_zero, range_eq_range']
#align list.Ico.zero_bot List.Ico.zero_bot
@[simp]
theorem length (n m : ℕ) : length (Ico n m) = m - n := by
dsimp [Ico]
simp [length_range', autoParam]
#align list.Ico.length List.Ico.length
theorem pairwise_lt (n m : ℕ) : Pairwise (· < ·) (Ico n m) := by
dsimp [Ico]
simp [pairwise_lt_range', autoParam]
#align list.Ico.pairwise_lt List.Ico.pairwise_lt
theorem nodup (n m : ℕ) : Nodup (Ico n m) := by
dsimp [Ico]
simp [nodup_range', autoParam]
#align list.Ico.nodup List.Ico.nodup
@[simp]
theorem mem {n m l : ℕ} : l ∈ Ico n m ↔ n ≤ l ∧ l < m := by
suffices n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m by simp [Ico, this]
rcases le_total n m with hnm | hmn
· rw [Nat.add_sub_cancel' hnm]
· rw [Nat.sub_eq_zero_iff_le.mpr hmn, Nat.add_zero]
exact
and_congr_right fun hnl =>
Iff.intro (fun hln => (not_le_of_gt hln hnl).elim) fun hlm => lt_of_lt_of_le hlm hmn
#align list.Ico.mem List.Ico.mem
theorem eq_nil_of_le {n m : ℕ} (h : m ≤ n) : Ico n m = [] := by
simp [Ico, Nat.sub_eq_zero_iff_le.mpr h]
#align list.Ico.eq_nil_of_le List.Ico.eq_nil_of_le
theorem map_add (n m k : ℕ) : (Ico n m).map (k + ·) = Ico (n + k) (m + k) := by
rw [Ico, Ico, map_add_range', Nat.add_sub_add_right m k, Nat.add_comm n k]
#align list.Ico.map_add List.Ico.map_add
theorem map_sub (n m k : ℕ) (h₁ : k ≤ n) :
((Ico n m).map fun x => x - k) = Ico (n - k) (m - k) := by
rw [Ico, Ico, Nat.sub_sub_sub_cancel_right h₁, map_sub_range' _ _ _ h₁]
#align list.Ico.map_sub List.Ico.map_sub
@[simp]
theorem self_empty {n : ℕ} : Ico n n = [] :=
eq_nil_of_le (le_refl n)
#align list.Ico.self_empty List.Ico.self_empty
@[simp]
theorem eq_empty_iff {n m : ℕ} : Ico n m = [] ↔ m ≤ n :=
Iff.intro (fun h => Nat.sub_eq_zero_iff_le.mp <| by rw [← length, h, List.length]) eq_nil_of_le
#align list.Ico.eq_empty_iff List.Ico.eq_empty_iff
theorem append_consecutive {n m l : ℕ} (hnm : n ≤ m) (hml : m ≤ l) :
Ico n m ++ Ico m l = Ico n l := by
dsimp only [Ico]
convert range'_append n (m-n) (l-m) 1 using 2
· rw [Nat.one_mul, Nat.add_sub_cancel' hnm]
· rw [Nat.sub_add_sub_cancel hml hnm]
#align list.Ico.append_consecutive List.Ico.append_consecutive
@[simp]
theorem inter_consecutive (n m l : ℕ) : Ico n m ∩ Ico m l = [] := by
apply eq_nil_iff_forall_not_mem.2
intro a
simp only [and_imp, not_and, not_lt, List.mem_inter_iff, List.Ico.mem]
intro _ h₂ h₃
exfalso
exact not_lt_of_ge h₃ h₂
#align list.Ico.inter_consecutive List.Ico.inter_consecutive
@[simp]
theorem bagInter_consecutive (n m l : Nat) :
@List.bagInter ℕ instBEqOfDecidableEq (Ico n m) (Ico m l) = [] :=
(bagInter_nil_iff_inter_nil _ _).2 (by convert inter_consecutive n m l)
#align list.Ico.bag_inter_consecutive List.Ico.bagInter_consecutive
@[simp]
theorem succ_singleton {n : ℕ} : Ico n (n + 1) = [n] := by
dsimp [Ico]
simp [range', Nat.add_sub_cancel_left]
#align list.Ico.succ_singleton List.Ico.succ_singleton
theorem succ_top {n m : ℕ} (h : n ≤ m) : Ico n (m + 1) = Ico n m ++ [m] := by
rwa [← succ_singleton, append_consecutive]
exact Nat.le_succ _
#align list.Ico.succ_top List.Ico.succ_top
theorem eq_cons {n m : ℕ} (h : n < m) : Ico n m = n :: Ico (n + 1) m := by
rw [← append_consecutive (Nat.le_succ n) h, succ_singleton]
rfl
#align list.Ico.eq_cons List.Ico.eq_cons
@[simp]
theorem pred_singleton {m : ℕ} (h : 0 < m) : Ico (m - 1) m = [m - 1] := by
dsimp [Ico]
rw [Nat.sub_sub_self (succ_le_of_lt h)]
simp [← Nat.one_eq_succ_zero]
#align list.Ico.pred_singleton List.Ico.pred_singleton
theorem chain'_succ (n m : ℕ) : Chain' (fun a b => b = succ a) (Ico n m) := by
by_cases h : n < m
· rw [eq_cons h]
exact chain_succ_range' _ _ 1
· rw [eq_nil_of_le (le_of_not_gt h)]
trivial
#align list.Ico.chain'_succ List.Ico.chain'_succ
-- Porting note (#10618): simp can prove this
-- @[simp]
| Mathlib/Data/List/Intervals.lean | 153 | 153 | theorem not_mem_top {n m : ℕ} : m ∉ Ico n m := by | simp
| [
" Ico 0 n = range n",
" (Ico n m).length = m - n",
" (range' n (m - n)).length = m - n",
" Pairwise (fun x x_1 => x < x_1) (Ico n m)",
" Pairwise (fun x x_1 => x < x_1) (range' n (m - n))",
" (Ico n m).Nodup",
" (range' n (m - n)).Nodup",
" l ∈ Ico n m ↔ n ≤ l ∧ l < m",
" n ≤ l ∧ l < n + (m - n) ↔ n... | [
" Ico 0 n = range n",
" (Ico n m).length = m - n",
" (range' n (m - n)).length = m - n",
" Pairwise (fun x x_1 => x < x_1) (Ico n m)",
" Pairwise (fun x x_1 => x < x_1) (range' n (m - n))",
" (Ico n m).Nodup",
" (range' n (m - n)).Nodup",
" l ∈ Ico n m ↔ n ≤ l ∧ l < m",
" n ≤ l ∧ l < n + (m - n) ↔ n... |
import Mathlib.Algebra.Group.Defs
#align_import group_theory.eckmann_hilton from "leanprover-community/mathlib"@"41cf0cc2f528dd40a8f2db167ea4fb37b8fde7f3"
universe u
namespace EckmannHilton
variable {X : Type u}
local notation a " <" m:51 "> " b => m a b
structure IsUnital (m : X → X → X) (e : X) extends Std.LawfulIdentity m e : Prop
#align eckmann_hilton.is_unital EckmannHilton.IsUnital
@[to_additive EckmannHilton.AddZeroClass.IsUnital]
theorem MulOneClass.isUnital [_G : MulOneClass X] : IsUnital (· * ·) (1 : X) :=
IsUnital.mk { left_id := MulOneClass.one_mul,
right_id := MulOneClass.mul_one }
#align eckmann_hilton.mul_one_class.is_unital EckmannHilton.MulOneClass.isUnital
#align eckmann_hilton.add_zero_class.is_unital EckmannHilton.AddZeroClass.IsUnital
variable {m₁ m₂ : X → X → X} {e₁ e₂ : X}
variable (h₁ : IsUnital m₁ e₁) (h₂ : IsUnital m₂ e₂)
variable (distrib : ∀ a b c d, ((a <m₂> b) <m₁> c <m₂> d) = (a <m₁> c) <m₂> b <m₁> d)
| Mathlib/GroupTheory/EckmannHilton.lean | 56 | 57 | theorem one : e₁ = e₂ := by |
simpa only [h₁.left_id, h₁.right_id, h₂.left_id, h₂.right_id] using distrib e₂ e₁ e₁ e₂
| [
" e₁ = e₂"
] | [
" e₁ = e₂"
] |
import Mathlib.RingTheory.Adjoin.FG
#align_import ring_theory.adjoin.tower from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
open Pointwise
universe u v w u₁
variable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁)
section
open scoped Classical
theorem Algebra.fg_trans' {R S A : Type*} [CommSemiring R] [CommSemiring S] [Semiring A]
[Algebra R S] [Algebra S A] [Algebra R A] [IsScalarTower R S A] (hRS : (⊤ : Subalgebra R S).FG)
(hSA : (⊤ : Subalgebra S A).FG) : (⊤ : Subalgebra R A).FG :=
let ⟨s, hs⟩ := hRS
let ⟨t, ht⟩ := hSA
⟨s.image (algebraMap S A) ∪ t, by
rw [Finset.coe_union, Finset.coe_image, Algebra.adjoin_algebraMap_image_union_eq_adjoin_adjoin,
hs, Algebra.adjoin_top, ht, Subalgebra.restrictScalars_top, Subalgebra.restrictScalars_top]⟩
#align algebra.fg_trans' Algebra.fg_trans'
end
section ArtinTate
variable (C : Type*)
section Semiring
variable [CommSemiring A] [CommSemiring B] [Semiring C]
variable [Algebra A B] [Algebra B C] [Algebra A C] [IsScalarTower A B C]
open Finset Submodule
open scoped Classical
| Mathlib/RingTheory/Adjoin/Tower.lean | 92 | 135 | theorem exists_subalgebra_of_fg (hAC : (⊤ : Subalgebra A C).FG) (hBC : (⊤ : Submodule B C).FG) :
∃ B₀ : Subalgebra A B, B₀.FG ∧ (⊤ : Submodule B₀ C).FG := by |
cases' hAC with x hx
cases' hBC with y hy
have := hy
simp_rw [eq_top_iff', mem_span_finset] at this
choose f hf using this
let s : Finset B := Finset.image₂ f (x ∪ y * y) y
have hxy :
∀ xi ∈ x, xi ∈ span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C) :=
fun xi hxi =>
hf xi ▸
sum_mem fun yj hyj =>
smul_mem (span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C))
⟨f xi yj, Algebra.subset_adjoin <| mem_image₂_of_mem (mem_union_left _ hxi) hyj⟩
(subset_span <| mem_insert_of_mem hyj)
have hyy :
span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C) *
span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C) ≤
span (Algebra.adjoin A (↑s : Set B)) (↑(insert 1 y : Finset C) : Set C) := by
rw [span_mul_span, span_le, coe_insert]
rintro _ ⟨yi, rfl | hyi, yj, rfl | hyj, rfl⟩ <;> dsimp
· rw [mul_one]
exact subset_span (Set.mem_insert _ _)
· rw [one_mul]
exact subset_span (Set.mem_insert_of_mem _ hyj)
· rw [mul_one]
exact subset_span (Set.mem_insert_of_mem _ hyi)
· rw [← hf (yi * yj)]
exact
SetLike.mem_coe.2
(sum_mem fun yk hyk =>
smul_mem (span (Algebra.adjoin A (↑s : Set B)) (insert 1 ↑y : Set C))
⟨f (yi * yj) yk,
Algebra.subset_adjoin <|
mem_image₂_of_mem (mem_union_right _ <| mul_mem_mul hyi hyj) hyk⟩
(subset_span <| Set.mem_insert_of_mem _ hyk : yk ∈ _))
refine ⟨Algebra.adjoin A (↑s : Set B), Subalgebra.fg_adjoin_finset _, insert 1 y, ?_⟩
convert restrictScalars_injective A (Algebra.adjoin A (s : Set B)) C _
rw [restrictScalars_top, eq_top_iff, ← Algebra.top_toSubmodule, ← hx, Algebra.adjoin_eq_span,
span_le]
refine fun r hr =>
Submonoid.closure_induction hr (fun c hc => hxy c hc) (subset_span <| mem_insert_self _ _)
fun p q hp hq => hyy <| Submodule.mul_mem_mul hp hq
| [
" adjoin R ↑(Finset.image (⇑(algebraMap S A)) s ∪ t) = ⊤",
" ∃ B₀, B₀.FG ∧ ⊤.FG",
" span ↥(Algebra.adjoin A ↑s) ↑(insert 1 y) * span ↥(Algebra.adjoin A ↑s) ↑(insert 1 y) ≤\n span ↥(Algebra.adjoin A ↑s) ↑(insert 1 y)",
" insert 1 ↑y * insert 1 ↑y ⊆ ↑(span (↥(Algebra.adjoin A ↑s)) (insert 1 ↑y))",
" (fun x... | [
" adjoin R ↑(Finset.image (⇑(algebraMap S A)) s ∪ t) = ⊤",
" ∃ B₀, B₀.FG ∧ ⊤.FG"
] |
import Mathlib.Algebra.Module.BigOperators
import Mathlib.Data.Fintype.BigOperators
import Mathlib.LinearAlgebra.AffineSpace.AffineMap
import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace
import Mathlib.LinearAlgebra.Finsupp
import Mathlib.Tactic.FinCases
#align_import linear_algebra.affine_space.combination from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0"
noncomputable section
open Affine
namespace Finset
theorem univ_fin2 : (univ : Finset (Fin 2)) = {0, 1} := by
ext x
fin_cases x <;> simp
#align finset.univ_fin2 Finset.univ_fin2
variable {k : Type*} {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V]
variable [S : AffineSpace V P]
variable {ι : Type*} (s : Finset ι)
variable {ι₂ : Type*} (s₂ : Finset ι₂)
def weightedVSubOfPoint (p : ι → P) (b : P) : (ι → k) →ₗ[k] V :=
∑ i ∈ s, (LinearMap.proj i : (ι → k) →ₗ[k] k).smulRight (p i -ᵥ b)
#align finset.weighted_vsub_of_point Finset.weightedVSubOfPoint
@[simp]
theorem weightedVSubOfPoint_apply (w : ι → k) (p : ι → P) (b : P) :
s.weightedVSubOfPoint p b w = ∑ i ∈ s, w i • (p i -ᵥ b) := by
simp [weightedVSubOfPoint, LinearMap.sum_apply]
#align finset.weighted_vsub_of_point_apply Finset.weightedVSubOfPoint_apply
@[simp (high)]
theorem weightedVSubOfPoint_apply_const (w : ι → k) (p : P) (b : P) :
s.weightedVSubOfPoint (fun _ => p) b w = (∑ i ∈ s, w i) • (p -ᵥ b) := by
rw [weightedVSubOfPoint_apply, sum_smul]
#align finset.weighted_vsub_of_point_apply_const Finset.weightedVSubOfPoint_apply_const
theorem weightedVSubOfPoint_congr {w₁ w₂ : ι → k} (hw : ∀ i ∈ s, w₁ i = w₂ i) {p₁ p₂ : ι → P}
(hp : ∀ i ∈ s, p₁ i = p₂ i) (b : P) :
s.weightedVSubOfPoint p₁ b w₁ = s.weightedVSubOfPoint p₂ b w₂ := by
simp_rw [weightedVSubOfPoint_apply]
refine sum_congr rfl fun i hi => ?_
rw [hw i hi, hp i hi]
#align finset.weighted_vsub_of_point_congr Finset.weightedVSubOfPoint_congr
theorem weightedVSubOfPoint_eq_of_weights_eq (p : ι → P) (j : ι) (w₁ w₂ : ι → k)
(hw : ∀ i, i ≠ j → w₁ i = w₂ i) :
s.weightedVSubOfPoint p (p j) w₁ = s.weightedVSubOfPoint p (p j) w₂ := by
simp only [Finset.weightedVSubOfPoint_apply]
congr
ext i
rcases eq_or_ne i j with h | h
· simp [h]
· simp [hw i h]
#align finset.weighted_vsub_of_point_eq_of_weights_eq Finset.weightedVSubOfPoint_eq_of_weights_eq
theorem weightedVSubOfPoint_eq_of_sum_eq_zero (w : ι → k) (p : ι → P) (h : ∑ i ∈ s, w i = 0)
(b₁ b₂ : P) : s.weightedVSubOfPoint p b₁ w = s.weightedVSubOfPoint p b₂ w := by
apply eq_of_sub_eq_zero
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← sum_sub_distrib]
conv_lhs =>
congr
· skip
· ext
rw [← smul_sub, vsub_sub_vsub_cancel_left]
rw [← sum_smul, h, zero_smul]
#align finset.weighted_vsub_of_point_eq_of_sum_eq_zero Finset.weightedVSubOfPoint_eq_of_sum_eq_zero
theorem weightedVSubOfPoint_vadd_eq_of_sum_eq_one (w : ι → k) (p : ι → P) (h : ∑ i ∈ s, w i = 1)
(b₁ b₂ : P) : s.weightedVSubOfPoint p b₁ w +ᵥ b₁ = s.weightedVSubOfPoint p b₂ w +ᵥ b₂ := by
erw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← @vsub_eq_zero_iff_eq V,
vadd_vsub_assoc, vsub_vadd_eq_vsub_sub, ← add_sub_assoc, add_comm, add_sub_assoc, ←
sum_sub_distrib]
conv_lhs =>
congr
· skip
· congr
· skip
· ext
rw [← smul_sub, vsub_sub_vsub_cancel_left]
rw [← sum_smul, h, one_smul, vsub_add_vsub_cancel, vsub_self]
#align finset.weighted_vsub_of_point_vadd_eq_of_sum_eq_one Finset.weightedVSubOfPoint_vadd_eq_of_sum_eq_one
@[simp (high)]
theorem weightedVSubOfPoint_erase [DecidableEq ι] (w : ι → k) (p : ι → P) (i : ι) :
(s.erase i).weightedVSubOfPoint p (p i) w = s.weightedVSubOfPoint p (p i) w := by
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply]
apply sum_erase
rw [vsub_self, smul_zero]
#align finset.weighted_vsub_of_point_erase Finset.weightedVSubOfPoint_erase
@[simp (high)]
theorem weightedVSubOfPoint_insert [DecidableEq ι] (w : ι → k) (p : ι → P) (i : ι) :
(insert i s).weightedVSubOfPoint p (p i) w = s.weightedVSubOfPoint p (p i) w := by
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply]
apply sum_insert_zero
rw [vsub_self, smul_zero]
#align finset.weighted_vsub_of_point_insert Finset.weightedVSubOfPoint_insert
| Mathlib/LinearAlgebra/AffineSpace/Combination.lean | 160 | 165 | theorem weightedVSubOfPoint_indicator_subset (w : ι → k) (p : ι → P) (b : P) {s₁ s₂ : Finset ι}
(h : s₁ ⊆ s₂) :
s₁.weightedVSubOfPoint p b w = s₂.weightedVSubOfPoint p b (Set.indicator (↑s₁) w) := by |
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply]
exact Eq.symm <|
sum_indicator_subset_of_eq_zero w (fun i wi => wi • (p i -ᵥ b : V)) h fun i => zero_smul k _
| [
" univ = {0, 1}",
" x ∈ univ ↔ x ∈ {0, 1}",
" ⟨0, ⋯⟩ ∈ univ ↔ ⟨0, ⋯⟩ ∈ {0, 1}",
" ⟨1, ⋯⟩ ∈ univ ↔ ⟨1, ⋯⟩ ∈ {0, 1}",
" (s.weightedVSubOfPoint p b) w = ∑ i ∈ s, w i • (p i -ᵥ b)",
" (s.weightedVSubOfPoint (fun x => p) b) w = (∑ i ∈ s, w i) • (p -ᵥ b)",
" (s.weightedVSubOfPoint p₁ b) w₁ = (s.weightedVSubOf... | [
" univ = {0, 1}",
" x ∈ univ ↔ x ∈ {0, 1}",
" ⟨0, ⋯⟩ ∈ univ ↔ ⟨0, ⋯⟩ ∈ {0, 1}",
" ⟨1, ⋯⟩ ∈ univ ↔ ⟨1, ⋯⟩ ∈ {0, 1}",
" (s.weightedVSubOfPoint p b) w = ∑ i ∈ s, w i • (p i -ᵥ b)",
" (s.weightedVSubOfPoint (fun x => p) b) w = (∑ i ∈ s, w i) • (p -ᵥ b)",
" (s.weightedVSubOfPoint p₁ b) w₁ = (s.weightedVSubOf... |
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Degree.Lemmas
import Mathlib.Algebra.Polynomial.HasseDeriv
#align_import data.polynomial.taylor from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
noncomputable section
namespace Polynomial
open Polynomial
variable {R : Type*} [Semiring R] (r : R) (f : R[X])
def taylor (r : R) : R[X] →ₗ[R] R[X] where
toFun f := f.comp (X + C r)
map_add' f g := add_comp
map_smul' c f := by simp only [smul_eq_C_mul, C_mul_comp, RingHom.id_apply]
#align polynomial.taylor Polynomial.taylor
theorem taylor_apply : taylor r f = f.comp (X + C r) :=
rfl
#align polynomial.taylor_apply Polynomial.taylor_apply
@[simp]
theorem taylor_X : taylor r X = X + C r := by simp only [taylor_apply, X_comp]
set_option linter.uppercaseLean3 false in
#align polynomial.taylor_X Polynomial.taylor_X
@[simp]
theorem taylor_C (x : R) : taylor r (C x) = C x := by simp only [taylor_apply, C_comp]
set_option linter.uppercaseLean3 false in
#align polynomial.taylor_C Polynomial.taylor_C
@[simp]
theorem taylor_zero' : taylor (0 : R) = LinearMap.id := by
ext
simp only [taylor_apply, add_zero, comp_X, _root_.map_zero, LinearMap.id_comp,
Function.comp_apply, LinearMap.coe_comp]
#align polynomial.taylor_zero' Polynomial.taylor_zero'
theorem taylor_zero (f : R[X]) : taylor 0 f = f := by rw [taylor_zero', LinearMap.id_apply]
#align polynomial.taylor_zero Polynomial.taylor_zero
@[simp]
theorem taylor_one : taylor r (1 : R[X]) = C 1 := by rw [← C_1, taylor_C]
#align polynomial.taylor_one Polynomial.taylor_one
@[simp]
theorem taylor_monomial (i : ℕ) (k : R) : taylor r (monomial i k) = C k * (X + C r) ^ i := by
simp [taylor_apply]
#align polynomial.taylor_monomial Polynomial.taylor_monomial
theorem taylor_coeff (n : ℕ) : (taylor r f).coeff n = (hasseDeriv n f).eval r :=
show (lcoeff R n).comp (taylor r) f = (leval r).comp (hasseDeriv n) f by
congr 1; clear! f; ext i
simp only [leval_apply, mul_one, one_mul, eval_monomial, LinearMap.comp_apply, coeff_C_mul,
hasseDeriv_monomial, taylor_apply, monomial_comp, C_1, (commute_X (C r)).add_pow i,
map_sum]
simp only [lcoeff_apply, ← C_eq_natCast, mul_assoc, ← C_pow, ← C_mul, coeff_mul_C,
(Nat.cast_commute _ _).eq, coeff_X_pow, boole_mul, Finset.sum_ite_eq, Finset.mem_range]
split_ifs with h; · rfl
push_neg at h; rw [Nat.choose_eq_zero_of_lt h, Nat.cast_zero, mul_zero]
#align polynomial.taylor_coeff Polynomial.taylor_coeff
@[simp]
| Mathlib/Algebra/Polynomial/Taylor.lean | 88 | 89 | theorem taylor_coeff_zero : (taylor r f).coeff 0 = f.eval r := by |
rw [taylor_coeff, hasseDeriv_zero, LinearMap.id_apply]
| [
" { toFun := fun f => f.comp (X + C r), map_add' := ⋯ }.toFun (c • f) =\n (RingHom.id R) c • { toFun := fun f => f.comp (X + C r), map_add' := ⋯ }.toFun f",
" (taylor r) X = X + C r",
" (taylor r) (C x) = C x",
" taylor 0 = LinearMap.id",
" ((taylor 0 ∘ₗ monomial n✝¹) 1).coeff n✝ = ((LinearMap.id ∘ₗ mono... | [
" { toFun := fun f => f.comp (X + C r), map_add' := ⋯ }.toFun (c • f) =\n (RingHom.id R) c • { toFun := fun f => f.comp (X + C r), map_add' := ⋯ }.toFun f",
" (taylor r) X = X + C r",
" (taylor r) (C x) = C x",
" taylor 0 = LinearMap.id",
" ((taylor 0 ∘ₗ monomial n✝¹) 1).coeff n✝ = ((LinearMap.id ∘ₗ mono... |
import Mathlib.Data.Matrix.Basic
variable {l m n o : Type*}
universe u v w
variable {R : Type*} {α : Type v} {β : Type w}
namespace Matrix
def col (w : m → α) : Matrix m Unit α :=
of fun x _ => w x
#align matrix.col Matrix.col
-- TODO: set as an equation lemma for `col`, see mathlib4#3024
@[simp]
theorem col_apply (w : m → α) (i j) : col w i j = w i :=
rfl
#align matrix.col_apply Matrix.col_apply
def row (v : n → α) : Matrix Unit n α :=
of fun _ y => v y
#align matrix.row Matrix.row
-- TODO: set as an equation lemma for `row`, see mathlib4#3024
@[simp]
theorem row_apply (v : n → α) (i j) : row v i j = v j :=
rfl
#align matrix.row_apply Matrix.row_apply
theorem col_injective : Function.Injective (col : (m → α) → _) :=
fun _x _y h => funext fun i => congr_fun₂ h i ()
@[simp] theorem col_inj {v w : m → α} : col v = col w ↔ v = w := col_injective.eq_iff
@[simp] theorem col_zero [Zero α] : col (0 : m → α) = 0 := rfl
@[simp] theorem col_eq_zero [Zero α] (v : m → α) : col v = 0 ↔ v = 0 := col_inj
@[simp]
theorem col_add [Add α] (v w : m → α) : col (v + w) = col v + col w := by
ext
rfl
#align matrix.col_add Matrix.col_add
@[simp]
theorem col_smul [SMul R α] (x : R) (v : m → α) : col (x • v) = x • col v := by
ext
rfl
#align matrix.col_smul Matrix.col_smul
theorem row_injective : Function.Injective (row : (n → α) → _) :=
fun _x _y h => funext fun j => congr_fun₂ h () j
@[simp] theorem row_inj {v w : n → α} : row v = row w ↔ v = w := row_injective.eq_iff
@[simp] theorem row_zero [Zero α] : row (0 : n → α) = 0 := rfl
@[simp] theorem row_eq_zero [Zero α] (v : n → α) : row v = 0 ↔ v = 0 := row_inj
@[simp]
theorem row_add [Add α] (v w : m → α) : row (v + w) = row v + row w := by
ext
rfl
#align matrix.row_add Matrix.row_add
@[simp]
theorem row_smul [SMul R α] (x : R) (v : m → α) : row (x • v) = x • row v := by
ext
rfl
#align matrix.row_smul Matrix.row_smul
@[simp]
theorem transpose_col (v : m → α) : (Matrix.col v)ᵀ = Matrix.row v := by
ext
rfl
#align matrix.transpose_col Matrix.transpose_col
@[simp]
| Mathlib/Data/Matrix/RowCol.lean | 100 | 102 | theorem transpose_row (v : m → α) : (Matrix.row v)ᵀ = Matrix.col v := by |
ext
rfl
| [
" col (v + w) = col v + col w",
" col (v + w) i✝ j✝ = (col v + col w) i✝ j✝",
" col (x • v) = x • col v",
" col (x • v) i✝ j✝ = (x • col v) i✝ j✝",
" row (v + w) = row v + row w",
" row (v + w) i✝ j✝ = (row v + row w) i✝ j✝",
" row (x • v) = x • row v",
" row (x • v) i✝ j✝ = (x • row v) i✝ j✝",
" (c... | [
" col (v + w) = col v + col w",
" col (v + w) i✝ j✝ = (col v + col w) i✝ j✝",
" col (x • v) = x • col v",
" col (x • v) i✝ j✝ = (x • col v) i✝ j✝",
" row (v + w) = row v + row w",
" row (v + w) i✝ j✝ = (row v + row w) i✝ j✝",
" row (x • v) = x • row v",
" row (x • v) i✝ j✝ = (x • row v) i✝ j✝",
" (c... |
import Batteries.Data.Fin.Basic
namespace Fin
attribute [norm_cast] val_last
protected theorem le_antisymm_iff {x y : Fin n} : x = y ↔ x ≤ y ∧ y ≤ x :=
Fin.ext_iff.trans Nat.le_antisymm_iff
protected theorem le_antisymm {x y : Fin n} (h1 : x ≤ y) (h2 : y ≤ x) : x = y :=
Fin.le_antisymm_iff.2 ⟨h1, h2⟩
@[simp] theorem coe_clamp (n m : Nat) : (clamp n m : Nat) = min n m := rfl
@[simp] theorem size_enum (n) : (enum n).size = n := Array.size_ofFn ..
@[simp] theorem enum_zero : (enum 0) = #[] := by simp [enum, Array.ofFn, Array.ofFn.go]
@[simp] theorem getElem_enum (i) (h : i < (enum n).size) : (enum n)[i] = ⟨i, size_enum n ▸ h⟩ :=
Array.getElem_ofFn ..
@[simp] theorem length_list (n) : (list n).length = n := by simp [list]
@[simp] theorem get_list (i : Fin (list n).length) : (list n).get i = i.cast (length_list n) := by
cases i; simp only [list]; rw [← Array.getElem_eq_data_get, getElem_enum, cast_mk]
@[simp] theorem list_zero : list 0 = [] := by simp [list]
theorem list_succ (n) : list (n+1) = 0 :: (list n).map Fin.succ := by
apply List.ext_get; simp; intro i; cases i <;> simp
theorem list_succ_last (n) : list (n+1) = (list n).map castSucc ++ [last n] := by
rw [list_succ]
induction n with
| zero => rfl
| succ n ih =>
rw [list_succ, List.map_cons castSucc, ih]
simp [Function.comp_def, succ_castSucc]
theorem list_reverse (n) : (list n).reverse = (list n).map rev := by
induction n with
| zero => rfl
| succ n ih =>
conv => lhs; rw [list_succ_last]
conv => rhs; rw [list_succ]
simp [List.reverse_map, ih, Function.comp_def, rev_succ]
theorem foldl_loop_lt (f : α → Fin n → α) (x) (h : m < n) :
foldl.loop n f x m = foldl.loop n f (f x ⟨m, h⟩) (m+1) := by
rw [foldl.loop, dif_pos h]
theorem foldl_loop_eq (f : α → Fin n → α) (x) : foldl.loop n f x n = x := by
rw [foldl.loop, dif_neg (Nat.lt_irrefl _)]
theorem foldl_loop (f : α → Fin (n+1) → α) (x) (h : m < n+1) :
foldl.loop (n+1) f x m = foldl.loop n (fun x i => f x i.succ) (f x ⟨m, h⟩) m := by
if h' : m < n then
rw [foldl_loop_lt _ _ h, foldl_loop_lt _ _ h', foldl_loop]; rfl
else
cases Nat.le_antisymm (Nat.le_of_lt_succ h) (Nat.not_lt.1 h')
rw [foldl_loop_lt, foldl_loop_eq, foldl_loop_eq]
termination_by n - m
@[simp] theorem foldl_zero (f : α → Fin 0 → α) (x) : foldl 0 f x = x := by simp [foldl, foldl.loop]
theorem foldl_succ (f : α → Fin (n+1) → α) (x) :
foldl (n+1) f x = foldl n (fun x i => f x i.succ) (f x 0) := foldl_loop ..
theorem foldl_succ_last (f : α → Fin (n+1) → α) (x) :
foldl (n+1) f x = f (foldl n (f · ·.castSucc) x) (last n) := by
rw [foldl_succ]
induction n generalizing x with
| zero => simp [foldl_succ, Fin.last]
| succ n ih => rw [foldl_succ, ih (f · ·.succ), foldl_succ]; simp [succ_castSucc]
theorem foldl_eq_foldl_list (f : α → Fin n → α) (x) : foldl n f x = (list n).foldl f x := by
induction n generalizing x with
| zero => rw [foldl_zero, list_zero, List.foldl_nil]
| succ n ih => rw [foldl_succ, ih, list_succ, List.foldl_cons, List.foldl_map]
unseal foldr.loop in
theorem foldr_loop_zero (f : Fin n → α → α) (x) : foldr.loop n f ⟨0, Nat.zero_le _⟩ x = x :=
rfl
unseal foldr.loop in
theorem foldr_loop_succ (f : Fin n → α → α) (x) (h : m < n) :
foldr.loop n f ⟨m+1, h⟩ x = foldr.loop n f ⟨m, Nat.le_of_lt h⟩ (f ⟨m, h⟩ x) :=
rfl
| .lake/packages/batteries/Batteries/Data/Fin/Lemmas.lean | 103 | 108 | theorem foldr_loop (f : Fin (n+1) → α → α) (x) (h : m+1 ≤ n+1) :
foldr.loop (n+1) f ⟨m+1, h⟩ x =
f 0 (foldr.loop n (fun i => f i.succ) ⟨m, Nat.le_of_succ_le_succ h⟩ x) := by |
induction m generalizing x with
| zero => simp [foldr_loop_zero, foldr_loop_succ]
| succ m ih => rw [foldr_loop_succ, ih, foldr_loop_succ, Fin.succ]
| [
" enum 0 = #[]",
" (list n).length = n",
" (list n).get i = cast ⋯ i",
" (list n).get ⟨val✝, isLt✝⟩ = cast ⋯ ⟨val✝, isLt✝⟩",
" (enum n).data.get ⟨val✝, isLt✝⟩ = cast ⋯ ⟨val✝, isLt✝⟩",
" list 0 = []",
" list (n + 1) = 0 :: List.map succ (list n)",
" ∀ (n_1 : Nat) (h₁ : n_1 < (list (n + 1)).length) (h₂ ... | [
" enum 0 = #[]",
" (list n).length = n",
" (list n).get i = cast ⋯ i",
" (list n).get ⟨val✝, isLt✝⟩ = cast ⋯ ⟨val✝, isLt✝⟩",
" (enum n).data.get ⟨val✝, isLt✝⟩ = cast ⋯ ⟨val✝, isLt✝⟩",
" list 0 = []",
" list (n + 1) = 0 :: List.map succ (list n)",
" ∀ (n_1 : Nat) (h₁ : n_1 < (list (n + 1)).length) (h₂ ... |
import Mathlib.Topology.MetricSpace.HausdorffDistance
#align_import topology.metric_space.pi_nat from "leanprover-community/mathlib"@"49b7f94aab3a3bdca1f9f34c5d818afb253b3993"
noncomputable section
open scoped Classical
open Topology Filter
open TopologicalSpace Set Metric Filter Function
attribute [local simp] pow_le_pow_iff_right one_lt_two inv_le_inv zero_le_two zero_lt_two
variable {E : ℕ → Type*}
namespace PiNat
irreducible_def firstDiff (x y : ∀ n, E n) : ℕ :=
if h : x ≠ y then Nat.find (ne_iff.1 h) else 0
#align pi_nat.first_diff PiNat.firstDiff
theorem apply_firstDiff_ne {x y : ∀ n, E n} (h : x ≠ y) :
x (firstDiff x y) ≠ y (firstDiff x y) := by
rw [firstDiff_def, dif_pos h]
exact Nat.find_spec (ne_iff.1 h)
#align pi_nat.apply_first_diff_ne PiNat.apply_firstDiff_ne
theorem apply_eq_of_lt_firstDiff {x y : ∀ n, E n} {n : ℕ} (hn : n < firstDiff x y) : x n = y n := by
rw [firstDiff_def] at hn
split_ifs at hn with h
· convert Nat.find_min (ne_iff.1 h) hn
simp
· exact (not_lt_zero' hn).elim
#align pi_nat.apply_eq_of_lt_first_diff PiNat.apply_eq_of_lt_firstDiff
theorem firstDiff_comm (x y : ∀ n, E n) : firstDiff x y = firstDiff y x := by
simp only [firstDiff_def, ne_comm]
#align pi_nat.first_diff_comm PiNat.firstDiff_comm
theorem min_firstDiff_le (x y z : ∀ n, E n) (h : x ≠ z) :
min (firstDiff x y) (firstDiff y z) ≤ firstDiff x z := by
by_contra! H
rw [lt_min_iff] at H
refine apply_firstDiff_ne h ?_
calc
x (firstDiff x z) = y (firstDiff x z) := apply_eq_of_lt_firstDiff H.1
_ = z (firstDiff x z) := apply_eq_of_lt_firstDiff H.2
#align pi_nat.min_first_diff_le PiNat.min_firstDiff_le
def cylinder (x : ∀ n, E n) (n : ℕ) : Set (∀ n, E n) :=
{ y | ∀ i, i < n → y i = x i }
#align pi_nat.cylinder PiNat.cylinder
theorem cylinder_eq_pi (x : ∀ n, E n) (n : ℕ) :
cylinder x n = Set.pi (Finset.range n : Set ℕ) fun i : ℕ => {x i} := by
ext y
simp [cylinder]
#align pi_nat.cylinder_eq_pi PiNat.cylinder_eq_pi
@[simp]
theorem cylinder_zero (x : ∀ n, E n) : cylinder x 0 = univ := by simp [cylinder_eq_pi]
#align pi_nat.cylinder_zero PiNat.cylinder_zero
theorem cylinder_anti (x : ∀ n, E n) {m n : ℕ} (h : m ≤ n) : cylinder x n ⊆ cylinder x m :=
fun _y hy i hi => hy i (hi.trans_le h)
#align pi_nat.cylinder_anti PiNat.cylinder_anti
@[simp]
theorem mem_cylinder_iff {x y : ∀ n, E n} {n : ℕ} : y ∈ cylinder x n ↔ ∀ i < n, y i = x i :=
Iff.rfl
#align pi_nat.mem_cylinder_iff PiNat.mem_cylinder_iff
| Mathlib/Topology/MetricSpace/PiNat.lean | 131 | 131 | theorem self_mem_cylinder (x : ∀ n, E n) (n : ℕ) : x ∈ cylinder x n := by | simp
| [
" x (firstDiff x y) ≠ y (firstDiff x y)",
" x (Nat.find ⋯) ≠ y (Nat.find ⋯)",
" x n = y n",
" x n = y n ↔ ¬x n ≠ y n",
" firstDiff x y = firstDiff y x",
" min (firstDiff x y) (firstDiff y z) ≤ firstDiff x z",
" False",
" x (firstDiff x z) = z (firstDiff x z)",
" cylinder x n = (↑(Finset.range n)).pi... | [
" x (firstDiff x y) ≠ y (firstDiff x y)",
" x (Nat.find ⋯) ≠ y (Nat.find ⋯)",
" x n = y n",
" x n = y n ↔ ¬x n ≠ y n",
" firstDiff x y = firstDiff y x",
" min (firstDiff x y) (firstDiff y z) ≤ firstDiff x z",
" False",
" x (firstDiff x z) = z (firstDiff x z)",
" cylinder x n = (↑(Finset.range n)).pi... |
import Mathlib.Combinatorics.SimpleGraph.Basic
namespace SimpleGraph
variable {V : Type*} (G : SimpleGraph V)
structure Dart extends V × V where
adj : G.Adj fst snd
deriving DecidableEq
#align simple_graph.dart SimpleGraph.Dart
initialize_simps_projections Dart (+toProd, -fst, -snd)
attribute [simp] Dart.adj
variable {G}
theorem Dart.ext_iff (d₁ d₂ : G.Dart) : d₁ = d₂ ↔ d₁.toProd = d₂.toProd := by
cases d₁; cases d₂; simp
#align simple_graph.dart.ext_iff SimpleGraph.Dart.ext_iff
@[ext]
theorem Dart.ext (d₁ d₂ : G.Dart) (h : d₁.toProd = d₂.toProd) : d₁ = d₂ :=
(Dart.ext_iff d₁ d₂).mpr h
#align simple_graph.dart.ext SimpleGraph.Dart.ext
-- Porting note: deleted `Dart.fst` and `Dart.snd` since they are now invalid declaration names,
-- even though there is not actually a `SimpleGraph.Dart.fst` or `SimpleGraph.Dart.snd`.
theorem Dart.toProd_injective : Function.Injective (Dart.toProd : G.Dart → V × V) :=
Dart.ext
#align simple_graph.dart.to_prod_injective SimpleGraph.Dart.toProd_injective
instance Dart.fintype [Fintype V] [DecidableRel G.Adj] : Fintype G.Dart :=
Fintype.ofEquiv (Σ v, G.neighborSet v)
{ toFun := fun s => ⟨(s.fst, s.snd), s.snd.property⟩
invFun := fun d => ⟨d.fst, d.snd, d.adj⟩
left_inv := fun s => by ext <;> simp
right_inv := fun d => by ext <;> simp }
#align simple_graph.dart.fintype SimpleGraph.Dart.fintype
def Dart.edge (d : G.Dart) : Sym2 V :=
Sym2.mk d.toProd
#align simple_graph.dart.edge SimpleGraph.Dart.edge
@[simp]
theorem Dart.edge_mk {p : V × V} (h : G.Adj p.1 p.2) : (Dart.mk p h).edge = Sym2.mk p :=
rfl
#align simple_graph.dart.edge_mk SimpleGraph.Dart.edge_mk
@[simp]
theorem Dart.edge_mem (d : G.Dart) : d.edge ∈ G.edgeSet :=
d.adj
#align simple_graph.dart.edge_mem SimpleGraph.Dart.edge_mem
@[simps]
def Dart.symm (d : G.Dart) : G.Dart :=
⟨d.toProd.swap, G.symm d.adj⟩
#align simple_graph.dart.symm SimpleGraph.Dart.symm
@[simp]
theorem Dart.symm_mk {p : V × V} (h : G.Adj p.1 p.2) : (Dart.mk p h).symm = Dart.mk p.swap h.symm :=
rfl
#align simple_graph.dart.symm_mk SimpleGraph.Dart.symm_mk
@[simp]
theorem Dart.edge_symm (d : G.Dart) : d.symm.edge = d.edge :=
Sym2.mk_prod_swap_eq
#align simple_graph.dart.edge_symm SimpleGraph.Dart.edge_symm
@[simp]
theorem Dart.edge_comp_symm : Dart.edge ∘ Dart.symm = (Dart.edge : G.Dart → Sym2 V) :=
funext Dart.edge_symm
#align simple_graph.dart.edge_comp_symm SimpleGraph.Dart.edge_comp_symm
@[simp]
theorem Dart.symm_symm (d : G.Dart) : d.symm.symm = d :=
Dart.ext _ _ <| Prod.swap_swap _
#align simple_graph.dart.symm_symm SimpleGraph.Dart.symm_symm
@[simp]
theorem Dart.symm_involutive : Function.Involutive (Dart.symm : G.Dart → G.Dart) :=
Dart.symm_symm
#align simple_graph.dart.symm_involutive SimpleGraph.Dart.symm_involutive
theorem Dart.symm_ne (d : G.Dart) : d.symm ≠ d :=
ne_of_apply_ne (Prod.snd ∘ Dart.toProd) d.adj.ne
#align simple_graph.dart.symm_ne SimpleGraph.Dart.symm_ne
| Mathlib/Combinatorics/SimpleGraph/Dart.lean | 107 | 109 | theorem dart_edge_eq_iff : ∀ d₁ d₂ : G.Dart, d₁.edge = d₂.edge ↔ d₁ = d₂ ∨ d₁ = d₂.symm := by |
rintro ⟨p, hp⟩ ⟨q, hq⟩
simp
| [
" d₁ = d₂ ↔ d₁.toProd = d₂.toProd",
" { toProd := toProd✝, adj := adj✝ } = d₂ ↔ { toProd := toProd✝, adj := adj✝ }.toProd = d₂.toProd",
" { toProd := toProd✝¹, adj := adj✝¹ } = { toProd := toProd✝, adj := adj✝ } ↔\n { toProd := toProd✝¹, adj := adj✝¹ }.toProd = { toProd := toProd✝, adj := adj✝ }.toProd",
"... | [
" d₁ = d₂ ↔ d₁.toProd = d₂.toProd",
" { toProd := toProd✝, adj := adj✝ } = d₂ ↔ { toProd := toProd✝, adj := adj✝ }.toProd = d₂.toProd",
" { toProd := toProd✝¹, adj := adj✝¹ } = { toProd := toProd✝, adj := adj✝ } ↔\n { toProd := toProd✝¹, adj := adj✝¹ }.toProd = { toProd := toProd✝, adj := adj✝ }.toProd",
"... |
import Mathlib.Combinatorics.SimpleGraph.Subgraph
import Mathlib.Data.List.Rotate
#align_import combinatorics.simple_graph.connectivity from "leanprover-community/mathlib"@"b99e2d58a5e6861833fa8de11e51a81144258db4"
open Function
universe u v w
namespace SimpleGraph
variable {V : Type u} {V' : Type v} {V'' : Type w}
variable (G : SimpleGraph V) (G' : SimpleGraph V') (G'' : SimpleGraph V'')
inductive Walk : V → V → Type u
| nil {u : V} : Walk u u
| cons {u v w : V} (h : G.Adj u v) (p : Walk v w) : Walk u w
deriving DecidableEq
#align simple_graph.walk SimpleGraph.Walk
attribute [refl] Walk.nil
@[simps]
instance Walk.instInhabited (v : V) : Inhabited (G.Walk v v) := ⟨Walk.nil⟩
#align simple_graph.walk.inhabited SimpleGraph.Walk.instInhabited
@[match_pattern, reducible]
def Adj.toWalk {G : SimpleGraph V} {u v : V} (h : G.Adj u v) : G.Walk u v :=
Walk.cons h Walk.nil
#align simple_graph.adj.to_walk SimpleGraph.Adj.toWalk
namespace Walk
variable {G}
@[match_pattern]
abbrev nil' (u : V) : G.Walk u u := Walk.nil
#align simple_graph.walk.nil' SimpleGraph.Walk.nil'
@[match_pattern]
abbrev cons' (u v w : V) (h : G.Adj u v) (p : G.Walk v w) : G.Walk u w := Walk.cons h p
#align simple_graph.walk.cons' SimpleGraph.Walk.cons'
protected def copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') : G.Walk u' v' :=
hu ▸ hv ▸ p
#align simple_graph.walk.copy SimpleGraph.Walk.copy
@[simp]
theorem copy_rfl_rfl {u v} (p : G.Walk u v) : p.copy rfl rfl = p := rfl
#align simple_graph.walk.copy_rfl_rfl SimpleGraph.Walk.copy_rfl_rfl
@[simp]
theorem copy_copy {u v u' v' u'' v''} (p : G.Walk u v)
(hu : u = u') (hv : v = v') (hu' : u' = u'') (hv' : v' = v'') :
(p.copy hu hv).copy hu' hv' = p.copy (hu.trans hu') (hv.trans hv') := by
subst_vars
rfl
#align simple_graph.walk.copy_copy SimpleGraph.Walk.copy_copy
@[simp]
theorem copy_nil {u u'} (hu : u = u') : (Walk.nil : G.Walk u u).copy hu hu = Walk.nil := by
subst_vars
rfl
#align simple_graph.walk.copy_nil SimpleGraph.Walk.copy_nil
theorem copy_cons {u v w u' w'} (h : G.Adj u v) (p : G.Walk v w) (hu : u = u') (hw : w = w') :
(Walk.cons h p).copy hu hw = Walk.cons (hu ▸ h) (p.copy rfl hw) := by
subst_vars
rfl
#align simple_graph.walk.copy_cons SimpleGraph.Walk.copy_cons
@[simp]
theorem cons_copy {u v w v' w'} (h : G.Adj u v) (p : G.Walk v' w') (hv : v' = v) (hw : w' = w) :
Walk.cons h (p.copy hv hw) = (Walk.cons (hv ▸ h) p).copy rfl hw := by
subst_vars
rfl
#align simple_graph.walk.cons_copy SimpleGraph.Walk.cons_copy
theorem exists_eq_cons_of_ne {u v : V} (hne : u ≠ v) :
∀ (p : G.Walk u v), ∃ (w : V) (h : G.Adj u w) (p' : G.Walk w v), p = cons h p'
| nil => (hne rfl).elim
| cons h p' => ⟨_, h, p', rfl⟩
#align simple_graph.walk.exists_eq_cons_of_ne SimpleGraph.Walk.exists_eq_cons_of_ne
def length {u v : V} : G.Walk u v → ℕ
| nil => 0
| cons _ q => q.length.succ
#align simple_graph.walk.length SimpleGraph.Walk.length
@[trans]
def append {u v w : V} : G.Walk u v → G.Walk v w → G.Walk u w
| nil, q => q
| cons h p, q => cons h (p.append q)
#align simple_graph.walk.append SimpleGraph.Walk.append
def concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) : G.Walk u w := p.append (cons h nil)
#align simple_graph.walk.concat SimpleGraph.Walk.concat
theorem concat_eq_append {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
p.concat h = p.append (cons h nil) := rfl
#align simple_graph.walk.concat_eq_append SimpleGraph.Walk.concat_eq_append
protected def reverseAux {u v w : V} : G.Walk u v → G.Walk u w → G.Walk v w
| nil, q => q
| cons h p, q => Walk.reverseAux p (cons (G.symm h) q)
#align simple_graph.walk.reverse_aux SimpleGraph.Walk.reverseAux
@[symm]
def reverse {u v : V} (w : G.Walk u v) : G.Walk v u := w.reverseAux nil
#align simple_graph.walk.reverse SimpleGraph.Walk.reverse
def getVert {u v : V} : G.Walk u v → ℕ → V
| nil, _ => u
| cons _ _, 0 => u
| cons _ q, n + 1 => q.getVert n
#align simple_graph.walk.get_vert SimpleGraph.Walk.getVert
@[simp]
| Mathlib/Combinatorics/SimpleGraph/Connectivity.lean | 208 | 208 | theorem getVert_zero {u v} (w : G.Walk u v) : w.getVert 0 = u := by | cases w <;> rfl
| [
" (p.copy hu hv).copy hu' hv' = p.copy ⋯ ⋯",
" (p.copy ⋯ ⋯).copy ⋯ ⋯ = p.copy ⋯ ⋯",
" nil.copy hu hu = nil",
" nil.copy ⋯ ⋯ = nil",
" (cons h p).copy hu hw = cons ⋯ (p.copy ⋯ hw)",
" (cons h p).copy ⋯ ⋯ = cons ⋯ (p.copy ⋯ ⋯)",
" cons h (p.copy hv hw) = (cons ⋯ p).copy ⋯ hw",
" cons h (p.copy ⋯ ⋯) = (c... | [
" (p.copy hu hv).copy hu' hv' = p.copy ⋯ ⋯",
" (p.copy ⋯ ⋯).copy ⋯ ⋯ = p.copy ⋯ ⋯",
" nil.copy hu hu = nil",
" nil.copy ⋯ ⋯ = nil",
" (cons h p).copy hu hw = cons ⋯ (p.copy ⋯ hw)",
" (cons h p).copy ⋯ ⋯ = cons ⋯ (p.copy ⋯ ⋯)",
" cons h (p.copy hv hw) = (cons ⋯ p).copy ⋯ hw",
" cons h (p.copy ⋯ ⋯) = (c... |
import Mathlib.Algebra.BigOperators.Fin
import Mathlib.Data.Nat.Choose.Sum
import Mathlib.Data.Nat.Factorial.BigOperators
import Mathlib.Data.Fin.VecNotation
import Mathlib.Data.Finset.Sym
import Mathlib.Data.Finsupp.Multiset
#align_import data.nat.choose.multinomial from "leanprover-community/mathlib"@"2738d2ca56cbc63be80c3bd48e9ed90ad94e947d"
open Finset
open scoped Nat
namespace Nat
variable {α : Type*} (s : Finset α) (f : α → ℕ) {a b : α} (n : ℕ)
def multinomial : ℕ :=
(∑ i ∈ s, f i)! / ∏ i ∈ s, (f i)!
#align nat.multinomial Nat.multinomial
theorem multinomial_pos : 0 < multinomial s f :=
Nat.div_pos (le_of_dvd (factorial_pos _) (prod_factorial_dvd_factorial_sum s f))
(prod_factorial_pos s f)
#align nat.multinomial_pos Nat.multinomial_pos
theorem multinomial_spec : (∏ i ∈ s, (f i)!) * multinomial s f = (∑ i ∈ s, f i)! :=
Nat.mul_div_cancel' (prod_factorial_dvd_factorial_sum s f)
#align nat.multinomial_spec Nat.multinomial_spec
@[simp] lemma multinomial_empty : multinomial ∅ f = 1 := by simp [multinomial]
#align nat.multinomial_nil Nat.multinomial_empty
@[deprecated (since := "2024-06-01")] alias multinomial_nil := multinomial_empty
variable {s f}
lemma multinomial_cons (ha : a ∉ s) (f : α → ℕ) :
multinomial (s.cons a ha) f = (f a + ∑ i ∈ s, f i).choose (f a) * multinomial s f := by
rw [multinomial, Nat.div_eq_iff_eq_mul_left _ (prod_factorial_dvd_factorial_sum _ _), prod_cons,
multinomial, mul_assoc, mul_left_comm _ (f a)!,
Nat.div_mul_cancel (prod_factorial_dvd_factorial_sum _ _), ← mul_assoc, Nat.choose_symm_add,
Nat.add_choose_mul_factorial_mul_factorial, Finset.sum_cons]
positivity
lemma multinomial_insert [DecidableEq α] (ha : a ∉ s) (f : α → ℕ) :
multinomial (insert a s) f = (f a + ∑ i ∈ s, f i).choose (f a) * multinomial s f := by
rw [← cons_eq_insert _ _ ha, multinomial_cons]
#align nat.multinomial_insert Nat.multinomial_insert
@[simp] lemma multinomial_singleton (a : α) (f : α → ℕ) : multinomial {a} f = 1 := by
rw [← cons_empty, multinomial_cons]; simp
#align nat.multinomial_singleton Nat.multinomial_singleton
@[simp]
theorem multinomial_insert_one [DecidableEq α] (h : a ∉ s) (h₁ : f a = 1) :
multinomial (insert a s) f = (s.sum f).succ * multinomial s f := by
simp only [multinomial, one_mul, factorial]
rw [Finset.sum_insert h, Finset.prod_insert h, h₁, add_comm, ← succ_eq_add_one, factorial_succ]
simp only [factorial_one, one_mul, Function.comp_apply, factorial, mul_one, ← one_eq_succ_zero]
rw [Nat.mul_div_assoc _ (prod_factorial_dvd_factorial_sum _ _)]
#align nat.multinomial_insert_one Nat.multinomial_insert_one
theorem multinomial_congr {f g : α → ℕ} (h : ∀ a ∈ s, f a = g a) :
multinomial s f = multinomial s g := by
simp only [multinomial]; congr 1
· rw [Finset.sum_congr rfl h]
· exact Finset.prod_congr rfl fun a ha => by rw [h a ha]
#align nat.multinomial_congr Nat.multinomial_congr
theorem binomial_eq [DecidableEq α] (h : a ≠ b) :
multinomial {a, b} f = (f a + f b)! / ((f a)! * (f b)!) := by
simp [multinomial, Finset.sum_pair h, Finset.prod_pair h]
#align nat.binomial_eq Nat.binomial_eq
theorem binomial_eq_choose [DecidableEq α] (h : a ≠ b) :
multinomial {a, b} f = (f a + f b).choose (f a) := by
simp [binomial_eq h, choose_eq_factorial_div_factorial (Nat.le_add_right _ _)]
#align nat.binomial_eq_choose Nat.binomial_eq_choose
theorem binomial_spec [DecidableEq α] (hab : a ≠ b) :
(f a)! * (f b)! * multinomial {a, b} f = (f a + f b)! := by
simpa [Finset.sum_pair hab, Finset.prod_pair hab] using multinomial_spec {a, b} f
#align nat.binomial_spec Nat.binomial_spec
@[simp]
theorem binomial_one [DecidableEq α] (h : a ≠ b) (h₁ : f a = 1) :
multinomial {a, b} f = (f b).succ := by
simp [multinomial_insert_one (Finset.not_mem_singleton.mpr h) h₁]
#align nat.binomial_one Nat.binomial_one
theorem binomial_succ_succ [DecidableEq α] (h : a ≠ b) :
multinomial {a, b} (Function.update (Function.update f a (f a).succ) b (f b).succ) =
multinomial {a, b} (Function.update f a (f a).succ) +
multinomial {a, b} (Function.update f b (f b).succ) := by
simp only [binomial_eq_choose, Function.update_apply,
h, Ne, ite_true, ite_false, not_false_eq_true]
rw [if_neg h.symm]
rw [add_succ, choose_succ_succ, succ_add_eq_add_succ]
ring
#align nat.binomial_succ_succ Nat.binomial_succ_succ
| Mathlib/Data/Nat/Choose/Multinomial.lean | 134 | 139 | theorem succ_mul_binomial [DecidableEq α] (h : a ≠ b) :
(f a + f b).succ * multinomial {a, b} f =
(f a).succ * multinomial {a, b} (Function.update f a (f a).succ) := by |
rw [binomial_eq_choose h, binomial_eq_choose h, mul_comm (f a).succ, Function.update_same,
Function.update_noteq (ne_comm.mp h)]
rw [succ_mul_choose_eq (f a + f b) (f a), succ_add (f a) (f b)]
| [
" multinomial ∅ f = 1",
" multinomial (cons a s ha) f = (f a + ∑ i ∈ s, f i).choose (f a) * multinomial s f",
" 0 < ∏ i ∈ cons a s ha, (f i)!",
" multinomial (insert a s) f = (f a + ∑ i ∈ s, f i).choose (f a) * multinomial s f",
" multinomial {a} f = 1",
" (f a + ∑ i ∈ ∅, f i).choose (f a) * multinomial ∅... | [
" multinomial ∅ f = 1",
" multinomial (cons a s ha) f = (f a + ∑ i ∈ s, f i).choose (f a) * multinomial s f",
" 0 < ∏ i ∈ cons a s ha, (f i)!",
" multinomial (insert a s) f = (f a + ∑ i ∈ s, f i).choose (f a) * multinomial s f",
" multinomial {a} f = 1",
" (f a + ∑ i ∈ ∅, f i).choose (f a) * multinomial ∅... |
import Mathlib.Algebra.Group.Support
import Mathlib.Algebra.Order.Monoid.WithTop
import Mathlib.Data.Nat.Cast.Field
#align_import algebra.char_zero.lemmas from "leanprover-community/mathlib"@"acee671f47b8e7972a1eb6f4eed74b4b3abce829"
open Function Set
section AddMonoidWithOne
variable {α M : Type*} [AddMonoidWithOne M] [CharZero M] {n : ℕ}
instance CharZero.NeZero.two : NeZero (2 : M) :=
⟨by
have : ((2 : ℕ) : M) ≠ 0 := Nat.cast_ne_zero.2 (by decide)
rwa [Nat.cast_two] at this⟩
#align char_zero.ne_zero.two CharZero.NeZero.two
section
variable {R : Type*} [NonAssocSemiring R] [NoZeroDivisors R] [CharZero R] {a : R}
@[simp]
theorem add_self_eq_zero {a : R} : a + a = 0 ↔ a = 0 := by
simp only [(two_mul a).symm, mul_eq_zero, two_ne_zero, false_or_iff]
#align add_self_eq_zero add_self_eq_zero
set_option linter.deprecated false
@[simp]
theorem bit0_eq_zero {a : R} : bit0 a = 0 ↔ a = 0 :=
add_self_eq_zero
#align bit0_eq_zero bit0_eq_zero
@[simp]
theorem zero_eq_bit0 {a : R} : 0 = bit0 a ↔ a = 0 := by
rw [eq_comm]
exact bit0_eq_zero
#align zero_eq_bit0 zero_eq_bit0
theorem bit0_ne_zero : bit0 a ≠ 0 ↔ a ≠ 0 :=
bit0_eq_zero.not
#align bit0_ne_zero bit0_ne_zero
theorem zero_ne_bit0 : 0 ≠ bit0 a ↔ a ≠ 0 :=
zero_eq_bit0.not
#align zero_ne_bit0 zero_ne_bit0
end
section
variable {R : Type*} [NonAssocRing R] [NoZeroDivisors R] [CharZero R]
@[simp] theorem neg_eq_self_iff {a : R} : -a = a ↔ a = 0 :=
neg_eq_iff_add_eq_zero.trans add_self_eq_zero
#align neg_eq_self_iff neg_eq_self_iff
@[simp] theorem eq_neg_self_iff {a : R} : a = -a ↔ a = 0 :=
eq_neg_iff_add_eq_zero.trans add_self_eq_zero
#align eq_neg_self_iff eq_neg_self_iff
| Mathlib/Algebra/CharZero/Lemmas.lean | 127 | 129 | theorem nat_mul_inj {n : ℕ} {a b : R} (h : (n : R) * a = (n : R) * b) : n = 0 ∨ a = b := by |
rw [← sub_eq_zero, ← mul_sub, mul_eq_zero, sub_eq_zero] at h
exact mod_cast h
| [
" 2 ≠ 0",
" a + a = 0 ↔ a = 0",
" 0 = bit0 a ↔ a = 0",
" bit0 a = 0 ↔ a = 0",
" n = 0 ∨ a = b"
] | [
" 2 ≠ 0",
" a + a = 0 ↔ a = 0",
" 0 = bit0 a ↔ a = 0",
" bit0 a = 0 ↔ a = 0",
" n = 0 ∨ a = b"
] |
import Mathlib.Algebra.Lie.Submodule
#align_import algebra.lie.ideal_operations from "leanprover-community/mathlib"@"8983bec7cdf6cb2dd1f21315c8a34ab00d7b2f6d"
universe u v w w₁ w₂
namespace LieSubmodule
variable {R : Type u} {L : Type v} {M : Type w} {M₂ : Type w₁}
variable [CommRing R] [LieRing L] [LieAlgebra R L]
variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M]
variable [AddCommGroup M₂] [Module R M₂] [LieRingModule L M₂] [LieModule R L M₂]
variable (N N' : LieSubmodule R L M) (I J : LieIdeal R L) (N₂ : LieSubmodule R L M₂)
section LieIdealOperations
instance hasBracket : Bracket (LieIdeal R L) (LieSubmodule R L M) :=
⟨fun I N => lieSpan R L { m | ∃ (x : I) (n : N), ⁅(x : L), (n : M)⁆ = m }⟩
#align lie_submodule.has_bracket LieSubmodule.hasBracket
theorem lieIdeal_oper_eq_span :
⁅I, N⁆ = lieSpan R L { m | ∃ (x : I) (n : N), ⁅(x : L), (n : M)⁆ = m } :=
rfl
#align lie_submodule.lie_ideal_oper_eq_span LieSubmodule.lieIdeal_oper_eq_span
| Mathlib/Algebra/Lie/IdealOperations.lean | 62 | 81 | theorem lieIdeal_oper_eq_linear_span :
(↑⁅I, N⁆ : Submodule R M) =
Submodule.span R { m | ∃ (x : I) (n : N), ⁅(x : L), (n : M)⁆ = m } := by |
apply le_antisymm
· let s := { m : M | ∃ (x : ↥I) (n : ↥N), ⁅(x : L), (n : M)⁆ = m }
have aux : ∀ (y : L), ∀ m' ∈ Submodule.span R s, ⁅y, m'⁆ ∈ Submodule.span R s := by
intro y m' hm'
refine Submodule.span_induction (R := R) (M := M) (s := s)
(p := fun m' ↦ ⁅y, m'⁆ ∈ Submodule.span R s) hm' ?_ ?_ ?_ ?_
· rintro m'' ⟨x, n, hm''⟩; rw [← hm'', leibniz_lie]
refine Submodule.add_mem _ ?_ ?_ <;> apply Submodule.subset_span
· use ⟨⁅y, ↑x⁆, I.lie_mem x.property⟩, n
· use x, ⟨⁅y, ↑n⁆, N.lie_mem n.property⟩
· simp only [lie_zero, Submodule.zero_mem]
· intro m₁ m₂ hm₁ hm₂; rw [lie_add]; exact Submodule.add_mem _ hm₁ hm₂
· intro t m'' hm''; rw [lie_smul]; exact Submodule.smul_mem _ t hm''
change _ ≤ ({ Submodule.span R s with lie_mem := fun hm' => aux _ _ hm' } : LieSubmodule R L M)
rw [lieIdeal_oper_eq_span, lieSpan_le]
exact Submodule.subset_span
· rw [lieIdeal_oper_eq_span]; apply submodule_span_le_lieSpan
| [
" ↑⁅I, N⁆ = Submodule.span R {m | ∃ x n, ⁅↑x, ↑n⁆ = m}",
" ↑⁅I, N⁆ ≤ Submodule.span R {m | ∃ x n, ⁅↑x, ↑n⁆ = m}",
" ∀ (y : L), ∀ m' ∈ Submodule.span R s, ⁅y, m'⁆ ∈ Submodule.span R s",
" ⁅y, m'⁆ ∈ Submodule.span R s",
" ∀ x ∈ s, (fun m' => ⁅y, m'⁆ ∈ Submodule.span R s) x",
" ⁅y, m''⁆ ∈ Submodule.span R s"... | [
" ↑⁅I, N⁆ = Submodule.span R {m | ∃ x n, ⁅↑x, ↑n⁆ = m}"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.