% Better horizontal rules
\usepackage{booktabs}
\usepackage{listings}
\usepackage{stmaryrd}
\usepackage{mathpartir}
\usepackage{fourier-orns}
\lstset{language=ML}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{multicol}
\usepackage{tikz}

% Override Scribble's default SecRef to numeric only
\renewcommand{\SecRef}[2]{~#1}

\hypersetup{hidelinks}

\usepackage[scaled=0.95]{zi4}
\usepackage[T1]{fontenc}

% For bib style
\newcommand{\Thyperref}[2]{\hyperref[#2]{#1}}

%% To show overfull, turn off for production!!!
\overfullrule=1mm

%% balance last page columns
%\usepackage{flushend}

%% for figure 2
\let\ulcorner\relax
\let\urcorner\relax
\let\llcorner\relax
\let\lrcorner\relax
\usepackage{amssymb}

%% -- types
\newcommand{\tvar}[1]{\mathsf{#1}}
\newcommand{\tnat}{\tvar{Natural}}
\newcommand{\tarray}{\tvar{Array}}
\newcommand{\tint}{\tvar{Int}}
\newcommand{\tnum}{\tvar{Num}}
\newcommand{\tlist}[1]{\tvar{List~#1}}
\newcommand{\naturals}{\mathbb{N}}
\newcommand{\ints}{\mathbb{Z}}

%% -- terms
\newcommand{\vectorgen}[1]{\langle #1 \rangle}
\newcommand{\vectoren}{\vectorgen{e_0, \ldots, e_{n-1}}}
\newcommand{\vectorvn}{\vectorgen{v_0, \ldots, v_{n-1}}}
\newcommand{\vectorxn}{\vectorgen{x_0, \ldots, x_{n-1}}}
\newcommand{\vlam}[2]{\lambda\,#1\,.\,#2}
\newcommand{\aref}[2]{#1@#2}
\newcommand{\checkedref}{\tvar{checked\mbox{-}ref}}
\newcommand{\unsaferef}{\tvar{unsafe\mbox{-}ref}}
\newcommand{\segfault}{\mathsf{segfault}}
\newcommand{\indexerror}{\mathsf{IndexError}}

%% -- evaluation contexts
\newcommand{\ectx}{E}
\newcommand{\ehole}{[\cdot]}

%% -- type environments
\newcommand{\tenv}{\Gamma}
\newcommand{\tenvempty}{\cdot}
\newcommand{\tenvcons}[3]{#1:#2,#3}

%% -- typing
\newcommand{\typestogen}[3]{#1 \vdash #2 : #3}
\newcommand{\typestoclosed}[2]{\typestogen{\tenvempty}{#1}{#2}}
\newcommand{\typesto}[2]{\typestogen{\tenv}{#1}{#2}}

%% -- elaboration
\newcommand{\elabarrow}{\rightsquigarrow}
\newcommand{\elabarrowplus}{\elabarrow^{+}}
\newcommand{\elabstogen}[5]{\typestogen{#1}{#2 #3 #4}{#5}}
\newcommand{\elabstoclosedplus}[3]{\elabstogen{\tenvempty}{#1}{\elabarrowplus}{#2}{#3}}
\newcommand{\elabstoclosed}[3]{\elabstogen{\tenvempty}{#1}{\elabarrow}{#2}{#3}}
\newcommand{\elabsto}[3]{\elabstogen{\tenv}{#1}{\elabarrow}{#2}{#3}}

%% -- evaluation
\newcommand{\bigstep}[2]{#1 \Downarrow #2}
\newcommand{\bigstepplus}[2]{#1 \Downarrow^+ #2}
\newcommand{\smallstepstar}[2]{#1 \rightarrow^* #2}
\newcommand{\smallstep}[2]{#1 \rightarrow #2}

%% -- misc
\newcommand{\esubst}[2]{[#2/#1]}
\newcommand{\qed}{$\square$}

