39
CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

Embed Size (px)

Citation preview

Page 1: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

CS2013Maths for Computing Science

Proof (part b)

Adam WynerUniversity of Aberdeen

Computing Science

Page 2: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 2

Topics

• Equivalences that can be used to replace formulae in proofs

• Tableau proofs• Further examples of Propositional Logic proofs.• Proof rules with quantifiers.

Page 3: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 3

Equivalences

Equivalence expressions can be substituted since they do not change truth.

Page 4: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 4

Equivalences

Page 5: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 5

A Direct Proof

1. ((A ∨ ¬ B) C)∨ (D (E F))

2. (A ∨ ¬ B) ((F G) H)

3. A ((E F) (F G))

4. A

5. Show: D H6. A ∨ ¬ B

7. (A ∨ ¬ B) ∨ C

8. (D (E F))

9. (E F) (F G)

10. D (F G)

11. (F G) H12. D H

Page 6: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 6

A Direct Proof

1. ((A ∨ ¬ B) C)∨ (D (E F))

2. (A ∨ ¬ B) ((F G) H)

3. A ((E F) (F G))

4. A

5. Show: D H DD 12

6. A ∨ ¬ B DI 4

7. (A ∨ ¬ B) ∨ C DI 6

8. (D (E F)) IE 1,7

9. (E F) (F G) IE 3,4

10. D (F G) HS 8,9

11. (F G) H IE 2,6

12. D H HS 10,11

Page 7: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 7

A Conditional Proof

1. (A B)∨ (C ∧ D)

2. (D E)∨ F3. Show: A F4. A

5. Show: F

6. A ∨ B

7. C ∧ D

8. D

9. (D E)∨10. F

Page 8: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 8

A Conditional Proof

1. (A B)∨ (C ∧ D)

2. (D E)∨ F3. Show: A F CD 4, 5

4. A Assumption

5. Show: F DD 10

6. A ∨ B DI 4

7. C ∧ D IE 1,6

8. D CE 7

9. (D E)∨ DI 8

10. F IE 2,9

Page 9: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 9

An Indirect Proof

1. A (B ∧ C)

2. (B D)∨ E3. (D A)∨4. Show: E ID 13

5. Assumption

6. IE 2,5

7. Second De Morgan 6

8. CE 7

9. DE 4,8

10. IE 1,9

11. CE 10

12. CE 7

13. ContraI 11,12

Page 10: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 10

An Indirect Proof

1. A (B ∧ C)

2. (B D)∨ E3. (D A)∨3. Show: E

4. ¬ E

5. ¬ (B D)∨6. ¬ B ∧ ¬ D

7. ¬ D

8. A

9. B ∧ C

10. B

11. ¬ B

12. B ∧ ¬ B

Page 11: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 11

An Indirect Proof

1. A (B ∧ C)

2. (B D)∨ E3. (D A)∨4. Show: E ID 13

5. ¬ E Assumption

6. ¬ (B D)∨ IE 2,5

7. ¬ B ∧ ¬ D Second De Morgan 6

8. ¬ D CE 7

9. A DE 4,8

10. B ∧ C IE 1,9

11. B CE 10

12. ¬ B CE 7

13. B ∧ ¬ B ContraI 11,12

Page 12: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 12

A Logical Equivalence

Prove: ¬ (p (∨ ¬ p ∧ q)) is equivalent to ¬ p ∧ ¬ q

1. ¬ (p (∨ ¬ p ∧ q)) ....

Page 13: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 13

A Logical Equivalence

Prove: ¬ (p (∨ ¬ p ∧ q)) is equivalent to ¬ p ∧ ¬ q

1. ¬ (p (∨ ¬ p ∧ q)) second De Morgan

2. first De Morgan

3. double negation

4. second distributive

5. negation

6. commutativity

7. identity law for F

Page 14: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 14

A Logical Equivalence

Prove: ¬ (p (∨ ¬ p ∧ q)) is equivalent to ¬ p ∧ ¬ q

1. ¬ (p (∨ ¬ p ∧ q)) ¬ p ∧ ¬ (¬ p ∧ q)

2. ¬ p ∧ (¬ (¬ p) ∨ ¬ q)

3. ¬ p ∧ (p ∨ ¬ q)

4. (¬ p p) ∧ ∨ ( ¬ p ∧ ¬ q)

5. F ∨ ( ¬ p ∧ ¬ q)

6. ( ¬ p ∧ ¬ q) ∨ F

7. ( ¬ p ∧ ¬ q)

Page 15: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 15

A Logical Equivalence

Prove: ¬ (p (∨ ¬ p ∧ q)) is equivalent to ¬ p ∧ ¬ q

1. ¬ (p (∨ ¬ p ∧ q)) ¬ p ∧ ¬ (¬ p ∧ q) second De Morgan

2. ¬ p ∧ (¬ (¬ p) ∨ ¬ q) first De Morgan

3. ¬ p ∧ (p ∨ ¬ q) double negation

4. (¬ p p) ∧ ∨ ( ¬ p ∧ ¬ q) second distributive

5. F ∨ ( ¬ p ∧ ¬ q) negation

6. ( ¬ p ∧ ¬ q) ∨ F commutativity

7. ( ¬ p ∧ ¬ q) identity law for F

Page 16: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

Tableau Proofs

• Another formal method for logical proofs.• Thanks to Ulle Endriss for some slides.

October 2014 CS2013 Maths for Computing 16

Page 17: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

Tableau Method – How?• A method for proving that a given set of formulas

is not satisfiable : • Given: set of premises ∆ and conclusion φ

