%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{\steps}{\mapsto}
\newcommand{\msteps}{\steps^*}

%% Types
\newcommand{\tunit}{\mathtt{unit}}
\newcommand{\tsum}[2]{#1 + #2}
\newcommand{\tprod}[2]{#1 \times #2}
\newcommand{\tarrow}[2]{#1 \rightarrow #2}
\newcommand{\hto}{\rightharpoonup}
\newcommand{\tpartial}[2]{#1 \hto #2}
\newcommand{\texists}[2]{\exists #1. #2}
\newcommand{\tforall}[2]{\forall #1. #2}

%% Expressions
\newcommand{\lam}[3]{\lambda #1{:}#2. #3}
\newcommand{\ap}[2]{#1\; #2}
\newcommand{\caseop}{\kw{case}}
\newcommand{\ecase}[5]{\caseop\; #1\; \{#2. #3; #4. #5\}}
\newcommand{\eprod}[2]{\langle #1, #2 \rangle}
\newcommand{\einl}[1]{\kw{L} \cdot #1}
\newcommand{\einr}[1]{\kw{R} \cdot #1}
\newcommand{\triv}{\langle \rangle}
\newcommand{\epack}[4]{\kw{pack}\; #3\; \kw{with}\; #4\; \kw{as}\; \texists{#1}{#2}}
\newcommand{\eopen}[6]{\kw{open}\; #4\; \kw{as}\; #1\; \kw{with} #3:#2\; \kw{in}\; #5}

%% Dynamic dispatch
\newcommand{\emcase}[5]{\caseop\; #1\; \{#4. #5\}_{#2 \in #3}}
\newcommand{\tdm}{\tau_\mathsf{dm}}
\newcommand{\edm}{e_\mathsf{dm}}
\newcommand{\tcv}{\tau_\mathsf{cv}}
\newcommand{\tmv}{\tau_\mathsf{mv}}
\newcommand{\vobj}{t_\mathsf{obj}}
\newcommand{\tobj}{\tau_\mathsf{obj}}
\newcommand{\tabs}{\tau_\mathsf{abs}}

%% Dynamic types
\newcommand{\numop}{\kw{num}}
\newcommand{\funop}{\kw{fun}}
\newcommand{\tdyn}{\kw{dyn}}
\newcommand{\enum}[1]{\numop!#1}
\newcommand{\efun}[1]{\funop!#1}
\newcommand{\enumc}[1]{#1 @ \numop}
\newcommand{\efunc}[1]{#1 @ \funop}
\newcommand{\enumq}[1]{\numop?#1}
\newcommand{\efunq}[1]{\funop?#1}

%% Nats and streams
\newcommand{\langns}{\Lang{LNS}}
\newcommand{\tnat}{\kw{nat}}
\newcommand{\zero}{\kw{z}}
\newcommand{\z}{\zero}
\newcommand{\sucop}{\kw{s}}
\newcommand{\suc}[1]{\OpAST{\sucop}{#1}}
\newcommand{\recop}{\kw{rec}}
\newcommand{\rec}[4]{\OpABT{\recop}{#1; #2; #3. #4}}
\newcommand{\altrecop}{\kw{rec'}}
\newcommand{\altrec}[5]{\OpABT{\altrecop}{#1; #2; #3. #4. #5}}
\newcommand{\natof}[1]{\overline{#1}}

\newcommand{\tstream}{\kw{stream}}
\newcommand{\hdop}{\kw{hd}}
\newcommand{\hd}[1]{\OpABT{\hdop}{#1}}
\newcommand{\tlop}{\kw{tl}}
\newcommand{\tl}[1]{\OpABT{\tlop}{#1}}
\newcommand{\strgenop}{\kw{strgen}}
\newcommand{\strgen}[5]{\strgenop\; #1\;
  \{\pairff{\hd{#2}}{#3} \mid \pairff{\tl{#4}}{#5}\}}

%% Generic programming
\newcommand{\fmapop}{\kw{map}}
\newcommand{\fmap}[2]{\OpABTp{\fmapop}{#1}{#2}}
\newcommand{\pos}{\; \mathsf{pos}}

%% Inductive and coinductive types
\newcommand{\langic}{\Lang{M}}
\newcommand{\tind}[2]{\mu #1. #2}
\newcommand{\tcoi}[2]{\nu #1. #2}
\newcommand{\tbool}{\kw{bool}}
\newcommand{\true}{\kw{true}}
\newcommand{\false}{\kw{false}}
\newcommand{\foldop}{\kw{fold}}
\newcommand{\fold}[2]{\OpABTp{\foldop}{#1}{#2}}
\newcommand{\grecop}{\kw{rec}}
\newcommand{\grec}[4]{\OpABTp{\grecop}{#1}{#2. #3; #4}}
\newcommand{\unfoldop}{\kw{unfold}}
\newcommand{\unfold}[2]{\OpABTp{\unfoldop}{#1}{#2}}
\newcommand{\genop}{\kw{gen}}
\newcommand{\gen}[4]{\OpABTp{\genop}{#1}{#2. #3; #4}}

\newcommand{\suspop}{\kw{susp}}
\newcommand{\tsusp}[1]{\suspop(#1)}
\newcommand{\susp}[1]{\OpABT{\suspop}{#1}}
\newcommand{\forceop}{\kw{force}}
\newcommand{\force}[1]{\OpABT{\forceop}{#1}}

%% Recursive Types
\newcommand{\langfpc}{\Lang{FPC}}
\newcommand{\tparr}[2]{#1 \rightharpoonup #2}
\newcommand{\trec}[2]{\kw{rec}\; #1 . #2}
\newcommand{\fixop}{\kw{fix}}
\newcommand{\efix}[3]{\OpABTp{\fixop}{#1}{#2 . #3}}
\newcommand{\dummy}{\_}
\newcommand{\foldnp}[1]{\OpABT{\foldop}{#1}}
\newcommand{\unfoldnp}[1]{\OpABT{\unfoldop}{#1}}

%% Self-reference
\newcommand{\selfop}{\kw{self}}
\newcommand{\tself}[1]{#1\;\selfop}
\newcommand{\eself}[3]{\kw{self}\;#2 : #1\;\kw{is}\;#3}
\newcommand{\unrollop}{\kw{unroll}}
\newcommand{\unroll}[1]{\OpABT{\unrollop}{#1}}
\newcommand{\tlprod}[1]{\langle #1 \rangle}
\newcommand{\tlpair}[2]{\kw{#1} \hookrightarrow #2}
\newcommand{\elprod}[1]{\langle #1 \rangle}
\newcommand{\elpair}[2]{\kw{#1} \hookrightarrow #2}
\newcommand{\projname}[2]{#1 \cdot \mathtt{#2}}

%% PCF
\newcommand{\langpcf}{\Lang{PCF}}
\newcommand{\ifzop}{\kw{ifz}}
\newcommand{\ifz}[4]{\OpABT{\ifzop}{#1; #2; #3. #4}}
\newcommand{\ifbop}{\kw{if}}
\newcommand{\ifb}[3]{\OpABT{\ifbop}{#1; #2; #3}}
\newcommand{\Goedel}{G\"{o}del}
\newcommand{\gn}[1]{\lceil #1 \rceil}

%% System F
\newcommand{\systemf}{System \Lang{F}}

%% Refinements
\newcommand{\rtop}[1]{\top_{#1}}
\newcommand{\rand}[3]{#2 \land_{#1} #3}
\newcommand{\rnum}[1]{\numop!#1}
\newcommand{\rfun}[1]{\funop!#1}
\newcommand{\rprod}[2]{#1 \times #2}
\newcommand{\rsum}[2]{#1 + #2}
\newcommand{\rarr}[2]{#1 \hto #2}
\newcommand{\refines}{\sqsubseteq}
\newcommand{\inrefn}[3]{#1 \in_{#2} #3}