%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                                                          %%
%% sdrt.sty v. 1.0 by Paul Isambert                                         %%
%% This set of macros is published under the LaTeX Project Public License.  %%
%%                                                                          %%
%% Comments, suggestions and bugs:                                          %%
%%                                                                          %%
%% zappathustra@free.fr                                                     %%
%%                                                                          %%
%% http://paulisambert.free.fr/                                             %%
%%                                                                          %%
%% Enjoy!                                                                   %%
%%                                                                          %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{sdrt}[2008/04/02 Package for typesetting Discourse Representation Theory and formal semantics in general]

\RequirePackage{ifthen}
\RequirePackage{xyling}
\RequirePackage{xytree}%This package is needed, otherwise there's trouble with the trees... but I dont know why!

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%The \lab[]{} command and all its variants%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\lab
\newcommand{\lab}[2][]{\ensuremath{\pi#1_{#2}}}

\newcommand{\labone}{\ensuremath{\lab{1}}} 
\newcommand{\labtwo}{\ensuremath{\lab{2}}}
\newcommand{\labthree}{\ensuremath{\lab{3}}} 
\newcommand{\labfour}{\ensuremath{\lab{4}}} 
\newcommand{\labfive}{\ensuremath{\lab{5}}} 
\newcommand{\labsix}{\ensuremath{\lab{6}}} 
\newcommand{\labseven}{\ensuremath{\lab{7}}} 
\newcommand{\labeight}{\ensuremath{\lab{8}}} 
\newcommand{\labnine}{\ensuremath{\lab{9}}} 
\newcommand{\labzero}{\ensuremath{\lab{0}}} 

\newcommand{\labprime}{\ensuremath{\lab[']{}}}
\newcommand{\labsecond}{\ensuremath{\lab['']{}}}
\newcommand{\labthird}{\ensuremath{\lab[''']{}}}
\newcommand{\labfourth}{\ensuremath{\lab['''']{}}}

%\klab
\newcommand{\klab}[2][]{\ensuremath{\lab[#1]{#2} : K_{\lab[#1]{#2}}}}

\newcommand{\klabone}{\ensuremath{\klab{1}}} 
\newcommand{\klabtwo}{\ensuremath{\klab{2}}}
\newcommand{\klabthree}{\ensuremath{\klab{3}}} 
\newcommand{\klabfour}{\ensuremath{\klab{4}}} 
\newcommand{\klabfive}{\ensuremath{\klab{5}}} 
\newcommand{\klabsix}{\ensuremath{\klab{6}}} 
\newcommand{\klabseven}{\ensuremath{\klab{7}}} 
\newcommand{\klabeight}{\ensuremath{\klab{8}}} 
\newcommand{\klabnine}{\ensuremath{\klab{9}}} 
\newcommand{\klabzero}{\ensuremath{\klab{0}}}

%\klabstar
\newcommand{\klabstar}[2][]{\ensuremath{\lab[#1]{#2} : K^{+}_{\lab[#1]{#2}}}}

\newcommand{\klabstarone}{\ensuremath{\klabstar{1}}} 
\newcommand{\klabstartwo}{\ensuremath{\klabstar{2}}}
\newcommand{\klabstarthree}{\ensuremath{\klabstar{3}}} 
\newcommand{\klabstarfour}{\ensuremath{\klabstar{4}}} 
\newcommand{\klabstarfive}{\ensuremath{\klabstar{5}}} 
\newcommand{\klabstarsix}{\ensuremath{\klabstar{6}}} 
\newcommand{\klabstarseven}{\ensuremath{\klabstar{7}}} 
\newcommand{\klabstareight}{\ensuremath{\klabstar{8}}} 
\newcommand{\klabstarnine}{\ensuremath{\klabstar{9}}} 
\newcommand{\klabstarzero}{\ensuremath{\klabstar{0}}}

%\flab
\newcommand{\flab}[2][]{\ensuremath{\mathcal{F}(\lab[#1]{#2})}}

\newcommand{\flabone}{\ensuremath{\flab{1}}} 
\newcommand{\flabtwo}{\ensuremath{\flab{2}}}
\newcommand{\flabthree}{\ensuremath{\flab{3}}} 
\newcommand{\flabfour}{\ensuremath{\flab{4}}} 
\newcommand{\flabfive}{\ensuremath{\flab{5}}} 
\newcommand{\flabsix}{\ensuremath{\flab{6}}} 
\newcommand{\flabseven}{\ensuremath{\flab{7}}} 
\newcommand{\flabeight}{\ensuremath{\flab{8}}} 
\newcommand{\flabnine}{\ensuremath{\flab{9}}} 
\newcommand{\flabzero}{\ensuremath{\flab{0}}}

%\flabk
\newcommand{\fklab}[2][]{\ensuremath{\flab[#1]{#2} = K_{\lab[#1]{#2}}}}

\newcommand{\fklabone}{\ensuremath{\fklab{1}}} 
\newcommand{\fklabtwo}{\ensuremath{\fklab{2}}}
\newcommand{\fklabthree}{\ensuremath{\fklab{3}}} 
\newcommand{\fklabfour}{\ensuremath{\fklab{4}}} 
\newcommand{\fklabfive}{\ensuremath{\fklab{5}}} 
\newcommand{\fklabsix}{\ensuremath{\fklab{6}}} 
\newcommand{\fklabseven}{\ensuremath{\fklab{7}}} 
\newcommand{\fklabeight}{\ensuremath{\fklab{8}}} 
\newcommand{\fklabnine}{\ensuremath{\fklab{9}}} 
\newcommand{\fklabzero}{\ensuremath{\fklab{0}}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%A shorthand for discourse relations%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\dr}[3]{\ensuremath{#1(\pi_{#2}, \pi_{#3})}}

%%%%%%%%%%%
%Variables%
%%%%%%%%%%%
\newcommand{\varsub}[2]{\ensuremath{#1_{#2}}}
\newcommand{\varsup}[2]{\ensuremath{#1^{#2}}}

%%%%%%%%%%
%\(P)SDRS%
%%%%%%%%%%

\newcommand{\SDRS}[3][none]
{\ifthenelse{\equal{#1}{none}}{\ensuremath
    {\hspace{2ex}
    \begin{array}{|l|}
    \hline
    ~ \vspace{-2.5ex}\\
    #2\\
    ~ \vspace{-2.5ex} \\
    \hline
    \\
    #3\hspace{5pt}\\
    \\    
    \hline
    \end{array}
    }
}
{\ensuremath
    {#1: \hspace{-.5ex}
    \begin{array}{|l|}
    \hline
    ~ \vspace{-2.5ex}\\
    #2\\
    ~ \vspace{-2.5ex} \\
    \hline
    \\
    #3\hspace{5pt}\\
    \\    
    \hline
    \end{array}
    }}
}

%Presupposed versions
\newcommand{\PSDRS}[3][none]{\ifthenelse{\equal{#1}{none}}{\ensuremath{\partial\left(\; \hspace{-2ex}\SDRS{#2}{#3}\; \right)}}{\ensuremath{#1: \partial\left(\; \SDRS{#2}{#3}\; \right)}}}
\newcommand{\pres}[1]{\ensuremath{\partial(#1)}}

%%%%%%%
%Trees%
%%%%%%%
\newcommand{\sdrtree}[1]{\Treek[1]{2}{#1}}
\newcommand{\LAB}[1]{\K{ #1}}
\newcommand{\cons}[1][d]{\Bk{.5}{-2}{#1}}
\newcommand{\consl}{\Bk{1}{-2}{dl}}
\newcommand{\consr}{\Bk{1}{-2}{dr}}
\newcommand{\srel}[2][d]{\ARk{.5}{-2}{#1}^{$#2$}}
\newcommand{\srell}[1]{\ARk{1}{-2}{dl}_{$#1$}}
\newcommand{\srelr}[1]{\ARk{1}{-2}{dr}^{$#1$}}
\newcommand{\crel}[2][rr]{\GBkk{3,2.5}{-1.7,-3.5}{#1}{->}_{$#2$}}

%%%%%%%%%
%Symbols%
%%%%%%%%%
\newcommand{\intens}[1]{\ensuremath{^{\wedge}#1}}
\newcommand{\extens}[1]{\ensuremath{^{\vee}#1}}
\newcommand{\true}[1]{\ensuremath{\delta#1}}
\newcommand{\necess}[2]{\ensuremath{[#1]#2}}
\newcommand{\possib}[2]{\ensuremath{\langle #1\rangle #2}}
\newcommand{\append}[2]{\ensuremath{#1^{\cap}#2}}
\newcommand{\summary}{\ensuremath{\sqcap}}
\newcommand{\merging}{\ensuremath{\sqcup}}
\newcommand{\aflast}{\ensuremath{\langle A, \mathcal{F}, LAST\rangle}}
\newcommand{\topic}{\ensuremath{\Downarrow}}
\newcommand{\believes}[2][]{\ifthenelse{\equal{#1}{}}{\ensuremath{\mathcal{B}_{#2}}}{\ensuremath{\mathcal{B}_{#2}(#1)}}}
\newcommand{\intends}[2][]{\ifthenelse{\equal{#1}{}}{\ensuremath{\mathcal{I}_{#2}}}{\ensuremath{\mathcal{I}_{#2}(#1)}}}
\newcommand{\extends}{\ensuremath{\subseteq}}
\newcommand{\Lbracket}{[\hspace{-.4ex}[}
\newcommand{\Rbracket}{]\hspace{-.4ex}]}
\newcommand{\ccp}[4][]{\ensuremath{(#2)\Lbracket #3\Rbracket_{#1}(#4)}}
\newcommand{\nmentp}[1][]{\ensuremath{{|\hspace{-4.8pt}\sim}_{#1}}}
\newcommand{\nmentm}[1][]{\ensuremath{{|\hspace{-5pt}\approx}_{#1}}}
\newcommand{\entm}[1][]{\ensuremath{\models_{#1}}}
\newcommand{\entp}[1][]{\ensuremath{\vdash_{#1}}}
\newcommand{\Nnmentp}[1][]{\ensuremath{{|\hspace{-4.8pt}\not\sim}_{#1}}}
\newcommand{\Nnmentm}[1][]{\ensuremath{{|\hspace{-5pt}\not\approx}_{#1}}}
\newcommand{\Nentm}[1][]{\ensuremath{\not\models_{#1}}}
\newcommand{\Nentp}[1][]{\ensuremath{\not\vdash_{#1}}}
\newcommand{\sarg}[2]{\scshape sarg\upshape\ensuremath{(#1, #2)}}
\newcommand{\outscopes}{\ensuremath{\succ}}
\newcommand{\tempprec}{\ensuremath{\prec}}
\newcommand{\lulf}{\ensuremath{\varsub{\mathcal{L}}{ulf}}}
\newcommand{\trfunc}{\ensuremath{\nu}}
\newcommand{\resolves}{\ensuremath{\leadsto}}
\newcommand{\kstar}{\ensuremath{K^{+}}}
\newcommand{\thext}{\ensuremath{T^{\rightarrow}}}
\newcommand{\update}{\emph{update}\textsubscript{\scshape sdrt}}
\newcommand{\bestupdate}{\emph{Best-update}\textsubscript{\scshape sdrt}}
\newcommand{\downdate}{\ensuremath{\downarrow}}
\newcommand{\revision}{\ensuremath{\otimes}}
\newcommand{\ulf}{\ensuremath{\mathcal{K}}}
\newcommand{\access}{\ensuremath{\leq}}
\newcommand{\efdeq}{\ensuremath{\coloneq}}
\newcommand{\union}[1]{\ensuremath{\bigcup\limits_{#1}}}
\newcommand{\subtype}{\ensuremath{\sqsubseteq}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Here is the code of the subscript.sty package used for \update, along with the license%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% subscript.sty
%
% Copyright 1999 Robin Fairbairns
%
% this fragment is distributed under the conditions of the LaTeX
% Project Public Licence -- see lppl.txt in the LaTeX distribution
%
% this fragment provides a command \textsubscript, which is
% shamelessly copied from the command \textsuperscript that's part of
% LaTeX
%
% the fragment may be used as a package in its own right, if so
% needed.

\DeclareRobustCommand*\textsubscript[1]{%
  \@textsubscript{\selectfont#1}}
\def\@textsubscript#1{%
  {\m@th\ensuremath{_{\mbox{\fontsize\sf@size\z@#1}}}}}