% macros for unified programming and math notations
% needs amsmath package

% ==> and <==
\newcommand{\imp}{\Rightarrow}
\newcommand{\impby}{\Leftarrow}
\newcommand{\pmi}{\impby}

% logical and ("et" in Latin), logical or ("vel" in Latin)
\newcommand{\et}{\wedge}
\newcommand{\vel}{\vee}

% max and min as up/down arrows: \bmax, \bmin
\newcommand{\bmax}{\mathbin{\uparrow}}
\newcommand{\bmin}{\mathbin{\downarrow}}

% bunch cardinality
\newcommand{\card}{\not{\mathrm{c}}}

% null bunch
\newcommand{\nul}{\mathit{null}}
% nil string
\newcommand{\nil}{\mathit{nil}}

% some common bunches: nat, xnat, int, xint, rat, xrat
\newcommand{\nat}{\mathit{nat}}
\newcommand{\xnat}{\mathit{xnat}}
\renewcommand{\int}{\mathit{int}}
\newcommand{\xint}{\mathit{xint}}
\newcommand{\rat}{\mathit{rat}}
\newcommand{\xrat}{\mathit{xrat}}

% 0 \bto 3 = 0,..3
% (b stands for bunch)
\newcommand{\bto}{\mathord{,}..}
% 0 \sto 3 = 0;..3
% (s stands for string)
\newcommand{\sto}{\mathord{;}..}

% the | in "n -> i | L"
\newcommand{\ow}{\mid}

% dependent composition P.Q
\newcommand{\dc}{\mathrel{.}}

% ok
\newcommand{\ok}{\mathit{ok}}

% :=
\newcommand{\get}{\mathpunct{:=}}

% if-then-else-fi
\newcommand{\cond}[3]{\mbox{\textbf{if} $#1$ \textbf{then} $#2$ \textbf{else} $#3$ \textbf{fi}}}
% if c then stuff
% else fluff fi
\newcommand{\condb}[3]{\begin{array}[t]{@{}l}\mbox{\textbf{if} $#1$ \textbf{then} $#2$} \\ \mbox{\textbf{else} $#3$ \textbf{fi}} \end{array}}
% if c then
%   stuff
% else
%   fluff
% fi
\newcommand{\condbb}[3]{\begin{array}[t]{@{}l}\mbox{\textbf{if} $#1$ \textbf{then}} \\ \quad #2 \\ \mbox{\textbf{else}} \\ \quad #3 \\ \mbox{\textbf{fi}} \end{array}}

% while-do-od
\newcommand{\while}[2]{\mbox{\textbf{while} $#1$ \textbf{do} $#2$ \textbf{od}}}
% while b
% do body od
\newcommand{\whileb}[2]{\begin{array}[t]{@{}l}\mbox{\textbf{while} $#1$} \\ \mbox{\textbf{do} $#2$ \textbf{od}} \end{array}}

% funktion applikation
\newcommand{\ap}{\,}

% enlarged relation symbol
\newcommand{\bigrel}[1]{\mathrel{\,\mbox{\Large$#1$\small$ $}\,}}

% some common enlarged relation symbols
\newcommand{\Eq}{\bigrel{=}}
\newcommand{\Imp}{\bigrel{\imp}}
\newcommand{\Impby}{\bigrel{\impby}}
\newcommand{\Pmi}{\Impby}

\newcommand{\blankrel}[1]{\mathrel{\phantom{#1}}}
\newcommand{\Blank}{\blankrel{\Eq}}

% function
% with domain: \fun{local_variable}{domain}{body}
% omit domain: \fn{local_variable}{body}
\newcommand{\fun}[3]{\langle #1 \colon #2 \rightarrow #3 \rangle}
\newcommand{\fn}[2]{\langle #1 \to #2 \rangle}

% quantified expressions sans quantifier
% with domain: \bind{local_variable}{domain}{body}
% omit domain: \bnd{local_variable}{body}
\newcommand{\bind}[3]{#1 \colon #2 \cdot #3}
\newcommand{\bnd}[2]{#1 \cdot #2}

% MAX and MIN
\newcommand{\MAX}{\mathop{\mathit{MAX}}}
\newcommand{\MIN}{\mathop{\mathit{MIN}}}

% multiple terms splitted into lines, like this:
%    A
%  + B
%  + C
% and you type:
% \begin{terms}
% & A \\
% + & B \\
% + & C
% \end{terms}
\newenvironment{terms}{\begin{array}[t]{@{}c@{\ }l}}{\end{array}}

% multiple lines, each left-justified
% \begin{lines}
% xxx + \\
% yyy + \\
% zzz
% \end{lines}
\newenvironment{lines}{\begin{array}[t]{@{}l}}{\end{array}}

