
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                           %
% General helper definitions for symbol construction                        %
%                                                                           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\mumoveback#1#2:#3{\mskip-#1mu\mskip-#3mu\relax#2\mskip#1mu}
\def\mumovebackX#1#2:#3{\vrule height 2pt depth 0pt width1pt\kern-1pt
                       \mumoveback{#1}#2:{#3}%
                       \vrule height 0pt depth 2pt width1pt\kern-1pt}

\def\ttmathchar#1{\mathtt{\count0=`#1 \advance\count0by"7100 \mathchar\count0}}

\def\sfkeyword#1{\ensuremath{\mathsf{#1}}\xspace}

\let\CMrightarrow=\rightarrow
\let\CMleftarrow=\leftarrow

\newcommand{\add@arrowhead}{\mathrel{\mkern-15mu\CMrightarrow}}
\newcommand{\rightarrowWithLimits}[2]
        {\mathrel{{\,#1\over\,#2}\mkern2mu}\add@arrowhead}
\newcommand{\leftarrowWithLimits}[2]
        {\mathrel{\CMleftarrow\mkern-13mu}\mathrel{\,#1\over\,#2}}

\def\powerset#1{\mathcal{P}(#1)}
\def\powersetFin#1{\mathcal{P}_{\!\mathrm{fin}}(#1)}

\def\disjointSetsSym{\mathrel{\#}}
\def\disjointSets#1#2{{#1}\disjointSetsSym{#2}}

\def\mapSpace#1#2{{#1}\mathbin{\CMrightarrow}{#2}}
\def\mapFinite#1#2{{#1}\mathbin{\rightarrowWithLimits{\mathrm{fin}}{}}{#2}}
\def\mapFinInj#1#2{{#1}\mathbin{\rightarrowWithLimits{\mathrm{fin}}
                                                     {\mathrm{inj}}}{#2}}

\def\mapJoin{\boxplus}

\def\Dom#1{\mathrm{Dom}\;{#1}}
\def\Img#1{\mathrm{Img}\;{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                           %
% Shorthand for variables names and such                                    %
%                                                                           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\varname{\mathtt}

{\catcode`\@=13
 \gdef@{\varname}
}\mathcode`\@="8000

\def\numberedpalette#1{#1{0} \OR #1{1} \OR #1{2} \OR \cdots}

\def\varnamepalette#1{{\def\\##1{\varname{#1##1}}\numberedpalette{\\}}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                           %
% Notation to make a variable into the set of its possible values           %
%                                                                           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\dotightframe#1#2#3{%
  \hbox{\vrule width#1pt
        \vbox{\hrule height#1pt
              \kern#2pt
              \hbox{\kern#2pt\relax#3\kern#2pt}
              \dimen0=\prevdepth
              \kern#2pt         \advance\dimen0by#2pt
              \hrule height#1pt \advance\dimen0by#1pt
              \setbox0\hbox{}\dp0\dimen0\ht0-\dimen0
              \box0}\vrule width#1pt}}
\def\varToSet#1{\leavevmode
                \dotightframe{.2}{.6}{\dotightframe{.2}{1.7}{$#1$}}}

