Course contentsShow
← Computer Science
Lesson 36 of 2,8722. Discrete Mathematics for CSFree lesson

Conditional Statements (Implication)

Master if-then statements, understand why false implies anything, and learn the truth table for implication.

Conditional Statements (Implication)

You'll learn: How "if P, then Q" statements work in logic and why their truth table might surprise you.

What is Implication?

In logic, an implication (or conditional statement) has the form "if P, then Q," written as P → Q. P is called the hypothesis (or antecedent), and Q is called the conclusion (or consequent).

Think of it as a promise: "If it rains, then I'll bring an umbrella."

The Truth Table

Here's where it gets interesting:

PQP → Q
TTT
TFF
FTT
FFT

The implication is only false when P is true but Q is false—that's a broken promise. In our example: it rained, but I didn't bring an umbrella.

Why Does False Imply Anything?

When P is false, the implication is automatically true regardless of Q. This seems odd at first.

Analogy: If I say "If I win the lottery, I'll buy you a car," and I never win the lottery, did I lie? No! The promise only applies if the condition happens. Since it didn't, you can't call me a liar—the statement holds true by default.

In programming terms: if the condition never triggers, the consequence is irrelevant. A false hypothesis makes the entire conditional statement vacuously true.

Practical Connection

You've already seen AND, OR, and XOR gates. Implication isn't typically a physical gate, but it appears in logical reasoning about programs: "If the input is valid, then the output is correct" must be verified in testing.

Key Takeaway: P → Q is false only when P is true and Q is false; otherwise it's true. A false hypothesis makes any implication automatically true.