How to write the math you’ve just read
$ ... $ for inline math.$$...$$ for standalone equations.To write the logic from Section 1.1, you only need to memorize these three commands:
| Concept | Logical Symbol | LaTeX Command |
|---|---|---|
| Universal | \(\forall\) | \forall |
| Existential | \(\exists\) | \exists |
| Conditional | \(\to\) | \to or \implies |
Goal: Write “For all \(x\), if \(x\) is an integer, then \(x\) is real.”
\forall x (\(\forall x\))\in \mathbb{Z} (\(\in \mathbb{Z}\))\implies (\(\implies\))x \in \mathbb{R} (\(x \in \mathbb{R}\))Full Code: $\forall x \in \mathbb{Z} \implies x \in \mathbb{R}$
Sometimes you need to separate your quantifiers from your predicates to make them readable.
| Symbol | Meaning | LaTeX Command |
|---|---|---|
| Element of | \(\in\) | \in |
| Such that | \(|\) or \(:\) | | or : |
| Negation | \(\neg\) | \neg |
| Set of Integers | \(\mathbb{Z}\) | \mathbb{Z} |
| Set of Reals | \(\mathbb{R}\) | \mathbb{R} |
Remember our Mother/Child example? Here is how to code it:
\(\forall\) Person \(p, \exists\) Mother \(m\): $\forall p, \exists m : \text{isMother}(m, p)$
\(\exists\) Mother \(m, \forall\) Person \(p\): $\exists m, \forall p : \text{isMother}(m, p)$
Pro-Tip: Use
\text{...}inside math mode to write normal words so they don’t look like \(slanted\) \(variables\).
forall will just look like \(forall\).
\forall becomes \(\forall\).$ has a matching $.\, if you desperately need a small space, but usually, the symbols handle it.Look at the following statement. Try to type the LaTeX code for it in your notes:
“There exists an \(n\) such that \(n\) is even and \(n > 10\).”
Solution: $\exists n \mid n \text{ is even} \land n > 10$
(Note: \land is the symbol for “and” \(\land\))
Keep these in your pocket:
\forall \(\to \forall\)\exists \(\to \exists\)\to \(\to \to\)\mathbb{R} \(\to \mathbb{R}\) (Real Numbers)\mathbb{Z} \(\to \mathbb{Z}\) (Integers)\mathbb{Q} \(\to \mathbb{Q}\) (Rational Numbers)