Set Theory and Logic Notation — Mathematical Foundations

Complete guide to set theory and logic notation in technical documentation. Learn sets, operations, logic symbols, quantifiers, and proof notation with KaTeX.

Introduction

Set theory and logic form the foundation of mathematics and computer science. From database queries to type systems, from algorithm correctness proofs to formal verification, these concepts appear throughout technical documentation.

This guide covers the essential notation for sets, set operations, propositional logic, predicate logic, and proof structures. You'll learn how to express these concepts clearly using KaTeX in your technical documentation.

Prerequisites
This guide assumes familiarity with basic KaTeX syntax. If you're new to KaTeX, start with our KaTeX Syntax Quick Reference first.

Set Notation Basics

Sets are collections of distinct objects. Understanding set notation is essential for documenting data structures, type systems, and mathematical specifications.

Defining Sets

Set Definition Notation

Different ways to define and describe sets

Roster notation (listing elements):

A={1,2,3,4,5}A = \{1, 2, 3, 4, 5\}A={1,2,3,4,5}

Set-builder notation (defining by property):

B={xZ:x>0}B = \{x \in \mathbb{Z} : x > 0\}B={xZ:x>0}

Alternative set-builder with vertical bar:

C={xx2<10}C = \{x \mid x^2 < 10\}C={xx2<10}

Interval notation:

[a,b]={xR:axb}[a, b] = \{x \in \mathbb{R} : a \leq x \leq b\}[a,b]={xR:axb} (a,b)={xR:a<x<b}(a, b) = \{x \in \mathbb{R} : a < x < b\}(a,b)={xR:a<x<b}

Special Sets

Standard Number Sets

Common mathematical sets with blackboard bold notation

Number sets:

  • Natural numbers: N={1,2,3,}\mathbb{N} = \{1, 2, 3, \ldots\}N={1,2,3,}
  • Integers: Z={,2,1,0,1,2,}\mathbb{Z} = \{\ldots, -2, -1, 0, 1, 2, \ldots\}Z={,2,1,0,1,2,}
  • Rationals: Q={pq:p,qZ,q0}\mathbb{Q} = \{\frac{p}{q} : p, q \in \mathbb{Z}, q \neq 0\}Q={qp:p,qZ,q=0}
  • Real numbers: R\mathbb{R}R
  • Complex numbers: C\mathbb{C}C

Special sets:

  • Empty set: \emptyset or {}\{\}{}
  • Universal set: UUU or U\mathcal{U}U
  • Power set: P(A)\mathcal{P}(A)P(A) or 2A2^A2A

Positive/negative variants:

Z+={1,2,3,},R={xR:x<0}\mathbb{Z}^+ = \{1, 2, 3, \ldots\}, \quad \mathbb{R}^- = \{x \in \mathbb{R} : x < 0\}Z+={1,2,3,},R={xR:x<0}

Set Membership and Relations

Membership and Subset Relations

Expressing element membership and set relationships

Element membership:

  • xAx \in AxAxxx is an element of AAA
  • xAx \notin Ax/Axxx is not an element of AAA

Subset relations:

  • ABA \subset BABAAA is a proper subset of BBB
  • ABA \subseteq BABAAA is a subset of BBB (possibly equal)
  • ABA \supset BABAAA is a proper superset of BBB
  • ABA \supseteq BABAAA is a superset of BBB
  • A⊄BA \not\subset BABAAA is not a subset of BBB

Set equality:

A=B    (AB)(BA)A = B \iff (A \subseteq B) \land (B \subseteq A)A=B(AB)(BA)

Set Operations

Set operations are fundamental to database queries, type systems, and algorithm design. These operations combine or modify sets to create new sets.

Basic Operations

Union, Intersection, and Difference

Core set operations

Union (elements in either set):

AB={x:xAxB}A \cup B = \{x : x \in A \lor x \in B\}AB={x:xAxB}

Intersection (elements in both sets):

AB={x:xAxB}A \cap B = \{x : x \in A \land x \in B\}AB={x:xAxB}

Set difference (elements in AAA but not BBB):

AB={x:xAxB}A \setminus B = \{x : x \in A \land x \notin B\}AB={x:xAx/B}

Alternative notation: ABA - BAB

Symmetric difference (elements in exactly one set):

AB=(AB)(BA)A \triangle B = (A \setminus B) \cup (B \setminus A)AB=(AB)(BA)

Alternative: ABA \oplus BAB

Complement and Power Set

Complement and Power Set

