You are on page 1of 80

CS 228 : Logic in Computer Science

Krishna. S

1/23
Recap

I Syntax of Propositional Logic


I Encoding puzzles as formulae
I Natural deduction

2/23
A Proof Engine for Natural Deduction

I If it rains, Tia is outside and does not have any raingear with her,
she will get wet. ϕ = (R ∧ TiaOut ∧ ¬RG) → TiaWet
I It is raining, and Tia is outside, and is not wet.
ψ = (R ∧ TiaOut ∧ ¬TiaWet)
I So, Tia has her rain gear with her. RG
I Thus, χ = ϕ ∧ ψ → RG.
I Given ϕ, ψ, can we “prove” RG?

3/23
A Proof Engine

I Given a formula ϕ in propositional logic, how to “prove” ϕ if ϕ is


valid?
I What is a proof engine?
I Show that this proof engine is sound and complete
I Completeness: Any fact that can be captured using propositional
logic can be proved by the proof engine
I Soundness: Any formula that is proved to be valid by the proof
engine is indeed valid

4/23
Natural Deduction

I In natural deduction, we have a collection of proof rules

5/23
Natural Deduction

I In natural deduction, we have a collection of proof rules


I These proof rules allow us to infer formulae from some given
formulae

5/23
Natural Deduction

I In natural deduction, we have a collection of proof rules


I These proof rules allow us to infer formulae from some given
formulae
I Given a set of premises, we deduce a conclusion which is also a
formula using proof rules. Recall how we deduced that Tia had
rain gear with her, from the given premises

5/23
Natural Deduction

I In natural deduction, we have a collection of proof rules


I These proof rules allow us to infer formulae from some given
formulae
I Given a set of premises, we deduce a conclusion which is also a
formula using proof rules. Recall how we deduced that Tia had
rain gear with her, from the given premises
I ϕ1 , . . . , ϕn ` ψ : This is called a sequent. ϕ1 , . . . , ϕn are
premises, and ψ, the conclusion.
I Given ϕ1 , . . . , ϕn , we can deduce or prove ψ. What was the
sequent in Tia’s case?

5/23
Natural Deduction

I In natural deduction, we have a collection of proof rules


I These proof rules allow us to infer formulae from some given
formulae
I Given a set of premises, we deduce a conclusion which is also a
formula using proof rules. Recall how we deduced that Tia had
rain gear with her, from the given premises
I ϕ1 , . . . , ϕn ` ψ : This is called a sequent. ϕ1 , . . . , ϕn are
premises, and ψ, the conclusion.
I Given ϕ1 , . . . , ϕn , we can deduce or prove ψ. What was the
sequent in Tia’s case?
I For example, ¬p → q, q → r , ¬r ` p is a sequent. How do you
prove this?

5/23
Natural Deduction

I In natural deduction, we have a collection of proof rules


I These proof rules allow us to infer formulae from some given
formulae
I Given a set of premises, we deduce a conclusion which is also a
formula using proof rules. Recall how we deduced that Tia had
rain gear with her, from the given premises
I ϕ1 , . . . , ϕn ` ψ : This is called a sequent. ϕ1 , . . . , ϕn are
premises, and ψ, the conclusion.
I Given ϕ1 , . . . , ϕn , we can deduce or prove ψ. What was the
sequent in Tia’s case?
I For example, ¬p → q, q → r , ¬r ` p is a sequent. How do you
prove this?
I Proof rules to be carefully chosen, for instance you should not
end up proving something like p ∧ q ` ¬q

5/23
The Rules of the Proof Engine

6/23
Rules for Natural Deduction

The and introduction rule denoted ∧i

ϕ ψ
ϕ∧ψ

7/23
Rules for Natural Deduction

The and elimination rule denoted ∧e1

ϕ∧ψ
ϕ

The and elimination rule denoted ∧e2

ϕ∧ψ
ψ

8/23
A first proof using ∧i, ∧e1, ∧e2

I Show that p ∧ q, r ` q ∧ r

1. p∧q premise
2.

9/23
A first proof using ∧i, ∧e1, ∧e2

I Show that p ∧ q, r ` q ∧ r

1. p∧q premise
2. r premise
3.

9/23
A first proof using ∧i, ∧e1, ∧e2

