N

Mathematical Logic

An introduction to propositions, logical connectives, conditional statements, logical equivalences, satisfiability, predicates, and quantifiers.

Introduction

Have you ever wondered how computers process complex reasoning, run bug-free software, or solve intricate puzzles in milliseconds? At the heart of computer science and mathematics lies logic—the formal framework that provides precise meaning to statements and eliminates ambiguity. Without logic, establishing software security, building artificial intelligence, or constructing mathematical proofs would be impossible.

By the end of this lesson, you will be able to:

  • Distinguish between propositions and non-propositions and evaluate truth values using logical connectives.
  • Formulate conditional statements alongside their converse, inverse, contrapositive, and biconditional forms.
  • Verify logical equivalences, tautologies, and satisfiability using truth tables and algebraic laws.
  • Translate natural language sentences into formal logic using predicates and quantifiers.

The Building Blocks of Thought – Propositions and Logical Connectives

To build a rigorous logical argument, we must begin with the fundamental unit of logic: the proposition. A proposition is a declarative sentence that is either true (T) or false (F), but not both.

Consider these declarative sentences:

  1. "Washington, D.C., is the capital of the United States." — True proposition (T)
  2. "1 + 1 = 2" — True proposition (T)
  3. "Toronto is the capital of Canada." — False proposition (F)
  4. "2 + 2 = 3" — False proposition (F)

In contrast, non-declarative sentences or open expressions are not propositions:

  • "What time is it?" (A question—neither true nor false)
  • "Read this carefully." (A command)
  • "x + 1 = 2" (Neither true nor false until a value is assigned to xx)

Propositional Variables and Atomic Propositions

We denote propositional variables using lowercase letters such as p,q,r,p, q, r, and ss. An atomic proposition is one that cannot be broken down into simpler propositions. To construct complex statements, we combine atomic propositions using logical operators (also called connectives).

The Fundamental Operators

  1. Negation (¬p\neg p or pˉ\bar{p}) The negation of pp is the statement "It is not the case that pp." It reverses the truth value of pp.
    • Example: If pp is "Michael's PC runs Linux," then ¬p\neg p is "Michael's PC does not run Linux."
  2. Conjunction (p∧qp \land q) The conjunction represents the statement "pp and qq." It is true only when both pp and qq are true; otherwise, it is false.
    • Note: In English, words like "but" function identically to "and" in logic (e.g., "The sun is shining, but it is raining").
  3. Disjunction (p∨qp \lor q) The disjunction represents "pp or qq." Logic uses the inclusive OR: p∨qp \lor q is true if at least one of pp or qq is true, and false only when both are false.
  4. Exclusive OR (p⊕qp \oplus q) The exclusive OR (XOR) is true when exactly one of pp and qq is true, but false when both are true or both are false.
    • Example: "A student can have soup or salad with dinner" implies you can choose one, but not both.

Truth Tables and Bit Operations

A truth table displays the truth value of a compound proposition for every possible combination of truth values of its variables.

ppqq¬p\neg pp∧qp \land qp∨qp \lor qp⊕qp \oplus q
TTFTTF
TFFFTT
FTTFTT
FFTFFF

In computer logic, truth values are represented as bits: 1 for True (T) and 0 for False (F). Bitwise operations apply AND, OR, and XOR bit-by-bit across equal-length bit strings.

  • Example: Bitwise XOR of 01 1011 and 11 0001 yields 10 1010.

Implication and Equivalence – Conditional and Biconditional Statements

Conditional statements are the backbone of mathematical proofs and programming logic. They express that a statement holds under a specific condition.

The Conditional Statement (p→qp \rightarrow q)

Let pp and qq be propositions. The conditional statement p→qp \rightarrow q is read "If pp, then qq." Here, pp is the hypothesis (or premise) and qq is the conclusion (or consequence).

Key Rule: p→qp \rightarrow q is false only when pp is true and qq is false. In all other cases, it is true.

Think of p→qp \rightarrow q as a campaign contract: "If I am elected (pp), then I will lower taxes (qq)."

  • If the politician is elected (pp is T) and lowers taxes (qq is T), the promise is kept (T).
  • If elected (pp is T) but taxes are not lowered (qq is F), the promise is broken (F).
  • If the politician loses (pp is F), the contract is not broken, regardless of whether taxes change (T).