Complement relative to universal set and power sets

Complement (elements not in AAA):

Ac=A=UA={xU:xA}A^c = \overline{A} = U \setminus A = \{x \in U : x \notin A\}Ac=A=UA={xU:x/A}

Power set (set of all subsets):

P(A)={S:SA}\mathcal{P}(A) = \{S : S \subseteq A\}P(A)={S:SA}

Example:

P({1,2})={,{1},{2},{1,2}}\mathcal{P}(\{1, 2\}) = \{\emptyset, \{1\}, \{2\}, \{1, 2\}\}P({1,2})={,{1},{2},{1,2}}

Cardinality of power set:

P(A)=2A|\mathcal{P}(A)| = 2^{|A|}P(A)=2A

Cartesian Product

Cartesian Product

Ordered pairs from two sets

Cartesian product:

A×B={(a,b):aAbB}A \times B = \{(a, b) : a \in A \land b \in B\}A×B={(a,b):aAbB}

Example:

{1,2}×{a,b}={(1,a),(1,b),(2,a),(2,b)}\{1, 2\} \times \{a, b\} = \{(1, a), (1, b), (2, a), (2, b)\}{1,2}×{a,b}={(1,a),(1,b),(2,a),(2,b)}

n-fold Cartesian product:

An=A×A××A(n times)A^n = A \times A \times \cdots \times A \quad (n \text{ times})An=A×A××A(n times)

Cardinality:

A×B=AB|A \times B| = |A| \cdot |B|A×B=AB

Indexed Operations

Indexed Unions and Intersections

Operations over families of sets

Indexed union:

i=1nAi=A1A2An\bigcup_{i=1}^{n} A_i = A_1 \cup A_2 \cup \cdots \cup A_ni=1nAi=A1A2An iIAi={x:iI,xAi}\bigcup_{i \in I} A_i = \{x : \exists i \in I, x \in A_i\}iIAi={x:iI,xAi}

Indexed intersection:

i=1nAi=A1A2An\bigcap_{i=1}^{n} A_i = A_1 \cap A_2 \cap \cdots \cap A_ni=1nAi=A1A2An iIAi={x:iI,xAi}\bigcap_{i \in I} A_i = \{x : \forall i \in I, x \in A_i\}iIAi={x:iI,xAi}

Disjoint union:

iIAi\bigsqcup_{i \in I} A_iiIAi

Propositional Logic

Propositional logic deals with statements that are either true or false. It's the foundation for boolean algebra, circuit design, and programming conditionals.

Logical Connectives

Basic Logical Operators

Connectives for combining propositions

Negation (NOT):

¬P,¬P,P,P\neg P, \quad \lnot P, \quad \sim P, \quad \overline{P}¬P,¬P,P,P

Conjunction (AND):

PQ,PQ,P&QP \land Q, \quad P \cdot Q, \quad P \& QPQ,PQ,P&Q

Disjunction (OR):

PQ,P+QP \lor Q, \quad P + QPQ,P+Q

Exclusive OR (XOR):

PQ,PQP \oplus Q, \quad P \veebar QPQ,PQ

Implication (IF...THEN):

P    Q,PQ,PQP \implies Q, \quad P \to Q, \quad P \Rightarrow QPQ,PQ,PQ

Biconditional (IF AND ONLY IF):

P    Q,PQ,PQP \iff Q, \quad P \leftrightarrow Q, \quad P \Leftrightarrow QPQ,PQ,PQ

Truth Tables

Truth Table Notation

Documenting logical operations with truth tables

Implication truth table:

PPPQQQP    QP \implies QPQ
TTT
TFF
FTT
FFT

De Morgan's Laws:

¬(PQ)¬P¬Q\neg(P \land Q) \equiv \neg P \lor \neg Q¬(PQ)¬P¬Q ¬(PQ)¬P¬Q\neg(P \lor Q) \equiv \neg P \land \neg Q¬(PQ)¬P¬Q

Logical Equivalences

Important Logical Equivalences

Common tautologies and equivalences

Contrapositive:

(P    Q)(¬Q    ¬P)(P \implies Q) \equiv (\neg Q \implies \neg P)(PQ)(¬Q¬P)

Material implication:

(P    Q)(¬PQ)(P \implies Q) \equiv (\neg P \lor Q)(PQ)(¬PQ)

Distributive laws:

