-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtensor_product.lean
1574 lines (1394 loc) · 57.1 KB
/
tensor_product.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
import algebra.group_power algebra.linear_algebra.prod_module algebra.module
import data.finsupp data.set.basic tactic.ring
noncomputable theory
universes u u₁ v v₁ w w₁
open classical set function
local attribute [instance] decidable_inhabited prop_decidable
namespace prod
@[simp] lemma prod_add_prod {α : Type u} {β : Type v} {γ : Type w}
[comm_ring α] [module α β] [module α γ] (x₁ x₂ : β) (y₁ y₂ : γ) :
(x₁, y₁) + (x₂, y₂) = (x₁ + x₂, y₁ + y₂) := rfl
@[simp] lemma smul_prod {α : Type u} {β : Type v} {γ : Type w}
[comm_ring α] [module α β] [module α γ] (r : α) (x : β) (y : γ) :
r • (x, y) = (r • x, r • y) := rfl
@[simp] lemma fst_smul {α : Type u} {β : Type v} {γ : Type w}
[comm_ring α] [module α β] [module α γ] (r : α) (z : β × γ) :
(r • z).fst = r • z.fst := rfl
@[simp] lemma snd_smul {α : Type u} {β : Type v} {γ : Type w}
[comm_ring α] [module α β] [module α γ] (r : α) (z : β × γ) :
(r • z).snd = r • z.snd := rfl
end prod
class type_singleton (α : Type u) : Type u :=
(default : α)
(unique : ∀ x : α, x = default)
namespace type_singleton
variables (α : Type u) [type_singleton α]
variables (β : Type v) [type_singleton β]
def equiv_unit : equiv α unit :=
{ to_fun := λ x, unit.star,
inv_fun := λ x, type_singleton.default α,
left_inv := λ x, by rw type_singleton.unique x,
right_inv := λ x, unit.cases_on x rfl }
def equiv_singleton : equiv α β :=
{ to_fun := λ x, type_singleton.default β,
inv_fun := λ x, type_singleton.default α,
left_inv := λ x, by rw type_singleton.unique x,
right_inv := λ x, by rw type_singleton.unique x }
end type_singleton
@[simp] lemma quotient.lift_beta {α : Sort u} {β : Sort v} [s : setoid α] (f : α → β) (h : ∀ (a b : α), a ≈ b → f a = f b) (x : α):
quotient.lift f h (quotient.mk x) = f x := rfl
@[simp] lemma quotient.lift_on_beta {α : Sort u} {β : Sort v} [s : setoid α] (f : α → β) (h : ∀ (a b : α), a ≈ b → f a = f b) (x : α):
quotient.lift_on (quotient.mk x) f h = f x := rfl
section bilinear
variables {α : Type u} [comm_ring α]
include α
variables {β : Type v} {γ : Type w} {α₁ : Type u₁} {β₁ : Type v₁}
variables [module α β] [module α γ] [module α α₁] [module α β₁]
structure is_bilinear_map {β γ α₁}
[module α β] [module α γ] [module α α₁]
(f : β → γ → α₁) : Prop :=
(add_pair : ∀ x y z, f (x + y) z = f x z + f y z)
(pair_add : ∀ x y z, f x (y + z) = f x y + f x z)
(smul_pair : ∀ r x y, f (r • x) y = r • f x y)
(pair_smul : ∀ r x y, f x (r • y) = r • f x y)
variables {f : β → γ → α₁} (hf : is_bilinear_map f)
include hf
theorem is_bilinear_map.zero_pair : ∀ y, f 0 y = 0 :=
λ y, calc f 0 y
= f (0 + 0) y - f 0 y : by rw [hf.add_pair 0 0 y]; simp
... = 0 : by simp
theorem is_bilinear_map.pair_zero : ∀ x, f x 0 = 0 :=
λ x, calc f x 0
= f x (0 + 0) - f x 0 : by rw [hf.pair_add x 0 0]; simp
... = 0 : by simp
theorem is_bilinear_map.linear_pair (y : γ) : is_linear_map (λ x, f x y) :=
{ add := λ m n, hf.add_pair m n y,
smul := λ r m, hf.smul_pair r m y }
theorem is_bilinear_map.pair_linear (x : β) : is_linear_map (λ y, f x y) :=
{ add := λ m n, hf.pair_add x m n,
smul := λ r m, hf.pair_smul r x m }
variables {g : α₁ → β₁} (hg : is_linear_map g)
include hg
theorem is_bilinear_map.comp : is_bilinear_map (λ x y, g (f x y)) :=
{ add_pair := λ x y z, by rw [hf.add_pair, hg.add],
pair_add := λ x y z, by rw [hf.pair_add, hg.add],
smul_pair := λ r x y, by rw [hf.smul_pair, hg.smul],
pair_smul := λ r x y, by rw [hf.pair_smul, hg.smul] }
omit hf hg
variables (β γ)
structure module_iso (β γ) [module α β] [module α γ] extends equiv β γ :=
( linear : is_linear_map to_fun )
end bilinear
infix ` ≃ₘ `:25 := module_iso
namespace module_iso
variables (α : Type u) [comm_ring α]
variables (β : Type v) (γ : Type w) (α₁ : Type u₁) [module α β] [module α γ] [module α α₁]
variables {α β γ α₁}
include α
protected def refl : β ≃ₘ β :=
{ linear := is_linear_map.id
..equiv.refl β }
protected def symm (hbc : β ≃ₘ γ) : γ ≃ₘ β :=
{ linear := is_linear_map.inverse hbc.linear hbc.left_inv hbc.right_inv
..equiv.symm hbc.to_equiv }
protected def trans : β ≃ₘ γ → γ ≃ₘ α₁ → β ≃ₘ α₁ :=
λ hbc hca,
{ linear := is_linear_map.comp hca.linear hbc.linear
..equiv.trans hbc.to_equiv hca.to_equiv }
end module_iso
theorem gsmul_sub (α : Type u) [add_group α] (a : α) :
∀ i j : int, gsmul a (i - j) = gsmul a i - gsmul a j :=
begin
intros i j,
rw sub_eq_add_neg,
rw sub_eq_add_neg,
rw gsmul_add,
rw gsmul_neg
end
theorem add_gsmul (α : Type u) [add_comm_group α] (a b : α) : ∀ n, gsmul (a + b) n = gsmul a n + gsmul b n :=
begin
intro n,
induction n,
{ rw ← int.coe_nat_eq,
rw smul_coe_nat,
rw smul_coe_nat,
rw smul_coe_nat,
rw add_monoid.add_smul },
{ rw int.neg_succ_of_nat_eq,
rw gsmul_neg,
rw gsmul_neg,
rw gsmul_neg,
rw gsmul_add,
rw gsmul_add,
rw gsmul_add,
rw smul_coe_nat,
rw smul_coe_nat,
rw smul_coe_nat,
rw add_monoid.add_smul,
simp }
end
theorem sub_gsmul (α : Type u) [add_comm_group α] (a b : α) : ∀ n, gsmul (a - b) n = gsmul a n - gsmul b n :=
begin
intro n,
rw sub_eq_add_neg,
rw sub_eq_add_neg,
rw add_gsmul,
rw neg_gsmul
end
theorem gsmul_smul (α : Type u) (β : Type v) [ring α] [module α β] (r : α) (x : β) :
∀ n:ℤ, gsmul (r • x) n = r • gsmul x n :=
begin
intro n,
cases n,
{ induction n with n ih,
{ simp },
{ rw nat.succ_eq_add_one,
rw int.of_nat_add,
simp [gsmul_add] at ih ⊢,
rw ih,
rw smul_add } },
{ rw int.neg_succ_of_nat_eq,
rw gsmul_neg,
rw gsmul_neg,
rw gsmul_add,
induction n with n ih,
{ simp [gsmul_one] },
{ simpa [gsmul_add, ih, smul_add] using ih } }
end
namespace multiset
variable {α : Type u}
@[simp] theorem map_id (s : multiset α) : map id s = s :=
quot.induction_on s $ λ l, congr_arg coe $ list.map_id _
end multiset
namespace list
theorem map_neg {α : Type u} [add_comm_group α] :
∀ L:list α, (L.map (λ x, -x)).sum = -L.sum
| [] := by simp
| (h::t) := by simp [map_neg t]
theorem sum_singleton {α : Type u} [add_group α] {x : α} :
list.sum [x] = x :=
calc list.sum [x] = x + list.sum [] : list.sum_cons
... = x + 0 : congr_arg _ list.sum_nil
... = x : add_zero x
end list
namespace finsupp
variables {α : Type u} {β : Type v} [add_comm_group β] {a : α} {b b₁ b₂ : β}
variables {α₁ : Type u₁}
variables {γ : Type w} [add_comm_group γ]
@[simp] lemma single_neg : single a (-b) = -single a b :=
ext $ assume a',
begin
by_cases h : a = a',
{ rw [h, neg_apply, single_eq_same, single_eq_same] },
{ rw [neg_apply, single_eq_of_ne h, single_eq_of_ne h, neg_zero] }
end
@[simp] lemma single_sub : single a (b₁ - b₂) = single a b₁ - single a b₂ :=
by simp
theorem sum_neg_index' {g : α →₀ β} {h : α → β → γ}:
(∀ (a : α) (b₁ b₂ : β), h a (b₁ - b₂) = h a b₁ - h a b₂) → finsupp.sum (-g) h = -finsupp.sum g h :=
begin
intro H,
rw ← zero_sub,
rw sum_sub_index H,
rw sum_zero_index,
rw zero_sub
end
@[simp] theorem finsum_apply {S : finset α₁} {f : α₁ → α →₀ β} {z : α} :
(S.sum f) z = S.sum (λ x, f x z) :=
eq.symm $ finset.sum_hom (λ g : α →₀ β, g z) rfl (λ x y, rfl)
end finsupp
namespace tensor_product
variables (α : Type u) [comm_ring α]
variables (β : Type v) (γ : Type w) (α₁ : Type u₁) (β₁ : Type v₁) (γ₁ : Type w₁)
variables [module α β] [module α γ] [module α α₁] [module α β₁] [module α γ₁]
def free_abelian_group : Type (max v w) := β × γ →₀ ℤ
instance free_abelian_group.has_coe_to_fun : has_coe_to_fun (free_abelian_group β γ) :=
finsupp.has_coe_to_fun
instance free_abelian_group.add_comm_monoid : add_comm_monoid (free_abelian_group β γ) :=
finsupp.add_comm_monoid
instance free_abelian_group.add_comm_group : add_comm_group (free_abelian_group β γ) :=
finsupp.add_comm_group
theorem structural_theorem (f : free_abelian_group β γ) :
∃ S : finset (free_abelian_group β γ), (∀ g ∈ S, ∃ (x : β) (y : γ) (n : ℤ) (H : n ≠ 0), g = finsupp.single (x, y) n) ∧ S.sum id = f :=
begin
rcases f with ⟨f, ⟨hf⟩⟩,
cases hf with S hs,
existsi S.image (λ z, finsupp.single z.val $ f z.val : {a : β × γ | f a ≠ 0} → free_abelian_group β γ),
split,
{ intros g hg,
rw finset.mem_image at hg,
rcases hg with ⟨z, hzs, hg⟩,
cases z with z hz,
cases z with x y,
exact ⟨x, y, f (x, y), hz, by simp [hg]⟩ },
{ rw finset.sum_image,
{ apply finsupp.ext,
intro z,
by_cases hz : f z = 0,
{ simp,
rw ← finset.sum_subset (finset.empty_subset S),
{ simpa using hz.symm },
{ intros x hx hnx,
rw id,
rw finsupp.single_apply,
have h2 : ¬x.val = z := λ hxz, x.property (by rwa hxz),
rw if_neg h2 } },
{ simp,
have h1 : finset.singleton (⟨z, hz⟩ : {a : β × γ | f a ≠ 0}) ⊆ S := λ x hx, hs x,
rw ← finset.sum_subset h1,
{ rw finset.sum_singleton,
rw id,
rw finsupp.single_apply,
rw if_pos rfl,
refl },
{ intros x hx hnxz,
rw finset.mem_singleton at hnxz,
rw id,
rw finsupp.single_apply,
have h2 : ¬x.val = z := λ hxz, hnxz (subtype.eq hxz),
rw if_neg h2 } } },
{ intros x hx y hy hxy,
by_contradiction hnxy,
have hxyx : @@coe_fn (free_abelian_group.has_coe_to_fun β γ) (finsupp.single x.val (f x.val)) x.val
= @@coe_fn (free_abelian_group.has_coe_to_fun β γ) (finsupp.single y.val (f y.val)) x.val := by rw hxy,
rw finsupp.single_apply at hxyx,
rw finsupp.single_apply at hxyx,
rw if_pos rfl at hxyx,
have h1 : ¬y.val = x.val := λ hyx, hnxy (subtype.eq hyx.symm),
rw if_neg h1 at hxyx,
exact x.property hxyx } }
end
variables α {β γ}
include α
namespace relators
def pair_add : β → γ → γ → ℤ → free_abelian_group β γ :=
λ x y₁ y₂ n, finsupp.single (x, y₁) n + finsupp.single (x, y₂) n - finsupp.single (x, y₁ + y₂) n
def add_pair : β → β → γ → ℤ → free_abelian_group β γ :=
λ x₁ x₂ y n, finsupp.single (x₁, y) n + finsupp.single (x₂, y) n - finsupp.single (x₁ + x₂, y) n
def smul_trans : α → β → γ → ℤ → free_abelian_group β γ :=
λ r x y n, finsupp.single (r • x, y) n - finsupp.single (x, r • y) n
variables α β γ
def smul_aux : α → β × γ → ℤ → free_abelian_group β γ :=
λ r f y, finsupp.single (r • f.fst, f.snd) y
variables {α β γ}
theorem pair_add.neg (x : β) (y₁ y₂ : γ) (n : ℤ) :
-pair_add α x y₁ y₂ n = pair_add α x y₁ y₂ (-n) :=
begin
unfold pair_add,
rw finsupp.single_neg,
rw finsupp.single_neg,
rw finsupp.single_neg,
simp,
repeat { rw add_comm, rw add_assoc }
end
theorem pair_add.smul (r : α) (x : β) (y₁ y₂ : γ) (n : ℤ) :
finsupp.sum (pair_add α x y₁ y₂ n) (smul_aux α β γ r) = relators.pair_add α (r • x) y₁ y₂ n :=
begin
unfold pair_add,
rw finsupp.sum_sub_index,
rw finsupp.sum_add_index,
repeat { rw finsupp.sum_single_index },
repeat { intros, simp [smul_aux] },
repeat { refl }
end
theorem add_pair.neg (x₁ x₂ : β) (y : γ) (n : ℤ) :
-add_pair α x₁ x₂ y n = add_pair α x₁ x₂ y (-n) :=
begin
unfold add_pair,
rw finsupp.single_neg,
rw finsupp.single_neg,
rw finsupp.single_neg,
simp,
repeat { rw add_comm, rw add_assoc }
end
theorem add_pair.smul (r : α) (x₁ x₂ : β) (y : γ) (n : ℤ) :
finsupp.sum (add_pair α x₁ x₂ y n) (smul_aux α β γ r) = relators.add_pair α (r • x₁) (r • x₂) y n :=
begin
unfold add_pair,
rw finsupp.sum_sub_index,
rw finsupp.sum_add_index,
repeat { rw finsupp.sum_single_index },
repeat { intros, simp [smul_aux, smul_add] },
repeat { refl }
end
theorem smul_trans.neg (r : α) (x : β) (y : γ) (n : ℤ) :
-smul_trans α r x y n = smul_trans α r x y (-n) :=
begin
unfold smul_trans,
rw finsupp.single_neg,
rw finsupp.single_neg,
simp
end
theorem smul_trans.smul (r r' : α) (x : β) (y : γ) (n : ℤ) :
finsupp.sum (smul_trans α r' x y n) (smul_aux α β γ r) = relators.smul_trans α r' (r • x) y n :=
begin
unfold smul_trans,
rw finsupp.sum_sub_index,
repeat { rw finsupp.sum_single_index },
repeat { intros, simp [smul_aux, smul_add, smul_smul, mul_comm] },
repeat { refl },
end
end relators
variables (α β γ)
def relators : set (free_abelian_group β γ) :=
{f | (∃ x y₁ y₂ n, f = relators.pair_add α x y₁ y₂ n) ∨
(∃ x₁ x₂ y n, f = relators.add_pair α x₁ x₂ y n) ∨
(∃ r x y n, f = relators.smul_trans α r x y n)}
theorem relators.zero_mem : (0 : free_abelian_group β γ ) ∈ relators α β γ :=
or.inl ⟨0, 0, 0, 0, by simpa [relators.pair_add, finsupp.single_zero]⟩
theorem relators.neg_mem : ∀ f, f ∈ relators α β γ → -f ∈ relators α β γ :=
begin
intros f hf,
rcases hf with hf | hf | hf;
rcases hf with ⟨a, b, c, d, hf⟩,
{ from or.inl ⟨a, b, c, -d, by rw [hf, relators.pair_add.neg]⟩ },
{ from or.inr (or.inl ⟨a, b, c, -d, by rw [hf, relators.add_pair.neg]⟩) },
{ from or.inr (or.inr ⟨a, b, c, -d, by rw [hf, relators.smul_trans.neg]⟩) }
end
def closure : set (free_abelian_group β γ) :=
{f | ∃ (L : list (free_abelian_group β γ)),
(∀ x ∈ L, x ∈ relators α β γ) ∧ L.sum = f}
def r : free_abelian_group β γ → free_abelian_group β γ → Prop :=
λ f g, f - g ∈ closure α β γ
local infix ≈ := r α β γ
theorem refl (f : free_abelian_group β γ) : f ≈ f :=
⟨[], by simp⟩
theorem symm (f g : free_abelian_group β γ) : f ≈ g → g ≈ f :=
λ ⟨L, hL, hLfg⟩, ⟨L.map (λ x, -x),
λ x hx, let ⟨y, hyL, hyx⟩ := list.exists_of_mem_map hx in
by rw ← hyx; exact relators.neg_mem α β γ y (hL y hyL),
by simp [list.map_neg, hLfg]⟩
theorem trans (f g h : free_abelian_group β γ) : f ≈ g → g ≈ h → f ≈ h :=
λ ⟨L₁, hL₁, hLfg₁⟩ ⟨L₂, hL₂, hLfg₂⟩,
⟨L₁ ++ L₂,
λ x hx, by rw [list.mem_append] at hx; from or.cases_on hx (hL₁ x) (hL₂ x),
by simp [hLfg₁, hLfg₂]⟩
instance : setoid (free_abelian_group β γ) :=
⟨r α β γ, refl α β γ, symm α β γ, trans α β γ⟩
end tensor_product
def tensor_product {α} (β γ) [comm_ring α] [module α β] [module α γ] : Type (max v w) :=
quotient (tensor_product.setoid α β γ)
local infix ` ⊗ `:100 := tensor_product
namespace tensor_product
variables (α : Type u) [comm_ring α]
variables (β : Type v) (γ : Type w) (α₁ : Type u₁) (β₁ : Type v₁) (γ₁ : Type w₁)
variables [module α β] [module α γ] [module α α₁] [module α β₁] [module α γ₁]
include α
def add : β ⊗ γ → β ⊗ γ → β ⊗ γ :=
quotient.lift₂ (λ f g, ⟦f + g⟧ : free_abelian_group β γ → free_abelian_group β γ → β ⊗ γ) $
λ f₁ f₂ g₁ g₂ ⟨L₁, hL₁, hLfg₁⟩ ⟨L₂, hL₂, hLfg₂⟩, quotient.sound
⟨L₁ ++ L₂,
λ x hx, by rw [list.mem_append] at hx; from or.cases_on hx (hL₁ x) (hL₂ x),
by rw [list.sum_append, hLfg₁, hLfg₂]; simp⟩
protected theorem add_assoc (f g h : β ⊗ γ) : add α β γ (add α β γ f g) h = add α β γ f (add α β γ g h) :=
quotient.induction_on₃ f g h $ λ m n k, quotient.sound $ by simp
def zero : β ⊗ γ := ⟦0⟧
protected theorem zero_add (f : β ⊗ γ) : add α β γ (zero α β γ) f = f :=
quotient.induction_on f $ λ m, quotient.sound $ by simp
protected theorem add_zero (f : β ⊗ γ) : add α β γ f (zero α β γ) = f :=
quotient.induction_on f $ λ m, quotient.sound $ by simp
def neg : β ⊗ γ → β ⊗ γ :=
quotient.lift (λ f, ⟦-f⟧ : free_abelian_group β γ → β ⊗ γ) $
λ f g ⟨L, hL, hLfg⟩, quotient.sound ⟨L.map (λ x, -x),
λ x hx, let ⟨y, hyL, hyx⟩ := list.exists_of_mem_map hx in
by rw ← hyx; exact relators.neg_mem α β γ y (hL y hyL),
by simp [list.map_neg, hLfg]⟩
protected theorem add_left_neg (f : β ⊗ γ) : add α β γ (neg α β γ f) f = zero α β γ :=
quotient.induction_on f $ λ m, quotient.sound $ by simp
protected theorem add_comm (f g : β ⊗ γ) : add α β γ f g = add α β γ g f :=
quotient.induction_on₂ f g $ λ m n, quotient.sound $ by simp
instance : add_comm_group (β ⊗ γ) :=
{ add := add α β γ,
add_assoc := tensor_product.add_assoc α β γ,
zero := zero α β γ,
zero_add := tensor_product.zero_add α β γ,
add_zero := tensor_product.add_zero α β γ,
neg := neg α β γ,
add_left_neg := tensor_product.add_left_neg α β γ,
add_comm := tensor_product.add_comm α β γ }
theorem mem_closure_of_finset {f : free_abelian_group β γ} :
(∃ (S : finset (free_abelian_group β γ)) g,
S.sum g = f ∧ ∀ x ∈ S, g x ∈ relators α β γ) →
f ∈ closure α β γ :=
λ ⟨S, g, hSf, hSr⟩, begin
cases S with ms hms,
cases quot.exists_rep ms with L hL,
existsi L.map g,
split,
{ intros x hxL,
rcases list.exists_of_mem_map hxL with ⟨y, hyL, hyx⟩,
have hyms : y ∈ ms,
{ unfold has_mem.mem,
unfold multiset.mem,
rw ← hL,
rw quot.lift_on,
rwa @quot.lift_beta _ (list.perm.setoid (free_abelian_group β γ)).r,
exact multiset.mem._proof_1 y },
rw ← hyx,
exact hSr y hyms },
{ change multiset.sum (multiset.map g ms) = f at hSf,
rw ← hL at hSf,
rw ← multiset.coe_sum,
exact hSf }
end
private lemma zero_eq_zero : (0 : free_abelian_group β γ) = (0 : β × γ →₀ ℤ) := rfl
private lemma sum_zero_index (f : β × γ → ℤ → free_abelian_group β γ) :
@finsupp.sum (β × γ) ℤ (free_abelian_group β γ) int.has_zero _ (0 : free_abelian_group β γ) f = 0 :=
begin
rw zero_eq_zero,
simp [finsupp.sum],
refl
end
private lemma sum_zero_index' [add_comm_group α₁] (f : β × γ → ℤ → α₁) :
@finsupp.sum (β × γ) ℤ α₁ int.has_zero _ (0 : free_abelian_group β γ) f = 0 :=
begin
rw zero_eq_zero,
simp [finsupp.sum]
end
def smul : α → β ⊗ γ → β ⊗ γ :=
λ r, quotient.lift (λ f, ⟦f.sum (relators.smul_aux α β γ r)⟧ : free_abelian_group β γ → β ⊗ γ) $
λ f g ⟨L, hL, hLfg⟩, quotient.sound
begin
clear _fun_match,
induction L generalizing f g,
{ existsi [],
have : f = g,
by simpa [add_neg_eq_zero] using hLfg.symm,
simp [this] },
{ specialize L_ih (λ z hzt, hL z (or.inr hzt)) L_tl.sum (0:free_abelian_group β γ),
specialize L_ih ⟨L_tl,
λ z hzt, hL z (or.inr hzt),
eq.symm (sub_zero _)⟩,
specialize L_ih (eq.symm $ sub_zero _),
rcases L_ih with ⟨L', hL', hLfg'⟩,
rw [sum_zero_index] at hLfg',
simp at hLfg',
rcases hL L_hd (or.inl rfl) with h | h | h,
{ rcases h with ⟨x, y₁, y₂, n, h⟩,
existsi list.cons (relators.pair_add α (r • x) y₁ y₂ n) L',
split,
{ exact λ z hz, or.cases_on (list.eq_or_mem_of_mem_cons hz)
(λ hzh, or.inl ⟨r • x, y₁, y₂, n, hzh⟩)
(λ hzt, hL' z hzt) },
{ rw ← finsupp.sum_sub_index,
rw ← hLfg,
rw list.sum_cons,
rw list.sum_cons,
rw finsupp.sum_add_index,
rw ← hLfg',
rw h,
rw relators.pair_add.smul,
all_goals { intros, simp [relators.smul_aux], try {refl} } } },
{ rcases h with ⟨x₁, x₂, y, n, h⟩,
existsi list.cons (relators.add_pair α (r • x₁) (r • x₂) y n) L',
split,
{ exact λ z hz, or.cases_on (list.eq_or_mem_of_mem_cons hz)
(λ hzh, or.inr $ or.inl ⟨r • x₁, r • x₂, y, n, hzh⟩)
(λ hzt, hL' z hzt) },
{ rw ← finsupp.sum_sub_index,
rw ← hLfg,
rw list.sum_cons,
rw list.sum_cons,
rw finsupp.sum_add_index,
rw ← hLfg',
rw h,
rw relators.add_pair.smul,
all_goals { intros, simp [relators.smul_aux], try {refl} } } },
{ rcases h with ⟨r', x, y, n, h⟩,
existsi list.cons (relators.smul_trans α r' (r • x) y n) L',
split,
{ exact λ z hz, or.cases_on (list.eq_or_mem_of_mem_cons hz)
(λ hzh, or.inr $ or.inr ⟨r', r • x, y, n, hzh⟩)
(λ hzt, hL' z hzt) },
{ rw ← finsupp.sum_sub_index,
rw ← hLfg,
rw list.sum_cons,
rw list.sum_cons,
rw finsupp.sum_add_index,
rw ← hLfg',
rw h,
rw relators.smul_trans.smul,
all_goals { intros, simp [relators.smul_aux], try {refl} } } } }
end
protected theorem smul_add (r : α) (f g : β ⊗ γ) : smul α β γ r (add α β γ f g) = add α β γ (smul α β γ r f) (smul α β γ r g) :=
quotient.induction_on₂ f g $ λ m n, quotient.sound $ by rw [finsupp.sum_add_index]; all_goals { intros, simp [relators.smul_aux], try {refl} }
protected theorem add_smul (r₁ r₂ : α) (f : β ⊗ γ) : smul α β γ (r₁ + r₂) f = add α β γ (smul α β γ r₁ f) (smul α β γ r₂ f) :=
quotient.induction_on f $ λ m, quotient.sound $
begin
unfold relators.smul_aux,
simp [add_smul],
rcases structural_theorem β γ m with ⟨S, hS, hSm⟩,
rw ← hSm,
apply symm,
apply mem_closure_of_finset,
existsi S,
revert m hS hSm,
apply finset.induction_on S,
{ intros m hS hSm,
existsi id,
split,
{ simp,
rw sum_zero_index,
rw sum_zero_index,
rw sum_zero_index,
simp },
{ intros x hx,
exfalso,
exact hx } },
{ intros g T hgT ih m hS hSm,
rcases hS g (finset.mem_insert_self g T) with ⟨x, y, n, H, h⟩,
rcases ih (T.sum id) (λ g' hg', hS g' $
finset.mem_insert_of_mem hg') rfl with ⟨φ', hst', hss'⟩,
existsi (λ f, if f = g then finsupp.single (r₁ • x, y) n +
finsupp.single (r₂ • x, y) n -
finsupp.single (r₁ • x + r₂ • x, y) n else φ' f),
split,
{ rw finset.sum_insert,
rw finset.sum_insert,
rw finsupp.sum_add_index,
rw finsupp.sum_add_index,
rw finsupp.sum_add_index,
rw if_pos rfl,
rw h,
rw id.def,
rw finsupp.sum_single_index,
rw finsupp.sum_single_index,
rw finsupp.sum_single_index,
have h1 : finset.sum T
(λ (f : free_abelian_group β γ),
ite (f = finsupp.single (x, y) n)
(finsupp.single (r₁ • x, y) n + finsupp.single (r₂ • x, y) n -
finsupp.single (r₁ • x + r₂ • x, y) n)
(φ' f)) = finset.sum T φ',
{ apply finset.sum_congr,
{ refl },
{ intros g' hg',
have h1 : g' ≠ g,
{ intro hgg',
rw hgg' at hg',
exact hgT hg' },
rw h at h1,
rw if_neg h1 } },
rw h1,
rw hst',
unfold prod.fst,
unfold prod.snd,
simp,
all_goals { intros,
try {rw finsupp.single_zero},
try {rw finsupp.single_zero},
try {rw finsupp.single_add},
try {refl},
try {refl},
try {exact hgT} } },
{ intros f' hf',
rw finset.mem_insert at hf',
cases hf',
{ dsimp,
rw if_pos hf',
from or.inr (or.inl ⟨r₁ • x, r₂ • x, y, n, rfl⟩) },
{ have h1 : f' ≠ g,
{ intro hfg',
rw hfg' at hf',
exact hgT hf' },
dsimp,
rw if_neg h1,
from hss' f' hf' } } }
end
protected theorem mul_smul (r₁ r₂ : α) (f : β ⊗ γ) : smul α β γ (r₁ * r₂) f = smul α β γ r₁ (smul α β γ r₂ f) :=
quotient.induction_on f $ λ m, quotient.sound $
begin
unfold relators.smul_aux,
simp [mul_smul],
rcases structural_theorem β γ m with ⟨S, hS, hSm⟩,
rw ← hSm,
apply symm,
apply mem_closure_of_finset,
existsi S,
existsi (λ f, 0 : free_abelian_group β γ → free_abelian_group β γ),
revert m hS hSm,
apply finset.induction_on S,
{ intros m hS hSm,
split,
{ simp,
rw sum_zero_index,
rw sum_zero_index,
rw sum_zero_index,
simp },
{ intros x hx,
exfalso,
exact hx } },
{ intros g T hgT ih m hS hSm,
rcases hS g (finset.mem_insert_self g T) with ⟨x, y, n, H, h⟩,
rcases ih (T.sum id) (λ g' hg', hS g' $
finset.mem_insert_of_mem hg') rfl with ⟨hst', hss'⟩,
split,
{ rw finset.sum_insert,
rw finset.sum_insert,
rw finset.sum_const_zero,
rw finset.sum_const_zero at hst',
rw finsupp.sum_add_index,
rw finsupp.sum_add_index,
rw finsupp.sum_add_index,
rw h,
rw id.def,
rw finsupp.sum_single_index,
rw finsupp.sum_single_index,
rw finsupp.sum_single_index,
unfold prod.fst,
unfold prod.snd,
rw add_comm_group.zero_add,
rw hst',
simp,
all_goals { intros,
try {rw finsupp.single_zero},
try {rw finsupp.single_zero},
try {rw finsupp.single_add},
try {refl},
try {refl},
try {exact hgT} } },
{ intros f' hf',
dsimp,
exact relators.zero_mem α β γ } }
end
protected theorem one_smul (f : β ⊗ γ) : smul α β γ 1 f = f :=
quotient.induction_on f $ λ m, quotient.sound $ by simp [relators.smul_aux]
instance : module α (β ⊗ γ) :=
{ smul := smul α β γ,
smul_add := tensor_product.smul_add α β γ,
add_smul := tensor_product.add_smul α β γ,
mul_smul := tensor_product.mul_smul α β γ,
one_smul := tensor_product.one_smul α β γ }
@[simp] lemma add_quot (f g : free_abelian_group β γ) : @has_add.add (β ⊗ γ) _ (⟦f⟧ : β ⊗ γ) ⟦g⟧ = ⟦f + g⟧ := rfl
@[simp] lemma neg_quot (f : free_abelian_group β γ) : @has_neg.neg (β ⊗ γ) _ (⟦f⟧ : β ⊗ γ) = ⟦-f⟧ := rfl
variables {α β γ}
def tprod : β → γ → β ⊗ γ :=
λ x y, ⟦finsupp.single (x, y) 1⟧
infix ` ⊗ₛ `:100 := tprod
variables {r r₁ r₂ : α} {x x₁ x₂ : β} {y y₁ y₂ : γ}
theorem tprod_unfold : x ⊗ₛ y = tprod x y := rfl
theorem tprod.is_bilinear_map : is_bilinear_map (@tprod α _ β γ _ _) :=
{ add_pair := λ x y z, quotient.sound $ setoid.symm $
⟨[(finsupp.single (x, z) 1 +
finsupp.single (y, z) 1 -
finsupp.single (x + y, z) 1 : free_abelian_group β γ)],
λ u hu, or.inr $ or.inl ⟨x, y, z, 1, list.eq_of_mem_singleton hu⟩,
list.sum_singleton⟩,
pair_add := λ x y z, quotient.sound $ setoid.symm $
⟨[(finsupp.single (x, y) 1 +
finsupp.single (x, z) 1 -
finsupp.single (x, y + z) 1 : free_abelian_group β γ)],
λ u hu, or.inl ⟨x, y, z, 1, list.eq_of_mem_singleton hu⟩,
list.sum_singleton⟩,
smul_pair := λ r x y, quotient.sound $ setoid.symm $
begin
simp [relators.smul_aux],
rw finsupp.sum_single_index,
exact finsupp.single_zero
end,
pair_smul := λ r x y, quotient.sound $ setoid.symm $
begin
simp [relators.smul_aux],
rw finsupp.sum_single_index,
unfold prod.fst,
unfold prod.snd,
existsi ([(finsupp.single (r • x, y) 1 -
finsupp.single (x, r • y) 1 : free_abelian_group β γ)]),
split,
{ intros z hz,
rw list.mem_singleton at hz,
rw hz,
from or.inr (or.inr ⟨r, x, y, 1, by simp [relators.smul_trans]⟩) },
simp [list.sum_singleton],
{ rw finsupp.single_zero,
refl }
end }
@[simp] lemma add_tprod : (x₁ + x₂) ⊗ₛ y = x₁ ⊗ₛ y + x₂ ⊗ₛ y :=
tprod.is_bilinear_map.add_pair x₁ x₂ y
@[simp] lemma tprod_add : x ⊗ₛ (y₁ + y₂) = x ⊗ₛ y₁ + x ⊗ₛ y₂ :=
tprod.is_bilinear_map.pair_add x y₁ y₂
@[simp] lemma smul_tprod : (r • x) ⊗ₛ y = r • x ⊗ₛ y :=
tprod.is_bilinear_map.smul_pair r x y
@[simp] lemma tprod_smul : x ⊗ₛ (r • y) = r • x ⊗ₛ y :=
tprod.is_bilinear_map.pair_smul r x y
@[simp] lemma zero_tprod : (0:β) ⊗ₛ y = 0 :=
tprod.is_bilinear_map.zero_pair y
@[simp] lemma tprod_zero {x : β} : x ⊗ₛ (0:γ) = 0 :=
tprod.is_bilinear_map.pair_zero x
namespace universal_property
variables {β γ α₁}
variables {f : β → γ → α₁} (hf : is_bilinear_map f)
include β γ α₁ hf
def factor_aux : free_abelian_group β γ → α₁ :=
λ g : free_abelian_group β γ, (g.sum (λ z n, gsmul (f z.fst z.snd) n))
theorem factor_equiv : ∀ g₁ g₂ : free_abelian_group β γ, g₁ ≈ g₂ → factor_aux hf g₁ = factor_aux hf g₂ :=
λ g₁ g₂ ⟨L, hL, hgL⟩,
begin
clear _fun_match _x,
induction L generalizing hgL hL g₂ g₁,
{ simp at hgL,
replace hgL := hgL.symm,
rw add_neg_eq_zero at hgL,
rw hgL },
{ specialize L_ih L_tl.sum 0,
specialize L_ih (λ x hx, hL x (list.mem_cons_of_mem L_hd hx)),
specialize L_ih (sub_zero _).symm,
rw ← sub_eq_zero,
unfold factor_aux at L_ih ⊢,
rw ← finsupp.sum_sub_index,
rw ← hgL,
rw list.sum_cons,
rw finsupp.sum_add_index,
rw L_ih,
rw sum_zero_index',
specialize hL L_hd,
specialize hL (or.inl rfl),
rcases hL with h | h | h,
{ rcases h with ⟨x, y₁, y₂, n, h⟩,
rw h,
unfold relators.pair_add,
rw finsupp.sum_sub_index,
rw finsupp.sum_add_index,
rw finsupp.sum_single_index,
rw finsupp.sum_single_index,
rw finsupp.sum_single_index,
rw ← add_gsmul,
rw ← sub_gsmul,
rw hf.pair_add,
simp,
{ rw gsmul_zero },
{ rw gsmul_zero },
{ rw gsmul_zero },
{ intros, rw gsmul_zero },
{ intros, rw gsmul_add },
{ intros, rw gsmul_sub } },
{ rcases h with ⟨x₁, x₂, y, n, h⟩,
rw h,
unfold relators.add_pair,
rw finsupp.sum_sub_index,
rw finsupp.sum_add_index,
rw finsupp.sum_single_index,
rw finsupp.sum_single_index,
rw finsupp.sum_single_index,
rw ← add_gsmul,
rw ← sub_gsmul,
rw hf.add_pair,
simp,
{ rw gsmul_zero },
{ rw gsmul_zero },
{ rw gsmul_zero },
{ intros, rw gsmul_zero },
{ intros, rw gsmul_add },
{ intros, rw gsmul_sub } },
{ rcases h with ⟨r, x, y, n, h⟩,
rw h,
unfold relators.smul_trans,
rw finsupp.sum_sub_index,
rw finsupp.sum_single_index,
rw finsupp.sum_single_index,
rw ← sub_gsmul,
rw hf.smul_pair,
rw hf.pair_smul,
simp,
{ rw gsmul_zero },
{ rw gsmul_zero },
{ intros, rw gsmul_sub } },
{ intros, rw gsmul_zero },
{ intros, rw gsmul_add },
{ intros, rw gsmul_sub } }
end
def factor : β ⊗ γ → α₁ :=
quotient.lift (factor_aux hf) (factor_equiv hf)
theorem factor_add : ∀ g₁ g₂ : β ⊗ γ, factor hf (g₁ + g₂) = factor hf g₁ + factor hf g₂ :=
λ x y, quotient.induction_on₂ x y
begin
intros m n,
simp [universal_property.factor],
simp [universal_property.factor_aux],
rw finsupp.sum_add_index,
{ intros, rw gsmul_zero },
{ intros, rw gsmul_add }
end
theorem factor_smul : ∀ (r : α) (g : β ⊗ γ), factor hf (r • g) = r • factor hf g :=
λ r x, quotient.induction_on x
begin
intros m,
simp [has_scalar.smul, smul, relators.smul_aux],
rcases structural_theorem β γ m with ⟨S, hS, hSm⟩,
rw ← hSm,
revert m hS hSm,
apply finset.induction_on S,
{ intros m hS hSm,
unfold universal_property.factor,
unfold universal_property.factor_aux,
simp [finsupp.sum_zero_index],
rw sum_zero_index,
rw sum_zero_index',
simp },
{ intros n T hnT ih m hS hSm,
unfold universal_property.factor,
unfold universal_property.factor_aux,
simp,
specialize ih (finset.sum T id),
specialize ih (λ g hg, hS g (finset.mem_insert_of_mem hg)),
specialize ih rfl,
unfold universal_property.factor at ih,
unfold universal_property.factor_aux at ih,
simp at ih,
rw finset.sum_insert,
rw finsupp.sum_add_index,
rw finsupp.sum_add_index,
rw finsupp.sum_add_index,
rw ih,
specialize hS n (finset.mem_insert_self n T),
rcases hS with ⟨x', y', n', H', hn'⟩,
rw hn',
rw finsupp.sum_single_index,
rw finsupp.sum_single_index,
rw finsupp.sum_single_index,
rw hf.smul_pair,
rw gsmul_smul,
rw smul_add,
{ rw gsmul_zero },
{ rw gsmul_zero },
{ rw finsupp.single_zero, refl },
{ intros, rw gsmul_zero },
{ intros, rw gsmul_add },
{ intros, rw gsmul_zero },
{ intros, rw gsmul_add },
{ intros, rw finsupp.single_zero, refl },
{ intros, rw finsupp.single_add },
{ exact hnT } }
end