% \iffalse meta-comment
%
%
% This file may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.2 of this license or (at your option) any later version.
% The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
% and version 1.2 or later is part of all distributions of LaTeX version 1999/12/01 or later.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{turnstile-en.dtx}
%</driver>
%<package>\ProvidesPackage{turnstile}
%<*package>
    [2007/06/23 v1.0 turnstile file]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{ifthen}
\EnableCrossrefs
\CodelineIndex
\RecordChanges

\begin{document}
  \DocInput{turnstile-en.dtx}
  \PrintChanges
  \PrintIndex
\end{document}

%</driver>
% \fi
%
% \CheckSum{0}
%
%
% \changes{v1.0}{2007/06/23}{Initial version}
%
% \GetFileInfo{turnstile-en.dtx}
%
% \DoNotIndex{\if}
%
%
% \title{The \textsf{turnstile} package}
% \author{%
%  Arthur Buchsbaum\\
%  Francisco Reinaldo\\
%  \texttt{arthur@inf.ufsc.br, reinaldo.opus@gmail.com}}
% \date{\filedate\qquad\fileversion}
%
% \maketitle
%
% \begin{abstract}
% \noindent\textsf{turnstile} is a class based on \texttt{article.cls}, to be used for typesetting articles. Among other uses, the turnstile sign is used for denoting a consequence relation,  related to a given logic, between collections of formulas and formulas. Many logicians have complaint the lack of a \LaTeX\ routine for issuing turnstile signs, in any of the forms it could arise.
% \end{abstract}
%
% \tableofcontents
%
% \section{Introduction}
%
% In this package some routines are provided for issuing the turnstile sign, nearly in all ways it could be utilized, from syntactical consequence to semantical consequence and forcing. A turnstile sign is usually composed of two lines, a horizontal one and a vertical one. Each of them can be single, double or triple, depending on the type of consequence relation someone wants to represent.
%
% \section{User macros}
%
% Below the turnstile sign it is usually put the name of a given logic, whereas, sometimes, some complementary information above it. The size of the expressions located below or above the turnstile sign determines its width and, of course, the length of its horizontal line.
%
% \section{Code}
%
% Identidication of the package and use of the package \textsf{ifthen}.
%    \begin{macrocode}
\RequirePackage{ifthen}
%    \end{macrocode}
%
% \subsection{Macro: $\backslash$newlength}
%
% \DescribeMacro{\newlength} The macro |\newlength{|\meta{command}|}| can be used to specify the space parameter.
%
% \subsubsection{Internal Commands}
%
% \DescribeMacro{\firstwidth} The width of the expression to be located below the turnstile sign.
%    \begin{macrocode}
\newlength{\firstwidth}
%    \end{macrocode}
%
% \DescribeMacro{\secondwidth} The width of the expression to be located above the turnstile sign.
%    \begin{macrocode}
\newlength{\secondwidth}
%    \end{macrocode}

% \DescribeMacro{\extrawidth} The extra length of the horizontal line to be put before and after the greatest expression.
%    \begin{macrocode}
\newlength{\extrawidth}
%    \end{macrocode}

% \DescribeMacro{\leasturnstilewidth} The length of the horizontal line when no expression is put below and above.
%    \begin{macrocode}
\newlength{\leasturnstilewidth}
%    \end{macrocode}

% \DescribeMacro{\turnstilewidth} The length of the horizontal line.
%    \begin{macrocode}
\newlength{\turnstilewidth}
%    \end{macrocode}

% \DescribeMacro{\turnstileheight}  The length of the vertical line.
%    \begin{macrocode}
\newlength{\turnstileheight}
%    \end{macrocode}

% \DescribeMacro{\dashthickness} The thickness of the dashes used to compose the lines of the turnstile sign.
%    \begin{macrocode}
\newlength{\dashthickness}
%    \end{macrocode}

% \DescribeMacro{\ddashthickness} The standard distance between two dashes in a double or triple line of the turnstile sign.
%    \begin{macrocode}
\newlength{\ddashthickness}
%    \end{macrocode}


