discrete structure - prince of songkla universitystaff.cs.psu.ac.th/sathit/344-281/01-logic.pdf ·...
TRANSCRIPT
![Page 1: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/1.jpg)
Discrete Structure
รศ.ดร. สาธต อนทจกร
![Page 2: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/2.jpg)
Goals of a Discrete Mathematics
• Mathematical Reasoning: to read, comprehend,
and construct math. arg.
– Logic, methods of proof
• Combinatorial Analysis:
– Counting problems
• Discrete Structures: to represent discrete objects
and relationships between objects
– Sets, permutations, relations, graphs, trees, and finite-
state machines
• Algorithmic Thinking:
– Both English and pseudocode
![Page 3: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/3.jpg)
Introduction to Discrete mathematics
• Discrete Mathematics (DM) เปนทฤษฎพนฐานทางเทคโนโลยทมประโยชนอยางมากในปจจบน
• ในการศกษาเพอใหเขาใจคอมพวเตอรทงสวนของฮารดแวรและซอฟตแวร ระบบการสอสาร การประมวลผลสญญาณ ทฤษฎสารสนเทศ ฯลฯ จ าเปนจะตองเรยนร DM
• นอกจากน DM ยงเปน Prerequisite(PR) ของคณตศาสตรและทฤษฎในศาสตรทางคอมพวเตอร ดงนนถาตองการทจะรศาสตรทางคอมพวเตอรอยางแทจรงจงจ าเปนจะตองศกษา DM ใหเขาใจอยางถองแท
![Page 4: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/4.jpg)
What exactly is DM?
• DM is mathematics that uses only
arithmetic and algebra, and does not involve
calculus.
• DM จะแปลกแยกออกมาจากแคลคลส ทใชอธบายการเปลยนแปลงของกระบวนการอยางตอเนอง ซงจะเปนแนวคดพนฐานทางวทยาศาสตรและเทคโนโลยในเชงการปฏวตทางดานอตสาหกรรม สวนแนวคดของ DM กมแนวคดพนฐานของวทยาศาสตรและเทคโนโลยเชนกน แตจะมงไปทางดานคอมพวเตอร
![Page 5: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/5.jpg)
For The Student
• PR ของวชานคอพชคณตของมธยมปลาย • For the students, the best way to study is to try to
do the homework problems before reading the texts, and to read the texts only when you get stuck.
• เอกสารประกอบการเรยน – แนวคดหลกมลทางคณตศาสตร(MA 201), คณตศาสตรทางดานวธการจดหม
(CO 233) มหาวทยาลยรามค าแหง – Mathematical Structures for Computer Science, Judith
L. Gersting [QA39.2G435m] – Discrete Mathematics and Its Applications, 5e, Rosen, McGrawHill, 2003,
[QA39.3 R67]
![Page 6: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/6.jpg)
ตรรกะ(Logic) เมอเรยนจบเรองตรรกะแลว นกศกษาจะตองสามารถ • มความรในการน าสญลกษณทางตรรกะไปใชงานในประพจนและพ
รดเคตลอจก • สามารถหาคาความจรงของนพจนในประพจนได • หาคาความจรงในการแปลความหมายของนพจนในพรดเคตลอจก
ได • สามารถพสจนประพจนและพรดเคตลอจกเพอก าหนด Validity
ได
![Page 7: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/7.jpg)
ประพจน (Propositions)
• ประโยคทสามารถก าหนดคาความจรง (Truth Values) ได ในตรรกคณตศาสตรจะเรยกประโยคประเภทนวา “ขอความ
(statement)” หรออาจจะเรยกวา “ประพจน(Proposition)”
• ประโยคทไมมคาความจรงจะไมเปนประพจน เชนประโยคค าถาม ประโยคขอรอง ประโยคค าสง
• ประโยคตอไปนขอใดเปนประพจน – จงตงใจเรยน – โลกกลม
– 2+2 = 5
![Page 8: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/8.jpg)
Propositional Logic
• Propositional Logic เปนตรรกของขอความหลายๆ ขอความทเกยวเนองกน (compound statements) โดยจะเรยกตรรกนวา Boolean connectives.
Some applications in computer science
• Design of digital electronic circuits.
• Expressing conditions in programs.
• Queries to databases & search engines.
George Boole
(1815-1864)
![Page 9: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/9.jpg)
นยามของประพจน นยาม: ประพจนใดๆ (มกจะแทนดวย p, q, r, …) กคอ: • ขอความ (สวนใหญแลวจะอยในรปของประโยค) ทมความหมาย
บางอยางและความหมายจะตองมความชดเจน
• และประพจนจะตองมคาความจรง (Truth value) โดยคาความจรงนจะมคาเปนจรง (true: T) หรอไมกเทจ (false:
F) โดยคาความจรงนจะตองมคาเพยงคาใดคาหนง คอไมจรงกเทจโดยไมมคา
ระหวางจรงกบเทจ ซงคาความจรงของขอความ มกจะขนอยกบสถานะการณหรอบรบท
และเมอเราไดศกษาทฤษฎความนาจะเปน จะมการก าหนดระดบของคาความจรงทอยระหวาง T กบ F แต ณ ตอนนในจ าไววาคาความจรงของประพจนมเพยงจรงกบเทจเทานน
![Page 10: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/10.jpg)
ตวเชอมตอขอความ (Logical Connectives)
• An operator or connective combines one or
more operand expressions into a larger
expression. (E.g., “+” in numeric exprs.)
– Unary operators take 1 operand (e.g., −3);
– binary operators take 2 operands (eg 3 4).
• Propositional or Boolean operators operate
on propositions (or their truth values) instead of on numbers.
![Page 11: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/11.jpg)
ตวด าเนนการบลนโดยทวไป
Formal Name Nickname Arity Symbol
Negation operator NOT Unary ¬,~
Conjunction operator AND Binary
Disjunction operator OR Binary
Exclusive-OR operator XOR Binary
Implication operator IMPLIES Binary
Biconditional operator IFF Binary ↔
![Page 12: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/12.jpg)
ตวด าเนนการปฏเสธ (Negation Operator)
The unary negation operator “¬” (NOT)
transforms a prop. into its logical negation.
E.g. If p = “I have brown hair.” then ¬p = “I
do not have brown hair.”
The truth table for NOT: T :≡ True; F :≡ False “:≡” means “is defined as”
p p
T F
F T
![Page 13: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/13.jpg)
ขอความรวม (Conjunctive Statements)
The binary conjunction operator “” (AND)
combines two propositions to form their
logical conjunction.
E.g. If
p=“I will have salad for lunch.” and
q=“I will have steak for dinner.”, then
pq=“I will have salad for lunch and I will have steak for dinner.”
ND
Remember: “” points up like an “A”, and it means “ND”
![Page 14: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/14.jpg)
ตารางคาความจรงของ AND
• Note that a conjunction p1 p2 … pn of n propositions will have 2n rows in its truth table.
• Remark. ¬ and operations together are sufficient to express any Boolean truth table!
p q pq
F F F
F T F
T F F
T T T
Operand columns
![Page 15: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/15.jpg)
ตวเชอมการเลอก (Disjunctive Operator)
The binary disjunction operator “” (OR)
combines two propositions to form their
logical disjunction.
p=“My car has a bad engine.”
q=“My car has a bad carburetor.”
pq=“Either my car has a bad engine, or
my car has a bad carburetor.”
After the downward-
pointing “axe” of “”
splits the wood, you
can take 1 piece OR the
other, or both.
Meaning is like “and/or” in English.
![Page 16: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/16.jpg)
ตารางคาความจรงของ OR
Note that pq means
that p is true, or q is
true, or both are true!
So, this operation is
also called inclusive or,
because it includes the
possibility that both p and q are true.
Remark.“¬” and “” together are also
universal.
p q pq
F F F
F T T
T F T
T T T
Note
difference
from AND
![Page 17: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/17.jpg)
ขอความมเงอนไข
Use parentheses to group sub-expressions:
“I just saw my old friend, and either he’s
grown or I’ve shrunk.” = f (g s)
(f g) s would mean something different
f g s would be ambiguous
By convention, “¬” takes precedence over
both “” and “”.
¬s f means (¬s) f , not ¬ (s f)
![Page 18: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/18.jpg)
A Simple Exercise
• Let
p=“It rained last night”,
q=“The sprinklers came on last night,”
r=“The lawn was wet this morning.”
• Translate each of the following into English:
• ¬p =
• r ¬p =
• ¬ r p q =
“It didn’t rain last night.” “The lawn was wet this morning, and
it didn’t rain last night.” “Either the lawn wasn’t wet this
morning, or it rained last night, or
the sprinklers came on last night.”
![Page 19: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/19.jpg)
The Exclusive Or Operator
The binary exclusive-or operator “” (XOR)
combines two propositions to form their logical “exclusive or” (exjunction?).
p = “I will earn an A in this course,”
q = “I will drop this course,”
p q = “I will either earn an A in this course, or I will drop it (but not both!)”
![Page 20: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/20.jpg)
ตารางคาความจรงของ Exclusive-Or
Note that pq means
that p is true, or q is
true, but not both!
This operation is
called exclusive or,
because it excludes the
possibility that both p and q are true.
Remark. “¬” and “” together are not universal.
p q pq
F F F
F T T
T F T
T T F Note
difference
from OR.
![Page 21: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/21.jpg)
ความคลมเครอในตรรกะของภาษาพด
Note that English “or” can be ambiguous regarding
the “both” case!
“Pat is a singer or
Pat is a writer.” -
“Pat is a man or
Pat is a woman.” -
Need context to disambiguate the meaning!
For this class, assume “or” means inclusive.
p q p "or" q
F F F
F T T
T F T
T T ?
![Page 22: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/22.jpg)
ขอความมเงอนไข
The implication p q states that p implies q.
i.e., If p is true, then q is true; but if p is not
true, then q could be either true or false.
E.g., let p = “You study hard.”
q = “You will get a good grade.”
p q = “If you study hard, then you will
get a good grade.” (else, it could go either way)
antecedent consequent
![Page 23: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/23.jpg)
ตารางคาความจรงของขอความมเงอนไข
p q is false only when p is true but q is not true.
p q does not say that p causes q!
p q does not require that p or q are ever true!
E.g. “(1=0) ox can fly” is TRUE!
p q pq
F F T
F T T
T F F
T T T
The
only
False
case!
![Page 24: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/24.jpg)
ตวอยางของขอความมเงอนไข
• “If this lecture ever ends, then the sun will rise tomorrow.” True or False?
• “If Tuesday is a day of the week, then I am a penguin.” True or False?
• “If 1+1=6, then I will get A.” True or False?
• “If the moon is made of green cheese, then I am richer than Bill Gates.” True or False?
![Page 25: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/25.jpg)
ขอความมเงอนไขสองทาง(Bicondition)
The biconditional p q states that p is true if
and only if (IFF) q is true.
p = “x+3=7”
q = “x=4”
p q = “x+3=7 กตอเมอ x=4”
![Page 26: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/26.jpg)
ตารางคาความจรงของ Biconditional p q means that p and q
have the same truth value.
Remark. This truth table is the exact opposite of ’s!
Thus, p q means ¬(p q)
p q does not imply that p and q are true, or that either of them causes the other, or that they have a common cause.
p q p q
F F T
F T F
T F F
T T T
![Page 27: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/27.jpg)
สรปตวด าเนนการแบบบล We have seen
1 unary operator and
5 binary operators.
Their truth tables are below.
p q p pq pq pq pq pq
F F T F F F T T
F T T F T T T F
T F F F T T F F
T T F T T F T T
![Page 28: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/28.jpg)
ตรรกสมมล(Logical Equivalence)
• Compound proposition p is logically
equivalent to compound proposition q,
written pq, IFF the compound
proposition pq is a tautology.
• Compound propositions p and q are
logically equivalent to each other IFF p and
q contain the same truth values as each
other in all rows of their truth tables.
![Page 29: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/29.jpg)
การพสจนความสมมลกนโดยใชตารางคาความจรง
p q ppqq pp qq pp qq ((pp qq))
F F
F T
T F
T T
F T
T T
T
T
T
T T
T
F F
F
F
F F
F F
T T
Ex. Prove that pq (p q).
![Page 30: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/30.jpg)
สจนรนดร(Tautology) ความขดแยง(Contradiction)
A tautology is a compound proposition that is true no matter what the truth values of its atomic propositions are!
Ex. p p [What is its truth table?]
A contradiction is a compound proposition that is false no matter what! Ex. p p [Truth table?]
Other compound props. are contingencies.
![Page 31: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/31.jpg)
กฎของความสมมล
These are similar to the arithmetic
identities you may have learned in
algebra, but for propositional
equivalences instead.
They provide a pattern or template that
can be used to match all or part of a
much more complicated proposition
and to find an equivalence for it.
![Page 32: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/32.jpg)
ตวอยางของกฎความสมมล
• Identity: pT p pF p
• Domination: pT T pF F
• Idempotent: pp p pp p
• Double negation: p p
• Commutative: pq qp pq qp
• Associative: (pq)r p(qr) (pq)r p(qr)
![Page 33: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/33.jpg)
กฎอนๆ ของความสมมล
• Distributive: p(qr) (pq)(pr)
p(qr) (pq)(pr)
• De Morgan’s:
(pq) p q
(pq) p q
• Trivial tautology/contradiction: p p T p p F
Augustus
De Morgan
(1806-1871)
![Page 34: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/34.jpg)
การนยามตวด าเนนการตางๆ ดวยความสมมล
Using equivalences, we can define operators
in terms of other operators.
Exclusive or: pq (pq)(pq)
pq (pq)(qp)
Implies: pq p q
Biconditional: pq (pq) (qp) pq (pq)
![Page 35: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/35.jpg)
ตวอยางของความสมมล Check using a symbolic derivation whether
(p q) (p r) p q r.
(p q) (p r)
(p q) (p r) [Expand definition of ]
(p q) ((p r) (p r)) [Expand defn. of ]
(p q) ((p r) (p r)) [DeMorgan’s Law]
(p q) ((p r) (p r))
(q p) ((p r) (p r)) [ commutes]
cont.
![Page 36: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/36.jpg)
q (p ((p r) (p r))) [ associative]
q (((p (p r)) (p (p r))) [distrib. over ]
q (((p p) r) (p (p r))) [assoc.]
q ((T r) (p (p r))) [trivail taut.]
q (T (p (p r))) [domination]
q (p (p r)) [identity]
q (p (p r))
q (p (p r)) [DeMorgan’s]
q ((p p) r) [Assoc.]
q (p r) [Idempotent]
(q p) r [Assoc.]
p q r [Commut.] Q.E.D.
Remark. Q.E.D. (quod erat demonstrandum)
![Page 37: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/37.jpg)
ทบทวนตรรกประพจน
Atomic propositions: p, q, r, …
Boolean operators:
Compound propositions: s : (p q) r
Equivalences: pq (p q)
Proving equivalences using:
Truth tables.
Symbolic derivations. p q r …
![Page 38: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/38.jpg)
Predicate Logic
• Predicate logic is an extension of
propositional logic that permits concisely
reasoning about whole classes of entities.
• Propositional logic (recall) treats simple
propositions (sentences) as atomic entities.
• In contrast, predicate logic distinguishes the
subject of a sentence from its predicate.
– Remember these English grammar terms?
![Page 39: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/39.jpg)
Applications of Predicate Logic
• It is the formal notation for writing perfectly
clear, concise, and unambiguous
mathematical definitions, axioms, and
theorems (more on these in module 2) for
any branch of mathematics.
• Predicate logic with function symbols, the “=” operator,
and a few proof-building rules is sufficient for defining
any conceivable mathematical system, and for proving anything that can be proved within that system!
![Page 40: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/40.jpg)
Other Applications
• Predicate logic is the foundation of the field of mathematical logic, which culminated in Gödel’s incompleteness theorem, which revealed the ultimate limits of mathematical thought: – Given any finitely describable, consistent
proof procedure, there will always remain some true statements that will never be proven by that procedure.
• i.e., we can’t discover all mathematical truths, unless we sometimes resort to making guesses.
Kurt Gödel
1906-1978
![Page 41: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/41.jpg)
Practical Applications
of Predicate Logic
• It is the basis for clearly expressed formal specifications for any complex system.
• It is basis for automatic theorem proverbs and many other Artificial Intelligence systems.
– E.g. automatic program verification systems.
• Predicate-logic like statements are supported by some of the more sophisticated database query engines and container class libraries
– these are types of programming tools.
![Page 42: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/42.jpg)
Subjects and Predicates
• In the sentence “The dog is sleeping”:
– The phrase “the dog” denotes the subject - the object or entity that the sentence is about.
– The phrase “is sleeping” denotes the predicate- a property that is true of the subject.
• In predicate logic, a predicate is modeled as a function P(·) from objects to propositions.
– P(x) = “x is sleeping” (where x is any object).
![Page 43: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/43.jpg)
More About Predicates
• Convention. Lowercase variables x, y, z... denote
objects/entities; uppercase variables P, Q, R…
denote propositional functions (predicates).
• Remark. Keep in mind that the result of applying a
predicate P to an object x is the proposition P(x).
But the predicate P itself (e.g. P=“is sleeping”) is
not a proposition (not a complete sentence).
– E.g. if P(x) = “x is a prime number”, P(3) is the proposition “3 is a prime number.”
![Page 44: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/44.jpg)
Propositional Functions
• Predicate logic generalizes the grammatical notion of a predicate to also include propositional functions of any number of arguments, each of which may take any grammatical role that a noun can take.
– E.g. let P(x,y,z) = “x gave y the grade z”, then: if x=“Mike”, y=“Mary”, z=“A”, then P(x,y,z) = “Mike gave Mary the grade A.”
![Page 45: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/45.jpg)
Universes of Discourse (U.D.s)
• The power of distinguishing objects from predicates is that it lets you state things about many objects at once.
E.g., let P(x)=“x+1>x”. We can then say, “For any number x, P(x) is true” instead of (0+1>0) (1+1>1) (2+1>2) ...
• The collection of values that a variable x can take is called x’s universe of discourse.
![Page 46: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/46.jpg)
Quantifier Expressions
• Quantifiers provide a notation that allows us to quantify (count) how many objects in the univ. of disc. satisfy a given predicate.
• “” is the FORLL or universal quantifier. x P(x) means for all x in the u.d., P holds.
• “” is the XISTS or existential quantifier. x P(x) means there exists an x in the u.d. (that is, 1 or more) such that P(x) is true.
![Page 47: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/47.jpg)
The Universal Quantifier
Example:
Let the u.d. of x be parking spaces at the
university.
Let P(x) be the predicate “x is full.”
Then the universal quantification of P(x),
x P(x), is the proposition:
– “All parking spaces at UF are full.”
– i.e., “Every parking space at UF is full.” – i.e., “For each parking space at UF, that space is full.”
![Page 48: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/48.jpg)
The Existential Quantifier
Example:
Let the u.d. of x be parking spaces at the
university.
Let P(x) be the predicate “x is full.”
Then the existential quantification of P(x),
x P(x), is the proposition:
– “Some parking space at UF is full.”
– “There is a parking space at UF that is full.”
– “At least one parking space at UF is full.”
![Page 49: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/49.jpg)
Free and Bound Variables
• An expression like P(x) is said to have a
free variable x (meaning, x is undefined).
• A quantifier (either or ) operates on an
expression having one or more free
variables, and binds one or more of those
variables, to produce an expression having one or more bound variables.
![Page 50: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/50.jpg)
Example of Binding
P(x,y) has 2 free variables, x and y.
x P(x,y) has 1 free variable, and one bound variable. [Which is which?]
“P(x), where x=3” is another way to bind x.
An expression with zero free variables is a bona-fide (actual) proposition.
An expression with one or more free variables is still only a predicate: e.g. let Q(y) = x P(x,y)
![Page 51: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/51.jpg)
Nesting of Quantifiers
Example: Let the u.d. of x & y be people.
Let L(x,y)=“x likes y” (a predicate w. 2 f.v.’s)
Then y L(x,y) = “There is someone whom x
likes.” (A predicate w. 1 free variable, x)
Then x (y L(x,y)) =
“Everyone has someone whom they like.” (A __________ with ___ free variables.)
![Page 52: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/52.jpg)
Review: Predicate Logic
• Objects x, y, z, …
• Predicates P, Q, R, … are functions
mapping objects x to propositions P(x).
• Multi-argument predicates P(x, y).
• Quantifiers: [x P(x)] :≡ “For all x’s, P(x).”
[x P(x)] :≡ “There is an x such that P(x).”
• Universes of discourse, bound & free vars.
![Page 53: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/53.jpg)
Quantifier Exercise
ก าหนดให R(x,y)=“x รก y,” ใหเขยนประพจนเปดตอไปนเปนประโยค:
• x(y R(x,y))=
• y(x R(x,y))=
• x(y R(x,y))=
• y(x R(x,y))=
• x(y R(x,y))=
ทกๆคนรกบางคน
มบางคนทถกทกๆคนรก
มบางคนรกทกๆคน
ทกคนถกรกโดยบางคน
แตละคน(ทกๆคน)รกทกคน
![Page 54: Discrete Structure - Prince of Songkla Universitystaff.cs.psu.ac.th/sathit/344-281/01-Logic.pdf · 2018-10-18 · Goals of a Discrete Mathematics • Mathematical Reasoning: to read,](https://reader034.vdocuments.site/reader034/viewer/2022050303/5f6c36c91e75bf4f6e799b36/html5/thumbnails/54.jpg)
Quantifier Exercise(Cont.)