-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtalk.tex
613 lines (567 loc) · 22 KB
/
talk.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
\documentclass[aspectratio=169,handout]{beamer}
\makeatletter
\appto\input@path{{pkgs/awesome-beamer},{pkgs/smile}}
\makeatother
\definecolor{dgreen}{HTML}{081c15}
\usetheme[english,color,coloraccent=dgreen,notoc,hyperref,listings]{awesome}
\usepackage[
backend=biber,
style=alphabetic
]{biblatex}
\usepackage[strict,autostyle]{csquotes}
\nocite{*}
\addbibresource{refs.bib}
\usetikzlibrary{tikzmark,decorations.text}
\def\m#1{\tikzmark{#1}}
\newcommand<>\ul[5][0pt]{\begin{tikzpicture}[o,blend mode=multiply]
\coordinate(#5_west) at ([yshift=#1-0.25ex]pic cs:#3);
\coordinate(#5_east) at ([yshift=#1+0.35ex]pic cs:#4);
\fill[ul=#2,visible on=#6] (#5_west) rectangle node(#5){} (#5_east);
\end{tikzpicture}}
\tikzset{ul/.style={#1!70!black,opacity=0.40,rounded corners=.17ex}}
\def\um#1#2#3{\begin{tikzpicture}[o]
\coordinate(#3_west) at ([yshift=0ex]pic cs:#1);
\coordinate(#3_east) at ([yshift=0ex]pic cs:#2);
\coordinate(#3) at ($(#3_west)!0.5!(#3_east)$);
\end{tikzpicture}}
\usepackage{emoji}
\usepackage{fontawesome5}
\usepackage{tikzpingus}
\usepackage{fancyqr}
\def\checkbox{\raisebox{-2pt}{\begin{tikzpicture}[]
\node (B) {\color{accent}\scalebox{.65}{\faCheck}};
\node[roundednode,node on layer=background,fill=lightgray!30,rnd,minimum width=1.7ex,minimum height=1.7ex] at (B) {};
\end{tikzpicture}}}
\usepackage[sfdefault]{FiraSans}
\usepackage{firamath-otf}
\usepackage{fontspec}
\setmonofont[
Path = ./fonts/,
Scale = .9,
Extension = .ttf,
Contextuals=Alternate,
BoldFont={*-Bold},
UprightFont={*-Regular},
]{Fira Code}
\usepackage[duration=25,defaulttransition=fade]{pdfpc}
\newcommand<>{\talknote}[1]{\only#2{\pdfpcnote{- #1}\relax}}
\background{res/uni.jpg}
\title{Constrained Zig}
\subtitle{Exploring properties of constraint programs}
\author{Lukas Pietzschmann}
\email{lukas.pietzschmann@uni-ulm.de}
\institute{Zigtoberfest}
\uni{Hochschule München}
\location{Munich}
\date{October 19$^\text{th}$, 2024}
\makeatletter
\newsavebox\avatar
\savebox\avatar{\begin{tikzpicture}
\node[roundnode,fill=accent,inner sep=0,outer sep=0,minimum width=1.75cm+\smile@linewidth] at (0,0) {};
\clip (0,0) circle (\dimexpr1.75cm/2\relax);
\node at (0,0) {\includegraphics[width=1.75cm]{res/me.png}};
\end{tikzpicture}}
\def\link #1 to #2;{\def\ULdepth{.5pt}\def\ULthickness{.1pt}\uline{\href{#2}{#1}}}
\def\ergo{\raisebox{-1pt}{\faAngleRight}}
\newcommand<>\tc[2]{\textcolor#3{#1}{#2}}
\newcommand<>\cg[1]{\tc#2{gray}{#1}}
\newcommand<>\cb[1]{\tc#2{black}{#1}}
\def\amcard#1#2#3{\begin{tikzpicture}
\node (T) {\faCaretRight~#2};
\node[below=1mm of T.south west,anchor=north west,text width=\textwidth/2-8.5mm,align=justify] (D) {\small#3};
\node[roundednode,fit=(T)(D),node on layer=background,fill=lightgray!20] (F) {};
\node[node on layer=background,anchor=north east,scale=2,opacity=0.1] at (F.north east) {#1};
\end{tikzpicture}}
\tikzset{bb/.style={draw=tcbcolframe,dash pattern=on 1mm off 1mm,dash phase=0.5mm,tcb@spec,segmentation@style}}
\def\setlinetext#1{\small\color{tcbcolframe}\contourlength{1.5pt}\contour{tcbcolback}{#1}}
\newenvironment{versusbox}[1][]{
\begin{beamerbox}[sidebyside,segmentation code={
\path[bb] (segmentation.north) to node[rotate=90]{\setlinetext{#1}} (segmentation.south);
}]{gray}{}%
}{\end{beamerbox}}
\usepackage[verbatim]{lstfiracode}
\lstdefinestyle{firastyleb}{style=FiraCodeStyle,style=smile@lst@base}
\lstdefinestyle{firastylep}{style=FiraCodeStyle,style=smile@lst@plain}
\lstset{tabsize=4,style=firastylep}
\lstdefinelanguage{chr}{
keywords={/, <=>, true}
}
\lstnewenvironment{chr}{\lstset{language=chr}}{}
\newcommand\chri[2][]{\lstinline[language=chr,#1]{#2}}
\def\signed#1{{\leavevmode\unskip\nobreak\hfil\penalty50\hskip2em
\hbox{}\nobreak\hfil(#1)%
\parfillskip=0pt \finalhyphendemerits=0 \endgraf}}
\newsavebox\quotebox
\newenvironment{aquote}[1]
{\savebox\quotebox{#1}\begin{quote}}
{\signed{\usebox\quotebox}\end{quote}}
\begin{document}
\makeatletter
\maketitle
\section{About Me}
\begin{frame}
\frametitle{About Me}
\begin{tikzpicture}[node distance=2mm]
\node[roundednode,shadow,draw=none,fill=lightgray,node on layer=background,minimum width=\textwidth,minimum height=2cm] (B) {};
\node[xshift=1.75cm/2+0.25cm] at (B.west) {\usebox\avatar};
\node[] at (B) {\bfseries Hi, I'm Lukas!};
\begin{scope}[scale=0.6]
\pingu[left wing wave,heart=accent,shift={(7cm,2mm)}]
\end{scope}
\uncover<2->{\node[below=of B.south west,anchor=north west] (S) {\amcard{\faUniversity}{Studies}{I'm studying computer science for my master's degree at Ulm University. Currently, I'm working on my thesis.}};}
\uncover<3->{\node[below=of B.south east,anchor=north east] (I) {\amcard{\faLightbulb}{Interests}{I enjoy various things, but compilers, typesetting, and functional programming spark the most joy inside me.}};}
\end{tikzpicture}
\end{frame}
\section{Motivation}
\begin{frame}[fragile]
\frametitle[A first small example]{Motivation}
\begin{onlyenv}<2->
\begin{aquote}{Eugene C. Freuder~\cite{freuder1997}}
Constraint Programming represents one of the closest approaches computer science
has yet made to the holy grail of programming: the user states the problem, the
computer solves it.
\end{aquote}\bigskip
\end{onlyenv}\onslide<3->
\lstset{xleftmargin=15mm}\begin{chr}
§\m{ps1}§min(N)§\m{pe1}§ §\m{rem1s}§\§\m{rem1e}§ §\m{ps2}§min(M)§\m{pe2}§ §\m{simpa1s}§<=>§\m{simpa1e}§ §\m{gs1}§N <= M§\m{ge1}§ | §\m{rs1}§true§\m{re1}§
\end{chr}
\ul<4->{blue}{ps1}{pe1}{p1}%
\ul<5->{gray}{rem1s}{rem1e}{rem1}%
\ul<4->{blue}{ps2}{pe2}{p2}%
\ul<5->{gray}{simpa1s}{simpa1e}{simpa1}%
\ul<6->{green}{gs1}{ge1}{g1}%
\ul<7->{red}{rs1}{re1}{r1}%
\begin{tikzpicture}[o,execute at begin node={\small}]
\node[shift={(-4mm,-7mm)},left,visible on=<4->] at (p1) (P1) {First min constraint};
\node[shift={(-4mm, -13mm)},left,visible on=<5->] at (rem1) (REM1) {Operation};
\node[shift={(4mm,-13mm)},right,visible on=<4->] at (p2) (P2) {Second min constraint};
\node[shift={(4mm,-7mm)},right,visible on=<6->] at (g1) (G1) {Guard};
\node[shift={(4mm,-7mm)},right,visible on=<7->] at (r1) (R1) {Result};
\draw[textarrow=blue,visible on=<4->] (P1) -| (p1);
\draw[textarrow=gray,visible on=<5->] (REM1) -| (rem1);
\draw[textarrow=blue,visible on=<4->] (P2) -| (p2);
\draw[textarrow=green,visible on=<6->] (G1) -| (g1);
\draw[textarrow=red,visible on=<7->] (R1) -| (r1);
\end{tikzpicture}
\end{frame}
\section{CHR Syntax and Semantic}
\begin{frame}[label={rules}]
\frametitle[Rules]{Introduction to CHR}
\onslide<2->CHR knows about three kinds of rules:\par\medskip
\begin{wide}
\begin{columns}[c]
\begin{column}<3->{0.33\textwidth}
\begin{block}[Propagation]
\centerline{\chri{C => G | CN}}\medskip
\chri{CN} is inferred if \chri{G} holds
\end{block}
\end{column}
\begin{column}<4->{0.33\textwidth}
\begin{block}[Simplification]
\centerline{\chri{C <=> G | CN}}\medskip
\chri{CO} is simplified to \chri{CN} if \chri{G} holds
\end{block}
\end{column}
\begin{column}<5->{0.33\textwidth}
\begin{block}[Simpagation]
\centerline{\chri{C}$_1$ \chri{\\ C}$_2$ \chri{<=> G | CN}}\medskip
\chri{C}$_2$ is simplified to \chri{CN} if \chri{G} holds
\end{block}
\end{column}
\end{columns}
\end{wide}\par\bigskip
\begin{tabular}{r|l|l}
\onslide<8->C & Head & CHR Constraints \\
\onslide<9->G & Guard & Conjunction of \m{bu1s}built-ins\m{bu1e} \\
\onslide<11->CN & Body & CHR Constraints and conjunction of built-ins
\end{tabular}\onslide<1->
\ul<10->{gray}{bu1s}{bu1e}{bi}\begin{tikzpicture}[o]
\node[shift={(23mm,5mm)},visible on=<10->] at (bi) (BI) {\small\color{darkgray}Zig code};
\draw[textarrow,shorten <=0,visible on=<10->] (BI.west) to (bi_east);
\end{tikzpicture}
\begin{modal}<beamer:6|handout:2>[Generalized Simpagation Rule]
\hskip5mm\par Behind the curtain, the embedding represents every rule as a 4-tuple:
\[\langle KH, RH, G, B \rangle\]
$KH$: Kept Head\hfill$RH$: Removed Head\hfill$G$: Guard\hfill$B$: Body\par\medskip
A propagation rule would then look like this: $\langle KH, \emptyset, G, B \rangle$
\end{modal}
\onslide<beamer:6|handout:2>\begin{tikzpicture}[o,scale=0.5]
\pingu[small,heart=accent,halo=blue,staff right,right wing wave,shift={(2.5cm,-1.8cm)}] at (current page.south east)
\end{tikzpicture}
\end{frame}
\begin{frame}[fragile,t]
\frametitle[Constraint Store]{Introduction to CHR}
\vspace{7mm}
\begin{columns}[T]
\begin{column}{0.65\textwidth}
\begin{tikzpicture}\tikzset{query/.style={roundednode,inner sep=1.5mm,fill=lightgray!25,draw=gray,minimum width=6.7cm,text width=6.7cm}}
\def\q{\only<all:1>{\color{gray}~Query~\ldots}}
\only<-4>{\node[query] (Q) {\strut\cg{\ergo}\q\ttfamily~\only<all:2->{min(3)}\only<all:3->{, min(1)}\only<all:4->{, min(5)}};}
\only<all:5->{\node[query] (Q) {\strut\cg{\ergo}\color{gray}\ttfamily~\cb<all:5-7>{min(3)}, \cb<all:9-12>{min(1)}, \cb<all:14-16>{min(5)}};}
\end{tikzpicture}
{\ttfamily%
\m{ps3}\cg<all:6-8,10-13,15-16>{min(N)}\m{pe3}
\chri{\\}
\m{ps4}\cg<all:6-8,10-13,15-16>{min(M)}\m{pe4}
\chri{<=>}
\m{gs2}\cg<all:6-8,10-13,15-16>{N}\m{ge2}
\chri{<=}
\m{rs2}\cg<all:6-8,10-13,15-16>{M}\m{re2}
\chri|
\chri{true}%
}\um{ps3}{pe3}{x}\um{ps4}{pe4}{y}\um{gs2}{ge2}{z}\um{rs2}{re2}{a}\par\vskip7mm
\ergo~\only<all:-4>{Add constraints to solve for}%
\only<all:5-7,10-11,15-16>{Check if we can find a matching for the currently active constraint}%
\only<all:8,12-13>{Fire the rule that matched}%
\only<all:9,14,17>{Make next query constraint active}%
\only<all:18>{The remaining constraints in the store are the solution}%
\end{column}
\begin{column}{0.25\textwidth}
\begin{tikzpicture}
\node[roundednode,lcr,dashed,fill=lightgray!25,draw=gray,minimum width=\awesome@sidebarwidth-3mm,minimum height=3cm,anchor=north west,xshift=\awesome@textmargin] at ([yshift=-1.5cm]current page.north west) (S) {};
\node[roundednode,color=black,text=white] at (S.south) {\tiny Constraint Store};
\node[anchor=north,yshift=-2mm,visible on=<all:8-11>] at (S.north) {\ttfamily min(3)};
\node[anchor=north,yshift=-2mm,visible on=<all:13->] at (S.north) {\ttfamily min(1)};
\end{tikzpicture}
\end{column}
\end{columns}
\begin{tikzpicture}[o]
\node[visible on=<all:6>] at (x) {\bfseries\chri{min(3)}};
\node[visible on=<all:10-12>] at (x) {\bfseries\chri{min(1)}};
\node[visible on=<all:16>] at (x) {\bfseries\chri{min(1)}};
\node[visible on=<all:7>] at (y) {\bfseries\chri{min(3)}};
\node[visible on=<all:11-12>] at (y) {\bfseries\chri{min(3)}};
\node[visible on=<all:15-16>] at (y) {\bfseries\chri{min(5)}};
\node[visible on=<all:6>] at (z) {\bfseries\chri{3}};
\node[visible on=<all:10-12>] at (z) {\bfseries\chri{1}};
\node[visible on=<all:16-16>] at (z) {\bfseries\chri{1}};
\node[visible on=<all:7>] at (a) {\bfseries\chri{3}};
\node[visible on=<all:11-12>] at (a) {\bfseries\chri{3}};
\node[visible on=<all:15-16>] at (a) {\bfseries\chri{5}};
\end{tikzpicture}
\end{frame}
\section{The Embedding}
\tikzset{paper/.style={roundednode,anchor=south east,rotate=#1,shadow}}
\newsavebox\paper
\savebox\paper{\begin{tikzpicture}
\node[paper=-10,xshift=4mm] (3) {\includegraphics[page=3,width=2.5cm]{res/FreeCHR.pdf}};
\node[paper=-05,xshift=2mm] (2) {\includegraphics[page=2,width=2.5cm]{res/FreeCHR.pdf}};
\node[paper=-00,xshift=0mm] (1) {\includegraphics[page=1,width=2.5cm]{res/FreeCHR.pdf}};
\end{tikzpicture}}
\begin{frame}
\frametitle{Inner workings of the Embedding}
\begin{wide}
\begin{columns}[c]
\begin{column}{\dimexpr\textwidth-\wd\paper\relax}
\begin{itemize}[<+(1)->]
\item Based on the concepts established in~\citetitle{rechenberger2023}~\cite{rechenberger2023}
\end{itemize}\par\bigskip
\begin{itemize}[<+(1)->]
\item Every rule is represented as a 4-tuple (see slide \ref{rules<2>})
\item We then compose more complex programs from subprograms --- or ultimately from single rules
\item Lastly, we apply the composition to a state until a fixpoint is reached
\end{itemize}
\end{column}
\begin{column}<2->{\wd\paper}
\usebox\paper
\end{column}
\end{columns}
\end{wide}
\end{frame}
\newsavebox\pingub
\savebox\pingub{\begin{tikzpicture}
\pingu[heart=accent,sun glasses,head band=red,wings wave,banner=Check it out!]
\end{tikzpicture}}
\begin{frame}
\frametitle{ZigCHR online}
\begin{wide}
\begin{columns}[c]
\begin{column}{\dimexpr\textwidth-4cm\relax}
\begin{itemize}
\item The embedding's source code is available on \link GitHub to /~https://github.com/LukasPietzschmann/zigchr;
\item Clone it and try it out yourself!
\end{itemize}\par\medskip
\begin{itemize}
\item Also, the repo contains some of the examples we're discussing today
\end{itemize}
\end{column}
\begin{column}{4cm}
\begin{center}
\fancyqr[height=3cm,color=accent]{https://lukas.pietzschmann.org/talks/zigtoberfest}\par
\parbox{4cm}{\centering\tiny\url{https://lukas.pietzschmann.org/talks/zigtoberfest}}
\end{center}
\end{column}
\end{columns}
\end{wide}
\begin{tikzpicture}[o]
\node[shift={(6mm,1.3cm)},rotate=-30,scale=0.5] at (current page.south west) (P) {\usebox\pingub};
\end{tikzpicture}
\end{frame}
\section{Some interesting examples}
\begin{frame}
\frametitle{Anytime Algorithms}
\begin{itemize}[<+(1)->]
\item We can interrupt the execution at anytime
\item The intermediate state will be an approximation of the final result
\item After that, the program will continue like nothing happened
\end{itemize}
\begin{itemize}
\item<5-> This is especially useful if we need to guarantee a certain response time
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Easy Memorization}
\begin{itemize}
\item[\ergo]<3-> Quizz: Change three symbols to make this have linear complexity
\end{itemize}\par\bigskip
\begin{onlyenv}<{2,3}>
\begin{chr}
fib(0, M) <=> M = 1
fib(1, M) <=> M = 1
fib(N, M) <=> N >= 2 |
fib(N-1,M1), fib(N-2,M2), M is M1 + M2
\end{chr}
\end{onlyenv}
\begin{onlyenv}<4->
\begin{chr}
fib(0, M) ==> M = 1
fib(1, M) ==> M = 1
fib(N, M) ==> N >= 2 |
fib(N-1,M1), fib(N-2,M2), M is M1 + M2
\end{chr}
\end{onlyenv}
\par\bigskip
\begin{itemize}
\item<4-> We have to change the simplification rules to propagations
\item<5-> This way, we do not remove calculated values from the store
\item<6-> But we remember them for future use
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle[What Confluence is]{Confluence}
\begin{wide}
\begin{columns}[c]
\begin{column}<2->{0.48\textwidth}
\begin{block}[Rule order matters]
\begin{chr}
throw(Coin) <=> head
throw(Coin) <=> tail
\end{chr}
\begin{itemize}[<+(2)->]
\item Depending on which rule we check first, we get a different result
\item That's great for coin tossing
\item Not so much for determinism
\end{itemize}
\end{block}
\end{column}
\begin{column}<+(2)->{0.48\textwidth}
\begin{block}[Constraint order matters]
\begin{chr}
set(K,V), c(K,V') <=> c(K,V)
\end{chr}
\begin{itemize}[<+(2)->]
\item Imagine the following query:\newline\chri{c(x,0),set(x,1),set(x,2)}
\item Depending on what constraint we select first, \chri{x} will be set differently
\end{itemize}
\end{block}
\end{column}
\end{columns}\par\bigskip
\onslide<+(2)->{\ergo~In confluent programs, the relation between the initial and final state is a function}
\end{wide}
\end{frame}
\begin{frame}[fragile]
\frametitle[Achieve Confluence]{Confluence}
\begin{columns}[t]
\begin{column}{0.7\textwidth}
\begin{itemize}
\item<3-> Both rules are applicable to a state containing only \chri{a}
\item<4-> From this, we can derive the two new states
\item<5-> Confluence requires then to be joinable
\end{itemize}
\end{column}
\begin{column}<2->{0.2\textwidth}
\begin{chr}
a => b
a => false
\end{chr}
\end{column}
\end{columns}\par\vskip6mm\onslide<6->{\centerline{\textcolor{gray}{\rule{\textwidth-1cm}{\smile@linewidth}}}}
\begin{columns}[t]
\begin{column}{0.7\textwidth}
\begin{itemize}
\item<6-> We can make the two states joinable by adding a single rule
\end{itemize}
\end{column}
\begin{column}<7->{0.2\textwidth}
\begin{chr}
a => b
a => false
b => false
\end{chr}
\end{column}
\end{columns}
\begin{tikzpicture}[o]
\node[shift={(\awesome@sidebarwidth/2+6mm,16mm)},visible on=<3->] at (current page.west) (a) {\chri{a}};
\node[yshift=-2cm,visible on=<5->] at (a) (e) {\chri{false} $\not\equiv$ \chri{b}};
\coordinate (m) at ($ (a)!0.5!(e) $);
\node[xshift=7mm,visible on=<4->] at (m) (x) {\chri{b}};
\node[xshift=-7mm,visible on=<4->] at (m) (y) {\chri{false}};
\node[roundednode,draw=gray,fill=lightgray!20,node on layer=background,dashed,lcr,fit=(a)(e)(x)(y),visible on=<3->] {};
\draw[arrow,visible on=<4->] (a) -- (x);
\draw[arrow,visible on=<4->] (a) -- (y);
\draw[arrow,visible on=<5->] (x) -- (e);
\draw[arrow,visible on=<5->] (y) -- (e);
\end{tikzpicture}
\end{frame}
\begin{frame}[fragile]
\frametitle[Gotchas]{Confluence}
\begin{itemize}\setlength\itemsep{1em}
\item<2->[\checkbox] Not every program can be made confluent
\begin{visibleenv}<3->
\begin{chr}
a => true
a => false
\end{chr}
\end{visibleenv}
\item<4->[\checkbox] Be aware of the semantics of your program
\begin{visibleenv}<5->
\begin{chr}
set(K, V), c(K, V') <=> c(K, V)
\end{chr}
\faCaretUp~does not equal~\faCaretDown
\begin{chr}
set(K, V), c(K, V') <=> V = V' | c(K, V)
\end{chr}
\end{visibleenv}
\end{itemize}
\end{frame}
\begin{frame}
\frametitle[Why we need it]{Confluence}
\begin{wide}
\begin{itemize}
\item<2-> If a program terminates, we can check if it's confluent
\item<3-> If it is, we get more cool properties for free:
\end{itemize}
\begin{columns}[b]
\begin{column}<4->{0.49\textwidth}
\begin{block}[Incrementality]
\begin{itemize}
\item We can add constraints during the program's execution
\item<5-> They will eventually participate in the computation
\item<6-> The result will be the same as if was there from the beginning
\end{itemize}
\end{block}
\end{column}
\begin{column}<7->{0.49\textwidth}
\begin{tikzpicture}[o,scale=.6]
\pingu[wings wave,princess crown,eyes shiny,xshift=15mm]
\end{tikzpicture}
\begin{block}[Parallelism]
\begin{itemize}
\item The algorithm can be executed in parallel
\item<8-> Without any modifications
\end{itemize}
\end{block}
\end{column}
\end{columns}
\end{wide}
\end{frame}
\newsavebox\mapredb
\savebox\mapredb{\begin{tikzpicture}[node distance=5mm and 1cm]
\tikzset{
sarrow/.style={arrow,short=2pt},
map/.style={draw=blue!13!black,fill=blue!2},
reduce/.style={draw=red!13!black,fill=red!2},
}
\node[roundednode,dashed,lcr,fill=lightgray!20,draw=gray,inner sep=2mm] (F) {\Large\faFile*[regular]};
\node[roundednode,right=of F] (SP) {\rotatebox{-90}{Split}};
\node[roundednode,map,right=of SP] (M3) {Map};
\node[roundednode,map,above=of M3] (M2) {Map};
\node[roundednode,map,above=of M2] (M1) {Map};
\node[roundednode,map,below=of M3] (M4) {Map};
\node[roundednode,map,below=of M4] (M5) {Map};
\node[roundednode,right=of M3] (SH) {\rotatebox{-90}{Shuffle}};
\node[roundednode,reduce,right=of SH] (R2) {Reduce};
\node[roundednode,reduce,above=of R2] (R1) {Reduce};
\node[roundednode,reduce,below=of R2] (R3) {Reduce};
\node[roundednode,right=of R2,dashed,lcr,fill=lightgray!20,draw=gray,inner sep=2mm] (E) {\Large\faFile*[regular]};
\draw[sarrow] (F) -- (SP);
\foreach \x in {1,2,3,4,5} {
\draw[sarrow] (SP) -- (M\x);
\draw[sarrow] (M\x) -- (SH);
}
\foreach \x in {1,2,3} {
\draw[sarrow] (SH) -- (R\x);
\draw[sarrow] (R\x) -- (E);
}
\end{tikzpicture}}
\begin{frame}[fragile]
\frametitle[Map-Reduce in CHR]{Declarative Concurrency}
\begin{visibleenv}<6->
\begin{tikzpicture}\tikzset{query/.style={roundednode,inner sep=1.5mm,fill=lightgray!25,draw=gray,minimum width=\textwidth-2mm}}
\node[query] (Q) {\strut};
\node[anchor=west] at (Q.west){\strut\cg{\ergo}~\chri{map(square), reduce(add), v(2), v(3), v(4), v(5)}};
\end{tikzpicture}
\end{visibleenv}
\begin{columns}[c]
\begin{column}{0.68\textwidth}
\begin{visibleenv}<4->
\begin{chr}
map(OP) \ v(X) <=>
C =.. [OP, X, R],
call(C),
r(R)
\end{chr}
\end{visibleenv}
\begin{visibleenv}<5->
\begin{chr}
reduce(OP) \ r(X), r(Y) <=>
C =.. [OP, X, Y, R],
call(C),
r(R)
\end{chr}
\end{visibleenv}
\end{column}
\begin{column}<7->{0.25\textwidth}
\begin{tikzpicture}
\node[roundednode,lcr,dashed,fill=lightgray!25,draw=gray,minimum width=\awesome@sidebarwidth+4mm,minimum height=3cm,anchor=north west,xshift=\awesome@textmargin] at ([yshift=-1.5cm]current page.north west) (S) {};
\node[roundednode,color=black,text=white] at (S.south) {\tiny Constraint Store};
\node[anchor=north,yshift=-2mm] at (S.north) {\chri{reduce(add)}};
\node[anchor=north,yshift=-7mm] at (S.north) {\chri{map(square)}};
\node[anchor=north,yshift=-12mm] at (S.north) {\chri{r(54)}};
\end{tikzpicture}
\end{column}
\end{columns}
\mode<beamer>{\begin{modal}<2>
\centerline{\usebox\mapredb}
\end{modal}}
\end{frame}
\section{TL;DR}
\mode<beamer>{\begin{frame}
% \frametitle{Why should anyone use this?}
\begin{wide}
\centerline{\Huge\bfseries Why should anyone use this?}
\end{wide}
\end{frame}}
\newsavebox\epingub
\savebox\epingub{\begin{tikzpicture}
\pingu[heart=accent,wings wave]
\end{tikzpicture}}
\begin{frame}
\frametitle{What's left to say}
\begin{wide}
\begin{tikzpicture}[o]
\path[postaction={decorate},decoration={text along path, text={|\bfseries\Huge\color{accent}|Zig is awesome},text align={fit to path}},visible on=<2->]
([shift={(-2.7cm,.2mm)}]current page.center) to[bend left=55] ([shift={(2.7cm,.2mm)}]current page.center);
\node[yshift=-7mm,visible on=<2->] (P) at (current page.center) {\usebox\epingub};
\node[below=of P,visible on=<3->] {\bfseries\Large\color{accent}Constraint programming, too \emoji{wink}};
\end{tikzpicture}
\end{wide}
\end{frame}
\section{References}
\defbibheading{bibliography}[\bibname]{}
\begin{frame}[allowframebreaks]
\frametitle{References}
\printbibliography
\end{frame}
\end{document}