Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 7726a92

Browse files
committed
feat(data/ordinal): sup, cofinality, subtraction
1 parent f6bbca7 commit 7726a92

File tree

9 files changed

+425
-106
lines changed

9 files changed

+425
-106
lines changed

algebra/order.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ lemma eq_of_forall_le_iff [partial_order α] {a b : α}
4848
(H : ∀ c, c ≤ a ↔ c ≤ b) : a = b :=
4949
le_antisymm ((H _).1 (le_refl _)) ((H _).2 (le_refl _))
5050

51+
lemma le_of_forall_le [preorder α] {a b : α}
52+
(H : ∀ c, c ≤ a → c ≤ b) : a ≤ b :=
53+
H _ (le_refl _)
54+
55+
lemma le_of_forall_lt [linear_order α] {a b : α}
56+
(H : ∀ c, c < a → c < b) : a ≤ b :=
57+
le_of_not_lt $ λ h, lt_irrefl _ (H _ h)
58+
5159
lemma eq_of_forall_ge_iff [partial_order α] {a b : α}
5260
(H : ∀ c, a ≤ c ↔ b ≤ c) : a = b :=
5361
le_antisymm ((H _).2 (le_refl _)) ((H _).1 (le_refl _))

algebra/ordered_ring.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import order algebra.order algebra.ordered_group algebra.ring
88
universe u
99
variable {α : Type u}
1010

11+
-- TODO: this is necessary additionally to mul_nonneg otherwise the simplifier can not match
12+
lemma zero_le_mul [ordered_semiring α] {a b : α} : 0 ≤ a → 0 ≤ b → 0 ≤ a * b :=
13+
mul_nonneg
14+
1115
section linear_ordered_semiring
1216
variable [linear_ordered_semiring α]
1317

analysis/ennreal.lean

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ open classical set lattice filter
1111
local attribute [instance] prop_decidable
1212

1313
universes u v w
14-
-- TODO: this is necessary additionally to mul_nonneg otherwise the simplifier can not match
15-
lemma zero_le_mul {α : Type u} [ordered_semiring α] {a b : α} : 0 ≤ a → 0 ≤ b → 0 ≤ a * b :=
16-
mul_nonneg
1714

1815
inductive ennreal : Type
1916
| of_nonneg_real : Πr:real, 0 ≤ r → ennreal
@@ -377,7 +374,7 @@ forall_ennreal.mpr ⟨assume r hr, forall_ennreal.mpr ⟨assume p hp,
377374

378375
lemma le_of_forall_epsilon_le (h : ∀ε>0, b < ∞ → a ≤ b + of_real ε) : a ≤ b :=
379376
suffices ∀r, 0 ≤ r → of_real r > b → a ≤ of_real r,
380-
from le_of_forall_le $ forall_ennreal.mpr $ by simp; assumption,
377+
from le_of_forall_le_of_dense $ forall_ennreal.mpr $ by simp; assumption,
381378
assume r hr hrb,
382379
let ⟨p, hp, b_eq, hpr⟩ := lt_iff_exists_of_real.mp hrb in
383380
have p < r, by simp [hp, hr] at hpr; assumption,
@@ -871,7 +868,7 @@ instance : has_div ennreal := ⟨λa b, a * b⁻¹⟩
871868
show Inf {b : ennreal | 10 * b} = ∞, by simp; refl
872869

873870
@[simp] lemma inv_infty : (∞ : ennreal)⁻¹ = 0 :=
874-
bot_unique $ le_of_forall_le $ λ a (h : a > 0), Inf_le $ by simp [*, ne_of_gt h]
871+
bot_unique $ le_of_forall_le_of_dense $ λ a (h : a > 0), Inf_le $ by simp [*, ne_of_gt h]
875872

876873
@[simp] lemma inv_of_real (hr : 0 < r) : (of_real r)⁻¹ = of_real (r⁻¹) :=
877874
have 0 ≤ r⁻¹, from le_of_lt (inv_pos hr),

analysis/metric_space.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ have 0 < (0:real), by simp [this] at h; exact h,
7575
lt_irrefl _ this
7676

7777
theorem eq_of_forall_dist_le {x y : α} (h : ∀ε, ε > 0 → dist x y ≤ ε) : x = y :=
78-
eq_of_dist_eq_zero (eq_of_le_of_forall_le dist_nonneg h)
78+
eq_of_dist_eq_zero (eq_of_le_of_forall_le_of_dense dist_nonneg h)
7979

8080
instance metric_space.to_separated [metric_space α] : separated α :=
8181
set.ext $ assume ⟨x, y⟩,

