51

When I work with quantifiers I noted that are very close to the other symbols and the result does not look good, for example

$\exists a\in\mathbb{R}\exists b\in\mathbb{R}\forall c\in\mathbb{R}\forall d\in\mathbb{R}$

Which is the proper form to write quantifiers?

  • 14
    There exist real scalars a,b for all real scalars c,d – percusse May 21 '13 at 18:56
  • 2
    I would recommend using $\exists a\in\mathbb{R}$, $\exists b\in\mathbb{R}$, $\forall c\in\mathbb{R}$, and $\forall b\in\mathbb{R}$, or perhaps $\exists a, b \in\mathbb{R}$, $\forall c, d \in\mathbb{R}$. – Peter Grill May 21 '13 at 19:02
  • 2
    @PeterGrill Breaking down (the beginning of) such a mathematical statement into multiple math-mode parts seems odd to me... – jub0bs May 21 '13 at 19:13
  • @Jubobs: I think it depends on what comes before and after. – Peter Grill May 21 '13 at 19:18
  • 1
    Sometimes even a space $\exists a\in\mathbb{R}\ \exists b\in\mathbb{R}$ can help. I agree with @percusse though. – marczellm May 21 '13 at 19:19
  • Apart from what others are answering. I personally think that the space AFTER the quantifiers is horrible. I usually add space \let\existstemp\exists \renewcommand*{\exists}{\existstemp\mkern1mu} (I don't exactly remember the space, I wrote the 1mu as an example). – Manuel May 21 '13 at 19:21
  • Like @percusse I'd recommend against using those symbols, especially in inline formulas. They hinder legibility and understanding. – egreg May 21 '13 at 19:21
  • @egreg In my opinion if they are part of a \displaymath, e.g. in definitions, I think is clearer (and easy to remember) to write the symbols. – Manuel May 21 '13 at 19:23
  • @Manuel I disagree: they're never clearer than words. However, I can stand seeing them (used sparingly), in displayed formulas. – egreg May 21 '13 at 19:25
  • @Manuel I mean quantifiers should have spaces before them. – Gaston Burrull May 21 '13 at 19:31
  • 1
    @percusse the problem is I can't always use the metalanguage working in logic. – Gaston Burrull May 21 '13 at 19:47
  • @GastónBurrull Okey, but I wrote an answer anyway. – Manuel May 21 '13 at 19:54
  • 2
    If you're working in Logic, then these symbols are part and parcel of what you need much like an integral since in analysis. – A.Ellett May 21 '13 at 21:02
  • 1
    @A.Ellett In logic this is much worse, at least I can probably describe in words the integral, but I can't logically define a formal language using the same "metalanguage" in the formal language since I need "metalanguage" to define formal language. Here you need the quantifier symbols inevitably. – Gaston Burrull May 21 '13 at 21:14
  • 1
    @GastónBurrull. I was rooting for. I am a former logician myself. – A.Ellett May 21 '13 at 21:35
  • @GastónBurrull It's formal logic's problem not the reader's. Formal language is for me an oxymoron no matter what the occasion is. – percusse May 21 '13 at 21:42
  • 1
    @percusse what are you saying? – Gaston Burrull May 21 '13 at 21:45
  • @GastónBurrull I mean if that's going to be read by humans, formal logic notation is for me not sensible. If it's for the proof machines then you don't need to typeset at all. But anyway that's just me. – percusse May 21 '13 at 21:51

6 Answers6

31

Simply make these characters what they should be: Operators. They aren't arithmetic operators but logical ones, but that doesn't make any difference here:

\documentclass{article}
\usepackage{amsmath,amssymb}
\DeclareMathOperator{\Exists}{\exists}
\DeclareMathOperator{\Forall}{\forall}
\begin{document}
$\Exists a\in\mathbb{R}\Exists b\in\mathbb{R}\Forall c\in\mathbb{R}\Forall d\in\mathbb{R}$

$\Exists a\in\mathbb{R}:\Exists b\in\mathbb{R}:\Forall c\in\mathbb{R}:\Forall d\in\mathbb{R}$

$\Exists a,b\in\mathbb{R}:\Forall c,d\in\mathbb{R}$
\end{document}

Three versions with <code>\DeclareMathOperator</code>

Additionally, I would add a colon which stands for "such that".

Last but not least, it's equivalent but easier to grasp, if the both "exists" and "foralls" are grouped. R^2 would be wrong in this case, because a and b should each be in R. (a,b) would be in R^2, but that's not written.

Toscho
  • 4,713
  • 6
    Logical conjunction is an operator because if P and Q are formulae, then so is (P)∧(Q). ∃x is an operator because if P is a formula then so is ∃x(P). ∃x∈R is an operator for the same reason. But , by itself, is not an operator in this sense, so I don't think it should be declared as one. – John Wickerson May 22 '13 at 07:28
  • 3
    \colon is better than : when writing for example "For every x there exists y such that...". – Jori Mäntysalo May 22 '13 at 09:42
  • 5
    @JohnWickerson: You are right. But ∃x is not a symbol by itself and so cannot be an operator in a typographical sense. The same is true for the integral: if f(x) is an formula, then \int f(x) is not a formula, but \int f(x)dx is. Yet, \int is a typographical operator. So \exists alone is not a logical operator, but \exists x\in M:P(x) is. Yet, \exists should be a typhographical operator. – Toscho May 22 '13 at 12:26
  • 1
    TLA+ uses colons: http://research.microsoft.com/en-us/um/people/lamport/tla/tla.html, and Lamport authored LaTeX. – 0 _ Mar 25 '16 at 06:18
  • You could also \let\oldexists\exists \let\exists\relax \DeclareMathOperator{\exists}{\oldexists} to continue writing \exists but get the above behaviour. – gsvg May 27 '17 at 11:31
21

It depends on the context.

If this is part of a piece of text, then you might consider Peter Grill's suggestion:

$\exists a\in\mathbb{R}$, $\exists b\in\mathbb{R}$, 
$\forall c\in\mathbb{R}$, and $\forall b\in\mathbb{R}$

enter image description here

On the other hand, if the quantifiers are part of a logical formula, you might consider a dot between the quantifiers, like this:

$\exists a\in\mathbb{R}\ldotp\exists b\in\mathbb{R}\ldotp
\forall c\in\mathbb{R}\ldotp\forall b\in\mathbb{R}\ldotp P$

enter image description here

This dot notation is inherited, I think, from Russell and Whitehead's Principia Mathematica, and is quite widely used, particularly in computer science. A comma between quantifiers is quite unusual, though it does appear in the syntax of the Coq theorem prover.

$\exists a\in\mathbb{R}, \exists b\in\mathbb{R}, 
\forall c\in\mathbb{R}, \forall d\in\mathbb{R}, P$

enter image description here

The comma notation becomes awkward when you want to quantify several variables at the same time, because then you have two different types of comma in the same formula:

$\exists a,b\in\mathbb{R}, \forall c,d\in\mathbb{R}, P$

enter image description here

In such cases, you might consider putting just a space between the variables, like this:

$\exists a\;b\in\mathbb{R}, \forall c\;d\in\mathbb{R}, P$

enter image description here

The idea of putting spaces between variables, rather than commas, is taken from the syntax of the Isabelle theorem prover.

  • 11
    I strongly disagree about using dots between quantifiers. Commas are fine, though. – jub0bs May 21 '13 at 19:35
  • I liked the second one, I prefer commas but is there a code for commas instead of using \ldotp?

    What about simple spaces "\ "?

    – Gaston Burrull May 21 '13 at 19:37
  • this answer is the closest to what I want, because what I want is a unique formula, not a separation into two parts

    what do you think about use of "\ " or "," instead of "\ldotp"?

    – Gaston Burrull May 21 '13 at 20:08
  • \ and , are fine alternatives. I incorporated , into my answer. – John Wickerson May 22 '13 at 07:42
  • 1
    @Jubobs Sometimes one replaces AND by a comma, which makes the notation very messy and inappropriate if commas are used between quantifiers instead of periods. – Dávid Natingga Aug 14 '15 at 12:31
  • Is there a way to write the quantifiers on top of 1 or more propositions? I would like to see the propositions stacked one on top of the other – An old man in the sea. Jun 13 '16 at 17:52
  • @Jubobs: Using dots for binding forms is common in some areas of theoretical computer science; for instance, "λ x. x x", "Π x. x + x", and "∃ x. x + x" are all common in type theory. It does look kind of weird, though, when you write something like "Note that $\forall x \in \R. \ x^2 \geq 0$, because […]," as it's not immediately obvious whether the dot ends the sentence or the domain of quantification. – wchargin Feb 25 '17 at 20:02
  • @wchargin True. Now that I've had some exposure to lambda calculus, I no longer mind the dots :) – jub0bs Feb 25 '17 at 20:26
8

In my opinion, the real issue with quantifiers is that it's hard to obtain consistent spacing, as I explained in this answer. The most striking example I found: \[\forall W\forall A\] gives

original output

Of course there should be more space before the second quantifier; a single space \   will usually be OK. The problem is the spacing after the quantifiers. There is no simple solution to this, other than using manual kerning where needed. In this case, \[\forall\mkern2mu W\ \forall\mkern-1mu A\] looks quite alright:

improved output

Let me point out that I'd use quantifiers only in displayed formulas, never in inline math.

Hendrik Vogt
  • 37,935
7

I don't know if this is what you are asking, but it's related.

In my opinion it's horrible the space after the quantifiers (they look very close to the next letter). I always edit them and add an small space

\let\existstemp\exists
\let\foralltemp\forall
\renewcommand*{\exists}{\existstemp\mkern2mu}
\renewcommand*{\forall}{\foralltemp\mkern2mu}

By the way, as others are saying, it depends on the situation. If it's inline I would go for There exist real scalars a,b for all real scalars c,d (Percusse's comment). But if it's inside a \displaymath I would go for the symbols.

