# odd (?) spacing for logic notation

I write code:

$\sim(p\land q)\iff (\sim p\lor \sim q)$


and my output is like this:

As you can see, the \land symbol is nice in between 'p' and 'q', but the \lor symbol stick somehow to the left, to the 'p' without space. I could manually "fix" it with forcefully added space, but I don't understand why the left and right side would have different output. Why in one example it stick to letter before, in second not. Am I doing something wrong? Is there better way to fix it without adding \; in math mode?

• \sim is set up as a binary relation (like =) and you are using it as a prefix negation so you want to define a command that is equivalent to \mathord{\sim} (or equivalently just {\sim} (or perhaps \mathop) – David Carlisle Sep 29 '19 at 12:14
• The negation symbol intended to go with \lor and \land is \lnot, though of course you could decide you don't like how it looks. I wonder if in that case it would not be more idiomatic to redefine \lnot to have the appearance of \mathord{\sim}. – Misha Lavrov Sep 29 '19 at 21:04

\sim is set up as an infix relation so has the spacing of = which affects the spacing of adjacent binary operators, you want a \mathord (like a letter) or perhaps better \mathop (like \log) symbol as you are using this as a prefix operator.

\documentclass{article}

\begin{document}

$\sim(p\land q)\iff (\sim p\lor \sim q)$

${\sim}(p\land q)\iff ({\sim} p\lor {\sim} q)$

$\mathop{{}\sim}(p\land q)\iff (\mathop{{}\sim} p\lor \mathop{{}\sim} q)$

\end{document}