/
Basic.lean
1905 lines (1633 loc) · 85.7 KB
/
Basic.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) 2020 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Algebra.Algebra.Defs
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Fintype.Sort
import Mathlib.Data.List.FinRange
import Mathlib.LinearAlgebra.Pi
import Mathlib.Logic.Equiv.Fintype
#align_import linear_algebra.multilinear.basic from "leanprover-community/mathlib"@"78fdf68dcd2fdb3fe64c0dd6f88926a49418a6ea"
/-!
# Multilinear maps
We define multilinear maps as maps from `∀ (i : ι), M₁ i` to `M₂` which are linear in each
coordinate. Here, `M₁ i` and `M₂` are modules over a ring `R`, and `ι` is an arbitrary type
(although some statements will require it to be a fintype). This space, denoted by
`MultilinearMap R M₁ M₂`, inherits a module structure by pointwise addition and multiplication.
## Main definitions
* `MultilinearMap R M₁ M₂` is the space of multilinear maps from `∀ (i : ι), M₁ i` to `M₂`.
* `f.map_smul` is the multiplicativity of the multilinear map `f` along each coordinate.
* `f.map_add` is the additivity of the multilinear map `f` along each coordinate.
* `f.map_smul_univ` expresses the multiplicativity of `f` over all coordinates at the same time,
writing `f (fun i => c i • m i)` as `(∏ i, c i) • f m`.
* `f.map_add_univ` expresses the additivity of `f` over all coordinates at the same time, writing
`f (m + m')` as the sum over all subsets `s` of `ι` of `f (s.piecewise m m')`.
* `f.map_sum` expresses `f (Σ_{j₁} g₁ j₁, ..., Σ_{jₙ} gₙ jₙ)` as the sum of
`f (g₁ (r 1), ..., gₙ (r n))` where `r` ranges over all possible functions.
We also register isomorphisms corresponding to currying or uncurrying variables, transforming a
multilinear function `f` on `n+1` variables into a linear function taking values in multilinear
functions in `n` variables, and into a multilinear function in `n` variables taking values in linear
functions. These operations are called `f.curryLeft` and `f.curryRight` respectively
(with inverses `f.uncurryLeft` and `f.uncurryRight`). These operations induce linear equivalences
between spaces of multilinear functions in `n+1` variables and spaces of linear functions into
multilinear functions in `n` variables (resp. multilinear functions in `n` variables taking values
in linear functions), called respectively `multilinearCurryLeftEquiv` and
`multilinearCurryRightEquiv`.
## Implementation notes
Expressing that a map is linear along the `i`-th coordinate when all other coordinates are fixed
can be done in two (equivalent) different ways:
* fixing a vector `m : ∀ (j : ι - i), M₁ j.val`, and then choosing separately the `i`-th coordinate
* fixing a vector `m : ∀j, M₁ j`, and then modifying its `i`-th coordinate
The second way is more artificial as the value of `m` at `i` is not relevant, but it has the
advantage of avoiding subtype inclusion issues. This is the definition we use, based on
`Function.update` that allows to change the value of `m` at `i`.
Note that the use of `Function.update` requires a `DecidableEq ι` term to appear somewhere in the
statement of `MultilinearMap.map_add'` and `MultilinearMap.map_smul'`. Three possible choices
are:
1. Requiring `DecidableEq ι` as an argument to `MultilinearMap` (as we did originally).
2. Using `Classical.decEq ι` in the statement of `map_add'` and `map_smul'`.
3. Quantifying over all possible `DecidableEq ι` instances in the statement of `map_add'` and
`map_smul'`.
Option 1 works fine, but puts unnecessary constraints on the user (the zero map certainly does not
need decidability). Option 2 looks great at first, but in the common case when `ι = Fin n` it
introduces non-defeq decidability instance diamonds within the context of proving `map_add'` and
`map_smul'`, of the form `Fin.decidableEq n = Classical.decEq (Fin n)`. Option 3 of course does
something similar, but of the form `Fin.decidableEq n = _inst`, which is much easier to clean up
since `_inst` is a free variable and so the equality can just be substituted.
-/
open Function Fin Set BigOperators
universe uR uS uι v v' v₁ v₂ v₃
variable {R : Type uR} {S : Type uS} {ι : Type uι} {n : ℕ}
{M : Fin n.succ → Type v} {M₁ : ι → Type v₁} {M₂ : Type v₂} {M₃ : Type v₃} {M' : Type v'}
/-- Multilinear maps over the ring `R`, from `∀ i, M₁ i` to `M₂` where `M₁ i` and `M₂` are modules
over `R`. -/
structure MultilinearMap (R : Type uR) {ι : Type uι} (M₁ : ι → Type v₁) (M₂ : Type v₂) [Semiring R]
[∀ i, AddCommMonoid (M₁ i)] [AddCommMonoid M₂] [∀ i, Module R (M₁ i)] [Module R M₂] where
/-- The underlying multivariate function of a multilinear map. -/
toFun : (∀ i, M₁ i) → M₂
/-- A multilinear map is additive in every argument. -/
map_add' :
∀ [DecidableEq ι] (m : ∀ i, M₁ i) (i : ι) (x y : M₁ i),
toFun (update m i (x + y)) = toFun (update m i x) + toFun (update m i y)
/-- A multilinear map is compatible with scalar multiplication in every argument. -/
map_smul' :
∀ [DecidableEq ι] (m : ∀ i, M₁ i) (i : ι) (c : R) (x : M₁ i),
toFun (update m i (c • x)) = c • toFun (update m i x)
#align multilinear_map MultilinearMap
-- Porting note: added to avoid a linter timeout.
attribute [nolint simpNF] MultilinearMap.mk.injEq
namespace MultilinearMap
section Semiring
variable [Semiring R] [∀ i, AddCommMonoid (M i)] [∀ i, AddCommMonoid (M₁ i)] [AddCommMonoid M₂]
[AddCommMonoid M₃] [AddCommMonoid M'] [∀ i, Module R (M i)] [∀ i, Module R (M₁ i)] [Module R M₂]
[Module R M₃] [Module R M'] (f f' : MultilinearMap R M₁ M₂)
-- Porting note: Replaced CoeFun with FunLike instance
instance : FunLike (MultilinearMap R M₁ M₂) (∀ i, M₁ i) M₂ where
coe f := f.toFun
coe_injective' := fun f g h ↦ by cases f; cases g; cases h; rfl
initialize_simps_projections MultilinearMap (toFun → apply)
@[simp]
theorem toFun_eq_coe : f.toFun = ⇑f :=
rfl
#align multilinear_map.to_fun_eq_coe MultilinearMap.toFun_eq_coe
@[simp]
theorem coe_mk (f : (∀ i, M₁ i) → M₂) (h₁ h₂) : ⇑(⟨f, h₁, h₂⟩ : MultilinearMap R M₁ M₂) = f :=
rfl
#align multilinear_map.coe_mk MultilinearMap.coe_mk
theorem congr_fun {f g : MultilinearMap R M₁ M₂} (h : f = g) (x : ∀ i, M₁ i) : f x = g x :=
DFunLike.congr_fun h x
#align multilinear_map.congr_fun MultilinearMap.congr_fun
nonrec theorem congr_arg (f : MultilinearMap R M₁ M₂) {x y : ∀ i, M₁ i} (h : x = y) : f x = f y :=
DFunLike.congr_arg f h
#align multilinear_map.congr_arg MultilinearMap.congr_arg
theorem coe_injective : Injective ((↑) : MultilinearMap R M₁ M₂ → (∀ i, M₁ i) → M₂) :=
DFunLike.coe_injective
#align multilinear_map.coe_injective MultilinearMap.coe_injective
@[norm_cast] -- Porting note (#10618): Removed simp attribute, simp can prove this
theorem coe_inj {f g : MultilinearMap R M₁ M₂} : (f : (∀ i, M₁ i) → M₂) = g ↔ f = g :=
DFunLike.coe_fn_eq
#align multilinear_map.coe_inj MultilinearMap.coe_inj
@[ext]
theorem ext {f f' : MultilinearMap R M₁ M₂} (H : ∀ x, f x = f' x) : f = f' :=
DFunLike.ext _ _ H
#align multilinear_map.ext MultilinearMap.ext
theorem ext_iff {f g : MultilinearMap R M₁ M₂} : f = g ↔ ∀ x, f x = g x :=
DFunLike.ext_iff
#align multilinear_map.ext_iff MultilinearMap.ext_iff
@[simp]
theorem mk_coe (f : MultilinearMap R M₁ M₂) (h₁ h₂) :
(⟨f, h₁, h₂⟩ : MultilinearMap R M₁ M₂) = f := rfl
#align multilinear_map.mk_coe MultilinearMap.mk_coe
@[simp]
protected theorem map_add [DecidableEq ι] (m : ∀ i, M₁ i) (i : ι) (x y : M₁ i) :
f (update m i (x + y)) = f (update m i x) + f (update m i y) :=
f.map_add' m i x y
#align multilinear_map.map_add MultilinearMap.map_add
@[simp]
protected theorem map_smul [DecidableEq ι] (m : ∀ i, M₁ i) (i : ι) (c : R) (x : M₁ i) :
f (update m i (c • x)) = c • f (update m i x) :=
f.map_smul' m i c x
#align multilinear_map.map_smul MultilinearMap.map_smul
theorem map_coord_zero {m : ∀ i, M₁ i} (i : ι) (h : m i = 0) : f m = 0 := by
classical
have : (0 : R) • (0 : M₁ i) = 0 := by simp
rw [← update_eq_self i m, h, ← this, f.map_smul, zero_smul R (M := M₂)]
#align multilinear_map.map_coord_zero MultilinearMap.map_coord_zero
@[simp]
theorem map_update_zero [DecidableEq ι] (m : ∀ i, M₁ i) (i : ι) : f (update m i 0) = 0 :=
f.map_coord_zero i (update_same i 0 m)
#align multilinear_map.map_update_zero MultilinearMap.map_update_zero
@[simp]
theorem map_zero [Nonempty ι] : f 0 = 0 := by
obtain ⟨i, _⟩ : ∃ i : ι, i ∈ Set.univ := Set.exists_mem_of_nonempty ι
exact map_coord_zero f i rfl
#align multilinear_map.map_zero MultilinearMap.map_zero
instance : Add (MultilinearMap R M₁ M₂) :=
⟨fun f f' =>
⟨fun x => f x + f' x, fun m i x y => by simp [add_left_comm, add_assoc], fun m i c x => by
simp [smul_add]⟩⟩
@[simp]
theorem add_apply (m : ∀ i, M₁ i) : (f + f') m = f m + f' m :=
rfl
#align multilinear_map.add_apply MultilinearMap.add_apply
instance : Zero (MultilinearMap R M₁ M₂) :=
⟨⟨fun _ => 0, fun _ i _ _ => by simp, fun _ i c _ => by simp⟩⟩
instance : Inhabited (MultilinearMap R M₁ M₂) :=
⟨0⟩
@[simp]
theorem zero_apply (m : ∀ i, M₁ i) : (0 : MultilinearMap R M₁ M₂) m = 0 :=
rfl
#align multilinear_map.zero_apply MultilinearMap.zero_apply
section SMul
variable {R' A : Type*} [Monoid R'] [Semiring A] [∀ i, Module A (M₁ i)] [DistribMulAction R' M₂]
[Module A M₂] [SMulCommClass A R' M₂]
instance : SMul R' (MultilinearMap A M₁ M₂) :=
⟨fun c f =>
⟨fun m => c • f m, fun m i x y => by simp [smul_add], fun l i x d => by
simp [← smul_comm x c (_ : M₂)]⟩⟩
@[simp]
theorem smul_apply (f : MultilinearMap A M₁ M₂) (c : R') (m : ∀ i, M₁ i) : (c • f) m = c • f m :=
rfl
#align multilinear_map.smul_apply MultilinearMap.smul_apply
theorem coe_smul (c : R') (f : MultilinearMap A M₁ M₂) : ⇑(c • f) = c • (⇑ f) :=
rfl
#align multilinear_map.coe_smul MultilinearMap.coe_smul
end SMul
instance addCommMonoid : AddCommMonoid (MultilinearMap R M₁ M₂) :=
coe_injective.addCommMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl
#align multilinear_map.add_comm_monoid MultilinearMap.addCommMonoid
/-- Coercion of a multilinear map to a function as an additive monoid homomorphism. -/
@[simps] def coeAddMonoidHom : MultilinearMap R M₁ M₂ →+ (((i : ι) → M₁ i) → M₂) where
toFun := DFunLike.coe; map_zero' := rfl; map_add' _ _ := rfl
@[simp]
theorem coe_sum {α : Type*} (f : α → MultilinearMap R M₁ M₂) (s : Finset α) :
⇑(∑ a in s, f a) = ∑ a in s, ⇑(f a) :=
map_sum coeAddMonoidHom f s
theorem sum_apply {α : Type*} (f : α → MultilinearMap R M₁ M₂) (m : ∀ i, M₁ i) {s : Finset α} :
(∑ a in s, f a) m = ∑ a in s, f a m := by simp
#align multilinear_map.sum_apply MultilinearMap.sum_apply
/-- If `f` is a multilinear map, then `f.toLinearMap m i` is the linear map obtained by fixing all
coordinates but `i` equal to those of `m`, and varying the `i`-th coordinate. -/
@[simps]
def toLinearMap [DecidableEq ι] (m : ∀ i, M₁ i) (i : ι) : M₁ i →ₗ[R] M₂ where
toFun x := f (update m i x)
map_add' x y := by simp
map_smul' c x := by simp
#align multilinear_map.to_linear_map MultilinearMap.toLinearMap
#align multilinear_map.to_linear_map_to_add_hom_apply MultilinearMap.toLinearMap_apply
/-- The cartesian product of two multilinear maps, as a multilinear map. -/
@[simps]
def prod (f : MultilinearMap R M₁ M₂) (g : MultilinearMap R M₁ M₃) : MultilinearMap R M₁ (M₂ × M₃)
where
toFun m := (f m, g m)
map_add' m i x y := by simp
map_smul' m i c x := by simp
#align multilinear_map.prod MultilinearMap.prod
#align multilinear_map.prod_apply MultilinearMap.prod_apply
/-- Combine a family of multilinear maps with the same domain and codomains `M' i` into a
multilinear map taking values in the space of functions `∀ i, M' i`. -/
@[simps]
def pi {ι' : Type*} {M' : ι' → Type*} [∀ i, AddCommMonoid (M' i)] [∀ i, Module R (M' i)]
(f : ∀ i, MultilinearMap R M₁ (M' i)) : MultilinearMap R M₁ (∀ i, M' i) where
toFun m i := f i m
map_add' _ _ _ _ := funext fun j => (f j).map_add _ _ _ _
map_smul' _ _ _ _ := funext fun j => (f j).map_smul _ _ _ _
#align multilinear_map.pi MultilinearMap.pi
#align multilinear_map.pi_apply MultilinearMap.pi_apply
section
variable (R M₂ M₃)
/-- Equivalence between linear maps `M₂ →ₗ[R] M₃` and one-multilinear maps. -/
@[simps]
def ofSubsingleton [Subsingleton ι] (i : ι) :
(M₂ →ₗ[R] M₃) ≃ MultilinearMap R (fun _ : ι ↦ M₂) M₃ where
toFun f :=
{ toFun := fun x ↦ f (x i)
map_add' := by intros; simp [update_eq_const_of_subsingleton]
map_smul' := by intros; simp [update_eq_const_of_subsingleton] }
invFun f :=
{ toFun := fun x ↦ f fun _ ↦ x
map_add' := fun x y ↦ by simpa [update_eq_const_of_subsingleton] using f.map_add 0 i x y
map_smul' := fun c x ↦ by simpa [update_eq_const_of_subsingleton] using f.map_smul 0 i c x }
left_inv f := rfl
right_inv f := by ext x; refine congr_arg f ?_; exact (eq_const_of_subsingleton _ _).symm
#align multilinear_map.of_subsingleton MultilinearMap.ofSubsingletonₓ
#align multilinear_map.of_subsingleton_apply MultilinearMap.ofSubsingleton_apply_applyₓ
variable (M₁) {M₂}
/-- The constant map is multilinear when `ι` is empty. -/
-- Porting note: Removed [simps] & added simpNF-approved version of the generated lemma manually.
@[simps (config := .asFn)]
def constOfIsEmpty [IsEmpty ι] (m : M₂) : MultilinearMap R M₁ M₂ where
toFun := Function.const _ m
map_add' _ := isEmptyElim
map_smul' _ := isEmptyElim
#align multilinear_map.const_of_is_empty MultilinearMap.constOfIsEmpty
#align multilinear_map.const_of_is_empty_apply MultilinearMap.constOfIsEmpty_apply
end
-- Porting note: Included `DFunLike.coe` to avoid strange CoeFun instance for Equiv
/-- Given a multilinear map `f` on `n` variables (parameterized by `Fin n`) and a subset `s` of `k`
of these variables, one gets a new multilinear map on `Fin k` by varying these variables, and fixing
the other ones equal to a given value `z`. It is denoted by `f.restr s hk z`, where `hk` is a
proof that the cardinality of `s` is `k`. The implicit identification between `Fin k` and `s` that
we use is the canonical (increasing) bijection. -/
def restr {k n : ℕ} (f : MultilinearMap R (fun _ : Fin n => M') M₂) (s : Finset (Fin n))
(hk : s.card = k) (z : M') : MultilinearMap R (fun _ : Fin k => M') M₂ where
toFun v := f fun j => if h : j ∈ s then v ((DFunLike.coe (s.orderIsoOfFin hk).symm) ⟨j, h⟩) else z
/- Porting note: The proofs of the following two lemmas used to only use `erw` followed by `simp`,
but it seems `erw` no longer unfolds or unifies well enough to work without more help. -/
map_add' v i x y := by
have : DFunLike.coe (s.orderIsoOfFin hk).symm = (s.orderIsoOfFin hk).toEquiv.symm := rfl
simp only [this]
erw [dite_comp_equiv_update (s.orderIsoOfFin hk).toEquiv,
dite_comp_equiv_update (s.orderIsoOfFin hk).toEquiv,
dite_comp_equiv_update (s.orderIsoOfFin hk).toEquiv]
simp
map_smul' v i c x := by
have : DFunLike.coe (s.orderIsoOfFin hk).symm = (s.orderIsoOfFin hk).toEquiv.symm := rfl
simp only [this]
erw [dite_comp_equiv_update (s.orderIsoOfFin hk).toEquiv,
dite_comp_equiv_update (s.orderIsoOfFin hk).toEquiv]
simp
#align multilinear_map.restr MultilinearMap.restr
/-- In the specific case of multilinear maps on spaces indexed by `Fin (n+1)`, where one can build
an element of `∀ (i : Fin (n+1)), M i` using `cons`, one can express directly the additivity of a
multilinear map along the first variable. -/
theorem cons_add (f : MultilinearMap R M M₂) (m : ∀ i : Fin n, M i.succ) (x y : M 0) :
f (cons (x + y) m) = f (cons x m) + f (cons y m) := by
simp_rw [← update_cons_zero x m (x + y), f.map_add, update_cons_zero]
#align multilinear_map.cons_add MultilinearMap.cons_add
/-- In the specific case of multilinear maps on spaces indexed by `Fin (n+1)`, where one can build
an element of `∀ (i : Fin (n+1)), M i` using `cons`, one can express directly the multiplicativity
of a multilinear map along the first variable. -/
theorem cons_smul (f : MultilinearMap R M M₂) (m : ∀ i : Fin n, M i.succ) (c : R) (x : M 0) :
f (cons (c • x) m) = c • f (cons x m) := by
simp_rw [← update_cons_zero x m (c • x), f.map_smul, update_cons_zero]
#align multilinear_map.cons_smul MultilinearMap.cons_smul
/-- In the specific case of multilinear maps on spaces indexed by `Fin (n+1)`, where one can build
an element of `∀ (i : Fin (n+1)), M i` using `snoc`, one can express directly the additivity of a
multilinear map along the first variable. -/
theorem snoc_add (f : MultilinearMap R M M₂)
(m : ∀ i : Fin n, M (castSucc i)) (x y : M (last n)) :
f (snoc m (x + y)) = f (snoc m x) + f (snoc m y) := by
simp_rw [← update_snoc_last x m (x + y), f.map_add, update_snoc_last]
#align multilinear_map.snoc_add MultilinearMap.snoc_add
/-- In the specific case of multilinear maps on spaces indexed by `Fin (n+1)`, where one can build
an element of `∀ (i : Fin (n+1)), M i` using `cons`, one can express directly the multiplicativity
of a multilinear map along the first variable. -/
theorem snoc_smul (f : MultilinearMap R M M₂) (m : ∀ i : Fin n, M (castSucc i)) (c : R)
(x : M (last n)) : f (snoc m (c • x)) = c • f (snoc m x) := by
simp_rw [← update_snoc_last x m (c • x), f.map_smul, update_snoc_last]
#align multilinear_map.snoc_smul MultilinearMap.snoc_smul
section
variable {M₁' : ι → Type*} [∀ i, AddCommMonoid (M₁' i)] [∀ i, Module R (M₁' i)]
variable {M₁'' : ι → Type*} [∀ i, AddCommMonoid (M₁'' i)] [∀ i, Module R (M₁'' i)]
/-- If `g` is a multilinear map and `f` is a collection of linear maps,
then `g (f₁ m₁, ..., fₙ mₙ)` is again a multilinear map, that we call
`g.compLinearMap f`. -/
def compLinearMap (g : MultilinearMap R M₁' M₂) (f : ∀ i, M₁ i →ₗ[R] M₁' i) : MultilinearMap R M₁ M₂
where
toFun m := g fun i => f i (m i)
map_add' m i x y := by
have : ∀ j z, f j (update m i z j) = update (fun k => f k (m k)) i (f i z) j := fun j z =>
Function.apply_update (fun k => f k) _ _ _ _
simp [this]
map_smul' m i c x := by
have : ∀ j z, f j (update m i z j) = update (fun k => f k (m k)) i (f i z) j := fun j z =>
Function.apply_update (fun k => f k) _ _ _ _
simp [this]
#align multilinear_map.comp_linear_map MultilinearMap.compLinearMap
@[simp]
theorem compLinearMap_apply (g : MultilinearMap R M₁' M₂) (f : ∀ i, M₁ i →ₗ[R] M₁' i)
(m : ∀ i, M₁ i) : g.compLinearMap f m = g fun i => f i (m i) :=
rfl
#align multilinear_map.comp_linear_map_apply MultilinearMap.compLinearMap_apply
/-- Composing a multilinear map twice with a linear map in each argument is
the same as composing with their composition. -/
theorem compLinearMap_assoc (g : MultilinearMap R M₁'' M₂) (f₁ : ∀ i, M₁' i →ₗ[R] M₁'' i)
(f₂ : ∀ i, M₁ i →ₗ[R] M₁' i) :
(g.compLinearMap f₁).compLinearMap f₂ = g.compLinearMap fun i => f₁ i ∘ₗ f₂ i :=
rfl
#align multilinear_map.comp_linear_map_assoc MultilinearMap.compLinearMap_assoc
/-- Composing the zero multilinear map with a linear map in each argument. -/
@[simp]
theorem zero_compLinearMap (f : ∀ i, M₁ i →ₗ[R] M₁' i) :
(0 : MultilinearMap R M₁' M₂).compLinearMap f = 0 :=
ext fun _ => rfl
#align multilinear_map.zero_comp_linear_map MultilinearMap.zero_compLinearMap
/-- Composing a multilinear map with the identity linear map in each argument. -/
@[simp]
theorem compLinearMap_id (g : MultilinearMap R M₁' M₂) :
(g.compLinearMap fun _ => LinearMap.id) = g :=
ext fun _ => rfl
#align multilinear_map.comp_linear_map_id MultilinearMap.compLinearMap_id
/-- Composing with a family of surjective linear maps is injective. -/
theorem compLinearMap_injective (f : ∀ i, M₁ i →ₗ[R] M₁' i) (hf : ∀ i, Surjective (f i)) :
Injective fun g : MultilinearMap R M₁' M₂ => g.compLinearMap f := fun g₁ g₂ h =>
ext fun x => by
simpa [fun i => surjInv_eq (hf i)] using ext_iff.mp h fun i => surjInv (hf i) (x i)
#align multilinear_map.comp_linear_map_injective MultilinearMap.compLinearMap_injective
theorem compLinearMap_inj (f : ∀ i, M₁ i →ₗ[R] M₁' i) (hf : ∀ i, Surjective (f i))
(g₁ g₂ : MultilinearMap R M₁' M₂) : g₁.compLinearMap f = g₂.compLinearMap f ↔ g₁ = g₂ :=
(compLinearMap_injective _ hf).eq_iff
#align multilinear_map.comp_linear_map_inj MultilinearMap.compLinearMap_inj
/-- Composing a multilinear map with a linear equiv on each argument gives the zero map
if and only if the multilinear map is the zero map. -/
@[simp]
theorem comp_linearEquiv_eq_zero_iff (g : MultilinearMap R M₁' M₂) (f : ∀ i, M₁ i ≃ₗ[R] M₁' i) :
(g.compLinearMap fun i => (f i : M₁ i →ₗ[R] M₁' i)) = 0 ↔ g = 0 := by
set f' := fun i => (f i : M₁ i →ₗ[R] M₁' i)
rw [← zero_compLinearMap f', compLinearMap_inj f' fun i => (f i).surjective]
#align multilinear_map.comp_linear_equiv_eq_zero_iff MultilinearMap.comp_linearEquiv_eq_zero_iff
end
/-- If one adds to a vector `m'` another vector `m`, but only for coordinates in a finset `t`, then
the image under a multilinear map `f` is the sum of `f (s.piecewise m m')` along all subsets `s` of
`t`. This is mainly an auxiliary statement to prove the result when `t = univ`, given in
`map_add_univ`, although it can be useful in its own right as it does not require the index set `ι`
to be finite. -/
theorem map_piecewise_add [DecidableEq ι] (m m' : ∀ i, M₁ i) (t : Finset ι) :
f (t.piecewise (m + m') m') = ∑ s in t.powerset, f (s.piecewise m m') := by
revert m'
refine' Finset.induction_on t (by simp) _
intro i t hit Hrec m'
have A : (insert i t).piecewise (m + m') m' = update (t.piecewise (m + m') m') i (m i + m' i) :=
t.piecewise_insert _ _ _
have B : update (t.piecewise (m + m') m') i (m' i) = t.piecewise (m + m') m' := by
ext j
by_cases h : j = i
· rw [h]
simp [hit]
· simp [h]
let m'' := update m' i (m i)
have C : update (t.piecewise (m + m') m') i (m i) = t.piecewise (m + m'') m'' := by
ext j
by_cases h : j = i
· rw [h]
simp [m'', hit]
· by_cases h' : j ∈ t <;> simp [m'', h, hit, h']
rw [A, f.map_add, B, C, Finset.sum_powerset_insert hit, Hrec, Hrec, add_comm (_ : M₂)]
congr 1
refine Finset.sum_congr rfl fun s hs => ?_
have : (insert i s).piecewise m m' = s.piecewise m m'' := by
ext j
by_cases h : j = i
· rw [h]
simp [m'', Finset.not_mem_of_mem_powerset_of_not_mem hs hit]
· by_cases h' : j ∈ s <;> simp [m'', h, h']
rw [this]
#align multilinear_map.map_piecewise_add MultilinearMap.map_piecewise_add
/-- Additivity of a multilinear map along all coordinates at the same time,
writing `f (m + m')` as the sum of `f (s.piecewise m m')` over all sets `s`. -/
theorem map_add_univ [DecidableEq ι] [Fintype ι] (m m' : ∀ i, M₁ i) :
f (m + m') = ∑ s : Finset ι, f (s.piecewise m m') := by
simpa using f.map_piecewise_add m m' Finset.univ
#align multilinear_map.map_add_univ MultilinearMap.map_add_univ
section ApplySum
variable {α : ι → Type*} (g : ∀ i, α i → M₁ i) (A : ∀ i, Finset (α i))
open Fintype Finset
/-- If `f` is multilinear, then `f (Σ_{j₁ ∈ A₁} g₁ j₁, ..., Σ_{jₙ ∈ Aₙ} gₙ jₙ)` is the sum of
`f (g₁ (r 1), ..., gₙ (r n))` where `r` ranges over all functions with `r 1 ∈ A₁`, ...,
`r n ∈ Aₙ`. This follows from multilinearity by expanding successively with respect to each
coordinate. Here, we give an auxiliary statement tailored for an inductive proof. Use instead
`map_sum_finset`. -/
theorem map_sum_finset_aux [DecidableEq ι] [Fintype ι] {n : ℕ} (h : (∑ i, (A i).card) = n) :
(f fun i => ∑ j in A i, g i j) = ∑ r in piFinset A, f fun i => g i (r i) := by
letI := fun i => Classical.decEq (α i)
induction' n using Nat.strong_induction_on with n IH generalizing A
-- If one of the sets is empty, then all the sums are zero
by_cases Ai_empty : ∃ i, A i = ∅
· rcases Ai_empty with ⟨i, hi⟩
have : ∑ j in A i, g i j = 0 := by rw [hi, Finset.sum_empty]
rw [f.map_coord_zero i this]
have : piFinset A = ∅ := by
refine Finset.eq_empty_of_forall_not_mem fun r hr => ?_
have : r i ∈ A i := mem_piFinset.mp hr i
simp [hi] at this
rw [this, Finset.sum_empty]
push_neg at Ai_empty
-- Otherwise, if all sets are at most singletons, then they are exactly singletons and the result
-- is again straightforward
by_cases Ai_singleton : ∀ i, (A i).card ≤ 1
· have Ai_card : ∀ i, (A i).card = 1 := by
intro i
have pos : Finset.card (A i) ≠ 0 := by simp [Finset.card_eq_zero, Ai_empty i]
have : Finset.card (A i) ≤ 1 := Ai_singleton i
exact le_antisymm this (Nat.succ_le_of_lt (_root_.pos_iff_ne_zero.mpr pos))
have :
∀ r : ∀ i, α i, r ∈ piFinset A → (f fun i => g i (r i)) = f fun i => ∑ j in A i, g i j := by
intro r hr
congr with i
have : ∀ j ∈ A i, g i j = g i (r i) := by
intro j hj
congr
apply Finset.card_le_one_iff.1 (Ai_singleton i) hj
exact mem_piFinset.mp hr i
simp only [Finset.sum_congr rfl this, Finset.mem_univ, Finset.sum_const, Ai_card i, one_nsmul]
simp only [Finset.sum_congr rfl this, Ai_card, card_piFinset, prod_const_one, one_nsmul,
Finset.sum_const]
-- Remains the interesting case where one of the `A i`, say `A i₀`, has cardinality at least 2.
-- We will split into two parts `B i₀` and `C i₀` of smaller cardinality, let `B i = C i = A i`
-- for `i ≠ i₀`, apply the inductive assumption to `B` and `C`, and add up the corresponding
-- parts to get the sum for `A`.
push_neg at Ai_singleton
obtain ⟨i₀, hi₀⟩ : ∃ i, 1 < (A i).card := Ai_singleton
obtain ⟨j₁, j₂, _, hj₂, _⟩ : ∃ j₁ j₂, j₁ ∈ A i₀ ∧ j₂ ∈ A i₀ ∧ j₁ ≠ j₂ :=
Finset.one_lt_card_iff.1 hi₀
let B := Function.update A i₀ (A i₀ \ {j₂})
let C := Function.update A i₀ {j₂}
have B_subset_A : ∀ i, B i ⊆ A i := by
intro i
by_cases hi : i = i₀
· rw [hi]
simp only [B, sdiff_subset, update_same]
· simp only [B, hi, update_noteq, Ne, not_false_iff, Finset.Subset.refl]
have C_subset_A : ∀ i, C i ⊆ A i := by
intro i
by_cases hi : i = i₀
· rw [hi]
simp only [C, hj₂, Finset.singleton_subset_iff, update_same]
· simp only [C, hi, update_noteq, Ne, not_false_iff, Finset.Subset.refl]
-- split the sum at `i₀` as the sum over `B i₀` plus the sum over `C i₀`, to use additivity.
have A_eq_BC :
(fun i => ∑ j in A i, g i j) =
Function.update (fun i => ∑ j in A i, g i j) i₀
((∑ j in B i₀, g i₀ j) + ∑ j in C i₀, g i₀ j) := by
ext i
by_cases hi : i = i₀
· rw [hi, update_same]
have : A i₀ = B i₀ ∪ C i₀ := by
simp only [B, C, Function.update_same, Finset.sdiff_union_self_eq_union]
symm
simp only [hj₂, Finset.singleton_subset_iff, Finset.union_eq_left]
rw [this]
refine Finset.sum_union <| Finset.disjoint_right.2 fun j hj => ?_
have : j = j₂ := by
simpa [C] using hj
rw [this]
simp only [B, mem_sdiff, eq_self_iff_true, not_true, not_false_iff, Finset.mem_singleton,
update_same, and_false_iff]
· simp [hi]
have Beq :
Function.update (fun i => ∑ j in A i, g i j) i₀ (∑ j in B i₀, g i₀ j) = fun i =>
∑ j in B i, g i j := by
ext i
by_cases hi : i = i₀
· rw [hi]
simp only [update_same]
· simp only [B, hi, update_noteq, Ne, not_false_iff]
have Ceq :
Function.update (fun i => ∑ j in A i, g i j) i₀ (∑ j in C i₀, g i₀ j) = fun i =>
∑ j in C i, g i j := by
ext i
by_cases hi : i = i₀
· rw [hi]
simp only [update_same]
· simp only [C, hi, update_noteq, Ne, not_false_iff]
-- Express the inductive assumption for `B`
have Brec : (f fun i => ∑ j in B i, g i j) = ∑ r in piFinset B, f fun i => g i (r i) := by
have : (∑ i, Finset.card (B i)) < ∑ i, Finset.card (A i) := by
refine'
Finset.sum_lt_sum (fun i _ => Finset.card_le_card (B_subset_A i))
⟨i₀, Finset.mem_univ _, _⟩
have : {j₂} ⊆ A i₀ := by simp [hj₂]
simp only [B, Finset.card_sdiff this, Function.update_same, Finset.card_singleton]
exact Nat.pred_lt (ne_of_gt (lt_trans Nat.zero_lt_one hi₀))
rw [h] at this
exact IH _ this B rfl
-- Express the inductive assumption for `C`
have Crec : (f fun i => ∑ j in C i, g i j) = ∑ r in piFinset C, f fun i => g i (r i) := by
have : (∑ i, Finset.card (C i)) < ∑ i, Finset.card (A i) :=
Finset.sum_lt_sum (fun i _ => Finset.card_le_card (C_subset_A i))
⟨i₀, Finset.mem_univ _, by simp [C, hi₀]⟩
rw [h] at this
exact IH _ this C rfl
have D : Disjoint (piFinset B) (piFinset C) :=
haveI : Disjoint (B i₀) (C i₀) := by simp [B, C]
piFinset_disjoint_of_disjoint B C this
have pi_BC : piFinset A = piFinset B ∪ piFinset C := by
apply Finset.Subset.antisymm
· intro r hr
by_cases hri₀ : r i₀ = j₂
· apply Finset.mem_union_right
refine mem_piFinset.2 fun i => ?_
by_cases hi : i = i₀
· have : r i₀ ∈ C i₀ := by simp [C, hri₀]
rwa [hi]
· simp [C, hi, mem_piFinset.1 hr i]
· apply Finset.mem_union_left
refine mem_piFinset.2 fun i => ?_
by_cases hi : i = i₀
· have : r i₀ ∈ B i₀ := by simp [B, hri₀, mem_piFinset.1 hr i₀]
rwa [hi]
· simp [B, hi, mem_piFinset.1 hr i]
· exact
Finset.union_subset (piFinset_subset _ _ fun i => B_subset_A i)
(piFinset_subset _ _ fun i => C_subset_A i)
rw [A_eq_BC]
simp only [MultilinearMap.map_add, Beq, Ceq, Brec, Crec, pi_BC]
rw [← Finset.sum_union D]
#align multilinear_map.map_sum_finset_aux MultilinearMap.map_sum_finset_aux
/-- If `f` is multilinear, then `f (Σ_{j₁ ∈ A₁} g₁ j₁, ..., Σ_{jₙ ∈ Aₙ} gₙ jₙ)` is the sum of
`f (g₁ (r 1), ..., gₙ (r n))` where `r` ranges over all functions with `r 1 ∈ A₁`, ...,
`r n ∈ Aₙ`. This follows from multilinearity by expanding successively with respect to each
coordinate. -/
theorem map_sum_finset [DecidableEq ι] [Fintype ι] :
(f fun i => ∑ j in A i, g i j) = ∑ r in piFinset A, f fun i => g i (r i) :=
f.map_sum_finset_aux _ _ rfl
#align multilinear_map.map_sum_finset MultilinearMap.map_sum_finset
/-- If `f` is multilinear, then `f (Σ_{j₁} g₁ j₁, ..., Σ_{jₙ} gₙ jₙ)` is the sum of
`f (g₁ (r 1), ..., gₙ (r n))` where `r` ranges over all functions `r`. This follows from
multilinearity by expanding successively with respect to each coordinate. -/
theorem map_sum [DecidableEq ι] [Fintype ι] [∀ i, Fintype (α i)] :
(f fun i => ∑ j, g i j) = ∑ r : ∀ i, α i, f fun i => g i (r i) :=
f.map_sum_finset g fun _ => Finset.univ
#align multilinear_map.map_sum MultilinearMap.map_sum
theorem map_update_sum {α : Type*} [DecidableEq ι] (t : Finset α) (i : ι) (g : α → M₁ i)
(m : ∀ i, M₁ i) : f (update m i (∑ a in t, g a)) = ∑ a in t, f (update m i (g a)) := by
classical
induction' t using Finset.induction with a t has ih h
· simp
· simp [Finset.sum_insert has, ih]
#align multilinear_map.map_update_sum MultilinearMap.map_update_sum
end ApplySum
/-- Restrict the codomain of a multilinear map to a submodule.
This is the multilinear version of `LinearMap.codRestrict`. -/
@[simps]
def codRestrict (f : MultilinearMap R M₁ M₂) (p : Submodule R M₂) (h : ∀ v, f v ∈ p) :
MultilinearMap R M₁ p where
toFun v := ⟨f v, h v⟩
map_add' _ _ _ _ := Subtype.ext <| MultilinearMap.map_add _ _ _ _ _
map_smul' _ _ _ _ := Subtype.ext <| MultilinearMap.map_smul _ _ _ _ _
#align multilinear_map.cod_restrict MultilinearMap.codRestrict
#align multilinear_map.cod_restrict_apply_coe MultilinearMap.codRestrict_apply_coe
section RestrictScalar
variable (R)
variable {A : Type*} [Semiring A] [SMul R A] [∀ i : ι, Module A (M₁ i)] [Module A M₂]
[∀ i, IsScalarTower R A (M₁ i)] [IsScalarTower R A M₂]
/-- Reinterpret an `A`-multilinear map as an `R`-multilinear map, if `A` is an algebra over `R`
and their actions on all involved modules agree with the action of `R` on `A`. -/
def restrictScalars (f : MultilinearMap A M₁ M₂) : MultilinearMap R M₁ M₂ where
toFun := f
map_add' := f.map_add
map_smul' m i := (f.toLinearMap m i).map_smul_of_tower
#align multilinear_map.restrict_scalars MultilinearMap.restrictScalars
@[simp]
theorem coe_restrictScalars (f : MultilinearMap A M₁ M₂) : ⇑(f.restrictScalars R) = f :=
rfl
#align multilinear_map.coe_restrict_scalars MultilinearMap.coe_restrictScalars
end RestrictScalar
section
variable {ι₁ ι₂ ι₃ : Type*}
/-- Transfer the arguments to a map along an equivalence between argument indices.
The naming is derived from `Finsupp.domCongr`, noting that here the permutation applies to the
domain of the domain. -/
@[simps apply]
def domDomCongr (σ : ι₁ ≃ ι₂) (m : MultilinearMap R (fun _ : ι₁ => M₂) M₃) :
MultilinearMap R (fun _ : ι₂ => M₂) M₃ where
toFun v := m fun i => v (σ i)
map_add' v i a b := by
letI := σ.injective.decidableEq
simp_rw [Function.update_apply_equiv_apply v]
rw [m.map_add]
map_smul' v i a b := by
letI := σ.injective.decidableEq
simp_rw [Function.update_apply_equiv_apply v]
rw [m.map_smul]
#align multilinear_map.dom_dom_congr MultilinearMap.domDomCongr
#align multilinear_map.dom_dom_congr_apply MultilinearMap.domDomCongr_apply
theorem domDomCongr_trans (σ₁ : ι₁ ≃ ι₂) (σ₂ : ι₂ ≃ ι₃)
(m : MultilinearMap R (fun _ : ι₁ => M₂) M₃) :
m.domDomCongr (σ₁.trans σ₂) = (m.domDomCongr σ₁).domDomCongr σ₂ :=
rfl
#align multilinear_map.dom_dom_congr_trans MultilinearMap.domDomCongr_trans
theorem domDomCongr_mul (σ₁ : Equiv.Perm ι₁) (σ₂ : Equiv.Perm ι₁)
(m : MultilinearMap R (fun _ : ι₁ => M₂) M₃) :
m.domDomCongr (σ₂ * σ₁) = (m.domDomCongr σ₁).domDomCongr σ₂ :=
rfl
#align multilinear_map.dom_dom_congr_mul MultilinearMap.domDomCongr_mul
/-- `MultilinearMap.domDomCongr` as an equivalence.
This is declared separately because it does not work with dot notation. -/
@[simps apply symm_apply]
def domDomCongrEquiv (σ : ι₁ ≃ ι₂) :
MultilinearMap R (fun _ : ι₁ => M₂) M₃ ≃+ MultilinearMap R (fun _ : ι₂ => M₂) M₃ where
toFun := domDomCongr σ
invFun := domDomCongr σ.symm
left_inv m := by
ext
simp [domDomCongr]
right_inv m := by
ext
simp [domDomCongr]
map_add' a b := by
ext
simp [domDomCongr]
#align multilinear_map.dom_dom_congr_equiv MultilinearMap.domDomCongrEquiv
#align multilinear_map.dom_dom_congr_equiv_apply MultilinearMap.domDomCongrEquiv_apply
#align multilinear_map.dom_dom_congr_equiv_symm_apply MultilinearMap.domDomCongrEquiv_symm_apply
/-- The results of applying `domDomCongr` to two maps are equal if
and only if those maps are. -/
@[simp]
theorem domDomCongr_eq_iff (σ : ι₁ ≃ ι₂) (f g : MultilinearMap R (fun _ : ι₁ => M₂) M₃) :
f.domDomCongr σ = g.domDomCongr σ ↔ f = g :=
(domDomCongrEquiv σ : _ ≃+ MultilinearMap R (fun _ => M₂) M₃).apply_eq_iff_eq
#align multilinear_map.dom_dom_congr_eq_iff MultilinearMap.domDomCongr_eq_iff
end
/-! If `{a // P a}` is a subtype of `ι` and if we fix an element `z` of `(i : {a // ¬ P a}) → M₁ i`,
then a multilinear map on `M₁` defines a multilinear map on the restriction of `M₁` to
`{a // P a}`, by fixing the arguments out of `{a // P a}` equal to the values of `z`. -/
lemma domDomRestrict_aux [DecidableEq ι] (P : ι → Prop) [DecidablePred P]
[DecidableEq {a // P a}]
(x : (i : {a // P a}) → M₁ i) (z : (i : {a // ¬ P a}) → M₁ i) (i : {a : ι // P a})
(c : M₁ i) : (fun j ↦ if h : P j then Function.update x i c ⟨j, h⟩ else z ⟨j, h⟩) =
Function.update (fun j => if h : P j then x ⟨j, h⟩ else z ⟨j, h⟩) i c := by
ext j
by_cases h : j = i
· rw [h, Function.update_same]
simp only [i.2, update_same, dite_true]
· rw [Function.update_noteq h]
by_cases h' : P j
· simp only [h', ne_eq, Subtype.mk.injEq, dite_true]
have h'' : ¬ ⟨j, h'⟩ = i :=
fun he => by apply_fun (fun x => x.1) at he; exact h he
rw [Function.update_noteq h'']
· simp only [h', ne_eq, Subtype.mk.injEq, dite_false]
lemma domDomRestrict_aux_right [DecidableEq ι] (P : ι → Prop) [DecidablePred P]
[DecidableEq {a // ¬ P a}]
(x : (i : {a // P a}) → M₁ i) (z : (i : {a // ¬ P a}) → M₁ i) (i : {a : ι // ¬ P a})
(c : M₁ i) : (fun j ↦ if h : P j then x ⟨j, h⟩ else Function.update z i c ⟨j, h⟩) =
Function.update (fun j => if h : P j then x ⟨j, h⟩ else z ⟨j, h⟩) i c := by
simpa only [dite_not] using domDomRestrict_aux _ z (fun j ↦ x ⟨j.1, not_not.mp j.2⟩) i c
/-- Given a multilinear map `f` on `(i : ι) → M i`, a (decidable) predicate `P` on `ι` and
an element `z` of `(i : {a // ¬ P a}) → M₁ i`, construct a multilinear map on
`(i : {a // P a}) → M₁ i)` whose value at `x` is `f` evaluated at the vector with `i`th coordinate
`x i` if `P i` and `z i` otherwise.
The naming is similar to `MultilinearMap.domDomCongr`: here we are applying the restriction to the
domain of the domain.
For a linear map version, see `MultilinearMap.domDomRestrictₗ`.
-/
def domDomRestrict (f : MultilinearMap R M₁ M₂) (P : ι → Prop) [DecidablePred P]
(z : (i : {a : ι // ¬ P a}) → M₁ i) :
MultilinearMap R (fun (i : {a : ι // P a}) => M₁ i) M₂ where
toFun x := f (fun j ↦ if h : P j then x ⟨j, h⟩ else z ⟨j, h⟩)
map_add' x i a b := by
classical
simp only
repeat (rw [domDomRestrict_aux])
simp only [MultilinearMap.map_add]
map_smul' z i c a := by
classical
simp only
repeat (rw [domDomRestrict_aux])
simp only [MultilinearMap.map_smul]
@[simp]
lemma domDomRestrict_apply (f : MultilinearMap R M₁ M₂) (P : ι → Prop)
[DecidablePred P] (x : (i : {a // P a}) → M₁ i) (z : (i : {a // ¬ P a}) → M₁ i) :
f.domDomRestrict P z x = f (fun j => if h : P j then x ⟨j, h⟩ else z ⟨j, h⟩) := rfl
-- TODO: Should add a ref here when available.
/-- The "derivative" of a multilinear map, as a linear map from `(i : ι) → M₁ i` to `M₂`.
For continuous multilinear maps, this will indeed be the derivative. -/
def linearDeriv [DecidableEq ι] [Fintype ι] (f : MultilinearMap R M₁ M₂)
(x : (i : ι) → M₁ i) : ((i : ι) → M₁ i) →ₗ[R] M₂ :=
∑ i : ι, (f.toLinearMap x i).comp (LinearMap.proj i)
@[simp]
lemma linearDeriv_apply [DecidableEq ι] [Fintype ι] (f : MultilinearMap R M₁ M₂)
(x y : (i : ι) → M₁ i) :
f.linearDeriv x y = ∑ i, f (update x i (y i)) := by
unfold linearDeriv
simp only [LinearMap.coeFn_sum, LinearMap.coe_comp, LinearMap.coe_proj, Finset.sum_apply,
Function.comp_apply, Function.eval, toLinearMap_apply]
end Semiring
end MultilinearMap
namespace LinearMap
variable [Semiring R] [∀ i, AddCommMonoid (M₁ i)] [AddCommMonoid M₂] [AddCommMonoid M₃]
[AddCommMonoid M'] [∀ i, Module R (M₁ i)] [Module R M₂] [Module R M₃] [Module R M']
/-- Composing a multilinear map with a linear map gives again a multilinear map. -/
def compMultilinearMap (g : M₂ →ₗ[R] M₃) (f : MultilinearMap R M₁ M₂) : MultilinearMap R M₁ M₃ where
toFun := g ∘ f
map_add' m i x y := by simp
map_smul' m i c x := by simp
#align linear_map.comp_multilinear_map LinearMap.compMultilinearMap
@[simp]
theorem coe_compMultilinearMap (g : M₂ →ₗ[R] M₃) (f : MultilinearMap R M₁ M₂) :
⇑(g.compMultilinearMap f) = g ∘ f :=
rfl
#align linear_map.coe_comp_multilinear_map LinearMap.coe_compMultilinearMap
@[simp]
theorem compMultilinearMap_apply (g : M₂ →ₗ[R] M₃) (f : MultilinearMap R M₁ M₂) (m : ∀ i, M₁ i) :
g.compMultilinearMap f m = g (f m) :=
rfl
#align linear_map.comp_multilinear_map_apply LinearMap.compMultilinearMap_apply
/-- The multilinear version of `LinearMap.subtype_comp_codRestrict` -/
@[simp]
theorem subtype_compMultilinearMap_codRestrict (f : MultilinearMap R M₁ M₂) (p : Submodule R M₂)
(h) : p.subtype.compMultilinearMap (f.codRestrict p h) = f :=
MultilinearMap.ext fun _ => rfl
#align linear_map.subtype_comp_multilinear_map_cod_restrict LinearMap.subtype_compMultilinearMap_codRestrict
/-- The multilinear version of `LinearMap.comp_codRestrict` -/
@[simp]
theorem compMultilinearMap_codRestrict (g : M₂ →ₗ[R] M₃) (f : MultilinearMap R M₁ M₂)
(p : Submodule R M₃) (h) :
(g.codRestrict p h).compMultilinearMap f =
(g.compMultilinearMap f).codRestrict p fun v => h (f v) :=
MultilinearMap.ext fun _ => rfl
#align linear_map.comp_multilinear_map_cod_restrict LinearMap.compMultilinearMap_codRestrict
variable {ι₁ ι₂ : Type*}
@[simp]
theorem compMultilinearMap_domDomCongr (σ : ι₁ ≃ ι₂) (g : M₂ →ₗ[R] M₃)
(f : MultilinearMap R (fun _ : ι₁ => M') M₂) :
(g.compMultilinearMap f).domDomCongr σ = g.compMultilinearMap (f.domDomCongr σ) := by
ext
simp [MultilinearMap.domDomCongr]
#align linear_map.comp_multilinear_map_dom_dom_congr LinearMap.compMultilinearMap_domDomCongr
end LinearMap
namespace MultilinearMap
section Semiring
variable [Semiring R] [(i : ι) → AddCommMonoid (M₁ i)] [(i : ι) → Module R (M₁ i)]
[AddCommMonoid M₂] [Module R M₂]
instance [Monoid S] [DistribMulAction S M₂] [Module R M₂] [SMulCommClass R S M₂] :
DistribMulAction S (MultilinearMap R M₁ M₂) :=
coe_injective.distribMulAction coeAddMonoidHom fun _ _ ↦ rfl
section Module
variable [Semiring S] [Module S M₂] [SMulCommClass R S M₂]
/-- The space of multilinear maps over an algebra over `R` is a module over `R`, for the pointwise
addition and scalar multiplication. -/
instance : Module S (MultilinearMap R M₁ M₂) :=
coe_injective.module _ coeAddMonoidHom fun _ _ ↦ rfl
instance [NoZeroSMulDivisors S M₂] : NoZeroSMulDivisors S (MultilinearMap R M₁ M₂) :=
coe_injective.noZeroSMulDivisors _ rfl coe_smul
variable (R S M₁ M₂ M₃)
section OfSubsingleton
variable [AddCommMonoid M₃] [Module S M₃] [Module R M₃] [SMulCommClass R S M₃]
/-- Linear equivalence between linear maps `M₂ →ₗ[R] M₃`
and one-multilinear maps `MultilinearMap R (fun _ : ι ↦ M₂) M₃`. -/
@[simps (config := { simpRhs := true })]
def ofSubsingletonₗ [Subsingleton ι] (i : ι) :
(M₂ →ₗ[R] M₃) ≃ₗ[S] MultilinearMap R (fun _ : ι ↦ M₂) M₃ :=
{ ofSubsingleton R M₂ M₃ i with
map_add' := fun _ _ ↦ rfl
map_smul' := fun _ _ ↦ rfl }
end OfSubsingleton
/-- The dependent version of `MultilinearMap.domDomCongrLinearEquiv`. -/
@[simps apply symm_apply]
def domDomCongrLinearEquiv' {ι' : Type*} (σ : ι ≃ ι') :
MultilinearMap R M₁ M₂ ≃ₗ[S] MultilinearMap R (fun i => M₁ (σ.symm i)) M₂ where
toFun f :=
{ toFun := f ∘ (σ.piCongrLeft' M₁).symm
map_add' := fun m i => by
letI := σ.decidableEq
rw [← σ.apply_symm_apply i]
intro x y
simp only [comp_apply, piCongrLeft'_symm_update, f.map_add]
map_smul' := fun m i c => by
letI := σ.decidableEq
rw [← σ.apply_symm_apply i]
intro x
simp only [Function.comp, piCongrLeft'_symm_update, f.map_smul] }
invFun f :=
{ toFun := f ∘ σ.piCongrLeft' M₁
map_add' := fun m i => by
letI := σ.symm.decidableEq
rw [← σ.symm_apply_apply i]
intro x y
simp only [comp_apply, piCongrLeft'_update, f.map_add]
map_smul' := fun m i c => by
letI := σ.symm.decidableEq
rw [← σ.symm_apply_apply i]
intro x
simp only [Function.comp, piCongrLeft'_update, f.map_smul] }
map_add' f₁ f₂ := by
ext
simp only [Function.comp, coe_mk, add_apply]
map_smul' c f := by
ext
simp only [Function.comp, coe_mk, smul_apply, RingHom.id_apply]
left_inv f := by
ext
simp only [coe_mk, comp_apply, Equiv.symm_apply_apply]
right_inv f := by
ext
simp only [coe_mk, comp_apply, Equiv.apply_symm_apply]
#align multilinear_map.dom_dom_congr_linear_equiv' MultilinearMap.domDomCongrLinearEquiv'
#align multilinear_map.dom_dom_congr_linear_equiv'_apply MultilinearMap.domDomCongrLinearEquiv'_apply
#align multilinear_map.dom_dom_congr_linear_equiv'_symm_apply MultilinearMap.domDomCongrLinearEquiv'_symm_apply
/-- The space of constant maps is equivalent to the space of maps that are multilinear with respect
to an empty family. -/
@[simps]
def constLinearEquivOfIsEmpty [IsEmpty ι] : M₂ ≃ₗ[S] MultilinearMap R M₁ M₂ where
toFun := MultilinearMap.constOfIsEmpty R _
map_add' _ _ := rfl
map_smul' _ _ := rfl
invFun f := f 0
left_inv _ := rfl
right_inv f := ext fun _ => MultilinearMap.congr_arg f <| Subsingleton.elim _ _
#align multilinear_map.const_linear_equiv_of_is_empty MultilinearMap.constLinearEquivOfIsEmpty
#align multilinear_map.const_linear_equiv_of_is_empty_apply_to_add_hom_apply MultilinearMap.constLinearEquivOfIsEmpty_apply
#align multilinear_map.const_linear_equiv_of_is_empty_apply_to_add_hom_symm_apply MultilinearMap.constLinearEquivOfIsEmpty_symm_apply
variable [AddCommMonoid M₃] [Module R M₃] [Module S M₃] [SMulCommClass R S M₃]
/-- `MultilinearMap.domDomCongr` as a `LinearEquiv`. -/
@[simps apply symm_apply]
def domDomCongrLinearEquiv {ι₁ ι₂} (σ : ι₁ ≃ ι₂) :
MultilinearMap R (fun _ : ι₁ => M₂) M₃ ≃ₗ[S] MultilinearMap R (fun _ : ι₂ => M₂) M₃ :=
{ (domDomCongrEquiv σ :
MultilinearMap R (fun _ : ι₁ => M₂) M₃ ≃+ MultilinearMap R (fun _ : ι₂ => M₂) M₃) with
map_smul' := fun c f => by
ext
simp [MultilinearMap.domDomCongr] }