Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redraw commutative diagrams with Tikz #219

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8d2977c
Draw 3.1/sheets
platipo Oct 4, 2019
229abbe
Draw 3.15/spanmul
platipo Oct 4, 2019
969fc2b
Draw 3.6/assocmon
platipo Oct 4, 2019
5022ee0
Draw 3.6/horizcomp
platipo Oct 4, 2019
9efb3dc
Draw 3.6/unitlawcomp
platipo Oct 4, 2019
023ff19
Draw 3.6/unitlawcomp-1
platipo Oct 4, 2019
0447a56
Draw 3.15/twocat
platipo Oct 4, 2019
cfcc06f
Draw 3.15/span
platipo Oct 4, 2019
c9d0038
Draw 3.15/compspan
platipo Oct 4, 2019
d3f39fe
Draw 3.15/pullspan
platipo Oct 4, 2019
19f6df5
Draw 3.15/morphspan
platipo Oct 4, 2019
9ac65b0
Draw 3.15/monad
platipo Oct 4, 2019
5e76102
Draw 3.15/bimonad
platipo Oct 4, 2019
d48eae1
Draw 3.15/spanmonad
platipo Oct 4, 2019
02925f0
Draw 3.15/spanunit
platipo Oct 4, 2019
cb86eda
Draw 2.1/productranking
platipo Oct 4, 2019
3913903
Draw 3.1/3_naturality
platipo Oct 4, 2019
b821f1a
Draw 1.10/3_naturality
platipo Oct 7, 2019
b8070d5
Draw 1.10/4_transport
platipo Oct 7, 2019
506d114
Draw 1.10/5_vertical
platipo Oct 7, 2019
71a3461
Draw 1.10/6_verticalnaturality
platipo Oct 7, 2019
0bfc3cf
Draw 1.10/6a_vertical
platipo Oct 7, 2019
d6f098d
Draw 1.10/10_horizontal
platipo Oct 7, 2019
f29c860
Draw 3.8/alg
platipo Oct 7, 2019
afca832
Draw 3.8/alg2
platipo Oct 7, 2019
35d1882
Draw 3.8/alg3a
platipo Oct 7, 2019
42d2631
Draw 3.8/alg3
platipo Oct 7, 2019
efc48a9
Draw 3.8/alg4
platipo Oct 7, 2019
bdf2df9
Draw 3.8/alg5
platipo Oct 7, 2019
c760e9a
Draw 3.8/alg6
platipo Oct 7, 2019
51f7201
Draw 3.8/alg7
platipo Oct 7, 2019
3b477ab
Draw 3.6/assoc1
platipo Oct 7, 2019
8fd22e2
Draw 3.6/assoc2
platipo Oct 7, 2019
479211c
Draw 3.6/assoc
platipo Oct 7, 2019
7f23332
Draw 3.6/assoctensor
platipo Oct 7, 2019
523b5e2
Draw 3.6/unitmon
platipo Oct 7, 2019
497eda4
Draw 3.6/assoc
platipo Oct 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/content/2.1/declarative-programming.tex
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,21 @@