Common natural language expressions for p→qp \rightarrow q include:

  • "pp implies qq" | "pp is sufficient for qq" | "qq whenever pp"
  • "qq is necessary for pp" | "pp only if qq" | "qq unless ¬p\neg p"

Given a conditional statement p→qp \rightarrow q, three related conditional statements can be formed:

  1. Converse: q→pq \rightarrow p
  2. Inverse: ¬p→¬q\neg p \rightarrow \neg q
  3. Contrapositive: ¬q→¬p\neg q \rightarrow \neg p

Crucial Insight: A conditional statement p→qp \rightarrow q and its contrapositive ¬q→¬p\neg q \rightarrow \neg p always share the exact same truth values. However, the converse and inverse do not necessarily match the truth value of the original statement.

Example: Consider "If it is raining, then the home team wins."

  • Contrapositive: "If the home team does not win, then it is not raining." (Logically equivalent)
  • Converse: "If the home team wins, then it is raining." (Not equivalent)
  • Inverse: "If it is not raining, then the home team does not win." (Not equivalent)

The Biconditional Statement (p↔qp \leftrightarrow q)

The biconditional statement p↔qp \leftrightarrow q is read "pp if and only if qq" (or "pp iff qq"). It is true when pp and qq have the same truth values, and false otherwise.

Operator Precedence

To minimize parentheses in complex expressions, logical operators follow a strict order of precedence:

  1. Negation (¬\neg)
  2. Conjunction (∧\land)
  3. Disjunction (∨\lor)
  4. Conditional (→\rightarrow)
  5. Biconditional (↔\leftrightarrow)

Logical Equivalences and Satisfiability – The Algebra of Truth

In mathematical arguments, replacing a complex statement with a simpler, logically equivalent statement is a essential technique.

Tautologies, Contradictions, and Contingencies

  • Tautology: A compound proposition that is always true regardless of variable values (e.g., p∨¬pp \lor \neg p).
  • Contradiction: A compound proposition that is always false (e.g., p∧¬pp \land \neg p).
  • Contingency: A compound proposition that is neither a tautology nor a contradiction (e.g., p→qp \rightarrow q).

Compound propositions pp and qq are logically equivalent (p≡qp \equiv q or p  ⟺  qp \iff q) if p↔qp \leftrightarrow q is a tautology.

Key Logical Equivalence Laws

  • De Morgan's Laws: ¬(p∧q)≡¬p∨¬q\neg(p \land q) \equiv \neg p \lor \neg q ¬(p∨q)≡¬p∧¬q\neg (p \lor q) \equiv\neg p \land \neg q
  • Conditional-Disjunction Equivalence: p→q≡¬p∨qp \rightarrow q \equiv\neg p \lor q
  • Distributive Laws: p∨(q∧r)≡(p∨q)∧(p∨r)p \lor (q \land r) \equiv (p \lor q) \land (p \lor r) p∧(q∨r)≡(p∧q)∨(p∧r)p \land (q \lor r) \equiv (p \land q) \lor (p \land r)
  • Absorption Laws: p∨(p∧q)≡pp \lor (p \land q) \equiv p p∧(p∨q)≡pp \land (p \lor q) \equiv p

Proving Equivalences Without Truth Tables

Proving equivalences using truth tables requires 2n2^n rows for nn variables. For large nn, algebraic manipulation using established equivalences is far more efficient.

Example: Show that ¬(p→q)≡p∧¬q\neg(p \rightarrow q) \equiv p \land\neg q.

