Sie sind auf Seite 1von 30

Wang: CIS 630: Artificial Intelligence

Deduction
An important part of human reasoning

Goal: Representing Knowledge in Logic


and Mechanizing Logical Reasoning

• Given a set of

• Assumptions (Facts)

• Universal Laws of Logic (Deduction)

• We can find all new facts which logically follow from


the assumptions

• Can be used to prove an assertion

• Or disprove an assertion

Logic, Page 1
Wang: CIS 630: Artificial Intelligence

Basic Concepts

• Logical expressions are built out of components

Objects (Constants)

Variables

Functions

The above three are called Terms

Predicates

Connectives

Quantifiers

Logic, Page 2
Wang: CIS 630: Artificial Intelligence

Objects

• Symbols that denote specific things or individuals

JOHN

MARY

BASKETBALL

TRIANGLE

Quantifiers

Variables

• Unspecific references to objects

Logic, Page 3
Wang: CIS 630: Artificial Intelligence

Functions

• An argument to a function is either an object or a variable

- Starting with a lowercase letter

• The value of a function is either an object or a variable

exp(0) = 1

next-day(THURSDAY) = FRIDAY

brother(JOHN) = JIM

Predicates
(or functions returning True or False)

• Functions which denote attributes of objects or relationships


between individuals

- Starting with a uppercase letter

Loves(JOHN, MARY)

Man(SOCRATES)

Sunny(THURDAY)

Logic, Page 4
Wang: CIS 630: Artificial Intelligence

Connectives

• Logical operators which computes truth values

∧ AND

∨ OR

¬ NOT

⊃ IMPLIES

Quantifiers

• Logical operators which assert the scope of a predicate

∀ For All (universal quantifier)

∃ There Exists (existential quantifier)

Logic, Page 5
Wang: CIS 630: Artificial Intelligence

Literals

• A term is an object, a variable, or a function

• An atomic formula (atom) is a predicate with a proper number


of arguments (terms)

• A literal is either an atom or the negation of an atom

• No Quantifiers

Well-formed Formulas (wffs)

Defined recursively

• Literals are wffs

• wffs connected by ¬, ∧, ∨, and ⊃ are wffs

• wffs surrounded by quantifiers are wffs

Logic, Page 6
Wang: CIS 630: Artificial Intelligence

Notations: Summary Diagram

Objects Variables Functions


x
John exp

Terms Predicates

Feathers

Atoms Negation
Feathers(x)

Connectives Literals Quantifiers

Well-formed formulas

∀x[Feathers(x) ⊃ Bird(x)]

Logic, Page 7
Wang: CIS 630: Artificial Intelligence

Logic & Semantics

External World Logic World

Block A

Block B

On(A, B)
On-relation

Logic, Page 8
Wang: CIS 630: Artificial Intelligence

Mathematical Logic (Brief Review)


Theorems of logical operations

• Distributivity

x ∧ (y ∨ z) = (x ∧ y) ∨ (x ∧ z)

x ∨ (y ∧ z) = (x ∨ y) ∧ (x ∨ z)

• DeMorgan's Laws

¬ ( x ∨ y) = (¬x ∧ ¬y)

¬ ( x ∧ y) = (¬x ∨ ¬y)

• Other laws of negation

¬ ( ¬x) = x

¬∀ x[E(x)] = ∃x[¬E(x)]

¬∃ x[E(x)] = ∀x[¬E(x)]

• Verify it youself by using truth tables

Logic, Page 9
Wang: CIS 630: Artificial Intelligence

Mathematical Logic (cont.)


Laws of Inference

• Modus Ponens (Forward)

If P ⊃ Q and P is true

Then Q is true

• Modus Tolens (Backforward)

If P ⊃ Q and ¬Q is true (Q is false)

Then ¬P is true (P is false)

• Syllogism

If P ⊃ Q and Q ⊃ R

Then P ⊃ R

Logic, Page 10
Wang: CIS 630: Artificial Intelligence

How to Use Deduction?

• Decide on Terms, Predicates

• Translate facts from Natural Language to well-formed


expressions

• The rest is mechanical ......

Logic, Page 11
Wang: CIS 630: Artificial Intelligence

Examples for Conversion from Natural


Language Sentences to Predicate Logic

1. Marcus was a man

Man(Marcus)

2. Marcus was a Pompeian

Pompeian(Marcus)

3. All Pompeians were Romans

∀x [Pompeian(x) ⊃ Roman(x)]

4. Caesar was a ruler

Ruler(Caesar)

5. All Romans were either loyal to Caesar or hated him

∀x [Roman(y) ⊃ (LoyalTo(x,Caesar) ∨ Hate(x,Caesar))]

6. Everyone is loyal to someone

∀x ∃y LoyalTo(x,y)

Logic, Page 12
Wang: CIS 630: Artificial Intelligence

Predicate Logic Examples (cont.)

7. People only try to assassinate rulers they aren't loyal to

∀x∀y[(Person(x) ∧ Ruler(y) ∧ TryAssassinate(x,y)) ⊃


¬LoyalTo(x,y)]

