Date post: | 31-Aug-2018 |
Category: |
Documents |
Upload: | truongtram |
View: | 234 times |
Download: | 0 times |
Wang: CIS 630 : Artificial Intelligence
Logic, Page 1
Deduction
An important part of human reasoning
Goal: Representing Knowledge in Logicand Mechanizing Logical Reasoning
• Given a set of
• Assumptions (Facts)
• Universal Laws of Logic (Deduction)
• We can find all new facts which logically follow fromthe assumptions
• Can be used to prove an assertion
• Or disprove an assertion
Wang: CIS 630 : Artificial Intelligence
Logic, Page 2
Basic Concepts
• Logical expressions are built out of components
Objects (Constants)
Variables
Functions
The above three are called Terms
Predicates
Connectives
Quantifiers
Wang: CIS 630 : Artificial Intelligence
Logic, Page 3
Objects
• Symbols that denote specific things or individuals
JOHN
MARY
BASKETBALL
TRIANGLE
Quantifiers
Variables
• Unspecific references to objects
x
y
z
Wang: CIS 630 : Artificial Intelligence
Logic, Page 4
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 relationshipsbetween individuals
- Starting with a uppercase letter
Loves(JOHN, MARY)
Man(SOCRATES)
Sunny(THURDAY)
Wang: CIS 630 : Artificial Intelligence
Logic, Page 5
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)
Wang: CIS 630 : Artificial Intelligence
Logic, Page 6
Literals
• A term is an object, a variable, or a function
• An atomic formula (atom) is a predicate with a proper numberof 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
Wang: CIS 630 : Artificial Intelligence
Logic, Page 7
Notations: Summary Diagram
Feathers(x)
xObjects
John
Variables Functions
exp
Terms Predicates
Feathers
Atoms Negation
LiteralsConnectives Quantifiers
Well-formed formulas
∀ x[Feathers(x) ⊃ Bird(x)]
Wang: CIS 630 : Artificial Intelligence
Logic, Page 8
Logic & Semantics
On-relation
External World Logic World
Block A
Block B
On(A, B)
Wang: CIS 630 : Artificial Intelligence
Logic, Page 9
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
Wang: CIS 630 : Artificial Intelligence
Logic, Page 10
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
Wang: CIS 630 : Artificial Intelligence
Logic, Page 11
How to Use Deduction?
• Decide on Terms, Predicates
• Translate facts from Natural Language to well-formedexpressions
• The rest is mechanical ......
Wang: CIS 630 : Artificial Intelligence
Logic, Page 12
Examples for Conversion from NaturalLanguage 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)
Wang: CIS 630 : Artificial Intelligence
Logic, Page 13
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)
Wang: CIS 630 : Artificial Intelligence
Logic, Page 14
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 generalsubstitutions to make two literals identical
• Theorem proving
Backforward reasoning to discover contradictions
Wang: CIS 630 : Artificial Intelligence
Logic, Page 15
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 Skolemfunctions
∀ x[¬Brick(x) ∨ ((On(x,Support(x)) ∧ ¬Pyramid(Support(x))∧ ∀ y[¬On(x,y) ∨ ¬On(y,x)]∧ ∀ y[Brick(y) ∨ ¬Equal(x,y)])]
Wang: CIS 630 : Artificial Intelligence
Logic, Page 16
Conversion to Clause Formcontinued
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))]
Wang: CIS 630 : Artificial Intelligence
Logic, Page 17
Conversion to Clause Formcontinued
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))
Wang: CIS 630 : Artificial Intelligence
Logic, Page 18
Basics of Resolution
Given
¬P ∨ QP ∨ 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 oppositesigns from two clauses, and combines the rest to a newclause.
Wang: CIS 630 : Artificial Intelligence
Logic, Page 19
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}
Wang: CIS 630 : Artificial Intelligence
Logic, Page 20
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}
Wang: CIS 630 : Artificial Intelligence
Logic, Page 21
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 thesame 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 differentnumber of arguments, return FAIL.
3. Recursively call the algorithm with each pair ofcorresponding arguments
• If FAIL, return FAIL
• Else append substitutions together and return it
Wang: CIS 630 : Artificial Intelligence
Logic, Page 22
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 setof facts
4. Until NIL is found, repeat
• Select two clauses
• Compute their resolvent
• Add it to the set of facts
Wang: CIS 630 : Artificial Intelligence
Logic, Page 23
Heuristics
Still needed
• Set of support
Choose clauses which contain facts which appear in thegoal, or facts directly derived from the negated goal byprior resolution
• Unit preference
Choose shortest clauses
• Breadth-first
Start from the initial clauses, level by level
Wang: CIS 630 : Artificial Intelligence
Logic, Page 24
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)]
Wang: CIS 630 : Artificial Intelligence
Logic, Page 25
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)
Wang: CIS 630 : Artificial Intelligence
Logic, Page 26
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
Wang: CIS 630 : Artificial Intelligence
Logic, Page 27
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 solvingmethod.
• But logic is weak for representing certain kinds of knowledge
Wang: CIS 630 : Artificial Intelligence
Logic, Page 28
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 flySparrows fly ==> Birds flyHawks fly (what about ostrich?)
Wang: CIS 630 : Artificial Intelligence
Logic, Page 29
Abduction
• Reverse causal reasoning
If P ⊃ Q, and QAbduce P
Example: Anyone who has lung problems is shortof breath.
Bill feels short of breath.Therefore, Bill has lung problems
• Approximate reasoning
• A useful form of reasoning, particularly for findingexplanations (diagnosis)
Wang: CIS 630 : Artificial Intelligence
Logic, Page 30
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 influid 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