22
Types of logic

Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Embed Size (px)

Citation preview

Page 1: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Types of logic

Page 2: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Propositional logic: syntax

Page 3: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Limitations of Propositional Logic1. It is too weak, i.e., has very limited expressiveness:• Each rule has to be represented for each situation:

e.g., “don’t go forward if the wumpus is in front of you” takes 64 rules

2. It cannot keep track of changes:• If one needs to track changes, e.g., where the agent has been

before then we need a timed-version of each rule. To track 100 steps we’ll then need 6400 rules for the previous example.

Its hard to write and maintain such a huge rule-baseInference becomes intractable

Page 4: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Predicate logic

Predicate Logic is more expressive, because it allows us to represent :

• Objects

• Predicates (facts)

• Variables

Page 5: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Thus, we can write

• Comet is a horse

• Prancer is a horse

• Comet is parent of Dasher

• Comet is a parent of Prancer

• Prancer is fast

• Dasher is a parent of Thunder

• Thunder is fast

• Thunder is a horse

• Dasher is a horse

• horse(Comet)

• horse(Prancer)

• parent-of(Comet,Dasher)

• parent-of(Comet,Prancer)

• fast(Prancer)

• parent-of(Dasher,Thunder)

• fast(Thunder)

• horse(Thunder)

• horse(Dasher)

Page 6: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Suppose we have the following rule (relation)

R1: if   x is-a horse

            x is-parent-of y

            y is-fast

       then  x is valuable

Page 7: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Bindings

In general, there will be variables in the rules which stand for arbitrary objects. We need to find bindings for them so that the rule is applicable.

Page 8: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Bindings

Page 9: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Bindings

From these we can deduce that there are two possible bindings applicable to the rule:

x = Comet and y = Prancer

x = Dasher and y = Thunder

Since x is valuable, Comet is valuable and Dasher is valuable

Page 10: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Forward Chaining

• Forward Chaining or data-driven inference works by repeatedly: starting from the current state, matching the premises of the rules (the IF parts), and performing the corresponding actions (the then parts) that usually update the knowledge base or working memory.

• The process continues until no more rules can be applied, or some cycle limit is met.

Page 11: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Forward Chaining

Page 12: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Backward Chaining

• Backward chaining or goal-driven inference works towards a final state by looking at the working memory to see if the sub-goal states already exist there. If not, the actions (the THEN parts) of the rules that will establish the sub-goals are identified and new sub-goals are set up for achieving the premises of those rules (the IF parts).

Page 13: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Backward Chaining

• The previous example now becomes:

Page 14: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Quantifiers

• A key to predicate logic we have been ignoring is the inclusion of quantifiers

• You should recall from discrete that you can also write statements such as – x  fast(x) -> horse(x)– y  fast(y) -> valuable(y)

Page 15: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Represent the following sentences in predicate logic with quantifiers

1. Schafer is a Hoosier

2. Hoosiers like basketball.

3. Children of basketball fans are basketball fans.

4. Basketball fans like the month of March.

5. Margaret is Schafer's daughter

Page 16: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

One possible solution

Page 17: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Rules of Inference

• Modus Ponens p ^ (p -> q) -> q

• In other words, if you have an implication rule in the knowledge base AND the left hand side of the implication rule (the antecedent) then you can infer the right hand side of the rule (the consequent)

Page 18: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Rules of Inference

• Modus Ponens p ^ (p -> q) -> q

p = Today is my birthday q = I get presents

p -> q (“if today is my birthday than I will get presents”)

Suppose that a knowledge base contains that statement PLUS the knowledge that today is my birthday.

We can infer that I will get presents.

Page 19: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Rules of Inference

• Modus Tolens q’ ^ (p -> q) -> p’

• In other words, if you have an implication rule in the knowledge base AND the negation of the consequent than you can imply the negation of the antecedent

Page 20: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Rules of Inference

• Modus Tolens q’ ^ (p -> q) -> p’

p = Today is my birthday q = I get presents

p -> q (“if today is my birthday than I will get presents”)

Suppose that a knowledge base contains that statement PLUS the knowledge that I will not get presents today.

We can infer that today must not be my birthday.

Page 21: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

CAUTION

• Do not try to use either p’ ^ (p -> q) -> q’

(If today is not my birthday than I can infer that I won’t get presents??? Not true!)

q ^ (p -> q) -> p

(If I get presents today it must be my birthday)

Page 22: Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has

Consider the following

Using rules of inference, what can you add to this knowledge base?