DEV Community

zuka3
zuka3

Posted on

Writing Theorems, Proofs, and Definitions on Dev.to

If you're writing a math-heavy article — explaining an algorithm's correctness, proving a complexity bound, or walking through a cryptographic protocol — you need a way to clearly distinguish theorems, proofs, definitions, and examples from the surrounding text.

Standard LaTeX has dedicated environments for this (\begin{theorem}, \begin{proof}). Dev.to doesn't. But with some markdown techniques, you can get close.

Method 1: Blockquotes (Simplest)

Markdown blockquotes (>) give a visual distinction from body text:

> **Theorem 1 (Lagrange's Theorem).**
> For a finite group G and subgroup H,
> the order of H divides the order of G:
> {% katex %} |G| = [G : H] \cdot |H| {% endkatex %}
Enter fullscreen mode Exit fullscreen mode

Theorem 1 (Lagrange's Theorem).
For a finite group G and subgroup H, the order of H divides the order of G:

G=[G:H]H|G| = [G : H] \cdot |H|

Simple, reliable, and works everywhere.

Method 2: Collapsible Proofs

Long proofs can overwhelm readers. Use <details> to make them collapsible:

<details>
<summary><b>Proof</b></summary>

Consider the set of left cosets of H in G.
Each coset gH contains |H| elements,
and distinct cosets are disjoint.
Since G is the disjoint union of its cosets:

{% katex %}
|G| = (\text{number of cosets}) \times |H| = [G:H] \cdot |H|
{% endkatex %}

{% katex inline %} \square {% endkatex %}
</details>
Enter fullscreen mode Exit fullscreen mode
Proof Consider the set of left cosets of H in G. Each coset gH contains |H| elements, and distinct cosets are disjoint. Since G is the disjoint union of its cosets:
G=(number of cosets)×H=[G:H]H|G| = (\text{number of cosets}) \times |H| = [G:H] \cdot |H|


\square

This lets readers see the theorem statement first and expand the proof only if they want the details.

Method 3: Horizontal Rules

Use --- to create visual boundaries:

---

**Theorem 2 (Euler's Formula).**

For any real number θ:

{% katex %}
e^{i\theta} = \cos\theta + i\sin\theta
{% endkatex %}

---
Enter fullscreen mode Exit fullscreen mode

Theorem 2 (Euler's Formula).

For any real number θ:

eiθ=cosθ+isinθ e^{i\theta} = \cos\theta + i\sin\theta

QED Marks

In LaTeX, \begin{proof} automatically adds a QED mark. On Dev.to, add it manually:

Style Code Result
White square {% katex inline %} \square {% endkatex %}
Black square {% katex inline %} \blacksquare {% endkatex %}
Text

Place it at the end of your proof, typically on the last line.

Numbering Conventions

Option 1: Sequential numbering (recommended)

Theorem 1, Lemma 2, Theorem 3, Corollary 4 ...

Sequential numbering makes it easy to find referenced items — "Lemma 2 comes before Theorem 3" is immediately clear from the numbers.

Option 2: Section-based numbering

Theorem 2.1, Lemma 2.2, Theorem 3.1 ...

Better for longer articles with clear sections.

Option 3: Type-based numbering

Theorem 1, Theorem 2, Lemma 1, Lemma 2 ...

Avoid this — it's confusing when referencing ("Lemma 1 is used in the proof of Theorem 2" doesn't tell you the ordering).

Distinguishing Types

In math writing, different statement types serve different roles:

Type Purpose When to use
Definition Introduces a term Before first use
Theorem Major result Central claims
Lemma Helper result Building blocks for theorems
Proposition Medium result Less central than a theorem
Corollary Direct consequence Immediately after a theorem
Example Concrete instance After definitions or theorems
Remark Commentary Supplementary notes

Full Example: The First Isomorphism Theorem

Here's a complete example combining everything:


Definition 1 (Group Homomorphism).
A map φ:GH\varphi: G \to H between groups is a homomorphism if

φ(ab)=φ(a)φ(b)\varphi(ab) = \varphi(a)\varphi(b)

for all a,bGa, b \in G .

Definition 2 (Kernel and Image).
For a homomorphism φ:GH\varphi: G \to H :

kerφ=gGφ(g)=eH Imφ=φ(g)gG\begin{aligned} \ker\varphi &= { g \in G \mid \varphi(g) = e_H } \ \operatorname{Im}\varphi &= { \varphi(g) \mid g \in G } \end{aligned}

Lemma 3. The kernel kerφ\ker\varphi is a normal subgroup of G.

Proof

The subgroup property is straightforward. For normality: for any

gGg \in G

and

nkerφn \in \ker\varphi

:

φ(gng1)=φ(g)φ(n)φ(g1)=φ(g)eHφ(g)1=eH\begin{aligned} \varphi(gng^{-1}) &= \varphi(g)\varphi(n)\varphi(g^{-1}) \\ &= \varphi(g) \cdot e_H \cdot \varphi(g)^{-1} = e_H \end{aligned}

So

gng1kerφgng^{-1} \in \ker\varphi

, proving

kerφG\ker\varphi \trianglelefteq G

.

\square

Theorem 4 (First Isomorphism Theorem).
For any group homomorphism φ:GH\varphi: G \to H :

G/kerφImφG / \ker\varphi \cong \operatorname{Im}\varphi

Proof

Let

N=kerφN = \ker\varphi

. Define

φˉ:G/NImφ\bar{\varphi}: G/N \to \operatorname{Im}\varphi

by

φˉ(gN)=φ(g)\bar{\varphi}(gN) = \varphi(g)

.

Well-defined: If

gN=gNgN = g'N

, then

g1gNg^{-1}g' \in N

, so

φ(g)=φ(g)\varphi(g) = \varphi(g')

.

Homomorphism:

φˉ(gNgN)=φ(gg)=φ(g)φ(g)=φˉ(gN)φˉ(gN)\bar{\varphi}(gN \cdot g'N) = \varphi(gg') = \varphi(g)\varphi(g') = \bar{\varphi}(gN)\bar{\varphi}(g'N)

.

Injective:

φˉ(gN)=eH\bar{\varphi}(gN) = e_H

implies

gNg \in N

, so

gN=NgN = N

.

Surjective: By definition of

Imφ\operatorname{Im}\varphi

.

Hence

φˉ\bar{\varphi}

is an isomorphism.

\square

Corollary 5. If φ\varphi is surjective, then G/kerφHG/\ker\varphi \cong H .


Templates

Copy-paste these to get started:

Theorem:

> **Theorem N (Name).**
> Statement here.
> {% katex %} equation {% endkatex %}
Enter fullscreen mode Exit fullscreen mode

Proof (collapsible):

<details>
<summary><b>Proof</b></summary>

Proof body here.

{% katex inline %} \square {% endkatex %}
</details>
Enter fullscreen mode Exit fullscreen mode

Definition:

> **Definition N (Term).**
> Definition here.
Enter fullscreen mode Exit fullscreen mode

Summary

  • Blockquotes for theorems/definitions, <details> for proofs
  • Sequential numbering for easy referencing
  • QED mark: \square at the end of proofs
  • Collapsible proofs keep articles scannable
  • No auto-numbering or cross-references — manage manually

Top comments (0)