ders3_1

advertisement

Discrete Computational

Structures

Logical Inference

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Logical Inference

• Why do we study propositional logic?

– We want to use them to solve problems.

– To solve a problem using the propositional logic, we often need to start from some “premises,” and obtain a certain “conclusion” using

inferences.

• Example: Computer scientists often need to verify the correctness of a program.

– One possible approach is to prove the program is correct.

– So one can start from the program and the semantics of the used programming language (i.e., the premise), and use inference to obtain a conclusion that the program does the right job.

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Logical Inference

• Deriving a logical conclusion by combining many propositions and using formal logic: hence, determining the truth of arguments.

• An argument is a sequence of statements in which the conjunction of the initial statements (called the premises/hypotheses) is said to imply the final statement (called the conclusion).

• An argument can be presented symbolically as where P

1

, P

2

(P

1

, ..., P n conclusion.

Λ P

2

Λ ... Λ P n

)  Q represent the hypotheses and Q represents the

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Valid Argument

• What is a valid argument?  When does Q logically follow from P

1

, P

2

, ..., P n

• Informal answer: Whenever the truth of hypotheses leads to the conclusion

.

• Note: We need to focus on the relationship of the conclusion to the hypotheses and not just any knowledge we might have about the conclusion Q.

• Example:

– P

1

: Neil Armstrong was the first human to step on the moon.

– P

2

: Mars is a red planet

And the conclusion

– Q: No human has ever been to Mars.

– P

1

Λ P

2

 Q is not a tautology

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Valid Argument

• An argument is valid if whenever the hypotheses are all true, the conclusion must also be true. A valid argument is intrinsically true, i.e. (P

Q is a tautology.

1

Λ P

2

Λ ... Λ P n

) 

• How to arrive at a valid argument?

– Using a proof sequence

• It is a sequence of propositional formulas in which each formula is either a hypothesis or the result of applying one of the formal system’s derivation rules to earlier formulas in the sequence.

• Generally speaking, in inference, we can always replace a logic formula with another one that is logically equivalent, just as we have seen for the implication rule.

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Rules for Propositional Logic

Derivation rules for propositional logic

Equivalence Rules

Allows individual formulas to be rewritten

Truth preserving rules

Inference Rules

Allows new formulas to be derived

Work only in one direction

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Implication Rule

• The first, and simplest, rule is:

P

P → Q

-------------

Q

• This rule is called Modus ponens . Intuitively, if we have the condition of an implication, then we can obtain its consequence.

• Example

If you study the BİM122 material, then you will pass

You study the BİM122 material

______________

 You will pass

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Another Implication Rule

• Recall that P → Q   P  Q   Q →  P .

• The implication rule just studied tells us that

 Q

 Q →  P

-------------

 P

• If we replace  Q →  P in the above with P → Q , then we get another implication rule

( Modus tonens ):

 Q

P → Q

-------------

 P

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Yet Another Implication Rule

• We have:

P → Q

Q → R

----------

 P → R

• Intuitively, if P implies Q and Q implies R, then we can get that P implies R.

• This rule is called Hypothetical syllogism.

• Example: P → Q means “if there is a storm, then the office is closed.” Q → R means “if the office is closed, then I don’t go to work.” P → R means “if there is a storm, then I don’t go to work.”

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Conjunction and Simplification Rules

• Rules are not restricted to implications. For example, we have a conjunction rule:

P

Q

----

 P  Q

• Intuitively, this means when you have P and Q both being true, then P  Q is also true.

• A closely related rule (simplification):

P  Q

------

 P

• Intuitively, this means when you have P  Q being true, clearly P is also true.

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Disjunction Rules

• One is (Disjunctive syllogism):

P  Q

 P

--------

 Q

• Another is (Addition rule):

P

---------

 P  Q

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Resolution Rule

• Third disjunction rule (Resolution rule):

P  Q

 P  R

-------------

 Q  R

• It plays an important role in AI systems.

• Intuitively, it means: if P implies R and  P implies Q ( why? Where do we get these implications?) , then we must have either Q or R. Clearly, this is true since one of P and  P must be true.

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Other Rules

• We can have more rules like:

P  Q

P → R

Q → S

-------------

 R  S

• Intuitively it means we can do inference in each of two cases (P or Q) independently.

Rule of Inference

P

P

Q

P

Q

P

P

Q

P

Q

P

P

Q

Q

Q

P

Q

 

P

P

Q

Q

R

P

R

P

Q

P

Q

P

Q

P

R

Q

R

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Rules of Inference or Method of Proof

Tautology (Deduction Theorem)

P

(P

Q)

(P

Q)

P

[(P)

(Q)]

(P

Q)

[(P)

(P

Q)]

P

[(

Q)

(P

Q)]

 

P

[(P

Q)

(Q

R)]

(P

R)

[(P

Q)

(

P)]

Q

[(P

Q)

(

P

R)]

(Q

R)

Name

Addition

Simplification

Conjunction

Modus Ponens

Modus Tollens

Hypothetical Syllogism

(“chaining”)

Disjunctive syllogism

Resolution

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Inference Example

• Prove P Λ  P  Q

1.

2.

P

 P

3.

4.

5.

P V Q

Q V P

 (  Q) V P

6.

7.

8.

 Q  P

 (  Q)

Q

(called Inconsistency) premise 1 premise 2

1, addition

3, commutativity

4, double negation

5, implication

2, 6, Modus Tollens

7, double negation

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Inference Example