data/cardinal.lean

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -286,19 +286,27 @@ instance : has_zero cardinal.{u} := ⟨⟦ulift empty⟧⟩
286286

287287
instance : inhabited cardinal.{u} := ⟨0
288288

289-
theorem ne_zero_iff_nonempty {α : Type u} : @ne cardinal ⟦α⟧ 0 ↔ nonempty α :=
289+
theorem ne_zero_iff_nonempty {α : Type u} : mk α ≠ 0 ↔ nonempty α :=
290290
not_iff_comm.1
291291
⟨λ h, quotient.sound ⟨(equiv.empty_of_not_nonempty h).trans equiv.ulift.symm⟩,
292292
λ e, let ⟨h⟩ := quotient.exact e in λ ⟨a⟩, (h a).down.elim⟩
293293

294294
instance : has_one cardinal.{u} := ⟨⟦ulift unit⟧⟩
295295

296+
instance : zero_ne_one_class cardinal.{u} :=
297+
{ zero := 0, one := 1, zero_ne_one :=
298+
ne.symm $ ne_zero_iff_nonempty.2 ⟨⟨()⟩⟩ }
299+
300+
theorem le_one_iff_subsingleton {α : Type u} : mk α ≤ 1 ↔ subsingleton α :=
301+
⟨λ ⟨f⟩, ⟨λ a b, f.inj (subsingleton.elim _ _)⟩,
302+
λ ⟨h⟩, ⟨⟨λ a, ⟨()⟩, λ a b _, h _ _⟩⟩⟩
303+
296304
instance : has_add cardinal.{u} :=
297-
⟨λq₁ q₂, quotient.lift_on₂ q₁ q₂ (λα β, α ⊕ β) $ assume α β γ δ ⟨e₁⟩ ⟨e₂⟩,
305+
⟨λq₁ q₂, quotient.lift_on₂ q₁ q₂ (λα β, mk (α ⊕ β)) $ assume α β γ δ ⟨e₁⟩ ⟨e₂⟩,
298306
quotient.sound ⟨equiv.sum_congr e₁ e₂⟩⟩
299307

300308
instance : has_mul cardinal.{u} :=
301-
⟨λq₁ q₂, quotient.lift_on₂ q₁ q₂ (λα β, α × β) $ assume α β γ δ ⟨e₁⟩ ⟨e₂⟩,
309+
⟨λq₁ q₂, quotient.lift_on₂ q₁ q₂ (λα β, mk (α × β)) $ assume α β γ δ ⟨e₁⟩ ⟨e₂⟩,
302310
quotient.sound ⟨equiv.prod_congr e₁ e₂⟩⟩
303311

304312
private theorem add_comm (a b : cardinal.{u}) : a + b = b + a :=
@@ -345,7 +353,7 @@ instance : comm_semiring cardinal.{u} :=
345353
by rw [mul_comm (a + b) c, left_distrib c a b, mul_comm c a, mul_comm c b] }
346354

347355
protected def power (a b : cardinal.{u}) : cardinal.{u} :=
348-
quotient.lift_on₂ a b (λα β, β → α) $ assume α₁ α₂ β₁ β₂ ⟨e₁⟩ ⟨e₂⟩,
356+
quotient.lift_on₂ a b (λα β, mk (β → α)) $ assume α₁ α₂ β₁ β₂ ⟨e₁⟩ ⟨e₂⟩,
349357
quotient.sound ⟨equiv.arrow_congr e₂ e₁⟩
350358

351359
local notation a ^ b := cardinal.power a b
@@ -362,7 +370,7 @@ quotient.induction_on a $ assume α, quotient.sound ⟨
362370
equiv.trans (equiv.arrow_unit_equiv_unit α) $
363371
equiv.ulift.symm⟩
364372

365-
@[simp] theorem prop_eq_two : @eq cardinal.{u} ⟦ulift Prop 2 :=
373+
@[simp] theorem prop_eq_two : mk (ulift Prop) = 2 :=
366374
quot.sound ⟨equiv.ulift.trans $ equiv.Prop_equiv_bool.trans $
367375
equiv.bool_equiv_unit_sum_unit.trans
368376
(equiv.sum_congr equiv.ulift equiv.ulift).symm⟩
@@ -395,6 +403,9 @@ open sum
395403
theorem zero_le (a : cardinal.{u}) : 0 ≤ a :=
396404
quot.induction_on a $ λ α, ⟨embedding.of_not_nonempty $ λ ⟨⟨a⟩⟩, a.elim⟩
397405

