CSE 311 Lecture 07: Inference Rules and Proofs for Propositional Logic

Topics

Logical inference
What is inference? Applications and a quick example.
Rules of inference
Inference rules for propositional logic.
Proofs using rules of inference
From hypotheses and facts to results, one rule at a time.

Logical inference

What is inference? Applications and a quick example.

What is inference?

So far, we’ve considered how to
Express statements using propositional and predicate logic.
Compute using Boolean (propositional) logic.
Show equivalence of different ways to express or compute statements.
Logic also has methods to infer statements from the ones we know.
Equivalence is a small part of this.

Applications of logical inference

Verification of programs, hardware, protocols, …
To verify that an implementation $P$ satisfies a specification $S$, translate both to logical formulas $s$ and $p$, and use automated logical inference to check that $p \rightarrow s \equiv \T$.
Synthesis of programs, hardware, protocols, …
Given a specification $S$, apply automated logical inference to the formula $\exists p. \forall x. s(x, p(x))$ to find an implementation $P$ that satisfies $S$ on all inputs $x$.
Logic programming, e.g., Prolog
Express the desired outcome as set of constraints (formulas).
Automatically apply logical inference to derive a solution.

Proofs via logical inference

  1. Start with known hypotheses and facts.
  2. Apply rules of inference to extend the set of facts.
  3. Result is proved when it is included in the set.

(Hypotheses, facts, and results are logical formulas.)

An example rule of inference: modus ponens

In English: if $A$ and $A\rightarrow B$ are both true then $B$ must be true.

We write this rule as $\rule{A ; A\rightarrow B}{B}$

Suppose that we are given the following propositions:

  • If it is Wednesday, then you have a 311 lecture today.
  • It is Wednesday.

By modus ponens, we infer that

  • You have a 311 lecture today.

A “hello world” proof

Show that $r$ follows from $p$, $p\rightarrow q$, and $q\rightarrow r$.

1. $p$ Given
2. $p\rightarrow q$ Given
3. $q\rightarrow r$ Given
4. $q$ MP: 1, 2
5. $r$ MP: 3, 4

Modus Ponens $\rule{A ; A\rightarrow B}{B}$

Proofs can use equivalences too

Show that $\neg p$ follows from $p \rightarrow q$ and $\neg q$.

1. $p \rightarrow q$ Given
2. $\neg q$ Given
3. $\neg q\rightarrow \neg p$ Contrapositive: 1
4. $\neg p$ MP: 2, 3

Modus Ponens $\rule{A ; A\rightarrow B}{B}$

Rules of inference

Inference rules for propositional logic.

Understanding inference rules

$\rule{A;B}{C, D}$

  • $A$ and $B$ are the premises of the rule.
  • $C$ and $D$ are the conclusions.
  • $\therefore$ means “therefore”.
  • “If $A$ and $B$ are true, then $C$ and $D$ must be true.”
Example (Modus Ponens):
$\rule{A ; A\rightarrow B}{B}$
If $A$ and $A\rightarrow B$ are true, then $B$ must be true.

Axioms are inference rules with no premises

$\rule{}{C, D}$

  • No premises required!
  • “$C$ and $D$ must be true.”
Example (Law of Excluded Middle):
$\rule{}{A\vee\neg A}$
$A \vee \neg A$ must be true.

Inference rules for propositional logic

Two rules per binary connective: to introduce and eliminate it.

Intro $\wedge$ $\rule{A; B}{A \wedge B}$
Elim $\wedge$ $\rule{A\wedge B}{A,B}$

Intro $\vee$ $\rule{A}{A\vee B, B\vee A}$
Elim $\vee$ $\rule{A\vee B; \neg A}{B}$

Direct Proof Rule $\rule{A\implies B}{A\rightarrow B}$
Modus Ponens $\rule{A ; A\rightarrow B}{B}$
Excluded Middle$\rule{}{A\vee\neg A}$