\begin{figure}[H]
\centering
\includegraphics[width=0.35\textwidth]{images/productranking.jpg}
\begin{tikzpicture}[cells={nodes={font=\fontsize{10}{6}\selectfont}}]
\def\colspace{1}
\def\rowspace{1}
\node (P0) at (2*\rowspace, 2*\colspace) {$c'$};
\node (P12) at (2*\rowspace, 0.8*\colspace) {$c$};
\node (P3) at (0*\rowspace, 0*\colspace) {$a$};
\node (P5) at (4*\rowspace, 0*\colspace) {$b$};

\path[commutative diagrams/.cd,every arrow, every label,line width=0.2mm]
(P0) edge node["$p'$", above] {} (P3)
(P0) edge node["$q'$"] {} (P5)
(P12) edge node[below, "$p$"] {} (P3)
(P12) edge node[below, "$q$"] {} (P5)
(P0) edge[commutative diagrams/dashrightarrow, "$m$", swap] (P12);
\end{tikzpicture}
\end{figure}

\noindent
Expand Down
35 changes: 33 additions & 2 deletions src/content/3.1/its-all-about-morphisms.tex
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ \section{Natural Transformations}

\begin{figure}[H]
\centering
\includegraphics[width=0.35\textwidth]{images/3_naturality.jpg}
\begin{tikzcd}[row sep=large,column sep=large]
& F_a \arrow[dd, dashed, pos=0.7, "F_f"] \arrow[dr, "\alpha_a"] & \\
a \arrow[rr, crossing over] \arrow[ur] \arrow[dd, "f"] & & G_a \arrow[dd, "G_f"] \\
& F_b \arrow[dr, "\alpha_b"] & \\
b \arrow[rr] \arrow[ur] & & G_b \\
\end{tikzcd}
\end{figure}

\noindent
Expand All @@ -78,7 +83,33 @@ \section{Natural Transformations}

\begin{figure}[H]
\centering
\includegraphics[width=0.35\textwidth]{images/sheets.png}
\begin{tikzpicture}[scale=1.15]
\def\between{0.85}
\def\length{1.7}
\def\arclen{1.3}
\draw (-\between/2,0) arc (0:-90:1) -- (-1-\between/2,\length)
arc (-90:0:1) -- cycle;
\draw (\between/2,0) arc (-180:-90:1) -- (1+\between/2,\length)
arc (-90:-180:1) -- cycle;

\def\nodecoordright{\between/2+0.5}
\def\nodecoordleft{-\between/2-0.5}
\def\nodecoordhigh{\length*0.85}
\def\nodecoordlow{\length*0}
\node (Ga) at (\nodecoordright, \nodecoordhigh) {$Ga$};
\node (Fa) at (\nodecoordleft, \nodecoordhigh) {$Fa$};
\node (Gb) at (\nodecoordright, \nodecoordlow) {$Gb$};
\node (Fb) at (\nodecoordleft, \nodecoordlow) {$Fb$};
\node (a) at (4*\nodecoordleft, \nodecoordhigh) {$a$};
\node (b) at (4*\nodecoordleft, \nodecoordlow) {$b$};

\path[commutative diagrams/.cd,every arrow, every label,line width=0.2mm]
(Fa) edge node {$\alpha_a$} (Ga)
(Fa) edge node[swap] {$Ff$} (Fb)
(Ga) edge node {$Gf$} (Gb)
(Fb) edge node {$\alpha_b$} (Gb)
(a) edge node[swap] {$f$} (b);
\end{tikzpicture}
\end{figure}

\noindent
Expand Down
134 changes: 124 additions & 10 deletions src/content/3.15/monads-monoids-and-categories.tex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ \section{Bicategories}

\begin{figure}[H]
\centering
\includegraphics[width=0.35\textwidth]{images/twocat.png}
\begin{tikzcd}[cells={nodes={font=\fontsize{10}{6}\selectfont}}]
a \arrow[r, bend left=50, "f"{name=U, above}] & b \arrow[l, bend left=50, "g"{name=D}] \arrow[Rightarrow, from=U, to=D, "\alpha"]
\end{tikzcd}
\caption{$0$-cells $a, b$; $1$-cells $f, g$; and a $2$-cell $\alpha$.}
\end{figure}

Expand Down Expand Up @@ -123,7 +125,17 @@ \section{Bicategories}

\begin{figure}[H]
\centering
\includegraphics[width=0.35\textwidth]{images/span.png}
\begin{tikzpicture}[cells={nodes={font=\fontsize{10}{6}\selectfont}}]
\def\colspace{1.2}
\def\rowspace{1.5}
\node (x) at (2*\rowspace, 2*\colspace) {$x$};
\node (a) at (1*\rowspace, 1*\colspace) {$a$};
\node (b) at (3*\rowspace, 1*\colspace) {$b$};

\path[commutative diagrams/.cd,every arrow, every label,line width=0.2mm]
(x) edge node[swap] {$f$} (a)
(x) edge node {$g$} (b);
\end{tikzpicture}
\end{figure}

\noindent
Expand All @@ -138,7 +150,21 @@ \section{Bicategories}

\begin{figure}[H]
\centering
\includegraphics[width=0.5\textwidth]{images/compspan.png}
\begin{tikzpicture}[cells={nodes={font=\fontsize{10}{6}\selectfont}}]
\def\colspace{1.2}
\def\rowspace{1.5}
\node (P1) at (1*\rowspace, 1*\colspace) {$x$};
\node (P2) at (3*\rowspace, 1*\colspace) {$y$};
\node (P3) at (0*\rowspace, 0*\colspace) {$a$};
\node (P4) at (2*\rowspace, 0*\colspace) {$b$};
\node (P5) at (4*\rowspace, 0*\colspace) {$c$};

\path[commutative diagrams/.cd,every arrow, every label,line width=0.2mm]
(P1) edge node[swap] {$f$} (P3)
(P1) edge node {$g$} (P4)
(P2) edge node[swap] {$f'$} (P4)
(P2) edge node {$g'$} (P5);
\end{tikzpicture}
\end{figure}

\noindent
Expand All @@ -156,7 +182,25 @@ \section{Bicategories}

\begin{figure}[H]
\centering
\includegraphics[width=0.5\textwidth]{images/pullspan.png}
\begin{tikzpicture}[cells={nodes={font=\fontsize{10}{6}\selectfont}}]
\def\colspace{1.2}
\def\rowspace{1.5}
\node (z) at (2*\rowspace, 2*\colspace) {$z$};
\node (x) at (1*\rowspace, 1*\colspace) {$x$};
\node (y) at (3*\rowspace, 1*\colspace) {$y$};
\node (a) at (0*\rowspace, 0*\colspace) {$a$};
\node (b) at (2*\rowspace, 0*\colspace) {$b$};
\node (c) at (4*\rowspace, 0*\colspace) {$c$};
\node (P0b) at (2*\rowspace, 1.7*\colspace) {\rotatebox[origin=c]{-45}{\Large$\lrcorner$}};

\path[commutative diagrams/.cd,every arrow, every label,line width=0.2mm]
(z) edge node[swap] {$h$} (x)
(z) edge node {$h'$} (y)
(x) edge node[swap] {$f$} (a)
(x) edge node[swap] {$g$} (b)
(y) edge node {$f'$} (b)
(y) edge node {$g'$} (c);
\end{tikzpicture}
\end{figure}

\noindent
Expand All @@ -170,7 +214,21 @@ \section{Bicategories}

\begin{figure}[H]
\centering
\includegraphics[width=0.4\textwidth]{images/morphspan.png}
\begin{tikzpicture}[cells={nodes={font=\fontsize{10}{6}\selectfont}}]
\def\colspace{1.2}
\def\rowspace{1.2}
\node (P0) at (2*\rowspace, 2*\colspace) {$x$};
\node (P12) at (2*\rowspace, 0.8*\colspace) {$y$};
\node (P3) at (0*\rowspace, 0*\colspace) {$a$};
\node (P5) at (4*\rowspace, 0*\colspace) {$b$};

\path[commutative diagrams/.cd,every arrow, every label,line width=0.2mm]
(P0) edge node {} (P3)
(P0) edge node {} (P5)
(P12) edge node {} (P3)
(P12) edge node[swap] {} (P5)
(P0) edge[commutative diagrams/Rightarrow, "$h$"] (P12);
\end{tikzpicture}
\caption{A $2$-cell in $\cat{Span}$.}
\end{figure}

Expand Down Expand Up @@ -207,7 +265,17 @@ \section{Monads}

\begin{figure}[H]
\centering
\includegraphics[width=0.3\textwidth]{images/monad.png}
\begin{tikzpicture}[cells={nodes={font=\fontsize{10}{6}\selectfont}}]
\def\colspace{1.8}
\def\rowspace{1.8}
\node (P0) at (1*\rowspace, 1*\colspace) {$T\circ T$};
\node (P1) at (1*\rowspace, 0*\colspace) {$T$};
\node (P2) at (0*\rowspace, 0*\colspace) {$I$};

\path[commutative diagrams/.cd,every arrow, every label,line width=0.2mm]
(P0) edge node {$\mu$} (P1)
(P2) edge node {$\eta$} (P1);
\end{tikzpicture}
\end{figure}

\noindent
Expand All @@ -228,7 +296,9 @@ \section{Monads}

\begin{figure}[H]
\centering
\includegraphics[width=0.3\textwidth]{images/bimonad.png}
\begin{tikzcd}[cells={nodes={font=\fontsize{10}{6}\selectfont}}]
a \arrow[loop above, "id"{name=id}] \arrow[loop, "T"{name=T}, looseness=18, out=130,in=50] \arrow[loop, "T\circ T"{name=T2}, looseness=25, out=140,in=40] \arrow[Rightarrow, from=id, to=T, "\eta"] \arrow[Rightarrow, from=T2, to=T, "\mu"']
\end{tikzcd}
\end{figure}

\noindent
Expand All @@ -249,7 +319,17 @@ \section{Monads}

\begin{figure}[H]
\centering
\includegraphics[width=0.3\textwidth]{images/spanmonad.png}
\begin{tikzpicture}[cells={nodes={font=\fontsize{10}{6}\selectfont}}]
\def\colspace{1.2}
\def\rowspace{1.5}
\node (P0) at (2*\rowspace, 2*\colspace) {$Arr$};
\node (P1) at (1*\rowspace, 1*\colspace) {$Ob$};
\node (P2) at (3*\rowspace, 1*\colspace) {$Ob$};

\path[commutative diagrams/.cd,every arrow, every label,line width=0.2mm]
(P0) edge node[swap] {$dom$} (P1)
(P0) edge node {$cod$} (P2);
\end{tikzpicture}
\end{figure}

\noindent
Expand All @@ -272,7 +352,21 @@ \section{Monads}

\begin{figure}[H]
\centering
\includegraphics[width=0.4\textwidth]{images/spanunit.png}
\begin{tikzpicture}[cells={nodes={font=\fontsize{10}{6}\selectfont}}]
\def\colspace{1.2}
\def\rowspace{1.2}
\node (P0) at (2*\rowspace, 2*\colspace) {$Ob$};
\node (P12) at (2*\rowspace, 0.8*\colspace) {$Arr$};
\node (P3) at (0*\rowspace, 0*\colspace) {$Ob$};
\node (P5) at (4*\rowspace, 0*\colspace) {$Ob$};

\path[commutative diagrams/.cd,every arrow, every label,line width=0.2mm]
(P0) edge node[swap] {$id$} (P3)
(P0) edge node {$id$} (P5)
(P12) edge node {$dom$} (P3)
(P12) edge node[swap] {$cod$} (P5)
(P0) edge[commutative diagrams/Rightarrow, "$\eta$"] (P12);
\end{tikzpicture}
\end{figure}

\noindent
Expand All @@ -293,7 +387,27 @@ \section{Monads}

\begin{figure}[H]
\centering
\includegraphics[width=0.5\textwidth]{images/spanmul.png}
\begin{tikzpicture}[cells={nodes={font=\bfseries}}]
\def\colspace{1.2}
\def\rowspace{1.5}
\node (P0) at (2*\rowspace, 2*\colspace) {$Arr\otimes Arr$};
\node (P1) at (1*\rowspace, 1*\colspace) {$Arr$};
\node (P2) at (3*\rowspace, 1*\colspace) {$Arr$};
\node (P3) at (0*\rowspace, 0*\colspace) {$Ob$};
\node (P4) at (2*\rowspace, 0*\colspace) {$Ob$};
\node (P5) at (4*\rowspace, 0*\colspace) {$Ob$};
\node (P0b) at (2*\rowspace, 1.7*\colspace) {\rotatebox[origin=c]{-45}{$\lrcorner$}};


\path[commutative diagrams/.cd,every arrow, every label,line width=0.2mm]
(P0) edge node {} (P1)
(P0) edge node {} (P2)
(P1) edge node[swap] {$dom$} (P3)
(P1) edge node[swap] {$cod$} (P4)
(P2) edge node[swap] {$dom$} (P4)
(P2) edge node[swap] {$cod$} (P5);
\end{tikzpicture}

\end{figure}

\noindent
Expand Down
42 changes: 38 additions & 4 deletions src/content/3.6/monads-categorically.tex
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,21 @@

\begin{figure}[H]
\centering
\includegraphics[width=0.4\textwidth]{images/unitlawcomp-1.png}
\begin{tikzpicture}[cells={nodes={font=\fontsize{10}{6}\selectfont}}]
\def\colspace{1.5}
\def\rowspace{2}
\node (P0) at (0*\rowspace, 1*\colspace) {$I\circ T$};
\node (P1) at (1*\rowspace, 1*\colspace) {$T^2$};
\node (P2) at (2*\rowspace, 1*\colspace) {$T\circ I$};
\node (P3) at (1*\rowspace, 0*\colspace) {$T$};

\path[commutative diagrams/.cd,every arrow, every label,line width=0.2mm]
(P0) edge node {$\eta\,\circ\, T$} (P1)
(P1) edge node {$T\,\circ\,\eta$} (P2)
(P0) edge node {} (P3)
(P1) edge node {$\eta$} (P3)
(P2) edge node {} (P3);
\end{tikzpicture}
\end{figure}

\noindent
Expand Down Expand Up @@ -276,7 +290,11 @@ \section{Monoidal Categories}

\begin{figure}[H]
\centering
\includegraphics[width=0.5\textwidth]{images/assocmon.png}
\begin{tikzcd}[cells={nodes={font=\fontsize{10}{6}\selectfont}}]
(a\times a) \times a \arrow[rr, "\alpha"] & & a\times (a\times a) \\
a\times a \arrow[from=1-1, "\mu\times id"] & & a\times a \arrow[from=1-3, "id\times\mu"] \\
& a \arrow[from=2-1, "\mu"] \arrow[from=2-3, "\mu"'] & \\
\end{tikzcd}
\end{figure}

\noindent
Expand Down Expand Up @@ -396,7 +414,9 @@ \section{Monads as Monoids}

\begin{figure}[H]
\centering
\includegraphics[width=0.4\textwidth]{images/horizcomp.png}
\begin{tikzcd}[cells={nodes={font=\fontsize{10}{6}\selectfont}}]
C \arrow[r, bend left=50, "F"{name=U, above}] \arrow[r, bend right=50, "F'"{name=D, below}] & C \arrow[Rightarrow, from=U, to=D] \arrow[r, bend left=50, "G"{name=U, above}] \arrow[r, bend right=50, "G'"{name=D, below}] & C \arrow[Rightarrow, from=U, to=D]
\end{tikzcd}
\end{figure}

\noindent
Expand All @@ -423,7 +443,21 @@ \section{Monads as Monoids}

\begin{figure}[H]
\centering
\includegraphics[width=0.5\textwidth]{images/unitlawcomp.png}
\begin{tikzpicture}[cells={nodes={font=\fontsize{10}{6}\selectfont}}]
\def\colspace{1.5}
\def\rowspace{2}
\node (P0) at (0*\rowspace, 1*\colspace) {$T\circ I$};
\node (P1) at (1*\rowspace, 1*\colspace) {$T^2$};
\node (P2) at (2*\rowspace, 1*\colspace) {$I\circ T$};
\node (P3) at (1*\rowspace, 0*\colspace) {$T$};

\path[commutative diagrams/.cd,every arrow, every label,line width=0.2mm]
(P0) edge node {$\eta\,\circ\, T$} (P1)
(P1) edge node {$T\,\circ\,\eta$} (P2)
(P0) edge node {} (P3)
(P1) edge node {$\eta$} (P3)
(P2) edge node {} (P3);
\end{tikzpicture}
\end{figure}

\noindent
Expand Down