\newenvironment{proofcases}
               {\list{}{\labelwidth=0pt \itemindent-\leftmargin
                        \let\makelabel\Descriptionlabel
                        \itshape% or whatever
               }}
               {\endlist}
\newcommand*\Descriptionlabel[1]{%
  \hspace\labelsep
  \emph%  reset current font setting
  % \sffamily% or whatever 
  #1.}


\newcommand{\izero}[0]{\ensuremath{\star}}
\newcommand{\afun}[2]{\ensuremath{\left< #1,#2 \right>}}
% \newcommand{\fanno}[0]{\ensuremath{\mathcal{F}}}
\newcommand{\fanno}[0]{\ensuremath{\Theta}}
\newcommand{\fun}[2]{\ensuremath{\lambda \, #1. \, #2}}


\newcommand{\tstack}[0]{\ensuremath{\Sigma}}
\newcommand{\partTo}[0]{\ensuremath{\rightharpoonup}}

\newcommand{\cf}[0]{\ensuremath{\mathsf{cf}}}

\newcommand{\valid}[2]{\ensuremath{\text{valid}_{#1}(#2)}}
\newcommand{\ix}[2]{\ensuremath{\left< #1,#2 \right>}}

\newcommand{\setCons}{\ensuremath{\mathop{\overline{\Cons}}}}

\newcommand{\Li}[1]{\ensuremath{\overline{#1}}}

\newcommand{\tuples}[3][]{\ensuremath{\tau_{#1}(#2,#3)}}

\newcommand{\semtree}[1]{\ensuremath{\mathit{Tr}(#1)}}
\newcommand{\cons}{\ensuremath{\mathop{::}}}

\newcommand{\Null}{\ensuremath{\mathrm{Null}}}

\newcommand{\trueS}{\ensuremath{\mathrm{true}}}
\newcommand{\falseS}{\ensuremath{\mathrm{false}}}
\newcommand{\ifS}[3]{\ensuremath{\mathrm{if}(#1,#2,#3)}}
\newcommand{\consS}[2]{\ensuremath{\mathrm{cons}(#1,#2)}}
\newcommand{\nilS}[0]{\ensuremath{\mathrm{nil}}}
\newcommand{\matchLS}[5]{\ensuremath{\mathrm{matL}(#1,#2,(#3,#4).#5)}}
\newcommand{\pairS}[2]{\ensuremath{\mathrm{pair}(#1,#2)}}
\newcommand{\matchPS}[4]{\ensuremath{\mathrm{matP}(#1,(#2,#3).#4)}}
\newcommand{\letS}[3]{\ensuremath{\mathrm{let}(#1,#2.#3)}}
\newcommand{\letFS}[3]{\ensuremath{\mathrm{flet}(#1,#2.#3)}}
\newcommand{\absS}[2]{\ensuremath{\mathrm{lam}(#1.#2)}}
\newcommand{\appS}[2]{\ensuremath{\mathrm{app}(#1,#2)}}
\newcommand{\recS}[4]{\ensuremath{\mathrm{rec}((#1,#2).#3,#1.#4)}}

\newcommand{\liT}[1]{\ensuremath{\mathrm{L}(#1)}}
\newcommand{\boolT}[0]{\ensuremath{\mathrm{Bool}}}
\newcommand{\tmono}[0]{\ensuremath{\vdash^{\!\!\!m}}}
\newcommand{\tpoly}[0]{\ensuremath{\vdash^{\!\!p}}}
\newcommand{\tcons}[0]{\ensuremath{\vdash^{\!c}}}

\newcommand{\cConst}{\ensuremath{M^\mathsf{const}}}
\newcommand{\cOp}{\ensuremath{M^\mathsf{\op}}}
\newcommand{\cVar}{\ensuremath{M^\mathsf{var}}}
\newcommand{\cApp}[1]{\ensuremath{M^\mathsf{app}_{#1}}}
\newcommand{\cAbs}[0]{\ensuremath{M^\mathsf{abs}}}
\newcommand{\cBind}{\ensuremath{M^\mathsf{bind}}}
% \newcommand{\cCons}{\ensuremath{M^\mathsf{cons}}}
\newcommand{\cMatch}[1]{\ensuremath{M^\mathsf{mat}}_{#1}}
\newcommand{\cCond}[1]{\ensuremath{M^\mathsf{cond}}_{#1}}
\newcommand{\cTuple}{\ensuremath{M^\mathsf{tuple}}}
\newcommand{\cMatchT}{\ensuremath{M^\mathsf{matT}}}
\newcommand{\cShare}{\ensuremath{M^\mathsf{share}}}
\newcommand{\cLet}[1]{\ensuremath{M^\mathsf{let}_{#1}}}
\newcommand{\cRec}[0]{\ensuremath{M^\mathsf{rec}}}
\newcommand{\cPair}{\ensuremath{M^\mathsf{pair}}}

\newcommand{\cB}[0]{\ensuremath{M^\mathsf{cbool}}}

\newcommand{\cNat}{\ensuremath{M^\mathsf{nat}}}
\newcommand{\cAdd}{\ensuremath{M^\mathsf{add}}}
\newcommand{\cMult}{\ensuremath{M^\mathsf{mult}}}

\newcommand{\cMake}{\ensuremath{M^\mathsf{Amake}}}
\newcommand{\cMakeLin}{\ensuremath{M^\mathsf{AmakeL}}}
\newcommand{\cSet}{\ensuremath{M^\mathsf{Aset}}}
\newcommand{\cGet}{\ensuremath{M^\mathsf{Aget}}}
\newcommand{\cFail}{\ensuremath{M^\mathsf{Afail}}}
\newcommand{\cLength}{\ensuremath{M^\mathsf{Alen}}}
\newcommand{\cRef}{\ensuremath{M^\mathsf{ref}}}
\newcommand{\cDRef}{\ensuremath{M^\mathsf{dref}}}
\newcommand{\cAssign}{\ensuremath{M^\mathsf{assign}}}
\newcommand{\cUdef}{\ensuremath{M^\mathsf{fail}}}
\newcommand{\cTick}{\ensuremath{M^\mathsf{tick}}}

%     & \;\,  \C{AMake},\C{ASet},\C{AGet},\C{ALength},\C{ref},\C{deref} \}

% 
\newcommand{\cMatP}[0]{\ensuremath{M^\mathsf{MatP}}}

% 
\newcommand{\cNil}{\ensuremath{M^\mathsf{nil}}}
\newcommand{\cCons}{\ensuremath{M^\mathsf{cons}}}
\newcommand{\cMatL}[1]{\ensuremath{M^\mathsf{matL}_{#1}}}


\newcommand{\gsym}[1]{\ensuremath{\text{#1}}}

\newcommand{\type}[1]{\ensuremath{\text{#1}}}

\newcommand{\li}[1]{\ensuremath{#1 \; \type{list}}}
\newcommand{\baseTypes}[0]{\ensuremath{\mathcal{B}}}

\newcommand{\typeVars}[0]{\ensuremath{\mathcal{X}}}

\newcommand{\types}[0]{\ensuremath{\mathcal{T}}}

\newcommand{\constants}[0]{\ensuremath{\mathit{Const}}}

\newcommand{\constr}[0]{\ensuremath{\mathcal{C}}}
\newcommand{\vid}[0]{\ensuremath{\mathit{Var}}}

\newcommand{\op}[0]{\ensuremath{\mathop{\mathit{op}}}}

\newcommand{\ops}[0]{\ensuremath{\mathbb{O}}}

\newcommand{\word}[1]{\ensuremath{\mathop{\,\mathsf{#1}\,}}}

\newcommand{\freevars}[1]{\ensuremath{\text{FV}(#1)}}

\newcommand{\closure}[2]{\ensuremath{(#1,#2)}}

\newcommand{\arr}[0]{\ensuremath{\mathit{\sigma}}}

\newcommand{\busy}[0]{\ensuremath{\circ}}

\newcommand{\fail}[0]{\ensuremath{\bot}}

\newcommand{\bigse}[2]{\ensuremath{\Downarrow #1 \mid #2}}

\newcommand{\bigs}[0]{\ensuremath{\Downarrow}}

\newcommand{\bigsb}[1]{\ensuremath{\Downarrow \busy \mid #1}}

\newcommand{\bigss}[2]{\ensuremath{\Downarrow^{#1}_{#2}}}

\newcommand{\pdash}[1]{\mathop{_{#1}\!\!\vdash}}

\newcommand{\C}[1]{\ensuremath{\mathsf{#1}}}


%-------------------------------------------------------
% Code
%-------------------------------------------------------

%Listings

\lstset{
   numbers=none, %use numbers=left
   numberstyle=\tiny,
   stepnumber=1,
   numbersep=5pt,
   basicstyle=\tt\small,
   escapechar=\%,
   mathescape,
%   language=CaML,
   columns=flexible,
%   basewidth=0.455em,
   xleftmargin=\leftmargini,
%   xrightmargin=\leftmargini,
%   morekeywords={mod,div,matchD},
   deletekeywords={as},
   literate={<-}{$\;\leftarrow\;\;\,$}{3} {->}{$\rightarrow$}{3},
   firstnumber=auto % use name=NAME to identify split listings
%
% Placement: belowskip,aboveskip,lineskip,boxpos=l|c|r
%
% wonna figure-style listings? Use: caption={Useless code,label=useless
%
% keywordstyle=\color{black}\bfseries\underbar
% morekeywords={one,two,three,four}
}
% \lstinline!! 
% use basicstyle=\small ?

%breaklines ?
\newcommand{\code}[1]{\text{\sl #1}}
\newcommand{\codebreak}[1]{\lstinline[breaklines,columns=fullflexible,basicstyle={\sl}]!#1!}

\newcommand{\codesmall}[1]{\lstinline[breaklines,columns=flexible,basicstyle=\footnotesize\sl]!#1!}

\newcommand{\fid}[0]{\text{FID} }

\newcommand{\loc}[0]{\ensuremath{\mathit{Loc}}}
\newcommand{\val}[0]{\ensuremath{\mathit{Val}}}




\newcommand{\vars}[1]{\ensuremath{\text{Var}(#1)}}



\newcommand{\heap}[0]{\ensuremath{H} }
\newcommand{\env}[0]{\ensuremath{V} }
\newcommand{\stack}[0]{\ensuremath{S} }

\newcommand{\monoid}[0]{\ensuremath{\mathcal{Q}} }

\newcommand{\Nil}[0]{\ensuremath{\cdot}}
\newcommand{\Cons}[0]{\ensuremath{{::}}}

%-------------------------------------------------------
%Functions

\newcommand{\dom}[1]{\text{dom}(#1)}
\newcommand{\img}[1]{\text{img}(#1)}

\newcommand{\coord}[1]{\ensuremath{\text{co}(#1)}}


%-------------------------------------------------------
% Types (lists, trees and functions)
%-------------------------------------------------------


%Potential
\newcommand{\shift}[0]{{\lhd}}
\newcommand{\del}[0]{{\rho}}

%sharing
\newcommand{\share}[0]{\ensuremath{\curlyveedownarrow\!}}
\newcommand{\plus}[0]{\ensuremath{\oplus}}

\newcommand{\funstar}[2]{\ensuremath{\langle #1,#2 \rangle^*}}
\newcommand{\funtype}[6]{\ensuremath{ [#5] \funold[#3/#4]{#6{:}#1}{#2}}}
\newcommand{\funtypeP}[3]{\ensuremath{\langle \funold{#1}{#2}, #3 \rangle}}
\newcommand{\typeJ}[5]{\ensuremath{#1 \rtyps{#2}{#5} #3:#4}}
\newcommand{\typeJCF}[5]{\ensuremath{#1 \, ^\text{cf}\,\!\!\!\rtyps{#2}{#5} #3:#4}}


\newcommand{\wellformed}[1]{\ensuremath{\mathit{WF}(#1)}}

%subtyping
\newcommand{\subtype}[0]{\ensuremath{<:}}
\newcommand{\suptype}[0]{\ensuremath{:>}}

%simple types

\newcommand{\simple}[1]{\ensuremath{|#1|}}

\newcommand{\datatypes}[0]{\ensuremath{\mathcal{A}}}
\newcommand{\fotypes}[0]{\ensuremath{\mathcal{F}}}

\newcommand{\datatypesLin}[0]{\ensuremath{\mathcal{A}_\text{lin}}}
\newcommand{\fotypesLin}[0]{\ensuremath{\mathcal{F}_\text{lin}}}

\newcommand{\fotypesLeft}[0]{\ensuremath{\mathcal{F}_\text{left}}}

\newcommand{\datatypesPoly}[0]{\ensuremath{\mathcal{A}_\text{pol}}}
\newcommand{\fotypesPoly}[0]{\ensuremath{\mathcal{F}_\text{pol}}}

\newcommand{\base}[0]{\ensuremath{\mathcal{A}}}
\newcommand{\first}[0]{\ensuremath{\mathcal{F}}}

\newcommand{\bool}[0]{\ensuremath{\mathit{bool}}}
\renewcommand{\int}[0]{\ensuremath{\mathit{int}}}
\newcommand{\unit}[0]{\ensuremath{\mathit{unit}}}

\newcommand{\closedTypes}[0]{\ensuremath{\mathcal{C}}}
\newcommand{\unitelement}[0]{\ast}



% %list trees functions
% \newcommand{\li}[2][XX]{%
%    \ifthenelse{\equal{#1}{XX}}%
%       {\ensuremath{L(#2)}}%
%             {\ensuremath{L^{#1}(#2)}}}

\newcommand{\tree}[2][XX]{%
   \ifthenelse{\equal{#1}{XX}}%
      {\ensuremath{T(#2)}}%
            {\ensuremath{T^{#1}(#2)}}}


\newcommand{\tr}[2][XX]{%
   \ifthenelse{\equal{#1}{XX}}%
      {\ensuremath{T(#2)}}%
            {\ensuremath{T^{#1}(#2)}}}

\newlength{\rWidth}


\newcommand{\funold}[3][XX]{%
   \ifthenelse{\equal{#1}{XX}}%
      {\ensuremath{#2 {\rightarrow} #3}}%
      { \settowidth{\rWidth}{\ensuremath{#1}}%
        \ensuremath{ #2 {\xrightarrow{\hspace{\rWidth}}\hspace{-0.84\rWidth}}\!\!\!^%
         {#1}%{\BehindSubString{,}{#1} / \BeforeSubString{,}{#1}}%
         \hspace{0.2\rWidth}\,\, #3}}}


\newcommand{\smallarray}[1]{ \footnotesize{ \ensuremath{ \!\!\!
  \left( \begin{array}{@{\hspace{0.1em}}l@{\hspace{0.4em}}l@{\hspace{0.4em}}l@{\hspace{0.1em}}}
  #1
  \end{array} \right) \!\! } } }


\newcommand{\smallarrayb}[1]{%
  \left( \small{\begin{array}{@{\hspace{0.1em}}l@{\hspace{0.4em}}l@{\hspace{0.4em}}l@{\hspace{0.4em}}l@{\hspace{0.1em}}}
  #1
  \end{array}} \right)}

\newcommand{\ann}[0]{\ensuremath{\text{ann}}}

%cost-free
\newcommand{\funcf}[3]{\fun[\mathit{CF}(#1)]{#2}{#3}}
\newcommand{\cfdash}[0]{\rtyps{\text{cf}}{}}
%0-1 length
\newcommand{\zol}[1]{\ensuremath{|#1|_{0-1}}}

%sized types
\newcommand{\sli}[2]{\ensuremath{L_{#2}(#1)}}

%semantics


\newcommand{\sem}[1]{\ensuremath{\llbracket #1 \rrbracket}}
\newcommand{\semT}[1]{\ensuremath{\llbracket #1 \rrbracket_T}}
\newcommand{\semcons}[0]{\ensuremath{\mathop{::}}}
\newcommand{\semtreeEmpty}[0]{\ensuremath{\mathit{leaf}}}

\newcommand{\elts}[0]{\ensuremath{\text{elems}}}

\newcommand{\uses}[1]{\ensuremath{\leadsto \hspace{0.2em} \mid #1 } }


%size
\newcommand{\size}[1]{\ensuremath{s_{#1}}}
\newcommand{\Size}[1]{\ensuremath{S_{#1}}}

%-------------------------------------------------------
%Type rules (mathpatir)

\newcommand{\Rule}[4][]{\ensuremath{\inferrule*[right={(#2)},#1]{#3}{#4}}}
\newcommand{\RuleToplabel}[4][]{\ensuremath{\inferrule[(#2)]{#3}{#4}}}
\newcommand{\RuleNolabel}[3][]{\ensuremath{\inferrule*[#1]{#2}{#3}}}

%-------------------------------------------------------



%-------------------------------------------------------
% Numbers
%-------------------------------------------------------


\newcommand{\Qplus}[0]{\ensuremath{\mathbb{Q}_{\geq 0}}}
\newcommand{\Q}[0]{\ensuremath{\mathbb{Q}}}
\newcommand{\N}[0]{\ensuremath{\mathbb{N}}}
\newcommand{\R}[0]{\ensuremath{\mathbb{R}}}
\newcommand{\Rplus}[0]{\ensuremath{\mathbb{R}_{\geq 0}}}

%-------------------------------------------------------

%Soundnes proof

\newcommand{\caseSound}[1]{  \vspace{1ex} \noindent
  \textsc{(#1)} \hspace{1em} }

%Multivariate

\newcommand{\atoms}[0]{\ensuremath{\mathit{P}}}
\newcommand{\res}[0]{\ensuremath{\mathit{R}}}
\newcommand{\obj}[0]{\ensuremath{\text{ob}}}
\newcommand{\craml}[0]{\ensuremath{\text{RP}}}

\newcommand{\ind}[0]{\ensuremath{\mathcal{I}}}



\newcommand{\id}[0]{\ensuremath{\mathit{id}}}

\newcommand{\rec}[1]{\textsl{rec}(#1)}
\newcommand{\lift}[2]{\ensuremath{[#1]_{#2}}}


\newcommand{\ac}[1]{\textsl{acost}(#1)}

\newcommand{\appsub}[2]{\ensuremath{#1(#2)}}
\newcommand{\subst}[3]{\ensuremath{[#1 {\mapsto} #2] #3}}
\newcommand{\fv}[1]{\ensuremath{\mathit{FV}(#1)}}

\newcommand{\tvars}[0]{\ensuremath{\mathcal{X}}}
\newcommand{\mtypes}[0]{\ensuremath{\mathcal{T}}}

\newcommand{\tsubst}[0]{\ensuremath{\sigma}}
\newcommand{\tsubsT}[0]{\ensuremath{\widehat{\sigma}}}

\newcommand{\consts}[0]{\ensuremath{C}}
\newcommand{\teq}[2]{\ensuremath{\left<#1,#2\right>}}
\newcommand{\unif}[0]{\ensuremath{\implies}}
\newcommand{\unifs}[0]{\ensuremath{\mathcal{U}}}

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