\documentclass{article} \usepackage{setspace} \usepackage{anyfontsize} \usepackage{amssymb} \usepackage{mathtools} \usepackage[margin=1.45in]{geometry} \usepackage{microtype} \usepackage{fancyvrb} \usepackage{bussproofs} \usepackage[oxford]{logictools} \usepackage[svgnames]{xcolor} \usepackage{tabularx} \usepackage{nicematrix,tikz} \usetikzlibrary{patterns.meta, patterns, decorations.markings,fadings} \tikzset{->-/.style={decoration={ markings, mark=at position #1 with {\arrow[line width=1.25pt]{>}}},postaction={decorate}}} %----------------------------------------------------- \title{The logictools Package} \author{Miles Min Yin Cheang} %----------------------------------------------------- %\usepackage[bitstream-charter,expert]{mathdesign} \usepackage{XCharter} \SetMathAlphabet{\mathcal}{normal}{OMS}{cmsy}{m}{n} \usepackage{hyperref} \hypersetup{ colorlinks, citecolor=black, filecolor=black, linkcolor=black, urlcolor=black } % nice box \usepackage{dashbox} % margins \makeatletter \newcommand{\importantsymbol}{\color{DarkBlue}\mathbin{\mathpalette\make@circled!}} \newcommand{\make@circled}[2]{% \ooalign{$\m@th#1\smallbigcirc{#1}$\cr\hidewidth$\m@th#1#2$\hidewidth\cr}% } \newcommand{\smallbigcirc}[1]{% \hbox{\scalebox{1.5}{$\m@th#1\bigcirc$}}% } \renewcommand{\importantsymbol}{\fboxsep=1.5pt\fboxrule=1pt\color{DarkBlue}\dashbox[10pt][c]{\color{DarkBlue}\textbf{!}}} \makeatother \usepackage{marginnote} \reversemarginpar % \newcommand{\versionnum}{0.1.1.} \AtBeginShipoutNext{% \AtBeginShipoutUpperLeft{% \put(\dimexpr\paperwidth-1pt\relax,-9pt){\makebox[0pt][r]{\setlength{\fboxsep}{3pt}\framebox{\textbf{Version:} \versionnum}}}% }% } \newcommand{\OddPageContent} { } % Super easy proof annotations in the style that Volker likes, with good(ish) kerning. \newcommand{\andlabel}[1]{ \RightLabel{\scriptsize($\land$\hspace{1px}#1)} } \newcommand{\orlabel}[1]{ \RightLabel{\scriptsize($\lor\hspace{1px}\text{#1}$)} } \newcommand{\implieslabel}[1]{ \RightLabel{\scriptsize($\rightarrow$\hspace{0.5px}#1)} } \newcommand{\ifflabel}[1]{ \RightLabel{\scriptsize($\leftrightarrow$\hspace{0.5px}#1)} } \newcommand{\neglabel}[1]{ \RightLabel{\scriptsize($\neg$\hspace{0.5px}#1)} } \newcommand{\foralllabel}[1]{ \RightLabel{\scriptsize($\forall$\hspace{1px}#1)} } \newcommand{\existslabel}[1]{ \RightLabel{\scriptsize($\exists$\hspace{0.5px}#1)} } % Consistent naming scheme for logical operators \newcommand{\limplies}{\rightarrow} \newcommand{\liff}{\leftrightarrow} \makeatletter \def\shorteq{\@ltoolsshorteq} \makeatother \fboxsep=0pt \fboxrule=1sp \begin{document} \maketitle \setstretch{1.4} \tableofcontents \newpage \section{Purpose of this package} The star of the show here is the formallogic environment. Prior to the development of this environment, spending way too much time fiddling around with spacing commands was a familiar experience for every logician. Most of the spacing you need in a logical statement is context sensitive, so only so much can be done through basic macros. Furthermore, using too many macros destroys the readability of the code, and slows down writing to a crawl. In an effort to change this, I wrote an environment that both \emph{speeds up} writing formal logic (by offering shorter syntax) and improves the output considerably. The details of how this works will be presented in the upcoming sections. The default settings were made with \LaTeX's default math font in mind, with the intention that the user come up with a preset that matches their preferences. The options can be changed on the fly, so more than one preset can be used in different parts of the document. Other than this, the option `oxford' will load a few neat macros that might be of particular interest to those studying logic at the University of Oxford; they provide shortcuts to notations that are commonly used in the first-year courses. It is likely that this section of the package will be updated with more content as I go through my degree. \newpage \section{The formallogic environment} \subsection{Introduction} \DeclareQuantifier{e}{\exists}[0mu][1.9mu] \DeclareQuantifier{f}{\forall}[0mu][0mu] This interface, accessed through the environment named \verb|formallogic|, or the command \verb|\fmllgc{}|, helps to type formal logic in \LaTeX. Here is a demo\footnote{Zooming in is recommended.}: \logictoolsoptions{partype=single,italiccorrection=1mu, quantskip=5mu,lastquantskip=5mu} \begin{center} \begin{tabular}{c|c|c} Code: & Output: & Default \LaTeX: \\ \hline \verb!|forall, x ; exists, y| (Ryx)! & \fmllgc{|forall,x;exists,y| (Ryx)} & $\forall x \exists y (Ryx)$ \\ \verb!|f,x;e,y|(Ryx)! & \fmllgc{|f,x;e,y| (Ryx)} & $\forall x \exists y (Ryx)$ \\ \verb|((P \land Q) \liff R)| &\logictoolsoptions{partype=double,italiccorrection=2mu,quantskip=5mu,lastquantskip=5mu,parinnerpad=5mu,parvoffset=0.14ex} \fmllgc{((P \land Q) \liff R)} & $\llparenthesis \llparenthesis P\land Q \rrparenthesis \liff R\rrparenthesis$ \\ \verb|((P \land Q) \liff R)| & \logictoolsoptions{partype=single,italiccorrection=1mu,quantskip=5mu,lastquantskip=5mu,parinnerpad=2mu,parstackkern=-3mu, parvoffset=0.15ex} \fmllgc{((P \land Q) \liff R)} & $((P\land Q)\liff R)$ \\ \verb|((P \land Q) \liff R)| & \logictoolsoptions{partype=single,italiccorrection=1mu,quantskip=5mu,lastquantskip=5mu,parinnerpad=2mu,parstackkern=2mu, parvoffset=0.17ex} \fmllgc{((P \land Q) \liff R)} & $((P\land Q)\liff R)$ \end{tabular} \end{center} The first and foremost difference that can be observed is the readability of the code. Certainly where we wish to use $\llparenthesis\, \cdots\, \rrparenthesis$, the code for the default \LaTeX\ output looks like: \begin{center} \verb|$\llparenthesis\llparenthesis P\land Q\rrparenthesis\liff R\rrparenthesis$| \end{center} Which can be shortened with shortcut macros but is still essentially unreadable. The case is arguably even worse for quantifiers, where we need to achieve nice spacing: \begin{center} \verb|$\forall\:\! x\ \exists\, y \ \, (Ryx)$|\rlap{ \ \ {\scriptsize\raisebox{0.3ex}{(What a mess!)}}} $\to \forall\:\! x\ \exists\, y \ \, (Ryx)$ \mbox{}\clap{vs.}$\hphantom{\to{\kern2.5pt}}\fmllgc{|f,x;e,y|\,(Ryx)}$\rlap{\quad \scriptsize\raisebox{0.1ex}{(from formallogic)}} \end{center} In the table, \texttt{forall} and \texttt{exists} reference direct copies of \verb|\forall| and \verb|\exists|. Logictools declares these two quantifiers by default. They will inherit the ugly kerning present for these symbols in \LaTeX's default math font (see table row 1). Good math fonts will not have this bug, and so fixing it will not be necessary in either default \LaTeX\ or in formallogic. For the above we declared quantifiers\footnote{The next section covers quantifier declaration in detail} \texttt{f} and \texttt{e} with better spacing than the \LaTeX\ default (as seen in row 2). The resulting syntax is clearly superior to what can be achieved without this environment. Note that there are various user-defined parameters controlling the typesetting (e.g. spacing, kerning, parenthesis style); this is how the same code produces markedly different outputs. Furthermore, the user can customise some of the syntax (e.g. the names of quantifiers). This means that just a few lines of code suffice to set the style and syntax for an entire document. The benefits of this approach over manual typesetting should be obvious. More useful syntactic shortcuts may be found in the \hyperlink{subsubsection.2.3.2}{\textsc{other syntax}} section. The next section covers quantifiers in more detail (primarily, quantifier syntax and declaration). \subsection{Quantifier stacks} Quantifier stacks are a concept introduced for typesetting logical quantifiers: \begin{center} \fmllgc{|forall , x ;exists , y ;forall, x_1 ;exists, z\in \mathbb{R}|} \verb!| forall, x ; exists, y ; forall, x_1 ; exists, z\in\mathbb{R} |! \end{center} Quantifier stacks are used by the formallogic environment. They are delimited by `\texttt{|}'. A quantifier stack is made up of quantifiers, written in the form \verb|