%THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{proof}
\usepackage{hyperref}
\newtheorem{lemma}{Lemma}
\newtheorem{corr}{Corollary}
\newenvironment{hint}{\noindent{\bf (Hint)}}{}
\newtheorem{thm}{Theorem}
\newtheorem{definition}{Definition}
\newtheorem{task}{Task}
\newtheorem{bonus}{Bonus Task}

\newif\ifsol

\newcommand{\makehwtitle}[4]
{{\centering\Large\textbf{Homework #1: #2}
    \normalsize\\
15-814: Types and Programming Languages\\
Fall 2015\\
TA: Evan Cavallo (ecavallo@cs.cmu.edu)\\
\ifsol \solcolor \textbf{SOLUTIONS} \normalcolor \\ \fi \vspace{0.5cm}%
Out: #3\\
Due: #4\\
}}

\newenvironment{proof}{\trivlist \item[\hskip \labelsep{\bf
Proof:}]}{\hfill$\Box$ \endtrivlist}

\newenvironment{sol}{
\trivlist \item[\hskip \labelsep{\bf
Solution:}]}{\endtrivlist}

\newcommand{\solution}[1]{\ifsol \begin{sol} #1 \end{sol} \fi}

\newcommand{\taskpts}[1]{[#1]}

\newenvironment{includeintemplate}{}{}
\newenvironment{noinclude}{}{}
\newcommand{\rulename}[1]{\text{\textsc{(#1)}}}
\newcommand{\einfer}[3]
        {\begin{equation}\label{eq:#1}\infer[]{#2}{#3}\end{equation}}

\allowdisplaybreaks       %mildly permissible to break up displayed equations
%% Propositions
\newtheorem{prop}{Proposition}

%% General
\newcommand{\textbsf}[1]{\textbf{\textsf{#1}}}
\newcommand{\Lang}[1]{\textbsf{#1}}
\newcommand{\kw}[1]{\ensuremath{\mathtt{#1}}}
\newcommand{\kwop}[1]{\ensuremath{\mathop{\mathtt{#1}}}}
\newcommand{\kwbin}[1]{\ensuremath{\mathbin{\mathtt{#1}}}}
\newcommand{\step}{\mapsto}
\newcommand{\G}{\Gamma}
\newcommand{\xv}{\vec{x}}
\newcommand{\entails}{\vdash}
\newcommand{\xvars}{\mathcal{X}}
\newcommand{\cdparens}[1]{\kw{(}{#1}\kw{)}}
\newcommand{\cdsqbracks}[1]{\kw{[}{#1}\kw{]}}
\newcommand{\OpAST}[2]{{#1}\cdparens{#2}}
\newcommand{\AbsAST}[2]{{#1}\cddot{#2}}
\newcommand{\OpABT}[2]{{#1}\cdparens{#2}}
\newcommand{\OpABTp}[3]{{#1}\cdsqbracks{#2}\cdparens{#3}}
\newcommand{\OpABTpp}[4]{{#1}\cdsqbracks{#2}\cdsqbracks{#3}\cdparens{#4}}
\newcommand{\OpABTn}[2]{{#1}\cdsqbracks{#2}}
\newcommand{\OpABTnn}[3]{{#1}\cdsqbracks{#2}\cdsqbracks{#3}}
\newcommand{\AbsABT}[2]{{#1}\cddot{#2}}
\newcommand{\pairff}[2]{{#1}\mathbin{\hookrightarrow}{#2}}
\newcommand{\eqdef}{\mathrel{\triangleq}}
\newcommand{\val}{\;\mathsf{val}}
\newcommand{\lequiv}[1]{\sim_{#1}}
\newcommand{\dom}[1]{\mathit{Dom}(#1)}
\newcommand{\dummy}{\_}
\newcommand{\vals}[3]{#1 \Downarrow_{#2} #3}

%% Types
\newcommand{\tunit}{\mathtt{unit}}
\newcommand{\tsum}[2]{#1 + #2}
\newcommand{\tprod}[2]{#1 \times #2}
\newcommand{\tarrow}[2]{#1 \rightarrow #2}
\newcommand{\tparr}[2]{#1 \rightharpoonup #2}
\newcommand{\tnat}{\kw{nat}}
\newcommand{\tint}{\kw{int}}
\newcommand{\tbool}{\kw{bool}}

%% Expressions
\newcommand{\lam}[3]{\lambda #1{:}#2.\ #3}
\newcommand{\lams}[2]{\lambda #1.\ #2}
\newcommand{\ap}[2]{\kw{ap}(#1;#2)}
\newcommand{\inl}[1]{\kw{L} \cdot #1}
\newcommand{\inr}[1]{\kw{R} \cdot #1}
\newcommand{\caseop}{\kw{case}}
\newcommand{\ecase}[5]{\caseop\; #1\; \{#2. #3; #4. #5\}}
\newcommand{\eprod}[2]{\langle #1, #2 \rangle}
\newcommand{\triv}{\langle \rangle}
\newcommand{\projl}[1]{#1 \cdot \kw{L}}
\newcommand{\projr}[1]{#1 \cdot \kw{R}}
\newcommand{\zero}{\kw{z}}
\newcommand{\z}{\zero}
\newcommand{\sucop}{\kw{s}}
\newcommand{\suc}[1]{\OpAST{\sucop}{#1}}
\newcommand{\ifzop}{\kw{ifz}}
\newcommand{\ifz}[4]{\OpABT{\ifzop}{#1; #2; #3. #4}}

%% PCF
\newcommand{\langpcf}{\Lang{PCF}}
\newcommand{\hto}{\hookrightarrow}
\newcommand{\fixop}{\kw{fix}}
\newcommand{\efix}[3]{\fixop\{#1\}(#2. #3)}

%% Recursive Types
\newcommand{\langfpc}{\Lang{FPC}}
\newcommand{\trec}[2]{\kw{rec}\; #1 . #2}
\newcommand{\foldop}{\kw{fold}}
\newcommand{\unfoldop}{\kw{unfold}}
\newcommand{\efold}[1]{\OpABT{\foldop}{#1}}
\newcommand{\eunfold}[1]{\OpABT{\unfoldop}{#1}}

%% Exceptions
\newcommand{\texn}{\tau_{\mathsf{exn}}}
\newcommand{\raiseop}{\kw{raise}}
\newcommand{\tryop}{\kw{try}}
\newcommand{\eraise}[2]{\raiseop\{#1\}(#2)}
\newcommand{\etry}[3]{\tryop(#1;#2.#3)}

%% Algol
\newcommand{\langma}{\Lang{MA}}
\newcommand{\Sg}{\Sigma}
\newcommand{\fstate}[3]{\nu{#1}\{ #2 \parallel #3 \}}
\newcommand{\sstate}[2]{\nu{#1}\{ #2 \}}
\newcommand{\shas}{\sim}
\newcommand{\mhas}{\sim}
\newcommand{\memmap}[2]{#1 \hookrightarrow #2}
\newcommand{\cmdop}{\kw{cmd}}
\newcommand{\tcmd}[1]{#1\; \cmdop}
\newcommand{\ecmd}[1]{\cmdop(#1)}
\newcommand{\retop}{\kw{ret}}
\newcommand{\mret}[1]{\retop(#1)}
\newcommand{\bndop}{\kw{bnd}}
\newcommand{\mbndc}[3]{\bndop\; #2 \leftarrow #1; #3}
\newcommand{\mbnd}[3]{\bndop(#1;#2.#3)}
\newcommand{\dclop}{\kw{dcl}}
\newcommand{\mdcl}[3]{\dclop(#1;#2.#3)}
\newcommand{\doop}{\kw{do}}
\newcommand{\mdo}[1]{\doop(#1)}
\newcommand{\getop}{\kw{get}}
\newcommand{\setop}{\kw{set}}
\newcommand{\mget}[1]{\getop[#1]}
\newcommand{\mset}[2]{\setop[#1](#2)}

\newcommand{\refop}{\kw{ref}}
\newcommand{\getrefop}{\kw{getref}}
\newcommand{\setrefop}{\kw{setref}}
\newcommand{\tref}[1]{#1\; \refop}
\newcommand{\eref}[1]{\refop[#1]}
\newcommand{\mgetref}[1]{\getrefop(#1)}
\newcommand{\msetref}[2]{\setrefop(#1;#2)}

\newcommand{\sexec}{\rhd}
\newcommand{\sret}{\lhd}
\newcommand{\sexn}{\blacktriangleleft}
\newcommand{\mraise}[2]{\raiseop\{#1\}(#2)}
\newcommand{\mtry}[3]{\tryop(#1;#2.#3)}

\newcommand{\treeop}{\kw{tree}}
\newcommand{\ttree}[1]{#1\; \treeop}

%% Continuations
\newcommand{\contop}{\kw{cont}}
\newcommand{\letccop}{\kw{letcc}}
\newcommand{\throwop}{\kw{throw}}
\newcommand{\tcont}[1]{#1\; \contop}
\newcommand{\econt}[1]{\contop(#1)}
\newcommand{\letcc}[3]{\letccop\{#1\}(#2.#3)}
\newcommand{\throw}[3]{\throwop\{#1\}(#2;#3)}

\newcommand{\stackemp}{\epsilon}

%% Fluid binding
\newcommand{\tfluid}{\tau_{\mathsf{fluid}}}
\newcommand{\putfop}{\kw{putf}}
\newcommand{\getfop}{\kw{getf}}
\newcommand{\eputf}[2]{\putfop(#1;#2)}
\newcommand{\egetf}{\getfop}
\newcommand{\fluidJ}[2]{\kw{fluid}(#1) \Rightarrow #2}
\newcommand{\nofluidJ}[1]{\kw{fluid}(#1) \not\Rightarrow}

%% Dynamic Classification
\newcommand{\tclsfd}{\kw{clsfd}}
\newcommand{\newop}{\kw{new}}
\newcommand{\inop}{\kw{in}}
\newcommand{\isinop}{\kw{isin}}
\newcommand{\enew}[3]{\newop\{#1\}(#2.#3)}
\newcommand{\ein}[2]{\inop[#1](#2)}
\newcommand{\eisin}[5]{\isinop[#1](#2;#3.#4;#5)}

%% Existential Types
\newcommand{\texists}[2]{\exists #1. #2}
\newcommand{\packop}{\kw{pack}}
\newcommand{\openop}{\kw{open}}
\newcommand{\epack}[4]{\packop\{#1.#2\}\{#3\}(#4)}
\newcommand{\epackc}[4]{\packop #3\; \kw{with}\; #4\; \kw{as}\; \texists{#1}{#2}}
\newcommand{\eopen}[6]{\openop\{#1.#2\}\{#3\}(#4;#1,#5.#6)}
\newcommand{\eopenc}[5]{\openop\; #4\; \kw{as}\; #1\; \kw{with} #3:#2\; \kw{in}\; #5}

%% Generic programming
\newcommand{\fmapop}{\kw{map}}
\newcommand{\efmap}[4]{\fmapop\{#1.#2\}(#3;#4)}

\newcommand{\eerror}{\kw{error}}