38
Logical and Rule- Logical and Rule- Based Reasoning Based Reasoning Part I Part I

Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

  • View
    230

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Logical and Rule-Based Logical and Rule-Based Reasoning Reasoning

Part IPart I

Page 2: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Logical Models and ReasoningLogical Models and Reasoning

Big Question:Big Question:

Do people think logically?Do people think logically?

Page 3: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

ExerciseExerciseYou are given 4 cards each with a letter on one side, and a You are given 4 cards each with a letter on one side, and a number on the other. You can see one side of each card number on the other. You can see one side of each card only:only:

Rule: “Rule: “if a card has a vowel on one side, then it if a card has a vowel on one side, then it has an odd number on the other”has an odd number on the other”

In order to check whether the rule is true of these cards, In order to check whether the rule is true of these cards, what is the what is the minimalminimal number of cards cards do you need to number of cards cards do you need to turn over and which ones?turn over and which ones?

EE 77 KK 22

1 2 3 4

Page 4: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

ExerciseExerciseNow assume each card has a beverage on one side, and the drinker's age on the other : :

Rule: “Rule: “if someone drinks beer, then she is 21 if someone drinks beer, then she is 21 years or older”years or older”

In order to check whether the rule is true of these cards, In order to check whether the rule is true of these cards, what is the what is the minimalminimal number of cards cards do you need number of cards cards do you need to turn over and which ones?to turn over and which ones?

BeerBeer CokeCoke 23years

23years

19years

19years

1 2 3 4

Page 5: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Logical ReasoningLogical ReasoningThe goal is find a way toThe goal is find a way to state knowledge explicitlystate knowledge explicitly draw conclusions from the stated knowledgedraw conclusions from the stated knowledge

LogicLogic A "logic" is a mathematical notation (a language) for stating A "logic" is a mathematical notation (a language) for stating

knowledgeknowledge The main alternative to logic is "natural language" i.e. The main alternative to logic is "natural language" i.e.

English, Swahili, etc.English, Swahili, etc. As in natural language the fundamental unit is a “sentence” As in natural language the fundamental unit is a “sentence”

(or a statement)(or a statement) Syntax and SemanticsSyntax and Semantics Logical inferenceLogical inference

Page 6: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Propositional Logic: SyntaxPropositional Logic: SyntaxSentencesSentences represented by propositional symbols (e.g., represented by propositional symbols (e.g., PP, ,

QQ, , RR, , SS, etc.), etc.) logical constants: logical constants: TrueTrue, , FalseFalse

Connectives: Connectives: , , , , , , , , is also shown as and as

Examples:Examples: ( ~ )P Q R

( ~ ) (~ )P Q Q R P

( ) ( )P Q Q P

( ) (~ )P Q P Q

Page 7: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Interpretations and ValidityInterpretations and Validity

A logical sentence S is A logical sentence S is satisfiablesatisfiable if it is if it is true at least in one situationtrue at least in one situation (under at least one “(under at least one “interpretationinterpretation”)”)

S is S is validvalid if it is true under all if it is true under all interpretations (S is a interpretations (S is a tautologytautology))

S is S is unsatisfiableunsatisfiable if it is false for all if it is false for all interpretations (S is interpretations (S is inconsistentinconsistent))

A sentence T A sentence T followsfollows (is (is entailedentailed by) S, if by) S, if any time S is true, T is also trueany time S is true, T is also true

Page 8: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

P Q P P Q P Q PQ PQF F T F F T TF T T F T T FT F F F T F FT T F T T T T

Propositional Logic: SemanticsPropositional Logic: SemanticsIn propositional logic, the semantics of connectives are In propositional logic, the semantics of connectives are specified by truth tables:specified by truth tables:

Each assignment of truth values to individual Each assignment of truth values to individual propositions (e.g., P, Q, R) in the sentence represents propositions (e.g., P, Q, R) in the sentence represents one interpretation one interpretation a row in the truth table a row in the truth table

Truth tables can also be used to determine the validity of Truth tables can also be used to determine the validity of sentencessentences

Page 9: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Notes on ImplicationNotes on ImplicationIf p and q are both true, then p If p and q are both true, then p q is true. q is true.

If 1+1 = 2 then the sun rises in the east. If 1+1 = 2 then the sun rises in the east. Here p: "1+1 = 2" and q: "the sun rises in the east." Here p: "1+1 = 2" and q: "the sun rises in the east."

If p is true and q is false, then p If p is true and q is false, then p q is false. q is false. When it rains, I carry an umbrella. When it rains, I carry an umbrella. p: "It is raining," and q: "I am carrying an umbrella." p: "It is raining," and q: "I am carrying an umbrella." we can rephrase as: "If it is raining then I am carrying an we can rephrase as: "If it is raining then I am carrying an

umbrella." umbrella." On days when it rains (p is true) and I forget to bring my On days when it rains (p is true) and I forget to bring my

umbrella (q is false), the statement p umbrella (q is false), the statement p q is false q is false

If p is false, then p If p is false, then p q is true, no matter whether q is q is true, no matter whether q is true true or not. or not. For instance: For instance:

