modus tollens
on this page
overview
modus tollens (latin: “method of denying”) is the logical rule for reasoning backwards from consequences to causes. when an expected result doesn’t occur, we can conclude that the condition that would have caused it wasn’t met.
formal structure:
this reads as: “if P implies Q, and Q is false, then P is false.”
formal characterization
logical form
premise 1: P → Q (if P then Q)
premise 2: ¬Q (Q is false)
conclusion: ¬P (therefore P is false)
this “backwards reasoning” pattern can be visualized as elimination logic:
Visual representation of how modus tollens eliminates possibilities through backwards reasoning
truth table verification
modus tollens is valid because whenever both premises are true, the conclusion must be true:
P | Q | P→Q | ¬Q | ¬P (conclusion) | valid? |
---|---|---|---|---|---|
T | T | T | F | (premise 2 false) | N/A |
T | F | F | T | (premise 1 false) | N/A |
F | T | T | F | (premise 2 false) | N/A |
F | F | T | T | T | ✓ |
the only row where both premises are true is row 4, where the conclusion is also true.
relationship to contraposition
modus tollens is equivalent to applying modus ponens to the contrapositive:
- original:
- contrapositive:
- modus tollens:
- equivalent: (modus ponens)
examples
basic diagnostic reasoning
if the power is on, then the light works
the light doesn't work
therefore, the power is not on
this eliminates “power failure” as a possible cause of the light not working.
scientific falsification
if the hypothesis is correct, then we should observe effect X
we do not observe effect X
therefore, the hypothesis is incorrect
this is the foundation of karl popper’s philosophy of scientific falsification.
everyday troubleshooting
if the car has gas, then it will start
the car won't start
therefore, the car doesn't have gas (or gas isn't the only issue)
note: this eliminates one possible cause but doesn’t rule out others.
logical debugging
if the function is called correctly, then no error occurs
an error occurred
therefore, the function was not called correctly
mathematical proof
if n is odd, then n² is odd
n² is even
therefore, n is even
this is often used in proof by contradiction.
advanced applications
elimination reasoning
modus tollens systematically eliminates possibilities:
if suspect was at the scene, then their fingerprints would be there
no fingerprints were found
therefore, suspect was not at the scene
if the network cable is faulty, then the connection would drop frequently
the connection is stable
therefore, the network cable is not faulty
if the medication is effective, then symptoms would improve within 24 hours
symptoms haven't improved after 48 hours
therefore, this medication is not effective (for this patient)
multiple hypothesis testing
using modus tollens on several competing explanations:
hypothesis 1: if server overload, then response time > 5 seconds
hypothesis 2: if database corruption, then query errors increase
hypothesis 3: if network issues, then packet loss > 2%
observations:
- response time = 2 seconds → server overload eliminated
- no query errors → database corruption eliminated
- packet loss = 5% → network issues supported
complex conditional reasoning
if (user is authenticated AND has permission), then access is granted
access was denied
therefore, (user is not authenticated OR lacks permission)
note how modus tollens on a conjunction yields a disjunction of negations (de morgan’s law).
common misconceptions
confusing with denying the antecedent
invalid pattern (fallacy):
if P then Q
P is false
therefore, Q is false (INVALID)
correct modus tollens:
if P then Q
Q is false
therefore, P is false ✓
the key difference: modus tollens denies the consequent (Q), not the antecedent (P).
overlooking alternative causes
misconception: “if one cause is eliminated, the effect can’t occur”
reality: many effects have multiple possible causes
example:
if it rains, then the ground is wet
the ground is not wet
therefore, it didn't rain ✓
but this doesn't mean wetness only comes from rain
(sprinklers, spilled water, melting snow, etc.)
assuming exhaustive conditions
misconception: “if the obvious cause is ruled out, there’s no explanation”
reality: there may be causes we haven’t considered
example:
if the battery is dead, then the car won't start
the car won't start
therefore... we can't conclude anything about the battery!
(this would be affirming the consequent)
correct approach:
if the battery is dead, then the starter won't turn
the starter is turning normally
therefore, the battery is not dead
practical applications
software debugging
hypothesis-driven debugging using modus tollens:
# hypothesis: if input validation fails, then error message appears
# observation: no error message
# conclusion: input validation didn't fail
def debug_login_issue():
# if password is wrong, then "invalid password" message shows
if no_password_error_message():
password_is_correct = True
# if username doesn't exist, then "user not found" message shows
if no_user_not_found_message():
username_exists = True
# continue eliminating possibilities...
medical diagnosis
differential diagnosis by elimination:
if patient has strep throat, then throat culture would be positive
throat culture is negative
therefore, patient doesn't have strep throat
if patient has appendicitis, then white blood cell count would be elevated
wbc count is normal
therefore, patient doesn't have appendicitis
continue testing other hypotheses...
system administration
network troubleshooting:
# if dns is misconfigured, then nslookup would fail
$ nslookup google.com
# success → dns is not misconfigured
# if firewall blocks port 80, then telnet to port 80 would fail
$ telnet server 80
# success → firewall is not blocking port 80
# if ssl certificate expired, then https connection would fail
$ curl https://server
# success → ssl certificate hasn't expired
security analysis
attack vector elimination:
if attacker used sql injection, then database logs would show malformed queries
database logs show no malformed queries
therefore, attacker didn't use sql injection
if attacker gained access via compromised credentials, then login logs would show unusual patterns
login logs show normal patterns
therefore, credentials weren't compromised
continue checking other attack vectors...
relationship to other inference rules
complement to modus ponens
- modus ponens: confirms by affirming →
- modus tollens: eliminates by denying →
both are equally valid and often used together:
rule: if authenticated, then access granted
scenario 1: user authenticated → access granted (modus ponens)
scenario 2: access denied → user not authenticated (modus tollens)
enables disjunctive syllogism
modus tollens can set up disjunctive syllogism:
either A or B is the cause
if A were the cause, then X would happen
X didn't happen
therefore, A is not the cause (modus tollens)
therefore, B is the cause (disjunctive syllogism)
contrapositive reasoning
modus tollens is essentially modus ponens applied to the contrapositive:
original conditional: if program is correct, then tests pass
contrapositive: if tests fail, then program is incorrect
modus tollens application: tests failed → program is incorrect
implementation in automated systems
rule-based systems
class ModusTollens:
def __init__(self, conditional, negated_consequent):
self.conditional = conditional # P → Q
self.negated_consequent = negated_consequent # ¬Q
def apply(self):
if (self.negated_consequent.statement == self.conditional.consequent and
self.negated_consequent.is_true()):
return Negation(self.conditional.antecedent)
return None
backward chaining
modus tollens is crucial for backward chaining inference:
% rule: mortal(X) :- human(X)
% goal: prove mortal(socrates)
% backward chain: to prove mortal(socrates), prove human(socrates)
% if goal fails at any step, modus tollens eliminates that path
constraint satisfaction
# if variable X = value, then constraint C must be satisfied
# constraint C is violated
# therefore, X ≠ value (eliminate this assignment)
def eliminate_inconsistent_values(variable, constraint):
for value in variable.domain:
if implies(variable == value, constraint.satisfied()):
if not constraint.satisfied():
variable.domain.remove(value) # modus tollens
philosophical significance
karl popper and falsification
popper argued that scientific theories should be falsifiable - capable of being proven wrong. modus tollens is the logical foundation:
if theory T is correct, then we should observe O
we don't observe O
therefore, theory T is incorrect
this makes modus tollens central to scientific methodology.
proof by contradiction
modus tollens enables reductio ad absurdum:
assume: P is true
derive: if P then Q (through valid reasoning)
observe: ¬Q (contradiction with known facts)
conclude: ¬P (original assumption was false)
critical thinking
modus tollens teaches us to:
- question assumptions when expected results don’t occur
- systematically eliminate possibilities
- reason backwards from effects to causes
- test hypotheses through their predictions
advanced topics
fuzzy logic extensions
in fuzzy logic, modus tollens becomes:
if P(x) then Q(y) with confidence C
Q(y) is false with confidence F
therefore, P(x) is false with confidence min(C,F)
temporal logic
with temporal operators:
if P holds at time t, then Q will hold at time t+1
Q doesn't hold at time t+1
therefore, P didn't hold at time t
modal logic
with necessity and possibility:
if necessarily P, then possibly Q
not possibly Q (impossible Q)
therefore, not necessarily P
practice exercises
identify valid applications
which correctly apply modus tollens?
-
if the file exists, then the program runs / the program didn’t run / therefore, the file doesn’t exist ✓
-
if the file exists, then the program runs / the file doesn’t exist / therefore, the program won’t run (INVALID) (denying antecedent)
-
if i study, then i pass the exam / i didn’t pass the exam / therefore, i didn’t study ✓
-
if i study, then i pass the exam / i didn’t study / therefore, i won’t pass (INVALID) (denying antecedent)
diagnostic scenarios
apply modus tollens to eliminate causes:
scenario: car won’t start
- if battery is dead, then lights won’t work → lights work → battery not dead
- if out of gas, then fuel gauge shows empty → gauge shows 1/4 tank → not out of gas
- if starter is broken, then no clicking sound → loud clicking sound → starter not broken
- remaining possibilities: ignition system, fuel pump, etc.
scenario: website is slow
- if server overloaded, then cpu usage > 90% → cpu usage = 45% → not overloaded
- if database issues, then query time > 5s → queries complete in 200ms → not database
- if network congestion, then ping time > 100ms → ping = 15ms → not network
- remaining possibilities: application code, caching issues, etc.
see also
- modus ponens - the complement to modus tollens
- contrapositive - the equivalent logical form
- negation - the logical operator in modus tollens
- denying the antecedent fallacy - the related fallacy
- proof by contradiction - applications in mathematical proof
══════════════════════════════════════════════════════════════════