I Show that p ∧ q, r ` q ∧ r

1. p∧q premise
2. r premise
3. q ∧e2 1
4.

9/23
A first proof using ∧i, ∧e1, ∧e2

I Show that p ∧ q, r ` q ∧ r

1. p∧q premise
2. r premise
3. q ∧e2 1
4. q∧r ∧i 3,2

9/23
Rules for Natural Deduction

The rule of double negation elimination ¬¬e

¬¬ϕ
ϕ

The rule of double negation introduction ¬¬i

ϕ
¬¬ϕ

10/23
Rules for Natural Deduction

The implies elimination rule or Modus Ponens MP

ϕ ϕ→ψ
ψ

11/23
Another Proof

I Show that p, p → q, p → (q → ¬¬r ) ` r

1. p → (q → ¬¬r ) premise
2.

12/23
Another Proof

I Show that p, p → q, p → (q → ¬¬r ) ` r

1. p → (q → ¬¬r ) premise
2. p→q premise
3.

12/23
Another Proof

I Show that p, p → q, p → (q → ¬¬r ) ` r

1. p → (q → ¬¬r ) premise
2. p→q premise
3. p premise
4.

12/23
Another Proof

I Show that p, p → q, p → (q → ¬¬r ) ` r

1. p → (q → ¬¬r ) premise
2. p→q premise
3. p premise
4. q → ¬¬r MP 1,3
5.

12/23
Another Proof

I Show that p, p → q, p → (q → ¬¬r ) ` r

1. p → (q → ¬¬r ) premise
2. p→q premise
3. p premise
4. q → ¬¬r MP 1,3
5. q MP 2,3
6.

12/23
Another Proof

I Show that p, p → q, p → (q → ¬¬r ) ` r

1. p → (q → ¬¬r ) premise
2. p→q premise
3. p premise
4. q → ¬¬r MP 1,3
5. q MP 2,3
6. ¬¬r MP 4,5
7.

12/23
Another Proof

I Show that p, p → q, p → (q → ¬¬r ) ` r

1. p → (q → ¬¬r ) premise
2. p→q premise
3. p premise
4. q → ¬¬r MP 1,3
5. q MP 2,3
6. ¬¬r MP 4,5
7. r ¬¬e 6

12/23
Rules for Natural Deduction

Another implies elimination rule or Modus Tollens MT

ϕ→ψ ¬ψ
¬ϕ

13/23
A Proof

I Show that p → ¬q, q ` ¬p

1. p → ¬q premise
2.

14/23
A Proof

I Show that p → ¬q, q ` ¬p

1. p → ¬q premise
2. q premise
3.

14/23
A Proof

I Show that p → ¬q, q ` ¬p

1. p → ¬q premise
2. q premise
3. ¬¬q ¬¬i 2
4.

14/23
A Proof

I Show that p → ¬q, q ` ¬p

1. p → ¬q premise
2. q premise
3. ¬¬q ¬¬i 2
4. ¬p MT 1,3

14/23
More Rules

I Thanks to MT, we have p → q, ¬q ` ¬p.

15/23
More Rules

I Thanks to MT, we have p → q, ¬q ` ¬p.


I Can we prove p → q ` ¬q → ¬p?

15/23
More Rules

I Thanks to MT, we have p → q, ¬q ` ¬p.


I Can we prove p → q ` ¬q → ¬p?
I So far, no proof rule that can do this.

15/23
More Rules

I Thanks to MT, we have p → q, ¬q ` ¬p.


I Can we prove p → q ` ¬q → ¬p?
I So far, no proof rule that can do this.
I Given p → q, let us assume ¬q. Can we then prove ¬p?

15/23
More Rules

I Thanks to MT, we have p → q, ¬q ` ¬p.


I Can we prove p → q ` ¬q → ¬p?
I So far, no proof rule that can do this.
I Given p → q, let us assume ¬q. Can we then prove ¬p?
I Yes, using MT.

15/23
The implies introduction rule → i

I p → q ` ¬q → ¬p

1. p→q premise
2. ¬q assumption
3. ¬p MT 1,2
4. ¬q → ¬p → i 2-3

16/23
More on → i

I ` (q → r ) → [(¬q → ¬p) → (p → r )]

