Skip to content

Commit cdd500c

Browse files
committed
feat: port Data.W.Cardinal (#2465)
Co-authored-by: Moritz Firsching <firsching@google.com>
1 parent 4458fc3 commit cdd500c

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,7 @@ import Mathlib.Data.Vector.Basic
722722
import Mathlib.Data.Vector.Mem
723723
import Mathlib.Data.Vector.Zip
724724
import Mathlib.Data.W.Basic
725+
import Mathlib.Data.W.Cardinal
725726
import Mathlib.Data.W.Constructions
726727
import Mathlib.Data.ZMod.Defs
727728
import Mathlib.Deprecated.Group

Mathlib/Data/W/Cardinal.lean

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/-
2+
Copyright (c) 2021 Chris Hughes. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Chris Hughes
5+
6+
! This file was ported from Lean 3 source module data.W.cardinal
7+
! leanprover-community/mathlib commit 6eeb941cf39066417a09b1bbc6e74761cadfcb1a
8+
! Please do not edit these lines, except to modify the commit id
9+
! if you have ported upstream changes.
10+
-/
11+
import Mathlib.Data.W.Basic
12+
import Mathlib.SetTheory.Cardinal.Ordinal
13+
14+
/-!
15+
# Cardinality of W-types
16+
17+
This file proves some theorems about the cardinality of W-types. The main result is
18+
`cardinal_mk_le_max_aleph0_of_finite` which says that if for any `a : α`,
19+
`β a` is finite, then the cardinality of `WType β` is at most the maximum of the
20+
cardinality of `α` and `ℵ₀`.
21+
This can be used to prove theorems about the cardinality of algebraic constructions such as
22+
polynomials. There is a surjection from a `WType` to `MvPolynomial` for example, and
23+
this surjection can be used to put an upper bound on the cardinality of `MvPolynomial`.
24+
25+
## Tags
26+
27+
W, W type, cardinal, first order
28+
-/
29+
30+
31+
universe u
32+
33+
variable {α : Type u} {β : α → Type u}
34+
35+
noncomputable section
36+
37+
namespace WType
38+
39+
open Cardinal
40+
41+
open Cardinal
42+
-- porting note: `W` is a special name, exceptionally in upper case in Lean3
43+
set_option linter.uppercaseLean3 false
44+
45+
theorem cardinal_mk_eq_sum : (#WType β) = sum (fun a : α => (#WType β) ^ (#β a)) := by
46+
simp only [Cardinal.power_def, ← Cardinal.mk_sigma]
47+
exact mk_congr (equivSigma β)
48+
#align W_type.cardinal_mk_eq_sum WType.cardinal_mk_eq_sum
49+
50+
/-- `#(WType β)` is the least cardinal `κ` such that `Sum (λ a : α, κ ^ #(β a)) ≤ κ` -/
51+
theorem cardinal_mk_le_of_le {κ : Cardinal.{u}} (hκ : (sum fun a : α => κ ^ (#β a)) ≤ κ) :
52+
(#WType β) ≤ κ := by
53+
induction' κ using Cardinal.inductionOn with γ
54+
simp only [Cardinal.power_def, ← Cardinal.mk_sigma, Cardinal.le_def] at hκ
55+
cases' hκ with
56+
exact Cardinal.mk_le_of_injective (elim_injective _ hκ.1 hκ.2)
57+
#align W_type.cardinal_mk_le_of_le WType.cardinal_mk_le_of_le
58+
59+
/-- If, for any `a : α`, `β a` is finite, then the cardinality of `WType β`
60+
is at most the maximum of the cardinality of `α` and `ℵ₀` -/
61+
theorem cardinal_mk_le_max_aleph0_of_finite [∀ a, Finite (β a)] : (#WType β) ≤ max (#α) ℵ₀ :=
62+
(isEmpty_or_nonempty α).elim
63+
(by
64+
intro h
65+
rw [Cardinal.mk_eq_zero (WType β)]
66+
exact zero_le _)
67+
fun hn =>
68+
let m := max (#α) ℵ₀
69+
cardinal_mk_le_of_le <|
70+
calc
71+
(Cardinal.sum fun a => m ^ (#β a)) ≤ (#α) * ⨆ a, m ^ (#β a) := Cardinal.sum_le_supᵢ _
72+
_ ≤ m * ⨆ a, m ^ (#β a) := mul_le_mul' (le_max_left _ _) le_rfl
73+
_ = m :=
74+
mul_eq_left.{u} (le_max_right _ _)
75+
(csupᵢ_le' fun i => pow_le (le_max_right _ _) (lt_aleph0_of_finite _)) <|
76+
pos_iff_ne_zero.1 <|
77+
Order.succ_le_iff.1
78+
(by
79+
rw [succ_zero]
80+
obtain ⟨a⟩ : Nonempty α; exact hn
81+
refine' le_trans _ (le_csupᵢ (bddAbove_range.{u, u} _) a)
82+
rw [← power_zero]
83+
exact
84+
power_le_power_left
85+
(pos_iff_ne_zero.1 (aleph0_pos.trans_le (le_max_right _ _))) (zero_le _))
86+
87+
#align W_type.cardinal_mk_le_max_aleph_0_of_finite WType.cardinal_mk_le_max_aleph0_of_finite
88+
89+
end WType

0 commit comments

Comments
 (0)