If the moon is made of green cheese, then I am the King of If the moon is made of green cheese, then I am the King of England. England.

Page 10: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Notes on ImplicationNotes on Implication

Using truth tables we Using truth tables we notice that the only notice that the only way the implication p way the implication p q can be false is for q can be false is for p to be true and q to p to be true and q to be false. be false. In other words, p In other words, p q q

is logically equivalent is logically equivalent to (~p) \/ q. to (~p) \/ q.

p  q  (~p) \/  q

"Switcheroo" law

Page 11: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Propositional InferencePropositional InferenceLet Let SS be be (A \/ C) /\ (B \/ ~C)(A \/ C) /\ (B \/ ~C) and let and let RR be be A \/ BA \/ B. Does . Does RR follow from follow from SS?? check all possible interpretations (involving A, check all possible interpretations (involving A,

B, and C); R must be true whenever B, and C); R must be true whenever SS is true is true

A B C A C B C R S = A BF F F F T F FF F T T F F FF T F F T F TF T T T T T TT F F T T T TT F T T F F TT T F T T T TT T T T T T T

Page 12: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Checking Validity and EquivalencesChecking Validity and Equivalences

Suppose we want to determine if a sentence:Suppose we want to determine if a sentence:

is valid:is valid: Construct the truth table for the sentence using all possible Construct the truth table for the sentence using all possible

combinations of true and false assigned to P and Qcombinations of true and false assigned to P and Q As intermediate steps, can create columns for different As intermediate steps, can create columns for different

components of the compound sentencecomponents of the compound sentence

P Q P P Q PQ (PQ) (P Q)F F T T T TF T T T T TT F F F F TT T F T T T

(PQ)(~PQ)

This sentence is a tautology because it is true under all interpretations

Page 13: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Some Useful Tautologies Some Useful Tautologies (equivalences)(equivalences)

( ) ( )P Q P Q

( ) ( )P Q P Q

P Q R P Q P R ( ) ( ) ( )

P Q R P Q P R ( ) ( ) ( )

( ) ( )P Q P Q ( ) ( )P Q P Q

(( ) ) ( )P Q R P Q R

Conversion between => and \/

DeMorgan’s Laws

Distributivity

Page 14: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Using Equivalences: ExampleUsing Equivalences: Example

Page 15: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Some Online Practice ExercisesSome Online Practice Exercises

http://people.hofstra.edu/faculty/http://people.hofstra.edu/faculty/Stefan_Waner/RealWorld/logic/logic3.htmlStefan_Waner/RealWorld/logic/logic3.html

Page 16: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

More Tautologies and EquivalencesMore Tautologies and Equivalences

Page 17: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

More Tautologies and EquivalencesMore Tautologies and Equivalences

Can also check it with truth tables:Can also check it with truth tables:

Page 18: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

More Tautologies and EquivalencesMore Tautologies and Equivalences

Page 19: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

More Online Practice ExercisesMore Online Practice Exercises

http://people.hofstra.edu/faculty/http://people.hofstra.edu/faculty/Stefan_Waner/RealWorld/logic/logic4.htmlStefan_Waner/RealWorld/logic/logic4.html

Page 20: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

More Tautologies and EquivalencesMore Tautologies and Equivalences

Page 21: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

More Tautologies and EquivalencesMore Tautologies and Equivalences

Page 22: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

More Tautologies and EquivalencesMore Tautologies and Equivalences

Page 23: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Summary of Tautological Summary of Tautological Implications and EquivalencesImplications and Equivalences

http://people.hofstra.edu/faculty/http://people.hofstra.edu/faculty/Stefan_Waner/RealWorld/logic/logic4.htmlStefan_Waner/RealWorld/logic/logic4.html

See tables A and B at the following page:

Page 24: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Exercise: The Island of Knights & Exercise: The Island of Knights & KnavesKnaves

We are in an island all of whose We are in an island all of whose inhabitants are either knights or knavesinhabitants are either knights or knaves knights always tell the truthknights always tell the truth knaves always lieknaves always lie

Problem: Problem: you meet inhabitants A and B, and A tells you you meet inhabitants A and B, and A tells you

“at least one of us is a knave”“at least one of us is a knave” can you determine who is a knave and who is can you determine who is a knave and who is

a knight?a knight?

Page 25: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Exercise: The Island of Knights Exercise: The Island of Knights & Knaves& Knaves

Problem 1Problem 1 you meet inhabitants A and B. A says: “We are you meet inhabitants A and B. A says: “We are

both knaves.” What are A and B?both knaves.” What are A and B?

Problem 2Problem 2 you meet inhabitants A, B, and C. You walk up you meet inhabitants A, B, and C. You walk up

to A and ask: "are you a knight or a knave?" A to A and ask: "are you a knight or a knave?" A gives an answer but you don't hear what she gives an answer but you don't hear what she said. B says: "A said she was a knave." C said. B says: "A said she was a knave." C says: "don't believe B; he is lying.” says: "don't believe B; he is lying.”

