Sei sulla pagina 1di 19

Inference Rules

CS160/CS122 Rosen: 1.5

What is logic?
Logic is a truth-preserving system of inference
Truth-preserving: If the initial statements are true, the inferred statements will be true System: a set of mechanistic transformations, based on syntax alone Inference: the process of deriving (inferring) new statements from old statements

Proposi0onal Logic
An argument is a sequence of proposi0ons:
Premises (Axioms) are the rst n proposi0ons Conclusion is the n+1th (nal) proposi0on.

An argument is valid if ( p 1 " p 2 " ... " p n ) # q is a tautology, given that p i s are the premises q (axioms) and is the conclusion
!

Hello World

Proof By Truth Table


n

If the conclusion is true in the truth table whenever the premises are true, it is proved
n

Warning: when the premises are false, the conclusion my be true or false

Problem: given n propositions, the truth table has 2n rows


n

Proof by truth table quickly becomes infeasible

Rules of Inference
n

A rule of inference is a pre-proved rela0on: any 0me the leH hand side (LHS) is true, the right hand side (RHS) is also true. Therefore, if we can match a premise to the LHS (by subs0tu0ng proposi0ons), we can assert the (subs0tuted) RHS

Example Rule of Inference


Modus Ponens

( p " ( p # q)) # q
p q

p p#q " q
1 1 1 1

p " q p " ( p # q) ( p " ( p # q)) # q

0 0 ! ! 1 1

0 1 ! 0 1

1 0 1 ! 0 ! 0 0 1 1

Example
Given
(p) If it is raining, then (q) the grass is wet. (p) It is raining.

Therefore, by modus ponens,


(q) The grass is wet.

Applying rules of inference


n

Example rule: A, AB B
n n

Read as A and AB, therefore B This rule has a name: modus ponens Subs0tute C for A, D for B Apply modus ponens Conclude D

If you have premises C, C D


n n n

Rules of Inference

Logical Equivalences

A Simple Proof
n n

Given: X, XY, Y Z, (Z)W Prove: W


Step

1. 2. 3. 4. 5. 6. 7.

x!y y!z x!z x

z
z ! w w

Reason Given (Premise) Given (Premise) Hypothetical Syllogism (1) & (2) Given (Premise) Modus Ponens (3) & (4) Given (Premise) Disjunctive Syllogism (5) & (6)

A Simple Proof From Words


In order to take CS161, I must rst take CS160 and either M155 or M160. I have not taken M155 but I have taken CS161. Prove that I have taken M160. First step: assign proposi0ons
n n n n

A : take CS161 B : take CS160 C : Take M155 D : Take M160

Now set up the proof


n

Axioms:
n n n

AB(CD) A C D

Conclusion:
n

Now do the Proof


Reason 1. A ! B " (C # D) Given (Premise) 2. A Given (Premise) 3. B ! (C " D) Modus Ponens (1) & (2) 4. C ! D Simplification 5. C Given (Premise) 6. D Disjunctive Syllogism (4) & (5) Step

Example
Given: Conclude:

p " q r#p r # s s#t

Proof of Example
Step 1. p " q 2. p 3. r " p 4. r 5. r " s 6. s 7. s " t 8. t Reason Premise Simplification using (1) Premise Modus Tollens (2) & (3) Premise Modus Ponens (4) & (5) Premise Modus Ponens (6) & (7)

! !

Another Example
Given: Conclude:

p"q p " r r"s !

q " s

Proof of Another Example


Step 1. p " q 2. q " p 3. p " r 4. q " r 5. 6. Reason Premise Implication law (1) Premise Hypothetical syllogism of (2) & (3) Premise Hypothetical syllogism of (4) & (5)

r"s
q " s

! !

Proof by Rules of Inference (Example)


Prove: (p(pq)) (pq)

(p(pq)) p (pq) p ((p)q) p(pq) (pp) (pq) F (pq) (pq) F (pq)

n n n n n n n

By 2nd DeMorgans By 1st DeMorgans By double negation By 2nd distributive By definition of By commutative law By definition of

Potrebbero piacerti anche