1.1 - 1.4 (first set)

advertisement
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.
1.1 Logic
Logic-
Proposition•
Notation:
•
Negation:
Truth Tables
Conjunction of p and q:
Disjunction of p and q:
Exclusive or:
Implication/Conditional:
Biconditional:
𝒑
𝒒
𝒑⊕𝒒
𝒑→𝒒
𝒑↔𝒒
Operations on Implications:
Converse:
Contrapositive:
Inverse:
More complicated truth tables
𝑝
𝑞
¬𝑝
𝑝→𝑞
¬𝑝 ∧ 𝑞
(𝑝 → 𝑞) ∨ (¬𝑝 ∧ 𝑞)
Logic and Bit Operators
1.2 Propositional Equivalences (Several Definitions):
Compound proposition-
Tautology-
Contradiction-
Contingency-
Logical Equivalence
Using Truth Tables to Demonstrate
Logical Equivalence
𝑝
𝑞
𝑝∨𝑞
𝑝∧𝑞
𝑝 ∨ (𝑝 ∧ 𝑞)
Show that 𝑝 → 𝑞 ∧ 𝑝 → 𝑟 and 𝑝 → (𝑞 ∧ 𝑟) are logically
equivalent.
𝑝
𝑞
𝑟
𝑝→𝑞
𝑝→𝑟
(𝑝 → 𝑞) ∧ (𝑝 → 𝑟)
𝑝 → (𝑞 ∧ 𝑟)
Some Commonly used Logical Equivalences
Other Commonly used Logical Equivalences
De Morgan’s Laws
Let’s revisit the knight and knave problem:
A says “I am a knave or B is a knight.”
B says nothing.
Arguments using logical equivalence
“Chain” of equivalences (recall the way you proved trig identities)
Examples:
1. Prove ¬ 𝑝 → 𝑞 → ¬𝑞 is a tautology.
2. Show that 𝑝 → 𝑞 ∧ 𝑝 → 𝑟 and 𝑝 → (𝑞 ∧ 𝑟) are logically
equivalent (again), this time using equivalences from the tables.
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?
1.3 – Predicates and Quantifiers
Is “𝑥 > 3” a proposition?
Predicates, or Propositional functions
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):
The Universal Quantifier
The 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)
The Existential Quantifier
The existential quantification of the predicate P(x) is the
proposition which states that…
In symbols,
Example: (Let the universe of discourse be all people)
Looping to Determine the Truth of a
Quantified Statement
Free and Bound Variables
“Scope” of a quantifier
Relationship with Conjunction and
Disjunction
Negating a Quantified Statement
Translating into English Sentences
P(x) = “x likes to fly kites”
Q(x,y) = “x knows y”
x (Q( Joan, x)  P( x))
L(x,y) = “x likes y”
x ( L( Susie, x)  L( x, Calvin))
Translating from English Sentences
“All cats are gray”
“There are pigs which can fly”
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)
Section 1.4 – Nested Quantifiers
Examples:
x( x  0  y ( xy  1))
xy ( x  y  y )
Order of quantification matters!
Example: M(x,y) = “x is y’s mother”
yxM ( x, y )
xyM ( x, y )
Another Example
Translate each of these, where M is as above and S(x) =
“x is a student” …
y ( S ( y )  xM ( x, y ))
yx( S ( y )  M ( x, y ))
English to First-Order Logic
Let L(x,y) = “x loves y”. Translate…
“Everybody loves somebody.”
“There are people who love everybody”
“All students love each other”
Download