8. Marcus tried to assassinate Caesar

TryAssassinate(Marcus, Caesar)

Can you prove: ¬LoyalTo(x,Caesar)

Logic, Page 13
Wang: CIS 630: Artificial Intelligence

Resolution
A way of mechanizing deduction

• Convert to Clause Form

• Each clause is a conjunct

Clause-1 ∧ Clause-2 ∧ ... ∧ Clause-n

• Each conjunct is a disjunction of literals

Clause-k = Literal-1 ∨ Literal-2 ∨ ... ∨ Literal-m

• Unification

A matching procedure which finds a set of most general


substitutions to make two literals identical

• Theorem proving

Backforward reasoning to discover contradictions

Logic, Page 14
Wang: CIS 630: Artificial Intelligence

Conversion to Clause Form


Example:
∀x[Brick(x) ⊃ (∃y[On(x,y) ∧ ¬Pyramid(y)]
∧¬∃ y[On(x,y) ∧ On(y,x)]
∧∀y[¬Brick(y) ⊃ ¬Equal(x,y)])]

1. Eliminate implications (⊃), using (P ⊃ Q) = (¬P ∨ Q)

∀x[¬Brick(x) ∨ (∃y[On(x,y) ∧ ¬Pyramid(y)]


∧¬∃ y[On(x,y) ∧ On(y,x)]
∧∀y[¬(¬Brick(y)) ∨ ¬Equal(x,y)])]

2. Move negation (¬) down to atoms

∀x[¬Brick(x) ∨ (∃y[On(x,y) ∧ ¬Pyramid(y)]


∧∀y[¬On(x,y) ∨ ¬On(y,x)]
∧∀y[Brick(y) ∨ ¬Equal(x,y)])]

3. Eliminate existential quantifiers by inserting Skolem


functions