Direct Proof Rule is special: not like the other rules.

Fun fact: one rule to rule them all

If your formula is in conjunctive normal form (CNF), then you need just one rule to construct proofs!

Resolution $\rule{(p_1 \vee \ldots \vee p_n \vee k);(q_1 \vee \ldots \vee q_m \vee \neg k )}{(p_1 \vee \ldots \vee p_n \vee q_1 \vee \ldots \vee q_m)}$

Automated theorem provers for propositional logic (a.k.a. SAT solvers) use resolution to construct proofs for CNF formulas with millions of variables and clauses (maxterms).

Proofs using rules of inference

From hypotheses and facts to results, one rule at a time.

The basic approach to constructing proofs

  1. Match the givens against the premises of the rules.
  2. Add the conclusions of the matched rules to the set of givens.
  3. Repeat!

Intro $\wedge$ $\rule{A; B}{A \wedge B}$
Elim $\wedge$ $\rule{A\wedge B}{A,B}$

Intro $\vee$ $\rule{A}{A\vee B, B\vee A}$
Elim $\vee$ $\rule{A\vee B; \neg A}{B}$

Direct Proof Rule $\rule{A\implies B}{A\rightarrow B}$
Modus Ponens $\rule{A ; A\rightarrow B}{B}$
Excluded Middle$\rule{}{A\vee\neg A}$

A slightly longer example

Show that $r$ follows from $p$, $p \rightarrow q$ and $(p \wedge q) \rightarrow r$.

1. $p$ Given
2. $p\rightarrow q$ Given
3. $(p \wedge q) \rightarrow r$ Given
4. $q$ MP: 1, 2
5. $p\wedge q$ Intro $\wedge$: 1, 4
6. $r$ MP: 3, 5

Intro $\wedge$ $\rule{A; B}{A \wedge B}$
Elim $\wedge$ $\rule{A\wedge B}{A,B}$

Intro $\vee$ $\rule{A}{A\vee B, B\vee A}$
Elim $\vee$ $\rule{A\vee B; \neg A}{B}$

Direct Proof Rule $\rule{A\implies B}{A\rightarrow B}$
Modus Ponens $\rule{A ; A\rightarrow B}{B}$
Excluded Middle$\rule{}{A\vee\neg A}$

Important note on applying rules of inference

Equivalences can be applied to any sub-formula of a given formula.
This works because we are substituting a sub-formula with an expression that has the same meaning. So the meaning of the whole formula remains unchanged after the substitution.
Inference rules can be applied only to whole formulas.
The result is incorrect otherwise, because inference rules produce formulas whose meaning is implied by, not equivalent to, the givens.
  1. $p\rightarrow r$ Given
  2. $(p\vee q)\rightarrow r$ Intro $\vee$: 1

2 does not follow from 1!
E.g, $p=\F, q=\T, r=\F$.

Proofs forwards and backwards

Prove that $\neg r$ follows from $p \wedge s$, $q \rightarrow \neg r$, and $\neg s \vee q$.

1. $p\wedge s$ Given
2. $q \rightarrow \neg r$ Given
3. $\neg s \vee q$ Given
4. $s$ Elim $\wedge$: 1
5. $\neg\neg s$ Double Negation: 4
6. $q$ Elim $\vee$: 3, 5
7. $\neg r$ MP: 2, 6
  • Write the givens and the goal. How to proceed?
  • Idea: work backwards!
    • We can use MP on 2 to get $\neg r$, but need $q$.
    • We can use Elim $\vee$ on 3 to get $q$, but need $\neg\neg s$.
    • We can use Double Negation to get $\neg\neg s$, but need $s$.
    • We have $s$ from Elim $\wedge$ on 1!

Intro $\wedge$ $\rule{A; B}{A \wedge B}$
Elim $\wedge$ $\rule{A\wedge B}{A,B}$

Intro $\vee$ $\rule{A}{A\vee B, B\vee A}$
Elim $\vee$ $\rule{A\vee B; \neg A}{B}$