P(QR)(PQ)(PR)P \land (Q \lor R) \equiv (P \land Q) \lor (P \land R)P(QR)(PQ)(PR) P(QR)(PQ)(PR)P \lor (Q \land R) \equiv (P \lor Q) \land (P \lor R)P(QR)(PQ)(PR)

Double negation:

¬(¬P)P\neg(\neg P) \equiv P¬(¬P)P

Absorption:

P(PQ)PP \lor (P \land Q) \equiv PP(PQ)P

Predicate Logic

Predicate logic extends propositional logic with quantifiers and predicates, allowing us to make statements about objects and their properties. It's essential for formal specifications and mathematical proofs.

Quantifiers

Universal and Existential Quantifiers

Expressing 'for all' and 'there exists'

Universal quantifier (for all):

xA,P(x)\forall x \in A, P(x)xA,P(x)

"For all xxx in AAA, property P(x)P(x)P(x) holds"

Existential quantifier (there exists):

xA,P(x)\exists x \in A, P(x)xA,P(x)

"There exists an xxx in AAA such that P(x)P(x)P(x) holds"

Unique existence:

!x,P(x)\exists! x, P(x)!x,P(x)

"There exists exactly one xxx such that P(x)P(x)P(x)"

Negation of quantifiers:

¬(x,P(x))x,¬P(x)\neg(\forall x, P(x)) \equiv \exists x, \neg P(x)¬(x,P(x))x,¬P(x) ¬(x,P(x))x,¬P(x)\neg(\exists x, P(x)) \equiv \forall x, \neg P(x)¬(x,P(x))x,¬P(x)

Nested Quantifiers

Multiple Quantifiers

Combining quantifiers for complex statements

Order matters:

"For every xxx, there exists a yyy":

x,y,P(x,y)\forall x, \exists y, P(x, y)x,y,P(x,y)

"There exists a yyy for every xxx":

y,x,P(x,y)\exists y, \forall x, P(x, y)y,x,P(x,y)

Example - Continuity:

ϵ>0,δ>0,x,(xa<δ    f(x)f(a)<ϵ)\forall \epsilon > 0, \exists \delta > 0, \forall x, (|x - a| < \delta \implies |f(x) - f(a)| < \epsilon)ϵ>0,δ>0,x,(xa<δf(x)f(a)<ϵ)

Example - Limit definition:

limxaf(x)=L    ϵ>0,δ>0,(0<xa<δ    f(x)L<ϵ)\lim_{x \to a} f(x) = L \iff \forall \epsilon > 0, \exists \delta > 0, (0 < |x - a| < \delta \implies |f(x) - L| < \epsilon)xalimf(x)=Lϵ>0,δ>0,(0<xa<δf(x)L<ϵ)

Predicates and Relations

Predicate Notation

Expressing properties and relations

Unary predicate (property):

P(x) — "x has property P"P(x) \text{ — "$x$ has property $P$"}P(x) — "x has property P"

Binary predicate (relation):

R(x,y) — "x is related to y by R"R(x, y) \text{ — "$x$ is related to $y$ by $R$"}R(x,y) — "x is related to y by R"

Alternative notation: xRyxRyxRy

Examples:

  • Prime(n)\text{Prime}(n)Prime(n) — "nnn is prime"
  • x<yx < yx<y — "xxx is less than yyy"
  • xy(modn)x \equiv y \pmod{n}xy(modn) — "xxx is congruent to yyy modulo nnn"

Relation properties:

  • Reflexive: x,xRx\forall x, xRxx,xRx
  • Symmetric: x,y,(xRy    yRx)\forall x, y, (xRy \implies yRx)x,y,(xRyyRx)
  • Transitive: x,y,z,(xRyyRz    xRz)\forall x, y, z, (xRy \land yRz \implies xRz)x,y,z,(xRyyRzxRz)

Proof Notation

Mathematical proofs require specific notation to express logical structure clearly. This notation is essential for formal verification, algorithm correctness, and mathematical documentation.

Proof Structure Symbols

Proof Notation

Symbols used in mathematical proofs

Therefore / Hence:

(therefore)\therefore \quad \text{(therefore)}(therefore)

Because / Since:

(because)\because \quad \text{(because)}(because)

QED / End of proof:

Q.E.D.\square \quad \blacksquare \quad \text{Q.E.D.}Q.E.D.

Contradiction:

(contradiction/false)\bot \quad \text{(contradiction/false)}(contradiction/false)

Tautology:

(tautology/true)\top \quad \text{(tautology/true)}(tautology/true)

Turnstile (proves/entails):