∀x[¬Brick(x) ∨ ((On(x,Support(x)) ∧ ¬Pyramid(Support(x))


∧∀y[¬On(x,y) ∨ ¬On(y,x)]
∧∀y[Brick(y) ∨ ¬Equal(x,y)])]

Logic, Page 15
Wang: CIS 630: Artificial Intelligence

Conversion to Clause Form


continued

4. Rename variables so that no two variables are the same

∀x[¬Brick(x) ∨ ((On(x,(Support(x)) ∧ ¬Pyramid(Support(x))


∧∀y[¬On(x,y) ∨ ¬On(y,x)]
∧∀z[Brick(z) ∨ ¬Equal(x,z)])]

5. Eliminate the universal quantifiers

[¬Brick(x)∨((On(x,(Support(x)) ∧ ¬Pyramid(Support(x))
∧[¬On(x,y) ∨ ¬On(y,x)]
∧[Brick(z) ∨ ¬Equal(x,z)])]

6. Move disjunctions down to the literals

[(¬Brick(x) ∨ (On(x,(Support(x))∧¬Pyramid(Support(x)))
∧(¬Brick(x) ∨ ¬On(x,y) ∨ ¬On(y,x))
∧(¬Brick(x) ∨ Brick(z) ∨ ¬Equal(x,z))]

in another step

[(¬Brick(x) ∨ On(x,Support(x))
∧(¬Brick(x) ∨¬Pyramid(Support(x))
∧(¬Brick(x) ∨ ¬On(x,y) ∨ ¬On(y,x))
∧(¬Brick(x) ∨ Brick(z) ∨ ¬Equal(x,z))]

Logic, Page 16
Wang: CIS 630: Artificial Intelligence

Conversion to Clause Form


continued

7. Eliminate conjunctions by convention

(¬Brick(x) ∨ On(x,Support(x))
(¬Brick(x) ∨¬Pyramid(Support(x))
(¬Brick(x) ∨ ¬On(x,y) ∨ ¬On(y,x))
(¬Brick(x) ∨ Brick(z) ∨ ¬Equal(x,z))

8. Rename all variables again so that no two are the same

By the fact: ∀x[P(x) ∧ Q(x)] = ∀x [P(x)] ∧ ∀x[Q(x)]

So we finally arrive at

(¬Brick(x) ∨ On(x,(Support(x))
(¬Brick(w) ∨¬Pyramid((Support(w)))
(¬Brick(u) ∨ ¬On(u,y) ∨ ¬On(y,u))
(¬Brick(v) ∨ Brick(z) ∨ ¬Equal(v,z))

Logic, Page 17
Wang: CIS 630: Artificial Intelligence

Basics of Resolution
Given

¬P ∨ Q
P∨R

We can conclude

Q∨R

OR given

¬Feathers(Squigs) ∨ Bird(Squigs)
Feathers(Squigs)

We can conclude

Bird(Squigs)

• In general, resolution cancels a pair of literals with opposite


signs from two clauses, and combines the rest to a new
clause.

Logic, Page 18
Wang: CIS 630: Artificial Intelligence

Unification
Q(x)
P(x) ==> FAIL

P(x)
P(y) ==> {y → x}
(Book version: x/y)

P(Marcus)
P(y) ==> {y → Marcus} (or Marcus/y)

P(Marcus)
P(Julius) ==> FAIL

P(x,x)
P(y,z) ==> {x → y, y → z}

Logic, Page 19
Wang: CIS 630: Artificial Intelligence

Find Most General Substitutions


Given:

Hate(x,y)
Hate(Marcus,z)

We could produce:

{x → Marcus, y → z}
{x → Marcus, z → y}
{x → Marcus, y → Caesar, z → Caesar}
{x → Marcus, y → Polonius, z → Polonius}

Logic, Page 20
Wang: CIS 630: Artificial Intelligence

Unification
Two literals: L1 and L2

1. If one of them is a term

• If they are identical, return NIL

• If one of them is variable and another one contains the


same variable, return FAIL

E.g.: {x, f(x)} ==> endless unification

else substitute the variable by the other

• Return FAIL

2. If the predicate names are not the same or they have different
number of arguments, return FAIL.

3. Recursively call the algorithm with each pair of


corresponding arguments

• If FAIL, return FAIL

• Else append substitutions together and return it

Logic, Page 21
Wang: CIS 630: Artificial Intelligence

Resolution Algorithm

1. Convert all facts to clause form (product of sums)

2. Negate the goal (theorem to be proven)

3. Convert the negated goal to clause form, and add to the set
of facts

4. Until NIL is found, repeat

• Select two clauses

• Compute their resolvent

• Add it to the set of facts

Logic, Page 22
Wang: CIS 630: Artificial Intelligence

Heuristics
Still needed

• Set of support

Choose clauses which contain facts which appear in the


goal, or facts directly derived from the negated goal by
prior resolution

• Unit preference

Choose shortest clauses

• Breadth-first

Start from the initial clauses, level by level

Logic, Page 23
Wang: CIS 630: Artificial Intelligence

Example

Whoever can read is literate

Dolphins are not literate

Some Dolphins are intelligent

PROVE

Some who are intelligent cannot read

Translate into Predicate Logic


• Whoever can read is literate

∀x [R(x) ⊃ L(x)]

• Dolphins are not literate

∀x [D(x) ⊃ ¬L(x)]

• Some Dolphins are intelligent

∃x [D(x) ∧ I(x)]

• Goal: Some who are intelligent cannot read

∃x [I(x) ∧ ¬R(x)]

Logic, Page 24
Wang: CIS 630: Artificial Intelligence

Convert into Clause Form


Forget about reality

• ∀x [R(x) ⊃ L(x)] convert to ¬R(x) ∨ L(x) ... (1)

• ∀x [D(x) ⊃ ¬L(x)] convert to ¬D(y) ∨ ¬L(y) ... (2)

• ∃x [D(x) ∧ I(x)] convert to D(S1) ... (3)


I(S1) ... (4)

• Negate conclusion

¬[∃ x(I(x) ∧ ¬R(x))] convert to ¬I(z) ∨ R(z) ... (5)

Logic, Page 25
Wang: CIS 630: Artificial Intelligence

Resolve

¬R(x) ∨ L(x) ... (1)


¬D(y) ∨ ¬L(y) ... (2)
D(S1) ... (3)
I(S1) ... (4)

and

¬I(z) ∨ R(z) ... (5)

• (4) and (5) ==> R(S1) ... (6)

• (6) and (1) ==> L(S1) ... (7)


• (7) and (2) ==> ¬D(S1) ... (8)

• (8) and (3) ==> NIL DONE

Logic, Page 26
Wang: CIS 630: Artificial Intelligence

Conclusions about Resolution

• It is powerful, and but subject to exponential explosion

• Theoretically, first-order predicate logic is

• Undecidable. No guarantee to halt (terminate)

• Acceptable. If the goal is true, guaranteed to halt

• Together, it is called semidecidable

• It is a uniform framework, and a general problem solving


method.

• But logic is weak for representing certain kinds of


knowledge

Logic, Page 27
Wang: CIS 630: Artificial Intelligence

Other Forms of Inference


• Induction

• Abduction

• Analogy

• Induction

• Reason from specific cases to general rules

• Very difficult to mechanize

• A major characteristic of learning


(problem for machine learning)

Robins fly
Sparrows fly ==> Birds fly
Hawks fly (what about ostrich?)

Logic, Page 28
Wang: CIS 630: Artificial Intelligence

Abduction

• Reverse causal reasoning

If P ⊃ Q, and Q
Abduce P

Example: Anyone who has lung problems is short


of breath.
Bill feels short of breath.
Therefore, Bill has lung problems

• Approximate reasoning

• A useful form of reasoning, particularly for finding


explanations (diagnosis)

Logic, Page 29
Wang: CIS 630: Artificial Intelligence

Analogy

• A powerful inference tool for people

• Frequently used in Natural Language

• Seeing clouds from a plane is like seeing ocean

• All modern cities are alike

• Problems in electromagnetism are just like problems in


fluid flow

• How is it used?

• Find an old problem similar to the new one

• Recall the solution to the old problem

• Apply it to the new problem

Logic, Page 30

Das könnte Ihnen auch gefallen