Direct Proof Rule $\rule{A\implies B}{A\rightarrow B}$
Modus Ponens $\rule{A ; A\rightarrow B}{B}$
Excluded Middle$\rule{}{A\vee\neg A}$

Proving implications with the direct proof rule

Direct Proof Rule $\rule{A\implies B}{A\rightarrow B}$

The premise $A\implies B$ means “Given $A$, we can prove $B$.”

So the direct proof rule says that if we have such a proof, then we can conclude that $A\rightarrow B$ is true.

Example: prove $ p \rightarrow (p \vee q)$.

1.1. $p$ Assumption
1.2. $p \vee q$ Intro $\vee$: 1
2. $ p \rightarrow (p \vee q)$ Direct Proof Rule

Indent the proof subroutine.

Example proofs using the direct proof rule: 1/2

Prove $(p\wedge q)\rightarrow(p\vee q)$.

There must be an application of the Direct Proof Rule (or an equivalence) to prove this implication.

1.1. $p\wedge q$ Assumption
1.2. $p$ Elim $\wedge$: 1.1
1.3. $p\vee q$ Intro $\vee$: 1.2
2. $(p\wedge q) \rightarrow (p \vee q)$ Direct Proof Rule
  • Write the premise and the conclusion.
  • Work backwards.
    • We can use Intro $\vee$ to get 1.3, but need $p$.
    • We have $p$ from Elim $\wedge$ on 1.1.

Example proofs using the direct proof rule: 2/2

Prove $((p\rightarrow q)\wedge(q\rightarrow r))\rightarrow(p\rightarrow r)$.

1.1. $(p\rightarrow q)\wedge(q\rightarrow r)$ Assumption
1.2. $p\rightarrow q$ Elim $\wedge$: 1.1
1.3. $q\rightarrow r$ Elim $\wedge$: 1.1
1.4.1. $p$ Assumption
1.4.2. $q$ MP: 1.2, 1.4.1
1.4.3. $r$ MP: 1.3, 1.4.2
1.5. $p\rightarrow r$ Direct Proof Rule
2. $((p\rightarrow q)\wedge(q\rightarrow r))\rightarrow(p\rightarrow r)$ Direct Proof Rule
  • Write the premise and the conclusion.
  • Work backwards.
    • We can use DPR to get 1.5.
    • We can use MP to get 1.4.3 but need $q$ and $q\rightarrow r$.
    • We have 1.2, 1.3 from Elim $\wedge$ on 1.1.
    • We have 1.4.2 from MP on 1.2, 1.4.1.

A general proof strategy

  1. Look at the rules for introducing connectives to see how you would build up the formula you want to prove from pieces of what is given.

  2. Use the rules for eliminating connectives to break down the given formulas so that you get the pieces need for 1.

  3. Write the proof beginning with what you figured out for 2 followed by 1.

Intro $\wedge$ $\rule{A; B}{A \wedge B}$
Elim $\wedge$ $\rule{A\wedge B}{A,B}$

Intro $\vee$ $\rule{A}{A\vee B, B\vee A}$
Elim $\vee$ $\rule{A\vee B; \neg A}{B}$

Direct Proof Rule $\rule{A\implies B}{A\rightarrow B}$
Modus Ponens $\rule{A ; A\rightarrow B}{B}$
Excluded Middle$\rule{}{A\vee\neg A}$

Summary

Rules of inference let us derive new formulas from given ones.
Modus ponens, intro and elimination, direct proof rule.
Proofs can use both rules of inference and equivalences.
Equivalences can be applied to subformulas.
Inference rules can be applied only to whole formulas.
Proofs are read front to back but often written from back to front.
Work your way backwards starting from the goal.
Direct proof rule lets us prove implications $A\rightarrow B$.
Indent direct proof rule subroutines.
The subroutine assumes $A$.
Then applies inference rules and equivalences to get $B$.