Suppose:

(1) If it is Saturday today, then we play football or basketball.

(2) If the football field is occupied, we don’t play football.

(3) It is Saturday today, and the football field is occupied.

Prove that we play basketball or volleyball.

First we formalize the problem :

P: It is Saturday today.

Q: We play football.

R: We play basketball.

S: The football field is occupied.

T: We play volleyball.

Our premise : P  (Q  R), S  Q, P, S

Need to prove : R  T

(1) P  (Q  R)

(2) P

(3) Q  R

(4) S   Q

(5) S

(6)  Q

(7) R

(8) R  T

Premise 1

Premise 2

1, 2, Implication

Premise 3

Premise 4

3, 4, Implication

3, 6, Disjunction

7, Addition

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Inference Example

Show that the premises “It is not sunny this afternoon and it is colder than yesterday,” “We will go swimming only if it is sunny,” “If we do not go swimming, then we will take a canoe trip,” and “If we take a canoe trip, then we will be home by sunset” lead to the conclusion “We will be home by sunset.

p : “It is sunny this afternoon,”

q : “It is colder than yesterday,”

r : “We will go swimming,”

s : “We will take a canoe trip,”

t : “We will be home by sunset.”

Then the premises become

¬ p

∧ q r → p

¬ r → s s → t .

The conclusion is simply t .

Step Reason

1. ¬ p

∧ q Premise

2. ¬ p Simplification using (1)

3. r → p Premise

4. ¬ r Modus tollens using (2) and (3)

5. ¬ r → s Premise

6. s Modus ponens using (4) and (5)

7. s → t Premise

8. t Modus ponens using (6) and (7)

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Inference Example

Show that the premises “If you send me an e-mail message, then I will finish writing the program,” “If you do not send me an e-mail message, then I will go to sleep early,” and “If I go to sleep early, then I will wake up feeling refreshed” lead to the conclusion “If I do not finish writing the program, then I will wake up feeling refreshed.”

p : “You send me an e-mail message,”

q : “I will finish writing the program,”

r : “I will go to sleep early,”

s : ““Iwill wake up feeling refreshed.”

Then the premises become p → q

¬p → r r → s

The conclusion is simply

¬q → s

Step Reason

1. p → q Premise

2. ¬q → ¬p Contrapositive of (1)

3. ¬p → r Premise

4. ¬q → r Hypothetical syllogism using (2) and (3)

5. r → s Premise

6. ¬q → s Hypothetical syllogism using (4) and (5)

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Rules of Inference for Quantified Statements

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Rules of Inference for Quantified Statements

Universal instantiation is to conclude that P(c) is true, where c is a particular member of the domain, given the premise

x P(x).

“All women are wise”  “Ayşe is wise,”

Universal generalization states that ∀ x P(x) is true, given the premise that P(c) is true for all elements c in the domain. Universal generalization is used when we show that

∀ x P(x) is true by taking an arbitrary element c from the domain and showing that P(c) is true. The element c that we select must be an arbitrary, and not a specific, element of the domain. That is, when we assert from

∀ x P(x) the existence of an element c in the domain, we have no control over c and cannot make any other assumptions about c other than it comes from the domain.

Existential instantiation is the rule that allows us to conclude that there is an element c in the domain for which

P(c) is true if we know that

∃ x P(x) is true. We cannot select an arbitrary value of c here, but rather it must be a c for which P(c) is true. Usually we have no knowledge of what c is, only that it exists. Because it exists, we may give it a name (c) and continue our argument.

Existential generalization is the rule of inference that is used to conclude that

∃ x P(x) is true when a particular element c with P(c) true is known. That is, if we know one element c in the domain for which P(c) is true, then we know that

∃ x P(x) is true.

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Rules of Inference for Quantified Statements

Example

Show that the premises “Everyone in this discrete mathematics class has taken a course in computer science” and “Marla is a student in this class” imply the conclusion “Marla has taken a course in computer science.”

Solution:

D(x): “x is in this discrete mathematics class,”

C(x): “x has taken a course in computer science.”

Then the premises are

∀ x(D(x) → C(x)) and

D(Marla).

The conclusion is

C(Marla).

Step Reason

1.

∀ x(D(x) → C(x)) Premise

2. D(Marla) → C(Marla) Universal instantiation from (1)

3. D(Marla) Premise

4. C(Marla) Modus ponens from (2) and (3)

DISCRETE COMPUTATIONAL STRUCTURES – Propositional Logic

Rules of Inference for Quantified Statements

Example

Show that the premises “A student in this class has not read the book,” and “Everyone in this class passed the first exam” imply the conclusion “Someone who passed the first exam has not read the book.”

Solution:

C(x): “x is in this class,”

B(x): “x has read the book,”

P(x): “x passed the first exam.” T

The premises are

∃ x(C(x)

¬B(x))

∀ x(C(x) → P(x)).

The conclusion is

∃ x(P(x)

¬B(x)).

Step Reason

1.

∃ x(C(x)

2. C(a)

3. C(a)

¬B(x))

¬B(a)

Premise

Existential instantiation from (1)

Simplification from (2)

4.

∀ x(C(x) → P(x)) Premise

5. C(a) → P(a)

6. P(a)

7. ¬B(a)

8. P(a)

¬B(a)

9.

∃ x(P(x)

¬B(x))

Universal instantiation from (4)

Modus ponens from (3) and (5)

Simplification from (2)

Conjunction from (6) and (7)

Existential generalization from (8)

Download