Discrete Mathematics

33
Discrete Mathematics Logic

description

Discrete Mathematics. Logic. Propositions. A proposition is a statement or sentence that can be determined to be either true or false (but no both). Examples: The only positive integers that divide 7 are 1 and 7 itself. Buy two tickets for Friday concert. - PowerPoint PPT Presentation

Transcript of Discrete Mathematics

Page 1: Discrete Mathematics

Discrete Mathematics

Logic

Page 2: Discrete Mathematics

Propositions A proposition is a statement or sentence

that can be determined to be either true or false (but no both).

Examples: The only positive integers that divide 7 are 1 and

7 itself. Buy two tickets for Friday concert. Earth is the only planet in the universe that

contains life.

Page 3: Discrete Mathematics

Example Use variable to represent propositions

P: 1+1=3

P: It is raining outside

P: Today is Tuesday

Page 4: Discrete Mathematics

ConnectivesIf p and q are propositions, new compound

propositions can be formed by using connectives

Most common connectives: Conjunction ^ Disjunction Negation ~ Exclusive-OR v Condition Bi-Condition

Page 5: Discrete Mathematics

Example P: It is raining Q: It is cold

Form a new compound statement by combining these two statements

P Q : It is raining and it is cold P Q : It is raining or it is cold

Page 6: Discrete Mathematics

Truth table of conjunction The truth values of compound propositions

can be described by truth tables. Truth table of conjunction

P Q is true only when both Pp and Q are true.

P Q P QT T T

T F F

F T F

F F F

Page 7: Discrete Mathematics

Example

Let P = “A decade is 10 years” Let Q = “A millennium is 100 years” P Q = “A decade is 10 years” and “A

millennium is 100 years” If P is true and Q is false then conjunction

is false

Page 8: Discrete Mathematics

Truth table of disjunction The truth table of disjunction is

p q is false only when both p and q are false Example: p = "John is a programmer", q = "Mary is a lawyer" p v q = "John is a programmer or Mary is a lawyer"

P Q P QT T T

T F T

F T T

F F F

Page 9: Discrete Mathematics

Negation Negation of P: in symbols ~P

~P is false when P is true, ~P is true when P is false Example, P : "John is a programmer" ~P = "John is not a programmer"

P ~P

T F

F T

Page 10: Discrete Mathematics

E.g

P: Paris is the capital of England ~P: Paris is not capital of England

Page 11: Discrete Mathematics

Exclusive disjunction “Either P or Q” (but not both), in symbols P

Q

P Q is true only when P is true and Q is false, or P is false and Q is true. Example: p = "John is programmer, q = "Mary is a lawyer" p v q = "Either John is a programmer or Mary is a lawyer"

P Q P v Q

T T F

T F T

F T T

F F F

Page 12: Discrete Mathematics

More compound statements

Let p, q, r be simple statements We can form other compound statements,

such as (pq)^r p(q^r) (~p)(~q) (pq)^(~r) and many others…

Page 13: Discrete Mathematics

Example: truth table of (P Q)RP Q R (P Q) R

T T T T

T T F F

T F T T

T F F F

F T T T

F T F F

F F T F

F F F F

Page 14: Discrete Mathematics

Conditional propositions

A conditional proposition is of the form “If P then Q” In symbols: P Q Example:

P = " A bottle contains acid" Q = “A bottle has a label” P Q = “If a bottle contains acid then it has a

label "

Page 15: Discrete Mathematics

Truth table of P Q

P Q is true when both p and q are true or when P is false

P Q P Q

T T T

T F F

F T T

F F T

Page 16: Discrete Mathematics

Example If the mathematics department gets an

additional $40,000 then it will hire one new faculty member.

Let P: The Mathematics Department gets an additional $40,000 and Q: The mathematics Department will hire one new faculty member.

Page 17: Discrete Mathematics

Hypothesis and conclusion

In a conditional proposition P Q,

P is called the hypothesis

Q is called the conclusion

Page 18: Discrete Mathematics

Example For all real number x if x > 0 then x2 > 0

