Discrete Structures Cấu Trúc Rời Rạc: TS Nguyễn Thị Huỳnh Trâm
Discrete Structures Cấu Trúc Rời Rạc: TS Nguyễn Thị Huỳnh Trâm
Definition (statement)
A statement (or proposition) is a
sentence that is true or false, but
not both.
Mệnh đề (kí hiệu là p, q, r…) là
các khẳng định có giá trị chân lý
xác định: đúng hoặc sai nhưng
không thể vừa đúng vừa sai
Statements (Mệnh đề)
A statement (or proposition) is a sentence that is true or false,
but not both.
Ex 1.
Ex 2.
-Các khẳng định dưới dạng tán thán hoặc mệnh lệnh không phải là mệnh
đề vì các câu này không có chân trị nhất định.
-Khẳng định “q: x khác 0” không phải là mệnh đề. Tuy nhiên nếu thay x
= 1 thì ta có mệnh đề đúng hoặc x =0 ta có mệnh đề sai. Khi đó khẳng
định này được gọi là vị từ.
Statements (Mệnh đề)
No solution 1 1
f 1,2 = + =0
1 2−3
Statements (mệnh đề nguyên thủy, mệnh đề sơ cấp): Không
được xây dựng từ các mệnh đề khác nhờ các liên từ hoặc trạng
từ KHÔNG (!, ¬)
Compound Statements
If x ≠ 0 and 𝑦 ≠ 3 then x = 1; y =2
1 1
f(x, 𝑦) = + statement
𝑥 𝑦−3
No solution 1 1
f 1,2 = + =0
1 2−3
Compound Statements (mệnh đề phức hợp): Là các mệnh đề
được xây dựng từ các mệnh đề khác nhờ liên từ kết chúng lại
như: Và (AND, ٿ ), Hay, Hoặc (OR, V), nếu…thì.. , trạng từ
KHÔNG (!, ¬, ~, NOT)
Compound Statements
If x ≠ 0 and 𝑦 ≠ 3 then x = 1; y =2
1 1
f(x, 𝑦) = + statement
𝑥 𝑦−3
No solution 1 1
f 1,2 = + =0
1 2−3
If ( true statement) Propositional Calculus (Phép tính
action 1 mệnh đề): nghiên cứu chân trị của các
else // false statement mệnh đề phức hợp
action 2
Logical connectives
1) Negation (Phép phủ định): If p is a statement variable, the
negation of p is “not p” or “it is not the case that p” and is
denoted ~p or p or ~p or !p
( Phủ định của mệnh đề p: “không” p hay “phủ định của” p).
Solution: .
The negation is
“It is not the case that Vandana’s smartphone has at least 32GB of
memory.”
This negation can also be expressed as
“Vandana’s smartphone does not have at least 32GB of memory”
or even more simply as
“Vandana’s smartphone has less than 32GB of memory.”
Logical connectives
1) Negation (Phép phủ định):
If x ≠ 0 and ! ( 𝑦 = 3) then x = 1; y =2
1 1 1 0
f(x, 𝑦) = +
𝑥 𝑦−3
Else If 1 ≠ 0 && ! (2 = 3)
If x=0 or y = 3 then
No solution 1
1 1
f 1,2 = + =0
1 2−3
Logical connectives
2) Conjunction (Phép “Và”): if p and q are statement variables,
the conjunction of p and q is “p and q”, denoted p q. It is true
when, and only when, both p and q are true. If either p and q is
false, or if both are false, p q is false.
Phép nối liền (và, hội, giao) của hai mệnh đề p, q được kí hiệu
bởi p q (đọc là “p và q”), là mệnh đề được xác định bởi : p q
đúng khi và chỉ khi p và q đồng thời đúng.
p q pq
Truth Table for p q 1 1 1
1 0 0
0 1 0
0 0 0
Logical connectives
Find the conjunction of the propositions p and q where p is the
proposition “Rebecca’s PC has more than 16 GB free hard disk
space” and q is the proposition “The processor in Rebecca’s PC
runs faster than 1 GHz.”
Solution:
Else 1 0
If x=0 or y = 3 then 0
No solution Else
If ( true statement)
action 1
else // false statement
action 2
Logical connectives
3. Disjunction (phép hoặc): If p and q are statement variable, the
disjunction of p and q is “p or q”, denoted p q. It is true when
either p is true, or q is true, or both and q are true; it is false only
when both p and q are false.
Phép hoặc (nối rời, tuyển, hợp) của hai mệnh đề p, q được kí
hiệu bởi p q (đọc là “p hay q”), là mệnh đề được định bởi : p
q sai khi và chỉ khi p và q đồng thời sai.
p q pq
Truth Table for p q 1 1 1
1 0 1
0 1 1
0 0 0
p q pq p q pq
Logical connectives 1 1 1 1 1 1
1 0 0 1 0 1
0 1 0 0 1 1
0 0 0 0 0 0
x = 1; y =3 1
If x ≠ 0 and ! ( 𝑦 = 3) then If 1 ≠ 0 && ! (3 = 3)
1 1
f(x, 𝑦) = + 1 0
𝑥 𝑦−3
0
Else Else
If x=0 or y = 3 then If x=0 || y = 3
No solution
0 1
1
No solution
p q pq p q pq
Logical connectives 1 1 1 1 1 1
1 0 0 1 0 1
0 1 0 0 1 1
0 0 0 0 0 0
p q pq p q pq
Logical connectives 1 1 1 1 1 1
1 0 0 1 0 1
0 1 0 0 1 1
0 0 0 0 0 0
Logical connectives
Inclusive-Or (HAY, OR) Exclusive-Or (p XOR q)(HOẶC)
( Phép nối rời , Phép tuyển) (Phép nối rời, Phép tuyển loại)
p q pq p q pq
𝐩 ⊕q
1 1 1 0 0 0
1 0 1 0 1 1
0 1 1 1 0 1
0 0 0 1 1 0
“Students who have taken calculus or computer science can
take this class.”
“Students who have taken calculus or computer science, but
not both, can enroll in this class.”
“Soup or salad comes with an entrée,”
Truth Table (Bảng chân trị)
The Truth Table for a given statement form displays the truth values that
correspond to all possible combinations of truth values for its component
statement variables
Bảng chân trị của dạng mệnh đề E(p,q,r): là bảng ghi tất cả các trường
hợp chân trị có thể xảy ra đối với dạng mệnh đề E theo chân trị của các
biến mệnh đề p, q, r.
p q r q∧r p∨(q∧r) p∨q (p∨q) ∧r
Nếu có n biến, bảng này sẽ có 2n 1
dòng, chưa kể dòng tiêu đề. 2
3
4
5
6
7
8
Truth Table
Bảng chân trị của 2 dạng mệnh đề p∨(q∧r) và (p∨q) ∧r
2 0 0 1
3 0 1 0
4 0 1 1 1
5 1 0 0
6 1 0 1
7 1 1 0
8 1 1 1 1
Truth Table p q pq
1 1 1
Bảng chân trị của 2 dạng mệnh đề p∨(q∧r) và (p∨q) ∧r
1 0 0
p q r q∧r p∨(q∧r) p∨q (p∨q) ∧r 0 1 0
1 0 0 0 0 0 0 0
2 0 0 1 0
3 0 1 0 0
4 0 1 1 1
5 1 0 0 0
6 1 0 1 0
7 1 1 0 0
8 1 1 1 1
Truth Table p q pq
1 1 1
Bảng chân trị của 2 dạng mệnh đề p∨(q∧r) và (p∨q) ∧r
1 0 0
p q r q∧r p∨(q∧r) p∨q (p∨q) ∧r 0 1 0
1 0 0 0 0 0 0 0
2 0 0 1 0 p q pq
3 0 1 0 0
1 1 1
4 0 1 1 1 1 0 1
5 1 0 0 0 0 1 1
6 1 0 1 0 0 0 0
7 1 1 0 0
8 1 1 1 1
Truth Table p q pq
1 1 1
Bảng chân trị của 2 dạng mệnh đề p∨(q∧r) và (p∨q) ∧r
1 0 0
p q r q∧r p∨(q∧r) p∨q (p∨q) ∧r 0 1 0
1 0 0 0 0 0
0 0 0
2 0 0 1 0 0 p q pq
3 0 1 0 0 0
1 1 1
4 0 1 1 1
1 0 1
5 1 0 0 0
0 1 1
6 1 0 1 0 0 0 0
7 1 1 0 0
8 1 1 1 1
Truth Table p q pq
1 1 1
Bảng chân trị của 2 dạng mệnh đề p∨(q∧r) và (p∨q) ∧r
1 0 0
p q r q∧r p∨(q∧r) p∨q (p∨q) ∧r
0 1 0
1 0 0 0 0 0
0 0 0
2 0 0 1 0 0
p q pq
3 0 1 0 0 0
4 0 1 1 1 1 1 1 1
1 0 1
5 1 0 0 0 1
0 1 1
6 1 0 1 0 1
0 0 0
7 1 1 0 0 1
8 1 1 1 1 1
Truth Table p q pq
1 1 1
Bảng chân trị của 2 dạng mệnh đề p∨(q∧r) và (p∨q) ∧r
1 0 0
0 1 0
p q r q∧r p∨(q∧r) p∨q (p∨q) ∧r 0 0 0
1 0 0 0 0 0 0 p q pq
2 0 0 1 0 0 0
1 1 1
3 0 1 0 0 0
1 0 1
4 0 1 1 1 1
0 1 1
5 1 0 0 0 1 0 0 0
6 1 0 1 0 1
7 1 1 0 0 1
8 1 1 1 1 1
Truth Table p q pq
1 1 1
Bảng chân trị của 2 dạng mệnh đề p∨(q∧r) và (p∨q) ∧r
1 0 0
p q r q∧r p∨(q∧r) p∨q (p∨q) ∧r 0 1 0
1 0 0 0 0 0 0
0 0 0
2 0 0 1 0 0 0 p q pq
3 0 1 0 0 0 1
1 1 1
4 0 1 1 1 1 1
1 0 1
5 1 0 0 0 1 1
0 1 1
6 1 0 1 0 1 1 0 0 0
7 1 1 0 0 1 1
8 1 1 1 1 1 1
Truth Table p q pq
1 1 1
Bảng chân trị của 2 dạng mệnh đề p∨(q∧r) và (p∨q) ∧r
1 0 0
0 1 0
p q r q∧r p∨(q∧r) p∨q (p∨q) ∧r 0 0 0
1 0 0 0 0 0 0 p q pq
2 0 0 1 0 0 0
1 1 1
3 0 1 0 0 0 1
1 0 1
4 0 1 1 1 1 1 1
0 1 1
5 1 0 0 0 1 1 0 0 0
6 1 0 1 0 1 1 1
7 1 1 0 0 1 1
8 1 1 1 1 1 1 1
Truth Table p q pq
1 1 1
Bảng chân trị của 2 dạng mệnh đề p∨(q∧r) và (p∨q) ∧r
1 0 0
0 1 0
p q r q∧r p∨(q∧r) p∨q (p∨q) ∧r 0 0 0
1 0 0 0 0 0 0 0 p q pq
2 0 0 1 0 0 0 0
1 1 1
3 0 1 0 0 0 1 0
1 0 1
4 0 1 1 1 1 1 1
0 1 1
5 1 0 0 0 1 1 0 0 0 0
6 1 0 1 0 1 1 1
7 1 1 0 0 1 1 0
8 1 1 1 1 1 1 1
Truth Table
Bảng chân trị của 2 dạng mệnh đề p∨(q∧r) và (p∨q) ∧r
Hai dạng mệnh đề p∨(q∧r) và (p∨q) ∧r có bảng chân trị khác nhau =>
Thứ tự thực hiện phép nối quan trọng và sự cần thiết của các dấu ()
Logically Equivalent (Tương đương logic)
Definition: Two statement forms are called logically equivalent
if, and only if, they have identical truth values for each possible
substitution of statements for their statement variables. The
logical equivalence of statement forms E and F is denoted by
writing 𝑬 ≡ 𝑭 or E⇔ F (Hai dạng mệnh đề E và F được nói là
tương đương logic nếu chúng có cùng bảng chân trị)
Ex p q pꓥq qꓥp
p ꓥ q and q ꓥ p always have the
0 0 0 0
same truth values, hence they
0 1 0 0 are logically equivalent.
1 0 0 0
1 1 1 1
Logically Equivalent (Tương đương logic)
p q pꓥq qꓥp
0 0 0 0
0 1 0 0
1 0 0 0
1 1 1 1
Logically Equivalent (Tương đương logic)
Definition: Two statement forms are called logically equivalent
if, and only if, they have identical truth values for each possible
substitution of statements for their statement variables. The
logical equivalence of statement forms E and F is denoted by
writing 𝑬 ≡ 𝑭 or E⇔ F (Hai dạng mệnh đề E và F được nói là
tương đương logic nếu chúng có cùng bảng chân trị)
Ex
0 0 1 1 0 1 1
0 1 1 0 0 1 0
1 0 0 1 0 1 0
1 1 0 0 1 0 0
Logically Equivalent (Tương đương logic)
Showing Non-equivalence
To show that statement forms P and Q are not logically equivalent,
there are 2 ways:
a) Truth table – find at least one row where their truth values differ.
b) Find a counter example – concrete statements for each of the
two forms, one of which is true and the other of which is false.
Ex: Show that the following 2 statement forms are not logically
equivalent.
“Not the case that both 0<1 and 1<0” which is TRUE
p t c pꓥt pꓥc
0 1 0 0 0
1 1 0 1 0
Summary of Logical Equivalences
Theorem 2.1.1 Logical Equivalence: Given any statement
variables p, q and r, a tautology t and a contradiction c:
Summary of Logical Equivalences
Theorem 2.1.1 Logical Equivalence: Given any statement
variables p, q and r, a tautology t and a contradiction c:
Ex: Use the laws in Theorem 2.1.1 to verify the following logical
equivalence:
Conditional Statements
Conditional (Implication, Phép kéo theo) If p and q are statement
variables, the conditional of q by p is “if p then q” or “p implies q”,
denoted p → q.
Representation of If-Then as Or
p → q ≡ ~p q
Negation of Conditional Statement
~(p → q) ≡ 𝐩 ~q
if p then q p→q “if p, then q”
Converse (Đảo) If q then p q→p “q whenever p”
“if p, q”
Contrapositive If not q then not p 𝑞ത → 𝑝ҧ
“p is sufficient for q”
(Phản đảo)
“q if p”
Inverse If not p then not q 𝑝ҧ → 𝑞ത “q when p”
“a necessary condition
for p is q”
What are the contrapositive, the converse, and the inverse of the
conditional statement “The home team wins whenever it is
raining?”
Solution: Because “q whenever p” is one of the ways to express
the conditional statement p → q, the original statement can be
rewritten as
“If it is raining, then the home team wins.”
Consequently, the contrapositive of this conditional statement is
“If the home team does not win, then it is not raining.”
if p then q p→q “if p, then q”
Converse (Đảo) If q then p q→p “q whenever p”
“if p, q”
Contrapositive If not q then not p 𝑞ത → 𝑝ҧ
“p is sufficient for q”
(Phản đảo)
“q if p”
Inverse If not p then not q 𝑝ҧ → 𝑞ത “q when p”
“a necessary condition
for p is q”
It is true if both p and q have the same truth values and is false if p and q
have opposite truth values.
Khi thay thế các biến x,y Khi thay thế các biến mệnh đề trong
trong hàm số bằng hằng số dạng mệnh đề bằng chân trị của các biến
(VD x =1, y=2) thì kết quả mệnh đề (VD p: 0, q: 0, r:1)thì kết quả
thực hiện các phép toán trong thực hiện các phép nối thao tác sẽ là
biểu thức sẽ là hằng số (VD chân trị của dạng mệnh đề (VD E(0,0,1)
f(1,2)=0) :
Độ ưu tiên các phép toán
1) Ngoặc ()
2) Phủ định
3) Và
4) Hay
5) Kéo theo →
6) Kéo theo hai chiều
Ví dụ:
1) p q →rhiểu là (p q) →r
2) p (q r) q hiểu là (p (q r)) (q)
Logically Equivalent (Tương đương logic)
p q p→q p q p↔q p q ¬p E: F:
p →qq→p p→q ¬ p∨q
0 0 1 0 0 1 0 0 1 1 1
0 1 1 0 1 0 0 1 1 1 1
1 0 0 1 0 0 1 0 0 0 0
1 1 1 1 1 1 1 1 0 1 1
Definition: Two statement forms are called logically equivalent if,
and only if, they have identical truth values for each possible
substitution of statements for their statement variables. The
logical equivalence of statement forms E and F is denoted by
writing 𝑬 ≡ 𝑭 or E⇔ F (Hai dạng mệnh đề E và F được nói là
tương đương logic nếu chúng có cùng bảng chân trị)
Logically Equivalent (Tương đương logic)
p q p→q p q p↔q p q ¬ p E: F:
p →qq→p p→q ¬ p∨q
0 0 1 0 0 1 0 0 1 1 1
0 1 1 0 1 0 0 1 1 1 1
1 0 0 1 0 0 1 0 0 0 0
1 1 1 1 1 1 1 1 0 1 1
Hai dạng mệnh đề p→q và ¬ p∨q có cùng bảng chân trị. Ta nói 2
mệnh đề này tương đương logic.
Note: Two statements are called logically equivalent if, and only if,
they have logical equivalent forms when identical component
statement variables are used to replace identical component
statements
Chú ý: Nếu E và F tương đương logic thì dạng mệnh đề E ⇔ F
luôn lấy giá trị là 1 dù các biến có lấy giá tri nào đi nữa.
Logically Equivalent
(Tương đương logic)
p q p→q p q p↔q p q ¬ p E: F: ¬
p →qq→p p→q p∨q
0 0 1 0 0 1 0 0 1 1 1
0 1 1 0 1 0 0 1 1 1 1
1 0 0 1 0 0 1 0 0 0 0
1 1 1 1 1 1 1 1 0 1 1
Hai dạng mệnh đề p→q và ¬ p∨q có cùng bảng chân trị. Ta nói 2
mệnh đề này tương đương logic.
Chú ý: Nếu E và F tương đương logic thì dạng mệnh đề E↔ F
luôn lấy giá trị là 1 dù các biến có lấy giá tri nào đi nữa.
Logically Equivalent (Tương đương logic)
11. Luật về phép kéo theo
p → q p q
q → p
Ví dụ: Nếu trời mưa thì đường trơn
Nếu đường không trơn thì trời không mưa
Use De Morgan’s laws to express the negations of “Miguel has a
cellphone and he has a laptop computer” and “Heather will go to the
concert or Steve will go to the concert.
Logically Equivalent (Tương đương logic)
Use De Morgan’s laws to express the negations of “Miguel has a
cellphone and he has a laptop computer”
Solution:
Let p be “Miguel has a cellphone” and
q be “Miguel has a laptop computer.”
Solution:
Let r be “Heather will go to the concert” and s be “Steve will go to the
concert.”
p → q ≡ 𝑝ҧ q
p → q ≡ p 𝑞ത
2. Luật De Morgan (p q) p q
(p q) p q
5. Luật phân phối p (q r) (p q) (p r)
p (q r) (p q) (p r)
11. Luật về phép kéo theo p → q p q
q → p
VD Cho p, q, r là các biến mệnh đề. Chứng minh rằng:
(p → r) (q→ r) (p → q) → r
Giải: (p → r) (q → r)
( p r ) ( q r) (luật 11. về phép kéo theo)
( p q ) r (luật phân phối)
( p q ) r (De Morgan)
( p → q ) r (luật 11. về phép kéo theo)
( p → q ) → r (luật 11. về phép kéo theo)
Phép chứng minh đảo đề
• Ứng dụng luật về phép kéo theo p → q q → p
• Để CM p → q đúng, ta CM q → p đúng.
• Ví dụ:
• Cho n là số tự nhiên. CM nếu n2 là số chẵn thì n là số chẵn.
• Ta CM nếu n là số lẻ thì n2 là số lẻ.