1. true premise
2.

17/23
More on → i

I ` (q → r ) → [(¬q → ¬p) → (p → r )]

1. true premise
2. q→r assumption
3.

17/23
More on → i

I ` (q → r ) → [(¬q → ¬p) → (p → r )]

1. true premise
2. q→r assumption
3. ¬q → ¬p assumption
4.

17/23
More on → i

I ` (q → r ) → [(¬q → ¬p) → (p → r )]

1. true premise
2. q→r assumption
3. ¬q → ¬p assumption
4. p assumption
5.

17/23
More on → i

I ` (q → r ) → [(¬q → ¬p) → (p → r )]

1. true premise
2. q→r assumption
3. ¬q → ¬p assumption
4. p assumption
5. ¬¬p ¬¬i 4
6.

17/23
More on → i

I ` (q → r ) → [(¬q → ¬p) → (p → r )]

1. true premise
2. q→r assumption
3. ¬q → ¬p assumption
4. p assumption
5. ¬¬p ¬¬i 4
6. ¬¬q MT 3,5
7.

17/23
More on → i

I ` (q → r ) → [(¬q → ¬p) → (p → r )]

1. true premise
2. q→r assumption
3. ¬q → ¬p assumption
4. p assumption
5. ¬¬p ¬¬i 4
6. ¬¬q MT 3,5
7. q ¬¬e 6
8.

17/23
More on → i

I ` (q → r ) → [(¬q → ¬p) → (p → r )]

1. true premise
2. q→r assumption
3. ¬q → ¬p assumption
4. p assumption
5. ¬¬p ¬¬i 4
6. ¬¬q MT 3,5
7. q ¬¬e 6
8. r MP 2,7

17/23
More on → i

I ` (q → r ) → [(¬q → ¬p) → (p → r )]

1. true premise
2. q→r assumption
3. ¬q → ¬p assumption
4. p assumption
5. ¬¬p ¬¬i 4
6. ¬¬q MT 3,5
7. q ¬¬e 6
8. r MP 2,7
9. p→r → i 4-8

17/23
More on → i

I ` (q → r ) → [(¬q → ¬p) → (p → r )]

1. true premise
2. q→r assumption
3. ¬q → ¬p assumption
4. p assumption
5. ¬¬p ¬¬i 4
6. ¬¬q MT 3,5
7. q ¬¬e 6
8. r MP 2,7
9. p→r → i 4-8
10. (¬q → ¬p) → (p → r ) → i 3-9
11.

17/23
More on → i

I ` (q → r ) → [(¬q → ¬p) → (p → r )]

1. true premise
2. q→r assumption
3. ¬q → ¬p assumption
4. p assumption
5. ¬¬p ¬¬i 4
6. ¬¬q MT 3,5
7. q ¬¬e 6
8. r MP 2,7
9. p→r → i 4-8
10. (¬q → ¬p) → (p → r ) → i 3-9
11. (q → r ) → [(¬q → ¬p) → (p → r )] → i 2-10

17/23
Transforming Proofs

I (q → r ), (¬q → ¬p), p ` r
I Transform any proof ϕ1 , . . . , ϕn ` ψ to
` ϕ1 → (ϕ2 → . . . (ϕn → ψ) . . . )) by adding n lines of the rule → i

18/23
More Examples

I p → (q → r ) ` (p ∧ q) → r

1. p → (q → r ) premise
2.

19/23
More Examples

I p → (q → r ) ` (p ∧ q) → r

1. p → (q → r ) premise
2. p∧q assumption
3.

19/23
More Examples

I p → (q → r ) ` (p ∧ q) → r

1. p → (q → r ) premise
2. p∧q assumption
3. p ∧e1 2
4.

19/23
More Examples

I p → (q → r ) ` (p ∧ q) → r

1. p → (q → r ) premise
2. p∧q assumption
3. p ∧e1 2
4. q ∧e2 2
5.

19/23
More Examples

I p → (q → r ) ` (p ∧ q) → r

1. p → (q → r ) premise
2. p∧q assumption
3. p ∧e1 2
4. q ∧e2 2
5. q→r MP 1,3
6.

19/23
More Examples