For example x=3 , 3 > 0 then 32 > 0 both are true.

x=-2 , -2 > 0 is false but -22 > 0

Page 19: Discrete Mathematics

Logical equivalence Two propositions are said to be logically equivalent if their truth tables are identical.

Example: ~P Q is logically equivalent to P Q

P Q ~P Q P Q

T T T T

T F F F

F T T T

F F T T

Page 20: Discrete Mathematics

Converse The converse of p q is q p

These two propositions

are not logically equivalent

p

q p q q p

T T T T

T F F T

F T T F

F F T T

Page 21: Discrete Mathematics

Contrapositive The contrapositive of the proposition p q is ~q

~p.

They are logically equivalent.

p q p q ~q ~p

T T T T

T F F F

F T T T

F F T T

Page 22: Discrete Mathematics

Bi-Conditional The double implication “p if and only if q” is

defined in symbols as p q

p q is logically equivalent to (p q)^(q p)

p q p q (p q) ^ (q p)

T T T T

T F F F

F T F F

F F T T

Page 23: Discrete Mathematics

Tautology A proposition is a tautology if its truth table

contains only true values for every case Example: p p v q

p q p p v q

T T T

T F T

F T T

F F T

Page 24: Discrete Mathematics

Contradiction A proposition is a tautology if its truth table

contains only false values for every case Example: p ^ ~p

p p ^ (~p)

T F

F F

Page 25: Discrete Mathematics

De Morgan’s laws for logic

The following pairs of propositions are logically equivalent:

~ (p q) and (~p)^(~q) ~ (p ^ q) and (~p) (~q)

Page 26: Discrete Mathematics

Quantifiers

A propositional function P(x) is a statement involving a variable x

For example: P(x): 2x is an even integer

x is an element of a set D For example, x is an element of the set of integers

D is called the domain of P(x)

Page 27: Discrete Mathematics

For every and for some

Most statements in mathematics and computer science use terms such as for every and for some.

For example: For every triangle T, the sum of the angles of T

is 180 degrees. For every integer n, n is less than p, for some

prime number p.

Page 28: Discrete Mathematics

Universal quantifier

One can write P(x) for every x in a domain D In symbols: x P(x)

is called the universal quantifier

Page 29: Discrete Mathematics

Inference Or Deduction An argument is a sequence of propositions

written as below : p1, p2 , p3 , p4 , p5 ,,…, , pn, therefore q.

(if p1v p2v,.., pn then q) or (if p1 ^p2 ^,.., pn then q)

the propositions p1, .., pn, are called hypotheses (premises) and proposition q is called conclusion (consequent).

The above argument is valid if the consequent can be proven from the premises.

Validity can be shown using truth table or by using theorems / rules.

Page 30: Discrete Mathematics

Rules of Inference Addition p , therefore p v q

(read as if we know p is true, therefore we know p or q is true)

Simplification

p ^ q , therefore p Conjunction

p , q , therefore p ^ q

Page 31: Discrete Mathematics

Rules of Inference (contd..) Modus Ponens p q , p, therefore q Modus Tollens ~ q, p q , therefore ~p Hypothetical Syllogism

p q, q r, therefore p r Disjunctive Syllogism p v q , ~ p, therefore q Resolution

p v q, ~ p v r , therefore q v r

Page 32: Discrete Mathematics

ExampleState which rule of inference is the basis of the

following argument :“ It is below freezing now. Therefore it is either

below freezing or raining now.”- addition rule

“It is below freezing and raining now. Therefore, it is below freezing now. “- simplification rule

“Rules : If it snows today, then we will go skiing”Fact : it snows today. Conclude: We will go skiing”

- modus ponens

Page 33: Discrete Mathematics

Problem

Show that the hypotheses : “ It is not sunny this afternoon and it is colder than

yesterday.”Will conclude :“We will be home by sunset “Given the following fact :“We will go swimming only if it is sunny. If we do

not go swimming, then we will take a canoe trip. If we take a canoe trip we will be home by sunset”