How to define semantic logic “implies” and “not” operators for use in LyX

logiclyxmath-operatorsstacking-symbolssymbols

In Schechter's Classical and nonclassical logics, he distinguishes symbols at the semantic level, from those at the syntactic level, by encircling the operators. For example, formal logic uses "∧" (\wedge) for conjunction, while semantic logic uses an encircled version, which can be implemented by \owedge from the stmaryrd package:

owedge symbol

But semantic operators corresponding to implication ("→", \rightarrow) and negation ("¬", \neg) don't exist among the usual symbols. How can these be generated in such a way that they can be used from LyX?

Best Answer

Personally, I keep all of my math macros in a separate LyX file that I can then include from other LyX documents (via Insert > File > Child Document). The solution requires placing some of the LaTeX code in a LyX preamble (because LyX macros can't handle the \mathpalette macro's structure). So I also have a separate LaTeX file for the preamble code, which I can then \input{…} in the "LaTeX preamble" setting of both the child and parent LyX documents.

In math-macros-preamble.tex, I place:

\newcommand{\semanticlogic}[2]{\ooalign{$\m@th#1\ocircle$\cr\scalebox{0.9}[1]{$\m@th#1#2$}\cr}}

\newcommand{\encircled}[1]{\mathpalette\semanticlogic{#1}}

\semanticlogic is a macro that takes as its arguments (1) the style macro (provided by \mathpalette) and (2) the operator to be encircled. The \encircled macro wraps \mathpalette so that it's easy to use inside a LyX macro.

In math-macros.lyx, I add \input{math-macros-preamble} to its preamble, then define a macro from \newcommand{\oimplies}{\mathbin{\encircled{\shortrightarrow}}}, giving it a LyX representation like \mathbin{$\ocircle\shortrightarrow$} so that it looks nicer when inlined into the parent document. Similarly, I create \onot as \encircled{\mkern1mu \neg}.

In the parent document, where I use the logic operators, I also add \input{math-macros-preamble} to its preamble, and include math-macros.lyx as a child document.

example semantic relation with operators