Typevia
Mathematical Typesetting

Introduction to Mathematical Proofs in LaTeX

In mathematics and logic, the structure of your document is just as important as the content itself. LaTeX is the industry standard for mathematical writing because it treats logical structures—like theorems, lemmas, and proofs—as distinct environments. This ensures consistent formatting, automatic numbering, and professional-grade typesetting.

To handle proofs and theorems effectively, we primarily rely on the amsthm package (part of the American Mathematical Society suite). This guide will teach you how to set up these environments, customize their appearance, and write clean, logical proofs.

1. Setting Up the Preamble

Before you can write a proof, you need to tell LaTeX how to handle "theorem-like" environments. This is done in the preamble (the area before \begin{document}).

To get started, you must load the amsthm package. You will then use the \newtheorem command to define the types of statements you intend to use.

Basic Syntax

\usepackage{amsmath, amsthm}

% \newtheorem{internal_name}{Display Name}[parent_counter]
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{definition}{Definition}[section]

Breakdown of the command:

  • internal_name: The name you use in your code (e.g., \begin{theorem}).
  • Display Name: The text that actually appears in the PDF (e.g., Theorem 1).
  • [parent_counter]: (Optional) This links numbering to a section. For example, [section] makes your definitions appear as Definition 1.1, 1.2, etc.
  • [theorem]: (Optional) Placing this in the middle tells LaTeX to share the numbering with the "theorem" environment. This keeps all your lemmas and theorems in a single numerical sequence (e.g., Lemma 1, Theorem 2, Lemma 3).

2. The Proof Environment

The proof environment is provided by the amsthm package. It is designed to wrap your logical arguments, automatically adding "Proof" at the beginning and a QED (Quod Erat Demonstrandum) symbol—usually an open square—at the end.

Basic Usage

\begin{theorem}
The sum of two even integers is always even.
\end{theorem}

\begin{proof}
Let $n$ and $m$ be two even integers. By definition, $n = 2k$ and $m = 2j$ for some integers $k, j$. 
Then:
\[ n + m = 2k + 2j = 2(k + j) \]
Since $k+j$ is an integer, $n+m$ is even.
\end{proof}

Note: The proof environment automatically handles spacing before and after the text, ensuring your document remains readable.

3. Theorem Styles

Not every mathematical statement should look the same. A "Theorem" is usually more significant than a "Remark." LaTeX allows you to define different visual styles using the \theoremstyle{} command.

The amsthm package offers three standard styles:

  1. plain: Bold title, italicized body text. Best for Theorems, Lemmas, and Corollaries.
  2. definition: Bold title, upright (roman) body text. Best for Definitions and Examples.
  3. remark: Italicized title, upright body text. Best for Notes and Remarks.

Example Setup with Styles

\theoremstyle{plain}
\newtheorem{thm}{Theorem}

\theoremstyle{definition}
\newtheorem{defn}{Definition}

\theoremstyle{remark}
\newtheorem*{note}{Note} % The asterisk means this environment won't be numbered

Using these styles helps readers visually distinguish between a core result (italicized) and a supporting definition (upright).

4. Customizing the QED Symbol

While the default open square ($\square$) is standard, you might want to change it to a filled square or specific text. You can redefine the symbol globally or adjust it locally.

Changing the Symbol Globally

To change the QED symbol to a black square, add this to your preamble:

\renewcommand{\qedsymbol}{$\blacksquare$}

Handling the "Floating QED" Problem

One of the most common issues beginners face is when a proof ends with a displayed equation. The QED symbol often drops to a new line, wasting space. To fix this, use the \qedhere command inside the equation.

\begin{proof}
The calculation concludes with:
\[ a^2 + b^2 = c^2. \qedhere \]
\end{proof}

Tip: If you are using the align* environment from amsmath, place \qedhere inside the final line of the alignment to ensure the square stays on the same line as the math.

5. Advanced Proof Structures: Cases and Steps

Complex proofs often require sub-structures like "Case 1" or "Step 1." While you can simply type these out, using specific formatting makes them stand out.

Using the Enumerate Package

The enumitem package is excellent for creating numbered cases within a proof.

\usepackage{enumitem}

\begin{proof}
We proceed by cases on the integer $n$.
\begin{enumerate}[label=\textbf{Case \arabic*:}]
    \item $n$ is even. If $n=2k$, then...
    \item $n$ is odd. If $n=2k+1$, then...
\end{enumerate}
Therefore, the statement holds for all $n$.
\end{proof}

6. Best Practices and Common Pitfalls

To create professional-looking mathematical documents, keep these tips in mind:

  • Don't Manual Format: Avoid using \textbf{Theorem 1} followed by \textit{...}. Always use \newtheorem environments. This allows you to change the style of every theorem in your document by changing a single line in the preamble.
  • Label Everything: Use \label{thm:my_theorem} inside your environments. This allows you to reference them later with \ref{thm:my_theorem} or \eqref{...} without worrying about changing numbers.
  • Keep Proofs Concise: If a proof is very long, consider breaking out technical lemmas into their own environments before the main theorem.
  • The Asterisk Trick: If you don't want a specific environment to be numbered (like an "Introduction" or a "Note"), use the starred version: \newtheorem*{note}{Note}.
  • Placement of \qedhere: Remember that \qedhere only works inside the proof environment. If you try to use it elsewhere, LaTeX will return an error.

By mastering these structures, you ensure that your mathematical writing is not only logically sound but also visually clear and easy for readers to follow.