50
Chapter 3: Basic Propositional Logic Based on Harry Gensler’s book For CS2209A/B By Dr. Charles Ling; [email protected]

Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

  • Upload
    others

  • View
    14

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

Chapter 3: Basic Propositional Logic

Based on Harry Gensler’s bookFor CS2209A/B

By Dr. Charles Ling; [email protected]

Page 2: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

The Ultimate GoalsAccepting premises (as true), is the conclusion (always)

true? Is the reasoning process valid?

Premises: If you smoke, you can get lung cancer. You do not smoke. Conclusion: you cannot get lung cancer.

Premises: If it rains and your tent leaks, your sleeping bag will get wet. Your sleeping bag did not get wet.Your tent leaks. Conclusion: it did not rain.

Formalize and automate the deduction processFirst: how to express premises and conclusions?

Page 3: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.1 Translation from English to Logic• Need a (formal) language to…

– deal with simple statements that may be true and false: use capital letters (P, Q, …)

• They are called propositions – deal with “if-then”, “and”, “or”, “not”, etc. in NL

Page 4: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

Well-Formed Formula (wff)1. Any capital letter is a wff. 2. The result of prefixing any wff with “~” is a wff. 3. The result of joining any two wffs by “·” or “∨” or “⊃”

or “≡” and enclosing the result in ( ) is a wff. Examples and usual meaning of connectives in NL

Page 5: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

Parentheses are important…

Page 6: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

Examples of Invalid wff

• p, p·q, p and q• (~P), (Q), ((R)) • P·Q, P·Q·R, (P·Q·R)• If p then q

Logic (including wff) is very precise

Page 7: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

Some useful rules in translation

