← Math|72 of 100
Discrete Mathematics

Logic and Proof

Master propositional logic, predicates, quantifiers, and proof techniques.

šŸ“‚ LogicšŸ“– Lesson 72 of 100šŸŽ“ Free Course

Advertisement

Logic and Proof

ā„¹ļø Why It Matters

Logic is the backbone of mathematical reasoning and computer science. Every algorithm, database query, and AI inference engine is built on logical foundations. Propositional logic determines whether programs are correct, circuits function properly, and knowledge bases are consistent. Understanding logic is essential for software verification, automated theorem proving, constraint satisfaction in AI, and formal reasoning in any technical discipline.

Logic gives us a formal language to distinguish truth from falsehood. When you write an if statement, you are making a logical proposition. When a search engine ranks results, it applies logical rules. When a mathematician proves a theorem, they chain logical steps. Mastering discrete logic means mastering the art of precise, unambiguous reasoning.


Propositions

DfProposition

A proposition (or statement) is a declarative sentence that is either true or false, but not both. Examples:

  • "2 + 2 = 4" — true proposition
  • "The moon is made of cheese" — false proposition
  • "x > 3" — not a proposition (x is a variable; truth depends on x)
  • "Sit down!" — not a proposition (imperative, not declarative)

DfLogical Connectives

Propositions can be combined using logical connectives to form compound propositions. The five fundamental connectives are:

ConnectiveSymbolNameRead As
Conjunction∧\landAND"P and Q"
Disjunction∨\lorOR"P or Q"
Negation¬\negNOT"not P"
Conditional→\toIMPLIES"if P then Q"
Biconditional↔\leftrightarrowIFF"P if and only if Q"

DfAtomic and Compound Propositions

An atomic proposition is a simple proposition with no connectives. A compound proposition is formed by combining atomic propositions with connectives. The truth value of a compound proposition is determined by the truth values of its components and the connectives used.


Logical Operators

Conjunction (AND)