(syntactic entailment)\vdash \quad \text{(syntactic entailment)}(syntactic entailment) (semantic entailment)\models \quad \text{(semantic entailment)}(semantic entailment)

Proof by Contradiction

Proof by Contradiction Structure

Documenting indirect proofs

Proof by contradiction:

To prove PPP:

  1. Assume ¬P\neg P¬P
  2. Derive a contradiction: Q¬QQ \land \neg QQ¬Q
  3. Conclude PPP must be true

Example - 2\sqrt{2}2 is irrational:

Assume 2=pq\sqrt{2} = \frac{p}{q}2=qp where gcd(p,q)=1\gcd(p, q) = 1gcd(p,q)=1.

Then 2=p2q22 = \frac{p^2}{q^2}2=q2p2, so p2=2q2p^2 = 2q^2p2=2q2.

p2\therefore p^2p2 is even, so ppp is even.

Let p=2kp = 2kp=2k. Then 4k2=2q24k^2 = 2q^24k2=2q2, so q2=2k2q^2 = 2k^2q2=2k2.

q\therefore qq is even. But gcd(p,q)=1\gcd(p, q) = 1gcd(p,q)=1. \bot

2\therefore \sqrt{2}2 is irrational. \square

Mathematical Induction

Induction Proof Structure

Documenting proofs by induction

Principle of Mathematical Induction:

To prove nN,P(n)\forall n \in \mathbb{N}, P(n)nN,P(n):

  1. Base case: Prove P(1)P(1)P(1)
  2. Inductive step: Prove P(k)    P(k+1)P(k) \implies P(k+1)P(k)P(k+1)

Example - Sum formula:

Claim: i=1ni=n(n+1)2\sum_{i=1}^{n} i = \frac{n(n+1)}{2}i=1ni=2n(n+1)

Base case (n=1n = 1n=1):

i=11i=1=122\sum_{i=1}^{1} i = 1 = \frac{1 \cdot 2}{2} \checkmarki=11i=1=212

Inductive step: Assume true for kkk. Then:

i=1k+1i=i=1ki+(k+1)=k(k+1)2+(k+1)\sum_{i=1}^{k+1} i = \sum_{i=1}^{k} i + (k+1) = \frac{k(k+1)}{2} + (k+1)i=1k+1i=i=1ki+(k+1)=2k(k+1)+(k+1) =k(k+1)+2(k+1)2=(k+1)(k+2)2= \frac{k(k+1) + 2(k+1)}{2} = \frac{(k+1)(k+2)}{2} \checkmark=2k(k+1)+2(k+1)=2(k+1)(k+2)

\therefore By induction, the formula holds nN\forall n \in \mathbb{N}nN. \square

Applications in Technical Documentation

Here are practical examples of set theory and logic notation in common technical documentation scenarios.

Type Systems

Type Theory Notation

Set theory in programming type systems

Type as a set:

Int={,2,1,0,1,2,}\text{Int} = \{\ldots, -2, -1, 0, 1, 2, \ldots\}Int={,2,1,0,1,2,}

Union types:

StringNumber\text{String} \cup \text{Number}StringNumber

Intersection types:

SerializableComparable\text{Serializable} \cap \text{Comparable}SerializableComparable

Subtyping:

IntegerNumberObject\text{Integer} \subseteq \text{Number} \subseteq \text{Object}IntegerNumberObject

Generic types:

ListT={[x1,x2,]:xiT}\text{List}\langle T \rangle = \{[x_1, x_2, \ldots] : x_i \in T\}ListT={[x1,x2,]:xiT}

Function types:

f:ABmeansfBAf: A \to B \quad \text{means} \quad f \in B^Af:ABmeansfBA

Database Queries

Relational Algebra

Set operations in database theory

Selection (filter rows):

σage>21(Users)\sigma_{\text{age} > 21}(\text{Users})σage>21(Users)

Projection (select columns):

πname, email(Users)\pi_{\text{name, email}}(\text{Users})πname, email(Users)

Join:

UsersUsers.id=Orders.user_idOrders\text{Users} \bowtie_{\text{Users.id} = \text{Orders.user\_id}} \text{Orders}UsersUsers.id=Orders.user_idOrders

Set operations on tables:

ActiveUsersPremiumUsers\text{ActiveUsers} \cup \text{PremiumUsers}ActiveUsersPremiumUsers AllUsersBannedUsers\text{AllUsers} \setminus \text{BannedUsers}AllUsersBannedUsers

Query composition:

πname(σstatus=’active’(Users))\pi_{\text{name}}(\sigma_{\text{status} = \text{'active'}}(\text{Users}))πname(σstatus=’active’(Users))

Algorithm Specifications

Formal Specifications

Logic in algorithm correctness

Precondition:

Pre:i[0,n),A[i]Z\text{Pre}: \forall i \in [0, n), A[i] \in \mathbb{Z}Pre:i[0,n),A[i]Z

Postcondition:

Post:i[0,n1),A[i]A[i+1]\text{Post}: \forall i \in [0, n-1), A[i] \leq A[i+1]Post:i[0,n1),A[i]A[i+1]

Loop invariant:

Inv:j[0,i),A[j]A[j+1]\text{Inv}: \forall j \in [0, i), A[j] \leq A[j+1]Inv:j[0,i),A[j]A[j+1]

Termination:

Variant:ni0decreasing\text{Variant}: n - i \geq 0 \land \text{decreasing}Variant:ni0decreasing

Hoare triple:

{P}S{Q}\{P\} \, S \, \{Q\}{P}S{Q}

"If precondition PPP holds before executing SSS, then postcondition QQQ holds after."

Boolean Algebra in Circuits

Digital Logic

Boolean algebra for circuit design

Basic gates:

  • AND: Y=ABY = A \cdot BY=AB
  • OR: Y=A+BY = A + BY=A+B
  • NOT: Y=AY = \overline{A}Y=A
  • XOR: Y=ABY = A \oplus BY=AB
  • NAND: Y=ABY = \overline{A \cdot B}Y=AB

Boolean simplification:

AB+A=A+B+A=1\overline{A \cdot B} + A = \overline{A} + \overline{B} + A = 1AB+A=A+B+A=1

Sum of products:

F=ABC+ABC+ABCF = \overline{A}BC + A\overline{B}C + AB\overline{C}F=ABC+ABC+ABC

Product of sums:

F=(A+B)(A+C)(B+C)F = (A + B)(\overline{A} + C)(B + \overline{C})F=(A+B)(A+C)(B+C)

Best Practices

Use Standard Notation
Stick to widely recognized symbols. Use ∈ for membership, ⊆ for subsets, and ∀/∃ for quantifiers. Avoid inventing new notation unless absolutely necessary.
Define Your Universe
Always specify the domain of discourse. Write "∀x ∈ ℝ" rather than just "∀x" to avoid ambiguity about what values x can take.
Use Set-Builder Notation for Complex Sets
When a set cannot be easily listed, use set-builder notation like "{x ∈ A : P(x)}" to clearly express "all elements of A satisfying property P".
Break Down Complex Formulas
For nested quantifiers or complex logical expressions, introduce intermediate definitions or break the formula across multiple lines with explanations.
Use Aligned Environments for Proofs
When showing step-by-step derivations, use the aligned environment to align equals signs and implications for clarity.

Common Mistakes

Confusing ∈ and ⊆
Use ∈ for element membership (x ∈ A) and ⊆ for subset relations (B ⊆ A). An element is not a subset, and a set is not an element (usually).
Wrong Quantifier Order
"∀x, ∃y, P(x,y)" and "∃y, ∀x, P(x,y)" mean different things. The first says "for each x, there is some y" (possibly different for each x). The second says "there is one y that works for all x".
Forgetting Negation Rules
When negating quantified statements, flip the quantifier and negate the predicate: ¬(∀x, P(x)) ≡ ∃x, ¬P(x).
Misusing Implication
Remember that P ⟹ Q is true when P is false, regardless of Q. This "vacuous truth" often confuses readers unfamiliar with formal logic.
Inconsistent Set Notation
Do not mix "{1,2,3}" with "(1,2,3)" for sets. Curly braces denote sets; parentheses denote ordered tuples or intervals.

Quick Reference

ConceptKaTeX SyntaxResult
Element ofx \in A$x \in A$
SubsetA \subseteq B$A \subseteq B$
UnionA \cup B$A \cup B$
IntersectionA \cap B$A \cap B$
Empty set\emptyset$\emptyset$
For all\forall x$\forall x$
There exists\exists x$\exists x$
Negation\neg P$\neg P$
ANDP \land Q$P \land Q$
ORP \lor Q$P \lor Q$
ImpliesP \implies Q$P \implies Q$
If and only ifP \iff Q$P \iff Q$
Therefore\therefore$\therefore$

Related Content

Ready to Start?

Start creating beautiful technical documentation with AutEng.

Get Started with AutEng