First of all, I usually space my math with \quads (this is personal taste, and you have to choose what you use). And, in second place, I don't know how your example should be read:

  • If it's read There exist real scalars a,b for all real scalars c,d I would change the order and write For all real scalars c,d there exist real scalars a,b… and write \forall c,d \in \mathbb{R} \quad \exists a,b \in \mathbb{R}.

  • And if it's read as There exist real scalars a,b such that for all real scalars c,d… then I would write \exists a,b \in \mathbb{R}, \quad \forall c,d \in \mathbb{R}

Here it is a full example.

enter image description here

\documentclass{article}
\usepackage{amssymb}

\let\existstemp\exists
\let\foralltemp\forall

\begin{document}
\[
    \exists a,b \in \mathbb{R}, \quad \forall c,d \in \mathbb{R}
\]

\renewcommand*{\exists}{\existstemp\mkern2mu}
\renewcommand*{\forall}{\foralltemp\mkern2mu}

\[
    \exists a,b \in \mathbb{R}, \quad \forall c,d \in \mathbb{R}
\]
\[
    \forall c,d \in \mathbb{R} \quad \exists a,b \in \mathbb{R}
\]
\end{document}

In order to justify the \quads instead of the \s, here is another example which, in my opinion, shows my idea (and why in displaymaths \quads are useful):