P∧Q={Tif P=T and Q=TFotherwiseP \land Q = \begin{cases} T & \text{if } P = T \text{ and } Q = T \\ F & \text{otherwise} \end{cases}

Here,

  • P∧QP \land Q=True only when both P and Q are true
  • P,QP, Q=Propositions (each true or false)

Disjunction (OR)

P∨Q={Fif P=F and Q=FTotherwiseP \lor Q = \begin{cases} F & \text{if } P = F \text{ and } Q = F \\ T & \text{otherwise} \end{cases}

Here,

  • P∨QP \lor Q=True when at least one of P or Q is true
  • P,QP, Q=Propositions (each true or false)

Negation (NOT)

¬P={Tif P=FFif P=T\neg P = \begin{cases} T & \text{if } P = F \\ F & \text{if } P = T \end{cases}

Here,

  • ¬P\neg P=Flips the truth value of P

Conditional (IMPLIES)

P→Q=¬P∨QP \to Q = \neg P \lor Q

Here,

  • P→QP \to Q=False only when P is true and Q is false
  • PP=Antecedent (hypothesis)
  • QQ=Consequent (conclusion)

āš ļø The Conditional Trap

The conditional P → Q is counterintuitive. "If it rains, then the ground is wet" is only false when it rains and the ground is NOT wet. If it doesn't rain, the statement is true regardless of the ground's state. This is because P → Q is defined as ¬P ∨ Q — a false antecedent makes the whole conditional true (vacuously true).

Biconditional (IFF)

P↔Q=(P→Q)∧(Q→P)P \leftrightarrow Q = (P \to Q) \land (Q \to P)

Here,

  • P↔QP \leftrightarrow Q=True when P and Q have the same truth value

Truth Tables

Truth tables exhaustively enumerate all possible input combinations and their resulting outputs. They are the primary tool for analyzing logical expressions.

Basic Truth Tables

PQP∧QP \land QP∨QP \lor Q¬P\neg PP→QP \to QP↔QP \leftrightarrow Q
TTTTFTT
TFFTFFF
FTFTTTF
FFFFTTT

Compound Example

PQRP∧QP \land Q(P∧Q)→R(P \land Q) \to R
TTTTT
TTFTF
TFTFT
TFRFT
FTTFT
FTFFT
FFTFT
FFFFT

šŸ’” Building Truth Tables

For a compound proposition with n distinct atomic propositions, the truth table has 2n2^n rows. List all combinations systematically: the first column alternates T/F every 2nāˆ’12^{n-1} rows, the second every 2nāˆ’22^{n-2} rows, and so on. This ensures every combination is covered exactly once.


Logical Equivalences

Two propositions are logically equivalent if they have identical truth tables — they are true in exactly the same cases.

ThFundamental Logical Equivalences

  1. Double Negation: ¬(¬P)≔P\neg(\neg P) \equiv P
  2. Commutative Laws: P∧Q≔Q∧PP \land Q \equiv Q \land P and P∨Q≔Q∨PP \lor Q \equiv Q \lor P
  3. Associative Laws: (P∧Q)∧R≔P∧(Q∧R)(P \land Q) \land R \equiv P \land (Q \land R) and (P∨Q)∨R≔P∨(Q∨R)(P \lor Q) \lor R \equiv P \lor (Q \lor R)
  4. Distributive Laws: P∧(Q∨R)≔(P∧Q)∨(P∧R)P \land (Q \lor R) \equiv (P \land Q) \lor (P \land R) and P∨(Q∧R)≔(P∨Q)∧(P∨R)P \lor (Q \land R) \equiv (P \lor Q) \land (P \lor R)
  5. Identity Laws: P∧T≔PP \land T \equiv P and P∨F≔PP \lor F \equiv P
  6. Domination Laws: P∨T≔TP \lor T \equiv T and P∧F≔FP \land F \equiv F
  7. Idempotent Laws: P∧P≔PP \land P \equiv P and P∨P≔PP \lor P \equiv P
  8. Absorption Laws: P∨(P∧Q)≔PP \lor (P \land Q) \equiv P and P∧(P∨Q)≔PP \land (P \lor Q) \equiv P

ThImplication Equivalences

  1. Conditional as Disjunction: P→Q≔¬P∨QP \to Q \equiv \neg P \lor Q
  2. Contrapositive: P→Q≔¬Q→¬PP \to Q \equiv \neg Q \to \neg P
  3. Converse: P→QP \to Q is NOT equivalent to Q→PQ \to P
  4. Inverse: P→QP \to Q is NOT equivalent to ¬P→¬Q\neg P \to \neg Q
  5. Biconditional: P↔Q≔(P→Q)∧(Q→P)P \leftrightarrow Q \equiv (P \to Q) \land (Q \to P)

ThDe Morgan's Laws

For any propositions P and Q:

¬(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

In words: The negation of an AND is the OR of the negations. The negation of an OR is the AND of the negations.

Proof of the first law (by truth table):

PQP∧QP \land Q¬(P∧Q)\neg(P \land Q)¬P\neg P¬Q\neg Q¬P∨¬Q\neg P \lor \neg Q
TTTFFFF
TFFTFTT
FTFTTFT
FFFTTTT

Columns 4 and 7 are identical, confirming the equivalence. āˆŽ

šŸ’” De Morgan's in Code

De Morgan's laws are used constantly in programming to simplify conditions. Instead of if not (A and B):, write if not A or not B:. Both are equivalent, but the negated form is sometimes clearer. Compilers and linters often apply these transformations automatically.


Normal Forms

DfLiteral

A literal is an atomic proposition or its negation. Examples: PP, ¬Q\neg Q, RR.

DfConjunctive Normal Form (CNF)

A formula is in Conjunctive Normal Form if it is a conjunction (AND) of one or more clauses, where each clause is a disjunction (OR) of literals.

CNF=(l1,1∨l1,2āˆØā‹Æā€‰)∧(l2,1∨l2,2āˆØā‹Æā€‰)āˆ§ā‹Æ\text{CNF} = (l_{1,1} \lor l_{1,2} \lor \cdots) \land (l_{2,1} \lor l_{2,2} \lor \cdots) \land \cdots

Example: (P∨¬Q)∧(¬P∨Q∨R)(P \lor \neg Q) \land (\neg P \lor Q \lor R)

DfDisjunctive Normal Form (DNF)

A formula is in Disjunctive Normal Form if it is a disjunction (OR) of one or more terms, where each term is a conjunction (AND) of literals.

DNF=(l1,1∧l1,2āˆ§ā‹Æā€‰)∨(l2,1∧l2,2āˆ§ā‹Æā€‰)āˆØā‹Æ\text{DNF} = (l_{1,1} \land l_{1,2} \land \cdots) \lor (l_{2,1} \land l_{2,2} \land \cdots) \lor \cdots

Example: (P∧¬Q)∨(¬P∧Q)(P \land \neg Q) \lor (\neg P \land Q)

ThConversion to CNF

Every proposition can be converted to CNF using these steps:

  1. Eliminate ↔\leftrightarrow using A↔B≔(A→B)∧(B→A)A \leftrightarrow B \equiv (A \to B) \land (B \to A)
  2. Eliminate →\to using A→B≔¬A∨BA \to B \equiv \neg A \lor B
  3. Push negations inward using De Morgan's laws and double negation
  4. Distribute ∧\land over ∨\lor using A∧(B∨C)≔(A∧B)∨(A∧C)A \land (B \lor C) \equiv (A \land B) \lor (A \land C) — wait, distribute ∨\lor over ∧\land for CNF
  5. Distribute ∨\lor over ∧\land using A∨(B∧C)≔(A∨B)∧(A∨C)A \lor (B \land C) \equiv (A \lor B) \land (A \lor C)

šŸ“Converting to CNF

Convert (P→Q)∧R(P \to Q) \land R to CNF.

Step 1: Eliminate implication: (¬P∨Q)∧R(\neg P \lor Q) \land R

This is already in CNF: a conjunction of (¬P∨Q)(\neg P \lor Q) and (R)(R), each a disjunction of literals.

šŸ“Converting to CNF (Complex)

Convert ¬(P→(Q∧R))\neg(P \to (Q \land R)) to CNF.

Step 1: Eliminate implication: ¬(¬P∨(Q∧R))\neg(\neg P \lor (Q \land R)) Step 2: Push negation (De Morgan's): P∧¬(Q∧R)P \land \neg(Q \land R) Step 3: Push negation again: P∧(¬Q∨¬R)P \land (\neg Q \lor \neg R)

Result: P∧(¬Q∨¬R)P \land (\neg Q \lor \neg R) — already in CNF.


Validity and Satisfiability

DfTautology

A tautology is a proposition that is true under every possible assignment of truth values to its atomic propositions. Example: P∨¬PP \lor \neg P is always true.

DfContradiction

A contradiction is a proposition that is false under every possible assignment. Example: P∧¬PP \land \neg P is always false.

DfContingency

A contingency is a proposition that is neither a tautology nor a contradiction — it is true for some assignments and false for others.

DfSatisfiability

A proposition is satisfiable if there exists at least one truth assignment that makes it true. A tautology is satisfiable, but a satisfiable formula is not necessarily a tautology. A contradiction is unsatisfiable.

SAT Problem: Given a propositional formula, determine whether it is satisfiable. This is the first problem proven to be NP-complete (Cook-Levin theorem, 1971), one of the most important results in computational complexity.

ā„¹ļø SAT Solvers in Practice

Despite SAT being NP-complete, modern SAT solvers (MiniSat, CaDiCaL, Kissat) can handle formulas with millions of variables. They use techniques like unit propagation, pure literal elimination, and conflict-driven clause learning (CDCL). SAT solvers are used in hardware verification, software testing, AI planning, and constraint optimization.


Python Implementation

from itertools import product

def truth_table(propositions, expr_func, labels):
    """Generate a truth table for a logical expression."""
    n = len(propositions)
    header = " | ".join(labels) + " | Result"
    print(header)
    print("-" * len(header))

    for combo in product([True, False], repeat=n):
        vals = dict(zip(propositions, combo))
        result = expr_func(**vals)
        row = " | ".join(
            f"{vals[p]:^5}" for p in propositions
        ) + f" | {result:^6}"
        print(row)

# --- Basic Operators ---
def AND(p, q):   return p and q
def OR(p, q):    return p or q
def NOT(p):      return not p
def IMPLIES(p, q): return (not p) or q
def IFF(p, q):   return p == q

# --- Verify De Morgan's Laws ---
def verify_demorgan(n_tests=10000):
    import random
    for _ in range(n_tests):
        A = random.randint(0, 1)
        B = random.randint(0, 1)
        lhs_or = not (A or B)
        rhs_or = (not A) and (not B)
        lhs_and = not (A and B)
        rhs_and = (not A) or (not B)
        assert lhs_or == rhs_or, "De Morgan OR violated!"
        assert lhs_and == rhs_and, "De Morgan AND violated!"
    print("De Morgan's laws verified!")

# --- Tautology Checker (brute force) ---
def is_tautology(propositions, expr_func):
    """Check if expr is true for all truth assignments."""
    for combo in product([True, False], repeat=len(propositions)):
        vals = dict(zip(propositions, combo))
        if not expr_func(**vals):
            return False
    return True

# --- SAT Solver (simple DPLL-style) ---
def solve_dpll(clauses, assignment=None):
    """Simple DPLL satisfiability checker.
    clauses: list of tuples, each tuple is a clause (disjunction of literals).
              Literals are (variable_name, is_positive).
    """
    if assignment is None:
        assignment = {}

    # Simplify clauses based on current assignment
    simplified = []
    for clause in clauses:
        satisfied = False
        new_clause = []
        for (var, pos) in clause:
            if var in assignment:
                if assignment[var] == pos:
                    satisfied = True
                    break
            else:
                new_clause.append((var, pos))
        if not satisfied:
            simplified.append(new_clause)

    # Remove clauses that are subsets of others (not needed for correctness)

    # Check for empty clause (contradiction)
    if any(len(c) == 0 for c in simplified):
        return None

    # All clauses satisfied
    if len(simplified) == 0:
        return assignment

    # Unit propagation: if a clause has one literal, assign it
    for clause in simplified:
        if len(clause) == 1:
            var, pos = clause[0]
            if var not in assignment:
                new_assign = dict(assignment)
                new_assign[var] = pos
                return solve_dpll(simplified, new_assign)

    # Choose an unassigned variable and branch
    all_vars = set()
    for clause in simplified:
        for (var, _) in clause:
            all_vars.add(var)
    unassigned = [v for v in all_vars if v not in assignment]
    if not unassigned:
        return assignment

    var = unassigned[0]
    for val in [True, False]:
        new_assign = dict(assignment)
        new_assign[var] = val
        result = solve_dpll(simplified, new_assign)
        if result is not None:
            return result

    return None

# --- CNF Conversion ---
def to_cnf(p, q):
    """Convert P → Q to CNF and print."""
    # P → Q ≔ ¬P ∨ Q, which is already CNF
    print(f"  P → Q ≔ ¬P ∨ Q (CNF)")
    # Verify equivalence
    for pv, qv in product([True, False], repeat=2):
        impl = IMPLIES(pv, qv)
        cnf = OR(NOT(pv), qv)
        assert impl == cnf, f"CNF mismatch for P={pv}, Q={qv}"
    print("  Verified: P → Q ≔ ¬P ∨ Q")

if __name__ == "__main__":
    print("=== Truth Table: P → Q ===")
    truth_table(["P", "Q"], IMPLIES, ["P", "Q"])

    print("\n=== Truth Table: P ↔ Q ===")
    truth_table(["P", "Q"], IFF, ["P", "Q"])

    print("\n=== De Morgan's Laws ===")
    verify_demorgan()

    print("\n=== Tautology Check ===")
    print(f"P ∨ ¬P is tautology: {is_tautology(['P'], lambda P: OR(P, NOT(P)))}")
    print(f"P ∧ ¬P is tautology: {is_tautology(['P'], lambda P: AND(P, NOT(P)))}")
    print(f"(P → Q) ↔ (¬Q → ¬P) is tautology: {is_tautology(['P', 'Q'], lambda P, Q: IFF(IMPLIES(P,Q), IMPLIES(NOT(Q), NOT(P))))}")

    print("\n=== CNF Conversion ===")
    to_cnf("P", "Q")

    print("\n=== SAT Solver ===")
    # (P ∨ Q) ∧ (¬P ∨ Q) ∧ (P ∨ ¬Q)
    clauses_sat = [
        [("P", True), ("Q", True)],
        [("P", False), ("Q", True)],
        [("P", True), ("Q", False)],
    ]
    result = solve_dpll(clauses_sat)
    print(f"SAT: {clauses_sat}")
    print(f"Satisfying assignment: {result}")

    # (P) ∧ (¬P) — unsatisfiable
    clauses_unsat = [
        [("P", True)],
        [("P", False)],
    ]
    result = solve_dpll(clauses_unsat)
    print(f"\nSAT: {clauses_unsat}")
    print(f"Result: {result}")

Applications in AI/ML

1. Logic Programming (Prolog)

Logic programming languages like Prolog encode knowledge as logical formulas and use unification and resolution to answer queries. A Prolog program is a set of Horn clauses (implications with a single consequent):

Architecture Diagram
ancestor(X, Y) :- parent(X, Y).
ancestor(X, Y) :- parent(X, Z), ancestor(Z, Y).

This directly encodes the logical rule: "X is an ancestor of Y if X is a parent of Y, or if X is a parent of Z and Z is an ancestor of Y."

2. Constraint Satisfaction Problems (CSPs)

Many AI problems are modeled as CSPs, where variables must satisfy logical constraints:

  • Scheduling: Staff shifts must cover all hours, no person works two shifts at once
  • Map coloring: Adjacent regions must have different colors
  • Sudoku: Each row, column, and box contains each digit exactly once

CSP solvers use logical inference (arc consistency, forward checking) combined with search to find satisfying assignments.

3. Knowledge Representation and Reasoning

Description logics and OWL (Web Ontology Language) represent knowledge using logical constructs. Automated reasoners check consistency of ontologies and infer new facts:

  • "All humans are mortal" + "Socrates is human" → "Socrates is mortal"
  • OWL reasoners detect contradictions in biomedical ontologies with millions of axioms

4. Hardware Verification

SAT solvers and model checkers verify that digital circuits satisfy their specifications. A circuit with nn inputs can be modeled as a Boolean formula; satisfiability of its negation indicates a bug.

5. AI Planning (SATPlan)

The planning problem — finding a sequence of actions to reach a goal — can be encoded as SAT. Each action and time step generates Boolean variables, and constraints ensure action preconditions are met. Modern planners encode planning as SAT and use CDCL solvers to find plans efficiently.

6. Neural Network Verification

Verifying that a neural network's output is correct within input bounds (e.g., a self-driving car always stops at red) is formulated as a satisfiability problem over piecewise-linear functions.


Common Mistakes

MistakeWhy It's WrongCorrect Approach
Confusing →\to with ↔\leftrightarrowP→QP \to Q means "if P then Q"; P↔QP \leftrightarrow Q means "P if and only if Q"Use →\to for one-directional implication, ↔\leftrightarrow for equivalence
Thinking P→QP \to Q means P causes QP→QP \to Q is true whenever P is false, regardless of QP→QP \to Q is equivalent to ¬P∨Q\neg P \lor Q, not "P causes Q"
Assuming ¬(P→Q)≔P→¬Q\neg(P \to Q) \equiv P \to \neg QThis is false. ¬(P→Q)≔P∧¬Q\neg(P \to Q) \equiv P \land \neg QNegation of implication: ¬(P→Q)≔P∧¬Q\neg(P \to Q) \equiv P \land \neg Q
Forgetting P→QP \to Q is true when P is falseA false antecedent makes the conditional vacuously trueCheck truth table: F→F=TF \to F = T and F→T=TF \to T = T
Confusing De Morgan's: ¬(P∨Q)=¬P∨¬Q\neg(P \lor Q) = \neg P \lor \neg QWrong! The negation of OR becomes ANDDe Morgan's: ¬(P∨Q)≔¬P∧¬Q\neg(P \lor Q) \equiv \neg P \land \neg Q
Thinking ∧\land distributes over ∨\lor the same wayBoth distribute, but the result is differentP∧(Q∨R)≔(P∧Q)∨(P∧R)P \land (Q \lor R) \equiv (P \land Q) \lor (P \land R); P∨(Q∧R)≔(P∨Q)∧(P∨R)P \lor (Q \land R) \equiv (P \lor Q) \land (P \lor R)
Confusing contrapositive with converseContrapositive: P→Q≔¬Q→¬PP \to Q \equiv \neg Q \to \neg P. Converse: Q→PQ \to P (NOT equivalent)Only contrapositive is logically equivalent to the original
Writing ¬(P∧Q)≔¬P∧¬Q\neg(P \land Q) \equiv \neg P \land \neg QThis is the most common De Morgan error¬(P∧Q)≔¬P∨¬Q\neg(P \land Q) \equiv \neg P \lor \neg Q (AND becomes OR)

Interview Questions

Q1: What is the truth table for the conditional? Why is "if False then True" true?

šŸ’”Answer

The conditional P → Q is false only when P is true and Q is false. All other cases are true:

PQP → Q
TTT
TFF
FTT
FFT

"If False then True" is true because the conditional makes a promise only about what happens when P is true. If P is false, the promise is not broken — it's vacuously true. Think of it as a contract: "If it rains, I'll bring an umbrella." If it doesn't rain, you haven't broken the contract regardless of whether you bring an umbrella.

Q2: Prove that the conditional and biconditional are not equivalent.

šŸ’”Answer

Consider P = True, Q = False:

  • P→Q=FP \to Q = F
  • P↔Q=FP \leftrightarrow Q = F

Now consider P = False, Q = True:

  • P→Q=TP \to Q = T
  • P↔Q=FP \leftrightarrow Q = F

Since they differ when P = F and Q = T, they are not equivalent. The conditional is asymmetric (P→Q ≠ Q→P), while the biconditional is symmetric.

Q3: Convert ¬(P→(Q∧¬R))\neg(P \to (Q \land \neg R)) to CNF.

šŸ’”Answer

Step 1: Eliminate →\to: ¬(¬P∨(Q∧¬R))\neg(\neg P \lor (Q \land \neg R))

Step 2: De Morgan's: P∧¬(Q∧¬R)P \land \neg(Q \land \neg R)

Step 3: De Morgan's: P∧(¬Q∨R)P \land (\neg Q \lor R)

CNF: P∧(¬Q∨R)P \land (\neg Q \lor R)

This is a conjunction of two clauses: (P)(P) and (¬Q∨R)(\neg Q \lor R).

Q4: Explain the SAT problem and why it matters for computer science.

šŸ’”Answer

The SAT problem asks: given a propositional formula, does there exist a truth assignment that makes it true? Cook and Levin proved SAT is NP-complete in 1971, meaning:

  1. Any problem in NP can be reduced to SAT in polynomial time
  2. If SAT has a polynomial-time solution, then P = NP
  3. SAT serves as a "universal" NP problem — solving it efficiently would solve all NP problems efficiently

Despite this worst-case hardness, modern SAT solvers are extremely fast in practice for structured problems. They are used in hardware verification (Intel, AMD verify CPUs with SAT), software testing (symbolic execution), AI planning, and constraint optimization.

Q5: What is the difference between tautology, satisfiability, and validity?

šŸ’”Answer

  • Tautology: True for ALL truth assignments (e.g., P ∨ ¬P). Always satisfiable.
  • Contradiction: False for ALL truth assignments (e.g., P ∧ ¬P). Never satisfiable.
  • Contingency: True for some, false for others (e.g., P ∨ Q). Satisfiable but not a tautology.
  • Satisfiable: True for AT LEAST ONE assignment. Includes tautologies and contingencies.
  • Valid: A formula is valid if it is a tautology — true under every interpretation.

A formula is valid ⟺ its negation is unsatisfiable ⟺ it is a tautology.

Q6: How does De Morgan's law apply to programming?

šŸ’”Answer

De Morgan's laws simplify complex boolean conditions:

# Instead of:
if not (age >= 18 and has_id):
    deny()

# Write:
if age < 18 or not has_id:
    deny()

Both are equivalent. The transformed version is often more readable because each condition is simpler. Compilers and static analyzers use De Morgan's laws to simplify expressions, optimize condition checks, and improve error message generation.


Practice Problems

Problem 1: Truth Table Construction

šŸ“Practice Problem 1

Construct the truth table for (P→Q)∧(Q→P)(P \to Q) \land (Q \to P). What does this formula represent?

šŸ’”Solution

PQP→QQ→P(P→Q)∧(Q→P)
TTTTT
TFFTF
FTTFF
FFTTT

This is P↔QP \leftrightarrow Q — the biconditional. It's true exactly when P and Q have the same truth value.

Problem 2: Logical Equivalence

šŸ“Practice Problem 2

Show that P→(Q→R)P \to (Q \to R) is logically equivalent to (P∧Q)→R(P \land Q) \to R.

šŸ’”Solution

Left side: P→(Q→R)≔¬P∨(¬Q∨R)≔¬P∨¬Q∨RP \to (Q \to R) \equiv \neg P \lor (\neg Q \lor R) \equiv \neg P \lor \neg Q \lor R

Right side: (P∧Q)→R≔¬(P∧Q)∨R≔¬P∨¬Q∨R(P \land Q) \to R \equiv \neg(P \land Q) \lor R \equiv \neg P \lor \neg Q \lor R

Both simplify to ¬P∨¬Q∨R\neg P \lor \neg Q \lor R, so they are equivalent. āˆŽ

Problem 3: CNF Conversion

šŸ“Practice Problem 3

Convert ¬P→(Q∧R)\neg P \to (Q \land R) to CNF.

šŸ’”Solution

Step 1: Eliminate →\to: ¬(¬P)∨(Q∧R)≔P∨(Q∧R)\neg(\neg P) \lor (Q \land R) \equiv P \lor (Q \land R)

Step 2: Distribute ∨\lor over ∧\land: (P∨Q)∧(P∨R)(P \lor Q) \land (P \lor R)

CNF: (P∨Q)∧(P∨R)(P \lor Q) \land (P \lor R) — a conjunction of two clauses, each a disjunction of two literals.

Problem 4: Satisfiability

šŸ“Practice Problem 4

Determine whether (P∨Q)∧(¬P∨Q)∧(P∨¬Q)∧(¬P∨¬Q)(P \lor Q) \land (\neg P \lor Q) \land (P \lor \neg Q) \land (\neg P \lor \neg Q) is satisfiable.

šŸ’”Solution

Try all four assignments:

  • P=T, Q=T: (T∨T)∧(F∨T)∧(T∨F)∧(F∨F)=T∧T∧T∧F=F(T \lor T) \land (F \lor T) \land (T \lor F) \land (F \lor F) = T \land T \land T \land F = F
  • P=T, Q=F: (T∨F)∧(F∨F)∧(T∨T)∧(F∨T)=T∧F∧T∧T=F(T \lor F) \land (F \lor F) \land (T \lor T) \land (F \lor T) = T \land F \land T \land T = F
  • P=F, Q=T: (F∨T)∧(T∨T)∧(F∨F)∧(T∨F)=T∧T∧F∧T=F(F \lor T) \land (T \lor T) \land (F \lor F) \land (T \lor F) = T \land T \land F \land T = F
  • P=F, Q=F: (F∨F)∧(T∨F)∧(F∨T)∧(T∨T)=F∧T∧T∧T=F(F \lor F) \land (T \lor F) \land (F \lor T) \land (T \lor T) = F \land T \land T \land T = F

No assignment satisfies the formula. It is unsatisfiable (a contradiction).

Problem 5: Prove Using Logical Equivalences

šŸ“Practice Problem 5

Prove that P→QP \to Q is logically equivalent to ¬Q→¬P\neg Q \to \neg P using equivalences only (no truth tables).

šŸ’”Solution

P→QP \to Q

≔¬P∨Q\equiv \neg P \lor Q (conditional as disjunction)

≔Q∨¬P\equiv Q \lor \neg P (commutativity of ∨\lor)

≔¬(¬Q)∨¬P\equiv \neg(\neg Q) \lor \neg P (double negation on Q)

≔¬Q→P\equiv \neg Q \to P (conditional as disjunction, in reverse)

Wait — this gives ¬Q→P\neg Q \to P, not ¬Q→¬P\neg Q \to \neg P. Let me redo:

P→Q≔¬P∨QP \to Q \equiv \neg P \lor Q

We want ¬Q→¬P≔¬(¬Q)∨¬P≔Q∨¬P≔¬P∨Q\neg Q \to \neg P \equiv \neg(\neg Q) \lor \neg P \equiv Q \lor \neg P \equiv \neg P \lor Q

Both equal ¬P∨Q\neg P \lor Q. āˆŽ


Quick Reference

ConceptFormula / DefinitionKey Insight
AND (∧\land)P∧QP \land QTrue only when both true
OR (∨\lor)P∨QP \lor QFalse only when both false
NOT (¬\neg)¬P\neg PFlips truth value
IMPLIES (→\to)P→Q≔¬P∨QP \to Q \equiv \neg P \lor QFalse only when T → F
IFF (↔\leftrightarrow)P↔QP \leftrightarrow QTrue when same truth value
De Morgan (OR)¬(P∨Q)≔¬P∧¬Q\neg(P \lor Q) \equiv \neg P \land \neg QNegation of OR is AND of negations
De Morgan (AND)¬(P∧Q)≔¬P∨¬Q\neg(P \land Q) \equiv \neg P \lor \neg QNegation of AND is OR of negations
ContrapositiveP→Q≔¬Q→¬PP \to Q \equiv \neg Q \to \neg PEquivalent to original conditional
CNF(l1∨l2āˆØā‹Æā€‰)āˆ§ā‹Æ(l_1 \lor l_2 \lor \cdots) \land \cdotsAND of ORs
DNF(l1∧l2āˆ§ā‹Æā€‰)āˆØā‹Æ(l_1 \land l_2 \land \cdots) \lor \cdotsOR of ANDs
TautologyAlways trueExample: P∨¬PP \lor \neg P
ContradictionAlways falseExample: P∧¬PP \land \neg P
SatisfiableTrue for some assignmentTautologies are satisfiable
SAT ProblemIs a formula satisfiable?First NP-complete problem

Cross-References

  • Set Theory — set operations and De Morgan's laws in the set context — the logical operators and set operations share identical algebraic structure (AND ↔ Intersection, OR ↔ Union, NOT ↔ Complement)
  • Boolean Algebra — Boolean algebra, switching circuits, and gate-level implementations of logical operators
  • Combinatorics — counting techniques used in logical enumeration and proof by exhaustion
  • Graph Theory — logical constraints in graph coloring and path problems
  • Automata Theory — how logical formulas define regular languages and finite automata
  • Information Theory — the connection between logical uncertainty and Shannon entropy
  • Discrete Mathematics Applications — applied uses of logic in cryptography, coding theory, and verification
Lesson Progress72 / 100