MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft
description
Transcript of MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft
![Page 1: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/1.jpg)
MATH 213 A – Discrete Mathematics for Computer Science
Dr. (Mr.) Bancroft
![Page 2: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/2.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/3.jpg)
1.1 Logic
Logic-
Proposition-
• Notation:
• Negation:
![Page 4: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/4.jpg)
Truth Tables
![Page 5: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/5.jpg)
Conjunction of p and q:
Disjunction of p and q:
![Page 6: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/6.jpg)
Exclusive or:
Implication/Conditional:
Biconditional:
![Page 7: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/7.jpg)
![Page 8: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/8.jpg)
Operations on Implications:
Converse:
Contrapositive:
Inverse:
![Page 9: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/9.jpg)
More complicated truth tables
![Page 10: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/10.jpg)
Logic and Bit Operators
![Page 11: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/11.jpg)
1.2 Propositional Equivalences (Several Definitions):
Compound proposition-
Tautology-
Contradiction-
Contingency-
![Page 12: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/12.jpg)
Logical Equivalence
![Page 13: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/13.jpg)
Using Truth Tables to Demonstrate Logical Equivalence
![Page 14: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/14.jpg)
Show that and are logically equivalent.
![Page 15: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/15.jpg)
Some Commonly used Logical Equivalences
![Page 16: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/16.jpg)
Other Commonly used Logical Equivalences
![Page 17: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/17.jpg)
De Morgan’s Laws
![Page 18: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/18.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/19.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/20.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/21.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/22.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/23.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/24.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/25.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/26.jpg)
Looping to Determine the Truth of a Quantified Statement
![Page 27: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/27.jpg)
Free and Bound Variables
“Scope” of a quantifier
![Page 28: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/28.jpg)
Relationship with Conjunction and Disjunction
![Page 29: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/29.jpg)
Negating a Quantified Statement
![Page 30: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/30.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/31.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/32.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/33.jpg)
Section 1.4 – Nested Quantifiers
)())1(0(
yyxyxxyyxx
Examples:
Order of quantification matters!Example: M(x,y) = “x is y’s mother”
),(),(yxyMxyxxMy
![Page 34: MATH 213 A – Discrete Mathematics for Computer Science Dr. ( Mr.) Bancroft](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/34.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022062310/5681607d550346895dcfa652/html5/thumbnails/35.jpg)
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”