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

Converse, Inverse, and Contrapositive

Learn to transform conditional statements and understand which transformations preserve logical equivalence.

Converse, Inverse, and Contrapositive

What you'll learn: How to transform conditional statements in three distinct ways and recognize that only one transformation is logically equivalent to the original.

The Core Idea

When you have a conditional statement (implication) p → q ("if p, then q"), you can create three related statements by flipping or negating parts of it:

  • Converse: Swap the hypothesis and conclusion: q → p ("if q, then p")
  • Inverse: Negate both parts: ¬p → ¬q ("if not p, then not q")
  • Contrapositive: Swap and negate both parts: ¬q → ¬p ("if not q, then not p")

Why This Matters

Only the contrapositive is logically equivalent to the original statement. If p → q is true, then ¬q → ¬p is always true. But the converse and inverse might be true or false—they're independent statements.

Example

Original: "If it's raining (p), then the ground is wet (q)."

  • Converse (q → p): "If the ground is wet, then it's raining." — Not necessarily true! (Someone could have used a hose)
  • Inverse (¬p → ¬q): "If it's not raining, then the ground is not wet." — Not necessarily true! (Same reason)
  • Contrapositive (¬q → ¬p): "If the ground is not wet, then it's not raining." — Always true! (If it were raining, the ground would be wet)

In Computer Science

When debugging or proving code correctness, you can use the contrapositive to reason backwards: instead of proving "if input is valid → output is correct," you can prove "if output is incorrect → input was invalid," which is sometimes easier.

Key Takeaway: The contrapositive ¬q → ¬p is logically equivalent to p → q, but the converse and inverse are not—they're separate statements that may or may not be true.