SlideShare a Scribd company logo
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

Backtracking
BacktrackingBacktracking
Backtracking
Pranay Meshram
 
Artificial Intelligence Notes Unit 3
Artificial Intelligence Notes Unit 3Artificial Intelligence Notes Unit 3
Artificial Intelligence Notes Unit 3
DigiGurukul
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.ppt
karthikaparthasarath
 
5 csp
5 csp5 csp
5 csp
Mhd Sb
 
AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)
Tajim Md. Niamat Ullah Akhund
 
First order logic
First order logicFirst order logic
First order logic
Megha Sharma
 
Fuzzy logic and application in AI
Fuzzy logic and application in AIFuzzy logic and application in AI
Fuzzy logic and application in AI
Ildar Nurgaliev
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 
AI Greedy & A* Informed Search Strategies by Example
AI Greedy & A* Informed Search Strategies by ExampleAI Greedy & A* Informed Search Strategies by Example
AI Greedy & A* Informed Search Strategies by Example
Ahmed Gad
 
Propositional logic
Propositional logicPropositional logic
Propositional logicRushdi Shams
 
Bayesian learning
Bayesian learningBayesian learning
Bayesian learning
Vignesh Saravanan
 
Learning in AI
Learning in AILearning in AI
Learning in AI
Minakshi Atre
 
Non- Deterministic Algorithms
Non- Deterministic AlgorithmsNon- Deterministic Algorithms
Non- Deterministic Algorithms
Dipankar Boruah
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
Rajendran
 
First order logic
First order logicFirst order logic
First order logic
Chinmay Patel
 
Problem solving
Problem solvingProblem solving
Problem solving
Shiwani Gupta
 
L7 fuzzy relations
L7 fuzzy relationsL7 fuzzy relations
L7 fuzzy relations
Mohammad Umar Rehman
 
Agreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared MemoryAgreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared Memory
SHIKHA GAUTAM
 
Problems, Problem spaces and Search
Problems, Problem spaces and SearchProblems, Problem spaces and Search
Problems, Problem spaces and Search
BMS Institute of Technology and Management
 

What's hot (20)

Backtracking
BacktrackingBacktracking
Backtracking
 
Artificial Intelligence Notes Unit 3
Artificial Intelligence Notes Unit 3Artificial Intelligence Notes Unit 3
Artificial Intelligence Notes Unit 3
 
Heuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.pptHeuristic Search Techniques Unit -II.ppt
Heuristic Search Techniques Unit -II.ppt
 
5 csp
5 csp5 csp
5 csp
 
AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)
 
First order logic
First order logicFirst order logic
First order logic
 
Fuzzy logic and application in AI
Fuzzy logic and application in AIFuzzy logic and application in AI
Fuzzy logic and application in AI
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
Frames
FramesFrames
Frames
 
AI Greedy & A* Informed Search Strategies by Example
AI Greedy & A* Informed Search Strategies by ExampleAI Greedy & A* Informed Search Strategies by Example
AI Greedy & A* Informed Search Strategies by Example
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
 
Bayesian learning
Bayesian learningBayesian learning
Bayesian learning
 
Learning in AI
Learning in AILearning in AI
Learning in AI
 
Non- Deterministic Algorithms
Non- Deterministic AlgorithmsNon- Deterministic Algorithms
Non- Deterministic Algorithms
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
 
First order logic
First order logicFirst order logic
First order logic
 
Problem solving
Problem solvingProblem solving
Problem solving
 
L7 fuzzy relations
L7 fuzzy relationsL7 fuzzy relations
L7 fuzzy relations
 
Agreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared MemoryAgreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared Memory
 
Problems, Problem spaces and Search
Problems, Problem spaces and SearchProblems, Problem spaces and Search
Problems, Problem spaces and Search
 

Similar to Logic 2

Per3 logika
Per3 logikaPer3 logika
First order logic in artificial Intelligence.pptx
First order logic in artificial Intelligence.pptxFirst order logic in artificial Intelligence.pptx
First order logic in artificial Intelligence.pptx
Y21IT051
 
AI_05_First Order Logic.pptx
AI_05_First Order Logic.pptxAI_05_First Order Logic.pptx
AI_05_First Order Logic.pptx
Yousef Aburawi
 
Quantification
QuantificationQuantification
Quantification
Abdur Rehman
 
continuity of module 2.pptx
continuity of module 2.pptxcontinuity of module 2.pptx
continuity of module 2.pptx
AnkitaVerma776806
 
lect14-semantics.ppt
lect14-semantics.pptlect14-semantics.ppt
lect14-semantics.ppt
RichardBobisSanAnton
 
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.pdf
smarwaneid
 
Discrete Structure Lecture #5 & 6.pdf
Discrete Structure Lecture #5 & 6.pdfDiscrete Structure Lecture #5 & 6.pdf
Discrete Structure Lecture #5 & 6.pdf
MuhammadUmerIhtisham
 
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
Michel 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 Formalization
Yoshihiro Mizoguchi
 
Nested loop
Nested loopNested loop
Nested loop
Lal Bdr. Saud
 
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 Making
GDSCSSN
 
Dscrete structure
Dscrete  structureDscrete  structure
Dscrete structure
Abdur Rehman
 
L03 ai - knowledge representation using logic
L03 ai - knowledge representation using logicL03 ai - knowledge representation using logic
L03 ai - knowledge representation using logic
Manjula V
 

Similar to Logic 2 (20)

Per3 logika
Per3 logikaPer3 logika
Per3 logika
 
First order logic in artificial Intelligence.pptx
First order logic in artificial Intelligence.pptxFirst order logic in artificial Intelligence.pptx
First order logic in artificial Intelligence.pptx
 
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
 

More from Tribhuvan University

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

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

Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 

Recently uploaded (20)

Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 

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