forked from HoTT/Coq-HoTT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FreeMonoidalCategory.v
1086 lines (1001 loc) · 32.7 KB
/
FreeMonoidalCategory.v
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
Require Import Basics Types.Forall Types.Paths WildCat.
Require Import WildCat.Bifunctor WildCat.TwoOneCat.
Require Import Spaces.List Classes.implementations.list.
Import ListNotations.
Local Open Scope list_scope.
(** The free monoidal category generated by a type. This is in fact a groupoid, so we axiomatize it as such. *)
Inductive FMC {X : Type} : Type :=
(** Elements of the generating set *)
| el : X -> FMC
(** Tensor unit *)
| unit : FMC
(** Tensor product *)
| tensor : FMC -> FMC -> FMC
.
Arguments FMC X : clear implicits.
Inductive HomFMC {X : Type} : FMC X -> FMC X -> Type :=
(** Identity morphism *)
| id x : HomFMC x x
(** Composition of morphisms *)
| comp {x y z} : HomFMC y z -> HomFMC x y -> HomFMC x z
(** Inversion of morphisms *)
| rev {x y} : HomFMC x y -> HomFMC y x
(** Left unitor *)
| left_unitor x : HomFMC (tensor unit x) x
(** Right unitor *)
| right_unitor x : HomFMC (tensor x unit) x
(** Associator *)
| associator x y z : HomFMC (tensor x (tensor y z)) (tensor (tensor x y) z)
(** Functoriality of tensor *)
| tensor2 {x x' y y'} : HomFMC x y -> HomFMC x' y' -> HomFMC (tensor x x') (tensor y y')
.
Inductive Hom2FMC {X : Type} : forall {a b : FMC X}, HomFMC a b -> HomFMC a b -> Type :=
(** Identity 2-morphism *)
| id2 {x y} (f : HomFMC x y) : Hom2FMC f f
(** Composition of 2-morphisms *)
| comp2 {x y} {f g h : HomFMC x y} : Hom2FMC g h -> Hom2FMC f g -> Hom2FMC f h
(** Inversion of 2-morphisms *)
| rev2 {x y} {f g : HomFMC x y} : Hom2FMC f g -> Hom2FMC g f
(** Left whiskering *)
| wl {x y z} (g : HomFMC y z) {f h : HomFMC x y}
: Hom2FMC f h -> Hom2FMC (comp g f) (comp g h)
(** Right whiskering *)
| wr {x y z} (f : HomFMC x y) {g h : HomFMC y z}
: Hom2FMC g h -> Hom2FMC (comp g f) (comp h f)
(** Associativity of composition of morphsisms *)
| associator2 {w x y z} {f : HomFMC w x} {g : HomFMC x y} (h : HomFMC y z)
: Hom2FMC (comp (comp h g) f) (comp h (comp g f))
(** Left identity for composition of morphisms *)
| left_unitor2 {x y} {f : HomFMC x y} : Hom2FMC (comp (id _) f) f
(** Right identity for composition of morphisms *)
| right_unitor2 {x y} {f : HomFMC x y} : Hom2FMC (comp f (id _)) f
(** Left inversion law for composition of morphisms *)
| left_invertor2 {x y} (f : HomFMC x y) : Hom2FMC (comp (rev f) f) (id _)
(** Right inversion law for composition of morphisms *)
| right_invertor2 {x y} (f : HomFMC x y) : Hom2FMC (comp f (rev f)) (id _)
(** Triangle identity *)
| triangle {x y}
: Hom2FMC
(tensor2 (id x) (left_unitor y))
(comp (tensor2 (right_unitor x) (id y)) (associator x unit y))
(** Pentagon identity *)
| pentagon {w x y z}
: Hom2FMC
(comp (associator (tensor w x) y z) (associator w x (tensor y z)))
(comp
(comp (tensor2 (associator w x y) (id z)) (associator w (tensor x y) z))
(tensor2 (id w) (associator x y z)))
(** 2-functioriality of tensor *)
| tensor3 {x x' y y'} {f g : HomFMC x y} {f' g' : HomFMC x' y'}
: Hom2FMC f g -> Hom2FMC f' g' -> Hom2FMC (tensor2 f f') (tensor2 g g')
(** Tensor functor preserves identity morphism *)
| tensor2_id {x y} : Hom2FMC (tensor2 (id x) (id y)) (id (tensor x y))
(** Tensor functor preserves composition of morphisms *)
| tensor2_comp {x x' y y' z z'} {f : HomFMC x y} {f' : HomFMC x' y'}
{g : HomFMC y z} {g' : HomFMC y' z'}
: Hom2FMC (tensor2 (comp g f) (comp g' f')) (comp (tensor2 g g') (tensor2 f f'))
(** Naturality of left unitor *)
| isnat_left_unitor x y f
: Hom2FMC (comp (left_unitor y) (tensor2 (id unit) f)) (comp f (left_unitor x))
(** Naturality of right unitor *)
| isnat_right_unitor x y f
: Hom2FMC (comp (right_unitor y) (tensor2 f (id unit))) (comp f (right_unitor x))
(** Naturality of associator in left variable *)
| isnat_l_associator w x y z f
: Hom2FMC
(comp (associator y w x) (tensor2 f (id (tensor w x))))
(comp (tensor2 (tensor2 f (id w)) (id x)) (associator z w x))
(** Naturality of associator in middle variable *)
| isnat_m_associator w x y z f
: Hom2FMC
(comp (associator w y x) (tensor2 (id w) (tensor2 f (id x))))
(comp (tensor2 (tensor2 (id w) f) (id x)) (associator w z x))
(** Naturality of associator in right variable *)
| isnat_r_associator w x y z f
: Hom2FMC
(comp (associator w x y) (tensor2 (id w) (tensor2 (id x) f)))
(comp (tensor2 (id (tensor w x)) f) (associator w x z))
.
Global Instance isgraph_FMC {X : Type} : IsGraph (FMC X)
:= {| Hom := HomFMC; |}.
Global Instance is01cat_FMC {X : Type} : Is01Cat (FMC X)
:= {| Id := @id _; cat_comp := @comp _ |}.
Global Instance is2graph_FMC {X : Type} : Is2Graph (FMC X)
:= fun x y => {| Hom := Hom2FMC |}.
Global Instance is1cat_FMC {X : Type} : Is1Cat (FMC X).
Proof.
snrapply Build_Is1Cat.
- intros x y; snrapply Build_Is01Cat; revert X x y.
+ exact @id2.
+ exact @comp2.
- intros x y; snrapply Build_Is0Gpd; revert X x y.
exact @rev2.
- intros x y z g; snrapply Build_Is0Functor; revert X x y z g.
exact @wl.
- intros x y z f; snrapply Build_Is0Functor; revert X x y z f.
exact @wr.
- revert X.
exact @associator2.
- revert X.
exact @left_unitor2.
- revert X.
exact @right_unitor2.
Defined.
Global Instance is0gpd_FMC {X : Type} : Is0Gpd (FMC X).
Proof.
snrapply Build_Is0Gpd; revert X.
exact @rev.
Defined.
Global Instance is1gpd_FMC {X : Type} : Is1Gpd (FMC X).
Proof.
snrapply Build_Is1Gpd; revert X.
- exact @left_invertor2.
- exact @right_invertor2.
Defined.
Global Instance hasequivs_FMC {X : Type} : HasEquivs (FMC X) := hasequivs_1gpd _.
Global Instance is0bifunctor_tensor {X}
: Is0Bifunctor (@tensor X).
Proof.
rapply Build_Is0Bifunctor'.
snrapply Build_Is0Functor.
intros [w x] [y z] [f g].
exact (tensor2 f g).
Defined.
Global Instance is1bifunctor_tensor {X}
: Is1Bifunctor (@tensor X).
Proof.
snrapply Build_Is1Bifunctor'.
snrapply Build_Is1Functor.
- intros [w x] [y z] [f g] [h k] [p q].
exact (tensor3 p q).
- intros [w x].
exact tensor2_id.
- intros [x x'] [y y'] [z z'] [f f'] [g g'].
exact tensor2_comp.
Defined.
Global Instance is0functor_tensor' {X y}
: Is0Functor (flip (@tensor X) y).
Proof.
snrapply Build_Is0Functor.
intros x z.
exact (flip tensor2 (id y)).
Defined.
Definition left_unitor' {X} (x : FMC X)
: tensor unit x $<~> x.
Proof.
exact (left_unitor x).
Defined.
Global Instance leftunitor_FMC {X} : LeftUnitor (@tensor X) unit.
Proof.
snrapply Build_NatEquiv; revert X.
- exact @left_unitor'.
- exact @isnat_left_unitor.
Defined.
Definition right_unitor' {X} (x : FMC X)
: tensor x unit $<~> x.
Proof.
exact (right_unitor x).
Defined.
Global Instance rightunitor_FMC {X} : RightUnitor (@tensor X) unit.
Proof.
snrapply Build_NatEquiv; revert X.
- exact @right_unitor'.
- exact @isnat_right_unitor.
Defined.
Definition associator' {X} (x y z : FMC X)
: tensor x (tensor y z) $<~> tensor (tensor x y) z.
Proof.
exact (associator x y z).
Defined.
Global Instance associator_FMC {X} : Associator (@tensor X).
Proof.
snrapply Build_Associator.
1: exact associator'.
intros [[a b] c] [[a' b'] c'] [[f g] h]; cbn -[Hom] in * |-.
change (?w $o ?x $== ?y $o ?z) with (Square z w x y).
snrapply hconcat.
- exact (associator' a' b' c).
- cbn -[Square].
nrapply vconcatR.
1: nrapply hconcat.
1: apply isnat_l_associator.
1: apply isnat_m_associator.
nrefine (comp2 (tensor2_comp) (tensor3 (id2 _) _)).
apply rev2.
apply left_unitor2.
- apply isnat_r_associator.
Defined.
Global Instance triangleidentity_FMC {X} : TriangleIdentity (@tensor X) unit
:= @triangle X.
Global Instance pentagonidentity_FMC {X} : PentagonIdentity (@tensor X) unit
:= @pentagon X.
Global Instance ismonoidalcat_FMC {X} : IsMonoidal (FMC X) tensor unit := {}.
Definition tensor2' {X} {x x' y y'} (f : x $-> y) (f' : x' $-> y')
: tensor x x' $-> tensor y y'
:= tensor2 (X:=X) f f'.
Definition comp' {X} {x y z} (f : y $-> z) (g : x $-> y)
: x $-> z
:= comp (X:=X) f g.
(** Attempt at normalized free monoidal categories, might be too strict *)
Definition NFMC (X : Type) := list X.
Global Instance isgraph_nfmc {X : Type} : IsGraph (NFMC X) := isgraph_paths _.
Global Instance is01cat_nfmc {X : Type} : Is01Cat (NFMC X) := is01cat_paths _.
Global Instance is2graph_nfmc {X : Type} : Is2Graph (NFMC X) := is2graph_paths _.
Global Instance is1cat_nfmc {X : Type} : Is1Cat (NFMC X) := is1cat_paths _.
Global Instance is0gpd_nfmc {X : Type} : Is0Gpd (NFMC X) := is0gpd_paths _.
Global Instance is1gpd_nfmc {X : Type} : Is1Gpd (NFMC X) := is1gpd_paths _.
Global Instance hasequivs_nfmc {X : Type} : HasEquivs (NFMC X) := hasequivs_1gpd _.
Global Instance is0bifunctor_app {X : Type} : Is0Bifunctor (@app X).
Proof.
srapply Build_Is0Bifunctor'.
snrapply Build_Is0Functor.
intros [l l'] [p p'] [q q'].
cbn; exact (ap011 _ q q').
Defined.
Global Instance is1bifunctor_app {X : Type} : Is1Bifunctor (@app X).
Proof.
snrapply Build_Is1Bifunctor'.
snrapply Build_Is1Functor.
- intros [l l'] [m m'] [p p'] [q q'] [r r'].
exact (ap022 _ r r').
- reflexivity.
- intros [l l'] [m m'] [n n'] [p p'] [q q'].
exact (ap011_pp _ p q p' q').
Defined.
Global Instance associator_nfmc {X : Type} : Associator (@app X).
Proof.
snrapply Build_Associator.
1: apply app_assoc.
simpl. hnf.
intros [[l m] n] [[l' m'] n'] [[f g] h]; cbn in * |-.
destruct f, g, h.
apply concat_1p_p1.
Defined.
Global Instance leftunitor_nfmc {X : Type} : LeftUnitor (@app X) [].
Proof.
snrapply Build_NatEquiv.
1: reflexivity.
intros l m p.
apply equiv_p1_1q.
apply ap_idmap.
Defined.
Global Instance rightunitor_nfmc {X : Type} : RightUnitor (@app X) [].
Proof.
snrapply Build_NatEquiv.
- intros l.
induction l.
+ reflexivity.
+ cbn; apply ap.
exact IHl.
- intros l m p.
destruct p.
apply concat_1p_p1.
Defined.
Global Instance triangleidentity_nfmc {X : Type} : TriangleIdentity (@app X) [].
Proof.
intros l m.
induction l.
1: reflexivity.
cbn.
apply moveL_Mp.
rhs_V nrapply (ap011_compose' (app (A:=X)) (cons a) idmap _ 1).
rhs nrapply (ap011_compose (app (A:=X)) (cons a)).
lhs nrapply concat_p1.
lhs_V nrapply ap_V.
f_ap.
lhs_V nrapply concat_p1.
apply moveR_Vp.
exact IHl.
Defined.
Global Instance pentagonidentity_nfmc {X : Type} : PentagonIdentity (@app X) [].
Proof.
intros l m n k.
lhs nrapply (list_pentagon l m n k).
apply concat_pp_p.
Defined.
Global Instance ismonoidal_nfmc {X : Type} : IsMonoidal (NFMC X) (app (A:=X)) [] := {}.
(* This is equivalent to the functor category as we have groupoids, but it is convenient to use core *)
Definition NFMC' (X : Type) := Fun11 (NFMC X) (NFMC X).
Global Instance isgraph_NFMC' {X : Type} : IsGraph (NFMC' X) := _.
Global Instance is01cat_NFMC' {X : Type} : Is01Cat (NFMC' X) := _.
Global Instance is2graph_NFMC' {X : Type} : Is2Graph (NFMC' X) := _.
Global Instance is1cat_NFMC' {X : Type} : Is1Cat (NFMC' X) := _.
Global Instance is0gpd_NFMC' {X : Type} : Is0Gpd (NFMC' X) := _.
Global Instance is1gpd_NFMC' {X : Type} : Is1Gpd (NFMC' X) := _.
Global Instance hasequivs_NFMC' {X : Type} : HasEquivs (NFMC' X) := hasequivs_1gpd _.
Definition nfmc'_tensor (X : Type) (x y : NFMC' X) : NFMC' X
:= fun11_compose x y.
Definition nfmc'_unit (X : Type) : NFMC' X := fun11_id.
Global Instance is0bifunctor_nfmc'_tensor {X : Type}
: Is0Bifunctor (nfmc'_tensor X).
Proof.
rapply Build_Is0Bifunctor'.
snrapply Build_Is0Functor.
intros [x x'] [y y'] [f f'].
rapply (nattrans_comp2 f f').
Defined.
Global Instance is1bifunctor_nfmc'_tensor {X : Type}
: Is1Bifunctor (nfmc'_tensor X).
Proof.
snrapply Build_Is1Bifunctor'.
snrapply Build_Is1Functor.
- simpl.
intros [x x'] [y y'] [f f'] [g g'] [h h'] a.
refine (_ @@ _).
+ exact (fmap2 x (h' a)).
+ exact (h _).
- intros [x x'].
intro a.
lhs nrapply concat_p1.
rapply (fmap_id x).
- intros [x x'] [y y'] [z z'] [f f'] [g g'] a.
simpl.
lhs nrapply concat_p_pp.
rhs nrapply concat_p_pp.
apply whiskerR.
unfold trans_postwhisker, trans_prewhisker.
lhs nrapply whiskerR.
1: exact (fmap_comp x (f' a) (g' a)).
simpl.
lhs nrapply concat_pp_p.
rhs nrapply concat_pp_p.
apply whiskerL.
rapply (isnat f).
Defined.
Global Instance associator_NFMC' {X : Type} : Associator (nfmc'_tensor X).
Proof.
snrapply Build_Associator.
{ intros x y z.
unfold nfmc'_tensor.
snrapply Build_NatTrans.
1: reflexivity.
intros a a' f.
apply concat_p1_1p. }
intros [[x y] z] [[x' y'] z'] [[f g] h] l; cbn in * |-.
simpl.
apply equiv_p1_1q.
unfold trans_postwhisker, trans_prewhisker.
cbn.
f_ap.
- rhs nrapply concat_p_pp.
f_ap.
+ rhs nrapply concat_p_pp.
apply whiskerR.
lhs_V nrapply concat_1p.
apply whiskerR.
symmetry.
lhs rapply (fmap2 x).
1: rapply (fmap_id y).
rapply (fmap_id x).
+ apply whiskerR.
lhs rapply (fmap_comp x').
rhs_V nrapply concat_1p.
apply whiskerR.
lhs rapply (fmap2 x').
1: rapply (fmap_id y).
rapply (fmap_id x').
- apply whiskerR.
rapply (fmap2 x').
apply concat_p1.
Defined.
Global Instance leftunitor_NFMC' {X : Type} : LeftUnitor (nfmc'_tensor X) (nfmc'_unit X).
Proof.
snrapply Build_NatEquiv.
- intros x.
snrapply Build_NatTrans.
1: reflexivity.
intros y y' g.
apply concat_p1_1p.
- intros x y f l.
apply equiv_p1_1q.
apply concat_p1.
Defined.
Global Instance rightunitor_NFMC' {X : Type} : RightUnitor (nfmc'_tensor X) (nfmc'_unit X).
Proof.
snrapply Build_NatEquiv.
+ intros y.
snrapply Build_NatTrans.
1: reflexivity.
intros x x' f.
apply concat_p1_1p.
+ intros x y f l.
apply equiv_p1_1q.
rhs_V nrapply concat_1p.
apply whiskerR.
rapply (fmap_id x).
Defined.
Global Instance triangleidentity_NFMC' {X : Type} : TriangleIdentity (nfmc'_tensor X) (nfmc'_unit X).
Proof.
intros x x' a.
apply equiv_p1_1q.
symmetry.
apply concat_p1.
Defined.
Global Instance pentagonidentity_NFMC' {X : Type} : PentagonIdentity (nfmc'_tensor X) (nfmc'_unit X).
Proof.
intros w x y z a; cbn.
lhs_V nrapply concat_p1.
f_ap.
- rhs nrapply concat_p1.
symmetry.
rapply (fmap_id w).
- rhs nrapply concat_1p.
rhs nrapply concat_p1.
rhs rapply (fmap2 w).
1: rapply (fmap_id w _)^.
lhs rapply (fmap2 x).
1: rapply (fmap_id y).
rapply (fmap_id x).
Defined.
Global Instance ismonoidal_NFMC' {X : Type}
: IsMonoidal (NFMC' X) (nfmc'_tensor X) (nfmc'_unit X) := {}.
(** *** Normalization functor *)
Definition interp (X : Type) : FMC X -> NFMC' X.
Proof.
intros m.
induction m as [| | a IHa b IHb ].
- snrapply Build_Fun11.
+ intros xs.
exact (x :: xs).
+ snrapply Build_Is0Functor.
intros xs ys p.
f_ap.
+ snrapply Build_Is1Functor.
* intros x' y xs ys p.
f_ap.
* reflexivity.
* intros a b c f g.
apply ap_pp.
- exact (nfmc'_unit X).
- exact (nfmc'_tensor X IHa IHb).
Defined.
Global Instance is0functor_interp {X : Type} : Is0Functor (interp X).
Proof.
snrapply Build_Is0Functor.
intros x y f.
induction f as [
| x y z f IHf g IHg
| x y f IHf | | |
| x x' y y' f IHf g IHg ].
- exact (Id _).
- exact (IHf $o IHg).
- exact IHf^$.
- exact (Id _).
- exact (Id _).
- exact (Id _).
- exact (nattrans_comp2 IHf IHg).
Defined.
Ltac simpl_trans := unfold nattrans_comp2, nattrans_comp, trans_comp, nattrans_prewhisker, nattrans_postwhisker, trans_prewhisker, trans_postwhisker, trans_nattrans.
Global Instance is1functor_interp (X : Type) : Is1Functor (interp X).
Proof.
snrapply Build_Is1Functor.
- intros x y f g p.
induction p.
+ reflexivity.
+ exact (IHp2 $@ IHp1).
+ exact IHp^$.
+ exact (_ $@L IHp).
+ exact (IHp $@R _).
+ exact (cat_assoc _ _ _).
+ exact (cat_idl _).
+ exact (cat_idr _).
+ exact (gpd_issect _).
+ exact (gpd_isretr _).
+ intros a.
symmetry.
apply concat_1p.
+ intros a.
simpl.
cbn.
unfold trans_postwhisker.
unfold id_transformation.
simpl.
lhs_V nrapply concat_p1.
f_ap.
* rhs nrapply concat_p1.
symmetry.
rapply (fmap_id (interp X w)).
* rhs nrapply concat_1p.
rhs nrapply concat_p1.
symmetry.
rapply (fmap_id (interp X w o interp X x o interp X y)).
+ admit.
+ intro.
lhs nrapply concat_p1.
rapply (fmap_id (interp X x)).
+ change (fmap (interp X) (tensor2' (comp' g f) (comp' g' f'))
$== fmap (interp X) (comp' (tensor2' g g') (tensor2' f f'))).
change (fmap (interp X) (comp' ?x ?y)) with (fmap (interp X) x $o fmap (interp X) y).
change (fmap (interp X) (tensor2' ?x ?y))
with (nattrans_comp2
(F := interp X _) (G := interp X _) (H := interp X _) (K := interp X _)
(fmap (interp X) x) (fmap (interp X) y)).
change (fmap (interp X) (comp' ?x ?y)) with (fmap (interp X) x $o fmap (interp X) y).
do 2 change (fmap (interp X) (tensor2' ?x ?y))
with (nattrans_comp2
(F := interp X _) (G := interp X _) (H := interp X _) (K := interp X _)
(fmap (interp X) x) (fmap (interp X) y)).
generalize (fmap (interp X) f).
generalize (fmap (interp X) f').
generalize (fmap (interp X) g).
generalize (fmap (interp X) g').
clear f f' g g'.
intros f f' g g'.
unfold nattrans_comp2.
unfold nattrans_prewhisker.
unfold nattrans_comp.
unfold trans_nattrans.
cbn.
unfold trans_postwhisker, trans_prewhisker.
simpl.
set (a := interp X x) in *.
set (a' := interp X x') in *.
set (b := interp X y) in *.
set (b' := interp X y') in *.
set (c := interp X z) in *.
set (c' := interp X z') in *.
admit.
+ intros l.
apply equiv_p1_1q.
nrapply concat_p1.
+ intros l.
apply equiv_p1_1q.
rhs_V nrapply concat_1p.
apply whiskerR.
rapply (fmap_id (interp X _)).
+ intros l.
apply equiv_p1_1q.
rhs nrapply concat_p_pp.
apply whiskerR.
lhs_V nrapply concat_1p.
apply whiskerR.
symmetry.
rapply (fmap_id (interp X (tensor z w))).
+ intros l.
apply equiv_p1_1q.
rhs nrapply concat_p_pp.
apply whiskerR.
refine (_ @ ((fmap_id (interp X (tensor w z)) _)^ @@ 1)).
rhs rapply concat_1p.
refine (fmap2 (interp X w) _ @ _).
{ lhs nrapply whiskerR.
1: rapply (fmap_id (interp X z)).
apply concat_1p. }
reflexivity.
+ intros l.
apply equiv_p1_1q.
apply whiskerR.
refine (fmap2 (interp X w) _ @ _).
1: nrapply concat_p1.
reflexivity.
- reflexivity.
- reflexivity.
Admitted.
Definition nfmc'_nfmc (X : Type) n : NFMC' X -> NFMC X := fun f => f n.
Global Instance is0functor_nfmc'_nfmc {X : Type} n : Is0Functor (nfmc'_nfmc X n).
Proof.
snrapply Build_Is0Functor.
intros f g p.
exact (p n).
Defined.
Global Instance is1functor_nfmc'_nfmc {X : Type} n : Is1Functor (nfmc'_nfmc X n).
Proof.
snrapply Build_Is1Functor.
- intros f g p q h.
exact (h n).
- reflexivity.
- reflexivity.
Defined.
Definition nfmc_fmc_incl (X : Type) : NFMC X -> FMC X.
Proof.
intros f.
induction f as [| x xs IHxs].
- exact unit.
- exact (tensor (el x) IHxs).
Defined.
Global Instance is0functor_nfmc_fmc_incl {X : Type} : Is0Functor (nfmc_fmc_incl X).
Proof.
snrapply Build_Is0Functor.
intros l m p.
exact (transport (fun x => nfmc_fmc_incl X l $-> nfmc_fmc_incl X x) p (Id _)).
Defined.
Global Instance is1functor_nfmc_fmc_incl {X : Type} : Is1Functor (nfmc_fmc_incl X).
Proof.
snrapply Build_Is1Functor.
- intros l m p q h.
destruct h.
reflexivity.
- reflexivity.
- intros l m n p q.
destruct p, q.
symmetry.
apply left_unitor2.
Defined.
Definition nrm' (X : Type) n : FMC X -> FMC X := nfmc_fmc_incl X o nfmc'_nfmc X n o interp X.
Global Instance is0functor_nrm' {X : Type} n : Is0Functor (nrm' X n) := _.
Global Instance is1functor_nrm' {X : Type} n : Is1Functor (nrm' X n) := _.
Definition zeta_trans {X} n
: Transformation
(fun a => tensor a (nfmc_fmc_incl X n))
(nrm' X n).
Proof.
intros x.
induction x as [| |a IHa b IHb] in n |- *.
- exact (id _).
- apply left_unitor.
- exact (IHa _ $o fmap11 tensor (Id a) (IHb _) $o (associator' _ _ _)^$).
Defined.
Lemma natequiv_left_unitor {X}
: NatEquiv (tensor (X:=X) unit) idmap.
Proof.
snrapply Build_NatEquiv.
- intros x.
apply left_unitor.
- intros x y f.
apply isnat_left_unitor.
Defined.
Definition isnat_left_unitor' {X} {x y : FMC X} (f : x $-> y)
: left_unitor' y $o fmap01 tensor unit f $== f $o left_unitor' x
:= isnat_left_unitor x y f.
Definition isnat_right_unitor' {X} {x y : FMC X} (f : x $-> y)
: right_unitor' y $o fmap10 tensor f unit $== f $o right_unitor' x
:= isnat_right_unitor x y f.
Definition triangle' {X} (x y : FMC X)
: fmap01 tensor x (left_unitor' y) $== fmap10 tensor (right_unitor' x) y $o associator' x unit y
:= triangle.
Definition pentagon' {X} (w x y z : FMC X)
: associator' (tensor w x) y z $o associator' w x (tensor y z)
$== fmap10 tensor (associator' w x y) z $o associator' w (tensor x y) z
$o fmap01 tensor w (associator' x y z)
:= pentagon.
Definition isnat_l_associator' {X} {w x y z : FMC X} (f : z $-> y)
: associator' y w x $o fmap10 tensor f (tensor w x)
$== fmap10 tensor (fmap10 tensor f w) x $o associator' z w x
:= isnat_l_associator w x y z f.
Definition isnat_m_associator' {X} {w x y z : FMC X} (f : z $-> y)
: associator' w y x $o fmap01 tensor w (fmap10 tensor f x)
$== fmap10 tensor (fmap01 tensor w f) x $o associator' w z x
:= isnat_m_associator w x y z f.
Definition isnat_r_associator' {X} {w x y z : FMC X} (f : z $-> y)
: associator' w x y $o fmap01 tensor w (fmap01 tensor x f)
$== fmap01 tensor (tensor w x) f $o associator' w x z
:= isnat_r_associator w x y z f.
(** Proven in [Kelly 64]. Proof is a little tricky even though the lemma is simple. *)
Lemma unitor_tensor_law {X} x y
: left_unitor' (tensor (X:=X) x y)
$== fmap10 tensor (left_unitor' x) y $o associator' unit x y.
Proof.
refine ((gpd_moveR_hV (isnat_left_unitor' _))^$ $@ ((_ $@L _) $@R _)
$@ gpd_moveR_hV (isnat_left_unitor' _)).
refine (_ $@ (fmap_comp _ _ _)^$).
refine (_ $@ (gpd_moveR_Vh (isnat_m_associator' _)^$ $@R _)).
refine (_ $@ (cat_assoc _ _ _)^$).
apply gpd_moveL_Vh.
change (fmap (tensor unit) ?f) with (fmap01 tensor unit f).
refine (_ $@L (triangle' _ _) $@ _).
refine ((cat_assoc _ _ _)^$ $@ _).
refine (_ $@ (cat_assoc _ _ _)^$).
refine (_ $@ ((fmap2 _ (triangle' _ _) $@ fmap_comp _ _ _)^$ $@R _)).
change (fmap (flip tensor y) ?f) with (fmap10 tensor f y).
refine (_ $@ (cat_assoc _ _ _)^$).
refine (_ $@ (_ $@L (pentagon' _ _ _ _ $@ cat_assoc _ _ _))).
refine ((_ $@R _) $@ cat_assoc _ _ _).
exact (isnat_l_associator' _).
Defined.
(** Main meat of proof *)
Global Instance is1natural_zeta_trans {X} n
: Is1Natural
(fun a => tensor a (nfmc_fmc_incl X n))
(nrm' X n)
(zeta_trans n).
Proof.
intros x y f.
(** We rewrite the goal as a square to make applying some lemmas easier. *)
change (?w $o ?x $== ?y $o ?z) with (Square z w x y).
(** We proceed by induction on the morphism [f]. *)
induction f as [
| x y z f IHf g IHg
| x y f IHf | | |
| a b a' b' f IHf g IHg ] in n |- *.
- (** Identity *)
nrapply vconcatL.
1: exact (fmap_id (flip tensor _) x).
nrapply vconcatR.
2: exact (fmap_id (nfmc_fmc_incl X o (fun f => f n) o interp X) x).
apply hrefl.
- (** Composition *)
nrapply vconcatL.
1: exact (fmap_comp (flip tensor _) g f).
nrapply vconcatR.
2: exact (fmap_comp (nfmc_fmc_incl X o (fun f => f n) o interp X) g f).
exact (hconcat (IHg _) (IHf _)).
- (** Inverse *)
nrapply vconcatL.
1: exact (gpd_1functor_V (flip tensor _) _).
nrapply vconcatR.
2: exact (gpd_1functor_V (nfmc_fmc_incl X o (fun f => f n) o interp X) _).
exact (hinverse' (IHf _)).
- (** Left unitor *)
change (Square
(zeta_trans _ unit $o fmap11 tensor (Id unit) (zeta_trans n x) $o (associator' _ _ _)^$)
(zeta_trans n x)
(fmap (flip tensor (nfmc_fmc_incl X n)) (left_unitor x))
(id _)).
snrapply vconcatL.
{ refine (_ $o (associator' _ _ _)^$).
apply left_unitor. }
{ symmetry.
apply gpd_moveR_hV.
apply unitor_tensor_law. }
unfold Square.
refine ((cat_assoc _ _ _)^$ $@ (_ $@R _) $@ cat_assoc _ _ _).
refine (_ $@ (cat_idl _)^$).
generalize (zeta_trans n x); intros h.
refine (_ $@ (_ $@L _)).
2: { refine (_ $@ (_ $@L _^$)).
2: apply tensor2_id.
symmetry.
rapply cat_idr. }
symmetry.
apply isnat_left_unitor.
- (** Right unitor *)
change (Square
(zeta_trans n x $o fmap11 tensor (Id x) (zeta_trans n unit) $o (associator' _ _ _)^$)
(zeta_trans n x)
(fmap (flip tensor (nfmc_fmc_incl X n)) (right_unitor x))
(id _)).
snrapply vconcatL.
{ refine (_ $o (associator' _ _ _)^$).
refine (fmap01 tensor x _).
apply left_unitor. }
{ apply gpd_moveL_hV.
symmetry.
apply triangle'. }
apply whiskerTL.
snrapply hconcatR.
{ refine (_ $o _).
1: apply right_unitor.
refine (_ $o _^$).
2: apply right_unitor.
refine (fmap10 tensor _ unit).
exact (zeta_trans n x). }
{ unfold Square.
refine (_ $@ (cat_idl _)^$).
unfold fmap11.
refine (_ $@ (_ $@L _^$) $@ cat_assoc _ _ _).
2: apply tensor2_id.
refine (_ $@ (cat_idr _)^$).
change (fmap (tensor x) ?f) with (fmap01 tensor x f).
refine (((cat_assoc _ _ _)^$ $@ _) $@R _).
apply gpd_moveR_hV.
apply isnat_right_unitor'. }
refine (_ $@ cat_assoc _ _ _).
apply gpd_moveL_hV.
symmetry.
apply isnat_right_unitor'.
- (** Associator *)
change (Square
(zeta_trans _ x $o fmap11 tensor (Id x) (zeta_trans n (tensor y z)) $o (associator' _ _ _)^$)
(zeta_trans _ (tensor x y) $o fmap11 tensor (Id (tensor x y)) (zeta_trans n z) $o (associator' _ _ _)^$)
(fmap (flip tensor (nfmc_fmc_incl X n)) (associator x y z))
(id _)).
snrapply vconcat.
{ refine (associator' _ _ _ $o _).
refine (fmap01 tensor x _)^$.
exact (associator' _ _ _). }
{ apply vinverse'.
unfold Square.
refine ((cat_assoc _ _ _)^$ $@ _).
apply gpd_moveR_hV.
apply pentagon. }
snrapply vconcat.
{ refine (associator' _ _ _ $o _).
refine (fmap01 tensor x _)^$.
rapply zeta_trans. }
{ nrapply hconcat.
{ apply hinverse'.
nrapply hconcatR.
2: exact ((_ $@L fmap_id _ _) $@ cat_idr _).
rapply (fmap_square (tensor x)).
simpl.
unfold Square.
refine (cat_assoc _ _ _ $@ _).
refine ((_ $@L _) $@ _).
1: apply left_invertor2.
refine (cat_idr _ $@ _).
change (comp ?x ?y) with (x $o y).
refine (_ $@L _).
refine (_^$ $@ _).
1: apply tensor2_comp.
eapply (tensor3 left_unitor2).
apply right_unitor2. }
simpl.
snrapply hconcatR.
1: exact (tensor2 (id (tensor x y)) (zeta_trans n z)).
2: { symmetry.
refine (_ $@ _).
2: apply tensor2_comp.
apply tensor3; apply rev2, right_unitor2. }
apply transpose.
apply isnat_r_associator. }
unfold Square.
refine ((cat_assoc _ _ _)^$ $@ _ $@ (cat_idl _)^$).
apply gpd_moveR_hV.
simpl.
do 4 change (comp ?x ?y) with (cat_comp (A:=FMC X) x y).
change (Hom2FMC ?f ?g) with (f $== g).
refine (cat_assoc _ _ _ $@ (_ $@L _) $@ _).
1: apply left_invertor2.
refine (cat_idr _ $@ _).
refine ((cat_assoc _ _ _)^$ $@ _).
refine ((_ $@L _) $@ _).
1: apply tensor2_id.
refine (cat_idr _ $@ _).
reflexivity.
- (** Functoriality of tensor *)
change (Square
(zeta_trans _ a $o fmap11 tensor (Id a) (zeta_trans n b) $o (associator' _ _ _)^$)
(zeta_trans _ a' $o fmap11 tensor (Id a') (zeta_trans n b') $o (associator' _ _ _)^$)
(fmap (flip tensor (nfmc_fmc_incl X n)) (tensor2 f g))
(fmap (nrm' X n) (tensor2 f g))).
snrapply vconcat.
1: exact (fmap11 tensor f (tensor2 g (id _))).
{ (** Using naturality of the associator *)
apply vinverse'.
nrapply vconcatR.
1: nrapply vconcatL.
2: exact (is1natural_associator_uncurried
(a, b, nfmc_fmc_incl X n)
(a', b', nfmc_fmc_incl X n)
(f, g, Id (nfmc_fmc_incl X n))).
- nrapply comp2.
1: nrapply wl; apply tensor2_comp.
nrapply comp2.
1: apply tensor2_comp.
simpl.
1: nrapply comp2.
2: apply rev2, tensor2_comp.
apply tensor3.
1: apply rev2, left_unitor2.
simpl.
nrapply comp2.
1: apply wl, rev2, right_unitor2.
nrapply comp2.
1: apply tensor2_comp.
nrapply comp2.
2: apply right_unitor2.
apply tensor3; apply rev2, left_unitor2.
- refine (_ $@ (_^$ $@R _)).
2: apply fmap_id.
2: exact _.
refine (_ $@ (cat_idl _)^$).
apply tensor3.
2: apply id2.
simpl.
nrapply comp2.
1: apply tensor2_comp.
apply tensor3.
1,2: apply rev2.
1: apply left_unitor2.
apply right_unitor2. }
snrapply vconcat.
{ rapply (fmap11 tensor f).
exact (fmap (nrm' X n) g). }
{ rapply fmap11_square.
1: apply vrefl.
apply IHg. }
nrapply vconcatR.
2: { refine (_ $o fmap2 _ _).
2: { refine (_ $@ _).
1: eapply tensor3.
1: apply rev2, left_unitor2.
1: apply rev2, right_unitor2.
apply tensor2_comp. }
rapply (fmap_comp (nrm' X n)). }
unfold fmap11.
snrapply hconcat.
1: rapply zeta_trans.
+ unfold Square.
unfold Square in IHf.
refine (IHf _ $@ _).
refine (_ $@R _).
unfold nfmc'_nfmc.
unfold is0functor_nrm'.
refine (fmap2 (nfmc_fmc_incl X) _).
(*
change (a $-> a') in f.
change (fmap (nfmc'_nfmc X (interp X b n)) (fmap (interp X) f)
$== fmap (nfmc'_nfmc X n) (fmap (interp X) (Id b) $@@ fmap (interp X) f)).
refine (_ $@ fmap2 (nfmc'_nfmc X n) _).
2: { refine ((_ $@ _) $@R _).
2: refine (fmap2 _ _).
2: symmetry.
2: refine (fmap_id _ _).
symmetry.
refine (fmap_id _ _). }
refine (_ $@ fmap2 _ _).
2: rapply (cat_idl _)^$.
reflexivity. *)
admit.
+
(*
unfold Square in IHg |- *.
set (r := tensor2 (id a') g).
change (HomFMC ?f ?g) with (f $== g) in r.
change (b $-> b') in g.