406+
theorem zero_lt_one : (0 : cardinal) < 1 :=
407+
lt_of_le_of_ne (zero_le _) zero_ne_one
408+
398409
theorem add_mono {a b c d : cardinal.{u}} : a ≤ b → c ≤ d → a + c ≤ b + d :=
399410
quotient.induction_on₂ a b $ assume α β, quotient.induction_on₂ c d $ assume γ δ ⟨e₁⟩ ⟨e₂⟩,
400411
⟨embedding.sum_congr e₁ e₂⟩
@@ -442,29 +453,28 @@ quot.induction_on a (λ α, ⟨⟨⟨λ a b, ⟨a = b⟩,
442453
instance : no_top_order cardinal.{u} :=
443454
{ no_top := λ a, ⟨_, cantor a⟩, ..cardinal.linear_order }
444455

445-
def min {ι} [inhabited ι] (f : ι → cardinal) : cardinal :=
456+
def min {ι} (I : nonempty ι) (f : ι → cardinal) : cardinal :=
446457
f $ classical.some $
447-
@embedding.injective_min _ (λ i, (f i).out) nonempty_of_inhabited
458+
@embedding.injective_min _ (λ i, (f i).out) I
448459

449-
theorem min_eq {ι} [inhabited ι] (f : ι → cardinal) : ∃ i, min f = f i :=
460+
theorem min_eq {ι} (I) (f : ι → cardinal) : ∃ i, min I f = f i :=
450461
⟨_, rfl⟩
451462

452-
theorem min_le} [inhabited ι] (f : ι → cardinal) (i) : min f ≤ f i :=
453-
by rw [← quotient.out_eq (min f), ← quotient.out_eq (f i)]; exact
463+
theorem min_le I} (f : ι → cardinal) (i) : min I f ≤ f i :=
464+
by rw [← quotient.out_eq (min I f), ← quotient.out_eq (f i)]; exact
454465
let ⟨g, hg⟩ := classical.some_spec
455-
(@embedding.injective_min _ (λ i, (f i).out) nonempty_of_inhabited) i in
466+
(@embedding.injective_min _ (λ i, (f i).out) I) i in
456467
⟨⟨g, hg⟩⟩
457468

458-
theorem le_min} [inhabited ι] {f : ι → cardinal} {a} : a ≤ min f ↔ ∀ i, a ≤ f i :=
469+
theorem le_min I} {f : ι → cardinal} {a} : a ≤ min I f ↔ ∀ i, a ≤ f i :=
459470
⟨λ h i, le_trans h (min_le _ _),
460-
λ h, let ⟨i, e⟩ := min_eq f in e.symm ▸ h i⟩
471+
λ h, let ⟨i, e⟩ := min_eq I f in e.symm ▸ h i⟩
461472

462473
protected theorem wf : @well_founded cardinal.{u} (<) :=
463474
⟨λ a, classical.by_contradiction $ λ h,
464475
let ι := {c :cardinal // ¬ acc (<) c},
465-
f : ι → cardinal := subtype.val in
466-
by have : inhabited ι := ⟨⟨_, h⟩⟩; exact
467-
let ⟨⟨c, hc⟩, hi⟩ := min_eq f in
476+
f : ι → cardinal := subtype.val,
477+
⟨⟨c, hc⟩, hi⟩ := @min_eq ι ⟨⟨_, h⟩⟩ f in
468478
hc (acc.intro _ (λ j ⟨_, h'⟩,
469479
classical.by_contradiction $ λ hj, h' $
470480
by have := min_le f ⟨j, hj⟩; rwa hi at this))⟩
@@ -475,11 +485,11 @@ def succ (c : cardinal) : cardinal :=
475485
@min {c' // c < c'} ⟨⟨_, cantor _⟩⟩ subtype.val
476486

477487
theorem lt_succ_self (c : cardinal) : c < succ c :=
478-
by cases min_eq _ with s e; rw [succ, e]; exact s.2
488+
by cases min_eq _ _ with s e; rw [succ, e]; exact s.2
479489

480490
theorem succ_le {a b : cardinal} : succ a ≤ b ↔ a < b :=
481491
⟨lt_of_lt_of_le (lt_succ_self _), λ h,
482-
by exact @min_le _ ⟨_⟩ _ (subtype.mk b h)⟩
492+
by exact min_le _ (subtype.mk b h)⟩
483493

484494
theorem add_one_le_succ (c : cardinal) : c + 1 ≤ succ c :=
485495
begin
@@ -508,7 +518,7 @@ def sup {ι} (f : ι → cardinal) : cardinal :=
508518
@min {c // ∀ i, f i ≤ c} ⟨⟨sum f, le_sum f⟩⟩ (λ a, a.1)
509519

510520
theorem le_sup {ι} (f : ι → cardinal) (i) : f i ≤ sup f :=
511-
by dsimp [sup]; cases min_eq _ with c hc; rw hc; exact c.2 i
521+
by dsimp [sup]; cases min_eq _ _ with c hc; rw hc; exact c.2 i
512522

513523
theorem sup_le {ι} (f : ι → cardinal) (a) : sup f ≤ a ↔ ∀ i, f i ≤ a :=
514524
⟨λ h i, le_trans (le_sup _ _) h,
@@ -570,13 +580,13 @@ quotient.sound ⟨equiv.ulift.trans (equiv.prod_congr equiv.ulift equiv.ulift).s
570580
quotient.induction_on₂ a b $ λ α β,
571581
quotient.sound ⟨equiv.ulift.trans (equiv.arrow_congr equiv.ulift equiv.ulift).symm⟩
572582

573-
@[simp] theorem lift_min} [inhabited ι] (f : ι → cardinal) : lift (min f) = min (lift ∘ f) :=
583+
@[simp] theorem lift_min I} (f : ι → cardinal) : lift (min I f) = min I (lift ∘ f) :=
574584
le_antisymm (le_min.2 $ λ a, lift_le.2 $ min_le _ a) $
575-
let ⟨i, e⟩ := min_eq (lift ∘ f) in
585+
let ⟨i, e⟩ := min_eq I (lift ∘ f) in
576586
by rw e; exact lift_le.2 (le_min.2 $ λ j, lift_le.1 $
577587
by have := min_le (lift ∘ f) j; rwa e at this)
578588

