Professional Documents
Culture Documents
Discrete Mathematics
VO TRI THUC
1
Chapter 1. Logic
- Propositional logic
- Propositional Equivalences
2
Chapter 1. Logic
- Propositional logic
- Propositional Equivalences
3
Propositions
Definition: A proposition is a declarative sentence
that is either true or false, but not both
Examples:
True
2+3=5
False
3*4=10
4
Proposition (cont.)
The conventional letters used for propositional
variables are p, q, r, s,…..
5
Which sentences are
proposition?
Close the door, please! Not Proposition
Read this carefully. Not Proposition
I like the course of Discrete Mathematics Proposition
Today, Cantho university closes. Proposition
2+3=5. Proposition
x+5=3, x∈R. Not Proposition
6
Proposition (Cont.)
Classify types of propositions:
One proposition: true or false.
Examples:
◦ 2 is the prime number
◦ 2 isn’t the prime number
Compound propositions: are formed from existing
propositions using logical operators.
Examples:
◦ An is watching television or he is studying math's.
◦ If I have 1000 $ then I’ll buy a new computer.
7
Logical Operators
Negation: Let p be a proposition. The negation of p,
denoted by ¬P, P is the statement “It is not the case that p”
Truth table
Example:
P ¬P
P= “2 > 0”
0 1
¬P= “2 ≤ 0”
1 0
8
Logic Operators (cont.)
Conjunction: Let p and q be propositions. The conjunction
of p and q, denoted PQ, is proposition “p and q”
Truth table
Example:
P Q PQ True
P=“2>0”
0 0 0
0 1 0 Q=“2=0” False
1 1 1
9
Logic Operators (cont.)
Disjunction: Let p and q be propositions. The disjunction of
p and q, denoted P Q, is proposition “p or q”
Truth table:
Example:
P Q PQ P=“2>0” True
0 0 0
Q=“2=0” False
0 1 1
1 0 1 P Q = “2>0 or 2=0” True
1 1 1
10
Logic Operators (cont.)
Exclusive (Xor): Let p and q be propositions. The exclusive or
of p and q, denoted by PQ, is the proposition that is true
when exactly one of p and q is true and is false otherwise.
Truth table: Example:
11
Logic Operators (cont.)
Conditional statement: Let p and q be propositions. The
conditional statement PQ is the proposition “if p, then q”
Truth table: Example:
Let P, Q are propositions
P Q PQ
P = you do 100% correctly on the
0 0 1
0 1 1 final exam
1 0 0 Q = you will get an A
1 1 1
Proposition P Q ?
12
Some ways
to express the conditional statement
If p, then q p implies q
If p, q p only if q
p is sufficient for q A sufficient condition for q is p
q if p q whenever p
q when p q is necessary for p
A necessary condition for p is q q follows from p
13
Logic Operators
Converse, contrapositive, and inverse
◦ Conditional statement: P Q:
◦ Q P: converse
◦ ¬Q ¬P: contrapositive
◦ ¬P ¬Q: inverse
Example:
Conditional statement: If it is raining, then the home team wins.
Contrapositive: If the home team doesn’t win, then it is not raining.
Converse: If the home team wins, then it is raining.
Inverse: If it is not raining, then the home team does not win.
14
Logic operators
Biconditional statement: Let p and q be propositions. The
biconditional statement PQ is the proposition “p if and
only if q”
Truth table:
P Q = (P Q) (Q P)
P Q PQ
0 0 1
0 1 0
1 0 0
1 1 1
15
Compound proposition
Let P, Q, R,... be propositions. We can use logical operators to build up
complicated compound propositions involving any number of
propositional variables.
Attention:
- A proposition is also a compound proposition.
- Let P be a compound proposition the ¬P is also a compound
proposition.
-The truth values of the compound proposition for each combination of
truth values of the propositional variables in it is found in the final
column of the table.
16
Truth table of
Compound Propositions
Example: Construct the truth table of ¬P (Q R )
P Q R ¬P QR ¬P (Q R)
17
Truth table of
Compound Propositions
Example: Construct the truth table of ¬P (Q R )
P Q R ¬P QR ¬P (Q R)
0 0 0 1 0 1
0 0 1 1 0 1
0 1 0 1 0 1
0 1 1 1 1 1
1 0 0 0 0 0
1 0 1 0 0 0
1 1 0 0 0 0
1 1 1 0 1 1
18
Translating English Sentences
You can access the Internet from campus only if you are a
computer science major or you are not a freshman.
( a (c ¬f))
19
Translating English Sentences
You cannot ride the roller coaster if you are under 4 feet tall
unless you are older than 16 years old.
(r ¬s) ¬q
20
Translating English Sentences
" If Michelle wins the Olympics, everyone will admire her,
and she will become rich. But, if she doesn't win, she will
lose everything."
W: Michelle wins the Olympics
A: everyone will admire her
R: she will become rich
L: she will lose everything
( W (A R)) (¬W L)
21
Compound propositions
If Michelle wins the Olympics, everyone will admire
her, and she will become rich. But, if she doesn't win,
she will lose everything.
If Michelle wins the Olympics, If she doesn't win, she will lose
AND
everyone will admire her, and she everything.
will become rich.
her rich.
22
Logic and Bit Operations
Example: Find the bitwise OR, AND, XOR of the bit strings
01 10 11 01 10
01101 10110
11000 11101
11101 11111 OR bit
01000 10100 AND bit
10101 01011 XOR bit
23
Chapter 1. Logic
- Propositional logic
- Propositional Equivalences
24
Propositional Equivalences
Tautology: a compound proposition is always true
Example: ¬P P P ¬P ¬P P
0 1 1
1 0 1
25
Propositional Equivalences
Contingency: A compound proposition is neither a
tautology nor a contradiction.
Example: (P Q ) (¬Q)
26
Propositional Equivalences
Contingency: A compound proposition is neither a
tautology nor a contradiction.
Example: (P Q ) (¬Q)
P Q ¬Q P Q (P Q ) (¬Q)
27
Propositional Equivalences
Contingency: A compound proposition is neither a
tautology nor a contradiction.
Example: (P Q ) (¬Q)
P Q ¬Q P Q (P Q ) (¬Q)
0 0 1 0 1
0 1 0 0 0
1 0 1 0 1
1 1 0 1 1
28
Logical consequence
Logical consequence: Let F and G be compound
propositions. G is logical consequence of F, if F G is
tautology.
Notation: F G
Example: Let two compound propositions:
F=(PQ)(QR)
G=PR
Show G is logical consequence of F?
29
Example: Let two compound propositions:
F=(PQ)(QR)
G=PR
Show G is logical consequence of F?
30
Example: Let two compound propositions:
F=(PQ)(QR)
G=PR
Show G is logical consequence of F?
31
Logical Equivalences
Definition: Compound propositions that have the
same truth values in all possible cases are called
logical equivalences
Example: Let F = P(QR)
G = (PQ) (PR)
Show F and G are logical equivalences?
32
Example: Let two compound propositions:
F = P(QR) G = (PQ) (PR)
Show F and G are logical equivalences?
33
Example: Let two compound propositions:
F = P(QR) G = (PQ) (PR)
Show F and G are logical equivalences?
34
Logical Equivalences
Let two compound propositions:
F=PQ G = ¬P Q
Show F and G are logical equivalences?
P Q PQ ¬P ¬P Q FG
0 0 1 1 1 1
0 1 1 1 1 1
1 0 0 0 0 1
1 1 1 0 1 1
35
Logical Equivalences
T= tautology, F = contradiction
P T T
Domination laws
P F F
P T P
Identity laws
P F P
P P P
Idempotent laws
P P P
36
Logical Equivalences
T= tautology, F = contradiction
P P T
Negation laws
P P F
P Q Q P
Commutative laws
P Q Q P
P Q R ( P Q) R P (Q R)
Associative laws
P Q R ( P Q) R P (Q R)
P (Q R ) (P Q) (P R )
Distributive laws
P (Q R ) (P Q) (P R ) 37
Logical Equivalences
T= tautology, F = contradiction
P Q P Q
De Morgan’s law
P Q P Q
P ( P Q ) P
Absorption laws
P ( P Q ) P
38
Applications
Writing
Speaking
Mathematics
Programming
39
Applications
Example1: Programming
◦ if (0<x<10 || x==10) x++;
Solution:
◦ if ( x>0 && x < = 10 ) x++;
40
Applications
Example 2: Show Q P ( P Q) and Q are logical
equivalences ?
Q P ( P Q) Q
Q P ( P Q) Q P ( P Q)
(Q P) ( P Q)
Q ( P P)
Q T
Q
41
Chapter 1. Logic
- Propositional logic
- Propositional Equivalences
42
Predicates
Definition: A predicate is P(x, y, ...), when x, y… are
variables in particular domains
◦ P(x,y,...) is not a proposition
◦ Once a value has been assigned to the variable x, the statement P(x)
is a proposition
◦ P(x, y,..) is also called a propositional function.
Example: P(x) = {x>3}, xR
◦ x = 4: {4>3}: True
◦ x = 2: {2>3}: False
43
Predicates
Example: Let Q(x, y) denote the statement “x=y+3”.
What are the truth values of the propositions Q(1, 2)
and Q(3, 0)?
Solution:
44
Predicate Operators
Let P(x), Q(x) be two predicates.
◦ Negation ¬P(x)
◦ Conjunction P(x) Q(x)
◦ Disjunction P(x) Q(x)
◦ Exclusive P(x) Q(x)
◦ Conditional Statement P(x) Q(x)
◦ Biconditional Statement P(x) Q(x)
45
Predicate Operators
Example 1: Express the statement: « If two people like a person,
they don’t like each other" as a logical expression involving
predicates and connectives:
Solution:
◦ « John likes Marry » => like (John, Marry).
◦ « Kelvin likes Marry » => like (Kelvin, Marry).
◦ like (X, Z) AND like (Y, Z) NOT like (X, Y) AND NOT like
(Y,X)
◦ (like(X, Z) like(Y, Z))(¬ like(X, Y)¬ like(Y, X))
46
Quantifiers
Universal quantification of P(x) is the statement
“P(x) for all values of x in the domain”
We use the notation x P(x) for universal quantification of P(x)
Example 1: Let P(x) be the statement “x+1>x”. What is the
truth value of the quantification x P(x) where the domain
consists of all real numbers?
x P(x) is TRUE
47
Quantifiers
Universal quantification of P(x) is the statement
“P(x) for all values of x in the domain”
We use the notation x P(x) for universal quantification of P(x)
Example 2: Let Q(x) be the statement “x<2”. What is the truth
value of the quantification x Q(x) where the domain consists
of all real numbers?
x Q(x) is FALSE
48
Quantifiers
Example: What is the truth value of x Q(x), where
is the statement “x2<10” and the domain consists
of the positive integers not exceeding 4?
49
Quantifiers
Existential quantification of P(x) is the proposition
“There exists an element x in the domain such that P(x)”
We use the notation x P(x) for existential quantification of P(x)
Example 1: Let P(x) denote the statement “x>3”. What is the
truth value of the quantification x P(x), where the domain
consists of all real number?
x P(x) is TRUE
50
Quantifiers
Existential quantification of P(x) is the proposition
“There exists an element x in the domain such that P(x)”
We use the notation x P(x) for existential quantification of P(x)
Example 2: Let Q(x) denote the statement “x=x+1”, What is the
truth value of the quantification x Q(x), where the domain
consists of all real number?
x Q(x) is FALSE
51
Quantifiers
Example: What is the truth value of x Q(x), where
is the statement “x2>10” and the domain consists
of the positive integers not exceeding 4?
52
Quantifiers
Statement When True? When False?
53
The Order of Quantifiers
Example: Let Q(x, y) denote { x+y=0}. What is the truth values
of the quantifications y,x, Q(x, y) and x, y, Q(x, y),
where the domain for all variables consists of all real
numbers?
Solution:
y,x, Q(x, y) denotes the proposition « There is a real
number y such that for every real number x, Q(x, y). => False
x, y, Q(x, y) denotes the proposition « For every real
number x there is a real number y such that, Q(x, y). => True
54
The Order of Quantifiers
55
Question
Finding the truth values “x P(x)”, “x P(x)”,
if the domain is empty
A. x P(x) = T, x P(x) = T,
B. x P(x) = T, x P(x) = F,
C. x P(x) = F, x P(x) = T,
D. x P(x) = F, x P(x) = F,
E. Cannot find the truth values
56
Quantifiers
Let P(a, b) be predicate with two variables a, b. When:
◦ ab P(a,b) ba P(a, b)
57
Logical Equivalences
De Morgan’s Laws for Quantifiers
Negation Equivalent When is Negation When False?
Statement True?
58
Logical Equivalences
Example: What is the negation of the statement “There
is an honest politician”?
Let H(x) denote “x is honest”
There is an honest politician: x H(x), the domain
consists of all politicians.
Negation: ¬x H(x) = x ¬H(x)
• Every politician is dishonest
• All politicians are not honest
• Not all politicians are honest
59
Logical Equivalences
Example: What is the negation of the statements “All
Americans eat cheeseburgers”?
Let C(x) denote “x eats cheeseburgers”
“All Americans eat cheeseburgers”: x C(x), the domain
consists of all Americans.
Negation: ¬ x C(x) = x ¬ C(x)
• Some American does not eat cheeseburgers
• There is an American who does not eat
cheeseburgers
60
Quantifiers
Theorem: Let P(x) and Q(x) be two predicates, that
have the same domain.
◦ x (P(x) Q(x)) (x (P(x) x (Q(x))
61
Translating from Logical Expression into English
Example: Translate the statement
x(C(x) y(C(y) F(x, y)))
Into English, where
C(x) is “x has a computer”
F(x, y) is “x and y are friends”
And the domain for both x and y consists of all students in
CT university.
62
Translating from Logical Expression into English
Example: Translate the statement
x(C(x) y(C(y) F(x, y)))
Into English, where
C(x) is “x has a computer”
F(x, y) is “x and y are friends”
And the domain for both x and y consists of all students in
CT university.
Solution: Every student in CT university has a computer or
has a friend who has a computer
63
Translating from Logical Expression into English
Example: Translate the statement
x y z((F(x, y) F(x, z) (yz)) F(y, z)
Into English, where
F(x, y) is “x and y are friends”
And the domain for both x, y, and z consists of all students
in CT university.
Solution: There is a student none of whose friends are also
friends with each other
64
Translating from English into Logical Expression
Express the statement: «If a person is female and is a
parent, then this person is someone’s mother» as a
logical expression involving predicates, quantifiers with a
domain consisting of all people, and connectives:
Solution: F(x) = "x is female"
P(x) = "x is a parent"
M(x, y) = "x is mother of y"
x (F(x) P(x)) y M(x,y)
65
Translating from English into Logical Expression
Consider these statements:
◦ “All lions are fierce".
◦ “Some lions do not drink coffee".
◦ “Some fierce creatures do not drink coffee".
Solutions:
Let: P(x)= {x is a lion}
Q(x)= {x is fierce}
R(x)= {x drinks coffee}
The domain consists of all creatures
67
68