What are B and C? How about A?What are B and C? How about A?

Page 26: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Logical InferenceLogical InferenceGiven a set of assumptions (premises), Given a set of assumptions (premises), logically inferring a new statement logically inferring a new statement (conclusion) is done by a step-by-step (conclusion) is done by a step-by-step derivation using “derivation using “rules of inferencerules of inference”” Rules of inference are the Tautological Rules of inference are the Tautological

Implications and Tautological Equivalences Implications and Tautological Equivalences we saw before (e.g., Modus Ponens)we saw before (e.g., Modus Ponens)

The derivation starting from the premises and The derivation starting from the premises and leading to the conclusion is called a “leading to the conclusion is called a “proofproof” or ” or and “and “argumentargument””

See the middle column of Tables A and B in See the middle column of Tables A and B in Section 4 of the Logic Web site.Section 4 of the Logic Web site.

Page 27: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Examples of Inference RulesExamples of Inference Rules

Page 28: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Applying Inference RulesApplying Inference RulesExample: Modus Ponens (MP)Example: Modus Ponens (MP) Suppose we have 3 statements we know to be true:Suppose we have 3 statements we know to be true:

Applying MP to statements 1 and 3, we conclude:Applying MP to statements 1 and 3, we conclude:

(r /\ ~s)(r /\ ~s) as the conclusion. as the conclusion.

Note that MP has the form: Note that MP has the form:

Here A stands for Here A stands for (p \/ q)(p \/ q) and B stands for and B stands for (r /\ ~s)(r /\ ~s). . Premise 2 in this case was not used.Premise 2 in this case was not used.

Page 29: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Applying Inference RulesApplying Inference Rules

Example: Modus Tollens (MT)Example: Modus Tollens (MT)

Page 30: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Applying Inference RulesApplying Inference RulesSome general rules to remember:Some general rules to remember:

Page 31: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Proof ExampleProof Example

Prove that the following Prove that the following argument is validargument is valid

Page 32: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Proof ExampleProof Example

Prove that the following Prove that the following argument is validargument is valid

Do Exercise 2P on Section 6 of the Logic Web siteDo Exercise 2P on Section 6 of the Logic Web site

Page 33: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Proof ExampleProof Example

Prove that the following Prove that the following argument is validargument is valid

Page 34: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

More Examples & ExercisesMore Examples & Exercises

In Section 6 of the Logic Web Site:In Section 6 of the Logic Web Site: Proof Strategies: Examples 4 and 5, and Proof Strategies: Examples 4 and 5, and

exercise 5Pexercise 5P Forward and Backward: Examples 6 and 7, Forward and Backward: Examples 6 and 7,

and exercise 7Pand exercise 7P Different types of arguments: Examples 8-10Different types of arguments: Examples 8-10 Logical Reasoning: Example 11Logical Reasoning: Example 11

Page 35: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Extra Credit ContestExtra Credit ContestYou are to write down and submit a statementYou are to write down and submit a statement

Rules of the contest: Rules of the contest: (Note: I can’t violate the rules)(Note: I can’t violate the rules) There are two prizes:There are two prizes:

Prize 1: you get a couple of m&m’sPrize 1: you get a couple of m&m’s

Prize 2: you get 10 extra credit points on your next Prize 2: you get 10 extra credit points on your next assignmentassignment

If your statement is true, then I have to give you If your statement is true, then I have to give you one of the prizesone of the prizes

If it is false, you get nothingIf it is false, you get nothing

The challengeThe challenge: come up with a statement that : come up with a statement that guarantees you get prize 2! guarantees you get prize 2!

Page 36: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Predicate LogicPredicate LogicConsider:Consider: p: All men are mortal. p: All men are mortal.

q: Socrates is a man. q: Socrates is a man. r: Socrates is mortal. r: Socrates is mortal.

We know that from p and q we should be able to We know that from p and q we should be able to prove r. prove r. But, there is nothing in propositional logic that allows But, there is nothing in propositional logic that allows

us to do this.us to do this.

Need to represent the relationship between all Need to represent the relationship between all men and one man in particular (Socrates).men and one man in particular (Socrates).

Page 37: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Predicate LogicPredicate Logic

Instead we need to use quantifiers and Instead we need to use quantifiers and predicates:predicates:

For all x, if x is a man, then x is For all x, if x is a man, then x is mortalmortal

x [ man(x) x [ man(x) mortal(x) ] mortal(x) ]

Universalquantifier

predicates

Page 38: Logical and Rule-Based Reasoning Part I. Logical Models and Reasoning Big Question: Do people think logically?

Predicate LogicPredicate Logic

Second quantifier is the existential Second quantifier is the existential quantifier (“there exists”):quantifier (“there exists”):

““Everybody loves somebody”Everybody loves somebody”

““for every person x, there is a person y so that x loves y”for every person x, there is a person y so that x loves y”

x [ person(x) x [ person(x) y [ person(y) /\ loves(x,y) ] ]y [ person(y) /\ loves(x,y) ] ]

Existensialquantifier

predicates