enter image description here

I think that the first line is far more readable than the second one.

Manuel
  • 27,118
  • I'm interested in space between \mathbb{R} and \exists. Writting "\mathbb{R} \exists" is horrible and "\mathbb{R}\quad \exists" is exaggerated, I prefer "\mathbb{R}\ \exists" or "\mathbb{R}\ \exists".

    About your suggestion, what about $\forall, c$? "," is a little space after quantifier also.

    – Gaston Burrull May 21 '13 at 20:00
  • @GastónBurrull About the \,, yes, it works (I used \mkern2mu to show how to adjust it). By the way the \quad if it's in a \displaymath I think it's much better than \ because it clearly separates the sentence. – Manuel May 21 '13 at 20:03
  • 1
    In your first item the meaning changes drastically if you swap the order. – percusse May 22 '13 at 07:55
  • @percusse My answer to that is: Of course. But then I think, may be I misunderstood part of the question. Shouldn't it change if I swap the order? May be in logic (which I don't know) it shouldn't. My point was only to add the space after the quantifiers and show the \quads as useful mathematical spaces. If I'm wrong, please correct me, it's true I know nothing about logic. – Manuel May 22 '13 at 10:02
  • 1
    @Manuel Sure. I learned it the hard way so I have an eye for that structure from my PhD :) One says there are fixed a,b for all c,d if you swap the order. The other one says for each a and b you can find some c and d. And that caused me a lot of trouble in thepast because they don't teach that in engineering heh. – percusse May 22 '13 at 10:31
  • Oops the last sentence should have a b and c d swapped sorry. – percusse May 22 '13 at 10:43
  • @Manuel This is the drastic meaning change that percusse refers to: Compare "For all roads r, there exists a city c, such that r leads to c" with "There exists a city c, such that for all roads r, r leads to c". :-) – John Wickerson May 22 '13 at 10:48
  • @JohnWickerson It's actually for all r in roads otherwise it's ambiguous whether it is Rome or any city that a road leads to. – percusse May 22 '13 at 10:52
  • @percusse Emmm, still not full aware of what you are saying. I wrote And, in second place, I don't know how your example should be read… and then put both options. If it is read as the first then I would swap order and write one thing, if it is read as the second then the phrase absolutely changes it's meaning and I would write it in another way. I never meant both to mean the same, in fact, I tried to differentiate them even more. Is that it? Sorry guys… – Manuel May 22 '13 at 11:08
  • @JohnWickerson and Percusse If you still think I'm wrong, feel free to edit and correct the answer the answer. – Manuel May 22 '13 at 11:18
  • @Manuel if for all comes at the start of the sentence it means something else than it comes after. Maybe a simpler example is for all guy in guys there exists a favorite woman (everybody finds a mate theoretically speaking :P) and there exists a favorite woman for all guy in guys (there is one particular woman who is the favorite of all men) \end{ultrasexistcomment} Here if you swap the order the meaning changes whether we need to find any a,b for every c, d or we are looking for a particular pair of a,b that is valid for every c,d. – percusse May 22 '13 at 11:37
  • @percusse I don't know how to correct it, if you want you can do it, if not, I will rewrite the answer only talking about the space after the quantifiers and the \quads. – Manuel May 22 '13 at 11:44
3

Another possibility is:

$\exists\ a,b \in \mathbb{R},\ \forall\ c, b \in\mathbb{R}$

enter image description here

  • 1
    I liked use of comma. I probably will use this in the future $\exists a\in\mathbb{R}, \exists b\in\mathbb {R}, \forall c\in \mathbb{R}, \forall d\in\mathbb{R}$. Since I don't like the space "\ " after the quantifier. – Gaston Burrull May 21 '13 at 19:52
  • 1
    The disadvantage of using commas, at least in the example above, is that you now have two different types of comma in your formula, with two different meanings, and this could make the formula a bit hard to understand. – John Wickerson May 22 '13 at 07:31
1

I've always used \; after every symbol that goes with a quantifier. For example,

\begin{equation*}
\forall \varepsilon > 0 \; \exists N \in \mathbb{N} \; \forall n \in \mathbb{N} \; 
(n \geq N \implies |s_n - L| < \varepsilon)
\end{equation*}

enter image description here

Though I do understand that such an ad hoc method is not good practice.