I p → (q → r ) ` (p ∧ q) → r

1. p → (q → r ) premise
2. p∧q assumption
3. p ∧e1 2
4. q ∧e2 2
5. q→r MP 1,3
6. r MP 4,5
7.

19/23
More Examples

I p → (q → r ) ` (p ∧ q) → r

1. p → (q → r ) premise
2. p∧q assumption
3. p ∧e1 2
4. q ∧e2 2
5. q→r MP 1,3
6. r MP 4,5
7. p∧q →r → i 2-6

19/23
More Rules

The or introduction rule ∨i1

ϕ
ϕ∨ψ

The or introduction rule ∨i2

ψ
ϕ∨ψ

20/23
More Rules

The or elimination rule ∨e

ϕ∨ψ ϕ`χ ψ`χ


χ

21/23
Or Elimination Example

I q → r ` (p ∨ q) → (p ∨ r )

1. q→r premise
2.

22/23
Or Elimination Example

I q → r ` (p ∨ q) → (p ∨ r )

1. q→r premise
2. p∨q assumption
3.

22/23
Or Elimination Example

I q → r ` (p ∨ q) → (p ∨ r )

1. q→r premise
2. p∨q assumption
3. p ∨ e (1)
4.

22/23
Or Elimination Example

I q → r ` (p ∨ q) → (p ∨ r )

1. q→r premise
2. p∨q assumption
3. p ∨ e (1)
4. p∨r ∨i1 3
5.

22/23
Or Elimination Example

I q → r ` (p ∨ q) → (p ∨ r )

1. q→r premise
2. p∨q assumption
3. p ∨ e (1)
4. p∨r ∨i1 3
5. q ∨ e (2)
6.

22/23
Or Elimination Example

I q → r ` (p ∨ q) → (p ∨ r )

1. q→r premise
2. p∨q assumption
3. p ∨ e (1)
4. p∨r ∨i1 3
5. q ∨ e (2)
6. r MP 1,5
7.

22/23
Or Elimination Example

I q → r ` (p ∨ q) → (p ∨ r )

1. q→r premise
2. p∨q assumption
3. p ∨ e (1)
4. p∨r ∨i1 3
5. q ∨ e (2)
6. r MP 1,5
7. p∨r ∨i2 6

22/23
Or Elimination Example

I q → r ` (p ∨ q) → (p ∨ r )

1. q→r premise
2. p∨q assumption
3. p ∨ e (1)
4. p∨r ∨i1 3
5. q ∨ e (2)
6. r MP 1,5
7. p∨r ∨i2 6
8. p∨r ∨e 2, 3-4, 5-7

22/23
Or Elimination Example

I q → r ` (p ∨ q) → (p ∨ r )

1. q→r premise
2. p∨q assumption
3. p ∨ e (1)
4. p∨r ∨i1 3
5. q ∨ e (2)
6. r MP 1,5
7. p∨r ∨i2 6
8. p∨r ∨e 2, 3-4, 5-7
9.

22/23
Or Elimination Example

I q → r ` (p ∨ q) → (p ∨ r )

1. q→r premise
2. p∨q assumption
3. p ∨ e (1)
4. p∨r ∨i1 3
5. q ∨ e (2)
6. r MP 1,5
7. p∨r ∨i2 6
8. p∨r ∨e 2, 3-4, 5-7
9. (p ∨ q) → (p ∨ r ) → i 2-8

22/23
Associativity Using Or Elimination
I (p ∨ q) ∨ r ` p ∨ (q ∨ r )

1. (p ∨ q) ∨ r premise
2.

23/23
Associativity Using Or Elimination
I (p ∨ q) ∨ r ` p ∨ (q ∨ r )

1. (p ∨ q) ∨ r premise
2. p∨q ∨ e (1)
3.

23/23
Associativity Using Or Elimination
I (p ∨ q) ∨ r ` p ∨ (q ∨ r )

1. (p ∨ q) ∨ r premise
2. p∨q ∨ e (1)
3. p ∨ e (1.1)
4.

23/23
Associativity Using Or Elimination
I (p ∨ q) ∨ r ` p ∨ (q ∨ r )

1. (p ∨ q) ∨ r premise
2. p∨q ∨ e (1)
3. p ∨ e (1.1)
4. p ∨ (q ∨ r ) ∨i1 3
5.

