% -*- root: main.tex -*-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% NOTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



\newcommand{\wElem}{w} %an element of \vct{w}
\newcommand{\st}{\;|\;} %such that
\newcommand{\kElem}{k}%the kth element
%RA-to-Poly Notation
\newcommand{\polyinput}[2]{\left(#1,\ldots, #2\right)}
\newcommand{\numvar}{n}
\newcommand{\rel}{R}
\newcommand{\prel}{\mathcal{\rel}}
\newcommand{\reli}{S}
\newcommand{\relii}{T}
\newcommand{\db}{D}
\newcommand{\idb}{\Omega}
\newcommand{\pdb}{\mathcal{D}}
\newcommand{\nxdb}{D(\vct{X})}%\mathbb{N}[\vct{X}] db
\newcommand{\tset}{\mathcal{T}}%the set of tuples in a database
\newcommand{\pd}{P}%pd for probability distribution
\newcommand{\eval}[1]{\llbracket #1 \rrbracket}%evaluation double brackets
\newcommand{\query}{Q}
\newcommand{\join}{\Join}
\newcommand{\select}{\sigma}
\newcommand{\project}{\pi}
\newcommand{\union}{\cup}
\newcommand{\sch}{sch}
\newcommand{\attr}[1]{attr\left(#1\right)}
\newcommand{\rw}{\textbf{W}}%\rw for random world
\newcommand{\graph}[1]{G^{(#1)}}
\newcommand{\eset}[1]{S^{(#1)}} %edge set for arbitrary subgraph
\newcommand{\linsys}[1]{LS(\graph{#1})}
\newcommand{\lintime}[1]{LT^{\graph{#1}}}
\newcommand{\aug}[1]{AUG^{\graph{#1}}}
\newcommand{\mtrix}[1]{M_{#1}}
\newcommand{\dtrm}[1]{Det\left(#1\right)}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Approx Alg
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\randvar}{Y}
\newcommand{\coeffset}{S}
\newcommand{\distinctvars}{d}
\newcommand{\coeffitem}[1]{c_{#1}\cdot\prob^{\distinctvars_{#1}}}
\newcommand{\unidist}[1]{Uniform\left(#1\right)}
\newcommand{\samplesize}{N}
\newcommand{\setsize}{m}
\newcommand{\empmean}{\overline{\vct{\randvar}}}
\newcommand{\setsum}{SUM}
\newcommand{\ave}[1]{AVG(#1)}
\newcommand{\hoeffestsum}{EST_{\setsum}}
\newcommand{\error}{\epsilon}
\newcommand{\conf}{\delta}


%Pseudo Code Notation
\newcommand{\plus}{\texttt{+}}
\newcommand{\mult}{\texttt{\times}}
\newcommand{\algname}[1]{\textsc{#1}}
\newcommand{\approxq}{\algname{Approximate$\rpoly$}}
\newcommand{\onepass}{\algname{OnePass}}
\newcommand{\sampmon}{\algname{SampleMonomial}}
\newcommand{\ceil}[1]{\left\lceil #1 \right\rceil}
\newcommand{\vari}[1]{\texttt{#1}}
\newcommand{\accum}{\vari{acc}}
\newcommand{\numsamp}{\vari{N}}
\newcommand{\numedge}{m}
\newcommand{\bivec}{\vari{b}_{\vari{vec}}}
%expression tree T
\newcommand{\etree}{\vari{T}}
\newcommand{\stree}{\vari{S}}
\newcommand{\lchild}{\vari{L}}
\newcommand{\rchild}{\vari{R}}
%members of T
\newcommand{\val}{\vari{val}}
\newcommand{\type}{\vari{type}}
\newcommand{\wght}{\vari{weight}}
%types of T
\newcommand{\var}{var}
\newcommand{\tnum}{num}
%%%%%%%
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\newcommand{\smb}{\poly\left(\vct{X}\right)}%smb for standard monomial basis
\newcommand{\etreeset}[1]{\vari{ET}\left(#1\right)}
\newcommand{\expandtree}[1]{\vari{E}(#1)}
\newcommand{\elist}[1]{\vari{List}\pbox{#1}}

%expandtree tuple elements:
\newcommand{\monom}{\vari{v}}
\newcommand{\coef}{\vari{c}}
%----------------------------------
\newcommand{\abs}[1]{\left|#1\right|}
\newcommand{\func}[1]{\textsc{#1}}
\newcommand{\polyf}{\func{poly}}
\newcommand{\evalmp}{\func{eval}}
\newcommand{\degree}{\func{deg}}
\newcommand{\treesize}{\func{size}}
\newcommand{\sign}{\func{sgn}}


%PDBs
\newcommand{\prob}{p}
\newcommand{\wSet}{\Omega}
\newcommand{\ti}{TIDB}
\newcommand{\bi}{BIDB}
\newcommand{\tiabb}{ti}
\newcommand{\biabb}{bi}
\newcommand{\biwset}{\idb_{\biabb}}
\newcommand{\block}{b}
\newcommand{\biord}{\leq_{x_\block}}
\newcommand{\tiwset}{\idb_{\tiabb}}
\newcommand{\bipd}{\pd_{\biabb}}
\newcommand{\tipd}{\pd_{\tiabb}}
\newcommand{\bipdb}{\pdb_{\biabb}}
\newcommand{\bivar}{x_{\block, i}}
\newcommand{\tipdb}{\pdb_{\tiabb}}

%Polynomial Reformulation
\newcommand{\wbit}{w}
\newcommand{\expct}{\mathop{\mathbb{E}}}
\newcommand{\pbox}[1]{\left[#1\right]}
\newcommand{\pbrace}[1]{\left\{#1\right\}}
\newcommand{\vct}[1]{\textbf{#1}}
%using \wVec for world bit vector notation
\newcommand{\poly}{Q}
\newcommand{\rpoly}{\widetilde{Q}}%r for reduced as in reduced 'Q'
\newcommand{\out}{output}%output aggregation over the output vector
\newcommand{\numocc}[2]{\#\left(#1, #2\right)}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	%Graph Symbols
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	%Shift macro
	\newcommand{\patternshift}[1]{\hspace*{-0.5mm}\raisebox{-0.35mm}{#1}\hspace*{-0.5mm} }
	%Global styles
	\tikzset{
		default_node/.style={align=center, inner sep=0pt},
		pattern_node/.style={fill=gray!50, draw=black, semithick, inner sep=0pt, minimum size = 2pt, circle},
		tree_node/.style={default_node, draw=black, black, circle, text width=0.3cm, font=\bfseries, minimum size=0.65cm},
		highlight_color/.style={black}, wght_color/.style={black},
		highlight_treenode/.style={tree_node, draw=black, black},
		edge from parent path={(\tikzparentnode) -- (\tikzchildnode)}
		}
	%Subgraph patterns
	\newcommand{\ed}{\patternshift{
					\begin{tikzpicture}[every path/.style={thick, draw}]%[baseline=0.00005cm]
					%\begin{scope}[yshift=-5cm]
						\node at (0, 0)[pattern_node](bottom){};
						\node [above=0.07cm of bottom, pattern_node] (top){};
						\draw (top) -- (bottom);
%						\node at (0, -2)[pattern_node, blue](b2){};
%						\node [above=0.07cm of b2, pattern_node, blue] (t2){};
%						\draw (t2) -- (b2);
					%\end{scope}
					\end{tikzpicture}
				}
			 }

	\newcommand{\kmatch}{\ed\cdots\ed^\kElem}
	\newcommand{\twodis}{\patternshift{
						\begin{tikzpicture}[every path/.style={thick, draw}]
							\node at (0, 0) [pattern_node] (bottom1) {};
							\node[above=0.07cm of bottom1, pattern_node] (top1) {} edge (bottom1);
							\node at (0.14, 0) [pattern_node] (bottom2) {};
							\node [above=0.07cm of bottom2, pattern_node] (top2) {} edge (bottom2);
						\end{tikzpicture}
						}
					}
	\newcommand{\twopath}{\patternshift{
						\begin{tikzpicture}[every path/.style={thick, draw}]
							\node at (0, 0.08) [pattern_node] (top){};
							\node [below left=0.095cm and 0.05cm of top, pattern_node](left){};
							\node[below right=0.095cm and 0.05cm of top, pattern_node](right){};
							\draw (top) -- (left);
							\draw (top) -- (right);
						\end{tikzpicture}
					}
				}
	\newcommand{\threedis}{\patternshift{
						\begin{tikzpicture}[every path/.style={thick, draw}]
							\node at (0, 0) [pattern_node] (bottom1) {};
							\node[above=0.07cm of bottom1, pattern_node] (top1) {} edge (bottom1);
							\node at (0.14, 0) [pattern_node] (bottom2) {};
							\node [above=0.07cm of bottom2, pattern_node] (top2) {} edge (bottom2);
							\node at (0.28, 0) [pattern_node] (bottom3) {};
							\node [above=0.07cm of bottom3, pattern_node] (top3) {} edge (bottom3);
						\end{tikzpicture}
					}
				}
	\newcommand{\tri}{\patternshift{
						\begin{tikzpicture}[every path/.style={ thick, draw}]
							\node at (0, 0.08) [pattern_node] (top){};
							\node [below left=0.08cm and 0.01cm of top, pattern_node](left){} edge (top);
							\node[below right=0.08cm and 0.01cm of top, pattern_node](right){} edge (top) edge (left);
						\end{tikzpicture}
					}
				}
	\newcommand{\twopathdis}{\ed~\twopath}
	\newcommand{\threepath}{\patternshift{
						\begin{tikzpicture}[every path/.style={thick, draw}]
							\node at (0, 0) [pattern_node] (node1a) {};
							\node [above=0.07cm of node1a, pattern_node] (node1b) {} edge (node1a);
							\node [right=0.099cm of node1a, pattern_node] (node2b) {}; %edge [semithick] (node1b);
							\node [above=0.07cm of node2b, pattern_node] (node3b) {} edge (node2b);
							\draw (node1b) -- (node3b);
						\end{tikzpicture}
					}
				}
	\newcommand{\oneint}{\patternshift{
						\begin{tikzpicture}[level/.style={sibling distance=0.14cm, level distance=0.15cm}, every path/.style={thick, draw}]
							\node at (0, 0) [pattern_node] {} [grow=down]
								child{node [pattern_node]{}}
								child {node [pattern_node] {}}
								child{node [pattern_node] {}};
						\end{tikzpicture}
					}
				}
\newcommand{\bsym}[1]{\boldsymbol{#1}}%b for bold; sym for symbol







%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMMENTS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\BG}[1]{\todo[inline]{\textbf{Boris says:$\,$} #1}}
\newcommand{\SF}[1]{\todo[inline]{\textbf{Su says:$\,$} #1}}
\newcommand{\OK}[1]{\todo[inline]{\textbf{Oliver says:$\,$} #1}}
\newcommand{\AH}[1]{\todo[inline, backgroundcolor=cyan]{\textbf{Aaron says:$\,$} #1}}
\newcommand{\SR}[1]{\todo[inline, backgroundcolor=white]{\textbf{Note to self:$\,$} #1}}
\newcommand{\AR}[1]{\todo[inline, color=green]{\textbf{Atri says:$\,$} #1}}



%
%borrowed from Su and Boris; Ihave them here for reference purposes.
%needs to be cleaned up
%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% THEOREM LIKE ENVIRONMENTS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareMathAlphabet{\mathbbold}{U}{bbold}{m}{n}

\newtheorem{Theorem}{Theorem}[section]
\newtheorem{Definition}{Definition}
\newtheorem{Lemma}{Lemma}
\newtheorem{Proposition}{Proposition}
\newtheorem{Property}{Property}
\newtheorem{Corollary}{Corollary}
\newtheorem{Claim}{Claim}
\newtheorem{Example}{Example}
\newtheorem{Axiom}{Axiom}
\newtheorem{Question}{Question}
\newtheorem{Assumption}{Assumption}






%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Rel model
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\tup}{t}
\newcommand{\comprehension}[2]{\left\{\;#1\;|\;#2\;\right\}}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SEMIRINGS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\udom}{\mathcal{U}}
\newcommand{\semN}{\mathbb{N}}
\newcommand{\domN}{\mathbb{N}}
\newcommand{\semB}{\mathbb{B}}
\newcommand{\semNX}{\mathbb{N}[X]}
\newcommand{\domK}{K}
\newcommand{\semK}{\mathcal{K}}

\newcommand{\onesymbol}{\mathbbold{1}}
\newcommand{\zerosymbol}{\mathbbold{0}}
\newcommand{\multsymb}{\otimes}
\newcommand{\addsymbol}{\oplus}
\newcommand{\addormultsymbol}{\bigcdot}
\newcommand{\monsymbol}{\ominus}

\newcommand{\kDom}{K}
\newcommand{\addK}{\addsymbol_{\semK}}
\newcommand{\multK}{\multsymb_{\semK}}
\newcommand{\genopK}{\odot_{\semK}}
\newcommand{\monK}{\monsymbol_{\semK}}
\newcommand{\oneK}{\onesymbol_{\semK}}
\newcommand{\zeroK}{\zerosymbol_{\semK}}
\newcommand{\addOf}[1]{\addsymbol_{#1}}
\newcommand{\multOf}[1]{\multsymb_{#1}}
\newcommand{\monOf}[1]{\monsymbol_{#1}}
\newcommand{\oneOf}[1]{\onesymbol_{#1}}
\newcommand{\zeroOf}[1]{\zerosymbol_{#1}}

\newcommand{\dbDomK}[1]{\mathcal{DB}_{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMPLEXITY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\sharpphard}{\#P-hard\xspace}
\newcommand{\sharpwonehard}{\#W[1]-hard\xspace}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "main"
%%% End:

%%%Adding stuff below so that long chain of display equatoons can be split across pages
\allowdisplaybreaks