• Rule: put “(” wherever you see “both,”“either,” or “if.”

Page 8: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

• Rule: Group together parts on either side of a comma.

Page 9: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

• Rule: have your capital letters stand for whole statements

Page 10: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

Exercise (also LogiCola C (EM & ET))• 1. Not both A and B. • 2. Both A and either B or C. • 3. Either both A and B or C. • 4. If A, then B or C. • 5. If A then B, or C. • 6. If not A, then not either B or C. • 7. If not A, then either not B or C. • 8. Either A or B, and C. • 9. Either A, or B and C. • 10. If A then not both not B and not C. • 11. If you get an error message, then the disk is bad or

it’s a Macintosh disk. • 12. If I bring my digital camera, then if my batteries don’t

die then I’ll take pictures of my backpack trip and put the pictures on my Web site.

Page 11: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

Exercise LogiCola C (EM & ET)

Page 12: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

LogiCola C-ET

Page 13: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

OK if you use LogiCola notations in assignment and quiz

Page 14: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.2 Simple truth tables: the meaning/semantics of wff

• A truth table gives a logical diagram for a wff. It lists all possible truth-value combinations for the letters and says whether the wff is true or false in each case.

• Define connectives first…

Page 15: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles
Page 16: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles
Page 17: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

Real-life “or” may have different meanings

“You can have all-you-can-eat soup or salad and bread”.

• Inclusive “or”. • Exclusive “or”: A or B but not both =

((A∨B)·~(A·B)) • Most logic books treat “either A or B” as

exclusive or… but this textbook treats “either A or B” as (A∨B)

Page 18: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles
Page 19: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

Some interesting examples of “if”“If A then B” does NOT imply A… but is often taken otherwise.

In “Death on the Nile”“If I did not sleep, if I walked on the deck, I might see who killed her”

The Conservatives have issued another apology, this time for comments caught on video Wednesday by an assistant to Transport Minister Lawrence Cannon.

The exchange was caught on video and broadcast Wed. by the Aboriginal Peoples Television Network.

“If you behave and you're sober and there's no problems and if you don't do a sit down and whatever, I don't care,” said Mr. Cannon's assistant Darlene Lannigan to Mr. Matchewan.

“Are you calling me an alcoholic?” replied Mr. Matchewan.She later added: “One of them showed up the other day and was drinking.”

Page 20: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles
Page 21: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.3 Truth evaluations

• We can calculate the truth value of a wff if we know the truth value of its letters.

LogiCola D (TM & TH)

Page 22: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.3a Exercise• Assume that A=1 and B=1 (A and B are both

true) while X=0 and Y=0 (X and Y are both false). Calculate the truth value of each wff below.

Page 23: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.4 Unknown evaluations • We can sometimes figure out a formula’s truth value

even if we don’t know the truth value of some letters. • Exercise—LogiCola D (UE, UM, & UH)

T=1 (T is true), F=0 (F is false), and U=?

Page 24: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.5 Complex truth tables

• A formula with n distinct letters has 2n

possible truth-value combinations:

Page 25: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles
Page 26: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

• The truth table for “(P∨~P)” is true in all cases—which makes the formula a tautology– the law of the excluded middle, says that every

statement is true or false (no other status, such as “maybe true”). This law holds in propositional logic

• The truth table for “(P·~P)” is false in all cases—which makes the formula a self-contradiction

• Otherwise, the formula is a contingent (either true of false; we do not know which one).

3.5a Exercise—LogiCola D (FM & FH)

Page 27: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

Logical Paradox…

• Everything I say is a lie. Is this a lie?

• Barber paradox: An adult male barber shaves all and only men who do not shave themselves. Does he shave himself?

• One thing is certain in this world: nothing is certain.

Page 28: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.6 The truth-table test • To prove a propositional argument (given

premises and conclusion)…• Construct a truth table showing the truth

value of the premises and conclusion for all possible cases.

• The argument is valid if and only if for all rows (cases) that the premises are all true, the conclusion is also true. Otherwise, the argument is invalid.

Page 29: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

• If you’re a dog, then you’re an animal. You’re not a dog. ∴ You’re not an animal

So, cannot conclude (or invalid to deduce) “you’re not an animal

Page 30: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.6a Exercise—LogiCola D (AE, AM, & AH)

Short-cut table: do it faster

1If C is 1, no need to evaluate any Pi (ignore this row and continue the table)

? If any Pi is 0, no need to evaluate other P’s and C (ignore this row and continue the table)

If the above case does not happen when you complete the table, the argument is valid.

0If C is 0, must evaluate Ps. If all Pi are 1, stop the table. The argument is invalid.

C…P3P2P1Letter comb

Page 31: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

A Note– Reasoning (or argument) is valid or invalid, not

“true” or “false”– When valid conclusion cannot be drawn: not

the same as drawing the negated conclusion. – Previous example: invalid to conclude “you are

an animal”– In court, given evidence, if I can prove “you are

guilty”, then “you are guilty” is true. But if I cannot prove you are guilty, then you can be either guilty or innocent.

Page 32: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.6a Exercise (selected)3. If television is always right, then Anacin is better than

Bayer. If television is always right, then Anacin isn’t better than Bayer. ∴ Television isn’t always right. [Use T and B.]

4. If it rains and your tent leaks, then your down sleeping bag will get wet. Your tent won’t leak. ∴ Your down sleeping bag won’t get wet. [Use R, L, and W.]

7. If ethics depends on God’s will, then something is good because God desires it. Something isn’t good because God desires it. (Instead, God desires something because it’s already good.) ∴ Ethics doesn’t depend on God’s will. [Use D and B; this argument is from Plato’s Euthyphro.]

9. I’ll go to Paris during spring break if and only if I’ll win the lottery. I won’t win the lottery. ∴ I won’t go to Paris during spring break. [Use P and W.]

Page 33: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

• If an argument “passes the truth-table test”, it means that the premises “entails” the conclusion (in semantics). ╞

• The truth-table test can get tedious for long arguments. Arguments with 6 letters may need 64 lines—and ones with 10 letters need 1024 lines

• Can we do it based only on “syntax”? Yes, see 3.10- , Chapter 4, …

Page 34: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.7 The truth-assignment test • Take a propositional argument. Set each

premise to 1 and the conclusion to 0. The argument is VALID if and only if no consistent way of assigning 1 and 0 to the letters will make this work—so we can’t make the premises all true and conclusion false.

• You REFUTE the argument if you can find such an assignment– Again, this does not prove the negated conclusion.

Page 35: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

Exercise—LogiCola E (S); E (E)

Is this method easier than the truth-table test?

Page 36: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles
Page 37: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

• Read Chapter 3.8 by yourselves • Read Chapter 3.9 by yourselves

• 3.8a Exercise—LogiCola C (HM & HT)• 3.9a Exercise—LogiCola E (F I)

Page 38: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

Some extra topics

See extra slides posted…• Adequate set of connectives (set2)

Page 39: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.10/3.11 S-rules, I-rules• Inference rules, which state that certain

formulas can be derived with validity from certain other formulas, mechanically

• “Deduce”, “formally deducible”: ├• Will be building blocks for formal proofs• Also check mechanically if a proof is valid • They reflect common forms of reasoning• What we hope to have (see later)…

– Everything that is deduced is indeed valid. Sound– Everything that is valid can be deduced. Complete

Page 40: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.10a Exercise—LogiCola F (SE & SH)

Each P and Q can match with any wff. E.g., (A ∙ (B ∙ C))

Page 41: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles
Page 42: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

All S-rules

Also: P → ~ ~ P

Page 43: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.11a Exercise—LogiCola F (IE & IH)Modus Ponens Modus Tolens

Page 44: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles
Page 45: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.12 Combining S- and I-rules

• 3.12a Exercise—LogiCola F (CE & CH)

Page 46: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.13 Extended inferences

Page 47: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

• Exercise

Page 48: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

Rules you can use

Page 49: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

Sound but Incomplete…

• These rules are certainly sound• But incomplete…

– Cannot prove these…

Next chapter: sound and complete proof system

Page 50: Chapter 3: Basic Propositional Logiccling.csd.uwo.ca/cs2209/LectureNotes/set1_chp3.pdfChapter 3: Basic Propositional Logic Based on Harry Gensler’sbook For CS2209A/B By Dr. Charles

3.14 Logic and computers

• Boolean Logic: used to design circuits in computers and digital devices• Automated logical deduction, automated proof system• Logic Programming: a logic-based declarative programming language• AI: knowledge representation, reasoning, planning• Hoare Logic: correctness of computer programs