SlideShare a Scribd company logo
1 of 32
Download to read offline
Artificial Intelligence Knowledge & Reasoning
Predicate Logic.
Reading: Sections 8.1, 8.2 & 8.3 of Textbook R&N
The world is blessed with many objects, some of which are
related to other objects.
Objects: people, houses, numbers, colors, baseball games, wars, …
Relations: red, round, brother of, bigger than, part of, comes between, …
How to represent the objects and their relation?
By Bal Krishna Subedi 1
Artificial Intelligence Knowledge & Reasoning
Predicate Logic: Basic Elements
Constants: John, 2, TU,...
Predicates Brother, >,...
Functions Sqrt, LeftLegOf,...
Variables x, y, a, b,...
Connectives ¬, ⇒, ∧, ∨, ⇔
Equality =
Quantifiers ∀, ∃
By Bal Krishna Subedi 2
Artificial Intelligence Knowledge & Reasoning
Predicate Logic: Syntax
Sentence → AtomicSentence
| (Sentence Connective Sentence)
| Quantifier Variable, ... Sentence
| ¬ Sentence
AtomicSentence → Predicate(Term, …) | Term = Term
Term → Function(Term, …) | Constant | Variable
Connective → ∧ | ∨ | ⇒ | ⇔
Quantifier → ∀ | ∃
Constant → A, B, C, X1 , X2, Jim, Jack
Variable → a, b, c, x1 , x2, counter, position, ...
Predicate → Adjacent-To, Younger-Than, HasColor, ...
Function → Father-Of, Square-Position, Sqrt, Cosine
ambiguities are resolved through precedence or parentheses
By Bal Krishna Subedi 3
Artificial Intelligence Knowledge & Reasoning
Sentences
Atomic Sentence:
A atomic sentence is formed from a predicate symbol followed by a parenthesized
list of terms.
E.g., Brother (Bill, Mary),
Father (Jack, John), Mother (Jill, John),
Sister (Jane, John)
Married (Jack, Jill)
BrotherOf (Bill) = Bob
Complex Sentence:
Complex sentences are made from atomic sentences using connectives.
E.g., Sibling (Tom, Bill) ⇒ Sibling (Bill, Tom).
Father (Jack, John) ∧ Mother (Jill, John) ∧ Sister (Jane, John).
¬ Sister (John, Jane).
Older (Father-Of (John), 30) ∨ Older (Mother-Of (John), 20).
By Bal Krishna Subedi 4
Artificial Intelligence Knowledge & Reasoning
Truth in first-order logic
Sentences are true with respect to a model and an interpretation
Model contains objects (domain elements) and relations among
them.
Interpretation specifies referents for
constant symbols → objects.
predicate symbols → relations.
function symbols → functional relations.
An atomic sentence predicate(term1,...,termn) is true iff the objects
referred to by term1,...,termn are in the relation referred to by
predicate.
Syntactically correct logical formulas are called well-formed
formulas (wff). Such wff are thus used to represent real-world
facts.
By Bal Krishna Subedi 5
Artificial Intelligence Knowledge & Reasoning
Quantifiers
• can be used to express properties of the
collections of objects
– eliminates the need to explicitly enumerate all
objects
• predicate logic uses two quantifiers
– universal quantifier ∀ : We can make a statement for all the
objects in the universe
– existential quantifier ∃ :We can make a statement about some
objects in the universe
By Bal Krishna Subedi 6
Artificial Intelligence Knowledge & Reasoning
Universal Quantification
∀<variables> <sentence>
Every CSG student needs a course in AI: ∀x Student (x, CSG) ⇒ Needs (x, AI)
∀x P is equivalent to the conjunction of instantiations of P and is interpreted as
P(x) is true for any possible x from the universe.
E.g., ∀x Student (x, CSG) ⇒ Needs (x, AI) is equivalent to claiming that
Student (John, CSG) ⇒ Needs (John, AI)
∧ Student (Richard, CSG) ⇒ Needs (Richard, AI)
∧ Student (Mike, CSG) ⇒ Needs (Mike, AI) ∧ ...
Typically, ⇒ is the main connective with ∀.
A common mistake to avoid: using ∧ as the main connective with ∀:
∀x Student (x, CSG) ∧ Needs (x, AI)
means “Everyone are CSG student and everyone needs AI” – very strong
statement - does not reflect the semantic.
By Bal Krishna Subedi 7
Artificial Intelligence Knowledge & Reasoning
Existential Quantification
∃<variables> <sentence>
Someone at CDCSIT is smart: ∃x At (x, CDCSIT) ∧ Smart (x)
∃x P is equivalent to the disjunction of instantiations of P and is interpreted as P(x)
is true for some object x in the universe.
E. g., ∃x At (x, CDCSIT) ∧ Smart (x) is equivalent to claiming that
At (John, CDCSIT) ∧ Smart (John)
∨ At (Richard, CDCSIT) ∧ Smart (Richard)
∨ At (Mike, CDCSIT) ∧ Smart (Mike) ∨ ...
Typically, ∧ is the main connective with ∃
Common mistake: using ⇒ as the main connective with ∃:
∃x At (x, CDCSIT) ⇒ Smart (x) is true if there is anyone who is not at
CDCSIT – very weak statement - does not reflect the semantic.
By Bal Krishna Subedi 8
Artificial Intelligence Knowledge & Reasoning
Multiple Quantifiers
more complex sentences can be formulated by
multiple variables and by nesting quantifiers
– the order of quantification is important
– variables must be introduced by quantifiers, and belong
to the innermost quantifier that mention them
Examples
∀x ∀y Brother (x, y) ⇒ Sibling (x, y)
∀x, y Parent (x, y) ⇒ Child (y, x)
∀x Human (x) ∃ y Mother (y, x)
∀x ∃ y Loves (x, y)
By Bal Krishna Subedi 9
Artificial Intelligence Knowledge & Reasoning
Properties of quantifiers
∀x ∀y is the same as ∀y ∀x.
∃x ∃y is the same as ∃y ∃x.
∃x ∀y is not the same as ∀y ∃x.
∃x ∀y Loves (x, y)
“There is a person who loves everyone in the world”.
∀y ∃x Loves (x, y)
“Everyone in the world is loved by at least one person”
Quantifier duality: each can be expressed using the other.
∀x Likes (x, IceCream) ¬∃x ¬Likes (x, IceCream).
∃x Likes (x, Cabbage) ¬∀x ¬Likes (x, Cabbage).
By Bal Krishna Subedi 10
Artificial Intelligence Knowledge & Reasoning
Some Examples
Everybody loves Jerry: ∀x Loves (x, Jerry)
Everybody loves somebody: ∀x ∃y Loves (x, y)
Brothers are siblings: ∀x, y Brother (x, y) ⇒ Sibling (x, y)
“Sibling” is reflexive: ∀x, y Sibling (x, y) ⇔ Sibling (y, x)
One's mother is one's female parent:
∀ x, y Mother (x, y) ⇔ (Female (x) ^ Parent (x, y))
A cousin is a child of a parent's sibling:
∀ x, y Cousin (x, y) ⇔ ∃ p, ps Parent (p, x) ^ Sibling
(ps, p) ^Parent (ps, y)
By Bal Krishna Subedi 11
Artificial Intelligence Knowledge & Reasoning
Inference With Predicate Logic
Reading: Chapter 9 of Textbook R&N
How to answer the questions if KB represented in
Predicate logic?
By Bal Krishna Subedi 12
Artificial Intelligence Knowledge & Reasoning
Inference rules for Quantifiers
Universal Instantiation:
if ∀ x P(x) is true then P(A) is true for any
individual “A”.
E.g., If we know that
∀ x Man (x) ⇒ Mortal (x),
then we can conclude
Man (Socrates) ⇒ Mortal (Socrates)
By Bal Krishna Subedi 13
Artificial Intelligence Knowledge & Reasoning
Reduction to Propositional Inference
How to convert quantified sentence to nonquantified?
∀x Student (x, CSG) ⇒ Needs (x, AI) is equivalent to
Student (John, CSG) ⇒ Needs (John, AI)
∧ Student (Richard, CSG) ⇒ Needs (Richard, AI)
∧ Student (Mike, CSG) ⇒ Needs (Mike, AI) ∧ ...
An existential quantifier sentence replaced by one instances where as
universal quantifier replaced by the set all possible instances.
Now we can apply any propositional inference rules.
By Bal Krishna Subedi 14
Artificial Intelligence Knowledge & Reasoning
Example
Bob is a buffalo. 1. Buffalo(Bob)
Pat is a pig 2. Pig(Pat)
Buffaloes run faster than pigs 3. ∀x, y Buffalo(x) ^ Pig(y) ⇒ Faster(x, y).
Bob runs faster than Pat ..?
From 1&2 (and-introduction) 4. Buffalo(Bob) ^ Pig(Pat)
∀ Elimination {x/Bob, y/Pat}5. Buffalo(Bob) ^ Pig(Pat) ⇒ Faster(Bob, Pat)
Modus Ponen 4 & 5 6. Faster(Bob, Pat)
Problem: branching factor huge –inefficient approach.
By Bal Krishna Subedi 15
Artificial Intelligence Knowledge & Reasoning
Generalized Modus Ponens (GMP)
n atomic sentence (p’i )and one implication, and the conclusion is
the result of applying the substitution (σ) to the consequent (q).
E.g. p’1= Faster(Bob,Pat)
p’2 = Faster(Pat,Steve)
p1 ^ p2 ⇒ q = Faster(x,y) ^ Faster(y, z) ⇒ Faster(x, z)
σ = {x/Bob, y/Pat, z/Steve}
qσ = Faster(Bob, Steve)
GMP used with KB of definite clauses (exactly one positive literal in conclusion):
either a atomic sentence or (conjunction of atomic sentences) ⇒ (atomic sentence)
All variables assumed universally quantified
By Bal Krishna Subedi 16
Artificial Intelligence Knowledge & Reasoning
Unification
To apply inference rule (e.g Modus Ponen) an inference system must
be able to find substitutions that make different logical expression
look identical.
Unification is an algorithm for determining the such substitutions
needed to make two predicate expression identical.
E. g., is P(x) and P(y) equivalent? – when y is substituted by x.
By Bal Krishna Subedi 17
Artificial Intelligence Knowledge & Reasoning
Unification
A substitution σ unifies atomic sentences p and q if pσ = qσ
p q σ
Knows(John, x) Knows(John, Jane) {x/Jane}
Knows(John, x) Knows(y,OJ) {x/John, y/OJ}
Knows(John, x) Knows(y, Mother(y)) {y/John, x/Mother(John)}
Idea: Unify rule premises with known facts, apply unifier to conclusion
E.g., if we know q and Knows(John, x) ⇒ Likes(John, x)
then we conclude Likes(John, Jane)
Likes(John,OJ)
Likes(John, Mother(John))
By Bal Krishna Subedi 18
Artificial Intelligence Knowledge & Reasoning
Most General Unifier (MGU)
Let the premises:
Knows(John, x) Knows(y, z)
The unify algorithm can return {y/John, x/z} or {x/John, y/John,
z/John} for the given premises.
The first gives the unification result as Knows(John, z) and second
gives Knows(John, John)
The first is more general then second.
For every unifiable pair of expressions, there is single most general
unifier that is unique up to the remaining of variables.
By Bal Krishna Subedi 19
Artificial Intelligence Knowledge & Reasoning
Predicate Definite Clauses
A definite clause is either a atomic sentence or a implication
whose antecedent is a conjunction of positive literals and whose
consequent is a single positive literal.
Buffalo(Bob).
Pig(Pat).
Buffalo(x) ^ Pig(y) ⇒ Faster(x, y).
- Universal quantifier is omitted.
Definite clauses are suitable normal form for use with GMP.
Problem: Not all knowledge bases can be converted into a set
of definite clauses, because of single positive restriction.
By Bal Krishna Subedi 20
Artificial Intelligence Knowledge & Reasoning
Forward chaining
When a new fact p is added to the KB
for each rule such that p unifies with a premise
if the other premises are known
then add the conclusion to the KB and continue
chaining
Forward chaining is also called data-driven reasoning
e.g., inferring properties and categories from percepts
By Bal Krishna Subedi 21
Artificial Intelligence Knowledge & Reasoning
Forward chaining example
Add facts 1, 2, 3, 4, 5, 6 in turn.
1. Buffalo(x) ^ Pig(y) ⇒ Faster(x, y)
2. Pig(y) ^ Slug(z) ⇒ Faster(y, z)
3. Faster(x, y) ^ Faster(y, z) ⇒ Faster(x, z)
4. Buffalo(Bob)
5. Pig(Pat)
6. Slug(Steve)
On the first iteration: {x/Bob, y/Pat, z/steve}
On the second iteration:
rule 1 is satisfied and Faster(Bob, Pat) is added
rule 2 is satisfied and Faster(Pat, Steve) is added
7. Faster(Bob, Pat)
8. Faster(Pat, Steve)
On the 3rd iteration: rule 3 is satisfied and Faster(Bob, Steve)
9. Faster(Bob, Steve)
By Bal Krishna Subedi 22
Artificial Intelligence Knowledge & Reasoning
Backward Chaining
When a query q is asked
if a matching fact q’ is known, return the unifier
for each rule whose consequent q’ matches q
attempt to prove each premise of the rule by backward
chaining
It is a recursive call, when goal unifies with known fact, no new subgoals
are added and the goal is solved.
Some added complications in keeping track of the unifiers.
More complications help to avoid infinite loops.
Two versions: find any solution, find all solutions.
Backward chaining is the basis for logic programming, e.g., Prolog
Back ward chaining also called goal-driven reasoning.
By Bal Krishna Subedi 23
Artificial Intelligence Knowledge & Reasoning
Backward chaining example
By Bal Krishna Subedi 24
Query
Faster(Pat, Steve)
Artificial Intelligence Knowledge & Reasoning
Resolution
Resolution inference rule combines two clauses to make a new one
C1 C2
C
Inference continues until an empty clause is derived (contradiction)
Resolution is a refutation procedure.
to prove KB |= α , show that KB ^ ¬ α is unsatisable
Resolution uses KB in CNF (conjunction of clauses)
By Bal Krishna Subedi 25
Artificial Intelligence Knowledge & Reasoning
Resolution inference rule
By Bal Krishna Subedi 26
Artificial Intelligence Knowledge & Reasoning
Conjunctive Normal Form
Literal = (possibly negated) atomic sentence. e.g., ¬ Rich(Me)
Clause = disjunction of literals, e.g., ¬ Rich(Me) ∨ Unhappy(Me)
The KB is a conjunction of clauses
Any predicate KB can be converted to CNF as follows:
1. Replace P ⇒ Q by ¬ P ∨ Q.
2. Move ¬ inwards, e.g., ¬∀x P becomes ∃x ¬P.
3. Standardize variables apart, e.g., ∀x P ∨ ∃x Q becomes ∀x P ∨ ∃y Q.
4. Move quantifiers left in order, e.g., ∀x P ∨ ∃y Q becomes ∀x ∃y P ∨ Q.
5. Eliminate ∃ by Skolemization (next slide).
6. Drop universal quantifiers.
7. Distribute ^ over ∨, e.g., (P ^ Q) ∨ R becomes (P ∨ Q) ^ (P ∨ R).
By Bal Krishna Subedi 27
Artificial Intelligence Knowledge & Reasoning
Skolemization
Skolemization is the process of removing existential quantifiers by
elimination.
∃x Rich(x) becomes Rich(G1) where G1 is a new “Skolem constant”
More tricky when ∃ is inside ∀
E.g., “Everyone has a heart"
∀x Person(x) ⇒ ∃y Heart(y) ^ Has(x, y)
Incorrect:
∀x Person(x) ⇒ Heart(H1) ^ Has(x, H1)
Correct:
∀x Person(x) ⇒ Heart(H(x)) ^ Has(x, H(x))
where H is a new symbol (“Skolem function")
Skolem function arguments: universally quantified variables
By Bal Krishna Subedi 28
Artificial Intelligence Knowledge & Reasoning
Resolution proof
To prove α:
- negate it
- convert to CNF
- add to CNF KB
- infer contradiction
E.g., to prove Rich(me), add ¬Rich(me) to the CNF KB
¬ PhD(x) ∨ HighlyQualified(x)
PhD(x) ∨ EarlyEarnings(x)
¬ HighlyQualified(x) ∨ Rich(x)
¬ EarlyEarnings(x) ∨ Rich(x)
By Bal Krishna Subedi 29
Artificial Intelligence Knowledge & Reasoning
Resolution proof
By Bal Krishna Subedi 30
Artificial Intelligence Knowledge & Reasoning
Completeness of Resolution
• Resolution is complete (for proof see page 300) and usually
necessary for mathematics.
• Completeness theorem by German mathematician KURT
Gaedel in 1930, J. A. Robinsion published resolution
algorithm in 1965.
• Automated theorem provers are starting to be useful to
mathematicians and have proved several new theorems; it has
been used to verify hardware designs and to generate logically
correct programs.
• Other detailed examples of resolution can be found on pages
298-300.
By Bal Krishna Subedi 31
Artificial Intelligence Knowledge & Reasoning
Home Works
For Home Works see logic homework.pdf
By Bal Krishna Subedi 32

More Related Content

What's hot

Forms of learning in ai
Forms of learning in aiForms of learning in ai
Forms of learning in aiRobert Antony
 
First Order Logic resolution
First Order Logic resolutionFirst Order Logic resolution
First Order Logic resolutionAmar Jukuntla
 
Artificial Intelligence - Propositional Logic
Artificial Intelligence - Propositional LogicArtificial Intelligence - Propositional Logic
Artificial Intelligence - Propositional LogicSaravanan T.M
 
Propositional logic & inference
Propositional logic & inferencePropositional logic & inference
Propositional logic & inferenceSlideshare
 
What is knowledge representation and reasoning ?
What is knowledge representation and reasoning ?What is knowledge representation and reasoning ?
What is knowledge representation and reasoning ?Anant Soft Computing
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptkarthikaparthasarath
 
Resolution method in AI.pptx
Resolution method in AI.pptxResolution method in AI.pptx
Resolution method in AI.pptxAbdullah251975
 
Logics for non monotonic reasoning-ai
Logics for non monotonic reasoning-aiLogics for non monotonic reasoning-ai
Logics for non monotonic reasoning-aiShaishavShah8
 
First order predicate logic (fopl)
First order predicate logic (fopl)First order predicate logic (fopl)
First order predicate logic (fopl)chauhankapil
 
Propositional logic
Propositional logicPropositional logic
Propositional logicRushdi Shams
 
Syntax and semantics of propositional logic
Syntax and semantics of propositional logicSyntax and semantics of propositional logic
Syntax and semantics of propositional logicJanet Stemwedel
 
Artificial Intelligence 1 Planning In The Real World
Artificial Intelligence 1 Planning In The Real WorldArtificial Intelligence 1 Planning In The Real World
Artificial Intelligence 1 Planning In The Real Worldahmad bassiouny
 
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...vikas dhakane
 
Discrete Mathematics - Propositional Logic
Discrete Mathematics - Propositional LogicDiscrete Mathematics - Propositional Logic
Discrete Mathematics - Propositional LogicUniversity of Potsdam
 

What's hot (20)

Forms of learning in ai
Forms of learning in aiForms of learning in ai
Forms of learning in ai
 
First Order Logic resolution
First Order Logic resolutionFirst Order Logic resolution
First Order Logic resolution
 
Artificial Intelligence - Propositional Logic
Artificial Intelligence - Propositional LogicArtificial Intelligence - Propositional Logic
Artificial Intelligence - Propositional Logic
 
Propositional logic & inference
Propositional logic & inferencePropositional logic & inference
Propositional logic & inference
 
What is knowledge representation and reasoning ?
What is knowledge representation and reasoning ?What is knowledge representation and reasoning ?
What is knowledge representation and reasoning ?
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.ppt
 
Forward Backward Chaining
Forward Backward ChainingForward Backward Chaining
Forward Backward Chaining
 
Resolution method in AI.pptx
Resolution method in AI.pptxResolution method in AI.pptx
Resolution method in AI.pptx
 
Logics for non monotonic reasoning-ai
Logics for non monotonic reasoning-aiLogics for non monotonic reasoning-ai
Logics for non monotonic reasoning-ai
 
First order predicate logic (fopl)
First order predicate logic (fopl)First order predicate logic (fopl)
First order predicate logic (fopl)
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
 
First order logic
First order logicFirst order logic
First order logic
 
Syntax and semantics of propositional logic
Syntax and semantics of propositional logicSyntax and semantics of propositional logic
Syntax and semantics of propositional logic
 
Unit8: Uncertainty in AI
Unit8: Uncertainty in AIUnit8: Uncertainty in AI
Unit8: Uncertainty in AI
 
Bayes learning
Bayes learningBayes learning
Bayes learning
 
AI_Session 20 Horn clause.pptx
AI_Session 20 Horn clause.pptxAI_Session 20 Horn clause.pptx
AI_Session 20 Horn clause.pptx
 
Artificial Intelligence 1 Planning In The Real World
Artificial Intelligence 1 Planning In The Real WorldArtificial Intelligence 1 Planning In The Real World
Artificial Intelligence 1 Planning In The Real World
 
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
 
First order logic
First order logicFirst order logic
First order logic
 
Discrete Mathematics - Propositional Logic
Discrete Mathematics - Propositional LogicDiscrete Mathematics - Propositional Logic
Discrete Mathematics - Propositional Logic
 

Similar to Logic 2

AI_05_First Order Logic.pptx
AI_05_First Order Logic.pptxAI_05_First Order Logic.pptx
AI_05_First Order Logic.pptxYousef Aburawi
 
Exchanging More than Complete Data
Exchanging More than Complete DataExchanging More than Complete Data
Exchanging More than Complete Datanet2-project
 
Chapter 01 - p2.pdf
Chapter 01 - p2.pdfChapter 01 - p2.pdf
Chapter 01 - p2.pdfsmarwaneid
 
Discrete Structure Lecture #5 & 6.pdf
Discrete Structure Lecture #5 & 6.pdfDiscrete Structure Lecture #5 & 6.pdf
Discrete Structure Lecture #5 & 6.pdfMuhammadUmerIhtisham
 
Presentation X-SHS - 27 oct 2015 - Topologie et perception
Presentation X-SHS - 27 oct 2015 - Topologie et perceptionPresentation X-SHS - 27 oct 2015 - Topologie et perception
Presentation X-SHS - 27 oct 2015 - Topologie et perceptionMichel Paillet
 
Theory of Relational Calculus and its Formalization
Theory of Relational Calculus and its FormalizationTheory of Relational Calculus and its Formalization
Theory of Relational Calculus and its FormalizationYoshihiro Mizoguchi
 
Jarrar.lecture notes.aai.2011s.ch9.fol.inference
Jarrar.lecture notes.aai.2011s.ch9.fol.inferenceJarrar.lecture notes.aai.2011s.ch9.fol.inference
Jarrar.lecture notes.aai.2011s.ch9.fol.inferencePalGov
 
Jarrar.lecture notes.aai.2011s.ch9.fol.inference
Jarrar.lecture notes.aai.2011s.ch9.fol.inferenceJarrar.lecture notes.aai.2011s.ch9.fol.inference
Jarrar.lecture notes.aai.2011s.ch9.fol.inferencePalGov
 
GDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision MakingGDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision MakingGDSCSSN
 
L03 ai - knowledge representation using logic
L03 ai - knowledge representation using logicL03 ai - knowledge representation using logic
L03 ai - knowledge representation using logicManjula V
 
Discrete Mathematics - All chapters
Discrete Mathematics - All chapters Discrete Mathematics - All chapters
Discrete Mathematics - All chapters Omnia A. Abdullah
 

Similar to Logic 2 (20)

Per3 logika
Per3 logikaPer3 logika
Per3 logika
 
AI_05_First Order Logic.pptx
AI_05_First Order Logic.pptxAI_05_First Order Logic.pptx
AI_05_First Order Logic.pptx
 
Quantification
QuantificationQuantification
Quantification
 
continuity of module 2.pptx
continuity of module 2.pptxcontinuity of module 2.pptx
continuity of module 2.pptx
 
Module_5_1.pptx
Module_5_1.pptxModule_5_1.pptx
Module_5_1.pptx
 
lect14-semantics.ppt
lect14-semantics.pptlect14-semantics.ppt
lect14-semantics.ppt
 
01bkb04p.ppt
01bkb04p.ppt01bkb04p.ppt
01bkb04p.ppt
 
Exchanging More than Complete Data
Exchanging More than Complete DataExchanging More than Complete Data
Exchanging More than Complete Data
 
Chapter 01 - p2.pdf
Chapter 01 - p2.pdfChapter 01 - p2.pdf
Chapter 01 - p2.pdf
 
Discrete Structure Lecture #5 & 6.pdf
Discrete Structure Lecture #5 & 6.pdfDiscrete Structure Lecture #5 & 6.pdf
Discrete Structure Lecture #5 & 6.pdf
 
3 fol examples v2
3 fol examples v23 fol examples v2
3 fol examples v2
 
Presentation X-SHS - 27 oct 2015 - Topologie et perception
Presentation X-SHS - 27 oct 2015 - Topologie et perceptionPresentation X-SHS - 27 oct 2015 - Topologie et perception
Presentation X-SHS - 27 oct 2015 - Topologie et perception
 
Theory of Relational Calculus and its Formalization
Theory of Relational Calculus and its FormalizationTheory of Relational Calculus and its Formalization
Theory of Relational Calculus and its Formalization
 
Nested loop
Nested loopNested loop
Nested loop
 
Jarrar.lecture notes.aai.2011s.ch9.fol.inference
Jarrar.lecture notes.aai.2011s.ch9.fol.inferenceJarrar.lecture notes.aai.2011s.ch9.fol.inference
Jarrar.lecture notes.aai.2011s.ch9.fol.inference
 
Jarrar.lecture notes.aai.2011s.ch9.fol.inference
Jarrar.lecture notes.aai.2011s.ch9.fol.inferenceJarrar.lecture notes.aai.2011s.ch9.fol.inference
Jarrar.lecture notes.aai.2011s.ch9.fol.inference
 
GDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision MakingGDSC SSN - solution Challenge : Fundamentals of Decision Making
GDSC SSN - solution Challenge : Fundamentals of Decision Making
 
Dscrete structure
Dscrete  structureDscrete  structure
Dscrete structure
 
L03 ai - knowledge representation using logic
L03 ai - knowledge representation using logicL03 ai - knowledge representation using logic
L03 ai - knowledge representation using logic
 
Discrete Mathematics - All chapters
Discrete Mathematics - All chapters Discrete Mathematics - All chapters
Discrete Mathematics - All chapters
 

More from Tribhuvan University (20)

Lecture 7 se
Lecture 7 seLecture 7 se
Lecture 7 se
 
Lecture 6 se
Lecture 6 seLecture 6 se
Lecture 6 se
 
Lecture 5 se
Lecture 5 seLecture 5 se
Lecture 5 se
 
Lecture 3 se
Lecture 3 seLecture 3 se
Lecture 3 se
 
Lecture 1 se
Lecture 1 seLecture 1 se
Lecture 1 se
 
Lecture 2 se
Lecture 2 seLecture 2 se
Lecture 2 se
 
Lecture 5 m&amp;ca
Lecture 5 m&amp;caLecture 5 m&amp;ca
Lecture 5 m&amp;ca
 
Lecture 4 m&amp;ca
Lecture 4 m&amp;caLecture 4 m&amp;ca
Lecture 4 m&amp;ca
 
Lecture 3 m&amp;ca
Lecture 3 m&amp;caLecture 3 m&amp;ca
Lecture 3 m&amp;ca
 
Lecture 2 m&amp;ca
Lecture 2 m&amp;caLecture 2 m&amp;ca
Lecture 2 m&amp;ca
 
Lecture 1 m&amp;ca
Lecture 1 m&amp;caLecture 1 m&amp;ca
Lecture 1 m&amp;ca
 
Neural network (csc372) lecture 2
Neural network (csc372) lecture 2Neural network (csc372) lecture 2
Neural network (csc372) lecture 2
 
Neural network (csc372) lecture 1
Neural network (csc372) lecture 1Neural network (csc372) lecture 1
Neural network (csc372) lecture 1
 
Ai unit-2
Ai unit-2Ai unit-2
Ai unit-2
 
Ai unit-3
Ai unit-3Ai unit-3
Ai unit-3
 
Ai unit-4
Ai unit-4Ai unit-4
Ai unit-4
 
Unit 4(nlp _neural_network)
Unit 4(nlp _neural_network)Unit 4(nlp _neural_network)
Unit 4(nlp _neural_network)
 
Ai unit-6
Ai unit-6Ai unit-6
Ai unit-6
 
Ai unit-1
Ai unit-1Ai unit-1
Ai unit-1
 
Knowldge reprsentations
Knowldge reprsentationsKnowldge reprsentations
Knowldge reprsentations
 

Recently uploaded

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 

Recently uploaded (20)

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 

Logic 2

  • 1. Artificial Intelligence Knowledge & Reasoning Predicate Logic. Reading: Sections 8.1, 8.2 & 8.3 of Textbook R&N The world is blessed with many objects, some of which are related to other objects. Objects: people, houses, numbers, colors, baseball games, wars, … Relations: red, round, brother of, bigger than, part of, comes between, … How to represent the objects and their relation? By Bal Krishna Subedi 1
  • 2. Artificial Intelligence Knowledge & Reasoning Predicate Logic: Basic Elements Constants: John, 2, TU,... Predicates Brother, >,... Functions Sqrt, LeftLegOf,... Variables x, y, a, b,... Connectives ¬, ⇒, ∧, ∨, ⇔ Equality = Quantifiers ∀, ∃ By Bal Krishna Subedi 2
  • 3. Artificial Intelligence Knowledge & Reasoning Predicate Logic: Syntax Sentence → AtomicSentence | (Sentence Connective Sentence) | Quantifier Variable, ... Sentence | ¬ Sentence AtomicSentence → Predicate(Term, …) | Term = Term Term → Function(Term, …) | Constant | Variable Connective → ∧ | ∨ | ⇒ | ⇔ Quantifier → ∀ | ∃ Constant → A, B, C, X1 , X2, Jim, Jack Variable → a, b, c, x1 , x2, counter, position, ... Predicate → Adjacent-To, Younger-Than, HasColor, ... Function → Father-Of, Square-Position, Sqrt, Cosine ambiguities are resolved through precedence or parentheses By Bal Krishna Subedi 3
  • 4. Artificial Intelligence Knowledge & Reasoning Sentences Atomic Sentence: A atomic sentence is formed from a predicate symbol followed by a parenthesized list of terms. E.g., Brother (Bill, Mary), Father (Jack, John), Mother (Jill, John), Sister (Jane, John) Married (Jack, Jill) BrotherOf (Bill) = Bob Complex Sentence: Complex sentences are made from atomic sentences using connectives. E.g., Sibling (Tom, Bill) ⇒ Sibling (Bill, Tom). Father (Jack, John) ∧ Mother (Jill, John) ∧ Sister (Jane, John). ¬ Sister (John, Jane). Older (Father-Of (John), 30) ∨ Older (Mother-Of (John), 20). By Bal Krishna Subedi 4
  • 5. Artificial Intelligence Knowledge & Reasoning Truth in first-order logic Sentences are true with respect to a model and an interpretation Model contains objects (domain elements) and relations among them. Interpretation specifies referents for constant symbols → objects. predicate symbols → relations. function symbols → functional relations. An atomic sentence predicate(term1,...,termn) is true iff the objects referred to by term1,...,termn are in the relation referred to by predicate. Syntactically correct logical formulas are called well-formed formulas (wff). Such wff are thus used to represent real-world facts. By Bal Krishna Subedi 5
  • 6. Artificial Intelligence Knowledge & Reasoning Quantifiers • can be used to express properties of the collections of objects – eliminates the need to explicitly enumerate all objects • predicate logic uses two quantifiers – universal quantifier ∀ : We can make a statement for all the objects in the universe – existential quantifier ∃ :We can make a statement about some objects in the universe By Bal Krishna Subedi 6
  • 7. Artificial Intelligence Knowledge & Reasoning Universal Quantification ∀<variables> <sentence> Every CSG student needs a course in AI: ∀x Student (x, CSG) ⇒ Needs (x, AI) ∀x P is equivalent to the conjunction of instantiations of P and is interpreted as P(x) is true for any possible x from the universe. E.g., ∀x Student (x, CSG) ⇒ Needs (x, AI) is equivalent to claiming that Student (John, CSG) ⇒ Needs (John, AI) ∧ Student (Richard, CSG) ⇒ Needs (Richard, AI) ∧ Student (Mike, CSG) ⇒ Needs (Mike, AI) ∧ ... Typically, ⇒ is the main connective with ∀. A common mistake to avoid: using ∧ as the main connective with ∀: ∀x Student (x, CSG) ∧ Needs (x, AI) means “Everyone are CSG student and everyone needs AI” – very strong statement - does not reflect the semantic. By Bal Krishna Subedi 7
  • 8. Artificial Intelligence Knowledge & Reasoning Existential Quantification ∃<variables> <sentence> Someone at CDCSIT is smart: ∃x At (x, CDCSIT) ∧ Smart (x) ∃x P is equivalent to the disjunction of instantiations of P and is interpreted as P(x) is true for some object x in the universe. E. g., ∃x At (x, CDCSIT) ∧ Smart (x) is equivalent to claiming that At (John, CDCSIT) ∧ Smart (John) ∨ At (Richard, CDCSIT) ∧ Smart (Richard) ∨ At (Mike, CDCSIT) ∧ Smart (Mike) ∨ ... Typically, ∧ is the main connective with ∃ Common mistake: using ⇒ as the main connective with ∃: ∃x At (x, CDCSIT) ⇒ Smart (x) is true if there is anyone who is not at CDCSIT – very weak statement - does not reflect the semantic. By Bal Krishna Subedi 8
  • 9. Artificial Intelligence Knowledge & Reasoning Multiple Quantifiers more complex sentences can be formulated by multiple variables and by nesting quantifiers – the order of quantification is important – variables must be introduced by quantifiers, and belong to the innermost quantifier that mention them Examples ∀x ∀y Brother (x, y) ⇒ Sibling (x, y) ∀x, y Parent (x, y) ⇒ Child (y, x) ∀x Human (x) ∃ y Mother (y, x) ∀x ∃ y Loves (x, y) By Bal Krishna Subedi 9
  • 10. Artificial Intelligence Knowledge & Reasoning Properties of quantifiers ∀x ∀y is the same as ∀y ∀x. ∃x ∃y is the same as ∃y ∃x. ∃x ∀y is not the same as ∀y ∃x. ∃x ∀y Loves (x, y) “There is a person who loves everyone in the world”. ∀y ∃x Loves (x, y) “Everyone in the world is loved by at least one person” Quantifier duality: each can be expressed using the other. ∀x Likes (x, IceCream) ¬∃x ¬Likes (x, IceCream). ∃x Likes (x, Cabbage) ¬∀x ¬Likes (x, Cabbage). By Bal Krishna Subedi 10
  • 11. Artificial Intelligence Knowledge & Reasoning Some Examples Everybody loves Jerry: ∀x Loves (x, Jerry) Everybody loves somebody: ∀x ∃y Loves (x, y) Brothers are siblings: ∀x, y Brother (x, y) ⇒ Sibling (x, y) “Sibling” is reflexive: ∀x, y Sibling (x, y) ⇔ Sibling (y, x) One's mother is one's female parent: ∀ x, y Mother (x, y) ⇔ (Female (x) ^ Parent (x, y)) A cousin is a child of a parent's sibling: ∀ x, y Cousin (x, y) ⇔ ∃ p, ps Parent (p, x) ^ Sibling (ps, p) ^Parent (ps, y) By Bal Krishna Subedi 11
  • 12. Artificial Intelligence Knowledge & Reasoning Inference With Predicate Logic Reading: Chapter 9 of Textbook R&N How to answer the questions if KB represented in Predicate logic? By Bal Krishna Subedi 12
  • 13. Artificial Intelligence Knowledge & Reasoning Inference rules for Quantifiers Universal Instantiation: if ∀ x P(x) is true then P(A) is true for any individual “A”. E.g., If we know that ∀ x Man (x) ⇒ Mortal (x), then we can conclude Man (Socrates) ⇒ Mortal (Socrates) By Bal Krishna Subedi 13
  • 14. Artificial Intelligence Knowledge & Reasoning Reduction to Propositional Inference How to convert quantified sentence to nonquantified? ∀x Student (x, CSG) ⇒ Needs (x, AI) is equivalent to Student (John, CSG) ⇒ Needs (John, AI) ∧ Student (Richard, CSG) ⇒ Needs (Richard, AI) ∧ Student (Mike, CSG) ⇒ Needs (Mike, AI) ∧ ... An existential quantifier sentence replaced by one instances where as universal quantifier replaced by the set all possible instances. Now we can apply any propositional inference rules. By Bal Krishna Subedi 14
  • 15. Artificial Intelligence Knowledge & Reasoning Example Bob is a buffalo. 1. Buffalo(Bob) Pat is a pig 2. Pig(Pat) Buffaloes run faster than pigs 3. ∀x, y Buffalo(x) ^ Pig(y) ⇒ Faster(x, y). Bob runs faster than Pat ..? From 1&2 (and-introduction) 4. Buffalo(Bob) ^ Pig(Pat) ∀ Elimination {x/Bob, y/Pat}5. Buffalo(Bob) ^ Pig(Pat) ⇒ Faster(Bob, Pat) Modus Ponen 4 & 5 6. Faster(Bob, Pat) Problem: branching factor huge –inefficient approach. By Bal Krishna Subedi 15
  • 16. Artificial Intelligence Knowledge & Reasoning Generalized Modus Ponens (GMP) n atomic sentence (p’i )and one implication, and the conclusion is the result of applying the substitution (σ) to the consequent (q). E.g. p’1= Faster(Bob,Pat) p’2 = Faster(Pat,Steve) p1 ^ p2 ⇒ q = Faster(x,y) ^ Faster(y, z) ⇒ Faster(x, z) σ = {x/Bob, y/Pat, z/Steve} qσ = Faster(Bob, Steve) GMP used with KB of definite clauses (exactly one positive literal in conclusion): either a atomic sentence or (conjunction of atomic sentences) ⇒ (atomic sentence) All variables assumed universally quantified By Bal Krishna Subedi 16
  • 17. Artificial Intelligence Knowledge & Reasoning Unification To apply inference rule (e.g Modus Ponen) an inference system must be able to find substitutions that make different logical expression look identical. Unification is an algorithm for determining the such substitutions needed to make two predicate expression identical. E. g., is P(x) and P(y) equivalent? – when y is substituted by x. By Bal Krishna Subedi 17
  • 18. Artificial Intelligence Knowledge & Reasoning Unification A substitution σ unifies atomic sentences p and q if pσ = qσ p q σ Knows(John, x) Knows(John, Jane) {x/Jane} Knows(John, x) Knows(y,OJ) {x/John, y/OJ} Knows(John, x) Knows(y, Mother(y)) {y/John, x/Mother(John)} Idea: Unify rule premises with known facts, apply unifier to conclusion E.g., if we know q and Knows(John, x) ⇒ Likes(John, x) then we conclude Likes(John, Jane) Likes(John,OJ) Likes(John, Mother(John)) By Bal Krishna Subedi 18
  • 19. Artificial Intelligence Knowledge & Reasoning Most General Unifier (MGU) Let the premises: Knows(John, x) Knows(y, z) The unify algorithm can return {y/John, x/z} or {x/John, y/John, z/John} for the given premises. The first gives the unification result as Knows(John, z) and second gives Knows(John, John) The first is more general then second. For every unifiable pair of expressions, there is single most general unifier that is unique up to the remaining of variables. By Bal Krishna Subedi 19
  • 20. Artificial Intelligence Knowledge & Reasoning Predicate Definite Clauses A definite clause is either a atomic sentence or a implication whose antecedent is a conjunction of positive literals and whose consequent is a single positive literal. Buffalo(Bob). Pig(Pat). Buffalo(x) ^ Pig(y) ⇒ Faster(x, y). - Universal quantifier is omitted. Definite clauses are suitable normal form for use with GMP. Problem: Not all knowledge bases can be converted into a set of definite clauses, because of single positive restriction. By Bal Krishna Subedi 20
  • 21. Artificial Intelligence Knowledge & Reasoning Forward chaining When a new fact p is added to the KB for each rule such that p unifies with a premise if the other premises are known then add the conclusion to the KB and continue chaining Forward chaining is also called data-driven reasoning e.g., inferring properties and categories from percepts By Bal Krishna Subedi 21
  • 22. Artificial Intelligence Knowledge & Reasoning Forward chaining example Add facts 1, 2, 3, 4, 5, 6 in turn. 1. Buffalo(x) ^ Pig(y) ⇒ Faster(x, y) 2. Pig(y) ^ Slug(z) ⇒ Faster(y, z) 3. Faster(x, y) ^ Faster(y, z) ⇒ Faster(x, z) 4. Buffalo(Bob) 5. Pig(Pat) 6. Slug(Steve) On the first iteration: {x/Bob, y/Pat, z/steve} On the second iteration: rule 1 is satisfied and Faster(Bob, Pat) is added rule 2 is satisfied and Faster(Pat, Steve) is added 7. Faster(Bob, Pat) 8. Faster(Pat, Steve) On the 3rd iteration: rule 3 is satisfied and Faster(Bob, Steve) 9. Faster(Bob, Steve) By Bal Krishna Subedi 22
  • 23. Artificial Intelligence Knowledge & Reasoning Backward Chaining When a query q is asked if a matching fact q’ is known, return the unifier for each rule whose consequent q’ matches q attempt to prove each premise of the rule by backward chaining It is a recursive call, when goal unifies with known fact, no new subgoals are added and the goal is solved. Some added complications in keeping track of the unifiers. More complications help to avoid infinite loops. Two versions: find any solution, find all solutions. Backward chaining is the basis for logic programming, e.g., Prolog Back ward chaining also called goal-driven reasoning. By Bal Krishna Subedi 23
  • 24. Artificial Intelligence Knowledge & Reasoning Backward chaining example By Bal Krishna Subedi 24 Query Faster(Pat, Steve)
  • 25. Artificial Intelligence Knowledge & Reasoning Resolution Resolution inference rule combines two clauses to make a new one C1 C2 C Inference continues until an empty clause is derived (contradiction) Resolution is a refutation procedure. to prove KB |= α , show that KB ^ ¬ α is unsatisable Resolution uses KB in CNF (conjunction of clauses) By Bal Krishna Subedi 25
  • 26. Artificial Intelligence Knowledge & Reasoning Resolution inference rule By Bal Krishna Subedi 26
  • 27. Artificial Intelligence Knowledge & Reasoning Conjunctive Normal Form Literal = (possibly negated) atomic sentence. e.g., ¬ Rich(Me) Clause = disjunction of literals, e.g., ¬ Rich(Me) ∨ Unhappy(Me) The KB is a conjunction of clauses Any predicate KB can be converted to CNF as follows: 1. Replace P ⇒ Q by ¬ P ∨ Q. 2. Move ¬ inwards, e.g., ¬∀x P becomes ∃x ¬P. 3. Standardize variables apart, e.g., ∀x P ∨ ∃x Q becomes ∀x P ∨ ∃y Q. 4. Move quantifiers left in order, e.g., ∀x P ∨ ∃y Q becomes ∀x ∃y P ∨ Q. 5. Eliminate ∃ by Skolemization (next slide). 6. Drop universal quantifiers. 7. Distribute ^ over ∨, e.g., (P ^ Q) ∨ R becomes (P ∨ Q) ^ (P ∨ R). By Bal Krishna Subedi 27
  • 28. Artificial Intelligence Knowledge & Reasoning Skolemization Skolemization is the process of removing existential quantifiers by elimination. ∃x Rich(x) becomes Rich(G1) where G1 is a new “Skolem constant” More tricky when ∃ is inside ∀ E.g., “Everyone has a heart" ∀x Person(x) ⇒ ∃y Heart(y) ^ Has(x, y) Incorrect: ∀x Person(x) ⇒ Heart(H1) ^ Has(x, H1) Correct: ∀x Person(x) ⇒ Heart(H(x)) ^ Has(x, H(x)) where H is a new symbol (“Skolem function") Skolem function arguments: universally quantified variables By Bal Krishna Subedi 28
  • 29. Artificial Intelligence Knowledge & Reasoning Resolution proof To prove α: - negate it - convert to CNF - add to CNF KB - infer contradiction E.g., to prove Rich(me), add ¬Rich(me) to the CNF KB ¬ PhD(x) ∨ HighlyQualified(x) PhD(x) ∨ EarlyEarnings(x) ¬ HighlyQualified(x) ∨ Rich(x) ¬ EarlyEarnings(x) ∨ Rich(x) By Bal Krishna Subedi 29
  • 30. Artificial Intelligence Knowledge & Reasoning Resolution proof By Bal Krishna Subedi 30
  • 31. Artificial Intelligence Knowledge & Reasoning Completeness of Resolution • Resolution is complete (for proof see page 300) and usually necessary for mathematics. • Completeness theorem by German mathematician KURT Gaedel in 1930, J. A. Robinsion published resolution algorithm in 1965. • Automated theorem provers are starting to be useful to mathematicians and have proved several new theorems; it has been used to verify hardware designs and to generate logically correct programs. • Other detailed examples of resolution can be found on pages 298-300. By Bal Krishna Subedi 31
  • 32. Artificial Intelligence Knowledge & Reasoning Home Works For Home Works see logic homework.pdf By Bal Krishna Subedi 32