-
Notifications
You must be signed in to change notification settings - Fork 4
/
Collected_WDs_TikZ_Pictures_wiring_diagrams.tex
2622 lines (2472 loc) · 108 KB
/
Collected_WDs_TikZ_Pictures_wiring_diagrams.tex
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
% Creative commons Attribution CC BY
% Work by David I. Spivak and Patrick Schultz
%
% You are free to:
% Share Ñ copy and redistribute the material in any medium or format
% Adapt Ñ remix, transform, and build upon the material for any purpose, even commercially.
%
% Under the following terms:
% Attribution Ñ You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
% No additional restrictions Ñ You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
%
% Use at your own risk.
\documentclass[11pt,oneside,article]{memoir}
\usepackage{amsthm}
\usepackage{newpxtext}
\usepackage[varg,bigdelims]{newpxmath}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{
cd,
math,
decorations.markings,
decorations.pathreplacing,
positioning,
arrows.meta,
circuits.logic.US,
shapes,
calc,
fit,
quotes}
\newcommand{\tn}{\textnormal}
\newcommand{\inp}[1]{#1^{\tn{in}}}
\newcommand{\outp}[1]{#1^{\tn{out}}}
\newcommand{\upd}[1]{#1^{\tn{upd}}}
\newcommand{\rdt}[1]{#1^{\tn{rdt}}}
\tikzset{
oriented WD/.style={%everything after equals replaces "oriented WD" in key.
every to/.style={out=0,in=180,draw},
label/.style={
font=\everymath\expandafter{\the\everymath\scriptstyle},
inner sep=0pt,
node distance=2pt and -2pt},
semithick,
node distance=1 and 1,
decoration={markings, mark=at position \stringdecpos with \stringdec},
ar/.style={postaction={decorate}},
execute at begin picture={\tikzset{
x=\bbx, y=\bby,
every fit/.style={inner xsep=\bbx, inner ysep=\bby}}}
},
string decoration/.store in=\stringdec,
string decoration={\arrow{stealth};},
string decoration pos/.store in=\stringdecpos,
string decoration pos=.7,
bbx/.store in=\bbx,
bbx = 1.5cm,
bby/.store in=\bby,
bby = 1.5ex,
bb port sep/.store in=\bbportsep,
bb port sep=1.5,
% bb wire sep/.store in=\bbwiresep,
% bb wire sep=1.75ex,
bb port length/.store in=\bbportlen,
bb port length=4pt,
bb penetrate/.store in=\bbpenetrate,
bb penetrate=0,
bb min width/.store in=\bbminwidth,
bb min width=1cm,
bb rounded corners/.store in=\bbcorners,
bb rounded corners=2pt,
bb small/.style={bb port sep=1, bb port length=2.5pt, bbx=.4cm, bb min width=.4cm,
bby=.7ex},
bb medium/.style={bb port sep=1, bb port length=2.5pt, bbx=.4cm, bb min width=.4cm,
bby=.9ex},
bb/.code 2 args={%When you see this key, run the code below:
\pgfmathsetlengthmacro{\bbheight}{\bbportsep * (max(#1,#2)+1) * \bby}
\pgfkeysalso{draw,minimum height=\bbheight,minimum width=\bbminwidth,outer
sep=0pt,
rounded corners=\bbcorners,thick,
prefix after command={\pgfextra{\let\fixname\tikzlastnode}},
append after command={\pgfextra{\draw
\ifnum #1=0{} \else foreach \i in {1,...,#1} {
($(\fixname.north west)!{\i/(#1+1)}!(\fixname.south west)$) +(-
\bbportlen,0)
coordinate (\fixname_in\i) -- +(\bbpenetrate,0) coordinate (\fixname_in\i')}\fi
%Define the endpoints of tickmarks
\ifnum #2=0{} \else foreach \i in {1,...,#2} {
($(\fixname.north east)!{\i/(#2+1)}!(\fixname.south east)$) +(-
\bbpenetrate,0)
coordinate (\fixname_out\i') -- +(\bbportlen,0) coordinate (\fixname_out\i)}\fi;
}}}
},
bb name/.style={append after command={\pgfextra{\node[anchor=north] at
(\fixname.north) {#1};}}}
}
\tikzset{
unoriented WD/.style={
every to/.style={draw},
shorten <=-\penetration, shorten >=-\penetration,
label distance=-2pt,
thick,
node distance=\spacing,
execute at begin picture={\tikzset{
x=\spacing, y=\spacing}}
},
pack size/.store in=\psize,
pack size = 8pt,
spacing/.store in=\spacing,
spacing = 8pt,
link size/.store in=\lsize,
link size = 2pt,
penetration/.store in=\penetration,
penetration = 2pt,
pack color/.store in=\pcolor,
pack color = blue,
pack inside color/.store in=\picolor,
pack inside color=blue!20,
pack outside color/.store in=\pocolor,
pack outside color=blue!50!black,
surround sep/.store in=\ssep,
surround sep=8pt,
link/.style={
circle,
draw=black,
fill=black,
inner sep=0pt,
minimum size=\lsize
},
pack/.style={
circle,
draw = \pocolor,
fill = \picolor,
inner sep = .25*\psize,
minimum size = \psize
},
outer pack/.style={
ellipse,
draw,
inner sep=\ssep,
color=\pocolor,
},
intermediate pack/.style={
ellipse,
dashed,
draw,
inner sep=\ssep,
color=\pocolor,
},
}
\tikzset{Yonepart/.pic={
\node[bb={1}{2},bb name = {\tiny$X_{11}$}] (X11) {};
\node[bb={2}{2},below right=of X11,bb name = {\tiny$X_{12}$}] (X12) {};
\node[bb={2}{1}, above right=of X12,bb name = {\tiny$X_{13}$}] (X13) {};
\node[bb={2}{2}, fit={($(X11.north west)+(.3,1.5)$) (X12) ($(X13.east)+(-.3,0)$)},bb name = {\scriptsize $Y_1$}] (Y1) {};
\draw (Y1_in1') to (X11_in1);
\draw (Y1_in2') to (X12_in2);
\draw (X11_out1) to (X13_in1);
\draw (X11_out2) to (X12_in1);
\draw (X12_out1) to (X13_in2);
\draw (X12_out2) to (Y1_out2');
\draw (X13_out1) to (Y1_out1');
\coordinate (bottombox) at ($(X12.south)$);
\coordinate (rightbox) at ($(X13.east)$);
\coordinate (Y1northwest) at ($(Y1.north west)$);
}
}
\tikzset{Ytwopart/.pic={
\node[bb={2}{2}, bb name = {\tiny$X_{21}$}] (X21) {};
\node[bb={1}{2},above right=-1 and 1 of X21,bb name = {\tiny$X_{22}$}] (X22) {};
\node[bb={1}{2}, fit={($(X21.south west)+(-.25,0)$) ($(X22.north east)+(.25,3.5)$)},bb name = {\scriptsize$Y_2$}] (Y2){};
\draw (Y2_in1') to (X21_in2);
\draw (X21_out1) to (X22_in1);
\draw (X22_out2) to (Y2_out1');
\draw let \p1=(X22.south east), \p2=($(Y2_out2)$), \n1={\y1-\bby}, \n2=\bbportlen in
(X21_out2) to (\x1+\n2,\n1) -- (\x1+\n2,\n1) to (Y2_out2');
\draw let \p1=(X22.north east), \p2=(X21.north west), \n1={\y1+\bby}, \n2=\bbportlen in
(X22_out1) to[in=0] (\x1+\n2,\n1) -- (\x2-\n2,\n1) to[out=180] (X21_in1);
}
}
\tikzset{SmallNeuronPic/.pic={
\node[bb={3}{1}] (N1) {$\scriptstyle N_1$};
\node[bb={2}{1}, above right=.7 and 3.5 of N1] (N2) {$\scriptstyle N_2$};
\node[bb={2}{1}, below =of N2] (N3) {$\scriptstyle N_3$};
\node[bb={3}{1}, below =of N3] (N4) {$\scriptstyle N_4$};
\node[bb={6}{8}, fit={($(N1.west)-(.5,0)$) ($(N2.north)+(0,2)$) ($(N3.east)+(1.5,0)$) ($(N4.south)-(0,1)$)}, bb name={$\scriptstyle X$}] (X) {};
\draw (X_in1') to (N2_in1);
\draw (X_in2') to (N1_in1);
\draw (X_in3') to (N1_in2);
\draw (X_in4') to (N1_in3);
\draw (X_in6') to (N4_in2);
\draw (N1_out1) to (N2_in2);
\draw (N1_out1) to (N3_in1);
\draw (N1_out1) to (N4_in1);
\draw (N2_out1) to (X_out1');
\draw (N2_out1) to (X_out2');
\draw (N2_out1) to (X_out3');
\draw (N3_out1) to (X_out4');
\draw (N3_out1) to (X_out5');
\draw (N3_out1) to (X_out6');
\draw (N4_out1) to (X_out7');
\draw (N4_out1) to (X_out8');
\draw (X_in5') to[looseness=2] (N3_in2);
\draw let \p1=(N4.south east), \p2=(N4.south west), \n1={\y2-\bby}, \n2=\bbportlen in
(N3_out1) to[in=0] (\x1+\n2,\n1) -- (\x2-\n2,\n1) to[out=180] (N4_in3);
}
}
\tikzset{SmallNeuronDashed/.pic={
\node[bb={3}{1}] (N1) {$\scriptstyle N_1$};
\node[bb={2}{1}, above right=.7 and 3.5 of N1] (N2) {$\scriptstyle N_2$};
\node[bb={2}{1}, below =of N2] (N3) {$\scriptstyle N_3$};
\node[bb={3}{1}, below =of N3] (N4) {$\scriptstyle N_4$};
\node[bb={6}{8}, fit={($(N1.west)-(.5,0)$) ($(N2.north)+(0,2)$) ($(N3.east)+(1.5,0)$) ($(N4.south)-(0,1)$)}, bb name={$\scriptstyle X$}] (X) {};
\draw[dashed] (X_in1') to (N2_in1);
\draw[dashed] (X_in2') to (N1_in1);
\draw[dashed] (X_in3') to (N1_in2);
\draw[dashed] (X_in4') to (N1_in3);
\draw[dashed] (X_in6') to (N4_in2);
\draw[dashed] (N1_out1) to (N2_in2);
\draw[dashed] (N1_out1) to (N3_in1);
\draw[dashed] (N1_out1) to (N4_in1);
\draw[dashed] (N2_out1) to (X_out1');
\draw[dashed] (N2_out1) to (X_out2');
\draw[dashed] (N2_out1) to (X_out3');
\draw[dashed] (N3_out1) to (X_out4');
\draw[dashed] (N3_out1) to (X_out5');
\draw[dashed] (N3_out1) to (X_out6');
\draw[dashed] (N4_out1) to (X_out7');
\draw[dashed] (N4_out1) to (X_out8');
\draw[dashed] (X_in5') to[looseness=2] (N3_in2);
\draw[dashed] let \p1=(N4.south east), \p2=(N4.south west), \n1={\y2-\bby}, \n2=\bbportlen in
(N3_out1) to[in=0] (\x1+\n2,\n1) -- (\x2-\n2,\n1) to[out=180] (N4_in3);
}
}
\tikzset{SmallNestingPic/.pic={
\path (0,0) pic [purple] {Yonepart};
\path ($(rightbox)+(5,-5)$) pic [orange] {Ytwopart};
\node[bb={1}{2}, fit={($(Y1northwest)+(-.5,4)$) ($(Y2.south east)+(1,0)$)}, bb name={\small $Z$}] (Z) {};
\draw (Z_in1') to (Y1_in2);
\draw let \p1=(Y2.north west),\p2=(Y2.north east),\n1={\y2+\bby},\n2=\bbportlen in
(Y1_out1) to (\x1+\n2,\n1)--(\x2+\n2,\n1) to (Z_out1');
\draw (Y1_out2) to (Y2_in1);
\draw (Y2_out2) to (Z_out2');
\draw let \p1=(Y2.north east), \p2=(Y1.north west), \n1={\y2+\bby}, \n2=\bbportlen in
(Y2_out1) to[in=0] (\x1+\n2,\n1) -- (\x2-\n2,\n1) to[out=180] (Y1_in1);
}
}
\tikzset{Zredgreen/.pic={
\node[bb={2}{2}, green!50!black, bb name = $\scriptstyle Y_1$] (YY1) {};
\node[bb={1}{2}, red, below right=-1 and 2 of YY1, bb name=$\scriptstyle Y_2$] (YY2) {};
\node[bb={1}{2}, fit={($(YY1.north west)+(-.5,4)$) ($(YY2.south east)+(.5,-2)$)}, bb name={\scriptsize $Z$}] (Z) {};
\draw (Z_in1') to (YY1_in2);
\draw (YY1_out1) to (Z_out1');
\draw (YY1_out2) to (YY2_in1);
\draw (YY2_out2) to (Z_out2');
\draw let \p1=(YY2.north east), \p2=(YY1.north west), \n1={\y2+\bby}, \n2=\bbportlen in
(YY2_out1) to[in=0] (\x1+\n2,\n1) -- (\x2-\n2,\n1) to[out=180] (YY1_in1);
}
}
\tikzset{Zcombined/.pic={
\node[bb={1}{2},green!25!black,bb name = {\tiny$X_{11}$}] (X11) {};
\node[bb={2}{2},green!25!black,below right=of X11,bb name = {\tiny$X_{12}$}] (X12) {};
\node[bb={2}{1}, green!25!black,above right=of X12,bb name = {\tiny$X_{13}$}] (X13) {};
\draw (X11_out1) to (X13_in1);
\draw (X11_out2) to (X12_in1);
\draw (X12_out1) to (X13_in2);
\node[bb={2}{2}, red!30!black, below right = 0 and 1.25 of X12, bb name = {\tiny$X_{21}$}] (X21) {};
\node[bb={1}{2}, red!30!black, above right=-1 and 1 of X21,bb name = {\tiny$X_{22}$}] (X22) {};
\draw (X21_out1) to (X22_in1);
\draw let \p1=(X22.north east), \p2=(X21.north west), \n1={\y1+\bby}, \n2=\bbportlen in
(X22_out1) to[in=0] (\x1+\n2,\n1) -- (\x2-\n2,\n1) to[out=180] (X21_in1);
\node[bb={1}{2}, fit = {($(X11.north east)+(-1,3)$) (X12) (X13) ($(X21.south)+(0,-1)$) ($(X22.east)+(.5,0)$)}, bb name ={\scriptsize $Z$}] (Z) {};
\draw (Z_in1') to (X12_in2);
\draw (X13_out1) to (Z_out1');
\draw (X12_out2) to (X21_in2);
\draw let \p1=(X22.south east),\n1={\y1-\bby}, \n2=\bbportlen in
(X21_out2) to (\x1+\n2,\n1) to (Z_out2');
\draw let \p1=(X22.north east), \p2=(X11.north west), \n1={\y2+\bby}, \n2=\bbportlen in
(X22_out2) to[in=0] (\x1+\n2,\n1) -- (\x2-\n2,\n1) to[out=180] (X11_in1);
}
}
\settrims{0pt}{0pt} % page and stock same size
%\setlxvchars %calculate line length such that there are about 65 characters per line in \normalfont
\settypeblocksize{*}{35pc}{*} % {height}{width}{ratio}
%\settypeblocksize{*}{39pc}{*} % {height}{width}{ratio}
\setlrmargins{*}{*}{1} % {spine}{edge}{ratio}
%\setulmargins{*}{*}{1} % {upper}{lower}{ratio}, hight of typeblock fixed
\setulmarginsandblock{1in}{1in}{*} % height of typeblock computed
\setheadfoot{\onelineskip}{2\onelineskip} % {headheight}{footskip}
\setheaderspaces{*}{1.5\onelineskip}{*} % {headdrop}{headsep}{ratio}
\checkandfixthelayout
\setcounter{tocdepth}{1}
\setcounter{secnumdepth}{1}
\pagestyle{ruled}
\renewcommand*{\chaptitlefont}{\bfseries\Large}
\setsecheadstyle{\bfseries\large\raggedright}
\setsubsecheadstyle{\bfseries\raggedright}
\begin{document}
\title{Collected Wiring diagrams}
\author{David I. Spivak}
\maketitle
\begin{equation}\label{eqn.overview}\tag{overview}
\begin{tikzpicture}
\begin{scope}[font=\footnotesize, text height=1.5ex, text depth=.5ex]
\begin{scope}[oriented WD, bb port sep=1, bb port length=2.5pt, bb min width=.4cm, bby=.2cm, inner xsep=.2cm, x=.5cm, y=.3cm]
\node[bb={1}{1}] (Catf) {$f$};
\node[bb={1}{1}, right=1 of Catf] (Catg) {$g$};
\node[bb={0}{0}, fit=(Catf) (Catg)] (Cat) {};
\node[coordinate] at (Cat.west|-Catf_in1) (Cat_in1) {};
\node[coordinate] at (Cat.east|-Catg_out1) (Cat_out1) {};
\draw[shorten <=-2pt] (Cat_in1) -- (Catf_in1);
\draw (Catf_out1) -- (Catg_in1);
\draw[shorten >=-2pt] (Catg_out1) -- (Cat_out1);
%
\node[bb={1}{2}, above right=-1.5 and 4 of Catf] (Monf) {$f$};
\node[bb={2}{1}, below right=-1 and 1 of Monf] (Mong) {$g$};
\node[bb={0}{0}, fit=(Monf) (Mong)] (Mon) {};
\node[coordinate] at (Mon.west|-Monf_in1) (Mon_in1) {};
\node[coordinate] at (Mon.west|-Mong_in2) (Mon_in2) {};
\node[coordinate] at (Mon.east|-Monf_out1) (Mon_out1) {};
\node[coordinate] at (Mon.east|-Mong_out1) (Mon_out2) {};
\draw[shorten <=-2pt] (Mon_in1) -- (Monf_in1);
\draw[shorten >=-2pt] (Monf_out1) -- (Mon_out1);
\draw (Monf_out2) to (Mong_in1);
\draw[shorten <=-2pt] (Mon_in2) -- (Mong_in2);
\draw[shorten >=-2pt] (Mong_out1) -- (Mon_out2);
%
\node[bb={2}{1}, right= 4.5 of Monf] (Trf) {$f$};
\node[bb={2}{2}, below right=-1 and 1 of Trf] (Trg) {$g$};
\node[bb={0}{0}, fit={($(Trf.north west)+(-.5,1)$) ($(Trg.south east)+(.5,-1)$)}] (Tr) {};
\node[coordinate] at (Tr.west|-Trf_in2) (Tr_in1) {};
\node[coordinate] at (Tr.west|-Trg_in2) (Tr_in2) {};
\node[coordinate] at (Tr.east|-Trf_out1) (Tr_out1) {};
\node[coordinate] at (Tr.east|-Trg_out2) (Tr_out2) {};
\draw[shorten <=-2pt] (Tr_in1) -- (Trf_in2);
\draw (Trf_out1) to (Trg_in1);
\draw[shorten <=-2pt] (Tr_in2) -- (Trg_in2);
\draw[shorten >=-2pt] (Trg_out2) -- (Tr_out2);
\draw let \p1=(Trg.east), \p2=(Trf.north west), \n1=\bbportlen, \n2=\bby in
(Trg_out1) to[in=0] (\x1+\n1,\y2+\n2) -- (\x2-\n1,\y2+\n2) to[out=180] (Trf_in1);
%
\end{scope}
\begin{scope}[penetration=0, unoriented WD, pack outside color=black, pack inside color=white]
\node[pack, right=2.9 of Trf] (Hypf) {$f$};
\node[pack, below right=0 and .5 of Hypf] (Hypg) {$g$};
\node[outer pack, inner sep=5pt, fit=(Hypf) (Hypg)] (Hyp) {};
\node[coordinate] at ($(Hypg.-30)!.5!(Hyp.-30)$) (link) {};
\draw (Hypf) to[bend left] (Hypg);
\draw (Hypf) to[bend right] (Hypg);
\draw (Hypg) -- (link);
\draw[shorten >= -2pt] (link) to[bend left] (Hyp.-20);
\draw[shorten >= -2pt] (link) to[bend right] (Hyp.-45);
\draw[shorten >= -2pt] (Hypf) -- (Hyp);
\end{scope}
\begin{scope}[circuit logic US, thick, every to/.style={out=0,in=180}]
\node[and gate, draw, right=2.5 of Hypf] (Opdf) {$f$};
\node[and gate, draw, below right=0 and 0.5 of Opdf] (Opdg) {$g$};
\node[and gate, inner sep=1pt, draw, fit=(Opdf) (Opdg)] (Opd) {};
\draw[shorten <=-2pt] (Opd.input 1|-Opdf.west) to (Opdf.west);
\draw[shorten <=-2pt] (Opd.input 1|-Opdg.input 2) to (Opdg.input 2);
\draw (Opdf.output) to (Opdg.input 1);
\draw[shorten >=-2pt] (Opdg.output) to (Opd.output);
\end{scope}
\node[below=.65 of Cat.south] (Cat name) {category};
\node[text width=1.5cm] at (Cat name-|Mon) {monoidal category};
\node[text width=2.5cm] at (Cat name-|Tr) {traced monoidal category};
\node[text width=2cm] at (Cat name-|Hyp) {hypergraph category};
\node at (Cat name-|Opd) {operad};
\end{scope}
\end{tikzpicture}
\end{equation}
%%%% Chapter %%%%
\chapter{Boxes}
\begin{equation}\label{box1}\tag{box1}
\begin{tikzpicture}[oriented WD, bbx = 1cm, bby =.5cm, bb min width=1cm, bb port length=4pt, bb port sep=1]
\node[bb={1}{1}] (X) {$M$};
\draw[label]
node [left=2pt of X_in1] {$A$}
node [right=2pt of X_out1] {$B$}
;
\end{tikzpicture}
\end{equation}
\begin{equation}\label{box2}\tag{box2}
\begin{tikzpicture}[oriented WD, bb small, bb port sep=2.2, baseline = (lone.center)]
\node[bb={3}{1}, inner sep=10pt] (lone) {$\dot{u}$};
\node[above right=-3 and 1.5 of lone] (a) {};
\node[below right=-3 and 1.5 of lone] (b) {};
\draw (lone_out1) to (a);
\draw (lone_out1) to (b);
\draw [label]
\foreach \i in {1,2,3} {
node[anchor=east] at (lone_in\i) {\small $a_\i$}
node[above right=1 and 0 of lone_out1] {\small $u$}
}
;
\end{tikzpicture}
\end{equation}
\begin{equation}\label{box3}\tag{box3}
\begin{tikzpicture}[oriented WD, bbx = .25cm, bby =.1cm, bb min width=.25cm, bb port length=2pt, bb port sep=1]
\node[bb={1}{1}] (X) {};
\draw[label]
node [left=2pt of X_in1] {$\inp{X}$}
node [right=2pt of X_out1] {$\outp{X}$}
;
\end{tikzpicture}
\end{equation}
\begin{equation}\label{box32}\tag{box32}
\begin{tikzpicture}[oriented WD, bbx = 1cm, bby =.3cm, bb min width=1cm, bb port length=4pt, bb port sep=1]
\node[bb={2}{3}] (X) {};
\draw[label]
node [left=2pt of X_in1] {$A$}
node [left=2pt of X_in2] {$B$}
node [right=2pt of X_out1] {$C$}
node [right=2pt of X_out2] {$D$}
node [right=2pt of X_out3] {$E$}
;
\end{tikzpicture}
\end{equation}
\begin{equation}\label{lots}\tag{lots}
\begin{tikzpicture}[oriented WD, bb small]
\node[bb={0}{0}] (00) {};
\node[bb={0}{1}, right=2 of 00] (01) {};
\node[bb={0}{2}, right=2 of 01] (02) {};
\node[bb={1}{0}, right=2 of 02] (10) {};
\node[bb={1}{1}, right=2 of 10] (11) {};
\node[bb={1}{2}, right=2 of 11] (12) {};
\node[bb={2}{0}, right=2 of 12] (20) {};
\node[bb={2}{1}, right=2 of 20] (21) {};
\node[bb={2}{2}, right=2 of 21] (22) {};
\node[ right=2 of 22] (dt) {$\cdots$};
\node[bb={3}{5}, right=2 of dt] (35) {};
\node[ right=2 of 35] (et) {etc.};
\end{tikzpicture}
\end{equation}
%%%% Chapter %%%%
\chapter{Simple Wiring Diagrams}
\begin{equation}\label{simple3}\tag{simple 3}
\begin{tikzpicture}[oriented WD, bbx = .3cm, bby =.3cm, bb min width=.5cm, bb port length=2pt, bb port sep=1]
\node[bb={1}{1}] (X1) {\tiny$\sigma_1$};
\node[bb={1}{1}, right=of X1] (X2) {\tiny$\sigma_2$};
\node[bb={1}{1}, right=of X2] (X3) {\tiny$\sigma_3$};
\node[bb={1}{1}, fit=(X1) (X2) (X3)] (Y) {};
\draw (Y_in1') to (X1_in1);
\draw (X1_out1) to (X2_in1);
\draw (X2_out1) to (X3_in1);
\draw (X3_out1) to (Y_out1');
\end{tikzpicture}
\end{equation}
\begin{equation}\label{no_exterior}\tag{no exterior}
\begin{tikzpicture}[oriented WD, bbx=1em, bby=1ex]
\node[bb={0}{1},bb name=$X_1$] (X1) {};
\node[bb={1}{0},right =2 of X1, bb name=$X_2$] (X2) {};
\draw[ar] (X1_out1) to (X2_in1);
\end{tikzpicture}
\end{equation}
\begin{equation}\label{simple2}\tag{simple 2}
\begin{tikzpicture}[oriented WD, bbx=1em, bby=1ex]
\node[bb={1}{1},bb name=$X_1$] (X1) {};
\node[bb={1}{1},right =2 of X1, bb name=$X_2$] (X2) {};
\node[bb={1}{1}, fit={($(X1.north west)+(-1,3)$) ($(X1.south)+(0,-3)$) ($(X2.east)+(1,0)$)}, bb name = $Y$] (Y) {};
%
\draw[ar] (Y_in1') to (X1_in1);
\draw[ar] (X1_out1) to (X2_in1);
\draw[ar] (X2_out1) to (Y_out1');
\draw[label]
node at ($(Y_in1')!.5!(X1_in1)+(0,7pt)$) {$A$}
node at ($(X1_out1)!.5!(X2_in1)+(0,7pt)$) {$B$}
node at ($(X2_out1)!.5!(Y_out1')+(0,7pt)$) {$C$};
\end{tikzpicture}
\end{equation}
\begin{equation}\label{no_passing_wires}\tag{no passing wires}
\begin{tikzpicture}[oriented WD, bb small]
\node[bb={1}{1}] (x) {};
\node[bb={2}{2}, fit={(x.north west) ($(x.south east)+(0,-2)$)}] (y) {};
\draw (y_in1') to (x_in1);
\draw (x_out1) to (y_out1');
\draw (y_in2') to (y_out2');
\draw[red, thin] ($(y.north west)+(-1,1)$) -- ($(y.south east)+(1,-1)$);
\draw[red, thin] ($(y.north east)+(1,1)$) -- ($(y.south west)+(-1,-1)$);
\end{tikzpicture}
\end{equation}
\begin{equation}\label{digging1}\tag{digging1}
\begin{tikzpicture}[oriented WD]
\node[bb={1}{0}] (shovel) {\;shovel\;};
\node[bb={1}{0}, below=2 of shovel] (person) {\;person\;};
\node[bb={1}{2}, left=4 of $(shovel)!.5!(person)$] (dig) {};
\draw[label]
node [left=2pt of dig_in1] {digging}
node [right=2pt of dig_out1] {scooping}
node [right=2pt of dig_out2] {levering}
node [left=2pt of shovel_in1] {scooping}
node [left=2pt of person_in1] {levering}
;
\end{tikzpicture}
\end{equation}
\begin{equation}\label{digging2}\tag{digging2}
\begin{tikzpicture}[oriented WD,bb small, font=\tiny]
\node[bb={1}{0}] (shovel) {S};
\node[bb={1}{0}, below=2 of shovel] (person) {P};
\node[bb={1}{2}, left=3 of $(shovel)!.5!(person)$] (dig) {D};
\node[bb={1}{0}, fit=(dig) (shovel) (person)] (outer) {};
\draw (outer_in1') to (dig_in1);
\draw (dig_out1) to (shovel_in1);
\draw (dig_out2) to (person_in1);
\end{tikzpicture}
\end{equation}
%%%% Chapter %%%%
\chapter{Oriented Wiring Diagrams}
% Section %
\section{No Tracing}
\subsection{No splitting}
\begin{equation}\label{parallel}\tag{parallel}
\begin{tikzpicture}[oriented WD, bbx=1em, bby=1ex]
\node[bb={1}{1},bb name=$X_1$] (X1) {};
\node[bb={1}{1},below =2 of X1, bb name=$X_2$] (X2) {};
\node[bb={2}{2}, fit={($(X1.north west)+(-1,3)$) ($(X2.south)+(0,-3)$) ($(X2.east)+(1,0)$)}, bb name = $Y$] (Y) {};
%
\draw[ar] (Y_in1') to (X1_in1);
\draw[ar] (Y_in2') to (X2_in1);
\draw[ar] (X1_out1) to (Y_out1');
\draw[ar] (X2_out1) to (Y_out2');
\draw[label]
node at ($(Y_in1')!.5!(X1_in1)+(0,7pt)$) {$A_1$}
node at ($(Y_in2')!.5!(X2_in1)+(0,7pt)$) {$B_1$}
node at ($(X1_out1)!.5!(Y_out1')+(0,7pt)$) {$A_2$}
node at ($(X2_out1)!.5!(Y_out2')+(0,7pt)$) {$B_2$};
\end{tikzpicture}
\end{equation}
\begin{equation}\label{junky}\tag{junky}
\begin{tikzpicture}[oriented WD, bb min width =.6cm, bb port sep =.5, bby=.3cm, bbx=.6cm,bb port length=3pt]
\node[bb={1}{2}] (X1) {};
\node[bb={2}{1}, below right=-.5 and 1 of X1] (X2) {};
\node[bb={2}{2}, fit=(X1) (X2)] (Y) {};
\draw (Y_in1') to (X1_in1);
\draw (Y_in2') to (X2_in2);
\draw (X1_out1) to (Y_out1');
\draw (X1_out2) to (X2_in1);
\draw (X2_out1) to (Y_out2');
\end{tikzpicture}
\end{equation}
\begin{equation}\label{blue_sub}\tag{blue substitution}
\begin{tikzpicture}[oriented WD,bb min width =.5cm, bbx=.5cm, bb port sep =1,bb port length=.08cm, bby=.15cm]
\begin{scope}[blue!60!black]
\node[bb={1}{2},bb name = {\tiny$X_{1}$}] (X11) {};
\node[bb={2}{2},below right=of X11,bb name = {\tiny$X_{2}$}] (X12) {};
\node[bb={2}{1}, above right=of X12,bb name = {\tiny$X_{3}$}] (X13) {};
\node[bb={2}{2}, fit={($(X11.north west)+(.3,1.5)$) (X12) ($(X13.east)+(-.3,0)$)},bb name = {\scriptsize $Y_3$}] (Y1) {};
\draw (Y1_in1') to (X11_in1);
\draw (Y1_in2') to (X12_in2);
\draw (X11_out1) to (X13_in1);
\draw (X11_out2) to (X12_in1);
\draw (X12_out1) to (X13_in2);
\draw (X12_out2) to (Y1_out2');
\draw (X13_out1) to (Y1_out1');
\end{scope}
\node [bb={1}{2}, below left =1 and 9 of $(Y1.north west)$] (Y1) {\tiny $Y_1$};
\node [bb={1}{1},below=3 of Y1] (Y2) {\tiny $Y_2$};
\node [bb={2}{2}, blue!60!black,below right = 0 and 1 of Y1] (Y3) {\tiny $Y_3$};
\node [bb={2}{1},right=3 of Y1] (Y4) {\tiny $Y_4$};
\node [bb={1}{1},right=3 of Y2] (Y5) {\tiny $Y_5$};
\node [bb={1}{1},right=1of Y5] (Y6) {\tiny $Y_6$};
\node [bb={2}{2},fit={($(Y1.north)+(0,3)$) ($(Y2.south west)+(0,-3)$) (Y3) (Y4) (Y5) (Y6)}, bb name={\footnotesize $Z$}] (Z) {};
\draw (Z_in1') to (Y1_in1);
\draw (Z_in2') to (Y2_in1);
\draw (Y1_out1) to (Y4_in1);
\draw (Y1_out2) to (Y3_in1);
\draw (Y2_out1) to (Y3_in2);
\draw (Y3_out1) to (Y4_in2);
\draw (Y3_out2) to (Y5_in1);
\draw (Y4_out1) to (Z_out1');
\draw (Y5_out1) to (Y6_in1);
\draw (Y6_out1) to (Z_out2');
\end{tikzpicture}
\end{equation}
\begin{equation}\label{terminate}\tag{terminate}
\begin{tikzpicture}[oriented WD]
\node[bb={1}{2}] (A) {};
\node[bb={2}{1}, below right=-1 and 1 of A] (B) {};
\node[bb={0}{0}, fit=(A) (B)] (outer) {};
\node[right=.6 of A_out1] (kill) {$\bullet$};
\draw (outer.west|-A_in1) -- (A_in1);
\draw (outer.west|-B_in2) -- (B_in2);
\draw (A_out1) to node[above, font=\footnotesize] {waste} (kill.center);
\draw (A_out2) to (B_in1);
\draw (B_out1) -- (B_out1-|outer.east);
\end{tikzpicture}
\end{equation}
\begin{equation}\label{IAN:feedforward}\tag{IAN: feedforward}
\begin{tabular}{c|c|c}
\small {Interfaces}&\small {Arrangements}&\small {Nesting}\\\hline
~&&\\
\parbox{.5in}{
\begin{tikzpicture}[oriented WD, bby=1ex]
\node[bb={3}{2}] (X1) {};
\node[bb={1}{1}, below=.4cm of X1] (X2) {};
\node[bb={0}{2}, below=.4cm of X2] (X3) {};
\end{tikzpicture}
}
&
\;\;\parbox{1.3in}{
\begin{tikzpicture}[oriented WD,bb min width =.5cm, bbx=.5cm, bb port sep =1,bb port length=.08cm, bby=.15cm]
\path (0,0) pic {Yonepart};
\end{tikzpicture}
}
&
\;\;\parbox{2in}{
\begin{tikzpicture}[oriented WD, bb small]
\node[bb={1}{2}] (X1) {};
\node[bb={2}{1},right=9 of X1] (X2) {};
\node[bb={1}{2},below right = 2 and 2 of X1] (X11) {};
\node[bb={2}{2},below right=of X11] (X12) {};
\node[bb={2}{1}, above right=of X12] (X13) {};
\node[bb={2}{2}, dashed, fit={($(X11.north west)+(.3,1.5)$) (X12) ($(X13.east)+(-.3,0)$)}] (Y1) {};
\node[bb={2}{2}, fit={($(X1.north west)+(0,3)$) (Y1) (X2)}] (Z) {};
\draw (Y1_in1') to (X11_in1);
\draw (Y1_in2') to (X12_in2);
\draw (X11_out1) to (X13_in1);
\draw (X11_out2) to (X12_in1);
\draw (X12_out1) to (X13_in2);
\draw (X12_out2) to (Y1_out2');
\draw (X13_out1) to (Y1_out1');
\draw (Z_in1') to (X1_in1);
\draw (Z_in2') to (Y1_in2);
\draw (X1_out1) to (X2_in1);
\draw (X1_out2) to (Y1_in1);
\draw (Y1_out1) to (X2_in2);
\draw (Y1_out2) to (Z_out2');
\draw (X2_out1) to (Z_out1');
\end{tikzpicture}
}\\
&&\parbox{1.7in}{(Getting a sense of how\\ fractals are a special case?)}
\end{tabular}
\end{equation}
\subsection{Splitting}
\begin{equation}\label{updrdt}\tag{upd and rdt}
\begin{tikzpicture}[oriented WD, bbx=1.1em, bb min width=3.3em, bby=2ex, bb port sep = 1]
\node[bb={2}{1}] (X1) {$\upd{f}$};
\node[bb={1}{1}, below right=-1 and 2 of X1] (X2) {$\rdt{f}$};
\node[bb={2}{1}, below right=-1.5 and 2 of X2] (X3) {$\upd{g}$};
\node[bb={3}{2}, fit={($(X1.north west)+(-1,0)$) (X2) ($(X3.south east)+(1,0)$)}, bb name = {$\upd{h}$}] (Y) {};
%
\draw (Y_in1') to (X1_in1) ;
\draw (Y_in2') to (X1_in2);
\draw (X1_out1) to (Y_out1');
\draw (X1_out1) to (X2_in1);
\draw (X2_out1) to (X3_in1);
\draw (Y_in3') to (X3_in2);
\draw (X3_out1) to (Y_out2');
\draw[label]
node at ($(Y_in1)+(-.5,0)$) {$A$}
node at ($(Y_in2)+(-.5,0)$) {$S$}
node at ($(Y_in3)+(-.5,0)$) {$T$}
node at ($(X1_out1)+(.3,.6)$) {$S$}
node at ($(X2_out1)+(.3,.6)$) {$B$}
node at ($(X3_out1)+(.3,.6)$) {$T$};
\end{tikzpicture}
\qquad\qquad
\begin{tikzpicture}[oriented WD, bbx=1.1em, bb min width=3.3em, bby=2ex, bb port sep = 1]
\node[bb={1}{1}] (X) {$\rdt{g}$};
\node[bb={2}{1}, fit={($(X.north west)+(-1,1)$) ($(X.south east)+(1,-1)$)}, bb name={$\rdt{h}$}] (Y) {};
\node [circle,minimum size=4pt, inner sep=0, fill] (dot) at ($(Y_in1')+(.5,0)$) {};
%
\draw (Y_in1') to (dot);
\draw (Y_in2') to (X_in1);
\draw (X_out1) to (Y_out1');
\draw[label]
node at ($(Y_in1)-(.5,0)$) {$S$}
node at ($(Y_in2)-(.5,0)$) {$T$}
node at ($(X_out1)+(.3,.6)$) {$C$};
\end{tikzpicture}
\end{equation}
\begin{equation}\label{split_leftright}\tag{split left/right}
\begin{tikzpicture}[oriented WD, bbx=1em, bby=1ex, bb port sep=3 pt]
\node[bb={1}{1},bb name=$X$] (X) {};
\node[bb={1}{2}, fit={(X) ($(X.north east)+(1.2,3)$) ($(X.south west)+(-1.2,-3)$)}, bb name = $Y$] (Y) {};
%
\draw[ar] (Y_in1') to (X_in1);
\draw[ar] (X_out1) to (Y_out1');
\draw[ar] (X_out1) to (Y_out2');
\draw[label]
node at ($(Y_in1')!.5!(X_in1)+(0,7pt)$) {$A$}
node at ($(X_out1)!.5!(Y_out1')+(0,7pt)$) {$B$}
node at ($(X_out1)!.5!(Y_out2')-(0,7pt)$) {$B$};
\end{tikzpicture}
\qquad\qquad
\begin{tikzpicture}[oriented WD, bbx=1em, bby=1ex, bb port sep=2 pt]
\node[bb={2}{1},bb name=$X$] (X) {};
\node[bb={1}{1}, fit={(X) ($(X.north east)+(1.2,3)$) ($(X.south west)+(-1.2,-3)$)}, bb name = $Y$] (Y) {};
%
\draw[ar] (Y_in1') to (X_in1);
\draw[ar] (Y_in1') to (X_in2);
\draw[ar] (X_out1) to (Y_out1');
\draw[label]
node at ($(Y_in1')!.5!(X_in1)+(0,7pt)$) {$A$}
node at ($(Y_in1')!.5!(X_in2)-(0,7pt)$) {$A$}
node at ($(X_out1)!.5!(Y_out1')+(0,7pt)$) {$B$};
\end{tikzpicture}
\end{equation}
\begin{equation}\label{split_and_terminate}\tag{split and terminate}
\begin{tikzpicture}[oriented WD,bb min width =.5cm, bbx=.5cm, bb port sep =1,bb port length=0, bby=.15cm]
\node [bb={1}{2}] (Y1) {\tiny $f_1$};
\node [bb={1}{2},below=3 of Y1] (Y2) {\tiny $f_2$};
\node [bb={2}{1},below right = 0 and 1 of Y1] (Y3) {\tiny $f_3$};
\node [bb={2}{1},right=3 of Y1] (Y4) {\tiny $f_4$};
\node [bb={1}{1},right=3 of Y2] (Y5) {\tiny $f_5$};
\node [bb={2}{2},fit={($(Y1.north)+(0,2)$) ($(Y2.south west)+(0,-2)$) (Y4) (Y5)}] (Z) {};
\node [circle, fill, inner sep=1pt] at ($(Y2_out2)+(0.5,0)$) (kill) {};
\draw (Z_in1'|-Y1_in1) to (Y1_in1);
\draw (Z_in2'|-Y2_in1) to (Y2_in1);
\draw (Y1_out1) to (Y4_in1);
\draw (Y1_out2) to (Y3_in1);
\draw (Y2_out1) to (Y3_in2);
\draw (Y2_out2) to (kill);
\draw (Y3_out1) to (Y4_in2);
\draw (Y3_out1) to (Y5_in1);
\draw (Y4_out1) to (Z_out1'|-Y4_out1);
\draw (Y5_out1) to (Z_out2'|-Y5_out1);
\end{tikzpicture}
\end{equation}
\begin{equation}\label{meringue}\tag{meringue}
\begin{tikzpicture}[oriented WD, align=center, bbx=1.2cm, bby=2ex]
\node[bb={3}{1}, bb min width=.9in] (filling) {make\\lemon\\filling};
\node[bb={2}{1}, bb min width=.9in, below=of filling] (meringue) {make\\meringue};
\node at ($(filling.west)!.5!(meringue.west)$) (helper) {};
\node[bb={1}{2}, left = of helper] (separate) {separate\\egg};
\node[bb={2}{1}, above right = -2 and 1 of filling] (fill) {fill crust};
\node[bb={2}{1}, below right = of fill] (finish) {add\\meringue};
\node[bb={0}{0}, fit=(separate) (meringue) (fill) (finish)] (pie) {};
%
\begin{scope}[font=\tiny]
\draw (pie.west|-fill_in1) to node[above] {crust} (fill_in1);
\draw (pie.west|-filling_in1) to node[above] {butter} (filling_in1);
\draw (pie.west|-filling_in2) to node[above] {sugar} (filling_in2);
\draw (pie.west|-separate_in1) to node[above] {egg} (separate_in1);
\draw (pie.west|-meringue_in2) to node[above] {butter} (meringue_in2);
\draw (separate_out1) to node[above] {yolk} (filling_in3);
\draw (separate_out2) to node[fill=white, inner sep=0.8pt] {white} (meringue_in1);
\draw (filling_out1) to node[fill=white, inner sep=0.8pt] {lemon\\filling} (fill_in2);
\draw (fill_out1) to node[fill=white, inner sep=0.8pt] {lemon pie} (finish_in1);
\draw let \p1=(fill.east|-meringue_out1), \n1=\bbportlen in
(meringue_out1) to node[above] {meringue} (\x1+\n1,\y1) to (finish_in2);
\draw (finish_out1) to node[above] {pie} (finish_out1-|pie.east);
\end{scope}
\end{tikzpicture}
\end{equation}
% Section %
\section{Tracing}
\subsection{No splitting}
\begin{equation}\label{minimal_feedback}\tag{minimal with feedback}
\begin{tikzpicture}[oriented WD, bb small]
\node[bb={1}{1}] (X) {};
\node[bb={0}{0},fit={($(X.north west)+(0,1)$) ($(X.south east)+(0,-1)$)}] (Y){};
\draw[ar] let \p1=(X.north west), \p2=(X.north east), \n1=\bbportlen, \n2={\y1+\bby} in
(X_out1) to[in=0] (\x2+\n1,\n2) -- (\x1-\n1,\n2) to[out=180] (X_in1);
\end{tikzpicture}
\end{equation}
\begin{equation}\label{f_and_g}\tag{f and g}
\begin{tikzpicture}[oriented WD, bb min width =.7cm, bby=1.6ex, bbx=.7cm,bb port length=3pt]
\node[bb port sep=1.6, bb={2}{2}, bb name=$f$] (X1) {};
\node[bb port sep=.8,bb={1}{1}, right=.7 of X1_out1, bb name=$g$] (X2) {};
\node[bb={1}{1}, fit={(X1) (X2) ($(X1.north)+(0,1)$)}] (Y) {};
\draw[ar] (Y_in1') to (X1_in2);
\draw[ar,pos=.8] (X1_out1) to (X2_in1);
\draw[ar] let \p1=(X2.south east), \n1={\y1-.8*\bby}, \n2=\bbportlen in
(X1_out2) -- (\x1+\n2,\n1) to (Y_out1');
\draw[ar] let \p1=(X2.north east), \p2=(X1.north west), \n1={\y2+\bby}, \n2=\bbportlen in
(X2_out1) to[in=0] (\x1+.7*\n2,\n1) -- (\x2-.7*\n2,\n1) to[out=180] (X1_in1);
\end{tikzpicture}
\end{equation}
\begin{equation}\label{little_trace}\tag{little trace}
\begin{tikzpicture}[oriented WD,bb port sep=1, bb port length=2.5pt, bbx=.5cm, bb min width=.5cm, bby=1ex]
\node[bb={2}{2}] (dom) {};
\node[bb={1}{1}, fit={(dom) ($(dom.north)+(0,1)$) ($(dom.south)-(0,2)$)}] (cod) {};
\draw[ar,pos=20] (cod_in1') to (dom_in2);
\draw[ar,pos=2] (dom_out2) to (cod_out1');
\draw[ar] let \p1=(dom.north east), \p2=(dom.north west), \n1={\y2+\bby}, \n2=\bbportlen in (dom_out1) to[in=0] (\x1+\n2,\n1) -- (\x2-\n2,\n1) to[out=180] (dom_in1);
\draw[label]
node[below left=2pt and 3pt of dom_in2]{\tiny$X$}
node[below right=2pt and 3pt of dom_out2]{\tiny$Y$}
node[above left=1pt and 3pt of dom_in1] {\tiny$U$}
node[above right=1pt and 3pt of dom_out1] {\tiny$U$};
\end{tikzpicture}
\end{equation}
\begin{equation}\label{bigger_trace}\tag{bigger trace}
\begin{tikzpicture}[oriented WD, bbx=1em, bby=1ex]
\node[bb={2}{2}, bb name=$X$] (dom) {};
\node[bb={1}{1}, fit={(dom) ($(dom.north east)+(1,4)$) ($(dom.south west)-(1,2)$)}, bb name = $Y$] (cod) {};
\draw[ar,pos=20] (cod_in1') to (dom_in2);
\draw[ar,pos=2] (dom_out2) to (cod_out1');
\draw[ar] let \p1=(dom.north east), \p2=(dom.north west), \n1={\y2+\bby}, \n2=\bbportlen in (dom_out1) to[in=0] (\x1+\n2,\n1) -- (\x2-\n2,\n1) to[out=180] (dom_in1);
\draw[label]
node[below left=2pt and 3pt of dom_in2]{$A$}
node[below right=2pt and 3pt of dom_out2]{$B$}
node[above left=4pt and 6pt of dom_in1] {$C$}
node[above right=4pt and 6pt of dom_out1] {$C$};
\end{tikzpicture}
\end{equation}
\begin{align}\label{dia:series_parallel}\tag{series parallel}
\begin{tikzpicture}[oriented WD, baseline=(Y.center), bbx=1em, bby=1ex]
\node[bb={1}{1},bb name=$R_1$] (X1) {};
\node[bb={1}{1},right =2 of X1, bb name=$R_2$] (X2) {};
\node[bb={1}{1}, fit={($(X1.north west)+(-1,3)$) ($(X1.south)+(0,-3)$) ($(X2.east)+(1,0)$)}, bb name = $R_1R_2$] (Y) {};
%
\draw[ar] (Y_in1') to (X1_in1);
\draw[ar] (X1_out1) to (X2_in1);
\draw[ar] (X2_out1) to (Y_out1');
\end{tikzpicture}
\qquad\qquad
\begin{tikzpicture}[oriented WD,baseline=(Y.center), bbx=1em, bby=1ex]
\node[bb={1}{1},bb name=$R_1$] (X1) {};
\node[bb={1}{1},below =2 of X1, bb name=$R_2$] (X2) {};
\node[bb={2}{2}, fit={($(X1.north west)+(-1,3)$) ($(X2.south)+(0,-3)$) ($(X2.east)+(1,0)$)}, bb name = $R_1\otimes R_2$] (Y) {};
%
\draw[ar] (Y_in1') to (X1_in1);
\draw[ar] (Y_in2') to (X2_in1);
\draw[ar] (X1_out1) to (Y_out1');
\draw[ar] (X2_out1) to (Y_out2');
\end{tikzpicture}
\qquad\qquad
\begin{tikzpicture}[oriented WD,baseline=(cod.center), bbx=1em, bby=1ex]
\node[bb={2}{2}, bb name=$R$] (dom) {};
\node[bb={1}{1}, fit={(dom) ($(dom.north east)+(1,4)$) ($(dom.south west)-(1,2)$)}, bb name = $\tn{Tr}(R)$] (cod) {};
\draw[ar,pos=20] (cod_in1') to (dom_in2);
\draw[ar,pos=2] (dom_out2) to (cod_out1');
\draw[ar] let \p1=(dom.north east), \p2=(dom.north west), \n1={\y2+\bby}, \n2=\bbportlen in (dom_out1) to[in=0] (\x1+\n2,\n1) -- (\x2-\n2,\n1) to[out=180] (dom_in1);
\draw[label]
node[below left=2pt and 3pt of dom_in2]{$A$}
node[below right=2pt and 3pt of dom_out2]{$B$}
node[above left=4pt and 6pt of dom_in1] {$C$}
node[above right=4pt and 6pt of dom_out1] {$C$};
\end{tikzpicture}
\end{align}
\begin{equation}\label{relations1}\tag{Relations 1}
\begin{tikzpicture}[oriented WD, bbx=1em, bby=1ex]
\node[bb={1}{1},bb name=$R_1$] (R1) {};
\node[bb={2}{1}, above right = -2 and 1.5 of R1, bb name=$R_2$] (R2) {};
\node[bb={1}{2}, right = 1.5 of R2, bb name=$R_3$] (R3) {};
\node[bb={1}{1}, fit={($(R1.south west)+(-1,-1)$) (R2) ($(R3.north east)+(1,3)$)}, bb name = $S$] (S) {};
%
\draw (S_in1') to (R2_in1);
\draw (R1_out1) to (R2_in2);
\draw (R2_out1) to (R3_in1);
\draw (R3_out1) to (S_out1');
\draw let \p1=(R3.south east), \p2=(R1.south west), \n1={\y2-\bby}, \n2=\bbportlen in
(R3_out2) to[in=0] (\x1+\n2,\n1) -- (\x2-\n2,\n1) to[out=180] (R1_in1);
%
\draw [label]
node[above left=.4 and 0 of R1_in1] {$x$}
node[above right=.8 and -.1 of R1_out1] {$y$}
node[above left=.4 and 0 of R2_in1] {$v$}
node[above left=.4 and 0 of S_in1] {$v$}
node[above right=.4 and 0 of R2_out1] {$w$}
node[above right=.4 and 0 of R3_out1] {$z$}
node[above right=.4 and 0 of S_out1] {$z$}
node[above right=.4 and 0 of R3_out2] {$x$}
;
\end{tikzpicture}
\end{equation}
\begin{equation}\label{relations2}\tag{relations 2}
\begin{tikzpicture}[oriented WD, bbx=1em, bby=1ex]
\node[bb port sep=3,bb={1}{2}, bb name=$R'_2$] (R2) {};
\node[bb port sep=1.5, bb={1}{1}, right=1 of R2_out2] (R1) {$R'_1$};
\node[bb port sep=3,bb={2}{1}, right=5.5 of R2, bb name=$R'_3$] (R3) {};
\node[bb={1}{1}, fit={(R1) (R2) (R3)}, bb name = $S$] (S) {};
%
\draw (S_in1') to (R2_in1);
\draw (R2_out2) to (R1_in1);
\draw (R2_out1) to (R3_in1);
\draw (R3_out1) to (S_out1');
\draw (R1_out1) to (R3_in2);
%
\draw [label]
node[above right=.4 and 0 of R2_out2] {$y$}
node[above right=.4 and 0 of R1_out1] {$x$}
node[above left=.4 and 0 of R2_in1] {$v$}
node[above right=.4 and 0 of R2_out1] {$w$}
node[above right=.4 and 0 of R3_out1] {$z$}
;
\end{tikzpicture}
\end{equation}
\begin{equation}\label{smallNestingPic}\tag{SmallNestingPic}
\begin{tikzpicture}[oriented WD, bb min width =.5cm, bbx=.5cm, bb port sep =1,bb port length=.08cm, bby=.14cm]
\path (0,0) pic {SmallNestingPic};
\end{tikzpicture}
\end{equation}
\begin{equation}\label{Zcombined}\tag{Zcombined}
\begin{tikzpicture}[oriented WD, bb min width =.5cm, bbx=.5cm, bb port sep =1,bb port length=.08cm, bby=.15cm]
\path (0,0) pic {Zcombined};
\end{tikzpicture}
\end{equation}
\begin{equation}\label{two_modules}\tag{two modules}
\begin{tikzpicture}[oriented WD, bbx=1em, bby=1ex]
\node[bb={3}{2},bb name=$X_1$] (X1) {};
\node[bb={2}{2},below right = -3 and 2 of X1, bb name=$X_2$] (X2) {};
\node[bb={3}{2}, fit={($(X1.north west)+(-1,2)$) ($(X2.south)+(0,-2)$) ($(X2.east)+(1,0)$)}, bb name = $Y$] (Y) {};
%
\draw[ar] (Y_in1') to (X1_in1);
\draw[ar] (X1_out2) to (X2_in1);
\draw[ar] (Y_in2') to (X1_in2);
\draw[ar] (X1_out1) to (Y_out1');
\draw (X2_out1) to (Y_out2');
%
\draw[ar] let \p1=(X2.south east), \p2=(X1.south west), \n1={\y1-\bby}, \n2=\bbportlen in
(X2_out2) to[in=0] (\x1+\n2,\n1) -- (\x2-\n2,\n1) to[out=180] (X1_in3);
\draw[ar] let \p1=(X1.south west), \p2=(X1.south east), \n1={\y1-\bby}, \n2=\bbportlen in
(Y_in3') to (\x1-\n2,\n1) -- (\x2-\n2,\n1) to (X2_in2);
\end{tikzpicture}
\end{equation}
\begin{equation}\label{pretty}\tag{pretty}
\begin{tikzpicture}[oriented WD, bb min width =.5cm, bbx=.5cm, bb port sep =1,bb port length=.08cm, bby=.15cm]
\node[bb={2}{2},green!25!black,bb name = {\tiny$X_1$}] (X11) {};
\node[bb={3}{3},green!25!black,below right=of X11,bb name = {\tiny$X_2$}] (X12) {};
\node[bb={2}{1}, green!25!black,above right=of X12,bb name = {\tiny$X_3$}] (X13) {};
\draw (X11_out1) to (X13_in1);
\draw (X11_out2) to (X12_in1);
\draw (X12_out1) to (X13_in2);
\node[bb={2}{2}, green!25!black, below right = -1 and 1.5 of X12, bb name = {\tiny$X_4$}] (X21) {};
\node[bb={1}{2}, green!25!black, above right=-1 and 1 of X21,bb name = {\tiny$X_5$}] (X22) {};
\draw (X21_out1) to (X22_in1);
\draw let \p1=(X22.north east), \p2=(X21.north west), \n1={\y1+\bby}, \n2=\bbportlen in
(X22_out1) to[in=0] (\x1+\n2,\n1) -- (\x2-\n2,\n1) to[out=180] (X21_in1);