1 discrete mathematics lecture 2. dr.bassant mohamed el-bagoury [email protected] module logic...
TRANSCRIPT
1
Discrete Mathematics Lecture 2.
Dr.Bassant Mohamed [email protected]
Module Logic (part 2 --- proof methods)
OutlineOutline
1. Mathematical Reasoning
2. Arguments Examples – Predicate Logic
3. Rules of Inference – Knowledge Engineering
4. Rules of Inference for Quantifiers
4. Methods for Theorem Proving
2
3
Mathematical ReasoningMathematical Reasoning
4
Mathematical ReasoningMathematical Reasoning
We need We need mathematical reasoningmathematical reasoning to to
• determine whether a mathematical argument is determine whether a mathematical argument is correct or incorrect and correct or incorrect and• construct mathematical arguments.construct mathematical arguments.
Mathematical reasoning is not only important for Mathematical reasoning is not only important for conducting conducting proofsproofs and and program verificationprogram verification, but , but also for also for artificial intelligenceartificial intelligence systems (drawing systems (drawing inferences).inferences).
5
ArgumentsArguments
Example:Example:
Gary is either intelligent or a good actor.Gary is either intelligent or a good actor.If Gary is intelligent, then he can count If Gary is intelligent, then he can count from 1 to 10.from 1 to 10.Gary can only count from 1 to 2.Gary can only count from 1 to 2.Therefore, Gary is a good actor.Therefore, Gary is a good actor.
i: “Gary is intelligent.”i: “Gary is intelligent.”a: “Gary is a good actor.”a: “Gary is a good actor.”c: “Gary can count from 1 to 10.”c: “Gary can count from 1 to 10.”
6
ArgumentsArguments
i: “Gary is intelligent.”i: “Gary is intelligent.”a: “Gary is a good actor.”a: “Gary is a good actor.”c: “Gary can count from 1 to 10.”c: “Gary can count from 1 to 10.”
Step 1:Step 1: cc HypothesisHypothesisStep 2:Step 2: i i c c HypothesisHypothesisStep 3:Step 3: i i Modus Tollens Steps 1 & 2Modus Tollens Steps 1 & 2Step 4:Step 4: a a i i HypothesisHypothesisStep 5:Step 5: a a Disjunctive SyllogismDisjunctive Syllogism
Steps 3 & 4Steps 3 & 4
Conclusion: Conclusion: aa (“Gary is a good actor.”) (“Gary is a good actor.”)
7
ArgumentsArguments
Another example:Another example:
““If it rains today, then we will not have a barbeque If it rains today, then we will not have a barbeque today. If we do not have a barbeque today, then we today. If we do not have a barbeque today, then we will have a barbeque tomorrow.will have a barbeque tomorrow.Therefore, if it rains today, then we will have a Therefore, if it rains today, then we will have a barbeque tomorrow.”barbeque tomorrow.”
This is a This is a validvalid argument: If its hypotheses are true, argument: If its hypotheses are true, then its conclusion is also true.then its conclusion is also true.
AI research × Software AI research × Software EngineeringEngineering
Knowledge Level
Symbol LevelSystem Level
Intelligent Behaviour
Requirements Specification
Functional Specification
System Implementation
A small Expert System ( Inference System ) of rules for analysis of automotive problems.
Rule 1: if the engine is getting gas, andthe engine will turn over,thenthe problem is spark plugs.
Rule 2: ifthe engine does not turn over, andthe lights do not come onthenthe problem is battery or cables.
Rule 3: ifthe engine does not turn over, andthe lights do come onthen the problem is the starter motor.
Rule 4: ifthere is gas in the fuel tank, andthere is gas in the carburetorthenthe engine is getting gas.
Fig The Inference System at the start of a consultation in the car diagnostic example.
Fig The Inference System after Rule 1 has fired.
The and/or graph searched in the car diagnosis example, with the conclusion of Inference Rule 4 matching the first premise of Inference Rule 1.
The following dialogue begins with the computer asking the user about the goals present in working memory.
Gas in fuel tank?YesGas in carburetor?YesEngine will turn over?Why It has been established that:1. The engine is getting gas, 2. The engine will turn over,Then the problem is the spark plugs. How the engine is getting gas This follows from rule 4:ifgas in fuel tank, andgas in carburetorthenengine is getting gas.gas in fuel tank was given by the usergas in carburetor was given by the user
14
TerminologyTerminology
An An axiomaxiom is a basic assumption about mathematical is a basic assumption about mathematical structures that needs no proof.structures that needs no proof.
We can use a We can use a proofproof to demonstrate that a particular to demonstrate that a particular statement is true. A proof consists of a sequence of statement is true. A proof consists of a sequence of statements that form an argument.statements that form an argument.
The steps that connect the statements in such a The steps that connect the statements in such a sequence are the sequence are the rules of inferencerules of inference..
Cases of incorrect reasoning are called Cases of incorrect reasoning are called fallaciesfallacies..
A A theoremtheorem is a statement that can be shown to be is a statement that can be shown to be true. true.
15
TerminologyTerminology
A A lemmalemma is a simple theorem used as an is a simple theorem used as an intermediate result in the proof of another theorem.intermediate result in the proof of another theorem.
A A corollarycorollary is a proposition that follows directly from is a proposition that follows directly from a theorem that has been proved.a theorem that has been proved.
A A conjectureconjecture is a statement whose truth value is is a statement whose truth value is unknown. Once it is proven, it becomes a theorem.unknown. Once it is proven, it becomes a theorem.
16
ArgumentsArguments
Just like a Just like a rule of inferencerule of inference, an , an argument argument consists consists of one or more hypotheses and a conclusion. of one or more hypotheses and a conclusion.
We say that an argument isWe say that an argument is valid valid, if whenever all its , if whenever all its hypotheses are true, its conclusion is also true.hypotheses are true, its conclusion is also true.
However, if any hypothesis is false, even a valid However, if any hypothesis is false, even a valid argument can lead to an incorrect conclusion. argument can lead to an incorrect conclusion.
17
ArgumentsArguments
Example:Example:
““If 101 is divisible by 3, then 101If 101 is divisible by 3, then 10122 is divisible by 9. is divisible by 9. 101 is divisible by 3. Consequently, 101101 is divisible by 3. Consequently, 10122 is divisible is divisible by 9.”by 9.”
Although the argument is Although the argument is validvalid, its conclusion is , its conclusion is incorrectincorrect, because one of the hypotheses is false , because one of the hypotheses is false (“101 is divisible by 3.”).(“101 is divisible by 3.”).
If in the above argument we replace 101 with 102, If in the above argument we replace 101 with 102, we could correctly conclude that 102we could correctly conclude that 10222 is divisible by is divisible by 9.9.
18
Theorems, proofs, and rules of inference
When is a mathematical argument (or “proof”) correct?What techniques can we use to construct a mathematical
argument?
Theorem – statement that can be shown to be true.Axioms or postulates or premises – statements which are given
and assumed to be true.
Proof – sequence of statements, a valid Argument, to show that a theorem is true.
Rules of Inference – rules used in a proof to draw conclusions from assertions known to be true.
19
Valid Arguments
Recall:
An argument is a sequence of propositions. The final proposition is called the conclusion of the argument while the other propositions are called the premises or hypotheses of the argument.
An Argument is valid whenever the truth of all its premises implies the truth of its conclusion.
How to show that q logically follows from the hypotheses (p1 p2 …pn)?
Show that
(p1 p2 …pn) q is a tautology
One can use the rules of inference to show the validity of an argument.
Vacuous proof - if one of the premises is false then (p1 p2 …pn) q is vacuously True, since False implies anything.
(reminder)
20
Methods for Proving Theorems
21
Methods of Proof
1) Direct Proof
2) Proof by Contraposition
3) Proof by Contradiction
4) Proof of Equivalences
5) Proof by Cases
6) Existence Proofs
7) Counterexamples
22
1) Direct Proof
Proof statement : p q
by:
Assume p
From p derive q.
23
Direct proof --- Example 1
Here’s what you know:
Mary is a Math major or a CS major.If Mary does not like discrete math, she is not a CS major.If Mary likes discrete math, she is smart.Mary is not a math major.
Can you conclude Mary is smart?
M CD CD SM
((M C) (D C) (D S) (M)) S?
Let M - Mary is a Math majorC – Mary is a CS majorD – Mary likes discrete math S – Mary is smart
Informally, what’s the inference chain of reasoning?
24
In general, to prove p q, assume p and show that q follows.
((M C) (D C) (D S) (M)) S?
Reminder: Propositional logic Rules of Inference or Method of Proof
Rule of Inference Tautology (Deduction Theorem) Name
P
P QP (P Q) Addition
P Q P
(P Q) P Simplification
P
Q
P Q
[(P) (Q)] (P Q) Conjunction
P
PQ
Q
[(P) (P Q)] P Modus Ponens
Q
P Q
P
[(Q) (P Q)] P Modus Tollens
P Q
Q R
P R
[(PQ) (Q R)] (PR) Hypothetical Syllogism
(“chaining”)
P Q P
Q
[(P Q) (P)] Q Disjunctive syllogism
P Q P R Q R
[(P Q) (P R)] (Q R) Resolution
See Table 1, p. 66, Rosen.
Subsumes MP
26
1. M C Given (premise)2. D C Given3. D S Given4. M Given
DS (disjunctive syllogism; 1,4)
MT (modus tollens; 2,5)
5. C
6. D
7. S MP (modus ponens; 3,6)
Mary is smart!
Example 1 - direct proof
QED
QED or Q.E.D. --- quod erat demonstrandum
27
Direct Proof --- Example 2
Theorem:
If n is odd integer, then n2 is odd.
Looks plausible, but…
How do we proceed? How do we prove this?
Start with
Definition: An integer is even if there exists an integer k such that n = 2k,
and n is odd if there exists an integer k such that n = 2k+1.
Properties: An integer is even or odd; and no integer is
both even and odd. (aside: would require proof.)
28
Theorem:
(n) P(n) Q(n),
where P(n) is “n is an odd integer” and Q(n) is “n2 is odd.”
We will show P(n) Q(n)
Example 2: Direct Proof
Theorem:If n is odd integer, then n2 is odd.
Proof:Let P --- “n is odd integer” Q --- “n2 is odd” we want to show that P Q
• Assume P, i.e., n is odd.
• By definition n = 2k + 1, where k is some integer.
• Therefore n2 = (2k + 1)2 = 4k2 + 4k + 1 = 2 (2k2 + 2k ) + 1, which is by definition is an odd number (use k’ = (2k2 + 2k ) ).
QED
Proof strategy hint: Go back to definitions of conceptsand start by trying direct proof.
MORE EXPLAINATION
30
The Foundations: Logic and Proofs
Chapter 1
31
Propositional Logic
32
Proposition is a declarative statement that is either true of false
•Baton Rouge is the capital of Louisiana True•Toronto is the capital of Canada False•1+1=2 True•2+2=3 False
Statements which are not propositions:
•What time is it?•x+1 = 2
33
Thursday istoday p
Thursdaynot istoday pNegation:
T F
F T
p ptruth table
34
Thursday istoday p
todayraining isit q
Conjunction: todayraining isit andThursday istoday qp
T T T
T F F
F T F
F F F
ptruth table
q qp
35
Thursday istoday p
Friday istoday q
Disjunction:Friday isor today Thursday istoday qp
T T T
T F T
F T T
F F F
ptruth table
q qp
36
Thursday istoday p
Friday istoday q
Exclusive-or:both)not (but Friday isor today Thursday istoday qp
T T F
T F T
F T T
F F F
ptruth table
q qp
one or the other but not both
37
math discrete learns Mariap
job good a find willMariaq
Conditional statement:job good a find willshemath then discrete learns Maria if qp
T T T
T F F
F T T
F F T
ptruth table
q qp
(hypothesis)
(conclusion)
if p then qp implies qq follows from pp only if qp is sufficient for q
38
qp
Converse: pq
Contrapositive:
Inverse:
pq
qp
Conditional statement:
equivalent(same truth table)
equivalent
39
flight thecan takeyou p
ticketabuy you q
Biconditional statement: ticketabuy you ifonly and ifflight thecan takeyou qp
T T T
T F F
F T F
F F T
ptruth table
q qp p if and only if qp iff qIf p then q and converselyp is necessary and sufficient for q
40
Compound propositions
T T F T T T
T F T T F F
F T F F F T
F F T T F F
p q q qp qp qpqp
Precedence of operators
higher lower
41
Translating English into propositions
old" years 16 older than areyou unless
feet tall 4under areyou ifcoaster roller theridecannot you "p
coasterroller theridecan you q
feet tall 4under areyou r
old years 16 older than areyou s
qsrp
Propositional Equivalences
42
always trueTautology:Contradiction:always false
Contingency:not a tautology andnot a contradiction
Compound proposition
T F T F
F T T F
p p pp pp tautology contradiction
Rules of Inference
43
If you have a current password, then you can log onto the network
You have a current password
Therefore,you can log onto the network
qp p
q
q
p
qp
Modus Ponens
Valid argument:if premises are true then conclusion is true
44
q
p
qp
Modus Ponens
qpqp ))((
If and then qp p q
45
Rules of Inference
q
p
qp
Modus Ponens
p
q
qp
Modus Tollens
rp
rq
qp
HypotheticalSyllogism
DisjunctiveSyllogism
q
p
qp
46
Rules of Inference
qp
p
Addition
p
qp
Simplification
qp
q
p
Conjunction Resolution
rq
rp
qp
47
It is below freezing now
Therefore,it is either below freezing or raining now
qp
p
Addition
p
qp pq
48
It is below freezing and raining now
Therefore,it is below freezing now p
qp
p
qp
Simplification
pq
49
If it rains today then we will not have a barbecue today
Therefore,if it rains today then we will have a barbecue tomorrow
p qp
rp
rq
qp
HypotheticalSyllogism
If we do not have a barbecue today then we will have a barbecue tomorrow
q
qr
rq
rp pr
50
it is not snowingor Jasmine is skiing
It is snowing or Bart is playing hockey
p
p
q
r
qp
rp
Therefore,Jasmine is skiingor Bart is playing hockey
rq
Resolution
rq
rp
qp
51
Hypothesis:It is not sunny this afternoonand it is colder than yesterday
We will go swimming only if it is sunny
If we do not go swimming, then we will take a canoe trip
If we take a canoe trip, then we will be home by sunset
We will be home by sunsetConclusion:
pq
rp
rs
st
qp
pr
sr
ts
t
52
t
ts
s
sr
r
pr
p
qp
.8
.7
.6
.5
.4
.3
.2
.1
Hypothesis
Simplification from 1
Hypothesis
Hypothesis
Modus tollens from 2,3
Hypothesis
Modus ponens from 4,5
Modus ponens from 6,7
53
Chapter 1:Foundations: Logic and Proofs
54
Foundations of Logic(§1.1-1.3)
Mathematical Logic is a tool for working with complicated compound statements. It includes:
• A language for expressing them.• A concise notation for writing them.• A methodology for objectively reasoning about
their truth or falsity.• It is the foundation for expressing formal proofs in
all branches of mathematics.
55
Universes of Discourse (U.D.s)
• The power of distinguishing objects from The power of distinguishing objects from predicates is that it lets you state things predicates is that it lets you state things about about manymany objects at once. objects at once.
• E.g., let E.g., let PP((xx)=“)=“xx+1>+1>xx”. We can then say,”. We can then say,“For “For anyany number number xx, , PP((xx) is true” instead of) is true” instead of((00+1>+1>00) ) ( (11+1>+1>11)) ( (22+1>+1>22)) ... ...
• The collection of values that a variable The collection of values that a variable xx can take is called can take is called xx’s ’s universe of discourseuniverse of discourse..
56
Quantifier Expressions
• QuantifiersQuantifiers provide a notation that allows provide a notation that allows us to us to quantify quantify (count) (count) how manyhow many objects objects in in the univ. of disc. satisfy a given predicate.the univ. of disc. satisfy a given predicate.
• ““” ” is the is the FORFORLLLL or or universaluniversal quantifier quantifier..xx PP((xx) means ) means for allfor all xx in the u.d., in the u.d., PP holds. holds.
• ““” ” is the is the XISTSXISTS or or existentialexistential quantifier quantifier..x Px P((xx) means ) means there there existsexists an an xx in the u.d. in the u.d. (that is, 1 or more) (that is, 1 or more) such thatsuch that PP((xx) is true.) is true.
57
The Universal Quantifier
• Example: Example: Let the u.d. of Let the u.d. of xx be be parking spaces at UFparking spaces at UF..Let Let PP((xx) be the ) be the predicatepredicate “ “xx is full.” is full.”Then the Then the universal quantification of Puniversal quantification of P((xx), ), xx PP((xx), is the ), is the proposition:proposition:– ““All parking spaces at UF are full.”All parking spaces at UF are full.”– i.e.i.e., “Every parking space at UF is full.”, “Every parking space at UF is full.”– i.e.i.e., “For each parking space at UF, that space is full.”, “For each parking space at UF, that space is full.”
58
The Existential Quantifier
• Example: Example: Let the u.d. of Let the u.d. of xx be be parking spaces at UFparking spaces at UF..Let Let PP((xx) be the ) be the predicatepredicate “ “xx is full.” is full.”Then the Then the existential quantification of Pexistential quantification of P((xx), ), xx PP((xx), is the ), is the propositionproposition::– ““Some parking space at UF is full.”Some parking space at UF is full.”– ““There is a parking space at UF that is full.”There is a parking space at UF that is full.”– ““At least one parking space at UF is full.”At least one parking space at UF is full.”
59
Review: Predicate Logic (§1.3)
• Objects Objects xx, , yy, , zz, … , … • Predicates Predicates PP, , QQ, , RR, … are functions , … are functions
mapping objects mapping objects xx to propositions to propositions PP((xx).).• Multi-argument predicates Multi-argument predicates PP((xx, , yy).).• Quantifiers: [Quantifiers: [xx PP((xx)] :≡ “For all )] :≡ “For all xx’s, ’s, PP((xx).” ).”
[[x Px P((xx)] :≡ “There is an )] :≡ “There is an xx such that such that PP((xx).”).”• Universes of discourse, bound & free vars.Universes of discourse, bound & free vars.
60
Foundations of Logic: Overview
• Propositional logicPropositional logic (§1.1-1.2): (§1.1-1.2):– Basic definitions. (§1.1)Basic definitions. (§1.1)– Equivalence rules & derivations. (§1.2)Equivalence rules & derivations. (§1.2)
• Predicate logicPredicate logic (§1.3-1.4) (§1.3-1.4)– Predicates.Predicates.– Quantified predicate expressions.Quantified predicate expressions.– Equivalences & derivations.Equivalences & derivations.
61
Propositional Logic (§1.1)
Propositional LogicPropositional Logic is the logic of compound is the logic of compound statements built from simpler statements statements built from simpler statements using so-called using so-called BooleanBoolean connectivesconnectives..
Some applications in computer science:Some applications in computer science:• Design of digital electronic circuits.Design of digital electronic circuits.• Expressing conditions in programs.Expressing conditions in programs.• Queries to databases & search engines.Queries to databases & search engines.
George Boole(1815-1864)
Chrysippus of Soli(ca. 281 B.C. – 205 B.C.)
62
Definition of a Proposition
A A propositionproposition ( (pp, , qq, , rr, …) is simply a , …) is simply a statementstatement ((i.e.i.e., , a declarative sentence)a declarative sentence) with a definite meaningwith a definite meaning, , having a having a truth valuetruth value that’s either that’s either truetrue (T) or (T) or falsefalse (F) ((F) (nevernever both, neither, or somewhere in both, neither, or somewhere in between).between).
(However, you might not (However, you might not knowknow the actual truth value, the actual truth value, and it might be situation-dependent.)and it might be situation-dependent.)
[Later we will study [Later we will study probability theory,probability theory, in which we assign in which we assign degrees of certaintydegrees of certainty to propositions. But for now: think to propositions. But for now: think True/False only!]True/False only!]
63
Examples of Propositions
• ““It is raining.” (In a given situation.)It is raining.” (In a given situation.)• ““Beijing is the capital of China.” • “1 + 2 = 3”Beijing is the capital of China.” • “1 + 2 = 3”
But, the following are But, the following are NOTNOT propositions: propositions:• ““Who’s there?” (interrogative, question)Who’s there?” (interrogative, question)• ““La la la la la.” (meaningless interjection)La la la la la.” (meaningless interjection)• ““Just do it!” (imperative, command)Just do it!” (imperative, command)• ““Yeah, I sorta dunno, whatever...” (vague)Yeah, I sorta dunno, whatever...” (vague)• ““1 + 2” (expression with a non-true/false value)1 + 2” (expression with a non-true/false value)
64
An An operatoroperator or or connectiveconnective combines one or combines one or more more operandoperand expressions into a larger expressions into a larger expression. (expression. (E.g.E.g., “+” in numeric exprs.), “+” in numeric exprs.)
UnaryUnary operators take 1 operand ( operators take 1 operand (e.g.,e.g., −3); −3); BinaryBinary operators take 2 operands (operators take 2 operands (egeg 3 3 4). 4).
PropositionalPropositional or or BooleanBoolean operators operate on operators operate on propositions or truth values instead of on propositions or truth values instead of on numbers.numbers.
Operators / Connectives
65
Some Popular Boolean Operators
Formal NameFormal Name NicknameNickname ArityArity SymbolSymbol
Negation operatorNegation operator NOTNOT UnaryUnary ¬¬
Conjunction operatorConjunction operator ANDAND BinaryBinary Disjunction operatorDisjunction operator OROR BinaryBinary Exclusive-OR operatorExclusive-OR operator XORXOR BinaryBinary Implication operatorImplication operator IMPLIESIMPLIES BinaryBinary Biconditional operatorBiconditional operator IFFIFF BinaryBinary ↔↔
66
The Negation Operator
The unary The unary negation operatornegation operator “¬” ( “¬” (NOTNOT) ) transforms a prop. into its logicaltransforms a prop. into its logical negation negation..
E.g.E.g. If If pp = “I have brown hair.” = “I have brown hair.”
then ¬then ¬pp = “I do = “I do notnot have brown hair.” have brown hair.”
Truth tableTruth table for for NOTNOT:: p p T F
T :≡ True; F :≡ False“:≡” means “is defined as”
Operandcolumn
Resultcolumn
67
The Conjunction Operator
The binary The binary conjunction operatorconjunction operator “ “” (” (ANDAND) ) combines two propositions to form their combines two propositions to form their logical logical conjunctionconjunction..
E.g.E.g. If If pp=“I will have salad for lunch.” and =“I will have salad for lunch.” and q=q=“I will have steak for dinner.”, then “I will have steak for dinner.”, then ppqq=“I will have salad for lunch =“I will have salad for lunch andand I will have steak for dinner.”I will have steak for dinner.”
Remember: “” points up like an “A”, and it means “” points up like an “A”, and it means “NDND””
NDND
68
• Note that aNote that aconjunctionconjunctionpp11 pp2 2 … … ppnn
of of nn propositions propositionswill have will have 22nn rows rowsin its truth table.in its truth table.
• Also: ¬Also: ¬ and and operations together are suffi- operations together are suffi-cient to express cient to express anyany Boolean truth table! Boolean truth table!
Conjunction Truth Table
p q p q F F F T T F T T
Operand columns
69
The Disjunction Operator
• The binary The binary disjunction operatordisjunction operator “ “” (” (OROR) ) combines two propositions to form their combines two propositions to form their logical logical disjunctiondisjunction..
• pp=“My car has a bad engine.”=“My car has a bad engine.”
• q=q=“My car has a bad carburetor.”“My car has a bad carburetor.”
• ppqq=“Either my car has a bad engine, =“Either my car has a bad engine, oror my car has a bad carburetor.”my car has a bad carburetor.” After the downward-
pointing “axe” of “””splits the wood, yousplits the wood, youcan take 1 piece OR the can take 1 piece OR the other, or both.other, or both.
Meaning is like “and/or” in English.
70
• Note that Note that ppq q meansmeansthat that pp is true, or is true, or qq is istrue, true, or bothor both are true! are true!
• So, this operation isSo, this operation isalso called also called inclusive or,inclusive or,because it because it includesincludes the thepossibility that both possibility that both pp and and qq are true. are true.
• ““¬” and “¬” and “” together are also universal.” together are also universal.
Disjunction Truth Table
p q p q F F F T T F T T
71
Nested Propositional Expressions
• Use parentheses to Use parentheses to group sub-expressionsgroup sub-expressions::““I just saw my old I just saw my old ffriendriend, , andand eithereither he’s he’s ggrownrown oror I’ve I’ve sshrunkhrunk.” = .” = ff ( (gg ss))– ((ff gg) ) ss would mean something different would mean something different– ff gg ss would be ambiguous would be ambiguous
• By convention, “¬” takes By convention, “¬” takes precedenceprecedence over over both “both “” and “” and “”.”.– ¬¬s s ff means (¬ means (¬ss)) f f , , not not ¬ (¬ (s s ff))
72
A Simple Exercise
Let Let pp=“It rained last night”, =“It rained last night”, qq=“The sprinklers came on last night,” =“The sprinklers came on last night,” rr=“The lawn was wet this morning.”=“The lawn was wet this morning.”
Translate each of the following into English:Translate each of the following into English:
¬¬pp = =
rr ¬ ¬pp = =
¬ ¬ r r pp q =q =
“It didn’t rain last night.”“The lawn was wet this morning, andit 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.”
73
The Exclusive Or Operator
The binary The binary exclusive-or operatorexclusive-or operator “ “” (” (XORXOR) ) combines two propositions to form their combines two propositions to form their logical “exclusive or” (exjunction?).logical “exclusive or” (exjunction?).
pp = “I will earn an A in this course,” = “I will earn an A in this course,”
qq = = “I will drop this course,”“I will drop this course,”
pp qq = “I will either earn an A for this = “I will either earn an A for this course, or I will drop it (course, or I will drop it (but not bothbut not both!)”!)”
74
• Note that Note that ppqq meansmeansthat that pp is is truetrue, or , or qq is istruetrue, but , but not bothnot both!!
• This operation isThis operation iscalled called exclusive orexclusive or,,because it because it excludesexcludes the thepossibility that both possibility that both pp and and qq are true. are true.
• ““¬” and “¬” and “” together are ” together are notnot universal. universal.
Exclusive-Or Truth Table
p q pq F F F T T F T T
75
Note that Note that EnglishEnglish “or” can be ambiguous “or” can be ambiguous regarding the “both” case!regarding the “both” case!
““Pat is a singer orPat is a singer orPat is a writer.” -Pat is a writer.” -
““Pat is a man orPat is a man orPat is a woman.” -Pat is a woman.” -
Need context to disambiguate the meaning!Need context to disambiguate the meaning!
For this class, assume “or” means For this class, assume “or” means inclusiveinclusive..
Natural Language is Ambiguous
p q p "or" q F F F T T F T T
76
The Implication Operator
The The implicationimplication p p qq states that states that pp implies implies qq..
I.e.I.e., If , If pp is true, then is true, then qq is true; is true; but if but if pp is not is not true, then true, then qq could be either true or false could be either true or false..
E.g.E.g., let , let p p = “You study hard.”= “You study hard.” q q = “You will get a good grade.”= “You will get a good grade.”
p p q = q = “If you study hard, then you will get “If you study hard, then you will get a good grade.” a good grade.” (else, it could go either way)(else, it could go either way)
antecedent consequent
77
Examples of Implications
• ““If this lecture ends, then the sun will rise If this lecture ends, then the sun will rise tomorrow.” tomorrow.” TrueTrue or or FalseFalse??
• ““If Tuesday is a day of the week, then I am If Tuesday is a day of the week, then I am a penguin.” a penguin.” TrueTrue or or FalseFalse??
• ““If 1+1=6, then Bush is president.” If 1+1=6, then Bush is president.” TrueTrue or or FalseFalse??
• ““If the moon is made of green cheese, then I If the moon is made of green cheese, then I am richer than Bill Gates.” am richer than Bill Gates.” True True oror False False??
78
English Phrases Meaning p q
• ““pp implies implies qq””• ““if if pp, then , then qq””• ““if if pp, , qq””• ““when when pp, , qq””• ““whenever whenever pp, , qq””• ““p p only if only if qq” “” “• p p is sufficient for is sufficient for qq””• ““q q if if pp””
• ““qq when when pp””• ““qq whenever whenever pp””• ““qq is necessary for is necessary for pp””• ““qq follows from follows from pp””• ““q q is implied by is implied by pp””We will see some equivalent We will see some equivalent
logic expressions later.logic expressions later.
79
The biconditional operator
The The biconditionalbiconditional p p qq states that states that pp is true is true if and if and only ifonly if (IFF)(IFF) qq is true is true..
p p = “Bush wins the 2004 election.”= “Bush wins the 2004 election.”
qq = = “Bush will be president for all of 2005.”“Bush will be president for all of 2005.”
p p q = q = “If, and only if, Bush wins the 2004 “If, and only if, Bush wins the 2004 election, Bush will be president for all of 2005.”election, Bush will be president for all of 2005.”
2004
I’m stillhere!
2005
80
Boolean Operations Summary
• We have seen 1 unary operator (out of the 4 We have seen 1 unary operator (out of the 4 possible) and 5 binary operators (out of the possible) and 5 binary operators (out of the 16 possible). Their truth tables are below.16 possible). Their truth tables are below.
p q p p q p q pq p q pqF F T F F F T TF T T F T T T FT F F F T T F FT T F T T F T T
81
Some Alternative Notations
Name: notandorxorimplies iffPropositional logic: Boolean algebra: ppq+C/C++/Java (wordwise):!&&||!= ==C/C++/Java (bitwise): ~&|^Logic gates:
82
End of §1.1
You have learned about:You have learned about:• Propositions: What Propositions: What
they are.they are.• Propositional logic Propositional logic
operators’operators’– Symbolic notations.Symbolic notations.
– English equivalents.English equivalents.
– Logical meaning.Logical meaning.
– Truth tables.Truth tables.
• Atomic vs. compound Atomic vs. compound propositions.propositions.
• Alternative notations.Alternative notations.• Bits and bit-strings.Bits and bit-strings.• Next section: §1.2Next section: §1.2
– Propositional Propositional equivalences.equivalences.
– How to prove them.How to prove them.
83
Propositional Equivalence (§1.2)
Two Two syntacticallysyntactically ( (i.e., i.e., textually) different textually) different compound propositions may be the compound propositions may be the semanticallysemantically identical (identical (i.e., i.e., have the same have the same meaning). We call them meaning). We call them equivalentequivalent. Learn:. Learn:
• Various Various equivalence rulesequivalence rules oror lawslaws..
• How to How to proveprove equivalences using equivalences using symbolic symbolic derivationsderivations..
84
Tautologies and Contradictions
A A tautologytautology is a compound proposition that is is a compound proposition that is truetrue no matter whatno matter what the truth values the truth values of its of its atomic propositions are!atomic propositions are!
Ex.Ex. p p pp [What is its truth table?] [What is its truth table?]A A contradictioncontradiction is a compound proposition is a compound proposition
that is that is falsefalse no matter what no matter what! ! Ex.Ex. p p p p [Truth table?][Truth table?]
Other compound props. are Other compound props. are contingenciescontingencies..
85
Predicate Logic (§1.3)
• Predicate logicPredicate logic is an extension of is an extension of propositional logic that permits concisely propositional logic that permits concisely reasoning about whole reasoning about whole classesclasses of entities. of entities.
• Propositional logic (recall) treats simple Propositional logic (recall) treats simple propositionspropositions (sentences) as atomic entities. (sentences) as atomic entities.
• In contrast, In contrast, predicate predicate logic distinguishes the logic distinguishes the subjectsubject of a sentence from its of a sentence from its predicatepredicate.. – Remember these English grammar terms?Remember these English grammar terms?
86
Applications of Predicate Logic
It is It is thethe formal notation for writing perfectly formal notation for writing perfectly clear, concise, and unambiguous clear, concise, and unambiguous mathematical mathematical definitionsdefinitions, , axiomsaxioms, and , and theorems theorems (more on these in chapter 3) for (more on these in chapter 3) for any any branch of mathematics. branch of mathematics.
Predicate logic with function symbols, the “=” operator, and a Predicate logic with function symbols, the “=” operator, and a few proof-building rules is sufficient for defining few proof-building rules is sufficient for defining anyany conceivable mathematical system, and for proving conceivable mathematical system, and for proving anything that can be proved within that system!anything that can be proved within that system!
87
Other Applications
• Predicate logic is the foundation of thePredicate logic is the foundation of thefield of field of mathematical logicmathematical logic, which , which culminated in culminated in Gödel’s incompleteness Gödel’s incompleteness theoremtheorem, which revealed the ultimate , which revealed the ultimate limits of mathematical thought:limits of mathematical thought: – Given any finitely describable, consistent Given any finitely describable, consistent
proof procedure, there will still be proof procedure, there will still be somesome true statements that can true statements that can never be provennever be provenby that procedure.by that procedure.
• I.e.I.e., we can’t discover , we can’t discover allall mathematical truths, mathematical truths, unless we sometimes resort to making unless we sometimes resort to making guesses.guesses.
Kurt Gödel1906-1978
88
Subjects and Predicates
• In the sentence “The dog is sleeping”:In the sentence “The dog is sleeping”:– The phrase “The phrase “the dogthe dog” denotes the ” denotes the subjectsubject - -
the the objectobject or or entity entity that the sentence is about.that the sentence is about.– The phrase “The phrase “is sleepingis sleeping” denotes the ” denotes the predicatepredicate- -
a property that is true a property that is true ofof the subject. the subject.
• In predicate logic, a In predicate logic, a predicatepredicate is modeled as is modeled as a a functionfunction PP(·)(·) from objects to propositions. from objects to propositions.– PP((xx) = “) = “xx is sleeping” (where is sleeping” (where xx is any object). is any object).
89
Review: Propositional Logic(§1.1-1.2)
• Atomic propositions: Atomic propositions: pp, , qq, , rr, … , …
• Boolean operators:Boolean operators:
• Compound propositions: s : (p qq) ) rr• Equivalences:Equivalences: ppq q ((p p q q))
• Proving equivalences using:Proving equivalences using:– Truth tablesTruth tables..– Symbolic derivations. Symbolic derivations. pp q q r … r …
Predicates and Quantifiers
90
zyxzyxR
yxyxQ
xxP
:),,(
3:),(
3:)(
properly gfunctionin isComputer :)(
intruderan by attack under is Computer :)(
xxB
xxA
variable predicate
Propositional functions
91
intruderan by attack under is Computer :)( xxA
}1,2,1{ Computers MATHCSCS
TMATHA
FCSA
TCSA
)1(
)2(
)1(
properly gfunctionin isComputer :)( xxB
FMATHB
TCSB
FCSB
)1(
)2(
)1(
Predicate logic
92
Universal quantifier: )(xPxfor all it holds x
xxxP 1:)(
)(xPx is true for every real number x
0:)( 2 xxQ
)(xQx is not true for every real number x
FQ )0(Counterexample:
(for every element in domain)
(for every element in domain)
)(xP
93
Existential quantifier: )(xPx
there is such that x
3:)( xxP
)(xPx is true because
011:)( xxxQ
)(xQx is not true
)(xP
TP )4(
94
For finite domain },,,{ 21 nxxx
)()()()( 21 nxPxPxPxPx
)()()()( 21 nxPxPxPxPx
95
Quantifiers with restricted domain
)2(0
)0(0
)0(0
2
3
2
zz
yy
xx
Precedence of operators
higher lower
96
Logical equivalences with quantifiers
)()())()(( xxQxxPxQxPx
)()())()(( xxQxxPxQxPx
?)()())()((
?)()())()((
xxQxxPxQxPx
xxQxxPxQxPx
False
False
97
)()( xPxxxP
)()( xPxxxP
De Morgan’s Laws for Quantifiers
98
))()((
))()(())()((
xQxPx
xQxPxxQxPx
qpqp )(Recall that:
Example
99
Translating English into Logical Expressions
“All hummingbirds are richly colored”“No large birds live on honey”“Birds that do not live on honey are dull in color”“Hummingbirds are small”
coloredrichly is )(
honeyon lives )(
bird large is )(
dhummingbir a is )(
xxS
xxR
xxQ
xxP
))()(( xSxPx
))()(( xRxQx
))()(( xSxRx
))()(( xQxPx
100
Universal Modus Ponens
)(
domainin particular somefor ),(
))()((
aQ
aaP
xQxPx
For all positive integers ,if then
x4x
xx 22
Therefore, 1002 2100
)(xP
)(xQ
4100 )100(P
)100(Q
))()(( xQxPx