forked from leanprover-community/mathlib4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstructions.lean
More file actions
684 lines (529 loc) · 26.4 KB
/
Constructions.lean
File metadata and controls
684 lines (529 loc) · 26.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Johannes Hölzl, Sander Dahmen, Kim Morrison, Chris Hughes, Anne Baanen
-/
module
public import Mathlib.Algebra.Algebra.Subalgebra.Lattice
public import Mathlib.LinearAlgebra.Basis.Prod
public import Mathlib.LinearAlgebra.Dimension.Free
public import Mathlib.LinearAlgebra.TensorProduct.Basis
/-!
# Rank of various constructions
## Main statements
- `rank_quotient_add_rank_le` : `rank M/N + rank N ≤ rank M`.
- `lift_rank_add_lift_rank_le_rank_prod`: `rank M × N ≤ rank M + rank N`.
- `rank_span_le_of_finite`: `rank (span s) ≤ #s` for finite `s`.
For free modules, we have
- `rank_prod` : `rank M × N = rank M + rank N`.
- `rank_finsupp` : `rank (ι →₀ M) = #ι * rank M`
- `rank_directSum`: `rank (⨁ Mᵢ) = ∑ rank Mᵢ`
- `rank_tensorProduct`: `rank (M ⊗ N) = rank M * rank N`.
Lemmas for ranks of submodules and subalgebras are also provided.
We have `finrank` variants for most lemmas as well.
-/
@[expose] public section
noncomputable section
universe u u' v v' u₁' w w'
variable {R : Type u} {S : Type u'} {M : Type v} {M' : Type v'} {M₁ : Type v}
variable {ι : Type w} {ι' : Type w'} {η : Type u₁'} {φ : η → Type*}
open Basis Cardinal DirectSum Function Module Set Submodule
section Quotient
variable [Ring R] [CommRing S] [AddCommGroup M] [AddCommGroup M'] [AddCommGroup M₁]
variable [Module R M]
theorem LinearIndependent.sumElim_of_quotient
{M' : Submodule R M} {ι₁ ι₂} {f : ι₁ → M'} (hf : LinearIndependent R f) (g : ι₂ → M)
(hg : LinearIndependent R (Submodule.Quotient.mk (p := M') ∘ g)) :
LinearIndependent R (Sum.elim (f · : ι₁ → M) g) := by
refine .sum_type (hf.map' M'.subtype M'.ker_subtype) (.of_comp M'.mkQ hg) ?_
refine disjoint_def.mpr fun x h₁ h₂ ↦ ?_
have : x ∈ M' := span_le.mpr (Set.range_subset_iff.mpr fun i ↦ (f i).prop) h₁
obtain ⟨c, rfl⟩ := Finsupp.mem_span_range_iff_exists_finsupp.mp h₂
simp_rw [← Quotient.mk_eq_zero, ← mkQ_apply, map_finsuppSum, map_smul, mkQ_apply] at this
rw [linearIndependent_iff.mp hg _ this, Finsupp.sum_zero_index]
theorem LinearIndepOn.union_of_quotient {s t : Set ι} {f : ι → M} (hs : LinearIndepOn R f s)
(ht : LinearIndepOn R (mkQ (span R (f '' s)) ∘ f) t) : LinearIndepOn R f (s ∪ t) := by
apply hs.union ht.of_comp
convert (Submodule.range_ker_disjoint ht).symm
· simp
aesop
theorem LinearIndepOn.union_id_of_quotient {M' : Submodule R M}
{s : Set M} (hs : s ⊆ M') (hs' : LinearIndepOn R id s) {t : Set M}
(ht : LinearIndepOn R (mkQ M') t) : LinearIndepOn R id (s ∪ t) :=
hs'.union_of_quotient <| by
rw [image_id]
exact ht.of_comp ((span R s).mapQ M' (LinearMap.id) (span_le.2 hs))
theorem linearIndepOn_union_iff_quotient {s t : Set ι} {f : ι → M} (hst : Disjoint s t) :
LinearIndepOn R f (s ∪ t) ↔
LinearIndepOn R f s ∧ LinearIndepOn R (mkQ (span R (f '' s)) ∘ f) t := by
refine ⟨fun h ↦ ⟨?_, ?_⟩, fun h ↦ h.1.union_of_quotient h.2⟩
· exact h.mono subset_union_left
apply (h.mono subset_union_right).map
simpa [← image_eq_range] using ((linearIndepOn_union_iff hst).1 h).2.2.symm
theorem LinearIndepOn.quotient_iff_union {s t : Set ι} {f : ι → M} (hs : LinearIndepOn R f s)
(hst : Disjoint s t) :
LinearIndepOn R (mkQ (span R (f '' s)) ∘ f) t ↔ LinearIndepOn R f (s ∪ t) := by
rw [linearIndepOn_union_iff_quotient hst, and_iff_right hs]
theorem rank_quotient_add_rank_le [Nontrivial R] (M' : Submodule R M) :
Module.rank R (M ⧸ M') + Module.rank R M' ≤ Module.rank R M := by
conv_lhs => simp only [Module.rank_def]
rw [Cardinal.ciSup_add_ciSup _ (bddAbove_range _) _ (bddAbove_range _)]
refine ciSup_le fun ⟨s, hs⟩ ↦ ciSup_le fun ⟨t, ht⟩ ↦ ?_
choose f hf using Submodule.Quotient.mk_surjective M'
simpa [add_comm] using (LinearIndependent.sumElim_of_quotient ht (fun (i : s) ↦ f i)
(by simpa [Function.comp_def, hf] using hs)).cardinal_le_rank
theorem rank_quotient_le (p : Submodule R M) : Module.rank R (M ⧸ p) ≤ Module.rank R M :=
(mkQ p).rank_le_of_surjective Quot.mk_surjective
/-- The dimension of a quotient is bounded by the dimension of the ambient space. -/
theorem Submodule.finrank_quotient_le [StrongRankCondition R] [Module.Finite R M]
(s : Submodule R M) : finrank R (M ⧸ s) ≤ finrank R M :=
toNat_le_toNat ((Submodule.mkQ s).rank_le_of_surjective Quot.mk_surjective)
(rank_lt_aleph0 _ _)
theorem LinearMap.finrank_le_finrank_of_surjective
[Module R M'] [StrongRankCondition R] [Module.Finite R M]
{f : M →ₗ[R] M'} (h : Function.Surjective f) : Module.finrank R M' ≤ Module.finrank R M := by
rw [← f.quotKerEquivOfSurjective h |>.finrank_eq]
exact Submodule.finrank_quotient_le _
end Quotient
variable [Semiring R] [CommSemiring S] [AddCommMonoid M] [AddCommMonoid M'] [AddCommMonoid M₁]
variable [Module R M]
section ULift
@[simp]
theorem rank_ulift : Module.rank R (ULift.{w} M) = Cardinal.lift.{w} (Module.rank R M) :=
Cardinal.lift_injective.{v} <| Eq.symm <| (lift_lift _).trans ULift.moduleEquiv.symm.lift_rank_eq
@[simp]
theorem finrank_ulift : finrank R (ULift M) = finrank R M := by
simp_rw [finrank, rank_ulift, toNat_lift]
end ULift
section Prod
variable (R M M')
variable [Module R M₁] [Module R M']
theorem rank_add_rank_le_rank_prod [Nontrivial R] :
Module.rank R M + Module.rank R M₁ ≤ Module.rank R (M × M₁) := by
conv_lhs => simp only [Module.rank_def]
rw [Cardinal.ciSup_add_ciSup _ (bddAbove_range _) _ (bddAbove_range _)]
exact ciSup_le fun ⟨s, hs⟩ ↦ ciSup_le fun ⟨t, ht⟩ ↦
(linearIndependent_inl_union_inr' hs ht).cardinal_le_rank
theorem lift_rank_add_lift_rank_le_rank_prod [Nontrivial R] :
lift.{v'} (Module.rank R M) + lift.{v} (Module.rank R M') ≤ Module.rank R (M × M') := by
rw [← rank_ulift, ← rank_ulift]
exact (rank_add_rank_le_rank_prod R _).trans_eq
(ULift.moduleEquiv.prodCongr ULift.moduleEquiv).rank_eq
variable {R M M'}
variable [StrongRankCondition R] [Module.Free R M] [Module.Free R M'] [Module.Free R M₁]
open Module.Free
/-- If `M` and `M'` are free, then the rank of `M × M'` is
`(Module.rank R M).lift + (Module.rank R M').lift`. -/
@[simp]
theorem rank_prod : Module.rank R (M × M') =
Cardinal.lift.{v'} (Module.rank R M) + Cardinal.lift.{v, v'} (Module.rank R M') := by
simpa [rank_eq_card_chooseBasisIndex R M, rank_eq_card_chooseBasisIndex R M', lift_umax]
using ((chooseBasis R M).prod (chooseBasis R M')).mk_eq_rank.symm
/-- If `M` and `M'` are free (and lie in the same universe), the rank of `M × M'` is
`(Module.rank R M) + (Module.rank R M')`. -/
theorem rank_prod' : Module.rank R (M × M₁) = Module.rank R M + Module.rank R M₁ := by simp
/-- The `finrank` of `M × M'` is `(finrank R M) + (finrank R M')`. -/
@[simp]
theorem Module.finrank_prod [Module.Finite R M] [Module.Finite R M'] :
finrank R (M × M') = finrank R M + finrank R M' := by
simp [finrank, rank_lt_aleph0 R M, rank_lt_aleph0 R M']
end Prod
section Finsupp
variable (R M M')
variable [StrongRankCondition R] [Module.Free R M] [Module R M'] [Module.Free R M']
open Module.Free
@[simp]
theorem rank_finsupp (ι : Type w) :
Module.rank R (ι →₀ M) = Cardinal.lift.{v} #ι * Cardinal.lift.{w} (Module.rank R M) := by
obtain ⟨⟨_, bs⟩⟩ := Module.Free.exists_basis (R := R) (M := M)
rw [← bs.mk_eq_rank'', ← (Finsupp.basis fun _ : ι => bs).mk_eq_rank'', Cardinal.mk_sigma,
Cardinal.sum_const]
theorem rank_finsupp' (ι : Type v) : Module.rank R (ι →₀ M) = #ι * Module.rank R M := by
simp [rank_finsupp]
/-- The rank of `(ι →₀ R)` is `(#ι).lift`. -/
theorem rank_finsupp_self (ι : Type w) : Module.rank R (ι →₀ R) = Cardinal.lift.{u} #ι := by
simp
/-- If `R` and `ι` lie in the same universe, the rank of `(ι →₀ R)` is `# ι`. -/
theorem rank_finsupp_self' {ι : Type u} : Module.rank R (ι →₀ R) = #ι := by simp
/-- The rank of the direct sum is the sum of the ranks. -/
@[simp]
theorem rank_directSum {ι : Type v} (M : ι → Type w) [∀ i : ι, AddCommMonoid (M i)]
[∀ i : ι, Module R (M i)] [∀ i : ι, Module.Free R (M i)] :
Module.rank R (⨁ i, M i) = Cardinal.sum fun i => Module.rank R (M i) := by
let B i := chooseBasis R (M i)
let b : Basis _ R (⨁ i, M i) := DFinsupp.basis fun i => B i
simp [← b.mk_eq_rank'', fun i => (B i).mk_eq_rank'']
/-- If `m` and `n` are finite, the rank of `m × n` matrices over a module `M` is
`(#m).lift * (#n).lift * rank R M`. -/
@[simp]
theorem rank_matrix_module (m : Type w) (n : Type w') [Finite m] [Finite n] :
Module.rank R (Matrix m n M) =
lift.{max v w'} #m * lift.{max v w} #n * lift.{max w w'} (Module.rank R M) := by
cases nonempty_fintype m
cases nonempty_fintype n
obtain ⟨I, b⟩ := Module.Free.exists_basis (R := R) (M := M)
rw [← (b.matrix m n).mk_eq_rank'']
simp only [mk_prod, lift_mul, lift_lift, ← mul_assoc, b.mk_eq_rank'']
/-- If `m` and `n` are finite and lie in the same universe, the rank of `m × n` matrices over a
module `M` is `(#m * #n).lift * rank R M`. -/
@[simp high]
theorem rank_matrix_module' (m n : Type w) [Finite m] [Finite n] :
Module.rank R (Matrix m n M) =
lift.{max v} (#m * #n) * lift.{w} (Module.rank R M) := by
rw [rank_matrix_module, lift_mul, lift_umax.{w, v}]
/-- If `m` and `n` are finite, the rank of `m × n` matrices is `(#m).lift * (#n).lift`. -/
theorem rank_matrix (m : Type v) (n : Type w) [Finite m] [Finite n] :
Module.rank R (Matrix m n R) =
Cardinal.lift.{max v w u, v} #m * Cardinal.lift.{max v w u, w} #n := by
rw [rank_matrix_module, rank_self, lift_one, mul_one, ← lift_lift.{v, max u w}, lift_id,
← lift_lift.{w, max u v}, lift_id]
/-- If `m` and `n` are finite and lie in the same universe, the rank of `m × n` matrices is
`(#n * #m).lift`. -/
theorem rank_matrix' (m n : Type v) [Finite m] [Finite n] :
Module.rank R (Matrix m n R) = Cardinal.lift.{u} (#m * #n) := by
rw [rank_matrix, lift_mul, lift_umax.{v, u}]
/-- If `m` and `n` are finite and lie in the same universe as `R`, the rank of `m × n` matrices
is `# m * # n`. -/
theorem rank_matrix'' (m n : Type u) [Finite m] [Finite n] :
Module.rank R (Matrix m n R) = #m * #n := by simp
open Fintype
namespace Module
@[simp]
theorem finrank_finsupp {ι : Type v} [Fintype ι] : finrank R (ι →₀ M) = card ι * finrank R M := by
rw [finrank, finrank, rank_finsupp, ← mk_toNat_eq_card, toNat_mul, toNat_lift, toNat_lift]
/-- The `finrank` of `(ι →₀ R)` is `Fintype.card ι`. -/
@[simp]
theorem finrank_finsupp_self {ι : Type v} [Fintype ι] : finrank R (ι →₀ R) = card ι := by
rw [finrank, rank_finsupp_self, ← mk_toNat_eq_card, toNat_lift]
/-- The `finrank` of the direct sum is the sum of the `finrank`s. -/
@[simp]
theorem finrank_directSum {ι : Type v} [Fintype ι] (M : ι → Type w) [∀ i : ι, AddCommMonoid (M i)]
[∀ i : ι, Module R (M i)] [∀ i : ι, Module.Free R (M i)] [∀ i : ι, Module.Finite R (M i)] :
finrank R (⨁ i, M i) = ∑ i, finrank R (M i) := by
simp only [finrank, fun i => rank_eq_card_chooseBasisIndex R (M i), rank_directSum, ← mk_sigma,
mk_toNat_eq_card, card_sigma]
/-- If `m` and `n` are `Fintype`, the `finrank` of `m × n` matrices over a module `M` is
`(Fintype.card m) * (Fintype.card n) * finrank R M`. -/
theorem finrank_matrix (m n : Type*) [Fintype m] [Fintype n] :
finrank R (Matrix m n M) = card m * card n * finrank R M := by simp [finrank]
end Module
end Finsupp
section Pi
variable [StrongRankCondition R] [Module.Free R M]
variable [∀ i, AddCommMonoid (φ i)] [∀ i, Module R (φ i)] [∀ i, Module.Free R (φ i)]
open Module.Free
open LinearMap
/-- The rank of a finite product of free modules is the sum of the ranks. -/
-- this result is not true without the freeness assumption
@[simp]
theorem rank_pi [Finite η] : Module.rank R (∀ i, φ i) =
Cardinal.sum fun i => Module.rank R (φ i) := by
cases nonempty_fintype η
let B i := chooseBasis R (φ i)
let b : Basis _ R (∀ i, φ i) := Pi.basis fun i => B i
simp [← b.mk_eq_rank'', fun i => (B i).mk_eq_rank'']
variable (R)
/-- The `finrank` of `(ι → R)` is `Fintype.card ι`. -/
theorem Module.finrank_pi {ι : Type v} [Fintype ι] :
finrank R (ι → R) = Fintype.card ι := by
simp [finrank]
--TODO: this should follow from `LinearEquiv.finrank_eq`, that is over a field.
/-- The `finrank` of a finite product is the sum of the `finrank`s. -/
theorem Module.finrank_pi_fintype
{ι : Type v} [Fintype ι] {M : ι → Type w} [∀ i : ι, AddCommMonoid (M i)]
[∀ i : ι, Module R (M i)] [∀ i : ι, Module.Free R (M i)] [∀ i : ι, Module.Finite R (M i)] :
finrank R (∀ i, M i) = ∑ i, finrank R (M i) := by
simp only [finrank, fun i => rank_eq_card_chooseBasisIndex R (M i), rank_pi, ← mk_sigma,
mk_toNat_eq_card, Fintype.card_sigma]
variable {R}
variable [Fintype η]
theorem rank_fun {M η : Type u} [Fintype η] [AddCommMonoid M] [Module R M] [Module.Free R M] :
Module.rank R (η → M) = Fintype.card η * Module.rank R M := by
rw [rank_pi, Cardinal.sum_const', Cardinal.mk_fintype]
theorem rank_fun_eq_lift_mul : Module.rank R (η → M) =
(Fintype.card η : Cardinal.{max u₁' v}) * Cardinal.lift.{u₁'} (Module.rank R M) := by
rw [rank_pi, Cardinal.sum_const, Cardinal.mk_fintype, Cardinal.lift_natCast]
theorem rank_fun' : Module.rank R (η → R) = Fintype.card η := by
rw [rank_fun_eq_lift_mul, rank_self, Cardinal.lift_one, mul_one]
theorem rank_fin_fun (n : ℕ) : Module.rank R (Fin n → R) = n := by simp
variable (R)
/-- The vector space of functions on a `Fintype ι` has `finrank` equal to the cardinality of `ι`. -/
@[simp]
theorem Module.finrank_fintype_fun_eq_card : finrank R (η → R) = Fintype.card η :=
finrank_eq_of_rank_eq rank_fun'
/-- The vector space of functions on `Fin n` has `finrank` equal to `n`. -/
theorem Module.finrank_fin_fun {n : ℕ} : finrank R (Fin n → R) = n := by simp
variable {R}
theorem Module.le_rank_iff_exists_linearMap'
[Module R M'] [Module.Finite R M] [Nontrivial R] :
Module.finrank R M ≤ Module.rank R M' ↔
∃ f : M →ₗ[R] M', Function.Injective f :=
let e := LinearEquiv.ofFinrankEq (R := R) M
(Fin (Module.finrank R M) → R) (Module.finrank_fin_fun R).symm
⟨
fun h => by
rw [Module.le_rank_iff_exists_linearMap] at h
rcases h with ⟨φ, hφ⟩
exact ⟨φ ∘ₛₗ e.toLinearMap, by simpa⟩,
fun ⟨f, hf⟩ => Module.le_rank_iff_exists_linearMap.mpr
⟨f ∘ₛₗ e.symm.toLinearMap, by simpa⟩
⟩
theorem Module.le_finrank_iff_existsLinearMap
[Module R M'] [Module.Finite R M] [Nontrivial R] [Module.Finite R M'] :
Module.finrank R M ≤ Module.finrank R M' ↔
∃ f : M →ₗ[R] M', Function.Injective f :=
⟨
fun h => Module.le_rank_iff_exists_linearMap'.mp <| by
rw [← Module.finrank_eq_rank R M', Nat.cast_le]
exact h,
fun h => by
let h := Module.le_rank_iff_exists_linearMap'.mpr h
rwa [← Module.finrank_eq_rank R M', Nat.cast_le] at h
⟩
theorem OrzechProperty.bijective_of_surjective_of_finrank_le [OrzechProperty R]
[Module R M'] [Module.Finite R M] [Nontrivial R] [Module.Finite R M']
(h : Module.finrank R M ≤ Module.finrank R M')
(f : M →ₗ[R] M') (hf : Function.Surjective f) :
Function.Bijective f := by
rcases Module.le_finrank_iff_existsLinearMap.mp h with ⟨φ, hφ⟩
refine OrzechProperty.bijective_of_surjective_of_injective φ _ hφ hf
-- TODO: merge with the `Finrank` content
/-- An `n`-dimensional `R`-vector space is equivalent to `Fin n → R`. -/
def finDimVectorspaceEquiv (n : ℕ) (hn : Module.rank R M = n) : M ≃ₗ[R] Fin n → R := by
haveI := nontrivial_of_invariantBasisNumber R
have : Cardinal.lift.{u} (n : Cardinal.{v}) = Cardinal.lift.{v} (n : Cardinal.{u}) := by simp
have hn := Cardinal.lift_inj.{v, u}.2 hn
rw [this] at hn
rw [← @rank_fin_fun R _ _ n] at hn
haveI : Module.Free R (Fin n → R) := Module.Free.pi _ _
exact Classical.choice (nonempty_linearEquiv_of_lift_rank_eq hn)
end Pi
section TensorProduct
open TensorProduct
variable [StrongRankCondition R] [StrongRankCondition S]
variable [Module S M] [Module S M'] [Module.Free S M']
variable [Module S M₁] [Module.Free S M₁]
variable [Algebra S R] [IsScalarTower S R M] [Module.Free R M]
open Module.Free
/-- The `S`-rank of `M ⊗[R] M'` is `(Module.rank S M).lift * (Module.rank R M').lift`. -/
@[simp]
theorem rank_tensorProduct :
Module.rank R (M ⊗[S] M') =
Cardinal.lift.{v'} (Module.rank R M) * Cardinal.lift.{v} (Module.rank S M') := by
obtain ⟨⟨_, bM⟩⟩ := Module.Free.exists_basis (R := R) (M := M)
obtain ⟨⟨_, bN⟩⟩ := Module.Free.exists_basis (R := S) (M := M')
rw [← bM.mk_eq_rank'', ← bN.mk_eq_rank'', ← (bM.tensorProduct bN).mk_eq_rank'', Cardinal.mk_prod]
/-- If `M` and `M'` lie in the same universe, the `S`-rank of `M ⊗[R] M'` is
`(Module.rank S M) * (Module.rank R M')`. -/
theorem rank_tensorProduct' :
Module.rank R (M ⊗[S] M₁) = Module.rank R M * Module.rank S M₁ := by simp
theorem Module.rank_baseChange :
Module.rank R (R ⊗[S] M') = Cardinal.lift.{u} (Module.rank S M') := by simp
/-- The `S`-`finrank` of `M ⊗[R] M'` is `(finrank S M) * (finrank R M')`. -/
@[simp]
theorem Module.finrank_tensorProduct :
finrank R (M ⊗[S] M') = finrank R M * finrank S M' := by simp [finrank]
theorem Module.finrank_baseChange : finrank R (R ⊗[S] M') = finrank S M' := by simp
end TensorProduct
section SubmoduleRank
section
open Module
namespace Submodule
theorem lt_of_le_of_finrank_lt_finrank {s t : Submodule R M} (le : s ≤ t)
(lt : finrank R s < finrank R t) : s < t :=
lt_of_le_of_ne le fun h => ne_of_lt lt (by rw [h])
theorem lt_top_of_finrank_lt_finrank {s : Submodule R M} (lt : finrank R s < finrank R M) :
s < ⊤ := by
rw [← finrank_top R M] at lt
exact lt_of_le_of_finrank_lt_finrank le_top lt
end Submodule
variable [StrongRankCondition R]
/-- The dimension of a submodule is bounded by the dimension of the ambient space. -/
theorem Submodule.finrank_le [Module.Finite R M] (s : Submodule R M) :
finrank R s ≤ finrank R M :=
toNat_le_toNat (Submodule.rank_le s) (rank_lt_aleph0 _ _)
/-- Pushforwards of finite submodules have a smaller finrank. -/
theorem Submodule.finrank_map_le
[Module R M'] (f : M →ₗ[R] M') (p : Submodule R M) [Module.Finite R p] :
finrank R (p.map f) ≤ finrank R p :=
finrank_le_finrank_of_rank_le_rank (lift_rank_map_le _ _) (rank_lt_aleph0 _ _)
theorem Submodule.finrank_mono {s t : Submodule R M} [Module.Finite R t] (hst : s ≤ t) :
finrank R s ≤ finrank R t :=
Cardinal.toNat_le_toNat (Submodule.rank_mono hst) (rank_lt_aleph0 R ↥t)
end
end SubmoduleRank
section Span
variable [StrongRankCondition R]
theorem rank_span_le (s : Set M) : Module.rank R (span R s) ≤ #s := by
rw [Finsupp.span_eq_range_linearCombination, ← lift_strictMono.le_iff_le]
refine (lift_rank_range_le _).trans ?_
rw [rank_finsupp_self]
simp only [lift_lift, le_refl]
theorem rank_span_finset_le (s : Finset M) : Module.rank R (span R (s : Set M)) ≤ s.card := by
simpa using rank_span_le (s : Set M)
theorem rank_span_of_finset (s : Finset M) : Module.rank R (span R (s : Set M)) < ℵ₀ :=
(rank_span_finset_le s).trans_lt natCast_lt_aleph0
open Submodule Module
variable (R) in
/-- The rank of a set of vectors as a natural number. -/
protected noncomputable def Set.finrank (s : Set M) : ℕ :=
finrank R (span R s)
theorem finrank_span_le_card (s : Set M) [Fintype s] : finrank R (span R s) ≤ s.toFinset.card :=
finrank_le_of_rank_le (by simpa using rank_span_le (R := R) s)
theorem finrank_span_finset_le_card (s : Finset M) : (s : Set M).finrank R ≤ s.card :=
calc
(s : Set M).finrank R ≤ (s : Set M).toFinset.card := finrank_span_le_card (M := M) s
_ = s.card := by simp
theorem finrank_range_le_card {ι : Type*} [Fintype ι] (b : ι → M) :
(Set.range b).finrank R ≤ Fintype.card ι := by
classical
refine (finrank_span_le_card _).trans ?_
rw [Set.toFinset_range]
exact Finset.card_image_le
theorem finrank_span_eq_card [Nontrivial R] {ι : Type*} [Fintype ι] {b : ι → M}
(hb : LinearIndependent R b) :
finrank R (span R (Set.range b)) = Fintype.card ι :=
finrank_eq_of_rank_eq
(by
have : Module.rank R (span R (Set.range b)) = #(Set.range b) := rank_span hb
rwa [← lift_inj, mk_range_eq_of_injective hb.injective, Cardinal.mk_fintype, lift_natCast,
lift_eq_nat_iff] at this)
theorem finrank_span_set_eq_card {s : Set M} [Fintype s] (hs : LinearIndepOn R id s) :
finrank R (span R s) = s.toFinset.card :=
finrank_eq_of_rank_eq
(by
have : Module.rank R (span R s) = #s := rank_span_set hs
rwa [Cardinal.mk_fintype, ← Set.toFinset_card] at this)
theorem finrank_span_finset_eq_card {s : Finset M} (hs : LinearIndepOn R id (s : Set M)) :
finrank R (span R (s : Set M)) = s.card := by
convert finrank_span_set_eq_card (s := (s : Set M)) hs
ext
simp
theorem span_lt_of_subset_of_card_lt_finrank {s : Set M} [Fintype s] {t : Submodule R M}
(subset : s ⊆ t) (card_lt : s.toFinset.card < finrank R t) : span R s < t :=
lt_of_le_of_finrank_lt_finrank (span_le.mpr subset)
(lt_of_le_of_lt (finrank_span_le_card _) card_lt)
theorem span_lt_top_of_card_lt_finrank {s : Set M} [Fintype s]
(card_lt : s.toFinset.card < finrank R M) : span R s < ⊤ :=
lt_top_of_finrank_lt_finrank (lt_of_le_of_lt (finrank_span_le_card _) card_lt)
lemma finrank_le_of_span_eq_top {ι : Type*} [Fintype ι] {v : ι → M}
(hv : Submodule.span R (Set.range v) = ⊤) : finrank R M ≤ Fintype.card ι := by
classical
rw [← finrank_top, ← hv]
exact (finrank_span_le_card _).trans (by convert Fintype.card_range_le v; rw [Set.toFinset_card])
@[simp]
lemma Pi.dim_spanSubset [Finite ι] [Nontrivial R] {s : Set ι} :
Module.finrank R (Pi.spanSubset R s) = s.ncard := by
classical
have := Fintype.ofFinite ι
rw [Pi.spanSubset, finrank_span_set_eq_card <| (Pi.basisFun R ι).linearIndepOn _ |>.id_image,
Set.toFinset_card, Fintype.card_eq_nat_card, Nat.card_coe_set_eq]
exact Set.ncard_image_of_injective s <| (Pi.basisFun R ι).injective
end Span
section SubalgebraRank
open Module
section Semiring
variable {F E : Type*} [CommSemiring F] [Semiring E] [Algebra F E]
@[simp]
theorem Subalgebra.rank_toSubmodule (S : Subalgebra F E) :
Module.rank F (Subalgebra.toSubmodule S) = Module.rank F S :=
rfl
@[simp]
theorem Subalgebra.finrank_toSubmodule (S : Subalgebra F E) :
finrank F (Subalgebra.toSubmodule S) = finrank F S :=
rfl
theorem subalgebra_top_rank_eq_submodule_top_rank :
Module.rank F (⊤ : Subalgebra F E) = Module.rank F (⊤ : Submodule F E) := by
rw [← Algebra.top_toSubmodule]
rfl
theorem subalgebra_top_finrank_eq_submodule_top_finrank :
finrank F (⊤ : Subalgebra F E) = finrank F (⊤ : Submodule F E) := by
rw [← Algebra.top_toSubmodule]
rfl
theorem Subalgebra.rank_top : Module.rank F (⊤ : Subalgebra F E) = Module.rank F E := by
rw [subalgebra_top_rank_eq_submodule_top_rank]
exact _root_.rank_top F E
end Semiring
section Ring
variable {F E : Type*} [CommRing F] [IsDomain F] [Ring E] [Algebra F E]
variable [StrongRankCondition F] [IsTorsionFree F E] [Nontrivial E]
@[simp]
theorem Subalgebra.rank_bot : Module.rank F (⊥ : Subalgebra F E) = 1 :=
(Subalgebra.toSubmoduleEquiv (⊥ : Subalgebra F E)).symm.rank_eq.trans <| by
rw [Algebra.toSubmodule_bot, one_eq_span, rank_span_set, mk_singleton _]
have := Module.nontrivial F E
exact .singleton one_ne_zero
@[simp]
theorem Subalgebra.finrank_bot : finrank F (⊥ : Subalgebra F E) = 1 :=
finrank_eq_of_rank_eq (by simp)
end Ring
end SubalgebraRank
section Extend
namespace Module.Basis
variable {R V : Type*} [CommRing R] [AddCommGroup V] [Module R V]
{W : Submodule R V} {m n : Type*}
(bW : Basis m R W) (bQ : Basis n R (V ⧸ W))
/-- Given a basis `bW` of a submodule of an `R`-module `V`,
and a basis `bQ` of the quotient `V ⧸ W`,
this is a basis of `V` combining `bW` and a lift of `bQ`. -/
noncomputable def sumQuot :
Basis (m ⊕ n) R V := by
let b : m ⊕ n → V := Sum.elim (fun i ↦ bW i) ((Function.surjInv W.mkQ_surjective) ∘ bQ)
have br : W.mkQ ∘ b ∘ Sum.inr = bQ := by
ext j
apply Function.rightInverse_surjInv W.mkQ_surjective
apply Basis.mk (v := b)
· apply LinearIndependent.sumElim_of_quotient
· exact bW.linearIndependent
· convert bQ.linearIndependent
· unfold b
rw [Set.Sum.elim_range, Submodule.span_union,
show Set.range (fun i ↦ (bW i : V)) = W.subtype '' (Set.range (fun i ↦ bW i)) by aesop,
← Submodule.map_span, bW.span_eq, Submodule.map_top, Submodule.range_subtype, top_le_iff,
← Submodule.map_mkQ_eq_top, Submodule.map_span, ← Set.range_comp, ← bQ.span_eq]
congr 2
@[simp]
theorem sumQuot_inl (i : m) :
sumQuot bW bQ (Sum.inl i) = bW i := by
simp [sumQuot]
@[simp]
theorem sumQuot_inr (j : n) :
Submodule.Quotient.mk (sumQuot bW bQ (Sum.inr j)) = bQ j := by
simpa only [sumQuot, Basis.coe_mk, Sum.elim_inr, Function.comp_apply, ← W.mkQ_apply]
using Function.rightInverse_surjInv W.mkQ_surjective _
@[simp]
theorem sumQuot_repr_left (i : m) :
(sumQuot bW bQ).repr (bW i) = Finsupp.single (Sum.inl i) 1 := by
rw [← Module.Basis.apply_eq_iff, sumQuot_inl]
theorem sumQuot_repr_inl (w : W) (i : m) :
(sumQuot bW bQ).repr w (Sum.inl i) = bW.repr w i := by
classical
refine Eq.symm <| (bW.repr_apply_eq
(fun w i => (sumQuot bW bQ).repr (W.subtype w) (Sum.inl i)) ?_ ?_ ?_ w i) <;>
aesop (add simp Finsupp.single_apply)
@[simp]
theorem sumQuot_repr_inl_of_mem (v : V) (hv : v ∈ W) (i : m) :
(sumQuot bW bQ).repr v (Sum.inl i) = bW.repr ⟨v, hv⟩ i :=
sumQuot_repr_inl bW bQ ⟨v, hv⟩ i
@[simp]
theorem sumQuot_repr_inr (v : V) (j : n) :
(sumQuot bW bQ).repr v (Sum.inr j) = bQ.repr (W.mkQ v) j := by
simp only [← Module.Basis.coord_apply]
rw [← LinearMap.comp_apply]
revert v
rw [← LinearMap.ext_iff]
apply (sumQuot bW bQ).ext
intro x
induction x with
| inl i =>
simp [sumQuot_inl, LinearMap.comp_apply,
(Quotient.mk_eq_zero W).mpr (Submodule.coe_mem (bW i))]
| inr i =>
classical
simp [LinearMap.comp_apply, sumQuot_inr, Finsupp.single_apply]
theorem sumQuot_repr_inr_of_mem (v : V) (hv : v ∈ W) (j : n) :
(sumQuot bW bQ).repr v (Sum.inr j) = 0 := by
suffices W.mkQ v = 0 by simp [sumQuot_repr_inr, this]
aesop
end Module.Basis
end Extend