35
MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Embed Size (px)

Citation preview

Page 1: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

MATH 213 A – Discrete Mathematics for Computer Science

Dr. (Mr.) Bancroft

Page 2: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

The inhabitants of the island created by Smullyan are peculiar. They consist of knights and knaves. Knights always tell the truth and knaves always lie. You encounter two people A and B. Determine, if possible, what A and B are (either a knight or a knave) from the way they address you.

A says “I am a knave or B is a knight.”

B says nothing.

Page 3: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

1.1 Logic

Logic-

Proposition-

• Notation:

• Negation:

Page 4: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Truth Tables

Page 5: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Conjunction of p and q:

Disjunction of p and q:

Page 6: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Exclusive or:

Implication/Conditional:

Biconditional:

Page 7: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft
Page 8: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Operations on Implications:

Converse:

Contrapositive:

Inverse:

Page 9: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

More complicated truth tables

Page 10: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Logic and Bit Operators

Page 11: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

1.2 Propositional Equivalences (Several Definitions):

Compound proposition-

Tautology-

Contradiction-

Contingency-

Page 12: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Logical Equivalence

Page 13: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Using Truth Tables to Demonstrate Logical Equivalence

Page 14: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Show that and are logically equivalent.

Page 15: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Some Commonly used Logical Equivalences

Page 16: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Other Commonly used Logical Equivalences

Page 17: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

De Morgan’s Laws

Page 18: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Let’s revisit the knight and knave problem:

A says “I am a knave or B is a knight.”B says nothing.

Page 19: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Arguments using logical equivalence“Chain” of equivalences (recall the way you proved trig identities)Examples:

1. Prove is a tautology.

Page 20: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

2. Show that and are logically equivalent (again), this time using equivalences from the tables.

Page 21: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Using a Computer to Find Tautologies

Practical only with small numbers of propositional variables.

How many rows does the truth table contain for a compound proposition containing 3 variables?

5 variables?

10 variables?

100 variables?

Page 22: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

1.3 – Predicates and Quantifiers

Is “” a proposition?

Predicates, or Propositional functions

Page 23: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Note that if x has no meaning, then P(x) is just a form.

The domain of x is …

There are two ways to give meaning to a predicate P(x):

Page 24: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

The Universal QuantifierThe universal quantification of the predicate P(x) is the proposition which states that…

In symbols,

Example: (Let the domain of discourse be all real numbers)

Page 25: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

The Existential QuantifierThe existential quantification of the predicate P(x) is the proposition which states that…

In symbols,

Example: (Let the universe of discourse be all people)

Page 26: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Looping to Determine the Truth of a Quantified Statement

Page 27: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Free and Bound Variables

“Scope” of a quantifier

Page 28: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Relationship with Conjunction and Disjunction

Page 29: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Negating a Quantified Statement

Page 30: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Translating into English Sentences

P(x) = “x likes to fly kites”Q(x,y) = “x knows y”

))(),(( xPxJoanQx

L(x,y) = “x likes y”

)),(),(( CalvinxLxSusieLx

Page 31: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Translating from English Sentences“All cats are gray”

“There are pigs which can fly”

Page 32: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Logic Programming

sibling(X,Y) :- parent(Z,X), parent(Z,Y), X \= Y.brother(X,Y) :- sibling(X,Y), male(X).sister(X,Y) :- sibling(X,Y), female(X).male(chris).male(mark).female(anne).female(erin).female(jessica).female(tracy).parent(chris,mark).parent(anne,mark).parent(chris,erin).parent(anne,erin).parent(chris,jessica).parent(anne,jessica).parent(chris,tracy).parent(anne,tracy).

?sibling(erin,jessica)?sibling(mark,chris)

?parent(Z,tracy)

Page 33: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Section 1.4 – Nested Quantifiers

)(

))1(0(

yyxyx

xyyxx

Examples:

Order of quantification matters!Example: M(x,y) = “x is y’s mother”

),(

),(

yxyMx

yxxMy

Page 34: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

Another Example

)),()((

)),()((

yxMySxy

yxxMySy

Translate each of these, where M is as above and S(x) = “x is a student” …

Page 35: MATH 213 A – Discrete Mathematics for Computer Science Dr. (Mr.) Bancroft

English to First-Order LogicLet L(x,y) = “x loves y”. Translate…

“Everybody loves somebody.”

“There are people who love everybody”

“All students love each other”