Vous êtes sur la page 1sur 7

10/29/12

Discrete Math Review


n

Discrete Math Review


(Rosen, Chapter 1.1 1.6)

TOPICS
Propositional Logic
Logical Operators
Truth Tables
Implication
Logical Equivalence
Inference Rules

10/1/12

A proposition is a statement that is either true


or false
Examples:
n
n
n

10/1/12

n
n
n

Fort Collins is in Nebraska (false)


Java is case sensitive (true)
We are not alone in the universe (?)

n
n
n

Every proposition is true or false, but its truth


value may be unknown

CS160 Fall Semester 2012

CS160 Fall Semester 2012

Logical Operators

Propositional Logic
n

What you should know about propositional


and predicate logic before the next midterm!
Less theory, more problem solving, will be
repeated in recitation and homework.

10/1/12

logical not (negation)


logical or (disjunction)
logical and (conjunction)
logical exclusive or
logical implication (conditional)
logical bi-implication (biconditional)

CS160 Fall Semester 2012

10/29/12

Truth Tables

Compound Propositions
n

pq

p q

(1) You should be able to write out the truth


table for all logical operators, from memory.

10/1/12

CS160 Fall Semester 2012

10/1/12

English to Propositional Logic


n

10/1/12

(2) You should be able to make a truth table


for any compound proposition:
p

pq

p (pq)

T
T
F
F

T
F
T
F

F
F
T
T

T
F
T
T

F
F
T
T

CS160 Fall Semester 2012

Propositional Logic to English

(3) You should be able to translate natural


language to logic (can be ambiguous!):
English:
If the car is out of gas, then it will stop
Logic:
p equals the car is out of gas
q equals the car will stop
pq
CS160 Fall Semester 2012

Propositions and operators can be


combined into compound propositions.

10/1/12

(4) You should be able to translate


propositional logic to natural language:
Logic:
p equals it is raining
q equals the grass will be wet
pq
English:
If it is raining, the grass will be wet.
CS160 Fall Semester 2012

10/29/12

Logical Equivalences: Definition


n

10/1/12

Logical Equivalences: Truth Tables


n

Certain propositions are equivalent (meaning


they share exactly the same truth values):
For example:
(p q) p q
De Morgans
(p T) p
Identity Law
(p p) F
Negation Law

CS160 Fall Semester 2012

10/1/12

Logical Equivalences: Review


n

10/1/12

(5) And you should know how to prove logical


equivalence with a truth table
For example: (p q) p q

p q (p q) (p q)

p q

CS160 Fall Semester 2012

10

Logical Equivalences (Rosen)

(6) You should understand the logical


equivalences and laws on the course web site.
You should be able to prove any of them using
a truth table that compares the truth values of
both sides of the equivalence.
Memorization of the logical equivalences is not
required in this class.

CS160 Fall Semester 2012

11

10/1/12

CS160 Fall Semester 2012

12

10/29/12

Transformation via Logical


Equivalences

Vocabulary

(7) You should be able to transform propositions


using logical equivalences.

Prove: p (p q) (p q)
p (p q) (p p) (p q)
T (p q)
(p q)
(p q)

n
n
n
n

Distributive law
Negation law
Domination law
De Morgans Law
n

10/1/12

CS160 Fall Semester 2012

13

(8) You should memorize the following


vocabulary:
n A tautology is a compound proposition that is
always true.
n A contradiction is a compound proposition
that is always false.
n A contingency is neither a tautology nor a
contradiction.
And know how to decide the category for a
compound proposition.

10/1/12

CS160 Fall Semester 2012

Logical Proof

Examples
p

p p

p p

Result is always
true, no matter
what A is
Therefore, it is a
tautology
10/1/12

14

CS160 Fall Semester 2012

Result is always
false, no matter
what A is

Given a set of axioms


n Statements asserted to be true
Prove a conclusion
n Another propositional statement
In other words:
n Show that the conclusion is true
n whenever the axioms are true

Therefore, it is a
contradiction

15

10/1/12

CS160 Fall Semester 2012

16

10/29/12

Logical Proof
n

10/1/12

Method 1: Proof by Truth Table

(9) You should be able to perform a logical


proof via truth tables.

(10) You should be able to perform a logical


proof via inference rules.
Both methods are described in the following
slides.

CS160 Fall Semester 2012

17

Prove that p q, given p


p

pq

10/1/12

A rule of inference is a proven relation: when


the left hand side (LHS) is true, the right
hand side (RHS) is also true.
Therefore, if we can match an axiom to the
LHS by substituting propositions, we can
assert the (substituted) RHS

Example rule: p, pq q
n
n

19

10/1/12

Read as p and pq, therefore q


This rule has a name: modus ponens

If you have axioms r, rs

CS160 Fall Semester 2012

18

Applying rules of inference

10/1/12

Thus the
conclusion
follows from
axiom

CS160 Fall Semester 2012

Method 2: Proof using Rules of


Inference
n

For all rows in


which axiom is
true, conclusion
is true

Substitute r for p, s for q


Apply modus ponens
Conclude s

CS160 Fall Semester 2012

20

10/29/12

Modus Ponens

Modus Tollens

If p, and p implies q, then q


Example:
p = it is sunny, q = it is hot
p q, it is hot whenever it is sunny
Given the above, if it is sunny, it must
be hot.

If not q and p implies q, then not p


Example:
p = it is sunny, q = it is hot
p q, it is hot whenever it is sunny
Given the above, if it is not hot, it
cannot be sunny.

10/1/12

CS160 Fall Semester 2012

21

10/1/12

Rules of Inference (Rosen)

CS160 Fall Semester 2012

22

A Simple Proof: Problem Statement


Example of a complete proof using inference rules,
from English to propositional logic and back:
n

n
10/1/12

CS160 Fall Semester 2012

23

If you dont go to the store, then you cannot not


cook dinner. (axiom)
If you cannot cook dinner or go out, you will be
hungry tonight. (axiom)
You are not hungry tonight, and you didnt go to
the store. (axiom)
You must have gone out to dinner. (conclusion)

10/1/12

CS160 Fall Semester 2012

24

10/29/12

A Simple Proof: Logic Translation

A Simple Proof: Applying Inference

p: you go to the store


q: you can cook dinner
r: you will go out
s: you will be hungry
AXIOMS: p q, (q r) s, s, p

CONCLUSION: r

n
n
n
n
n
n

p q, (q r) s, s, p



p, p q q
modus ponens
s, (q r) s q r

modus tollens
q, q r r
disjunctive syllogism
CONCLUSION: r
You must have gone out to dinner!

10/1/12

CS160 Fall Semester 2012

25

10/1/12

Predicate Logic
n

(11) You should recognize predicate logic

Quantification express the extent to which a


predicate is true over a set of elements:
n Universal , for all
n Existential , there exists

(12) You should able to translate between


predicate logic and English, in both directions.

10/1/12

CS160 Fall Semester 2012

26

Predicate Logic (contd)

symbols, i.e. quantifications.


n

CS160 Fall Semester 2012

27

Specifies a proposition (and optionally a


domain), for example:
n

x N, -10 < x < -5

// False, since no negative x

x N, x > -1

// True, since no negative x

Predicate logic has similar equivalences and


inference rules (De Morgans):
n

x: P(x) = x : P(x) // True for all = false for none

x: P(x) = x : P(x) // Not true for all = false for some

10/1/12

CS160 Fall Semester 2012

28

Vous aimerez peut-être aussi