Ref Rules of Inference — Quick Reference

Each rule is shown in natural-deduction (Gentzen) form: premises above the bar, conclusion below.

$\dfrac{p,\;\; p \to q}{q}$ Modus Ponens
$\dfrac{\neg q,\;\; p \to q}{\neg p}$ Modus Tollens
$\dfrac{p \to q,\;\; q \to r}{p \to r}$ Hypothetical Syllogism
$\dfrac{p \vee q,\;\; \neg p}{q}$ Disjunctive Syllogism
$\dfrac{p}{p \vee q}$ Addition
$\dfrac{p \wedge q}{p}$ Simplification
$\dfrac{p,\;\; q}{p \wedge q}$ Conjunction
$\dfrac{p \vee q,\;\; \neg p \vee r}{q \vee r}$ Resolution

Helper to use in all exercises: write a function valid(premises_conj, conclusion) -> bool that returns True iff the argument is valid.

Hint: An argument is valid iff its premises cannot be True while the conclusion is False — i.e., not satisfiable(And(premises, Not(conclusion))).
Ex 1 Modus Ponens SymPy

Verify the validity of Modus Ponens using the valid helper.

$\dfrac{p,\;\; p \to q}{q}$ Modus Ponens
Ex 2 Modus Tollens SymPy

Verify Modus Tollens:

$\dfrac{\neg q,\;\; p \to q}{\neg p}$ Modus Tollens
Ex 3 Hypothetical Syllogism SymPy

Verify Hypothetical Syllogism:

$\dfrac{p \to q,\;\; q \to r}{p \to r}$ Hypothetical Syllogism
Ex 4 Disjunctive Syllogism SymPy

Verify Disjunctive Syllogism:

$\dfrac{p \vee q,\;\; \neg p}{q}$ Disjunctive Syllogism
Ex 5 Addition and Simplification SymPy

Verify both rules:

$\dfrac{p}{p \vee q}$ Addition
$\dfrac{p \wedge q}{p}$ Simplification
Ex 6 Conjunction and Resolution SymPy

Verify both rules:

$\dfrac{p,\;\; q}{p \wedge q}$ Conjunction
$\dfrac{p \vee q,\;\; \neg p \vee r}{q \vee r}$ Resolution
Ex 7 All Eight Rules in One Sweep SymPy

Store all eight rules in a dictionary mapping rule names to (premises, conclusion) tuples. Iterate over the dictionary and verify every rule is valid.

Ex 8 Multi-Step Inference — Swimming SymPy

Model the following argument and verify its validity:

  1. You will go swimming or go to the gym.   $\mathrm{Swim} \vee \mathrm{Gym}$
  2. If you go swimming, you will need a swimsuit.   $\mathrm{Swim} \to \mathrm{Swimsuit}$

Conclusion: You will need a swimsuit or go to the gym.   $\mathrm{Swimsuit} \vee \mathrm{Gym}$

Ex 9 Invalid Argument — Affirming the Consequent fallacy

The following is a common logical fallacy. Show that it is not a valid argument:

$\dfrac{p \to q,\;\; q}{p}$ ✗ Affirming the Consequent
Example fallacy: "If it rains, the ground is wet. The ground is wet. Therefore it rained." — Can you think of another reason the ground might be wet?
Ex 10 Quantified Rules — Universal & Existential Instantiation Z3

Use Z3 to verify two quantified rules of inference:

Universal Instantiation: $\forall x\; H(x) \to M(x)$ and $H(\text{socrates})$ implies $M(\text{socrates})$.

Existential Generalization: $M(\text{socrates})$ implies $\exists x\; M(x)$.

Ex 11 Exam & Director — Full Worked Example SymPy

Model and verify the following argument:

  1. If no one cheated, no one meets the director.   $\neg\exists x\,\mathrm{Cheat}(x) \to \neg\exists x\,\mathrm{Director}(x)$
  2. Octave (class president) met the director.   $\mathrm{ExDirector}$
  3. Either no one cheated, or someone gets detention.   $\neg\mathrm{ExCheat} \vee \mathrm{ExDetention}$

Conclusion: Someone gets a detention.   $\mathrm{ExDetention}$