¬(p→q)≡¬(¬p∨q)via Conditional Equivalence≡¬(¬p)∧¬qvia De Morgan’s Law≡p∧¬qvia Double Negation Law\begin{aligned} \neg(p \rightarrow q) &\equiv \neg(\neg p \lor q) && \text{via Conditional Equivalence} \\ &\equiv \neg(\neg p) \land \neg q && \text{via De Morgan's Law} \\ &\equiv p \land \neg q && \text{via Double Negation Law} \end{aligned}

Satisfiability (SAT)

A compound proposition is satisfiable if there is at least one assignment of truth values to its variables that makes it true. If all assignments make it false, it is unsatisfiable.

Real-world applications of satisfiability include:

  • nn-Queens Problem: Placing nn chess queens on an n×nn \times n board so no two queens attack each other.
  • Sudoku: Modeling grid constraints as conjunctions of propositions to allow SAT solvers to solve puzzles in under 10 milliseconds.

Expanding Logic Beyond Fixed Truths – Predicates and Quantifiers

Propositional logic cannot express assertions that apply to groups of objects, such as "Every computer connected to the network is functioning properly." To express these mathematical assertions, we use predicate logic.

Predicates and Propositional Functions

A predicate refers to a property or characteristic of a subject variable. In the statement "x>3x > 3", xx is the variable subject and "is greater than 3" is the predicate.

We denote this statement as P(x)P(x), where PP is the propositional function. P(x)P(x) becomes a proposition with a distinct truth value once xx is assigned a value:

  • For P(x)=x>3P(x) = x > 3: P(4)P(4) is True, while P(2)P(2) is False.
  • Multivariable predicates Q(x,y)=x=y+3Q(x, y) = x = y + 3: Q(3,0)Q(3, 0) is True, while Q(1,2)Q(1, 2) is False.

In computer programming, predicates define preconditions (valid input states) and postconditions (expected output states) to prove code correctness.

Quantifiers

Quantification expresses the extent to which a predicate applies over a domain of discourse (the domain).

  1. Universal Quantifier (∀xP(x)\forall x P(x)) States that P(x)P(x) is true for every value of xx in the domain. A single counterexample (an element where P(x)P(x) is false) refutes a universally quantified statement.
    • Example: ∀x(x2≥x)\forall x (x^2 \ge x) is False over real numbers (e.g., x=0.5x = 0.5), but True over positive integers.
  2. Existential Quantifier (∃xP(x)\exists x P(x)) States that there is at least one element xx in the domain for which P(x)P(x) is true.
    • Example: ∃x(x>3)\exists x (x > 3) is True over real numbers because x=4x = 4 satisfies it.
  3. Uniqueness Quantifier (∃!xP(x)\exists! x P(x)) States that there exists one and only one element xx in the domain such that P(x)P(x) is true.

Negating Quantified Expressions

Negating quantifiers flips the quantifier type and negates the inner predicate. These rules are known as De Morgan's Laws for Quantifiers:

NegationEquivalent StatementWhen True?When False?
¬∀xP(x)\neg \forall x P(x)∃x¬P(x)\exists x \neg P(x)There is an xx for which P(x)P(x) is false.P(x)P(x) is true for every xx.
¬∃xP(x)\neg \exists x P(x)$\forall x\neg P(x)$$P(x)P(x) is false for every xx.There is an xx for which P(x)P(x) is true.

Example: Negating "All Americans eat cheeseburgers" (∀xC(x)\forall x C(x)) yields "There is an American who does not eat cheeseburgers" (∃x¬C(x)\exists x \neg C(x)).

Logic Programming (Prolog)

In AI and automated reasoning, declarative languages like Prolog use predicate logic rules and facts to answer complex database queries:

instructor(chan, math273).
enrolled(kevin, math273).
teaches(P, S) :- instructor(P, C), enrolled(S, C).

Querying ?teaches(X, kevin) leads Prolog to evaluate the logical assertions and return X = chan.

Summary

Mathematical logic forms the rigorous foundation for all formal reasoning, software development, and circuit design. By moving from basic propositional connectives to predicate logic and quantifiers, we gain the tools to eliminate ambiguity and analyze complex systems systematically.

Key Takeaways

  • Propositions are declarative statements with fixed truth values (T or F).
  • Connectives (¬,∧,∨,⊕,→,↔\neg, \land, \lor, \oplus, \rightarrow, \leftrightarrow) combine atomic propositions into compound expressions.
  • Conditional Statements (p→qp \rightarrow q) are false only when the hypothesis is true and the conclusion is false; a conditional statement is logically equivalent only to its contrapositive (¬q→¬p\neg q \rightarrow\neg p).
  • Logical Equivalences (such as De Morgan's Laws) allow complex propositions to be simplified algebraically without huge truth tables.
  • Predicates & Quantifiers (∀,∃\forall, \exists) extend propositional logic to analyze properties over specified domains, forming the basis for logic programming and automated verification.