% \DescribeMacro{\raiseup} The vertical distance for lifting up the expression to be located above the turnstile sign.
%    \begin{macrocode}
\newlength{\raiseup}
%    \end{macrocode}

% \DescribeMacro{\raisedown} The vertical distance for lifting down the expression to be located below the turnstile sign.
%    \begin{macrocode}
\newlength{\raisedown}
%    \end{macrocode}

% \DescribeMacro{\tinyverdistance} The very short distance for lifting up or down an expression, depending if the horizontal line is single, double or triple, and from the standard thickness of the dash used for composition of any line of the turnstile sign.
%    \begin{macrocode}
\newlength{\tinyverdistance}
%    \end{macrocode}

% \DescribeMacro{\verdistance} The distance between the expression located above or below and the horizontal line.
%    \begin{macrocode}
\newlength{\verdistance}
%    \end{macrocode}

% \DescribeMacro{\lift} The vertical distance in which the final composition of the turnstile will be lift.
%    \begin{macrocode}
\newlength{\lift}
%    \end{macrocode}

% \DescribeMacro{\lengthvar}  It is only an auxiliary length variable.
%    \begin{macrocode}
\newlength{\lengthvar}
%    \end{macrocode}
%
% \subsection{Macro: $\backslash$newsavebox}
%
% \DescribeMacro{\newsavebox} |\newsavebox{|\meta{command}|}| is used to store any expression which composes the turnstile sign, including the complete turnstile sign.
%
% \subsubsection{Internal Commands}
%
% \DescribeMacro{\first} It contains the expression to be located below the turnstile sign.
%    \begin{macrocode}
\newsavebox{\first}
%    \end{macrocode}

% \DescribeMacro{\second} It contains the expression to be located above the turnstile sign.
%    \begin{macrocode}
\newsavebox{\second}
%    \end{macrocode}