23/23
Associativity Using Or Elimination
I (p ∨ q) ∨ r ` p ∨ (q ∨ r )

1. (p ∨ q) ∨ r premise
2. p∨q ∨ e (1)
3. p ∨ e (1.1)
4. p ∨ (q ∨ r ) ∨i1 3
5. q ∨ e (1.2)
6.

23/23
Associativity Using Or Elimination
I (p ∨ q) ∨ r ` p ∨ (q ∨ r )

1. (p ∨ q) ∨ r premise
2. p∨q ∨ e (1)
3. p ∨ e (1.1)
4. p ∨ (q ∨ r ) ∨i1 3
5. q ∨ e (1.2)
6. q∨r ∨i1 5
7.

23/23
Associativity Using Or Elimination
I (p ∨ q) ∨ r ` p ∨ (q ∨ r )

1. (p ∨ q) ∨ r premise
2. p∨q ∨ e (1)
3. p ∨ e (1.1)
4. p ∨ (q ∨ r ) ∨i1 3
5. q ∨ e (1.2)
6. q∨r ∨i1 5
7. p ∨ (q ∨ r ) ∨i2 6
8.

23/23
Associativity Using Or Elimination
I (p ∨ q) ∨ r ` p ∨ (q ∨ r )

1. (p ∨ q) ∨ r premise
2. p∨q ∨ e (1)
3. p ∨ e (1.1)
4. p ∨ (q ∨ r ) ∨i1 3
5. q ∨ e (1.2)
6. q∨r ∨i1 5
7. p ∨ (q ∨ r ) ∨i2 6
8. p ∨ (q ∨ r ) ∨e 2, 3-4, 5-7
9.

23/23
Associativity Using Or Elimination
I (p ∨ q) ∨ r ` p ∨ (q ∨ r )

1. (p ∨ q) ∨ r premise
2. p∨q ∨ e (1)
3. p ∨ e (1.1)
4. p ∨ (q ∨ r ) ∨i1 3
5. q ∨ e (1.2)
6. q∨r ∨i1 5
7. p ∨ (q ∨ r ) ∨i2 6
8. p ∨ (q ∨ r ) ∨e 2, 3-4, 5-7
9. r ∨ e (2)
10.

23/23
Associativity Using Or Elimination
I (p ∨ q) ∨ r ` p ∨ (q ∨ r )

1. (p ∨ q) ∨ r premise
2. p∨q ∨ e (1)
3. p ∨ e (1.1)
4. p ∨ (q ∨ r ) ∨i1 3
5. q ∨ e (1.2)
6. q∨r ∨i1 5
7. p ∨ (q ∨ r ) ∨i2 6
8. p ∨ (q ∨ r ) ∨e 2, 3-4, 5-7
9. r ∨ e (2)
10. q∨r ∨i2 9
11.

23/23
Associativity Using Or Elimination
I (p ∨ q) ∨ r ` p ∨ (q ∨ r )

1. (p ∨ q) ∨ r premise
2. p∨q ∨ e (1)
3. p ∨ e (1.1)
4. p ∨ (q ∨ r ) ∨i1 3
5. q ∨ e (1.2)
6. q∨r ∨i1 5
7. p ∨ (q ∨ r ) ∨i2 6
8. p ∨ (q ∨ r ) ∨e 2, 3-4, 5-7
9. r ∨ e (2)
10. q∨r ∨i2 9
11. p ∨ (q ∨ r ) ∨i2 10

23/23
Associativity Using Or Elimination
I (p ∨ q) ∨ r ` p ∨ (q ∨ r )

1. (p ∨ q) ∨ r premise
2. p∨q ∨ e (1)
3. p ∨ e (1.1)
4. p ∨ (q ∨ r ) ∨i1 3
5. q ∨ e (1.2)
6. q∨r ∨i1 5
7. p ∨ (q ∨ r ) ∨i2 6
8. p ∨ (q ∨ r ) ∨e 2, 3-4, 5-7
9. r ∨ e (2)
10. q∨r ∨i2 9
11. p ∨ (q ∨ r ) ∨i2 10
12. p ∨ (q ∨ r ) ∨e 1, 2-8, 9-11

23/23

You might also like