-
Notifications
You must be signed in to change notification settings - Fork 0
/
dissertation.preamble.tex
615 lines (551 loc) · 25.1 KB
/
dissertation.preamble.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
%%%%% BIBLIO AND STRUCTURE
\usepackage{natbib}
\let\parencite\citep
\let\textcite\citet
% \bibliographystyle{plain}
% \bibliographystyle{alpha}
% \bibliographystyle{}
\bibliographystyle{plainnat}
\setcitestyle{citesep={;},aysep={},open={[},close={]}}
% \setcitestyle{citesep={;},aysep={,},open={(},close={)}}
% \setcitestyle{citesep={;},aysep={,}}
% \bibliographystyle{IEEEbib}
\usepackage{appendix}
% for sub-appendices
% https://tex.stackexchange.com/questions/120716/appendix-after-each-chapter
\AtBeginEnvironment{subappendices}{
\chapter*{Appendices for Chapter \thechapter}
% \addcontentsline{toc}{chapter}{Appendices}
% \addtocontents{toc}{\rule[.1\normalbaselineskip]{1.25in}{.15mm}\par}
% \addtocontents{toc}{APPENDICES}
\addtocontents{toc}{\medskip\relax
\rule[0.5ex]{1in}{.15mm}\hfill
Chapter \thechapter\ Appendices
\hfill \rule[0.5ex]{1in}{.15mm}
\hfill\phantom{-}
}
\counterwithin{figure}{section}
\counterwithin{table}{section}
}
\AtEndEnvironment{subappendices}{%
\counterwithin{figure}{chapter}
\counterwithin{table}{chapter}
% \counterwithout{figure}{section}
% \counterwithout{table}{section}
}
%%%%% EXTRA COMMANDS TO HIDE STUFF;
% ideally, it will be possible to delete all of this at the end.
% \newcommand{\notation}[1]{\ignorespaces} % disable notation
\newcommand{\notation}[1]{{\color{red}#1}~~} % enable notation
\newcommand{\vfull}[1]{{\color{orange}#1}} % previously cut "full-version"; highlight
\newcommand\fadeout[1]{{\color{gray!50}\small#1}}
\newcommand\commentout[1]{}
% \newcommand\temphide[1]{{\color{gray!80}$\blacksquare$}}
\newcommand\temphide[1]{}
\newcommand\discard[1]{{\color{orange!80!black}$\blacksquare$}}
\newcommand{\TODO}[1][INCOMPLETE]{{\centering\Large\color{red}$\langle$~\texttt{#1}~$\rangle$\par}}
\newcommand\hidewithbox[1]{{\color{red}$\blacksquare$}}
\newcommand\forjoe[1]{{\color{red}Note for Joe: #1}}
% \newcommand\forjoe[1]{}
% \newcommand{\newmaterial}[1]{{\color{violet}#1}}
\let\newmaterial\relax
\let\oldnewmaterial\relax
\newcommand{\overkill}[1]{{\color{gray!50!white}#1}}
%%%%% STANDARD PACKAGES
\usepackage{mathtools} %also loads amsmath
\usepackage{faktor}
\usepackage{amssymb,bbm}
\usepackage{booktabs}
\usepackage{cancel}
\newcommand{\Cancel}[2][black]{{\color{#1}\cancel{\color{black}#2}}}
\usepackage{nicefrac}
\usepackage[noend]{algorithmic}
\usepackage{algorithm}
% \usepackage{algpseudocode}
\usepackage[dvipsnames, cmyk]{xcolor} % must be loaded before tikz
\usepackage{tikz} % setup comes later
\usepackage{enumitem}
\usepackage{array}
\newcolumntype{L}{>{$}l<{$}} % switch mathmode, a description column
% \usepackage{trimclip}
\usepackage{xstring}
\usepackage{environ}% http://ctan.org/pkg/environ;
% required for use of label_matrix.tex.
\usepackage{nameref,hyperref}%\Autoref is defined by thmtools
\usepackage[noabbrev,nameinlink,capitalize]{cleveref}% n.b. cleveref after! hyperref
\newcommand{\creflastconjunction}{, and\nobreakspace}
%%%%% visual appearance
% \colorlet{color1}{blue}
\colorlet{color1}{Emerald}
\colorlet{color2}{color1>wheel,1,3}
\colorlet{color3}{color1>wheel,2,3}
\definecolor{deepgreen}{rgb}{0,0.5,0}
\colorlet{pinkish}{color3!25!magenta}
\usepackage{relsize}
\usepackage{wrapfig}
\usepackage{scalerel}
% \hypersetup{colorlinks=true, linkcolor=blue, urlcolor=magenta, citecolor=deepgreen}
% \hypersetup{colorlinks=true, linkcolor=color1, urlcolor=magenta, citecolor=color2}
% \hypersetup{colorlinks=true, linkcolor=blue, urlcolor=magenta, citecolor=Emerald}
\hypersetup{colorlinks=true, linkcolor=blue, urlcolor=magenta, citecolor=Emerald!50!deepgreen}
% \usepackage{parskip}
\usepackage{microtype} % microtypography
\usepackage{makecell}
% \usepackage[format=plain,labelfont={sl},textfont={it,small},margin=1cm]{caption}
\usepackage[format=hang,labelfont={it},textfont={small}]{caption}
\usepackage{subcaption}
%\usepackage{subfig}
%\captionsetup[subfigure]{subrefformat=simple,labelformat=simple}
%\renewcommand\thesubfigure{(\alph{subfigure})}
%%%%% PREPARING EXTRA SYMBOLS
\usepackage{stmaryrd} % disable me for Joe
\SetSymbolFont{stmry}{bold}{U}{stmry}{m}{n}
\makeatletter
% load lBrace, rBrace from stix... but don't load stix
\@ifpackageloaded{stix}{}{
\DeclareFontEncoding{LS2}{}{\noaccents@} \DeclareFontSubstitution{LS2}{stix}{m}{n}
\DeclareSymbolFont{stix@largesymbols}{LS2}{stixex}{m}{n}
\SetSymbolFont{stix@largesymbols}{bold}{LS2}{stixex}{b}{n}
\DeclareMathDelimiter{\lBrace}{\mathopen} {stix@largesymbols}{"E8}{stix@largesymbols}{"0E}
\DeclareMathDelimiter{\rBrace}{\mathclose}{stix@largesymbols}{"E9}{stix@largesymbols}{"0F}
}
% who doesn't love dutchcal?
\DeclareMathAlphabet{\mathdcal}{U}{dutchcal}{m}{n}
\DeclareMathAlphabet{\mathbdcal}{U}{dutchcal}{b}{n}
\DeclareRobustCommand{\shortto}{\mathrel{\mathpalette\short@to\relax}}
\newcommand{\short@to}[2]{%
\mkern2mu
\clipbox{{.5\width} 0 0 0}{$\m@th#1\vphantom{+}{\shortrightarrow}$}%
}
% better-spaced cases environment
\makeatletter
\renewenvironment{cases}[1][l]{\matrix@check\cases\env@cases{#1}}{\endarray\right.}
\def\env@cases#1{%
\let\@ifnextchar\new@ifnextchar
\left\lbrace\def\arraystretch{1.2}%
\array{@{}#1@{\quad}l@{}}}
\makeatother
\newcommand\numberthis{\addtocounter{equation}{1}\tag{\theequation}}
\makeatother
%% don't double space matrices please...
\makeatletter
\def\env@matrix{\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\linespread{1}\selectfont
\renewcommand{\arraystretch}{1.2}%
\array{*\c@MaxMatrixCols c}}
\makeatother
%%% GENERAL SYMBOLS
\let\Horig\H
\let\H\relax
\let\nf\nicefrac
\DeclareMathOperator{\H}{\mathrm{H}} % Entropy
\DeclareMathOperator{\I}{\mathrm{I}} % Information
\DeclareMathOperator*{\Ex}{\mathbb{E}} % Expectation
\DeclareMathOperator*{\EX}{\scalebox{1.5}{$\mathbb{E}$}} % BIG expectation
\DeclareMathOperator*{\argmin}{arg\,min} % argmin
\DeclareMathOperator*{\argmax}{arg\,max} % argmax
% \DeclareMathOperator*{\argmin}{\arg\!\min}
% \DeclareMathOperator*{\argmax}{\arg\!\max}
\DeclareMathOperator{\im}{\mathrm{im}} % image of a map
\DeclareMathSymbol{\shortminus}{\mathbin}{AMSa}{"39} %shorter minus
\DeclarePairedDelimiter{\norm}{\Vert}{\Vert} % paired norm
\DeclarePairedDelimiter{\pqty}{\lparen}{\rparen} % paired parens
\newcommand{\ifrac}[2]{{#1}/{#2}} % inline fraction, (I guess?)
\DeclareMathOperator{\Supp}{\mathrm{Supp}} %support
\newcommand{\Unif}{\mathrm{Unif}} % uniform distribution
\newcommand{\Rext}{\mskip1mu\overline{\mskip-1mu\mathbb R\!}\,}
\newcommand\mat[1]{\mathbf #1} % short matrix / \mathbf
\newcommand{\indi}[1] % indicator function
{\mathbbm{1}_{\left[\vphantom{\big[}#1 \vphantom{\big]}\right]}}
\DeclarePairedDelimiterX{\infdivx}[2]{(}{)}{#1\;\delimsize\|\;#2}
\newcommand{\thickD}{I\mkern-8muD}
\newcommand{\kldiv}{\thickD\infdivx} % D_\mathrm{KL}
% graphical models stuff
\newcommand{\CI}{\mathrel{\perp\mspace{-10mu}\perp}} % independence
\newcommand{\Pa}{\mathop{\mathbf{Pa}}\nolimits}
\newcommand{\Ch}{\mathop{\mathbf{Ch}}\nolimits}
\newcommand{\tto}{\rightarrow\mathrel{\mspace{-15mu}}\rightarrow}
% Other notions of uncertainty
\newcommand\Bel{\mathit{Bel}}
\newcommand\Plaus{\mathit{Plaus}}
\newcommand\At[1]{\mathit{A\mkern-2mu t}(#1)} % boolean algebra atoms
\newcommand\lang[1]{\mathcal L^{\mathit{#1}}} % languages
\newcommand\geqc{\succcurlyeq}
\newcommand\leqc{\preccurlyeq}
% (these are all defined in pdg-preamble.tex)
% \DeclarePairedDelimiter{\cbbr}{\lBrace}{\rBrace}
% \DeclarePairedDelimiter{\bbr}{\llbracket}{\rrbracket}
% \DeclarePairedDelimiter{\ppr}{\llparenthesis}{\rrparenthesis}
% \DeclarePairedDelimiterX{\aar}[1]{\langle}{\rangle}
% {\mspace{3mu}\mathllap{\delimsize\langle}#1\mathrlap{\delimsize\rangle}\mspace{3mu}}
% \DeclarePairedDelimiterXPP{\aard}[1]{}{\langle}{\rangle}{_{\!_\downarrow}}
% {\mspace{-3.5mu}\delimsize\langle#1\delimsize\rangle\mspace{-3.5mu}}
%
\relax%%%%% STANDARD SETS / SPACES / CATEGORIES %%%%
% \newcommand{\Stoch}{\mathbf{Stoch}}
\newcommand{\Stoch}{\mathbb{S}\mathbf{toch}}
% \newcommand{\FinSet}{\mathbf{FinSet}}
% \newcommand{\Set}{\mathbf{Set}}
\newcommand\CMon{\mathbb{C\mskip-1.5muM}\mskip-1.3mu\mathbf{o\mskip-1mun}}
\newcommand\Mon{\mathbb{M}\mskip-1.5mu\mathbf{o\mskip-1mun}}
\newcommand\Set{\ensuremath{\mathbb{S}\mathbf{et}}}
\newcommand\Top{\ensuremath{\mathbb{T}\mathbf{op}}}
\newcommand\Rel{\ensuremath{\mathbb{R}\mathbf{el}}}
\newcommand\Diff{\ensuremath{\mathbb{D}\mathbf{iff}}}
\newcommand\Meas{\ensuremath{\mathbb{M}\mathbf{eas}}}
\newcommand\FinSet{\ensuremath{\mathbb{F}\mathbf{in}\mathbf{S}\mathbf{et}}}
\newcommand\Two{\mathbbm 2}
\newcommand\PDG{\mathbb{P}\mathrm{DG}}
\newcommand\Semiringoid{\mathbb S\mathbf{emiringoid}}
\newcommand\Mat{\mathop{\mathrm{Mat}}}
\relax %%% category theory macros %%%
%\newcommand\CMon{\mathbb{C}\!\mathrm{o}\mathbb{M}} \newcommand\ICMon{\mathbb{I\mskip-1muC\mskip-1.5muM}\mskip-1.3mu\mathbf{o\mskip-1mun}}
\DeclareMathOperator{\ob}{\mathop{\mathrm{ob}}}
\DeclareMathOperator{\id}{\mathrm{id}}
\DeclareMathOperator{\Hom}{\mathop{\mathrm{Hom}}}
%%%%% SPECIAL COMMANDS FOR PDG-AAAI %%%%%
\newcommand{\Gr}{\mathcal G}
\newcommand{\alle}[1][a]{_{\ed {#1}XY}}
% \newcommand\GFE{\mathit{G\mkern-4mu F\mkern-4.5mu E}}
\newcommand\VFE{\mathit{V\mkern-4mu F\mkern-4.5mu E}}
% conversions
\newcommand{\WFGof}[1]{\Psi_{{#1}}}
\newcommand{\FGof}[1]{\Phi_{{#1}}}
%%%%% SPECIAL COMMANDS FOR QIM %%%%%%%
\newcommand{\derind}[2]{ {#1}^{+\tilde{#2}(\X^{\U})}}
\newcommand\U{\mathcal U}
\newcommand\enV{\mathcal V} % for endogenous variables
%%%%% SPECIAL COMMANDS FOR ONE-TRUE-LOSS %%%%%%%
\newcommand{\datadist}[1]{\Pr\nolimits_{#1}}
% \newcommand{\datadist}[1]{p_\text{data}}
\newcommand\XEnt{\mathrm{CrossEntropy}}
%%%%% SPECIAL COMMANDS FOR INFERENCE %%%%%%%
\newcommand\bmu{\boldsymbol\mu}
\newcommand\C{\mathdcal C}
\newcommand\minimize{\mathop{\scalebox{0.98}{$\mathsf{minimize}$}}\limits}
\newcommand\maximize{\mathop{\scalebox{0.98}{$\mathsf{maximize}$}}\limits}
\newcommand\subjto{{\scalebox{0.98}{$\mathsf{subject~to}$}}}
\newcommand\zogamma{{\mathrlap{\raisebox{-0.1ex}{$\hat{\phantom{x}}$}}\gamma}}
\newcommand\actree{tree marginal}
\newcommand\AcTree{Tree Marginal}
\newcommand\cactree{calibrated \actree}
%%%%% SPECIAL COMMANDS FOR LIR %%%%%%%%%
\newcommand\btheta{\boldsymbol\theta}
\newcommand\Ctx{\dg{C\mskip-2mut\mskip-2mux}}
\newcommand\Mm{\dg{M}}
\newcommand\MThetadense{\dg{M}(\mskip-1mu\Theta\mskip-1mu)}
\newcommand\Attn{\dg{A\mskip-2.2mut\mskip-2mut\mskip-2mun}}
\newcommand\Ctrl{\dg{C\mskip-2mut\mskip-2mur\mskip-2mul}}
\newcommand\attn{A}
\newcommand\ctrl{C}
\relax % Short arrows.
% \newcommand{\veryshortarrow}[1][3pt]{\mathrel{%
% {\hbox{\rule[-.5\fontdimen8\textfont3]{#1}{\fontdimen8\textfont3}}}%
% \mkern-4mu\hbox{\usefont{U}{lasy}{m}{n}\symbol{41}}}}
\newcommand{\veryshortarrow}[1][3pt]{\mathrel{%
\hbox{\rule[\dimexpr\fontdimen22\textfont2-.2pt\relax]{#1}{.4pt}}%
\mkern-4mu\hbox{\usefont{U}{lasy}{m}{n}\symbol{41}}}}
\makeatletter
\setbox0\hbox{$\xdef\scriptratio{\strip@pt\dimexpr
\numexpr(\sf@size*65536)/\f@size sp}$}
\newcommand{\scriptveryshortarrow}[1][3pt]{{%
\hbox{\rule[\scriptratio\dimexpr\fontdimen22\textfont2-.2pt\relax]
{\scriptratio\dimexpr#1\relax}{\scriptratio\dimexpr.4pt\relax}}%
\mkern-4mu\hbox{\let\f@size\sf@size\usefont{U}{lasy}{m}{n}\symbol{41}}}}
\makeatother
% \let\sto\veryshortarrow
\newcommand\sto{\mathchoice{{\to}}{\veryshortarrow}{\scriptveryshortarrow}{{\to}}}
% \newcommand\sto{{{\scalebox{1}[1]{$\scriptstyle\to$}}}}
%
\newsavebox{\stosbox}
\sbox{\stosbox}{\begin{tikzpicture}\draw[->] (0,0) to (0.15,0);\end{tikzpicture}}
% \newcommand\sto{\usebox\stosbox}
%%%
%%% hacky: now I have to do the same thing for green and blue
\newsavebox{\stosboxgreen}
\sbox{\stosboxgreen}{\begin{tikzpicture}\draw[->,green!70!black] (0,0) to (0.15,0);\end{tikzpicture}}
% \newcommand\stogreen{\usebox\stosboxgreen}
\newcommand\stogreen{{\color{green!70!black}\sto}}
\newsavebox{\stosboxblue}
\sbox{\stosboxblue}{\begin{tikzpicture}\draw[->,blue] (0,0) to (0.15,0);\end{tikzpicture}}
% \newcommand\stoblue{\usebox\stosboxblue}
\newcommand\stoblue{{\color{blue}\sto}}
%%%%%%% SPECIAL COMMANDS FOR REASONING WITH PDGS %%%%%%
\newcommand\False{\dg{F\mskip-5mua\!l\mskip-4mus\mskip-1.5mue}}
%%%%% SPECIAL COMMANDS FOR CONFIDENCE %%%%%
\newcommand\confdom{[\bot,\!\top]}
\newcommand\Lrn{\mathit{Lrn}}
\newcommand{\ext}[1]{\overline #1} % extension of \Phi and F to mixture.
\usepackage{xparse}
\let\realItem\item % save a copy of the original item; will be temporarily swapped out in envirnoments below.
\makeatletter
\NewDocumentCommand\myItemboldperiod{o}{%
\IfNoValueTF{#1}%
{\realItem}% add an item
{\realItem[\conflabel{#1}]%
\def\@currentlabel{#1}%
\protected@edef\cref@currentlabel{[CFaxiomsi][][]#1}% \label[#1]{#2}
}% add an item and update label
}
\makeatother
% \newcommand\conflabel[1]{\textbf{#1.}}
\newcommand\conflabel[1]{\textbf{[#1]}}
\newlist{LrnAxioms}{enumerate}{1}
\setlist[LrnAxioms]{%
resume,%
label=\conflabel{L\arabic{*}},
ref={L\arabic*},
leftmargin=*,
itemindent=1.5em, labelsep=1em, topsep=1ex,
before=\let\item\myItemboldperiod,
}
\crefname{LrnAxiomsi}{}{}
\crefrangeformat{LrnAxiomsi}{#3#1#4#5--\crefstripprefix{#1}{#2}#6}
\newlist{LrnBelAxioms}{enumerate}{1}
\setlist[LrnBelAxioms]{
resume,%
label=\conflabel{LB\arabic{*}},
ref={LB\arabic*},
leftmargin=*,
itemindent=1.5em, labelsep=1em, topsep=1ex,
before=\let\item\myItemboldperiod,
}
\crefname{LrnBelAxiomsi}{}{}
\crefrangeformat{LrnBelAxiomsi}{#3#1#4#5--\crefstripprefix{#1}{#2}#6}
%%%%% DATABASE SYMBOLS %%%%%
\newcommand{\D}{\mathbdcal D} % for a database
\newcommand{\Attrs}{\mathdcal A}
\newcommand{\Idx}{\mathcal J}
\newcommand{\Doms}{{\mathcal D}}
% \newcommand{\Rels}{{\mathcal R}}
\newcommand{\Rels}{{\mathbf R}}
\newcommand{\Cols}{\mathcal C}%{\sigma}
\newcommand{\Sch}{\mathdcal S}
\newcommand{\Keys}{\mathcal K}
\newcommand{\DBProb}{\mathdcal P}
\newcommand{\arity}{\mathit{ar}}
\newcommand\Varis{\V\kern-.65pt\mathit{ars}}%
\newcommand\Bmid{\mathrel{\Big|}}%
\newcommand\vals{\mathbf{vals}}
\newcommand\nj{\bowtie}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% before theorems I need this:
\def\structurelevels{part,section,subsection,subsubsection,paragraph}%
\newcommand\nextstructurelevel{%
\ifnum\value{section}=0 section\else%
\ifnum\value{subsection}=0 subsection\else%
\ifnum\value{subsubsection}=0 subsubsection\else%
paragraph\fi\fi\fi}
%% The loop didn't work :( burrying it for now...
% \expandafter\newcommand\nextstructurelevel{%
% {\foreach\strl in \structurelevels{%
% \ifnum\expandafter\value{\strl}=0%
% \strl\breakforeach\fi%
% }%
% }}
% \newcommand\nextstructurelevel{subsubsection}
%%%%%%%%%%%%%%%% THEOREMS %%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsthm}
\usepackage{thmtools} % asmsymb must be loaded also.
\usepackage[framemethod=TikZ]{mdframed}
% \usepackage[nobox]{restatelinks}
\usepackage[nobox,strip]{restatelinks}
\makeatletter\begingroup
\@for\theoremstyle:=definition,remark,plain\do{%
\expandafter\g@addto@macro\csname th@\theoremstyle\endcsname{%
\addtolength\thm@preskip\parskip}
}\endgroup
% add theorems, examples,etc to table of contents
\def\thmTOCadd{
\edef\asdffdsa{\nextstructurelevel}
% \edef\asdffdsa{subsubsection}
\ifx\thmt@optarg\@empty
\addcontentsline{toc}{\asdffdsa}{%
\texorpdfstring{
\makebox[3cm][r]{\color{gray}{\it\thmt@thmname}~%
\csname the\thmt@envname\endcsname}}%
{\thmt@thmname\csname the\thmt@envname\endcsname: \thmt@optarg}}
\else\addcontentsline{toc}{\asdffdsa}{%
\texorpdfstring{
\makebox[3cm][r]{\color{gray}{\it\thmt@thmname}~%
\csname the\thmt@envname\endcsname:}\hspace{1em} {\color{black!50!gray}\small\thmt@optarg}}%
{\thmt@thmname\csname the\thmt@envname\endcsname: \thmt@optarg} %
}\fi}
%... except actually we don't want to add this to TOC, I think...
\def\thmTOCadd{}
% macro for clearing theorems (if preamble adapted)
% my answer presented here: https://tex.stackexchange.com/a/296184/191268
\def\cleartheorem#1{%
\expandafter\let\csname#1\endcsname\relax
\expandafter\let\csname c@#1\endcsname\relax
}
\def\clearthms#1{ \@for\tname:=#1\do{\cleartheorem\tname} }
\makeatother
\theoremstyle{plain}
\declaretheorem[numberwithin=chapter,name=Theorem,postheadhook={\thmTOCadd}]{theorem}
\newtheorem{coro}{Corollary}[theorem]
\declaretheorem[sibling=theorem,name=Proposition, postheadhook={\thmTOCadd}]{prop}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{fact}[theorem]{Fact}
\newtheorem{falsity}[theorem]{Falsity}
\newtheorem{conj}[theorem]{Conjecture}
\newtheorem{claim}{Claim}
\declaretheorem[numberwithin=theorem,name=Claim]{iclaim} % internal claims for lproofs.
\theoremstyle{definition}
\newtheorem*{defn*}{Definition}
\declaretheorem[name=Definition,style=definition,qed=$\square$,within=chapter, postheadhook={\thmTOCadd}]{defn}
\declaretheorem[name=Construction,qed=$\square$,sibling=defn, postheadhook={\thmTOCadd}]{constr}
% \declaretheorem[qed=$\square$]{example}
\declaretheorem[name=Example,qed=$\triangle$,postheadhook={\thmTOCadd},numberwithin=chapter]{example}
\theoremstyle{remark}
\newtheorem*{remark}{Remark}
\crefname{example}{Example}{Examples}
\crefname{defn}{Definition}{Definitions}
\crefname{prop}{Proposition}{Propositions}
\crefname{constr}{Construction}{Constructions}
\crefname{conj}{Conjecture}{Conjectures}
\crefname{fact}{Fact}{Facts}
\crefname{claim}{Claim}{Claims}
\crefname{iclaim}{Claim}{Claims}
\crefname{coro}{Corolary}{Corolaries}
%% ANNOTATION
\newcommand{\todo}[1]{{\color{red}\ \!\Large\smash{\textbf{[}}{\normalsize\textsc{todo:} #1}\ \!\smash{\textbf{]}}}}
\newcommand{\note}[1]{{\color{blue}\ \!\Large\smash{\textbf{[}}{\normalsize\textsc{note:} #1}\ \!\smash{\textbf{]}}}}
\newcommand{\moveme}[1]{{\color{purple}\ \!\Large\smash{\textbf{[}}{\normalsize\textsc{moveme:} #1}\ \!\smash{\textbf{]}}}}
\mdfdefinestyle{mybox}{skipabove=1em,skipbelow=1em,roundcorner=2pt}
\newmdenv[style=mybox,fontcolor=black!25, backgroundcolor=black!3,linecolor=black!20]{inactive}
\newmdenv[style=mybox,backgroundcolor=color3!5,linecolor=color3!20]{highlight-changes}
\newmdenv[style=mybox,linecolor=color2!50,topline=false,bottomline=false,rightline=false,innerleftmargin=1em,linewidth=5pt]{leftbar}
\newmdenv[roundcorner=5pt, subtitlebelowline=true,subtitleaboveline=true, subtitlebackgroundcolor=color1!70!white,
backgroundcolor=color3!20!white, frametitle={Annotating},frametitlerule=true, frametitlebackgroundcolor=color1!70!white, skipabove=1em,skipbelow=1em,]{annotating}
\newmdenv[roundcorner=5pt, backgroundcolor=pinkish!20!white, frametitle={$\langle$under construction $\rangle$},frametitlerule=false,
innertopmargin=2pt, frametitlebelowskip=3pt, frametitleaboveskip=2pt, frametitlebackgroundcolor=pinkish!70!white, skipabove=1em,skipbelow=1em, frametitlefont={\normalfont\itshape},leftmargin=-10pt, rightmargin=-10pt]
{wip}
% \usetikzlibrary{external}
% \tikzexternalize[prefix=tikz/] % activate!
% \usepackage{etoolbox}
% \AtBeginEnvironment{tikzcd}{\tikzexternaldisable} %... except careful of tikzcd...
% \AtEndEnvironment{tikzcd}{\tikzexternalenable}
% %%%%%%%%%%%%%%%% TIKZ SETUP %%%%%%%%%%%%%%%%%%%%%
% \usetikzlibrary{positioning,fit,calc, decorations, arrows, shapes, shapes.geometric}
% \usetikzlibrary{patterns,backgrounds}
% \usetikzlibrary{cd}
%
% \pgfdeclaredecoration{arrows}{draw}{
% \state{draw}[width=\pgfdecoratedinputsegmentlength]{%
% \path [every arrow subpath/.try] \pgfextra{%
% \pgfpathmoveto{\pgfpointdecoratedinputsegmentfirst}%
% \pgfpathlineto{\pgfpointdecoratedinputsegmentlast}%
% };
% }}
% %%%%%%%%%%%%
% \tikzset{AmpRep/.style={ampersand replacement=\&}}
% \tikzset{center base/.style={baseline={([yshift=-.8ex]current bounding box.center)}}}
\tikzset{paperfig/.style={center base,scale=1.0, every node/.style={transform shape}}}
% \tikzset{paperfig/.style={center base,scale=0.9, every node/.style={transform shape}}}
%
% \tikzset{is bn/.style={background rectangle/.style={fill=blue!35,opacity=0.3, rounded corners=5},show background rectangle}}
% % Node Stylings
% \tikzset{dpadded/.style={rounded corners=2, inner sep=0.7em, draw, outer sep=0.3em, fill={black!50}, fill opacity=0.08, text opacity=1}}
% % \tikzset{active/.style={fill=blue, fill opacity=0.1}}
% % \tikzset{square/.style={regular polygon,regular polygon sides=4, rounded corners = 0}}
% % \tikzset{octagon/.style={regular polygon,regular polygon sides=8, rounded corners = 0}}
% \tikzset{dpad0/.style={outer sep=0.05em, inner sep=0.3em, draw=gray!75, rounded corners=4, fill=black!08, fill opacity=1}}
% \tikzset{dpad1/.style={outer sep=0.1em, inner sep=0.4em, draw=gray!75, rounded corners=3, fill=black!08, fill opacity=1}}
% \tikzset{dpad/.style args={#1}{every matrix/.append style={nodes={dpadded, #1}}}}
% \tikzset{light pad/.style={outer sep=0.2em, inner sep=0.5em, draw=gray!50}}
%
% \tikzset{arr/.style={draw, ->, thick, shorten <=3pt, shorten >=3pt}}
% \tikzset{arr0/.style={draw, ->, thick, shorten <=0pt, shorten >=0pt}}
% \tikzset{arr1/.style={draw, ->, thick, shorten <=1pt, shorten >=1pt}}
% \tikzset{arr2/.style={draw, ->, thick, shorten <=2pt, shorten >=2pt}}
% \tikzset{archain/.style args={#1}{arr, every arrow subpath/.style={draw,arr, #1}, decoration=arrows, decorate}}
%
%
\usetikzlibrary{decorations.pathmorphing}
\tikzset{fgnode/.style={dpadded,inner sep=0.6em, circle},
factor/.style={light pad, fill=black}}
\tikzset{bnnode/.style={dpad1,circle,inner sep=3pt}}
\tikzset{lirfactor/.style={draw,minimum width=1.5em, minimum height=1.5em,fill=gray!50!black,text=white,font=\mathversion{bold}\bfseries}}
%
% % For illustrating what's inside of nodes:
% \tikzset{alternative/.style args={#1|#2|#3}{name=#1, circle, fill, inner sep=1pt,label={[name={lab-#1},gray!30!black]#3:\scriptsize #2}} }
%
% \tikzset{bpt/.style args={#1|#2}{alternative={#1|#2|above}} }
% \tikzset{tpt/.style args={#1|#2}{alternative={#1|#2|below}} }
% \tikzset{lpt/.style args={#1|#2}{alternative={#1|#2|left}} }
% \tikzset{rpt/.style args={#1|#2}{alternative={#1|#2|right}} }
% \tikzset{pt/.style args={#1}{alternative={#1|#1|above}} }
% \tikzset{mpt/.style args={#1|#2}{name=#1, circle, fill, inner sep=1pt,label={[name={lab-#1},gray]\scriptsize #2}} }
%
% \tikzset{Dom/.style args={#1 (#2) around #3}{dpadded, name=#2, label={[name={lab-#2},align=center] #1}, fit={ #3 } }}
% \tikzset{bDom/.style args={#1 (#2) around #3}{dpadded, name=#2, label={[name={lab-#2},align=center]below:#1}, fit={ #3 } }}
%
%
% \newcommand\cmergearr[4]{
% \draw[arr,-] (#1) -- (#4) -- (#2);
% \draw[arr, shorten <=0] (#4) -- (#3);
% }
% \newcommand\mergearr[3]{
% \coordinate (center-#1#2#3) at (barycentric cs:#1=1,#2=1,#3=1.2);
% \cmergearr{#1}{#2}{#3}{center-#1#2#3}
% }
% \newcommand\cunmergearr[4]{
% \draw[arr,-, , shorten >=0] (#1) -- (#4);
% \draw[arr, shorten <=0] (#4) -- (#2);
% \draw[arr, shorten <=0] (#4) -- (#3);
% }
% \newcommand\unmergearr[3]{
% \coordinate (center-#1#2#3) at (barycentric cs:#1=1.2,#2=1,#3=1);
% \cunmergearr{#1}{#2}{#3}{center-#1#2#3}
% }
%
%
\usetikzlibrary{matrix}
\tikzset{toprule/.style={%
execute at end cell={%
\draw [line cap=rect,#1]
(\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn.north west) -- (\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn.north east);%
}
},
bottomrule/.style={%
execute at end cell={%
\draw [line cap=rect,#1] (\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn.south west) -- (\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn.south east);%
}
},
leftrule/.style={%
execute at end cell={%
\draw [line cap=rect,#1] (\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn.north west) -- (\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn.south west);%
}
},
rightrule/.style={%
execute at end cell={%
\draw [line cap=rect,#1] (\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn.north east) -- (\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn.south east);%
}
},
table with head/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={rectangle,minimum width=2.5em, outer sep=0pt},
row 1/.style={toprule=thick, bottomrule},
}
}
%
%
%
% % \NewEnviron{ctikzpicture}{\begin{center}\expandafter\begin{tikzpicture}\BODY\end{tikzpicture}\end{center}}
% % \usetikzlibrary{shapes.geometric}
% \usetikzlibrary{backgrounds}
% \tikzset{dpad0/.style={outer sep=0.05em, inner sep=0.3em, draw=gray!75, rounded corners=4, fill=black!08, fill opacity=1}}
% \tikzset{arr0/.style={draw, ->, thick, shorten <=0pt, shorten >=0pt}}
% \tikzset{arr1/.style={draw, ->, thick, shorten <=1pt, shorten >=1pt}}
% \tikzset{arr2/.style={draw, ->, thick, shorten <=2pt, shorten >=2pt}}
\usetikzlibrary{patterns,backgrounds}
\tikzset{is bn/.style={background rectangle/.style={fill=blue!35,opacity=0.3, rounded corners=5},show background rectangle}}
% % \newcommand\lab[1]{(#1)(lab-#1)}
%
%
% %%%%%%%%%%%%%% label_matrix.tex %%%%%%%%%%%%%%%%
% % \input{labelmatrix}