Context stringlengths 57 85k | file_name stringlengths 21 79 | start int64 14 2.42k | end int64 18 2.43k | theorem stringlengths 25 2.71k | proof stringlengths 5 10.6k |
|---|---|---|---|---|---|
import Mathlib.Data.Nat.Defs
import Mathlib.Order.Interval.Set.Basic
import Mathlib.Tactic.Monotonicity.Attr
#align_import data.nat.log from "leanprover-community/mathlib"@"3e00d81bdcbf77c8188bbd18f5524ddc3ed8cac6"
namespace Nat
--@[pp_nodot] porting note: unknown attribute
def log (b : ℕ) : ℕ → ℕ
| n => if h : b ≤ n ∧ 1 < b then log b (n / b) + 1 else 0
decreasing_by
-- putting this in the def triggers the `unusedHavesSuffices` linter:
-- https://github.com/leanprover-community/batteries/issues/428
have : n / b < n := div_lt_self ((Nat.zero_lt_one.trans h.2).trans_le h.1) h.2
decreasing_trivial
#align nat.log Nat.log
@[simp]
theorem log_eq_zero_iff {b n : ℕ} : log b n = 0 ↔ n < b ∨ b ≤ 1 := by
rw [log, dite_eq_right_iff]
simp only [Nat.add_eq_zero_iff, Nat.one_ne_zero, and_false, imp_false, not_and_or, not_le, not_lt]
#align nat.log_eq_zero_iff Nat.log_eq_zero_iff
theorem log_of_lt {b n : ℕ} (hb : n < b) : log b n = 0 :=
log_eq_zero_iff.2 (Or.inl hb)
#align nat.log_of_lt Nat.log_of_lt
theorem log_of_left_le_one {b : ℕ} (hb : b ≤ 1) (n) : log b n = 0 :=
log_eq_zero_iff.2 (Or.inr hb)
#align nat.log_of_left_le_one Nat.log_of_left_le_one
@[simp]
theorem log_pos_iff {b n : ℕ} : 0 < log b n ↔ b ≤ n ∧ 1 < b := by
rw [Nat.pos_iff_ne_zero, Ne, log_eq_zero_iff, not_or, not_lt, not_le]
#align nat.log_pos_iff Nat.log_pos_iff
theorem log_pos {b n : ℕ} (hb : 1 < b) (hbn : b ≤ n) : 0 < log b n :=
log_pos_iff.2 ⟨hbn, hb⟩
#align nat.log_pos Nat.log_pos
theorem log_of_one_lt_of_le {b n : ℕ} (h : 1 < b) (hn : b ≤ n) : log b n = log b (n / b) + 1 := by
rw [log]
exact if_pos ⟨hn, h⟩
#align nat.log_of_one_lt_of_le Nat.log_of_one_lt_of_le
@[simp] lemma log_zero_left : ∀ n, log 0 n = 0 := log_of_left_le_one $ Nat.zero_le _
#align nat.log_zero_left Nat.log_zero_left
@[simp]
theorem log_zero_right (b : ℕ) : log b 0 = 0 :=
log_eq_zero_iff.2 (le_total 1 b)
#align nat.log_zero_right Nat.log_zero_right
@[simp]
theorem log_one_left : ∀ n, log 1 n = 0 :=
log_of_left_le_one le_rfl
#align nat.log_one_left Nat.log_one_left
@[simp]
theorem log_one_right (b : ℕ) : log b 1 = 0 :=
log_eq_zero_iff.2 (lt_or_le _ _)
#align nat.log_one_right Nat.log_one_right
theorem pow_le_iff_le_log {b : ℕ} (hb : 1 < b) {x y : ℕ} (hy : y ≠ 0) :
b ^ x ≤ y ↔ x ≤ log b y := by
induction' y using Nat.strong_induction_on with y ih generalizing x
cases x with
| zero => dsimp; omega
| succ x =>
rw [log]; split_ifs with h
· have b_pos : 0 < b := lt_of_succ_lt hb
rw [Nat.add_le_add_iff_right, ← ih (y / b) (div_lt_self
(Nat.pos_iff_ne_zero.2 hy) hb) (Nat.div_pos h.1 b_pos).ne', le_div_iff_mul_le b_pos,
pow_succ', Nat.mul_comm]
· exact iff_of_false (fun hby => h ⟨(le_self_pow x.succ_ne_zero _).trans hby, hb⟩)
(not_succ_le_zero _)
#align nat.pow_le_iff_le_log Nat.pow_le_iff_le_log
theorem lt_pow_iff_log_lt {b : ℕ} (hb : 1 < b) {x y : ℕ} (hy : y ≠ 0) : y < b ^ x ↔ log b y < x :=
lt_iff_lt_of_le_iff_le (pow_le_iff_le_log hb hy)
#align nat.lt_pow_iff_log_lt Nat.lt_pow_iff_log_lt
theorem pow_le_of_le_log {b x y : ℕ} (hy : y ≠ 0) (h : x ≤ log b y) : b ^ x ≤ y := by
refine (le_or_lt b 1).elim (fun hb => ?_) fun hb => (pow_le_iff_le_log hb hy).2 h
rw [log_of_left_le_one hb, Nat.le_zero] at h
rwa [h, Nat.pow_zero, one_le_iff_ne_zero]
#align nat.pow_le_of_le_log Nat.pow_le_of_le_log
theorem le_log_of_pow_le {b x y : ℕ} (hb : 1 < b) (h : b ^ x ≤ y) : x ≤ log b y := by
rcases ne_or_eq y 0 with (hy | rfl)
exacts [(pow_le_iff_le_log hb hy).1 h, (h.not_lt (Nat.pow_pos (Nat.zero_lt_one.trans hb))).elim]
#align nat.le_log_of_pow_le Nat.le_log_of_pow_le
theorem pow_log_le_self (b : ℕ) {x : ℕ} (hx : x ≠ 0) : b ^ log b x ≤ x :=
pow_le_of_le_log hx le_rfl
#align nat.pow_log_le_self Nat.pow_log_le_self
theorem log_lt_of_lt_pow {b x y : ℕ} (hy : y ≠ 0) : y < b ^ x → log b y < x :=
lt_imp_lt_of_le_imp_le (pow_le_of_le_log hy)
#align nat.log_lt_of_lt_pow Nat.log_lt_of_lt_pow
theorem lt_pow_of_log_lt {b x y : ℕ} (hb : 1 < b) : log b y < x → y < b ^ x :=
lt_imp_lt_of_le_imp_le (le_log_of_pow_le hb)
#align nat.lt_pow_of_log_lt Nat.lt_pow_of_log_lt
theorem lt_pow_succ_log_self {b : ℕ} (hb : 1 < b) (x : ℕ) : x < b ^ (log b x).succ :=
lt_pow_of_log_lt hb (lt_succ_self _)
#align nat.lt_pow_succ_log_self Nat.lt_pow_succ_log_self
theorem log_eq_iff {b m n : ℕ} (h : m ≠ 0 ∨ 1 < b ∧ n ≠ 0) :
log b n = m ↔ b ^ m ≤ n ∧ n < b ^ (m + 1) := by
rcases em (1 < b ∧ n ≠ 0) with (⟨hb, hn⟩ | hbn)
· rw [le_antisymm_iff, ← Nat.lt_succ_iff, ← pow_le_iff_le_log, ← lt_pow_iff_log_lt, and_comm] <;>
assumption
have hm : m ≠ 0 := h.resolve_right hbn
rw [not_and_or, not_lt, Ne, not_not] at hbn
rcases hbn with (hb | rfl)
· obtain rfl | rfl := le_one_iff_eq_zero_or_eq_one.1 hb
any_goals
simp only [ne_eq, zero_eq, reduceSucc, lt_self_iff_false, not_lt_zero, false_and, or_false]
at h
simp [h, eq_comm (a := 0), Nat.zero_pow (Nat.pos_iff_ne_zero.2 _)] <;> omega
· simp [@eq_comm _ 0, hm]
#align nat.log_eq_iff Nat.log_eq_iff
theorem log_eq_of_pow_le_of_lt_pow {b m n : ℕ} (h₁ : b ^ m ≤ n) (h₂ : n < b ^ (m + 1)) :
log b n = m := by
rcases eq_or_ne m 0 with (rfl | hm)
· rw [Nat.pow_one] at h₂
exact log_of_lt h₂
· exact (log_eq_iff (Or.inl hm)).2 ⟨h₁, h₂⟩
#align nat.log_eq_of_pow_le_of_lt_pow Nat.log_eq_of_pow_le_of_lt_pow
theorem log_pow {b : ℕ} (hb : 1 < b) (x : ℕ) : log b (b ^ x) = x :=
log_eq_of_pow_le_of_lt_pow le_rfl (Nat.pow_lt_pow_right hb x.lt_succ_self)
#align nat.log_pow Nat.log_pow
theorem log_eq_one_iff' {b n : ℕ} : log b n = 1 ↔ b ≤ n ∧ n < b * b := by
rw [log_eq_iff (Or.inl Nat.one_ne_zero), Nat.pow_add, Nat.pow_one]
#align nat.log_eq_one_iff' Nat.log_eq_one_iff'
theorem log_eq_one_iff {b n : ℕ} : log b n = 1 ↔ n < b * b ∧ 1 < b ∧ b ≤ n :=
log_eq_one_iff'.trans
⟨fun h => ⟨h.2, lt_mul_self_iff.1 (h.1.trans_lt h.2), h.1⟩, fun h => ⟨h.2.2, h.1⟩⟩
#align nat.log_eq_one_iff Nat.log_eq_one_iff
theorem log_mul_base {b n : ℕ} (hb : 1 < b) (hn : n ≠ 0) : log b (n * b) = log b n + 1 := by
apply log_eq_of_pow_le_of_lt_pow <;> rw [pow_succ', Nat.mul_comm b]
exacts [Nat.mul_le_mul_right _ (pow_log_le_self _ hn),
(Nat.mul_lt_mul_right (Nat.zero_lt_one.trans hb)).2 (lt_pow_succ_log_self hb _)]
#align nat.log_mul_base Nat.log_mul_base
theorem pow_log_le_add_one (b : ℕ) : ∀ x, b ^ log b x ≤ x + 1
| 0 => by rw [log_zero_right, Nat.pow_zero]
| x + 1 => (pow_log_le_self b x.succ_ne_zero).trans (x + 1).le_succ
#align nat.pow_log_le_add_one Nat.pow_log_le_add_one
theorem log_monotone {b : ℕ} : Monotone (log b) := by
refine monotone_nat_of_le_succ fun n => ?_
rcases le_or_lt b 1 with hb | hb
· rw [log_of_left_le_one hb]
exact zero_le _
· exact le_log_of_pow_le hb (pow_log_le_add_one _ _)
#align nat.log_monotone Nat.log_monotone
@[mono]
theorem log_mono_right {b n m : ℕ} (h : n ≤ m) : log b n ≤ log b m :=
log_monotone h
#align nat.log_mono_right Nat.log_mono_right
@[mono]
theorem log_anti_left {b c n : ℕ} (hc : 1 < c) (hb : c ≤ b) : log b n ≤ log c n := by
rcases eq_or_ne n 0 with (rfl | hn); · rw [log_zero_right, log_zero_right]
apply le_log_of_pow_le hc
calc
c ^ log b n ≤ b ^ log b n := Nat.pow_le_pow_left hb _
_ ≤ n := pow_log_le_self _ hn
#align nat.log_anti_left Nat.log_anti_left
theorem log_antitone_left {n : ℕ} : AntitoneOn (fun b => log b n) (Set.Ioi 1) := fun _ hc _ _ hb =>
log_anti_left (Set.mem_Iio.1 hc) hb
#align nat.log_antitone_left Nat.log_antitone_left
@[simp]
theorem log_div_base (b n : ℕ) : log b (n / b) = log b n - 1 := by
rcases le_or_lt b 1 with hb | hb
· rw [log_of_left_le_one hb, log_of_left_le_one hb, Nat.zero_sub]
cases' lt_or_le n b with h h
· rw [div_eq_of_lt h, log_of_lt h, log_zero_right]
rw [log_of_one_lt_of_le hb h, Nat.add_sub_cancel_right]
#align nat.log_div_base Nat.log_div_base
@[simp]
theorem log_div_mul_self (b n : ℕ) : log b (n / b * b) = log b n := by
rcases le_or_lt b 1 with hb | hb
· rw [log_of_left_le_one hb, log_of_left_le_one hb]
cases' lt_or_le n b with h h
· rw [div_eq_of_lt h, Nat.zero_mul, log_zero_right, log_of_lt h]
rw [log_mul_base hb (Nat.div_pos h (by omega)).ne', log_div_base,
Nat.sub_add_cancel (succ_le_iff.2 <| log_pos hb h)]
#align nat.log_div_mul_self Nat.log_div_mul_self
theorem add_pred_div_lt {b n : ℕ} (hb : 1 < b) (hn : 2 ≤ n) : (n + b - 1) / b < n := by
rw [div_lt_iff_lt_mul (by omega), ← succ_le_iff, ← pred_eq_sub_one,
succ_pred_eq_of_pos (by omega)]
exact Nat.add_le_mul hn hb
-- Porting note: Was private in mathlib 3
-- #align nat.add_pred_div_lt Nat.add_pred_div_lt
--@[pp_nodot]
def clog (b : ℕ) : ℕ → ℕ
| n => if h : 1 < b ∧ 1 < n then clog b ((n + b - 1) / b) + 1 else 0
decreasing_by
-- putting this in the def triggers the `unusedHavesSuffices` linter:
-- https://github.com/leanprover-community/batteries/issues/428
have : (n + b - 1) / b < n := add_pred_div_lt h.1 h.2
decreasing_trivial
#align nat.clog Nat.clog
theorem clog_of_left_le_one {b : ℕ} (hb : b ≤ 1) (n : ℕ) : clog b n = 0 := by
rw [clog, dif_neg fun h : 1 < b ∧ 1 < n => h.1.not_le hb]
#align nat.clog_of_left_le_one Nat.clog_of_left_le_one
theorem clog_of_right_le_one {n : ℕ} (hn : n ≤ 1) (b : ℕ) : clog b n = 0 := by
rw [clog, dif_neg fun h : 1 < b ∧ 1 < n => h.2.not_le hn]
#align nat.clog_of_right_le_one Nat.clog_of_right_le_one
@[simp] lemma clog_zero_left (n : ℕ) : clog 0 n = 0 := clog_of_left_le_one (Nat.zero_le _) _
#align nat.clog_zero_left Nat.clog_zero_left
@[simp] lemma clog_zero_right (b : ℕ) : clog b 0 = 0 := clog_of_right_le_one (Nat.zero_le _) _
#align nat.clog_zero_right Nat.clog_zero_right
@[simp]
theorem clog_one_left (n : ℕ) : clog 1 n = 0 :=
clog_of_left_le_one le_rfl _
#align nat.clog_one_left Nat.clog_one_left
@[simp]
theorem clog_one_right (b : ℕ) : clog b 1 = 0 :=
clog_of_right_le_one le_rfl _
#align nat.clog_one_right Nat.clog_one_right
theorem clog_of_two_le {b n : ℕ} (hb : 1 < b) (hn : 2 ≤ n) :
clog b n = clog b ((n + b - 1) / b) + 1 := by rw [clog, dif_pos (⟨hb, hn⟩ : 1 < b ∧ 1 < n)]
#align nat.clog_of_two_le Nat.clog_of_two_le
theorem clog_pos {b n : ℕ} (hb : 1 < b) (hn : 2 ≤ n) : 0 < clog b n := by
rw [clog_of_two_le hb hn]
exact zero_lt_succ _
#align nat.clog_pos Nat.clog_pos
theorem clog_eq_one {b n : ℕ} (hn : 2 ≤ n) (h : n ≤ b) : clog b n = 1 := by
rw [clog_of_two_le (hn.trans h) hn, clog_of_right_le_one]
rw [← Nat.lt_succ_iff, Nat.div_lt_iff_lt_mul] <;> omega
#align nat.clog_eq_one Nat.clog_eq_one
theorem le_pow_iff_clog_le {b : ℕ} (hb : 1 < b) {x y : ℕ} : x ≤ b ^ y ↔ clog b x ≤ y := by
induction' x using Nat.strong_induction_on with x ih generalizing y
cases y
· rw [Nat.pow_zero]
refine ⟨fun h => (clog_of_right_le_one h b).le, ?_⟩
simp_rw [← not_lt]
contrapose!
exact clog_pos hb
have b_pos : 0 < b := zero_lt_of_lt hb
rw [clog]; split_ifs with h
· rw [Nat.add_le_add_iff_right, ← ih ((x + b - 1) / b) (add_pred_div_lt hb h.2),
Nat.div_le_iff_le_mul_add_pred b_pos, Nat.mul_comm b, ← Nat.pow_succ,
Nat.add_sub_assoc (Nat.succ_le_of_lt b_pos), Nat.add_le_add_iff_right]
· exact iff_of_true ((not_lt.1 (not_and.1 h hb)).trans <| succ_le_of_lt <| Nat.pow_pos b_pos)
(zero_le _)
#align nat.le_pow_iff_clog_le Nat.le_pow_iff_clog_le
theorem pow_lt_iff_lt_clog {b : ℕ} (hb : 1 < b) {x y : ℕ} : b ^ y < x ↔ y < clog b x :=
lt_iff_lt_of_le_iff_le (le_pow_iff_clog_le hb)
#align nat.pow_lt_iff_lt_clog Nat.pow_lt_iff_lt_clog
theorem clog_pow (b x : ℕ) (hb : 1 < b) : clog b (b ^ x) = x :=
eq_of_forall_ge_iff fun z ↦ by rw [← le_pow_iff_clog_le hb, Nat.pow_le_pow_iff_right hb]
#align nat.clog_pow Nat.clog_pow
theorem pow_pred_clog_lt_self {b : ℕ} (hb : 1 < b) {x : ℕ} (hx : 1 < x) :
b ^ (clog b x).pred < x := by
rw [← not_le, le_pow_iff_clog_le hb, not_le]
exact pred_lt (clog_pos hb hx).ne'
#align nat.pow_pred_clog_lt_self Nat.pow_pred_clog_lt_self
theorem le_pow_clog {b : ℕ} (hb : 1 < b) (x : ℕ) : x ≤ b ^ clog b x :=
(le_pow_iff_clog_le hb).2 le_rfl
#align nat.le_pow_clog Nat.le_pow_clog
@[mono]
theorem clog_mono_right (b : ℕ) {n m : ℕ} (h : n ≤ m) : clog b n ≤ clog b m := by
rcases le_or_lt b 1 with hb | hb
· rw [clog_of_left_le_one hb]
exact zero_le _
· rw [← le_pow_iff_clog_le hb]
exact h.trans (le_pow_clog hb _)
#align nat.clog_mono_right Nat.clog_mono_right
@[mono]
| Mathlib/Data/Nat/Log.lean | 335 | 339 | theorem clog_anti_left {b c n : ℕ} (hc : 1 < c) (hb : c ≤ b) : clog b n ≤ clog c n := by |
rw [← le_pow_iff_clog_le (lt_of_lt_of_le hc hb)]
calc
n ≤ c ^ clog c n := le_pow_clog hc _
_ ≤ b ^ clog c n := Nat.pow_le_pow_left hb _
|
import Mathlib.Order.ConditionallyCompleteLattice.Finset
import Mathlib.Order.Interval.Finset.Nat
#align_import data.nat.lattice from "leanprover-community/mathlib"@"52fa514ec337dd970d71d8de8d0fd68b455a1e54"
assert_not_exists MonoidWithZero
open Set
namespace Nat
open scoped Classical
noncomputable instance : InfSet ℕ :=
⟨fun s ↦ if h : ∃ n, n ∈ s then @Nat.find (fun n ↦ n ∈ s) _ h else 0⟩
noncomputable instance : SupSet ℕ :=
⟨fun s ↦ if h : ∃ n, ∀ a ∈ s, a ≤ n then @Nat.find (fun n ↦ ∀ a ∈ s, a ≤ n) _ h else 0⟩
theorem sInf_def {s : Set ℕ} (h : s.Nonempty) : sInf s = @Nat.find (fun n ↦ n ∈ s) _ h :=
dif_pos _
#align nat.Inf_def Nat.sInf_def
theorem sSup_def {s : Set ℕ} (h : ∃ n, ∀ a ∈ s, a ≤ n) :
sSup s = @Nat.find (fun n ↦ ∀ a ∈ s, a ≤ n) _ h :=
dif_pos _
#align nat.Sup_def Nat.sSup_def
theorem _root_.Set.Infinite.Nat.sSup_eq_zero {s : Set ℕ} (h : s.Infinite) : sSup s = 0 :=
dif_neg fun ⟨n, hn⟩ ↦
let ⟨k, hks, hk⟩ := h.exists_gt n
(hn k hks).not_lt hk
#align set.infinite.nat.Sup_eq_zero Set.Infinite.Nat.sSup_eq_zero
@[simp]
theorem sInf_eq_zero {s : Set ℕ} : sInf s = 0 ↔ 0 ∈ s ∨ s = ∅ := by
cases eq_empty_or_nonempty s with
| inl h => subst h
simp only [or_true_iff, eq_self_iff_true, iff_true_iff, iInf, InfSet.sInf,
mem_empty_iff_false, exists_false, dif_neg, not_false_iff]
| inr h => simp only [h.ne_empty, or_false_iff, Nat.sInf_def, h, Nat.find_eq_zero]
#align nat.Inf_eq_zero Nat.sInf_eq_zero
@[simp]
theorem sInf_empty : sInf ∅ = 0 := by
rw [sInf_eq_zero]
right
rfl
#align nat.Inf_empty Nat.sInf_empty
@[simp]
theorem iInf_of_empty {ι : Sort*} [IsEmpty ι] (f : ι → ℕ) : iInf f = 0 := by
rw [iInf_of_isEmpty, sInf_empty]
#align nat.infi_of_empty Nat.iInf_of_empty
@[simp]
lemma iInf_const_zero {ι : Sort*} : ⨅ i : ι, 0 = 0 :=
(isEmpty_or_nonempty ι).elim (fun h ↦ by simp) fun h ↦ sInf_eq_zero.2 <| by simp
theorem sInf_mem {s : Set ℕ} (h : s.Nonempty) : sInf s ∈ s := by
rw [Nat.sInf_def h]
exact Nat.find_spec h
#align nat.Inf_mem Nat.sInf_mem
theorem not_mem_of_lt_sInf {s : Set ℕ} {m : ℕ} (hm : m < sInf s) : m ∉ s := by
cases eq_empty_or_nonempty s with
| inl h => subst h; apply not_mem_empty
| inr h => rw [Nat.sInf_def h] at hm; exact Nat.find_min h hm
#align nat.not_mem_of_lt_Inf Nat.not_mem_of_lt_sInf
protected theorem sInf_le {s : Set ℕ} {m : ℕ} (hm : m ∈ s) : sInf s ≤ m := by
rw [Nat.sInf_def ⟨m, hm⟩]
exact Nat.find_min' ⟨m, hm⟩ hm
#align nat.Inf_le Nat.sInf_le
theorem nonempty_of_pos_sInf {s : Set ℕ} (h : 0 < sInf s) : s.Nonempty := by
by_contra contra
rw [Set.not_nonempty_iff_eq_empty] at contra
have h' : sInf s ≠ 0 := ne_of_gt h
apply h'
rw [Nat.sInf_eq_zero]
right
assumption
#align nat.nonempty_of_pos_Inf Nat.nonempty_of_pos_sInf
theorem nonempty_of_sInf_eq_succ {s : Set ℕ} {k : ℕ} (h : sInf s = k + 1) : s.Nonempty :=
nonempty_of_pos_sInf (h.symm ▸ succ_pos k : sInf s > 0)
#align nat.nonempty_of_Inf_eq_succ Nat.nonempty_of_sInf_eq_succ
theorem eq_Ici_of_nonempty_of_upward_closed {s : Set ℕ} (hs : s.Nonempty)
(hs' : ∀ k₁ k₂ : ℕ, k₁ ≤ k₂ → k₁ ∈ s → k₂ ∈ s) : s = Ici (sInf s) :=
ext fun n ↦ ⟨fun H ↦ Nat.sInf_le H, fun H ↦ hs' (sInf s) n H (sInf_mem hs)⟩
#align nat.eq_Ici_of_nonempty_of_upward_closed Nat.eq_Ici_of_nonempty_of_upward_closed
| Mathlib/Data/Nat/Lattice.lean | 110 | 120 | theorem sInf_upward_closed_eq_succ_iff {s : Set ℕ} (hs : ∀ k₁ k₂ : ℕ, k₁ ≤ k₂ → k₁ ∈ s → k₂ ∈ s)
(k : ℕ) : sInf s = k + 1 ↔ k + 1 ∈ s ∧ k ∉ s := by |
constructor
· intro H
rw [eq_Ici_of_nonempty_of_upward_closed (nonempty_of_sInf_eq_succ _) hs, H, mem_Ici, mem_Ici]
· exact ⟨le_rfl, k.not_succ_le_self⟩;
· exact k
· assumption
· rintro ⟨H, H'⟩
rw [sInf_def (⟨_, H⟩ : s.Nonempty), find_eq_iff]
exact ⟨H, fun n hnk hns ↦ H' <| hs n k (Nat.lt_succ_iff.mp hnk) hns⟩
|
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
import Mathlib.Data.NNRat.Defs
variable {ι α : Type*}
namespace NNRat
@[norm_cast]
theorem coe_list_sum (l : List ℚ≥0) : (l.sum : ℚ) = (l.map (↑)).sum :=
map_list_sum coeHom _
#align nnrat.coe_list_sum NNRat.coe_list_sum
@[norm_cast]
theorem coe_list_prod (l : List ℚ≥0) : (l.prod : ℚ) = (l.map (↑)).prod :=
map_list_prod coeHom _
#align nnrat.coe_list_prod NNRat.coe_list_prod
@[norm_cast]
theorem coe_multiset_sum (s : Multiset ℚ≥0) : (s.sum : ℚ) = (s.map (↑)).sum :=
map_multiset_sum coeHom _
#align nnrat.coe_multiset_sum NNRat.coe_multiset_sum
@[norm_cast]
theorem coe_multiset_prod (s : Multiset ℚ≥0) : (s.prod : ℚ) = (s.map (↑)).prod :=
map_multiset_prod coeHom _
#align nnrat.coe_multiset_prod NNRat.coe_multiset_prod
@[norm_cast]
theorem coe_sum {s : Finset α} {f : α → ℚ≥0} : ↑(∑ a ∈ s, f a) = ∑ a ∈ s, (f a : ℚ) :=
map_sum coeHom _ _
#align nnrat.coe_sum NNRat.coe_sum
theorem toNNRat_sum_of_nonneg {s : Finset α} {f : α → ℚ} (hf : ∀ a, a ∈ s → 0 ≤ f a) :
(∑ a ∈ s, f a).toNNRat = ∑ a ∈ s, (f a).toNNRat := by
rw [← coe_inj, coe_sum, Rat.coe_toNNRat _ (Finset.sum_nonneg hf)]
exact Finset.sum_congr rfl fun x hxs ↦ by rw [Rat.coe_toNNRat _ (hf x hxs)]
#align nnrat.to_nnrat_sum_of_nonneg NNRat.toNNRat_sum_of_nonneg
@[norm_cast]
theorem coe_prod {s : Finset α} {f : α → ℚ≥0} : ↑(∏ a ∈ s, f a) = ∏ a ∈ s, (f a : ℚ) :=
map_prod coeHom _ _
#align nnrat.coe_prod NNRat.coe_prod
| Mathlib/Data/NNRat/BigOperators.lean | 52 | 55 | theorem toNNRat_prod_of_nonneg {s : Finset α} {f : α → ℚ} (hf : ∀ a ∈ s, 0 ≤ f a) :
(∏ a ∈ s, f a).toNNRat = ∏ a ∈ s, (f a).toNNRat := by |
rw [← coe_inj, coe_prod, Rat.coe_toNNRat _ (Finset.prod_nonneg hf)]
exact Finset.prod_congr rfl fun x hxs ↦ by rw [Rat.coe_toNNRat _ (hf x hxs)]
|
import Mathlib.Data.ENNReal.Real
import Mathlib.Order.Interval.Finset.Nat
import Mathlib.Topology.UniformSpace.Pi
import Mathlib.Topology.UniformSpace.UniformConvergence
import Mathlib.Topology.UniformSpace.UniformEmbedding
#align_import topology.metric_space.emetric_space from "leanprover-community/mathlib"@"c8f305514e0d47dfaa710f5a52f0d21b588e6328"
open Set Filter Classical
open scoped Uniformity Topology Filter NNReal ENNReal Pointwise
universe u v w
variable {α : Type u} {β : Type v} {X : Type*}
theorem uniformity_dist_of_mem_uniformity [LinearOrder β] {U : Filter (α × α)} (z : β)
(D : α → α → β) (H : ∀ s, s ∈ U ↔ ∃ ε > z, ∀ {a b : α}, D a b < ε → (a, b) ∈ s) :
U = ⨅ ε > z, 𝓟 { p : α × α | D p.1 p.2 < ε } :=
HasBasis.eq_biInf ⟨fun s => by simp only [H, subset_def, Prod.forall, mem_setOf]⟩
#align uniformity_dist_of_mem_uniformity uniformity_dist_of_mem_uniformity
@[ext]
class EDist (α : Type*) where
edist : α → α → ℝ≥0∞
#align has_edist EDist
export EDist (edist)
def uniformSpaceOfEDist (edist : α → α → ℝ≥0∞) (edist_self : ∀ x : α, edist x x = 0)
(edist_comm : ∀ x y : α, edist x y = edist y x)
(edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z) : UniformSpace α :=
.ofFun edist edist_self edist_comm edist_triangle fun ε ε0 =>
⟨ε / 2, ENNReal.half_pos ε0.ne', fun _ h₁ _ h₂ =>
(ENNReal.add_lt_add h₁ h₂).trans_eq (ENNReal.add_halves _)⟩
#align uniform_space_of_edist uniformSpaceOfEDist
-- the uniform structure is embedded in the emetric space structure
-- to avoid instance diamond issues. See Note [forgetful inheritance].
class PseudoEMetricSpace (α : Type u) extends EDist α : Type u where
edist_self : ∀ x : α, edist x x = 0
edist_comm : ∀ x y : α, edist x y = edist y x
edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z
toUniformSpace : UniformSpace α := uniformSpaceOfEDist edist edist_self edist_comm edist_triangle
uniformity_edist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | edist p.1 p.2 < ε } := by rfl
#align pseudo_emetric_space PseudoEMetricSpace
attribute [instance] PseudoEMetricSpace.toUniformSpace
@[ext]
protected theorem PseudoEMetricSpace.ext {α : Type*} {m m' : PseudoEMetricSpace α}
(h : m.toEDist = m'.toEDist) : m = m' := by
cases' m with ed _ _ _ U hU
cases' m' with ed' _ _ _ U' hU'
congr 1
exact UniformSpace.ext (((show ed = ed' from h) ▸ hU).trans hU'.symm)
variable [PseudoEMetricSpace α]
export PseudoEMetricSpace (edist_self edist_comm edist_triangle)
attribute [simp] edist_self
theorem edist_triangle_left (x y z : α) : edist x y ≤ edist z x + edist z y := by
rw [edist_comm z]; apply edist_triangle
#align edist_triangle_left edist_triangle_left
theorem edist_triangle_right (x y z : α) : edist x y ≤ edist x z + edist y z := by
rw [edist_comm y]; apply edist_triangle
#align edist_triangle_right edist_triangle_right
theorem edist_congr_right {x y z : α} (h : edist x y = 0) : edist x z = edist y z := by
apply le_antisymm
· rw [← zero_add (edist y z), ← h]
apply edist_triangle
· rw [edist_comm] at h
rw [← zero_add (edist x z), ← h]
apply edist_triangle
#align edist_congr_right edist_congr_right
theorem edist_congr_left {x y z : α} (h : edist x y = 0) : edist z x = edist z y := by
rw [edist_comm z x, edist_comm z y]
apply edist_congr_right h
#align edist_congr_left edist_congr_left
-- new theorem
theorem edist_congr {w x y z : α} (hl : edist w x = 0) (hr : edist y z = 0) :
edist w y = edist x z :=
(edist_congr_right hl).trans (edist_congr_left hr)
theorem edist_triangle4 (x y z t : α) : edist x t ≤ edist x y + edist y z + edist z t :=
calc
edist x t ≤ edist x z + edist z t := edist_triangle x z t
_ ≤ edist x y + edist y z + edist z t := add_le_add_right (edist_triangle x y z) _
#align edist_triangle4 edist_triangle4
theorem edist_le_Ico_sum_edist (f : ℕ → α) {m n} (h : m ≤ n) :
edist (f m) (f n) ≤ ∑ i ∈ Finset.Ico m n, edist (f i) (f (i + 1)) := by
induction n, h using Nat.le_induction with
| base => rw [Finset.Ico_self, Finset.sum_empty, edist_self]
| succ n hle ihn =>
calc
edist (f m) (f (n + 1)) ≤ edist (f m) (f n) + edist (f n) (f (n + 1)) := edist_triangle _ _ _
_ ≤ (∑ i ∈ Finset.Ico m n, _) + _ := add_le_add ihn le_rfl
_ = ∑ i ∈ Finset.Ico m (n + 1), _ := by
{ rw [Nat.Ico_succ_right_eq_insert_Ico hle, Finset.sum_insert, add_comm]; simp }
#align edist_le_Ico_sum_edist edist_le_Ico_sum_edist
theorem edist_le_range_sum_edist (f : ℕ → α) (n : ℕ) :
edist (f 0) (f n) ≤ ∑ i ∈ Finset.range n, edist (f i) (f (i + 1)) :=
Nat.Ico_zero_eq_range ▸ edist_le_Ico_sum_edist f (Nat.zero_le n)
#align edist_le_range_sum_edist edist_le_range_sum_edist
theorem edist_le_Ico_sum_of_edist_le {f : ℕ → α} {m n} (hmn : m ≤ n) {d : ℕ → ℝ≥0∞}
(hd : ∀ {k}, m ≤ k → k < n → edist (f k) (f (k + 1)) ≤ d k) :
edist (f m) (f n) ≤ ∑ i ∈ Finset.Ico m n, d i :=
le_trans (edist_le_Ico_sum_edist f hmn) <|
Finset.sum_le_sum fun _k hk => hd (Finset.mem_Ico.1 hk).1 (Finset.mem_Ico.1 hk).2
#align edist_le_Ico_sum_of_edist_le edist_le_Ico_sum_of_edist_le
theorem edist_le_range_sum_of_edist_le {f : ℕ → α} (n : ℕ) {d : ℕ → ℝ≥0∞}
(hd : ∀ {k}, k < n → edist (f k) (f (k + 1)) ≤ d k) :
edist (f 0) (f n) ≤ ∑ i ∈ Finset.range n, d i :=
Nat.Ico_zero_eq_range ▸ edist_le_Ico_sum_of_edist_le (zero_le n) fun _ => hd
#align edist_le_range_sum_of_edist_le edist_le_range_sum_of_edist_le
theorem uniformity_pseudoedist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | edist p.1 p.2 < ε } :=
PseudoEMetricSpace.uniformity_edist
#align uniformity_pseudoedist uniformity_pseudoedist
theorem uniformSpace_edist :
‹PseudoEMetricSpace α›.toUniformSpace =
uniformSpaceOfEDist edist edist_self edist_comm edist_triangle :=
UniformSpace.ext uniformity_pseudoedist
#align uniform_space_edist uniformSpace_edist
theorem uniformity_basis_edist :
(𝓤 α).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 < ε } :=
(@uniformSpace_edist α _).symm ▸ UniformSpace.hasBasis_ofFun ⟨1, one_pos⟩ _ _ _ _ _
#align uniformity_basis_edist uniformity_basis_edist
theorem mem_uniformity_edist {s : Set (α × α)} :
s ∈ 𝓤 α ↔ ∃ ε > 0, ∀ {a b : α}, edist a b < ε → (a, b) ∈ s :=
uniformity_basis_edist.mem_uniformity_iff
#align mem_uniformity_edist mem_uniformity_edist
protected theorem EMetric.mk_uniformity_basis {β : Type*} {p : β → Prop} {f : β → ℝ≥0∞}
(hf₀ : ∀ x, p x → 0 < f x) (hf : ∀ ε, 0 < ε → ∃ x, p x ∧ f x ≤ ε) :
(𝓤 α).HasBasis p fun x => { p : α × α | edist p.1 p.2 < f x } := by
refine ⟨fun s => uniformity_basis_edist.mem_iff.trans ?_⟩
constructor
· rintro ⟨ε, ε₀, hε⟩
rcases hf ε ε₀ with ⟨i, hi, H⟩
exact ⟨i, hi, fun x hx => hε <| lt_of_lt_of_le hx.out H⟩
· exact fun ⟨i, hi, H⟩ => ⟨f i, hf₀ i hi, H⟩
#align emetric.mk_uniformity_basis EMetric.mk_uniformity_basis
protected theorem EMetric.mk_uniformity_basis_le {β : Type*} {p : β → Prop} {f : β → ℝ≥0∞}
(hf₀ : ∀ x, p x → 0 < f x) (hf : ∀ ε, 0 < ε → ∃ x, p x ∧ f x ≤ ε) :
(𝓤 α).HasBasis p fun x => { p : α × α | edist p.1 p.2 ≤ f x } := by
refine ⟨fun s => uniformity_basis_edist.mem_iff.trans ?_⟩
constructor
· rintro ⟨ε, ε₀, hε⟩
rcases exists_between ε₀ with ⟨ε', hε'⟩
rcases hf ε' hε'.1 with ⟨i, hi, H⟩
exact ⟨i, hi, fun x hx => hε <| lt_of_le_of_lt (le_trans hx.out H) hε'.2⟩
· exact fun ⟨i, hi, H⟩ => ⟨f i, hf₀ i hi, fun x hx => H (le_of_lt hx.out)⟩
#align emetric.mk_uniformity_basis_le EMetric.mk_uniformity_basis_le
theorem uniformity_basis_edist_le :
(𝓤 α).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 ≤ ε } :=
EMetric.mk_uniformity_basis_le (fun _ => id) fun ε ε₀ => ⟨ε, ε₀, le_refl ε⟩
#align uniformity_basis_edist_le uniformity_basis_edist_le
theorem uniformity_basis_edist' (ε' : ℝ≥0∞) (hε' : 0 < ε') :
(𝓤 α).HasBasis (fun ε : ℝ≥0∞ => ε ∈ Ioo 0 ε') fun ε => { p : α × α | edist p.1 p.2 < ε } :=
EMetric.mk_uniformity_basis (fun _ => And.left) fun ε ε₀ =>
let ⟨δ, hδ⟩ := exists_between hε'
⟨min ε δ, ⟨lt_min ε₀ hδ.1, lt_of_le_of_lt (min_le_right _ _) hδ.2⟩, min_le_left _ _⟩
#align uniformity_basis_edist' uniformity_basis_edist'
theorem uniformity_basis_edist_le' (ε' : ℝ≥0∞) (hε' : 0 < ε') :
(𝓤 α).HasBasis (fun ε : ℝ≥0∞ => ε ∈ Ioo 0 ε') fun ε => { p : α × α | edist p.1 p.2 ≤ ε } :=
EMetric.mk_uniformity_basis_le (fun _ => And.left) fun ε ε₀ =>
let ⟨δ, hδ⟩ := exists_between hε'
⟨min ε δ, ⟨lt_min ε₀ hδ.1, lt_of_le_of_lt (min_le_right _ _) hδ.2⟩, min_le_left _ _⟩
#align uniformity_basis_edist_le' uniformity_basis_edist_le'
theorem uniformity_basis_edist_nnreal :
(𝓤 α).HasBasis (fun ε : ℝ≥0 => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 < ε } :=
EMetric.mk_uniformity_basis (fun _ => ENNReal.coe_pos.2) fun _ε ε₀ =>
let ⟨δ, hδ⟩ := ENNReal.lt_iff_exists_nnreal_btwn.1 ε₀
⟨δ, ENNReal.coe_pos.1 hδ.1, le_of_lt hδ.2⟩
#align uniformity_basis_edist_nnreal uniformity_basis_edist_nnreal
theorem uniformity_basis_edist_nnreal_le :
(𝓤 α).HasBasis (fun ε : ℝ≥0 => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 ≤ ε } :=
EMetric.mk_uniformity_basis_le (fun _ => ENNReal.coe_pos.2) fun _ε ε₀ =>
let ⟨δ, hδ⟩ := ENNReal.lt_iff_exists_nnreal_btwn.1 ε₀
⟨δ, ENNReal.coe_pos.1 hδ.1, le_of_lt hδ.2⟩
#align uniformity_basis_edist_nnreal_le uniformity_basis_edist_nnreal_le
theorem uniformity_basis_edist_inv_nat :
(𝓤 α).HasBasis (fun _ => True) fun n : ℕ => { p : α × α | edist p.1 p.2 < (↑n)⁻¹ } :=
EMetric.mk_uniformity_basis (fun n _ ↦ ENNReal.inv_pos.2 <| ENNReal.natCast_ne_top n) fun _ε ε₀ ↦
let ⟨n, hn⟩ := ENNReal.exists_inv_nat_lt (ne_of_gt ε₀)
⟨n, trivial, le_of_lt hn⟩
#align uniformity_basis_edist_inv_nat uniformity_basis_edist_inv_nat
theorem uniformity_basis_edist_inv_two_pow :
(𝓤 α).HasBasis (fun _ => True) fun n : ℕ => { p : α × α | edist p.1 p.2 < 2⁻¹ ^ n } :=
EMetric.mk_uniformity_basis (fun _ _ => ENNReal.pow_pos (ENNReal.inv_pos.2 ENNReal.two_ne_top) _)
fun _ε ε₀ =>
let ⟨n, hn⟩ := ENNReal.exists_inv_two_pow_lt (ne_of_gt ε₀)
⟨n, trivial, le_of_lt hn⟩
#align uniformity_basis_edist_inv_two_pow uniformity_basis_edist_inv_two_pow
theorem edist_mem_uniformity {ε : ℝ≥0∞} (ε0 : 0 < ε) : { p : α × α | edist p.1 p.2 < ε } ∈ 𝓤 α :=
mem_uniformity_edist.2 ⟨ε, ε0, id⟩
#align edist_mem_uniformity edist_mem_uniformity
open EMetric
def PseudoEMetricSpace.replaceUniformity {α} [U : UniformSpace α] (m : PseudoEMetricSpace α)
(H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace]) : PseudoEMetricSpace α where
edist := @edist _ m.toEDist
edist_self := edist_self
edist_comm := edist_comm
edist_triangle := edist_triangle
toUniformSpace := U
uniformity_edist := H.trans (@PseudoEMetricSpace.uniformity_edist α _)
#align pseudo_emetric_space.replace_uniformity PseudoEMetricSpace.replaceUniformity
def PseudoEMetricSpace.induced {α β} (f : α → β) (m : PseudoEMetricSpace β) :
PseudoEMetricSpace α where
edist x y := edist (f x) (f y)
edist_self _ := edist_self _
edist_comm _ _ := edist_comm _ _
edist_triangle _ _ _ := edist_triangle _ _ _
toUniformSpace := UniformSpace.comap f m.toUniformSpace
uniformity_edist := (uniformity_basis_edist.comap (Prod.map f f)).eq_biInf
#align pseudo_emetric_space.induced PseudoEMetricSpace.induced
instance {α : Type*} {p : α → Prop} [PseudoEMetricSpace α] : PseudoEMetricSpace (Subtype p) :=
PseudoEMetricSpace.induced Subtype.val ‹_›
theorem Subtype.edist_eq {p : α → Prop} (x y : Subtype p) : edist x y = edist (x : α) y := rfl
#align subtype.edist_eq Subtype.edist_eq
instance Prod.pseudoEMetricSpaceMax [PseudoEMetricSpace β] : PseudoEMetricSpace (α × β) where
edist x y := edist x.1 y.1 ⊔ edist x.2 y.2
edist_self x := by simp
edist_comm x y := by simp [edist_comm]
edist_triangle x y z :=
max_le (le_trans (edist_triangle _ _ _) (add_le_add (le_max_left _ _) (le_max_left _ _)))
(le_trans (edist_triangle _ _ _) (add_le_add (le_max_right _ _) (le_max_right _ _)))
uniformity_edist := uniformity_prod.trans <| by
simp [PseudoEMetricSpace.uniformity_edist, ← iInf_inf_eq, setOf_and]
toUniformSpace := inferInstance
#align prod.pseudo_emetric_space_max Prod.pseudoEMetricSpaceMax
theorem Prod.edist_eq [PseudoEMetricSpace β] (x y : α × β) :
edist x y = max (edist x.1 y.1) (edist x.2 y.2) :=
rfl
#align prod.edist_eq Prod.edist_eq
namespace EMetric
variable {x y z : α} {ε ε₁ ε₂ : ℝ≥0∞} {s t : Set α}
def ball (x : α) (ε : ℝ≥0∞) : Set α :=
{ y | edist y x < ε }
#align emetric.ball EMetric.ball
@[simp] theorem mem_ball : y ∈ ball x ε ↔ edist y x < ε := Iff.rfl
#align emetric.mem_ball EMetric.mem_ball
theorem mem_ball' : y ∈ ball x ε ↔ edist x y < ε := by rw [edist_comm, mem_ball]
#align emetric.mem_ball' EMetric.mem_ball'
def closedBall (x : α) (ε : ℝ≥0∞) :=
{ y | edist y x ≤ ε }
#align emetric.closed_ball EMetric.closedBall
@[simp] theorem mem_closedBall : y ∈ closedBall x ε ↔ edist y x ≤ ε := Iff.rfl
#align emetric.mem_closed_ball EMetric.mem_closedBall
| Mathlib/Topology/EMetricSpace/Basic.lean | 560 | 560 | theorem mem_closedBall' : y ∈ closedBall x ε ↔ edist x y ≤ ε := by | rw [edist_comm, mem_closedBall]
|
import Mathlib.MeasureTheory.Measure.ProbabilityMeasure
import Mathlib.MeasureTheory.Measure.Lebesgue.Basic
import Mathlib.MeasureTheory.Integral.Layercake
import Mathlib.MeasureTheory.Integral.BoundedContinuousFunction
#align_import measure_theory.measure.portmanteau from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
noncomputable section
open MeasureTheory Set Filter BoundedContinuousFunction
open scoped Topology ENNReal NNReal BoundedContinuousFunction
namespace MeasureTheory
section LimsupClosedLEAndLELiminfOpen
variable {Ω : Type*} [MeasurableSpace Ω]
theorem le_measure_compl_liminf_of_limsup_measure_le {ι : Type*} {L : Filter ι} {μ : Measure Ω}
{μs : ι → Measure Ω} [IsProbabilityMeasure μ] [∀ i, IsProbabilityMeasure (μs i)] {E : Set Ω}
(E_mble : MeasurableSet E) (h : (L.limsup fun i => μs i E) ≤ μ E) :
μ Eᶜ ≤ L.liminf fun i => μs i Eᶜ := by
rcases L.eq_or_neBot with rfl | hne
· simp only [liminf_bot, le_top]
have meas_Ec : μ Eᶜ = 1 - μ E := by
simpa only [measure_univ] using measure_compl E_mble (measure_lt_top μ E).ne
have meas_i_Ec : ∀ i, μs i Eᶜ = 1 - μs i E := by
intro i
simpa only [measure_univ] using measure_compl E_mble (measure_lt_top (μs i) E).ne
simp_rw [meas_Ec, meas_i_Ec]
have obs :
(L.liminf fun i : ι => 1 - μs i E) = L.liminf ((fun x => 1 - x) ∘ fun i : ι => μs i E) := rfl
rw [obs]
have := antitone_const_tsub.map_limsup_of_continuousAt (F := L)
(fun i => μs i E) (ENNReal.continuous_sub_left ENNReal.one_ne_top).continuousAt
simp_rw [← this]
exact antitone_const_tsub h
#align measure_theory.le_measure_compl_liminf_of_limsup_measure_le MeasureTheory.le_measure_compl_liminf_of_limsup_measure_le
theorem le_measure_liminf_of_limsup_measure_compl_le {ι : Type*} {L : Filter ι} {μ : Measure Ω}
{μs : ι → Measure Ω} [IsProbabilityMeasure μ] [∀ i, IsProbabilityMeasure (μs i)] {E : Set Ω}
(E_mble : MeasurableSet E) (h : (L.limsup fun i => μs i Eᶜ) ≤ μ Eᶜ) :
μ E ≤ L.liminf fun i => μs i E :=
compl_compl E ▸ le_measure_compl_liminf_of_limsup_measure_le (MeasurableSet.compl E_mble) h
#align measure_theory.le_measure_liminf_of_limsup_measure_compl_le MeasureTheory.le_measure_liminf_of_limsup_measure_compl_le
theorem limsup_measure_compl_le_of_le_liminf_measure {ι : Type*} {L : Filter ι} {μ : Measure Ω}
{μs : ι → Measure Ω} [IsProbabilityMeasure μ] [∀ i, IsProbabilityMeasure (μs i)] {E : Set Ω}
(E_mble : MeasurableSet E) (h : μ E ≤ L.liminf fun i => μs i E) :
(L.limsup fun i => μs i Eᶜ) ≤ μ Eᶜ := by
rcases L.eq_or_neBot with rfl | hne
· simp only [limsup_bot, bot_le]
have meas_Ec : μ Eᶜ = 1 - μ E := by
simpa only [measure_univ] using measure_compl E_mble (measure_lt_top μ E).ne
have meas_i_Ec : ∀ i, μs i Eᶜ = 1 - μs i E := by
intro i
simpa only [measure_univ] using measure_compl E_mble (measure_lt_top (μs i) E).ne
simp_rw [meas_Ec, meas_i_Ec]
have obs :
(L.limsup fun i : ι => 1 - μs i E) = L.limsup ((fun x => 1 - x) ∘ fun i : ι => μs i E) := rfl
rw [obs]
have := antitone_const_tsub.map_liminf_of_continuousAt (F := L)
(fun i => μs i E) (ENNReal.continuous_sub_left ENNReal.one_ne_top).continuousAt
simp_rw [← this]
exact antitone_const_tsub h
#align measure_theory.limsup_measure_compl_le_of_le_liminf_measure MeasureTheory.limsup_measure_compl_le_of_le_liminf_measure
theorem limsup_measure_le_of_le_liminf_measure_compl {ι : Type*} {L : Filter ι} {μ : Measure Ω}
{μs : ι → Measure Ω} [IsProbabilityMeasure μ] [∀ i, IsProbabilityMeasure (μs i)] {E : Set Ω}
(E_mble : MeasurableSet E) (h : μ Eᶜ ≤ L.liminf fun i => μs i Eᶜ) :
(L.limsup fun i => μs i E) ≤ μ E :=
compl_compl E ▸ limsup_measure_compl_le_of_le_liminf_measure (MeasurableSet.compl E_mble) h
#align measure_theory.limsup_measure_le_of_le_liminf_measure_compl MeasureTheory.limsup_measure_le_of_le_liminf_measure_compl
variable [TopologicalSpace Ω] [OpensMeasurableSpace Ω]
theorem limsup_measure_closed_le_iff_liminf_measure_open_ge {ι : Type*} {L : Filter ι}
{μ : Measure Ω} {μs : ι → Measure Ω} [IsProbabilityMeasure μ]
[∀ i, IsProbabilityMeasure (μs i)] :
(∀ F, IsClosed F → (L.limsup fun i => μs i F) ≤ μ F) ↔
∀ G, IsOpen G → μ G ≤ L.liminf fun i => μs i G := by
constructor
· intro h G G_open
exact le_measure_liminf_of_limsup_measure_compl_le
G_open.measurableSet (h Gᶜ (isClosed_compl_iff.mpr G_open))
· intro h F F_closed
exact limsup_measure_le_of_le_liminf_measure_compl
F_closed.measurableSet (h Fᶜ (isOpen_compl_iff.mpr F_closed))
#align measure_theory.limsup_measure_closed_le_iff_liminf_measure_open_ge MeasureTheory.limsup_measure_closed_le_iff_liminf_measure_open_ge
end LimsupClosedLEAndLELiminfOpen -- section
section TendstoOfNullFrontier
variable {Ω : Type*} [MeasurableSpace Ω]
theorem tendsto_measure_of_le_liminf_measure_of_limsup_measure_le {ι : Type*} {L : Filter ι}
{μ : Measure Ω} {μs : ι → Measure Ω} {E₀ E E₁ : Set Ω} (E₀_subset : E₀ ⊆ E) (subset_E₁ : E ⊆ E₁)
(nulldiff : μ (E₁ \ E₀) = 0) (h_E₀ : μ E₀ ≤ L.liminf fun i => μs i E₀)
(h_E₁ : (L.limsup fun i => μs i E₁) ≤ μ E₁) : L.Tendsto (fun i => μs i E) (𝓝 (μ E)) := by
apply tendsto_of_le_liminf_of_limsup_le
· have E₀_ae_eq_E : E₀ =ᵐ[μ] E :=
EventuallyLE.antisymm E₀_subset.eventuallyLE
(subset_E₁.eventuallyLE.trans (ae_le_set.mpr nulldiff))
calc
μ E = μ E₀ := measure_congr E₀_ae_eq_E.symm
_ ≤ L.liminf fun i => μs i E₀ := h_E₀
_ ≤ L.liminf fun i => μs i E :=
liminf_le_liminf (eventually_of_forall fun _ => measure_mono E₀_subset)
· have E_ae_eq_E₁ : E =ᵐ[μ] E₁ :=
EventuallyLE.antisymm subset_E₁.eventuallyLE
((ae_le_set.mpr nulldiff).trans E₀_subset.eventuallyLE)
calc
(L.limsup fun i => μs i E) ≤ L.limsup fun i => μs i E₁ :=
limsup_le_limsup (eventually_of_forall fun _ => measure_mono subset_E₁)
_ ≤ μ E₁ := h_E₁
_ = μ E := measure_congr E_ae_eq_E₁.symm
· infer_param
· infer_param
#align measure_theory.tendsto_measure_of_le_liminf_measure_of_limsup_measure_le MeasureTheory.tendsto_measure_of_le_liminf_measure_of_limsup_measure_le
variable [TopologicalSpace Ω] [OpensMeasurableSpace Ω]
theorem tendsto_measure_of_null_frontier {ι : Type*} {L : Filter ι} {μ : Measure Ω}
{μs : ι → Measure Ω} [IsProbabilityMeasure μ] [∀ i, IsProbabilityMeasure (μs i)]
(h_opens : ∀ G, IsOpen G → μ G ≤ L.liminf fun i => μs i G) {E : Set Ω}
(E_nullbdry : μ (frontier E) = 0) : L.Tendsto (fun i => μs i E) (𝓝 (μ E)) :=
haveI h_closeds : ∀ F, IsClosed F → (L.limsup fun i => μs i F) ≤ μ F :=
limsup_measure_closed_le_iff_liminf_measure_open_ge.mpr h_opens
tendsto_measure_of_le_liminf_measure_of_limsup_measure_le interior_subset subset_closure
E_nullbdry (h_opens _ isOpen_interior) (h_closeds _ isClosed_closure)
#align measure_theory.tendsto_measure_of_null_frontier MeasureTheory.tendsto_measure_of_null_frontier
end TendstoOfNullFrontier --section
section ConvergenceImpliesLimsupClosedLE
theorem FiniteMeasure.limsup_measure_closed_le_of_tendsto {Ω ι : Type*} {L : Filter ι}
[MeasurableSpace Ω] [TopologicalSpace Ω] [HasOuterApproxClosed Ω]
[OpensMeasurableSpace Ω] {μ : FiniteMeasure Ω}
{μs : ι → FiniteMeasure Ω} (μs_lim : Tendsto μs L (𝓝 μ)) {F : Set Ω} (F_closed : IsClosed F) :
(L.limsup fun i => (μs i : Measure Ω) F) ≤ (μ : Measure Ω) F := by
rcases L.eq_or_neBot with rfl | hne
· simp only [limsup_bot, bot_le]
apply ENNReal.le_of_forall_pos_le_add
intro ε ε_pos _
let fs := F_closed.apprSeq
have key₁ : Tendsto (fun n ↦ ∫⁻ ω, (fs n ω : ℝ≥0∞) ∂μ) atTop (𝓝 ((μ : Measure Ω) F)) :=
HasOuterApproxClosed.tendsto_lintegral_apprSeq F_closed (μ : Measure Ω)
have room₁ : (μ : Measure Ω) F < (μ : Measure Ω) F + ε / 2 := by
apply
ENNReal.lt_add_right (measure_lt_top (μ : Measure Ω) F).ne
(ENNReal.div_pos_iff.mpr ⟨(ENNReal.coe_pos.mpr ε_pos).ne.symm, ENNReal.two_ne_top⟩).ne.symm
rcases eventually_atTop.mp (eventually_lt_of_tendsto_lt room₁ key₁) with ⟨M, hM⟩
have key₂ := FiniteMeasure.tendsto_iff_forall_lintegral_tendsto.mp μs_lim (fs M)
have room₂ :
(lintegral (μ : Measure Ω) fun a => fs M a) <
(lintegral (μ : Measure Ω) fun a => fs M a) + ε / 2 := by
apply ENNReal.lt_add_right (ne_of_lt ?_)
(ENNReal.div_pos_iff.mpr ⟨(ENNReal.coe_pos.mpr ε_pos).ne.symm, ENNReal.two_ne_top⟩).ne.symm
apply BoundedContinuousFunction.lintegral_lt_top_of_nnreal
have ev_near := Eventually.mono (eventually_lt_of_tendsto_lt room₂ key₂) fun n => le_of_lt
have ev_near' := Eventually.mono ev_near
(fun n ↦ le_trans (HasOuterApproxClosed.measure_le_lintegral F_closed (μs n) M))
apply (Filter.limsup_le_limsup ev_near').trans
rw [limsup_const]
apply le_trans (add_le_add (hM M rfl.le).le (le_refl (ε / 2 : ℝ≥0∞)))
simp only [add_assoc, ENNReal.add_halves, le_refl]
#align measure_theory.finite_measure.limsup_measure_closed_le_of_tendsto MeasureTheory.FiniteMeasure.limsup_measure_closed_le_of_tendsto
theorem ProbabilityMeasure.limsup_measure_closed_le_of_tendsto {Ω ι : Type*} {L : Filter ι}
[MeasurableSpace Ω] [TopologicalSpace Ω] [OpensMeasurableSpace Ω] [HasOuterApproxClosed Ω]
{μ : ProbabilityMeasure Ω} {μs : ι → ProbabilityMeasure Ω} (μs_lim : Tendsto μs L (𝓝 μ))
{F : Set Ω} (F_closed : IsClosed F) :
(L.limsup fun i => (μs i : Measure Ω) F) ≤ (μ : Measure Ω) F := by
apply FiniteMeasure.limsup_measure_closed_le_of_tendsto
((ProbabilityMeasure.tendsto_nhds_iff_toFiniteMeasure_tendsto_nhds L).mp μs_lim) F_closed
#align measure_theory.probability_measure.limsup_measure_closed_le_of_tendsto MeasureTheory.ProbabilityMeasure.limsup_measure_closed_le_of_tendsto
theorem ProbabilityMeasure.le_liminf_measure_open_of_tendsto {Ω ι : Type*} {L : Filter ι}
[MeasurableSpace Ω] [PseudoEMetricSpace Ω] [OpensMeasurableSpace Ω] [HasOuterApproxClosed Ω]
{μ : ProbabilityMeasure Ω} {μs : ι → ProbabilityMeasure Ω} (μs_lim : Tendsto μs L (𝓝 μ))
{G : Set Ω} (G_open : IsOpen G) :
(μ : Measure Ω) G ≤ L.liminf fun i => (μs i : Measure Ω) G :=
haveI h_closeds : ∀ F, IsClosed F → (L.limsup fun i ↦ (μs i : Measure Ω) F) ≤ (μ : Measure Ω) F :=
fun _ F_closed => ProbabilityMeasure.limsup_measure_closed_le_of_tendsto μs_lim F_closed
le_measure_liminf_of_limsup_measure_compl_le G_open.measurableSet
(h_closeds _ (isClosed_compl_iff.mpr G_open))
#align measure_theory.probability_measure.le_liminf_measure_open_of_tendsto MeasureTheory.ProbabilityMeasure.le_liminf_measure_open_of_tendsto
theorem ProbabilityMeasure.tendsto_measure_of_null_frontier_of_tendsto' {Ω ι : Type*}
{L : Filter ι} [MeasurableSpace Ω] [PseudoEMetricSpace Ω] [OpensMeasurableSpace Ω]
[HasOuterApproxClosed Ω] {μ : ProbabilityMeasure Ω} {μs : ι → ProbabilityMeasure Ω}
(μs_lim : Tendsto μs L (𝓝 μ)) {E : Set Ω} (E_nullbdry : (μ : Measure Ω) (frontier E) = 0) :
Tendsto (fun i => (μs i : Measure Ω) E) L (𝓝 ((μ : Measure Ω) E)) :=
haveI h_opens : ∀ G, IsOpen G → (μ : Measure Ω) G ≤ L.liminf fun i => (μs i : Measure Ω) G :=
fun _ G_open => ProbabilityMeasure.le_liminf_measure_open_of_tendsto μs_lim G_open
tendsto_measure_of_null_frontier h_opens E_nullbdry
#align measure_theory.probability_measure.tendsto_measure_of_null_frontier_of_tendsto' MeasureTheory.ProbabilityMeasure.tendsto_measure_of_null_frontier_of_tendsto'
theorem ProbabilityMeasure.tendsto_measure_of_null_frontier_of_tendsto {Ω ι : Type*} {L : Filter ι}
[MeasurableSpace Ω] [PseudoEMetricSpace Ω] [OpensMeasurableSpace Ω] [HasOuterApproxClosed Ω]
{μ : ProbabilityMeasure Ω} {μs : ι → ProbabilityMeasure Ω} (μs_lim : Tendsto μs L (𝓝 μ))
{E : Set Ω} (E_nullbdry : μ (frontier E) = 0) : Tendsto (fun i => μs i E) L (𝓝 (μ E)) := by
have E_nullbdry' : (μ : Measure Ω) (frontier E) = 0 := by
rw [← ProbabilityMeasure.ennreal_coeFn_eq_coeFn_toMeasure, E_nullbdry, ENNReal.coe_zero]
have key := ProbabilityMeasure.tendsto_measure_of_null_frontier_of_tendsto' μs_lim E_nullbdry'
exact (ENNReal.tendsto_toNNReal (measure_ne_top (↑μ) E)).comp key
#align measure_theory.probability_measure.tendsto_measure_of_null_frontier_of_tendsto MeasureTheory.ProbabilityMeasure.tendsto_measure_of_null_frontier_of_tendsto
end ConvergenceImpliesLimsupClosedLE --section
section LimitBorelImpliesLimsupClosedLE
open ENNReal
variable {Ω : Type*} [PseudoEMetricSpace Ω] [MeasurableSpace Ω] [OpensMeasurableSpace Ω]
| Mathlib/MeasureTheory/Measure/Portmanteau.lean | 399 | 410 | theorem exists_null_frontier_thickening (μ : Measure Ω) [SigmaFinite μ] (s : Set Ω) {a b : ℝ}
(hab : a < b) : ∃ r ∈ Ioo a b, μ (frontier (Metric.thickening r s)) = 0 := by |
have mbles : ∀ r : ℝ, MeasurableSet (frontier (Metric.thickening r s)) :=
fun r => isClosed_frontier.measurableSet
have disjs := Metric.frontier_thickening_disjoint s
have key := Measure.countable_meas_pos_of_disjoint_iUnion (μ := μ) mbles disjs
have aux := measure_diff_null (s := Ioo a b) (Set.Countable.measure_zero key volume)
have len_pos : 0 < ENNReal.ofReal (b - a) := by simp only [hab, ENNReal.ofReal_pos, sub_pos]
rw [← Real.volume_Ioo, ← aux] at len_pos
rcases nonempty_of_measure_ne_zero len_pos.ne.symm with ⟨r, ⟨r_in_Ioo, hr⟩⟩
refine ⟨r, r_in_Ioo, ?_⟩
simpa only [mem_setOf_eq, not_lt, le_zero_iff] using hr
|
import Mathlib.Topology.MetricSpace.HausdorffDistance
#align_import topology.metric_space.hausdorff_distance from "leanprover-community/mathlib"@"bc91ed7093bf098d253401e69df601fc33dde156"
noncomputable section
open NNReal ENNReal Topology Set Filter Bornology
universe u v w
variable {ι : Sort*} {α : Type u} {β : Type v}
namespace Metric
section Cthickening
variable [PseudoEMetricSpace α] {δ ε : ℝ} {s t : Set α} {x : α}
open EMetric
def cthickening (δ : ℝ) (E : Set α) : Set α :=
{ x : α | infEdist x E ≤ ENNReal.ofReal δ }
#align metric.cthickening Metric.cthickening
@[simp]
theorem mem_cthickening_iff : x ∈ cthickening δ s ↔ infEdist x s ≤ ENNReal.ofReal δ :=
Iff.rfl
#align metric.mem_cthickening_iff Metric.mem_cthickening_iff
lemma eventually_not_mem_cthickening_of_infEdist_pos {E : Set α} {x : α} (h : x ∉ closure E) :
∀ᶠ δ in 𝓝 (0 : ℝ), x ∉ Metric.cthickening δ E := by
obtain ⟨ε, ⟨ε_pos, ε_lt⟩⟩ := exists_real_pos_lt_infEdist_of_not_mem_closure h
filter_upwards [eventually_lt_nhds ε_pos] with δ hδ
simp only [cthickening, mem_setOf_eq, not_le]
exact ((ofReal_lt_ofReal_iff ε_pos).mpr hδ).trans ε_lt
theorem mem_cthickening_of_edist_le (x y : α) (δ : ℝ) (E : Set α) (h : y ∈ E)
(h' : edist x y ≤ ENNReal.ofReal δ) : x ∈ cthickening δ E :=
(infEdist_le_edist_of_mem h).trans h'
#align metric.mem_cthickening_of_edist_le Metric.mem_cthickening_of_edist_le
theorem mem_cthickening_of_dist_le {α : Type*} [PseudoMetricSpace α] (x y : α) (δ : ℝ) (E : Set α)
(h : y ∈ E) (h' : dist x y ≤ δ) : x ∈ cthickening δ E := by
apply mem_cthickening_of_edist_le x y δ E h
rw [edist_dist]
exact ENNReal.ofReal_le_ofReal h'
#align metric.mem_cthickening_of_dist_le Metric.mem_cthickening_of_dist_le
theorem cthickening_eq_preimage_infEdist (δ : ℝ) (E : Set α) :
cthickening δ E = (fun x => infEdist x E) ⁻¹' Iic (ENNReal.ofReal δ) :=
rfl
#align metric.cthickening_eq_preimage_inf_edist Metric.cthickening_eq_preimage_infEdist
theorem isClosed_cthickening {δ : ℝ} {E : Set α} : IsClosed (cthickening δ E) :=
IsClosed.preimage continuous_infEdist isClosed_Iic
#align metric.is_closed_cthickening Metric.isClosed_cthickening
@[simp]
| Mathlib/Topology/MetricSpace/Thickening.lean | 238 | 239 | theorem cthickening_empty (δ : ℝ) : cthickening δ (∅ : Set α) = ∅ := by |
simp only [cthickening, ENNReal.ofReal_ne_top, setOf_false, infEdist_empty, top_le_iff]
|
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Combinatorics.Additive.AP.Three.Defs
import Mathlib.Combinatorics.Pigeonhole
import Mathlib.Data.Complex.ExponentialBounds
#align_import combinatorics.additive.behrend from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8"
open Nat hiding log
open Finset Metric Real
open scoped Pointwise
lemma threeAPFree_frontier {𝕜 E : Type*} [LinearOrderedField 𝕜] [TopologicalSpace E]
[AddCommMonoid E] [Module 𝕜 E] {s : Set E} (hs₀ : IsClosed s) (hs₁ : StrictConvex 𝕜 s) :
ThreeAPFree (frontier s) := by
intro a ha b hb c hc habc
obtain rfl : (1 / 2 : 𝕜) • a + (1 / 2 : 𝕜) • c = b := by
rwa [← smul_add, one_div, inv_smul_eq_iff₀ (show (2 : 𝕜) ≠ 0 by norm_num), two_smul]
have :=
hs₁.eq (hs₀.frontier_subset ha) (hs₀.frontier_subset hc) one_half_pos one_half_pos
(add_halves _) hb.2
simp [this, ← add_smul]
ring_nf
simp
#align add_salem_spencer_frontier threeAPFree_frontier
lemma threeAPFree_sphere {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
[StrictConvexSpace ℝ E] (x : E) (r : ℝ) : ThreeAPFree (sphere x r) := by
obtain rfl | hr := eq_or_ne r 0
· rw [sphere_zero]
exact threeAPFree_singleton _
· convert threeAPFree_frontier isClosed_ball (strictConvex_closedBall ℝ x r)
exact (frontier_closedBall _ hr).symm
#align add_salem_spencer_sphere threeAPFree_sphere
namespace Behrend
variable {α β : Type*} {n d k N : ℕ} {x : Fin n → ℕ}
def box (n d : ℕ) : Finset (Fin n → ℕ) :=
Fintype.piFinset fun _ => range d
#align behrend.box Behrend.box
theorem mem_box : x ∈ box n d ↔ ∀ i, x i < d := by simp only [box, Fintype.mem_piFinset, mem_range]
#align behrend.mem_box Behrend.mem_box
@[simp]
theorem card_box : (box n d).card = d ^ n := by simp [box]
#align behrend.card_box Behrend.card_box
@[simp]
theorem box_zero : box (n + 1) 0 = ∅ := by simp [box]
#align behrend.box_zero Behrend.box_zero
def sphere (n d k : ℕ) : Finset (Fin n → ℕ) :=
(box n d).filter fun x => ∑ i, x i ^ 2 = k
#align behrend.sphere Behrend.sphere
theorem sphere_zero_subset : sphere n d 0 ⊆ 0 := fun x => by simp [sphere, Function.funext_iff]
#align behrend.sphere_zero_subset Behrend.sphere_zero_subset
@[simp]
| Mathlib/Combinatorics/Additive/AP/Three/Behrend.lean | 118 | 118 | theorem sphere_zero_right (n k : ℕ) : sphere (n + 1) 0 k = ∅ := by | simp [sphere]
|
import Mathlib.Probability.Variance
#align_import probability.moments from "leanprover-community/mathlib"@"85453a2a14be8da64caf15ca50930cf4c6e5d8de"
open MeasureTheory Filter Finset Real
noncomputable section
open scoped MeasureTheory ProbabilityTheory ENNReal NNReal
namespace ProbabilityTheory
variable {Ω ι : Type*} {m : MeasurableSpace Ω} {X : Ω → ℝ} {p : ℕ} {μ : Measure Ω}
def moment (X : Ω → ℝ) (p : ℕ) (μ : Measure Ω) : ℝ :=
μ[X ^ p]
#align probability_theory.moment ProbabilityTheory.moment
def centralMoment (X : Ω → ℝ) (p : ℕ) (μ : Measure Ω) : ℝ := by
have m := fun (x : Ω) => μ[X] -- Porting note: Lean deems `μ[(X - fun x => μ[X]) ^ p]` ambiguous
exact μ[(X - m) ^ p]
#align probability_theory.central_moment ProbabilityTheory.centralMoment
@[simp]
theorem moment_zero (hp : p ≠ 0) : moment 0 p μ = 0 := by
simp only [moment, hp, zero_pow, Ne, not_false_iff, Pi.zero_apply, integral_const,
smul_eq_mul, mul_zero, integral_zero]
#align probability_theory.moment_zero ProbabilityTheory.moment_zero
@[simp]
theorem centralMoment_zero (hp : p ≠ 0) : centralMoment 0 p μ = 0 := by
simp only [centralMoment, hp, Pi.zero_apply, integral_const, smul_eq_mul,
mul_zero, zero_sub, Pi.pow_apply, Pi.neg_apply, neg_zero, zero_pow, Ne, not_false_iff]
#align probability_theory.central_moment_zero ProbabilityTheory.centralMoment_zero
theorem centralMoment_one' [IsFiniteMeasure μ] (h_int : Integrable X μ) :
centralMoment X 1 μ = (1 - (μ Set.univ).toReal) * μ[X] := by
simp only [centralMoment, Pi.sub_apply, pow_one]
rw [integral_sub h_int (integrable_const _)]
simp only [sub_mul, integral_const, smul_eq_mul, one_mul]
#align probability_theory.central_moment_one' ProbabilityTheory.centralMoment_one'
@[simp]
theorem centralMoment_one [IsProbabilityMeasure μ] : centralMoment X 1 μ = 0 := by
by_cases h_int : Integrable X μ
· rw [centralMoment_one' h_int]
simp only [measure_univ, ENNReal.one_toReal, sub_self, zero_mul]
· simp only [centralMoment, Pi.sub_apply, pow_one]
have : ¬Integrable (fun x => X x - integral μ X) μ := by
refine fun h_sub => h_int ?_
have h_add : X = (fun x => X x - integral μ X) + fun _ => integral μ X := by ext1 x; simp
rw [h_add]
exact h_sub.add (integrable_const _)
rw [integral_undef this]
#align probability_theory.central_moment_one ProbabilityTheory.centralMoment_one
theorem centralMoment_two_eq_variance [IsFiniteMeasure μ] (hX : Memℒp X 2 μ) :
centralMoment X 2 μ = variance X μ := by rw [hX.variance_eq]; rfl
#align probability_theory.central_moment_two_eq_variance ProbabilityTheory.centralMoment_two_eq_variance
section MomentGeneratingFunction
variable {t : ℝ}
def mgf (X : Ω → ℝ) (μ : Measure Ω) (t : ℝ) : ℝ :=
μ[fun ω => exp (t * X ω)]
#align probability_theory.mgf ProbabilityTheory.mgf
def cgf (X : Ω → ℝ) (μ : Measure Ω) (t : ℝ) : ℝ :=
log (mgf X μ t)
#align probability_theory.cgf ProbabilityTheory.cgf
@[simp]
theorem mgf_zero_fun : mgf 0 μ t = (μ Set.univ).toReal := by
simp only [mgf, Pi.zero_apply, mul_zero, exp_zero, integral_const, smul_eq_mul, mul_one]
#align probability_theory.mgf_zero_fun ProbabilityTheory.mgf_zero_fun
@[simp]
theorem cgf_zero_fun : cgf 0 μ t = log (μ Set.univ).toReal := by simp only [cgf, mgf_zero_fun]
#align probability_theory.cgf_zero_fun ProbabilityTheory.cgf_zero_fun
@[simp]
theorem mgf_zero_measure : mgf X (0 : Measure Ω) t = 0 := by simp only [mgf, integral_zero_measure]
#align probability_theory.mgf_zero_measure ProbabilityTheory.mgf_zero_measure
@[simp]
theorem cgf_zero_measure : cgf X (0 : Measure Ω) t = 0 := by
simp only [cgf, log_zero, mgf_zero_measure]
#align probability_theory.cgf_zero_measure ProbabilityTheory.cgf_zero_measure
@[simp]
theorem mgf_const' (c : ℝ) : mgf (fun _ => c) μ t = (μ Set.univ).toReal * exp (t * c) := by
simp only [mgf, integral_const, smul_eq_mul]
#align probability_theory.mgf_const' ProbabilityTheory.mgf_const'
-- @[simp] -- Porting note: `simp only` already proves this
theorem mgf_const (c : ℝ) [IsProbabilityMeasure μ] : mgf (fun _ => c) μ t = exp (t * c) := by
simp only [mgf_const', measure_univ, ENNReal.one_toReal, one_mul]
#align probability_theory.mgf_const ProbabilityTheory.mgf_const
@[simp]
theorem cgf_const' [IsFiniteMeasure μ] (hμ : μ ≠ 0) (c : ℝ) :
cgf (fun _ => c) μ t = log (μ Set.univ).toReal + t * c := by
simp only [cgf, mgf_const']
rw [log_mul _ (exp_pos _).ne']
· rw [log_exp _]
· rw [Ne, ENNReal.toReal_eq_zero_iff, Measure.measure_univ_eq_zero]
simp only [hμ, measure_ne_top μ Set.univ, or_self_iff, not_false_iff]
#align probability_theory.cgf_const' ProbabilityTheory.cgf_const'
@[simp]
theorem cgf_const [IsProbabilityMeasure μ] (c : ℝ) : cgf (fun _ => c) μ t = t * c := by
simp only [cgf, mgf_const, log_exp]
#align probability_theory.cgf_const ProbabilityTheory.cgf_const
@[simp]
theorem mgf_zero' : mgf X μ 0 = (μ Set.univ).toReal := by
simp only [mgf, zero_mul, exp_zero, integral_const, smul_eq_mul, mul_one]
#align probability_theory.mgf_zero' ProbabilityTheory.mgf_zero'
-- @[simp] -- Porting note: `simp only` already proves this
theorem mgf_zero [IsProbabilityMeasure μ] : mgf X μ 0 = 1 := by
simp only [mgf_zero', measure_univ, ENNReal.one_toReal]
#align probability_theory.mgf_zero ProbabilityTheory.mgf_zero
@[simp]
theorem cgf_zero' : cgf X μ 0 = log (μ Set.univ).toReal := by simp only [cgf, mgf_zero']
#align probability_theory.cgf_zero' ProbabilityTheory.cgf_zero'
-- @[simp] -- Porting note: `simp only` already proves this
theorem cgf_zero [IsProbabilityMeasure μ] : cgf X μ 0 = 0 := by
simp only [cgf_zero', measure_univ, ENNReal.one_toReal, log_one]
#align probability_theory.cgf_zero ProbabilityTheory.cgf_zero
theorem mgf_undef (hX : ¬Integrable (fun ω => exp (t * X ω)) μ) : mgf X μ t = 0 := by
simp only [mgf, integral_undef hX]
#align probability_theory.mgf_undef ProbabilityTheory.mgf_undef
theorem cgf_undef (hX : ¬Integrable (fun ω => exp (t * X ω)) μ) : cgf X μ t = 0 := by
simp only [cgf, mgf_undef hX, log_zero]
#align probability_theory.cgf_undef ProbabilityTheory.cgf_undef
theorem mgf_nonneg : 0 ≤ mgf X μ t := by
unfold mgf; positivity
#align probability_theory.mgf_nonneg ProbabilityTheory.mgf_nonneg
theorem mgf_pos' (hμ : μ ≠ 0) (h_int_X : Integrable (fun ω => exp (t * X ω)) μ) :
0 < mgf X μ t := by
simp_rw [mgf]
have : ∫ x : Ω, exp (t * X x) ∂μ = ∫ x : Ω in Set.univ, exp (t * X x) ∂μ := by
simp only [Measure.restrict_univ]
rw [this, setIntegral_pos_iff_support_of_nonneg_ae _ _]
· have h_eq_univ : (Function.support fun x : Ω => exp (t * X x)) = Set.univ := by
ext1 x
simp only [Function.mem_support, Set.mem_univ, iff_true_iff]
exact (exp_pos _).ne'
rw [h_eq_univ, Set.inter_univ _]
refine Ne.bot_lt ?_
simp only [hμ, ENNReal.bot_eq_zero, Ne, Measure.measure_univ_eq_zero, not_false_iff]
· filter_upwards with x
rw [Pi.zero_apply]
exact (exp_pos _).le
· rwa [integrableOn_univ]
#align probability_theory.mgf_pos' ProbabilityTheory.mgf_pos'
theorem mgf_pos [IsProbabilityMeasure μ] (h_int_X : Integrable (fun ω => exp (t * X ω)) μ) :
0 < mgf X μ t :=
mgf_pos' (IsProbabilityMeasure.ne_zero μ) h_int_X
#align probability_theory.mgf_pos ProbabilityTheory.mgf_pos
theorem mgf_neg : mgf (-X) μ t = mgf X μ (-t) := by simp_rw [mgf, Pi.neg_apply, mul_neg, neg_mul]
#align probability_theory.mgf_neg ProbabilityTheory.mgf_neg
theorem cgf_neg : cgf (-X) μ t = cgf X μ (-t) := by simp_rw [cgf, mgf_neg]
#align probability_theory.cgf_neg ProbabilityTheory.cgf_neg
theorem IndepFun.exp_mul {X Y : Ω → ℝ} (h_indep : IndepFun X Y μ) (s t : ℝ) :
IndepFun (fun ω => exp (s * X ω)) (fun ω => exp (t * Y ω)) μ := by
have h_meas : ∀ t, Measurable fun x => exp (t * x) := fun t => (measurable_id'.const_mul t).exp
change IndepFun ((fun x => exp (s * x)) ∘ X) ((fun x => exp (t * x)) ∘ Y) μ
exact IndepFun.comp h_indep (h_meas s) (h_meas t)
#align probability_theory.indep_fun.exp_mul ProbabilityTheory.IndepFun.exp_mul
theorem IndepFun.mgf_add {X Y : Ω → ℝ} (h_indep : IndepFun X Y μ)
(hX : AEStronglyMeasurable (fun ω => exp (t * X ω)) μ)
(hY : AEStronglyMeasurable (fun ω => exp (t * Y ω)) μ) :
mgf (X + Y) μ t = mgf X μ t * mgf Y μ t := by
simp_rw [mgf, Pi.add_apply, mul_add, exp_add]
exact (h_indep.exp_mul t t).integral_mul hX hY
#align probability_theory.indep_fun.mgf_add ProbabilityTheory.IndepFun.mgf_add
| Mathlib/Probability/Moments.lean | 232 | 239 | theorem IndepFun.mgf_add' {X Y : Ω → ℝ} (h_indep : IndepFun X Y μ) (hX : AEStronglyMeasurable X μ)
(hY : AEStronglyMeasurable Y μ) : mgf (X + Y) μ t = mgf X μ t * mgf Y μ t := by |
have A : Continuous fun x : ℝ => exp (t * x) := by fun_prop
have h'X : AEStronglyMeasurable (fun ω => exp (t * X ω)) μ :=
A.aestronglyMeasurable.comp_aemeasurable hX.aemeasurable
have h'Y : AEStronglyMeasurable (fun ω => exp (t * Y ω)) μ :=
A.aestronglyMeasurable.comp_aemeasurable hY.aemeasurable
exact h_indep.mgf_add h'X h'Y
|
import Mathlib.Algebra.Order.Ring.Defs
import Mathlib.Algebra.Group.Int
import Mathlib.Data.Nat.Dist
import Mathlib.Data.Ordmap.Ordnode
import Mathlib.Tactic.Abel
import Mathlib.Tactic.Linarith
#align_import data.ordmap.ordset from "leanprover-community/mathlib"@"47b51515e69f59bca5cf34ef456e6000fe205a69"
variable {α : Type*}
namespace Ordnode
theorem not_le_delta {s} (H : 1 ≤ s) : ¬s ≤ delta * 0 :=
not_le_of_gt H
#align ordnode.not_le_delta Ordnode.not_le_delta
theorem delta_lt_false {a b : ℕ} (h₁ : delta * a < b) (h₂ : delta * b < a) : False :=
not_le_of_lt (lt_trans ((mul_lt_mul_left (by decide)).2 h₁) h₂) <| by
simpa [mul_assoc] using Nat.mul_le_mul_right a (by decide : 1 ≤ delta * delta)
#align ordnode.delta_lt_false Ordnode.delta_lt_false
def realSize : Ordnode α → ℕ
| nil => 0
| node _ l _ r => realSize l + realSize r + 1
#align ordnode.real_size Ordnode.realSize
def Sized : Ordnode α → Prop
| nil => True
| node s l _ r => s = size l + size r + 1 ∧ Sized l ∧ Sized r
#align ordnode.sized Ordnode.Sized
theorem Sized.node' {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (node' l x r) :=
⟨rfl, hl, hr⟩
#align ordnode.sized.node' Ordnode.Sized.node'
theorem Sized.eq_node' {s l x r} (h : @Sized α (node s l x r)) : node s l x r = .node' l x r := by
rw [h.1]
#align ordnode.sized.eq_node' Ordnode.Sized.eq_node'
theorem Sized.size_eq {s l x r} (H : Sized (@node α s l x r)) :
size (@node α s l x r) = size l + size r + 1 :=
H.1
#align ordnode.sized.size_eq Ordnode.Sized.size_eq
@[elab_as_elim]
theorem Sized.induction {t} (hl : @Sized α t) {C : Ordnode α → Prop} (H0 : C nil)
(H1 : ∀ l x r, C l → C r → C (.node' l x r)) : C t := by
induction t with
| nil => exact H0
| node _ _ _ _ t_ih_l t_ih_r =>
rw [hl.eq_node']
exact H1 _ _ _ (t_ih_l hl.2.1) (t_ih_r hl.2.2)
#align ordnode.sized.induction Ordnode.Sized.induction
theorem size_eq_realSize : ∀ {t : Ordnode α}, Sized t → size t = realSize t
| nil, _ => rfl
| node s l x r, ⟨h₁, h₂, h₃⟩ => by
rw [size, h₁, size_eq_realSize h₂, size_eq_realSize h₃]; rfl
#align ordnode.size_eq_real_size Ordnode.size_eq_realSize
@[simp]
theorem Sized.size_eq_zero {t : Ordnode α} (ht : Sized t) : size t = 0 ↔ t = nil := by
cases t <;> [simp;simp [ht.1]]
#align ordnode.sized.size_eq_zero Ordnode.Sized.size_eq_zero
theorem Sized.pos {s l x r} (h : Sized (@node α s l x r)) : 0 < s := by
rw [h.1]; apply Nat.le_add_left
#align ordnode.sized.pos Ordnode.Sized.pos
theorem dual_dual : ∀ t : Ordnode α, dual (dual t) = t
| nil => rfl
| node s l x r => by rw [dual, dual, dual_dual l, dual_dual r]
#align ordnode.dual_dual Ordnode.dual_dual
@[simp]
theorem size_dual (t : Ordnode α) : size (dual t) = size t := by cases t <;> rfl
#align ordnode.size_dual Ordnode.size_dual
def BalancedSz (l r : ℕ) : Prop :=
l + r ≤ 1 ∨ l ≤ delta * r ∧ r ≤ delta * l
#align ordnode.balanced_sz Ordnode.BalancedSz
instance BalancedSz.dec : DecidableRel BalancedSz := fun _ _ => Or.decidable
#align ordnode.balanced_sz.dec Ordnode.BalancedSz.dec
def Balanced : Ordnode α → Prop
| nil => True
| node _ l _ r => BalancedSz (size l) (size r) ∧ Balanced l ∧ Balanced r
#align ordnode.balanced Ordnode.Balanced
instance Balanced.dec : DecidablePred (@Balanced α)
| nil => by
unfold Balanced
infer_instance
| node _ l _ r => by
unfold Balanced
haveI := Balanced.dec l
haveI := Balanced.dec r
infer_instance
#align ordnode.balanced.dec Ordnode.Balanced.dec
@[symm]
theorem BalancedSz.symm {l r : ℕ} : BalancedSz l r → BalancedSz r l :=
Or.imp (by rw [add_comm]; exact id) And.symm
#align ordnode.balanced_sz.symm Ordnode.BalancedSz.symm
theorem balancedSz_zero {l : ℕ} : BalancedSz l 0 ↔ l ≤ 1 := by
simp (config := { contextual := true }) [BalancedSz]
#align ordnode.balanced_sz_zero Ordnode.balancedSz_zero
theorem balancedSz_up {l r₁ r₂ : ℕ} (h₁ : r₁ ≤ r₂) (h₂ : l + r₂ ≤ 1 ∨ r₂ ≤ delta * l)
(H : BalancedSz l r₁) : BalancedSz l r₂ := by
refine or_iff_not_imp_left.2 fun h => ?_
refine ⟨?_, h₂.resolve_left h⟩
cases H with
| inl H =>
cases r₂
· cases h (le_trans (Nat.add_le_add_left (Nat.zero_le _) _) H)
· exact le_trans (le_trans (Nat.le_add_right _ _) H) (Nat.le_add_left 1 _)
| inr H =>
exact le_trans H.1 (Nat.mul_le_mul_left _ h₁)
#align ordnode.balanced_sz_up Ordnode.balancedSz_up
theorem balancedSz_down {l r₁ r₂ : ℕ} (h₁ : r₁ ≤ r₂) (h₂ : l + r₂ ≤ 1 ∨ l ≤ delta * r₁)
(H : BalancedSz l r₂) : BalancedSz l r₁ :=
have : l + r₂ ≤ 1 → BalancedSz l r₁ := fun H => Or.inl (le_trans (Nat.add_le_add_left h₁ _) H)
Or.casesOn H this fun H => Or.casesOn h₂ this fun h₂ => Or.inr ⟨h₂, le_trans h₁ H.2⟩
#align ordnode.balanced_sz_down Ordnode.balancedSz_down
theorem Balanced.dual : ∀ {t : Ordnode α}, Balanced t → Balanced (dual t)
| nil, _ => ⟨⟩
| node _ l _ r, ⟨b, bl, br⟩ => ⟨by rw [size_dual, size_dual]; exact b.symm, br.dual, bl.dual⟩
#align ordnode.balanced.dual Ordnode.Balanced.dual
def node3L (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : Ordnode α :=
node' (node' l x m) y r
#align ordnode.node3_l Ordnode.node3L
def node3R (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : Ordnode α :=
node' l x (node' m y r)
#align ordnode.node3_r Ordnode.node3R
def node4L : Ordnode α → α → Ordnode α → α → Ordnode α → Ordnode α
| l, x, node _ ml y mr, z, r => node' (node' l x ml) y (node' mr z r)
| l, x, nil, z, r => node3L l x nil z r
#align ordnode.node4_l Ordnode.node4L
-- should not happen
def node4R : Ordnode α → α → Ordnode α → α → Ordnode α → Ordnode α
| l, x, node _ ml y mr, z, r => node' (node' l x ml) y (node' mr z r)
| l, x, nil, z, r => node3R l x nil z r
#align ordnode.node4_r Ordnode.node4R
-- should not happen
def rotateL : Ordnode α → α → Ordnode α → Ordnode α
| l, x, node _ m y r => if size m < ratio * size r then node3L l x m y r else node4L l x m y r
| l, x, nil => node' l x nil
#align ordnode.rotate_l Ordnode.rotateL
-- Porting note (#11467): during the port we marked these lemmas with `@[eqns]`
-- to emulate the old Lean 3 behaviour.
theorem rotateL_node (l : Ordnode α) (x : α) (sz : ℕ) (m : Ordnode α) (y : α) (r : Ordnode α) :
rotateL l x (node sz m y r) =
if size m < ratio * size r then node3L l x m y r else node4L l x m y r :=
rfl
theorem rotateL_nil (l : Ordnode α) (x : α) : rotateL l x nil = node' l x nil :=
rfl
-- should not happen
def rotateR : Ordnode α → α → Ordnode α → Ordnode α
| node _ l x m, y, r => if size m < ratio * size l then node3R l x m y r else node4R l x m y r
| nil, y, r => node' nil y r
#align ordnode.rotate_r Ordnode.rotateR
-- Porting note (#11467): during the port we marked these lemmas with `@[eqns]`
-- to emulate the old Lean 3 behaviour.
theorem rotateR_node (sz : ℕ) (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) :
rotateR (node sz l x m) y r =
if size m < ratio * size l then node3R l x m y r else node4R l x m y r :=
rfl
theorem rotateR_nil (y : α) (r : Ordnode α) : rotateR nil y r = node' nil y r :=
rfl
-- should not happen
def balanceL' (l : Ordnode α) (x : α) (r : Ordnode α) : Ordnode α :=
if size l + size r ≤ 1 then node' l x r
else if size l > delta * size r then rotateR l x r else node' l x r
#align ordnode.balance_l' Ordnode.balanceL'
def balanceR' (l : Ordnode α) (x : α) (r : Ordnode α) : Ordnode α :=
if size l + size r ≤ 1 then node' l x r
else if size r > delta * size l then rotateL l x r else node' l x r
#align ordnode.balance_r' Ordnode.balanceR'
def balance' (l : Ordnode α) (x : α) (r : Ordnode α) : Ordnode α :=
if size l + size r ≤ 1 then node' l x r
else
if size r > delta * size l then rotateL l x r
else if size l > delta * size r then rotateR l x r else node' l x r
#align ordnode.balance' Ordnode.balance'
theorem dual_node' (l : Ordnode α) (x : α) (r : Ordnode α) :
dual (node' l x r) = node' (dual r) x (dual l) := by simp [node', add_comm]
#align ordnode.dual_node' Ordnode.dual_node'
| Mathlib/Data/Ordmap/Ordset.lean | 316 | 318 | theorem dual_node3L (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) :
dual (node3L l x m y r) = node3R (dual r) y (dual m) x (dual l) := by |
simp [node3L, node3R, dual_node', add_comm]
|
import Mathlib.Data.Set.Function
import Mathlib.Analysis.BoundedVariation
#align_import analysis.constant_speed from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
open scoped NNReal ENNReal
open Set MeasureTheory Classical
variable {α : Type*} [LinearOrder α] {E : Type*} [PseudoEMetricSpace E]
variable (f : ℝ → E) (s : Set ℝ) (l : ℝ≥0)
def HasConstantSpeedOnWith :=
∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s), eVariationOn f (s ∩ Icc x y) = ENNReal.ofReal (l * (y - x))
#align has_constant_speed_on_with HasConstantSpeedOnWith
variable {f s l}
theorem HasConstantSpeedOnWith.hasLocallyBoundedVariationOn (h : HasConstantSpeedOnWith f s l) :
LocallyBoundedVariationOn f s := fun x y hx hy => by
simp only [BoundedVariationOn, h hx hy, Ne, ENNReal.ofReal_ne_top, not_false_iff]
#align has_constant_speed_on_with.has_locally_bounded_variation_on HasConstantSpeedOnWith.hasLocallyBoundedVariationOn
theorem hasConstantSpeedOnWith_of_subsingleton (f : ℝ → E) {s : Set ℝ} (hs : s.Subsingleton)
(l : ℝ≥0) : HasConstantSpeedOnWith f s l := by
rintro x hx y hy; cases hs hx hy
rw [eVariationOn.subsingleton f (fun y hy z hz => hs hy.1 hz.1 : (s ∩ Icc x x).Subsingleton)]
simp only [sub_self, mul_zero, ENNReal.ofReal_zero]
#align has_constant_speed_on_with_of_subsingleton hasConstantSpeedOnWith_of_subsingleton
theorem hasConstantSpeedOnWith_iff_ordered :
HasConstantSpeedOnWith f s l ↔ ∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s),
x ≤ y → eVariationOn f (s ∩ Icc x y) = ENNReal.ofReal (l * (y - x)) := by
refine ⟨fun h x xs y ys _ => h xs ys, fun h x xs y ys => ?_⟩
rcases le_total x y with (xy | yx)
· exact h xs ys xy
· rw [eVariationOn.subsingleton, ENNReal.ofReal_of_nonpos]
· exact mul_nonpos_of_nonneg_of_nonpos l.prop (sub_nonpos_of_le yx)
· rintro z ⟨zs, xz, zy⟩ w ⟨ws, xw, wy⟩
cases le_antisymm (zy.trans yx) xz
cases le_antisymm (wy.trans yx) xw
rfl
#align has_constant_speed_on_with_iff_ordered hasConstantSpeedOnWith_iff_ordered
theorem hasConstantSpeedOnWith_iff_variationOnFromTo_eq :
HasConstantSpeedOnWith f s l ↔ LocallyBoundedVariationOn f s ∧
∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s), variationOnFromTo f s x y = l * (y - x) := by
constructor
· rintro h; refine ⟨h.hasLocallyBoundedVariationOn, fun x xs y ys => ?_⟩
rw [hasConstantSpeedOnWith_iff_ordered] at h
rcases le_total x y with (xy | yx)
· rw [variationOnFromTo.eq_of_le f s xy, h xs ys xy]
exact ENNReal.toReal_ofReal (mul_nonneg l.prop (sub_nonneg.mpr xy))
· rw [variationOnFromTo.eq_of_ge f s yx, h ys xs yx]
have := ENNReal.toReal_ofReal (mul_nonneg l.prop (sub_nonneg.mpr yx))
simp_all only [NNReal.val_eq_coe]; ring
· rw [hasConstantSpeedOnWith_iff_ordered]
rintro h x xs y ys xy
rw [← h.2 xs ys, variationOnFromTo.eq_of_le f s xy, ENNReal.ofReal_toReal (h.1 x y xs ys)]
#align has_constant_speed_on_with_iff_variation_on_from_to_eq hasConstantSpeedOnWith_iff_variationOnFromTo_eq
theorem HasConstantSpeedOnWith.union {t : Set ℝ} (hfs : HasConstantSpeedOnWith f s l)
(hft : HasConstantSpeedOnWith f t l) {x : ℝ} (hs : IsGreatest s x) (ht : IsLeast t x) :
HasConstantSpeedOnWith f (s ∪ t) l := by
rw [hasConstantSpeedOnWith_iff_ordered] at hfs hft ⊢
rintro z (zs | zt) y (ys | yt) zy
· have : (s ∪ t) ∩ Icc z y = s ∩ Icc z y := by
ext w; constructor
· rintro ⟨ws | wt, zw, wy⟩
· exact ⟨ws, zw, wy⟩
· exact ⟨(le_antisymm (wy.trans (hs.2 ys)) (ht.2 wt)).symm ▸ hs.1, zw, wy⟩
· rintro ⟨ws, zwy⟩; exact ⟨Or.inl ws, zwy⟩
rw [this, hfs zs ys zy]
· have : (s ∪ t) ∩ Icc z y = s ∩ Icc z x ∪ t ∩ Icc x y := by
ext w; constructor
· rintro ⟨ws | wt, zw, wy⟩
exacts [Or.inl ⟨ws, zw, hs.2 ws⟩, Or.inr ⟨wt, ht.2 wt, wy⟩]
· rintro (⟨ws, zw, wx⟩ | ⟨wt, xw, wy⟩)
exacts [⟨Or.inl ws, zw, wx.trans (ht.2 yt)⟩, ⟨Or.inr wt, (hs.2 zs).trans xw, wy⟩]
rw [this, @eVariationOn.union _ _ _ _ f _ _ x, hfs zs hs.1 (hs.2 zs), hft ht.1 yt (ht.2 yt)]
· have q := ENNReal.ofReal_add (mul_nonneg l.prop (sub_nonneg.mpr (hs.2 zs)))
(mul_nonneg l.prop (sub_nonneg.mpr (ht.2 yt)))
simp only [NNReal.val_eq_coe] at q
rw [← q]
ring_nf
exacts [⟨⟨hs.1, hs.2 zs, le_rfl⟩, fun w ⟨_, _, wx⟩ => wx⟩,
⟨⟨ht.1, le_rfl, ht.2 yt⟩, fun w ⟨_, xw, _⟩ => xw⟩]
· cases le_antisymm zy ((hs.2 ys).trans (ht.2 zt))
simp only [Icc_self, sub_self, mul_zero, ENNReal.ofReal_zero]
exact eVariationOn.subsingleton _ fun _ ⟨_, uz⟩ _ ⟨_, vz⟩ => uz.trans vz.symm
· have : (s ∪ t) ∩ Icc z y = t ∩ Icc z y := by
ext w; constructor
· rintro ⟨ws | wt, zw, wy⟩
· exact ⟨le_antisymm ((ht.2 zt).trans zw) (hs.2 ws) ▸ ht.1, zw, wy⟩
· exact ⟨wt, zw, wy⟩
· rintro ⟨wt, zwy⟩; exact ⟨Or.inr wt, zwy⟩
rw [this, hft zt yt zy]
#align has_constant_speed_on_with.union HasConstantSpeedOnWith.union
theorem HasConstantSpeedOnWith.Icc_Icc {x y z : ℝ} (hfs : HasConstantSpeedOnWith f (Icc x y) l)
(hft : HasConstantSpeedOnWith f (Icc y z) l) : HasConstantSpeedOnWith f (Icc x z) l := by
rcases le_total x y with (xy | yx)
· rcases le_total y z with (yz | zy)
· rw [← Set.Icc_union_Icc_eq_Icc xy yz]
exact hfs.union hft (isGreatest_Icc xy) (isLeast_Icc yz)
· rintro u ⟨xu, uz⟩ v ⟨xv, vz⟩
rw [Icc_inter_Icc, sup_of_le_right xu, inf_of_le_right vz, ←
hfs ⟨xu, uz.trans zy⟩ ⟨xv, vz.trans zy⟩, Icc_inter_Icc, sup_of_le_right xu,
inf_of_le_right (vz.trans zy)]
· rintro u ⟨xu, uz⟩ v ⟨xv, vz⟩
rw [Icc_inter_Icc, sup_of_le_right xu, inf_of_le_right vz, ←
hft ⟨yx.trans xu, uz⟩ ⟨yx.trans xv, vz⟩, Icc_inter_Icc, sup_of_le_right (yx.trans xu),
inf_of_le_right vz]
#align has_constant_speed_on_with.Icc_Icc HasConstantSpeedOnWith.Icc_Icc
theorem hasConstantSpeedOnWith_zero_iff :
HasConstantSpeedOnWith f s 0 ↔ ∀ᵉ (x ∈ s) (y ∈ s), edist (f x) (f y) = 0 := by
dsimp [HasConstantSpeedOnWith]
simp only [zero_mul, ENNReal.ofReal_zero, ← eVariationOn.eq_zero_iff]
constructor
· by_contra!
obtain ⟨h, hfs⟩ := this
simp_rw [ne_eq, eVariationOn.eq_zero_iff] at hfs h
push_neg at hfs
obtain ⟨x, xs, y, ys, hxy⟩ := hfs
rcases le_total x y with (xy | yx)
· exact hxy (h xs ys x ⟨xs, le_rfl, xy⟩ y ⟨ys, xy, le_rfl⟩)
· rw [edist_comm] at hxy
exact hxy (h ys xs y ⟨ys, le_rfl, yx⟩ x ⟨xs, yx, le_rfl⟩)
· rintro h x _ y _
refine le_antisymm ?_ zero_le'
rw [← h]
exact eVariationOn.mono f inter_subset_left
#align has_constant_speed_on_with_zero_iff hasConstantSpeedOnWith_zero_iff
theorem HasConstantSpeedOnWith.ratio {l' : ℝ≥0} (hl' : l' ≠ 0) {φ : ℝ → ℝ} (φm : MonotoneOn φ s)
(hfφ : HasConstantSpeedOnWith (f ∘ φ) s l) (hf : HasConstantSpeedOnWith f (φ '' s) l') ⦃x : ℝ⦄
(xs : x ∈ s) : EqOn φ (fun y => l / l' * (y - x) + φ x) s := by
rintro y ys
rw [← sub_eq_iff_eq_add, mul_comm, ← mul_div_assoc, eq_div_iff (NNReal.coe_ne_zero.mpr hl')]
rw [hasConstantSpeedOnWith_iff_variationOnFromTo_eq] at hf
rw [hasConstantSpeedOnWith_iff_variationOnFromTo_eq] at hfφ
symm
calc
(y - x) * l = l * (y - x) := by rw [mul_comm]
_ = variationOnFromTo (f ∘ φ) s x y := (hfφ.2 xs ys).symm
_ = variationOnFromTo f (φ '' s) (φ x) (φ y) :=
(variationOnFromTo.comp_eq_of_monotoneOn f φ φm xs ys)
_ = l' * (φ y - φ x) := (hf.2 ⟨x, xs, rfl⟩ ⟨y, ys, rfl⟩)
_ = (φ y - φ x) * l' := by rw [mul_comm]
#align has_constant_speed_on_with.ratio HasConstantSpeedOnWith.ratio
def HasUnitSpeedOn (f : ℝ → E) (s : Set ℝ) :=
HasConstantSpeedOnWith f s 1
#align has_unit_speed_on HasUnitSpeedOn
theorem HasUnitSpeedOn.union {t : Set ℝ} {x : ℝ} (hfs : HasUnitSpeedOn f s)
(hft : HasUnitSpeedOn f t) (hs : IsGreatest s x) (ht : IsLeast t x) :
HasUnitSpeedOn f (s ∪ t) :=
HasConstantSpeedOnWith.union hfs hft hs ht
#align has_unit_speed_on.union HasUnitSpeedOn.union
theorem HasUnitSpeedOn.Icc_Icc {x y z : ℝ} (hfs : HasUnitSpeedOn f (Icc x y))
(hft : HasUnitSpeedOn f (Icc y z)) : HasUnitSpeedOn f (Icc x z) :=
HasConstantSpeedOnWith.Icc_Icc hfs hft
#align has_unit_speed_on.Icc_Icc HasUnitSpeedOn.Icc_Icc
theorem unique_unit_speed {φ : ℝ → ℝ} (φm : MonotoneOn φ s) (hfφ : HasUnitSpeedOn (f ∘ φ) s)
(hf : HasUnitSpeedOn f (φ '' s)) ⦃x : ℝ⦄ (xs : x ∈ s) : EqOn φ (fun y => y - x + φ x) s := by
dsimp only [HasUnitSpeedOn] at hf hfφ
convert HasConstantSpeedOnWith.ratio one_ne_zero φm hfφ hf xs using 3
norm_num
#align unique_unit_speed unique_unit_speed
| Mathlib/Analysis/ConstantSpeed.lean | 222 | 235 | theorem unique_unit_speed_on_Icc_zero {s t : ℝ} (hs : 0 ≤ s) (ht : 0 ≤ t) {φ : ℝ → ℝ}
(φm : MonotoneOn φ <| Icc 0 s) (φst : φ '' Icc 0 s = Icc 0 t)
(hfφ : HasUnitSpeedOn (f ∘ φ) (Icc 0 s)) (hf : HasUnitSpeedOn f (Icc 0 t)) :
EqOn φ id (Icc 0 s) := by |
rw [← φst] at hf
convert unique_unit_speed φm hfφ hf ⟨le_rfl, hs⟩ using 1
have : φ 0 = 0 := by
have hm : 0 ∈ φ '' Icc 0 s := by simp only [φst, ht, mem_Icc, le_refl, and_self]
obtain ⟨x, xs, hx⟩ := hm
apply le_antisymm ((φm ⟨le_rfl, hs⟩ xs xs.1).trans_eq hx) _
have := φst ▸ mapsTo_image φ (Icc 0 s)
exact (mem_Icc.mp (@this 0 (by rw [mem_Icc]; exact ⟨le_rfl, hs⟩))).1
simp only [tsub_zero, this, add_zero]
rfl
|
import Mathlib.Algebra.Group.Pi.Lemmas
import Mathlib.Topology.Algebra.Monoid
import Mathlib.Topology.Homeomorph
#align_import topology.algebra.group_with_zero from "leanprover-community/mathlib"@"c10e724be91096453ee3db13862b9fb9a992fef2"
open Topology Filter Function
variable {α β G₀ : Type*}
section DivConst
variable [DivInvMonoid G₀] [TopologicalSpace G₀] [ContinuousMul G₀] {f : α → G₀} {s : Set α}
{l : Filter α}
theorem Filter.Tendsto.div_const {x : G₀} (hf : Tendsto f l (𝓝 x)) (y : G₀) :
Tendsto (fun a => f a / y) l (𝓝 (x / y)) := by
simpa only [div_eq_mul_inv] using hf.mul tendsto_const_nhds
#align filter.tendsto.div_const Filter.Tendsto.div_const
variable [TopologicalSpace α]
nonrec theorem ContinuousAt.div_const {a : α} (hf : ContinuousAt f a) (y : G₀) :
ContinuousAt (fun x => f x / y) a :=
hf.div_const y
#align continuous_at.div_const ContinuousAt.div_const
nonrec theorem ContinuousWithinAt.div_const {a} (hf : ContinuousWithinAt f s a) (y : G₀) :
ContinuousWithinAt (fun x => f x / y) s a :=
hf.div_const _
#align continuous_within_at.div_const ContinuousWithinAt.div_const
| Mathlib/Topology/Algebra/GroupWithZero.lean | 69 | 71 | theorem ContinuousOn.div_const (hf : ContinuousOn f s) (y : G₀) :
ContinuousOn (fun x => f x / y) s := by |
simpa only [div_eq_mul_inv] using hf.mul continuousOn_const
|
import Mathlib.Dynamics.Ergodic.MeasurePreserving
import Mathlib.MeasureTheory.Function.SimpleFunc
import Mathlib.MeasureTheory.Measure.MutuallySingular
import Mathlib.MeasureTheory.Measure.Count
import Mathlib.Topology.IndicatorConstPointwise
import Mathlib.MeasureTheory.Constructions.BorelSpace.Real
#align_import measure_theory.integral.lebesgue from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"
assert_not_exists NormedSpace
set_option autoImplicit true
noncomputable section
open Set hiding restrict restrict_apply
open Filter ENNReal
open Function (support)
open scoped Classical
open Topology NNReal ENNReal MeasureTheory
namespace MeasureTheory
local infixr:25 " →ₛ " => SimpleFunc
variable {α β γ δ : Type*}
section Lintegral
open SimpleFunc
variable {m : MeasurableSpace α} {μ ν : Measure α}
irreducible_def lintegral {_ : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) : ℝ≥0∞ :=
⨆ (g : α →ₛ ℝ≥0∞) (_ : ⇑g ≤ f), g.lintegral μ
#align measure_theory.lintegral MeasureTheory.lintegral
@[inherit_doc MeasureTheory.lintegral]
notation3 "∫⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => lintegral μ r
@[inherit_doc MeasureTheory.lintegral]
notation3 "∫⁻ "(...)", "r:60:(scoped f => lintegral volume f) => r
@[inherit_doc MeasureTheory.lintegral]
notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => lintegral (Measure.restrict μ s) r
@[inherit_doc MeasureTheory.lintegral]
notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => lintegral (Measure.restrict volume s) f) => r
theorem SimpleFunc.lintegral_eq_lintegral {m : MeasurableSpace α} (f : α →ₛ ℝ≥0∞) (μ : Measure α) :
∫⁻ a, f a ∂μ = f.lintegral μ := by
rw [MeasureTheory.lintegral]
exact le_antisymm (iSup₂_le fun g hg => lintegral_mono hg <| le_rfl)
(le_iSup₂_of_le f le_rfl le_rfl)
#align measure_theory.simple_func.lintegral_eq_lintegral MeasureTheory.SimpleFunc.lintegral_eq_lintegral
@[mono]
theorem lintegral_mono' {m : MeasurableSpace α} ⦃μ ν : Measure α⦄ (hμν : μ ≤ ν) ⦃f g : α → ℝ≥0∞⦄
(hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂ν := by
rw [lintegral, lintegral]
exact iSup_mono fun φ => iSup_mono' fun hφ => ⟨le_trans hφ hfg, lintegral_mono (le_refl φ) hμν⟩
#align measure_theory.lintegral_mono' MeasureTheory.lintegral_mono'
-- workaround for the known eta-reduction issue with `@[gcongr]`
@[gcongr] theorem lintegral_mono_fn' ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) (h2 : μ ≤ ν) :
lintegral μ f ≤ lintegral ν g :=
lintegral_mono' h2 hfg
theorem lintegral_mono ⦃f g : α → ℝ≥0∞⦄ (hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ :=
lintegral_mono' (le_refl μ) hfg
#align measure_theory.lintegral_mono MeasureTheory.lintegral_mono
-- workaround for the known eta-reduction issue with `@[gcongr]`
@[gcongr] theorem lintegral_mono_fn ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) :
lintegral μ f ≤ lintegral μ g :=
lintegral_mono hfg
theorem lintegral_mono_nnreal {f g : α → ℝ≥0} (h : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ :=
lintegral_mono fun a => ENNReal.coe_le_coe.2 (h a)
#align measure_theory.lintegral_mono_nnreal MeasureTheory.lintegral_mono_nnreal
theorem iSup_lintegral_measurable_le_eq_lintegral (f : α → ℝ≥0∞) :
⨆ (g : α → ℝ≥0∞) (_ : Measurable g) (_ : g ≤ f), ∫⁻ a, g a ∂μ = ∫⁻ a, f a ∂μ := by
apply le_antisymm
· exact iSup_le fun i => iSup_le fun _ => iSup_le fun h'i => lintegral_mono h'i
· rw [lintegral]
refine iSup₂_le fun i hi => le_iSup₂_of_le i i.measurable <| le_iSup_of_le hi ?_
exact le_of_eq (i.lintegral_eq_lintegral _).symm
#align measure_theory.supr_lintegral_measurable_le_eq_lintegral MeasureTheory.iSup_lintegral_measurable_le_eq_lintegral
theorem lintegral_mono_set {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞}
(hst : s ⊆ t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ :=
lintegral_mono' (Measure.restrict_mono hst (le_refl μ)) (le_refl f)
#align measure_theory.lintegral_mono_set MeasureTheory.lintegral_mono_set
theorem lintegral_mono_set' {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞}
(hst : s ≤ᵐ[μ] t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ :=
lintegral_mono' (Measure.restrict_mono' hst (le_refl μ)) (le_refl f)
#align measure_theory.lintegral_mono_set' MeasureTheory.lintegral_mono_set'
theorem monotone_lintegral {_ : MeasurableSpace α} (μ : Measure α) : Monotone (lintegral μ) :=
lintegral_mono
#align measure_theory.monotone_lintegral MeasureTheory.monotone_lintegral
@[simp]
theorem lintegral_const (c : ℝ≥0∞) : ∫⁻ _, c ∂μ = c * μ univ := by
rw [← SimpleFunc.const_lintegral, ← SimpleFunc.lintegral_eq_lintegral, SimpleFunc.coe_const]
rfl
#align measure_theory.lintegral_const MeasureTheory.lintegral_const
theorem lintegral_zero : ∫⁻ _ : α, 0 ∂μ = 0 := by simp
#align measure_theory.lintegral_zero MeasureTheory.lintegral_zero
theorem lintegral_zero_fun : lintegral μ (0 : α → ℝ≥0∞) = 0 :=
lintegral_zero
#align measure_theory.lintegral_zero_fun MeasureTheory.lintegral_zero_fun
-- @[simp] -- Porting note (#10618): simp can prove this
theorem lintegral_one : ∫⁻ _, (1 : ℝ≥0∞) ∂μ = μ univ := by rw [lintegral_const, one_mul]
#align measure_theory.lintegral_one MeasureTheory.lintegral_one
theorem set_lintegral_const (s : Set α) (c : ℝ≥0∞) : ∫⁻ _ in s, c ∂μ = c * μ s := by
rw [lintegral_const, Measure.restrict_apply_univ]
#align measure_theory.set_lintegral_const MeasureTheory.set_lintegral_const
theorem set_lintegral_one (s) : ∫⁻ _ in s, 1 ∂μ = μ s := by rw [set_lintegral_const, one_mul]
#align measure_theory.set_lintegral_one MeasureTheory.set_lintegral_one
theorem set_lintegral_const_lt_top [IsFiniteMeasure μ] (s : Set α) {c : ℝ≥0∞} (hc : c ≠ ∞) :
∫⁻ _ in s, c ∂μ < ∞ := by
rw [lintegral_const]
exact ENNReal.mul_lt_top hc (measure_ne_top (μ.restrict s) univ)
#align measure_theory.set_lintegral_const_lt_top MeasureTheory.set_lintegral_const_lt_top
theorem lintegral_const_lt_top [IsFiniteMeasure μ] {c : ℝ≥0∞} (hc : c ≠ ∞) : ∫⁻ _, c ∂μ < ∞ := by
simpa only [Measure.restrict_univ] using set_lintegral_const_lt_top (univ : Set α) hc
#align measure_theory.lintegral_const_lt_top MeasureTheory.lintegral_const_lt_top
section
variable (μ)
theorem exists_measurable_le_lintegral_eq (f : α → ℝ≥0∞) :
∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := by
rcases eq_or_ne (∫⁻ a, f a ∂μ) 0 with h₀ | h₀
· exact ⟨0, measurable_zero, zero_le f, h₀.trans lintegral_zero.symm⟩
rcases exists_seq_strictMono_tendsto' h₀.bot_lt with ⟨L, _, hLf, hL_tendsto⟩
have : ∀ n, ∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ L n < ∫⁻ a, g a ∂μ := by
intro n
simpa only [← iSup_lintegral_measurable_le_eq_lintegral f, lt_iSup_iff, exists_prop] using
(hLf n).2
choose g hgm hgf hLg using this
refine
⟨fun x => ⨆ n, g n x, measurable_iSup hgm, fun x => iSup_le fun n => hgf n x, le_antisymm ?_ ?_⟩
· refine le_of_tendsto' hL_tendsto fun n => (hLg n).le.trans <| lintegral_mono fun x => ?_
exact le_iSup (fun n => g n x) n
· exact lintegral_mono fun x => iSup_le fun n => hgf n x
#align measure_theory.exists_measurable_le_lintegral_eq MeasureTheory.exists_measurable_le_lintegral_eq
end
theorem lintegral_eq_nnreal {m : MeasurableSpace α} (f : α → ℝ≥0∞) (μ : Measure α) :
∫⁻ a, f a ∂μ =
⨆ (φ : α →ₛ ℝ≥0) (_ : ∀ x, ↑(φ x) ≤ f x), (φ.map ((↑) : ℝ≥0 → ℝ≥0∞)).lintegral μ := by
rw [lintegral]
refine
le_antisymm (iSup₂_le fun φ hφ => ?_) (iSup_mono' fun φ => ⟨φ.map ((↑) : ℝ≥0 → ℝ≥0∞), le_rfl⟩)
by_cases h : ∀ᵐ a ∂μ, φ a ≠ ∞
· let ψ := φ.map ENNReal.toNNReal
replace h : ψ.map ((↑) : ℝ≥0 → ℝ≥0∞) =ᵐ[μ] φ := h.mono fun a => ENNReal.coe_toNNReal
have : ∀ x, ↑(ψ x) ≤ f x := fun x => le_trans ENNReal.coe_toNNReal_le_self (hφ x)
exact
le_iSup_of_le (φ.map ENNReal.toNNReal) (le_iSup_of_le this (ge_of_eq <| lintegral_congr h))
· have h_meas : μ (φ ⁻¹' {∞}) ≠ 0 := mt measure_zero_iff_ae_nmem.1 h
refine le_trans le_top (ge_of_eq <| (iSup_eq_top _).2 fun b hb => ?_)
obtain ⟨n, hn⟩ : ∃ n : ℕ, b < n * μ (φ ⁻¹' {∞}) := exists_nat_mul_gt h_meas (ne_of_lt hb)
use (const α (n : ℝ≥0)).restrict (φ ⁻¹' {∞})
simp only [lt_iSup_iff, exists_prop, coe_restrict, φ.measurableSet_preimage, coe_const,
ENNReal.coe_indicator, map_coe_ennreal_restrict, SimpleFunc.map_const, ENNReal.coe_natCast,
restrict_const_lintegral]
refine ⟨indicator_le fun x hx => le_trans ?_ (hφ _), hn⟩
simp only [mem_preimage, mem_singleton_iff] at hx
simp only [hx, le_top]
#align measure_theory.lintegral_eq_nnreal MeasureTheory.lintegral_eq_nnreal
theorem exists_simpleFunc_forall_lintegral_sub_lt_of_pos {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞)
{ε : ℝ≥0∞} (hε : ε ≠ 0) :
∃ φ : α →ₛ ℝ≥0,
(∀ x, ↑(φ x) ≤ f x) ∧
∀ ψ : α →ₛ ℝ≥0, (∀ x, ↑(ψ x) ≤ f x) → (map (↑) (ψ - φ)).lintegral μ < ε := by
rw [lintegral_eq_nnreal] at h
have := ENNReal.lt_add_right h hε
erw [ENNReal.biSup_add] at this <;> [skip; exact ⟨0, fun x => zero_le _⟩]
simp_rw [lt_iSup_iff, iSup_lt_iff, iSup_le_iff] at this
rcases this with ⟨φ, hle : ∀ x, ↑(φ x) ≤ f x, b, hbφ, hb⟩
refine ⟨φ, hle, fun ψ hψ => ?_⟩
have : (map (↑) φ).lintegral μ ≠ ∞ := ne_top_of_le_ne_top h (by exact le_iSup₂ (α := ℝ≥0∞) φ hle)
rw [← ENNReal.add_lt_add_iff_left this, ← add_lintegral, ← SimpleFunc.map_add @ENNReal.coe_add]
refine (hb _ fun x => le_trans ?_ (max_le (hle x) (hψ x))).trans_lt hbφ
norm_cast
simp only [add_apply, sub_apply, add_tsub_eq_max]
rfl
#align measure_theory.exists_simple_func_forall_lintegral_sub_lt_of_pos MeasureTheory.exists_simpleFunc_forall_lintegral_sub_lt_of_pos
theorem iSup_lintegral_le {ι : Sort*} (f : ι → α → ℝ≥0∞) :
⨆ i, ∫⁻ a, f i a ∂μ ≤ ∫⁻ a, ⨆ i, f i a ∂μ := by
simp only [← iSup_apply]
exact (monotone_lintegral μ).le_map_iSup
#align measure_theory.supr_lintegral_le MeasureTheory.iSup_lintegral_le
theorem iSup₂_lintegral_le {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) :
⨆ (i) (j), ∫⁻ a, f i j a ∂μ ≤ ∫⁻ a, ⨆ (i) (j), f i j a ∂μ := by
convert (monotone_lintegral μ).le_map_iSup₂ f with a
simp only [iSup_apply]
#align measure_theory.supr₂_lintegral_le MeasureTheory.iSup₂_lintegral_le
theorem le_iInf_lintegral {ι : Sort*} (f : ι → α → ℝ≥0∞) :
∫⁻ a, ⨅ i, f i a ∂μ ≤ ⨅ i, ∫⁻ a, f i a ∂μ := by
simp only [← iInf_apply]
exact (monotone_lintegral μ).map_iInf_le
#align measure_theory.le_infi_lintegral MeasureTheory.le_iInf_lintegral
theorem le_iInf₂_lintegral {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) :
∫⁻ a, ⨅ (i) (h : ι' i), f i h a ∂μ ≤ ⨅ (i) (h : ι' i), ∫⁻ a, f i h a ∂μ := by
convert (monotone_lintegral μ).map_iInf₂_le f with a
simp only [iInf_apply]
#align measure_theory.le_infi₂_lintegral MeasureTheory.le_iInf₂_lintegral
theorem lintegral_mono_ae {f g : α → ℝ≥0∞} (h : ∀ᵐ a ∂μ, f a ≤ g a) :
∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := by
rcases exists_measurable_superset_of_null h with ⟨t, hts, ht, ht0⟩
have : ∀ᵐ x ∂μ, x ∉ t := measure_zero_iff_ae_nmem.1 ht0
rw [lintegral, lintegral]
refine iSup_le fun s => iSup_le fun hfs => le_iSup_of_le (s.restrict tᶜ) <| le_iSup_of_le ?_ ?_
· intro a
by_cases h : a ∈ t <;>
simp only [restrict_apply s ht.compl, mem_compl_iff, h, not_true, not_false_eq_true,
indicator_of_not_mem, zero_le, not_false_eq_true, indicator_of_mem]
exact le_trans (hfs a) (_root_.by_contradiction fun hnfg => h (hts hnfg))
· refine le_of_eq (SimpleFunc.lintegral_congr <| this.mono fun a hnt => ?_)
by_cases hat : a ∈ t <;> simp only [restrict_apply s ht.compl, mem_compl_iff, hat, not_true,
not_false_eq_true, indicator_of_not_mem, not_false_eq_true, indicator_of_mem]
exact (hnt hat).elim
#align measure_theory.lintegral_mono_ae MeasureTheory.lintegral_mono_ae
theorem set_lintegral_mono_ae {s : Set α} {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g)
(hfg : ∀ᵐ x ∂μ, x ∈ s → f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ :=
lintegral_mono_ae <| (ae_restrict_iff <| measurableSet_le hf hg).2 hfg
#align measure_theory.set_lintegral_mono_ae MeasureTheory.set_lintegral_mono_ae
theorem set_lintegral_mono {s : Set α} {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g)
(hfg : ∀ x ∈ s, f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ :=
set_lintegral_mono_ae hf hg (ae_of_all _ hfg)
#align measure_theory.set_lintegral_mono MeasureTheory.set_lintegral_mono
theorem set_lintegral_mono_ae' {s : Set α} {f g : α → ℝ≥0∞} (hs : MeasurableSet s)
(hfg : ∀ᵐ x ∂μ, x ∈ s → f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ :=
lintegral_mono_ae <| (ae_restrict_iff' hs).2 hfg
theorem set_lintegral_mono' {s : Set α} {f g : α → ℝ≥0∞} (hs : MeasurableSet s)
(hfg : ∀ x ∈ s, f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ :=
set_lintegral_mono_ae' hs (ae_of_all _ hfg)
theorem set_lintegral_le_lintegral (s : Set α) (f : α → ℝ≥0∞) :
∫⁻ x in s, f x ∂μ ≤ ∫⁻ x, f x ∂μ :=
lintegral_mono' Measure.restrict_le_self le_rfl
theorem lintegral_congr_ae {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) : ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ :=
le_antisymm (lintegral_mono_ae <| h.le) (lintegral_mono_ae <| h.symm.le)
#align measure_theory.lintegral_congr_ae MeasureTheory.lintegral_congr_ae
theorem lintegral_congr {f g : α → ℝ≥0∞} (h : ∀ a, f a = g a) : ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := by
simp only [h]
#align measure_theory.lintegral_congr MeasureTheory.lintegral_congr
theorem set_lintegral_congr {f : α → ℝ≥0∞} {s t : Set α} (h : s =ᵐ[μ] t) :
∫⁻ x in s, f x ∂μ = ∫⁻ x in t, f x ∂μ := by rw [Measure.restrict_congr_set h]
#align measure_theory.set_lintegral_congr MeasureTheory.set_lintegral_congr
theorem set_lintegral_congr_fun {f g : α → ℝ≥0∞} {s : Set α} (hs : MeasurableSet s)
(hfg : ∀ᵐ x ∂μ, x ∈ s → f x = g x) : ∫⁻ x in s, f x ∂μ = ∫⁻ x in s, g x ∂μ := by
rw [lintegral_congr_ae]
rw [EventuallyEq]
rwa [ae_restrict_iff' hs]
#align measure_theory.set_lintegral_congr_fun MeasureTheory.set_lintegral_congr_fun
theorem lintegral_ofReal_le_lintegral_nnnorm (f : α → ℝ) :
∫⁻ x, ENNReal.ofReal (f x) ∂μ ≤ ∫⁻ x, ‖f x‖₊ ∂μ := by
simp_rw [← ofReal_norm_eq_coe_nnnorm]
refine lintegral_mono fun x => ENNReal.ofReal_le_ofReal ?_
rw [Real.norm_eq_abs]
exact le_abs_self (f x)
#align measure_theory.lintegral_of_real_le_lintegral_nnnorm MeasureTheory.lintegral_ofReal_le_lintegral_nnnorm
theorem lintegral_nnnorm_eq_of_ae_nonneg {f : α → ℝ} (h_nonneg : 0 ≤ᵐ[μ] f) :
∫⁻ x, ‖f x‖₊ ∂μ = ∫⁻ x, ENNReal.ofReal (f x) ∂μ := by
apply lintegral_congr_ae
filter_upwards [h_nonneg] with x hx
rw [Real.nnnorm_of_nonneg hx, ENNReal.ofReal_eq_coe_nnreal hx]
#align measure_theory.lintegral_nnnorm_eq_of_ae_nonneg MeasureTheory.lintegral_nnnorm_eq_of_ae_nonneg
theorem lintegral_nnnorm_eq_of_nonneg {f : α → ℝ} (h_nonneg : 0 ≤ f) :
∫⁻ x, ‖f x‖₊ ∂μ = ∫⁻ x, ENNReal.ofReal (f x) ∂μ :=
lintegral_nnnorm_eq_of_ae_nonneg (Filter.eventually_of_forall h_nonneg)
#align measure_theory.lintegral_nnnorm_eq_of_nonneg MeasureTheory.lintegral_nnnorm_eq_of_nonneg
theorem lintegral_iSup {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, Measurable (f n)) (h_mono : Monotone f) :
∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by
set c : ℝ≥0 → ℝ≥0∞ := (↑)
set F := fun a : α => ⨆ n, f n a
refine le_antisymm ?_ (iSup_lintegral_le _)
rw [lintegral_eq_nnreal]
refine iSup_le fun s => iSup_le fun hsf => ?_
refine ENNReal.le_of_forall_lt_one_mul_le fun a ha => ?_
rcases ENNReal.lt_iff_exists_coe.1 ha with ⟨r, rfl, _⟩
have ha : r < 1 := ENNReal.coe_lt_coe.1 ha
let rs := s.map fun a => r * a
have eq_rs : rs.map c = (const α r : α →ₛ ℝ≥0∞) * map c s := rfl
have eq : ∀ p, rs.map c ⁻¹' {p} = ⋃ n, rs.map c ⁻¹' {p} ∩ { a | p ≤ f n a } := by
intro p
rw [← inter_iUnion]; nth_rw 1 [← inter_univ (map c rs ⁻¹' {p})]
refine Set.ext fun x => and_congr_right fun hx => true_iff_iff.2 ?_
by_cases p_eq : p = 0
· simp [p_eq]
simp only [coe_map, mem_preimage, Function.comp_apply, mem_singleton_iff] at hx
subst hx
have : r * s x ≠ 0 := by rwa [Ne, ← ENNReal.coe_eq_zero]
have : s x ≠ 0 := right_ne_zero_of_mul this
have : (rs.map c) x < ⨆ n : ℕ, f n x := by
refine lt_of_lt_of_le (ENNReal.coe_lt_coe.2 ?_) (hsf x)
suffices r * s x < 1 * s x by simpa
exact mul_lt_mul_of_pos_right ha (pos_iff_ne_zero.2 this)
rcases lt_iSup_iff.1 this with ⟨i, hi⟩
exact mem_iUnion.2 ⟨i, le_of_lt hi⟩
have mono : ∀ r : ℝ≥0∞, Monotone fun n => rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a } := by
intro r i j h
refine inter_subset_inter_right _ ?_
simp_rw [subset_def, mem_setOf]
intro x hx
exact le_trans hx (h_mono h x)
have h_meas : ∀ n, MeasurableSet {a : α | map c rs a ≤ f n a} := fun n =>
measurableSet_le (SimpleFunc.measurable _) (hf n)
calc
(r : ℝ≥0∞) * (s.map c).lintegral μ = ∑ r ∈ (rs.map c).range, r * μ (rs.map c ⁻¹' {r}) := by
rw [← const_mul_lintegral, eq_rs, SimpleFunc.lintegral]
_ = ∑ r ∈ (rs.map c).range, r * μ (⋃ n, rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := by
simp only [(eq _).symm]
_ = ∑ r ∈ (rs.map c).range, ⨆ n, r * μ (rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) :=
(Finset.sum_congr rfl fun x _ => by
rw [measure_iUnion_eq_iSup (mono x).directed_le, ENNReal.mul_iSup])
_ = ⨆ n, ∑ r ∈ (rs.map c).range, r * μ (rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := by
refine ENNReal.finset_sum_iSup_nat fun p i j h ↦ ?_
gcongr _ * μ ?_
exact mono p h
_ ≤ ⨆ n : ℕ, ((rs.map c).restrict { a | (rs.map c) a ≤ f n a }).lintegral μ := by
gcongr with n
rw [restrict_lintegral _ (h_meas n)]
refine le_of_eq (Finset.sum_congr rfl fun r _ => ?_)
congr 2 with a
refine and_congr_right ?_
simp (config := { contextual := true })
_ ≤ ⨆ n, ∫⁻ a, f n a ∂μ := by
simp only [← SimpleFunc.lintegral_eq_lintegral]
gcongr with n a
simp only [map_apply] at h_meas
simp only [coe_map, restrict_apply _ (h_meas _), (· ∘ ·)]
exact indicator_apply_le id
#align measure_theory.lintegral_supr MeasureTheory.lintegral_iSup
theorem lintegral_iSup' {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, AEMeasurable (f n) μ)
(h_mono : ∀ᵐ x ∂μ, Monotone fun n => f n x) : ∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by
simp_rw [← iSup_apply]
let p : α → (ℕ → ℝ≥0∞) → Prop := fun _ f' => Monotone f'
have hp : ∀ᵐ x ∂μ, p x fun i => f i x := h_mono
have h_ae_seq_mono : Monotone (aeSeq hf p) := by
intro n m hnm x
by_cases hx : x ∈ aeSeqSet hf p
· exact aeSeq.prop_of_mem_aeSeqSet hf hx hnm
· simp only [aeSeq, hx, if_false, le_rfl]
rw [lintegral_congr_ae (aeSeq.iSup hf hp).symm]
simp_rw [iSup_apply]
rw [lintegral_iSup (aeSeq.measurable hf p) h_ae_seq_mono]
congr with n
exact lintegral_congr_ae (aeSeq.aeSeq_n_eq_fun_n_ae hf hp n)
#align measure_theory.lintegral_supr' MeasureTheory.lintegral_iSup'
theorem lintegral_tendsto_of_tendsto_of_monotone {f : ℕ → α → ℝ≥0∞} {F : α → ℝ≥0∞}
(hf : ∀ n, AEMeasurable (f n) μ) (h_mono : ∀ᵐ x ∂μ, Monotone fun n => f n x)
(h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 <| F x)) :
Tendsto (fun n => ∫⁻ x, f n x ∂μ) atTop (𝓝 <| ∫⁻ x, F x ∂μ) := by
have : Monotone fun n => ∫⁻ x, f n x ∂μ := fun i j hij =>
lintegral_mono_ae (h_mono.mono fun x hx => hx hij)
suffices key : ∫⁻ x, F x ∂μ = ⨆ n, ∫⁻ x, f n x ∂μ by
rw [key]
exact tendsto_atTop_iSup this
rw [← lintegral_iSup' hf h_mono]
refine lintegral_congr_ae ?_
filter_upwards [h_mono, h_tendsto] with _ hx_mono hx_tendsto using
tendsto_nhds_unique hx_tendsto (tendsto_atTop_iSup hx_mono)
#align measure_theory.lintegral_tendsto_of_tendsto_of_monotone MeasureTheory.lintegral_tendsto_of_tendsto_of_monotone
theorem lintegral_eq_iSup_eapprox_lintegral {f : α → ℝ≥0∞} (hf : Measurable f) :
∫⁻ a, f a ∂μ = ⨆ n, (eapprox f n).lintegral μ :=
calc
∫⁻ a, f a ∂μ = ∫⁻ a, ⨆ n, (eapprox f n : α → ℝ≥0∞) a ∂μ := by
congr; ext a; rw [iSup_eapprox_apply f hf]
_ = ⨆ n, ∫⁻ a, (eapprox f n : α → ℝ≥0∞) a ∂μ := by
apply lintegral_iSup
· measurability
· intro i j h
exact monotone_eapprox f h
_ = ⨆ n, (eapprox f n).lintegral μ := by
congr; ext n; rw [(eapprox f n).lintegral_eq_lintegral]
#align measure_theory.lintegral_eq_supr_eapprox_lintegral MeasureTheory.lintegral_eq_iSup_eapprox_lintegral
theorem exists_pos_set_lintegral_lt_of_measure_lt {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {ε : ℝ≥0∞}
(hε : ε ≠ 0) : ∃ δ > 0, ∀ s, μ s < δ → ∫⁻ x in s, f x ∂μ < ε := by
rcases exists_between (pos_iff_ne_zero.mpr hε) with ⟨ε₂, hε₂0, hε₂ε⟩
rcases exists_between hε₂0 with ⟨ε₁, hε₁0, hε₁₂⟩
rcases exists_simpleFunc_forall_lintegral_sub_lt_of_pos h hε₁0.ne' with ⟨φ, _, hφ⟩
rcases φ.exists_forall_le with ⟨C, hC⟩
use (ε₂ - ε₁) / C, ENNReal.div_pos_iff.2 ⟨(tsub_pos_iff_lt.2 hε₁₂).ne', ENNReal.coe_ne_top⟩
refine fun s hs => lt_of_le_of_lt ?_ hε₂ε
simp only [lintegral_eq_nnreal, iSup_le_iff]
intro ψ hψ
calc
(map (↑) ψ).lintegral (μ.restrict s) ≤
(map (↑) φ).lintegral (μ.restrict s) + (map (↑) (ψ - φ)).lintegral (μ.restrict s) := by
rw [← SimpleFunc.add_lintegral, ← SimpleFunc.map_add @ENNReal.coe_add]
refine SimpleFunc.lintegral_mono (fun x => ?_) le_rfl
simp only [add_tsub_eq_max, le_max_right, coe_map, Function.comp_apply, SimpleFunc.coe_add,
SimpleFunc.coe_sub, Pi.add_apply, Pi.sub_apply, ENNReal.coe_max (φ x) (ψ x)]
_ ≤ (map (↑) φ).lintegral (μ.restrict s) + ε₁ := by
gcongr
refine le_trans ?_ (hφ _ hψ).le
exact SimpleFunc.lintegral_mono le_rfl Measure.restrict_le_self
_ ≤ (SimpleFunc.const α (C : ℝ≥0∞)).lintegral (μ.restrict s) + ε₁ := by
gcongr
exact SimpleFunc.lintegral_mono (fun x ↦ ENNReal.coe_le_coe.2 (hC x)) le_rfl
_ = C * μ s + ε₁ := by
simp only [← SimpleFunc.lintegral_eq_lintegral, coe_const, lintegral_const,
Measure.restrict_apply, MeasurableSet.univ, univ_inter, Function.const]
_ ≤ C * ((ε₂ - ε₁) / C) + ε₁ := by gcongr
_ ≤ ε₂ - ε₁ + ε₁ := by gcongr; apply mul_div_le
_ = ε₂ := tsub_add_cancel_of_le hε₁₂.le
#align measure_theory.exists_pos_set_lintegral_lt_of_measure_lt MeasureTheory.exists_pos_set_lintegral_lt_of_measure_lt
theorem tendsto_set_lintegral_zero {ι} {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {l : Filter ι}
{s : ι → Set α} (hl : Tendsto (μ ∘ s) l (𝓝 0)) :
Tendsto (fun i => ∫⁻ x in s i, f x ∂μ) l (𝓝 0) := by
simp only [ENNReal.nhds_zero, tendsto_iInf, tendsto_principal, mem_Iio,
← pos_iff_ne_zero] at hl ⊢
intro ε ε0
rcases exists_pos_set_lintegral_lt_of_measure_lt h ε0.ne' with ⟨δ, δ0, hδ⟩
exact (hl δ δ0).mono fun i => hδ _
#align measure_theory.tendsto_set_lintegral_zero MeasureTheory.tendsto_set_lintegral_zero
theorem le_lintegral_add (f g : α → ℝ≥0∞) :
∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ ≤ ∫⁻ a, f a + g a ∂μ := by
simp only [lintegral]
refine ENNReal.biSup_add_biSup_le' (p := fun h : α →ₛ ℝ≥0∞ => h ≤ f)
(q := fun h : α →ₛ ℝ≥0∞ => h ≤ g) ⟨0, zero_le f⟩ ⟨0, zero_le g⟩ fun f' hf' g' hg' => ?_
exact le_iSup₂_of_le (f' + g') (add_le_add hf' hg') (add_lintegral _ _).ge
#align measure_theory.le_lintegral_add MeasureTheory.le_lintegral_add
-- Use stronger lemmas `lintegral_add_left`/`lintegral_add_right` instead
theorem lintegral_add_aux {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ :=
calc
∫⁻ a, f a + g a ∂μ =
∫⁻ a, (⨆ n, (eapprox f n : α → ℝ≥0∞) a) + ⨆ n, (eapprox g n : α → ℝ≥0∞) a ∂μ := by
simp only [iSup_eapprox_apply, hf, hg]
_ = ∫⁻ a, ⨆ n, (eapprox f n + eapprox g n : α → ℝ≥0∞) a ∂μ := by
congr; funext a
rw [ENNReal.iSup_add_iSup_of_monotone]
· simp only [Pi.add_apply]
· intro i j h
exact monotone_eapprox _ h a
· intro i j h
exact monotone_eapprox _ h a
_ = ⨆ n, (eapprox f n).lintegral μ + (eapprox g n).lintegral μ := by
rw [lintegral_iSup]
· congr
funext n
rw [← SimpleFunc.add_lintegral, ← SimpleFunc.lintegral_eq_lintegral]
simp only [Pi.add_apply, SimpleFunc.coe_add]
· measurability
· intro i j h a
dsimp
gcongr <;> exact monotone_eapprox _ h _
_ = (⨆ n, (eapprox f n).lintegral μ) + ⨆ n, (eapprox g n).lintegral μ := by
refine (ENNReal.iSup_add_iSup_of_monotone ?_ ?_).symm <;>
· intro i j h
exact SimpleFunc.lintegral_mono (monotone_eapprox _ h) le_rfl
_ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by
rw [lintegral_eq_iSup_eapprox_lintegral hf, lintegral_eq_iSup_eapprox_lintegral hg]
#align measure_theory.lintegral_add_aux MeasureTheory.lintegral_add_aux
@[simp]
theorem lintegral_add_left {f : α → ℝ≥0∞} (hf : Measurable f) (g : α → ℝ≥0∞) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by
refine le_antisymm ?_ (le_lintegral_add _ _)
rcases exists_measurable_le_lintegral_eq μ fun a => f a + g a with ⟨φ, hφm, hφ_le, hφ_eq⟩
calc
∫⁻ a, f a + g a ∂μ = ∫⁻ a, φ a ∂μ := hφ_eq
_ ≤ ∫⁻ a, f a + (φ a - f a) ∂μ := lintegral_mono fun a => le_add_tsub
_ = ∫⁻ a, f a ∂μ + ∫⁻ a, φ a - f a ∂μ := lintegral_add_aux hf (hφm.sub hf)
_ ≤ ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ :=
add_le_add_left (lintegral_mono fun a => tsub_le_iff_left.2 <| hφ_le a) _
#align measure_theory.lintegral_add_left MeasureTheory.lintegral_add_left
theorem lintegral_add_left' {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (g : α → ℝ≥0∞) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by
rw [lintegral_congr_ae hf.ae_eq_mk, ← lintegral_add_left hf.measurable_mk,
lintegral_congr_ae (hf.ae_eq_mk.add (ae_eq_refl g))]
#align measure_theory.lintegral_add_left' MeasureTheory.lintegral_add_left'
theorem lintegral_add_right' (f : α → ℝ≥0∞) {g : α → ℝ≥0∞} (hg : AEMeasurable g μ) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by
simpa only [add_comm] using lintegral_add_left' hg f
#align measure_theory.lintegral_add_right' MeasureTheory.lintegral_add_right'
@[simp]
theorem lintegral_add_right (f : α → ℝ≥0∞) {g : α → ℝ≥0∞} (hg : Measurable g) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ :=
lintegral_add_right' f hg.aemeasurable
#align measure_theory.lintegral_add_right MeasureTheory.lintegral_add_right
@[simp]
theorem lintegral_smul_measure (c : ℝ≥0∞) (f : α → ℝ≥0∞) : ∫⁻ a, f a ∂c • μ = c * ∫⁻ a, f a ∂μ := by
simp only [lintegral, iSup_subtype', SimpleFunc.lintegral_smul, ENNReal.mul_iSup, smul_eq_mul]
#align measure_theory.lintegral_smul_measure MeasureTheory.lintegral_smul_measure
lemma set_lintegral_smul_measure (c : ℝ≥0∞) (f : α → ℝ≥0∞) (s : Set α) :
∫⁻ a in s, f a ∂(c • μ) = c * ∫⁻ a in s, f a ∂μ := by
rw [Measure.restrict_smul, lintegral_smul_measure]
@[simp]
theorem lintegral_sum_measure {m : MeasurableSpace α} {ι} (f : α → ℝ≥0∞) (μ : ι → Measure α) :
∫⁻ a, f a ∂Measure.sum μ = ∑' i, ∫⁻ a, f a ∂μ i := by
simp only [lintegral, iSup_subtype', SimpleFunc.lintegral_sum, ENNReal.tsum_eq_iSup_sum]
rw [iSup_comm]
congr; funext s
induction' s using Finset.induction_on with i s hi hs
· simp
simp only [Finset.sum_insert hi, ← hs]
refine (ENNReal.iSup_add_iSup ?_).symm
intro φ ψ
exact
⟨⟨φ ⊔ ψ, fun x => sup_le (φ.2 x) (ψ.2 x)⟩,
add_le_add (SimpleFunc.lintegral_mono le_sup_left le_rfl)
(Finset.sum_le_sum fun j _ => SimpleFunc.lintegral_mono le_sup_right le_rfl)⟩
#align measure_theory.lintegral_sum_measure MeasureTheory.lintegral_sum_measure
theorem hasSum_lintegral_measure {ι} {_ : MeasurableSpace α} (f : α → ℝ≥0∞) (μ : ι → Measure α) :
HasSum (fun i => ∫⁻ a, f a ∂μ i) (∫⁻ a, f a ∂Measure.sum μ) :=
(lintegral_sum_measure f μ).symm ▸ ENNReal.summable.hasSum
#align measure_theory.has_sum_lintegral_measure MeasureTheory.hasSum_lintegral_measure
@[simp]
theorem lintegral_add_measure {m : MeasurableSpace α} (f : α → ℝ≥0∞) (μ ν : Measure α) :
∫⁻ a, f a ∂(μ + ν) = ∫⁻ a, f a ∂μ + ∫⁻ a, f a ∂ν := by
simpa [tsum_fintype] using lintegral_sum_measure f fun b => cond b μ ν
#align measure_theory.lintegral_add_measure MeasureTheory.lintegral_add_measure
@[simp]
theorem lintegral_finset_sum_measure {ι} {m : MeasurableSpace α} (s : Finset ι) (f : α → ℝ≥0∞)
(μ : ι → Measure α) : ∫⁻ a, f a ∂(∑ i ∈ s, μ i) = ∑ i ∈ s, ∫⁻ a, f a ∂μ i := by
rw [← Measure.sum_coe_finset, lintegral_sum_measure, ← Finset.tsum_subtype']
simp only [Finset.coe_sort_coe]
#align measure_theory.lintegral_finset_sum_measure MeasureTheory.lintegral_finset_sum_measure
@[simp]
theorem lintegral_zero_measure {m : MeasurableSpace α} (f : α → ℝ≥0∞) :
∫⁻ a, f a ∂(0 : Measure α) = 0 := by
simp [lintegral]
#align measure_theory.lintegral_zero_measure MeasureTheory.lintegral_zero_measure
@[simp]
theorem lintegral_of_isEmpty {α} [MeasurableSpace α] [IsEmpty α] (μ : Measure α) (f : α → ℝ≥0∞) :
∫⁻ x, f x ∂μ = 0 := by
have : Subsingleton (Measure α) := inferInstance
convert lintegral_zero_measure f
theorem set_lintegral_empty (f : α → ℝ≥0∞) : ∫⁻ x in ∅, f x ∂μ = 0 := by
rw [Measure.restrict_empty, lintegral_zero_measure]
#align measure_theory.set_lintegral_empty MeasureTheory.set_lintegral_empty
theorem set_lintegral_univ (f : α → ℝ≥0∞) : ∫⁻ x in univ, f x ∂μ = ∫⁻ x, f x ∂μ := by
rw [Measure.restrict_univ]
#align measure_theory.set_lintegral_univ MeasureTheory.set_lintegral_univ
theorem set_lintegral_measure_zero (s : Set α) (f : α → ℝ≥0∞) (hs' : μ s = 0) :
∫⁻ x in s, f x ∂μ = 0 := by
convert lintegral_zero_measure _
exact Measure.restrict_eq_zero.2 hs'
#align measure_theory.set_lintegral_measure_zero MeasureTheory.set_lintegral_measure_zero
theorem lintegral_finset_sum' (s : Finset β) {f : β → α → ℝ≥0∞}
(hf : ∀ b ∈ s, AEMeasurable (f b) μ) :
∫⁻ a, ∑ b ∈ s, f b a ∂μ = ∑ b ∈ s, ∫⁻ a, f b a ∂μ := by
induction' s using Finset.induction_on with a s has ih
· simp
· simp only [Finset.sum_insert has]
rw [Finset.forall_mem_insert] at hf
rw [lintegral_add_left' hf.1, ih hf.2]
#align measure_theory.lintegral_finset_sum' MeasureTheory.lintegral_finset_sum'
theorem lintegral_finset_sum (s : Finset β) {f : β → α → ℝ≥0∞} (hf : ∀ b ∈ s, Measurable (f b)) :
∫⁻ a, ∑ b ∈ s, f b a ∂μ = ∑ b ∈ s, ∫⁻ a, f b a ∂μ :=
lintegral_finset_sum' s fun b hb => (hf b hb).aemeasurable
#align measure_theory.lintegral_finset_sum MeasureTheory.lintegral_finset_sum
@[simp]
theorem lintegral_const_mul (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : Measurable f) :
∫⁻ a, r * f a ∂μ = r * ∫⁻ a, f a ∂μ :=
calc
∫⁻ a, r * f a ∂μ = ∫⁻ a, ⨆ n, (const α r * eapprox f n) a ∂μ := by
congr
funext a
rw [← iSup_eapprox_apply f hf, ENNReal.mul_iSup]
simp
_ = ⨆ n, r * (eapprox f n).lintegral μ := by
rw [lintegral_iSup]
· congr
funext n
rw [← SimpleFunc.const_mul_lintegral, ← SimpleFunc.lintegral_eq_lintegral]
· intro n
exact SimpleFunc.measurable _
· intro i j h a
exact mul_le_mul_left' (monotone_eapprox _ h _) _
_ = r * ∫⁻ a, f a ∂μ := by rw [← ENNReal.mul_iSup, lintegral_eq_iSup_eapprox_lintegral hf]
#align measure_theory.lintegral_const_mul MeasureTheory.lintegral_const_mul
theorem lintegral_const_mul'' (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) :
∫⁻ a, r * f a ∂μ = r * ∫⁻ a, f a ∂μ := by
have A : ∫⁻ a, f a ∂μ = ∫⁻ a, hf.mk f a ∂μ := lintegral_congr_ae hf.ae_eq_mk
have B : ∫⁻ a, r * f a ∂μ = ∫⁻ a, r * hf.mk f a ∂μ :=
lintegral_congr_ae (EventuallyEq.fun_comp hf.ae_eq_mk _)
rw [A, B, lintegral_const_mul _ hf.measurable_mk]
#align measure_theory.lintegral_const_mul'' MeasureTheory.lintegral_const_mul''
theorem lintegral_const_mul_le (r : ℝ≥0∞) (f : α → ℝ≥0∞) :
r * ∫⁻ a, f a ∂μ ≤ ∫⁻ a, r * f a ∂μ := by
rw [lintegral, ENNReal.mul_iSup]
refine iSup_le fun s => ?_
rw [ENNReal.mul_iSup, iSup_le_iff]
intro hs
rw [← SimpleFunc.const_mul_lintegral, lintegral]
refine le_iSup_of_le (const α r * s) (le_iSup_of_le (fun x => ?_) le_rfl)
exact mul_le_mul_left' (hs x) _
#align measure_theory.lintegral_const_mul_le MeasureTheory.lintegral_const_mul_le
theorem lintegral_const_mul' (r : ℝ≥0∞) (f : α → ℝ≥0∞) (hr : r ≠ ∞) :
∫⁻ a, r * f a ∂μ = r * ∫⁻ a, f a ∂μ := by
by_cases h : r = 0
· simp [h]
apply le_antisymm _ (lintegral_const_mul_le r f)
have rinv : r * r⁻¹ = 1 := ENNReal.mul_inv_cancel h hr
have rinv' : r⁻¹ * r = 1 := by
rw [mul_comm]
exact rinv
have := lintegral_const_mul_le (μ := μ) r⁻¹ fun x => r * f x
simp? [(mul_assoc _ _ _).symm, rinv'] at this says
simp only [(mul_assoc _ _ _).symm, rinv', one_mul] at this
simpa [(mul_assoc _ _ _).symm, rinv] using mul_le_mul_left' this r
#align measure_theory.lintegral_const_mul' MeasureTheory.lintegral_const_mul'
theorem lintegral_mul_const (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : Measurable f) :
∫⁻ a, f a * r ∂μ = (∫⁻ a, f a ∂μ) * r := by simp_rw [mul_comm, lintegral_const_mul r hf]
#align measure_theory.lintegral_mul_const MeasureTheory.lintegral_mul_const
theorem lintegral_mul_const'' (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) :
∫⁻ a, f a * r ∂μ = (∫⁻ a, f a ∂μ) * r := by simp_rw [mul_comm, lintegral_const_mul'' r hf]
#align measure_theory.lintegral_mul_const'' MeasureTheory.lintegral_mul_const''
theorem lintegral_mul_const_le (r : ℝ≥0∞) (f : α → ℝ≥0∞) :
(∫⁻ a, f a ∂μ) * r ≤ ∫⁻ a, f a * r ∂μ := by
simp_rw [mul_comm, lintegral_const_mul_le r f]
#align measure_theory.lintegral_mul_const_le MeasureTheory.lintegral_mul_const_le
theorem lintegral_mul_const' (r : ℝ≥0∞) (f : α → ℝ≥0∞) (hr : r ≠ ∞) :
∫⁻ a, f a * r ∂μ = (∫⁻ a, f a ∂μ) * r := by simp_rw [mul_comm, lintegral_const_mul' r f hr]
#align measure_theory.lintegral_mul_const' MeasureTheory.lintegral_mul_const'
theorem lintegral_lintegral_mul {β} [MeasurableSpace β] {ν : Measure β} {f : α → ℝ≥0∞}
{g : β → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g ν) :
∫⁻ x, ∫⁻ y, f x * g y ∂ν ∂μ = (∫⁻ x, f x ∂μ) * ∫⁻ y, g y ∂ν := by
simp [lintegral_const_mul'' _ hg, lintegral_mul_const'' _ hf]
#align measure_theory.lintegral_lintegral_mul MeasureTheory.lintegral_lintegral_mul
-- TODO: Need a better way of rewriting inside of an integral
theorem lintegral_rw₁ {f f' : α → β} (h : f =ᵐ[μ] f') (g : β → ℝ≥0∞) :
∫⁻ a, g (f a) ∂μ = ∫⁻ a, g (f' a) ∂μ :=
lintegral_congr_ae <| h.mono fun a h => by dsimp only; rw [h]
#align measure_theory.lintegral_rw₁ MeasureTheory.lintegral_rw₁
-- TODO: Need a better way of rewriting inside of an integral
theorem lintegral_rw₂ {f₁ f₁' : α → β} {f₂ f₂' : α → γ} (h₁ : f₁ =ᵐ[μ] f₁') (h₂ : f₂ =ᵐ[μ] f₂')
(g : β → γ → ℝ≥0∞) : ∫⁻ a, g (f₁ a) (f₂ a) ∂μ = ∫⁻ a, g (f₁' a) (f₂' a) ∂μ :=
lintegral_congr_ae <| h₁.mp <| h₂.mono fun _ h₂ h₁ => by dsimp only; rw [h₁, h₂]
#align measure_theory.lintegral_rw₂ MeasureTheory.lintegral_rw₂
theorem lintegral_indicator_le (f : α → ℝ≥0∞) (s : Set α) :
∫⁻ a, s.indicator f a ∂μ ≤ ∫⁻ a in s, f a ∂μ := by
simp only [lintegral]
apply iSup_le (fun g ↦ (iSup_le (fun hg ↦ ?_)))
have : g ≤ f := hg.trans (indicator_le_self s f)
refine le_iSup_of_le g (le_iSup_of_le this (le_of_eq ?_))
rw [lintegral_restrict, SimpleFunc.lintegral]
congr with t
by_cases H : t = 0
· simp [H]
congr with x
simp only [mem_preimage, mem_singleton_iff, mem_inter_iff, iff_self_and]
rintro rfl
contrapose! H
simpa [H] using hg x
@[simp]
theorem lintegral_indicator (f : α → ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) :
∫⁻ a, s.indicator f a ∂μ = ∫⁻ a in s, f a ∂μ := by
apply le_antisymm (lintegral_indicator_le f s)
simp only [lintegral, ← restrict_lintegral_eq_lintegral_restrict _ hs, iSup_subtype']
refine iSup_mono' (Subtype.forall.2 fun φ hφ => ?_)
refine ⟨⟨φ.restrict s, fun x => ?_⟩, le_rfl⟩
simp [hφ x, hs, indicator_le_indicator]
#align measure_theory.lintegral_indicator MeasureTheory.lintegral_indicator
theorem lintegral_indicator₀ (f : α → ℝ≥0∞) {s : Set α} (hs : NullMeasurableSet s μ) :
∫⁻ a, s.indicator f a ∂μ = ∫⁻ a in s, f a ∂μ := by
rw [← lintegral_congr_ae (indicator_ae_eq_of_ae_eq_set hs.toMeasurable_ae_eq),
lintegral_indicator _ (measurableSet_toMeasurable _ _),
Measure.restrict_congr_set hs.toMeasurable_ae_eq]
#align measure_theory.lintegral_indicator₀ MeasureTheory.lintegral_indicator₀
theorem lintegral_indicator_const_le (s : Set α) (c : ℝ≥0∞) :
∫⁻ a, s.indicator (fun _ => c) a ∂μ ≤ c * μ s :=
(lintegral_indicator_le _ _).trans (set_lintegral_const s c).le
theorem lintegral_indicator_const₀ {s : Set α} (hs : NullMeasurableSet s μ) (c : ℝ≥0∞) :
∫⁻ a, s.indicator (fun _ => c) a ∂μ = c * μ s := by
rw [lintegral_indicator₀ _ hs, set_lintegral_const]
theorem lintegral_indicator_const {s : Set α} (hs : MeasurableSet s) (c : ℝ≥0∞) :
∫⁻ a, s.indicator (fun _ => c) a ∂μ = c * μ s :=
lintegral_indicator_const₀ hs.nullMeasurableSet c
#align measure_theory.lintegral_indicator_const MeasureTheory.lintegral_indicator_const
theorem set_lintegral_eq_const {f : α → ℝ≥0∞} (hf : Measurable f) (r : ℝ≥0∞) :
∫⁻ x in { x | f x = r }, f x ∂μ = r * μ { x | f x = r } := by
have : ∀ᵐ x ∂μ, x ∈ { x | f x = r } → f x = r := ae_of_all μ fun _ hx => hx
rw [set_lintegral_congr_fun _ this]
· rw [lintegral_const, Measure.restrict_apply MeasurableSet.univ, Set.univ_inter]
· exact hf (measurableSet_singleton r)
#align measure_theory.set_lintegral_eq_const MeasureTheory.set_lintegral_eq_const
theorem lintegral_indicator_one_le (s : Set α) : ∫⁻ a, s.indicator 1 a ∂μ ≤ μ s :=
(lintegral_indicator_const_le _ _).trans <| (one_mul _).le
@[simp]
theorem lintegral_indicator_one₀ (hs : NullMeasurableSet s μ) : ∫⁻ a, s.indicator 1 a ∂μ = μ s :=
(lintegral_indicator_const₀ hs _).trans <| one_mul _
@[simp]
theorem lintegral_indicator_one (hs : MeasurableSet s) : ∫⁻ a, s.indicator 1 a ∂μ = μ s :=
(lintegral_indicator_const hs _).trans <| one_mul _
#align measure_theory.lintegral_indicator_one MeasureTheory.lintegral_indicator_one
theorem lintegral_add_mul_meas_add_le_le_lintegral {f g : α → ℝ≥0∞} (hle : f ≤ᵐ[μ] g)
(hg : AEMeasurable g μ) (ε : ℝ≥0∞) :
∫⁻ a, f a ∂μ + ε * μ { x | f x + ε ≤ g x } ≤ ∫⁻ a, g a ∂μ := by
rcases exists_measurable_le_lintegral_eq μ f with ⟨φ, hφm, hφ_le, hφ_eq⟩
calc
∫⁻ x, f x ∂μ + ε * μ { x | f x + ε ≤ g x } = ∫⁻ x, φ x ∂μ + ε * μ { x | f x + ε ≤ g x } := by
rw [hφ_eq]
_ ≤ ∫⁻ x, φ x ∂μ + ε * μ { x | φ x + ε ≤ g x } := by
gcongr
exact fun x => (add_le_add_right (hφ_le _) _).trans
_ = ∫⁻ x, φ x + indicator { x | φ x + ε ≤ g x } (fun _ => ε) x ∂μ := by
rw [lintegral_add_left hφm, lintegral_indicator₀, set_lintegral_const]
exact measurableSet_le (hφm.nullMeasurable.measurable'.add_const _) hg.nullMeasurable
_ ≤ ∫⁻ x, g x ∂μ := lintegral_mono_ae (hle.mono fun x hx₁ => ?_)
simp only [indicator_apply]; split_ifs with hx₂
exacts [hx₂, (add_zero _).trans_le <| (hφ_le x).trans hx₁]
#align measure_theory.lintegral_add_mul_meas_add_le_le_lintegral MeasureTheory.lintegral_add_mul_meas_add_le_le_lintegral
theorem mul_meas_ge_le_lintegral₀ {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (ε : ℝ≥0∞) :
ε * μ { x | ε ≤ f x } ≤ ∫⁻ a, f a ∂μ := by
simpa only [lintegral_zero, zero_add] using
lintegral_add_mul_meas_add_le_le_lintegral (ae_of_all _ fun x => zero_le (f x)) hf ε
#align measure_theory.mul_meas_ge_le_lintegral₀ MeasureTheory.mul_meas_ge_le_lintegral₀
theorem mul_meas_ge_le_lintegral {f : α → ℝ≥0∞} (hf : Measurable f) (ε : ℝ≥0∞) :
ε * μ { x | ε ≤ f x } ≤ ∫⁻ a, f a ∂μ :=
mul_meas_ge_le_lintegral₀ hf.aemeasurable ε
#align measure_theory.mul_meas_ge_le_lintegral MeasureTheory.mul_meas_ge_le_lintegral
lemma meas_le_lintegral₀ {f : α → ℝ≥0∞} (hf : AEMeasurable f μ)
{s : Set α} (hs : ∀ x ∈ s, 1 ≤ f x) : μ s ≤ ∫⁻ a, f a ∂μ := by
apply le_trans _ (mul_meas_ge_le_lintegral₀ hf 1)
rw [one_mul]
exact measure_mono hs
lemma lintegral_le_meas {s : Set α} {f : α → ℝ≥0∞} (hf : ∀ a, f a ≤ 1) (h'f : ∀ a ∈ sᶜ, f a = 0) :
∫⁻ a, f a ∂μ ≤ μ s := by
apply (lintegral_mono (fun x ↦ ?_)).trans (lintegral_indicator_one_le s)
by_cases hx : x ∈ s
· simpa [hx] using hf x
· simpa [hx] using h'f x hx
theorem lintegral_eq_top_of_measure_eq_top_ne_zero {f : α → ℝ≥0∞} (hf : AEMeasurable f μ)
(hμf : μ {x | f x = ∞} ≠ 0) : ∫⁻ x, f x ∂μ = ∞ :=
eq_top_iff.mpr <|
calc
∞ = ∞ * μ { x | ∞ ≤ f x } := by simp [mul_eq_top, hμf]
_ ≤ ∫⁻ x, f x ∂μ := mul_meas_ge_le_lintegral₀ hf ∞
#align measure_theory.lintegral_eq_top_of_measure_eq_top_ne_zero MeasureTheory.lintegral_eq_top_of_measure_eq_top_ne_zero
theorem setLintegral_eq_top_of_measure_eq_top_ne_zero (hf : AEMeasurable f (μ.restrict s))
(hμf : μ ({x ∈ s | f x = ∞}) ≠ 0) : ∫⁻ x in s, f x ∂μ = ∞ :=
lintegral_eq_top_of_measure_eq_top_ne_zero hf <|
mt (eq_bot_mono <| by rw [← setOf_inter_eq_sep]; exact Measure.le_restrict_apply _ _) hμf
#align measure_theory.set_lintegral_eq_top_of_measure_eq_top_ne_zero MeasureTheory.setLintegral_eq_top_of_measure_eq_top_ne_zero
theorem measure_eq_top_of_lintegral_ne_top (hf : AEMeasurable f μ) (hμf : ∫⁻ x, f x ∂μ ≠ ∞) :
μ {x | f x = ∞} = 0 :=
of_not_not fun h => hμf <| lintegral_eq_top_of_measure_eq_top_ne_zero hf h
#align measure_theory.measure_eq_top_of_lintegral_ne_top MeasureTheory.measure_eq_top_of_lintegral_ne_top
theorem measure_eq_top_of_setLintegral_ne_top (hf : AEMeasurable f (μ.restrict s))
(hμf : ∫⁻ x in s, f x ∂μ ≠ ∞) : μ ({x ∈ s | f x = ∞}) = 0 :=
of_not_not fun h => hμf <| setLintegral_eq_top_of_measure_eq_top_ne_zero hf h
#align measure_theory.measure_eq_top_of_set_lintegral_ne_top MeasureTheory.measure_eq_top_of_setLintegral_ne_top
theorem meas_ge_le_lintegral_div {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) {ε : ℝ≥0∞} (hε : ε ≠ 0)
(hε' : ε ≠ ∞) : μ { x | ε ≤ f x } ≤ (∫⁻ a, f a ∂μ) / ε :=
(ENNReal.le_div_iff_mul_le (Or.inl hε) (Or.inl hε')).2 <| by
rw [mul_comm]
exact mul_meas_ge_le_lintegral₀ hf ε
#align measure_theory.meas_ge_le_lintegral_div MeasureTheory.meas_ge_le_lintegral_div
theorem ae_eq_of_ae_le_of_lintegral_le {f g : α → ℝ≥0∞} (hfg : f ≤ᵐ[μ] g) (hf : ∫⁻ x, f x ∂μ ≠ ∞)
(hg : AEMeasurable g μ) (hgf : ∫⁻ x, g x ∂μ ≤ ∫⁻ x, f x ∂μ) : f =ᵐ[μ] g := by
have : ∀ n : ℕ, ∀ᵐ x ∂μ, g x < f x + (n : ℝ≥0∞)⁻¹ := by
intro n
simp only [ae_iff, not_lt]
have : ∫⁻ x, f x ∂μ + (↑n)⁻¹ * μ { x : α | f x + (n : ℝ≥0∞)⁻¹ ≤ g x } ≤ ∫⁻ x, f x ∂μ :=
(lintegral_add_mul_meas_add_le_le_lintegral hfg hg n⁻¹).trans hgf
rw [(ENNReal.cancel_of_ne hf).add_le_iff_nonpos_right, nonpos_iff_eq_zero, mul_eq_zero] at this
exact this.resolve_left (ENNReal.inv_ne_zero.2 (ENNReal.natCast_ne_top _))
refine hfg.mp ((ae_all_iff.2 this).mono fun x hlt hle => hle.antisymm ?_)
suffices Tendsto (fun n : ℕ => f x + (n : ℝ≥0∞)⁻¹) atTop (𝓝 (f x)) from
ge_of_tendsto' this fun i => (hlt i).le
simpa only [inv_top, add_zero] using
tendsto_const_nhds.add (ENNReal.tendsto_inv_iff.2 ENNReal.tendsto_nat_nhds_top)
#align measure_theory.ae_eq_of_ae_le_of_lintegral_le MeasureTheory.ae_eq_of_ae_le_of_lintegral_le
@[simp]
theorem lintegral_eq_zero_iff' {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) :
∫⁻ a, f a ∂μ = 0 ↔ f =ᵐ[μ] 0 :=
have : ∫⁻ _ : α, 0 ∂μ ≠ ∞ := by simp [lintegral_zero, zero_ne_top]
⟨fun h =>
(ae_eq_of_ae_le_of_lintegral_le (ae_of_all _ <| zero_le f) this hf
(h.trans lintegral_zero.symm).le).symm,
fun h => (lintegral_congr_ae h).trans lintegral_zero⟩
#align measure_theory.lintegral_eq_zero_iff' MeasureTheory.lintegral_eq_zero_iff'
@[simp]
theorem lintegral_eq_zero_iff {f : α → ℝ≥0∞} (hf : Measurable f) : ∫⁻ a, f a ∂μ = 0 ↔ f =ᵐ[μ] 0 :=
lintegral_eq_zero_iff' hf.aemeasurable
#align measure_theory.lintegral_eq_zero_iff MeasureTheory.lintegral_eq_zero_iff
theorem lintegral_pos_iff_support {f : α → ℝ≥0∞} (hf : Measurable f) :
(0 < ∫⁻ a, f a ∂μ) ↔ 0 < μ (Function.support f) := by
simp [pos_iff_ne_zero, hf, Filter.EventuallyEq, ae_iff, Function.support]
#align measure_theory.lintegral_pos_iff_support MeasureTheory.lintegral_pos_iff_support
theorem setLintegral_pos_iff {f : α → ℝ≥0∞} (hf : Measurable f) {s : Set α} :
0 < ∫⁻ a in s, f a ∂μ ↔ 0 < μ (Function.support f ∩ s) := by
rw [lintegral_pos_iff_support hf, Measure.restrict_apply (measurableSet_support hf)]
theorem lintegral_iSup_ae {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, Measurable (f n))
(h_mono : ∀ n, ∀ᵐ a ∂μ, f n a ≤ f n.succ a) : ∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by
let ⟨s, hs⟩ := exists_measurable_superset_of_null (ae_iff.1 (ae_all_iff.2 h_mono))
let g n a := if a ∈ s then 0 else f n a
have g_eq_f : ∀ᵐ a ∂μ, ∀ n, g n a = f n a :=
(measure_zero_iff_ae_nmem.1 hs.2.2).mono fun a ha n => if_neg ha
calc
∫⁻ a, ⨆ n, f n a ∂μ = ∫⁻ a, ⨆ n, g n a ∂μ :=
lintegral_congr_ae <| g_eq_f.mono fun a ha => by simp only [ha]
_ = ⨆ n, ∫⁻ a, g n a ∂μ :=
(lintegral_iSup (fun n => measurable_const.piecewise hs.2.1 (hf n))
(monotone_nat_of_le_succ fun n a => ?_))
_ = ⨆ n, ∫⁻ a, f n a ∂μ := by simp only [lintegral_congr_ae (g_eq_f.mono fun _a ha => ha _)]
simp only [g]
split_ifs with h
· rfl
· have := Set.not_mem_subset hs.1 h
simp only [not_forall, not_le, mem_setOf_eq, not_exists, not_lt] at this
exact this n
#align measure_theory.lintegral_supr_ae MeasureTheory.lintegral_iSup_ae
theorem lintegral_sub' {f g : α → ℝ≥0∞} (hg : AEMeasurable g μ) (hg_fin : ∫⁻ a, g a ∂μ ≠ ∞)
(h_le : g ≤ᵐ[μ] f) : ∫⁻ a, f a - g a ∂μ = ∫⁻ a, f a ∂μ - ∫⁻ a, g a ∂μ := by
refine ENNReal.eq_sub_of_add_eq hg_fin ?_
rw [← lintegral_add_right' _ hg]
exact lintegral_congr_ae (h_le.mono fun x hx => tsub_add_cancel_of_le hx)
#align measure_theory.lintegral_sub' MeasureTheory.lintegral_sub'
theorem lintegral_sub {f g : α → ℝ≥0∞} (hg : Measurable g) (hg_fin : ∫⁻ a, g a ∂μ ≠ ∞)
(h_le : g ≤ᵐ[μ] f) : ∫⁻ a, f a - g a ∂μ = ∫⁻ a, f a ∂μ - ∫⁻ a, g a ∂μ :=
lintegral_sub' hg.aemeasurable hg_fin h_le
#align measure_theory.lintegral_sub MeasureTheory.lintegral_sub
theorem lintegral_sub_le' (f g : α → ℝ≥0∞) (hf : AEMeasurable f μ) :
∫⁻ x, g x ∂μ - ∫⁻ x, f x ∂μ ≤ ∫⁻ x, g x - f x ∂μ := by
rw [tsub_le_iff_right]
by_cases hfi : ∫⁻ x, f x ∂μ = ∞
· rw [hfi, add_top]
exact le_top
· rw [← lintegral_add_right' _ hf]
gcongr
exact le_tsub_add
#align measure_theory.lintegral_sub_le' MeasureTheory.lintegral_sub_le'
theorem lintegral_sub_le (f g : α → ℝ≥0∞) (hf : Measurable f) :
∫⁻ x, g x ∂μ - ∫⁻ x, f x ∂μ ≤ ∫⁻ x, g x - f x ∂μ :=
lintegral_sub_le' f g hf.aemeasurable
#align measure_theory.lintegral_sub_le MeasureTheory.lintegral_sub_le
theorem lintegral_strict_mono_of_ae_le_of_frequently_ae_lt {f g : α → ℝ≥0∞} (hg : AEMeasurable g μ)
(hfi : ∫⁻ x, f x ∂μ ≠ ∞) (h_le : f ≤ᵐ[μ] g) (h : ∃ᵐ x ∂μ, f x ≠ g x) :
∫⁻ x, f x ∂μ < ∫⁻ x, g x ∂μ := by
contrapose! h
simp only [not_frequently, Ne, Classical.not_not]
exact ae_eq_of_ae_le_of_lintegral_le h_le hfi hg h
#align measure_theory.lintegral_strict_mono_of_ae_le_of_frequently_ae_lt MeasureTheory.lintegral_strict_mono_of_ae_le_of_frequently_ae_lt
theorem lintegral_strict_mono_of_ae_le_of_ae_lt_on {f g : α → ℝ≥0∞} (hg : AEMeasurable g μ)
(hfi : ∫⁻ x, f x ∂μ ≠ ∞) (h_le : f ≤ᵐ[μ] g) {s : Set α} (hμs : μ s ≠ 0)
(h : ∀ᵐ x ∂μ, x ∈ s → f x < g x) : ∫⁻ x, f x ∂μ < ∫⁻ x, g x ∂μ :=
lintegral_strict_mono_of_ae_le_of_frequently_ae_lt hg hfi h_le <|
((frequently_ae_mem_iff.2 hμs).and_eventually h).mono fun _x hx => (hx.2 hx.1).ne
#align measure_theory.lintegral_strict_mono_of_ae_le_of_ae_lt_on MeasureTheory.lintegral_strict_mono_of_ae_le_of_ae_lt_on
theorem lintegral_strict_mono {f g : α → ℝ≥0∞} (hμ : μ ≠ 0) (hg : AEMeasurable g μ)
(hfi : ∫⁻ x, f x ∂μ ≠ ∞) (h : ∀ᵐ x ∂μ, f x < g x) : ∫⁻ x, f x ∂μ < ∫⁻ x, g x ∂μ := by
rw [Ne, ← Measure.measure_univ_eq_zero] at hμ
refine lintegral_strict_mono_of_ae_le_of_ae_lt_on hg hfi (ae_le_of_ae_lt h) hμ ?_
simpa using h
#align measure_theory.lintegral_strict_mono MeasureTheory.lintegral_strict_mono
theorem set_lintegral_strict_mono {f g : α → ℝ≥0∞} {s : Set α} (hsm : MeasurableSet s)
(hs : μ s ≠ 0) (hg : Measurable g) (hfi : ∫⁻ x in s, f x ∂μ ≠ ∞)
(h : ∀ᵐ x ∂μ, x ∈ s → f x < g x) : ∫⁻ x in s, f x ∂μ < ∫⁻ x in s, g x ∂μ :=
lintegral_strict_mono (by simp [hs]) hg.aemeasurable hfi ((ae_restrict_iff' hsm).mpr h)
#align measure_theory.set_lintegral_strict_mono MeasureTheory.set_lintegral_strict_mono
theorem lintegral_iInf_ae {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, Measurable (f n))
(h_mono : ∀ n : ℕ, f n.succ ≤ᵐ[μ] f n) (h_fin : ∫⁻ a, f 0 a ∂μ ≠ ∞) :
∫⁻ a, ⨅ n, f n a ∂μ = ⨅ n, ∫⁻ a, f n a ∂μ :=
have fn_le_f0 : ∫⁻ a, ⨅ n, f n a ∂μ ≤ ∫⁻ a, f 0 a ∂μ :=
lintegral_mono fun a => iInf_le_of_le 0 le_rfl
have fn_le_f0' : ⨅ n, ∫⁻ a, f n a ∂μ ≤ ∫⁻ a, f 0 a ∂μ := iInf_le_of_le 0 le_rfl
(ENNReal.sub_right_inj h_fin fn_le_f0 fn_le_f0').1 <|
show ∫⁻ a, f 0 a ∂μ - ∫⁻ a, ⨅ n, f n a ∂μ = ∫⁻ a, f 0 a ∂μ - ⨅ n, ∫⁻ a, f n a ∂μ from
calc
∫⁻ a, f 0 a ∂μ - ∫⁻ a, ⨅ n, f n a ∂μ = ∫⁻ a, f 0 a - ⨅ n, f n a ∂μ :=
(lintegral_sub (measurable_iInf h_meas)
(ne_top_of_le_ne_top h_fin <| lintegral_mono fun a => iInf_le _ _)
(ae_of_all _ fun a => iInf_le _ _)).symm
_ = ∫⁻ a, ⨆ n, f 0 a - f n a ∂μ := congr rfl (funext fun a => ENNReal.sub_iInf)
_ = ⨆ n, ∫⁻ a, f 0 a - f n a ∂μ :=
(lintegral_iSup_ae (fun n => (h_meas 0).sub (h_meas n)) fun n =>
(h_mono n).mono fun a ha => tsub_le_tsub le_rfl ha)
_ = ⨆ n, ∫⁻ a, f 0 a ∂μ - ∫⁻ a, f n a ∂μ :=
(have h_mono : ∀ᵐ a ∂μ, ∀ n : ℕ, f n.succ a ≤ f n a := ae_all_iff.2 h_mono
have h_mono : ∀ n, ∀ᵐ a ∂μ, f n a ≤ f 0 a := fun n =>
h_mono.mono fun a h => by
induction' n with n ih
· exact le_rfl
· exact le_trans (h n) ih
congr_arg iSup <|
funext fun n =>
lintegral_sub (h_meas _) (ne_top_of_le_ne_top h_fin <| lintegral_mono_ae <| h_mono n)
(h_mono n))
_ = ∫⁻ a, f 0 a ∂μ - ⨅ n, ∫⁻ a, f n a ∂μ := ENNReal.sub_iInf.symm
#align measure_theory.lintegral_infi_ae MeasureTheory.lintegral_iInf_ae
theorem lintegral_iInf {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, Measurable (f n)) (h_anti : Antitone f)
(h_fin : ∫⁻ a, f 0 a ∂μ ≠ ∞) : ∫⁻ a, ⨅ n, f n a ∂μ = ⨅ n, ∫⁻ a, f n a ∂μ :=
lintegral_iInf_ae h_meas (fun n => ae_of_all _ <| h_anti n.le_succ) h_fin
#align measure_theory.lintegral_infi MeasureTheory.lintegral_iInf
theorem lintegral_iInf' {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, AEMeasurable (f n) μ)
(h_anti : ∀ᵐ a ∂μ, Antitone (fun i ↦ f i a)) (h_fin : ∫⁻ a, f 0 a ∂μ ≠ ∞) :
∫⁻ a, ⨅ n, f n a ∂μ = ⨅ n, ∫⁻ a, f n a ∂μ := by
simp_rw [← iInf_apply]
let p : α → (ℕ → ℝ≥0∞) → Prop := fun _ f' => Antitone f'
have hp : ∀ᵐ x ∂μ, p x fun i => f i x := h_anti
have h_ae_seq_mono : Antitone (aeSeq h_meas p) := by
intro n m hnm x
by_cases hx : x ∈ aeSeqSet h_meas p
· exact aeSeq.prop_of_mem_aeSeqSet h_meas hx hnm
· simp only [aeSeq, hx, if_false]
exact le_rfl
rw [lintegral_congr_ae (aeSeq.iInf h_meas hp).symm]
simp_rw [iInf_apply]
rw [lintegral_iInf (aeSeq.measurable h_meas p) h_ae_seq_mono]
· congr
exact funext fun n ↦ lintegral_congr_ae (aeSeq.aeSeq_n_eq_fun_n_ae h_meas hp n)
· rwa [lintegral_congr_ae (aeSeq.aeSeq_n_eq_fun_n_ae h_meas hp 0)]
theorem lintegral_iInf_directed_of_measurable {mα : MeasurableSpace α} [Countable β]
{f : β → α → ℝ≥0∞} {μ : Measure α} (hμ : μ ≠ 0) (hf : ∀ b, Measurable (f b))
(hf_int : ∀ b, ∫⁻ a, f b a ∂μ ≠ ∞) (h_directed : Directed (· ≥ ·) f) :
∫⁻ a, ⨅ b, f b a ∂μ = ⨅ b, ∫⁻ a, f b a ∂μ := by
cases nonempty_encodable β
cases isEmpty_or_nonempty β
· simp only [iInf_of_empty, lintegral_const,
ENNReal.top_mul (Measure.measure_univ_ne_zero.mpr hμ)]
inhabit β
have : ∀ a, ⨅ b, f b a = ⨅ n, f (h_directed.sequence f n) a := by
refine fun a =>
le_antisymm (le_iInf fun n => iInf_le _ _)
(le_iInf fun b => iInf_le_of_le (Encodable.encode b + 1) ?_)
exact h_directed.sequence_le b a
-- Porting note: used `∘` below to deal with its reduced reducibility
calc
∫⁻ a, ⨅ b, f b a ∂μ
_ = ∫⁻ a, ⨅ n, (f ∘ h_directed.sequence f) n a ∂μ := by simp only [this, Function.comp_apply]
_ = ⨅ n, ∫⁻ a, (f ∘ h_directed.sequence f) n a ∂μ := by
rw [lintegral_iInf ?_ h_directed.sequence_anti]
· exact hf_int _
· exact fun n => hf _
_ = ⨅ b, ∫⁻ a, f b a ∂μ := by
refine le_antisymm (le_iInf fun b => ?_) (le_iInf fun n => ?_)
· exact iInf_le_of_le (Encodable.encode b + 1) (lintegral_mono <| h_directed.sequence_le b)
· exact iInf_le (fun b => ∫⁻ a, f b a ∂μ) _
#align lintegral_infi_directed_of_measurable MeasureTheory.lintegral_iInf_directed_of_measurable
theorem lintegral_liminf_le' {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, AEMeasurable (f n) μ) :
∫⁻ a, liminf (fun n => f n a) atTop ∂μ ≤ liminf (fun n => ∫⁻ a, f n a ∂μ) atTop :=
calc
∫⁻ a, liminf (fun n => f n a) atTop ∂μ = ∫⁻ a, ⨆ n : ℕ, ⨅ i ≥ n, f i a ∂μ := by
simp only [liminf_eq_iSup_iInf_of_nat]
_ = ⨆ n : ℕ, ∫⁻ a, ⨅ i ≥ n, f i a ∂μ :=
(lintegral_iSup' (fun n => aemeasurable_biInf _ (to_countable _) (fun i _ ↦ h_meas i))
(ae_of_all μ fun a n m hnm => iInf_le_iInf_of_subset fun i hi => le_trans hnm hi))
_ ≤ ⨆ n : ℕ, ⨅ i ≥ n, ∫⁻ a, f i a ∂μ := iSup_mono fun n => le_iInf₂_lintegral _
_ = atTop.liminf fun n => ∫⁻ a, f n a ∂μ := Filter.liminf_eq_iSup_iInf_of_nat.symm
#align measure_theory.lintegral_liminf_le' MeasureTheory.lintegral_liminf_le'
theorem lintegral_liminf_le {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, Measurable (f n)) :
∫⁻ a, liminf (fun n => f n a) atTop ∂μ ≤ liminf (fun n => ∫⁻ a, f n a ∂μ) atTop :=
lintegral_liminf_le' fun n => (h_meas n).aemeasurable
#align measure_theory.lintegral_liminf_le MeasureTheory.lintegral_liminf_le
theorem limsup_lintegral_le {f : ℕ → α → ℝ≥0∞} {g : α → ℝ≥0∞} (hf_meas : ∀ n, Measurable (f n))
(h_bound : ∀ n, f n ≤ᵐ[μ] g) (h_fin : ∫⁻ a, g a ∂μ ≠ ∞) :
limsup (fun n => ∫⁻ a, f n a ∂μ) atTop ≤ ∫⁻ a, limsup (fun n => f n a) atTop ∂μ :=
calc
limsup (fun n => ∫⁻ a, f n a ∂μ) atTop = ⨅ n : ℕ, ⨆ i ≥ n, ∫⁻ a, f i a ∂μ :=
limsup_eq_iInf_iSup_of_nat
_ ≤ ⨅ n : ℕ, ∫⁻ a, ⨆ i ≥ n, f i a ∂μ := iInf_mono fun n => iSup₂_lintegral_le _
_ = ∫⁻ a, ⨅ n : ℕ, ⨆ i ≥ n, f i a ∂μ := by
refine (lintegral_iInf ?_ ?_ ?_).symm
· intro n
exact measurable_biSup _ (to_countable _) (fun i _ ↦ hf_meas i)
· intro n m hnm a
exact iSup_le_iSup_of_subset fun i hi => le_trans hnm hi
· refine ne_top_of_le_ne_top h_fin (lintegral_mono_ae ?_)
refine (ae_all_iff.2 h_bound).mono fun n hn => ?_
exact iSup_le fun i => iSup_le fun _ => hn i
_ = ∫⁻ a, limsup (fun n => f n a) atTop ∂μ := by simp only [limsup_eq_iInf_iSup_of_nat]
#align measure_theory.limsup_lintegral_le MeasureTheory.limsup_lintegral_le
theorem tendsto_lintegral_of_dominated_convergence {F : ℕ → α → ℝ≥0∞} {f : α → ℝ≥0∞}
(bound : α → ℝ≥0∞) (hF_meas : ∀ n, Measurable (F n)) (h_bound : ∀ n, F n ≤ᵐ[μ] bound)
(h_fin : ∫⁻ a, bound a ∂μ ≠ ∞) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop (𝓝 (f a))) :
Tendsto (fun n => ∫⁻ a, F n a ∂μ) atTop (𝓝 (∫⁻ a, f a ∂μ)) :=
tendsto_of_le_liminf_of_limsup_le
(calc
∫⁻ a, f a ∂μ = ∫⁻ a, liminf (fun n : ℕ => F n a) atTop ∂μ :=
lintegral_congr_ae <| h_lim.mono fun a h => h.liminf_eq.symm
_ ≤ liminf (fun n => ∫⁻ a, F n a ∂μ) atTop := lintegral_liminf_le hF_meas
)
(calc
limsup (fun n : ℕ => ∫⁻ a, F n a ∂μ) atTop ≤ ∫⁻ a, limsup (fun n => F n a) atTop ∂μ :=
limsup_lintegral_le hF_meas h_bound h_fin
_ = ∫⁻ a, f a ∂μ := lintegral_congr_ae <| h_lim.mono fun a h => h.limsup_eq
)
#align measure_theory.tendsto_lintegral_of_dominated_convergence MeasureTheory.tendsto_lintegral_of_dominated_convergence
theorem tendsto_lintegral_of_dominated_convergence' {F : ℕ → α → ℝ≥0∞} {f : α → ℝ≥0∞}
(bound : α → ℝ≥0∞) (hF_meas : ∀ n, AEMeasurable (F n) μ) (h_bound : ∀ n, F n ≤ᵐ[μ] bound)
(h_fin : ∫⁻ a, bound a ∂μ ≠ ∞) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop (𝓝 (f a))) :
Tendsto (fun n => ∫⁻ a, F n a ∂μ) atTop (𝓝 (∫⁻ a, f a ∂μ)) := by
have : ∀ n, ∫⁻ a, F n a ∂μ = ∫⁻ a, (hF_meas n).mk (F n) a ∂μ := fun n =>
lintegral_congr_ae (hF_meas n).ae_eq_mk
simp_rw [this]
apply
tendsto_lintegral_of_dominated_convergence bound (fun n => (hF_meas n).measurable_mk) _ h_fin
· have : ∀ n, ∀ᵐ a ∂μ, (hF_meas n).mk (F n) a = F n a := fun n => (hF_meas n).ae_eq_mk.symm
have : ∀ᵐ a ∂μ, ∀ n, (hF_meas n).mk (F n) a = F n a := ae_all_iff.mpr this
filter_upwards [this, h_lim] with a H H'
simp_rw [H]
exact H'
· intro n
filter_upwards [h_bound n, (hF_meas n).ae_eq_mk] with a H H'
rwa [H'] at H
#align measure_theory.tendsto_lintegral_of_dominated_convergence' MeasureTheory.tendsto_lintegral_of_dominated_convergence'
theorem tendsto_lintegral_filter_of_dominated_convergence {ι} {l : Filter ι}
[l.IsCountablyGenerated] {F : ι → α → ℝ≥0∞} {f : α → ℝ≥0∞} (bound : α → ℝ≥0∞)
(hF_meas : ∀ᶠ n in l, Measurable (F n)) (h_bound : ∀ᶠ n in l, ∀ᵐ a ∂μ, F n a ≤ bound a)
(h_fin : ∫⁻ a, bound a ∂μ ≠ ∞) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) l (𝓝 (f a))) :
Tendsto (fun n => ∫⁻ a, F n a ∂μ) l (𝓝 <| ∫⁻ a, f a ∂μ) := by
rw [tendsto_iff_seq_tendsto]
intro x xl
have hxl := by
rw [tendsto_atTop'] at xl
exact xl
have h := inter_mem hF_meas h_bound
replace h := hxl _ h
rcases h with ⟨k, h⟩
rw [← tendsto_add_atTop_iff_nat k]
refine tendsto_lintegral_of_dominated_convergence ?_ ?_ ?_ ?_ ?_
· exact bound
· intro
refine (h _ ?_).1
exact Nat.le_add_left _ _
· intro
refine (h _ ?_).2
exact Nat.le_add_left _ _
· assumption
· refine h_lim.mono fun a h_lim => ?_
apply @Tendsto.comp _ _ _ (fun n => x (n + k)) fun n => F n a
· assumption
rw [tendsto_add_atTop_iff_nat]
assumption
#align measure_theory.tendsto_lintegral_filter_of_dominated_convergence MeasureTheory.tendsto_lintegral_filter_of_dominated_convergence
theorem lintegral_tendsto_of_tendsto_of_antitone {f : ℕ → α → ℝ≥0∞} {F : α → ℝ≥0∞}
(hf : ∀ n, AEMeasurable (f n) μ) (h_anti : ∀ᵐ x ∂μ, Antitone fun n ↦ f n x)
(h0 : ∫⁻ a, f 0 a ∂μ ≠ ∞)
(h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n ↦ f n x) atTop (𝓝 (F x))) :
Tendsto (fun n ↦ ∫⁻ x, f n x ∂μ) atTop (𝓝 (∫⁻ x, F x ∂μ)) := by
have : Antitone fun n ↦ ∫⁻ x, f n x ∂μ := fun i j hij ↦
lintegral_mono_ae (h_anti.mono fun x hx ↦ hx hij)
suffices key : ∫⁻ x, F x ∂μ = ⨅ n, ∫⁻ x, f n x ∂μ by
rw [key]
exact tendsto_atTop_iInf this
rw [← lintegral_iInf' hf h_anti h0]
refine lintegral_congr_ae ?_
filter_upwards [h_anti, h_tendsto] with _ hx_anti hx_tendsto
using tendsto_nhds_unique hx_tendsto (tendsto_atTop_iInf hx_anti)
section
open Encodable
theorem lintegral_iSup_directed_of_measurable [Countable β] {f : β → α → ℝ≥0∞}
(hf : ∀ b, Measurable (f b)) (h_directed : Directed (· ≤ ·) f) :
∫⁻ a, ⨆ b, f b a ∂μ = ⨆ b, ∫⁻ a, f b a ∂μ := by
cases nonempty_encodable β
cases isEmpty_or_nonempty β
· simp [iSup_of_empty]
inhabit β
have : ∀ a, ⨆ b, f b a = ⨆ n, f (h_directed.sequence f n) a := by
intro a
refine le_antisymm (iSup_le fun b => ?_) (iSup_le fun n => le_iSup (fun n => f n a) _)
exact le_iSup_of_le (encode b + 1) (h_directed.le_sequence b a)
calc
∫⁻ a, ⨆ b, f b a ∂μ = ∫⁻ a, ⨆ n, f (h_directed.sequence f n) a ∂μ := by simp only [this]
_ = ⨆ n, ∫⁻ a, f (h_directed.sequence f n) a ∂μ :=
(lintegral_iSup (fun n => hf _) h_directed.sequence_mono)
_ = ⨆ b, ∫⁻ a, f b a ∂μ := by
refine le_antisymm (iSup_le fun n => ?_) (iSup_le fun b => ?_)
· exact le_iSup (fun b => ∫⁻ a, f b a ∂μ) _
· exact le_iSup_of_le (encode b + 1) (lintegral_mono <| h_directed.le_sequence b)
#align measure_theory.lintegral_supr_directed_of_measurable MeasureTheory.lintegral_iSup_directed_of_measurable
theorem lintegral_iSup_directed [Countable β] {f : β → α → ℝ≥0∞} (hf : ∀ b, AEMeasurable (f b) μ)
(h_directed : Directed (· ≤ ·) f) : ∫⁻ a, ⨆ b, f b a ∂μ = ⨆ b, ∫⁻ a, f b a ∂μ := by
simp_rw [← iSup_apply]
let p : α → (β → ENNReal) → Prop := fun x f' => Directed LE.le f'
have hp : ∀ᵐ x ∂μ, p x fun i => f i x := by
filter_upwards [] with x i j
obtain ⟨z, hz₁, hz₂⟩ := h_directed i j
exact ⟨z, hz₁ x, hz₂ x⟩
have h_ae_seq_directed : Directed LE.le (aeSeq hf p) := by
intro b₁ b₂
obtain ⟨z, hz₁, hz₂⟩ := h_directed b₁ b₂
refine ⟨z, ?_, ?_⟩ <;>
· intro x
by_cases hx : x ∈ aeSeqSet hf p
· repeat rw [aeSeq.aeSeq_eq_fun_of_mem_aeSeqSet hf hx]
apply_rules [hz₁, hz₂]
· simp only [aeSeq, hx, if_false]
exact le_rfl
convert lintegral_iSup_directed_of_measurable (aeSeq.measurable hf p) h_ae_seq_directed using 1
· simp_rw [← iSup_apply]
rw [lintegral_congr_ae (aeSeq.iSup hf hp).symm]
· congr 1
ext1 b
rw [lintegral_congr_ae]
apply EventuallyEq.symm
exact aeSeq.aeSeq_n_eq_fun_n_ae hf hp _
#align measure_theory.lintegral_supr_directed MeasureTheory.lintegral_iSup_directed
end
theorem lintegral_tsum [Countable β] {f : β → α → ℝ≥0∞} (hf : ∀ i, AEMeasurable (f i) μ) :
∫⁻ a, ∑' i, f i a ∂μ = ∑' i, ∫⁻ a, f i a ∂μ := by
simp only [ENNReal.tsum_eq_iSup_sum]
rw [lintegral_iSup_directed]
· simp [lintegral_finset_sum' _ fun i _ => hf i]
· intro b
exact Finset.aemeasurable_sum _ fun i _ => hf i
· intro s t
use s ∪ t
constructor
· exact fun a => Finset.sum_le_sum_of_subset Finset.subset_union_left
· exact fun a => Finset.sum_le_sum_of_subset Finset.subset_union_right
#align measure_theory.lintegral_tsum MeasureTheory.lintegral_tsum
open Measure
theorem lintegral_iUnion₀ [Countable β] {s : β → Set α} (hm : ∀ i, NullMeasurableSet (s i) μ)
(hd : Pairwise (AEDisjoint μ on s)) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i, s i, f a ∂μ = ∑' i, ∫⁻ a in s i, f a ∂μ := by
simp only [Measure.restrict_iUnion_ae hd hm, lintegral_sum_measure]
#align measure_theory.lintegral_Union₀ MeasureTheory.lintegral_iUnion₀
theorem lintegral_iUnion [Countable β] {s : β → Set α} (hm : ∀ i, MeasurableSet (s i))
(hd : Pairwise (Disjoint on s)) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i, s i, f a ∂μ = ∑' i, ∫⁻ a in s i, f a ∂μ :=
lintegral_iUnion₀ (fun i => (hm i).nullMeasurableSet) hd.aedisjoint f
#align measure_theory.lintegral_Union MeasureTheory.lintegral_iUnion
theorem lintegral_biUnion₀ {t : Set β} {s : β → Set α} (ht : t.Countable)
(hm : ∀ i ∈ t, NullMeasurableSet (s i) μ) (hd : t.Pairwise (AEDisjoint μ on s)) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i ∈ t, s i, f a ∂μ = ∑' i : t, ∫⁻ a in s i, f a ∂μ := by
haveI := ht.toEncodable
rw [biUnion_eq_iUnion, lintegral_iUnion₀ (SetCoe.forall'.1 hm) (hd.subtype _ _)]
#align measure_theory.lintegral_bUnion₀ MeasureTheory.lintegral_biUnion₀
theorem lintegral_biUnion {t : Set β} {s : β → Set α} (ht : t.Countable)
(hm : ∀ i ∈ t, MeasurableSet (s i)) (hd : t.PairwiseDisjoint s) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i ∈ t, s i, f a ∂μ = ∑' i : t, ∫⁻ a in s i, f a ∂μ :=
lintegral_biUnion₀ ht (fun i hi => (hm i hi).nullMeasurableSet) hd.aedisjoint f
#align measure_theory.lintegral_bUnion MeasureTheory.lintegral_biUnion
theorem lintegral_biUnion_finset₀ {s : Finset β} {t : β → Set α}
(hd : Set.Pairwise (↑s) (AEDisjoint μ on t)) (hm : ∀ b ∈ s, NullMeasurableSet (t b) μ)
(f : α → ℝ≥0∞) : ∫⁻ a in ⋃ b ∈ s, t b, f a ∂μ = ∑ b ∈ s, ∫⁻ a in t b, f a ∂μ := by
simp only [← Finset.mem_coe, lintegral_biUnion₀ s.countable_toSet hm hd, ← Finset.tsum_subtype']
#align measure_theory.lintegral_bUnion_finset₀ MeasureTheory.lintegral_biUnion_finset₀
theorem lintegral_biUnion_finset {s : Finset β} {t : β → Set α} (hd : Set.PairwiseDisjoint (↑s) t)
(hm : ∀ b ∈ s, MeasurableSet (t b)) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ b ∈ s, t b, f a ∂μ = ∑ b ∈ s, ∫⁻ a in t b, f a ∂μ :=
lintegral_biUnion_finset₀ hd.aedisjoint (fun b hb => (hm b hb).nullMeasurableSet) f
#align measure_theory.lintegral_bUnion_finset MeasureTheory.lintegral_biUnion_finset
theorem lintegral_iUnion_le [Countable β] (s : β → Set α) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i, s i, f a ∂μ ≤ ∑' i, ∫⁻ a in s i, f a ∂μ := by
rw [← lintegral_sum_measure]
exact lintegral_mono' restrict_iUnion_le le_rfl
#align measure_theory.lintegral_Union_le MeasureTheory.lintegral_iUnion_le
theorem lintegral_union {f : α → ℝ≥0∞} {A B : Set α} (hB : MeasurableSet B) (hAB : Disjoint A B) :
∫⁻ a in A ∪ B, f a ∂μ = ∫⁻ a in A, f a ∂μ + ∫⁻ a in B, f a ∂μ := by
rw [restrict_union hAB hB, lintegral_add_measure]
#align measure_theory.lintegral_union MeasureTheory.lintegral_union
theorem lintegral_union_le (f : α → ℝ≥0∞) (s t : Set α) :
∫⁻ a in s ∪ t, f a ∂μ ≤ ∫⁻ a in s, f a ∂μ + ∫⁻ a in t, f a ∂μ := by
rw [← lintegral_add_measure]
exact lintegral_mono' (restrict_union_le _ _) le_rfl
theorem lintegral_inter_add_diff {B : Set α} (f : α → ℝ≥0∞) (A : Set α) (hB : MeasurableSet B) :
∫⁻ x in A ∩ B, f x ∂μ + ∫⁻ x in A \ B, f x ∂μ = ∫⁻ x in A, f x ∂μ := by
rw [← lintegral_add_measure, restrict_inter_add_diff _ hB]
#align measure_theory.lintegral_inter_add_diff MeasureTheory.lintegral_inter_add_diff
theorem lintegral_add_compl (f : α → ℝ≥0∞) {A : Set α} (hA : MeasurableSet A) :
∫⁻ x in A, f x ∂μ + ∫⁻ x in Aᶜ, f x ∂μ = ∫⁻ x, f x ∂μ := by
rw [← lintegral_add_measure, Measure.restrict_add_restrict_compl hA]
#align measure_theory.lintegral_add_compl MeasureTheory.lintegral_add_compl
theorem lintegral_max {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) :
∫⁻ x, max (f x) (g x) ∂μ =
∫⁻ x in { x | f x ≤ g x }, g x ∂μ + ∫⁻ x in { x | g x < f x }, f x ∂μ := by
have hm : MeasurableSet { x | f x ≤ g x } := measurableSet_le hf hg
rw [← lintegral_add_compl (fun x => max (f x) (g x)) hm]
simp only [← compl_setOf, ← not_le]
refine congr_arg₂ (· + ·) (set_lintegral_congr_fun hm ?_) (set_lintegral_congr_fun hm.compl ?_)
exacts [ae_of_all _ fun x => max_eq_right (a := f x) (b := g x),
ae_of_all _ fun x (hx : ¬ f x ≤ g x) => max_eq_left (not_le.1 hx).le]
#align measure_theory.lintegral_max MeasureTheory.lintegral_max
theorem set_lintegral_max {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) (s : Set α) :
∫⁻ x in s, max (f x) (g x) ∂μ =
∫⁻ x in s ∩ { x | f x ≤ g x }, g x ∂μ + ∫⁻ x in s ∩ { x | g x < f x }, f x ∂μ := by
rw [lintegral_max hf hg, restrict_restrict, restrict_restrict, inter_comm s, inter_comm s]
exacts [measurableSet_lt hg hf, measurableSet_le hf hg]
#align measure_theory.set_lintegral_max MeasureTheory.set_lintegral_max
theorem lintegral_map {mβ : MeasurableSpace β} {f : β → ℝ≥0∞} {g : α → β} (hf : Measurable f)
(hg : Measurable g) : ∫⁻ a, f a ∂map g μ = ∫⁻ a, f (g a) ∂μ := by
erw [lintegral_eq_iSup_eapprox_lintegral hf, lintegral_eq_iSup_eapprox_lintegral (hf.comp hg)]
congr with n : 1
convert SimpleFunc.lintegral_map _ hg
ext1 x; simp only [eapprox_comp hf hg, coe_comp]
#align measure_theory.lintegral_map MeasureTheory.lintegral_map
theorem lintegral_map' {mβ : MeasurableSpace β} {f : β → ℝ≥0∞} {g : α → β}
(hf : AEMeasurable f (Measure.map g μ)) (hg : AEMeasurable g μ) :
∫⁻ a, f a ∂Measure.map g μ = ∫⁻ a, f (g a) ∂μ :=
calc
∫⁻ a, f a ∂Measure.map g μ = ∫⁻ a, hf.mk f a ∂Measure.map g μ :=
lintegral_congr_ae hf.ae_eq_mk
_ = ∫⁻ a, hf.mk f a ∂Measure.map (hg.mk g) μ := by
congr 1
exact Measure.map_congr hg.ae_eq_mk
_ = ∫⁻ a, hf.mk f (hg.mk g a) ∂μ := lintegral_map hf.measurable_mk hg.measurable_mk
_ = ∫⁻ a, hf.mk f (g a) ∂μ := lintegral_congr_ae <| hg.ae_eq_mk.symm.fun_comp _
_ = ∫⁻ a, f (g a) ∂μ := lintegral_congr_ae (ae_eq_comp hg hf.ae_eq_mk.symm)
#align measure_theory.lintegral_map' MeasureTheory.lintegral_map'
theorem lintegral_map_le {mβ : MeasurableSpace β} (f : β → ℝ≥0∞) {g : α → β} (hg : Measurable g) :
∫⁻ a, f a ∂Measure.map g μ ≤ ∫⁻ a, f (g a) ∂μ := by
rw [← iSup_lintegral_measurable_le_eq_lintegral, ← iSup_lintegral_measurable_le_eq_lintegral]
refine iSup₂_le fun i hi => iSup_le fun h'i => ?_
refine le_iSup₂_of_le (i ∘ g) (hi.comp hg) ?_
exact le_iSup_of_le (fun x => h'i (g x)) (le_of_eq (lintegral_map hi hg))
#align measure_theory.lintegral_map_le MeasureTheory.lintegral_map_le
theorem lintegral_comp [MeasurableSpace β] {f : β → ℝ≥0∞} {g : α → β} (hf : Measurable f)
(hg : Measurable g) : lintegral μ (f ∘ g) = ∫⁻ a, f a ∂map g μ :=
(lintegral_map hf hg).symm
#align measure_theory.lintegral_comp MeasureTheory.lintegral_comp
theorem set_lintegral_map [MeasurableSpace β] {f : β → ℝ≥0∞} {g : α → β} {s : Set β}
(hs : MeasurableSet s) (hf : Measurable f) (hg : Measurable g) :
∫⁻ y in s, f y ∂map g μ = ∫⁻ x in g ⁻¹' s, f (g x) ∂μ := by
rw [restrict_map hg hs, lintegral_map hf hg]
#align measure_theory.set_lintegral_map MeasureTheory.set_lintegral_map
theorem lintegral_indicator_const_comp {mβ : MeasurableSpace β} {f : α → β} {s : Set β}
(hf : Measurable f) (hs : MeasurableSet s) (c : ℝ≥0∞) :
∫⁻ a, s.indicator (fun _ => c) (f a) ∂μ = c * μ (f ⁻¹' s) := by
erw [lintegral_comp (measurable_const.indicator hs) hf, lintegral_indicator_const hs,
Measure.map_apply hf hs]
#align measure_theory.lintegral_indicator_const_comp MeasureTheory.lintegral_indicator_const_comp
| Mathlib/MeasureTheory/Integral/Lebesgue.lean | 1,437 | 1,447 | theorem _root_.MeasurableEmbedding.lintegral_map [MeasurableSpace β] {g : α → β}
(hg : MeasurableEmbedding g) (f : β → ℝ≥0∞) : ∫⁻ a, f a ∂map g μ = ∫⁻ a, f (g a) ∂μ := by |
rw [lintegral, lintegral]
refine le_antisymm (iSup₂_le fun f₀ hf₀ => ?_) (iSup₂_le fun f₀ hf₀ => ?_)
· rw [SimpleFunc.lintegral_map _ hg.measurable]
have : (f₀.comp g hg.measurable : α → ℝ≥0∞) ≤ f ∘ g := fun x => hf₀ (g x)
exact le_iSup_of_le (comp f₀ g hg.measurable) (by exact le_iSup (α := ℝ≥0∞) _ this)
· rw [← f₀.extend_comp_eq hg (const _ 0), ← SimpleFunc.lintegral_map, ←
SimpleFunc.lintegral_eq_lintegral, ← lintegral]
refine lintegral_mono_ae (hg.ae_map_iff.2 <| eventually_of_forall fun x => ?_)
exact (extend_apply _ _ _ _).trans_le (hf₀ _)
|
import Mathlib.Order.Interval.Set.Basic
import Mathlib.Data.Set.NAry
import Mathlib.Order.Directed
#align_import order.bounds.basic from "leanprover-community/mathlib"@"b1abe23ae96fef89ad30d9f4362c307f72a55010"
open Function Set
open OrderDual (toDual ofDual)
universe u v w x
variable {α : Type u} {β : Type v} {γ : Type w} {ι : Sort x}
section
variable [Preorder α] [Preorder β] {s t : Set α} {a b : α}
def upperBounds (s : Set α) : Set α :=
{ x | ∀ ⦃a⦄, a ∈ s → a ≤ x }
#align upper_bounds upperBounds
def lowerBounds (s : Set α) : Set α :=
{ x | ∀ ⦃a⦄, a ∈ s → x ≤ a }
#align lower_bounds lowerBounds
def BddAbove (s : Set α) :=
(upperBounds s).Nonempty
#align bdd_above BddAbove
def BddBelow (s : Set α) :=
(lowerBounds s).Nonempty
#align bdd_below BddBelow
def IsLeast (s : Set α) (a : α) : Prop :=
a ∈ s ∧ a ∈ lowerBounds s
#align is_least IsLeast
def IsGreatest (s : Set α) (a : α) : Prop :=
a ∈ s ∧ a ∈ upperBounds s
#align is_greatest IsGreatest
def IsLUB (s : Set α) : α → Prop :=
IsLeast (upperBounds s)
#align is_lub IsLUB
def IsGLB (s : Set α) : α → Prop :=
IsGreatest (lowerBounds s)
#align is_glb IsGLB
theorem mem_upperBounds : a ∈ upperBounds s ↔ ∀ x ∈ s, x ≤ a :=
Iff.rfl
#align mem_upper_bounds mem_upperBounds
theorem mem_lowerBounds : a ∈ lowerBounds s ↔ ∀ x ∈ s, a ≤ x :=
Iff.rfl
#align mem_lower_bounds mem_lowerBounds
lemma mem_upperBounds_iff_subset_Iic : a ∈ upperBounds s ↔ s ⊆ Iic a := Iff.rfl
#align mem_upper_bounds_iff_subset_Iic mem_upperBounds_iff_subset_Iic
lemma mem_lowerBounds_iff_subset_Ici : a ∈ lowerBounds s ↔ s ⊆ Ici a := Iff.rfl
#align mem_lower_bounds_iff_subset_Ici mem_lowerBounds_iff_subset_Ici
theorem bddAbove_def : BddAbove s ↔ ∃ x, ∀ y ∈ s, y ≤ x :=
Iff.rfl
#align bdd_above_def bddAbove_def
theorem bddBelow_def : BddBelow s ↔ ∃ x, ∀ y ∈ s, x ≤ y :=
Iff.rfl
#align bdd_below_def bddBelow_def
theorem bot_mem_lowerBounds [OrderBot α] (s : Set α) : ⊥ ∈ lowerBounds s := fun _ _ => bot_le
#align bot_mem_lower_bounds bot_mem_lowerBounds
theorem top_mem_upperBounds [OrderTop α] (s : Set α) : ⊤ ∈ upperBounds s := fun _ _ => le_top
#align top_mem_upper_bounds top_mem_upperBounds
@[simp]
theorem isLeast_bot_iff [OrderBot α] : IsLeast s ⊥ ↔ ⊥ ∈ s :=
and_iff_left <| bot_mem_lowerBounds _
#align is_least_bot_iff isLeast_bot_iff
@[simp]
theorem isGreatest_top_iff [OrderTop α] : IsGreatest s ⊤ ↔ ⊤ ∈ s :=
and_iff_left <| top_mem_upperBounds _
#align is_greatest_top_iff isGreatest_top_iff
theorem not_bddAbove_iff' : ¬BddAbove s ↔ ∀ x, ∃ y ∈ s, ¬y ≤ x := by
simp [BddAbove, upperBounds, Set.Nonempty]
#align not_bdd_above_iff' not_bddAbove_iff'
theorem not_bddBelow_iff' : ¬BddBelow s ↔ ∀ x, ∃ y ∈ s, ¬x ≤ y :=
@not_bddAbove_iff' αᵒᵈ _ _
#align not_bdd_below_iff' not_bddBelow_iff'
theorem not_bddAbove_iff {α : Type*} [LinearOrder α] {s : Set α} :
¬BddAbove s ↔ ∀ x, ∃ y ∈ s, x < y := by
simp only [not_bddAbove_iff', not_le]
#align not_bdd_above_iff not_bddAbove_iff
theorem not_bddBelow_iff {α : Type*} [LinearOrder α] {s : Set α} :
¬BddBelow s ↔ ∀ x, ∃ y ∈ s, y < x :=
@not_bddAbove_iff αᵒᵈ _ _
#align not_bdd_below_iff not_bddBelow_iff
@[simp] lemma bddBelow_preimage_ofDual {s : Set α} : BddBelow (ofDual ⁻¹' s) ↔ BddAbove s := Iff.rfl
@[simp] lemma bddAbove_preimage_ofDual {s : Set α} : BddAbove (ofDual ⁻¹' s) ↔ BddBelow s := Iff.rfl
@[simp] lemma bddBelow_preimage_toDual {s : Set αᵒᵈ} :
BddBelow (toDual ⁻¹' s) ↔ BddAbove s := Iff.rfl
@[simp] lemma bddAbove_preimage_toDual {s : Set αᵒᵈ} :
BddAbove (toDual ⁻¹' s) ↔ BddBelow s := Iff.rfl
theorem BddAbove.dual (h : BddAbove s) : BddBelow (ofDual ⁻¹' s) :=
h
#align bdd_above.dual BddAbove.dual
theorem BddBelow.dual (h : BddBelow s) : BddAbove (ofDual ⁻¹' s) :=
h
#align bdd_below.dual BddBelow.dual
theorem IsLeast.dual (h : IsLeast s a) : IsGreatest (ofDual ⁻¹' s) (toDual a) :=
h
#align is_least.dual IsLeast.dual
theorem IsGreatest.dual (h : IsGreatest s a) : IsLeast (ofDual ⁻¹' s) (toDual a) :=
h
#align is_greatest.dual IsGreatest.dual
theorem IsLUB.dual (h : IsLUB s a) : IsGLB (ofDual ⁻¹' s) (toDual a) :=
h
#align is_lub.dual IsLUB.dual
theorem IsGLB.dual (h : IsGLB s a) : IsLUB (ofDual ⁻¹' s) (toDual a) :=
h
#align is_glb.dual IsGLB.dual
abbrev IsLeast.orderBot (h : IsLeast s a) :
OrderBot s where
bot := ⟨a, h.1⟩
bot_le := Subtype.forall.2 h.2
#align is_least.order_bot IsLeast.orderBot
abbrev IsGreatest.orderTop (h : IsGreatest s a) :
OrderTop s where
top := ⟨a, h.1⟩
le_top := Subtype.forall.2 h.2
#align is_greatest.order_top IsGreatest.orderTop
theorem upperBounds_mono_set ⦃s t : Set α⦄ (hst : s ⊆ t) : upperBounds t ⊆ upperBounds s :=
fun _ hb _ h => hb <| hst h
#align upper_bounds_mono_set upperBounds_mono_set
theorem lowerBounds_mono_set ⦃s t : Set α⦄ (hst : s ⊆ t) : lowerBounds t ⊆ lowerBounds s :=
fun _ hb _ h => hb <| hst h
#align lower_bounds_mono_set lowerBounds_mono_set
theorem upperBounds_mono_mem ⦃a b⦄ (hab : a ≤ b) : a ∈ upperBounds s → b ∈ upperBounds s :=
fun ha _ h => le_trans (ha h) hab
#align upper_bounds_mono_mem upperBounds_mono_mem
theorem lowerBounds_mono_mem ⦃a b⦄ (hab : a ≤ b) : b ∈ lowerBounds s → a ∈ lowerBounds s :=
fun hb _ h => le_trans hab (hb h)
#align lower_bounds_mono_mem lowerBounds_mono_mem
theorem upperBounds_mono ⦃s t : Set α⦄ (hst : s ⊆ t) ⦃a b⦄ (hab : a ≤ b) :
a ∈ upperBounds t → b ∈ upperBounds s := fun ha =>
upperBounds_mono_set hst <| upperBounds_mono_mem hab ha
#align upper_bounds_mono upperBounds_mono
theorem lowerBounds_mono ⦃s t : Set α⦄ (hst : s ⊆ t) ⦃a b⦄ (hab : a ≤ b) :
b ∈ lowerBounds t → a ∈ lowerBounds s := fun hb =>
lowerBounds_mono_set hst <| lowerBounds_mono_mem hab hb
#align lower_bounds_mono lowerBounds_mono
theorem BddAbove.mono ⦃s t : Set α⦄ (h : s ⊆ t) : BddAbove t → BddAbove s :=
Nonempty.mono <| upperBounds_mono_set h
#align bdd_above.mono BddAbove.mono
theorem BddBelow.mono ⦃s t : Set α⦄ (h : s ⊆ t) : BddBelow t → BddBelow s :=
Nonempty.mono <| lowerBounds_mono_set h
#align bdd_below.mono BddBelow.mono
theorem IsLUB.of_subset_of_superset {s t p : Set α} (hs : IsLUB s a) (hp : IsLUB p a) (hst : s ⊆ t)
(htp : t ⊆ p) : IsLUB t a :=
⟨upperBounds_mono_set htp hp.1, lowerBounds_mono_set (upperBounds_mono_set hst) hs.2⟩
#align is_lub.of_subset_of_superset IsLUB.of_subset_of_superset
theorem IsGLB.of_subset_of_superset {s t p : Set α} (hs : IsGLB s a) (hp : IsGLB p a) (hst : s ⊆ t)
(htp : t ⊆ p) : IsGLB t a :=
hs.dual.of_subset_of_superset hp hst htp
#align is_glb.of_subset_of_superset IsGLB.of_subset_of_superset
theorem IsLeast.mono (ha : IsLeast s a) (hb : IsLeast t b) (hst : s ⊆ t) : b ≤ a :=
hb.2 (hst ha.1)
#align is_least.mono IsLeast.mono
theorem IsGreatest.mono (ha : IsGreatest s a) (hb : IsGreatest t b) (hst : s ⊆ t) : a ≤ b :=
hb.2 (hst ha.1)
#align is_greatest.mono IsGreatest.mono
theorem IsLUB.mono (ha : IsLUB s a) (hb : IsLUB t b) (hst : s ⊆ t) : a ≤ b :=
IsLeast.mono hb ha <| upperBounds_mono_set hst
#align is_lub.mono IsLUB.mono
theorem IsGLB.mono (ha : IsGLB s a) (hb : IsGLB t b) (hst : s ⊆ t) : b ≤ a :=
IsGreatest.mono hb ha <| lowerBounds_mono_set hst
#align is_glb.mono IsGLB.mono
theorem subset_lowerBounds_upperBounds (s : Set α) : s ⊆ lowerBounds (upperBounds s) :=
fun _ hx _ hy => hy hx
#align subset_lower_bounds_upper_bounds subset_lowerBounds_upperBounds
theorem subset_upperBounds_lowerBounds (s : Set α) : s ⊆ upperBounds (lowerBounds s) :=
fun _ hx _ hy => hy hx
#align subset_upper_bounds_lower_bounds subset_upperBounds_lowerBounds
theorem Set.Nonempty.bddAbove_lowerBounds (hs : s.Nonempty) : BddAbove (lowerBounds s) :=
hs.mono (subset_upperBounds_lowerBounds s)
#align set.nonempty.bdd_above_lower_bounds Set.Nonempty.bddAbove_lowerBounds
theorem Set.Nonempty.bddBelow_upperBounds (hs : s.Nonempty) : BddBelow (upperBounds s) :=
hs.mono (subset_lowerBounds_upperBounds s)
#align set.nonempty.bdd_below_upper_bounds Set.Nonempty.bddBelow_upperBounds
theorem IsLeast.isGLB (h : IsLeast s a) : IsGLB s a :=
⟨h.2, fun _ hb => hb h.1⟩
#align is_least.is_glb IsLeast.isGLB
theorem IsGreatest.isLUB (h : IsGreatest s a) : IsLUB s a :=
⟨h.2, fun _ hb => hb h.1⟩
#align is_greatest.is_lub IsGreatest.isLUB
theorem IsLUB.upperBounds_eq (h : IsLUB s a) : upperBounds s = Ici a :=
Set.ext fun _ => ⟨fun hb => h.2 hb, fun hb => upperBounds_mono_mem hb h.1⟩
#align is_lub.upper_bounds_eq IsLUB.upperBounds_eq
theorem IsGLB.lowerBounds_eq (h : IsGLB s a) : lowerBounds s = Iic a :=
h.dual.upperBounds_eq
#align is_glb.lower_bounds_eq IsGLB.lowerBounds_eq
theorem IsLeast.lowerBounds_eq (h : IsLeast s a) : lowerBounds s = Iic a :=
h.isGLB.lowerBounds_eq
#align is_least.lower_bounds_eq IsLeast.lowerBounds_eq
theorem IsGreatest.upperBounds_eq (h : IsGreatest s a) : upperBounds s = Ici a :=
h.isLUB.upperBounds_eq
#align is_greatest.upper_bounds_eq IsGreatest.upperBounds_eq
-- Porting note (#10756): new lemma
theorem IsGreatest.lt_iff (h : IsGreatest s a) : a < b ↔ ∀ x ∈ s, x < b :=
⟨fun hlt _x hx => (h.2 hx).trans_lt hlt, fun h' => h' _ h.1⟩
-- Porting note (#10756): new lemma
theorem IsLeast.lt_iff (h : IsLeast s a) : b < a ↔ ∀ x ∈ s, b < x :=
h.dual.lt_iff
theorem isLUB_le_iff (h : IsLUB s a) : a ≤ b ↔ b ∈ upperBounds s := by
rw [h.upperBounds_eq]
rfl
#align is_lub_le_iff isLUB_le_iff
theorem le_isGLB_iff (h : IsGLB s a) : b ≤ a ↔ b ∈ lowerBounds s := by
rw [h.lowerBounds_eq]
rfl
#align le_is_glb_iff le_isGLB_iff
theorem isLUB_iff_le_iff : IsLUB s a ↔ ∀ b, a ≤ b ↔ b ∈ upperBounds s :=
⟨fun h _ => isLUB_le_iff h, fun H => ⟨(H _).1 le_rfl, fun b hb => (H b).2 hb⟩⟩
#align is_lub_iff_le_iff isLUB_iff_le_iff
theorem isGLB_iff_le_iff : IsGLB s a ↔ ∀ b, b ≤ a ↔ b ∈ lowerBounds s :=
@isLUB_iff_le_iff αᵒᵈ _ _ _
#align is_glb_iff_le_iff isGLB_iff_le_iff
theorem IsLUB.bddAbove (h : IsLUB s a) : BddAbove s :=
⟨a, h.1⟩
#align is_lub.bdd_above IsLUB.bddAbove
theorem IsGLB.bddBelow (h : IsGLB s a) : BddBelow s :=
⟨a, h.1⟩
#align is_glb.bdd_below IsGLB.bddBelow
theorem IsGreatest.bddAbove (h : IsGreatest s a) : BddAbove s :=
⟨a, h.2⟩
#align is_greatest.bdd_above IsGreatest.bddAbove
theorem IsLeast.bddBelow (h : IsLeast s a) : BddBelow s :=
⟨a, h.2⟩
#align is_least.bdd_below IsLeast.bddBelow
theorem IsLeast.nonempty (h : IsLeast s a) : s.Nonempty :=
⟨a, h.1⟩
#align is_least.nonempty IsLeast.nonempty
theorem IsGreatest.nonempty (h : IsGreatest s a) : s.Nonempty :=
⟨a, h.1⟩
#align is_greatest.nonempty IsGreatest.nonempty
@[simp]
theorem upperBounds_union : upperBounds (s ∪ t) = upperBounds s ∩ upperBounds t :=
Subset.antisymm (fun _ hb => ⟨fun _ hx => hb (Or.inl hx), fun _ hx => hb (Or.inr hx)⟩)
fun _ hb _ hx => hx.elim (fun hs => hb.1 hs) fun ht => hb.2 ht
#align upper_bounds_union upperBounds_union
@[simp]
theorem lowerBounds_union : lowerBounds (s ∪ t) = lowerBounds s ∩ lowerBounds t :=
@upperBounds_union αᵒᵈ _ s t
#align lower_bounds_union lowerBounds_union
theorem union_upperBounds_subset_upperBounds_inter :
upperBounds s ∪ upperBounds t ⊆ upperBounds (s ∩ t) :=
union_subset (upperBounds_mono_set inter_subset_left)
(upperBounds_mono_set inter_subset_right)
#align union_upper_bounds_subset_upper_bounds_inter union_upperBounds_subset_upperBounds_inter
theorem union_lowerBounds_subset_lowerBounds_inter :
lowerBounds s ∪ lowerBounds t ⊆ lowerBounds (s ∩ t) :=
@union_upperBounds_subset_upperBounds_inter αᵒᵈ _ s t
#align union_lower_bounds_subset_lower_bounds_inter union_lowerBounds_subset_lowerBounds_inter
theorem isLeast_union_iff {a : α} {s t : Set α} :
IsLeast (s ∪ t) a ↔ IsLeast s a ∧ a ∈ lowerBounds t ∨ a ∈ lowerBounds s ∧ IsLeast t a := by
simp [IsLeast, lowerBounds_union, or_and_right, and_comm (a := a ∈ t), and_assoc]
#align is_least_union_iff isLeast_union_iff
theorem isGreatest_union_iff :
IsGreatest (s ∪ t) a ↔
IsGreatest s a ∧ a ∈ upperBounds t ∨ a ∈ upperBounds s ∧ IsGreatest t a :=
@isLeast_union_iff αᵒᵈ _ a s t
#align is_greatest_union_iff isGreatest_union_iff
theorem BddAbove.inter_of_left (h : BddAbove s) : BddAbove (s ∩ t) :=
h.mono inter_subset_left
#align bdd_above.inter_of_left BddAbove.inter_of_left
theorem BddAbove.inter_of_right (h : BddAbove t) : BddAbove (s ∩ t) :=
h.mono inter_subset_right
#align bdd_above.inter_of_right BddAbove.inter_of_right
theorem BddBelow.inter_of_left (h : BddBelow s) : BddBelow (s ∩ t) :=
h.mono inter_subset_left
#align bdd_below.inter_of_left BddBelow.inter_of_left
theorem BddBelow.inter_of_right (h : BddBelow t) : BddBelow (s ∩ t) :=
h.mono inter_subset_right
#align bdd_below.inter_of_right BddBelow.inter_of_right
theorem BddAbove.union [IsDirected α (· ≤ ·)] {s t : Set α} :
BddAbove s → BddAbove t → BddAbove (s ∪ t) := by
rintro ⟨a, ha⟩ ⟨b, hb⟩
obtain ⟨c, hca, hcb⟩ := exists_ge_ge a b
rw [BddAbove, upperBounds_union]
exact ⟨c, upperBounds_mono_mem hca ha, upperBounds_mono_mem hcb hb⟩
#align bdd_above.union BddAbove.union
theorem bddAbove_union [IsDirected α (· ≤ ·)] {s t : Set α} :
BddAbove (s ∪ t) ↔ BddAbove s ∧ BddAbove t :=
⟨fun h => ⟨h.mono subset_union_left, h.mono subset_union_right⟩, fun h =>
h.1.union h.2⟩
#align bdd_above_union bddAbove_union
theorem BddBelow.union [IsDirected α (· ≥ ·)] {s t : Set α} :
BddBelow s → BddBelow t → BddBelow (s ∪ t) :=
@BddAbove.union αᵒᵈ _ _ _ _
#align bdd_below.union BddBelow.union
theorem bddBelow_union [IsDirected α (· ≥ ·)] {s t : Set α} :
BddBelow (s ∪ t) ↔ BddBelow s ∧ BddBelow t :=
@bddAbove_union αᵒᵈ _ _ _ _
#align bdd_below_union bddBelow_union
theorem IsLUB.union [SemilatticeSup γ] {a b : γ} {s t : Set γ} (hs : IsLUB s a) (ht : IsLUB t b) :
IsLUB (s ∪ t) (a ⊔ b) :=
⟨fun _ h =>
h.casesOn (fun h => le_sup_of_le_left <| hs.left h) fun h => le_sup_of_le_right <| ht.left h,
fun _ hc =>
sup_le (hs.right fun _ hd => hc <| Or.inl hd) (ht.right fun _ hd => hc <| Or.inr hd)⟩
#align is_lub.union IsLUB.union
theorem IsGLB.union [SemilatticeInf γ] {a₁ a₂ : γ} {s t : Set γ} (hs : IsGLB s a₁)
(ht : IsGLB t a₂) : IsGLB (s ∪ t) (a₁ ⊓ a₂) :=
hs.dual.union ht
#align is_glb.union IsGLB.union
theorem IsLeast.union [LinearOrder γ] {a b : γ} {s t : Set γ} (ha : IsLeast s a)
(hb : IsLeast t b) : IsLeast (s ∪ t) (min a b) :=
⟨by rcases le_total a b with h | h <;> simp [h, ha.1, hb.1], (ha.isGLB.union hb.isGLB).1⟩
#align is_least.union IsLeast.union
theorem IsGreatest.union [LinearOrder γ] {a b : γ} {s t : Set γ} (ha : IsGreatest s a)
(hb : IsGreatest t b) : IsGreatest (s ∪ t) (max a b) :=
⟨by rcases le_total a b with h | h <;> simp [h, ha.1, hb.1], (ha.isLUB.union hb.isLUB).1⟩
#align is_greatest.union IsGreatest.union
theorem IsLUB.inter_Ici_of_mem [LinearOrder γ] {s : Set γ} {a b : γ} (ha : IsLUB s a) (hb : b ∈ s) :
IsLUB (s ∩ Ici b) a :=
⟨fun _ hx => ha.1 hx.1, fun c hc =>
have hbc : b ≤ c := hc ⟨hb, le_rfl⟩
ha.2 fun x hx => ((le_total x b).elim fun hxb => hxb.trans hbc) fun hbx => hc ⟨hx, hbx⟩⟩
#align is_lub.inter_Ici_of_mem IsLUB.inter_Ici_of_mem
theorem IsGLB.inter_Iic_of_mem [LinearOrder γ] {s : Set γ} {a b : γ} (ha : IsGLB s a) (hb : b ∈ s) :
IsGLB (s ∩ Iic b) a :=
ha.dual.inter_Ici_of_mem hb
#align is_glb.inter_Iic_of_mem IsGLB.inter_Iic_of_mem
theorem bddAbove_iff_exists_ge [SemilatticeSup γ] {s : Set γ} (x₀ : γ) :
BddAbove s ↔ ∃ x, x₀ ≤ x ∧ ∀ y ∈ s, y ≤ x := by
rw [bddAbove_def, exists_ge_and_iff_exists]
exact Monotone.ball fun x _ => monotone_le
#align bdd_above_iff_exists_ge bddAbove_iff_exists_ge
theorem bddBelow_iff_exists_le [SemilatticeInf γ] {s : Set γ} (x₀ : γ) :
BddBelow s ↔ ∃ x, x ≤ x₀ ∧ ∀ y ∈ s, x ≤ y :=
bddAbove_iff_exists_ge (toDual x₀)
#align bdd_below_iff_exists_le bddBelow_iff_exists_le
theorem BddAbove.exists_ge [SemilatticeSup γ] {s : Set γ} (hs : BddAbove s) (x₀ : γ) :
∃ x, x₀ ≤ x ∧ ∀ y ∈ s, y ≤ x :=
(bddAbove_iff_exists_ge x₀).mp hs
#align bdd_above.exists_ge BddAbove.exists_ge
theorem BddBelow.exists_le [SemilatticeInf γ] {s : Set γ} (hs : BddBelow s) (x₀ : γ) :
∃ x, x ≤ x₀ ∧ ∀ y ∈ s, x ≤ y :=
(bddBelow_iff_exists_le x₀).mp hs
#align bdd_below.exists_le BddBelow.exists_le
theorem isLeast_Ici : IsLeast (Ici a) a :=
⟨left_mem_Ici, fun _ => id⟩
#align is_least_Ici isLeast_Ici
theorem isGreatest_Iic : IsGreatest (Iic a) a :=
⟨right_mem_Iic, fun _ => id⟩
#align is_greatest_Iic isGreatest_Iic
theorem isLUB_Iic : IsLUB (Iic a) a :=
isGreatest_Iic.isLUB
#align is_lub_Iic isLUB_Iic
theorem isGLB_Ici : IsGLB (Ici a) a :=
isLeast_Ici.isGLB
#align is_glb_Ici isGLB_Ici
theorem upperBounds_Iic : upperBounds (Iic a) = Ici a :=
isLUB_Iic.upperBounds_eq
#align upper_bounds_Iic upperBounds_Iic
theorem lowerBounds_Ici : lowerBounds (Ici a) = Iic a :=
isGLB_Ici.lowerBounds_eq
#align lower_bounds_Ici lowerBounds_Ici
theorem bddAbove_Iic : BddAbove (Iic a) :=
isLUB_Iic.bddAbove
#align bdd_above_Iic bddAbove_Iic
theorem bddBelow_Ici : BddBelow (Ici a) :=
isGLB_Ici.bddBelow
#align bdd_below_Ici bddBelow_Ici
theorem bddAbove_Iio : BddAbove (Iio a) :=
⟨a, fun _ hx => le_of_lt hx⟩
#align bdd_above_Iio bddAbove_Iio
theorem bddBelow_Ioi : BddBelow (Ioi a) :=
⟨a, fun _ hx => le_of_lt hx⟩
#align bdd_below_Ioi bddBelow_Ioi
theorem lub_Iio_le (a : α) (hb : IsLUB (Iio a) b) : b ≤ a :=
(isLUB_le_iff hb).mpr fun _ hk => le_of_lt hk
#align lub_Iio_le lub_Iio_le
theorem le_glb_Ioi (a : α) (hb : IsGLB (Ioi a) b) : a ≤ b :=
@lub_Iio_le αᵒᵈ _ _ a hb
#align le_glb_Ioi le_glb_Ioi
theorem lub_Iio_eq_self_or_Iio_eq_Iic [PartialOrder γ] {j : γ} (i : γ) (hj : IsLUB (Iio i) j) :
j = i ∨ Iio i = Iic j := by
cases' eq_or_lt_of_le (lub_Iio_le i hj) with hj_eq_i hj_lt_i
· exact Or.inl hj_eq_i
· right
exact Set.ext fun k => ⟨fun hk_lt => hj.1 hk_lt, fun hk_le_j => lt_of_le_of_lt hk_le_j hj_lt_i⟩
#align lub_Iio_eq_self_or_Iio_eq_Iic lub_Iio_eq_self_or_Iio_eq_Iic
theorem glb_Ioi_eq_self_or_Ioi_eq_Ici [PartialOrder γ] {j : γ} (i : γ) (hj : IsGLB (Ioi i) j) :
j = i ∨ Ioi i = Ici j :=
@lub_Iio_eq_self_or_Iio_eq_Iic γᵒᵈ _ j i hj
#align glb_Ioi_eq_self_or_Ioi_eq_Ici glb_Ioi_eq_self_or_Ioi_eq_Ici
section
variable [LinearOrder γ]
theorem exists_lub_Iio (i : γ) : ∃ j, IsLUB (Iio i) j := by
by_cases h_exists_lt : ∃ j, j ∈ upperBounds (Iio i) ∧ j < i
· obtain ⟨j, hj_ub, hj_lt_i⟩ := h_exists_lt
exact ⟨j, hj_ub, fun k hk_ub => hk_ub hj_lt_i⟩
· refine ⟨i, fun j hj => le_of_lt hj, ?_⟩
rw [mem_lowerBounds]
by_contra h
refine h_exists_lt ?_
push_neg at h
exact h
#align exists_lub_Iio exists_lub_Iio
theorem exists_glb_Ioi (i : γ) : ∃ j, IsGLB (Ioi i) j :=
@exists_lub_Iio γᵒᵈ _ i
#align exists_glb_Ioi exists_glb_Ioi
variable [DenselyOrdered γ]
theorem isLUB_Iio {a : γ} : IsLUB (Iio a) a :=
⟨fun _ hx => le_of_lt hx, fun _ hy => le_of_forall_ge_of_dense hy⟩
#align is_lub_Iio isLUB_Iio
theorem isGLB_Ioi {a : γ} : IsGLB (Ioi a) a :=
@isLUB_Iio γᵒᵈ _ _ a
#align is_glb_Ioi isGLB_Ioi
theorem upperBounds_Iio {a : γ} : upperBounds (Iio a) = Ici a :=
isLUB_Iio.upperBounds_eq
#align upper_bounds_Iio upperBounds_Iio
theorem lowerBounds_Ioi {a : γ} : lowerBounds (Ioi a) = Iic a :=
isGLB_Ioi.lowerBounds_eq
#align lower_bounds_Ioi lowerBounds_Ioi
end
theorem isGreatest_singleton : IsGreatest {a} a :=
⟨mem_singleton a, fun _ hx => le_of_eq <| eq_of_mem_singleton hx⟩
#align is_greatest_singleton isGreatest_singleton
theorem isLeast_singleton : IsLeast {a} a :=
@isGreatest_singleton αᵒᵈ _ a
#align is_least_singleton isLeast_singleton
theorem isLUB_singleton : IsLUB {a} a :=
isGreatest_singleton.isLUB
#align is_lub_singleton isLUB_singleton
theorem isGLB_singleton : IsGLB {a} a :=
isLeast_singleton.isGLB
#align is_glb_singleton isGLB_singleton
@[simp] lemma bddAbove_singleton : BddAbove ({a} : Set α) := isLUB_singleton.bddAbove
#align bdd_above_singleton bddAbove_singleton
@[simp] lemma bddBelow_singleton : BddBelow ({a} : Set α) := isGLB_singleton.bddBelow
#align bdd_below_singleton bddBelow_singleton
@[simp]
theorem upperBounds_singleton : upperBounds {a} = Ici a :=
isLUB_singleton.upperBounds_eq
#align upper_bounds_singleton upperBounds_singleton
@[simp]
theorem lowerBounds_singleton : lowerBounds {a} = Iic a :=
isGLB_singleton.lowerBounds_eq
#align lower_bounds_singleton lowerBounds_singleton
theorem bddAbove_Icc : BddAbove (Icc a b) :=
⟨b, fun _ => And.right⟩
#align bdd_above_Icc bddAbove_Icc
theorem bddBelow_Icc : BddBelow (Icc a b) :=
⟨a, fun _ => And.left⟩
#align bdd_below_Icc bddBelow_Icc
theorem bddAbove_Ico : BddAbove (Ico a b) :=
bddAbove_Icc.mono Ico_subset_Icc_self
#align bdd_above_Ico bddAbove_Ico
theorem bddBelow_Ico : BddBelow (Ico a b) :=
bddBelow_Icc.mono Ico_subset_Icc_self
#align bdd_below_Ico bddBelow_Ico
theorem bddAbove_Ioc : BddAbove (Ioc a b) :=
bddAbove_Icc.mono Ioc_subset_Icc_self
#align bdd_above_Ioc bddAbove_Ioc
theorem bddBelow_Ioc : BddBelow (Ioc a b) :=
bddBelow_Icc.mono Ioc_subset_Icc_self
#align bdd_below_Ioc bddBelow_Ioc
theorem bddAbove_Ioo : BddAbove (Ioo a b) :=
bddAbove_Icc.mono Ioo_subset_Icc_self
#align bdd_above_Ioo bddAbove_Ioo
theorem bddBelow_Ioo : BddBelow (Ioo a b) :=
bddBelow_Icc.mono Ioo_subset_Icc_self
#align bdd_below_Ioo bddBelow_Ioo
theorem isGreatest_Icc (h : a ≤ b) : IsGreatest (Icc a b) b :=
⟨right_mem_Icc.2 h, fun _ => And.right⟩
#align is_greatest_Icc isGreatest_Icc
theorem isLUB_Icc (h : a ≤ b) : IsLUB (Icc a b) b :=
(isGreatest_Icc h).isLUB
#align is_lub_Icc isLUB_Icc
theorem upperBounds_Icc (h : a ≤ b) : upperBounds (Icc a b) = Ici b :=
(isLUB_Icc h).upperBounds_eq
#align upper_bounds_Icc upperBounds_Icc
theorem isLeast_Icc (h : a ≤ b) : IsLeast (Icc a b) a :=
⟨left_mem_Icc.2 h, fun _ => And.left⟩
#align is_least_Icc isLeast_Icc
theorem isGLB_Icc (h : a ≤ b) : IsGLB (Icc a b) a :=
(isLeast_Icc h).isGLB
#align is_glb_Icc isGLB_Icc
theorem lowerBounds_Icc (h : a ≤ b) : lowerBounds (Icc a b) = Iic a :=
(isGLB_Icc h).lowerBounds_eq
#align lower_bounds_Icc lowerBounds_Icc
theorem isGreatest_Ioc (h : a < b) : IsGreatest (Ioc a b) b :=
⟨right_mem_Ioc.2 h, fun _ => And.right⟩
#align is_greatest_Ioc isGreatest_Ioc
theorem isLUB_Ioc (h : a < b) : IsLUB (Ioc a b) b :=
(isGreatest_Ioc h).isLUB
#align is_lub_Ioc isLUB_Ioc
theorem upperBounds_Ioc (h : a < b) : upperBounds (Ioc a b) = Ici b :=
(isLUB_Ioc h).upperBounds_eq
#align upper_bounds_Ioc upperBounds_Ioc
theorem isLeast_Ico (h : a < b) : IsLeast (Ico a b) a :=
⟨left_mem_Ico.2 h, fun _ => And.left⟩
#align is_least_Ico isLeast_Ico
theorem isGLB_Ico (h : a < b) : IsGLB (Ico a b) a :=
(isLeast_Ico h).isGLB
#align is_glb_Ico isGLB_Ico
theorem lowerBounds_Ico (h : a < b) : lowerBounds (Ico a b) = Iic a :=
(isGLB_Ico h).lowerBounds_eq
#align lower_bounds_Ico lowerBounds_Ico
section
variable [SemilatticeSup γ] [DenselyOrdered γ]
theorem isGLB_Ioo {a b : γ} (h : a < b) : IsGLB (Ioo a b) a :=
⟨fun x hx => hx.1.le, fun x hx => by
cases' eq_or_lt_of_le (le_sup_right : a ≤ x ⊔ a) with h₁ h₂
· exact h₁.symm ▸ le_sup_left
obtain ⟨y, lty, ylt⟩ := exists_between h₂
apply (not_lt_of_le (sup_le (hx ⟨lty, ylt.trans_le (sup_le _ h.le)⟩) lty.le) ylt).elim
obtain ⟨u, au, ub⟩ := exists_between h
apply (hx ⟨au, ub⟩).trans ub.le⟩
#align is_glb_Ioo isGLB_Ioo
theorem lowerBounds_Ioo {a b : γ} (hab : a < b) : lowerBounds (Ioo a b) = Iic a :=
(isGLB_Ioo hab).lowerBounds_eq
#align lower_bounds_Ioo lowerBounds_Ioo
theorem isGLB_Ioc {a b : γ} (hab : a < b) : IsGLB (Ioc a b) a :=
(isGLB_Ioo hab).of_subset_of_superset (isGLB_Icc hab.le) Ioo_subset_Ioc_self Ioc_subset_Icc_self
#align is_glb_Ioc isGLB_Ioc
theorem lowerBounds_Ioc {a b : γ} (hab : a < b) : lowerBounds (Ioc a b) = Iic a :=
(isGLB_Ioc hab).lowerBounds_eq
#align lower_bound_Ioc lowerBounds_Ioc
end
section
variable [SemilatticeInf γ] [DenselyOrdered γ]
theorem isLUB_Ioo {a b : γ} (hab : a < b) : IsLUB (Ioo a b) b := by
simpa only [dual_Ioo] using isGLB_Ioo hab.dual
#align is_lub_Ioo isLUB_Ioo
theorem upperBounds_Ioo {a b : γ} (hab : a < b) : upperBounds (Ioo a b) = Ici b :=
(isLUB_Ioo hab).upperBounds_eq
#align upper_bounds_Ioo upperBounds_Ioo
theorem isLUB_Ico {a b : γ} (hab : a < b) : IsLUB (Ico a b) b := by
simpa only [dual_Ioc] using isGLB_Ioc hab.dual
#align is_lub_Ico isLUB_Ico
theorem upperBounds_Ico {a b : γ} (hab : a < b) : upperBounds (Ico a b) = Ici b :=
(isLUB_Ico hab).upperBounds_eq
#align upper_bounds_Ico upperBounds_Ico
end
theorem bddBelow_iff_subset_Ici : BddBelow s ↔ ∃ a, s ⊆ Ici a :=
Iff.rfl
#align bdd_below_iff_subset_Ici bddBelow_iff_subset_Ici
theorem bddAbove_iff_subset_Iic : BddAbove s ↔ ∃ a, s ⊆ Iic a :=
Iff.rfl
#align bdd_above_iff_subset_Iic bddAbove_iff_subset_Iic
theorem bddBelow_bddAbove_iff_subset_Icc : BddBelow s ∧ BddAbove s ↔ ∃ a b, s ⊆ Icc a b := by
simp [Ici_inter_Iic.symm, subset_inter_iff, bddBelow_iff_subset_Ici,
bddAbove_iff_subset_Iic, exists_and_left, exists_and_right]
#align bdd_below_bdd_above_iff_subset_Icc bddBelow_bddAbove_iff_subset_Icc
@[simp] theorem isGreatest_univ_iff : IsGreatest univ a ↔ IsTop a := by
simp [IsGreatest, mem_upperBounds, IsTop]
#align is_greatest_univ_iff isGreatest_univ_iff
theorem isGreatest_univ [OrderTop α] : IsGreatest (univ : Set α) ⊤ :=
isGreatest_univ_iff.2 isTop_top
#align is_greatest_univ isGreatest_univ
@[simp]
theorem OrderTop.upperBounds_univ [PartialOrder γ] [OrderTop γ] :
upperBounds (univ : Set γ) = {⊤} := by rw [isGreatest_univ.upperBounds_eq, Ici_top]
#align order_top.upper_bounds_univ OrderTop.upperBounds_univ
theorem isLUB_univ [OrderTop α] : IsLUB (univ : Set α) ⊤ :=
isGreatest_univ.isLUB
#align is_lub_univ isLUB_univ
@[simp]
theorem OrderBot.lowerBounds_univ [PartialOrder γ] [OrderBot γ] :
lowerBounds (univ : Set γ) = {⊥} :=
@OrderTop.upperBounds_univ γᵒᵈ _ _
#align order_bot.lower_bounds_univ OrderBot.lowerBounds_univ
@[simp] theorem isLeast_univ_iff : IsLeast univ a ↔ IsBot a :=
@isGreatest_univ_iff αᵒᵈ _ _
#align is_least_univ_iff isLeast_univ_iff
theorem isLeast_univ [OrderBot α] : IsLeast (univ : Set α) ⊥ :=
@isGreatest_univ αᵒᵈ _ _
#align is_least_univ isLeast_univ
theorem isGLB_univ [OrderBot α] : IsGLB (univ : Set α) ⊥ :=
isLeast_univ.isGLB
#align is_glb_univ isGLB_univ
@[simp]
theorem NoMaxOrder.upperBounds_univ [NoMaxOrder α] : upperBounds (univ : Set α) = ∅ :=
eq_empty_of_subset_empty fun b hb =>
let ⟨_, hx⟩ := exists_gt b
not_le_of_lt hx (hb trivial)
#align no_max_order.upper_bounds_univ NoMaxOrder.upperBounds_univ
@[simp]
theorem NoMinOrder.lowerBounds_univ [NoMinOrder α] : lowerBounds (univ : Set α) = ∅ :=
@NoMaxOrder.upperBounds_univ αᵒᵈ _ _
#align no_min_order.lower_bounds_univ NoMinOrder.lowerBounds_univ
@[simp]
theorem not_bddAbove_univ [NoMaxOrder α] : ¬BddAbove (univ : Set α) := by simp [BddAbove]
#align not_bdd_above_univ not_bddAbove_univ
@[simp]
theorem not_bddBelow_univ [NoMinOrder α] : ¬BddBelow (univ : Set α) :=
@not_bddAbove_univ αᵒᵈ _ _
#align not_bdd_below_univ not_bddBelow_univ
@[simp]
theorem upperBounds_empty : upperBounds (∅ : Set α) = univ := by
simp only [upperBounds, eq_univ_iff_forall, mem_setOf_eq, forall_mem_empty, forall_true_iff]
#align upper_bounds_empty upperBounds_empty
@[simp]
theorem lowerBounds_empty : lowerBounds (∅ : Set α) = univ :=
@upperBounds_empty αᵒᵈ _
#align lower_bounds_empty lowerBounds_empty
@[simp]
theorem bddAbove_empty [Nonempty α] : BddAbove (∅ : Set α) := by
simp only [BddAbove, upperBounds_empty, univ_nonempty]
#align bdd_above_empty bddAbove_empty
@[simp]
theorem bddBelow_empty [Nonempty α] : BddBelow (∅ : Set α) := by
simp only [BddBelow, lowerBounds_empty, univ_nonempty]
#align bdd_below_empty bddBelow_empty
@[simp] theorem isGLB_empty_iff : IsGLB ∅ a ↔ IsTop a := by
simp [IsGLB]
#align is_glb_empty_iff isGLB_empty_iff
@[simp] theorem isLUB_empty_iff : IsLUB ∅ a ↔ IsBot a :=
@isGLB_empty_iff αᵒᵈ _ _
#align is_lub_empty_iff isLUB_empty_iff
theorem isGLB_empty [OrderTop α] : IsGLB ∅ (⊤ : α) :=
isGLB_empty_iff.2 isTop_top
#align is_glb_empty isGLB_empty
theorem isLUB_empty [OrderBot α] : IsLUB ∅ (⊥ : α) :=
@isGLB_empty αᵒᵈ _ _
#align is_lub_empty isLUB_empty
theorem IsLUB.nonempty [NoMinOrder α] (hs : IsLUB s a) : s.Nonempty :=
let ⟨a', ha'⟩ := exists_lt a
nonempty_iff_ne_empty.2 fun h =>
not_le_of_lt ha' <| hs.right <| by rw [h, upperBounds_empty]; exact mem_univ _
#align is_lub.nonempty IsLUB.nonempty
theorem IsGLB.nonempty [NoMaxOrder α] (hs : IsGLB s a) : s.Nonempty :=
hs.dual.nonempty
#align is_glb.nonempty IsGLB.nonempty
theorem nonempty_of_not_bddAbove [ha : Nonempty α] (h : ¬BddAbove s) : s.Nonempty :=
(Nonempty.elim ha) fun x => (not_bddAbove_iff'.1 h x).imp fun _ ha => ha.1
#align nonempty_of_not_bdd_above nonempty_of_not_bddAbove
theorem nonempty_of_not_bddBelow [Nonempty α] (h : ¬BddBelow s) : s.Nonempty :=
@nonempty_of_not_bddAbove αᵒᵈ _ _ _ h
#align nonempty_of_not_bdd_below nonempty_of_not_bddBelow
@[simp]
| Mathlib/Order/Bounds/Basic.lean | 935 | 937 | theorem bddAbove_insert [IsDirected α (· ≤ ·)] {s : Set α} {a : α} :
BddAbove (insert a s) ↔ BddAbove s := by |
simp only [insert_eq, bddAbove_union, bddAbove_singleton, true_and_iff]
|
import Mathlib.Algebra.Order.Group.Nat
import Mathlib.Data.Finset.Antidiagonal
import Mathlib.Data.Finset.Card
import Mathlib.Data.Multiset.NatAntidiagonal
#align_import data.finset.nat_antidiagonal from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
open Function
namespace Finset
namespace Nat
instance instHasAntidiagonal : HasAntidiagonal ℕ where
antidiagonal n := ⟨Multiset.Nat.antidiagonal n, Multiset.Nat.nodup_antidiagonal n⟩
mem_antidiagonal {n} {xy} := by
rw [mem_def, Multiset.Nat.mem_antidiagonal]
lemma antidiagonal_eq_map (n : ℕ) :
antidiagonal n = (range (n + 1)).map ⟨fun i ↦ (i, n - i), fun _ _ h ↦ (Prod.ext_iff.1 h).1⟩ :=
rfl
lemma antidiagonal_eq_map' (n : ℕ) :
antidiagonal n =
(range (n + 1)).map ⟨fun i ↦ (n - i, i), fun _ _ h ↦ (Prod.ext_iff.1 h).2⟩ := by
rw [← map_swap_antidiagonal, antidiagonal_eq_map, map_map]; rfl
lemma antidiagonal_eq_image (n : ℕ) :
antidiagonal n = (range (n + 1)).image fun i ↦ (i, n - i) := by
simp only [antidiagonal_eq_map, map_eq_image, Function.Embedding.coeFn_mk]
lemma antidiagonal_eq_image' (n : ℕ) :
antidiagonal n = (range (n + 1)).image fun i ↦ (n - i, i) := by
simp only [antidiagonal_eq_map', map_eq_image, Function.Embedding.coeFn_mk]
@[simp]
theorem card_antidiagonal (n : ℕ) : (antidiagonal n).card = n + 1 := by simp [antidiagonal]
#align finset.nat.card_antidiagonal Finset.Nat.card_antidiagonal
-- nolint as this is for dsimp
@[simp, nolint simpNF]
theorem antidiagonal_zero : antidiagonal 0 = {(0, 0)} := rfl
#align finset.nat.antidiagonal_zero Finset.Nat.antidiagonal_zero
theorem antidiagonal_succ (n : ℕ) :
antidiagonal (n + 1) =
cons (0, n + 1)
((antidiagonal n).map
(Embedding.prodMap ⟨Nat.succ, Nat.succ_injective⟩ (Embedding.refl _)))
(by simp) := by
apply eq_of_veq
rw [cons_val, map_val]
apply Multiset.Nat.antidiagonal_succ
#align finset.nat.antidiagonal_succ Finset.Nat.antidiagonal_succ
theorem antidiagonal_succ' (n : ℕ) :
antidiagonal (n + 1) =
cons (n + 1, 0)
((antidiagonal n).map
(Embedding.prodMap (Embedding.refl _) ⟨Nat.succ, Nat.succ_injective⟩))
(by simp) := by
apply eq_of_veq
rw [cons_val, map_val]
exact Multiset.Nat.antidiagonal_succ'
#align finset.nat.antidiagonal_succ' Finset.Nat.antidiagonal_succ'
| Mathlib/Data/Finset/NatAntidiagonal.lean | 89 | 99 | theorem antidiagonal_succ_succ' {n : ℕ} :
antidiagonal (n + 2) =
cons (0, n + 2)
(cons (n + 2, 0)
((antidiagonal n).map
(Embedding.prodMap ⟨Nat.succ, Nat.succ_injective⟩
⟨Nat.succ, Nat.succ_injective⟩)) <|
by simp)
(by simp) := by |
simp_rw [antidiagonal_succ (n + 1), antidiagonal_succ', Finset.map_cons, map_map]
rfl
|
import Mathlib.Algebra.Homology.Additive
import Mathlib.AlgebraicTopology.MooreComplex
import Mathlib.Algebra.BigOperators.Fin
import Mathlib.CategoryTheory.Preadditive.Opposite
import Mathlib.CategoryTheory.Idempotents.FunctorCategories
#align_import algebraic_topology.alternating_face_map_complex from "leanprover-community/mathlib"@"88bca0ce5d22ebfd9e73e682e51d60ea13b48347"
open CategoryTheory CategoryTheory.Limits CategoryTheory.Subobject
open CategoryTheory.Preadditive CategoryTheory.Category CategoryTheory.Idempotents
open Opposite
open Simplicial
noncomputable section
namespace AlgebraicTopology
namespace AlternatingFaceMapComplex
variable {C : Type*} [Category C] [Preadditive C]
variable (X : SimplicialObject C)
variable (Y : SimplicialObject C)
@[simp]
def objD (n : ℕ) : X _[n + 1] ⟶ X _[n] :=
∑ i : Fin (n + 2), (-1 : ℤ) ^ (i : ℕ) • X.δ i
#align algebraic_topology.alternating_face_map_complex.obj_d AlgebraicTopology.AlternatingFaceMapComplex.objD
| Mathlib/AlgebraicTopology/AlternatingFaceMapComplex.lean | 70 | 112 | theorem d_squared (n : ℕ) : objD X (n + 1) ≫ objD X n = 0 := by |
-- we start by expanding d ≫ d as a double sum
dsimp
simp only [comp_sum, sum_comp, ← Finset.sum_product']
-- then, we decompose the index set P into a subset S and its complement Sᶜ
let P := Fin (n + 2) × Fin (n + 3)
let S := Finset.univ.filter fun ij : P => (ij.2 : ℕ) ≤ (ij.1 : ℕ)
erw [← Finset.sum_add_sum_compl S, ← eq_neg_iff_add_eq_zero, ← Finset.sum_neg_distrib]
/- we are reduced to showing that two sums are equal, and this is obtained
by constructing a bijection φ : S -> Sᶜ, which maps (i,j) to (j,i+1),
and by comparing the terms -/
let φ : ∀ ij : P, ij ∈ S → P := fun ij hij =>
(Fin.castLT ij.2 (lt_of_le_of_lt (Finset.mem_filter.mp hij).right (Fin.is_lt ij.1)), ij.1.succ)
apply Finset.sum_bij φ
· -- φ(S) is contained in Sᶜ
intro ij hij
simp only [S, Finset.mem_univ, Finset.compl_filter, Finset.mem_filter, true_and_iff,
Fin.val_succ, Fin.coe_castLT] at hij ⊢
linarith
· -- φ : S → Sᶜ is injective
rintro ⟨i, j⟩ hij ⟨i', j'⟩ hij' h
rw [Prod.mk.inj_iff]
exact ⟨by simpa using congr_arg Prod.snd h,
by simpa [Fin.castSucc_castLT] using congr_arg Fin.castSucc (congr_arg Prod.fst h)⟩
· -- φ : S → Sᶜ is surjective
rintro ⟨i', j'⟩ hij'
simp only [S, Finset.mem_univ, forall_true_left, Prod.forall, ge_iff_le, Finset.compl_filter,
not_le, Finset.mem_filter, true_and] at hij'
refine ⟨(j'.pred <| ?_, Fin.castSucc i'), ?_, ?_⟩
· rintro rfl
simp only [Fin.val_zero, not_lt_zero'] at hij'
· simpa only [S, Finset.mem_univ, forall_true_left, Prod.forall, ge_iff_le, Finset.mem_filter,
Fin.coe_castSucc, Fin.coe_pred, true_and] using Nat.le_sub_one_of_lt hij'
· simp only [φ, Fin.castLT_castSucc, Fin.succ_pred]
· -- identification of corresponding terms in both sums
rintro ⟨i, j⟩ hij
dsimp
simp only [zsmul_comp, comp_zsmul, smul_smul, ← neg_smul]
congr 1
· simp only [Fin.val_succ, pow_add, pow_one, mul_neg, neg_neg, mul_one]
apply mul_comm
· rw [CategoryTheory.SimplicialObject.δ_comp_δ'']
simpa [S] using hij
|
import Batteries.Control.ForInStep.Lemmas
import Batteries.Data.List.Basic
import Batteries.Tactic.Init
import Batteries.Tactic.Alias
namespace List
open Nat
@[simp] theorem mem_toArray {a : α} {l : List α} : a ∈ l.toArray ↔ a ∈ l := by
simp [Array.mem_def]
@[simp]
theorem drop_one : ∀ l : List α, drop 1 l = tail l
| [] | _ :: _ => rfl
theorem zipWith_distrib_tail : (zipWith f l l').tail = zipWith f l.tail l'.tail := by
rw [← drop_one]; simp [zipWith_distrib_drop]
theorem subset_def {l₁ l₂ : List α} : l₁ ⊆ l₂ ↔ ∀ {a : α}, a ∈ l₁ → a ∈ l₂ := .rfl
@[simp] theorem nil_subset (l : List α) : [] ⊆ l := nofun
@[simp] theorem Subset.refl (l : List α) : l ⊆ l := fun _ i => i
theorem Subset.trans {l₁ l₂ l₃ : List α} (h₁ : l₁ ⊆ l₂) (h₂ : l₂ ⊆ l₃) : l₁ ⊆ l₃ :=
fun _ i => h₂ (h₁ i)
instance : Trans (Membership.mem : α → List α → Prop) Subset Membership.mem :=
⟨fun h₁ h₂ => h₂ h₁⟩
instance : Trans (Subset : List α → List α → Prop) Subset Subset :=
⟨Subset.trans⟩
@[simp] theorem subset_cons (a : α) (l : List α) : l ⊆ a :: l := fun _ => Mem.tail _
theorem subset_of_cons_subset {a : α} {l₁ l₂ : List α} : a :: l₁ ⊆ l₂ → l₁ ⊆ l₂ :=
fun s _ i => s (mem_cons_of_mem _ i)
theorem subset_cons_of_subset (a : α) {l₁ l₂ : List α} : l₁ ⊆ l₂ → l₁ ⊆ a :: l₂ :=
fun s _ i => .tail _ (s i)
theorem cons_subset_cons {l₁ l₂ : List α} (a : α) (s : l₁ ⊆ l₂) : a :: l₁ ⊆ a :: l₂ :=
fun _ => by simp only [mem_cons]; exact Or.imp_right (@s _)
@[simp] theorem subset_append_left (l₁ l₂ : List α) : l₁ ⊆ l₁ ++ l₂ := fun _ => mem_append_left _
@[simp] theorem subset_append_right (l₁ l₂ : List α) : l₂ ⊆ l₁ ++ l₂ := fun _ => mem_append_right _
theorem subset_append_of_subset_left (l₂ : List α) : l ⊆ l₁ → l ⊆ l₁ ++ l₂ :=
fun s => Subset.trans s <| subset_append_left _ _
theorem subset_append_of_subset_right (l₁ : List α) : l ⊆ l₂ → l ⊆ l₁ ++ l₂ :=
fun s => Subset.trans s <| subset_append_right _ _
@[simp] theorem cons_subset : a :: l ⊆ m ↔ a ∈ m ∧ l ⊆ m := by
simp only [subset_def, mem_cons, or_imp, forall_and, forall_eq]
@[simp] theorem append_subset {l₁ l₂ l : List α} :
l₁ ++ l₂ ⊆ l ↔ l₁ ⊆ l ∧ l₂ ⊆ l := by simp [subset_def, or_imp, forall_and]
theorem subset_nil {l : List α} : l ⊆ [] ↔ l = [] :=
⟨fun h => match l with | [] => rfl | _::_ => (nomatch h (.head ..)), fun | rfl => Subset.refl _⟩
theorem map_subset {l₁ l₂ : List α} (f : α → β) (H : l₁ ⊆ l₂) : map f l₁ ⊆ map f l₂ :=
fun x => by simp only [mem_map]; exact .imp fun a => .imp_left (@H _)
@[simp] theorem nil_sublist : ∀ l : List α, [] <+ l
| [] => .slnil
| a :: l => (nil_sublist l).cons a
@[simp] theorem Sublist.refl : ∀ l : List α, l <+ l
| [] => .slnil
| a :: l => (Sublist.refl l).cons₂ a
theorem Sublist.trans {l₁ l₂ l₃ : List α} (h₁ : l₁ <+ l₂) (h₂ : l₂ <+ l₃) : l₁ <+ l₃ := by
induction h₂ generalizing l₁ with
| slnil => exact h₁
| cons _ _ IH => exact (IH h₁).cons _
| @cons₂ l₂ _ a _ IH =>
generalize e : a :: l₂ = l₂'
match e ▸ h₁ with
| .slnil => apply nil_sublist
| .cons a' h₁' => cases e; apply (IH h₁').cons
| .cons₂ a' h₁' => cases e; apply (IH h₁').cons₂
instance : Trans (@Sublist α) Sublist Sublist := ⟨Sublist.trans⟩
@[simp] theorem sublist_cons (a : α) (l : List α) : l <+ a :: l := (Sublist.refl l).cons _
theorem sublist_of_cons_sublist : a :: l₁ <+ l₂ → l₁ <+ l₂ :=
(sublist_cons a l₁).trans
@[simp] theorem sublist_append_left : ∀ l₁ l₂ : List α, l₁ <+ l₁ ++ l₂
| [], _ => nil_sublist _
| _ :: l₁, l₂ => (sublist_append_left l₁ l₂).cons₂ _
@[simp] theorem sublist_append_right : ∀ l₁ l₂ : List α, l₂ <+ l₁ ++ l₂
| [], _ => Sublist.refl _
| _ :: l₁, l₂ => (sublist_append_right l₁ l₂).cons _
theorem sublist_append_of_sublist_left (s : l <+ l₁) : l <+ l₁ ++ l₂ :=
s.trans <| sublist_append_left ..
theorem sublist_append_of_sublist_right (s : l <+ l₂) : l <+ l₁ ++ l₂ :=
s.trans <| sublist_append_right ..
@[simp]
theorem cons_sublist_cons : a :: l₁ <+ a :: l₂ ↔ l₁ <+ l₂ :=
⟨fun | .cons _ s => sublist_of_cons_sublist s | .cons₂ _ s => s, .cons₂ _⟩
@[simp] theorem append_sublist_append_left : ∀ l, l ++ l₁ <+ l ++ l₂ ↔ l₁ <+ l₂
| [] => Iff.rfl
| _ :: l => cons_sublist_cons.trans (append_sublist_append_left l)
theorem Sublist.append_left : l₁ <+ l₂ → ∀ l, l ++ l₁ <+ l ++ l₂ :=
fun h l => (append_sublist_append_left l).mpr h
theorem Sublist.append_right : l₁ <+ l₂ → ∀ l, l₁ ++ l <+ l₂ ++ l
| .slnil, _ => Sublist.refl _
| .cons _ h, _ => (h.append_right _).cons _
| .cons₂ _ h, _ => (h.append_right _).cons₂ _
theorem sublist_or_mem_of_sublist (h : l <+ l₁ ++ a :: l₂) : l <+ l₁ ++ l₂ ∨ a ∈ l := by
induction l₁ generalizing l with
| nil => match h with
| .cons _ h => exact .inl h
| .cons₂ _ h => exact .inr (.head ..)
| cons b l₁ IH =>
match h with
| .cons _ h => exact (IH h).imp_left (Sublist.cons _)
| .cons₂ _ h => exact (IH h).imp (Sublist.cons₂ _) (.tail _)
theorem Sublist.reverse : l₁ <+ l₂ → l₁.reverse <+ l₂.reverse
| .slnil => Sublist.refl _
| .cons _ h => by rw [reverse_cons]; exact sublist_append_of_sublist_left h.reverse
| .cons₂ _ h => by rw [reverse_cons, reverse_cons]; exact h.reverse.append_right _
@[simp] theorem reverse_sublist : l₁.reverse <+ l₂.reverse ↔ l₁ <+ l₂ :=
⟨fun h => l₁.reverse_reverse ▸ l₂.reverse_reverse ▸ h.reverse, Sublist.reverse⟩
@[simp] theorem append_sublist_append_right (l) : l₁ ++ l <+ l₂ ++ l ↔ l₁ <+ l₂ :=
⟨fun h => by
have := h.reverse
simp only [reverse_append, append_sublist_append_left, reverse_sublist] at this
exact this,
fun h => h.append_right l⟩
theorem Sublist.append (hl : l₁ <+ l₂) (hr : r₁ <+ r₂) : l₁ ++ r₁ <+ l₂ ++ r₂ :=
(hl.append_right _).trans ((append_sublist_append_left _).2 hr)
theorem Sublist.subset : l₁ <+ l₂ → l₁ ⊆ l₂
| .slnil, _, h => h
| .cons _ s, _, h => .tail _ (s.subset h)
| .cons₂ .., _, .head .. => .head ..
| .cons₂ _ s, _, .tail _ h => .tail _ (s.subset h)
instance : Trans (@Sublist α) Subset Subset :=
⟨fun h₁ h₂ => trans h₁.subset h₂⟩
instance : Trans Subset (@Sublist α) Subset :=
⟨fun h₁ h₂ => trans h₁ h₂.subset⟩
instance : Trans (Membership.mem : α → List α → Prop) Sublist Membership.mem :=
⟨fun h₁ h₂ => h₂.subset h₁⟩
theorem Sublist.length_le : l₁ <+ l₂ → length l₁ ≤ length l₂
| .slnil => Nat.le_refl 0
| .cons _l s => le_succ_of_le (length_le s)
| .cons₂ _ s => succ_le_succ (length_le s)
@[simp] theorem sublist_nil {l : List α} : l <+ [] ↔ l = [] :=
⟨fun s => subset_nil.1 s.subset, fun H => H ▸ Sublist.refl _⟩
theorem Sublist.eq_of_length : l₁ <+ l₂ → length l₁ = length l₂ → l₁ = l₂
| .slnil, _ => rfl
| .cons a s, h => nomatch Nat.not_lt.2 s.length_le (h ▸ lt_succ_self _)
| .cons₂ a s, h => by rw [s.eq_of_length (succ.inj h)]
theorem Sublist.eq_of_length_le (s : l₁ <+ l₂) (h : length l₂ ≤ length l₁) : l₁ = l₂ :=
s.eq_of_length <| Nat.le_antisymm s.length_le h
@[simp] theorem singleton_sublist {a : α} {l} : [a] <+ l ↔ a ∈ l := by
refine ⟨fun h => h.subset (mem_singleton_self _), fun h => ?_⟩
obtain ⟨_, _, rfl⟩ := append_of_mem h
exact ((nil_sublist _).cons₂ _).trans (sublist_append_right ..)
@[simp] theorem replicate_sublist_replicate {m n} (a : α) :
replicate m a <+ replicate n a ↔ m ≤ n := by
refine ⟨fun h => ?_, fun h => ?_⟩
· have := h.length_le; simp only [length_replicate] at this ⊢; exact this
· induction h with
| refl => apply Sublist.refl
| step => simp [*, replicate, Sublist.cons]
theorem isSublist_iff_sublist [BEq α] [LawfulBEq α] {l₁ l₂ : List α} :
l₁.isSublist l₂ ↔ l₁ <+ l₂ := by
cases l₁ <;> cases l₂ <;> simp [isSublist]
case cons.cons hd₁ tl₁ hd₂ tl₂ =>
if h_eq : hd₁ = hd₂ then
simp [h_eq, cons_sublist_cons, isSublist_iff_sublist]
else
simp only [beq_iff_eq, h_eq]
constructor
· intro h_sub
apply Sublist.cons
exact isSublist_iff_sublist.mp h_sub
· intro h_sub
cases h_sub
case cons h_sub =>
exact isSublist_iff_sublist.mpr h_sub
case cons₂ =>
contradiction
instance [DecidableEq α] (l₁ l₂ : List α) : Decidable (l₁ <+ l₂) :=
decidable_of_iff (l₁.isSublist l₂) isSublist_iff_sublist
theorem tail_eq_tailD (l) : @tail α l = tailD l [] := by cases l <;> rfl
theorem tail_eq_tail? (l) : @tail α l = (tail? l).getD [] := by simp [tail_eq_tailD]
@[simp] theorem next?_nil : @next? α [] = none := rfl
@[simp] theorem next?_cons (a l) : @next? α (a :: l) = some (a, l) := rfl
theorem get_eq_iff : List.get l n = x ↔ l.get? n.1 = some x := by simp [get?_eq_some]
theorem get?_inj
(h₀ : i < xs.length) (h₁ : Nodup xs) (h₂ : xs.get? i = xs.get? j) : i = j := by
induction xs generalizing i j with
| nil => cases h₀
| cons x xs ih =>
match i, j with
| 0, 0 => rfl
| i+1, j+1 => simp; cases h₁ with
| cons ha h₁ => exact ih (Nat.lt_of_succ_lt_succ h₀) h₁ h₂
| i+1, 0 => ?_ | 0, j+1 => ?_
all_goals
simp at h₂
cases h₁; rename_i h' h
have := h x ?_ rfl; cases this
rw [mem_iff_get?]
exact ⟨_, h₂⟩; exact ⟨_ , h₂.symm⟩
theorem tail_drop (l : List α) (n : Nat) : (l.drop n).tail = l.drop (n + 1) := by
induction l generalizing n with
| nil => simp
| cons hd tl hl =>
cases n
· simp
· simp [hl]
@[simp] theorem modifyNth_nil (f : α → α) (n) : [].modifyNth f n = [] := by cases n <;> rfl
@[simp] theorem modifyNth_zero_cons (f : α → α) (a : α) (l : List α) :
(a :: l).modifyNth f 0 = f a :: l := rfl
@[simp] theorem modifyNth_succ_cons (f : α → α) (a : α) (l : List α) (n) :
(a :: l).modifyNth f (n + 1) = a :: l.modifyNth f n := by rfl
theorem modifyNthTail_id : ∀ n (l : List α), l.modifyNthTail id n = l
| 0, _ => rfl
| _+1, [] => rfl
| n+1, a :: l => congrArg (cons a) (modifyNthTail_id n l)
theorem eraseIdx_eq_modifyNthTail : ∀ n (l : List α), eraseIdx l n = modifyNthTail tail n l
| 0, l => by cases l <;> rfl
| n+1, [] => rfl
| n+1, a :: l => congrArg (cons _) (eraseIdx_eq_modifyNthTail _ _)
@[deprecated] alias removeNth_eq_nth_tail := eraseIdx_eq_modifyNthTail
theorem get?_modifyNth (f : α → α) :
∀ n (l : List α) m, (modifyNth f n l).get? m = (fun a => if n = m then f a else a) <$> l.get? m
| n, l, 0 => by cases l <;> cases n <;> rfl
| n, [], _+1 => by cases n <;> rfl
| 0, _ :: l, m+1 => by cases h : l.get? m <;> simp [h, modifyNth, m.succ_ne_zero.symm]
| n+1, a :: l, m+1 =>
(get?_modifyNth f n l m).trans <| by
cases h' : l.get? m <;> by_cases h : n = m <;>
simp [h, if_pos, if_neg, Option.map, mt Nat.succ.inj, not_false_iff, h']
theorem modifyNthTail_length (f : List α → List α) (H : ∀ l, length (f l) = length l) :
∀ n l, length (modifyNthTail f n l) = length l
| 0, _ => H _
| _+1, [] => rfl
| _+1, _ :: _ => congrArg (·+1) (modifyNthTail_length _ H _ _)
theorem modifyNthTail_add (f : List α → List α) (n) (l₁ l₂ : List α) :
modifyNthTail f (l₁.length + n) (l₁ ++ l₂) = l₁ ++ modifyNthTail f n l₂ := by
induction l₁ <;> simp [*, Nat.succ_add]
theorem exists_of_modifyNthTail (f : List α → List α) {n} {l : List α} (h : n ≤ l.length) :
∃ l₁ l₂, l = l₁ ++ l₂ ∧ l₁.length = n ∧ modifyNthTail f n l = l₁ ++ f l₂ :=
have ⟨_, _, eq, hl⟩ : ∃ l₁ l₂, l = l₁ ++ l₂ ∧ l₁.length = n :=
⟨_, _, (take_append_drop n l).symm, length_take_of_le h⟩
⟨_, _, eq, hl, hl ▸ eq ▸ modifyNthTail_add (n := 0) ..⟩
@[simp] theorem modify_get?_length (f : α → α) : ∀ n l, length (modifyNth f n l) = length l :=
modifyNthTail_length _ fun l => by cases l <;> rfl
@[simp] theorem get?_modifyNth_eq (f : α → α) (n) (l : List α) :
(modifyNth f n l).get? n = f <$> l.get? n := by
simp only [get?_modifyNth, if_pos]
@[simp] theorem get?_modifyNth_ne (f : α → α) {m n} (l : List α) (h : m ≠ n) :
(modifyNth f m l).get? n = l.get? n := by
simp only [get?_modifyNth, if_neg h, id_map']
theorem exists_of_modifyNth (f : α → α) {n} {l : List α} (h : n < l.length) :
∃ l₁ a l₂, l = l₁ ++ a :: l₂ ∧ l₁.length = n ∧ modifyNth f n l = l₁ ++ f a :: l₂ :=
match exists_of_modifyNthTail _ (Nat.le_of_lt h) with
| ⟨_, _::_, eq, hl, H⟩ => ⟨_, _, _, eq, hl, H⟩
| ⟨_, [], eq, hl, _⟩ => nomatch Nat.ne_of_gt h (eq ▸ append_nil _ ▸ hl)
theorem modifyNthTail_eq_take_drop (f : List α → List α) (H : f [] = []) :
∀ n l, modifyNthTail f n l = take n l ++ f (drop n l)
| 0, _ => rfl
| _ + 1, [] => H.symm
| n + 1, b :: l => congrArg (cons b) (modifyNthTail_eq_take_drop f H n l)
theorem modifyNth_eq_take_drop (f : α → α) :
∀ n l, modifyNth f n l = take n l ++ modifyHead f (drop n l) :=
modifyNthTail_eq_take_drop _ rfl
theorem modifyNth_eq_take_cons_drop (f : α → α) {n l} (h) :
modifyNth f n l = take n l ++ f (get l ⟨n, h⟩) :: drop (n + 1) l := by
rw [modifyNth_eq_take_drop, drop_eq_get_cons h]; rfl
theorem set_eq_modifyNth (a : α) : ∀ n (l : List α), set l n a = modifyNth (fun _ => a) n l
| 0, l => by cases l <;> rfl
| n+1, [] => rfl
| n+1, b :: l => congrArg (cons _) (set_eq_modifyNth _ _ _)
theorem set_eq_take_cons_drop (a : α) {n l} (h : n < length l) :
set l n a = take n l ++ a :: drop (n + 1) l := by
rw [set_eq_modifyNth, modifyNth_eq_take_cons_drop _ h]
theorem modifyNth_eq_set_get? (f : α → α) :
∀ n (l : List α), l.modifyNth f n = ((fun a => l.set n (f a)) <$> l.get? n).getD l
| 0, l => by cases l <;> rfl
| n+1, [] => rfl
| n+1, b :: l =>
(congrArg (cons _) (modifyNth_eq_set_get? ..)).trans <| by cases h : l.get? n <;> simp [h]
theorem modifyNth_eq_set_get (f : α → α) {n} {l : List α} (h) :
l.modifyNth f n = l.set n (f (l.get ⟨n, h⟩)) := by
rw [modifyNth_eq_set_get?, get?_eq_get h]; rfl
theorem exists_of_set {l : List α} (h : n < l.length) :
∃ l₁ a l₂, l = l₁ ++ a :: l₂ ∧ l₁.length = n ∧ l.set n a' = l₁ ++ a' :: l₂ := by
rw [set_eq_modifyNth]; exact exists_of_modifyNth _ h
theorem exists_of_set' {l : List α} (h : n < l.length) :
∃ l₁ l₂, l = l₁ ++ l.get ⟨n, h⟩ :: l₂ ∧ l₁.length = n ∧ l.set n a' = l₁ ++ a' :: l₂ :=
have ⟨_, _, _, h₁, h₂, h₃⟩ := exists_of_set h; ⟨_, _, get_of_append h₁ h₂ ▸ h₁, h₂, h₃⟩
@[simp]
theorem get?_set_eq (a : α) (n) (l : List α) : (set l n a).get? n = (fun _ => a) <$> l.get? n := by
simp only [set_eq_modifyNth, get?_modifyNth_eq]
theorem get?_set_eq_of_lt (a : α) {n} {l : List α} (h : n < length l) :
(set l n a).get? n = some a := by rw [get?_set_eq, get?_eq_get h]; rfl
@[simp]
theorem get?_set_ne (a : α) {m n} (l : List α) (h : m ≠ n) : (set l m a).get? n = l.get? n := by
simp only [set_eq_modifyNth, get?_modifyNth_ne _ _ h]
theorem get?_set (a : α) {m n} (l : List α) :
(set l m a).get? n = if m = n then (fun _ => a) <$> l.get? n else l.get? n := by
by_cases m = n <;> simp [*, get?_set_eq, get?_set_ne]
theorem get?_set_of_lt (a : α) {m n} (l : List α) (h : n < length l) :
(set l m a).get? n = if m = n then some a else l.get? n := by
simp [get?_set, get?_eq_get h]
theorem get?_set_of_lt' (a : α) {m n} (l : List α) (h : m < length l) :
(set l m a).get? n = if m = n then some a else l.get? n := by
simp [get?_set]; split <;> subst_vars <;> simp [*, get?_eq_get h]
theorem drop_set_of_lt (a : α) {n m : Nat} (l : List α) (h : n < m) :
(l.set n a).drop m = l.drop m :=
List.ext fun i => by rw [get?_drop, get?_drop, get?_set_ne _ _ (by omega)]
theorem take_set_of_lt (a : α) {n m : Nat} (l : List α) (h : m < n) :
(l.set n a).take m = l.take m :=
List.ext fun i => by
rw [get?_take_eq_if, get?_take_eq_if]
split
· next h' => rw [get?_set_ne _ _ (by omega)]
· rfl
theorem length_eraseIdx : ∀ {l i}, i < length l → length (@eraseIdx α l i) = length l - 1
| [], _, _ => rfl
| _::_, 0, _ => by simp [eraseIdx]
| x::xs, i+1, h => by
have : i < length xs := Nat.lt_of_succ_lt_succ h
simp [eraseIdx, ← Nat.add_one]
rw [length_eraseIdx this, Nat.sub_add_cancel (Nat.lt_of_le_of_lt (Nat.zero_le _) this)]
@[deprecated] alias length_removeNth := length_eraseIdx
@[simp] theorem length_tail (l : List α) : length (tail l) = length l - 1 := by cases l <;> rfl
@[simp] theorem eraseP_nil : [].eraseP p = [] := rfl
theorem eraseP_cons (a : α) (l : List α) :
(a :: l).eraseP p = bif p a then l else a :: l.eraseP p := rfl
@[simp] theorem eraseP_cons_of_pos {l : List α} (p) (h : p a) : (a :: l).eraseP p = l := by
simp [eraseP_cons, h]
@[simp] theorem eraseP_cons_of_neg {l : List α} (p) (h : ¬p a) :
(a :: l).eraseP p = a :: l.eraseP p := by simp [eraseP_cons, h]
theorem eraseP_of_forall_not {l : List α} (h : ∀ a, a ∈ l → ¬p a) : l.eraseP p = l := by
induction l with
| nil => rfl
| cons _ _ ih => simp [h _ (.head ..), ih (forall_mem_cons.1 h).2]
theorem exists_of_eraseP : ∀ {l : List α} {a} (al : a ∈ l) (pa : p a),
∃ a l₁ l₂, (∀ b ∈ l₁, ¬p b) ∧ p a ∧ l = l₁ ++ a :: l₂ ∧ l.eraseP p = l₁ ++ l₂
| b :: l, a, al, pa =>
if pb : p b then
⟨b, [], l, forall_mem_nil _, pb, by simp [pb]⟩
else
match al with
| .head .. => nomatch pb pa
| .tail _ al =>
let ⟨c, l₁, l₂, h₁, h₂, h₃, h₄⟩ := exists_of_eraseP al pa
⟨c, b::l₁, l₂, (forall_mem_cons ..).2 ⟨pb, h₁⟩,
h₂, by rw [h₃, cons_append], by simp [pb, h₄]⟩
theorem exists_or_eq_self_of_eraseP (p) (l : List α) :
l.eraseP p = l ∨
∃ a l₁ l₂, (∀ b ∈ l₁, ¬p b) ∧ p a ∧ l = l₁ ++ a :: l₂ ∧ l.eraseP p = l₁ ++ l₂ :=
if h : ∃ a ∈ l, p a then
let ⟨_, ha, pa⟩ := h
.inr (exists_of_eraseP ha pa)
else
.inl (eraseP_of_forall_not (h ⟨·, ·, ·⟩))
@[simp] theorem length_eraseP_of_mem (al : a ∈ l) (pa : p a) :
length (l.eraseP p) = Nat.pred (length l) := by
let ⟨_, l₁, l₂, _, _, e₁, e₂⟩ := exists_of_eraseP al pa
rw [e₂]; simp [length_append, e₁]; rfl
theorem eraseP_append_left {a : α} (pa : p a) :
∀ {l₁ : List α} l₂, a ∈ l₁ → (l₁++l₂).eraseP p = l₁.eraseP p ++ l₂
| x :: xs, l₂, h => by
by_cases h' : p x <;> simp [h']
rw [eraseP_append_left pa l₂ ((mem_cons.1 h).resolve_left (mt _ h'))]
intro | rfl => exact pa
theorem eraseP_append_right :
∀ {l₁ : List α} l₂, (∀ b ∈ l₁, ¬p b) → eraseP p (l₁++l₂) = l₁ ++ l₂.eraseP p
| [], l₂, _ => rfl
| x :: xs, l₂, h => by
simp [(forall_mem_cons.1 h).1, eraseP_append_right _ (forall_mem_cons.1 h).2]
theorem eraseP_sublist (l : List α) : l.eraseP p <+ l := by
match exists_or_eq_self_of_eraseP p l with
| .inl h => rw [h]; apply Sublist.refl
| .inr ⟨c, l₁, l₂, _, _, h₃, h₄⟩ => rw [h₄, h₃]; simp
theorem eraseP_subset (l : List α) : l.eraseP p ⊆ l := (eraseP_sublist l).subset
protected theorem Sublist.eraseP : l₁ <+ l₂ → l₁.eraseP p <+ l₂.eraseP p
| .slnil => Sublist.refl _
| .cons a s => by
by_cases h : p a <;> simp [h]
exacts [s.eraseP.trans (eraseP_sublist _), s.eraseP.cons _]
| .cons₂ a s => by
by_cases h : p a <;> simp [h]
exacts [s, s.eraseP]
theorem mem_of_mem_eraseP {l : List α} : a ∈ l.eraseP p → a ∈ l := (eraseP_subset _ ·)
@[simp] theorem mem_eraseP_of_neg {l : List α} (pa : ¬p a) : a ∈ l.eraseP p ↔ a ∈ l := by
refine ⟨mem_of_mem_eraseP, fun al => ?_⟩
match exists_or_eq_self_of_eraseP p l with
| .inl h => rw [h]; assumption
| .inr ⟨c, l₁, l₂, h₁, h₂, h₃, h₄⟩ =>
rw [h₄]; rw [h₃] at al
have : a ≠ c := fun h => (h ▸ pa).elim h₂
simp [this] at al; simp [al]
theorem eraseP_map (f : β → α) : ∀ (l : List β), (map f l).eraseP p = map f (l.eraseP (p ∘ f))
| [] => rfl
| b::l => by by_cases h : p (f b) <;> simp [h, eraseP_map f l, eraseP_cons_of_pos]
@[simp] theorem extractP_eq_find?_eraseP
(l : List α) : extractP p l = (find? p l, eraseP p l) := by
let rec go (acc) : ∀ xs, l = acc.data ++ xs →
extractP.go p l xs acc = (xs.find? p, acc.data ++ xs.eraseP p)
| [] => fun h => by simp [extractP.go, find?, eraseP, h]
| x::xs => by
simp [extractP.go, find?, eraseP]; cases p x <;> simp
· intro h; rw [go _ xs]; {simp}; simp [h]
exact go #[] _ rfl
@[simp] theorem filter_sublist {p : α → Bool} : ∀ (l : List α), filter p l <+ l
| [] => .slnil
| a :: l => by rw [filter]; split <;> simp [Sublist.cons, Sublist.cons₂, filter_sublist l]
theorem length_filter_le (p : α → Bool) (l : List α) :
(l.filter p).length ≤ l.length := (filter_sublist _).length_le
theorem length_filterMap_le (f : α → Option β) (l : List α) :
(filterMap f l).length ≤ l.length := by
rw [← length_map _ some, map_filterMap_some_eq_filter_map_is_some, ← length_map _ f]
apply length_filter_le
protected theorem Sublist.filterMap (f : α → Option β) (s : l₁ <+ l₂) :
filterMap f l₁ <+ filterMap f l₂ := by
induction s <;> simp <;> split <;> simp [*, cons, cons₂]
theorem Sublist.filter (p : α → Bool) {l₁ l₂} (s : l₁ <+ l₂) : filter p l₁ <+ filter p l₂ := by
rw [← filterMap_eq_filter]; apply s.filterMap
@[simp]
theorem filter_eq_self {l} : filter p l = l ↔ ∀ a ∈ l, p a := by
induction l with simp
| cons a l ih =>
cases h : p a <;> simp [*]
intro h; exact Nat.lt_irrefl _ (h ▸ length_filter_le p l)
@[simp]
theorem filter_length_eq_length {l} : (filter p l).length = l.length ↔ ∀ a ∈ l, p a :=
Iff.trans ⟨l.filter_sublist.eq_of_length, congrArg length⟩ filter_eq_self
@[simp] theorem findIdx_nil {α : Type _} (p : α → Bool) : [].findIdx p = 0 := rfl
theorem findIdx_cons (p : α → Bool) (b : α) (l : List α) :
(b :: l).findIdx p = bif p b then 0 else (l.findIdx p) + 1 := by
cases H : p b with
| true => simp [H, findIdx, findIdx.go]
| false => simp [H, findIdx, findIdx.go, findIdx_go_succ]
where
findIdx_go_succ (p : α → Bool) (l : List α) (n : Nat) :
List.findIdx.go p l (n + 1) = (findIdx.go p l n) + 1 := by
cases l with
| nil => unfold findIdx.go; exact Nat.succ_eq_add_one n
| cons head tail =>
unfold findIdx.go
cases p head <;> simp only [cond_false, cond_true]
exact findIdx_go_succ p tail (n + 1)
theorem findIdx_of_get?_eq_some {xs : List α} (w : xs.get? (xs.findIdx p) = some y) : p y := by
induction xs with
| nil => simp_all
| cons x xs ih => by_cases h : p x <;> simp_all [findIdx_cons]
theorem findIdx_get {xs : List α} {w : xs.findIdx p < xs.length} :
p (xs.get ⟨xs.findIdx p, w⟩) :=
xs.findIdx_of_get?_eq_some (get?_eq_get w)
theorem findIdx_lt_length_of_exists {xs : List α} (h : ∃ x ∈ xs, p x) :
xs.findIdx p < xs.length := by
induction xs with
| nil => simp_all
| cons x xs ih =>
by_cases p x
· simp_all only [forall_exists_index, and_imp, mem_cons, exists_eq_or_imp, true_or,
findIdx_cons, cond_true, length_cons]
apply Nat.succ_pos
· simp_all [findIdx_cons]
refine Nat.succ_lt_succ ?_
obtain ⟨x', m', h'⟩ := h
exact ih x' m' h'
theorem findIdx_get?_eq_get_of_exists {xs : List α} (h : ∃ x ∈ xs, p x) :
xs.get? (xs.findIdx p) = some (xs.get ⟨xs.findIdx p, xs.findIdx_lt_length_of_exists h⟩) :=
get?_eq_get (findIdx_lt_length_of_exists h)
@[simp] theorem findIdx?_nil : ([] : List α).findIdx? p i = none := rfl
@[simp] theorem findIdx?_cons :
(x :: xs).findIdx? p i = if p x then some i else findIdx? p xs (i + 1) := rfl
@[simp] theorem findIdx?_succ :
(xs : List α).findIdx? p (i+1) = (xs.findIdx? p i).map fun i => i + 1 := by
induction xs generalizing i with simp
| cons _ _ _ => split <;> simp_all
theorem findIdx?_eq_some_iff (xs : List α) (p : α → Bool) :
xs.findIdx? p = some i ↔ (xs.take (i + 1)).map p = replicate i false ++ [true] := by
induction xs generalizing i with
| nil => simp
| cons x xs ih =>
simp only [findIdx?_cons, Nat.zero_add, findIdx?_succ, take_succ_cons, map_cons]
split <;> cases i <;> simp_all
theorem findIdx?_of_eq_some {xs : List α} {p : α → Bool} (w : xs.findIdx? p = some i) :
match xs.get? i with | some a => p a | none => false := by
induction xs generalizing i with
| nil => simp_all
| cons x xs ih =>
simp_all only [findIdx?_cons, Nat.zero_add, findIdx?_succ]
split at w <;> cases i <;> simp_all
theorem findIdx?_of_eq_none {xs : List α} {p : α → Bool} (w : xs.findIdx? p = none) :
∀ i, match xs.get? i with | some a => ¬ p a | none => true := by
intro i
induction xs generalizing i with
| nil => simp_all
| cons x xs ih =>
simp_all only [Bool.not_eq_true, findIdx?_cons, Nat.zero_add, findIdx?_succ]
cases i with
| zero =>
split at w <;> simp_all
| succ i =>
simp only [get?_cons_succ]
apply ih
split at w <;> simp_all
@[simp] theorem findIdx?_append :
(xs ++ ys : List α).findIdx? p =
(xs.findIdx? p <|> (ys.findIdx? p).map fun i => i + xs.length) := by
induction xs with simp
| cons _ _ _ => split <;> simp_all [Option.map_orElse, Option.map_map]; rfl
@[simp] theorem findIdx?_replicate :
(replicate n a).findIdx? p = if 0 < n ∧ p a then some 0 else none := by
induction n with
| zero => simp
| succ n ih =>
simp only [replicate, findIdx?_cons, Nat.zero_add, findIdx?_succ, Nat.zero_lt_succ, true_and]
split <;> simp_all
theorem Pairwise.sublist : l₁ <+ l₂ → l₂.Pairwise R → l₁.Pairwise R
| .slnil, h => h
| .cons _ s, .cons _ h₂ => h₂.sublist s
| .cons₂ _ s, .cons h₁ h₂ => (h₂.sublist s).cons fun _ h => h₁ _ (s.subset h)
theorem pairwise_map {l : List α} :
(l.map f).Pairwise R ↔ l.Pairwise fun a b => R (f a) (f b) := by
induction l
· simp
· simp only [map, pairwise_cons, forall_mem_map_iff, *]
theorem pairwise_append {l₁ l₂ : List α} :
(l₁ ++ l₂).Pairwise R ↔ l₁.Pairwise R ∧ l₂.Pairwise R ∧ ∀ a ∈ l₁, ∀ b ∈ l₂, R a b := by
induction l₁ <;> simp [*, or_imp, forall_and, and_assoc, and_left_comm]
theorem pairwise_reverse {l : List α} :
l.reverse.Pairwise R ↔ l.Pairwise (fun a b => R b a) := by
induction l <;> simp [*, pairwise_append, and_comm]
theorem Pairwise.imp {α R S} (H : ∀ {a b}, R a b → S a b) :
∀ {l : List α}, l.Pairwise R → l.Pairwise S
| _, .nil => .nil
| _, .cons h₁ h₂ => .cons (H ∘ h₁ ·) (h₂.imp H)
theorem replaceF_nil : [].replaceF p = [] := rfl
theorem replaceF_cons (a : α) (l : List α) :
(a :: l).replaceF p = match p a with
| none => a :: replaceF p l
| some a' => a' :: l := rfl
theorem replaceF_cons_of_some {l : List α} (p) (h : p a = some a') :
(a :: l).replaceF p = a' :: l := by
simp [replaceF_cons, h]
theorem replaceF_cons_of_none {l : List α} (p) (h : p a = none) :
(a :: l).replaceF p = a :: l.replaceF p := by simp [replaceF_cons, h]
theorem replaceF_of_forall_none {l : List α} (h : ∀ a, a ∈ l → p a = none) : l.replaceF p = l := by
induction l with
| nil => rfl
| cons _ _ ih => simp [h _ (.head ..), ih (forall_mem_cons.1 h).2]
theorem exists_of_replaceF : ∀ {l : List α} {a a'} (al : a ∈ l) (pa : p a = some a'),
∃ a a' l₁ l₂,
(∀ b ∈ l₁, p b = none) ∧ p a = some a' ∧ l = l₁ ++ a :: l₂ ∧ l.replaceF p = l₁ ++ a' :: l₂
| b :: l, a, a', al, pa =>
match pb : p b with
| some b' => ⟨b, b', [], l, forall_mem_nil _, pb, by simp [pb]⟩
| none =>
match al with
| .head .. => nomatch pb.symm.trans pa
| .tail _ al =>
let ⟨c, c', l₁, l₂, h₁, h₂, h₃, h₄⟩ := exists_of_replaceF al pa
⟨c, c', b::l₁, l₂, (forall_mem_cons ..).2 ⟨pb, h₁⟩,
h₂, by rw [h₃, cons_append], by simp [pb, h₄]⟩
theorem exists_or_eq_self_of_replaceF (p) (l : List α) :
l.replaceF p = l ∨ ∃ a a' l₁ l₂,
(∀ b ∈ l₁, p b = none) ∧ p a = some a' ∧ l = l₁ ++ a :: l₂ ∧ l.replaceF p = l₁ ++ a' :: l₂ :=
if h : ∃ a ∈ l, (p a).isSome then
let ⟨_, ha, pa⟩ := h
.inr (exists_of_replaceF ha (Option.get_mem pa))
else
.inl <| replaceF_of_forall_none fun a ha =>
Option.not_isSome_iff_eq_none.1 fun h' => h ⟨a, ha, h'⟩
@[simp] theorem length_replaceF : length (replaceF f l) = length l := by
induction l <;> simp [replaceF]; split <;> simp [*]
theorem disjoint_symm (d : Disjoint l₁ l₂) : Disjoint l₂ l₁ := fun _ i₂ i₁ => d i₁ i₂
theorem disjoint_comm : Disjoint l₁ l₂ ↔ Disjoint l₂ l₁ := ⟨disjoint_symm, disjoint_symm⟩
| .lake/packages/batteries/Batteries/Data/List/Lemmas.lean | 819 | 819 | theorem disjoint_left : Disjoint l₁ l₂ ↔ ∀ ⦃a⦄, a ∈ l₁ → a ∉ l₂ := by | simp [Disjoint]
|
import Mathlib.MeasureTheory.Function.LpSeminorm.Basic
import Mathlib.MeasureTheory.Integral.MeanInequalities
#align_import measure_theory.function.lp_seminorm from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9"
open Filter
open scoped ENNReal Topology
namespace MeasureTheory
variable {α E : Type*} {m : MeasurableSpace α} [NormedAddCommGroup E]
{p : ℝ≥0∞} {q : ℝ} {μ : Measure α} {f g : α → E}
theorem snorm'_add_le {f g : α → E} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ)
(hq1 : 1 ≤ q) : snorm' (f + g) q μ ≤ snorm' f q μ + snorm' g q μ :=
calc
(∫⁻ a, (‖(f + g) a‖₊ : ℝ≥0∞) ^ q ∂μ) ^ (1 / q) ≤
(∫⁻ a, ((fun a => (‖f a‖₊ : ℝ≥0∞)) + fun a => (‖g a‖₊ : ℝ≥0∞)) a ^ q ∂μ) ^ (1 / q) := by
gcongr with a
simp only [Pi.add_apply, ← ENNReal.coe_add, ENNReal.coe_le_coe, nnnorm_add_le]
_ ≤ snorm' f q μ + snorm' g q μ := ENNReal.lintegral_Lp_add_le hf.ennnorm hg.ennnorm hq1
#align measure_theory.snorm'_add_le MeasureTheory.snorm'_add_le
theorem snorm'_add_le_of_le_one {f g : α → E} (hf : AEStronglyMeasurable f μ) (hq0 : 0 ≤ q)
(hq1 : q ≤ 1) : snorm' (f + g) q μ ≤ (2 : ℝ≥0∞) ^ (1 / q - 1) * (snorm' f q μ + snorm' g q μ) :=
calc
(∫⁻ a, (‖(f + g) a‖₊ : ℝ≥0∞) ^ q ∂μ) ^ (1 / q) ≤
(∫⁻ a, ((fun a => (‖f a‖₊ : ℝ≥0∞)) + fun a => (‖g a‖₊ : ℝ≥0∞)) a ^ q ∂μ) ^ (1 / q) := by
gcongr with a
simp only [Pi.add_apply, ← ENNReal.coe_add, ENNReal.coe_le_coe, nnnorm_add_le]
_ ≤ (2 : ℝ≥0∞) ^ (1 / q - 1) * (snorm' f q μ + snorm' g q μ) :=
ENNReal.lintegral_Lp_add_le_of_le_one hf.ennnorm hq0 hq1
#align measure_theory.snorm'_add_le_of_le_one MeasureTheory.snorm'_add_le_of_le_one
theorem snormEssSup_add_le {f g : α → E} :
snormEssSup (f + g) μ ≤ snormEssSup f μ + snormEssSup g μ := by
refine le_trans (essSup_mono_ae (eventually_of_forall fun x => ?_)) (ENNReal.essSup_add_le _ _)
simp_rw [Pi.add_apply, ← ENNReal.coe_add, ENNReal.coe_le_coe]
exact nnnorm_add_le _ _
#align measure_theory.snorm_ess_sup_add_le MeasureTheory.snormEssSup_add_le
theorem snorm_add_le {f g : α → E} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ)
(hp1 : 1 ≤ p) : snorm (f + g) p μ ≤ snorm f p μ + snorm g p μ := by
by_cases hp0 : p = 0
· simp [hp0]
by_cases hp_top : p = ∞
· simp [hp_top, snormEssSup_add_le]
have hp1_real : 1 ≤ p.toReal := by
rwa [← ENNReal.one_toReal, ENNReal.toReal_le_toReal ENNReal.one_ne_top hp_top]
repeat rw [snorm_eq_snorm' hp0 hp_top]
exact snorm'_add_le hf hg hp1_real
#align measure_theory.snorm_add_le MeasureTheory.snorm_add_le
noncomputable def LpAddConst (p : ℝ≥0∞) : ℝ≥0∞ :=
if p ∈ Set.Ioo (0 : ℝ≥0∞) 1 then (2 : ℝ≥0∞) ^ (1 / p.toReal - 1) else 1
set_option linter.uppercaseLean3 false in
#align measure_theory.Lp_add_const MeasureTheory.LpAddConst
theorem LpAddConst_of_one_le {p : ℝ≥0∞} (hp : 1 ≤ p) : LpAddConst p = 1 := by
rw [LpAddConst, if_neg]
intro h
exact lt_irrefl _ (h.2.trans_le hp)
set_option linter.uppercaseLean3 false in
#align measure_theory.Lp_add_const_of_one_le MeasureTheory.LpAddConst_of_one_le
theorem LpAddConst_zero : LpAddConst 0 = 1 := by
rw [LpAddConst, if_neg]
intro h
exact lt_irrefl _ h.1
set_option linter.uppercaseLean3 false in
#align measure_theory.Lp_add_const_zero MeasureTheory.LpAddConst_zero
theorem LpAddConst_lt_top (p : ℝ≥0∞) : LpAddConst p < ∞ := by
rw [LpAddConst]
split_ifs with h
· apply ENNReal.rpow_lt_top_of_nonneg _ ENNReal.two_ne_top
simp only [one_div, sub_nonneg]
apply one_le_inv (ENNReal.toReal_pos h.1.ne' (h.2.trans ENNReal.one_lt_top).ne)
simpa using ENNReal.toReal_mono ENNReal.one_ne_top h.2.le
· exact ENNReal.one_lt_top
set_option linter.uppercaseLean3 false in
#align measure_theory.Lp_add_const_lt_top MeasureTheory.LpAddConst_lt_top
theorem snorm_add_le' {f g : α → E} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ)
(p : ℝ≥0∞) : snorm (f + g) p μ ≤ LpAddConst p * (snorm f p μ + snorm g p μ) := by
rcases eq_or_ne p 0 with (rfl | hp)
· simp only [snorm_exponent_zero, add_zero, mul_zero, le_zero_iff]
rcases lt_or_le p 1 with (h'p | h'p)
· simp only [snorm_eq_snorm' hp (h'p.trans ENNReal.one_lt_top).ne]
convert snorm'_add_le_of_le_one hf ENNReal.toReal_nonneg _
· have : p ∈ Set.Ioo (0 : ℝ≥0∞) 1 := ⟨hp.bot_lt, h'p⟩
simp only [LpAddConst, if_pos this]
· simpa using ENNReal.toReal_mono ENNReal.one_ne_top h'p.le
· simp [LpAddConst_of_one_le h'p]
exact snorm_add_le hf hg h'p
#align measure_theory.snorm_add_le' MeasureTheory.snorm_add_le'
variable (μ E)
theorem exists_Lp_half (p : ℝ≥0∞) {δ : ℝ≥0∞} (hδ : δ ≠ 0) :
∃ η : ℝ≥0∞,
0 < η ∧
∀ (f g : α → E), AEStronglyMeasurable f μ → AEStronglyMeasurable g μ →
snorm f p μ ≤ η → snorm g p μ ≤ η → snorm (f + g) p μ < δ := by
have :
Tendsto (fun η : ℝ≥0∞ => LpAddConst p * (η + η)) (𝓝[>] 0) (𝓝 (LpAddConst p * (0 + 0))) :=
(ENNReal.Tendsto.const_mul (tendsto_id.add tendsto_id)
(Or.inr (LpAddConst_lt_top p).ne)).mono_left
nhdsWithin_le_nhds
simp only [add_zero, mul_zero] at this
rcases (((tendsto_order.1 this).2 δ hδ.bot_lt).and self_mem_nhdsWithin).exists with ⟨η, hη, ηpos⟩
refine ⟨η, ηpos, fun f g hf hg Hf Hg => ?_⟩
calc
snorm (f + g) p μ ≤ LpAddConst p * (snorm f p μ + snorm g p μ) := snorm_add_le' hf hg p
_ ≤ LpAddConst p * (η + η) := by gcongr
_ < δ := hη
set_option linter.uppercaseLean3 false in
#align measure_theory.exists_Lp_half MeasureTheory.exists_Lp_half
variable {μ E}
theorem snorm_sub_le' {f g : α → E} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ)
(p : ℝ≥0∞) : snorm (f - g) p μ ≤ LpAddConst p * (snorm f p μ + snorm g p μ) := by
simpa only [sub_eq_add_neg, snorm_neg] using snorm_add_le' hf hg.neg p
#align measure_theory.snorm_sub_le' MeasureTheory.snorm_sub_le'
| Mathlib/MeasureTheory/Function/LpSeminorm/TriangleInequality.lean | 145 | 147 | theorem snorm_sub_le {f g : α → E} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ)
(hp : 1 ≤ p) : snorm (f - g) p μ ≤ snorm f p μ + snorm g p μ := by |
simpa [LpAddConst_of_one_le hp] using snorm_sub_le' hf hg p
|
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α where
__ := GeneralizedBooleanAlgebra.toBot
bot_le a := by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, inf_comm x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [inf_comm x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α where
__ := ‹GeneralizedBooleanAlgebra α›
__ := GeneralizedBooleanAlgebra.toOrderBot
sdiff := (· \ ·)
sdiff_le_iff y x z :=
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x := by
rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := by rw [← inf_sup_right]))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, sup_comm x, inf_sup_self, inf_comm, sup_comm z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine le_trans (sup_le_sup_left sdiff_le z) ?_
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine le_of_inf_le_sup_le ?_ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) := by
rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, inf_comm (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
| Mathlib/Order/BooleanAlgebra.lean | 319 | 322 | theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by |
refine sdiff_le.lt_of_ne fun h => hy ?_
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
|
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic
import Mathlib.Topology.Order.ProjIcc
#align_import analysis.special_functions.trigonometric.inverse from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
noncomputable section
open scoped Classical
open Topology Filter
open Set Filter
open Real
namespace Real
variable {x y : ℝ}
-- @[pp_nodot] Porting note: not implemented
noncomputable def arcsin : ℝ → ℝ :=
Subtype.val ∘ IccExtend (neg_le_self zero_le_one) sinOrderIso.symm
#align real.arcsin Real.arcsin
theorem arcsin_mem_Icc (x : ℝ) : arcsin x ∈ Icc (-(π / 2)) (π / 2) :=
Subtype.coe_prop _
#align real.arcsin_mem_Icc Real.arcsin_mem_Icc
@[simp]
theorem range_arcsin : range arcsin = Icc (-(π / 2)) (π / 2) := by
rw [arcsin, range_comp Subtype.val]
simp [Icc]
#align real.range_arcsin Real.range_arcsin
theorem arcsin_le_pi_div_two (x : ℝ) : arcsin x ≤ π / 2 :=
(arcsin_mem_Icc x).2
#align real.arcsin_le_pi_div_two Real.arcsin_le_pi_div_two
theorem neg_pi_div_two_le_arcsin (x : ℝ) : -(π / 2) ≤ arcsin x :=
(arcsin_mem_Icc x).1
#align real.neg_pi_div_two_le_arcsin Real.neg_pi_div_two_le_arcsin
theorem arcsin_projIcc (x : ℝ) :
arcsin (projIcc (-1) 1 (neg_le_self zero_le_one) x) = arcsin x := by
rw [arcsin, Function.comp_apply, IccExtend_val, Function.comp_apply, IccExtend,
Function.comp_apply]
#align real.arcsin_proj_Icc Real.arcsin_projIcc
theorem sin_arcsin' {x : ℝ} (hx : x ∈ Icc (-1 : ℝ) 1) : sin (arcsin x) = x := by
simpa [arcsin, IccExtend_of_mem _ _ hx, -OrderIso.apply_symm_apply] using
Subtype.ext_iff.1 (sinOrderIso.apply_symm_apply ⟨x, hx⟩)
#align real.sin_arcsin' Real.sin_arcsin'
theorem sin_arcsin {x : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) : sin (arcsin x) = x :=
sin_arcsin' ⟨hx₁, hx₂⟩
#align real.sin_arcsin Real.sin_arcsin
theorem arcsin_sin' {x : ℝ} (hx : x ∈ Icc (-(π / 2)) (π / 2)) : arcsin (sin x) = x :=
injOn_sin (arcsin_mem_Icc _) hx <| by rw [sin_arcsin (neg_one_le_sin _) (sin_le_one _)]
#align real.arcsin_sin' Real.arcsin_sin'
theorem arcsin_sin {x : ℝ} (hx₁ : -(π / 2) ≤ x) (hx₂ : x ≤ π / 2) : arcsin (sin x) = x :=
arcsin_sin' ⟨hx₁, hx₂⟩
#align real.arcsin_sin Real.arcsin_sin
theorem strictMonoOn_arcsin : StrictMonoOn arcsin (Icc (-1) 1) :=
(Subtype.strictMono_coe _).comp_strictMonoOn <|
sinOrderIso.symm.strictMono.strictMonoOn_IccExtend _
#align real.strict_mono_on_arcsin Real.strictMonoOn_arcsin
theorem monotone_arcsin : Monotone arcsin :=
(Subtype.mono_coe _).comp <| sinOrderIso.symm.monotone.IccExtend _
#align real.monotone_arcsin Real.monotone_arcsin
theorem injOn_arcsin : InjOn arcsin (Icc (-1) 1) :=
strictMonoOn_arcsin.injOn
#align real.inj_on_arcsin Real.injOn_arcsin
theorem arcsin_inj {x y : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) (hy₁ : -1 ≤ y) (hy₂ : y ≤ 1) :
arcsin x = arcsin y ↔ x = y :=
injOn_arcsin.eq_iff ⟨hx₁, hx₂⟩ ⟨hy₁, hy₂⟩
#align real.arcsin_inj Real.arcsin_inj
@[continuity]
theorem continuous_arcsin : Continuous arcsin :=
continuous_subtype_val.comp sinOrderIso.symm.continuous.Icc_extend'
#align real.continuous_arcsin Real.continuous_arcsin
theorem continuousAt_arcsin {x : ℝ} : ContinuousAt arcsin x :=
continuous_arcsin.continuousAt
#align real.continuous_at_arcsin Real.continuousAt_arcsin
theorem arcsin_eq_of_sin_eq {x y : ℝ} (h₁ : sin x = y) (h₂ : x ∈ Icc (-(π / 2)) (π / 2)) :
arcsin y = x := by
subst y
exact injOn_sin (arcsin_mem_Icc _) h₂ (sin_arcsin' (sin_mem_Icc x))
#align real.arcsin_eq_of_sin_eq Real.arcsin_eq_of_sin_eq
@[simp]
theorem arcsin_zero : arcsin 0 = 0 :=
arcsin_eq_of_sin_eq sin_zero ⟨neg_nonpos.2 pi_div_two_pos.le, pi_div_two_pos.le⟩
#align real.arcsin_zero Real.arcsin_zero
@[simp]
theorem arcsin_one : arcsin 1 = π / 2 :=
arcsin_eq_of_sin_eq sin_pi_div_two <| right_mem_Icc.2 (neg_le_self pi_div_two_pos.le)
#align real.arcsin_one Real.arcsin_one
theorem arcsin_of_one_le {x : ℝ} (hx : 1 ≤ x) : arcsin x = π / 2 := by
rw [← arcsin_projIcc, projIcc_of_right_le _ hx, Subtype.coe_mk, arcsin_one]
#align real.arcsin_of_one_le Real.arcsin_of_one_le
theorem arcsin_neg_one : arcsin (-1) = -(π / 2) :=
arcsin_eq_of_sin_eq (by rw [sin_neg, sin_pi_div_two]) <|
left_mem_Icc.2 (neg_le_self pi_div_two_pos.le)
#align real.arcsin_neg_one Real.arcsin_neg_one
theorem arcsin_of_le_neg_one {x : ℝ} (hx : x ≤ -1) : arcsin x = -(π / 2) := by
rw [← arcsin_projIcc, projIcc_of_le_left _ hx, Subtype.coe_mk, arcsin_neg_one]
#align real.arcsin_of_le_neg_one Real.arcsin_of_le_neg_one
@[simp]
theorem arcsin_neg (x : ℝ) : arcsin (-x) = -arcsin x := by
rcases le_total x (-1) with hx₁ | hx₁
· rw [arcsin_of_le_neg_one hx₁, neg_neg, arcsin_of_one_le (le_neg.2 hx₁)]
rcases le_total 1 x with hx₂ | hx₂
· rw [arcsin_of_one_le hx₂, arcsin_of_le_neg_one (neg_le_neg hx₂)]
refine arcsin_eq_of_sin_eq ?_ ?_
· rw [sin_neg, sin_arcsin hx₁ hx₂]
· exact ⟨neg_le_neg (arcsin_le_pi_div_two _), neg_le.2 (neg_pi_div_two_le_arcsin _)⟩
#align real.arcsin_neg Real.arcsin_neg
theorem arcsin_le_iff_le_sin {x y : ℝ} (hx : x ∈ Icc (-1 : ℝ) 1) (hy : y ∈ Icc (-(π / 2)) (π / 2)) :
arcsin x ≤ y ↔ x ≤ sin y := by
rw [← arcsin_sin' hy, strictMonoOn_arcsin.le_iff_le hx (sin_mem_Icc _), arcsin_sin' hy]
#align real.arcsin_le_iff_le_sin Real.arcsin_le_iff_le_sin
theorem arcsin_le_iff_le_sin' {x y : ℝ} (hy : y ∈ Ico (-(π / 2)) (π / 2)) :
arcsin x ≤ y ↔ x ≤ sin y := by
rcases le_total x (-1) with hx₁ | hx₁
· simp [arcsin_of_le_neg_one hx₁, hy.1, hx₁.trans (neg_one_le_sin _)]
cases' lt_or_le 1 x with hx₂ hx₂
· simp [arcsin_of_one_le hx₂.le, hy.2.not_le, (sin_le_one y).trans_lt hx₂]
exact arcsin_le_iff_le_sin ⟨hx₁, hx₂⟩ (mem_Icc_of_Ico hy)
#align real.arcsin_le_iff_le_sin' Real.arcsin_le_iff_le_sin'
theorem le_arcsin_iff_sin_le {x y : ℝ} (hx : x ∈ Icc (-(π / 2)) (π / 2)) (hy : y ∈ Icc (-1 : ℝ) 1) :
x ≤ arcsin y ↔ sin x ≤ y := by
rw [← neg_le_neg_iff, ← arcsin_neg,
arcsin_le_iff_le_sin ⟨neg_le_neg hy.2, neg_le.2 hy.1⟩ ⟨neg_le_neg hx.2, neg_le.2 hx.1⟩, sin_neg,
neg_le_neg_iff]
#align real.le_arcsin_iff_sin_le Real.le_arcsin_iff_sin_le
theorem le_arcsin_iff_sin_le' {x y : ℝ} (hx : x ∈ Ioc (-(π / 2)) (π / 2)) :
x ≤ arcsin y ↔ sin x ≤ y := by
rw [← neg_le_neg_iff, ← arcsin_neg, arcsin_le_iff_le_sin' ⟨neg_le_neg hx.2, neg_lt.2 hx.1⟩,
sin_neg, neg_le_neg_iff]
#align real.le_arcsin_iff_sin_le' Real.le_arcsin_iff_sin_le'
theorem arcsin_lt_iff_lt_sin {x y : ℝ} (hx : x ∈ Icc (-1 : ℝ) 1) (hy : y ∈ Icc (-(π / 2)) (π / 2)) :
arcsin x < y ↔ x < sin y :=
not_le.symm.trans <| (not_congr <| le_arcsin_iff_sin_le hy hx).trans not_le
#align real.arcsin_lt_iff_lt_sin Real.arcsin_lt_iff_lt_sin
theorem arcsin_lt_iff_lt_sin' {x y : ℝ} (hy : y ∈ Ioc (-(π / 2)) (π / 2)) :
arcsin x < y ↔ x < sin y :=
not_le.symm.trans <| (not_congr <| le_arcsin_iff_sin_le' hy).trans not_le
#align real.arcsin_lt_iff_lt_sin' Real.arcsin_lt_iff_lt_sin'
theorem lt_arcsin_iff_sin_lt {x y : ℝ} (hx : x ∈ Icc (-(π / 2)) (π / 2)) (hy : y ∈ Icc (-1 : ℝ) 1) :
x < arcsin y ↔ sin x < y :=
not_le.symm.trans <| (not_congr <| arcsin_le_iff_le_sin hy hx).trans not_le
#align real.lt_arcsin_iff_sin_lt Real.lt_arcsin_iff_sin_lt
theorem lt_arcsin_iff_sin_lt' {x y : ℝ} (hx : x ∈ Ico (-(π / 2)) (π / 2)) :
x < arcsin y ↔ sin x < y :=
not_le.symm.trans <| (not_congr <| arcsin_le_iff_le_sin' hx).trans not_le
#align real.lt_arcsin_iff_sin_lt' Real.lt_arcsin_iff_sin_lt'
theorem arcsin_eq_iff_eq_sin {x y : ℝ} (hy : y ∈ Ioo (-(π / 2)) (π / 2)) :
arcsin x = y ↔ x = sin y := by
simp only [le_antisymm_iff, arcsin_le_iff_le_sin' (mem_Ico_of_Ioo hy),
le_arcsin_iff_sin_le' (mem_Ioc_of_Ioo hy)]
#align real.arcsin_eq_iff_eq_sin Real.arcsin_eq_iff_eq_sin
@[simp]
theorem arcsin_nonneg {x : ℝ} : 0 ≤ arcsin x ↔ 0 ≤ x :=
(le_arcsin_iff_sin_le' ⟨neg_lt_zero.2 pi_div_two_pos, pi_div_two_pos.le⟩).trans <| by
rw [sin_zero]
#align real.arcsin_nonneg Real.arcsin_nonneg
@[simp]
theorem arcsin_nonpos {x : ℝ} : arcsin x ≤ 0 ↔ x ≤ 0 :=
neg_nonneg.symm.trans <| arcsin_neg x ▸ arcsin_nonneg.trans neg_nonneg
#align real.arcsin_nonpos Real.arcsin_nonpos
@[simp]
theorem arcsin_eq_zero_iff {x : ℝ} : arcsin x = 0 ↔ x = 0 := by simp [le_antisymm_iff]
#align real.arcsin_eq_zero_iff Real.arcsin_eq_zero_iff
@[simp]
theorem zero_eq_arcsin_iff {x} : 0 = arcsin x ↔ x = 0 :=
eq_comm.trans arcsin_eq_zero_iff
#align real.zero_eq_arcsin_iff Real.zero_eq_arcsin_iff
@[simp]
theorem arcsin_pos {x : ℝ} : 0 < arcsin x ↔ 0 < x :=
lt_iff_lt_of_le_iff_le arcsin_nonpos
#align real.arcsin_pos Real.arcsin_pos
@[simp]
theorem arcsin_lt_zero {x : ℝ} : arcsin x < 0 ↔ x < 0 :=
lt_iff_lt_of_le_iff_le arcsin_nonneg
#align real.arcsin_lt_zero Real.arcsin_lt_zero
@[simp]
theorem arcsin_lt_pi_div_two {x : ℝ} : arcsin x < π / 2 ↔ x < 1 :=
(arcsin_lt_iff_lt_sin' (right_mem_Ioc.2 <| neg_lt_self pi_div_two_pos)).trans <| by
rw [sin_pi_div_two]
#align real.arcsin_lt_pi_div_two Real.arcsin_lt_pi_div_two
@[simp]
theorem neg_pi_div_two_lt_arcsin {x : ℝ} : -(π / 2) < arcsin x ↔ -1 < x :=
(lt_arcsin_iff_sin_lt' <| left_mem_Ico.2 <| neg_lt_self pi_div_two_pos).trans <| by
rw [sin_neg, sin_pi_div_two]
#align real.neg_pi_div_two_lt_arcsin Real.neg_pi_div_two_lt_arcsin
@[simp]
theorem arcsin_eq_pi_div_two {x : ℝ} : arcsin x = π / 2 ↔ 1 ≤ x :=
⟨fun h => not_lt.1 fun h' => (arcsin_lt_pi_div_two.2 h').ne h, arcsin_of_one_le⟩
#align real.arcsin_eq_pi_div_two Real.arcsin_eq_pi_div_two
@[simp]
theorem pi_div_two_eq_arcsin {x} : π / 2 = arcsin x ↔ 1 ≤ x :=
eq_comm.trans arcsin_eq_pi_div_two
#align real.pi_div_two_eq_arcsin Real.pi_div_two_eq_arcsin
@[simp]
theorem pi_div_two_le_arcsin {x} : π / 2 ≤ arcsin x ↔ 1 ≤ x :=
(arcsin_le_pi_div_two x).le_iff_eq.trans pi_div_two_eq_arcsin
#align real.pi_div_two_le_arcsin Real.pi_div_two_le_arcsin
@[simp]
theorem arcsin_eq_neg_pi_div_two {x : ℝ} : arcsin x = -(π / 2) ↔ x ≤ -1 :=
⟨fun h => not_lt.1 fun h' => (neg_pi_div_two_lt_arcsin.2 h').ne' h, arcsin_of_le_neg_one⟩
#align real.arcsin_eq_neg_pi_div_two Real.arcsin_eq_neg_pi_div_two
@[simp]
theorem neg_pi_div_two_eq_arcsin {x} : -(π / 2) = arcsin x ↔ x ≤ -1 :=
eq_comm.trans arcsin_eq_neg_pi_div_two
#align real.neg_pi_div_two_eq_arcsin Real.neg_pi_div_two_eq_arcsin
@[simp]
theorem arcsin_le_neg_pi_div_two {x} : arcsin x ≤ -(π / 2) ↔ x ≤ -1 :=
(neg_pi_div_two_le_arcsin x).le_iff_eq.trans arcsin_eq_neg_pi_div_two
#align real.arcsin_le_neg_pi_div_two Real.arcsin_le_neg_pi_div_two
@[simp]
theorem pi_div_four_le_arcsin {x} : π / 4 ≤ arcsin x ↔ √2 / 2 ≤ x := by
rw [← sin_pi_div_four, le_arcsin_iff_sin_le']
have := pi_pos
constructor <;> linarith
#align real.pi_div_four_le_arcsin Real.pi_div_four_le_arcsin
theorem mapsTo_sin_Ioo : MapsTo sin (Ioo (-(π / 2)) (π / 2)) (Ioo (-1) 1) := fun x h => by
rwa [mem_Ioo, ← arcsin_lt_pi_div_two, ← neg_pi_div_two_lt_arcsin, arcsin_sin h.1.le h.2.le]
#align real.maps_to_sin_Ioo Real.mapsTo_sin_Ioo
@[simp]
def sinPartialHomeomorph : PartialHomeomorph ℝ ℝ where
toFun := sin
invFun := arcsin
source := Ioo (-(π / 2)) (π / 2)
target := Ioo (-1) 1
map_source' := mapsTo_sin_Ioo
map_target' _ hy := ⟨neg_pi_div_two_lt_arcsin.2 hy.1, arcsin_lt_pi_div_two.2 hy.2⟩
left_inv' _ hx := arcsin_sin hx.1.le hx.2.le
right_inv' _ hy := sin_arcsin hy.1.le hy.2.le
open_source := isOpen_Ioo
open_target := isOpen_Ioo
continuousOn_toFun := continuous_sin.continuousOn
continuousOn_invFun := continuous_arcsin.continuousOn
#align real.sin_local_homeomorph Real.sinPartialHomeomorph
theorem cos_arcsin_nonneg (x : ℝ) : 0 ≤ cos (arcsin x) :=
cos_nonneg_of_mem_Icc ⟨neg_pi_div_two_le_arcsin _, arcsin_le_pi_div_two _⟩
#align real.cos_arcsin_nonneg Real.cos_arcsin_nonneg
-- The junk values for `arcsin` and `sqrt` make this true even outside `[-1, 1]`.
theorem cos_arcsin (x : ℝ) : cos (arcsin x) = √(1 - x ^ 2) := by
by_cases hx₁ : -1 ≤ x; swap
· rw [not_le] at hx₁
rw [arcsin_of_le_neg_one hx₁.le, cos_neg, cos_pi_div_two, sqrt_eq_zero_of_nonpos]
nlinarith
by_cases hx₂ : x ≤ 1; swap
· rw [not_le] at hx₂
rw [arcsin_of_one_le hx₂.le, cos_pi_div_two, sqrt_eq_zero_of_nonpos]
nlinarith
have : sin (arcsin x) ^ 2 + cos (arcsin x) ^ 2 = 1 := sin_sq_add_cos_sq (arcsin x)
rw [← eq_sub_iff_add_eq', ← sqrt_inj (sq_nonneg _) (sub_nonneg.2 (sin_sq_le_one (arcsin x))), sq,
sqrt_mul_self (cos_arcsin_nonneg _)] at this
rw [this, sin_arcsin hx₁ hx₂]
#align real.cos_arcsin Real.cos_arcsin
-- The junk values for `arcsin` and `sqrt` make this true even outside `[-1, 1]`.
theorem tan_arcsin (x : ℝ) : tan (arcsin x) = x / √(1 - x ^ 2) := by
rw [tan_eq_sin_div_cos, cos_arcsin]
by_cases hx₁ : -1 ≤ x; swap
· have h : √(1 - x ^ 2) = 0 := sqrt_eq_zero_of_nonpos (by nlinarith)
rw [h]
simp
by_cases hx₂ : x ≤ 1; swap
· have h : √(1 - x ^ 2) = 0 := sqrt_eq_zero_of_nonpos (by nlinarith)
rw [h]
simp
rw [sin_arcsin hx₁ hx₂]
#align real.tan_arcsin Real.tan_arcsin
-- @[pp_nodot] Porting note: not implemented
noncomputable def arccos (x : ℝ) : ℝ :=
π / 2 - arcsin x
#align real.arccos Real.arccos
theorem arccos_eq_pi_div_two_sub_arcsin (x : ℝ) : arccos x = π / 2 - arcsin x :=
rfl
#align real.arccos_eq_pi_div_two_sub_arcsin Real.arccos_eq_pi_div_two_sub_arcsin
theorem arcsin_eq_pi_div_two_sub_arccos (x : ℝ) : arcsin x = π / 2 - arccos x := by simp [arccos]
#align real.arcsin_eq_pi_div_two_sub_arccos Real.arcsin_eq_pi_div_two_sub_arccos
theorem arccos_le_pi (x : ℝ) : arccos x ≤ π := by
unfold arccos; linarith [neg_pi_div_two_le_arcsin x]
#align real.arccos_le_pi Real.arccos_le_pi
theorem arccos_nonneg (x : ℝ) : 0 ≤ arccos x := by
unfold arccos; linarith [arcsin_le_pi_div_two x]
#align real.arccos_nonneg Real.arccos_nonneg
@[simp]
theorem arccos_pos {x : ℝ} : 0 < arccos x ↔ x < 1 := by simp [arccos]
#align real.arccos_pos Real.arccos_pos
theorem cos_arccos {x : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) : cos (arccos x) = x := by
rw [arccos, cos_pi_div_two_sub, sin_arcsin hx₁ hx₂]
#align real.cos_arccos Real.cos_arccos
theorem arccos_cos {x : ℝ} (hx₁ : 0 ≤ x) (hx₂ : x ≤ π) : arccos (cos x) = x := by
rw [arccos, ← sin_pi_div_two_sub, arcsin_sin] <;> simp [sub_eq_add_neg] <;> linarith
#align real.arccos_cos Real.arccos_cos
lemma arccos_eq_of_eq_cos (hy₀ : 0 ≤ y) (hy₁ : y ≤ π) (hxy : x = cos y) : arccos x = y := by
rw [hxy, arccos_cos hy₀ hy₁]
theorem strictAntiOn_arccos : StrictAntiOn arccos (Icc (-1) 1) := fun _ hx _ hy h =>
sub_lt_sub_left (strictMonoOn_arcsin hx hy h) _
#align real.strict_anti_on_arccos Real.strictAntiOn_arccos
theorem arccos_injOn : InjOn arccos (Icc (-1) 1) :=
strictAntiOn_arccos.injOn
#align real.arccos_inj_on Real.arccos_injOn
theorem arccos_inj {x y : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) (hy₁ : -1 ≤ y) (hy₂ : y ≤ 1) :
arccos x = arccos y ↔ x = y :=
arccos_injOn.eq_iff ⟨hx₁, hx₂⟩ ⟨hy₁, hy₂⟩
#align real.arccos_inj Real.arccos_inj
@[simp]
theorem arccos_zero : arccos 0 = π / 2 := by simp [arccos]
#align real.arccos_zero Real.arccos_zero
@[simp]
theorem arccos_one : arccos 1 = 0 := by simp [arccos]
#align real.arccos_one Real.arccos_one
@[simp]
theorem arccos_neg_one : arccos (-1) = π := by simp [arccos, add_halves]
#align real.arccos_neg_one Real.arccos_neg_one
@[simp]
theorem arccos_eq_zero {x} : arccos x = 0 ↔ 1 ≤ x := by simp [arccos, sub_eq_zero]
#align real.arccos_eq_zero Real.arccos_eq_zero
@[simp]
| Mathlib/Analysis/SpecialFunctions/Trigonometric/Inverse.lean | 402 | 402 | theorem arccos_eq_pi_div_two {x} : arccos x = π / 2 ↔ x = 0 := by | simp [arccos]
|
import Mathlib.Algebra.BigOperators.Intervals
import Mathlib.Algebra.BigOperators.Ring.List
import Mathlib.Data.Int.ModEq
import Mathlib.Data.Nat.Bits
import Mathlib.Data.Nat.Log
import Mathlib.Data.List.Indexes
import Mathlib.Data.List.Palindrome
import Mathlib.Tactic.IntervalCases
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring
#align_import data.nat.digits from "leanprover-community/mathlib"@"369525b73f229ccd76a6ec0e0e0bf2be57599768"
namespace Nat
variable {n : ℕ}
def digitsAux0 : ℕ → List ℕ
| 0 => []
| n + 1 => [n + 1]
#align nat.digits_aux_0 Nat.digitsAux0
def digitsAux1 (n : ℕ) : List ℕ :=
List.replicate n 1
#align nat.digits_aux_1 Nat.digitsAux1
def digitsAux (b : ℕ) (h : 2 ≤ b) : ℕ → List ℕ
| 0 => []
| n + 1 =>
((n + 1) % b) :: digitsAux b h ((n + 1) / b)
decreasing_by exact Nat.div_lt_self (Nat.succ_pos _) h
#align nat.digits_aux Nat.digitsAux
@[simp]
theorem digitsAux_zero (b : ℕ) (h : 2 ≤ b) : digitsAux b h 0 = [] := by rw [digitsAux]
#align nat.digits_aux_zero Nat.digitsAux_zero
theorem digitsAux_def (b : ℕ) (h : 2 ≤ b) (n : ℕ) (w : 0 < n) :
digitsAux b h n = (n % b) :: digitsAux b h (n / b) := by
cases n
· cases w
· rw [digitsAux]
#align nat.digits_aux_def Nat.digitsAux_def
def digits : ℕ → ℕ → List ℕ
| 0 => digitsAux0
| 1 => digitsAux1
| b + 2 => digitsAux (b + 2) (by norm_num)
#align nat.digits Nat.digits
@[simp]
theorem digits_zero (b : ℕ) : digits b 0 = [] := by
rcases b with (_ | ⟨_ | ⟨_⟩⟩) <;> simp [digits, digitsAux0, digitsAux1]
#align nat.digits_zero Nat.digits_zero
-- @[simp] -- Porting note (#10618): simp can prove this
theorem digits_zero_zero : digits 0 0 = [] :=
rfl
#align nat.digits_zero_zero Nat.digits_zero_zero
@[simp]
theorem digits_zero_succ (n : ℕ) : digits 0 n.succ = [n + 1] :=
rfl
#align nat.digits_zero_succ Nat.digits_zero_succ
theorem digits_zero_succ' : ∀ {n : ℕ}, n ≠ 0 → digits 0 n = [n]
| 0, h => (h rfl).elim
| _ + 1, _ => rfl
#align nat.digits_zero_succ' Nat.digits_zero_succ'
@[simp]
theorem digits_one (n : ℕ) : digits 1 n = List.replicate n 1 :=
rfl
#align nat.digits_one Nat.digits_one
-- @[simp] -- Porting note (#10685): dsimp can prove this
theorem digits_one_succ (n : ℕ) : digits 1 (n + 1) = 1 :: digits 1 n :=
rfl
#align nat.digits_one_succ Nat.digits_one_succ
theorem digits_add_two_add_one (b n : ℕ) :
digits (b + 2) (n + 1) = ((n + 1) % (b + 2)) :: digits (b + 2) ((n + 1) / (b + 2)) := by
simp [digits, digitsAux_def]
#align nat.digits_add_two_add_one Nat.digits_add_two_add_one
@[simp]
lemma digits_of_two_le_of_pos {b : ℕ} (hb : 2 ≤ b) (hn : 0 < n) :
Nat.digits b n = n % b :: Nat.digits b (n / b) := by
rw [Nat.eq_add_of_sub_eq hb rfl, Nat.eq_add_of_sub_eq hn rfl, Nat.digits_add_two_add_one]
theorem digits_def' :
∀ {b : ℕ} (_ : 1 < b) {n : ℕ} (_ : 0 < n), digits b n = (n % b) :: digits b (n / b)
| 0, h => absurd h (by decide)
| 1, h => absurd h (by decide)
| b + 2, _ => digitsAux_def _ (by simp) _
#align nat.digits_def' Nat.digits_def'
@[simp]
theorem digits_of_lt (b x : ℕ) (hx : x ≠ 0) (hxb : x < b) : digits b x = [x] := by
rcases exists_eq_succ_of_ne_zero hx with ⟨x, rfl⟩
rcases Nat.exists_eq_add_of_le' ((Nat.le_add_left 1 x).trans_lt hxb) with ⟨b, rfl⟩
rw [digits_add_two_add_one, div_eq_of_lt hxb, digits_zero, mod_eq_of_lt hxb]
#align nat.digits_of_lt Nat.digits_of_lt
theorem digits_add (b : ℕ) (h : 1 < b) (x y : ℕ) (hxb : x < b) (hxy : x ≠ 0 ∨ y ≠ 0) :
digits b (x + b * y) = x :: digits b y := by
rcases Nat.exists_eq_add_of_le' h with ⟨b, rfl : _ = _ + 2⟩
cases y
· simp [hxb, hxy.resolve_right (absurd rfl)]
dsimp [digits]
rw [digitsAux_def]
· congr
· simp [Nat.add_mod, mod_eq_of_lt hxb]
· simp [add_mul_div_left, div_eq_of_lt hxb]
· apply Nat.succ_pos
#align nat.digits_add Nat.digits_add
-- If we had a function converting a list into a polynomial,
-- and appropriate lemmas about that function,
-- we could rewrite this in terms of that.
def ofDigits {α : Type*} [Semiring α] (b : α) : List ℕ → α
| [] => 0
| h :: t => h + b * ofDigits b t
#align nat.of_digits Nat.ofDigits
theorem ofDigits_eq_foldr {α : Type*} [Semiring α] (b : α) (L : List ℕ) :
ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L := by
induction' L with d L ih
· rfl
· dsimp [ofDigits]
rw [ih]
#align nat.of_digits_eq_foldr Nat.ofDigits_eq_foldr
theorem ofDigits_eq_sum_map_with_index_aux (b : ℕ) (l : List ℕ) :
((List.range l.length).zipWith ((fun i a : ℕ => a * b ^ (i + 1))) l).sum =
b * ((List.range l.length).zipWith (fun i a => a * b ^ i) l).sum := by
suffices
(List.range l.length).zipWith (fun i a : ℕ => a * b ^ (i + 1)) l =
(List.range l.length).zipWith (fun i a => b * (a * b ^ i)) l
by simp [this]
congr; ext; simp [pow_succ]; ring
#align nat.of_digits_eq_sum_map_with_index_aux Nat.ofDigits_eq_sum_map_with_index_aux
theorem ofDigits_eq_sum_mapIdx (b : ℕ) (L : List ℕ) :
ofDigits b L = (L.mapIdx fun i a => a * b ^ i).sum := by
rw [List.mapIdx_eq_enum_map, List.enum_eq_zip_range, List.map_uncurry_zip_eq_zipWith,
ofDigits_eq_foldr]
induction' L with hd tl hl
· simp
· simpa [List.range_succ_eq_map, List.zipWith_map_left, ofDigits_eq_sum_map_with_index_aux] using
Or.inl hl
#align nat.of_digits_eq_sum_map_with_index Nat.ofDigits_eq_sum_mapIdx
@[simp]
theorem ofDigits_nil {b : ℕ} : ofDigits b [] = 0 := rfl
@[simp]
theorem ofDigits_singleton {b n : ℕ} : ofDigits b [n] = n := by simp [ofDigits]
#align nat.of_digits_singleton Nat.ofDigits_singleton
@[simp]
theorem ofDigits_one_cons {α : Type*} [Semiring α] (h : ℕ) (L : List ℕ) :
ofDigits (1 : α) (h :: L) = h + ofDigits 1 L := by simp [ofDigits]
#align nat.of_digits_one_cons Nat.ofDigits_one_cons
theorem ofDigits_cons {b hd} {tl : List ℕ} :
ofDigits b (hd :: tl) = hd + b * ofDigits b tl := rfl
theorem ofDigits_append {b : ℕ} {l1 l2 : List ℕ} :
ofDigits b (l1 ++ l2) = ofDigits b l1 + b ^ l1.length * ofDigits b l2 := by
induction' l1 with hd tl IH
· simp [ofDigits]
· rw [ofDigits, List.cons_append, ofDigits, IH, List.length_cons, pow_succ']
ring
#align nat.of_digits_append Nat.ofDigits_append
@[norm_cast]
theorem coe_ofDigits (α : Type*) [Semiring α] (b : ℕ) (L : List ℕ) :
((ofDigits b L : ℕ) : α) = ofDigits (b : α) L := by
induction' L with d L ih
· simp [ofDigits]
· dsimp [ofDigits]; push_cast; rw [ih]
#align nat.coe_of_digits Nat.coe_ofDigits
@[norm_cast]
theorem coe_int_ofDigits (b : ℕ) (L : List ℕ) : ((ofDigits b L : ℕ) : ℤ) = ofDigits (b : ℤ) L := by
induction' L with d L _
· rfl
· dsimp [ofDigits]; push_cast; simp only
#align nat.coe_int_of_digits Nat.coe_int_ofDigits
theorem digits_zero_of_eq_zero {b : ℕ} (h : b ≠ 0) :
∀ {L : List ℕ} (_ : ofDigits b L = 0), ∀ l ∈ L, l = 0
| _ :: _, h0, _, List.Mem.head .. => Nat.eq_zero_of_add_eq_zero_right h0
| _ :: _, h0, _, List.Mem.tail _ hL =>
digits_zero_of_eq_zero h (mul_right_injective₀ h (Nat.eq_zero_of_add_eq_zero_left h0)) _ hL
#align nat.digits_zero_of_eq_zero Nat.digits_zero_of_eq_zero
theorem digits_ofDigits (b : ℕ) (h : 1 < b) (L : List ℕ) (w₁ : ∀ l ∈ L, l < b)
(w₂ : ∀ h : L ≠ [], L.getLast h ≠ 0) : digits b (ofDigits b L) = L := by
induction' L with d L ih
· dsimp [ofDigits]
simp
· dsimp [ofDigits]
replace w₂ := w₂ (by simp)
rw [digits_add b h]
· rw [ih]
· intro l m
apply w₁
exact List.mem_cons_of_mem _ m
· intro h
rw [List.getLast_cons h] at w₂
convert w₂
· exact w₁ d (List.mem_cons_self _ _)
· by_cases h' : L = []
· rcases h' with rfl
left
simpa using w₂
· right
contrapose! w₂
refine digits_zero_of_eq_zero h.ne_bot w₂ _ ?_
rw [List.getLast_cons h']
exact List.getLast_mem h'
#align nat.digits_of_digits Nat.digits_ofDigits
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
cases' b with b
· cases' n with n
· rfl
· change ofDigits 0 [n + 1] = n + 1
dsimp [ofDigits]
· cases' b with b
· induction' n with n ih
· rfl
· rw [Nat.zero_add] at ih ⊢
simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
· apply Nat.strongInductionOn n _
clear n
intro n h
cases n
· rw [digits_zero]
rfl
· simp only [Nat.succ_eq_add_one, digits_add_two_add_one]
dsimp [ofDigits]
rw [h _ (Nat.div_lt_self' _ b)]
rw [Nat.mod_add_div]
#align nat.of_digits_digits Nat.ofDigits_digits
theorem ofDigits_one (L : List ℕ) : ofDigits 1 L = L.sum := by
induction' L with _ _ ih
· rfl
· simp [ofDigits, List.sum_cons, ih]
#align nat.of_digits_one Nat.ofDigits_one
theorem digits_eq_nil_iff_eq_zero {b n : ℕ} : digits b n = [] ↔ n = 0 := by
constructor
· intro h
have : ofDigits b (digits b n) = ofDigits b [] := by rw [h]
convert this
rw [ofDigits_digits]
· rintro rfl
simp
#align nat.digits_eq_nil_iff_eq_zero Nat.digits_eq_nil_iff_eq_zero
theorem digits_ne_nil_iff_ne_zero {b n : ℕ} : digits b n ≠ [] ↔ n ≠ 0 :=
not_congr digits_eq_nil_iff_eq_zero
#align nat.digits_ne_nil_iff_ne_zero Nat.digits_ne_nil_iff_ne_zero
theorem digits_eq_cons_digits_div {b n : ℕ} (h : 1 < b) (w : n ≠ 0) :
digits b n = (n % b) :: digits b (n / b) := by
rcases b with (_ | _ | b)
· rw [digits_zero_succ' w, Nat.mod_zero, Nat.div_zero, Nat.digits_zero_zero]
· norm_num at h
rcases n with (_ | n)
· norm_num at w
· simp only [digits_add_two_add_one, ne_eq]
#align nat.digits_eq_cons_digits_div Nat.digits_eq_cons_digits_div
theorem digits_getLast {b : ℕ} (m : ℕ) (h : 1 < b) (p q) :
(digits b m).getLast p = (digits b (m / b)).getLast q := by
by_cases hm : m = 0
· simp [hm]
simp only [digits_eq_cons_digits_div h hm]
rw [List.getLast_cons]
#align nat.digits_last Nat.digits_getLast
theorem digits.injective (b : ℕ) : Function.Injective b.digits :=
Function.LeftInverse.injective (ofDigits_digits b)
#align nat.digits.injective Nat.digits.injective
@[simp]
theorem digits_inj_iff {b n m : ℕ} : b.digits n = b.digits m ↔ n = m :=
(digits.injective b).eq_iff
#align nat.digits_inj_iff Nat.digits_inj_iff
theorem digits_len (b n : ℕ) (hb : 1 < b) (hn : n ≠ 0) : (b.digits n).length = b.log n + 1 := by
induction' n using Nat.strong_induction_on with n IH
rw [digits_eq_cons_digits_div hb hn, List.length]
by_cases h : n / b = 0
· have hb0 : b ≠ 0 := (Nat.succ_le_iff.1 hb).ne_bot
simp [h, log_eq_zero_iff, ← Nat.div_eq_zero_iff hb0.bot_lt]
· have : n / b < n := div_lt_self (Nat.pos_of_ne_zero hn) hb
rw [IH _ this h, log_div_base, tsub_add_cancel_of_le]
refine Nat.succ_le_of_lt (log_pos hb ?_)
contrapose! h
exact div_eq_of_lt h
#align nat.digits_len Nat.digits_len
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
(digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
rcases b with (_ | _ | b)
· cases m
· cases hm rfl
· simp
· cases m
· cases hm rfl
rename ℕ => m
simp only [zero_add, digits_one, List.getLast_replicate_succ m 1]
exact Nat.one_ne_zero
revert hm
apply Nat.strongInductionOn m
intro n IH hn
by_cases hnb : n < b + 2
· simpa only [digits_of_lt (b + 2) n hn hnb]
· rw [digits_getLast n (le_add_left 2 b)]
refine IH _ (Nat.div_lt_self hn.bot_lt (one_lt_succ_succ b)) ?_
rw [← pos_iff_ne_zero]
exact Nat.div_pos (le_of_not_lt hnb) (zero_lt_succ (succ b))
#align nat.last_digit_ne_zero Nat.getLast_digit_ne_zero
theorem mul_ofDigits (n : ℕ) {b : ℕ} {l : List ℕ} :
n * ofDigits b l = ofDigits b (l.map (n * ·)) := by
induction l with
| nil => rfl
| cons hd tl ih =>
rw [List.map_cons, ofDigits_cons, ofDigits_cons, ← ih]
ring
theorem ofDigits_add_ofDigits_eq_ofDigits_zipWith_of_length_eq {b : ℕ} {l1 l2 : List ℕ}
(h : l1.length = l2.length) :
ofDigits b l1 + ofDigits b l2 = ofDigits b (l1.zipWith (· + ·) l2) := by
induction l1 generalizing l2 with
| nil => simp_all [eq_comm, List.length_eq_zero, ofDigits]
| cons hd₁ tl₁ ih₁ =>
induction l2 generalizing tl₁ with
| nil => simp_all
| cons hd₂ tl₂ ih₂ =>
simp_all only [List.length_cons, succ_eq_add_one, ofDigits_cons, add_left_inj,
eq_comm, List.zipWith_cons_cons, add_eq]
rw [← ih₁ h.symm, mul_add]
ac_rfl
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
apply Nat.strongInductionOn m
intro n IH d hd
cases' n with n
· rw [digits_zero] at hd
cases hd
-- base b+2 expansion of 0 has no digits
rw [digits_add_two_add_one] at hd
cases hd
· exact n.succ.mod_lt (by simp)
-- Porting note: Previous code (single line) contained linarith.
-- . exact IH _ (Nat.div_lt_self (Nat.succ_pos _) (by linarith)) hd
· apply IH ((n + 1) / (b + 2))
· apply Nat.div_lt_self <;> omega
· assumption
#align nat.digits_lt_base' Nat.digits_lt_base'
theorem digits_lt_base {b m d : ℕ} (hb : 1 < b) (hd : d ∈ digits b m) : d < b := by
rcases b with (_ | _ | b) <;> try simp_all
exact digits_lt_base' hd
#align nat.digits_lt_base Nat.digits_lt_base
theorem ofDigits_lt_base_pow_length' {b : ℕ} {l : List ℕ} (hl : ∀ x ∈ l, x < b + 2) :
ofDigits (b + 2) l < (b + 2) ^ l.length := by
induction' l with hd tl IH
· simp [ofDigits]
· rw [ofDigits, List.length_cons, pow_succ]
have : (ofDigits (b + 2) tl + 1) * (b + 2) ≤ (b + 2) ^ tl.length * (b + 2) :=
mul_le_mul (IH fun x hx => hl _ (List.mem_cons_of_mem _ hx)) (by rfl) (by simp only [zero_le])
(Nat.zero_le _)
suffices ↑hd < b + 2 by linarith
exact hl hd (List.mem_cons_self _ _)
#align nat.of_digits_lt_base_pow_length' Nat.ofDigits_lt_base_pow_length'
theorem ofDigits_lt_base_pow_length {b : ℕ} {l : List ℕ} (hb : 1 < b) (hl : ∀ x ∈ l, x < b) :
ofDigits b l < b ^ l.length := by
rcases b with (_ | _ | b) <;> try simp_all
exact ofDigits_lt_base_pow_length' hl
#align nat.of_digits_lt_base_pow_length Nat.ofDigits_lt_base_pow_length
theorem lt_base_pow_length_digits' {b m : ℕ} : m < (b + 2) ^ (digits (b + 2) m).length := by
convert @ofDigits_lt_base_pow_length' b (digits (b + 2) m) fun _ => digits_lt_base'
rw [ofDigits_digits (b + 2) m]
#align nat.lt_base_pow_length_digits' Nat.lt_base_pow_length_digits'
theorem lt_base_pow_length_digits {b m : ℕ} (hb : 1 < b) : m < b ^ (digits b m).length := by
rcases b with (_ | _ | b) <;> try simp_all
exact lt_base_pow_length_digits'
#align nat.lt_base_pow_length_digits Nat.lt_base_pow_length_digits
theorem ofDigits_digits_append_digits {b m n : ℕ} :
ofDigits b (digits b n ++ digits b m) = n + b ^ (digits b n).length * m := by
rw [ofDigits_append, ofDigits_digits, ofDigits_digits]
#align nat.of_digits_digits_append_digits Nat.ofDigits_digits_append_digits
theorem digits_append_digits {b m n : ℕ} (hb : 0 < b) :
digits b n ++ digits b m = digits b (n + b ^ (digits b n).length * m) := by
rcases eq_or_lt_of_le (Nat.succ_le_of_lt hb) with (rfl | hb)
· simp [List.replicate_add]
rw [← ofDigits_digits_append_digits]
refine (digits_ofDigits b hb _ (fun l hl => ?_) (fun h_append => ?_)).symm
· rcases (List.mem_append.mp hl) with (h | h) <;> exact digits_lt_base hb h
· by_cases h : digits b m = []
· simp only [h, List.append_nil] at h_append ⊢
exact getLast_digit_ne_zero b <| digits_ne_nil_iff_ne_zero.mp h_append
· exact (List.getLast_append' _ _ h) ▸
(getLast_digit_ne_zero _ <| digits_ne_nil_iff_ne_zero.mp h)
theorem digits_len_le_digits_len_succ (b n : ℕ) :
(digits b n).length ≤ (digits b (n + 1)).length := by
rcases Decidable.eq_or_ne n 0 with (rfl | hn)
· simp
rcases le_or_lt b 1 with hb | hb
· interval_cases b <;> simp_arith [digits_zero_succ', hn]
simpa [digits_len, hb, hn] using log_mono_right (le_succ _)
#align nat.digits_len_le_digits_len_succ Nat.digits_len_le_digits_len_succ
theorem le_digits_len_le (b n m : ℕ) (h : n ≤ m) : (digits b n).length ≤ (digits b m).length :=
monotone_nat_of_le_succ (digits_len_le_digits_len_succ b) h
#align nat.le_digits_len_le Nat.le_digits_len_le
@[mono]
theorem ofDigits_monotone {p q : ℕ} (L : List ℕ) (h : p ≤ q) : ofDigits p L ≤ ofDigits q L := by
induction' L with _ _ hi
· rfl
· simp only [ofDigits, cast_id, add_le_add_iff_left]
exact Nat.mul_le_mul h hi
theorem sum_le_ofDigits {p : ℕ} (L : List ℕ) (h : 1 ≤ p) : L.sum ≤ ofDigits p L :=
(ofDigits_one L).symm ▸ ofDigits_monotone L h
theorem digit_sum_le (p n : ℕ) : List.sum (digits p n) ≤ n := by
induction' n with n
· exact digits_zero _ ▸ Nat.le_refl (List.sum [])
· induction' p with p
· rw [digits_zero_succ, List.sum_cons, List.sum_nil, add_zero]
· nth_rw 2 [← ofDigits_digits p.succ (n + 1)]
rw [← ofDigits_one <| digits p.succ n.succ]
exact ofDigits_monotone (digits p.succ n.succ) <| Nat.succ_pos p
theorem pow_length_le_mul_ofDigits {b : ℕ} {l : List ℕ} (hl : l ≠ []) (hl2 : l.getLast hl ≠ 0) :
(b + 2) ^ l.length ≤ (b + 2) * ofDigits (b + 2) l := by
rw [← List.dropLast_append_getLast hl]
simp only [List.length_append, List.length, zero_add, List.length_dropLast, ofDigits_append,
List.length_dropLast, ofDigits_singleton, add_comm (l.length - 1), pow_add, pow_one]
apply Nat.mul_le_mul_left
refine le_trans ?_ (Nat.le_add_left _ _)
have : 0 < l.getLast hl := by rwa [pos_iff_ne_zero]
convert Nat.mul_le_mul_left ((b + 2) ^ (l.length - 1)) this using 1
rw [Nat.mul_one]
#align nat.pow_length_le_mul_of_digits Nat.pow_length_le_mul_ofDigits
theorem base_pow_length_digits_le' (b m : ℕ) (hm : m ≠ 0) :
(b + 2) ^ (digits (b + 2) m).length ≤ (b + 2) * m := by
have : digits (b + 2) m ≠ [] := digits_ne_nil_iff_ne_zero.mpr hm
convert @pow_length_le_mul_ofDigits b (digits (b+2) m)
this (getLast_digit_ne_zero _ hm)
rw [ofDigits_digits]
#align nat.base_pow_length_digits_le' Nat.base_pow_length_digits_le'
theorem base_pow_length_digits_le (b m : ℕ) (hb : 1 < b) :
m ≠ 0 → b ^ (digits b m).length ≤ b * m := by
rcases b with (_ | _ | b) <;> try simp_all
exact base_pow_length_digits_le' b m
#align nat.base_pow_length_digits_le Nat.base_pow_length_digits_le
lemma ofDigits_div_eq_ofDigits_tail {p : ℕ} (hpos : 0 < p) (digits : List ℕ)
(w₁ : ∀ l ∈ digits, l < p) : ofDigits p digits / p = ofDigits p digits.tail := by
induction' digits with hd tl
· simp [ofDigits]
· refine Eq.trans (add_mul_div_left hd _ hpos) ?_
rw [Nat.div_eq_of_lt <| w₁ _ <| List.mem_cons_self _ _, zero_add]
rfl
lemma ofDigits_div_pow_eq_ofDigits_drop
{p : ℕ} (i : ℕ) (hpos : 0 < p) (digits : List ℕ) (w₁ : ∀ l ∈ digits, l < p) :
ofDigits p digits / p ^ i = ofDigits p (digits.drop i) := by
induction' i with i hi
· simp
· rw [Nat.pow_succ, ← Nat.div_div_eq_div_mul, hi, ofDigits_div_eq_ofDigits_tail hpos
(List.drop i digits) fun x hx ↦ w₁ x <| List.mem_of_mem_drop hx, ← List.drop_one,
List.drop_drop, add_comm]
lemma self_div_pow_eq_ofDigits_drop {p : ℕ} (i n : ℕ) (h : 2 ≤ p):
n / p ^ i = ofDigits p ((p.digits n).drop i) := by
convert ofDigits_div_pow_eq_ofDigits_drop i (zero_lt_of_lt h) (p.digits n)
(fun l hl ↦ digits_lt_base h hl)
exact (ofDigits_digits p n).symm
open Finset
theorem sub_one_mul_sum_div_pow_eq_sub_sum_digits {p : ℕ}
(L : List ℕ) {h_nonempty} (h_ne_zero : L.getLast h_nonempty ≠ 0) (h_lt : ∀ l ∈ L, l < p) :
(p - 1) * ∑ i ∈ range L.length, (ofDigits p L) / p ^ i.succ = (ofDigits p L) - L.sum := by
obtain h | rfl | h : 1 < p ∨ 1 = p ∨ p < 1 := trichotomous 1 p
· induction' L with hd tl ih
· simp [ofDigits]
· simp only [List.length_cons, List.sum_cons, self_div_pow_eq_ofDigits_drop _ _ h,
digits_ofDigits p h (hd :: tl) h_lt (fun _ => h_ne_zero)]
simp only [ofDigits]
rw [sum_range_succ, Nat.cast_id]
simp only [List.drop, List.drop_length]
obtain rfl | h' := em <| tl = []
· simp [ofDigits]
· have w₁' := fun l hl ↦ h_lt l <| List.mem_cons_of_mem hd hl
have w₂' := fun (h : tl ≠ []) ↦ (List.getLast_cons h) ▸ h_ne_zero
have ih := ih (w₂' h') w₁'
simp only [self_div_pow_eq_ofDigits_drop _ _ h, digits_ofDigits p h tl w₁' w₂',
← Nat.one_add] at ih
have := sum_singleton (fun x ↦ ofDigits p <| tl.drop x) tl.length
rw [← Ico_succ_singleton, List.drop_length, ofDigits] at this
have h₁ : 1 ≤ tl.length := List.length_pos.mpr h'
rw [← sum_range_add_sum_Ico _ <| h₁, ← add_zero (∑ x ∈ Ico _ _, ofDigits p (tl.drop x)),
← this, sum_Ico_consecutive _ h₁ <| (le_add_right tl.length 1),
← sum_Ico_add _ 0 tl.length 1,
Ico_zero_eq_range, mul_add, mul_add, ih, range_one, sum_singleton, List.drop, ofDigits,
mul_zero, add_zero, ← Nat.add_sub_assoc <| sum_le_ofDigits _ <| Nat.le_of_lt h]
nth_rw 2 [← one_mul <| ofDigits p tl]
rw [← add_mul, one_eq_succ_zero, Nat.sub_add_cancel <| zero_lt_of_lt h,
Nat.add_sub_add_left]
· simp [ofDigits_one]
· simp [lt_one_iff.mp h]
cases L
· rfl
· simp [ofDigits]
theorem sub_one_mul_sum_log_div_pow_eq_sub_sum_digits {p : ℕ} (n : ℕ) :
(p - 1) * ∑ i ∈ range (log p n).succ, n / p ^ i.succ = n - (p.digits n).sum := by
obtain h | rfl | h : 1 < p ∨ 1 = p ∨ p < 1 := trichotomous 1 p
· rcases eq_or_ne n 0 with rfl | hn
· simp
· convert sub_one_mul_sum_div_pow_eq_sub_sum_digits (p.digits n) (getLast_digit_ne_zero p hn) <|
(fun l a ↦ digits_lt_base h a)
· refine (digits_len p n h hn).symm
all_goals exact (ofDigits_digits p n).symm
· simp
· simp [lt_one_iff.mp h]
cases n
all_goals simp
theorem digits_two_eq_bits (n : ℕ) : digits 2 n = n.bits.map fun b => cond b 1 0 := by
induction' n using Nat.binaryRecFromOne with b n h ih
· simp
· rfl
rw [bits_append_bit _ _ fun hn => absurd hn h]
cases b
· rw [digits_def' one_lt_two]
· simpa [Nat.bit, Nat.bit0_val n]
· simpa [pos_iff_ne_zero, Nat.bit0_eq_zero]
· simpa [Nat.bit, Nat.bit1_val n, add_comm, digits_add 2 one_lt_two 1 n, Nat.add_mul_div_left]
#align nat.digits_two_eq_bits Nat.digits_two_eq_bits
-- This is really a theorem about polynomials.
| Mathlib/Data/Nat/Digits.lean | 639 | 645 | theorem dvd_ofDigits_sub_ofDigits {α : Type*} [CommRing α] {a b k : α} (h : k ∣ a - b)
(L : List ℕ) : k ∣ ofDigits a L - ofDigits b L := by |
induction' L with d L ih
· change k ∣ 0 - 0
simp
· simp only [ofDigits, add_sub_add_left_eq_sub]
exact dvd_mul_sub_mul h ih
|
import Mathlib.Analysis.Asymptotics.AsymptoticEquivalent
import Mathlib.Analysis.Normed.Group.Lemmas
import Mathlib.Analysis.NormedSpace.AddTorsor
import Mathlib.Analysis.NormedSpace.AffineIsometry
import Mathlib.Analysis.NormedSpace.OperatorNorm.NormedSpace
import Mathlib.Analysis.NormedSpace.RieszLemma
import Mathlib.Analysis.NormedSpace.Pointwise
import Mathlib.Topology.Algebra.Module.FiniteDimension
import Mathlib.Topology.Algebra.InfiniteSum.Module
import Mathlib.Topology.Instances.Matrix
#align_import analysis.normed_space.finite_dimension from "leanprover-community/mathlib"@"9425b6f8220e53b059f5a4904786c3c4b50fc057"
universe u v w x
noncomputable section
open Set FiniteDimensional TopologicalSpace Filter Asymptotics Classical Topology
NNReal Metric
section CompleteField
variable {𝕜 : Type u} [NontriviallyNormedField 𝕜] {E : Type v} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {F : Type w} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {F' : Type x}
[AddCommGroup F'] [Module 𝕜 F'] [TopologicalSpace F'] [TopologicalAddGroup F']
[ContinuousSMul 𝕜 F'] [CompleteSpace 𝕜]
theorem ContinuousLinearMap.continuous_det : Continuous fun f : E →L[𝕜] E => f.det := by
change Continuous fun f : E →L[𝕜] E => LinearMap.det (f : E →ₗ[𝕜] E)
-- Porting note: this could be easier with `det_cases`
by_cases h : ∃ s : Finset E, Nonempty (Basis (↥s) 𝕜 E)
· rcases h with ⟨s, ⟨b⟩⟩
haveI : FiniteDimensional 𝕜 E := FiniteDimensional.of_fintype_basis b
simp_rw [LinearMap.det_eq_det_toMatrix_of_finset b]
refine Continuous.matrix_det ?_
exact
((LinearMap.toMatrix b b).toLinearMap.comp
(ContinuousLinearMap.coeLM 𝕜)).continuous_of_finiteDimensional
· -- Porting note: was `unfold LinearMap.det`
rw [LinearMap.det_def]
simpa only [h, MonoidHom.one_apply, dif_neg, not_false_iff] using continuous_const
#align continuous_linear_map.continuous_det ContinuousLinearMap.continuous_det
irreducible_def lipschitzExtensionConstant (E' : Type*) [NormedAddCommGroup E'] [NormedSpace ℝ E']
[FiniteDimensional ℝ E'] : ℝ≥0 :=
let A := (Basis.ofVectorSpace ℝ E').equivFun.toContinuousLinearEquiv
max (‖A.symm.toContinuousLinearMap‖₊ * ‖A.toContinuousLinearMap‖₊) 1
#align lipschitz_extension_constant lipschitzExtensionConstant
theorem lipschitzExtensionConstant_pos (E' : Type*) [NormedAddCommGroup E'] [NormedSpace ℝ E']
[FiniteDimensional ℝ E'] : 0 < lipschitzExtensionConstant E' := by
rw [lipschitzExtensionConstant]
exact zero_lt_one.trans_le (le_max_right _ _)
#align lipschitz_extension_constant_pos lipschitzExtensionConstant_pos
theorem LipschitzOnWith.extend_finite_dimension {α : Type*} [PseudoMetricSpace α] {E' : Type*}
[NormedAddCommGroup E'] [NormedSpace ℝ E'] [FiniteDimensional ℝ E'] {s : Set α} {f : α → E'}
{K : ℝ≥0} (hf : LipschitzOnWith K f s) :
∃ g : α → E', LipschitzWith (lipschitzExtensionConstant E' * K) g ∧ EqOn f g s := by
let ι : Type _ := Basis.ofVectorSpaceIndex ℝ E'
let A := (Basis.ofVectorSpace ℝ E').equivFun.toContinuousLinearEquiv
have LA : LipschitzWith ‖A.toContinuousLinearMap‖₊ A := by apply A.lipschitz
have L : LipschitzOnWith (‖A.toContinuousLinearMap‖₊ * K) (A ∘ f) s :=
LA.comp_lipschitzOnWith hf
obtain ⟨g, hg, gs⟩ :
∃ g : α → ι → ℝ, LipschitzWith (‖A.toContinuousLinearMap‖₊ * K) g ∧ EqOn (A ∘ f) g s :=
L.extend_pi
refine ⟨A.symm ∘ g, ?_, ?_⟩
· have LAsymm : LipschitzWith ‖A.symm.toContinuousLinearMap‖₊ A.symm := by
apply A.symm.lipschitz
apply (LAsymm.comp hg).weaken
rw [lipschitzExtensionConstant, ← mul_assoc]
exact mul_le_mul' (le_max_left _ _) le_rfl
· intro x hx
have : A (f x) = g x := gs hx
simp only [(· ∘ ·), ← this, A.symm_apply_apply]
#align lipschitz_on_with.extend_finite_dimension LipschitzOnWith.extend_finite_dimension
theorem LinearMap.exists_antilipschitzWith [FiniteDimensional 𝕜 E] (f : E →ₗ[𝕜] F)
(hf : LinearMap.ker f = ⊥) : ∃ K > 0, AntilipschitzWith K f := by
cases subsingleton_or_nontrivial E
· exact ⟨1, zero_lt_one, AntilipschitzWith.of_subsingleton⟩
· rw [LinearMap.ker_eq_bot] at hf
let e : E ≃L[𝕜] LinearMap.range f := (LinearEquiv.ofInjective f hf).toContinuousLinearEquiv
exact ⟨_, e.nnnorm_symm_pos, e.antilipschitz⟩
#align linear_map.exists_antilipschitz_with LinearMap.exists_antilipschitzWith
open Function in
theorem LinearMap.injective_iff_antilipschitz [FiniteDimensional 𝕜 E] (f : E →ₗ[𝕜] F) :
Injective f ↔ ∃ K > 0, AntilipschitzWith K f := by
constructor
· rw [← LinearMap.ker_eq_bot]
exact f.exists_antilipschitzWith
· rintro ⟨K, -, H⟩
exact H.injective
open Function in
theorem ContinuousLinearMap.isOpen_injective [FiniteDimensional 𝕜 E] :
IsOpen { L : E →L[𝕜] F | Injective L } := by
rw [isOpen_iff_eventually]
rintro φ₀ hφ₀
rcases φ₀.injective_iff_antilipschitz.mp hφ₀ with ⟨K, K_pos, H⟩
have : ∀ᶠ φ in 𝓝 φ₀, ‖φ - φ₀‖₊ < K⁻¹ := eventually_nnnorm_sub_lt _ <| inv_pos_of_pos K_pos
filter_upwards [this] with φ hφ
apply φ.injective_iff_antilipschitz.mpr
exact ⟨(K⁻¹ - ‖φ - φ₀‖₊)⁻¹, inv_pos_of_pos (tsub_pos_of_lt hφ),
H.add_sub_lipschitzWith (φ - φ₀).lipschitz hφ⟩
protected theorem LinearIndependent.eventually {ι} [Finite ι] {f : ι → E}
(hf : LinearIndependent 𝕜 f) : ∀ᶠ g in 𝓝 f, LinearIndependent 𝕜 g := by
cases nonempty_fintype ι
simp only [Fintype.linearIndependent_iff'] at hf ⊢
rcases LinearMap.exists_antilipschitzWith _ hf with ⟨K, K0, hK⟩
have : Tendsto (fun g : ι → E => ∑ i, ‖g i - f i‖) (𝓝 f) (𝓝 <| ∑ i, ‖f i - f i‖) :=
tendsto_finset_sum _ fun i _ =>
Tendsto.norm <| ((continuous_apply i).tendsto _).sub tendsto_const_nhds
simp only [sub_self, norm_zero, Finset.sum_const_zero] at this
refine (this.eventually (gt_mem_nhds <| inv_pos.2 K0)).mono fun g hg => ?_
replace hg : ∑ i, ‖g i - f i‖₊ < K⁻¹ := by
rw [← NNReal.coe_lt_coe]
push_cast
exact hg
rw [LinearMap.ker_eq_bot]
refine (hK.add_sub_lipschitzWith (LipschitzWith.of_dist_le_mul fun v u => ?_) hg).injective
simp only [dist_eq_norm, LinearMap.lsum_apply, Pi.sub_apply, LinearMap.sum_apply,
LinearMap.comp_apply, LinearMap.proj_apply, LinearMap.smulRight_apply, LinearMap.id_apply, ←
Finset.sum_sub_distrib, ← smul_sub, ← sub_smul, NNReal.coe_sum, coe_nnnorm, Finset.sum_mul]
refine norm_sum_le_of_le _ fun i _ => ?_
rw [norm_smul, mul_comm]
gcongr
exact norm_le_pi_norm (v - u) i
#align linear_independent.eventually LinearIndependent.eventually
theorem isOpen_setOf_linearIndependent {ι : Type*} [Finite ι] :
IsOpen { f : ι → E | LinearIndependent 𝕜 f } :=
isOpen_iff_mem_nhds.2 fun _ => LinearIndependent.eventually
#align is_open_set_of_linear_independent isOpen_setOf_linearIndependent
theorem isOpen_setOf_nat_le_rank (n : ℕ) :
IsOpen { f : E →L[𝕜] F | ↑n ≤ (f : E →ₗ[𝕜] F).rank } := by
simp only [LinearMap.le_rank_iff_exists_linearIndependent_finset, setOf_exists, ← exists_prop]
refine isOpen_biUnion fun t _ => ?_
have : Continuous fun f : E →L[𝕜] F => fun x : (t : Set E) => f x :=
continuous_pi fun x => (ContinuousLinearMap.apply 𝕜 F (x : E)).continuous
exact isOpen_setOf_linearIndependent.preimage this
#align is_open_set_of_nat_le_rank isOpen_setOf_nat_le_rank
theorem Basis.opNNNorm_le {ι : Type*} [Fintype ι] (v : Basis ι 𝕜 E) {u : E →L[𝕜] F} (M : ℝ≥0)
(hu : ∀ i, ‖u (v i)‖₊ ≤ M) : ‖u‖₊ ≤ Fintype.card ι • ‖v.equivFunL.toContinuousLinearMap‖₊ * M :=
u.opNNNorm_le_bound _ fun e => by
set φ := v.equivFunL.toContinuousLinearMap
calc
‖u e‖₊ = ‖u (∑ i, v.equivFun e i • v i)‖₊ := by rw [v.sum_equivFun]
_ = ‖∑ i, v.equivFun e i • (u <| v i)‖₊ := by simp [map_sum, LinearMap.map_smul]
_ ≤ ∑ i, ‖v.equivFun e i • (u <| v i)‖₊ := nnnorm_sum_le _ _
_ = ∑ i, ‖v.equivFun e i‖₊ * ‖u (v i)‖₊ := by simp only [nnnorm_smul]
_ ≤ ∑ i, ‖v.equivFun e i‖₊ * M := by gcongr; apply hu
_ = (∑ i, ‖v.equivFun e i‖₊) * M := by rw [Finset.sum_mul]
_ ≤ Fintype.card ι • (‖φ‖₊ * ‖e‖₊) * M := by
gcongr
calc
∑ i, ‖v.equivFun e i‖₊ ≤ Fintype.card ι • ‖φ e‖₊ := Pi.sum_nnnorm_apply_le_nnnorm _
_ ≤ Fintype.card ι • (‖φ‖₊ * ‖e‖₊) := nsmul_le_nsmul_right (φ.le_opNNNorm e) _
_ = Fintype.card ι • ‖φ‖₊ * M * ‖e‖₊ := by simp only [smul_mul_assoc, mul_right_comm]
#align basis.op_nnnorm_le Basis.opNNNorm_le
@[deprecated (since := "2024-02-02")] alias Basis.op_nnnorm_le := Basis.opNNNorm_le
| Mathlib/Analysis/NormedSpace/FiniteDimension.lean | 317 | 320 | theorem Basis.opNorm_le {ι : Type*} [Fintype ι] (v : Basis ι 𝕜 E) {u : E →L[𝕜] F} {M : ℝ}
(hM : 0 ≤ M) (hu : ∀ i, ‖u (v i)‖ ≤ M) :
‖u‖ ≤ Fintype.card ι • ‖v.equivFunL.toContinuousLinearMap‖ * M := by |
simpa using NNReal.coe_le_coe.mpr (v.opNNNorm_le ⟨M, hM⟩ hu)
|
import Mathlib.Dynamics.Ergodic.MeasurePreserving
import Mathlib.MeasureTheory.Function.SimpleFunc
import Mathlib.MeasureTheory.Measure.MutuallySingular
import Mathlib.MeasureTheory.Measure.Count
import Mathlib.Topology.IndicatorConstPointwise
import Mathlib.MeasureTheory.Constructions.BorelSpace.Real
#align_import measure_theory.integral.lebesgue from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"
assert_not_exists NormedSpace
set_option autoImplicit true
noncomputable section
open Set hiding restrict restrict_apply
open Filter ENNReal
open Function (support)
open scoped Classical
open Topology NNReal ENNReal MeasureTheory
namespace MeasureTheory
local infixr:25 " →ₛ " => SimpleFunc
variable {α β γ δ : Type*}
section Lintegral
open SimpleFunc
variable {m : MeasurableSpace α} {μ ν : Measure α}
irreducible_def lintegral {_ : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) : ℝ≥0∞ :=
⨆ (g : α →ₛ ℝ≥0∞) (_ : ⇑g ≤ f), g.lintegral μ
#align measure_theory.lintegral MeasureTheory.lintegral
@[inherit_doc MeasureTheory.lintegral]
notation3 "∫⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => lintegral μ r
@[inherit_doc MeasureTheory.lintegral]
notation3 "∫⁻ "(...)", "r:60:(scoped f => lintegral volume f) => r
@[inherit_doc MeasureTheory.lintegral]
notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => lintegral (Measure.restrict μ s) r
@[inherit_doc MeasureTheory.lintegral]
notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => lintegral (Measure.restrict volume s) f) => r
theorem SimpleFunc.lintegral_eq_lintegral {m : MeasurableSpace α} (f : α →ₛ ℝ≥0∞) (μ : Measure α) :
∫⁻ a, f a ∂μ = f.lintegral μ := by
rw [MeasureTheory.lintegral]
exact le_antisymm (iSup₂_le fun g hg => lintegral_mono hg <| le_rfl)
(le_iSup₂_of_le f le_rfl le_rfl)
#align measure_theory.simple_func.lintegral_eq_lintegral MeasureTheory.SimpleFunc.lintegral_eq_lintegral
@[mono]
theorem lintegral_mono' {m : MeasurableSpace α} ⦃μ ν : Measure α⦄ (hμν : μ ≤ ν) ⦃f g : α → ℝ≥0∞⦄
(hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂ν := by
rw [lintegral, lintegral]
exact iSup_mono fun φ => iSup_mono' fun hφ => ⟨le_trans hφ hfg, lintegral_mono (le_refl φ) hμν⟩
#align measure_theory.lintegral_mono' MeasureTheory.lintegral_mono'
-- workaround for the known eta-reduction issue with `@[gcongr]`
@[gcongr] theorem lintegral_mono_fn' ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) (h2 : μ ≤ ν) :
lintegral μ f ≤ lintegral ν g :=
lintegral_mono' h2 hfg
theorem lintegral_mono ⦃f g : α → ℝ≥0∞⦄ (hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ :=
lintegral_mono' (le_refl μ) hfg
#align measure_theory.lintegral_mono MeasureTheory.lintegral_mono
-- workaround for the known eta-reduction issue with `@[gcongr]`
@[gcongr] theorem lintegral_mono_fn ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) :
lintegral μ f ≤ lintegral μ g :=
lintegral_mono hfg
theorem lintegral_mono_nnreal {f g : α → ℝ≥0} (h : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ :=
lintegral_mono fun a => ENNReal.coe_le_coe.2 (h a)
#align measure_theory.lintegral_mono_nnreal MeasureTheory.lintegral_mono_nnreal
theorem iSup_lintegral_measurable_le_eq_lintegral (f : α → ℝ≥0∞) :
⨆ (g : α → ℝ≥0∞) (_ : Measurable g) (_ : g ≤ f), ∫⁻ a, g a ∂μ = ∫⁻ a, f a ∂μ := by
apply le_antisymm
· exact iSup_le fun i => iSup_le fun _ => iSup_le fun h'i => lintegral_mono h'i
· rw [lintegral]
refine iSup₂_le fun i hi => le_iSup₂_of_le i i.measurable <| le_iSup_of_le hi ?_
exact le_of_eq (i.lintegral_eq_lintegral _).symm
#align measure_theory.supr_lintegral_measurable_le_eq_lintegral MeasureTheory.iSup_lintegral_measurable_le_eq_lintegral
theorem lintegral_mono_set {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞}
(hst : s ⊆ t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ :=
lintegral_mono' (Measure.restrict_mono hst (le_refl μ)) (le_refl f)
#align measure_theory.lintegral_mono_set MeasureTheory.lintegral_mono_set
theorem lintegral_mono_set' {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞}
(hst : s ≤ᵐ[μ] t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ :=
lintegral_mono' (Measure.restrict_mono' hst (le_refl μ)) (le_refl f)
#align measure_theory.lintegral_mono_set' MeasureTheory.lintegral_mono_set'
theorem monotone_lintegral {_ : MeasurableSpace α} (μ : Measure α) : Monotone (lintegral μ) :=
lintegral_mono
#align measure_theory.monotone_lintegral MeasureTheory.monotone_lintegral
@[simp]
theorem lintegral_const (c : ℝ≥0∞) : ∫⁻ _, c ∂μ = c * μ univ := by
rw [← SimpleFunc.const_lintegral, ← SimpleFunc.lintegral_eq_lintegral, SimpleFunc.coe_const]
rfl
#align measure_theory.lintegral_const MeasureTheory.lintegral_const
theorem lintegral_zero : ∫⁻ _ : α, 0 ∂μ = 0 := by simp
#align measure_theory.lintegral_zero MeasureTheory.lintegral_zero
theorem lintegral_zero_fun : lintegral μ (0 : α → ℝ≥0∞) = 0 :=
lintegral_zero
#align measure_theory.lintegral_zero_fun MeasureTheory.lintegral_zero_fun
-- @[simp] -- Porting note (#10618): simp can prove this
theorem lintegral_one : ∫⁻ _, (1 : ℝ≥0∞) ∂μ = μ univ := by rw [lintegral_const, one_mul]
#align measure_theory.lintegral_one MeasureTheory.lintegral_one
theorem set_lintegral_const (s : Set α) (c : ℝ≥0∞) : ∫⁻ _ in s, c ∂μ = c * μ s := by
rw [lintegral_const, Measure.restrict_apply_univ]
#align measure_theory.set_lintegral_const MeasureTheory.set_lintegral_const
theorem set_lintegral_one (s) : ∫⁻ _ in s, 1 ∂μ = μ s := by rw [set_lintegral_const, one_mul]
#align measure_theory.set_lintegral_one MeasureTheory.set_lintegral_one
theorem set_lintegral_const_lt_top [IsFiniteMeasure μ] (s : Set α) {c : ℝ≥0∞} (hc : c ≠ ∞) :
∫⁻ _ in s, c ∂μ < ∞ := by
rw [lintegral_const]
exact ENNReal.mul_lt_top hc (measure_ne_top (μ.restrict s) univ)
#align measure_theory.set_lintegral_const_lt_top MeasureTheory.set_lintegral_const_lt_top
theorem lintegral_const_lt_top [IsFiniteMeasure μ] {c : ℝ≥0∞} (hc : c ≠ ∞) : ∫⁻ _, c ∂μ < ∞ := by
simpa only [Measure.restrict_univ] using set_lintegral_const_lt_top (univ : Set α) hc
#align measure_theory.lintegral_const_lt_top MeasureTheory.lintegral_const_lt_top
section
variable (μ)
theorem exists_measurable_le_lintegral_eq (f : α → ℝ≥0∞) :
∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := by
rcases eq_or_ne (∫⁻ a, f a ∂μ) 0 with h₀ | h₀
· exact ⟨0, measurable_zero, zero_le f, h₀.trans lintegral_zero.symm⟩
rcases exists_seq_strictMono_tendsto' h₀.bot_lt with ⟨L, _, hLf, hL_tendsto⟩
have : ∀ n, ∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ L n < ∫⁻ a, g a ∂μ := by
intro n
simpa only [← iSup_lintegral_measurable_le_eq_lintegral f, lt_iSup_iff, exists_prop] using
(hLf n).2
choose g hgm hgf hLg using this
refine
⟨fun x => ⨆ n, g n x, measurable_iSup hgm, fun x => iSup_le fun n => hgf n x, le_antisymm ?_ ?_⟩
· refine le_of_tendsto' hL_tendsto fun n => (hLg n).le.trans <| lintegral_mono fun x => ?_
exact le_iSup (fun n => g n x) n
· exact lintegral_mono fun x => iSup_le fun n => hgf n x
#align measure_theory.exists_measurable_le_lintegral_eq MeasureTheory.exists_measurable_le_lintegral_eq
end
| Mathlib/MeasureTheory/Integral/Lebesgue.lean | 199 | 220 | theorem lintegral_eq_nnreal {m : MeasurableSpace α} (f : α → ℝ≥0∞) (μ : Measure α) :
∫⁻ a, f a ∂μ =
⨆ (φ : α →ₛ ℝ≥0) (_ : ∀ x, ↑(φ x) ≤ f x), (φ.map ((↑) : ℝ≥0 → ℝ≥0∞)).lintegral μ := by |
rw [lintegral]
refine
le_antisymm (iSup₂_le fun φ hφ => ?_) (iSup_mono' fun φ => ⟨φ.map ((↑) : ℝ≥0 → ℝ≥0∞), le_rfl⟩)
by_cases h : ∀ᵐ a ∂μ, φ a ≠ ∞
· let ψ := φ.map ENNReal.toNNReal
replace h : ψ.map ((↑) : ℝ≥0 → ℝ≥0∞) =ᵐ[μ] φ := h.mono fun a => ENNReal.coe_toNNReal
have : ∀ x, ↑(ψ x) ≤ f x := fun x => le_trans ENNReal.coe_toNNReal_le_self (hφ x)
exact
le_iSup_of_le (φ.map ENNReal.toNNReal) (le_iSup_of_le this (ge_of_eq <| lintegral_congr h))
· have h_meas : μ (φ ⁻¹' {∞}) ≠ 0 := mt measure_zero_iff_ae_nmem.1 h
refine le_trans le_top (ge_of_eq <| (iSup_eq_top _).2 fun b hb => ?_)
obtain ⟨n, hn⟩ : ∃ n : ℕ, b < n * μ (φ ⁻¹' {∞}) := exists_nat_mul_gt h_meas (ne_of_lt hb)
use (const α (n : ℝ≥0)).restrict (φ ⁻¹' {∞})
simp only [lt_iSup_iff, exists_prop, coe_restrict, φ.measurableSet_preimage, coe_const,
ENNReal.coe_indicator, map_coe_ennreal_restrict, SimpleFunc.map_const, ENNReal.coe_natCast,
restrict_const_lintegral]
refine ⟨indicator_le fun x hx => le_trans ?_ (hφ _), hn⟩
simp only [mem_preimage, mem_singleton_iff] at hx
simp only [hx, le_top]
|
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
#align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
open Filter Metric Set
open scoped ComplexConjugate Real Topology
namespace Complex
variable {a x z : ℂ}
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
#align complex.arg Complex.arg
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
#align complex.sin_arg Complex.sin_arg
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
#align complex.cos_arg Complex.cos_arg
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
set_option linter.uppercaseLean3 false in
#align complex.abs_mul_cos_add_sin_mul_I Complex.abs_mul_cos_add_sin_mul_I
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine ⟨fun hz => ⟨arg z, ?_⟩, ?_⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
#align complex.abs_eq_one_iff Complex.abs_eq_one_iff
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
set_option linter.uppercaseLean3 false in
#align complex.range_exp_mul_I Complex.range_exp_mul_I
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [re_ofReal_mul, im_ofReal_mul, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left₀ _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine Real.cos_pos_of_mem_Ioo ⟨?_, ?_⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel_right] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
set_option linter.uppercaseLean3 false in
#align complex.arg_mul_cos_add_sin_mul_I Complex.arg_mul_cos_add_sin_mul_I
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
set_option linter.uppercaseLean3 false in
#align complex.arg_cos_add_sin_mul_I Complex.arg_cos_add_sin_mul_I
lemma arg_exp_mul_I (θ : ℝ) :
arg (exp (θ * I)) = toIocMod (mul_pos two_pos Real.pi_pos) (-π) θ := by
convert arg_cos_add_sin_mul_I (θ := toIocMod (mul_pos two_pos Real.pi_pos) (-π) θ) _ using 2
· rw [← exp_mul_I, eq_sub_of_add_eq $ toIocMod_add_toIocDiv_zsmul _ _ θ, ofReal_sub,
ofReal_zsmul, ofReal_mul, ofReal_ofNat, exp_mul_I_periodic.sub_zsmul_eq]
· convert toIocMod_mem_Ioc _ _ _
ring
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
#align complex.arg_zero Complex.arg_zero
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
#align complex.ext_abs_arg Complex.ext_abs_arg
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
#align complex.ext_abs_arg_iff Complex.ext_abs_arg_iff
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz)
· simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
#align complex.arg_mem_Ioc Complex.arg_mem_Ioc
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
#align complex.range_arg Complex.range_arg
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
#align complex.arg_le_pi Complex.arg_le_pi
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
#align complex.neg_pi_lt_arg Complex.neg_pi_lt_arg
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
#align complex.abs_arg_le_pi Complex.abs_arg_le_pi
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
#align complex.arg_nonneg_iff Complex.arg_nonneg_iff
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
#align complex.arg_neg_iff Complex.arg_neg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
#align complex.arg_real_mul Complex.arg_real_mul
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel₀ _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
#align complex.arg_eq_arg_iff Complex.arg_eq_arg_iff
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
#align complex.arg_one Complex.arg_one
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
#align complex.arg_neg_one Complex.arg_neg_one
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
set_option linter.uppercaseLean3 false in
#align complex.arg_I Complex.arg_I
@[simp]
| Mathlib/Analysis/SpecialFunctions/Complex/Arg.lean | 222 | 222 | theorem arg_neg_I : arg (-I) = -(π / 2) := by | simp [arg, le_refl]
|
import Mathlib.Data.Finset.Prod
import Mathlib.Data.Set.Finite
#align_import data.finset.n_ary from "leanprover-community/mathlib"@"eba7871095e834365616b5e43c8c7bb0b37058d0"
open Function Set
variable {α α' β β' γ γ' δ δ' ε ε' ζ ζ' ν : Type*}
namespace Finset
variable [DecidableEq α'] [DecidableEq β'] [DecidableEq γ] [DecidableEq γ'] [DecidableEq δ]
[DecidableEq δ'] [DecidableEq ε] [DecidableEq ε'] {f f' : α → β → γ} {g g' : α → β → γ → δ}
{s s' : Finset α} {t t' : Finset β} {u u' : Finset γ} {a a' : α} {b b' : β} {c : γ}
def image₂ (f : α → β → γ) (s : Finset α) (t : Finset β) : Finset γ :=
(s ×ˢ t).image <| uncurry f
#align finset.image₂ Finset.image₂
@[simp]
theorem mem_image₂ : c ∈ image₂ f s t ↔ ∃ a ∈ s, ∃ b ∈ t, f a b = c := by
simp [image₂, and_assoc]
#align finset.mem_image₂ Finset.mem_image₂
@[simp, norm_cast]
theorem coe_image₂ (f : α → β → γ) (s : Finset α) (t : Finset β) :
(image₂ f s t : Set γ) = Set.image2 f s t :=
Set.ext fun _ => mem_image₂
#align finset.coe_image₂ Finset.coe_image₂
theorem card_image₂_le (f : α → β → γ) (s : Finset α) (t : Finset β) :
(image₂ f s t).card ≤ s.card * t.card :=
card_image_le.trans_eq <| card_product _ _
#align finset.card_image₂_le Finset.card_image₂_le
theorem card_image₂_iff :
(image₂ f s t).card = s.card * t.card ↔ (s ×ˢ t : Set (α × β)).InjOn fun x => f x.1 x.2 := by
rw [← card_product, ← coe_product]
exact card_image_iff
#align finset.card_image₂_iff Finset.card_image₂_iff
theorem card_image₂ (hf : Injective2 f) (s : Finset α) (t : Finset β) :
(image₂ f s t).card = s.card * t.card :=
(card_image_of_injective _ hf.uncurry).trans <| card_product _ _
#align finset.card_image₂ Finset.card_image₂
theorem mem_image₂_of_mem (ha : a ∈ s) (hb : b ∈ t) : f a b ∈ image₂ f s t :=
mem_image₂.2 ⟨a, ha, b, hb, rfl⟩
#align finset.mem_image₂_of_mem Finset.mem_image₂_of_mem
theorem mem_image₂_iff (hf : Injective2 f) : f a b ∈ image₂ f s t ↔ a ∈ s ∧ b ∈ t := by
rw [← mem_coe, coe_image₂, mem_image2_iff hf, mem_coe, mem_coe]
#align finset.mem_image₂_iff Finset.mem_image₂_iff
theorem image₂_subset (hs : s ⊆ s') (ht : t ⊆ t') : image₂ f s t ⊆ image₂ f s' t' := by
rw [← coe_subset, coe_image₂, coe_image₂]
exact image2_subset hs ht
#align finset.image₂_subset Finset.image₂_subset
theorem image₂_subset_left (ht : t ⊆ t') : image₂ f s t ⊆ image₂ f s t' :=
image₂_subset Subset.rfl ht
#align finset.image₂_subset_left Finset.image₂_subset_left
theorem image₂_subset_right (hs : s ⊆ s') : image₂ f s t ⊆ image₂ f s' t :=
image₂_subset hs Subset.rfl
#align finset.image₂_subset_right Finset.image₂_subset_right
theorem image_subset_image₂_left (hb : b ∈ t) : s.image (fun a => f a b) ⊆ image₂ f s t :=
image_subset_iff.2 fun _ ha => mem_image₂_of_mem ha hb
#align finset.image_subset_image₂_left Finset.image_subset_image₂_left
theorem image_subset_image₂_right (ha : a ∈ s) : t.image (fun b => f a b) ⊆ image₂ f s t :=
image_subset_iff.2 fun _ => mem_image₂_of_mem ha
#align finset.image_subset_image₂_right Finset.image_subset_image₂_right
theorem forall_image₂_iff {p : γ → Prop} :
(∀ z ∈ image₂ f s t, p z) ↔ ∀ x ∈ s, ∀ y ∈ t, p (f x y) := by
simp_rw [← mem_coe, coe_image₂, forall_image2_iff]
#align finset.forall_image₂_iff Finset.forall_image₂_iff
@[simp]
theorem image₂_subset_iff : image₂ f s t ⊆ u ↔ ∀ x ∈ s, ∀ y ∈ t, f x y ∈ u :=
forall_image₂_iff
#align finset.image₂_subset_iff Finset.image₂_subset_iff
theorem image₂_subset_iff_left : image₂ f s t ⊆ u ↔ ∀ a ∈ s, (t.image fun b => f a b) ⊆ u := by
simp_rw [image₂_subset_iff, image_subset_iff]
#align finset.image₂_subset_iff_left Finset.image₂_subset_iff_left
theorem image₂_subset_iff_right : image₂ f s t ⊆ u ↔ ∀ b ∈ t, (s.image fun a => f a b) ⊆ u := by
simp_rw [image₂_subset_iff, image_subset_iff, @forall₂_swap α]
#align finset.image₂_subset_iff_right Finset.image₂_subset_iff_right
@[simp, aesop safe apply (rule_sets := [finsetNonempty])]
theorem image₂_nonempty_iff : (image₂ f s t).Nonempty ↔ s.Nonempty ∧ t.Nonempty := by
rw [← coe_nonempty, coe_image₂]
exact image2_nonempty_iff
#align finset.image₂_nonempty_iff Finset.image₂_nonempty_iff
theorem Nonempty.image₂ (hs : s.Nonempty) (ht : t.Nonempty) : (image₂ f s t).Nonempty :=
image₂_nonempty_iff.2 ⟨hs, ht⟩
#align finset.nonempty.image₂ Finset.Nonempty.image₂
theorem Nonempty.of_image₂_left (h : (s.image₂ f t).Nonempty) : s.Nonempty :=
(image₂_nonempty_iff.1 h).1
#align finset.nonempty.of_image₂_left Finset.Nonempty.of_image₂_left
theorem Nonempty.of_image₂_right (h : (s.image₂ f t).Nonempty) : t.Nonempty :=
(image₂_nonempty_iff.1 h).2
#align finset.nonempty.of_image₂_right Finset.Nonempty.of_image₂_right
@[simp]
theorem image₂_empty_left : image₂ f ∅ t = ∅ :=
coe_injective <| by simp
#align finset.image₂_empty_left Finset.image₂_empty_left
@[simp]
theorem image₂_empty_right : image₂ f s ∅ = ∅ :=
coe_injective <| by simp
#align finset.image₂_empty_right Finset.image₂_empty_right
@[simp]
| Mathlib/Data/Finset/NAry.lean | 145 | 146 | theorem image₂_eq_empty_iff : image₂ f s t = ∅ ↔ s = ∅ ∨ t = ∅ := by |
simp_rw [← not_nonempty_iff_eq_empty, image₂_nonempty_iff, not_and_or]
|
import Mathlib.Algebra.BigOperators.Intervals
import Mathlib.Algebra.BigOperators.Ring.List
import Mathlib.Data.Int.ModEq
import Mathlib.Data.Nat.Bits
import Mathlib.Data.Nat.Log
import Mathlib.Data.List.Indexes
import Mathlib.Data.List.Palindrome
import Mathlib.Tactic.IntervalCases
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring
#align_import data.nat.digits from "leanprover-community/mathlib"@"369525b73f229ccd76a6ec0e0e0bf2be57599768"
namespace Nat
variable {n : ℕ}
def digitsAux0 : ℕ → List ℕ
| 0 => []
| n + 1 => [n + 1]
#align nat.digits_aux_0 Nat.digitsAux0
def digitsAux1 (n : ℕ) : List ℕ :=
List.replicate n 1
#align nat.digits_aux_1 Nat.digitsAux1
def digitsAux (b : ℕ) (h : 2 ≤ b) : ℕ → List ℕ
| 0 => []
| n + 1 =>
((n + 1) % b) :: digitsAux b h ((n + 1) / b)
decreasing_by exact Nat.div_lt_self (Nat.succ_pos _) h
#align nat.digits_aux Nat.digitsAux
@[simp]
theorem digitsAux_zero (b : ℕ) (h : 2 ≤ b) : digitsAux b h 0 = [] := by rw [digitsAux]
#align nat.digits_aux_zero Nat.digitsAux_zero
theorem digitsAux_def (b : ℕ) (h : 2 ≤ b) (n : ℕ) (w : 0 < n) :
digitsAux b h n = (n % b) :: digitsAux b h (n / b) := by
cases n
· cases w
· rw [digitsAux]
#align nat.digits_aux_def Nat.digitsAux_def
def digits : ℕ → ℕ → List ℕ
| 0 => digitsAux0
| 1 => digitsAux1
| b + 2 => digitsAux (b + 2) (by norm_num)
#align nat.digits Nat.digits
@[simp]
theorem digits_zero (b : ℕ) : digits b 0 = [] := by
rcases b with (_ | ⟨_ | ⟨_⟩⟩) <;> simp [digits, digitsAux0, digitsAux1]
#align nat.digits_zero Nat.digits_zero
-- @[simp] -- Porting note (#10618): simp can prove this
theorem digits_zero_zero : digits 0 0 = [] :=
rfl
#align nat.digits_zero_zero Nat.digits_zero_zero
@[simp]
theorem digits_zero_succ (n : ℕ) : digits 0 n.succ = [n + 1] :=
rfl
#align nat.digits_zero_succ Nat.digits_zero_succ
theorem digits_zero_succ' : ∀ {n : ℕ}, n ≠ 0 → digits 0 n = [n]
| 0, h => (h rfl).elim
| _ + 1, _ => rfl
#align nat.digits_zero_succ' Nat.digits_zero_succ'
@[simp]
theorem digits_one (n : ℕ) : digits 1 n = List.replicate n 1 :=
rfl
#align nat.digits_one Nat.digits_one
-- @[simp] -- Porting note (#10685): dsimp can prove this
theorem digits_one_succ (n : ℕ) : digits 1 (n + 1) = 1 :: digits 1 n :=
rfl
#align nat.digits_one_succ Nat.digits_one_succ
theorem digits_add_two_add_one (b n : ℕ) :
digits (b + 2) (n + 1) = ((n + 1) % (b + 2)) :: digits (b + 2) ((n + 1) / (b + 2)) := by
simp [digits, digitsAux_def]
#align nat.digits_add_two_add_one Nat.digits_add_two_add_one
@[simp]
lemma digits_of_two_le_of_pos {b : ℕ} (hb : 2 ≤ b) (hn : 0 < n) :
Nat.digits b n = n % b :: Nat.digits b (n / b) := by
rw [Nat.eq_add_of_sub_eq hb rfl, Nat.eq_add_of_sub_eq hn rfl, Nat.digits_add_two_add_one]
theorem digits_def' :
∀ {b : ℕ} (_ : 1 < b) {n : ℕ} (_ : 0 < n), digits b n = (n % b) :: digits b (n / b)
| 0, h => absurd h (by decide)
| 1, h => absurd h (by decide)
| b + 2, _ => digitsAux_def _ (by simp) _
#align nat.digits_def' Nat.digits_def'
@[simp]
theorem digits_of_lt (b x : ℕ) (hx : x ≠ 0) (hxb : x < b) : digits b x = [x] := by
rcases exists_eq_succ_of_ne_zero hx with ⟨x, rfl⟩
rcases Nat.exists_eq_add_of_le' ((Nat.le_add_left 1 x).trans_lt hxb) with ⟨b, rfl⟩
rw [digits_add_two_add_one, div_eq_of_lt hxb, digits_zero, mod_eq_of_lt hxb]
#align nat.digits_of_lt Nat.digits_of_lt
theorem digits_add (b : ℕ) (h : 1 < b) (x y : ℕ) (hxb : x < b) (hxy : x ≠ 0 ∨ y ≠ 0) :
digits b (x + b * y) = x :: digits b y := by
rcases Nat.exists_eq_add_of_le' h with ⟨b, rfl : _ = _ + 2⟩
cases y
· simp [hxb, hxy.resolve_right (absurd rfl)]
dsimp [digits]
rw [digitsAux_def]
· congr
· simp [Nat.add_mod, mod_eq_of_lt hxb]
· simp [add_mul_div_left, div_eq_of_lt hxb]
· apply Nat.succ_pos
#align nat.digits_add Nat.digits_add
-- If we had a function converting a list into a polynomial,
-- and appropriate lemmas about that function,
-- we could rewrite this in terms of that.
def ofDigits {α : Type*} [Semiring α] (b : α) : List ℕ → α
| [] => 0
| h :: t => h + b * ofDigits b t
#align nat.of_digits Nat.ofDigits
theorem ofDigits_eq_foldr {α : Type*} [Semiring α] (b : α) (L : List ℕ) :
ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L := by
induction' L with d L ih
· rfl
· dsimp [ofDigits]
rw [ih]
#align nat.of_digits_eq_foldr Nat.ofDigits_eq_foldr
theorem ofDigits_eq_sum_map_with_index_aux (b : ℕ) (l : List ℕ) :
((List.range l.length).zipWith ((fun i a : ℕ => a * b ^ (i + 1))) l).sum =
b * ((List.range l.length).zipWith (fun i a => a * b ^ i) l).sum := by
suffices
(List.range l.length).zipWith (fun i a : ℕ => a * b ^ (i + 1)) l =
(List.range l.length).zipWith (fun i a => b * (a * b ^ i)) l
by simp [this]
congr; ext; simp [pow_succ]; ring
#align nat.of_digits_eq_sum_map_with_index_aux Nat.ofDigits_eq_sum_map_with_index_aux
theorem ofDigits_eq_sum_mapIdx (b : ℕ) (L : List ℕ) :
ofDigits b L = (L.mapIdx fun i a => a * b ^ i).sum := by
rw [List.mapIdx_eq_enum_map, List.enum_eq_zip_range, List.map_uncurry_zip_eq_zipWith,
ofDigits_eq_foldr]
induction' L with hd tl hl
· simp
· simpa [List.range_succ_eq_map, List.zipWith_map_left, ofDigits_eq_sum_map_with_index_aux] using
Or.inl hl
#align nat.of_digits_eq_sum_map_with_index Nat.ofDigits_eq_sum_mapIdx
@[simp]
theorem ofDigits_nil {b : ℕ} : ofDigits b [] = 0 := rfl
@[simp]
theorem ofDigits_singleton {b n : ℕ} : ofDigits b [n] = n := by simp [ofDigits]
#align nat.of_digits_singleton Nat.ofDigits_singleton
@[simp]
theorem ofDigits_one_cons {α : Type*} [Semiring α] (h : ℕ) (L : List ℕ) :
ofDigits (1 : α) (h :: L) = h + ofDigits 1 L := by simp [ofDigits]
#align nat.of_digits_one_cons Nat.ofDigits_one_cons
theorem ofDigits_cons {b hd} {tl : List ℕ} :
ofDigits b (hd :: tl) = hd + b * ofDigits b tl := rfl
theorem ofDigits_append {b : ℕ} {l1 l2 : List ℕ} :
ofDigits b (l1 ++ l2) = ofDigits b l1 + b ^ l1.length * ofDigits b l2 := by
induction' l1 with hd tl IH
· simp [ofDigits]
· rw [ofDigits, List.cons_append, ofDigits, IH, List.length_cons, pow_succ']
ring
#align nat.of_digits_append Nat.ofDigits_append
@[norm_cast]
theorem coe_ofDigits (α : Type*) [Semiring α] (b : ℕ) (L : List ℕ) :
((ofDigits b L : ℕ) : α) = ofDigits (b : α) L := by
induction' L with d L ih
· simp [ofDigits]
· dsimp [ofDigits]; push_cast; rw [ih]
#align nat.coe_of_digits Nat.coe_ofDigits
@[norm_cast]
theorem coe_int_ofDigits (b : ℕ) (L : List ℕ) : ((ofDigits b L : ℕ) : ℤ) = ofDigits (b : ℤ) L := by
induction' L with d L _
· rfl
· dsimp [ofDigits]; push_cast; simp only
#align nat.coe_int_of_digits Nat.coe_int_ofDigits
theorem digits_zero_of_eq_zero {b : ℕ} (h : b ≠ 0) :
∀ {L : List ℕ} (_ : ofDigits b L = 0), ∀ l ∈ L, l = 0
| _ :: _, h0, _, List.Mem.head .. => Nat.eq_zero_of_add_eq_zero_right h0
| _ :: _, h0, _, List.Mem.tail _ hL =>
digits_zero_of_eq_zero h (mul_right_injective₀ h (Nat.eq_zero_of_add_eq_zero_left h0)) _ hL
#align nat.digits_zero_of_eq_zero Nat.digits_zero_of_eq_zero
theorem digits_ofDigits (b : ℕ) (h : 1 < b) (L : List ℕ) (w₁ : ∀ l ∈ L, l < b)
(w₂ : ∀ h : L ≠ [], L.getLast h ≠ 0) : digits b (ofDigits b L) = L := by
induction' L with d L ih
· dsimp [ofDigits]
simp
· dsimp [ofDigits]
replace w₂ := w₂ (by simp)
rw [digits_add b h]
· rw [ih]
· intro l m
apply w₁
exact List.mem_cons_of_mem _ m
· intro h
rw [List.getLast_cons h] at w₂
convert w₂
· exact w₁ d (List.mem_cons_self _ _)
· by_cases h' : L = []
· rcases h' with rfl
left
simpa using w₂
· right
contrapose! w₂
refine digits_zero_of_eq_zero h.ne_bot w₂ _ ?_
rw [List.getLast_cons h']
exact List.getLast_mem h'
#align nat.digits_of_digits Nat.digits_ofDigits
| Mathlib/Data/Nat/Digits.lean | 267 | 287 | theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by |
cases' b with b
· cases' n with n
· rfl
· change ofDigits 0 [n + 1] = n + 1
dsimp [ofDigits]
· cases' b with b
· induction' n with n ih
· rfl
· rw [Nat.zero_add] at ih ⊢
simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
· apply Nat.strongInductionOn n _
clear n
intro n h
cases n
· rw [digits_zero]
rfl
· simp only [Nat.succ_eq_add_one, digits_add_two_add_one]
dsimp [ofDigits]
rw [h _ (Nat.div_lt_self' _ b)]
rw [Nat.mod_add_div]
|
import Mathlib.Analysis.SpecialFunctions.Log.Base
import Mathlib.MeasureTheory.Measure.MeasureSpaceDef
#align_import measure_theory.measure.doubling from "leanprover-community/mathlib"@"5f6e827d81dfbeb6151d7016586ceeb0099b9655"
noncomputable section
open Set Filter Metric MeasureTheory TopologicalSpace ENNReal NNReal Topology
class IsUnifLocDoublingMeasure {α : Type*} [MetricSpace α] [MeasurableSpace α]
(μ : Measure α) : Prop where
exists_measure_closedBall_le_mul'' :
∃ C : ℝ≥0, ∀ᶠ ε in 𝓝[>] 0, ∀ x, μ (closedBall x (2 * ε)) ≤ C * μ (closedBall x ε)
#align is_unif_loc_doubling_measure IsUnifLocDoublingMeasure
namespace IsUnifLocDoublingMeasure
variable {α : Type*} [MetricSpace α] [MeasurableSpace α] (μ : Measure α)
[IsUnifLocDoublingMeasure μ]
-- Porting note: added for missing infer kinds
theorem exists_measure_closedBall_le_mul :
∃ C : ℝ≥0, ∀ᶠ ε in 𝓝[>] 0, ∀ x, μ (closedBall x (2 * ε)) ≤ C * μ (closedBall x ε) :=
exists_measure_closedBall_le_mul''
def doublingConstant : ℝ≥0 :=
Classical.choose <| exists_measure_closedBall_le_mul μ
#align is_unif_loc_doubling_measure.doubling_constant IsUnifLocDoublingMeasure.doublingConstant
theorem exists_measure_closedBall_le_mul' :
∀ᶠ ε in 𝓝[>] 0, ∀ x, μ (closedBall x (2 * ε)) ≤ doublingConstant μ * μ (closedBall x ε) :=
Classical.choose_spec <| exists_measure_closedBall_le_mul μ
#align is_unif_loc_doubling_measure.exists_measure_closed_ball_le_mul' IsUnifLocDoublingMeasure.exists_measure_closedBall_le_mul'
theorem exists_eventually_forall_measure_closedBall_le_mul (K : ℝ) :
∃ C : ℝ≥0, ∀ᶠ ε in 𝓝[>] 0, ∀ x, ∀ t ≤ K, μ (closedBall x (t * ε)) ≤ C * μ (closedBall x ε) := by
let C := doublingConstant μ
have hμ :
∀ n : ℕ, ∀ᶠ ε in 𝓝[>] 0, ∀ x,
μ (closedBall x ((2 : ℝ) ^ n * ε)) ≤ ↑(C ^ n) * μ (closedBall x ε) := by
intro n
induction' n with n ih
· simp
replace ih := eventually_nhdsWithin_pos_mul_left (two_pos : 0 < (2 : ℝ)) ih
refine (ih.and (exists_measure_closedBall_le_mul' μ)).mono fun ε hε x => ?_
calc
μ (closedBall x ((2 : ℝ) ^ (n + 1) * ε)) = μ (closedBall x ((2 : ℝ) ^ n * (2 * ε))) := by
rw [pow_succ, mul_assoc]
_ ≤ ↑(C ^ n) * μ (closedBall x (2 * ε)) := hε.1 x
_ ≤ ↑(C ^ n) * (C * μ (closedBall x ε)) := by gcongr; exact hε.2 x
_ = ↑(C ^ (n + 1)) * μ (closedBall x ε) := by rw [← mul_assoc, pow_succ, ENNReal.coe_mul]
rcases lt_or_le K 1 with (hK | hK)
· refine ⟨1, ?_⟩
simp only [ENNReal.coe_one, one_mul]
refine eventually_mem_nhdsWithin.mono fun ε hε x t ht ↦ ?_
gcongr
nlinarith [mem_Ioi.mp hε]
· use C ^ ⌈Real.logb 2 K⌉₊
filter_upwards [hμ ⌈Real.logb 2 K⌉₊, eventually_mem_nhdsWithin] with ε hε hε₀ x t ht
refine le_trans ?_ (hε x)
gcongr
· exact (mem_Ioi.mp hε₀).le
· refine ht.trans ?_
rw [← Real.rpow_natCast, ← Real.logb_le_iff_le_rpow]
exacts [Nat.le_ceil _, by norm_num, by linarith]
#align is_unif_loc_doubling_measure.exists_eventually_forall_measure_closed_ball_le_mul IsUnifLocDoublingMeasure.exists_eventually_forall_measure_closedBall_le_mul
def scalingConstantOf (K : ℝ) : ℝ≥0 :=
max (Classical.choose <| exists_eventually_forall_measure_closedBall_le_mul μ K) 1
#align is_unif_loc_doubling_measure.scaling_constant_of IsUnifLocDoublingMeasure.scalingConstantOf
@[simp]
theorem one_le_scalingConstantOf (K : ℝ) : 1 ≤ scalingConstantOf μ K :=
le_max_of_le_right <| le_refl 1
#align is_unif_loc_doubling_measure.one_le_scaling_constant_of IsUnifLocDoublingMeasure.one_le_scalingConstantOf
| Mathlib/MeasureTheory/Measure/Doubling.lean | 113 | 129 | theorem eventually_measure_mul_le_scalingConstantOf_mul (K : ℝ) :
∃ R : ℝ,
0 < R ∧
∀ x t r, t ∈ Ioc 0 K → r ≤ R →
μ (closedBall x (t * r)) ≤ scalingConstantOf μ K * μ (closedBall x r) := by |
have h := Classical.choose_spec (exists_eventually_forall_measure_closedBall_le_mul μ K)
rcases mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 h with ⟨R, Rpos, hR⟩
refine ⟨R, Rpos, fun x t r ht hr => ?_⟩
rcases lt_trichotomy r 0 with (rneg | rfl | rpos)
· have : t * r < 0 := mul_neg_of_pos_of_neg ht.1 rneg
simp only [closedBall_eq_empty.2 this, measure_empty, zero_le']
· simp only [mul_zero, closedBall_zero]
refine le_mul_of_one_le_of_le ?_ le_rfl
apply ENNReal.one_le_coe_iff.2 (le_max_right _ _)
· apply (hR ⟨rpos, hr⟩ x t ht.2).trans
gcongr
apply le_max_left
|
import Mathlib.Algebra.GroupPower.IterateHom
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Order.Iterate
import Mathlib.Order.SemiconjSup
import Mathlib.Tactic.Monotonicity
import Mathlib.Topology.Order.MonotoneContinuity
#align_import dynamics.circle.rotation_number.translation_number from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
open scoped Classical
open Filter Set Int Topology
open Function hiding Commute
structure CircleDeg1Lift extends ℝ →o ℝ : Type where
map_add_one' : ∀ x, toFun (x + 1) = toFun x + 1
#align circle_deg1_lift CircleDeg1Lift
namespace CircleDeg1Lift
instance : FunLike CircleDeg1Lift ℝ ℝ where
coe f := f.toFun
coe_injective' | ⟨⟨_, _⟩, _⟩, ⟨⟨_, _⟩, _⟩, rfl => rfl
instance : OrderHomClass CircleDeg1Lift ℝ ℝ where
map_rel f _ _ h := f.monotone' h
@[simp] theorem coe_mk (f h) : ⇑(mk f h) = f := rfl
#align circle_deg1_lift.coe_mk CircleDeg1Lift.coe_mk
variable (f g : CircleDeg1Lift)
@[simp] theorem coe_toOrderHom : ⇑f.toOrderHom = f := rfl
protected theorem monotone : Monotone f := f.monotone'
#align circle_deg1_lift.monotone CircleDeg1Lift.monotone
@[mono] theorem mono {x y} (h : x ≤ y) : f x ≤ f y := f.monotone h
#align circle_deg1_lift.mono CircleDeg1Lift.mono
theorem strictMono_iff_injective : StrictMono f ↔ Injective f :=
f.monotone.strictMono_iff_injective
#align circle_deg1_lift.strict_mono_iff_injective CircleDeg1Lift.strictMono_iff_injective
@[simp]
theorem map_add_one : ∀ x, f (x + 1) = f x + 1 :=
f.map_add_one'
#align circle_deg1_lift.map_add_one CircleDeg1Lift.map_add_one
@[simp]
theorem map_one_add (x : ℝ) : f (1 + x) = 1 + f x := by rw [add_comm, map_add_one, add_comm 1]
#align circle_deg1_lift.map_one_add CircleDeg1Lift.map_one_add
#noalign circle_deg1_lift.coe_inj -- Use `DFunLike.coe_inj`
@[ext]
theorem ext ⦃f g : CircleDeg1Lift⦄ (h : ∀ x, f x = g x) : f = g :=
DFunLike.ext f g h
#align circle_deg1_lift.ext CircleDeg1Lift.ext
theorem ext_iff {f g : CircleDeg1Lift} : f = g ↔ ∀ x, f x = g x :=
DFunLike.ext_iff
#align circle_deg1_lift.ext_iff CircleDeg1Lift.ext_iff
instance : Monoid CircleDeg1Lift where
mul f g :=
{ toOrderHom := f.1.comp g.1
map_add_one' := fun x => by simp [map_add_one] }
one := ⟨.id, fun _ => rfl⟩
mul_one f := rfl
one_mul f := rfl
mul_assoc f₁ f₂ f₃ := DFunLike.coe_injective rfl
instance : Inhabited CircleDeg1Lift := ⟨1⟩
@[simp]
theorem coe_mul : ⇑(f * g) = f ∘ g :=
rfl
#align circle_deg1_lift.coe_mul CircleDeg1Lift.coe_mul
theorem mul_apply (x) : (f * g) x = f (g x) :=
rfl
#align circle_deg1_lift.mul_apply CircleDeg1Lift.mul_apply
@[simp]
theorem coe_one : ⇑(1 : CircleDeg1Lift) = id :=
rfl
#align circle_deg1_lift.coe_one CircleDeg1Lift.coe_one
instance unitsHasCoeToFun : CoeFun CircleDeg1Liftˣ fun _ => ℝ → ℝ :=
⟨fun f => ⇑(f : CircleDeg1Lift)⟩
#align circle_deg1_lift.units_has_coe_to_fun CircleDeg1Lift.unitsHasCoeToFun
#noalign circle_deg1_lift.units_coe -- now LHS = RHS
@[simp]
theorem units_inv_apply_apply (f : CircleDeg1Liftˣ) (x : ℝ) :
(f⁻¹ : CircleDeg1Liftˣ) (f x) = x := by simp only [← mul_apply, f.inv_mul, coe_one, id]
#align circle_deg1_lift.units_inv_apply_apply CircleDeg1Lift.units_inv_apply_apply
@[simp]
theorem units_apply_inv_apply (f : CircleDeg1Liftˣ) (x : ℝ) :
f ((f⁻¹ : CircleDeg1Liftˣ) x) = x := by simp only [← mul_apply, f.mul_inv, coe_one, id]
#align circle_deg1_lift.units_apply_inv_apply CircleDeg1Lift.units_apply_inv_apply
def toOrderIso : CircleDeg1Liftˣ →* ℝ ≃o ℝ where
toFun f :=
{ toFun := f
invFun := ⇑f⁻¹
left_inv := units_inv_apply_apply f
right_inv := units_apply_inv_apply f
map_rel_iff' := ⟨fun h => by simpa using mono (↑f⁻¹) h, mono f⟩ }
map_one' := rfl
map_mul' f g := rfl
#align circle_deg1_lift.to_order_iso CircleDeg1Lift.toOrderIso
@[simp]
theorem coe_toOrderIso (f : CircleDeg1Liftˣ) : ⇑(toOrderIso f) = f :=
rfl
#align circle_deg1_lift.coe_to_order_iso CircleDeg1Lift.coe_toOrderIso
@[simp]
theorem coe_toOrderIso_symm (f : CircleDeg1Liftˣ) :
⇑(toOrderIso f).symm = (f⁻¹ : CircleDeg1Liftˣ) :=
rfl
#align circle_deg1_lift.coe_to_order_iso_symm CircleDeg1Lift.coe_toOrderIso_symm
@[simp]
theorem coe_toOrderIso_inv (f : CircleDeg1Liftˣ) : ⇑(toOrderIso f)⁻¹ = (f⁻¹ : CircleDeg1Liftˣ) :=
rfl
#align circle_deg1_lift.coe_to_order_iso_inv CircleDeg1Lift.coe_toOrderIso_inv
theorem isUnit_iff_bijective {f : CircleDeg1Lift} : IsUnit f ↔ Bijective f :=
⟨fun ⟨u, h⟩ => h ▸ (toOrderIso u).bijective, fun h =>
Units.isUnit
{ val := f
inv :=
{ toFun := (Equiv.ofBijective f h).symm
monotone' := fun x y hxy =>
(f.strictMono_iff_injective.2 h.1).le_iff_le.1
(by simp only [Equiv.ofBijective_apply_symm_apply f h, hxy])
map_add_one' := fun x =>
h.1 <| by simp only [Equiv.ofBijective_apply_symm_apply f, f.map_add_one] }
val_inv := ext <| Equiv.ofBijective_apply_symm_apply f h
inv_val := ext <| Equiv.ofBijective_symm_apply_apply f h }⟩
#align circle_deg1_lift.is_unit_iff_bijective CircleDeg1Lift.isUnit_iff_bijective
theorem coe_pow : ∀ n : ℕ, ⇑(f ^ n) = f^[n]
| 0 => rfl
| n + 1 => by
ext x
simp [coe_pow n, pow_succ]
#align circle_deg1_lift.coe_pow CircleDeg1Lift.coe_pow
theorem semiconjBy_iff_semiconj {f g₁ g₂ : CircleDeg1Lift} :
SemiconjBy f g₁ g₂ ↔ Semiconj f g₁ g₂ :=
ext_iff
#align circle_deg1_lift.semiconj_by_iff_semiconj CircleDeg1Lift.semiconjBy_iff_semiconj
theorem commute_iff_commute {f g : CircleDeg1Lift} : Commute f g ↔ Function.Commute f g :=
ext_iff
#align circle_deg1_lift.commute_iff_commute CircleDeg1Lift.commute_iff_commute
def translate : Multiplicative ℝ →* CircleDeg1Liftˣ := MonoidHom.toHomUnits <|
{ toFun := fun x =>
⟨⟨fun y => Multiplicative.toAdd x + y, fun _ _ h => add_le_add_left h _⟩, fun _ =>
(add_assoc _ _ _).symm⟩
map_one' := ext <| zero_add
map_mul' := fun _ _ => ext <| add_assoc _ _ }
#align circle_deg1_lift.translate CircleDeg1Lift.translate
@[simp]
theorem translate_apply (x y : ℝ) : translate (Multiplicative.ofAdd x) y = x + y :=
rfl
#align circle_deg1_lift.translate_apply CircleDeg1Lift.translate_apply
@[simp]
theorem translate_inv_apply (x y : ℝ) : (translate <| Multiplicative.ofAdd x)⁻¹ y = -x + y :=
rfl
#align circle_deg1_lift.translate_inv_apply CircleDeg1Lift.translate_inv_apply
@[simp]
theorem translate_zpow (x : ℝ) (n : ℤ) :
translate (Multiplicative.ofAdd x) ^ n = translate (Multiplicative.ofAdd <| ↑n * x) := by
simp only [← zsmul_eq_mul, ofAdd_zsmul, MonoidHom.map_zpow]
#align circle_deg1_lift.translate_zpow CircleDeg1Lift.translate_zpow
@[simp]
theorem translate_pow (x : ℝ) (n : ℕ) :
translate (Multiplicative.ofAdd x) ^ n = translate (Multiplicative.ofAdd <| ↑n * x) :=
translate_zpow x n
#align circle_deg1_lift.translate_pow CircleDeg1Lift.translate_pow
@[simp]
theorem translate_iterate (x : ℝ) (n : ℕ) :
(translate (Multiplicative.ofAdd x))^[n] = translate (Multiplicative.ofAdd <| ↑n * x) := by
rw [← coe_pow, ← Units.val_pow_eq_pow_val, translate_pow]
#align circle_deg1_lift.translate_iterate CircleDeg1Lift.translate_iterate
theorem commute_nat_add (n : ℕ) : Function.Commute f (n + ·) := by
simpa only [nsmul_one, add_left_iterate] using Function.Commute.iterate_right f.map_one_add n
#align circle_deg1_lift.commute_nat_add CircleDeg1Lift.commute_nat_add
theorem commute_add_nat (n : ℕ) : Function.Commute f (· + n) := by
simp only [add_comm _ (n : ℝ), f.commute_nat_add n]
#align circle_deg1_lift.commute_add_nat CircleDeg1Lift.commute_add_nat
theorem commute_sub_nat (n : ℕ) : Function.Commute f (· - n) := by
simpa only [sub_eq_add_neg] using
(f.commute_add_nat n).inverses_right (Equiv.addRight _).right_inv (Equiv.addRight _).left_inv
#align circle_deg1_lift.commute_sub_nat CircleDeg1Lift.commute_sub_nat
theorem commute_add_int : ∀ n : ℤ, Function.Commute f (· + n)
| (n : ℕ) => f.commute_add_nat n
| -[n+1] => by simpa [sub_eq_add_neg] using f.commute_sub_nat (n + 1)
#align circle_deg1_lift.commute_add_int CircleDeg1Lift.commute_add_int
theorem commute_int_add (n : ℤ) : Function.Commute f (n + ·) := by
simpa only [add_comm _ (n : ℝ)] using f.commute_add_int n
#align circle_deg1_lift.commute_int_add CircleDeg1Lift.commute_int_add
theorem commute_sub_int (n : ℤ) : Function.Commute f (· - n) := by
simpa only [sub_eq_add_neg] using
(f.commute_add_int n).inverses_right (Equiv.addRight _).right_inv (Equiv.addRight _).left_inv
#align circle_deg1_lift.commute_sub_int CircleDeg1Lift.commute_sub_int
@[simp]
theorem map_int_add (m : ℤ) (x : ℝ) : f (m + x) = m + f x :=
f.commute_int_add m x
#align circle_deg1_lift.map_int_add CircleDeg1Lift.map_int_add
@[simp]
theorem map_add_int (x : ℝ) (m : ℤ) : f (x + m) = f x + m :=
f.commute_add_int m x
#align circle_deg1_lift.map_add_int CircleDeg1Lift.map_add_int
@[simp]
theorem map_sub_int (x : ℝ) (n : ℤ) : f (x - n) = f x - n :=
f.commute_sub_int n x
#align circle_deg1_lift.map_sub_int CircleDeg1Lift.map_sub_int
@[simp]
theorem map_add_nat (x : ℝ) (n : ℕ) : f (x + n) = f x + n :=
f.map_add_int x n
#align circle_deg1_lift.map_add_nat CircleDeg1Lift.map_add_nat
@[simp]
theorem map_nat_add (n : ℕ) (x : ℝ) : f (n + x) = n + f x :=
f.map_int_add n x
#align circle_deg1_lift.map_nat_add CircleDeg1Lift.map_nat_add
@[simp]
theorem map_sub_nat (x : ℝ) (n : ℕ) : f (x - n) = f x - n :=
f.map_sub_int x n
#align circle_deg1_lift.map_sub_nat CircleDeg1Lift.map_sub_nat
theorem map_int_of_map_zero (n : ℤ) : f n = f 0 + n := by rw [← f.map_add_int, zero_add]
#align circle_deg1_lift.map_int_of_map_zero CircleDeg1Lift.map_int_of_map_zero
@[simp]
theorem map_fract_sub_fract_eq (x : ℝ) : f (fract x) - fract x = f x - x := by
rw [Int.fract, f.map_sub_int, sub_sub_sub_cancel_right]
#align circle_deg1_lift.map_fract_sub_fract_eq CircleDeg1Lift.map_fract_sub_fract_eq
noncomputable instance : Lattice CircleDeg1Lift where
sup f g :=
{ toFun := fun x => max (f x) (g x)
monotone' := fun x y h => max_le_max (f.mono h) (g.mono h)
-- TODO: generalize to `Monotone.max`
map_add_one' := fun x => by simp [max_add_add_right] }
le f g := ∀ x, f x ≤ g x
le_refl f x := le_refl (f x)
le_trans f₁ f₂ f₃ h₁₂ h₂₃ x := le_trans (h₁₂ x) (h₂₃ x)
le_antisymm f₁ f₂ h₁₂ h₂₁ := ext fun x => le_antisymm (h₁₂ x) (h₂₁ x)
le_sup_left f g x := le_max_left (f x) (g x)
le_sup_right f g x := le_max_right (f x) (g x)
sup_le f₁ f₂ f₃ h₁ h₂ x := max_le (h₁ x) (h₂ x)
inf f g :=
{ toFun := fun x => min (f x) (g x)
monotone' := fun x y h => min_le_min (f.mono h) (g.mono h)
map_add_one' := fun x => by simp [min_add_add_right] }
inf_le_left f g x := min_le_left (f x) (g x)
inf_le_right f g x := min_le_right (f x) (g x)
le_inf f₁ f₂ f₃ h₂ h₃ x := le_min (h₂ x) (h₃ x)
@[simp]
theorem sup_apply (x : ℝ) : (f ⊔ g) x = max (f x) (g x) :=
rfl
#align circle_deg1_lift.sup_apply CircleDeg1Lift.sup_apply
@[simp]
theorem inf_apply (x : ℝ) : (f ⊓ g) x = min (f x) (g x) :=
rfl
#align circle_deg1_lift.inf_apply CircleDeg1Lift.inf_apply
theorem iterate_monotone (n : ℕ) : Monotone fun f : CircleDeg1Lift => f^[n] := fun f _ h =>
f.monotone.iterate_le_of_le h _
#align circle_deg1_lift.iterate_monotone CircleDeg1Lift.iterate_monotone
theorem iterate_mono {f g : CircleDeg1Lift} (h : f ≤ g) (n : ℕ) : f^[n] ≤ g^[n] :=
iterate_monotone n h
#align circle_deg1_lift.iterate_mono CircleDeg1Lift.iterate_mono
theorem pow_mono {f g : CircleDeg1Lift} (h : f ≤ g) (n : ℕ) : f ^ n ≤ g ^ n := fun x => by
simp only [coe_pow, iterate_mono h n x]
#align circle_deg1_lift.pow_mono CircleDeg1Lift.pow_mono
theorem pow_monotone (n : ℕ) : Monotone fun f : CircleDeg1Lift => f ^ n := fun _ _ h => pow_mono h n
#align circle_deg1_lift.pow_monotone CircleDeg1Lift.pow_monotone
theorem map_le_of_map_zero (x : ℝ) : f x ≤ f 0 + ⌈x⌉ :=
calc
f x ≤ f ⌈x⌉ := f.monotone <| le_ceil _
_ = f 0 + ⌈x⌉ := f.map_int_of_map_zero _
#align circle_deg1_lift.map_le_of_map_zero CircleDeg1Lift.map_le_of_map_zero
theorem map_map_zero_le : f (g 0) ≤ f 0 + ⌈g 0⌉ :=
f.map_le_of_map_zero (g 0)
#align circle_deg1_lift.map_map_zero_le CircleDeg1Lift.map_map_zero_le
theorem floor_map_map_zero_le : ⌊f (g 0)⌋ ≤ ⌊f 0⌋ + ⌈g 0⌉ :=
calc
⌊f (g 0)⌋ ≤ ⌊f 0 + ⌈g 0⌉⌋ := floor_mono <| f.map_map_zero_le g
_ = ⌊f 0⌋ + ⌈g 0⌉ := floor_add_int _ _
#align circle_deg1_lift.floor_map_map_zero_le CircleDeg1Lift.floor_map_map_zero_le
theorem ceil_map_map_zero_le : ⌈f (g 0)⌉ ≤ ⌈f 0⌉ + ⌈g 0⌉ :=
calc
⌈f (g 0)⌉ ≤ ⌈f 0 + ⌈g 0⌉⌉ := ceil_mono <| f.map_map_zero_le g
_ = ⌈f 0⌉ + ⌈g 0⌉ := ceil_add_int _ _
#align circle_deg1_lift.ceil_map_map_zero_le CircleDeg1Lift.ceil_map_map_zero_le
theorem map_map_zero_lt : f (g 0) < f 0 + g 0 + 1 :=
calc
f (g 0) ≤ f 0 + ⌈g 0⌉ := f.map_map_zero_le g
_ < f 0 + (g 0 + 1) := add_lt_add_left (ceil_lt_add_one _) _
_ = f 0 + g 0 + 1 := (add_assoc _ _ _).symm
#align circle_deg1_lift.map_map_zero_lt CircleDeg1Lift.map_map_zero_lt
theorem le_map_of_map_zero (x : ℝ) : f 0 + ⌊x⌋ ≤ f x :=
calc
f 0 + ⌊x⌋ = f ⌊x⌋ := (f.map_int_of_map_zero _).symm
_ ≤ f x := f.monotone <| floor_le _
#align circle_deg1_lift.le_map_of_map_zero CircleDeg1Lift.le_map_of_map_zero
theorem le_map_map_zero : f 0 + ⌊g 0⌋ ≤ f (g 0) :=
f.le_map_of_map_zero (g 0)
#align circle_deg1_lift.le_map_map_zero CircleDeg1Lift.le_map_map_zero
theorem le_floor_map_map_zero : ⌊f 0⌋ + ⌊g 0⌋ ≤ ⌊f (g 0)⌋ :=
calc
⌊f 0⌋ + ⌊g 0⌋ = ⌊f 0 + ⌊g 0⌋⌋ := (floor_add_int _ _).symm
_ ≤ ⌊f (g 0)⌋ := floor_mono <| f.le_map_map_zero g
#align circle_deg1_lift.le_floor_map_map_zero CircleDeg1Lift.le_floor_map_map_zero
theorem le_ceil_map_map_zero : ⌈f 0⌉ + ⌊g 0⌋ ≤ ⌈(f * g) 0⌉ :=
calc
⌈f 0⌉ + ⌊g 0⌋ = ⌈f 0 + ⌊g 0⌋⌉ := (ceil_add_int _ _).symm
_ ≤ ⌈f (g 0)⌉ := ceil_mono <| f.le_map_map_zero g
#align circle_deg1_lift.le_ceil_map_map_zero CircleDeg1Lift.le_ceil_map_map_zero
theorem lt_map_map_zero : f 0 + g 0 - 1 < f (g 0) :=
calc
f 0 + g 0 - 1 = f 0 + (g 0 - 1) := add_sub_assoc _ _ _
_ < f 0 + ⌊g 0⌋ := add_lt_add_left (sub_one_lt_floor _) _
_ ≤ f (g 0) := f.le_map_map_zero g
#align circle_deg1_lift.lt_map_map_zero CircleDeg1Lift.lt_map_map_zero
theorem dist_map_map_zero_lt : dist (f 0 + g 0) (f (g 0)) < 1 := by
rw [dist_comm, Real.dist_eq, abs_lt, lt_sub_iff_add_lt', sub_lt_iff_lt_add', ← sub_eq_add_neg]
exact ⟨f.lt_map_map_zero g, f.map_map_zero_lt g⟩
#align circle_deg1_lift.dist_map_map_zero_lt CircleDeg1Lift.dist_map_map_zero_lt
theorem dist_map_zero_lt_of_semiconj {f g₁ g₂ : CircleDeg1Lift} (h : Function.Semiconj f g₁ g₂) :
dist (g₁ 0) (g₂ 0) < 2 :=
calc
dist (g₁ 0) (g₂ 0) ≤ dist (g₁ 0) (f (g₁ 0) - f 0) + dist _ (g₂ 0) := dist_triangle _ _ _
_ = dist (f 0 + g₁ 0) (f (g₁ 0)) + dist (g₂ 0 + f 0) (g₂ (f 0)) := by
simp only [h.eq, Real.dist_eq, sub_sub, add_comm (f 0), sub_sub_eq_add_sub,
abs_sub_comm (g₂ (f 0))]
_ < 1 + 1 := add_lt_add (f.dist_map_map_zero_lt g₁) (g₂.dist_map_map_zero_lt f)
_ = 2 := one_add_one_eq_two
#align circle_deg1_lift.dist_map_zero_lt_of_semiconj CircleDeg1Lift.dist_map_zero_lt_of_semiconj
theorem dist_map_zero_lt_of_semiconjBy {f g₁ g₂ : CircleDeg1Lift} (h : SemiconjBy f g₁ g₂) :
dist (g₁ 0) (g₂ 0) < 2 :=
dist_map_zero_lt_of_semiconj <| semiconjBy_iff_semiconj.1 h
#align circle_deg1_lift.dist_map_zero_lt_of_semiconj_by CircleDeg1Lift.dist_map_zero_lt_of_semiconjBy
protected theorem tendsto_atBot : Tendsto f atBot atBot :=
tendsto_atBot_mono f.map_le_of_map_zero <| tendsto_atBot_add_const_left _ _ <|
(tendsto_atBot_mono fun x => (ceil_lt_add_one x).le) <|
tendsto_atBot_add_const_right _ _ tendsto_id
#align circle_deg1_lift.tendsto_at_bot CircleDeg1Lift.tendsto_atBot
protected theorem tendsto_atTop : Tendsto f atTop atTop :=
tendsto_atTop_mono f.le_map_of_map_zero <| tendsto_atTop_add_const_left _ _ <|
(tendsto_atTop_mono fun x => (sub_one_lt_floor x).le) <| by
simpa [sub_eq_add_neg] using tendsto_atTop_add_const_right _ _ tendsto_id
#align circle_deg1_lift.tendsto_at_top CircleDeg1Lift.tendsto_atTop
theorem continuous_iff_surjective : Continuous f ↔ Function.Surjective f :=
⟨fun h => h.surjective f.tendsto_atTop f.tendsto_atBot, f.monotone.continuous_of_surjective⟩
#align circle_deg1_lift.continuous_iff_surjective CircleDeg1Lift.continuous_iff_surjective
theorem iterate_le_of_map_le_add_int {x : ℝ} {m : ℤ} (h : f x ≤ x + m) (n : ℕ) :
f^[n] x ≤ x + n * m := by
simpa only [nsmul_eq_mul, add_right_iterate] using
(f.commute_add_int m).iterate_le_of_map_le f.monotone (monotone_id.add_const (m : ℝ)) h n
#align circle_deg1_lift.iterate_le_of_map_le_add_int CircleDeg1Lift.iterate_le_of_map_le_add_int
theorem le_iterate_of_add_int_le_map {x : ℝ} {m : ℤ} (h : x + m ≤ f x) (n : ℕ) :
x + n * m ≤ f^[n] x := by
simpa only [nsmul_eq_mul, add_right_iterate] using
(f.commute_add_int m).symm.iterate_le_of_map_le (monotone_id.add_const (m : ℝ)) f.monotone h n
#align circle_deg1_lift.le_iterate_of_add_int_le_map CircleDeg1Lift.le_iterate_of_add_int_le_map
theorem iterate_eq_of_map_eq_add_int {x : ℝ} {m : ℤ} (h : f x = x + m) (n : ℕ) :
f^[n] x = x + n * m := by
simpa only [nsmul_eq_mul, add_right_iterate] using (f.commute_add_int m).iterate_eq_of_map_eq n h
#align circle_deg1_lift.iterate_eq_of_map_eq_add_int CircleDeg1Lift.iterate_eq_of_map_eq_add_int
theorem iterate_pos_le_iff {x : ℝ} {m : ℤ} {n : ℕ} (hn : 0 < n) :
f^[n] x ≤ x + n * m ↔ f x ≤ x + m := by
simpa only [nsmul_eq_mul, add_right_iterate] using
(f.commute_add_int m).iterate_pos_le_iff_map_le f.monotone (strictMono_id.add_const (m : ℝ)) hn
#align circle_deg1_lift.iterate_pos_le_iff CircleDeg1Lift.iterate_pos_le_iff
theorem iterate_pos_lt_iff {x : ℝ} {m : ℤ} {n : ℕ} (hn : 0 < n) :
f^[n] x < x + n * m ↔ f x < x + m := by
simpa only [nsmul_eq_mul, add_right_iterate] using
(f.commute_add_int m).iterate_pos_lt_iff_map_lt f.monotone (strictMono_id.add_const (m : ℝ)) hn
#align circle_deg1_lift.iterate_pos_lt_iff CircleDeg1Lift.iterate_pos_lt_iff
theorem iterate_pos_eq_iff {x : ℝ} {m : ℤ} {n : ℕ} (hn : 0 < n) :
f^[n] x = x + n * m ↔ f x = x + m := by
simpa only [nsmul_eq_mul, add_right_iterate] using
(f.commute_add_int m).iterate_pos_eq_iff_map_eq f.monotone (strictMono_id.add_const (m : ℝ)) hn
#align circle_deg1_lift.iterate_pos_eq_iff CircleDeg1Lift.iterate_pos_eq_iff
theorem le_iterate_pos_iff {x : ℝ} {m : ℤ} {n : ℕ} (hn : 0 < n) :
x + n * m ≤ f^[n] x ↔ x + m ≤ f x := by
simpa only [not_lt] using not_congr (f.iterate_pos_lt_iff hn)
#align circle_deg1_lift.le_iterate_pos_iff CircleDeg1Lift.le_iterate_pos_iff
theorem lt_iterate_pos_iff {x : ℝ} {m : ℤ} {n : ℕ} (hn : 0 < n) :
x + n * m < f^[n] x ↔ x + m < f x := by
simpa only [not_le] using not_congr (f.iterate_pos_le_iff hn)
#align circle_deg1_lift.lt_iterate_pos_iff CircleDeg1Lift.lt_iterate_pos_iff
theorem mul_floor_map_zero_le_floor_iterate_zero (n : ℕ) : ↑n * ⌊f 0⌋ ≤ ⌊f^[n] 0⌋ := by
rw [le_floor, Int.cast_mul, Int.cast_natCast, ← zero_add ((n : ℝ) * _)]
apply le_iterate_of_add_int_le_map
simp [floor_le]
#align circle_deg1_lift.mul_floor_map_zero_le_floor_iterate_zero CircleDeg1Lift.mul_floor_map_zero_le_floor_iterate_zero
noncomputable section
def transnumAuxSeq (n : ℕ) : ℝ :=
(f ^ (2 ^ n : ℕ)) 0 / 2 ^ n
#align circle_deg1_lift.transnum_aux_seq CircleDeg1Lift.transnumAuxSeq
def translationNumber : ℝ :=
limUnder atTop f.transnumAuxSeq
#align circle_deg1_lift.translation_number CircleDeg1Lift.translationNumber
end
-- TODO: choose two different symbols for `CircleDeg1Lift.translationNumber` and the future
-- `circle_mono_homeo.rotation_number`, then make them `localized notation`s
local notation "τ" => translationNumber
theorem transnumAuxSeq_def : f.transnumAuxSeq = fun n : ℕ => (f ^ (2 ^ n : ℕ)) 0 / 2 ^ n :=
rfl
#align circle_deg1_lift.transnum_aux_seq_def CircleDeg1Lift.transnumAuxSeq_def
theorem translationNumber_eq_of_tendsto_aux {τ' : ℝ} (h : Tendsto f.transnumAuxSeq atTop (𝓝 τ')) :
τ f = τ' :=
h.limUnder_eq
#align circle_deg1_lift.translation_number_eq_of_tendsto_aux CircleDeg1Lift.translationNumber_eq_of_tendsto_aux
theorem translationNumber_eq_of_tendsto₀ {τ' : ℝ}
(h : Tendsto (fun n : ℕ => f^[n] 0 / n) atTop (𝓝 τ')) : τ f = τ' :=
f.translationNumber_eq_of_tendsto_aux <| by
simpa [(· ∘ ·), transnumAuxSeq_def, coe_pow] using
h.comp (Nat.tendsto_pow_atTop_atTop_of_one_lt one_lt_two)
#align circle_deg1_lift.translation_number_eq_of_tendsto₀ CircleDeg1Lift.translationNumber_eq_of_tendsto₀
theorem translationNumber_eq_of_tendsto₀' {τ' : ℝ}
(h : Tendsto (fun n : ℕ => f^[n + 1] 0 / (n + 1)) atTop (𝓝 τ')) : τ f = τ' :=
f.translationNumber_eq_of_tendsto₀ <| (tendsto_add_atTop_iff_nat 1).1 (mod_cast h)
#align circle_deg1_lift.translation_number_eq_of_tendsto₀' CircleDeg1Lift.translationNumber_eq_of_tendsto₀'
theorem transnumAuxSeq_zero : f.transnumAuxSeq 0 = f 0 := by simp [transnumAuxSeq]
#align circle_deg1_lift.transnum_aux_seq_zero CircleDeg1Lift.transnumAuxSeq_zero
theorem transnumAuxSeq_dist_lt (n : ℕ) :
dist (f.transnumAuxSeq n) (f.transnumAuxSeq (n + 1)) < 1 / 2 / 2 ^ n := by
have : 0 < (2 ^ (n + 1) : ℝ) := pow_pos zero_lt_two _
rw [div_div, ← pow_succ', ← abs_of_pos this]
replace := abs_pos.2 (ne_of_gt this)
convert (div_lt_div_right this).2 ((f ^ 2 ^ n).dist_map_map_zero_lt (f ^ 2 ^ n)) using 1
simp_rw [transnumAuxSeq, Real.dist_eq]
rw [← abs_div, sub_div, pow_succ, pow_succ', ← two_mul, mul_div_mul_left _ _ (two_ne_zero' ℝ),
pow_mul, sq, mul_apply]
#align circle_deg1_lift.transnum_aux_seq_dist_lt CircleDeg1Lift.transnumAuxSeq_dist_lt
theorem tendsto_translationNumber_aux : Tendsto f.transnumAuxSeq atTop (𝓝 <| τ f) :=
(cauchySeq_of_le_geometric_two 1 fun n => le_of_lt <| f.transnumAuxSeq_dist_lt n).tendsto_limUnder
#align circle_deg1_lift.tendsto_translation_number_aux CircleDeg1Lift.tendsto_translationNumber_aux
theorem dist_map_zero_translationNumber_le : dist (f 0) (τ f) ≤ 1 :=
f.transnumAuxSeq_zero ▸
dist_le_of_le_geometric_two_of_tendsto₀ 1 (fun n => le_of_lt <| f.transnumAuxSeq_dist_lt n)
f.tendsto_translationNumber_aux
#align circle_deg1_lift.dist_map_zero_translation_number_le CircleDeg1Lift.dist_map_zero_translationNumber_le
theorem tendsto_translationNumber_of_dist_bounded_aux (x : ℕ → ℝ) (C : ℝ)
(H : ∀ n : ℕ, dist ((f ^ n) 0) (x n) ≤ C) :
Tendsto (fun n : ℕ => x (2 ^ n) / 2 ^ n) atTop (𝓝 <| τ f) := by
apply f.tendsto_translationNumber_aux.congr_dist (squeeze_zero (fun _ => dist_nonneg) _ _)
· exact fun n => C / 2 ^ n
· intro n
have : 0 < (2 ^ n : ℝ) := pow_pos zero_lt_two _
convert (div_le_div_right this).2 (H (2 ^ n)) using 1
rw [transnumAuxSeq, Real.dist_eq, ← sub_div, abs_div, abs_of_pos this, Real.dist_eq]
· exact mul_zero C ▸ tendsto_const_nhds.mul <| tendsto_inv_atTop_zero.comp <|
tendsto_pow_atTop_atTop_of_one_lt one_lt_two
#align circle_deg1_lift.tendsto_translation_number_of_dist_bounded_aux CircleDeg1Lift.tendsto_translationNumber_of_dist_bounded_aux
theorem translationNumber_eq_of_dist_bounded {f g : CircleDeg1Lift} (C : ℝ)
(H : ∀ n : ℕ, dist ((f ^ n) 0) ((g ^ n) 0) ≤ C) : τ f = τ g :=
Eq.symm <| g.translationNumber_eq_of_tendsto_aux <|
f.tendsto_translationNumber_of_dist_bounded_aux _ C H
#align circle_deg1_lift.translation_number_eq_of_dist_bounded CircleDeg1Lift.translationNumber_eq_of_dist_bounded
@[simp]
theorem translationNumber_one : τ 1 = 0 :=
translationNumber_eq_of_tendsto₀ _ <| by simp [tendsto_const_nhds]
#align circle_deg1_lift.translation_number_one CircleDeg1Lift.translationNumber_one
theorem translationNumber_eq_of_semiconjBy {f g₁ g₂ : CircleDeg1Lift} (H : SemiconjBy f g₁ g₂) :
τ g₁ = τ g₂ :=
translationNumber_eq_of_dist_bounded 2 fun n =>
le_of_lt <| dist_map_zero_lt_of_semiconjBy <| H.pow_right n
#align circle_deg1_lift.translation_number_eq_of_semiconj_by CircleDeg1Lift.translationNumber_eq_of_semiconjBy
theorem translationNumber_eq_of_semiconj {f g₁ g₂ : CircleDeg1Lift}
(H : Function.Semiconj f g₁ g₂) : τ g₁ = τ g₂ :=
translationNumber_eq_of_semiconjBy <| semiconjBy_iff_semiconj.2 H
#align circle_deg1_lift.translation_number_eq_of_semiconj CircleDeg1Lift.translationNumber_eq_of_semiconj
theorem translationNumber_mul_of_commute {f g : CircleDeg1Lift} (h : Commute f g) :
τ (f * g) = τ f + τ g := by
refine tendsto_nhds_unique ?_
(f.tendsto_translationNumber_aux.add g.tendsto_translationNumber_aux)
simp only [transnumAuxSeq, ← add_div]
refine (f * g).tendsto_translationNumber_of_dist_bounded_aux
(fun n ↦ (f ^ n) 0 + (g ^ n) 0) 1 fun n ↦ ?_
rw [h.mul_pow, dist_comm]
exact le_of_lt ((f ^ n).dist_map_map_zero_lt (g ^ n))
#align circle_deg1_lift.translation_number_mul_of_commute CircleDeg1Lift.translationNumber_mul_of_commute
@[simp]
theorem translationNumber_units_inv (f : CircleDeg1Liftˣ) : τ ↑f⁻¹ = -τ f :=
eq_neg_iff_add_eq_zero.2 <| by
simp [← translationNumber_mul_of_commute (Commute.refl _).units_inv_left]
#align circle_deg1_lift.translation_number_units_inv CircleDeg1Lift.translationNumber_units_inv
@[simp]
theorem translationNumber_pow : ∀ n : ℕ, τ (f ^ n) = n * τ f
| 0 => by simp
| n + 1 => by
rw [pow_succ, translationNumber_mul_of_commute (Commute.pow_self f n),
translationNumber_pow n, Nat.cast_add_one, add_mul, one_mul]
#align circle_deg1_lift.translation_number_pow CircleDeg1Lift.translationNumber_pow
@[simp]
theorem translationNumber_zpow (f : CircleDeg1Liftˣ) : ∀ n : ℤ, τ (f ^ n : Units _) = n * τ f
| (n : ℕ) => by simp [translationNumber_pow f n]
| -[n+1] => by simp; ring
#align circle_deg1_lift.translation_number_zpow CircleDeg1Lift.translationNumber_zpow
@[simp]
theorem translationNumber_conj_eq (f : CircleDeg1Liftˣ) (g : CircleDeg1Lift) :
τ (↑f * g * ↑f⁻¹) = τ g :=
(translationNumber_eq_of_semiconjBy (f.mk_semiconjBy g)).symm
#align circle_deg1_lift.translation_number_conj_eq CircleDeg1Lift.translationNumber_conj_eq
@[simp]
theorem translationNumber_conj_eq' (f : CircleDeg1Liftˣ) (g : CircleDeg1Lift) :
τ (↑f⁻¹ * g * f) = τ g :=
translationNumber_conj_eq f⁻¹ g
#align circle_deg1_lift.translation_number_conj_eq' CircleDeg1Lift.translationNumber_conj_eq'
theorem dist_pow_map_zero_mul_translationNumber_le (n : ℕ) :
dist ((f ^ n) 0) (n * f.translationNumber) ≤ 1 :=
f.translationNumber_pow n ▸ (f ^ n).dist_map_zero_translationNumber_le
#align circle_deg1_lift.dist_pow_map_zero_mul_translation_number_le CircleDeg1Lift.dist_pow_map_zero_mul_translationNumber_le
theorem tendsto_translation_number₀' :
Tendsto (fun n : ℕ => (f ^ (n + 1) : CircleDeg1Lift) 0 / ((n : ℝ) + 1)) atTop (𝓝 <| τ f) := by
refine
tendsto_iff_dist_tendsto_zero.2 <|
squeeze_zero (fun _ => dist_nonneg) (fun n => ?_)
((tendsto_const_div_atTop_nhds_zero_nat 1).comp (tendsto_add_atTop_nat 1))
dsimp
have : (0 : ℝ) < n + 1 := n.cast_add_one_pos
rw [Real.dist_eq, div_sub' _ _ _ (ne_of_gt this), abs_div, ← Real.dist_eq, abs_of_pos this,
Nat.cast_add_one, div_le_div_right this, ← Nat.cast_add_one]
apply dist_pow_map_zero_mul_translationNumber_le
#align circle_deg1_lift.tendsto_translation_number₀' CircleDeg1Lift.tendsto_translation_number₀'
theorem tendsto_translation_number₀ : Tendsto (fun n : ℕ => (f ^ n) 0 / n) atTop (𝓝 <| τ f) :=
(tendsto_add_atTop_iff_nat 1).1 (mod_cast f.tendsto_translation_number₀')
#align circle_deg1_lift.tendsto_translation_number₀ CircleDeg1Lift.tendsto_translation_number₀
theorem tendsto_translationNumber (x : ℝ) :
Tendsto (fun n : ℕ => ((f ^ n) x - x) / n) atTop (𝓝 <| τ f) := by
rw [← translationNumber_conj_eq' (translate <| Multiplicative.ofAdd x)]
refine (tendsto_translation_number₀ _).congr fun n ↦ ?_
simp [sub_eq_neg_add, Units.conj_pow']
#align circle_deg1_lift.tendsto_translation_number CircleDeg1Lift.tendsto_translationNumber
theorem tendsto_translation_number' (x : ℝ) :
Tendsto (fun n : ℕ => ((f ^ (n + 1) : CircleDeg1Lift) x - x) / (n + 1)) atTop (𝓝 <| τ f) :=
mod_cast (tendsto_add_atTop_iff_nat 1).2 (f.tendsto_translationNumber x)
#align circle_deg1_lift.tendsto_translation_number' CircleDeg1Lift.tendsto_translation_number'
theorem translationNumber_mono : Monotone τ := fun f g h =>
le_of_tendsto_of_tendsto' f.tendsto_translation_number₀ g.tendsto_translation_number₀ fun n => by
gcongr; exact pow_mono h _ _
#align circle_deg1_lift.translation_number_mono CircleDeg1Lift.translationNumber_mono
theorem translationNumber_translate (x : ℝ) : τ (translate <| Multiplicative.ofAdd x) = x :=
translationNumber_eq_of_tendsto₀' _ <| by
simp only [translate_iterate, translate_apply, add_zero, Nat.cast_succ,
mul_div_cancel_left₀ (M₀ := ℝ) _ (Nat.cast_add_one_ne_zero _), tendsto_const_nhds]
#align circle_deg1_lift.translation_number_translate CircleDeg1Lift.translationNumber_translate
theorem translationNumber_le_of_le_add {z : ℝ} (hz : ∀ x, f x ≤ x + z) : τ f ≤ z :=
translationNumber_translate z ▸ translationNumber_mono fun x => (hz x).trans_eq (add_comm _ _)
#align circle_deg1_lift.translation_number_le_of_le_add CircleDeg1Lift.translationNumber_le_of_le_add
theorem le_translationNumber_of_add_le {z : ℝ} (hz : ∀ x, x + z ≤ f x) : z ≤ τ f :=
translationNumber_translate z ▸ translationNumber_mono fun x => (add_comm _ _).trans_le (hz x)
#align circle_deg1_lift.le_translation_number_of_add_le CircleDeg1Lift.le_translationNumber_of_add_le
theorem translationNumber_le_of_le_add_int {x : ℝ} {m : ℤ} (h : f x ≤ x + m) : τ f ≤ m :=
le_of_tendsto' (f.tendsto_translation_number' x) fun n =>
(div_le_iff' (n.cast_add_one_pos : (0 : ℝ) < _)).mpr <| sub_le_iff_le_add'.2 <|
(coe_pow f (n + 1)).symm ▸ @Nat.cast_add_one ℝ _ n ▸ f.iterate_le_of_map_le_add_int h (n + 1)
#align circle_deg1_lift.translation_number_le_of_le_add_int CircleDeg1Lift.translationNumber_le_of_le_add_int
theorem translationNumber_le_of_le_add_nat {x : ℝ} {m : ℕ} (h : f x ≤ x + m) : τ f ≤ m :=
@translationNumber_le_of_le_add_int f x m h
#align circle_deg1_lift.translation_number_le_of_le_add_nat CircleDeg1Lift.translationNumber_le_of_le_add_nat
theorem le_translationNumber_of_add_int_le {x : ℝ} {m : ℤ} (h : x + m ≤ f x) : ↑m ≤ τ f :=
ge_of_tendsto' (f.tendsto_translation_number' x) fun n =>
(le_div_iff (n.cast_add_one_pos : (0 : ℝ) < _)).mpr <| le_sub_iff_add_le'.2 <| by
simp only [coe_pow, mul_comm (m : ℝ), ← Nat.cast_add_one, f.le_iterate_of_add_int_le_map h]
#align circle_deg1_lift.le_translation_number_of_add_int_le CircleDeg1Lift.le_translationNumber_of_add_int_le
theorem le_translationNumber_of_add_nat_le {x : ℝ} {m : ℕ} (h : x + m ≤ f x) : ↑m ≤ τ f :=
@le_translationNumber_of_add_int_le f x m h
#align circle_deg1_lift.le_translation_number_of_add_nat_le CircleDeg1Lift.le_translationNumber_of_add_nat_le
theorem translationNumber_of_eq_add_int {x : ℝ} {m : ℤ} (h : f x = x + m) : τ f = m :=
le_antisymm (translationNumber_le_of_le_add_int f <| le_of_eq h)
(le_translationNumber_of_add_int_le f <| le_of_eq h.symm)
#align circle_deg1_lift.translation_number_of_eq_add_int CircleDeg1Lift.translationNumber_of_eq_add_int
theorem floor_sub_le_translationNumber (x : ℝ) : ↑⌊f x - x⌋ ≤ τ f :=
le_translationNumber_of_add_int_le f <| le_sub_iff_add_le'.1 (floor_le <| f x - x)
#align circle_deg1_lift.floor_sub_le_translation_number CircleDeg1Lift.floor_sub_le_translationNumber
theorem translationNumber_le_ceil_sub (x : ℝ) : τ f ≤ ⌈f x - x⌉ :=
translationNumber_le_of_le_add_int f <| sub_le_iff_le_add'.1 (le_ceil <| f x - x)
#align circle_deg1_lift.translation_number_le_ceil_sub CircleDeg1Lift.translationNumber_le_ceil_sub
theorem map_lt_of_translationNumber_lt_int {n : ℤ} (h : τ f < n) (x : ℝ) : f x < x + n :=
not_le.1 <| mt f.le_translationNumber_of_add_int_le <| not_le.2 h
#align circle_deg1_lift.map_lt_of_translation_number_lt_int CircleDeg1Lift.map_lt_of_translationNumber_lt_int
theorem map_lt_of_translationNumber_lt_nat {n : ℕ} (h : τ f < n) (x : ℝ) : f x < x + n :=
@map_lt_of_translationNumber_lt_int f n h x
#align circle_deg1_lift.map_lt_of_translation_number_lt_nat CircleDeg1Lift.map_lt_of_translationNumber_lt_nat
theorem map_lt_add_floor_translationNumber_add_one (x : ℝ) : f x < x + ⌊τ f⌋ + 1 := by
rw [add_assoc]
norm_cast
refine map_lt_of_translationNumber_lt_int _ ?_ _
push_cast
exact lt_floor_add_one _
#align circle_deg1_lift.map_lt_add_floor_translation_number_add_one CircleDeg1Lift.map_lt_add_floor_translationNumber_add_one
theorem map_lt_add_translationNumber_add_one (x : ℝ) : f x < x + τ f + 1 :=
calc
f x < x + ⌊τ f⌋ + 1 := f.map_lt_add_floor_translationNumber_add_one x
_ ≤ x + τ f + 1 := by gcongr; apply floor_le
#align circle_deg1_lift.map_lt_add_translation_number_add_one CircleDeg1Lift.map_lt_add_translationNumber_add_one
theorem lt_map_of_int_lt_translationNumber {n : ℤ} (h : ↑n < τ f) (x : ℝ) : x + n < f x :=
not_le.1 <| mt f.translationNumber_le_of_le_add_int <| not_le.2 h
#align circle_deg1_lift.lt_map_of_int_lt_translation_number CircleDeg1Lift.lt_map_of_int_lt_translationNumber
theorem lt_map_of_nat_lt_translationNumber {n : ℕ} (h : ↑n < τ f) (x : ℝ) : x + n < f x :=
@lt_map_of_int_lt_translationNumber f n h x
#align circle_deg1_lift.lt_map_of_nat_lt_translation_number CircleDeg1Lift.lt_map_of_nat_lt_translationNumber
theorem translationNumber_of_map_pow_eq_add_int {x : ℝ} {n : ℕ} {m : ℤ} (h : (f ^ n) x = x + m)
(hn : 0 < n) : τ f = m / n := by
have := (f ^ n).translationNumber_of_eq_add_int h
rwa [translationNumber_pow, mul_comm, ← eq_div_iff] at this
exact Nat.cast_ne_zero.2 (ne_of_gt hn)
#align circle_deg1_lift.translation_number_of_map_pow_eq_add_int CircleDeg1Lift.translationNumber_of_map_pow_eq_add_int
theorem forall_map_sub_of_Icc (P : ℝ → Prop) (h : ∀ x ∈ Icc (0 : ℝ) 1, P (f x - x)) (x : ℝ) :
P (f x - x) :=
f.map_fract_sub_fract_eq x ▸ h _ ⟨fract_nonneg _, le_of_lt (fract_lt_one _)⟩
#align circle_deg1_lift.forall_map_sub_of_Icc CircleDeg1Lift.forall_map_sub_of_Icc
| Mathlib/Dynamics/Circle/RotationNumber/TranslationNumber.lean | 906 | 914 | theorem translationNumber_lt_of_forall_lt_add (hf : Continuous f) {z : ℝ} (hz : ∀ x, f x < x + z) :
τ f < z := by |
obtain ⟨x, -, hx⟩ : ∃ x ∈ Icc (0 : ℝ) 1, ∀ y ∈ Icc (0 : ℝ) 1, f y - y ≤ f x - x :=
isCompact_Icc.exists_isMaxOn (nonempty_Icc.2 zero_le_one)
(hf.sub continuous_id).continuousOn
refine lt_of_le_of_lt ?_ (sub_lt_iff_lt_add'.2 <| hz x)
apply translationNumber_le_of_le_add
simp only [← sub_le_iff_le_add']
exact f.forall_map_sub_of_Icc (fun a => a ≤ f x - x) hx
|
import Mathlib.Topology.Sets.Opens
#align_import topology.sets.closeds from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988"
open Order OrderDual Set
variable {ι α β : Type*} [TopologicalSpace α] [TopologicalSpace β]
namespace TopologicalSpace
structure Closeds (α : Type*) [TopologicalSpace α] where
carrier : Set α
closed' : IsClosed carrier
#align topological_space.closeds TopologicalSpace.Closeds
namespace Closeds
instance : SetLike (Closeds α) α where
coe := Closeds.carrier
coe_injective' s t h := by cases s; cases t; congr
instance : CanLift (Set α) (Closeds α) (↑) IsClosed where
prf s hs := ⟨⟨s, hs⟩, rfl⟩
theorem closed (s : Closeds α) : IsClosed (s : Set α) :=
s.closed'
#align topological_space.closeds.closed TopologicalSpace.Closeds.closed
def Simps.coe (s : Closeds α) : Set α := s
initialize_simps_projections Closeds (carrier → coe, as_prefix coe)
@[ext]
protected theorem ext {s t : Closeds α} (h : (s : Set α) = t) : s = t :=
SetLike.ext' h
#align topological_space.closeds.ext TopologicalSpace.Closeds.ext
@[simp]
theorem coe_mk (s : Set α) (h) : (mk s h : Set α) = s :=
rfl
#align topological_space.closeds.coe_mk TopologicalSpace.Closeds.coe_mk
@[simps]
protected def closure (s : Set α) : Closeds α :=
⟨closure s, isClosed_closure⟩
#align topological_space.closeds.closure TopologicalSpace.Closeds.closure
theorem gc : GaloisConnection Closeds.closure ((↑) : Closeds α → Set α) := fun _ U =>
⟨subset_closure.trans, fun h => closure_minimal h U.closed⟩
#align topological_space.closeds.gc TopologicalSpace.Closeds.gc
def gi : GaloisInsertion (@Closeds.closure α _) (↑) where
choice s hs := ⟨s, closure_eq_iff_isClosed.1 <| hs.antisymm subset_closure⟩
gc := gc
le_l_u _ := subset_closure
choice_eq _s hs := SetLike.coe_injective <| subset_closure.antisymm hs
#align topological_space.closeds.gi TopologicalSpace.Closeds.gi
instance completeLattice : CompleteLattice (Closeds α) :=
CompleteLattice.copy
(GaloisInsertion.liftCompleteLattice gi)
-- le
_ rfl
-- top
⟨univ, isClosed_univ⟩ rfl
-- bot
⟨∅, isClosed_empty⟩ (SetLike.coe_injective closure_empty.symm)
-- sup
(fun s t => ⟨s ∪ t, s.2.union t.2⟩)
(funext fun s => funext fun t => SetLike.coe_injective (s.2.union t.2).closure_eq.symm)
-- inf
(fun s t => ⟨s ∩ t, s.2.inter t.2⟩) rfl
-- sSup
_ rfl
-- sInf
(fun S => ⟨⋂ s ∈ S, ↑s, isClosed_biInter fun s _ => s.2⟩)
(funext fun _ => SetLike.coe_injective sInf_image.symm)
instance : Inhabited (Closeds α) :=
⟨⊥⟩
@[simp, norm_cast]
| Mathlib/Topology/Sets/Closeds.lean | 110 | 111 | theorem coe_sup (s t : Closeds α) : (↑(s ⊔ t) : Set α) = ↑s ∪ ↑t := by |
rfl
|
import Mathlib.Algebra.Order.Ring.Defs
import Mathlib.Combinatorics.SimpleGraph.Basic
import Mathlib.Data.Sym.Card
open Finset Function
namespace SimpleGraph
variable {V : Type*} (G : SimpleGraph V) {e : Sym2 V}
section EdgeFinset
variable {G₁ G₂ : SimpleGraph V} [Fintype G.edgeSet] [Fintype G₁.edgeSet] [Fintype G₂.edgeSet]
abbrev edgeFinset : Finset (Sym2 V) :=
Set.toFinset G.edgeSet
#align simple_graph.edge_finset SimpleGraph.edgeFinset
@[norm_cast]
theorem coe_edgeFinset : (G.edgeFinset : Set (Sym2 V)) = G.edgeSet :=
Set.coe_toFinset _
#align simple_graph.coe_edge_finset SimpleGraph.coe_edgeFinset
variable {G}
theorem mem_edgeFinset : e ∈ G.edgeFinset ↔ e ∈ G.edgeSet :=
Set.mem_toFinset
#align simple_graph.mem_edge_finset SimpleGraph.mem_edgeFinset
theorem not_isDiag_of_mem_edgeFinset : e ∈ G.edgeFinset → ¬e.IsDiag :=
not_isDiag_of_mem_edgeSet _ ∘ mem_edgeFinset.1
#align simple_graph.not_is_diag_of_mem_edge_finset SimpleGraph.not_isDiag_of_mem_edgeFinset
theorem edgeFinset_inj : G₁.edgeFinset = G₂.edgeFinset ↔ G₁ = G₂ := by simp
#align simple_graph.edge_finset_inj SimpleGraph.edgeFinset_inj
theorem edgeFinset_subset_edgeFinset : G₁.edgeFinset ⊆ G₂.edgeFinset ↔ G₁ ≤ G₂ := by simp
#align simple_graph.edge_finset_subset_edge_finset SimpleGraph.edgeFinset_subset_edgeFinset
theorem edgeFinset_ssubset_edgeFinset : G₁.edgeFinset ⊂ G₂.edgeFinset ↔ G₁ < G₂ := by simp
#align simple_graph.edge_finset_ssubset_edge_finset SimpleGraph.edgeFinset_ssubset_edgeFinset
@[gcongr] alias ⟨_, edgeFinset_mono⟩ := edgeFinset_subset_edgeFinset
#align simple_graph.edge_finset_mono SimpleGraph.edgeFinset_mono
alias ⟨_, edgeFinset_strict_mono⟩ := edgeFinset_ssubset_edgeFinset
#align simple_graph.edge_finset_strict_mono SimpleGraph.edgeFinset_strict_mono
attribute [mono] edgeFinset_mono edgeFinset_strict_mono
@[simp]
theorem edgeFinset_bot : (⊥ : SimpleGraph V).edgeFinset = ∅ := by simp [edgeFinset]
#align simple_graph.edge_finset_bot SimpleGraph.edgeFinset_bot
@[simp]
theorem edgeFinset_sup [Fintype (edgeSet (G₁ ⊔ G₂))] [DecidableEq V] :
(G₁ ⊔ G₂).edgeFinset = G₁.edgeFinset ∪ G₂.edgeFinset := by simp [edgeFinset]
#align simple_graph.edge_finset_sup SimpleGraph.edgeFinset_sup
@[simp]
theorem edgeFinset_inf [DecidableEq V] : (G₁ ⊓ G₂).edgeFinset = G₁.edgeFinset ∩ G₂.edgeFinset := by
simp [edgeFinset]
#align simple_graph.edge_finset_inf SimpleGraph.edgeFinset_inf
@[simp]
theorem edgeFinset_sdiff [DecidableEq V] :
(G₁ \ G₂).edgeFinset = G₁.edgeFinset \ G₂.edgeFinset := by simp [edgeFinset]
#align simple_graph.edge_finset_sdiff SimpleGraph.edgeFinset_sdiff
theorem edgeFinset_card : G.edgeFinset.card = Fintype.card G.edgeSet :=
Set.toFinset_card _
#align simple_graph.edge_finset_card SimpleGraph.edgeFinset_card
@[simp]
theorem edgeSet_univ_card : (univ : Finset G.edgeSet).card = G.edgeFinset.card :=
Fintype.card_of_subtype G.edgeFinset fun _ => mem_edgeFinset
#align simple_graph.edge_set_univ_card SimpleGraph.edgeSet_univ_card
variable [Fintype V]
@[simp]
theorem edgeFinset_top [DecidableEq V] :
(⊤ : SimpleGraph V).edgeFinset = univ.filter fun e => ¬e.IsDiag := by
rw [← coe_inj]; simp
| Mathlib/Combinatorics/SimpleGraph/Finite.lean | 125 | 127 | theorem card_edgeFinset_top_eq_card_choose_two [DecidableEq V] :
(⊤ : SimpleGraph V).edgeFinset.card = (Fintype.card V).choose 2 := by |
simp_rw [Set.toFinset_card, edgeSet_top, Set.coe_setOf, ← Sym2.card_subtype_not_diag]
|
import Mathlib.Logic.Relation
import Mathlib.Data.Option.Basic
import Mathlib.Data.Seq.Seq
#align_import data.seq.wseq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
namespace Stream'
open Function
universe u v w
def WSeq (α) :=
Seq (Option α)
#align stream.wseq Stream'.WSeq
namespace WSeq
variable {α : Type u} {β : Type v} {γ : Type w}
@[coe]
def ofSeq : Seq α → WSeq α :=
(· <$> ·) some
#align stream.wseq.of_seq Stream'.WSeq.ofSeq
@[coe]
def ofList (l : List α) : WSeq α :=
ofSeq l
#align stream.wseq.of_list Stream'.WSeq.ofList
@[coe]
def ofStream (l : Stream' α) : WSeq α :=
ofSeq l
#align stream.wseq.of_stream Stream'.WSeq.ofStream
instance coeSeq : Coe (Seq α) (WSeq α) :=
⟨ofSeq⟩
#align stream.wseq.coe_seq Stream'.WSeq.coeSeq
instance coeList : Coe (List α) (WSeq α) :=
⟨ofList⟩
#align stream.wseq.coe_list Stream'.WSeq.coeList
instance coeStream : Coe (Stream' α) (WSeq α) :=
⟨ofStream⟩
#align stream.wseq.coe_stream Stream'.WSeq.coeStream
def nil : WSeq α :=
Seq.nil
#align stream.wseq.nil Stream'.WSeq.nil
instance inhabited : Inhabited (WSeq α) :=
⟨nil⟩
#align stream.wseq.inhabited Stream'.WSeq.inhabited
def cons (a : α) : WSeq α → WSeq α :=
Seq.cons (some a)
#align stream.wseq.cons Stream'.WSeq.cons
def think : WSeq α → WSeq α :=
Seq.cons none
#align stream.wseq.think Stream'.WSeq.think
def destruct : WSeq α → Computation (Option (α × WSeq α)) :=
Computation.corec fun s =>
match Seq.destruct s with
| none => Sum.inl none
| some (none, s') => Sum.inr s'
| some (some a, s') => Sum.inl (some (a, s'))
#align stream.wseq.destruct Stream'.WSeq.destruct
def recOn {C : WSeq α → Sort v} (s : WSeq α) (h1 : C nil) (h2 : ∀ x s, C (cons x s))
(h3 : ∀ s, C (think s)) : C s :=
Seq.recOn s h1 fun o => Option.recOn o h3 h2
#align stream.wseq.rec_on Stream'.WSeq.recOn
protected def Mem (a : α) (s : WSeq α) :=
Seq.Mem (some a) s
#align stream.wseq.mem Stream'.WSeq.Mem
instance membership : Membership α (WSeq α) :=
⟨WSeq.Mem⟩
#align stream.wseq.has_mem Stream'.WSeq.membership
theorem not_mem_nil (a : α) : a ∉ @nil α :=
Seq.not_mem_nil (some a)
#align stream.wseq.not_mem_nil Stream'.WSeq.not_mem_nil
def head (s : WSeq α) : Computation (Option α) :=
Computation.map (Prod.fst <$> ·) (destruct s)
#align stream.wseq.head Stream'.WSeq.head
def flatten : Computation (WSeq α) → WSeq α :=
Seq.corec fun c =>
match Computation.destruct c with
| Sum.inl s => Seq.omap (return ·) (Seq.destruct s)
| Sum.inr c' => some (none, c')
#align stream.wseq.flatten Stream'.WSeq.flatten
def tail (s : WSeq α) : WSeq α :=
flatten <| (fun o => Option.recOn o nil Prod.snd) <$> destruct s
#align stream.wseq.tail Stream'.WSeq.tail
def drop (s : WSeq α) : ℕ → WSeq α
| 0 => s
| n + 1 => tail (drop s n)
#align stream.wseq.drop Stream'.WSeq.drop
def get? (s : WSeq α) (n : ℕ) : Computation (Option α) :=
head (drop s n)
#align stream.wseq.nth Stream'.WSeq.get?
def toList (s : WSeq α) : Computation (List α) :=
@Computation.corec (List α) (List α × WSeq α)
(fun ⟨l, s⟩ =>
match Seq.destruct s with
| none => Sum.inl l.reverse
| some (none, s') => Sum.inr (l, s')
| some (some a, s') => Sum.inr (a::l, s'))
([], s)
#align stream.wseq.to_list Stream'.WSeq.toList
def length (s : WSeq α) : Computation ℕ :=
@Computation.corec ℕ (ℕ × WSeq α)
(fun ⟨n, s⟩ =>
match Seq.destruct s with
| none => Sum.inl n
| some (none, s') => Sum.inr (n, s')
| some (some _, s') => Sum.inr (n + 1, s'))
(0, s)
#align stream.wseq.length Stream'.WSeq.length
class IsFinite (s : WSeq α) : Prop where
out : (toList s).Terminates
#align stream.wseq.is_finite Stream'.WSeq.IsFinite
instance toList_terminates (s : WSeq α) [h : IsFinite s] : (toList s).Terminates :=
h.out
#align stream.wseq.to_list_terminates Stream'.WSeq.toList_terminates
def get (s : WSeq α) [IsFinite s] : List α :=
(toList s).get
#align stream.wseq.get Stream'.WSeq.get
class Productive (s : WSeq α) : Prop where
get?_terminates : ∀ n, (get? s n).Terminates
#align stream.wseq.productive Stream'.WSeq.Productive
#align stream.wseq.productive.nth_terminates Stream'.WSeq.Productive.get?_terminates
theorem productive_iff (s : WSeq α) : Productive s ↔ ∀ n, (get? s n).Terminates :=
⟨fun h => h.1, fun h => ⟨h⟩⟩
#align stream.wseq.productive_iff Stream'.WSeq.productive_iff
instance get?_terminates (s : WSeq α) [h : Productive s] : ∀ n, (get? s n).Terminates :=
h.get?_terminates
#align stream.wseq.nth_terminates Stream'.WSeq.get?_terminates
instance head_terminates (s : WSeq α) [Productive s] : (head s).Terminates :=
s.get?_terminates 0
#align stream.wseq.head_terminates Stream'.WSeq.head_terminates
def updateNth (s : WSeq α) (n : ℕ) (a : α) : WSeq α :=
@Seq.corec (Option α) (ℕ × WSeq α)
(fun ⟨n, s⟩ =>
match Seq.destruct s, n with
| none, _ => none
| some (none, s'), n => some (none, n, s')
| some (some a', s'), 0 => some (some a', 0, s')
| some (some _, s'), 1 => some (some a, 0, s')
| some (some a', s'), n + 2 => some (some a', n + 1, s'))
(n + 1, s)
#align stream.wseq.update_nth Stream'.WSeq.updateNth
def removeNth (s : WSeq α) (n : ℕ) : WSeq α :=
@Seq.corec (Option α) (ℕ × WSeq α)
(fun ⟨n, s⟩ =>
match Seq.destruct s, n with
| none, _ => none
| some (none, s'), n => some (none, n, s')
| some (some a', s'), 0 => some (some a', 0, s')
| some (some _, s'), 1 => some (none, 0, s')
| some (some a', s'), n + 2 => some (some a', n + 1, s'))
(n + 1, s)
#align stream.wseq.remove_nth Stream'.WSeq.removeNth
def filterMap (f : α → Option β) : WSeq α → WSeq β :=
Seq.corec fun s =>
match Seq.destruct s with
| none => none
| some (none, s') => some (none, s')
| some (some a, s') => some (f a, s')
#align stream.wseq.filter_map Stream'.WSeq.filterMap
def filter (p : α → Prop) [DecidablePred p] : WSeq α → WSeq α :=
filterMap fun a => if p a then some a else none
#align stream.wseq.filter Stream'.WSeq.filter
-- example of infinite list manipulations
def find (p : α → Prop) [DecidablePred p] (s : WSeq α) : Computation (Option α) :=
head <| filter p s
#align stream.wseq.find Stream'.WSeq.find
def zipWith (f : α → β → γ) (s1 : WSeq α) (s2 : WSeq β) : WSeq γ :=
@Seq.corec (Option γ) (WSeq α × WSeq β)
(fun ⟨s1, s2⟩ =>
match Seq.destruct s1, Seq.destruct s2 with
| some (none, s1'), some (none, s2') => some (none, s1', s2')
| some (some _, _), some (none, s2') => some (none, s1, s2')
| some (none, s1'), some (some _, _) => some (none, s1', s2)
| some (some a1, s1'), some (some a2, s2') => some (some (f a1 a2), s1', s2')
| _, _ => none)
(s1, s2)
#align stream.wseq.zip_with Stream'.WSeq.zipWith
def zip : WSeq α → WSeq β → WSeq (α × β) :=
zipWith Prod.mk
#align stream.wseq.zip Stream'.WSeq.zip
def findIndexes (p : α → Prop) [DecidablePred p] (s : WSeq α) : WSeq ℕ :=
(zip s (Stream'.nats : WSeq ℕ)).filterMap fun ⟨a, n⟩ => if p a then some n else none
#align stream.wseq.find_indexes Stream'.WSeq.findIndexes
def findIndex (p : α → Prop) [DecidablePred p] (s : WSeq α) : Computation ℕ :=
(fun o => Option.getD o 0) <$> head (findIndexes p s)
#align stream.wseq.find_index Stream'.WSeq.findIndex
def indexOf [DecidableEq α] (a : α) : WSeq α → Computation ℕ :=
findIndex (Eq a)
#align stream.wseq.index_of Stream'.WSeq.indexOf
def indexesOf [DecidableEq α] (a : α) : WSeq α → WSeq ℕ :=
findIndexes (Eq a)
#align stream.wseq.indexes_of Stream'.WSeq.indexesOf
def union (s1 s2 : WSeq α) : WSeq α :=
@Seq.corec (Option α) (WSeq α × WSeq α)
(fun ⟨s1, s2⟩ =>
match Seq.destruct s1, Seq.destruct s2 with
| none, none => none
| some (a1, s1'), none => some (a1, s1', nil)
| none, some (a2, s2') => some (a2, nil, s2')
| some (none, s1'), some (none, s2') => some (none, s1', s2')
| some (some a1, s1'), some (none, s2') => some (some a1, s1', s2')
| some (none, s1'), some (some a2, s2') => some (some a2, s1', s2')
| some (some a1, s1'), some (some a2, s2') => some (some a1, cons a2 s1', s2'))
(s1, s2)
#align stream.wseq.union Stream'.WSeq.union
def isEmpty (s : WSeq α) : Computation Bool :=
Computation.map Option.isNone <| head s
#align stream.wseq.is_empty Stream'.WSeq.isEmpty
def compute (s : WSeq α) : WSeq α :=
match Seq.destruct s with
| some (none, s') => s'
| _ => s
#align stream.wseq.compute Stream'.WSeq.compute
def take (s : WSeq α) (n : ℕ) : WSeq α :=
@Seq.corec (Option α) (ℕ × WSeq α)
(fun ⟨n, s⟩ =>
match n, Seq.destruct s with
| 0, _ => none
| _ + 1, none => none
| m + 1, some (none, s') => some (none, m + 1, s')
| m + 1, some (some a, s') => some (some a, m, s'))
(n, s)
#align stream.wseq.take Stream'.WSeq.take
def splitAt (s : WSeq α) (n : ℕ) : Computation (List α × WSeq α) :=
@Computation.corec (List α × WSeq α) (ℕ × List α × WSeq α)
(fun ⟨n, l, s⟩ =>
match n, Seq.destruct s with
| 0, _ => Sum.inl (l.reverse, s)
| _ + 1, none => Sum.inl (l.reverse, s)
| _ + 1, some (none, s') => Sum.inr (n, l, s')
| m + 1, some (some a, s') => Sum.inr (m, a::l, s'))
(n, [], s)
#align stream.wseq.split_at Stream'.WSeq.splitAt
def any (s : WSeq α) (p : α → Bool) : Computation Bool :=
Computation.corec
(fun s : WSeq α =>
match Seq.destruct s with
| none => Sum.inl false
| some (none, s') => Sum.inr s'
| some (some a, s') => if p a then Sum.inl true else Sum.inr s')
s
#align stream.wseq.any Stream'.WSeq.any
def all (s : WSeq α) (p : α → Bool) : Computation Bool :=
Computation.corec
(fun s : WSeq α =>
match Seq.destruct s with
| none => Sum.inl true
| some (none, s') => Sum.inr s'
| some (some a, s') => if p a then Sum.inr s' else Sum.inl false)
s
#align stream.wseq.all Stream'.WSeq.all
def scanl (f : α → β → α) (a : α) (s : WSeq β) : WSeq α :=
cons a <|
@Seq.corec (Option α) (α × WSeq β)
(fun ⟨a, s⟩ =>
match Seq.destruct s with
| none => none
| some (none, s') => some (none, a, s')
| some (some b, s') =>
let a' := f a b
some (some a', a', s'))
(a, s)
#align stream.wseq.scanl Stream'.WSeq.scanl
def inits (s : WSeq α) : WSeq (List α) :=
cons [] <|
@Seq.corec (Option (List α)) (Batteries.DList α × WSeq α)
(fun ⟨l, s⟩ =>
match Seq.destruct s with
| none => none
| some (none, s') => some (none, l, s')
| some (some a, s') =>
let l' := l.push a
some (some l'.toList, l', s'))
(Batteries.DList.empty, s)
#align stream.wseq.inits Stream'.WSeq.inits
def collect (s : WSeq α) (n : ℕ) : List α :=
(Seq.take n s).filterMap id
#align stream.wseq.collect Stream'.WSeq.collect
def append : WSeq α → WSeq α → WSeq α :=
Seq.append
#align stream.wseq.append Stream'.WSeq.append
def map (f : α → β) : WSeq α → WSeq β :=
Seq.map (Option.map f)
#align stream.wseq.map Stream'.WSeq.map
def join (S : WSeq (WSeq α)) : WSeq α :=
Seq.join
((fun o : Option (WSeq α) =>
match o with
| none => Seq1.ret none
| some s => (none, s)) <$>
S)
#align stream.wseq.join Stream'.WSeq.join
def bind (s : WSeq α) (f : α → WSeq β) : WSeq β :=
join (map f s)
#align stream.wseq.bind Stream'.WSeq.bind
@[simp]
def LiftRelO (R : α → β → Prop) (C : WSeq α → WSeq β → Prop) :
Option (α × WSeq α) → Option (β × WSeq β) → Prop
| none, none => True
| some (a, s), some (b, t) => R a b ∧ C s t
| _, _ => False
#align stream.wseq.lift_rel_o Stream'.WSeq.LiftRelO
theorem LiftRelO.imp {R S : α → β → Prop} {C D : WSeq α → WSeq β → Prop} (H1 : ∀ a b, R a b → S a b)
(H2 : ∀ s t, C s t → D s t) : ∀ {o p}, LiftRelO R C o p → LiftRelO S D o p
| none, none, _ => trivial
| some (_, _), some (_, _), h => And.imp (H1 _ _) (H2 _ _) h
| none, some _, h => False.elim h
| some (_, _), none, h => False.elim h
#align stream.wseq.lift_rel_o.imp Stream'.WSeq.LiftRelO.imp
theorem LiftRelO.imp_right (R : α → β → Prop) {C D : WSeq α → WSeq β → Prop}
(H : ∀ s t, C s t → D s t) {o p} : LiftRelO R C o p → LiftRelO R D o p :=
LiftRelO.imp (fun _ _ => id) H
#align stream.wseq.lift_rel_o.imp_right Stream'.WSeq.LiftRelO.imp_right
@[simp]
def BisimO (R : WSeq α → WSeq α → Prop) : Option (α × WSeq α) → Option (α × WSeq α) → Prop :=
LiftRelO (· = ·) R
#align stream.wseq.bisim_o Stream'.WSeq.BisimO
theorem BisimO.imp {R S : WSeq α → WSeq α → Prop} (H : ∀ s t, R s t → S s t) {o p} :
BisimO R o p → BisimO S o p :=
LiftRelO.imp_right _ H
#align stream.wseq.bisim_o.imp Stream'.WSeq.BisimO.imp
def LiftRel (R : α → β → Prop) (s : WSeq α) (t : WSeq β) : Prop :=
∃ C : WSeq α → WSeq β → Prop,
C s t ∧ ∀ {s t}, C s t → Computation.LiftRel (LiftRelO R C) (destruct s) (destruct t)
#align stream.wseq.lift_rel Stream'.WSeq.LiftRel
def Equiv : WSeq α → WSeq α → Prop :=
LiftRel (· = ·)
#align stream.wseq.equiv Stream'.WSeq.Equiv
theorem liftRel_destruct {R : α → β → Prop} {s : WSeq α} {t : WSeq β} :
LiftRel R s t → Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t)
| ⟨R, h1, h2⟩ => by
refine Computation.LiftRel.imp ?_ _ _ (h2 h1)
apply LiftRelO.imp_right
exact fun s' t' h' => ⟨R, h', @h2⟩
#align stream.wseq.lift_rel_destruct Stream'.WSeq.liftRel_destruct
theorem liftRel_destruct_iff {R : α → β → Prop} {s : WSeq α} {t : WSeq β} :
LiftRel R s t ↔ Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t) :=
⟨liftRel_destruct, fun h =>
⟨fun s t =>
LiftRel R s t ∨ Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t),
Or.inr h, fun {s t} h => by
have h : Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t) := by
cases' h with h h
· exact liftRel_destruct h
· assumption
apply Computation.LiftRel.imp _ _ _ h
intro a b
apply LiftRelO.imp_right
intro s t
apply Or.inl⟩⟩
#align stream.wseq.lift_rel_destruct_iff Stream'.WSeq.liftRel_destruct_iff
-- Porting note: To avoid ambiguous notation, `~` became `~ʷ`.
infixl:50 " ~ʷ " => Equiv
theorem destruct_congr {s t : WSeq α} :
s ~ʷ t → Computation.LiftRel (BisimO (· ~ʷ ·)) (destruct s) (destruct t) :=
liftRel_destruct
#align stream.wseq.destruct_congr Stream'.WSeq.destruct_congr
theorem destruct_congr_iff {s t : WSeq α} :
s ~ʷ t ↔ Computation.LiftRel (BisimO (· ~ʷ ·)) (destruct s) (destruct t) :=
liftRel_destruct_iff
#align stream.wseq.destruct_congr_iff Stream'.WSeq.destruct_congr_iff
theorem LiftRel.refl (R : α → α → Prop) (H : Reflexive R) : Reflexive (LiftRel R) := fun s => by
refine ⟨(· = ·), rfl, fun {s t} (h : s = t) => ?_⟩
rw [← h]
apply Computation.LiftRel.refl
intro a
cases' a with a
· simp
· cases a
simp only [LiftRelO, and_true]
apply H
#align stream.wseq.lift_rel.refl Stream'.WSeq.LiftRel.refl
theorem LiftRelO.swap (R : α → β → Prop) (C) :
swap (LiftRelO R C) = LiftRelO (swap R) (swap C) := by
funext x y
rcases x with ⟨⟩ | ⟨hx, jx⟩ <;> rcases y with ⟨⟩ | ⟨hy, jy⟩ <;> rfl
#align stream.wseq.lift_rel_o.swap Stream'.WSeq.LiftRelO.swap
theorem LiftRel.swap_lem {R : α → β → Prop} {s1 s2} (h : LiftRel R s1 s2) :
LiftRel (swap R) s2 s1 := by
refine ⟨swap (LiftRel R), h, fun {s t} (h : LiftRel R t s) => ?_⟩
rw [← LiftRelO.swap, Computation.LiftRel.swap]
apply liftRel_destruct h
#align stream.wseq.lift_rel.swap_lem Stream'.WSeq.LiftRel.swap_lem
theorem LiftRel.swap (R : α → β → Prop) : swap (LiftRel R) = LiftRel (swap R) :=
funext fun _ => funext fun _ => propext ⟨LiftRel.swap_lem, LiftRel.swap_lem⟩
#align stream.wseq.lift_rel.swap Stream'.WSeq.LiftRel.swap
theorem LiftRel.symm (R : α → α → Prop) (H : Symmetric R) : Symmetric (LiftRel R) :=
fun s1 s2 (h : Function.swap (LiftRel R) s2 s1) => by rwa [LiftRel.swap, H.swap_eq] at h
#align stream.wseq.lift_rel.symm Stream'.WSeq.LiftRel.symm
theorem LiftRel.trans (R : α → α → Prop) (H : Transitive R) : Transitive (LiftRel R) :=
fun s t u h1 h2 => by
refine ⟨fun s u => ∃ t, LiftRel R s t ∧ LiftRel R t u, ⟨t, h1, h2⟩, fun {s u} h => ?_⟩
rcases h with ⟨t, h1, h2⟩
have h1 := liftRel_destruct h1
have h2 := liftRel_destruct h2
refine
Computation.liftRel_def.2
⟨(Computation.terminates_of_liftRel h1).trans (Computation.terminates_of_liftRel h2),
fun {a c} ha hc => ?_⟩
rcases h1.left ha with ⟨b, hb, t1⟩
have t2 := Computation.rel_of_liftRel h2 hb hc
cases' a with a <;> cases' c with c
· trivial
· cases b
· cases t2
· cases t1
· cases a
cases' b with b
· cases t1
· cases b
cases t2
· cases' a with a s
cases' b with b
· cases t1
cases' b with b t
cases' c with c u
cases' t1 with ab st
cases' t2 with bc tu
exact ⟨H ab bc, t, st, tu⟩
#align stream.wseq.lift_rel.trans Stream'.WSeq.LiftRel.trans
theorem LiftRel.equiv (R : α → α → Prop) : Equivalence R → Equivalence (LiftRel R)
| ⟨refl, symm, trans⟩ => ⟨LiftRel.refl R refl, @(LiftRel.symm R @symm), @(LiftRel.trans R @trans)⟩
#align stream.wseq.lift_rel.equiv Stream'.WSeq.LiftRel.equiv
@[refl]
theorem Equiv.refl : ∀ s : WSeq α, s ~ʷ s :=
LiftRel.refl (· = ·) Eq.refl
#align stream.wseq.equiv.refl Stream'.WSeq.Equiv.refl
@[symm]
theorem Equiv.symm : ∀ {s t : WSeq α}, s ~ʷ t → t ~ʷ s :=
@(LiftRel.symm (· = ·) (@Eq.symm _))
#align stream.wseq.equiv.symm Stream'.WSeq.Equiv.symm
@[trans]
theorem Equiv.trans : ∀ {s t u : WSeq α}, s ~ʷ t → t ~ʷ u → s ~ʷ u :=
@(LiftRel.trans (· = ·) (@Eq.trans _))
#align stream.wseq.equiv.trans Stream'.WSeq.Equiv.trans
theorem Equiv.equivalence : Equivalence (@Equiv α) :=
⟨@Equiv.refl _, @Equiv.symm _, @Equiv.trans _⟩
#align stream.wseq.equiv.equivalence Stream'.WSeq.Equiv.equivalence
open Computation
@[simp]
theorem destruct_nil : destruct (nil : WSeq α) = Computation.pure none :=
Computation.destruct_eq_pure rfl
#align stream.wseq.destruct_nil Stream'.WSeq.destruct_nil
@[simp]
theorem destruct_cons (a : α) (s) : destruct (cons a s) = Computation.pure (some (a, s)) :=
Computation.destruct_eq_pure <| by simp [destruct, cons, Computation.rmap]
#align stream.wseq.destruct_cons Stream'.WSeq.destruct_cons
@[simp]
theorem destruct_think (s : WSeq α) : destruct (think s) = (destruct s).think :=
Computation.destruct_eq_think <| by simp [destruct, think, Computation.rmap]
#align stream.wseq.destruct_think Stream'.WSeq.destruct_think
@[simp]
theorem seq_destruct_nil : Seq.destruct (nil : WSeq α) = none :=
Seq.destruct_nil
#align stream.wseq.seq_destruct_nil Stream'.WSeq.seq_destruct_nil
@[simp]
theorem seq_destruct_cons (a : α) (s) : Seq.destruct (cons a s) = some (some a, s) :=
Seq.destruct_cons _ _
#align stream.wseq.seq_destruct_cons Stream'.WSeq.seq_destruct_cons
@[simp]
theorem seq_destruct_think (s : WSeq α) : Seq.destruct (think s) = some (none, s) :=
Seq.destruct_cons _ _
#align stream.wseq.seq_destruct_think Stream'.WSeq.seq_destruct_think
@[simp]
theorem head_nil : head (nil : WSeq α) = Computation.pure none := by simp [head]
#align stream.wseq.head_nil Stream'.WSeq.head_nil
@[simp]
theorem head_cons (a : α) (s) : head (cons a s) = Computation.pure (some a) := by simp [head]
#align stream.wseq.head_cons Stream'.WSeq.head_cons
@[simp]
theorem head_think (s : WSeq α) : head (think s) = (head s).think := by simp [head]
#align stream.wseq.head_think Stream'.WSeq.head_think
@[simp]
theorem flatten_pure (s : WSeq α) : flatten (Computation.pure s) = s := by
refine Seq.eq_of_bisim (fun s1 s2 => flatten (Computation.pure s2) = s1) ?_ rfl
intro s' s h
rw [← h]
simp only [Seq.BisimO, flatten, Seq.omap, pure_def, Seq.corec_eq, destruct_pure]
cases Seq.destruct s with
| none => simp
| some val =>
cases' val with o s'
simp
#align stream.wseq.flatten_ret Stream'.WSeq.flatten_pure
@[simp]
theorem flatten_think (c : Computation (WSeq α)) : flatten c.think = think (flatten c) :=
Seq.destruct_eq_cons <| by simp [flatten, think]
#align stream.wseq.flatten_think Stream'.WSeq.flatten_think
@[simp]
theorem destruct_flatten (c : Computation (WSeq α)) : destruct (flatten c) = c >>= destruct := by
refine
Computation.eq_of_bisim
(fun c1 c2 => c1 = c2 ∨ ∃ c, c1 = destruct (flatten c) ∧ c2 = Computation.bind c destruct) ?_
(Or.inr ⟨c, rfl, rfl⟩)
intro c1 c2 h
exact
match c1, c2, h with
| c, _, Or.inl rfl => by cases c.destruct <;> simp
| _, _, Or.inr ⟨c, rfl, rfl⟩ => by
induction' c using Computation.recOn with a c' <;> simp
· cases (destruct a).destruct <;> simp
· exact Or.inr ⟨c', rfl, rfl⟩
#align stream.wseq.destruct_flatten Stream'.WSeq.destruct_flatten
theorem head_terminates_iff (s : WSeq α) : Terminates (head s) ↔ Terminates (destruct s) :=
terminates_map_iff _ (destruct s)
#align stream.wseq.head_terminates_iff Stream'.WSeq.head_terminates_iff
@[simp]
theorem tail_nil : tail (nil : WSeq α) = nil := by simp [tail]
#align stream.wseq.tail_nil Stream'.WSeq.tail_nil
@[simp]
theorem tail_cons (a : α) (s) : tail (cons a s) = s := by simp [tail]
#align stream.wseq.tail_cons Stream'.WSeq.tail_cons
@[simp]
theorem tail_think (s : WSeq α) : tail (think s) = (tail s).think := by simp [tail]
#align stream.wseq.tail_think Stream'.WSeq.tail_think
@[simp]
theorem dropn_nil (n) : drop (nil : WSeq α) n = nil := by induction n <;> simp [*, drop]
#align stream.wseq.dropn_nil Stream'.WSeq.dropn_nil
@[simp]
theorem dropn_cons (a : α) (s) (n) : drop (cons a s) (n + 1) = drop s n := by
induction n with
| zero => simp [drop]
| succ n n_ih =>
-- porting note (#10745): was `simp [*, drop]`.
simp [drop, ← n_ih]
#align stream.wseq.dropn_cons Stream'.WSeq.dropn_cons
@[simp]
theorem dropn_think (s : WSeq α) (n) : drop (think s) n = (drop s n).think := by
induction n <;> simp [*, drop]
#align stream.wseq.dropn_think Stream'.WSeq.dropn_think
theorem dropn_add (s : WSeq α) (m) : ∀ n, drop s (m + n) = drop (drop s m) n
| 0 => rfl
| n + 1 => congr_arg tail (dropn_add s m n)
#align stream.wseq.dropn_add Stream'.WSeq.dropn_add
theorem dropn_tail (s : WSeq α) (n) : drop (tail s) n = drop s (n + 1) := by
rw [Nat.add_comm]
symm
apply dropn_add
#align stream.wseq.dropn_tail Stream'.WSeq.dropn_tail
theorem get?_add (s : WSeq α) (m n) : get? s (m + n) = get? (drop s m) n :=
congr_arg head (dropn_add _ _ _)
#align stream.wseq.nth_add Stream'.WSeq.get?_add
theorem get?_tail (s : WSeq α) (n) : get? (tail s) n = get? s (n + 1) :=
congr_arg head (dropn_tail _ _)
#align stream.wseq.nth_tail Stream'.WSeq.get?_tail
@[simp]
theorem join_nil : join nil = (nil : WSeq α) :=
Seq.join_nil
#align stream.wseq.join_nil Stream'.WSeq.join_nil
@[simp]
theorem join_think (S : WSeq (WSeq α)) : join (think S) = think (join S) := by
simp only [join, think]
dsimp only [(· <$> ·)]
simp [join, Seq1.ret]
#align stream.wseq.join_think Stream'.WSeq.join_think
@[simp]
theorem join_cons (s : WSeq α) (S) : join (cons s S) = think (append s (join S)) := by
simp only [join, think]
dsimp only [(· <$> ·)]
simp [join, cons, append]
#align stream.wseq.join_cons Stream'.WSeq.join_cons
@[simp]
theorem nil_append (s : WSeq α) : append nil s = s :=
Seq.nil_append _
#align stream.wseq.nil_append Stream'.WSeq.nil_append
@[simp]
theorem cons_append (a : α) (s t) : append (cons a s) t = cons a (append s t) :=
Seq.cons_append _ _ _
#align stream.wseq.cons_append Stream'.WSeq.cons_append
@[simp]
theorem think_append (s t : WSeq α) : append (think s) t = think (append s t) :=
Seq.cons_append _ _ _
#align stream.wseq.think_append Stream'.WSeq.think_append
@[simp]
theorem append_nil (s : WSeq α) : append s nil = s :=
Seq.append_nil _
#align stream.wseq.append_nil Stream'.WSeq.append_nil
@[simp]
theorem append_assoc (s t u : WSeq α) : append (append s t) u = append s (append t u) :=
Seq.append_assoc _ _ _
#align stream.wseq.append_assoc Stream'.WSeq.append_assoc
@[simp]
def tail.aux : Option (α × WSeq α) → Computation (Option (α × WSeq α))
| none => Computation.pure none
| some (_, s) => destruct s
#align stream.wseq.tail.aux Stream'.WSeq.tail.aux
theorem destruct_tail (s : WSeq α) : destruct (tail s) = destruct s >>= tail.aux := by
simp only [tail, destruct_flatten, tail.aux]; rw [← bind_pure_comp, LawfulMonad.bind_assoc]
apply congr_arg; ext1 (_ | ⟨a, s⟩) <;> apply (@pure_bind Computation _ _ _ _ _ _).trans _ <;> simp
#align stream.wseq.destruct_tail Stream'.WSeq.destruct_tail
@[simp]
def drop.aux : ℕ → Option (α × WSeq α) → Computation (Option (α × WSeq α))
| 0 => Computation.pure
| n + 1 => fun a => tail.aux a >>= drop.aux n
#align stream.wseq.drop.aux Stream'.WSeq.drop.aux
theorem drop.aux_none : ∀ n, @drop.aux α n none = Computation.pure none
| 0 => rfl
| n + 1 =>
show Computation.bind (Computation.pure none) (drop.aux n) = Computation.pure none by
rw [ret_bind, drop.aux_none n]
#align stream.wseq.drop.aux_none Stream'.WSeq.drop.aux_none
theorem destruct_dropn : ∀ (s : WSeq α) (n), destruct (drop s n) = destruct s >>= drop.aux n
| s, 0 => (bind_pure' _).symm
| s, n + 1 => by
rw [← dropn_tail, destruct_dropn _ n, destruct_tail, LawfulMonad.bind_assoc]
rfl
#align stream.wseq.destruct_dropn Stream'.WSeq.destruct_dropn
theorem head_terminates_of_head_tail_terminates (s : WSeq α) [T : Terminates (head (tail s))] :
Terminates (head s) :=
(head_terminates_iff _).2 <| by
rcases (head_terminates_iff _).1 T with ⟨⟨a, h⟩⟩
simp? [tail] at h says simp only [tail, destruct_flatten] at h
rcases exists_of_mem_bind h with ⟨s', h1, _⟩
unfold Functor.map at h1
exact
let ⟨t, h3, _⟩ := Computation.exists_of_mem_map h1
Computation.terminates_of_mem h3
#align stream.wseq.head_terminates_of_head_tail_terminates Stream'.WSeq.head_terminates_of_head_tail_terminates
theorem destruct_some_of_destruct_tail_some {s : WSeq α} {a} (h : some a ∈ destruct (tail s)) :
∃ a', some a' ∈ destruct s := by
unfold tail Functor.map at h; simp only [destruct_flatten] at h
rcases exists_of_mem_bind h with ⟨t, tm, td⟩; clear h
rcases Computation.exists_of_mem_map tm with ⟨t', ht', ht2⟩; clear tm
cases' t' with t' <;> rw [← ht2] at td <;> simp only [destruct_nil] at td
· have := mem_unique td (ret_mem _)
contradiction
· exact ⟨_, ht'⟩
#align stream.wseq.destruct_some_of_destruct_tail_some Stream'.WSeq.destruct_some_of_destruct_tail_some
theorem head_some_of_head_tail_some {s : WSeq α} {a} (h : some a ∈ head (tail s)) :
∃ a', some a' ∈ head s := by
unfold head at h
rcases Computation.exists_of_mem_map h with ⟨o, md, e⟩; clear h
cases' o with o <;> [injection e; injection e with h']; clear h'
cases' destruct_some_of_destruct_tail_some md with a am
exact ⟨_, Computation.mem_map (@Prod.fst α (WSeq α) <$> ·) am⟩
#align stream.wseq.head_some_of_head_tail_some Stream'.WSeq.head_some_of_head_tail_some
theorem head_some_of_get?_some {s : WSeq α} {a n} (h : some a ∈ get? s n) :
∃ a', some a' ∈ head s := by
induction n generalizing a with
| zero => exact ⟨_, h⟩
| succ n IH =>
let ⟨a', h'⟩ := head_some_of_head_tail_some h
exact IH h'
#align stream.wseq.head_some_of_nth_some Stream'.WSeq.head_some_of_get?_some
instance productive_tail (s : WSeq α) [Productive s] : Productive (tail s) :=
⟨fun n => by rw [get?_tail]; infer_instance⟩
#align stream.wseq.productive_tail Stream'.WSeq.productive_tail
instance productive_dropn (s : WSeq α) [Productive s] (n) : Productive (drop s n) :=
⟨fun m => by rw [← get?_add]; infer_instance⟩
#align stream.wseq.productive_dropn Stream'.WSeq.productive_dropn
def toSeq (s : WSeq α) [Productive s] : Seq α :=
⟨fun n => (get? s n).get,
fun {n} h => by
cases e : Computation.get (get? s (n + 1))
· assumption
have := Computation.mem_of_get_eq _ e
simp? [get?] at this h says simp only [get?] at this h
cases' head_some_of_head_tail_some this with a' h'
have := mem_unique h' (@Computation.mem_of_get_eq _ _ _ _ h)
contradiction⟩
#align stream.wseq.to_seq Stream'.WSeq.toSeq
| Mathlib/Data/Seq/WSeq.lean | 893 | 896 | theorem get?_terminates_le {s : WSeq α} {m n} (h : m ≤ n) :
Terminates (get? s n) → Terminates (get? s m) := by |
induction' h with m' _ IH
exacts [id, fun T => IH (@head_terminates_of_head_tail_terminates _ _ T)]
|
import Mathlib.Algebra.GeomSum
import Mathlib.Algebra.Order.Ring.Basic
import Mathlib.Algebra.Ring.Int
import Mathlib.NumberTheory.Padics.PadicVal
import Mathlib.RingTheory.Ideal.Quotient
#align_import number_theory.multiplicity from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
open Ideal Ideal.Quotient Finset
variable {R : Type*} {n : ℕ}
section CommRing
variable [CommRing R] {a b x y : R}
theorem dvd_geom_sum₂_iff_of_dvd_sub {x y p : R} (h : p ∣ x - y) :
(p ∣ ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i)) ↔ p ∣ n * y ^ (n - 1) := by
rw [← mem_span_singleton, ← Ideal.Quotient.eq] at h
simp only [← mem_span_singleton, ← eq_zero_iff_mem, RingHom.map_geom_sum₂, h, geom_sum₂_self,
_root_.map_mul, map_pow, map_natCast]
#align dvd_geom_sum₂_iff_of_dvd_sub dvd_geom_sum₂_iff_of_dvd_sub
theorem dvd_geom_sum₂_iff_of_dvd_sub' {x y p : R} (h : p ∣ x - y) :
(p ∣ ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i)) ↔ p ∣ n * x ^ (n - 1) := by
rw [geom_sum₂_comm, dvd_geom_sum₂_iff_of_dvd_sub]; simpa using h.neg_right
#align dvd_geom_sum₂_iff_of_dvd_sub' dvd_geom_sum₂_iff_of_dvd_sub'
theorem dvd_geom_sum₂_self {x y : R} (h : ↑n ∣ x - y) :
↑n ∣ ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i) :=
(dvd_geom_sum₂_iff_of_dvd_sub h).mpr (dvd_mul_right _ _)
#align dvd_geom_sum₂_self dvd_geom_sum₂_self
| Mathlib/NumberTheory/Multiplicity.lean | 56 | 71 | theorem sq_dvd_add_pow_sub_sub (p x : R) (n : ℕ) :
p ^ 2 ∣ (x + p) ^ n - x ^ (n - 1) * p * n - x ^ n := by |
cases' n with n n
· simp only [pow_zero, Nat.cast_zero, sub_zero, sub_self, dvd_zero, Nat.zero_eq, mul_zero]
· simp only [Nat.succ_sub_succ_eq_sub, tsub_zero, Nat.cast_succ, add_pow, Finset.sum_range_succ,
Nat.choose_self, Nat.succ_sub _, tsub_self, pow_one, Nat.choose_succ_self_right, pow_zero,
mul_one, Nat.cast_zero, zero_add, Nat.succ_eq_add_one, add_tsub_cancel_left]
suffices p ^ 2 ∣ ∑ i ∈ range n, x ^ i * p ^ (n + 1 - i) * ↑((n + 1).choose i) by
convert this; abel
apply Finset.dvd_sum
intro y hy
calc
p ^ 2 ∣ p ^ (n + 1 - y) :=
pow_dvd_pow p (le_tsub_of_add_le_left (by linarith [Finset.mem_range.mp hy]))
_ ∣ x ^ y * p ^ (n + 1 - y) * ↑((n + 1).choose y) :=
dvd_mul_of_dvd_left (dvd_mul_left _ _) _
|
import Mathlib.Algebra.Polynomial.RingDivision
import Mathlib.RingTheory.Polynomial.Nilpotent
open scoped Classical Polynomial
open Polynomial
noncomputable section
| Mathlib/RingTheory/Polynomial/IrreducibleRing.lean | 37 | 61 | theorem Polynomial.Monic.irreducible_of_irreducible_map_of_isPrime_nilradical
{R S : Type*} [CommRing R] [(nilradical R).IsPrime] [CommRing S] [IsDomain S]
(φ : R →+* S) (f : R[X]) (hm : f.Monic) (hi : Irreducible (f.map φ)) : Irreducible f := by |
let R' := R ⧸ nilradical R
let ψ : R' →+* S := Ideal.Quotient.lift (nilradical R) φ
(haveI := RingHom.ker_isPrime φ; nilradical_le_prime (RingHom.ker φ))
let ι := algebraMap R R'
rw [show φ = ψ.comp ι from rfl, ← map_map] at hi
replace hi := hm.map ι |>.irreducible_of_irreducible_map _ _ hi
refine ⟨fun h ↦ hi.1 <| (mapRingHom ι).isUnit_map h, fun a b h ↦ ?_⟩
wlog hb : IsUnit (b.map ι) generalizing a b
· exact (this b a (mul_comm a b ▸ h)
(hi.2 _ _ (by rw [h, Polynomial.map_mul]) |>.resolve_right hb)).symm
have hn (i : ℕ) (hi : i ≠ 0) : IsNilpotent (b.coeff i) := by
obtain ⟨_, _, h⟩ := Polynomial.isUnit_iff.1 hb
simpa only [coeff_map, coeff_C, hi, ite_false, ← RingHom.mem_ker,
show RingHom.ker ι = nilradical R from Ideal.mk_ker] using congr(coeff $(h.symm) i)
refine .inr <| isUnit_of_coeff_isUnit_isNilpotent (isUnit_of_mul_isUnit_right
(x := a.coeff f.natDegree) <| (IsUnit.neg_iff _).1 ?_) hn
have hc : f.leadingCoeff = _ := congr(coeff $h f.natDegree)
rw [hm, coeff_mul, Finset.Nat.sum_antidiagonal_eq_sum_range_succ fun i j ↦ a.coeff i * b.coeff j,
Finset.sum_range_succ, ← sub_eq_iff_eq_add, Nat.sub_self] at hc
rw [← add_sub_cancel_left 1 (-(_ * _)), ← sub_eq_add_neg, hc]
exact IsNilpotent.isUnit_sub_one <| show _ ∈ nilradical R from sum_mem fun i hi ↦
Ideal.mul_mem_left _ _ <| hn _ <| Nat.sub_ne_zero_of_lt (List.mem_range.1 hi)
|
import Mathlib.Algebra.BigOperators.Intervals
import Mathlib.Algebra.BigOperators.Ring.List
import Mathlib.Data.Int.ModEq
import Mathlib.Data.Nat.Bits
import Mathlib.Data.Nat.Log
import Mathlib.Data.List.Indexes
import Mathlib.Data.List.Palindrome
import Mathlib.Tactic.IntervalCases
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring
#align_import data.nat.digits from "leanprover-community/mathlib"@"369525b73f229ccd76a6ec0e0e0bf2be57599768"
namespace Nat
variable {n : ℕ}
def digitsAux0 : ℕ → List ℕ
| 0 => []
| n + 1 => [n + 1]
#align nat.digits_aux_0 Nat.digitsAux0
def digitsAux1 (n : ℕ) : List ℕ :=
List.replicate n 1
#align nat.digits_aux_1 Nat.digitsAux1
def digitsAux (b : ℕ) (h : 2 ≤ b) : ℕ → List ℕ
| 0 => []
| n + 1 =>
((n + 1) % b) :: digitsAux b h ((n + 1) / b)
decreasing_by exact Nat.div_lt_self (Nat.succ_pos _) h
#align nat.digits_aux Nat.digitsAux
@[simp]
theorem digitsAux_zero (b : ℕ) (h : 2 ≤ b) : digitsAux b h 0 = [] := by rw [digitsAux]
#align nat.digits_aux_zero Nat.digitsAux_zero
theorem digitsAux_def (b : ℕ) (h : 2 ≤ b) (n : ℕ) (w : 0 < n) :
digitsAux b h n = (n % b) :: digitsAux b h (n / b) := by
cases n
· cases w
· rw [digitsAux]
#align nat.digits_aux_def Nat.digitsAux_def
def digits : ℕ → ℕ → List ℕ
| 0 => digitsAux0
| 1 => digitsAux1
| b + 2 => digitsAux (b + 2) (by norm_num)
#align nat.digits Nat.digits
@[simp]
theorem digits_zero (b : ℕ) : digits b 0 = [] := by
rcases b with (_ | ⟨_ | ⟨_⟩⟩) <;> simp [digits, digitsAux0, digitsAux1]
#align nat.digits_zero Nat.digits_zero
-- @[simp] -- Porting note (#10618): simp can prove this
theorem digits_zero_zero : digits 0 0 = [] :=
rfl
#align nat.digits_zero_zero Nat.digits_zero_zero
@[simp]
theorem digits_zero_succ (n : ℕ) : digits 0 n.succ = [n + 1] :=
rfl
#align nat.digits_zero_succ Nat.digits_zero_succ
theorem digits_zero_succ' : ∀ {n : ℕ}, n ≠ 0 → digits 0 n = [n]
| 0, h => (h rfl).elim
| _ + 1, _ => rfl
#align nat.digits_zero_succ' Nat.digits_zero_succ'
@[simp]
theorem digits_one (n : ℕ) : digits 1 n = List.replicate n 1 :=
rfl
#align nat.digits_one Nat.digits_one
-- @[simp] -- Porting note (#10685): dsimp can prove this
theorem digits_one_succ (n : ℕ) : digits 1 (n + 1) = 1 :: digits 1 n :=
rfl
#align nat.digits_one_succ Nat.digits_one_succ
theorem digits_add_two_add_one (b n : ℕ) :
digits (b + 2) (n + 1) = ((n + 1) % (b + 2)) :: digits (b + 2) ((n + 1) / (b + 2)) := by
simp [digits, digitsAux_def]
#align nat.digits_add_two_add_one Nat.digits_add_two_add_one
@[simp]
lemma digits_of_two_le_of_pos {b : ℕ} (hb : 2 ≤ b) (hn : 0 < n) :
Nat.digits b n = n % b :: Nat.digits b (n / b) := by
rw [Nat.eq_add_of_sub_eq hb rfl, Nat.eq_add_of_sub_eq hn rfl, Nat.digits_add_two_add_one]
theorem digits_def' :
∀ {b : ℕ} (_ : 1 < b) {n : ℕ} (_ : 0 < n), digits b n = (n % b) :: digits b (n / b)
| 0, h => absurd h (by decide)
| 1, h => absurd h (by decide)
| b + 2, _ => digitsAux_def _ (by simp) _
#align nat.digits_def' Nat.digits_def'
@[simp]
theorem digits_of_lt (b x : ℕ) (hx : x ≠ 0) (hxb : x < b) : digits b x = [x] := by
rcases exists_eq_succ_of_ne_zero hx with ⟨x, rfl⟩
rcases Nat.exists_eq_add_of_le' ((Nat.le_add_left 1 x).trans_lt hxb) with ⟨b, rfl⟩
rw [digits_add_two_add_one, div_eq_of_lt hxb, digits_zero, mod_eq_of_lt hxb]
#align nat.digits_of_lt Nat.digits_of_lt
theorem digits_add (b : ℕ) (h : 1 < b) (x y : ℕ) (hxb : x < b) (hxy : x ≠ 0 ∨ y ≠ 0) :
digits b (x + b * y) = x :: digits b y := by
rcases Nat.exists_eq_add_of_le' h with ⟨b, rfl : _ = _ + 2⟩
cases y
· simp [hxb, hxy.resolve_right (absurd rfl)]
dsimp [digits]
rw [digitsAux_def]
· congr
· simp [Nat.add_mod, mod_eq_of_lt hxb]
· simp [add_mul_div_left, div_eq_of_lt hxb]
· apply Nat.succ_pos
#align nat.digits_add Nat.digits_add
-- If we had a function converting a list into a polynomial,
-- and appropriate lemmas about that function,
-- we could rewrite this in terms of that.
def ofDigits {α : Type*} [Semiring α] (b : α) : List ℕ → α
| [] => 0
| h :: t => h + b * ofDigits b t
#align nat.of_digits Nat.ofDigits
theorem ofDigits_eq_foldr {α : Type*} [Semiring α] (b : α) (L : List ℕ) :
ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L := by
induction' L with d L ih
· rfl
· dsimp [ofDigits]
rw [ih]
#align nat.of_digits_eq_foldr Nat.ofDigits_eq_foldr
theorem ofDigits_eq_sum_map_with_index_aux (b : ℕ) (l : List ℕ) :
((List.range l.length).zipWith ((fun i a : ℕ => a * b ^ (i + 1))) l).sum =
b * ((List.range l.length).zipWith (fun i a => a * b ^ i) l).sum := by
suffices
(List.range l.length).zipWith (fun i a : ℕ => a * b ^ (i + 1)) l =
(List.range l.length).zipWith (fun i a => b * (a * b ^ i)) l
by simp [this]
congr; ext; simp [pow_succ]; ring
#align nat.of_digits_eq_sum_map_with_index_aux Nat.ofDigits_eq_sum_map_with_index_aux
theorem ofDigits_eq_sum_mapIdx (b : ℕ) (L : List ℕ) :
ofDigits b L = (L.mapIdx fun i a => a * b ^ i).sum := by
rw [List.mapIdx_eq_enum_map, List.enum_eq_zip_range, List.map_uncurry_zip_eq_zipWith,
ofDigits_eq_foldr]
induction' L with hd tl hl
· simp
· simpa [List.range_succ_eq_map, List.zipWith_map_left, ofDigits_eq_sum_map_with_index_aux] using
Or.inl hl
#align nat.of_digits_eq_sum_map_with_index Nat.ofDigits_eq_sum_mapIdx
@[simp]
theorem ofDigits_nil {b : ℕ} : ofDigits b [] = 0 := rfl
@[simp]
theorem ofDigits_singleton {b n : ℕ} : ofDigits b [n] = n := by simp [ofDigits]
#align nat.of_digits_singleton Nat.ofDigits_singleton
@[simp]
theorem ofDigits_one_cons {α : Type*} [Semiring α] (h : ℕ) (L : List ℕ) :
ofDigits (1 : α) (h :: L) = h + ofDigits 1 L := by simp [ofDigits]
#align nat.of_digits_one_cons Nat.ofDigits_one_cons
theorem ofDigits_cons {b hd} {tl : List ℕ} :
ofDigits b (hd :: tl) = hd + b * ofDigits b tl := rfl
theorem ofDigits_append {b : ℕ} {l1 l2 : List ℕ} :
ofDigits b (l1 ++ l2) = ofDigits b l1 + b ^ l1.length * ofDigits b l2 := by
induction' l1 with hd tl IH
· simp [ofDigits]
· rw [ofDigits, List.cons_append, ofDigits, IH, List.length_cons, pow_succ']
ring
#align nat.of_digits_append Nat.ofDigits_append
@[norm_cast]
theorem coe_ofDigits (α : Type*) [Semiring α] (b : ℕ) (L : List ℕ) :
((ofDigits b L : ℕ) : α) = ofDigits (b : α) L := by
induction' L with d L ih
· simp [ofDigits]
· dsimp [ofDigits]; push_cast; rw [ih]
#align nat.coe_of_digits Nat.coe_ofDigits
@[norm_cast]
theorem coe_int_ofDigits (b : ℕ) (L : List ℕ) : ((ofDigits b L : ℕ) : ℤ) = ofDigits (b : ℤ) L := by
induction' L with d L _
· rfl
· dsimp [ofDigits]; push_cast; simp only
#align nat.coe_int_of_digits Nat.coe_int_ofDigits
theorem digits_zero_of_eq_zero {b : ℕ} (h : b ≠ 0) :
∀ {L : List ℕ} (_ : ofDigits b L = 0), ∀ l ∈ L, l = 0
| _ :: _, h0, _, List.Mem.head .. => Nat.eq_zero_of_add_eq_zero_right h0
| _ :: _, h0, _, List.Mem.tail _ hL =>
digits_zero_of_eq_zero h (mul_right_injective₀ h (Nat.eq_zero_of_add_eq_zero_left h0)) _ hL
#align nat.digits_zero_of_eq_zero Nat.digits_zero_of_eq_zero
theorem digits_ofDigits (b : ℕ) (h : 1 < b) (L : List ℕ) (w₁ : ∀ l ∈ L, l < b)
(w₂ : ∀ h : L ≠ [], L.getLast h ≠ 0) : digits b (ofDigits b L) = L := by
induction' L with d L ih
· dsimp [ofDigits]
simp
· dsimp [ofDigits]
replace w₂ := w₂ (by simp)
rw [digits_add b h]
· rw [ih]
· intro l m
apply w₁
exact List.mem_cons_of_mem _ m
· intro h
rw [List.getLast_cons h] at w₂
convert w₂
· exact w₁ d (List.mem_cons_self _ _)
· by_cases h' : L = []
· rcases h' with rfl
left
simpa using w₂
· right
contrapose! w₂
refine digits_zero_of_eq_zero h.ne_bot w₂ _ ?_
rw [List.getLast_cons h']
exact List.getLast_mem h'
#align nat.digits_of_digits Nat.digits_ofDigits
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
cases' b with b
· cases' n with n
· rfl
· change ofDigits 0 [n + 1] = n + 1
dsimp [ofDigits]
· cases' b with b
· induction' n with n ih
· rfl
· rw [Nat.zero_add] at ih ⊢
simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
· apply Nat.strongInductionOn n _
clear n
intro n h
cases n
· rw [digits_zero]
rfl
· simp only [Nat.succ_eq_add_one, digits_add_two_add_one]
dsimp [ofDigits]
rw [h _ (Nat.div_lt_self' _ b)]
rw [Nat.mod_add_div]
#align nat.of_digits_digits Nat.ofDigits_digits
theorem ofDigits_one (L : List ℕ) : ofDigits 1 L = L.sum := by
induction' L with _ _ ih
· rfl
· simp [ofDigits, List.sum_cons, ih]
#align nat.of_digits_one Nat.ofDigits_one
theorem digits_eq_nil_iff_eq_zero {b n : ℕ} : digits b n = [] ↔ n = 0 := by
constructor
· intro h
have : ofDigits b (digits b n) = ofDigits b [] := by rw [h]
convert this
rw [ofDigits_digits]
· rintro rfl
simp
#align nat.digits_eq_nil_iff_eq_zero Nat.digits_eq_nil_iff_eq_zero
theorem digits_ne_nil_iff_ne_zero {b n : ℕ} : digits b n ≠ [] ↔ n ≠ 0 :=
not_congr digits_eq_nil_iff_eq_zero
#align nat.digits_ne_nil_iff_ne_zero Nat.digits_ne_nil_iff_ne_zero
theorem digits_eq_cons_digits_div {b n : ℕ} (h : 1 < b) (w : n ≠ 0) :
digits b n = (n % b) :: digits b (n / b) := by
rcases b with (_ | _ | b)
· rw [digits_zero_succ' w, Nat.mod_zero, Nat.div_zero, Nat.digits_zero_zero]
· norm_num at h
rcases n with (_ | n)
· norm_num at w
· simp only [digits_add_two_add_one, ne_eq]
#align nat.digits_eq_cons_digits_div Nat.digits_eq_cons_digits_div
theorem digits_getLast {b : ℕ} (m : ℕ) (h : 1 < b) (p q) :
(digits b m).getLast p = (digits b (m / b)).getLast q := by
by_cases hm : m = 0
· simp [hm]
simp only [digits_eq_cons_digits_div h hm]
rw [List.getLast_cons]
#align nat.digits_last Nat.digits_getLast
theorem digits.injective (b : ℕ) : Function.Injective b.digits :=
Function.LeftInverse.injective (ofDigits_digits b)
#align nat.digits.injective Nat.digits.injective
@[simp]
theorem digits_inj_iff {b n m : ℕ} : b.digits n = b.digits m ↔ n = m :=
(digits.injective b).eq_iff
#align nat.digits_inj_iff Nat.digits_inj_iff
theorem digits_len (b n : ℕ) (hb : 1 < b) (hn : n ≠ 0) : (b.digits n).length = b.log n + 1 := by
induction' n using Nat.strong_induction_on with n IH
rw [digits_eq_cons_digits_div hb hn, List.length]
by_cases h : n / b = 0
· have hb0 : b ≠ 0 := (Nat.succ_le_iff.1 hb).ne_bot
simp [h, log_eq_zero_iff, ← Nat.div_eq_zero_iff hb0.bot_lt]
· have : n / b < n := div_lt_self (Nat.pos_of_ne_zero hn) hb
rw [IH _ this h, log_div_base, tsub_add_cancel_of_le]
refine Nat.succ_le_of_lt (log_pos hb ?_)
contrapose! h
exact div_eq_of_lt h
#align nat.digits_len Nat.digits_len
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
(digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
rcases b with (_ | _ | b)
· cases m
· cases hm rfl
· simp
· cases m
· cases hm rfl
rename ℕ => m
simp only [zero_add, digits_one, List.getLast_replicate_succ m 1]
exact Nat.one_ne_zero
revert hm
apply Nat.strongInductionOn m
intro n IH hn
by_cases hnb : n < b + 2
· simpa only [digits_of_lt (b + 2) n hn hnb]
· rw [digits_getLast n (le_add_left 2 b)]
refine IH _ (Nat.div_lt_self hn.bot_lt (one_lt_succ_succ b)) ?_
rw [← pos_iff_ne_zero]
exact Nat.div_pos (le_of_not_lt hnb) (zero_lt_succ (succ b))
#align nat.last_digit_ne_zero Nat.getLast_digit_ne_zero
theorem mul_ofDigits (n : ℕ) {b : ℕ} {l : List ℕ} :
n * ofDigits b l = ofDigits b (l.map (n * ·)) := by
induction l with
| nil => rfl
| cons hd tl ih =>
rw [List.map_cons, ofDigits_cons, ofDigits_cons, ← ih]
ring
theorem ofDigits_add_ofDigits_eq_ofDigits_zipWith_of_length_eq {b : ℕ} {l1 l2 : List ℕ}
(h : l1.length = l2.length) :
ofDigits b l1 + ofDigits b l2 = ofDigits b (l1.zipWith (· + ·) l2) := by
induction l1 generalizing l2 with
| nil => simp_all [eq_comm, List.length_eq_zero, ofDigits]
| cons hd₁ tl₁ ih₁ =>
induction l2 generalizing tl₁ with
| nil => simp_all
| cons hd₂ tl₂ ih₂ =>
simp_all only [List.length_cons, succ_eq_add_one, ofDigits_cons, add_left_inj,
eq_comm, List.zipWith_cons_cons, add_eq]
rw [← ih₁ h.symm, mul_add]
ac_rfl
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
apply Nat.strongInductionOn m
intro n IH d hd
cases' n with n
· rw [digits_zero] at hd
cases hd
-- base b+2 expansion of 0 has no digits
rw [digits_add_two_add_one] at hd
cases hd
· exact n.succ.mod_lt (by simp)
-- Porting note: Previous code (single line) contained linarith.
-- . exact IH _ (Nat.div_lt_self (Nat.succ_pos _) (by linarith)) hd
· apply IH ((n + 1) / (b + 2))
· apply Nat.div_lt_self <;> omega
· assumption
#align nat.digits_lt_base' Nat.digits_lt_base'
theorem digits_lt_base {b m d : ℕ} (hb : 1 < b) (hd : d ∈ digits b m) : d < b := by
rcases b with (_ | _ | b) <;> try simp_all
exact digits_lt_base' hd
#align nat.digits_lt_base Nat.digits_lt_base
theorem ofDigits_lt_base_pow_length' {b : ℕ} {l : List ℕ} (hl : ∀ x ∈ l, x < b + 2) :
ofDigits (b + 2) l < (b + 2) ^ l.length := by
induction' l with hd tl IH
· simp [ofDigits]
· rw [ofDigits, List.length_cons, pow_succ]
have : (ofDigits (b + 2) tl + 1) * (b + 2) ≤ (b + 2) ^ tl.length * (b + 2) :=
mul_le_mul (IH fun x hx => hl _ (List.mem_cons_of_mem _ hx)) (by rfl) (by simp only [zero_le])
(Nat.zero_le _)
suffices ↑hd < b + 2 by linarith
exact hl hd (List.mem_cons_self _ _)
#align nat.of_digits_lt_base_pow_length' Nat.ofDigits_lt_base_pow_length'
theorem ofDigits_lt_base_pow_length {b : ℕ} {l : List ℕ} (hb : 1 < b) (hl : ∀ x ∈ l, x < b) :
ofDigits b l < b ^ l.length := by
rcases b with (_ | _ | b) <;> try simp_all
exact ofDigits_lt_base_pow_length' hl
#align nat.of_digits_lt_base_pow_length Nat.ofDigits_lt_base_pow_length
theorem lt_base_pow_length_digits' {b m : ℕ} : m < (b + 2) ^ (digits (b + 2) m).length := by
convert @ofDigits_lt_base_pow_length' b (digits (b + 2) m) fun _ => digits_lt_base'
rw [ofDigits_digits (b + 2) m]
#align nat.lt_base_pow_length_digits' Nat.lt_base_pow_length_digits'
theorem lt_base_pow_length_digits {b m : ℕ} (hb : 1 < b) : m < b ^ (digits b m).length := by
rcases b with (_ | _ | b) <;> try simp_all
exact lt_base_pow_length_digits'
#align nat.lt_base_pow_length_digits Nat.lt_base_pow_length_digits
theorem ofDigits_digits_append_digits {b m n : ℕ} :
ofDigits b (digits b n ++ digits b m) = n + b ^ (digits b n).length * m := by
rw [ofDigits_append, ofDigits_digits, ofDigits_digits]
#align nat.of_digits_digits_append_digits Nat.ofDigits_digits_append_digits
theorem digits_append_digits {b m n : ℕ} (hb : 0 < b) :
digits b n ++ digits b m = digits b (n + b ^ (digits b n).length * m) := by
rcases eq_or_lt_of_le (Nat.succ_le_of_lt hb) with (rfl | hb)
· simp [List.replicate_add]
rw [← ofDigits_digits_append_digits]
refine (digits_ofDigits b hb _ (fun l hl => ?_) (fun h_append => ?_)).symm
· rcases (List.mem_append.mp hl) with (h | h) <;> exact digits_lt_base hb h
· by_cases h : digits b m = []
· simp only [h, List.append_nil] at h_append ⊢
exact getLast_digit_ne_zero b <| digits_ne_nil_iff_ne_zero.mp h_append
· exact (List.getLast_append' _ _ h) ▸
(getLast_digit_ne_zero _ <| digits_ne_nil_iff_ne_zero.mp h)
theorem digits_len_le_digits_len_succ (b n : ℕ) :
(digits b n).length ≤ (digits b (n + 1)).length := by
rcases Decidable.eq_or_ne n 0 with (rfl | hn)
· simp
rcases le_or_lt b 1 with hb | hb
· interval_cases b <;> simp_arith [digits_zero_succ', hn]
simpa [digits_len, hb, hn] using log_mono_right (le_succ _)
#align nat.digits_len_le_digits_len_succ Nat.digits_len_le_digits_len_succ
theorem le_digits_len_le (b n m : ℕ) (h : n ≤ m) : (digits b n).length ≤ (digits b m).length :=
monotone_nat_of_le_succ (digits_len_le_digits_len_succ b) h
#align nat.le_digits_len_le Nat.le_digits_len_le
@[mono]
theorem ofDigits_monotone {p q : ℕ} (L : List ℕ) (h : p ≤ q) : ofDigits p L ≤ ofDigits q L := by
induction' L with _ _ hi
· rfl
· simp only [ofDigits, cast_id, add_le_add_iff_left]
exact Nat.mul_le_mul h hi
theorem sum_le_ofDigits {p : ℕ} (L : List ℕ) (h : 1 ≤ p) : L.sum ≤ ofDigits p L :=
(ofDigits_one L).symm ▸ ofDigits_monotone L h
theorem digit_sum_le (p n : ℕ) : List.sum (digits p n) ≤ n := by
induction' n with n
· exact digits_zero _ ▸ Nat.le_refl (List.sum [])
· induction' p with p
· rw [digits_zero_succ, List.sum_cons, List.sum_nil, add_zero]
· nth_rw 2 [← ofDigits_digits p.succ (n + 1)]
rw [← ofDigits_one <| digits p.succ n.succ]
exact ofDigits_monotone (digits p.succ n.succ) <| Nat.succ_pos p
theorem pow_length_le_mul_ofDigits {b : ℕ} {l : List ℕ} (hl : l ≠ []) (hl2 : l.getLast hl ≠ 0) :
(b + 2) ^ l.length ≤ (b + 2) * ofDigits (b + 2) l := by
rw [← List.dropLast_append_getLast hl]
simp only [List.length_append, List.length, zero_add, List.length_dropLast, ofDigits_append,
List.length_dropLast, ofDigits_singleton, add_comm (l.length - 1), pow_add, pow_one]
apply Nat.mul_le_mul_left
refine le_trans ?_ (Nat.le_add_left _ _)
have : 0 < l.getLast hl := by rwa [pos_iff_ne_zero]
convert Nat.mul_le_mul_left ((b + 2) ^ (l.length - 1)) this using 1
rw [Nat.mul_one]
#align nat.pow_length_le_mul_of_digits Nat.pow_length_le_mul_ofDigits
theorem base_pow_length_digits_le' (b m : ℕ) (hm : m ≠ 0) :
(b + 2) ^ (digits (b + 2) m).length ≤ (b + 2) * m := by
have : digits (b + 2) m ≠ [] := digits_ne_nil_iff_ne_zero.mpr hm
convert @pow_length_le_mul_ofDigits b (digits (b+2) m)
this (getLast_digit_ne_zero _ hm)
rw [ofDigits_digits]
#align nat.base_pow_length_digits_le' Nat.base_pow_length_digits_le'
theorem base_pow_length_digits_le (b m : ℕ) (hb : 1 < b) :
m ≠ 0 → b ^ (digits b m).length ≤ b * m := by
rcases b with (_ | _ | b) <;> try simp_all
exact base_pow_length_digits_le' b m
#align nat.base_pow_length_digits_le Nat.base_pow_length_digits_le
lemma ofDigits_div_eq_ofDigits_tail {p : ℕ} (hpos : 0 < p) (digits : List ℕ)
(w₁ : ∀ l ∈ digits, l < p) : ofDigits p digits / p = ofDigits p digits.tail := by
induction' digits with hd tl
· simp [ofDigits]
· refine Eq.trans (add_mul_div_left hd _ hpos) ?_
rw [Nat.div_eq_of_lt <| w₁ _ <| List.mem_cons_self _ _, zero_add]
rfl
lemma ofDigits_div_pow_eq_ofDigits_drop
{p : ℕ} (i : ℕ) (hpos : 0 < p) (digits : List ℕ) (w₁ : ∀ l ∈ digits, l < p) :
ofDigits p digits / p ^ i = ofDigits p (digits.drop i) := by
induction' i with i hi
· simp
· rw [Nat.pow_succ, ← Nat.div_div_eq_div_mul, hi, ofDigits_div_eq_ofDigits_tail hpos
(List.drop i digits) fun x hx ↦ w₁ x <| List.mem_of_mem_drop hx, ← List.drop_one,
List.drop_drop, add_comm]
lemma self_div_pow_eq_ofDigits_drop {p : ℕ} (i n : ℕ) (h : 2 ≤ p):
n / p ^ i = ofDigits p ((p.digits n).drop i) := by
convert ofDigits_div_pow_eq_ofDigits_drop i (zero_lt_of_lt h) (p.digits n)
(fun l hl ↦ digits_lt_base h hl)
exact (ofDigits_digits p n).symm
open Finset
theorem sub_one_mul_sum_div_pow_eq_sub_sum_digits {p : ℕ}
(L : List ℕ) {h_nonempty} (h_ne_zero : L.getLast h_nonempty ≠ 0) (h_lt : ∀ l ∈ L, l < p) :
(p - 1) * ∑ i ∈ range L.length, (ofDigits p L) / p ^ i.succ = (ofDigits p L) - L.sum := by
obtain h | rfl | h : 1 < p ∨ 1 = p ∨ p < 1 := trichotomous 1 p
· induction' L with hd tl ih
· simp [ofDigits]
· simp only [List.length_cons, List.sum_cons, self_div_pow_eq_ofDigits_drop _ _ h,
digits_ofDigits p h (hd :: tl) h_lt (fun _ => h_ne_zero)]
simp only [ofDigits]
rw [sum_range_succ, Nat.cast_id]
simp only [List.drop, List.drop_length]
obtain rfl | h' := em <| tl = []
· simp [ofDigits]
· have w₁' := fun l hl ↦ h_lt l <| List.mem_cons_of_mem hd hl
have w₂' := fun (h : tl ≠ []) ↦ (List.getLast_cons h) ▸ h_ne_zero
have ih := ih (w₂' h') w₁'
simp only [self_div_pow_eq_ofDigits_drop _ _ h, digits_ofDigits p h tl w₁' w₂',
← Nat.one_add] at ih
have := sum_singleton (fun x ↦ ofDigits p <| tl.drop x) tl.length
rw [← Ico_succ_singleton, List.drop_length, ofDigits] at this
have h₁ : 1 ≤ tl.length := List.length_pos.mpr h'
rw [← sum_range_add_sum_Ico _ <| h₁, ← add_zero (∑ x ∈ Ico _ _, ofDigits p (tl.drop x)),
← this, sum_Ico_consecutive _ h₁ <| (le_add_right tl.length 1),
← sum_Ico_add _ 0 tl.length 1,
Ico_zero_eq_range, mul_add, mul_add, ih, range_one, sum_singleton, List.drop, ofDigits,
mul_zero, add_zero, ← Nat.add_sub_assoc <| sum_le_ofDigits _ <| Nat.le_of_lt h]
nth_rw 2 [← one_mul <| ofDigits p tl]
rw [← add_mul, one_eq_succ_zero, Nat.sub_add_cancel <| zero_lt_of_lt h,
Nat.add_sub_add_left]
· simp [ofDigits_one]
· simp [lt_one_iff.mp h]
cases L
· rfl
· simp [ofDigits]
theorem sub_one_mul_sum_log_div_pow_eq_sub_sum_digits {p : ℕ} (n : ℕ) :
(p - 1) * ∑ i ∈ range (log p n).succ, n / p ^ i.succ = n - (p.digits n).sum := by
obtain h | rfl | h : 1 < p ∨ 1 = p ∨ p < 1 := trichotomous 1 p
· rcases eq_or_ne n 0 with rfl | hn
· simp
· convert sub_one_mul_sum_div_pow_eq_sub_sum_digits (p.digits n) (getLast_digit_ne_zero p hn) <|
(fun l a ↦ digits_lt_base h a)
· refine (digits_len p n h hn).symm
all_goals exact (ofDigits_digits p n).symm
· simp
· simp [lt_one_iff.mp h]
cases n
all_goals simp
theorem digits_two_eq_bits (n : ℕ) : digits 2 n = n.bits.map fun b => cond b 1 0 := by
induction' n using Nat.binaryRecFromOne with b n h ih
· simp
· rfl
rw [bits_append_bit _ _ fun hn => absurd hn h]
cases b
· rw [digits_def' one_lt_two]
· simpa [Nat.bit, Nat.bit0_val n]
· simpa [pos_iff_ne_zero, Nat.bit0_eq_zero]
· simpa [Nat.bit, Nat.bit1_val n, add_comm, digits_add 2 one_lt_two 1 n, Nat.add_mul_div_left]
#align nat.digits_two_eq_bits Nat.digits_two_eq_bits
-- This is really a theorem about polynomials.
theorem dvd_ofDigits_sub_ofDigits {α : Type*} [CommRing α] {a b k : α} (h : k ∣ a - b)
(L : List ℕ) : k ∣ ofDigits a L - ofDigits b L := by
induction' L with d L ih
· change k ∣ 0 - 0
simp
· simp only [ofDigits, add_sub_add_left_eq_sub]
exact dvd_mul_sub_mul h ih
#align nat.dvd_of_digits_sub_of_digits Nat.dvd_ofDigits_sub_ofDigits
theorem ofDigits_modEq' (b b' : ℕ) (k : ℕ) (h : b ≡ b' [MOD k]) (L : List ℕ) :
ofDigits b L ≡ ofDigits b' L [MOD k] := by
induction' L with d L ih
· rfl
· dsimp [ofDigits]
dsimp [Nat.ModEq] at *
conv_lhs => rw [Nat.add_mod, Nat.mul_mod, h, ih]
conv_rhs => rw [Nat.add_mod, Nat.mul_mod]
#align nat.of_digits_modeq' Nat.ofDigits_modEq'
theorem ofDigits_modEq (b k : ℕ) (L : List ℕ) : ofDigits b L ≡ ofDigits (b % k) L [MOD k] :=
ofDigits_modEq' b (b % k) k (b.mod_modEq k).symm L
#align nat.of_digits_modeq Nat.ofDigits_modEq
theorem ofDigits_mod (b k : ℕ) (L : List ℕ) : ofDigits b L % k = ofDigits (b % k) L % k :=
ofDigits_modEq b k L
#align nat.of_digits_mod Nat.ofDigits_mod
| Mathlib/Data/Nat/Digits.lean | 666 | 667 | theorem ofDigits_mod_eq_head! (b : ℕ) (l : List ℕ) : ofDigits b l % b = l.head! % b := by |
induction l <;> simp [Nat.ofDigits, Int.ModEq]
|
import Mathlib.RingTheory.IntegralClosure
import Mathlib.RingTheory.FractionalIdeal.Basic
#align_import ring_theory.fractional_ideal from "leanprover-community/mathlib"@"ed90a7d327c3a5caf65a6faf7e8a0d63c4605df7"
open IsLocalization Pointwise nonZeroDivisors
namespace FractionalIdeal
open Set Submodule
variable {R : Type*} [CommRing R] {S : Submonoid R} {P : Type*} [CommRing P]
variable [Algebra R P] [loc : IsLocalization S P]
section
variable {P' : Type*} [CommRing P'] [Algebra R P'] [loc' : IsLocalization S P']
variable {P'' : Type*} [CommRing P''] [Algebra R P''] [loc'' : IsLocalization S P'']
theorem _root_.IsFractional.map (g : P →ₐ[R] P') {I : Submodule R P} :
IsFractional S I → IsFractional S (Submodule.map g.toLinearMap I)
| ⟨a, a_nonzero, hI⟩ =>
⟨a, a_nonzero, fun b hb => by
obtain ⟨b', b'_mem, hb'⟩ := Submodule.mem_map.mp hb
rw [AlgHom.toLinearMap_apply] at hb'
obtain ⟨x, hx⟩ := hI b' b'_mem
use x
rw [← g.commutes, hx, g.map_smul, hb']⟩
#align is_fractional.map IsFractional.map
def map (g : P →ₐ[R] P') : FractionalIdeal S P → FractionalIdeal S P' := fun I =>
⟨Submodule.map g.toLinearMap I, I.isFractional.map g⟩
#align fractional_ideal.map FractionalIdeal.map
@[simp, norm_cast]
theorem coe_map (g : P →ₐ[R] P') (I : FractionalIdeal S P) :
↑(map g I) = Submodule.map g.toLinearMap I :=
rfl
#align fractional_ideal.coe_map FractionalIdeal.coe_map
@[simp]
theorem mem_map {I : FractionalIdeal S P} {g : P →ₐ[R] P'} {y : P'} :
y ∈ I.map g ↔ ∃ x, x ∈ I ∧ g x = y :=
Submodule.mem_map
#align fractional_ideal.mem_map FractionalIdeal.mem_map
variable (I J : FractionalIdeal S P) (g : P →ₐ[R] P')
@[simp]
theorem map_id : I.map (AlgHom.id _ _) = I :=
coeToSubmodule_injective (Submodule.map_id (I : Submodule R P))
#align fractional_ideal.map_id FractionalIdeal.map_id
@[simp]
theorem map_comp (g' : P' →ₐ[R] P'') : I.map (g'.comp g) = (I.map g).map g' :=
coeToSubmodule_injective (Submodule.map_comp g.toLinearMap g'.toLinearMap I)
#align fractional_ideal.map_comp FractionalIdeal.map_comp
@[simp, norm_cast]
theorem map_coeIdeal (I : Ideal R) : (I : FractionalIdeal S P).map g = I := by
ext x
simp only [mem_coeIdeal]
constructor
· rintro ⟨_, ⟨y, hy, rfl⟩, rfl⟩
exact ⟨y, hy, (g.commutes y).symm⟩
· rintro ⟨y, hy, rfl⟩
exact ⟨_, ⟨y, hy, rfl⟩, g.commutes y⟩
#align fractional_ideal.map_coe_ideal FractionalIdeal.map_coeIdeal
@[simp]
theorem map_one : (1 : FractionalIdeal S P).map g = 1 :=
map_coeIdeal g ⊤
#align fractional_ideal.map_one FractionalIdeal.map_one
@[simp]
theorem map_zero : (0 : FractionalIdeal S P).map g = 0 :=
map_coeIdeal g 0
#align fractional_ideal.map_zero FractionalIdeal.map_zero
@[simp]
theorem map_add : (I + J).map g = I.map g + J.map g :=
coeToSubmodule_injective (Submodule.map_sup _ _ _)
#align fractional_ideal.map_add FractionalIdeal.map_add
@[simp]
theorem map_mul : (I * J).map g = I.map g * J.map g := by
simp only [mul_def]
exact coeToSubmodule_injective (Submodule.map_mul _ _ _)
#align fractional_ideal.map_mul FractionalIdeal.map_mul
@[simp]
theorem map_map_symm (g : P ≃ₐ[R] P') : (I.map (g : P →ₐ[R] P')).map (g.symm : P' →ₐ[R] P) = I := by
rw [← map_comp, g.symm_comp, map_id]
#align fractional_ideal.map_map_symm FractionalIdeal.map_map_symm
@[simp]
theorem map_symm_map (I : FractionalIdeal S P') (g : P ≃ₐ[R] P') :
(I.map (g.symm : P' →ₐ[R] P)).map (g : P →ₐ[R] P') = I := by
rw [← map_comp, g.comp_symm, map_id]
#align fractional_ideal.map_symm_map FractionalIdeal.map_symm_map
theorem map_mem_map {f : P →ₐ[R] P'} (h : Function.Injective f) {x : P} {I : FractionalIdeal S P} :
f x ∈ map f I ↔ x ∈ I :=
mem_map.trans ⟨fun ⟨_, hx', x'_eq⟩ => h x'_eq ▸ hx', fun h => ⟨x, h, rfl⟩⟩
#align fractional_ideal.map_mem_map FractionalIdeal.map_mem_map
theorem map_injective (f : P →ₐ[R] P') (h : Function.Injective f) :
Function.Injective (map f : FractionalIdeal S P → FractionalIdeal S P') := fun _ _ hIJ =>
ext fun _ => (map_mem_map h).symm.trans (hIJ.symm ▸ map_mem_map h)
#align fractional_ideal.map_injective FractionalIdeal.map_injective
def mapEquiv (g : P ≃ₐ[R] P') : FractionalIdeal S P ≃+* FractionalIdeal S P' where
toFun := map g
invFun := map g.symm
map_add' I J := map_add I J _
map_mul' I J := map_mul I J _
left_inv I := by rw [← map_comp, AlgEquiv.symm_comp, map_id]
right_inv I := by rw [← map_comp, AlgEquiv.comp_symm, map_id]
#align fractional_ideal.map_equiv FractionalIdeal.mapEquiv
@[simp]
theorem coeFun_mapEquiv (g : P ≃ₐ[R] P') :
(mapEquiv g : FractionalIdeal S P → FractionalIdeal S P') = map g :=
rfl
#align fractional_ideal.coe_fun_map_equiv FractionalIdeal.coeFun_mapEquiv
@[simp]
theorem mapEquiv_apply (g : P ≃ₐ[R] P') (I : FractionalIdeal S P) : mapEquiv g I = map (↑g) I :=
rfl
#align fractional_ideal.map_equiv_apply FractionalIdeal.mapEquiv_apply
@[simp]
theorem mapEquiv_symm (g : P ≃ₐ[R] P') :
((mapEquiv g).symm : FractionalIdeal S P' ≃+* _) = mapEquiv g.symm :=
rfl
#align fractional_ideal.map_equiv_symm FractionalIdeal.mapEquiv_symm
@[simp]
theorem mapEquiv_refl : mapEquiv AlgEquiv.refl = RingEquiv.refl (FractionalIdeal S P) :=
RingEquiv.ext fun x => by simp
#align fractional_ideal.map_equiv_refl FractionalIdeal.mapEquiv_refl
theorem isFractional_span_iff {s : Set P} :
IsFractional S (span R s) ↔ ∃ a ∈ S, ∀ b : P, b ∈ s → IsInteger R (a • b) :=
⟨fun ⟨a, a_mem, h⟩ => ⟨a, a_mem, fun b hb => h b (subset_span hb)⟩, fun ⟨a, a_mem, h⟩ =>
⟨a, a_mem, fun b hb =>
span_induction hb h
(by
rw [smul_zero]
exact isInteger_zero)
(fun x y hx hy => by
rw [smul_add]
exact isInteger_add hx hy)
fun s x hx => by
rw [smul_comm]
exact isInteger_smul hx⟩⟩
#align fractional_ideal.is_fractional_span_iff FractionalIdeal.isFractional_span_iff
theorem isFractional_of_fg {I : Submodule R P} (hI : I.FG) : IsFractional S I := by
rcases hI with ⟨I, rfl⟩
rcases exist_integer_multiples_of_finset S I with ⟨⟨s, hs1⟩, hs⟩
rw [isFractional_span_iff]
exact ⟨s, hs1, hs⟩
#align fractional_ideal.is_fractional_of_fg FractionalIdeal.isFractional_of_fg
theorem mem_span_mul_finite_of_mem_mul {I J : FractionalIdeal S P} {x : P} (hx : x ∈ I * J) :
∃ T T' : Finset P, (T : Set P) ⊆ I ∧ (T' : Set P) ⊆ J ∧ x ∈ span R (T * T' : Set P) :=
Submodule.mem_span_mul_finite_of_mem_mul (by simpa using mem_coe.mpr hx)
#align fractional_ideal.mem_span_mul_finite_of_mem_mul FractionalIdeal.mem_span_mul_finite_of_mem_mul
variable (S)
theorem coeIdeal_fg (inj : Function.Injective (algebraMap R P)) (I : Ideal R) :
FG ((I : FractionalIdeal S P) : Submodule R P) ↔ I.FG :=
coeSubmodule_fg _ inj _
#align fractional_ideal.coe_ideal_fg FractionalIdeal.coeIdeal_fg
variable {S}
theorem fg_unit (I : (FractionalIdeal S P)ˣ) : FG (I : Submodule R P) :=
Submodule.fg_unit <| Units.map (coeSubmoduleHom S P).toMonoidHom I
#align fractional_ideal.fg_unit FractionalIdeal.fg_unit
theorem fg_of_isUnit (I : FractionalIdeal S P) (h : IsUnit I) : FG (I : Submodule R P) :=
fg_unit h.unit
#align fractional_ideal.fg_of_is_unit FractionalIdeal.fg_of_isUnit
theorem _root_.Ideal.fg_of_isUnit (inj : Function.Injective (algebraMap R P)) (I : Ideal R)
(h : IsUnit (I : FractionalIdeal S P)) : I.FG := by
rw [← coeIdeal_fg S inj I]
exact FractionalIdeal.fg_of_isUnit I h
#align ideal.fg_of_is_unit Ideal.fg_of_isUnit
variable (S P P')
noncomputable irreducible_def canonicalEquiv : FractionalIdeal S P ≃+* FractionalIdeal S P' :=
mapEquiv
{ ringEquivOfRingEquiv P P' (RingEquiv.refl R)
(show S.map _ = S by rw [RingEquiv.toMonoidHom_refl, Submonoid.map_id]) with
commutes' := fun r => ringEquivOfRingEquiv_eq _ _ }
#align fractional_ideal.canonical_equiv FractionalIdeal.canonicalEquiv
@[simp]
theorem mem_canonicalEquiv_apply {I : FractionalIdeal S P} {x : P'} :
x ∈ canonicalEquiv S P P' I ↔
∃ y ∈ I,
IsLocalization.map P' (RingHom.id R) (fun y (hy : y ∈ S) => show RingHom.id R y ∈ S from hy)
(y : P) =
x := by
rw [canonicalEquiv, mapEquiv_apply, mem_map]
exact ⟨fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩, fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩⟩
#align fractional_ideal.mem_canonical_equiv_apply FractionalIdeal.mem_canonicalEquiv_apply
@[simp]
theorem canonicalEquiv_symm : (canonicalEquiv S P P').symm = canonicalEquiv S P' P :=
RingEquiv.ext fun I =>
SetLike.ext_iff.mpr fun x => by
rw [mem_canonicalEquiv_apply, canonicalEquiv, mapEquiv_symm, mapEquiv_apply,
mem_map]
exact ⟨fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩, fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩⟩
#align fractional_ideal.canonical_equiv_symm FractionalIdeal.canonicalEquiv_symm
theorem canonicalEquiv_flip (I) : canonicalEquiv S P P' (canonicalEquiv S P' P I) = I := by
rw [← canonicalEquiv_symm]; erw [RingEquiv.apply_symm_apply]
#align fractional_ideal.canonical_equiv_flip FractionalIdeal.canonicalEquiv_flip
@[simp]
theorem canonicalEquiv_canonicalEquiv (P'' : Type*) [CommRing P''] [Algebra R P'']
[IsLocalization S P''] (I : FractionalIdeal S P) :
canonicalEquiv S P' P'' (canonicalEquiv S P P' I) = canonicalEquiv S P P'' I := by
ext
simp only [IsLocalization.map_map, RingHomInvPair.comp_eq₂, mem_canonicalEquiv_apply,
exists_prop, exists_exists_and_eq_and]
#align fractional_ideal.canonical_equiv_canonical_equiv FractionalIdeal.canonicalEquiv_canonicalEquiv
theorem canonicalEquiv_trans_canonicalEquiv (P'' : Type*) [CommRing P''] [Algebra R P'']
[IsLocalization S P''] :
(canonicalEquiv S P P').trans (canonicalEquiv S P' P'') = canonicalEquiv S P P'' :=
RingEquiv.ext (canonicalEquiv_canonicalEquiv S P P' P'')
#align fractional_ideal.canonical_equiv_trans_canonical_equiv FractionalIdeal.canonicalEquiv_trans_canonicalEquiv
@[simp]
theorem canonicalEquiv_coeIdeal (I : Ideal R) : canonicalEquiv S P P' I = I := by
ext
simp [IsLocalization.map_eq]
#align fractional_ideal.canonical_equiv_coe_ideal FractionalIdeal.canonicalEquiv_coeIdeal
@[simp]
theorem canonicalEquiv_self : canonicalEquiv S P P = RingEquiv.refl _ := by
rw [← canonicalEquiv_trans_canonicalEquiv S P P]
convert (canonicalEquiv S P P).symm_trans_self
exact (canonicalEquiv_symm S P P).symm
#align fractional_ideal.canonical_equiv_self FractionalIdeal.canonicalEquiv_self
end
section PrincipalIdeal
variable {R₁ : Type*} [CommRing R₁] {K : Type*} [Field K]
variable [Algebra R₁ K] [IsFractionRing R₁ K]
open scoped Classical
variable (R₁)
-- Porting note: `@[simps]` generated a `Subtype.val` coercion instead of a
-- `FractionalIdeal.coeToSubmodule` coercion
def spanFinset {ι : Type*} (s : Finset ι) (f : ι → K) : FractionalIdeal R₁⁰ K :=
⟨Submodule.span R₁ (f '' s), by
obtain ⟨a', ha'⟩ := IsLocalization.exist_integer_multiples R₁⁰ s f
refine ⟨a', a'.2, fun x hx => Submodule.span_induction hx ?_ ?_ ?_ ?_⟩
· rintro _ ⟨i, hi, rfl⟩
exact ha' i hi
· rw [smul_zero]
exact IsLocalization.isInteger_zero
· intro x y hx hy
rw [smul_add]
exact IsLocalization.isInteger_add hx hy
· intro c x hx
rw [smul_comm]
exact IsLocalization.isInteger_smul hx⟩
#align fractional_ideal.span_finset FractionalIdeal.spanFinset
@[simp] lemma spanFinset_coe {ι : Type*} (s : Finset ι) (f : ι → K) :
(spanFinset R₁ s f : Submodule R₁ K) = Submodule.span R₁ (f '' s) :=
rfl
variable {R₁}
@[simp]
theorem spanFinset_eq_zero {ι : Type*} {s : Finset ι} {f : ι → K} :
spanFinset R₁ s f = 0 ↔ ∀ j ∈ s, f j = 0 := by
simp only [← coeToSubmodule_inj, spanFinset_coe, coe_zero, Submodule.span_eq_bot,
Set.mem_image, Finset.mem_coe, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂]
#align fractional_ideal.span_finset_eq_zero FractionalIdeal.spanFinset_eq_zero
theorem spanFinset_ne_zero {ι : Type*} {s : Finset ι} {f : ι → K} :
spanFinset R₁ s f ≠ 0 ↔ ∃ j ∈ s, f j ≠ 0 := by simp
#align fractional_ideal.span_finset_ne_zero FractionalIdeal.spanFinset_ne_zero
open Submodule.IsPrincipal
theorem isFractional_span_singleton (x : P) : IsFractional S (span R {x} : Submodule R P) :=
let ⟨a, ha⟩ := exists_integer_multiple S x
isFractional_span_iff.mpr ⟨a, a.2, fun _ hx' => (Set.mem_singleton_iff.mp hx').symm ▸ ha⟩
#align fractional_ideal.is_fractional_span_singleton FractionalIdeal.isFractional_span_singleton
variable (S)
irreducible_def spanSingleton (x : P) : FractionalIdeal S P :=
⟨span R {x}, isFractional_span_singleton x⟩
#align fractional_ideal.span_singleton FractionalIdeal.spanSingleton
-- local attribute [semireducible] span_singleton
@[simp]
theorem coe_spanSingleton (x : P) : (spanSingleton S x : Submodule R P) = span R {x} := by
rw [spanSingleton]
rfl
#align fractional_ideal.coe_span_singleton FractionalIdeal.coe_spanSingleton
@[simp]
theorem mem_spanSingleton {x y : P} : x ∈ spanSingleton S y ↔ ∃ z : R, z • y = x := by
rw [spanSingleton]
exact Submodule.mem_span_singleton
#align fractional_ideal.mem_span_singleton FractionalIdeal.mem_spanSingleton
theorem mem_spanSingleton_self (x : P) : x ∈ spanSingleton S x :=
(mem_spanSingleton S).mpr ⟨1, one_smul _ _⟩
#align fractional_ideal.mem_span_singleton_self FractionalIdeal.mem_spanSingleton_self
variable (P) in
theorem den_mul_self_eq_num' (I : FractionalIdeal S P) :
spanSingleton S (algebraMap R P I.den) * I = I.num := by
apply coeToSubmodule_injective
dsimp only
rw [coe_mul, ← smul_eq_mul, coe_spanSingleton, smul_eq_mul, Submodule.span_singleton_mul]
convert I.den_mul_self_eq_num using 1
ext
erw [Set.mem_smul_set, Set.mem_smul_set]
simp [Algebra.smul_def]
variable {S}
@[simp]
theorem spanSingleton_le_iff_mem {x : P} {I : FractionalIdeal S P} :
spanSingleton S x ≤ I ↔ x ∈ I := by
rw [← coe_le_coe, coe_spanSingleton, Submodule.span_singleton_le_iff_mem, mem_coe]
#align fractional_ideal.span_singleton_le_iff_mem FractionalIdeal.spanSingleton_le_iff_mem
theorem spanSingleton_eq_spanSingleton [NoZeroSMulDivisors R P] {x y : P} :
spanSingleton S x = spanSingleton S y ↔ ∃ z : Rˣ, z • x = y := by
rw [← Submodule.span_singleton_eq_span_singleton, spanSingleton, spanSingleton]
exact Subtype.mk_eq_mk
#align fractional_ideal.span_singleton_eq_span_singleton FractionalIdeal.spanSingleton_eq_spanSingleton
| Mathlib/RingTheory/FractionalIdeal/Operations.lean | 670 | 674 | theorem eq_spanSingleton_of_principal (I : FractionalIdeal S P) [IsPrincipal (I : Submodule R P)] :
I = spanSingleton S (generator (I : Submodule R P)) := by |
-- Porting note: this used to be `coeToSubmodule_injective (span_singleton_generator ↑I).symm`
-- but Lean 4 struggled to unify everything. Turned it into an explicit `rw`.
rw [spanSingleton, ← coeToSubmodule_inj, coe_mk, span_singleton_generator]
|
import Mathlib.CategoryTheory.Limits.Shapes.Pullbacks
import Mathlib.CategoryTheory.Limits.Preserves.Basic
#align_import category_theory.limits.preserves.shapes.pullbacks from "leanprover-community/mathlib"@"f11e306adb9f2a393539d2bb4293bf1b42caa7ac"
noncomputable section
universe v₁ v₂ u₁ u₂
-- Porting note: need Functor namespace for mapCone
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Functor
namespace CategoryTheory.Limits
section Pushout
variable {C : Type u₁} [Category.{v₁} C]
variable {D : Type u₂} [Category.{v₂} D]
variable (G : C ⥤ D)
variable {W X Y Z : C} {h : X ⟶ Z} {k : Y ⟶ Z} {f : W ⟶ X} {g : W ⟶ Y} (comm : f ≫ h = g ≫ k)
def isColimitMapCoconePushoutCoconeEquiv :
IsColimit (mapCocone G (PushoutCocone.mk h k comm)) ≃
IsColimit
(PushoutCocone.mk (G.map h) (G.map k) (by simp only [← G.map_comp, comm]) :
PushoutCocone (G.map f) (G.map g)) :=
(IsColimit.precomposeHomEquiv (diagramIsoSpan.{v₂} _).symm _).symm.trans <|
IsColimit.equivIsoColimit <|
Cocones.ext (Iso.refl _) <| by
rintro (_ | _ | _) <;> dsimp <;>
simp only [Category.comp_id, Category.id_comp, ← G.map_comp]
#align category_theory.limits.is_colimit_map_cocone_pushout_cocone_equiv CategoryTheory.Limits.isColimitMapCoconePushoutCoconeEquiv
def isColimitPushoutCoconeMapOfIsColimit [PreservesColimit (span f g) G]
(l : IsColimit (PushoutCocone.mk h k comm)) :
IsColimit (PushoutCocone.mk (G.map h) (G.map k) (show G.map f ≫ G.map h = G.map g ≫ G.map k
from by simp only [← G.map_comp,comm] )) :=
isColimitMapCoconePushoutCoconeEquiv G comm (PreservesColimit.preserves l)
#align category_theory.limits.is_colimit_pushout_cocone_map_of_is_colimit CategoryTheory.Limits.isColimitPushoutCoconeMapOfIsColimit
def isColimitOfIsColimitPushoutCoconeMap [ReflectsColimit (span f g) G]
(l : IsColimit (PushoutCocone.mk (G.map h) (G.map k) (show G.map f ≫ G.map h =
G.map g ≫ G.map k from by simp only [← G.map_comp,comm]))) :
IsColimit (PushoutCocone.mk h k comm) :=
ReflectsColimit.reflects ((isColimitMapCoconePushoutCoconeEquiv G comm).symm l)
#align category_theory.limits.is_colimit_of_is_colimit_pushout_cocone_map CategoryTheory.Limits.isColimitOfIsColimitPushoutCoconeMap
variable (f g) [PreservesColimit (span f g) G]
def isColimitOfHasPushoutOfPreservesColimit [i : HasPushout f g] :
IsColimit (PushoutCocone.mk (G.map pushout.inl) (G.map (@pushout.inr _ _ _ _ _ f g i))
(show G.map f ≫ G.map pushout.inl = G.map g ≫ G.map pushout.inr from by
simp only [← G.map_comp, pushout.condition])) :=
isColimitPushoutCoconeMapOfIsColimit G _ (pushoutIsPushout f g)
#align category_theory.limits.is_colimit_of_has_pushout_of_preserves_colimit CategoryTheory.Limits.isColimitOfHasPushoutOfPreservesColimit
def preservesPushoutSymmetry : PreservesColimit (span g f) G where
preserves {c} hc := by
apply (IsColimit.precomposeHomEquiv (diagramIsoSpan.{v₂} _).symm _).toFun
apply IsColimit.ofIsoColimit _ (PushoutCocone.isoMk _).symm
apply PushoutCocone.isColimitOfFlip
apply (isColimitMapCoconePushoutCoconeEquiv _ _).toFun
· refine @PreservesColimit.preserves _ _ _ _ _ _ _ _ ?_ _ ?_ -- Porting note: more TC coddling
· dsimp
infer_instance
· exact PushoutCocone.flipIsColimit hc
#align category_theory.limits.preserves_pushout_symmetry CategoryTheory.Limits.preservesPushoutSymmetry
theorem hasPushout_of_preservesPushout [HasPushout f g] : HasPushout (G.map f) (G.map g) :=
⟨⟨⟨_, isColimitPushoutCoconeMapOfIsColimit G _ (pushoutIsPushout _ _)⟩⟩⟩
#align category_theory.limits.has_pushout_of_preserves_pushout CategoryTheory.Limits.hasPushout_of_preservesPushout
variable [HasPushout f g] [HasPushout (G.map f) (G.map g)]
def PreservesPushout.iso : pushout (G.map f) (G.map g) ≅ G.obj (pushout f g) :=
IsColimit.coconePointUniqueUpToIso (colimit.isColimit _)
(isColimitOfHasPushoutOfPreservesColimit G f g)
#align category_theory.limits.preserves_pushout.iso CategoryTheory.Limits.PreservesPushout.iso
@[simp]
theorem PreservesPushout.iso_hom : (PreservesPushout.iso G f g).hom = pushoutComparison G f g :=
rfl
#align category_theory.limits.preserves_pushout.iso_hom CategoryTheory.Limits.PreservesPushout.iso_hom
@[reassoc]
| Mathlib/CategoryTheory/Limits/Preserves/Shapes/Pullbacks.lean | 225 | 228 | theorem PreservesPushout.inl_iso_hom :
pushout.inl ≫ (PreservesPushout.iso G f g).hom = G.map pushout.inl := by |
delta PreservesPushout.iso
simp
|
import Mathlib.Algebra.Bounds
import Mathlib.Algebra.Order.Field.Basic -- Porting note: `LinearOrderedField`, etc
import Mathlib.Data.Set.Pointwise.SMul
#align_import algebra.order.pointwise from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
open Function Set
open Pointwise
variable {α : Type*}
-- Porting note: Swapped the place of `CompleteLattice` and `ConditionallyCompleteLattice`
-- due to simpNF problem between `sSup_xx` `csSup_xx`.
section CompleteLattice
variable [CompleteLattice α]
section Group
variable [Group α] [CovariantClass α α (· * ·) (· ≤ ·)] [CovariantClass α α (swap (· * ·)) (· ≤ ·)]
{s t : Set α}
@[to_additive]
theorem csSup_inv (hs₀ : s.Nonempty) (hs₁ : BddBelow s) : sSup s⁻¹ = (sInf s)⁻¹ := by
rw [← image_inv]
exact ((OrderIso.inv α).map_csInf' hs₀ hs₁).symm
#align cSup_inv csSup_inv
#align cSup_neg csSup_neg
@[to_additive]
theorem csInf_inv (hs₀ : s.Nonempty) (hs₁ : BddAbove s) : sInf s⁻¹ = (sSup s)⁻¹ := by
rw [← image_inv]
exact ((OrderIso.inv α).map_csSup' hs₀ hs₁).symm
#align cInf_inv csInf_inv
#align cInf_neg csInf_neg
@[to_additive]
theorem csSup_mul (hs₀ : s.Nonempty) (hs₁ : BddAbove s) (ht₀ : t.Nonempty) (ht₁ : BddAbove t) :
sSup (s * t) = sSup s * sSup t :=
csSup_image2_eq_csSup_csSup (fun _ => (OrderIso.mulRight _).to_galoisConnection)
(fun _ => (OrderIso.mulLeft _).to_galoisConnection) hs₀ hs₁ ht₀ ht₁
#align cSup_mul csSup_mul
#align cSup_add csSup_add
@[to_additive]
theorem csInf_mul (hs₀ : s.Nonempty) (hs₁ : BddBelow s) (ht₀ : t.Nonempty) (ht₁ : BddBelow t) :
sInf (s * t) = sInf s * sInf t :=
csInf_image2_eq_csInf_csInf (fun _ => (OrderIso.mulRight _).symm.to_galoisConnection)
(fun _ => (OrderIso.mulLeft _).symm.to_galoisConnection) hs₀ hs₁ ht₀ ht₁
#align cInf_mul csInf_mul
#align cInf_add csInf_add
@[to_additive]
| Mathlib/Algebra/Order/Pointwise.lean | 160 | 162 | theorem csSup_div (hs₀ : s.Nonempty) (hs₁ : BddAbove s) (ht₀ : t.Nonempty) (ht₁ : BddBelow t) :
sSup (s / t) = sSup s / sInf t := by |
rw [div_eq_mul_inv, csSup_mul hs₀ hs₁ ht₀.inv ht₁.inv, csSup_inv ht₀ ht₁, div_eq_mul_inv]
|
import Mathlib.MeasureTheory.Measure.Restrict
open scoped ENNReal NNReal Topology
open Set MeasureTheory Measure Filter Function MeasurableSpace ENNReal
variable {α β δ ι : Type*}
namespace MeasureTheory
variable {m0 : MeasurableSpace α} [MeasurableSpace β] {μ ν ν₁ ν₂: Measure α}
{s t : Set α}
section IsFiniteMeasure
class IsFiniteMeasure (μ : Measure α) : Prop where
measure_univ_lt_top : μ univ < ∞
#align measure_theory.is_finite_measure MeasureTheory.IsFiniteMeasure
#align measure_theory.is_finite_measure.measure_univ_lt_top MeasureTheory.IsFiniteMeasure.measure_univ_lt_top
| Mathlib/MeasureTheory/Measure/Typeclasses.lean | 41 | 44 | theorem not_isFiniteMeasure_iff : ¬IsFiniteMeasure μ ↔ μ Set.univ = ∞ := by |
refine ⟨fun h => ?_, fun h => fun h' => h'.measure_univ_lt_top.ne h⟩
by_contra h'
exact h ⟨lt_top_iff_ne_top.mpr h'⟩
|
import Mathlib.CategoryTheory.NatIso
#align_import category_theory.bicategory.basic from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514"
namespace CategoryTheory
universe w v u
open Category Iso
-- intended to be used with explicit universe parameters
@[nolint checkUnivs]
class Bicategory (B : Type u) extends CategoryStruct.{v} B where
-- category structure on the collection of 1-morphisms:
homCategory : ∀ a b : B, Category.{w} (a ⟶ b) := by infer_instance
-- left whiskering:
whiskerLeft {a b c : B} (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) : f ≫ g ⟶ f ≫ h
-- right whiskering:
whiskerRight {a b c : B} {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) : f ≫ h ⟶ g ≫ h
-- associator:
associator {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) : (f ≫ g) ≫ h ≅ f ≫ g ≫ h
-- left unitor:
leftUnitor {a b : B} (f : a ⟶ b) : 𝟙 a ≫ f ≅ f
-- right unitor:
rightUnitor {a b : B} (f : a ⟶ b) : f ≫ 𝟙 b ≅ f
-- axioms for left whiskering:
whiskerLeft_id : ∀ {a b c} (f : a ⟶ b) (g : b ⟶ c), whiskerLeft f (𝟙 g) = 𝟙 (f ≫ g) := by
aesop_cat
whiskerLeft_comp :
∀ {a b c} (f : a ⟶ b) {g h i : b ⟶ c} (η : g ⟶ h) (θ : h ⟶ i),
whiskerLeft f (η ≫ θ) = whiskerLeft f η ≫ whiskerLeft f θ := by
aesop_cat
id_whiskerLeft :
∀ {a b} {f g : a ⟶ b} (η : f ⟶ g),
whiskerLeft (𝟙 a) η = (leftUnitor f).hom ≫ η ≫ (leftUnitor g).inv := by
aesop_cat
comp_whiskerLeft :
∀ {a b c d} (f : a ⟶ b) (g : b ⟶ c) {h h' : c ⟶ d} (η : h ⟶ h'),
whiskerLeft (f ≫ g) η =
(associator f g h).hom ≫ whiskerLeft f (whiskerLeft g η) ≫ (associator f g h').inv := by
aesop_cat
-- axioms for right whiskering:
id_whiskerRight : ∀ {a b c} (f : a ⟶ b) (g : b ⟶ c), whiskerRight (𝟙 f) g = 𝟙 (f ≫ g) := by
aesop_cat
comp_whiskerRight :
∀ {a b c} {f g h : a ⟶ b} (η : f ⟶ g) (θ : g ⟶ h) (i : b ⟶ c),
whiskerRight (η ≫ θ) i = whiskerRight η i ≫ whiskerRight θ i := by
aesop_cat
whiskerRight_id :
∀ {a b} {f g : a ⟶ b} (η : f ⟶ g),
whiskerRight η (𝟙 b) = (rightUnitor f).hom ≫ η ≫ (rightUnitor g).inv := by
aesop_cat
whiskerRight_comp :
∀ {a b c d} {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c) (h : c ⟶ d),
whiskerRight η (g ≫ h) =
(associator f g h).inv ≫ whiskerRight (whiskerRight η g) h ≫ (associator f' g h).hom := by
aesop_cat
-- associativity of whiskerings:
whisker_assoc :
∀ {a b c d} (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g') (h : c ⟶ d),
whiskerRight (whiskerLeft f η) h =
(associator f g h).hom ≫ whiskerLeft f (whiskerRight η h) ≫ (associator f g' h).inv := by
aesop_cat
-- exchange law of left and right whiskerings:
whisker_exchange :
∀ {a b c} {f g : a ⟶ b} {h i : b ⟶ c} (η : f ⟶ g) (θ : h ⟶ i),
whiskerLeft f θ ≫ whiskerRight η i = whiskerRight η h ≫ whiskerLeft g θ := by
aesop_cat
-- pentagon identity:
pentagon :
∀ {a b c d e} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e),
whiskerRight (associator f g h).hom i ≫
(associator f (g ≫ h) i).hom ≫ whiskerLeft f (associator g h i).hom =
(associator (f ≫ g) h i).hom ≫ (associator f g (h ≫ i)).hom := by
aesop_cat
-- triangle identity:
triangle :
∀ {a b c} (f : a ⟶ b) (g : b ⟶ c),
(associator f (𝟙 b) g).hom ≫ whiskerLeft f (leftUnitor g).hom
= whiskerRight (rightUnitor f).hom g := by
aesop_cat
#align category_theory.bicategory CategoryTheory.Bicategory
#align category_theory.bicategory.hom_category CategoryTheory.Bicategory.homCategory
#align category_theory.bicategory.whisker_left CategoryTheory.Bicategory.whiskerLeft
#align category_theory.bicategory.whisker_right CategoryTheory.Bicategory.whiskerRight
#align category_theory.bicategory.left_unitor CategoryTheory.Bicategory.leftUnitor
#align category_theory.bicategory.right_unitor CategoryTheory.Bicategory.rightUnitor
#align category_theory.bicategory.whisker_left_id' CategoryTheory.Bicategory.whiskerLeft_id
#align category_theory.bicategory.whisker_left_comp' CategoryTheory.Bicategory.whiskerLeft_comp
#align category_theory.bicategory.id_whisker_left' CategoryTheory.Bicategory.id_whiskerLeft
#align category_theory.bicategory.comp_whisker_left' CategoryTheory.Bicategory.comp_whiskerLeft
#align category_theory.bicategory.id_whisker_right' CategoryTheory.Bicategory.id_whiskerRight
#align category_theory.bicategory.comp_whisker_right' CategoryTheory.Bicategory.comp_whiskerRight
#align category_theory.bicategory.whisker_right_id' CategoryTheory.Bicategory.whiskerRight_id
#align category_theory.bicategory.whisker_right_comp' CategoryTheory.Bicategory.whiskerRight_comp
#align category_theory.bicategory.whisker_assoc' CategoryTheory.Bicategory.whisker_assoc
#align category_theory.bicategory.whisker_exchange' CategoryTheory.Bicategory.whisker_exchange
#align category_theory.bicategory.pentagon' CategoryTheory.Bicategory.pentagon
#align category_theory.bicategory.triangle' CategoryTheory.Bicategory.triangle
namespace Bicategory
scoped infixr:81 " ◁ " => Bicategory.whiskerLeft
scoped infixl:81 " ▷ " => Bicategory.whiskerRight
scoped notation "α_" => Bicategory.associator
scoped notation "λ_" => Bicategory.leftUnitor
scoped notation "ρ_" => Bicategory.rightUnitor
attribute [instance] homCategory
attribute [reassoc]
whiskerLeft_comp id_whiskerLeft comp_whiskerLeft comp_whiskerRight whiskerRight_id
whiskerRight_comp whisker_assoc whisker_exchange
attribute [reassoc (attr := simp)] pentagon triangle
attribute [simp]
whiskerLeft_id whiskerLeft_comp id_whiskerLeft comp_whiskerLeft id_whiskerRight comp_whiskerRight
whiskerRight_id whiskerRight_comp whisker_assoc
variable {B : Type u} [Bicategory.{w, v} B] {a b c d e : B}
@[reassoc (attr := simp)]
theorem whiskerLeft_hom_inv (f : a ⟶ b) {g h : b ⟶ c} (η : g ≅ h) :
f ◁ η.hom ≫ f ◁ η.inv = 𝟙 (f ≫ g) := by rw [← whiskerLeft_comp, hom_inv_id, whiskerLeft_id]
#align category_theory.bicategory.hom_inv_whisker_left CategoryTheory.Bicategory.whiskerLeft_hom_inv
@[reassoc (attr := simp)]
theorem hom_inv_whiskerRight {f g : a ⟶ b} (η : f ≅ g) (h : b ⟶ c) :
η.hom ▷ h ≫ η.inv ▷ h = 𝟙 (f ≫ h) := by rw [← comp_whiskerRight, hom_inv_id, id_whiskerRight]
#align category_theory.bicategory.hom_inv_whisker_right CategoryTheory.Bicategory.hom_inv_whiskerRight
@[reassoc (attr := simp)]
theorem whiskerLeft_inv_hom (f : a ⟶ b) {g h : b ⟶ c} (η : g ≅ h) :
f ◁ η.inv ≫ f ◁ η.hom = 𝟙 (f ≫ h) := by rw [← whiskerLeft_comp, inv_hom_id, whiskerLeft_id]
#align category_theory.bicategory.inv_hom_whisker_left CategoryTheory.Bicategory.whiskerLeft_inv_hom
@[reassoc (attr := simp)]
theorem inv_hom_whiskerRight {f g : a ⟶ b} (η : f ≅ g) (h : b ⟶ c) :
η.inv ▷ h ≫ η.hom ▷ h = 𝟙 (g ≫ h) := by rw [← comp_whiskerRight, inv_hom_id, id_whiskerRight]
#align category_theory.bicategory.inv_hom_whisker_right CategoryTheory.Bicategory.inv_hom_whiskerRight
@[simps]
def whiskerLeftIso (f : a ⟶ b) {g h : b ⟶ c} (η : g ≅ h) : f ≫ g ≅ f ≫ h where
hom := f ◁ η.hom
inv := f ◁ η.inv
#align category_theory.bicategory.whisker_left_iso CategoryTheory.Bicategory.whiskerLeftIso
instance whiskerLeft_isIso (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) [IsIso η] : IsIso (f ◁ η) :=
(whiskerLeftIso f (asIso η)).isIso_hom
#align category_theory.bicategory.whisker_left_is_iso CategoryTheory.Bicategory.whiskerLeft_isIso
@[simp]
theorem inv_whiskerLeft (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h) [IsIso η] :
inv (f ◁ η) = f ◁ inv η := by
apply IsIso.inv_eq_of_hom_inv_id
simp only [← whiskerLeft_comp, whiskerLeft_id, IsIso.hom_inv_id]
#align category_theory.bicategory.inv_whisker_left CategoryTheory.Bicategory.inv_whiskerLeft
@[simps!]
def whiskerRightIso {f g : a ⟶ b} (η : f ≅ g) (h : b ⟶ c) : f ≫ h ≅ g ≫ h where
hom := η.hom ▷ h
inv := η.inv ▷ h
#align category_theory.bicategory.whisker_right_iso CategoryTheory.Bicategory.whiskerRightIso
instance whiskerRight_isIso {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) [IsIso η] : IsIso (η ▷ h) :=
(whiskerRightIso (asIso η) h).isIso_hom
#align category_theory.bicategory.whisker_right_is_iso CategoryTheory.Bicategory.whiskerRight_isIso
@[simp]
theorem inv_whiskerRight {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c) [IsIso η] :
inv (η ▷ h) = inv η ▷ h := by
apply IsIso.inv_eq_of_hom_inv_id
simp only [← comp_whiskerRight, id_whiskerRight, IsIso.hom_inv_id]
#align category_theory.bicategory.inv_whisker_right CategoryTheory.Bicategory.inv_whiskerRight
@[reassoc (attr := simp)]
theorem pentagon_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
f ◁ (α_ g h i).inv ≫ (α_ f (g ≫ h) i).inv ≫ (α_ f g h).inv ▷ i =
(α_ f g (h ≫ i)).inv ≫ (α_ (f ≫ g) h i).inv :=
eq_of_inv_eq_inv (by simp)
#align category_theory.bicategory.pentagon_inv CategoryTheory.Bicategory.pentagon_inv
@[reassoc (attr := simp)]
theorem pentagon_inv_inv_hom_hom_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
(α_ f (g ≫ h) i).inv ≫ (α_ f g h).inv ▷ i ≫ (α_ (f ≫ g) h i).hom =
f ◁ (α_ g h i).hom ≫ (α_ f g (h ≫ i)).inv := by
rw [← cancel_epi (f ◁ (α_ g h i).inv), ← cancel_mono (α_ (f ≫ g) h i).inv]
simp
#align category_theory.bicategory.pentagon_inv_inv_hom_hom_inv CategoryTheory.Bicategory.pentagon_inv_inv_hom_hom_inv
@[reassoc (attr := simp)]
theorem pentagon_inv_hom_hom_hom_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
(α_ (f ≫ g) h i).inv ≫ (α_ f g h).hom ▷ i ≫ (α_ f (g ≫ h) i).hom =
(α_ f g (h ≫ i)).hom ≫ f ◁ (α_ g h i).inv :=
eq_of_inv_eq_inv (by simp)
#align category_theory.bicategory.pentagon_inv_hom_hom_hom_inv CategoryTheory.Bicategory.pentagon_inv_hom_hom_hom_inv
@[reassoc (attr := simp)]
theorem pentagon_hom_inv_inv_inv_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
f ◁ (α_ g h i).hom ≫ (α_ f g (h ≫ i)).inv ≫ (α_ (f ≫ g) h i).inv =
(α_ f (g ≫ h) i).inv ≫ (α_ f g h).inv ▷ i := by
simp [← cancel_epi (f ◁ (α_ g h i).inv)]
#align category_theory.bicategory.pentagon_hom_inv_inv_inv_inv CategoryTheory.Bicategory.pentagon_hom_inv_inv_inv_inv
@[reassoc (attr := simp)]
theorem pentagon_hom_hom_inv_hom_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
(α_ (f ≫ g) h i).hom ≫ (α_ f g (h ≫ i)).hom ≫ f ◁ (α_ g h i).inv =
(α_ f g h).hom ▷ i ≫ (α_ f (g ≫ h) i).hom :=
eq_of_inv_eq_inv (by simp)
#align category_theory.bicategory.pentagon_hom_hom_inv_hom_hom CategoryTheory.Bicategory.pentagon_hom_hom_inv_hom_hom
@[reassoc (attr := simp)]
theorem pentagon_hom_inv_inv_inv_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
(α_ f g (h ≫ i)).hom ≫ f ◁ (α_ g h i).inv ≫ (α_ f (g ≫ h) i).inv =
(α_ (f ≫ g) h i).inv ≫ (α_ f g h).hom ▷ i := by
rw [← cancel_epi (α_ f g (h ≫ i)).inv, ← cancel_mono ((α_ f g h).inv ▷ i)]
simp
#align category_theory.bicategory.pentagon_hom_inv_inv_inv_hom CategoryTheory.Bicategory.pentagon_hom_inv_inv_inv_hom
@[reassoc (attr := simp)]
theorem pentagon_hom_hom_inv_inv_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
(α_ f (g ≫ h) i).hom ≫ f ◁ (α_ g h i).hom ≫ (α_ f g (h ≫ i)).inv =
(α_ f g h).inv ▷ i ≫ (α_ (f ≫ g) h i).hom :=
eq_of_inv_eq_inv (by simp)
#align category_theory.bicategory.pentagon_hom_hom_inv_inv_hom CategoryTheory.Bicategory.pentagon_hom_hom_inv_inv_hom
@[reassoc (attr := simp)]
theorem pentagon_inv_hom_hom_hom_hom (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
(α_ f g h).inv ▷ i ≫ (α_ (f ≫ g) h i).hom ≫ (α_ f g (h ≫ i)).hom =
(α_ f (g ≫ h) i).hom ≫ f ◁ (α_ g h i).hom := by
simp [← cancel_epi ((α_ f g h).hom ▷ i)]
#align category_theory.bicategory.pentagon_inv_hom_hom_hom_hom CategoryTheory.Bicategory.pentagon_inv_hom_hom_hom_hom
@[reassoc (attr := simp)]
theorem pentagon_inv_inv_hom_inv_inv (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) (i : d ⟶ e) :
(α_ f g (h ≫ i)).inv ≫ (α_ (f ≫ g) h i).inv ≫ (α_ f g h).hom ▷ i =
f ◁ (α_ g h i).inv ≫ (α_ f (g ≫ h) i).inv :=
eq_of_inv_eq_inv (by simp)
#align category_theory.bicategory.pentagon_inv_inv_hom_inv_inv CategoryTheory.Bicategory.pentagon_inv_inv_hom_inv_inv
theorem triangle_assoc_comp_left (f : a ⟶ b) (g : b ⟶ c) :
(α_ f (𝟙 b) g).hom ≫ f ◁ (λ_ g).hom = (ρ_ f).hom ▷ g :=
triangle f g
#align category_theory.bicategory.triangle_assoc_comp_left CategoryTheory.Bicategory.triangle_assoc_comp_left
@[reassoc (attr := simp)]
theorem triangle_assoc_comp_right (f : a ⟶ b) (g : b ⟶ c) :
(α_ f (𝟙 b) g).inv ≫ (ρ_ f).hom ▷ g = f ◁ (λ_ g).hom := by rw [← triangle, inv_hom_id_assoc]
#align category_theory.bicategory.triangle_assoc_comp_right CategoryTheory.Bicategory.triangle_assoc_comp_right
@[reassoc (attr := simp)]
theorem triangle_assoc_comp_right_inv (f : a ⟶ b) (g : b ⟶ c) :
(ρ_ f).inv ▷ g ≫ (α_ f (𝟙 b) g).hom = f ◁ (λ_ g).inv := by
simp [← cancel_mono (f ◁ (λ_ g).hom)]
#align category_theory.bicategory.triangle_assoc_comp_right_inv CategoryTheory.Bicategory.triangle_assoc_comp_right_inv
@[reassoc (attr := simp)]
theorem triangle_assoc_comp_left_inv (f : a ⟶ b) (g : b ⟶ c) :
f ◁ (λ_ g).inv ≫ (α_ f (𝟙 b) g).inv = (ρ_ f).inv ▷ g := by
simp [← cancel_mono ((ρ_ f).hom ▷ g)]
#align category_theory.bicategory.triangle_assoc_comp_left_inv CategoryTheory.Bicategory.triangle_assoc_comp_left_inv
@[reassoc]
theorem associator_naturality_left {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c) (h : c ⟶ d) :
η ▷ g ▷ h ≫ (α_ f' g h).hom = (α_ f g h).hom ≫ η ▷ (g ≫ h) := by simp
#align category_theory.bicategory.associator_naturality_left CategoryTheory.Bicategory.associator_naturality_left
@[reassoc]
theorem associator_inv_naturality_left {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c) (h : c ⟶ d) :
η ▷ (g ≫ h) ≫ (α_ f' g h).inv = (α_ f g h).inv ≫ η ▷ g ▷ h := by simp
#align category_theory.bicategory.associator_inv_naturality_left CategoryTheory.Bicategory.associator_inv_naturality_left
@[reassoc]
theorem whiskerRight_comp_symm {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c) (h : c ⟶ d) :
η ▷ g ▷ h = (α_ f g h).hom ≫ η ▷ (g ≫ h) ≫ (α_ f' g h).inv := by simp
#align category_theory.bicategory.whisker_right_comp_symm CategoryTheory.Bicategory.whiskerRight_comp_symm
@[reassoc]
theorem associator_naturality_middle (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g') (h : c ⟶ d) :
(f ◁ η) ▷ h ≫ (α_ f g' h).hom = (α_ f g h).hom ≫ f ◁ η ▷ h := by simp
#align category_theory.bicategory.associator_naturality_middle CategoryTheory.Bicategory.associator_naturality_middle
@[reassoc]
theorem associator_inv_naturality_middle (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g') (h : c ⟶ d) :
f ◁ η ▷ h ≫ (α_ f g' h).inv = (α_ f g h).inv ≫ (f ◁ η) ▷ h := by simp
#align category_theory.bicategory.associator_inv_naturality_middle CategoryTheory.Bicategory.associator_inv_naturality_middle
@[reassoc]
theorem whisker_assoc_symm (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g') (h : c ⟶ d) :
f ◁ η ▷ h = (α_ f g h).inv ≫ (f ◁ η) ▷ h ≫ (α_ f g' h).hom := by simp
#align category_theory.bicategory.whisker_assoc_symm CategoryTheory.Bicategory.whisker_assoc_symm
@[reassoc]
theorem associator_naturality_right (f : a ⟶ b) (g : b ⟶ c) {h h' : c ⟶ d} (η : h ⟶ h') :
(f ≫ g) ◁ η ≫ (α_ f g h').hom = (α_ f g h).hom ≫ f ◁ g ◁ η := by simp
#align category_theory.bicategory.associator_naturality_right CategoryTheory.Bicategory.associator_naturality_right
@[reassoc]
theorem associator_inv_naturality_right (f : a ⟶ b) (g : b ⟶ c) {h h' : c ⟶ d} (η : h ⟶ h') :
f ◁ g ◁ η ≫ (α_ f g h').inv = (α_ f g h).inv ≫ (f ≫ g) ◁ η := by simp
#align category_theory.bicategory.associator_inv_naturality_right CategoryTheory.Bicategory.associator_inv_naturality_right
@[reassoc]
theorem comp_whiskerLeft_symm (f : a ⟶ b) (g : b ⟶ c) {h h' : c ⟶ d} (η : h ⟶ h') :
f ◁ g ◁ η = (α_ f g h).inv ≫ (f ≫ g) ◁ η ≫ (α_ f g h').hom := by simp
#align category_theory.bicategory.comp_whisker_left_symm CategoryTheory.Bicategory.comp_whiskerLeft_symm
@[reassoc]
theorem leftUnitor_naturality {f g : a ⟶ b} (η : f ⟶ g) :
𝟙 a ◁ η ≫ (λ_ g).hom = (λ_ f).hom ≫ η := by
simp
#align category_theory.bicategory.left_unitor_naturality CategoryTheory.Bicategory.leftUnitor_naturality
@[reassoc]
theorem leftUnitor_inv_naturality {f g : a ⟶ b} (η : f ⟶ g) :
η ≫ (λ_ g).inv = (λ_ f).inv ≫ 𝟙 a ◁ η := by simp
#align category_theory.bicategory.left_unitor_inv_naturality CategoryTheory.Bicategory.leftUnitor_inv_naturality
theorem id_whiskerLeft_symm {f g : a ⟶ b} (η : f ⟶ g) : η = (λ_ f).inv ≫ 𝟙 a ◁ η ≫ (λ_ g).hom := by
simp
#align category_theory.bicategory.id_whisker_left_symm CategoryTheory.Bicategory.id_whiskerLeft_symm
@[reassoc]
theorem rightUnitor_naturality {f g : a ⟶ b} (η : f ⟶ g) :
η ▷ 𝟙 b ≫ (ρ_ g).hom = (ρ_ f).hom ≫ η := by simp
#align category_theory.bicategory.right_unitor_naturality CategoryTheory.Bicategory.rightUnitor_naturality
@[reassoc]
theorem rightUnitor_inv_naturality {f g : a ⟶ b} (η : f ⟶ g) :
η ≫ (ρ_ g).inv = (ρ_ f).inv ≫ η ▷ 𝟙 b := by simp
#align category_theory.bicategory.right_unitor_inv_naturality CategoryTheory.Bicategory.rightUnitor_inv_naturality
theorem whiskerRight_id_symm {f g : a ⟶ b} (η : f ⟶ g) : η = (ρ_ f).inv ≫ η ▷ 𝟙 b ≫ (ρ_ g).hom := by
simp
#align category_theory.bicategory.whisker_right_id_symm CategoryTheory.Bicategory.whiskerRight_id_symm
theorem whiskerLeft_iff {f g : a ⟶ b} (η θ : f ⟶ g) : 𝟙 a ◁ η = 𝟙 a ◁ θ ↔ η = θ := by simp
#align category_theory.bicategory.whisker_left_iff CategoryTheory.Bicategory.whiskerLeft_iff
| Mathlib/CategoryTheory/Bicategory/Basic.lean | 415 | 415 | theorem whiskerRight_iff {f g : a ⟶ b} (η θ : f ⟶ g) : η ▷ 𝟙 b = θ ▷ 𝟙 b ↔ η = θ := by | simp
|
import Mathlib.Algebra.MvPolynomial.Supported
import Mathlib.RingTheory.WittVector.Truncated
#align_import ring_theory.witt_vector.mul_coeff from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4"
noncomputable section
namespace WittVector
variable (p : ℕ) [hp : Fact p.Prime]
variable {k : Type*} [CommRing k]
local notation "𝕎" => WittVector p
-- Porting note: new notation
local notation "𝕄" => MvPolynomial (Fin 2 × ℕ) ℤ
open Finset MvPolynomial
def wittPolyProd (n : ℕ) : 𝕄 :=
rename (Prod.mk (0 : Fin 2)) (wittPolynomial p ℤ n) *
rename (Prod.mk (1 : Fin 2)) (wittPolynomial p ℤ n)
#align witt_vector.witt_poly_prod WittVector.wittPolyProd
theorem wittPolyProd_vars (n : ℕ) : (wittPolyProd p n).vars ⊆ univ ×ˢ range (n + 1) := by
rw [wittPolyProd]
apply Subset.trans (vars_mul _ _)
refine union_subset ?_ ?_ <;>
· refine Subset.trans (vars_rename _ _) ?_
simp [wittPolynomial_vars, image_subset_iff]
#align witt_vector.witt_poly_prod_vars WittVector.wittPolyProd_vars
def wittPolyProdRemainder (n : ℕ) : 𝕄 :=
∑ i ∈ range n, (p : 𝕄) ^ i * wittMul p i ^ p ^ (n - i)
#align witt_vector.witt_poly_prod_remainder WittVector.wittPolyProdRemainder
theorem wittPolyProdRemainder_vars (n : ℕ) :
(wittPolyProdRemainder p n).vars ⊆ univ ×ˢ range n := by
rw [wittPolyProdRemainder]
refine Subset.trans (vars_sum_subset _ _) ?_
rw [biUnion_subset]
intro x hx
apply Subset.trans (vars_mul _ _)
refine union_subset ?_ ?_
· apply Subset.trans (vars_pow _ _)
have : (p : 𝕄) = C (p : ℤ) := by simp only [Int.cast_natCast, eq_intCast]
rw [this, vars_C]
apply empty_subset
· apply Subset.trans (vars_pow _ _)
apply Subset.trans (wittMul_vars _ _)
apply product_subset_product (Subset.refl _)
simp only [mem_range, range_subset] at hx ⊢
exact hx
#align witt_vector.witt_poly_prod_remainder_vars WittVector.wittPolyProdRemainder_vars
def remainder (n : ℕ) : 𝕄 :=
(∑ x ∈ range (n + 1),
(rename (Prod.mk 0)) ((monomial (Finsupp.single x (p ^ (n + 1 - x)))) ((p : ℤ) ^ x))) *
∑ x ∈ range (n + 1),
(rename (Prod.mk 1)) ((monomial (Finsupp.single x (p ^ (n + 1 - x)))) ((p : ℤ) ^ x))
#align witt_vector.remainder WittVector.remainder
theorem remainder_vars (n : ℕ) : (remainder p n).vars ⊆ univ ×ˢ range (n + 1) := by
rw [remainder]
apply Subset.trans (vars_mul _ _)
refine union_subset ?_ ?_ <;>
· refine Subset.trans (vars_sum_subset _ _) ?_
rw [biUnion_subset]
intro x hx
rw [rename_monomial, vars_monomial, Finsupp.mapDomain_single]
· apply Subset.trans Finsupp.support_single_subset
simpa using mem_range.mp hx
· apply pow_ne_zero
exact mod_cast hp.out.ne_zero
#align witt_vector.remainder_vars WittVector.remainder_vars
def polyOfInterest (n : ℕ) : 𝕄 :=
wittMul p (n + 1) + (p : 𝕄) ^ (n + 1) * X (0, n + 1) * X (1, n + 1) -
X (0, n + 1) * rename (Prod.mk (1 : Fin 2)) (wittPolynomial p ℤ (n + 1)) -
X (1, n + 1) * rename (Prod.mk (0 : Fin 2)) (wittPolynomial p ℤ (n + 1))
#align witt_vector.poly_of_interest WittVector.polyOfInterest
theorem mul_polyOfInterest_aux1 (n : ℕ) :
∑ i ∈ range (n + 1), (p : 𝕄) ^ i * wittMul p i ^ p ^ (n - i) = wittPolyProd p n := by
simp only [wittPolyProd]
convert wittStructureInt_prop p (X (0 : Fin 2) * X 1) n using 1
· simp only [wittPolynomial, wittMul]
rw [AlgHom.map_sum]
congr 1 with i
congr 1
have hsupp : (Finsupp.single i (p ^ (n - i))).support = {i} := by
rw [Finsupp.support_eq_singleton]
simp only [and_true_iff, Finsupp.single_eq_same, eq_self_iff_true, Ne]
exact pow_ne_zero _ hp.out.ne_zero
simp only [bind₁_monomial, hsupp, Int.cast_natCast, prod_singleton, eq_intCast,
Finsupp.single_eq_same, C_pow, mul_eq_mul_left_iff, true_or_iff, eq_self_iff_true,
Int.cast_pow]
· simp only [map_mul, bind₁_X_right]
#align witt_vector.mul_poly_of_interest_aux1 WittVector.mul_polyOfInterest_aux1
theorem mul_polyOfInterest_aux2 (n : ℕ) :
(p : 𝕄) ^ n * wittMul p n + wittPolyProdRemainder p n = wittPolyProd p n := by
convert mul_polyOfInterest_aux1 p n
rw [sum_range_succ, add_comm, Nat.sub_self, pow_zero, pow_one]
rfl
#align witt_vector.mul_poly_of_interest_aux2 WittVector.mul_polyOfInterest_aux2
theorem mul_polyOfInterest_aux3 (n : ℕ) : wittPolyProd p (n + 1) =
-((p : 𝕄) ^ (n + 1) * X (0, n + 1)) * ((p : 𝕄) ^ (n + 1) * X (1, n + 1)) +
(p : 𝕄) ^ (n + 1) * X (0, n + 1) * rename (Prod.mk (1 : Fin 2)) (wittPolynomial p ℤ (n + 1)) +
(p : 𝕄) ^ (n + 1) * X (1, n + 1) * rename (Prod.mk (0 : Fin 2)) (wittPolynomial p ℤ (n + 1)) +
remainder p n := by
-- a useful auxiliary fact
have mvpz : (p : 𝕄) ^ (n + 1) = MvPolynomial.C ((p : ℤ) ^ (n + 1)) := by norm_cast
-- Porting note: the original proof applies `sum_range_succ` through a non-`conv` rewrite,
-- but this does not work in Lean 4; the whole proof also times out very badly. The proof has been
-- nearly totally rewritten here and now finishes quite fast.
rw [wittPolyProd, wittPolynomial, AlgHom.map_sum, AlgHom.map_sum]
conv_lhs =>
arg 1
rw [sum_range_succ, ← C_mul_X_pow_eq_monomial, tsub_self, pow_zero, pow_one, map_mul,
rename_C, rename_X, ← mvpz]
conv_lhs =>
arg 2
rw [sum_range_succ, ← C_mul_X_pow_eq_monomial, tsub_self, pow_zero, pow_one, map_mul,
rename_C, rename_X, ← mvpz]
conv_rhs =>
enter [1, 1, 2, 2]
rw [sum_range_succ, ← C_mul_X_pow_eq_monomial, tsub_self, pow_zero, pow_one, map_mul,
rename_C, rename_X, ← mvpz]
conv_rhs =>
enter [1, 2, 2]
rw [sum_range_succ, ← C_mul_X_pow_eq_monomial, tsub_self, pow_zero, pow_one, map_mul,
rename_C, rename_X, ← mvpz]
simp only [add_mul, mul_add]
rw [add_comm _ (remainder p n)]
simp only [add_assoc]
apply congrArg (Add.add _)
ring
#align witt_vector.mul_poly_of_interest_aux3 WittVector.mul_polyOfInterest_aux3
theorem mul_polyOfInterest_aux4 (n : ℕ) :
(p : 𝕄) ^ (n + 1) * wittMul p (n + 1) =
-((p : 𝕄) ^ (n + 1) * X (0, n + 1)) * ((p : 𝕄) ^ (n + 1) * X (1, n + 1)) +
(p : 𝕄) ^ (n + 1) * X (0, n + 1) * rename (Prod.mk (1 : Fin 2)) (wittPolynomial p ℤ (n + 1)) +
(p : 𝕄) ^ (n + 1) * X (1, n + 1) * rename (Prod.mk (0 : Fin 2)) (wittPolynomial p ℤ (n + 1)) +
(remainder p n - wittPolyProdRemainder p (n + 1)) := by
rw [← add_sub_assoc, eq_sub_iff_add_eq, mul_polyOfInterest_aux2]
exact mul_polyOfInterest_aux3 _ _
#align witt_vector.mul_poly_of_interest_aux4 WittVector.mul_polyOfInterest_aux4
theorem mul_polyOfInterest_aux5 (n : ℕ) :
(p : 𝕄) ^ (n + 1) * polyOfInterest p n = remainder p n - wittPolyProdRemainder p (n + 1) := by
simp only [polyOfInterest, mul_sub, mul_add, sub_eq_iff_eq_add']
rw [mul_polyOfInterest_aux4 p n]
ring
#align witt_vector.mul_poly_of_interest_aux5 WittVector.mul_polyOfInterest_aux5
theorem mul_polyOfInterest_vars (n : ℕ) :
((p : 𝕄) ^ (n + 1) * polyOfInterest p n).vars ⊆ univ ×ˢ range (n + 1) := by
rw [mul_polyOfInterest_aux5]
apply Subset.trans (vars_sub_subset _)
refine union_subset ?_ ?_
· apply remainder_vars
· apply wittPolyProdRemainder_vars
#align witt_vector.mul_poly_of_interest_vars WittVector.mul_polyOfInterest_vars
| Mathlib/RingTheory/WittVector/MulCoeff.lean | 205 | 212 | theorem polyOfInterest_vars_eq (n : ℕ) : (polyOfInterest p n).vars =
((p : 𝕄) ^ (n + 1) * (wittMul p (n + 1) + (p : 𝕄) ^ (n + 1) * X (0, n + 1) * X (1, n + 1) -
X (0, n + 1) * rename (Prod.mk (1 : Fin 2)) (wittPolynomial p ℤ (n + 1)) -
X (1, n + 1) * rename (Prod.mk (0 : Fin 2)) (wittPolynomial p ℤ (n + 1)))).vars := by |
have : (p : 𝕄) ^ (n + 1) = C ((p : ℤ) ^ (n + 1)) := by norm_cast
rw [polyOfInterest, this, vars_C_mul]
apply pow_ne_zero
exact mod_cast hp.out.ne_zero
|
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic
import Mathlib.Analysis.Normed.Group.AddCircle
import Mathlib.Algebra.CharZero.Quotient
import Mathlib.Topology.Instances.Sign
#align_import analysis.special_functions.trigonometric.angle from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec"
open Real
noncomputable section
namespace Real
-- Porting note: can't derive `NormedAddCommGroup, Inhabited`
def Angle : Type :=
AddCircle (2 * π)
#align real.angle Real.Angle
namespace Angle
-- Porting note (#10754): added due to missing instances due to no deriving
instance : NormedAddCommGroup Angle :=
inferInstanceAs (NormedAddCommGroup (AddCircle (2 * π)))
-- Porting note (#10754): added due to missing instances due to no deriving
instance : Inhabited Angle :=
inferInstanceAs (Inhabited (AddCircle (2 * π)))
-- Porting note (#10754): added due to missing instances due to no deriving
-- also, without this, a plain `QuotientAddGroup.mk`
-- causes coerced terms to be of type `ℝ ⧸ AddSubgroup.zmultiples (2 * π)`
@[coe]
protected def coe (r : ℝ) : Angle := QuotientAddGroup.mk r
instance : Coe ℝ Angle := ⟨Angle.coe⟩
instance : CircularOrder Real.Angle :=
QuotientAddGroup.circularOrder (hp' := ⟨by norm_num [pi_pos]⟩)
@[continuity]
theorem continuous_coe : Continuous ((↑) : ℝ → Angle) :=
continuous_quotient_mk'
#align real.angle.continuous_coe Real.Angle.continuous_coe
def coeHom : ℝ →+ Angle :=
QuotientAddGroup.mk' _
#align real.angle.coe_hom Real.Angle.coeHom
@[simp]
theorem coe_coeHom : (coeHom : ℝ → Angle) = ((↑) : ℝ → Angle) :=
rfl
#align real.angle.coe_coe_hom Real.Angle.coe_coeHom
@[elab_as_elim]
protected theorem induction_on {p : Angle → Prop} (θ : Angle) (h : ∀ x : ℝ, p x) : p θ :=
Quotient.inductionOn' θ h
#align real.angle.induction_on Real.Angle.induction_on
@[simp]
theorem coe_zero : ↑(0 : ℝ) = (0 : Angle) :=
rfl
#align real.angle.coe_zero Real.Angle.coe_zero
@[simp]
theorem coe_add (x y : ℝ) : ↑(x + y : ℝ) = (↑x + ↑y : Angle) :=
rfl
#align real.angle.coe_add Real.Angle.coe_add
@[simp]
theorem coe_neg (x : ℝ) : ↑(-x : ℝ) = -(↑x : Angle) :=
rfl
#align real.angle.coe_neg Real.Angle.coe_neg
@[simp]
theorem coe_sub (x y : ℝ) : ↑(x - y : ℝ) = (↑x - ↑y : Angle) :=
rfl
#align real.angle.coe_sub Real.Angle.coe_sub
theorem coe_nsmul (n : ℕ) (x : ℝ) : ↑(n • x : ℝ) = n • (↑x : Angle) :=
rfl
#align real.angle.coe_nsmul Real.Angle.coe_nsmul
theorem coe_zsmul (z : ℤ) (x : ℝ) : ↑(z • x : ℝ) = z • (↑x : Angle) :=
rfl
#align real.angle.coe_zsmul Real.Angle.coe_zsmul
@[simp, norm_cast]
theorem natCast_mul_eq_nsmul (x : ℝ) (n : ℕ) : ↑((n : ℝ) * x) = n • (↑x : Angle) := by
simpa only [nsmul_eq_mul] using coeHom.map_nsmul x n
#align real.angle.coe_nat_mul_eq_nsmul Real.Angle.natCast_mul_eq_nsmul
@[simp, norm_cast]
theorem intCast_mul_eq_zsmul (x : ℝ) (n : ℤ) : ↑((n : ℝ) * x : ℝ) = n • (↑x : Angle) := by
simpa only [zsmul_eq_mul] using coeHom.map_zsmul x n
#align real.angle.coe_int_mul_eq_zsmul Real.Angle.intCast_mul_eq_zsmul
@[deprecated (since := "2024-05-25")] alias coe_nat_mul_eq_nsmul := natCast_mul_eq_nsmul
@[deprecated (since := "2024-05-25")] alias coe_int_mul_eq_zsmul := intCast_mul_eq_zsmul
theorem angle_eq_iff_two_pi_dvd_sub {ψ θ : ℝ} : (θ : Angle) = ψ ↔ ∃ k : ℤ, θ - ψ = 2 * π * k := by
simp only [QuotientAddGroup.eq, AddSubgroup.zmultiples_eq_closure,
AddSubgroup.mem_closure_singleton, zsmul_eq_mul', (sub_eq_neg_add _ _).symm, eq_comm]
-- Porting note: added `rw`, `simp [Angle.coe, QuotientAddGroup.eq]` doesn't fire otherwise
rw [Angle.coe, Angle.coe, QuotientAddGroup.eq]
simp only [AddSubgroup.zmultiples_eq_closure,
AddSubgroup.mem_closure_singleton, zsmul_eq_mul', (sub_eq_neg_add _ _).symm, eq_comm]
#align real.angle.angle_eq_iff_two_pi_dvd_sub Real.Angle.angle_eq_iff_two_pi_dvd_sub
@[simp]
theorem coe_two_pi : ↑(2 * π : ℝ) = (0 : Angle) :=
angle_eq_iff_two_pi_dvd_sub.2 ⟨1, by rw [sub_zero, Int.cast_one, mul_one]⟩
#align real.angle.coe_two_pi Real.Angle.coe_two_pi
@[simp]
theorem neg_coe_pi : -(π : Angle) = π := by
rw [← coe_neg, angle_eq_iff_two_pi_dvd_sub]
use -1
simp [two_mul, sub_eq_add_neg]
#align real.angle.neg_coe_pi Real.Angle.neg_coe_pi
@[simp]
theorem two_nsmul_coe_div_two (θ : ℝ) : (2 : ℕ) • (↑(θ / 2) : Angle) = θ := by
rw [← coe_nsmul, two_nsmul, add_halves]
#align real.angle.two_nsmul_coe_div_two Real.Angle.two_nsmul_coe_div_two
@[simp]
theorem two_zsmul_coe_div_two (θ : ℝ) : (2 : ℤ) • (↑(θ / 2) : Angle) = θ := by
rw [← coe_zsmul, two_zsmul, add_halves]
#align real.angle.two_zsmul_coe_div_two Real.Angle.two_zsmul_coe_div_two
-- Porting note (#10618): @[simp] can prove it
theorem two_nsmul_neg_pi_div_two : (2 : ℕ) • (↑(-π / 2) : Angle) = π := by
rw [two_nsmul_coe_div_two, coe_neg, neg_coe_pi]
#align real.angle.two_nsmul_neg_pi_div_two Real.Angle.two_nsmul_neg_pi_div_two
-- Porting note (#10618): @[simp] can prove it
theorem two_zsmul_neg_pi_div_two : (2 : ℤ) • (↑(-π / 2) : Angle) = π := by
rw [two_zsmul, ← two_nsmul, two_nsmul_neg_pi_div_two]
#align real.angle.two_zsmul_neg_pi_div_two Real.Angle.two_zsmul_neg_pi_div_two
theorem sub_coe_pi_eq_add_coe_pi (θ : Angle) : θ - π = θ + π := by
rw [sub_eq_add_neg, neg_coe_pi]
#align real.angle.sub_coe_pi_eq_add_coe_pi Real.Angle.sub_coe_pi_eq_add_coe_pi
@[simp]
theorem two_nsmul_coe_pi : (2 : ℕ) • (π : Angle) = 0 := by simp [← natCast_mul_eq_nsmul]
#align real.angle.two_nsmul_coe_pi Real.Angle.two_nsmul_coe_pi
@[simp]
theorem two_zsmul_coe_pi : (2 : ℤ) • (π : Angle) = 0 := by simp [← intCast_mul_eq_zsmul]
#align real.angle.two_zsmul_coe_pi Real.Angle.two_zsmul_coe_pi
@[simp]
theorem coe_pi_add_coe_pi : (π : Real.Angle) + π = 0 := by rw [← two_nsmul, two_nsmul_coe_pi]
#align real.angle.coe_pi_add_coe_pi Real.Angle.coe_pi_add_coe_pi
theorem zsmul_eq_iff {ψ θ : Angle} {z : ℤ} (hz : z ≠ 0) :
z • ψ = z • θ ↔ ∃ k : Fin z.natAbs, ψ = θ + (k : ℕ) • (2 * π / z : ℝ) :=
QuotientAddGroup.zmultiples_zsmul_eq_zsmul_iff hz
#align real.angle.zsmul_eq_iff Real.Angle.zsmul_eq_iff
theorem nsmul_eq_iff {ψ θ : Angle} {n : ℕ} (hz : n ≠ 0) :
n • ψ = n • θ ↔ ∃ k : Fin n, ψ = θ + (k : ℕ) • (2 * π / n : ℝ) :=
QuotientAddGroup.zmultiples_nsmul_eq_nsmul_iff hz
#align real.angle.nsmul_eq_iff Real.Angle.nsmul_eq_iff
theorem two_zsmul_eq_iff {ψ θ : Angle} : (2 : ℤ) • ψ = (2 : ℤ) • θ ↔ ψ = θ ∨ ψ = θ + ↑π := by
-- Porting note: no `Int.natAbs_bit0` anymore
have : Int.natAbs 2 = 2 := rfl
rw [zsmul_eq_iff two_ne_zero, this, Fin.exists_fin_two, Fin.val_zero,
Fin.val_one, zero_smul, add_zero, one_smul, Int.cast_two,
mul_div_cancel_left₀ (_ : ℝ) two_ne_zero]
#align real.angle.two_zsmul_eq_iff Real.Angle.two_zsmul_eq_iff
theorem two_nsmul_eq_iff {ψ θ : Angle} : (2 : ℕ) • ψ = (2 : ℕ) • θ ↔ ψ = θ ∨ ψ = θ + ↑π := by
simp_rw [← natCast_zsmul, Nat.cast_ofNat, two_zsmul_eq_iff]
#align real.angle.two_nsmul_eq_iff Real.Angle.two_nsmul_eq_iff
theorem two_nsmul_eq_zero_iff {θ : Angle} : (2 : ℕ) • θ = 0 ↔ θ = 0 ∨ θ = π := by
convert two_nsmul_eq_iff <;> simp
#align real.angle.two_nsmul_eq_zero_iff Real.Angle.two_nsmul_eq_zero_iff
theorem two_nsmul_ne_zero_iff {θ : Angle} : (2 : ℕ) • θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π := by
rw [← not_or, ← two_nsmul_eq_zero_iff]
#align real.angle.two_nsmul_ne_zero_iff Real.Angle.two_nsmul_ne_zero_iff
theorem two_zsmul_eq_zero_iff {θ : Angle} : (2 : ℤ) • θ = 0 ↔ θ = 0 ∨ θ = π := by
simp_rw [two_zsmul, ← two_nsmul, two_nsmul_eq_zero_iff]
#align real.angle.two_zsmul_eq_zero_iff Real.Angle.two_zsmul_eq_zero_iff
theorem two_zsmul_ne_zero_iff {θ : Angle} : (2 : ℤ) • θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π := by
rw [← not_or, ← two_zsmul_eq_zero_iff]
#align real.angle.two_zsmul_ne_zero_iff Real.Angle.two_zsmul_ne_zero_iff
theorem eq_neg_self_iff {θ : Angle} : θ = -θ ↔ θ = 0 ∨ θ = π := by
rw [← add_eq_zero_iff_eq_neg, ← two_nsmul, two_nsmul_eq_zero_iff]
#align real.angle.eq_neg_self_iff Real.Angle.eq_neg_self_iff
theorem ne_neg_self_iff {θ : Angle} : θ ≠ -θ ↔ θ ≠ 0 ∧ θ ≠ π := by
rw [← not_or, ← eq_neg_self_iff.not]
#align real.angle.ne_neg_self_iff Real.Angle.ne_neg_self_iff
theorem neg_eq_self_iff {θ : Angle} : -θ = θ ↔ θ = 0 ∨ θ = π := by rw [eq_comm, eq_neg_self_iff]
#align real.angle.neg_eq_self_iff Real.Angle.neg_eq_self_iff
theorem neg_ne_self_iff {θ : Angle} : -θ ≠ θ ↔ θ ≠ 0 ∧ θ ≠ π := by
rw [← not_or, ← neg_eq_self_iff.not]
#align real.angle.neg_ne_self_iff Real.Angle.neg_ne_self_iff
theorem two_nsmul_eq_pi_iff {θ : Angle} : (2 : ℕ) • θ = π ↔ θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ) := by
have h : (π : Angle) = ((2 : ℕ) • (π / 2 : ℝ) :) := by rw [two_nsmul, add_halves]
nth_rw 1 [h]
rw [coe_nsmul, two_nsmul_eq_iff]
-- Porting note: `congr` didn't simplify the goal of iff of `Or`s
convert Iff.rfl
rw [add_comm, ← coe_add, ← sub_eq_zero, ← coe_sub, neg_div, ← neg_sub, sub_neg_eq_add, add_assoc,
add_halves, ← two_mul, coe_neg, coe_two_pi, neg_zero]
#align real.angle.two_nsmul_eq_pi_iff Real.Angle.two_nsmul_eq_pi_iff
theorem two_zsmul_eq_pi_iff {θ : Angle} : (2 : ℤ) • θ = π ↔ θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ) := by
rw [two_zsmul, ← two_nsmul, two_nsmul_eq_pi_iff]
#align real.angle.two_zsmul_eq_pi_iff Real.Angle.two_zsmul_eq_pi_iff
theorem cos_eq_iff_coe_eq_or_eq_neg {θ ψ : ℝ} :
cos θ = cos ψ ↔ (θ : Angle) = ψ ∨ (θ : Angle) = -ψ := by
constructor
· intro Hcos
rw [← sub_eq_zero, cos_sub_cos, mul_eq_zero, mul_eq_zero, neg_eq_zero,
eq_false (two_ne_zero' ℝ), false_or_iff, sin_eq_zero_iff, sin_eq_zero_iff] at Hcos
rcases Hcos with (⟨n, hn⟩ | ⟨n, hn⟩)
· right
rw [eq_div_iff_mul_eq (two_ne_zero' ℝ), ← sub_eq_iff_eq_add] at hn
rw [← hn, coe_sub, eq_neg_iff_add_eq_zero, sub_add_cancel, mul_assoc, intCast_mul_eq_zsmul,
mul_comm, coe_two_pi, zsmul_zero]
· left
rw [eq_div_iff_mul_eq (two_ne_zero' ℝ), eq_sub_iff_add_eq] at hn
rw [← hn, coe_add, mul_assoc, intCast_mul_eq_zsmul, mul_comm, coe_two_pi, zsmul_zero,
zero_add]
· rw [angle_eq_iff_two_pi_dvd_sub, ← coe_neg, angle_eq_iff_two_pi_dvd_sub]
rintro (⟨k, H⟩ | ⟨k, H⟩)
· rw [← sub_eq_zero, cos_sub_cos, H, mul_assoc 2 π k, mul_div_cancel_left₀ _ (two_ne_zero' ℝ),
mul_comm π _, sin_int_mul_pi, mul_zero]
rw [← sub_eq_zero, cos_sub_cos, ← sub_neg_eq_add, H, mul_assoc 2 π k,
mul_div_cancel_left₀ _ (two_ne_zero' ℝ), mul_comm π _, sin_int_mul_pi, mul_zero,
zero_mul]
#align real.angle.cos_eq_iff_coe_eq_or_eq_neg Real.Angle.cos_eq_iff_coe_eq_or_eq_neg
theorem sin_eq_iff_coe_eq_or_add_eq_pi {θ ψ : ℝ} :
sin θ = sin ψ ↔ (θ : Angle) = ψ ∨ (θ : Angle) + ψ = π := by
constructor
· intro Hsin
rw [← cos_pi_div_two_sub, ← cos_pi_div_two_sub] at Hsin
cases' cos_eq_iff_coe_eq_or_eq_neg.mp Hsin with h h
· left
rw [coe_sub, coe_sub] at h
exact sub_right_inj.1 h
right
rw [coe_sub, coe_sub, eq_neg_iff_add_eq_zero, add_sub, sub_add_eq_add_sub, ← coe_add,
add_halves, sub_sub, sub_eq_zero] at h
exact h.symm
· rw [angle_eq_iff_two_pi_dvd_sub, ← eq_sub_iff_add_eq, ← coe_sub, angle_eq_iff_two_pi_dvd_sub]
rintro (⟨k, H⟩ | ⟨k, H⟩)
· rw [← sub_eq_zero, sin_sub_sin, H, mul_assoc 2 π k, mul_div_cancel_left₀ _ (two_ne_zero' ℝ),
mul_comm π _, sin_int_mul_pi, mul_zero, zero_mul]
have H' : θ + ψ = 2 * k * π + π := by
rwa [← sub_add, sub_add_eq_add_sub, sub_eq_iff_eq_add, mul_assoc, mul_comm π _, ←
mul_assoc] at H
rw [← sub_eq_zero, sin_sub_sin, H', add_div, mul_assoc 2 _ π,
mul_div_cancel_left₀ _ (two_ne_zero' ℝ), cos_add_pi_div_two, sin_int_mul_pi, neg_zero,
mul_zero]
#align real.angle.sin_eq_iff_coe_eq_or_add_eq_pi Real.Angle.sin_eq_iff_coe_eq_or_add_eq_pi
theorem cos_sin_inj {θ ψ : ℝ} (Hcos : cos θ = cos ψ) (Hsin : sin θ = sin ψ) : (θ : Angle) = ψ := by
cases' cos_eq_iff_coe_eq_or_eq_neg.mp Hcos with hc hc; · exact hc
cases' sin_eq_iff_coe_eq_or_add_eq_pi.mp Hsin with hs hs; · exact hs
rw [eq_neg_iff_add_eq_zero, hs] at hc
obtain ⟨n, hn⟩ : ∃ n, n • _ = _ := QuotientAddGroup.leftRel_apply.mp (Quotient.exact' hc)
rw [← neg_one_mul, add_zero, ← sub_eq_zero, zsmul_eq_mul, ← mul_assoc, ← sub_mul, mul_eq_zero,
eq_false (ne_of_gt pi_pos), or_false_iff, sub_neg_eq_add, ← Int.cast_zero, ← Int.cast_one,
← Int.cast_ofNat, ← Int.cast_mul, ← Int.cast_add, Int.cast_inj] at hn
have : (n * 2 + 1) % (2 : ℤ) = 0 % (2 : ℤ) := congr_arg (· % (2 : ℤ)) hn
rw [add_comm, Int.add_mul_emod_self] at this
exact absurd this one_ne_zero
#align real.angle.cos_sin_inj Real.Angle.cos_sin_inj
def sin (θ : Angle) : ℝ :=
sin_periodic.lift θ
#align real.angle.sin Real.Angle.sin
@[simp]
theorem sin_coe (x : ℝ) : sin (x : Angle) = Real.sin x :=
rfl
#align real.angle.sin_coe Real.Angle.sin_coe
@[continuity]
theorem continuous_sin : Continuous sin :=
Real.continuous_sin.quotient_liftOn' _
#align real.angle.continuous_sin Real.Angle.continuous_sin
def cos (θ : Angle) : ℝ :=
cos_periodic.lift θ
#align real.angle.cos Real.Angle.cos
@[simp]
theorem cos_coe (x : ℝ) : cos (x : Angle) = Real.cos x :=
rfl
#align real.angle.cos_coe Real.Angle.cos_coe
@[continuity]
theorem continuous_cos : Continuous cos :=
Real.continuous_cos.quotient_liftOn' _
#align real.angle.continuous_cos Real.Angle.continuous_cos
theorem cos_eq_real_cos_iff_eq_or_eq_neg {θ : Angle} {ψ : ℝ} :
cos θ = Real.cos ψ ↔ θ = ψ ∨ θ = -ψ := by
induction θ using Real.Angle.induction_on
exact cos_eq_iff_coe_eq_or_eq_neg
#align real.angle.cos_eq_real_cos_iff_eq_or_eq_neg Real.Angle.cos_eq_real_cos_iff_eq_or_eq_neg
theorem cos_eq_iff_eq_or_eq_neg {θ ψ : Angle} : cos θ = cos ψ ↔ θ = ψ ∨ θ = -ψ := by
induction ψ using Real.Angle.induction_on
exact cos_eq_real_cos_iff_eq_or_eq_neg
#align real.angle.cos_eq_iff_eq_or_eq_neg Real.Angle.cos_eq_iff_eq_or_eq_neg
theorem sin_eq_real_sin_iff_eq_or_add_eq_pi {θ : Angle} {ψ : ℝ} :
sin θ = Real.sin ψ ↔ θ = ψ ∨ θ + ψ = π := by
induction θ using Real.Angle.induction_on
exact sin_eq_iff_coe_eq_or_add_eq_pi
#align real.angle.sin_eq_real_sin_iff_eq_or_add_eq_pi Real.Angle.sin_eq_real_sin_iff_eq_or_add_eq_pi
theorem sin_eq_iff_eq_or_add_eq_pi {θ ψ : Angle} : sin θ = sin ψ ↔ θ = ψ ∨ θ + ψ = π := by
induction ψ using Real.Angle.induction_on
exact sin_eq_real_sin_iff_eq_or_add_eq_pi
#align real.angle.sin_eq_iff_eq_or_add_eq_pi Real.Angle.sin_eq_iff_eq_or_add_eq_pi
@[simp]
theorem sin_zero : sin (0 : Angle) = 0 := by rw [← coe_zero, sin_coe, Real.sin_zero]
#align real.angle.sin_zero Real.Angle.sin_zero
-- Porting note (#10618): @[simp] can prove it
theorem sin_coe_pi : sin (π : Angle) = 0 := by rw [sin_coe, Real.sin_pi]
#align real.angle.sin_coe_pi Real.Angle.sin_coe_pi
theorem sin_eq_zero_iff {θ : Angle} : sin θ = 0 ↔ θ = 0 ∨ θ = π := by
nth_rw 1 [← sin_zero]
rw [sin_eq_iff_eq_or_add_eq_pi]
simp
#align real.angle.sin_eq_zero_iff Real.Angle.sin_eq_zero_iff
theorem sin_ne_zero_iff {θ : Angle} : sin θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π := by
rw [← not_or, ← sin_eq_zero_iff]
#align real.angle.sin_ne_zero_iff Real.Angle.sin_ne_zero_iff
@[simp]
theorem sin_neg (θ : Angle) : sin (-θ) = -sin θ := by
induction θ using Real.Angle.induction_on
exact Real.sin_neg _
#align real.angle.sin_neg Real.Angle.sin_neg
theorem sin_antiperiodic : Function.Antiperiodic sin (π : Angle) := by
intro θ
induction θ using Real.Angle.induction_on
exact Real.sin_antiperiodic _
#align real.angle.sin_antiperiodic Real.Angle.sin_antiperiodic
@[simp]
theorem sin_add_pi (θ : Angle) : sin (θ + π) = -sin θ :=
sin_antiperiodic θ
#align real.angle.sin_add_pi Real.Angle.sin_add_pi
@[simp]
theorem sin_sub_pi (θ : Angle) : sin (θ - π) = -sin θ :=
sin_antiperiodic.sub_eq θ
#align real.angle.sin_sub_pi Real.Angle.sin_sub_pi
@[simp]
theorem cos_zero : cos (0 : Angle) = 1 := by rw [← coe_zero, cos_coe, Real.cos_zero]
#align real.angle.cos_zero Real.Angle.cos_zero
-- Porting note (#10618): @[simp] can prove it
theorem cos_coe_pi : cos (π : Angle) = -1 := by rw [cos_coe, Real.cos_pi]
#align real.angle.cos_coe_pi Real.Angle.cos_coe_pi
@[simp]
theorem cos_neg (θ : Angle) : cos (-θ) = cos θ := by
induction θ using Real.Angle.induction_on
exact Real.cos_neg _
#align real.angle.cos_neg Real.Angle.cos_neg
theorem cos_antiperiodic : Function.Antiperiodic cos (π : Angle) := by
intro θ
induction θ using Real.Angle.induction_on
exact Real.cos_antiperiodic _
#align real.angle.cos_antiperiodic Real.Angle.cos_antiperiodic
@[simp]
theorem cos_add_pi (θ : Angle) : cos (θ + π) = -cos θ :=
cos_antiperiodic θ
#align real.angle.cos_add_pi Real.Angle.cos_add_pi
@[simp]
theorem cos_sub_pi (θ : Angle) : cos (θ - π) = -cos θ :=
cos_antiperiodic.sub_eq θ
#align real.angle.cos_sub_pi Real.Angle.cos_sub_pi
theorem cos_eq_zero_iff {θ : Angle} : cos θ = 0 ↔ θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ) := by
rw [← cos_pi_div_two, ← cos_coe, cos_eq_iff_eq_or_eq_neg, ← coe_neg, ← neg_div]
#align real.angle.cos_eq_zero_iff Real.Angle.cos_eq_zero_iff
theorem sin_add (θ₁ θ₂ : Real.Angle) : sin (θ₁ + θ₂) = sin θ₁ * cos θ₂ + cos θ₁ * sin θ₂ := by
induction θ₁ using Real.Angle.induction_on
induction θ₂ using Real.Angle.induction_on
exact Real.sin_add _ _
#align real.angle.sin_add Real.Angle.sin_add
theorem cos_add (θ₁ θ₂ : Real.Angle) : cos (θ₁ + θ₂) = cos θ₁ * cos θ₂ - sin θ₁ * sin θ₂ := by
induction θ₂ using Real.Angle.induction_on
induction θ₁ using Real.Angle.induction_on
exact Real.cos_add _ _
#align real.angle.cos_add Real.Angle.cos_add
@[simp]
theorem cos_sq_add_sin_sq (θ : Real.Angle) : cos θ ^ 2 + sin θ ^ 2 = 1 := by
induction θ using Real.Angle.induction_on
exact Real.cos_sq_add_sin_sq _
#align real.angle.cos_sq_add_sin_sq Real.Angle.cos_sq_add_sin_sq
theorem sin_add_pi_div_two (θ : Angle) : sin (θ + ↑(π / 2)) = cos θ := by
induction θ using Real.Angle.induction_on
exact Real.sin_add_pi_div_two _
#align real.angle.sin_add_pi_div_two Real.Angle.sin_add_pi_div_two
theorem sin_sub_pi_div_two (θ : Angle) : sin (θ - ↑(π / 2)) = -cos θ := by
induction θ using Real.Angle.induction_on
exact Real.sin_sub_pi_div_two _
#align real.angle.sin_sub_pi_div_two Real.Angle.sin_sub_pi_div_two
theorem sin_pi_div_two_sub (θ : Angle) : sin (↑(π / 2) - θ) = cos θ := by
induction θ using Real.Angle.induction_on
exact Real.sin_pi_div_two_sub _
#align real.angle.sin_pi_div_two_sub Real.Angle.sin_pi_div_two_sub
theorem cos_add_pi_div_two (θ : Angle) : cos (θ + ↑(π / 2)) = -sin θ := by
induction θ using Real.Angle.induction_on
exact Real.cos_add_pi_div_two _
#align real.angle.cos_add_pi_div_two Real.Angle.cos_add_pi_div_two
theorem cos_sub_pi_div_two (θ : Angle) : cos (θ - ↑(π / 2)) = sin θ := by
induction θ using Real.Angle.induction_on
exact Real.cos_sub_pi_div_two _
#align real.angle.cos_sub_pi_div_two Real.Angle.cos_sub_pi_div_two
theorem cos_pi_div_two_sub (θ : Angle) : cos (↑(π / 2) - θ) = sin θ := by
induction θ using Real.Angle.induction_on
exact Real.cos_pi_div_two_sub _
#align real.angle.cos_pi_div_two_sub Real.Angle.cos_pi_div_two_sub
theorem abs_sin_eq_of_two_nsmul_eq {θ ψ : Angle} (h : (2 : ℕ) • θ = (2 : ℕ) • ψ) :
|sin θ| = |sin ψ| := by
rw [two_nsmul_eq_iff] at h
rcases h with (rfl | rfl)
· rfl
· rw [sin_add_pi, abs_neg]
#align real.angle.abs_sin_eq_of_two_nsmul_eq Real.Angle.abs_sin_eq_of_two_nsmul_eq
theorem abs_sin_eq_of_two_zsmul_eq {θ ψ : Angle} (h : (2 : ℤ) • θ = (2 : ℤ) • ψ) :
|sin θ| = |sin ψ| := by
simp_rw [two_zsmul, ← two_nsmul] at h
exact abs_sin_eq_of_two_nsmul_eq h
#align real.angle.abs_sin_eq_of_two_zsmul_eq Real.Angle.abs_sin_eq_of_two_zsmul_eq
theorem abs_cos_eq_of_two_nsmul_eq {θ ψ : Angle} (h : (2 : ℕ) • θ = (2 : ℕ) • ψ) :
|cos θ| = |cos ψ| := by
rw [two_nsmul_eq_iff] at h
rcases h with (rfl | rfl)
· rfl
· rw [cos_add_pi, abs_neg]
#align real.angle.abs_cos_eq_of_two_nsmul_eq Real.Angle.abs_cos_eq_of_two_nsmul_eq
theorem abs_cos_eq_of_two_zsmul_eq {θ ψ : Angle} (h : (2 : ℤ) • θ = (2 : ℤ) • ψ) :
|cos θ| = |cos ψ| := by
simp_rw [two_zsmul, ← two_nsmul] at h
exact abs_cos_eq_of_two_nsmul_eq h
#align real.angle.abs_cos_eq_of_two_zsmul_eq Real.Angle.abs_cos_eq_of_two_zsmul_eq
@[simp]
| Mathlib/Analysis/SpecialFunctions/Trigonometric/Angle.lean | 508 | 511 | theorem coe_toIcoMod (θ ψ : ℝ) : ↑(toIcoMod two_pi_pos ψ θ) = (θ : Angle) := by |
rw [angle_eq_iff_two_pi_dvd_sub]
refine ⟨-toIcoDiv two_pi_pos ψ θ, ?_⟩
rw [toIcoMod_sub_self, zsmul_eq_mul, mul_comm]
|
import Mathlib.CategoryTheory.Bicategory.Basic
import Mathlib.CategoryTheory.Monoidal.Mon_
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Equalizers
#align_import category_theory.monoidal.Bimod from "leanprover-community/mathlib"@"4698e35ca56a0d4fa53aa5639c3364e0a77f4eba"
universe v₁ v₂ u₁ u₂
open CategoryTheory
open CategoryTheory.MonoidalCategory
variable {C : Type u₁} [Category.{v₁} C] [MonoidalCategory.{v₁} C]
section
open CategoryTheory.Limits
variable [HasCoequalizers C]
section
variable [∀ X : C, PreservesColimitsOfSize.{0, 0} (tensorLeft X)]
theorem id_tensor_π_preserves_coequalizer_inv_desc {W X Y Z : C} (f g : X ⟶ Y) (h : Z ⊗ Y ⟶ W)
(wh : (Z ◁ f) ≫ h = (Z ◁ g) ≫ h) :
(Z ◁ coequalizer.π f g) ≫
(PreservesCoequalizer.iso (tensorLeft Z) f g).inv ≫ coequalizer.desc h wh =
h :=
map_π_preserves_coequalizer_inv_desc (tensorLeft Z) f g h wh
#align id_tensor_π_preserves_coequalizer_inv_desc id_tensor_π_preserves_coequalizer_inv_desc
theorem id_tensor_π_preserves_coequalizer_inv_colimMap_desc {X Y Z X' Y' Z' : C} (f g : X ⟶ Y)
(f' g' : X' ⟶ Y') (p : Z ⊗ X ⟶ X') (q : Z ⊗ Y ⟶ Y') (wf : (Z ◁ f) ≫ q = p ≫ f')
(wg : (Z ◁ g) ≫ q = p ≫ g') (h : Y' ⟶ Z') (wh : f' ≫ h = g' ≫ h) :
(Z ◁ coequalizer.π f g) ≫
(PreservesCoequalizer.iso (tensorLeft Z) f g).inv ≫
colimMap (parallelPairHom (Z ◁ f) (Z ◁ g) f' g' p q wf wg) ≫ coequalizer.desc h wh =
q ≫ h :=
map_π_preserves_coequalizer_inv_colimMap_desc (tensorLeft Z) f g f' g' p q wf wg h wh
#align id_tensor_π_preserves_coequalizer_inv_colim_map_desc id_tensor_π_preserves_coequalizer_inv_colimMap_desc
end
section
variable [∀ X : C, PreservesColimitsOfSize.{0, 0} (tensorRight X)]
theorem π_tensor_id_preserves_coequalizer_inv_desc {W X Y Z : C} (f g : X ⟶ Y) (h : Y ⊗ Z ⟶ W)
(wh : (f ▷ Z) ≫ h = (g ▷ Z) ≫ h) :
(coequalizer.π f g ▷ Z) ≫
(PreservesCoequalizer.iso (tensorRight Z) f g).inv ≫ coequalizer.desc h wh =
h :=
map_π_preserves_coequalizer_inv_desc (tensorRight Z) f g h wh
#align π_tensor_id_preserves_coequalizer_inv_desc π_tensor_id_preserves_coequalizer_inv_desc
theorem π_tensor_id_preserves_coequalizer_inv_colimMap_desc {X Y Z X' Y' Z' : C} (f g : X ⟶ Y)
(f' g' : X' ⟶ Y') (p : X ⊗ Z ⟶ X') (q : Y ⊗ Z ⟶ Y') (wf : (f ▷ Z) ≫ q = p ≫ f')
(wg : (g ▷ Z) ≫ q = p ≫ g') (h : Y' ⟶ Z') (wh : f' ≫ h = g' ≫ h) :
(coequalizer.π f g ▷ Z) ≫
(PreservesCoequalizer.iso (tensorRight Z) f g).inv ≫
colimMap (parallelPairHom (f ▷ Z) (g ▷ Z) f' g' p q wf wg) ≫ coequalizer.desc h wh =
q ≫ h :=
map_π_preserves_coequalizer_inv_colimMap_desc (tensorRight Z) f g f' g' p q wf wg h wh
#align π_tensor_id_preserves_coequalizer_inv_colim_map_desc π_tensor_id_preserves_coequalizer_inv_colimMap_desc
end
end
structure Bimod (A B : Mon_ C) where
X : C
actLeft : A.X ⊗ X ⟶ X
one_actLeft : (A.one ▷ X) ≫ actLeft = (λ_ X).hom := by aesop_cat
left_assoc :
(A.mul ▷ X) ≫ actLeft = (α_ A.X A.X X).hom ≫ (A.X ◁ actLeft) ≫ actLeft := by aesop_cat
actRight : X ⊗ B.X ⟶ X
actRight_one : (X ◁ B.one) ≫ actRight = (ρ_ X).hom := by aesop_cat
right_assoc :
(X ◁ B.mul) ≫ actRight = (α_ X B.X B.X).inv ≫ (actRight ▷ B.X) ≫ actRight := by
aesop_cat
middle_assoc :
(actLeft ▷ B.X) ≫ actRight = (α_ A.X X B.X).hom ≫ (A.X ◁ actRight) ≫ actLeft := by
aesop_cat
set_option linter.uppercaseLean3 false in
#align Bimod Bimod
attribute [reassoc (attr := simp)] Bimod.one_actLeft Bimod.actRight_one Bimod.left_assoc
Bimod.right_assoc Bimod.middle_assoc
namespace Bimod
variable {A B : Mon_ C} (M : Bimod A B)
@[ext]
structure Hom (M N : Bimod A B) where
hom : M.X ⟶ N.X
left_act_hom : M.actLeft ≫ hom = (A.X ◁ hom) ≫ N.actLeft := by aesop_cat
right_act_hom : M.actRight ≫ hom = (hom ▷ B.X) ≫ N.actRight := by aesop_cat
set_option linter.uppercaseLean3 false in
#align Bimod.hom Bimod.Hom
attribute [reassoc (attr := simp)] Hom.left_act_hom Hom.right_act_hom
@[simps]
def id' (M : Bimod A B) : Hom M M where hom := 𝟙 M.X
set_option linter.uppercaseLean3 false in
#align Bimod.id' Bimod.id'
instance homInhabited (M : Bimod A B) : Inhabited (Hom M M) :=
⟨id' M⟩
set_option linter.uppercaseLean3 false in
#align Bimod.hom_inhabited Bimod.homInhabited
@[simps]
def comp {M N O : Bimod A B} (f : Hom M N) (g : Hom N O) : Hom M O where hom := f.hom ≫ g.hom
set_option linter.uppercaseLean3 false in
#align Bimod.comp Bimod.comp
instance : Category (Bimod A B) where
Hom M N := Hom M N
id := id'
comp f g := comp f g
-- Porting note: added because `Hom.ext` is not triggered automatically
@[ext]
lemma hom_ext {M N : Bimod A B} (f g : M ⟶ N) (h : f.hom = g.hom) : f = g :=
Hom.ext _ _ h
@[simp]
theorem id_hom' (M : Bimod A B) : (𝟙 M : Hom M M).hom = 𝟙 M.X :=
rfl
set_option linter.uppercaseLean3 false in
#align Bimod.id_hom' Bimod.id_hom'
@[simp]
theorem comp_hom' {M N K : Bimod A B} (f : M ⟶ N) (g : N ⟶ K) :
(f ≫ g : Hom M K).hom = f.hom ≫ g.hom :=
rfl
set_option linter.uppercaseLean3 false in
#align Bimod.comp_hom' Bimod.comp_hom'
@[simps]
def isoOfIso {X Y : Mon_ C} {P Q : Bimod X Y} (f : P.X ≅ Q.X)
(f_left_act_hom : P.actLeft ≫ f.hom = (X.X ◁ f.hom) ≫ Q.actLeft)
(f_right_act_hom : P.actRight ≫ f.hom = (f.hom ▷ Y.X) ≫ Q.actRight) : P ≅ Q where
hom :=
{ hom := f.hom }
inv :=
{ hom := f.inv
left_act_hom := by
rw [← cancel_mono f.hom, Category.assoc, Category.assoc, Iso.inv_hom_id, Category.comp_id,
f_left_act_hom, ← Category.assoc, ← MonoidalCategory.whiskerLeft_comp, Iso.inv_hom_id,
MonoidalCategory.whiskerLeft_id, Category.id_comp]
right_act_hom := by
rw [← cancel_mono f.hom, Category.assoc, Category.assoc, Iso.inv_hom_id, Category.comp_id,
f_right_act_hom, ← Category.assoc, ← comp_whiskerRight, Iso.inv_hom_id,
MonoidalCategory.id_whiskerRight, Category.id_comp] }
hom_inv_id := by ext; dsimp; rw [Iso.hom_inv_id]
inv_hom_id := by ext; dsimp; rw [Iso.inv_hom_id]
set_option linter.uppercaseLean3 false in
#align Bimod.iso_of_iso Bimod.isoOfIso
variable (A)
@[simps]
def regular : Bimod A A where
X := A.X
actLeft := A.mul
actRight := A.mul
set_option linter.uppercaseLean3 false in
#align Bimod.regular Bimod.regular
instance : Inhabited (Bimod A A) :=
⟨regular A⟩
def forget : Bimod A B ⥤ C where
obj A := A.X
map f := f.hom
set_option linter.uppercaseLean3 false in
#align Bimod.forget Bimod.forget
open CategoryTheory.Limits
variable [HasCoequalizers C]
namespace TensorBimod
variable {R S T : Mon_ C} (P : Bimod R S) (Q : Bimod S T)
noncomputable def X : C :=
coequalizer (P.actRight ▷ Q.X) ((α_ _ _ _).hom ≫ (P.X ◁ Q.actLeft))
set_option linter.uppercaseLean3 false in
#align Bimod.tensor_Bimod.X Bimod.TensorBimod.X
section
variable [∀ X : C, PreservesColimitsOfSize.{0, 0} (tensorLeft X)]
noncomputable def actLeft : R.X ⊗ X P Q ⟶ X P Q :=
(PreservesCoequalizer.iso (tensorLeft R.X) _ _).inv ≫
colimMap
(parallelPairHom _ _ _ _
((α_ _ _ _).inv ≫ ((α_ _ _ _).inv ▷ _) ≫ (P.actLeft ▷ S.X ▷ Q.X))
((α_ _ _ _).inv ≫ (P.actLeft ▷ Q.X))
(by
dsimp
simp only [Category.assoc]
slice_lhs 1 2 => rw [associator_inv_naturality_middle]
slice_rhs 3 4 => rw [← comp_whiskerRight, middle_assoc, comp_whiskerRight]
coherence)
(by
dsimp
slice_lhs 1 1 => rw [MonoidalCategory.whiskerLeft_comp]
slice_lhs 2 3 => rw [associator_inv_naturality_right]
slice_lhs 3 4 => rw [whisker_exchange]
coherence))
set_option linter.uppercaseLean3 false in
#align Bimod.tensor_Bimod.act_left Bimod.TensorBimod.actLeft
theorem whiskerLeft_π_actLeft :
(R.X ◁ coequalizer.π _ _) ≫ actLeft P Q =
(α_ _ _ _).inv ≫ (P.actLeft ▷ Q.X) ≫ coequalizer.π _ _ := by
erw [map_π_preserves_coequalizer_inv_colimMap (tensorLeft _)]
simp only [Category.assoc]
set_option linter.uppercaseLean3 false in
#align Bimod.tensor_Bimod.id_tensor_π_act_left Bimod.TensorBimod.whiskerLeft_π_actLeft
| Mathlib/CategoryTheory/Monoidal/Bimod.lean | 250 | 259 | theorem one_act_left' : (R.one ▷ _) ≫ actLeft P Q = (λ_ _).hom := by |
refine (cancel_epi ((tensorLeft _).map (coequalizer.π _ _))).1 ?_
dsimp [X]
-- Porting note: had to replace `rw` by `erw`
slice_lhs 1 2 => erw [whisker_exchange]
slice_lhs 2 3 => rw [whiskerLeft_π_actLeft]
slice_lhs 1 2 => rw [associator_inv_naturality_left]
slice_lhs 2 3 => rw [← comp_whiskerRight, one_actLeft]
slice_rhs 1 2 => rw [leftUnitor_naturality]
coherence
|
import Mathlib.Algebra.GeomSum
import Mathlib.Algebra.Order.Ring.Basic
import Mathlib.Algebra.Ring.Int
import Mathlib.NumberTheory.Padics.PadicVal
import Mathlib.RingTheory.Ideal.Quotient
#align_import number_theory.multiplicity from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
open Ideal Ideal.Quotient Finset
variable {R : Type*} {n : ℕ}
section CommRing
variable [CommRing R] {a b x y : R}
| Mathlib/NumberTheory/Multiplicity.lean | 39 | 43 | theorem dvd_geom_sum₂_iff_of_dvd_sub {x y p : R} (h : p ∣ x - y) :
(p ∣ ∑ i ∈ range n, x ^ i * y ^ (n - 1 - i)) ↔ p ∣ n * y ^ (n - 1) := by |
rw [← mem_span_singleton, ← Ideal.Quotient.eq] at h
simp only [← mem_span_singleton, ← eq_zero_iff_mem, RingHom.map_geom_sum₂, h, geom_sum₂_self,
_root_.map_mul, map_pow, map_natCast]
|
import Mathlib.Order.Interval.Set.UnorderedInterval
import Mathlib.Algebra.Order.Interval.Set.Monoid
import Mathlib.Data.Set.Pointwise.Basic
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Algebra.Order.Group.MinMax
#align_import data.set.pointwise.interval from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
open Interval Pointwise
variable {α : Type*}
namespace Set
section LinearOrderedField
variable [LinearOrderedField α] {a : α}
@[simp]
theorem preimage_mul_const_Iio (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Iio a = Iio (a / c) :=
ext fun _x => (lt_div_iff h).symm
#align set.preimage_mul_const_Iio Set.preimage_mul_const_Iio
@[simp]
theorem preimage_mul_const_Ioi (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ioi a = Ioi (a / c) :=
ext fun _x => (div_lt_iff h).symm
#align set.preimage_mul_const_Ioi Set.preimage_mul_const_Ioi
@[simp]
theorem preimage_mul_const_Iic (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Iic a = Iic (a / c) :=
ext fun _x => (le_div_iff h).symm
#align set.preimage_mul_const_Iic Set.preimage_mul_const_Iic
@[simp]
theorem preimage_mul_const_Ici (a : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ici a = Ici (a / c) :=
ext fun _x => (div_le_iff h).symm
#align set.preimage_mul_const_Ici Set.preimage_mul_const_Ici
@[simp]
theorem preimage_mul_const_Ioo (a b : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ioo a b = Ioo (a / c) (b / c) := by simp [← Ioi_inter_Iio, h]
#align set.preimage_mul_const_Ioo Set.preimage_mul_const_Ioo
@[simp]
theorem preimage_mul_const_Ioc (a b : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ioc a b = Ioc (a / c) (b / c) := by simp [← Ioi_inter_Iic, h]
#align set.preimage_mul_const_Ioc Set.preimage_mul_const_Ioc
@[simp]
theorem preimage_mul_const_Ico (a b : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Ico a b = Ico (a / c) (b / c) := by simp [← Ici_inter_Iio, h]
#align set.preimage_mul_const_Ico Set.preimage_mul_const_Ico
@[simp]
| Mathlib/Data/Set/Pointwise/Interval.lean | 634 | 635 | theorem preimage_mul_const_Icc (a b : α) {c : α} (h : 0 < c) :
(fun x => x * c) ⁻¹' Icc a b = Icc (a / c) (b / c) := by | simp [← Ici_inter_Iic, h]
|
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 NoZeroDivisors
variable [Semiring R] [NoZeroDivisors R] {p q : R[X]}
instance : NoZeroDivisors R[X] where
eq_zero_or_eq_zero_of_mul_eq_zero h := by
rw [← leadingCoeff_eq_zero, ← leadingCoeff_eq_zero]
refine eq_zero_or_eq_zero_of_mul_eq_zero ?_
rw [← leadingCoeff_zero, ← leadingCoeff_mul, h]
theorem natDegree_mul (hp : p ≠ 0) (hq : q ≠ 0) : (p*q).natDegree = p.natDegree + q.natDegree := by
rw [← Nat.cast_inj (R := WithBot ℕ), ← degree_eq_natDegree (mul_ne_zero hp hq),
Nat.cast_add, ← degree_eq_natDegree hp, ← degree_eq_natDegree hq, degree_mul]
#align polynomial.nat_degree_mul Polynomial.natDegree_mul
theorem trailingDegree_mul : (p * q).trailingDegree = p.trailingDegree + q.trailingDegree := by
by_cases hp : p = 0
· rw [hp, zero_mul, trailingDegree_zero, top_add]
by_cases hq : q = 0
· rw [hq, mul_zero, trailingDegree_zero, add_top]
· rw [trailingDegree_eq_natTrailingDegree hp, trailingDegree_eq_natTrailingDegree hq,
trailingDegree_eq_natTrailingDegree (mul_ne_zero hp hq), natTrailingDegree_mul hp hq]
apply WithTop.coe_add
#align polynomial.trailing_degree_mul Polynomial.trailingDegree_mul
@[simp]
theorem natDegree_pow (p : R[X]) (n : ℕ) : natDegree (p ^ n) = n * natDegree p := by
classical
obtain rfl | hp := eq_or_ne p 0
· obtain rfl | hn := eq_or_ne n 0 <;> simp [*]
exact natDegree_pow' $ by
rw [← leadingCoeff_pow, Ne, leadingCoeff_eq_zero]; exact pow_ne_zero _ hp
#align polynomial.nat_degree_pow Polynomial.natDegree_pow
theorem degree_le_mul_left (p : R[X]) (hq : q ≠ 0) : degree p ≤ degree (p * q) := by
classical
exact if hp : p = 0 then by simp only [hp, zero_mul, le_refl]
else by
rw [degree_mul, degree_eq_natDegree hp, degree_eq_natDegree hq];
exact WithBot.coe_le_coe.2 (Nat.le_add_right _ _)
#align polynomial.degree_le_mul_left Polynomial.degree_le_mul_left
theorem natDegree_le_of_dvd {p q : R[X]} (h1 : p ∣ q) (h2 : q ≠ 0) : p.natDegree ≤ q.natDegree := by
rcases h1 with ⟨q, rfl⟩; rw [mul_ne_zero_iff] at h2
rw [natDegree_mul h2.1 h2.2]; exact Nat.le_add_right _ _
#align polynomial.nat_degree_le_of_dvd Polynomial.natDegree_le_of_dvd
theorem degree_le_of_dvd {p q : R[X]} (h1 : p ∣ q) (h2 : q ≠ 0) : degree p ≤ degree q := by
rcases h1 with ⟨q, rfl⟩; rw [mul_ne_zero_iff] at h2
exact degree_le_mul_left p h2.2
#align polynomial.degree_le_of_dvd Polynomial.degree_le_of_dvd
theorem eq_zero_of_dvd_of_degree_lt {p q : R[X]} (h₁ : p ∣ q) (h₂ : degree q < degree p) :
q = 0 := by
by_contra hc
exact (lt_iff_not_ge _ _).mp h₂ (degree_le_of_dvd h₁ hc)
#align polynomial.eq_zero_of_dvd_of_degree_lt Polynomial.eq_zero_of_dvd_of_degree_lt
| Mathlib/Algebra/Polynomial/RingDivision.lean | 172 | 175 | theorem eq_zero_of_dvd_of_natDegree_lt {p q : R[X]} (h₁ : p ∣ q) (h₂ : natDegree q < natDegree p) :
q = 0 := by |
by_contra hc
exact (lt_iff_not_ge _ _).mp h₂ (natDegree_le_of_dvd h₁ hc)
|
import Mathlib.Algebra.Group.Prod
import Mathlib.Data.Set.Lattice
#align_import data.nat.pairing from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432"
assert_not_exists MonoidWithZero
open Prod Decidable Function
namespace Nat
-- Porting note: no pp_nodot
--@[pp_nodot]
def pair (a b : ℕ) : ℕ :=
if a < b then b * b + a else a * a + a + b
#align nat.mkpair Nat.pair
-- Porting note: no pp_nodot
--@[pp_nodot]
def unpair (n : ℕ) : ℕ × ℕ :=
let s := sqrt n
if n - s * s < s then (n - s * s, s) else (s, n - s * s - s)
#align nat.unpair Nat.unpair
@[simp]
theorem pair_unpair (n : ℕ) : pair (unpair n).1 (unpair n).2 = n := by
dsimp only [unpair]; let s := sqrt n
have sm : s * s + (n - s * s) = n := Nat.add_sub_cancel' (sqrt_le _)
split_ifs with h
· simp [pair, h, sm]
· have hl : n - s * s - s ≤ s := Nat.sub_le_iff_le_add.2
(Nat.sub_le_iff_le_add'.2 <| by rw [← Nat.add_assoc]; apply sqrt_le_add)
simp [pair, hl.not_lt, Nat.add_assoc, Nat.add_sub_cancel' (le_of_not_gt h), sm]
#align nat.mkpair_unpair Nat.pair_unpair
theorem pair_unpair' {n a b} (H : unpair n = (a, b)) : pair a b = n := by
simpa [H] using pair_unpair n
#align nat.mkpair_unpair' Nat.pair_unpair'
@[simp]
| Mathlib/Data/Nat/Pairing.lean | 64 | 73 | theorem unpair_pair (a b : ℕ) : unpair (pair a b) = (a, b) := by |
dsimp only [pair]; split_ifs with h
· show unpair (b * b + a) = (a, b)
have be : sqrt (b * b + a) = b := sqrt_add_eq _ (le_trans (le_of_lt h) (Nat.le_add_left _ _))
simp [unpair, be, Nat.add_sub_cancel_left, h]
· show unpair (a * a + a + b) = (a, b)
have ae : sqrt (a * a + (a + b)) = a := by
rw [sqrt_add_eq]
exact Nat.add_le_add_left (le_of_not_gt h) _
simp [unpair, ae, Nat.not_lt_zero, Nat.add_assoc, Nat.add_sub_cancel_left]
|
import Mathlib.Algebra.Order.Ring.Defs
import Mathlib.Algebra.Group.Int
import Mathlib.Data.Nat.Dist
import Mathlib.Data.Ordmap.Ordnode
import Mathlib.Tactic.Abel
import Mathlib.Tactic.Linarith
#align_import data.ordmap.ordset from "leanprover-community/mathlib"@"47b51515e69f59bca5cf34ef456e6000fe205a69"
variable {α : Type*}
namespace Ordnode
theorem not_le_delta {s} (H : 1 ≤ s) : ¬s ≤ delta * 0 :=
not_le_of_gt H
#align ordnode.not_le_delta Ordnode.not_le_delta
theorem delta_lt_false {a b : ℕ} (h₁ : delta * a < b) (h₂ : delta * b < a) : False :=
not_le_of_lt (lt_trans ((mul_lt_mul_left (by decide)).2 h₁) h₂) <| by
simpa [mul_assoc] using Nat.mul_le_mul_right a (by decide : 1 ≤ delta * delta)
#align ordnode.delta_lt_false Ordnode.delta_lt_false
def realSize : Ordnode α → ℕ
| nil => 0
| node _ l _ r => realSize l + realSize r + 1
#align ordnode.real_size Ordnode.realSize
def Sized : Ordnode α → Prop
| nil => True
| node s l _ r => s = size l + size r + 1 ∧ Sized l ∧ Sized r
#align ordnode.sized Ordnode.Sized
theorem Sized.node' {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (node' l x r) :=
⟨rfl, hl, hr⟩
#align ordnode.sized.node' Ordnode.Sized.node'
theorem Sized.eq_node' {s l x r} (h : @Sized α (node s l x r)) : node s l x r = .node' l x r := by
rw [h.1]
#align ordnode.sized.eq_node' Ordnode.Sized.eq_node'
theorem Sized.size_eq {s l x r} (H : Sized (@node α s l x r)) :
size (@node α s l x r) = size l + size r + 1 :=
H.1
#align ordnode.sized.size_eq Ordnode.Sized.size_eq
@[elab_as_elim]
theorem Sized.induction {t} (hl : @Sized α t) {C : Ordnode α → Prop} (H0 : C nil)
(H1 : ∀ l x r, C l → C r → C (.node' l x r)) : C t := by
induction t with
| nil => exact H0
| node _ _ _ _ t_ih_l t_ih_r =>
rw [hl.eq_node']
exact H1 _ _ _ (t_ih_l hl.2.1) (t_ih_r hl.2.2)
#align ordnode.sized.induction Ordnode.Sized.induction
theorem size_eq_realSize : ∀ {t : Ordnode α}, Sized t → size t = realSize t
| nil, _ => rfl
| node s l x r, ⟨h₁, h₂, h₃⟩ => by
rw [size, h₁, size_eq_realSize h₂, size_eq_realSize h₃]; rfl
#align ordnode.size_eq_real_size Ordnode.size_eq_realSize
@[simp]
theorem Sized.size_eq_zero {t : Ordnode α} (ht : Sized t) : size t = 0 ↔ t = nil := by
cases t <;> [simp;simp [ht.1]]
#align ordnode.sized.size_eq_zero Ordnode.Sized.size_eq_zero
theorem Sized.pos {s l x r} (h : Sized (@node α s l x r)) : 0 < s := by
rw [h.1]; apply Nat.le_add_left
#align ordnode.sized.pos Ordnode.Sized.pos
theorem dual_dual : ∀ t : Ordnode α, dual (dual t) = t
| nil => rfl
| node s l x r => by rw [dual, dual, dual_dual l, dual_dual r]
#align ordnode.dual_dual Ordnode.dual_dual
@[simp]
theorem size_dual (t : Ordnode α) : size (dual t) = size t := by cases t <;> rfl
#align ordnode.size_dual Ordnode.size_dual
def BalancedSz (l r : ℕ) : Prop :=
l + r ≤ 1 ∨ l ≤ delta * r ∧ r ≤ delta * l
#align ordnode.balanced_sz Ordnode.BalancedSz
instance BalancedSz.dec : DecidableRel BalancedSz := fun _ _ => Or.decidable
#align ordnode.balanced_sz.dec Ordnode.BalancedSz.dec
def Balanced : Ordnode α → Prop
| nil => True
| node _ l _ r => BalancedSz (size l) (size r) ∧ Balanced l ∧ Balanced r
#align ordnode.balanced Ordnode.Balanced
instance Balanced.dec : DecidablePred (@Balanced α)
| nil => by
unfold Balanced
infer_instance
| node _ l _ r => by
unfold Balanced
haveI := Balanced.dec l
haveI := Balanced.dec r
infer_instance
#align ordnode.balanced.dec Ordnode.Balanced.dec
@[symm]
theorem BalancedSz.symm {l r : ℕ} : BalancedSz l r → BalancedSz r l :=
Or.imp (by rw [add_comm]; exact id) And.symm
#align ordnode.balanced_sz.symm Ordnode.BalancedSz.symm
theorem balancedSz_zero {l : ℕ} : BalancedSz l 0 ↔ l ≤ 1 := by
simp (config := { contextual := true }) [BalancedSz]
#align ordnode.balanced_sz_zero Ordnode.balancedSz_zero
theorem balancedSz_up {l r₁ r₂ : ℕ} (h₁ : r₁ ≤ r₂) (h₂ : l + r₂ ≤ 1 ∨ r₂ ≤ delta * l)
(H : BalancedSz l r₁) : BalancedSz l r₂ := by
refine or_iff_not_imp_left.2 fun h => ?_
refine ⟨?_, h₂.resolve_left h⟩
cases H with
| inl H =>
cases r₂
· cases h (le_trans (Nat.add_le_add_left (Nat.zero_le _) _) H)
· exact le_trans (le_trans (Nat.le_add_right _ _) H) (Nat.le_add_left 1 _)
| inr H =>
exact le_trans H.1 (Nat.mul_le_mul_left _ h₁)
#align ordnode.balanced_sz_up Ordnode.balancedSz_up
theorem balancedSz_down {l r₁ r₂ : ℕ} (h₁ : r₁ ≤ r₂) (h₂ : l + r₂ ≤ 1 ∨ l ≤ delta * r₁)
(H : BalancedSz l r₂) : BalancedSz l r₁ :=
have : l + r₂ ≤ 1 → BalancedSz l r₁ := fun H => Or.inl (le_trans (Nat.add_le_add_left h₁ _) H)
Or.casesOn H this fun H => Or.casesOn h₂ this fun h₂ => Or.inr ⟨h₂, le_trans h₁ H.2⟩
#align ordnode.balanced_sz_down Ordnode.balancedSz_down
theorem Balanced.dual : ∀ {t : Ordnode α}, Balanced t → Balanced (dual t)
| nil, _ => ⟨⟩
| node _ l _ r, ⟨b, bl, br⟩ => ⟨by rw [size_dual, size_dual]; exact b.symm, br.dual, bl.dual⟩
#align ordnode.balanced.dual Ordnode.Balanced.dual
def node3L (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : Ordnode α :=
node' (node' l x m) y r
#align ordnode.node3_l Ordnode.node3L
def node3R (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : Ordnode α :=
node' l x (node' m y r)
#align ordnode.node3_r Ordnode.node3R
def node4L : Ordnode α → α → Ordnode α → α → Ordnode α → Ordnode α
| l, x, node _ ml y mr, z, r => node' (node' l x ml) y (node' mr z r)
| l, x, nil, z, r => node3L l x nil z r
#align ordnode.node4_l Ordnode.node4L
-- should not happen
def node4R : Ordnode α → α → Ordnode α → α → Ordnode α → Ordnode α
| l, x, node _ ml y mr, z, r => node' (node' l x ml) y (node' mr z r)
| l, x, nil, z, r => node3R l x nil z r
#align ordnode.node4_r Ordnode.node4R
-- should not happen
def rotateL : Ordnode α → α → Ordnode α → Ordnode α
| l, x, node _ m y r => if size m < ratio * size r then node3L l x m y r else node4L l x m y r
| l, x, nil => node' l x nil
#align ordnode.rotate_l Ordnode.rotateL
-- Porting note (#11467): during the port we marked these lemmas with `@[eqns]`
-- to emulate the old Lean 3 behaviour.
theorem rotateL_node (l : Ordnode α) (x : α) (sz : ℕ) (m : Ordnode α) (y : α) (r : Ordnode α) :
rotateL l x (node sz m y r) =
if size m < ratio * size r then node3L l x m y r else node4L l x m y r :=
rfl
theorem rotateL_nil (l : Ordnode α) (x : α) : rotateL l x nil = node' l x nil :=
rfl
-- should not happen
def rotateR : Ordnode α → α → Ordnode α → Ordnode α
| node _ l x m, y, r => if size m < ratio * size l then node3R l x m y r else node4R l x m y r
| nil, y, r => node' nil y r
#align ordnode.rotate_r Ordnode.rotateR
-- Porting note (#11467): during the port we marked these lemmas with `@[eqns]`
-- to emulate the old Lean 3 behaviour.
theorem rotateR_node (sz : ℕ) (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) :
rotateR (node sz l x m) y r =
if size m < ratio * size l then node3R l x m y r else node4R l x m y r :=
rfl
theorem rotateR_nil (y : α) (r : Ordnode α) : rotateR nil y r = node' nil y r :=
rfl
-- should not happen
def balanceL' (l : Ordnode α) (x : α) (r : Ordnode α) : Ordnode α :=
if size l + size r ≤ 1 then node' l x r
else if size l > delta * size r then rotateR l x r else node' l x r
#align ordnode.balance_l' Ordnode.balanceL'
def balanceR' (l : Ordnode α) (x : α) (r : Ordnode α) : Ordnode α :=
if size l + size r ≤ 1 then node' l x r
else if size r > delta * size l then rotateL l x r else node' l x r
#align ordnode.balance_r' Ordnode.balanceR'
def balance' (l : Ordnode α) (x : α) (r : Ordnode α) : Ordnode α :=
if size l + size r ≤ 1 then node' l x r
else
if size r > delta * size l then rotateL l x r
else if size l > delta * size r then rotateR l x r else node' l x r
#align ordnode.balance' Ordnode.balance'
theorem dual_node' (l : Ordnode α) (x : α) (r : Ordnode α) :
dual (node' l x r) = node' (dual r) x (dual l) := by simp [node', add_comm]
#align ordnode.dual_node' Ordnode.dual_node'
theorem dual_node3L (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) :
dual (node3L l x m y r) = node3R (dual r) y (dual m) x (dual l) := by
simp [node3L, node3R, dual_node', add_comm]
#align ordnode.dual_node3_l Ordnode.dual_node3L
theorem dual_node3R (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) :
dual (node3R l x m y r) = node3L (dual r) y (dual m) x (dual l) := by
simp [node3L, node3R, dual_node', add_comm]
#align ordnode.dual_node3_r Ordnode.dual_node3R
theorem dual_node4L (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) :
dual (node4L l x m y r) = node4R (dual r) y (dual m) x (dual l) := by
cases m <;> simp [node4L, node4R, node3R, dual_node3L, dual_node', add_comm]
#align ordnode.dual_node4_l Ordnode.dual_node4L
theorem dual_node4R (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) :
dual (node4R l x m y r) = node4L (dual r) y (dual m) x (dual l) := by
cases m <;> simp [node4L, node4R, node3L, dual_node3R, dual_node', add_comm]
#align ordnode.dual_node4_r Ordnode.dual_node4R
theorem dual_rotateL (l : Ordnode α) (x : α) (r : Ordnode α) :
dual (rotateL l x r) = rotateR (dual r) x (dual l) := by
cases r <;> simp [rotateL, rotateR, dual_node']; split_ifs <;>
simp [dual_node3L, dual_node4L, node3R, add_comm]
#align ordnode.dual_rotate_l Ordnode.dual_rotateL
theorem dual_rotateR (l : Ordnode α) (x : α) (r : Ordnode α) :
dual (rotateR l x r) = rotateL (dual r) x (dual l) := by
rw [← dual_dual (rotateL _ _ _), dual_rotateL, dual_dual, dual_dual]
#align ordnode.dual_rotate_r Ordnode.dual_rotateR
theorem dual_balance' (l : Ordnode α) (x : α) (r : Ordnode α) :
dual (balance' l x r) = balance' (dual r) x (dual l) := by
simp [balance', add_comm]; split_ifs with h h_1 h_2 <;>
simp [dual_node', dual_rotateL, dual_rotateR, add_comm]
cases delta_lt_false h_1 h_2
#align ordnode.dual_balance' Ordnode.dual_balance'
theorem dual_balanceL (l : Ordnode α) (x : α) (r : Ordnode α) :
dual (balanceL l x r) = balanceR (dual r) x (dual l) := by
unfold balanceL balanceR
cases' r with rs rl rx rr
· cases' l with ls ll lx lr; · rfl
cases' ll with lls lll llx llr <;> cases' lr with lrs lrl lrx lrr <;> dsimp only [dual, id] <;>
try rfl
split_ifs with h <;> repeat simp [h, add_comm]
· cases' l with ls ll lx lr; · rfl
dsimp only [dual, id]
split_ifs; swap; · simp [add_comm]
cases' ll with lls lll llx llr <;> cases' lr with lrs lrl lrx lrr <;> try rfl
dsimp only [dual, id]
split_ifs with h <;> simp [h, add_comm]
#align ordnode.dual_balance_l Ordnode.dual_balanceL
theorem dual_balanceR (l : Ordnode α) (x : α) (r : Ordnode α) :
dual (balanceR l x r) = balanceL (dual r) x (dual l) := by
rw [← dual_dual (balanceL _ _ _), dual_balanceL, dual_dual, dual_dual]
#align ordnode.dual_balance_r Ordnode.dual_balanceR
theorem Sized.node3L {l x m y r} (hl : @Sized α l) (hm : Sized m) (hr : Sized r) :
Sized (node3L l x m y r) :=
(hl.node' hm).node' hr
#align ordnode.sized.node3_l Ordnode.Sized.node3L
theorem Sized.node3R {l x m y r} (hl : @Sized α l) (hm : Sized m) (hr : Sized r) :
Sized (node3R l x m y r) :=
hl.node' (hm.node' hr)
#align ordnode.sized.node3_r Ordnode.Sized.node3R
theorem Sized.node4L {l x m y r} (hl : @Sized α l) (hm : Sized m) (hr : Sized r) :
Sized (node4L l x m y r) := by
cases m <;> [exact (hl.node' hm).node' hr; exact (hl.node' hm.2.1).node' (hm.2.2.node' hr)]
#align ordnode.sized.node4_l Ordnode.Sized.node4L
theorem node3L_size {l x m y r} : size (@node3L α l x m y r) = size l + size m + size r + 2 := by
dsimp [node3L, node', size]; rw [add_right_comm _ 1]
#align ordnode.node3_l_size Ordnode.node3L_size
theorem node3R_size {l x m y r} : size (@node3R α l x m y r) = size l + size m + size r + 2 := by
dsimp [node3R, node', size]; rw [← add_assoc, ← add_assoc]
#align ordnode.node3_r_size Ordnode.node3R_size
theorem node4L_size {l x m y r} (hm : Sized m) :
size (@node4L α l x m y r) = size l + size m + size r + 2 := by
cases m <;> simp [node4L, node3L, node'] <;> [abel; (simp [size, hm.1]; abel)]
#align ordnode.node4_l_size Ordnode.node4L_size
theorem Sized.dual : ∀ {t : Ordnode α}, Sized t → Sized (dual t)
| nil, _ => ⟨⟩
| node _ l _ r, ⟨rfl, sl, sr⟩ => ⟨by simp [size_dual, add_comm], Sized.dual sr, Sized.dual sl⟩
#align ordnode.sized.dual Ordnode.Sized.dual
theorem Sized.dual_iff {t : Ordnode α} : Sized (.dual t) ↔ Sized t :=
⟨fun h => by rw [← dual_dual t]; exact h.dual, Sized.dual⟩
#align ordnode.sized.dual_iff Ordnode.Sized.dual_iff
theorem Sized.rotateL {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (rotateL l x r) := by
cases r; · exact hl.node' hr
rw [Ordnode.rotateL_node]; split_ifs
· exact hl.node3L hr.2.1 hr.2.2
· exact hl.node4L hr.2.1 hr.2.2
#align ordnode.sized.rotate_l Ordnode.Sized.rotateL
theorem Sized.rotateR {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (rotateR l x r) :=
Sized.dual_iff.1 <| by rw [dual_rotateR]; exact hr.dual.rotateL hl.dual
#align ordnode.sized.rotate_r Ordnode.Sized.rotateR
theorem Sized.rotateL_size {l x r} (hm : Sized r) :
size (@Ordnode.rotateL α l x r) = size l + size r + 1 := by
cases r <;> simp [Ordnode.rotateL]
simp only [hm.1]
split_ifs <;> simp [node3L_size, node4L_size hm.2.1] <;> abel
#align ordnode.sized.rotate_l_size Ordnode.Sized.rotateL_size
theorem Sized.rotateR_size {l x r} (hl : Sized l) :
size (@Ordnode.rotateR α l x r) = size l + size r + 1 := by
rw [← size_dual, dual_rotateR, hl.dual.rotateL_size, size_dual, size_dual, add_comm (size l)]
#align ordnode.sized.rotate_r_size Ordnode.Sized.rotateR_size
theorem Sized.balance' {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (balance' l x r) := by
unfold balance'; split_ifs
· exact hl.node' hr
· exact hl.rotateL hr
· exact hl.rotateR hr
· exact hl.node' hr
#align ordnode.sized.balance' Ordnode.Sized.balance'
theorem size_balance' {l x r} (hl : @Sized α l) (hr : Sized r) :
size (@balance' α l x r) = size l + size r + 1 := by
unfold balance'; split_ifs
· rfl
· exact hr.rotateL_size
· exact hl.rotateR_size
· rfl
#align ordnode.size_balance' Ordnode.size_balance'
theorem All.imp {P Q : α → Prop} (H : ∀ a, P a → Q a) : ∀ {t}, All P t → All Q t
| nil, _ => ⟨⟩
| node _ _ _ _, ⟨h₁, h₂, h₃⟩ => ⟨h₁.imp H, H _ h₂, h₃.imp H⟩
#align ordnode.all.imp Ordnode.All.imp
theorem Any.imp {P Q : α → Prop} (H : ∀ a, P a → Q a) : ∀ {t}, Any P t → Any Q t
| nil => id
| node _ _ _ _ => Or.imp (Any.imp H) <| Or.imp (H _) (Any.imp H)
#align ordnode.any.imp Ordnode.Any.imp
theorem all_singleton {P : α → Prop} {x : α} : All P (singleton x) ↔ P x :=
⟨fun h => h.2.1, fun h => ⟨⟨⟩, h, ⟨⟩⟩⟩
#align ordnode.all_singleton Ordnode.all_singleton
theorem any_singleton {P : α → Prop} {x : α} : Any P (singleton x) ↔ P x :=
⟨by rintro (⟨⟨⟩⟩ | h | ⟨⟨⟩⟩); exact h, fun h => Or.inr (Or.inl h)⟩
#align ordnode.any_singleton Ordnode.any_singleton
theorem all_dual {P : α → Prop} : ∀ {t : Ordnode α}, All P (dual t) ↔ All P t
| nil => Iff.rfl
| node _ _l _x _r =>
⟨fun ⟨hr, hx, hl⟩ => ⟨all_dual.1 hl, hx, all_dual.1 hr⟩, fun ⟨hl, hx, hr⟩ =>
⟨all_dual.2 hr, hx, all_dual.2 hl⟩⟩
#align ordnode.all_dual Ordnode.all_dual
theorem all_iff_forall {P : α → Prop} : ∀ {t}, All P t ↔ ∀ x, Emem x t → P x
| nil => (iff_true_intro <| by rintro _ ⟨⟩).symm
| node _ l x r => by simp [All, Emem, all_iff_forall, Any, or_imp, forall_and]
#align ordnode.all_iff_forall Ordnode.all_iff_forall
theorem any_iff_exists {P : α → Prop} : ∀ {t}, Any P t ↔ ∃ x, Emem x t ∧ P x
| nil => ⟨by rintro ⟨⟩, by rintro ⟨_, ⟨⟩, _⟩⟩
| node _ l x r => by simp only [Emem]; simp [Any, any_iff_exists, or_and_right, exists_or]
#align ordnode.any_iff_exists Ordnode.any_iff_exists
theorem emem_iff_all {x : α} {t} : Emem x t ↔ ∀ P, All P t → P x :=
⟨fun h _ al => all_iff_forall.1 al _ h, fun H => H _ <| all_iff_forall.2 fun _ => id⟩
#align ordnode.emem_iff_all Ordnode.emem_iff_all
theorem all_node' {P l x r} : @All α P (node' l x r) ↔ All P l ∧ P x ∧ All P r :=
Iff.rfl
#align ordnode.all_node' Ordnode.all_node'
theorem all_node3L {P l x m y r} :
@All α P (node3L l x m y r) ↔ All P l ∧ P x ∧ All P m ∧ P y ∧ All P r := by
simp [node3L, all_node', and_assoc]
#align ordnode.all_node3_l Ordnode.all_node3L
theorem all_node3R {P l x m y r} :
@All α P (node3R l x m y r) ↔ All P l ∧ P x ∧ All P m ∧ P y ∧ All P r :=
Iff.rfl
#align ordnode.all_node3_r Ordnode.all_node3R
theorem all_node4L {P l x m y r} :
@All α P (node4L l x m y r) ↔ All P l ∧ P x ∧ All P m ∧ P y ∧ All P r := by
cases m <;> simp [node4L, all_node', All, all_node3L, and_assoc]
#align ordnode.all_node4_l Ordnode.all_node4L
theorem all_node4R {P l x m y r} :
@All α P (node4R l x m y r) ↔ All P l ∧ P x ∧ All P m ∧ P y ∧ All P r := by
cases m <;> simp [node4R, all_node', All, all_node3R, and_assoc]
#align ordnode.all_node4_r Ordnode.all_node4R
theorem all_rotateL {P l x r} : @All α P (rotateL l x r) ↔ All P l ∧ P x ∧ All P r := by
cases r <;> simp [rotateL, all_node']; split_ifs <;>
simp [all_node3L, all_node4L, All, and_assoc]
#align ordnode.all_rotate_l Ordnode.all_rotateL
theorem all_rotateR {P l x r} : @All α P (rotateR l x r) ↔ All P l ∧ P x ∧ All P r := by
rw [← all_dual, dual_rotateR, all_rotateL]; simp [all_dual, and_comm, and_left_comm, and_assoc]
#align ordnode.all_rotate_r Ordnode.all_rotateR
theorem all_balance' {P l x r} : @All α P (balance' l x r) ↔ All P l ∧ P x ∧ All P r := by
rw [balance']; split_ifs <;> simp [all_node', all_rotateL, all_rotateR]
#align ordnode.all_balance' Ordnode.all_balance'
theorem foldr_cons_eq_toList : ∀ (t : Ordnode α) (r : List α), t.foldr List.cons r = toList t ++ r
| nil, r => rfl
| node _ l x r, r' => by
rw [foldr, foldr_cons_eq_toList l, foldr_cons_eq_toList r, ← List.cons_append,
← List.append_assoc, ← foldr_cons_eq_toList l]; rfl
#align ordnode.foldr_cons_eq_to_list Ordnode.foldr_cons_eq_toList
@[simp]
theorem toList_nil : toList (@nil α) = [] :=
rfl
#align ordnode.to_list_nil Ordnode.toList_nil
@[simp]
theorem toList_node (s l x r) : toList (@node α s l x r) = toList l ++ x :: toList r := by
rw [toList, foldr, foldr_cons_eq_toList]; rfl
#align ordnode.to_list_node Ordnode.toList_node
theorem emem_iff_mem_toList {x : α} {t} : Emem x t ↔ x ∈ toList t := by
unfold Emem; induction t <;> simp [Any, *, or_assoc]
#align ordnode.emem_iff_mem_to_list Ordnode.emem_iff_mem_toList
theorem length_toList' : ∀ t : Ordnode α, (toList t).length = t.realSize
| nil => rfl
| node _ l _ r => by
rw [toList_node, List.length_append, List.length_cons, length_toList' l,
length_toList' r]; rfl
#align ordnode.length_to_list' Ordnode.length_toList'
theorem length_toList {t : Ordnode α} (h : Sized t) : (toList t).length = t.size := by
rw [length_toList', size_eq_realSize h]
#align ordnode.length_to_list Ordnode.length_toList
theorem equiv_iff {t₁ t₂ : Ordnode α} (h₁ : Sized t₁) (h₂ : Sized t₂) :
Equiv t₁ t₂ ↔ toList t₁ = toList t₂ :=
and_iff_right_of_imp fun h => by rw [← length_toList h₁, h, length_toList h₂]
#align ordnode.equiv_iff Ordnode.equiv_iff
| Mathlib/Data/Ordmap/Ordset.lean | 574 | 575 | theorem pos_size_of_mem [LE α] [@DecidableRel α (· ≤ ·)] {x : α} {t : Ordnode α} (h : Sized t)
(h_mem : x ∈ t) : 0 < size t := by | cases t; · { contradiction }; · { simp [h.1] }
|
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex
#align_import analysis.special_functions.trigonometric.arctan from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
noncomputable section
namespace Real
open Set Filter
open scoped Topology Real
theorem tan_add {x y : ℝ}
(h : ((∀ k : ℤ, x ≠ (2 * k + 1) * π / 2) ∧ ∀ l : ℤ, y ≠ (2 * l + 1) * π / 2) ∨
(∃ k : ℤ, x = (2 * k + 1) * π / 2) ∧ ∃ l : ℤ, y = (2 * l + 1) * π / 2) :
tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) := by
simpa only [← Complex.ofReal_inj, Complex.ofReal_sub, Complex.ofReal_add, Complex.ofReal_div,
Complex.ofReal_mul, Complex.ofReal_tan] using
@Complex.tan_add (x : ℂ) (y : ℂ) (by convert h <;> norm_cast)
#align real.tan_add Real.tan_add
theorem tan_add' {x y : ℝ}
(h : (∀ k : ℤ, x ≠ (2 * k + 1) * π / 2) ∧ ∀ l : ℤ, y ≠ (2 * l + 1) * π / 2) :
tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) :=
tan_add (Or.inl h)
#align real.tan_add' Real.tan_add'
theorem tan_two_mul {x : ℝ} : tan (2 * x) = 2 * tan x / (1 - tan x ^ 2) := by
have := @Complex.tan_two_mul x
norm_cast at *
#align real.tan_two_mul Real.tan_two_mul
theorem tan_int_mul_pi_div_two (n : ℤ) : tan (n * π / 2) = 0 :=
tan_eq_zero_iff.mpr (by use n)
#align real.tan_int_mul_pi_div_two Real.tan_int_mul_pi_div_two
theorem continuousOn_tan : ContinuousOn tan {x | cos x ≠ 0} := by
suffices ContinuousOn (fun x => sin x / cos x) {x | cos x ≠ 0} by
have h_eq : (fun x => sin x / cos x) = tan := by ext1 x; rw [tan_eq_sin_div_cos]
rwa [h_eq] at this
exact continuousOn_sin.div continuousOn_cos fun x => id
#align real.continuous_on_tan Real.continuousOn_tan
@[continuity]
theorem continuous_tan : Continuous fun x : {x | cos x ≠ 0} => tan x :=
continuousOn_iff_continuous_restrict.1 continuousOn_tan
#align real.continuous_tan Real.continuous_tan
theorem continuousOn_tan_Ioo : ContinuousOn tan (Ioo (-(π / 2)) (π / 2)) := by
refine ContinuousOn.mono continuousOn_tan fun x => ?_
simp only [and_imp, mem_Ioo, mem_setOf_eq, Ne]
rw [cos_eq_zero_iff]
rintro hx_gt hx_lt ⟨r, hxr_eq⟩
rcases le_or_lt 0 r with h | h
· rw [lt_iff_not_ge] at hx_lt
refine hx_lt ?_
rw [hxr_eq, ← one_mul (π / 2), mul_div_assoc, ge_iff_le, mul_le_mul_right (half_pos pi_pos)]
simp [h]
· rw [lt_iff_not_ge] at hx_gt
refine hx_gt ?_
rw [hxr_eq, ← one_mul (π / 2), mul_div_assoc, ge_iff_le, neg_mul_eq_neg_mul,
mul_le_mul_right (half_pos pi_pos)]
have hr_le : r ≤ -1 := by rwa [Int.lt_iff_add_one_le, ← le_neg_iff_add_nonpos_right] at h
rw [← le_sub_iff_add_le, mul_comm, ← le_div_iff]
· set_option tactic.skipAssignedInstances false in norm_num
rw [← Int.cast_one, ← Int.cast_neg]; norm_cast
· exact zero_lt_two
#align real.continuous_on_tan_Ioo Real.continuousOn_tan_Ioo
theorem surjOn_tan : SurjOn tan (Ioo (-(π / 2)) (π / 2)) univ :=
have := neg_lt_self pi_div_two_pos
continuousOn_tan_Ioo.surjOn_of_tendsto (nonempty_Ioo.2 this)
(by rw [tendsto_comp_coe_Ioo_atBot this]; exact tendsto_tan_neg_pi_div_two)
(by rw [tendsto_comp_coe_Ioo_atTop this]; exact tendsto_tan_pi_div_two)
#align real.surj_on_tan Real.surjOn_tan
theorem tan_surjective : Function.Surjective tan := fun _ => surjOn_tan.subset_range trivial
#align real.tan_surjective Real.tan_surjective
theorem image_tan_Ioo : tan '' Ioo (-(π / 2)) (π / 2) = univ :=
univ_subset_iff.1 surjOn_tan
#align real.image_tan_Ioo Real.image_tan_Ioo
def tanOrderIso : Ioo (-(π / 2)) (π / 2) ≃o ℝ :=
(strictMonoOn_tan.orderIso _ _).trans <|
(OrderIso.setCongr _ _ image_tan_Ioo).trans OrderIso.Set.univ
#align real.tan_order_iso Real.tanOrderIso
-- @[pp_nodot] -- Porting note: removed
noncomputable def arctan (x : ℝ) : ℝ :=
tanOrderIso.symm x
#align real.arctan Real.arctan
@[simp]
theorem tan_arctan (x : ℝ) : tan (arctan x) = x :=
tanOrderIso.apply_symm_apply x
#align real.tan_arctan Real.tan_arctan
theorem arctan_mem_Ioo (x : ℝ) : arctan x ∈ Ioo (-(π / 2)) (π / 2) :=
Subtype.coe_prop _
#align real.arctan_mem_Ioo Real.arctan_mem_Ioo
@[simp]
theorem range_arctan : range arctan = Ioo (-(π / 2)) (π / 2) :=
((EquivLike.surjective _).range_comp _).trans Subtype.range_coe
#align real.range_arctan Real.range_arctan
theorem arctan_tan {x : ℝ} (hx₁ : -(π / 2) < x) (hx₂ : x < π / 2) : arctan (tan x) = x :=
Subtype.ext_iff.1 <| tanOrderIso.symm_apply_apply ⟨x, hx₁, hx₂⟩
#align real.arctan_tan Real.arctan_tan
theorem cos_arctan_pos (x : ℝ) : 0 < cos (arctan x) :=
cos_pos_of_mem_Ioo <| arctan_mem_Ioo x
#align real.cos_arctan_pos Real.cos_arctan_pos
theorem cos_sq_arctan (x : ℝ) : cos (arctan x) ^ 2 = 1 / (1 + x ^ 2) := by
rw_mod_cast [one_div, ← inv_one_add_tan_sq (cos_arctan_pos x).ne', tan_arctan]
#align real.cos_sq_arctan Real.cos_sq_arctan
| Mathlib/Analysis/SpecialFunctions/Trigonometric/Arctan.lean | 142 | 143 | theorem sin_arctan (x : ℝ) : sin (arctan x) = x / √(1 + x ^ 2) := by |
rw_mod_cast [← tan_div_sqrt_one_add_tan_sq (cos_arctan_pos x), tan_arctan]
|
import Mathlib.RingTheory.Derivation.ToSquareZero
import Mathlib.RingTheory.Ideal.Cotangent
import Mathlib.RingTheory.IsTensorProduct
import Mathlib.Algebra.Exact
import Mathlib.Algebra.MvPolynomial.PDeriv
import Mathlib.Algebra.Polynomial.Derivation
#align_import ring_theory.kaehler from "leanprover-community/mathlib"@"4b92a463033b5587bb011657e25e4710bfca7364"
suppress_compilation
section KaehlerDifferential
open scoped TensorProduct
open Algebra
universe u v
variable (R : Type u) (S : Type v) [CommRing R] [CommRing S] [Algebra R S]
abbrev KaehlerDifferential.ideal : Ideal (S ⊗[R] S) :=
RingHom.ker (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S)
#align kaehler_differential.ideal KaehlerDifferential.ideal
variable {S}
theorem KaehlerDifferential.one_smul_sub_smul_one_mem_ideal (a : S) :
(1 : S) ⊗ₜ[R] a - a ⊗ₜ[R] (1 : S) ∈ KaehlerDifferential.ideal R S := by simp [RingHom.mem_ker]
#align kaehler_differential.one_smul_sub_smul_one_mem_ideal KaehlerDifferential.one_smul_sub_smul_one_mem_ideal
variable {R}
variable {M : Type*} [AddCommGroup M] [Module R M] [Module S M] [IsScalarTower R S M]
def Derivation.tensorProductTo (D : Derivation R S M) : S ⊗[R] S →ₗ[S] M :=
TensorProduct.AlgebraTensorModule.lift ((LinearMap.lsmul S (S →ₗ[R] M)).flip D.toLinearMap)
#align derivation.tensor_product_to Derivation.tensorProductTo
theorem Derivation.tensorProductTo_tmul (D : Derivation R S M) (s t : S) :
D.tensorProductTo (s ⊗ₜ t) = s • D t := rfl
#align derivation.tensor_product_to_tmul Derivation.tensorProductTo_tmul
theorem Derivation.tensorProductTo_mul (D : Derivation R S M) (x y : S ⊗[R] S) :
D.tensorProductTo (x * y) =
TensorProduct.lmul' (S := S) R x • D.tensorProductTo y +
TensorProduct.lmul' (S := S) R y • D.tensorProductTo x := by
refine TensorProduct.induction_on x ?_ ?_ ?_
· rw [zero_mul, map_zero, map_zero, zero_smul, smul_zero, add_zero]
swap
· intro x₁ y₁ h₁ h₂
rw [add_mul, map_add, map_add, map_add, add_smul, smul_add, h₁, h₂, add_add_add_comm]
intro x₁ x₂
refine TensorProduct.induction_on y ?_ ?_ ?_
· rw [mul_zero, map_zero, map_zero, zero_smul, smul_zero, add_zero]
swap
· intro x₁ y₁ h₁ h₂
rw [mul_add, map_add, map_add, map_add, add_smul, smul_add, h₁, h₂, add_add_add_comm]
intro x y
simp only [TensorProduct.tmul_mul_tmul, Derivation.tensorProductTo,
TensorProduct.AlgebraTensorModule.lift_apply, TensorProduct.lift.tmul',
TensorProduct.lmul'_apply_tmul]
dsimp
rw [D.leibniz]
simp only [smul_smul, smul_add, mul_comm (x * y) x₁, mul_right_comm x₁ x₂, ← mul_assoc]
#align derivation.tensor_product_to_mul Derivation.tensorProductTo_mul
variable (R S)
theorem KaehlerDifferential.submodule_span_range_eq_ideal :
Submodule.span S (Set.range fun s : S => (1 : S) ⊗ₜ[R] s - s ⊗ₜ[R] (1 : S)) =
(KaehlerDifferential.ideal R S).restrictScalars S := by
apply le_antisymm
· rw [Submodule.span_le]
rintro _ ⟨s, rfl⟩
exact KaehlerDifferential.one_smul_sub_smul_one_mem_ideal _ _
· rintro x (hx : _ = _)
have : x - TensorProduct.lmul' (S := S) R x ⊗ₜ[R] (1 : S) = x := by
rw [hx, TensorProduct.zero_tmul, sub_zero]
rw [← this]
clear this hx
refine TensorProduct.induction_on x ?_ ?_ ?_
· rw [map_zero, TensorProduct.zero_tmul, sub_zero]; exact zero_mem _
· intro x y
have : x ⊗ₜ[R] y - (x * y) ⊗ₜ[R] (1 : S) = x • ((1 : S) ⊗ₜ y - y ⊗ₜ (1 : S)) := by
simp_rw [smul_sub, TensorProduct.smul_tmul', smul_eq_mul, mul_one]
rw [TensorProduct.lmul'_apply_tmul, this]
refine Submodule.smul_mem _ x ?_
apply Submodule.subset_span
exact Set.mem_range_self y
· intro x y hx hy
rw [map_add, TensorProduct.add_tmul, ← sub_add_sub_comm]
exact add_mem hx hy
#align kaehler_differential.submodule_span_range_eq_ideal KaehlerDifferential.submodule_span_range_eq_ideal
theorem KaehlerDifferential.span_range_eq_ideal :
Ideal.span (Set.range fun s : S => (1 : S) ⊗ₜ[R] s - s ⊗ₜ[R] (1 : S)) =
KaehlerDifferential.ideal R S := by
apply le_antisymm
· rw [Ideal.span_le]
rintro _ ⟨s, rfl⟩
exact KaehlerDifferential.one_smul_sub_smul_one_mem_ideal _ _
· change (KaehlerDifferential.ideal R S).restrictScalars S ≤ (Ideal.span _).restrictScalars S
rw [← KaehlerDifferential.submodule_span_range_eq_ideal, Ideal.span]
conv_rhs => rw [← Submodule.span_span_of_tower S]
exact Submodule.subset_span
#align kaehler_differential.span_range_eq_ideal KaehlerDifferential.span_range_eq_ideal
def KaehlerDifferential : Type v :=
(KaehlerDifferential.ideal R S).Cotangent
#align kaehler_differential KaehlerDifferential
instance : AddCommGroup (KaehlerDifferential R S) := by
unfold KaehlerDifferential
infer_instance
instance KaehlerDifferential.module : Module (S ⊗[R] S) (KaehlerDifferential R S) :=
Ideal.Cotangent.moduleOfTower _
#align kaehler_differential.module KaehlerDifferential.module
@[inherit_doc KaehlerDifferential]
notation:100 "Ω[" S "⁄" R "]" => KaehlerDifferential R S
instance : Nonempty (Ω[S⁄R]) := ⟨0⟩
instance KaehlerDifferential.module' {R' : Type*} [CommRing R'] [Algebra R' S]
[SMulCommClass R R' S] :
Module R' (Ω[S⁄R]) :=
Submodule.Quotient.module' _
#align kaehler_differential.module' KaehlerDifferential.module'
instance : IsScalarTower S (S ⊗[R] S) (Ω[S⁄R]) :=
Ideal.Cotangent.isScalarTower _
instance KaehlerDifferential.isScalarTower_of_tower {R₁ R₂ : Type*} [CommRing R₁] [CommRing R₂]
[Algebra R₁ S] [Algebra R₂ S] [SMul R₁ R₂]
[SMulCommClass R R₁ S] [SMulCommClass R R₂ S] [IsScalarTower R₁ R₂ S] :
IsScalarTower R₁ R₂ (Ω[S⁄R]) :=
Submodule.Quotient.isScalarTower _ _
#align kaehler_differential.is_scalar_tower_of_tower KaehlerDifferential.isScalarTower_of_tower
instance KaehlerDifferential.isScalarTower' : IsScalarTower R (S ⊗[R] S) (Ω[S⁄R]) :=
Submodule.Quotient.isScalarTower _ _
#align kaehler_differential.is_scalar_tower' KaehlerDifferential.isScalarTower'
def KaehlerDifferential.fromIdeal : KaehlerDifferential.ideal R S →ₗ[S ⊗[R] S] Ω[S⁄R] :=
(KaehlerDifferential.ideal R S).toCotangent
#align kaehler_differential.from_ideal KaehlerDifferential.fromIdeal
def KaehlerDifferential.DLinearMap : S →ₗ[R] Ω[S⁄R] :=
((KaehlerDifferential.fromIdeal R S).restrictScalars R).comp
((TensorProduct.includeRight.toLinearMap - TensorProduct.includeLeft.toLinearMap :
S →ₗ[R] S ⊗[R] S).codRestrict
((KaehlerDifferential.ideal R S).restrictScalars R)
(KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R) :
_ →ₗ[R] _)
set_option linter.uppercaseLean3 false in
#align kaehler_differential.D_linear_map KaehlerDifferential.DLinearMap
theorem KaehlerDifferential.DLinearMap_apply (s : S) :
KaehlerDifferential.DLinearMap R S s =
(KaehlerDifferential.ideal R S).toCotangent
⟨1 ⊗ₜ s - s ⊗ₜ 1, KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R s⟩ := rfl
set_option linter.uppercaseLean3 false in
#align kaehler_differential.D_linear_map_apply KaehlerDifferential.DLinearMap_apply
def KaehlerDifferential.D : Derivation R S (Ω[S⁄R]) :=
{ toLinearMap := KaehlerDifferential.DLinearMap R S
map_one_eq_zero' := by
dsimp [KaehlerDifferential.DLinearMap_apply, Ideal.toCotangent_apply]
congr
rw [sub_self]
leibniz' := fun a b => by
have : LinearMap.CompatibleSMul { x // x ∈ ideal R S } (Ω[S⁄R]) S (S ⊗[R] S) := inferInstance
dsimp [KaehlerDifferential.DLinearMap_apply]
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [← LinearMap.map_smul_of_tower (M₂ := Ω[S⁄R]),
← LinearMap.map_smul_of_tower (M₂ := Ω[S⁄R]), ← map_add, Ideal.toCotangent_eq, pow_two]
convert Submodule.mul_mem_mul (KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R a : _)
(KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R b : _) using 1
simp only [AddSubgroupClass.coe_sub, Submodule.coe_add, Submodule.coe_mk,
TensorProduct.tmul_mul_tmul, mul_sub, sub_mul, mul_comm b, Submodule.coe_smul_of_tower,
smul_sub, TensorProduct.smul_tmul', smul_eq_mul, mul_one]
ring_nf }
set_option linter.uppercaseLean3 false in
#align kaehler_differential.D KaehlerDifferential.D
theorem KaehlerDifferential.D_apply (s : S) :
KaehlerDifferential.D R S s =
(KaehlerDifferential.ideal R S).toCotangent
⟨1 ⊗ₜ s - s ⊗ₜ 1, KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R s⟩ := rfl
set_option linter.uppercaseLean3 false in
#align kaehler_differential.D_apply KaehlerDifferential.D_apply
theorem KaehlerDifferential.span_range_derivation :
Submodule.span S (Set.range <| KaehlerDifferential.D R S) = ⊤ := by
rw [_root_.eq_top_iff]
rintro x -
obtain ⟨⟨x, hx⟩, rfl⟩ := Ideal.toCotangent_surjective _ x
have : x ∈ (KaehlerDifferential.ideal R S).restrictScalars S := hx
rw [← KaehlerDifferential.submodule_span_range_eq_ideal] at this
suffices ∃ hx, (KaehlerDifferential.ideal R S).toCotangent ⟨x, hx⟩ ∈
Submodule.span S (Set.range <| KaehlerDifferential.D R S) by
exact this.choose_spec
refine Submodule.span_induction this ?_ ?_ ?_ ?_
· rintro _ ⟨x, rfl⟩
refine ⟨KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R x, ?_⟩
apply Submodule.subset_span
exact ⟨x, KaehlerDifferential.DLinearMap_apply R S x⟩
· exact ⟨zero_mem _, Submodule.zero_mem _⟩
· rintro x y ⟨hx₁, hx₂⟩ ⟨hy₁, hy₂⟩; exact ⟨add_mem hx₁ hy₁, Submodule.add_mem _ hx₂ hy₂⟩
· rintro r x ⟨hx₁, hx₂⟩;
exact ⟨((KaehlerDifferential.ideal R S).restrictScalars S).smul_mem r hx₁,
Submodule.smul_mem _ r hx₂⟩
#align kaehler_differential.span_range_derivation KaehlerDifferential.span_range_derivation
variable {R S}
def Derivation.liftKaehlerDifferential (D : Derivation R S M) : Ω[S⁄R] →ₗ[S] M := by
refine LinearMap.comp ((((KaehlerDifferential.ideal R S) •
(⊤ : Submodule (S ⊗[R] S) (KaehlerDifferential.ideal R S))).restrictScalars S).liftQ ?_ ?_)
(Submodule.Quotient.restrictScalarsEquiv S _).symm.toLinearMap
· exact D.tensorProductTo.comp ((KaehlerDifferential.ideal R S).subtype.restrictScalars S)
· intro x hx
rw [LinearMap.mem_ker]
refine Submodule.smul_induction_on hx ?_ ?_
· rintro x hx y -
rw [RingHom.mem_ker] at hx
dsimp
rw [Derivation.tensorProductTo_mul, hx, y.prop, zero_smul, zero_smul, zero_add]
· intro x y ex ey; rw [map_add, ex, ey, zero_add]
#align derivation.lift_kaehler_differential Derivation.liftKaehlerDifferential
theorem Derivation.liftKaehlerDifferential_apply (D : Derivation R S M) (x) :
D.liftKaehlerDifferential ((KaehlerDifferential.ideal R S).toCotangent x) =
D.tensorProductTo x := rfl
#align derivation.lift_kaehler_differential_apply Derivation.liftKaehlerDifferential_apply
theorem Derivation.liftKaehlerDifferential_comp (D : Derivation R S M) :
D.liftKaehlerDifferential.compDer (KaehlerDifferential.D R S) = D := by
ext a
dsimp [KaehlerDifferential.D_apply]
refine (D.liftKaehlerDifferential_apply _).trans ?_
rw [Subtype.coe_mk, map_sub, Derivation.tensorProductTo_tmul, Derivation.tensorProductTo_tmul,
one_smul, D.map_one_eq_zero, smul_zero, sub_zero]
#align derivation.lift_kaehler_differential_comp Derivation.liftKaehlerDifferential_comp
@[simp]
theorem Derivation.liftKaehlerDifferential_comp_D (D' : Derivation R S M) (x : S) :
D'.liftKaehlerDifferential (KaehlerDifferential.D R S x) = D' x :=
Derivation.congr_fun D'.liftKaehlerDifferential_comp x
set_option linter.uppercaseLean3 false in
#align derivation.lift_kaehler_differential_comp_D Derivation.liftKaehlerDifferential_comp_D
@[ext]
theorem Derivation.liftKaehlerDifferential_unique (f f' : Ω[S⁄R] →ₗ[S] M)
(hf : f.compDer (KaehlerDifferential.D R S) = f'.compDer (KaehlerDifferential.D R S)) :
f = f' := by
apply LinearMap.ext
intro x
have : x ∈ Submodule.span S (Set.range <| KaehlerDifferential.D R S) := by
rw [KaehlerDifferential.span_range_derivation]; trivial
refine Submodule.span_induction this ?_ ?_ ?_ ?_
· rintro _ ⟨x, rfl⟩; exact congr_arg (fun D : Derivation R S M => D x) hf
· rw [map_zero, map_zero]
· intro x y hx hy; rw [map_add, map_add, hx, hy]
· intro a x e; simp [e]
#align derivation.lift_kaehler_differential_unique Derivation.liftKaehlerDifferential_unique
variable (R S)
theorem Derivation.liftKaehlerDifferential_D :
(KaehlerDifferential.D R S).liftKaehlerDifferential = LinearMap.id :=
Derivation.liftKaehlerDifferential_unique _ _
(KaehlerDifferential.D R S).liftKaehlerDifferential_comp
set_option linter.uppercaseLean3 false in
#align derivation.lift_kaehler_differential_D Derivation.liftKaehlerDifferential_D
variable {R S}
theorem KaehlerDifferential.D_tensorProductTo (x : KaehlerDifferential.ideal R S) :
(KaehlerDifferential.D R S).tensorProductTo x =
(KaehlerDifferential.ideal R S).toCotangent x := by
rw [← Derivation.liftKaehlerDifferential_apply, Derivation.liftKaehlerDifferential_D]
rfl
set_option linter.uppercaseLean3 false in
#align kaehler_differential.D_tensor_product_to KaehlerDifferential.D_tensorProductTo
variable (R S)
theorem KaehlerDifferential.tensorProductTo_surjective :
Function.Surjective (KaehlerDifferential.D R S).tensorProductTo := by
intro x; obtain ⟨x, rfl⟩ := (KaehlerDifferential.ideal R S).toCotangent_surjective x
exact ⟨x, KaehlerDifferential.D_tensorProductTo x⟩
#align kaehler_differential.tensor_product_to_surjective KaehlerDifferential.tensorProductTo_surjective
@[simps! symm_apply apply_apply]
def KaehlerDifferential.linearMapEquivDerivation : (Ω[S⁄R] →ₗ[S] M) ≃ₗ[S] Derivation R S M :=
{ Derivation.llcomp.flip <| KaehlerDifferential.D R S with
invFun := Derivation.liftKaehlerDifferential
left_inv := fun _ =>
Derivation.liftKaehlerDifferential_unique _ _ (Derivation.liftKaehlerDifferential_comp _)
right_inv := Derivation.liftKaehlerDifferential_comp }
#align kaehler_differential.linear_map_equiv_derivation KaehlerDifferential.linearMapEquivDerivation
def KaehlerDifferential.quotientCotangentIdealRingEquiv :
(S ⊗ S ⧸ KaehlerDifferential.ideal R S ^ 2) ⧸ (KaehlerDifferential.ideal R S).cotangentIdeal ≃+*
S := by
have : Function.RightInverse (TensorProduct.includeLeft (R := R) (S := R) (A := S) (B := S))
(↑(TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S) : S ⊗[R] S →+* S) := by
intro x; rw [AlgHom.coe_toRingHom, ← AlgHom.comp_apply, TensorProduct.lmul'_comp_includeLeft]
rfl
refine (Ideal.quotCotangent _).trans ?_
refine (Ideal.quotEquivOfEq ?_).trans (RingHom.quotientKerEquivOfRightInverse this)
ext; rfl
#align kaehler_differential.quotient_cotangent_ideal_ring_equiv KaehlerDifferential.quotientCotangentIdealRingEquiv
def KaehlerDifferential.quotientCotangentIdeal :
((S ⊗ S ⧸ KaehlerDifferential.ideal R S ^ 2) ⧸
(KaehlerDifferential.ideal R S).cotangentIdeal) ≃ₐ[S] S :=
{ KaehlerDifferential.quotientCotangentIdealRingEquiv R S with
commutes' := (KaehlerDifferential.quotientCotangentIdealRingEquiv R S).apply_symm_apply }
#align kaehler_differential.quotient_cotangent_ideal KaehlerDifferential.quotientCotangentIdeal
theorem KaehlerDifferential.End_equiv_aux (f : S →ₐ[R] S ⊗ S ⧸ KaehlerDifferential.ideal R S ^ 2) :
(Ideal.Quotient.mkₐ R (KaehlerDifferential.ideal R S).cotangentIdeal).comp f =
IsScalarTower.toAlgHom R S _ ↔
(TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S).kerSquareLift.comp f = AlgHom.id R S := by
rw [AlgHom.ext_iff, AlgHom.ext_iff]
apply forall_congr'
intro x
have e₁ : (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S).kerSquareLift (f x) =
KaehlerDifferential.quotientCotangentIdealRingEquiv R S
(Ideal.Quotient.mk (KaehlerDifferential.ideal R S).cotangentIdeal <| f x) := by
generalize f x = y; obtain ⟨y, rfl⟩ := Ideal.Quotient.mk_surjective y; rfl
have e₂ :
x = KaehlerDifferential.quotientCotangentIdealRingEquiv R S (IsScalarTower.toAlgHom R S _ x) :=
(mul_one x).symm
constructor
· intro e
exact (e₁.trans (@RingEquiv.congr_arg _ _ _ _ _ _
(KaehlerDifferential.quotientCotangentIdealRingEquiv R S) _ _ e)).trans e₂.symm
· intro e; apply (KaehlerDifferential.quotientCotangentIdealRingEquiv R S).injective
exact e₁.symm.trans (e.trans e₂)
#align kaehler_differential.End_equiv_aux KaehlerDifferential.End_equiv_aux
local instance smul_SSmod_SSmod : SMul (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2)
(S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := Mul.toSMul _
@[nolint defLemma]
local instance isScalarTower_S_right :
IsScalarTower S (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2)
(S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := Ideal.Quotient.isScalarTower_right
@[nolint defLemma]
local instance isScalarTower_R_right :
IsScalarTower R (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2)
(S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := Ideal.Quotient.isScalarTower_right
@[nolint defLemma]
local instance isScalarTower_SS_right : IsScalarTower (S ⊗[R] S)
(S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) :=
Ideal.Quotient.isScalarTower_right
local instance instS : Module S (KaehlerDifferential.ideal R S).cotangentIdeal :=
Submodule.module' _
local instance instR : Module R (KaehlerDifferential.ideal R S).cotangentIdeal :=
Submodule.module' _
local instance instSS : Module (S ⊗[R] S) (KaehlerDifferential.ideal R S).cotangentIdeal :=
Submodule.module' _
noncomputable def KaehlerDifferential.endEquivDerivation' :
Derivation R S (Ω[S⁄R]) ≃ₗ[R] Derivation R S (ideal R S).cotangentIdeal :=
LinearEquiv.compDer ((KaehlerDifferential.ideal R S).cotangentEquivIdeal.restrictScalars S)
#align kaehler_differential.End_equiv_derivation' KaehlerDifferential.endEquivDerivation'
def KaehlerDifferential.endEquivAuxEquiv :
{ f //
(Ideal.Quotient.mkₐ R (KaehlerDifferential.ideal R S).cotangentIdeal).comp f =
IsScalarTower.toAlgHom R S _ } ≃
{ f // (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S).kerSquareLift.comp f = AlgHom.id R S } :=
(Equiv.refl _).subtypeEquiv (KaehlerDifferential.End_equiv_aux R S)
#align kaehler_differential.End_equiv_aux_equiv KaehlerDifferential.endEquivAuxEquiv
noncomputable def KaehlerDifferential.endEquiv :
Module.End S (Ω[S⁄R]) ≃
{ f // (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S).kerSquareLift.comp f = AlgHom.id R S } :=
(KaehlerDifferential.linearMapEquivDerivation R S).toEquiv.trans <|
(KaehlerDifferential.endEquivDerivation' R S).toEquiv.trans <|
(derivationToSquareZeroEquivLift (KaehlerDifferential.ideal R S).cotangentIdeal
(KaehlerDifferential.ideal R S).cotangentIdeal_square).trans <|
KaehlerDifferential.endEquivAuxEquiv R S
#align kaehler_differential.End_equiv KaehlerDifferential.endEquiv
section Presentation
open KaehlerDifferential (D)
open Finsupp (single)
noncomputable def KaehlerDifferential.kerTotal : Submodule S (S →₀ S) :=
Submodule.span S
(((Set.range fun x : S × S => single x.1 1 + single x.2 1 - single (x.1 + x.2) 1) ∪
Set.range fun x : S × S => single x.2 x.1 + single x.1 x.2 - single (x.1 * x.2) 1) ∪
Set.range fun x : R => single (algebraMap R S x) 1)
#align kaehler_differential.ker_total KaehlerDifferential.kerTotal
unsuppress_compilation in
-- Porting note: was `local notation x "𝖣" y => (KaehlerDifferential.kerTotal R S).mkQ (single y x)`
-- but not having `DFunLike.coe` leads to `kerTotal_mkQ_single_smul` failing.
local notation3 x "𝖣" y => DFunLike.coe (KaehlerDifferential.kerTotal R S).mkQ (single y x)
theorem KaehlerDifferential.kerTotal_mkQ_single_add (x y z) : (z𝖣x + y) = (z𝖣x) + z𝖣y := by
rw [← map_add, eq_comm, ← sub_eq_zero, ← map_sub (Submodule.mkQ (kerTotal R S)),
Submodule.mkQ_apply, Submodule.Quotient.mk_eq_zero]
simp_rw [← Finsupp.smul_single_one _ z, ← smul_add, ← smul_sub]
exact Submodule.smul_mem _ _ (Submodule.subset_span (Or.inl <| Or.inl <| ⟨⟨_, _⟩, rfl⟩))
#align kaehler_differential.ker_total_mkq_single_add KaehlerDifferential.kerTotal_mkQ_single_add
theorem KaehlerDifferential.kerTotal_mkQ_single_mul (x y z) :
(z𝖣x * y) = ((z * x)𝖣y) + (z * y)𝖣x := by
rw [← map_add, eq_comm, ← sub_eq_zero, ← map_sub (Submodule.mkQ (kerTotal R S)),
Submodule.mkQ_apply, Submodule.Quotient.mk_eq_zero]
simp_rw [← Finsupp.smul_single_one _ z, ← @smul_eq_mul _ _ z, ← Finsupp.smul_single, ← smul_add,
← smul_sub]
exact Submodule.smul_mem _ _ (Submodule.subset_span (Or.inl <| Or.inr <| ⟨⟨_, _⟩, rfl⟩))
#align kaehler_differential.ker_total_mkq_single_mul KaehlerDifferential.kerTotal_mkQ_single_mul
theorem KaehlerDifferential.kerTotal_mkQ_single_algebraMap (x y) : (y𝖣algebraMap R S x) = 0 := by
rw [Submodule.mkQ_apply, Submodule.Quotient.mk_eq_zero, ← Finsupp.smul_single_one _ y]
exact Submodule.smul_mem _ _ (Submodule.subset_span (Or.inr <| ⟨_, rfl⟩))
#align kaehler_differential.ker_total_mkq_single_algebra_map KaehlerDifferential.kerTotal_mkQ_single_algebraMap
theorem KaehlerDifferential.kerTotal_mkQ_single_algebraMap_one (x) : (x𝖣1) = 0 := by
rw [← (algebraMap R S).map_one, KaehlerDifferential.kerTotal_mkQ_single_algebraMap]
#align kaehler_differential.ker_total_mkq_single_algebra_map_one KaehlerDifferential.kerTotal_mkQ_single_algebraMap_one
theorem KaehlerDifferential.kerTotal_mkQ_single_smul (r : R) (x y) : (y𝖣r • x) = r • y𝖣x := by
letI : SMulZeroClass R S := inferInstance
rw [Algebra.smul_def, KaehlerDifferential.kerTotal_mkQ_single_mul,
KaehlerDifferential.kerTotal_mkQ_single_algebraMap, add_zero, ← LinearMap.map_smul_of_tower,
Finsupp.smul_single, mul_comm, Algebra.smul_def]
#align kaehler_differential.ker_total_mkq_single_smul KaehlerDifferential.kerTotal_mkQ_single_smul
noncomputable def KaehlerDifferential.derivationQuotKerTotal :
Derivation R S ((S →₀ S) ⧸ KaehlerDifferential.kerTotal R S) where
toFun x := 1𝖣x
map_add' x y := KaehlerDifferential.kerTotal_mkQ_single_add _ _ _ _ _
map_smul' r s := KaehlerDifferential.kerTotal_mkQ_single_smul _ _ _ _ _
map_one_eq_zero' := KaehlerDifferential.kerTotal_mkQ_single_algebraMap_one _ _ _
leibniz' a b :=
(KaehlerDifferential.kerTotal_mkQ_single_mul _ _ _ _ _).trans
(by simp_rw [← Finsupp.smul_single_one _ (1 * _ : S)]; dsimp; simp)
#align kaehler_differential.derivation_quot_ker_total KaehlerDifferential.derivationQuotKerTotal
theorem KaehlerDifferential.derivationQuotKerTotal_apply (x) :
KaehlerDifferential.derivationQuotKerTotal R S x = 1𝖣x :=
rfl
#align kaehler_differential.derivation_quot_ker_total_apply KaehlerDifferential.derivationQuotKerTotal_apply
theorem KaehlerDifferential.derivationQuotKerTotal_lift_comp_total :
(KaehlerDifferential.derivationQuotKerTotal R S).liftKaehlerDifferential.comp
(Finsupp.total S (Ω[S⁄R]) S (KaehlerDifferential.D R S)) =
Submodule.mkQ _ := by
apply Finsupp.lhom_ext
intro a b
conv_rhs => rw [← Finsupp.smul_single_one a b, LinearMap.map_smul]
simp [KaehlerDifferential.derivationQuotKerTotal_apply]
#align kaehler_differential.derivation_quot_ker_total_lift_comp_total KaehlerDifferential.derivationQuotKerTotal_lift_comp_total
theorem KaehlerDifferential.kerTotal_eq :
LinearMap.ker (Finsupp.total S (Ω[S⁄R]) S (KaehlerDifferential.D R S)) =
KaehlerDifferential.kerTotal R S := by
apply le_antisymm
· conv_rhs => rw [← (KaehlerDifferential.kerTotal R S).ker_mkQ]
rw [← KaehlerDifferential.derivationQuotKerTotal_lift_comp_total]
exact LinearMap.ker_le_ker_comp _ _
· rw [KaehlerDifferential.kerTotal, Submodule.span_le]
rintro _ ((⟨⟨x, y⟩, rfl⟩ | ⟨⟨x, y⟩, rfl⟩) | ⟨x, rfl⟩) <;> dsimp <;> simp [LinearMap.mem_ker]
#align kaehler_differential.ker_total_eq KaehlerDifferential.kerTotal_eq
| Mathlib/RingTheory/Kaehler.lean | 565 | 567 | theorem KaehlerDifferential.total_surjective :
Function.Surjective (Finsupp.total S (Ω[S⁄R]) S (KaehlerDifferential.D R S)) := by |
rw [← LinearMap.range_eq_top, Finsupp.range_total, KaehlerDifferential.span_range_derivation]
|
import Mathlib.Topology.Order.ProjIcc
import Mathlib.Topology.ContinuousFunction.Ordered
import Mathlib.Topology.CompactOpen
import Mathlib.Topology.UnitInterval
#align_import topology.homotopy.basic from "leanprover-community/mathlib"@"11c53f174270aa43140c0b26dabce5fc4a253e80"
noncomputable section
universe u v w x
variable {F : Type*} {X : Type u} {Y : Type v} {Z : Type w} {Z' : Type x} {ι : Type*}
variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] [TopologicalSpace Z']
open unitInterval
namespace ContinuousMap
structure Homotopy (f₀ f₁ : C(X, Y)) extends C(I × X, Y) where
map_zero_left : ∀ x, toFun (0, x) = f₀ x
map_one_left : ∀ x, toFun (1, x) = f₁ x
#align continuous_map.homotopy ContinuousMap.Homotopy
section
class HomotopyLike {X Y : outParam Type*} [TopologicalSpace X] [TopologicalSpace Y]
(F : Type*) (f₀ f₁ : outParam <| C(X, Y)) [FunLike F (I × X) Y]
extends ContinuousMapClass F (I × X) Y : Prop where
map_zero_left (f : F) : ∀ x, f (0, x) = f₀ x
map_one_left (f : F) : ∀ x, f (1, x) = f₁ x
#align continuous_map.homotopy_like ContinuousMap.HomotopyLike
end
namespace Homotopy
section
variable {f₀ f₁ : C(X, Y)}
instance instFunLike : FunLike (Homotopy f₀ f₁) (I × X) Y where
coe f := f.toFun
coe_injective' f g h := by
obtain ⟨⟨_, _⟩, _⟩ := f
obtain ⟨⟨_, _⟩, _⟩ := g
congr
instance : HomotopyLike (Homotopy f₀ f₁) f₀ f₁ where
map_continuous f := f.continuous_toFun
map_zero_left f := f.map_zero_left
map_one_left f := f.map_one_left
@[ext]
theorem ext {F G : Homotopy f₀ f₁} (h : ∀ x, F x = G x) : F = G :=
DFunLike.ext _ _ h
#align continuous_map.homotopy.ext ContinuousMap.Homotopy.ext
def Simps.apply (F : Homotopy f₀ f₁) : I × X → Y :=
F
#align continuous_map.homotopy.simps.apply ContinuousMap.Homotopy.Simps.apply
initialize_simps_projections Homotopy (toFun → apply, -toContinuousMap)
protected theorem continuous (F : Homotopy f₀ f₁) : Continuous F :=
F.continuous_toFun
#align continuous_map.homotopy.continuous ContinuousMap.Homotopy.continuous
@[simp]
theorem apply_zero (F : Homotopy f₀ f₁) (x : X) : F (0, x) = f₀ x :=
F.map_zero_left x
#align continuous_map.homotopy.apply_zero ContinuousMap.Homotopy.apply_zero
@[simp]
theorem apply_one (F : Homotopy f₀ f₁) (x : X) : F (1, x) = f₁ x :=
F.map_one_left x
#align continuous_map.homotopy.apply_one ContinuousMap.Homotopy.apply_one
@[simp]
theorem coe_toContinuousMap (F : Homotopy f₀ f₁) : ⇑F.toContinuousMap = F :=
rfl
#align continuous_map.homotopy.coe_to_continuous_map ContinuousMap.Homotopy.coe_toContinuousMap
def curry (F : Homotopy f₀ f₁) : C(I, C(X, Y)) :=
F.toContinuousMap.curry
#align continuous_map.homotopy.curry ContinuousMap.Homotopy.curry
@[simp]
theorem curry_apply (F : Homotopy f₀ f₁) (t : I) (x : X) : F.curry t x = F (t, x) :=
rfl
#align continuous_map.homotopy.curry_apply ContinuousMap.Homotopy.curry_apply
def extend (F : Homotopy f₀ f₁) : C(ℝ, C(X, Y)) :=
F.curry.IccExtend zero_le_one
#align continuous_map.homotopy.extend ContinuousMap.Homotopy.extend
theorem extend_apply_of_le_zero (F : Homotopy f₀ f₁) {t : ℝ} (ht : t ≤ 0) (x : X) :
F.extend t x = f₀ x := by
rw [← F.apply_zero]
exact ContinuousMap.congr_fun (Set.IccExtend_of_le_left (zero_le_one' ℝ) F.curry ht) x
#align continuous_map.homotopy.extend_apply_of_le_zero ContinuousMap.Homotopy.extend_apply_of_le_zero
| Mathlib/Topology/Homotopy/Basic.lean | 172 | 175 | theorem extend_apply_of_one_le (F : Homotopy f₀ f₁) {t : ℝ} (ht : 1 ≤ t) (x : X) :
F.extend t x = f₁ x := by |
rw [← F.apply_one]
exact ContinuousMap.congr_fun (Set.IccExtend_of_right_le (zero_le_one' ℝ) F.curry ht) x
|
import Mathlib.Algebra.BigOperators.NatAntidiagonal
import Mathlib.Topology.Algebra.InfiniteSum.Constructions
import Mathlib.Topology.Algebra.Ring.Basic
#align_import topology.algebra.infinite_sum.ring from "leanprover-community/mathlib"@"9a59dcb7a2d06bf55da57b9030169219980660cd"
open Filter Finset Function
open scoped Classical
variable {ι κ R α : Type*}
section NonUnitalNonAssocSemiring
variable [NonUnitalNonAssocSemiring α] [TopologicalSpace α] [TopologicalSemiring α] {f g : ι → α}
{a a₁ a₂ : α}
theorem HasSum.mul_left (a₂) (h : HasSum f a₁) : HasSum (fun i ↦ a₂ * f i) (a₂ * a₁) := by
simpa only using h.map (AddMonoidHom.mulLeft a₂) (continuous_const.mul continuous_id)
#align has_sum.mul_left HasSum.mul_left
| Mathlib/Topology/Algebra/InfiniteSum/Ring.lean | 38 | 39 | theorem HasSum.mul_right (a₂) (hf : HasSum f a₁) : HasSum (fun i ↦ f i * a₂) (a₁ * a₂) := by |
simpa only using hf.map (AddMonoidHom.mulRight a₂) (continuous_id.mul continuous_const)
|
import Mathlib.Algebra.CharZero.Lemmas
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Data.Real.Basic
import Mathlib.Data.Set.Image
#align_import data.complex.basic from "leanprover-community/mathlib"@"31c24aa72e7b3e5ed97a8412470e904f82b81004"
open Set Function
structure Complex : Type where
re : ℝ
im : ℝ
#align complex Complex
@[inherit_doc] notation "ℂ" => Complex
namespace Complex
open ComplexConjugate
noncomputable instance : DecidableEq ℂ :=
Classical.decEq _
@[simps apply]
def equivRealProd : ℂ ≃ ℝ × ℝ where
toFun z := ⟨z.re, z.im⟩
invFun p := ⟨p.1, p.2⟩
left_inv := fun ⟨_, _⟩ => rfl
right_inv := fun ⟨_, _⟩ => rfl
#align complex.equiv_real_prod Complex.equivRealProd
@[simp]
theorem eta : ∀ z : ℂ, Complex.mk z.re z.im = z
| ⟨_, _⟩ => rfl
#align complex.eta Complex.eta
-- We only mark this lemma with `ext` *locally* to avoid it applying whenever terms of `ℂ` appear.
theorem ext : ∀ {z w : ℂ}, z.re = w.re → z.im = w.im → z = w
| ⟨_, _⟩, ⟨_, _⟩, rfl, rfl => rfl
#align complex.ext Complex.ext
attribute [local ext] Complex.ext
theorem ext_iff {z w : ℂ} : z = w ↔ z.re = w.re ∧ z.im = w.im :=
⟨fun H => by simp [H], fun h => ext h.1 h.2⟩
#align complex.ext_iff Complex.ext_iff
theorem re_surjective : Surjective re := fun x => ⟨⟨x, 0⟩, rfl⟩
#align complex.re_surjective Complex.re_surjective
theorem im_surjective : Surjective im := fun y => ⟨⟨0, y⟩, rfl⟩
#align complex.im_surjective Complex.im_surjective
@[simp]
theorem range_re : range re = univ :=
re_surjective.range_eq
#align complex.range_re Complex.range_re
@[simp]
theorem range_im : range im = univ :=
im_surjective.range_eq
#align complex.range_im Complex.range_im
-- Porting note: refactored instance to allow `norm_cast` to work
@[coe]
def ofReal' (r : ℝ) : ℂ :=
⟨r, 0⟩
instance : Coe ℝ ℂ :=
⟨ofReal'⟩
@[simp, norm_cast]
theorem ofReal_re (r : ℝ) : Complex.re (r : ℂ) = r :=
rfl
#align complex.of_real_re Complex.ofReal_re
@[simp, norm_cast]
theorem ofReal_im (r : ℝ) : (r : ℂ).im = 0 :=
rfl
#align complex.of_real_im Complex.ofReal_im
theorem ofReal_def (r : ℝ) : (r : ℂ) = ⟨r, 0⟩ :=
rfl
#align complex.of_real_def Complex.ofReal_def
@[simp, norm_cast]
theorem ofReal_inj {z w : ℝ} : (z : ℂ) = w ↔ z = w :=
⟨congrArg re, by apply congrArg⟩
#align complex.of_real_inj Complex.ofReal_inj
-- Porting note: made coercion explicit
theorem ofReal_injective : Function.Injective ((↑) : ℝ → ℂ) := fun _ _ => congrArg re
#align complex.of_real_injective Complex.ofReal_injective
-- Porting note: made coercion explicit
instance canLift : CanLift ℂ ℝ (↑) fun z => z.im = 0 where
prf z hz := ⟨z.re, ext rfl hz.symm⟩
#align complex.can_lift Complex.canLift
def Set.reProdIm (s t : Set ℝ) : Set ℂ :=
re ⁻¹' s ∩ im ⁻¹' t
#align set.re_prod_im Complex.Set.reProdIm
@[inherit_doc]
infixl:72 " ×ℂ " => Set.reProdIm
theorem mem_reProdIm {z : ℂ} {s t : Set ℝ} : z ∈ s ×ℂ t ↔ z.re ∈ s ∧ z.im ∈ t :=
Iff.rfl
#align complex.mem_re_prod_im Complex.mem_reProdIm
instance : Zero ℂ :=
⟨(0 : ℝ)⟩
instance : Inhabited ℂ :=
⟨0⟩
@[simp]
theorem zero_re : (0 : ℂ).re = 0 :=
rfl
#align complex.zero_re Complex.zero_re
@[simp]
theorem zero_im : (0 : ℂ).im = 0 :=
rfl
#align complex.zero_im Complex.zero_im
@[simp, norm_cast]
theorem ofReal_zero : ((0 : ℝ) : ℂ) = 0 :=
rfl
#align complex.of_real_zero Complex.ofReal_zero
@[simp]
theorem ofReal_eq_zero {z : ℝ} : (z : ℂ) = 0 ↔ z = 0 :=
ofReal_inj
#align complex.of_real_eq_zero Complex.ofReal_eq_zero
theorem ofReal_ne_zero {z : ℝ} : (z : ℂ) ≠ 0 ↔ z ≠ 0 :=
not_congr ofReal_eq_zero
#align complex.of_real_ne_zero Complex.ofReal_ne_zero
instance : One ℂ :=
⟨(1 : ℝ)⟩
@[simp]
theorem one_re : (1 : ℂ).re = 1 :=
rfl
#align complex.one_re Complex.one_re
@[simp]
theorem one_im : (1 : ℂ).im = 0 :=
rfl
#align complex.one_im Complex.one_im
@[simp, norm_cast]
theorem ofReal_one : ((1 : ℝ) : ℂ) = 1 :=
rfl
#align complex.of_real_one Complex.ofReal_one
@[simp]
theorem ofReal_eq_one {z : ℝ} : (z : ℂ) = 1 ↔ z = 1 :=
ofReal_inj
#align complex.of_real_eq_one Complex.ofReal_eq_one
theorem ofReal_ne_one {z : ℝ} : (z : ℂ) ≠ 1 ↔ z ≠ 1 :=
not_congr ofReal_eq_one
#align complex.of_real_ne_one Complex.ofReal_ne_one
instance : Add ℂ :=
⟨fun z w => ⟨z.re + w.re, z.im + w.im⟩⟩
@[simp]
theorem add_re (z w : ℂ) : (z + w).re = z.re + w.re :=
rfl
#align complex.add_re Complex.add_re
@[simp]
theorem add_im (z w : ℂ) : (z + w).im = z.im + w.im :=
rfl
#align complex.add_im Complex.add_im
-- replaced by `re_ofNat`
#noalign complex.bit0_re
#noalign complex.bit1_re
-- replaced by `im_ofNat`
#noalign complex.bit0_im
#noalign complex.bit1_im
@[simp, norm_cast]
theorem ofReal_add (r s : ℝ) : ((r + s : ℝ) : ℂ) = r + s :=
ext_iff.2 <| by simp [ofReal']
#align complex.of_real_add Complex.ofReal_add
-- replaced by `Complex.ofReal_ofNat`
#noalign complex.of_real_bit0
#noalign complex.of_real_bit1
instance : Neg ℂ :=
⟨fun z => ⟨-z.re, -z.im⟩⟩
@[simp]
theorem neg_re (z : ℂ) : (-z).re = -z.re :=
rfl
#align complex.neg_re Complex.neg_re
@[simp]
theorem neg_im (z : ℂ) : (-z).im = -z.im :=
rfl
#align complex.neg_im Complex.neg_im
@[simp, norm_cast]
theorem ofReal_neg (r : ℝ) : ((-r : ℝ) : ℂ) = -r :=
ext_iff.2 <| by simp [ofReal']
#align complex.of_real_neg Complex.ofReal_neg
instance : Sub ℂ :=
⟨fun z w => ⟨z.re - w.re, z.im - w.im⟩⟩
instance : Mul ℂ :=
⟨fun z w => ⟨z.re * w.re - z.im * w.im, z.re * w.im + z.im * w.re⟩⟩
@[simp]
theorem mul_re (z w : ℂ) : (z * w).re = z.re * w.re - z.im * w.im :=
rfl
#align complex.mul_re Complex.mul_re
@[simp]
theorem mul_im (z w : ℂ) : (z * w).im = z.re * w.im + z.im * w.re :=
rfl
#align complex.mul_im Complex.mul_im
@[simp, norm_cast]
theorem ofReal_mul (r s : ℝ) : ((r * s : ℝ) : ℂ) = r * s :=
ext_iff.2 <| by simp [ofReal']
#align complex.of_real_mul Complex.ofReal_mul
theorem re_ofReal_mul (r : ℝ) (z : ℂ) : (r * z).re = r * z.re := by simp [ofReal']
#align complex.of_real_mul_re Complex.re_ofReal_mul
| Mathlib/Data/Complex/Basic.lean | 262 | 262 | theorem im_ofReal_mul (r : ℝ) (z : ℂ) : (r * z).im = r * z.im := by | simp [ofReal']
|
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
import Mathlib.Analysis.SpecialFunctions.Pow.Complex
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine exists_congr fun x => ?_
refine (iff_of_eq <| congr_arg _ ?_).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
use k - 1
field_simp
ring
#align complex.sin_eq_zero_iff Complex.sin_eq_zero_iff
theorem sin_ne_zero_iff {θ : ℂ} : sin θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π := by
rw [← not_exists, not_iff_not, sin_eq_zero_iff]
#align complex.sin_ne_zero_iff Complex.sin_ne_zero_iff
theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, k * π / 2 = θ := by
rw [tan, div_eq_zero_iff, ← mul_eq_zero, ← mul_right_inj' two_ne_zero, mul_zero,
← mul_assoc, ← sin_two_mul, sin_eq_zero_iff]
field_simp [mul_comm, eq_comm]
#align complex.tan_eq_zero_iff Complex.tan_eq_zero_iff
theorem tan_ne_zero_iff {θ : ℂ} : tan θ ≠ 0 ↔ ∀ k : ℤ, (k * π / 2 : ℂ) ≠ θ := by
rw [← not_exists, not_iff_not, tan_eq_zero_iff]
#align complex.tan_ne_zero_iff Complex.tan_ne_zero_iff
theorem tan_int_mul_pi_div_two (n : ℤ) : tan (n * π / 2) = 0 :=
tan_eq_zero_iff.mpr (by use n)
#align complex.tan_int_mul_pi_div_two Complex.tan_int_mul_pi_div_two
theorem tan_eq_zero_iff' {θ : ℂ} (hθ : cos θ ≠ 0) : tan θ = 0 ↔ ∃ k : ℤ, k * π = θ := by
simp only [tan, hθ, div_eq_zero_iff, sin_eq_zero_iff]; simp [eq_comm]
theorem cos_eq_cos_iff {x y : ℂ} : cos x = cos y ↔ ∃ k : ℤ, y = 2 * k * π + x ∨ y = 2 * k * π - x :=
calc
cos x = cos y ↔ cos x - cos y = 0 := sub_eq_zero.symm
_ ↔ -2 * sin ((x + y) / 2) * sin ((x - y) / 2) = 0 := by rw [cos_sub_cos]
_ ↔ sin ((x + y) / 2) = 0 ∨ sin ((x - y) / 2) = 0 := by simp [(by norm_num : (2 : ℂ) ≠ 0)]
_ ↔ sin ((x - y) / 2) = 0 ∨ sin ((x + y) / 2) = 0 := or_comm
_ ↔ (∃ k : ℤ, y = 2 * k * π + x) ∨ ∃ k : ℤ, y = 2 * k * π - x := by
apply or_congr <;>
field_simp [sin_eq_zero_iff, (by norm_num : -(2 : ℂ) ≠ 0), eq_sub_iff_add_eq',
sub_eq_iff_eq_add, mul_comm (2 : ℂ), mul_right_comm _ (2 : ℂ)]
constructor <;> · rintro ⟨k, rfl⟩; use -k; simp
_ ↔ ∃ k : ℤ, y = 2 * k * π + x ∨ y = 2 * k * π - x := exists_or.symm
#align complex.cos_eq_cos_iff Complex.cos_eq_cos_iff
theorem sin_eq_sin_iff {x y : ℂ} :
sin x = sin y ↔ ∃ k : ℤ, y = 2 * k * π + x ∨ y = (2 * k + 1) * π - x := by
simp only [← Complex.cos_sub_pi_div_two, cos_eq_cos_iff, sub_eq_iff_eq_add]
refine exists_congr fun k => or_congr ?_ ?_ <;> refine Eq.congr rfl ?_ <;> field_simp <;> ring
#align complex.sin_eq_sin_iff Complex.sin_eq_sin_iff
theorem cos_eq_one_iff {x : ℂ} : cos x = 1 ↔ ∃ k : ℤ, k * (2 * π) = x := by
rw [← cos_zero, eq_comm, cos_eq_cos_iff]
simp [mul_assoc, mul_left_comm, eq_comm]
| Mathlib/Analysis/SpecialFunctions/Trigonometric/Complex.lean | 114 | 116 | theorem cos_eq_neg_one_iff {x : ℂ} : cos x = -1 ↔ ∃ k : ℤ, π + k * (2 * π) = x := by |
rw [← neg_eq_iff_eq_neg, ← cos_sub_pi, cos_eq_one_iff]
simp only [eq_sub_iff_add_eq']
|
import Mathlib.Analysis.InnerProductSpace.Basic
import Mathlib.Analysis.NormedSpace.Banach
import Mathlib.LinearAlgebra.SesquilinearForm
#align_import analysis.inner_product_space.symmetric from "leanprover-community/mathlib"@"3f655f5297b030a87d641ad4e825af8d9679eb0b"
open RCLike
open ComplexConjugate
variable {𝕜 E E' F G : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]
variable [NormedAddCommGroup G] [InnerProductSpace 𝕜 G]
variable [NormedAddCommGroup E'] [InnerProductSpace ℝ E']
local notation "⟪" x ", " y "⟫" => @inner 𝕜 _ _ x y
namespace LinearMap
def IsSymmetric (T : E →ₗ[𝕜] E) : Prop :=
∀ x y, ⟪T x, y⟫ = ⟪x, T y⟫
#align linear_map.is_symmetric LinearMap.IsSymmetric
theorem IsSymmetric.conj_inner_sym {T : E →ₗ[𝕜] E} (hT : IsSymmetric T) (x y : E) :
conj ⟪T x, y⟫ = ⟪T y, x⟫ := by rw [hT x y, inner_conj_symm]
#align linear_map.is_symmetric.conj_inner_sym LinearMap.IsSymmetric.conj_inner_sym
@[simp]
theorem IsSymmetric.apply_clm {T : E →L[𝕜] E} (hT : IsSymmetric (T : E →ₗ[𝕜] E)) (x y : E) :
⟪T x, y⟫ = ⟪x, T y⟫ :=
hT x y
#align linear_map.is_symmetric.apply_clm LinearMap.IsSymmetric.apply_clm
theorem isSymmetric_zero : (0 : E →ₗ[𝕜] E).IsSymmetric := fun x y =>
(inner_zero_right x : ⟪x, 0⟫ = 0).symm ▸ (inner_zero_left y : ⟪0, y⟫ = 0)
#align linear_map.is_symmetric_zero LinearMap.isSymmetric_zero
theorem isSymmetric_id : (LinearMap.id : E →ₗ[𝕜] E).IsSymmetric := fun _ _ => rfl
#align linear_map.is_symmetric_id LinearMap.isSymmetric_id
theorem IsSymmetric.add {T S : E →ₗ[𝕜] E} (hT : T.IsSymmetric) (hS : S.IsSymmetric) :
(T + S).IsSymmetric := by
intro x y
rw [LinearMap.add_apply, inner_add_left, hT x y, hS x y, ← inner_add_right]
rfl
#align linear_map.is_symmetric.add LinearMap.IsSymmetric.add
| Mathlib/Analysis/InnerProductSpace/Symmetric.lean | 97 | 110 | theorem IsSymmetric.continuous [CompleteSpace E] {T : E →ₗ[𝕜] E} (hT : IsSymmetric T) :
Continuous T := by |
-- We prove it by using the closed graph theorem
refine T.continuous_of_seq_closed_graph fun u x y hu hTu => ?_
rw [← sub_eq_zero, ← @inner_self_eq_zero 𝕜]
have hlhs : ∀ k : ℕ, ⟪T (u k) - T x, y - T x⟫ = ⟪u k - x, T (y - T x)⟫ := by
intro k
rw [← T.map_sub, hT]
refine tendsto_nhds_unique ((hTu.sub_const _).inner tendsto_const_nhds) ?_
simp_rw [Function.comp_apply, hlhs]
rw [← inner_zero_left (T (y - T x))]
refine Filter.Tendsto.inner ?_ tendsto_const_nhds
rw [← sub_self x]
exact hu.sub_const _
|
import Mathlib.Data.Matrix.Basic
import Mathlib.Data.PEquiv
#align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1"
namespace PEquiv
open Matrix
universe u v
variable {k l m n : Type*}
variable {α : Type v}
open Matrix
def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α :=
of fun i j => if j ∈ f i then (1 : α) else 0
#align pequiv.to_matrix PEquiv.toMatrix
-- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024
@[simp]
theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) :
toMatrix f i j = if j ∈ f i then (1 : α) else 0 :=
rfl
#align pequiv.to_matrix_apply PEquiv.toMatrix_apply
theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α)
(i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by
dsimp [toMatrix, Matrix.mul_apply]
cases' h : f i with fi
· simp [h]
· rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm]
#align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply
theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) :
(f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by
ext
simp only [transpose, mem_iff_mem f, toMatrix_apply]
congr
#align pequiv.to_matrix_symm PEquiv.toMatrix_symm
@[simp]
theorem toMatrix_refl [DecidableEq n] [Zero α] [One α] :
((PEquiv.refl n).toMatrix : Matrix n n α) = 1 := by
ext
simp [toMatrix_apply, one_apply]
#align pequiv.to_matrix_refl PEquiv.toMatrix_refl
theorem matrix_mul_apply [Fintype m] [Semiring α] [DecidableEq n] (M : Matrix l m α) (f : m ≃. n)
(i j) : (M * f.toMatrix :) i j = Option.casesOn (f.symm j) 0 fun fj => M i fj := by
dsimp [toMatrix, Matrix.mul_apply]
cases' h : f.symm j with fj
· simp [h, ← f.eq_some_iff]
· rw [Finset.sum_eq_single fj]
· simp [h, ← f.eq_some_iff]
· rintro b - n
simp [h, ← f.eq_some_iff, n.symm]
· simp
#align pequiv.matrix_mul_apply PEquiv.matrix_mul_apply
theorem toPEquiv_mul_matrix [Fintype m] [DecidableEq m] [Semiring α] (f : m ≃ m)
(M : Matrix m n α) : f.toPEquiv.toMatrix * M = M.submatrix f id := by
ext i j
rw [mul_matrix_apply, Equiv.toPEquiv_apply, submatrix_apply, id]
#align pequiv.to_pequiv_mul_matrix PEquiv.toPEquiv_mul_matrix
theorem mul_toPEquiv_toMatrix {m n α : Type*} [Fintype n] [DecidableEq n] [Semiring α] (f : n ≃ n)
(M : Matrix m n α) : M * f.toPEquiv.toMatrix = M.submatrix id f.symm :=
Matrix.ext fun i j => by
rw [PEquiv.matrix_mul_apply, ← Equiv.toPEquiv_symm, Equiv.toPEquiv_apply,
Matrix.submatrix_apply, id]
#align pequiv.mul_to_pequiv_to_matrix PEquiv.mul_toPEquiv_toMatrix
theorem toMatrix_trans [Fintype m] [DecidableEq m] [DecidableEq n] [Semiring α] (f : l ≃. m)
(g : m ≃. n) : ((f.trans g).toMatrix : Matrix l n α) = f.toMatrix * g.toMatrix := by
ext i j
rw [mul_matrix_apply]
dsimp [toMatrix, PEquiv.trans]
cases f i <;> simp
#align pequiv.to_matrix_trans PEquiv.toMatrix_trans
@[simp]
theorem toMatrix_bot [DecidableEq n] [Zero α] [One α] :
((⊥ : PEquiv m n).toMatrix : Matrix m n α) = 0 :=
rfl
#align pequiv.to_matrix_bot PEquiv.toMatrix_bot
| Mathlib/Data/Matrix/PEquiv.lean | 123 | 139 | theorem toMatrix_injective [DecidableEq n] [MonoidWithZero α] [Nontrivial α] :
Function.Injective (@toMatrix m n α _ _ _) := by |
classical
intro f g
refine not_imp_not.1 ?_
simp only [Matrix.ext_iff.symm, toMatrix_apply, PEquiv.ext_iff, not_forall, exists_imp]
intro i hi
use i
cases' hf : f i with fi
· cases' hg : g i with gi
-- Porting note: was `cc`
· rw [hf, hg] at hi
exact (hi rfl).elim
· use gi
simp
· use fi
simp [hf.symm, Ne.symm hi]
|
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}
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ω _))
#align measure_theory.norm_stopped_value_least_ge_le MeasureTheory.norm_stoppedValue_leastGE_le
theorem Submartingale.stoppedValue_leastGE_snorm_le [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ)
(hr : 0 ≤ r) (hf0 : f 0 = 0) (hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) (i : ℕ) :
snorm (stoppedValue f (leastGE f r i)) 1 μ ≤ 2 * μ Set.univ * ENNReal.ofReal (r + R) := by
refine snorm_one_le_of_le' ((hf.stoppedValue_leastGE r).integrable _) ?_
(norm_stoppedValue_leastGE_le hr hf0 hbdd i)
rw [← integral_univ]
refine le_trans ?_ ((hf.stoppedValue_leastGE r).setIntegral_le (zero_le _) MeasurableSet.univ)
simp_rw [stoppedValue, leastGE, hitting_of_le le_rfl, hf0, integral_zero', le_rfl]
#align measure_theory.submartingale.stopped_value_least_ge_snorm_le MeasureTheory.Submartingale.stoppedValue_leastGE_snorm_le
theorem Submartingale.stoppedValue_leastGE_snorm_le' [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ)
(hr : 0 ≤ r) (hf0 : f 0 = 0) (hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) (i : ℕ) :
snorm (stoppedValue f (leastGE f r i)) 1 μ ≤
ENNReal.toNNReal (2 * μ Set.univ * ENNReal.ofReal (r + R)) := by
refine (hf.stoppedValue_leastGE_snorm_le hr hf0 hbdd i).trans ?_
simp [ENNReal.coe_toNNReal (measure_ne_top μ _), ENNReal.coe_toNNReal]
#align measure_theory.submartingale.stopped_value_least_ge_snorm_le' MeasureTheory.Submartingale.stoppedValue_leastGE_snorm_le'
theorem Submartingale.exists_tendsto_of_abs_bddAbove_aux [IsFiniteMeasure μ]
(hf : Submartingale f ℱ μ) (hf0 : f 0 = 0) (hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) :
∀ᵐ ω ∂μ, BddAbove (Set.range fun n => f n ω) → ∃ c, Tendsto (fun n => f n ω) atTop (𝓝 c) := by
have ht :
∀ᵐ ω ∂μ, ∀ i : ℕ, ∃ c, Tendsto (fun n => stoppedValue f (leastGE f i n) ω) atTop (𝓝 c) := by
rw [ae_all_iff]
exact fun i => Submartingale.exists_ae_tendsto_of_bdd (hf.stoppedValue_leastGE i)
(hf.stoppedValue_leastGE_snorm_le' i.cast_nonneg hf0 hbdd)
filter_upwards [ht] with ω hω hωb
rw [BddAbove] at hωb
obtain ⟨i, hi⟩ := exists_nat_gt hωb.some
have hib : ∀ n, f n ω < i := by
intro n
exact lt_of_le_of_lt ((mem_upperBounds.1 hωb.some_mem) _ ⟨n, rfl⟩) hi
have heq : ∀ n, stoppedValue f (leastGE f i n) ω = f n ω := by
intro n
rw [leastGE]; unfold hitting; rw [stoppedValue]
rw [if_neg]
simp only [Set.mem_Icc, Set.mem_union, Set.mem_Ici]
push_neg
exact fun j _ => hib j
simp only [← heq, hω i]
#align measure_theory.submartingale.exists_tendsto_of_abs_bdd_above_aux MeasureTheory.Submartingale.exists_tendsto_of_abs_bddAbove_aux
theorem Submartingale.bddAbove_iff_exists_tendsto_aux [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ)
(hf0 : f 0 = 0) (hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) :
∀ᵐ ω ∂μ, BddAbove (Set.range fun n => f n ω) ↔ ∃ c, Tendsto (fun n => f n ω) atTop (𝓝 c) := by
filter_upwards [hf.exists_tendsto_of_abs_bddAbove_aux hf0 hbdd] with ω hω using
⟨hω, fun ⟨c, hc⟩ => hc.bddAbove_range⟩
#align measure_theory.submartingale.bdd_above_iff_exists_tendsto_aux MeasureTheory.Submartingale.bddAbove_iff_exists_tendsto_aux
theorem Submartingale.bddAbove_iff_exists_tendsto [IsFiniteMeasure μ] (hf : Submartingale f ℱ μ)
(hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) :
∀ᵐ ω ∂μ, BddAbove (Set.range fun n => f n ω) ↔ ∃ c, Tendsto (fun n => f n ω) atTop (𝓝 c) := by
set g : ℕ → Ω → ℝ := fun n ω => f n ω - f 0 ω
have hg : Submartingale g ℱ μ :=
hf.sub_martingale (martingale_const_fun _ _ (hf.adapted 0) (hf.integrable 0))
have hg0 : g 0 = 0 := by
ext ω
simp only [g, sub_self, Pi.zero_apply]
have hgbdd : ∀ᵐ ω ∂μ, ∀ i : ℕ, |g (i + 1) ω - g i ω| ≤ ↑R := by
simpa only [g, sub_sub_sub_cancel_right]
filter_upwards [hg.bddAbove_iff_exists_tendsto_aux hg0 hgbdd] with ω hω
convert hω using 1
· refine ⟨fun h => ?_, fun h => ?_⟩ <;> obtain ⟨b, hb⟩ := h <;>
refine ⟨b + |f 0 ω|, fun y hy => ?_⟩ <;> obtain ⟨n, rfl⟩ := hy
· simp_rw [g, sub_eq_add_neg]
exact add_le_add (hb ⟨n, rfl⟩) (neg_le_abs _)
· exact sub_le_iff_le_add.1 (le_trans (sub_le_sub_left (le_abs_self _) _) (hb ⟨n, rfl⟩))
· refine ⟨fun h => ?_, fun h => ?_⟩ <;> obtain ⟨c, hc⟩ := h
· exact ⟨c - f 0 ω, hc.sub_const _⟩
· refine ⟨c + f 0 ω, ?_⟩
have := hc.add_const (f 0 ω)
simpa only [g, sub_add_cancel]
#align measure_theory.submartingale.bdd_above_iff_exists_tendsto MeasureTheory.Submartingale.bddAbove_iff_exists_tendsto
theorem Martingale.bddAbove_range_iff_bddBelow_range [IsFiniteMeasure μ] (hf : Martingale f ℱ μ)
(hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) :
∀ᵐ ω ∂μ, BddAbove (Set.range fun n => f n ω) ↔ BddBelow (Set.range fun n => f n ω) := by
have hbdd' : ∀ᵐ ω ∂μ, ∀ i, |(-f) (i + 1) ω - (-f) i ω| ≤ R := by
filter_upwards [hbdd] with ω hω i
erw [← abs_neg, neg_sub, sub_neg_eq_add, neg_add_eq_sub]
exact hω i
have hup := hf.submartingale.bddAbove_iff_exists_tendsto hbdd
have hdown := hf.neg.submartingale.bddAbove_iff_exists_tendsto hbdd'
filter_upwards [hup, hdown] with ω hω₁ hω₂
have : (∃ c, Tendsto (fun n => f n ω) atTop (𝓝 c)) ↔
∃ c, Tendsto (fun n => (-f) n ω) atTop (𝓝 c) := by
constructor <;> rintro ⟨c, hc⟩
· exact ⟨-c, hc.neg⟩
· refine ⟨-c, ?_⟩
convert hc.neg
simp only [neg_neg, Pi.neg_apply]
rw [hω₁, this, ← hω₂]
constructor <;> rintro ⟨c, hc⟩ <;> refine ⟨-c, fun ω hω => ?_⟩
· rw [mem_upperBounds] at hc
refine neg_le.2 (hc _ ?_)
simpa only [Pi.neg_apply, Set.mem_range, neg_inj]
· rw [mem_lowerBounds] at hc
simp_rw [Set.mem_range, Pi.neg_apply, neg_eq_iff_eq_neg] at hω
refine le_neg.1 (hc _ ?_)
simpa only [Set.mem_range]
#align measure_theory.martingale.bdd_above_range_iff_bdd_below_range MeasureTheory.Martingale.bddAbove_range_iff_bddBelow_range
theorem Martingale.ae_not_tendsto_atTop_atTop [IsFiniteMeasure μ] (hf : Martingale f ℱ μ)
(hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) :
∀ᵐ ω ∂μ, ¬Tendsto (fun n => f n ω) atTop atTop := by
filter_upwards [hf.bddAbove_range_iff_bddBelow_range hbdd] with ω hω htop using
unbounded_of_tendsto_atTop htop (hω.2 <| bddBelow_range_of_tendsto_atTop_atTop htop)
#align measure_theory.martingale.ae_not_tendsto_at_top_at_top MeasureTheory.Martingale.ae_not_tendsto_atTop_atTop
theorem Martingale.ae_not_tendsto_atTop_atBot [IsFiniteMeasure μ] (hf : Martingale f ℱ μ)
(hbdd : ∀ᵐ ω ∂μ, ∀ i, |f (i + 1) ω - f i ω| ≤ R) :
∀ᵐ ω ∂μ, ¬Tendsto (fun n => f n ω) atTop atBot := by
filter_upwards [hf.bddAbove_range_iff_bddBelow_range hbdd] with ω hω htop using
unbounded_of_tendsto_atBot htop (hω.1 <| bddAbove_range_of_tendsto_atTop_atBot htop)
#align measure_theory.martingale.ae_not_tendsto_at_top_at_bot MeasureTheory.Martingale.ae_not_tendsto_atTop_atBot
namespace BorelCantelli
noncomputable def process (s : ℕ → Set Ω) (n : ℕ) : Ω → ℝ :=
∑ k ∈ Finset.range n, (s (k + 1)).indicator 1
#align measure_theory.borel_cantelli.process MeasureTheory.BorelCantelli.process
variable {s : ℕ → Set Ω}
| Mathlib/Probability/Martingale/BorelCantelli.lean | 287 | 287 | theorem process_zero : process s 0 = 0 := by | rw [process, Finset.range_zero, Finset.sum_empty]
|
import Mathlib.Algebra.Lie.Subalgebra
import Mathlib.RingTheory.Noetherian
import Mathlib.RingTheory.Artinian
#align_import algebra.lie.submodule from "leanprover-community/mathlib"@"9822b65bfc4ac74537d77ae318d27df1df662471"
universe u v w w₁ w₂
section LieSubmodule
variable (R : Type u) (L : Type v) (M : Type w)
variable [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M]
variable [LieRingModule L M] [LieModule R L M]
structure LieSubmodule extends Submodule R M where
lie_mem : ∀ {x : L} {m : M}, m ∈ carrier → ⁅x, m⁆ ∈ carrier
#align lie_submodule LieSubmodule
attribute [nolint docBlame] LieSubmodule.toSubmodule
attribute [coe] LieSubmodule.toSubmodule
namespace LieSubmodule
variable {R L M}
variable (N N' : LieSubmodule R L M)
instance : SetLike (LieSubmodule R L M) M where
coe s := s.carrier
coe_injective' N O h := by cases N; cases O; congr; exact SetLike.coe_injective' h
instance : AddSubgroupClass (LieSubmodule R L M) M where
add_mem {N} _ _ := N.add_mem'
zero_mem N := N.zero_mem'
neg_mem {N} x hx := show -x ∈ N.toSubmodule from neg_mem hx
instance instSMulMemClass : SMulMemClass (LieSubmodule R L M) R M where
smul_mem {s} c _ h := s.smul_mem' c h
instance : Zero (LieSubmodule R L M) :=
⟨{ (0 : Submodule R M) with
lie_mem := fun {x m} h ↦ by rw [(Submodule.mem_bot R).1 h]; apply lie_zero }⟩
instance : Inhabited (LieSubmodule R L M) :=
⟨0⟩
instance coeSubmodule : CoeOut (LieSubmodule R L M) (Submodule R M) :=
⟨toSubmodule⟩
#align lie_submodule.coe_submodule LieSubmodule.coeSubmodule
-- Syntactic tautology
#noalign lie_submodule.to_submodule_eq_coe
@[norm_cast]
theorem coe_toSubmodule : ((N : Submodule R M) : Set M) = N :=
rfl
#align lie_submodule.coe_to_submodule LieSubmodule.coe_toSubmodule
-- Porting note (#10618): `simp` can prove this after `mem_coeSubmodule` is added to the simp set,
-- but `dsimp` can't.
@[simp, nolint simpNF]
theorem mem_carrier {x : M} : x ∈ N.carrier ↔ x ∈ (N : Set M) :=
Iff.rfl
#align lie_submodule.mem_carrier LieSubmodule.mem_carrier
theorem mem_mk_iff (S : Set M) (h₁ h₂ h₃ h₄) {x : M} :
x ∈ (⟨⟨⟨⟨S, h₁⟩, h₂⟩, h₃⟩, h₄⟩ : LieSubmodule R L M) ↔ x ∈ S :=
Iff.rfl
#align lie_submodule.mem_mk_iff LieSubmodule.mem_mk_iff
@[simp]
theorem mem_mk_iff' (p : Submodule R M) (h) {x : M} :
x ∈ (⟨p, h⟩ : LieSubmodule R L M) ↔ x ∈ p :=
Iff.rfl
@[simp]
theorem mem_coeSubmodule {x : M} : x ∈ (N : Submodule R M) ↔ x ∈ N :=
Iff.rfl
#align lie_submodule.mem_coe_submodule LieSubmodule.mem_coeSubmodule
theorem mem_coe {x : M} : x ∈ (N : Set M) ↔ x ∈ N :=
Iff.rfl
#align lie_submodule.mem_coe LieSubmodule.mem_coe
@[simp]
protected theorem zero_mem : (0 : M) ∈ N :=
zero_mem N
#align lie_submodule.zero_mem LieSubmodule.zero_mem
-- Porting note (#10618): @[simp] can prove this
theorem mk_eq_zero {x} (h : x ∈ N) : (⟨x, h⟩ : N) = 0 ↔ x = 0 :=
Subtype.ext_iff_val
#align lie_submodule.mk_eq_zero LieSubmodule.mk_eq_zero
@[simp]
theorem coe_toSet_mk (S : Set M) (h₁ h₂ h₃ h₄) :
((⟨⟨⟨⟨S, h₁⟩, h₂⟩, h₃⟩, h₄⟩ : LieSubmodule R L M) : Set M) = S :=
rfl
#align lie_submodule.coe_to_set_mk LieSubmodule.coe_toSet_mk
| Mathlib/Algebra/Lie/Submodule.lean | 132 | 133 | theorem coe_toSubmodule_mk (p : Submodule R M) (h) :
(({ p with lie_mem := h } : LieSubmodule R L M) : Submodule R M) = p := by | cases p; rfl
|
import Mathlib.Topology.Algebra.Constructions
import Mathlib.Topology.Bases
import Mathlib.Topology.UniformSpace.Basic
#align_import topology.uniform_space.cauchy from "leanprover-community/mathlib"@"22131150f88a2d125713ffa0f4693e3355b1eb49"
universe u v
open scoped Classical
open Filter TopologicalSpace Set UniformSpace Function
open scoped Classical
open Uniformity Topology Filter
variable {α : Type u} {β : Type v} [uniformSpace : UniformSpace α]
def Cauchy (f : Filter α) :=
NeBot f ∧ f ×ˢ f ≤ 𝓤 α
#align cauchy Cauchy
def IsComplete (s : Set α) :=
∀ f, Cauchy f → f ≤ 𝓟 s → ∃ x ∈ s, f ≤ 𝓝 x
#align is_complete IsComplete
theorem Filter.HasBasis.cauchy_iff {ι} {p : ι → Prop} {s : ι → Set (α × α)} (h : (𝓤 α).HasBasis p s)
{f : Filter α} :
Cauchy f ↔ NeBot f ∧ ∀ i, p i → ∃ t ∈ f, ∀ x ∈ t, ∀ y ∈ t, (x, y) ∈ s i :=
and_congr Iff.rfl <|
(f.basis_sets.prod_self.le_basis_iff h).trans <| by
simp only [subset_def, Prod.forall, mem_prod_eq, and_imp, id, forall_mem_comm]
#align filter.has_basis.cauchy_iff Filter.HasBasis.cauchy_iff
theorem cauchy_iff' {f : Filter α} :
Cauchy f ↔ NeBot f ∧ ∀ s ∈ 𝓤 α, ∃ t ∈ f, ∀ x ∈ t, ∀ y ∈ t, (x, y) ∈ s :=
(𝓤 α).basis_sets.cauchy_iff
#align cauchy_iff' cauchy_iff'
theorem cauchy_iff {f : Filter α} : Cauchy f ↔ NeBot f ∧ ∀ s ∈ 𝓤 α, ∃ t ∈ f, t ×ˢ t ⊆ s :=
cauchy_iff'.trans <| by
simp only [subset_def, Prod.forall, mem_prod_eq, and_imp, id, forall_mem_comm]
#align cauchy_iff cauchy_iff
lemma cauchy_iff_le {l : Filter α} [hl : l.NeBot] :
Cauchy l ↔ l ×ˢ l ≤ 𝓤 α := by
simp only [Cauchy, hl, true_and]
theorem Cauchy.ultrafilter_of {l : Filter α} (h : Cauchy l) :
Cauchy (@Ultrafilter.of _ l h.1 : Filter α) := by
haveI := h.1
have := Ultrafilter.of_le l
exact ⟨Ultrafilter.neBot _, (Filter.prod_mono this this).trans h.2⟩
#align cauchy.ultrafilter_of Cauchy.ultrafilter_of
theorem cauchy_map_iff {l : Filter β} {f : β → α} :
Cauchy (l.map f) ↔ NeBot l ∧ Tendsto (fun p : β × β => (f p.1, f p.2)) (l ×ˢ l) (𝓤 α) := by
rw [Cauchy, map_neBot_iff, prod_map_map_eq, Tendsto]
#align cauchy_map_iff cauchy_map_iff
theorem cauchy_map_iff' {l : Filter β} [hl : NeBot l] {f : β → α} :
Cauchy (l.map f) ↔ Tendsto (fun p : β × β => (f p.1, f p.2)) (l ×ˢ l) (𝓤 α) :=
cauchy_map_iff.trans <| and_iff_right hl
#align cauchy_map_iff' cauchy_map_iff'
theorem Cauchy.mono {f g : Filter α} [hg : NeBot g] (h_c : Cauchy f) (h_le : g ≤ f) : Cauchy g :=
⟨hg, le_trans (Filter.prod_mono h_le h_le) h_c.right⟩
#align cauchy.mono Cauchy.mono
theorem Cauchy.mono' {f g : Filter α} (h_c : Cauchy f) (_ : NeBot g) (h_le : g ≤ f) : Cauchy g :=
h_c.mono h_le
#align cauchy.mono' Cauchy.mono'
theorem cauchy_nhds {a : α} : Cauchy (𝓝 a) :=
⟨nhds_neBot, nhds_prod_eq.symm.trans_le (nhds_le_uniformity a)⟩
#align cauchy_nhds cauchy_nhds
theorem cauchy_pure {a : α} : Cauchy (pure a) :=
cauchy_nhds.mono (pure_le_nhds a)
#align cauchy_pure cauchy_pure
theorem Filter.Tendsto.cauchy_map {l : Filter β} [NeBot l] {f : β → α} {a : α}
(h : Tendsto f l (𝓝 a)) : Cauchy (map f l) :=
cauchy_nhds.mono h
#align filter.tendsto.cauchy_map Filter.Tendsto.cauchy_map
lemma Cauchy.mono_uniformSpace {u v : UniformSpace β} {F : Filter β} (huv : u ≤ v)
(hF : Cauchy (uniformSpace := u) F) : Cauchy (uniformSpace := v) F :=
⟨hF.1, hF.2.trans huv⟩
lemma cauchy_inf_uniformSpace {u v : UniformSpace β} {F : Filter β} :
Cauchy (uniformSpace := u ⊓ v) F ↔
Cauchy (uniformSpace := u) F ∧ Cauchy (uniformSpace := v) F := by
unfold Cauchy
rw [inf_uniformity (u := u), le_inf_iff, and_and_left]
lemma cauchy_iInf_uniformSpace {ι : Sort*} [Nonempty ι] {u : ι → UniformSpace β}
{l : Filter β} :
Cauchy (uniformSpace := ⨅ i, u i) l ↔ ∀ i, Cauchy (uniformSpace := u i) l := by
unfold Cauchy
rw [iInf_uniformity, le_iInf_iff, forall_and, forall_const]
lemma cauchy_iInf_uniformSpace' {ι : Sort*} {u : ι → UniformSpace β}
{l : Filter β} [l.NeBot] :
Cauchy (uniformSpace := ⨅ i, u i) l ↔ ∀ i, Cauchy (uniformSpace := u i) l := by
simp_rw [cauchy_iff_le (uniformSpace := _), iInf_uniformity, le_iInf_iff]
lemma cauchy_comap_uniformSpace {u : UniformSpace β} {f : α → β} {l : Filter α} :
Cauchy (uniformSpace := comap f u) l ↔ Cauchy (map f l) := by
simp only [Cauchy, map_neBot_iff, prod_map_map_eq, map_le_iff_le_comap]
rfl
lemma cauchy_prod_iff [UniformSpace β] {F : Filter (α × β)} :
Cauchy F ↔ Cauchy (map Prod.fst F) ∧ Cauchy (map Prod.snd F) := by
simp_rw [instUniformSpaceProd, ← cauchy_comap_uniformSpace, ← cauchy_inf_uniformSpace]
theorem Cauchy.prod [UniformSpace β] {f : Filter α} {g : Filter β} (hf : Cauchy f) (hg : Cauchy g) :
Cauchy (f ×ˢ g) := by
have := hf.1; have := hg.1
simpa [cauchy_prod_iff, hf.1] using ⟨hf, hg⟩
#align cauchy.prod Cauchy.prod
theorem le_nhds_of_cauchy_adhp_aux {f : Filter α} {x : α}
(adhs : ∀ s ∈ 𝓤 α, ∃ t ∈ f, t ×ˢ t ⊆ s ∧ ∃ y, (x, y) ∈ s ∧ y ∈ t) : f ≤ 𝓝 x := by
-- Consider a neighborhood `s` of `x`
intro s hs
-- Take an entourage twice smaller than `s`
rcases comp_mem_uniformity_sets (mem_nhds_uniformity_iff_right.1 hs) with ⟨U, U_mem, hU⟩
-- Take a set `t ∈ f`, `t × t ⊆ U`, and a point `y ∈ t` such that `(x, y) ∈ U`
rcases adhs U U_mem with ⟨t, t_mem, ht, y, hxy, hy⟩
apply mem_of_superset t_mem
-- Given a point `z ∈ t`, we have `(x, y) ∈ U` and `(y, z) ∈ t × t ⊆ U`, hence `z ∈ s`
exact fun z hz => hU (prod_mk_mem_compRel hxy (ht <| mk_mem_prod hy hz)) rfl
#align le_nhds_of_cauchy_adhp_aux le_nhds_of_cauchy_adhp_aux
theorem le_nhds_of_cauchy_adhp {f : Filter α} {x : α} (hf : Cauchy f) (adhs : ClusterPt x f) :
f ≤ 𝓝 x :=
le_nhds_of_cauchy_adhp_aux
(fun s hs => by
obtain ⟨t, t_mem, ht⟩ : ∃ t ∈ f, t ×ˢ t ⊆ s := (cauchy_iff.1 hf).2 s hs
use t, t_mem, ht
exact forall_mem_nonempty_iff_neBot.2 adhs _ (inter_mem_inf (mem_nhds_left x hs) t_mem))
#align le_nhds_of_cauchy_adhp le_nhds_of_cauchy_adhp
theorem le_nhds_iff_adhp_of_cauchy {f : Filter α} {x : α} (hf : Cauchy f) :
f ≤ 𝓝 x ↔ ClusterPt x f :=
⟨fun h => ClusterPt.of_le_nhds' h hf.1, le_nhds_of_cauchy_adhp hf⟩
#align le_nhds_iff_adhp_of_cauchy le_nhds_iff_adhp_of_cauchy
nonrec theorem Cauchy.map [UniformSpace β] {f : Filter α} {m : α → β} (hf : Cauchy f)
(hm : UniformContinuous m) : Cauchy (map m f) :=
⟨hf.1.map _,
calc
map m f ×ˢ map m f = map (Prod.map m m) (f ×ˢ f) := Filter.prod_map_map_eq
_ ≤ Filter.map (Prod.map m m) (𝓤 α) := map_mono hf.right
_ ≤ 𝓤 β := hm⟩
#align cauchy.map Cauchy.map
nonrec theorem Cauchy.comap [UniformSpace β] {f : Filter β} {m : α → β} (hf : Cauchy f)
(hm : comap (fun p : α × α => (m p.1, m p.2)) (𝓤 β) ≤ 𝓤 α) [NeBot (comap m f)] :
Cauchy (comap m f) :=
⟨‹_›,
calc
comap m f ×ˢ comap m f = comap (Prod.map m m) (f ×ˢ f) := prod_comap_comap_eq
_ ≤ comap (Prod.map m m) (𝓤 β) := comap_mono hf.right
_ ≤ 𝓤 α := hm⟩
#align cauchy.comap Cauchy.comap
theorem Cauchy.comap' [UniformSpace β] {f : Filter β} {m : α → β} (hf : Cauchy f)
(hm : Filter.comap (fun p : α × α => (m p.1, m p.2)) (𝓤 β) ≤ 𝓤 α)
(_ : NeBot (Filter.comap m f)) : Cauchy (Filter.comap m f) :=
hf.comap hm
#align cauchy.comap' Cauchy.comap'
def CauchySeq [Preorder β] (u : β → α) :=
Cauchy (atTop.map u)
#align cauchy_seq CauchySeq
| Mathlib/Topology/UniformSpace/Cauchy.lean | 202 | 204 | theorem CauchySeq.tendsto_uniformity [Preorder β] {u : β → α} (h : CauchySeq u) :
Tendsto (Prod.map u u) atTop (𝓤 α) := by |
simpa only [Tendsto, prod_map_map_eq', prod_atTop_atTop_eq] using h.right
|
import Mathlib.Order.Interval.Set.UnorderedInterval
import Mathlib.Algebra.Order.Interval.Set.Monoid
import Mathlib.Data.Set.Pointwise.Basic
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Algebra.Order.Group.MinMax
#align_import data.set.pointwise.interval from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
open Interval Pointwise
variable {α : Type*}
namespace Set
section OrderedAddCommGroup
variable [OrderedAddCommGroup α] (a b c : α)
@[simp]
theorem preimage_const_add_Ici : (fun x => a + x) ⁻¹' Ici b = Ici (b - a) :=
ext fun _x => sub_le_iff_le_add'.symm
#align set.preimage_const_add_Ici Set.preimage_const_add_Ici
@[simp]
theorem preimage_const_add_Ioi : (fun x => a + x) ⁻¹' Ioi b = Ioi (b - a) :=
ext fun _x => sub_lt_iff_lt_add'.symm
#align set.preimage_const_add_Ioi Set.preimage_const_add_Ioi
@[simp]
theorem preimage_const_add_Iic : (fun x => a + x) ⁻¹' Iic b = Iic (b - a) :=
ext fun _x => le_sub_iff_add_le'.symm
#align set.preimage_const_add_Iic Set.preimage_const_add_Iic
@[simp]
theorem preimage_const_add_Iio : (fun x => a + x) ⁻¹' Iio b = Iio (b - a) :=
ext fun _x => lt_sub_iff_add_lt'.symm
#align set.preimage_const_add_Iio Set.preimage_const_add_Iio
@[simp]
theorem preimage_const_add_Icc : (fun x => a + x) ⁻¹' Icc b c = Icc (b - a) (c - a) := by
simp [← Ici_inter_Iic]
#align set.preimage_const_add_Icc Set.preimage_const_add_Icc
@[simp]
theorem preimage_const_add_Ico : (fun x => a + x) ⁻¹' Ico b c = Ico (b - a) (c - a) := by
simp [← Ici_inter_Iio]
#align set.preimage_const_add_Ico Set.preimage_const_add_Ico
@[simp]
theorem preimage_const_add_Ioc : (fun x => a + x) ⁻¹' Ioc b c = Ioc (b - a) (c - a) := by
simp [← Ioi_inter_Iic]
#align set.preimage_const_add_Ioc Set.preimage_const_add_Ioc
@[simp]
theorem preimage_const_add_Ioo : (fun x => a + x) ⁻¹' Ioo b c = Ioo (b - a) (c - a) := by
simp [← Ioi_inter_Iio]
#align set.preimage_const_add_Ioo Set.preimage_const_add_Ioo
@[simp]
theorem preimage_add_const_Ici : (fun x => x + a) ⁻¹' Ici b = Ici (b - a) :=
ext fun _x => sub_le_iff_le_add.symm
#align set.preimage_add_const_Ici Set.preimage_add_const_Ici
@[simp]
theorem preimage_add_const_Ioi : (fun x => x + a) ⁻¹' Ioi b = Ioi (b - a) :=
ext fun _x => sub_lt_iff_lt_add.symm
#align set.preimage_add_const_Ioi Set.preimage_add_const_Ioi
@[simp]
theorem preimage_add_const_Iic : (fun x => x + a) ⁻¹' Iic b = Iic (b - a) :=
ext fun _x => le_sub_iff_add_le.symm
#align set.preimage_add_const_Iic Set.preimage_add_const_Iic
@[simp]
theorem preimage_add_const_Iio : (fun x => x + a) ⁻¹' Iio b = Iio (b - a) :=
ext fun _x => lt_sub_iff_add_lt.symm
#align set.preimage_add_const_Iio Set.preimage_add_const_Iio
@[simp]
theorem preimage_add_const_Icc : (fun x => x + a) ⁻¹' Icc b c = Icc (b - a) (c - a) := by
simp [← Ici_inter_Iic]
#align set.preimage_add_const_Icc Set.preimage_add_const_Icc
@[simp]
theorem preimage_add_const_Ico : (fun x => x + a) ⁻¹' Ico b c = Ico (b - a) (c - a) := by
simp [← Ici_inter_Iio]
#align set.preimage_add_const_Ico Set.preimage_add_const_Ico
@[simp]
theorem preimage_add_const_Ioc : (fun x => x + a) ⁻¹' Ioc b c = Ioc (b - a) (c - a) := by
simp [← Ioi_inter_Iic]
#align set.preimage_add_const_Ioc Set.preimage_add_const_Ioc
@[simp]
theorem preimage_add_const_Ioo : (fun x => x + a) ⁻¹' Ioo b c = Ioo (b - a) (c - a) := by
simp [← Ioi_inter_Iio]
#align set.preimage_add_const_Ioo Set.preimage_add_const_Ioo
@[simp]
theorem preimage_neg_Ici : -Ici a = Iic (-a) :=
ext fun _x => le_neg
#align set.preimage_neg_Ici Set.preimage_neg_Ici
@[simp]
theorem preimage_neg_Iic : -Iic a = Ici (-a) :=
ext fun _x => neg_le
#align set.preimage_neg_Iic Set.preimage_neg_Iic
@[simp]
theorem preimage_neg_Ioi : -Ioi a = Iio (-a) :=
ext fun _x => lt_neg
#align set.preimage_neg_Ioi Set.preimage_neg_Ioi
@[simp]
theorem preimage_neg_Iio : -Iio a = Ioi (-a) :=
ext fun _x => neg_lt
#align set.preimage_neg_Iio Set.preimage_neg_Iio
@[simp]
theorem preimage_neg_Icc : -Icc a b = Icc (-b) (-a) := by simp [← Ici_inter_Iic, inter_comm]
#align set.preimage_neg_Icc Set.preimage_neg_Icc
@[simp]
theorem preimage_neg_Ico : -Ico a b = Ioc (-b) (-a) := by
simp [← Ici_inter_Iio, ← Ioi_inter_Iic, inter_comm]
#align set.preimage_neg_Ico Set.preimage_neg_Ico
@[simp]
theorem preimage_neg_Ioc : -Ioc a b = Ico (-b) (-a) := by
simp [← Ioi_inter_Iic, ← Ici_inter_Iio, inter_comm]
#align set.preimage_neg_Ioc Set.preimage_neg_Ioc
@[simp]
theorem preimage_neg_Ioo : -Ioo a b = Ioo (-b) (-a) := by simp [← Ioi_inter_Iio, inter_comm]
#align set.preimage_neg_Ioo Set.preimage_neg_Ioo
@[simp]
theorem preimage_sub_const_Ici : (fun x => x - a) ⁻¹' Ici b = Ici (b + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Ici Set.preimage_sub_const_Ici
@[simp]
theorem preimage_sub_const_Ioi : (fun x => x - a) ⁻¹' Ioi b = Ioi (b + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Ioi Set.preimage_sub_const_Ioi
@[simp]
theorem preimage_sub_const_Iic : (fun x => x - a) ⁻¹' Iic b = Iic (b + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Iic Set.preimage_sub_const_Iic
@[simp]
theorem preimage_sub_const_Iio : (fun x => x - a) ⁻¹' Iio b = Iio (b + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Iio Set.preimage_sub_const_Iio
@[simp]
theorem preimage_sub_const_Icc : (fun x => x - a) ⁻¹' Icc b c = Icc (b + a) (c + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Icc Set.preimage_sub_const_Icc
@[simp]
theorem preimage_sub_const_Ico : (fun x => x - a) ⁻¹' Ico b c = Ico (b + a) (c + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Ico Set.preimage_sub_const_Ico
@[simp]
theorem preimage_sub_const_Ioc : (fun x => x - a) ⁻¹' Ioc b c = Ioc (b + a) (c + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Ioc Set.preimage_sub_const_Ioc
@[simp]
theorem preimage_sub_const_Ioo : (fun x => x - a) ⁻¹' Ioo b c = Ioo (b + a) (c + a) := by
simp [sub_eq_add_neg]
#align set.preimage_sub_const_Ioo Set.preimage_sub_const_Ioo
@[simp]
theorem preimage_const_sub_Ici : (fun x => a - x) ⁻¹' Ici b = Iic (a - b) :=
ext fun _x => le_sub_comm
#align set.preimage_const_sub_Ici Set.preimage_const_sub_Ici
@[simp]
theorem preimage_const_sub_Iic : (fun x => a - x) ⁻¹' Iic b = Ici (a - b) :=
ext fun _x => sub_le_comm
#align set.preimage_const_sub_Iic Set.preimage_const_sub_Iic
@[simp]
theorem preimage_const_sub_Ioi : (fun x => a - x) ⁻¹' Ioi b = Iio (a - b) :=
ext fun _x => lt_sub_comm
#align set.preimage_const_sub_Ioi Set.preimage_const_sub_Ioi
@[simp]
theorem preimage_const_sub_Iio : (fun x => a - x) ⁻¹' Iio b = Ioi (a - b) :=
ext fun _x => sub_lt_comm
#align set.preimage_const_sub_Iio Set.preimage_const_sub_Iio
@[simp]
theorem preimage_const_sub_Icc : (fun x => a - x) ⁻¹' Icc b c = Icc (a - c) (a - b) := by
simp [← Ici_inter_Iic, inter_comm]
#align set.preimage_const_sub_Icc Set.preimage_const_sub_Icc
@[simp]
theorem preimage_const_sub_Ico : (fun x => a - x) ⁻¹' Ico b c = Ioc (a - c) (a - b) := by
simp [← Ioi_inter_Iic, ← Ici_inter_Iio, inter_comm]
#align set.preimage_const_sub_Ico Set.preimage_const_sub_Ico
@[simp]
theorem preimage_const_sub_Ioc : (fun x => a - x) ⁻¹' Ioc b c = Ico (a - c) (a - b) := by
simp [← Ioi_inter_Iic, ← Ici_inter_Iio, inter_comm]
#align set.preimage_const_sub_Ioc Set.preimage_const_sub_Ioc
@[simp]
theorem preimage_const_sub_Ioo : (fun x => a - x) ⁻¹' Ioo b c = Ioo (a - c) (a - b) := by
simp [← Ioi_inter_Iio, inter_comm]
#align set.preimage_const_sub_Ioo Set.preimage_const_sub_Ioo
-- @[simp] -- Porting note (#10618): simp can prove this modulo `add_comm`
theorem image_const_add_Iic : (fun x => a + x) '' Iic b = Iic (a + b) := by simp [add_comm]
#align set.image_const_add_Iic Set.image_const_add_Iic
-- @[simp] -- Porting note (#10618): simp can prove this modulo `add_comm`
theorem image_const_add_Iio : (fun x => a + x) '' Iio b = Iio (a + b) := by simp [add_comm]
#align set.image_const_add_Iio Set.image_const_add_Iio
-- @[simp] -- Porting note (#10618): simp can prove this
| Mathlib/Data/Set/Pointwise/Interval.lean | 363 | 363 | theorem image_add_const_Iic : (fun x => x + a) '' Iic b = Iic (b + a) := by | simp
|
import Mathlib.ModelTheory.Substructures
#align_import model_theory.finitely_generated from "leanprover-community/mathlib"@"0602c59878ff3d5f71dea69c2d32ccf2e93e5398"
open FirstOrder Set
namespace FirstOrder
namespace Language
open Structure
variable {L : Language} {M : Type*} [L.Structure M]
namespace Substructure
def FG (N : L.Substructure M) : Prop :=
∃ S : Finset M, closure L S = N
#align first_order.language.substructure.fg FirstOrder.Language.Substructure.FG
theorem fg_def {N : L.Substructure M} : N.FG ↔ ∃ S : Set M, S.Finite ∧ closure L S = N :=
⟨fun ⟨t, h⟩ => ⟨_, Finset.finite_toSet t, h⟩, by
rintro ⟨t', h, rfl⟩
rcases Finite.exists_finset_coe h with ⟨t, rfl⟩
exact ⟨t, rfl⟩⟩
#align first_order.language.substructure.fg_def FirstOrder.Language.Substructure.fg_def
theorem fg_iff_exists_fin_generating_family {N : L.Substructure M} :
N.FG ↔ ∃ (n : ℕ) (s : Fin n → M), closure L (range s) = N := by
rw [fg_def]
constructor
· rintro ⟨S, Sfin, hS⟩
obtain ⟨n, f, rfl⟩ := Sfin.fin_embedding
exact ⟨n, f, hS⟩
· rintro ⟨n, s, hs⟩
exact ⟨range s, finite_range s, hs⟩
#align first_order.language.substructure.fg_iff_exists_fin_generating_family FirstOrder.Language.Substructure.fg_iff_exists_fin_generating_family
theorem fg_bot : (⊥ : L.Substructure M).FG :=
⟨∅, by rw [Finset.coe_empty, closure_empty]⟩
#align first_order.language.substructure.fg_bot FirstOrder.Language.Substructure.fg_bot
theorem fg_closure {s : Set M} (hs : s.Finite) : FG (closure L s) :=
⟨hs.toFinset, by rw [hs.coe_toFinset]⟩
#align first_order.language.substructure.fg_closure FirstOrder.Language.Substructure.fg_closure
theorem fg_closure_singleton (x : M) : FG (closure L ({x} : Set M)) :=
fg_closure (finite_singleton x)
#align first_order.language.substructure.fg_closure_singleton FirstOrder.Language.Substructure.fg_closure_singleton
theorem FG.sup {N₁ N₂ : L.Substructure M} (hN₁ : N₁.FG) (hN₂ : N₂.FG) : (N₁ ⊔ N₂).FG :=
let ⟨t₁, ht₁⟩ := fg_def.1 hN₁
let ⟨t₂, ht₂⟩ := fg_def.1 hN₂
fg_def.2 ⟨t₁ ∪ t₂, ht₁.1.union ht₂.1, by rw [closure_union, ht₁.2, ht₂.2]⟩
#align first_order.language.substructure.fg.sup FirstOrder.Language.Substructure.FG.sup
theorem FG.map {N : Type*} [L.Structure N] (f : M →[L] N) {s : L.Substructure M} (hs : s.FG) :
(s.map f).FG :=
let ⟨t, ht⟩ := fg_def.1 hs
fg_def.2 ⟨f '' t, ht.1.image _, by rw [closure_image, ht.2]⟩
#align first_order.language.substructure.fg.map FirstOrder.Language.Substructure.FG.map
theorem FG.of_map_embedding {N : Type*} [L.Structure N] (f : M ↪[L] N) {s : L.Substructure M}
(hs : (s.map f.toHom).FG) : s.FG := by
rcases hs with ⟨t, h⟩
rw [fg_def]
refine ⟨f ⁻¹' t, t.finite_toSet.preimage f.injective.injOn, ?_⟩
have hf : Function.Injective f.toHom := f.injective
refine map_injective_of_injective hf ?_
rw [← h, map_closure, Embedding.coe_toHom, image_preimage_eq_of_subset]
intro x hx
have h' := subset_closure (L := L) hx
rw [h] at h'
exact Hom.map_le_range h'
#align first_order.language.substructure.fg.of_map_embedding FirstOrder.Language.Substructure.FG.of_map_embedding
def CG (N : L.Substructure M) : Prop :=
∃ S : Set M, S.Countable ∧ closure L S = N
#align first_order.language.substructure.cg FirstOrder.Language.Substructure.CG
theorem cg_def {N : L.Substructure M} : N.CG ↔ ∃ S : Set M, S.Countable ∧ closure L S = N :=
Iff.refl _
#align first_order.language.substructure.cg_def FirstOrder.Language.Substructure.cg_def
| Mathlib/ModelTheory/FinitelyGenerated.lean | 111 | 113 | theorem FG.cg {N : L.Substructure M} (h : N.FG) : N.CG := by |
obtain ⟨s, hf, rfl⟩ := fg_def.1 h
exact ⟨s, hf.countable, rfl⟩
|
import Mathlib.Data.Real.Sqrt
import Mathlib.Analysis.NormedSpace.Star.Basic
import Mathlib.Analysis.NormedSpace.ContinuousLinearMap
import Mathlib.Analysis.NormedSpace.Basic
#align_import data.is_R_or_C.basic from "leanprover-community/mathlib"@"baa88307f3e699fa7054ef04ec79fa4f056169cb"
section
local notation "𝓚" => algebraMap ℝ _
open ComplexConjugate
class RCLike (K : semiOutParam Type*) extends DenselyNormedField K, StarRing K,
NormedAlgebra ℝ K, CompleteSpace K where
re : K →+ ℝ
im : K →+ ℝ
I : K
I_re_ax : re I = 0
I_mul_I_ax : I = 0 ∨ I * I = -1
re_add_im_ax : ∀ z : K, 𝓚 (re z) + 𝓚 (im z) * I = z
ofReal_re_ax : ∀ r : ℝ, re (𝓚 r) = r
ofReal_im_ax : ∀ r : ℝ, im (𝓚 r) = 0
mul_re_ax : ∀ z w : K, re (z * w) = re z * re w - im z * im w
mul_im_ax : ∀ z w : K, im (z * w) = re z * im w + im z * re w
conj_re_ax : ∀ z : K, re (conj z) = re z
conj_im_ax : ∀ z : K, im (conj z) = -im z
conj_I_ax : conj I = -I
norm_sq_eq_def_ax : ∀ z : K, ‖z‖ ^ 2 = re z * re z + im z * im z
mul_im_I_ax : ∀ z : K, im z * im I = im z
[toPartialOrder : PartialOrder K]
le_iff_re_im {z w : K} : z ≤ w ↔ re z ≤ re w ∧ im z = im w
-- note we cannot put this in the `extends` clause
[toDecidableEq : DecidableEq K]
#align is_R_or_C RCLike
scoped[ComplexOrder] attribute [instance 100] RCLike.toPartialOrder
attribute [instance 100] RCLike.toDecidableEq
end
variable {K E : Type*} [RCLike K]
namespace RCLike
open ComplexConjugate
@[coe] abbrev ofReal : ℝ → K := Algebra.cast
noncomputable instance (priority := 900) algebraMapCoe : CoeTC ℝ K :=
⟨ofReal⟩
#align is_R_or_C.algebra_map_coe RCLike.algebraMapCoe
theorem ofReal_alg (x : ℝ) : (x : K) = x • (1 : K) :=
Algebra.algebraMap_eq_smul_one x
#align is_R_or_C.of_real_alg RCLike.ofReal_alg
theorem real_smul_eq_coe_mul (r : ℝ) (z : K) : r • z = (r : K) * z :=
Algebra.smul_def r z
#align is_R_or_C.real_smul_eq_coe_mul RCLike.real_smul_eq_coe_mul
theorem real_smul_eq_coe_smul [AddCommGroup E] [Module K E] [Module ℝ E] [IsScalarTower ℝ K E]
(r : ℝ) (x : E) : r • x = (r : K) • x := by rw [RCLike.ofReal_alg, smul_one_smul]
#align is_R_or_C.real_smul_eq_coe_smul RCLike.real_smul_eq_coe_smul
theorem algebraMap_eq_ofReal : ⇑(algebraMap ℝ K) = ofReal :=
rfl
#align is_R_or_C.algebra_map_eq_of_real RCLike.algebraMap_eq_ofReal
@[simp, rclike_simps]
theorem re_add_im (z : K) : (re z : K) + im z * I = z :=
RCLike.re_add_im_ax z
#align is_R_or_C.re_add_im RCLike.re_add_im
@[simp, norm_cast, rclike_simps]
theorem ofReal_re : ∀ r : ℝ, re (r : K) = r :=
RCLike.ofReal_re_ax
#align is_R_or_C.of_real_re RCLike.ofReal_re
@[simp, norm_cast, rclike_simps]
theorem ofReal_im : ∀ r : ℝ, im (r : K) = 0 :=
RCLike.ofReal_im_ax
#align is_R_or_C.of_real_im RCLike.ofReal_im
@[simp, rclike_simps]
theorem mul_re : ∀ z w : K, re (z * w) = re z * re w - im z * im w :=
RCLike.mul_re_ax
#align is_R_or_C.mul_re RCLike.mul_re
@[simp, rclike_simps]
theorem mul_im : ∀ z w : K, im (z * w) = re z * im w + im z * re w :=
RCLike.mul_im_ax
#align is_R_or_C.mul_im RCLike.mul_im
theorem ext_iff {z w : K} : z = w ↔ re z = re w ∧ im z = im w :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, fun ⟨h₁, h₂⟩ => re_add_im z ▸ re_add_im w ▸ h₁ ▸ h₂ ▸ rfl⟩
#align is_R_or_C.ext_iff RCLike.ext_iff
theorem ext {z w : K} (hre : re z = re w) (him : im z = im w) : z = w :=
ext_iff.2 ⟨hre, him⟩
#align is_R_or_C.ext RCLike.ext
@[norm_cast]
theorem ofReal_zero : ((0 : ℝ) : K) = 0 :=
algebraMap.coe_zero
#align is_R_or_C.of_real_zero RCLike.ofReal_zero
@[rclike_simps]
theorem zero_re' : re (0 : K) = (0 : ℝ) :=
map_zero re
#align is_R_or_C.zero_re' RCLike.zero_re'
@[norm_cast]
theorem ofReal_one : ((1 : ℝ) : K) = 1 :=
map_one (algebraMap ℝ K)
#align is_R_or_C.of_real_one RCLike.ofReal_one
@[simp, rclike_simps]
theorem one_re : re (1 : K) = 1 := by rw [← ofReal_one, ofReal_re]
#align is_R_or_C.one_re RCLike.one_re
@[simp, rclike_simps]
theorem one_im : im (1 : K) = 0 := by rw [← ofReal_one, ofReal_im]
#align is_R_or_C.one_im RCLike.one_im
theorem ofReal_injective : Function.Injective ((↑) : ℝ → K) :=
(algebraMap ℝ K).injective
#align is_R_or_C.of_real_injective RCLike.ofReal_injective
@[norm_cast]
theorem ofReal_inj {z w : ℝ} : (z : K) = (w : K) ↔ z = w :=
algebraMap.coe_inj
#align is_R_or_C.of_real_inj RCLike.ofReal_inj
-- replaced by `RCLike.ofNat_re`
#noalign is_R_or_C.bit0_re
#noalign is_R_or_C.bit1_re
-- replaced by `RCLike.ofNat_im`
#noalign is_R_or_C.bit0_im
#noalign is_R_or_C.bit1_im
theorem ofReal_eq_zero {x : ℝ} : (x : K) = 0 ↔ x = 0 :=
algebraMap.lift_map_eq_zero_iff x
#align is_R_or_C.of_real_eq_zero RCLike.ofReal_eq_zero
theorem ofReal_ne_zero {x : ℝ} : (x : K) ≠ 0 ↔ x ≠ 0 :=
ofReal_eq_zero.not
#align is_R_or_C.of_real_ne_zero RCLike.ofReal_ne_zero
@[simp, rclike_simps, norm_cast]
theorem ofReal_add (r s : ℝ) : ((r + s : ℝ) : K) = r + s :=
algebraMap.coe_add _ _
#align is_R_or_C.of_real_add RCLike.ofReal_add
-- replaced by `RCLike.ofReal_ofNat`
#noalign is_R_or_C.of_real_bit0
#noalign is_R_or_C.of_real_bit1
@[simp, norm_cast, rclike_simps]
theorem ofReal_neg (r : ℝ) : ((-r : ℝ) : K) = -r :=
algebraMap.coe_neg r
#align is_R_or_C.of_real_neg RCLike.ofReal_neg
@[simp, norm_cast, rclike_simps]
theorem ofReal_sub (r s : ℝ) : ((r - s : ℝ) : K) = r - s :=
map_sub (algebraMap ℝ K) r s
#align is_R_or_C.of_real_sub RCLike.ofReal_sub
@[simp, rclike_simps, norm_cast]
theorem ofReal_sum {α : Type*} (s : Finset α) (f : α → ℝ) :
((∑ i ∈ s, f i : ℝ) : K) = ∑ i ∈ s, (f i : K) :=
map_sum (algebraMap ℝ K) _ _
#align is_R_or_C.of_real_sum RCLike.ofReal_sum
@[simp, rclike_simps, norm_cast]
theorem ofReal_finsupp_sum {α M : Type*} [Zero M] (f : α →₀ M) (g : α → M → ℝ) :
((f.sum fun a b => g a b : ℝ) : K) = f.sum fun a b => (g a b : K) :=
map_finsupp_sum (algebraMap ℝ K) f g
#align is_R_or_C.of_real_finsupp_sum RCLike.ofReal_finsupp_sum
@[simp, norm_cast, rclike_simps]
theorem ofReal_mul (r s : ℝ) : ((r * s : ℝ) : K) = r * s :=
algebraMap.coe_mul _ _
#align is_R_or_C.of_real_mul RCLike.ofReal_mul
@[simp, norm_cast, rclike_simps]
theorem ofReal_pow (r : ℝ) (n : ℕ) : ((r ^ n : ℝ) : K) = (r : K) ^ n :=
map_pow (algebraMap ℝ K) r n
#align is_R_or_C.of_real_pow RCLike.ofReal_pow
@[simp, rclike_simps, norm_cast]
theorem ofReal_prod {α : Type*} (s : Finset α) (f : α → ℝ) :
((∏ i ∈ s, f i : ℝ) : K) = ∏ i ∈ s, (f i : K) :=
map_prod (algebraMap ℝ K) _ _
#align is_R_or_C.of_real_prod RCLike.ofReal_prod
@[simp, rclike_simps, norm_cast]
theorem ofReal_finsupp_prod {α M : Type*} [Zero M] (f : α →₀ M) (g : α → M → ℝ) :
((f.prod fun a b => g a b : ℝ) : K) = f.prod fun a b => (g a b : K) :=
map_finsupp_prod _ f g
#align is_R_or_C.of_real_finsupp_prod RCLike.ofReal_finsupp_prod
@[simp, norm_cast, rclike_simps]
theorem real_smul_ofReal (r x : ℝ) : r • (x : K) = (r : K) * (x : K) :=
real_smul_eq_coe_mul _ _
#align is_R_or_C.real_smul_of_real RCLike.real_smul_ofReal
@[rclike_simps]
theorem re_ofReal_mul (r : ℝ) (z : K) : re (↑r * z) = r * re z := by
simp only [mul_re, ofReal_im, zero_mul, ofReal_re, sub_zero]
#align is_R_or_C.of_real_mul_re RCLike.re_ofReal_mul
@[rclike_simps]
theorem im_ofReal_mul (r : ℝ) (z : K) : im (↑r * z) = r * im z := by
simp only [add_zero, ofReal_im, zero_mul, ofReal_re, mul_im]
#align is_R_or_C.of_real_mul_im RCLike.im_ofReal_mul
@[rclike_simps]
theorem smul_re (r : ℝ) (z : K) : re (r • z) = r * re z := by
rw [real_smul_eq_coe_mul, re_ofReal_mul]
#align is_R_or_C.smul_re RCLike.smul_re
@[rclike_simps]
theorem smul_im (r : ℝ) (z : K) : im (r • z) = r * im z := by
rw [real_smul_eq_coe_mul, im_ofReal_mul]
#align is_R_or_C.smul_im RCLike.smul_im
@[simp, norm_cast, rclike_simps]
theorem norm_ofReal (r : ℝ) : ‖(r : K)‖ = |r| :=
norm_algebraMap' K r
#align is_R_or_C.norm_of_real RCLike.norm_ofReal
-- see Note [lower instance priority]
instance (priority := 100) charZero_rclike : CharZero K :=
(RingHom.charZero_iff (algebraMap ℝ K).injective).1 inferInstance
set_option linter.uppercaseLean3 false in
#align is_R_or_C.char_zero_R_or_C RCLike.charZero_rclike
@[simp, rclike_simps]
theorem I_re : re (I : K) = 0 :=
I_re_ax
set_option linter.uppercaseLean3 false in
#align is_R_or_C.I_re RCLike.I_re
@[simp, rclike_simps]
theorem I_im (z : K) : im z * im (I : K) = im z :=
mul_im_I_ax z
set_option linter.uppercaseLean3 false in
#align is_R_or_C.I_im RCLike.I_im
@[simp, rclike_simps]
theorem I_im' (z : K) : im (I : K) * im z = im z := by rw [mul_comm, I_im]
set_option linter.uppercaseLean3 false in
#align is_R_or_C.I_im' RCLike.I_im'
@[rclike_simps] -- porting note (#10618): was `simp`
theorem I_mul_re (z : K) : re (I * z) = -im z := by
simp only [I_re, zero_sub, I_im', zero_mul, mul_re]
set_option linter.uppercaseLean3 false in
#align is_R_or_C.I_mul_re RCLike.I_mul_re
theorem I_mul_I : (I : K) = 0 ∨ (I : K) * I = -1 :=
I_mul_I_ax
set_option linter.uppercaseLean3 false in
#align is_R_or_C.I_mul_I RCLike.I_mul_I
variable (𝕜) in
lemma I_eq_zero_or_im_I_eq_one : (I : K) = 0 ∨ im (I : K) = 1 :=
I_mul_I (K := K) |>.imp_right fun h ↦ by simpa [h] using (I_mul_re (I : K)).symm
@[simp, rclike_simps]
theorem conj_re (z : K) : re (conj z) = re z :=
RCLike.conj_re_ax z
#align is_R_or_C.conj_re RCLike.conj_re
@[simp, rclike_simps]
theorem conj_im (z : K) : im (conj z) = -im z :=
RCLike.conj_im_ax z
#align is_R_or_C.conj_im RCLike.conj_im
@[simp, rclike_simps]
theorem conj_I : conj (I : K) = -I :=
RCLike.conj_I_ax
set_option linter.uppercaseLean3 false in
#align is_R_or_C.conj_I RCLike.conj_I
@[simp, rclike_simps]
theorem conj_ofReal (r : ℝ) : conj (r : K) = (r : K) := by
rw [ext_iff]
simp only [ofReal_im, conj_im, eq_self_iff_true, conj_re, and_self_iff, neg_zero]
#align is_R_or_C.conj_of_real RCLike.conj_ofReal
-- replaced by `RCLike.conj_ofNat`
#noalign is_R_or_C.conj_bit0
#noalign is_R_or_C.conj_bit1
theorem conj_nat_cast (n : ℕ) : conj (n : K) = n := map_natCast _ _
-- See note [no_index around OfNat.ofNat]
theorem conj_ofNat (n : ℕ) [n.AtLeastTwo] : conj (no_index (OfNat.ofNat n : K)) = OfNat.ofNat n :=
map_ofNat _ _
@[rclike_simps] -- Porting note (#10618): was a `simp` but `simp` can prove it
theorem conj_neg_I : conj (-I) = (I : K) := by rw [map_neg, conj_I, neg_neg]
set_option linter.uppercaseLean3 false in
#align is_R_or_C.conj_neg_I RCLike.conj_neg_I
theorem conj_eq_re_sub_im (z : K) : conj z = re z - im z * I :=
(congr_arg conj (re_add_im z).symm).trans <| by
rw [map_add, map_mul, conj_I, conj_ofReal, conj_ofReal, mul_neg, sub_eq_add_neg]
#align is_R_or_C.conj_eq_re_sub_im RCLike.conj_eq_re_sub_im
theorem sub_conj (z : K) : z - conj z = 2 * im z * I :=
calc
z - conj z = re z + im z * I - (re z - im z * I) := by rw [re_add_im, ← conj_eq_re_sub_im]
_ = 2 * im z * I := by rw [add_sub_sub_cancel, ← two_mul, mul_assoc]
#align is_R_or_C.sub_conj RCLike.sub_conj
@[rclike_simps]
theorem conj_smul (r : ℝ) (z : K) : conj (r • z) = r • conj z := by
rw [conj_eq_re_sub_im, conj_eq_re_sub_im, smul_re, smul_im, ofReal_mul, ofReal_mul,
real_smul_eq_coe_mul r (_ - _), mul_sub, mul_assoc]
#align is_R_or_C.conj_smul RCLike.conj_smul
theorem add_conj (z : K) : z + conj z = 2 * re z :=
calc
z + conj z = re z + im z * I + (re z - im z * I) := by rw [re_add_im, conj_eq_re_sub_im]
_ = 2 * re z := by rw [add_add_sub_cancel, two_mul]
#align is_R_or_C.add_conj RCLike.add_conj
theorem re_eq_add_conj (z : K) : ↑(re z) = (z + conj z) / 2 := by
rw [add_conj, mul_div_cancel_left₀ (re z : K) two_ne_zero]
#align is_R_or_C.re_eq_add_conj RCLike.re_eq_add_conj
theorem im_eq_conj_sub (z : K) : ↑(im z) = I * (conj z - z) / 2 := by
rw [← neg_inj, ← ofReal_neg, ← I_mul_re, re_eq_add_conj, map_mul, conj_I, ← neg_div, ← mul_neg,
neg_sub, mul_sub, neg_mul, sub_eq_add_neg]
#align is_R_or_C.im_eq_conj_sub RCLike.im_eq_conj_sub
open List in
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
tfae_have 1 → 4
· intro h
rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div,
ofReal_zero]
tfae_have 4 → 3
· intro h
conv_rhs => rw [← re_add_im z, h, ofReal_zero, zero_mul, add_zero]
tfae_have 3 → 2
· exact fun h => ⟨_, h⟩
tfae_have 2 → 1
· exact fun ⟨r, hr⟩ => hr ▸ conj_ofReal _
tfae_finish
#align is_R_or_C.is_real_tfae RCLike.is_real_TFAE
theorem conj_eq_iff_real {z : K} : conj z = z ↔ ∃ r : ℝ, z = (r : K) :=
((is_real_TFAE z).out 0 1).trans <| by simp only [eq_comm]
#align is_R_or_C.conj_eq_iff_real RCLike.conj_eq_iff_real
theorem conj_eq_iff_re {z : K} : conj z = z ↔ (re z : K) = z :=
(is_real_TFAE z).out 0 2
#align is_R_or_C.conj_eq_iff_re RCLike.conj_eq_iff_re
theorem conj_eq_iff_im {z : K} : conj z = z ↔ im z = 0 :=
(is_real_TFAE z).out 0 3
#align is_R_or_C.conj_eq_iff_im RCLike.conj_eq_iff_im
@[simp]
theorem star_def : (Star.star : K → K) = conj :=
rfl
#align is_R_or_C.star_def RCLike.star_def
variable (K)
abbrev conjToRingEquiv : K ≃+* Kᵐᵒᵖ :=
starRingEquiv
#align is_R_or_C.conj_to_ring_equiv RCLike.conjToRingEquiv
variable {K} {z : K}
def normSq : K →*₀ ℝ where
toFun z := re z * re z + im z * im z
map_zero' := by simp only [add_zero, mul_zero, map_zero]
map_one' := by simp only [one_im, add_zero, mul_one, one_re, mul_zero]
map_mul' z w := by
simp only [mul_im, mul_re]
ring
#align is_R_or_C.norm_sq RCLike.normSq
theorem normSq_apply (z : K) : normSq z = re z * re z + im z * im z :=
rfl
#align is_R_or_C.norm_sq_apply RCLike.normSq_apply
theorem norm_sq_eq_def {z : K} : ‖z‖ ^ 2 = re z * re z + im z * im z :=
norm_sq_eq_def_ax z
#align is_R_or_C.norm_sq_eq_def RCLike.norm_sq_eq_def
theorem normSq_eq_def' (z : K) : normSq z = ‖z‖ ^ 2 :=
norm_sq_eq_def.symm
#align is_R_or_C.norm_sq_eq_def' RCLike.normSq_eq_def'
@[rclike_simps]
theorem normSq_zero : normSq (0 : K) = 0 :=
normSq.map_zero
#align is_R_or_C.norm_sq_zero RCLike.normSq_zero
@[rclike_simps]
theorem normSq_one : normSq (1 : K) = 1 :=
normSq.map_one
#align is_R_or_C.norm_sq_one RCLike.normSq_one
theorem normSq_nonneg (z : K) : 0 ≤ normSq z :=
add_nonneg (mul_self_nonneg _) (mul_self_nonneg _)
#align is_R_or_C.norm_sq_nonneg RCLike.normSq_nonneg
@[rclike_simps] -- porting note (#10618): was `simp`
theorem normSq_eq_zero {z : K} : normSq z = 0 ↔ z = 0 :=
map_eq_zero _
#align is_R_or_C.norm_sq_eq_zero RCLike.normSq_eq_zero
@[simp, rclike_simps]
theorem normSq_pos {z : K} : 0 < normSq z ↔ z ≠ 0 := by
rw [lt_iff_le_and_ne, Ne, eq_comm]; simp [normSq_nonneg]
#align is_R_or_C.norm_sq_pos RCLike.normSq_pos
@[simp, rclike_simps]
theorem normSq_neg (z : K) : normSq (-z) = normSq z := by simp only [normSq_eq_def', norm_neg]
#align is_R_or_C.norm_sq_neg RCLike.normSq_neg
@[simp, rclike_simps]
theorem normSq_conj (z : K) : normSq (conj z) = normSq z := by
simp only [normSq_apply, neg_mul, mul_neg, neg_neg, rclike_simps]
#align is_R_or_C.norm_sq_conj RCLike.normSq_conj
@[rclike_simps] -- porting note (#10618): was `simp`
theorem normSq_mul (z w : K) : normSq (z * w) = normSq z * normSq w :=
map_mul _ z w
#align is_R_or_C.norm_sq_mul RCLike.normSq_mul
theorem normSq_add (z w : K) : normSq (z + w) = normSq z + normSq w + 2 * re (z * conj w) := by
simp only [normSq_apply, map_add, rclike_simps]
ring
#align is_R_or_C.norm_sq_add RCLike.normSq_add
theorem re_sq_le_normSq (z : K) : re z * re z ≤ normSq z :=
le_add_of_nonneg_right (mul_self_nonneg _)
#align is_R_or_C.re_sq_le_norm_sq RCLike.re_sq_le_normSq
theorem im_sq_le_normSq (z : K) : im z * im z ≤ normSq z :=
le_add_of_nonneg_left (mul_self_nonneg _)
#align is_R_or_C.im_sq_le_norm_sq RCLike.im_sq_le_normSq
theorem mul_conj (z : K) : z * conj z = ‖z‖ ^ 2 := by
apply ext <;> simp [← ofReal_pow, norm_sq_eq_def, mul_comm]
#align is_R_or_C.mul_conj RCLike.mul_conj
theorem conj_mul (z : K) : conj z * z = ‖z‖ ^ 2 := by rw [mul_comm, mul_conj]
#align is_R_or_C.conj_mul RCLike.conj_mul
lemma inv_eq_conj (hz : ‖z‖ = 1) : z⁻¹ = conj z :=
inv_eq_of_mul_eq_one_left $ by simp_rw [conj_mul, hz, algebraMap.coe_one, one_pow]
theorem normSq_sub (z w : K) : normSq (z - w) = normSq z + normSq w - 2 * re (z * conj w) := by
simp only [normSq_add, sub_eq_add_neg, map_neg, mul_neg, normSq_neg, map_neg]
#align is_R_or_C.norm_sq_sub RCLike.normSq_sub
theorem sqrt_normSq_eq_norm {z : K} : √(normSq z) = ‖z‖ := by
rw [normSq_eq_def', Real.sqrt_sq (norm_nonneg _)]
#align is_R_or_C.sqrt_norm_sq_eq_norm RCLike.sqrt_normSq_eq_norm
@[simp, norm_cast, rclike_simps]
theorem ofReal_inv (r : ℝ) : ((r⁻¹ : ℝ) : K) = (r : K)⁻¹ :=
map_inv₀ _ r
#align is_R_or_C.of_real_inv RCLike.ofReal_inv
theorem inv_def (z : K) : z⁻¹ = conj z * ((‖z‖ ^ 2)⁻¹ : ℝ) := by
rcases eq_or_ne z 0 with (rfl | h₀)
· simp
· apply inv_eq_of_mul_eq_one_right
rw [← mul_assoc, mul_conj, ofReal_inv, ofReal_pow, mul_inv_cancel]
simpa
#align is_R_or_C.inv_def RCLike.inv_def
@[simp, rclike_simps]
theorem inv_re (z : K) : re z⁻¹ = re z / normSq z := by
rw [inv_def, normSq_eq_def', mul_comm, re_ofReal_mul, conj_re, div_eq_inv_mul]
#align is_R_or_C.inv_re RCLike.inv_re
@[simp, rclike_simps]
theorem inv_im (z : K) : im z⁻¹ = -im z / normSq z := by
rw [inv_def, normSq_eq_def', mul_comm, im_ofReal_mul, conj_im, div_eq_inv_mul]
#align is_R_or_C.inv_im RCLike.inv_im
| Mathlib/Analysis/RCLike/Basic.lean | 550 | 552 | theorem div_re (z w : K) : re (z / w) = re z * re w / normSq w + im z * im w / normSq w := by |
simp only [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, neg_mul, mul_neg, neg_neg, map_neg,
rclike_simps]
|
import Mathlib.Algebra.Module.Submodule.EqLocus
import Mathlib.Algebra.Module.Submodule.RestrictScalars
import Mathlib.Algebra.Ring.Idempotents
import Mathlib.Data.Set.Pointwise.SMul
import Mathlib.LinearAlgebra.Basic
import Mathlib.Order.CompactlyGenerated.Basic
import Mathlib.Order.OmegaCompletePartialOrder
#align_import linear_algebra.span from "leanprover-community/mathlib"@"10878f6bf1dab863445907ab23fbfcefcb5845d0"
variable {R R₂ K M M₂ V S : Type*}
namespace Submodule
open Function Set
open Pointwise
section AddCommMonoid
variable [Semiring R] [AddCommMonoid M] [Module R M]
variable {x : M} (p p' : Submodule R M)
variable [Semiring R₂] {σ₁₂ : R →+* R₂}
variable [AddCommMonoid M₂] [Module R₂ M₂]
variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂]
section
variable (R)
def span (s : Set M) : Submodule R M :=
sInf { p | s ⊆ p }
#align submodule.span Submodule.span
variable {R}
-- Porting note: renamed field to `principal'` and added `principal` to fix explicit argument
@[mk_iff]
class IsPrincipal (S : Submodule R M) : Prop where
principal' : ∃ a, S = span R {a}
#align submodule.is_principal Submodule.IsPrincipal
theorem IsPrincipal.principal (S : Submodule R M) [S.IsPrincipal] :
∃ a, S = span R {a} :=
Submodule.IsPrincipal.principal'
#align submodule.is_principal.principal Submodule.IsPrincipal.principal
end
variable {s t : Set M}
theorem mem_span : x ∈ span R s ↔ ∀ p : Submodule R M, s ⊆ p → x ∈ p :=
mem_iInter₂
#align submodule.mem_span Submodule.mem_span
@[aesop safe 20 apply (rule_sets := [SetLike])]
theorem subset_span : s ⊆ span R s := fun _ h => mem_span.2 fun _ hp => hp h
#align submodule.subset_span Submodule.subset_span
theorem span_le {p} : span R s ≤ p ↔ s ⊆ p :=
⟨Subset.trans subset_span, fun ss _ h => mem_span.1 h _ ss⟩
#align submodule.span_le Submodule.span_le
theorem span_mono (h : s ⊆ t) : span R s ≤ span R t :=
span_le.2 <| Subset.trans h subset_span
#align submodule.span_mono Submodule.span_mono
theorem span_monotone : Monotone (span R : Set M → Submodule R M) := fun _ _ => span_mono
#align submodule.span_monotone Submodule.span_monotone
theorem span_eq_of_le (h₁ : s ⊆ p) (h₂ : p ≤ span R s) : span R s = p :=
le_antisymm (span_le.2 h₁) h₂
#align submodule.span_eq_of_le Submodule.span_eq_of_le
theorem span_eq : span R (p : Set M) = p :=
span_eq_of_le _ (Subset.refl _) subset_span
#align submodule.span_eq Submodule.span_eq
theorem span_eq_span (hs : s ⊆ span R t) (ht : t ⊆ span R s) : span R s = span R t :=
le_antisymm (span_le.2 hs) (span_le.2 ht)
#align submodule.span_eq_span Submodule.span_eq_span
lemma coe_span_eq_self [SetLike S M] [AddSubmonoidClass S M] [SMulMemClass S R M] (s : S) :
(span R (s : Set M) : Set M) = s := by
refine le_antisymm ?_ subset_span
let s' : Submodule R M :=
{ carrier := s
add_mem' := add_mem
zero_mem' := zero_mem _
smul_mem' := SMulMemClass.smul_mem }
exact span_le (p := s') |>.mpr le_rfl
@[simp]
theorem span_coe_eq_restrictScalars [Semiring S] [SMul S R] [Module S M] [IsScalarTower S R M] :
span S (p : Set M) = p.restrictScalars S :=
span_eq (p.restrictScalars S)
#align submodule.span_coe_eq_restrict_scalars Submodule.span_coe_eq_restrictScalars
theorem image_span_subset (f : F) (s : Set M) (N : Submodule R₂ M₂) :
f '' span R s ⊆ N ↔ ∀ m ∈ s, f m ∈ N := image_subset_iff.trans <| span_le (p := N.comap f)
theorem image_span_subset_span (f : F) (s : Set M) : f '' span R s ⊆ span R₂ (f '' s) :=
(image_span_subset f s _).2 fun x hx ↦ subset_span ⟨x, hx, rfl⟩
theorem map_span [RingHomSurjective σ₁₂] (f : F) (s : Set M) :
(span R s).map f = span R₂ (f '' s) :=
Eq.symm <| span_eq_of_le _ (Set.image_subset f subset_span) (image_span_subset_span f s)
#align submodule.map_span Submodule.map_span
alias _root_.LinearMap.map_span := Submodule.map_span
#align linear_map.map_span LinearMap.map_span
theorem map_span_le [RingHomSurjective σ₁₂] (f : F) (s : Set M) (N : Submodule R₂ M₂) :
map f (span R s) ≤ N ↔ ∀ m ∈ s, f m ∈ N := image_span_subset f s N
#align submodule.map_span_le Submodule.map_span_le
alias _root_.LinearMap.map_span_le := Submodule.map_span_le
#align linear_map.map_span_le LinearMap.map_span_le
@[simp]
theorem span_insert_zero : span R (insert (0 : M) s) = span R s := by
refine le_antisymm ?_ (Submodule.span_mono (Set.subset_insert 0 s))
rw [span_le, Set.insert_subset_iff]
exact ⟨by simp only [SetLike.mem_coe, Submodule.zero_mem], Submodule.subset_span⟩
#align submodule.span_insert_zero Submodule.span_insert_zero
-- See also `span_preimage_eq` below.
theorem span_preimage_le (f : F) (s : Set M₂) :
span R (f ⁻¹' s) ≤ (span R₂ s).comap f := by
rw [span_le, comap_coe]
exact preimage_mono subset_span
#align submodule.span_preimage_le Submodule.span_preimage_le
alias _root_.LinearMap.span_preimage_le := Submodule.span_preimage_le
#align linear_map.span_preimage_le LinearMap.span_preimage_le
theorem closure_subset_span {s : Set M} : (AddSubmonoid.closure s : Set M) ⊆ span R s :=
(@AddSubmonoid.closure_le _ _ _ (span R s).toAddSubmonoid).mpr subset_span
#align submodule.closure_subset_span Submodule.closure_subset_span
theorem closure_le_toAddSubmonoid_span {s : Set M} :
AddSubmonoid.closure s ≤ (span R s).toAddSubmonoid :=
closure_subset_span
#align submodule.closure_le_to_add_submonoid_span Submodule.closure_le_toAddSubmonoid_span
@[simp]
theorem span_closure {s : Set M} : span R (AddSubmonoid.closure s : Set M) = span R s :=
le_antisymm (span_le.mpr closure_subset_span) (span_mono AddSubmonoid.subset_closure)
#align submodule.span_closure Submodule.span_closure
@[elab_as_elim]
theorem span_induction {p : M → Prop} (h : x ∈ span R s) (mem : ∀ x ∈ s, p x) (zero : p 0)
(add : ∀ x y, p x → p y → p (x + y)) (smul : ∀ (a : R) (x), p x → p (a • x)) : p x :=
((@span_le (p := ⟨⟨⟨p, by intros x y; exact add x y⟩, zero⟩, smul⟩)) s).2 mem h
#align submodule.span_induction Submodule.span_induction
theorem span_induction₂ {p : M → M → Prop} {a b : M} (ha : a ∈ Submodule.span R s)
(hb : b ∈ Submodule.span R s) (mem_mem : ∀ x ∈ s, ∀ y ∈ s, p x y)
(zero_left : ∀ y, p 0 y) (zero_right : ∀ x, p x 0)
(add_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ + x₂) y)
(add_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ + y₂))
(smul_left : ∀ (r : R) x y, p x y → p (r • x) y)
(smul_right : ∀ (r : R) x y, p x y → p x (r • y)) : p a b :=
Submodule.span_induction ha
(fun x hx => Submodule.span_induction hb (mem_mem x hx) (zero_right x) (add_right x) fun r =>
smul_right r x)
(zero_left b) (fun x₁ x₂ => add_left x₁ x₂ b) fun r x => smul_left r x b
@[elab_as_elim]
theorem span_induction' {p : ∀ x, x ∈ span R s → Prop}
(mem : ∀ (x) (h : x ∈ s), p x (subset_span h))
(zero : p 0 (Submodule.zero_mem _))
(add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›))
(smul : ∀ (a : R) (x hx), p x hx → p (a • x) (Submodule.smul_mem _ _ ‹_›)) {x}
(hx : x ∈ span R s) : p x hx := by
refine Exists.elim ?_ fun (hx : x ∈ span R s) (hc : p x hx) => hc
refine
span_induction hx (fun m hm => ⟨subset_span hm, mem m hm⟩) ⟨zero_mem _, zero⟩
(fun x y hx hy =>
Exists.elim hx fun hx' hx =>
Exists.elim hy fun hy' hy => ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩)
fun r x hx => Exists.elim hx fun hx' hx => ⟨smul_mem _ _ hx', smul r _ _ hx⟩
#align submodule.span_induction' Submodule.span_induction'
open AddSubmonoid in
theorem span_eq_closure {s : Set M} : (span R s).toAddSubmonoid = closure (@univ R • s) := by
refine le_antisymm
(fun x hx ↦ span_induction hx (fun x hx ↦ subset_closure ⟨1, trivial, x, hx, one_smul R x⟩)
(zero_mem _) (fun _ _ ↦ add_mem) fun r m hm ↦ closure_induction hm ?_ ?_ fun _ _ h h' ↦ ?_)
(closure_le.2 ?_)
· rintro _ ⟨r, -, m, hm, rfl⟩; exact smul_mem _ _ (subset_span hm)
· rintro _ ⟨r', -, m, hm, rfl⟩; exact subset_closure ⟨r * r', trivial, m, hm, mul_smul r r' m⟩
· rw [smul_zero]; apply zero_mem
· rw [smul_add]; exact add_mem h h'
@[elab_as_elim]
theorem closure_induction {p : M → Prop} (h : x ∈ span R s) (zero : p 0)
(add : ∀ x y, p x → p y → p (x + y)) (smul_mem : ∀ r : R, ∀ x ∈ s, p (r • x)) : p x := by
rw [← mem_toAddSubmonoid, span_eq_closure] at h
refine AddSubmonoid.closure_induction h ?_ zero add
rintro _ ⟨r, -, m, hm, rfl⟩
exact smul_mem r m hm
@[elab_as_elim]
theorem closure_induction' {p : ∀ x, x ∈ span R s → Prop}
(zero : p 0 (Submodule.zero_mem _))
(add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›))
(smul_mem : ∀ (r x) (h : x ∈ s), p (r • x) (Submodule.smul_mem _ _ <| subset_span h)) {x}
(hx : x ∈ span R s) : p x hx := by
refine Exists.elim ?_ fun (hx : x ∈ span R s) (hc : p x hx) ↦ hc
refine closure_induction hx ⟨zero_mem _, zero⟩
(fun x y hx hy ↦ Exists.elim hx fun hx' hx ↦
Exists.elim hy fun hy' hy ↦ ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩)
fun r x hx ↦ ⟨Submodule.smul_mem _ _ (subset_span hx), smul_mem r x hx⟩
@[simp]
theorem span_span_coe_preimage : span R (((↑) : span R s → M) ⁻¹' s) = ⊤ :=
eq_top_iff.2 fun x ↦ Subtype.recOn x fun x hx _ ↦ by
refine span_induction' (p := fun x hx ↦ (⟨x, hx⟩ : span R s) ∈ span R (Subtype.val ⁻¹' s))
(fun x' hx' ↦ subset_span hx') ?_ (fun x _ y _ ↦ ?_) (fun r x _ ↦ ?_) hx
· exact zero_mem _
· exact add_mem
· exact smul_mem _ _
#align submodule.span_span_coe_preimage Submodule.span_span_coe_preimage
@[simp]
lemma span_setOf_mem_eq_top :
span R {x : span R s | (x : M) ∈ s} = ⊤ :=
span_span_coe_preimage
theorem span_nat_eq_addSubmonoid_closure (s : Set M) :
(span ℕ s).toAddSubmonoid = AddSubmonoid.closure s := by
refine Eq.symm (AddSubmonoid.closure_eq_of_le subset_span ?_)
apply (OrderIso.to_galoisConnection (AddSubmonoid.toNatSubmodule (M := M)).symm).l_le
(a := span ℕ s) (b := AddSubmonoid.closure s)
rw [span_le]
exact AddSubmonoid.subset_closure
#align submodule.span_nat_eq_add_submonoid_closure Submodule.span_nat_eq_addSubmonoid_closure
@[simp]
theorem span_nat_eq (s : AddSubmonoid M) : (span ℕ (s : Set M)).toAddSubmonoid = s := by
rw [span_nat_eq_addSubmonoid_closure, s.closure_eq]
#align submodule.span_nat_eq Submodule.span_nat_eq
theorem span_int_eq_addSubgroup_closure {M : Type*} [AddCommGroup M] (s : Set M) :
(span ℤ s).toAddSubgroup = AddSubgroup.closure s :=
Eq.symm <|
AddSubgroup.closure_eq_of_le _ subset_span fun x hx =>
span_induction hx (fun x hx => AddSubgroup.subset_closure hx) (AddSubgroup.zero_mem _)
(fun _ _ => AddSubgroup.add_mem _) fun _ _ _ => AddSubgroup.zsmul_mem _ ‹_› _
#align submodule.span_int_eq_add_subgroup_closure Submodule.span_int_eq_addSubgroup_closure
@[simp]
theorem span_int_eq {M : Type*} [AddCommGroup M] (s : AddSubgroup M) :
(span ℤ (s : Set M)).toAddSubgroup = s := by rw [span_int_eq_addSubgroup_closure, s.closure_eq]
#align submodule.span_int_eq Submodule.span_int_eq
section
variable (R M)
protected def gi : GaloisInsertion (@span R M _ _ _) (↑) where
choice s _ := span R s
gc _ _ := span_le
le_l_u _ := subset_span
choice_eq _ _ := rfl
#align submodule.gi Submodule.gi
end
@[simp]
theorem span_empty : span R (∅ : Set M) = ⊥ :=
(Submodule.gi R M).gc.l_bot
#align submodule.span_empty Submodule.span_empty
@[simp]
theorem span_univ : span R (univ : Set M) = ⊤ :=
eq_top_iff.2 <| SetLike.le_def.2 <| subset_span
#align submodule.span_univ Submodule.span_univ
theorem span_union (s t : Set M) : span R (s ∪ t) = span R s ⊔ span R t :=
(Submodule.gi R M).gc.l_sup
#align submodule.span_union Submodule.span_union
theorem span_iUnion {ι} (s : ι → Set M) : span R (⋃ i, s i) = ⨆ i, span R (s i) :=
(Submodule.gi R M).gc.l_iSup
#align submodule.span_Union Submodule.span_iUnion
theorem span_iUnion₂ {ι} {κ : ι → Sort*} (s : ∀ i, κ i → Set M) :
span R (⋃ (i) (j), s i j) = ⨆ (i) (j), span R (s i j) :=
(Submodule.gi R M).gc.l_iSup₂
#align submodule.span_Union₂ Submodule.span_iUnion₂
theorem span_attach_biUnion [DecidableEq M] {α : Type*} (s : Finset α) (f : s → Finset M) :
span R (s.attach.biUnion f : Set M) = ⨆ x, span R (f x) := by simp [span_iUnion]
#align submodule.span_attach_bUnion Submodule.span_attach_biUnion
theorem sup_span : p ⊔ span R s = span R (p ∪ s) := by rw [Submodule.span_union, p.span_eq]
#align submodule.sup_span Submodule.sup_span
theorem span_sup : span R s ⊔ p = span R (s ∪ p) := by rw [Submodule.span_union, p.span_eq]
#align submodule.span_sup Submodule.span_sup
notation:1000
R " ∙ " x => span R (singleton x)
theorem span_eq_iSup_of_singleton_spans (s : Set M) : span R s = ⨆ x ∈ s, R ∙ x := by
simp only [← span_iUnion, Set.biUnion_of_singleton s]
#align submodule.span_eq_supr_of_singleton_spans Submodule.span_eq_iSup_of_singleton_spans
theorem span_range_eq_iSup {ι : Sort*} {v : ι → M} : span R (range v) = ⨆ i, R ∙ v i := by
rw [span_eq_iSup_of_singleton_spans, iSup_range]
#align submodule.span_range_eq_supr Submodule.span_range_eq_iSup
theorem span_smul_le (s : Set M) (r : R) : span R (r • s) ≤ span R s := by
rw [span_le]
rintro _ ⟨x, hx, rfl⟩
exact smul_mem (span R s) r (subset_span hx)
#align submodule.span_smul_le Submodule.span_smul_le
theorem subset_span_trans {U V W : Set M} (hUV : U ⊆ Submodule.span R V)
(hVW : V ⊆ Submodule.span R W) : U ⊆ Submodule.span R W :=
(Submodule.gi R M).gc.le_u_l_trans hUV hVW
#align submodule.subset_span_trans Submodule.subset_span_trans
theorem span_smul_eq_of_isUnit (s : Set M) (r : R) (hr : IsUnit r) : span R (r • s) = span R s := by
apply le_antisymm
· apply span_smul_le
· convert span_smul_le (r • s) ((hr.unit⁻¹ : _) : R)
rw [smul_smul]
erw [hr.unit.inv_val]
rw [one_smul]
#align submodule.span_smul_eq_of_is_unit Submodule.span_smul_eq_of_isUnit
@[simp]
theorem coe_iSup_of_directed {ι} [Nonempty ι] (S : ι → Submodule R M)
(H : Directed (· ≤ ·) S) : ((iSup S: Submodule R M) : Set M) = ⋃ i, S i :=
let s : Submodule R M :=
{ __ := AddSubmonoid.copy _ _ (AddSubmonoid.coe_iSup_of_directed H).symm
smul_mem' := fun r _ hx ↦ have ⟨i, hi⟩ := Set.mem_iUnion.mp hx
Set.mem_iUnion.mpr ⟨i, (S i).smul_mem' r hi⟩ }
have : iSup S = s := le_antisymm
(iSup_le fun i ↦ le_iSup (fun i ↦ (S i : Set M)) i) (Set.iUnion_subset fun _ ↦ le_iSup S _)
this.symm ▸ rfl
#align submodule.coe_supr_of_directed Submodule.coe_iSup_of_directed
@[simp]
theorem mem_iSup_of_directed {ι} [Nonempty ι] (S : ι → Submodule R M) (H : Directed (· ≤ ·) S) {x} :
x ∈ iSup S ↔ ∃ i, x ∈ S i := by
rw [← SetLike.mem_coe, coe_iSup_of_directed S H, mem_iUnion]
rfl
#align submodule.mem_supr_of_directed Submodule.mem_iSup_of_directed
theorem mem_sSup_of_directed {s : Set (Submodule R M)} {z} (hs : s.Nonempty)
(hdir : DirectedOn (· ≤ ·) s) : z ∈ sSup s ↔ ∃ y ∈ s, z ∈ y := by
have : Nonempty s := hs.to_subtype
simp only [sSup_eq_iSup', mem_iSup_of_directed _ hdir.directed_val, SetCoe.exists, Subtype.coe_mk,
exists_prop]
#align submodule.mem_Sup_of_directed Submodule.mem_sSup_of_directed
@[norm_cast, simp]
theorem coe_iSup_of_chain (a : ℕ →o Submodule R M) : (↑(⨆ k, a k) : Set M) = ⋃ k, (a k : Set M) :=
coe_iSup_of_directed a a.monotone.directed_le
#align submodule.coe_supr_of_chain Submodule.coe_iSup_of_chain
theorem coe_scott_continuous :
OmegaCompletePartialOrder.Continuous' ((↑) : Submodule R M → Set M) :=
⟨SetLike.coe_mono, coe_iSup_of_chain⟩
#align submodule.coe_scott_continuous Submodule.coe_scott_continuous
@[simp]
theorem mem_iSup_of_chain (a : ℕ →o Submodule R M) (m : M) : (m ∈ ⨆ k, a k) ↔ ∃ k, m ∈ a k :=
mem_iSup_of_directed a a.monotone.directed_le
#align submodule.mem_supr_of_chain Submodule.mem_iSup_of_chain
section
variable {p p'}
theorem mem_sup : x ∈ p ⊔ p' ↔ ∃ y ∈ p, ∃ z ∈ p', y + z = x :=
⟨fun h => by
rw [← span_eq p, ← span_eq p', ← span_union] at h
refine span_induction h ?_ ?_ ?_ ?_
· rintro y (h | h)
· exact ⟨y, h, 0, by simp, by simp⟩
· exact ⟨0, by simp, y, h, by simp⟩
· exact ⟨0, by simp, 0, by simp⟩
· rintro _ _ ⟨y₁, hy₁, z₁, hz₁, rfl⟩ ⟨y₂, hy₂, z₂, hz₂, rfl⟩
exact ⟨_, add_mem hy₁ hy₂, _, add_mem hz₁ hz₂, by
rw [add_assoc, add_assoc, ← add_assoc y₂, ← add_assoc z₁, add_comm y₂]⟩
· rintro a _ ⟨y, hy, z, hz, rfl⟩
exact ⟨_, smul_mem _ a hy, _, smul_mem _ a hz, by simp [smul_add]⟩, by
rintro ⟨y, hy, z, hz, rfl⟩
exact add_mem ((le_sup_left : p ≤ p ⊔ p') hy) ((le_sup_right : p' ≤ p ⊔ p') hz)⟩
#align submodule.mem_sup Submodule.mem_sup
theorem mem_sup' : x ∈ p ⊔ p' ↔ ∃ (y : p) (z : p'), (y : M) + z = x :=
mem_sup.trans <| by simp only [Subtype.exists, exists_prop]
#align submodule.mem_sup' Submodule.mem_sup'
lemma exists_add_eq_of_codisjoint (h : Codisjoint p p') (x : M) :
∃ y ∈ p, ∃ z ∈ p', y + z = x := by
suffices x ∈ p ⊔ p' by exact Submodule.mem_sup.mp this
simpa only [h.eq_top] using Submodule.mem_top
variable (p p')
theorem coe_sup : ↑(p ⊔ p') = (p + p' : Set M) := by
ext
rw [SetLike.mem_coe, mem_sup, Set.mem_add]
simp
#align submodule.coe_sup Submodule.coe_sup
theorem sup_toAddSubmonoid : (p ⊔ p').toAddSubmonoid = p.toAddSubmonoid ⊔ p'.toAddSubmonoid := by
ext x
rw [mem_toAddSubmonoid, mem_sup, AddSubmonoid.mem_sup]
rfl
#align submodule.sup_to_add_submonoid Submodule.sup_toAddSubmonoid
theorem sup_toAddSubgroup {R M : Type*} [Ring R] [AddCommGroup M] [Module R M]
(p p' : Submodule R M) : (p ⊔ p').toAddSubgroup = p.toAddSubgroup ⊔ p'.toAddSubgroup := by
ext x
rw [mem_toAddSubgroup, mem_sup, AddSubgroup.mem_sup]
rfl
#align submodule.sup_to_add_subgroup Submodule.sup_toAddSubgroup
end
theorem mem_span_singleton_self (x : M) : x ∈ R ∙ x :=
subset_span rfl
#align submodule.mem_span_singleton_self Submodule.mem_span_singleton_self
theorem nontrivial_span_singleton {x : M} (h : x ≠ 0) : Nontrivial (R ∙ x) :=
⟨by
use 0, ⟨x, Submodule.mem_span_singleton_self x⟩
intro H
rw [eq_comm, Submodule.mk_eq_zero] at H
exact h H⟩
#align submodule.nontrivial_span_singleton Submodule.nontrivial_span_singleton
theorem mem_span_singleton {y : M} : (x ∈ R ∙ y) ↔ ∃ a : R, a • y = x :=
⟨fun h => by
refine span_induction h ?_ ?_ ?_ ?_
· rintro y (rfl | ⟨⟨_⟩⟩)
exact ⟨1, by simp⟩
· exact ⟨0, by simp⟩
· rintro _ _ ⟨a, rfl⟩ ⟨b, rfl⟩
exact ⟨a + b, by simp [add_smul]⟩
· rintro a _ ⟨b, rfl⟩
exact ⟨a * b, by simp [smul_smul]⟩, by
rintro ⟨a, y, rfl⟩; exact smul_mem _ _ (subset_span <| by simp)⟩
#align submodule.mem_span_singleton Submodule.mem_span_singleton
theorem le_span_singleton_iff {s : Submodule R M} {v₀ : M} :
(s ≤ R ∙ v₀) ↔ ∀ v ∈ s, ∃ r : R, r • v₀ = v := by simp_rw [SetLike.le_def, mem_span_singleton]
#align submodule.le_span_singleton_iff Submodule.le_span_singleton_iff
variable (R)
| Mathlib/LinearAlgebra/Span.lean | 504 | 506 | theorem span_singleton_eq_top_iff (x : M) : (R ∙ x) = ⊤ ↔ ∀ v, ∃ r : R, r • x = v := by |
rw [eq_top_iff, le_span_singleton_iff]
tauto
|
import Mathlib.Topology.MetricSpace.Basic
#align_import topology.metric_space.infsep from "leanprover-community/mathlib"@"5316314b553dcf8c6716541851517c1a9715e22b"
variable {α β : Type*}
namespace Set
section Einfsep
open ENNReal
open Function
noncomputable def einfsep [EDist α] (s : Set α) : ℝ≥0∞ :=
⨅ (x ∈ s) (y ∈ s) (_ : x ≠ y), edist x y
#align set.einfsep Set.einfsep
section EDist
variable [EDist α] {x y : α} {s t : Set α}
theorem le_einfsep_iff {d} :
d ≤ s.einfsep ↔ ∀ x ∈ s, ∀ y ∈ s, x ≠ y → d ≤ edist x y := by
simp_rw [einfsep, le_iInf_iff]
#align set.le_einfsep_iff Set.le_einfsep_iff
theorem einfsep_zero : s.einfsep = 0 ↔ ∀ C > 0, ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < C := by
simp_rw [einfsep, ← _root_.bot_eq_zero, iInf_eq_bot, iInf_lt_iff, exists_prop]
#align set.einfsep_zero Set.einfsep_zero
theorem einfsep_pos : 0 < s.einfsep ↔ ∃ C > 0, ∀ x ∈ s, ∀ y ∈ s, x ≠ y → C ≤ edist x y := by
rw [pos_iff_ne_zero, Ne, einfsep_zero]
simp only [not_forall, not_exists, not_lt, exists_prop, not_and]
#align set.einfsep_pos Set.einfsep_pos
theorem einfsep_top :
s.einfsep = ∞ ↔ ∀ x ∈ s, ∀ y ∈ s, x ≠ y → edist x y = ∞ := by
simp_rw [einfsep, iInf_eq_top]
#align set.einfsep_top Set.einfsep_top
theorem einfsep_lt_top :
s.einfsep < ∞ ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < ∞ := by
simp_rw [einfsep, iInf_lt_iff, exists_prop]
#align set.einfsep_lt_top Set.einfsep_lt_top
theorem einfsep_ne_top :
s.einfsep ≠ ∞ ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y ≠ ∞ := by
simp_rw [← lt_top_iff_ne_top, einfsep_lt_top]
#align set.einfsep_ne_top Set.einfsep_ne_top
theorem einfsep_lt_iff {d} :
s.einfsep < d ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < d := by
simp_rw [einfsep, iInf_lt_iff, exists_prop]
#align set.einfsep_lt_iff Set.einfsep_lt_iff
theorem nontrivial_of_einfsep_lt_top (hs : s.einfsep < ∞) : s.Nontrivial := by
rcases einfsep_lt_top.1 hs with ⟨_, hx, _, hy, hxy, _⟩
exact ⟨_, hx, _, hy, hxy⟩
#align set.nontrivial_of_einfsep_lt_top Set.nontrivial_of_einfsep_lt_top
theorem nontrivial_of_einfsep_ne_top (hs : s.einfsep ≠ ∞) : s.Nontrivial :=
nontrivial_of_einfsep_lt_top (lt_top_iff_ne_top.mpr hs)
#align set.nontrivial_of_einfsep_ne_top Set.nontrivial_of_einfsep_ne_top
theorem Subsingleton.einfsep (hs : s.Subsingleton) : s.einfsep = ∞ := by
rw [einfsep_top]
exact fun _ hx _ hy hxy => (hxy <| hs hx hy).elim
#align set.subsingleton.einfsep Set.Subsingleton.einfsep
theorem le_einfsep_image_iff {d} {f : β → α} {s : Set β} : d ≤ einfsep (f '' s)
↔ ∀ x ∈ s, ∀ y ∈ s, f x ≠ f y → d ≤ edist (f x) (f y) := by
simp_rw [le_einfsep_iff, forall_mem_image]
#align set.le_einfsep_image_iff Set.le_einfsep_image_iff
theorem le_edist_of_le_einfsep {d x} (hx : x ∈ s) {y} (hy : y ∈ s) (hxy : x ≠ y)
(hd : d ≤ s.einfsep) : d ≤ edist x y :=
le_einfsep_iff.1 hd x hx y hy hxy
#align set.le_edist_of_le_einfsep Set.le_edist_of_le_einfsep
theorem einfsep_le_edist_of_mem {x} (hx : x ∈ s) {y} (hy : y ∈ s) (hxy : x ≠ y) :
s.einfsep ≤ edist x y :=
le_edist_of_le_einfsep hx hy hxy le_rfl
#align set.einfsep_le_edist_of_mem Set.einfsep_le_edist_of_mem
theorem einfsep_le_of_mem_of_edist_le {d x} (hx : x ∈ s) {y} (hy : y ∈ s) (hxy : x ≠ y)
(hxy' : edist x y ≤ d) : s.einfsep ≤ d :=
le_trans (einfsep_le_edist_of_mem hx hy hxy) hxy'
#align set.einfsep_le_of_mem_of_edist_le Set.einfsep_le_of_mem_of_edist_le
theorem le_einfsep {d} (h : ∀ x ∈ s, ∀ y ∈ s, x ≠ y → d ≤ edist x y) : d ≤ s.einfsep :=
le_einfsep_iff.2 h
#align set.le_einfsep Set.le_einfsep
@[simp]
theorem einfsep_empty : (∅ : Set α).einfsep = ∞ :=
subsingleton_empty.einfsep
#align set.einfsep_empty Set.einfsep_empty
@[simp]
theorem einfsep_singleton : ({x} : Set α).einfsep = ∞ :=
subsingleton_singleton.einfsep
#align set.einfsep_singleton Set.einfsep_singleton
theorem einfsep_iUnion_mem_option {ι : Type*} (o : Option ι) (s : ι → Set α) :
(⋃ i ∈ o, s i).einfsep = ⨅ i ∈ o, (s i).einfsep := by cases o <;> simp
#align set.einfsep_Union_mem_option Set.einfsep_iUnion_mem_option
theorem einfsep_anti (hst : s ⊆ t) : t.einfsep ≤ s.einfsep :=
le_einfsep fun _x hx _y hy => einfsep_le_edist_of_mem (hst hx) (hst hy)
#align set.einfsep_anti Set.einfsep_anti
theorem einfsep_insert_le : (insert x s).einfsep ≤ ⨅ (y ∈ s) (_ : x ≠ y), edist x y := by
simp_rw [le_iInf_iff]
exact fun _ hy hxy => einfsep_le_edist_of_mem (mem_insert _ _) (mem_insert_of_mem _ hy) hxy
#align set.einfsep_insert_le Set.einfsep_insert_le
theorem le_einfsep_pair : edist x y ⊓ edist y x ≤ ({x, y} : Set α).einfsep := by
simp_rw [le_einfsep_iff, inf_le_iff, mem_insert_iff, mem_singleton_iff]
rintro a (rfl | rfl) b (rfl | rfl) hab <;> (try simp only [le_refl, true_or, or_true]) <;>
contradiction
#align set.le_einfsep_pair Set.le_einfsep_pair
theorem einfsep_pair_le_left (hxy : x ≠ y) : ({x, y} : Set α).einfsep ≤ edist x y :=
einfsep_le_edist_of_mem (mem_insert _ _) (mem_insert_of_mem _ (mem_singleton _)) hxy
#align set.einfsep_pair_le_left Set.einfsep_pair_le_left
theorem einfsep_pair_le_right (hxy : x ≠ y) : ({x, y} : Set α).einfsep ≤ edist y x := by
rw [pair_comm]; exact einfsep_pair_le_left hxy.symm
#align set.einfsep_pair_le_right Set.einfsep_pair_le_right
theorem einfsep_pair_eq_inf (hxy : x ≠ y) : ({x, y} : Set α).einfsep = edist x y ⊓ edist y x :=
le_antisymm (le_inf (einfsep_pair_le_left hxy) (einfsep_pair_le_right hxy)) le_einfsep_pair
#align set.einfsep_pair_eq_inf Set.einfsep_pair_eq_inf
| Mathlib/Topology/MetricSpace/Infsep.lean | 163 | 166 | theorem einfsep_eq_iInf : s.einfsep = ⨅ d : s.offDiag, (uncurry edist) (d : α × α) := by |
refine eq_of_forall_le_iff fun _ => ?_
simp_rw [le_einfsep_iff, le_iInf_iff, imp_forall_iff, SetCoe.forall, mem_offDiag,
Prod.forall, uncurry_apply_pair, and_imp]
|
import Mathlib.NumberTheory.Cyclotomic.Discriminant
import Mathlib.RingTheory.Polynomial.Eisenstein.IsIntegral
import Mathlib.RingTheory.Ideal.Norm
#align_import number_theory.cyclotomic.rat from "leanprover-community/mathlib"@"b353176c24d96c23f0ce1cc63efc3f55019702d9"
universe u
open Algebra IsCyclotomicExtension Polynomial NumberField
open scoped Cyclotomic Nat
variable {p : ℕ+} {k : ℕ} {K : Type u} [Field K] [CharZero K] {ζ : K} [hp : Fact (p : ℕ).Prime]
namespace IsCyclotomicExtension.Rat
theorem discr_prime_pow_ne_two' [IsCyclotomicExtension {p ^ (k + 1)} ℚ K]
(hζ : IsPrimitiveRoot ζ ↑(p ^ (k + 1))) (hk : p ^ (k + 1) ≠ 2) :
discr ℚ (hζ.subOnePowerBasis ℚ).basis =
(-1) ^ ((p ^ (k + 1) : ℕ).totient / 2) * p ^ ((p : ℕ) ^ k * ((p - 1) * (k + 1) - 1)) := by
rw [← discr_prime_pow_ne_two hζ (cyclotomic.irreducible_rat (p ^ (k + 1)).pos) hk]
exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm
#align is_cyclotomic_extension.rat.discr_prime_pow_ne_two' IsCyclotomicExtension.Rat.discr_prime_pow_ne_two'
theorem discr_odd_prime' [IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) (hodd : p ≠ 2) :
discr ℚ (hζ.subOnePowerBasis ℚ).basis = (-1) ^ (((p : ℕ) - 1) / 2) * p ^ ((p : ℕ) - 2) := by
rw [← discr_odd_prime hζ (cyclotomic.irreducible_rat hp.out.pos) hodd]
exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm
#align is_cyclotomic_extension.rat.discr_odd_prime' IsCyclotomicExtension.Rat.discr_odd_prime'
| Mathlib/NumberTheory/Cyclotomic/Rat.lean | 55 | 59 | theorem discr_prime_pow' [IsCyclotomicExtension {p ^ k} ℚ K] (hζ : IsPrimitiveRoot ζ ↑(p ^ k)) :
discr ℚ (hζ.subOnePowerBasis ℚ).basis =
(-1) ^ ((p ^ k : ℕ).totient / 2) * p ^ ((p : ℕ) ^ (k - 1) * ((p - 1) * k - 1)) := by |
rw [← discr_prime_pow hζ (cyclotomic.irreducible_rat (p ^ k).pos)]
exact hζ.discr_zeta_eq_discr_zeta_sub_one.symm
|
import Mathlib.Order.Filter.Lift
import Mathlib.Topology.Defs.Filter
#align_import topology.basic from "leanprover-community/mathlib"@"e354e865255654389cc46e6032160238df2e0f40"
noncomputable section
open Set Filter
universe u v w x
def TopologicalSpace.ofClosed {X : Type u} (T : Set (Set X)) (empty_mem : ∅ ∈ T)
(sInter_mem : ∀ A, A ⊆ T → ⋂₀ A ∈ T)
(union_mem : ∀ A, A ∈ T → ∀ B, B ∈ T → A ∪ B ∈ T) : TopologicalSpace X where
IsOpen X := Xᶜ ∈ T
isOpen_univ := by simp [empty_mem]
isOpen_inter s t hs ht := by simpa only [compl_inter] using union_mem sᶜ hs tᶜ ht
isOpen_sUnion s hs := by
simp only [Set.compl_sUnion]
exact sInter_mem (compl '' s) fun z ⟨y, hy, hz⟩ => hz ▸ hs y hy
#align topological_space.of_closed TopologicalSpace.ofClosed
section TopologicalSpace
variable {X : Type u} {Y : Type v} {ι : Sort w} {α β : Type*}
{x : X} {s s₁ s₂ t : Set X} {p p₁ p₂ : X → Prop}
open Topology
lemma isOpen_mk {p h₁ h₂ h₃} : IsOpen[⟨p, h₁, h₂, h₃⟩] s ↔ p s := Iff.rfl
#align is_open_mk isOpen_mk
@[ext]
protected theorem TopologicalSpace.ext :
∀ {f g : TopologicalSpace X}, IsOpen[f] = IsOpen[g] → f = g
| ⟨_, _, _, _⟩, ⟨_, _, _, _⟩, rfl => rfl
#align topological_space_eq TopologicalSpace.ext
section
variable [TopologicalSpace X]
end
protected theorem TopologicalSpace.ext_iff {t t' : TopologicalSpace X} :
t = t' ↔ ∀ s, IsOpen[t] s ↔ IsOpen[t'] s :=
⟨fun h s => h ▸ Iff.rfl, fun h => by ext; exact h _⟩
#align topological_space_eq_iff TopologicalSpace.ext_iff
theorem isOpen_fold {t : TopologicalSpace X} : t.IsOpen s = IsOpen[t] s :=
rfl
#align is_open_fold isOpen_fold
variable [TopologicalSpace X]
theorem isOpen_iUnion {f : ι → Set X} (h : ∀ i, IsOpen (f i)) : IsOpen (⋃ i, f i) :=
isOpen_sUnion (forall_mem_range.2 h)
#align is_open_Union isOpen_iUnion
theorem isOpen_biUnion {s : Set α} {f : α → Set X} (h : ∀ i ∈ s, IsOpen (f i)) :
IsOpen (⋃ i ∈ s, f i) :=
isOpen_iUnion fun i => isOpen_iUnion fun hi => h i hi
#align is_open_bUnion isOpen_biUnion
theorem IsOpen.union (h₁ : IsOpen s₁) (h₂ : IsOpen s₂) : IsOpen (s₁ ∪ s₂) := by
rw [union_eq_iUnion]; exact isOpen_iUnion (Bool.forall_bool.2 ⟨h₂, h₁⟩)
#align is_open.union IsOpen.union
lemma isOpen_iff_of_cover {f : α → Set X} (ho : ∀ i, IsOpen (f i)) (hU : (⋃ i, f i) = univ) :
IsOpen s ↔ ∀ i, IsOpen (f i ∩ s) := by
refine ⟨fun h i ↦ (ho i).inter h, fun h ↦ ?_⟩
rw [← s.inter_univ, inter_comm, ← hU, iUnion_inter]
exact isOpen_iUnion fun i ↦ h i
@[simp] theorem isOpen_empty : IsOpen (∅ : Set X) := by
rw [← sUnion_empty]; exact isOpen_sUnion fun a => False.elim
#align is_open_empty isOpen_empty
theorem Set.Finite.isOpen_sInter {s : Set (Set X)} (hs : s.Finite) :
(∀ t ∈ s, IsOpen t) → IsOpen (⋂₀ s) :=
Finite.induction_on hs (fun _ => by rw [sInter_empty]; exact isOpen_univ) fun _ _ ih h => by
simp only [sInter_insert, forall_mem_insert] at h ⊢
exact h.1.inter (ih h.2)
#align is_open_sInter Set.Finite.isOpen_sInter
theorem Set.Finite.isOpen_biInter {s : Set α} {f : α → Set X} (hs : s.Finite)
(h : ∀ i ∈ s, IsOpen (f i)) :
IsOpen (⋂ i ∈ s, f i) :=
sInter_image f s ▸ (hs.image _).isOpen_sInter (forall_mem_image.2 h)
#align is_open_bInter Set.Finite.isOpen_biInter
theorem isOpen_iInter_of_finite [Finite ι] {s : ι → Set X} (h : ∀ i, IsOpen (s i)) :
IsOpen (⋂ i, s i) :=
(finite_range _).isOpen_sInter (forall_mem_range.2 h)
#align is_open_Inter isOpen_iInter_of_finite
theorem isOpen_biInter_finset {s : Finset α} {f : α → Set X} (h : ∀ i ∈ s, IsOpen (f i)) :
IsOpen (⋂ i ∈ s, f i) :=
s.finite_toSet.isOpen_biInter h
#align is_open_bInter_finset isOpen_biInter_finset
@[simp] -- Porting note: added `simp`
theorem isOpen_const {p : Prop} : IsOpen { _x : X | p } := by by_cases p <;> simp [*]
#align is_open_const isOpen_const
theorem IsOpen.and : IsOpen { x | p₁ x } → IsOpen { x | p₂ x } → IsOpen { x | p₁ x ∧ p₂ x } :=
IsOpen.inter
#align is_open.and IsOpen.and
@[simp] theorem isOpen_compl_iff : IsOpen sᶜ ↔ IsClosed s :=
⟨fun h => ⟨h⟩, fun h => h.isOpen_compl⟩
#align is_open_compl_iff isOpen_compl_iff
theorem TopologicalSpace.ext_iff_isClosed {t₁ t₂ : TopologicalSpace X} :
t₁ = t₂ ↔ ∀ s, IsClosed[t₁] s ↔ IsClosed[t₂] s := by
rw [TopologicalSpace.ext_iff, compl_surjective.forall]
simp only [@isOpen_compl_iff _ _ t₁, @isOpen_compl_iff _ _ t₂]
alias ⟨_, TopologicalSpace.ext_isClosed⟩ := TopologicalSpace.ext_iff_isClosed
-- Porting note (#10756): new lemma
theorem isClosed_const {p : Prop} : IsClosed { _x : X | p } := ⟨isOpen_const (p := ¬p)⟩
@[simp] theorem isClosed_empty : IsClosed (∅ : Set X) := isClosed_const
#align is_closed_empty isClosed_empty
@[simp] theorem isClosed_univ : IsClosed (univ : Set X) := isClosed_const
#align is_closed_univ isClosed_univ
theorem IsClosed.union : IsClosed s₁ → IsClosed s₂ → IsClosed (s₁ ∪ s₂) := by
simpa only [← isOpen_compl_iff, compl_union] using IsOpen.inter
#align is_closed.union IsClosed.union
theorem isClosed_sInter {s : Set (Set X)} : (∀ t ∈ s, IsClosed t) → IsClosed (⋂₀ s) := by
simpa only [← isOpen_compl_iff, compl_sInter, sUnion_image] using isOpen_biUnion
#align is_closed_sInter isClosed_sInter
theorem isClosed_iInter {f : ι → Set X} (h : ∀ i, IsClosed (f i)) : IsClosed (⋂ i, f i) :=
isClosed_sInter <| forall_mem_range.2 h
#align is_closed_Inter isClosed_iInter
theorem isClosed_biInter {s : Set α} {f : α → Set X} (h : ∀ i ∈ s, IsClosed (f i)) :
IsClosed (⋂ i ∈ s, f i) :=
isClosed_iInter fun i => isClosed_iInter <| h i
#align is_closed_bInter isClosed_biInter
@[simp]
theorem isClosed_compl_iff {s : Set X} : IsClosed sᶜ ↔ IsOpen s := by
rw [← isOpen_compl_iff, compl_compl]
#align is_closed_compl_iff isClosed_compl_iff
alias ⟨_, IsOpen.isClosed_compl⟩ := isClosed_compl_iff
#align is_open.is_closed_compl IsOpen.isClosed_compl
theorem IsOpen.sdiff (h₁ : IsOpen s) (h₂ : IsClosed t) : IsOpen (s \ t) :=
IsOpen.inter h₁ h₂.isOpen_compl
#align is_open.sdiff IsOpen.sdiff
theorem IsClosed.inter (h₁ : IsClosed s₁) (h₂ : IsClosed s₂) : IsClosed (s₁ ∩ s₂) := by
rw [← isOpen_compl_iff] at *
rw [compl_inter]
exact IsOpen.union h₁ h₂
#align is_closed.inter IsClosed.inter
theorem IsClosed.sdiff (h₁ : IsClosed s) (h₂ : IsOpen t) : IsClosed (s \ t) :=
IsClosed.inter h₁ (isClosed_compl_iff.mpr h₂)
#align is_closed.sdiff IsClosed.sdiff
theorem Set.Finite.isClosed_biUnion {s : Set α} {f : α → Set X} (hs : s.Finite)
(h : ∀ i ∈ s, IsClosed (f i)) :
IsClosed (⋃ i ∈ s, f i) := by
simp only [← isOpen_compl_iff, compl_iUnion] at *
exact hs.isOpen_biInter h
#align is_closed_bUnion Set.Finite.isClosed_biUnion
lemma isClosed_biUnion_finset {s : Finset α} {f : α → Set X} (h : ∀ i ∈ s, IsClosed (f i)) :
IsClosed (⋃ i ∈ s, f i) :=
s.finite_toSet.isClosed_biUnion h
theorem isClosed_iUnion_of_finite [Finite ι] {s : ι → Set X} (h : ∀ i, IsClosed (s i)) :
IsClosed (⋃ i, s i) := by
simp only [← isOpen_compl_iff, compl_iUnion] at *
exact isOpen_iInter_of_finite h
#align is_closed_Union isClosed_iUnion_of_finite
theorem isClosed_imp {p q : X → Prop} (hp : IsOpen { x | p x }) (hq : IsClosed { x | q x }) :
IsClosed { x | p x → q x } := by
simpa only [imp_iff_not_or] using hp.isClosed_compl.union hq
#align is_closed_imp isClosed_imp
theorem IsClosed.not : IsClosed { a | p a } → IsOpen { a | ¬p a } :=
isOpen_compl_iff.mpr
#align is_closed.not IsClosed.not
theorem mem_interior : x ∈ interior s ↔ ∃ t ⊆ s, IsOpen t ∧ x ∈ t := by
simp only [interior, mem_sUnion, mem_setOf_eq, and_assoc, and_left_comm]
#align mem_interior mem_interiorₓ
@[simp]
theorem isOpen_interior : IsOpen (interior s) :=
isOpen_sUnion fun _ => And.left
#align is_open_interior isOpen_interior
theorem interior_subset : interior s ⊆ s :=
sUnion_subset fun _ => And.right
#align interior_subset interior_subset
theorem interior_maximal (h₁ : t ⊆ s) (h₂ : IsOpen t) : t ⊆ interior s :=
subset_sUnion_of_mem ⟨h₂, h₁⟩
#align interior_maximal interior_maximal
theorem IsOpen.interior_eq (h : IsOpen s) : interior s = s :=
interior_subset.antisymm (interior_maximal (Subset.refl s) h)
#align is_open.interior_eq IsOpen.interior_eq
theorem interior_eq_iff_isOpen : interior s = s ↔ IsOpen s :=
⟨fun h => h ▸ isOpen_interior, IsOpen.interior_eq⟩
#align interior_eq_iff_is_open interior_eq_iff_isOpen
theorem subset_interior_iff_isOpen : s ⊆ interior s ↔ IsOpen s := by
simp only [interior_eq_iff_isOpen.symm, Subset.antisymm_iff, interior_subset, true_and]
#align subset_interior_iff_is_open subset_interior_iff_isOpen
theorem IsOpen.subset_interior_iff (h₁ : IsOpen s) : s ⊆ interior t ↔ s ⊆ t :=
⟨fun h => Subset.trans h interior_subset, fun h₂ => interior_maximal h₂ h₁⟩
#align is_open.subset_interior_iff IsOpen.subset_interior_iff
theorem subset_interior_iff : t ⊆ interior s ↔ ∃ U, IsOpen U ∧ t ⊆ U ∧ U ⊆ s :=
⟨fun h => ⟨interior s, isOpen_interior, h, interior_subset⟩, fun ⟨_U, hU, htU, hUs⟩ =>
htU.trans (interior_maximal hUs hU)⟩
#align subset_interior_iff subset_interior_iff
lemma interior_subset_iff : interior s ⊆ t ↔ ∀ U, IsOpen U → U ⊆ s → U ⊆ t := by
simp [interior]
@[mono, gcongr]
theorem interior_mono (h : s ⊆ t) : interior s ⊆ interior t :=
interior_maximal (Subset.trans interior_subset h) isOpen_interior
#align interior_mono interior_mono
@[simp]
theorem interior_empty : interior (∅ : Set X) = ∅ :=
isOpen_empty.interior_eq
#align interior_empty interior_empty
@[simp]
theorem interior_univ : interior (univ : Set X) = univ :=
isOpen_univ.interior_eq
#align interior_univ interior_univ
@[simp]
theorem interior_eq_univ : interior s = univ ↔ s = univ :=
⟨fun h => univ_subset_iff.mp <| h.symm.trans_le interior_subset, fun h => h.symm ▸ interior_univ⟩
#align interior_eq_univ interior_eq_univ
@[simp]
theorem interior_interior : interior (interior s) = interior s :=
isOpen_interior.interior_eq
#align interior_interior interior_interior
@[simp]
theorem interior_inter : interior (s ∩ t) = interior s ∩ interior t :=
(Monotone.map_inf_le (fun _ _ ↦ interior_mono) s t).antisymm <|
interior_maximal (inter_subset_inter interior_subset interior_subset) <|
isOpen_interior.inter isOpen_interior
#align interior_inter interior_inter
theorem Set.Finite.interior_biInter {ι : Type*} {s : Set ι} (hs : s.Finite) (f : ι → Set X) :
interior (⋂ i ∈ s, f i) = ⋂ i ∈ s, interior (f i) :=
hs.induction_on (by simp) <| by intros; simp [*]
theorem Set.Finite.interior_sInter {S : Set (Set X)} (hS : S.Finite) :
interior (⋂₀ S) = ⋂ s ∈ S, interior s := by
rw [sInter_eq_biInter, hS.interior_biInter]
@[simp]
theorem Finset.interior_iInter {ι : Type*} (s : Finset ι) (f : ι → Set X) :
interior (⋂ i ∈ s, f i) = ⋂ i ∈ s, interior (f i) :=
s.finite_toSet.interior_biInter f
#align finset.interior_Inter Finset.interior_iInter
@[simp]
theorem interior_iInter_of_finite [Finite ι] (f : ι → Set X) :
interior (⋂ i, f i) = ⋂ i, interior (f i) := by
rw [← sInter_range, (finite_range f).interior_sInter, biInter_range]
#align interior_Inter interior_iInter_of_finite
theorem interior_union_isClosed_of_interior_empty (h₁ : IsClosed s)
(h₂ : interior t = ∅) : interior (s ∪ t) = interior s :=
have : interior (s ∪ t) ⊆ s := fun x ⟨u, ⟨(hu₁ : IsOpen u), (hu₂ : u ⊆ s ∪ t)⟩, (hx₁ : x ∈ u)⟩ =>
by_contradiction fun hx₂ : x ∉ s =>
have : u \ s ⊆ t := fun x ⟨h₁, h₂⟩ => Or.resolve_left (hu₂ h₁) h₂
have : u \ s ⊆ interior t := by rwa [(IsOpen.sdiff hu₁ h₁).subset_interior_iff]
have : u \ s ⊆ ∅ := by rwa [h₂] at this
this ⟨hx₁, hx₂⟩
Subset.antisymm (interior_maximal this isOpen_interior) (interior_mono subset_union_left)
#align interior_union_is_closed_of_interior_empty interior_union_isClosed_of_interior_empty
theorem isOpen_iff_forall_mem_open : IsOpen s ↔ ∀ x ∈ s, ∃ t, t ⊆ s ∧ IsOpen t ∧ x ∈ t := by
rw [← subset_interior_iff_isOpen]
simp only [subset_def, mem_interior]
#align is_open_iff_forall_mem_open isOpen_iff_forall_mem_open
theorem interior_iInter_subset (s : ι → Set X) : interior (⋂ i, s i) ⊆ ⋂ i, interior (s i) :=
subset_iInter fun _ => interior_mono <| iInter_subset _ _
#align interior_Inter_subset interior_iInter_subset
theorem interior_iInter₂_subset (p : ι → Sort*) (s : ∀ i, p i → Set X) :
interior (⋂ (i) (j), s i j) ⊆ ⋂ (i) (j), interior (s i j) :=
(interior_iInter_subset _).trans <| iInter_mono fun _ => interior_iInter_subset _
#align interior_Inter₂_subset interior_iInter₂_subset
theorem interior_sInter_subset (S : Set (Set X)) : interior (⋂₀ S) ⊆ ⋂ s ∈ S, interior s :=
calc
interior (⋂₀ S) = interior (⋂ s ∈ S, s) := by rw [sInter_eq_biInter]
_ ⊆ ⋂ s ∈ S, interior s := interior_iInter₂_subset _ _
#align interior_sInter_subset interior_sInter_subset
theorem Filter.HasBasis.lift'_interior {l : Filter X} {p : ι → Prop} {s : ι → Set X}
(h : l.HasBasis p s) : (l.lift' interior).HasBasis p fun i => interior (s i) :=
h.lift' fun _ _ ↦ interior_mono
theorem Filter.lift'_interior_le (l : Filter X) : l.lift' interior ≤ l := fun _s hs ↦
mem_of_superset (mem_lift' hs) interior_subset
theorem Filter.HasBasis.lift'_interior_eq_self {l : Filter X} {p : ι → Prop} {s : ι → Set X}
(h : l.HasBasis p s) (ho : ∀ i, p i → IsOpen (s i)) : l.lift' interior = l :=
le_antisymm l.lift'_interior_le <| h.lift'_interior.ge_iff.2 fun i hi ↦ by
simpa only [(ho i hi).interior_eq] using h.mem_of_mem hi
@[simp]
theorem isClosed_closure : IsClosed (closure s) :=
isClosed_sInter fun _ => And.left
#align is_closed_closure isClosed_closure
theorem subset_closure : s ⊆ closure s :=
subset_sInter fun _ => And.right
#align subset_closure subset_closure
theorem not_mem_of_not_mem_closure {P : X} (hP : P ∉ closure s) : P ∉ s := fun h =>
hP (subset_closure h)
#align not_mem_of_not_mem_closure not_mem_of_not_mem_closure
theorem closure_minimal (h₁ : s ⊆ t) (h₂ : IsClosed t) : closure s ⊆ t :=
sInter_subset_of_mem ⟨h₂, h₁⟩
#align closure_minimal closure_minimal
theorem Disjoint.closure_left (hd : Disjoint s t) (ht : IsOpen t) :
Disjoint (closure s) t :=
disjoint_compl_left.mono_left <| closure_minimal hd.subset_compl_right ht.isClosed_compl
#align disjoint.closure_left Disjoint.closure_left
theorem Disjoint.closure_right (hd : Disjoint s t) (hs : IsOpen s) :
Disjoint s (closure t) :=
(hd.symm.closure_left hs).symm
#align disjoint.closure_right Disjoint.closure_right
theorem IsClosed.closure_eq (h : IsClosed s) : closure s = s :=
Subset.antisymm (closure_minimal (Subset.refl s) h) subset_closure
#align is_closed.closure_eq IsClosed.closure_eq
theorem IsClosed.closure_subset (hs : IsClosed s) : closure s ⊆ s :=
closure_minimal (Subset.refl _) hs
#align is_closed.closure_subset IsClosed.closure_subset
theorem IsClosed.closure_subset_iff (h₁ : IsClosed t) : closure s ⊆ t ↔ s ⊆ t :=
⟨Subset.trans subset_closure, fun h => closure_minimal h h₁⟩
#align is_closed.closure_subset_iff IsClosed.closure_subset_iff
theorem IsClosed.mem_iff_closure_subset (hs : IsClosed s) :
x ∈ s ↔ closure ({x} : Set X) ⊆ s :=
(hs.closure_subset_iff.trans Set.singleton_subset_iff).symm
#align is_closed.mem_iff_closure_subset IsClosed.mem_iff_closure_subset
@[mono, gcongr]
theorem closure_mono (h : s ⊆ t) : closure s ⊆ closure t :=
closure_minimal (Subset.trans h subset_closure) isClosed_closure
#align closure_mono closure_mono
theorem monotone_closure (X : Type*) [TopologicalSpace X] : Monotone (@closure X _) := fun _ _ =>
closure_mono
#align monotone_closure monotone_closure
theorem diff_subset_closure_iff : s \ t ⊆ closure t ↔ s ⊆ closure t := by
rw [diff_subset_iff, union_eq_self_of_subset_left subset_closure]
#align diff_subset_closure_iff diff_subset_closure_iff
theorem closure_inter_subset_inter_closure (s t : Set X) :
closure (s ∩ t) ⊆ closure s ∩ closure t :=
(monotone_closure X).map_inf_le s t
#align closure_inter_subset_inter_closure closure_inter_subset_inter_closure
theorem isClosed_of_closure_subset (h : closure s ⊆ s) : IsClosed s := by
rw [subset_closure.antisymm h]; exact isClosed_closure
#align is_closed_of_closure_subset isClosed_of_closure_subset
theorem closure_eq_iff_isClosed : closure s = s ↔ IsClosed s :=
⟨fun h => h ▸ isClosed_closure, IsClosed.closure_eq⟩
#align closure_eq_iff_is_closed closure_eq_iff_isClosed
theorem closure_subset_iff_isClosed : closure s ⊆ s ↔ IsClosed s :=
⟨isClosed_of_closure_subset, IsClosed.closure_subset⟩
#align closure_subset_iff_is_closed closure_subset_iff_isClosed
@[simp]
theorem closure_empty : closure (∅ : Set X) = ∅ :=
isClosed_empty.closure_eq
#align closure_empty closure_empty
@[simp]
theorem closure_empty_iff (s : Set X) : closure s = ∅ ↔ s = ∅ :=
⟨subset_eq_empty subset_closure, fun h => h.symm ▸ closure_empty⟩
#align closure_empty_iff closure_empty_iff
@[simp]
theorem closure_nonempty_iff : (closure s).Nonempty ↔ s.Nonempty := by
simp only [nonempty_iff_ne_empty, Ne, closure_empty_iff]
#align closure_nonempty_iff closure_nonempty_iff
alias ⟨Set.Nonempty.of_closure, Set.Nonempty.closure⟩ := closure_nonempty_iff
#align set.nonempty.of_closure Set.Nonempty.of_closure
#align set.nonempty.closure Set.Nonempty.closure
@[simp]
theorem closure_univ : closure (univ : Set X) = univ :=
isClosed_univ.closure_eq
#align closure_univ closure_univ
@[simp]
theorem closure_closure : closure (closure s) = closure s :=
isClosed_closure.closure_eq
#align closure_closure closure_closure
| Mathlib/Topology/Basic.lean | 492 | 494 | theorem closure_eq_compl_interior_compl : closure s = (interior sᶜ)ᶜ := by |
rw [interior, closure, compl_sUnion, compl_image_set_of]
simp only [compl_subset_compl, isOpen_compl_iff]
|
import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor
import Mathlib.CategoryTheory.Monoidal.Functor
#align_import category_theory.monoidal.preadditive from "leanprover-community/mathlib"@"986c4d5761f938b2e1c43c01f001b6d9d88c2055"
noncomputable section
open scoped Classical
namespace CategoryTheory
open CategoryTheory.Limits
open CategoryTheory.MonoidalCategory
variable (C : Type*) [Category C] [Preadditive C] [MonoidalCategory C]
class MonoidalPreadditive : Prop where
whiskerLeft_zero : ∀ {X Y Z : C}, X ◁ (0 : Y ⟶ Z) = 0 := by aesop_cat
zero_whiskerRight : ∀ {X Y Z : C}, (0 : Y ⟶ Z) ▷ X = 0 := by aesop_cat
whiskerLeft_add : ∀ {X Y Z : C} (f g : Y ⟶ Z), X ◁ (f + g) = X ◁ f + X ◁ g := by aesop_cat
add_whiskerRight : ∀ {X Y Z : C} (f g : Y ⟶ Z), (f + g) ▷ X = f ▷ X + g ▷ X := by aesop_cat
#align category_theory.monoidal_preadditive CategoryTheory.MonoidalPreadditive
attribute [simp] MonoidalPreadditive.whiskerLeft_zero MonoidalPreadditive.zero_whiskerRight
attribute [simp] MonoidalPreadditive.whiskerLeft_add MonoidalPreadditive.add_whiskerRight
variable {C}
variable [MonoidalPreadditive C]
instance tensorLeft_additive (X : C) : (tensorLeft X).Additive where
#align category_theory.tensor_left_additive CategoryTheory.tensorLeft_additive
instance tensorRight_additive (X : C) : (tensorRight X).Additive where
#align category_theory.tensor_right_additive CategoryTheory.tensorRight_additive
instance tensoringLeft_additive (X : C) : ((tensoringLeft C).obj X).Additive where
#align category_theory.tensoring_left_additive CategoryTheory.tensoringLeft_additive
instance tensoringRight_additive (X : C) : ((tensoringRight C).obj X).Additive where
#align category_theory.tensoring_right_additive CategoryTheory.tensoringRight_additive
theorem monoidalPreadditive_of_faithful {D} [Category D] [Preadditive D] [MonoidalCategory D]
(F : MonoidalFunctor D C) [F.Faithful] [F.Additive] :
MonoidalPreadditive D :=
{ whiskerLeft_zero := by
intros
apply F.toFunctor.map_injective
simp [F.map_whiskerLeft]
zero_whiskerRight := by
intros
apply F.toFunctor.map_injective
simp [F.map_whiskerRight]
whiskerLeft_add := by
intros
apply F.toFunctor.map_injective
simp only [F.map_whiskerLeft, Functor.map_add, Preadditive.comp_add, Preadditive.add_comp,
MonoidalPreadditive.whiskerLeft_add]
add_whiskerRight := by
intros
apply F.toFunctor.map_injective
simp only [F.map_whiskerRight, Functor.map_add, Preadditive.comp_add, Preadditive.add_comp,
MonoidalPreadditive.add_whiskerRight] }
#align category_theory.monoidal_preadditive_of_faithful CategoryTheory.monoidalPreadditive_of_faithful
theorem whiskerLeft_sum (P : C) {Q R : C} {J : Type*} (s : Finset J) (g : J → (Q ⟶ R)) :
P ◁ ∑ j ∈ s, g j = ∑ j ∈ s, P ◁ g j :=
map_sum ((tensoringLeft C).obj P).mapAddHom g s
theorem sum_whiskerRight {Q R : C} {J : Type*} (s : Finset J) (g : J → (Q ⟶ R)) (P : C) :
(∑ j ∈ s, g j) ▷ P = ∑ j ∈ s, g j ▷ P :=
map_sum ((tensoringRight C).obj P).mapAddHom g s
theorem tensor_sum {P Q R S : C} {J : Type*} (s : Finset J) (f : P ⟶ Q) (g : J → (R ⟶ S)) :
(f ⊗ ∑ j ∈ s, g j) = ∑ j ∈ s, f ⊗ g j := by
simp only [tensorHom_def, whiskerLeft_sum, Preadditive.comp_sum]
#align category_theory.tensor_sum CategoryTheory.tensor_sum
theorem sum_tensor {P Q R S : C} {J : Type*} (s : Finset J) (f : P ⟶ Q) (g : J → (R ⟶ S)) :
(∑ j ∈ s, g j) ⊗ f = ∑ j ∈ s, g j ⊗ f := by
simp only [tensorHom_def, sum_whiskerRight, Preadditive.sum_comp]
#align category_theory.sum_tensor CategoryTheory.sum_tensor
-- In a closed monoidal category, this would hold because
-- `tensorLeft X` is a left adjoint and hence preserves all colimits.
-- In any case it is true in any preadditive category.
instance (X : C) : PreservesFiniteBiproducts (tensorLeft X) where
preserves {J} :=
{ preserves := fun {f} =>
{ preserves := fun {b} i => isBilimitOfTotal _ (by
dsimp
simp_rw [← id_tensorHom]
simp only [← tensor_comp, Category.comp_id, ← tensor_sum, ← tensor_id,
IsBilimit.total i]) } }
instance (X : C) : PreservesFiniteBiproducts (tensorRight X) where
preserves {J} :=
{ preserves := fun {f} =>
{ preserves := fun {b} i => isBilimitOfTotal _ (by
dsimp
simp_rw [← tensorHom_id]
simp only [← tensor_comp, Category.comp_id, ← sum_tensor, ← tensor_id,
IsBilimit.total i]) } }
variable [HasFiniteBiproducts C]
def leftDistributor {J : Type} [Fintype J] (X : C) (f : J → C) : X ⊗ ⨁ f ≅ ⨁ fun j => X ⊗ f j :=
(tensorLeft X).mapBiproduct f
#align category_theory.left_distributor CategoryTheory.leftDistributor
theorem leftDistributor_hom {J : Type} [Fintype J] (X : C) (f : J → C) :
(leftDistributor X f).hom =
∑ j : J, (X ◁ biproduct.π f j) ≫ biproduct.ι (fun j => X ⊗ f j) j := by
ext
dsimp [leftDistributor, Functor.mapBiproduct, Functor.mapBicone]
erw [biproduct.lift_π]
simp only [Preadditive.sum_comp, Category.assoc, biproduct.ι_π, comp_dite, comp_zero,
Finset.sum_dite_eq', Finset.mem_univ, ite_true, eqToHom_refl, Category.comp_id]
#align category_theory.left_distributor_hom CategoryTheory.leftDistributor_hom
theorem leftDistributor_inv {J : Type} [Fintype J] (X : C) (f : J → C) :
(leftDistributor X f).inv = ∑ j : J, biproduct.π _ j ≫ (X ◁ biproduct.ι f j) := by
ext
dsimp [leftDistributor, Functor.mapBiproduct, Functor.mapBicone]
simp only [Preadditive.comp_sum, biproduct.ι_π_assoc, dite_comp, zero_comp,
Finset.sum_dite_eq, Finset.mem_univ, ite_true, eqToHom_refl, Category.id_comp,
biproduct.ι_desc]
#align category_theory.left_distributor_inv CategoryTheory.leftDistributor_inv
@[reassoc (attr := simp)]
theorem leftDistributor_hom_comp_biproduct_π {J : Type} [Fintype J] (X : C) (f : J → C) (j : J) :
(leftDistributor X f).hom ≫ biproduct.π _ j = X ◁ biproduct.π _ j := by
simp [leftDistributor_hom, Preadditive.sum_comp, biproduct.ι_π, comp_dite]
@[reassoc (attr := simp)]
theorem biproduct_ι_comp_leftDistributor_hom {J : Type} [Fintype J] (X : C) (f : J → C) (j : J) :
(X ◁ biproduct.ι _ j) ≫ (leftDistributor X f).hom = biproduct.ι (fun j => X ⊗ f j) j := by
simp [leftDistributor_hom, Preadditive.comp_sum, ← MonoidalCategory.whiskerLeft_comp_assoc,
biproduct.ι_π, whiskerLeft_dite, dite_comp]
@[reassoc (attr := simp)]
theorem leftDistributor_inv_comp_biproduct_π {J : Type} [Fintype J] (X : C) (f : J → C) (j : J) :
(leftDistributor X f).inv ≫ (X ◁ biproduct.π _ j) = biproduct.π _ j := by
simp [leftDistributor_inv, Preadditive.sum_comp, ← MonoidalCategory.whiskerLeft_comp,
biproduct.ι_π, whiskerLeft_dite, comp_dite]
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Monoidal/Preadditive.lean | 188 | 190 | theorem biproduct_ι_comp_leftDistributor_inv {J : Type} [Fintype J] (X : C) (f : J → C) (j : J) :
biproduct.ι _ j ≫ (leftDistributor X f).inv = X ◁ biproduct.ι _ j := by |
simp [leftDistributor_inv, Preadditive.comp_sum, ← id_tensor_comp, biproduct.ι_π_assoc, dite_comp]
|
import Mathlib.Data.Countable.Basic
import Mathlib.Data.Fin.VecNotation
import Mathlib.Order.Disjointed
import Mathlib.MeasureTheory.OuterMeasure.Defs
#align_import measure_theory.measure.outer_measure from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55"
noncomputable section
open Set Function Filter
open scoped Classical NNReal Topology ENNReal
namespace MeasureTheory
section OuterMeasureClass
variable {α ι F : Type*} [FunLike F (Set α) ℝ≥0∞] [OuterMeasureClass F α]
{μ : F} {s t : Set α}
@[simp]
theorem measure_empty : μ ∅ = 0 := OuterMeasureClass.measure_empty μ
#align measure_theory.measure_empty MeasureTheory.measure_empty
@[mono, gcongr]
theorem measure_mono (h : s ⊆ t) : μ s ≤ μ t :=
OuterMeasureClass.measure_mono μ h
#align measure_theory.measure_mono MeasureTheory.measure_mono
theorem measure_mono_null (h : s ⊆ t) (ht : μ t = 0) : μ s = 0 :=
eq_bot_mono (measure_mono h) ht
#align measure_theory.measure_mono_null MeasureTheory.measure_mono_null
theorem measure_pos_of_superset (h : s ⊆ t) (hs : μ s ≠ 0) : 0 < μ t :=
hs.bot_lt.trans_le (measure_mono h)
| Mathlib/MeasureTheory/OuterMeasure/Basic.lean | 63 | 69 | theorem measure_iUnion_le [Countable ι] (s : ι → Set α) : μ (⋃ i, s i) ≤ ∑' i, μ (s i) := by |
refine rel_iSup_tsum μ measure_empty (· ≤ ·) (fun t ↦ ?_) _
calc
μ (⋃ i, t i) = μ (⋃ i, disjointed t i) := by rw [iUnion_disjointed]
_ ≤ ∑' i, μ (disjointed t i) :=
OuterMeasureClass.measure_iUnion_nat_le _ _ (disjoint_disjointed _)
_ ≤ ∑' i, μ (t i) := by gcongr; apply disjointed_subset
|
import Mathlib.Algebra.Category.GroupCat.EquivalenceGroupAddGroup
import Mathlib.GroupTheory.QuotientGroup
#align_import algebra.category.Group.epi_mono from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
noncomputable section
open scoped Pointwise
universe u v
namespace MonoidHom
open QuotientGroup
variable {A : Type u} {B : Type v}
section
variable [Group A] [Group B]
@[to_additive]
| Mathlib/Algebra/Category/GroupCat/EpiMono.lean | 35 | 36 | theorem ker_eq_bot_of_cancel {f : A →* B} (h : ∀ u v : f.ker →* A, f.comp u = f.comp v → u = v) :
f.ker = ⊥ := by | simpa using _root_.congr_arg range (h f.ker.subtype 1 (by aesop_cat))
|
import Mathlib.Topology.Bases
import Mathlib.Order.Filter.CountableInter
import Mathlib.Topology.Compactness.SigmaCompact
open Set Filter Topology TopologicalSpace
universe u v
variable {X : Type u} {Y : Type v} {ι : Type*}
variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X}
section Lindelof
def IsLindelof (s : Set X) :=
∀ ⦃f⦄ [NeBot f] [CountableInterFilter f], f ≤ 𝓟 s → ∃ x ∈ s, ClusterPt x f
theorem IsLindelof.compl_mem_sets (hs : IsLindelof s) {f : Filter X} [CountableInterFilter f]
(hf : ∀ x ∈ s, sᶜ ∈ 𝓝 x ⊓ f) : sᶜ ∈ f := by
contrapose! hf
simp only [not_mem_iff_inf_principal_compl, compl_compl, inf_assoc] at hf ⊢
exact hs inf_le_right
theorem IsLindelof.compl_mem_sets_of_nhdsWithin (hs : IsLindelof s) {f : Filter X}
[CountableInterFilter f] (hf : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, tᶜ ∈ f) : sᶜ ∈ f := by
refine hs.compl_mem_sets fun x hx ↦ ?_
rw [← disjoint_principal_right, disjoint_right_comm, (basis_sets _).disjoint_iff_left]
exact hf x hx
@[elab_as_elim]
theorem IsLindelof.induction_on (hs : IsLindelof s) {p : Set X → Prop}
(hmono : ∀ ⦃s t⦄, s ⊆ t → p t → p s)
(hcountable_union : ∀ (S : Set (Set X)), S.Countable → (∀ s ∈ S, p s) → p (⋃₀ S))
(hnhds : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, p t) : p s := by
let f : Filter X := ofCountableUnion p hcountable_union (fun t ht _ hsub ↦ hmono hsub ht)
have : sᶜ ∈ f := hs.compl_mem_sets_of_nhdsWithin (by simpa [f] using hnhds)
rwa [← compl_compl s]
theorem IsLindelof.inter_right (hs : IsLindelof s) (ht : IsClosed t) : IsLindelof (s ∩ t) := by
intro f hnf _ hstf
rw [← inf_principal, le_inf_iff] at hstf
obtain ⟨x, hsx, hx⟩ : ∃ x ∈ s, ClusterPt x f := hs hstf.1
have hxt : x ∈ t := ht.mem_of_nhdsWithin_neBot <| hx.mono hstf.2
exact ⟨x, ⟨hsx, hxt⟩, hx⟩
theorem IsLindelof.inter_left (ht : IsLindelof t) (hs : IsClosed s) : IsLindelof (s ∩ t) :=
inter_comm t s ▸ ht.inter_right hs
theorem IsLindelof.diff (hs : IsLindelof s) (ht : IsOpen t) : IsLindelof (s \ t) :=
hs.inter_right (isClosed_compl_iff.mpr ht)
theorem IsLindelof.of_isClosed_subset (hs : IsLindelof s) (ht : IsClosed t) (h : t ⊆ s) :
IsLindelof t := inter_eq_self_of_subset_right h ▸ hs.inter_right ht
theorem IsLindelof.image_of_continuousOn {f : X → Y} (hs : IsLindelof s) (hf : ContinuousOn f s) :
IsLindelof (f '' s) := by
intro l lne _ ls
have : NeBot (l.comap f ⊓ 𝓟 s) :=
comap_inf_principal_neBot_of_image_mem lne (le_principal_iff.1 ls)
obtain ⟨x, hxs, hx⟩ : ∃ x ∈ s, ClusterPt x (l.comap f ⊓ 𝓟 s) := @hs _ this _ inf_le_right
haveI := hx.neBot
use f x, mem_image_of_mem f hxs
have : Tendsto f (𝓝 x ⊓ (comap f l ⊓ 𝓟 s)) (𝓝 (f x) ⊓ l) := by
convert (hf x hxs).inf (@tendsto_comap _ _ f l) using 1
rw [nhdsWithin]
ac_rfl
exact this.neBot
theorem IsLindelof.image {f : X → Y} (hs : IsLindelof s) (hf : Continuous f) :
IsLindelof (f '' s) := hs.image_of_continuousOn hf.continuousOn
theorem IsLindelof.adherence_nhdset {f : Filter X} [CountableInterFilter f] (hs : IsLindelof s)
(hf₂ : f ≤ 𝓟 s) (ht₁ : IsOpen t) (ht₂ : ∀ x ∈ s, ClusterPt x f → x ∈ t) : t ∈ f :=
(eq_or_neBot _).casesOn mem_of_eq_bot fun _ ↦
let ⟨x, hx, hfx⟩ := @hs (f ⊓ 𝓟 tᶜ) _ _ <| inf_le_of_left_le hf₂
have : x ∈ t := ht₂ x hx hfx.of_inf_left
have : tᶜ ∩ t ∈ 𝓝[tᶜ] x := inter_mem_nhdsWithin _ (ht₁.mem_nhds this)
have A : 𝓝[tᶜ] x = ⊥ := empty_mem_iff_bot.1 <| compl_inter_self t ▸ this
have : 𝓝[tᶜ] x ≠ ⊥ := hfx.of_inf_right.ne
absurd A this
theorem IsLindelof.elim_countable_subcover {ι : Type v} (hs : IsLindelof s) (U : ι → Set X)
(hUo : ∀ i, IsOpen (U i)) (hsU : s ⊆ ⋃ i, U i) :
∃ r : Set ι, r.Countable ∧ (s ⊆ ⋃ i ∈ r, U i) := by
have hmono : ∀ ⦃s t : Set X⦄, s ⊆ t → (∃ r : Set ι, r.Countable ∧ t ⊆ ⋃ i ∈ r, U i)
→ (∃ r : Set ι, r.Countable ∧ s ⊆ ⋃ i ∈ r, U i) := by
intro _ _ hst ⟨r, ⟨hrcountable, hsub⟩⟩
exact ⟨r, hrcountable, Subset.trans hst hsub⟩
have hcountable_union : ∀ (S : Set (Set X)), S.Countable
→ (∀ s ∈ S, ∃ r : Set ι, r.Countable ∧ (s ⊆ ⋃ i ∈ r, U i))
→ ∃ r : Set ι, r.Countable ∧ (⋃₀ S ⊆ ⋃ i ∈ r, U i) := by
intro S hS hsr
choose! r hr using hsr
refine ⟨⋃ s ∈ S, r s, hS.biUnion_iff.mpr (fun s hs ↦ (hr s hs).1), ?_⟩
refine sUnion_subset ?h.right.h
simp only [mem_iUnion, exists_prop, iUnion_exists, biUnion_and']
exact fun i is x hx ↦ mem_biUnion is ((hr i is).2 hx)
have h_nhds : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, ∃ r : Set ι, r.Countable ∧ (t ⊆ ⋃ i ∈ r, U i) := by
intro x hx
let ⟨i, hi⟩ := mem_iUnion.1 (hsU hx)
refine ⟨U i, mem_nhdsWithin_of_mem_nhds ((hUo i).mem_nhds hi), {i}, by simp, ?_⟩
simp only [mem_singleton_iff, iUnion_iUnion_eq_left]
exact Subset.refl _
exact hs.induction_on hmono hcountable_union h_nhds
theorem IsLindelof.elim_nhds_subcover' (hs : IsLindelof s) (U : ∀ x ∈ s, Set X)
(hU : ∀ x (hx : x ∈ s), U x ‹x ∈ s› ∈ 𝓝 x) :
∃ t : Set s, t.Countable ∧ s ⊆ ⋃ x ∈ t, U (x : s) x.2 := by
have := hs.elim_countable_subcover (fun x : s ↦ interior (U x x.2)) (fun _ ↦ isOpen_interior)
fun x hx ↦
mem_iUnion.2 ⟨⟨x, hx⟩, mem_interior_iff_mem_nhds.2 <| hU _ _⟩
rcases this with ⟨r, ⟨hr, hs⟩⟩
use r, hr
apply Subset.trans hs
apply iUnion₂_subset
intro i hi
apply Subset.trans interior_subset
exact subset_iUnion_of_subset i (subset_iUnion_of_subset hi (Subset.refl _))
theorem IsLindelof.elim_nhds_subcover (hs : IsLindelof s) (U : X → Set X)
(hU : ∀ x ∈ s, U x ∈ 𝓝 x) :
∃ t : Set X, t.Countable ∧ (∀ x ∈ t, x ∈ s) ∧ s ⊆ ⋃ x ∈ t, U x := by
let ⟨t, ⟨htc, htsub⟩⟩ := hs.elim_nhds_subcover' (fun x _ ↦ U x) hU
refine ⟨↑t, Countable.image htc Subtype.val, ?_⟩
constructor
· intro _
simp only [mem_image, Subtype.exists, exists_and_right, exists_eq_right, forall_exists_index]
tauto
· have : ⋃ x ∈ t, U ↑x = ⋃ x ∈ Subtype.val '' t, U x := biUnion_image.symm
rwa [← this]
| Mathlib/Topology/Compactness/Lindelof.lean | 182 | 192 | theorem IsLindelof.disjoint_nhdsSet_left {l : Filter X} [CountableInterFilter l]
(hs : IsLindelof s) :
Disjoint (𝓝ˢ s) l ↔ ∀ x ∈ s, Disjoint (𝓝 x) l := by |
refine ⟨fun h x hx ↦ h.mono_left <| nhds_le_nhdsSet hx, fun H ↦ ?_⟩
choose! U hxU hUl using fun x hx ↦ (nhds_basis_opens x).disjoint_iff_left.1 (H x hx)
choose hxU hUo using hxU
rcases hs.elim_nhds_subcover U fun x hx ↦ (hUo x hx).mem_nhds (hxU x hx) with ⟨t, htc, hts, hst⟩
refine (hasBasis_nhdsSet _).disjoint_iff_left.2
⟨⋃ x ∈ t, U x, ⟨isOpen_biUnion fun x hx ↦ hUo x (hts x hx), hst⟩, ?_⟩
rw [compl_iUnion₂]
exact (countable_bInter_mem htc).mpr (fun i hi ↦ hUl _ (hts _ hi))
|
import Mathlib.Topology.Algebra.Module.WeakDual
import Mathlib.MeasureTheory.Integral.BoundedContinuousFunction
import Mathlib.MeasureTheory.Measure.HasOuterApproxClosed
#align_import measure_theory.measure.finite_measure from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
noncomputable section
open MeasureTheory
open Set
open Filter
open BoundedContinuousFunction
open scoped Topology ENNReal NNReal BoundedContinuousFunction
namespace MeasureTheory
namespace FiniteMeasure
section FiniteMeasure
variable {Ω : Type*} [MeasurableSpace Ω]
def _root_.MeasureTheory.FiniteMeasure (Ω : Type*) [MeasurableSpace Ω] : Type _ :=
{ μ : Measure Ω // IsFiniteMeasure μ }
#align measure_theory.finite_measure MeasureTheory.FiniteMeasure
-- Porting note: as with other subtype synonyms (e.g., `ℝ≥0`, we need a new function for the
-- coercion instead of relying on `Subtype.val`.
@[coe]
def toMeasure : FiniteMeasure Ω → Measure Ω := Subtype.val
instance instCoe : Coe (FiniteMeasure Ω) (MeasureTheory.Measure Ω) where
coe := toMeasure
instance isFiniteMeasure (μ : FiniteMeasure Ω) : IsFiniteMeasure (μ : Measure Ω) :=
μ.prop
#align measure_theory.finite_measure.is_finite_measure MeasureTheory.FiniteMeasure.isFiniteMeasure
@[simp]
theorem val_eq_toMeasure (ν : FiniteMeasure Ω) : ν.val = (ν : Measure Ω) :=
rfl
#align measure_theory.finite_measure.val_eq_to_measure MeasureTheory.FiniteMeasure.val_eq_toMeasure
theorem toMeasure_injective : Function.Injective ((↑) : FiniteMeasure Ω → Measure Ω) :=
Subtype.coe_injective
#align measure_theory.finite_measure.coe_injective MeasureTheory.FiniteMeasure.toMeasure_injective
instance instFunLike : FunLike (FiniteMeasure Ω) (Set Ω) ℝ≥0 where
coe μ s := ((μ : Measure Ω) s).toNNReal
coe_injective' μ ν h := toMeasure_injective $ Measure.ext fun s _ ↦ by
simpa [ENNReal.toNNReal_eq_toNNReal_iff, measure_ne_top] using congr_fun h s
lemma coeFn_def (μ : FiniteMeasure Ω) : μ = fun s ↦ ((μ : Measure Ω) s).toNNReal := rfl
#align measure_theory.finite_measure.coe_fn_eq_to_nnreal_coe_fn_to_measure MeasureTheory.FiniteMeasure.coeFn_def
lemma coeFn_mk (μ : Measure Ω) (hμ) :
DFunLike.coe (F := FiniteMeasure Ω) ⟨μ, hμ⟩ = fun s ↦ (μ s).toNNReal := rfl
@[simp, norm_cast]
lemma mk_apply (μ : Measure Ω) (hμ) (s : Set Ω) :
DFunLike.coe (F := FiniteMeasure Ω) ⟨μ, hμ⟩ s = (μ s).toNNReal := rfl
@[simp]
theorem ennreal_coeFn_eq_coeFn_toMeasure (ν : FiniteMeasure Ω) (s : Set Ω) :
(ν s : ℝ≥0∞) = (ν : Measure Ω) s :=
ENNReal.coe_toNNReal (measure_lt_top (↑ν) s).ne
#align measure_theory.finite_measure.ennreal_coe_fn_eq_coe_fn_to_measure MeasureTheory.FiniteMeasure.ennreal_coeFn_eq_coeFn_toMeasure
theorem apply_mono (μ : FiniteMeasure Ω) {s₁ s₂ : Set Ω} (h : s₁ ⊆ s₂) : μ s₁ ≤ μ s₂ := by
change ((μ : Measure Ω) s₁).toNNReal ≤ ((μ : Measure Ω) s₂).toNNReal
have key : (μ : Measure Ω) s₁ ≤ (μ : Measure Ω) s₂ := (μ : Measure Ω).mono h
apply (ENNReal.toNNReal_le_toNNReal (measure_ne_top _ s₁) (measure_ne_top _ s₂)).mpr key
#align measure_theory.finite_measure.apply_mono MeasureTheory.FiniteMeasure.apply_mono
def mass (μ : FiniteMeasure Ω) : ℝ≥0 :=
μ univ
#align measure_theory.finite_measure.mass MeasureTheory.FiniteMeasure.mass
@[simp] theorem apply_le_mass (μ : FiniteMeasure Ω) (s : Set Ω) : μ s ≤ μ.mass := by
simpa using apply_mono μ (subset_univ s)
@[simp]
theorem ennreal_mass {μ : FiniteMeasure Ω} : (μ.mass : ℝ≥0∞) = (μ : Measure Ω) univ :=
ennreal_coeFn_eq_coeFn_toMeasure μ Set.univ
#align measure_theory.finite_measure.ennreal_mass MeasureTheory.FiniteMeasure.ennreal_mass
instance instZero : Zero (FiniteMeasure Ω) where zero := ⟨0, MeasureTheory.isFiniteMeasureZero⟩
#align measure_theory.finite_measure.has_zero MeasureTheory.FiniteMeasure.instZero
@[simp, norm_cast] lemma coeFn_zero : ⇑(0 : FiniteMeasure Ω) = 0 := rfl
#align measure_theory.finite_measure.coe_fn_zero MeasureTheory.FiniteMeasure.coeFn_zero
@[simp]
theorem zero_mass : (0 : FiniteMeasure Ω).mass = 0 :=
rfl
#align measure_theory.finite_measure.zero.mass MeasureTheory.FiniteMeasure.zero_mass
@[simp]
theorem mass_zero_iff (μ : FiniteMeasure Ω) : μ.mass = 0 ↔ μ = 0 := by
refine ⟨fun μ_mass => ?_, fun hμ => by simp only [hμ, zero_mass]⟩
apply toMeasure_injective
apply Measure.measure_univ_eq_zero.mp
rwa [← ennreal_mass, ENNReal.coe_eq_zero]
#align measure_theory.finite_measure.mass_zero_iff MeasureTheory.FiniteMeasure.mass_zero_iff
theorem mass_nonzero_iff (μ : FiniteMeasure Ω) : μ.mass ≠ 0 ↔ μ ≠ 0 := by
rw [not_iff_not]
exact FiniteMeasure.mass_zero_iff μ
#align measure_theory.finite_measure.mass_nonzero_iff MeasureTheory.FiniteMeasure.mass_nonzero_iff
@[ext]
theorem eq_of_forall_toMeasure_apply_eq (μ ν : FiniteMeasure Ω)
(h : ∀ s : Set Ω, MeasurableSet s → (μ : Measure Ω) s = (ν : Measure Ω) s) : μ = ν := by
apply Subtype.ext
ext1 s s_mble
exact h s s_mble
#align measure_theory.finite_measure.eq_of_forall_measure_apply_eq MeasureTheory.FiniteMeasure.eq_of_forall_toMeasure_apply_eq
theorem eq_of_forall_apply_eq (μ ν : FiniteMeasure Ω)
(h : ∀ s : Set Ω, MeasurableSet s → μ s = ν s) : μ = ν := by
ext1 s s_mble
simpa [ennreal_coeFn_eq_coeFn_toMeasure] using congr_arg ((↑) : ℝ≥0 → ℝ≥0∞) (h s s_mble)
#align measure_theory.finite_measure.eq_of_forall_apply_eq MeasureTheory.FiniteMeasure.eq_of_forall_apply_eq
instance instInhabited : Inhabited (FiniteMeasure Ω) :=
⟨0⟩
instance instAdd : Add (FiniteMeasure Ω) where add μ ν := ⟨μ + ν, MeasureTheory.isFiniteMeasureAdd⟩
variable {R : Type*} [SMul R ℝ≥0] [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0 ℝ≥0∞]
[IsScalarTower R ℝ≥0∞ ℝ≥0∞]
instance instSMul : SMul R (FiniteMeasure Ω) where
smul (c : R) μ := ⟨c • (μ : Measure Ω), MeasureTheory.isFiniteMeasureSMulOfNNRealTower⟩
@[simp, norm_cast]
theorem toMeasure_zero : ((↑) : FiniteMeasure Ω → Measure Ω) 0 = 0 :=
rfl
#align measure_theory.finite_measure.coe_zero MeasureTheory.FiniteMeasure.toMeasure_zero
-- Porting note: with `simp` here the `coeFn` lemmas below fall prey to `simpNF`: the LHS simplifies
@[norm_cast]
theorem toMeasure_add (μ ν : FiniteMeasure Ω) : ↑(μ + ν) = (↑μ + ↑ν : Measure Ω) :=
rfl
#align measure_theory.finite_measure.coe_add MeasureTheory.FiniteMeasure.toMeasure_add
@[simp, norm_cast]
theorem toMeasure_smul (c : R) (μ : FiniteMeasure Ω) : ↑(c • μ) = c • (μ : Measure Ω) :=
rfl
#align measure_theory.finite_measure.coe_smul MeasureTheory.FiniteMeasure.toMeasure_smul
@[simp, norm_cast]
theorem coeFn_add (μ ν : FiniteMeasure Ω) : (⇑(μ + ν) : Set Ω → ℝ≥0) = (⇑μ + ⇑ν : Set Ω → ℝ≥0) := by
funext
simp only [Pi.add_apply, ← ENNReal.coe_inj, ne_eq, ennreal_coeFn_eq_coeFn_toMeasure,
ENNReal.coe_add]
norm_cast
#align measure_theory.finite_measure.coe_fn_add MeasureTheory.FiniteMeasure.coeFn_add
@[simp, norm_cast]
theorem coeFn_smul [IsScalarTower R ℝ≥0 ℝ≥0] (c : R) (μ : FiniteMeasure Ω) :
(⇑(c • μ) : Set Ω → ℝ≥0) = c • (⇑μ : Set Ω → ℝ≥0) := by
funext; simp [← ENNReal.coe_inj, ENNReal.coe_smul]
#align measure_theory.finite_measure.coe_fn_smul MeasureTheory.FiniteMeasure.coeFn_smul
instance instAddCommMonoid : AddCommMonoid (FiniteMeasure Ω) :=
toMeasure_injective.addCommMonoid (↑) toMeasure_zero toMeasure_add fun _ _ => toMeasure_smul _ _
@[simps]
def toMeasureAddMonoidHom : FiniteMeasure Ω →+ Measure Ω where
toFun := (↑)
map_zero' := toMeasure_zero
map_add' := toMeasure_add
#align measure_theory.finite_measure.coe_add_monoid_hom MeasureTheory.FiniteMeasure.toMeasureAddMonoidHom
instance {Ω : Type*} [MeasurableSpace Ω] : Module ℝ≥0 (FiniteMeasure Ω) :=
Function.Injective.module _ toMeasureAddMonoidHom toMeasure_injective toMeasure_smul
@[simp]
theorem smul_apply [IsScalarTower R ℝ≥0 ℝ≥0] (c : R) (μ : FiniteMeasure Ω) (s : Set Ω) :
(c • μ) s = c • μ s := by
rw [coeFn_smul, Pi.smul_apply]
#align measure_theory.finite_measure.coe_fn_smul_apply MeasureTheory.FiniteMeasure.smul_apply
def restrict (μ : FiniteMeasure Ω) (A : Set Ω) : FiniteMeasure Ω where
val := (μ : Measure Ω).restrict A
property := MeasureTheory.isFiniteMeasureRestrict (μ : Measure Ω) A
#align measure_theory.finite_measure.restrict MeasureTheory.FiniteMeasure.restrict
theorem restrict_measure_eq (μ : FiniteMeasure Ω) (A : Set Ω) :
(μ.restrict A : Measure Ω) = (μ : Measure Ω).restrict A :=
rfl
#align measure_theory.finite_measure.restrict_measure_eq MeasureTheory.FiniteMeasure.restrict_measure_eq
theorem restrict_apply_measure (μ : FiniteMeasure Ω) (A : Set Ω) {s : Set Ω}
(s_mble : MeasurableSet s) : (μ.restrict A : Measure Ω) s = (μ : Measure Ω) (s ∩ A) :=
Measure.restrict_apply s_mble
#align measure_theory.finite_measure.restrict_apply_measure MeasureTheory.FiniteMeasure.restrict_apply_measure
theorem restrict_apply (μ : FiniteMeasure Ω) (A : Set Ω) {s : Set Ω} (s_mble : MeasurableSet s) :
(μ.restrict A) s = μ (s ∩ A) := by
apply congr_arg ENNReal.toNNReal
exact Measure.restrict_apply s_mble
#align measure_theory.finite_measure.restrict_apply MeasureTheory.FiniteMeasure.restrict_apply
theorem restrict_mass (μ : FiniteMeasure Ω) (A : Set Ω) : (μ.restrict A).mass = μ A := by
simp only [mass, restrict_apply μ A MeasurableSet.univ, univ_inter]
#align measure_theory.finite_measure.restrict_mass MeasureTheory.FiniteMeasure.restrict_mass
theorem restrict_eq_zero_iff (μ : FiniteMeasure Ω) (A : Set Ω) : μ.restrict A = 0 ↔ μ A = 0 := by
rw [← mass_zero_iff, restrict_mass]
#align measure_theory.finite_measure.restrict_eq_zero_iff MeasureTheory.FiniteMeasure.restrict_eq_zero_iff
theorem restrict_nonzero_iff (μ : FiniteMeasure Ω) (A : Set Ω) : μ.restrict A ≠ 0 ↔ μ A ≠ 0 := by
rw [← mass_nonzero_iff, restrict_mass]
#align measure_theory.finite_measure.restrict_nonzero_iff MeasureTheory.FiniteMeasure.restrict_nonzero_iff
variable [TopologicalSpace Ω]
theorem ext_of_forall_lintegral_eq [HasOuterApproxClosed Ω] [BorelSpace Ω]
{μ ν : FiniteMeasure Ω} (h : ∀ (f : Ω →ᵇ ℝ≥0), ∫⁻ x, f x ∂μ = ∫⁻ x, f x ∂ν) :
μ = ν := by
apply Subtype.ext
change (μ : Measure Ω) = (ν : Measure Ω)
exact ext_of_forall_lintegral_eq_of_IsFiniteMeasure h
def testAgainstNN (μ : FiniteMeasure Ω) (f : Ω →ᵇ ℝ≥0) : ℝ≥0 :=
(∫⁻ ω, f ω ∂(μ : Measure Ω)).toNNReal
#align measure_theory.finite_measure.test_against_nn MeasureTheory.FiniteMeasure.testAgainstNN
@[simp]
theorem testAgainstNN_coe_eq {μ : FiniteMeasure Ω} {f : Ω →ᵇ ℝ≥0} :
(μ.testAgainstNN f : ℝ≥0∞) = ∫⁻ ω, f ω ∂(μ : Measure Ω) :=
ENNReal.coe_toNNReal (f.lintegral_lt_top_of_nnreal _).ne
#align measure_theory.finite_measure.test_against_nn_coe_eq MeasureTheory.FiniteMeasure.testAgainstNN_coe_eq
theorem testAgainstNN_const (μ : FiniteMeasure Ω) (c : ℝ≥0) :
μ.testAgainstNN (BoundedContinuousFunction.const Ω c) = c * μ.mass := by
simp [← ENNReal.coe_inj]
#align measure_theory.finite_measure.test_against_nn_const MeasureTheory.FiniteMeasure.testAgainstNN_const
theorem testAgainstNN_mono (μ : FiniteMeasure Ω) {f g : Ω →ᵇ ℝ≥0} (f_le_g : (f : Ω → ℝ≥0) ≤ g) :
μ.testAgainstNN f ≤ μ.testAgainstNN g := by
simp only [← ENNReal.coe_le_coe, testAgainstNN_coe_eq]
gcongr
apply f_le_g
#align measure_theory.finite_measure.test_against_nn_mono MeasureTheory.FiniteMeasure.testAgainstNN_mono
@[simp]
theorem testAgainstNN_zero (μ : FiniteMeasure Ω) : μ.testAgainstNN 0 = 0 := by
simpa only [zero_mul] using μ.testAgainstNN_const 0
#align measure_theory.finite_measure.test_against_nn_zero MeasureTheory.FiniteMeasure.testAgainstNN_zero
@[simp]
theorem testAgainstNN_one (μ : FiniteMeasure Ω) : μ.testAgainstNN 1 = μ.mass := by
simp only [testAgainstNN, coe_one, Pi.one_apply, ENNReal.coe_one, lintegral_one]
rfl
#align measure_theory.finite_measure.test_against_nn_one MeasureTheory.FiniteMeasure.testAgainstNN_one
@[simp]
theorem zero_testAgainstNN_apply (f : Ω →ᵇ ℝ≥0) : (0 : FiniteMeasure Ω).testAgainstNN f = 0 := by
simp only [testAgainstNN, toMeasure_zero, lintegral_zero_measure, ENNReal.zero_toNNReal]
#align measure_theory.finite_measure.zero.test_against_nn_apply MeasureTheory.FiniteMeasure.zero_testAgainstNN_apply
theorem zero_testAgainstNN : (0 : FiniteMeasure Ω).testAgainstNN = 0 := by
funext;
simp only [zero_testAgainstNN_apply, Pi.zero_apply]
#align measure_theory.finite_measure.zero.test_against_nn MeasureTheory.FiniteMeasure.zero_testAgainstNN
@[simp]
theorem smul_testAgainstNN_apply (c : ℝ≥0) (μ : FiniteMeasure Ω) (f : Ω →ᵇ ℝ≥0) :
(c • μ).testAgainstNN f = c • μ.testAgainstNN f := by
simp only [testAgainstNN, toMeasure_smul, smul_eq_mul, ← ENNReal.smul_toNNReal, ENNReal.smul_def,
lintegral_smul_measure]
#align measure_theory.finite_measure.smul_test_against_nn_apply MeasureTheory.FiniteMeasure.smul_testAgainstNN_apply
section weak_convergence
variable [OpensMeasurableSpace Ω]
theorem testAgainstNN_add (μ : FiniteMeasure Ω) (f₁ f₂ : Ω →ᵇ ℝ≥0) :
μ.testAgainstNN (f₁ + f₂) = μ.testAgainstNN f₁ + μ.testAgainstNN f₂ := by
simp only [← ENNReal.coe_inj, BoundedContinuousFunction.coe_add, ENNReal.coe_add, Pi.add_apply,
testAgainstNN_coe_eq]
exact lintegral_add_left (BoundedContinuousFunction.measurable_coe_ennreal_comp _) _
#align measure_theory.finite_measure.test_against_nn_add MeasureTheory.FiniteMeasure.testAgainstNN_add
| Mathlib/MeasureTheory/Measure/FiniteMeasure.lean | 396 | 404 | theorem testAgainstNN_smul [IsScalarTower R ℝ≥0 ℝ≥0] [PseudoMetricSpace R] [Zero R]
[BoundedSMul R ℝ≥0] (μ : FiniteMeasure Ω) (c : R) (f : Ω →ᵇ ℝ≥0) :
μ.testAgainstNN (c • f) = c • μ.testAgainstNN f := by |
simp only [← ENNReal.coe_inj, BoundedContinuousFunction.coe_smul, testAgainstNN_coe_eq,
ENNReal.coe_smul]
simp_rw [← smul_one_smul ℝ≥0∞ c (f _ : ℝ≥0∞), ← smul_one_smul ℝ≥0∞ c (lintegral _ _ : ℝ≥0∞),
smul_eq_mul]
exact
@lintegral_const_mul _ _ (μ : Measure Ω) (c • (1 : ℝ≥0∞)) _ f.measurable_coe_ennreal_comp
|
import Mathlib.Analysis.NormedSpace.AddTorsorBases
#align_import analysis.convex.intrinsic from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
open AffineSubspace Set
open scoped Pointwise
variable {𝕜 V W Q P : Type*}
section AddTorsor
variable (𝕜) [Ring 𝕜] [AddCommGroup V] [Module 𝕜 V] [TopologicalSpace P] [AddTorsor V P]
{s t : Set P} {x : P}
def intrinsicInterior (s : Set P) : Set P :=
(↑) '' interior ((↑) ⁻¹' s : Set <| affineSpan 𝕜 s)
#align intrinsic_interior intrinsicInterior
def intrinsicFrontier (s : Set P) : Set P :=
(↑) '' frontier ((↑) ⁻¹' s : Set <| affineSpan 𝕜 s)
#align intrinsic_frontier intrinsicFrontier
def intrinsicClosure (s : Set P) : Set P :=
(↑) '' closure ((↑) ⁻¹' s : Set <| affineSpan 𝕜 s)
#align intrinsic_closure intrinsicClosure
variable {𝕜}
@[simp]
theorem mem_intrinsicInterior :
x ∈ intrinsicInterior 𝕜 s ↔ ∃ y, y ∈ interior ((↑) ⁻¹' s : Set <| affineSpan 𝕜 s) ∧ ↑y = x :=
mem_image _ _ _
#align mem_intrinsic_interior mem_intrinsicInterior
@[simp]
theorem mem_intrinsicFrontier :
x ∈ intrinsicFrontier 𝕜 s ↔ ∃ y, y ∈ frontier ((↑) ⁻¹' s : Set <| affineSpan 𝕜 s) ∧ ↑y = x :=
mem_image _ _ _
#align mem_intrinsic_frontier mem_intrinsicFrontier
@[simp]
theorem mem_intrinsicClosure :
x ∈ intrinsicClosure 𝕜 s ↔ ∃ y, y ∈ closure ((↑) ⁻¹' s : Set <| affineSpan 𝕜 s) ∧ ↑y = x :=
mem_image _ _ _
#align mem_intrinsic_closure mem_intrinsicClosure
theorem intrinsicInterior_subset : intrinsicInterior 𝕜 s ⊆ s :=
image_subset_iff.2 interior_subset
#align intrinsic_interior_subset intrinsicInterior_subset
theorem intrinsicFrontier_subset (hs : IsClosed s) : intrinsicFrontier 𝕜 s ⊆ s :=
image_subset_iff.2 (hs.preimage continuous_induced_dom).frontier_subset
#align intrinsic_frontier_subset intrinsicFrontier_subset
theorem intrinsicFrontier_subset_intrinsicClosure : intrinsicFrontier 𝕜 s ⊆ intrinsicClosure 𝕜 s :=
image_subset _ frontier_subset_closure
#align intrinsic_frontier_subset_intrinsic_closure intrinsicFrontier_subset_intrinsicClosure
theorem subset_intrinsicClosure : s ⊆ intrinsicClosure 𝕜 s :=
fun x hx => ⟨⟨x, subset_affineSpan _ _ hx⟩, subset_closure hx, rfl⟩
#align subset_intrinsic_closure subset_intrinsicClosure
@[simp]
theorem intrinsicInterior_empty : intrinsicInterior 𝕜 (∅ : Set P) = ∅ := by simp [intrinsicInterior]
#align intrinsic_interior_empty intrinsicInterior_empty
@[simp]
theorem intrinsicFrontier_empty : intrinsicFrontier 𝕜 (∅ : Set P) = ∅ := by simp [intrinsicFrontier]
#align intrinsic_frontier_empty intrinsicFrontier_empty
@[simp]
theorem intrinsicClosure_empty : intrinsicClosure 𝕜 (∅ : Set P) = ∅ := by simp [intrinsicClosure]
#align intrinsic_closure_empty intrinsicClosure_empty
@[simp]
theorem intrinsicClosure_nonempty : (intrinsicClosure 𝕜 s).Nonempty ↔ s.Nonempty :=
⟨by simp_rw [nonempty_iff_ne_empty]; rintro h rfl; exact h intrinsicClosure_empty,
Nonempty.mono subset_intrinsicClosure⟩
#align intrinsic_closure_nonempty intrinsicClosure_nonempty
alias ⟨Set.Nonempty.ofIntrinsicClosure, Set.Nonempty.intrinsicClosure⟩ := intrinsicClosure_nonempty
#align set.nonempty.of_intrinsic_closure Set.Nonempty.ofIntrinsicClosure
#align set.nonempty.intrinsic_closure Set.Nonempty.intrinsicClosure
--attribute [protected] Set.Nonempty.intrinsicClosure -- Porting note: removed
@[simp]
theorem intrinsicInterior_singleton (x : P) : intrinsicInterior 𝕜 ({x} : Set P) = {x} := by
simpa only [intrinsicInterior, preimage_coe_affineSpan_singleton, interior_univ, image_univ,
Subtype.range_coe] using coe_affineSpan_singleton _ _ _
#align intrinsic_interior_singleton intrinsicInterior_singleton
@[simp]
| Mathlib/Analysis/Convex/Intrinsic.lean | 142 | 143 | theorem intrinsicFrontier_singleton (x : P) : intrinsicFrontier 𝕜 ({x} : Set P) = ∅ := by |
rw [intrinsicFrontier, preimage_coe_affineSpan_singleton, frontier_univ, image_empty]
|
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Comp
#align_import analysis.calculus.deriv.inv from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
universe u v w
open scoped Classical
open Topology Filter ENNReal
open Filter Asymptotics Set
open ContinuousLinearMap (smulRight smulRight_one_eq_iff)
variable {𝕜 : Type u} [NontriviallyNormedField 𝕜]
variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {f f₀ f₁ g : 𝕜 → F}
variable {f' f₀' f₁' g' : F}
variable {x : 𝕜}
variable {s t : Set 𝕜}
variable {L : Filter 𝕜}
section Inverse
theorem hasStrictDerivAt_inv (hx : x ≠ 0) : HasStrictDerivAt Inv.inv (-(x ^ 2)⁻¹) x := by
suffices
(fun p : 𝕜 × 𝕜 => (p.1 - p.2) * ((x * x)⁻¹ - (p.1 * p.2)⁻¹)) =o[𝓝 (x, x)] fun p =>
(p.1 - p.2) * 1 by
refine this.congr' ?_ (eventually_of_forall fun _ => mul_one _)
refine Eventually.mono ((isOpen_ne.prod isOpen_ne).mem_nhds ⟨hx, hx⟩) ?_
rintro ⟨y, z⟩ ⟨hy, hz⟩
simp only [mem_setOf_eq] at hy hz
-- hy : y ≠ 0, hz : z ≠ 0
field_simp [hx, hy, hz]
ring
refine (isBigO_refl (fun p : 𝕜 × 𝕜 => p.1 - p.2) _).mul_isLittleO ((isLittleO_one_iff 𝕜).2 ?_)
rw [← sub_self (x * x)⁻¹]
exact tendsto_const_nhds.sub ((continuous_mul.tendsto (x, x)).inv₀ <| mul_ne_zero hx hx)
#align has_strict_deriv_at_inv hasStrictDerivAt_inv
theorem hasDerivAt_inv (x_ne_zero : x ≠ 0) : HasDerivAt (fun y => y⁻¹) (-(x ^ 2)⁻¹) x :=
(hasStrictDerivAt_inv x_ne_zero).hasDerivAt
#align has_deriv_at_inv hasDerivAt_inv
theorem hasDerivWithinAt_inv (x_ne_zero : x ≠ 0) (s : Set 𝕜) :
HasDerivWithinAt (fun x => x⁻¹) (-(x ^ 2)⁻¹) s x :=
(hasDerivAt_inv x_ne_zero).hasDerivWithinAt
#align has_deriv_within_at_inv hasDerivWithinAt_inv
theorem differentiableAt_inv : DifferentiableAt 𝕜 (fun x => x⁻¹) x ↔ x ≠ 0 :=
⟨fun H => NormedField.continuousAt_inv.1 H.continuousAt, fun H =>
(hasDerivAt_inv H).differentiableAt⟩
#align differentiable_at_inv differentiableAt_inv
theorem differentiableWithinAt_inv (x_ne_zero : x ≠ 0) :
DifferentiableWithinAt 𝕜 (fun x => x⁻¹) s x :=
(differentiableAt_inv.2 x_ne_zero).differentiableWithinAt
#align differentiable_within_at_inv differentiableWithinAt_inv
theorem differentiableOn_inv : DifferentiableOn 𝕜 (fun x : 𝕜 => x⁻¹) { x | x ≠ 0 } := fun _x hx =>
differentiableWithinAt_inv hx
#align differentiable_on_inv differentiableOn_inv
theorem deriv_inv : deriv (fun x => x⁻¹) x = -(x ^ 2)⁻¹ := by
rcases eq_or_ne x 0 with (rfl | hne)
· simp [deriv_zero_of_not_differentiableAt (mt differentiableAt_inv.1 (not_not.2 rfl))]
· exact (hasDerivAt_inv hne).deriv
#align deriv_inv deriv_inv
@[simp]
theorem deriv_inv' : (deriv fun x : 𝕜 => x⁻¹) = fun x => -(x ^ 2)⁻¹ :=
funext fun _ => deriv_inv
#align deriv_inv' deriv_inv'
theorem derivWithin_inv (x_ne_zero : x ≠ 0) (hxs : UniqueDiffWithinAt 𝕜 s x) :
derivWithin (fun x => x⁻¹) s x = -(x ^ 2)⁻¹ := by
rw [DifferentiableAt.derivWithin (differentiableAt_inv.2 x_ne_zero) hxs]
exact deriv_inv
#align deriv_within_inv derivWithin_inv
theorem hasFDerivAt_inv (x_ne_zero : x ≠ 0) :
HasFDerivAt (fun x => x⁻¹) (smulRight (1 : 𝕜 →L[𝕜] 𝕜) (-(x ^ 2)⁻¹) : 𝕜 →L[𝕜] 𝕜) x :=
hasDerivAt_inv x_ne_zero
#align has_fderiv_at_inv hasFDerivAt_inv
theorem hasFDerivWithinAt_inv (x_ne_zero : x ≠ 0) :
HasFDerivWithinAt (fun x => x⁻¹) (smulRight (1 : 𝕜 →L[𝕜] 𝕜) (-(x ^ 2)⁻¹) : 𝕜 →L[𝕜] 𝕜) s x :=
(hasFDerivAt_inv x_ne_zero).hasFDerivWithinAt
#align has_fderiv_within_at_inv hasFDerivWithinAt_inv
| Mathlib/Analysis/Calculus/Deriv/Inv.lean | 114 | 115 | theorem fderiv_inv : fderiv 𝕜 (fun x => x⁻¹) x = smulRight (1 : 𝕜 →L[𝕜] 𝕜) (-(x ^ 2)⁻¹) := by |
rw [← deriv_fderiv, deriv_inv]
|
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Reverse
import Mathlib.Algebra.Polynomial.Inductions
import Mathlib.RingTheory.Localization.Basic
#align_import data.polynomial.laurent from "leanprover-community/mathlib"@"831c494092374cfe9f50591ed0ac81a25efc5b86"
open Polynomial Function AddMonoidAlgebra Finsupp
noncomputable section
variable {R : Type*}
abbrev LaurentPolynomial (R : Type*) [Semiring R] :=
AddMonoidAlgebra R ℤ
#align laurent_polynomial LaurentPolynomial
@[nolint docBlame]
scoped[LaurentPolynomial] notation:9000 R "[T;T⁻¹]" => LaurentPolynomial R
open LaurentPolynomial
-- Porting note: `ext` no longer applies `Finsupp.ext` automatically
@[ext]
theorem LaurentPolynomial.ext [Semiring R] {p q : R[T;T⁻¹]} (h : ∀ a, p a = q a) : p = q :=
Finsupp.ext h
def Polynomial.toLaurent [Semiring R] : R[X] →+* R[T;T⁻¹] :=
(mapDomainRingHom R Int.ofNatHom).comp (toFinsuppIso R)
#align polynomial.to_laurent Polynomial.toLaurent
theorem Polynomial.toLaurent_apply [Semiring R] (p : R[X]) :
toLaurent p = p.toFinsupp.mapDomain (↑) :=
rfl
#align polynomial.to_laurent_apply Polynomial.toLaurent_apply
def Polynomial.toLaurentAlg [CommSemiring R] : R[X] →ₐ[R] R[T;T⁻¹] :=
(mapDomainAlgHom R R Int.ofNatHom).comp (toFinsuppIsoAlg R).toAlgHom
#align polynomial.to_laurent_alg Polynomial.toLaurentAlg
@[simp] lemma Polynomial.coe_toLaurentAlg [CommSemiring R] :
(toLaurentAlg : R[X] → R[T;T⁻¹]) = toLaurent :=
rfl
theorem Polynomial.toLaurentAlg_apply [CommSemiring R] (f : R[X]) : toLaurentAlg f = toLaurent f :=
rfl
#align polynomial.to_laurent_alg_apply Polynomial.toLaurentAlg_apply
namespace LaurentPolynomial
section Semiring
variable [Semiring R]
theorem single_zero_one_eq_one : (Finsupp.single 0 1 : R[T;T⁻¹]) = (1 : R[T;T⁻¹]) :=
rfl
#align laurent_polynomial.single_zero_one_eq_one LaurentPolynomial.single_zero_one_eq_one
def C : R →+* R[T;T⁻¹] :=
singleZeroRingHom
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.C LaurentPolynomial.C
theorem algebraMap_apply {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] (r : R) :
algebraMap R (LaurentPolynomial A) r = C (algebraMap R A r) :=
rfl
#align laurent_polynomial.algebra_map_apply LaurentPolynomial.algebraMap_apply
theorem C_eq_algebraMap {R : Type*} [CommSemiring R] (r : R) : C r = algebraMap R R[T;T⁻¹] r :=
rfl
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.C_eq_algebra_map LaurentPolynomial.C_eq_algebraMap
theorem single_eq_C (r : R) : Finsupp.single 0 r = C r := rfl
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.single_eq_C LaurentPolynomial.single_eq_C
@[simp] lemma C_apply (t : R) (n : ℤ) : C t n = if n = 0 then t else 0 := by
rw [← single_eq_C, Finsupp.single_apply]; aesop
def T (n : ℤ) : R[T;T⁻¹] :=
Finsupp.single n 1
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.T LaurentPolynomial.T
@[simp] lemma T_apply (m n : ℤ) : (T n : R[T;T⁻¹]) m = if n = m then 1 else 0 :=
Finsupp.single_apply
@[simp]
theorem T_zero : (T 0 : R[T;T⁻¹]) = 1 :=
rfl
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.T_zero LaurentPolynomial.T_zero
theorem T_add (m n : ℤ) : (T (m + n) : R[T;T⁻¹]) = T m * T n := by
-- Porting note: was `convert single_mul_single.symm`
simp [T, single_mul_single]
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.T_add LaurentPolynomial.T_add
theorem T_sub (m n : ℤ) : (T (m - n) : R[T;T⁻¹]) = T m * T (-n) := by rw [← T_add, sub_eq_add_neg]
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.T_sub LaurentPolynomial.T_sub
@[simp]
theorem T_pow (m : ℤ) (n : ℕ) : (T m ^ n : R[T;T⁻¹]) = T (n * m) := by
rw [T, T, single_pow n, one_pow, nsmul_eq_mul]
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.T_pow LaurentPolynomial.T_pow
@[simp]
theorem mul_T_assoc (f : R[T;T⁻¹]) (m n : ℤ) : f * T m * T n = f * T (m + n) := by
simp [← T_add, mul_assoc]
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.mul_T_assoc LaurentPolynomial.mul_T_assoc
@[simp]
theorem single_eq_C_mul_T (r : R) (n : ℤ) :
(Finsupp.single n r : R[T;T⁻¹]) = (C r * T n : R[T;T⁻¹]) := by
-- Porting note: was `convert single_mul_single.symm`
simp [C, T, single_mul_single]
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.single_eq_C_mul_T LaurentPolynomial.single_eq_C_mul_T
-- This lemma locks in the right changes and is what Lean proved directly.
-- The actual `simp`-normal form of a Laurent monomial is `C a * T n`, whenever it can be reached.
@[simp]
theorem _root_.Polynomial.toLaurent_C_mul_T (n : ℕ) (r : R) :
(toLaurent (Polynomial.monomial n r) : R[T;T⁻¹]) = C r * T n :=
show Finsupp.mapDomain (↑) (monomial n r).toFinsupp = (C r * T n : R[T;T⁻¹]) by
rw [toFinsupp_monomial, Finsupp.mapDomain_single, single_eq_C_mul_T]
set_option linter.uppercaseLean3 false in
#align polynomial.to_laurent_C_mul_T Polynomial.toLaurent_C_mul_T
@[simp]
theorem _root_.Polynomial.toLaurent_C (r : R) : toLaurent (Polynomial.C r) = C r := by
convert Polynomial.toLaurent_C_mul_T 0 r
simp only [Int.ofNat_zero, T_zero, mul_one]
set_option linter.uppercaseLean3 false in
#align polynomial.to_laurent_C Polynomial.toLaurent_C
@[simp]
theorem _root_.Polynomial.toLaurent_comp_C : toLaurent (R := R) ∘ Polynomial.C = C :=
funext Polynomial.toLaurent_C
@[simp]
theorem _root_.Polynomial.toLaurent_X : (toLaurent Polynomial.X : R[T;T⁻¹]) = T 1 := by
have : (Polynomial.X : R[X]) = monomial 1 1 := by simp [← C_mul_X_pow_eq_monomial]
simp [this, Polynomial.toLaurent_C_mul_T]
set_option linter.uppercaseLean3 false in
#align polynomial.to_laurent_X Polynomial.toLaurent_X
-- @[simp] -- Porting note (#10618): simp can prove this
theorem _root_.Polynomial.toLaurent_one : (Polynomial.toLaurent : R[X] → R[T;T⁻¹]) 1 = 1 :=
map_one Polynomial.toLaurent
#align polynomial.to_laurent_one Polynomial.toLaurent_one
-- @[simp] -- Porting note (#10618): simp can prove this
theorem _root_.Polynomial.toLaurent_C_mul_eq (r : R) (f : R[X]) :
toLaurent (Polynomial.C r * f) = C r * toLaurent f := by
simp only [_root_.map_mul, Polynomial.toLaurent_C]
set_option linter.uppercaseLean3 false in
#align polynomial.to_laurent_C_mul_eq Polynomial.toLaurent_C_mul_eq
-- @[simp] -- Porting note (#10618): simp can prove this
theorem _root_.Polynomial.toLaurent_X_pow (n : ℕ) : toLaurent (X ^ n : R[X]) = T n := by
simp only [map_pow, Polynomial.toLaurent_X, T_pow, mul_one]
set_option linter.uppercaseLean3 false in
#align polynomial.to_laurent_X_pow Polynomial.toLaurent_X_pow
-- @[simp] -- Porting note (#10618): simp can prove this
theorem _root_.Polynomial.toLaurent_C_mul_X_pow (n : ℕ) (r : R) :
toLaurent (Polynomial.C r * X ^ n) = C r * T n := by
simp only [_root_.map_mul, Polynomial.toLaurent_C, Polynomial.toLaurent_X_pow]
set_option linter.uppercaseLean3 false in
#align polynomial.to_laurent_C_mul_X_pow Polynomial.toLaurent_C_mul_X_pow
instance invertibleT (n : ℤ) : Invertible (T n : R[T;T⁻¹]) where
invOf := T (-n)
invOf_mul_self := by rw [← T_add, add_left_neg, T_zero]
mul_invOf_self := by rw [← T_add, add_right_neg, T_zero]
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.invertible_T LaurentPolynomial.invertibleT
@[simp]
theorem invOf_T (n : ℤ) : ⅟ (T n : R[T;T⁻¹]) = T (-n) :=
rfl
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.inv_of_T LaurentPolynomial.invOf_T
theorem isUnit_T (n : ℤ) : IsUnit (T n : R[T;T⁻¹]) :=
isUnit_of_invertible _
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.is_unit_T LaurentPolynomial.isUnit_T
@[elab_as_elim]
protected theorem induction_on {M : R[T;T⁻¹] → Prop} (p : R[T;T⁻¹]) (h_C : ∀ a, M (C a))
(h_add : ∀ {p q}, M p → M q → M (p + q))
(h_C_mul_T : ∀ (n : ℕ) (a : R), M (C a * T n) → M (C a * T (n + 1)))
(h_C_mul_T_Z : ∀ (n : ℕ) (a : R), M (C a * T (-n)) → M (C a * T (-n - 1))) : M p := by
have A : ∀ {n : ℤ} {a : R}, M (C a * T n) := by
intro n a
refine Int.induction_on n ?_ ?_ ?_
· simpa only [T_zero, mul_one] using h_C a
· exact fun m => h_C_mul_T m a
· exact fun m => h_C_mul_T_Z m a
have B : ∀ s : Finset ℤ, M (s.sum fun n : ℤ => C (p.toFun n) * T n) := by
apply Finset.induction
· convert h_C 0
simp only [Finset.sum_empty, _root_.map_zero]
· intro n s ns ih
rw [Finset.sum_insert ns]
exact h_add A ih
convert B p.support
ext a
simp_rw [← single_eq_C_mul_T]
-- Porting note: did not make progress in `simp_rw`
rw [Finset.sum_apply']
simp_rw [Finsupp.single_apply, Finset.sum_ite_eq']
split_ifs with h
· rfl
· exact Finsupp.not_mem_support_iff.mp h
#align laurent_polynomial.induction_on LaurentPolynomial.induction_on
@[elab_as_elim]
protected theorem induction_on' {M : R[T;T⁻¹] → Prop} (p : R[T;T⁻¹])
(h_add : ∀ p q, M p → M q → M (p + q)) (h_C_mul_T : ∀ (n : ℤ) (a : R), M (C a * T n)) :
M p := by
refine p.induction_on (fun a => ?_) (fun {p q} => h_add p q) ?_ ?_ <;>
try exact fun n f _ => h_C_mul_T _ f
convert h_C_mul_T 0 a
exact (mul_one _).symm
#align laurent_polynomial.induction_on' LaurentPolynomial.induction_on'
theorem commute_T (n : ℤ) (f : R[T;T⁻¹]) : Commute (T n) f :=
f.induction_on' (fun p q Tp Tq => Commute.add_right Tp Tq) fun m a =>
show T n * _ = _ by
rw [T, T, ← single_eq_C, single_mul_single, single_mul_single, single_mul_single]
simp [add_comm]
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.commute_T LaurentPolynomial.commute_T
@[simp]
theorem T_mul (n : ℤ) (f : R[T;T⁻¹]) : T n * f = f * T n :=
(commute_T n f).eq
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.T_mul LaurentPolynomial.T_mul
def trunc : R[T;T⁻¹] →+ R[X] :=
(toFinsuppIso R).symm.toAddMonoidHom.comp <| comapDomain.addMonoidHom fun _ _ => Int.ofNat.inj
#align laurent_polynomial.trunc LaurentPolynomial.trunc
@[simp]
theorem trunc_C_mul_T (n : ℤ) (r : R) : trunc (C r * T n) = ite (0 ≤ n) (monomial n.toNat r) 0 := by
apply (toFinsuppIso R).injective
rw [← single_eq_C_mul_T, trunc, AddMonoidHom.coe_comp, Function.comp_apply]
-- Porting note (#10691): was `rw`
erw [comapDomain.addMonoidHom_apply Int.ofNat_injective]
rw [toFinsuppIso_apply]
-- Porting note: rewrote proof below relative to mathlib3.
by_cases n0 : 0 ≤ n
· lift n to ℕ using n0
erw [comapDomain_single]
simp only [Nat.cast_nonneg, Int.toNat_ofNat, ite_true, toFinsupp_monomial]
· lift -n to ℕ using (neg_pos.mpr (not_le.mp n0)).le with m
rw [toFinsupp_inj, if_neg n0]
ext a
have := ((not_le.mp n0).trans_le (Int.ofNat_zero_le a)).ne
simp only [coeff_ofFinsupp, comapDomain_apply, Int.ofNat_eq_coe, coeff_zero,
single_eq_of_ne this]
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.trunc_C_mul_T LaurentPolynomial.trunc_C_mul_T
@[simp]
theorem leftInverse_trunc_toLaurent :
Function.LeftInverse (trunc : R[T;T⁻¹] → R[X]) Polynomial.toLaurent := by
refine fun f => f.induction_on' ?_ ?_
· intro f g hf hg
simp only [hf, hg, _root_.map_add]
· intro n r
simp only [Polynomial.toLaurent_C_mul_T, trunc_C_mul_T, Int.natCast_nonneg, Int.toNat_natCast,
if_true]
#align laurent_polynomial.left_inverse_trunc_to_laurent LaurentPolynomial.leftInverse_trunc_toLaurent
@[simp]
theorem _root_.Polynomial.trunc_toLaurent (f : R[X]) : trunc (toLaurent f) = f :=
leftInverse_trunc_toLaurent _
#align polynomial.trunc_to_laurent Polynomial.trunc_toLaurent
theorem _root_.Polynomial.toLaurent_injective :
Function.Injective (Polynomial.toLaurent : R[X] → R[T;T⁻¹]) :=
leftInverse_trunc_toLaurent.injective
#align polynomial.to_laurent_injective Polynomial.toLaurent_injective
@[simp]
theorem _root_.Polynomial.toLaurent_inj (f g : R[X]) : toLaurent f = toLaurent g ↔ f = g :=
⟨fun h => Polynomial.toLaurent_injective h, congr_arg _⟩
#align polynomial.to_laurent_inj Polynomial.toLaurent_inj
theorem _root_.Polynomial.toLaurent_ne_zero {f : R[X]} : f ≠ 0 ↔ toLaurent f ≠ 0 :=
(map_ne_zero_iff _ Polynomial.toLaurent_injective).symm
#align polynomial.to_laurent_ne_zero Polynomial.toLaurent_ne_zero
theorem exists_T_pow (f : R[T;T⁻¹]) : ∃ (n : ℕ) (f' : R[X]), toLaurent f' = f * T n := by
refine f.induction_on' ?_ fun n a => ?_ <;> clear f
· rintro f g ⟨m, fn, hf⟩ ⟨n, gn, hg⟩
refine ⟨m + n, fn * X ^ n + gn * X ^ m, ?_⟩
simp only [hf, hg, add_mul, add_comm (n : ℤ), map_add, map_mul, Polynomial.toLaurent_X_pow,
mul_T_assoc, Int.ofNat_add]
· cases' n with n n
· exact ⟨0, Polynomial.C a * X ^ n, by simp⟩
· refine ⟨n + 1, Polynomial.C a, ?_⟩
simp only [Int.negSucc_eq, Polynomial.toLaurent_C, Int.ofNat_succ, mul_T_assoc, add_left_neg,
T_zero, mul_one]
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.exists_T_pow LaurentPolynomial.exists_T_pow
@[elab_as_elim]
theorem induction_on_mul_T {Q : R[T;T⁻¹] → Prop} (f : R[T;T⁻¹])
(Qf : ∀ {f : R[X]} {n : ℕ}, Q (toLaurent f * T (-n))) : Q f := by
rcases f.exists_T_pow with ⟨n, f', hf⟩
rw [← mul_one f, ← T_zero, ← Nat.cast_zero, ← Nat.sub_self n, Nat.cast_sub rfl.le, T_sub,
← mul_assoc, ← hf]
exact Qf
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.induction_on_mul_T LaurentPolynomial.induction_on_mul_T
theorem reduce_to_polynomial_of_mul_T (f : R[T;T⁻¹]) {Q : R[T;T⁻¹] → Prop}
(Qf : ∀ f : R[X], Q (toLaurent f)) (QT : ∀ f, Q (f * T 1) → Q f) : Q f := by
induction' f using LaurentPolynomial.induction_on_mul_T with f n
induction' n with n hn
· simpa only [Nat.zero_eq, Nat.cast_zero, neg_zero, T_zero, mul_one] using Qf _
· convert QT _ _
simpa using hn
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.reduce_to_polynomial_of_mul_T LaurentPolynomial.reduce_to_polynomial_of_mul_T
section Support
theorem support_C_mul_T (a : R) (n : ℤ) : Finsupp.support (C a * T n) ⊆ {n} := by
-- Porting note: was
-- simpa only [← single_eq_C_mul_T] using support_single_subset
rw [← single_eq_C_mul_T]
exact support_single_subset
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.support_C_mul_T LaurentPolynomial.support_C_mul_T
theorem support_C_mul_T_of_ne_zero {a : R} (a0 : a ≠ 0) (n : ℤ) :
Finsupp.support (C a * T n) = {n} := by
rw [← single_eq_C_mul_T]
exact support_single_ne_zero _ a0
set_option linter.uppercaseLean3 false in
#align laurent_polynomial.support_C_mul_T_of_ne_zero LaurentPolynomial.support_C_mul_T_of_ne_zero
| Mathlib/Algebra/Polynomial/Laurent.lean | 461 | 478 | theorem toLaurent_support (f : R[X]) : f.toLaurent.support = f.support.map Nat.castEmbedding := by |
generalize hd : f.support = s
revert f
refine Finset.induction_on s ?_ ?_ <;> clear s
· simp (config := { contextual := true }) only [Polynomial.support_eq_empty, map_zero,
Finsupp.support_zero, eq_self_iff_true, imp_true_iff, Finset.map_empty,
Finsupp.support_eq_empty]
· intro a s as hf f fs
have : (erase a f).toLaurent.support = s.map Nat.castEmbedding := by
refine hf (f.erase a) ?_
simp only [fs, Finset.erase_eq_of_not_mem as, Polynomial.support_erase,
Finset.erase_insert_eq_erase]
rw [← monomial_add_erase f a, Finset.map_insert, ← this, map_add, Polynomial.toLaurent_C_mul_T,
support_add_eq, Finset.insert_eq]
· congr
exact support_C_mul_T_of_ne_zero (Polynomial.mem_support_iff.mp (by simp [fs])) _
· rw [this]
exact Disjoint.mono_left (support_C_mul_T _ _) (by simpa)
|
import Batteries.Classes.Order
import Batteries.Control.ForInStep.Basic
namespace Batteries
namespace BinomialHeap
namespace Imp
inductive HeapNode (α : Type u) where
| nil : HeapNode α
| node (a : α) (child sibling : HeapNode α) : HeapNode α
deriving Repr
@[simp] def HeapNode.realSize : HeapNode α → Nat
| .nil => 0
| .node _ c s => c.realSize + 1 + s.realSize
def HeapNode.singleton (a : α) : HeapNode α := .node a .nil .nil
def HeapNode.rank : HeapNode α → Nat
| .nil => 0
| .node _ _ s => s.rank + 1
@[inline] private def HeapNode.rankTR (s : HeapNode α) : Nat := go s 0 where
go : HeapNode α → Nat → Nat
| .nil, r => r
| .node _ _ s, r => go s (r + 1)
@[csimp] private theorem HeapNode.rankTR_eq : @rankTR = @rank := by
funext α s; exact go s 0
where
go {α} : ∀ s n, @rankTR.go α s n = rank s + n
| .nil, _ => (Nat.zero_add ..).symm
| .node .., _ => by simp_arith only [rankTR.go, go, rank]
inductive Heap (α : Type u) where
| nil : Heap α
| cons (rank : Nat) (val : α) (node : HeapNode α) (next : Heap α) : Heap α
deriving Repr
@[simp] def Heap.realSize : Heap α → Nat
| .nil => 0
| .cons _ _ c s => c.realSize + 1 + s.realSize
def Heap.size : Heap α → Nat
| .nil => 0
| .cons r _ _ s => 1 <<< r + s.size
@[inline] def Heap.isEmpty : Heap α → Bool
| .nil => true
| _ => false
@[inline] def Heap.singleton (a : α) : Heap α := .cons 0 a .nil .nil
def Heap.rankGT : Heap α → Nat → Prop
| .nil, _ => True
| .cons r .., n => n < r
instance : Decidable (Heap.rankGT s n) :=
match s with
| .nil => inferInstanceAs (Decidable True)
| .cons .. => inferInstanceAs (Decidable (_ < _))
@[simp] def Heap.length : Heap α → Nat
| .nil => 0
| .cons _ _ _ r => r.length + 1
@[inline] def combine (le : α → α → Bool) (a₁ a₂ : α) (n₁ n₂ : HeapNode α) : α × HeapNode α :=
if le a₁ a₂ then (a₁, .node a₂ n₂ n₁) else (a₂, .node a₁ n₁ n₂)
@[specialize] def Heap.merge (le : α → α → Bool) : Heap α → Heap α → Heap α
| .nil, h => h
| h, .nil => h
| s₁@(.cons r₁ a₁ n₁ t₁), s₂@(.cons r₂ a₂ n₂ t₂) =>
if r₁ < r₂ then .cons r₁ a₁ n₁ (merge le t₁ s₂)
else if r₂ < r₁ then .cons r₂ a₂ n₂ (merge le s₁ t₂)
else
let (a, n) := combine le a₁ a₂ n₁ n₂
let r := r₁ + 1
if t₁.rankGT r then if t₂.rankGT r
then .cons r a n (merge le t₁ t₂)
else merge le (.cons r a n t₁) t₂
else if t₂.rankGT r
then merge le t₁ (.cons r a n t₂)
else .cons r a n (merge le t₁ t₂)
termination_by s₁ s₂ => s₁.length + s₂.length
def HeapNode.toHeap (s : HeapNode α) : Heap α := go s s.rank .nil where
go : HeapNode α → Nat → Heap α → Heap α
| .nil, _, res => res
| .node a c s, n, res => go s (n - 1) (.cons (n - 1) a c res)
@[specialize] def Heap.headD (le : α → α → Bool) (a : α) : Heap α → α
| .nil => a
| .cons _ b _ hs => headD le (if le a b then a else b) hs
@[inline] def Heap.head? (le : α → α → Bool) : Heap α → Option α
| .nil => none
| .cons _ h _ hs => some <| headD le h hs
structure FindMin (α) where
before : Heap α → Heap α := id
val : α
node : HeapNode α
next : Heap α
@[specialize] def Heap.findMin (le : α → α → Bool) (k : Heap α → Heap α) :
Heap α → FindMin α → FindMin α
| .nil, res => res
| .cons r a c s, res =>
-- It is important that we check `le res.val a` here, not the other way
-- around. This ensures that head? and findMin find the same element even
-- when we have `le res.val a` and `le a res.val` (i.e. le is not antisymmetric).
findMin le (k ∘ .cons r a c) s <| if le res.val a then res else ⟨k, a, c, s⟩
def Heap.deleteMin (le : α → α → Bool) : Heap α → Option (α × Heap α)
| .nil => none
| .cons r a c s =>
let { before, val, node, next } := findMin le (.cons r a c) s ⟨id, a, c, s⟩
some (val, node.toHeap.merge le (before next))
@[inline] def Heap.tail? (le : α → α → Bool) (h : Heap α) : Option (Heap α) :=
deleteMin le h |>.map (·.snd)
@[inline] def Heap.tail (le : α → α → Bool) (h : Heap α) : Heap α := tail? le h |>.getD .nil
theorem Heap.realSize_merge (le) (s₁ s₂ : Heap α) :
(s₁.merge le s₂).realSize = s₁.realSize + s₂.realSize := by
unfold merge; split
· simp
· simp
· next r₁ a₁ n₁ t₁ r₂ a₂ n₂ t₂ =>
have IH₁ r a n := realSize_merge le t₁ (cons r a n t₂)
have IH₂ r a n := realSize_merge le (cons r a n t₁) t₂
have IH₃ := realSize_merge le t₁ t₂
split; · simp [IH₁, Nat.add_assoc]
split; · simp [IH₂, Nat.add_assoc, Nat.add_left_comm]
split; simp only; rename_i a n eq
have : n.realSize = n₁.realSize + 1 + n₂.realSize := by
rw [combine] at eq; split at eq <;> cases eq <;>
simp [Nat.add_assoc, Nat.add_left_comm, Nat.add_comm]
split <;> split <;> simp [IH₁, IH₂, IH₃, this, Nat.add_assoc, Nat.add_left_comm]
termination_by s₁.length + s₂.length
private def FindMin.HasSize (res : FindMin α) (n : Nat) : Prop :=
∃ m,
(∀ s, (res.before s).realSize = m + s.realSize) ∧
n = m + res.node.realSize + res.next.realSize + 1
private theorem Heap.realSize_findMin {s : Heap α}
(m) (hk : ∀ s, (k s).realSize = m + s.realSize)
(eq : n = m + s.realSize) (hres : res.HasSize n) :
(s.findMin le k res).HasSize n :=
match s with
| .nil => hres
| .cons r a c s => by
simp [findMin]
refine realSize_findMin (m + c.realSize + 1)
(by simp [hk, Nat.add_assoc]) (by simp [eq, Nat.add_assoc]) ?_
split
· exact hres
· exact ⟨m, hk, by simp [eq, Nat.add_assoc, Nat.add_comm, Nat.add_left_comm]⟩
theorem HeapNode.realSize_toHeap (s : HeapNode α) : s.toHeap.realSize = s.realSize := go s where
go {n res} : ∀ s : HeapNode α, (toHeap.go s n res).realSize = s.realSize + res.realSize
| .nil => (Nat.zero_add _).symm
| .node a c s => by simp [toHeap.go, go, Nat.add_assoc, Nat.add_left_comm]
| .lake/packages/batteries/Batteries/Data/BinomialHeap/Basic.lean | 247 | 257 | theorem Heap.realSize_deleteMin {s : Heap α} (eq : s.deleteMin le = some (a, s')) :
s.realSize = s'.realSize + 1 := by |
cases s with cases eq | cons r a c s => ?_
have : (s.findMin le (cons r a c) ⟨id, a, c, s⟩).HasSize (c.realSize + s.realSize + 1) :=
Heap.realSize_findMin (c.realSize + 1) (by simp) (Nat.add_right_comm ..) ⟨0, by simp⟩
revert this
match s.findMin le (cons r a c) ⟨id, a, c, s⟩ with
| { before, val, node, next } =>
intro ⟨m, ih₁, ih₂⟩; dsimp only at ih₁ ih₂
rw [realSize, Nat.add_right_comm, ih₂]
simp only [realSize_merge, HeapNode.realSize_toHeap, ih₁, Nat.add_assoc, Nat.add_left_comm]
|
import Mathlib.Algebra.CharZero.Defs
import Mathlib.Algebra.Group.Pi.Basic
import Mathlib.Algebra.Group.Units
import Mathlib.Algebra.GroupWithZero.NeZero
import Mathlib.Algebra.Order.Group.Defs
import Mathlib.Algebra.Order.GroupWithZero.Unbundled
import Mathlib.Algebra.Order.Monoid.Canonical.Defs
import Mathlib.Algebra.Order.Monoid.NatCast
import Mathlib.Algebra.Order.Monoid.Unbundled.MinMax
import Mathlib.Algebra.Ring.Defs
import Mathlib.Tactic.Tauto
#align_import algebra.order.ring.char_zero from "leanprover-community/mathlib"@"655994e298904d7e5bbd1e18c95defd7b543eb94"
#align_import algebra.order.ring.defs from "leanprover-community/mathlib"@"44e29dbcff83ba7114a464d592b8c3743987c1e5"
open Function
universe u
variable {α : Type u} {β : Type*}
theorem add_one_le_two_mul [LE α] [Semiring α] [CovariantClass α α (· + ·) (· ≤ ·)] {a : α}
(a1 : 1 ≤ a) : a + 1 ≤ 2 * a :=
calc
a + 1 ≤ a + a := add_le_add_left a1 a
_ = 2 * a := (two_mul _).symm
#align add_one_le_two_mul add_one_le_two_mul
class OrderedSemiring (α : Type u) extends Semiring α, OrderedAddCommMonoid α where
protected zero_le_one : (0 : α) ≤ 1
protected mul_le_mul_of_nonneg_left : ∀ a b c : α, a ≤ b → 0 ≤ c → c * a ≤ c * b
protected mul_le_mul_of_nonneg_right : ∀ a b c : α, a ≤ b → 0 ≤ c → a * c ≤ b * c
#align ordered_semiring OrderedSemiring
class OrderedCommSemiring (α : Type u) extends OrderedSemiring α, CommSemiring α where
mul_le_mul_of_nonneg_right a b c ha hc :=
-- parentheses ensure this generates an `optParam` rather than an `autoParam`
(by simpa only [mul_comm] using mul_le_mul_of_nonneg_left a b c ha hc)
#align ordered_comm_semiring OrderedCommSemiring
class OrderedRing (α : Type u) extends Ring α, OrderedAddCommGroup α where
protected zero_le_one : 0 ≤ (1 : α)
protected mul_nonneg : ∀ a b : α, 0 ≤ a → 0 ≤ b → 0 ≤ a * b
#align ordered_ring OrderedRing
class OrderedCommRing (α : Type u) extends OrderedRing α, CommRing α
#align ordered_comm_ring OrderedCommRing
class StrictOrderedSemiring (α : Type u) extends Semiring α, OrderedCancelAddCommMonoid α,
Nontrivial α where
protected zero_le_one : (0 : α) ≤ 1
protected mul_lt_mul_of_pos_left : ∀ a b c : α, a < b → 0 < c → c * a < c * b
protected mul_lt_mul_of_pos_right : ∀ a b c : α, a < b → 0 < c → a * c < b * c
#align strict_ordered_semiring StrictOrderedSemiring
class StrictOrderedCommSemiring (α : Type u) extends StrictOrderedSemiring α, CommSemiring α
#align strict_ordered_comm_semiring StrictOrderedCommSemiring
class StrictOrderedRing (α : Type u) extends Ring α, OrderedAddCommGroup α, Nontrivial α where
protected zero_le_one : 0 ≤ (1 : α)
protected mul_pos : ∀ a b : α, 0 < a → 0 < b → 0 < a * b
#align strict_ordered_ring StrictOrderedRing
class StrictOrderedCommRing (α : Type*) extends StrictOrderedRing α, CommRing α
#align strict_ordered_comm_ring StrictOrderedCommRing
class LinearOrderedSemiring (α : Type u) extends StrictOrderedSemiring α,
LinearOrderedAddCommMonoid α
#align linear_ordered_semiring LinearOrderedSemiring
class LinearOrderedCommSemiring (α : Type*) extends StrictOrderedCommSemiring α,
LinearOrderedSemiring α
#align linear_ordered_comm_semiring LinearOrderedCommSemiring
class LinearOrderedRing (α : Type u) extends StrictOrderedRing α, LinearOrder α
#align linear_ordered_ring LinearOrderedRing
class LinearOrderedCommRing (α : Type u) extends LinearOrderedRing α, CommMonoid α
#align linear_ordered_comm_ring LinearOrderedCommRing
section OrderedSemiring
variable [OrderedSemiring α] {a b c d : α}
-- see Note [lower instance priority]
instance (priority := 100) OrderedSemiring.zeroLEOneClass : ZeroLEOneClass α :=
{ ‹OrderedSemiring α› with }
#align ordered_semiring.zero_le_one_class OrderedSemiring.zeroLEOneClass
-- see Note [lower instance priority]
instance (priority := 200) OrderedSemiring.toPosMulMono : PosMulMono α :=
⟨fun x _ _ h => OrderedSemiring.mul_le_mul_of_nonneg_left _ _ _ h x.2⟩
#align ordered_semiring.to_pos_mul_mono OrderedSemiring.toPosMulMono
-- see Note [lower instance priority]
instance (priority := 200) OrderedSemiring.toMulPosMono : MulPosMono α :=
⟨fun x _ _ h => OrderedSemiring.mul_le_mul_of_nonneg_right _ _ _ h x.2⟩
#align ordered_semiring.to_mul_pos_mono OrderedSemiring.toMulPosMono
set_option linter.deprecated false in
theorem bit1_mono : Monotone (bit1 : α → α) := fun _ _ h => add_le_add_right (bit0_mono h) _
#align bit1_mono bit1_mono
@[simp]
theorem pow_nonneg (H : 0 ≤ a) : ∀ n : ℕ, 0 ≤ a ^ n
| 0 => by
rw [pow_zero]
exact zero_le_one
| n + 1 => by
rw [pow_succ]
exact mul_nonneg (pow_nonneg H _) H
#align pow_nonneg pow_nonneg
lemma pow_le_pow_of_le_one (ha₀ : 0 ≤ a) (ha₁ : a ≤ 1) : ∀ {m n : ℕ}, m ≤ n → a ^ n ≤ a ^ m
| _, _, Nat.le.refl => le_rfl
| _, _, Nat.le.step h => by
rw [pow_succ']
exact (mul_le_of_le_one_left (pow_nonneg ha₀ _) ha₁).trans $ pow_le_pow_of_le_one ha₀ ha₁ h
#align pow_le_pow_of_le_one pow_le_pow_of_le_one
lemma pow_le_of_le_one (h₀ : 0 ≤ a) (h₁ : a ≤ 1) {n : ℕ} (hn : n ≠ 0) : a ^ n ≤ a :=
(pow_one a).subst (pow_le_pow_of_le_one h₀ h₁ (Nat.pos_of_ne_zero hn))
#align pow_le_of_le_one pow_le_of_le_one
lemma sq_le (h₀ : 0 ≤ a) (h₁ : a ≤ 1) : a ^ 2 ≤ a := pow_le_of_le_one h₀ h₁ two_ne_zero
#align sq_le sq_le
-- Porting note: it's unfortunate we need to write `(@one_le_two α)` here.
theorem add_le_mul_two_add (a2 : 2 ≤ a) (b0 : 0 ≤ b) : a + (2 + b) ≤ a * (2 + b) :=
calc
a + (2 + b) ≤ a + (a + a * b) :=
add_le_add_left (add_le_add a2 <| le_mul_of_one_le_left b0 <| (@one_le_two α).trans a2) a
_ ≤ a * (2 + b) := by rw [mul_add, mul_two, add_assoc]
#align add_le_mul_two_add add_le_mul_two_add
theorem one_le_mul_of_one_le_of_one_le (ha : 1 ≤ a) (hb : 1 ≤ b) : (1 : α) ≤ a * b :=
Left.one_le_mul_of_le_of_le ha hb <| zero_le_one.trans ha
#align one_le_mul_of_one_le_of_one_le one_le_mul_of_one_le_of_one_le
section
set_option linter.deprecated false
theorem bit1_pos [Nontrivial α] (h : 0 ≤ a) : 0 < bit1 a :=
zero_lt_one.trans_le <| bit1_zero.symm.trans_le <| bit1_mono h
#align bit1_pos bit1_pos
| Mathlib/Algebra/Order/Ring/Defs.lean | 319 | 321 | theorem bit1_pos' (h : 0 < a) : 0 < bit1 a := by |
nontriviality
exact bit1_pos h.le
|
import Mathlib.Analysis.Calculus.ContDiff.Basic
import Mathlib.Analysis.Calculus.ParametricIntegral
import Mathlib.MeasureTheory.Constructions.Prod.Integral
import Mathlib.MeasureTheory.Function.LocallyIntegrable
import Mathlib.MeasureTheory.Group.Integral
import Mathlib.MeasureTheory.Group.Prod
import Mathlib.MeasureTheory.Integral.IntervalIntegral
#align_import analysis.convolution from "leanprover-community/mathlib"@"8905e5ed90859939681a725b00f6063e65096d95"
open Set Function Filter MeasureTheory MeasureTheory.Measure TopologicalSpace
open ContinuousLinearMap Metric Bornology
open scoped Pointwise Topology NNReal Filter
universe u𝕜 uG uE uE' uE'' uF uF' uF'' uP
variable {𝕜 : Type u𝕜} {G : Type uG} {E : Type uE} {E' : Type uE'} {E'' : Type uE''} {F : Type uF}
{F' : Type uF'} {F'' : Type uF''} {P : Type uP}
variable [NormedAddCommGroup E] [NormedAddCommGroup E'] [NormedAddCommGroup E'']
[NormedAddCommGroup F] {f f' : G → E} {g g' : G → E'} {x x' : G} {y y' : E}
namespace MeasureTheory
section NontriviallyNormedField
variable [NontriviallyNormedField 𝕜]
variable [NormedSpace 𝕜 E] [NormedSpace 𝕜 E'] [NormedSpace 𝕜 E''] [NormedSpace 𝕜 F]
variable (L : E →L[𝕜] E' →L[𝕜] F)
section Measurability
variable [MeasurableSpace G] {μ ν : Measure G}
def ConvolutionExistsAt [Sub G] (f : G → E) (g : G → E') (x : G) (L : E →L[𝕜] E' →L[𝕜] F)
(μ : Measure G := by volume_tac) : Prop :=
Integrable (fun t => L (f t) (g (x - t))) μ
#align convolution_exists_at MeasureTheory.ConvolutionExistsAt
def ConvolutionExists [Sub G] (f : G → E) (g : G → E') (L : E →L[𝕜] E' →L[𝕜] F)
(μ : Measure G := by volume_tac) : Prop :=
∀ x : G, ConvolutionExistsAt f g x L μ
#align convolution_exists MeasureTheory.ConvolutionExists
section ConvolutionExists
variable {L} in
theorem ConvolutionExistsAt.integrable [Sub G] {x : G} (h : ConvolutionExistsAt f g x L μ) :
Integrable (fun t => L (f t) (g (x - t))) μ :=
h
#align convolution_exists_at.integrable MeasureTheory.ConvolutionExistsAt.integrable
section Group
variable [AddGroup G]
theorem AEStronglyMeasurable.convolution_integrand' [MeasurableAdd₂ G]
[MeasurableNeg G] [SigmaFinite ν] (hf : AEStronglyMeasurable f ν)
(hg : AEStronglyMeasurable g <| map (fun p : G × G => p.1 - p.2) (μ.prod ν)) :
AEStronglyMeasurable (fun p : G × G => L (f p.2) (g (p.1 - p.2))) (μ.prod ν) :=
L.aestronglyMeasurable_comp₂ hf.snd <| hg.comp_measurable measurable_sub
#align measure_theory.ae_strongly_measurable.convolution_integrand' MeasureTheory.AEStronglyMeasurable.convolution_integrand'
section
variable [MeasurableAdd G] [MeasurableNeg G]
theorem AEStronglyMeasurable.convolution_integrand_snd'
(hf : AEStronglyMeasurable f μ) {x : G}
(hg : AEStronglyMeasurable g <| map (fun t => x - t) μ) :
AEStronglyMeasurable (fun t => L (f t) (g (x - t))) μ :=
L.aestronglyMeasurable_comp₂ hf <| hg.comp_measurable <| measurable_id.const_sub x
#align measure_theory.ae_strongly_measurable.convolution_integrand_snd' MeasureTheory.AEStronglyMeasurable.convolution_integrand_snd'
theorem AEStronglyMeasurable.convolution_integrand_swap_snd' {x : G}
(hf : AEStronglyMeasurable f <| map (fun t => x - t) μ) (hg : AEStronglyMeasurable g μ) :
AEStronglyMeasurable (fun t => L (f (x - t)) (g t)) μ :=
L.aestronglyMeasurable_comp₂ (hf.comp_measurable <| measurable_id.const_sub x) hg
#align measure_theory.ae_strongly_measurable.convolution_integrand_swap_snd' MeasureTheory.AEStronglyMeasurable.convolution_integrand_swap_snd'
theorem _root_.BddAbove.convolutionExistsAt' {x₀ : G} {s : Set G}
(hbg : BddAbove ((fun i => ‖g i‖) '' ((fun t => -t + x₀) ⁻¹' s))) (hs : MeasurableSet s)
(h2s : (support fun t => L (f t) (g (x₀ - t))) ⊆ s) (hf : IntegrableOn f s μ)
(hmg : AEStronglyMeasurable g <| map (fun t => x₀ - t) (μ.restrict s)) :
ConvolutionExistsAt f g x₀ L μ := by
rw [ConvolutionExistsAt]
rw [← integrableOn_iff_integrable_of_support_subset h2s]
set s' := (fun t => -t + x₀) ⁻¹' s
have : ∀ᵐ t : G ∂μ.restrict s,
‖L (f t) (g (x₀ - t))‖ ≤ s.indicator (fun t => ‖L‖ * ‖f t‖ * ⨆ i : s', ‖g i‖) t := by
filter_upwards
refine le_indicator (fun t ht => ?_) fun t ht => ?_
· apply_rules [L.le_of_opNorm₂_le_of_le, le_rfl]
refine (le_ciSup_set hbg <| mem_preimage.mpr ?_)
rwa [neg_sub, sub_add_cancel]
· have : t ∉ support fun t => L (f t) (g (x₀ - t)) := mt (fun h => h2s h) ht
rw [nmem_support.mp this, norm_zero]
refine Integrable.mono' ?_ ?_ this
· rw [integrable_indicator_iff hs]; exact ((hf.norm.const_mul _).mul_const _).integrableOn
· exact hf.aestronglyMeasurable.convolution_integrand_snd' L hmg
#align bdd_above.convolution_exists_at' BddAbove.convolutionExistsAt'
theorem ConvolutionExistsAt.ofNorm' {x₀ : G}
(h : ConvolutionExistsAt (fun x => ‖f x‖) (fun x => ‖g x‖) x₀ (mul ℝ ℝ) μ)
(hmf : AEStronglyMeasurable f μ) (hmg : AEStronglyMeasurable g <| map (fun t => x₀ - t) μ) :
ConvolutionExistsAt f g x₀ L μ := by
refine (h.const_mul ‖L‖).mono'
(hmf.convolution_integrand_snd' L hmg) (eventually_of_forall fun x => ?_)
rw [mul_apply', ← mul_assoc]
apply L.le_opNorm₂
#align convolution_exists_at.of_norm' MeasureTheory.ConvolutionExistsAt.ofNorm'
end
section CommGroup
variable [AddCommGroup G]
variable [NormedSpace ℝ F]
noncomputable def convolution [Sub G] (f : G → E) (g : G → E') (L : E →L[𝕜] E' →L[𝕜] F)
(μ : Measure G := by volume_tac) : G → F := fun x =>
∫ t, L (f t) (g (x - t)) ∂μ
#align convolution MeasureTheory.convolution
scoped[Convolution] notation:67 f " ⋆[" L:67 ", " μ:67 "] " g:66 => convolution f g L μ
scoped[Convolution]
notation:67 f " ⋆[" L:67 "]" g:66 => convolution f g L MeasureSpace.volume
scoped[Convolution]
notation:67 f " ⋆ " g:66 =>
convolution f g (ContinuousLinearMap.lsmul ℝ ℝ) MeasureSpace.volume
open scoped Convolution
theorem convolution_def [Sub G] : (f ⋆[L, μ] g) x = ∫ t, L (f t) (g (x - t)) ∂μ :=
rfl
#align convolution_def MeasureTheory.convolution_def
theorem convolution_lsmul [Sub G] {f : G → 𝕜} {g : G → F} :
(f ⋆[lsmul 𝕜 𝕜, μ] g : G → F) x = ∫ t, f t • g (x - t) ∂μ :=
rfl
#align convolution_lsmul MeasureTheory.convolution_lsmul
theorem convolution_mul [Sub G] [NormedSpace ℝ 𝕜] {f : G → 𝕜} {g : G → 𝕜} :
(f ⋆[mul 𝕜 𝕜, μ] g) x = ∫ t, f t * g (x - t) ∂μ :=
rfl
#align convolution_mul MeasureTheory.convolution_mul
section Group
variable {L} [AddGroup G]
theorem smul_convolution [SMulCommClass ℝ 𝕜 F] {y : 𝕜} : y • f ⋆[L, μ] g = y • (f ⋆[L, μ] g) := by
ext; simp only [Pi.smul_apply, convolution_def, ← integral_smul, L.map_smul₂]
#align smul_convolution MeasureTheory.smul_convolution
theorem convolution_smul [SMulCommClass ℝ 𝕜 F] {y : 𝕜} : f ⋆[L, μ] y • g = y • (f ⋆[L, μ] g) := by
ext; simp only [Pi.smul_apply, convolution_def, ← integral_smul, (L _).map_smul]
#align convolution_smul MeasureTheory.convolution_smul
@[simp]
theorem zero_convolution : 0 ⋆[L, μ] g = 0 := by
ext
simp_rw [convolution_def, Pi.zero_apply, L.map_zero₂, integral_zero]
#align zero_convolution MeasureTheory.zero_convolution
@[simp]
theorem convolution_zero : f ⋆[L, μ] 0 = 0 := by
ext
simp_rw [convolution_def, Pi.zero_apply, (L _).map_zero, integral_zero]
#align convolution_zero MeasureTheory.convolution_zero
| Mathlib/Analysis/Convolution.lean | 494 | 497 | theorem ConvolutionExistsAt.distrib_add {x : G} (hfg : ConvolutionExistsAt f g x L μ)
(hfg' : ConvolutionExistsAt f g' x L μ) :
(f ⋆[L, μ] (g + g')) x = (f ⋆[L, μ] g) x + (f ⋆[L, μ] g') x := by |
simp only [convolution_def, (L _).map_add, Pi.add_apply, integral_add hfg hfg']
|
import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.FDeriv.Add
#align_import analysis.calculus.deriv.add from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
universe u v w
open scoped Classical
open Topology Filter ENNReal
open Filter Asymptotics Set
variable {𝕜 : Type u} [NontriviallyNormedField 𝕜]
variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {f f₀ f₁ g : 𝕜 → F}
variable {f' f₀' f₁' g' : F}
variable {x : 𝕜}
variable {s t : Set 𝕜}
variable {L : Filter 𝕜}
section Add
nonrec theorem HasDerivAtFilter.add (hf : HasDerivAtFilter f f' x L)
(hg : HasDerivAtFilter g g' x L) : HasDerivAtFilter (fun y => f y + g y) (f' + g') x L := by
simpa using (hf.add hg).hasDerivAtFilter
#align has_deriv_at_filter.add HasDerivAtFilter.add
nonrec theorem HasStrictDerivAt.add (hf : HasStrictDerivAt f f' x) (hg : HasStrictDerivAt g g' x) :
HasStrictDerivAt (fun y => f y + g y) (f' + g') x := by simpa using (hf.add hg).hasStrictDerivAt
#align has_strict_deriv_at.add HasStrictDerivAt.add
nonrec theorem HasDerivWithinAt.add (hf : HasDerivWithinAt f f' s x)
(hg : HasDerivWithinAt g g' s x) : HasDerivWithinAt (fun y => f y + g y) (f' + g') s x :=
hf.add hg
#align has_deriv_within_at.add HasDerivWithinAt.add
nonrec theorem HasDerivAt.add (hf : HasDerivAt f f' x) (hg : HasDerivAt g g' x) :
HasDerivAt (fun x => f x + g x) (f' + g') x :=
hf.add hg
#align has_deriv_at.add HasDerivAt.add
theorem derivWithin_add (hxs : UniqueDiffWithinAt 𝕜 s x) (hf : DifferentiableWithinAt 𝕜 f s x)
(hg : DifferentiableWithinAt 𝕜 g s x) :
derivWithin (fun y => f y + g y) s x = derivWithin f s x + derivWithin g s x :=
(hf.hasDerivWithinAt.add hg.hasDerivWithinAt).derivWithin hxs
#align deriv_within_add derivWithin_add
@[simp]
theorem deriv_add (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) :
deriv (fun y => f y + g y) x = deriv f x + deriv g x :=
(hf.hasDerivAt.add hg.hasDerivAt).deriv
#align deriv_add deriv_add
-- Porting note (#10756): new theorem
theorem HasStrictDerivAt.add_const (c : F) (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun y ↦ f y + c) f' x :=
add_zero f' ▸ hf.add (hasStrictDerivAt_const x c)
theorem HasDerivAtFilter.add_const (hf : HasDerivAtFilter f f' x L) (c : F) :
HasDerivAtFilter (fun y => f y + c) f' x L :=
add_zero f' ▸ hf.add (hasDerivAtFilter_const x L c)
#align has_deriv_at_filter.add_const HasDerivAtFilter.add_const
nonrec theorem HasDerivWithinAt.add_const (hf : HasDerivWithinAt f f' s x) (c : F) :
HasDerivWithinAt (fun y => f y + c) f' s x :=
hf.add_const c
#align has_deriv_within_at.add_const HasDerivWithinAt.add_const
nonrec theorem HasDerivAt.add_const (hf : HasDerivAt f f' x) (c : F) :
HasDerivAt (fun x => f x + c) f' x :=
hf.add_const c
#align has_deriv_at.add_const HasDerivAt.add_const
| Mathlib/Analysis/Calculus/Deriv/Add.lean | 97 | 99 | theorem derivWithin_add_const (hxs : UniqueDiffWithinAt 𝕜 s x) (c : F) :
derivWithin (fun y => f y + c) s x = derivWithin f s x := by |
simp only [derivWithin, fderivWithin_add_const hxs]
|
import Mathlib.Algebra.BigOperators.Pi
import Mathlib.Algebra.BigOperators.Ring
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
import Mathlib.Algebra.BigOperators.Fin
import Mathlib.Algebra.Group.Submonoid.Membership
import Mathlib.Data.Finsupp.Fin
import Mathlib.Data.Finsupp.Indicator
#align_import algebra.big_operators.finsupp from "leanprover-community/mathlib"@"842328d9df7e96fd90fc424e115679c15fb23a71"
noncomputable section
open Finset Function
variable {α ι γ A B C : Type*} [AddCommMonoid A] [AddCommMonoid B] [AddCommMonoid C]
variable {t : ι → A → C} (h0 : ∀ i, t i 0 = 0) (h1 : ∀ i x y, t i (x + y) = t i x + t i y)
variable {s : Finset α} {f : α → ι →₀ A} (i : ι)
variable (g : ι →₀ A) (k : ι → A → γ → B) (x : γ)
variable {β M M' N P G H R S : Type*}
namespace Finsupp
section SumProd
@[to_additive "`sum f g` is the sum of `g a (f a)` over the support of `f`. "]
def prod [Zero M] [CommMonoid N] (f : α →₀ M) (g : α → M → N) : N :=
∏ a ∈ f.support, g a (f a)
#align finsupp.prod Finsupp.prod
#align finsupp.sum Finsupp.sum
variable [Zero M] [Zero M'] [CommMonoid N]
@[to_additive]
| Mathlib/Algebra/BigOperators/Finsupp.lean | 54 | 57 | theorem prod_of_support_subset (f : α →₀ M) {s : Finset α} (hs : f.support ⊆ s) (g : α → M → N)
(h : ∀ i ∈ s, g i 0 = 1) : f.prod g = ∏ x ∈ s, g x (f x) := by |
refine Finset.prod_subset hs fun x hxs hx => h x hxs ▸ (congr_arg (g x) ?_)
exact not_mem_support_iff.1 hx
|
import Mathlib.Data.List.Sublists
import Mathlib.Data.Multiset.Bind
#align_import data.multiset.powerset from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
namespace Multiset
open List
variable {α : Type*}
-- Porting note (#11215): TODO: Write a more efficient version
def powersetAux (l : List α) : List (Multiset α) :=
(sublists l).map (↑)
#align multiset.powerset_aux Multiset.powersetAux
theorem powersetAux_eq_map_coe {l : List α} : powersetAux l = (sublists l).map (↑) :=
rfl
#align multiset.powerset_aux_eq_map_coe Multiset.powersetAux_eq_map_coe
@[simp]
theorem mem_powersetAux {l : List α} {s} : s ∈ powersetAux l ↔ s ≤ ↑l :=
Quotient.inductionOn s <| by simp [powersetAux_eq_map_coe, Subperm, and_comm]
#align multiset.mem_powerset_aux Multiset.mem_powersetAux
def powersetAux' (l : List α) : List (Multiset α) :=
(sublists' l).map (↑)
#align multiset.powerset_aux' Multiset.powersetAux'
theorem powersetAux_perm_powersetAux' {l : List α} : powersetAux l ~ powersetAux' l := by
rw [powersetAux_eq_map_coe]; exact (sublists_perm_sublists' _).map _
#align multiset.powerset_aux_perm_powerset_aux' Multiset.powersetAux_perm_powersetAux'
@[simp]
theorem powersetAux'_nil : powersetAux' (@nil α) = [0] :=
rfl
#align multiset.powerset_aux'_nil Multiset.powersetAux'_nil
@[simp]
| Mathlib/Data/Multiset/Powerset.lean | 55 | 57 | theorem powersetAux'_cons (a : α) (l : List α) :
powersetAux' (a :: l) = powersetAux' l ++ List.map (cons a) (powersetAux' l) := by |
simp only [powersetAux', sublists'_cons, map_append, List.map_map, append_cancel_left_eq]; rfl
|
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Bounds
#align_import data.real.pi.bounds from "leanprover-community/mathlib"@"402f8982dddc1864bd703da2d6e2ee304a866973"
-- Porting note: needed to add a lot of type ascriptions for lean to interpret numbers as reals.
open scoped Real
namespace Real
theorem pi_gt_sqrtTwoAddSeries (n : ℕ) :
(2 : ℝ) ^ (n + 1) * √(2 - sqrtTwoAddSeries 0 n) < π := by
have : √(2 - sqrtTwoAddSeries 0 n) / (2 : ℝ) * (2 : ℝ) ^ (n + 2) < π := by
rw [← lt_div_iff, ← sin_pi_over_two_pow_succ]
focus
apply sin_lt
apply div_pos pi_pos
all_goals apply pow_pos; norm_num
apply lt_of_le_of_lt (le_of_eq _) this
rw [pow_succ' _ (n + 1), ← mul_assoc, div_mul_cancel₀, mul_comm]; norm_num
#align real.pi_gt_sqrt_two_add_series Real.pi_gt_sqrtTwoAddSeries
theorem pi_lt_sqrtTwoAddSeries (n : ℕ) :
π < (2 : ℝ) ^ (n + 1) * √(2 - sqrtTwoAddSeries 0 n) + 1 / (4 : ℝ) ^ n := by
have : π <
(√(2 - sqrtTwoAddSeries 0 n) / (2 : ℝ) + (1 : ℝ) / ((2 : ℝ) ^ n) ^ 3 / 4) *
(2 : ℝ) ^ (n + 2) := by
rw [← div_lt_iff (by norm_num), ← sin_pi_over_two_pow_succ]
refine lt_of_lt_of_le (lt_add_of_sub_right_lt (sin_gt_sub_cube ?_ ?_)) ?_
· apply div_pos pi_pos; apply pow_pos; norm_num
· rw [div_le_iff']
· refine le_trans pi_le_four ?_
simp only [show (4 : ℝ) = (2 : ℝ) ^ 2 by norm_num, mul_one]
apply pow_le_pow_right (by norm_num)
apply le_add_of_nonneg_left; apply Nat.zero_le
· apply pow_pos; norm_num
apply add_le_add_left; rw [div_le_div_right (by norm_num)]
rw [le_div_iff (by norm_num), ← mul_pow]
refine le_trans ?_ (le_of_eq (one_pow 3)); apply pow_le_pow_left
· apply le_of_lt; apply mul_pos
· apply div_pos pi_pos; apply pow_pos; norm_num
· apply pow_pos; norm_num
· rw [← le_div_iff (by norm_num)]
refine le_trans ((div_le_div_right ?_).mpr pi_le_four) ?_
· apply pow_pos; norm_num
· simp only [pow_succ', ← div_div, one_div]
-- Porting note: removed `convert le_rfl`
norm_num
apply lt_of_lt_of_le this (le_of_eq _); rw [add_mul]; congr 1
· ring
simp only [show (4 : ℝ) = 2 ^ 2 by norm_num, ← pow_mul, div_div, ← pow_add]
rw [one_div, one_div, inv_mul_eq_iff_eq_mul₀, eq_comm, mul_inv_eq_iff_eq_mul₀, ← pow_add]
· rw [add_assoc, Nat.mul_succ, add_comm, add_comm n, add_assoc, mul_comm n]
all_goals norm_num
#align real.pi_lt_sqrt_two_add_series Real.pi_lt_sqrtTwoAddSeries
theorem pi_lower_bound_start (n : ℕ) {a}
(h : sqrtTwoAddSeries ((0 : ℕ) / (1 : ℕ)) n ≤ (2 : ℝ) - (a / (2 : ℝ) ^ (n + 1)) ^ 2) :
a < π := by
refine lt_of_le_of_lt ?_ (pi_gt_sqrtTwoAddSeries n); rw [mul_comm]
refine (div_le_iff (pow_pos (by norm_num) _ : (0 : ℝ) < _)).mp (le_sqrt_of_sq_le ?_)
rwa [le_sub_comm, show (0 : ℝ) = (0 : ℕ) / (1 : ℕ) by rw [Nat.cast_zero, zero_div]]
#align real.pi_lower_bound_start Real.pi_lower_bound_start
theorem sqrtTwoAddSeries_step_up (c d : ℕ) {a b n : ℕ} {z : ℝ} (hz : sqrtTwoAddSeries (c / d) n ≤ z)
(hb : 0 < b) (hd : 0 < d) (h : (2 * b + a) * d ^ 2 ≤ c ^ 2 * b) :
sqrtTwoAddSeries (a / b) (n + 1) ≤ z := by
refine le_trans ?_ hz; rw [sqrtTwoAddSeries_succ]; apply sqrtTwoAddSeries_monotone_left
have hb' : 0 < (b : ℝ) := Nat.cast_pos.2 hb
have hd' : 0 < (d : ℝ) := Nat.cast_pos.2 hd
rw [sqrt_le_left (div_nonneg c.cast_nonneg d.cast_nonneg), div_pow,
add_div_eq_mul_add_div _ _ (ne_of_gt hb'), div_le_div_iff hb' (pow_pos hd' _)]
exact mod_cast h
#align real.sqrt_two_add_series_step_up Real.sqrtTwoAddSeries_step_up
| Mathlib/Data/Real/Pi/Bounds.lean | 128 | 136 | theorem pi_upper_bound_start (n : ℕ) {a}
(h : (2 : ℝ) - ((a - 1 / (4 : ℝ) ^ n) / (2 : ℝ) ^ (n + 1)) ^ 2 ≤
sqrtTwoAddSeries ((0 : ℕ) / (1 : ℕ)) n)
(h₂ : (1 : ℝ) / (4 : ℝ) ^ n ≤ a) : π < a := by |
refine lt_of_lt_of_le (pi_lt_sqrtTwoAddSeries n) ?_
rw [← le_sub_iff_add_le, ← le_div_iff', sqrt_le_left, sub_le_comm]
· rwa [Nat.cast_zero, zero_div] at h
· exact div_nonneg (sub_nonneg.2 h₂) (pow_nonneg (le_of_lt zero_lt_two) _)
· exact pow_pos zero_lt_two _
|
import Mathlib.Order.Interval.Set.Image
import Mathlib.Order.CompleteLatticeIntervals
import Mathlib.Topology.Order.DenselyOrdered
import Mathlib.Topology.Order.Monotone
#align_import topology.algebra.order.intermediate_value from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514"
open Filter OrderDual TopologicalSpace Function Set
open Topology Filter
universe u v w
section
variable {X : Type u} {α : Type v} [TopologicalSpace X] [LinearOrder α] [TopologicalSpace α]
[OrderClosedTopology α]
theorem intermediate_value_univ₂ [PreconnectedSpace X] {a b : X} {f g : X → α} (hf : Continuous f)
(hg : Continuous g) (ha : f a ≤ g a) (hb : g b ≤ f b) : ∃ x, f x = g x := by
obtain ⟨x, _, hfg, hgf⟩ : (univ ∩ { x | f x ≤ g x ∧ g x ≤ f x }).Nonempty :=
isPreconnected_closed_iff.1 PreconnectedSpace.isPreconnected_univ _ _ (isClosed_le hf hg)
(isClosed_le hg hf) (fun _ _ => le_total _ _) ⟨a, trivial, ha⟩ ⟨b, trivial, hb⟩
exact ⟨x, le_antisymm hfg hgf⟩
#align intermediate_value_univ₂ intermediate_value_univ₂
theorem intermediate_value_univ₂_eventually₁ [PreconnectedSpace X] {a : X} {l : Filter X} [NeBot l]
{f g : X → α} (hf : Continuous f) (hg : Continuous g) (ha : f a ≤ g a) (he : g ≤ᶠ[l] f) :
∃ x, f x = g x :=
let ⟨_, h⟩ := he.exists; intermediate_value_univ₂ hf hg ha h
#align intermediate_value_univ₂_eventually₁ intermediate_value_univ₂_eventually₁
theorem intermediate_value_univ₂_eventually₂ [PreconnectedSpace X] {l₁ l₂ : Filter X} [NeBot l₁]
[NeBot l₂] {f g : X → α} (hf : Continuous f) (hg : Continuous g) (he₁ : f ≤ᶠ[l₁] g)
(he₂ : g ≤ᶠ[l₂] f) : ∃ x, f x = g x :=
let ⟨_, h₁⟩ := he₁.exists
let ⟨_, h₂⟩ := he₂.exists
intermediate_value_univ₂ hf hg h₁ h₂
#align intermediate_value_univ₂_eventually₂ intermediate_value_univ₂_eventually₂
theorem IsPreconnected.intermediate_value₂ {s : Set X} (hs : IsPreconnected s) {a b : X}
(ha : a ∈ s) (hb : b ∈ s) {f g : X → α} (hf : ContinuousOn f s) (hg : ContinuousOn g s)
(ha' : f a ≤ g a) (hb' : g b ≤ f b) : ∃ x ∈ s, f x = g x :=
let ⟨x, hx⟩ :=
@intermediate_value_univ₂ s α _ _ _ _ (Subtype.preconnectedSpace hs) ⟨a, ha⟩ ⟨b, hb⟩ _ _
(continuousOn_iff_continuous_restrict.1 hf) (continuousOn_iff_continuous_restrict.1 hg) ha'
hb'
⟨x, x.2, hx⟩
#align is_preconnected.intermediate_value₂ IsPreconnected.intermediate_value₂
theorem IsPreconnected.intermediate_value₂_eventually₁ {s : Set X} (hs : IsPreconnected s) {a : X}
{l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f g : X → α} (hf : ContinuousOn f s)
(hg : ContinuousOn g s) (ha' : f a ≤ g a) (he : g ≤ᶠ[l] f) : ∃ x ∈ s, f x = g x := by
rw [continuousOn_iff_continuous_restrict] at hf hg
obtain ⟨b, h⟩ :=
@intermediate_value_univ₂_eventually₁ _ _ _ _ _ _ (Subtype.preconnectedSpace hs) ⟨a, ha⟩ _
(comap_coe_neBot_of_le_principal hl) _ _ hf hg ha' (he.comap _)
exact ⟨b, b.prop, h⟩
#align is_preconnected.intermediate_value₂_eventually₁ IsPreconnected.intermediate_value₂_eventually₁
theorem IsPreconnected.intermediate_value₂_eventually₂ {s : Set X} (hs : IsPreconnected s)
{l₁ l₂ : Filter X} [NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f g : X → α}
(hf : ContinuousOn f s) (hg : ContinuousOn g s) (he₁ : f ≤ᶠ[l₁] g) (he₂ : g ≤ᶠ[l₂] f) :
∃ x ∈ s, f x = g x := by
rw [continuousOn_iff_continuous_restrict] at hf hg
obtain ⟨b, h⟩ :=
@intermediate_value_univ₂_eventually₂ _ _ _ _ _ _ (Subtype.preconnectedSpace hs) _ _
(comap_coe_neBot_of_le_principal hl₁) (comap_coe_neBot_of_le_principal hl₂) _ _ hf hg
(he₁.comap _) (he₂.comap _)
exact ⟨b, b.prop, h⟩
#align is_preconnected.intermediate_value₂_eventually₂ IsPreconnected.intermediate_value₂_eventually₂
theorem IsPreconnected.intermediate_value {s : Set X} (hs : IsPreconnected s) {a b : X} (ha : a ∈ s)
(hb : b ∈ s) {f : X → α} (hf : ContinuousOn f s) : Icc (f a) (f b) ⊆ f '' s := fun _x hx =>
hs.intermediate_value₂ ha hb hf continuousOn_const hx.1 hx.2
#align is_preconnected.intermediate_value IsPreconnected.intermediate_value
theorem IsPreconnected.intermediate_value_Ico {s : Set X} (hs : IsPreconnected s) {a : X}
{l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s) {v : α}
(ht : Tendsto f l (𝓝 v)) : Ico (f a) v ⊆ f '' s := fun _ h =>
hs.intermediate_value₂_eventually₁ ha hl hf continuousOn_const h.1
(eventually_ge_of_tendsto_gt h.2 ht)
#align is_preconnected.intermediate_value_Ico IsPreconnected.intermediate_value_Ico
theorem IsPreconnected.intermediate_value_Ioc {s : Set X} (hs : IsPreconnected s) {a : X}
{l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s) {v : α}
(ht : Tendsto f l (𝓝 v)) : Ioc v (f a) ⊆ f '' s := fun _ h =>
(hs.intermediate_value₂_eventually₁ ha hl continuousOn_const hf h.2
(eventually_le_of_tendsto_lt h.1 ht)).imp fun _ h => h.imp_right Eq.symm
#align is_preconnected.intermediate_value_Ioc IsPreconnected.intermediate_value_Ioc
theorem IsPreconnected.intermediate_value_Ioo {s : Set X} (hs : IsPreconnected s) {l₁ l₂ : Filter X}
[NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)
{v₁ v₂ : α} (ht₁ : Tendsto f l₁ (𝓝 v₁)) (ht₂ : Tendsto f l₂ (𝓝 v₂)) :
Ioo v₁ v₂ ⊆ f '' s := fun _ h =>
hs.intermediate_value₂_eventually₂ hl₁ hl₂ hf continuousOn_const
(eventually_le_of_tendsto_lt h.1 ht₁) (eventually_ge_of_tendsto_gt h.2 ht₂)
#align is_preconnected.intermediate_value_Ioo IsPreconnected.intermediate_value_Ioo
theorem IsPreconnected.intermediate_value_Ici {s : Set X} (hs : IsPreconnected s) {a : X}
{l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)
(ht : Tendsto f l atTop) : Ici (f a) ⊆ f '' s := fun y h =>
hs.intermediate_value₂_eventually₁ ha hl hf continuousOn_const h (tendsto_atTop.1 ht y)
#align is_preconnected.intermediate_value_Ici IsPreconnected.intermediate_value_Ici
theorem IsPreconnected.intermediate_value_Iic {s : Set X} (hs : IsPreconnected s) {a : X}
{l : Filter X} (ha : a ∈ s) [NeBot l] (hl : l ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)
(ht : Tendsto f l atBot) : Iic (f a) ⊆ f '' s := fun y h =>
(hs.intermediate_value₂_eventually₁ ha hl continuousOn_const hf h (tendsto_atBot.1 ht y)).imp
fun _ h => h.imp_right Eq.symm
#align is_preconnected.intermediate_value_Iic IsPreconnected.intermediate_value_Iic
theorem IsPreconnected.intermediate_value_Ioi {s : Set X} (hs : IsPreconnected s) {l₁ l₂ : Filter X}
[NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)
{v : α} (ht₁ : Tendsto f l₁ (𝓝 v)) (ht₂ : Tendsto f l₂ atTop) : Ioi v ⊆ f '' s := fun y h =>
hs.intermediate_value₂_eventually₂ hl₁ hl₂ hf continuousOn_const
(eventually_le_of_tendsto_lt h ht₁) (tendsto_atTop.1 ht₂ y)
#align is_preconnected.intermediate_value_Ioi IsPreconnected.intermediate_value_Ioi
theorem IsPreconnected.intermediate_value_Iio {s : Set X} (hs : IsPreconnected s) {l₁ l₂ : Filter X}
[NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)
{v : α} (ht₁ : Tendsto f l₁ atBot) (ht₂ : Tendsto f l₂ (𝓝 v)) : Iio v ⊆ f '' s := fun y h =>
hs.intermediate_value₂_eventually₂ hl₁ hl₂ hf continuousOn_const (tendsto_atBot.1 ht₁ y)
(eventually_ge_of_tendsto_gt h ht₂)
#align is_preconnected.intermediate_value_Iio IsPreconnected.intermediate_value_Iio
theorem IsPreconnected.intermediate_value_Iii {s : Set X} (hs : IsPreconnected s) {l₁ l₂ : Filter X}
[NeBot l₁] [NeBot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α} (hf : ContinuousOn f s)
(ht₁ : Tendsto f l₁ atBot) (ht₂ : Tendsto f l₂ atTop) : univ ⊆ f '' s := fun y _ =>
hs.intermediate_value₂_eventually₂ hl₁ hl₂ hf continuousOn_const (tendsto_atBot.1 ht₁ y)
(tendsto_atTop.1 ht₂ y)
set_option linter.uppercaseLean3 false in
#align is_preconnected.intermediate_value_Iii IsPreconnected.intermediate_value_Iii
theorem intermediate_value_univ [PreconnectedSpace X] (a b : X) {f : X → α} (hf : Continuous f) :
Icc (f a) (f b) ⊆ range f := fun _ hx => intermediate_value_univ₂ hf continuous_const hx.1 hx.2
#align intermediate_value_univ intermediate_value_univ
theorem mem_range_of_exists_le_of_exists_ge [PreconnectedSpace X] {c : α} {f : X → α}
(hf : Continuous f) (h₁ : ∃ a, f a ≤ c) (h₂ : ∃ b, c ≤ f b) : c ∈ range f :=
let ⟨a, ha⟩ := h₁; let ⟨b, hb⟩ := h₂; intermediate_value_univ a b hf ⟨ha, hb⟩
#align mem_range_of_exists_le_of_exists_ge mem_range_of_exists_le_of_exists_ge
theorem IsPreconnected.Icc_subset {s : Set α} (hs : IsPreconnected s) {a b : α} (ha : a ∈ s)
(hb : b ∈ s) : Icc a b ⊆ s := by
simpa only [image_id] using hs.intermediate_value ha hb continuousOn_id
#align is_preconnected.Icc_subset IsPreconnected.Icc_subset
theorem IsPreconnected.ordConnected {s : Set α} (h : IsPreconnected s) : OrdConnected s :=
⟨fun _ hx _ hy => h.Icc_subset hx hy⟩
#align is_preconnected.ord_connected IsPreconnected.ordConnected
theorem IsConnected.Icc_subset {s : Set α} (hs : IsConnected s) {a b : α} (ha : a ∈ s)
(hb : b ∈ s) : Icc a b ⊆ s :=
hs.2.Icc_subset ha hb
#align is_connected.Icc_subset IsConnected.Icc_subset
theorem IsPreconnected.eq_univ_of_unbounded {s : Set α} (hs : IsPreconnected s) (hb : ¬BddBelow s)
(ha : ¬BddAbove s) : s = univ := by
refine eq_univ_of_forall fun x => ?_
obtain ⟨y, ys, hy⟩ : ∃ y ∈ s, y < x := not_bddBelow_iff.1 hb x
obtain ⟨z, zs, hz⟩ : ∃ z ∈ s, x < z := not_bddAbove_iff.1 ha x
exact hs.Icc_subset ys zs ⟨le_of_lt hy, le_of_lt hz⟩
#align is_preconnected.eq_univ_of_unbounded IsPreconnected.eq_univ_of_unbounded
end
variable {α : Type u} {β : Type v} {γ : Type w} [ConditionallyCompleteLinearOrder α]
[TopologicalSpace α] [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β]
[OrderTopology β] [Nonempty γ]
theorem IsConnected.Ioo_csInf_csSup_subset {s : Set α} (hs : IsConnected s) (hb : BddBelow s)
(ha : BddAbove s) : Ioo (sInf s) (sSup s) ⊆ s := fun _x hx =>
let ⟨_y, ys, hy⟩ := (isGLB_lt_iff (isGLB_csInf hs.nonempty hb)).1 hx.1
let ⟨_z, zs, hz⟩ := (lt_isLUB_iff (isLUB_csSup hs.nonempty ha)).1 hx.2
hs.Icc_subset ys zs ⟨hy.le, hz.le⟩
#align is_connected.Ioo_cInf_cSup_subset IsConnected.Ioo_csInf_csSup_subset
theorem eq_Icc_csInf_csSup_of_connected_bdd_closed {s : Set α} (hc : IsConnected s)
(hb : BddBelow s) (ha : BddAbove s) (hcl : IsClosed s) : s = Icc (sInf s) (sSup s) :=
(subset_Icc_csInf_csSup hb ha).antisymm <|
hc.Icc_subset (hcl.csInf_mem hc.nonempty hb) (hcl.csSup_mem hc.nonempty ha)
#align eq_Icc_cInf_cSup_of_connected_bdd_closed eq_Icc_csInf_csSup_of_connected_bdd_closed
theorem IsPreconnected.Ioi_csInf_subset {s : Set α} (hs : IsPreconnected s) (hb : BddBelow s)
(ha : ¬BddAbove s) : Ioi (sInf s) ⊆ s := fun x hx =>
have sne : s.Nonempty := nonempty_of_not_bddAbove ha
let ⟨_y, ys, hy⟩ : ∃ y ∈ s, y < x := (isGLB_lt_iff (isGLB_csInf sne hb)).1 hx
let ⟨_z, zs, hz⟩ : ∃ z ∈ s, x < z := not_bddAbove_iff.1 ha x
hs.Icc_subset ys zs ⟨hy.le, hz.le⟩
#align is_preconnected.Ioi_cInf_subset IsPreconnected.Ioi_csInf_subset
theorem IsPreconnected.Iio_csSup_subset {s : Set α} (hs : IsPreconnected s) (hb : ¬BddBelow s)
(ha : BddAbove s) : Iio (sSup s) ⊆ s :=
IsPreconnected.Ioi_csInf_subset (α := αᵒᵈ) hs ha hb
#align is_preconnected.Iio_cSup_subset IsPreconnected.Iio_csSup_subset
theorem IsPreconnected.mem_intervals {s : Set α} (hs : IsPreconnected s) :
s ∈
({Icc (sInf s) (sSup s), Ico (sInf s) (sSup s), Ioc (sInf s) (sSup s), Ioo (sInf s) (sSup s),
Ici (sInf s), Ioi (sInf s), Iic (sSup s), Iio (sSup s), univ, ∅} : Set (Set α)) := by
rcases s.eq_empty_or_nonempty with (rfl | hne)
· apply_rules [Or.inr, mem_singleton]
have hs' : IsConnected s := ⟨hne, hs⟩
by_cases hb : BddBelow s <;> by_cases ha : BddAbove s
· refine mem_of_subset_of_mem ?_ <| mem_Icc_Ico_Ioc_Ioo_of_subset_of_subset
(hs'.Ioo_csInf_csSup_subset hb ha) (subset_Icc_csInf_csSup hb ha)
simp only [insert_subset_iff, mem_insert_iff, mem_singleton_iff, true_or, or_true,
singleton_subset_iff, and_self]
· refine Or.inr <| Or.inr <| Or.inr <| Or.inr ?_
cases'
mem_Ici_Ioi_of_subset_of_subset (hs.Ioi_csInf_subset hb ha) fun x hx => csInf_le hb hx with
hs hs
· exact Or.inl hs
· exact Or.inr (Or.inl hs)
· iterate 6 apply Or.inr
cases' mem_Iic_Iio_of_subset_of_subset (hs.Iio_csSup_subset hb ha) fun x hx => le_csSup ha hx
with hs hs
· exact Or.inl hs
· exact Or.inr (Or.inl hs)
· iterate 8 apply Or.inr
exact Or.inl (hs.eq_univ_of_unbounded hb ha)
#align is_preconnected.mem_intervals IsPreconnected.mem_intervals
theorem setOf_isPreconnected_subset_of_ordered :
{ s : Set α | IsPreconnected s } ⊆
-- bounded intervals
(range (uncurry Icc) ∪ range (uncurry Ico) ∪ range (uncurry Ioc) ∪ range (uncurry Ioo)) ∪
-- unbounded intervals and `univ`
(range Ici ∪ range Ioi ∪ range Iic ∪ range Iio ∪ {univ, ∅}) := by
intro s hs
rcases hs.mem_intervals with (hs | hs | hs | hs | hs | hs | hs | hs | hs | hs) <;> rw [hs] <;>
simp only [union_insert, union_singleton, mem_insert_iff, mem_union, mem_range, Prod.exists,
uncurry_apply_pair, exists_apply_eq_apply, true_or, or_true, exists_apply_eq_apply2]
#align set_of_is_preconnected_subset_of_ordered setOf_isPreconnected_subset_of_ordered
theorem IsClosed.mem_of_ge_of_forall_exists_gt {a b : α} {s : Set α} (hs : IsClosed (s ∩ Icc a b))
(ha : a ∈ s) (hab : a ≤ b) (hgt : ∀ x ∈ s ∩ Ico a b, (s ∩ Ioc x b).Nonempty) : b ∈ s := by
let S := s ∩ Icc a b
replace ha : a ∈ S := ⟨ha, left_mem_Icc.2 hab⟩
have Sbd : BddAbove S := ⟨b, fun z hz => hz.2.2⟩
let c := sSup (s ∩ Icc a b)
have c_mem : c ∈ S := hs.csSup_mem ⟨_, ha⟩ Sbd
have c_le : c ≤ b := csSup_le ⟨_, ha⟩ fun x hx => hx.2.2
cases' eq_or_lt_of_le c_le with hc hc
· exact hc ▸ c_mem.1
exfalso
rcases hgt c ⟨c_mem.1, c_mem.2.1, hc⟩ with ⟨x, xs, cx, xb⟩
exact not_lt_of_le (le_csSup Sbd ⟨xs, le_trans (le_csSup Sbd ha) (le_of_lt cx), xb⟩) cx
#align is_closed.mem_of_ge_of_forall_exists_gt IsClosed.mem_of_ge_of_forall_exists_gt
theorem IsClosed.Icc_subset_of_forall_exists_gt {a b : α} {s : Set α} (hs : IsClosed (s ∩ Icc a b))
(ha : a ∈ s) (hgt : ∀ x ∈ s ∩ Ico a b, ∀ y ∈ Ioi x, (s ∩ Ioc x y).Nonempty) : Icc a b ⊆ s := by
intro y hy
have : IsClosed (s ∩ Icc a y) := by
suffices s ∩ Icc a y = s ∩ Icc a b ∩ Icc a y by
rw [this]
exact IsClosed.inter hs isClosed_Icc
rw [inter_assoc]
congr
exact (inter_eq_self_of_subset_right <| Icc_subset_Icc_right hy.2).symm
exact
IsClosed.mem_of_ge_of_forall_exists_gt this ha hy.1 fun x hx =>
hgt x ⟨hx.1, Ico_subset_Ico_right hy.2 hx.2⟩ y hx.2.2
#align is_closed.Icc_subset_of_forall_exists_gt IsClosed.Icc_subset_of_forall_exists_gt
variable [DenselyOrdered α] {a b : α}
theorem IsClosed.Icc_subset_of_forall_mem_nhdsWithin {a b : α} {s : Set α}
(hs : IsClosed (s ∩ Icc a b)) (ha : a ∈ s) (hgt : ∀ x ∈ s ∩ Ico a b, s ∈ 𝓝[>] x) :
Icc a b ⊆ s := by
apply hs.Icc_subset_of_forall_exists_gt ha
rintro x ⟨hxs, hxab⟩ y hyxb
have : s ∩ Ioc x y ∈ 𝓝[>] x :=
inter_mem (hgt x ⟨hxs, hxab⟩) (Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, hyxb⟩)
exact (nhdsWithin_Ioi_self_neBot' ⟨b, hxab.2⟩).nonempty_of_mem this
#align is_closed.Icc_subset_of_forall_mem_nhds_within IsClosed.Icc_subset_of_forall_mem_nhdsWithin
theorem isPreconnected_Icc_aux (x y : α) (s t : Set α) (hxy : x ≤ y) (hs : IsClosed s)
(ht : IsClosed t) (hab : Icc a b ⊆ s ∪ t) (hx : x ∈ Icc a b ∩ s) (hy : y ∈ Icc a b ∩ t) :
(Icc a b ∩ (s ∩ t)).Nonempty := by
have xyab : Icc x y ⊆ Icc a b := Icc_subset_Icc hx.1.1 hy.1.2
by_contra hst
suffices Icc x y ⊆ s from
hst ⟨y, xyab <| right_mem_Icc.2 hxy, this <| right_mem_Icc.2 hxy, hy.2⟩
apply (IsClosed.inter hs isClosed_Icc).Icc_subset_of_forall_mem_nhdsWithin hx.2
rintro z ⟨zs, hz⟩
have zt : z ∈ tᶜ := fun zt => hst ⟨z, xyab <| Ico_subset_Icc_self hz, zs, zt⟩
have : tᶜ ∩ Ioc z y ∈ 𝓝[>] z := by
rw [← nhdsWithin_Ioc_eq_nhdsWithin_Ioi hz.2]
exact mem_nhdsWithin.2 ⟨tᶜ, ht.isOpen_compl, zt, Subset.rfl⟩
apply mem_of_superset this
have : Ioc z y ⊆ s ∪ t := fun w hw => hab (xyab ⟨le_trans hz.1 (le_of_lt hw.1), hw.2⟩)
exact fun w ⟨wt, wzy⟩ => (this wzy).elim id fun h => (wt h).elim
#align is_preconnected_Icc_aux isPreconnected_Icc_aux
theorem isPreconnected_Icc : IsPreconnected (Icc a b) :=
isPreconnected_closed_iff.2
(by
rintro s t hs ht hab ⟨x, hx⟩ ⟨y, hy⟩
-- This used to use `wlog`, but it was causing timeouts.
rcases le_total x y with h | h
· exact isPreconnected_Icc_aux x y s t h hs ht hab hx hy
· rw [inter_comm s t]
rw [union_comm s t] at hab
exact isPreconnected_Icc_aux y x t s h ht hs hab hy hx)
#align is_preconnected_Icc isPreconnected_Icc
theorem isPreconnected_uIcc : IsPreconnected (uIcc a b) :=
isPreconnected_Icc
#align is_preconnected_uIcc isPreconnected_uIcc
theorem Set.OrdConnected.isPreconnected {s : Set α} (h : s.OrdConnected) : IsPreconnected s :=
isPreconnected_of_forall_pair fun x hx y hy =>
⟨uIcc x y, h.uIcc_subset hx hy, left_mem_uIcc, right_mem_uIcc, isPreconnected_uIcc⟩
#align set.ord_connected.is_preconnected Set.OrdConnected.isPreconnected
theorem isPreconnected_iff_ordConnected {s : Set α} : IsPreconnected s ↔ OrdConnected s :=
⟨IsPreconnected.ordConnected, Set.OrdConnected.isPreconnected⟩
#align is_preconnected_iff_ord_connected isPreconnected_iff_ordConnected
theorem isPreconnected_Ici : IsPreconnected (Ici a) :=
ordConnected_Ici.isPreconnected
#align is_preconnected_Ici isPreconnected_Ici
theorem isPreconnected_Iic : IsPreconnected (Iic a) :=
ordConnected_Iic.isPreconnected
#align is_preconnected_Iic isPreconnected_Iic
theorem isPreconnected_Iio : IsPreconnected (Iio a) :=
ordConnected_Iio.isPreconnected
#align is_preconnected_Iio isPreconnected_Iio
theorem isPreconnected_Ioi : IsPreconnected (Ioi a) :=
ordConnected_Ioi.isPreconnected
#align is_preconnected_Ioi isPreconnected_Ioi
theorem isPreconnected_Ioo : IsPreconnected (Ioo a b) :=
ordConnected_Ioo.isPreconnected
#align is_preconnected_Ioo isPreconnected_Ioo
theorem isPreconnected_Ioc : IsPreconnected (Ioc a b) :=
ordConnected_Ioc.isPreconnected
#align is_preconnected_Ioc isPreconnected_Ioc
theorem isPreconnected_Ico : IsPreconnected (Ico a b) :=
ordConnected_Ico.isPreconnected
#align is_preconnected_Ico isPreconnected_Ico
theorem isConnected_Ici : IsConnected (Ici a) :=
⟨nonempty_Ici, isPreconnected_Ici⟩
#align is_connected_Ici isConnected_Ici
theorem isConnected_Iic : IsConnected (Iic a) :=
⟨nonempty_Iic, isPreconnected_Iic⟩
#align is_connected_Iic isConnected_Iic
theorem isConnected_Ioi [NoMaxOrder α] : IsConnected (Ioi a) :=
⟨nonempty_Ioi, isPreconnected_Ioi⟩
#align is_connected_Ioi isConnected_Ioi
theorem isConnected_Iio [NoMinOrder α] : IsConnected (Iio a) :=
⟨nonempty_Iio, isPreconnected_Iio⟩
#align is_connected_Iio isConnected_Iio
theorem isConnected_Icc (h : a ≤ b) : IsConnected (Icc a b) :=
⟨nonempty_Icc.2 h, isPreconnected_Icc⟩
#align is_connected_Icc isConnected_Icc
theorem isConnected_Ioo (h : a < b) : IsConnected (Ioo a b) :=
⟨nonempty_Ioo.2 h, isPreconnected_Ioo⟩
#align is_connected_Ioo isConnected_Ioo
theorem isConnected_Ioc (h : a < b) : IsConnected (Ioc a b) :=
⟨nonempty_Ioc.2 h, isPreconnected_Ioc⟩
#align is_connected_Ioc isConnected_Ioc
theorem isConnected_Ico (h : a < b) : IsConnected (Ico a b) :=
⟨nonempty_Ico.2 h, isPreconnected_Ico⟩
#align is_connected_Ico isConnected_Ico
instance (priority := 100) ordered_connected_space : PreconnectedSpace α :=
⟨ordConnected_univ.isPreconnected⟩
#align ordered_connected_space ordered_connected_space
theorem setOf_isPreconnected_eq_of_ordered :
{ s : Set α | IsPreconnected s } =
-- bounded intervals
range (uncurry Icc) ∪ range (uncurry Ico) ∪ range (uncurry Ioc) ∪ range (uncurry Ioo) ∪
-- unbounded intervals and `univ`
(range Ici ∪ range Ioi ∪ range Iic ∪ range Iio ∪ {univ, ∅}) := by
refine Subset.antisymm setOf_isPreconnected_subset_of_ordered ?_
simp only [subset_def, forall_mem_range, uncurry, or_imp, forall_and, mem_union,
mem_setOf_eq, insert_eq, mem_singleton_iff, forall_eq, forall_true_iff, and_true_iff,
isPreconnected_Icc, isPreconnected_Ico, isPreconnected_Ioc, isPreconnected_Ioo,
isPreconnected_Ioi, isPreconnected_Iio, isPreconnected_Ici, isPreconnected_Iic,
isPreconnected_univ, isPreconnected_empty]
#align set_of_is_preconnected_eq_of_ordered setOf_isPreconnected_eq_of_ordered
lemma isTotallyDisconnected_iff_lt {s : Set α} :
IsTotallyDisconnected s ↔ ∀ x ∈ s, ∀ y ∈ s, x < y → ∃ z ∉ s, z ∈ Ioo x y := by
simp only [IsTotallyDisconnected, isPreconnected_iff_ordConnected, ← not_nontrivial_iff,
nontrivial_iff_exists_lt, not_exists, not_and]
refine ⟨fun h x hx y hy hxy ↦ ?_, fun h t hts ht x hx y hy hxy ↦ ?_⟩
· simp_rw [← not_ordConnected_inter_Icc_iff hx hy]
exact fun hs ↦ h _ inter_subset_left hs _ ⟨hx, le_rfl, hxy.le⟩ _ ⟨hy, hxy.le, le_rfl⟩ hxy
· obtain ⟨z, h1z, h2z⟩ := h x (hts hx) y (hts hy) hxy
exact h1z <| hts <| ht.1 hx hy ⟨h2z.1.le, h2z.2.le⟩
variable {δ : Type*} [LinearOrder δ] [TopologicalSpace δ] [OrderClosedTopology δ]
theorem intermediate_value_Icc {a b : α} (hab : a ≤ b) {f : α → δ} (hf : ContinuousOn f (Icc a b)) :
Icc (f a) (f b) ⊆ f '' Icc a b :=
isPreconnected_Icc.intermediate_value (left_mem_Icc.2 hab) (right_mem_Icc.2 hab) hf
#align intermediate_value_Icc intermediate_value_Icc
theorem intermediate_value_Icc' {a b : α} (hab : a ≤ b) {f : α → δ}
(hf : ContinuousOn f (Icc a b)) : Icc (f b) (f a) ⊆ f '' Icc a b :=
isPreconnected_Icc.intermediate_value (right_mem_Icc.2 hab) (left_mem_Icc.2 hab) hf
#align intermediate_value_Icc' intermediate_value_Icc'
theorem intermediate_value_uIcc {a b : α} {f : α → δ} (hf : ContinuousOn f (uIcc a b)) :
uIcc (f a) (f b) ⊆ f '' uIcc a b := by
cases le_total (f a) (f b) <;> simp [*, isPreconnected_uIcc.intermediate_value]
#align intermediate_value_uIcc intermediate_value_uIcc
theorem intermediate_value_Ico {a b : α} (hab : a ≤ b) {f : α → δ} (hf : ContinuousOn f (Icc a b)) :
Ico (f a) (f b) ⊆ f '' Ico a b :=
Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.2 (not_lt_of_le (he ▸ h.1))) fun hlt =>
@IsPreconnected.intermediate_value_Ico _ _ _ _ _ _ _ isPreconnected_Ico _ _ ⟨refl a, hlt⟩
(right_nhdsWithin_Ico_neBot hlt) inf_le_right _ (hf.mono Ico_subset_Icc_self) _
((hf.continuousWithinAt ⟨hab, refl b⟩).mono Ico_subset_Icc_self)
#align intermediate_value_Ico intermediate_value_Ico
theorem intermediate_value_Ico' {a b : α} (hab : a ≤ b) {f : α → δ}
(hf : ContinuousOn f (Icc a b)) : Ioc (f b) (f a) ⊆ f '' Ico a b :=
Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.1 (not_lt_of_le (he ▸ h.2))) fun hlt =>
@IsPreconnected.intermediate_value_Ioc _ _ _ _ _ _ _ isPreconnected_Ico _ _ ⟨refl a, hlt⟩
(right_nhdsWithin_Ico_neBot hlt) inf_le_right _ (hf.mono Ico_subset_Icc_self) _
((hf.continuousWithinAt ⟨hab, refl b⟩).mono Ico_subset_Icc_self)
#align intermediate_value_Ico' intermediate_value_Ico'
theorem intermediate_value_Ioc {a b : α} (hab : a ≤ b) {f : α → δ} (hf : ContinuousOn f (Icc a b)) :
Ioc (f a) (f b) ⊆ f '' Ioc a b :=
Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.2 (not_le_of_lt (he ▸ h.1))) fun hlt =>
@IsPreconnected.intermediate_value_Ioc _ _ _ _ _ _ _ isPreconnected_Ioc _ _ ⟨hlt, refl b⟩
(left_nhdsWithin_Ioc_neBot hlt) inf_le_right _ (hf.mono Ioc_subset_Icc_self) _
((hf.continuousWithinAt ⟨refl a, hab⟩).mono Ioc_subset_Icc_self)
#align intermediate_value_Ioc intermediate_value_Ioc
theorem intermediate_value_Ioc' {a b : α} (hab : a ≤ b) {f : α → δ}
(hf : ContinuousOn f (Icc a b)) : Ico (f b) (f a) ⊆ f '' Ioc a b :=
Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.1 (not_le_of_lt (he ▸ h.2))) fun hlt =>
@IsPreconnected.intermediate_value_Ico _ _ _ _ _ _ _ isPreconnected_Ioc _ _ ⟨hlt, refl b⟩
(left_nhdsWithin_Ioc_neBot hlt) inf_le_right _ (hf.mono Ioc_subset_Icc_self) _
((hf.continuousWithinAt ⟨refl a, hab⟩).mono Ioc_subset_Icc_self)
#align intermediate_value_Ioc' intermediate_value_Ioc'
theorem intermediate_value_Ioo {a b : α} (hab : a ≤ b) {f : α → δ} (hf : ContinuousOn f (Icc a b)) :
Ioo (f a) (f b) ⊆ f '' Ioo a b :=
Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.2 (not_lt_of_lt (he ▸ h.1))) fun hlt =>
@IsPreconnected.intermediate_value_Ioo _ _ _ _ _ _ _ isPreconnected_Ioo _ _
(left_nhdsWithin_Ioo_neBot hlt) (right_nhdsWithin_Ioo_neBot hlt) inf_le_right inf_le_right _
(hf.mono Ioo_subset_Icc_self) _ _
((hf.continuousWithinAt ⟨refl a, hab⟩).mono Ioo_subset_Icc_self)
((hf.continuousWithinAt ⟨hab, refl b⟩).mono Ioo_subset_Icc_self)
#align intermediate_value_Ioo intermediate_value_Ioo
theorem intermediate_value_Ioo' {a b : α} (hab : a ≤ b) {f : α → δ}
(hf : ContinuousOn f (Icc a b)) : Ioo (f b) (f a) ⊆ f '' Ioo a b :=
Or.elim (eq_or_lt_of_le hab) (fun he _ h => absurd h.1 (not_lt_of_lt (he ▸ h.2))) fun hlt =>
@IsPreconnected.intermediate_value_Ioo _ _ _ _ _ _ _ isPreconnected_Ioo _ _
(right_nhdsWithin_Ioo_neBot hlt) (left_nhdsWithin_Ioo_neBot hlt) inf_le_right inf_le_right _
(hf.mono Ioo_subset_Icc_self) _ _
((hf.continuousWithinAt ⟨hab, refl b⟩).mono Ioo_subset_Icc_self)
((hf.continuousWithinAt ⟨refl a, hab⟩).mono Ioo_subset_Icc_self)
#align intermediate_value_Ioo' intermediate_value_Ioo'
theorem ContinuousOn.surjOn_Icc {s : Set α} [hs : OrdConnected s] {f : α → δ}
(hf : ContinuousOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) : SurjOn f s (Icc (f a) (f b)) :=
hs.isPreconnected.intermediate_value ha hb hf
#align continuous_on.surj_on_Icc ContinuousOn.surjOn_Icc
theorem ContinuousOn.surjOn_uIcc {s : Set α} [hs : OrdConnected s] {f : α → δ}
(hf : ContinuousOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
SurjOn f s (uIcc (f a) (f b)) := by
rcases le_total (f a) (f b) with hab | hab <;> simp [hf.surjOn_Icc, *]
#align continuous_on.surj_on_uIcc ContinuousOn.surjOn_uIcc
theorem Continuous.surjective {f : α → δ} (hf : Continuous f) (h_top : Tendsto f atTop atTop)
(h_bot : Tendsto f atBot atBot) : Function.Surjective f := fun p =>
mem_range_of_exists_le_of_exists_ge hf (h_bot.eventually (eventually_le_atBot p)).exists
(h_top.eventually (eventually_ge_atTop p)).exists
#align continuous.surjective Continuous.surjective
theorem Continuous.surjective' {f : α → δ} (hf : Continuous f) (h_top : Tendsto f atBot atTop)
(h_bot : Tendsto f atTop atBot) : Function.Surjective f :=
Continuous.surjective (α := αᵒᵈ) hf h_top h_bot
#align continuous.surjective' Continuous.surjective'
theorem ContinuousOn.surjOn_of_tendsto {f : α → δ} {s : Set α} [OrdConnected s] (hs : s.Nonempty)
(hf : ContinuousOn f s) (hbot : Tendsto (fun x : s => f x) atBot atBot)
(htop : Tendsto (fun x : s => f x) atTop atTop) : SurjOn f s univ :=
haveI := Classical.inhabited_of_nonempty hs.to_subtype
surjOn_iff_surjective.2 <| hf.restrict.surjective htop hbot
#align continuous_on.surj_on_of_tendsto ContinuousOn.surjOn_of_tendsto
theorem ContinuousOn.surjOn_of_tendsto' {f : α → δ} {s : Set α} [OrdConnected s] (hs : s.Nonempty)
(hf : ContinuousOn f s) (hbot : Tendsto (fun x : s => f x) atBot atTop)
(htop : Tendsto (fun x : s => f x) atTop atBot) : SurjOn f s univ :=
ContinuousOn.surjOn_of_tendsto (δ := δᵒᵈ) hs hf hbot htop
#align continuous_on.surj_on_of_tendsto' ContinuousOn.surjOn_of_tendsto'
theorem Continuous.strictMono_of_inj_boundedOrder [BoundedOrder α] {f : α → δ}
(hf_c : Continuous f) (hf : f ⊥ ≤ f ⊤) (hf_i : Injective f) : StrictMono f := by
intro a b hab
by_contra! h
have H : f b < f a := lt_of_le_of_ne h <| hf_i.ne hab.ne'
by_cases ha : f a ≤ f ⊥
· obtain ⟨u, hu⟩ := intermediate_value_Ioc le_top hf_c.continuousOn ⟨H.trans_le ha, hf⟩
have : u = ⊥ := hf_i hu.2
aesop
· by_cases hb : f ⊥ < f b
· obtain ⟨u, hu⟩ := intermediate_value_Ioo bot_le hf_c.continuousOn ⟨hb, H⟩
rw [hf_i hu.2] at hu
exact (hab.trans hu.1.2).false
· push_neg at ha hb
replace hb : f b < f ⊥ := lt_of_le_of_ne hb <| hf_i.ne (lt_of_lt_of_le' hab bot_le).ne'
obtain ⟨u, hu⟩ := intermediate_value_Ioo' hab.le hf_c.continuousOn ⟨hb, ha⟩
have : u = ⊥ := hf_i hu.2
aesop
theorem Continuous.strictAnti_of_inj_boundedOrder [BoundedOrder α] {f : α → δ}
(hf_c : Continuous f) (hf : f ⊤ ≤ f ⊥) (hf_i : Injective f) : StrictAnti f :=
hf_c.strictMono_of_inj_boundedOrder (δ := δᵒᵈ) hf hf_i
theorem Continuous.strictMono_of_inj_boundedOrder' [BoundedOrder α] {f : α → δ}
(hf_c : Continuous f) (hf_i : Injective f) : StrictMono f ∨ StrictAnti f :=
(le_total (f ⊥) (f ⊤)).imp
(hf_c.strictMono_of_inj_boundedOrder · hf_i)
(hf_c.strictAnti_of_inj_boundedOrder · hf_i)
theorem Continuous.strictMonoOn_of_inj_rigidity {f : α → δ}
(hf_c : Continuous f) (hf_i : Injective f) {a b : α} (hab : a < b)
(hf_mono : StrictMonoOn f (Icc a b)) : StrictMono f := by
intro x y hxy
let s := min a x
let t := max b y
have hsa : s ≤ a := min_le_left a x
have hbt : b ≤ t := le_max_left b y
have hst : s ≤ t := hsa.trans $ hbt.trans' hab.le
have hf_mono_st : StrictMonoOn f (Icc s t) ∨ StrictAntiOn f (Icc s t) := by
letI := Icc.completeLinearOrder hst
have := Continuous.strictMono_of_inj_boundedOrder' (f := Set.restrict (Icc s t) f)
hf_c.continuousOn.restrict hf_i.injOn.injective
exact this.imp strictMono_restrict.mp strictAntiOn_iff_strictAnti.mpr
have (h : StrictAntiOn f (Icc s t)) : False := by
have : Icc a b ⊆ Icc s t := Icc_subset_Icc hsa hbt
replace : StrictAntiOn f (Icc a b) := StrictAntiOn.mono h this
replace : IsAntichain (· ≤ ·) (Icc a b) :=
IsAntichain.of_strictMonoOn_antitoneOn hf_mono this.antitoneOn
exact this.not_lt (left_mem_Icc.mpr (le_of_lt hab)) (right_mem_Icc.mpr (le_of_lt hab)) hab
replace hf_mono_st : StrictMonoOn f (Icc s t) := hf_mono_st.resolve_right this
have hsx : s ≤ x := min_le_right a x
have hyt : y ≤ t := le_max_right b y
replace : Icc x y ⊆ Icc s t := Icc_subset_Icc hsx hyt
replace : StrictMonoOn f (Icc x y) := StrictMonoOn.mono hf_mono_st this
exact this (left_mem_Icc.mpr (le_of_lt hxy)) (right_mem_Icc.mpr (le_of_lt hxy)) hxy
theorem ContinuousOn.strictMonoOn_of_injOn_Icc {a b : α} {f : α → δ}
(hab : a ≤ b) (hfab : f a ≤ f b)
(hf_c : ContinuousOn f (Icc a b)) (hf_i : InjOn f (Icc a b)) :
StrictMonoOn f (Icc a b) := by
letI := Icc.completeLinearOrder hab
refine StrictMono.of_restrict ?_
set g : Icc a b → δ := Set.restrict (Icc a b) f
have hgab : g ⊥ ≤ g ⊤ := by aesop
exact Continuous.strictMono_of_inj_boundedOrder (f := g) hf_c.restrict hgab hf_i.injective
theorem ContinuousOn.strictAntiOn_of_injOn_Icc {a b : α} {f : α → δ}
(hab : a ≤ b) (hfab : f b ≤ f a)
(hf_c : ContinuousOn f (Icc a b)) (hf_i : InjOn f (Icc a b)) :
StrictAntiOn f (Icc a b) := ContinuousOn.strictMonoOn_of_injOn_Icc (δ := δᵒᵈ) hab hfab hf_c hf_i
theorem ContinuousOn.strictMonoOn_of_injOn_Icc' {a b : α} {f : α → δ} (hab : a ≤ b)
(hf_c : ContinuousOn f (Icc a b)) (hf_i : InjOn f (Icc a b)) :
StrictMonoOn f (Icc a b) ∨ StrictAntiOn f (Icc a b) :=
(le_total (f a) (f b)).imp
(ContinuousOn.strictMonoOn_of_injOn_Icc hab · hf_c hf_i)
(ContinuousOn.strictAntiOn_of_injOn_Icc hab · hf_c hf_i)
| Mathlib/Topology/Order/IntermediateValue.lean | 743 | 761 | theorem Continuous.strictMono_of_inj {f : α → δ}
(hf_c : Continuous f) (hf_i : Injective f) : StrictMono f ∨ StrictAnti f := by |
have H {c d : α} (hcd : c < d) : StrictMono f ∨ StrictAnti f :=
(hf_c.continuousOn.strictMonoOn_of_injOn_Icc' hcd.le hf_i.injOn).imp
(hf_c.strictMonoOn_of_inj_rigidity hf_i hcd)
(hf_c.strictMonoOn_of_inj_rigidity (δ := δᵒᵈ) hf_i hcd)
by_cases hn : Nonempty α
· let a : α := Classical.choice ‹_›
by_cases h : ∃ b : α, a ≠ b
· choose b hb using h
by_cases hab : a < b
· exact H hab
· push_neg at hab
have : b < a := by exact Ne.lt_of_le (id (Ne.symm hb)) hab
exact H this
· push_neg at h
haveI : Subsingleton α := ⟨fun c d => Trans.trans (h c).symm (h d)⟩
exact Or.inl <| Subsingleton.strictMono f
· aesop
|
import Mathlib.Algebra.BigOperators.Intervals
import Mathlib.Algebra.BigOperators.Ring.List
import Mathlib.Data.Int.ModEq
import Mathlib.Data.Nat.Bits
import Mathlib.Data.Nat.Log
import Mathlib.Data.List.Indexes
import Mathlib.Data.List.Palindrome
import Mathlib.Tactic.IntervalCases
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring
#align_import data.nat.digits from "leanprover-community/mathlib"@"369525b73f229ccd76a6ec0e0e0bf2be57599768"
namespace Nat
variable {n : ℕ}
def digitsAux0 : ℕ → List ℕ
| 0 => []
| n + 1 => [n + 1]
#align nat.digits_aux_0 Nat.digitsAux0
def digitsAux1 (n : ℕ) : List ℕ :=
List.replicate n 1
#align nat.digits_aux_1 Nat.digitsAux1
def digitsAux (b : ℕ) (h : 2 ≤ b) : ℕ → List ℕ
| 0 => []
| n + 1 =>
((n + 1) % b) :: digitsAux b h ((n + 1) / b)
decreasing_by exact Nat.div_lt_self (Nat.succ_pos _) h
#align nat.digits_aux Nat.digitsAux
@[simp]
theorem digitsAux_zero (b : ℕ) (h : 2 ≤ b) : digitsAux b h 0 = [] := by rw [digitsAux]
#align nat.digits_aux_zero Nat.digitsAux_zero
theorem digitsAux_def (b : ℕ) (h : 2 ≤ b) (n : ℕ) (w : 0 < n) :
digitsAux b h n = (n % b) :: digitsAux b h (n / b) := by
cases n
· cases w
· rw [digitsAux]
#align nat.digits_aux_def Nat.digitsAux_def
def digits : ℕ → ℕ → List ℕ
| 0 => digitsAux0
| 1 => digitsAux1
| b + 2 => digitsAux (b + 2) (by norm_num)
#align nat.digits Nat.digits
@[simp]
theorem digits_zero (b : ℕ) : digits b 0 = [] := by
rcases b with (_ | ⟨_ | ⟨_⟩⟩) <;> simp [digits, digitsAux0, digitsAux1]
#align nat.digits_zero Nat.digits_zero
-- @[simp] -- Porting note (#10618): simp can prove this
theorem digits_zero_zero : digits 0 0 = [] :=
rfl
#align nat.digits_zero_zero Nat.digits_zero_zero
@[simp]
theorem digits_zero_succ (n : ℕ) : digits 0 n.succ = [n + 1] :=
rfl
#align nat.digits_zero_succ Nat.digits_zero_succ
theorem digits_zero_succ' : ∀ {n : ℕ}, n ≠ 0 → digits 0 n = [n]
| 0, h => (h rfl).elim
| _ + 1, _ => rfl
#align nat.digits_zero_succ' Nat.digits_zero_succ'
@[simp]
theorem digits_one (n : ℕ) : digits 1 n = List.replicate n 1 :=
rfl
#align nat.digits_one Nat.digits_one
-- @[simp] -- Porting note (#10685): dsimp can prove this
theorem digits_one_succ (n : ℕ) : digits 1 (n + 1) = 1 :: digits 1 n :=
rfl
#align nat.digits_one_succ Nat.digits_one_succ
theorem digits_add_two_add_one (b n : ℕ) :
digits (b + 2) (n + 1) = ((n + 1) % (b + 2)) :: digits (b + 2) ((n + 1) / (b + 2)) := by
simp [digits, digitsAux_def]
#align nat.digits_add_two_add_one Nat.digits_add_two_add_one
@[simp]
lemma digits_of_two_le_of_pos {b : ℕ} (hb : 2 ≤ b) (hn : 0 < n) :
Nat.digits b n = n % b :: Nat.digits b (n / b) := by
rw [Nat.eq_add_of_sub_eq hb rfl, Nat.eq_add_of_sub_eq hn rfl, Nat.digits_add_two_add_one]
theorem digits_def' :
∀ {b : ℕ} (_ : 1 < b) {n : ℕ} (_ : 0 < n), digits b n = (n % b) :: digits b (n / b)
| 0, h => absurd h (by decide)
| 1, h => absurd h (by decide)
| b + 2, _ => digitsAux_def _ (by simp) _
#align nat.digits_def' Nat.digits_def'
@[simp]
theorem digits_of_lt (b x : ℕ) (hx : x ≠ 0) (hxb : x < b) : digits b x = [x] := by
rcases exists_eq_succ_of_ne_zero hx with ⟨x, rfl⟩
rcases Nat.exists_eq_add_of_le' ((Nat.le_add_left 1 x).trans_lt hxb) with ⟨b, rfl⟩
rw [digits_add_two_add_one, div_eq_of_lt hxb, digits_zero, mod_eq_of_lt hxb]
#align nat.digits_of_lt Nat.digits_of_lt
theorem digits_add (b : ℕ) (h : 1 < b) (x y : ℕ) (hxb : x < b) (hxy : x ≠ 0 ∨ y ≠ 0) :
digits b (x + b * y) = x :: digits b y := by
rcases Nat.exists_eq_add_of_le' h with ⟨b, rfl : _ = _ + 2⟩
cases y
· simp [hxb, hxy.resolve_right (absurd rfl)]
dsimp [digits]
rw [digitsAux_def]
· congr
· simp [Nat.add_mod, mod_eq_of_lt hxb]
· simp [add_mul_div_left, div_eq_of_lt hxb]
· apply Nat.succ_pos
#align nat.digits_add Nat.digits_add
-- If we had a function converting a list into a polynomial,
-- and appropriate lemmas about that function,
-- we could rewrite this in terms of that.
def ofDigits {α : Type*} [Semiring α] (b : α) : List ℕ → α
| [] => 0
| h :: t => h + b * ofDigits b t
#align nat.of_digits Nat.ofDigits
theorem ofDigits_eq_foldr {α : Type*} [Semiring α] (b : α) (L : List ℕ) :
ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L := by
induction' L with d L ih
· rfl
· dsimp [ofDigits]
rw [ih]
#align nat.of_digits_eq_foldr Nat.ofDigits_eq_foldr
theorem ofDigits_eq_sum_map_with_index_aux (b : ℕ) (l : List ℕ) :
((List.range l.length).zipWith ((fun i a : ℕ => a * b ^ (i + 1))) l).sum =
b * ((List.range l.length).zipWith (fun i a => a * b ^ i) l).sum := by
suffices
(List.range l.length).zipWith (fun i a : ℕ => a * b ^ (i + 1)) l =
(List.range l.length).zipWith (fun i a => b * (a * b ^ i)) l
by simp [this]
congr; ext; simp [pow_succ]; ring
#align nat.of_digits_eq_sum_map_with_index_aux Nat.ofDigits_eq_sum_map_with_index_aux
theorem ofDigits_eq_sum_mapIdx (b : ℕ) (L : List ℕ) :
ofDigits b L = (L.mapIdx fun i a => a * b ^ i).sum := by
rw [List.mapIdx_eq_enum_map, List.enum_eq_zip_range, List.map_uncurry_zip_eq_zipWith,
ofDigits_eq_foldr]
induction' L with hd tl hl
· simp
· simpa [List.range_succ_eq_map, List.zipWith_map_left, ofDigits_eq_sum_map_with_index_aux] using
Or.inl hl
#align nat.of_digits_eq_sum_map_with_index Nat.ofDigits_eq_sum_mapIdx
@[simp]
theorem ofDigits_nil {b : ℕ} : ofDigits b [] = 0 := rfl
@[simp]
theorem ofDigits_singleton {b n : ℕ} : ofDigits b [n] = n := by simp [ofDigits]
#align nat.of_digits_singleton Nat.ofDigits_singleton
@[simp]
theorem ofDigits_one_cons {α : Type*} [Semiring α] (h : ℕ) (L : List ℕ) :
ofDigits (1 : α) (h :: L) = h + ofDigits 1 L := by simp [ofDigits]
#align nat.of_digits_one_cons Nat.ofDigits_one_cons
theorem ofDigits_cons {b hd} {tl : List ℕ} :
ofDigits b (hd :: tl) = hd + b * ofDigits b tl := rfl
theorem ofDigits_append {b : ℕ} {l1 l2 : List ℕ} :
ofDigits b (l1 ++ l2) = ofDigits b l1 + b ^ l1.length * ofDigits b l2 := by
induction' l1 with hd tl IH
· simp [ofDigits]
· rw [ofDigits, List.cons_append, ofDigits, IH, List.length_cons, pow_succ']
ring
#align nat.of_digits_append Nat.ofDigits_append
@[norm_cast]
theorem coe_ofDigits (α : Type*) [Semiring α] (b : ℕ) (L : List ℕ) :
((ofDigits b L : ℕ) : α) = ofDigits (b : α) L := by
induction' L with d L ih
· simp [ofDigits]
· dsimp [ofDigits]; push_cast; rw [ih]
#align nat.coe_of_digits Nat.coe_ofDigits
@[norm_cast]
theorem coe_int_ofDigits (b : ℕ) (L : List ℕ) : ((ofDigits b L : ℕ) : ℤ) = ofDigits (b : ℤ) L := by
induction' L with d L _
· rfl
· dsimp [ofDigits]; push_cast; simp only
#align nat.coe_int_of_digits Nat.coe_int_ofDigits
theorem digits_zero_of_eq_zero {b : ℕ} (h : b ≠ 0) :
∀ {L : List ℕ} (_ : ofDigits b L = 0), ∀ l ∈ L, l = 0
| _ :: _, h0, _, List.Mem.head .. => Nat.eq_zero_of_add_eq_zero_right h0
| _ :: _, h0, _, List.Mem.tail _ hL =>
digits_zero_of_eq_zero h (mul_right_injective₀ h (Nat.eq_zero_of_add_eq_zero_left h0)) _ hL
#align nat.digits_zero_of_eq_zero Nat.digits_zero_of_eq_zero
theorem digits_ofDigits (b : ℕ) (h : 1 < b) (L : List ℕ) (w₁ : ∀ l ∈ L, l < b)
(w₂ : ∀ h : L ≠ [], L.getLast h ≠ 0) : digits b (ofDigits b L) = L := by
induction' L with d L ih
· dsimp [ofDigits]
simp
· dsimp [ofDigits]
replace w₂ := w₂ (by simp)
rw [digits_add b h]
· rw [ih]
· intro l m
apply w₁
exact List.mem_cons_of_mem _ m
· intro h
rw [List.getLast_cons h] at w₂
convert w₂
· exact w₁ d (List.mem_cons_self _ _)
· by_cases h' : L = []
· rcases h' with rfl
left
simpa using w₂
· right
contrapose! w₂
refine digits_zero_of_eq_zero h.ne_bot w₂ _ ?_
rw [List.getLast_cons h']
exact List.getLast_mem h'
#align nat.digits_of_digits Nat.digits_ofDigits
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
cases' b with b
· cases' n with n
· rfl
· change ofDigits 0 [n + 1] = n + 1
dsimp [ofDigits]
· cases' b with b
· induction' n with n ih
· rfl
· rw [Nat.zero_add] at ih ⊢
simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
· apply Nat.strongInductionOn n _
clear n
intro n h
cases n
· rw [digits_zero]
rfl
· simp only [Nat.succ_eq_add_one, digits_add_two_add_one]
dsimp [ofDigits]
rw [h _ (Nat.div_lt_self' _ b)]
rw [Nat.mod_add_div]
#align nat.of_digits_digits Nat.ofDigits_digits
theorem ofDigits_one (L : List ℕ) : ofDigits 1 L = L.sum := by
induction' L with _ _ ih
· rfl
· simp [ofDigits, List.sum_cons, ih]
#align nat.of_digits_one Nat.ofDigits_one
theorem digits_eq_nil_iff_eq_zero {b n : ℕ} : digits b n = [] ↔ n = 0 := by
constructor
· intro h
have : ofDigits b (digits b n) = ofDigits b [] := by rw [h]
convert this
rw [ofDigits_digits]
· rintro rfl
simp
#align nat.digits_eq_nil_iff_eq_zero Nat.digits_eq_nil_iff_eq_zero
theorem digits_ne_nil_iff_ne_zero {b n : ℕ} : digits b n ≠ [] ↔ n ≠ 0 :=
not_congr digits_eq_nil_iff_eq_zero
#align nat.digits_ne_nil_iff_ne_zero Nat.digits_ne_nil_iff_ne_zero
theorem digits_eq_cons_digits_div {b n : ℕ} (h : 1 < b) (w : n ≠ 0) :
digits b n = (n % b) :: digits b (n / b) := by
rcases b with (_ | _ | b)
· rw [digits_zero_succ' w, Nat.mod_zero, Nat.div_zero, Nat.digits_zero_zero]
· norm_num at h
rcases n with (_ | n)
· norm_num at w
· simp only [digits_add_two_add_one, ne_eq]
#align nat.digits_eq_cons_digits_div Nat.digits_eq_cons_digits_div
theorem digits_getLast {b : ℕ} (m : ℕ) (h : 1 < b) (p q) :
(digits b m).getLast p = (digits b (m / b)).getLast q := by
by_cases hm : m = 0
· simp [hm]
simp only [digits_eq_cons_digits_div h hm]
rw [List.getLast_cons]
#align nat.digits_last Nat.digits_getLast
theorem digits.injective (b : ℕ) : Function.Injective b.digits :=
Function.LeftInverse.injective (ofDigits_digits b)
#align nat.digits.injective Nat.digits.injective
@[simp]
theorem digits_inj_iff {b n m : ℕ} : b.digits n = b.digits m ↔ n = m :=
(digits.injective b).eq_iff
#align nat.digits_inj_iff Nat.digits_inj_iff
theorem digits_len (b n : ℕ) (hb : 1 < b) (hn : n ≠ 0) : (b.digits n).length = b.log n + 1 := by
induction' n using Nat.strong_induction_on with n IH
rw [digits_eq_cons_digits_div hb hn, List.length]
by_cases h : n / b = 0
· have hb0 : b ≠ 0 := (Nat.succ_le_iff.1 hb).ne_bot
simp [h, log_eq_zero_iff, ← Nat.div_eq_zero_iff hb0.bot_lt]
· have : n / b < n := div_lt_self (Nat.pos_of_ne_zero hn) hb
rw [IH _ this h, log_div_base, tsub_add_cancel_of_le]
refine Nat.succ_le_of_lt (log_pos hb ?_)
contrapose! h
exact div_eq_of_lt h
#align nat.digits_len Nat.digits_len
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
(digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
rcases b with (_ | _ | b)
· cases m
· cases hm rfl
· simp
· cases m
· cases hm rfl
rename ℕ => m
simp only [zero_add, digits_one, List.getLast_replicate_succ m 1]
exact Nat.one_ne_zero
revert hm
apply Nat.strongInductionOn m
intro n IH hn
by_cases hnb : n < b + 2
· simpa only [digits_of_lt (b + 2) n hn hnb]
· rw [digits_getLast n (le_add_left 2 b)]
refine IH _ (Nat.div_lt_self hn.bot_lt (one_lt_succ_succ b)) ?_
rw [← pos_iff_ne_zero]
exact Nat.div_pos (le_of_not_lt hnb) (zero_lt_succ (succ b))
#align nat.last_digit_ne_zero Nat.getLast_digit_ne_zero
| Mathlib/Data/Nat/Digits.lean | 379 | 385 | theorem mul_ofDigits (n : ℕ) {b : ℕ} {l : List ℕ} :
n * ofDigits b l = ofDigits b (l.map (n * ·)) := by |
induction l with
| nil => rfl
| cons hd tl ih =>
rw [List.map_cons, ofDigits_cons, ofDigits_cons, ← ih]
ring
|
import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics
import Mathlib.NumberTheory.Liouville.Basic
import Mathlib.Topology.Instances.Irrational
#align_import number_theory.liouville.liouville_with from "leanprover-community/mathlib"@"0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8"
open Filter Metric Real Set
open scoped Filter Topology
def LiouvilleWith (p x : ℝ) : Prop :=
∃ C, ∃ᶠ n : ℕ in atTop, ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < C / n ^ p
#align liouville_with LiouvilleWith
theorem liouvilleWith_one (x : ℝ) : LiouvilleWith 1 x := by
use 2
refine ((eventually_gt_atTop 0).mono fun n hn => ?_).frequently
have hn' : (0 : ℝ) < n := by simpa
have : x < ↑(⌊x * ↑n⌋ + 1) / ↑n := by
rw [lt_div_iff hn', Int.cast_add, Int.cast_one];
exact Int.lt_floor_add_one _
refine ⟨⌊x * n⌋ + 1, this.ne, ?_⟩
rw [abs_sub_comm, abs_of_pos (sub_pos.2 this), rpow_one, sub_lt_iff_lt_add',
add_div_eq_mul_add_div _ _ hn'.ne']
gcongr
calc _ ≤ x * n + 1 := by push_cast; gcongr; apply Int.floor_le
_ < x * n + 2 := by linarith
#align liouville_with_one liouvilleWith_one
namespace LiouvilleWith
variable {p q x y : ℝ} {r : ℚ} {m : ℤ} {n : ℕ}
theorem exists_pos (h : LiouvilleWith p x) :
∃ (C : ℝ) (_h₀ : 0 < C),
∃ᶠ n : ℕ in atTop, 1 ≤ n ∧ ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < C / n ^ p := by
rcases h with ⟨C, hC⟩
refine ⟨max C 1, zero_lt_one.trans_le <| le_max_right _ _, ?_⟩
refine ((eventually_ge_atTop 1).and_frequently hC).mono ?_
rintro n ⟨hle, m, hne, hlt⟩
refine ⟨hle, m, hne, hlt.trans_le ?_⟩
gcongr
apply le_max_left
#align liouville_with.exists_pos LiouvilleWith.exists_pos
theorem mono (h : LiouvilleWith p x) (hle : q ≤ p) : LiouvilleWith q x := by
rcases h.exists_pos with ⟨C, hC₀, hC⟩
refine ⟨C, hC.mono ?_⟩; rintro n ⟨hn, m, hne, hlt⟩
refine ⟨m, hne, hlt.trans_le <| ?_⟩
gcongr
exact_mod_cast hn
#align liouville_with.mono LiouvilleWith.mono
theorem frequently_lt_rpow_neg (h : LiouvilleWith p x) (hlt : q < p) :
∃ᶠ n : ℕ in atTop, ∃ m : ℤ, x ≠ m / n ∧ |x - m / n| < n ^ (-q) := by
rcases h.exists_pos with ⟨C, _hC₀, hC⟩
have : ∀ᶠ n : ℕ in atTop, C < n ^ (p - q) := by
simpa only [(· ∘ ·), neg_sub, one_div] using
((tendsto_rpow_atTop (sub_pos.2 hlt)).comp tendsto_natCast_atTop_atTop).eventually
(eventually_gt_atTop C)
refine (this.and_frequently hC).mono ?_
rintro n ⟨hnC, hn, m, hne, hlt⟩
replace hn : (0 : ℝ) < n := Nat.cast_pos.2 hn
refine ⟨m, hne, hlt.trans <| (div_lt_iff <| rpow_pos_of_pos hn _).2 ?_⟩
rwa [mul_comm, ← rpow_add hn, ← sub_eq_add_neg]
#align liouville_with.frequently_lt_rpow_neg LiouvilleWith.frequently_lt_rpow_neg
theorem mul_rat (h : LiouvilleWith p x) (hr : r ≠ 0) : LiouvilleWith p (x * r) := by
rcases h.exists_pos with ⟨C, _hC₀, hC⟩
refine ⟨r.den ^ p * (|r| * C), (tendsto_id.nsmul_atTop r.pos).frequently (hC.mono ?_)⟩
rintro n ⟨_hn, m, hne, hlt⟩
have A : (↑(r.num * m) : ℝ) / ↑(r.den • id n) = m / n * r := by
simp [← div_mul_div_comm, ← r.cast_def, mul_comm]
refine ⟨r.num * m, ?_, ?_⟩
· rw [A]; simp [hne, hr]
· rw [A, ← sub_mul, abs_mul]
simp only [smul_eq_mul, id, Nat.cast_mul]
calc _ < C / ↑n ^ p * |↑r| := by gcongr
_ = ↑r.den ^ p * (↑|r| * C) / (↑r.den * ↑n) ^ p := ?_
rw [mul_rpow, mul_div_mul_left, mul_comm, mul_div_assoc]
· simp only [Rat.cast_abs, le_refl]
all_goals positivity
#align liouville_with.mul_rat LiouvilleWith.mul_rat
theorem mul_rat_iff (hr : r ≠ 0) : LiouvilleWith p (x * r) ↔ LiouvilleWith p x :=
⟨fun h => by
simpa only [mul_assoc, ← Rat.cast_mul, mul_inv_cancel hr, Rat.cast_one, mul_one] using
h.mul_rat (inv_ne_zero hr),
fun h => h.mul_rat hr⟩
#align liouville_with.mul_rat_iff LiouvilleWith.mul_rat_iff
theorem rat_mul_iff (hr : r ≠ 0) : LiouvilleWith p (r * x) ↔ LiouvilleWith p x := by
rw [mul_comm, mul_rat_iff hr]
#align liouville_with.rat_mul_iff LiouvilleWith.rat_mul_iff
theorem rat_mul (h : LiouvilleWith p x) (hr : r ≠ 0) : LiouvilleWith p (r * x) :=
(rat_mul_iff hr).2 h
#align liouville_with.rat_mul LiouvilleWith.rat_mul
theorem mul_int_iff (hm : m ≠ 0) : LiouvilleWith p (x * m) ↔ LiouvilleWith p x := by
rw [← Rat.cast_intCast, mul_rat_iff (Int.cast_ne_zero.2 hm)]
#align liouville_with.mul_int_iff LiouvilleWith.mul_int_iff
theorem mul_int (h : LiouvilleWith p x) (hm : m ≠ 0) : LiouvilleWith p (x * m) :=
(mul_int_iff hm).2 h
#align liouville_with.mul_int LiouvilleWith.mul_int
theorem int_mul_iff (hm : m ≠ 0) : LiouvilleWith p (m * x) ↔ LiouvilleWith p x := by
rw [mul_comm, mul_int_iff hm]
#align liouville_with.int_mul_iff LiouvilleWith.int_mul_iff
theorem int_mul (h : LiouvilleWith p x) (hm : m ≠ 0) : LiouvilleWith p (m * x) :=
(int_mul_iff hm).2 h
#align liouville_with.int_mul LiouvilleWith.int_mul
theorem mul_nat_iff (hn : n ≠ 0) : LiouvilleWith p (x * n) ↔ LiouvilleWith p x := by
rw [← Rat.cast_natCast, mul_rat_iff (Nat.cast_ne_zero.2 hn)]
#align liouville_with.mul_nat_iff LiouvilleWith.mul_nat_iff
theorem mul_nat (h : LiouvilleWith p x) (hn : n ≠ 0) : LiouvilleWith p (x * n) :=
(mul_nat_iff hn).2 h
#align liouville_with.mul_nat LiouvilleWith.mul_nat
theorem nat_mul_iff (hn : n ≠ 0) : LiouvilleWith p (n * x) ↔ LiouvilleWith p x := by
rw [mul_comm, mul_nat_iff hn]
#align liouville_with.nat_mul_iff LiouvilleWith.nat_mul_iff
theorem nat_mul (h : LiouvilleWith p x) (hn : n ≠ 0) : LiouvilleWith p (n * x) := by
rw [mul_comm]; exact h.mul_nat hn
#align liouville_with.nat_mul LiouvilleWith.nat_mul
theorem add_rat (h : LiouvilleWith p x) (r : ℚ) : LiouvilleWith p (x + r) := by
rcases h.exists_pos with ⟨C, _hC₀, hC⟩
refine ⟨r.den ^ p * C, (tendsto_id.nsmul_atTop r.pos).frequently (hC.mono ?_)⟩
rintro n ⟨hn, m, hne, hlt⟩
have : (↑(r.den * m + r.num * n : ℤ) / ↑(r.den • id n) : ℝ) = m / n + r := by
rw [Algebra.id.smul_eq_mul, id]
nth_rewrite 4 [← Rat.num_div_den r]
push_cast
rw [add_div, mul_div_mul_left _ _ (by positivity), mul_div_mul_right _ _ (by positivity)]
refine ⟨r.den * m + r.num * n, ?_⟩; rw [this, add_sub_add_right_eq_sub]
refine ⟨by simpa, hlt.trans_le (le_of_eq ?_)⟩
have : (r.den ^ p : ℝ) ≠ 0 := by positivity
simp [mul_rpow, Nat.cast_nonneg, mul_div_mul_left, this]
#align liouville_with.add_rat LiouvilleWith.add_rat
@[simp]
theorem add_rat_iff : LiouvilleWith p (x + r) ↔ LiouvilleWith p x :=
⟨fun h => by simpa using h.add_rat (-r), fun h => h.add_rat r⟩
#align liouville_with.add_rat_iff LiouvilleWith.add_rat_iff
@[simp]
theorem rat_add_iff : LiouvilleWith p (r + x) ↔ LiouvilleWith p x := by rw [add_comm, add_rat_iff]
#align liouville_with.rat_add_iff LiouvilleWith.rat_add_iff
theorem rat_add (h : LiouvilleWith p x) (r : ℚ) : LiouvilleWith p (r + x) :=
add_comm x r ▸ h.add_rat r
#align liouville_with.rat_add LiouvilleWith.rat_add
@[simp]
theorem add_int_iff : LiouvilleWith p (x + m) ↔ LiouvilleWith p x := by
rw [← Rat.cast_intCast m, add_rat_iff]
#align liouville_with.add_int_iff LiouvilleWith.add_int_iff
@[simp]
theorem int_add_iff : LiouvilleWith p (m + x) ↔ LiouvilleWith p x := by rw [add_comm, add_int_iff]
#align liouville_with.int_add_iff LiouvilleWith.int_add_iff
@[simp]
theorem add_nat_iff : LiouvilleWith p (x + n) ↔ LiouvilleWith p x := by
rw [← Rat.cast_natCast n, add_rat_iff]
#align liouville_with.add_nat_iff LiouvilleWith.add_nat_iff
@[simp]
| Mathlib/NumberTheory/Liouville/LiouvilleWith.lean | 225 | 225 | theorem nat_add_iff : LiouvilleWith p (n + x) ↔ LiouvilleWith p x := by | rw [add_comm, add_nat_iff]
|
import Mathlib.Data.Set.Image
import Mathlib.Data.SProd
#align_import data.set.prod from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
open Function
namespace Set
section Prod
variable {α β γ δ : Type*} {s s₁ s₂ : Set α} {t t₁ t₂ : Set β} {a : α} {b : β}
theorem Subsingleton.prod (hs : s.Subsingleton) (ht : t.Subsingleton) :
(s ×ˢ t).Subsingleton := fun _x hx _y hy ↦
Prod.ext (hs hx.1 hy.1) (ht hx.2 hy.2)
noncomputable instance decidableMemProd [DecidablePred (· ∈ s)] [DecidablePred (· ∈ t)] :
DecidablePred (· ∈ s ×ˢ t) := fun _ => And.decidable
#align set.decidable_mem_prod Set.decidableMemProd
@[gcongr]
theorem prod_mono (hs : s₁ ⊆ s₂) (ht : t₁ ⊆ t₂) : s₁ ×ˢ t₁ ⊆ s₂ ×ˢ t₂ :=
fun _ ⟨h₁, h₂⟩ => ⟨hs h₁, ht h₂⟩
#align set.prod_mono Set.prod_mono
@[gcongr]
theorem prod_mono_left (hs : s₁ ⊆ s₂) : s₁ ×ˢ t ⊆ s₂ ×ˢ t :=
prod_mono hs Subset.rfl
#align set.prod_mono_left Set.prod_mono_left
@[gcongr]
theorem prod_mono_right (ht : t₁ ⊆ t₂) : s ×ˢ t₁ ⊆ s ×ˢ t₂ :=
prod_mono Subset.rfl ht
#align set.prod_mono_right Set.prod_mono_right
@[simp]
theorem prod_self_subset_prod_self : s₁ ×ˢ s₁ ⊆ s₂ ×ˢ s₂ ↔ s₁ ⊆ s₂ :=
⟨fun h _ hx => (h (mk_mem_prod hx hx)).1, fun h _ hx => ⟨h hx.1, h hx.2⟩⟩
#align set.prod_self_subset_prod_self Set.prod_self_subset_prod_self
@[simp]
theorem prod_self_ssubset_prod_self : s₁ ×ˢ s₁ ⊂ s₂ ×ˢ s₂ ↔ s₁ ⊂ s₂ :=
and_congr prod_self_subset_prod_self <| not_congr prod_self_subset_prod_self
#align set.prod_self_ssubset_prod_self Set.prod_self_ssubset_prod_self
theorem prod_subset_iff {P : Set (α × β)} : s ×ˢ t ⊆ P ↔ ∀ x ∈ s, ∀ y ∈ t, (x, y) ∈ P :=
⟨fun h _ hx _ hy => h (mk_mem_prod hx hy), fun h ⟨_, _⟩ hp => h _ hp.1 _ hp.2⟩
#align set.prod_subset_iff Set.prod_subset_iff
theorem forall_prod_set {p : α × β → Prop} : (∀ x ∈ s ×ˢ t, p x) ↔ ∀ x ∈ s, ∀ y ∈ t, p (x, y) :=
prod_subset_iff
#align set.forall_prod_set Set.forall_prod_set
theorem exists_prod_set {p : α × β → Prop} : (∃ x ∈ s ×ˢ t, p x) ↔ ∃ x ∈ s, ∃ y ∈ t, p (x, y) := by
simp [and_assoc]
#align set.exists_prod_set Set.exists_prod_set
@[simp]
theorem prod_empty : s ×ˢ (∅ : Set β) = ∅ := by
ext
exact and_false_iff _
#align set.prod_empty Set.prod_empty
@[simp]
theorem empty_prod : (∅ : Set α) ×ˢ t = ∅ := by
ext
exact false_and_iff _
#align set.empty_prod Set.empty_prod
@[simp, mfld_simps]
theorem univ_prod_univ : @univ α ×ˢ @univ β = univ := by
ext
exact true_and_iff _
#align set.univ_prod_univ Set.univ_prod_univ
theorem univ_prod {t : Set β} : (univ : Set α) ×ˢ t = Prod.snd ⁻¹' t := by simp [prod_eq]
#align set.univ_prod Set.univ_prod
theorem prod_univ {s : Set α} : s ×ˢ (univ : Set β) = Prod.fst ⁻¹' s := by simp [prod_eq]
#align set.prod_univ Set.prod_univ
@[simp] lemma prod_eq_univ [Nonempty α] [Nonempty β] : s ×ˢ t = univ ↔ s = univ ∧ t = univ := by
simp [eq_univ_iff_forall, forall_and]
@[simp]
theorem singleton_prod : ({a} : Set α) ×ˢ t = Prod.mk a '' t := by
ext ⟨x, y⟩
simp [and_left_comm, eq_comm]
#align set.singleton_prod Set.singleton_prod
@[simp]
theorem prod_singleton : s ×ˢ ({b} : Set β) = (fun a => (a, b)) '' s := by
ext ⟨x, y⟩
simp [and_left_comm, eq_comm]
#align set.prod_singleton Set.prod_singleton
theorem singleton_prod_singleton : ({a} : Set α) ×ˢ ({b} : Set β) = {(a, b)} := by simp
#align set.singleton_prod_singleton Set.singleton_prod_singleton
@[simp]
theorem union_prod : (s₁ ∪ s₂) ×ˢ t = s₁ ×ˢ t ∪ s₂ ×ˢ t := by
ext ⟨x, y⟩
simp [or_and_right]
#align set.union_prod Set.union_prod
@[simp]
theorem prod_union : s ×ˢ (t₁ ∪ t₂) = s ×ˢ t₁ ∪ s ×ˢ t₂ := by
ext ⟨x, y⟩
simp [and_or_left]
#align set.prod_union Set.prod_union
theorem inter_prod : (s₁ ∩ s₂) ×ˢ t = s₁ ×ˢ t ∩ s₂ ×ˢ t := by
ext ⟨x, y⟩
simp only [← and_and_right, mem_inter_iff, mem_prod]
#align set.inter_prod Set.inter_prod
theorem prod_inter : s ×ˢ (t₁ ∩ t₂) = s ×ˢ t₁ ∩ s ×ˢ t₂ := by
ext ⟨x, y⟩
simp only [← and_and_left, mem_inter_iff, mem_prod]
#align set.prod_inter Set.prod_inter
@[mfld_simps]
theorem prod_inter_prod : s₁ ×ˢ t₁ ∩ s₂ ×ˢ t₂ = (s₁ ∩ s₂) ×ˢ (t₁ ∩ t₂) := by
ext ⟨x, y⟩
simp [and_assoc, and_left_comm]
#align set.prod_inter_prod Set.prod_inter_prod
lemma compl_prod_eq_union {α β : Type*} (s : Set α) (t : Set β) :
(s ×ˢ t)ᶜ = (sᶜ ×ˢ univ) ∪ (univ ×ˢ tᶜ) := by
ext p
simp only [mem_compl_iff, mem_prod, not_and, mem_union, mem_univ, and_true, true_and]
constructor <;> intro h
· by_cases fst_in_s : p.fst ∈ s
· exact Or.inr (h fst_in_s)
· exact Or.inl fst_in_s
· intro fst_in_s
simpa only [fst_in_s, not_true, false_or] using h
@[simp]
theorem disjoint_prod : Disjoint (s₁ ×ˢ t₁) (s₂ ×ˢ t₂) ↔ Disjoint s₁ s₂ ∨ Disjoint t₁ t₂ := by
simp_rw [disjoint_left, mem_prod, not_and_or, Prod.forall, and_imp, ← @forall_or_right α, ←
@forall_or_left β, ← @forall_or_right (_ ∈ s₁), ← @forall_or_left (_ ∈ t₁)]
#align set.disjoint_prod Set.disjoint_prod
theorem Disjoint.set_prod_left (hs : Disjoint s₁ s₂) (t₁ t₂ : Set β) :
Disjoint (s₁ ×ˢ t₁) (s₂ ×ˢ t₂) :=
disjoint_left.2 fun ⟨_a, _b⟩ ⟨ha₁, _⟩ ⟨ha₂, _⟩ => disjoint_left.1 hs ha₁ ha₂
#align set.disjoint.set_prod_left Set.Disjoint.set_prod_left
theorem Disjoint.set_prod_right (ht : Disjoint t₁ t₂) (s₁ s₂ : Set α) :
Disjoint (s₁ ×ˢ t₁) (s₂ ×ˢ t₂) :=
disjoint_left.2 fun ⟨_a, _b⟩ ⟨_, hb₁⟩ ⟨_, hb₂⟩ => disjoint_left.1 ht hb₁ hb₂
#align set.disjoint.set_prod_right Set.Disjoint.set_prod_right
theorem insert_prod : insert a s ×ˢ t = Prod.mk a '' t ∪ s ×ˢ t := by
ext ⟨x, y⟩
simp (config := { contextual := true }) [image, iff_def, or_imp]
#align set.insert_prod Set.insert_prod
theorem prod_insert : s ×ˢ insert b t = (fun a => (a, b)) '' s ∪ s ×ˢ t := by
ext ⟨x, y⟩
-- porting note (#10745):
-- was `simp (config := { contextual := true }) [image, iff_def, or_imp, Imp.swap]`
simp only [mem_prod, mem_insert_iff, image, mem_union, mem_setOf_eq, Prod.mk.injEq]
refine ⟨fun h => ?_, fun h => ?_⟩
· obtain ⟨hx, rfl|hy⟩ := h
· exact Or.inl ⟨x, hx, rfl, rfl⟩
· exact Or.inr ⟨hx, hy⟩
· obtain ⟨x, hx, rfl, rfl⟩|⟨hx, hy⟩ := h
· exact ⟨hx, Or.inl rfl⟩
· exact ⟨hx, Or.inr hy⟩
#align set.prod_insert Set.prod_insert
theorem prod_preimage_eq {f : γ → α} {g : δ → β} :
(f ⁻¹' s) ×ˢ (g ⁻¹' t) = (fun p : γ × δ => (f p.1, g p.2)) ⁻¹' s ×ˢ t :=
rfl
#align set.prod_preimage_eq Set.prod_preimage_eq
theorem prod_preimage_left {f : γ → α} :
(f ⁻¹' s) ×ˢ t = (fun p : γ × β => (f p.1, p.2)) ⁻¹' s ×ˢ t :=
rfl
#align set.prod_preimage_left Set.prod_preimage_left
theorem prod_preimage_right {g : δ → β} :
s ×ˢ (g ⁻¹' t) = (fun p : α × δ => (p.1, g p.2)) ⁻¹' s ×ˢ t :=
rfl
#align set.prod_preimage_right Set.prod_preimage_right
theorem preimage_prod_map_prod (f : α → β) (g : γ → δ) (s : Set β) (t : Set δ) :
Prod.map f g ⁻¹' s ×ˢ t = (f ⁻¹' s) ×ˢ (g ⁻¹' t) :=
rfl
#align set.preimage_prod_map_prod Set.preimage_prod_map_prod
theorem mk_preimage_prod (f : γ → α) (g : γ → β) :
(fun x => (f x, g x)) ⁻¹' s ×ˢ t = f ⁻¹' s ∩ g ⁻¹' t :=
rfl
#align set.mk_preimage_prod Set.mk_preimage_prod
@[simp]
theorem mk_preimage_prod_left (hb : b ∈ t) : (fun a => (a, b)) ⁻¹' s ×ˢ t = s := by
ext a
simp [hb]
#align set.mk_preimage_prod_left Set.mk_preimage_prod_left
@[simp]
theorem mk_preimage_prod_right (ha : a ∈ s) : Prod.mk a ⁻¹' s ×ˢ t = t := by
ext b
simp [ha]
#align set.mk_preimage_prod_right Set.mk_preimage_prod_right
@[simp]
theorem mk_preimage_prod_left_eq_empty (hb : b ∉ t) : (fun a => (a, b)) ⁻¹' s ×ˢ t = ∅ := by
ext a
simp [hb]
#align set.mk_preimage_prod_left_eq_empty Set.mk_preimage_prod_left_eq_empty
@[simp]
theorem mk_preimage_prod_right_eq_empty (ha : a ∉ s) : Prod.mk a ⁻¹' s ×ˢ t = ∅ := by
ext b
simp [ha]
#align set.mk_preimage_prod_right_eq_empty Set.mk_preimage_prod_right_eq_empty
theorem mk_preimage_prod_left_eq_if [DecidablePred (· ∈ t)] :
(fun a => (a, b)) ⁻¹' s ×ˢ t = if b ∈ t then s else ∅ := by split_ifs with h <;> simp [h]
#align set.mk_preimage_prod_left_eq_if Set.mk_preimage_prod_left_eq_if
theorem mk_preimage_prod_right_eq_if [DecidablePred (· ∈ s)] :
Prod.mk a ⁻¹' s ×ˢ t = if a ∈ s then t else ∅ := by split_ifs with h <;> simp [h]
#align set.mk_preimage_prod_right_eq_if Set.mk_preimage_prod_right_eq_if
| Mathlib/Data/Set/Prod.lean | 256 | 258 | theorem mk_preimage_prod_left_fn_eq_if [DecidablePred (· ∈ t)] (f : γ → α) :
(fun a => (f a, b)) ⁻¹' s ×ˢ t = if b ∈ t then f ⁻¹' s else ∅ := by |
rw [← mk_preimage_prod_left_eq_if, prod_preimage_left, preimage_preimage]
|
import Mathlib.AlgebraicGeometry.AffineScheme
import Mathlib.AlgebraicGeometry.Pullbacks
import Mathlib.CategoryTheory.MorphismProperty.Limits
import Mathlib.Data.List.TFAE
#align_import algebraic_geometry.morphisms.basic from "leanprover-community/mathlib"@"434e2fd21c1900747afc6d13d8be7f4eedba7218"
set_option linter.uppercaseLean3 false
universe u
open TopologicalSpace CategoryTheory CategoryTheory.Limits Opposite
noncomputable section
namespace AlgebraicGeometry
def AffineTargetMorphismProperty :=
∀ ⦃X Y : Scheme⦄ (_ : X ⟶ Y) [IsAffine Y], Prop
#align algebraic_geometry.affine_target_morphism_property AlgebraicGeometry.AffineTargetMorphismProperty
protected def Scheme.isIso : MorphismProperty Scheme :=
@IsIso Scheme _
#align algebraic_geometry.Scheme.is_iso AlgebraicGeometry.Scheme.isIso
protected def Scheme.affineTargetIsIso : AffineTargetMorphismProperty := fun _ _ f _ => IsIso f
#align algebraic_geometry.Scheme.affine_target_is_iso AlgebraicGeometry.Scheme.affineTargetIsIso
instance : Inhabited AffineTargetMorphismProperty := ⟨Scheme.affineTargetIsIso⟩
def AffineTargetMorphismProperty.toProperty (P : AffineTargetMorphismProperty) :
MorphismProperty Scheme := fun _ _ f => ∃ h, @P _ _ f h
#align algebraic_geometry.affine_target_morphism_property.to_property AlgebraicGeometry.AffineTargetMorphismProperty.toProperty
theorem AffineTargetMorphismProperty.toProperty_apply (P : AffineTargetMorphismProperty)
{X Y : Scheme} (f : X ⟶ Y) [i : IsAffine Y] : P.toProperty f ↔ P f := by
delta AffineTargetMorphismProperty.toProperty; simp [*]
#align algebraic_geometry.affine_target_morphism_property.to_property_apply AlgebraicGeometry.AffineTargetMorphismProperty.toProperty_apply
theorem affine_cancel_left_isIso {P : AffineTargetMorphismProperty} (hP : P.toProperty.RespectsIso)
{X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso f] [IsAffine Z] : P (f ≫ g) ↔ P g := by
rw [← P.toProperty_apply, ← P.toProperty_apply, hP.cancel_left_isIso]
#align algebraic_geometry.affine_cancel_left_is_iso AlgebraicGeometry.affine_cancel_left_isIso
theorem affine_cancel_right_isIso {P : AffineTargetMorphismProperty} (hP : P.toProperty.RespectsIso)
{X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso g] [IsAffine Z] [IsAffine Y] :
P (f ≫ g) ↔ P f := by rw [← P.toProperty_apply, ← P.toProperty_apply, hP.cancel_right_isIso]
#align algebraic_geometry.affine_cancel_right_is_iso AlgebraicGeometry.affine_cancel_right_isIso
theorem AffineTargetMorphismProperty.respectsIso_mk {P : AffineTargetMorphismProperty}
(h₁ : ∀ {X Y Z} (e : X ≅ Y) (f : Y ⟶ Z) [IsAffine Z], P f → P (e.hom ≫ f))
(h₂ : ∀ {X Y Z} (e : Y ≅ Z) (f : X ⟶ Y) [h : IsAffine Y],
P f → @P _ _ (f ≫ e.hom) (isAffineOfIso e.inv)) :
P.toProperty.RespectsIso := by
constructor
· rintro X Y Z e f ⟨a, h⟩; exact ⟨a, h₁ e f h⟩
· rintro X Y Z e f ⟨a, h⟩; exact ⟨isAffineOfIso e.inv, h₂ e f h⟩
#align algebraic_geometry.affine_target_morphism_property.respects_iso_mk AlgebraicGeometry.AffineTargetMorphismProperty.respectsIso_mk
def targetAffineLocally (P : AffineTargetMorphismProperty) : MorphismProperty Scheme :=
fun {X Y : Scheme} (f : X ⟶ Y) => ∀ U : Y.affineOpens, @P _ _ (f ∣_ U) U.prop
#align algebraic_geometry.target_affine_locally AlgebraicGeometry.targetAffineLocally
theorem IsAffineOpen.map_isIso {X Y : Scheme} {U : Opens Y.carrier} (hU : IsAffineOpen U)
(f : X ⟶ Y) [IsIso f] : IsAffineOpen ((Opens.map f.1.base).obj U) :=
haveI : IsAffine _ := hU
isAffineOfIso (f ∣_ U)
#align algebraic_geometry.is_affine_open.map_is_iso AlgebraicGeometry.IsAffineOpen.map_isIso
theorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}
(hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso := by
constructor
· introv H U
rw [morphismRestrict_comp, affine_cancel_left_isIso hP]
exact H U
· introv H
rintro ⟨U, hU : IsAffineOpen U⟩; dsimp
haveI : IsAffine _ := hU.map_isIso e.hom
rw [morphismRestrict_comp, affine_cancel_right_isIso hP]
exact H ⟨(Opens.map e.hom.val.base).obj U, hU.map_isIso e.hom⟩
#align algebraic_geometry.target_affine_locally_respects_iso AlgebraicGeometry.targetAffineLocally_respectsIso
structure AffineTargetMorphismProperty.IsLocal (P : AffineTargetMorphismProperty) : Prop where
RespectsIso : P.toProperty.RespectsIso
toBasicOpen :
∀ {X Y : Scheme} [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj <| op ⊤),
P f → @P _ _ (f ∣_ Y.basicOpen r) ((topIsAffineOpen Y).basicOpenIsAffine _)
ofBasicOpenCover :
∀ {X Y : Scheme} [IsAffine Y] (f : X ⟶ Y) (s : Finset (Y.presheaf.obj <| op ⊤))
(_ : Ideal.span (s : Set (Y.presheaf.obj <| op ⊤)) = ⊤),
(∀ r : s, @P _ _ (f ∣_ Y.basicOpen r.1) ((topIsAffineOpen Y).basicOpenIsAffine _)) → P f
#align algebraic_geometry.affine_target_morphism_property.is_local AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal
@[local simp] lemma CommRingCat.id_apply (R : CommRingCat) (x : R) : 𝟙 R x = x := rfl
theorem targetAffineLocallyOfOpenCover {P : AffineTargetMorphismProperty} (hP : P.IsLocal)
{X Y : Scheme} (f : X ⟶ Y) (𝒰 : Y.OpenCover) [∀ i, IsAffine (𝒰.obj i)]
(h𝒰 : ∀ i, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i)) :
targetAffineLocally P f := by
classical
let S i := (⟨⟨Set.range (𝒰.map i).1.base, (𝒰.IsOpen i).base_open.isOpen_range⟩,
rangeIsAffineOpenOfOpenImmersion (𝒰.map i)⟩ : Y.affineOpens)
intro U
apply of_affine_open_cover (P := _) U (Set.range S)
· intro U r h
haveI : IsAffine _ := U.2
have := hP.2 (f ∣_ U.1)
replace this := this (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op r) h
rw [← P.toProperty_apply] at this ⊢
exact (hP.1.arrow_mk_iso_iff (morphismRestrictRestrictBasicOpen f _ r)).mp this
· intro U s hs H
haveI : IsAffine _ := U.2
apply hP.3 (f ∣_ U.1) (s.image (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op))
· apply_fun Ideal.comap (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top.symm).op) at hs
rw [Ideal.comap_top] at hs
rw [← hs]
simp only [eqToHom_op, eqToHom_map, Finset.coe_image]
have : ∀ {R S : CommRingCat} (e : S = R) (s : Set S),
Ideal.span (eqToHom e '' s) = Ideal.comap (eqToHom e.symm) (Ideal.span s) := by
intro _ S e _
subst e
simp only [eqToHom_refl, CommRingCat.id_apply, Set.image_id']
-- Porting note: Lean didn't see `𝟙 _` is just ring hom id
exact (Ideal.comap_id _).symm
apply this
· rintro ⟨r, hr⟩
obtain ⟨r, hr', rfl⟩ := Finset.mem_image.mp hr
specialize H ⟨r, hr'⟩
rw [← P.toProperty_apply] at H ⊢
exact (hP.1.arrow_mk_iso_iff (morphismRestrictRestrictBasicOpen f _ r)).mpr H
· rw [Set.eq_univ_iff_forall]
simp only [Set.mem_iUnion]
intro x
exact ⟨⟨_, ⟨𝒰.f x, rfl⟩⟩, 𝒰.Covers x⟩
· rintro ⟨_, i, rfl⟩
specialize h𝒰 i
rw [← P.toProperty_apply] at h𝒰 ⊢
exact (hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)).mpr h𝒰
#align algebraic_geometry.target_affine_locally_of_open_cover AlgebraicGeometry.targetAffineLocallyOfOpenCover
open List in
theorem AffineTargetMorphismProperty.IsLocal.affine_openCover_TFAE
{P : AffineTargetMorphismProperty} (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) :
TFAE
[targetAffineLocally P f,
∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)),
∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
∀ (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)] (i : 𝒰.J),
P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
∀ {U : Scheme} (g : U ⟶ Y) [IsAffine U] [IsOpenImmersion g],
P (pullback.snd : pullback f g ⟶ U),
∃ (ι : Type u) (U : ι → Opens Y.carrier) (_ : iSup U = ⊤) (hU' : ∀ i, IsAffineOpen (U i)),
∀ i, @P _ _ (f ∣_ U i) (hU' i)] := by
tfae_have 1 → 4
· intro H U g h₁ h₂
replace H := H ⟨⟨_, h₂.base_open.isOpen_range⟩, rangeIsAffineOpenOfOpenImmersion g⟩
rw [← P.toProperty_apply] at H ⊢
rwa [← hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
tfae_have 4 → 3
· intro H 𝒰 h𝒰 i
apply H
tfae_have 3 → 2
· exact fun H => ⟨Y.affineCover, inferInstance, H Y.affineCover⟩
tfae_have 2 → 1
· rintro ⟨𝒰, h𝒰, H⟩; exact targetAffineLocallyOfOpenCover hP f 𝒰 H
tfae_have 5 → 2
· rintro ⟨ι, U, hU, hU', H⟩
refine ⟨Y.openCoverOfSuprEqTop U hU, hU', ?_⟩
intro i
specialize H i
rw [← P.toProperty_apply, ← hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
rw [← P.toProperty_apply] at H
convert H
all_goals ext1; exact Subtype.range_coe
tfae_have 1 → 5
· intro H
refine ⟨Y.carrier, fun x => (Scheme.Hom.opensRange <| Y.affineCover.map x),
?_, fun i => rangeIsAffineOpenOfOpenImmersion _, ?_⟩
· rw [eq_top_iff]; intro x _; erw [Opens.mem_iSup]; exact ⟨x, Y.affineCover.Covers x⟩
· intro i; exact H ⟨_, rangeIsAffineOpenOfOpenImmersion _⟩
tfae_finish
#align algebraic_geometry.affine_target_morphism_property.is_local.affine_open_cover_tfae AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.affine_openCover_TFAE
theorem AffineTargetMorphismProperty.isLocalOfOpenCoverImply (P : AffineTargetMorphismProperty)
(hP : P.toProperty.RespectsIso)
(H : ∀ {X Y : Scheme.{u}} (f : X ⟶ Y),
(∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)),
∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i)) →
∀ {U : Scheme} (g : U ⟶ Y) [IsAffine U] [IsOpenImmersion g],
P (pullback.snd : pullback f g ⟶ U)) :
P.IsLocal := by
refine ⟨hP, ?_, ?_⟩
· introv h
haveI : IsAffine _ := (topIsAffineOpen Y).basicOpenIsAffine r
delta morphismRestrict
rw [affine_cancel_left_isIso hP]
refine @H _ _ f ⟨Scheme.openCoverOfIsIso (𝟙 Y), ?_, ?_⟩ _ (Y.ofRestrict _) _ _
· intro i; dsimp; infer_instance
· intro i; dsimp
rwa [← Category.comp_id pullback.snd, ← pullback.condition, affine_cancel_left_isIso hP]
· introv hs hs'
replace hs := ((topIsAffineOpen Y).basicOpen_union_eq_self_iff _).mpr hs
have := H f ⟨Y.openCoverOfSuprEqTop _ hs, ?_, ?_⟩ (𝟙 _)
· rwa [← Category.comp_id pullback.snd, ← pullback.condition, affine_cancel_left_isIso hP]
at this
· intro i; exact (topIsAffineOpen Y).basicOpenIsAffine _
· rintro (i : s)
specialize hs' i
haveI : IsAffine _ := (topIsAffineOpen Y).basicOpenIsAffine i.1
delta morphismRestrict at hs'
rwa [affine_cancel_left_isIso hP] at hs'
#align algebraic_geometry.affine_target_morphism_property.is_local_of_open_cover_imply AlgebraicGeometry.AffineTargetMorphismProperty.isLocalOfOpenCoverImply
theorem AffineTargetMorphismProperty.IsLocal.affine_openCover_iff {P : AffineTargetMorphismProperty}
(hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y)
[h𝒰 : ∀ i, IsAffine (𝒰.obj i)] :
targetAffineLocally P f ↔ ∀ i, @P _ _ (pullback.snd : pullback f (𝒰.map i) ⟶ _) (h𝒰 i) := by
refine ⟨fun H => let h := ((hP.affine_openCover_TFAE f).out 0 2).mp H; ?_,
fun H => let h := ((hP.affine_openCover_TFAE f).out 1 0).mp; ?_⟩
· exact fun i => h 𝒰 i
· exact h ⟨𝒰, inferInstance, H⟩
#align algebraic_geometry.affine_target_morphism_property.is_local.affine_open_cover_iff AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.affine_openCover_iff
theorem AffineTargetMorphismProperty.IsLocal.affine_target_iff {P : AffineTargetMorphismProperty}
(hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) [IsAffine Y] :
targetAffineLocally P f ↔ P f := by
haveI : ∀ i, IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 Y)) i) := fun i => by
dsimp; infer_instance
rw [hP.affine_openCover_iff f (Scheme.openCoverOfIsIso (𝟙 Y))]
trans P (pullback.snd : pullback f (𝟙 _) ⟶ _)
· exact ⟨fun H => H PUnit.unit, fun H _ => H⟩
rw [← Category.comp_id pullback.snd, ← pullback.condition, affine_cancel_left_isIso hP.1]
#align algebraic_geometry.affine_target_morphism_property.is_local.affine_target_iff AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.affine_target_iff
structure PropertyIsLocalAtTarget (P : MorphismProperty Scheme) : Prop where
RespectsIso : P.RespectsIso
restrict : ∀ {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y.carrier), P f → P (f ∣_ U)
of_openCover :
∀ {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y),
(∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i)) → P f
#align algebraic_geometry.property_is_local_at_target AlgebraicGeometry.PropertyIsLocalAtTarget
lemma propertyIsLocalAtTarget_of_morphismRestrict (P : MorphismProperty Scheme)
(hP₁ : P.RespectsIso)
(hP₂ : ∀ {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Opens Y.carrier), P f → P (f ∣_ U))
(hP₃ : ∀ {X Y : Scheme.{u}} (f : X ⟶ Y) {ι : Type u} (U : ι → Opens Y.carrier)
(_ : iSup U = ⊤), (∀ i, P (f ∣_ U i)) → P f) :
PropertyIsLocalAtTarget P where
RespectsIso := hP₁
restrict := hP₂
of_openCover {X Y} f 𝒰 h𝒰 := by
apply hP₃ f (fun i : 𝒰.J => Scheme.Hom.opensRange (𝒰.map i)) 𝒰.iSup_opensRange
simp_rw [hP₁.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
exact h𝒰
theorem AffineTargetMorphismProperty.IsLocal.targetAffineLocallyIsLocal
{P : AffineTargetMorphismProperty} (hP : P.IsLocal) :
PropertyIsLocalAtTarget (targetAffineLocally P) := by
constructor
· exact targetAffineLocally_respectsIso hP.1
· intro X Y f U H V
rw [← P.toProperty_apply (i := V.2), hP.1.arrow_mk_iso_iff (morphismRestrictRestrict f _ _)]
convert H ⟨_, IsAffineOpen.imageIsOpenImmersion V.2 (Y.ofRestrict _)⟩
rw [← P.toProperty_apply]
· rintro X Y f 𝒰 h𝒰
-- Porting note: rewrite `[(hP.affine_openCover_TFAE f).out 0 1` directly complains about
-- metavariables
have h01 := (hP.affine_openCover_TFAE f).out 0 1
rw [h01]
refine ⟨𝒰.bind fun _ => Scheme.affineCover _, ?_, ?_⟩
· intro i; dsimp [Scheme.OpenCover.bind]; infer_instance
· intro i
specialize h𝒰 i.1
-- Porting note: rewrite `[(hP.affine_openCover_TFAE pullback.snd).out 0 1` directly
-- complains about metavariables
have h02 := (hP.affine_openCover_TFAE (pullback.snd : pullback f (𝒰.map i.fst) ⟶ _)).out 0 2
rw [h02] at h𝒰
specialize h𝒰 (Scheme.affineCover _) i.2
let e : pullback f ((𝒰.obj i.fst).affineCover.map i.snd ≫ 𝒰.map i.fst) ⟶
pullback (pullback.snd : pullback f (𝒰.map i.fst) ⟶ _)
((𝒰.obj i.fst).affineCover.map i.snd) := by
refine (pullbackSymmetry _ _).hom ≫ ?_
refine (pullbackRightPullbackFstIso _ _ _).inv ≫ ?_
refine (pullbackSymmetry _ _).hom ≫ ?_
refine pullback.map _ _ _ _ (pullbackSymmetry _ _).hom (𝟙 _) (𝟙 _) ?_ ?_ <;>
simp only [Category.comp_id, Category.id_comp, pullbackSymmetry_hom_comp_snd]
rw [← affine_cancel_left_isIso hP.1 e] at h𝒰
convert h𝒰 using 1
simp [e]
#align algebraic_geometry.affine_target_morphism_property.is_local.target_affine_locally_is_local AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.targetAffineLocallyIsLocal
open List in
theorem PropertyIsLocalAtTarget.openCover_TFAE {P : MorphismProperty Scheme}
(hP : PropertyIsLocalAtTarget P) {X Y : Scheme.{u}} (f : X ⟶ Y) :
TFAE
[P f,
∃ 𝒰 : Scheme.OpenCover.{u} Y,
∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
∀ (𝒰 : Scheme.OpenCover.{u} Y) (i : 𝒰.J),
P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
∀ U : Opens Y.carrier, P (f ∣_ U),
∀ {U : Scheme} (g : U ⟶ Y) [IsOpenImmersion g], P (pullback.snd : pullback f g ⟶ U),
∃ (ι : Type u) (U : ι → Opens Y.carrier) (_ : iSup U = ⊤), ∀ i, P (f ∣_ U i)] := by
tfae_have 2 → 1
· rintro ⟨𝒰, H⟩; exact hP.3 f 𝒰 H
tfae_have 1 → 4
· intro H U; exact hP.2 f U H
tfae_have 4 → 3
· intro H 𝒰 i
rw [← hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
exact H <| Scheme.Hom.opensRange (𝒰.map i)
tfae_have 3 → 2
· exact fun H => ⟨Y.affineCover, H Y.affineCover⟩
tfae_have 4 → 5
· intro H U g hg
rw [← hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
apply H
tfae_have 5 → 4
· intro H U
erw [hP.1.cancel_left_isIso]
apply H
tfae_have 4 → 6
· intro H; exact ⟨PUnit, fun _ => ⊤, ciSup_const, fun _ => H _⟩
tfae_have 6 → 2
· rintro ⟨ι, U, hU, H⟩
refine ⟨Y.openCoverOfSuprEqTop U hU, ?_⟩
intro i
rw [← hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
convert H i
all_goals ext1; exact Subtype.range_coe
tfae_finish
#align algebraic_geometry.property_is_local_at_target.open_cover_tfae AlgebraicGeometry.PropertyIsLocalAtTarget.openCover_TFAE
theorem PropertyIsLocalAtTarget.openCover_iff {P : MorphismProperty Scheme}
(hP : PropertyIsLocalAtTarget P) {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y) :
P f ↔ ∀ i, P (pullback.snd : pullback f (𝒰.map i) ⟶ _) := by
-- Porting note: couldn't get the term mode proof work
refine ⟨fun H => let h := ((hP.openCover_TFAE f).out 0 2).mp H; fun i => ?_,
fun H => let h := ((hP.openCover_TFAE f).out 1 0).mp; ?_⟩
· exact h 𝒰 i
· exact h ⟨𝒰, H⟩
#align algebraic_geometry.property_is_local_at_target.open_cover_iff AlgebraicGeometry.PropertyIsLocalAtTarget.openCover_iff
def AffineTargetMorphismProperty.diagonal (P : AffineTargetMorphismProperty) :
AffineTargetMorphismProperty :=
fun {X _} f _ =>
∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [IsAffine U₁] [IsAffine U₂] [IsOpenImmersion f₁]
[IsOpenImmersion f₂], P (pullback.mapDesc f₁ f₂ f)
#align algebraic_geometry.affine_target_morphism_property.diagonal AlgebraicGeometry.AffineTargetMorphismProperty.diagonal
theorem AffineTargetMorphismProperty.diagonal_respectsIso (P : AffineTargetMorphismProperty)
(hP : P.toProperty.RespectsIso) : P.diagonal.toProperty.RespectsIso := by
delta AffineTargetMorphismProperty.diagonal
apply AffineTargetMorphismProperty.respectsIso_mk
· introv H _ _
rw [pullback.mapDesc_comp, affine_cancel_left_isIso hP, affine_cancel_right_isIso hP]
-- Porting note: add the following two instances
have i1 : IsOpenImmersion (f₁ ≫ e.hom) := PresheafedSpace.IsOpenImmersion.comp _ _
have i2 : IsOpenImmersion (f₂ ≫ e.hom) := PresheafedSpace.IsOpenImmersion.comp _ _
apply H
· introv H _ _
-- Porting note: add the following two instances
have _ : IsAffine Z := isAffineOfIso e.inv
rw [pullback.mapDesc_comp, affine_cancel_right_isIso hP]
apply H
#align algebraic_geometry.affine_target_morphism_property.diagonal_respects_iso AlgebraicGeometry.AffineTargetMorphismProperty.diagonal_respectsIso
theorem diagonalTargetAffineLocallyOfOpenCover (P : AffineTargetMorphismProperty) (hP : P.IsLocal)
{X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)]
(𝒰' : ∀ i, Scheme.OpenCover.{u} (pullback f (𝒰.map i))) [∀ i j, IsAffine ((𝒰' i).obj j)]
(h𝒰' : ∀ i j k, P (pullback.mapDesc ((𝒰' i).map j) ((𝒰' i).map k) pullback.snd)) :
(targetAffineLocally P).diagonal f := by
let 𝒱 := (Scheme.Pullback.openCoverOfBase 𝒰 f f).bind fun i =>
Scheme.Pullback.openCoverOfLeftRight.{u} (𝒰' i) (𝒰' i) pullback.snd pullback.snd
have i1 : ∀ i, IsAffine (𝒱.obj i) := fun i => by dsimp [𝒱]; infer_instance
apply (hP.affine_openCover_iff _ 𝒱).mpr
rintro ⟨i, j, k⟩
dsimp [𝒱]
convert (affine_cancel_left_isIso hP.1
(pullbackDiagonalMapIso _ _ ((𝒰' i).map j) ((𝒰' i).map k)).inv pullback.snd).mp _
pick_goal 3
· convert h𝒰' i j k; apply pullback.hom_ext <;> simp
all_goals apply pullback.hom_ext <;>
simp only [Category.assoc, pullback.lift_fst, pullback.lift_snd, pullback.lift_fst_assoc,
pullback.lift_snd_assoc]
#align algebraic_geometry.diagonal_target_affine_locally_of_open_cover AlgebraicGeometry.diagonalTargetAffineLocallyOfOpenCover
theorem AffineTargetMorphismProperty.diagonalOfTargetAffineLocally
(P : AffineTargetMorphismProperty) (hP : P.IsLocal) {X Y U : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y)
[IsAffine U] [IsOpenImmersion g] (H : (targetAffineLocally P).diagonal f) :
P.diagonal (pullback.snd : pullback f g ⟶ _) := by
rintro U V f₁ f₂ hU hV hf₁ hf₂
replace H := ((hP.affine_openCover_TFAE (pullback.diagonal f)).out 0 3).mp H
let g₁ := pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f
(f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst) g
(by rw [Category.assoc, Category.assoc, pullback.condition])
(by rw [Category.assoc, Category.assoc, pullback.condition])
specialize H g₁
rw [← affine_cancel_left_isIso hP.1 (pullbackDiagonalMapIso f _ f₁ f₂).hom]
convert H
apply pullback.hom_ext <;>
simp only [Category.assoc, pullback.lift_fst, pullback.lift_snd, pullback.lift_fst_assoc,
pullback.lift_snd_assoc, Category.comp_id, pullbackDiagonalMapIso_hom_fst,
pullbackDiagonalMapIso_hom_snd]
#align algebraic_geometry.affine_target_morphism_property.diagonal_of_target_affine_locally AlgebraicGeometry.AffineTargetMorphismProperty.diagonalOfTargetAffineLocally
open List in
theorem AffineTargetMorphismProperty.IsLocal.diagonal_affine_openCover_TFAE
{P : AffineTargetMorphismProperty} (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) :
TFAE
[(targetAffineLocally P).diagonal f,
∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)),
∀ i : 𝒰.J, P.diagonal (pullback.snd : pullback f (𝒰.map i) ⟶ _),
∀ (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)] (i : 𝒰.J),
P.diagonal (pullback.snd : pullback f (𝒰.map i) ⟶ _),
∀ {U : Scheme} (g : U ⟶ Y) [IsAffine U] [IsOpenImmersion g],
P.diagonal (pullback.snd : pullback f g ⟶ _),
∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)) (𝒰' :
∀ i, Scheme.OpenCover.{u} (pullback f (𝒰.map i))) (_ : ∀ i j, IsAffine ((𝒰' i).obj j)),
∀ i j k, P (pullback.mapDesc ((𝒰' i).map j) ((𝒰' i).map k) pullback.snd)] := by
tfae_have 1 → 4
· introv H hU hg _ _; apply P.diagonalOfTargetAffineLocally <;> assumption
tfae_have 4 → 3
· introv H h𝒰; apply H
tfae_have 3 → 2
· exact fun H => ⟨Y.affineCover, inferInstance, H Y.affineCover⟩
tfae_have 2 → 5
· rintro ⟨𝒰, h𝒰, H⟩
refine ⟨𝒰, inferInstance, fun _ => Scheme.affineCover _, inferInstance, ?_⟩
intro i j k
apply H
tfae_have 5 → 1
· rintro ⟨𝒰, _, 𝒰', _, H⟩
exact diagonalTargetAffineLocallyOfOpenCover P hP f 𝒰 𝒰' H
tfae_finish
#align algebraic_geometry.affine_target_morphism_property.is_local.diagonal_affine_open_cover_tfae AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.diagonal_affine_openCover_TFAE
theorem AffineTargetMorphismProperty.IsLocal.diagonal {P : AffineTargetMorphismProperty}
(hP : P.IsLocal) : P.diagonal.IsLocal :=
AffineTargetMorphismProperty.isLocalOfOpenCoverImply P.diagonal (P.diagonal_respectsIso hP.1)
fun {_ _} f => ((hP.diagonal_affine_openCover_TFAE f).out 1 3).mp
#align algebraic_geometry.affine_target_morphism_property.is_local.diagonal AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.diagonal
theorem diagonal_targetAffineLocally_eq_targetAffineLocally (P : AffineTargetMorphismProperty)
(hP : P.IsLocal) : (targetAffineLocally P).diagonal = targetAffineLocally P.diagonal := by
ext _ _ f
exact ((hP.diagonal_affine_openCover_TFAE f).out 0 1).trans
((hP.diagonal.affine_openCover_TFAE f).out 1 0)
#align algebraic_geometry.diagonal_target_affine_locally_eq_target_affine_locally AlgebraicGeometry.diagonal_targetAffineLocally_eq_targetAffineLocally
| Mathlib/AlgebraicGeometry/Morphisms/Basic.lean | 590 | 605 | theorem universallyIsLocalAtTarget (P : MorphismProperty Scheme)
(hP : ∀ {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y),
(∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i)) → P f) :
PropertyIsLocalAtTarget P.universally := by |
refine ⟨P.universally_respectsIso, fun {X Y} f U =>
P.universally_stableUnderBaseChange (isPullback_morphismRestrict f U).flip, ?_⟩
intro X Y f 𝒰 h X' Y' i₁ i₂ f' H
apply hP _ (𝒰.pullbackCover i₂)
intro i
dsimp
apply h i (pullback.lift (pullback.fst ≫ i₁) (pullback.snd ≫ pullback.snd) _) pullback.snd
swap
· rw [Category.assoc, Category.assoc, ← pullback.condition, ← pullback.condition_assoc, H.w]
refine (IsPullback.of_right ?_ (pullback.lift_snd _ _ _) (IsPullback.of_hasPullback _ _)).flip
rw [pullback.lift_fst, ← pullback.condition]
exact (IsPullback.of_hasPullback _ _).paste_horiz H.flip
|
import Mathlib.Topology.Compactness.SigmaCompact
import Mathlib.Topology.Connected.TotallyDisconnected
import Mathlib.Topology.Inseparable
#align_import topology.separation from "leanprover-community/mathlib"@"d91e7f7a7f1c7e9f0e18fdb6bde4f652004c735d"
open Function Set Filter Topology TopologicalSpace
open scoped Classical
universe u v
variable {X : Type*} {Y : Type*} [TopologicalSpace X]
section Separation
def SeparatedNhds : Set X → Set X → Prop := fun s t : Set X =>
∃ U V : Set X, IsOpen U ∧ IsOpen V ∧ s ⊆ U ∧ t ⊆ V ∧ Disjoint U V
#align separated_nhds SeparatedNhds
theorem separatedNhds_iff_disjoint {s t : Set X} : SeparatedNhds s t ↔ Disjoint (𝓝ˢ s) (𝓝ˢ t) := by
simp only [(hasBasis_nhdsSet s).disjoint_iff (hasBasis_nhdsSet t), SeparatedNhds, exists_prop, ←
exists_and_left, and_assoc, and_comm, and_left_comm]
#align separated_nhds_iff_disjoint separatedNhds_iff_disjoint
alias ⟨SeparatedNhds.disjoint_nhdsSet, _⟩ := separatedNhds_iff_disjoint
class T0Space (X : Type u) [TopologicalSpace X] : Prop where
t0 : ∀ ⦃x y : X⦄, Inseparable x y → x = y
#align t0_space T0Space
theorem t0Space_iff_inseparable (X : Type u) [TopologicalSpace X] :
T0Space X ↔ ∀ x y : X, Inseparable x y → x = y :=
⟨fun ⟨h⟩ => h, fun h => ⟨h⟩⟩
#align t0_space_iff_inseparable t0Space_iff_inseparable
theorem t0Space_iff_not_inseparable (X : Type u) [TopologicalSpace X] :
T0Space X ↔ Pairwise fun x y : X => ¬Inseparable x y := by
simp only [t0Space_iff_inseparable, Ne, not_imp_not, Pairwise]
#align t0_space_iff_not_inseparable t0Space_iff_not_inseparable
theorem Inseparable.eq [T0Space X] {x y : X} (h : Inseparable x y) : x = y :=
T0Space.t0 h
#align inseparable.eq Inseparable.eq
protected theorem Inducing.injective [TopologicalSpace Y] [T0Space X] {f : X → Y}
(hf : Inducing f) : Injective f := fun _ _ h =>
(hf.inseparable_iff.1 <| .of_eq h).eq
#align inducing.injective Inducing.injective
protected theorem Inducing.embedding [TopologicalSpace Y] [T0Space X] {f : X → Y}
(hf : Inducing f) : Embedding f :=
⟨hf, hf.injective⟩
#align inducing.embedding Inducing.embedding
lemma embedding_iff_inducing [TopologicalSpace Y] [T0Space X] {f : X → Y} :
Embedding f ↔ Inducing f :=
⟨Embedding.toInducing, Inducing.embedding⟩
#align embedding_iff_inducing embedding_iff_inducing
theorem t0Space_iff_nhds_injective (X : Type u) [TopologicalSpace X] :
T0Space X ↔ Injective (𝓝 : X → Filter X) :=
t0Space_iff_inseparable X
#align t0_space_iff_nhds_injective t0Space_iff_nhds_injective
theorem nhds_injective [T0Space X] : Injective (𝓝 : X → Filter X) :=
(t0Space_iff_nhds_injective X).1 ‹_›
#align nhds_injective nhds_injective
theorem inseparable_iff_eq [T0Space X] {x y : X} : Inseparable x y ↔ x = y :=
nhds_injective.eq_iff
#align inseparable_iff_eq inseparable_iff_eq
@[simp]
theorem nhds_eq_nhds_iff [T0Space X] {a b : X} : 𝓝 a = 𝓝 b ↔ a = b :=
nhds_injective.eq_iff
#align nhds_eq_nhds_iff nhds_eq_nhds_iff
@[simp]
theorem inseparable_eq_eq [T0Space X] : Inseparable = @Eq X :=
funext₂ fun _ _ => propext inseparable_iff_eq
#align inseparable_eq_eq inseparable_eq_eq
theorem TopologicalSpace.IsTopologicalBasis.inseparable_iff {b : Set (Set X)}
(hb : IsTopologicalBasis b) {x y : X} : Inseparable x y ↔ ∀ s ∈ b, (x ∈ s ↔ y ∈ s) :=
⟨fun h s hs ↦ inseparable_iff_forall_open.1 h _ (hb.isOpen hs),
fun h ↦ hb.nhds_hasBasis.eq_of_same_basis <| by
convert hb.nhds_hasBasis using 2
exact and_congr_right (h _)⟩
theorem TopologicalSpace.IsTopologicalBasis.eq_iff [T0Space X] {b : Set (Set X)}
(hb : IsTopologicalBasis b) {x y : X} : x = y ↔ ∀ s ∈ b, (x ∈ s ↔ y ∈ s) :=
inseparable_iff_eq.symm.trans hb.inseparable_iff
theorem t0Space_iff_exists_isOpen_xor'_mem (X : Type u) [TopologicalSpace X] :
T0Space X ↔ Pairwise fun x y => ∃ U : Set X, IsOpen U ∧ Xor' (x ∈ U) (y ∈ U) := by
simp only [t0Space_iff_not_inseparable, xor_iff_not_iff, not_forall, exists_prop,
inseparable_iff_forall_open, Pairwise]
#align t0_space_iff_exists_is_open_xor_mem t0Space_iff_exists_isOpen_xor'_mem
theorem exists_isOpen_xor'_mem [T0Space X] {x y : X} (h : x ≠ y) :
∃ U : Set X, IsOpen U ∧ Xor' (x ∈ U) (y ∈ U) :=
(t0Space_iff_exists_isOpen_xor'_mem X).1 ‹_› h
#align exists_is_open_xor_mem exists_isOpen_xor'_mem
def specializationOrder (X) [TopologicalSpace X] [T0Space X] : PartialOrder X :=
{ specializationPreorder X, PartialOrder.lift (OrderDual.toDual ∘ 𝓝) nhds_injective with }
#align specialization_order specializationOrder
instance SeparationQuotient.instT0Space : T0Space (SeparationQuotient X) :=
⟨fun x y => Quotient.inductionOn₂' x y fun _ _ h =>
SeparationQuotient.mk_eq_mk.2 <| SeparationQuotient.inducing_mk.inseparable_iff.1 h⟩
theorem minimal_nonempty_closed_subsingleton [T0Space X] {s : Set X} (hs : IsClosed s)
(hmin : ∀ t, t ⊆ s → t.Nonempty → IsClosed t → t = s) : s.Subsingleton := by
clear Y -- Porting note: added
refine fun x hx y hy => of_not_not fun hxy => ?_
rcases exists_isOpen_xor'_mem hxy with ⟨U, hUo, hU⟩
wlog h : x ∈ U ∧ y ∉ U
· refine this hs hmin y hy x hx (Ne.symm hxy) U hUo hU.symm (hU.resolve_left h)
cases' h with hxU hyU
have : s \ U = s := hmin (s \ U) diff_subset ⟨y, hy, hyU⟩ (hs.sdiff hUo)
exact (this.symm.subset hx).2 hxU
#align minimal_nonempty_closed_subsingleton minimal_nonempty_closed_subsingleton
theorem minimal_nonempty_closed_eq_singleton [T0Space X] {s : Set X} (hs : IsClosed s)
(hne : s.Nonempty) (hmin : ∀ t, t ⊆ s → t.Nonempty → IsClosed t → t = s) : ∃ x, s = {x} :=
exists_eq_singleton_iff_nonempty_subsingleton.2
⟨hne, minimal_nonempty_closed_subsingleton hs hmin⟩
#align minimal_nonempty_closed_eq_singleton minimal_nonempty_closed_eq_singleton
theorem IsClosed.exists_closed_singleton [T0Space X] [CompactSpace X] {S : Set X}
(hS : IsClosed S) (hne : S.Nonempty) : ∃ x : X, x ∈ S ∧ IsClosed ({x} : Set X) := by
obtain ⟨V, Vsub, Vne, Vcls, hV⟩ := hS.exists_minimal_nonempty_closed_subset hne
rcases minimal_nonempty_closed_eq_singleton Vcls Vne hV with ⟨x, rfl⟩
exact ⟨x, Vsub (mem_singleton x), Vcls⟩
#align is_closed.exists_closed_singleton IsClosed.exists_closed_singleton
theorem minimal_nonempty_open_subsingleton [T0Space X] {s : Set X} (hs : IsOpen s)
(hmin : ∀ t, t ⊆ s → t.Nonempty → IsOpen t → t = s) : s.Subsingleton := by
clear Y -- Porting note: added
refine fun x hx y hy => of_not_not fun hxy => ?_
rcases exists_isOpen_xor'_mem hxy with ⟨U, hUo, hU⟩
wlog h : x ∈ U ∧ y ∉ U
· exact this hs hmin y hy x hx (Ne.symm hxy) U hUo hU.symm (hU.resolve_left h)
cases' h with hxU hyU
have : s ∩ U = s := hmin (s ∩ U) inter_subset_left ⟨x, hx, hxU⟩ (hs.inter hUo)
exact hyU (this.symm.subset hy).2
#align minimal_nonempty_open_subsingleton minimal_nonempty_open_subsingleton
theorem minimal_nonempty_open_eq_singleton [T0Space X] {s : Set X} (hs : IsOpen s)
(hne : s.Nonempty) (hmin : ∀ t, t ⊆ s → t.Nonempty → IsOpen t → t = s) : ∃ x, s = {x} :=
exists_eq_singleton_iff_nonempty_subsingleton.2 ⟨hne, minimal_nonempty_open_subsingleton hs hmin⟩
#align minimal_nonempty_open_eq_singleton minimal_nonempty_open_eq_singleton
| Mathlib/Topology/Separation.lean | 326 | 340 | theorem exists_isOpen_singleton_of_isOpen_finite [T0Space X] {s : Set X} (hfin : s.Finite)
(hne : s.Nonempty) (ho : IsOpen s) : ∃ x ∈ s, IsOpen ({x} : Set X) := by |
lift s to Finset X using hfin
induction' s using Finset.strongInductionOn with s ihs
rcases em (∃ t, t ⊂ s ∧ t.Nonempty ∧ IsOpen (t : Set X)) with (⟨t, hts, htne, hto⟩ | ht)
· rcases ihs t hts htne hto with ⟨x, hxt, hxo⟩
exact ⟨x, hts.1 hxt, hxo⟩
· -- Porting note: was `rcases minimal_nonempty_open_eq_singleton ho hne _ with ⟨x, hx⟩`
-- https://github.com/leanprover/std4/issues/116
rsuffices ⟨x, hx⟩ : ∃ x, s.toSet = {x}
· exact ⟨x, hx.symm ▸ rfl, hx ▸ ho⟩
refine minimal_nonempty_open_eq_singleton ho hne ?_
refine fun t hts htne hto => of_not_not fun hts' => ht ?_
lift t to Finset X using s.finite_toSet.subset hts
exact ⟨t, ssubset_iff_subset_ne.2 ⟨hts, mt Finset.coe_inj.2 hts'⟩, htne, hto⟩
|
import Mathlib.LinearAlgebra.Dimension.Finrank
import Mathlib.LinearAlgebra.InvariantBasisNumber
#align_import linear_algebra.dimension from "leanprover-community/mathlib"@"47a5f8186becdbc826190ced4312f8199f9db6a5"
noncomputable section
universe u v w w'
variable {R : Type u} {M : Type v} [Ring R] [AddCommGroup M] [Module R M]
variable {ι : Type w} {ι' : Type w'}
open Cardinal Basis Submodule Function Set
attribute [local instance] nontrivial_of_invariantBasisNumber
section StrongRankCondition
variable [StrongRankCondition R]
open Submodule
-- An auxiliary lemma for `linearIndependent_le_span'`,
-- with the additional assumption that the linearly independent family is finite.
theorem linearIndependent_le_span_aux' {ι : Type*} [Fintype ι] (v : ι → M)
(i : LinearIndependent R v) (w : Set M) [Fintype w] (s : range v ≤ span R w) :
Fintype.card ι ≤ Fintype.card w := by
-- We construct an injective linear map `(ι → R) →ₗ[R] (w → R)`,
-- by thinking of `f : ι → R` as a linear combination of the finite family `v`,
-- and expressing that (using the axiom of choice) as a linear combination over `w`.
-- We can do this linearly by constructing the map on a basis.
fapply card_le_of_injective' R
· apply Finsupp.total
exact fun i => Span.repr R w ⟨v i, s (mem_range_self i)⟩
· intro f g h
apply_fun Finsupp.total w M R (↑) at h
simp only [Finsupp.total_total, Submodule.coe_mk, Span.finsupp_total_repr] at h
rw [← sub_eq_zero, ← LinearMap.map_sub] at h
exact sub_eq_zero.mp (linearIndependent_iff.mp i _ h)
#align linear_independent_le_span_aux' linearIndependent_le_span_aux'
lemma LinearIndependent.finite_of_le_span_finite {ι : Type*} (v : ι → M) (i : LinearIndependent R v)
(w : Set M) [Finite w] (s : range v ≤ span R w) : Finite ι :=
letI := Fintype.ofFinite w
Fintype.finite <| fintypeOfFinsetCardLe (Fintype.card w) fun t => by
let v' := fun x : (t : Set ι) => v x
have i' : LinearIndependent R v' := i.comp _ Subtype.val_injective
have s' : range v' ≤ span R w := (range_comp_subset_range _ _).trans s
simpa using linearIndependent_le_span_aux' v' i' w s'
#align linear_independent_fintype_of_le_span_fintype LinearIndependent.finite_of_le_span_finite
| Mathlib/LinearAlgebra/Dimension/StrongRankCondition.lean | 214 | 220 | theorem linearIndependent_le_span' {ι : Type*} (v : ι → M) (i : LinearIndependent R v) (w : Set M)
[Fintype w] (s : range v ≤ span R w) : #ι ≤ Fintype.card w := by |
haveI : Finite ι := i.finite_of_le_span_finite v w s
letI := Fintype.ofFinite ι
rw [Cardinal.mk_fintype]
simp only [Cardinal.natCast_le]
exact linearIndependent_le_span_aux' v i w s
|
import Mathlib.Data.ENNReal.Real
import Mathlib.Order.Interval.Finset.Nat
import Mathlib.Topology.UniformSpace.Pi
import Mathlib.Topology.UniformSpace.UniformConvergence
import Mathlib.Topology.UniformSpace.UniformEmbedding
#align_import topology.metric_space.emetric_space from "leanprover-community/mathlib"@"c8f305514e0d47dfaa710f5a52f0d21b588e6328"
open Set Filter Classical
open scoped Uniformity Topology Filter NNReal ENNReal Pointwise
universe u v w
variable {α : Type u} {β : Type v} {X : Type*}
theorem uniformity_dist_of_mem_uniformity [LinearOrder β] {U : Filter (α × α)} (z : β)
(D : α → α → β) (H : ∀ s, s ∈ U ↔ ∃ ε > z, ∀ {a b : α}, D a b < ε → (a, b) ∈ s) :
U = ⨅ ε > z, 𝓟 { p : α × α | D p.1 p.2 < ε } :=
HasBasis.eq_biInf ⟨fun s => by simp only [H, subset_def, Prod.forall, mem_setOf]⟩
#align uniformity_dist_of_mem_uniformity uniformity_dist_of_mem_uniformity
@[ext]
class EDist (α : Type*) where
edist : α → α → ℝ≥0∞
#align has_edist EDist
export EDist (edist)
def uniformSpaceOfEDist (edist : α → α → ℝ≥0∞) (edist_self : ∀ x : α, edist x x = 0)
(edist_comm : ∀ x y : α, edist x y = edist y x)
(edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z) : UniformSpace α :=
.ofFun edist edist_self edist_comm edist_triangle fun ε ε0 =>
⟨ε / 2, ENNReal.half_pos ε0.ne', fun _ h₁ _ h₂ =>
(ENNReal.add_lt_add h₁ h₂).trans_eq (ENNReal.add_halves _)⟩
#align uniform_space_of_edist uniformSpaceOfEDist
-- the uniform structure is embedded in the emetric space structure
-- to avoid instance diamond issues. See Note [forgetful inheritance].
class PseudoEMetricSpace (α : Type u) extends EDist α : Type u where
edist_self : ∀ x : α, edist x x = 0
edist_comm : ∀ x y : α, edist x y = edist y x
edist_triangle : ∀ x y z : α, edist x z ≤ edist x y + edist y z
toUniformSpace : UniformSpace α := uniformSpaceOfEDist edist edist_self edist_comm edist_triangle
uniformity_edist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | edist p.1 p.2 < ε } := by rfl
#align pseudo_emetric_space PseudoEMetricSpace
attribute [instance] PseudoEMetricSpace.toUniformSpace
@[ext]
protected theorem PseudoEMetricSpace.ext {α : Type*} {m m' : PseudoEMetricSpace α}
(h : m.toEDist = m'.toEDist) : m = m' := by
cases' m with ed _ _ _ U hU
cases' m' with ed' _ _ _ U' hU'
congr 1
exact UniformSpace.ext (((show ed = ed' from h) ▸ hU).trans hU'.symm)
variable [PseudoEMetricSpace α]
export PseudoEMetricSpace (edist_self edist_comm edist_triangle)
attribute [simp] edist_self
theorem edist_triangle_left (x y z : α) : edist x y ≤ edist z x + edist z y := by
rw [edist_comm z]; apply edist_triangle
#align edist_triangle_left edist_triangle_left
theorem edist_triangle_right (x y z : α) : edist x y ≤ edist x z + edist y z := by
rw [edist_comm y]; apply edist_triangle
#align edist_triangle_right edist_triangle_right
theorem edist_congr_right {x y z : α} (h : edist x y = 0) : edist x z = edist y z := by
apply le_antisymm
· rw [← zero_add (edist y z), ← h]
apply edist_triangle
· rw [edist_comm] at h
rw [← zero_add (edist x z), ← h]
apply edist_triangle
#align edist_congr_right edist_congr_right
theorem edist_congr_left {x y z : α} (h : edist x y = 0) : edist z x = edist z y := by
rw [edist_comm z x, edist_comm z y]
apply edist_congr_right h
#align edist_congr_left edist_congr_left
-- new theorem
theorem edist_congr {w x y z : α} (hl : edist w x = 0) (hr : edist y z = 0) :
edist w y = edist x z :=
(edist_congr_right hl).trans (edist_congr_left hr)
theorem edist_triangle4 (x y z t : α) : edist x t ≤ edist x y + edist y z + edist z t :=
calc
edist x t ≤ edist x z + edist z t := edist_triangle x z t
_ ≤ edist x y + edist y z + edist z t := add_le_add_right (edist_triangle x y z) _
#align edist_triangle4 edist_triangle4
theorem edist_le_Ico_sum_edist (f : ℕ → α) {m n} (h : m ≤ n) :
edist (f m) (f n) ≤ ∑ i ∈ Finset.Ico m n, edist (f i) (f (i + 1)) := by
induction n, h using Nat.le_induction with
| base => rw [Finset.Ico_self, Finset.sum_empty, edist_self]
| succ n hle ihn =>
calc
edist (f m) (f (n + 1)) ≤ edist (f m) (f n) + edist (f n) (f (n + 1)) := edist_triangle _ _ _
_ ≤ (∑ i ∈ Finset.Ico m n, _) + _ := add_le_add ihn le_rfl
_ = ∑ i ∈ Finset.Ico m (n + 1), _ := by
{ rw [Nat.Ico_succ_right_eq_insert_Ico hle, Finset.sum_insert, add_comm]; simp }
#align edist_le_Ico_sum_edist edist_le_Ico_sum_edist
theorem edist_le_range_sum_edist (f : ℕ → α) (n : ℕ) :
edist (f 0) (f n) ≤ ∑ i ∈ Finset.range n, edist (f i) (f (i + 1)) :=
Nat.Ico_zero_eq_range ▸ edist_le_Ico_sum_edist f (Nat.zero_le n)
#align edist_le_range_sum_edist edist_le_range_sum_edist
theorem edist_le_Ico_sum_of_edist_le {f : ℕ → α} {m n} (hmn : m ≤ n) {d : ℕ → ℝ≥0∞}
(hd : ∀ {k}, m ≤ k → k < n → edist (f k) (f (k + 1)) ≤ d k) :
edist (f m) (f n) ≤ ∑ i ∈ Finset.Ico m n, d i :=
le_trans (edist_le_Ico_sum_edist f hmn) <|
Finset.sum_le_sum fun _k hk => hd (Finset.mem_Ico.1 hk).1 (Finset.mem_Ico.1 hk).2
#align edist_le_Ico_sum_of_edist_le edist_le_Ico_sum_of_edist_le
theorem edist_le_range_sum_of_edist_le {f : ℕ → α} (n : ℕ) {d : ℕ → ℝ≥0∞}
(hd : ∀ {k}, k < n → edist (f k) (f (k + 1)) ≤ d k) :
edist (f 0) (f n) ≤ ∑ i ∈ Finset.range n, d i :=
Nat.Ico_zero_eq_range ▸ edist_le_Ico_sum_of_edist_le (zero_le n) fun _ => hd
#align edist_le_range_sum_of_edist_le edist_le_range_sum_of_edist_le
theorem uniformity_pseudoedist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | edist p.1 p.2 < ε } :=
PseudoEMetricSpace.uniformity_edist
#align uniformity_pseudoedist uniformity_pseudoedist
theorem uniformSpace_edist :
‹PseudoEMetricSpace α›.toUniformSpace =
uniformSpaceOfEDist edist edist_self edist_comm edist_triangle :=
UniformSpace.ext uniformity_pseudoedist
#align uniform_space_edist uniformSpace_edist
theorem uniformity_basis_edist :
(𝓤 α).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 < ε } :=
(@uniformSpace_edist α _).symm ▸ UniformSpace.hasBasis_ofFun ⟨1, one_pos⟩ _ _ _ _ _
#align uniformity_basis_edist uniformity_basis_edist
theorem mem_uniformity_edist {s : Set (α × α)} :
s ∈ 𝓤 α ↔ ∃ ε > 0, ∀ {a b : α}, edist a b < ε → (a, b) ∈ s :=
uniformity_basis_edist.mem_uniformity_iff
#align mem_uniformity_edist mem_uniformity_edist
protected theorem EMetric.mk_uniformity_basis {β : Type*} {p : β → Prop} {f : β → ℝ≥0∞}
(hf₀ : ∀ x, p x → 0 < f x) (hf : ∀ ε, 0 < ε → ∃ x, p x ∧ f x ≤ ε) :
(𝓤 α).HasBasis p fun x => { p : α × α | edist p.1 p.2 < f x } := by
refine ⟨fun s => uniformity_basis_edist.mem_iff.trans ?_⟩
constructor
· rintro ⟨ε, ε₀, hε⟩
rcases hf ε ε₀ with ⟨i, hi, H⟩
exact ⟨i, hi, fun x hx => hε <| lt_of_lt_of_le hx.out H⟩
· exact fun ⟨i, hi, H⟩ => ⟨f i, hf₀ i hi, H⟩
#align emetric.mk_uniformity_basis EMetric.mk_uniformity_basis
protected theorem EMetric.mk_uniformity_basis_le {β : Type*} {p : β → Prop} {f : β → ℝ≥0∞}
(hf₀ : ∀ x, p x → 0 < f x) (hf : ∀ ε, 0 < ε → ∃ x, p x ∧ f x ≤ ε) :
(𝓤 α).HasBasis p fun x => { p : α × α | edist p.1 p.2 ≤ f x } := by
refine ⟨fun s => uniformity_basis_edist.mem_iff.trans ?_⟩
constructor
· rintro ⟨ε, ε₀, hε⟩
rcases exists_between ε₀ with ⟨ε', hε'⟩
rcases hf ε' hε'.1 with ⟨i, hi, H⟩
exact ⟨i, hi, fun x hx => hε <| lt_of_le_of_lt (le_trans hx.out H) hε'.2⟩
· exact fun ⟨i, hi, H⟩ => ⟨f i, hf₀ i hi, fun x hx => H (le_of_lt hx.out)⟩
#align emetric.mk_uniformity_basis_le EMetric.mk_uniformity_basis_le
theorem uniformity_basis_edist_le :
(𝓤 α).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 ≤ ε } :=
EMetric.mk_uniformity_basis_le (fun _ => id) fun ε ε₀ => ⟨ε, ε₀, le_refl ε⟩
#align uniformity_basis_edist_le uniformity_basis_edist_le
theorem uniformity_basis_edist' (ε' : ℝ≥0∞) (hε' : 0 < ε') :
(𝓤 α).HasBasis (fun ε : ℝ≥0∞ => ε ∈ Ioo 0 ε') fun ε => { p : α × α | edist p.1 p.2 < ε } :=
EMetric.mk_uniformity_basis (fun _ => And.left) fun ε ε₀ =>
let ⟨δ, hδ⟩ := exists_between hε'
⟨min ε δ, ⟨lt_min ε₀ hδ.1, lt_of_le_of_lt (min_le_right _ _) hδ.2⟩, min_le_left _ _⟩
#align uniformity_basis_edist' uniformity_basis_edist'
theorem uniformity_basis_edist_le' (ε' : ℝ≥0∞) (hε' : 0 < ε') :
(𝓤 α).HasBasis (fun ε : ℝ≥0∞ => ε ∈ Ioo 0 ε') fun ε => { p : α × α | edist p.1 p.2 ≤ ε } :=
EMetric.mk_uniformity_basis_le (fun _ => And.left) fun ε ε₀ =>
let ⟨δ, hδ⟩ := exists_between hε'
⟨min ε δ, ⟨lt_min ε₀ hδ.1, lt_of_le_of_lt (min_le_right _ _) hδ.2⟩, min_le_left _ _⟩
#align uniformity_basis_edist_le' uniformity_basis_edist_le'
theorem uniformity_basis_edist_nnreal :
(𝓤 α).HasBasis (fun ε : ℝ≥0 => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 < ε } :=
EMetric.mk_uniformity_basis (fun _ => ENNReal.coe_pos.2) fun _ε ε₀ =>
let ⟨δ, hδ⟩ := ENNReal.lt_iff_exists_nnreal_btwn.1 ε₀
⟨δ, ENNReal.coe_pos.1 hδ.1, le_of_lt hδ.2⟩
#align uniformity_basis_edist_nnreal uniformity_basis_edist_nnreal
theorem uniformity_basis_edist_nnreal_le :
(𝓤 α).HasBasis (fun ε : ℝ≥0 => 0 < ε) fun ε => { p : α × α | edist p.1 p.2 ≤ ε } :=
EMetric.mk_uniformity_basis_le (fun _ => ENNReal.coe_pos.2) fun _ε ε₀ =>
let ⟨δ, hδ⟩ := ENNReal.lt_iff_exists_nnreal_btwn.1 ε₀
⟨δ, ENNReal.coe_pos.1 hδ.1, le_of_lt hδ.2⟩
#align uniformity_basis_edist_nnreal_le uniformity_basis_edist_nnreal_le
theorem uniformity_basis_edist_inv_nat :
(𝓤 α).HasBasis (fun _ => True) fun n : ℕ => { p : α × α | edist p.1 p.2 < (↑n)⁻¹ } :=
EMetric.mk_uniformity_basis (fun n _ ↦ ENNReal.inv_pos.2 <| ENNReal.natCast_ne_top n) fun _ε ε₀ ↦
let ⟨n, hn⟩ := ENNReal.exists_inv_nat_lt (ne_of_gt ε₀)
⟨n, trivial, le_of_lt hn⟩
#align uniformity_basis_edist_inv_nat uniformity_basis_edist_inv_nat
theorem uniformity_basis_edist_inv_two_pow :
(𝓤 α).HasBasis (fun _ => True) fun n : ℕ => { p : α × α | edist p.1 p.2 < 2⁻¹ ^ n } :=
EMetric.mk_uniformity_basis (fun _ _ => ENNReal.pow_pos (ENNReal.inv_pos.2 ENNReal.two_ne_top) _)
fun _ε ε₀ =>
let ⟨n, hn⟩ := ENNReal.exists_inv_two_pow_lt (ne_of_gt ε₀)
⟨n, trivial, le_of_lt hn⟩
#align uniformity_basis_edist_inv_two_pow uniformity_basis_edist_inv_two_pow
theorem edist_mem_uniformity {ε : ℝ≥0∞} (ε0 : 0 < ε) : { p : α × α | edist p.1 p.2 < ε } ∈ 𝓤 α :=
mem_uniformity_edist.2 ⟨ε, ε0, id⟩
#align edist_mem_uniformity edist_mem_uniformity
open EMetric
def PseudoEMetricSpace.replaceUniformity {α} [U : UniformSpace α] (m : PseudoEMetricSpace α)
(H : 𝓤[U] = 𝓤[PseudoEMetricSpace.toUniformSpace]) : PseudoEMetricSpace α where
edist := @edist _ m.toEDist
edist_self := edist_self
edist_comm := edist_comm
edist_triangle := edist_triangle
toUniformSpace := U
uniformity_edist := H.trans (@PseudoEMetricSpace.uniformity_edist α _)
#align pseudo_emetric_space.replace_uniformity PseudoEMetricSpace.replaceUniformity
def PseudoEMetricSpace.induced {α β} (f : α → β) (m : PseudoEMetricSpace β) :
PseudoEMetricSpace α where
edist x y := edist (f x) (f y)
edist_self _ := edist_self _
edist_comm _ _ := edist_comm _ _
edist_triangle _ _ _ := edist_triangle _ _ _
toUniformSpace := UniformSpace.comap f m.toUniformSpace
uniformity_edist := (uniformity_basis_edist.comap (Prod.map f f)).eq_biInf
#align pseudo_emetric_space.induced PseudoEMetricSpace.induced
instance {α : Type*} {p : α → Prop} [PseudoEMetricSpace α] : PseudoEMetricSpace (Subtype p) :=
PseudoEMetricSpace.induced Subtype.val ‹_›
theorem Subtype.edist_eq {p : α → Prop} (x y : Subtype p) : edist x y = edist (x : α) y := rfl
#align subtype.edist_eq Subtype.edist_eq
instance Prod.pseudoEMetricSpaceMax [PseudoEMetricSpace β] : PseudoEMetricSpace (α × β) where
edist x y := edist x.1 y.1 ⊔ edist x.2 y.2
edist_self x := by simp
edist_comm x y := by simp [edist_comm]
edist_triangle x y z :=
max_le (le_trans (edist_triangle _ _ _) (add_le_add (le_max_left _ _) (le_max_left _ _)))
(le_trans (edist_triangle _ _ _) (add_le_add (le_max_right _ _) (le_max_right _ _)))
uniformity_edist := uniformity_prod.trans <| by
simp [PseudoEMetricSpace.uniformity_edist, ← iInf_inf_eq, setOf_and]
toUniformSpace := inferInstance
#align prod.pseudo_emetric_space_max Prod.pseudoEMetricSpaceMax
theorem Prod.edist_eq [PseudoEMetricSpace β] (x y : α × β) :
edist x y = max (edist x.1 y.1) (edist x.2 y.2) :=
rfl
#align prod.edist_eq Prod.edist_eq
namespace EMetric
variable {x y z : α} {ε ε₁ ε₂ : ℝ≥0∞} {s t : Set α}
def ball (x : α) (ε : ℝ≥0∞) : Set α :=
{ y | edist y x < ε }
#align emetric.ball EMetric.ball
@[simp] theorem mem_ball : y ∈ ball x ε ↔ edist y x < ε := Iff.rfl
#align emetric.mem_ball EMetric.mem_ball
theorem mem_ball' : y ∈ ball x ε ↔ edist x y < ε := by rw [edist_comm, mem_ball]
#align emetric.mem_ball' EMetric.mem_ball'
def closedBall (x : α) (ε : ℝ≥0∞) :=
{ y | edist y x ≤ ε }
#align emetric.closed_ball EMetric.closedBall
@[simp] theorem mem_closedBall : y ∈ closedBall x ε ↔ edist y x ≤ ε := Iff.rfl
#align emetric.mem_closed_ball EMetric.mem_closedBall
theorem mem_closedBall' : y ∈ closedBall x ε ↔ edist x y ≤ ε := by rw [edist_comm, mem_closedBall]
#align emetric.mem_closed_ball' EMetric.mem_closedBall'
@[simp]
theorem closedBall_top (x : α) : closedBall x ∞ = univ :=
eq_univ_of_forall fun _ => mem_setOf.2 le_top
#align emetric.closed_ball_top EMetric.closedBall_top
theorem ball_subset_closedBall : ball x ε ⊆ closedBall x ε := fun _ h => le_of_lt h.out
#align emetric.ball_subset_closed_ball EMetric.ball_subset_closedBall
theorem pos_of_mem_ball (hy : y ∈ ball x ε) : 0 < ε :=
lt_of_le_of_lt (zero_le _) hy
#align emetric.pos_of_mem_ball EMetric.pos_of_mem_ball
theorem mem_ball_self (h : 0 < ε) : x ∈ ball x ε := by
rwa [mem_ball, edist_self]
#align emetric.mem_ball_self EMetric.mem_ball_self
theorem mem_closedBall_self : x ∈ closedBall x ε := by
rw [mem_closedBall, edist_self]; apply zero_le
#align emetric.mem_closed_ball_self EMetric.mem_closedBall_self
theorem mem_ball_comm : x ∈ ball y ε ↔ y ∈ ball x ε := by rw [mem_ball', mem_ball]
#align emetric.mem_ball_comm EMetric.mem_ball_comm
theorem mem_closedBall_comm : x ∈ closedBall y ε ↔ y ∈ closedBall x ε := by
rw [mem_closedBall', mem_closedBall]
#align emetric.mem_closed_ball_comm EMetric.mem_closedBall_comm
@[gcongr]
theorem ball_subset_ball (h : ε₁ ≤ ε₂) : ball x ε₁ ⊆ ball x ε₂ := fun _y (yx : _ < ε₁) =>
lt_of_lt_of_le yx h
#align emetric.ball_subset_ball EMetric.ball_subset_ball
@[gcongr]
theorem closedBall_subset_closedBall (h : ε₁ ≤ ε₂) : closedBall x ε₁ ⊆ closedBall x ε₂ :=
fun _y (yx : _ ≤ ε₁) => le_trans yx h
#align emetric.closed_ball_subset_closed_ball EMetric.closedBall_subset_closedBall
theorem ball_disjoint (h : ε₁ + ε₂ ≤ edist x y) : Disjoint (ball x ε₁) (ball y ε₂) :=
Set.disjoint_left.mpr fun z h₁ h₂ =>
(edist_triangle_left x y z).not_lt <| (ENNReal.add_lt_add h₁ h₂).trans_le h
#align emetric.ball_disjoint EMetric.ball_disjoint
theorem ball_subset (h : edist x y + ε₁ ≤ ε₂) (h' : edist x y ≠ ∞) : ball x ε₁ ⊆ ball y ε₂ :=
fun z zx =>
calc
edist z y ≤ edist z x + edist x y := edist_triangle _ _ _
_ = edist x y + edist z x := add_comm _ _
_ < edist x y + ε₁ := ENNReal.add_lt_add_left h' zx
_ ≤ ε₂ := h
#align emetric.ball_subset EMetric.ball_subset
theorem exists_ball_subset_ball (h : y ∈ ball x ε) : ∃ ε' > 0, ball y ε' ⊆ ball x ε := by
have : 0 < ε - edist y x := by simpa using h
refine ⟨ε - edist y x, this, ball_subset ?_ (ne_top_of_lt h)⟩
exact (add_tsub_cancel_of_le (mem_ball.mp h).le).le
#align emetric.exists_ball_subset_ball EMetric.exists_ball_subset_ball
theorem ball_eq_empty_iff : ball x ε = ∅ ↔ ε = 0 :=
eq_empty_iff_forall_not_mem.trans
⟨fun h => le_bot_iff.1 (le_of_not_gt fun ε0 => h _ (mem_ball_self ε0)), fun ε0 _ h =>
not_lt_of_le (le_of_eq ε0) (pos_of_mem_ball h)⟩
#align emetric.ball_eq_empty_iff EMetric.ball_eq_empty_iff
theorem ordConnected_setOf_closedBall_subset (x : α) (s : Set α) :
OrdConnected { r | closedBall x r ⊆ s } :=
⟨fun _ _ _ h₁ _ h₂ => (closedBall_subset_closedBall h₂.2).trans h₁⟩
#align emetric.ord_connected_set_of_closed_ball_subset EMetric.ordConnected_setOf_closedBall_subset
theorem ordConnected_setOf_ball_subset (x : α) (s : Set α) : OrdConnected { r | ball x r ⊆ s } :=
⟨fun _ _ _ h₁ _ h₂ => (ball_subset_ball h₂.2).trans h₁⟩
#align emetric.ord_connected_set_of_ball_subset EMetric.ordConnected_setOf_ball_subset
def edistLtTopSetoid : Setoid α where
r x y := edist x y < ⊤
iseqv :=
⟨fun x => by rw [edist_self]; exact ENNReal.coe_lt_top,
fun h => by rwa [edist_comm], fun hxy hyz =>
lt_of_le_of_lt (edist_triangle _ _ _) (ENNReal.add_lt_top.2 ⟨hxy, hyz⟩)⟩
#align emetric.edist_lt_top_setoid EMetric.edistLtTopSetoid
@[simp]
theorem ball_zero : ball x 0 = ∅ := by rw [EMetric.ball_eq_empty_iff]
#align emetric.ball_zero EMetric.ball_zero
theorem nhds_basis_eball : (𝓝 x).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) (ball x) :=
nhds_basis_uniformity uniformity_basis_edist
#align emetric.nhds_basis_eball EMetric.nhds_basis_eball
theorem nhdsWithin_basis_eball : (𝓝[s] x).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) fun ε => ball x ε ∩ s :=
nhdsWithin_hasBasis nhds_basis_eball s
#align emetric.nhds_within_basis_eball EMetric.nhdsWithin_basis_eball
theorem nhds_basis_closed_eball : (𝓝 x).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) (closedBall x) :=
nhds_basis_uniformity uniformity_basis_edist_le
#align emetric.nhds_basis_closed_eball EMetric.nhds_basis_closed_eball
theorem nhdsWithin_basis_closed_eball :
(𝓝[s] x).HasBasis (fun ε : ℝ≥0∞ => 0 < ε) fun ε => closedBall x ε ∩ s :=
nhdsWithin_hasBasis nhds_basis_closed_eball s
#align emetric.nhds_within_basis_closed_eball EMetric.nhdsWithin_basis_closed_eball
theorem nhds_eq : 𝓝 x = ⨅ ε > 0, 𝓟 (ball x ε) :=
nhds_basis_eball.eq_biInf
#align emetric.nhds_eq EMetric.nhds_eq
theorem mem_nhds_iff : s ∈ 𝓝 x ↔ ∃ ε > 0, ball x ε ⊆ s :=
nhds_basis_eball.mem_iff
#align emetric.mem_nhds_iff EMetric.mem_nhds_iff
theorem mem_nhdsWithin_iff : s ∈ 𝓝[t] x ↔ ∃ ε > 0, ball x ε ∩ t ⊆ s :=
nhdsWithin_basis_eball.mem_iff
#align emetric.mem_nhds_within_iff EMetric.mem_nhdsWithin_iff
section
variable [PseudoEMetricSpace β] {f : α → β}
theorem tendsto_nhdsWithin_nhdsWithin {t : Set β} {a b} :
Tendsto f (𝓝[s] a) (𝓝[t] b) ↔
∀ ε > 0, ∃ δ > 0, ∀ ⦃x⦄, x ∈ s → edist x a < δ → f x ∈ t ∧ edist (f x) b < ε :=
(nhdsWithin_basis_eball.tendsto_iff nhdsWithin_basis_eball).trans <|
forall₂_congr fun ε _ => exists_congr fun δ => and_congr_right fun _ =>
forall_congr' fun x => by simp; tauto
#align emetric.tendsto_nhds_within_nhds_within EMetric.tendsto_nhdsWithin_nhdsWithin
theorem tendsto_nhdsWithin_nhds {a b} :
Tendsto f (𝓝[s] a) (𝓝 b) ↔
∀ ε > 0, ∃ δ > 0, ∀ {x : α}, x ∈ s → edist x a < δ → edist (f x) b < ε := by
rw [← nhdsWithin_univ b, tendsto_nhdsWithin_nhdsWithin]
simp only [mem_univ, true_and_iff]
#align emetric.tendsto_nhds_within_nhds EMetric.tendsto_nhdsWithin_nhds
theorem tendsto_nhds_nhds {a b} :
Tendsto f (𝓝 a) (𝓝 b) ↔ ∀ ε > 0, ∃ δ > 0, ∀ ⦃x⦄, edist x a < δ → edist (f x) b < ε :=
nhds_basis_eball.tendsto_iff nhds_basis_eball
#align emetric.tendsto_nhds_nhds EMetric.tendsto_nhds_nhds
end
theorem isOpen_iff : IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, ball x ε ⊆ s := by
simp [isOpen_iff_nhds, mem_nhds_iff]
#align emetric.is_open_iff EMetric.isOpen_iff
theorem isOpen_ball : IsOpen (ball x ε) :=
isOpen_iff.2 fun _ => exists_ball_subset_ball
#align emetric.is_open_ball EMetric.isOpen_ball
theorem isClosed_ball_top : IsClosed (ball x ⊤) :=
isOpen_compl_iff.1 <| isOpen_iff.2 fun _y hy =>
⟨⊤, ENNReal.coe_lt_top, fun _z hzy hzx =>
hy (edistLtTopSetoid.trans (edistLtTopSetoid.symm hzy) hzx)⟩
#align emetric.is_closed_ball_top EMetric.isClosed_ball_top
theorem ball_mem_nhds (x : α) {ε : ℝ≥0∞} (ε0 : 0 < ε) : ball x ε ∈ 𝓝 x :=
isOpen_ball.mem_nhds (mem_ball_self ε0)
#align emetric.ball_mem_nhds EMetric.ball_mem_nhds
theorem closedBall_mem_nhds (x : α) {ε : ℝ≥0∞} (ε0 : 0 < ε) : closedBall x ε ∈ 𝓝 x :=
mem_of_superset (ball_mem_nhds x ε0) ball_subset_closedBall
#align emetric.closed_ball_mem_nhds EMetric.closedBall_mem_nhds
theorem ball_prod_same [PseudoEMetricSpace β] (x : α) (y : β) (r : ℝ≥0∞) :
ball x r ×ˢ ball y r = ball (x, y) r :=
ext fun z => by simp [Prod.edist_eq]
#align emetric.ball_prod_same EMetric.ball_prod_same
theorem closedBall_prod_same [PseudoEMetricSpace β] (x : α) (y : β) (r : ℝ≥0∞) :
closedBall x r ×ˢ closedBall y r = closedBall (x, y) r :=
ext fun z => by simp [Prod.edist_eq]
#align emetric.closed_ball_prod_same EMetric.closedBall_prod_same
theorem mem_closure_iff : x ∈ closure s ↔ ∀ ε > 0, ∃ y ∈ s, edist x y < ε :=
(mem_closure_iff_nhds_basis nhds_basis_eball).trans <| by simp only [mem_ball, edist_comm x]
#align emetric.mem_closure_iff EMetric.mem_closure_iff
theorem tendsto_nhds {f : Filter β} {u : β → α} {a : α} :
Tendsto u f (𝓝 a) ↔ ∀ ε > 0, ∀ᶠ x in f, edist (u x) a < ε :=
nhds_basis_eball.tendsto_right_iff
#align emetric.tendsto_nhds EMetric.tendsto_nhds
theorem tendsto_atTop [Nonempty β] [SemilatticeSup β] {u : β → α} {a : α} :
Tendsto u atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, edist (u n) a < ε :=
(atTop_basis.tendsto_iff nhds_basis_eball).trans <| by
simp only [exists_prop, true_and_iff, mem_Ici, mem_ball]
#align emetric.tendsto_at_top EMetric.tendsto_atTop
| Mathlib/Topology/EMetricSpace/Basic.lean | 751 | 752 | theorem inseparable_iff : Inseparable x y ↔ edist x y = 0 := by |
simp [inseparable_iff_mem_closure, mem_closure_iff, edist_comm, forall_lt_iff_le']
|
import Mathlib.Data.List.Nodup
import Mathlib.Data.List.Zip
import Mathlib.Data.Nat.Defs
import Mathlib.Data.List.Infix
#align_import data.list.rotate from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
universe u
variable {α : Type u}
open Nat Function
namespace List
theorem rotate_mod (l : List α) (n : ℕ) : l.rotate (n % l.length) = l.rotate n := by simp [rotate]
#align list.rotate_mod List.rotate_mod
@[simp]
theorem rotate_nil (n : ℕ) : ([] : List α).rotate n = [] := by simp [rotate]
#align list.rotate_nil List.rotate_nil
@[simp]
theorem rotate_zero (l : List α) : l.rotate 0 = l := by simp [rotate]
#align list.rotate_zero List.rotate_zero
-- Porting note: removing simp, simp can prove it
theorem rotate'_nil (n : ℕ) : ([] : List α).rotate' n = [] := by cases n <;> rfl
#align list.rotate'_nil List.rotate'_nil
@[simp]
theorem rotate'_zero (l : List α) : l.rotate' 0 = l := by cases l <;> rfl
#align list.rotate'_zero List.rotate'_zero
theorem rotate'_cons_succ (l : List α) (a : α) (n : ℕ) :
(a :: l : List α).rotate' n.succ = (l ++ [a]).rotate' n := by simp [rotate']
#align list.rotate'_cons_succ List.rotate'_cons_succ
@[simp]
theorem length_rotate' : ∀ (l : List α) (n : ℕ), (l.rotate' n).length = l.length
| [], _ => by simp
| a :: l, 0 => rfl
| a :: l, n + 1 => by rw [List.rotate', length_rotate' (l ++ [a]) n]; simp
#align list.length_rotate' List.length_rotate'
theorem rotate'_eq_drop_append_take :
∀ {l : List α} {n : ℕ}, n ≤ l.length → l.rotate' n = l.drop n ++ l.take n
| [], n, h => by simp [drop_append_of_le_length h]
| l, 0, h => by simp [take_append_of_le_length h]
| a :: l, n + 1, h => by
have hnl : n ≤ l.length := le_of_succ_le_succ h
have hnl' : n ≤ (l ++ [a]).length := by
rw [length_append, length_cons, List.length]; exact le_of_succ_le h
rw [rotate'_cons_succ, rotate'_eq_drop_append_take hnl', drop, take,
drop_append_of_le_length hnl, take_append_of_le_length hnl]; simp
#align list.rotate'_eq_drop_append_take List.rotate'_eq_drop_append_take
theorem rotate'_rotate' : ∀ (l : List α) (n m : ℕ), (l.rotate' n).rotate' m = l.rotate' (n + m)
| a :: l, 0, m => by simp
| [], n, m => by simp
| a :: l, n + 1, m => by
rw [rotate'_cons_succ, rotate'_rotate' _ n, Nat.add_right_comm, ← rotate'_cons_succ,
Nat.succ_eq_add_one]
#align list.rotate'_rotate' List.rotate'_rotate'
@[simp]
theorem rotate'_length (l : List α) : rotate' l l.length = l := by
rw [rotate'_eq_drop_append_take le_rfl]; simp
#align list.rotate'_length List.rotate'_length
@[simp]
theorem rotate'_length_mul (l : List α) : ∀ n : ℕ, l.rotate' (l.length * n) = l
| 0 => by simp
| n + 1 =>
calc
l.rotate' (l.length * (n + 1)) =
(l.rotate' (l.length * n)).rotate' (l.rotate' (l.length * n)).length := by
simp [-rotate'_length, Nat.mul_succ, rotate'_rotate']
_ = l := by rw [rotate'_length, rotate'_length_mul l n]
#align list.rotate'_length_mul List.rotate'_length_mul
theorem rotate'_mod (l : List α) (n : ℕ) : l.rotate' (n % l.length) = l.rotate' n :=
calc
l.rotate' (n % l.length) =
(l.rotate' (n % l.length)).rotate' ((l.rotate' (n % l.length)).length * (n / l.length)) :=
by rw [rotate'_length_mul]
_ = l.rotate' n := by rw [rotate'_rotate', length_rotate', Nat.mod_add_div]
#align list.rotate'_mod List.rotate'_mod
theorem rotate_eq_rotate' (l : List α) (n : ℕ) : l.rotate n = l.rotate' n :=
if h : l.length = 0 then by simp_all [length_eq_zero]
else by
rw [← rotate'_mod,
rotate'_eq_drop_append_take (le_of_lt (Nat.mod_lt _ (Nat.pos_of_ne_zero h)))];
simp [rotate]
#align list.rotate_eq_rotate' List.rotate_eq_rotate'
theorem rotate_cons_succ (l : List α) (a : α) (n : ℕ) :
(a :: l : List α).rotate (n + 1) = (l ++ [a]).rotate n := by
rw [rotate_eq_rotate', rotate_eq_rotate', rotate'_cons_succ]
#align list.rotate_cons_succ List.rotate_cons_succ
@[simp]
theorem mem_rotate : ∀ {l : List α} {a : α} {n : ℕ}, a ∈ l.rotate n ↔ a ∈ l
| [], _, n => by simp
| a :: l, _, 0 => by simp
| a :: l, _, n + 1 => by simp [rotate_cons_succ, mem_rotate, or_comm]
#align list.mem_rotate List.mem_rotate
@[simp]
theorem length_rotate (l : List α) (n : ℕ) : (l.rotate n).length = l.length := by
rw [rotate_eq_rotate', length_rotate']
#align list.length_rotate List.length_rotate
@[simp]
theorem rotate_replicate (a : α) (n : ℕ) (k : ℕ) : (replicate n a).rotate k = replicate n a :=
eq_replicate.2 ⟨by rw [length_rotate, length_replicate], fun b hb =>
eq_of_mem_replicate <| mem_rotate.1 hb⟩
#align list.rotate_replicate List.rotate_replicate
theorem rotate_eq_drop_append_take {l : List α} {n : ℕ} :
n ≤ l.length → l.rotate n = l.drop n ++ l.take n := by
rw [rotate_eq_rotate']; exact rotate'_eq_drop_append_take
#align list.rotate_eq_drop_append_take List.rotate_eq_drop_append_take
theorem rotate_eq_drop_append_take_mod {l : List α} {n : ℕ} :
l.rotate n = l.drop (n % l.length) ++ l.take (n % l.length) := by
rcases l.length.zero_le.eq_or_lt with hl | hl
· simp [eq_nil_of_length_eq_zero hl.symm]
rw [← rotate_eq_drop_append_take (n.mod_lt hl).le, rotate_mod]
#align list.rotate_eq_drop_append_take_mod List.rotate_eq_drop_append_take_mod
@[simp]
theorem rotate_append_length_eq (l l' : List α) : (l ++ l').rotate l.length = l' ++ l := by
rw [rotate_eq_rotate']
induction l generalizing l'
· simp
· simp_all [rotate']
#align list.rotate_append_length_eq List.rotate_append_length_eq
theorem rotate_rotate (l : List α) (n m : ℕ) : (l.rotate n).rotate m = l.rotate (n + m) := by
rw [rotate_eq_rotate', rotate_eq_rotate', rotate_eq_rotate', rotate'_rotate']
#align list.rotate_rotate List.rotate_rotate
@[simp]
theorem rotate_length (l : List α) : rotate l l.length = l := by
rw [rotate_eq_rotate', rotate'_length]
#align list.rotate_length List.rotate_length
@[simp]
theorem rotate_length_mul (l : List α) (n : ℕ) : l.rotate (l.length * n) = l := by
rw [rotate_eq_rotate', rotate'_length_mul]
#align list.rotate_length_mul List.rotate_length_mul
theorem rotate_perm (l : List α) (n : ℕ) : l.rotate n ~ l := by
rw [rotate_eq_rotate']
induction' n with n hn generalizing l
· simp
· cases' l with hd tl
· simp
· rw [rotate'_cons_succ]
exact (hn _).trans (perm_append_singleton _ _)
#align list.rotate_perm List.rotate_perm
@[simp]
theorem nodup_rotate {l : List α} {n : ℕ} : Nodup (l.rotate n) ↔ Nodup l :=
(rotate_perm l n).nodup_iff
#align list.nodup_rotate List.nodup_rotate
@[simp]
theorem rotate_eq_nil_iff {l : List α} {n : ℕ} : l.rotate n = [] ↔ l = [] := by
induction' n with n hn generalizing l
· simp
· cases' l with hd tl
· simp
· simp [rotate_cons_succ, hn]
#align list.rotate_eq_nil_iff List.rotate_eq_nil_iff
@[simp]
theorem nil_eq_rotate_iff {l : List α} {n : ℕ} : [] = l.rotate n ↔ [] = l := by
rw [eq_comm, rotate_eq_nil_iff, eq_comm]
#align list.nil_eq_rotate_iff List.nil_eq_rotate_iff
@[simp]
theorem rotate_singleton (x : α) (n : ℕ) : [x].rotate n = [x] :=
rotate_replicate x 1 n
#align list.rotate_singleton List.rotate_singleton
theorem zipWith_rotate_distrib {β γ : Type*} (f : α → β → γ) (l : List α) (l' : List β) (n : ℕ)
(h : l.length = l'.length) :
(zipWith f l l').rotate n = zipWith f (l.rotate n) (l'.rotate n) := by
rw [rotate_eq_drop_append_take_mod, rotate_eq_drop_append_take_mod,
rotate_eq_drop_append_take_mod, h, zipWith_append, ← zipWith_distrib_drop, ←
zipWith_distrib_take, List.length_zipWith, h, min_self]
rw [length_drop, length_drop, h]
#align list.zip_with_rotate_distrib List.zipWith_rotate_distrib
attribute [local simp] rotate_cons_succ
-- Porting note: removing @[simp], simp can prove it
theorem zipWith_rotate_one {β : Type*} (f : α → α → β) (x y : α) (l : List α) :
zipWith f (x :: y :: l) ((x :: y :: l).rotate 1) = f x y :: zipWith f (y :: l) (l ++ [x]) := by
simp
#align list.zip_with_rotate_one List.zipWith_rotate_one
theorem get?_rotate {l : List α} {n m : ℕ} (hml : m < l.length) :
(l.rotate n).get? m = l.get? ((m + n) % l.length) := by
rw [rotate_eq_drop_append_take_mod]
rcases lt_or_le m (l.drop (n % l.length)).length with hm | hm
· rw [get?_append hm, get?_drop, ← add_mod_mod]
rw [length_drop, Nat.lt_sub_iff_add_lt] at hm
rw [mod_eq_of_lt hm, Nat.add_comm]
· have hlt : n % length l < length l := mod_lt _ (m.zero_le.trans_lt hml)
rw [get?_append_right hm, get?_take, length_drop]
· congr 1
rw [length_drop] at hm
have hm' := Nat.sub_le_iff_le_add'.1 hm
have : n % length l + m - length l < length l := by
rw [Nat.sub_lt_iff_lt_add' hm']
exact Nat.add_lt_add hlt hml
conv_rhs => rw [Nat.add_comm m, ← mod_add_mod, mod_eq_sub_mod hm', mod_eq_of_lt this]
rw [← Nat.add_right_inj, ← Nat.add_sub_assoc, Nat.add_sub_sub_cancel, Nat.add_sub_cancel',
Nat.add_comm]
exacts [hm', hlt.le, hm]
· rwa [Nat.sub_lt_iff_lt_add hm, length_drop, Nat.sub_add_cancel hlt.le]
#align list.nth_rotate List.get?_rotate
-- Porting note (#10756): new lemma
theorem get_rotate (l : List α) (n : ℕ) (k : Fin (l.rotate n).length) :
(l.rotate n).get k =
l.get ⟨(k + n) % l.length, mod_lt _ (length_rotate l n ▸ k.1.zero_le.trans_lt k.2)⟩ := by
rw [← Option.some_inj, ← get?_eq_get, ← get?_eq_get, get?_rotate]
exact k.2.trans_eq (length_rotate _ _)
theorem head?_rotate {l : List α} {n : ℕ} (h : n < l.length) : head? (l.rotate n) = l.get? n := by
rw [← get?_zero, get?_rotate (n.zero_le.trans_lt h), Nat.zero_add, Nat.mod_eq_of_lt h]
#align list.head'_rotate List.head?_rotate
-- Porting note: moved down from its original location below `get_rotate` so that the
-- non-deprecated lemma does not use the deprecated version
set_option linter.deprecated false in
@[deprecated get_rotate (since := "2023-01-13")]
theorem nthLe_rotate (l : List α) (n k : ℕ) (hk : k < (l.rotate n).length) :
(l.rotate n).nthLe k hk =
l.nthLe ((k + n) % l.length) (mod_lt _ (length_rotate l n ▸ k.zero_le.trans_lt hk)) :=
get_rotate l n ⟨k, hk⟩
#align list.nth_le_rotate List.nthLe_rotate
set_option linter.deprecated false in
theorem nthLe_rotate_one (l : List α) (k : ℕ) (hk : k < (l.rotate 1).length) :
(l.rotate 1).nthLe k hk =
l.nthLe ((k + 1) % l.length) (mod_lt _ (length_rotate l 1 ▸ k.zero_le.trans_lt hk)) :=
nthLe_rotate l 1 k hk
#align list.nth_le_rotate_one List.nthLe_rotate_one
-- Porting note (#10756): new lemma
theorem get_eq_get_rotate (l : List α) (n : ℕ) (k : Fin l.length) :
l.get k = (l.rotate n).get ⟨(l.length - n % l.length + k) % l.length,
(Nat.mod_lt _ (k.1.zero_le.trans_lt k.2)).trans_eq (length_rotate _ _).symm⟩ := by
rw [get_rotate]
refine congr_arg l.get (Fin.eq_of_val_eq ?_)
simp only [mod_add_mod]
rw [← add_mod_mod, Nat.add_right_comm, Nat.sub_add_cancel, add_mod_left, mod_eq_of_lt]
exacts [k.2, (mod_lt _ (k.1.zero_le.trans_lt k.2)).le]
set_option linter.deprecated false in
@[deprecated get_eq_get_rotate]
theorem nthLe_rotate' (l : List α) (n k : ℕ) (hk : k < l.length) :
(l.rotate n).nthLe ((l.length - n % l.length + k) % l.length)
((Nat.mod_lt _ (k.zero_le.trans_lt hk)).trans_le (length_rotate _ _).ge) =
l.nthLe k hk :=
(get_eq_get_rotate l n ⟨k, hk⟩).symm
#align list.nth_le_rotate' List.nthLe_rotate'
theorem rotate_eq_self_iff_eq_replicate [hα : Nonempty α] :
∀ {l : List α}, (∀ n, l.rotate n = l) ↔ ∃ a, l = replicate l.length a
| [] => by simp
| a :: l => ⟨fun h => ⟨a, ext_get (length_replicate _ _).symm fun n h₁ h₂ => by
rw [get_replicate, ← Option.some_inj, ← get?_eq_get, ← head?_rotate h₁, h, head?_cons]⟩,
fun ⟨b, hb⟩ n => by rw [hb, rotate_replicate]⟩
#align list.rotate_eq_self_iff_eq_replicate List.rotate_eq_self_iff_eq_replicate
theorem rotate_one_eq_self_iff_eq_replicate [Nonempty α] {l : List α} :
l.rotate 1 = l ↔ ∃ a : α, l = List.replicate l.length a :=
⟨fun h =>
rotate_eq_self_iff_eq_replicate.mp fun n =>
Nat.rec l.rotate_zero (fun n hn => by rwa [Nat.succ_eq_add_one, ← l.rotate_rotate, hn]) n,
fun h => rotate_eq_self_iff_eq_replicate.mpr h 1⟩
#align list.rotate_one_eq_self_iff_eq_replicate List.rotate_one_eq_self_iff_eq_replicate
theorem rotate_injective (n : ℕ) : Function.Injective fun l : List α => l.rotate n := by
rintro l l' (h : l.rotate n = l'.rotate n)
have hle : l.length = l'.length := (l.length_rotate n).symm.trans (h.symm ▸ l'.length_rotate n)
rw [rotate_eq_drop_append_take_mod, rotate_eq_drop_append_take_mod] at h
obtain ⟨hd, ht⟩ := append_inj h (by simp_all)
rw [← take_append_drop _ l, ht, hd, take_append_drop]
#align list.rotate_injective List.rotate_injective
@[simp]
theorem rotate_eq_rotate {l l' : List α} {n : ℕ} : l.rotate n = l'.rotate n ↔ l = l' :=
(rotate_injective n).eq_iff
#align list.rotate_eq_rotate List.rotate_eq_rotate
theorem rotate_eq_iff {l l' : List α} {n : ℕ} :
l.rotate n = l' ↔ l = l'.rotate (l'.length - n % l'.length) := by
rw [← @rotate_eq_rotate _ l _ n, rotate_rotate, ← rotate_mod l', add_mod]
rcases l'.length.zero_le.eq_or_lt with hl | hl
· rw [eq_nil_of_length_eq_zero hl.symm, rotate_nil]
· rcases (Nat.zero_le (n % l'.length)).eq_or_lt with hn | hn
· simp [← hn]
· rw [mod_eq_of_lt (Nat.sub_lt hl hn), Nat.sub_add_cancel, mod_self, rotate_zero]
exact (Nat.mod_lt _ hl).le
#align list.rotate_eq_iff List.rotate_eq_iff
@[simp]
theorem rotate_eq_singleton_iff {l : List α} {n : ℕ} {x : α} : l.rotate n = [x] ↔ l = [x] := by
rw [rotate_eq_iff, rotate_singleton]
#align list.rotate_eq_singleton_iff List.rotate_eq_singleton_iff
@[simp]
theorem singleton_eq_rotate_iff {l : List α} {n : ℕ} {x : α} : [x] = l.rotate n ↔ [x] = l := by
rw [eq_comm, rotate_eq_singleton_iff, eq_comm]
#align list.singleton_eq_rotate_iff List.singleton_eq_rotate_iff
theorem reverse_rotate (l : List α) (n : ℕ) :
(l.rotate n).reverse = l.reverse.rotate (l.length - n % l.length) := by
rw [← length_reverse l, ← rotate_eq_iff]
induction' n with n hn generalizing l
· simp
· cases' l with hd tl
· simp
· rw [rotate_cons_succ, ← rotate_rotate, hn]
simp
#align list.reverse_rotate List.reverse_rotate
theorem rotate_reverse (l : List α) (n : ℕ) :
l.reverse.rotate n = (l.rotate (l.length - n % l.length)).reverse := by
rw [← reverse_reverse l]
simp_rw [reverse_rotate, reverse_reverse, rotate_eq_iff, rotate_rotate, length_rotate,
length_reverse]
rw [← length_reverse l]
let k := n % l.reverse.length
cases' hk' : k with k'
· simp_all! [k, length_reverse, ← rotate_rotate]
· cases' l with x l
· simp
· rw [Nat.mod_eq_of_lt, Nat.sub_add_cancel, rotate_length]
· exact Nat.sub_le _ _
· exact Nat.sub_lt (by simp) (by simp_all! [k])
#align list.rotate_reverse List.rotate_reverse
theorem map_rotate {β : Type*} (f : α → β) (l : List α) (n : ℕ) :
map f (l.rotate n) = (map f l).rotate n := by
induction' n with n hn IH generalizing l
· simp
· cases' l with hd tl
· simp
· simp [hn]
#align list.map_rotate List.map_rotate
theorem Nodup.rotate_congr {l : List α} (hl : l.Nodup) (hn : l ≠ []) (i j : ℕ)
(h : l.rotate i = l.rotate j) : i % l.length = j % l.length := by
rw [← rotate_mod l i, ← rotate_mod l j] at h
simpa only [head?_rotate, mod_lt, length_pos_of_ne_nil hn, get?_eq_get, Option.some_inj,
hl.get_inj_iff, Fin.ext_iff] using congr_arg head? h
#align list.nodup.rotate_congr List.Nodup.rotate_congr
theorem Nodup.rotate_congr_iff {l : List α} (hl : l.Nodup) {i j : ℕ} :
l.rotate i = l.rotate j ↔ i % l.length = j % l.length ∨ l = [] := by
rcases eq_or_ne l [] with rfl | hn
· simp
· simp only [hn, or_false]
refine ⟨hl.rotate_congr hn _ _, fun h ↦ ?_⟩
rw [← rotate_mod, h, rotate_mod]
theorem Nodup.rotate_eq_self_iff {l : List α} (hl : l.Nodup) {n : ℕ} :
l.rotate n = l ↔ n % l.length = 0 ∨ l = [] := by
rw [← zero_mod, ← hl.rotate_congr_iff, rotate_zero]
#align list.nodup.rotate_eq_self_iff List.Nodup.rotate_eq_self_iff
section IsRotated
variable (l l' : List α)
def IsRotated : Prop :=
∃ n, l.rotate n = l'
#align list.is_rotated List.IsRotated
@[inherit_doc List.IsRotated]
infixr:1000 " ~r " => IsRotated
variable {l l'}
@[refl]
theorem IsRotated.refl (l : List α) : l ~r l :=
⟨0, by simp⟩
#align list.is_rotated.refl List.IsRotated.refl
@[symm]
theorem IsRotated.symm (h : l ~r l') : l' ~r l := by
obtain ⟨n, rfl⟩ := h
cases' l with hd tl
· exists 0
· use (hd :: tl).length * n - n
rw [rotate_rotate, Nat.add_sub_cancel', rotate_length_mul]
exact Nat.le_mul_of_pos_left _ (by simp)
#align list.is_rotated.symm List.IsRotated.symm
theorem isRotated_comm : l ~r l' ↔ l' ~r l :=
⟨IsRotated.symm, IsRotated.symm⟩
#align list.is_rotated_comm List.isRotated_comm
@[simp]
protected theorem IsRotated.forall (l : List α) (n : ℕ) : l.rotate n ~r l :=
IsRotated.symm ⟨n, rfl⟩
#align list.is_rotated.forall List.IsRotated.forall
@[trans]
theorem IsRotated.trans : ∀ {l l' l'' : List α}, l ~r l' → l' ~r l'' → l ~r l''
| _, _, _, ⟨n, rfl⟩, ⟨m, rfl⟩ => ⟨n + m, by rw [rotate_rotate]⟩
#align list.is_rotated.trans List.IsRotated.trans
theorem IsRotated.eqv : Equivalence (@IsRotated α) :=
Equivalence.mk IsRotated.refl IsRotated.symm IsRotated.trans
#align list.is_rotated.eqv List.IsRotated.eqv
def IsRotated.setoid (α : Type*) : Setoid (List α) where
r := IsRotated
iseqv := IsRotated.eqv
#align list.is_rotated.setoid List.IsRotated.setoid
theorem IsRotated.perm (h : l ~r l') : l ~ l' :=
Exists.elim h fun _ hl => hl ▸ (rotate_perm _ _).symm
#align list.is_rotated.perm List.IsRotated.perm
theorem IsRotated.nodup_iff (h : l ~r l') : Nodup l ↔ Nodup l' :=
h.perm.nodup_iff
#align list.is_rotated.nodup_iff List.IsRotated.nodup_iff
theorem IsRotated.mem_iff (h : l ~r l') {a : α} : a ∈ l ↔ a ∈ l' :=
h.perm.mem_iff
#align list.is_rotated.mem_iff List.IsRotated.mem_iff
@[simp]
theorem isRotated_nil_iff : l ~r [] ↔ l = [] :=
⟨fun ⟨n, hn⟩ => by simpa using hn, fun h => h ▸ by rfl⟩
#align list.is_rotated_nil_iff List.isRotated_nil_iff
@[simp]
theorem isRotated_nil_iff' : [] ~r l ↔ [] = l := by
rw [isRotated_comm, isRotated_nil_iff, eq_comm]
#align list.is_rotated_nil_iff' List.isRotated_nil_iff'
@[simp]
theorem isRotated_singleton_iff {x : α} : l ~r [x] ↔ l = [x] :=
⟨fun ⟨n, hn⟩ => by simpa using hn, fun h => h ▸ by rfl⟩
#align list.is_rotated_singleton_iff List.isRotated_singleton_iff
@[simp]
theorem isRotated_singleton_iff' {x : α} : [x] ~r l ↔ [x] = l := by
rw [isRotated_comm, isRotated_singleton_iff, eq_comm]
#align list.is_rotated_singleton_iff' List.isRotated_singleton_iff'
theorem isRotated_concat (hd : α) (tl : List α) : (tl ++ [hd]) ~r (hd :: tl) :=
IsRotated.symm ⟨1, by simp⟩
#align list.is_rotated_concat List.isRotated_concat
theorem isRotated_append : (l ++ l') ~r (l' ++ l) :=
⟨l.length, by simp⟩
#align list.is_rotated_append List.isRotated_append
theorem IsRotated.reverse (h : l ~r l') : l.reverse ~r l'.reverse := by
obtain ⟨n, rfl⟩ := h
exact ⟨_, (reverse_rotate _ _).symm⟩
#align list.is_rotated.reverse List.IsRotated.reverse
theorem isRotated_reverse_comm_iff : l.reverse ~r l' ↔ l ~r l'.reverse := by
constructor <;>
· intro h
simpa using h.reverse
#align list.is_rotated_reverse_comm_iff List.isRotated_reverse_comm_iff
@[simp]
| Mathlib/Data/List/Rotate.lean | 512 | 513 | theorem isRotated_reverse_iff : l.reverse ~r l'.reverse ↔ l ~r l' := by |
simp [isRotated_reverse_comm_iff]
|
import Mathlib.Analysis.Asymptotics.AsymptoticEquivalent
import Mathlib.Analysis.Calculus.FDeriv.Linear
import Mathlib.Analysis.Calculus.FDeriv.Comp
#align_import analysis.calculus.fderiv.equiv 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}
namespace ContinuousLinearEquiv
variable (iso : E ≃L[𝕜] F)
@[fun_prop]
protected theorem hasStrictFDerivAt : HasStrictFDerivAt iso (iso : E →L[𝕜] F) x :=
iso.toContinuousLinearMap.hasStrictFDerivAt
#align continuous_linear_equiv.has_strict_fderiv_at ContinuousLinearEquiv.hasStrictFDerivAt
@[fun_prop]
protected theorem hasFDerivWithinAt : HasFDerivWithinAt iso (iso : E →L[𝕜] F) s x :=
iso.toContinuousLinearMap.hasFDerivWithinAt
#align continuous_linear_equiv.has_fderiv_within_at ContinuousLinearEquiv.hasFDerivWithinAt
@[fun_prop]
protected theorem hasFDerivAt : HasFDerivAt iso (iso : E →L[𝕜] F) x :=
iso.toContinuousLinearMap.hasFDerivAtFilter
#align continuous_linear_equiv.has_fderiv_at ContinuousLinearEquiv.hasFDerivAt
@[fun_prop]
protected theorem differentiableAt : DifferentiableAt 𝕜 iso x :=
iso.hasFDerivAt.differentiableAt
#align continuous_linear_equiv.differentiable_at ContinuousLinearEquiv.differentiableAt
@[fun_prop]
protected theorem differentiableWithinAt : DifferentiableWithinAt 𝕜 iso s x :=
iso.differentiableAt.differentiableWithinAt
#align continuous_linear_equiv.differentiable_within_at ContinuousLinearEquiv.differentiableWithinAt
protected theorem fderiv : fderiv 𝕜 iso x = iso :=
iso.hasFDerivAt.fderiv
#align continuous_linear_equiv.fderiv ContinuousLinearEquiv.fderiv
protected theorem fderivWithin (hxs : UniqueDiffWithinAt 𝕜 s x) : fderivWithin 𝕜 iso s x = iso :=
iso.toContinuousLinearMap.fderivWithin hxs
#align continuous_linear_equiv.fderiv_within ContinuousLinearEquiv.fderivWithin
@[fun_prop]
protected theorem differentiable : Differentiable 𝕜 iso := fun _ => iso.differentiableAt
#align continuous_linear_equiv.differentiable ContinuousLinearEquiv.differentiable
@[fun_prop]
protected theorem differentiableOn : DifferentiableOn 𝕜 iso s :=
iso.differentiable.differentiableOn
#align continuous_linear_equiv.differentiable_on ContinuousLinearEquiv.differentiableOn
theorem comp_differentiableWithinAt_iff {f : G → E} {s : Set G} {x : G} :
DifferentiableWithinAt 𝕜 (iso ∘ f) s x ↔ DifferentiableWithinAt 𝕜 f s x := by
refine
⟨fun H => ?_, fun H => iso.differentiable.differentiableAt.comp_differentiableWithinAt x H⟩
have : DifferentiableWithinAt 𝕜 (iso.symm ∘ iso ∘ f) s x :=
iso.symm.differentiable.differentiableAt.comp_differentiableWithinAt x H
rwa [← Function.comp.assoc iso.symm iso f, iso.symm_comp_self] at this
#align continuous_linear_equiv.comp_differentiable_within_at_iff ContinuousLinearEquiv.comp_differentiableWithinAt_iff
theorem comp_differentiableAt_iff {f : G → E} {x : G} :
DifferentiableAt 𝕜 (iso ∘ f) x ↔ DifferentiableAt 𝕜 f x := by
rw [← differentiableWithinAt_univ, ← differentiableWithinAt_univ,
iso.comp_differentiableWithinAt_iff]
#align continuous_linear_equiv.comp_differentiable_at_iff ContinuousLinearEquiv.comp_differentiableAt_iff
theorem comp_differentiableOn_iff {f : G → E} {s : Set G} :
DifferentiableOn 𝕜 (iso ∘ f) s ↔ DifferentiableOn 𝕜 f s := by
rw [DifferentiableOn, DifferentiableOn]
simp only [iso.comp_differentiableWithinAt_iff]
#align continuous_linear_equiv.comp_differentiable_on_iff ContinuousLinearEquiv.comp_differentiableOn_iff
theorem comp_differentiable_iff {f : G → E} : Differentiable 𝕜 (iso ∘ f) ↔ Differentiable 𝕜 f := by
rw [← differentiableOn_univ, ← differentiableOn_univ]
exact iso.comp_differentiableOn_iff
#align continuous_linear_equiv.comp_differentiable_iff ContinuousLinearEquiv.comp_differentiable_iff
theorem comp_hasFDerivWithinAt_iff {f : G → E} {s : Set G} {x : G} {f' : G →L[𝕜] E} :
HasFDerivWithinAt (iso ∘ f) ((iso : E →L[𝕜] F).comp f') s x ↔ HasFDerivWithinAt f f' s x := by
refine ⟨fun H => ?_, fun H => iso.hasFDerivAt.comp_hasFDerivWithinAt x H⟩
have A : f = iso.symm ∘ iso ∘ f := by
rw [← Function.comp.assoc, iso.symm_comp_self]
rfl
have B : f' = (iso.symm : F →L[𝕜] E).comp ((iso : E →L[𝕜] F).comp f') := by
rw [← ContinuousLinearMap.comp_assoc, iso.coe_symm_comp_coe, ContinuousLinearMap.id_comp]
rw [A, B]
exact iso.symm.hasFDerivAt.comp_hasFDerivWithinAt x H
#align continuous_linear_equiv.comp_has_fderiv_within_at_iff ContinuousLinearEquiv.comp_hasFDerivWithinAt_iff
theorem comp_hasStrictFDerivAt_iff {f : G → E} {x : G} {f' : G →L[𝕜] E} :
HasStrictFDerivAt (iso ∘ f) ((iso : E →L[𝕜] F).comp f') x ↔ HasStrictFDerivAt f f' x := by
refine ⟨fun H => ?_, fun H => iso.hasStrictFDerivAt.comp x H⟩
convert iso.symm.hasStrictFDerivAt.comp x H using 1 <;>
ext z <;> apply (iso.symm_apply_apply _).symm
#align continuous_linear_equiv.comp_has_strict_fderiv_at_iff ContinuousLinearEquiv.comp_hasStrictFDerivAt_iff
theorem comp_hasFDerivAt_iff {f : G → E} {x : G} {f' : G →L[𝕜] E} :
HasFDerivAt (iso ∘ f) ((iso : E →L[𝕜] F).comp f') x ↔ HasFDerivAt f f' x := by
simp_rw [← hasFDerivWithinAt_univ, iso.comp_hasFDerivWithinAt_iff]
#align continuous_linear_equiv.comp_has_fderiv_at_iff ContinuousLinearEquiv.comp_hasFDerivAt_iff
| Mathlib/Analysis/Calculus/FDeriv/Equiv.lean | 145 | 149 | theorem comp_hasFDerivWithinAt_iff' {f : G → E} {s : Set G} {x : G} {f' : G →L[𝕜] F} :
HasFDerivWithinAt (iso ∘ f) f' s x ↔
HasFDerivWithinAt f ((iso.symm : F →L[𝕜] E).comp f') s x := by |
rw [← iso.comp_hasFDerivWithinAt_iff, ← ContinuousLinearMap.comp_assoc, iso.coe_comp_coe_symm,
ContinuousLinearMap.id_comp]
|
import Mathlib.MeasureTheory.Measure.NullMeasurable
import Mathlib.MeasureTheory.MeasurableSpace.Basic
import Mathlib.Topology.Algebra.Order.LiminfLimsup
#align_import measure_theory.measure.measure_space from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55"
noncomputable section
open Set
open Filter hiding map
open Function MeasurableSpace
open scoped Classical symmDiff
open Topology Filter ENNReal NNReal Interval MeasureTheory
variable {α β γ δ ι R R' : Type*}
namespace MeasureTheory
section
variable {m : MeasurableSpace α} {μ μ₁ μ₂ : Measure α} {s s₁ s₂ t : Set α}
instance ae_isMeasurablyGenerated : IsMeasurablyGenerated (ae μ) :=
⟨fun _s hs =>
let ⟨t, hst, htm, htμ⟩ := exists_measurable_superset_of_null hs
⟨tᶜ, compl_mem_ae_iff.2 htμ, htm.compl, compl_subset_comm.1 hst⟩⟩
#align measure_theory.ae_is_measurably_generated MeasureTheory.ae_isMeasurablyGenerated
theorem ae_uIoc_iff [LinearOrder α] {a b : α} {P : α → Prop} :
(∀ᵐ x ∂μ, x ∈ Ι a b → P x) ↔ (∀ᵐ x ∂μ, x ∈ Ioc a b → P x) ∧ ∀ᵐ x ∂μ, x ∈ Ioc b a → P x := by
simp only [uIoc_eq_union, mem_union, or_imp, eventually_and]
#align measure_theory.ae_uIoc_iff MeasureTheory.ae_uIoc_iff
theorem measure_union (hd : Disjoint s₁ s₂) (h : MeasurableSet s₂) : μ (s₁ ∪ s₂) = μ s₁ + μ s₂ :=
measure_union₀ h.nullMeasurableSet hd.aedisjoint
#align measure_theory.measure_union MeasureTheory.measure_union
theorem measure_union' (hd : Disjoint s₁ s₂) (h : MeasurableSet s₁) : μ (s₁ ∪ s₂) = μ s₁ + μ s₂ :=
measure_union₀' h.nullMeasurableSet hd.aedisjoint
#align measure_theory.measure_union' MeasureTheory.measure_union'
theorem measure_inter_add_diff (s : Set α) (ht : MeasurableSet t) : μ (s ∩ t) + μ (s \ t) = μ s :=
measure_inter_add_diff₀ _ ht.nullMeasurableSet
#align measure_theory.measure_inter_add_diff MeasureTheory.measure_inter_add_diff
theorem measure_diff_add_inter (s : Set α) (ht : MeasurableSet t) : μ (s \ t) + μ (s ∩ t) = μ s :=
(add_comm _ _).trans (measure_inter_add_diff s ht)
#align measure_theory.measure_diff_add_inter MeasureTheory.measure_diff_add_inter
theorem measure_union_add_inter (s : Set α) (ht : MeasurableSet t) :
μ (s ∪ t) + μ (s ∩ t) = μ s + μ t := by
rw [← measure_inter_add_diff (s ∪ t) ht, Set.union_inter_cancel_right, union_diff_right, ←
measure_inter_add_diff s ht]
ac_rfl
#align measure_theory.measure_union_add_inter MeasureTheory.measure_union_add_inter
theorem measure_union_add_inter' (hs : MeasurableSet s) (t : Set α) :
μ (s ∪ t) + μ (s ∩ t) = μ s + μ t := by
rw [union_comm, inter_comm, measure_union_add_inter t hs, add_comm]
#align measure_theory.measure_union_add_inter' MeasureTheory.measure_union_add_inter'
lemma measure_symmDiff_eq (hs : MeasurableSet s) (ht : MeasurableSet t) :
μ (s ∆ t) = μ (s \ t) + μ (t \ s) := by
simpa only [symmDiff_def, sup_eq_union] using measure_union disjoint_sdiff_sdiff (ht.diff hs)
lemma measure_symmDiff_le (s t u : Set α) :
μ (s ∆ u) ≤ μ (s ∆ t) + μ (t ∆ u) :=
le_trans (μ.mono <| symmDiff_triangle s t u) (measure_union_le (s ∆ t) (t ∆ u))
theorem measure_add_measure_compl (h : MeasurableSet s) : μ s + μ sᶜ = μ univ :=
measure_add_measure_compl₀ h.nullMeasurableSet
#align measure_theory.measure_add_measure_compl MeasureTheory.measure_add_measure_compl
theorem measure_biUnion₀ {s : Set β} {f : β → Set α} (hs : s.Countable)
(hd : s.Pairwise (AEDisjoint μ on f)) (h : ∀ b ∈ s, NullMeasurableSet (f b) μ) :
μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) := by
haveI := hs.toEncodable
rw [biUnion_eq_iUnion]
exact measure_iUnion₀ (hd.on_injective Subtype.coe_injective fun x => x.2) fun x => h x x.2
#align measure_theory.measure_bUnion₀ MeasureTheory.measure_biUnion₀
theorem measure_biUnion {s : Set β} {f : β → Set α} (hs : s.Countable) (hd : s.PairwiseDisjoint f)
(h : ∀ b ∈ s, MeasurableSet (f b)) : μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) :=
measure_biUnion₀ hs hd.aedisjoint fun b hb => (h b hb).nullMeasurableSet
#align measure_theory.measure_bUnion MeasureTheory.measure_biUnion
theorem measure_sUnion₀ {S : Set (Set α)} (hs : S.Countable) (hd : S.Pairwise (AEDisjoint μ))
(h : ∀ s ∈ S, NullMeasurableSet s μ) : μ (⋃₀ S) = ∑' s : S, μ s := by
rw [sUnion_eq_biUnion, measure_biUnion₀ hs hd h]
#align measure_theory.measure_sUnion₀ MeasureTheory.measure_sUnion₀
theorem measure_sUnion {S : Set (Set α)} (hs : S.Countable) (hd : S.Pairwise Disjoint)
(h : ∀ s ∈ S, MeasurableSet s) : μ (⋃₀ S) = ∑' s : S, μ s := by
rw [sUnion_eq_biUnion, measure_biUnion hs hd h]
#align measure_theory.measure_sUnion MeasureTheory.measure_sUnion
theorem measure_biUnion_finset₀ {s : Finset ι} {f : ι → Set α}
(hd : Set.Pairwise (↑s) (AEDisjoint μ on f)) (hm : ∀ b ∈ s, NullMeasurableSet (f b) μ) :
μ (⋃ b ∈ s, f b) = ∑ p ∈ s, μ (f p) := by
rw [← Finset.sum_attach, Finset.attach_eq_univ, ← tsum_fintype]
exact measure_biUnion₀ s.countable_toSet hd hm
#align measure_theory.measure_bUnion_finset₀ MeasureTheory.measure_biUnion_finset₀
theorem measure_biUnion_finset {s : Finset ι} {f : ι → Set α} (hd : PairwiseDisjoint (↑s) f)
(hm : ∀ b ∈ s, MeasurableSet (f b)) : μ (⋃ b ∈ s, f b) = ∑ p ∈ s, μ (f p) :=
measure_biUnion_finset₀ hd.aedisjoint fun b hb => (hm b hb).nullMeasurableSet
#align measure_theory.measure_bUnion_finset MeasureTheory.measure_biUnion_finset
theorem tsum_meas_le_meas_iUnion_of_disjoint₀ {ι : Type*} [MeasurableSpace α] (μ : Measure α)
{As : ι → Set α} (As_mble : ∀ i : ι, NullMeasurableSet (As i) μ)
(As_disj : Pairwise (AEDisjoint μ on As)) : (∑' i, μ (As i)) ≤ μ (⋃ i, As i) := by
rw [ENNReal.tsum_eq_iSup_sum, iSup_le_iff]
intro s
simp only [← measure_biUnion_finset₀ (fun _i _hi _j _hj hij => As_disj hij) fun i _ => As_mble i]
gcongr
exact iUnion_subset fun _ ↦ Subset.rfl
theorem tsum_meas_le_meas_iUnion_of_disjoint {ι : Type*} [MeasurableSpace α] (μ : Measure α)
{As : ι → Set α} (As_mble : ∀ i : ι, MeasurableSet (As i))
(As_disj : Pairwise (Disjoint on As)) : (∑' i, μ (As i)) ≤ μ (⋃ i, As i) :=
tsum_meas_le_meas_iUnion_of_disjoint₀ μ (fun i ↦ (As_mble i).nullMeasurableSet)
(fun _ _ h ↦ Disjoint.aedisjoint (As_disj h))
#align measure_theory.tsum_meas_le_meas_Union_of_disjoint MeasureTheory.tsum_meas_le_meas_iUnion_of_disjoint
| Mathlib/MeasureTheory/Measure/MeasureSpace.lean | 209 | 211 | theorem tsum_measure_preimage_singleton {s : Set β} (hs : s.Countable) {f : α → β}
(hf : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y})) : (∑' b : s, μ (f ⁻¹' {↑b})) = μ (f ⁻¹' s) := by |
rw [← Set.biUnion_preimage_singleton, measure_biUnion hs (pairwiseDisjoint_fiber f s) hf]
|
import Mathlib.MeasureTheory.Constructions.Pi
import Mathlib.MeasureTheory.Integral.Lebesgue
open scoped Classical ENNReal
open Set Function Equiv Finset
noncomputable section
namespace MeasureTheory
section LMarginal
variable {δ δ' : Type*} {π : δ → Type*} [∀ x, MeasurableSpace (π x)]
variable {μ : ∀ i, Measure (π i)} [∀ i, SigmaFinite (μ i)] [DecidableEq δ]
variable {s t : Finset δ} {f g : (∀ i, π i) → ℝ≥0∞} {x y : ∀ i, π i} {i : δ}
def lmarginal (μ : ∀ i, Measure (π i)) (s : Finset δ) (f : (∀ i, π i) → ℝ≥0∞)
(x : ∀ i, π i) : ℝ≥0∞ :=
∫⁻ y : ∀ i : s, π i, f (updateFinset x s y) ∂Measure.pi fun i : s => μ i
-- Note: this notation is not a binder. This is more convenient since it returns a function.
@[inherit_doc]
notation "∫⋯∫⁻_" s ", " f " ∂" μ:70 => lmarginal μ s f
@[inherit_doc]
notation "∫⋯∫⁻_" s ", " f => lmarginal (fun _ ↦ volume) s f
variable (μ)
theorem _root_.Measurable.lmarginal (hf : Measurable f) : Measurable (∫⋯∫⁻_s, f ∂μ) := by
refine Measurable.lintegral_prod_right ?_
refine hf.comp ?_
rw [measurable_pi_iff]; intro i
by_cases hi : i ∈ s
· simp [hi, updateFinset]
exact measurable_pi_iff.1 measurable_snd _
· simp [hi, updateFinset]
exact measurable_pi_iff.1 measurable_fst _
@[simp] theorem lmarginal_empty (f : (∀ i, π i) → ℝ≥0∞) : ∫⋯∫⁻_∅, f ∂μ = f := by
ext1 x
simp_rw [lmarginal, Measure.pi_of_empty fun i : (∅ : Finset δ) => μ i]
apply lintegral_dirac'
exact Subsingleton.measurable
theorem lmarginal_congr {x y : ∀ i, π i} (f : (∀ i, π i) → ℝ≥0∞)
(h : ∀ i ∉ s, x i = y i) :
(∫⋯∫⁻_s, f ∂μ) x = (∫⋯∫⁻_s, f ∂μ) y := by
dsimp [lmarginal, updateFinset_def]; rcongr; exact h _ ‹_›
theorem lmarginal_update_of_mem {i : δ} (hi : i ∈ s)
(f : (∀ i, π i) → ℝ≥0∞) (x : ∀ i, π i) (y : π i) :
(∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∂μ) x := by
apply lmarginal_congr
intro j hj
have : j ≠ i := by rintro rfl; exact hj hi
apply update_noteq this
theorem lmarginal_union (f : (∀ i, π i) → ℝ≥0∞) (hf : Measurable f)
(hst : Disjoint s t) : ∫⋯∫⁻_s ∪ t, f ∂μ = ∫⋯∫⁻_s, ∫⋯∫⁻_t, f ∂μ ∂μ := by
ext1 x
let e := MeasurableEquiv.piFinsetUnion π hst
calc (∫⋯∫⁻_s ∪ t, f ∂μ) x
= ∫⁻ (y : (i : ↥(s ∪ t)) → π i), f (updateFinset x (s ∪ t) y)
∂.pi fun i' : ↥(s ∪ t) ↦ μ i' := rfl
_ = ∫⁻ (y : ((i : s) → π i) × ((j : t) → π j)), f (updateFinset x (s ∪ t) _)
∂(Measure.pi fun i : s ↦ μ i).prod (.pi fun j : t ↦ μ j) := by
rw [measurePreserving_piFinsetUnion hst μ |>.lintegral_map_equiv]
_ = ∫⁻ (y : (i : s) → π i), ∫⁻ (z : (j : t) → π j), f (updateFinset x (s ∪ t) (e (y, z)))
∂.pi fun j : t ↦ μ j ∂.pi fun i : s ↦ μ i := by
apply lintegral_prod
apply Measurable.aemeasurable
exact hf.comp <| measurable_updateFinset.comp e.measurable
_ = (∫⋯∫⁻_s, ∫⋯∫⁻_t, f ∂μ ∂μ) x := by
simp_rw [lmarginal, updateFinset_updateFinset hst]
rfl
theorem lmarginal_union' (f : (∀ i, π i) → ℝ≥0∞) (hf : Measurable f) {s t : Finset δ}
(hst : Disjoint s t) : ∫⋯∫⁻_s ∪ t, f ∂μ = ∫⋯∫⁻_t, ∫⋯∫⁻_s, f ∂μ ∂μ := by
rw [Finset.union_comm, lmarginal_union μ f hf hst.symm]
variable {μ}
set_option backward.synthInstance.canonInstances false in -- See https://github.com/leanprover-community/mathlib4/issues/12532
theorem lmarginal_singleton (f : (∀ i, π i) → ℝ≥0∞) (i : δ) :
∫⋯∫⁻_{i}, f ∂μ = fun x => ∫⁻ xᵢ, f (Function.update x i xᵢ) ∂μ i := by
let α : Type _ := ({i} : Finset δ)
let e := (MeasurableEquiv.piUnique fun j : α ↦ π j).symm
ext1 x
calc (∫⋯∫⁻_{i}, f ∂μ) x
= ∫⁻ (y : π (default : α)), f (updateFinset x {i} (e y)) ∂μ (default : α) := by
simp_rw [lmarginal, measurePreserving_piUnique (fun j : ({i} : Finset δ) ↦ μ j) |>.symm _
|>.lintegral_map_equiv]
_ = ∫⁻ xᵢ, f (Function.update x i xᵢ) ∂μ i := by simp [update_eq_updateFinset]; rfl
theorem lmarginal_insert (f : (∀ i, π i) → ℝ≥0∞) (hf : Measurable f) {i : δ}
(hi : i ∉ s) (x : ∀ i, π i) :
(∫⋯∫⁻_insert i s, f ∂μ) x = ∫⁻ xᵢ, (∫⋯∫⁻_s, f ∂μ) (Function.update x i xᵢ) ∂μ i := by
rw [Finset.insert_eq, lmarginal_union μ f hf (Finset.disjoint_singleton_left.mpr hi),
lmarginal_singleton]
theorem lmarginal_erase (f : (∀ i, π i) → ℝ≥0∞) (hf : Measurable f) {i : δ}
(hi : i ∈ s) (x : ∀ i, π i) :
(∫⋯∫⁻_s, f ∂μ) x = ∫⁻ xᵢ, (∫⋯∫⁻_(erase s i), f ∂μ) (Function.update x i xᵢ) ∂μ i := by
simpa [insert_erase hi] using lmarginal_insert _ hf (not_mem_erase i s) x
theorem lmarginal_insert' (f : (∀ i, π i) → ℝ≥0∞) (hf : Measurable f) {i : δ}
(hi : i ∉ s) :
∫⋯∫⁻_insert i s, f ∂μ = ∫⋯∫⁻_s, (fun x ↦ ∫⁻ xᵢ, f (Function.update x i xᵢ) ∂μ i) ∂μ := by
rw [Finset.insert_eq, Finset.union_comm,
lmarginal_union (s := s) μ f hf (Finset.disjoint_singleton_right.mpr hi), lmarginal_singleton]
theorem lmarginal_erase' (f : (∀ i, π i) → ℝ≥0∞) (hf : Measurable f) {i : δ}
(hi : i ∈ s) :
∫⋯∫⁻_s, f ∂μ = ∫⋯∫⁻_(erase s i), (fun x ↦ ∫⁻ xᵢ, f (Function.update x i xᵢ) ∂μ i) ∂μ := by
simpa [insert_erase hi] using lmarginal_insert' _ hf (not_mem_erase i s)
open Filter
@[gcongr]
theorem lmarginal_mono {f g : (∀ i, π i) → ℝ≥0∞} (hfg : f ≤ g) : ∫⋯∫⁻_s, f ∂μ ≤ ∫⋯∫⁻_s, g ∂μ :=
fun _ => lintegral_mono fun _ => hfg _
@[simp] theorem lmarginal_univ [Fintype δ] {f : (∀ i, π i) → ℝ≥0∞} :
∫⋯∫⁻_univ, f ∂μ = fun _ => ∫⁻ x, f x ∂Measure.pi μ := by
let e : { j // j ∈ Finset.univ } ≃ δ := Equiv.subtypeUnivEquiv mem_univ
ext1 x
simp_rw [lmarginal, measurePreserving_piCongrLeft μ e |>.lintegral_map_equiv, updateFinset_def]
simp
rfl
theorem lintegral_eq_lmarginal_univ [Fintype δ] {f : (∀ i, π i) → ℝ≥0∞} (x : ∀ i, π i) :
∫⁻ x, f x ∂Measure.pi μ = (∫⋯∫⁻_univ, f ∂μ) x := by simp
theorem lmarginal_image [DecidableEq δ'] {e : δ' → δ} (he : Injective e) (s : Finset δ')
{f : (∀ i, π (e i)) → ℝ≥0∞} (hf : Measurable f) (x : ∀ i, π i) :
(∫⋯∫⁻_s.image e, f ∘ (· ∘' e) ∂μ) x = (∫⋯∫⁻_s, f ∂μ ∘' e) (x ∘' e) := by
have h : Measurable ((· ∘' e) : (∀ i, π i) → _) :=
measurable_pi_iff.mpr <| fun i ↦ measurable_pi_apply (e i)
induction s using Finset.induction generalizing x with
| empty => simp
| insert hi ih =>
rw [image_insert, lmarginal_insert _ (hf.comp h) (he.mem_finset_image.not.mpr hi),
lmarginal_insert _ hf hi]
simp_rw [ih, ← update_comp_eq_of_injective' x he]
theorem lmarginal_update_of_not_mem {i : δ}
{f : (∀ i, π i) → ℝ≥0∞} (hf : Measurable f) (hi : i ∉ s) (x : ∀ i, π i) (y : π i) :
(∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∘ (Function.update · i y) ∂μ) x := by
induction s using Finset.induction generalizing x with
| empty => simp
| @insert i' s hi' ih =>
rw [lmarginal_insert _ hf hi', lmarginal_insert _ (hf.comp measurable_update_left) hi']
have hii' : i ≠ i' := mt (by rintro rfl; exact mem_insert_self i s) hi
simp_rw [update_comm hii', ih (mt Finset.mem_insert_of_mem hi)]
theorem lmarginal_eq_of_subset {f g : (∀ i, π i) → ℝ≥0∞} (hst : s ⊆ t)
(hf : Measurable f) (hg : Measurable g) (hfg : ∫⋯∫⁻_s, f ∂μ = ∫⋯∫⁻_s, g ∂μ) :
∫⋯∫⁻_t, f ∂μ = ∫⋯∫⁻_t, g ∂μ := by
rw [← union_sdiff_of_subset hst, lmarginal_union' μ f hf disjoint_sdiff,
lmarginal_union' μ g hg disjoint_sdiff, hfg]
theorem lmarginal_le_of_subset {f g : (∀ i, π i) → ℝ≥0∞} (hst : s ⊆ t)
(hf : Measurable f) (hg : Measurable g) (hfg : ∫⋯∫⁻_s, f ∂μ ≤ ∫⋯∫⁻_s, g ∂μ) :
∫⋯∫⁻_t, f ∂μ ≤ ∫⋯∫⁻_t, g ∂μ := by
rw [← union_sdiff_of_subset hst, lmarginal_union' μ f hf disjoint_sdiff,
lmarginal_union' μ g hg disjoint_sdiff]
exact lmarginal_mono hfg
| Mathlib/MeasureTheory/Integral/Marginal.lean | 237 | 242 | theorem lintegral_eq_of_lmarginal_eq [Fintype δ] (s : Finset δ) {f g : (∀ i, π i) → ℝ≥0∞}
(hf : Measurable f) (hg : Measurable g) (hfg : ∫⋯∫⁻_s, f ∂μ = ∫⋯∫⁻_s, g ∂μ) :
∫⁻ x, f x ∂Measure.pi μ = ∫⁻ x, g x ∂Measure.pi μ := by |
rcases isEmpty_or_nonempty (∀ i, π i) with h|⟨⟨x⟩⟩
· simp_rw [lintegral_of_isEmpty]
simp_rw [lintegral_eq_lmarginal_univ x, lmarginal_eq_of_subset (Finset.subset_univ s) hf hg hfg]
|
import Mathlib.Topology.UniformSpace.UniformConvergence
import Mathlib.Topology.UniformSpace.Equicontinuity
import Mathlib.Topology.Separation
import Mathlib.Topology.Support
#align_import topology.uniform_space.compact from "leanprover-community/mathlib"@"735b22f8f9ff9792cf4212d7cb051c4c994bc685"
open scoped Classical
open Uniformity Topology Filter UniformSpace Set
variable {α β γ : Type*} [UniformSpace α] [UniformSpace β]
theorem nhdsSet_diagonal_eq_uniformity [CompactSpace α] : 𝓝ˢ (diagonal α) = 𝓤 α := by
refine nhdsSet_diagonal_le_uniformity.antisymm ?_
have :
(𝓤 (α × α)).HasBasis (fun U => U ∈ 𝓤 α) fun U =>
(fun p : (α × α) × α × α => ((p.1.1, p.2.1), p.1.2, p.2.2)) ⁻¹' U ×ˢ U := by
rw [uniformity_prod_eq_comap_prod]
exact (𝓤 α).basis_sets.prod_self.comap _
refine (isCompact_diagonal.nhdsSet_basis_uniformity this).ge_iff.2 fun U hU => ?_
exact mem_of_superset hU fun ⟨x, y⟩ hxy => mem_iUnion₂.2
⟨(x, x), rfl, refl_mem_uniformity hU, hxy⟩
#align nhds_set_diagonal_eq_uniformity nhdsSet_diagonal_eq_uniformity
theorem compactSpace_uniformity [CompactSpace α] : 𝓤 α = ⨆ x, 𝓝 (x, x) :=
nhdsSet_diagonal_eq_uniformity.symm.trans (nhdsSet_diagonal _)
#align compact_space_uniformity compactSpace_uniformity
theorem unique_uniformity_of_compact [t : TopologicalSpace γ] [CompactSpace γ]
{u u' : UniformSpace γ} (h : u.toTopologicalSpace = t) (h' : u'.toTopologicalSpace = t) :
u = u' := by
refine UniformSpace.ext ?_
have : @CompactSpace γ u.toTopologicalSpace := by rwa [h]
have : @CompactSpace γ u'.toTopologicalSpace := by rwa [h']
rw [@compactSpace_uniformity _ u, compactSpace_uniformity, h, h']
#align unique_uniformity_of_compact unique_uniformity_of_compact
def uniformSpaceOfCompactT2 [TopologicalSpace γ] [CompactSpace γ] [T2Space γ] : UniformSpace γ where
uniformity := 𝓝ˢ (diagonal γ)
symm := continuous_swap.tendsto_nhdsSet fun x => Eq.symm
comp := by
set 𝓝Δ := 𝓝ˢ (diagonal γ)
-- The filter of neighborhoods of Δ
set F := 𝓝Δ.lift' fun s : Set (γ × γ) => s ○ s
-- Compositions of neighborhoods of Δ
-- If this weren't true, then there would be V ∈ 𝓝Δ such that F ⊓ 𝓟 Vᶜ ≠ ⊥
rw [le_iff_forall_inf_principal_compl]
intro V V_in
by_contra H
haveI : NeBot (F ⊓ 𝓟 Vᶜ) := ⟨H⟩
-- Hence compactness would give us a cluster point (x, y) for F ⊓ 𝓟 Vᶜ
obtain ⟨⟨x, y⟩, hxy⟩ : ∃ p : γ × γ, ClusterPt p (F ⊓ 𝓟 Vᶜ) := exists_clusterPt_of_compactSpace _
-- In particular (x, y) is a cluster point of 𝓟 Vᶜ, hence is not in the interior of V,
-- and a fortiori not in Δ, so x ≠ y
have clV : ClusterPt (x, y) (𝓟 <| Vᶜ) := hxy.of_inf_right
have : (x, y) ∉ interior V := by
have : (x, y) ∈ closure Vᶜ := by rwa [mem_closure_iff_clusterPt]
rwa [closure_compl] at this
have diag_subset : diagonal γ ⊆ interior V := subset_interior_iff_mem_nhdsSet.2 V_in
have x_ne_y : x ≠ y := mt (@diag_subset (x, y)) this
-- Since γ is compact and Hausdorff, it is T₄, hence T₃.
-- So there are closed neighborhoods V₁ and V₂ of x and y contained in
-- disjoint open neighborhoods U₁ and U₂.
obtain
⟨U₁, _, V₁, V₁_in, U₂, _, V₂, V₂_in, V₁_cl, V₂_cl, U₁_op, U₂_op, VU₁, VU₂, hU₁₂⟩ :=
disjoint_nested_nhds x_ne_y
-- We set U₃ := (V₁ ∪ V₂)ᶜ so that W := U₁ ×ˢ U₁ ∪ U₂ ×ˢ U₂ ∪ U₃ ×ˢ U₃ is an open
-- neighborhood of Δ.
let U₃ := (V₁ ∪ V₂)ᶜ
have U₃_op : IsOpen U₃ := (V₁_cl.union V₂_cl).isOpen_compl
let W := U₁ ×ˢ U₁ ∪ U₂ ×ˢ U₂ ∪ U₃ ×ˢ U₃
have W_in : W ∈ 𝓝Δ := by
rw [mem_nhdsSet_iff_forall]
rintro ⟨z, z'⟩ (rfl : z = z')
refine IsOpen.mem_nhds ?_ ?_
· apply_rules [IsOpen.union, IsOpen.prod]
· simp only [W, mem_union, mem_prod, and_self_iff]
exact (_root_.em _).imp_left fun h => union_subset_union VU₁ VU₂ h
-- So W ○ W ∈ F by definition of F
have : W ○ W ∈ F := @mem_lift' _ _ _ (fun s => s ○ s) _ W_in
-- Porting note: was `by simpa only using mem_lift' W_in`
-- And V₁ ×ˢ V₂ ∈ 𝓝 (x, y)
have hV₁₂ : V₁ ×ˢ V₂ ∈ 𝓝 (x, y) := prod_mem_nhds V₁_in V₂_in
-- But (x, y) is also a cluster point of F so (V₁ ×ˢ V₂) ∩ (W ○ W) ≠ ∅
-- However the construction of W implies (V₁ ×ˢ V₂) ∩ (W ○ W) = ∅.
-- Indeed assume for contradiction there is some (u, v) in the intersection.
obtain ⟨⟨u, v⟩, ⟨u_in, v_in⟩, w, huw, hwv⟩ := clusterPt_iff.mp hxy.of_inf_left hV₁₂ this
-- So u ∈ V₁, v ∈ V₂, and there exists some w such that (u, w) ∈ W and (w ,v) ∈ W.
-- Because u is in V₁ which is disjoint from U₂ and U₃, (u, w) ∈ W forces (u, w) ∈ U₁ ×ˢ U₁.
have uw_in : (u, w) ∈ U₁ ×ˢ U₁ :=
(huw.resolve_right fun h => h.1 <| Or.inl u_in).resolve_right fun h =>
hU₁₂.le_bot ⟨VU₁ u_in, h.1⟩
-- Similarly, because v ∈ V₂, (w ,v) ∈ W forces (w, v) ∈ U₂ ×ˢ U₂.
have wv_in : (w, v) ∈ U₂ ×ˢ U₂ :=
(hwv.resolve_right fun h => h.2 <| Or.inr v_in).resolve_left fun h =>
hU₁₂.le_bot ⟨h.2, VU₂ v_in⟩
-- Hence w ∈ U₁ ∩ U₂ which is empty.
-- So we have a contradiction
exact hU₁₂.le_bot ⟨uw_in.2, wv_in.1⟩
nhds_eq_comap_uniformity x := by
simp_rw [nhdsSet_diagonal, comap_iSup, nhds_prod_eq, comap_prod, (· ∘ ·), comap_id']
rw [iSup_split_single _ x, comap_const_of_mem fun V => mem_of_mem_nhds]
suffices ∀ y ≠ x, comap (fun _ : γ ↦ x) (𝓝 y) ⊓ 𝓝 y ≤ 𝓝 x by simpa
intro y hxy
simp [comap_const_of_not_mem (compl_singleton_mem_nhds hxy) (not_not_intro rfl)]
#align uniform_space_of_compact_t2 uniformSpaceOfCompactT2
theorem CompactSpace.uniformContinuous_of_continuous [CompactSpace α] {f : α → β}
(h : Continuous f) : UniformContinuous f :=
calc map (Prod.map f f) (𝓤 α)
= map (Prod.map f f) (𝓝ˢ (diagonal α)) := by rw [nhdsSet_diagonal_eq_uniformity]
_ ≤ 𝓝ˢ (diagonal β) := (h.prod_map h).tendsto_nhdsSet mapsTo_prod_map_diagonal
_ ≤ 𝓤 β := nhdsSet_diagonal_le_uniformity
#align compact_space.uniform_continuous_of_continuous CompactSpace.uniformContinuous_of_continuous
theorem IsCompact.uniformContinuousOn_of_continuous {s : Set α} {f : α → β} (hs : IsCompact s)
(hf : ContinuousOn f s) : UniformContinuousOn f s := by
rw [uniformContinuousOn_iff_restrict]
rw [isCompact_iff_compactSpace] at hs
rw [continuousOn_iff_continuous_restrict] at hf
exact CompactSpace.uniformContinuous_of_continuous hf
#align is_compact.uniform_continuous_on_of_continuous IsCompact.uniformContinuousOn_of_continuous
| Mathlib/Topology/UniformSpace/Compact.lean | 181 | 193 | theorem IsCompact.uniformContinuousAt_of_continuousAt {r : Set (β × β)} {s : Set α}
(hs : IsCompact s) (f : α → β) (hf : ∀ a ∈ s, ContinuousAt f a) (hr : r ∈ 𝓤 β) :
{ x : α × α | x.1 ∈ s → (f x.1, f x.2) ∈ r } ∈ 𝓤 α := by |
obtain ⟨t, ht, htsymm, htr⟩ := comp_symm_mem_uniformity_sets hr
choose U hU T hT hb using fun a ha =>
exists_mem_nhds_ball_subset_of_mem_nhds ((hf a ha).preimage_mem_nhds <| mem_nhds_left _ ht)
obtain ⟨fs, hsU⟩ := hs.elim_nhds_subcover' U hU
apply mem_of_superset ((biInter_finset_mem fs).2 fun a _ => hT a a.2)
rintro ⟨a₁, a₂⟩ h h₁
obtain ⟨a, ha, haU⟩ := Set.mem_iUnion₂.1 (hsU h₁)
apply htr
refine ⟨f a, htsymm.mk_mem_comm.1 (hb _ _ _ haU ?_), hb _ _ _ haU ?_⟩
exacts [mem_ball_self _ (hT a a.2), mem_iInter₂.1 h a ha]
|
import Mathlib.MeasureTheory.Function.SimpleFuncDenseLp
#align_import measure_theory.integral.set_to_l1 from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
noncomputable section
open scoped Classical Topology NNReal ENNReal MeasureTheory Pointwise
open Set Filter TopologicalSpace ENNReal EMetric
namespace MeasureTheory
variable {α E F F' G 𝕜 : Type*} {p : ℝ≥0∞} [NormedAddCommGroup E] [NormedSpace ℝ E]
[NormedAddCommGroup F] [NormedSpace ℝ F] [NormedAddCommGroup F'] [NormedSpace ℝ F']
[NormedAddCommGroup G] {m : MeasurableSpace α} {μ : Measure α}
local infixr:25 " →ₛ " => SimpleFunc
open Finset
section FinMeasAdditive
def FinMeasAdditive {β} [AddMonoid β] {_ : MeasurableSpace α} (μ : Measure α) (T : Set α → β) :
Prop :=
∀ s t, MeasurableSet s → MeasurableSet t → μ s ≠ ∞ → μ t ≠ ∞ → s ∩ t = ∅ → T (s ∪ t) = T s + T t
#align measure_theory.fin_meas_additive MeasureTheory.FinMeasAdditive
namespace FinMeasAdditive
variable {β : Type*} [AddCommMonoid β] {T T' : Set α → β}
theorem zero : FinMeasAdditive μ (0 : Set α → β) := fun s t _ _ _ _ _ => by simp
#align measure_theory.fin_meas_additive.zero MeasureTheory.FinMeasAdditive.zero
| Mathlib/MeasureTheory/Integral/SetToL1.lean | 105 | 109 | theorem add (hT : FinMeasAdditive μ T) (hT' : FinMeasAdditive μ T') :
FinMeasAdditive μ (T + T') := by |
intro s t hs ht hμs hμt hst
simp only [hT s t hs ht hμs hμt hst, hT' s t hs ht hμs hμt hst, Pi.add_apply]
abel
|
import Mathlib.Algebra.BigOperators.Ring
import Mathlib.Combinatorics.Derangements.Basic
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Tactic.Ring
#align_import combinatorics.derangements.finite from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395"
open derangements Equiv Fintype
variable {α : Type*} [DecidableEq α] [Fintype α]
instance : DecidablePred (derangements α) := fun _ => Fintype.decidableForallFintype
-- Porting note: used to use the tactic delta_instance
instance : Fintype (derangements α) := Subtype.fintype (fun (_ : Perm α) => ∀ (x_1 : α), ¬_ = x_1)
theorem card_derangements_invariant {α β : Type*} [Fintype α] [DecidableEq α] [Fintype β]
[DecidableEq β] (h : card α = card β) : card (derangements α) = card (derangements β) :=
Fintype.card_congr (Equiv.derangementsCongr <| equivOfCardEq h)
#align card_derangements_invariant card_derangements_invariant
theorem card_derangements_fin_add_two (n : ℕ) :
card (derangements (Fin (n + 2))) =
(n + 1) * card (derangements (Fin n)) + (n + 1) * card (derangements (Fin (n + 1))) := by
-- get some basic results about the size of fin (n+1) plus or minus an element
have h1 : ∀ a : Fin (n + 1), card ({a}ᶜ : Set (Fin (n + 1))) = card (Fin n) := by
intro a
simp only [Fintype.card_fin, Finset.card_fin, Fintype.card_ofFinset, Finset.filter_ne' _ a,
Set.mem_compl_singleton_iff, Finset.card_erase_of_mem (Finset.mem_univ a),
add_tsub_cancel_right]
have h2 : card (Fin (n + 2)) = card (Option (Fin (n + 1))) := by simp only [card_fin, card_option]
-- rewrite the LHS and substitute in our fintype-level equivalence
simp only [card_derangements_invariant h2,
card_congr
(@derangementsRecursionEquiv (Fin (n + 1))
_),-- push the cardinality through the Σ and ⊕ so that we can use `card_n`
card_sigma,
card_sum, card_derangements_invariant (h1 _), Finset.sum_const, nsmul_eq_mul, Finset.card_fin,
mul_add, Nat.cast_id]
#align card_derangements_fin_add_two card_derangements_fin_add_two
def numDerangements : ℕ → ℕ
| 0 => 1
| 1 => 0
| n + 2 => (n + 1) * (numDerangements n + numDerangements (n + 1))
#align num_derangements numDerangements
@[simp]
theorem numDerangements_zero : numDerangements 0 = 1 :=
rfl
#align num_derangements_zero numDerangements_zero
@[simp]
theorem numDerangements_one : numDerangements 1 = 0 :=
rfl
#align num_derangements_one numDerangements_one
theorem numDerangements_add_two (n : ℕ) :
numDerangements (n + 2) = (n + 1) * (numDerangements n + numDerangements (n + 1)) :=
rfl
#align num_derangements_add_two numDerangements_add_two
| Mathlib/Combinatorics/Derangements/Finite.lean | 87 | 92 | theorem numDerangements_succ (n : ℕ) :
(numDerangements (n + 1) : ℤ) = (n + 1) * (numDerangements n : ℤ) - (-1) ^ n := by |
induction' n with n hn
· rfl
· simp only [numDerangements_add_two, hn, pow_succ, Int.ofNat_mul, Int.ofNat_add, Int.ofNat_succ]
ring
|
import Mathlib.Analysis.NormedSpace.Star.GelfandDuality
import Mathlib.Topology.Algebra.StarSubalgebra
#align_import analysis.normed_space.star.continuous_functional_calculus from "leanprover-community/mathlib"@"31c24aa72e7b3e5ed97a8412470e904f82b81004"
open scoped Pointwise ENNReal NNReal ComplexOrder
open WeakDual WeakDual.CharacterSpace elementalStarAlgebra
variable {A : Type*} [NormedRing A] [NormedAlgebra ℂ A]
variable [StarRing A] [CstarRing A] [StarModule ℂ A]
instance {R A : Type*} [CommRing R] [StarRing R] [NormedRing A] [Algebra R A] [StarRing A]
[ContinuousStar A] [StarModule R A] (a : A) [IsStarNormal a] :
NormedCommRing (elementalStarAlgebra R a) :=
{ SubringClass.toNormedRing (elementalStarAlgebra R a) with
mul_comm := mul_comm }
-- Porting note: these hack instances no longer seem to be necessary
#noalign elemental_star_algebra.complex.normed_algebra
variable [CompleteSpace A] (a : A) [IsStarNormal a] (S : StarSubalgebra ℂ A)
| Mathlib/Analysis/NormedSpace/Star/ContinuousFunctionalCalculus.lean | 81 | 94 | theorem spectrum_star_mul_self_of_isStarNormal :
spectrum ℂ (star a * a) ⊆ Set.Icc (0 : ℂ) ‖star a * a‖ := by |
-- this instance should be found automatically, but without providing it Lean goes on a wild
-- goose chase when trying to apply `spectrum.gelfandTransform_eq`.
--letI := elementalStarAlgebra.Complex.normedAlgebra a
rcases subsingleton_or_nontrivial A with ⟨⟩
· simp only [spectrum.of_subsingleton, Set.empty_subset]
· set a' : elementalStarAlgebra ℂ a := ⟨a, self_mem ℂ a⟩
refine (spectrum.subset_starSubalgebra (star a' * a')).trans ?_
rw [← spectrum.gelfandTransform_eq (star a' * a'), ContinuousMap.spectrum_eq_range]
rintro - ⟨φ, rfl⟩
rw [gelfandTransform_apply_apply ℂ _ (star a' * a') φ, map_mul φ, map_star φ]
rw [Complex.eq_coe_norm_of_nonneg (star_mul_self_nonneg _), ← map_star, ← map_mul]
exact ⟨by positivity, Complex.real_le_real.2 (AlgHom.norm_apply_le_self φ (star a' * a'))⟩
|
import Mathlib.Analysis.Analytic.Basic
import Mathlib.Combinatorics.Enumerative.Composition
#align_import analysis.analytic.composition from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a"
noncomputable section
variable {𝕜 : Type*} {E F G H : Type*}
open Filter List
open scoped Topology Classical NNReal ENNReal
section Topological
variable [CommRing 𝕜] [AddCommGroup E] [AddCommGroup F] [AddCommGroup G]
variable [Module 𝕜 E] [Module 𝕜 F] [Module 𝕜 G]
variable [TopologicalSpace E] [TopologicalSpace F] [TopologicalSpace G]
namespace FormalMultilinearSeries
variable [TopologicalAddGroup E] [ContinuousConstSMul 𝕜 E]
variable [TopologicalAddGroup F] [ContinuousConstSMul 𝕜 F]
variable [TopologicalAddGroup G] [ContinuousConstSMul 𝕜 G]
def applyComposition (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (c : Composition n) :
(Fin n → E) → Fin c.length → F := fun v i => p (c.blocksFun i) (v ∘ c.embedding i)
#align formal_multilinear_series.apply_composition FormalMultilinearSeries.applyComposition
theorem applyComposition_ones (p : FormalMultilinearSeries 𝕜 E F) (n : ℕ) :
p.applyComposition (Composition.ones n) = fun v i =>
p 1 fun _ => v (Fin.castLE (Composition.length_le _) i) := by
funext v i
apply p.congr (Composition.ones_blocksFun _ _)
intro j hjn hj1
obtain rfl : j = 0 := by omega
refine congr_arg v ?_
rw [Fin.ext_iff, Fin.coe_castLE, Composition.ones_embedding, Fin.val_mk]
#align formal_multilinear_series.apply_composition_ones FormalMultilinearSeries.applyComposition_ones
theorem applyComposition_single (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (hn : 0 < n)
(v : Fin n → E) : p.applyComposition (Composition.single n hn) v = fun _j => p n v := by
ext j
refine p.congr (by simp) fun i hi1 hi2 => ?_
dsimp
congr 1
convert Composition.single_embedding hn ⟨i, hi2⟩ using 1
cases' j with j_val j_property
have : j_val = 0 := le_bot_iff.1 (Nat.lt_succ_iff.1 j_property)
congr!
simp
#align formal_multilinear_series.apply_composition_single FormalMultilinearSeries.applyComposition_single
@[simp]
theorem removeZero_applyComposition (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ}
(c : Composition n) : p.removeZero.applyComposition c = p.applyComposition c := by
ext v i
simp [applyComposition, zero_lt_one.trans_le (c.one_le_blocksFun i), removeZero_of_pos]
#align formal_multilinear_series.remove_zero_apply_composition FormalMultilinearSeries.removeZero_applyComposition
theorem applyComposition_update (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (c : Composition n)
(j : Fin n) (v : Fin n → E) (z : E) :
p.applyComposition c (Function.update v j z) =
Function.update (p.applyComposition c v) (c.index j)
(p (c.blocksFun (c.index j))
(Function.update (v ∘ c.embedding (c.index j)) (c.invEmbedding j) z)) := by
ext k
by_cases h : k = c.index j
· rw [h]
let r : Fin (c.blocksFun (c.index j)) → Fin n := c.embedding (c.index j)
simp only [Function.update_same]
change p (c.blocksFun (c.index j)) (Function.update v j z ∘ r) = _
let j' := c.invEmbedding j
suffices B : Function.update v j z ∘ r = Function.update (v ∘ r) j' z by rw [B]
suffices C : Function.update v (r j') z ∘ r = Function.update (v ∘ r) j' z by
convert C; exact (c.embedding_comp_inv j).symm
exact Function.update_comp_eq_of_injective _ (c.embedding _).injective _ _
· simp only [h, Function.update_eq_self, Function.update_noteq, Ne, not_false_iff]
let r : Fin (c.blocksFun k) → Fin n := c.embedding k
change p (c.blocksFun k) (Function.update v j z ∘ r) = p (c.blocksFun k) (v ∘ r)
suffices B : Function.update v j z ∘ r = v ∘ r by rw [B]
apply Function.update_comp_eq_of_not_mem_range
rwa [c.mem_range_embedding_iff']
#align formal_multilinear_series.apply_composition_update FormalMultilinearSeries.applyComposition_update
@[simp]
| Mathlib/Analysis/Analytic/Composition.lean | 166 | 169 | theorem compContinuousLinearMap_applyComposition {n : ℕ} (p : FormalMultilinearSeries 𝕜 F G)
(f : E →L[𝕜] F) (c : Composition n) (v : Fin n → E) :
(p.compContinuousLinearMap f).applyComposition c v = p.applyComposition c (f ∘ v) := by |
simp (config := {unfoldPartialApp := true}) [applyComposition]; rfl
|
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]
theorem getVert_zero {u v} (w : G.Walk u v) : w.getVert 0 = u := by cases w <;> rfl
#align simple_graph.walk.get_vert_zero SimpleGraph.Walk.getVert_zero
theorem getVert_of_length_le {u v} (w : G.Walk u v) {i : ℕ} (hi : w.length ≤ i) :
w.getVert i = v := by
induction w generalizing i with
| nil => rfl
| cons _ _ ih =>
cases i
· cases hi
· exact ih (Nat.succ_le_succ_iff.1 hi)
#align simple_graph.walk.get_vert_of_length_le SimpleGraph.Walk.getVert_of_length_le
@[simp]
theorem getVert_length {u v} (w : G.Walk u v) : w.getVert w.length = v :=
w.getVert_of_length_le rfl.le
#align simple_graph.walk.get_vert_length SimpleGraph.Walk.getVert_length
theorem adj_getVert_succ {u v} (w : G.Walk u v) {i : ℕ} (hi : i < w.length) :
G.Adj (w.getVert i) (w.getVert (i + 1)) := by
induction w generalizing i with
| nil => cases hi
| cons hxy _ ih =>
cases i
· simp [getVert, hxy]
· exact ih (Nat.succ_lt_succ_iff.1 hi)
#align simple_graph.walk.adj_get_vert_succ SimpleGraph.Walk.adj_getVert_succ
@[simp]
theorem cons_append {u v w x : V} (h : G.Adj u v) (p : G.Walk v w) (q : G.Walk w x) :
(cons h p).append q = cons h (p.append q) := rfl
#align simple_graph.walk.cons_append SimpleGraph.Walk.cons_append
@[simp]
theorem cons_nil_append {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h nil).append p = cons h p := rfl
#align simple_graph.walk.cons_nil_append SimpleGraph.Walk.cons_nil_append
@[simp]
theorem append_nil {u v : V} (p : G.Walk u v) : p.append nil = p := by
induction p with
| nil => rfl
| cons _ _ ih => rw [cons_append, ih]
#align simple_graph.walk.append_nil SimpleGraph.Walk.append_nil
@[simp]
theorem nil_append {u v : V} (p : G.Walk u v) : nil.append p = p :=
rfl
#align simple_graph.walk.nil_append SimpleGraph.Walk.nil_append
theorem append_assoc {u v w x : V} (p : G.Walk u v) (q : G.Walk v w) (r : G.Walk w x) :
p.append (q.append r) = (p.append q).append r := by
induction p with
| nil => rfl
| cons h p' ih =>
dsimp only [append]
rw [ih]
#align simple_graph.walk.append_assoc SimpleGraph.Walk.append_assoc
@[simp]
theorem append_copy_copy {u v w u' v' w'} (p : G.Walk u v) (q : G.Walk v w)
(hu : u = u') (hv : v = v') (hw : w = w') :
(p.copy hu hv).append (q.copy hv hw) = (p.append q).copy hu hw := by
subst_vars
rfl
#align simple_graph.walk.append_copy_copy SimpleGraph.Walk.append_copy_copy
theorem concat_nil {u v : V} (h : G.Adj u v) : nil.concat h = cons h nil := rfl
#align simple_graph.walk.concat_nil SimpleGraph.Walk.concat_nil
@[simp]
theorem concat_cons {u v w x : V} (h : G.Adj u v) (p : G.Walk v w) (h' : G.Adj w x) :
(cons h p).concat h' = cons h (p.concat h') := rfl
#align simple_graph.walk.concat_cons SimpleGraph.Walk.concat_cons
theorem append_concat {u v w x : V} (p : G.Walk u v) (q : G.Walk v w) (h : G.Adj w x) :
p.append (q.concat h) = (p.append q).concat h := append_assoc _ _ _
#align simple_graph.walk.append_concat SimpleGraph.Walk.append_concat
theorem concat_append {u v w x : V} (p : G.Walk u v) (h : G.Adj v w) (q : G.Walk w x) :
(p.concat h).append q = p.append (cons h q) := by
rw [concat_eq_append, ← append_assoc, cons_nil_append]
#align simple_graph.walk.concat_append SimpleGraph.Walk.concat_append
theorem exists_cons_eq_concat {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
∃ (x : V) (q : G.Walk u x) (h' : G.Adj x w), cons h p = q.concat h' := by
induction p generalizing u with
| nil => exact ⟨_, nil, h, rfl⟩
| cons h' p ih =>
obtain ⟨y, q, h'', hc⟩ := ih h'
refine ⟨y, cons h q, h'', ?_⟩
rw [concat_cons, hc]
#align simple_graph.walk.exists_cons_eq_concat SimpleGraph.Walk.exists_cons_eq_concat
theorem exists_concat_eq_cons {u v w : V} :
∀ (p : G.Walk u v) (h : G.Adj v w),
∃ (x : V) (h' : G.Adj u x) (q : G.Walk x w), p.concat h = cons h' q
| nil, h => ⟨_, h, nil, rfl⟩
| cons h' p, h => ⟨_, h', Walk.concat p h, concat_cons _ _ _⟩
#align simple_graph.walk.exists_concat_eq_cons SimpleGraph.Walk.exists_concat_eq_cons
@[simp]
theorem reverse_nil {u : V} : (nil : G.Walk u u).reverse = nil := rfl
#align simple_graph.walk.reverse_nil SimpleGraph.Walk.reverse_nil
theorem reverse_singleton {u v : V} (h : G.Adj u v) : (cons h nil).reverse = cons (G.symm h) nil :=
rfl
#align simple_graph.walk.reverse_singleton SimpleGraph.Walk.reverse_singleton
@[simp]
theorem cons_reverseAux {u v w x : V} (p : G.Walk u v) (q : G.Walk w x) (h : G.Adj w u) :
(cons h p).reverseAux q = p.reverseAux (cons (G.symm h) q) := rfl
#align simple_graph.walk.cons_reverse_aux SimpleGraph.Walk.cons_reverseAux
@[simp]
protected theorem append_reverseAux {u v w x : V}
(p : G.Walk u v) (q : G.Walk v w) (r : G.Walk u x) :
(p.append q).reverseAux r = q.reverseAux (p.reverseAux r) := by
induction p with
| nil => rfl
| cons h _ ih => exact ih q (cons (G.symm h) r)
#align simple_graph.walk.append_reverse_aux SimpleGraph.Walk.append_reverseAux
@[simp]
protected theorem reverseAux_append {u v w x : V}
(p : G.Walk u v) (q : G.Walk u w) (r : G.Walk w x) :
(p.reverseAux q).append r = p.reverseAux (q.append r) := by
induction p with
| nil => rfl
| cons h _ ih => simp [ih (cons (G.symm h) q)]
#align simple_graph.walk.reverse_aux_append SimpleGraph.Walk.reverseAux_append
protected theorem reverseAux_eq_reverse_append {u v w : V} (p : G.Walk u v) (q : G.Walk u w) :
p.reverseAux q = p.reverse.append q := by simp [reverse]
#align simple_graph.walk.reverse_aux_eq_reverse_append SimpleGraph.Walk.reverseAux_eq_reverse_append
@[simp]
theorem reverse_cons {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h p).reverse = p.reverse.append (cons (G.symm h) nil) := by simp [reverse]
#align simple_graph.walk.reverse_cons SimpleGraph.Walk.reverse_cons
@[simp]
theorem reverse_copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') :
(p.copy hu hv).reverse = p.reverse.copy hv hu := by
subst_vars
rfl
#align simple_graph.walk.reverse_copy SimpleGraph.Walk.reverse_copy
@[simp]
theorem reverse_append {u v w : V} (p : G.Walk u v) (q : G.Walk v w) :
(p.append q).reverse = q.reverse.append p.reverse := by simp [reverse]
#align simple_graph.walk.reverse_append SimpleGraph.Walk.reverse_append
@[simp]
theorem reverse_concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
(p.concat h).reverse = cons (G.symm h) p.reverse := by simp [concat_eq_append]
#align simple_graph.walk.reverse_concat SimpleGraph.Walk.reverse_concat
@[simp]
theorem reverse_reverse {u v : V} (p : G.Walk u v) : p.reverse.reverse = p := by
induction p with
| nil => rfl
| cons _ _ ih => simp [ih]
#align simple_graph.walk.reverse_reverse SimpleGraph.Walk.reverse_reverse
@[simp]
theorem length_nil {u : V} : (nil : G.Walk u u).length = 0 := rfl
#align simple_graph.walk.length_nil SimpleGraph.Walk.length_nil
@[simp]
theorem length_cons {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h p).length = p.length + 1 := rfl
#align simple_graph.walk.length_cons SimpleGraph.Walk.length_cons
@[simp]
theorem length_copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') :
(p.copy hu hv).length = p.length := by
subst_vars
rfl
#align simple_graph.walk.length_copy SimpleGraph.Walk.length_copy
@[simp]
theorem length_append {u v w : V} (p : G.Walk u v) (q : G.Walk v w) :
(p.append q).length = p.length + q.length := by
induction p with
| nil => simp
| cons _ _ ih => simp [ih, add_comm, add_left_comm, add_assoc]
#align simple_graph.walk.length_append SimpleGraph.Walk.length_append
@[simp]
theorem length_concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
(p.concat h).length = p.length + 1 := length_append _ _
#align simple_graph.walk.length_concat SimpleGraph.Walk.length_concat
@[simp]
protected theorem length_reverseAux {u v w : V} (p : G.Walk u v) (q : G.Walk u w) :
(p.reverseAux q).length = p.length + q.length := by
induction p with
| nil => simp!
| cons _ _ ih => simp [ih, Nat.succ_add, Nat.add_assoc]
#align simple_graph.walk.length_reverse_aux SimpleGraph.Walk.length_reverseAux
@[simp]
theorem length_reverse {u v : V} (p : G.Walk u v) : p.reverse.length = p.length := by simp [reverse]
#align simple_graph.walk.length_reverse SimpleGraph.Walk.length_reverse
theorem eq_of_length_eq_zero {u v : V} : ∀ {p : G.Walk u v}, p.length = 0 → u = v
| nil, _ => rfl
#align simple_graph.walk.eq_of_length_eq_zero SimpleGraph.Walk.eq_of_length_eq_zero
theorem adj_of_length_eq_one {u v : V} : ∀ {p : G.Walk u v}, p.length = 1 → G.Adj u v
| cons h nil, _ => h
@[simp]
theorem exists_length_eq_zero_iff {u v : V} : (∃ p : G.Walk u v, p.length = 0) ↔ u = v := by
constructor
· rintro ⟨p, hp⟩
exact eq_of_length_eq_zero hp
· rintro rfl
exact ⟨nil, rfl⟩
#align simple_graph.walk.exists_length_eq_zero_iff SimpleGraph.Walk.exists_length_eq_zero_iff
@[simp]
theorem length_eq_zero_iff {u : V} {p : G.Walk u u} : p.length = 0 ↔ p = nil := by cases p <;> simp
#align simple_graph.walk.length_eq_zero_iff SimpleGraph.Walk.length_eq_zero_iff
theorem getVert_append {u v w : V} (p : G.Walk u v) (q : G.Walk v w) (i : ℕ) :
(p.append q).getVert i = if i < p.length then p.getVert i else q.getVert (i - p.length) := by
induction p generalizing i with
| nil => simp
| cons h p ih => cases i <;> simp [getVert, ih, Nat.succ_lt_succ_iff]
theorem getVert_reverse {u v : V} (p : G.Walk u v) (i : ℕ) :
p.reverse.getVert i = p.getVert (p.length - i) := by
induction p with
| nil => rfl
| cons h p ih =>
simp only [reverse_cons, getVert_append, length_reverse, ih, length_cons]
split_ifs
next hi =>
rw [Nat.succ_sub hi.le]
simp [getVert]
next hi =>
obtain rfl | hi' := Nat.eq_or_lt_of_not_lt hi
· simp [getVert]
· rw [Nat.eq_add_of_sub_eq (Nat.sub_pos_of_lt hi') rfl, Nat.sub_eq_zero_of_le hi']
simp [getVert]
theorem concat_ne_nil {u v : V} (p : G.Walk u v) (h : G.Adj v u) : p.concat h ≠ nil := by
cases p <;> simp [concat]
#align simple_graph.walk.concat_ne_nil SimpleGraph.Walk.concat_ne_nil
theorem concat_inj {u v v' w : V} {p : G.Walk u v} {h : G.Adj v w} {p' : G.Walk u v'}
{h' : G.Adj v' w} (he : p.concat h = p'.concat h') : ∃ hv : v = v', p.copy rfl hv = p' := by
induction p with
| nil =>
cases p'
· exact ⟨rfl, rfl⟩
· exfalso
simp only [concat_nil, concat_cons, cons.injEq] at he
obtain ⟨rfl, he⟩ := he
simp only [heq_iff_eq] at he
exact concat_ne_nil _ _ he.symm
| cons _ _ ih =>
rw [concat_cons] at he
cases p'
· exfalso
simp only [concat_nil, cons.injEq] at he
obtain ⟨rfl, he⟩ := he
rw [heq_iff_eq] at he
exact concat_ne_nil _ _ he
· rw [concat_cons, cons.injEq] at he
obtain ⟨rfl, he⟩ := he
rw [heq_iff_eq] at he
obtain ⟨rfl, rfl⟩ := ih he
exact ⟨rfl, rfl⟩
#align simple_graph.walk.concat_inj SimpleGraph.Walk.concat_inj
def support {u v : V} : G.Walk u v → List V
| nil => [u]
| cons _ p => u :: p.support
#align simple_graph.walk.support SimpleGraph.Walk.support
def darts {u v : V} : G.Walk u v → List G.Dart
| nil => []
| cons h p => ⟨(u, _), h⟩ :: p.darts
#align simple_graph.walk.darts SimpleGraph.Walk.darts
def edges {u v : V} (p : G.Walk u v) : List (Sym2 V) := p.darts.map Dart.edge
#align simple_graph.walk.edges SimpleGraph.Walk.edges
@[simp]
theorem support_nil {u : V} : (nil : G.Walk u u).support = [u] := rfl
#align simple_graph.walk.support_nil SimpleGraph.Walk.support_nil
@[simp]
theorem support_cons {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
(cons h p).support = u :: p.support := rfl
#align simple_graph.walk.support_cons SimpleGraph.Walk.support_cons
@[simp]
theorem support_concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
(p.concat h).support = p.support.concat w := by
induction p <;> simp [*, concat_nil]
#align simple_graph.walk.support_concat SimpleGraph.Walk.support_concat
@[simp]
theorem support_copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') :
(p.copy hu hv).support = p.support := by
subst_vars
rfl
#align simple_graph.walk.support_copy SimpleGraph.Walk.support_copy
theorem support_append {u v w : V} (p : G.Walk u v) (p' : G.Walk v w) :
(p.append p').support = p.support ++ p'.support.tail := by
induction p <;> cases p' <;> simp [*]
#align simple_graph.walk.support_append SimpleGraph.Walk.support_append
@[simp]
theorem support_reverse {u v : V} (p : G.Walk u v) : p.reverse.support = p.support.reverse := by
induction p <;> simp [support_append, *]
#align simple_graph.walk.support_reverse SimpleGraph.Walk.support_reverse
@[simp]
theorem support_ne_nil {u v : V} (p : G.Walk u v) : p.support ≠ [] := by cases p <;> simp
#align simple_graph.walk.support_ne_nil SimpleGraph.Walk.support_ne_nil
theorem tail_support_append {u v w : V} (p : G.Walk u v) (p' : G.Walk v w) :
(p.append p').support.tail = p.support.tail ++ p'.support.tail := by
rw [support_append, List.tail_append_of_ne_nil _ _ (support_ne_nil _)]
#align simple_graph.walk.tail_support_append SimpleGraph.Walk.tail_support_append
theorem support_eq_cons {u v : V} (p : G.Walk u v) : p.support = u :: p.support.tail := by
cases p <;> simp
#align simple_graph.walk.support_eq_cons SimpleGraph.Walk.support_eq_cons
@[simp]
theorem start_mem_support {u v : V} (p : G.Walk u v) : u ∈ p.support := by cases p <;> simp
#align simple_graph.walk.start_mem_support SimpleGraph.Walk.start_mem_support
@[simp]
theorem end_mem_support {u v : V} (p : G.Walk u v) : v ∈ p.support := by induction p <;> simp [*]
#align simple_graph.walk.end_mem_support SimpleGraph.Walk.end_mem_support
@[simp]
theorem support_nonempty {u v : V} (p : G.Walk u v) : { w | w ∈ p.support }.Nonempty :=
⟨u, by simp⟩
#align simple_graph.walk.support_nonempty SimpleGraph.Walk.support_nonempty
theorem mem_support_iff {u v w : V} (p : G.Walk u v) :
w ∈ p.support ↔ w = u ∨ w ∈ p.support.tail := by cases p <;> simp
#align simple_graph.walk.mem_support_iff SimpleGraph.Walk.mem_support_iff
theorem mem_support_nil_iff {u v : V} : u ∈ (nil : G.Walk v v).support ↔ u = v := by simp
#align simple_graph.walk.mem_support_nil_iff SimpleGraph.Walk.mem_support_nil_iff
@[simp]
theorem mem_tail_support_append_iff {t u v w : V} (p : G.Walk u v) (p' : G.Walk v w) :
t ∈ (p.append p').support.tail ↔ t ∈ p.support.tail ∨ t ∈ p'.support.tail := by
rw [tail_support_append, List.mem_append]
#align simple_graph.walk.mem_tail_support_append_iff SimpleGraph.Walk.mem_tail_support_append_iff
@[simp]
theorem end_mem_tail_support_of_ne {u v : V} (h : u ≠ v) (p : G.Walk u v) : v ∈ p.support.tail := by
obtain ⟨_, _, _, rfl⟩ := exists_eq_cons_of_ne h p
simp
#align simple_graph.walk.end_mem_tail_support_of_ne SimpleGraph.Walk.end_mem_tail_support_of_ne
@[simp, nolint unusedHavesSuffices]
theorem mem_support_append_iff {t u v w : V} (p : G.Walk u v) (p' : G.Walk v w) :
t ∈ (p.append p').support ↔ t ∈ p.support ∨ t ∈ p'.support := by
simp only [mem_support_iff, mem_tail_support_append_iff]
obtain rfl | h := eq_or_ne t v <;> obtain rfl | h' := eq_or_ne t u <;>
-- this `have` triggers the unusedHavesSuffices linter:
(try have := h'.symm) <;> simp [*]
#align simple_graph.walk.mem_support_append_iff SimpleGraph.Walk.mem_support_append_iff
@[simp]
theorem subset_support_append_left {V : Type u} {G : SimpleGraph V} {u v w : V}
(p : G.Walk u v) (q : G.Walk v w) : p.support ⊆ (p.append q).support := by
simp only [Walk.support_append, List.subset_append_left]
#align simple_graph.walk.subset_support_append_left SimpleGraph.Walk.subset_support_append_left
@[simp]
theorem subset_support_append_right {V : Type u} {G : SimpleGraph V} {u v w : V}
(p : G.Walk u v) (q : G.Walk v w) : q.support ⊆ (p.append q).support := by
intro h
simp (config := { contextual := true }) only [mem_support_append_iff, or_true_iff, imp_true_iff]
#align simple_graph.walk.subset_support_append_right SimpleGraph.Walk.subset_support_append_right
| Mathlib/Combinatorics/SimpleGraph/Connectivity.lean | 645 | 646 | theorem coe_support {u v : V} (p : G.Walk u v) :
(p.support : Multiset V) = {u} + p.support.tail := by | cases p <;> rfl
|
import Mathlib.Algebra.Order.Ring.Rat
import Mathlib.Tactic.NormNum.Inv
import Mathlib.Tactic.NormNum.Pow
import Mathlib.Util.AtomM
set_option autoImplicit true
namespace Mathlib.Tactic
namespace Ring
open Mathlib.Meta Qq NormNum Lean.Meta AtomM
open Lean (MetaM Expr mkRawNatLit)
def instCommSemiringNat : CommSemiring ℕ := inferInstance
def sℕ : Q(CommSemiring ℕ) := q(instCommSemiringNat)
-- In this file, we would like to use multi-character auto-implicits.
set_option relaxedAutoImplicit true
mutual
inductive ExBase : ∀ {α : Q(Type u)}, Q(CommSemiring $α) → (e : Q($α)) → Type
| atom (id : ℕ) : ExBase sα e
| sum (_ : ExSum sα e) : ExBase sα e
inductive ExProd : ∀ {α : Q(Type u)}, Q(CommSemiring $α) → (e : Q($α)) → Type
| const (value : ℚ) (hyp : Option Expr := none) : ExProd sα e
| mul {α : Q(Type u)} {sα : Q(CommSemiring $α)} {x : Q($α)} {e : Q(ℕ)} {b : Q($α)} :
ExBase sα x → ExProd sℕ e → ExProd sα b → ExProd sα q($x ^ $e * $b)
inductive ExSum : ∀ {α : Q(Type u)}, Q(CommSemiring $α) → (e : Q($α)) → Type
| zero {α : Q(Type u)} {sα : Q(CommSemiring $α)} : ExSum sα q(0 : $α)
| add {α : Q(Type u)} {sα : Q(CommSemiring $α)} {a b : Q($α)} :
ExProd sα a → ExSum sα b → ExSum sα q($a + $b)
end
mutual -- partial only to speed up compilation
partial def ExBase.eq : ExBase sα a → ExBase sα b → Bool
| .atom i, .atom j => i == j
| .sum a, .sum b => a.eq b
| _, _ => false
@[inherit_doc ExBase.eq]
partial def ExProd.eq : ExProd sα a → ExProd sα b → Bool
| .const i _, .const j _ => i == j
| .mul a₁ a₂ a₃, .mul b₁ b₂ b₃ => a₁.eq b₁ && a₂.eq b₂ && a₃.eq b₃
| _, _ => false
@[inherit_doc ExBase.eq]
partial def ExSum.eq : ExSum sα a → ExSum sα b → Bool
| .zero, .zero => true
| .add a₁ a₂, .add b₁ b₂ => a₁.eq b₁ && a₂.eq b₂
| _, _ => false
end
mutual -- partial only to speed up compilation
partial def ExBase.cmp : ExBase sα a → ExBase sα b → Ordering
| .atom i, .atom j => compare i j
| .sum a, .sum b => a.cmp b
| .atom .., .sum .. => .lt
| .sum .., .atom .. => .gt
@[inherit_doc ExBase.cmp]
partial def ExProd.cmp : ExProd sα a → ExProd sα b → Ordering
| .const i _, .const j _ => compare i j
| .mul a₁ a₂ a₃, .mul b₁ b₂ b₃ => (a₁.cmp b₁).then (a₂.cmp b₂) |>.then (a₃.cmp b₃)
| .const _ _, .mul .. => .lt
| .mul .., .const _ _ => .gt
@[inherit_doc ExBase.cmp]
partial def ExSum.cmp : ExSum sα a → ExSum sα b → Ordering
| .zero, .zero => .eq
| .add a₁ a₂, .add b₁ b₂ => (a₁.cmp b₁).then (a₂.cmp b₂)
| .zero, .add .. => .lt
| .add .., .zero => .gt
end
instance : Inhabited (Σ e, (ExBase sα) e) := ⟨default, .atom 0⟩
instance : Inhabited (Σ e, (ExSum sα) e) := ⟨_, .zero⟩
instance : Inhabited (Σ e, (ExProd sα) e) := ⟨default, .const 0 none⟩
mutual
partial def ExBase.cast : ExBase sα a → Σ a, ExBase sβ a
| .atom i => ⟨a, .atom i⟩
| .sum a => let ⟨_, vb⟩ := a.cast; ⟨_, .sum vb⟩
partial def ExProd.cast : ExProd sα a → Σ a, ExProd sβ a
| .const i h => ⟨a, .const i h⟩
| .mul a₁ a₂ a₃ => ⟨_, .mul a₁.cast.2 a₂ a₃.cast.2⟩
partial def ExSum.cast : ExSum sα a → Σ a, ExSum sβ a
| .zero => ⟨_, .zero⟩
| .add a₁ a₂ => ⟨_, .add a₁.cast.2 a₂.cast.2⟩
end
structure Result {α : Q(Type u)} (E : Q($α) → Type) (e : Q($α)) where
expr : Q($α)
val : E expr
proof : Q($e = $expr)
instance [Inhabited (Σ e, E e)] : Inhabited (Result E e) :=
let ⟨e', v⟩ : Σ e, E e := default; ⟨e', v, default⟩
variable {α : Q(Type u)} (sα : Q(CommSemiring $α)) [CommSemiring R]
def ExProd.mkNat (n : ℕ) : (e : Q($α)) × ExProd sα e :=
let lit : Q(ℕ) := mkRawNatLit n
⟨q(($lit).rawCast : $α), .const n none⟩
def ExProd.mkNegNat (_ : Q(Ring $α)) (n : ℕ) : (e : Q($α)) × ExProd sα e :=
let lit : Q(ℕ) := mkRawNatLit n
⟨q((Int.negOfNat $lit).rawCast : $α), .const (-n) none⟩
def ExProd.mkRat (_ : Q(DivisionRing $α)) (q : ℚ) (n : Q(ℤ)) (d : Q(ℕ)) (h : Expr) :
(e : Q($α)) × ExProd sα e :=
⟨q(Rat.rawCast $n $d : $α), .const q h⟩
section
variable {sα}
def ExBase.toProd (va : ExBase sα a) (vb : ExProd sℕ b) :
ExProd sα q($a ^ $b * (nat_lit 1).rawCast) := .mul va vb (.const 1 none)
def ExProd.toSum (v : ExProd sα e) : ExSum sα q($e + 0) := .add v .zero
def ExProd.coeff : ExProd sα e → ℚ
| .const q _ => q
| .mul _ _ v => v.coeff
end
inductive Overlap (e : Q($α)) where
| zero (_ : Q(IsNat $e (nat_lit 0)))
| nonzero (_ : Result (ExProd sα) e)
theorem add_overlap_pf (x : R) (e) (pq_pf : a + b = c) :
x ^ e * a + x ^ e * b = x ^ e * c := by subst_vars; simp [mul_add]
theorem add_overlap_pf_zero (x : R) (e) :
IsNat (a + b) (nat_lit 0) → IsNat (x ^ e * a + x ^ e * b) (nat_lit 0)
| ⟨h⟩ => ⟨by simp [h, ← mul_add]⟩
def evalAddOverlap (va : ExProd sα a) (vb : ExProd sα b) : Option (Overlap sα q($a + $b)) :=
match va, vb with
| .const za ha, .const zb hb => do
let ra := Result.ofRawRat za a ha; let rb := Result.ofRawRat zb b hb
let res ← NormNum.evalAdd.core q($a + $b) q(HAdd.hAdd) a b ra rb
match res with
| .isNat _ (.lit (.natVal 0)) p => pure <| .zero p
| rc =>
let ⟨zc, hc⟩ ← rc.toRatNZ
let ⟨c, pc⟩ := rc.toRawEq
pure <| .nonzero ⟨c, .const zc hc, pc⟩
| .mul (x := a₁) (e := a₂) va₁ va₂ va₃, .mul vb₁ vb₂ vb₃ => do
guard (va₁.eq vb₁ && va₂.eq vb₂)
match ← evalAddOverlap va₃ vb₃ with
| .zero p => pure <| .zero (q(add_overlap_pf_zero $a₁ $a₂ $p) : Expr)
| .nonzero ⟨_, vc, p⟩ =>
pure <| .nonzero ⟨_, .mul va₁ va₂ vc, (q(add_overlap_pf $a₁ $a₂ $p) : Expr)⟩
| _, _ => none
theorem add_pf_zero_add (b : R) : 0 + b = b := by simp
theorem add_pf_add_zero (a : R) : a + 0 = a := by simp
theorem add_pf_add_overlap
(_ : a₁ + b₁ = c₁) (_ : a₂ + b₂ = c₂) : (a₁ + a₂ : R) + (b₁ + b₂) = c₁ + c₂ := by
subst_vars; simp [add_assoc, add_left_comm]
theorem add_pf_add_overlap_zero
(h : IsNat (a₁ + b₁) (nat_lit 0)) (h₄ : a₂ + b₂ = c) : (a₁ + a₂ : R) + (b₁ + b₂) = c := by
subst_vars; rw [add_add_add_comm, h.1, Nat.cast_zero, add_pf_zero_add]
theorem add_pf_add_lt (a₁ : R) (_ : a₂ + b = c) : (a₁ + a₂) + b = a₁ + c := by simp [*, add_assoc]
theorem add_pf_add_gt (b₁ : R) (_ : a + b₂ = c) : a + (b₁ + b₂) = b₁ + c := by
subst_vars; simp [add_left_comm]
partial def evalAdd (va : ExSum sα a) (vb : ExSum sα b) : Result (ExSum sα) q($a + $b) :=
match va, vb with
| .zero, vb => ⟨b, vb, q(add_pf_zero_add $b)⟩
| va, .zero => ⟨a, va, q(add_pf_add_zero $a)⟩
| .add (a := a₁) (b := _a₂) va₁ va₂, .add (a := b₁) (b := _b₂) vb₁ vb₂ =>
match evalAddOverlap sα va₁ vb₁ with
| some (.nonzero ⟨_, vc₁, pc₁⟩) =>
let ⟨_, vc₂, pc₂⟩ := evalAdd va₂ vb₂
⟨_, .add vc₁ vc₂, q(add_pf_add_overlap $pc₁ $pc₂)⟩
| some (.zero pc₁) =>
let ⟨c₂, vc₂, pc₂⟩ := evalAdd va₂ vb₂
⟨c₂, vc₂, q(add_pf_add_overlap_zero $pc₁ $pc₂)⟩
| none =>
if let .lt := va₁.cmp vb₁ then
let ⟨_c, vc, (pc : Q($_a₂ + ($b₁ + $_b₂) = $_c))⟩ := evalAdd va₂ vb
⟨_, .add va₁ vc, q(add_pf_add_lt $a₁ $pc)⟩
else
let ⟨_c, vc, (pc : Q($a₁ + $_a₂ + $_b₂ = $_c))⟩ := evalAdd va vb₂
⟨_, .add vb₁ vc, q(add_pf_add_gt $b₁ $pc)⟩
theorem one_mul (a : R) : (nat_lit 1).rawCast * a = a := by simp [Nat.rawCast]
theorem mul_one (a : R) : a * (nat_lit 1).rawCast = a := by simp [Nat.rawCast]
theorem mul_pf_left (a₁ : R) (a₂) (_ : a₃ * b = c) : (a₁ ^ a₂ * a₃ : R) * b = a₁ ^ a₂ * c := by
subst_vars; rw [mul_assoc]
theorem mul_pf_right (b₁ : R) (b₂) (_ : a * b₃ = c) : a * (b₁ ^ b₂ * b₃) = b₁ ^ b₂ * c := by
subst_vars; rw [mul_left_comm]
theorem mul_pp_pf_overlap (x : R) (_ : ea + eb = e) (_ : a₂ * b₂ = c) :
(x ^ ea * a₂ : R) * (x ^ eb * b₂) = x ^ e * c := by
subst_vars; simp [pow_add, mul_mul_mul_comm]
partial def evalMulProd (va : ExProd sα a) (vb : ExProd sα b) : Result (ExProd sα) q($a * $b) :=
match va, vb with
| .const za ha, .const zb hb =>
if za = 1 then
⟨b, .const zb hb, (q(one_mul $b) : Expr)⟩
else if zb = 1 then
⟨a, .const za ha, (q(mul_one $a) : Expr)⟩
else
let ra := Result.ofRawRat za a ha; let rb := Result.ofRawRat zb b hb
let rc := (NormNum.evalMul.core q($a * $b) q(HMul.hMul) _ _
q(CommSemiring.toSemiring) ra rb).get!
let ⟨zc, hc⟩ := rc.toRatNZ.get!
let ⟨c, pc⟩ := rc.toRawEq
⟨c, .const zc hc, pc⟩
| .mul (x := a₁) (e := a₂) va₁ va₂ va₃, .const _ _ =>
let ⟨_, vc, pc⟩ := evalMulProd va₃ vb
⟨_, .mul va₁ va₂ vc, (q(mul_pf_left $a₁ $a₂ $pc) : Expr)⟩
| .const _ _, .mul (x := b₁) (e := b₂) vb₁ vb₂ vb₃ =>
let ⟨_, vc, pc⟩ := evalMulProd va vb₃
⟨_, .mul vb₁ vb₂ vc, (q(mul_pf_right $b₁ $b₂ $pc) : Expr)⟩
| .mul (x := xa) (e := ea) vxa vea va₂, .mul (x := xb) (e := eb) vxb veb vb₂ => Id.run do
if vxa.eq vxb then
if let some (.nonzero ⟨_, ve, pe⟩) := evalAddOverlap sℕ vea veb then
let ⟨_, vc, pc⟩ := evalMulProd va₂ vb₂
return ⟨_, .mul vxa ve vc, (q(mul_pp_pf_overlap $xa $pe $pc) : Expr)⟩
if let .lt := (vxa.cmp vxb).then (vea.cmp veb) then
let ⟨_, vc, pc⟩ := evalMulProd va₂ vb
⟨_, .mul vxa vea vc, (q(mul_pf_left $xa $ea $pc) : Expr)⟩
else
let ⟨_, vc, pc⟩ := evalMulProd va vb₂
⟨_, .mul vxb veb vc, (q(mul_pf_right $xb $eb $pc) : Expr)⟩
theorem mul_zero (a : R) : a * 0 = 0 := by simp
theorem mul_add (_ : (a : R) * b₁ = c₁) (_ : a * b₂ = c₂) (_ : c₁ + 0 + c₂ = d) :
a * (b₁ + b₂) = d := by subst_vars; simp [_root_.mul_add]
def evalMul₁ (va : ExProd sα a) (vb : ExSum sα b) : Result (ExSum sα) q($a * $b) :=
match vb with
| .zero => ⟨_, .zero, q(mul_zero $a)⟩
| .add vb₁ vb₂ =>
let ⟨_, vc₁, pc₁⟩ := evalMulProd sα va vb₁
let ⟨_, vc₂, pc₂⟩ := evalMul₁ va vb₂
let ⟨_, vd, pd⟩ := evalAdd sα vc₁.toSum vc₂
⟨_, vd, q(mul_add $pc₁ $pc₂ $pd)⟩
theorem zero_mul (b : R) : 0 * b = 0 := by simp
theorem add_mul (_ : (a₁ : R) * b = c₁) (_ : a₂ * b = c₂) (_ : c₁ + c₂ = d) :
(a₁ + a₂) * b = d := by subst_vars; simp [_root_.add_mul]
def evalMul (va : ExSum sα a) (vb : ExSum sα b) : Result (ExSum sα) q($a * $b) :=
match va with
| .zero => ⟨_, .zero, q(zero_mul $b)⟩
| .add va₁ va₂ =>
let ⟨_, vc₁, pc₁⟩ := evalMul₁ sα va₁ vb
let ⟨_, vc₂, pc₂⟩ := evalMul va₂ vb
let ⟨_, vd, pd⟩ := evalAdd sα vc₁ vc₂
⟨_, vd, q(add_mul $pc₁ $pc₂ $pd)⟩
theorem natCast_nat (n) : ((Nat.rawCast n : ℕ) : R) = Nat.rawCast n := by simp
theorem natCast_mul (a₂) (_ : ((a₁ : ℕ) : R) = b₁) (_ : ((a₃ : ℕ) : R) = b₃) :
((a₁ ^ a₂ * a₃ : ℕ) : R) = b₁ ^ a₂ * b₃ := by subst_vars; simp
theorem natCast_zero : ((0 : ℕ) : R) = 0 := Nat.cast_zero
theorem natCast_add (_ : ((a₁ : ℕ) : R) = b₁) (_ : ((a₂ : ℕ) : R) = b₂) :
((a₁ + a₂ : ℕ) : R) = b₁ + b₂ := by subst_vars; simp
mutual
partial def ExBase.evalNatCast (va : ExBase sℕ a) : AtomM (Result (ExBase sα) q($a)) :=
match va with
| .atom _ => do
let a' : Q($α) := q($a)
let i ← addAtom a'
pure ⟨a', ExBase.atom i, (q(Eq.refl $a') : Expr)⟩
| .sum va => do
let ⟨_, vc, p⟩ ← va.evalNatCast
pure ⟨_, .sum vc, p⟩
partial def ExProd.evalNatCast (va : ExProd sℕ a) : AtomM (Result (ExProd sα) q($a)) :=
match va with
| .const c hc =>
have n : Q(ℕ) := a.appArg!
pure ⟨q(Nat.rawCast $n), .const c hc, (q(natCast_nat (R := $α) $n) : Expr)⟩
| .mul (e := a₂) va₁ va₂ va₃ => do
let ⟨_, vb₁, pb₁⟩ ← va₁.evalNatCast
let ⟨_, vb₃, pb₃⟩ ← va₃.evalNatCast
pure ⟨_, .mul vb₁ va₂ vb₃, q(natCast_mul $a₂ $pb₁ $pb₃)⟩
partial def ExSum.evalNatCast (va : ExSum sℕ a) : AtomM (Result (ExSum sα) q($a)) :=
match va with
| .zero => pure ⟨_, .zero, q(natCast_zero (R := $α))⟩
| .add va₁ va₂ => do
let ⟨_, vb₁, pb₁⟩ ← va₁.evalNatCast
let ⟨_, vb₂, pb₂⟩ ← va₂.evalNatCast
pure ⟨_, .add vb₁ vb₂, q(natCast_add $pb₁ $pb₂)⟩
end
theorem smul_nat (_ : (a * b : ℕ) = c) : a • b = c := by subst_vars; simp
theorem smul_eq_cast (_ : ((a : ℕ) : R) = a') (_ : a' * b = c) : a • b = c := by subst_vars; simp
def evalNSMul (va : ExSum sℕ a) (vb : ExSum sα b) : AtomM (Result (ExSum sα) q($a • $b)) := do
if ← isDefEq sα sℕ then
let ⟨_, va'⟩ := va.cast
have _b : Q(ℕ) := b
let ⟨(_c : Q(ℕ)), vc, (pc : Q($a * $_b = $_c))⟩ := evalMul sα va' vb
pure ⟨_, vc, (q(smul_nat $pc) : Expr)⟩
else
let ⟨_, va', pa'⟩ ← va.evalNatCast sα
let ⟨_, vc, pc⟩ := evalMul sα va' vb
pure ⟨_, vc, (q(smul_eq_cast $pa' $pc) : Expr)⟩
theorem neg_one_mul {R} [Ring R] {a b : R} (_ : (Int.negOfNat (nat_lit 1)).rawCast * a = b) :
-a = b := by subst_vars; simp [Int.negOfNat]
theorem neg_mul {R} [Ring R] (a₁ : R) (a₂) {a₃ b : R}
(_ : -a₃ = b) : -(a₁ ^ a₂ * a₃) = a₁ ^ a₂ * b := by subst_vars; simp
def evalNegProd (rα : Q(Ring $α)) (va : ExProd sα a) : Result (ExProd sα) q(-$a) :=
match va with
| .const za ha =>
let lit : Q(ℕ) := mkRawNatLit 1
let ⟨m1, _⟩ := ExProd.mkNegNat sα rα 1
let rm := Result.isNegNat rα lit (q(IsInt.of_raw $α (.negOfNat $lit)) : Expr)
let ra := Result.ofRawRat za a ha
let rb := (NormNum.evalMul.core q($m1 * $a) q(HMul.hMul) _ _
q(CommSemiring.toSemiring) rm ra).get!
let ⟨zb, hb⟩ := rb.toRatNZ.get!
let ⟨b, (pb : Q((Int.negOfNat (nat_lit 1)).rawCast * $a = $b))⟩ := rb.toRawEq
⟨b, .const zb hb, (q(neg_one_mul (R := $α) $pb) : Expr)⟩
| .mul (x := a₁) (e := a₂) va₁ va₂ va₃ =>
let ⟨_, vb, pb⟩ := evalNegProd rα va₃
⟨_, .mul va₁ va₂ vb, (q(neg_mul $a₁ $a₂ $pb) : Expr)⟩
theorem neg_zero {R} [Ring R] : -(0 : R) = 0 := by simp
theorem neg_add {R} [Ring R] {a₁ a₂ b₁ b₂ : R}
(_ : -a₁ = b₁) (_ : -a₂ = b₂) : -(a₁ + a₂) = b₁ + b₂ := by subst_vars; simp [add_comm]
def evalNeg (rα : Q(Ring $α)) (va : ExSum sα a) : Result (ExSum sα) q(-$a) :=
match va with
| .zero => ⟨_, .zero, (q(neg_zero (R := $α)) : Expr)⟩
| .add va₁ va₂ =>
let ⟨_, vb₁, pb₁⟩ := evalNegProd sα rα va₁
let ⟨_, vb₂, pb₂⟩ := evalNeg rα va₂
⟨_, .add vb₁ vb₂, (q(neg_add $pb₁ $pb₂) : Expr)⟩
theorem sub_pf {R} [Ring R] {a b c d : R}
(_ : -b = c) (_ : a + c = d) : a - b = d := by subst_vars; simp [sub_eq_add_neg]
def evalSub (rα : Q(Ring $α)) (va : ExSum sα a) (vb : ExSum sα b) : Result (ExSum sα) q($a - $b) :=
let ⟨_c, vc, pc⟩ := evalNeg sα rα vb
let ⟨d, vd, (pd : Q($a + $_c = $d))⟩ := evalAdd sα va vc
⟨d, vd, (q(sub_pf $pc $pd) : Expr)⟩
theorem pow_prod_atom (a : R) (b) : a ^ b = (a + 0) ^ b * (nat_lit 1).rawCast := by simp
def evalPowProdAtom (va : ExProd sα a) (vb : ExProd sℕ b) : Result (ExProd sα) q($a ^ $b) :=
⟨_, (ExBase.sum va.toSum).toProd vb, q(pow_prod_atom $a $b)⟩
theorem pow_atom (a : R) (b) : a ^ b = a ^ b * (nat_lit 1).rawCast + 0 := by simp
def evalPowAtom (va : ExBase sα a) (vb : ExProd sℕ b) : Result (ExSum sα) q($a ^ $b) :=
⟨_, (va.toProd vb).toSum, q(pow_atom $a $b)⟩
theorem const_pos (n : ℕ) (h : Nat.ble 1 n = true) : 0 < (n.rawCast : ℕ) := Nat.le_of_ble_eq_true h
theorem mul_exp_pos (n) (h₁ : 0 < a₁) (h₂ : 0 < a₂) : 0 < a₁ ^ n * a₂ :=
Nat.mul_pos (Nat.pos_pow_of_pos _ h₁) h₂
theorem add_pos_left (a₂) (h : 0 < a₁) : 0 < a₁ + a₂ := Nat.lt_of_lt_of_le h (Nat.le_add_right ..)
theorem add_pos_right (a₁) (h : 0 < a₂) : 0 < a₁ + a₂ := Nat.lt_of_lt_of_le h (Nat.le_add_left ..)
mutual
partial def ExBase.evalPos (va : ExBase sℕ a) : Option Q(0 < $a) :=
match va with
| .atom _ => none
| .sum va => va.evalPos
partial def ExProd.evalPos (va : ExProd sℕ a) : Option Q(0 < $a) :=
match va with
| .const _ _ =>
-- it must be positive because it is a nonzero nat literal
have lit : Q(ℕ) := a.appArg!
haveI : $a =Q Nat.rawCast $lit := ⟨⟩
haveI p : Nat.ble 1 $lit =Q true := ⟨⟩
some q(const_pos $lit $p)
| .mul (e := ea₁) vxa₁ _ va₂ => do
let pa₁ ← vxa₁.evalPos
let pa₂ ← va₂.evalPos
some q(mul_exp_pos $ea₁ $pa₁ $pa₂)
partial def ExSum.evalPos (va : ExSum sℕ a) : Option Q(0 < $a) :=
match va with
| .zero => none
| .add (a := a₁) (b := a₂) va₁ va₂ => do
match va₁.evalPos with
| some p => some q(add_pos_left $a₂ $p)
| none => let p ← va₂.evalPos; some q(add_pos_right $a₁ $p)
end
theorem pow_one (a : R) : a ^ nat_lit 1 = a := by simp
theorem pow_bit0 (_ : (a : R) ^ k = b) (_ : b * b = c) : a ^ (Nat.mul (nat_lit 2) k) = c := by
subst_vars; simp [Nat.succ_mul, pow_add]
theorem pow_bit1 (_ : (a : R) ^ k = b) (_ : b * b = c) (_ : c * a = d) :
a ^ (Nat.add (Nat.mul (nat_lit 2) k) (nat_lit 1)) = d := by
subst_vars; simp [Nat.succ_mul, pow_add]
partial def evalPowNat (va : ExSum sα a) (n : Q(ℕ)) : Result (ExSum sα) q($a ^ $n) :=
let nn := n.natLit!
if nn = 1 then
⟨_, va, (q(pow_one $a) : Expr)⟩
else
let nm := nn >>> 1
have m : Q(ℕ) := mkRawNatLit nm
if nn &&& 1 = 0 then
let ⟨_, vb, pb⟩ := evalPowNat va m
let ⟨_, vc, pc⟩ := evalMul sα vb vb
⟨_, vc, (q(pow_bit0 $pb $pc) : Expr)⟩
else
let ⟨_, vb, pb⟩ := evalPowNat va m
let ⟨_, vc, pc⟩ := evalMul sα vb vb
let ⟨_, vd, pd⟩ := evalMul sα vc va
⟨_, vd, (q(pow_bit1 $pb $pc $pd) : Expr)⟩
theorem one_pow (b : ℕ) : ((nat_lit 1).rawCast : R) ^ b = (nat_lit 1).rawCast := by simp
theorem mul_pow (_ : ea₁ * b = c₁) (_ : a₂ ^ b = c₂) :
(xa₁ ^ ea₁ * a₂ : R) ^ b = xa₁ ^ c₁ * c₂ := by subst_vars; simp [_root_.mul_pow, pow_mul]
def evalPowProd (va : ExProd sα a) (vb : ExProd sℕ b) : Result (ExProd sα) q($a ^ $b) :=
let res : Option (Result (ExProd sα) q($a ^ $b)) := do
match va, vb with
| .const 1, _ => some ⟨_, va, (q(one_pow (R := $α) $b) : Expr)⟩
| .const za ha, .const zb hb =>
assert! 0 ≤ zb
let ra := Result.ofRawRat za a ha
have lit : Q(ℕ) := b.appArg!
let rb := (q(IsNat.of_raw ℕ $lit) : Expr)
let rc ← NormNum.evalPow.core q($a ^ $b) q(HPow.hPow) q($a) q($b) lit rb
q(CommSemiring.toSemiring) ra
let ⟨zc, hc⟩ ← rc.toRatNZ
let ⟨c, pc⟩ := rc.toRawEq
some ⟨c, .const zc hc, pc⟩
| .mul vxa₁ vea₁ va₂, vb => do
let ⟨_, vc₁, pc₁⟩ := evalMulProd sℕ vea₁ vb
let ⟨_, vc₂, pc₂⟩ := evalPowProd va₂ vb
some ⟨_, .mul vxa₁ vc₁ vc₂, q(mul_pow $pc₁ $pc₂)⟩
| _, _ => none
res.getD (evalPowProdAtom sα va vb)
structure ExtractCoeff (e : Q(ℕ)) where
k : Q(ℕ)
e' : Q(ℕ)
ve' : ExProd sℕ e'
p : Q($e = $e' * $k)
theorem coeff_one (k : ℕ) : k.rawCast = (nat_lit 1).rawCast * k := by simp
theorem coeff_mul (a₁ a₂ : ℕ) (_ : a₃ = c₂ * k) : a₁ ^ a₂ * a₃ = (a₁ ^ a₂ * c₂) * k := by
subst_vars; rw [mul_assoc]
def extractCoeff (va : ExProd sℕ a) : ExtractCoeff a :=
match va with
| .const _ _ =>
have k : Q(ℕ) := a.appArg!
⟨k, q((nat_lit 1).rawCast), .const 1, (q(coeff_one $k) : Expr)⟩
| .mul (x := a₁) (e := a₂) va₁ va₂ va₃ =>
let ⟨k, _, vc, pc⟩ := extractCoeff va₃
⟨k, _, .mul va₁ va₂ vc, q(coeff_mul $a₁ $a₂ $pc)⟩
theorem pow_one_cast (a : R) : a ^ (nat_lit 1).rawCast = a := by simp
theorem zero_pow (_ : 0 < b) : (0 : R) ^ b = 0 := match b with | b+1 => by simp [pow_succ]
theorem single_pow (_ : (a : R) ^ b = c) : (a + 0) ^ b = c + 0 := by simp [*]
theorem pow_nat (_ : b = c * k) (_ : a ^ c = d) (_ : d ^ k = e) : (a : R) ^ b = e := by
subst_vars; simp [pow_mul]
partial def evalPow₁ (va : ExSum sα a) (vb : ExProd sℕ b) : Result (ExSum sα) q($a ^ $b) :=
match va, vb with
| va, .const 1 =>
haveI : $b =Q Nat.rawCast (nat_lit 1) := ⟨⟩
⟨_, va, q(pow_one_cast $a)⟩
| .zero, vb => match vb.evalPos with
| some p => ⟨_, .zero, q(zero_pow (R := $α) $p)⟩
| none => evalPowAtom sα (.sum .zero) vb
| ExSum.add va .zero, vb => -- TODO: using `.add` here takes a while to compile?
let ⟨_, vc, pc⟩ := evalPowProd sα va vb
⟨_, vc.toSum, q(single_pow $pc)⟩
| va, vb =>
if vb.coeff > 1 then
let ⟨k, _, vc, pc⟩ := extractCoeff vb
let ⟨_, vd, pd⟩ := evalPow₁ va vc
let ⟨_, ve, pe⟩ := evalPowNat sα vd k
⟨_, ve, q(pow_nat $pc $pd $pe)⟩
else evalPowAtom sα (.sum va) vb
theorem pow_zero (a : R) : a ^ 0 = (nat_lit 1).rawCast + 0 := by simp
theorem pow_add (_ : a ^ b₁ = c₁) (_ : a ^ b₂ = c₂) (_ : c₁ * c₂ = d) :
(a : R) ^ (b₁ + b₂) = d := by subst_vars; simp [_root_.pow_add]
def evalPow (va : ExSum sα a) (vb : ExSum sℕ b) : Result (ExSum sα) q($a ^ $b) :=
match vb with
| .zero => ⟨_, (ExProd.mkNat sα 1).2.toSum, q(pow_zero $a)⟩
| .add vb₁ vb₂ =>
let ⟨_, vc₁, pc₁⟩ := evalPow₁ sα va vb₁
let ⟨_, vc₂, pc₂⟩ := evalPow va vb₂
let ⟨_, vd, pd⟩ := evalMul sα vc₁ vc₂
⟨_, vd, q(pow_add $pc₁ $pc₂ $pd)⟩
structure Cache {α : Q(Type u)} (sα : Q(CommSemiring $α)) :=
rα : Option Q(Ring $α)
dα : Option Q(DivisionRing $α)
czα : Option Q(CharZero $α)
def mkCache {α : Q(Type u)} (sα : Q(CommSemiring $α)) : MetaM (Cache sα) :=
return {
rα := (← trySynthInstanceQ q(Ring $α)).toOption
dα := (← trySynthInstanceQ q(DivisionRing $α)).toOption
czα := (← trySynthInstanceQ q(CharZero $α)).toOption }
theorem cast_pos : IsNat (a : R) n → a = n.rawCast + 0
| ⟨e⟩ => by simp [e]
theorem cast_zero : IsNat (a : R) (nat_lit 0) → a = 0
| ⟨e⟩ => by simp [e]
theorem cast_neg {R} [Ring R] {a : R} : IsInt a (.negOfNat n) → a = (Int.negOfNat n).rawCast + 0
| ⟨e⟩ => by simp [e]
theorem cast_rat {R} [DivisionRing R] {a : R} : IsRat a n d → a = Rat.rawCast n d + 0
| ⟨_, e⟩ => by simp [e, div_eq_mul_inv]
def evalCast : NormNum.Result e → Option (Result (ExSum sα) e)
| .isNat _ (.lit (.natVal 0)) p => do
assumeInstancesCommute
pure ⟨_, .zero, q(cast_zero $p)⟩
| .isNat _ lit p => do
assumeInstancesCommute
pure ⟨_, (ExProd.mkNat sα lit.natLit!).2.toSum, (q(cast_pos $p) :)⟩
| .isNegNat rα lit p =>
pure ⟨_, (ExProd.mkNegNat _ rα lit.natLit!).2.toSum, (q(cast_neg $p) : Expr)⟩
| .isRat dα q n d p =>
pure ⟨_, (ExProd.mkRat sα dα q n d q(IsRat.den_nz $p)).2.toSum, (q(cast_rat $p) : Expr)⟩
| _ => none
theorem toProd_pf (p : (a : R) = a') :
a = a' ^ (nat_lit 1).rawCast * (nat_lit 1).rawCast := by simp [*]
theorem atom_pf (a : R) : a = a ^ (nat_lit 1).rawCast * (nat_lit 1).rawCast + 0 := by simp
theorem atom_pf' (p : (a : R) = a') :
a = a' ^ (nat_lit 1).rawCast * (nat_lit 1).rawCast + 0 := by simp [*]
def evalAtom (e : Q($α)) : AtomM (Result (ExSum sα) e) := do
let r ← (← read).evalAtom e
have e' : Q($α) := r.expr
let i ← addAtom e'
let ve' := (ExBase.atom i (e := e')).toProd (ExProd.mkNat sℕ 1).2 |>.toSum
pure ⟨_, ve', match r.proof? with
| none => (q(atom_pf $e) : Expr)
| some (p : Q($e = $e')) => (q(atom_pf' $p) : Expr)⟩
theorem inv_mul {R} [DivisionRing R] {a₁ a₂ a₃ b₁ b₃ c}
(_ : (a₁⁻¹ : R) = b₁) (_ : (a₃⁻¹ : R) = b₃)
(_ : b₃ * (b₁ ^ a₂ * (nat_lit 1).rawCast) = c) :
(a₁ ^ a₂ * a₃ : R)⁻¹ = c := by subst_vars; simp
nonrec theorem inv_zero {R} [DivisionRing R] : (0 : R)⁻¹ = 0 := inv_zero
theorem inv_single {R} [DivisionRing R] {a b : R}
(_ : (a : R)⁻¹ = b) : (a + 0)⁻¹ = b + 0 := by simp [*]
theorem inv_add (_ : ((a₁ : ℕ) : R) = b₁) (_ : ((a₂ : ℕ) : R) = b₂) :
((a₁ + a₂ : ℕ) : R) = b₁ + b₂ := by subst_vars; simp
section
variable (dα : Q(DivisionRing $α))
def evalInvAtom (a : Q($α)) : AtomM (Result (ExBase sα) q($a⁻¹)) := do
let a' : Q($α) := q($a⁻¹)
let i ← addAtom a'
pure ⟨a', ExBase.atom i, (q(Eq.refl $a') : Expr)⟩
def ExProd.evalInv (czα : Option Q(CharZero $α)) (va : ExProd sα a) :
AtomM (Result (ExProd sα) q($a⁻¹)) := do
match va with
| .const c hc =>
let ra := Result.ofRawRat c a hc
match NormNum.evalInv.core q($a⁻¹) a ra dα czα with
| some rc =>
let ⟨zc, hc⟩ := rc.toRatNZ.get!
let ⟨c, pc⟩ := rc.toRawEq
pure ⟨c, .const zc hc, pc⟩
| none =>
let ⟨_, vc, pc⟩ ← evalInvAtom sα dα a
pure ⟨_, vc.toProd (ExProd.mkNat sℕ 1).2, q(toProd_pf $pc)⟩
| .mul (x := a₁) (e := _a₂) _va₁ va₂ va₃ => do
let ⟨_b₁, vb₁, pb₁⟩ ← evalInvAtom sα dα a₁
let ⟨_b₃, vb₃, pb₃⟩ ← va₃.evalInv czα
let ⟨c, vc, (pc : Q($_b₃ * ($_b₁ ^ $_a₂ * Nat.rawCast 1) = $c))⟩ :=
evalMulProd sα vb₃ (vb₁.toProd va₂)
pure ⟨c, vc, (q(inv_mul $pb₁ $pb₃ $pc) : Expr)⟩
def ExSum.evalInv (czα : Option Q(CharZero $α)) (va : ExSum sα a) :
AtomM (Result (ExSum sα) q($a⁻¹)) :=
match va with
| ExSum.zero => pure ⟨_, .zero, (q(inv_zero (R := $α)) : Expr)⟩
| ExSum.add va ExSum.zero => do
let ⟨_, vb, pb⟩ ← va.evalInv dα czα
pure ⟨_, vb.toSum, (q(inv_single $pb) : Expr)⟩
| va => do
let ⟨_, vb, pb⟩ ← evalInvAtom sα dα a
pure ⟨_, vb.toProd (ExProd.mkNat sℕ 1).2 |>.toSum, q(atom_pf' $pb)⟩
end
theorem div_pf {R} [DivisionRing R] {a b c d : R}
(_ : b⁻¹ = c) (_ : a * c = d) : a / b = d := by subst_vars; simp [div_eq_mul_inv]
def evalDiv (rα : Q(DivisionRing $α)) (czα : Option Q(CharZero $α)) (va : ExSum sα a)
(vb : ExSum sα b) : AtomM (Result (ExSum sα) q($a / $b)) := do
let ⟨_c, vc, pc⟩ ← vb.evalInv sα rα czα
let ⟨d, vd, (pd : Q($a * $_c = $d))⟩ := evalMul sα va vc
pure ⟨d, vd, (q(div_pf $pc $pd) : Expr)⟩
| Mathlib/Tactic/Ring/Basic.lean | 968 | 969 | theorem add_congr (_ : a = a') (_ : b = b')
(_ : a' + b' = c) : (a + b : R) = c := by | subst_vars; rfl
|
import Mathlib.Algebra.Polynomial.Degree.Definitions
import Mathlib.Algebra.Polynomial.Eval
import Mathlib.Algebra.Polynomial.Monic
import Mathlib.Algebra.Polynomial.RingDivision
import Mathlib.Tactic.Abel
#align_import ring_theory.polynomial.pochhammer from "leanprover-community/mathlib"@"53b216bcc1146df1c4a0a86877890ea9f1f01589"
universe u v
open Polynomial
open Polynomial
section Ring
variable (R : Type u) [Ring R]
noncomputable def descPochhammer : ℕ → R[X]
| 0 => 1
| n + 1 => X * (descPochhammer n).comp (X - 1)
@[simp]
theorem descPochhammer_zero : descPochhammer R 0 = 1 :=
rfl
@[simp]
theorem descPochhammer_one : descPochhammer R 1 = X := by simp [descPochhammer]
theorem descPochhammer_succ_left (n : ℕ) :
descPochhammer R (n + 1) = X * (descPochhammer R n).comp (X - 1) := by
rw [descPochhammer]
theorem monic_descPochhammer (n : ℕ) [Nontrivial R] [NoZeroDivisors R] :
Monic <| descPochhammer R n := by
induction' n with n hn
· simp
· have h : leadingCoeff (X - 1 : R[X]) = 1 := leadingCoeff_X_sub_C 1
have : natDegree (X - (1 : R[X])) ≠ 0 := ne_zero_of_eq_one <| natDegree_X_sub_C (1 : R)
rw [descPochhammer_succ_left, Monic.def, leadingCoeff_mul, leadingCoeff_comp this, hn, monic_X,
one_mul, one_mul, h, one_pow]
section
variable {R} {T : Type v} [Ring T]
@[simp]
theorem descPochhammer_map (f : R →+* T) (n : ℕ) :
(descPochhammer R n).map f = descPochhammer T n := by
induction' n with n ih
· simp
· simp [ih, descPochhammer_succ_left, map_comp]
end
@[simp, norm_cast]
theorem descPochhammer_eval_cast (n : ℕ) (k : ℤ) :
(((descPochhammer ℤ n).eval k : ℤ) : R) = ((descPochhammer R n).eval k : R) := by
rw [← descPochhammer_map (algebraMap ℤ R), eval_map, ← eq_intCast (algebraMap ℤ R)]
simp only [algebraMap_int_eq, eq_intCast, eval₂_at_intCast, Nat.cast_id, eq_natCast, Int.cast_id]
theorem descPochhammer_eval_zero {n : ℕ} :
(descPochhammer R n).eval 0 = if n = 0 then 1 else 0 := by
cases n
· simp
· simp [X_mul, Nat.succ_ne_zero, descPochhammer_succ_left]
| Mathlib/RingTheory/Polynomial/Pochhammer.lean | 295 | 295 | theorem descPochhammer_zero_eval_zero : (descPochhammer R 0).eval 0 = 1 := by | simp
|
import Mathlib.CategoryTheory.Functor.FullyFaithful
import Mathlib.CategoryTheory.FullSubcategory
import Mathlib.CategoryTheory.Whiskering
import Mathlib.CategoryTheory.EssentialImage
import Mathlib.Tactic.CategoryTheory.Slice
#align_import category_theory.equivalence from "leanprover-community/mathlib"@"9aba7801eeecebb61f58a5763c2b6dd1b47dc6ef"
namespace CategoryTheory
open CategoryTheory.Functor NatIso Category
-- declare the `v`'s first; see `CategoryTheory.Category` for an explanation
universe v₁ v₂ v₃ u₁ u₂ u₃
@[ext]
structure Equivalence (C : Type u₁) (D : Type u₂) [Category.{v₁} C] [Category.{v₂} D] where mk' ::
functor : C ⥤ D
inverse : D ⥤ C
unitIso : 𝟭 C ≅ functor ⋙ inverse
counitIso : inverse ⋙ functor ≅ 𝟭 D
functor_unitIso_comp :
∀ X : C, functor.map (unitIso.hom.app X) ≫ counitIso.hom.app (functor.obj X) =
𝟙 (functor.obj X) := by aesop_cat
#align category_theory.equivalence CategoryTheory.Equivalence
#align category_theory.equivalence.unit_iso CategoryTheory.Equivalence.unitIso
#align category_theory.equivalence.counit_iso CategoryTheory.Equivalence.counitIso
#align category_theory.equivalence.functor_unit_iso_comp CategoryTheory.Equivalence.functor_unitIso_comp
infixr:10 " ≌ " => Equivalence
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
namespace Equivalence
abbrev unit (e : C ≌ D) : 𝟭 C ⟶ e.functor ⋙ e.inverse :=
e.unitIso.hom
#align category_theory.equivalence.unit CategoryTheory.Equivalence.unit
abbrev counit (e : C ≌ D) : e.inverse ⋙ e.functor ⟶ 𝟭 D :=
e.counitIso.hom
#align category_theory.equivalence.counit CategoryTheory.Equivalence.counit
abbrev unitInv (e : C ≌ D) : e.functor ⋙ e.inverse ⟶ 𝟭 C :=
e.unitIso.inv
#align category_theory.equivalence.unit_inv CategoryTheory.Equivalence.unitInv
abbrev counitInv (e : C ≌ D) : 𝟭 D ⟶ e.inverse ⋙ e.functor :=
e.counitIso.inv
#align category_theory.equivalence.counit_inv CategoryTheory.Equivalence.counitInv
@[simp]
theorem Equivalence_mk'_unit (functor inverse unit_iso counit_iso f) :
(⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).unit = unit_iso.hom :=
rfl
#align category_theory.equivalence.equivalence_mk'_unit CategoryTheory.Equivalence.Equivalence_mk'_unit
@[simp]
theorem Equivalence_mk'_counit (functor inverse unit_iso counit_iso f) :
(⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).counit = counit_iso.hom :=
rfl
#align category_theory.equivalence.equivalence_mk'_counit CategoryTheory.Equivalence.Equivalence_mk'_counit
@[simp]
theorem Equivalence_mk'_unitInv (functor inverse unit_iso counit_iso f) :
(⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).unitInv = unit_iso.inv :=
rfl
#align category_theory.equivalence.equivalence_mk'_unit_inv CategoryTheory.Equivalence.Equivalence_mk'_unitInv
@[simp]
theorem Equivalence_mk'_counitInv (functor inverse unit_iso counit_iso f) :
(⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).counitInv = counit_iso.inv :=
rfl
#align category_theory.equivalence.equivalence_mk'_counit_inv CategoryTheory.Equivalence.Equivalence_mk'_counitInv
@[reassoc (attr := simp)]
theorem functor_unit_comp (e : C ≌ D) (X : C) :
e.functor.map (e.unit.app X) ≫ e.counit.app (e.functor.obj X) = 𝟙 (e.functor.obj X) :=
e.functor_unitIso_comp X
#align category_theory.equivalence.functor_unit_comp CategoryTheory.Equivalence.functor_unit_comp
@[reassoc (attr := simp)]
theorem counitInv_functor_comp (e : C ≌ D) (X : C) :
e.counitInv.app (e.functor.obj X) ≫ e.functor.map (e.unitInv.app X) = 𝟙 (e.functor.obj X) := by
erw [Iso.inv_eq_inv (e.functor.mapIso (e.unitIso.app X) ≪≫ e.counitIso.app (e.functor.obj X))
(Iso.refl _)]
exact e.functor_unit_comp X
#align category_theory.equivalence.counit_inv_functor_comp CategoryTheory.Equivalence.counitInv_functor_comp
theorem counitInv_app_functor (e : C ≌ D) (X : C) :
e.counitInv.app (e.functor.obj X) = e.functor.map (e.unit.app X) := by
symm
erw [← Iso.comp_hom_eq_id (e.counitIso.app _), functor_unit_comp]
rfl
#align category_theory.equivalence.counit_inv_app_functor CategoryTheory.Equivalence.counitInv_app_functor
theorem counit_app_functor (e : C ≌ D) (X : C) :
e.counit.app (e.functor.obj X) = e.functor.map (e.unitInv.app X) := by
erw [← Iso.hom_comp_eq_id (e.functor.mapIso (e.unitIso.app X)), functor_unit_comp]
rfl
#align category_theory.equivalence.counit_app_functor CategoryTheory.Equivalence.counit_app_functor
@[reassoc (attr := simp)]
theorem unit_inverse_comp (e : C ≌ D) (Y : D) :
e.unit.app (e.inverse.obj Y) ≫ e.inverse.map (e.counit.app Y) = 𝟙 (e.inverse.obj Y) := by
rw [← id_comp (e.inverse.map _), ← map_id e.inverse, ← counitInv_functor_comp, map_comp]
dsimp
rw [← Iso.hom_inv_id_assoc (e.unitIso.app _) (e.inverse.map (e.functor.map _)), app_hom, app_inv]
slice_lhs 2 3 => erw [e.unit.naturality]
slice_lhs 1 2 => erw [e.unit.naturality]
slice_lhs 4 4 =>
rw [← Iso.hom_inv_id_assoc (e.inverse.mapIso (e.counitIso.app _)) (e.unitInv.app _)]
slice_lhs 3 4 =>
erw [← map_comp e.inverse, e.counit.naturality]
erw [(e.counitIso.app _).hom_inv_id, map_id]
erw [id_comp]
slice_lhs 2 3 => erw [← map_comp e.inverse, e.counitIso.inv.naturality, map_comp]
slice_lhs 3 4 => erw [e.unitInv.naturality]
slice_lhs 4 5 => erw [← map_comp (e.functor ⋙ e.inverse), (e.unitIso.app _).hom_inv_id, map_id]
erw [id_comp]
slice_lhs 3 4 => erw [← e.unitInv.naturality]
slice_lhs 2 3 =>
erw [← map_comp e.inverse, ← e.counitIso.inv.naturality, (e.counitIso.app _).hom_inv_id,
map_id]
erw [id_comp, (e.unitIso.app _).hom_inv_id]; rfl
#align category_theory.equivalence.unit_inverse_comp CategoryTheory.Equivalence.unit_inverse_comp
@[reassoc (attr := simp)]
theorem inverse_counitInv_comp (e : C ≌ D) (Y : D) :
e.inverse.map (e.counitInv.app Y) ≫ e.unitInv.app (e.inverse.obj Y) = 𝟙 (e.inverse.obj Y) := by
erw [Iso.inv_eq_inv (e.unitIso.app (e.inverse.obj Y) ≪≫ e.inverse.mapIso (e.counitIso.app Y))
(Iso.refl _)]
exact e.unit_inverse_comp Y
#align category_theory.equivalence.inverse_counit_inv_comp CategoryTheory.Equivalence.inverse_counitInv_comp
| Mathlib/CategoryTheory/Equivalence.lean | 214 | 217 | theorem unit_app_inverse (e : C ≌ D) (Y : D) :
e.unit.app (e.inverse.obj Y) = e.inverse.map (e.counitInv.app Y) := by |
erw [← Iso.comp_hom_eq_id (e.inverse.mapIso (e.counitIso.app Y)), unit_inverse_comp]
dsimp
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.