% \DescribeMacro{\turnstilebox}  It contains the final composition of the turnstile sign, before eventually adding horizontal spaces before and after it, depending if it will be used as a binary relation.
%    \begin{macrocode}
\newsavebox{\turnstilebox}
%    \end{macrocode}
%
% \subsection{Macro: $\backslash$makever}
%
% \DescribeMacro{\makever} |\makever{|\meta{command}|}[|\meta{params}|]| |\makever| is a routine used by |\turnstile| command, which composes a vertical line for the turnstile sign (some turnstile signs can have two vertical lines: one before and one after the horizontal line). It uses four arguments. The first one informs the kind of the line, ``n'' for no dash, ``s'' for a single line, ``d'' for a double line, and ``t'' for a triple line; the second one informs the thickness of a dash; the third one the height of the vertical line; and finally the fourth one the distance between two adjacent vertical dashes. Of course, |\makever| draws nothing if the first argument equals ``n''.
%
%    \begin{macrocode}
\newcommand{\makever}[4]
           {\ifthenelse{\equal{#1}{s}}{\rule[-0.5#3]{#2}{#3}}{}
            \ifthenelse{\equal{#1}{d}}{\rule[-0.5#3]{#2}{#3}
                                       \hspace{#4}
                                       \rule[-0.5#3]{#2}{#3}}{}
            \ifthenelse{\equal{#1}{t}}{\rule[-0.5#3]{#2}{#3}
                                       \hspace{#4}
                                       \rule[-0.5#3]{#2}{#3}
                                       \hspace{#4}
                                       \rule[-0.5#3]{#2}{#3}}{}}
%    \end{macrocode}
%
% \subsection{Macro: $\backslash$makehor}
%
% \DescribeMacro{\makehor} |\makehor{|\meta{command}|}[|\meta{params}|]| |\makehor| is also a routine used by |\turnstile| command, which composes the horizontal line of the turnstile sign. It uses four arguments. The first one informs the kind of the line, ``n'' for no dash, ``s'' for a single line, ``d'' for a double line, and ``t'' for a triple line; the second one informs the thickness of a dash; the third one the length of the horizontal line, and finally the fourth one the distance between two adjacent horizontal dashes. |\makehor| only advances an horizontal space of |\turnstilewidth| if the first argument equals ``n'', for at least providing space for the two expressions which must be located below and above the turnstile sign.
%
%    \begin{macrocode}
\newcommand{\makehor}[4]
    {\ifthenelse{\equal{#1}{n}}{\hspace{#3}}{}
     \ifthenelse{\equal{#1}{s}}{\rule[-0.5#2]{#3}{#2}}{}
     \ifthenelse{\equal{#1}{d}}{\setlength{\lengthvar}{#2}
            \addtolength{\lengthvar}{0.5#4}
            \rule[-\lengthvar]{#3}{#2}
            \hspace{-#3}
            \rule[0.5#4]{#3}{#2}}{}
    \ifthenelse{\equal{#1}{t}}{\setlength{\lengthvar}{1.5#2}
        \addtolength{\lengthvar}{#4}
        \rule[-\lengthvar]{#3}{#2}
        \hspace{-#3}
        \rule[-0.5#2]{#3}{#2}
        \hspace{-#3}
        \setlength{\lengthvar}{0.5#2}
        \addtolength{\lengthvar}{#4}
        \rule[\lengthvar]{#3}{#2}}{}}
%    \end{macrocode}
%
% \subsection{Macro: $\backslash$turnstile}
%
% \DescribeMacro{\turnstile} |\turnstile{|\meta{6}|}[|\meta{params}|]| |\turnstile| draws a turnstile sign together with its accompanying expressions.
%
%The first argument is optional, it informs the size by which the internal expressions must be displayed, ``d'' for displayed formulas, ``t'' for text formulas, ``s'' for first subscript or superscript formulas, and ``ss'' for later subscript or superscript formulas. The default value is ``s''. The result of applying ``t'' or ``d'' is the same, except if there is a mathematical sign in the fourth or fifth argument issued in distinct ways, depending if it is inside text formulas or displayed formulas.
%
%The second argument informs the kind of the vertical line which precedes the horizontal line, ``s'' for a single one, ``d'' for a double one, ``t'' for a triple one and ``n'' when no line is drawn before the horizontal line.
%
% The third argument provides the kind of the horizontal line, in an analogous way.
%
%The fourth and fifth arguments provide respectively the expressions to be placed below and above the turnstile sign, whereon both these expressions are converted to the size specified by the first argument.
%
%Finally, the sixth argument informs the kind of the closing vertical line, if it exists, also in an analogous way that it is done for the second and third arguments.
%
%    \begin{macrocode}
\newcommand{\turnstile}[6][s]
    {\ifthenelse{\equal{#1}{d}}
        {\sbox{\first}{$\displaystyle{#4}$}
        \sbox{\second}{$\displaystyle{#5}$}}{}
    \ifthenelse{\equal{#1}{t}}
        {\sbox{\first}{$\textstyle{#4}$}
        \sbox{\second}{$\textstyle{#5}$}}{}
    \ifthenelse{\equal{#1}{s}}
        {\sbox{\first}{$\scriptstyle{#4}$}
        \sbox{\second}{$\scriptstyle{#5}$}}{}
    \ifthenelse{\equal{#1}{ss}}
        {\sbox{\first}{$\scriptscriptstyle{#4}$}
        \sbox{\second}{$\scriptscriptstyle{#5}$}}{}
    \setlength{\dashthickness}{0.111ex}
    \setlength{\ddashthickness}{0.35ex}
    \setlength{\leasturnstilewidth}{0.8em}
    \setlength{\extrawidth}{0.2em}
    \ifthenelse{%
      \equal{#3}{n}}{\setlength{\tinyverdistance}{0ex}}{}
    \ifthenelse{%
      \equal{#3}{s}}{\setlength{\tinyverdistance}{0.5\dashthickness}}{}
    \ifthenelse{%
      \equal{#3}{d}}{\setlength{\tinyverdistance}{0.5\ddashthickness}
        \addtolength{\tinyverdistance}{\dashthickness}}{}
    \ifthenelse{%
      \equal{#3}{t}}{\setlength{\tinyverdistance}{1.5\dashthickness}
        \addtolength{\tinyverdistance}{\ddashthickness}}{}
        \setlength{\verdistance}{0.4ex}
        \settoheight{\lengthvar}{\usebox{\first}}
        \setlength{\raisedown}{-\lengthvar}
        \addtolength{\raisedown}{-\tinyverdistance}
        \addtolength{\raisedown}{-\verdistance}
        \settodepth{\raiseup}{\usebox{\second}}
        \addtolength{\raiseup}{\tinyverdistance}
        \addtolength{\raiseup}{\verdistance}
        \setlength{\lift}{0.8ex}
        \settowidth{\firstwidth}{\usebox{\first}}
        \settowidth{\secondwidth}{\usebox{\second}}
        \ifthenelse{\lengthtest{\firstwidth = 0ex}
            \and
            \lengthtest{\secondwidth = 0ex}}
                {\setlength{\turnstilewidth}{\leasturnstilewidth}}
                {\setlength{\turnstilewidth}{2\extrawidth}
        \ifthenelse{\lengthtest{\firstwidth < \secondwidth}}
            {\addtolength{\turnstilewidth}{\secondwidth}}
            {\addtolength{\turnstilewidth}{\firstwidth}}}
    \setlength{\turnstileheight}{3ex}
    \sbox{\turnstilebox}
    {\raisebox{\lift}{\ensuremath{
        \makever{#2}{\dashthickness}{\turnstileheight}{\ddashthickness}
        \makehor{#3}{\dashthickness}{\turnstilewidth}{\ddashthickness}
        \hspace{-\turnstilewidth}
        \raisebox{\raisedown}
        {\makebox[\turnstilewidth]{\usebox{\first}}}
            \hspace{-\turnstilewidth}
            \raisebox{\raiseup}
            {\makebox[\turnstilewidth]{\usebox{\second}}}
        \makever{#6}{\dashthickness}{\turnstileheight}{\ddashthickness}}}}
        \mathrel{\usebox{\turnstilebox}}}
%    \end{macrocode}
%
% \subsection{Macro: $\backslash$??tstile , $\backslash$???tstile}
%
% \DescribeMacro{\??tstile}
% \DescribeMacro{\???tstile}
% Next some more new commands are provided for getting easier the calling of |\turnstile| command. Before the string ``tstile'' of any of these commands it can be placed a string with two |\??| or three |\???| letters. These letters indicate the kind of the lines to be successively drawn; they can be ``n'', ``s'', ``d'' or ``t''. The letter ``n'' informs that the line is empty, the letter ``s'' that the line is single, the letter ``d'' that the line is double, and finally ``t'' indicates that the line is triple.
%
%The corresponding commands for the two lettered strings provide the most common turnstile signs, in which is not drawn a second vertical line following the horizontal line. The first letter of these strings indicates the kind of the vertical line and the second the kind of the horizontal line to be drawn after the vertical line. The three lettered strings can contain any of the letters ``n'', ``s'', ``d'' and ``t'', with the restriction that the last letter must be distinct from ``n'', because the case in which the third line is empty is already dealt by the commands with two lettered strings preceding ``tstile''. The first letter informs the kind of the first vertical line, the second the kind of the horizontal line, and finally the third letter the kind of the second vertical line. Below there are the commands providing turnstile signs with a vertical line followed by a horizontal line, whereon any of these two lines can be empty, and the commands providing turnstile signs with a second vertical line, besides the first one, whereon the first two lines can be empty, but the second vertical line is not empty.
%
%All these commands have three arguments, whereon the first one is optional.
%
%The first argument is optional, it informs the size by which the internal expressions must be displayed, ``d'' for displayed formulas, ``t'' for text formulas, ``s'' for first subscript or superscript formulas, and ``ss'' for later subscript or superscript formulas. The default value is ``s''. The result of applying ``t'' or ``d'' is the same, except if there is a mathematical sign in the second or third argument issued in distinct ways, depending if it is inside text formulas or displayed formulas.
%
%The second and third arguments provide respectively the expressions to be placed below and above the turnstile sign, whereon both these expressions are converted to the size specified by the first argument.
%
%    \begin{macrocode}
\newcommand{\nntstile}[3][s]{\turnstile[#1]{n}{n}{#2}{#3}{n}}
\newcommand{\nststile}[3][s]{\turnstile[#1]{n}{s}{#2}{#3}{n}}
\newcommand{\ndtstile}[3][s]{\turnstile[#1]{n}{d}{#2}{#3}{n}}
\newcommand{\nttstile}[3][s]{\turnstile[#1]{n}{t}{#2}{#3}{n}}

\newcommand{\sntstile}[3][s]{\turnstile[#1]{s}{n}{#2}{#3}{n}}
\newcommand{\sststile}[3][s]{\turnstile[#1]{s}{s}{#2}{#3}{n}}
\newcommand{\sdtstile}[3][s]{\turnstile[#1]{s}{d}{#2}{#3}{n}}
\newcommand{\sttstile}[3][s]{\turnstile[#1]{s}{t}{#2}{#3}{n}}

\newcommand{\dntstile}[3][s]{\turnstile[#1]{d}{n}{#2}{#3}{n}}
\newcommand{\dststile}[3][s]{\turnstile[#1]{d}{s}{#2}{#3}{n}}
\newcommand{\ddtstile}[3][s]{\turnstile[#1]{d}{d}{#2}{#3}{n}}
\newcommand{\dttstile}[3][s]{\turnstile[#1]{d}{t}{#2}{#3}{n}}

\newcommand{\tntstile}[3][s]{\turnstile[#1]{t}{n}{#2}{#3}{n}}
\newcommand{\tststile}[3][s]{\turnstile[#1]{t}{s}{#2}{#3}{n}}
\newcommand{\tdtstile}[3][s]{\turnstile[#1]{t}{d}{#2}{#3}{n}}
\newcommand{\tttstile}[3][s]{\turnstile[#1]{t}{t}{#2}{#3}{n}}

\newcommand{\nnststile}[3][s]{\turnstile[#1]{n}{n}{#2}{#3}{s}}
\newcommand{\nsststile}[3][s]{\turnstile[#1]{n}{s}{#2}{#3}{s}}
\newcommand{\ndststile}[3][s]{\turnstile[#1]{n}{d}{#2}{#3}{s}}
\newcommand{\ntststile}[3][s]{\turnstile[#1]{n}{t}{#2}{#3}{s}}

\newcommand{\nndtstile}[3][s]{\turnstile[#1]{n}{n}{#2}{#3}{d}}
\newcommand{\nsdtstile}[3][s]{\turnstile[#1]{n}{s}{#2}{#3}{d}}
\newcommand{\nddtstile}[3][s]{\turnstile[#1]{n}{d}{#2}{#3}{d}}
\newcommand{\ntdtstile}[3][s]{\turnstile[#1]{n}{t}{#2}{#3}{d}}

\newcommand{\nnttstile}[3][s]{\turnstile[#1]{n}{n}{#2}{#3}{t}}
\newcommand{\nsttstile}[3][s]{\turnstile[#1]{n}{s}{#2}{#3}{t}}
\newcommand{\ndttstile}[3][s]{\turnstile[#1]{n}{d}{#2}{#3}{t}}
\newcommand{\ntttstile}[3][s]{\turnstile[#1]{n}{t}{#2}{#3}{t}}

\newcommand{\snststile}[3][s]{\turnstile[#1]{s}{n}{#2}{#3}{s}}
\newcommand{\ssststile}[3][s]{\turnstile[#1]{s}{s}{#2}{#3}{s}}
\newcommand{\sdststile}[3][s]{\turnstile[#1]{s}{d}{#2}{#3}{s}}
\newcommand{\stststile}[3][s]{\turnstile[#1]{s}{t}{#2}{#3}{s}}

\newcommand{\sndtstile}[3][s]{\turnstile[#1]{s}{n}{#2}{#3}{d}}
\newcommand{\ssdtstile}[3][s]{\turnstile[#1]{s}{s}{#2}{#3}{d}}
\newcommand{\sddtstile}[3][s]{\turnstile[#1]{s}{d}{#2}{#3}{d}}
\newcommand{\stdtstile}[3][s]{\turnstile[#1]{s}{t}{#2}{#3}{d}}

\newcommand{\snttstile}[3][s]{\turnstile[#1]{s}{n}{#2}{#3}{t}}
\newcommand{\ssttstile}[3][s]{\turnstile[#1]{s}{s}{#2}{#3}{t}}
\newcommand{\sdttstile}[3][s]{\turnstile[#1]{s}{d}{#2}{#3}{t}}
\newcommand{\stttstile}[3][s]{\turnstile[#1]{s}{t}{#2}{#3}{t}}

\newcommand{\dnststile}[3][s]{\turnstile[#1]{d}{n}{#2}{#3}{s}}
\newcommand{\dsststile}[3][s]{\turnstile[#1]{d}{s}{#2}{#3}{s}}
\newcommand{\ddststile}[3][s]{\turnstile[#1]{d}{d}{#2}{#3}{s}}
\newcommand{\dtststile}[3][s]{\turnstile[#1]{d}{t}{#2}{#3}{s}}

\newcommand{\dndtstile}[3][s]{\turnstile[#1]{d}{n}{#2}{#3}{d}}
\newcommand{\dsdtstile}[3][s]{\turnstile[#1]{d}{s}{#2}{#3}{d}}
\newcommand{\dddtstile}[3][s]{\turnstile[#1]{d}{d}{#2}{#3}{d}}
\newcommand{\dtdtstile}[3][s]{\turnstile[#1]{d}{t}{#2}{#3}{d}}

\newcommand{\dnttstile}[3][s]{\turnstile[#1]{d}{n}{#2}{#3}{t}}
\newcommand{\dsttstile}[3][s]{\turnstile[#1]{d}{s}{#2}{#3}{t}}
\newcommand{\ddttstile}[3][s]{\turnstile[#1]{d}{d}{#2}{#3}{t}}
\newcommand{\dtttstile}[3][s]{\turnstile[#1]{d}{t}{#2}{#3}{t}}

\newcommand{\tnststile}[3][s]{\turnstile[#1]{t}{n}{#2}{#3}{s}}
\newcommand{\tsststile}[3][s]{\turnstile[#1]{t}{s}{#2}{#3}{s}}
\newcommand{\tdststile}[3][s]{\turnstile[#1]{t}{d}{#2}{#3}{s}}
\newcommand{\ttststile}[3][s]{\turnstile[#1]{t}{t}{#2}{#3}{s}}

\newcommand{\tndtstile}[3][s]{\turnstile[#1]{t}{n}{#2}{#3}{d}}
\newcommand{\tsdtstile}[3][s]{\turnstile[#1]{t}{s}{#2}{#3}{d}}
\newcommand{\tddtstile}[3][s]{\turnstile[#1]{t}{d}{#2}{#3}{d}}
\newcommand{\ttdtstile}[3][s]{\turnstile[#1]{t}{t}{#2}{#3}{d}}

\newcommand{\tnttstile}[3][s]{\turnstile[#1]{t}{n}{#2}{#3}{t}}
\newcommand{\tsttstile}[3][s]{\turnstile[#1]{t}{s}{#2}{#3}{t}}
\newcommand{\tdttstile}[3][s]{\turnstile[#1]{t}{d}{#2}{#3}{t}}
\newcommand{\ttttstile}[3][s]{\turnstile[#1]{t}{t}{#2}{#3}{t}}
%    \end{macrocode}
%
% Well, we think you took everything. Enjoy using \texttt{turnstile}!
%
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \Finale
\endinput



