# How to typeset right and left logical projection binary operations in LaTeX?

In his section on Boolean Basics in The Art of Computer Programming Volume 4A, Pre-Fascicle 0B, Donald Knuth introduces notation for right and left logical projections, which appropriately look like the English letters L and R translated into logical connectives, found in Table 1 of page 3 (PDF page 7). This is precisely the notation I was looking for in this StackExchange question.

However, I'm not sure what command is used to output these symbols in LaTeX, and I can't located them in the Comprehensive LaTeX Symbols List either. Does anyone know how Donald Knuth came up with these symbols and how to typeset them in LaTeX?

Extending my first approach at Identifying Mystery "R" Symbol, to include a \KnL of the same height and width as \KnR. EDITED to tweak the quality of the symbols under large magnification.

Based on OP comments, EDITED to adjust size to the height of an "i" using \scalerel*{item to scale}{item of target size}; also enclosed the solution in a \mathbin to address spacing considerations. Note that the target size can be changed by the user to something other than an "i", so as to suit their sensibilities.

\documentclass{article}
\usepackage{stackengine,scalerel}
\usepackage{graphicx}
\def\KnRgap{\rule{1.63ex}{0ex}\rule[-.3ex]{0ex}{1.8ex}}
\def\KnR{\kern1pt\mathbin{\scalerel*{%
\stackinset{r}{0pt}{b}{0pt}{\rotatebox{53}{\rule{.07ex}{1.29ex}}}{%
\stackinset{l}{0pt}{t}{.02ex}{\rule{.07ex}{1.8ex}}{%
\stackinset{l}{.02ex}{t}{.02ex}{\rule{1ex}{.07ex}}{%
\stackinset{r}{0pt}{t}{.02ex}{\scalebox{.76}{$\supset\mkern -2mu$}}{%
\KnRgap%
}}}}}{i}}\kern1pt%
}
\def\KnL{\kern1pt\mathbin{\scalerel*{%
\stackinset{l}{0pt}{t}{.02ex}{\rule{.07ex}{1.78ex}}{%
\stackinset{l}{.02ex}{b}{0pt}{\rule{1.53ex}{.07ex}}{%
\KnRgap%
}}}{i}}\kern1pt%
}
\begin{document}
$\mathcal{P} \KnR \mathcal{Q}$~~Right projection; second dictator%

$\mathcal{P} \KnL \mathcal{Q}$~~Left projection
\end{document}


One advantage of using the \scalerel approach is that it automatically accounts for the math style (shown here in \textstyle, \scriptstyle, and \scriptscriptstyle):

And extending the second approach (likewise EDITED to address the size issue) from that answer:

\documentclass{article}
\DeclareFontFamily{U}{matha}{\hyphenchar\font45}
\DeclareFontShape{U}{matha}{m}{n}{
<5> <6> <7> <8> <9> <10> gen * matha
<10.95> matha10 <12> <14.4> <17.28> <20.74> <24.88> matha12
}{}
\DeclareSymbolFont{matha}{U}{matha}{m}{n}
\DeclareMathSymbol{\varcup}{3}{matha}{"59}
\usepackage{stackengine,scalerel}
\usepackage{graphicx}
\def\KnRgap{\rule{1.45ex}{0ex}\rule[-.3ex]{0ex}{1.8ex}}
\def\KnR{\kern1pt\mathbin{\scalerel*{%
\stackinset{r}{0pt}{b}{0pt}{\rotatebox{45}{\rule{.08ex}{1.14ex}}}{%
\stackinset{l}{0pt}{t}{.02ex}{\rule{.08ex}{1.8ex}}{%
\stackinset{l}{.02ex}{t}{0.0pt}{\rule{.7ex}{.08ex}}{%
\stackinset{r}{0pt}{t}{0.0ex}{\scalebox{.81}{%
\rotatebox{90}{$\varcup\mkern -2mu$}}}{%
\KnRgap%
}}}}}{i}}\kern1pt%
}
\def\KnL{\kern1pt\mathbin{\scalerel*{%
\stackinset{l}{0pt}{t}{.02ex}{\rule{.08ex}{1.78ex}}{%
\stackinset{l}{}{b}{}{\rule{1.4ex}{.08ex}}{%
{%
\KnRgap%
}}}}{i}}\kern1pt%
}
\begin{document}
$\mathcal{P} \KnR \mathcal{Q}$~~Right projection; second dictator%

$\mathcal{P} \KnL \mathcal{Q}$~~Left projection
\end{document}


• Steven, thanks so much for this! However it might be displaying a little bit larger than intended (Knuth's were the same size as the other logical symbols ∨ and ∧). What do you think? Here's an image of the output I'm getting: i.imgur.com/TIsJEOw.png – Mathemanic Sep 8 '15 at 4:40
• @EthanAlvaree I see your point. When I addressed it in the other question, there was no issue of "proper size" to address. Also, I'm guessing these should be surrounded with a \mathbin{} or \mathrel{}. Perhaps when I get a moment, I will try to merely scale them slightly smaller and repost. – Steven B. Segletes Sep 8 '15 at 9:51
• @EthanAlvaree Please see revision. – Steven B. Segletes Sep 8 '15 at 10:30
• It's perfect... Thank you Steven! Hopefully others searching for these symbols can find this StackExchange question and answer. – Mathemanic Sep 9 '15 at 23:23
• @EthanAlvaree You are most welcome. Glad to help. Best wishes. – Steven B. Segletes Sep 10 '15 at 0:54