/
dimension.lean
1337 lines (1150 loc) · 51.9 KB
/
dimension.lean
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
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/-
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, Scott Morrison
-/
import linear_algebra.dfinsupp
import linear_algebra.invariant_basis_number
import linear_algebra.isomorphisms
import linear_algebra.std_basis
import set_theory.cardinal.cofinality
/-!
# Dimension of modules and vector spaces
## Main definitions
* The rank of a module is defined as `module.rank : cardinal`.
This is defined as the supremum of the cardinalities of linearly independent subsets.
* The rank of a linear map is defined as the rank of its range.
## Main statements
* `linear_map.dim_le_of_injective`: the source of an injective linear map has dimension
at most that of the target.
* `linear_map.dim_le_of_surjective`: the target of a surjective linear map has dimension
at most that of that source.
* `basis_fintype_of_finite_spans`:
the existence of a finite spanning set implies that any basis is finite.
* `infinite_basis_le_maximal_linear_independent`:
if `b` is an infinite basis for a module `M`,
and `s` is a maximal linearly independent set,
then the cardinality of `b` is bounded by the cardinality of `s`.
For modules over rings satisfying the rank condition
* `basis.le_span`:
the cardinality of a basis is bounded by the cardinality of any spanning set
For modules over rings satisfying the strong rank condition
* `linear_independent_le_span`:
For any linearly independent family `v : ι → M`
and any finite spanning set `w : set M`,
the cardinality of `ι` is bounded by the cardinality of `w`.
* `linear_independent_le_basis`:
If `b` is a basis for a module `M`,
and `s` is a linearly independent set,
then the cardinality of `s` is bounded by the cardinality of `b`.
For modules over rings with invariant basis number
(including all commutative rings and all noetherian rings)
* `mk_eq_mk_of_basis`: the dimension theorem, any two bases of the same vector space have the same
cardinality.
For vector spaces (i.e. modules over a field), we have
* `dim_quotient_add_dim`: if `V₁` is a submodule of `V`, then
`module.rank (V/V₁) + module.rank V₁ = module.rank V`.
* `dim_range_add_dim_ker`: the rank-nullity theorem.
## Implementation notes
There is a naming discrepancy: most of the theorem names refer to `dim`,
even though the definition is of `module.rank`.
This reflects that `module.rank` was originally called `dim`, and only defined for vector spaces.
Many theorems in this file are not universe-generic when they relate dimensions
in different universes. They should be as general as they can be without
inserting `lift`s. The types `V`, `V'`, ... all live in different universes,
and `V₁`, `V₂`, ... all live in the same universe.
-/
noncomputable theory
universes u v v' v'' u₁' w w'
variables {K : Type u} {V V₁ V₂ V₃ : Type v} {V' V'₁ : Type v'} {V'' : Type v''}
variables {ι : Type w} {ι' : Type w'} {η : Type u₁'} {φ : η → Type*}
open_locale classical big_operators cardinal
open basis submodule function set
section module
section
variables [semiring K] [add_comm_monoid V] [module K V]
include K
variables (K V)
/-- The rank of a module, defined as a term of type `cardinal`.
We define this as the supremum of the cardinalities of linearly independent subsets.
For a free module over any ring satisfying the strong rank condition
(e.g. left-noetherian rings, commutative rings, and in particular division rings and fields),
this is the same as the dimension of the space (i.e. the cardinality of any basis).
In particular this agrees with the usual notion of the dimension of a vector space.
The definition is marked as protected to avoid conflicts with `_root_.rank`,
the rank of a linear map.
-/
protected def module.rank : cardinal :=
cardinal.sup.{v v} (λ ι : {s : set V // linear_independent K (coe : s → V)}, #ι.1)
end
section
variables {R : Type u} [ring R]
variables {M : Type v} [add_comm_group M] [module R M]
variables {M' : Type v'} [add_comm_group M'] [module R M']
variables {M₁ : Type v} [add_comm_group M₁] [module R M₁]
theorem linear_map.lift_dim_le_of_injective (f : M →ₗ[R] M') (i : injective f) :
cardinal.lift.{v'} (module.rank R M) ≤ cardinal.lift.{ v} (module.rank R M') :=
begin
dsimp [module.rank],
fapply cardinal.lift_sup_le_lift_sup',
{ rintro ⟨s, li⟩,
use f '' s,
convert (li.map' f (linear_map.ker_eq_bot.mpr i)).comp
(equiv.set.image ⇑f s i).symm (equiv.injective _),
ext ⟨-, ⟨x, ⟨h, rfl⟩⟩⟩,
simp, },
{ rintro ⟨s, li⟩,
exact cardinal.lift_mk_le'.mpr ⟨(equiv.set.image f s i).to_embedding⟩, }
end
theorem linear_map.dim_le_of_injective (f : M →ₗ[R] M₁) (i : injective f) :
module.rank R M ≤ module.rank R M₁ :=
cardinal.lift_le.1 (f.lift_dim_le_of_injective i)
theorem dim_le {n : ℕ}
(H : ∀ s : finset M, linear_independent R (λ i : s, (i : M)) → s.card ≤ n) :
module.rank R M ≤ n :=
begin
apply cardinal.sup_le,
rintro ⟨s, li⟩,
exact linear_independent_bounded_of_finset_linear_independent_bounded H _ li,
end
lemma lift_dim_range_le (f : M →ₗ[R] M') :
cardinal.lift.{v} (module.rank R f.range) ≤ cardinal.lift.{v'} (module.rank R M) :=
begin
dsimp [module.rank],
apply cardinal.lift_sup_le,
rintro ⟨s, li⟩,
apply le_trans,
swap 2,
apply cardinal.lift_le.mpr,
refine (cardinal.le_sup _ ⟨range_splitting f '' s, _⟩),
{ apply linear_independent.of_comp f.range_restrict,
convert li.comp (equiv.set.range_splitting_image_equiv f s) (equiv.injective _) using 1, },
{ exact (cardinal.lift_mk_eq'.mpr ⟨equiv.set.range_splitting_image_equiv f s⟩).ge, },
end
lemma dim_range_le (f : M →ₗ[R] M₁) : module.rank R f.range ≤ module.rank R M :=
by simpa using lift_dim_range_le f
lemma lift_dim_map_le (f : M →ₗ[R] M') (p : submodule R M) :
cardinal.lift.{v} (module.rank R (p.map f)) ≤ cardinal.lift.{v'} (module.rank R p) :=
begin
have h := lift_dim_range_le (f.comp (submodule.subtype p)),
rwa [linear_map.range_comp, range_subtype] at h,
end
lemma dim_map_le (f : M →ₗ[R] M₁) (p : submodule R M) : module.rank R (p.map f) ≤ module.rank R p :=
by simpa using lift_dim_map_le f p
lemma dim_le_of_submodule (s t : submodule R M) (h : s ≤ t) :
module.rank R s ≤ module.rank R t :=
(of_le h).dim_le_of_injective $ assume ⟨x, hx⟩ ⟨y, hy⟩ eq,
subtype.eq $ show x = y, from subtype.ext_iff_val.1 eq
/-- Two linearly equivalent vector spaces have the same dimension, a version with different
universes. -/
theorem linear_equiv.lift_dim_eq (f : M ≃ₗ[R] M') :
cardinal.lift.{v'} (module.rank R M) = cardinal.lift.{v} (module.rank R M') :=
begin
apply le_antisymm,
{ exact f.to_linear_map.lift_dim_le_of_injective f.injective, },
{ exact f.symm.to_linear_map.lift_dim_le_of_injective f.symm.injective, },
end
/-- Two linearly equivalent vector spaces have the same dimension. -/
theorem linear_equiv.dim_eq (f : M ≃ₗ[R] M₁) :
module.rank R M = module.rank R M₁ :=
cardinal.lift_inj.1 f.lift_dim_eq
lemma dim_eq_of_injective (f : M →ₗ[R] M₁) (h : injective f) :
module.rank R M = module.rank R f.range :=
(linear_equiv.of_injective f h).dim_eq
/-- Pushforwards of submodules along a `linear_equiv` have the same dimension. -/
lemma linear_equiv.dim_map_eq (f : M ≃ₗ[R] M₁) (p : submodule R M) :
module.rank R (p.map (f : M →ₗ[R] M₁)) = module.rank R p :=
(f.submodule_map p).dim_eq.symm
variables (R M)
@[simp] lemma dim_top : module.rank R (⊤ : submodule R M) = module.rank R M :=
begin
have : (⊤ : submodule R M) ≃ₗ[R] M := linear_equiv.of_top ⊤ rfl,
rw this.dim_eq,
end
variables {R M}
lemma dim_range_of_surjective (f : M →ₗ[R] M') (h : surjective f) :
module.rank R f.range = module.rank R M' :=
by rw [linear_map.range_eq_top.2 h, dim_top]
lemma dim_submodule_le (s : submodule R M) : module.rank R s ≤ module.rank R M :=
begin
rw ←dim_top R M,
exact dim_le_of_submodule _ _ le_top,
end
lemma linear_map.dim_le_of_surjective (f : M →ₗ[R] M₁) (h : surjective f) :
module.rank R M₁ ≤ module.rank R M :=
begin
rw ←dim_range_of_surjective f h,
apply dim_range_le,
end
theorem dim_quotient_le (p : submodule R M) :
module.rank R (M ⧸ p) ≤ module.rank R M :=
(mkq p).dim_le_of_surjective (surjective_quot_mk _)
variables [nontrivial R]
lemma {m} cardinal_lift_le_dim_of_linear_independent
{ι : Type w} {v : ι → M} (hv : linear_independent R v) :
cardinal.lift.{max v m} (#ι) ≤ cardinal.lift.{max w m} (module.rank R M) :=
begin
apply le_trans,
{ exact cardinal.lift_mk_le.mpr
⟨(equiv.of_injective _ hv.injective).to_embedding⟩, },
{ simp only [cardinal.lift_le],
apply le_trans,
swap,
exact cardinal.le_sup _ ⟨range v, hv.coe_range⟩,
exact le_rfl, },
end
lemma cardinal_lift_le_dim_of_linear_independent'
{ι : Type w} {v : ι → M} (hv : linear_independent R v) :
cardinal.lift.{v} (#ι) ≤ cardinal.lift.{w} (module.rank R M) :=
cardinal_lift_le_dim_of_linear_independent.{u v w 0} hv
lemma cardinal_le_dim_of_linear_independent
{ι : Type v} {v : ι → M} (hv : linear_independent R v) :
#ι ≤ module.rank R M :=
by simpa using cardinal_lift_le_dim_of_linear_independent hv
lemma cardinal_le_dim_of_linear_independent'
{s : set M} (hs : linear_independent R (λ x, x : s → M)) :
#s ≤ module.rank R M :=
cardinal_le_dim_of_linear_independent hs
variables (R M)
@[simp] lemma dim_punit : module.rank R punit = 0 :=
begin
apply le_bot_iff.mp,
apply cardinal.sup_le,
rintro ⟨s, li⟩,
apply le_bot_iff.mpr,
apply cardinal.mk_emptyc_iff.mpr,
simp only [subtype.coe_mk],
by_contradiction h,
have ne : s.nonempty := ne_empty_iff_nonempty.mp h,
simpa using linear_independent.ne_zero (⟨_, ne.some_mem⟩ : s) li,
end
@[simp] lemma dim_bot : module.rank R (⊥ : submodule R M) = 0 :=
begin
have : (⊥ : submodule R M) ≃ₗ[R] punit := bot_equiv_punit,
rw [this.dim_eq, dim_punit],
end
variables {R M}
/--
Over any nontrivial ring, the existence of a finite spanning set implies that any basis is finite.
-/
-- One might hope that a finite spanning set implies that any linearly independent set is finite.
-- While this is true over a division ring
-- (simply because any linearly independent set can be extended to a basis),
-- I'm not certain what more general statements are possible.
def basis_fintype_of_finite_spans (w : set M) [fintype w] (s : span R w = ⊤)
{ι : Type w} (b : basis ι R M) : fintype ι :=
begin
-- We'll work by contradiction, assuming `ι` is infinite.
apply fintype_of_not_infinite _,
introI i,
-- Let `S` be the union of the supports of `x ∈ w` expressed as linear combinations of `b`.
-- This is a finite set since `w` is finite.
let S : finset ι := finset.univ.sup (λ x : w, (b.repr x).support),
let bS : set M := b '' S,
have h : ∀ x ∈ w, x ∈ span R bS,
{ intros x m,
rw [←b.total_repr x, finsupp.span_image_eq_map_total, submodule.mem_map],
use b.repr x,
simp only [and_true, eq_self_iff_true, finsupp.mem_supported],
change (b.repr x).support ≤ S,
convert (finset.le_sup (by simp : (⟨x, m⟩ : w) ∈ finset.univ)),
refl, },
-- Thus this finite subset of the basis elements spans the entire module.
have k : span R bS = ⊤ := eq_top_iff.2 (le_trans s.ge (span_le.2 h)),
-- Now there is some `x : ι` not in `S`, since `ι` is infinite.
obtain ⟨x, nm⟩ := infinite.exists_not_mem_finset S,
-- However it must be in the span of the finite subset,
have k' : b x ∈ span R bS, { rw k, exact mem_top, },
-- giving the desire contradiction.
refine b.linear_independent.not_mem_span_image _ k',
exact nm,
end
/--
Over any ring `R`, if `b` is a basis for a module `M`,
and `s` is a maximal linearly independent set,
then the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.
-/
-- From [Les familles libres maximales d'un module ont-elles le meme cardinal?][lazarus1973]
lemma union_support_maximal_linear_independent_eq_range_basis
{ι : Type w} (b : basis ι R M)
{κ : Type w'} (v : κ → M) (i : linear_independent R v) (m : i.maximal) :
(⋃ k, ((b.repr (v k)).support : set ι)) = univ :=
begin
-- If that's not the case,
by_contradiction h,
simp only [←ne.def, ne_univ_iff_exists_not_mem, mem_Union, not_exists_not,
finsupp.mem_support_iff, finset.mem_coe] at h,
-- We have some basis element `b b'` which is not in the support of any of the `v i`.
obtain ⟨b', w⟩ := h,
-- Using this, we'll construct a linearly independent family strictly larger than `v`,
-- by also using this `b b'`.
let v' : option κ → M := λ o, o.elim (b b') v,
have r : range v ⊆ range v',
{ rintro - ⟨k, rfl⟩,
use some k,
refl, },
have r' : b b' ∉ range v,
{ rintro ⟨k, p⟩,
simpa [w] using congr_arg (λ m, (b.repr m) b') p, },
have r'' : range v ≠ range v',
{ intro e,
have p : b b' ∈ range v', { use none, refl, },
rw ←e at p,
exact r' p, },
have inj' : injective v',
{ rintros (_|k) (_|k) z,
{ refl, },
{ exfalso, exact r' ⟨k, z.symm⟩, },
{ exfalso, exact r' ⟨k, z⟩, },
{ congr, exact i.injective z, }, },
-- The key step in the proof is checking that this strictly larger family is linearly independent.
have i' : linear_independent R (coe : range v' → M),
{ rw [linear_independent_subtype_range inj', linear_independent_iff],
intros l z,
rw [finsupp.total_option] at z,
simp only [v', option.elim] at z,
change _ + finsupp.total κ M R v l.some = 0 at z,
-- We have some linear combination of `b b'` and the `v i`, which we want to show is trivial.
-- We'll first show the coefficient of `b b'` is zero,
-- by expressing the `v i` in the basis `b`, and using that the `v i` have no `b b'` term.
have l₀ : l none = 0,
{ rw ←eq_neg_iff_add_eq_zero at z,
replace z := eq_neg_of_eq_neg z,
apply_fun (λ x, b.repr x b') at z,
simp only [repr_self, linear_equiv.map_smul, mul_one, finsupp.single_eq_same, pi.neg_apply,
finsupp.smul_single', linear_equiv.map_neg, finsupp.coe_neg] at z,
erw finsupp.congr_fun (finsupp.apply_total R (b.repr : M →ₗ[R] ι →₀ R) v l.some) b' at z,
simpa [finsupp.total_apply, w] using z, },
-- Then all the other coefficients are zero, because `v` is linear independent.
have l₁ : l.some = 0,
{ rw [l₀, zero_smul, zero_add] at z,
exact linear_independent_iff.mp i _ z, },
-- Finally we put those facts together to show the linear combination is trivial.
ext (_|a),
{ simp only [l₀, finsupp.coe_zero, pi.zero_apply], },
{ erw finsupp.congr_fun l₁ a,
simp only [finsupp.coe_zero, pi.zero_apply], }, },
dsimp [linear_independent.maximal] at m,
specialize m (range v') i' r,
exact r'' m,
end
/--
Over any ring `R`, if `b` is an infinite basis for a module `M`,
and `s` is a maximal linearly independent set,
then the cardinality of `b` is bounded by the cardinality of `s`.
-/
lemma infinite_basis_le_maximal_linear_independent'
{ι : Type w} (b : basis ι R M) [infinite ι]
{κ : Type w'} (v : κ → M) (i : linear_independent R v) (m : i.maximal) :
cardinal.lift.{w'} (#ι) ≤ cardinal.lift.{w} (#κ) :=
begin
let Φ := λ k : κ, (b.repr (v k)).support,
have w₁ : #ι ≤ #(set.range Φ),
{ apply cardinal.le_range_of_union_finset_eq_top,
exact union_support_maximal_linear_independent_eq_range_basis b v i m, },
have w₂ :
cardinal.lift.{w'} (#(set.range Φ)) ≤ cardinal.lift.{w} (#κ) :=
cardinal.mk_range_le_lift,
exact (cardinal.lift_le.mpr w₁).trans w₂,
end
/--
Over any ring `R`, if `b` is an infinite basis for a module `M`,
and `s` is a maximal linearly independent set,
then the cardinality of `b` is bounded by the cardinality of `s`.
-/
-- (See `infinite_basis_le_maximal_linear_independent'` for the more general version
-- where the index types can live in different universes.)
lemma infinite_basis_le_maximal_linear_independent
{ι : Type w} (b : basis ι R M) [infinite ι]
{κ : Type w} (v : κ → M) (i : linear_independent R v) (m : i.maximal) :
#ι ≤ #κ :=
cardinal.lift_le.mp (infinite_basis_le_maximal_linear_independent' b v i m)
lemma complete_lattice.independent.subtype_ne_bot_le_rank [no_zero_smul_divisors R M]
{V : ι → submodule R M} (hV : complete_lattice.independent V) :
cardinal.lift.{v} (#{i : ι // V i ≠ ⊥}) ≤ cardinal.lift.{w} (module.rank R M) :=
begin
set I := {i : ι // V i ≠ ⊥},
have hI : ∀ i : I, ∃ v ∈ V i, v ≠ (0:M),
{ intros i,
rw ← submodule.ne_bot_iff,
exact i.prop },
choose v hvV hv using hI,
have : linear_independent R v,
{ exact (hV.comp _ subtype.coe_injective).linear_independent _ hvV hv },
exact cardinal_lift_le_dim_of_linear_independent' this
end
end
section rank_zero
variables {R : Type u} {M : Type v}
variables [ring R] [nontrivial R] [add_comm_group M] [module R M] [no_zero_smul_divisors R M]
lemma dim_zero_iff_forall_zero : module.rank R M = 0 ↔ ∀ x : M, x = 0 :=
begin
refine ⟨λ h, _, λ h, _⟩,
{ contrapose! h,
obtain ⟨x, hx⟩ := h,
suffices : 1 ≤ module.rank R M,
{ intro h, exact lt_irrefl _ (lt_of_lt_of_le cardinal.zero_lt_one (h ▸ this)) },
suffices : linear_independent R (λ (y : ({x} : set M)), ↑y),
{ simpa using (cardinal_le_dim_of_linear_independent this), },
exact linear_independent_singleton hx },
{ have : (⊤ : submodule R M) = ⊥,
{ ext x, simp [h x] },
rw [←dim_top, this, dim_bot] }
end
lemma dim_zero_iff : module.rank R M = 0 ↔ subsingleton M :=
dim_zero_iff_forall_zero.trans (subsingleton_iff_forall_eq 0).symm
lemma dim_pos_iff_exists_ne_zero : 0 < module.rank R M ↔ ∃ x : M, x ≠ 0 :=
begin
rw ←not_iff_not,
simpa using dim_zero_iff_forall_zero
end
lemma dim_pos_iff_nontrivial : 0 < module.rank R M ↔ nontrivial M :=
dim_pos_iff_exists_ne_zero.trans (nontrivial_iff_exists_ne 0).symm
lemma dim_pos [h : nontrivial M] : 0 < module.rank R M :=
dim_pos_iff_nontrivial.2 h
end rank_zero
section invariant_basis_number
variables {R : Type u} [ring R] [invariant_basis_number R]
variables {M : Type v} [add_comm_group M] [module R M]
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : basis ι R M) (v' : basis ι' R M) :
cardinal.lift.{w'} (#ι) = cardinal.lift.{w} (#ι') :=
begin
haveI := nontrivial_of_invariant_basis_number R,
by_cases h : #ι < ℵ₀,
{ -- `v` is a finite basis, so by `basis_fintype_of_finite_spans` so is `v'`.
haveI : fintype ι := (cardinal.lt_aleph_0_iff_fintype.mp h).some,
haveI : fintype (range v) := set.fintype_range ⇑v,
haveI := basis_fintype_of_finite_spans _ v.span_eq v',
-- We clean up a little:
rw [cardinal.mk_fintype, cardinal.mk_fintype],
simp only [cardinal.lift_nat_cast, cardinal.nat_cast_inj],
-- Now we can use invariant basis number to show they have the same cardinality.
apply card_eq_of_lequiv R,
exact (((finsupp.linear_equiv_fun_on_fintype R R ι).symm.trans v.repr.symm) ≪≫ₗ
v'.repr) ≪≫ₗ (finsupp.linear_equiv_fun_on_fintype R R ι'), },
{ -- `v` is an infinite basis,
-- so by `infinite_basis_le_maximal_linear_independent`, `v'` is at least as big,
-- and then applying `infinite_basis_le_maximal_linear_independent` again
-- we see they have the same cardinality.
simp only [not_lt] at h,
haveI : infinite ι := cardinal.infinite_iff.mpr h,
have w₁ :=
infinite_basis_le_maximal_linear_independent' v _ v'.linear_independent v'.maximal,
haveI : infinite ι' := cardinal.infinite_iff.mpr (begin
apply cardinal.lift_le.{w' w}.mp,
have p := (cardinal.lift_le.mpr h).trans w₁,
rw cardinal.lift_aleph_0 at ⊢ p,
exact p,
end),
have w₂ :=
infinite_basis_le_maximal_linear_independent' v' _ v.linear_independent v.maximal,
exact le_antisymm w₁ w₂, }
end
/-- Given two bases indexed by `ι` and `ι'` of an `R`-module, where `R` satisfies the invariant
basis number property, an equiv `ι ≃ ι' `. -/
def basis.index_equiv (v : basis ι R M) (v' : basis ι' R M) : ι ≃ ι' :=
nonempty.some (cardinal.lift_mk_eq.1 (cardinal.lift_umax_eq.2 (mk_eq_mk_of_basis v v')))
theorem mk_eq_mk_of_basis' {ι' : Type w} (v : basis ι R M) (v' : basis ι' R M) :
#ι = #ι' :=
cardinal.lift_inj.1 $ mk_eq_mk_of_basis v v'
end invariant_basis_number
section rank_condition
variables {R : Type u} [ring R] [rank_condition R]
variables {M : Type v} [add_comm_group M] [module R M]
/--
An auxiliary lemma for `basis.le_span`.
If `R` satisfies the rank condition,
then for any finite basis `b : basis ι R M`,
and any finite spanning set `w : set M`,
the cardinality of `ι` is bounded by the cardinality of `w`.
-/
lemma basis.le_span'' {ι : Type*} [fintype ι] (b : basis ι R M)
{w : set M} [fintype w] (s : span R w = ⊤) :
fintype.card ι ≤ fintype.card w :=
begin
-- We construct an surjective linear map `(w → R) →ₗ[R] (ι → R)`,
-- by expressing a linear combination in `w` as a linear combination in `ι`.
fapply card_le_of_surjective' R,
{ exact b.repr.to_linear_map.comp (finsupp.total w M R coe), },
{ apply surjective.comp,
apply linear_equiv.surjective,
rw [←linear_map.range_eq_top, finsupp.range_total],
simpa using s, },
end
/--
Another auxiliary lemma for `basis.le_span`, which does not require assuming the basis is finite,
but still assumes we have a finite spanning set.
-/
lemma basis_le_span' {ι : Type*} (b : basis ι R M)
{w : set M} [fintype w] (s : span R w = ⊤) :
#ι ≤ fintype.card w :=
begin
haveI := nontrivial_of_invariant_basis_number R,
haveI := basis_fintype_of_finite_spans w s b,
rw cardinal.mk_fintype ι,
simp only [cardinal.nat_cast_le],
exact basis.le_span'' b s,
end
/--
If `R` satisfies the rank condition,
then the cardinality of any basis is bounded by the cardinality of any spanning set.
-/
-- Note that if `R` satisfies the strong rank condition,
-- this also follows from `linear_independent_le_span` below.
theorem basis.le_span {J : set M} (v : basis ι R M)
(hJ : span R J = ⊤) : #(range v) ≤ #J :=
begin
haveI := nontrivial_of_invariant_basis_number R,
casesI fintype_or_infinite J,
{ rw [←cardinal.lift_le, cardinal.mk_range_eq_of_injective v.injective, cardinal.mk_fintype J],
convert cardinal.lift_le.{w v}.2 (basis_le_span' v hJ),
simp, },
{ have := cardinal.mk_range_eq_of_injective v.injective,
let S : J → set ι := λ j, ↑(v.repr j).support,
let S' : J → set M := λ j, v '' S j,
have hs : range v ⊆ ⋃ j, S' j,
{ intros b hb,
rcases mem_range.1 hb with ⟨i, hi⟩,
have : span R J ≤ comap v.repr.to_linear_map (finsupp.supported R R (⋃ j, S j)) :=
span_le.2 (λ j hj x hx, ⟨_, ⟨⟨j, hj⟩, rfl⟩, hx⟩),
rw hJ at this,
replace : v.repr (v i) ∈ (finsupp.supported R R (⋃ j, S j)) := this trivial,
rw [v.repr_self, finsupp.mem_supported,
finsupp.support_single_ne_zero _ one_ne_zero] at this,
{ subst b,
rcases mem_Union.1 (this (finset.mem_singleton_self _)) with ⟨j, hj⟩,
exact mem_Union.2 ⟨j, (mem_image _ _ _).2 ⟨i, hj, rfl⟩⟩ },
{ apply_instance } },
refine le_of_not_lt (λ IJ, _),
suffices : #(⋃ j, S' j) < #(range v),
{ exact not_le_of_lt this ⟨set.embedding_of_subset _ _ hs⟩ },
refine lt_of_le_of_lt (le_trans cardinal.mk_Union_le_sum_mk
(cardinal.sum_le_sum _ (λ _, ℵ₀) _)) _,
{ exact λ j, le_of_lt (cardinal.lt_aleph_0_iff_finite.2 $ (finset.finite_to_set _).image _) },
{ simpa } },
end
end rank_condition
section strong_rank_condition
variables {R : Type u} [ring R] [strong_rank_condition R]
variables {M : Type v} [add_comm_group M] [module R M]
open submodule
-- An auxiliary lemma for `linear_independent_le_span'`,
-- with the additional assumption that the linearly independent family is finite.
lemma linear_independent_le_span_aux'
{ι : Type*} [fintype ι] (v : ι → M) (i : linear_independent R v)
(w : set M) [fintype w] (s : range v ≤ span R w) :
fintype.card ι ≤ fintype.card w :=
begin
-- 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 λ i, span.repr R w ⟨v i, s (mem_range_self i)⟩, },
{ intros f g h,
apply_fun finsupp.total w M R coe at h,
simp only [finsupp.total_total, submodule.coe_mk, span.finsupp_total_repr] at h,
rw [←sub_eq_zero, ←linear_map.map_sub] at h,
exact sub_eq_zero.mp (linear_independent_iff.mp i _ h), },
end
/--
If `R` satisfies the strong rank condition,
then any linearly independent family `v : ι → M`
contained in the span of some finite `w : set M`,
is itself finite.
-/
def linear_independent_fintype_of_le_span_fintype
{ι : Type*} (v : ι → M) (i : linear_independent R v)
(w : set M) [fintype w] (s : range v ≤ span R w) : fintype ι :=
fintype_of_finset_card_le (fintype.card w) (λ t, begin
let v' := λ x : (t : set ι), v x,
have i' : linear_independent R v' := i.comp _ subtype.val_injective,
have s' : range v' ≤ span R w := (range_comp_subset_range _ _).trans s,
simpa using linear_independent_le_span_aux' v' i' w s',
end)
/--
If `R` satisfies the strong rank condition,
then for any linearly independent family `v : ι → M`
contained in the span of some finite `w : set M`,
the cardinality of `ι` is bounded by the cardinality of `w`.
-/
lemma linear_independent_le_span' {ι : Type*} (v : ι → M) (i : linear_independent R v)
(w : set M) [fintype w] (s : range v ≤ span R w) :
#ι ≤ fintype.card w :=
begin
haveI : fintype ι := linear_independent_fintype_of_le_span_fintype v i w s,
rw cardinal.mk_fintype,
simp only [cardinal.nat_cast_le],
exact linear_independent_le_span_aux' v i w s,
end
/--
If `R` satisfies the strong rank condition,
then for any linearly independent family `v : ι → M`
and any finite spanning set `w : set M`,
the cardinality of `ι` is bounded by the cardinality of `w`.
-/
lemma linear_independent_le_span {ι : Type*} (v : ι → M) (i : linear_independent R v)
(w : set M) [fintype w] (s : span R w = ⊤) :
#ι ≤ fintype.card w :=
begin
apply linear_independent_le_span' v i w,
rw s,
exact le_top,
end
/-- A linearly-independent family of vectors in a module over a ring satisfying the strong rank
condition must be finite if the module is Noetherian. -/
noncomputable def fintype_of_is_noetherian_linear_independent [is_noetherian R M]
{v : ι → M} (hi : linear_independent R v) : fintype ι :=
begin
have hfg : (⊤ : submodule R M).fg,
{ exact is_noetherian_def.mp infer_instance ⊤, },
rw submodule.fg_def at hfg,
choose s hs hs' using hfg,
haveI : fintype s := hs.fintype,
apply linear_independent_fintype_of_le_span_fintype v hi s,
simp only [hs', set.subset_univ, submodule.top_coe, set.le_eq_subset],
end
/-- A linearly-independent subset of a module over a ring satisfying the strong rank condition
must be finite if the module is Noetherian. -/
lemma finite_of_is_noetherian_linear_independent [is_noetherian R M]
{s : set M} (hi : linear_independent R (coe : s → M)) : s.finite :=
⟨fintype_of_is_noetherian_linear_independent hi⟩
/--
An auxiliary lemma for `linear_independent_le_basis`:
we handle the case where the basis `b` is infinite.
-/
lemma linear_independent_le_infinite_basis
{ι : Type*} (b : basis ι R M) [infinite ι]
{κ : Type*} (v : κ → M) (i : linear_independent R v) :
#κ ≤ #ι :=
begin
by_contradiction,
rw [not_le, ← cardinal.mk_finset_eq_mk ι] at h,
let Φ := λ k : κ, (b.repr (v k)).support,
obtain ⟨s, w : infinite ↥(Φ ⁻¹' {s})⟩ := cardinal.exists_infinite_fiber Φ h (by apply_instance),
let v' := λ k : Φ ⁻¹' {s}, v k,
have i' : linear_independent R v' := i.comp _ subtype.val_injective,
have w' : fintype (Φ ⁻¹' {s}),
{ apply linear_independent_fintype_of_le_span_fintype v' i' (s.image b),
rintros m ⟨⟨p,⟨rfl⟩⟩,rfl⟩,
simp only [set_like.mem_coe, subtype.coe_mk, finset.coe_image],
apply basis.mem_span_repr_support, },
exactI w.false,
end
/--
Over any ring `R` satisfying the strong rank condition,
if `b` is a basis for a module `M`,
and `s` is a linearly independent set,
then the cardinality of `s` is bounded by the cardinality of `b`.
-/
lemma linear_independent_le_basis
{ι : Type*} (b : basis ι R M)
{κ : Type*} (v : κ → M) (i : linear_independent R v) :
#κ ≤ #ι :=
begin
-- We split into cases depending on whether `ι` is infinite.
cases fintype_or_infinite ι; resetI,
{ -- When `ι` is finite, we have `linear_independent_le_span`,
rw cardinal.mk_fintype ι,
haveI : nontrivial R := nontrivial_of_invariant_basis_number R,
rw fintype.card_congr (equiv.of_injective b b.injective),
exact linear_independent_le_span v i (range b) b.span_eq, },
{ -- and otherwise we have `linear_indepedent_le_infinite_basis`.
exact linear_independent_le_infinite_basis b v i, },
end
/-- In an `n`-dimensional space, the rank is at most `m`. -/
lemma basis.card_le_card_of_linear_independent_aux
{R : Type*} [ring R] [strong_rank_condition R]
(n : ℕ) {m : ℕ} (v : fin m → fin n → R) :
linear_independent R v → m ≤ n :=
λ h, by simpa using (linear_independent_le_basis (pi.basis_fun R (fin n)) v h)
/--
Over any ring `R` satisfying the strong rank condition,
if `b` is an infinite basis for a module `M`,
then every maximal linearly independent set has the same cardinality as `b`.
This proof (along with some of the lemmas above) comes from
[Les familles libres maximales d'un module ont-elles le meme cardinal?][lazarus1973]
-/
-- When the basis is not infinite this need not be true!
lemma maximal_linear_independent_eq_infinite_basis
{ι : Type*} (b : basis ι R M) [infinite ι]
{κ : Type*} (v : κ → M) (i : linear_independent R v) (m : i.maximal) :
#κ = #ι :=
begin
apply le_antisymm,
{ exact linear_independent_le_basis b v i, },
{ haveI : nontrivial R := nontrivial_of_invariant_basis_number R,
exact infinite_basis_le_maximal_linear_independent b v i m, }
end
theorem basis.mk_eq_dim'' {ι : Type v} (v : basis ι R M) :
#ι = module.rank R M :=
begin
haveI := nontrivial_of_invariant_basis_number R,
apply le_antisymm,
{ transitivity,
swap,
apply cardinal.le_sup,
exact ⟨set.range v, by { convert v.reindex_range.linear_independent, ext, simp }⟩,
exact (cardinal.mk_range_eq v v.injective).ge, },
{ apply cardinal.sup_le,
rintro ⟨s, li⟩,
apply linear_independent_le_basis v _ li, },
end
-- By this stage we want to have a complete API for `module.rank`,
-- so we set it `irreducible` here, to keep ourselves honest.
attribute [irreducible] module.rank
theorem basis.mk_range_eq_dim (v : basis ι R M) :
#(range v) = module.rank R M :=
v.reindex_range.mk_eq_dim''
/-- If a vector space has a finite basis, then its dimension (seen as a cardinal) is equal to the
cardinality of the basis. -/
lemma dim_eq_card_basis {ι : Type w} [fintype ι] (h : basis ι R M) :
module.rank R M = fintype.card ι :=
by {haveI := nontrivial_of_invariant_basis_number R,
rw [←h.mk_range_eq_dim, cardinal.mk_fintype, set.card_range_of_injective h.injective] }
lemma basis.card_le_card_of_linear_independent {ι : Type*} [fintype ι]
(b : basis ι R M) {ι' : Type*} [fintype ι'] {v : ι' → M} (hv : linear_independent R v) :
fintype.card ι' ≤ fintype.card ι :=
begin
letI := nontrivial_of_invariant_basis_number R,
simpa [dim_eq_card_basis b, cardinal.mk_fintype] using
cardinal_lift_le_dim_of_linear_independent' hv
end
lemma basis.card_le_card_of_submodule (N : submodule R M) [fintype ι] (b : basis ι R M)
[fintype ι'] (b' : basis ι' R N) : fintype.card ι' ≤ fintype.card ι :=
b.card_le_card_of_linear_independent (b'.linear_independent.map' N.subtype N.ker_subtype)
lemma basis.card_le_card_of_le
{N O : submodule R M} (hNO : N ≤ O) [fintype ι] (b : basis ι R O) [fintype ι']
(b' : basis ι' R N) : fintype.card ι' ≤ fintype.card ι :=
b.card_le_card_of_linear_independent
(b'.linear_independent.map' (submodule.of_le hNO) (N.ker_of_le O _))
theorem basis.mk_eq_dim (v : basis ι R M) :
cardinal.lift.{v} (#ι) = cardinal.lift.{w} (module.rank R M) :=
begin
haveI := nontrivial_of_invariant_basis_number R,
rw [←v.mk_range_eq_dim, cardinal.mk_range_eq_of_injective v.injective]
end
theorem {m} basis.mk_eq_dim' (v : basis ι R M) :
cardinal.lift.{max v m} (#ι) = cardinal.lift.{max w m} (module.rank R M) :=
by simpa using v.mk_eq_dim
/-- If a module has a finite dimension, all bases are indexed by a finite type. -/
lemma basis.nonempty_fintype_index_of_dim_lt_aleph_0 {ι : Type*}
(b : basis ι R M) (h : module.rank R M < ℵ₀) :
nonempty (fintype ι) :=
by rwa [← cardinal.lift_lt, ← b.mk_eq_dim,
-- ensure `aleph_0` has the correct universe
cardinal.lift_aleph_0, ← cardinal.lift_aleph_0.{u_1 v},
cardinal.lift_lt, cardinal.lt_aleph_0_iff_fintype] at h
/-- If a module has a finite dimension, all bases are indexed by a finite type. -/
noncomputable def basis.fintype_index_of_dim_lt_aleph_0 {ι : Type*}
(b : basis ι R M) (h : module.rank R M < ℵ₀) :
fintype ι :=
classical.choice (b.nonempty_fintype_index_of_dim_lt_aleph_0 h)
/-- If a module has a finite dimension, all bases are indexed by a finite set. -/
lemma basis.finite_index_of_dim_lt_aleph_0 {ι : Type*} {s : set ι}
(b : basis s R M) (h : module.rank R M < ℵ₀) :
s.finite :=
finite_def.2 (b.nonempty_fintype_index_of_dim_lt_aleph_0 h)
lemma dim_span {v : ι → M} (hv : linear_independent R v) :
module.rank R ↥(span R (range v)) = #(range v) :=
begin
haveI := nontrivial_of_invariant_basis_number R,
rw [←cardinal.lift_inj, ← (basis.span hv).mk_eq_dim,
cardinal.mk_range_eq_of_injective (@linear_independent.injective ι R M v _ _ _ _ hv)]
end
lemma dim_span_set {s : set M} (hs : linear_independent R (λ x, x : s → M)) :
module.rank R ↥(span R s) = #s :=
by { rw [← @set_of_mem_eq _ s, ← subtype.range_coe_subtype], exact dim_span hs }
/-- If `N` is a submodule in a free, finitely generated module,
do induction on adjoining a linear independent element to a submodule. -/
def submodule.induction_on_rank [is_domain R] [fintype ι] (b : basis ι R M)
(P : submodule R M → Sort*) (ih : ∀ (N : submodule R M),
(∀ (N' ≤ N) (x ∈ N), (∀ (c : R) (y ∈ N'), c • x + y = (0 : M) → c = 0) → P N') →
P N)
(N : submodule R M) : P N :=
submodule.induction_on_rank_aux b P ih (fintype.card ι) N (λ s hs hli,
by simpa using b.card_le_card_of_linear_independent hli)
/-- If `S` a finite-dimensional ring extension of `R` which is free as an `R`-module,
then the rank of an ideal `I` of `S` over `R` is the same as the rank of `S`.
-/
lemma ideal.rank_eq {R S : Type*} [comm_ring R] [strong_rank_condition R] [ring S] [is_domain S]
[algebra R S] {n m : Type*} [fintype n] [fintype m]
(b : basis n R S) {I : ideal S} (hI : I ≠ ⊥) (c : basis m R I) :
fintype.card m = fintype.card n :=
begin
obtain ⟨a, ha⟩ := submodule.nonzero_mem_of_bot_lt (bot_lt_iff_ne_bot.mpr hI),
have : linear_independent R (λ i, b i • a),
{ have hb := b.linear_independent,
rw fintype.linear_independent_iff at ⊢ hb,
intros g hg,
apply hb g,
simp only [← smul_assoc, ← finset.sum_smul, smul_eq_zero] at hg,
exact hg.resolve_right ha },
exact le_antisymm
(b.card_le_card_of_linear_independent (c.linear_independent.map' (submodule.subtype I)
(linear_map.ker_eq_bot.mpr subtype.coe_injective)))
(c.card_le_card_of_linear_independent this),
end
variables (R)
@[simp] lemma dim_self : module.rank R R = 1 :=
by rw [←cardinal.lift_inj, ← (basis.singleton punit R).mk_eq_dim, cardinal.mk_punit]
end strong_rank_condition
section division_ring
variables [division_ring K] [add_comm_group V] [module K V] [add_comm_group V₁] [module K V₁]
variables {K V}
/-- If a vector space has a finite dimension, the index set of `basis.of_vector_space` is finite. -/
lemma basis.finite_of_vector_space_index_of_dim_lt_aleph_0 (h : module.rank K V < ℵ₀) :
(basis.of_vector_space_index K V).finite :=
finite_def.2 $ (basis.of_vector_space K V).nonempty_fintype_index_of_dim_lt_aleph_0 h
variables [add_comm_group V'] [module K V']
/-- Two vector spaces are isomorphic if they have the same dimension. -/
theorem nonempty_linear_equiv_of_lift_dim_eq
(cond : cardinal.lift.{v'} (module.rank K V) = cardinal.lift.{v} (module.rank K V')) :
nonempty (V ≃ₗ[K] V') :=
begin
let B := basis.of_vector_space K V,
let B' := basis.of_vector_space K V',
have : cardinal.lift.{v' v} (#_) = cardinal.lift.{v v'} (#_),
by rw [B.mk_eq_dim'', cond, B'.mk_eq_dim''],
exact (cardinal.lift_mk_eq.{v v' 0}.1 this).map (B.equiv B')
end
/-- Two vector spaces are isomorphic if they have the same dimension. -/
theorem nonempty_linear_equiv_of_dim_eq (cond : module.rank K V = module.rank K V₁) :
nonempty (V ≃ₗ[K] V₁) :=
nonempty_linear_equiv_of_lift_dim_eq $ congr_arg _ cond
section
variables (V V' V₁)
/-- Two vector spaces are isomorphic if they have the same dimension. -/
def linear_equiv.of_lift_dim_eq
(cond : cardinal.lift.{v'} (module.rank K V) = cardinal.lift.{v} (module.rank K V')) :
V ≃ₗ[K] V' :=
classical.choice (nonempty_linear_equiv_of_lift_dim_eq cond)
/-- Two vector spaces are isomorphic if they have the same dimension. -/
def linear_equiv.of_dim_eq (cond : module.rank K V = module.rank K V₁) : V ≃ₗ[K] V₁ :=
classical.choice (nonempty_linear_equiv_of_dim_eq cond)
end
/-- Two vector spaces are isomorphic if and only if they have the same dimension. -/
theorem linear_equiv.nonempty_equiv_iff_lift_dim_eq :
nonempty (V ≃ₗ[K] V') ↔
cardinal.lift.{v'} (module.rank K V) = cardinal.lift.{v} (module.rank K V') :=
⟨λ ⟨h⟩, linear_equiv.lift_dim_eq h, λ h, nonempty_linear_equiv_of_lift_dim_eq h⟩
/-- Two vector spaces are isomorphic if and only if they have the same dimension. -/
theorem linear_equiv.nonempty_equiv_iff_dim_eq :
nonempty (V ≃ₗ[K] V₁) ↔ module.rank K V = module.rank K V₁ :=
⟨λ ⟨h⟩, linear_equiv.dim_eq h, λ h, nonempty_linear_equiv_of_dim_eq h⟩
-- TODO how far can we generalise this?
-- When `s` is finite, we could prove this for any ring satisfying the strong rank condition
-- using `linear_independent_le_span'`
lemma dim_span_le (s : set V) : module.rank K (span K s) ≤ #s :=
begin
obtain ⟨b, hb, hsab, hlib⟩ := exists_linear_independent K s,
convert cardinal.mk_le_mk_of_subset hb,
rw [← hsab, dim_span_set hlib]
end
lemma dim_span_of_finset (s : finset V) :
module.rank K (span K (↑s : set V)) < ℵ₀ :=
calc module.rank K (span K (↑s : set V)) ≤ #(↑s : set V) : dim_span_le ↑s
... = s.card : by rw [finset.coe_sort_coe, cardinal.mk_finset]
... < ℵ₀ : cardinal.nat_lt_aleph_0 _
theorem dim_prod : module.rank K (V × V₁) = module.rank K V + module.rank K V₁ :=
begin
let b := basis.of_vector_space K V,
let c := basis.of_vector_space K V₁,
rw [← cardinal.lift_inj,
← (basis.prod b c).mk_eq_dim,
cardinal.lift_add, ← cardinal.mk_ulift,
← b.mk_eq_dim, ← c.mk_eq_dim,
← cardinal.mk_ulift, ← cardinal.mk_ulift,
cardinal.add_def (ulift _)],
exact cardinal.lift_inj.1 (cardinal.lift_mk_eq.2
⟨equiv.ulift.trans (equiv.sum_congr equiv.ulift equiv.ulift).symm ⟩),
end