579-
def ω : cardinal.{u} := lift (mk ℕ)
589+
def omega : cardinal.{u} := lift (mk ℕ)
580590

581591
@[simp] theorem mk_fin : ∀ (n : ℕ), mk (fin n) = n
582592
| 0 := quotient.sound ⟨(equiv.empty_of_not_nonempty $
@@ -613,15 +623,19 @@ by simp [le_antisymm_iff]
613623
@[simp] theorem nat_succ (n : ℕ) : succ n = n.succ :=
614624
le_antisymm (succ_le.2 $ nat_cast_lt.2 $ nat.lt_succ_self _) (add_one_le_succ _)
615625

616-
theorem nat_lt_ω (n : ℕ) : (n : cardinal.{u}) < ω :=
617-
succ_le.1 $ by rw [nat_succ, ← lift_mk_fin, ω, lift_mk_le.{0 0 u}]; exact
626+
@[simp] theorem succ_zero : succ 0 = 1 :=
627+
by simpa using nat_succ 0
628+
629+
theorem nat_lt_omega (n : ℕ) : (n : cardinal.{u}) < omega :=
630+
succ_le.1 $ by rw [nat_succ, ← lift_mk_fin, omega, lift_mk_le.{0 0 u}]; exact
618631
⟨⟨fin.val, λ a b, fin.eq_of_veq⟩⟩
619632

620633
/-
621-
theorem lt_ω {c : cardinal} : c < ω ↔ ∃ n : ℕ, c = n :=
634+
theorem lt_omega {c : cardinal} : c < omega ↔ ∃ n : ℕ, c = n :=
622635
⟨λ h, begin
623636
cases le_mk_iff_exists_set.1 h.1 with S e, rw ← e,
624-
end, λ ⟨n, e⟩, e.symm ▸ nat_lt_ω _⟩
637+
638+
end, λ ⟨n, e⟩, e.symm ▸ nat_lt_omega _⟩
625639
-/
626640

627641
end cardinal

data/fintype.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ instance subtype {p : α → Prop} (s : finset α)
6868
multiset.nodup_pmap (λ a _ b _, congr_arg subtype.val) s.2⟩,
6969
λ ⟨x, px⟩, multiset.mem_pmap.2 ⟨x, (H x).2 px, rfl⟩⟩
7070

71+
theorem subtype_card {p : α → Prop} (s : finset α)
72+
(H : ∀ x : α, x ∈ s ↔ p x) :
73+
@card {x // p x} (fintype.subtype s H) = s.card :=
74+
multiset.card_pmap _ _ _
75+
76+
theorem card_of_subtype {p : α → Prop} (s : finset α)
77+
(H : ∀ x : α, x ∈ s ↔ p x) [fintype {x // p x}] :
78+
card {x // p x} = s.card :=
79+
by rw ← subtype_card s H; congr
80+
7181
def of_bijective [fintype α] (f : α → β) (H : function.bijective f) : fintype β :=
7282
⟨⟨univ.1.map f, multiset.nodup_map H.1 univ.2⟩,
7383
λ b, let ⟨a, e⟩ := H.2 b in e ▸ multiset.mem_map_of_mem _ (mem_univ _)⟩

0 commit comments

Comments
 (0)