Task: prove ∆ |= φHow? show ∆ {¬φ} is not satisfiable (which is ∪equivalent), i.e. add the complement of the conclusion to the premises and derive a contradiction (“refutation procedure”).If a proof fails, we can sometimes conclude that the set in question is satisfiable, or that the conclusion in question does not follow (ok for propositional logic; for first-order logic only in special cases).

October 2014 CS2013 Maths for Computing 17

Page 18: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

Construction

• Data structure: a proof is represented as a tableau—a binary tree, the nodes of which are labelled with formulas.

• Start: we start by putting the premises and the negated conclusion into the root of an otherwise empty tableau.

• Expansion: we apply expansion rules to the formulas on the tree, thereby adding new formulas and splitting branches. Use all premises and copy analysed formulas into all relevant branches.

• Closure: we close branches that are contradictory. • Success: a proof is successful iff we can close all branches.

October 2014 CS2013 Maths for Computing 18

Page 19: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

Construction

• We close a branch if it contains both a formula and the same formula with a "¬" in front.

• Each such branch represents a way in which the original sentences might perhaps be true. Closing a branch signifies that this branch is not a way in which the original sentences could all be true.

• Where all the branches close, there was no way in which the original sentences could all be true.

• There is at most one rule that can be applied to a given formula.

October 2014 CS2013 Maths for Computing 19

Page 20: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

Propositional Tableau Rules

October 2014 CS2013 Maths for Computing 20

Page 21: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

Example (Truth Tables say?)Prove: ((P → Q) → P) → P

¬(((P → Q) → P) → P)

((P → Q) → P)

¬P

¬(P → Q) P

x

P

¬Q

x

October 2014 CS2013 Maths for Computing 21

Page 22: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

Prove: P → (Q R), ¬Q ¬R |= ¬P∧ ∨

P → (Q R), ¬Q ¬R, P∧ ∨

¬P (Q R)∧x

Q

R

¬Q ¬R

x x

October 2014 CS2013 Maths for Computing 22

Page 23: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

More Examples• {(P → Q) → R), S → ¬P, T, (¬S → T) → Q, ¬R}• {P → (Q R), ¬R → (S T), ¬T, T → U}∨ ∧• {P R, (¬P Q) (¬Q ¬R)}∧ ∨ ∧ ∨• {(P Q) R, ¬Q ¬R, ¬P}∨ ∧ ∨• {¬P Q, ¬P ¬Q, P R, ¬R}∨ ∨ ∨• {P R, P Q, ¬P ¬Q}∧ ∨ ∨

October 2014 CS2013 Maths for Computing 23

Page 24: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

Termination

• Assuming we analyse each formula at most once, we have:

• Theorem 1 (Termination) For any propositional tableau, after a finite number of steps no more expansion rules will be applicable.

• This must be so, because each rule results in ever shorter formulas.

• Note: Importantly, termination will not hold in the first-order case.

October 2014 CS2013 Maths for Computing 24

Page 25: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

Quantifiers

• How to prove with universal and existential quantifiers.

October 2014 CS2013 Maths for Computing 25

Page 26: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 26

Universal Instantiation

• x P(x)P(o) (substitute any constant o)

The same for any other variable than x.

Page 27: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 27

Existential Generalization

• P(o) x P(x)

The same for any other variable than x.

Page 28: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 28

Universal Generalisation

• P(g) x P(x)

• This is not a valid inference of course. But suppose you can prove P(g) without using any information about g ...

• ... then the inference to x P(x) is valid!• In other words ...

Page 29: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 29

Universal Generalisation

• P(g) (for g an arbitrary or general constant)x P(x)

• Concretely, your strategy should be to choose a new constant g (i.e., that did not occur in your proof so far) and to prove P(g).

Page 30: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 30

Existential Instantiation

• x P(x)P(c) (substitute a new constant c)

Once again, the inference is not generally valid, but we can regard it as valid if c is a new constant.

Page 31: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 31

Simple Formal Proof in Predicate Logic

• Argument:– “All TAs compose quizzes. Ramesh is a TA.

Therefore, Ramesh composes quizzes.”• First, separate the premises from conclusions:

– Premise #1: All TAs compose quizzes.– Premise #2: Ramesh is a TA.– Conclusion: Ramesh composes quizzes.

Page 32: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 32

Rendering in Logic

Render the example in logic notation.• Premise #1: All TAs compose easy quizzes.

– Let U.D. = all people– Let T(x) :≡ “x is a TA”– Let E(x) :≡ “x composes quizzes”– Then Premise #1 says: x(T(x)→E(x))

Page 33: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 33

Rendering cont…

• Premise #2: Ramesh is a TA.– Let r :≡ Ramesh– Then Premise #2 says: T(r)– And the Conclusion says: E(r)

• The argument is correct, because it can be reduced to a sequence of applications of valid inference rules, as follows:

Page 34: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 34

Formal Proof UsingNatural Deduction

Statement How obtained

1. x(T(x) → E(x)) (Premise #1)

2. T(r) → E(r) (Universal instantiation)

3. T(r) (Premise #2)

4. E(r) (MP 2, 3)

Page 35: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 35

A very similar proof

Can you prove:• x(T(x) → E(x)) and E(r)• T(r).

Page 36: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 36

in Natural Deduction

A very simple example:

Theorem: From xF(x) it follows that yF(y)

1. xF(x) (Premiss)

2. F(a) (Arbitrary a, Exist. Inst.)

3. yF(y) (Exist. Generalisation)

Page 37: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 37

Quantifier Rules

Page 38: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

October 2014 CS2013 Maths for Computing 38

Longer Quantifier Proof

Page 39: CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science

References and Credits

• Slides adapted from Michael P. Frank's course• Textbook: Rosen. Discrete Mathematics & Its

Applications. McGraw-Hill. Fifth edition.

CS 2013 Maths for Computing 39October 2014